diff --git a/Engine/lib/CMakeLists.txt b/Engine/lib/CMakeLists.txt index c40797e34..8ea025664 100644 --- a/Engine/lib/CMakeLists.txt +++ b/Engine/lib/CMakeLists.txt @@ -252,134 +252,6 @@ if(TORQUE_SFX_OPENAL) mark_as_advanced(ALSOFT_WERROR) endif() -advanced_option(INSTALL_DOCS "" OFF) -advanced_option(INSTALL_PKG_CONFIG_MODULE "" OFF) -advanced_option(INSTALL_CMAKE_PACKAGE_MODULE "" OFF) -advanced_option(BUILD_TESTING "" OFF) -add_subdirectory(libogg ${TORQUE_LIB_TARG_DIRECTORY}/libogg ) -add_subdirectory(libvorbis ${TORQUE_LIB_TARG_DIRECTORY}/libvorbis EXCLUDE_FROM_ALL) - -advanced_option(INSTALL_PKGCONFIG_MODULES "" OFF) -advanced_option(INSTALL_CMAKE_CONFIG_MODULE "" OFF) -add_subdirectory(flac ${TORQUE_LIB_TARG_DIRECTORY}/flac EXCLUDE_FROM_ALL) - -advanced_option(INSTALL_DOCS "" OFF) -advanced_option(OPUS_INSTALL_PKG_CONFIG_MODULE "" OFF) -advanced_option(OPUS_INSTALL_CMAKE_CONFIG_MODULE "" OFF) -mark_as_advanced(OPUS_ASSERTIONS) -mark_as_advanced(OPUS_BUILD_PROGRAMS) -mark_as_advanced(OPUS_BUILD_SHARED_LIBRARY) -mark_as_advanced(OPUS_BUILD_TESTING) -mark_as_advanced(OPUS_CHECK_ASM) -mark_as_advanced(OPUS_CUSTOM_MODES) -mark_as_advanced(OPUS_DISABLE_INTRINSICS) -mark_as_advanced(OPUS_ENABLE_FLOAT_API) -mark_as_advanced(OPUS_FIXED_POINT) -mark_as_advanced(OPUS_FLOAT_APPROX) -mark_as_advanced(OPUS_FUZZING) -mark_as_advanced(OPUS_HARDENING) -mark_as_advanced(OPUS_STACK_PROTECTOR) -mark_as_advanced(OPUS_USE_ALLOCA) -mark_as_advanced(OPUS_X86_MAY_HAVE_AVX) -mark_as_advanced(OPUS_X86_MAY_HAVE_SSE) -mark_as_advanced(OPUS_X86_MAY_HAVE_SSE2) -mark_as_advanced(OPUS_X86_MAY_HAVE_SSE4_1) -mark_as_advanced(OPUS_X86_PRESUME_AVX) -mark_as_advanced(OPUS_X86_PRESUME_SSE) -mark_as_advanced(OPUS_X86_PRESUME_SSE2) -mark_as_advanced(OPUS_X86_PRESUME_SSE4_1) -add_subdirectory(opus ${TORQUE_LIB_TARG_DIRECTORY}/opus EXCLUDE_FROM_ALL) -add_subdirectory(libtheora ${TORQUE_LIB_TARG_DIRECTORY}/libtheora EXCLUDE_FROM_ALL) - -mark_as_advanced(PULSEAUDIO_INCLUDE_DIR) -mark_as_advanced(PULSEAUDIO_LIBRARY) - -# Setup python -find_package(Python3 QUIET) - -if(NOT Python3_FOUND) - if(WIN32) - message(STATUS "Python3 not found — downloading embedded Python...") - set(program_version 3.12.7) - # Detect architecture - if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") - if(TORQUE_CPU_ARM64) - set(download_url "https://www.python.org/ftp/python/${program_version}/python-${program_version}-embed-arm64.zip") - set(download_filename "python-${program_version}-embed-arm64.zip") - set(download_sha512 D1D1183682D20AC057C45BF2AD264B6568CDEB54A1502823C76A2448386CAEF79A3AB9EA8FF57A5C023D432590FCCB5E3E9980F8760CD9BAAC5A2A82BA240D73) - endif() - else() - if(TORQUE_CPU_X64) - set(download_url "https://www.python.org/ftp/python/${program_version}/python-${program_version}-embed-amd64.zip") - set(download_filename "python-${program_version}-embed-amd64.zip") - set(download_sha512 2F67A8487A9EDECE26B73AAB27E75249E538938AD976D371A9411B54DBAE20AFEAC82B406AD4EEEE38B1CF6F407E7620679D30C0FFF82EC8E8AE62268C322D59) - endif() - endif() - if(TORQUE_CPU_X32 OR TORQUE_CPU_ARM32) - set(download_urls "https://www.python.org/ftp/python/${program_version}/python-${program_version}-embed-win32.zip") - set(download_filename "python-${program_version}-embed-win32.zip") - set(download_sha512 15542080E0CC25C574391218107FE843006E8C5A7161D1CD48CF14A3C47155C0244587273D9C747F35B15EA17676869ECCE079214824214C1A62ABFC86AD9F9B) - endif() - - if(NOT download_url) - message(FATAL_ERROR "Unsupported architecture or missing TORQUE_CPU_* definition.") - endif() - - set(python_dir "${CMAKE_BINARY_DIR}/tools/python") - set(python_zip "${python_dir}/${download_filename}") - - # Ensure the target directory exists - file(MAKE_DIRECTORY "${python_dir}") - - # Download the Python embedded zip if not already there - if(NOT EXISTS "${python_zip}") - message(STATUS "Downloading ${download_url} ...") - file(DOWNLOAD - "${download_url}" - "${python_zip}" - SHOW_PROGRESS - EXPECTED_HASH SHA512=${download_sha512} - STATUS download_status - ) - list(GET download_status 0 status_code) - if(NOT status_code EQUAL 0) - message(FATAL_ERROR "Download failed: ${download_status}") - endif() - endif() - - # Extract the embedded Python ZIP - message(STATUS "Extracting Python to ${python_dir}") - execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf "${python_zip}" - WORKING_DIRECTORY "${python_dir}" - RESULT_VARIABLE extract_result - ) - - if(NOT extract_result EQUAL 0) - message(FATAL_ERROR "Failed to extract ${python_zip}") - endif() - - file(GLOB embedded_python_exe "${python_dir}/python.exe") - if(embedded_python_exe) - set(Python_EXECUTABLE "${embedded_python_exe}" CACHE FILEPATH "Path to embedded Python" FORCE) - message(STATUS "Using embedded Python: ${Python_EXECUTABLE}") - endif() - else() - message(FATAL_ERROR "Cannot find python3 please install it") - endif(WIN32) -endif() - -advanced_option(BUILD_PROGRAMS "" OFF) -advanced_option(BUILD_EXAMPLES "" OFF) -advanced_option(BUILD_TESTING "" OFF) -advanced_option(BUILD_REGTEST "" OFF) -advanced_option(ENABLE_BOW_DOCS "" OFF) -advanced_option(ENABLE_CPACK "" OFF) -advanced_option(ENABLE_PACKAGE_CONFIG "" OFF) -advanced_option(INSTALL_PKGCONFIG_MODULE "" OFF) -set(BUILD_SHARED_LIBS ON ) -add_subdirectory(libsndfile ${TORQUE_LIB_TARG_DIRECTORY}/libsndfile EXCLUDE_FROM_ALL) - set(BUILD_SHARED_LIBS OFF ) if(TORQUE_TESTING) add_subdirectory(gtest ${TORQUE_LIB_TARG_DIRECTORY}/gtest EXCLUDE_FROM_ALL) diff --git a/Engine/lib/flac/.clang-format b/Engine/lib/flac/.clang-format deleted file mode 100644 index a5439cd60..000000000 --- a/Engine/lib/flac/.clang-format +++ /dev/null @@ -1,21 +0,0 @@ -BasedOnStyle: WebKit -AlignAfterOpenBracket: Align -AlignEscapedNewlines: DontAlign -AlignOperands: true -BraceWrapping: - AfterFunction: true - BeforeElse: true -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeInheritanceComma: true -BreakConstructorInitializers: BeforeComma -DerivePointerAlignment: false -IndentCaseLabels: true -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: All -PointerAlignment: Right -SortIncludes: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeParens: Never -TabWidth: 4 -UseTab: ForContinuationAndIndentation diff --git a/Engine/lib/flac/.github/workflows/action.yml b/Engine/lib/flac/.github/workflows/action.yml deleted file mode 100644 index c8bdbff89..000000000 --- a/Engine/lib/flac/.github/workflows/action.yml +++ /dev/null @@ -1,134 +0,0 @@ -name: GitHub Actions - -on: - push: - pull_request: - -jobs: - build: - strategy: - matrix: - include: - - name: ubuntu-latest-clang-autotools - os: ubuntu-latest - cc: clang - cxx: clang++ - build-system: autotools - configure-opts: '' - - - name: ubuntu-latest-gcc-cmake - os: ubuntu-latest - cc: gcc - cxx: g++ - build-system: cmake - configure-opts: '' - - - name: ubuntu-latest-clang-cmake - os: ubuntu-latest - cc: clang - cxx: clang++ - build-system: cmake - configure-opts: '' - - - name: macos-latest-clang-autotools - os: macos-latest - cc: clang - cxx: clang++ - build-system: autotools - configure-opts: '' - - - name: macos-latest-clang-cmake - os: macos-latest - cc: clang - cxx: clang++ - build-system: cmake - configure-opts: '' - - - name: windows-latest-cmake - os: windows-latest - build-system: cmake - configure-opts: '' - - - name: windows-latest-cmake-shared - os: windows-latest - build-system: cmake - configure-opts: '-DBUILD_SHARED_LIBS=ON' - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - - - uses: actions/checkout@v3 - if: startsWith(matrix.build-system,'cmake') - with: - repository: xiph/ogg - path: ./ogg - - - name: Install MacOS dependencies - if: startsWith(matrix.os,'macos') && !startsWith(matrix.build-system,'cmake') - run: | - brew update - brew install automake pkg-config libogg - - - name: Install Linux dependencies - if: startsWith(matrix.os,'ubuntu') - run: | - sudo apt-get update - sudo apt-get install -y libtool-bin libogg-dev - - - name: Install Windows dependencies - if: startsWith(matrix.os,'windows') - run: | - choco install busybox - - - name: Build with Autotools - if: startsWith(matrix.build-system,'autotools') - env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - run: | - ./autogen.sh - ./configure ${{ matrix.configure-opts }} - make - make check - - - name: Prepare CMake build directory - if: startsWith(matrix.build-system,'cmake') - env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - run: mkdir cmake-build - - - name: CMake generator - if: startsWith(matrix.build-system,'cmake') - env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - working-directory: cmake-build - run: cmake .. -DCMAKE_BUILD_TYPE=Release -DINSTALL_MANPAGES=OFF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ${{ matrix.configure-opts }} -DCMAKE_FIND_FRAMEWORK=NEVER - - - name: CMake build - if: startsWith(matrix.build-system,'cmake') - env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - working-directory: cmake-build - run: cmake --build . --config Release - - - name: CMake test - if: startsWith(matrix.build-system,'cmake') - env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - working-directory: cmake-build - run: ctest -V -C Release - - - name: Upload logs on failure - uses: actions/upload-artifact@v2 - if: failure() - with: - name: flac-${{ github.sha }}-${{ github.run_id }}-logs - path: | - ./**/*.log - ./**/out*.meta diff --git a/Engine/lib/flac/.github/workflows/cifuzz.yml b/Engine/lib/flac/.github/workflows/cifuzz.yml deleted file mode 100644 index b04d1959e..000000000 --- a/Engine/lib/flac/.github/workflows/cifuzz.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: CIFuzz -on: - pull_request: - push: - branches: - - master - - 1.3.x -jobs: - Fuzzing: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - sanitizer: [address, undefined, memory] - steps: - - name: Build Fuzzers (${{ matrix.sanitizer }}) - id: build - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master - with: - oss-fuzz-project-name: 'flac' - language: c++ - sanitizer: ${{ matrix.sanitizer }} - - name: Run Fuzzers (${{ matrix.sanitizer }}) - uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master - with: - oss-fuzz-project-name: 'flac' - language: c++ - fuzz-seconds: 7200 - sanitizer: ${{ matrix.sanitizer }} - - name: Upload Crash - uses: actions/upload-artifact@v1 - if: failure() && steps.build.outcome == 'success' - with: - name: ${{ matrix.sanitizer }}-artifacts - path: ./out/artifacts - diff --git a/Engine/lib/flac/.github/workflows/distcheck.yml b/Engine/lib/flac/.github/workflows/distcheck.yml deleted file mode 100644 index 90daba2d1..000000000 --- a/Engine/lib/flac/.github/workflows/distcheck.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Autotools distcheck and ABI check - -on: - push: - branches: - - main - - master - pull_request: - -jobs: - distcheck: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - - uses: actions/checkout@v3 - with: - repository: ietf-wg-cellar/flac-test-files - path: ./test-files - - - name: Install Linux dependencies - run: | - sudo apt-get update - sudo apt-get install -y libtool-bin libogg-dev doxygen libxml2-utils w3c-sgml-lib pandoc abi-compliance-checker - - - name: Build with Autotools - run: | - ./autogen.sh - ./configure - - - name: Build and check source package - run: make distcheck - - - name: Check binary compatibility - run: | - make - unxz --keep test/abi/abi-libFLAC-1.4.0.dump.xz - unxz --keep test/abi/abi-libFLAC++-1.4.0.dump.xz - abi-compliance-checker -l flac -old test/abi/abi-libFLAC-1.4.0.dump -new test/abi/abi-descriptor-libFLAC-1.4.3.xml - abi-compliance-checker -l flac++ -old test/abi/abi-libFLAC++-1.4.0.dump -new test/abi/abi-descriptor-libFLAC++-1.4.3.xml - - - name: Check with flac test files - run: ./src/flac/flac -t test-files/subset/*.flac test-files/uncommon/0[5-9]*.flac test-files/uncommon/10*.flac - - - name: Upload ABI compliance reports - uses: actions/upload-artifact@v3 - with: - name: flac-${{ github.sha }}-${{ github.run_id }}-compat - path: | - ./compat_reports - - - name: Upload logs on failure - uses: actions/upload-artifact@v3 - if: failure() - with: - name: flac-${{ github.sha }}-${{ github.run_id }}-logs - path: | - ./flac-**/**/*.log diff --git a/Engine/lib/flac/.github/workflows/options.yml b/Engine/lib/flac/.github/workflows/options.yml deleted file mode 100644 index d2c8673e8..000000000 --- a/Engine/lib/flac/.github/workflows/options.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: GitHub Actions for specific options - -on: - push: - pull_request: - -jobs: - build: - strategy: - matrix: - include: - - name: 32-bit-words - cppflags: '' - configure-opts: --disable-64-bit-words - - - name: integer-only-library - cppflags: '-DFLAC__INTEGER_ONLY_LIBRARY' - configure-opts: '' - - - name: no-asm - cppflags: '' - configure-opts: --disable-asm-optimizations - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y libtool-bin libogg-dev - - - name: Build and run tests - env: - CPPFLAGS: ${{ matrix.cppflags }} - run: | - ./autogen.sh - ./configure --disable-thorough-tests ${{ matrix.configure-opts }} - make - make check - - - name: Upload logs on failure - uses: actions/upload-artifact@v2 - if: failure() - with: - name: flac-${{ github.sha }}-${{ github.run_id }}-logs - path: | - ./**/*.log - ./**/out*.meta diff --git a/Engine/lib/flac/.gitignore b/Engine/lib/flac/.gitignore deleted file mode 100644 index 2b283c48c..000000000 --- a/Engine/lib/flac/.gitignore +++ /dev/null @@ -1,102 +0,0 @@ -*.a -*.la -*.lo -*.o -*.so -*.dll -*.dylib -*.exe -.deps -.libs -aclocal.m4 -ar-lib -autom4te.cache/ -compile -config.guess -config.h -config.h.in -config.log -config.rpath -config.status -config.sub -configure -depcomp -doc/Doxyfile -doc/FLAC.tag -doc/api/ -examples/c/decode/file/example_c_decode_file -examples/c/encode/file/example_c_encode_file -examples/cpp/decode/file/example_cpp_decode_file -examples/cpp/encode/file/example_cpp_encode_file -install-sh -libtool -libtool-disable-static -ltmain.sh -m4/libtool.m4 -m4/ltoptions.m4 -m4/ltsugar.m4 -m4/ltversion.m4 -m4/lt~obsolete.m4 -man/flac.1 -man/metaflac.1 -missing -objs/debug -objs/release -src/flac/flac -src/libFLAC++/flac++.pc -src/libFLAC/flac.pc -src/metaflac/metaflac -src/share/getopt/libgetopt.a -src/test_grabbag/cuesheet/test_cuesheet -src/test_grabbag/picture/test_picture -src/test_libFLAC++/test_libFLAC++ -src/test_libFLAC/test_libFLAC -src/test_seeking/test_seeking -src/test_streams/test_streams -stamp-h1 -test/*.aiff -test/*.cmp -test/*.cue -test/*.flac -test/*.log -test/*.oga -test/*.raw -test/*.rf64 -test/*.w64 -test/*.wav -test/common.sh -test/cuesheet.diff -test/cuesheet.log -test/metaflac-test-files/out.meta -test/metaflac.flac -test/picture.diff -test/picture.log -.dirstamp -microbench/benchmark_residual -/ogg/ -oss-fuzz/fuzzer_decoder -oss-fuzz/fuzzer_seek -oss-fuzz/fuzzer_metadata -oss-fuzz/fuzzer_encoder -oss-fuzz/fuzzer_encoder_v2 -oss-fuzz/fuzzer_reencoder -oss-fuzz/fuzzer_tool_flac -oss-fuzz/fuzzer_tool_metaflac - -/*[Bb]uild*/ -/out/ -CMakeSettings.json -CMakeLists.txt.user -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -Makefile.in -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -_deps - -/.vs*/ diff --git a/Engine/lib/flac/.gitlab-ci.yml b/Engine/lib/flac/.gitlab-ci.yml deleted file mode 100644 index 87e8ae9e6..000000000 --- a/Engine/lib/flac/.gitlab-ci.yml +++ /dev/null @@ -1,36 +0,0 @@ -default: - tags: - - docker - # Image from https://hub.docker.com/_/gcc/ based on Debian - image: gcc:9 - -autotools: - stage: build - before_script: - - apt-get update && - apt-get install -y libogg-dev - libtool-bin gettext zip - doxygen graphviz pandoc - # Create an unpriviledged user, required for tests. - - adduser --disabled-password --gecos "Gitlab CI" flac - script: - - ./autogen.sh - - ./configure - - make - - su -c 'make distcheck' flac - -cmake: - stage: build - before_script: - - apt-get update && - apt-get install -y libogg-dev - cmake ninja-build - doxygen graphviz pandoc - # Create an unpriviledged user, required for tests. - - adduser --disabled-password --gecos "Gitlab CI" flac - script: - - mkdir _build - - cmake -S . -B _build -G "Ninja" -DCMAKE_BUILD_TYPE=Release - - chown -R flac . - - su -c 'cmake --build _build' flac - - su -c 'cd _build && ctest -V' flac diff --git a/Engine/lib/flac/.travis.yml b/Engine/lib/flac/.travis.yml deleted file mode 100644 index a4de83010..000000000 --- a/Engine/lib/flac/.travis.yml +++ /dev/null @@ -1,61 +0,0 @@ -language: c - -jobs: - include: - - os: linux - dist: focal - arch: arm64 - compiler: gcc - env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DWITH_ASM=0 - - os: linux - dist: focal - arch: arm64 - compiler: gcc - env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS= - - os: linux - dist: focal - arch: arm64 - compiler: gcc - env: BUILD_SYSTEM="autotools" CONFIGURE_OPTS= -# - os: linux -# dist: focal -# arch: arm64 -# compiler: clang -# env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DWITH_STACK_PROTECTOR=OFF # Clang on focal arm64 seems broken, can't find a way to reproduce this on my machine - - os: linux - dist: focal - arch: arm64 - compiler: gcc - env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DENABLE_64_BIT_WORDS=OFF - - os: linux - dist: focal - arch: ppc64le - compiler: gcc - env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DWITH_ASM=0 - - os: linux - dist: focal - arch: ppc64le - compiler: gcc - env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS= - - os: linux - dist: focal - arch: ppc64le - compiler: gcc - env: BUILD_SYSTEM="autotools" CONFIGURE_OPTS= - - os: linux - dist: focal - arch: ppc64le - compiler: clang - env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS= - - os: linux - dist: focal - arch: ppc64le - compiler: gcc - env: BUILD_SYSTEM="cmake" CONFIGURE_OPTS=-DENABLE_64_BIT_WORDS=OFF - -install: - - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get -y install libtool-bin libogg-dev; fi - -script: - - if [[ "${BUILD_SYSTEM}" == "autotools" ]]; then ./autogen.sh && ./configure $CONFIGURE_OPTS && make && make check; fi - - if [[ "${BUILD_SYSTEM}" == "cmake" ]]; then mkdir cmake-build && cd cmake-build && cmake .. -DCMAKE_BUILD_TYPE=Release -DINSTALL_MANPAGES=OFF $CONFIGURE_OPTS && cat config.h && cmake --build . && travis_wait 30 ctest --output-on-failure; fi diff --git a/Engine/lib/flac/AUTHORS b/Engine/lib/flac/AUTHORS deleted file mode 100644 index 34c5f8970..000000000 --- a/Engine/lib/flac/AUTHORS +++ /dev/null @@ -1,60 +0,0 @@ -/* FLAC - Free Lossless Audio Codec - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This file is part the FLAC project. FLAC is comprised of several - * components distributed under different licenses. The codec libraries - * are distributed under Xiph.Org's BSD-like license (see the file - * COPYING.Xiph in this distribution). All other programs, libraries, and - * plugins are distributed under the GPL (see COPYING.GPL). The documentation - * is distributed under the Gnu FDL (see COPYING.FDL). Each file in the - * FLAC distribution contains at the top the terms under which it may be - * distributed. - * - * Since this particular file is relevant to all components of FLAC, - * it may be distributed under the Xiph.Org license, which is the least - * restrictive of those mentioned above. See the file COPYING.Xiph in this - * distribution. - */ - -This file lists major contributors to the FLAC project. This list is not -exhaustive. For an exhaustive list, run the command `git shortlog -s` on -the git repo or visit https://gitlab.xiph.org/xiph/flac/-/graphs/master - -For a complete list of contributions, run the command `git log` on the -git repo, visit https://github.com/xiph/flac/commits or visit -https://gitlab.xiph.org/xiph/flac/commits - -Original author: Josh Coalson -Maintainer 2012-2020: Erik de Castro Lopo -Maintainer from 2022: Martijn van Beurden - -Website : https://www.xiph.org/flac/ - -Other major contributors and their contributions: - -"lvqcl" -* Visual Studio build system. -* Optimisations in the encoder and decoder. - -"Janne Hyvärinen" -* Visual Studio build system. -* Unicode handling on Windows. - -"Andrey Astafiev" -* Russian translation of the HTML documentation - -"Miroslav Lichvar" -* IA-32 assembly versions of several libFLAC routines - -"Brady Patterson" -* AIFF file support, PPC assembly versions of libFLAC routines - -"Daisuke Shimamura" -* i18n support in the XMMS plugin - -"X-Fixer" -* Configuration system, tag editing, and file info in the Winamp2 plugin - -"Matt Zimmerman" -* Libtool/autoconf/automake make system, flac man page diff --git a/Engine/lib/flac/CHANGELOG.md b/Engine/lib/flac/CHANGELOG.md deleted file mode 100644 index 71467a5ae..000000000 --- a/Engine/lib/flac/CHANGELOG.md +++ /dev/null @@ -1,992 +0,0 @@ -# Changelog - -This changelog is not exhaustive, review [the git commit log](https://github.com/xiph/flac/commits) for an exhaustive list of changes. - -## FLAC 1.4.3 (23-Jun-2023) - -As there have been additions to the libFLAC interfaces, the libFLAC version number is incremented to 13. The libFLAC++ version number stays at 10. - -* General - * All PowerPC-specific code has been removed, as it turned out those improvements didn't actually improve anything - * Large improvements in encoder speed for all presets. The largest change is for the fastest presets and for 24-bit and 32-bit inputs. - * Small improvement in decoder speed for BMI2-capable CPUs - * Various documentation fixes and cleanups (Mark Grassi, Jake Schmidt) - * Various fixes (Ozkan Sezer, Zhipeng Xue, orbea, Sam James, Harish Mahendrakar) - * Fix building on Universal Windows Platform (Dmitry Kostjučenko) -* flac - * A lot of small fixes for bugs found by fuzzing - * Various improvements to the --keep-foreign-metadata and --keep-foreign-metadata-if-present options on decoding - * The output format (WAV/AIFF/RF64 etc.) is now automatically selected based on what kind of foreign metadata is stored - * Decoded file is checked afterwards, to see whether stored foreign format data agrees with FLAC audio properties - * AIFF-C sowt data can now be restored - * Add --force-legacy-wave-format option, to decode to WAV with WAVEFORMATPCM where WAVE_FORMAT_EXTENSIBLE would be more appropriate - * Add --force-aiff-c-none-format and --force-aiff-c-sowt-format to decode to AIFF-C - * The storage of WAVEFORMATEXTENSIBLE_CHANNEL_MASK is no longer restricted to known channel orderings - * Throw an error when WAV or AIFF files are over 4GiB in length and the --ignore-chunk-sizes option is not set - * Warn on testing files when ID3v2 tags are found - * Warn when data trails the audio data of a WAV/AIFF/RF64/W64 file - * Fix output file not being deleted after error on Windows - * Removal of the --sector--align option -* metaflac - * A lot of small fixes for bugs found by fuzzing - * Added options --append and --data-format, which makes it possible to copy metadata blocks from one FLAC file to another - * Added option --remove-all-tags-except - * Added option --show-all-tags (harridu, Martijn van Beurden) -* libFLAC - * No longer write seektables to Ogg, even when specifically asked for. Seektables in Ogg are not defined - * Add functions FLAC__metadata_object_set_raw and FLAC__metadata_object_get_raw to convert between blob and FLAC__StreamMetadata -* Build system - * Autoconf (configure) - * The option --enable-64-bit-words is now on by default - * CMake - * The option ENABLE_64_BIT_WORDS is now on by default -* Testing/validation - * Fuzzers were added for the flac and metaflac command line tools - * Fuzzer coverage was improved - -## FLAC 1.4.2 (22-Oct-2022) - -Once again, this release only has a few changes. A problem with FLAC playback in GStreamer (and possibly other libFLAC users) was the reason for the short time since the last release - -* General - * Remove xmms plugin (Martijn van Beurden, TokyoBlackHole) - * Remove all pure assembler, removing build dependency on nasm - * Made console output more uniform across different platforms and CPUs - * Improve ability to tune compile for a certain system (for example with -march=native) when combining with --disable-asm-optimizations: plain C functions can now be better optimized -* Build system - * Default CFLAGS are now prepended instead of dropped when user CFLAGS are set - * -msse2 is no longer added by default (was only applicable to x86) - * Fix cross-compiling and out-of-tree building when pandoc and doxygen are not available - * Fix issue with Clang not compiling functions with intrinsics - * Fix detection of bswap intrinsics (Ozkan Sezer) - * Improve search for libssp on MinGW (Ozkan Sezer, Martijn van Beurden) -* libFLAC - * Fix issue when the libFLAC user seeks in a file instead of libFLAC itself - -## FLAC 1.4.1 (22-Sep-2022) - -This release only has a few changes. It was triggered by a problem in the 1.4.0 tarball: man pages were empty and api documentation missing - -* CMake fixes (Tomasz Kłoczko) -* Add checks that man pages and api docs end up in tarball -* Enable installation of prebuilt man pages and api docs -* Fix compiler warnings (Johannes Kauffmann, Ozkan Sezer) -* Fix format specifier (manxorist) -* Enable building on Universal Windows Platform (Steve Lhomme) -* Fix versioning from git - -## FLAC 1.4.0 (09-Sep-2022) - -As there have been changes to the library interfaces, the libFLAC version number is incremented to 12, the libFLAC++ version number is incremented to 10. As some changes were breaking, the version age numbers (see [libtool versioning](https://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning)) have been reset to 0. For more details on the changes to the API, see the [porting guide](https://xiph.org/flac/api/group__porting__1__3__4__to__1__4__0.html). - -The XMMS plugin and 'common' plugin code (used only by the XMMS plugin) are deprecated, they will be removed in a future release. - -* General: - * It is now possible to limit the minimum bitrate of a FLAC file generated by libFLAC and with the `flac` tool to 1 bit/sample. This function can be used to aid live streaming, for example for internet radio - * Encoding files with sample rates up to 1'048'575Hz is now possible. (Con Kolivas) - * Compression of preset -3 through -8 was slightly improved at the cost of a small decrease in encoding speed by increasing the precision with which autocorrelation was calculated (Martijn van Beurden) - * Encoding speed of preset -0, -1 and -2 was slightly improved - * Compression of presets -1 and -4 was slighly improved on certain material by changing the adaptive mid-side heuristics - * Speedups specifically targeting 64-bit ARMv8 devices using NEON were integrated (Ronen Gvili, Martijn van Beurden) - * Speedups for x86_64 CPUs having the FMA instruction set extention are added - * Encoding and decoding of 32-bit PCM is now possible -* (Ogg) FLAC format: - * The FLAC format document is being rewritten by the IETF CELLAR working group. The latest draft can be found on [https://datatracker.ietf.org/doc/draft-ietf-cellar-flac/](https://datatracker.ietf.org/doc/draft-ietf-cellar-flac/) - * The FLAC format document specifies no bounds for the residual. In other to match current decoder implementations, it is proposed to bound the residual to the range provided by a 32-bit int signed two's complement. This limit must be checked by FLAC encoders as to keep FLAC decoders free from the complexity of being to decode a residual exceeding a 32-bit int. - * There is now a set of files available to test whether a FLAC decoder implements the format correctly. This FLAC decoder testbench can be found at [https://github.com/ietf-wg-cellar/flac-test-files](https://github.com/ietf-wg-cellar/flac-test-files). Also, results of testing hard- and software can be found here at [https://wiki.hydrogenaud.io/index.php?title=FLAC_decoder_testbench](https://wiki.hydrogenaud.io/index.php?title=FLAC_decoder_testbench). -* flac: - * The option --limit-min-bitrate was added to aid streaming, see [github #264](https://github.com/xiph/flac/pull/264) - * The option --keep-foreign-metadata-if-present is added. This option works the same as --keep-foreign-metadata, but does return a warning instead of an error if no foreign metadata was found to store or restore - * The warning returned by the foreign metadata handling is now clearer in case a user tries to restore foreign metadata of the wrong type, for example decoding a FLAC file containing AIFF foreign metadata to a WAV file - * A problem when using the analyse function causing the first frame to have a wrong size and offset was fixed - * Fix bug where channel mask of a file is unintentionally reused when several files are processed with one command - * The order of compression-related commands is no longer important, i.e. -8ep gives the same result as -ep8. Previously, a compression level (like -8) would override a more specific setting (like -e or -p). This is no longer the case - * flac now checks the block-align property of WAV files to ensure non-standard WAV files (for which flac has no handling) are not mangled -* metaflac: - * (none) -* build system: - * MSVC and Makefile.lite build system files have been removed. Building with MSVC (Visual Studio) can be done by using CMake - * Various CMake improvements, especially for creating MSVC build files (Martijn van Beurden, martinRenou, CookiePLMonster, David Callu, Tyler Dunn, Cameron Cawley) - * Various fixes for MinGW (Martijn van Beurden, Cameron Cawley) - * Removed obsolete autotools macro's to silence warnings - * Fixes for FreeBSD PowerPC (pkubaj) - * Fixed some compiler warnings (Martijn van Beurden, Tyler Dunn) - * Fix building with uclibc (Fabrice Fontaine) -* testing/validation: - * Addition of new encoder fuzzer, adding fuzzing for 8, 24 and 32-bit inputs - * Addition of new decoder fuzzer, adding coverage of seeking code - * Addition of metadata fuzzer, adding coverage of metadata APIs - * Various improvements to fuzzers to improve code coverage, fuzzing speed and stability - * Many changes to test suite to improve cross-platform compatibility (Rosen Penev) - * Windows CI now also builds the whole test suite - * Clang-format file added (Rosen Penev) - * Add warning on using v141_xp platform toolset with /MT (Martijn van Beurden, Paul Sanders) -* libraries: - * Various seeking fixes (Martijn van Beurden, Robert Kausch) - * Various bugs fixed found by fuzzing - * On decoding, it is now checked whether residuals can be contained by a 32-bit int, preventing integer overflow - * Add check that samples supplied to libFLAC actually fall within the bps set - * Add checks when parsing metadata blocks to not allocate excessive amounts of memory and not overread - * Undocumented Windows-only utf8 functions are no longer exported to the DLL interface - * Removed all assembler and intrinsics code from the decoder to improve fuzzing, as they provided only a small speed benefit - * The bitwriter buffer is limited in size to 2^24 bytes, so it cannot write excessively large files. This is a backup in case another bug in this area creeps (back) in. - * The metadata iterations should now never return a vorbiscomment entry with NULL as an entry, now always at least an empty string is returned -* documentation: - * Removed html documentation and generate man pages from markdown -* Interface changes: - * libFLAC: - * Addition of FLAC__stream_encoder_set_limit_min_bitrate() and FLAC__stream_encoder_get_limit_min_bitrate(), see [github #264](https://github.com/xiph/flac/pull/264) - * get_client_data_from_decoder is renamed FLAC__get_decoder_client_data(), see [github #124](https://github.com/xiph/flac/pull/124) - * All API functions taking a filename as an argument now take UTF-8 filenames on Windows, and no longer accept filenames using the current codepage - * FLAC__Frame struct has changed: warmup samples are now stored in FLAC__int64 instead of FLAC__int32 types, and verbatim samples can now be stored in either FLAC__int32 or FLAC__int64 depending on whether samples fix the former or latter - * The FLAC__StreamMetadata struct now has a tag, so it can be forward declared - * libFLAC++: - * Addition of ::set_limit_min_bitrate() and ::get_limit_min_bitrate(), see [github #264](https://github.com/xiph/flac/pull/264) - * All API functions taking a filename as an argument now take UTF-8 filenames on Windows, and no longer accept filenames using the current codepage - * The ::FLAC__Frame struct has changed, see the libFLAC interface change. - -## FLAC 1.3.4 (20-Feb-2022) - -This release mostly fixes (security related) bugs. When building with MSVC, using CMake is preferred, see the README under "Building with CMake" for more information. Building with MSVC using solution files is deprecated and these files will be removed in the future. As there have been no changes to the library interfaces, the libFLAC version number remains 11, and libFLAC++ version number remains 9. - -* General: - * Fix 12 decoder bugs found by oss-fuzz, including CVE-2020-0499 (erikd, Martijn van Beurden) - * Fix encoder bug CVE-2021-0561 (NeelkamalSemwal) - * Integrate oss-fuzzers (erikd, Guido Vranken) - * Seeking fixes (NeelkamalSemwal, Robert Kausch) - * Various fixes and improvements (Andrei Astafev, Rosen Penev, Håkan Kvist, oreo639, erikd, Tamás Zahola, Ulrik Mikaelsson, Tyler Dunn, tmkk) -* FLAC format: - * (none) -* Ogg FLAC format: - * (none) -* flac: - * Various fixes and improvements (Andrei Astafev, Martijn van Beurden) -* metaflac: - * (none) -* build system: - * CMake improvements (evpobr, Vitaliy Kirsanov, erikd, Ozkan Sezer, Tyler Dunn, tg-m DeadSix27, ericLemanissier, Chocobo1). - * Fixes for MinGW and MSVC (Ozkan Sezer). - * Fix for clang (Ozkan Sezer) - * Fix for PowerPC (Peter Seiderer, Thomas BERNARD) - * Fix for FreeBSD PowerPC (pkubaj). -* testing/validation: - * Add Windows target to CI, improve logging (Ralph Giles) - * CI improvements (Ralph Giles, Ewout ter Hoeven) -* documentation: - * Doxygen fixes (Tyler Dunn) - * Fix typos (Tim Gates, maxz) -* Interface changes: - * libFLAC: - * (none) - * libFLAC++: - * (none) - -## FLAC 1.3.3 (4-Augs-2019) - -* General: - * Fix CPU detection (Janne Hyvärinen). - * Switch from unsigned types to uint32_t (erikd). - * CppCheck fixes (erikd). - * Improve SIMD decoding of 24 bit files (lvqcl). - * POWER* amnd POWER9 improvements (Anton Blanchard). - * More tests. -* FLAC format: - * (none) -* Ogg FLAC format: - * (none) -* flac: - * When converting to WAV, use WAVEFORMATEXTENSIBLE when bits per second is not 8 or 16 (erikd). - * Fix --output-prefix with input-files in sub-directories (orbea). -* metaflac: - * (none) -* plugins: - * (none) -* build system: - * Cmake support (Vitaliy Kirsanov, evpobr). - * Visual Studio updates (Janne Hyvärinen). - * Fix for MSVC when UNICODE is enabled (lvqcl). - * Fix for OpenBSD/i386 (Christian Weisgerber). -* documentation: - * (none) -* libraries: - * (none). -* Interface changes: - * libFLAC: - * (none) - * libFLAC++: - * (none) - -## FLAC 1.3.2 (01-Jan-2017) - -* General: - * Fix undefined behaviour using GCC/Clang UBSAN (erikd). - * General hardening via fuzz testing with AFL (erikd and others). - * General code improvements (lvqcl, erikd and others). - * Add FLAC in MP4 specification docs (Ralph Giles). - * MSVS build cleanups (lvqcl). - * Fix some cppcheck warnings (erikd). - * Assume all currently used OSes support SSE2. -* FLAC format: - * (none) -* Ogg FLAC format: - * (none) -* flac: - * Fix potential infinite loop on flac-to-flac conversion (erikd). - * Add WAVEFORMATEXTENSIBLE to WAV (as needed) when decoding (lvqcl). - * Only write vorbis-comments if they are non-empty. - * Error out if decoding RAW with bits != (8|16|24). -* metaflac: - * Add --scan-replay-gain option. -* plugins: - * (none) -* build system: - * Fixes for MSVC and Makefile.lite build systems. -* documentation: - * (none) -* libraries: - * CPU detection cleanup and fixes (Julian Calaby, erikd and lvqcl). - * Fix two stream decoder bugs (Max Kellermann). - * Fix a NULL dereference bug (on a malformed file). - * Changed the LPC order guess for a slight compression improvement, particularly for classical music (Martijn van Beurden). - * Improved encoding speed on older Intel CPUs. - * Fixed a seeking bug when decoding certain files (Miroslav Lichvar). - * Put an upper bound (32768) on the number of seek points. - * Fix potential memory leaks. - * Support 64bit brword/bwword allowing FLAC__BYTES_PER_WORD to be set to 8 (disabled by default). - * Fix an out-of-bounds heap read. - * Win32: Only use large buffers when writing to disk. -* Interface changes: - * libFLAC: - * (none) - * libFLAC++: - * (none) - -## FLAC 1.3.1 (25-Nov-2014) - -* General: - * Improved decoding efficiency of all bit depths but especially so for 24 bits for IA32 architecture (lvqcl and Miroslav Lichvar). - * Faster encoding using SSE and AVX (lvqcl). - * Fixed bartlett, bartlett_hann and triangle functions. - * New apodization functions partial_tukey and punchout_tukey for improved compression (Martijn van Beurden). - * Retuned compression presets to incorporate new apodization functions (Martijn van Beurden). - * Fix -Wcast-align warnings on armhf architecture (Erik de Castro Lopo). -* FLAC format: - * (none) -* Ogg FLAC format: - * (none) -* flac: - * Help output documentation improvements. - * I/O buffering improvements on Windows to reduce disk fragmentation when writing files. - * Only write vorbis-comments if they are non-empty. -* metaflac: - * (none) -* plugins: - * Fix symbol visibility in XMMS plugin. -* build system: - * Many fixes and improvements across all the build systems. -* documentation: - * Document new [apodization windows](https://xiph.org/flac/documentation_tools_flac.html#flac_options_apodization). -* libraries: - * Fix CVE-2014-9028 (heap write overflow) and CVE-2014-8962 (heap read overflow) (Erik de Castro Lopo). -* Interface changes: - * libFLAC: - * (none) - * libFLAC++: - * (none) - -## FLAC 1.3.0 (26-May-2013) - -* General: - * Move development to Xiph.org git repository. - * The [--sector-align](https://xiph.org/flac/documentation_tools_flac.html#flac_options_sector_align) option of flac has been deprecated and may not exist in future versions. [shntool](http://www.etree.org/shnutils/shntool/) provides similar functionality. - * Support for the RF64 and Wave64 formats in flac (see below). - * Better handling of cuesheets with non-CD-DA sample rates. - * The [--ignore-chunk-sizes](https://xiph.org/flac/documentation_tools_flac.html#flac_options_ignore_chunk_sizes) option has been added to the flac command line tool. -* FLAC format: - * (none) -* Ogg FLAC format: - * (none) -* flac: - * Added support for encoding from and decoding to the RF64 format, and a new corresponding option [--force-rf64-format](https://xiph.org/flac/documentation_tools_flac.html#flac_options_force_rf64_format). ([SF #1762502](http://sourceforge.net/p/flac/feature-requests/78/)). [--keep-foreign-metadata](https://xiph.org/flac/documentation_tools_flac.html#flac_options_keep_foreign_metadata) is also supported. - * Added support for encoding from and decoding to the Sony Wave64 format, and a new corresponding option [--force-wave64-format](https://xiph.org/flac/documentation_tools_flac.html#flac_options_force_wave64_format). ([SF #1769582](http://sourceforge.net/p/flac/feature-requests/79/)). [--keep-foreign-metadata](https://xiph.org/flac/documentation_tools_flac.html#flac_options_keep_foreign_metadata) is also supported. - * Added new options [--preserve-modtime](https://xiph.org/flac/documentation_tools_flac.html#flac_options_preserve_modtime) and [--no-preserve-modtime](https://xiph.org/flac/documentation_tools_flac.html#negative_options) to specify whether or not output files should copy the timestamp and permissions from their input files. The default is [--preserve-modtime](https://xiph.org/flac/documentation_tools_flac.html#flac_options_preserve_modtime) as in previous versions. ([SF #1805428](http://sourceforge.net/p/flac/feature-requests/85/)). - * Allow MM:SS:FF and MM:SS.SS time formats in non-CD-DA cuesheets. ([SF #1947353](http://sourceforge.net/p/flac/feature-requests/95/), [SF #2182432](http://sourceforge.net/p/flac/bugs/338/)) - * The [--sector-align](https://xiph.org/flac/documentation_tools_flac.html#flac_options_sector_align) option of flac has been deprecated and may not exist in future versions. [shntool](http://www.etree.org/shnutils/shntool/) provides similar functionality. ([SF #1805946](http://sourceforge.net/p/flac/feature-requests/86/)) - * Improved error message when user attempts to decode a non-FLAC file ([SF #2222789](http://sourceforge.net/p/flac/bugs/341/)). - * Fix bug where flac was disallowing use of --replay-gain when encoding from stdin ([SF #1840124](http://sourceforge.net/p/flac/bugs/313/)). - * Fix bug with fractional seconds on some locales ([SF #1815517](http://sourceforge.net/p/flac/bugs/309/), [SF #1858012](http://sourceforge.net/p/flac/bugs/321/)). - * Read and write appropriate channel masks for 6.1 and 7.1 surround input WAV files. Documentation was also updated. - * Correct Wave64 GUIDs. - * Support 56kHz to 192kHz gain analysis (patch from Earl Chew) - * Add ability to handle unicode filenames on Windows (large set of patches from Janne Hyvärinen) -* metaflac: - * Allow MM:SS:FF and MM:SS.SS time formats in non-CD-DA cuesheets. ([SF #1947353](http://sourceforge.net/p/flac/feature-requests/95/), [SF #2182432](http://sourceforge.net/p/flac/bugs/338/)) -* plugins: - * Minor updates for XMMS plugin. - * Winamp2 plugin was dropped because Nullsoft has provided native FLAC support since 2006. -* build system: - * Fixes for autotools (including [SF #1859664](http://sourceforge.net/p/flac/patches/28/)). - * Fixes for MinGW (including [SF #2000973](http://sourceforge.net/p/flac/bugs/), [SF #2209829](http://sourceforge.net/p/flac/bugs/)). - * Fixes for gcc (including [SF #1834168](http://sourceforge.net/p/flac/bugs/), [SF #2002481](http://sourceforge.net/p/flac/bugs/334/)). - * Fixes for Sun Studio/Forte ([SF #1701960](http://sourceforge.net/p/flac/patches/22/)). - * Fixes for windows builds (including [SF #1676822](http://sourceforge.net/p/flac/bugs/257/), [SF #1756624](http://sourceforge.net/p/flac/feature-requests/73/), [SF #1809863](http://sourceforge.net/p/flac/bugs/307/), [SF #1911149](http://sourceforge.net/p/flac/feature-requests/)). - * Fixes for FreeBSD and OpenBSD. - * Compile with GNU gcc _FORTIFY_SOURCE=2 and stack protection where those features are detected. - * Enable a bunch of GCC compiler warnings and fix code that generates warnings. -* documentation: - * Document [--ignore-chunk-sizes](https://xiph.org/flac/documentation_tools_flac.html#flac_options_ignore_chunk_sizes) and [--apply-replaygain-which-is-not-lossless](https://xiph.org/flac/documentation_tools_flac.html#flac_options_apply_replaygain_which_is_not_lossless) option for flac. -* libraries: - * libFLAC encoder was defaulting to level 0 compression instead of 5 ([SF #1816825](http://sourceforge.net/p/flac/bugs/310/)). - * Fix bug in bitreader handling of read callback returning a short count ([SF #2490454](http://sourceforge.net/p/flac/bugs/345/)). - * Improve decoder's ability to distinguish between a FLAC sync code and an MPEG one ([SF #2491433](http://sourceforge.net/p/flac/bugs/346/)). -* Interface changes: - * libFLAC: - * **Added** FLAC__format_blocksize_is_subset() - * libFLAC++: - * Add a number of convenience methods. - -## FLAC 1.2.1 (17-Sep-2007) - -* General: - * With the new [--keep-foreign-metadata](https://xiph.org/flac/documentation_tools_flac.html#flac_options_keep_foreign_metadata) in flac, non-audio RIFF and AIFF chunks can be stored in FLAC files and recreated when decoding. This allows, among other, things support for archiving BWF files and other WAVE files from editing tools that preserves all the metadata. -* FLAC format: - * Specified 2 new APPLICATION metadata blocks for storing WAVE and AIFF chunks (for use with [--keep-foreign-metadata](https://xiph.org/flac/documentation_tools_flac.html#flac_options_keep_foreign_metadata) in flac). - * The lead-out track number for non-CDDA cuesheets now must be 255. -* Ogg FLAC format: - * This is not a format change, but changed default extension for Ogg FLAC from .ogg to .oga, according to new Xiph [specification](http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions) ([SF #1762492](http://sourceforge.net/p/flac/bugs/283/)). -* flac: - * Added a new option [--no-utf8-convert](https://xiph.org/flac/documentation_tools_flac.html#flac_options_no_utf8_convert) which works like it does in metaflac ([SF #973740](http://sourceforge.net/p/flac/feature-requests/35/)). - * Added a new option [--keep-foreign-metadata](https://xiph.org/flac/documentation_tools_flac.html#flac_options_keep_foreign_metadata) which can save/restore RIFF and AIFF chunks to/from FLAC files ([SF #363478](http://sourceforge.net/p/flac/feature-requests/9/)). - * Changed default extension for Ogg FLAC from .ogg to .oga, according to new Xiph [specification](http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions) ([SF #1762492](http://sourceforge.net/p/flac/bugs/283/)). - * Fixed bug where using --replay-gain without any padding option caused only a small PADDING block to be created ([SF #1760790](http://sourceforge.net/p/flac/bugs/282/)). - * Fixed bug where encoding from stdin on Windows could fail if WAVE/AIFF contained unknown chunks ([SF #1776803](http://sourceforge.net/p/flac/bugs/290/)). - * Fixed bug where importing non-CDDA cuesheets would cause an invalid lead-out track number ([SF #1764105](http://sourceforge.net/p/flac/bugs/286/)). -* metaflac: - * Changed default extension for Ogg FLAC from .ogg to .oga, according to new Xiph [specification](http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions) ([SF #1762492](http://sourceforge.net/p/flac/bugs/283/)). - * Fixed bug where importing non-CDDA cuesheets would cause an invalid lead-out track number ([SF #1764105](http://sourceforge.net/p/flac/bugs/286/)). -* plugins: - * (none) -* build system: - * New configure option --disable-cpplibs to prevent building libFLAC++ ([SF #1723295](http://sourceforge.net/p/flac/patches/23/)). - * Fixed bug compiling flac without Ogg support ([SF #1760786](http://sourceforge.net/p/flac/bugs/281/)). - * Fixed bug where sometimes an existing installation of flac could interfere with the build process ([SF #1763690](http://sourceforge.net/p/flac/bugs/285/)). - * OS X fixes ([SF #1786225](http://sourceforge.net/p/flac/patches/25/)). - * MinGW fixes ([SF #1684879](http://sourceforge.net/p/flac/bugs/264/)). - * Solaris 10 fixes ([SF #1783225](http://sourceforge.net/p/flac/bugs/294/) [SF #1783630](http://sourceforge.net/p/flac/bugs/295/)). - * OS/2 fixes ([SF #1771378](http://sourceforge.net/p/flac/bugs/287/) [SF #1229495](http://sourceforge.net/p/flac/bugs/174/)). - * automake-1.10 fixes ([SF #1791361](http://sourceforge.net/p/flac/bugs/300/) [SF #1792179](http://sourceforge.net/p/flac/bugs/302/)). -* documentation: - * Added new [tutorial](https://xiph.org/flac/documentation_tools_flac.html#tutorial) section for flac. - * Added [example code](https://xiph.org/flac/documentation_example_code.html) section for using libFLAC/libFLAC++. -* libraries: - * libFLAC: Fixed very rare seek bug ([SF #1684049](http://sourceforge.net/p/flac/bugs/263/)). - * libFLAC: Fixed seek bug with Ogg FLAC and small streams ([SF #1792172](http://sourceforge.net/p/flac/bugs/301/)). - * libFLAC: 64-bit fixes ([SF #1790872](http://sourceforge.net/p/flac/bugs/299/)). - * libFLAC: Fix assembler code to be position independent. - * libFLAC: Optimization of a number of inner loop functions. - * Added support for encoding the residual coding method introduced in libFLAC 1.2.0 (RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) which will encode 24-bit files more efficiently. -* Interface changes: - * libFLAC: - * **Added** FLAC__metadata_simple_iterator_is_last() - * **Added** FLAC__metadata_simple_iterator_get_block_offset() - * **Added** FLAC__metadata_simple_iterator_get_block_length() - * **Added** FLAC__metadata_simple_iterator_get_application_id() - * libFLAC++: - * **Added** FLAC::Metadata::SimpleIterator::is_last() - * **Added** FLAC::Metadata::SimpleIterator::get_block_offset() - * **Added** FLAC::Metadata::SimpleIterator::get_block_length() - * **Added** FLAC::Metadata::SimpleIterator::get_application_id() - -## FLAC 1.2.0 (23-Jul-2007) - -* General: - * Small encoding speedups for all modes. -* FLAC format: - * One of the reserved bits in the FLAC frame header has been assigned for future use; make sure to refer to the [porting guide](https://xiph.org/flac/api/group__porting__1__1__4__to__1__2__0.html) if you parse FLAC streams manually. -* Ogg FLAC format: - * (none) -* flac: - * Added runtime detection of SSE OS support for most operating systems. - * Added a new undocumented option --ignore-chunk-sizes for ignoring the size of the 'data' chunk (WAVE) or 'SSND' chunk (AIFF). Can be used to encode files with bogus data sizes (e.g. with WAV files piped from foobar2000 to flac.exe as an external encoder). **Use with caution**: all subsequent data is treated as audio, so the data/SSND chunk must be the last or the following data/tags will be treated as audio and encoded. -* metaflac: - * (none) -* plugins: - * (none) -* build system: - * Added solution and project files for building with VC++ 2005. -* libraries: - * Added runtime detection of SSE OS support for most operating systems. - * Fixed bug where invalid seek tables could cause some seeks to fail. - * Added support for decoding the new residual coding method (RESIDUAL_CODING_METHOD_PARTITIONED_RICE2). -* Interface changes (see also the [porting guide](https://xiph.org/flac/api/group__porting__1__1__4__to__1__2__0.html) for specific instructions on porting to FLAC 1.2.0): - * libFLAC: - * **Added** FLAC__format_sample_rate_is_subset() - * libFLAC++: - * **Added** FLAC::Decoder::Stream::get_decode_position() - -## FLAC 1.1.4 (13-Feb-2007) - -* General: - * Improved compression with no change to format or decrease in speed. - * Encoding and decoding speedups for all modes. Encoding at -8 is twice as fast. -* FLAC format: - * (none) -* Ogg FLAC format: - * (none) -* flac: - * Improved compression with no change to format or decrease in speed. - * Encoding and decoding speedups for all modes. Encoding at -8 is twice as fast. - * Added a new option [-w,--warnings-as-errors](https://xiph.org/flac/documentation_tools_flac.html#flac_options_warnings_as_errors) for treating all warnings as errors. - * Allow [--picture](https://xiph.org/flac/documentation_tools_flac.html#flac_options_picture) option to take only a filename, and have all other attributes extracted from the file itself. - * Fixed a bug that caused suboptimal default compression settings in some locales ([SF #1608883](http://sourceforge.net/p/flac/bugs/237/)). - * Fixed a bug where FLAC-to-FLAC transcoding of a corrupted FLAC file would truncate the transcoded file at the first error ([SF #1615019](http://sourceforge.net/p/flac/bugs/241/)). - * Fixed a bug where using [-F](https://xiph.org/flac/documentation_tools_flac.html#flac_options_decode_through_errors) with FLAC-to-FLAC transcoding of a corrupted FLAC would have no effect ([SF #1615391](http://sourceforge.net/p/flac/bugs/242/)). - * Fixed a bug where new PICTURE metadata blocks specified with [--picture](https://xiph.org/flac/documentation_tools_flac.html#flac_options_picture) would not be transferred during FLAC-to-FLAC transcoding ([SF #1627993](http://sourceforge.net/p/flac/bugs/246/)). -* metaflac: - * Allow [--import-picture-from](https://xiph.org/flac/documentation_tools_metaflac.html#metaflac_shorthand_import_picture_from) option to take only a filename, and have all other attributes extracted from the file itself. -* plugins: - * Fixed a bug in the XMMS plugin where Ctrl-3 (file info) would cause a crash if the file did not exist ([SF #1634941](http://sourceforge.net/p/flac/patches/20/)). -* build system: - * Fixed a makefile linkage bug with libogg ([SF #1611414](http://sourceforge.net/p/flac/bugs/239/)). - * Added pkg-config files for libFLAC and libFLAC++ ([SF #1647881](http://sourceforge.net/p/flac/patches/21/)). - * Added --disable-ogg option for building without Ogg support even if libogg is installed ([SF #1196996](http://sourceforge.net/p/flac/bugs/165/)). -* libraries: - * Completely rewritten bitbuffer which uses native machine word size instead of bytes for dramatic speed improvements. The speedup should be most dramatic on CPUs with slower byte manipulation capability and big-endian machines. - * Much faster Rice partition size estimation which greatly speeds encoding in higher modes. - * Increased compression for all modes. - * Reduced memory requirements for encoder and decoder. - * Fixed a bug with default apodization settings that were erroneous in some locales ([SF #1608883](http://sourceforge.net/p/flac/bugs/237/)). -* Interface changes: - * libFLAC: - * (behavior only) FLAC__stream_encoder_set_metadata() now makes a copy of the "metadata" array of pointers (but still not copies of the objects themselves) so the client does not need to maintain its copy of the array after the call. - * libFLAC++: - * (none) - -## FLAC 1.1.3 (27-Nov-2006) - -* General: - * Improved compression with no impact on format or decoding speed. - * Much better recovery for corrupted files - * Better multichannel support - * Large file (>2GB) support everywhere - * flac now supports FLAC and Ogg FLAC as input to the encoder (e.g. can re-encode FLAC to FLAC) and preserve all the metadata like tags, etc. - * New [PICTURE](https://xiph.org/flac/format.html#def_PICTURE) metadata block for storing things like cover art, new [--picture](https://xiph.org/flac/documentation_tools_flac.html#flac_options_picture) option to flac and [--import-picture-from](https://xiph.org/flac/documentation_tools_metaflac.html#metaflac_shorthand_import_picture_from) option to metaflac for importing pictures, new [--export-picture-to](https://xiph.org/flac/documentation_tools_metaflac.html#metaflac_shorthand_export_picture_to) option to metaflac for exporting pictures, and metadata API [additions](https://xiph.org/flac/api/group__flac__metadata__level0.html#ga3) for searching for suitable pictures based on type, size and color constraints. - * Support for new REPLAYGAIN_REFERENCE_LOUDNESS tag. - * Fixed a bug in Ogg FLAC encoding where metadata was not being updated properly. Existing Ogg FLAC files should be recoded to fix up the metadata, e.g. flac -Vf -S 10s --ogg file.ogg - * In the developer libraries, the interface has been simplfied by merging the three decoding layers into a single class; ditto for the encoders. Also, libOggFLAC has been merged into libFLAC and libOggFLAC++ has been merged into libFLAC++ so there is a single API supporting both native FLAC and Ogg FLAC. -* FLAC format: - * New [PICTURE](https://xiph.org/flac/format.html#def_PICTURE) metadata block for storing things like cover art. - * Speaker assignments and channel orders for 3-6 channels (see [frame header](https://xiph.org/flac/format.html#frame_header)). - * Further restrictions on the [FLAC subset](https://xiph.org/flac/format.html#subset) when the sample rate is <=48kHz; in this case the maximum LPC order is now 12 and maximum blocksize is 4608\. This is to further limit the processing and memory requirements for hardware implementations while not measurably affecting compression. -* Ogg FLAC format: - * (none) -* flac: - * Improved the [-F](https://xiph.org/flac/documentation_tools_flac.html#flac_options_decode_through_errors) option to allow decoding of FLAC files whose metadata is corrupted, and other kinds of severe corruption. - * Encoder can now take FLAC and Ogg FLAC as input. The output FLAC file will have all the same metadata as the original unless overridden with options on the command line. - * Encoder can now take WAVEFORMATEXTENSIBLE WAVE files as input; decoder will output WAVEFORMATEXTENSIBLE WAVE files when necessary to conform to the latest Microsoft specifications. - * Now properly supports AIFF and WAVEFORMATEXTENSIBLE multichannel input, performing necessary channel reordering both for encoding and decoding. WAVEFORMATEXTENSIBLE channel mask is also saved to a tag on encoding and restored on decoding for situations when there is no natural mapping to FLAC channel assignments. - * Expanded support for "odd" sample resolutions to WAVE and AIFF input; all resolutions from 4 to 24 bits-per-sample now supported for all input types. - * Added a new option [--tag-from-file](https://xiph.org/flac/documentation_tools_flac.html#flac_options_tag_from_file) for setting a tag from file (e.g. for importing a cuesheet as a tag). - * Added a new option [--picture](https://xiph.org/flac/documentation_tools_flac.html#flac_options_picture) for adding pictures. - * Added a new option [--apodization](https://xiph.org/flac/documentation_tools_flac.html#flac_options_apodization) for specifying the window function(s) to be used in LPC analysis. - * Added support for encoding from non-compressed AIFF-C ([SF #1090933](http://sourceforge.net/p/flac/bugs/143/)). - * Importing of non-CDDA-compliant cuesheets now only issues a warning, not an error (see [here](http://www.hydrogenaud.io/forums/index.php?showtopic=31282)). - * MD5 comparison failures on decoding are now an error instead of a warning and will also return a non-zero exit code ([SF #1493725](http://sourceforge.net/p/flac/bugs/221/)). - * The default padding size is now 8K, or 64K if the input audio stream is more than 20 minutes long. - * Fixed a bug in cuesheet parsing where it would return an error if the last line of the cuesheet did not end with a newline. - * Fixed a bug that caused a crash when -a and -t were used together ([SF #1229481](http://sourceforge.net/p/flac/bugs/173/)). - * Fixed a bug with --sector-align where appended samples were not always totally silent ([SF #1237707](http://sourceforge.net/p/flac/bugs/179/)). - * Fixed bugs with --sector-align and raw input files. - * Fixed a bug printing out unknown AIFF subchunk names ([SF #1267476](http://sourceforge.net/p/flac/bugs/186/)). - * Fixed a bug where WAVE files with "data" subchunks of size 0 where accepted ([SF #1293830](http://sourceforge.net/p/flac/bugs/190/)). - * Fixed a bug where sync error at end-of-stream of truncated files was not being caught ([SF #1244071](http://sourceforge.net/p/flac/bugs/183/)). - * Fixed a problem with filename parsing if file does not have extension but also has a . in the path ([SF #1161916](http://sourceforge.net/p/flac/bugs/159/)). - * Fixed a problem with fractional-second parsing for --skip/--until in some locales ([SF #1031043](http://sourceforge.net/p/flac/bugs/125/)). - * Increase progress report rate when -p and -e are used together ([SF #1580122](http://sourceforge.net/p/flac/bugs/229/)). -* metaflac: - * Added support for read-only operations on Ogg FLAC files. - * Added a new option [--set-tag-from-file](https://xiph.org/flac/documentation_tools_metaflac.html#metaflac_shorthand_set_tag_from_file) for setting a tag from file (e.g. for importing a cuesheet as a tag). - * Added a new option [--import-picture-from](https://xiph.org/flac/documentation_tools_metaflac.html#metaflac_shorthand_import_picture_from) for importing pictures. - * Added a new option [--export-picture-to](https://xiph.org/flac/documentation_tools_metaflac.html#metaflac_shorthand_export_picture_to) for exporting pictures. - * Added shorthand operation [--remove-replay-gain](https://xiph.org/flac/documentation_tools_metaflac.html#metaflac_shorthand_remove_replay_gain) for removing ReplayGain tags. - * [--export-cuesheet-to](https://xiph.org/flac/documentation_tools_metaflac.html#metaflac_shorthand_export_cuesheet_to) now properly specifies the FLAC file name ([SF #1272825](http://sourceforge.net/p/flac/feature-requests/46/)). - * Importing of non-CDDA-compliant cuesheets now issues a warning. - * Removed the following deprecated tag editing options; you should use the new option names shown instead: - * Removed --show-vc-vendor; use --show-vendor-tag - * Removed --show-vc-field; use --show-tag - * Removed --remove-vc-all; use --remove-all-tags - * Removed --remove-vc-field; use --remove-tag - * Removed --remove-vc-firstfield; use --remove-first-tag - * Removed --set-vc-field; use --set-tag - * Removed --import-vc-from; use --import-tags-from - * Removed --export-vc-to; use --export-tags-to - * Disallow multiple input FLAC files when --import-tags-from=- is used ([SF #1082577](http://sourceforge.net/p/flac/bugs/141/)). -* plugins: - * When ReplayGain is on, if tags for the preferred kind of gain (album/track) are not in a stream, the other kind will be used. - * Added ReplayGain info to file info box in XMMS plugin - * Fixed UTF-8 decoder to disallow non-shortest-form and surrogate sequences (see [here](http://www.unicode.org/versions/corrigendum1.html)). -* build system: - * Added support for building on OS/2 with EMX ([SF #1229495](http://sourceforge.net/p/flac/bugs/174/)) - * Added support for building with Borland C++ ([SF #1599018](http://sourceforge.net/p/flac/patches/17/)) - * Added a --disable-xmms-plugin option to configure to prevent building the XMMS plugin ([SF #930494](http://sourceforge.net/p/flac/feature-requests/33/)). - * Added a --disable-doxygen-docs option to configure for disabling Doxygen-based API doc generation ([SF #1365935](http://sourceforge.net/p/flac/patches/12/)). - * Added a --disable-thorough-tests option to configure to do the basic library, stream, and tool tests in a reasonable time ([SF #1077948](http://sourceforge.net/p/flac/feature-requests/40/)). - * Added large file support with AC_SYS_LARGEFILE; use --disable-largefile with configure to disable. -* libraries: - * Merged libOggFLAC into libFLAC; both formats are now supported through the same API. - * Merged libOggFLAC++ into libFLAC++; both formats are now supported through the same API. - * libFLAC and libFLAC++: Simplified encoder setup with new FLAC__stream_encoder_set_compression_level() function. - * libFLAC: Improved compression with no impact on FLAC format or decoding time by adding a windowing stage before LPC analysis. - * libFLAC: Fixed a bug where missing STREAMINFO fields (min/max framesize, total samples, MD5 sum) and seek point offsets were not getting rewritten back to Ogg FLAC file ([SF #1338969](http://sourceforge.net/p/flac/bugs/197/)). - * libFLAC: Fixed a bug in cuesheet parsing where it would return an error if the last line of the cuesheet did not end with a newline. - * libFLAC: Fixed UTF-8 decoder to disallow non-shortest-form and surrogate sequences (see [here](http://www.unicode.org/versions/corrigendum1.html)). - * libFLAC: Fixed a bug in the return value for FLAC__stream_decoder_set_metadata_respond_application() and FLAC__stream_decoder_set_metadata_ignore_application() when there was a memory allocation error ([SF #1235005](http://sourceforge.net/p/flac/bugs/176/)). -* Interface changes (see also the [porting guide](https://xiph.org/flac/api/group__porting__1__1__2__to__1__1__3.html) for specific instructions on porting to FLAC 1.1.3): - * all libraries; - * Merged libOggFLAC into libFLAC; both formats are now supported through the same API. - * Merged libOggFLAC++ into libFLAC++; both formats are now supported through the same API. - * Merged seekable stream decoder and file decoder into the stream decoder. - * Merged seekable stream encoder and file encoder into the stream encoder. - * Added #defines for the API version number to make porting easier; see include/lib*FLAC*/export.h. - * libFLAC: - * **Added** FLAC__stream_encoder_set_apodization() - * **Added** FLAC__stream_encoder_set_compression_level() - * **Added** FLAC__metadata_object_cuesheet_calculate_cddb_id() - * **Added** FLAC__metadata_get_cuesheet() - * **Added** FLAC__metadata_get_picture() - * **Added** FLAC__metadata_chain_read_ogg() and FLAC__metadata_chain_read_ogg_with_callbacks() - * **Changed** FLAC__stream_encoder_finish() now returns a FLAC__bool to signal a verify failure, or error processing last frame or updating metadata. - * **Changed** FLAC__StreamDecoderState: removed state FLAC__STREAM_DECODER_UNPARSEABLE_STREAM - * **Changed** FLAC__StreamDecoderErrorStatus: new error code FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM - * The above two changes mean that when the decoder encounters what it thinks are unparseable frames from a future decoder, instead of returning a fatal error with the FLAC__STREAM_DECODER_UNPARSEABLE_STREAM state, it just calls the error callback with FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM and leaves the behavior up to the application. - * libFLAC++: - * **Added** FLAC::Metadata::Picture - * **Added** FLAC::Encoder::Stream::set_apodization() - * **Added** FLAC::Encoder::Stream::set_compression_level() - * **Added** FLAC::Metadata::CueSheet::calculate_cddb_id() - * **Added** FLAC::Metadata::get_cuesheet() - * **Added** FLAC::Metadata::get_picture() - * **Changed** FLAC::Metadata::Chain::read() to accept a flag denoting Ogg FLAC input - * **Changed** FLAC::Decoder::Stream::finish() now returns a bool to signal an MD5 failure like FLAC__stream_decoder_finish() does. - * **Changed** FLAC::Encoder::Stream::finish() now returns a bool to signal a verify failure, or error processing last frame or updating metadata. - * libOggFLAC: - * Merged into libFLAC. - * libOggFLAC++: - * Merged into libFLAC++. - -## FLAC 1.1.2 (05-Feb-2005) - -* General: - * Sped up decoding by a few percent overall. - * Sped up encoding when not using LPC (i.e. when using flac options -0, -1, -2, or -l 0). - * Fixed a decoding bug that could cause sync errors with some ID3v1-tagged FLAC files. - * Added [HTML documentation for metaflac](https://xiph.org/flac/documentation_tools_metaflac.html#metaflac). -* FLAC format: - * (none) -* Ogg FLAC format: - * (none) -* flac: - * New option [--input-size](https://xiph.org/flac/documentation_tools_flac.html#flac_options_input_size) to manually specify the input size when encoding raw samples from stdin. -* metaflac: - * (none) -* plugins: - * Added support for HTTP streaming in XMMS plugin. **NOTE**: there is a bug in the XMMS mpg123 plugin that hijacks FLAC streams; to fix it you will need to add the '.flac' extension to the list of exceptions in Input/mpg123/mpg123.c:is_our_file() in the XMMS sources and recompile. -* build system: - * (none) -* libraries: - * libFLAC: Sped up Rice block decoding in the bitbuffer, resulting in decoding speed gains of a few percent. - * libFLAC: Sped up encoding when not using LPC (i.e. max_lpc_order == 0). - * libFLAC: Trailing NUL characters maintained on Vorbis comment entries so they can be treated like C strings. - * libFLAC: More FLAC tag (i.e. Vorbis comment) validation. - * libFLAC: Fixed a bug in the logic that determines the frame or sample number in a frame header; the bug could cause sync errors with some ID3v1-tagged FLAC files. - * libFLAC, libOggFLAC: Can now be compiled to use only integer instructions, including encoding. The decoder is almost completely integer anyway but there were a couple places that needed a fixed-point replacement. There is no fixed-point version of LPC analysis yet, so if libFLAC is compiled integer-only, the encoder will behave as if the max LPC order is 0 (i.e. used fixed predictors only). LPC decoding is supported in all cases as it always was integer-only. -* Interface changes: - * libFLAC: - * **Changed:** Metadata object interface now maintains a trailing NUL on Vorbis comment entries for convenience. - * **Changed:** Metadata object interface now validates all Vorbis comment entries on input and returns false if an entry does not conform to the Vorbis comment spec. - * **Added** FLAC__format_vorbiscomment_entry_name_is_legal() - * **Added** FLAC__format_vorbiscomment_entry_value_is_legal() - * **Added** FLAC__format_vorbiscomment_entry_is_legal() - * **Added** FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair() - * **Added** FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair() - * **Changed** the signature of FLAC__metadata_object_vorbiscomment_entry_matches(): the first argument is now FLAC__StreamMetadata_VorbisComment_Entry entry (was const FLAC__StreamMetadata_VorbisComment_Entry \*entry), i.e. entry is now pass-by-value. - * libFLAC++: - * **Changed:** Metadata object interface now maintains a trailing NUL on Vorbis comment values for convenience. - * **Changed:** Metadata object interface now validates all Vorbis comment entries on input and returns false if an entry does not conform to the Vorbis comment spec. - * **Changed:** All Metadata objects' operator=() methods now return a reference to themselves. - * **Added** methods to FLAC::Metadata::VorbisComment::Entry for setting comment values from null-terminated strings: - * Entry(const char \*field) - * Entry(const char \*field_name, const char \*field_value) - * bool set_field(const char \*field) - * bool set_field_value(const char \*field_value) - * **Changed** the signature of FLAC::Metadata::VorbisComment::get_vendor_string() and FLAC::Metadata::VorbisComment::set_vendor_string() to use a UTF-8, NUL-terminated string const FLAC__byte * for the vendor string instead of FLAC::Metadata::VorbisComment::Entry. - * **Added** FLAC::Metadata::*::assign() to all Metadata objects. - * **Added** bool FLAC::Metadata::get_tags(const char \*filename, VorbisComment &tags) - * libOggFLAC: - * (none) - * libOggFLAC++: - * (none) - -## FLAC 1.1.1 (01-Oct-2004) - -* General: - * Ogg FLAC seeking now works - * New optimizations almost double the decoding speed on PowerPC (e.g. Mac G4/G5) - * A native OS X release thanks to updated Project Builder and autotools files -* FLAC format: - * Made invalid the metadata block type 127 so that audio frames can always be distinguished from metadata by seeing 0xff as the first byte. (This was also required for the Ogg FLAC mapping.) -* Ogg FLAC format: - * First official FLAC->Ogg bitstream mapping standardized (see new [FLAC-to-Ogg mapping specification](ogg_mapping.html)). See the documentation for the [--ogg](https://xiph.org/flac/documentation_tools_flac.html#flac_options_ogg) switch about having to re-encode older Ogg FLAC files. -* flac: - * Print an error when output file already exists instead of automatically overwriting. - * New option [-f](https://xiph.org/flac/documentation_tools_flac.html#flac_options_force) ([--force](https://xiph.org/flac/documentation_tools_flac.html#flac_options_force)) to force overwriting if the output file already exists. - * New option [--cue](https://xiph.org/flac/documentation_tools_flac.html#flac_options_cue) to select a specific section to decode using cuesheet track/index points. - * New option [--totally-silent](https://xiph.org/flac/documentation_tools_flac.html#flac_options_totally_silent) to suppress all output. - * New (but undocumented) option --apply-replaygain-which-is-not-lossless which applies ReplayGain to the decoded output. See [this thread](http://www.hydrogenaud.io/forums/index.php?showtopic=17293&st=11) for usage and caveats. - * When encoding to Ogg FLAC, use a random serial number (instead of 0 as was done before) when a serial number is not specified. - * When encoding multiple Ogg FLAC streams, --serial-number or random serial number sets the first number, which is then incremented for subsequent streams (before, the same serial number was used for all streams). - * Decoder no longer exits with an error when writing to stdout and the pipe is broken. - * Better explanation of common error messages. - * Default extension when writing AIFF files is .aif (before, it was .aiff). - * Write more common representation of SANE numbers in AIFF files. - * Bug fix: calculating ReplayGain on 48kHz streams. - * Bug fix: check for supported block alignments in WAVE files. - * Bug fix: "offset" field in AIFF SSND chunk properly handled. - * Bug fix: [#679166](http://sourceforge.net/p/flac/bugs/77/): flac doesn't respect RIFF subchunk padding byte. - * Bug fix: [#828391](http://sourceforge.net/p/flac/bugs/90/): --add-replay-gain segfaults. - * Bug fix: [#851155](http://sourceforge.net/p/flac/bugs/96/): Can't seek to position in flac file. - * Bug fix: [#851756](http://sourceforge.net/p/flac/bugs/97/): flac --skip --until reads entire file. - * Bug fix: [#877122](http://sourceforge.net/p/flac/bugs/100/): problem parsing cuesheet with CATALOG entry. - * Bug fix: [#896057](http://sourceforge.net/p/flac/bugs/104/): parsing ISRC number from cuesheet. -* metaflac: - * Renamed the tag editing options as follows (the ...-vc-... options still work but are deprecated): - * --show-vc-vendor becomes --show-vendor-tag - * --show-vc-field becomes --show-tag - * --remove-vc-all becomes --remove-all-tags - * --remove-vc-field becomes --remove-tag - * --remove-vc-firstfield becomes --remove-first-tag - * --set-vc-field becomes --set-tag - * --import-vc-from becomes --import-tags-from - * --export-vc-to becomes --export-tags-to - * Better explanation of common error messages. - * Bug fix: calculating ReplayGain on 48kHz streams. - * Bug fix: incorrect numbers when printing seek points. -* plugins: - * Speed optimization in ReplayGain synthesis. - * Speed optimization in XMMS playback. - * Support for big-endian architectures in XMMS plugin. - * Removed support for ID3 tags. - * Bug fix: make hard limiter default to off in XMMS plugin. - * Bug fix: stream length calculation bug in XMMS plugin, debian bug #200435 - * Bug fix: small memory leak in XMMS plugin. -* build system: - * ordinals.h is now static, not a build-generated file anymore. -* libraries: - * libFLAC: PPC+Altivec optimizations of some decoder routines. - * libFLAC: Make stream encoder encode the blocksize and sample rate in the frame header if at all possible (not in STREAMINFO), even if subset encoding was not requested. - * libFLAC: Bug fix: fixed seek routine where infinite loop could happen when seeking past end of stream. - * libFLAC, libFLAC++: added methods to skip single frames, useful for quickly finding frame boundaries (see interface changes below). - * libOggFLAC, libOggFLAC++: New seekable-stream and file encoder and decoder APIs to match native FLAC APIs (see interface changes below). -* Interface changes: - * libFLAC: - * **Added** FLAC__metadata_get_tags() - * **Added** callback-based versions of metadata editing functions: - * FLAC__metadata_chain_read_with_callbacks() - * FLAC__metadata_chain_write_with_callbacks() - * FLAC__metadata_chain_write_with_callbacks_and_tempfile() - * FLAC__metadata_chain_check_if_tempfile_needed() - * **Added** decoder functions for skipping single frames, also useful for quickly finding frame boundaries: - * FLAC__stream_decoder_skip_single_frame() - * FLAC__seekable_stream_decoder_skip_single_frame() - * FLAC__file_decoder_skip_single_frame() - * **Added** new required tell callback on seekable stream encoder: - * FLAC__SeekableStreamEncoderTellStatus and FLAC__SeekableStreamEncoderTellStatusString\[\] - * FLAC__SeekableStreamEncoderTellCallback - * FLAC__seekable_stream_encoder_set_tell_callback() - * **Changed** FLAC__SeekableStreamEncoderState by adding FLAC__SEEKABLE_STREAM_ENCODER_TELL_ERROR - * **Changed** Tell callback is now required to initialize seekable stream encoder - * **Deleted** erroneous and unimplemented FLAC__file_decoder_process_remaining_frames() - * libFLAC++: - * **Added** FLAC::Metadata::get_tags() - * **Added** decoder functions for skipping single frames, also useful for quickly finding frame boundaries: - * FLAC::Decoder::Stream::skip_single_frame() - * FLAC::Decoder::SeekableStream::skip_single_frame() - * FLAC::Decoder::File::skip_single_frame() - * **Added** encoder functions for setting metadata: - * FLAC::Encoder::Stream::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks) - * FLAC::Encoder::SeekableStream::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks) - * FLAC::Encoder::File::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks) - * **Added** new required tell callback on seekable stream encoder: - * pure virtual FLAC::Encoder::SeekableStream::tell_callback() - * **Changed** Tell callback is now required to initialize seekable stream encoder - * **Deleted** the following methods: - * FLAC::Decoder::Stream::State::resolved_as_cstring() - * FLAC::Encoder::Stream::State::resolved_as_cstring() - * libOggFLAC: - * **Added** OggFLAC__SeekableStreamDecoder interface - * **Added** OggFLAC__FileDecoder interface - * **Added** OggFLAC__SeekableStreamEncoder interface - * **Added** OggFLAC__FileEncoder interface - * **Added** OggFLAC__stream_decoder_get_resolved_state_string() - * **Added** OggFLAC__stream_encoder_get_resolved_state_string() - * **Added** OggFLAC__stream_encoder_set_metadata_callback() - * **Changed** OggFLAC__StreamDecoderState by adding OggFLAC__STREAM_DECODER_END_OF_STREAM - * libOggFLAC++: - * **Added** OggFLAC::Decoder::SeekableStream interface - * **Added** OggFLAC::Decoder::File interface - * **Added** OggFLAC::Encoder::SeekableStream interface - * **Added** OggFLAC::Encoder::File interface - * **Added** OggFLAC::Decoder::Stream::get_resolved_state_string() - * **Added** OggFLAC::Encoder::Stream::get_resolved_state_string() - * **Added** pure virtual OggFLAC::Encoder::Stream::metadata_callback() - -## FLAC 1.1.0 (26-Jan-2003) - -General: - -* All code is now [Valgrind](http://valgrind.org/)-clean! -* New [CUESHEET](https://xiph.org/flac/format.html#def_CUESHEET) metadata block for storing CD TOC and index point information. Now a CD can be completely backed up to a single FLAC file for archival. -* [ReplayGain](http://www.replaygain.org/) support. -* Better compression of 24-bit files. -* More complete AIFF support. -* 3DNow! optimizations enabled by default. -* Complete MSVC build system with .dsp projects for everything, which can build both static libs and DLLs, and in debug or release mode, all in the same source tree. - -flac: - -* Can now decode FLAC to AIFF; new --force-aiff-format option. -* New --cuesheet option for reading and storing a cuesheet when encoding a whole CD. Automatically creates seek points for track and index points unless --no-cued-seekpoints is used. -* New --replay-gain option for calculating ReplayGain values and storing them as tags. -* New --until option complements --skip to stop decoding at a specified point in the stream. -* --skip and --until now also accept mm:ss.ss format. -* New -S #s flavor to specify seekpoints every '#' number of seconds. -* flac now defaults to -S 10s instead of -S 100x for the seek table. -* flac now adds a 4k PADDING block by default (turn off with --no-padding). -* Fixed a bug with --skip and AIFF-to-FLAC encoding. -* Fixed a bug where decoding a FLAC file whose total_samples==0 in the STREAMINFO would corrupt the WAVE header. - -metaflac: - -* New --import-cuesheet-from option for reading and storing a cuesheet to a FLAC-encoded CD. Automatically creates seek points for track and index points unless --no-cued-seekpoints is used. -* New --export-cuesheet-to option for writing a cuesheet from a FLAC file for use with CD authoring software. -* New --add-replay-gain option for calculating ReplayGain values and storing them as tags. -* New --add-seekpoint option to add seekpoints to an existing FLAC file. Includes new --add-seekpoint=#s flavor to add seekpoints every '#' number of seconds. - -XMMS plugin: - -* Configurable sample resolution conversion with dither. -* ReplayGain support with customizable noise shaping, pre-amp, and optional hard limiter. -* New Vorbis comment editor. -* File info now works. -* Bitrate now shows the smoothed instantaneous bitrate. -* Uses the ARTIST tag if there is no PERFORMER tag. - -Winamp2 plugin: - -* Configurable sample resolution conversion with dither. -* ReplayGain support with customizable noise shaping, pre-amp, and optional hard limiter. -* File info now works. -* Uses the ARTIST tag if there is no PERFORMER tag. - -Libraries (developers take note!): - -* All code and tests are instrumented for Valgrind. All tests run Valgrind-clean, meaning no memory leaks or buffer over/under-runs. -* Separate 64-bit datapath through the filter in libFLAC for better compression of >16 bps files. -* FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT) now sets the vendor string. -* The documentation on the usage of FLAC::Iterator::get_block() in libFLAC++ has an important correction. If you use this class make sure to read [this](https://xiph.org/flac/api/group__flacpp__metadata__level2.html). - -## FLAC 1.0.4 (24-Sep-2002) - -Plugins: - -* Support for Vorbis comments, ID3 v1 and v2 tags. -* Configurable title formatting and charset conversion in XMMS plugin. -* Support for 8- and 24-bit FLAC files. There is a compile-time option for raw 24-bit output or 24bps-to-16bps linear dithering (the default). - -flac: - -* Improved option parser (now uses getopt). -* AIFF input support (thanks to Brady Patterson). -* Small decoder speedup. -* --sector-align now supported for raw input files. -* New -T, --tag options for adding Vorbis comments while encoding. -* New --serial-number option for use with --ogg. -* Automatically writes vendor string in Vorbis comments. -* Drastically reduced memory requirements. -* Fixed bug where extra fmt/data chunks that were supposed to be skipped were not getting skipped. -* Fixed bug in granulepos setting for Ogg FLAC streams. -* Fixed memory leak when encoding multiple files with -V. - -metaflac: - -* UTF-8 support in Vorbis comments. -* New --import-vc-from and --export-vc-to commands for importing/exporting Vorbis comments from/to a file. For example, the following can be used to copy tags back and forth: -metaflac --export-vc-to=- --no-utf8-convert file.flac | vorbiscomment --raw -w file.ogg -vorbiscomment --raw -l file.ogg | metaflac --import-vc-from=- --no-utf8-convert file.flac - -* Fixed [bug #606796](http://sourceforge.net/p/flac/bugs/54/) where metaflac was failing on read-only files. - -Libraries: - -* All APIs now meticulously documented via Doxygen. [See here](https://xiph.org/flac/api/index.html). -* New libOggFLAC and libOggFLAC++ libraries. These wrap around libFLAC to provide encoding and decoding of Ogg FLAC streams, providing interfaces similar to the ones of the native FLAC libraries. These are also documented via Doxygen. -* New FLAC__SeekableStreamEncoder and FLAC__FileEncoder in libFLAC simplify common encoding tasks. -* New verify mode in all encoders. -* FLAC__stream_encoder_finish() now resets the defaults just like the stream decoders. -* Drastically reduced memory requirements of encoders and decoders. -* Encoder now automatically writes vendor string in VORBIS_COMMENT block. -* Encoding speedup of fixed predictors and MD5 speedup for 16bps mono/stereo signals on x86 (thanks to Miroslav Lichvar). -* Fixed bug in metadata interface where a bps in STREAMINFO > 16 was incorrectly parsed. -* Fixed bug where aborting stream decoder could cause infinite loop. -* Behavior change: simplified decoder \*_process() commands. -* Behavior change: calling FLAC__stream_encoder_init() calls write callback once for "fLaC" signature and once for each metadata block. - * Behavior change: deprecated do_escape_coding and rice_parameter_search_distance in encoder. - -## FLAC 1.0.3 (03-Jul-2002) - -New features: - -* 24-bit input support restored in flac. -* Decoder speedup in libFLAC, which is directly passed on to the command-line decoder and plugins. -* New -F option to flac to continue decoding in spite of errors. -* Correctly set granulepos in Ogg packets so seeking Ogg FLAC streams will be easier. -* New [VORBIS_COMMENT](https://xiph.org/flac/format.html#metadata_block_vorbis_comment) metadata block for tagging with Vorbis-style comments. -* Vastly improved metaflac, now with many editing and tagging options. -* Partial id3v1 support in Winamp plugins. -* Updated Winamp 3 plugin. -* Note: new semantics for -P option in flac. -* Note: removed -R option in flac. - -New library features: - -* Previously mentioned decoder speedup in libFLAC. -* New metadata interface to libFLAC for manipulating metadata in FLAC files. -* New libFLAC++ API, an object wrapper around libFLAC. -* New [VORBIS_COMMENT](https://xiph.org/flac/format.html#metadata_block_vorbis_comment) metadata block for tagging with Vorbis-style comments. -* Customizable metadata filtering by type in decoders. -* Stream encoder can take an arbitrary list of metadata blocks, instead of just one SEEKTABLE and/or PADDING block. - -Bugs fixed: - -* Fixed bug with using pipes under Windows. -* Fixed several bugs in the plugins and made them more robust in general. -* Fixed bug in flac where decoding to WAVE of a FLAC file with 0 for total_samples in the STREAMINFO block yielded a WAVE chunk of 0 size. -* Fixed bug in Ogg packet numbering. - -## FLAC 1.0.2 (03-Dec-2001) - -* This release is only to fix a bug that was causing some of the plugins to crash sporadically. It can also affect libFLAC users that reuse one file decoder instance for multiple files - -## FLAC 1.0.1 (14-Nov-2001) - -New features for users: - -* Support for Ogg-FLAC, i.e. flac can now read and write FLAC streams using Ogg as the transport layer. -* New Winamp 3 plugin based on the Wasabi Beta 1 SDK. -* New utilities for adding FLAC support to the Monkey's Audio GUI (see [how](https://xiph.org/flac/documentation_tasks.html#monkey)). -* Mac OS X support. The download area now contains an OS X binary release. -* Mingw32 support. -* Better handling of MS-specific 'fmt' chunks in WAVE files. - -New features for developers: - -* Added a SeekableStreamDecoder layer between StreamDecoder and FileDecoder. This makes it easier to use libFLAC in situations where files have been abstracted away. See the latest [documentation](https://xiph.org/flac/api/index.html) for more. The interface for the StreamDecoder and FileDecoder remain the same and are still binary-compatible with libFLAC 1.0. -* Drastically reduced the stack requirements of the encoder. - -Bug fixes: - -* Fixed a serious bug with flac and raw input where the encoder was trying to rewind when it shouldn't, which would add 12 junk samples to the encoded file. This was not present in WAVE encoding. -* Fixed a minor bug in libFLAC with setting the file name to stdin on a file decoder. -* Fixed a minor bug in libFLAC where multiple calls to setting the file name on a file decoder caused leaked memory. -* Fixed a minor bug in metaflac, now correctly skips an id3v2 tag if present. -* Fixed a minor bug in metaflac, now correctly skips long metadata blocks. - -## FLAC 1.0 (20-Jul-2001) - -It's finally here. There are a few new features but mostly it is minor bug fixes since 0.10: - -* New '--sector-align' option to flac which aligns a group of encoded files on CD audio sector boundaries. -* New '--output-prefix' option to flac to allow the user to prepend a prefix to all output filenames (useful, for example, for encoding/decoding to a different directory). -* Better WAVE autodetection (doesn't rely on ungetc() anymore). -* Cleaner one-line encoding/decoding stats. -* Changes to the libFLAC interface and type names to make binary compatibility easier to maintain in the future. -* New '--sse-os' option to 'configure' to enable faster SSE-based routines. -* Another (hopefully last) fix to the Winamp 2 plugin. -* Slightly improved Rice parameter estimation. -* Bug fixes for some very rare corner cases when encoding. - -## FLAC 0.10 (07-Jun-2001) - -This is probably the final beta. There have been many improvements in the last two months: - -* Both the encoder and decoder have been significantly sped up. Aside from C improvements, the code base now has an assembly infrastructure that allows assembly routines for different architectures to be easily integrated. Many key routines have now have faster IA-32 implementations (thanks to Miroslav). -* A new metadata block [SEEKTABLE](https://xiph.org/flac/format.html#def_SEEKTABLE) has been defined to hold an arbitrary number of seek points, which speeds up seeking within a stream. -* flac now has a command-line usage similar to 'gzip'; make sure to see the latest [documentation](https://xiph.org/flac/documentation.html) for the new usage. It also attempts to preserve the input file's timestamp and permissions. -* The -# options in flac have been tweaked to yield the best compression-to-encode-time ratios. The new default is -5. -* flac can now usually autodetect WAVE files when encoding so that -fw is usually not needed when encoding from stdin. -* The WAVE reader in flac now just ignores (with a warning) unsupported sub-chunks instead of aborting with an error. -* Added an option '--delete-input-file' to flac which automatically deletes the input after a successful encode/decode. -* Added an option '-o' to flac to force the output file name (the old usage of "flac - outputfilename" is no longer supported). -* Changed the XMMS plugin to send smaller chunks of samples (now 512) so that visualization is not slow. -* Fixed a bug in the stream decoder where the decoded samples counter got corrupted after a seek. - -## FLAC 0.9 (31-Mar-2001) - -Bug fixes and some new features: - -* FLAC's sync code has been lengthened to 14 bits from 9 bits. This should enable a faster and more robust synchronization mechanism. -* Two reserved bits were added to the frame header. -* A CRC-16 was added to the FLAC frame footer, and the decoder now does frame integrity checking based on the CRC. -* The format now includes a new subframe field to indicate when a subblock has one or more 0 LSBs for all samples. This increases compression on some kinds of data. -* Added two options to the analysis mode, one for including the residual signal in the analysis file, and one for generating gnuplot files of each subframe's residual distribution with some statistics. See the latest [documentation](https://xiph.org/flac/documentation.html#analysis_options). -* XMMS plugin now supports 8-bit files. -* Fixed a bug in the Winamp2 plugin where the audio sounded garbled. -* Fixed a bug in the Winamp2 plugin where Winamp would hang sporadically at the end of a track (c.f. [bug #231197](http://sourceforge.net/projects/flac/&atid=113478)). - -## FLAC 0.8 (05-Mar-2001) - -Changes since 0.7: - -* Created a new utility called metaflac. It is a metadata editor for .flac files. Right now it just lists the contents of the metadata blocks but eventually it will allow update/insertion/deletion. -* Added two new metadata blocks: PADDING which has an obvious function, and APPLICATION, which is meant to be open to third party applications. See the [latest format docs](https://xiph.org/flac/format.html#def_APPLICATION) for more info, or the new [id registration page](https://xiph.org/flac/id.html). -* Added a -P option to flac to reserve a PADDING block when encoding. -* Added support for 24-bit files to flac (the FLAC format always supported it). -* Started the Winamp3 plugin. -* Greatly expanded the test suite, adding more streams (24-bit streams, noise streams, non-audio streams, more patterns) and more option combinations to the encoder. The test suite runs about 30 streams and over 5000 encodings now. -* Fixed a bug in libFLAC that happened when using an exhaustive LPC coefficient quantization search with 8 bps input. -* Fixed a bug in libFLAC where the error estimation in the fixed predictor could overflow. -* Fixed a bug in libFLAC where LPC was attempted even when the autocorrelation coefficients implied it wouldn't help. -* Reworked the LPC coefficient quantizer, which also fixed another bug that might occur in rare cases. -* Really fixed the '-V overflow' bug (c.f. [bug #231976](http://sourceforge.net/p/flac/bugs/5/)). -* Fixed a bug in flac related to the decode buffer sizing.FLAC is very close to being ready for an official release. The only known problems left are with the Winamp plugins, which should be fixed soon, and pipes with MSVC. - -## FLAC 0.7 (12-Feb-2001) - -Changes: - -* Fixed a bug that happened when both -fr and --seek were used at the same time. -* Fixed a bug with -p (c.f. [bug #230992](http://sourceforge.net/p/flac/bugs/1/)). -* Fixed a bug that happened when using large (>32K) blocksizes and -V (c.f. [bug #231976](http://sourceforge.net/p/flac/bugs/5/)). -* Fixed a bug where encoder was double-closing a file. -* Expanded the test suite. -* Added more optimization flags for gcc, which should speed up flac. - -## FLAC 0.6 (28-Jan-2001) - -The encoder is now much faster. The -m option has been sped up by 4x and -r improved, meaning that in the default compression mode (-6), encoding should be at least 3 times faster. Other changes: - -* Some bugs related to flac and pipes were fixed -* A "loose mid-side" (-M) option to the encoder has been added, which adaptively switches between independent and mid-side coding, instead of the exhaustive search that -m does. -* An analyze mode (-a) has been added to flac. This is useful mainly for developers; currently it will dump info about each frame and subframe to a file. It's a text file in a format that can be easily processed by scripts; a separate analysis program is in the works. -* The source now has an autoconf/libtool-based build system. This should allow the source to build "out-of-the-box" on many more platforms. - -## FLAC 0.5 (15-Jan-2001) - -This is the first beta version of FLAC. Being beta, there will be no changes to the format that will break older streams, unless a serious bug involving the format is found. What this means is that, barring such a bug, streams created with 0.5 will be decodable by future versions. This version also includes some new features: - -* An [MD5 signature](http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html) of the unencoded audio is computed during encoding, and stored in the Encoding metadata block in the stream header. When decoding, flac will now compute the MD5 signature of the decoded data and compare it against the signature in the stream header. -* A test mode (-t) has been added to flac. It works like decode mode but doesn't write an output file. - -## FLAC 0.4 (23-Dec-2000) - -This version fixes a bug in the constant subframe detection. More importantly, a verify option (-V) has been added to flac that verifies the encoding process. With this option turned on, flac will create a parallel decoder while encoding to make sure that the encoded output decodes to exactly match the original input. In this way, any unknown bug in the encoder will be caught and flac will abort with an error message. diff --git a/Engine/lib/flac/CMakeLists.txt b/Engine/lib/flac/CMakeLists.txt deleted file mode 100644 index ada6af865..000000000 --- a/Engine/lib/flac/CMakeLists.txt +++ /dev/null @@ -1,291 +0,0 @@ -# 3.1 is OK for most parts. However: -# 3.3 is needed in src/libFLAC -# 3.5 is needed in src/libFLAC/ia32 -# 3.9 is needed in 'doc' because of doxygen_add_docs() -cmake_minimum_required(VERSION 3.5) - -if(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES OR DEFINED ENV{CFLAGS} OR DEFINED ENV{CXXFLAGS})) - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo") -endif() - -project(FLAC VERSION 1.4.3) # HOMEPAGE_URL "https://www.xiph.org/flac/") - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -option(BUILD_CXXLIBS "Build libFLAC++" ON) -option(BUILD_PROGRAMS "Build and install programs" OFF) -option(BUILD_EXAMPLES "Build and install examples" OFF) -option(BUILD_TESTING "Build tests" OFF) -option(BUILD_DOCS "Build and install doxygen documents" OFF) -option(WITH_FORTIFY_SOURCE "Enable protection against buffer overflows" ON) -option(WITH_STACK_PROTECTOR "Enable GNU GCC stack smash protection" ON) -option(INSTALL_MANPAGES "Install MAN pages" OFF) -option(INSTALL_PKGCONFIG_MODULES "Install PkgConfig modules" ON) -option(INSTALL_CMAKE_CONFIG_MODULE "Install CMake package-config module" ON) -option(WITH_OGG "ogg support (default: test for libogg)" OFF) -option(BUILD_SHARED_LIBS "Build shared instead of static libraries" OFF) - -set(VERSION ${PROJECT_VERSION}) - -if(NOT UNIX) - # This is to make sure testing works when building with a DLL - set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/objs) - set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/objs) -endif() - -if(WITH_OGG) - if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ogg") - add_subdirectory("ogg") - set(OGG_FOUND 1 CACHE INTERNAL "ogg has been added as subdirectory") - set_target_properties(ogg PROPERTIES FOLDER Libraries) - if(BUILD_TESTING) - set_target_properties(test_bitwise test_framing PROPERTIES FOLDER Tests) - endif() - else() - if(NOT TARGET Ogg::ogg) - find_package(Ogg REQUIRED) - else() - set(OGG_FOUND 1 CACHE INTERNAL "ogg has already been built") - endif() - set(OGG_PACKAGE "ogg") - endif() -endif() - -find_program (HAVE_GIT git) - -if(HAVE_GIT) - execute_process( - COMMAND git --git-dir=.git describe --tags --exact-match - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_COMMIT_TAG - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - execute_process( - COMMAND git --git-dir=.git log -1 --pretty=format:%h - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_COMMIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - execute_process( - COMMAND git --git-dir=.git log -1 --pretty=format:%cd --date=format:%Y%m%d - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_COMMIT_DATE - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) -endif() - -if(NOT WIN32) - find_package(Iconv) - set(HAVE_ICONV ${Iconv_FOUND}) -endif() - -if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") - set(CMAKE_C_FLAGS "-Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Winline ${CMAKE_C_FLAGS}") - set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG ${CMAKE_C_FLAGS_RELEASE}") -endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef ${CMAKE_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${CMAKE_CXX_FLAGS_RELEASE}") -endif() -if(MSVC) - set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /Oi /Ot /Oy /DNDEBUG ${CMAKE_C_FLAGS_RELEASE}") -endif() - -include(CMakePackageConfigHelpers) -include(CheckCCompilerFlag) -include(CheckCXXCompilerFlag) -include(CheckSymbolExists) -include(CheckFunctionExists) -include(CheckIncludeFile) -include(CheckCSourceCompiles) -include(CheckCXXSourceCompiles) -include(CheckLibraryExists) -include(GNUInstallDirs) -include(UseSystemExtensions) -include(TestBigEndian) -enable_testing() - -check_include_file("byteswap.h" HAVE_BYTESWAP_H) -check_include_file("inttypes.h" HAVE_INTTYPES_H) -check_include_file("stdint.h" HAVE_STDINT_H) -check_include_file("stdbool.h" HAVE_STDBOOL_H) -check_include_file("arm_neon.h" FLAC__HAS_NEONINTRIN) - -if(NOT HAVE_STDINT_H OR NOT HAVE_STDBOOL_H) - message(SEND_ERROR "Header stdint.h and/or stdbool.h not found") -endif() - -if(MSVC) - check_include_file("intrin.h" FLAC__HAS_X86INTRIN) -else() - check_include_file("x86intrin.h" FLAC__HAS_X86INTRIN) -endif() - -check_function_exists(fseeko HAVE_FSEEKO) - -check_c_source_compiles("int main() { return __builtin_bswap16 (0) ; }" HAVE_BSWAP16) -check_c_source_compiles("int main() { return __builtin_bswap32 (0) ; }" HAVE_BSWAP32) -check_c_source_compiles(" - #include - int main() - { - char* cs = nl_langinfo(CODESET); - return !cs; - }" - HAVE_LANGINFO_CODESET) - -test_big_endian(CPU_IS_BIG_ENDIAN) - -check_c_compiler_flag(-Werror HAVE_WERROR_FLAG) -check_c_compiler_flag(-Wdeclaration-after-statement HAVE_DECL_AFTER_STMT_FLAG) -check_c_compiler_flag(-mstackrealign HAVE_STACKREALIGN_FLAG) -check_cxx_compiler_flag(-Weffc++ HAVE_WEFFCXX_FLAG) - -if(MINGW AND (WITH_FORTIFY_SOURCE OR WITH_STACK_PROTECTOR)) - check_library_exists("ssp.a" __stack_chk_fail "" HAVE_LIBSSP) - if(NOT HAVE_LIBSSP) - message(WARNING "Could not find libssp in MinGW, stack protection and/or FORTIFY_SOURCE are unavailable") - else() - link_libraries("ssp.a") - endif() -elseif(NOT MSVC) - set(HAVE_LIBSSP 1) -endif() - -if(WITH_STACK_PROTECTOR) - if(NOT MSVC) - check_c_compiler_flag("-fstack-protector-strong" HAVE_STACK_PROTECTOR_FLAG) - endif() -endif() - -if(HAVE_WERROR_FLAG) - option(ENABLE_WERROR "Enable -Werror in all Makefiles" OFF) -endif() - -add_compile_options( - $<$:/wd4267> - $<$:/wd4996> - $<$:-Werror> - $<$,$>:-Weffc++> - $<$,$>:-Wdeclaration-after-statement>) - -if(WITH_FORTIFY_SOURCE AND HAVE_LIBSSP) - add_definitions(-D_FORTIFY_SOURCE=2) -endif() - -if(HAVE_STACK_PROTECTOR_FLAG AND HAVE_LIBSSP) - add_compile_options($<$,$>:-fstack-protector-strong>) -endif() - -if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND HAVE_STACKREALIGN_FLAG) - add_compile_options($<$,$>:-mstackrealign>) -endif() - -include_directories("include") - -include_directories("${CMAKE_CURRENT_BINARY_DIR}") -add_definitions(-DHAVE_CONFIG_H) - -if(MSVC) - add_definitions( - -D_CRT_SECURE_NO_WARNINGS - -D_USE_MATH_DEFINES) -endif() -if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) - add_definitions(-DFLAC__OVERFLOW_DETECT) -endif() - -add_subdirectory("src") -add_subdirectory("microbench") -if(BUILD_DOCS) - add_subdirectory("doc") -endif() -if(BUILD_EXAMPLES) - add_subdirectory("examples") -endif() -if(BUILD_TESTING) - add_subdirectory("test") -endif() - -# The following folder layout is mostly for MSVC -set_property(GLOBAL PROPERTY USE_FOLDERS ON) - -set_target_properties(FLAC grabbag getopt replaygain_analysis replaygain_synthesis utf8 PROPERTIES FOLDER Libraries) -if(BUILD_CXXLIBS) - set_target_properties(FLAC++ PROPERTIES FOLDER Libraries) -endif() -if(BUILD_PROGRAMS) - set_target_properties(flacapp metaflac PROPERTIES FOLDER Programs) -endif() -if(BUILD_TESTING) - set_target_properties(test_libFLAC test_libs_common test_picture test_seeking test_streams test_cuesheet PROPERTIES FOLDER Tests) - if(BUILD_CXXLIBS) - set_target_properties(test_libFLAC++ PROPERTIES FOLDER Tests) - endif() -endif() -if(BUILD_EXAMPLES) - set_target_properties(decode_file encode_file PROPERTIES FOLDER Examples) - if(BUILD_CXXLIBS) - set_target_properties(decode_file_cxx encode_file_cxx PROPERTIES FOLDER Examples) - endif() -endif() -if(BUILD_UTILS) - set_target_properties(flacdiff flactimer PROPERTIES FOLDER Utils) -endif() - -configure_file(config.cmake.h.in config.h) - -if(INSTALL_CMAKE_CONFIG_MODULE) - install( - EXPORT targets - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" - NAMESPACE FLAC::) - export(EXPORT targets NAMESPACE FLAC:: FILE FLACTargets.cmake) - - configure_package_config_file( - ${PROJECT_SOURCE_DIR}/flac-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake - INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") - write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake COMPATIBILITY AnyNewerVersion) - - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" - ) - - install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") -endif() - -file(GLOB FLAC_HEADERS "include/FLAC/*.h") -file(GLOB FLAC++_HEADERS "include/FLAC++/*.h") -install(FILES ${FLAC_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/FLAC") -install(FILES ${FLAC++_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/FLAC++") -if(INSTALL_MANPAGES) - find_program (HAVE_PANDOC pandoc) - if(HAVE_PANDOC) - file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/man") - add_custom_command( - OUTPUT man/flac.1 - COMMAND pandoc --standalone --to man "${CMAKE_SOURCE_DIR}/man/flac.md" > man/flac.1 - ) - add_custom_command( - OUTPUT man/metaflac.1 - COMMAND pandoc --standalone --to man "${CMAKE_SOURCE_DIR}/man/metaflac.md" > man/metaflac.1 - ) - add_custom_target(man ALL DEPENDS man/flac.1 man/metaflac.1) - install(FILES "${CMAKE_BINARY_DIR}/man/flac.1" "${CMAKE_BINARY_DIR}/man/metaflac.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") - else() - if(EXISTS "${CMAKE_SOURCE_DIR}/man/flac.1" AND EXISTS "${CMAKE_SOURCE_DIR}/man/metaflac.1") - install(FILES "man/flac.1" "man/metaflac.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") - else() - message(SEND_ERROR "Pandoc nor prebuild manpages are found. Cannot install manpages. Set INSTALL_MANPAGES to OFF to build without man pages") - endif() - endif() -endif() diff --git a/Engine/lib/flac/CONTRIBUTING.md b/Engine/lib/flac/CONTRIBUTING.md deleted file mode 100644 index 4c6ae799c..000000000 --- a/Engine/lib/flac/CONTRIBUTING.md +++ /dev/null @@ -1,74 +0,0 @@ -Thanks for considering contributing to the FLAC project! - -Contributing to FLAC is possible in many ways. Among them are - -- Reporting bugs or other issues at https://github.com/xiph/flac/issues -- Submitting patches at https://github.com/xiph/flac/pulls -- Testing FLAC playing devices and software at - https://wiki.hydrogenaud.io/index.php?title=FLAC_decoder_testbench - -General communication not specific to issues is generally done through -the FLAC mailing lists: - -- For user questions and discussions: - https://lists.xiph.org/mailman/listinfo/flac -- For developer questions and discussions: - https://lists.xiph.org/mailman/listinfo/flac-dev - -## Goals - -Since FLAC is an open-source project, it's important to have a set of -goals that everyone works to. They may change slightly from time to time -but they're a good guideline. Changes should be in line with the goals -and should not attempt to embrace any of the anti-goals. - -**Goals** - -- FLAC should be and stay an open format with an open-source reference - implementation. -- FLAC should be lossless. This seems obvious but lossy compression - seems to creep into every audio codec. This goal also means that flac - should stay archival quality and be truly lossless for all input. - Testing of releases should be thorough. -- FLAC should yield respectable compression, on par or better than other - lossless codecs. -- FLAC should allow at least realtime decoding on even modest hardware. -- FLAC should support fast sample-accurate seeking. -- FLAC should allow gapless playback of consecutive streams. This follows from the lossless goal. -- The FLAC project owes a lot to the many people who have advanced the - audio compression field so freely, and aims also to contribute through - the open-source development of new ideas. - -**Anti-goals** - -- Lossy compression. There are already many suitable lossy formats (Ogg - Vorbis, MP3, etc.). -- Copy prevention, DRM, etc. There is no intention to add any copy - prevention methods. Of course, we can't stop someone from encrypting a - FLAC stream in another container (e.g. the way Apple encrypts AAC in - MP4 with FairPlay), that is the choice of the user. - - -## Contributing patches - -Contributions to FLAC should be licensed with the same license as the -part of the FLAC project the contribution belongs to. These are - -- libFLAC and libFLAC++ are licensed under Xiph.org's - BSD-like license (see COPYING.Xiph), so contributions to these - libraries should also be licensed under this license, otherwise they - cannot be accepted -- the flac and metaflac command line programs are licensed under GPLv2, - see COPYING.GPL -- the helper libraries for flac and metaflac (which are in src/share) - are licensed under varying licenses, see the license preamble for each - file to see how they are licensed - -Patches can be contributed through GitHub as a Pull Request. -Alternatively you can supply patches through the mailing list. - -## Code style - -FLAC does have its own peculiar coding style that does not seem to fit -general categories. You can use `git clang-format` to have your patch -auto-formatted similar to the rest of the code. diff --git a/Engine/lib/flac/COPYING.FDL b/Engine/lib/flac/COPYING.FDL deleted file mode 100644 index 4a0fe1c8d..000000000 --- a/Engine/lib/flac/COPYING.FDL +++ /dev/null @@ -1,397 +0,0 @@ - GNU Free Documentation License - Version 1.2, November 2002 - - - Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - -0. PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -functional and useful document "free" in the sense of freedom: to -assure everyone the effective freedom to copy and redistribute it, -with or without modifying it, either commercially or noncommercially. -Secondarily, this License preserves for the author and publisher a way -to get credit for their work, while not being considered responsible -for modifications made by others. - -This License is a kind of "copyleft", which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - - -1. APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work, in any medium, that -contains a notice placed by the copyright holder saying it can be -distributed under the terms of this License. Such a notice grants a -world-wide, royalty-free license, unlimited in duration, to use that -work under the conditions stated herein. The "Document", below, -refers to any such manual or work. Any member of the public is a -licensee, and is addressed as "you". You accept the license if you -copy, modify or distribute the work in a way requiring permission -under copyright law. - -A "Modified Version" of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A "Secondary Section" is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (Thus, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The "Invariant Sections" are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. If a -section does not fit the above definition of Secondary then it is not -allowed to be designated as Invariant. The Document may contain zero -Invariant Sections. If the Document does not identify any Invariant -Sections then there are none. - -The "Cover Texts" are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. A Front-Cover Text may -be at most 5 words, and a Back-Cover Text may be at most 25 words. - -A "Transparent" copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, that is suitable for revising the document -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup, or absence of markup, has been arranged to thwart -or discourage subsequent modification by readers is not Transparent. -An image format is not Transparent if used for any substantial amount -of text. A copy that is not "Transparent" is called "Opaque". - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML, PostScript or PDF designed for human modification. Examples of -transparent image formats include PNG, XCF and JPG. Opaque formats -include proprietary formats that can be read and edited only by -proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML, PostScript or PDF produced by some word -processors for output purposes only. - -The "Title Page" means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, "Title Page" means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - -A section "Entitled XYZ" means a named subunit of the Document whose -title either is precisely XYZ or contains XYZ in parentheses following -text that translates XYZ in another language. (Here XYZ stands for a -specific section name mentioned below, such as "Acknowledgements", -"Dedications", "Endorsements", or "History".) To "Preserve the Title" -of such a section when you modify the Document means that it remains a -section "Entitled XYZ" according to this definition. - -The Document may include Warranty Disclaimers next to the notice which -states that this License applies to the Document. These Warranty -Disclaimers are considered to be included by reference in this -License, but only as regards disclaiming warranties: any other -implication that these Warranty Disclaimers may have is void and has -no effect on the meaning of this License. - - -2. VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. - - -3. COPYING IN QUANTITY - -If you publish printed copies (or copies in media that commonly have -printed covers) of the Document, numbering more than 100, and the -Document's license notice requires Cover Texts, you must enclose the -copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a computer-network location from which the general network-using -public has access to download using public-standard network protocols -a complete Transparent copy of the Document, free of added material. -If you use the latter option, you must take reasonably prudent steps, -when you begin distribution of Opaque copies in quantity, to ensure -that this Transparent copy will remain thus accessible at the stated -location until at least one year after the last time you distribute an -Opaque copy (directly or through your agents or retailers) of that -edition to the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. - - -4. MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission. -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has fewer than five), - unless they release you from this requirement. -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. -D. Preserve all the copyright notices of the Document. -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below. -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice. -H. Include an unaltered copy of this License. -I. Preserve the section Entitled "History", Preserve its Title, and add - to it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section Entitled "History" in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence. -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the "History" section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. -K. For any section Entitled "Acknowledgements" or "Dedications", - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor acknowledgements - and/or dedications given therein. -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. -M. Delete any section Entitled "Endorsements". Such a section - may not be included in the Modified Version. -N. Do not retitle any existing section to be Entitled "Endorsements" - or to conflict in title with any Invariant Section. -O. Preserve any Warranty Disclaimers. - -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section Entitled "Endorsements", provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. - - -5. COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice, and that you preserve all their Warranty Disclaimers. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections Entitled "History" -in the various original documents, forming one section Entitled -"History"; likewise combine any sections Entitled "Acknowledgements", -and any sections Entitled "Dedications". You must delete all sections -Entitled "Endorsements". - - -6. COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. - - -7. AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, is called an "aggregate" if the copyright -resulting from the compilation is not used to limit the legal rights -of the compilation's users beyond what the individual works permit. -When the Document is included in an aggregate, this License does not -apply to the other works in the aggregate which are not themselves -derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one half of -the entire aggregate, the Document's Cover Texts may be placed on -covers that bracket the Document within the aggregate, or the -electronic equivalent of covers if the Document is in electronic form. -Otherwise they must appear on printed covers that bracket the whole -aggregate. - - -8. TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License, and all the license notices in the -Document, and any Warranty Disclaimers, provided that you also include -the original English version of this License and the original versions -of those notices and disclaimers. In case of a disagreement between -the translation and the original version of this License or a notice -or disclaimer, the original version will prevail. - -If a section in the Document is Entitled "Acknowledgements", -"Dedications", or "History", the requirement (section 4) to Preserve -its Title (section 1) will typically require changing the actual -title. - - -9. TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. - - -10. FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License "or any later version" applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - - -ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - - Copyright (c) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - -If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, -replace the "with...Texts." line with this: - - with the Invariant Sections being LIST THEIR TITLES, with the - Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. - -If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. diff --git a/Engine/lib/flac/COPYING.GPL b/Engine/lib/flac/COPYING.GPL deleted file mode 100644 index d159169d1..000000000 --- a/Engine/lib/flac/COPYING.GPL +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/Engine/lib/flac/COPYING.LGPL b/Engine/lib/flac/COPYING.LGPL deleted file mode 100644 index 5ab7695ab..000000000 --- a/Engine/lib/flac/COPYING.LGPL +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/Engine/lib/flac/COPYING.Xiph b/Engine/lib/flac/COPYING.Xiph deleted file mode 100644 index 86629af14..000000000 --- a/Engine/lib/flac/COPYING.Xiph +++ /dev/null @@ -1,29 +0,0 @@ -Copyright (C) 2000-2009 Josh Coalson -Copyright (C) 2011-2023 Xiph.Org Foundation - -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 the Xiph.Org Foundation nor the names of its -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 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. diff --git a/Engine/lib/flac/Makefile.am b/Engine/lib/flac/Makefile.am deleted file mode 100644 index 3bb523e88..000000000 --- a/Engine/lib/flac/Makefile.am +++ /dev/null @@ -1,61 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -# -# automake provides the following useful targets: -# -# all: build all programs and libraries using the current -# configuration (set by configure) -# -# check: build and run all self-tests -# -# clean: remove everything except what's required to build everything -# -# distclean: remove everything except what goes in the distribution -# - -ACLOCAL_AMFLAGS = -I m4 - -SUBDIRS = doc include m4 man src test microbench oss-fuzz - -if EXAMPLES -SUBDIRS += examples -endif - -EXTRA_DIST = \ - CMakeLists.txt \ - config.cmake.h.in \ - flac-config.cmake.in \ - cmake/CheckA64NEON.c.in \ - cmake/CheckA64NEON.cmake \ - cmake/CheckCPUArch.c.in \ - cmake/CheckCPUArch.cmake \ - cmake/FindOgg.cmake \ - cmake/UseSystemExtensions.cmake \ - CHANGELOG.md \ - COPYING.FDL \ - COPYING.GPL \ - COPYING.LGPL \ - COPYING.Xiph \ - README.md \ - autogen.sh \ - config.rpath \ - depcomp \ - ltmain.sh - -CLEANFILES = *~ diff --git a/Engine/lib/flac/README.md b/Engine/lib/flac/README.md deleted file mode 100644 index 2979862a6..000000000 --- a/Engine/lib/flac/README.md +++ /dev/null @@ -1,278 +0,0 @@ - - -# Free Lossless Audio Codec (FLAC) - -FLAC is open source software that can reduce the amount of storage space -needed to store digital audio signals without needing to remove -information in doing so. - -The files read and produced by this software are called FLAC files. As -these files (which follow the [FLAC format](https://xiph.org/flac/format.html)) -can be read from and written to by other software as well, this software -is often referred to as the FLAC reference implementation. - -FLAC has been developed by volunteers. If you want to help out, see -CONTRIBUTING.md for more information. - -## Components - -FLAC is comprised of - * libFLAC, a library which implements reference encoders and - decoders for native FLAC and Ogg FLAC, and a metadata interface - * libFLAC++, a C++ object wrapper library around libFLAC - * `flac`, a command-line program for encoding and decoding files - * `metaflac`, a command-line program for viewing and editing FLAC - metadata - * user and API documentation - -The libraries (libFLAC, libFLAC++) are licensed under Xiph.org's -BSD-like license (see COPYING.Xiph). All other programs and plugins are -licensed under the GNU General Public License (see COPYING.GPL). The -documentation is licensed under the GNU Free Documentation License -(see COPYING.FDL). - -## Documentation - -For documentation of the `flac` and `metaflac` command line tools, see -the directory man, which contains the files flac.md and metaflac.md - -The API documentation is in html and is generated by Doxygen. It can be -found in the directory doc/html/api. It is included in a release tarball -and must be build with Doxygen when the source is taken directly from -git. - -The directory examples contains example source code on using libFLAC and -libFLAC++. - -Documentation concerning the FLAC format itself (which can be used to -create software reading and writing FLAC software independent from -libFLAC) was included in previous releases, but can now be found on -https://datatracker.ietf.org/doc/draft-ietf-cellar-flac/ Additionally -a set of files for conformance testing called the FLAC decoder testbench -can be found at https://github.com/ietf-wg-cellar/flac-test-files - -If you have questions about FLAC that this document does not answer, -please submit them at the following tracker so this document can be -improved: - -https://github.com/xiph/flac/issues - -## Building FLAC - -All components of the FLAC project can be build with a variety of -compilers (including GCC, Clang, Visual Studio, Intel C++ Compiler) on -many architectures (inluding x86, x86_64, ARMv7, ARMv8 and PowerPC) -for many different operating systems. - -To do this, FLAC provides two build systems: one using GNU's autotools -and one with CMake. Both differ slighly in configuration options, but -should be considered equivalent for most use cases. - -FLAC used to provide files specifically for building with Visual Studio, -but these have been removed in favor of using CMake. - -## Building with CMake - -CMake is a cross-platform build system. FLAC can be built on Windows, -Linux, Mac OS X using CMake. - -You can use either CMake's CLI or GUI. We recommend you to have a -separate build folder outside the repository in order to not spoil it -with generated files. It is possible however to do a so-called in-tree -build, in that case /path/to/flac-build in the following examples is -equal to /path/to/flac-source. - -### CMake CLI - -Go to your build folder and run something like this: - -``` -/path/to/flac-build$ cmake /path/to/flac-source -``` - -or e.g. in Windows shell - -``` -C:\path\to\flac-build> cmake \path\to\flac-source -``` - -(provided that cmake is in your %PATH% variable) - -That will generate build scripts for the default build system (e.g. -Makefiles for UNIX). After that you start build with a command like -this: - -``` -/path/to/flac-build$ make -``` - -And afterwards you can run tests or install the built libraries and -headers - -``` -/path/to/flac-build$ make test -/path/to/flac-build$ make install -``` - -If you want use a build system other than default add -G flag to cmake, -e.g.: - -``` -/path/to/flac-build$ cmake /path/to/flac-source -GNinja -/path/to/flac-build$ ninja -``` - -or: - -``` -/path/to/flac-build$ cmake /path/to/flac-source -GXcode -``` - -Use cmake --help to see the list of available generators. - -By default CMake will search for OGG. If CMake fails to find it you can -help CMake by specifying the exact path: - -``` -/path/to/flac-build$ cmake /path/to/flac-source -DOGG_ROOT=/path/to/ogg -``` - -If you would like CMake to build OGG alongside FLAC, you can place the -ogg sources directly in the flac source directory as a subdirectory with -the name ogg, for example: - -``` -/path/to/flac-source/ogg -``` - -If you don't want to build flac with OGG support you can tell CMake not -to look for OGG: - -``` -/path/to/flac-build$ cmake /path/to/flac-source -DWITH_OGG=OFF -``` - -Other FLAC's options (e.g. building C++ lib or docs) can also be put to -cmake through -D flag. If you want to know what options are available, -use -LH: - -``` -/path/to/flac-build$ cmake /path/to/flac-source -LH -``` - -### CMake GUI (for Visual Studio) -It is likely that you would prefer to use the CMake GUI if you use -Visual Studio to build FLAC. It's in essence the same process as -building using CLI. - -Open cmake-gui. In the window select a source directory (the -repository's root), a build directory (some other directory outside the -repository). Then press button "Configure". CMake will ask you which -build system you prefer. Choose that version of Visual Studio which you -have on your system, choose whether you want to build for Win32 or x64. -Press OK. - -After CMake finishes you can change the configuration to your liking and -if you change anything, run Configure again. With the "Generate" button, -CMake creates Visual Studio files, which can be opened from Visual -Studio. With the button "Open Project" CMake will launch Visual Studio -and open the generated solution. You can use the project files as usual -but remember that they were generated by CMake. That means that your -changes (e.g. some additional compile flags) will be lost when you run -CMake next time. - -CMake searches by default for OGG on your system and returns an error -if it cannot find it. If you want to build OGG alongside FLAC, you can -download the OGG sources and extract them in a subdirectory of the FLAC -source directory with the name ogg (i.e. /path/to/flac-source/ogg) -before running CMake. If you don't want to build FLAC with OGG support, -untick the box following WITH_OGG flag in the list of variables in -cmake-gui window and run "Configure" again. - -If CMake fails to find MSVC compiler then running cmake-gui from MS -Developer comand prompt should help. - -## Building with GNU autotools - -FLAC uses autoconf and libtool for configuring and building. To -configure a build, open a commmand line/terminal and run `./configure` -You can provide options to this command, which are listed by running -`./configure --help`. - -In case the configure script is not present (for example when building -from git and not from a release tarball), it can be generated by running -`./autogen.sh`. This may require a libtool development package though. - -After configuration, build with `make`, verify the build with -`make check` and install with `make install`. Installation might require -administrator priviledged, i.e. `sudo make install`. - -The 'make check' step is optional; omit it to skip all the tests, which -can take about an hour to complete. Even though it will stop with an -explicit message on any failure, it does print out a lot of stuff so you -might want to capture the output to a file if you're having a problem. -Also, don't run 'make check' as root because it confuses some of the -tests. - -Summarizing: - -``` -./configure -make && make check -sudo make install -``` - -## Note to embedded developers - -libFLAC has grown larger over time as more functionality has been -included, but much of it may be unnecessary for a particular embedded -implementation. Unused parts may be pruned by some simple editing of -configure.ac and src/libFLAC/Makefile.am; the following dependency -graph shows which modules may be pruned without breaking things -further down: - -``` -metadata.h - stream_decoder.h - format.h - -stream_encoder.h - stream_decoder.h - format.h - -stream_decoder.h - format.h -``` - -In other words, for pure decoding applications, both the stream encoder -and metadata editing interfaces can be safely removed. Note that this -is specific to building the libraries for embedded use. The command line -tools do not provide such compartmentalization, and require a complete -libFLAC build to function. - -There is a section dedicated to embedded use in the libFLAC API -HTML documentation (see doc/html/api/index.html). - -Also, there are several places in the libFLAC code with comments marked -with "OPT:" where a #define can be changed to enable code that might be -faster on a specific platform. Experimenting with these can yield -faster binaries. diff --git a/Engine/lib/flac/autogen.sh b/Engine/lib/flac/autogen.sh deleted file mode 100644 index 491d3557e..000000000 --- a/Engine/lib/flac/autogen.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# Run this to set up the build system: configure, makefiles, etc. -# We trust that the user has a recent enough autoconf & automake setup -# (not older than a few years...) - -use_symlinks=" --symlink" - -case $1 in - --no-symlink*) - use_symlinks="" - echo "Copying autotool files instead of using symlinks." - ;; - *) - echo "Using symlinks to autotool files (use --no-symlinks to copy instead)." - ;; - esac - -test_program_errors=0 - -test_program () { - if ! command -v $1 >/dev/null 2>&1 ; then - echo "Missing program '$1'." - test_program_errors=1 - fi -} - -for prog in autoconf automake libtool pkg-config ; do - test_program $prog - done - -if test $(uname -s) != "Darwin" ; then - test_program gettext - fi - -test $test_program_errors -ne 1 || exit 1 - -#------------------------------------------------------------------------------- - -set -e - -if test $(uname -s) = "OpenBSD" ; then - # OpenBSD needs these environment variables set. - if test -z "$AUTOCONF_VERSION" ; then - AUTOCONF_VERSION=2.69 - export AUTOCONF_VERSION - echo "Defaulting to use AUTOCONF_VERSION version ${AUTOCONF_VERSION}." - else - echo "Using AUTOCONF_VERSION version ${AUTOCONF_VERSION}." - fi - if test -z "$AUTOMAKE_VERSION" ; then - AUTOMAKE_VERSION=1.15 - export AUTOMAKE_VERSION - echo "Defaulting to use AUTOMAKE_VERSION version ${AUTOMAKE_VERSION}." - else - echo "Using AUTOMAKE_VERSION version ${AUTOMAKE_VERSION}." - fi - fi - -srcdir=`dirname $0` -test -n "$srcdir" && cd "$srcdir" - -echo "Updating build configuration files for FLAC, please wait...." - -touch config.rpath -autoreconf --install $use_symlinks --force -#./configure "$@" && echo diff --git a/Engine/lib/flac/cmake/CheckA64NEON.c.in b/Engine/lib/flac/cmake/CheckA64NEON.c.in deleted file mode 100644 index 4d43d4fa5..000000000 --- a/Engine/lib/flac/cmake/CheckA64NEON.c.in +++ /dev/null @@ -1,6 +0,0 @@ -#include -int main (void) -{ - float64x2_t tmp; - tmp = vdupq_n_f64(0.0f); -} diff --git a/Engine/lib/flac/cmake/CheckA64NEON.cmake b/Engine/lib/flac/cmake/CheckA64NEON.cmake deleted file mode 100644 index 247b86485..000000000 --- a/Engine/lib/flac/cmake/CheckA64NEON.cmake +++ /dev/null @@ -1,14 +0,0 @@ -macro(CHECK_A64NEON VARIABLE) - if(NOT DEFINED HAVE_${VARIABLE}) - message(STATUS "Check whether A64 NEON can be used") - configure_file(${PROJECT_SOURCE_DIR}/cmake/CheckA64NEON.c.in ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckA64NEON.c @ONLY) - try_compile(HAVE_${VARIABLE} "${PROJECT_BINARY_DIR}" - "${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckA64NEON.c") - if(HAVE_${VARIABLE}) - message(STATUS "Check whether A64 NEON can be used - yes") - set(${VARIABLE} 1 CACHE INTERNAL "Result of CHECK_A64NEON" FORCE) - else () - message(STATUS "Check whether A64 NEON can be used - no") - endif() - endif () -endmacro(CHECK_A64NEON) diff --git a/Engine/lib/flac/cmake/CheckCPUArch.c.in b/Engine/lib/flac/cmake/CheckCPUArch.c.in deleted file mode 100644 index 549313947..000000000 --- a/Engine/lib/flac/cmake/CheckCPUArch.c.in +++ /dev/null @@ -1,7 +0,0 @@ -int main(void) { -#if @CHECK_CPU_ARCH_DEFINES@ - return 0; -#else - fail -#endif -} diff --git a/Engine/lib/flac/cmake/CheckCPUArch.cmake b/Engine/lib/flac/cmake/CheckCPUArch.cmake deleted file mode 100644 index 665fa6150..000000000 --- a/Engine/lib/flac/cmake/CheckCPUArch.cmake +++ /dev/null @@ -1,27 +0,0 @@ -macro(_CHECK_CPU_ARCH ARCH ARCH_DEFINES VARIABLE) - if(NOT DEFINED HAVE_${VARIABLE}) - message(STATUS "Check CPU architecture is ${ARCH}") - set(CHECK_CPU_ARCH_DEFINES ${ARCH_DEFINES}) - configure_file(${PROJECT_SOURCE_DIR}/cmake/CheckCPUArch.c.in ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c @ONLY) - try_compile(HAVE_${VARIABLE} "${PROJECT_BINARY_DIR}" - "${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c") - if(HAVE_${VARIABLE}) - message(STATUS "Check CPU architecture is ${ARCH} - yes") - set(${VARIABLE} 1 CACHE INTERNAL "Result of CHECK_CPU_ARCH" FORCE) - else () - message(STATUS "Check CPU architecture is ${ARCH} - no") - endif() - endif () -endmacro(_CHECK_CPU_ARCH) - -macro(CHECK_CPU_ARCH_X64 VARIABLE) - _CHECK_CPU_ARCH(x64 "defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" ${VARIABLE}) -endmacro(CHECK_CPU_ARCH_X64) - -macro(CHECK_CPU_ARCH_X86 VARIABLE) - _CHECK_CPU_ARCH(x86 "defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" ${VARIABLE}) -endmacro(CHECK_CPU_ARCH_X86) - -macro(CHECK_CPU_ARCH_ARM64 VARIABLE) - _CHECK_CPU_ARCH(arm64 "defined(__aarch64__) || defined(__arm64__)" ${VARIABLE}) -endmacro(CHECK_CPU_ARCH_ARM64) diff --git a/Engine/lib/flac/cmake/FindOgg.cmake b/Engine/lib/flac/cmake/FindOgg.cmake deleted file mode 100644 index b60c3526d..000000000 --- a/Engine/lib/flac/cmake/FindOgg.cmake +++ /dev/null @@ -1,26 +0,0 @@ -find_package(PkgConfig) -pkg_check_modules(_OGG QUIET ogg) - -find_path(OGG_INCLUDE_DIR - NAMES "ogg/ogg.h" - PATHS ${_OGG_INCLUDE_DIRS}) - -find_library(OGG_LIBRARY - NAMES ogg libogg - HINTS ${_OGG_LIBRARY_DIRS}) - -mark_as_advanced( - OGG_INCLUDE_DIR - OGG_LIBRARY) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Ogg - REQUIRED_VARS OGG_INCLUDE_DIR OGG_LIBRARY - VERSION_VAR _OGG_VERSION) - -if(OGG_FOUND AND NOT TARGET Ogg::ogg) - add_library(Ogg::ogg UNKNOWN IMPORTED) - set_target_properties(Ogg::ogg PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIR}" - IMPORTED_LOCATION "${OGG_LIBRARY}") -endif() diff --git a/Engine/lib/flac/cmake/UseSystemExtensions.cmake b/Engine/lib/flac/cmake/UseSystemExtensions.cmake deleted file mode 100644 index 604f4d369..000000000 --- a/Engine/lib/flac/cmake/UseSystemExtensions.cmake +++ /dev/null @@ -1,63 +0,0 @@ -include(CheckCSourceCompiles) - -check_c_source_compiles(" - #include - mbstate_t x; - int main() { return 0; }" - HAVE_MBSTATE) -if(NOT HAVE_MBSTATE) - check_c_source_compiles(" - #define _XOPEN_SOURCE 500 - #include - mbstate_t x; - int main() { return 0; }" - DODEFINE_XOPEN_SOURCE) -endif() -check_c_source_compiles(" - #define __EXTENSIONS__ 1 - #include - #ifdef HAVE_SYS_TYPES_H - # include - #endif - #ifdef HAVE_SYS_STAT_H - # include - #endif - #ifdef STDC_HEADERS - # include - # include - #else - # ifdef HAVE_STDLIB_H - # include - # endif - #endif - #ifdef HAVE_STRING_H - # if !defined STDC_HEADERS && defined HAVE_MEMORY_H - # include - # endif - # include - #endif - #ifdef HAVE_STRINGS_H - # include - #endif - #ifdef HAVE_INTTYPES_H - # include - #endif - #ifdef HAVE_STDINT_H - # include - #endif - #ifdef HAVE_UNISTD_H - # include - #endif - int main() { return 0; }" - DODEFINE_EXTENSIONS) - -add_definitions( - -D_DARWIN_C_SOURCE - -D_POSIX_PTHREAD_SEMANTICS - -D__STDC_WANT_IEC_60559_BFP_EXT__ - -D__STDC_WANT_IEC_60559_DFP_EXT__ - -D__STDC_WANT_IEC_60559_FUNCS_EXT__ - -D__STDC_WANT_IEC_60559_TYPES_EXT__ - -D__STDC_WANT_LIB_EXT2__ - -D__STDC_WANT_MATH_SPEC_FUNCS__ - -D_TANDEM_SOURCE) diff --git a/Engine/lib/flac/config.cmake.h.in b/Engine/lib/flac/config.cmake.h.in deleted file mode 100644 index acc73f084..000000000 --- a/Engine/lib/flac/config.cmake.h.in +++ /dev/null @@ -1,223 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -#cmakedefine AC_APPLE_UNIVERSAL_BUILD - -/* Target processor is big endian. */ -#cmakedefine01 CPU_IS_BIG_ENDIAN - -/* Target processor ARM64 */ -#cmakedefine FLAC__CPU_ARM64 - -/* Set FLAC__BYTES_PER_WORD to 8 (4 is the default) */ -#cmakedefine01 ENABLE_64_BIT_WORDS - -/* define to align allocated memory on 32-byte boundaries */ -#cmakedefine FLAC__ALIGN_MALLOC_DATA - -/* define if you have docbook-to-man or docbook2man */ -#cmakedefine FLAC__HAS_DOCBOOK_TO_MAN - -/* define if you have the ogg library */ -#cmakedefine01 OGG_FOUND -#define FLAC__HAS_OGG OGG_FOUND - -/* Set to 1 if is available. */ -#cmakedefine01 FLAC__HAS_X86INTRIN - -/* Set to 1 if is available. */ -#cmakedefine01 FLAC__HAS_NEONINTRIN - -/* Set to 1 if contains A64 intrinsics */ -#cmakedefine01 FLAC__HAS_A64NEONINTRIN - -/* define if building for Darwin / MacOS X */ -#cmakedefine FLAC__SYS_DARWIN - -/* define if building for Linux */ -#cmakedefine FLAC__SYS_LINUX - -/* define to enable use of AVX instructions */ -#cmakedefine WITH_AVX -#ifdef WITH_AVX - #define FLAC__USE_AVX -#endif - -/* Define to the commit date of the current git HEAD */ -#cmakedefine GIT_COMMIT_DATE "@GIT_COMMIT_DATE@" - -/* Define to the short hash of the current git HEAD */ -#cmakedefine GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" - -/* Define to the tag of the current git HEAD */ -#cmakedefine GIT_COMMIT_TAG "@GIT_COMMIT_TAG@" - -/* Compiler has the __builtin_bswap16 intrinsic */ -#cmakedefine HAVE_BSWAP16 - -/* Compiler has the __builtin_bswap32 intrinsic */ -#cmakedefine HAVE_BSWAP32 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_BYTESWAP_H - -/* define if you have clock_gettime */ -#cmakedefine HAVE_CLOCK_GETTIME - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_CPUID_H - -/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ -#cmakedefine HAVE_FSEEKO - -/* Define to 1 if you have the `getopt_long' function. */ -#cmakedefine HAVE_GETOPT_LONG - -/* Define if you have the iconv() function and it works. */ -#cmakedefine HAVE_ICONV - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H - -/* Define if you have and nl_langinfo(CODESET). */ -#cmakedefine HAVE_LANGINFO_CODESET - -/* lround support */ -#cmakedefine01 HAVE_LROUND - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MEMORY_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_IOCTL_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_TERMIOS_H - -/* Define to 1 if typeof works with your compiler. */ -#cmakedefine HAVE_TYPEOF - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_X86INTRIN_H - -/* Define as const if the declaration of iconv() needs const. */ -#cmakedefine ICONV_CONST - -/* Define if debugging is disabled */ -#cmakedefine NDEBUG - -/* Name of package */ -#cmakedefine PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#cmakedefine PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#cmakedefine PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#cmakedefine PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#cmakedefine PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#cmakedefine PACKAGE_URL - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "@PROJECT_VERSION@" - -/* The size of `off_t', as computed by sizeof. */ -#cmakedefine SIZEOF_OFF_T - -/* The size of `void*', as computed by sizeof. */ -#cmakedefine SIZEOF_VOIDP - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -#define _ALL_SOURCE -#endif - -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#ifndef _XOPEN_SOURCE -#cmakedefine DODEFINE_XOPEN_SOURCE 500 -#ifdef DODEFINE_XOPEN_SOURCE -#define _XOPEN_SOURCE DODEFINE_XOPEN_SOURCE -#endif -#endif - -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -#cmakedefine _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -#cmakedefine _TANDEM_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -#cmakedefine DODEFINE_EXTENSIONS -#ifdef DODEFINE_EXTENSIONS -#define __EXTENSIONS__ DODEFINE_EXTENSIONS -#endif -#endif - - -/* Target processor is big endian. */ -#define WORDS_BIGENDIAN CPU_IS_BIG_ENDIAN - -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - -/* Number of bits in a file offset, on hosts where this is settable. */ -#ifndef _FILE_OFFSET_BITS -# define _FILE_OFFSET_BITS 64 -#endif - -/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ -#ifndef _LARGEFILE_SOURCE -# define _LARGEFILE_SOURCE -#endif - -/* Define for large files, on AIX-style hosts. */ -#cmakedefine _LARGE_FILES - -/* Define to 1 if on MINIX. */ -#cmakedefine _MINIX - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -#cmakedefine _POSIX_1_SOURCE - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -#cmakedefine _POSIX_SOURCE - -/* Define to __typeof__ if your compiler spells it that way. */ -#cmakedefine typeof diff --git a/Engine/lib/flac/configure.ac b/Engine/lib/flac/configure.ac deleted file mode 100644 index 418677c7a..000000000 --- a/Engine/lib/flac/configure.ac +++ /dev/null @@ -1,602 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -# NOTE that for many of the AM_CONDITIONALs we use the prefix FLaC__ -# instead of FLAC__ since autoconf triggers off 'AC_' in strings - -AC_PREREQ(2.60) -AC_INIT([flac],[1.4.3],[flac-dev@xiph.org],[flac],[https://www.xiph.org/flac/]) -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_SRCDIR([src/flac/main.c]) -AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([foreign 1.10 -Wall tar-pax no-dist-gzip dist-xz subdir-objects]) -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -AX_CHECK_ENABLE_DEBUG -user_cflags=$CFLAGS - -#Prefer whatever the current ISO standard is. -AC_PROG_CC -AC_USE_SYSTEM_EXTENSIONS -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -LT_INIT([win32-dll disable-static pic-only]) -AM_PROG_AS -AC_PROG_CXX -XIPH_C_COMPILER_IS_CLANG -XIPH_GCC_REALLY_IS_GCC -AC_PROG_MAKE_SET -AC_PROG_MKDIR_P - -AC_SYS_LARGEFILE -AC_FUNC_FSEEKO - -AC_CHECK_SIZEOF(off_t,1) # Fake default value. -AC_CHECK_SIZEOF([void*]) -AC_SEARCH_LIBS([lround],[m], [AC_DEFINE(HAVE_LROUND,1,lround support)]) - -AM_PROG_CC_C_O -AC_C_INLINE -AC_C_TYPEOF - -AC_CHECK_HEADERS([stdint.h stdbool.h inttypes.h byteswap.h sys/auxv.h sys/param.h sys/ioctl.h termios.h x86intrin.h cpuid.h arm_neon.h]) - -if test "x$ac_cv_header_stdint_h" != xyes -o "x$ac_cv_header_stdbool_h" != xyes; then -AC_MSG_ERROR("Header stdint.h and/or stdbool.h not found") -fi - - -XIPH_C_BSWAP32 -XIPH_C_BSWAP16 - -ac_cv_c_big_endian=0 -ac_cv_c_little_endian=0 -AC_C_BIGENDIAN([ac_cv_c_big_endian=1], [ac_cv_c_little_endian=1], [ - AC_MSG_WARN([[*****************************************************************]]) - AC_MSG_WARN([[*** Not able to determine endian-ness of target processor. ]]) - AC_MSG_WARN([[*** The constants CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in ]]) - AC_MSG_WARN([[*** config.h may need to be hand editied. ]]) - AC_MSG_WARN([[*****************************************************************]]) -]) -AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian}, - [Target processor is big endian.]) -AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian}, - [Target processor is little endian.]) -AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, ${ac_cv_c_big_endian}, - [Target processor is big endian.]) - -AC_ARG_ENABLE(asm-optimizations, AS_HELP_STRING([--disable-asm-optimizations],[Do not use any CPU specific optimization routines]), asm_opt=no, asm_opt=yes) -AM_CONDITIONAL(FLaC__NO_ASM, test "x$asm_opt" = xno) -if test "x$asm_opt" = xno ; then -AC_DEFINE(FLAC__NO_ASM) -AH_TEMPLATE(FLAC__NO_ASM, [define to disable use of assembly code]) -fi - -dnl check for getauxval in standard library -AC_CHECK_FUNCS(getauxval) - -dnl check for getopt in standard library -dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] ) -AC_CHECK_FUNCS(getopt_long, [], []) - -AC_CHECK_SIZEOF(void*,1) - -asm_optimisation=no -case "$host_cpu" in - amd64|x86_64) - case "$host" in - *gnux32) - # x32 user space and 64 bit kernel. - cpu_x86_64=true - AC_DEFINE(FLAC__CPU_X86_64) - AH_TEMPLATE(FLAC__CPU_X86_64, [define if building for x86_64]) - ;; - *) - if test $ac_cv_sizeof_voidp = 4 ; then - # This must be a 32 bit user space running on 64 bit kernel so treat - # this as ia32. - cpu_ia32=true - AC_DEFINE(FLAC__CPU_IA32) - AH_TEMPLATE(FLAC__CPU_IA32, [define if building for ia32/i386]) - else - # x86_64 user space and kernel. - cpu_x86_64=true - AC_DEFINE(FLAC__CPU_X86_64) - AH_TEMPLATE(FLAC__CPU_X86_64, [define if building for x86_64]) - fi - ;; - esac - ;; - i*86) - cpu_ia32=true - AC_DEFINE(FLAC__CPU_IA32) - AH_TEMPLATE(FLAC__CPU_IA32, [define if building for ia32/i386]) - ;; - arm64|aarch64) - cpu_arm64=true - AC_DEFINE(FLAC__CPU_ARM64) - AH_TEMPLATE(FLAC__CPU_ARM64, [define if building for ARM]) - ;; -esac -AM_CONDITIONAL(FLAC__CPU_X86_64, test "x$cpu_x86_64" = xtrue) -AM_CONDITIONAL(FLaC__CPU_IA32, test "x$cpu_ia32" = xtrue) -AM_CONDITIONAL(FLAC__CPU_ARM64, test "x$cpu_arm64" = xtrue) - -if test "x$ac_cv_header_x86intrin_h" = xyes -a "x$asm_opt" = xyes; then - AC_DEFINE([FLAC__HAS_X86INTRIN], 1, [Set to 1 if is available.]) - asm_optimisation=yes -else - AC_DEFINE([FLAC__HAS_X86INTRIN], 0) -fi - -if test "x$ac_cv_header_arm_neon_h" = xyes -a "x$asm_opt" = xyes; then - AC_DEFINE([FLAC__HAS_NEONINTRIN], 1, [Set to 1 if is available.]) - AC_MSG_CHECKING([whether arm_neon.h has A64 functions]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include ]], - [[float64x2_t sum5; sum5 = vdupq_n_f64(0.0f);]])], - [AC_MSG_RESULT([yes]) - has_a64neon=yes], - [AC_MSG_RESULT([no])]) - if test "x$has_a64neon" = xyes; then - AC_DEFINE([FLAC__HAS_A64NEONINTRIN], 1, [Set to 1 if has A64 instructions.]) - asm_optimisation=yes - else - AC_DEFINE([FLAC__HAS_A64NEONINTRIN], 0) - fi -else - AC_DEFINE([FLAC__HAS_NEONINTRIN], 0) -fi - -case "$host" in - i386-*-openbsd3.[[0-3]]) OBJ_FORMAT=aoutb ;; - *-*-cygwin|*mingw*) OBJ_FORMAT=win32 ;; - *-*-darwin*) OBJ_FORMAT=macho ;; - *emx*) OBJ_FORMAT=aout ;; - *djgpp) OBJ_FORMAT=coff ;; - *) OBJ_FORMAT=elf ;; -esac -AC_SUBST(OBJ_FORMAT) - -os_is_windows=no -case "$host" in - *mingw*) - os_is_windows=yes - AC_CHECK_TOOL(RC,[windres],[:]) - ;; -esac - -AM_CONDITIONAL(OS_IS_WINDOWS, test "x$os_is_windows" = xyes) -AM_CONDITIONAL(HAVE_WINDRES, test "x$RC" != "x:") - -case "$host" in - *-linux-*) - sys_linux=true - AC_DEFINE(FLAC__SYS_LINUX) - AH_TEMPLATE(FLAC__SYS_LINUX, [define if building for Linux]) - ;; - *-*-darwin*) - sys_darwin=true - AC_DEFINE(FLAC__SYS_DARWIN) - AH_TEMPLATE(FLAC__SYS_DARWIN, [define if building for Darwin / MacOS X]) - ;; -esac -AM_CONDITIONAL(FLaC__SYS_DARWIN, test "x$sys_darwin" = xtrue) -AM_CONDITIONAL(FLaC__SYS_LINUX, test "x$sys_linux" = xtrue) - -if test "x$cpu_ia32" = xtrue || test "x$cpu_x86_64" = xtrue ; then -AC_DEFINE(FLAC__ALIGN_MALLOC_DATA) -AH_TEMPLATE(FLAC__ALIGN_MALLOC_DATA, [define to align allocated memory on 32-byte boundaries]) -fi - -AM_CONDITIONAL([DEBUG], [test "x${ax_enable_debug}" = "xyes" || test "x${ax_enable_debug}" = "xinfo"]) - -AC_ARG_ENABLE(avx, -AS_HELP_STRING([--disable-avx],[Disable AVX, AVX2 optimizations. There is runtime detection of CPU features, so disabling is only necessary when a compiler does not know about them]), -[case "${enableval}" in - yes) use_avx=true ;; - no) use_avx=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-avx) ;; -esac],[use_avx=true]) -AM_CONDITIONAL(FLaC__USE_AVX, test "x$use_avx" = xtrue) -if test "x$use_avx" = xtrue ; then -AC_DEFINE(FLAC__USE_AVX) -AH_TEMPLATE(FLAC__USE_AVX, [define to enable use of AVX instructions]) -fi - -AC_ARG_ENABLE(thorough-tests, -AS_HELP_STRING([--disable-thorough-tests],[Disable thorough (long) testing, do only basic tests]), -[case "${enableval}" in - yes) thorough_tests=true ;; - no) thorough_tests=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-thorough-tests) ;; -esac],[thorough_tests=true]) -AC_ARG_ENABLE(exhaustive-tests, -AS_HELP_STRING([--enable-exhaustive-tests],[Enable exhaustive testing (VERY long)]), -[case "${enableval}" in - yes) exhaustive_tests=true ;; - no) exhaustive_tests=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-exhaustive-tests) ;; -esac],[exhaustive_tests=false]) -if test "x$thorough_tests" = xfalse ; then -FLAC__TEST_LEVEL=0 -elif test "x$exhaustive_tests" = xfalse ; then -FLAC__TEST_LEVEL=1 -else -FLAC__TEST_LEVEL=2 -fi -AC_SUBST(FLAC__TEST_LEVEL) - -AC_ARG_ENABLE(werror, - AS_HELP_STRING([--enable-werror],[Enable -Werror in all Makefiles])) - -AC_ARG_ENABLE([stack-smash-protection], - [AS_HELP_STRING([--disable-stack-smash-protection],[Disable GNU GCC stack smash protection])],, - [AS_IF([test "$ac_cv_c_compiler_gnu" = "yes"], - [enable_stack_smash_protection=yes],[enable_stack_smash_protection=no])]) - -AC_ARG_ENABLE([fortify-source], - [AS_HELP_STRING([--disable-fortify-source],[Disable _FORTIFY_SOURCE buffer overflow protection])],, - [AS_IF([test "$ac_cv_c_compiler_gnu" = "yes"], - [enable_fortify_source=yes],[enable_fortify_source=no])]) - -case "$host" in - *mingw*) - if test "$enable_fortify_source" = "yes"; then - AC_SEARCH_LIBS(__memset_chk, ssp, , mingw_has_memset_chk=no) - fi - if test "$enable_stack_smash_protection" = "yes"; then - AC_SEARCH_LIBS(__stack_chk_fail, ssp, , mingw_has_stack_chk_fail=no) - fi - ;; -esac - - -AC_ARG_ENABLE(64-bit-words, - AS_HELP_STRING([--disable-64-bit-words],[Set FLAC__BYTES_PER_WORD to 4 (8 is the default)])) -if test "x$enable_64_bit_words" = xno ; then - AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],0,[Set FLAC__BYTES_PER_WORD to 8 (this is the default)]) -else - AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],1) -fi -AC_SUBST(ENABLE_64_BIT_WORDS) - -AC_ARG_ENABLE(valgrind-testing, -AS_HELP_STRING([--enable-valgrind-testing],[Run all tests inside Valgrind]), -[case "${enableval}" in - yes) FLAC__TEST_WITH_VALGRIND=yes ;; - no) FLAC__TEST_WITH_VALGRIND=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind-testing) ;; -esac],[FLAC__TEST_WITH_VALGRIND=no]) -AC_SUBST(FLAC__TEST_WITH_VALGRIND) - -AC_ARG_ENABLE(doxygen-docs, -AS_HELP_STRING([--disable-doxygen-docs],[Disable API documentation building via Doxygen]), -[case "${enableval}" in - yes) enable_doxygen_docs=true ;; - no) enable_doxygen_docs=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-doxygen-docs) ;; -esac],[enable_doxygen_docs=true]) -if test "x$enable_doxygen_docs" != xfalse ; then - AC_CHECK_PROGS(DOXYGEN, doxygen) -fi -AM_CONDITIONAL(FLaC__HAS_DOXYGEN, test -n "$DOXYGEN") - -if test ! -n "$DOXYGEN" && test -f "$srcdir/doc/FLAC.tag" && test -f "$srcdir/doc/api/modules.html" ; then - HAS_PREBUILT_DOXYGEN=yes -fi -AM_CONDITIONAL(FLaC__HAS_PREBUILT_DOXYGEN, test "x$HAS_PREBUILT_DOXYGEN" = xyes) - -dnl build FLAC++ or not -AC_ARG_ENABLE([cpplibs], -AS_HELP_STRING([--disable-cpplibs],[Do not build libFLAC++]), -[case "${enableval}" in - yes) disable_cpplibs=false ;; - no) disable_cpplibs=true ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-cpplibs) ;; -esac], [disable_cpplibs=false]) -AM_CONDITIONAL(FLaC__WITH_CPPLIBS, [test "x$disable_cpplibs" != xtrue]) - -AC_ARG_ENABLE([oss-fuzzers], - [AS_HELP_STRING([--enable-oss-fuzzers], - [Whether to generate the fuzzers for OSS-Fuzz (Clang only)])], - [have_oss_fuzzers=yes], [have_oss_fuzzers=no]) - -if test "x$have_oss_fuzzers" = "xyes"; then - if test "x$xiph_cv_c_compiler_clang" = "xyes" ; then - AM_CONDITIONAL([USE_OSSFUZZERS], [test "x$have_oss_fuzzers" = "xyes"]) - if test "x$LIB_FUZZING_ENGINE" = "x" ; then - # Only set this if it is empty. - LIB_FUZZING_ENGINE=-fsanitize=fuzzer - fi - else - AM_CONDITIONAL([USE_OSSFUZZERS], [test "false" = "true"]) - # Disable fuzzer if the compiler is not Clang. - AC_MSG_WARN([*** Ozz-Fuzz is disabled because that requires the Clang compiler.]) - have_oss_fuzzers="no (compiler is not Clang)" - fi -else - AM_CONDITIONAL([USE_OSSFUZZERS], [test "false" = "true"]) -fi - -AC_SUBST([LIB_FUZZING_ENGINE]) - -dnl check for ogg library -AC_ARG_ENABLE([ogg], - AS_HELP_STRING([--disable-ogg],[Disable ogg support (default: test for libogg)]), - [ want_ogg=$enableval ], [ want_ogg=yes ] ) - -if test "x$want_ogg" != "xno"; then - XIPH_PATH_OGG(have_ogg=yes, AC_MSG_WARN([*** Ogg development environment not installed - Ogg support will not be built])) -fi - -FLAC__HAS_OGG=0 -AM_CONDITIONAL(FLaC__HAS_OGG, [test "x$have_ogg" = xyes]) -if test "x$have_ogg" = xyes ; then - FLAC__HAS_OGG=1 - OGG_PACKAGE="ogg" -else - have_ogg=no -fi -AC_DEFINE_UNQUOTED([FLAC__HAS_OGG],$FLAC__HAS_OGG,[define if you have the ogg library]) -AC_SUBST(FLAC__HAS_OGG) -AC_SUBST(OGG_PACKAGE) - -dnl Build programs? -AC_ARG_ENABLE([programs], - AS_HELP_STRING([--disable-programs], [Do not build and install flac and metaflac])) -AM_CONDITIONAL(FLaC__WITH_PROGRAMS, [test "x$enable_programs" != "xno"]) - -dnl Build examples? -AC_ARG_ENABLE([examples], - AS_HELP_STRING([--disable-examples], [Do not build and install examples])) -AM_CONDITIONAL([EXAMPLES], [test "x$enable_examples" != "xno"]) - -dnl Ask git which version FLAC is -AC_ARG_ENABLE([version-from-git], - AS_HELP_STRING([--disable-version-from-git], [Do not use git tag, commit hash and commit date for version number]), - [ enable_version_from_git=$enableval ], [ enable_version_from_git=yes ]) - - -dnl check for i18n(internationalization); these are from libiconv/gettext -AM_ICONV -AM_LANGINFO_CODESET - -AC_CHECK_PROGS(PANDOC, pandoc) -AM_CONDITIONAL(FLaC__HAS_PANDOC, test -n "$PANDOC") -if test -n "$PANDOC" ; then - AC_DEFINE(FLAC__HAS_PANDOC) - AH_TEMPLATE(FLAC__HAS_PANDOC, [define if you have pandoc]) -else -if test -f "$srcdir/man/flac.1" && test -f "$srcdir/man/metaflac.1" ; then - HAS_PREBUILT_MANPAGES=yes -fi -fi -AM_CONDITIONAL(FLaC__HAS_PREBUILT_MANPAGES, test "x$HAS_PREBUILT_MANPAGES" = "xyes") - -AC_CHECK_LIB(rt, clock_gettime, - LIB_CLOCK_GETTIME=-lrt - AC_DEFINE(HAVE_CLOCK_GETTIME) - AH_TEMPLATE(HAVE_CLOCK_GETTIME, [define if you have clock_gettime])) -AC_SUBST(LIB_CLOCK_GETTIME) - -XIPH_GCC_VERSION dnl Sets a non-zero GCC_XXX_VERSION for gcc, not clang. checks below rely on that.. - -if test x$ac_cv_c_compiler_gnu = xyes -o x$xiph_cv_c_compiler_clang = xyes ; then - dnl Prepend defaults to CFLAGS for GCC and Clang - AS_IF([test "x${ax_enable_debug}" = "xno"], [ - CFLAGS="-O3 -funroll-loops $CFLAGS" - CXXFLAGS="-O3 $CXXFLAGS" - ]) - - CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Winline " # -Wcast-qual -Wbad-function-cast -Wwrite-strings -Wconversion - CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef " # -Wcast-qual -Wbad-function-cast -Wwrite-strings -Woverloaded-virtual -Wmissing-declarations - - XIPH_ADD_CFLAGS([-Wdeclaration-after-statement]) - - dnl some distributions (such as Gentoo) have _FORTIFY_SOURCE always - dnl enabled. We test for this situation in order to prevent polluting - dnl the console with messages of macro redefinitions. - - if test "$enable_fortify_source" = "yes" && test "x$mingw_has_memset_chk" != "xno" - then - AX_ADD_FORTIFY_SOURCE - fi - - AC_LANG_PUSH([C++]) - XIPH_ADD_CXXFLAGS([-Weffc++]) - AC_LANG_POP([C++]) - - if test x$xiph_cv_c_compiler_clang = xyes -a "$OBJ_FORMAT" = elf; then - CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR" - CFLAGS="$CFLAGS -fvisibility=hidden" - CXXFLAGS="$CXXFLAGS -fvisibility=hidden" - elif test "$GCC_MAJOR_VERSION" -ge 4 && test "$OBJ_FORMAT" = elf; then - CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR" - CFLAGS="$CFLAGS -fvisibility=hidden" - CXXFLAGS="$CXXFLAGS -fvisibility=hidden" - fi - - - if test x$xiph_cv_c_compiler_clang = xyes -a "$OBJ_FORMAT" = macho; then - CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR" - CFLAGS="$CFLAGS -fvisibility=hidden" - CXXFLAGS="$CXXFLAGS -fvisibility=hidden" - elif test "$GCC_MAJOR_VERSION" -ge 4 && test "$OBJ_FORMAT" = macho; then - CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR" - CFLAGS="$CFLAGS -fvisibility=hidden" - CXXFLAGS="$CXXFLAGS -fvisibility=hidden" - fi - - if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x42" ; then - XIPH_ADD_CFLAGS([-fgnu89-inline]) - fi - - if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x47" ; then - XIPH_ADD_CFLAGS([-fno-inline-small-functions]) - fi - - fi - -case "$host_os" in - "mingw32"|"os2") - if test "$host_cpu" = "i686"; then - XIPH_ADD_CFLAGS([-mstackrealign]) - fi - esac - -if test x$enable_werror = "xyes" ; then - XIPH_ADD_CFLAGS([-Werror]) - AC_LANG_PUSH([C++]) - XIPH_ADD_CXXFLAGS([-Werror]) - AC_LANG_POP([C++]) - fi - -if test x$enable_stack_smash_protection = "xyes" && test "x$mingw_has_stack_chk_fail" != "xno" ; then - XIPH_GCC_STACK_PROTECTOR - XIPH_GXX_STACK_PROTECTOR -else - enable_stack_smash_protection=no -fi - -AH_VERBATIM([FLAC_API_EXPORTS], -[/* libtool defines DLL_EXPORT for windows dll builds, - but flac code relies on FLAC_API_EXPORTS instead. */ -#ifdef DLL_EXPORT -#ifdef __cplusplus -# define FLACPP_API_EXPORTS -#else -# define FLAC_API_EXPORTS -#endif -#endif]) - -if test x$enable_static = "xyes" ; then -dnl for correct FLAC_API - CPPFLAGS="-DFLAC__NO_DLL $CPPFLAGS" - fi - -AC_CHECK_PROG(GIT_FOUND,git,yes) - -if test x$GIT_FOUND$enable_version_from_git = "xyesyes"; then - GIT_COMMIT_TAG=`git -C $srcdir --git-dir=.git describe --tags --exact-match 2>/dev/null` - GIT_COMMIT_HASH=`git -C $srcdir --git-dir=.git log -1 --pretty=format:%h 2>/dev/null` - GIT_COMMIT_DATE=`git -C $srcdir --git-dir=.git log -1 --pretty=format:%cd --date=format:%Y%m%d 2>/dev/null` - if test ${#GIT_COMMIT_HASH} = 8 && test ${#GIT_COMMIT_DATE} = 8; then - GIT_COMMIT_VERSION_AVAIL=yes - if test ${#GIT_COMMIT_TAG} != 0 ; then - GIT_COMMIT_TAG_AVAIL=yes - AC_DEFINE_UNQUOTED(GIT_COMMIT_TAG, "${GIT_COMMIT_TAG}", "Define to the tag of the current git HEAD") - else - GIT_COMMIT_VERSION_HASH=yes - fi - AC_DEFINE_UNQUOTED(GIT_COMMIT_HASH, "${GIT_COMMIT_HASH}", "Define to the short hash of the current git HEAD") - AC_DEFINE_UNQUOTED(GIT_COMMIT_DATE, "${GIT_COMMIT_DATE}", "Define to the commit date of the current git HEAD") - fi -fi - -AC_SUBST(GIT_COMMIT_VERSION_HASH) - -AX_CHECK_COMPILE_FLAG([-fassociative-math -fno-signed-zeros -fno-trapping-math -freciprocal-math],HAVE_ASSOC_MATH=yes) -AM_CONDITIONAL(ASSOC_MATH_AVAILABLE, test "x$HAVE_ASSOC_MATH" = "xyes") - - -AC_CONFIG_FILES([ \ - Makefile \ - src/Makefile \ - src/libFLAC/Makefile \ - src/libFLAC/flac.pc \ - src/libFLAC/include/Makefile \ - src/libFLAC/include/private/Makefile \ - src/libFLAC/include/protected/Makefile \ - src/libFLAC++/Makefile \ - src/libFLAC++/flac++.pc \ - src/flac/Makefile \ - src/metaflac/Makefile \ - src/share/Makefile \ - src/test_grabbag/Makefile \ - src/test_grabbag/cuesheet/Makefile \ - src/test_grabbag/picture/Makefile \ - src/test_libs_common/Makefile \ - src/test_libFLAC/Makefile \ - src/test_libFLAC++/Makefile \ - src/test_seeking/Makefile \ - src/test_streams/Makefile \ - src/utils/Makefile \ - src/utils/flacdiff/Makefile \ - src/utils/flactimer/Makefile \ - examples/Makefile \ - examples/c/Makefile \ - examples/c/decode/Makefile \ - examples/c/decode/file/Makefile \ - examples/c/encode/Makefile \ - examples/c/encode/file/Makefile \ - examples/cpp/Makefile \ - examples/cpp/decode/Makefile \ - examples/cpp/decode/file/Makefile \ - examples/cpp/encode/Makefile \ - examples/cpp/encode/file/Makefile \ - include/Makefile \ - include/FLAC/Makefile \ - include/FLAC++/Makefile \ - include/share/Makefile \ - include/share/grabbag/Makefile \ - include/test_libs_common/Makefile \ - doc/Doxyfile \ - doc/Makefile \ - doc/images/Makefile \ - m4/Makefile \ - man/Makefile \ - test/common.sh \ - test/Makefile \ - test/cuesheets/Makefile \ - test/foreign-metadata-test-files/Makefile \ - test/flac-to-flac-metadata-test-files/Makefile \ - test/metaflac-test-files/Makefile \ - test/pictures/Makefile \ - microbench/Makefile \ - oss-fuzz/Makefile -]) -AC_OUTPUT - -AC_MSG_RESULT([ --=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=- - - Configuration summary : - - FLAC version : ............................ ${VERSION} - - Host CPU : ................................ ${host_cpu} - Host Vendor : ............................. ${host_vendor} - Host OS : ................................. ${host_os} -]) - -if test x$GIT_COMMIT_TAG_AVAIL = xyes ; then - echo " Version string : reference libFLAC ${GIT_COMMIT_TAG} ${GIT_COMMIT_DATE}" -elif test x$GIT_COMMIT_VERSION_AVAIL = xyes ; then - echo " Version string : reference libFLAC git-${GIT_COMMIT_HASH} ${GIT_COMMIT_DATE}" -fi - echo "" - echo " Compiler is GCC : ......................... ${ac_cv_c_compiler_gnu}" -if test x$ac_cv_c_compiler_gnu = xyes ; then - echo " GCC version : ............................. ${GCC_VERSION}" -fi - echo " Compiler is Clang : ....................... ${xiph_cv_c_compiler_clang}" - echo " Asm optimizations : ....................... ${asm_optimisation}" - echo " Ogg/FLAC support : ........................ ${have_ogg}" - echo " Stack protector : ........................ ${enable_stack_smash_protection}" - echo " Fuzzing support (Clang only) : ............ ${have_oss_fuzzers}" -echo diff --git a/Engine/lib/flac/doc/CMakeLists.txt b/Engine/lib/flac/doc/CMakeLists.txt deleted file mode 100644 index df1f27751..000000000 --- a/Engine/lib/flac/doc/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -cmake_minimum_required(VERSION 3.9) - -find_package(Doxygen) - -if (NOT DOXYGEN_FOUND) - return() -endif() - -option(BUILD_DOXYGEN "Enable API documentation building via Doxygen" ON) - -if (NOT BUILD_DOXYGEN) - return() -endif() - -set(top_srcdir "${PROJECT_SOURCE_DIR}") -configure_file(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) - - -add_custom_target(FLAC-doxygen ALL - COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM ) - -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/" - DESTINATION "${CMAKE_INSTALL_DOCDIR}/api") diff --git a/Engine/lib/flac/doc/Doxyfile.in b/Engine/lib/flac/doc/Doxyfile.in deleted file mode 100644 index 8133ea348..000000000 --- a/Engine/lib/flac/doc/Doxyfile.in +++ /dev/null @@ -1,1784 +0,0 @@ -# Doxyfile 1.7.6.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = FLAC - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = 1.4.3 - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = Free Lossless Audio Codec - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = doxytmp - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = NO - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = YES - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = YES - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = .. - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = "assert=\par Assertions:" \ - "default=\par Default Value:" - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = YES - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = NO - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = YES - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = @top_srcdir@/include/FLAC \ - @top_srcdir@/include/FLAC++ - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = @top_srcdir@/doc/doxygen.footer.html - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# style sheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the -# mathjax.org site, so you can quickly see the result without installing -# MathJax, but it is strongly recommended to install a local copy of MathJax -# before deployment. - -MATHJAX_RELPATH = http://www.mathjax.org/mathjax - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = NO - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = YES - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = FLAC__NO_DLL - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = FLAC_API \ - FLACPP_API - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = FLAC.tag - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/Engine/lib/flac/doc/Makefile.am b/Engine/lib/flac/doc/Makefile.am deleted file mode 100644 index 55395ca7c..000000000 --- a/Engine/lib/flac/doc/Makefile.am +++ /dev/null @@ -1,62 +0,0 @@ -# flac - Command-line FLAC encoder/decoder -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -SUBDIRS = . images - -if FLaC__HAS_DOXYGEN -all-local: Doxyfile -FLAC.tag: Doxyfile - doxygen Doxyfile - rm -rf api - mv doxytmp/html api - rm -rf doxytmp - -doc_DATA = \ - FLAC.tag -else -if FLaC__HAS_PREBUILT_DOXYGEN -doc_DATA = \ - FLAC.tag -endif -endif - -EXTRA_DIST = Doxyfile.in doxygen.footer.html \ - isoflac.txt $(doc_DATA) CMakeLists.txt \ - api - -if FLaC__HAS_DOXYGEN -# The install targets don't copy whole directories so we have to -# handle 'api/' specially: -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(docdir)/api - (cd $(builddir)/api && $(INSTALL_DATA) * $(DESTDIR)$(docdir)/api) -uninstall-local: - rm -rf $(DESTDIR)$(docdir)/api -distclean-local: - rm -rf FLAC.tag api doxytmp -endif - -if FLaC__HAS_PREBUILT_DOXYGEN -# The install targets don't copy whole directories so we have to -# handle 'api/' specially: -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(docdir)/api - (cd $(srcdir)/api && $(INSTALL_DATA) * $(DESTDIR)$(docdir)/api) -uninstall-local: - rm -rf $(DESTDIR)$(docdir)/api -endif diff --git a/Engine/lib/flac/doc/doxygen.footer.html b/Engine/lib/flac/doc/doxygen.footer.html deleted file mode 100644 index e395c610a..000000000 --- a/Engine/lib/flac/doc/doxygen.footer.html +++ /dev/null @@ -1,15 +0,0 @@ - -
- -Copyright (c) 2000-2009 Josh Coalson -Copyright (c) 2011-2023 Xiph.Org Foundation - - - - - - - - - - diff --git a/Engine/lib/flac/doc/images/Makefile.am b/Engine/lib/flac/doc/images/Makefile.am deleted file mode 100644 index 1e30a5c39..000000000 --- a/Engine/lib/flac/doc/images/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -logosdir = $(htmldir)/images - -logos_DATA = \ - logo.svg \ - logo130.gif - -EXTRA_DIST = $(logos_DATA) diff --git a/Engine/lib/flac/doc/images/logo.svg b/Engine/lib/flac/doc/images/logo.svg deleted file mode 100644 index 4ee2d4181..000000000 --- a/Engine/lib/flac/doc/images/logo.svg +++ /dev/null @@ -1,431 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Engine/lib/flac/doc/images/logo130.gif b/Engine/lib/flac/doc/images/logo130.gif deleted file mode 100644 index 3200df347..000000000 Binary files a/Engine/lib/flac/doc/images/logo130.gif and /dev/null differ diff --git a/Engine/lib/flac/doc/isoflac.txt b/Engine/lib/flac/doc/isoflac.txt deleted file mode 100644 index 888aed797..000000000 --- a/Engine/lib/flac/doc/isoflac.txt +++ /dev/null @@ -1,666 +0,0 @@ -Encapsulation of FLAC in ISO Base Media File Format -Version 0.0.4 - -Table of Contents -1 Scope -2 Supporting Normative References -3 Design Rules of Encapsulation - 3.1 File Type Identification - 3.2 Overview of Track Structure - 3.3 Definition of FLAC sample - 3.3.1 Sample entry format - 3.3.2 FLAC Specific Box - 3.3.3 Sample format - 3.3.4 Duration of FLAC sample - 3.3.5 Sub-sample - 3.3.6 Random Access - 3.3.6.1 Random Access Point - 3.4 Basic Structure (informative) - 3.4.1 Initial Movie - 3.5 Example of Encapsulation (informative) -4 Acknowledgements -5 Author's Address - -1 Scope - - This document specifies the normative mapping for encapsulation of - FLAC coded audio bitstreams in ISO Base Media file format and its - derivatives. The encapsulation of FLAC coded bitstreams in - QuickTime file format is outside the scope of this specification. - -2 Supporting Normative References - - [1] ISO/IEC 14496-12:2012 Corrected version - - Information technology — Coding of audio-visual objects — Part - 12: ISO base media file format - - [2] ISO/IEC 14496-12:2012/Amd.1:2013 - - Information technology — Coding of audio-visual objects — Part - 12: ISO base media file format AMENDMENT 1: Various - enhancements including support for large metadata - - [3] FLAC format specification - - https://xiph.org/flac/format.html - - Definition of the FLAC Audio Codec stream format - - [4] FLAC-in-Ogg mapping specification - - https://xiph.org/flac/ogg_mapping.html - - Ogg Encapsulation for the FLAC Audio Codec - - [5] Matroska specification - -3 Design Rules of Encapsulation - - 3.1 File Type Identification - - This specification does not define any brand to declare files - which conform to this specification. Files which conform to - this specification shall contain at least one brand which - supports the requirements and the requirements described in - this clause without contradiction in the compatible brands - list of the File Type Box. The minimal support of the - encapsulation of FLAC bitstreams in ISO Base Media file format - requires the 'isom' brand. - - 3.2 Overview of Track Structure - - FLAC coded audio shall be encapsulated into the ISO Base - Media File Format as media data within an audio track. - - + The handler_type field in the Handler Reference Box - shall be set to 'soun'. - - + The Media Information Box shall contain the Sound Media - Header Box. - - + The codingname of the sample entry is 'fLaC'. - - This specification does not define any encapsulation - using MP4AudioSampleEntry with objectTypeIndication - specified by the MPEG-4 Registration Authority - (http://www.mp4ra.org/). See section 'Sample entry - format' for the definition of the sample entry. - - + The 'dfLa' box is added to the sample entry to convey - initializing information for the decoder. - - See section 'FLAC Specific Box' for the definition of - the box contents. - - + A FLAC sample is exactly one FLAC frame as described - in the format specification[3]. See section - 'Sample format' for details of the frame contents. - - + Every FLAC sample is a sync sample. No pre-roll or - lapping is required. See section 'Random Access' for - further details. - - 3.3 Definition of a FLAC sample - - 3.3.1 Sample entry format - - For any track containing one or more FLAC bitstreams, a - sample entry describing the corresponding FLAC bitstream - shall be present inside the Sample Table Box. This version - of the specification defines only one sample entry format - named FLACSampleEntry whose codingname is 'fLaC'. This - sample entry includes exactly one FLAC Specific Box - defined in section 'FLAC specific box' as a mandatory box - and indicates that FLAC samples described by this sample - entry are stored by the sample format described in section - 'Sample format'. - - The syntax and semantics of the FLACSampleEntry is shown - as follows. The data fields of this box and native - FLAC[3] structures encoded within FLAC blocks are both - stored in big-endian format, though for purposes of the - ISO BMFF container, FLAC native metadata and data blocks - are treated as unstructured octet streams. - - class FLACSampleEntry() extends AudioSampleEntry ('fLaC'){ - FLACSpecificBox(); - } - - The fields of the AudioSampleEntry portion shall be set as - follows: - - + channelcount: - - The channelcount field shall be set equal to the - channel count specified by the FLAC bitstream's native - METADATA_BLOCK_STREAMINFO header as described in [3]. - Note that the FLAC FRAME_HEADER structure that begins - each FLAC sample redundantly encodes channel number; - the number of channels declared in each FRAME_HEADER - MUST match the number of channels declared here and in - the METADATA_BLOCK_STREAMINFO header. - - + samplesize: - - The samplesize field shall be set equal to the bits - per sample specified by the FLAC bitstream's native - METADATA_BLOCK_STREAMINFO header as described in [3]. - Note that the FLAC FRAME_HEADER structure that begins - each FLAC sample redundantly encodes the number of - bits per sample; the bits per sample declared in each - FRAME_HEADER MUST match the samplesize declared here - and the bits per sample field declared in the - METADATA_BLOCK_STREAMINFO header. - - + samplerate: - - When possible, the samplerate field shall be set - equal to the sample rate specified by the FLAC - bitstream's native METADATA_BLOCK_STREAMINFO header - as described in [3], left-shifted by 16 bits to - create the appropriate 16.16 fixed-point - representation. - - When the bitstream's native sample rate is greater - than the maximum expressible value of 65535 Hz, - the samplerate field shall hold the greatest - expressible regular division of that rate. I.e. - the samplerate field shall hold 48000.0 for - native sample rates of 96 and 192 kHz. In the - case of unusual sample rates which do not have - an expressible regular division, the maximum value - of 65535.0 Hz should be used. - - High-rate FLAC bitstreams are common, and the native - value from the METADATA_BLOCK_STREAMINFO header in - the FLACSpecificBox MUST be read to determine the - correct sample rate of the bitstream. - - Note that the FLAC FRAME_HEADER structure that begins - each FLAC sample redundantly encodes the sample rate; - the sample rate declared in each FRAME_HEADER MUST - match the sample rate declared in the - METADATA_BLOCK_STREAMINFO header, and here in the - AudioSampleEntry portion of the FLACSampleEntry - as much as is allowed by the encoding restrictions - described above. - - Finally, the FLACSpecificBox carries codec headers: - - + FLACSpecificBox - - This box contains initializing information for the - decoder as defined in section 'FLAC specific box'. - - 3.3.2 FLAC Specific Box - - Exactly one FLAC Specific Box shall be present in each - FLACSampleEntry. This specification defines version 0 - of this box. If incompatible changes occur in future - versions of this specification, another version number - will be defined. The data fields of this box and native - FLAC[3] structures encoded within FLAC blocks are both - stored in big-endian format, though for purposes of the - ISO BMFF container, FLAC native metadata and data blocks - are treated as unstructured octet streams. - - The syntax and semantics of the FLAC Specific Box is shown - as follows. - - class FLACMetadataBlock { - unsigned int(1) LastMetadataBlockFlag; - unsigned int(7) BlockType; - unsigned int(24) Length; - unsigned int(8) BlockData[Length]; - } - - aligned(8) class FLACSpecificBox - extends FullBox('dfLa', version=0, 0){ - for (i=0; ; i++) { // to end of box - FLACMetadataBlock(); - } - } - - + Version: - - The Version field shall be set to 0. - - In the future versions of this specification, this - field may be set to other values. And without support - of those values, the reader shall not read the fields - after this within the FLACSpecificBox. - - + Flags: - - The Flags field shall be set to 0. - - After the FullBox header, the box contains a sequence of - FLAC[3] native-metadata block structures that fill the - remainder of the box. - - Each FLACMetadataBlock structure consists of three fields - filling a total of four bytes that form a FLAC[3] native - METADATA_BLOCK_HEADER, followed by raw octet bytes that - comprise the FLAC[3] native METADATA_BLOCK_DATA. - - + LastMetadataBlockFlag: - - The LastMetadataBlockFlag field maps semantically to - the FLAC[3] native METADATA_BLOCK_HEADER - Last-metadata-block flag as defined in the FLAC[3] - file specification. - - The LastMetadataBlockFlag is set to 1 if this - MetadataBlock is the last metadata block in the - FLACSpecificBox. It is set to 0 otherwise. - - + BlockType: - - The BlockType field maps semantically to the FLAC[3] - native METADATA_BLOCK_HEADER BLOCK_TYPE field as - defined in the FLAC[3] file specification. - - The BlockType is set to a valid FLAC[3] BLOCK_TYPE - value that identifies the type of this native metadata - block. The BlockType of the first FLACMetadataBlock - must be set to 0, signifying this is a FLAC[3] native - METADATA_BLOCK_STREAMINFO block. - - + Length: - - The Length field maps semantically to the FLAC[3] - native METADATA_BLOCK_HEADER Length field as - defined in the FLAC[3] file specification. - - The length field specifies the number of bytes of - MetadataBlockData to follow. - - + BlockData - - The BlockData field maps semantically to the FLAC[3] - native METADATA_BLOCK_HEADER METADATA_BLOCK_DATA as - defined in the FLAC[3] file specification. - - Taken together, the bytes of the FLACMetadataBlock form a - complete FLAC[3] native METADATA_BLOCK structure. - - Note that a minimum of a single FLACMetadataBlock, - consisting of a FLAC[3] native METADATA_BLOCK_STREAMINFO - structure, is required. Should the FLACSpecificBox - contain more than a single FLACMetadataBlock structure, - the FLACMetadataBlock containing the FLAC[3] native - METADATA_BLOCK_STREAMINFO must occur first in the list. - - Other containers that package FLAC audio streams, such as - Ogg[4] and Matroska[5], wrap FLAC[3] native metadata without - modification similar to this specification. When - repackaging or remuxing FLAC[3] streams from another - format that contains FLAC[3] native metadata into an ISO - BMFF file, the complete FLAC[3] native metadata should be - preserved in the ISO BMFF stream as described above. It - is also allowed to parse this native metadata and include - contextually redundant ISO BMFF-native repackagings and/or - reparsings of FLAC[3] native metadata, so long as the - native metadata is also preserved. - - 3.3.3 Sample format - - A FLAC sample is exactly one FLAC audio FRAME (as defined - in the FLAC[3] file specification) belonging to a FLAC - bitstreams. The FLAC sample data begins with a complete - FLAC FRAME_HEADER, followed by one FLAC SUBFRAME per - channel, any necessary bit padding, and ends with the - usual FLAC FRAME_FOOTER. - - Note that the FLAC native FRAME_HEADER structure that - begins each FLAC sample redundantly encodes channel count, - sample rate, and sample size. The values of these fields - must agree both with the values declared in the FLAC - METADATA_BLOCK_STREAMINFO structure as well as the - FLACSampleEntry box. - - 3.3.4 Duration of a FLAC sample - - The duration of any given FLAC sample is determined by - dividing the decoded block size of a FLAC frame, as - encoded in the FLAC FRAME's FRAME_HEADER structure, by the - value of the timescale field in the Media Header Box. - FLAC samples are permitted to have variable durations - within a given audio stream. FLAC does not use padding - values. - - 3.3.5 Sub-sample - - Sub-samples are not defined for FLAC samples in this - specification. - - 3.3.6 Random Access - - This subclause describes the nature of the random access - of FLAC sample. - - 3.3.6.1 Random Access Point - - All FLAC samples can be independently decoded - i.e. every FLAC sample is a sync sample. The Sync - Sample Box shall not be present as long as there are - no samples other than FLAC samples in the same - track. The sample_is_non_sync_sample field for FLAC - samples shall be set to 0. - - 3.4 Basic Structure (informative) - - 3.4.1 Initial Movie - - This subclause shows a basic structure of the Movie Box as follows: - - +----+----+----+----+----+----+----+----+------------------------------+ - |moov| | | | | | | | Movie Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | |mvhd| | | | | | | Movie Header Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | |trak| | | | | | | Track Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | |tkhd| | | | | | Track Header Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | |edts|* | | | | | Edit Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | |elst|* | | | | Edit List Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | |mdia| | | | | | Media Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | |mdhd| | | | | Media Header Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | |hdlr| | | | | Handler Reference Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | |minf| | | | | Media Information Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | |smhd| | | | Sound Media Header Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | |dinf| | | | Data Information Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | | |dref| | | Data Reference Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | | | |url | | DataEntryUrlBox | - +----+----+----+----+----+----+ or +----+------------------------------+ - | | | | | | |urn | | DataEntryUrnBox | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | |stbl| | | | Sample Table | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | | |stsd| | | Sample Description Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | | | |fLaC| | FLACSampleEntry | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | | | | |dfLa| FLAC Specific Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | | |stts| | | Decoding Time to Sample Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | | |stsc| | | Sample To Chunk Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | | |stsz| | | Sample Size Box | - +----+----+----+----+----+ or +----+----+------------------------------+ - | | | | | |stz2| | | Compact Sample Size Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | | | | |stco| | | Chunk Offset Box | - +----+----+----+----+----+ or +----+----+------------------------------+ - | | | | | |co64| | | Chunk Large Offset Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | |mvex|* | | | | | | Movie Extends Box | - +----+----+----+----+----+----+----+----+------------------------------+ - | | |trex|* | | | | | Track Extends Box | - +----+----+----+----+----+----+----+----+------------------------------+ - - Figure 1 - Basic structure of Movie Box - - It is strongly recommended that the order of boxes should - follow the above structure. Boxes marked with an asterisk - (*) may or may not be present depending on context. For - most boxes listed above, the definition is as is defined - in ISO/IEC 14496-12 [1]. The additional boxes and the - additional requirements, restrictions and recommendations - to the other boxes are described in this specification. - - 3.5 Example of Encapsulation (informative) - [File] - size = 17790 - [ftyp: File Type Box] - position = 0 - size = 24 - major_brand = mp42 : MP4 version 2 - minor_version = 0 - compatible_brands - brand[0] = mp42 : MP4 version 2 - brand[1] = isom : ISO Base Media file format - [moov: Movie Box] - position = 24 - size = 757 - [mvhd: Movie Header Box] - position = 32 - size = 108 - version = 0 - flags = 0x000000 - creation_time = UTC 2014/12/12, 18:41:19 - modification_time = UTC 2014/12/12, 18:41:19 - timescale = 48000 - duration = 33600 (00:00:00.700) - rate = 1.000000 - volume = 1.000000 - reserved = 0x0000 - reserved = 0x00000000 - reserved = 0x00000000 - transformation matrix - | a, b, u | | 1.000000, 0.000000, 0.000000 | - | c, d, v | = | 0.000000, 1.000000, 0.000000 | - | x, y, w | | 0.000000, 0.000000, 1.000000 | - pre_defined = 0x00000000 - pre_defined = 0x00000000 - pre_defined = 0x00000000 - pre_defined = 0x00000000 - pre_defined = 0x00000000 - pre_defined = 0x00000000 - next_track_ID = 2 - [iods: Object Descriptor Box] - position = 140 - size = 33 - version = 0 - flags = 0x000000 - [tag = 0x10: MP4_IOD] - expandableClassSize = 16 - ObjectDescriptorID = 1 - URL_Flag = 0 - includeInlineProfileLevelFlag = 0 - reserved = 0xf - ODProfileLevelIndication = 0xff - sceneProfileLevelIndication = 0xff - audioProfileLevelIndication = 0xfe - visualProfileLevelIndication = 0xff - graphicsProfileLevelIndication = 0xff - [tag = 0x0e: ES_ID_Inc] - expandableClassSize = 4 - Track_ID = 1 - [trak: Track Box] - position = 173 - size = 608 - [tkhd: Track Header Box] - position = 181 - size = 92 - version = 0 - flags = 0x000007 - Track enabled - Track in movie - Track in preview - creation_time = UTC 2014/12/12, 18:41:19 - modification_time = UTC 2014/12/12, 18:41:19 - track_ID = 1 - reserved = 0x00000000 - duration = 33600 (00:00:00.700) - reserved = 0x00000000 - reserved = 0x00000000 - layer = 0 - alternate_group = 0 - volume = 1.000000 - reserved = 0x0000 - transformation matrix - | a, b, u | | 1.000000, 0.000000, 0.000000 | - | c, d, v | = | 0.000000, 1.000000, 0.000000 | - | x, y, w | | 0.000000, 0.000000, 1.000000 | - width = 0.000000 - height = 0.000000 - [mdia: Media Box] - position = 273 - size = 472 - [mdhd: Media Header Box] - position = 281 - size = 32 - version = 0 - flags = 0x000000 - creation_time = UTC 2014/12/12, 18:41:19 - modification_time = UTC 2014/12/12, 18:41:19 - timescale = 48000 - duration = 34560 (00:00:00.720) - language = und - pre_defined = 0x0000 - [hdlr: Handler Reference Box] - position = 313 - size = 51 - version = 0 - flags = 0x000000 - pre_defined = 0x00000000 - handler_type = soun - reserved = 0x00000000 - reserved = 0x00000000 - reserved = 0x00000000 - name = Xiph Audio Handler - [minf: Media Information Box] - position = 364 - size = 381 - [smhd: Sound Media Header Box] - position = 372 - size = 16 - version = 0 - flags = 0x000000 - balance = 0.000000 - reserved = 0x0000 - [dinf: Data Information Box] - position = 388 - size = 36 - [dref: Data Reference Box] - position = 396 - size = 28 - version = 0 - flags = 0x000000 - entry_count = 1 - [url : Data Entry Url Box] - position = 412 - size = 12 - version = 0 - flags = 0x000001 - location = in the same file - [stbl: Sample Table Box] - position = 424 - size = 321 - [stsd: Sample Description Box] - position = 432 - size = 79 - version = 0 - flags = 0x000000 - entry_count = 1 - [fLaC: Audio Description] - position = 448 - size = 63 - reserved = 0x000000000000 - data_reference_index = 1 - reserved = 0x0000 - reserved = 0x0000 - reserved = 0x00000000 - channelcount = 2 - samplesize = 16 - pre_defined = 0 - reserved = 0 - samplerate = 48000.000000 - [dfLa: FLAC Specific Box] - position = 484 - size = 50 - version = 0 - flags = 0x000000 - [FLACMetadataBlock] - LastMetadataBlockFlag = 1 - BlockType = 0 - Length = 34 - BlockData[34]; - [stts: Decoding Time to Sample Box] - position = 492 - size = 24 - version = 0 - flags = 0x000000 - entry_count = 1 - entry[0] - sample_count = 18 - sample_delta = 1920 - [stsc: Sample To Chunk Box] - position = 516 - size = 40 - version = 0 - flags = 0x000000 - entry_count = 2 - entry[0] - first_chunk = 1 - samples_per_chunk = 13 - sample_description_index = 1 - entry[1] - first_chunk = 2 - samples_per_chunk = 5 - sample_description_index = 1 - [stsz: Sample Size Box] - position = 556 - size = 92 - version = 0 - flags = 0x000000 - sample_size = 0 (variable) - sample_count = 18 - entry_size[0] = 977 - entry_size[1] = 938 - entry_size[2] = 939 - entry_size[3] = 938 - entry_size[4] = 934 - entry_size[5] = 945 - entry_size[6] = 948 - entry_size[7] = 956 - entry_size[8] = 955 - entry_size[9] = 930 - entry_size[10] = 933 - entry_size[11] = 934 - entry_size[12] = 972 - entry_size[13] = 977 - entry_size[14] = 958 - entry_size[15] = 949 - entry_size[16] = 962 - entry_size[17] = 848 - [stco: Chunk Offset Box] - position = 648 - size = 24 - version = 0 - flags = 0x000000 - entry_count = 2 - chunk_offset[0] = 686 - chunk_offset[1] = 12985 - [free: Free Space Box] - position = 672 - size = 8 - [mdat: Media Data Box] - position = 680 - size = 17001 - -4 Acknowledgements - - This spec draws heavily from the Opus-in-ISOBMFF specification - work done by Yusuke Nakamura - - Thank you to Tim Terriberry, David Evans, and Yusuke Nakamura - for valuable feedback. Thank you to Ralph Giles for editorial - help. - -5 Author Address - - Monty Montgomery diff --git a/Engine/lib/flac/doc/release_checklist.md b/Engine/lib/flac/doc/release_checklist.md deleted file mode 100644 index 3a5a59d75..000000000 --- a/Engine/lib/flac/doc/release_checklist.md +++ /dev/null @@ -1,40 +0,0 @@ -1. Change version number in - - /configure.ac - - /CMakeLists.txt - - /doc/Doxyfile.in - - /man/flac.md - - /man/metaflac.md - - /test/metaflac-test-files/case07-expect.meta -1. Change version date in - - /src/libFLAC/format.c - - /test/metaflac-test-files/case07-expect.meta -1. Update changelog -1. Check copyright year and update if applicable -1. Check libFLAC and libFLAC++ for interface changes and update - version numbers in include/FLAC/export.h, include/FLAC++/export.h, - src/libFLAC/Makefile.am, src/libFLAC++/Makefile.am, - src/libFLAC/CMakeLists.txt and src/libFLAC++/CMakeLists.txt -1. Prepare and check release tarball by running - `git clean -ffxd && ./autogen.sh && ./configure && make distcheck` -1. Check whether release tarball contains api documentation and - generated man pages -1. Prepare Windows release. Instructions are for building with MinGW-w64 - - Take last release as template - - Update readme's if necessary - - Copy changelog and tool documentation - - Unpack tarball and create empty directories build64 and build32 - - Unpack most recent libogg: change - `add_library(ogg ${OGG_HEADERS} ${OGG_SOURCES})` to - `add_library(ogg STATIC ${OGG_HEADERS} ${OGG_SOURCES})` - - Add `-static-libgcc` to FLAC's CFLAGS - - Add `-static-libgcc  -static-libstdc++ -Wl,-Bstatic,--whole-archive - -lwinpthread -Wl,-Bdynamic,--no-whole-archive` to FLAC's CXXFLAGS - - Run `CMake -DBUILD_SHARED_LIBS=ON .. && ninja` in both build64 and - build32 in the corresponding build environments - - Check dependencies of flac.exe, metaflac.exe, libFLAC.dll and - libFLAC++.dll, e.g. with objdump -x *.* | grep DLL. - Dependencies should only include KERNEL32.DLL, ADVAPI32.DLL, - msvcrt.dll and libFLAC.dll - - Copy flac.exe, metaflac.exe, libFLAC.dll and libFLAC++.dll of both - builds to proper directories - - Zip directory diff --git a/Engine/lib/flac/examples/CMakeLists.txt b/Engine/lib/flac/examples/CMakeLists.txt deleted file mode 100644 index ed18e3b1a..000000000 --- a/Engine/lib/flac/examples/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_subdirectory("c/decode/file") -add_subdirectory("c/encode/file") - -if(BUILD_CXXLIBS) - add_subdirectory("cpp/decode/file") - add_subdirectory("cpp/encode/file") -endif() diff --git a/Engine/lib/flac/examples/Makefile.am b/Engine/lib/flac/examples/Makefile.am deleted file mode 100644 index 18b844fa4..000000000 --- a/Engine/lib/flac/examples/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -if FLaC__WITH_CPPLIBS -CPPLIBS_DIRS = cpp -endif - -SUBDIRS = c $(CPPLIBS_DIRS) - -EXTRA_DIST = \ - CMakeLists.txt \ - README diff --git a/Engine/lib/flac/examples/README b/Engine/lib/flac/examples/README deleted file mode 100644 index 2da7bd6de..000000000 --- a/Engine/lib/flac/examples/README +++ /dev/null @@ -1,12 +0,0 @@ -Here are several small example programs that use the libraries in different -ways. - -The "c" directory has programs that are all in C and use libFLAC. - -The "cpp" directory has analogous programs that are all in C++ and use libFLAC++. - -The programs are: -c/decode/file/ - example_c_decode_file - Simple FLAC file decoder using libFLAC -c/encode/file/ - example_c_encode_file - Simple FLAC file encoder using libFLAC -cpp/decode/file/ - example_cpp_decode_file - Simple FLAC file decoder using libFLAC++ -cpp/encode/file/ - example_cpp_encode_file - Simple FLAC file encoder using libFLAC++ diff --git a/Engine/lib/flac/examples/c/Makefile.am b/Engine/lib/flac/examples/c/Makefile.am deleted file mode 100644 index ced8f8ede..000000000 --- a/Engine/lib/flac/examples/c/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -SUBDIRS = decode encode diff --git a/Engine/lib/flac/examples/c/decode/Makefile.am b/Engine/lib/flac/examples/c/decode/Makefile.am deleted file mode 100644 index 3c9499cbc..000000000 --- a/Engine/lib/flac/examples/c/decode/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -SUBDIRS = file diff --git a/Engine/lib/flac/examples/c/decode/file/CMakeLists.txt b/Engine/lib/flac/examples/c/decode/file/CMakeLists.txt deleted file mode 100644 index 53a299182..000000000 --- a/Engine/lib/flac/examples/c/decode/file/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(decode_file main.c) -target_link_libraries(decode_file FLAC) diff --git a/Engine/lib/flac/examples/c/decode/file/Makefile.am b/Engine/lib/flac/examples/c/decode/file/Makefile.am deleted file mode 100644 index b74a782bc..000000000 --- a/Engine/lib/flac/examples/c/decode/file/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# example_c_decode_file - Simple FLAC file decoder using libFLAC -# Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -noinst_PROGRAMS = example_c_decode_file -example_c_decode_file_LDADD = \ - $(top_builddir)/src/libFLAC/libFLAC.la - -example_c_decode_file_SOURCES = main.c - -CLEANFILES = example_c_decode_file.exe diff --git a/Engine/lib/flac/examples/c/decode/file/main.c b/Engine/lib/flac/examples/c/decode/file/main.c deleted file mode 100644 index 009b0d721..000000000 --- a/Engine/lib/flac/examples/c/decode/file/main.c +++ /dev/null @@ -1,200 +0,0 @@ -/* example_c_decode_file - Simple FLAC file decoder using libFLAC - * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * This example shows how to use libFLAC to decode a FLAC file to a WAVE - * file. It only supports 16-bit stereo files. - * - * Complete API documentation can be found at: - * http://xiph.org/flac/api/ - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include "share/compat.h" -#include "FLAC/stream_decoder.h" - -static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); -static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); -static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); - -static FLAC__uint64 total_samples = 0; -static unsigned sample_rate = 0; -static unsigned channels = 0; -static unsigned bps = 0; - -static FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 x) -{ - return - fputc(x, f) != EOF && - fputc(x >> 8, f) != EOF - ; -} - -static FLAC__bool write_little_endian_int16(FILE *f, FLAC__int16 x) -{ - return write_little_endian_uint16(f, (FLAC__uint16)x); -} - -static FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 x) -{ - return - fputc(x, f) != EOF && - fputc(x >> 8, f) != EOF && - fputc(x >> 16, f) != EOF && - fputc(x >> 24, f) != EOF - ; -} - -int main(int argc, char *argv[]) -{ - FLAC__bool ok = true; - FLAC__StreamDecoder *decoder = 0; - FLAC__StreamDecoderInitStatus init_status; - FILE *fout; - - if(argc != 3) { - fprintf(stderr, "usage: %s infile.flac outfile.wav\n", argv[0]); - return 1; - } - - if((fout = fopen(argv[2], "wb")) == NULL) { - fprintf(stderr, "ERROR: opening %s for output\n", argv[2]); - return 1; - } - - if((decoder = FLAC__stream_decoder_new()) == NULL) { - fprintf(stderr, "ERROR: allocating decoder\n"); - fclose(fout); - return 1; - } - - (void)FLAC__stream_decoder_set_md5_checking(decoder, true); - - init_status = FLAC__stream_decoder_init_file(decoder, argv[1], write_callback, metadata_callback, error_callback, /*client_data=*/fout); - if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - fprintf(stderr, "ERROR: initializing decoder: %s\n", FLAC__StreamDecoderInitStatusString[init_status]); - ok = false; - } - - if(ok) { - ok = FLAC__stream_decoder_process_until_end_of_stream(decoder); - fprintf(stderr, "decoding: %s\n", ok? "succeeded" : "FAILED"); - fprintf(stderr, " state: %s\n", FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(decoder)]); - } - - FLAC__stream_decoder_delete(decoder); - fclose(fout); - - return 0; -} - -FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - FILE *f = (FILE*)client_data; - const FLAC__uint32 total_size = (FLAC__uint32)(total_samples * channels * (bps/8)); - size_t i; - - (void)decoder; - - if(total_samples == 0) { - fprintf(stderr, "ERROR: this example only works for FLAC files that have a total_samples count in STREAMINFO\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - if(channels != 2 || bps != 16) { - fprintf(stderr, "ERROR: this example only supports 16bit stereo streams\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - if(frame->header.channels != 2) { - fprintf(stderr, "ERROR: This frame contains %u channels (should be 2)\n", frame->header.channels); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - if(buffer [0] == NULL) { - fprintf(stderr, "ERROR: buffer [0] is NULL\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - if(buffer [1] == NULL) { - fprintf(stderr, "ERROR: buffer [1] is NULL\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - /* write WAVE header before we write the first frame */ - if(frame->header.number.sample_number == 0) { - if( - fwrite("RIFF", 1, 4, f) < 4 || - !write_little_endian_uint32(f, total_size + 36) || - fwrite("WAVEfmt ", 1, 8, f) < 8 || - !write_little_endian_uint32(f, 16) || - !write_little_endian_uint16(f, 1) || - !write_little_endian_uint16(f, (FLAC__uint16)channels) || - !write_little_endian_uint32(f, sample_rate) || - !write_little_endian_uint32(f, sample_rate * channels * (bps/8)) || - !write_little_endian_uint16(f, (FLAC__uint16)(channels * (bps/8))) || /* block align */ - !write_little_endian_uint16(f, (FLAC__uint16)bps) || - fwrite("data", 1, 4, f) < 4 || - !write_little_endian_uint32(f, total_size) - ) { - fprintf(stderr, "ERROR: write error\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - - /* write decoded PCM samples */ - for(i = 0; i < frame->header.blocksize; i++) { - if( - !write_little_endian_int16(f, (FLAC__int16)buffer[0][i]) || /* left channel */ - !write_little_endian_int16(f, (FLAC__int16)buffer[1][i]) /* right channel */ - ) { - fprintf(stderr, "ERROR: write error\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - (void)decoder, (void)client_data; - - /* print some stats */ - if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { - /* save for later */ - total_samples = metadata->data.stream_info.total_samples; - sample_rate = metadata->data.stream_info.sample_rate; - channels = metadata->data.stream_info.channels; - bps = metadata->data.stream_info.bits_per_sample; - - fprintf(stderr, "sample rate : %u Hz\n", sample_rate); - fprintf(stderr, "channels : %u\n", channels); - fprintf(stderr, "bits per sample: %u\n", bps); - fprintf(stderr, "total samples : %" PRIu64 "\n", total_samples); - } -} - -void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - (void)decoder, (void)client_data; - - fprintf(stderr, "Got error callback: %s\n", FLAC__StreamDecoderErrorStatusString[status]); -} diff --git a/Engine/lib/flac/examples/c/encode/Makefile.am b/Engine/lib/flac/examples/c/encode/Makefile.am deleted file mode 100644 index 3c9499cbc..000000000 --- a/Engine/lib/flac/examples/c/encode/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -SUBDIRS = file diff --git a/Engine/lib/flac/examples/c/encode/file/CMakeLists.txt b/Engine/lib/flac/examples/c/encode/file/CMakeLists.txt deleted file mode 100644 index 4b7d4c2ca..000000000 --- a/Engine/lib/flac/examples/c/encode/file/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(encode_file main.c) -target_link_libraries(encode_file FLAC) diff --git a/Engine/lib/flac/examples/c/encode/file/Makefile.am b/Engine/lib/flac/examples/c/encode/file/Makefile.am deleted file mode 100644 index 1771f7c12..000000000 --- a/Engine/lib/flac/examples/c/encode/file/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# example_c_encode_file - Simple FLAC file encoder using libFLAC -# Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -noinst_PROGRAMS = example_c_encode_file -example_c_encode_file_LDADD = \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - @OGG_LIBS@ \ - -lm - -example_c_encode_file_SOURCES = main.c - -CLEANFILES = example_c_encode_file.exe diff --git a/Engine/lib/flac/examples/c/encode/file/main.c b/Engine/lib/flac/examples/c/encode/file/main.c deleted file mode 100644 index 22532aba6..000000000 --- a/Engine/lib/flac/examples/c/encode/file/main.c +++ /dev/null @@ -1,173 +0,0 @@ -/* example_c_encode_file - Simple FLAC file encoder using libFLAC - * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * This example shows how to use libFLAC to encode a WAVE file to a FLAC - * file. It only supports 16-bit stereo files in canonical WAVE format. - * - * Complete API documentation can be found at: - * http://xiph.org/flac/api/ - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include "share/compat.h" -#include "FLAC/metadata.h" -#include "FLAC/stream_encoder.h" - -static void progress_callback(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data); - -#define READSIZE 1024 - -static unsigned total_samples = 0; /* can use a 32-bit number due to WAVE size limitations */ -static FLAC__byte buffer[READSIZE/*samples*/ * 2/*bytes_per_sample*/ * 2/*channels*/]; /* we read the WAVE data into here */ -static FLAC__int32 pcm[READSIZE/*samples*/ * 2/*channels*/]; - -int main(int argc, char *argv[]) -{ - FLAC__bool ok = true; - FLAC__StreamEncoder *encoder = 0; - FLAC__StreamEncoderInitStatus init_status; - FLAC__StreamMetadata *metadata[2]; - FLAC__StreamMetadata_VorbisComment_Entry entry; - FILE *fin; - unsigned sample_rate = 0; - unsigned channels = 0; - unsigned bps = 0; - - if(argc != 3) { - fprintf(stderr, "usage: %s infile.wav outfile.flac\n", argv[0]); - return 1; - } - - if((fin = fopen(argv[1], "rb")) == NULL) { - fprintf(stderr, "ERROR: opening %s for output\n", argv[1]); - return 1; - } - - /* read wav header and validate it */ - if( - fread(buffer, 1, 44, fin) != 44 || - memcmp(buffer, "RIFF", 4) || - memcmp(buffer+8, "WAVEfmt \020\000\000\000\001\000\002\000", 16) || - memcmp(buffer+32, "\004\000\020\000data", 8) - ) { - fprintf(stderr, "ERROR: invalid/unsupported WAVE file, only 16bps stereo WAVE in canonical form allowed\n"); - fclose(fin); - return 1; - } - sample_rate = ((((((unsigned)buffer[27] << 8) | buffer[26]) << 8) | buffer[25]) << 8) | buffer[24]; - channels = 2; - bps = 16; - total_samples = (((((((unsigned)buffer[43] << 8) | buffer[42]) << 8) | buffer[41]) << 8) | buffer[40]) / 4; - - /* allocate the encoder */ - if((encoder = FLAC__stream_encoder_new()) == NULL) { - fprintf(stderr, "ERROR: allocating encoder\n"); - fclose(fin); - return 1; - } - - ok &= FLAC__stream_encoder_set_verify(encoder, true); - ok &= FLAC__stream_encoder_set_compression_level(encoder, 5); - ok &= FLAC__stream_encoder_set_channels(encoder, channels); - ok &= FLAC__stream_encoder_set_bits_per_sample(encoder, bps); - ok &= FLAC__stream_encoder_set_sample_rate(encoder, sample_rate); - ok &= FLAC__stream_encoder_set_total_samples_estimate(encoder, total_samples); - - /* now add some metadata; we'll add some tags and a padding block */ - if(ok) { - if( - (metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)) == NULL || - (metadata[1] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)) == NULL || - /* there are many tag (vorbiscomment) functions but these are convenient for this particular use: */ - !FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "ARTIST", "Some Artist") || - !FLAC__metadata_object_vorbiscomment_append_comment(metadata[0], entry, /*copy=*/false) || /* copy=false: let metadata object take control of entry's allocated string */ - !FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "YEAR", "1984") || - !FLAC__metadata_object_vorbiscomment_append_comment(metadata[0], entry, /*copy=*/false) - ) { - fprintf(stderr, "ERROR: out of memory or tag error\n"); - ok = false; - } else { - - metadata[1]->length = 1234; /* set the padding length */ - - ok = FLAC__stream_encoder_set_metadata(encoder, metadata, 2); - - } - } - - /* initialize encoder */ - if(ok) { - init_status = FLAC__stream_encoder_init_file(encoder, argv[2], progress_callback, /*client_data=*/NULL); - if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { - fprintf(stderr, "ERROR: initializing encoder: %s\n", FLAC__StreamEncoderInitStatusString[init_status]); - ok = false; - } - } - - /* read blocks of samples from WAVE file and feed to encoder */ - if(ok) { - size_t left = (size_t)total_samples; - while(ok && left) { - size_t need = (left>READSIZE? (size_t)READSIZE : (size_t)left); - if(fread(buffer, channels*(bps/8), need, fin) != need) { - fprintf(stderr, "ERROR: reading from WAVE file\n"); - ok = false; - } - else { - /* convert the packed little-endian 16-bit PCM samples from WAVE into an interleaved FLAC__int32 buffer for libFLAC */ - size_t i; - for(i = 0; i < need*channels; i++) { - /* inefficient but simple and works on big- or little-endian machines */ - pcm[i] = (FLAC__int32)(((FLAC__int16)(FLAC__int8)buffer[2*i+1] << 8) | (FLAC__int16)buffer[2*i]); - } - /* feed samples to encoder */ - ok = FLAC__stream_encoder_process_interleaved(encoder, pcm, need); - } - left -= need; - } - } - - ok &= FLAC__stream_encoder_finish(encoder); - - fprintf(stderr, "encoding: %s\n", ok? "succeeded" : "FAILED"); - fprintf(stderr, " state: %s\n", FLAC__StreamEncoderStateString[FLAC__stream_encoder_get_state(encoder)]); - - /* now that encoding is finished, the metadata can be freed */ - FLAC__metadata_object_delete(metadata[0]); - FLAC__metadata_object_delete(metadata[1]); - - FLAC__stream_encoder_delete(encoder); - fclose(fin); - - return 0; -} - -void progress_callback(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data) -{ - (void)encoder, (void)client_data; - - fprintf(stderr, "wrote %" PRIu64 " bytes, %" PRIu64 "/%u samples, %u/%u frames\n", bytes_written, samples_written, total_samples, frames_written, total_frames_estimate); -} diff --git a/Engine/lib/flac/examples/cpp/Makefile.am b/Engine/lib/flac/examples/cpp/Makefile.am deleted file mode 100644 index ced8f8ede..000000000 --- a/Engine/lib/flac/examples/cpp/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -SUBDIRS = decode encode diff --git a/Engine/lib/flac/examples/cpp/decode/Makefile.am b/Engine/lib/flac/examples/cpp/decode/Makefile.am deleted file mode 100644 index 3c9499cbc..000000000 --- a/Engine/lib/flac/examples/cpp/decode/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -SUBDIRS = file diff --git a/Engine/lib/flac/examples/cpp/decode/file/CMakeLists.txt b/Engine/lib/flac/examples/cpp/decode/file/CMakeLists.txt deleted file mode 100644 index 2ce420d72..000000000 --- a/Engine/lib/flac/examples/cpp/decode/file/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(decode_file_cxx main.cpp) -target_link_libraries(decode_file_cxx FLAC++) diff --git a/Engine/lib/flac/examples/cpp/decode/file/Makefile.am b/Engine/lib/flac/examples/cpp/decode/file/Makefile.am deleted file mode 100644 index ff6085308..000000000 --- a/Engine/lib/flac/examples/cpp/decode/file/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# example_cpp_decode_file - Simple FLAC file decoder using libFLAC -# Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -noinst_PROGRAMS = example_cpp_decode_file -example_cpp_decode_file_LDADD = \ - $(top_builddir)/src/libFLAC++/libFLAC++.la \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - @OGG_LIBS@ \ - -lm - -example_cpp_decode_file_SOURCES = main.cpp - -CLEANFILES = example_cpp_decode_file.exe diff --git a/Engine/lib/flac/examples/cpp/decode/file/main.cpp b/Engine/lib/flac/examples/cpp/decode/file/main.cpp deleted file mode 100644 index d1c29958d..000000000 --- a/Engine/lib/flac/examples/cpp/decode/file/main.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* example_cpp_decode_file - Simple FLAC file decoder using libFLAC - * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * This example shows how to use libFLAC++ to decode a FLAC file to a WAVE - * file. It only supports 16-bit stereo files. - * - * Complete API documentation can be found at: - * http://xiph.org/flac/api/ - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#include "FLAC++/decoder.h" -#include "share/compat.h" - -static FLAC__uint64 total_samples = 0; -static uint32_t sample_rate = 0; -static uint32_t channels = 0; -static uint32_t bps = 0; - -static bool write_little_endian_uint16(FILE *f, FLAC__uint16 x) -{ - return - fputc(x, f) != EOF && - fputc(x >> 8, f) != EOF - ; -} - -static bool write_little_endian_int16(FILE *f, FLAC__int16 x) -{ - return write_little_endian_uint16(f, (FLAC__uint16)x); -} - -static bool write_little_endian_uint32(FILE *f, FLAC__uint32 x) -{ - return - fputc(x, f) != EOF && - fputc(x >> 8, f) != EOF && - fputc(x >> 16, f) != EOF && - fputc(x >> 24, f) != EOF - ; -} - -class OurDecoder: public FLAC::Decoder::File { -public: - OurDecoder(FILE *f_): FLAC::Decoder::File(), f(f_) { } -protected: - FILE *f; - - virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]); - virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata); - virtual void error_callback(::FLAC__StreamDecoderErrorStatus status); -private: - OurDecoder(const OurDecoder&); - OurDecoder&operator=(const OurDecoder&); -}; - -int main(int argc, char *argv[]) -{ - bool ok = true; - FILE *fout; - - if(argc != 3) { - fprintf(stderr, "usage: %s infile.flac outfile.wav\n", argv[0]); - return 1; - } - - if((fout = fopen(argv[2], "wb")) == NULL) { - fprintf(stderr, "ERROR: opening %s for output\n", argv[2]); - return 1; - } - - OurDecoder decoder(fout); - - if(!decoder) { - fprintf(stderr, "ERROR: allocating decoder\n"); - fclose(fout); - return 1; - } - - (void)decoder.set_md5_checking(true); - - FLAC__StreamDecoderInitStatus init_status = decoder.init(argv[1]); - if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - fprintf(stderr, "ERROR: initializing decoder: %s\n", FLAC__StreamDecoderInitStatusString[init_status]); - ok = false; - } - - if(ok) { - ok = decoder.process_until_end_of_stream(); - fprintf(stderr, "decoding: %s\n", ok? "succeeded" : "FAILED"); - fprintf(stderr, " state: %s\n", decoder.get_state().resolved_as_cstring(decoder)); - } - - fclose(fout); - - return 0; -} - -::FLAC__StreamDecoderWriteStatus OurDecoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) -{ - const FLAC__uint32 total_size = (FLAC__uint32)(total_samples * channels * (bps/8)); - size_t i; - - // Update data - channels = OurDecoder::get_channels(); - bps = OurDecoder::get_bits_per_sample(); - - if(total_samples == 0) { - fprintf(stderr, "ERROR: this example only works for FLAC files that have a total_samples count in STREAMINFO\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - if(channels != 2 || bps != 16) { - fprintf(stderr, "ERROR: this example only supports 16bit stereo streams\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - /* write WAVE header before we write the first frame */ - if(frame->header.number.sample_number == 0) { - if( - fwrite("RIFF", 1, 4, f) < 4 || - !write_little_endian_uint32(f, total_size + 36) || - fwrite("WAVEfmt ", 1, 8, f) < 8 || - !write_little_endian_uint32(f, 16) || - !write_little_endian_uint16(f, 1) || - !write_little_endian_uint16(f, (FLAC__uint16)channels) || - !write_little_endian_uint32(f, sample_rate) || - !write_little_endian_uint32(f, sample_rate * channels * (bps/8)) || - !write_little_endian_uint16(f, (FLAC__uint16)(channels * (bps/8))) || /* block align */ - !write_little_endian_uint16(f, (FLAC__uint16)bps) || - fwrite("data", 1, 4, f) < 4 || - !write_little_endian_uint32(f, total_size) - ) { - fprintf(stderr, "ERROR: write error\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - - /* write decoded PCM samples */ - for(i = 0; i < frame->header.blocksize; i++) { - if( - !write_little_endian_int16(f, (FLAC__int16)buffer[0][i]) || /* left channel */ - !write_little_endian_int16(f, (FLAC__int16)buffer[1][i]) /* right channel */ - ) { - fprintf(stderr, "ERROR: write error\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void OurDecoder::metadata_callback(const ::FLAC__StreamMetadata *metadata) -{ - /* print some stats */ - if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { - /* save for later */ - total_samples = metadata->data.stream_info.total_samples; - sample_rate = metadata->data.stream_info.sample_rate; - channels = metadata->data.stream_info.channels; - bps = metadata->data.stream_info.bits_per_sample; - - fprintf(stderr, "sample rate : %u Hz\n", sample_rate); - fprintf(stderr, "channels : %u\n", channels); - fprintf(stderr, "bits per sample: %u\n", bps); - fprintf(stderr, "total samples : %" PRIu64 "\n", total_samples); - } -} - -void OurDecoder::error_callback(::FLAC__StreamDecoderErrorStatus status) -{ - fprintf(stderr, "Got error callback: %s\n", FLAC__StreamDecoderErrorStatusString[status]); -} diff --git a/Engine/lib/flac/examples/cpp/encode/Makefile.am b/Engine/lib/flac/examples/cpp/encode/Makefile.am deleted file mode 100644 index 3c9499cbc..000000000 --- a/Engine/lib/flac/examples/cpp/encode/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -SUBDIRS = file diff --git a/Engine/lib/flac/examples/cpp/encode/file/CMakeLists.txt b/Engine/lib/flac/examples/cpp/encode/file/CMakeLists.txt deleted file mode 100644 index 26178763c..000000000 --- a/Engine/lib/flac/examples/cpp/encode/file/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(encode_file_cxx main.cpp) -target_link_libraries(encode_file_cxx FLAC++) diff --git a/Engine/lib/flac/examples/cpp/encode/file/Makefile.am b/Engine/lib/flac/examples/cpp/encode/file/Makefile.am deleted file mode 100644 index f293d615e..000000000 --- a/Engine/lib/flac/examples/cpp/encode/file/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# example_cpp_encode_file - Simple FLAC file encoder using libFLAC -# Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -noinst_PROGRAMS = example_cpp_encode_file -example_cpp_encode_file_LDADD = \ - $(top_builddir)/src/libFLAC++/libFLAC++.la \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - @OGG_LIBS@ \ - -lm - -example_cpp_encode_file_SOURCES = main.cpp - -CLEANFILES = example_cpp_encode_file.exe diff --git a/Engine/lib/flac/examples/cpp/encode/file/main.cpp b/Engine/lib/flac/examples/cpp/encode/file/main.cpp deleted file mode 100644 index c420d230d..000000000 --- a/Engine/lib/flac/examples/cpp/encode/file/main.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* example_cpp_encode_file - Simple FLAC file encoder using libFLAC - * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * This example shows how to use libFLAC++ to encode a WAVE file to a FLAC - * file. It only supports 16-bit stereo files in canonical WAVE format. - * - * Complete API documentation can be found at: - * http://xiph.org/flac/api/ - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include - -#include "FLAC++/metadata.h" -#include "FLAC++/encoder.h" -#include "share/compat.h" - -#include - -class OurEncoder: public FLAC::Encoder::File { -public: - OurEncoder(): FLAC::Encoder::File() { } -protected: - virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate); -}; - -#define READSIZE 1024 - -static uint32_t total_samples = 0; /* can use a 32-bit number due to WAVE size limitations */ -static FLAC__byte buffer[READSIZE/*samples*/ * 2/*bytes_per_sample*/ * 2/*channels*/]; /* we read the WAVE data into here */ -static FLAC__int32 pcm[READSIZE/*samples*/ * 2/*channels*/]; - -int main(int argc, char *argv[]) -{ - bool ok = true; - OurEncoder encoder; - FLAC__StreamEncoderInitStatus init_status; - FLAC__StreamMetadata *metadata[2]; - FLAC__StreamMetadata_VorbisComment_Entry entry; - FILE *fin; - uint32_t sample_rate = 0; - uint32_t channels = 0; - uint32_t bps = 0; - - if(argc != 3) { - fprintf(stderr, "usage: %s infile.wav outfile.flac\n", argv[0]); - return 1; - } - - if((fin = fopen(argv[1], "rb")) == NULL) { - fprintf(stderr, "ERROR: opening %s for output\n", argv[1]); - return 1; - } - - /* read wav header and validate it */ - if( - fread(buffer, 1, 44, fin) != 44 || - memcmp(buffer, "RIFF", 4) || - memcmp(buffer+8, "WAVEfmt \020\000\000\000\001\000\002\000", 16) || - memcmp(buffer+32, "\004\000\020\000data", 8) - ) { - fprintf(stderr, "ERROR: invalid/unsupported WAVE file, only 16bps stereo WAVE in canonical form allowed\n"); - fclose(fin); - return 1; - } - sample_rate = ((((((uint32_t)buffer[27] << 8) | buffer[26]) << 8) | buffer[25]) << 8) | buffer[24]; - channels = 2; - bps = 16; - total_samples = (((((((uint32_t)buffer[43] << 8) | buffer[42]) << 8) | buffer[41]) << 8) | buffer[40]) / 4; - - /* check the encoder */ - if(!encoder) { - fprintf(stderr, "ERROR: allocating encoder\n"); - fclose(fin); - return 1; - } - - ok &= encoder.set_verify(true); - ok &= encoder.set_compression_level(5); - ok &= encoder.set_channels(channels); - ok &= encoder.set_bits_per_sample(bps); - ok &= encoder.set_sample_rate(sample_rate); - ok &= encoder.set_total_samples_estimate(total_samples); - - /* now add some metadata; we'll add some tags and a padding block */ - if(ok) { - if( - (metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)) == NULL || - (metadata[1] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)) == NULL || - /* there are many tag (vorbiscomment) functions but these are convenient for this particular use: */ - !FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "ARTIST", "Some Artist") || - !FLAC__metadata_object_vorbiscomment_append_comment(metadata[0], entry, /*copy=*/false) || /* copy=false: let metadata object take control of entry's allocated string */ - !FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "YEAR", "1984") || - !FLAC__metadata_object_vorbiscomment_append_comment(metadata[0], entry, /*copy=*/false) - ) { - fprintf(stderr, "ERROR: out of memory or tag error\n"); - ok = false; - } else { - - metadata[1]->length = 1234; /* set the padding length */ - - ok = encoder.set_metadata(metadata, 2); - - } - } - - /* initialize encoder */ - if(ok) { - init_status = encoder.init(argv[2]); - if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { - fprintf(stderr, "ERROR: initializing encoder: %s\n", FLAC__StreamEncoderInitStatusString[init_status]); - ok = false; - } - } - - /* read blocks of samples from WAVE file and feed to encoder */ - if(ok) { - size_t left = (size_t)total_samples; - while(ok && left) { - size_t need = (left>READSIZE? (size_t)READSIZE : (size_t)left); - if(fread(buffer, channels*(bps/8), need, fin) != need) { - fprintf(stderr, "ERROR: reading from WAVE file\n"); - ok = false; - } - else { - /* convert the packed little-endian 16-bit PCM samples from WAVE into an interleaved FLAC__int32 buffer for libFLAC */ - size_t i; - for(i = 0; i < need*channels; i++) { - /* inefficient but simple and works on big- or little-endian machines */ - pcm[i] = (FLAC__int32)(((FLAC__int16)(FLAC__int8)buffer[2*i+1] << 8) | (FLAC__int16)buffer[2*i]); - } - /* feed samples to encoder */ - ok = encoder.process_interleaved(pcm, need); - } - left -= need; - } - } - - ok &= encoder.finish(); - - fprintf(stderr, "encoding: %s\n", ok? "succeeded" : "FAILED"); - fprintf(stderr, " state: %s\n", encoder.get_state().resolved_as_cstring(encoder)); - - /* now that encoding is finished, the metadata can be freed */ - FLAC__metadata_object_delete(metadata[0]); - FLAC__metadata_object_delete(metadata[1]); - - fclose(fin); - - return 0; -} - -void OurEncoder::progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate) -{ - fprintf(stderr, "wrote %" PRIu64 " bytes, %" PRIu64 "/%u samples, %u/%u frames\n", bytes_written, samples_written, total_samples, frames_written, total_frames_estimate); -} diff --git a/Engine/lib/flac/flac-config.cmake.in b/Engine/lib/flac/flac-config.cmake.in deleted file mode 100644 index bcafc4c8b..000000000 --- a/Engine/lib/flac/flac-config.cmake.in +++ /dev/null @@ -1,17 +0,0 @@ -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) -if(NOT TARGET Ogg::ogg) - find_dependency(Ogg) -endif() - -include("${CMAKE_CURRENT_LIST_DIR}/targets.cmake") - -if(TARGET FLAC::FLAC) - set(FLAC_FLAC_FOUND 1) -endif() -if(TARGET FLAC::FLAC++) - set(FLAC_FLAC++_FOUND 1) -endif() - -check_required_components(FLAC) diff --git a/Engine/lib/flac/include/FLAC++/Makefile.am b/Engine/lib/flac/include/FLAC++/Makefile.am deleted file mode 100644 index ba5daa5b1..000000000 --- a/Engine/lib/flac/include/FLAC++/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# libFLAC++ - Free Lossless Audio Codec library -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# 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 the Xiph.org Foundation nor the names of its -# 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 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. - -flaccppincludedir = $(includedir)/FLAC++ -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -flaccppinclude_HEADERS = \ - all.h \ - decoder.h \ - encoder.h \ - export.h \ - metadata.h diff --git a/Engine/lib/flac/include/FLAC++/all.h b/Engine/lib/flac/include/FLAC++/all.h deleted file mode 100644 index fa5bd4160..000000000 --- a/Engine/lib/flac/include/FLAC++/all.h +++ /dev/null @@ -1,49 +0,0 @@ -/* libFLAC++ - Free Lossless Audio Codec library - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLACPP__ALL_H -#define FLACPP__ALL_H - -#include "export.h" - -#include "encoder.h" -#include "decoder.h" -#include "metadata.h" - -/** \defgroup flacpp FLAC C++ API - * - * The FLAC C++ API is the interface to libFLAC++, a set of classes - * that encapsulate the encoders, decoders, and metadata interfaces - * in libFLAC. - */ - -#endif diff --git a/Engine/lib/flac/include/FLAC++/decoder.h b/Engine/lib/flac/include/FLAC++/decoder.h deleted file mode 100644 index 6f0bda99a..000000000 --- a/Engine/lib/flac/include/FLAC++/decoder.h +++ /dev/null @@ -1,248 +0,0 @@ -/* libFLAC++ - Free Lossless Audio Codec library - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLACPP__DECODER_H -#define FLACPP__DECODER_H - -#include "export.h" - -#include -#include "FLAC/stream_decoder.h" - - -/** \file include/FLAC++/decoder.h - * - * \brief - * This module contains the classes which implement the various - * decoders. - * - * See the detailed documentation in the - * \link flacpp_decoder decoder \endlink module. - */ - -/** \defgroup flacpp_decoder FLAC++/decoder.h: decoder classes - * \ingroup flacpp - * - * \brief - * This module describes the decoder layers provided by libFLAC++. - * - * The libFLAC++ decoder classes are object wrappers around their - * counterparts in libFLAC. All decoding layers available in - * libFLAC are also provided here. The interface is very similar; - * make sure to read the \link flac_decoder libFLAC decoder module \endlink. - * - * There are only two significant differences here. First, instead of - * passing in C function pointers for callbacks, you inherit from the - * decoder class and provide implementations for the callbacks in your - * derived class; because of this there is no need for a 'client_data' - * property. - * - * Second, there are two stream decoder classes. FLAC::Decoder::Stream - * is used for the same cases that FLAC__stream_decoder_init_stream() / - * FLAC__stream_decoder_init_ogg_stream() are used, and FLAC::Decoder::File - * is used for the same cases that - * FLAC__stream_decoder_init_FILE() and FLAC__stream_decoder_init_file() / - * FLAC__stream_decoder_init_ogg_FILE() and FLAC__stream_decoder_init_ogg_file() - * are used. - */ - -namespace FLAC { - namespace Decoder { - - /** \ingroup flacpp_decoder - * \brief - * This class wraps the ::FLAC__StreamDecoder. If you are - * decoding from a file, FLAC::Decoder::File may be more - * convenient. - * - * The usage of this class is similar to FLAC__StreamDecoder, - * except instead of providing callbacks to - * FLAC__stream_decoder_init*_stream(), you will inherit from this - * class and override the virtual callback functions with your - * own implementations, then call init() or init_ogg(). The rest - * of the calls work the same as in the C layer. - * - * Only the read, write, and error callbacks are mandatory. The - * others are optional; this class provides default - * implementations that do nothing. In order for seeking to work - * you must override seek_callback(), tell_callback(), - * length_callback(), and eof_callback(). - */ - class FLACPP_API Stream { - public: - /** This class is a wrapper around FLAC__StreamDecoderState. - */ - class FLACPP_API State { - public: - inline State(::FLAC__StreamDecoderState state): state_(state) { } - inline operator ::FLAC__StreamDecoderState() const { return state_; } - inline const char *as_cstring() const { return ::FLAC__StreamDecoderStateString[state_]; } - inline const char *resolved_as_cstring(const Stream &decoder) const { return ::FLAC__stream_decoder_get_resolved_state_string(decoder.decoder_); } - protected: - ::FLAC__StreamDecoderState state_; - }; - - Stream(); - virtual ~Stream(); - - //@{ - /** Call after construction to check that the object was created - * successfully. If not, use get_state() to find out why not. - */ - virtual bool is_valid() const; - inline operator bool() const { return is_valid(); } ///< See is_valid() - //@} - - virtual bool set_ogg_serial_number(long value); ///< See FLAC__stream_decoder_set_ogg_serial_number() - virtual bool set_md5_checking(bool value); ///< See FLAC__stream_decoder_set_md5_checking() - virtual bool set_metadata_respond(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_respond() - virtual bool set_metadata_respond_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_respond_application() - virtual bool set_metadata_respond_all(); ///< See FLAC__stream_decoder_set_metadata_respond_all() - virtual bool set_metadata_ignore(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_ignore() - virtual bool set_metadata_ignore_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_ignore_application() - virtual bool set_metadata_ignore_all(); ///< See FLAC__stream_decoder_set_metadata_ignore_all() - - /* get_state() is not virtual since we want subclasses to be able to return their own state */ - State get_state() const; ///< See FLAC__stream_decoder_get_state() - virtual bool get_md5_checking() const; ///< See FLAC__stream_decoder_get_md5_checking() - virtual FLAC__uint64 get_total_samples() const; ///< See FLAC__stream_decoder_get_total_samples() - virtual uint32_t get_channels() const; ///< See FLAC__stream_decoder_get_channels() - virtual ::FLAC__ChannelAssignment get_channel_assignment() const; ///< See FLAC__stream_decoder_get_channel_assignment() - virtual uint32_t get_bits_per_sample() const; ///< See FLAC__stream_decoder_get_bits_per_sample() - virtual uint32_t get_sample_rate() const; ///< See FLAC__stream_decoder_get_sample_rate() - virtual uint32_t get_blocksize() const; ///< See FLAC__stream_decoder_get_blocksize() - virtual bool get_decode_position(FLAC__uint64 *position) const; ///< See FLAC__stream_decoder_get_decode_position() - - virtual ::FLAC__StreamDecoderInitStatus init(); ///< Seek FLAC__stream_decoder_init_stream() - virtual ::FLAC__StreamDecoderInitStatus init_ogg(); ///< Seek FLAC__stream_decoder_init_ogg_stream() - - virtual bool finish(); ///< See FLAC__stream_decoder_finish() - - virtual bool flush(); ///< See FLAC__stream_decoder_flush() - virtual bool reset(); ///< See FLAC__stream_decoder_reset() - - virtual bool process_single(); ///< See FLAC__stream_decoder_process_single() - virtual bool process_until_end_of_metadata(); ///< See FLAC__stream_decoder_process_until_end_of_metadata() - virtual bool process_until_end_of_stream(); ///< See FLAC__stream_decoder_process_until_end_of_stream() - virtual bool skip_single_frame(); ///< See FLAC__stream_decoder_skip_single_frame() - - virtual bool seek_absolute(FLAC__uint64 sample); ///< See FLAC__stream_decoder_seek_absolute() - protected: - /// see FLAC__StreamDecoderReadCallback - virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) = 0; - - /// see FLAC__StreamDecoderSeekCallback - virtual ::FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset); - - /// see FLAC__StreamDecoderTellCallback - virtual ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset); - - /// see FLAC__StreamDecoderLengthCallback - virtual ::FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length); - - /// see FLAC__StreamDecoderEofCallback - virtual bool eof_callback(); - - /// see FLAC__StreamDecoderWriteCallback - virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0; - - /// see FLAC__StreamDecoderMetadataCallback - virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata); - - /// see FLAC__StreamDecoderErrorCallback - virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0; - -#if (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC) - // lame hack: some compilers can't see a protected decoder_ from nested State::resolved_as_cstring() - friend State; -#endif - ::FLAC__StreamDecoder *decoder_; - - static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); - static ::FLAC__StreamDecoderSeekStatus seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data); - static ::FLAC__StreamDecoderTellStatus tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); - static ::FLAC__StreamDecoderLengthStatus length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data); - static FLAC__bool eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data); - static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); - static void metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data); - static void error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data); - private: - // Private and undefined so you can't use them: - Stream(const Stream &); - void operator=(const Stream &); - }; - - /** \ingroup flacpp_decoder - * \brief - * This class wraps the ::FLAC__StreamDecoder. If you are - * not decoding from a file, you may need to use - * FLAC::Decoder::Stream. - * - * The usage of this class is similar to FLAC__StreamDecoder, - * except instead of providing callbacks to - * FLAC__stream_decoder_init*_FILE() or - * FLAC__stream_decoder_init*_file(), you will inherit from this - * class and override the virtual callback functions with your - * own implementations, then call init() or init_off(). The rest - * of the calls work the same as in the C layer. - * - * Only the write, and error callbacks from FLAC::Decoder::Stream - * are mandatory. The others are optional; this class provides - * full working implementations for all other callbacks and - * supports seeking. - */ - class FLACPP_API File: public Stream { - public: - File(); - virtual ~File(); - - using Stream::init; - virtual ::FLAC__StreamDecoderInitStatus init(FILE *file); ///< See FLAC__stream_decoder_init_FILE() - virtual ::FLAC__StreamDecoderInitStatus init(const char *filename); ///< See FLAC__stream_decoder_init_file() - virtual ::FLAC__StreamDecoderInitStatus init(const std::string &filename); ///< See FLAC__stream_decoder_init_file() - using Stream::init_ogg; - virtual ::FLAC__StreamDecoderInitStatus init_ogg(FILE *file); ///< See FLAC__stream_decoder_init_ogg_FILE() - virtual ::FLAC__StreamDecoderInitStatus init_ogg(const char *filename); ///< See FLAC__stream_decoder_init_ogg_file() - virtual ::FLAC__StreamDecoderInitStatus init_ogg(const std::string &filename); ///< See FLAC__stream_decoder_init_ogg_file() - protected: - // this is a dummy implementation to satisfy the pure virtual in Stream that is actually supplied internally by the C layer - virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes); - private: - // Private and undefined so you can't use them: - File(const File &); - void operator=(const File &); - }; - - } -} - -#endif diff --git a/Engine/lib/flac/include/FLAC++/encoder.h b/Engine/lib/flac/include/FLAC++/encoder.h deleted file mode 100644 index 2400823d4..000000000 --- a/Engine/lib/flac/include/FLAC++/encoder.h +++ /dev/null @@ -1,265 +0,0 @@ -/* libFLAC++ - Free Lossless Audio Codec library - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLACPP__ENCODER_H -#define FLACPP__ENCODER_H - -#include "export.h" - -#include "FLAC/stream_encoder.h" -#include "decoder.h" -#include "metadata.h" - - -/** \file include/FLAC++/encoder.h - * - * \brief - * This module contains the classes which implement the various - * encoders. - * - * See the detailed documentation in the - * \link flacpp_encoder encoder \endlink module. - */ - -/** \defgroup flacpp_encoder FLAC++/encoder.h: encoder classes - * \ingroup flacpp - * - * \brief - * This module describes the encoder layers provided by libFLAC++. - * - * The libFLAC++ encoder classes are object wrappers around their - * counterparts in libFLAC. All encoding layers available in - * libFLAC are also provided here. The interface is very similar; - * make sure to read the \link flac_encoder libFLAC encoder module \endlink. - * - * There are only two significant differences here. First, instead of - * passing in C function pointers for callbacks, you inherit from the - * encoder class and provide implementations for the callbacks in your - * derived class; because of this there is no need for a 'client_data' - * property. - * - * Second, there are two stream encoder classes. FLAC::Encoder::Stream - * is used for the same cases that FLAC__stream_encoder_init_stream() / - * FLAC__stream_encoder_init_ogg_stream() are used, and FLAC::Encoder::File - * is used for the same cases that - * FLAC__stream_encoder_init_FILE() and FLAC__stream_encoder_init_file() / - * FLAC__stream_encoder_init_ogg_FILE() and FLAC__stream_encoder_init_ogg_file() - * are used. - */ - -namespace FLAC { - namespace Encoder { - - /** \ingroup flacpp_encoder - * \brief - * This class wraps the ::FLAC__StreamEncoder. If you are - * encoding to a file, FLAC::Encoder::File may be more - * convenient. - * - * The usage of this class is similar to FLAC__StreamEncoder, - * except instead of providing callbacks to - * FLAC__stream_encoder_init*_stream(), you will inherit from this - * class and override the virtual callback functions with your - * own implementations, then call init() or init_ogg(). The rest of - * the calls work the same as in the C layer. - * - * Only the write callback is mandatory. The others are - * optional; this class provides default implementations that do - * nothing. In order for some STREAMINFO and SEEKTABLE data to - * be written properly, you must override seek_callback() and - * tell_callback(); see FLAC__stream_encoder_init_stream() as to - * why. - */ - class FLACPP_API Stream { - public: - /** This class is a wrapper around FLAC__StreamEncoderState. - */ - class FLACPP_API State { - public: - inline State(::FLAC__StreamEncoderState state): state_(state) { } - inline operator ::FLAC__StreamEncoderState() const { return state_; } - inline const char *as_cstring() const { return ::FLAC__StreamEncoderStateString[state_]; } - inline const char *resolved_as_cstring(const Stream &encoder) const { return ::FLAC__stream_encoder_get_resolved_state_string(encoder.encoder_); } - protected: - ::FLAC__StreamEncoderState state_; - }; - - Stream(); - virtual ~Stream(); - - //@{ - /** Call after construction to check that the object was created - * successfully. If not, use get_state() to find out why not. - * - */ - virtual bool is_valid() const; - inline operator bool() const { return is_valid(); } ///< See is_valid() - //@} - - virtual bool set_ogg_serial_number(long value); ///< See FLAC__stream_encoder_set_ogg_serial_number() - virtual bool set_verify(bool value); ///< See FLAC__stream_encoder_set_verify() - virtual bool set_streamable_subset(bool value); ///< See FLAC__stream_encoder_set_streamable_subset() - virtual bool set_channels(uint32_t value); ///< See FLAC__stream_encoder_set_channels() - virtual bool set_bits_per_sample(uint32_t value); ///< See FLAC__stream_encoder_set_bits_per_sample() - virtual bool set_sample_rate(uint32_t value); ///< See FLAC__stream_encoder_set_sample_rate() - virtual bool set_compression_level(uint32_t value); ///< See FLAC__stream_encoder_set_compression_level() - virtual bool set_blocksize(uint32_t value); ///< See FLAC__stream_encoder_set_blocksize() - virtual bool set_do_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_do_mid_side_stereo() - virtual bool set_loose_mid_side_stereo(bool value); ///< See FLAC__stream_encoder_set_loose_mid_side_stereo() - virtual bool set_apodization(const char *specification); ///< See FLAC__stream_encoder_set_apodization() - virtual bool set_max_lpc_order(uint32_t value); ///< See FLAC__stream_encoder_set_max_lpc_order() - virtual bool set_qlp_coeff_precision(uint32_t value); ///< See FLAC__stream_encoder_set_qlp_coeff_precision() - virtual bool set_do_qlp_coeff_prec_search(bool value); ///< See FLAC__stream_encoder_set_do_qlp_coeff_prec_search() - virtual bool set_do_escape_coding(bool value); ///< See FLAC__stream_encoder_set_do_escape_coding() - virtual bool set_do_exhaustive_model_search(bool value); ///< See FLAC__stream_encoder_set_do_exhaustive_model_search() - virtual bool set_min_residual_partition_order(uint32_t value); ///< See FLAC__stream_encoder_set_min_residual_partition_order() - virtual bool set_max_residual_partition_order(uint32_t value); ///< See FLAC__stream_encoder_set_max_residual_partition_order() - virtual bool set_rice_parameter_search_dist(uint32_t value); ///< See FLAC__stream_encoder_set_rice_parameter_search_dist() - virtual bool set_total_samples_estimate(FLAC__uint64 value); ///< See FLAC__stream_encoder_set_total_samples_estimate() - virtual bool set_metadata(::FLAC__StreamMetadata **metadata, uint32_t num_blocks); ///< See FLAC__stream_encoder_set_metadata() - virtual bool set_metadata(FLAC::Metadata::Prototype **metadata, uint32_t num_blocks); ///< See FLAC__stream_encoder_set_metadata() - virtual bool set_limit_min_bitrate(bool value); ///< See FLAC__stream_encoder_set_limit_min_bitrate() - - /* get_state() is not virtual since we want subclasses to be able to return their own state */ - State get_state() const; ///< See FLAC__stream_encoder_get_state() - virtual Decoder::Stream::State get_verify_decoder_state() const; ///< See FLAC__stream_encoder_get_verify_decoder_state() - virtual void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got); ///< See FLAC__stream_encoder_get_verify_decoder_error_stats() - virtual bool get_verify() const; ///< See FLAC__stream_encoder_get_verify() - virtual bool get_streamable_subset() const; ///< See FLAC__stream_encoder_get_streamable_subset() - virtual bool get_do_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_do_mid_side_stereo() - virtual bool get_loose_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_loose_mid_side_stereo() - virtual uint32_t get_channels() const; ///< See FLAC__stream_encoder_get_channels() - virtual uint32_t get_bits_per_sample() const; ///< See FLAC__stream_encoder_get_bits_per_sample() - virtual uint32_t get_sample_rate() const; ///< See FLAC__stream_encoder_get_sample_rate() - virtual uint32_t get_blocksize() const; ///< See FLAC__stream_encoder_get_blocksize() - virtual uint32_t get_max_lpc_order() const; ///< See FLAC__stream_encoder_get_max_lpc_order() - virtual uint32_t get_qlp_coeff_precision() const; ///< See FLAC__stream_encoder_get_qlp_coeff_precision() - virtual bool get_do_qlp_coeff_prec_search() const; ///< See FLAC__stream_encoder_get_do_qlp_coeff_prec_search() - virtual bool get_do_escape_coding() const; ///< See FLAC__stream_encoder_get_do_escape_coding() - virtual bool get_do_exhaustive_model_search() const; ///< See FLAC__stream_encoder_get_do_exhaustive_model_search() - virtual uint32_t get_min_residual_partition_order() const; ///< See FLAC__stream_encoder_get_min_residual_partition_order() - virtual uint32_t get_max_residual_partition_order() const; ///< See FLAC__stream_encoder_get_max_residual_partition_order() - virtual uint32_t get_rice_parameter_search_dist() const; ///< See FLAC__stream_encoder_get_rice_parameter_search_dist() - virtual FLAC__uint64 get_total_samples_estimate() const; ///< See FLAC__stream_encoder_get_total_samples_estimate() - virtual bool get_limit_min_bitrate() const; ///< See FLAC__stream_encoder_get_limit_min_bitrate() - - virtual ::FLAC__StreamEncoderInitStatus init(); ///< See FLAC__stream_encoder_init_stream() - virtual ::FLAC__StreamEncoderInitStatus init_ogg(); ///< See FLAC__stream_encoder_init_ogg_stream() - - virtual bool finish(); ///< See FLAC__stream_encoder_finish() - - virtual bool process(const FLAC__int32 * const buffer[], uint32_t samples); ///< See FLAC__stream_encoder_process() - virtual bool process_interleaved(const FLAC__int32 buffer[], uint32_t samples); ///< See FLAC__stream_encoder_process_interleaved() - protected: - /// See FLAC__StreamEncoderReadCallback - virtual ::FLAC__StreamEncoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes); - - /// See FLAC__StreamEncoderWriteCallback - virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame) = 0; - - /// See FLAC__StreamEncoderSeekCallback - virtual ::FLAC__StreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset); - - /// See FLAC__StreamEncoderTellCallback - virtual ::FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset); - - /// See FLAC__StreamEncoderMetadataCallback - virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata); - -#if (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC) - // lame hack: some compilers can't see a protected encoder_ from nested State::resolved_as_cstring() - friend State; -#endif - ::FLAC__StreamEncoder *encoder_; - - static ::FLAC__StreamEncoderReadStatus read_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data); - static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data); - static ::FLAC__StreamEncoderSeekStatus seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data); - static ::FLAC__StreamEncoderTellStatus tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data); - static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data); - private: - // Private and undefined so you can't use them: - Stream(const Stream &); - void operator=(const Stream &); - }; - - /** \ingroup flacpp_encoder - * \brief - * This class wraps the ::FLAC__StreamEncoder. If you are - * not encoding to a file, you may need to use - * FLAC::Encoder::Stream. - * - * The usage of this class is similar to FLAC__StreamEncoder, - * except instead of providing callbacks to - * FLAC__stream_encoder_init*_FILE() or - * FLAC__stream_encoder_init*_file(), you will inherit from this - * class and override the virtual callback functions with your - * own implementations, then call init() or init_ogg(). The rest - * of the calls work the same as in the C layer. - * - * There are no mandatory callbacks; all the callbacks from - * FLAC::Encoder::Stream are implemented here fully and support - * full post-encode STREAMINFO and SEEKTABLE updating. There is - * only an optional progress callback which you may override to - * get periodic reports on the progress of the encode. - */ - class FLACPP_API File: public Stream { - public: - File(); - virtual ~File(); - - using Stream::init; - virtual ::FLAC__StreamEncoderInitStatus init(FILE *file); ///< See FLAC__stream_encoder_init_FILE() - virtual ::FLAC__StreamEncoderInitStatus init(const char *filename); ///< See FLAC__stream_encoder_init_file() - virtual ::FLAC__StreamEncoderInitStatus init(const std::string &filename); ///< See FLAC__stream_encoder_init_file() - using Stream::init_ogg; - virtual ::FLAC__StreamEncoderInitStatus init_ogg(FILE *file); ///< See FLAC__stream_encoder_init_ogg_FILE() - virtual ::FLAC__StreamEncoderInitStatus init_ogg(const char *filename); ///< See FLAC__stream_encoder_init_ogg_file() - virtual ::FLAC__StreamEncoderInitStatus init_ogg(const std::string &filename); ///< See FLAC__stream_encoder_init_ogg_file() - protected: - /// See FLAC__StreamEncoderProgressCallback - virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate); - - /// This is a dummy implementation to satisfy the pure virtual in Stream that is actually supplied internally by the C layer - virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame); - private: - static void progress_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data); - - // Private and undefined so you can't use them: - File(const Stream &); - void operator=(const Stream &); - }; - - } -} - -#endif diff --git a/Engine/lib/flac/include/FLAC++/export.h b/Engine/lib/flac/include/FLAC++/export.h deleted file mode 100644 index 21d9d8b0b..000000000 --- a/Engine/lib/flac/include/FLAC++/export.h +++ /dev/null @@ -1,100 +0,0 @@ -/* libFLAC++ - Free Lossless Audio Codec library - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLACPP__EXPORT_H -#define FLACPP__EXPORT_H - -/** \file include/FLAC++/export.h - * - * \brief - * This module contains \#defines and symbols for exporting function - * calls, and providing version information and compiled-in features. - * - * See the \link flacpp_export export \endlink module. - */ - -/** \defgroup flacpp_export FLAC++/export.h: export symbols - * \ingroup flacpp - * - * \brief - * This module contains \#defines and symbols for exporting function - * calls, and providing version information and compiled-in features. - * - * If you are compiling for Windows (with Visual Studio or MinGW for - * example) and will link to the static library (libFLAC++.lib) you - * should define FLAC__NO_DLL in your project to make sure the symbols - * are exported properly. - * - * \{ - */ - -/** This \#define is used internally in libFLAC and its headers to make - * sure the correct symbols are exported when working with shared - * libraries. On Windows, this \#define is set to __declspec(dllexport) - * when compiling libFLAC into a library and to __declspec(dllimport) - * when the headers are used to link to that DLL. On non-Windows systems - * it is used to set symbol visibility. - * - * Because of this, the define FLAC__NO_DLL must be defined when linking - * to libFLAC statically or linking will fail. - */ -/* This has grown quite complicated. FLAC__NO_DLL is used by MSVC sln - * files and CMake, which build either static or shared. autotools can - * build static, shared or **both**. Therefore, DLL_EXPORT, which is set - * by libtool, must override FLAC__NO_DLL on building shared components - */ -#if defined(_WIN32) -#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT)) -#define FLACPP_API -#else -#ifdef FLACPP_API_EXPORTS -#define FLACPP_API __declspec(dllexport) -#else -#define FLACPP_API __declspec(dllimport) -#endif -#endif -#elif defined(FLAC__USE_VISIBILITY_ATTR) -#define FLACPP_API __attribute__ ((visibility ("default"))) -#else -#define FLACPP_API -#endif - -/** These \#defines will mirror the libtool-based library version number, see - * http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning - */ -#define FLACPP_API_VERSION_CURRENT 10 -#define FLACPP_API_VERSION_REVISION 1 /**< see above */ -#define FLACPP_API_VERSION_AGE 0 /**< see above */ - -/* \} */ - -#endif diff --git a/Engine/lib/flac/include/FLAC++/metadata.h b/Engine/lib/flac/include/FLAC++/metadata.h deleted file mode 100644 index 26bc47652..000000000 --- a/Engine/lib/flac/include/FLAC++/metadata.h +++ /dev/null @@ -1,1234 +0,0 @@ -/* libFLAC++ - Free Lossless Audio Codec library - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLACPP__METADATA_H -#define FLACPP__METADATA_H - -#include "export.h" - -#include "FLAC/metadata.h" - -// =============================================================== -// -// Full documentation for the metadata interface can be found -// in the C layer in include/FLAC/metadata.h -// -// =============================================================== - -/** \file include/FLAC++/metadata.h - * - * \brief - * This module provides classes for creating and manipulating FLAC - * metadata blocks in memory, and three progressively more powerful - * interfaces for traversing and editing metadata in FLAC files. - * - * See the detailed documentation for each interface in the - * \link flacpp_metadata metadata \endlink module. - */ - -/** \defgroup flacpp_metadata FLAC++/metadata.h: metadata interfaces - * \ingroup flacpp - * - * \brief - * This module provides classes for creating and manipulating FLAC - * metadata blocks in memory, and three progressively more powerful - * interfaces for traversing and editing metadata in FLAC files. - * - * The behavior closely mimics the C layer interface; be sure to read - * the detailed description of the - * \link flac_metadata C metadata module \endlink. Note that like the - * C layer, currently only the Chain interface (level 2) supports Ogg - * FLAC files, and it is read-only i.e. no writing back changed - * metadata to file. - */ - - -namespace FLAC { - namespace Metadata { - - // ============================================================ - // - // Metadata objects - // - // ============================================================ - - /** \defgroup flacpp_metadata_object FLAC++/metadata.h: metadata object classes - * \ingroup flacpp_metadata - * - * This module contains classes representing FLAC metadata - * blocks in memory. - * - * The behavior closely mimics the C layer interface; be - * sure to read the detailed description of the - * \link flac_metadata_object C metadata object module \endlink. - * - * Any time a metadata object is constructed or assigned, you - * should check is_valid() to make sure the underlying - * ::FLAC__StreamMetadata object was able to be created. - * - * \warning - * When the get_*() methods of any metadata object method - * return you a const pointer, DO NOT disobey and write into it. - * Always use the set_*() methods. - * - * \{ - */ - - /** Base class for all metadata block types. - * See the \link flacpp_metadata_object overview \endlink for more. - */ - class FLACPP_API Prototype { - protected: - //@{ - /** Constructs a copy of the given object. This form - * always performs a deep copy. - */ - Prototype(const Prototype &); - Prototype(const ::FLAC__StreamMetadata &); - Prototype(const ::FLAC__StreamMetadata *); - //@} - - /** Constructs an object with copy control. When \a copy - * is \c true, behaves identically to - * FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object). - * When \a copy is \c false, the instance takes ownership of - * the pointer and the ::FLAC__StreamMetadata object will - * be freed by the destructor. - * - * \assert - * \code object != NULL \endcode - */ - Prototype(::FLAC__StreamMetadata *object, bool copy); - - //@{ - /** Assign from another object. Always performs a deep copy. */ - Prototype &operator=(const Prototype &); - Prototype &operator=(const ::FLAC__StreamMetadata &); - Prototype &operator=(const ::FLAC__StreamMetadata *); - //@} - - /** Assigns an object with copy control. See - * Prototype(::FLAC__StreamMetadata *object, bool copy). - */ - Prototype &assign_object(::FLAC__StreamMetadata *object, bool copy); - - /** Deletes the underlying ::FLAC__StreamMetadata object. - */ - virtual void clear(); - - ::FLAC__StreamMetadata *object_; - public: - /** Deletes the underlying ::FLAC__StreamMetadata object. - */ - virtual ~Prototype(); - - //@{ - /** Check for equality, performing a deep compare by following pointers. - */ - inline bool operator==(const Prototype &) const; - inline bool operator==(const ::FLAC__StreamMetadata &) const; - inline bool operator==(const ::FLAC__StreamMetadata *) const; - //@} - - //@{ - /** Check for inequality, performing a deep compare by following pointers. */ - inline bool operator!=(const Prototype &) const; - inline bool operator!=(const ::FLAC__StreamMetadata &) const; - inline bool operator!=(const ::FLAC__StreamMetadata *) const; - //@} - - friend class SimpleIterator; - friend class Iterator; - - /** Returns \c true if the object was correctly constructed - * (i.e. the underlying ::FLAC__StreamMetadata object was - * properly allocated), else \c false. - */ - inline bool is_valid() const; - - /** Returns \c true if this block is the last block in a - * stream, else \c false. - * - * \assert - * \code is_valid() \endcode - */ - bool get_is_last() const; - - /** Returns the type of the block. - * - * \assert - * \code is_valid() \endcode - */ - ::FLAC__MetadataType get_type() const; - - /** Returns the stream length of the metadata block. - * - * \note - * The length does not include the metadata block header, - * per spec. - * - * \assert - * \code is_valid() \endcode - */ - uint32_t get_length() const; - - /** Sets the "is_last" flag for the block. When using the iterators - * it is not necessary to set this flag; they will do it for you. - * - * \assert - * \code is_valid() \endcode - */ - void set_is_last(bool); - - /** Returns a pointer to the underlying ::FLAC__StreamMetadata - * object. This can be useful for plugging any holes between - * the C++ and C interfaces. - * - * \assert - * \code is_valid() \endcode - */ - inline operator const ::FLAC__StreamMetadata *() const; - private: - /** Private and undefined so you can't use it. */ - Prototype(); - - // These are used only by Iterator - bool is_reference_; - inline void set_reference(bool x) { is_reference_ = x; } - }; - - // local utility routines - - namespace local { - - /** Construct a new object of the type provided in object->type and return it. */ - Prototype *construct_block(::FLAC__StreamMetadata *object); - - } - -#ifdef _MSC_VER -// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) -#pragma warning ( disable : 4800 ) -#endif - - inline bool Prototype::operator==(const Prototype &object) const - { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); } - - inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const - { return (bool)::FLAC__metadata_object_is_equal(object_, &object); } - - inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const - { return (bool)::FLAC__metadata_object_is_equal(object_, object); } - -#ifdef _MSC_VER -#pragma warning ( default : 4800 ) -#endif - - inline bool Prototype::operator!=(const Prototype &object) const - { return !operator==(object); } - - inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const - { return !operator==(object); } - - inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const - { return !operator==(object); } - - inline bool Prototype::is_valid() const - { return 0 != object_; } - - inline Prototype::operator const ::FLAC__StreamMetadata *() const - { return object_; } - - /** Create a deep copy of an object and return it. */ - FLACPP_API Prototype *clone(const Prototype *); - - - /** STREAMINFO metadata block. - * See the \link flacpp_metadata_object overview \endlink for more, - * and the format specification. - */ - class FLACPP_API StreamInfo : public Prototype { - public: - StreamInfo(); - - //@{ - /** Constructs a copy of the given object. This form - * always performs a deep copy. - */ - inline StreamInfo(const StreamInfo &object): Prototype(object) { } - inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { } - inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { } - //@} - - /** Constructs an object with copy control. See - * Prototype(::FLAC__StreamMetadata *object, bool copy). - */ - inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } - - ~StreamInfo(); - - //@{ - /** Assign from another object. Always performs a deep copy. */ - inline StreamInfo &operator=(const StreamInfo &object) { Prototype::operator=(object); return *this; } - inline StreamInfo &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } - inline StreamInfo &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } - //@} - - /** Assigns an object with copy control. See - * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). - */ - inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } - - //@{ - /** Check for equality, performing a deep compare by following pointers. */ - inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } - //@} - - //@{ - /** Check for inequality, performing a deep compare by following pointers. */ - inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } - //@} - - //@{ - /** See format specification. */ - uint32_t get_min_blocksize() const; - uint32_t get_max_blocksize() const; - uint32_t get_min_framesize() const; - uint32_t get_max_framesize() const; - uint32_t get_sample_rate() const; - uint32_t get_channels() const; - uint32_t get_bits_per_sample() const; - FLAC__uint64 get_total_samples() const; - const FLAC__byte *get_md5sum() const; - - void set_min_blocksize(uint32_t value); - void set_max_blocksize(uint32_t value); - void set_min_framesize(uint32_t value); - void set_max_framesize(uint32_t value); - void set_sample_rate(uint32_t value); - void set_channels(uint32_t value); - void set_bits_per_sample(uint32_t value); - void set_total_samples(FLAC__uint64 value); - void set_md5sum(const FLAC__byte value[16]); - //@} - }; - - /** PADDING metadata block. - * See the \link flacpp_metadata_object overview \endlink for more, - * and the format specification. - */ - class FLACPP_API Padding : public Prototype { - public: - Padding(); - - //@{ - /** Constructs a copy of the given object. This form - * always performs a deep copy. - */ - inline Padding(const Padding &object): Prototype(object) { } - inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { } - inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { } - //@} - - /** Constructs an object with copy control. See - * Prototype(::FLAC__StreamMetadata *object, bool copy). - */ - inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } - - /** Constructs an object with the given length. - */ - Padding(uint32_t length); - - ~Padding(); - - //@{ - /** Assign from another object. Always performs a deep copy. */ - inline Padding &operator=(const Padding &object) { Prototype::operator=(object); return *this; } - inline Padding &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } - inline Padding &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } - //@} - - /** Assigns an object with copy control. See - * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). - */ - inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } - - //@{ - /** Check for equality, performing a deep compare by following pointers. */ - inline bool operator==(const Padding &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } - //@} - - //@{ - /** Check for inequality, performing a deep compare by following pointers. */ - inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } - //@} - - /** Sets the length in bytes of the padding block. - */ - void set_length(uint32_t length); - }; - - /** APPLICATION metadata block. - * See the \link flacpp_metadata_object overview \endlink for more, - * and the format specification. - */ - class FLACPP_API Application : public Prototype { - public: - Application(); - // - //@{ - /** Constructs a copy of the given object. This form - * always performs a deep copy. - */ - inline Application(const Application &object): Prototype(object) { } - inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { } - inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { } - //@} - - /** Constructs an object with copy control. See - * Prototype(::FLAC__StreamMetadata *object, bool copy). - */ - inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } - - ~Application(); - - //@{ - /** Assign from another object. Always performs a deep copy. */ - inline Application &operator=(const Application &object) { Prototype::operator=(object); return *this; } - inline Application &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } - inline Application &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } - //@} - - /** Assigns an object with copy control. See - * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). - */ - inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } - - //@{ - /** Check for equality, performing a deep compare by following pointers. */ - inline bool operator==(const Application &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } - //@} - - //@{ - /** Check for inequality, performing a deep compare by following pointers. */ - inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } - //@} - - const FLAC__byte *get_id() const; - const FLAC__byte *get_data() const; - - void set_id(const FLAC__byte value[4]); - //! This form always copies \a data - bool set_data(const FLAC__byte *data, uint32_t length); - bool set_data(FLAC__byte *data, uint32_t length, bool copy); - }; - - /** SEEKTABLE metadata block. - * See the \link flacpp_metadata_object overview \endlink for more, - * and the format specification. - */ - class FLACPP_API SeekTable : public Prototype { - public: - SeekTable(); - - //@{ - /** Constructs a copy of the given object. This form - * always performs a deep copy. - */ - inline SeekTable(const SeekTable &object): Prototype(object) { } - inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { } - inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { } - //@} - - /** Constructs an object with copy control. See - * Prototype(::FLAC__StreamMetadata *object, bool copy). - */ - inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } - - ~SeekTable(); - - //@{ - /** Assign from another object. Always performs a deep copy. */ - inline SeekTable &operator=(const SeekTable &object) { Prototype::operator=(object); return *this; } - inline SeekTable &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } - inline SeekTable &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } - //@} - - /** Assigns an object with copy control. See - * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). - */ - inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } - - //@{ - /** Check for equality, performing a deep compare by following pointers. */ - inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } - //@} - - //@{ - /** Check for inequality, performing a deep compare by following pointers. */ - inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } - //@} - - uint32_t get_num_points() const; - ::FLAC__StreamMetadata_SeekPoint get_point(uint32_t index) const; - - //! See FLAC__metadata_object_seektable_resize_points() - bool resize_points(uint32_t new_num_points); - - //! See FLAC__metadata_object_seektable_set_point() - void set_point(uint32_t index, const ::FLAC__StreamMetadata_SeekPoint &point); - - //! See FLAC__metadata_object_seektable_insert_point() - bool insert_point(uint32_t index, const ::FLAC__StreamMetadata_SeekPoint &point); - - //! See FLAC__metadata_object_seektable_delete_point() - bool delete_point(uint32_t index); - - //! See FLAC__metadata_object_seektable_is_legal() - bool is_legal() const; - - //! See FLAC__metadata_object_seektable_template_append_placeholders() - bool template_append_placeholders(uint32_t num); - - //! See FLAC__metadata_object_seektable_template_append_point() - bool template_append_point(FLAC__uint64 sample_number); - - //! See FLAC__metadata_object_seektable_template_append_points() - bool template_append_points(FLAC__uint64 sample_numbers[], uint32_t num); - - //! See FLAC__metadata_object_seektable_template_append_spaced_points() - bool template_append_spaced_points(uint32_t num, FLAC__uint64 total_samples); - - //! See FLAC__metadata_object_seektable_template_append_spaced_points_by_samples() - bool template_append_spaced_points_by_samples(uint32_t samples, FLAC__uint64 total_samples); - - //! See FLAC__metadata_object_seektable_template_sort() - bool template_sort(bool compact); - }; - - /** VORBIS_COMMENT metadata block. - * See the \link flacpp_metadata_object overview \endlink for more, - * and the format specification. - */ - class FLACPP_API VorbisComment : public Prototype { - public: - /** Convenience class for encapsulating Vorbis comment - * entries. An entry is a vendor string or a comment - * field. In the case of a vendor string, the field - * name is undefined; only the field value is relevant. - * - * A \a field as used in the methods refers to an - * entire 'NAME=VALUE' string; for convenience the - * string is NUL-terminated. A length field is - * required in the unlikely event that the value - * contains contain embedded NULs. - * - * A \a field_name is what is on the left side of the - * first '=' in the \a field. By definition it is ASCII - * and so is NUL-terminated and does not require a - * length to describe it. \a field_name is undefined - * for a vendor string entry. - * - * A \a field_value is what is on the right side of the - * first '=' in the \a field. By definition, this may - * contain embedded NULs and so a \a field_value_length - * is required to describe it. However in practice, - * embedded NULs are not known to be used, so it is - * generally safe to treat field values as NUL- - * terminated UTF-8 strings. - * - * Always check is_valid() after the constructor or operator= - * to make sure memory was properly allocated and that the - * Entry conforms to the Vorbis comment specification. - */ - class FLACPP_API Entry { - public: - Entry(); - - Entry(const char *field, uint32_t field_length); - Entry(const char *field); // assumes \a field is NUL-terminated - - Entry(const char *field_name, const char *field_value, uint32_t field_value_length); - Entry(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated - - Entry(const Entry &entry); - - Entry &operator=(const Entry &entry); - - virtual ~Entry(); - - virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed. - - uint32_t get_field_length() const; - uint32_t get_field_name_length() const; - uint32_t get_field_value_length() const; - - ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const; - const char *get_field() const; - const char *get_field_name() const; - const char *get_field_value() const; - - bool set_field(const char *field, uint32_t field_length); - bool set_field(const char *field); // assumes \a field is NUL-terminated - bool set_field_name(const char *field_name); - bool set_field_value(const char *field_value, uint32_t field_value_length); - bool set_field_value(const char *field_value); // assumes \a field_value is NUL-terminated - protected: - bool is_valid_; - ::FLAC__StreamMetadata_VorbisComment_Entry entry_; - char *field_name_; - uint32_t field_name_length_; - char *field_value_; - uint32_t field_value_length_; - private: - void zero(); - void clear(); - void clear_entry(); - void clear_field_name(); - void clear_field_value(); - void construct(const char *field, uint32_t field_length); - void construct(const char *field); // assumes \a field is NUL-terminated - void construct(const char *field_name, const char *field_value, uint32_t field_value_length); - void construct(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated - void compose_field(); - void parse_field(); - }; - - VorbisComment(); - - //@{ - /** Constructs a copy of the given object. This form - * always performs a deep copy. - */ - inline VorbisComment(const VorbisComment &object): Prototype(object) { } - inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { } - inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { } - //@} - - /** Constructs an object with copy control. See - * Prototype(::FLAC__StreamMetadata *object, bool copy). - */ - inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } - - ~VorbisComment(); - - //@{ - /** Assign from another object. Always performs a deep copy. */ - inline VorbisComment &operator=(const VorbisComment &object) { Prototype::operator=(object); return *this; } - inline VorbisComment &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } - inline VorbisComment &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } - //@} - - /** Assigns an object with copy control. See - * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). - */ - inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } - - //@{ - /** Check for equality, performing a deep compare by following pointers. */ - inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } - //@} - - //@{ - /** Check for inequality, performing a deep compare by following pointers. */ - inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } - //@} - - uint32_t get_num_comments() const; - const FLAC__byte *get_vendor_string() const; // NUL-terminated UTF-8 string - Entry get_comment(uint32_t index) const; - - //! See FLAC__metadata_object_vorbiscomment_set_vendor_string() - bool set_vendor_string(const FLAC__byte *string); // NUL-terminated UTF-8 string - - //! See FLAC__metadata_object_vorbiscomment_resize_comments() - bool resize_comments(uint32_t new_num_comments); - - //! See FLAC__metadata_object_vorbiscomment_set_comment() - bool set_comment(uint32_t index, const Entry &entry); - - //! See FLAC__metadata_object_vorbiscomment_insert_comment() - bool insert_comment(uint32_t index, const Entry &entry); - - //! See FLAC__metadata_object_vorbiscomment_append_comment() - bool append_comment(const Entry &entry); - - //! See FLAC__metadata_object_vorbiscomment_replace_comment() - bool replace_comment(const Entry &entry, bool all); - - //! See FLAC__metadata_object_vorbiscomment_delete_comment() - bool delete_comment(uint32_t index); - - //! See FLAC__metadata_object_vorbiscomment_find_entry_from() - int find_entry_from(uint32_t offset, const char *field_name); - - //! See FLAC__metadata_object_vorbiscomment_remove_entry_matching() - int remove_entry_matching(const char *field_name); - - //! See FLAC__metadata_object_vorbiscomment_remove_entries_matching() - int remove_entries_matching(const char *field_name); - }; - - /** CUESHEET metadata block. - * See the \link flacpp_metadata_object overview \endlink for more, - * and the format specification. - */ - class FLACPP_API CueSheet : public Prototype { - public: - /** Convenience class for encapsulating a cue sheet - * track. - * - * Always check is_valid() after the constructor or operator= - * to make sure memory was properly allocated. - */ - class FLACPP_API Track { - protected: - ::FLAC__StreamMetadata_CueSheet_Track *object_; - public: - Track(); - Track(const ::FLAC__StreamMetadata_CueSheet_Track *track); - Track(const Track &track); - Track &operator=(const Track &track); - - virtual ~Track(); - - virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed. - - - inline FLAC__uint64 get_offset() const { return object_->offset; } - inline FLAC__byte get_number() const { return object_->number; } - inline const char *get_isrc() const { return object_->isrc; } - inline uint32_t get_type() const { return object_->type; } - inline bool get_pre_emphasis() const { return object_->pre_emphasis; } - - inline FLAC__byte get_num_indices() const { return object_->num_indices; } - ::FLAC__StreamMetadata_CueSheet_Index get_index(uint32_t i) const; - - inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; } - - inline void set_offset(FLAC__uint64 value) { object_->offset = value; } - inline void set_number(FLAC__byte value) { object_->number = value; } - void set_isrc(const char value[12]); - void set_type(uint32_t value); - inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; } - - void set_index(uint32_t i, const ::FLAC__StreamMetadata_CueSheet_Index &index); - //@@@ It's awkward but to insert/delete index points - //@@@ you must use the routines in the CueSheet class. - }; - - CueSheet(); - - //@{ - /** Constructs a copy of the given object. This form - * always performs a deep copy. - */ - inline CueSheet(const CueSheet &object): Prototype(object) { } - inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { } - inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { } - //@} - - /** Constructs an object with copy control. See - * Prototype(::FLAC__StreamMetadata *object, bool copy). - */ - inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } - - ~CueSheet(); - - //@{ - /** Assign from another object. Always performs a deep copy. */ - inline CueSheet &operator=(const CueSheet &object) { Prototype::operator=(object); return *this; } - inline CueSheet &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } - inline CueSheet &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } - //@} - - /** Assigns an object with copy control. See - * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). - */ - inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } - - //@{ - /** Check for equality, performing a deep compare by following pointers. */ - inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } - //@} - - //@{ - /** Check for inequality, performing a deep compare by following pointers. */ - inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } - //@} - - const char *get_media_catalog_number() const; - FLAC__uint64 get_lead_in() const; - bool get_is_cd() const; - - uint32_t get_num_tracks() const; - Track get_track(uint32_t i) const; - - void set_media_catalog_number(const char value[128]); - void set_lead_in(FLAC__uint64 value); - void set_is_cd(bool value); - - void set_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); - - //! See FLAC__metadata_object_cuesheet_track_resize_indices() - bool resize_indices(uint32_t track_num, uint32_t new_num_indices); - - //! See FLAC__metadata_object_cuesheet_track_insert_index() - bool insert_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); - - //! See FLAC__metadata_object_cuesheet_track_insert_blank_index() - bool insert_blank_index(uint32_t track_num, uint32_t index_num); - - //! See FLAC__metadata_object_cuesheet_track_delete_index() - bool delete_index(uint32_t track_num, uint32_t index_num); - - //! See FLAC__metadata_object_cuesheet_resize_tracks() - bool resize_tracks(uint32_t new_num_tracks); - - //! See FLAC__metadata_object_cuesheet_set_track() - bool set_track(uint32_t i, const Track &track); - - //! See FLAC__metadata_object_cuesheet_insert_track() - bool insert_track(uint32_t i, const Track &track); - - //! See FLAC__metadata_object_cuesheet_insert_blank_track() - bool insert_blank_track(uint32_t i); - - //! See FLAC__metadata_object_cuesheet_delete_track() - bool delete_track(uint32_t i); - - //! See FLAC__metadata_object_cuesheet_is_legal() - bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const; - - //! See FLAC__metadata_object_cuesheet_calculate_cddb_id() - FLAC__uint32 calculate_cddb_id() const; - }; - - /** PICTURE metadata block. - * See the \link flacpp_metadata_object overview \endlink for more, - * and the format specification. - */ - class FLACPP_API Picture : public Prototype { - public: - Picture(); - - //@{ - /** Constructs a copy of the given object. This form - * always performs a deep copy. - */ - inline Picture(const Picture &object): Prototype(object) { } - inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { } - inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { } - //@} - - /** Constructs an object with copy control. See - * Prototype(::FLAC__StreamMetadata *object, bool copy). - */ - inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } - - ~Picture(); - - //@{ - /** Assign from another object. Always performs a deep copy. */ - inline Picture &operator=(const Picture &object) { Prototype::operator=(object); return *this; } - inline Picture &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } - inline Picture &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } - //@} - - /** Assigns an object with copy control. See - * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). - */ - inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } - - //@{ - /** Check for equality, performing a deep compare by following pointers. */ - inline bool operator==(const Picture &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } - //@} - - //@{ - /** Check for inequality, performing a deep compare by following pointers. */ - inline bool operator!=(const Picture &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } - //@} - - ::FLAC__StreamMetadata_Picture_Type get_type() const; - const char *get_mime_type() const; // NUL-terminated printable ASCII string - const FLAC__byte *get_description() const; // NUL-terminated UTF-8 string - FLAC__uint32 get_width() const; - FLAC__uint32 get_height() const; - FLAC__uint32 get_depth() const; - FLAC__uint32 get_colors() const; ///< a return value of \c 0 means true-color, i.e. 2^depth colors - FLAC__uint32 get_data_length() const; - const FLAC__byte *get_data() const; - - void set_type(::FLAC__StreamMetadata_Picture_Type type); - - //! See FLAC__metadata_object_picture_set_mime_type() - bool set_mime_type(const char *string); // NUL-terminated printable ASCII string - - //! See FLAC__metadata_object_picture_set_description() - bool set_description(const FLAC__byte *string); // NUL-terminated UTF-8 string - - void set_width(FLAC__uint32 value) const; - void set_height(FLAC__uint32 value) const; - void set_depth(FLAC__uint32 value) const; - void set_colors(FLAC__uint32 value) const; ///< a value of \c 0 means true-color, i.e. 2^depth colors - - //! See FLAC__metadata_object_picture_set_data() - bool set_data(const FLAC__byte *data, FLAC__uint32 data_length); - - //! See FLAC__metadata_object_picture_is_legal() - bool is_legal(const char **violation); - }; - - /** Opaque metadata block for storing unknown types. - * This should not be used unless you know what you are doing; - * it is currently used only internally to support forward - * compatibility of metadata blocks. - * See the \link flacpp_metadata_object overview \endlink for more, - */ - class FLACPP_API Unknown : public Prototype { - public: - Unknown(); - // - //@{ - /** Constructs a copy of the given object. This form - * always performs a deep copy. - */ - inline Unknown(const Unknown &object): Prototype(object) { } - inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { } - inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { } - //@} - - /** Constructs an object with copy control. See - * Prototype(::FLAC__StreamMetadata *object, bool copy). - */ - inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } - - ~Unknown(); - - //@{ - /** Assign from another object. Always performs a deep copy. */ - inline Unknown &operator=(const Unknown &object) { Prototype::operator=(object); return *this; } - inline Unknown &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } - inline Unknown &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } - //@} - - /** Assigns an object with copy control. See - * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). - */ - inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } - - //@{ - /** Check for equality, performing a deep compare by following pointers. */ - inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } - inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } - //@} - - //@{ - /** Check for inequality, performing a deep compare by following pointers. */ - inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } - inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } - //@} - - const FLAC__byte *get_data() const; - - //! This form always copies \a data - bool set_data(const FLAC__byte *data, uint32_t length); - bool set_data(FLAC__byte *data, uint32_t length, bool copy); - }; - - /* \} */ - - - /** \defgroup flacpp_metadata_level0 FLAC++/metadata.h: metadata level 0 interface - * \ingroup flacpp_metadata - * - * \brief - * Level 0 metadata iterators. - * - * See the \link flac_metadata_level0 C layer equivalent \endlink - * for more. - * - * \{ - */ - - FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo); ///< See FLAC__metadata_get_streaminfo(). - - FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags); ///< See FLAC__metadata_get_tags(). - FLACPP_API bool get_tags(const char *filename, VorbisComment &tags); ///< See FLAC__metadata_get_tags(). - - FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet); ///< See FLAC__metadata_get_cuesheet(). - FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet); ///< See FLAC__metadata_get_cuesheet(). - - FLACPP_API bool get_picture(const char *filename, Picture *&picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors); ///< See FLAC__metadata_get_picture(). - FLACPP_API bool get_picture(const char *filename, Picture &picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors); ///< See FLAC__metadata_get_picture(). - - /* \} */ - - - /** \defgroup flacpp_metadata_level1 FLAC++/metadata.h: metadata level 1 interface - * \ingroup flacpp_metadata - * - * \brief - * Level 1 metadata iterator. - * - * The flow through the iterator in the C++ layer is similar - * to the C layer: - * - Create a SimpleIterator instance - * - Check SimpleIterator::is_valid() - * - Call SimpleIterator::init() and check the return - * - Traverse and/or edit. Edits are written to file - * immediately. - * - Destroy the SimpleIterator instance - * - * The ownership of pointers in the C++ layer follows that in - * the C layer, i.e. - * - The objects returned by get_block() are yours to - * modify, but changes are not reflected in the FLAC file - * until you call set_block(). The objects are also - * yours to delete; they are not automatically deleted - * when passed to set_block() or insert_block_after(). - * - * See the \link flac_metadata_level1 C layer equivalent \endlink - * for more. - * - * \{ - */ - - /** This class is a wrapper around the FLAC__metadata_simple_iterator - * structures and methods; see the - * \link flacpp_metadata_level1 usage guide \endlink and - * ::FLAC__Metadata_SimpleIterator. - */ - class FLACPP_API SimpleIterator { - public: - /** This class is a wrapper around FLAC__Metadata_SimpleIteratorStatus. - */ - class FLACPP_API Status { - public: - inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { } - inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; } - inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; } - protected: - ::FLAC__Metadata_SimpleIteratorStatus status_; - }; - - SimpleIterator(); - virtual ~SimpleIterator(); - - bool is_valid() const; ///< Returns \c true iff object was properly constructed. - - bool init(const char *filename, bool read_only, bool preserve_file_stats); ///< See FLAC__metadata_simple_iterator_init(). - - Status status(); ///< See FLAC__metadata_simple_iterator_status(). - bool is_writable() const; ///< See FLAC__metadata_simple_iterator_is_writable(). - - bool next(); ///< See FLAC__metadata_simple_iterator_next(). - bool prev(); ///< See FLAC__metadata_simple_iterator_prev(). - bool is_last() const; ///< See FLAC__metadata_simple_iterator_is_last(). - - off_t get_block_offset() const; ///< See FLAC__metadata_simple_iterator_get_block_offset(). - ::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_simple_iterator_get_block_type(). - uint32_t get_block_length() const; ///< See FLAC__metadata_simple_iterator_get_block_length(). - bool get_application_id(FLAC__byte *id); ///< See FLAC__metadata_simple_iterator_get_application_id(). - Prototype *get_block(); ///< See FLAC__metadata_simple_iterator_get_block(). - bool set_block(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_set_block(). - bool insert_block_after(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_insert_block_after(). - bool delete_block(bool use_padding = true); ///< See FLAC__metadata_simple_iterator_delete_block(). - - protected: - ::FLAC__Metadata_SimpleIterator *iterator_; - void clear(); - - private: // Do not use. - SimpleIterator(const SimpleIterator&); - SimpleIterator&operator=(const SimpleIterator&); - }; - - /* \} */ - - - /** \defgroup flacpp_metadata_level2 FLAC++/metadata.h: metadata level 2 interface - * \ingroup flacpp_metadata - * - * \brief - * Level 2 metadata iterator. - * - * The flow through the iterator in the C++ layer is similar - * to the C layer: - * - Create a Chain instance - * - Check Chain::is_valid() - * - Call Chain::read() and check the return - * - Traverse and/or edit with an Iterator or with - * Chain::merge_padding() or Chain::sort_padding() - * - Write changes back to FLAC file with Chain::write() - * - Destroy the Chain instance - * - * The ownership of pointers in the C++ layer is slightly - * different than in the C layer, i.e. - * - The objects returned by Iterator::get_block() are NOT - * owned by the iterator and should be deleted by the - * caller when finished, BUT, when you modify the block, - * it will directly edit what's in the chain and you do - * not need to call Iterator::set_block(). However the - * changes will not be reflected in the FLAC file until - * the chain is written with Chain::write(). - * - When you pass an object to Iterator::set_block(), - * Iterator::insert_block_before(), or - * Iterator::insert_block_after(), the iterator takes - * ownership of the block and it will be deleted by the - * chain. - * - * See the \link flac_metadata_level2 C layer equivalent \endlink - * for more. - * - * \{ - */ - - /** This class is a wrapper around the FLAC__metadata_chain - * structures and methods; see the - * \link flacpp_metadata_level2 usage guide \endlink and - * ::FLAC__Metadata_Chain. - */ - class FLACPP_API Chain { - public: - /** This class is a wrapper around FLAC__Metadata_ChainStatus. - */ - class FLACPP_API Status { - public: - inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { } - inline operator ::FLAC__Metadata_ChainStatus() const { return status_; } - inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; } - protected: - ::FLAC__Metadata_ChainStatus status_; - }; - - Chain(); - virtual ~Chain(); - - friend class Iterator; - - bool is_valid() const; ///< Returns \c true iff object was properly constructed. - - Status status(); ///< See FLAC__metadata_chain_status(). - - bool read(const char *filename, bool is_ogg = false); ///< See FLAC__metadata_chain_read(), FLAC__metadata_chain_read_ogg(). - bool read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, bool is_ogg = false); ///< See FLAC__metadata_chain_read_with_callbacks(), FLAC__metadata_chain_read_ogg_with_callbacks(). - - bool check_if_tempfile_needed(bool use_padding); ///< See FLAC__metadata_chain_check_if_tempfile_needed(). - - bool write(bool use_padding = true, bool preserve_file_stats = false); ///< See FLAC__metadata_chain_write(). - bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks); ///< See FLAC__metadata_chain_write_with_callbacks(). - bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks); ///< See FLAC__metadata_chain_write_with_callbacks_and_tempfile(). - - void merge_padding(); ///< See FLAC__metadata_chain_merge_padding(). - void sort_padding(); ///< See FLAC__metadata_chain_sort_padding(). - - protected: - ::FLAC__Metadata_Chain *chain_; - virtual void clear(); - - private: // Do not use. - Chain(const Chain&); - Chain&operator=(const Chain&); - }; - - /** This class is a wrapper around the FLAC__metadata_iterator - * structures and methods; see the - * \link flacpp_metadata_level2 usage guide \endlink and - * ::FLAC__Metadata_Iterator. - */ - class FLACPP_API Iterator { - public: - Iterator(); - virtual ~Iterator(); - - bool is_valid() const; ///< Returns \c true iff object was properly constructed. - - - void init(Chain &chain); ///< See FLAC__metadata_iterator_init(). - - bool next(); ///< See FLAC__metadata_iterator_next(). - bool prev(); ///< See FLAC__metadata_iterator_prev(). - - ::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_iterator_get_block_type(). - Prototype *get_block(); ///< See FLAC__metadata_iterator_get_block(). - bool set_block(Prototype *block); ///< See FLAC__metadata_iterator_set_block(). - bool delete_block(bool replace_with_padding); ///< See FLAC__metadata_iterator_delete_block(). - bool insert_block_before(Prototype *block); ///< See FLAC__metadata_iterator_insert_block_before(). - bool insert_block_after(Prototype *block); ///< See FLAC__metadata_iterator_insert_block_after(). - - protected: - ::FLAC__Metadata_Iterator *iterator_; - virtual void clear(); - - private: // Do not use. - Iterator(const Iterator&); - Iterator&operator=(const Iterator&); - }; - - /* \} */ - - } -} - -#endif diff --git a/Engine/lib/flac/include/FLAC/Makefile.am b/Engine/lib/flac/include/FLAC/Makefile.am deleted file mode 100644 index 80ded6190..000000000 --- a/Engine/lib/flac/include/FLAC/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -# libFLAC - Free Lossless Audio Codec library -# Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# 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 the Xiph.org Foundation nor the names of its -# 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 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. - -flaccincludedir = $(includedir)/FLAC - -flaccinclude_HEADERS = \ - all.h \ - assert.h \ - callback.h \ - export.h \ - format.h \ - metadata.h \ - ordinals.h \ - stream_decoder.h \ - stream_encoder.h diff --git a/Engine/lib/flac/include/FLAC/all.h b/Engine/lib/flac/include/FLAC/all.h deleted file mode 100644 index 277dcbc52..000000000 --- a/Engine/lib/flac/include/FLAC/all.h +++ /dev/null @@ -1,450 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__ALL_H -#define FLAC__ALL_H - -#include "export.h" - -#include "assert.h" -#include "callback.h" -#include "format.h" -#include "metadata.h" -#include "ordinals.h" -#include "stream_decoder.h" -#include "stream_encoder.h" - -/** \mainpage - * - * \section intro Introduction - * - * This is the documentation for the FLAC C and C++ APIs. It is - * highly interconnected; this introduction should give you a top - * level idea of the structure and how to find the information you - * need. As a prerequisite you should have at least a basic - * knowledge of the FLAC format, documented - * here. - * - * \section c_api FLAC C API - * - * The FLAC C API is the interface to libFLAC, a set of structures - * describing the components of FLAC streams, and functions for - * encoding and decoding streams, as well as manipulating FLAC - * metadata in files. The public include files will be installed - * in your include area (for example /usr/include/FLAC/...). - * - * By writing a little code and linking against libFLAC, it is - * relatively easy to add FLAC support to another program. The - * library is licensed under Xiph's BSD license. - * Complete source code of libFLAC as well as the command-line - * encoder and plugins is available and is a useful source of - * examples. - * - * Aside from encoders and decoders, libFLAC provides a powerful - * metadata interface for manipulating metadata in FLAC files. It - * allows the user to add, delete, and modify FLAC metadata blocks - * and it can automatically take advantage of PADDING blocks to avoid - * rewriting the entire FLAC file when changing the size of the - * metadata. - * - * libFLAC usually only requires the standard C library and C math - * library. In particular, threading is not used so there is no - * dependency on a thread library. However, libFLAC does not use - * global variables and should be thread-safe. - * - * libFLAC also supports encoding to and decoding from Ogg FLAC. - * However the metadata editing interfaces currently have limited - * read-only support for Ogg FLAC files. - * - * \section cpp_api FLAC C++ API - * - * The FLAC C++ API is a set of classes that encapsulate the - * structures and functions in libFLAC. They provide slightly more - * functionality with respect to metadata but are otherwise - * equivalent. For the most part, they share the same usage as - * their counterparts in libFLAC, and the FLAC C API documentation - * can be used as a supplement. The public include files - * for the C++ API will be installed in your include area (for - * example /usr/include/FLAC++/...). - * - * libFLAC++ is also licensed under - * Xiph's BSD license. - * - * \section getting_started Getting Started - * - * A good starting point for learning the API is to browse through - * the modules. Modules are logical - * groupings of related functions or classes, which correspond roughly - * to header files or sections of header files. Each module includes a - * detailed description of the general usage of its functions or - * classes. - * - * From there you can go on to look at the documentation of - * individual functions. You can see different views of the individual - * functions through the links in top bar across this page. - * - * If you prefer a more hands-on approach, you can jump right to some - * example code. - * - * \section porting_guide Porting Guide - * - * Starting with FLAC 1.1.3 a \link porting Porting Guide \endlink - * has been introduced which gives detailed instructions on how to - * port your code to newer versions of FLAC. - * - * \section embedded_developers Embedded Developers - * - * libFLAC has grown larger over time as more functionality has been - * included, but much of it may be unnecessary for a particular embedded - * implementation. Unused parts may be pruned by some simple editing of - * src/libFLAC/Makefile.am. In general, the decoders, encoders, and - * metadata interface are all independent from each other. - * - * It is easiest to just describe the dependencies: - * - * - All modules depend on the \link flac_format Format \endlink module. - * - The decoders and encoders depend on the bitbuffer. - * - The decoder is independent of the encoder. The encoder uses the - * decoder because of the verify feature, but this can be removed if - * not needed. - * - Parts of the metadata interface require the stream decoder (but not - * the encoder). - * - Ogg support is selectable through the compile time macro - * \c FLAC__HAS_OGG. - * - * For example, if your application only requires the stream decoder, no - * encoder, and no metadata interface, you can remove the stream encoder - * and the metadata interface, which will greatly reduce the size of the - * library. - * - * Also, there are several places in the libFLAC code with comments marked - * with "OPT:" where a \#define can be changed to enable code that might be - * faster on a specific platform. Experimenting with these can yield faster - * binaries. - */ - -/** \defgroup porting Porting Guide for New Versions - * - * This module describes differences in the library interfaces from - * version to version. It assists in the porting of code that uses - * the libraries to newer versions of FLAC. - * - * One simple facility for making porting easier that has been added - * in FLAC 1.1.3 is a set of \#defines in \c export.h of each - * library's includes (e.g. \c include/FLAC/export.h). The - * \#defines mirror the libraries' - * libtool version numbers, - * e.g. in libFLAC there are \c FLAC_API_VERSION_CURRENT, - * \c FLAC_API_VERSION_REVISION, and \c FLAC_API_VERSION_AGE. - * These can be used to support multiple versions of an API during the - * transition phase, e.g. - * - * \code - * #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 - * legacy code - * #else - * new code - * #endif - * \endcode - * - * The source will work for multiple versions and the legacy code can - * easily be removed when the transition is complete. - * - * Another available symbol is FLAC_API_SUPPORTS_OGG_FLAC (defined in - * include/FLAC/export.h), which can be used to determine whether or not - * the library has been compiled with support for Ogg FLAC. This is - * simpler than trying to call an Ogg init function and catching the - * error. - */ - -/** \defgroup porting_1_1_2_to_1_1_3 Porting from FLAC 1.1.2 to 1.1.3 - * \ingroup porting - * - * \brief - * This module describes porting from FLAC 1.1.2 to FLAC 1.1.3. - * - * The main change between the APIs in 1.1.2 and 1.1.3 is that they have - * been simplified. First, libOggFLAC has been merged into libFLAC and - * libOggFLAC++ has been merged into libFLAC++. Second, both the three - * decoding layers and three encoding layers have been merged into a - * single stream decoder and stream encoder. That is, the functionality - * of FLAC__SeekableStreamDecoder and FLAC__FileDecoder has been merged - * into FLAC__StreamDecoder, and FLAC__SeekableStreamEncoder and - * FLAC__FileEncoder into FLAC__StreamEncoder. Only the - * FLAC__StreamDecoder and FLAC__StreamEncoder remain. What this means - * is there is now a single API that can be used to encode or decode - * streams to/from native FLAC or Ogg FLAC and the single API can work - * on both seekable and non-seekable streams. - * - * Instead of creating an encoder or decoder of a certain layer, now the - * client will always create a FLAC__StreamEncoder or - * FLAC__StreamDecoder. The old layers are now differentiated by the - * initialization function. For example, for the decoder, - * FLAC__stream_decoder_init() has been replaced by - * FLAC__stream_decoder_init_stream(). This init function takes - * callbacks for the I/O, and the seeking callbacks are optional. This - * allows the client to use the same object for seekable and - * non-seekable streams. For decoding a FLAC file directly, the client - * can use FLAC__stream_decoder_init_file() and pass just a filename - * and fewer callbacks; most of the other callbacks are supplied - * internally. For situations where fopen()ing by filename is not - * possible (e.g. Unicode filenames on Windows) the client can instead - * open the file itself and supply the FILE* to - * FLAC__stream_decoder_init_FILE(). The init functions now returns a - * FLAC__StreamDecoderInitStatus instead of FLAC__StreamDecoderState. - * Since the callbacks and client data are now passed to the init - * function, the FLAC__stream_decoder_set_*_callback() functions and - * FLAC__stream_decoder_set_client_data() are no longer needed. The - * rest of the calls to the decoder are the same as before. - * - * There are counterpart init functions for Ogg FLAC, e.g. - * FLAC__stream_decoder_init_ogg_stream(). All the rest of the calls - * and callbacks are the same as for native FLAC. - * - * As an example, in FLAC 1.1.2 a seekable stream decoder would have - * been set up like so: - * - * \code - * FLAC__SeekableStreamDecoder *decoder = FLAC__seekable_stream_decoder_new(); - * if(decoder == NULL) do_something; - * FLAC__seekable_stream_decoder_set_md5_checking(decoder, true); - * [... other settings ...] - * FLAC__seekable_stream_decoder_set_read_callback(decoder, my_read_callback); - * FLAC__seekable_stream_decoder_set_seek_callback(decoder, my_seek_callback); - * FLAC__seekable_stream_decoder_set_tell_callback(decoder, my_tell_callback); - * FLAC__seekable_stream_decoder_set_length_callback(decoder, my_length_callback); - * FLAC__seekable_stream_decoder_set_eof_callback(decoder, my_eof_callback); - * FLAC__seekable_stream_decoder_set_write_callback(decoder, my_write_callback); - * FLAC__seekable_stream_decoder_set_metadata_callback(decoder, my_metadata_callback); - * FLAC__seekable_stream_decoder_set_error_callback(decoder, my_error_callback); - * FLAC__seekable_stream_decoder_set_client_data(decoder, my_client_data); - * if(FLAC__seekable_stream_decoder_init(decoder) != FLAC__SEEKABLE_STREAM_DECODER_OK) do_something; - * \endcode - * - * In FLAC 1.1.3 it is like this: - * - * \code - * FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new(); - * if(decoder == NULL) do_something; - * FLAC__stream_decoder_set_md5_checking(decoder, true); - * [... other settings ...] - * if(FLAC__stream_decoder_init_stream( - * decoder, - * my_read_callback, - * my_seek_callback, // or NULL - * my_tell_callback, // or NULL - * my_length_callback, // or NULL - * my_eof_callback, // or NULL - * my_write_callback, - * my_metadata_callback, // or NULL - * my_error_callback, - * my_client_data - * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something; - * \endcode - * - * or you could do; - * - * \code - * [...] - * FILE *file = fopen("somefile.flac","rb"); - * if(file == NULL) do_somthing; - * if(FLAC__stream_decoder_init_FILE( - * decoder, - * file, - * my_write_callback, - * my_metadata_callback, // or NULL - * my_error_callback, - * my_client_data - * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something; - * \endcode - * - * or just: - * - * \code - * [...] - * if(FLAC__stream_decoder_init_file( - * decoder, - * "somefile.flac", - * my_write_callback, - * my_metadata_callback, // or NULL - * my_error_callback, - * my_client_data - * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something; - * \endcode - * - * Another small change to the decoder is in how it handles unparseable - * streams. Before, when the decoder found an unparseable stream - * (reserved for when the decoder encounters a stream from a future - * encoder that it can't parse), it changed the state to - * \c FLAC__STREAM_DECODER_UNPARSEABLE_STREAM. Now the decoder instead - * drops sync and calls the error callback with a new error code - * \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM. This is - * more robust. If your error callback does not discriminate on the the - * error state, your code does not need to be changed. - * - * The encoder now has a new setting: - * FLAC__stream_encoder_set_apodization(). This is for setting the - * method used to window the data before LPC analysis. You only need to - * add a call to this function if the default is not suitable. There - * are also two new convenience functions that may be useful: - * FLAC__metadata_object_cuesheet_calculate_cddb_id() and - * FLAC__metadata_get_cuesheet(). - * - * The \a bytes parameter to FLAC__StreamDecoderReadCallback, - * FLAC__StreamEncoderReadCallback, and FLAC__StreamEncoderWriteCallback - * is now \c size_t instead of \c uint32_t. - */ - -/** \defgroup porting_1_1_3_to_1_1_4 Porting from FLAC 1.1.3 to 1.1.4 - * \ingroup porting - * - * \brief - * This module describes porting from FLAC 1.1.3 to FLAC 1.1.4. - * - * There were no changes to any of the interfaces from 1.1.3 to 1.1.4. - * There was a slight change in the implementation of - * FLAC__stream_encoder_set_metadata(); the function now makes a copy - * of the \a metadata array of pointers so the client no longer needs - * to maintain it after the call. The objects themselves that are - * pointed to by the array are still not copied though and must be - * maintained until the call to FLAC__stream_encoder_finish(). - */ - -/** \defgroup porting_1_1_4_to_1_2_0 Porting from FLAC 1.1.4 to 1.2.0 - * \ingroup porting - * - * \brief - * This module describes porting from FLAC 1.1.4 to FLAC 1.2.0. - * - * There were only very minor changes to the interfaces from 1.1.4 to 1.2.0. - * In libFLAC, \c FLAC__format_sample_rate_is_subset() was added. - * In libFLAC++, \c FLAC::Decoder::Stream::get_decode_position() was added. - * - * Finally, value of the constant \c FLAC__FRAME_HEADER_RESERVED_LEN - * has changed to reflect the conversion of one of the reserved bits - * into active use. It used to be \c 2 and now is \c 1. However the - * FLAC frame header length has not changed, so to skip the proper - * number of bits, use \c FLAC__FRAME_HEADER_RESERVED_LEN + - * \c FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN - */ - -/** \defgroup porting_1_3_4_to_1_4_0 Porting from FLAC 1.3.4 to 1.4.0 - * \ingroup porting - * - * \brief - * This module describes porting from FLAC 1.3.4 to FLAC 1.4.0. - * - * \section porting_1_3_4_to_1_4_0_summary Summary - * - * Between FLAC 1.3.4 and FLAC 1.4.0, there have four breaking changes - * - the function get_client_data_from_decoder has been renamed to - * FLAC__get_decoder_client_data - * - some data types in the FLAC__Frame struct have changed - * - all functions resizing metadata blocks now return the object - * untouched if memory allocation fails, whereas previously the - * handling varied and was more or less undefined - * - all functions accepting a filename now take UTF-8 encoded filenames - * on Windows instead of filenames in the current codepage - * - * Furthermore, there have been the following additions - * - the functions FLAC__stream_encoder_set_limit_min_bitrate, - * FLAC__stream_encoder_get_limit_min_bitrate, - * FLAC::encoder::file::set_limit_min_bitrate() and - * FLAC::encoder::file::get_limit_min_bitrate() have been added - * - Added FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA to the - * FLAC__StreamDecoderErrorStatus enum - * - * \section porting_1_3_4_to_1_4_0_breaking Breaking changes - * - * The function \b get_client_data_from_decoder was added in FLAC 1.3.3 - * but did not follow the API naming convention and was not properly - * exported. The function is now renamed and properly integrated as - * FLAC__stream_decoder_get_client_data - * - * To accomodate encoding and decoding 32-bit int PCM, some data types - * in the \b FLAC__frame struct were changed. Specifically, warmup - * in both the FLAC__Subframe_Fixed struc and the FLAC__Subframe_LPC - * struct is changed from FLAC__int32 to FLAC__int64. Also, value - * in the FLAC__Subframe_Constant is changed from FLAC__int32 to - * FLAC__int64. Finally, in FLAC__Subframe_Verbatim struct data is - * changes from a FLAC__int32 array to a union containing a FLAC__int32 - * array and a FLAC__int64 array. Also, a new member is added, - * data_type, which clarifies whether the FLAC__int32 or FLAC__int64 - * array is in use. - * - * Furthermore, the following functions now return the object untouched - * if memory allocation fails, whereas previously the handling varied - * and was more or less undefined - * - * - FLAC__metadata_object_seektable_resize_points - * - FLAC__metadata_object_vorbiscomment_resize_comments - * - FLAC__metadata_object_cuesheet_track_resize_indices - * - FLAC__metadata_object_cuesheet_resize_tracks - * - * The last breaking change is that all API functions taking a filename - * as an argument now, on Windows, must be supplied with that filename - * in the UTF-8 character encoding instead of using the current code - * page. libFLAC internally translates these UTF-8 encoded filenames to - * an appropriate representation to use with _wfopen. On all other - * systems, filename is passed to fopen without any translation, as it - * in libFLAC 1.3.4 and earlier. - * - * \section porting_1_3_4_to_1_4_0_additions Additions - * - * To aid in creating properly streamable FLAC files, a set of functions - * was added to make it possible to enfore a minimum bitrate to files - * created through libFLAC's stream_encoder.h interface. With this - * function enabled the resulting FLAC files have a minimum bitrate of - * 1bit/sample independent of the number of channels, i.e. 48kbit/s for - * 48kHz. This can be beneficial for streaming, as very low bitrates for - * silent sections compressed with 'constant' subframes can result in a - * bitrate of 1kbit/s, creating problems with clients that aren't aware - * of this possibility and buffer too much data. - * - * Finally, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA was added to - * the FLAC__StreamDecoderErrorStatus enum to signal that the decoder - * encountered unreadable metadata. - * - */ - -/** \defgroup flac FLAC C API - * - * The FLAC C API is the interface to libFLAC, a set of structures - * describing the components of FLAC streams, and functions for - * encoding and decoding streams, as well as manipulating FLAC - * metadata in files. - * - * You should start with the format components as all other modules - * are dependent on it. - */ - -#endif diff --git a/Engine/lib/flac/include/FLAC/assert.h b/Engine/lib/flac/include/FLAC/assert.h deleted file mode 100644 index ee3ee080b..000000000 --- a/Engine/lib/flac/include/FLAC/assert.h +++ /dev/null @@ -1,51 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__ASSERT_H -#define FLAC__ASSERT_H - -/* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */ -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -#define FLAC__ASSERT(x) if(!(x)) __builtin_abort(); -#define FLAC__ASSERT_DECLARATION(x) x -#else -#ifndef NDEBUG -#include -#define FLAC__ASSERT(x) assert(x) -#define FLAC__ASSERT_DECLARATION(x) x -#else -#define FLAC__ASSERT(x) -#define FLAC__ASSERT_DECLARATION(x) -#endif -#endif - -#endif diff --git a/Engine/lib/flac/include/FLAC/callback.h b/Engine/lib/flac/include/FLAC/callback.h deleted file mode 100644 index 4babcd324..000000000 --- a/Engine/lib/flac/include/FLAC/callback.h +++ /dev/null @@ -1,190 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__CALLBACK_H -#define FLAC__CALLBACK_H - -#include "ordinals.h" -#include /* for size_t */ - -/** \file include/FLAC/callback.h - * - * \brief - * This module defines the structures for describing I/O callbacks - * to the other FLAC interfaces. - * - * See the detailed documentation for callbacks in the - * \link flac_callbacks callbacks \endlink module. - */ - -/** \defgroup flac_callbacks FLAC/callback.h: I/O callback structures - * \ingroup flac - * - * \brief - * This module defines the structures for describing I/O callbacks - * to the other FLAC interfaces. - * - * The purpose of the I/O callback functions is to create a common way - * for the metadata interfaces to handle I/O. - * - * Originally the metadata interfaces required filenames as the way of - * specifying FLAC files to operate on. This is problematic in some - * environments so there is an additional option to specify a set of - * callbacks for doing I/O on the FLAC file, instead of the filename. - * - * In addition to the callbacks, a FLAC__IOHandle type is defined as an - * opaque structure for a data source. - * - * The callback function prototypes are similar (but not identical) to the - * stdio functions fread, fwrite, fseek, ftell, feof, and fclose. If you use - * stdio streams to implement the callbacks, you can pass fread, fwrite, and - * fclose anywhere a FLAC__IOCallback_Read, FLAC__IOCallback_Write, or - * FLAC__IOCallback_Close is required, and a FILE* anywhere a FLAC__IOHandle - * is required. \warning You generally CANNOT directly use fseek or ftell - * for FLAC__IOCallback_Seek or FLAC__IOCallback_Tell since on most systems - * these use 32-bit offsets and FLAC requires 64-bit offsets to deal with - * large files. You will have to find an equivalent function (e.g. ftello), - * or write a wrapper. The same is true for feof() since this is usually - * implemented as a macro, not as a function whose address can be taken. - * - * \{ - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** This is the opaque handle type used by the callbacks. Typically - * this is a \c FILE* or address of a file descriptor. - */ -typedef void* FLAC__IOHandle; - -/** Signature for the read callback. - * The signature and semantics match POSIX fread() implementations - * and can generally be used interchangeably. Note that the global - * variable errno from errno.h is read by some libFLAC functions to - * detect read errors. - * - * \param ptr The address of the read buffer. - * \param size The size of the records to be read. - * \param nmemb The number of records to be read. - * \param handle The handle to the data source. - * \retval size_t - * The number of records read. - */ -typedef size_t (*FLAC__IOCallback_Read) (void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle); - -/** Signature for the write callback. - * The signature and semantics match POSIX fwrite() implementations - * and can generally be used interchangeably. - * - * \param ptr The address of the write buffer. - * \param size The size of the records to be written. - * \param nmemb The number of records to be written. - * \param handle The handle to the data source. - * \retval size_t - * The number of records written. - */ -typedef size_t (*FLAC__IOCallback_Write) (const void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle); - -/** Signature for the seek callback. - * The signature and semantics mostly match POSIX fseek() WITH ONE IMPORTANT - * EXCEPTION: the offset is a 64-bit type whereas fseek() is generally 'long' - * and 32-bits wide. - * - * \param handle The handle to the data source. - * \param offset The new position, relative to \a whence - * \param whence \c SEEK_SET, \c SEEK_CUR, or \c SEEK_END - * \retval int - * \c 0 on success, \c -1 on error. - */ -typedef int (*FLAC__IOCallback_Seek) (FLAC__IOHandle handle, FLAC__int64 offset, int whence); - -/** Signature for the tell callback. - * The signature and semantics mostly match POSIX ftell() WITH ONE IMPORTANT - * EXCEPTION: the offset is a 64-bit type whereas ftell() is generally 'long' - * and 32-bits wide. - * - * \param handle The handle to the data source. - * \retval FLAC__int64 - * The current position on success, \c -1 on error. - */ -typedef FLAC__int64 (*FLAC__IOCallback_Tell) (FLAC__IOHandle handle); - -/** Signature for the EOF callback. - * The signature and semantics mostly match POSIX feof() but WATCHOUT: - * on many systems, feof() is a macro, so in this case a wrapper function - * must be provided instead. - * - * \param handle The handle to the data source. - * \retval int - * \c 0 if not at end of file, nonzero if at end of file. - */ -typedef int (*FLAC__IOCallback_Eof) (FLAC__IOHandle handle); - -/** Signature for the close callback. - * The signature and semantics match POSIX fclose() implementations - * and can generally be used interchangeably. - * - * \param handle The handle to the data source. - * \retval int - * \c 0 on success, \c EOF on error. - */ -typedef int (*FLAC__IOCallback_Close) (FLAC__IOHandle handle); - -/** A structure for holding a set of callbacks. - * Each FLAC interface that requires a FLAC__IOCallbacks structure will - * describe which of the callbacks are required. The ones that are not - * required may be set to NULL. - * - * If the seek requirement for an interface is optional, you can signify that - * a data source is not seekable by setting the \a seek field to \c NULL. - * - * See the detailed documentation for callbacks in the - * \link flac_callbacks callbacks \endlink module. - */ -typedef struct { - FLAC__IOCallback_Read read; /**< See FLAC__IOCallbacks */ - FLAC__IOCallback_Write write; /**< See FLAC__IOCallbacks */ - FLAC__IOCallback_Seek seek; /**< See FLAC__IOCallbacks */ - FLAC__IOCallback_Tell tell; /**< See FLAC__IOCallbacks */ - FLAC__IOCallback_Eof eof; /**< See FLAC__IOCallbacks */ - FLAC__IOCallback_Close close; /**< See FLAC__IOCallbacks */ -} FLAC__IOCallbacks; - -/* \} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/FLAC/export.h b/Engine/lib/flac/include/FLAC/export.h deleted file mode 100644 index d14728a50..000000000 --- a/Engine/lib/flac/include/FLAC/export.h +++ /dev/null @@ -1,115 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__EXPORT_H -#define FLAC__EXPORT_H - -/** \file include/FLAC/export.h - * - * \brief - * This module contains \#defines and symbols for exporting function - * calls, and providing version information and compiled-in features. - * - * See the \link flac_export export \endlink module. - */ - -/** \defgroup flac_export FLAC/export.h: export symbols - * \ingroup flac - * - * \brief - * This module contains \#defines and symbols for exporting function - * calls, and providing version information and compiled-in features. - * - * If you are compiling for Windows (with Visual Studio or MinGW for - * example) and will link to the static library (libFLAC++.lib) you - * should define FLAC__NO_DLL in your project to make sure the symbols - * are exported properly. - * - * \{ - */ - -/** This \#define is used internally in libFLAC and its headers to make - * sure the correct symbols are exported when working with shared - * libraries. On Windows, this \#define is set to __declspec(dllexport) - * when compiling libFLAC into a library and to __declspec(dllimport) - * when the headers are used to link to that DLL. On non-Windows systems - * it is used to set symbol visibility. - * - * Because of this, the define FLAC__NO_DLL must be defined when linking - * to libFLAC statically or linking will fail. - */ -/* This has grown quite complicated. FLAC__NO_DLL is used by MSVC sln - * files and CMake, which build either static or shared. autotools can - * build static, shared or **both**. Therefore, DLL_EXPORT, which is set - * by libtool, must override FLAC__NO_DLL on building shared components - */ -#if defined(_WIN32) - -#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT)) -#define FLAC_API -#else -#ifdef FLAC_API_EXPORTS -#define FLAC_API __declspec(dllexport) -#else -#define FLAC_API __declspec(dllimport) -#endif -#endif - -#elif defined(FLAC__USE_VISIBILITY_ATTR) -#define FLAC_API __attribute__ ((visibility ("default"))) - -#else -#define FLAC_API - -#endif - -/** These \#defines will mirror the libtool-based library version number, see - * http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning - */ -#define FLAC_API_VERSION_CURRENT 13 -#define FLAC_API_VERSION_REVISION 0 /**< see above */ -#define FLAC_API_VERSION_AGE 1 /**< see above */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** \c 1 if the library has been compiled with support for Ogg FLAC, else \c 0. */ -extern FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC; - -#ifdef __cplusplus -} -#endif - -/* \} */ - -#endif diff --git a/Engine/lib/flac/include/FLAC/format.h b/Engine/lib/flac/include/FLAC/format.h deleted file mode 100644 index ef7c8b219..000000000 --- a/Engine/lib/flac/include/FLAC/format.h +++ /dev/null @@ -1,1032 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__FORMAT_H -#define FLAC__FORMAT_H - -#include "export.h" -#include "ordinals.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file include/FLAC/format.h - * - * \brief - * This module contains structure definitions for the representation - * of FLAC format components in memory. These are the basic - * structures used by the rest of the interfaces. - * - * See the detailed documentation in the - * \link flac_format format \endlink module. - */ - -/** \defgroup flac_format FLAC/format.h: format components - * \ingroup flac - * - * \brief - * This module contains structure definitions for the representation - * of FLAC format components in memory. These are the basic - * structures used by the rest of the interfaces. - * - * First, you should be familiar with the - * FLAC format. Many of the values here - * follow directly from the specification. As a user of libFLAC, the - * interesting parts really are the structures that describe the frame - * header and metadata blocks. - * - * The format structures here are very primitive, designed to store - * information in an efficient way. Reading information from the - * structures is easy but creating or modifying them directly is - * more complex. For the most part, as a user of a library, editing - * is not necessary; however, for metadata blocks it is, so there are - * convenience functions provided in the \link flac_metadata metadata - * module \endlink to simplify the manipulation of metadata blocks. - * - * \note - * It's not the best convention, but symbols ending in _LEN are in bits - * and _LENGTH are in bytes. _LENGTH symbols are \#defines instead of - * global variables because they are usually used when declaring byte - * arrays and some compilers require compile-time knowledge of array - * sizes when declared on the stack. - * - * \{ - */ - - -/* - Most of the values described in this file are defined by the FLAC - format specification. There is nothing to tune here. -*/ - -/** The largest legal metadata type code. */ -#define FLAC__MAX_METADATA_TYPE_CODE (126u) - -/** The minimum block size, in samples, permitted by the format. */ -#define FLAC__MIN_BLOCK_SIZE (16u) - -/** The maximum block size, in samples, permitted by the format. */ -#define FLAC__MAX_BLOCK_SIZE (65535u) - -/** The maximum block size, in samples, permitted by the FLAC subset for - * sample rates up to 48kHz. */ -#define FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ (4608u) - -/** The maximum number of channels permitted by the format. */ -#define FLAC__MAX_CHANNELS (8u) - -/** The minimum sample resolution permitted by the format. */ -#define FLAC__MIN_BITS_PER_SAMPLE (4u) - -/** The maximum sample resolution permitted by the format. */ -#define FLAC__MAX_BITS_PER_SAMPLE (32u) - -/** The maximum sample resolution permitted by libFLAC. - * - * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However, - * the reference encoder/decoder used to be limited to 24 bits. This - * value was used to signal that limit. - */ -#define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (32u) - -/** The maximum sample rate permitted by the format. The value is - * ((2 ^ 20) - 1) - */ -#define FLAC__MAX_SAMPLE_RATE (1048575u) - -/** The maximum LPC order permitted by the format. */ -#define FLAC__MAX_LPC_ORDER (32u) - -/** The maximum LPC order permitted by the FLAC subset for sample rates - * up to 48kHz. */ -#define FLAC__SUBSET_MAX_LPC_ORDER_48000HZ (12u) - -/** The minimum quantized linear predictor coefficient precision - * permitted by the format. - */ -#define FLAC__MIN_QLP_COEFF_PRECISION (5u) - -/** The maximum quantized linear predictor coefficient precision - * permitted by the format. - */ -#define FLAC__MAX_QLP_COEFF_PRECISION (15u) - -/** The maximum order of the fixed predictors permitted by the format. */ -#define FLAC__MAX_FIXED_ORDER (4u) - -/** The maximum Rice partition order permitted by the format. */ -#define FLAC__MAX_RICE_PARTITION_ORDER (15u) - -/** The maximum Rice partition order permitted by the FLAC Subset. */ -#define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u) - -/** The version string of the release, stamped onto the libraries and binaries. - * - * \note - * This does not correspond to the shared library version number, which - * is used to determine binary compatibility. - */ -extern FLAC_API const char *FLAC__VERSION_STRING; - -/** The vendor string inserted by the encoder into the VORBIS_COMMENT block. - * This is a NUL-terminated ASCII string; when inserted into the - * VORBIS_COMMENT the trailing null is stripped. - */ -extern FLAC_API const char *FLAC__VENDOR_STRING; - -/** The byte string representation of the beginning of a FLAC stream. */ -extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */ - -/** The 32-bit integer big-endian representation of the beginning of - * a FLAC stream. - */ -extern FLAC_API const uint32_t FLAC__STREAM_SYNC; /* = 0x664C6143 */ - -/** The length of the FLAC signature in bits. */ -extern FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN; /* = 32 bits */ - -/** The length of the FLAC signature in bytes. */ -#define FLAC__STREAM_SYNC_LENGTH (4u) - - -/***************************************************************************** - * - * Subframe structures - * - *****************************************************************************/ - -/*****************************************************************************/ - -/** An enumeration of the available entropy coding methods. */ -typedef enum { - FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0, - /**< Residual is coded by partitioning into contexts, each with it's own - * 4-bit Rice parameter. */ - - FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1 - /**< Residual is coded by partitioning into contexts, each with it's own - * 5-bit Rice parameter. */ -} FLAC__EntropyCodingMethodType; - -/** Maps a FLAC__EntropyCodingMethodType to a C string. - * - * Using a FLAC__EntropyCodingMethodType as the index to this array will - * give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[]; - - -/** Contents of a Rice partitioned residual - */ -typedef struct { - - uint32_t *parameters; - /**< The Rice parameters for each context. */ - - uint32_t *raw_bits; - /**< Widths for escape-coded partitions. Will be non-zero for escaped - * partitions and zero for unescaped partitions. - */ - - uint32_t capacity_by_order; - /**< The capacity of the \a parameters and \a raw_bits arrays - * specified as an order, i.e. the number of array elements - * allocated is 2 ^ \a capacity_by_order. - */ -} FLAC__EntropyCodingMethod_PartitionedRiceContents; - -/** Header for a Rice partitioned residual. (c.f. format specification) - */ -typedef struct { - - uint32_t order; - /**< The partition order, i.e. # of contexts = 2 ^ \a order. */ - - const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents; - /**< The context's Rice parameters and/or raw bits. */ - -} FLAC__EntropyCodingMethod_PartitionedRice; - -extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */ -extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */ -extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */ -extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */ - -extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; -/**< == (1<format specification) - */ -typedef struct { - FLAC__EntropyCodingMethodType type; - union { - FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice; - } data; -} FLAC__EntropyCodingMethod; - -extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */ - -/*****************************************************************************/ - -/** An enumeration of the available subframe types. */ -typedef enum { - FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */ - FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */ - FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */ - FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */ -} FLAC__SubframeType; - -/** Maps a FLAC__SubframeType to a C string. - * - * Using a FLAC__SubframeType as the index to this array will - * give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__SubframeTypeString[]; - - -/** CONSTANT subframe. (c.f. format specification) - */ -typedef struct { - FLAC__int64 value; /**< The constant signal value. */ -} FLAC__Subframe_Constant; - -/** An enumeration of the possible verbatim subframe data types. */ -typedef enum { - FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32, /**< verbatim subframe has 32-bit int */ - FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT64 /**< verbatim subframe has 64-bit int */ -} FLAC__VerbatimSubframeDataType; - - -/** VERBATIM subframe. (c.f. format specification) - */ -typedef struct { - union { - const FLAC__int32 *int32; /**< A FLAC__int32 pointer to verbatim signal. */ - const FLAC__int64 *int64; /**< A FLAC__int64 pointer to verbatim signal. */ - } data; - FLAC__VerbatimSubframeDataType data_type; -} FLAC__Subframe_Verbatim; - - -/** FIXED subframe. (c.f. format specification) - */ -typedef struct { - FLAC__EntropyCodingMethod entropy_coding_method; - /**< The residual coding method. */ - - uint32_t order; - /**< The polynomial order. */ - - FLAC__int64 warmup[FLAC__MAX_FIXED_ORDER]; - /**< Warmup samples to prime the predictor, length == order. */ - - const FLAC__int32 *residual; - /**< The residual signal, length == (blocksize minus order) samples. */ -} FLAC__Subframe_Fixed; - - -/** LPC subframe. (c.f. format specification) - */ -typedef struct { - FLAC__EntropyCodingMethod entropy_coding_method; - /**< The residual coding method. */ - - uint32_t order; - /**< The FIR order. */ - - uint32_t qlp_coeff_precision; - /**< Quantized FIR filter coefficient precision in bits. */ - - int quantization_level; - /**< The qlp coeff shift needed. */ - - FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; - /**< FIR filter coefficients. */ - - FLAC__int64 warmup[FLAC__MAX_LPC_ORDER]; - /**< Warmup samples to prime the predictor, length == order. */ - - const FLAC__int32 *residual; - /**< The residual signal, length == (blocksize minus order) samples. */ -} FLAC__Subframe_LPC; - -extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */ -extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */ - - -/** FLAC subframe structure. (c.f. format specification) - */ -typedef struct { - FLAC__SubframeType type; - union { - FLAC__Subframe_Constant constant; - FLAC__Subframe_Fixed fixed; - FLAC__Subframe_LPC lpc; - FLAC__Subframe_Verbatim verbatim; - } data; - uint32_t wasted_bits; -} FLAC__Subframe; - -/** == 1 (bit) - * - * This used to be a zero-padding bit (hence the name - * FLAC__SUBFRAME_ZERO_PAD_LEN) but is now a reserved bit. It still has a - * mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1 - * to mean something else. - */ -extern FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN; -extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */ -extern FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */ - -extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */ -extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */ -extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */ -extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */ - -/*****************************************************************************/ - - -/***************************************************************************** - * - * Frame structures - * - *****************************************************************************/ - -/** An enumeration of the available channel assignments. */ -typedef enum { - FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, /**< independent channels */ - FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, /**< left+side stereo */ - FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, /**< right+side stereo */ - FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 /**< mid+side stereo */ -} FLAC__ChannelAssignment; - -/** Maps a FLAC__ChannelAssignment to a C string. - * - * Using a FLAC__ChannelAssignment as the index to this array will - * give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__ChannelAssignmentString[]; - -/** An enumeration of the possible frame numbering methods. */ -typedef enum { - FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER, /**< number contains the frame number */ - FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER /**< number contains the sample number of first sample in frame */ -} FLAC__FrameNumberType; - -/** Maps a FLAC__FrameNumberType to a C string. - * - * Using a FLAC__FrameNumberType as the index to this array will - * give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__FrameNumberTypeString[]; - - -/** FLAC frame header structure. (c.f. format specification) - */ -typedef struct { - uint32_t blocksize; - /**< The number of samples per subframe. */ - - uint32_t sample_rate; - /**< The sample rate in Hz. */ - - uint32_t channels; - /**< The number of channels (== number of subframes). */ - - FLAC__ChannelAssignment channel_assignment; - /**< The channel assignment for the frame. */ - - uint32_t bits_per_sample; - /**< The sample resolution. */ - - FLAC__FrameNumberType number_type; - /**< The numbering scheme used for the frame. As a convenience, the - * decoder will always convert a frame number to a sample number because - * the rules are complex. */ - - union { - FLAC__uint32 frame_number; - FLAC__uint64 sample_number; - } number; - /**< The frame number or sample number of first sample in frame; - * use the \a number_type value to determine which to use. */ - - FLAC__uint8 crc; - /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) - * of the raw frame header bytes, meaning everything before the CRC byte - * including the sync code. - */ -} FLAC__FrameHeader; - -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */ -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */ -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */ -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */ -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */ -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */ -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */ -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */ -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */ -extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */ - - -/** FLAC frame footer structure. (c.f. format specification) - */ -typedef struct { - FLAC__uint16 crc; - /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with - * 0) of the bytes before the crc, back to and including the frame header - * sync code. - */ -} FLAC__FrameFooter; - -extern FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */ - - -/** FLAC frame structure. (c.f. format specification) - */ -typedef struct { - FLAC__FrameHeader header; - FLAC__Subframe subframes[FLAC__MAX_CHANNELS]; - FLAC__FrameFooter footer; -} FLAC__Frame; - -/*****************************************************************************/ - - -/***************************************************************************** - * - * Meta-data structures - * - *****************************************************************************/ - -/** An enumeration of the available metadata block types. */ -typedef enum { - - FLAC__METADATA_TYPE_STREAMINFO = 0, - /**< STREAMINFO block */ - - FLAC__METADATA_TYPE_PADDING = 1, - /**< PADDING block */ - - FLAC__METADATA_TYPE_APPLICATION = 2, - /**< APPLICATION block */ - - FLAC__METADATA_TYPE_SEEKTABLE = 3, - /**< SEEKTABLE block */ - - FLAC__METADATA_TYPE_VORBIS_COMMENT = 4, - /**< VORBISCOMMENT block (a.k.a. FLAC tags) */ - - FLAC__METADATA_TYPE_CUESHEET = 5, - /**< CUESHEET block */ - - FLAC__METADATA_TYPE_PICTURE = 6, - /**< PICTURE block */ - - FLAC__METADATA_TYPE_UNDEFINED = 7, - /**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */ - - FLAC__MAX_METADATA_TYPE = FLAC__MAX_METADATA_TYPE_CODE, - /**< No type will ever be greater than this. There is not enough room in the protocol block. */ -} FLAC__MetadataType; - -/** Maps a FLAC__MetadataType to a C string. - * - * Using a FLAC__MetadataType as the index to this array will - * give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__MetadataTypeString[]; - - -/** FLAC STREAMINFO structure. (c.f. format specification) - */ -typedef struct { - uint32_t min_blocksize, max_blocksize; - uint32_t min_framesize, max_framesize; - uint32_t sample_rate; - uint32_t channels; - uint32_t bits_per_sample; - FLAC__uint64 total_samples; - FLAC__byte md5sum[16]; -} FLAC__StreamMetadata_StreamInfo; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */ - -/** The total stream length of the STREAMINFO block in bytes. */ -#define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u) - -/** FLAC PADDING structure. (c.f. format specification) - */ -typedef struct { - int dummy; - /**< Conceptually this is an empty struct since we don't store the - * padding bytes. Empty structs are not allowed by some C compilers, - * hence the dummy. - */ -} FLAC__StreamMetadata_Padding; - - -/** FLAC APPLICATION structure. (c.f. format specification) - */ -typedef struct { - FLAC__byte id[4]; - FLAC__byte *data; -} FLAC__StreamMetadata_Application; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */ - -/** SeekPoint structure used in SEEKTABLE blocks. (c.f. format specification) - */ -typedef struct { - FLAC__uint64 sample_number; - /**< The sample number of the target frame. */ - - FLAC__uint64 stream_offset; - /**< The offset, in bytes, of the target frame with respect to - * beginning of the first frame. */ - - uint32_t frame_samples; - /**< The number of samples in the target frame. */ -} FLAC__StreamMetadata_SeekPoint; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */ - -/** The total stream length of a seek point in bytes. */ -#define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u) - -/** The value used in the \a sample_number field of - * FLAC__StreamMetadataSeekPoint used to indicate a placeholder - * point (== 0xffffffffffffffff). - */ -extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - - -/** FLAC SEEKTABLE structure. (c.f. format specification) - * - * \note From the format specification: - * - The seek points must be sorted by ascending sample number. - * - Each seek point's sample number must be the first sample of the - * target frame. - * - Each seek point's sample number must be unique within the table. - * - Existence of a SEEKTABLE block implies a correct setting of - * total_samples in the stream_info block. - * - Behavior is undefined when more than one SEEKTABLE block is - * present in a stream. - */ -typedef struct { - uint32_t num_points; - FLAC__StreamMetadata_SeekPoint *points; -} FLAC__StreamMetadata_SeekTable; - - -/** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. format specification) - * - * For convenience, the APIs maintain a trailing NUL character at the end of - * \a entry which is not counted toward \a length, i.e. - * \code strlen(entry) == length \endcode - */ -typedef struct { - FLAC__uint32 length; - FLAC__byte *entry; -} FLAC__StreamMetadata_VorbisComment_Entry; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */ - - -/** FLAC VORBIS_COMMENT structure. (c.f. format specification) - */ -typedef struct { - FLAC__StreamMetadata_VorbisComment_Entry vendor_string; - FLAC__uint32 num_comments; - FLAC__StreamMetadata_VorbisComment_Entry *comments; -} FLAC__StreamMetadata_VorbisComment; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */ - - -/** FLAC CUESHEET track index structure. (See the - * format specification for - * the full description of each field.) - */ -typedef struct { - FLAC__uint64 offset; - /**< Offset in samples, relative to the track offset, of the index - * point. - */ - - FLAC__byte number; - /**< The index point number. */ -} FLAC__StreamMetadata_CueSheet_Index; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == 3*8 (bits) */ - - -/** FLAC CUESHEET track structure. (See the - * format specification for - * the full description of each field.) - */ -typedef struct { - FLAC__uint64 offset; - /**< Track offset in samples, relative to the beginning of the FLAC audio stream. */ - - FLAC__byte number; - /**< The track number. */ - - char isrc[13]; - /**< Track ISRC. This is a 12-digit alphanumeric code plus a trailing \c NUL byte */ - - uint32_t type:1; - /**< The track type: 0 for audio, 1 for non-audio. */ - - uint32_t pre_emphasis:1; - /**< The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis. */ - - FLAC__byte num_indices; - /**< The number of track index points. */ - - FLAC__StreamMetadata_CueSheet_Index *indices; - /**< NULL if num_indices == 0, else pointer to array of index points. */ - -} FLAC__StreamMetadata_CueSheet_Track; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+13*8 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */ - - -/** FLAC CUESHEET structure. (See the - * format specification - * for the full description of each field.) - */ -typedef struct { - char media_catalog_number[129]; - /**< Media catalog number, in ASCII printable characters 0x20-0x7e. In - * general, the media catalog number may be 0 to 128 bytes long; any - * unused characters should be right-padded with NUL characters. - */ - - FLAC__uint64 lead_in; - /**< The number of lead-in samples. */ - - FLAC__bool is_cd; - /**< \c true if CUESHEET corresponds to a Compact Disc, else \c false. */ - - uint32_t num_tracks; - /**< The number of tracks. */ - - FLAC__StreamMetadata_CueSheet_Track *tracks; - /**< NULL if num_tracks == 0, else pointer to array of tracks. */ - -} FLAC__StreamMetadata_CueSheet; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == 7+258*8 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */ - - -/** An enumeration of the PICTURE types (see FLAC__StreamMetadataPicture and id3 v2.4 APIC tag). */ -typedef enum { - FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = 0, /**< Other */ - FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = 1, /**< 32x32 pixels 'file icon' (PNG only) */ - FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = 2, /**< Other file icon */ - FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = 3, /**< Cover (front) */ - FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = 4, /**< Cover (back) */ - FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = 5, /**< Leaflet page */ - FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = 6, /**< Media (e.g. label side of CD) */ - FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = 7, /**< Lead artist/lead performer/soloist */ - FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = 8, /**< Artist/performer */ - FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = 9, /**< Conductor */ - FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = 10, /**< Band/Orchestra */ - FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = 11, /**< Composer */ - FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = 12, /**< Lyricist/text writer */ - FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = 13, /**< Recording Location */ - FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = 14, /**< During recording */ - FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = 15, /**< During performance */ - FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = 16, /**< Movie/video screen capture */ - FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = 17, /**< A bright coloured fish */ - FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = 18, /**< Illustration */ - FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = 19, /**< Band/artist logotype */ - FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = 20, /**< Publisher/Studio logotype */ - FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED -} FLAC__StreamMetadata_Picture_Type; - -/** Maps a FLAC__StreamMetadata_Picture_Type to a C string. - * - * Using a FLAC__StreamMetadata_Picture_Type as the index to this array - * will give the string equivalent. The contents should not be - * modified. - */ -extern FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[]; - -/** FLAC PICTURE structure. (See the - * format specification - * for the full description of each field.) - */ -typedef struct { - FLAC__StreamMetadata_Picture_Type type; - /**< The kind of picture stored. */ - - char *mime_type; - /**< Picture data's MIME type, in ASCII printable characters - * 0x20-0x7e, NUL terminated. For best compatibility with players, - * use picture data of MIME type \c image/jpeg or \c image/png. A - * MIME type of '-->' is also allowed, in which case the picture - * data should be a complete URL. In file storage, the MIME type is - * stored as a 32-bit length followed by the ASCII string with no NUL - * terminator, but is converted to a plain C string in this structure - * for convenience. - */ - - FLAC__byte *description; - /**< Picture's description in UTF-8, NUL terminated. In file storage, - * the description is stored as a 32-bit length followed by the UTF-8 - * string with no NUL terminator, but is converted to a plain C string - * in this structure for convenience. - */ - - FLAC__uint32 width; - /**< Picture's width in pixels. */ - - FLAC__uint32 height; - /**< Picture's height in pixels. */ - - FLAC__uint32 depth; - /**< Picture's color depth in bits-per-pixel. */ - - FLAC__uint32 colors; - /**< For indexed palettes (like GIF), picture's number of colors (the - * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth). - */ - - FLAC__uint32 data_length; - /**< Length of binary picture data in bytes. */ - - FLAC__byte *data; - /**< Binary picture data. */ - -} FLAC__StreamMetadata_Picture; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN; /**< == 32 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN; /**< == 32 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN; /**< == 32 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN; /**< == 32 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN; /**< == 32 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN; /**< == 32 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN; /**< == 32 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN; /**< == 32 (bits) */ - - -/** Structure that is used when a metadata block of unknown type is loaded. - * The contents are opaque. The structure is used only internally to - * correctly handle unknown metadata. - */ -typedef struct { - FLAC__byte *data; -} FLAC__StreamMetadata_Unknown; - - -/** FLAC metadata block structure. (c.f. format specification) - */ -typedef struct FLAC__StreamMetadata { - FLAC__MetadataType type; - /**< The type of the metadata block; used determine which member of the - * \a data union to dereference. If type >= FLAC__METADATA_TYPE_UNDEFINED - * then \a data.unknown must be used. */ - - FLAC__bool is_last; - /**< \c true if this metadata block is the last, else \a false */ - - uint32_t length; - /**< Length, in bytes, of the block data as it appears in the stream. */ - - union { - FLAC__StreamMetadata_StreamInfo stream_info; - FLAC__StreamMetadata_Padding padding; - FLAC__StreamMetadata_Application application; - FLAC__StreamMetadata_SeekTable seek_table; - FLAC__StreamMetadata_VorbisComment vorbis_comment; - FLAC__StreamMetadata_CueSheet cue_sheet; - FLAC__StreamMetadata_Picture picture; - FLAC__StreamMetadata_Unknown unknown; - } data; - /**< Polymorphic block data; use the \a type value to determine which - * to use. */ -} FLAC__StreamMetadata; - -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */ -extern FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */ - -/** The total stream length of a metadata block header in bytes. */ -#define FLAC__STREAM_METADATA_HEADER_LENGTH (4u) - -/*****************************************************************************/ - - -/***************************************************************************** - * - * Utility functions - * - *****************************************************************************/ - -/** Tests that a sample rate is valid for FLAC. - * - * \param sample_rate The sample rate to test for compliance. - * \retval FLAC__bool - * \c true if the given sample rate conforms to the specification, else - * \c false. - */ -FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(uint32_t sample_rate); - -/** Tests that a blocksize at the given sample rate is valid for the FLAC - * subset. - * - * \param blocksize The blocksize to test for compliance. - * \param sample_rate The sample rate is needed, since the valid subset - * blocksize depends on the sample rate. - * \retval FLAC__bool - * \c true if the given blocksize conforms to the specification for the - * subset at the given sample rate, else \c false. - */ -FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate); - -/** Tests that a sample rate is valid for the FLAC subset. The subset rules - * for valid sample rates are slightly more complex since the rate has to - * be expressible completely in the frame header. - * - * \param sample_rate The sample rate to test for compliance. - * \retval FLAC__bool - * \c true if the given sample rate conforms to the specification for the - * subset, else \c false. - */ -FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate); - -/** Check a Vorbis comment entry name to see if it conforms to the Vorbis - * comment specification. - * - * Vorbis comment names must be composed only of characters from - * [0x20-0x3C,0x3E-0x7D]. - * - * \param name A NUL-terminated string to be checked. - * \assert - * \code name != NULL \endcode - * \retval FLAC__bool - * \c false if entry name is illegal, else \c true. - */ -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name); - -/** Check a Vorbis comment entry value to see if it conforms to the Vorbis - * comment specification. - * - * Vorbis comment values must be valid UTF-8 sequences. - * - * \param value A string to be checked. - * \param length A the length of \a value in bytes. May be - * \c (uint32_t)(-1) to indicate that \a value is a plain - * UTF-8 NUL-terminated string. - * \assert - * \code value != NULL \endcode - * \retval FLAC__bool - * \c false if entry name is illegal, else \c true. - */ -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, uint32_t length); - -/** Check a Vorbis comment entry to see if it conforms to the Vorbis - * comment specification. - * - * Vorbis comment entries must be of the form 'name=value', and 'name' and - * 'value' must be legal according to - * FLAC__format_vorbiscomment_entry_name_is_legal() and - * FLAC__format_vorbiscomment_entry_value_is_legal() respectively. - * - * \param entry An entry to be checked. - * \param length The length of \a entry in bytes. - * \assert - * \code value != NULL \endcode - * \retval FLAC__bool - * \c false if entry name is illegal, else \c true. - */ -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, uint32_t length); - -/** Check a seek table to see if it conforms to the FLAC specification. - * See the format specification for limits on the contents of the - * seek table. - * - * \param seek_table A pointer to a seek table to be checked. - * \assert - * \code seek_table != NULL \endcode - * \retval FLAC__bool - * \c false if seek table is illegal, else \c true. - */ -FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table); - -/** Sort a seek table's seek points according to the format specification. - * This includes a "unique-ification" step to remove duplicates, i.e. - * seek points with identical \a sample_number values. Duplicate seek - * points are converted into placeholder points and sorted to the end of - * the table. - * - * \param seek_table A pointer to a seek table to be sorted. - * \assert - * \code seek_table != NULL \endcode - * \retval uint32_t - * The number of duplicate seek points converted into placeholders. - */ -FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table); - -/** Check a cue sheet to see if it conforms to the FLAC specification. - * See the format specification for limits on the contents of the - * cue sheet. - * - * \param cue_sheet A pointer to an existing cue sheet to be checked. - * \param check_cd_da_subset If \c true, check CUESHEET against more - * stringent requirements for a CD-DA (audio) disc. - * \param violation Address of a pointer to a string. If there is a - * violation, a pointer to a string explanation of the - * violation will be returned here. \a violation may be - * \c NULL if you don't need the returned string. Do not - * free the returned string; it will always point to static - * data. - * \assert - * \code cue_sheet != NULL \endcode - * \retval FLAC__bool - * \c false if cue sheet is illegal, else \c true. - */ -FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation); - -/** Check picture data to see if it conforms to the FLAC specification. - * See the format specification for limits on the contents of the - * PICTURE block. - * - * \param picture A pointer to existing picture data to be checked. - * \param violation Address of a pointer to a string. If there is a - * violation, a pointer to a string explanation of the - * violation will be returned here. \a violation may be - * \c NULL if you don't need the returned string. Do not - * free the returned string; it will always point to static - * data. - * \assert - * \code picture != NULL \endcode - * \retval FLAC__bool - * \c false if picture data is illegal, else \c true. - */ -FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation); - -/* \} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/FLAC/metadata.h b/Engine/lib/flac/include/FLAC/metadata.h deleted file mode 100644 index 4747a5f3f..000000000 --- a/Engine/lib/flac/include/FLAC/metadata.h +++ /dev/null @@ -1,2234 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__METADATA_H -#define FLAC__METADATA_H - -#include /* for off_t */ -#include "export.h" -#include "callback.h" -#include "format.h" - -/* -------------------------------------------------------------------- - (For an example of how all these routines are used, see the source - code for the unit tests in src/test_libFLAC/metadata_*.c, or - metaflac in src/metaflac/) - ------------------------------------------------------------------*/ - -/** \file include/FLAC/metadata.h - * - * \brief - * This module provides functions for creating and manipulating FLAC - * metadata blocks in memory, and three progressively more powerful - * interfaces for traversing and editing metadata in FLAC files. - * - * See the detailed documentation for each interface in the - * \link flac_metadata metadata \endlink module. - */ - -/** \defgroup flac_metadata FLAC/metadata.h: metadata interfaces - * \ingroup flac - * - * \brief - * This module provides functions for creating and manipulating FLAC - * metadata blocks in memory, and three progressively more powerful - * interfaces for traversing and editing metadata in native FLAC files. - * Note that currently only the Chain interface (level 2) supports Ogg - * FLAC files, and it is read-only i.e. no writing back changed - * metadata to file. - * - * There are three metadata interfaces of increasing complexity: - * - * Level 0: - * Read-only access to the STREAMINFO, VORBIS_COMMENT, CUESHEET, and - * PICTURE blocks. - * - * Level 1: - * Read-write access to all metadata blocks. This level is write- - * efficient in most cases (more on this below), and uses less memory - * than level 2. - * - * Level 2: - * Read-write access to all metadata blocks. This level is write- - * efficient in all cases, but uses more memory since all metadata for - * the whole file is read into memory and manipulated before writing - * out again. - * - * What do we mean by efficient? Since FLAC metadata appears at the - * beginning of the file, when writing metadata back to a FLAC file - * it is possible to grow or shrink the metadata such that the entire - * file must be rewritten. However, if the size remains the same during - * changes or PADDING blocks are utilized, only the metadata needs to be - * overwritten, which is much faster. - * - * Efficient means the whole file is rewritten at most one time, and only - * when necessary. Level 1 is not efficient only in the case that you - * cause more than one metadata block to grow or shrink beyond what can - * be accommodated by padding. In this case you should probably use level - * 2, which allows you to edit all the metadata for a file in memory and - * write it out all at once. - * - * All levels know how to skip over and not disturb an ID3v2 tag at the - * front of the file. - * - * All levels access files via their filenames. In addition, level 2 - * has additional alternative read and write functions that take an I/O - * handle and callbacks, for situations where access by filename is not - * possible. - * - * In addition to the three interfaces, this module defines functions for - * creating and manipulating various metadata objects in memory. As we see - * from the Format module, FLAC metadata blocks in memory are very primitive - * structures for storing information in an efficient way. Reading - * information from the structures is easy but creating or modifying them - * directly is more complex. The metadata object routines here facilitate - * this by taking care of the consistency and memory management drudgery. - * - * Unless you will be using the level 1 or 2 interfaces to modify existing - * metadata however, you will not probably not need these. - * - * From a dependency standpoint, none of the encoders or decoders require - * the metadata module. This is so that embedded users can strip out the - * metadata module from libFLAC to reduce the size and complexity. - */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/** \defgroup flac_metadata_level0 FLAC/metadata.h: metadata level 0 interface - * \ingroup flac_metadata - * - * \brief - * The level 0 interface consists of individual routines to read the - * STREAMINFO, VORBIS_COMMENT, CUESHEET, and PICTURE blocks, requiring - * only a filename. - * - * On Windows, filename must be a UTF-8 encoded filename, which libFLAC - * internally translates to an appropriate representation to use with - * _wfopen. On all other systems, filename is passed to fopen without - * any translation. - * - * They try to skip any ID3v2 tag at the head of the file. - * - * \{ - */ - -/** Read the STREAMINFO metadata block of the given FLAC file. This function - * will try to skip any ID3v2 tag at the head of the file. - * - * \param filename The path to the FLAC file to read. - * \param streaminfo A pointer to space for the STREAMINFO block. Since - * FLAC__StreamMetadata is a simple structure with no - * memory allocation involved, you pass the address of - * an existing structure. It need not be initialized. - * \assert - * \code filename != NULL \endcode - * \code streaminfo != NULL \endcode - * \retval FLAC__bool - * \c true if a valid STREAMINFO block was read from \a filename. Returns - * \c false if there was a memory allocation error, a file decoder error, - * or the file contained no STREAMINFO block. (A memory allocation error - * is possible because this function must set up a file decoder.) - */ -FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo); - -/** Read the VORBIS_COMMENT metadata block of the given FLAC file. This - * function will try to skip any ID3v2 tag at the head of the file. - * - * \param filename The path to the FLAC file to read. - * \param tags The address where the returned pointer will be - * stored. The \a tags object must be deleted by - * the caller using FLAC__metadata_object_delete(). - * \assert - * \code filename != NULL \endcode - * \code tags != NULL \endcode - * \retval FLAC__bool - * \c true if a valid VORBIS_COMMENT block was read from \a filename, - * and \a *tags will be set to the address of the metadata structure. - * Returns \c false if there was a memory allocation error, a file - * decoder error, or the file contained no VORBIS_COMMENT block, and - * \a *tags will be set to \c NULL. - */ -FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags); - -/** Read the CUESHEET metadata block of the given FLAC file. This - * function will try to skip any ID3v2 tag at the head of the file. - * - * \param filename The path to the FLAC file to read. - * \param cuesheet The address where the returned pointer will be - * stored. The \a cuesheet object must be deleted by - * the caller using FLAC__metadata_object_delete(). - * \assert - * \code filename != NULL \endcode - * \code cuesheet != NULL \endcode - * \retval FLAC__bool - * \c true if a valid CUESHEET block was read from \a filename, - * and \a *cuesheet will be set to the address of the metadata - * structure. Returns \c false if there was a memory allocation - * error, a file decoder error, or the file contained no CUESHEET - * block, and \a *cuesheet will be set to \c NULL. - */ -FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__StreamMetadata **cuesheet); - -/** Read a PICTURE metadata block of the given FLAC file. This - * function will try to skip any ID3v2 tag at the head of the file. - * Since there can be more than one PICTURE block in a file, this - * function takes a number of parameters that act as constraints to - * the search. The PICTURE block with the largest area matching all - * the constraints will be returned, or \a *picture will be set to - * \c NULL if there was no such block. - * - * \param filename The path to the FLAC file to read. - * \param picture The address where the returned pointer will be - * stored. The \a picture object must be deleted by - * the caller using FLAC__metadata_object_delete(). - * \param type The desired picture type. Use \c -1 to mean - * "any type". - * \param mime_type The desired MIME type, e.g. "image/jpeg". The - * string will be matched exactly. Use \c NULL to - * mean "any MIME type". - * \param description The desired description. The string will be - * matched exactly. Use \c NULL to mean "any - * description". - * \param max_width The maximum width in pixels desired. Use - * \c (uint32_t)(-1) to mean "any width". - * \param max_height The maximum height in pixels desired. Use - * \c (uint32_t)(-1) to mean "any height". - * \param max_depth The maximum color depth in bits-per-pixel desired. - * Use \c (uint32_t)(-1) to mean "any depth". - * \param max_colors The maximum number of colors desired. Use - * \c (uint32_t)(-1) to mean "any number of colors". - * \assert - * \code filename != NULL \endcode - * \code picture != NULL \endcode - * \retval FLAC__bool - * \c true if a valid PICTURE block was read from \a filename, - * and \a *picture will be set to the address of the metadata - * structure. Returns \c false if there was a memory allocation - * error, a file decoder error, or the file contained no PICTURE - * block, and \a *picture will be set to \c NULL. - */ -FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors); - -/* \} */ - - -/** \defgroup flac_metadata_level1 FLAC/metadata.h: metadata level 1 interface - * \ingroup flac_metadata - * - * \brief - * The level 1 interface provides read-write access to FLAC file metadata and - * operates directly on the FLAC file. - * - * The general usage of this interface is: - * - * - Create an iterator using FLAC__metadata_simple_iterator_new() - * - Attach it to a file using FLAC__metadata_simple_iterator_init() and check - * the exit code. Call FLAC__metadata_simple_iterator_is_writable() to - * see if the file is writable, or only read access is allowed. - * - Use FLAC__metadata_simple_iterator_next() and - * FLAC__metadata_simple_iterator_prev() to traverse the blocks. - * This is does not read the actual blocks themselves. - * FLAC__metadata_simple_iterator_next() is relatively fast. - * FLAC__metadata_simple_iterator_prev() is slower since it needs to search - * forward from the front of the file. - * - Use FLAC__metadata_simple_iterator_get_block_type() or - * FLAC__metadata_simple_iterator_get_block() to access the actual data at - * the current iterator position. The returned object is yours to modify - * and free. - * - Use FLAC__metadata_simple_iterator_set_block() to write a modified block - * back. You must have write permission to the original file. Make sure to - * read the whole comment to FLAC__metadata_simple_iterator_set_block() - * below. - * - Use FLAC__metadata_simple_iterator_insert_block_after() to add new blocks. - * Use the object creation functions from - * \link flac_metadata_object here \endlink to generate new objects. - * - Use FLAC__metadata_simple_iterator_delete_block() to remove the block - * currently referred to by the iterator, or replace it with padding. - * - Destroy the iterator with FLAC__metadata_simple_iterator_delete() when - * finished. - * - * \note - * The FLAC file remains open the whole time between - * FLAC__metadata_simple_iterator_init() and - * FLAC__metadata_simple_iterator_delete(), so make sure you are not altering - * the file during this time. - * - * \note - * Do not modify the \a is_last, \a length, or \a type fields of returned - * FLAC__StreamMetadata objects. These are managed automatically. - * - * \note - * If any of the modification functions - * (FLAC__metadata_simple_iterator_set_block(), - * FLAC__metadata_simple_iterator_delete_block(), - * FLAC__metadata_simple_iterator_insert_block_after(), etc.) return \c false, - * you should delete the iterator as it may no longer be valid. - * - * \{ - */ - -struct FLAC__Metadata_SimpleIterator; -/** The opaque structure definition for the level 1 iterator type. - * See the - * \link flac_metadata_level1 metadata level 1 module \endlink - * for a detailed description. - */ -typedef struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator; - -/** Status type for FLAC__Metadata_SimpleIterator. - * - * The iterator's current status can be obtained by calling FLAC__metadata_simple_iterator_status(). - */ -typedef enum { - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK = 0, - /**< The iterator is in the normal OK state */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, - /**< The data passed into a function violated the function's usage criteria */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE, - /**< The iterator could not open the target file */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE, - /**< The iterator could not find the FLAC signature at the start of the file */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE, - /**< The iterator tried to write to a file that was not writable */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA, - /**< The iterator encountered input that does not conform to the FLAC metadata specification */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR, - /**< The iterator encountered an error while reading the FLAC file */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, - /**< The iterator encountered an error while seeking in the FLAC file */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR, - /**< The iterator encountered an error while writing the FLAC file */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR, - /**< The iterator encountered an error renaming the FLAC file */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR, - /**< The iterator encountered an error removing the temporary file */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR, - /**< Memory allocation failed */ - - FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR - /**< The caller violated an assertion or an unexpected error occurred */ - -} FLAC__Metadata_SimpleIteratorStatus; - -/** Maps a FLAC__Metadata_SimpleIteratorStatus to a C string. - * - * Using a FLAC__Metadata_SimpleIteratorStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[]; - - -/** Create a new iterator instance. - * - * \retval FLAC__Metadata_SimpleIterator* - * \c NULL if there was an error allocating memory, else the new instance. - */ -FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new(void); - -/** Free an iterator instance. Deletes the object pointed to by \a iterator. - * - * \param iterator A pointer to an existing iterator. - * \assert - * \code iterator != NULL \endcode - */ -FLAC_API void FLAC__metadata_simple_iterator_delete(FLAC__Metadata_SimpleIterator *iterator); - -/** Get the current status of the iterator. Call this after a function - * returns \c false to get the reason for the error. Also resets the status - * to FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK. - * - * \param iterator A pointer to an existing iterator. - * \assert - * \code iterator != NULL \endcode - * \retval FLAC__Metadata_SimpleIteratorStatus - * The current status of the iterator. - */ -FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status(FLAC__Metadata_SimpleIterator *iterator); - -/** Initialize the iterator to point to the first metadata block in the - * given FLAC file. - * - * On Windows, filename must be a UTF-8 encoded filename, which libFLAC - * internally translates to an appropriate representation to use with - * _wfopen. On all other systems, filename is passed to fopen without - * any translation. - * - * \param iterator A pointer to an existing iterator. - * \param filename The path to the FLAC file. - * \param read_only If \c true, the FLAC file will be opened - * in read-only mode; if \c false, the FLAC - * file will be opened for edit even if no - * edits are performed. - * \param preserve_file_stats If \c true, the owner and modification - * time will be preserved even if the FLAC - * file is written to. - * \assert - * \code iterator != NULL \endcode - * \code filename != NULL \endcode - * \retval FLAC__bool - * \c false if a memory allocation error occurs, the file can't be - * opened, or another error occurs, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool read_only, FLAC__bool preserve_file_stats); - -/** Returns \c true if the FLAC file is writable. If \c false, calls to - * FLAC__metadata_simple_iterator_set_block() and - * FLAC__metadata_simple_iterator_insert_block_after() will fail. - * - * \param iterator A pointer to an existing iterator. - * \assert - * \code iterator != NULL \endcode - * \retval FLAC__bool - * See above. - */ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable(const FLAC__Metadata_SimpleIterator *iterator); - -/** Moves the iterator forward one metadata block, returning \c false if - * already at the end. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \retval FLAC__bool - * \c false if already at the last metadata block of the chain, else - * \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIterator *iterator); - -/** Moves the iterator backward one metadata block, returning \c false if - * already at the beginning. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \retval FLAC__bool - * \c false if already at the first metadata block of the chain, else - * \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator); - -/** Returns a flag telling if the current metadata block is the last. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \retval FLAC__bool - * \c true if the current metadata block is the last in the file, - * else \c false. - */ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_SimpleIterator *iterator); - -/** Get the offset of the metadata block at the current position. This - * avoids reading the actual block data which can save time for large - * blocks. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \retval off_t - * The offset of the metadata block at the current iterator position. - * This is the byte offset relative to the beginning of the file of - * the current metadata block's header. - */ -FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator); - -/** Get the type of the metadata block at the current position. This - * avoids reading the actual block data which can save time for large - * blocks. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \retval FLAC__MetadataType - * The type of the metadata block at the current iterator position. - */ -FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator); - -/** Get the length of the metadata block at the current position. This - * avoids reading the actual block data which can save time for large - * blocks. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \retval uint32_t - * The length of the metadata block at the current iterator position. - * The is same length as that in the - * metadata block header, - * i.e. the length of the metadata body that follows the header. - */ -FLAC_API uint32_t FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator); - -/** Get the application ID of the \c APPLICATION block at the current - * position. This avoids reading the actual block data which can save - * time for large blocks. - * - * \param iterator A pointer to an existing initialized iterator. - * \param id A pointer to a buffer of at least \c 4 bytes where - * the ID will be stored. - * \assert - * \code iterator != NULL \endcode - * \code id != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \retval FLAC__bool - * \c true if the ID was successfully read, else \c false, in which - * case you should check FLAC__metadata_simple_iterator_status() to - * find out why. If the status is - * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, then the - * current metadata block is not an \c APPLICATION block. Otherwise - * if the status is - * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR or - * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, an I/O error - * occurred and the iterator can no longer be used. - */ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id); - -/** Get the metadata block at the current position. You can modify the - * block but must use FLAC__metadata_simple_iterator_set_block() to - * write it back to the FLAC file. - * - * You must call FLAC__metadata_object_delete() on the returned object - * when you are finished with it. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \retval FLAC__StreamMetadata* - * The current metadata block, or \c NULL if there was a memory - * allocation error. - */ -FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator); - -/** Write a block back to the FLAC file. This function tries to be - * as efficient as possible; how the block is actually written is - * shown by the following: - * - * Existing block is a STREAMINFO block and the new block is a - * STREAMINFO block: the new block is written in place. Make sure - * you know what you're doing when changing the values of a - * STREAMINFO block. - * - * Existing block is a STREAMINFO block and the new block is a - * not a STREAMINFO block: this is an error since the first block - * must be a STREAMINFO block. Returns \c false without altering the - * file. - * - * Existing block is not a STREAMINFO block and the new block is a - * STREAMINFO block: this is an error since there may be only one - * STREAMINFO block. Returns \c false without altering the file. - * - * Existing block and new block are the same length: the existing - * block will be replaced by the new block, written in place. - * - * Existing block is longer than new block: if use_padding is \c true, - * the existing block will be overwritten in place with the new - * block followed by a PADDING block, if possible, to make the total - * size the same as the existing block. Remember that a padding - * block requires at least four bytes so if the difference in size - * between the new block and existing block is less than that, the - * entire file will have to be rewritten, using the new block's - * exact size. If use_padding is \c false, the entire file will be - * rewritten, replacing the existing block by the new block. - * - * Existing block is shorter than new block: if use_padding is \c true, - * the function will try and expand the new block into the following - * PADDING block, if it exists and doing so won't shrink the PADDING - * block to less than 4 bytes. If there is no following PADDING - * block, or it will shrink to less than 4 bytes, or use_padding is - * \c false, the entire file is rewritten, replacing the existing block - * with the new block. Note that in this case any following PADDING - * block is preserved as is. - * - * After writing the block, the iterator will remain in the same - * place, i.e. pointing to the new block. - * - * \param iterator A pointer to an existing initialized iterator. - * \param block The block to set. - * \param use_padding See above. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \code block != NULL \endcode - * \retval FLAC__bool - * \c true if successful, else \c false. - */ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding); - -/** This is similar to FLAC__metadata_simple_iterator_set_block() - * except that instead of writing over an existing block, it appends - * a block after the existing block. \a use_padding is again used to - * tell the function to try an expand into following padding in an - * attempt to avoid rewriting the entire file. - * - * This function will fail and return \c false if given a STREAMINFO - * block. - * - * After writing the block, the iterator will be pointing to the - * new block. - * - * \param iterator A pointer to an existing initialized iterator. - * \param block The block to set. - * \param use_padding See above. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \code block != NULL \endcode - * \retval FLAC__bool - * \c true if successful, else \c false. - */ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding); - -/** Deletes the block at the current position. This will cause the - * entire FLAC file to be rewritten, unless \a use_padding is \c true, - * in which case the block will be replaced by an equal-sized PADDING - * block. The iterator will be left pointing to the block before the - * one just deleted. - * - * You may not delete the STREAMINFO block. - * - * \param iterator A pointer to an existing initialized iterator. - * \param use_padding See above. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_simple_iterator_init() - * \retval FLAC__bool - * \c true if successful, else \c false. - */ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding); - -/* \} */ - - -/** \defgroup flac_metadata_level2 FLAC/metadata.h: metadata level 2 interface - * \ingroup flac_metadata - * - * \brief - * The level 2 interface provides read-write access to FLAC file metadata; - * all metadata is read into memory, operated on in memory, and then written - * to file, which is more efficient than level 1 when editing multiple blocks. - * - * Currently Ogg FLAC is supported for read only, via - * FLAC__metadata_chain_read_ogg() but a subsequent - * FLAC__metadata_chain_write() will fail. - * - * The general usage of this interface is: - * - * - Create a new chain using FLAC__metadata_chain_new(). A chain is a - * linked list of FLAC metadata blocks. - * - Read all metadata into the chain from a FLAC file using - * FLAC__metadata_chain_read() or FLAC__metadata_chain_read_ogg() and - * check the status. - * - Optionally, consolidate the padding using - * FLAC__metadata_chain_merge_padding() or - * FLAC__metadata_chain_sort_padding(). - * - Create a new iterator using FLAC__metadata_iterator_new() - * - Initialize the iterator to point to the first element in the chain - * using FLAC__metadata_iterator_init() - * - Traverse the chain using FLAC__metadata_iterator_next and - * FLAC__metadata_iterator_prev(). - * - Get a block for reading or modification using - * FLAC__metadata_iterator_get_block(). The pointer to the object - * inside the chain is returned, so the block is yours to modify. - * Changes will be reflected in the FLAC file when you write the - * chain. You can also add and delete blocks (see functions below). - * - When done, write out the chain using FLAC__metadata_chain_write(). - * Make sure to read the whole comment to the function below. - * - Delete the chain using FLAC__metadata_chain_delete(). - * - * \note - * Even though the FLAC file is not open while the chain is being - * manipulated, you must not alter the file externally during - * this time. The chain assumes the FLAC file will not change - * between the time of FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg() - * and FLAC__metadata_chain_write(). - * - * \note - * Do not modify the is_last, length, or type fields of returned - * FLAC__StreamMetadata objects. These are managed automatically. - * - * \note - * The metadata objects returned by FLAC__metadata_iterator_get_block() - * are owned by the chain; do not FLAC__metadata_object_delete() them. - * In the same way, blocks passed to FLAC__metadata_iterator_set_block() - * become owned by the chain and they will be deleted when the chain is - * deleted. - * - * \{ - */ - -struct FLAC__Metadata_Chain; -/** The opaque structure definition for the level 2 chain type. - */ -typedef struct FLAC__Metadata_Chain FLAC__Metadata_Chain; - -struct FLAC__Metadata_Iterator; -/** The opaque structure definition for the level 2 iterator type. - */ -typedef struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator; - -typedef enum { - FLAC__METADATA_CHAIN_STATUS_OK = 0, - /**< The chain is in the normal OK state */ - - FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT, - /**< The data passed into a function violated the function's usage criteria */ - - FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE, - /**< The chain could not open the target file */ - - FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE, - /**< The chain could not find the FLAC signature at the start of the file */ - - FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE, - /**< The chain tried to write to a file that was not writable */ - - FLAC__METADATA_CHAIN_STATUS_BAD_METADATA, - /**< The chain encountered input that does not conform to the FLAC metadata specification */ - - FLAC__METADATA_CHAIN_STATUS_READ_ERROR, - /**< The chain encountered an error while reading the FLAC file */ - - FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR, - /**< The chain encountered an error while seeking in the FLAC file */ - - FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR, - /**< The chain encountered an error while writing the FLAC file */ - - FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR, - /**< The chain encountered an error renaming the FLAC file */ - - FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR, - /**< The chain encountered an error removing the temporary file */ - - FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR, - /**< Memory allocation failed */ - - FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR, - /**< The caller violated an assertion or an unexpected error occurred */ - - FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS, - /**< One or more of the required callbacks was NULL */ - - FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH, - /**< FLAC__metadata_chain_write() was called on a chain read by - * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), - * or - * FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile() - * was called on a chain read by - * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). - * Matching read/write methods must always be used. */ - - FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL - /**< FLAC__metadata_chain_write_with_callbacks() was called when the - * chain write requires a tempfile; use - * FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead. - * Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was - * called when the chain write does not require a tempfile; use - * FLAC__metadata_chain_write_with_callbacks() instead. - * Always check FLAC__metadata_chain_check_if_tempfile_needed() - * before writing via callbacks. */ - -} FLAC__Metadata_ChainStatus; - -/** Maps a FLAC__Metadata_ChainStatus to a C string. - * - * Using a FLAC__Metadata_ChainStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__Metadata_ChainStatusString[]; - -/*********** FLAC__Metadata_Chain ***********/ - -/** Create a new chain instance. - * - * \retval FLAC__Metadata_Chain* - * \c NULL if there was an error allocating memory, else the new instance. - */ -FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new(void); - -/** Free a chain instance. Deletes the object pointed to by \a chain. - * - * \param chain A pointer to an existing chain. - * \assert - * \code chain != NULL \endcode - */ -FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain); - -/** Get the current status of the chain. Call this after a function - * returns \c false to get the reason for the error. Also resets the - * status to FLAC__METADATA_CHAIN_STATUS_OK. - * - * \param chain A pointer to an existing chain. - * \assert - * \code chain != NULL \endcode - * \retval FLAC__Metadata_ChainStatus - * The current status of the chain. - */ -FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain); - -/** Read all metadata from a FLAC file into the chain. - * - * On Windows, filename must be a UTF-8 encoded filename, which libFLAC - * internally translates to an appropriate representation to use with - * _wfopen. On all other systems, filename is passed to fopen without - * any translation. - * - * \param chain A pointer to an existing chain. - * \param filename The path to the FLAC file to read. - * \assert - * \code chain != NULL \endcode - * \code filename != NULL \endcode - * \retval FLAC__bool - * \c true if a valid list of metadata blocks was read from - * \a filename, else \c false. On failure, check the status with - * FLAC__metadata_chain_status(). - */ -FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename); - -/** Read all metadata from an Ogg FLAC file into the chain. - * - * On Windows, filename must be a UTF-8 encoded filename, which libFLAC - * internally translates to an appropriate representation to use with - * _wfopen. On all other systems, filename is passed to fopen without - * any translation. - * - * \note Ogg FLAC metadata data writing is not supported yet and - * FLAC__metadata_chain_write() will fail. - * - * \param chain A pointer to an existing chain. - * \param filename The path to the Ogg FLAC file to read. - * \assert - * \code chain != NULL \endcode - * \code filename != NULL \endcode - * \retval FLAC__bool - * \c true if a valid list of metadata blocks was read from - * \a filename, else \c false. On failure, check the status with - * FLAC__metadata_chain_status(). - */ -FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg(FLAC__Metadata_Chain *chain, const char *filename); - -/** Read all metadata from a FLAC stream into the chain via I/O callbacks. - * - * The \a handle need only be open for reading, but must be seekable. - * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" - * for Windows). - * - * \param chain A pointer to an existing chain. - * \param handle The I/O handle of the FLAC stream to read. The - * handle will NOT be closed after the metadata is read; - * that is the duty of the caller. - * \param callbacks - * A set of callbacks to use for I/O. The mandatory - * callbacks are \a read, \a seek, and \a tell. - * \assert - * \code chain != NULL \endcode - * \retval FLAC__bool - * \c true if a valid list of metadata blocks was read from - * \a handle, else \c false. On failure, check the status with - * FLAC__metadata_chain_status(). - */ -FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks); - -/** Read all metadata from an Ogg FLAC stream into the chain via I/O callbacks. - * - * The \a handle need only be open for reading, but must be seekable. - * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" - * for Windows). - * - * \note Ogg FLAC metadata data writing is not supported yet and - * FLAC__metadata_chain_write() will fail. - * - * \param chain A pointer to an existing chain. - * \param handle The I/O handle of the Ogg FLAC stream to read. The - * handle will NOT be closed after the metadata is read; - * that is the duty of the caller. - * \param callbacks - * A set of callbacks to use for I/O. The mandatory - * callbacks are \a read, \a seek, and \a tell. - * \assert - * \code chain != NULL \endcode - * \retval FLAC__bool - * \c true if a valid list of metadata blocks was read from - * \a handle, else \c false. On failure, check the status with - * FLAC__metadata_chain_status(). - */ -FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks); - -/** Checks if writing the given chain would require the use of a - * temporary file, or if it could be written in place. - * - * Under certain conditions, padding can be utilized so that writing - * edited metadata back to the FLAC file does not require rewriting the - * entire file. If rewriting is required, then a temporary workfile is - * required. When writing metadata using callbacks, you must check - * this function to know whether to call - * FLAC__metadata_chain_write_with_callbacks() or - * FLAC__metadata_chain_write_with_callbacks_and_tempfile(). When - * writing with FLAC__metadata_chain_write(), the temporary file is - * handled internally. - * - * \param chain A pointer to an existing chain. - * \param use_padding - * Whether or not padding will be allowed to be used - * during the write. The value of \a use_padding given - * here must match the value later passed to - * FLAC__metadata_chain_write_with_callbacks() or - * FLAC__metadata_chain_write_with_callbacks_with_tempfile(). - * \assert - * \code chain != NULL \endcode - * \retval FLAC__bool - * \c true if writing the current chain would require a tempfile, or - * \c false if metadata can be written in place. - */ -FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding); - -/** Write all metadata out to the FLAC file. This function tries to be as - * efficient as possible; how the metadata is actually written is shown by - * the following: - * - * If the current chain is the same size as the existing metadata, the new - * data is written in place. - * - * If the current chain is longer than the existing metadata, and - * \a use_padding is \c true, and the last block is a PADDING block of - * sufficient length, the function will truncate the final padding block - * so that the overall size of the metadata is the same as the existing - * metadata, and then just rewrite the metadata. Otherwise, if not all of - * the above conditions are met, the entire FLAC file must be rewritten. - * If you want to use padding this way it is a good idea to call - * FLAC__metadata_chain_sort_padding() first so that you have the maximum - * amount of padding to work with, unless you need to preserve ordering - * of the PADDING blocks for some reason. - * - * If the current chain is shorter than the existing metadata, and - * \a use_padding is \c true, and the final block is a PADDING block, the padding - * is extended to make the overall size the same as the existing data. If - * \a use_padding is \c true and the last block is not a PADDING block, a new - * PADDING block is added to the end of the new data to make it the same - * size as the existing data (if possible, see the note to - * FLAC__metadata_simple_iterator_set_block() about the four byte limit) - * and the new data is written in place. If none of the above apply or - * \a use_padding is \c false, the entire FLAC file is rewritten. - * - * If \a preserve_file_stats is \c true, the owner and modification time will - * be preserved even if the FLAC file is written. - * - * For this write function to be used, the chain must have been read with - * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(), not - * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(). - * - * \param chain A pointer to an existing chain. - * \param use_padding See above. - * \param preserve_file_stats See above. - * \assert - * \code chain != NULL \endcode - * \retval FLAC__bool - * \c true if the write succeeded, else \c false. On failure, - * check the status with FLAC__metadata_chain_status(). - */ -FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats); - -/** Write all metadata out to a FLAC stream via callbacks. - * - * (See FLAC__metadata_chain_write() for the details on how padding is - * used to write metadata in place if possible.) - * - * The \a handle must be open for updating and be seekable. The - * equivalent minimum stdio fopen() file mode is \c "r+" (or \c "r+b" - * for Windows). - * - * For this write function to be used, the chain must have been read with - * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), - * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). - * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned - * \c false. - * - * \param chain A pointer to an existing chain. - * \param use_padding See FLAC__metadata_chain_write() - * \param handle The I/O handle of the FLAC stream to write. The - * handle will NOT be closed after the metadata is - * written; that is the duty of the caller. - * \param callbacks A set of callbacks to use for I/O. The mandatory - * callbacks are \a write and \a seek. - * \assert - * \code chain != NULL \endcode - * \retval FLAC__bool - * \c true if the write succeeded, else \c false. On failure, - * check the status with FLAC__metadata_chain_status(). - */ -FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks); - -/** Write all metadata out to a FLAC stream via callbacks. - * - * (See FLAC__metadata_chain_write() for the details on how padding is - * used to write metadata in place if possible.) - * - * This version of the write-with-callbacks function must be used when - * FLAC__metadata_chain_check_if_tempfile_needed() returns true. In - * this function, you must supply an I/O handle corresponding to the - * FLAC file to edit, and a temporary handle to which the new FLAC - * file will be written. It is the caller's job to move this temporary - * FLAC file on top of the original FLAC file to complete the metadata - * edit. - * - * The \a handle must be open for reading and be seekable. The - * equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb" - * for Windows). - * - * The \a temp_handle must be open for writing. The - * equivalent minimum stdio fopen() file mode is \c "w" (or \c "wb" - * for Windows). It should be an empty stream, or at least positioned - * at the start-of-file (in which case it is the caller's duty to - * truncate it on return). - * - * For this write function to be used, the chain must have been read with - * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), - * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). - * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned - * \c true. - * - * \param chain A pointer to an existing chain. - * \param use_padding See FLAC__metadata_chain_write() - * \param handle The I/O handle of the original FLAC stream to read. - * The handle will NOT be closed after the metadata is - * written; that is the duty of the caller. - * \param callbacks A set of callbacks to use for I/O on \a handle. - * The mandatory callbacks are \a read, \a seek, and - * \a eof. - * \param temp_handle The I/O handle of the FLAC stream to write. The - * handle will NOT be closed after the metadata is - * written; that is the duty of the caller. - * \param temp_callbacks - * A set of callbacks to use for I/O on temp_handle. - * The only mandatory callback is \a write. - * \assert - * \code chain != NULL \endcode - * \retval FLAC__bool - * \c true if the write succeeded, else \c false. On failure, - * check the status with FLAC__metadata_chain_status(). - */ -FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__IOHandle temp_handle, FLAC__IOCallbacks temp_callbacks); - -/** Merge adjacent PADDING blocks into a single block. - * - * \note This function does not write to the FLAC file, it only - * modifies the chain. - * - * \warning Any iterator on the current chain will become invalid after this - * call. You should delete the iterator and get a new one. - * - * \param chain A pointer to an existing chain. - * \assert - * \code chain != NULL \endcode - */ -FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain); - -/** This function will move all PADDING blocks to the end on the metadata, - * then merge them into a single block. - * - * \note This function does not write to the FLAC file, it only - * modifies the chain. - * - * \warning Any iterator on the current chain will become invalid after this - * call. You should delete the iterator and get a new one. - * - * \param chain A pointer to an existing chain. - * \assert - * \code chain != NULL \endcode - */ -FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain); - - -/*********** FLAC__Metadata_Iterator ***********/ - -/** Create a new iterator instance. - * - * \retval FLAC__Metadata_Iterator* - * \c NULL if there was an error allocating memory, else the new instance. - */ -FLAC_API FLAC__Metadata_Iterator *FLAC__metadata_iterator_new(void); - -/** Free an iterator instance. Deletes the object pointed to by \a iterator. - * - * \param iterator A pointer to an existing iterator. - * \assert - * \code iterator != NULL \endcode - */ -FLAC_API void FLAC__metadata_iterator_delete(FLAC__Metadata_Iterator *iterator); - -/** Initialize the iterator to point to the first metadata block in the - * given chain. - * - * \param iterator A pointer to an existing iterator. - * \param chain A pointer to an existing and initialized (read) chain. - * \assert - * \code iterator != NULL \endcode - * \code chain != NULL \endcode - */ -FLAC_API void FLAC__metadata_iterator_init(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain); - -/** Moves the iterator forward one metadata block, returning \c false if - * already at the end. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_iterator_init() - * \retval FLAC__bool - * \c false if already at the last metadata block of the chain, else - * \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_iterator_next(FLAC__Metadata_Iterator *iterator); - -/** Moves the iterator backward one metadata block, returning \c false if - * already at the beginning. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_iterator_init() - * \retval FLAC__bool - * \c false if already at the first metadata block of the chain, else - * \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_iterator_prev(FLAC__Metadata_Iterator *iterator); - -/** Get the type of the metadata block at the current position. - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_iterator_init() - * \retval FLAC__MetadataType - * The type of the metadata block at the current iterator position. - */ -FLAC_API FLAC__MetadataType FLAC__metadata_iterator_get_block_type(const FLAC__Metadata_Iterator *iterator); - -/** Get the metadata block at the current position. You can modify - * the block in place but must write the chain before the changes - * are reflected to the FLAC file. You do not need to call - * FLAC__metadata_iterator_set_block() to reflect the changes; - * the pointer returned by FLAC__metadata_iterator_get_block() - * points directly into the chain. - * - * \warning - * Do not call FLAC__metadata_object_delete() on the returned object; - * to delete a block use FLAC__metadata_iterator_delete_block(). - * - * \param iterator A pointer to an existing initialized iterator. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_iterator_init() - * \retval FLAC__StreamMetadata* - * The current metadata block. - */ -FLAC_API FLAC__StreamMetadata *FLAC__metadata_iterator_get_block(FLAC__Metadata_Iterator *iterator); - -/** Set the metadata block at the current position, replacing the existing - * block. The new block passed in becomes owned by the chain and it will be - * deleted when the chain is deleted. - * - * \param iterator A pointer to an existing initialized iterator. - * \param block A pointer to a metadata block. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_iterator_init() - * \code block != NULL \endcode - * \retval FLAC__bool - * \c false if the conditions in the above description are not met, or - * a memory allocation error occurs, otherwise \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_iterator_set_block(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block); - -/** Removes the current block from the chain. If \a replace_with_padding is - * \c true, the block will instead be replaced with a padding block of equal - * size. You can not delete the STREAMINFO block. The iterator will be - * left pointing to the block before the one just "deleted", even if - * \a replace_with_padding is \c true. - * - * \param iterator A pointer to an existing initialized iterator. - * \param replace_with_padding See above. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_iterator_init() - * \retval FLAC__bool - * \c false if the conditions in the above description are not met, - * otherwise \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_iterator_delete_block(FLAC__Metadata_Iterator *iterator, FLAC__bool replace_with_padding); - -/** Insert a new block before the current block. You cannot insert a block - * before the first STREAMINFO block. You cannot insert a STREAMINFO block - * as there can be only one, the one that already exists at the head when you - * read in a chain. The chain takes ownership of the new block and it will be - * deleted when the chain is deleted. The iterator will be left pointing to - * the new block. - * - * \param iterator A pointer to an existing initialized iterator. - * \param block A pointer to a metadata block to insert. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_iterator_init() - * \retval FLAC__bool - * \c false if the conditions in the above description are not met, or - * a memory allocation error occurs, otherwise \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_before(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block); - -/** Insert a new block after the current block. You cannot insert a STREAMINFO - * block as there can be only one, the one that already exists at the head when - * you read in a chain. The chain takes ownership of the new block and it will - * be deleted when the chain is deleted. The iterator will be left pointing to - * the new block. - * - * \param iterator A pointer to an existing initialized iterator. - * \param block A pointer to a metadata block to insert. - * \assert - * \code iterator != NULL \endcode - * \a iterator has been successfully initialized with - * FLAC__metadata_iterator_init() - * \retval FLAC__bool - * \c false if the conditions in the above description are not met, or - * a memory allocation error occurs, otherwise \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block); - -/* \} */ - - -/** \defgroup flac_metadata_object FLAC/metadata.h: metadata object methods - * \ingroup flac_metadata - * - * \brief - * This module contains methods for manipulating FLAC metadata objects. - * - * Since many are variable length we have to be careful about the memory - * management. We decree that all pointers to data in the object are - * owned by the object and memory-managed by the object. - * - * Use the FLAC__metadata_object_new() and FLAC__metadata_object_delete() - * functions to create all instances. When using the - * FLAC__metadata_object_set_*() functions to set pointers to data, set - * \a copy to \c true to have the function make it's own copy of the data, or - * to \c false to give the object ownership of your data. In the latter case - * your pointer must be freeable by free() and will be free()d when the object - * is FLAC__metadata_object_delete()d. It is legal to pass a null pointer as - * the data pointer to a FLAC__metadata_object_set_*() function as long as - * the length argument is 0 and the \a copy argument is \c false. - * - * The FLAC__metadata_object_new() and FLAC__metadata_object_clone() function - * will return \c NULL in the case of a memory allocation error, otherwise a new - * object. The FLAC__metadata_object_set_*() functions return \c false in the - * case of a memory allocation error. - * - * We don't have the convenience of C++ here, so note that the library relies - * on you to keep the types straight. In other words, if you pass, for - * example, a FLAC__StreamMetadata* that represents a STREAMINFO block to - * FLAC__metadata_object_application_set_data(), you will get an assertion - * failure. - * - * For convenience the FLAC__metadata_object_vorbiscomment_*() functions - * maintain a trailing NUL on each Vorbis comment entry. This is not counted - * toward the length or stored in the stream, but it can make working with plain - * comments (those that don't contain embedded-NULs in the value) easier. - * Entries passed into these functions have trailing NULs added if missing, and - * returned entries are guaranteed to have a trailing NUL. - * - * The FLAC__metadata_object_vorbiscomment_*() functions that take a Vorbis - * comment entry/name/value will first validate that it complies with the Vorbis - * comment specification and return false if it does not. - * - * There is no need to recalculate the length field on metadata blocks you - * have modified. They will be calculated automatically before they are - * written back to a file. - * - * \{ - */ - - -/** Create a new metadata object instance of the given type. - * - * The object will be "empty"; i.e. values and data pointers will be \c 0, - * with the exception of FLAC__METADATA_TYPE_VORBIS_COMMENT, which will have - * the vendor string set (but zero comments). - * - * Do not pass in a value greater than or equal to - * \a FLAC__METADATA_TYPE_UNDEFINED unless you really know what you're - * doing. - * - * \param type Type of object to create - * \retval FLAC__StreamMetadata* - * \c NULL if there was an error allocating memory or the type code is - * greater than FLAC__MAX_METADATA_TYPE_CODE, else the new instance. - */ -FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type); - -/** Create a copy of an existing metadata object. - * - * The copy is a "deep" copy, i.e. dynamically allocated data within the - * object is also copied. The caller takes ownership of the new block and - * is responsible for freeing it with FLAC__metadata_object_delete(). - * - * \param object Pointer to object to copy. - * \assert - * \code object != NULL \endcode - * \retval FLAC__StreamMetadata* - * \c NULL if there was an error allocating memory, else the new instance. - */ -FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_clone(const FLAC__StreamMetadata *object); - -/** Free a metadata object. Deletes the object pointed to by \a object. - * - * The delete is a "deep" delete, i.e. dynamically allocated data within the - * object is also deleted. - * - * \param object A pointer to an existing object. - * \assert - * \code object != NULL \endcode - */ -FLAC_API void FLAC__metadata_object_delete(FLAC__StreamMetadata *object); - -/** Compares two metadata objects. - * - * The compare is "deep", i.e. dynamically allocated data within the - * object is also compared. - * - * \param block1 A pointer to an existing object. - * \param block2 A pointer to an existing object. - * \assert - * \code block1 != NULL \endcode - * \code block2 != NULL \endcode - * \retval FLAC__bool - * \c true if objects are identical, else \c false. - */ -FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2); - -/** Sets the application data of an APPLICATION block. - * - * If \a copy is \c true, a copy of the data is stored; otherwise, the object - * takes ownership of the pointer. The existing data will be freed if this - * function is successful, otherwise the original data will remain if \a copy - * is \c true and malloc() fails. - * - * \note It is safe to pass a const pointer to \a data if \a copy is \c true. - * - * \param object A pointer to an existing APPLICATION object. - * \param data A pointer to the data to set. - * \param length The length of \a data in bytes. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_APPLICATION \endcode - * \code (data != NULL && length > 0) || - * (data == NULL && length == 0 && copy == false) \endcode - * \retval FLAC__bool - * \c false if \a copy is \c true and malloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, uint32_t length, FLAC__bool copy); - -/** Resize the seekpoint array. - * - * If the size shrinks, elements will truncated; if it grows, new placeholder - * points will be added to the end. If this function returns false, the - * object is left untouched. - * - * \param object A pointer to an existing SEEKTABLE object. - * \param new_num_points The desired length of the array; may be \c 0. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \code (object->data.seek_table.points == NULL && object->data.seek_table.num_points == 0) || - * (object->data.seek_table.points != NULL && object->data.seek_table.num_points > 0) \endcode - * \retval FLAC__bool - * \c false if memory allocation error, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, uint32_t new_num_points); - -/** Set a seekpoint in a seektable. - * - * \param object A pointer to an existing SEEKTABLE object. - * \param point_num Index into seekpoint array to set. - * \param point The point to set. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \code object->data.seek_table.num_points > point_num \endcode - */ -FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point); - -/** Insert a seekpoint into a seektable. - * - * \param object A pointer to an existing SEEKTABLE object. - * \param point_num Index into seekpoint array to set. - * \param point The point to set. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \code object->data.seek_table.num_points >= point_num \endcode - * \retval FLAC__bool - * \c false if memory allocation error, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point); - -/** Delete a seekpoint from a seektable. - * - * \param object A pointer to an existing SEEKTABLE object. - * \param point_num Index into seekpoint array to set. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \code object->data.seek_table.num_points > point_num \endcode - * \retval FLAC__bool - * \c false if memory allocation error, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, uint32_t point_num); - -/** Check a seektable to see if it conforms to the FLAC specification. - * See the format specification for limits on the contents of the - * seektable. - * - * \param object A pointer to an existing SEEKTABLE object. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \retval FLAC__bool - * \c false if seek table is illegal, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetadata *object); - -/** Append a number of placeholder points to the end of a seek table. - * - * \note - * As with the other ..._seektable_template_... functions, you should - * call FLAC__metadata_object_seektable_template_sort() when finished - * to make the seek table legal. - * - * \param object A pointer to an existing SEEKTABLE object. - * \param num The number of placeholder points to append. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \retval FLAC__bool - * \c false if memory allocation fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, uint32_t num); - -/** Append a specific seek point template to the end of a seek table. - * - * \note - * As with the other ..._seektable_template_... functions, you should - * call FLAC__metadata_object_seektable_template_sort() when finished - * to make the seek table legal. - * - * \param object A pointer to an existing SEEKTABLE object. - * \param sample_number The sample number of the seek point template. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \retval FLAC__bool - * \c false if memory allocation fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__StreamMetadata *object, FLAC__uint64 sample_number); - -/** Append specific seek point templates to the end of a seek table. - * - * \note - * As with the other ..._seektable_template_... functions, you should - * call FLAC__metadata_object_seektable_template_sort() when finished - * to make the seek table legal. - * - * \param object A pointer to an existing SEEKTABLE object. - * \param sample_numbers An array of sample numbers for the seek points. - * \param num The number of seek point templates to append. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \retval FLAC__bool - * \c false if memory allocation fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], uint32_t num); - -/** Append a set of evenly-spaced seek point templates to the end of a - * seek table. - * - * \note - * As with the other ..._seektable_template_... functions, you should - * call FLAC__metadata_object_seektable_template_sort() when finished - * to make the seek table legal. - * - * \param object A pointer to an existing SEEKTABLE object. - * \param num The number of placeholder points to append. - * \param total_samples The total number of samples to be encoded; - * the seekpoints will be spaced approximately - * \a total_samples / \a num samples apart. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \code total_samples > 0 \endcode - * \retval FLAC__bool - * \c false if memory allocation fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, uint32_t num, FLAC__uint64 total_samples); - -/** Append a set of evenly-spaced seek point templates to the end of a - * seek table. - * - * \note - * As with the other ..._seektable_template_... functions, you should - * call FLAC__metadata_object_seektable_template_sort() when finished - * to make the seek table legal. - * - * \param object A pointer to an existing SEEKTABLE object. - * \param samples The number of samples apart to space the placeholder - * points. The first point will be at sample \c 0, the - * second at sample \a samples, then 2*\a samples, and - * so on. As long as \a samples and \a total_samples - * are greater than \c 0, there will always be at least - * one seekpoint at sample \c 0. - * \param total_samples The total number of samples to be encoded; - * the seekpoints will be spaced - * \a samples samples apart. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \code samples > 0 \endcode - * \code total_samples > 0 \endcode - * \retval FLAC__bool - * \c false if memory allocation fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, uint32_t samples, FLAC__uint64 total_samples); - -/** Sort a seek table's seek points according to the format specification, - * removing duplicates. - * - * \param object A pointer to a seek table to be sorted. - * \param compact If \c false, behaves like FLAC__format_seektable_sort(). - * If \c true, duplicates are deleted and the seek table is - * shrunk appropriately; the number of placeholder points - * present in the seek table will be the same after the call - * as before. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode - * \retval FLAC__bool - * \c false if realloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact); - -/** Sets the vendor string in a VORBIS_COMMENT block. - * - * For convenience, a trailing NUL is added to the entry if it doesn't have - * one already. - * - * If \a copy is \c true, a copy of the entry is stored; otherwise, the object - * takes ownership of the \c entry.entry pointer. - * - * \note If this function returns \c false, the caller still owns the - * pointer. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param entry The entry to set the vendor string to. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \code (entry.entry != NULL && entry.length > 0) || - * (entry.entry == NULL && entry.length == 0) \endcode - * \retval FLAC__bool - * \c false if memory allocation fails or \a entry does not comply with the - * Vorbis comment specification, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); - -/** Resize the comment array. - * - * If the size shrinks, elements will truncated; if it grows, new empty - * fields will be added to the end. If this function returns false, the - * object is left untouched. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param new_num_comments The desired length of the array; may be \c 0. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \code (object->data.vorbis_comment.comments == NULL && object->data.vorbis_comment.num_comments == 0) || - * (object->data.vorbis_comment.comments != NULL && object->data.vorbis_comment.num_comments > 0) \endcode - * \retval FLAC__bool - * \c false if memory allocation fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, uint32_t new_num_comments); - -/** Sets a comment in a VORBIS_COMMENT block. - * - * For convenience, a trailing NUL is added to the entry if it doesn't have - * one already. - * - * If \a copy is \c true, a copy of the entry is stored; otherwise, the object - * takes ownership of the \c entry.entry pointer. - * - * \note If this function returns \c false, the caller still owns the - * pointer. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param comment_num Index into comment array to set. - * \param entry The entry to set the comment to. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \code comment_num < object->data.vorbis_comment.num_comments \endcode - * \code (entry.entry != NULL && entry.length > 0) || - * (entry.entry == NULL && entry.length == 0) \endcode - * \retval FLAC__bool - * \c false if memory allocation fails or \a entry does not comply with the - * Vorbis comment specification, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); - -/** Insert a comment in a VORBIS_COMMENT block at the given index. - * - * For convenience, a trailing NUL is added to the entry if it doesn't have - * one already. - * - * If \a copy is \c true, a copy of the entry is stored; otherwise, the object - * takes ownership of the \c entry.entry pointer. - * - * \note If this function returns \c false, the caller still owns the - * pointer. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param comment_num The index at which to insert the comment. The comments - * at and after \a comment_num move right one position. - * To append a comment to the end, set \a comment_num to - * \c object->data.vorbis_comment.num_comments . - * \param entry The comment to insert. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \code object->data.vorbis_comment.num_comments >= comment_num \endcode - * \code (entry.entry != NULL && entry.length > 0) || - * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode - * \retval FLAC__bool - * \c false if memory allocation fails or \a entry does not comply with the - * Vorbis comment specification, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); - -/** Appends a comment to a VORBIS_COMMENT block. - * - * For convenience, a trailing NUL is added to the entry if it doesn't have - * one already. - * - * If \a copy is \c true, a copy of the entry is stored; otherwise, the object - * takes ownership of the \c entry.entry pointer. - * - * \note If this function returns \c false, the caller still owns the - * pointer. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param entry The comment to insert. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \code (entry.entry != NULL && entry.length > 0) || - * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode - * \retval FLAC__bool - * \c false if memory allocation fails or \a entry does not comply with the - * Vorbis comment specification, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy); - -/** Replaces comments in a VORBIS_COMMENT block with a new one. - * - * For convenience, a trailing NUL is added to the entry if it doesn't have - * one already. - * - * Depending on the value of \a all, either all or just the first comment - * whose field name(s) match the given entry's name will be replaced by the - * given entry. If no comments match, \a entry will simply be appended. - * - * If \a copy is \c true, a copy of the entry is stored; otherwise, the object - * takes ownership of the \c entry.entry pointer. - * - * \note If this function returns \c false, the caller still owns the - * pointer. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param entry The comment to insert. - * \param all If \c true, all comments whose field name matches - * \a entry's field name will be removed, and \a entry will - * be inserted at the position of the first matching - * comment. If \c false, only the first comment whose - * field name matches \a entry's field name will be - * replaced with \a entry. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \code (entry.entry != NULL && entry.length > 0) || - * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode - * \retval FLAC__bool - * \c false if memory allocation fails or \a entry does not comply with the - * Vorbis comment specification, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool all, FLAC__bool copy); - -/** Delete a comment in a VORBIS_COMMENT block at the given index. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param comment_num The index of the comment to delete. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \code object->data.vorbis_comment.num_comments > comment_num \endcode - * \retval FLAC__bool - * \c false if realloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, uint32_t comment_num); - -/** Creates a Vorbis comment entry from NUL-terminated name and value strings. - * - * On return, the filled-in \a entry->entry pointer will point to malloc()ed - * memory and shall be owned by the caller. For convenience the entry will - * have a terminating NUL. - * - * \param entry A pointer to a Vorbis comment entry. The entry's - * \c entry pointer should not point to allocated - * memory as it will be overwritten. - * \param field_name The field name in ASCII, \c NUL terminated. - * \param field_value The field value in UTF-8, \c NUL terminated. - * \assert - * \code entry != NULL \endcode - * \code field_name != NULL \endcode - * \code field_value != NULL \endcode - * \retval FLAC__bool - * \c false if malloc() fails, or if \a field_name or \a field_value does - * not comply with the Vorbis comment specification, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, const char *field_value); - -/** Splits a Vorbis comment entry into NUL-terminated name and value strings. - * - * The returned pointers to name and value will be allocated by malloc() - * and shall be owned by the caller. - * - * \param entry An existing Vorbis comment entry. - * \param field_name The address of where the returned pointer to the - * field name will be stored. - * \param field_value The address of where the returned pointer to the - * field value will be stored. - * \assert - * \code (entry.entry != NULL && entry.length > 0) \endcode - * \code memchr(entry.entry, '=', entry.length) != NULL \endcode - * \code field_name != NULL \endcode - * \code field_value != NULL \endcode - * \retval FLAC__bool - * \c false if memory allocation fails or \a entry does not comply with the - * Vorbis comment specification, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(const FLAC__StreamMetadata_VorbisComment_Entry entry, char **field_name, char **field_value); - -/** Check if the given Vorbis comment entry's field name matches the given - * field name. - * - * \param entry An existing Vorbis comment entry. - * \param field_name The field name to check. - * \param field_name_length The length of \a field_name, not including the - * terminating \c NUL. - * \assert - * \code (entry.entry != NULL && entry.length > 0) \endcode - * \retval FLAC__bool - * \c true if the field names match, else \c false - */ -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, uint32_t field_name_length); - -/** Find a Vorbis comment with the given field name. - * - * The search begins at entry number \a offset; use an offset of 0 to - * search from the beginning of the comment array. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param offset The offset into the comment array from where to start - * the search. - * \param field_name The field name of the comment to find. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \code field_name != NULL \endcode - * \retval int - * The offset in the comment array of the first comment whose field - * name matches \a field_name, or \c -1 if no match was found. - */ -FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, uint32_t offset, const char *field_name); - -/** Remove first Vorbis comment matching the given field name. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param field_name The field name of comment to delete. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \retval int - * \c -1 for memory allocation error, \c 0 for no matching entries, - * \c 1 for one matching entry deleted. - */ -FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entry_matching(FLAC__StreamMetadata *object, const char *field_name); - -/** Remove all Vorbis comments matching the given field name. - * - * \param object A pointer to an existing VORBIS_COMMENT object. - * \param field_name The field name of comments to delete. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode - * \retval int - * \c -1 for memory allocation error, \c 0 for no matching entries, - * else the number of matching entries deleted. - */ -FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entries_matching(FLAC__StreamMetadata *object, const char *field_name); - -/** Create a new CUESHEET track instance. - * - * The object will be "empty"; i.e. values and data pointers will be \c 0. - * - * \retval FLAC__StreamMetadata_CueSheet_Track* - * \c NULL if there was an error allocating memory, else the new instance. - */ -FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_new(void); - -/** Create a copy of an existing CUESHEET track object. - * - * The copy is a "deep" copy, i.e. dynamically allocated data within the - * object is also copied. The caller takes ownership of the new object and - * is responsible for freeing it with - * FLAC__metadata_object_cuesheet_track_delete(). - * - * \param object Pointer to object to copy. - * \assert - * \code object != NULL \endcode - * \retval FLAC__StreamMetadata_CueSheet_Track* - * \c NULL if there was an error allocating memory, else the new instance. - */ -FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_clone(const FLAC__StreamMetadata_CueSheet_Track *object); - -/** Delete a CUESHEET track object - * - * \param object A pointer to an existing CUESHEET track object. - * \assert - * \code object != NULL \endcode - */ -FLAC_API void FLAC__metadata_object_cuesheet_track_delete(FLAC__StreamMetadata_CueSheet_Track *object); - -/** Resize a track's index point array. - * - * If the size shrinks, elements will truncated; if it grows, new blank - * indices will be added to the end. If this function returns false, the - * track object is left untouched. - * - * \param object A pointer to an existing CUESHEET object. - * \param track_num The index of the track to modify. NOTE: this is not - * necessarily the same as the track's \a number field. - * \param new_num_indices The desired length of the array; may be \c 0. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \code object->data.cue_sheet.num_tracks > track_num \endcode - * \code (object->data.cue_sheet.tracks[track_num].indices == NULL && object->data.cue_sheet.tracks[track_num].num_indices == 0) || - * (object->data.cue_sheet.tracks[track_num].indices != NULL && object->data.cue_sheet.tracks[track_num].num_indices > 0) \endcode - * \retval FLAC__bool - * \c false if memory allocation error, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t new_num_indices); - -/** Insert an index point in a CUESHEET track at the given index. - * - * \param object A pointer to an existing CUESHEET object. - * \param track_num The index of the track to modify. NOTE: this is not - * necessarily the same as the track's \a number field. - * \param index_num The index into the track's index array at which to - * insert the index point. NOTE: this is not necessarily - * the same as the index point's \a number field. The - * indices at and after \a index_num move right one - * position. To append an index point to the end, set - * \a index_num to - * \c object->data.cue_sheet.tracks[track_num].num_indices . - * \param index The index point to insert. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \code object->data.cue_sheet.num_tracks > track_num \endcode - * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode - * \retval FLAC__bool - * \c false if realloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num, FLAC__StreamMetadata_CueSheet_Index index); - -/** Insert a blank index point in a CUESHEET track at the given index. - * - * A blank index point is one in which all field values are zero. - * - * \param object A pointer to an existing CUESHEET object. - * \param track_num The index of the track to modify. NOTE: this is not - * necessarily the same as the track's \a number field. - * \param index_num The index into the track's index array at which to - * insert the index point. NOTE: this is not necessarily - * the same as the index point's \a number field. The - * indices at and after \a index_num move right one - * position. To append an index point to the end, set - * \a index_num to - * \c object->data.cue_sheet.tracks[track_num].num_indices . - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \code object->data.cue_sheet.num_tracks > track_num \endcode - * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode - * \retval FLAC__bool - * \c false if realloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num); - -/** Delete an index point in a CUESHEET track at the given index. - * - * \param object A pointer to an existing CUESHEET object. - * \param track_num The index into the track array of the track to - * modify. NOTE: this is not necessarily the same - * as the track's \a number field. - * \param index_num The index into the track's index array of the index - * to delete. NOTE: this is not necessarily the same - * as the index's \a number field. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \code object->data.cue_sheet.num_tracks > track_num \endcode - * \code object->data.cue_sheet.tracks[track_num].num_indices > index_num \endcode - * \retval FLAC__bool - * \c false if realloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num); - -/** Resize the track array. - * - * If the size shrinks, elements will truncated; if it grows, new blank - * tracks will be added to the end. If this function returns false, the - * object is left untouched. - * - * \param object A pointer to an existing CUESHEET object. - * \param new_num_tracks The desired length of the array; may be \c 0. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \code (object->data.cue_sheet.tracks == NULL && object->data.cue_sheet.num_tracks == 0) || - * (object->data.cue_sheet.tracks != NULL && object->data.cue_sheet.num_tracks > 0) \endcode - * \retval FLAC__bool - * \c false if memory allocation error, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, uint32_t new_num_tracks); - -/** Sets a track in a CUESHEET block. - * - * If \a copy is \c true, a copy of the track is stored; otherwise, the object - * takes ownership of the \a track pointer. - * - * \param object A pointer to an existing CUESHEET object. - * \param track_num Index into track array to set. NOTE: this is not - * necessarily the same as the track's \a number field. - * \param track The track to set the track to. You may safely pass in - * a const pointer if \a copy is \c true. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \code track_num < object->data.cue_sheet.num_tracks \endcode - * \code (track->indices != NULL && track->num_indices > 0) || - * (track->indices == NULL && track->num_indices == 0) \endcode - * \retval FLAC__bool - * \c false if \a copy is \c true and malloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy); - -/** Insert a track in a CUESHEET block at the given index. - * - * If \a copy is \c true, a copy of the track is stored; otherwise, the object - * takes ownership of the \a track pointer. - * - * \param object A pointer to an existing CUESHEET object. - * \param track_num The index at which to insert the track. NOTE: this - * is not necessarily the same as the track's \a number - * field. The tracks at and after \a track_num move right - * one position. To append a track to the end, set - * \a track_num to \c object->data.cue_sheet.num_tracks . - * \param track The track to insert. You may safely pass in a const - * pointer if \a copy is \c true. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \code object->data.cue_sheet.num_tracks >= track_num \endcode - * \retval FLAC__bool - * \c false if \a copy is \c true and malloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy); - -/** Insert a blank track in a CUESHEET block at the given index. - * - * A blank track is one in which all field values are zero. - * - * \param object A pointer to an existing CUESHEET object. - * \param track_num The index at which to insert the track. NOTE: this - * is not necessarily the same as the track's \a number - * field. The tracks at and after \a track_num move right - * one position. To append a track to the end, set - * \a track_num to \c object->data.cue_sheet.num_tracks . - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \code object->data.cue_sheet.num_tracks >= track_num \endcode - * \retval FLAC__bool - * \c false if \a copy is \c true and malloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, uint32_t track_num); - -/** Delete a track in a CUESHEET block at the given index. - * - * \param object A pointer to an existing CUESHEET object. - * \param track_num The index into the track array of the track to - * delete. NOTE: this is not necessarily the same - * as the track's \a number field. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \code object->data.cue_sheet.num_tracks > track_num \endcode - * \retval FLAC__bool - * \c false if realloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, uint32_t track_num); - -/** Check a cue sheet to see if it conforms to the FLAC specification. - * See the format specification for limits on the contents of the - * cue sheet. - * - * \param object A pointer to an existing CUESHEET object. - * \param check_cd_da_subset If \c true, check CUESHEET against more - * stringent requirements for a CD-DA (audio) disc. - * \param violation Address of a pointer to a string. If there is a - * violation, a pointer to a string explanation of the - * violation will be returned here. \a violation may be - * \c NULL if you don't need the returned string. Do not - * free the returned string; it will always point to static - * data. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \retval FLAC__bool - * \c false if cue sheet is illegal, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_is_legal(const FLAC__StreamMetadata *object, FLAC__bool check_cd_da_subset, const char **violation); - -/** Calculate and return the CDDB/freedb ID for a cue sheet. The function - * assumes the cue sheet corresponds to a CD; the result is undefined - * if the cuesheet's is_cd bit is not set. - * - * \param object A pointer to an existing CUESHEET object. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode - * \retval FLAC__uint32 - * The unsigned integer representation of the CDDB/freedb ID - */ -FLAC_API FLAC__uint32 FLAC__metadata_object_cuesheet_calculate_cddb_id(const FLAC__StreamMetadata *object); - -/** Sets the MIME type of a PICTURE block. - * - * If \a copy is \c true, a copy of the string is stored; otherwise, the object - * takes ownership of the pointer. The existing string will be freed if this - * function is successful, otherwise the original string will remain if \a copy - * is \c true and malloc() fails. - * - * \note It is safe to pass a const pointer to \a mime_type if \a copy is \c true. - * - * \param object A pointer to an existing PICTURE object. - * \param mime_type A pointer to the MIME type string. The string must be - * ASCII characters 0x20-0x7e, NUL-terminated. No validation - * is done. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode - * \code (mime_type != NULL) \endcode - * \retval FLAC__bool - * \c false if \a copy is \c true and malloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_picture_set_mime_type(FLAC__StreamMetadata *object, char *mime_type, FLAC__bool copy); - -/** Sets the description of a PICTURE block. - * - * If \a copy is \c true, a copy of the string is stored; otherwise, the object - * takes ownership of the pointer. The existing string will be freed if this - * function is successful, otherwise the original string will remain if \a copy - * is \c true and malloc() fails. - * - * \note It is safe to pass a const pointer to \a description if \a copy is \c true. - * - * \param object A pointer to an existing PICTURE object. - * \param description A pointer to the description string. The string must be - * valid UTF-8, NUL-terminated. No validation is done. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode - * \code (description != NULL) \endcode - * \retval FLAC__bool - * \c false if \a copy is \c true and malloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_picture_set_description(FLAC__StreamMetadata *object, FLAC__byte *description, FLAC__bool copy); - -/** Sets the picture data of a PICTURE block. - * - * If \a copy is \c true, a copy of the data is stored; otherwise, the object - * takes ownership of the pointer. Also sets the \a data_length field of the - * metadata object to what is passed in as the \a length parameter. The - * existing data will be freed if this function is successful, otherwise the - * original data and data_length will remain if \a copy is \c true and - * malloc() fails. - * - * \note It is safe to pass a const pointer to \a data if \a copy is \c true. - * - * \param object A pointer to an existing PICTURE object. - * \param data A pointer to the data to set. - * \param length The length of \a data in bytes. - * \param copy See above. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode - * \code (data != NULL && length > 0) || - * (data == NULL && length == 0 && copy == false) \endcode - * \retval FLAC__bool - * \c false if \a copy is \c true and malloc() fails, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, FLAC__uint32 length, FLAC__bool copy); - -/** Check a PICTURE block to see if it conforms to the FLAC specification. - * See the format specification for limits on the contents of the - * PICTURE block. - * - * \param object A pointer to existing PICTURE block to be checked. - * \param violation Address of a pointer to a string. If there is a - * violation, a pointer to a string explanation of the - * violation will be returned here. \a violation may be - * \c NULL if you don't need the returned string. Do not - * free the returned string; it will always point to static - * data. - * \assert - * \code object != NULL \endcode - * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode - * \retval FLAC__bool - * \c false if PICTURE block is illegal, else \c true. - */ -FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMetadata *object, const char **violation); - - -/** Get the raw (binary) representation of a FLAC__StreamMetadata objeect. - * After use, free() the returned buffer. The length of the buffer is - * the length of the input metadata object plus 4 bytes for the header. - * - * \param object A pointer to metadata block to be converted. - * \assert - * \code object != NULL \endcode - * \retval FLAC__byte* - * \c NULL if there was an error, else a pointer to a buffer holding - * the requested data. - */ -FLAC_API FLAC__byte * FLAC__metadata_object_get_raw(const FLAC__StreamMetadata *object); - - -/** Turn a raw (binary) representation into a FLAC__StreamMetadata objeect. - * The returned object must be deleted with FLAC__metadata_object_delete() - * after use. - * - * \param buffer A pointer to a buffer containing a binary representation - * to be converted to a FLAC__StreamMetadata object - * \param length The length of the supplied buffer - * \retval FLAC__StreamMetadata* - * \c NULL if there was an error, else a pointer to a FLAC__StreamMetadata - * holding the requested data. - */ - -FLAC_API FLAC__StreamMetadata * FLAC__metadata_object_set_raw(FLAC__byte *buffer, FLAC__uint32 length); -/* \} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/FLAC/ordinals.h b/Engine/lib/flac/include/FLAC/ordinals.h deleted file mode 100644 index d61aac578..000000000 --- a/Engine/lib/flac/include/FLAC/ordinals.h +++ /dev/null @@ -1,55 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__ORDINALS_H -#define FLAC__ORDINALS_H - -/* This of course assumes C99 headers */ - -#include -#include - -typedef int8_t FLAC__int8; -typedef uint8_t FLAC__uint8; - -typedef int16_t FLAC__int16; -typedef int32_t FLAC__int32; -typedef int64_t FLAC__int64; -typedef uint16_t FLAC__uint16; -typedef uint32_t FLAC__uint32; -typedef uint64_t FLAC__uint64; - -typedef int FLAC__bool; - -typedef FLAC__uint8 FLAC__byte; - -#endif diff --git a/Engine/lib/flac/include/FLAC/stream_decoder.h b/Engine/lib/flac/include/FLAC/stream_decoder.h deleted file mode 100644 index 2272bcac9..000000000 --- a/Engine/lib/flac/include/FLAC/stream_decoder.h +++ /dev/null @@ -1,1584 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__STREAM_DECODER_H -#define FLAC__STREAM_DECODER_H - -#include /* for FILE */ -#include "export.h" -#include "format.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** \file include/FLAC/stream_decoder.h - * - * \brief - * This module contains the functions which implement the stream - * decoder. - * - * See the detailed documentation in the - * \link flac_stream_decoder stream decoder \endlink module. - */ - -/** \defgroup flac_decoder FLAC/ \*_decoder.h: decoder interfaces - * \ingroup flac - * - * \brief - * This module describes the decoder layers provided by libFLAC. - * - * The stream decoder can be used to decode complete streams either from - * the client via callbacks, or directly from a file, depending on how - * it is initialized. When decoding via callbacks, the client provides - * callbacks for reading FLAC data and writing decoded samples, and - * handling metadata and errors. If the client also supplies seek-related - * callback, the decoder function for sample-accurate seeking within the - * FLAC input is also available. When decoding from a file, the client - * needs only supply a filename or open \c FILE* and write/metadata/error - * callbacks; the rest of the callbacks are supplied internally. For more - * info see the \link flac_stream_decoder stream decoder \endlink module. - */ - -/** \defgroup flac_stream_decoder FLAC/stream_decoder.h: stream decoder interface - * \ingroup flac_decoder - * - * \brief - * This module contains the functions which implement the stream - * decoder. - * - * The stream decoder can decode native FLAC, and optionally Ogg FLAC - * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files. - * - * The basic usage of this decoder is as follows: - * - The program creates an instance of a decoder using - * FLAC__stream_decoder_new(). - * - The program overrides the default settings using - * FLAC__stream_decoder_set_*() functions. - * - The program initializes the instance to validate the settings and - * prepare for decoding using - * - FLAC__stream_decoder_init_stream() or FLAC__stream_decoder_init_FILE() - * or FLAC__stream_decoder_init_file() for native FLAC, - * - FLAC__stream_decoder_init_ogg_stream() or FLAC__stream_decoder_init_ogg_FILE() - * or FLAC__stream_decoder_init_ogg_file() for Ogg FLAC - * - The program calls the FLAC__stream_decoder_process_*() functions - * to decode data, which subsequently calls the callbacks. - * - The program finishes the decoding with FLAC__stream_decoder_finish(), - * which flushes the input and output and resets the decoder to the - * uninitialized state. - * - The instance may be used again or deleted with - * FLAC__stream_decoder_delete(). - * - * In more detail, the program will create a new instance by calling - * FLAC__stream_decoder_new(), then call FLAC__stream_decoder_set_*() - * functions to override the default decoder options, and call - * one of the FLAC__stream_decoder_init_*() functions. - * - * There are three initialization functions for native FLAC, one for - * setting up the decoder to decode FLAC data from the client via - * callbacks, and two for decoding directly from a FLAC file. - * - * For decoding via callbacks, use FLAC__stream_decoder_init_stream(). - * You must also supply several callbacks for handling I/O. Some (like - * seeking) are optional, depending on the capabilities of the input. - * - * For decoding directly from a file, use FLAC__stream_decoder_init_FILE() - * or FLAC__stream_decoder_init_file(). Then you must only supply an open - * \c FILE* or filename and fewer callbacks; the decoder will handle - * the other callbacks internally. - * - * There are three similarly-named init functions for decoding from Ogg - * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the - * library has been built with Ogg support. - * - * Once the decoder is initialized, your program will call one of several - * functions to start the decoding process: - * - * - FLAC__stream_decoder_process_single() - Tells the decoder to process at - * most one metadata block or audio frame and return, calling either the - * metadata callback or write callback, respectively, once. If the decoder - * loses sync it will return with only the error callback being called. - * - FLAC__stream_decoder_process_until_end_of_metadata() - Tells the decoder - * to process the stream from the current location and stop upon reaching - * the first audio frame. The client will get one metadata, write, or error - * callback per metadata block, audio frame, or sync error, respectively. - * - FLAC__stream_decoder_process_until_end_of_stream() - Tells the decoder - * to process the stream from the current location until the read callback - * returns FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM or - * FLAC__STREAM_DECODER_READ_STATUS_ABORT. The client will get one metadata, - * write, or error callback per metadata block, audio frame, or sync error, - * respectively. - * - * When the decoder has finished decoding (normally or through an abort), - * the instance is finished by calling FLAC__stream_decoder_finish(), which - * ensures the decoder is in the correct state and frees memory. Then the - * instance may be deleted with FLAC__stream_decoder_delete() or initialized - * again to decode another stream. - * - * Seeking is exposed through the FLAC__stream_decoder_seek_absolute() method. - * At any point after the stream decoder has been initialized, the client can - * call this function to seek to an exact sample within the stream. - * Subsequently, the first time the write callback is called it will be - * passed a (possibly partial) block starting at that sample. - * - * If the client cannot seek via the callback interface provided, but still - * has another way of seeking, it can flush the decoder using - * FLAC__stream_decoder_flush() and start feeding data from the new position - * through the read callback. - * - * The stream decoder also provides MD5 signature checking. If this is - * turned on before initialization, FLAC__stream_decoder_finish() will - * report when the decoded MD5 signature does not match the one stored - * in the STREAMINFO block. MD5 checking is automatically turned off - * (until the next FLAC__stream_decoder_reset()) if there is no signature - * in the STREAMINFO block or when a seek is attempted. - * - * The FLAC__stream_decoder_set_metadata_*() functions deserve special - * attention. By default, the decoder only calls the metadata_callback for - * the STREAMINFO block. These functions allow you to tell the decoder - * explicitly which blocks to parse and return via the metadata_callback - * and/or which to skip. Use a FLAC__stream_decoder_set_metadata_respond_all(), - * FLAC__stream_decoder_set_metadata_ignore() ... or FLAC__stream_decoder_set_metadata_ignore_all(), - * FLAC__stream_decoder_set_metadata_respond() ... sequence to exactly specify - * which blocks to return. Remember that metadata blocks can potentially - * be big (for example, cover art) so filtering out the ones you don't - * use can reduce the memory requirements of the decoder. Also note the - * special forms FLAC__stream_decoder_set_metadata_respond_application(id) - * and FLAC__stream_decoder_set_metadata_ignore_application(id) for - * filtering APPLICATION blocks based on the application ID. - * - * STREAMINFO and SEEKTABLE blocks are always parsed and used internally, but - * they still can legally be filtered from the metadata_callback. - * - * \note - * The "set" functions may only be called when the decoder is in the - * state FLAC__STREAM_DECODER_UNINITIALIZED, i.e. after - * FLAC__stream_decoder_new() or FLAC__stream_decoder_finish(), but - * before FLAC__stream_decoder_init_*(). If this is the case they will - * return \c true, otherwise \c false. - * - * \note - * FLAC__stream_decoder_finish() resets all settings to the constructor - * defaults, including the callbacks. - * - * \{ - */ - - -/** State values for a FLAC__StreamDecoder - * - * The decoder's state can be obtained by calling FLAC__stream_decoder_get_state(). - */ -typedef enum { - - FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = 0, - /**< The decoder is ready to search for metadata. */ - - FLAC__STREAM_DECODER_READ_METADATA, - /**< The decoder is ready to or is in the process of reading metadata. */ - - FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC, - /**< The decoder is ready to or is in the process of searching for the - * frame sync code. - */ - - FLAC__STREAM_DECODER_READ_FRAME, - /**< The decoder is ready to or is in the process of reading a frame. */ - - FLAC__STREAM_DECODER_END_OF_STREAM, - /**< The decoder has reached the end of the stream. */ - - FLAC__STREAM_DECODER_OGG_ERROR, - /**< An error occurred in the underlying Ogg layer. */ - - FLAC__STREAM_DECODER_SEEK_ERROR, - /**< An error occurred while seeking. The decoder must be flushed - * with FLAC__stream_decoder_flush() or reset with - * FLAC__stream_decoder_reset() before decoding can continue. - */ - - FLAC__STREAM_DECODER_ABORTED, - /**< The decoder was aborted by the read or write callback. */ - - FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR, - /**< An error occurred allocating memory. The decoder is in an invalid - * state and can no longer be used. - */ - - FLAC__STREAM_DECODER_UNINITIALIZED - /**< The decoder is in the uninitialized state; one of the - * FLAC__stream_decoder_init_*() functions must be called before samples - * can be processed. - */ - -} FLAC__StreamDecoderState; - -/** Maps a FLAC__StreamDecoderState to a C string. - * - * Using a FLAC__StreamDecoderState as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamDecoderStateString[]; - - -/** Possible return values for the FLAC__stream_decoder_init_*() functions. - */ -typedef enum { - - FLAC__STREAM_DECODER_INIT_STATUS_OK = 0, - /**< Initialization was successful. */ - - FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER, - /**< The library was not compiled with support for the given container - * format. - */ - - FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS, - /**< A required callback was not supplied. */ - - FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR, - /**< An error occurred allocating memory. */ - - FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE, - /**< fopen() failed in FLAC__stream_decoder_init_file() or - * FLAC__stream_decoder_init_ogg_file(). */ - - FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED - /**< FLAC__stream_decoder_init_*() was called when the decoder was - * already initialized, usually because - * FLAC__stream_decoder_finish() was not called. - */ - -} FLAC__StreamDecoderInitStatus; - -/** Maps a FLAC__StreamDecoderInitStatus to a C string. - * - * Using a FLAC__StreamDecoderInitStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamDecoderInitStatusString[]; - - -/** Return values for the FLAC__StreamDecoder read callback. - */ -typedef enum { - - FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, - /**< The read was OK and decoding can continue. */ - - FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM, - /**< The read was attempted while at the end of the stream. Note that - * the client must only return this value when the read callback was - * called when already at the end of the stream. Otherwise, if the read - * itself moves to the end of the stream, the client should still return - * the data and \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on - * the next read callback it should return - * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count - * of \c 0. - */ - - FLAC__STREAM_DECODER_READ_STATUS_ABORT - /**< An unrecoverable error occurred. The decoder will return from the process call. */ - -} FLAC__StreamDecoderReadStatus; - -/** Maps a FLAC__StreamDecoderReadStatus to a C string. - * - * Using a FLAC__StreamDecoderReadStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamDecoderReadStatusString[]; - - -/** Return values for the FLAC__StreamDecoder seek callback. - */ -typedef enum { - - FLAC__STREAM_DECODER_SEEK_STATUS_OK, - /**< The seek was OK and decoding can continue. */ - - FLAC__STREAM_DECODER_SEEK_STATUS_ERROR, - /**< An unrecoverable error occurred. The decoder will return from the process call. */ - - FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED - /**< Client does not support seeking. */ - -} FLAC__StreamDecoderSeekStatus; - -/** Maps a FLAC__StreamDecoderSeekStatus to a C string. - * - * Using a FLAC__StreamDecoderSeekStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[]; - - -/** Return values for the FLAC__StreamDecoder tell callback. - */ -typedef enum { - - FLAC__STREAM_DECODER_TELL_STATUS_OK, - /**< The tell was OK and decoding can continue. */ - - FLAC__STREAM_DECODER_TELL_STATUS_ERROR, - /**< An unrecoverable error occurred. The decoder will return from the process call. */ - - FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED - /**< Client does not support telling the position. */ - -} FLAC__StreamDecoderTellStatus; - -/** Maps a FLAC__StreamDecoderTellStatus to a C string. - * - * Using a FLAC__StreamDecoderTellStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamDecoderTellStatusString[]; - - -/** Return values for the FLAC__StreamDecoder length callback. - */ -typedef enum { - - FLAC__STREAM_DECODER_LENGTH_STATUS_OK, - /**< The length call was OK and decoding can continue. */ - - FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR, - /**< An unrecoverable error occurred. The decoder will return from the process call. */ - - FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED - /**< Client does not support reporting the length. */ - -} FLAC__StreamDecoderLengthStatus; - -/** Maps a FLAC__StreamDecoderLengthStatus to a C string. - * - * Using a FLAC__StreamDecoderLengthStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[]; - - -/** Return values for the FLAC__StreamDecoder write callback. - */ -typedef enum { - - FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE, - /**< The write was OK and decoding can continue. */ - - FLAC__STREAM_DECODER_WRITE_STATUS_ABORT - /**< An unrecoverable error occurred. The decoder will return from the process call. */ - -} FLAC__StreamDecoderWriteStatus; - -/** Maps a FLAC__StreamDecoderWriteStatus to a C string. - * - * Using a FLAC__StreamDecoderWriteStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[]; - - -/** Possible values passed back to the FLAC__StreamDecoder error callback. - * \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC is the generic catch- - * all. The rest could be caused by bad sync (false synchronization on - * data that is not the start of a frame) or corrupted data. The error - * itself is the decoder's best guess at what happened assuming a correct - * sync. For example \c FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER - * could be caused by a correct sync on the start of a frame, but some - * data in the frame header was corrupted. Or it could be the result of - * syncing on a point the stream that looked like the starting of a frame - * but was not. \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM - * could be because the decoder encountered a valid frame made by a future - * version of the encoder which it cannot parse, or because of a false - * sync making it appear as though an encountered frame was generated by - * a future encoder. \c FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA is - * caused by finding data that doesn't fit a metadata block (too large - * or too small) or finding inconsistencies in the metadata, for example - * a PICTURE block with an image that exceeds the size of the metadata - * block. - */ -typedef enum { - - FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC, - /**< An error in the stream caused the decoder to lose synchronization. */ - - FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER, - /**< The decoder encountered a corrupted frame header. */ - - FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH, - /**< The frame's data did not match the CRC in the footer. */ - - FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM, - /**< The decoder encountered reserved fields in use in the stream. */ - - FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA - /**< The decoder encountered a corrupted metadata block. */ - -} FLAC__StreamDecoderErrorStatus; - -/** Maps a FLAC__StreamDecoderErrorStatus to a C string. - * - * Using a FLAC__StreamDecoderErrorStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[]; - - -/*********************************************************************** - * - * class FLAC__StreamDecoder - * - ***********************************************************************/ - -struct FLAC__StreamDecoderProtected; -struct FLAC__StreamDecoderPrivate; -/** The opaque structure definition for the stream decoder type. - * See the \link flac_stream_decoder stream decoder module \endlink - * for a detailed description. - */ -typedef struct { - struct FLAC__StreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */ - struct FLAC__StreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */ -} FLAC__StreamDecoder; - -/** Signature for the read callback. - * - * A function pointer matching this signature must be passed to - * FLAC__stream_decoder_init*_stream(). The supplied function will be - * called when the decoder needs more input data. The address of the - * buffer to be filled is supplied, along with the number of bytes the - * buffer can hold. The callback may choose to supply less data and - * modify the byte count but must be careful not to overflow the buffer. - * The callback then returns a status code chosen from - * FLAC__StreamDecoderReadStatus. - * - * Here is an example of a read callback for stdio streams: - * \code - * FLAC__StreamDecoderReadStatus read_cb(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) - * { - * FILE *file = ((MyClientData*)client_data)->file; - * if(*bytes > 0) { - * *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file); - * if(ferror(file)) - * return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - * else if(*bytes == 0) - * return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - * else - * return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - * } - * else - * return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - * } - * \endcode - * - * \note In general, FLAC__StreamDecoder functions which change the - * state should not be called on the \a decoder while in the callback. - * - * \param decoder The decoder instance calling the callback. - * \param buffer A pointer to a location for the callee to store - * data to be decoded. - * \param bytes A pointer to the size of the buffer. On entry - * to the callback, it contains the maximum number - * of bytes that may be stored in \a buffer. The - * callee must set it to the actual number of bytes - * stored (0 in case of error or end-of-stream) before - * returning. - * \param client_data The callee's client data set through - * FLAC__stream_decoder_init_*(). - * \retval FLAC__StreamDecoderReadStatus - * The callee's return status. Note that the callback should return - * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM if and only if - * zero bytes were read and there is no more data to be read. - */ -typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); - -/** Signature for the seek callback. - * - * A function pointer matching this signature may be passed to - * FLAC__stream_decoder_init*_stream(). The supplied function will be - * called when the decoder needs to seek the input stream. The decoder - * will pass the absolute byte offset to seek to, 0 meaning the - * beginning of the stream. - * - * Here is an example of a seek callback for stdio streams: - * \code - * FLAC__StreamDecoderSeekStatus seek_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) - * { - * FILE *file = ((MyClientData*)client_data)->file; - * if(file == stdin) - * return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; - * else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0) - * return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - * else - * return FLAC__STREAM_DECODER_SEEK_STATUS_OK; - * } - * \endcode - * - * \note In general, FLAC__StreamDecoder functions which change the - * state should not be called on the \a decoder while in the callback. - * - * \param decoder The decoder instance calling the callback. - * \param absolute_byte_offset The offset from the beginning of the stream - * to seek to. - * \param client_data The callee's client data set through - * FLAC__stream_decoder_init_*(). - * \retval FLAC__StreamDecoderSeekStatus - * The callee's return status. - */ -typedef FLAC__StreamDecoderSeekStatus (*FLAC__StreamDecoderSeekCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data); - -/** Signature for the tell callback. - * - * A function pointer matching this signature may be passed to - * FLAC__stream_decoder_init*_stream(). The supplied function will be - * called when the decoder wants to know the current position of the - * stream. The callback should return the byte offset from the - * beginning of the stream. - * - * Here is an example of a tell callback for stdio streams: - * \code - * FLAC__StreamDecoderTellStatus tell_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) - * { - * FILE *file = ((MyClientData*)client_data)->file; - * off_t pos; - * if(file == stdin) - * return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED; - * else if((pos = ftello(file)) < 0) - * return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - * else { - * *absolute_byte_offset = (FLAC__uint64)pos; - * return FLAC__STREAM_DECODER_TELL_STATUS_OK; - * } - * } - * \endcode - * - * \note In general, FLAC__StreamDecoder functions which change the - * state should not be called on the \a decoder while in the callback. - * - * \param decoder The decoder instance calling the callback. - * \param absolute_byte_offset A pointer to storage for the current offset - * from the beginning of the stream. - * \param client_data The callee's client data set through - * FLAC__stream_decoder_init_*(). - * \retval FLAC__StreamDecoderTellStatus - * The callee's return status. - */ -typedef FLAC__StreamDecoderTellStatus (*FLAC__StreamDecoderTellCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); - -/** Signature for the length callback. - * - * A function pointer matching this signature may be passed to - * FLAC__stream_decoder_init*_stream(). The supplied function will be - * called when the decoder wants to know the total length of the stream - * in bytes. - * - * Here is an example of a length callback for stdio streams: - * \code - * FLAC__StreamDecoderLengthStatus length_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) - * { - * FILE *file = ((MyClientData*)client_data)->file; - * struct stat filestats; - * - * if(file == stdin) - * return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; - * else if(fstat(fileno(file), &filestats) != 0) - * return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; - * else { - * *stream_length = (FLAC__uint64)filestats.st_size; - * return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; - * } - * } - * \endcode - * - * \note In general, FLAC__StreamDecoder functions which change the - * state should not be called on the \a decoder while in the callback. - * - * \param decoder The decoder instance calling the callback. - * \param stream_length A pointer to storage for the length of the stream - * in bytes. - * \param client_data The callee's client data set through - * FLAC__stream_decoder_init_*(). - * \retval FLAC__StreamDecoderLengthStatus - * The callee's return status. - */ -typedef FLAC__StreamDecoderLengthStatus (*FLAC__StreamDecoderLengthCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data); - -/** Signature for the EOF callback. - * - * A function pointer matching this signature may be passed to - * FLAC__stream_decoder_init*_stream(). The supplied function will be - * called when the decoder needs to know if the end of the stream has - * been reached. - * - * Here is an example of a EOF callback for stdio streams: - * FLAC__bool eof_cb(const FLAC__StreamDecoder *decoder, void *client_data) - * \code - * { - * FILE *file = ((MyClientData*)client_data)->file; - * return feof(file)? true : false; - * } - * \endcode - * - * \note In general, FLAC__StreamDecoder functions which change the - * state should not be called on the \a decoder while in the callback. - * - * \param decoder The decoder instance calling the callback. - * \param client_data The callee's client data set through - * FLAC__stream_decoder_init_*(). - * \retval FLAC__bool - * \c true if the currently at the end of the stream, else \c false. - */ -typedef FLAC__bool (*FLAC__StreamDecoderEofCallback)(const FLAC__StreamDecoder *decoder, void *client_data); - -/** Signature for the write callback. - * - * A function pointer matching this signature must be passed to one of - * the FLAC__stream_decoder_init_*() functions. - * The supplied function will be called when the decoder has decoded a - * single audio frame. The decoder will pass the frame metadata as well - * as an array of pointers (one for each channel) pointing to the - * decoded audio. - * - * \note In general, FLAC__StreamDecoder functions which change the - * state should not be called on the \a decoder while in the callback. - * - * \param decoder The decoder instance calling the callback. - * \param frame The description of the decoded frame. See - * FLAC__Frame. - * \param buffer An array of pointers to decoded channels of data. - * Each pointer will point to an array of signed - * samples of length \a frame->header.blocksize. - * Channels will be ordered according to the FLAC - * specification; see the documentation for the - * frame header. - * \param client_data The callee's client data set through - * FLAC__stream_decoder_init_*(). - * \retval FLAC__StreamDecoderWriteStatus - * The callee's return status. - */ -typedef FLAC__StreamDecoderWriteStatus (*FLAC__StreamDecoderWriteCallback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); - -/** Signature for the metadata callback. - * - * A function pointer matching this signature must be passed to one of - * the FLAC__stream_decoder_init_*() functions. - * The supplied function will be called when the decoder has decoded a - * metadata block. In a valid FLAC file there will always be one - * \c STREAMINFO block, followed by zero or more other metadata blocks. - * These will be supplied by the decoder in the same order as they - * appear in the stream and always before the first audio frame (i.e. - * write callback). The metadata block that is passed in must not be - * modified, and it doesn't live beyond the callback, so you should make - * a copy of it with FLAC__metadata_object_clone() if you will need it - * elsewhere. Since metadata blocks can potentially be large, by - * default the decoder only calls the metadata callback for the - * \c STREAMINFO block; you can instruct the decoder to pass or filter - * other blocks with FLAC__stream_decoder_set_metadata_*() calls. - * - * \note In general, FLAC__StreamDecoder functions which change the - * state should not be called on the \a decoder while in the callback. - * - * \param decoder The decoder instance calling the callback. - * \param metadata The decoded metadata block. - * \param client_data The callee's client data set through - * FLAC__stream_decoder_init_*(). - */ -typedef void (*FLAC__StreamDecoderMetadataCallback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); - -/** Signature for the error callback. - * - * A function pointer matching this signature must be passed to one of - * the FLAC__stream_decoder_init_*() functions. - * The supplied function will be called whenever an error occurs during - * decoding. - * - * \note In general, FLAC__StreamDecoder functions which change the - * state should not be called on the \a decoder while in the callback. - * - * \param decoder The decoder instance calling the callback. - * \param status The error encountered by the decoder. - * \param client_data The callee's client data set through - * FLAC__stream_decoder_init_*(). - */ -typedef void (*FLAC__StreamDecoderErrorCallback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); - - -/*********************************************************************** - * - * Class constructor/destructor - * - ***********************************************************************/ - -/** Create a new stream decoder instance. The instance is created with - * default settings; see the individual FLAC__stream_decoder_set_*() - * functions for each setting's default. - * - * \retval FLAC__StreamDecoder* - * \c NULL if there was an error allocating memory, else the new instance. - */ -FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void); - -/** Free a decoder instance. Deletes the object pointed to by \a decoder. - * - * \param decoder A pointer to an existing decoder. - * \assert - * \code decoder != NULL \endcode - */ -FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder); - - -/*********************************************************************** - * - * Public class method prototypes - * - ***********************************************************************/ - -/** Set the serial number for the FLAC stream within the Ogg container. - * The default behavior is to use the serial number of the first Ogg - * page. Setting a serial number here will explicitly specify which - * stream is to be decoded. - * - * \note - * This does not need to be set for native FLAC decoding. - * - * \default \c use serial number of first page - * \param decoder A decoder instance to set. - * \param serial_number See above. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number); - -/** Set the "MD5 signature checking" flag. If \c true, the decoder will - * compute the MD5 signature of the unencoded audio data while decoding - * and compare it to the signature from the STREAMINFO block, if it - * exists, during FLAC__stream_decoder_finish(). - * - * MD5 signature checking will be turned off (until the next - * FLAC__stream_decoder_reset()) if there is no signature in the - * STREAMINFO block or when a seek is attempted. - * - * Clients that do not use the MD5 check should leave this off to speed - * up decoding. - * - * \default \c false - * \param decoder A decoder instance to set. - * \param value Flag value (see above). - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value); - -/** Direct the decoder to pass on all metadata blocks of type \a type. - * - * \default By default, only the \c STREAMINFO block is returned via the - * metadata callback. - * \param decoder A decoder instance to set. - * \param type See above. - * \assert - * \code decoder != NULL \endcode - * \a type is valid - * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type); - -/** Direct the decoder to pass on all APPLICATION metadata blocks of the - * given \a id. - * - * \default By default, only the \c STREAMINFO block is returned via the - * metadata callback. - * \param decoder A decoder instance to set. - * \param id See above. - * \assert - * \code decoder != NULL \endcode - * \code id != NULL \endcode - * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]); - -/** Direct the decoder to pass on all metadata blocks of any type. - * - * \default By default, only the \c STREAMINFO block is returned via the - * metadata callback. - * \param decoder A decoder instance to set. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder); - -/** Direct the decoder to filter out all metadata blocks of type \a type. - * - * \default By default, only the \c STREAMINFO block is returned via the - * metadata callback. - * \param decoder A decoder instance to set. - * \param type See above. - * \assert - * \code decoder != NULL \endcode - * \a type is valid - * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type); - -/** Direct the decoder to filter out all APPLICATION metadata blocks of - * the given \a id. - * - * \default By default, only the \c STREAMINFO block is returned via the - * metadata callback. - * \param decoder A decoder instance to set. - * \param id See above. - * \assert - * \code decoder != NULL \endcode - * \code id != NULL \endcode - * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]); - -/** Direct the decoder to filter out all metadata blocks of any type. - * - * \default By default, only the \c STREAMINFO block is returned via the - * metadata callback. - * \param decoder A decoder instance to set. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c false if the decoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder); - -/** Get the current decoder state. - * - * \param decoder A decoder instance to query. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__StreamDecoderState - * The current decoder state. - */ -FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder); - -/** Get the current decoder state as a C string. - * - * \param decoder A decoder instance to query. - * \assert - * \code decoder != NULL \endcode - * \retval const char * - * The decoder state as a C string. Do not modify the contents. - */ -FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder); - -/** Get the "MD5 signature checking" flag. - * This is the value of the setting, not whether or not the decoder is - * currently checking the MD5 (remember, it can be turned off automatically - * by a seek). When the decoder is reset the flag will be restored to the - * value returned by this function. - * - * \param decoder A decoder instance to query. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * See above. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder); - -/** Get the total number of samples in the stream being decoded. - * Will only be valid after decoding has started and will contain the - * value from the \c STREAMINFO block. A value of \c 0 means "unknown". - * - * \param decoder A decoder instance to query. - * \assert - * \code decoder != NULL \endcode - * \retval uint32_t - * See above. - */ -FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder); - -/** Get the current number of channels in the stream being decoded. - * Will only be valid after decoding has started and will contain the - * value from the most recently decoded frame header. - * - * \param decoder A decoder instance to query. - * \assert - * \code decoder != NULL \endcode - * \retval uint32_t - * See above. - */ -FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder); - -/** Get the current channel assignment in the stream being decoded. - * Will only be valid after decoding has started and will contain the - * value from the most recently decoded frame header. - * - * \param decoder A decoder instance to query. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__ChannelAssignment - * See above. - */ -FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder); - -/** Get the current sample resolution in the stream being decoded. - * Will only be valid after decoding has started and will contain the - * value from the most recently decoded frame header. - * - * \param decoder A decoder instance to query. - * \assert - * \code decoder != NULL \endcode - * \retval uint32_t - * See above. - */ -FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder); - -/** Get the current sample rate in Hz of the stream being decoded. - * Will only be valid after decoding has started and will contain the - * value from the most recently decoded frame header. - * - * \param decoder A decoder instance to query. - * \assert - * \code decoder != NULL \endcode - * \retval uint32_t - * See above. - */ -FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder); - -/** Get the current blocksize of the stream being decoded. - * Will only be valid after decoding has started and will contain the - * value from the most recently decoded frame header. - * - * \param decoder A decoder instance to query. - * \assert - * \code decoder != NULL \endcode - * \retval uint32_t - * See above. - */ -FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder); - -/** Returns the decoder's current read position within the stream. - * The position is the byte offset from the start of the stream. - * Bytes before this position have been fully decoded. Note that - * there may still be undecoded bytes in the decoder's read FIFO. - * The returned position is correct even after a seek. - * - * \warning This function currently only works for native FLAC, - * not Ogg FLAC streams. - * - * \param decoder A decoder instance to query. - * \param position Address at which to return the desired position. - * \assert - * \code decoder != NULL \endcode - * \code position != NULL \endcode - * \retval FLAC__bool - * \c true if successful, \c false if the stream is not native FLAC, - * or there was an error from the 'tell' callback or it returned - * \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position); - -/** Return client_data from decoder. - * The data pointed to by the pointer should not be modified. - * - * \param decoder A decoder instance. - * \retval const void * - * The callee's client data set through FLAC__stream_decoder_init_*(). - * Do not modify the contents. - */ -FLAC_API const void *FLAC__stream_decoder_get_client_data(FLAC__StreamDecoder *decoder); - -/** Initialize the decoder instance to decode native FLAC streams. - * - * This flavor of initialization sets up the decoder to decode from a - * native FLAC stream. I/O is performed via callbacks to the client. - * For decoding from a plain file via filename or open FILE*, - * FLAC__stream_decoder_init_file() and FLAC__stream_decoder_init_FILE() - * provide a simpler interface. - * - * This function should be called after FLAC__stream_decoder_new() and - * FLAC__stream_decoder_set_*() but before any of the - * FLAC__stream_decoder_process_*() functions. Will set and return the - * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA - * if initialization succeeded. - * - * \param decoder An uninitialized decoder instance. - * \param read_callback See FLAC__StreamDecoderReadCallback. This - * pointer must not be \c NULL. - * \param seek_callback See FLAC__StreamDecoderSeekCallback. This - * pointer may be \c NULL if seeking is not - * supported. If \a seek_callback is not \c NULL then a - * \a tell_callback, \a length_callback, and \a eof_callback must also be supplied. - * Alternatively, a dummy seek callback that just - * returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the decoder. - * \param tell_callback See FLAC__StreamDecoderTellCallback. This - * pointer may be \c NULL if not supported by the client. If - * \a seek_callback is not \c NULL then a - * \a tell_callback must also be supplied. - * Alternatively, a dummy tell callback that just - * returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the decoder. - * \param length_callback See FLAC__StreamDecoderLengthCallback. This - * pointer may be \c NULL if not supported by the client. If - * \a seek_callback is not \c NULL then a - * \a length_callback must also be supplied. - * Alternatively, a dummy length callback that just - * returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the decoder. - * \param eof_callback See FLAC__StreamDecoderEofCallback. This - * pointer may be \c NULL if not supported by the client. If - * \a seek_callback is not \c NULL then a - * \a eof_callback must also be supplied. - * Alternatively, a dummy length callback that just - * returns \c false - * may also be supplied, all though this is slightly - * less efficient for the decoder. - * \param write_callback See FLAC__StreamDecoderWriteCallback. This - * pointer must not be \c NULL. - * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param error_callback See FLAC__StreamDecoderErrorCallback. This - * pointer must not be \c NULL. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__StreamDecoderInitStatus - * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamDecoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream( - FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderReadCallback read_callback, - FLAC__StreamDecoderSeekCallback seek_callback, - FLAC__StreamDecoderTellCallback tell_callback, - FLAC__StreamDecoderLengthCallback length_callback, - FLAC__StreamDecoderEofCallback eof_callback, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -); - -/** Initialize the decoder instance to decode Ogg FLAC streams. - * - * This flavor of initialization sets up the decoder to decode from a - * FLAC stream in an Ogg container. I/O is performed via callbacks to the - * client. For decoding from a plain file via filename or open FILE*, - * FLAC__stream_decoder_init_ogg_file() and FLAC__stream_decoder_init_ogg_FILE() - * provide a simpler interface. - * - * This function should be called after FLAC__stream_decoder_new() and - * FLAC__stream_decoder_set_*() but before any of the - * FLAC__stream_decoder_process_*() functions. Will set and return the - * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA - * if initialization succeeded. - * - * \note Support for Ogg FLAC in the library is optional. If this - * library has been built without support for Ogg FLAC, this function - * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER. - * - * \param decoder An uninitialized decoder instance. - * \param read_callback See FLAC__StreamDecoderReadCallback. This - * pointer must not be \c NULL. - * \param seek_callback See FLAC__StreamDecoderSeekCallback. This - * pointer may be \c NULL if seeking is not - * supported. If \a seek_callback is not \c NULL then a - * \a tell_callback, \a length_callback, and \a eof_callback must also be supplied. - * Alternatively, a dummy seek callback that just - * returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the decoder. - * \param tell_callback See FLAC__StreamDecoderTellCallback. This - * pointer may be \c NULL if not supported by the client. If - * \a seek_callback is not \c NULL then a - * \a tell_callback must also be supplied. - * Alternatively, a dummy tell callback that just - * returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the decoder. - * \param length_callback See FLAC__StreamDecoderLengthCallback. This - * pointer may be \c NULL if not supported by the client. If - * \a seek_callback is not \c NULL then a - * \a length_callback must also be supplied. - * Alternatively, a dummy length callback that just - * returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the decoder. - * \param eof_callback See FLAC__StreamDecoderEofCallback. This - * pointer may be \c NULL if not supported by the client. If - * \a seek_callback is not \c NULL then a - * \a eof_callback must also be supplied. - * Alternatively, a dummy length callback that just - * returns \c false - * may also be supplied, all though this is slightly - * less efficient for the decoder. - * \param write_callback See FLAC__StreamDecoderWriteCallback. This - * pointer must not be \c NULL. - * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param error_callback See FLAC__StreamDecoderErrorCallback. This - * pointer must not be \c NULL. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__StreamDecoderInitStatus - * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamDecoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream( - FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderReadCallback read_callback, - FLAC__StreamDecoderSeekCallback seek_callback, - FLAC__StreamDecoderTellCallback tell_callback, - FLAC__StreamDecoderLengthCallback length_callback, - FLAC__StreamDecoderEofCallback eof_callback, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -); - -/** Initialize the decoder instance to decode native FLAC files. - * - * This flavor of initialization sets up the decoder to decode from a - * plain native FLAC file. For non-stdio streams, you must use - * FLAC__stream_decoder_init_stream() and provide callbacks for the I/O. - * - * This function should be called after FLAC__stream_decoder_new() and - * FLAC__stream_decoder_set_*() but before any of the - * FLAC__stream_decoder_process_*() functions. Will set and return the - * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA - * if initialization succeeded. - * - * \param decoder An uninitialized decoder instance. - * \param file An open FLAC file. The file should have been - * opened with mode \c "rb" and rewound. The file - * becomes owned by the decoder and should not be - * manipulated by the client while decoding. - * Unless \a file is \c stdin, it will be closed - * when FLAC__stream_decoder_finish() is called. - * Note however that seeking will not work when - * decoding from \c stdin since it is not seekable. - * \param write_callback See FLAC__StreamDecoderWriteCallback. This - * pointer must not be \c NULL. - * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param error_callback See FLAC__StreamDecoderErrorCallback. This - * pointer must not be \c NULL. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code decoder != NULL \endcode - * \code file != NULL \endcode - * \retval FLAC__StreamDecoderInitStatus - * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamDecoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE( - FLAC__StreamDecoder *decoder, - FILE *file, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -); - -/** Initialize the decoder instance to decode Ogg FLAC files. - * - * This flavor of initialization sets up the decoder to decode from a - * plain Ogg FLAC file. For non-stdio streams, you must use - * FLAC__stream_decoder_init_ogg_stream() and provide callbacks for the I/O. - * - * This function should be called after FLAC__stream_decoder_new() and - * FLAC__stream_decoder_set_*() but before any of the - * FLAC__stream_decoder_process_*() functions. Will set and return the - * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA - * if initialization succeeded. - * - * \note Support for Ogg FLAC in the library is optional. If this - * library has been built without support for Ogg FLAC, this function - * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER. - * - * \param decoder An uninitialized decoder instance. - * \param file An open FLAC file. The file should have been - * opened with mode \c "rb" and rewound. The file - * becomes owned by the decoder and should not be - * manipulated by the client while decoding. - * Unless \a file is \c stdin, it will be closed - * when FLAC__stream_decoder_finish() is called. - * Note however that seeking will not work when - * decoding from \c stdin since it is not seekable. - * \param write_callback See FLAC__StreamDecoderWriteCallback. This - * pointer must not be \c NULL. - * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param error_callback See FLAC__StreamDecoderErrorCallback. This - * pointer must not be \c NULL. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code decoder != NULL \endcode - * \code file != NULL \endcode - * \retval FLAC__StreamDecoderInitStatus - * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamDecoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE( - FLAC__StreamDecoder *decoder, - FILE *file, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -); - -/** Initialize the decoder instance to decode native FLAC files. - * - * This flavor of initialization sets up the decoder to decode from a plain - * native FLAC file. If POSIX fopen() semantics are not sufficient, you must - * use FLAC__stream_decoder_init_FILE(), or FLAC__stream_decoder_init_stream() - * and provide callbacks for the I/O. - * - * On Windows, filename must be a UTF-8 encoded filename, which libFLAC - * internally translates to an appropriate representation to use with - * _wfopen. On all other systems, filename is passed to fopen without - * any translation. - * - * This function should be called after FLAC__stream_decoder_new() and - * FLAC__stream_decoder_set_*() but before any of the - * FLAC__stream_decoder_process_*() functions. Will set and return the - * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA - * if initialization succeeded. - * - * \param decoder An uninitialized decoder instance. - * \param filename The name of the file to decode from. The file will - * be opened with fopen(). Use \c NULL to decode from - * \c stdin. Note that \c stdin is not seekable. - * \param write_callback See FLAC__StreamDecoderWriteCallback. This - * pointer must not be \c NULL. - * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param error_callback See FLAC__StreamDecoderErrorCallback. This - * pointer must not be \c NULL. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__StreamDecoderInitStatus - * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamDecoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file( - FLAC__StreamDecoder *decoder, - const char *filename, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -); - -/** Initialize the decoder instance to decode Ogg FLAC files. - * - * This flavor of initialization sets up the decoder to decode from a plain - * Ogg FLAC file. If POSIX fopen() semantics are not sufficient, you must use - * FLAC__stream_decoder_init_ogg_FILE(), or FLAC__stream_decoder_init_ogg_stream() - * and provide callbacks for the I/O. - * - * On Windows, filename must be a UTF-8 encoded filename, which libFLAC - * internally translates to an appropriate representation to use with - * _wfopen. On all other systems, filename is passed to fopen without - * any translation. - * - * This function should be called after FLAC__stream_decoder_new() and - * FLAC__stream_decoder_set_*() but before any of the - * FLAC__stream_decoder_process_*() functions. Will set and return the - * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA - * if initialization succeeded. - * - * \note Support for Ogg FLAC in the library is optional. If this - * library has been built without support for Ogg FLAC, this function - * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER. - * - * \param decoder An uninitialized decoder instance. - * \param filename The name of the file to decode from. The file will - * be opened with fopen(). Use \c NULL to decode from - * \c stdin. Note that \c stdin is not seekable. - * \param write_callback See FLAC__StreamDecoderWriteCallback. This - * pointer must not be \c NULL. - * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param error_callback See FLAC__StreamDecoderErrorCallback. This - * pointer must not be \c NULL. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__StreamDecoderInitStatus - * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamDecoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file( - FLAC__StreamDecoder *decoder, - const char *filename, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -); - -/** Finish the decoding process. - * Flushes the decoding buffer, releases resources, resets the decoder - * settings to their defaults, and returns the decoder state to - * FLAC__STREAM_DECODER_UNINITIALIZED. - * - * In the event of a prematurely-terminated decode, it is not strictly - * necessary to call this immediately before FLAC__stream_decoder_delete() - * but it is good practice to match every FLAC__stream_decoder_init_*() - * with a FLAC__stream_decoder_finish(). - * - * \param decoder An uninitialized decoder instance. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c false if MD5 checking is on AND a STREAMINFO block was available - * AND the MD5 signature in the STREAMINFO block was non-zero AND the - * signature does not match the one computed by the decoder; else - * \c true. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder); - -/** Flush the stream input. - * The decoder's input buffer will be cleared and the state set to - * \c FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC. This will also turn - * off MD5 checking. - * - * \param decoder A decoder instance. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c true if successful, else \c false if a memory allocation - * error occurs (in which case the state will be set to - * \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR). - */ -FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder); - -/** Reset the decoding process. - * The decoder's input buffer will be cleared and the state set to - * \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA. This is similar to - * FLAC__stream_decoder_finish() except that the settings are - * preserved; there is no need to call FLAC__stream_decoder_init_*() - * before decoding again. MD5 checking will be restored to its original - * setting. - * - * If the decoder is seekable, or was initialized with - * FLAC__stream_decoder_init*_FILE() or FLAC__stream_decoder_init*_file(), - * the decoder will also attempt to seek to the beginning of the file. - * If this rewind fails, this function will return \c false. It follows - * that FLAC__stream_decoder_reset() cannot be used when decoding from - * \c stdin. - * - * If the decoder was initialized with FLAC__stream_encoder_init*_stream() - * and is not seekable (i.e. no seek callback was provided or the seek - * callback returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED), it - * is the duty of the client to start feeding data from the beginning of - * the stream on the next FLAC__stream_decoder_process_*() call. - * - * \param decoder A decoder instance. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c true if successful, else \c false if a memory allocation occurs - * (in which case the state will be set to - * \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR) or a seek error - * occurs (the state will be unchanged). - */ -FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder); - -/** Decode one metadata block or audio frame. - * This version instructs the decoder to decode a either a single metadata - * block or a single frame and stop, unless the callbacks return a fatal - * error or the read callback returns - * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM. - * - * As the decoder needs more input it will call the read callback. - * Depending on what was decoded, the metadata or write callback will be - * called with the decoded metadata block or audio frame. - * - * Unless there is a fatal read error or end of stream, this function - * will return once one whole frame is decoded. In other words, if the - * stream is not synchronized or points to a corrupt frame header, the - * decoder will continue to try and resync until it gets to a valid - * frame, then decode one frame, then return. If the decoder points to - * a frame whose frame CRC in the frame footer does not match the - * computed frame CRC, this function will issue a - * FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH error to the - * error callback, and return, having decoded one complete, although - * corrupt, frame. (Such corrupted frames are sent as silence of the - * correct length to the write callback.) - * - * \param decoder An initialized decoder instance. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c false if any fatal read, write, or memory allocation error - * occurred (meaning decoding must stop), else \c true; for more - * information about the decoder, check the decoder state with - * FLAC__stream_decoder_get_state(). - */ -FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder); - -/** Decode until the end of the metadata. - * This version instructs the decoder to decode from the current position - * and continue until all the metadata has been read, or until the - * callbacks return a fatal error or the read callback returns - * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM. - * - * As the decoder needs more input it will call the read callback. - * As each metadata block is decoded, the metadata callback will be called - * with the decoded metadata. - * - * \param decoder An initialized decoder instance. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c false if any fatal read, write, or memory allocation error - * occurred (meaning decoding must stop), else \c true; for more - * information about the decoder, check the decoder state with - * FLAC__stream_decoder_get_state(). - */ -FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder); - -/** Decode until the end of the stream. - * This version instructs the decoder to decode from the current position - * and continue until the end of stream (the read callback returns - * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM), or until the - * callbacks return a fatal error. - * - * As the decoder needs more input it will call the read callback. - * As each metadata block and frame is decoded, the metadata or write - * callback will be called with the decoded metadata or frame. - * - * \param decoder An initialized decoder instance. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c false if any fatal read, write, or memory allocation error - * occurred (meaning decoding must stop), else \c true; for more - * information about the decoder, check the decoder state with - * FLAC__stream_decoder_get_state(). - */ -FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder); - -/** Skip one audio frame. - * This version instructs the decoder to 'skip' a single frame and stop, - * unless the callbacks return a fatal error or the read callback returns - * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM. - * - * The decoding flow is the same as what occurs when - * FLAC__stream_decoder_process_single() is called to process an audio - * frame, except that this function does not decode the parsed data into - * PCM or call the write callback. The integrity of the frame is still - * checked the same way as in the other process functions. - * - * This function will return once one whole frame is skipped, in the - * same way that FLAC__stream_decoder_process_single() will return once - * one whole frame is decoded. - * - * This function can be used in more quickly determining FLAC frame - * boundaries when decoding of the actual data is not needed, for - * example when an application is separating a FLAC stream into frames - * for editing or storing in a container. To do this, the application - * can use FLAC__stream_decoder_skip_single_frame() to quickly advance - * to the next frame, then use - * FLAC__stream_decoder_get_decode_position() to find the new frame - * boundary. - * - * This function should only be called when the stream has advanced - * past all the metadata, otherwise it will return \c false. - * - * \param decoder An initialized decoder instance not in a metadata - * state. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c false if any fatal read, write, or memory allocation error - * occurred (meaning decoding must stop), or if the decoder - * is in the FLAC__STREAM_DECODER_SEARCH_FOR_METADATA or - * FLAC__STREAM_DECODER_READ_METADATA state, else \c true; for more - * information about the decoder, check the decoder state with - * FLAC__stream_decoder_get_state(). - */ -FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder); - -/** Flush the input and seek to an absolute sample. - * Decoding will resume at the given sample. Note that because of - * this, the next write callback may contain a partial block. The - * client must support seeking the input or this function will fail - * and return \c false. Furthermore, if the decoder state is - * \c FLAC__STREAM_DECODER_SEEK_ERROR, then the decoder must be flushed - * with FLAC__stream_decoder_flush() or reset with - * FLAC__stream_decoder_reset() before decoding can continue. - * - * \param decoder A decoder instance. - * \param sample The target sample number to seek to. - * \assert - * \code decoder != NULL \endcode - * \retval FLAC__bool - * \c true if successful, else \c false. - */ -FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample); - -/* \} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/FLAC/stream_encoder.h b/Engine/lib/flac/include/FLAC/stream_encoder.h deleted file mode 100644 index a0d026397..000000000 --- a/Engine/lib/flac/include/FLAC/stream_encoder.h +++ /dev/null @@ -1,1837 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__STREAM_ENCODER_H -#define FLAC__STREAM_ENCODER_H - -#include /* for FILE */ -#include "export.h" -#include "format.h" -#include "stream_decoder.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/** \file include/FLAC/stream_encoder.h - * - * \brief - * This module contains the functions which implement the stream - * encoder. - * - * See the detailed documentation in the - * \link flac_stream_encoder stream encoder \endlink module. - */ - -/** \defgroup flac_encoder FLAC/ \*_encoder.h: encoder interfaces - * \ingroup flac - * - * \brief - * This module describes the encoder layers provided by libFLAC. - * - * The stream encoder can be used to encode complete streams either to the - * client via callbacks, or directly to a file, depending on how it is - * initialized. When encoding via callbacks, the client provides a write - * callback which will be called whenever FLAC data is ready to be written. - * If the client also supplies a seek callback, the encoder will also - * automatically handle the writing back of metadata discovered while - * encoding, like stream info, seek points offsets, etc. When encoding to - * a file, the client needs only supply a filename or open \c FILE* and an - * optional progress callback for periodic notification of progress; the - * write and seek callbacks are supplied internally. For more info see the - * \link flac_stream_encoder stream encoder \endlink module. - */ - -/** \defgroup flac_stream_encoder FLAC/stream_encoder.h: stream encoder interface - * \ingroup flac_encoder - * - * \brief - * This module contains the functions which implement the stream - * encoder. - * - * The stream encoder can encode to native FLAC, and optionally Ogg FLAC - * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files. - * - * The basic usage of this encoder is as follows: - * - The program creates an instance of an encoder using - * FLAC__stream_encoder_new(). - * - The program overrides the default settings using - * FLAC__stream_encoder_set_*() functions. At a minimum, the following - * functions should be called: - * - FLAC__stream_encoder_set_channels() - * - FLAC__stream_encoder_set_bits_per_sample() - * - FLAC__stream_encoder_set_sample_rate() - * - FLAC__stream_encoder_set_ogg_serial_number() (if encoding to Ogg FLAC) - * - FLAC__stream_encoder_set_total_samples_estimate() (if known) - * - If the application wants to control the compression level or set its own - * metadata, then the following should also be called: - * - FLAC__stream_encoder_set_compression_level() - * - FLAC__stream_encoder_set_verify() - * - FLAC__stream_encoder_set_metadata() - * - The rest of the set functions should only be called if the client needs - * exact control over how the audio is compressed; thorough understanding - * of the FLAC format is necessary to achieve good results. - * - The program initializes the instance to validate the settings and - * prepare for encoding using - * - FLAC__stream_encoder_init_stream() or FLAC__stream_encoder_init_FILE() - * or FLAC__stream_encoder_init_file() for native FLAC - * - FLAC__stream_encoder_init_ogg_stream() or FLAC__stream_encoder_init_ogg_FILE() - * or FLAC__stream_encoder_init_ogg_file() for Ogg FLAC - * - The program calls FLAC__stream_encoder_process() or - * FLAC__stream_encoder_process_interleaved() to encode data, which - * subsequently calls the callbacks when there is encoder data ready - * to be written. - * - The program finishes the encoding with FLAC__stream_encoder_finish(), - * which causes the encoder to encode any data still in its input pipe, - * update the metadata with the final encoding statistics if output - * seeking is possible, and finally reset the encoder to the - * uninitialized state. - * - The instance may be used again or deleted with - * FLAC__stream_encoder_delete(). - * - * In more detail, the stream encoder functions similarly to the - * \link flac_stream_decoder stream decoder \endlink, but has fewer - * callbacks and more options. Typically the client will create a new - * instance by calling FLAC__stream_encoder_new(), then set the necessary - * parameters with FLAC__stream_encoder_set_*(), and initialize it by - * calling one of the FLAC__stream_encoder_init_*() functions. - * - * Unlike the decoders, the stream encoder has many options that can - * affect the speed and compression ratio. When setting these parameters - * you should have some basic knowledge of the format (see the - * user-level documentation - * or the formal description). The - * FLAC__stream_encoder_set_*() functions themselves do not validate the - * values as many are interdependent. The FLAC__stream_encoder_init_*() - * functions will do this, so make sure to pay attention to the state - * returned by FLAC__stream_encoder_init_*() to make sure that it is - * FLAC__STREAM_ENCODER_INIT_STATUS_OK. Any parameters that are not set - * before FLAC__stream_encoder_init_*() will take on the defaults from - * the constructor. - * - * There are three initialization functions for native FLAC, one for - * setting up the encoder to encode FLAC data to the client via - * callbacks, and two for encoding directly to a file. - * - * For encoding via callbacks, use FLAC__stream_encoder_init_stream(). - * You must also supply a write callback which will be called anytime - * there is raw encoded data to write. If the client can seek the output - * it is best to also supply seek and tell callbacks, as this allows the - * encoder to go back after encoding is finished to write back - * information that was collected while encoding, like seek point offsets, - * frame sizes, etc. - * - * For encoding directly to a file, use FLAC__stream_encoder_init_FILE() - * or FLAC__stream_encoder_init_file(). Then you must only supply a - * filename or open \c FILE*; the encoder will handle all the callbacks - * internally. You may also supply a progress callback for periodic - * notification of the encoding progress. - * - * There are three similarly-named init functions for encoding to Ogg - * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the - * library has been built with Ogg support. - * - * The call to FLAC__stream_encoder_init_*() currently will also immediately - * call the write callback several times, once with the \c fLaC signature, - * and once for each encoded metadata block. Note that for Ogg FLAC - * encoding you will usually get at least twice the number of callbacks than - * with native FLAC, one for the Ogg page header and one for the page body. - * - * After initializing the instance, the client may feed audio data to the - * encoder in one of two ways: - * - * - Channel separate, through FLAC__stream_encoder_process() - The client - * will pass an array of pointers to buffers, one for each channel, to - * the encoder, each of the same length. The samples need not be - * block-aligned, but each channel should have the same number of samples. - * - Channel interleaved, through - * FLAC__stream_encoder_process_interleaved() - The client will pass a single - * pointer to data that is channel-interleaved (i.e. channel0_sample0, - * channel1_sample0, ... , channelN_sample0, channel0_sample1, ...). - * Again, the samples need not be block-aligned but they must be - * sample-aligned, i.e. the first value should be channel0_sample0 and - * the last value channelN_sampleM. - * - * Note that for either process call, each sample in the buffers should be a - * signed integer, right-justified to the resolution set by - * FLAC__stream_encoder_set_bits_per_sample(). For example, if the resolution - * is 16 bits per sample, the samples should all be in the range [-32768,32767]. - * - * When the client is finished encoding data, it calls - * FLAC__stream_encoder_finish(), which causes the encoder to encode any - * data still in its input pipe, and call the metadata callback with the - * final encoding statistics. Then the instance may be deleted with - * FLAC__stream_encoder_delete() or initialized again to encode another - * stream. - * - * For programs that write their own metadata, but that do not know the - * actual metadata until after encoding, it is advantageous to instruct - * the encoder to write a PADDING block of the correct size, so that - * instead of rewriting the whole stream after encoding, the program can - * just overwrite the PADDING block. If only the maximum size of the - * metadata is known, the program can write a slightly larger padding - * block, then split it after encoding. - * - * Make sure you understand how lengths are calculated. All FLAC metadata - * blocks have a 4 byte header which contains the type and length. This - * length does not include the 4 bytes of the header. See the format page - * for the specification of metadata blocks and their lengths. - * - * \note - * If you are writing the FLAC data to a file via callbacks, make sure it - * is open for update (e.g. mode "w+" for stdio streams). This is because - * after the first encoding pass, the encoder will try to seek back to the - * beginning of the stream, to the STREAMINFO block, to write some data - * there. (If using FLAC__stream_encoder_init*_file() or - * FLAC__stream_encoder_init*_FILE(), the file is managed internally.) - * - * \note - * The "set" functions may only be called when the encoder is in the - * state FLAC__STREAM_ENCODER_UNINITIALIZED, i.e. after - * FLAC__stream_encoder_new() or FLAC__stream_encoder_finish(), but - * before FLAC__stream_encoder_init_*(). If this is the case they will - * return \c true, otherwise \c false. - * - * \note - * FLAC__stream_encoder_finish() resets all settings to the constructor - * defaults. - * - * \{ - */ - - -/** State values for a FLAC__StreamEncoder. - * - * The encoder's state can be obtained by calling FLAC__stream_encoder_get_state(). - * - * If the encoder gets into any other state besides \c FLAC__STREAM_ENCODER_OK - * or \c FLAC__STREAM_ENCODER_UNINITIALIZED, it becomes invalid for encoding and - * must be deleted with FLAC__stream_encoder_delete(). - */ -typedef enum { - - FLAC__STREAM_ENCODER_OK = 0, - /**< The encoder is in the normal OK state and samples can be processed. */ - - FLAC__STREAM_ENCODER_UNINITIALIZED, - /**< The encoder is in the uninitialized state; one of the - * FLAC__stream_encoder_init_*() functions must be called before samples - * can be processed. - */ - - FLAC__STREAM_ENCODER_OGG_ERROR, - /**< An error occurred in the underlying Ogg layer. */ - - FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR, - /**< An error occurred in the underlying verify stream decoder; - * check FLAC__stream_encoder_get_verify_decoder_state(). - */ - - FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA, - /**< The verify decoder detected a mismatch between the original - * audio signal and the decoded audio signal. - */ - - FLAC__STREAM_ENCODER_CLIENT_ERROR, - /**< One of the callbacks returned a fatal error. */ - - FLAC__STREAM_ENCODER_IO_ERROR, - /**< An I/O error occurred while opening/reading/writing a file. - * Check \c errno. - */ - - FLAC__STREAM_ENCODER_FRAMING_ERROR, - /**< An error occurred while writing the stream; usually, the - * write_callback returned an error. - */ - - FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR - /**< Memory allocation failed. */ - -} FLAC__StreamEncoderState; - -/** Maps a FLAC__StreamEncoderState to a C string. - * - * Using a FLAC__StreamEncoderState as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamEncoderStateString[]; - - -/** Possible return values for the FLAC__stream_encoder_init_*() functions. - */ -typedef enum { - - FLAC__STREAM_ENCODER_INIT_STATUS_OK = 0, - /**< Initialization was successful. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR, - /**< General failure to set up encoder; call FLAC__stream_encoder_get_state() for cause. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER, - /**< The library was not compiled with support for the given container - * format. - */ - - FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS, - /**< A required callback was not supplied. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS, - /**< The encoder has an invalid setting for number of channels. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE, - /**< The encoder has an invalid setting for bits-per-sample. - * FLAC supports 4-32 bps. - */ - - FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE, - /**< The encoder has an invalid setting for the input sample rate. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE, - /**< The encoder has an invalid setting for the block size. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER, - /**< The encoder has an invalid setting for the maximum LPC order. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION, - /**< The encoder has an invalid setting for the precision of the quantized linear predictor coefficients. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER, - /**< The specified block size is less than the maximum LPC order. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE, - /**< The encoder is bound to the Subset but other settings violate it. */ - - FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA, - /**< The metadata input to the encoder is invalid, in one of the following ways: - * - FLAC__stream_encoder_set_metadata() was called with a null pointer but a block count > 0 - * - One of the metadata blocks contains an undefined type - * - It contains an illegal CUESHEET as checked by FLAC__format_cuesheet_is_legal() - * - It contains an illegal SEEKTABLE as checked by FLAC__format_seektable_is_legal() - * - It contains more than one SEEKTABLE block or more than one VORBIS_COMMENT block - */ - - FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED - /**< FLAC__stream_encoder_init_*() was called when the encoder was - * already initialized, usually because - * FLAC__stream_encoder_finish() was not called. - */ - -} FLAC__StreamEncoderInitStatus; - -/** Maps a FLAC__StreamEncoderInitStatus to a C string. - * - * Using a FLAC__StreamEncoderInitStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamEncoderInitStatusString[]; - - -/** Return values for the FLAC__StreamEncoder read callback. - */ -typedef enum { - - FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE, - /**< The read was OK and decoding can continue. */ - - FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM, - /**< The read was attempted at the end of the stream. */ - - FLAC__STREAM_ENCODER_READ_STATUS_ABORT, - /**< An unrecoverable error occurred. */ - - FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED - /**< Client does not support reading back from the output. */ - -} FLAC__StreamEncoderReadStatus; - -/** Maps a FLAC__StreamEncoderReadStatus to a C string. - * - * Using a FLAC__StreamEncoderReadStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamEncoderReadStatusString[]; - - -/** Return values for the FLAC__StreamEncoder write callback. - */ -typedef enum { - - FLAC__STREAM_ENCODER_WRITE_STATUS_OK = 0, - /**< The write was OK and encoding can continue. */ - - FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR - /**< An unrecoverable error occurred. The encoder will return from the process call. */ - -} FLAC__StreamEncoderWriteStatus; - -/** Maps a FLAC__StreamEncoderWriteStatus to a C string. - * - * Using a FLAC__StreamEncoderWriteStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamEncoderWriteStatusString[]; - - -/** Return values for the FLAC__StreamEncoder seek callback. - */ -typedef enum { - - FLAC__STREAM_ENCODER_SEEK_STATUS_OK, - /**< The seek was OK and encoding can continue. */ - - FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR, - /**< An unrecoverable error occurred. */ - - FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED - /**< Client does not support seeking. */ - -} FLAC__StreamEncoderSeekStatus; - -/** Maps a FLAC__StreamEncoderSeekStatus to a C string. - * - * Using a FLAC__StreamEncoderSeekStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamEncoderSeekStatusString[]; - - -/** Return values for the FLAC__StreamEncoder tell callback. - */ -typedef enum { - - FLAC__STREAM_ENCODER_TELL_STATUS_OK, - /**< The tell was OK and encoding can continue. */ - - FLAC__STREAM_ENCODER_TELL_STATUS_ERROR, - /**< An unrecoverable error occurred. */ - - FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED - /**< Client does not support seeking. */ - -} FLAC__StreamEncoderTellStatus; - -/** Maps a FLAC__StreamEncoderTellStatus to a C string. - * - * Using a FLAC__StreamEncoderTellStatus as the index to this array - * will give the string equivalent. The contents should not be modified. - */ -extern FLAC_API const char * const FLAC__StreamEncoderTellStatusString[]; - - -/*********************************************************************** - * - * class FLAC__StreamEncoder - * - ***********************************************************************/ - -struct FLAC__StreamEncoderProtected; -struct FLAC__StreamEncoderPrivate; -/** The opaque structure definition for the stream encoder type. - * See the \link flac_stream_encoder stream encoder module \endlink - * for a detailed description. - */ -typedef struct { - struct FLAC__StreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */ - struct FLAC__StreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */ -} FLAC__StreamEncoder; - -/** Signature for the read callback. - * - * A function pointer matching this signature must be passed to - * FLAC__stream_encoder_init_ogg_stream() if seeking is supported. - * The supplied function will be called when the encoder needs to read back - * encoded data. This happens during the metadata callback, when the encoder - * has to read, modify, and rewrite the metadata (e.g. seekpoints) gathered - * while encoding. The address of the buffer to be filled is supplied, along - * with the number of bytes the buffer can hold. The callback may choose to - * supply less data and modify the byte count but must be careful not to - * overflow the buffer. The callback then returns a status code chosen from - * FLAC__StreamEncoderReadStatus. - * - * Here is an example of a read callback for stdio streams: - * \code - * FLAC__StreamEncoderReadStatus read_cb(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data) - * { - * FILE *file = ((MyClientData*)client_data)->file; - * if(*bytes > 0) { - * *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file); - * if(ferror(file)) - * return FLAC__STREAM_ENCODER_READ_STATUS_ABORT; - * else if(*bytes == 0) - * return FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM; - * else - * return FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE; - * } - * else - * return FLAC__STREAM_ENCODER_READ_STATUS_ABORT; - * } - * \endcode - * - * \note In general, FLAC__StreamEncoder functions which change the - * state should not be called on the \a encoder while in the callback. - * - * \param encoder The encoder instance calling the callback. - * \param buffer A pointer to a location for the callee to store - * data to be encoded. - * \param bytes A pointer to the size of the buffer. On entry - * to the callback, it contains the maximum number - * of bytes that may be stored in \a buffer. The - * callee must set it to the actual number of bytes - * stored (0 in case of error or end-of-stream) before - * returning. - * \param client_data The callee's client data set through - * FLAC__stream_encoder_set_client_data(). - * \retval FLAC__StreamEncoderReadStatus - * The callee's return status. - */ -typedef FLAC__StreamEncoderReadStatus (*FLAC__StreamEncoderReadCallback)(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data); - -/** Signature for the write callback. - * - * A function pointer matching this signature must be passed to - * FLAC__stream_encoder_init*_stream(). The supplied function will be called - * by the encoder anytime there is raw encoded data ready to write. It may - * include metadata mixed with encoded audio frames and the data is not - * guaranteed to be aligned on frame or metadata block boundaries. - * - * The only duty of the callback is to write out the \a bytes worth of data - * in \a buffer to the current position in the output stream. The arguments - * \a samples and \a current_frame are purely informational. If \a samples - * is greater than \c 0, then \a current_frame will hold the current frame - * number that is being written; otherwise it indicates that the write - * callback is being called to write metadata. - * - * \note - * Unlike when writing to native FLAC, when writing to Ogg FLAC the - * write callback will be called twice when writing each audio - * frame; once for the page header, and once for the page body. - * When writing the page header, the \a samples argument to the - * write callback will be \c 0. - * - * \note In general, FLAC__StreamEncoder functions which change the - * state should not be called on the \a encoder while in the callback. - * - * \param encoder The encoder instance calling the callback. - * \param buffer An array of encoded data of length \a bytes. - * \param bytes The byte length of \a buffer. - * \param samples The number of samples encoded by \a buffer. - * \c 0 has a special meaning; see above. - * \param current_frame The number of the current frame being encoded. - * \param client_data The callee's client data set through - * FLAC__stream_encoder_init_*(). - * \retval FLAC__StreamEncoderWriteStatus - * The callee's return status. - */ -typedef FLAC__StreamEncoderWriteStatus (*FLAC__StreamEncoderWriteCallback)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data); - -/** Signature for the seek callback. - * - * A function pointer matching this signature may be passed to - * FLAC__stream_encoder_init*_stream(). The supplied function will be called - * when the encoder needs to seek the output stream. The encoder will pass - * the absolute byte offset to seek to, 0 meaning the beginning of the stream. - * - * Here is an example of a seek callback for stdio streams: - * \code - * FLAC__StreamEncoderSeekStatus seek_cb(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) - * { - * FILE *file = ((MyClientData*)client_data)->file; - * if(file == stdin) - * return FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED; - * else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0) - * return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR; - * else - * return FLAC__STREAM_ENCODER_SEEK_STATUS_OK; - * } - * \endcode - * - * \note In general, FLAC__StreamEncoder functions which change the - * state should not be called on the \a encoder while in the callback. - * - * \param encoder The encoder instance calling the callback. - * \param absolute_byte_offset The offset from the beginning of the stream - * to seek to. - * \param client_data The callee's client data set through - * FLAC__stream_encoder_init_*(). - * \retval FLAC__StreamEncoderSeekStatus - * The callee's return status. - */ -typedef FLAC__StreamEncoderSeekStatus (*FLAC__StreamEncoderSeekCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data); - -/** Signature for the tell callback. - * - * A function pointer matching this signature may be passed to - * FLAC__stream_encoder_init*_stream(). The supplied function will be called - * when the encoder needs to know the current position of the output stream. - * - * \warning - * The callback must return the true current byte offset of the output to - * which the encoder is writing. If you are buffering the output, make - * sure and take this into account. If you are writing directly to a - * FILE* from your write callback, ftell() is sufficient. If you are - * writing directly to a file descriptor from your write callback, you - * can use lseek(fd, SEEK_CUR, 0). The encoder may later seek back to - * these points to rewrite metadata after encoding. - * - * Here is an example of a tell callback for stdio streams: - * \code - * FLAC__StreamEncoderTellStatus tell_cb(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) - * { - * FILE *file = ((MyClientData*)client_data)->file; - * off_t pos; - * if(file == stdin) - * return FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED; - * else if((pos = ftello(file)) < 0) - * return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR; - * else { - * *absolute_byte_offset = (FLAC__uint64)pos; - * return FLAC__STREAM_ENCODER_TELL_STATUS_OK; - * } - * } - * \endcode - * - * \note In general, FLAC__StreamEncoder functions which change the - * state should not be called on the \a encoder while in the callback. - * - * \param encoder The encoder instance calling the callback. - * \param absolute_byte_offset The address at which to store the current - * position of the output. - * \param client_data The callee's client data set through - * FLAC__stream_encoder_init_*(). - * \retval FLAC__StreamEncoderTellStatus - * The callee's return status. - */ -typedef FLAC__StreamEncoderTellStatus (*FLAC__StreamEncoderTellCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data); - -/** Signature for the metadata callback. - * - * A function pointer matching this signature may be passed to - * FLAC__stream_encoder_init*_stream(). The supplied function will be called - * once at the end of encoding with the populated STREAMINFO structure. This - * is so the client can seek back to the beginning of the file and write the - * STREAMINFO block with the correct statistics after encoding (like - * minimum/maximum frame size and total samples). - * - * \note In general, FLAC__StreamEncoder functions which change the - * state should not be called on the \a encoder while in the callback. - * - * \param encoder The encoder instance calling the callback. - * \param metadata The final populated STREAMINFO block. - * \param client_data The callee's client data set through - * FLAC__stream_encoder_init_*(). - */ -typedef void (*FLAC__StreamEncoderMetadataCallback)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data); - -/** Signature for the progress callback. - * - * A function pointer matching this signature may be passed to - * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE(). - * The supplied function will be called when the encoder has finished - * writing a frame. The \c total_frames_estimate argument to the - * callback will be based on the value from - * FLAC__stream_encoder_set_total_samples_estimate(). - * - * \note In general, FLAC__StreamEncoder functions which change the - * state should not be called on the \a encoder while in the callback. - * - * \param encoder The encoder instance calling the callback. - * \param bytes_written Bytes written so far. - * \param samples_written Samples written so far. - * \param frames_written Frames written so far. - * \param total_frames_estimate The estimate of the total number of - * frames to be written. - * \param client_data The callee's client data set through - * FLAC__stream_encoder_init_*(). - */ -typedef void (*FLAC__StreamEncoderProgressCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data); - - -/*********************************************************************** - * - * Class constructor/destructor - * - ***********************************************************************/ - -/** Create a new stream encoder instance. The instance is created with - * default settings; see the individual FLAC__stream_encoder_set_*() - * functions for each setting's default. - * - * \retval FLAC__StreamEncoder* - * \c NULL if there was an error allocating memory, else the new instance. - */ -FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void); - -/** Free an encoder instance. Deletes the object pointed to by \a encoder. - * - * \param encoder A pointer to an existing encoder. - * \assert - * \code encoder != NULL \endcode - */ -FLAC_API void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder); - - -/*********************************************************************** - * - * Public class method prototypes - * - ***********************************************************************/ - -/** Set the serial number for the FLAC stream to use in the Ogg container. - * - * \note - * This does not need to be set for native FLAC encoding. - * - * \note - * It is recommended to set a serial number explicitly as the default of '0' - * may collide with other streams. - * - * \default \c 0 - * \param encoder An encoder instance to set. - * \param serial_number See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_ogg_serial_number(FLAC__StreamEncoder *encoder, long serial_number); - -/** Set the "verify" flag. If \c true, the encoder will verify it's own - * encoded output by feeding it through an internal decoder and comparing - * the original signal against the decoded signal. If a mismatch occurs, - * the process call will return \c false. Note that this will slow the - * encoding process by the extra time required for decoding and comparison. - * - * \default \c false - * \param encoder An encoder instance to set. - * \param value Flag value (see above). - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value); - -/** Set the Subset flag. If \c true, - * the encoder will comply with the Subset and will check the - * settings during FLAC__stream_encoder_init_*() to see if all settings - * comply. If \c false, the settings may take advantage of the full - * range that the format allows. - * - * Make sure you know what it entails before setting this to \c false. - * - * \default \c true - * \param encoder An encoder instance to set. - * \param value Flag value (see above). - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value); - -/** Set the number of channels to be encoded. - * - * \default \c 2 - * \param encoder An encoder instance to set. - * \param value See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, uint32_t value); - -/** Set the sample resolution of the input to be encoded. - * - * \warning - * Do not feed the encoder data that is wider than the value you - * set here or you will generate an invalid stream. - * - * \default \c 16 - * \param encoder An encoder instance to set. - * \param value See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, uint32_t value); - -/** Set the sample rate (in Hz) of the input to be encoded. - * - * \default \c 44100 - * \param encoder An encoder instance to set. - * \param value See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, uint32_t value); - -/** Set the compression level - * - * The compression level is roughly proportional to the amount of effort - * the encoder expends to compress the file. A higher level usually - * means more computation but higher compression. The default level is - * suitable for most applications. - * - * Currently the levels range from \c 0 (fastest, least compression) to - * \c 8 (slowest, most compression). A value larger than \c 8 will be - * treated as \c 8. - * - * This function automatically calls the following other \c _set_ - * functions with appropriate values, so the client does not need to - * unless it specifically wants to override them: - * - FLAC__stream_encoder_set_do_mid_side_stereo() - * - FLAC__stream_encoder_set_loose_mid_side_stereo() - * - FLAC__stream_encoder_set_apodization() - * - FLAC__stream_encoder_set_max_lpc_order() - * - FLAC__stream_encoder_set_qlp_coeff_precision() - * - FLAC__stream_encoder_set_do_qlp_coeff_prec_search() - * - FLAC__stream_encoder_set_do_escape_coding() - * - FLAC__stream_encoder_set_do_exhaustive_model_search() - * - FLAC__stream_encoder_set_min_residual_partition_order() - * - FLAC__stream_encoder_set_max_residual_partition_order() - * - FLAC__stream_encoder_set_rice_parameter_search_dist() - * - * The actual values set for each level are: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
leveldo mid-side stereoloose mid-side stereoapodizationmax lpc orderqlp coeff precisionqlp coeff prec searchescape codingexhaustive model searchmin residual partition ordermax residual partition orderrice parameter search dist
0 false false tukey(0.5) 0 0 false false false 0 3 0
1 true true tukey(0.5) 0 0 false false false 0 3 0
2 true false tukey(0.5) 0 0 false false false 0 3 0
3 false false tukey(0.5) 6 0 false false false 0 4 0
4 true true tukey(0.5) 8 0 false false false 0 4 0
5 true false tukey(0.5) 8 0 false false false 0 5 0
6 true false subdivide_tukey(2) 8 0 false false false 0 6 0
7 true false subdivide_tukey(2) 12 0 false false false 0 6 0
8 true false subdivide_tukey(3) 12 0 false false false 0 6 0
- * - * \default \c 5 - * \param encoder An encoder instance to set. - * \param value See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, uint32_t value); - -/** Set the blocksize to use while encoding. - * - * The number of samples to use per frame. Use \c 0 to let the encoder - * estimate a blocksize; this is usually best. - * - * \default \c 0 - * \param encoder An encoder instance to set. - * \param value See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, uint32_t value); - -/** Set to \c true to enable mid-side encoding on stereo input. The - * number of channels must be 2 for this to have any effect. Set to - * \c false to use only independent channel coding. - * - * \default \c true - * \param encoder An encoder instance to set. - * \param value Flag value (see above). - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value); - -/** Set to \c true to enable adaptive switching between mid-side and - * left-right encoding on stereo input. Set to \c false to use - * exhaustive searching. Setting this to \c true requires - * FLAC__stream_encoder_set_do_mid_side_stereo() to also be set to - * \c true in order to have any effect. - * - * \default \c false - * \param encoder An encoder instance to set. - * \param value Flag value (see above). - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value); - -/** Sets the apodization function(s) the encoder will use when windowing - * audio data for LPC analysis. - * - * The \a specification is a plain ASCII string which specifies exactly - * which functions to use. There may be more than one (up to 32), - * separated by \c ';' characters. Some functions take one or more - * comma-separated arguments in parentheses. - * - * The available functions are \c bartlett, \c bartlett_hann, - * \c blackman, \c blackman_harris_4term_92db, \c connes, \c flattop, - * \c gauss(STDDEV), \c hamming, \c hann, \c kaiser_bessel, \c nuttall, - * \c rectangle, \c triangle, \c tukey(P), \c partial_tukey(n[/ov[/P]]), - * \c punchout_tukey(n[/ov[/P]]), \c subdivide_tukey(n[/P]), \c welch. - * - * For \c gauss(STDDEV), STDDEV specifies the standard deviation - * (0blocksize / (2 ^ order). - * - * Set both min and max values to \c 0 to force a single context, - * whose Rice parameter is based on the residual signal variance. - * Otherwise, set a min and max order, and the encoder will search - * all orders, using the mean of each context for its Rice parameter, - * and use the best. - * - * \default \c 0 - * \param encoder An encoder instance to set. - * \param value See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value); - -/** Set the maximum partition order to search when coding the residual. - * This is used in tandem with - * FLAC__stream_encoder_set_min_residual_partition_order(). - * - * The partition order determines the context size in the residual. - * The context size will be approximately blocksize / (2 ^ order). - * - * Set both min and max values to \c 0 to force a single context, - * whose Rice parameter is based on the residual signal variance. - * Otherwise, set a min and max order, and the encoder will search - * all orders, using the mean of each context for its Rice parameter, - * and use the best. - * - * \default \c 5 - * \param encoder An encoder instance to set. - * \param value See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value); - -/** Deprecated. Setting this value has no effect. - * - * \default \c 0 - * \param encoder An encoder instance to set. - * \param value See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, uint32_t value); - -/** Set an estimate of the total samples that will be encoded. - * This is merely an estimate and may be set to \c 0 if unknown. - * This value will be written to the STREAMINFO block before encoding, - * and can remove the need for the caller to rewrite the value later - * if the value is known before encoding. - * - * \default \c 0 - * \param encoder An encoder instance to set. - * \param value See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value); - -/** Set the metadata blocks to be emitted to the stream before encoding. - * A value of \c NULL, \c 0 implies no metadata; otherwise, supply an - * array of pointers to metadata blocks. The array is non-const since - * the encoder may need to change the \a is_last flag inside them, and - * in some cases update seek point offsets. Otherwise, the encoder will - * not modify or free the blocks. It is up to the caller to free the - * metadata blocks after encoding finishes. - * - * \note - * The encoder stores only copies of the pointers in the \a metadata array; - * the metadata blocks themselves must survive at least until after - * FLAC__stream_encoder_finish() returns. Do not free the blocks until then. - * - * \note - * The STREAMINFO block is always written and no STREAMINFO block may - * occur in the supplied array. - * - * \note - * By default the encoder does not create a SEEKTABLE. If one is supplied - * in the \a metadata array, but the client has specified that it does not - * support seeking, then the SEEKTABLE will be written verbatim. However - * by itself this is not very useful as the client will not know the stream - * offsets for the seekpoints ahead of time. In order to get a proper - * seektable the client must support seeking. See next note. - * - * \note - * SEEKTABLE blocks are handled specially. Since you will not know - * the values for the seek point stream offsets, you should pass in - * a SEEKTABLE 'template', that is, a SEEKTABLE object with the - * required sample numbers (or placeholder points), with \c 0 for the - * \a frame_samples and \a stream_offset fields for each point. If the - * client has specified that it supports seeking by providing a seek - * callback to FLAC__stream_encoder_init_stream() or both seek AND read - * callback to FLAC__stream_encoder_init_ogg_stream() (or by using - * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE()), - * then while it is encoding the encoder will fill the stream offsets in - * for you and when encoding is finished, it will seek back and write the - * real values into the SEEKTABLE block in the stream. There are helper - * routines for manipulating seektable template blocks; see metadata.h: - * FLAC__metadata_object_seektable_template_*(). If the client does - * not support seeking, the SEEKTABLE will have inaccurate offsets which - * will slow down or remove the ability to seek in the FLAC stream. - * - * \note - * The encoder instance \b will modify the first \c SEEKTABLE block - * as it transforms the template to a valid seektable while encoding, - * but it is still up to the caller to free all metadata blocks after - * encoding. - * - * \note - * A VORBIS_COMMENT block may be supplied. The vendor string in it - * will be ignored. libFLAC will use it's own vendor string. libFLAC - * will not modify the passed-in VORBIS_COMMENT's vendor string, it - * will simply write it's own into the stream. If no VORBIS_COMMENT - * block is present in the \a metadata array, libFLAC will write an - * empty one, containing only the vendor string. - * - * \note The Ogg FLAC mapping requires that the VORBIS_COMMENT block be - * the second metadata block of the stream. The encoder already supplies - * the STREAMINFO block automatically. If \a metadata does not contain a - * VORBIS_COMMENT block, the encoder will supply that too. Otherwise, if - * \a metadata does contain a VORBIS_COMMENT block and it is not the - * first, the init function will reorder \a metadata by moving the - * VORBIS_COMMENT block to the front; the relative ordering of the other - * blocks will remain as they were. - * - * \note The Ogg FLAC mapping limits the number of metadata blocks per - * stream to \c 65535. If \a num_blocks exceeds this the function will - * return \c false. - * - * \default \c NULL, 0 - * \param encoder An encoder instance to set. - * \param metadata See above. - * \param num_blocks See above. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - * \c false if the encoder is already initialized, or if - * \a num_blocks > 65535 if encoding to Ogg FLAC, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, uint32_t num_blocks); - -/** Set to \c true to make the encoder not output frames which contain - * only constant subframes. This is beneficial for streaming - * applications: very small frames can cause problems with buffering - * as bitrates can drop as low 1kbit/s for CDDA audio encoded within - * subset. The minimum bitrate for a FLAC file encoded with this - * function used is raised to 1bit/sample (i.e. 48kbit/s for 48kHz - * material). - * - * \default \c false - * \param encoder An encoder instance to set. - * \param value Flag value (see above). - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if the encoder is already initialized, else \c true. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_limit_min_bitrate(FLAC__StreamEncoder *encoder, FLAC__bool value); - -/** Get the current encoder state. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__StreamEncoderState - * The current encoder state. - */ -FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder); - -/** Get the state of the verify stream decoder. - * Useful when the stream encoder state is - * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__StreamDecoderState - * The verify stream decoder state. - */ -FLAC_API FLAC__StreamDecoderState FLAC__stream_encoder_get_verify_decoder_state(const FLAC__StreamEncoder *encoder); - -/** Get the current encoder state as a C string. - * This version automatically resolves - * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR by getting the - * verify decoder's state. - * - * \param encoder A encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval const char * - * The encoder state as a C string. Do not modify the contents. - */ -FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__StreamEncoder *encoder); - -/** Get relevant values about the nature of a verify decoder error. - * Useful when the stream encoder state is - * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR. The arguments should - * be addresses in which the stats will be returned, or NULL if value - * is not desired. - * - * \param encoder An encoder instance to query. - * \param absolute_sample The absolute sample number of the mismatch. - * \param frame_number The number of the frame in which the mismatch occurred. - * \param channel The channel in which the mismatch occurred. - * \param sample The number of the sample (relative to the frame) in - * which the mismatch occurred. - * \param expected The expected value for the sample in question. - * \param got The actual value returned by the decoder. - * \assert - * \code encoder != NULL \endcode - */ -FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got); - -/** Get the "verify" flag. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * See FLAC__stream_encoder_set_verify(). - */ -FLAC_API FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder); - -/** Get the Subset flag. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * See FLAC__stream_encoder_set_streamable_subset(). - */ -FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder); - -/** Get the number of input channels being processed. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval uint32_t - * See FLAC__stream_encoder_set_channels(). - */ -FLAC_API uint32_t FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder); - -/** Get the input sample resolution setting. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval uint32_t - * See FLAC__stream_encoder_set_bits_per_sample(). - */ -FLAC_API uint32_t FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder); - -/** Get the input sample rate setting. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval uint32_t - * See FLAC__stream_encoder_set_sample_rate(). - */ -FLAC_API uint32_t FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder); - -/** Get the blocksize setting. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval uint32_t - * See FLAC__stream_encoder_set_blocksize(). - */ -FLAC_API uint32_t FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder); - -/** Get the "mid/side stereo coding" flag. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * See FLAC__stream_encoder_get_do_mid_side_stereo(). - */ -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder); - -/** Get the "adaptive mid/side switching" flag. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * See FLAC__stream_encoder_set_loose_mid_side_stereo(). - */ -FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder); - -/** Get the maximum LPC order setting. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval uint32_t - * See FLAC__stream_encoder_set_max_lpc_order(). - */ -FLAC_API uint32_t FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder); - -/** Get the quantized linear predictor coefficient precision setting. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval uint32_t - * See FLAC__stream_encoder_set_qlp_coeff_precision(). - */ -FLAC_API uint32_t FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder); - -/** Get the qlp coefficient precision search flag. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * See FLAC__stream_encoder_set_do_qlp_coeff_prec_search(). - */ -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder); - -/** Get the "escape coding" flag. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * See FLAC__stream_encoder_set_do_escape_coding(). - */ -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder); - -/** Get the exhaustive model search flag. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * See FLAC__stream_encoder_set_do_exhaustive_model_search(). - */ -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder); - -/** Get the minimum residual partition order setting. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval uint32_t - * See FLAC__stream_encoder_set_min_residual_partition_order(). - */ -FLAC_API uint32_t FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder); - -/** Get maximum residual partition order setting. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval uint32_t - * See FLAC__stream_encoder_set_max_residual_partition_order(). - */ -FLAC_API uint32_t FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder); - -/** Get the Rice parameter search distance setting. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval uint32_t - * See FLAC__stream_encoder_set_rice_parameter_search_dist(). - */ -FLAC_API uint32_t FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder); - -/** Get the previously set estimate of the total samples to be encoded. - * The encoder merely mimics back the value given to - * FLAC__stream_encoder_set_total_samples_estimate() since it has no - * other way of knowing how many samples the client will encode. - * - * \param encoder An encoder instance to set. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__uint64 - * See FLAC__stream_encoder_get_total_samples_estimate(). - */ -FLAC_API FLAC__uint64 FLAC__stream_encoder_get_total_samples_estimate(const FLAC__StreamEncoder *encoder); - -/** Get the "limit_min_bitrate" flag. - * - * \param encoder An encoder instance to query. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * See FLAC__stream_encoder_set_limit_min_bitrate(). - */ -FLAC_API FLAC__bool FLAC__stream_encoder_get_limit_min_bitrate(const FLAC__StreamEncoder *encoder); - -/** Initialize the encoder instance to encode native FLAC streams. - * - * This flavor of initialization sets up the encoder to encode to a - * native FLAC stream. I/O is performed via callbacks to the client. - * For encoding to a plain file via filename or open \c FILE*, - * FLAC__stream_encoder_init_file() and FLAC__stream_encoder_init_FILE() - * provide a simpler interface. - * - * This function should be called after FLAC__stream_encoder_new() and - * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() - * or FLAC__stream_encoder_process_interleaved(). - * initialization succeeded. - * - * The call to FLAC__stream_encoder_init_stream() currently will also - * immediately call the write callback several times, once with the \c fLaC - * signature, and once for each encoded metadata block. - * - * \param encoder An uninitialized encoder instance. - * \param write_callback See FLAC__StreamEncoderWriteCallback. This - * pointer must not be \c NULL. - * \param seek_callback See FLAC__StreamEncoderSeekCallback. This - * pointer may be \c NULL if seeking is not - * supported. The encoder uses seeking to go back - * and write some some stream statistics to the - * STREAMINFO block; this is recommended but not - * necessary to create a valid FLAC stream. If - * \a seek_callback is not \c NULL then a - * \a tell_callback must also be supplied. - * Alternatively, a dummy seek callback that just - * returns \c FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the encoder. - * \param tell_callback See FLAC__StreamEncoderTellCallback. This - * pointer may be \c NULL if seeking is not - * supported. If \a seek_callback is \c NULL then - * this argument will be ignored. If - * \a seek_callback is not \c NULL then a - * \a tell_callback must also be supplied. - * Alternatively, a dummy tell callback that just - * returns \c FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the encoder. - * \param metadata_callback See FLAC__StreamEncoderMetadataCallback. This - * pointer may be \c NULL if the callback is not - * desired. If the client provides a seek callback, - * this function is not necessary as the encoder - * will automatically seek back and update the - * STREAMINFO block. It may also be \c NULL if the - * client does not support seeking, since it will - * have no way of going back to update the - * STREAMINFO. However the client can still supply - * a callback if it would like to know the details - * from the STREAMINFO. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__StreamEncoderInitStatus - * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamEncoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data); - -/** Initialize the encoder instance to encode Ogg FLAC streams. - * - * This flavor of initialization sets up the encoder to encode to a FLAC - * stream in an Ogg container. I/O is performed via callbacks to the - * client. For encoding to a plain file via filename or open \c FILE*, - * FLAC__stream_encoder_init_ogg_file() and FLAC__stream_encoder_init_ogg_FILE() - * provide a simpler interface. - * - * This function should be called after FLAC__stream_encoder_new() and - * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() - * or FLAC__stream_encoder_process_interleaved(). - * initialization succeeded. - * - * The call to FLAC__stream_encoder_init_ogg_stream() currently will also - * immediately call the write callback several times to write the metadata - * packets. - * - * \param encoder An uninitialized encoder instance. - * \param read_callback See FLAC__StreamEncoderReadCallback. This - * pointer must not be \c NULL if \a seek_callback - * is non-NULL since they are both needed to be - * able to write data back to the Ogg FLAC stream - * in the post-encode phase. - * \param write_callback See FLAC__StreamEncoderWriteCallback. This - * pointer must not be \c NULL. - * \param seek_callback See FLAC__StreamEncoderSeekCallback. This - * pointer may be \c NULL if seeking is not - * supported. The encoder uses seeking to go back - * and write some some stream statistics to the - * STREAMINFO block; this is recommended but not - * necessary to create a valid FLAC stream. If - * \a seek_callback is not \c NULL then a - * \a tell_callback must also be supplied. - * Alternatively, a dummy seek callback that just - * returns \c FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the encoder. - * \param tell_callback See FLAC__StreamEncoderTellCallback. This - * pointer may be \c NULL if seeking is not - * supported. If \a seek_callback is \c NULL then - * this argument will be ignored. If - * \a seek_callback is not \c NULL then a - * \a tell_callback must also be supplied. - * Alternatively, a dummy tell callback that just - * returns \c FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED - * may also be supplied, all though this is slightly - * less efficient for the encoder. - * \param metadata_callback See FLAC__StreamEncoderMetadataCallback. This - * pointer may be \c NULL if the callback is not - * desired. If the client provides a seek callback, - * this function is not necessary as the encoder - * will automatically seek back and update the - * STREAMINFO block. It may also be \c NULL if the - * client does not support seeking, since it will - * have no way of going back to update the - * STREAMINFO. However the client can still supply - * a callback if it would like to know the details - * from the STREAMINFO. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__StreamEncoderInitStatus - * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamEncoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderReadCallback read_callback, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data); - -/** Initialize the encoder instance to encode native FLAC files. - * - * This flavor of initialization sets up the encoder to encode to a - * plain native FLAC file. For non-stdio streams, you must use - * FLAC__stream_encoder_init_stream() and provide callbacks for the I/O. - * - * This function should be called after FLAC__stream_encoder_new() and - * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() - * or FLAC__stream_encoder_process_interleaved(). - * initialization succeeded. - * - * \param encoder An uninitialized encoder instance. - * \param file An open file. The file should have been opened - * with mode \c "w+b" and rewound. The file - * becomes owned by the encoder and should not be - * manipulated by the client while encoding. - * Unless \a file is \c stdout, it will be closed - * when FLAC__stream_encoder_finish() is called. - * Note however that a proper SEEKTABLE cannot be - * created when encoding to \c stdout since it is - * not seekable. - * \param progress_callback See FLAC__StreamEncoderProgressCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code encoder != NULL \endcode - * \code file != NULL \endcode - * \retval FLAC__StreamEncoderInitStatus - * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamEncoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data); - -/** Initialize the encoder instance to encode Ogg FLAC files. - * - * This flavor of initialization sets up the encoder to encode to a - * plain Ogg FLAC file. For non-stdio streams, you must use - * FLAC__stream_encoder_init_ogg_stream() and provide callbacks for the I/O. - * - * This function should be called after FLAC__stream_encoder_new() and - * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() - * or FLAC__stream_encoder_process_interleaved(). - * initialization succeeded. - * - * \param encoder An uninitialized encoder instance. - * \param file An open file. The file should have been opened - * with mode \c "w+b" and rewound. The file - * becomes owned by the encoder and should not be - * manipulated by the client while encoding. - * Unless \a file is \c stdout, it will be closed - * when FLAC__stream_encoder_finish() is called. - * Note however that a proper SEEKTABLE cannot be - * created when encoding to \c stdout since it is - * not seekable. - * \param progress_callback See FLAC__StreamEncoderProgressCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code encoder != NULL \endcode - * \code file != NULL \endcode - * \retval FLAC__StreamEncoderInitStatus - * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamEncoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data); - -/** Initialize the encoder instance to encode native FLAC files. - * - * This flavor of initialization sets up the encoder to encode to a plain - * FLAC file. If POSIX fopen() semantics are not sufficient you must use - * FLAC__stream_encoder_init_FILE(), or FLAC__stream_encoder_init_stream() - * and provide callbacks for the I/O. - * - * On Windows, filename must be a UTF-8 encoded filename, which libFLAC - * internally translates to an appropriate representation to use with - * _wfopen. On all other systems, filename is passed to fopen without - * any translation. - * - * This function should be called after FLAC__stream_encoder_new() and - * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() - * or FLAC__stream_encoder_process_interleaved(). - * initialization succeeded. - * - * \param encoder An uninitialized encoder instance. - * \param filename The name of the file to encode to. The file will - * be opened with fopen(). Use \c NULL to encode to - * \c stdout. Note however that a proper SEEKTABLE - * cannot be created when encoding to \c stdout since - * it is not seekable. - * \param progress_callback See FLAC__StreamEncoderProgressCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__StreamEncoderInitStatus - * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamEncoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data); - -/** Initialize the encoder instance to encode Ogg FLAC files. - * - * This flavor of initialization sets up the encoder to encode to a plain - * Ogg FLAC file. If POSIX fopen() semantics are not sufficient, you must use - * FLAC__stream_encoder_init_ogg_FILE(), or FLAC__stream_encoder_init_ogg_stream() - * and provide callbacks for the I/O. - * - * On Windows, filename must be a UTF-8 encoded filename, which libFLAC - * internally translates to an appropriate representation to use with - * _wfopen. On all other systems, filename is passed to fopen without - * any translation. - * - * This function should be called after FLAC__stream_encoder_new() and - * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process() - * or FLAC__stream_encoder_process_interleaved(). - * initialization succeeded. - * - * \param encoder An uninitialized encoder instance. - * \param filename The name of the file to encode to. The file will - * be opened with fopen(). Use \c NULL to encode to - * \c stdout. Note however that a proper SEEKTABLE - * cannot be created when encoding to \c stdout since - * it is not seekable. - * \param progress_callback See FLAC__StreamEncoderProgressCallback. This - * pointer may be \c NULL if the callback is not - * desired. - * \param client_data This value will be supplied to callbacks in their - * \a client_data argument. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__StreamEncoderInitStatus - * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful; - * see FLAC__StreamEncoderInitStatus for the meanings of other return values. - */ -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data); - -/** Finish the encoding process. - * Flushes the encoding buffer, releases resources, resets the encoder - * settings to their defaults, and returns the encoder state to - * FLAC__STREAM_ENCODER_UNINITIALIZED. Note that this can generate - * one or more write callbacks before returning, and will generate - * a metadata callback. - * - * Note that in the course of processing the last frame, errors can - * occur, so the caller should be sure to check the return value to - * ensure the file was encoded properly. - * - * In the event of a prematurely-terminated encode, it is not strictly - * necessary to call this immediately before FLAC__stream_encoder_delete() - * but it is good practice to match every FLAC__stream_encoder_init_*() - * with a FLAC__stream_encoder_finish(). - * - * \param encoder An uninitialized encoder instance. - * \assert - * \code encoder != NULL \endcode - * \retval FLAC__bool - * \c false if an error occurred processing the last frame; or if verify - * mode is set (see FLAC__stream_encoder_set_verify()), there was a - * verify mismatch; else \c true. If \c false, caller should check the - * state with FLAC__stream_encoder_get_state() for more information - * about the error. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder); - -/** Submit data for encoding. - * This version allows you to supply the input data via an array of - * pointers, each pointer pointing to an array of \a samples samples - * representing one channel. The samples need not be block-aligned, - * but each channel should have the same number of samples. Each sample - * should be a signed integer, right-justified to the resolution set by - * FLAC__stream_encoder_set_bits_per_sample(). For example, if the - * resolution is 16 bits per sample, the samples should all be in the - * range [-32768,32767]. - * - * For applications where channel order is important, channels must - * follow the order as described in the - * frame header. - * - * \param encoder An initialized encoder instance in the OK state. - * \param buffer An array of pointers to each channel's signal. - * \param samples The number of samples in one channel. - * \assert - * \code encoder != NULL \endcode - * \code FLAC__stream_encoder_get_state(encoder) == FLAC__STREAM_ENCODER_OK \endcode - * \retval FLAC__bool - * \c true if successful, else \c false; in this case, check the - * encoder state with FLAC__stream_encoder_get_state() to see what - * went wrong. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], uint32_t samples); - -/** Submit data for encoding. - * This version allows you to supply the input data where the channels - * are interleaved into a single array (i.e. channel0_sample0, - * channel1_sample0, ... , channelN_sample0, channel0_sample1, ...). - * The samples need not be block-aligned but they must be - * sample-aligned, i.e. the first value should be channel0_sample0 - * and the last value channelN_sampleM. Each sample should be a signed - * integer, right-justified to the resolution set by - * FLAC__stream_encoder_set_bits_per_sample(). For example, if the - * resolution is 16 bits per sample, the samples should all be in the - * range [-32768,32767]. - * - * For applications where channel order is important, channels must - * follow the order as described in the - * frame header. - * - * \param encoder An initialized encoder instance in the OK state. - * \param buffer An array of channel-interleaved data (see above). - * \param samples The number of samples in one channel, the same as for - * FLAC__stream_encoder_process(). For example, if - * encoding two channels, \c 1000 \a samples corresponds - * to a \a buffer of 2000 values. - * \assert - * \code encoder != NULL \endcode - * \code FLAC__stream_encoder_get_state(encoder) == FLAC__STREAM_ENCODER_OK \endcode - * \retval FLAC__bool - * \c true if successful, else \c false; in this case, check the - * encoder state with FLAC__stream_encoder_get_state() to see what - * went wrong. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], uint32_t samples); - -/* \} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/Makefile.am b/Engine/lib/flac/include/Makefile.am deleted file mode 100644 index 01c5c9b62..000000000 --- a/Engine/lib/flac/include/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -if FLaC__WITH_CPPLIBS -CPPLIBS_DIRS = FLAC++ -endif - -SUBDIRS = FLAC $(CPPLIBS_DIRS) share test_libs_common diff --git a/Engine/lib/flac/include/share/Makefile.am b/Engine/lib/flac/include/share/Makefile.am deleted file mode 100644 index a6a3ca0fb..000000000 --- a/Engine/lib/flac/include/share/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = grabbag - -EXTRA_DIST = \ - alloc.h \ - compat.h \ - endswap.h \ - getopt.h \ - grabbag.h \ - macros.h \ - private.h \ - replaygain_analysis.h \ - replaygain_synthesis.h \ - safe_str.h \ - utf8.h \ - win_utf8_io.h diff --git a/Engine/lib/flac/include/share/alloc.h b/Engine/lib/flac/include/share/alloc.h deleted file mode 100644 index b0da6941d..000000000 --- a/Engine/lib/flac/include/share/alloc.h +++ /dev/null @@ -1,318 +0,0 @@ -/* alloc - Convenience routines for safely allocating memory - * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__SHARE__ALLOC_H -#define FLAC__SHARE__ALLOC_H - -#ifdef HAVE_CONFIG_H -# include -#endif - -/* WATCHOUT: for c++ you may have to #define __STDC_LIMIT_MACROS 1 real early - * before #including this file, otherwise SIZE_MAX might not be defined - */ - -#include /* for SIZE_MAX */ -#ifdef HAVE_STDINT_H -#include /* for SIZE_MAX in case limits.h didn't get it */ -#endif -#include /* for size_t, malloc(), etc */ -#include "share/compat.h" - -#ifndef SIZE_MAX -# ifndef SIZE_T_MAX -# ifdef _MSC_VER -# ifdef _WIN64 -# define SIZE_T_MAX FLAC__U64L(0xffffffffffffffff) -# else -# define SIZE_T_MAX 0xffffffff -# endif -# else -# error -# endif -# endif -# define SIZE_MAX SIZE_T_MAX -#endif - -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -extern int alloc_check_threshold, alloc_check_counter; - -static inline int alloc_check() { - if(alloc_check_threshold == INT32_MAX) - return 0; - else if(alloc_check_counter++ == alloc_check_threshold) - return 1; - else - return 0; -} - -#endif - -/* avoid malloc()ing 0 bytes, see: - * https://www.securecoding.cert.org/confluence/display/seccode/MEM04-A.+Do+not+make+assumptions+about+the+result+of+allocating+0+bytes?focusedCommentId=5407003 -*/ - -static inline void *safe_malloc_(size_t size) -{ -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* Fail if requested */ - if(alloc_check()) - return NULL; -#endif - /* malloc(0) is undefined; FLAC src convention is to always allocate */ - if(!size) - size++; - return malloc(size); -} - -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -static inline void *malloc_(size_t size) -{ - /* Fail if requested */ - if(alloc_check()) - return NULL; - return malloc(size); -} -#else -#define malloc_ malloc -#endif - - - -static inline void *safe_calloc_(size_t nmemb, size_t size) -{ -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* Fail if requested */ - if(alloc_check()) - return NULL; -#endif - if(!nmemb || !size) - return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ - return calloc(nmemb, size); -} - -/*@@@@ there's probably a better way to prevent overflows when allocating untrusted sums but this works for now */ - -static inline void *safe_malloc_add_2op_(size_t size1, size_t size2) -{ - size2 += size1; - if(size2 < size1) - return 0; - return safe_malloc_(size2); -} - -static inline void *safe_malloc_add_3op_(size_t size1, size_t size2, size_t size3) -{ - size2 += size1; - if(size2 < size1) - return 0; - size3 += size2; - if(size3 < size2) - return 0; - return safe_malloc_(size3); -} - -static inline void *safe_malloc_add_4op_(size_t size1, size_t size2, size_t size3, size_t size4) -{ - size2 += size1; - if(size2 < size1) - return 0; - size3 += size2; - if(size3 < size2) - return 0; - size4 += size3; - if(size4 < size3) - return 0; - return safe_malloc_(size4); -} - -void *safe_malloc_mul_2op_(size_t size1, size_t size2) ; - -static inline void *safe_malloc_mul_3op_(size_t size1, size_t size2, size_t size3) -{ - if(!size1 || !size2 || !size3) - return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ - if(size1 > SIZE_MAX / size2) - return 0; - size1 *= size2; - if(size1 > SIZE_MAX / size3) - return 0; - return malloc_(size1*size3); -} - -/* size1*size2 + size3 */ -static inline void *safe_malloc_mul2add_(size_t size1, size_t size2, size_t size3) -{ - if(!size1 || !size2) - return safe_malloc_(size3); - if(size1 > SIZE_MAX / size2) - return 0; - return safe_malloc_add_2op_(size1*size2, size3); -} - -/* size1 * (size2 + size3) */ -static inline void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size3) -{ - if(!size1 || (!size2 && !size3)) - return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ - size2 += size3; - if(size2 < size3) - return 0; - if(size1 > SIZE_MAX / size2) - return 0; - return malloc_(size1*size2); -} - -static inline void *safe_realloc_(void *ptr, size_t size) -{ - void *oldptr; - void *newptr; -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* Fail if requested */ - if(alloc_check() && size > 0) { - free(ptr); - return NULL; - } -#endif - oldptr = ptr; - newptr = realloc(ptr, size); - if(size > 0 && newptr == 0) - free(oldptr); - return newptr; -} - -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -static inline void *realloc_(void *ptr, size_t size) -{ - /* Fail if requested */ - if(alloc_check()) - return NULL; - return realloc(ptr, size); -} -#else -#define realloc_ realloc -#endif - - -static inline void *safe_realloc_nofree_add_2op_(void *ptr, size_t size1, size_t size2) -{ - size2 += size1; - if(size2 < size1) - return 0; - return realloc_(ptr, size2); -} - -static inline void *safe_realloc_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3) -{ - size2 += size1; - if(size2 < size1) { - free(ptr); - return 0; - } - size3 += size2; - if(size3 < size2) { - free(ptr); - return 0; - } - return safe_realloc_(ptr, size3); -} - -static inline void *safe_realloc_nofree_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3) -{ - size2 += size1; - if(size2 < size1) - return 0; - size3 += size2; - if(size3 < size2) - return 0; - return realloc_(ptr, size3); -} - -static inline void *safe_realloc_nofree_add_4op_(void *ptr, size_t size1, size_t size2, size_t size3, size_t size4) -{ - size2 += size1; - if(size2 < size1) - return 0; - size3 += size2; - if(size3 < size2) - return 0; - size4 += size3; - if(size4 < size3) - return 0; - return realloc_(ptr, size4); -} - -static inline void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2) -{ - if(!size1 || !size2) - return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */ - if(size1 > SIZE_MAX / size2) { - free(ptr); - return 0; - } - return safe_realloc_(ptr, size1*size2); -} - -static inline void *safe_realloc_nofree_mul_2op_(void *ptr, size_t size1, size_t size2) -{ - if(!size1 || !size2) - return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */ - if(size1 > SIZE_MAX / size2) - return 0; - return realloc_(ptr, size1*size2); -} - -/* size1 * (size2 + size3) */ -static inline void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3) -{ - if(!size1 || (!size2 && !size3)) - return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */ - size2 += size3; - if(size2 < size3) { - free(ptr); - return 0; - } - return safe_realloc_mul_2op_(ptr, size1, size2); -} - -/* size1 * (size2 + size3) */ -static inline void *safe_realloc_nofree_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3) -{ - if(!size1 || (!size2 && !size3)) - return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */ - size2 += size3; - if(size2 < size3) - return 0; - return safe_realloc_nofree_mul_2op_(ptr, size1, size2); -} - -#endif diff --git a/Engine/lib/flac/include/share/compat.h b/Engine/lib/flac/include/share/compat.h deleted file mode 100644 index 6ce23a5c0..000000000 --- a/Engine/lib/flac/include/share/compat.h +++ /dev/null @@ -1,240 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -/* This is the preferred location of all CPP hackery to make $random_compiler - * work like something approaching a C99 (or maybe more accurately GNU99) - * compiler. - * - * It is assumed that this header will be included after "config.h". - */ - -#ifndef FLAC__SHARE__COMPAT_H -#define FLAC__SHARE__COMPAT_H - -#include -#include - -#if defined _WIN32 && !defined __CYGWIN__ -/* where MSVC puts unlink() */ -# include -#else -# include -#endif - -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#include /* for off_t */ -#define FLAC__off_t __int64 /* use this instead of off_t to fix the 2 GB limit */ -#define FLAC__OFF_T_MAX INT64_MAX -#if !defined __MINGW32__ -#define fseeko _fseeki64 -#define ftello _ftelli64 -#else /* MinGW */ -#if !defined(HAVE_FSEEKO) -#define fseeko fseeko64 -#define ftello ftello64 -#endif -#endif -#else -#define FLAC__off_t off_t -#define FLAC__OFF_T_MAX OFF_T_MAX -#endif - - - -#ifdef HAVE_INTTYPES_H -#define __STDC_FORMAT_MACROS -#include -#endif - -#if defined(_MSC_VER) -#define strtoll _strtoi64 -#define strtoull _strtoui64 -#endif - -#if defined(_MSC_VER) && !defined(__cplusplus) -#define inline __inline -#endif - -#if defined __INTEL_COMPILER || (defined _MSC_VER && defined _WIN64) -/* MSVS generates VERY slow 32-bit code with __restrict */ -#define flac_restrict __restrict -#elif defined __GNUC__ -#define flac_restrict __restrict__ -#else -#define flac_restrict -#endif - -#define FLAC__U64L(x) x##ULL - -#if defined _MSC_VER || defined __MINGW32__ -#define FLAC__STRCASECMP _stricmp -#define FLAC__STRNCASECMP _strnicmp -#elif defined __BORLANDC__ -#define FLAC__STRCASECMP stricmp -#define FLAC__STRNCASECMP strnicmp -#else -#define FLAC__STRCASECMP strcasecmp -#define FLAC__STRNCASECMP strncasecmp -#endif - -#if defined _MSC_VER || defined __MINGW32__ || defined __EMX__ -#include /* for _setmode(), chmod() */ -#include /* for _O_BINARY */ -#else -#include /* for chown(), unlink() */ -#endif - -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#if defined __BORLANDC__ -#include /* for utime() */ -#else -#include /* for utime() */ -#endif -#else -#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) -#include -#else -#include /* some flavors of BSD (like OS X) require this to get time_t */ -#include /* for utime() */ -#endif -#endif - -#if defined _MSC_VER -# if _MSC_VER >= 1800 -# include -# elif _MSC_VER >= 1600 -/* Visual Studio 2010 has decent C99 support */ -# include -# define PRIu64 "llu" -# define PRId64 "lld" -# define PRIx64 "llx" -# else -# include -# ifndef UINT32_MAX -# define UINT32_MAX _UI32_MAX -# endif -# define PRIu64 "I64u" -# define PRId64 "I64d" -# define PRIx64 "I64x" -# endif -# if defined(_USING_V110_SDK71_) && !defined(_DLL) -# pragma message("WARNING: This compile will NOT FUNCTION PROPERLY on Windows XP. See comments in include/share/compat.h for details") -#define FLAC__USE_FILELENGTHI64 -/* - ************************************************************************************* - * V110_SDK71, in MSVC 2017 also known as v141_xp, is a platform toolset that is supposed - * to target Windows XP. It turns out however that certain functions provided silently fail - * on Windows XP only, which makes debugging challenging. This only occurs when building with - * /MT. This problem has been reported to Microsoft, but there hasn't been a fix for years. See - * https://web.archive.org/web/20170327195018/https://connect.microsoft.com/VisualStudio/feedback/details/1557168/wstat64-returns-1-on-xp-always - * - * It is known that this problem affects the functions _wstat64 (used by flac_stat i.e. - * stat64_utf8) and _fstat64 (i.e. flac_fstat) and therefore affects both libFLAC in - * several places as well as the flac and metaflac command line tools - * - * As the extent of this problem is unknown and Microsoft seems unwilling to fix it, - * users of libFLAC building with Visual Studio are encouraged to not use the /MT compile - * switch when explicitly targeting Windows XP. When use of /MT is deemed necessary with - * this toolset, be sure to check whether your application works properly on Windows XP. - * It is also possible to build for Windows XP with MinGW instead. - ************************************************************************************* -*/ -# endif -#endif /* defined _MSC_VER */ - -#ifdef _WIN32 -/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */ - -#include "share/win_utf8_io.h" -#define flac_printf printf_utf8 -#define flac_fprintf fprintf_utf8 -#define flac_vfprintf vfprintf_utf8 -#define flac_fopen fopen_utf8 -#define flac_chmod chmod_utf8 -#define flac_utime utime_utf8 -#define flac_unlink unlink_utf8 -#define flac_rename rename_utf8 -#define flac_stat stat64_utf8 - -#else - -#define flac_printf printf -#define flac_fprintf fprintf -#define flac_vfprintf vfprintf - -#define flac_fopen fopen -#define flac_chmod chmod -#define flac_unlink unlink -#define flac_rename rename -#define flac_stat stat - -#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) -#define flac_utime(a, b) utimensat (AT_FDCWD, a, *b, 0) -#else -#define flac_utime utime -#endif -#endif - -#ifdef _WIN32 -#define flac_stat_s __stat64 /* stat struct */ -#define flac_fstat _fstat64 -#else -#define flac_stat_s stat /* stat struct */ -#define flac_fstat fstat -#endif - -#ifdef ANDROID -#include -#endif - -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 -#endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -/* FLAC needs to compile and work correctly on systems with a normal ISO C99 - * snprintf as well as Microsoft Visual Studio which has an non-standards - * conformant snprint_s function. - * - * This function wraps the MS version to behave more like the ISO version. - */ -#ifdef __cplusplus -extern "C" { -#endif -int flac_snprintf(char *str, size_t size, const char *fmt, ...); -int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va); -#ifdef __cplusplus -}; -#endif - -#endif /* FLAC__SHARE__COMPAT_H */ diff --git a/Engine/lib/flac/include/share/endswap.h b/Engine/lib/flac/include/share/endswap.h deleted file mode 100644 index 8687b9d76..000000000 --- a/Engine/lib/flac/include/share/endswap.h +++ /dev/null @@ -1,84 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -/* It is assumed that this header will be included after "config.h". */ - -#ifdef HAVE_BSWAP32 /* GCC and Clang */ - -/* GCC prior to 4.8 didn't provide bswap16 on x86_64 */ -#ifndef HAVE_BSWAP16 -static inline unsigned short __builtin_bswap16(unsigned short a) -{ - return (a<<8)|(a>>8); -} -#endif - -#define ENDSWAP_16(x) (__builtin_bswap16 (x)) -#define ENDSWAP_32(x) (__builtin_bswap32 (x)) -#define ENDSWAP_64(x) (__builtin_bswap64 (x)) - -#elif defined _MSC_VER /* Windows */ - -#include - -#define ENDSWAP_16(x) (_byteswap_ushort (x)) -#define ENDSWAP_32(x) (_byteswap_ulong (x)) -#define ENDSWAP_64(x) (_byteswap_uint64 (x)) - -#elif defined HAVE_BYTESWAP_H /* Linux */ - -#include - -#define ENDSWAP_16(x) (bswap_16 (x)) -#define ENDSWAP_32(x) (bswap_32 (x)) -#define ENDSWAP_64(x) (bswap_64 (x)) - -#else - -#define ENDSWAP_16(x) ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8)) -#define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) & 0xFF00) << 8) | (((x) & 0xFF) << 24)) -#define ENDSWAP_64(x) ((ENDSWAP_32(((x) >> 32) & 0xFFFFFFFF)) | (ENDSWAP_32((x) & 0xFFFFFFFF) << 32)) - -#endif - - -/* Host to little-endian byte swapping (for MD5 calculation) */ -#if CPU_IS_BIG_ENDIAN - -#define H2LE_16(x) ENDSWAP_16 (x) -#define H2LE_32(x) ENDSWAP_32 (x) - -#else - -#define H2LE_16(x) (x) -#define H2LE_32(x) (x) - -#endif diff --git a/Engine/lib/flac/include/share/getopt.h b/Engine/lib/flac/include/share/getopt.h deleted file mode 100644 index 66aced0f4..000000000 --- a/Engine/lib/flac/include/share/getopt.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - NOTE: - I cannot get the vanilla getopt code to work (i.e. compile only what - is needed and not duplicate symbols found in the standard library) - on all the platforms that FLAC supports. In particular the gating - of code with the ELIDE_CODE #define is not accurate enough on systems - that are POSIX but not glibc. If someone has a patch that works on - GNU/Linux, Darwin, AND Solaris please submit it on the project page: - https://sourceforge.net/p/flac/patches/ - - In the meantime I have munged the global symbols and removed gates - around code, while at the same time trying to touch the original as - little as possible. -*/ -/* Declarations for getopt. - Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -#ifndef SHARE__GETOPT_H -#define SHARE__GETOPT_H - -/*[JEC] was:#ifndef __need_getopt*/ -/*[JEC] was:# define _GETOPT_H 1*/ -/*[JEC] was:#endif*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* For communication from `share__getopt' to the caller. - When `share__getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *share__optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `share__getopt'. - - On entry to `share__getopt', zero means this is the first call; initialize. - - When `share__getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `share__optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int share__optind; - -/* Callers store zero here to inhibit the error message `share__getopt' prints - for unrecognized options. */ - -extern int share__opterr; - -/* Set to an option character which was unrecognized. */ - -extern int share__optopt; - -/*[JEC] was:#ifndef __need_getopt */ -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to share__getopt_long or share__getopt_long_only is a vector - of `struct share__option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - share__no_argument (or 0) if the option does not take an argument, - share__required_argument (or 1) if the option requires an argument, - share__optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `share__optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `share__getopt' - returns the contents of the `val' field. */ - -struct share__option -{ -# if defined __STDC__ && __STDC__ - const char *name; -# else - char *name; -# endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct share__option'. */ - -# define share__no_argument 0 -# define share__required_argument 1 -# define share__optional_argument 2 -/*[JEC] was:#endif*/ /* need getopt */ - - -/* Get definitions and prototypes for functions to process the - arguments in ARGV (ARGC of them, minus the program name) for - options given in OPTS. - - Return the option character from OPTS just read. Return -1 when - there are no more options. For unrecognized options, or options - missing arguments, `share__optopt' is set to the option letter, and '?' is - returned. - - The OPTS string is a list of characters which are recognized option - letters, optionally followed by colons, specifying that that letter - takes an argument, to be placed in `share__optarg'. - - If a letter in OPTS is followed by two colons, its argument is - optional. This behavior is specific to the GNU `share__getopt'. - - The argument `--' causes premature termination of argument - scanning, explicitly telling `share__getopt' that there are no more - options. - - If OPTS begins with `--', then non-option arguments are treated as - arguments to the option '\0'. This behavior is specific to the GNU - `share__getopt'. */ - -/*[JEC] was:#if defined __STDC__ && __STDC__*/ -/*[JEC] was:# ifdef __GNU_LIBRARY__*/ -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int share__getopt (int argc, char *const *argv, const char *shortopts); -/*[JEC] was:# else*/ /* not __GNU_LIBRARY__ */ -/*[JEC] was:extern int getopt ();*/ -/*[JEC] was:# endif*/ /* __GNU_LIBRARY__ */ - -/*[JEC] was:# ifndef __need_getopt*/ -extern int share__getopt_long (int argc, char *const *argv, const char *shortopts, - const struct share__option *longopts, int *longind); -extern int share__getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct share__option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int share___getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct share__option *longopts, int *longind, - int long_only); -/*[JEC] was:# endif*/ -/*[JEC] was:#else*/ /* not __STDC__ */ -/*[JEC] was:extern int getopt ();*/ -/*[JEC] was:# ifndef __need_getopt*/ -/*[JEC] was:extern int getopt_long ();*/ -/*[JEC] was:extern int getopt_long_only ();*/ - -/*[JEC] was:extern int _getopt_internal ();*/ -/*[JEC] was:# endif*/ -/*[JEC] was:#endif*/ /* __STDC__ */ - -#ifdef __cplusplus -} -#endif - -/* Make sure we later can get all the definitions and declarations. */ -/*[JEC] was:#undef __need_getopt*/ - -#endif /* getopt.h */ diff --git a/Engine/lib/flac/include/share/grabbag.h b/Engine/lib/flac/include/share/grabbag.h deleted file mode 100644 index 6424fa975..000000000 --- a/Engine/lib/flac/include/share/grabbag.h +++ /dev/null @@ -1,30 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef SHARE__GRABBAG_H -#define SHARE__GRABBAG_H - -/* These can't be included by themselves, only from within grabbag.h */ -#include "grabbag/cuesheet.h" -#include "grabbag/file.h" -#include "grabbag/picture.h" -#include "grabbag/replaygain.h" -#include "grabbag/seektable.h" - -#endif diff --git a/Engine/lib/flac/include/share/grabbag/Makefile.am b/Engine/lib/flac/include/share/grabbag/Makefile.am deleted file mode 100644 index 22baa1574..000000000 --- a/Engine/lib/flac/include/share/grabbag/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = \ - cuesheet.h \ - file.h \ - picture.h \ - replaygain.h \ - seektable.h diff --git a/Engine/lib/flac/include/share/grabbag/cuesheet.h b/Engine/lib/flac/include/share/grabbag/cuesheet.h deleted file mode 100644 index d0eb94d4e..000000000 --- a/Engine/lib/flac/include/share/grabbag/cuesheet.h +++ /dev/null @@ -1,43 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ - -#ifndef GRABBAG__CUESHEET_H -#define GRABBAG__CUESHEET_H - -#include -#include "FLAC/metadata.h" - -#ifdef __cplusplus -extern "C" { -#endif - -uint32_t grabbag__cuesheet_msf_to_frame(uint32_t minutes, uint32_t seconds, uint32_t frames); -void grabbag__cuesheet_frame_to_msf(uint32_t frame, uint32_t *minutes, uint32_t *seconds, uint32_t *frames); - -FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, uint32_t *last_line_read, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset); - -void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/share/grabbag/file.h b/Engine/lib/flac/include/share/grabbag/file.h deleted file mode 100644 index 9a2e086a7..000000000 --- a/Engine/lib/flac/include/share/grabbag/file.h +++ /dev/null @@ -1,65 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Convenience routines for manipulating files */ - -/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ - -#ifndef GRABAG__FILE_H -#define GRABAG__FILE_H - -/* needed because of off_t */ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include /* for off_t */ -#include /* for FILE */ -#include "FLAC/ordinals.h" -#include "share/compat.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void grabbag__file_copy_metadata(const char *srcpath, const char *destpath); -FLAC__off_t grabbag__file_get_filesize(const char *srcpath); -const char *grabbag__file_get_basename(const char *srcpath); - -/* read_only == false means "make file writable by user" - * read_only == true means "make file read-only for everyone" - */ -FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only); - -/* returns true iff stat() succeeds for both files and they have the same device and inode. */ -/* on windows, uses GetFileInformationByHandle() to compare */ -FLAC__bool grabbag__file_are_same(const char *f1, const char *f2); - -/* attempts to make writable before unlinking */ -FLAC__bool grabbag__file_remove_file(const char *filename); - -/* these will forcibly set stdin/stdout to binary mode (for OSes that require it) */ -FILE *grabbag__file_get_binary_stdin(void); -FILE *grabbag__file_get_binary_stdout(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/share/grabbag/picture.h b/Engine/lib/flac/include/share/grabbag/picture.h deleted file mode 100644 index 6bc4c3912..000000000 --- a/Engine/lib/flac/include/share/grabbag/picture.h +++ /dev/null @@ -1,54 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ - -#ifndef GRABBAG__PICTURE_H -#define GRABBAG__PICTURE_H - -#include "FLAC/metadata.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* spec should be of the form "[TYPE]|MIME_TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE", e.g. - * "|image/jpeg|||cover.jpg" - * "4|image/jpeg||300x300x24|backcover.jpg" - * "|image/png|description|300x300x24/71|cover.png" - * "-->|image/gif||300x300x24/71|http://blah.blah.blah/cover.gif" - * - * empty type means default to FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER - * empty resolution spec means to get from the file (cannot get used with "-->" linked images) - * spec and error_message must not be NULL - */ -FLAC__StreamMetadata *grabbag__picture_parse_specification(const char *spec, const char **error_message); - -typedef struct PictureResolution -{ uint32_t width, height, depth, colors ; -} PictureResolution ; - -FLAC__StreamMetadata *grabbag__picture_from_specification(int type, const char *mime_type, const char * description, - const PictureResolution * res, const char * filepath, const char **error_message); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/share/grabbag/replaygain.h b/Engine/lib/flac/include/share/grabbag/replaygain.h deleted file mode 100644 index 90e7a8c9e..000000000 --- a/Engine/lib/flac/include/share/grabbag/replaygain.h +++ /dev/null @@ -1,73 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* - * This wraps the replaygain_analysis lib, which is LGPL. This wrapper - * allows analysis of different input resolutions by automatically - * scaling the input signal - */ - -/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ - -#ifndef GRABBAG__REPLAYGAIN_H -#define GRABBAG__REPLAYGAIN_H - -#include "FLAC/metadata.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern const uint32_t GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED; - -extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS; /* = "REPLAYGAIN_REFERENCE_LOUDNESS" */ -extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN; /* = "REPLAYGAIN_TRACK_GAIN" */ -extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK; /* = "REPLAYGAIN_TRACK_PEAK" */ -extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN; /* = "REPLAYGAIN_ALBUM_GAIN" */ -extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK; /* = "REPLAYGAIN_ALBUM_PEAK" */ - -FLAC__bool grabbag__replaygain_is_valid_sample_frequency(uint32_t sample_frequency); - -FLAC__bool grabbag__replaygain_init(uint32_t sample_frequency); - -/* 'bps' must be valid for FLAC, i.e. >=4 and <= 32 */ -FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, uint32_t bps, uint32_t samples); - -void grabbag__replaygain_get_album(float *gain, float *peak); -void grabbag__replaygain_get_title(float *gain, float *peak); - -/* These three functions return an error string on error, or NULL if successful */ -const char *grabbag__replaygain_analyze_file(const char *filename, float *title_gain, float *title_peak); -const char *grabbag__replaygain_store_to_vorbiscomment(FLAC__StreamMetadata *block, float album_gain, float album_peak, float title_gain, float title_peak); -const char *grabbag__replaygain_store_to_vorbiscomment_reference(FLAC__StreamMetadata *block); -const char *grabbag__replaygain_store_to_vorbiscomment_album(FLAC__StreamMetadata *block, float album_gain, float album_peak); -const char *grabbag__replaygain_store_to_vorbiscomment_title(FLAC__StreamMetadata *block, float title_gain, float title_peak); -const char *grabbag__replaygain_store_to_file(const char *filename, float album_gain, float album_peak, float title_gain, float title_peak, FLAC__bool preserve_modtime); -const char *grabbag__replaygain_store_to_file_reference(const char *filename, FLAC__bool preserve_modtime); -const char *grabbag__replaygain_store_to_file_album(const char *filename, float album_gain, float album_peak, FLAC__bool preserve_modtime); -const char *grabbag__replaygain_store_to_file_title(const char *filename, float title_gain, float title_peak, FLAC__bool preserve_modtime); - -FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *reference, double *gain, double *peak); -double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/share/grabbag/seektable.h b/Engine/lib/flac/include/share/grabbag/seektable.h deleted file mode 100644 index 751995be6..000000000 --- a/Engine/lib/flac/include/share/grabbag/seektable.h +++ /dev/null @@ -1,39 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Convenience routines for working with seek tables */ - -/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ - -#ifndef GRABAG__SEEKTABLE_H -#define GRABAG__SEEKTABLE_H - -#include "FLAC/format.h" - -#ifdef __cplusplus -extern "C" { -#endif - -FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, uint32_t sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/flac/include/share/macros.h b/Engine/lib/flac/include/share/macros.h deleted file mode 100644 index 3e7ee554f..000000000 --- a/Engine/lib/flac/include/share/macros.h +++ /dev/null @@ -1,45 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#include - -/* FLAC_CHECK_RETURN : Check the return value of the provided function and - * print an error message if it fails (ie returns a value < 0). - * - * Ideally, a library should not print anything, but this macro is only used - * for things that extremely unlikely to fail, like `chown` to a previoulsy - * saved `uid`. - */ - -#define FLAC_CHECK_RETURN(x) \ - { if ((x) < 0) \ - fprintf (stderr, "%s : %s\n", #x, strerror (errno)) ; \ - } diff --git a/Engine/lib/flac/include/share/private.h b/Engine/lib/flac/include/share/private.h deleted file mode 100644 index 5340d4018..000000000 --- a/Engine/lib/flac/include/share/private.h +++ /dev/null @@ -1,54 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__SHARE__PRIVATE_H -#define FLAC__SHARE__PRIVATE_H - -/* - * Unpublished debug routines from libFLAC. This should not be used from any - * client code other than code shipped with the FLAC sources. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_disable_instruction_set(FLAC__StreamEncoder *encoder, int value); -FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); -FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); -FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value); -/* - * The following two routines were intended as debug routines and are not - * in the public headers, but SHOULD NOT CHANGE! It is known they are used - * in some non-audio projects needing every last bit of performance. - * See https://github.com/xiph/flac/issues/547 for details. These projects - * provide their own prototypes, so changing the signature of these - * functions would break building. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value); -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *encoder); - -#endif /* FLAC__SHARE__PRIVATE_H */ diff --git a/Engine/lib/flac/include/share/replaygain_analysis.h b/Engine/lib/flac/include/share/replaygain_analysis.h deleted file mode 100644 index f06a9b29f..000000000 --- a/Engine/lib/flac/include/share/replaygain_analysis.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ReplayGainAnalysis - analyzes input samples and give the recommended dB change - * Copyright (C) 2001 David Robinson and Glen Sawyer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * concept and filter values by David Robinson (David@Robinson.org) - * -- blame him if you think the idea is flawed - * coding by Glen Sawyer (glensawyer@hotmail.com) 442 N 700 E, Provo, UT 84606 USA - * -- blame him if you think this runs too slowly, or the coding is otherwise flawed - * minor cosmetic tweaks to integrate with FLAC by Josh Coalson - * - * For an explanation of the concepts and the basic algorithms involved, go to: - * http://www.replaygain.org/ - */ - -#ifndef GAIN_ANALYSIS_H -#define GAIN_ANALYSIS_H - -#include - -#define GAIN_NOT_ENOUGH_SAMPLES -24601 -#define GAIN_ANALYSIS_ERROR 0 -#define GAIN_ANALYSIS_OK 1 - -#define INIT_GAIN_ANALYSIS_ERROR 0 -#define INIT_GAIN_ANALYSIS_OK 1 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef float flac_float_t; /* Type used for filtering */ - -extern flac_float_t ReplayGainReferenceLoudness; /* in dB SPL, currently == 89.0 */ - -int InitGainAnalysis ( long samplefreq ); -int ValidGainFrequency ( long samplefreq ); -int AnalyzeSamples ( const flac_float_t* left_samples, const flac_float_t* right_samples, size_t num_samples, int num_channels ); -flac_float_t GetTitleGain ( void ); -flac_float_t GetAlbumGain ( void ); - -#ifdef __cplusplus -} -#endif - -#endif /* GAIN_ANALYSIS_H */ diff --git a/Engine/lib/flac/include/share/replaygain_synthesis.h b/Engine/lib/flac/include/share/replaygain_synthesis.h deleted file mode 100644 index 1701995d4..000000000 --- a/Engine/lib/flac/include/share/replaygain_synthesis.h +++ /dev/null @@ -1,52 +0,0 @@ -/* replaygain_synthesis - Routines for applying ReplayGain to a signal - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H -#define FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H - -#include /* for size_t */ -#include "FLAC/format.h" - -#define FLAC_SHARE__MAX_SUPPORTED_CHANNELS FLAC__MAX_CHANNELS - -typedef enum { - NOISE_SHAPING_NONE = 0, - NOISE_SHAPING_LOW = 1, - NOISE_SHAPING_MEDIUM = 2, - NOISE_SHAPING_HIGH = 3 -} NoiseShaping; - -typedef struct { - const float* FilterCoeff; - FLAC__uint64 Mask; - double Add; - float Dither; - float ErrorHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; /* 16th order Noise shaping */ - float DitherHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; - int LastRandomNumber [FLAC_SHARE__MAX_SUPPORTED_CHANNELS]; - unsigned LastHistoryIndex; - NoiseShaping ShapingType; -} DitherContext; - -void FLAC__replaygain_synthesis__init_dither_context(DitherContext *dither, int bits, int shapingtype); - -/* scale = (float) pow(10., (double)replaygain * 0.05); */ -size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool unsigned_data_out, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, const uint32_t source_bps, const uint32_t target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context); - -#endif diff --git a/Engine/lib/flac/include/share/safe_str.h b/Engine/lib/flac/include/share/safe_str.h deleted file mode 100644 index 85ecbdaf7..000000000 --- a/Engine/lib/flac/include/share/safe_str.h +++ /dev/null @@ -1,71 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -/* Safe string handling functions to replace things like strcpy, strncpy, - * strcat, strncat etc. - * All of these functions guarantee a correctly NUL terminated string but - * the string may be truncated if the destination buffer was too short. - */ - -#ifndef FLAC__SHARE_SAFE_STR_H -#define FLAC__SHARE_SAFE_STR_H - -static inline char * -safe_strncat(char *dest, const char *src, size_t dest_size) -{ - char * ret; - - if (dest_size < 1) - return dest; - - /* Assume dist has space for a term character .. */ - ret = strncat(dest, src, dest_size - strlen (dest)); - /* .. but set it explicitly. */ - dest [dest_size - 1] = 0; - - return ret; -} - -static inline char * -safe_strncpy(char *dest, const char *src, size_t dest_size) -{ - char * ret; - - if (dest_size < 1) - return dest; - - ret = strncpy(dest, src, dest_size - 1); - dest [dest_size - 1] = 0; - - return ret; -} - -#endif /* FLAC__SHARE_SAFE_STR_H */ diff --git a/Engine/lib/flac/include/share/utf8.h b/Engine/lib/flac/include/share/utf8.h deleted file mode 100644 index 7d6650d60..000000000 --- a/Engine/lib/flac/include/share/utf8.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef SHARE__UTF8_H -#define SHARE__UTF8_H - -/* - * Convert a string between UTF-8 and the locale's charset. - * Invalid bytes are replaced by '#', and characters that are - * not available in the target encoding are replaced by '?'. - * - * If the locale's charset is not set explicitly then it is - * obtained using nl_langinfo(CODESET), where available, the - * environment variable CHARSET, or assumed to be US-ASCII. - * - * Return value of conversion functions: - * - * -1 : memory allocation failed - * 0 : data was converted exactly - * 1 : valid data was converted approximately (using '?') - * 2 : input was invalid (but still converted, using '#') - * 3 : unknown encoding (but still converted, using '?') - */ - -int utf8_encode(const char *from, char **to); -int utf8_decode(const char *from, char **to); - -#endif diff --git a/Engine/lib/flac/include/share/win_utf8_io.h b/Engine/lib/flac/include/share/win_utf8_io.h deleted file mode 100644 index ed07386f8..000000000 --- a/Engine/lib/flac/include/share/win_utf8_io.h +++ /dev/null @@ -1,71 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef _WIN32 - -#ifndef flac__win_utf8_io_h -#define flac__win_utf8_io_h - -#include -#include -#include -#include -#include "FLAC/ordinals.h" - -#ifdef __cplusplus -extern "C" { -#endif - -size_t strlen_utf8(const char *str); -int win_get_console_width(void); - -int get_utf8_argv(int *argc, char ***argv); - -int printf_utf8(const char *format, ...); -int fprintf_utf8(FILE *stream, const char *format, ...); -int vfprintf_utf8(FILE *stream, const char *format, va_list argptr); - -FILE* fopen_utf8(const char *filename, const char *mode); -int stat64_utf8(const char *path, struct __stat64 *buffer); -int chmod_utf8(const char *filename, int pmode); -int utime_utf8(const char *filename, struct utimbuf *times); -int unlink_utf8(const char *filename); -int rename_utf8(const char *oldname, const char *newname); - -#include -HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif -#endif diff --git a/Engine/lib/flac/include/test_libs_common/Makefile.am b/Engine/lib/flac/include/test_libs_common/Makefile.am deleted file mode 100644 index af82b4d82..000000000 --- a/Engine/lib/flac/include/test_libs_common/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = \ - file_utils_flac.h \ - metadata_utils.h diff --git a/Engine/lib/flac/include/test_libs_common/file_utils_flac.h b/Engine/lib/flac/include/test_libs_common/file_utils_flac.h deleted file mode 100644 index 5c59c98b4..000000000 --- a/Engine/lib/flac/include/test_libs_common/file_utils_flac.h +++ /dev/null @@ -1,36 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_FILE_UTILS_H -#define FLAC__TEST_LIBFLAC_FILE_UTILS_H - -/* needed because of off_t */ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/format.h" -#include /* for off_t */ -#include "share/compat.h" - -extern const long file_utils__ogg_serial_number; - -FLAC__bool file_utils__generate_flacfile(FLAC__bool is_ogg, const char *output_filename, FLAC__off_t *output_filesize, uint32_t length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, uint32_t num_metadata); - -#endif diff --git a/Engine/lib/flac/include/test_libs_common/metadata_utils.h b/Engine/lib/flac/include/test_libs_common/metadata_utils.h deleted file mode 100644 index 1ed923a6f..000000000 --- a/Engine/lib/flac/include/test_libs_common/metadata_utils.h +++ /dev/null @@ -1,71 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBS_COMMON_METADATA_UTILS_H -#define FLAC__TEST_LIBS_COMMON_METADATA_UTILS_H - -/* - * These are not tests, just utility functions used by the metadata tests - */ - -#include "FLAC/format.h" - -FLAC__bool mutils__compare_block_data_streaminfo(const FLAC__StreamMetadata_StreamInfo *block, const FLAC__StreamMetadata_StreamInfo *blockcopy); - -FLAC__bool mutils__compare_block_data_padding(const FLAC__StreamMetadata_Padding *block, const FLAC__StreamMetadata_Padding *blockcopy, uint32_t block_length); - -FLAC__bool mutils__compare_block_data_application(const FLAC__StreamMetadata_Application *block, const FLAC__StreamMetadata_Application *blockcopy, uint32_t block_length); - -FLAC__bool mutils__compare_block_data_seektable(const FLAC__StreamMetadata_SeekTable *block, const FLAC__StreamMetadata_SeekTable *blockcopy); - -FLAC__bool mutils__compare_block_data_vorbiscomment(const FLAC__StreamMetadata_VorbisComment *block, const FLAC__StreamMetadata_VorbisComment *blockcopy); - -FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueSheet *block, const FLAC__StreamMetadata_CueSheet *blockcopy); - -FLAC__bool mutils__compare_block_data_picture(const FLAC__StreamMetadata_Picture *block, const FLAC__StreamMetadata_Picture *blockcopy); - -FLAC__bool mutils__compare_block_data_unknown(const FLAC__StreamMetadata_Unknown *block, const FLAC__StreamMetadata_Unknown *blockcopy, uint32_t block_length); - -FLAC__bool mutils__compare_block(const FLAC__StreamMetadata *block, const FLAC__StreamMetadata *blockcopy); - -void mutils__init_metadata_blocks( - FLAC__StreamMetadata *streaminfo, - FLAC__StreamMetadata *padding, - FLAC__StreamMetadata *seektable, - FLAC__StreamMetadata *application1, - FLAC__StreamMetadata *application2, - FLAC__StreamMetadata *vorbiscomment, - FLAC__StreamMetadata *cuesheet, - FLAC__StreamMetadata *picture, - FLAC__StreamMetadata *unknown -); - -void mutils__free_metadata_blocks( - FLAC__StreamMetadata *streaminfo, - FLAC__StreamMetadata *padding, - FLAC__StreamMetadata *seektable, - FLAC__StreamMetadata *application1, - FLAC__StreamMetadata *application2, - FLAC__StreamMetadata *vorbiscomment, - FLAC__StreamMetadata *cuesheet, - FLAC__StreamMetadata *picture, - FLAC__StreamMetadata *unknown -); - -#endif diff --git a/Engine/lib/flac/m4/Makefile.am b/Engine/lib/flac/m4/Makefile.am deleted file mode 100644 index 1a25b7a98..000000000 --- a/Engine/lib/flac/m4/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -EXTRA_DIST = \ - add_cflags.m4 \ - add_cxxflags.m4 \ - bswap.m4 \ - endian.m4 \ - gcc_version.m4 \ - ogg.m4 \ - stack_protect.m4 diff --git a/Engine/lib/flac/m4/add_cflags.m4 b/Engine/lib/flac/m4/add_cflags.m4 deleted file mode 100644 index d9b633c72..000000000 --- a/Engine/lib/flac/m4/add_cflags.m4 +++ /dev/null @@ -1,15 +0,0 @@ -dnl @synopsis XIPH_ADD_CFLAGS -dnl -dnl Add the given option to CFLAGS, if it doesn't break the compiler - -AC_DEFUN([XIPH_ADD_CFLAGS], -[AC_MSG_CHECKING([if $CC accepts $1]) - ac_add_cflags__old_cflags="$CFLAGS" - CFLAGS="$1" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[puts("Hello, World!"); return 0;]])],[AC_MSG_RESULT(yes) - CFLAGS="$ac_add_cflags__old_cflags $1"],[AC_MSG_RESULT(no) - CFLAGS="$ac_add_cflags__old_cflags" - ]) -])# XIPH_ADD_CFLAGS diff --git a/Engine/lib/flac/m4/add_cxxflags.m4 b/Engine/lib/flac/m4/add_cxxflags.m4 deleted file mode 100644 index b76e710fc..000000000 --- a/Engine/lib/flac/m4/add_cxxflags.m4 +++ /dev/null @@ -1,16 +0,0 @@ -dnl @synopsis XIPH_ADD_CXXFLAGS -dnl -dnl Add the given option to CXXFLAGS, if it doesn't break the compiler - -AC_DEFUN([XIPH_ADD_CXXFLAGS], -[AC_MSG_CHECKING([if $CXX accepts $1]) - AC_LANG_ASSERT([C++]) - ac_add_cxxflags__old_cxxflags="$CXXFLAGS" - CXXFLAGS="$1" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[puts("Hello, World!"); return 0;]])],[AC_MSG_RESULT(yes) - CXXFLAGS="$ac_add_cxxflags__old_cxxflags $1"],[AC_MSG_RESULT(no) - CXXFLAGS="$ac_add_cxxflags__old_cxxflags" - ]) -])# XIPH_ADD_CXXFLAGS diff --git a/Engine/lib/flac/m4/ax_add_fortify_source.m4 b/Engine/lib/flac/m4/ax_add_fortify_source.m4 deleted file mode 100644 index d443814be..000000000 --- a/Engine/lib/flac/m4/ax_add_fortify_source.m4 +++ /dev/null @@ -1,53 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_add_fortify_source.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_ADD_FORTIFY_SOURCE -# -# DESCRIPTION -# -# Check whether -D_FORTIFY_SOURCE=2 can be added to CPPFLAGS without macro -# redefinition warnings. Some distributions (such as Gentoo Linux) enable -# _FORTIFY_SOURCE globally in their compilers, leading to unnecessary -# warnings in the form of -# -# :0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] -# : note: this is the location of the previous definition -# -# which is a problem if -Werror is enabled. This macro checks whether -# _FORTIFY_SOURCE is already defined, and if not, adds -D_FORTIFY_SOURCE=2 -# to CPPFLAGS. -# -# LICENSE -# -# Copyright (c) 2017 David Seifert -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 1 - -AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[ - AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CPPFLAGS]) - AC_LINK_IFELSE([ - AC_LANG_SOURCE( - [[ - int main() { - #ifndef _FORTIFY_SOURCE - return 0; - #else - this_is_an_error; - #endif - } - ]] - )], [ - AC_MSG_RESULT([yes]) - CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2" - ], [ - AC_MSG_RESULT([no]) - ]) -]) diff --git a/Engine/lib/flac/m4/ax_check_compile_flag.m4 b/Engine/lib/flac/m4/ax_check_compile_flag.m4 deleted file mode 100644 index bd753b34d..000000000 --- a/Engine/lib/flac/m4/ax_check_compile_flag.m4 +++ /dev/null @@ -1,53 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_COMPILE_IFELSE. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 6 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_VAR_IF(CACHEVAR,yes, - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS diff --git a/Engine/lib/flac/m4/ax_check_enable_debug.m4 b/Engine/lib/flac/m4/ax_check_enable_debug.m4 deleted file mode 100644 index f99d75feb..000000000 --- a/Engine/lib/flac/m4/ax_check_enable_debug.m4 +++ /dev/null @@ -1,124 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_enable_debug.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], [ENABLE DEBUG VARIABLES ...], [DISABLE DEBUG VARIABLES NDEBUG ...], [IS-RELEASE]) -# -# DESCRIPTION -# -# Check for the presence of an --enable-debug option to configure, with -# the specified default value used when the option is not present. Return -# the value in the variable $ax_enable_debug. -# -# Specifying 'yes' adds '-g -O0' to the compilation flags for all -# languages. Specifying 'info' adds '-g' to the compilation flags. -# Specifying 'profile' adds '-g -pg' to the compilation flags and '-pg' to -# the linking flags. Otherwise, nothing is added. -# -# Define the variables listed in the second argument if debug is enabled, -# defaulting to no variables. Defines the variables listed in the third -# argument if debug is disabled, defaulting to NDEBUG. All lists of -# variables should be space-separated. -# -# If debug is not enabled, ensure AC_PROG_* will not add debugging flags. -# Should be invoked prior to any AC_PROG_* compiler checks. -# -# IS-RELEASE can be used to change the default to 'no' when making a -# release. Set IS-RELEASE to 'yes' or 'no' as appropriate. By default, it -# uses the value of $ax_is_release, so if you are using the AX_IS_RELEASE -# macro, there is no need to pass this parameter. -# -# AX_IS_RELEASE([git-directory]) -# AX_CHECK_ENABLE_DEBUG() -# -# LICENSE -# -# Copyright (c) 2011 Rhys Ulerich -# Copyright (c) 2014, 2015 Philip Withnall -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. - -#serial 5 - -AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[ - AC_BEFORE([$0],[AC_PROG_CC])dnl - AC_BEFORE([$0],[AC_PROG_CXX])dnl - AC_BEFORE([$0],[AC_PROG_F77])dnl - AC_BEFORE([$0],[AC_PROG_FC])dnl - - AC_MSG_CHECKING(whether to enable debugging) - - ax_enable_debug_default=m4_tolower(m4_normalize(ifelse([$1],,[no],[$1]))) - ax_enable_debug_is_release=m4_tolower(m4_normalize(ifelse([$4],, - [$ax_is_release], - [$4]))) - - # If this is a release, override the default. - AS_IF([test "$ax_enable_debug_is_release" = "yes"], - [ax_enable_debug_default="no"]) - - m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))]) - m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))]) - - AC_ARG_ENABLE(debug, - [AS_HELP_STRING([--enable-debug=]@<:@yes/info/profile/no@:>@,[compile with debugging])], - [],enable_debug=$ax_enable_debug_default) - - # empty mean debug yes - AS_IF([test "x$enable_debug" = "x"], - [enable_debug="yes"]) - - # case of debug - AS_CASE([$enable_debug], - [yes],[ - AC_MSG_RESULT(yes) - CFLAGS="${CFLAGS} -g -O0" - CXXFLAGS="${CXXFLAGS} -g -O0" - FFLAGS="${FFLAGS} -g -O0" - FCFLAGS="${FCFLAGS} -g -O0" - OBJCFLAGS="${OBJCFLAGS} -g -O0" - ], - [info],[ - AC_MSG_RESULT(info) - CFLAGS="${CFLAGS} -g" - CXXFLAGS="${CXXFLAGS} -g" - FFLAGS="${FFLAGS} -g" - FCFLAGS="${FCFLAGS} -g" - OBJCFLAGS="${OBJCFLAGS} -g" - ], - [profile],[ - AC_MSG_RESULT(profile) - CFLAGS="${CFLAGS} -g -pg" - CXXFLAGS="${CXXFLAGS} -g -pg" - FFLAGS="${FFLAGS} -g -pg" - FCFLAGS="${FCFLAGS} -g -pg" - OBJCFLAGS="${OBJCFLAGS} -g -pg" - LDFLAGS="${LDFLAGS} -pg" - ], - [ - AC_MSG_RESULT(no) - dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags - dnl by setting any unset environment flag variables - AS_IF([test "x${CFLAGS+set}" != "xset"], - [CFLAGS=""]) - AS_IF([test "x${CXXFLAGS+set}" != "xset"], - [CXXFLAGS=""]) - AS_IF([test "x${FFLAGS+set}" != "xset"], - [FFLAGS=""]) - AS_IF([test "x${FCFLAGS+set}" != "xset"], - [FCFLAGS=""]) - AS_IF([test "x${OBJCFLAGS+set}" != "xset"], - [OBJCFLAGS=""]) - ]) - - dnl Define various variables if debugging is disabled. - dnl assert.h is a NOP if NDEBUG is defined, so define it by default. - AS_IF([test "x$enable_debug" = "xyes"], - [m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])], - [m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])]) - ax_enable_debug=$enable_debug -]) diff --git a/Engine/lib/flac/m4/bswap.m4 b/Engine/lib/flac/m4/bswap.m4 deleted file mode 100644 index b1abae95d..000000000 --- a/Engine/lib/flac/m4/bswap.m4 +++ /dev/null @@ -1,66 +0,0 @@ -dnl Copyright (C) 2012-2023 Xiph.Org Foundation -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions -dnl are met: -dnl -dnl - Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl -dnl - Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl -dnl - Neither the name of the Xiph.org Foundation nor the names of its -dnl contributors may be used to endorse or promote products derived from -dnl this software without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR -dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -dnl @synopsis XIPH_C_BSWAP32 -dnl -dnl @author Erik de Castro Lopo -dnl -dnl Dtermine whether the compiler has the __builtin_bswap32() intrinsic which -dnl is likely to be present for most versions of GCC as well as Clang. - -AC_DEFUN([XIPH_C_BSWAP32], -[AC_CACHE_CHECK(for bswap32 intrinsic, - ac_cv_c_bswap32, - - AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[return __builtin_bswap32 (0) ;]])],[ac_cv_c_bswap32=yes],[ac_cv_c_bswap32=no]) - if test $ac_cv_c_bswap32 = yes; then - AC_DEFINE_UNQUOTED(HAVE_BSWAP32, [1], [Compiler has the __builtin_bswap32 intrinsic]) - fi - )] -)# XIPH_C_BSWAP32 - - -dnl @synopsis XIPH_C_BSWAP16 -dnl -dnl @author Erik de Castro Lopo -dnl -dnl Dtermine whether the compiler has the __builtin_bswap16() intrinsic which -dnl is likely to be present for most versions of GCC as well as Clang. - -AC_DEFUN([XIPH_C_BSWAP16], -[AC_CACHE_CHECK(for bswap16 intrinsic, - ac_cv_c_bswap16, - - AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[return __builtin_bswap16 (0) ;]])],[ac_cv_c_bswap16=yes],[ac_cv_c_bswap16=no]) - if test $ac_cv_c_bswap16 = yes; then - AC_DEFINE_UNQUOTED(HAVE_BSWAP16, [1], [Compiler has the __builtin_bswap16 intrinsic]) - fi - )] -)# XIPH_C_BSWAP16 diff --git a/Engine/lib/flac/m4/c_attribute.m4 b/Engine/lib/flac/m4/c_attribute.m4 deleted file mode 100644 index 48aa62230..000000000 --- a/Engine/lib/flac/m4/c_attribute.m4 +++ /dev/null @@ -1,18 +0,0 @@ -# -# Check for supported __attribute__ features -# -# AC_C_ATTRIBUTE(FEATURE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -AC_DEFUN([AC_C_ATTRIBUTE], -[AS_VAR_PUSHDEF([CACHEVAR], [ax_cv_c_attribute_$1])dnl -AC_CACHE_CHECK([for __attribute__ (($1))], - CACHEVAR,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], - [[ void foo(void) __attribute__ (($1)); ]])], - [AS_VAR_SET(CACHEVAR, [yes])], - [AS_VAR_SET(CACHEVAR, [no])])]) -AS_VAR_IF(CACHEVAR,yes, - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl diff --git a/Engine/lib/flac/m4/clang.m4 b/Engine/lib/flac/m4/clang.m4 deleted file mode 100644 index 11326a43b..000000000 --- a/Engine/lib/flac/m4/clang.m4 +++ /dev/null @@ -1,28 +0,0 @@ -dnl @synopsis XIPH_C_COMPILER_IS_CLANG -dnl -dnl Find out if a compiler claiming to be gcc really is gcc (clang lies). -dnl @version 1.0 Oct 31 2013 -dnl @author Erik de Castro Lopo -dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright -dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is -dnl provided "as is" without express or implied warranty. -dnl - - -AC_DEFUN([XIPH_C_COMPILER_IS_CLANG], -[AC_CACHE_CHECK(whether we are using the CLANG C compiler, - xiph_cv_c_compiler_clang, - [ AC_LANG_ASSERT(C) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[ - #ifndef __clang__ - This is not clang! - #endif - ]])],[xiph_cv_c_compiler_clang=yes],[xiph_cv_c_compiler_clang=no - ])] - )] -) diff --git a/Engine/lib/flac/m4/codeset.m4 b/Engine/lib/flac/m4/codeset.m4 deleted file mode 100644 index cf53d2416..000000000 --- a/Engine/lib/flac/m4/codeset.m4 +++ /dev/null @@ -1,23 +0,0 @@ -# codeset.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2000-2002, 2006, 2008-2012 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([AM_LANGINFO_CODESET], -[ - AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[char* cs = nl_langinfo(CODESET); return !cs;]])], - [am_cv_langinfo_codeset=yes], - [am_cv_langinfo_codeset=no]) - ]) - if test $am_cv_langinfo_codeset = yes; then - AC_DEFINE([HAVE_LANGINFO_CODESET], [1], - [Define if you have and nl_langinfo(CODESET).]) - fi -]) diff --git a/Engine/lib/flac/m4/endian.m4 b/Engine/lib/flac/m4/endian.m4 deleted file mode 100644 index 28fbf3217..000000000 --- a/Engine/lib/flac/m4/endian.m4 +++ /dev/null @@ -1,169 +0,0 @@ -dnl Copyright (C) 2012-2023 Xiph.Org Foundation -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions -dnl are met: -dnl -dnl - Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl -dnl - Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl -dnl - Neither the name of the Xiph.org Foundation nor the names of its -dnl contributors may be used to endorse or promote products derived from -dnl this software without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR -dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -dnl @synopsis XIPH_C_FIND_ENDIAN -dnl -dnl Determine endian-ness of target processor. -dnl @version 1.1 Mar 03 2002 -dnl @author Erik de Castro Lopo -dnl -dnl Majority written from scratch to replace the standard autoconf macro -dnl AC_C_BIGENDIAN. Only part remaining from the original is the invocation -dnl of the AC_RUN_IFELSE([AC_LANG_SOURCE([[]])],[],[],[]) macro. -dnl -dnl Find endian-ness in the following way: -dnl 1) Look in . -dnl 2) If 1) fails, look in and . -dnl 3) If 1) and 2) fails and not cross compiling run a test program. -dnl 4) If 1) and 2) fails and cross compiling then guess based on target. - -AC_DEFUN([XIPH_C_FIND_ENDIAN], -[AC_CACHE_CHECK(processor byte ordering, - ac_cv_c_byte_order, - -# Initialize to unknown -ac_cv_c_byte_order=unknown - -if test x$ac_cv_header_endian_h = xyes ; then - - # First try which should set BYTE_ORDER. - - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - #if BYTE_ORDER != LITTLE_ENDIAN - not big endian - #endif - ]], [[return 0 ;]])],[ac_cv_c_byte_order=little - ],[])] - - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - #if BYTE_ORDER != BIG_ENDIAN - not big endian - #endif - ]], [[return 0 ;]])],[ac_cv_c_byte_order=big - ],[])] - - fi - -if test $ac_cv_c_byte_order = unknown ; then - - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN - bogus endian macros - #endif - ]], [[return 0 ;]])],[_au_m4_changequote([,])AC_TRY_LINK([ - #include - #include - #if BYTE_ORDER != LITTLE_ENDIAN - not big endian - #endif - ], return 0 ;, - ac_cv_c_byte_order=little - ) - - _au_m4_changequote([,])AC_TRY_LINK([ - #include - #include - #if BYTE_ORDER != LITTLE_ENDIAN - not big endian - #endif - ], return 0 ;, - ac_cv_c_byte_order=little - ) - - ],[])] - - fi - -if test $ac_cv_c_byte_order = unknown ; then - if test $cross_compiling = yes ; then - # This is the last resort. Try to guess the target processor endian-ness - # by looking at the target CPU type. - [ - case "$target_cpu" in - alpha* | i?86* | mipsel* | ia64*) - ac_cv_c_byte_order=little - ;; - - m68* | mips* | powerpc* | hppa* | sparc*) - ac_cv_c_byte_order=big - ;; - - esac - ] - else - AC_RUN_IFELSE([AC_LANG_SOURCE([[[ - int main (void) - { /* Are we little or big endian? From Harbison&Steele. */ - union - { long l ; - char c [sizeof (long)] ; - } u ; - u.l = 1 ; - return (u.c [sizeof (long) - 1] == 1); - } - ]]])],[],[ac_cv_c_byte_order=big],[]) - - AC_RUN_IFELSE([AC_LANG_SOURCE([[[int main (void) - { /* Are we little or big endian? From Harbison&Steele. */ - union - { long l ; - char c [sizeof (long)] ; - } u ; - u.l = 1 ; - return (u.c [0] == 1); - }]]])],[],[ac_cv_c_byte_order=little],[]) - fi - fi - -) - -if test $ac_cv_c_byte_order = big ; then - ac_cv_c_big_endian=1 - ac_cv_c_little_endian=0 -elif test $ac_cv_c_byte_order = little ; then - ac_cv_c_big_endian=0 - ac_cv_c_little_endian=1 -else - ac_cv_c_big_endian=0 - ac_cv_c_little_endian=0 - - AC_MSG_WARN([[*****************************************************************]]) - AC_MSG_WARN([[*** Not able to determine endian-ness of target processor. ]]) - AC_MSG_WARN([[*** The constants CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in ]]) - AC_MSG_WARN([[*** config.h may need to be hand editied. ]]) - AC_MSG_WARN([[*****************************************************************]]) - fi - -] -)# XIPH_C_FIND_ENDIAN diff --git a/Engine/lib/flac/m4/gcc_version.m4 b/Engine/lib/flac/m4/gcc_version.m4 deleted file mode 100644 index e6aaa603f..000000000 --- a/Engine/lib/flac/m4/gcc_version.m4 +++ /dev/null @@ -1,34 +0,0 @@ -dnl @synopsis XIPH_GCC_VERSION -dnl -dnl Find the version of gcc. -dnl @version 1.0 Nov 05 2007 -dnl @version 1.1 Mar 10 2013 -dnl @author Erik de Castro Lopo -dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright -dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is -dnl provided "as is" without express or implied warranty. -dnl - -AC_DEFUN([XIPH_GCC_VERSION], -[ -if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then - - AC_MSG_CHECKING([for version of $CC]) - GCC_VERSION=`$CC -dumpversion` - AC_MSG_RESULT($GCC_VERSION) - - GCC_MAJOR_VERSION=`echo $GCC_VERSION | cut -d. -f 1` - GCC_MINOR_VERSION=`echo $GCC_VERSION | cut -d. -f 2` -else - GCC_MAJOR_VERSION=0 - GCC_MINOR_VERSION=0 - fi - -AC_SUBST(GCC_VERSION) -AC_SUBST(GCC_MAJOR_VERSION) -AC_SUBST(GCC_MINOR_VERSION) - -])# XIPH_GCC_VERSION diff --git a/Engine/lib/flac/m4/iconv.m4 b/Engine/lib/flac/m4/iconv.m4 deleted file mode 100644 index 6a47236c4..000000000 --- a/Engine/lib/flac/m4/iconv.m4 +++ /dev/null @@ -1,268 +0,0 @@ -# iconv.m4 serial 18 (gettext-0.18.2) -dnl Copyright (C) 2000-2002, 2007-2012 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], -[ - dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - - dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV - dnl accordingly. - AC_LIB_LINKFLAGS_BODY([iconv]) -]) - -AC_DEFUN([AM_ICONV_LINK], -[ - dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and - dnl those with the standalone portable GNU libiconv installed). - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - - dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV - dnl accordingly. - AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) - - dnl Add $INCICONV to CPPFLAGS before performing the following checks, - dnl because if the user has installed libiconv and not disabled its use - dnl via --without-libiconv-prefix, he wants to use it. The first - dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. - am_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) - - AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ - am_cv_func_iconv="no, consider installing GNU libiconv" - am_cv_lib_iconv=no - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);]])], - [am_cv_func_iconv=yes]) - if test "$am_cv_func_iconv" != yes; then - am_save_LIBS="$LIBS" - LIBS="$LIBS $LIBICONV" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);]])], - [am_cv_lib_iconv=yes] - [am_cv_func_iconv=yes]) - LIBS="$am_save_LIBS" - fi - ]) - if test "$am_cv_func_iconv" = yes; then - AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ - dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, - dnl Solaris 10. - am_save_LIBS="$LIBS" - if test $am_cv_lib_iconv = yes; then - LIBS="$LIBS $LIBICONV" - fi - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -int main () -{ - int result = 0; - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ - { - iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); - if (cd_utf8_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\342\202\254"; /* EURO SIGN */ - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_utf8_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 1; - iconv_close (cd_utf8_to_88591); - } - } - /* Test against Solaris 10 bug: Failures are not distinguishable from - successful returns. */ - { - iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); - if (cd_ascii_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\263"; - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_ascii_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 2; - iconv_close (cd_ascii_to_88591); - } - } - /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static const char input[] = "\304"; - static char buf[2] = { (char)0xDE, (char)0xAD }; - const char *inptr = input; - size_t inbytesleft = 1; - char *outptr = buf; - size_t outbytesleft = 1; - size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) - result |= 4; - iconv_close (cd_88591_to_utf8); - } - } -#if 0 /* This bug could be worked around by the caller. */ - /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - char buf[50]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if ((int)res > 0) - result |= 8; - iconv_close (cd_88591_to_utf8); - } - } -#endif - /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is - provided. */ - if (/* Try standardized names. */ - iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) - /* Try IRIX, OSF/1 names. */ - && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) - /* Try AIX names. */ - && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) - /* Try HP-UX names. */ - && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) - result |= 16; - return result; -}]])], - [am_cv_func_iconv_works=yes], - [am_cv_func_iconv_works=no], - [ -changequote(,)dnl - case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac -changequote([,])dnl - ]) - LIBS="$am_save_LIBS" - ]) - case "$am_cv_func_iconv_works" in - *no) am_func_iconv=no am_cv_lib_iconv=no ;; - *) am_func_iconv=yes ;; - esac - else - am_func_iconv=no am_cv_lib_iconv=no - fi - if test "$am_func_iconv" = yes; then - AC_DEFINE([HAVE_ICONV], [1], - [Define if you have the iconv() function and it works.]) - fi - if test "$am_cv_lib_iconv" = yes; then - AC_MSG_CHECKING([how to link with libiconv]) - AC_MSG_RESULT([$LIBICONV]) - else - dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV - dnl either. - CPPFLAGS="$am_save_CPPFLAGS" - LIBICONV= - LTLIBICONV= - fi - AC_SUBST([LIBICONV]) - AC_SUBST([LTLIBICONV]) -]) - -dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to -dnl avoid warnings like -dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". -dnl This is tricky because of the way 'aclocal' is implemented: -dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. -dnl Otherwise aclocal's initial scan pass would miss the macro definition. -dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. -dnl Otherwise aclocal would emit many "Use of uninitialized value $1" -dnl warnings. -m4_define([gl_iconv_AC_DEFUN], - m4_version_prereq([2.64], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [m4_ifdef([gl_00GNULIB], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [[AC_DEFUN( - [$1], [$2])]])])) -gl_iconv_AC_DEFUN([AM_ICONV], -[ - AM_ICONV_LINK - if test "$am_cv_func_iconv" = yes; then - AC_MSG_CHECKING([for iconv declaration]) - AC_CACHE_VAL([am_cv_proto_iconv], [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include -extern -#ifdef __cplusplus -"C" -#endif -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) -size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); -#else -size_t iconv(); -#endif - ]], - [[]])], - [am_cv_proto_iconv_arg1=""], - [am_cv_proto_iconv_arg1="const"]) - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) - am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - AC_MSG_RESULT([ - $am_cv_proto_iconv]) - AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], - [Define as const if the declaration of iconv() needs const.]) - dnl Also substitute ICONV_CONST in the gnulib generated . - m4_ifdef([gl_ICONV_H_DEFAULTS], - [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) - if test -n "$am_cv_proto_iconv_arg1"; then - ICONV_CONST="const" - fi - ]) - fi -]) diff --git a/Engine/lib/flac/m4/lib-ld.m4 b/Engine/lib/flac/m4/lib-ld.m4 deleted file mode 100644 index e1feab540..000000000 --- a/Engine/lib/flac/m4/lib-ld.m4 +++ /dev/null @@ -1,119 +0,0 @@ -# lib-ld.m4 serial 6 -dnl Copyright (C) 1996-2003, 2009-2012 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Subroutines of libtool.m4, -dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid -dnl collision with libtool.m4. - -dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. -AC_DEFUN([AC_LIB_PROG_LD_GNU], -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], -[# I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 /dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` - while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL([acl_cv_path_LD], -[if test -z "$LD"; then - acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$acl_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 = 1.10 to complain if config.rpath is missing. - m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) - AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS - AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld - AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host - AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir - AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - ]) - wl="$acl_cv_wl" - acl_libext="$acl_cv_libext" - acl_shlibext="$acl_cv_shlibext" - acl_libname_spec="$acl_cv_libname_spec" - acl_library_names_spec="$acl_cv_library_names_spec" - acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - acl_hardcode_direct="$acl_cv_hardcode_direct" - acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" - dnl Determine whether the user wants rpath handling at all. - AC_ARG_ENABLE([rpath], - [ --disable-rpath do not hardcode runtime library paths], - :, enable_rpath=yes) -]) - -dnl AC_LIB_FROMPACKAGE(name, package) -dnl declares that libname comes from the given package. The configure file -dnl will then not have a --with-libname-prefix option but a -dnl --with-package-prefix option. Several libraries can come from the same -dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar -dnl macro call that searches for libname. -AC_DEFUN([AC_LIB_FROMPACKAGE], -[ - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - define([acl_frompackage_]NAME, [$2]) - popdef([NAME]) - pushdef([PACK],[$2]) - pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - define([acl_libsinpackage_]PACKUP, - m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) - popdef([PACKUP]) - popdef([PACK]) -]) - -dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and -dnl the libraries corresponding to explicit and implicit dependencies. -dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. -dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found -dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. -AC_DEFUN([AC_LIB_LINKFLAGS_BODY], -[ - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) - pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) - dnl Autoconf >= 2.61 supports dots in --with options. - pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_ARG_WITH(P_A_C_K[-prefix], -[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib - --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi - fi - fi -]) - dnl Search the library and its dependencies in $additional_libdir and - dnl $LDFLAGS. Using breadth-first-seach. - LIB[]NAME= - LTLIB[]NAME= - INC[]NAME= - LIB[]NAME[]_PREFIX= - dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been - dnl computed. So it has to be reset here. - HAVE_LIB[]NAME= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='$1 $2' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - dnl See if it was already located by an earlier AC_LIB_LINKFLAGS - dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" - else - dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined - dnl that this library doesn't exist. So just drop it. - : - fi - else - dnl Search the library lib$name in $additional_libdir and $LDFLAGS - dnl and the already constructed $LIBNAME/$LTLIBNAME. - found_dir= - found_la= - found_so= - found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi - if test $use_additional = yes; then - dir="$additional_libdir" - dnl The same code as in the loop below: - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - dnl Found the library. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - dnl Linking with a shared library. We attempt to hardcode its - dnl directory into the executable's runpath, unless it's the - dnl standard /usr/lib. - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - dnl No hardcoding is needed. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - dnl The hardcoding into $LIBNAME is system dependent. - if test "$acl_hardcode_direct" = yes; then - dnl Using DIR/libNAME.so during linking hardcodes DIR into the - dnl resulting binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - dnl Rely on "-L$found_dir". - dnl But don't add it if it's already contained in the LDFLAGS - dnl or the already constructed $LIBNAME - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" - fi - if test "$acl_hardcode_minus_L" != no; then - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH - dnl here, because this doesn't fit in flags passed to the - dnl compiler. So give up. No hardcoding. This affects only - dnl very old systems. - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - dnl Linking with a static library. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" - else - dnl We shouldn't come here, but anyway it's good to have a - dnl fallback. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" - fi - fi - dnl Assume the include files are nearby. - additional_includedir= - case "$found_dir" in - */$acl_libdirstem | */$acl_libdirstem/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - dnl Potentially add $additional_includedir to $INCNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's /usr/local/include and we are using GCC on Linux, - dnl 3. if it's already present in $CPPFLAGS or the already - dnl constructed $INCNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INC[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $INCNAME. - INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - dnl Look for dependencies. - if test -n "$found_la"; then - dnl Read the .la file. It defines the variables - dnl dlname, library_names, old_library, dependency_libs, current, - dnl age, revision, installed, dlopen, dlpreopen, libdir. - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - dnl We use only dependency_libs. - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's /usr/local/lib and we are using GCC on Linux, - dnl 3. if it's already present in $LDFLAGS or the already - dnl constructed $LIBNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LIBNAME. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LTLIBNAME. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - dnl Handle this in the next round. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - dnl Handle this in the next round. Throw away the .la's - dnl directory; it is already contained in a preceding -L - dnl option. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - dnl Most likely an immediate library name. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" - ;; - esac - done - fi - else - dnl Didn't find the library; assume it is in the system directories - dnl known to the linker and runtime loader. (All the system - dnl directories known to the linker should also be known to the - dnl runtime loader, otherwise the system is severely misconfigured.) - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user must - dnl pass all path elements in one option. We can arrange that for a - dnl single library, but not when more than one $LIBNAMEs are used. - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" - done - dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - else - dnl The -rpath options are cumulative. - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - dnl When using libtool, the option that works for both libraries and - dnl executables is -R. The -R options are cumulative. - for found_dir in $ltrpathdirs; do - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" - done - fi - popdef([P_A_C_K]) - popdef([PACKLIBS]) - popdef([PACKUP]) - popdef([PACK]) - popdef([NAME]) -]) - -dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, -dnl unless already present in VAR. -dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes -dnl contains two or three consecutive elements that belong together. -AC_DEFUN([AC_LIB_APPENDTOVAR], -[ - for element in [$2]; do - haveit= - for x in $[$1]; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - [$1]="${[$1]}${[$1]:+ }$element" - fi - done -]) - -dnl For those cases where a variable contains several -L and -l options -dnl referring to unknown libraries and directories, this macro determines the -dnl necessary additional linker options for the runtime path. -dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) -dnl sets LDADDVAR to linker options needed together with LIBSVALUE. -dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, -dnl otherwise linking without libtool is assumed. -AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], -[ - AC_REQUIRE([AC_LIB_RPATH]) - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - $1= - if test "$enable_rpath" != no; then - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode directories into the resulting - dnl binary. - rpathdirs= - next= - for opt in $2; do - if test -n "$next"; then - dir="$next" - dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then - rpathdirs="$rpathdirs $dir" - fi - next= - else - case $opt in - -L) next=yes ;; - -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` - dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then - rpathdirs="$rpathdirs $dir" - fi - next= ;; - *) next= ;; - esac - fi - done - if test "X$rpathdirs" != "X"; then - if test -n ""$3""; then - dnl libtool is used for linking. Use -R options. - for dir in $rpathdirs; do - $1="${$1}${$1:+ }-R$dir" - done - else - dnl The linker is used for linking directly. - if test -n "$acl_hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user - dnl must pass all path elements in one option. - alldirs= - for dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" - done - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - $1="$flag" - else - dnl The -rpath options are cumulative. - for dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - $1="${$1}${$1:+ }$flag" - done - fi - fi - fi - fi - fi - AC_SUBST([$1]) -]) diff --git a/Engine/lib/flac/m4/lib-prefix.m4 b/Engine/lib/flac/m4/lib-prefix.m4 deleted file mode 100644 index 51687d364..000000000 --- a/Engine/lib/flac/m4/lib-prefix.m4 +++ /dev/null @@ -1,224 +0,0 @@ -# lib-prefix.m4 serial 7 (gettext-0.18) -dnl Copyright (C) 2001-2005, 2008-2012 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and -dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't -dnl require excessive bracketing. -ifdef([AS_HELP_STRING], -[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], -[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) - -dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed -dnl to access previously installed libraries. The basic assumption is that -dnl a user will want packages to use other packages he previously installed -dnl with the same --prefix option. -dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate -dnl libraries, but is otherwise very convenient. -AC_DEFUN([AC_LIB_PREFIX], -[ - AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_LIB_ARG_WITH([lib-prefix], -[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib - --without-lib-prefix don't search for libraries in includedir and libdir], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - fi - fi -]) - if test $use_additional = yes; then - dnl Potentially add $additional_includedir to $CPPFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's already present in $CPPFLAGS, - dnl 3. if it's /usr/local/include and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - for x in $CPPFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $CPPFLAGS. - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" - fi - fi - fi - fi - dnl Potentially add $additional_libdir to $LDFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's already present in $LDFLAGS, - dnl 3. if it's /usr/local/lib and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then - haveit= - for x in $LDFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then - if test -n "$GCC"; then - case $host_os in - linux*) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LDFLAGS. - LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" - fi - fi - fi - fi - fi -]) - -dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, -dnl acl_final_exec_prefix, containing the values to which $prefix and -dnl $exec_prefix will expand at the end of the configure script. -AC_DEFUN([AC_LIB_PREPARE_PREFIX], -[ - dnl Unfortunately, prefix and exec_prefix get only finally determined - dnl at the end of configure. - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the -dnl variables prefix and exec_prefix bound to the values they will have -dnl at the end of the configure script. -AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], -[ - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - $1 - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_PREPARE_MULTILIB creates -dnl - a variable acl_libdirstem, containing the basename of the libdir, either -dnl "lib" or "lib64" or "lib/64", -dnl - a variable acl_libdirstem2, as a secondary possible value for -dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or -dnl "lib/amd64". -AC_DEFUN([AC_LIB_PREPARE_MULTILIB], -[ - dnl There is no formal standard regarding lib and lib64. - dnl On glibc systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine - dnl the compiler's default mode by looking at the compiler's library search - dnl path. If at least one of its elements ends in /lib64 or points to a - dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. - dnl Otherwise we use the default, namely "lib". - dnl On Solaris systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or - dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. - AC_REQUIRE([AC_CANONICAL_HOST]) - acl_libdirstem=lib - acl_libdirstem2= - case "$host_os" in - solaris*) - dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment - dnl . - dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." - dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the - dnl symlink is missing, so we set acl_libdirstem2 too. - AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], - [AC_EGREP_CPP([sixtyfour bits], [ -#ifdef _LP64 -sixtyfour bits -#endif - ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) - ]) - if test $gl_cv_solaris_64bit = yes; then - acl_libdirstem=lib/64 - case "$host_cpu" in - sparc*) acl_libdirstem2=lib/sparcv9 ;; - i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; - esac - fi - ;; - *) - searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac - fi - done - IFS="$acl_save_IFS" - fi - ;; - esac - test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" -]) diff --git a/Engine/lib/flac/m4/ogg.m4 b/Engine/lib/flac/m4/ogg.m4 deleted file mode 100644 index 3b1a28a6e..000000000 --- a/Engine/lib/flac/m4/ogg.m4 +++ /dev/null @@ -1,114 +0,0 @@ -# Configure paths for libogg -# Jack Moffitt 10-21-2000 -# Shamelessly stolen from Owen Taylor and Manish Singh - -dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS -dnl -AC_DEFUN([XIPH_PATH_OGG], -[dnl -dnl Get the cflags and libraries -dnl -AC_ARG_WITH(ogg,AS_HELP_STRING([--with-ogg=PFX],[Prefix where libogg is installed (optional)]), ogg_prefix="$withval", ogg_prefix="") -AC_ARG_WITH(ogg-libraries,AS_HELP_STRING([--with-ogg-libraries=DIR],[Directory where libogg library is installed (optional)]), ogg_libraries="$withval", ogg_libraries="") -AC_ARG_WITH(ogg-includes,AS_HELP_STRING([--with-ogg-includes=DIR],[Directory where libogg header files are installed (optional)]), ogg_includes="$withval", ogg_includes="") -AC_ARG_ENABLE(oggtest,AS_HELP_STRING([--disable-oggtest],[Do not try to compile and run a test Ogg program]),, enable_oggtest=yes) - - if test "x$ogg_libraries" != "x" ; then - OGG_LIBS="-L$ogg_libraries" - elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then - OGG_LIBS="" - elif test "x$ogg_prefix" != "x" ; then - OGG_LIBS="-L$ogg_prefix/lib" - elif test "x$prefix" != "xNONE" ; then - OGG_LIBS="-L$prefix/lib" - fi - - if test "x$ogg_prefix" != "xno" ; then - OGG_LIBS="$OGG_LIBS -logg" - fi - - if test "x$ogg_includes" != "x" ; then - OGG_CFLAGS="-I$ogg_includes" - elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then - OGG_CFLAGS="" - elif test "x$ogg_prefix" != "x" ; then - OGG_CFLAGS="-I$ogg_prefix/include" - elif test "x$prefix" != "xNONE"; then - OGG_CFLAGS="-I$prefix/include" - fi - - AC_MSG_CHECKING(for Ogg) - if test "x$ogg_prefix" = "xno" ; then - no_ogg="disabled" - enable_oggtest="no" - else - no_ogg="" - fi - - - if test "x$enable_oggtest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $OGG_CFLAGS" - LIBS="$LIBS $OGG_LIBS" -dnl -dnl Now check if the installed Ogg is sufficiently new. -dnl - rm -f conf.oggtest - AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include -#include - -int main () -{ - system("touch conf.oggtest"); - return 0; -} - -]])],[],[no_ogg=yes],[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - - if test "x$no_ogg" = "xdisabled" ; then - AC_MSG_RESULT(no) - ifelse([$2], , :, [$2]) - elif test "x$no_ogg" = "x" ; then - AC_MSG_RESULT(yes) - ifelse([$1], , :, [$1]) - else - AC_MSG_RESULT(no) - if test -f conf.oggtest ; then - : - else - echo "*** Could not run Ogg test program, checking why..." - CFLAGS="$CFLAGS $OGG_CFLAGS" - LIBS="$LIBS $OGG_LIBS" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -]], [[ return 0; ]])],[ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding Ogg or finding the wrong" - echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],[ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occurred. This usually means Ogg was incorrectly installed" - echo "*** or that you have moved Ogg since it was installed." ]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - OGG_CFLAGS="" - OGG_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(OGG_CFLAGS) - AC_SUBST(OGG_LIBS) - rm -f conf.oggtest -]) diff --git a/Engine/lib/flac/m4/really_gcc.m4 b/Engine/lib/flac/m4/really_gcc.m4 deleted file mode 100644 index 8bc94d5eb..000000000 --- a/Engine/lib/flac/m4/really_gcc.m4 +++ /dev/null @@ -1,29 +0,0 @@ -dnl @synopsis XIPH_GCC_REALLY_IS_GCC -dnl -dnl Find out if a compiler claiming to be gcc really is gcc (clang lies). -dnl @version 1.0 Oct 31 2013 -dnl @author Erik de Castro Lopo -dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright -dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is -dnl provided "as is" without express or implied warranty. -dnl - -# If the configure script has already detected GNU GCC, then make sure it -# isn't CLANG masquerading as GCC. - -AC_DEFUN([XIPH_GCC_REALLY_IS_GCC], -[ AC_LANG_ASSERT(C) - if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[ - #ifdef __clang__ - This is clang! - #endif - ]])],[ac_cv_c_compiler_gnu=yes],[ac_cv_c_compiler_gnu=no - ]) - fi -]) diff --git a/Engine/lib/flac/m4/stack_protect.m4 b/Engine/lib/flac/m4/stack_protect.m4 deleted file mode 100644 index cf8af6648..000000000 --- a/Engine/lib/flac/m4/stack_protect.m4 +++ /dev/null @@ -1,67 +0,0 @@ -dnl Copyright (C) 2013-2023 Xiph.Org Foundation -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions -dnl are met: -dnl -dnl - Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl -dnl - Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl -dnl - Neither the name of the Xiph.org Foundation nor the names of its -dnl contributors may be used to endorse or promote products derived from -dnl this software without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR -dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -dnl We want to know if GCC stack protector works, for the C and for the C++ -dnl compiler. -dnl -dnl Just checking if the compiler accepts the required CFLAGSs is not enough -dnl because we have seen at least one instance where this check was -dnl in-sufficient. -dnl -dnl Instead, try to compile and link a test program with the stack protector -dnl flags. If that works, we use it. - -AC_DEFUN([XIPH_GCC_STACK_PROTECTOR], -[AC_LANG_ASSERT(C) - AC_MSG_CHECKING([if $CC supports stack smash protection]) - xiph_stack_check_old_cflags="$CFLAGS" - SSP_FLAGS="-fstack-protector-strong" - CFLAGS=$SSP_FLAGS - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[puts("Hello, World!"); return 0;]])],[AC_MSG_RESULT(yes) - CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS"],[AC_MSG_RESULT(no) - CFLAGS="$xiph_stack_check_old_cflags" - ]) -])# XIPH_GCC_STACK_PROTECTOR - -AC_DEFUN([XIPH_GXX_STACK_PROTECTOR], -[AC_LANG_PUSH([C++]) - AC_MSG_CHECKING([if $CXX supports stack smash protection]) - xiph_stack_check_old_cxxflags="$CXXFLAGS" - SSP_FLAGS="-fstack-protector-strong" - CXXFLAGS=$SSP_FLAGS - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[puts("Hello, World!"); return 0;]])],[AC_MSG_RESULT(yes) - CXXFLAGS="$xiph_stack_check_old_cxxflags $SSP_FLAGS"],[AC_MSG_RESULT(no) - CXXFLAGS="$xiph_stack_check_old_cxxflags" - ]) - AC_LANG_POP([C++]) -])# XIPH_GXX_STACK_PROTECTOR diff --git a/Engine/lib/flac/man/Makefile.am b/Engine/lib/flac/man/Makefile.am deleted file mode 100644 index 50bacae92..000000000 --- a/Engine/lib/flac/man/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -# flac - Command-line FLAC encoder/decoder -# Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -if FLaC__HAS_PANDOC -flac.1: flac.md - pandoc --standalone --to man $? > $@ - -metaflac.1: metaflac.md - pandoc --standalone --to man $? > $@ - -man_MANS = flac.1 metaflac.1 - -else -if FLaC__HAS_PREBUILT_MANPAGES -man_MANS = flac.1 metaflac.1 -endif -endif - -EXTRA_DIST = flac.1 metaflac.1 flac.md metaflac.md diff --git a/Engine/lib/flac/man/flac.md b/Engine/lib/flac/man/flac.md deleted file mode 100644 index b51ac698a..000000000 --- a/Engine/lib/flac/man/flac.md +++ /dev/null @@ -1,760 +0,0 @@ -% flac(1) Version 1.4.3 | Free Lossless Audio Codec conversion tool - -# NAME - -flac - Free Lossless Audio Codec - -# SYNOPSIS - -**flac** \[ *OPTIONS* \] \[ *infile.wav* \| *infile.rf64* \| -*infile.aiff* \| *infile.raw* \| *infile.flac* \| *infile.oga* \| -*infile.ogg* \| **-** *...* \] - -**flac** \[ **-d** \| **\--decode** \| **-t** \| **\--test** \| **-a** \| -**\--analyze** \] \[ *OPTIONS* \] \[ *infile.flac* \| *infile.oga* \| -*infile.ogg* \| **-** *...* \] - -# DESCRIPTION - -**flac** is a command-line tool for encoding, decoding, testing and -analyzing FLAC streams. - -# GENERAL USAGE - -**flac** supports as input RIFF WAVE, Wave64, RF64, AIFF, FLAC or Ogg -FLAC format, or raw interleaved samples. The decoder currently can output -to RIFF WAVE, Wave64, RF64, or AIFF format, or raw interleaved samples. -flac only supports linear PCM samples (in other words, no A-LAW, uLAW, -etc.), and the input must be between 4 and 32 bits per sample. - -flac assumes that files ending in ".wav" or that have the RIFF WAVE -header present are WAVE files, files ending in ".w64" or have the Wave64 -header present are Wave64 files, files ending in ".rf64" or have the -RF64 header present are RF64 files, files ending in ".aif" or ".aiff" or -have the AIFF header present are AIFF files, files ending in ".flac" -or have the FLAC header present are FLAC files and files ending in ".oga" -or ".ogg" or have the Ogg FLAC header present are Ogg FLAC files. - -Other than this, flac makes no assumptions about file extensions, though -the convention is that FLAC files have the extension ".flac" -(or ".fla" on ancient "8.3" file systems like FAT-16). - -Before going into the full command-line description, a few other things -help to sort it out: -1. flac encodes by default, so you must use -d to decode -2. the options -0 .. -8 (or --fast and --best) that control the - compression level actually are just synonyms for different groups of - specific encoding options (described later) and you can get the same - effect by using the same options. When specific options are specified - they take priority over the compression level no matter the order -3. flac behaves similarly to gzip in the way it handles input and output - files -4. the order in which options are specified is generally not important - -Skip to the examples below for examples of some common tasks. - -flac will be invoked one of four ways, depending on whether you are -encoding, decoding, testing, or analyzing. Encoding is the default -invocation, but can be switch to decoding with **-d**, analysis with -**-a** or testing with **-t**. Depending on which way is chosen, -encoding, decoding, analysis or testing options can be used, see section -OPTIONS for details. General options can be used for all. - -If only one inputfile is specified, it may be "-" for stdin. When stdin -is used as input, flac will write to stdout. Otherwise flac will perform -the desired operation on each input file to similarly named output files -(meaning for encoding, the extension will be replaced with ".flac", or -appended with ".flac" if the input file has no extension, and for -decoding, the extension will be ".wav" for WAVE output and ".raw" for raw -output). The original file is not deleted unless --delete-input-file is -specified. - -If you are encoding/decoding from stdin to a file, you should use the -o -option like so: - - flac [options] -o outputfile - flac -d [options] -o outputfile - -which are better than: - - flac [options] > outputfile - flac -d [options] > outputfile - -since the former allows flac to seek backwards to write the STREAMINFO or -RIFF WAVE header contents when necessary. - -Also, you can force output data to go to stdout using -c. - -To encode or decode files that start with a dash, use -- to signal the -end of options, to keep the filenames themselves from being treated as -options: - - flac -V -- -01-filename.wav - -The encoding options affect the compression ratio and encoding speed. The -format options are used to tell flac the arrangement of samples if the -input file (or output file when decoding) is a raw file. If it is a RIFF -WAVE, Wave64, RF64, or AIFF file the format options are not needed since -they are read from the file's header. - -In test mode, flac acts just like in decode mode, except no output file -is written. Both decode and test modes detect errors in the stream, but -they also detect when the MD5 signature of the decoded audio does not -match the stored MD5 signature, even when the bitstream is valid. - -flac can also re-encode FLAC files. In other words, you can specify a -FLAC or Ogg FLAC file as an input to the encoder and it will decoder it -and re-encode it according to the options you specify. It will also -preserve all the metadata unless you override it with other options (e.g. -specifying new tags, seekpoints, cuesheet, padding, etc.). - -flac has been tuned so that the default settings yield a good speed vs. -compression tradeoff for many kinds of input. However, if you are looking -to maximize the compression rate or speed, or want to use the full power -of FLAC's metadata system, see the page titled 'About the FLAC Format' on -the FLAC website. - -# EXAMPLES - -Some common **encoding** tasks using flac: - -`flac abc.wav` -: Encode abc.wav to abc.flac using the default compression setting. abc.wav is not deleted. - -`flac --delete-input-file abc.wav` -: Like above, except abc.wav is deleted if there were no errors. - -`flac --delete-input-file -w abc.wav` -: Like above, except abc.wav is deleted if there were no errors or warnings. - -`flac --best abc.wav` -: Encode abc.wav to abc.flac using the highest compression setting. - -`flac --verify abc.wav` -: Encode abc.wav to abc.flac and internally decode abc.flac to make sure it matches abc.wav. - -`flac -o my.flac abc.wav` -: Encode abc.wav to my.flac. - -`flac -T "TITLE=Bohemian Rhapsody" -T "ARTIST=Queen" abc.wav` -: Encode abc.wav and add some tags at the same time to abc.flac. - -`flac *.wav` -: Encode all .wav files in the current directory. - -`flac abc.aiff` -: Encode abc.aiff to abc.flac. - -`flac abc.rf64` -: Encode abc.rf64 to abc.flac. - -`flac abc.w64` -: Encode abc.w64 to abc.flac. - -`flac abc.flac --force` -: This one's a little tricky: notice that flac is in encode mode by - default (you have to specify -d to decode) so this command actually - recompresses abc.flac back to abc.flac. --force is needed to make - sure you really want to overwrite abc.flac with a new version. Why - would you want to do this? It allows you to recompress an existing - FLAC file with (usually) higher compression options or a newer - version of FLAC and preserve all the metadata like tags too. - -Some common **decoding** tasks using flac: - -`flac -d abc.flac` -: Decode abc.flac to abc.wav. abc.flac is not deleted. NOTE: Without - -d it means re-encode abc.flac to abc.flac (see above). - -`flac -d --force-aiff-format abc.flac` -`flac -d -o abc.aiff abc.flac` -: Two different ways of decoding abc.flac to abc.aiff (AIFF format). - abc.flac is not deleted. - -`flac -d --force-rf64-format abc.flac` -`flac -d -o abc.rf64 abc.flac` -: Two different ways of decoding abc.flac to abc.rf64 (RF64 format). - abc.flac is not deleted. - -`flac -d --force-wave64-format abc.flac` -`flac -d -o abc.w64 abc.flac` -: Two different ways of decoding abc.flac to abc.w64 (Wave64 format). - abc.flac is not deleted. - -`flac -d -F abc.flac` -: Decode abc.flac to abc.wav and don't abort if errors are found - (useful for recovering as much as possible from corrupted files). - - -# OPTIONS - -A summary of options is included below. For a complete description, see -the HTML documentation. - -## GENERAL OPTIONS - -**-v, \--version** -: Show the flac version number - -**-h, \--help** -: Show basic usage and a list of all options - -**-H, \--explain** -: Show detailed explanation of usage and all options - -**-d, \--decode** -: Decode (the default behavior is to encode) - -**-t, \--test** -: Test a flac encoded file (same as -d except no decoded file is written) - -**-a, \--analyze** -: Analyze a FLAC encoded file (same as -d except an analysis file is - written) - -**-c, \--stdout** -: Write output to stdout - -**-s, \--silent** -: Silent mode (do not write runtime encode/decode statistics to stderr) - -**\--totally-silent** -: Do not print anything of any kind, including warnings or errors. The - exit code will be the only way to determine successful completion. - -**\--no-utf8-convert** -: Do not convert tags from local charset to UTF-8. This is useful for - scripts, and setting tags in situations where the locale is wrong. - This option must appear before any tag options! - -**-w, \--warnings-as-errors** -: Treat all warnings as errors (which cause flac to terminate with a - non-zero exit code). - -**-f, \--force** -: Force overwriting of output files. By default, flac warns that the - output file already exists and continues to the next file. - -**-o** *filename***, \--output-name=***filename* -: Force the output file name (usually flac just changes the extension). - May only be used when encoding a single file. May not be used in - conjunction with \--output-prefix. - -**\--output-prefix=***string* -: Prefix each output file name with the given string. This can be - useful for encoding or decoding files to a different directory. Make - sure if your string is a path name that it ends with a trailing \`/' - (slash). - -**\--delete-input-file** -: Automatically delete the input file after a successful encode or - decode. If there was an error (including a verify error) the input - file is left intact. - -**\--preserve-modtime** -: Output files have their timestamps/permissions set to match those of - their inputs (this is default). Use \--no-preserve-modtime to make - output files have the current time and default permissions. - -**\--keep-foreign-metadata** -: If encoding, save WAVE, RF64, or AIFF non-audio chunks in FLAC - metadata. If decoding, restore any saved non-audio chunks from FLAC - metadata when writing the decoded file. Foreign metadata cannot be - transcoded, e.g. WAVE chunks saved in a FLAC file cannot be restored - when decoding to AIFF. Input and output must be regular files (not - stdin or stdout). With this option, FLAC will pick the right output - format on decoding. - -**\--keep-foreign-metadata-if-present** -: Like \--keep-foreign-metadata, but without throwing an error if - foreign metadata cannot be found or restored, instead printing a - warning. - -**\--skip={***\#***\|***mm:ss.ss***}** -: Skip over the first number of samples of the input. This works for - both encoding and decoding, but not testing. The alternative form - mm:ss.ss can be used to specify minutes, seconds, and fractions of a - second. - -**\--until={***\#***\|\[***+***\|***-***\]***mm:ss.ss***}** -: Stop at the given sample number for each input file. This works for - both encoding and decoding, but not testing. The given sample number - is not included in the decoded output. The alternative form mm:ss.ss - can be used to specify minutes, seconds, and fractions of a second. - If a \`+' (plus) sign is at the beginning, the \--until point is - relative to the \--skip point. If a \`-' (minus) sign is at the - beginning, the \--until point is relative to end of the audio. - -**\--ogg** -: When encoding, generate Ogg FLAC output instead of native FLAC. Ogg - FLAC streams are FLAC streams wrapped in an Ogg transport layer. The - resulting file should have an '.oga' extension and will still be - decodable by flac. When decoding, force the input to be treated as - Ogg FLAC. This is useful when piping input from stdin or when the - filename does not end in '.oga' or '.ogg'. - -**\--serial-number=***\#* -: When used with \--ogg, specifies the serial number to use for the - first Ogg FLAC stream, which is then incremented for each additional - stream. When encoding and no serial number is given, flac uses a - random number for the first stream, then increments it for each - additional stream. When decoding and no number is given, flac uses - the serial number of the first page. - -## ANALYSIS OPTIONS - -**\--residual-text** -: Includes the residual signal in the analysis file. This will make the - file very big, much larger than even the decoded file. - -**\--residual-gnuplot** -: Generates a gnuplot file for every subframe; each file will contain - the residual distribution of the subframe. This will create a lot of - files. - -## DECODING OPTIONS - -**\--cue=\[***\#.#***\]\[-\[***\#.#***\]\]** -: Set the beginning and ending cuepoints to decode. The optional first - \#.# is the track and index point at which decoding will start; the - default is the beginning of the stream. The optional second \#.# is - the track and index point at which decoding will end; the default is - the end of the stream. If the cuepoint does not exist, the closest - one before it (for the start point) or after it (for the end point) - will be used. If those don't exist, the start of the stream (for the - start point) or end of the stream (for the end point) will be used. - The cuepoints are merely translated into sample numbers then used as - \--skip and \--until. A CD track can always be cued by, for example, - \--cue=9.1-10.1 for track 9, even if the CD has no 10th track. - -**-F, \--decode-through-errors** -: By default flac stops decoding with an error and removes the - partially decoded file if it encounters a bitstream error. With -F, - errors are still printed but flac will continue decoding to - completion. Note that errors may cause the decoded audio to be - missing some samples or have silent sections. - -**\--apply-replaygain-which-is-not-lossless\[=\\]** -: Applies ReplayGain values while decoding. **WARNING: THIS IS NOT - LOSSLESS. DECODED AUDIO WILL NOT BE IDENTICAL TO THE ORIGINAL WITH - THIS OPTION.** This option is useful for example in transcoding - media servers, where the client does not support ReplayGain. For - details on the use of this option, see the section **ReplayGain - application specification**. - -## ENCODING OPTIONS - -**-V, \--verify** -: Verify a correct encoding by decoding the output in parallel and - comparing to the original - -**\--lax** -: Allow encoder to generate non-Subset files. The resulting FLAC file - may not be streamable or might have trouble being played in all - players (especially hardware devices), so you should only use this - option in combination with custom encoding options meant for - archival. - -**\--replay-gain** -: Calculate ReplayGain values and store them as FLAC tags, similar to - vorbisgain. Title gains/peaks will be computed for each input file, - and an album gain/peak will be computed for all files. All input - files must have the same resolution, sample rate, and number of - channels. Only mono and stereo files are allowed, and the sample - rate must be 8, 11.025, 12, 16, 18.9, 22.05, 24, 28, 32, 36, 37.8, - 44.1, 48, 56, 64, 72, 75.6, 88.2, 96, 112, 128, 144, 151.2, 176.4, - 192, 224, 256, 288, 302.4, 352.8, 384, 448, 512, 576, or 604.8 kHz. - Also note that this option may leave a few extra bytes in a PADDING - block as the exact size of the tags is not known until all files - are processed. Note that this option cannot be used when encoding - to standard output (stdout). - -**\--cuesheet=***filename* -: Import the given cuesheet file and store it in a CUESHEET metadata - block. This option may only be used when encoding a single file. A - seekpoint will be added for each index point in the cuesheet to the - SEEKTABLE unless \--no-cued-seekpoints is specified. - -**\--picture={***FILENAME***\|***SPECIFICATION***}** -: Import a picture and store it in a PICTURE metadata block. More than - one \--picture option can be specified. Either a filename for the - picture file or a more complete specification form can be used. The - SPECIFICATION is a string whose parts are separated by \| (pipe) - characters. Some parts may be left empty to invoke default values. - FILENAME is just shorthand for "\|\|\|\|FILENAME". For the format of - SPECIFICATION, see the section **picture specification**. - -**\--ignore-chunk-sizes** -: When encoding to flac, ignore the file size headers in WAV and AIFF - files to attempt to work around problems with over-sized or malformed - files. WAV and AIFF files both have an unsigned 32 bit numbers in - the file header which specifes the length of audio data. Since this - number is unsigned 32 bits, that limits the size of a valid file to - being just over 4 Gigabytes. Files larger than this are mal-formed, - but should be read correctly using this option. - -**-S {***\#***\|***X***\|***\#x***\|***\#s***}, \--seekpoint={***\#***\|***X***\|***\#x***\|***\#s***}** -: Include a point or points in a SEEKTABLE. Using \#, a seek point at - that sample number is added. Using X, a placeholder point is added at - the end of a the table. Using \#x, \# evenly spaced seek points will - be added, the first being at sample 0. Using \#s, a seekpoint will be - added every \# seconds (# does not have to be a whole number; it can - be, for example, 9.5, meaning a seekpoint every 9.5 seconds). You may - use many -S options; the resulting SEEKTABLE will be the unique-ified - union of all such values. With no -S options, flac defaults to - '-S 10s'. Use \--no-seektable for no SEEKTABLE. Note: '-S \#x' and - '-S \#s' will not work if the encoder can't determine the input size - before starting. Note: if you use '-S \#' and \# is \>= samples in - the input, there will be either no seek point entered (if the input - size is determinable before encoding starts) or a placeholder point - (if input size is not determinable). - -**-P** *\#***, \--padding=***\#* -: Tell the encoder to write a PADDING metadata block of the given - length (in bytes) after the STREAMINFO block. This is useful if you - plan to tag the file later with an APPLICATION block; instead of - having to rewrite the entire file later just to insert your block, - you can write directly over the PADDING block. Note that the total - length of the PADDING block will be 4 bytes longer than the length - given because of the 4 metadata block header bytes. You can force no - PADDING block at all to be written with \--no-padding. The encoder - writes a PADDING block of 8192 bytes by default (or 65536 bytes if - the input audio stream is more that 20 minutes long). - -**-T** *FIELD=VALUE***, \--tag=***FIELD=VALUE* -: Add a FLAC tag. The comment must adhere to the Vorbis comment spec; - i.e. the FIELD must contain only legal characters, terminated by an - 'equals' sign. Make sure to quote the comment if necessary. This - option may appear more than once to add several comments. NOTE: all - tags will be added to all encoded files. - -**\--tag-from-file=***FIELD=FILENAME* -: Like \--tag, except FILENAME is a file whose contents will be read - verbatim to set the tag value. The contents will be converted to - UTF-8 from the local charset. This can be used to store a cuesheet - in a tag (e.g. \--tag-from-file="CUESHEET=image.cue"). Do not try to - store binary data in tag fields! Use APPLICATION blocks for that. - -**-b** *\#***, \--blocksize=***\#* -: Specify the blocksize in samples. The default is 1152 for -l 0, - else 4096. For subset streams this must be \<= 4608 if the samplerate - \<= 48kHz, for subset streams with higher samplerates it must be \<= - 16384. - -**-m, \--mid-side** -: Try mid-side coding for each frame (stereo input only) - -**-M, \--adaptive-mid-side** -: Adaptive mid-side coding for all frames (stereo input only) - -**-0..-8, \--compression-level-0..\--compression-level-8** -: Fastest compression..highest compression (default is -5). These are - synonyms for other options: - -**-0, \--compression-level-0** -: Synonymous with -l 0 -b 1152 -r 3 \--no-mid-side - -**-1, \--compression-level-1** -: Synonymous with -l 0 -b 1152 -M -r 3 - -**-2, \--compression-level-2** -: Synonymous with -l 0 -b 1152 -m -r 3 - -**-3, \--compression-level-3** -: Synonymous with -l 6 -b 4096 -r 4 \--no-mid-side - -**-4, \--compression-level-4** -: Synonymous with -l 8 -b 4096 -M -r 4 - -**-5, \--compression-level-5** -: Synonymous with -l 8 -b 4096 -m -r 5 - -**-6, \--compression-level-6** -: Synonymous with -l 8 -b 4096 -m -r 6 -A subdivide_tukey(2) - -**-7, \--compression-level-7** -: Synonymous with -l 12 -b 4096 -m -r 6 -A subdivide_tukey(2) - -**-8, \--compression-level-8** -: Synonymous with -l 12 -b 4096 -m -r 6 -A subdivide_tukey(3) - -**\--fast** -: Fastest compression. Currently synonymous with -0. - -**\--best** -: Highest compression. Currently synonymous with -8. - -**-e, \--exhaustive-model-search** -: Do exhaustive model search (expensive!) - -**-A** *function***, \--apodization=***function* -: Window audio data with given the apodization function. See section - **Apodization functions** for details. - -**-l** *\#***, \--max-lpc-order=***\#* -: Specifies the maximum LPC order. This number must be \<= 32. For - subset streams, it must be \<=12 if the sample rate is \<=48kHz. If - 0, the encoder will not attempt generic linear prediction, and use - only fixed predictors. Using fixed predictors is faster but usually - results in files being 5-10% larger. - -**-p, \--qlp-coeff-precision-search** -: Do exhaustive search of LP coefficient quantization (expensive!). - Overrides -q; does nothing if using -l 0 - -**-q** *\#***, \--qlp-coeff-precision=***\#* -: Precision of the quantized linear-predictor coefficients, 0 =\> let - encoder decide (min is 5, default is 0) - -**-r \[***\#***,\]***\#***, \--rice-partition-order=\[***\#***,\]***\#* -: Set the \[min,\]max residual partition order (0..15). min defaults to - 0 if unspecified. Default is -r 5. - -## FORMAT OPTIONS - -**\--endian={***big***\|***little***}** -: Set the byte order for samples - -**\--channels=***\#* -: Set number of channels. - -**\--bps=***\#* -: Set bits per sample. - -**\--sample-rate=***\#* -: Set sample rate (in Hz). - -**\--sign={***signed***\|***unsigned***}** -: Set the sign of samples. - -**\--input-size=***\#* -: Specify the size of the raw input in bytes. If you are encoding raw - samples from stdin, you must set this option in order to be able to - use \--skip, \--until, \--cuesheet, or other options that need to - know the size of the input beforehand. If the size given is greater - than what is found in the input stream, the encoder will complain - about an unexpected end-of-file. If the size given is less, samples - will be truncated. - -**\--force-raw-format** -: Force input (when encoding) or output (when decoding) to be treated - as raw samples (even if filename ends in *.wav*). - -**\--force-aiff-format** -**\--force-rf64-format** -**\--force-wave64-format** -: Force the decoder to output AIFF/RF64/WAVE64 format respectively. - This option is not needed if the output filename (as set by -o) - ends with *.aif* or *.aiff*, *.rf64* and *.w64* respectively. Also, - this option has no effect when encoding since input is - auto-detected. When none of these options nor - --keep-foreign-metadata are given and no output filename is set, - the output format is WAV by default. - -**\--force-legacy-wave-format** -**\--force-extensible-wave-format** -: Instruct the decoder to output a WAVE file with WAVE_FORMAT_PCM and - WAVE_FORMAT_EXTENSIBLE respectively. If none of these options nor - --keep-foreign-metadata are given, FLAC outputs WAVE_FORMAT_PCM - for mono or stereo with a bit depth of 8 or 16 bits, and - WAVE_FORMAT_EXTENSIBLE for all other audio formats. - -**\--force-aiff-c-none-format** -**\--force-aiff-c-sowt-format** -: Instruct the decoder to output an AIFF-C file with format NONE and - sowt respectively. - -## NEGATIVE OPTIONS - -**\--no-adaptive-mid-side** -**\--no-cued-seekpoints** -**\--no-decode-through-errors** -**\--no-delete-input-file** -**\--no-preserve-modtime** -**\--no-keep-foreign-metadata** -**\--no-exhaustive-model-search** -**\--no-force** -**\--no-lax** -**\--no-mid-side** -**\--no-ogg** -**\--no-padding** -**\--no-qlp-coeff-prec-search** -**\--no-replay-gain** -**\--no-residual-gnuplot** -**\--no-residual-text** -**\--no-seektable** -**\--no-silent** -**\--no-verify** -**\--no-warnings-as-errors** - -These flags can be used to invert the sense of the corresponding normal -option. - -## ReplayGain application specification -The option \--apply-replaygain-which-is-not-lossless\[=\\]** -applies ReplayGain values while decoding. **WARNING: THIS IS NOT -LOSSLESS. DECODED AUDIO WILL NOT BE IDENTICAL TO THE ORIGINAL WITH THIS -OPTION.** This option is useful for example in transcoding media servers, -where the client does not support ReplayGain. - -The equals sign and \ is optional. If omitted, the -default specification is 0aLn1. - -The \ is a shorthand notation for describing how to apply -ReplayGain. All components are optional but order is important. '\[\]' -means 'optional'. '\|' means 'or'. '{}' means required. The format is: - -\[\\]\[a\|t\]\[l\|L\]\[n{0\|1\|2\|3}\] - -In which the following parameters are used: - -- **preamp**: A floating point number in dB. This is added to the - existing gain value. - -- **a\|t**: Specify 'a' to use the album gain, or 't' to use the track - gain. If tags for the preferred kind (album/track) do not exist but - tags for the other (track/album) do, those will be used instead. - -- **l\|L**: Specify 'l' to peak-limit the output, so that the - ReplayGain peak value is full-scale. Specify 'L' to use a 6dB hard - limiter that kicks in when the signal approaches full-scale. - -- **n{0\|1\|2\|3}**: Specify the amount of noise shaping. ReplayGain - synthesis happens in floating point; the result is dithered before - converting back to integer. This quantization adds noise. Noise - shaping tries to move the noise where you won't hear it as much. - 0 means no noise shaping, 1 means 'low', 2 means 'medium', 3 means - 'high'. - -For example, the default of 0aLn1 means 0dB preamp, use album gain, 6dB -hard limit, low noise shaping. \--apply-replaygain-which-is-not-lossless=3 -means 3dB preamp, use album gain, no limiting, no noise shaping. - -flac uses the ReplayGain tags for the calculation. If a stream does -not have the required tags or they can't be parsed, decoding will -continue with a warning, and no ReplayGain is applied to that stream. - -## Picture specification -This described the specification used for the **\--picture** option. -\[TYPE\]\|\[MIME-TYPE\]\|\[DESCRIPTION\]\|\[WIDTHxHEIGHTxDEPTH\[/COLORS\]\]\|FILE - -TYPE is optional; it is a number from one of: - -0. Other -1. 32x32 pixels 'file icon' (PNG only) -2. Other file icon -3. Cover (front) -4. Cover (back) -5. Leaflet page -6. Media (e.g. label side of CD) -7. Lead artist/lead performer/soloist -8. Artist/performer -9. Conductor -10. Band/Orchestra -11. Composer -12. Lyricist/text writer -13. Recording Location -14. During recording -15. During performance -16. Movie/video screen capture -17. A bright coloured fish -18. Illustration -19. Band/artist logotype -20. Publisher/Studio logotype - -The default is 3 (front cover). There may only be one picture each of -type 1 and 2 in a file. - -MIME-TYPE is optional; if left blank, it will be detected from the file. -For best compatibility with players, use pictures with MIME type -image/jpeg or image/png. The MIME type can also be \--\> to mean that -FILE is actually a URL to an image, though this use is discouraged. - -DESCRIPTION is optional; the default is an empty string. - -The next part specifies the resolution and color information. If the -MIME-TYPE is image/jpeg, image/png, or image/gif, you can usually leave -this empty and they can be detected from the file. Otherwise, you must -specify the width in pixels, height in pixels, and color depth in -bits-per-pixel. If the image has indexed colors you should also specify -the number of colors used. When manually specified, it is not checked -against the file for accuracy. - -FILE is the path to the picture file to be imported, or the URL if MIME -type is \--\> - -For example, "\|image/jpeg\|\|\|../cover.jpg" will embed the JPEG file -at ../cover.jpg, defaulting to type 3 (front cover) and an empty -description. The resolution and color info will be retrieved from the -file itself. - -The specification -"4\|\--\>\|CD\|320x300x24/173\|http://blah.blah/backcover.tiff" will -embed the given URL, with type 4 (back cover), description "CD", and a -manually specified resolution of 320x300, 24 bits-per-pixel, and 173 -colors. The file at the URL will not be fetched; the URL itself is -stored in the PICTURE metadata block. - -## Apodization functions -To improve LPC analysis, audio data is windowed . The window can be -selected with one or more **-A** options. Possible functions are: -bartlett, bartlett_hann, blackman, blackman_harris_4term_92db, -connes, flattop, gauss(STDDEV), hamming, hann, kaiser_bessel, nuttall, -rectangle, triangle, tukey(P), partial_tukey(n\[/ov\[/P\]\]), -punchout_tukey(n\[/ov\[/P\]\]), subdivide_tukey(n\[/P\]) welch. - -- For gauss(STDDEV), STDDEV is the standard deviation (0\ for the Debian GNU/Linux system (but may be used by -others). It has been kept up-to-date by the Xiph.org Foundation. diff --git a/Engine/lib/flac/man/metaflac.md b/Engine/lib/flac/man/metaflac.md deleted file mode 100644 index 8c049d743..000000000 --- a/Engine/lib/flac/man/metaflac.md +++ /dev/null @@ -1,299 +0,0 @@ -% metaflac(1) Version 1.4.3 | Free Lossless Audio Codec metadata tool - -# NAME - -metaflac - program to list, add, remove, or edit metadata in one or more -FLAC files. - -# SYNOPSIS - -**metaflac** \[ *options* \] \[ *operations* \] *FLACfile ...* - -# DESCRIPTION - -Use **metaflac** to list, add, remove, or edit metadata in one or more -FLAC files. You may perform one major operation, or many shorthand -operations at a time. - -# GENERAL USAGE - -metaflac is the command-line .flac file metadata editor. You can use it -to list the contents of metadata blocks, edit, delete or insert blocks, -and manage padding. - -metaflac takes a set of "options" (though some are not optional) and a -set of FLAC files to operate on. There are three kinds of "options": - -- Major operations, which specify a mode of operation like listing - blocks, removing blocks, etc. These will have sub-operations describing - exactly what is to be done. - -- Shorthand operations, which are convenient synonyms for major - operations. For example, there is a shorthand operation - --show-sample-rate that shows just the sample rate field from the - STREAMINFO metadata block. - -- Global options, which affect all the operations. - -All of these are described in the tables below. At least one shorthand -or major operation must be supplied. You can use multiple shorthand -operations to do more than one thing to a file or set of files. Most of -the common things to do to metadata have shorthand operations. As an -example, here is how to show the MD5 signatures for a set of three FLAC -files: - -`metaflac --show-md5sum file1.flac file2.flac file3.flac` - -Another example; this removes all DESCRIPTION and COMMENT tags in a set -of FLAC files, and uses the --preserve-modtime global option to keep the -FLAC file modification times the same (usually when files are edited the -modification time is set to the current time): - -`metaflac --preserve-modtime --remove-tag=DESCRIPTION --remove-tag=COMMENT file1.flac file2.flac file3.flac` - -# OPTIONS - -**\--preserve-modtime** -: Preserve the original modification time in spite of edits. - -**\--with-filename** -: Prefix each output line with the FLAC file name (the default if more - than one FLAC file is specified). This option has no effect for - options exporting to a file, like --export-tags-to. - -**\--no-filename** -: Do not prefix each output line with the FLAC file name (the default - if only one FLAC file is specified). - -**\--no-utf8-convert** -: Do not convert tags from UTF-8 to local charset, or vice versa. This - is useful for scripts, and setting tags in situations where the - locale is wrong. - -**\--dont-use-padding** -: By default metaflac tries to use padding where possible to avoid - rewriting the entire file if the metadata size changes. Use this - option to tell metaflac to not take advantage of padding this way. - -# SHORTHAND OPERATIONS - -**\--show-md5sum** -: Show the MD5 signature from the STREAMINFO block. - -**\--show-min-blocksize** -: Show the minimum block size from the STREAMINFO block. - -**\--show-max-blocksize** -: Show the maximum block size from the STREAMINFO block. - -**\--show-min-framesize** -: Show the minimum frame size from the STREAMINFO block. - -**\--show-max-framesize** -: Show the maximum frame size from the STREAMINFO block. - -**\--show-sample-rate** -: Show the sample rate from the STREAMINFO block. - -**\--show-channels** -: Show the number of channels from the STREAMINFO block. - -**\--show-bps** -: Show the \# of bits per sample from the STREAMINFO block. - -**\--show-total-samples** -: Show the total \# of samples from the STREAMINFO block. - -**\--show-vendor-tag** -: Show the vendor string from the VORBIS_COMMENT block. - -**\--show-tag=name** -: Show all tags where the field name matches 'name'. - -**\--show-all-tags** -: Show all tags. This is an alias for --export-tags-to=-. - -**\--remove-tag=name** -: Remove all tags whose field name is 'name'. - -**\--remove-first-tag=name** -: Remove first tag whose field name is 'name'. - -**\--remove-all-tags** -: Remove all tags, leaving only the vendor string. - -**\--remove-all-tags-except=NAME1\[=NAME2\[=...\]\]** -: Remove all tags, except the vendor string and the tag names - specified. Tag names must be separated by an = character. - -**\--set-tag=field** -: Add a tag. The field must comply with the Vorbis comment spec, of the - form "NAME=VALUE". If there is currently no tag block, one will be - created. - -**\--set-tag-from-file=field** -: Like \--set-tag, except the VALUE is a filename whose contents will - be read verbatim to set the tag value. Unless \--no-utf8-convert is - specified, the contents will be converted to UTF-8 from the local - charset. This can be used to store a cuesheet in a tag (e.g. - \--set-tag-from-file="CUESHEET=image.cue"). Do not try to store - binary data in tag fields! Use APPLICATION blocks for that. - -**\--import-tags-from=file** -: Import tags from a file. Use '-' for stdin. Each line should be of - the form NAME=VALUE. Multi-line comments are currently not supported. - Specify \--remove-all-tags and/or \--no-utf8-convert before - \--import-tags-from if necessary. If FILE is '-' (stdin), only one - FLAC file may be specified. - -**\--export-tags-to=file** -: Export tags to a file. Use '-' for stdout. Each line will be of the - form NAME=VALUE. Specify \--no-utf8-convert if necessary. - -**\--import-cuesheet-from=file** -: Import a cuesheet from a file. Use '-' for stdin. Only one FLAC file - may be specified. A seekpoint will be added for each index point in - the cuesheet to the SEEKTABLE unless \--no-cued-seekpoints is - specified. - -**\--export-cuesheet-to=file** -: Export CUESHEET block to a cuesheet file, suitable for use by CD - authoring software. Use '-' for stdout. Only one FLAC file may be - specified on the command line. - -**\--import-picture-from={***FILENAME***\|***SPECIFICATION***}** -: Import a picture and store it in a PICTURE metadata block. More than - one \--import-picture-from command can be specified. Either a filename - for the picture file or a more complete specification form can be - used. The SPECIFICATION is a string whose parts are separated by \| - (pipe) characters. Some parts may be left empty to invoke default - values. FILENAME is just shorthand for "\|\|\|\|FILENAME". For - details on the specification, see the section **Picture - specification** in the **flac(1)** man page. - -**\--export-picture-to=file** -: Export PICTURE block to a file. Use '-' for stdout. Only one FLAC - file may be specified on the command line. The first PICTURE block - will be exported unless \--export-picture-to is preceded by a - \--block-number=# option to specify the exact metadata block to - extract. Note that the block number is the one shown by \--list. - -**\--add-replay-gain** -: Calculates the title and album gains/peaks of the given FLAC files as - if all the files were part of one album, then stores them as FLAC - tags. The tags are the same as those used by vorbisgain. Existing - ReplayGain tags will be replaced. If only one FLAC file is given, - the album and title gains will be the same. Since this operation - requires two passes, it is always executed last, after all other - operations have been completed and written to disk. All FLAC files - specified must have the same resolution, sample rate, and number of - channels. Only mono and stereo files are allowed, and the sample - rate must be 8, 11.025, 12, 16, 18.9, 22.05, 24, 28, 32, 36, 37.8, - 44.1, 48, 56, 64, 72, 75.6, 88.2, 96, 112, 128, 144, 151.2, 176.4, - 192, 224, 256, 288, 302.4, 352.8, 384, 448, 512, 576, or 604.8 kHz. - -**\--scan-replay-gain** -: Like \--add-replay-gain, but only analyzes the files rather than - writing them to the tags. - -**\--remove-replay-gain** -: Removes the ReplayGain tags. - -**\--add-seekpoint={***\#***\|***X***\|***\#x***\|***\#s***}** -: Add seek points to a SEEKTABLE block. Using \#, a seek point at that - sample number is added. Using X, a placeholder point is added at the - end of a the table. Using \#x, \# evenly spaced seek points will be - added, the first being at sample 0. Using \#s, a seekpoint will be - added every \# seconds (# does not have to be a whole number; it can - be, for example, 9.5, meaning a seekpoint every 9.5 seconds). If no - SEEKTABLE block exists, one will be created. If one already exists, - points will be added to the existing table, and any duplicates will - be turned into placeholder points. You may use many \--add-seekpoint - options; the resulting SEEKTABLE will be the unique-ified union of - all such values. Example: \--add-seekpoint=100x \--add-seekpoint=3.5s - will add 100 evenly spaced seekpoints and a seekpoint every 3.5 - seconds. - -**\--add-padding=length** -: Add a padding block of the given length (in bytes). The overall - length of the new block will be 4 + length; the extra 4 bytes is for - the metadata block header. - -# MAJOR OPERATIONS - -**\--list** -: List the contents of one or more metadata blocks to stdout. By - default, all metadata blocks are listed in text format. Use the - options **\--block-number**, **\--block-type** or - **\--except-block-type** to change this behavior. - -**\--remove** -: Remove one or more metadata blocks from the metadata. Use the options - **\--block-number**, **\--block-type** or **\--except-block-type** - to specify which blocks should be removed. Note that if both - \--block-number and \--[except-]block-type are specified, the result - is the logical AND of both arguments. Unless \--dont-use-padding - is specified, the blocks will be replaced with padding. You may not - remove the STREAMINFO block. - -**\--block-number=#\[,#\[...\]\]** -: An optional comma-separated list of block numbers to display. The - first block, the STREAMINFO block, is block 0. - -**\--block-type=type\[,type\[...\]\]** - -**\--except-block-type=type\[,type\[...\]\]** -: An optional comma-separated list of block types to be included or - ignored with this option. Use only one of \--block-type or - \--except-block-type. The valid block types are: STREAMINFO, PADDING, - APPLICATION, SEEKTABLE, VORBIS_COMMENT, PICTURE. You may narrow down - the types of APPLICATION blocks selected by appending APPLICATION - with a colon and the ID of the APPLICATION block in either ASCII - or hexadecimal representation. E.g. APPLICATION:abcd for the - APPLICATION block(s) whose textual representation of the 4-byte ID - is "abcd" or APPLICATION:0xXXXXXXXX for the APPLICATION block(s) - whose hexadecimal big- endian representation of the 4-byte ID - is "0xXXXXXXXX". For the example "abcd" above the hexadecimal - equivalalent is 0x61626364 - -**\--application-data-format=hexdump\|text** -: If the application block you are displaying contains binary data but - your \--data-format=text, you can display a hex dump of the - application data contents instead using - \--application-data-format=hexdump. - -**\--data-format=binary\|binary-headerless\|text** -: For use with --list. By default a human-readable text - representation of the data is isplayed. You may specify - --data-format=binary to dump the raw binary form of each metadata - block. Specify --data-format=binary-headerless to omit output of - metadata block headers, including the id of APPLICATION metadata - blocks. - -**\--append** -: Insert a metadata block from a file. This must be a binary block as - exported with --list --data-format=binary. The insertion point is - defined with --block-number=#. The new block will be added after the - given block number. This prevents the illegal insertion of a block - before the first STREAMINFO block. You may not --append another - STREAMINFO block. It is possible to copy a metadata block from one - file to another with this option. For example use - `metaflac --list --data-format=binary --block-number=6 file.flac > block` - to export the block, and then import it with - `metaflac --append anotherfile.flac < block` - -**\--remove-all** -: Remove all metadata blocks (except the STREAMINFO block) from the - metadata. Unless \--dont-use-padding is specified, the blocks will be - replaced with padding. - -**\--merge-padding** -: Merge adjacent PADDING blocks into single blocks. - -**\--sort-padding** -: Move all PADDING blocks to the end of the metadata and merge them - into a single block. - -# SEE ALSO - -**flac(1)** diff --git a/Engine/lib/flac/microbench/CMakeLists.txt b/Engine/lib/flac/microbench/CMakeLists.txt deleted file mode 100644 index 639915b63..000000000 --- a/Engine/lib/flac/microbench/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -if(MSVC) - return() -endif() - -set(CMAKE_REQUIRED_LIBRARIES rt) -check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) - -if(APPLE) - add_definitions(-DFLAC__SYS_DARWIN) -endif() - -add_executable(benchmark_residual benchmark_residual.c util.c) -target_include_directories(benchmark_residual PRIVATE - "$/include") -target_link_libraries(benchmark_residual - FLAC - $<$:rt>) diff --git a/Engine/lib/flac/microbench/Makefile.am b/Engine/lib/flac/microbench/Makefile.am deleted file mode 100644 index 81de3adb8..000000000 --- a/Engine/lib/flac/microbench/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2015-2023 Xiph.Org Foundation -# -# 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 the Xiph.org Foundation nor the names of its -# 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 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. - - -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/libFLAC/include - -noinst_HEADERS = util.h - -noinst_PROGRAMS = benchmark_residual - -benchmark_residual_SOURCES = benchmark_residual.c util.c - -benchmark_residual_LDADD = @LIB_CLOCK_GETTIME@ - -EXTRA_DIST = CMakeLists.txt diff --git a/Engine/lib/flac/microbench/benchmark_residual.c b/Engine/lib/flac/microbench/benchmark_residual.c deleted file mode 100644 index d9b19d7bb..000000000 --- a/Engine/lib/flac/microbench/benchmark_residual.c +++ /dev/null @@ -1,151 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include "FLAC/ordinals.h" -#include "share/compat.h" -#include "private/bitmath.h" -#include "private/fixed.h" -#include "private/macros.h" -#include "FLAC/assert.h" - -#include "util.h" - -static void FLAC__fixed_compute_residual_shift(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]) -{ - const int idata_len = (int) data_len; - int i; - - switch(order) { - case 0: - FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); - memcpy(residual, data, sizeof(residual[0])*data_len); - break; - case 1: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - data[i-1]; - break; - case 2: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - (data[i-1] << 1) + data[i-2]; - break; - case 3: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) - data[i-3]; - break; - case 4: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - ((data[i-1]+data[i-3])<<2) + ((data[i-2]<<2) + (data[i-2]<<1)) + data[i-4]; - break; - default: - FLAC__ASSERT(0); - } -} - -static void FLAC__fixed_compute_residual_mult(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]) -{ - const int idata_len = (int)data_len; - int i; - - switch(order) { - case 0: - FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); - memcpy(residual, data, sizeof(residual[0])*data_len); - break; - case 1: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - data[i-1]; - break; - case 2: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - 2*data[i-1] + data[i-2]; - break; - case 3: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3]; - break; - case 4: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4]; - break; - default: - FLAC__ASSERT(0); - } -} - -static FLAC__int32 data [200000] ; -static FLAC__int32 residual [200000] ; - -static unsigned bench_order = 0 ; - -static void -bench_shift (void) -{ FLAC__fixed_compute_residual_shift (data, ARRAY_LEN (data), bench_order, residual) ; -} - -static void -bench_mult (void) -{ FLAC__fixed_compute_residual_mult (data, ARRAY_LEN (data), bench_order, residual) ; -} - -int -main (void) -{ bench_stats stats ; - - puts ("") ; - - for (bench_order = 2 ; bench_order <= 4 ; bench_order ++) { - memset (&stats, 0, sizeof (stats)) ; - stats.testfunc = bench_shift ; - stats.run_count = 100 ; - stats.loop_count = 10 ; - - benchmark_stats (&stats) ; - printf ("shift order %u : %f %f %f %f\n", bench_order, stats.min_time, stats.median_time, stats.mean_time, stats.max_time) ; - - memset (&stats, 0, sizeof (stats)) ; - stats.testfunc = bench_mult ; - stats.run_count = 100 ; - stats.loop_count = 10 ; - - benchmark_stats (&stats) ; - printf ("mult order %u : %f %f %f %f\n\n", bench_order, stats.min_time, stats.median_time, stats.mean_time, stats.max_time) ; - } - - return 0 ; -} diff --git a/Engine/lib/flac/microbench/util.c b/Engine/lib/flac/microbench/util.c deleted file mode 100644 index 2ecd4a35b..000000000 --- a/Engine/lib/flac/microbench/util.c +++ /dev/null @@ -1,205 +0,0 @@ -/* FLAC - Free Lossless Audio Codec - * Copyright (C) 2015-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include "util.h" - -#if defined _WIN32 - -#include - -static double -counter_diff (const LARGE_INTEGER * start, const LARGE_INTEGER * end) -{ - LARGE_INTEGER diff, freq; - - QueryPerformanceFrequency(&freq); - diff.QuadPart = end->QuadPart - start->QuadPart; - - return (double)diff.QuadPart/(double)freq.QuadPart; -} - -double -benchmark_function (void (*testfunc) (void), unsigned count) -{ - LARGE_INTEGER start, end; - unsigned k; - - QueryPerformanceCounter (&start) ; - - for (k = 0 ; k < count ; k++) - testfunc(); - - QueryPerformanceCounter (&end) ; - - return counter_diff (&start, &end) / count ; -} /* benchmark_function */ - -#elif defined FLAC__SYS_DARWIN - -#include - -static double -counter_diff (const uint64_t * start, const uint64_t * end) -{ - mach_timebase_info_data_t t_info; - mach_timebase_info(&t_info); - uint64_t duration = *end - *start; - - return duration * ((double)t_info.numer/(double)t_info.denom); -} - -double -benchmark_function (void (*testfunc) (void), unsigned count) -{ - uint64_t start, end; - unsigned k; - - start = mach_absolute_time(); - - for (k = 0 ; k < count ; k++) - testfunc(); - - end = mach_absolute_time(); - - return counter_diff (&start, &end) / count ; -} /* benchmark_function */ - -#elif defined HAVE_CLOCK_GETTIME - -#include -#include - -static double -timespec_diff (const struct timespec * start, const struct timespec * end) -{ struct timespec diff; - - if (end->tv_nsec - start->tv_nsec < 0) - { diff.tv_sec = end->tv_sec - start->tv_sec - 1 ; - diff.tv_nsec = 1000000000 + end->tv_nsec - start->tv_nsec ; - } - else - { diff.tv_sec = end->tv_sec - start->tv_sec ; - diff.tv_nsec = end->tv_nsec-start->tv_nsec ; - } ; - - return diff.tv_sec + 1e-9 * diff.tv_nsec ; -} - -double -benchmark_function (void (*testfunc) (void), unsigned count) -{ struct timespec start, end; - unsigned k ; - - clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &start) ; - - for (k = 0 ; k < count ; k++) - testfunc () ; - - clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &end) ; - - return timespec_diff (&start, &end) / count ; -} /* benchmark_function */ - -#else - -#include -#include - -static double -timeval_diff (const struct timeval * start, const struct timeval * end) -{ struct timeval diff; - - if (end->tv_usec - start->tv_usec < 0) - { diff.tv_sec = end->tv_sec - start->tv_sec - 1 ; - diff.tv_usec = 1000000 + end->tv_usec - start->tv_usec ; - } - else - { diff.tv_sec = end->tv_sec - start->tv_sec ; - diff.tv_usec = end->tv_usec-start->tv_usec ; - } ; - - return diff.tv_sec + 1e-6 * diff.tv_usec ; -} - -double -benchmark_function (void (*testfunc) (void), unsigned count) -{ struct timeval start, end; - unsigned k ; - - gettimeofday(&start, NULL); - - for (k = 0 ; k < count ; k++) - testfunc () ; - - gettimeofday(&end, NULL); - - return timeval_diff (&start, &end) / count ; -} /* benchmark_function */ - -#endif - -static int -double_cmp (const void * a, const void * b) -{ const double * pa = (double *) a ; - const double * pb = (double *) b ; - return pa [0] < pb [0] ; -} /* double_cmp */ - -void -benchmark_stats (bench_stats * stats) -{ double sum, times [stats->run_count] ; - unsigned k ; - - for (k = 0 ; k < stats->run_count ; k++) - times [k] = benchmark_function (stats->testfunc, stats->loop_count) ; - - qsort (times, stats->run_count, sizeof (times [0]), double_cmp) ; - - sum = 0.0 ; - stats->min_time = stats->max_time = times [0] ; - for (k = 0 ; k < stats->run_count ; k++) - { stats->min_time = stats->min_time < times [k] ? stats->min_time : times [k] ; - stats->max_time = stats->max_time > times [k] ? stats->max_time : times [k] ; - sum += times [k] ; - } - stats->mean_time = sum / stats->run_count ; - if (stats->run_count & 1) - stats->median_time = times [(stats->run_count + 1) / 2] ; - else - stats->median_time = 0.5 * (times [stats->run_count / 2] + times [(stats->run_count / 2) + 1]) ; - - return ; -} /* benchmark_stats */ diff --git a/Engine/lib/flac/microbench/util.h b/Engine/lib/flac/microbench/util.h deleted file mode 100644 index 1fba4466a..000000000 --- a/Engine/lib/flac/microbench/util.h +++ /dev/null @@ -1,43 +0,0 @@ -/* FLAC - Free Lossless Audio Codec - * Copyright (C) 2015-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#define ARRAY_LEN(x) ((sizeof (x) / sizeof (x [0]))) - -typedef struct bench_stats -{ void (*testfunc) (void) ; - unsigned run_count ; - unsigned loop_count ; - double min_time, mean_time, median_time, max_time ; -} bench_stats ; - -double benchmark_function (void (*testfunc) (void), unsigned count) ; - -void benchmark_stats (bench_stats * stats) ; diff --git a/Engine/lib/flac/oss-fuzz/Makefile.am b/Engine/lib/flac/oss-fuzz/Makefile.am deleted file mode 100644 index bf669aa36..000000000 --- a/Engine/lib/flac/oss-fuzz/Makefile.am +++ /dev/null @@ -1,104 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2019-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/oss-fuzz - -AM_CFLAGS = ${LIB_FUZZING_ENGINE} -AM_CXXFLAGS = -std=c++11 $(LIB_FUZZING_ENGINE) -LDADD = $(flac_libs) - - -EXTRA_DIST = \ - fuzzer_encoder.dict \ - common.h \ - Readme.md \ - fuzzing/datasource/datasource.hpp \ - fuzzing/datasource/id.hpp \ - fuzzing/exception.hpp \ - fuzzing/memory.hpp \ - fuzzing/types.hpp - -noinst_PROGRAMS = - -if USE_OSSFUZZERS -noinst_PROGRAMS += fuzzer_encoder fuzzer_encoder_v2 fuzzer_decoder fuzzer_seek fuzzer_metadata fuzzer_reencoder fuzzer_tool_flac fuzzer_tool_metaflac -endif - -fuzzer_encoder_SOURCES = encoder.cc -fuzzer_encoder_v2_SOURCES = encoder_v2.cc -fuzzer_decoder_SOURCES = decoder.cc -fuzzer_seek_SOURCES = seek.cc -fuzzer_metadata_SOURCES = metadata.cc -fuzzer_reencoder_SOURCES = reencoder.cc -fuzzer_tool_flac_SOURCES = ${flac_SOURCES} empty.cc tool_flac.c # empty.cc is to force use of C++ linker, which is mandated by oss-fuzz -fuzzer_tool_flac_LDADD = \ - $(top_builddir)/src/share/utf8/libutf8.la \ - $(top_builddir)/src/share/grabbag/libgrabbag.la \ - $(top_builddir)/src/share/getopt/libgetopt.la \ - $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ - $(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - @LTLIBICONV@ \ - -lm -fuzzer_tool_metaflac_SOURCES = ${metaflac_SOURCES} empty.cc tool_metaflac.c # empty.cc is to force use of C++ linker, which is mandated by oss-fuzz -fuzzer_tool_metaflac_LDADD = \ - $(top_builddir)/src/share/utf8/libutf8.la \ - $(top_builddir)/src/share/grabbag/libgrabbag.la \ - $(top_builddir)/src/share/getopt/libgetopt.la \ - $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ - $(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - @LTLIBICONV@ \ - -lm - -flac_libs = \ - $(top_builddir)/src/libFLAC/libFLAC-static.la \ - $(top_builddir)/src/libFLAC++/libFLAC++-static.la \ - @OGG_LIBS@ \ - -lm - -flac_SOURCES = \ - ${top_builddir}/src/flac/analyze.c \ - ${top_builddir}/src/flac/decode.c \ - ${top_builddir}/src/flac/encode.c \ - ${top_builddir}/src/flac/foreign_metadata.c \ - ${top_builddir}/src/flac/local_string_utils.c \ - ${top_builddir}/src/flac/utils.c \ - ${top_builddir}/src/flac/vorbiscomment.c \ - ${top_builddir}/src/flac/analyze.h \ - ${top_builddir}/src/flac/decode.h \ - ${top_builddir}/src/flac/encode.h \ - ${top_builddir}/src/flac/foreign_metadata.h \ - ${top_builddir}/src/flac/local_string_utils.h \ - ${top_builddir}/src/flac/utils.h \ - ${top_builddir}/src/flac/vorbiscomment.h - -metaflac_SOURCES = \ - ${top_builddir}/src/metaflac/operations.c \ - ${top_builddir}/src/metaflac/operations_shorthand_cuesheet.c \ - ${top_builddir}/src/metaflac/operations_shorthand_picture.c \ - ${top_builddir}/src/metaflac/operations_shorthand_seektable.c \ - ${top_builddir}/src/metaflac/operations_shorthand_streaminfo.c \ - ${top_builddir}/src/metaflac/operations_shorthand_vorbiscomment.c \ - ${top_builddir}/src/metaflac/options.c \ - ${top_builddir}/src/metaflac/usage.c \ - ${top_builddir}/src/metaflac/utils.c \ - ${top_builddir}/src/metaflac/operations.h \ - ${top_builddir}/src/metaflac/operations_shorthand.h \ - ${top_builddir}/src/metaflac/options.h \ - ${top_builddir}/src/metaflac/usage.h \ - ${top_builddir}/src/metaflac/utils.h diff --git a/Engine/lib/flac/oss-fuzz/Readme.md b/Engine/lib/flac/oss-fuzz/Readme.md deleted file mode 100644 index 90f27639b..000000000 --- a/Engine/lib/flac/oss-fuzz/Readme.md +++ /dev/null @@ -1,13 +0,0 @@ -Fuzzers fuzzer_decoder.cc and fuzzer_encoder.cc were taken from - - https://github.com/guidovranken/flac-fuzzers - -The header files in the directory fuzzing and below were taken from: - - https://github.com/guidovranken/fuzzing-headers.git - -Some minor modifications were made to make them build with the default C++ -warning flags. - -The code mentioned above, contributed by Guido Vranken, is licensed under -the MIT license. See the files themselves for details diff --git a/Engine/lib/flac/oss-fuzz/common.h b/Engine/lib/flac/oss-fuzz/common.h deleted file mode 100644 index 9545f95e2..000000000 --- a/Engine/lib/flac/oss-fuzz/common.h +++ /dev/null @@ -1,2 +0,0 @@ -extern int alloc_check_threshold, alloc_check_counter; -int alloc_check_threshold = INT32_MAX, alloc_check_counter = 0; diff --git a/Engine/lib/flac/oss-fuzz/decoder.cc b/Engine/lib/flac/oss-fuzz/decoder.cc deleted file mode 100644 index b7ddf2182..000000000 --- a/Engine/lib/flac/oss-fuzz/decoder.cc +++ /dev/null @@ -1,408 +0,0 @@ -/* Copyright 2019 Guido Vranken - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#include -#include - -#include "FLAC++/decoder.h" -#include "FLAC++/metadata.h" -#include "common.h" - -template <> FLAC__MetadataType fuzzing::datasource::Base::Get(const uint64_t id) { - (void)id; - switch ( Get() ) { - case 0: - return FLAC__METADATA_TYPE_STREAMINFO; - case 1: - return FLAC__METADATA_TYPE_PADDING; - case 2: - return FLAC__METADATA_TYPE_APPLICATION; - case 3: - return FLAC__METADATA_TYPE_SEEKTABLE; - case 4: - return FLAC__METADATA_TYPE_VORBIS_COMMENT; - case 5: - return FLAC__METADATA_TYPE_CUESHEET; - case 6: - return FLAC__METADATA_TYPE_PICTURE; - case 7: - return FLAC__METADATA_TYPE_UNDEFINED; - case 8: - return FLAC__MAX_METADATA_TYPE; - default: - return FLAC__METADATA_TYPE_STREAMINFO; - } -} - -namespace FLAC { - namespace Decoder { - class FuzzerStream : public Stream { - private: - fuzzing::datasource::Datasource& ds; - public: - FuzzerStream(fuzzing::datasource::Datasource& dsrc) : - Stream(), ds(dsrc) { } - - ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) override { - try { - const size_t maxCopySize = *bytes; - - if ( maxCopySize > 0 ) { - /* memset just to test if this overwrites anything, and triggers ASAN */ - memset(buffer, 0, maxCopySize); - } - - const auto data = ds.GetData(0); - const auto dataSize = data.size(); - const auto copySize = std::min(maxCopySize, dataSize); - - if ( copySize > 0 ) { - memcpy(buffer, data.data(), copySize); - } - - *bytes = copySize; - - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } catch ( ... ) { - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - } - } - - ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) override { - { - fuzzing::memory::memory_test(&(frame->header), sizeof(frame->header)); - fuzzing::memory::memory_test(&(frame->footer), sizeof(frame->footer)); - } - - { - const auto numChannels = get_channels(); - const size_t bytesPerChannel = frame->header.blocksize * sizeof(FLAC__int32); - for (size_t i = 0; i < numChannels; i++) { - fuzzing::memory::memory_test(buffer[i], bytesPerChannel); - } - } - - try { - if ( ds.Get() == true ) { - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } catch ( ... ) { } - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; - } - - void error_callback(::FLAC__StreamDecoderErrorStatus status) override { - fuzzing::memory::memory_test(status); - } - - void metadata_callback(const ::FLAC__StreamMetadata *metadata) override { - Metadata::Prototype * cloned_object = nullptr; - fuzzing::memory::memory_test(metadata->type); - fuzzing::memory::memory_test(metadata->is_last); - fuzzing::memory::memory_test(metadata->length); - fuzzing::memory::memory_test(metadata->data); - if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) - cloned_object = new Metadata::StreamInfo(metadata); - else if (metadata->type == FLAC__METADATA_TYPE_PADDING) - cloned_object = new Metadata::Padding(metadata); - else if (metadata->type == FLAC__METADATA_TYPE_APPLICATION) - cloned_object = new Metadata::Application(metadata); - else if (metadata->type == FLAC__METADATA_TYPE_SEEKTABLE) - cloned_object = new Metadata::SeekTable(metadata); - else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) - cloned_object = new Metadata::VorbisComment(metadata); - else if (metadata->type == FLAC__METADATA_TYPE_CUESHEET) - cloned_object = new Metadata::CueSheet(metadata); - else if (metadata->type == FLAC__METADATA_TYPE_PICTURE) - cloned_object = new Metadata::Picture(metadata); - else - return; - if (0 != cloned_object && *cloned_object == *metadata && cloned_object->is_valid()) { - if (cloned_object->get_type() == FLAC__METADATA_TYPE_SEEKTABLE) - dynamic_cast(cloned_object)->is_legal(); - if (cloned_object->get_type() == FLAC__METADATA_TYPE_PICTURE) - dynamic_cast(cloned_object)->is_legal(NULL); - if (cloned_object->get_type() == FLAC__METADATA_TYPE_CUESHEET) - dynamic_cast(cloned_object)->is_legal(true,NULL); - } - delete cloned_object; - } - - ::FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) override { - fuzzing::memory::memory_test(absolute_byte_offset); - - try { - if ( ds.Get() == true ) { - return FLAC__STREAM_DECODER_SEEK_STATUS_OK; - } else { - return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - } - } catch ( ... ) { - return FLAC__STREAM_DECODER_SEEK_STATUS_OK; - } - } -#if 0 - ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) override { - fuzzing::memory::memory_test(*absolute_byte_offset); - - try { - if ( ds.Get() == true ) { - return FLAC__STREAM_DECODER_TELL_STATUS_OK; - } else { - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - } - } catch ( ... ) { - return FLAC__STREAM_DECODER_TELL_STATUS_OK; - } - } - - ::FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length) override { - fuzzing::memory::memory_test(*stream_length); - - try { - if ( ds.Get() == true ) { - return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; - } else { - return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; - } - } catch ( ... ) { - return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; - } - } -#endif - }; - } -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - fuzzing::datasource::Datasource ds(data, size); - FLAC::Decoder::FuzzerStream decoder(ds); - bool use_ogg = true; - - try { - if ( ds.Get() ) { - use_ogg = false; - } - if ( ds.Get() ) { -#ifdef FUZZER_DEBUG - printf("set_ogg_serial_number\n"); -#endif - decoder.set_ogg_serial_number(ds.Get()); - } - if ( ds.Get() ) { -#ifdef FUZZER_DEBUG - printf("set_md5_checking\n"); -#endif - decoder.set_md5_checking(ds.Get()); - } - if ( ds.Get() ) { -#ifdef FUZZER_DEBUG - printf("set_metadata_respond\n"); -#endif - decoder.set_metadata_respond(ds.Get<::FLAC__MetadataType>()); - } - if ( ds.Get() ) { - const auto idVector = ds.GetData(0); - unsigned char id[4]; - if ( idVector.size() >= sizeof(id) ) { - memcpy(id, idVector.data(), sizeof(id)); -#ifdef FUZZER_DEBUG - printf("set_metadata_respond_application\n"); -#endif - decoder.set_metadata_respond_application(id); - } - } - if ( ds.Get() ) { -#ifdef FUZZER_DEBUG - printf("set_metadata_respond_all\n"); -#endif - decoder.set_metadata_respond_all(); - } - if ( ds.Get() ) { -#ifdef FUZZER_DEBUG - printf("set_metadata_ignore\n"); -#endif - decoder.set_metadata_ignore(ds.Get<::FLAC__MetadataType>()); - } - if ( ds.Get() ) { - const auto idVector = ds.GetData(0); - unsigned char id[4]; - if ( idVector.size() >= sizeof(id) ) { - memcpy(id, idVector.data(), sizeof(id)); -#ifdef FUZZER_DEBUG - printf("set_metadata_ignore_application\n"); -#endif - decoder.set_metadata_ignore_application(id); - } - } - if ( ds.Get() ) { -#ifdef FUZZER_DEBUG - printf("set_metadata_ignore_all\n"); -#endif - decoder.set_metadata_ignore_all(); - } - { - ::FLAC__StreamDecoderInitStatus ret; - if ( !use_ogg ) { - ret = decoder.init(); - } else { - ret = decoder.init_ogg(); - } - - if ( ret != FLAC__STREAM_DECODER_INIT_STATUS_OK ) { - goto end; - } - } - - while ( ds.Get() ) { - switch ( ds.Get() ) { - case 0: - { -#ifdef FUZZER_DEBUG - printf("flush\n"); -#endif - const bool res = decoder.flush(); - fuzzing::memory::memory_test(res); - } - break; - case 1: - { -#ifdef FUZZER_DEBUG - printf("reset\n"); -#endif - const bool res = decoder.reset(); - fuzzing::memory::memory_test(res); - } - break; - case 2: - { -#ifdef FUZZER_DEBUG - printf("process_single\n"); -#endif - const bool res = decoder.process_single(); - fuzzing::memory::memory_test(res); - } - break; - case 3: - { -#ifdef FUZZER_DEBUG - printf("process_until_end_of_metadata\n"); -#endif - const bool res = decoder.process_until_end_of_metadata(); - fuzzing::memory::memory_test(res); - } - break; - case 4: - { -#ifdef FUZZER_DEBUG - printf("process_until_end_of_stream\n"); -#endif - const bool res = decoder.process_until_end_of_stream(); - fuzzing::memory::memory_test(res); - } - break; - case 5: - { -#ifdef FUZZER_DEBUG - printf("skip_single_frame\n"); -#endif - const bool res = decoder.skip_single_frame(); - fuzzing::memory::memory_test(res); - } - break; - case 6: - { -#ifdef FUZZER_DEBUG - printf("seek_absolute\n"); -#endif - const bool res = decoder.seek_absolute(ds.Get()); - fuzzing::memory::memory_test(res); - } - break; - case 7: - { -#ifdef FUZZER_DEBUG - printf("get_md5_checking\n"); -#endif - const bool res = decoder.get_md5_checking(); - fuzzing::memory::memory_test(res); - } - break; - case 8: - { -#ifdef FUZZER_DEBUG - printf("get_total_samples\n"); -#endif - const bool res = decoder.get_total_samples(); - fuzzing::memory::memory_test(res); - } - break; - case 9: - { -#ifdef FUZZER_DEBUG - printf("get_channels\n"); -#endif - const bool res = decoder.get_channels(); - fuzzing::memory::memory_test(res); - } - break; - case 10: - { -#ifdef FUZZER_DEBUG - printf("get_bits_per_sample\n"); -#endif - const bool res = decoder.get_bits_per_sample(); - fuzzing::memory::memory_test(res); - } - break; - case 11: - { -#ifdef FUZZER_DEBUG - printf("get_sample_rate\n"); -#endif - const bool res = decoder.get_sample_rate(); - fuzzing::memory::memory_test(res); - } - break; - case 12: - { -#ifdef FUZZER_DEBUG - printf("get_blocksize\n"); -#endif - const bool res = decoder.get_blocksize(); - fuzzing::memory::memory_test(res); - } - break; - } - } - } catch ( ... ) { } - -end: - { - const bool res = decoder.finish(); - fuzzing::memory::memory_test(res); - } - return 0; -} diff --git a/Engine/lib/flac/oss-fuzz/encoder.cc b/Engine/lib/flac/oss-fuzz/encoder.cc deleted file mode 100644 index 23cb39720..000000000 --- a/Engine/lib/flac/oss-fuzz/encoder.cc +++ /dev/null @@ -1,257 +0,0 @@ -/* Copyright 2019 Guido Vranken - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#include -#include - -#include "FLAC++/encoder.h" -#include "common.h" - -namespace FLAC { - namespace Encoder { - class FuzzerStream : public Stream { - private: - // fuzzing::datasource::Datasource& ds; - public: - FuzzerStream(fuzzing::datasource::Datasource&) : - Stream() { } - - ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t /* samples */, uint32_t /* current_frame */) override { - fuzzing::memory::memory_test(buffer, bytes); -#if 0 - try { - if ( ds.Get() == true ) { - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - } - } catch ( ... ) { } -#endif - return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; - } - }; - } -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - fuzzing::datasource::Datasource ds(data, size); - FLAC::Encoder::FuzzerStream encoder(ds); - - try { - const int channels = ds.Get(); - const int bps = ds.Get(); - encoder.set_channels(channels); - encoder.set_bits_per_sample(bps); - - { - const bool res = encoder.set_streamable_subset(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_ogg_serial_number(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_verify(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_compression_level(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_do_exhaustive_model_search(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_do_mid_side_stereo(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_loose_mid_side_stereo(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const auto s = ds.Get(); - const bool res = encoder.set_apodization(s.data()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_max_lpc_order(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_qlp_coeff_precision(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_do_qlp_coeff_prec_search(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_do_escape_coding(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_min_residual_partition_order(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_max_residual_partition_order(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_rice_parameter_search_dist(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_total_samples_estimate(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_blocksize(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_limit_min_bitrate(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_sample_rate(ds.Get()); - fuzzing::memory::memory_test(res); - } - - if ( size > 2 * 65535 * 4 ) { - /* With large inputs and expensive options enabled, the fuzzer can get *really* slow. - * Some combinations can make the fuzzer timeout (>60 seconds). However, while combining - * options makes the fuzzer slower, most options do not expose new code when combined. - * Therefore, combining slow options is disabled for large inputs. Any input containing - * more than 65536 * 2 samples of 32 bits each (max blocksize, stereo) is considered large - */ - encoder.set_do_qlp_coeff_prec_search(false); - encoder.set_do_exhaustive_model_search(false); - } - if ( size > 2 * 4096 * 4 + 250 ) { - /* With subdivide_tukey in the mix testing apodizations can get really expensive. Therefore - * this is disabled for inputs of more than one whole stereo block of 32-bit inputs plus a - * bit of overhead */ - encoder.set_apodization(""); - } - - { - ::FLAC__StreamEncoderInitStatus ret; - if ( ds.Get() ) { - ret = encoder.init(); - } else { - ret = encoder.init_ogg(); - } - - if ( ret != FLAC__STREAM_ENCODER_INIT_STATUS_OK ) { - goto end; - } - } - - /* These sets must fail, because encoder is already initialized */ - { - bool res = false; - res = res || encoder.set_streamable_subset(true); - res = res || encoder.set_ogg_serial_number(0); - res = res || encoder.set_verify(true); - res = res || encoder.set_compression_level(0); - res = res || encoder.set_do_exhaustive_model_search(true); - res = res || encoder.set_do_mid_side_stereo(true); - res = res || encoder.set_loose_mid_side_stereo(true); - res = res || encoder.set_apodization("test"); - res = res || encoder.set_max_lpc_order(0); - res = res || encoder.set_qlp_coeff_precision(0); - res = res || encoder.set_do_qlp_coeff_prec_search(true); - res = res || encoder.set_do_escape_coding(true); - res = res || encoder.set_min_residual_partition_order(0); - res = res || encoder.set_max_residual_partition_order(0); - res = res || encoder.set_rice_parameter_search_dist(0); - res = res || encoder.set_total_samples_estimate(0); - res = res || encoder.set_channels(channels); - res = res || encoder.set_bits_per_sample(16); - res = res || encoder.set_limit_min_bitrate(true); - res = res || encoder.set_blocksize(3021); - res = res || encoder.set_sample_rate(44100); - fuzzing::memory::memory_test(res); - if(res) - abort(); - } - - - { - /* XORing values as otherwise compiler will optimize, apparently */ - bool res = false; - res = res != encoder.get_streamable_subset(); - res = res != encoder.get_verify(); - res = res != encoder.get_do_exhaustive_model_search(); - res = res != encoder.get_do_mid_side_stereo(); - res = res != encoder.get_loose_mid_side_stereo(); - res = res != encoder.get_max_lpc_order(); - res = res != encoder.get_qlp_coeff_precision(); - res = res != encoder.get_do_qlp_coeff_prec_search(); - res = res != encoder.get_do_escape_coding(); - res = res != encoder.get_min_residual_partition_order(); - res = res != encoder.get_max_residual_partition_order(); - res = res != encoder.get_rice_parameter_search_dist(); - res = res != encoder.get_total_samples_estimate(); - res = res != encoder.get_channels(); - res = res != encoder.get_bits_per_sample(); - res = res != encoder.get_limit_min_bitrate(); - res = res != encoder.get_blocksize(); - res = res != encoder.get_sample_rate(); - fuzzing::memory::memory_test(res); - } - - - while ( ds.Get() ) { - { - auto dat = ds.GetVector(); - - if( ds.Get() ) - /* Mask */ - for (size_t i = 0; i < dat.size(); i++) - /* If we get here, bps is 4 or larger, or init will have failed */ - dat[i] = (int32_t)(((uint32_t)(dat[i]) << (32-bps)) >> (32-bps)); - - const uint32_t samples = dat.size() / channels; - if ( samples > 0 ) { - const int32_t* ptr = dat.data(); - const bool res = encoder.process_interleaved(ptr, samples); - fuzzing::memory::memory_test(res); - } - } - } - } catch ( ... ) { } - -end: - { - const bool res = encoder.finish(); - fuzzing::memory::memory_test(res); - } - return 0; -} diff --git a/Engine/lib/flac/oss-fuzz/encoder_v2.cc b/Engine/lib/flac/oss-fuzz/encoder_v2.cc deleted file mode 100644 index 64483461c..000000000 --- a/Engine/lib/flac/oss-fuzz/encoder_v2.cc +++ /dev/null @@ -1,352 +0,0 @@ -/* fuzzer_encoder_v2 - * Copyright (C) 2022-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#include -#include /* for memcpy */ -#include "FLAC/stream_encoder.h" -#include "FLAC/metadata.h" -extern "C" { -#include "share/private.h" -} -#include "common.h" - -/* This C++ fuzzer uses the FLAC and not FLAC++ because the latter lacks a few - * hidden functions like FLAC__stream_encoder_disable_constant_subframes. It - * is still processed by a C++ compiler because that's what oss-fuzz expects */ - - -static FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) -{ - (void)encoder, (void)buffer, (void)bytes, (void)samples, (void)current_frame, (void)client_data; - return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - FLAC__bool encoder_valid = true; - FLAC__StreamEncoder *encoder = 0; - FLAC__StreamEncoderState state; - FLAC__StreamMetadata *metadata[16] = {NULL}; - unsigned num_metadata = 0; - FLAC__StreamMetadata_VorbisComment_Entry VorbisCommentField; - - unsigned sample_rate, channels, bps; - uint64_t samples_estimate, samples_in_input; - unsigned compression_level, input_data_width, blocksize, max_lpc_order, qlp_coeff_precision, min_residual_partition_order, max_residual_partition_order, metadata_mask, instruction_set_disable_mask; - FLAC__bool ogg, write_to_file, interleaved; - - FLAC__bool data_bools[24]; - - /* Set alloc threshold. This check was added later and no spare config - * bytes were left, so we're reusing the sample rate as that of little - * consequence to the encoder and decoder except reading the frame header */ - - if(size < 3) - return 0; - alloc_check_threshold = data[2]; - alloc_check_counter = 0; - - /* allocate the encoder */ - if((encoder = FLAC__stream_encoder_new()) == NULL) { - fprintf(stderr, "ERROR: allocating encoder\n"); - return 1; - } - - /* Use first 20 byte for configuration */ - if(size < 20){ - FLAC__stream_encoder_delete(encoder); - return 0; - } - - /* First 3 byte for sample rate, 4th byte for channels, 5th byte for bps */ - sample_rate = ((unsigned)data[0] << 16) + ((unsigned)data[1] << 8) + data[2]; - channels = data[3]; - bps = data[4]; - - /* Number of samples estimate, format accepts 36-bit max */ - samples_estimate = ((uint64_t)data[5] << 32) + ((unsigned)data[6] << 24) + ((unsigned)data[7] << 16) + ((unsigned)data[8] << 8) + data[9]; - - compression_level = data[10]&0b1111; - input_data_width = 1 + (data[10]>>4)%4; - samples_in_input = (size-20)/input_data_width; - blocksize = ((unsigned)data[11] << 8) + (unsigned)data[12]; - max_lpc_order = data[13]; - qlp_coeff_precision = data[14]; - min_residual_partition_order = data[15] & 0b1111; - max_residual_partition_order = data[15] & 0b11110000; - metadata_mask = data[16]; - instruction_set_disable_mask = data[17]; - - /* Get array of bools from configuration */ - for(int i = 0; i < 16; i++) - data_bools[i] = data[18+i/8] & (1 << (i % 8)); - - ogg = data_bools[0]; - interleaved = data_bools[1]; - write_to_file = data_bools[13]; - - /* Set input and process parameters */ - encoder_valid &= FLAC__stream_encoder_set_verify(encoder, data_bools[2]); - encoder_valid &= FLAC__stream_encoder_set_channels(encoder, channels); - encoder_valid &= FLAC__stream_encoder_set_bits_per_sample(encoder, bps); - encoder_valid &= FLAC__stream_encoder_set_sample_rate(encoder, sample_rate); - encoder_valid &= FLAC__stream_encoder_set_total_samples_estimate(encoder, samples_estimate); - encoder_valid &= FLAC__stream_encoder_disable_instruction_set(encoder, instruction_set_disable_mask); - encoder_valid &= FLAC__stream_encoder_set_limit_min_bitrate(encoder, data_bools[15]); - - /* Set compression related parameters */ - encoder_valid &= FLAC__stream_encoder_set_compression_level(encoder, compression_level); - if(data_bools[3]){ - /* Bias towards regular compression levels */ - encoder_valid &= FLAC__stream_encoder_set_blocksize(encoder, blocksize); - encoder_valid &= FLAC__stream_encoder_set_max_lpc_order(encoder, max_lpc_order); - encoder_valid &= FLAC__stream_encoder_set_qlp_coeff_precision(encoder, qlp_coeff_precision); - encoder_valid &= FLAC__stream_encoder_set_min_residual_partition_order(encoder, min_residual_partition_order); - - /* With large inputs and expensive options enabled, the fuzzer can get *really* slow. - * Some combinations can make the fuzzer timeout (>60 seconds). However, while combining - * options makes the fuzzer slower, most options do not expose new code when combined. - * Therefore, combining slow options is disabled for large inputs. Any input containing - * more than 65536 * 2 samples (max blocksize, stereo) is considered large - */ - if(samples_in_input < (2*65536)) { - encoder_valid &= FLAC__stream_encoder_set_streamable_subset(encoder, data_bools[4]); - encoder_valid &= FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, data_bools[5]); - encoder_valid &= FLAC__stream_encoder_set_do_escape_coding(encoder, data_bools[6]); - encoder_valid &= FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, data_bools[7]); - /* Combining model search, precision search and a high residual partition order is especially - * expensive, so limit that even further. This high partition order can only be set on - * large blocksize and with streamable subset disabled */ - if(samples_in_input < (2 * 4609) || data_bools[4] || !data_bools[7] || !data_bools[5] || max_residual_partition_order < 9 || blocksize < 4609) - encoder_valid &= FLAC__stream_encoder_set_max_residual_partition_order(encoder, max_residual_partition_order); - } - else { - if(!data_bools[4]) - encoder_valid &= FLAC__stream_encoder_set_streamable_subset(encoder, false); - else if(data_bools[6]) - encoder_valid &= FLAC__stream_encoder_set_do_escape_coding(encoder, true); - else if(data_bools[7]) - encoder_valid &= FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, true); - else if(data_bools[5]) - encoder_valid &= FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, true); - } - encoder_valid &= FLAC__stream_encoder_set_do_mid_side_stereo(encoder, data_bools[8]); - encoder_valid &= FLAC__stream_encoder_set_loose_mid_side_stereo(encoder, data_bools[9]); - - encoder_valid &= FLAC__stream_encoder_disable_constant_subframes(encoder, data_bools[10]); - encoder_valid &= FLAC__stream_encoder_disable_fixed_subframes(encoder, data_bools[11]); - encoder_valid &= FLAC__stream_encoder_disable_verbatim_subframes(encoder, data_bools[12]); - } - - /* Disable alloc check if requested */ - if(encoder_valid && data_bools[14]) - alloc_check_threshold = INT32_MAX; - - /* add metadata */ - if(encoder_valid && (metadata_mask & 1)) { - if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_STREAMINFO)) == NULL) - encoder_valid = false; - else - num_metadata++; - } - if(encoder_valid && (metadata_mask & 2) && size > 21){ - if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)) == NULL) - encoder_valid = false; - else { - metadata[num_metadata++]->length = (((unsigned)data[20]) << 8) + (unsigned)(data[21]); - } - } - if(encoder_valid && (metadata_mask & 4) && size > 20){ - FLAC__byte * application_data = (FLAC__byte *)malloc(size-20); - if(0 != application_data && ((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)) == NULL)) - encoder_valid = false; - else { - memcpy(application_data,data+20,size-20); - FLAC__metadata_object_application_set_data(metadata[num_metadata++], application_data, size-20, 0); - } - } - if(encoder_valid && (metadata_mask & 8) && size > 25){ - if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE)) == NULL) - encoder_valid = false; - else { - unsigned seekpoint_spacing = ((unsigned)data[22] << 8) + data[23]; - unsigned total_samples_for_seekpoints = ((unsigned)data[24] << 8) + data[25]; - FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(metadata[num_metadata++], seekpoint_spacing, total_samples_for_seekpoints); - } - } - if(encoder_valid && (metadata_mask & 16)){ - if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)) != NULL) { - bool vorbiscomment_valid = true; - /* Append a vorbis comment */ - if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&VorbisCommentField, "COMMENTARY", "Nothing to 🤔 report")) - vorbiscomment_valid = false; - else { - if(FLAC__metadata_object_vorbiscomment_append_comment(metadata[num_metadata], VorbisCommentField, false)) { - - /* Insert a vorbis comment at the first index */ - if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&VorbisCommentField, "COMMENTARY", "Still nothing to report 🤔🤣")) - vorbiscomment_valid = false; - else - if(!FLAC__metadata_object_vorbiscomment_insert_comment(metadata[num_metadata], 0, VorbisCommentField, false)) { - free(VorbisCommentField.entry); - vorbiscomment_valid = false; - } - } - else { - free(VorbisCommentField.entry); - vorbiscomment_valid = false; - } - } - if(!vorbiscomment_valid) { - FLAC__metadata_object_delete(metadata[num_metadata]); - metadata[num_metadata] = 0; - } - else - num_metadata++; - } - } - if(encoder_valid && (metadata_mask & 32)){ - if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET)) != NULL) { - if(!FLAC__metadata_object_cuesheet_insert_blank_track(metadata[num_metadata],0)) { - FLAC__metadata_object_delete(metadata[num_metadata]); - metadata[num_metadata] = 0; - } - else { - if(!FLAC__metadata_object_cuesheet_track_insert_blank_index(metadata[num_metadata],0,0)) { - FLAC__metadata_object_delete(metadata[num_metadata]); - metadata[num_metadata] = 0; - } - else { - metadata[num_metadata]->data.cue_sheet.tracks[0].number = 1; - num_metadata++; - } - } - } - } - if(encoder_valid && (metadata_mask & 64)){ - if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE)) != NULL) { - num_metadata++; - } - } - if(encoder_valid && (metadata_mask & 128)){ - if((metadata[num_metadata] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_UNDEFINED)) != NULL) { - metadata[num_metadata]->length = 24; - metadata[num_metadata]->data.unknown.data = (FLAC__byte *)calloc(24, 1); - num_metadata++; - } - } - - if(num_metadata && encoder_valid) - encoder_valid = FLAC__stream_encoder_set_metadata(encoder, metadata, num_metadata); - - /* initialize encoder */ - if(encoder_valid) { - FLAC__StreamEncoderInitStatus init_status; - if(ogg) - if(write_to_file) - init_status = FLAC__stream_encoder_init_ogg_file(encoder, "/tmp/tmp.flac", NULL, NULL); - else - init_status = FLAC__stream_encoder_init_ogg_stream(encoder, NULL, write_callback, NULL, NULL, NULL, NULL); - else - if(write_to_file) - init_status = FLAC__stream_encoder_init_file(encoder, "/tmp/tmp.flac", NULL, NULL); - else - init_status = FLAC__stream_encoder_init_stream(encoder, write_callback, NULL, NULL, NULL, NULL); - if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { - encoder_valid = false; - } - } - - - /* send samples to encoder */ - if(encoder_valid && size > (input_data_width*channels+26)) { - unsigned samples = (size - 26)/input_data_width/channels; - const uint8_t * pcm_data = data + 26; - int32_t * data_as_int32 = (int32_t *)malloc(4*samples*channels); - if(0 != data_as_int32){ - for(unsigned i = 0; i < samples*channels; i++) - if(input_data_width == 1) - data_as_int32[i] = (int32_t)pcm_data[i] - 0x80; - else if(input_data_width == 2) - data_as_int32[i] = (((int32_t)pcm_data[i*2] << 8) + pcm_data[i*2+1]) - 0x8000; - else if(input_data_width == 3) - data_as_int32[i] = (((int32_t)pcm_data[i*3] << 16) + ((int32_t)pcm_data[i*3+1] << 8) + pcm_data[i*3+2]) - 0x800000; - else if(input_data_width == 4) - data_as_int32[i] = (((int64_t)pcm_data[i*4] << 24) + ((int32_t)pcm_data[i*4+1] << 16) + ((int32_t)pcm_data[i*4+2] << 8) + pcm_data[i*4+3]) - 0x80000000; - - /* feed samples to encoder */ - if(interleaved) - encoder_valid = FLAC__stream_encoder_process_interleaved(encoder, data_as_int32, samples); - else { - encoder_valid = FLAC__stream_encoder_process(encoder, (const int32_t*[]){data_as_int32, - data_as_int32+samples, - data_as_int32+samples*2, - data_as_int32+samples*3, - data_as_int32+samples*4, data_as_int32+samples*5, data_as_int32+samples*6, data_as_int32+samples*7}, samples); - } - free(data_as_int32); - } - else { - encoder_valid = false; - } - } - - state = FLAC__stream_encoder_get_state(encoder); - if(!(state == FLAC__STREAM_ENCODER_OK || - state == FLAC__STREAM_ENCODER_UNINITIALIZED || - state == FLAC__STREAM_ENCODER_CLIENT_ERROR || - ((state == FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR || - state == FLAC__STREAM_ENCODER_FRAMING_ERROR || - (state == FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR && - FLAC__stream_encoder_get_verify_decoder_state(encoder) == FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR)) && - alloc_check_threshold < INT32_MAX))) { - fprintf(stderr,"-----\nERROR: stream encoder returned %s\n-----\n",FLAC__stream_encoder_get_resolved_state_string(encoder)); - if(state == FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA) { - uint32_t frame_number, channel, sample_number; - FLAC__int32 expected, got; - FLAC__stream_encoder_get_verify_decoder_error_stats(encoder, NULL, &frame_number, &channel, &sample_number, &expected, &got); - fprintf(stderr,"Frame number %d\nChannel %d\n Sample number %d\nExpected value %d\nGot %d\n", frame_number, channel, sample_number, expected, got); - } - abort(); - } - - FLAC__stream_encoder_finish(encoder); - - /* now that encoding is finished, the metadata can be freed */ - for(unsigned i = 0; i < 16; i++) - if(0 != metadata[i]) - FLAC__metadata_object_delete(metadata[i]); - - FLAC__stream_encoder_delete(encoder); - - return 0; -} - diff --git a/Engine/lib/flac/oss-fuzz/fuzzer_decoder.dict b/Engine/lib/flac/oss-fuzz/fuzzer_decoder.dict deleted file mode 100644 index 0e79191ba..000000000 --- a/Engine/lib/flac/oss-fuzz/fuzzer_decoder.dict +++ /dev/null @@ -1,6 +0,0 @@ -flac_stream_marker="fLaC" -ogg_stream_marker="OggS" -flac_in_ogg_marker="\x7fFLAC" - -synccode_fixed_blocksize="\xFF\xF8" -synccode_variable_blocksize="\xFF\xF9" diff --git a/Engine/lib/flac/oss-fuzz/fuzzer_encoder.dict b/Engine/lib/flac/oss-fuzz/fuzzer_encoder.dict deleted file mode 100644 index 9662137e2..000000000 --- a/Engine/lib/flac/oss-fuzz/fuzzer_encoder.dict +++ /dev/null @@ -1,18 +0,0 @@ -"bartlett" -"bartlett_hann" -"blackman" -"blackman_harris_4term_92db" -"connes" -"flattop" -"gauss()" -"hamming" -"hann" -"kaiser_bessel" -"nuttall" -"rectangle" -"triangle" -"tukey(0)" -"partial_tukey(0)" -"punchout_tukey(0)" -"subdivide_tukey(0)" -"welch" diff --git a/Engine/lib/flac/oss-fuzz/fuzzer_reencoder.dict b/Engine/lib/flac/oss-fuzz/fuzzer_reencoder.dict deleted file mode 100644 index 0e79191ba..000000000 --- a/Engine/lib/flac/oss-fuzz/fuzzer_reencoder.dict +++ /dev/null @@ -1,6 +0,0 @@ -flac_stream_marker="fLaC" -ogg_stream_marker="OggS" -flac_in_ogg_marker="\x7fFLAC" - -synccode_fixed_blocksize="\xFF\xF8" -synccode_variable_blocksize="\xFF\xF9" diff --git a/Engine/lib/flac/oss-fuzz/fuzzer_tool_flac.dict b/Engine/lib/flac/oss-fuzz/fuzzer_tool_flac.dict deleted file mode 100644 index 3ef9be51a..000000000 --- a/Engine/lib/flac/oss-fuzz/fuzzer_tool_flac.dict +++ /dev/null @@ -1,19 +0,0 @@ -"--keep-foreign-metadata-if-present" -"--replay-gain" -"--apply-replaygain-which-is-not-lossless" - -"--force-raw-format" -"--force-aiff-format" -"--force-rf64-format" -"--force-wave64-format" -"--force-aiff-c-sowt-format" -"--force-aiff-c-none-format" -"--force-legacy-wave-format" -"--force-extensible-wave-format" - -"--endian=big" -"--sample-rate=1" -"--channels=1" -"--bps=32" -"--sign=unsigned" - diff --git a/Engine/lib/flac/oss-fuzz/fuzzing/datasource/datasource.hpp b/Engine/lib/flac/oss-fuzz/fuzzing/datasource/datasource.hpp deleted file mode 100644 index 3c9484ebb..000000000 --- a/Engine/lib/flac/oss-fuzz/fuzzing/datasource/datasource.hpp +++ /dev/null @@ -1,190 +0,0 @@ -/* Copyright 2019 Guido Vranken - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace fuzzing { -namespace datasource { - -class Base -{ - protected: - virtual std::vector get(const size_t min, const size_t max, const uint64_t id = 0) = 0; - public: - Base(void) = default; - virtual ~Base(void) = default; - - template T Get(const uint64_t id = 0); - uint16_t GetChoice(const uint64_t id = 0); - std::vector GetData(const uint64_t id, const size_t min = 0, const size_t max = 0); - template std::vector GetVector(const uint64_t id = 0); - - class OutOfData : public fuzzing::exception::FlowException { - public: - OutOfData() = default; - }; - - class DeserializationFailure : public fuzzing::exception::FlowException { - public: - DeserializationFailure() = default; - }; -}; - -#ifndef FUZZING_HEADERS_NO_IMPL -template T Base::Get(const uint64_t id) -{ - T ret; - const auto v = get(sizeof(ret), sizeof(ret), id); - memcpy(&ret, v.data(), sizeof(ret)); - return ret; -} - -template <> bool Base::Get(const uint64_t id) -{ - uint8_t ret; - const auto v = get(sizeof(ret), sizeof(ret), id); - memcpy(&ret, v.data(), sizeof(ret)); - return (ret % 2) ? true : false; -} - -template <> std::string Base::Get(const uint64_t id) -{ - auto data = GetData(id); - return std::string(data.data(), data.data() + data.size()); -} - -template <> std::vector Base::Get>(const uint64_t id) -{ - std::vector ret; - while ( true ) { - auto data = GetData(id); - ret.push_back( std::string(data.data(), data.data() + data.size()) ); - if ( Get(id) == false ) { - break; - } - } - return ret; -} - -uint16_t Base::GetChoice(const uint64_t id) -{ - return Get(id); -} - -std::vector Base::GetData(const uint64_t id, const size_t min, const size_t max) -{ - return get(min, max, id); -} - - -template <> types::String<> Base::Get>(const uint64_t id) { - const auto data = GetData(id); - types::String<> ret(data.data(), data.size()); - return ret; -} - -template <> types::Data<> Base::Get>(const uint64_t id) { - const auto data = GetData(id); - types::Data<> ret(data.data(), data.size()); - return ret; -} - -template -std::vector Base::GetVector(const uint64_t id) { - std::vector ret; - - while ( Get(id) == true ) { - ret.push_back( Get(id) ); - } - - return ret; -} -#endif - -class Datasource : public Base -{ - private: - const uint8_t* data; - const size_t size; - size_t idx; - size_t left; - std::vector get(const size_t min, const size_t max, const uint64_t id = 0) override; - - // Make copy constructor and assignment operator private. - Datasource(const Datasource &) : data(0), size(0), idx(0), left(0) {} - Datasource& operator=(const Datasource &) { return *this; } - public: - Datasource(const uint8_t* _data, const size_t _size); -}; - -#ifndef FUZZING_HEADERS_NO_IMPL -Datasource::Datasource(const uint8_t* _data, const size_t _size) : - Base(), data(_data), size(_size), idx(0), left(size) -{ -} - -std::vector Datasource::get(const size_t min, const size_t max, const uint64_t id) { - (void)id; - - uint32_t getSize; - if ( left < sizeof(getSize) ) { - throw OutOfData(); - } - memcpy(&getSize, data + idx, sizeof(getSize)); - idx += sizeof(getSize); - left -= sizeof(getSize); - - if ( getSize < min ) { - getSize = min; - } - if ( max && getSize > max ) { - getSize = max; - } - - if ( left < getSize ) { - throw OutOfData(); - } - - std::vector ret(getSize); - - if ( getSize > 0 ) { - memcpy(ret.data(), data + idx, getSize); - } - idx += getSize; - left -= getSize; - - return ret; -} -#endif - -} /* namespace datasource */ -} /* namespace fuzzing */ diff --git a/Engine/lib/flac/oss-fuzz/fuzzing/datasource/id.hpp b/Engine/lib/flac/oss-fuzz/fuzzing/datasource/id.hpp deleted file mode 100644 index 457c9840e..000000000 --- a/Engine/lib/flac/oss-fuzz/fuzzing/datasource/id.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright 2019 Guido Vranken - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include -#include - -namespace fuzzing { -namespace datasource { - -/* From: https://gist.github.com/underscorediscovery/81308642d0325fd386237cfa3b44785c */ -inline uint64_t hash_64_fnv1a(const void* key, const uint64_t len) { - - const char* data = (char*)key; - uint64_t hash = 0xcbf29ce484222325; - uint64_t prime = 0x100000001b3; - - for(uint64_t i = 0; i < len; ++i) { - uint8_t value = data[i]; - hash = hash ^ value; - hash *= prime; - } - - return hash; - -} //hash_64_fnv1a - -// FNV1a c++11 constexpr compile time hash functions, 32 and 64 bit -// str should be a null terminated string literal, value should be left out -// e.g hash_32_fnv1a_const("example") -// code license: public domain or equivalent -// post: https://notes.underscorediscovery.com/constexpr-fnv1a/ - -constexpr uint32_t val_32_const = 0x811c9dc5; -constexpr uint32_t prime_32_const = 0x1000193; -constexpr uint64_t val_64_const = 0xcbf29ce484222325; -constexpr uint64_t prime_64_const = 0x100000001b3; - - -inline constexpr uint64_t ID(const char* const str, const uint64_t value = val_64_const) noexcept { - auto ret = (str[0] == '\0') ? value : ID(&str[1], (value ^ uint64_t(str[0])) * prime_64_const); - return ret; -} - -inline constexpr std::pair IDPair(const char* const str, const uint64_t value = val_64_const) noexcept { - return {str, ID(str, value)}; -} - -using IDMap = std::map; - -} /* namespace datasource */ -} /* namespace fuzzing */ diff --git a/Engine/lib/flac/oss-fuzz/fuzzing/exception.hpp b/Engine/lib/flac/oss-fuzz/fuzzing/exception.hpp deleted file mode 100644 index d1ec580ca..000000000 --- a/Engine/lib/flac/oss-fuzz/fuzzing/exception.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright 2019 Guido Vranken - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -namespace fuzzing { -namespace exception { - -class ExceptionBase : public std::exception { - public: - ExceptionBase(void) = default; - /* typeid(T).name */ -}; - -/* Recoverable exception */ -class FlowException : public ExceptionBase { - public: - FlowException(void) : ExceptionBase() { } -}; - -/* Error in this library, should never happen */ -class LogicException : public ExceptionBase { - private: - std::string reason; - public: - LogicException(const std::string r) : ExceptionBase(), reason(r) { } - virtual const char* what(void) const throw() { - return reason.c_str(); - } -}; - -/* Error in target application */ -class TargetException : public ExceptionBase { - private: - std::string reason; - public: - TargetException(const std::string r) : ExceptionBase(), reason(r) { } - virtual const char* what(void) const throw() { - return reason.c_str(); - } -}; - -} /* namespace exception */ -} /* namespace fuzzing */ diff --git a/Engine/lib/flac/oss-fuzz/fuzzing/memory.hpp b/Engine/lib/flac/oss-fuzz/fuzzing/memory.hpp deleted file mode 100644 index b324c3670..000000000 --- a/Engine/lib/flac/oss-fuzz/fuzzing/memory.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright 2019 Guido Vranken - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#ifndef ASAN -#define ASAN 0 -#endif - -#ifndef MSAN -#define MSAN 0 -#endif - -namespace fuzzing { -namespace memory { - -#ifndef FUZZING_HEADERS_NO_IMPL -#if ASAN == 1 -extern "C" void *__asan_region_is_poisoned(const void *beg, size_t size); -#endif - -#if MSAN == 1 -extern "C" void __msan_check_mem_is_initialized(const volatile void *x, size_t size); -#endif - -void memory_test_asan(const void* data, const size_t size) -{ - (void)data; - (void)size; - -#if ASAN == 1 - if ( __asan_region_is_poisoned(data, size) != NULL ) { - abort(); - } -#endif -} - -void memory_test_msan(const void* data, const size_t size) -{ - (void)data; - (void)size; - -#if MSAN == 1 - __msan_check_mem_is_initialized(data, size); -#endif -} - -void memory_test(const void* data, const size_t size) -{ - memory_test_asan(data, size); - memory_test_msan(data, size); -} - -template -void memory_test(const T& t) -{ - (void)t; -} - -template <> -void memory_test(const std::string& s) -{ - (void)s; - -#if MSAN == 1 - memory_test(s.data(), s.size()); -#endif -} - -#endif - -} /* namespace memory */ -} /* namespace fuzzing */ diff --git a/Engine/lib/flac/oss-fuzz/fuzzing/types.hpp b/Engine/lib/flac/oss-fuzz/fuzzing/types.hpp deleted file mode 100644 index 914e64f8e..000000000 --- a/Engine/lib/flac/oss-fuzz/fuzzing/types.hpp +++ /dev/null @@ -1,158 +0,0 @@ -/* Copyright 2019 Guido Vranken - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace fuzzing { -namespace types { - -template -class Container { - private: - CoreType* InvalidAddress = (CoreType*)0x12; - - CoreType* _data = InvalidAddress; - size_t _size = 0; - -#ifndef FUZZING_HEADERS_NO_IMPL - void copy(const void* data, size_t size) { - if ( size > 0 ) { - std::memcpy(_data, data, size); - } - } - - void allocate(size_t size) { - if ( size > 0 ) { - _data = static_cast(malloc(size * sizeof(CoreType))); - } else { - _data = InvalidAddress; - } - }; - - void allocate_and_copy(const void* data, size_t size) { - allocate(size); - copy(data, size); - } - - void allocate_plus_1_and_copy(const void* data, size_t size) { - allocate(size+1); - copy(data, size); - } - - void access_hook(void) const { - if ( UseMSAN == true ) { - memory::memory_test_msan(_data, _size); - } - } - - void free(void) { - access_hook(); - - if ( _data != InvalidAddress ) { - std::free(_data); - _data = InvalidAddress; - _size = 0; - } - } - -#endif - - public: -#ifndef FUZZING_HEADERS_NO_IMPL - CoreType* data(void) { - access_hook(); - return _data; - } - - size_t size(void) const { - access_hook(); - return _size; - } -#endif - - Container(void) -#ifndef FUZZING_HEADERS_NO_IMPL - = default -#endif - ; - - Container(const void* data, const size_t size) -#ifndef FUZZING_HEADERS_NO_IMPL - { - if ( NullTerminated == false ) { - allocate_and_copy(data, size); - } else { - allocate_plus_1_and_copy(data, size); - _data[size] = 0; - } - - access_hook(); - } -#endif - ; - - template - Container(const T& t) -#ifndef FUZZING_HEADERS_NO_IMPL - { - Container(t.data(), t.size()); - } -#endif - ; - - ~Container(void) -#ifndef FUZZING_HEADERS_NO_IMPL - { - this->free(); - } -#endif - ; - - - - // The copy constructor was not originally explicitly supplied - // so it must have been incorrectly just copying the pointers. - Container(const Container &c) { - InvalidAddress = c.InvalidAddress; - allocate_and_copy(c._data, c._size); - } - - Container& operator=(Container &c) { - InvalidAddress = c.InvalidAddress; - allocate_and_copy(c._data, c._size); - } - -}; - -template using String = Container; -template using Data = Container; - -} /* namespace types */ -} /* namespace fuzzing */ diff --git a/Engine/lib/flac/oss-fuzz/metadata.cc b/Engine/lib/flac/oss-fuzz/metadata.cc deleted file mode 100644 index ad27fe955..000000000 --- a/Engine/lib/flac/oss-fuzz/metadata.cc +++ /dev/null @@ -1,526 +0,0 @@ -/* fuzzer_metadata - * Copyright (C) 2022-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#include -#include -#include /* for memcpy */ -#include -#include "FLAC++/metadata.h" -#include "common.h" - -#define CONFIG_LENGTH 2 - -#define min(x,y) (x> 4; - - if(0)//data[1] < 128) /* Use MSB as on/off */ - alloc_check_threshold = data[1]; - else - alloc_check_threshold = INT32_MAX; - alloc_check_counter = 0; - - - /* Leave at least one byte as input */ - if(command_length >= size - 1 - CONFIG_LENGTH) - command_length = size - 1 - CONFIG_LENGTH; - - /* Dump input to file */ - { - int file_to_fuzz = mkstemps(filename, 5); - - if (file_to_fuzz < 0) - abort(); - write(file_to_fuzz,data+CONFIG_LENGTH+command_length,size-CONFIG_LENGTH-command_length); - close(file_to_fuzz); - } - - run_tests_with_level_0_interface(filename); - run_tests_with_level_1_interface(filename, init_bools[1], init_bools[2], data+CONFIG_LENGTH, command_length/2); - - /* Dump input to file, to start fresh for level 2 */ - if(!init_bools[1]){ - FILE * file_to_fuzz = fopen(filename,"w"); - fwrite(data+CONFIG_LENGTH+command_length,1,size-CONFIG_LENGTH-command_length,file_to_fuzz); - fclose(file_to_fuzz); - } - - run_tests_with_level_2_interface(filename, init_bools[0], init_bools[3], data+command_length/2+CONFIG_LENGTH, command_length/2); - - remove(filename); - - return 0; -} - -static void run_tests_with_level_0_interface(char filename[]) { - FLAC::Metadata::StreamInfo streaminfo; - FLAC::Metadata::VorbisComment vorbis_comment; - FLAC::Metadata::CueSheet cue_sheet; - FLAC::Metadata::Picture picture; - - FLAC::Metadata::get_streaminfo(filename,streaminfo); - FLAC::Metadata::get_tags(filename,vorbis_comment); - FLAC::Metadata::get_cuesheet(filename,cue_sheet); - FLAC::Metadata::get_picture(filename,picture, (FLAC__StreamMetadata_Picture_Type)(1), NULL, NULL, -1, -1, -1, -1); -} - -static void run_tests_with_level_1_interface(char filename[], bool readonly, bool preservestats, const uint8_t *data, size_t size) { - FLAC::Metadata::SimpleIterator iterator; - FLAC::Metadata::Prototype *metadata_block = nullptr; - uint8_t id[4] = {0}; - - if(!iterator.is_valid()) - return; - - if(!iterator.init(filename,readonly,preservestats)) - return; - - for(size_t i = 0; i < size && iterator.status() == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; i++) { - switch(data[i] & 7) { - case 0: - iterator.get_block_type(); - iterator.get_block_offset(); - iterator.get_block_length(); - iterator.get_application_id(id); - break; - case 1: - iterator.next(); - break; - case 2: - iterator.prev(); - break; - case 3: - iterator.delete_block(data[i] & 8); - break; - case 4: - if(metadata_block != 0) { - delete metadata_block; - metadata_block = nullptr; - } - metadata_block = iterator.get_block(); - break; - case 5: - if(metadata_block != 0) - iterator.set_block(metadata_block,data[i] & 8); - break; - case 6: - if(metadata_block != 0) - iterator.insert_block_after(metadata_block, data[i] & 8); - break; - case 7: - iterator.status(); - iterator.is_last(); - iterator.is_writable(); - break; - } - } - if(metadata_block != 0) { - delete metadata_block; - metadata_block = nullptr; - } - - -} - - -static void run_tests_with_level_2_interface(char filename[], bool ogg, bool use_padding, const uint8_t *data, size_t size) { - FLAC::Metadata::Chain chain; - FLAC::Metadata::Iterator iterator; - FLAC::Metadata::Prototype *metadata_block_get = nullptr; - FLAC::Metadata::Prototype *metadata_block_transfer = nullptr; - FLAC::Metadata::Prototype *metadata_block_put = nullptr; - - if(!chain.is_valid()) - return; - - if(!chain.read(filename, ogg)) - return; - - iterator.init(chain); - - for(size_t i = 0; i < size; i++) { - switch(data[i] & 15) { - case 0: - iterator.get_block_type(); - break; - case 1: - iterator.next(); - break; - case 2: - iterator.prev(); - break; - case 3: - iterator.delete_block(data[i] & 16); - break; - case 4: - metadata_block_get = iterator.get_block(); - if(metadata_block_get != 0 && metadata_block_get->is_valid()) { - if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) { - if(metadata_block_transfer != metadata_block_get) { - delete metadata_block_transfer; - metadata_block_transfer = nullptr; - metadata_block_transfer = FLAC::Metadata::clone(metadata_block_get); - } - } - else { - metadata_block_transfer = FLAC::Metadata::clone(metadata_block_get); - } - } - delete metadata_block_get; - break; - case 5: - if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) { - metadata_block_put = FLAC::Metadata::clone(metadata_block_transfer); - if(metadata_block_put != 0 && metadata_block_put->is_valid()) { - if(!iterator.insert_block_before(metadata_block_put)) - delete metadata_block_put; - } - else - if(metadata_block_put != 0) - delete metadata_block_put; - } - break; - case 6: - if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) { - metadata_block_put = FLAC::Metadata::clone(metadata_block_transfer); - if(metadata_block_put != 0 && metadata_block_put->is_valid()) { - if(!iterator.insert_block_after(metadata_block_put)) - delete metadata_block_put; - } - else - if(metadata_block_put != 0) - delete metadata_block_put; - } - break; - case 7: - if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) { - metadata_block_put = FLAC::Metadata::clone(metadata_block_transfer); - if(metadata_block_put != 0 && metadata_block_put->is_valid()) { - if(!iterator.set_block(metadata_block_put)) - delete metadata_block_put; - } - else - if(metadata_block_put != 0) - delete metadata_block_put; - } - break; - case 8: /* Examine block */ - if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) { - switch(metadata_block_transfer->get_type()) { - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - { - uint32_t num_comments; - ::FLAC__StreamMetadata_VorbisComment_Entry entry; - FLAC::Metadata::VorbisComment::Entry entry_cpp; - FLAC::Metadata::VorbisComment * vorbiscomment = dynamic_cast(metadata_block_transfer); - const ::FLAC__StreamMetadata * metadata_c = *metadata_block_transfer; - if(vorbiscomment == 0) - abort(); - vorbiscomment->get_vendor_string(); - num_comments = vorbiscomment->get_num_comments(); - if(num_comments > 0) { - entry = metadata_c->data.vorbis_comment.comments[min(data[i]>>4,num_comments-1)]; - if(entry.entry == 0) - abort(); - if(vorbiscomment->get_comment(min(data[i]>>4,num_comments-1)).is_valid()) { - entry_cpp = vorbiscomment->get_comment(min(data[i]>>4,num_comments-1)); - if(entry_cpp.is_valid() && entry_cpp.get_field() == 0) - abort(); - vorbiscomment->find_entry_from(0,"TEST"); - } - } - - } - break; - case FLAC__METADATA_TYPE_CUESHEET: - { - uint32_t num_tracks, num_indices; - FLAC::Metadata::CueSheet * cuesheet = dynamic_cast(metadata_block_transfer); - if(cuesheet == 0 || !cuesheet->is_legal()) - break; - cuesheet->is_legal(true); /* check CDDA subset */ - cuesheet->calculate_cddb_id(); - cuesheet->get_media_catalog_number(); - cuesheet->get_lead_in(); - cuesheet->get_is_cd(); - num_tracks = cuesheet->get_num_tracks(); - if(num_tracks > 0) { - FLAC::Metadata::CueSheet::Track track = cuesheet->get_track(min(data[i]>>4,num_tracks-1)); - track.get_offset(); - track.get_number(); - track.get_isrc(); - track.get_pre_emphasis(); - num_indices = track.get_num_indices(); - if(num_indices > 0) { - FLAC__StreamMetadata_CueSheet_Index index = track.get_index(min(data[i]>>4,num_indices-1)); - (void)index; - } - } - } - break; - case FLAC__METADATA_TYPE_PICTURE: - { - char * violation = nullptr; - FLAC::Metadata::Picture * picture = dynamic_cast(metadata_block_transfer); - if(picture == 0 || !picture->is_legal((const char **)&violation)) - break; - picture->get_data(); - } - break; - default: - break; - } - - } - break; - case 9: /* Replace or add in block */ - if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) { - switch(metadata_block_transfer->get_type()) { - case FLAC__METADATA_TYPE_SEEKTABLE: - { - uint32_t num_seekpoints; - FLAC__StreamMetadata_SeekPoint seekpoint; - FLAC::Metadata::SeekTable * seektable = dynamic_cast(metadata_block_transfer); - if(seektable == 0) - break; - if(seektable->is_valid() && seektable->is_legal()) { - num_seekpoints = seektable->get_num_points(); - if(num_seekpoints > 0) { - seekpoint = seektable->get_point(min(data[i]>>5,num_seekpoints-1)); - seektable->set_point(0,seekpoint); - seektable->insert_point(min(data[i]>>5,num_seekpoints-1),seekpoint); - } - seektable->template_append_placeholders(4); - seektable->template_append_point(111111); - seektable->template_append_points((FLAC__uint64[]){222222, 333333, 444444}, 3); - seektable->template_append_spaced_points(data[i]>>5, 1234567); - seektable->template_append_spaced_points_by_samples(data[i]>>5, 2468000); - seektable->template_sort(data[i] & 16); - } - } - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - { - uint32_t num_comments; - FLAC::Metadata::VorbisComment::Entry entry; - FLAC::Metadata::VorbisComment * vorbiscomment = dynamic_cast(metadata_block_transfer); - if(vorbiscomment == 0) - break; - num_comments = vorbiscomment->get_num_comments(); - if(num_comments > 0 && entry.is_valid()) { - if(vorbiscomment->get_comment(min(data[i]>>5,num_comments-1)).is_valid()) { - entry = vorbiscomment->get_comment(min(data[i]>>5,num_comments-1)); - if(entry.is_valid()) { - vorbiscomment->replace_comment(entry,data[i] & 16); - vorbiscomment->set_comment(0,entry); - vorbiscomment->append_comment(entry); - vorbiscomment->insert_comment(0,entry); - } - } - } - } - break; - case FLAC__METADATA_TYPE_CUESHEET: - { - uint32_t num_tracks, num_indices; - FLAC::Metadata::CueSheet * cuesheet = dynamic_cast(metadata_block_transfer); - if(cuesheet == 0 || !cuesheet->is_legal()) - break; - num_tracks = cuesheet->get_num_tracks(); - if(num_tracks > 0) { - FLAC::Metadata::CueSheet::Track track = cuesheet->get_track(min(data[i]>>4,num_tracks-1)); - num_indices = track.get_num_indices(); - if(num_indices > 0) { - FLAC__StreamMetadata_CueSheet_Index index = track.get_index(min(data[i]>>4,num_indices-1)); - track.set_index(0,index); - cuesheet->insert_index(0,0,index); - cuesheet->insert_blank_index(0,0); - } - cuesheet->insert_blank_track(0); - cuesheet->insert_track(0,track); - cuesheet->resize_indices(min(data[i]>>4,num_tracks-1),data[i]>>4); - } - } - break; - case FLAC__METADATA_TYPE_PICTURE: - { - FLAC::Metadata::Picture * picture = dynamic_cast(metadata_block_transfer); - const char testtext[] = "TEST"; - if(picture == 0 || !picture->is_legal(NULL)) - break; - picture->set_description((FLAC__byte *)&testtext); - picture->set_mime_type((const char *)&testtext); - picture->set_data((FLAC__byte *)&testtext,4); - } - break; - default: - break; - } - - } - break; - case 10: /* Delete from block */ - if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) { - switch(metadata_block_transfer->get_type()) { - case FLAC__METADATA_TYPE_SEEKTABLE: - { - uint32_t num_seekpoints; - FLAC::Metadata::SeekTable * seektable = dynamic_cast(metadata_block_transfer); - if(seektable == 0) - break; - if(seektable->is_valid() && seektable->is_legal()) { - num_seekpoints = seektable->get_num_points(); - if(num_seekpoints > 0) - seektable->delete_point(min(data[i]>>4,num_seekpoints-1)); - } - } - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - { - uint32_t num_comments; - FLAC::Metadata::VorbisComment * vorbiscomment = dynamic_cast(metadata_block_transfer); - if(vorbiscomment == 0) - break; - num_comments = vorbiscomment->get_num_comments(); - if(num_comments > 0) - vorbiscomment->delete_comment(min(data[i]>>4,num_comments-1)); - vorbiscomment->remove_entry_matching("TEST"); - vorbiscomment->remove_entries_matching("TEST"); - } - break; - case FLAC__METADATA_TYPE_CUESHEET: - { - uint32_t num_tracks; - FLAC::Metadata::CueSheet * cuesheet = dynamic_cast(metadata_block_transfer); - if(cuesheet == 0 || !cuesheet->is_legal()) - break; - num_tracks = cuesheet->get_num_tracks(); - if(num_tracks > 0) { - FLAC::Metadata::CueSheet::Track track = cuesheet->get_track(min(data[i]>>4,num_tracks-1)); - if(track.get_num_indices() > 0) - cuesheet->delete_index(min(data[i]>>4,num_tracks-1),0); - cuesheet->delete_track(0); - } - } - break; - default: - break; - } - - } - break; - case 11: /* Resize block */ - if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) { - switch(metadata_block_transfer->get_type()) { - case FLAC__METADATA_TYPE_PADDING: - { - FLAC::Metadata::Padding * padding = dynamic_cast(metadata_block_transfer); - if(padding == 0) - break; - padding->set_length(data[i]>>4); - } - break; - case FLAC__METADATA_TYPE_SEEKTABLE: - { - FLAC::Metadata::SeekTable * seektable = dynamic_cast(metadata_block_transfer); - if(seektable == 0) - break; - seektable->resize_points(data[i]>>4); - } - break; - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - { - FLAC::Metadata::VorbisComment * vorbiscomment = dynamic_cast(metadata_block_transfer); - if(vorbiscomment == 0) - break; - vorbiscomment->resize_comments(data[i]>>4); - } - break; - case FLAC__METADATA_TYPE_CUESHEET: - { - uint32_t num_tracks; - FLAC::Metadata::CueSheet * cuesheet = dynamic_cast(metadata_block_transfer); - if(cuesheet == 0 || !cuesheet->is_legal()) - break; - num_tracks = cuesheet->get_num_tracks(); - if(num_tracks > 0) { - cuesheet->resize_indices(min(data[i]>>4,num_tracks-1),data[i]>>4); - } - cuesheet->resize_tracks(data[i]<<4); - } - break; - default: - break; - } - - } - break; - case 12: /* Prototype functions */ - if(metadata_block_transfer != 0 && metadata_block_transfer->is_valid()) { - const ::FLAC__StreamMetadata * metadata_compare = *metadata_block_transfer; - metadata_block_transfer->get_is_last(); - metadata_block_transfer->get_length(); - metadata_block_transfer->set_is_last(data[i] & 16); - FLAC__metadata_object_is_equal(metadata_compare, metadata_compare); - } - break; - } - } - if(metadata_block_transfer != 0) { - delete metadata_block_transfer; - metadata_block_transfer = nullptr; - } - - chain.status(); - chain.sort_padding(); - chain.merge_padding(); - - chain.check_if_tempfile_needed(!use_padding); - chain.write(use_padding); - -} diff --git a/Engine/lib/flac/oss-fuzz/reencoder.cc b/Engine/lib/flac/oss-fuzz/reencoder.cc deleted file mode 100644 index 457fbd4ce..000000000 --- a/Engine/lib/flac/oss-fuzz/reencoder.cc +++ /dev/null @@ -1,304 +0,0 @@ -/* Copyright 2019 Guido Vranken - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#include -#include - -#include "FLAC++/encoder.h" -#include "FLAC++/decoder.h" -#include "FLAC++/metadata.h" -#include "common.h" - -#define MAX_NUM_METADATA_BLOCKS 2048 - -namespace FLAC { - namespace Encoder { - class FuzzerStream : public Stream { - private: - // fuzzing::datasource::Datasource& ds; - public: - FuzzerStream(fuzzing::datasource::Datasource&) : - Stream() { } - - ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t /* samples */, uint32_t /* current_frame */) override { - fuzzing::memory::memory_test(buffer, bytes); - return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; - } - }; - } - namespace Decoder { - class FuzzerDecoder : public Stream { - private: - fuzzing::datasource::Datasource& ds; - FLAC::Encoder::FuzzerStream& encoder; - public: - FuzzerDecoder(fuzzing::datasource::Datasource& dsrc, FLAC::Encoder::FuzzerStream& encoder_arg) : - Stream(), ds(dsrc), encoder(encoder_arg) { } - - ::FLAC__StreamMetadata * metadata_blocks[MAX_NUM_METADATA_BLOCKS] = {0}; - int num_metadata_blocks = 0; - - void metadata_callback(const ::FLAC__StreamMetadata *metadata) override { - if(num_metadata_blocks < MAX_NUM_METADATA_BLOCKS) - if((metadata_blocks[num_metadata_blocks] = FLAC__metadata_object_clone(metadata)) != NULL) - num_metadata_blocks++; - } - - ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) override { - try { - const size_t maxCopySize = *bytes; - - if ( maxCopySize > 0 ) { - /* memset just to test if this overwrites anything, and triggers ASAN */ - memset(buffer, 0, maxCopySize); - } - - const auto data = ds.GetData(0); - const auto dataSize = data.size(); - const auto copySize = std::min(maxCopySize, dataSize); - - if ( copySize > 0 ) { - memcpy(buffer, data.data(), copySize); - } - - *bytes = copySize; - - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } catch ( ... ) { - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - } - } - - ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) override { - { - fuzzing::memory::memory_test(&(frame->header), sizeof(frame->header)); - fuzzing::memory::memory_test(&(frame->footer), sizeof(frame->footer)); - } - - { - const auto numChannels = get_channels(); - const size_t bytesPerChannel = frame->header.blocksize * sizeof(FLAC__int32); - for (size_t i = 0; i < numChannels; i++) { - fuzzing::memory::memory_test(buffer[i], bytesPerChannel); - } - } - - /* Data is checked, now pass it towards encoder */ - if(encoder.get_state() == FLAC__STREAM_ENCODER_OK) { - if(encoder.get_channels() != get_channels()) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - if(encoder.get_bits_per_sample() != get_bits_per_sample()) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - encoder.process(buffer, frame->header.blocksize); - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; - } - else - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - void error_callback(::FLAC__StreamDecoderErrorStatus status) override { - fuzzing::memory::memory_test(status); - } - }; - } -} - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - fuzzing::datasource::Datasource ds(data, size); - FLAC::Encoder::FuzzerStream encoder(ds); - FLAC::Decoder::FuzzerDecoder decoder(ds, encoder); - - try { - const int channels = ds.Get(); - const int bps = ds.Get(); - encoder.set_channels(channels); - encoder.set_bits_per_sample(bps); - - { - const bool res = encoder.set_streamable_subset(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_ogg_serial_number(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_verify(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_compression_level(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_do_mid_side_stereo(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_loose_mid_side_stereo(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_max_lpc_order(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_qlp_coeff_precision(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_do_escape_coding(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_min_residual_partition_order(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_max_residual_partition_order(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_total_samples_estimate(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_blocksize(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_limit_min_bitrate(ds.Get()); - fuzzing::memory::memory_test(res); - } - { - const bool res = encoder.set_sample_rate(ds.Get()); - fuzzing::memory::memory_test(res); - } - - decoder.set_metadata_respond_all(); - - { - ::FLAC__StreamDecoderInitStatus ret; - if ( ds.Get() ) { - ret = decoder.init(); - } else { - ret = decoder.init_ogg(); - } - - if ( ret != FLAC__STREAM_DECODER_INIT_STATUS_OK ) { - goto end; - } - - decoder.process_until_end_of_metadata(); - if(decoder.num_metadata_blocks > 0) - encoder.set_metadata(decoder.metadata_blocks, decoder.num_metadata_blocks); - } - - { - ::FLAC__StreamEncoderInitStatus ret; - if ( ds.Get() ) { - ret = encoder.init(); - } else { - ret = encoder.init_ogg(); - } - - if ( ret != FLAC__STREAM_ENCODER_INIT_STATUS_OK ) { - goto end; - } - } - - /* These sets must fail, because encoder is already initialized */ - { - bool res = false; - res = res || encoder.set_streamable_subset(true); - res = res || encoder.set_ogg_serial_number(0); - res = res || encoder.set_verify(true); - res = res || encoder.set_compression_level(0); - res = res || encoder.set_do_exhaustive_model_search(true); - res = res || encoder.set_do_mid_side_stereo(true); - res = res || encoder.set_loose_mid_side_stereo(true); - res = res || encoder.set_apodization("test"); - res = res || encoder.set_max_lpc_order(0); - res = res || encoder.set_qlp_coeff_precision(0); - res = res || encoder.set_do_qlp_coeff_prec_search(true); - res = res || encoder.set_do_escape_coding(true); - res = res || encoder.set_min_residual_partition_order(0); - res = res || encoder.set_max_residual_partition_order(0); - res = res || encoder.set_rice_parameter_search_dist(0); - res = res || encoder.set_total_samples_estimate(0); - res = res || encoder.set_channels(channels); - res = res || encoder.set_bits_per_sample(16); - res = res || encoder.set_limit_min_bitrate(true); - res = res || encoder.set_blocksize(3021); - res = res || encoder.set_sample_rate(44100); - fuzzing::memory::memory_test(res); - if(res) - abort(); - } - - - { - /* XORing values as otherwise compiler will optimize, apparently */ - bool res = false; - res = res != encoder.get_streamable_subset(); - res = res != encoder.get_verify(); - res = res != encoder.get_do_exhaustive_model_search(); - res = res != encoder.get_do_mid_side_stereo(); - res = res != encoder.get_loose_mid_side_stereo(); - res = res != encoder.get_max_lpc_order(); - res = res != encoder.get_qlp_coeff_precision(); - res = res != encoder.get_do_qlp_coeff_prec_search(); - res = res != encoder.get_do_escape_coding(); - res = res != encoder.get_min_residual_partition_order(); - res = res != encoder.get_max_residual_partition_order(); - res = res != encoder.get_rice_parameter_search_dist(); - res = res != encoder.get_total_samples_estimate(); - res = res != encoder.get_channels(); - res = res != encoder.get_bits_per_sample(); - res = res != encoder.get_limit_min_bitrate(); - res = res != encoder.get_blocksize(); - res = res != encoder.get_sample_rate(); - fuzzing::memory::memory_test(res); - } - - decoder.process_until_end_of_stream(); - - } catch ( ... ) { } - -end: - { - const bool res = encoder.finish(); - fuzzing::memory::memory_test(res); - } - { - const bool res = decoder.finish(); - fuzzing::memory::memory_test(res); - } - for(int i = 0; i < decoder.num_metadata_blocks; i++) - FLAC__metadata_object_delete(decoder.metadata_blocks[i]); - - return 0; -} diff --git a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/aiff-with-foreign-metadata-8bps.fuzz b/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/aiff-with-foreign-metadata-8bps.fuzz deleted file mode 100644 index 944c775a3..000000000 Binary files a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/aiff-with-foreign-metadata-8bps.fuzz and /dev/null differ diff --git a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-aiff-8bps.fuzz b/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-aiff-8bps.fuzz deleted file mode 100644 index 36fe91b58..000000000 Binary files a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-aiff-8bps.fuzz and /dev/null differ diff --git a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-wav-8bps.fuzz b/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-wav-8bps.fuzz deleted file mode 100644 index 6f4ed9c59..000000000 Binary files a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/flac-foreign-metadata-wav-8bps.fuzz and /dev/null differ diff --git a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless-ogg.fuzz b/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless-ogg.fuzz deleted file mode 100644 index e211fc6ea..000000000 Binary files a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless-ogg.fuzz and /dev/null differ diff --git a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless.fuzz b/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless.fuzz deleted file mode 100644 index 9d97430ba..000000000 Binary files a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/replaygain-which-is-not-lossless.fuzz and /dev/null differ diff --git a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/wav-with-foreign-metadata-8bps.fuzz b/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/wav-with-foreign-metadata-8bps.fuzz deleted file mode 100644 index d708a3cb8..000000000 Binary files a/Engine/lib/flac/oss-fuzz/seedcorpus/fuzzer_tool_flac/wav-with-foreign-metadata-8bps.fuzz and /dev/null differ diff --git a/Engine/lib/flac/oss-fuzz/seek.cc b/Engine/lib/flac/oss-fuzz/seek.cc deleted file mode 100644 index d3ccbe882..000000000 --- a/Engine/lib/flac/oss-fuzz/seek.cc +++ /dev/null @@ -1,195 +0,0 @@ -/* fuzzer_seek - * Copyright (C) 2022-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#include -#include /* for memcpy */ -#include "FLAC/stream_decoder.h" -#include "common.h" - -int write_abort_check_counter = -1; - -#if 0 /* set to 1 to debug */ -#define FPRINTF_DEBUG_ONLY(...) fprintf(__VA_ARGS__) -#else -#define FPRINTF_DEBUG_ONLY(...) -#endif - -#define CONFIG_LENGTH 2 - -static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data) -{ - (void)decoder, (void)frame, (void)buffer, (void)client_data; - if(write_abort_check_counter > 0) { - write_abort_check_counter--; - if(write_abort_check_counter == 0) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } else if(write_abort_check_counter == 0) - /* This must not happen: write callback called after abort is returned */ - abort(); - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus error, void *client_data) -{ - (void)decoder, (void)error, (void)client_data; -} - - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - FLAC__bool decoder_valid = true; - FLAC__StreamDecoder *decoder; - uint8_t command_length; - FLAC__bool init_bools[16], ogg; - - if(size > 2 && data[1] < 128) /* Use MSB as on/off */ - alloc_check_threshold = data[1]; - else - alloc_check_threshold = INT32_MAX; - alloc_check_counter = 0; - - write_abort_check_counter = -1; - - /* allocate the decoder */ - if((decoder = FLAC__stream_decoder_new()) == NULL) { - fprintf(stderr, "ERROR: allocating decoder\n"); - return 1; - } - - /* Use first byte for configuration, leave at least one byte of input */ - if(size < 1 + CONFIG_LENGTH){ - FLAC__stream_decoder_delete(decoder); - return 0; - } - - /* First 4 bits for configuration bools, next 4 for length of command section */ - for(int i = 0; i < 4; i++) - init_bools[i] = data[i/8] & (1 << (i % 8)); - - command_length = data[0] >> 4; - - /* Leave at least one byte as input */ - if(command_length >= size - 1 - CONFIG_LENGTH) - command_length = size - 1 - CONFIG_LENGTH; - - /* Dump decoder input to file */ - { - FILE * file_to_decode = fopen("/tmp/tmp.flac","w"); - fwrite(data+CONFIG_LENGTH+command_length,1,size-CONFIG_LENGTH-command_length,file_to_decode); - fclose(file_to_decode); - } - - ogg = init_bools[0]; - - FLAC__stream_decoder_set_md5_checking(decoder,init_bools[1]); - if(init_bools[2]) - FLAC__stream_decoder_set_metadata_respond_all(decoder); - if(init_bools[3]) - FLAC__stream_decoder_set_metadata_ignore_all(decoder); - - /* initialize decoder */ - if(decoder_valid) { - FLAC__StreamDecoderInitStatus init_status; - if(ogg) - init_status = FLAC__stream_decoder_init_ogg_file(decoder, "/tmp/tmp.flac", write_callback, NULL, error_callback, NULL); - else - init_status = FLAC__stream_decoder_init_file(decoder, "/tmp/tmp.flac", write_callback, NULL, error_callback, NULL); - if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - decoder_valid = false; - } - } - - /* Run commands */ - for(uint8_t i = 0; decoder_valid && (i < command_length); i++){ - const uint8_t * command = data+CONFIG_LENGTH+i; - uint8_t shift = 1u << (command[0] >> 3); - FLAC__uint64 seekpos; - - switch(command[0] & 15){ - case 0: - FPRINTF_DEBUG_ONLY(stderr,"end_of_stream\n"); - decoder_valid = FLAC__stream_decoder_process_until_end_of_stream(decoder); - break; - case 1: - FPRINTF_DEBUG_ONLY(stderr,"end_of_metadata\n"); - decoder_valid = FLAC__stream_decoder_process_until_end_of_metadata(decoder); - break; - case 2: - FPRINTF_DEBUG_ONLY(stderr,"single\n"); - decoder_valid = FLAC__stream_decoder_process_single(decoder); - break; - case 3: - FPRINTF_DEBUG_ONLY(stderr,"skip_single\n"); - decoder_valid = FLAC__stream_decoder_skip_single_frame(decoder); - break; - case 4: - FPRINTF_DEBUG_ONLY(stderr,"reset\n"); - decoder_valid = FLAC__stream_decoder_reset(decoder); - break; - case 5: - FPRINTF_DEBUG_ONLY(stderr,"flush\n"); - decoder_valid = FLAC__stream_decoder_flush(decoder); - break; - case 6: - case 14: - shift = 1u << (command[0] >> 3); - FPRINTF_DEBUG_ONLY(stderr,"seek short %hhu\n",shift); - decoder_valid = FLAC__stream_decoder_seek_absolute(decoder,shift); - break; - case 7: - if(i+8 >= command_length) /* Not enough data available to do this */ - break; - seekpos = ((FLAC__uint64)command[1] << 56) + - ((FLAC__uint64)command[2] << 48) + - ((FLAC__uint64)command[3] << 40) + - ((FLAC__uint64)command[4] << 32) + - ((FLAC__uint64)command[5] << 24) + - ((FLAC__uint64)command[6] << 16) + - ((FLAC__uint64)command[7] << 8) + - command[8]; - i+=8; - FPRINTF_DEBUG_ONLY(stderr,"seek long %lu\n",seekpos); - decoder_valid = FLAC__stream_decoder_seek_absolute(decoder,seekpos); - break; - case 8: - /* Set abort on write callback */ - write_abort_check_counter = (command[0] >> 4) + 1; - break; - } - } - - FLAC__stream_decoder_finish(decoder); - - FLAC__stream_decoder_delete(decoder); - - return 0; -} - diff --git a/Engine/lib/flac/oss-fuzz/tool_flac.c b/Engine/lib/flac/oss-fuzz/tool_flac.c deleted file mode 100644 index ce10a0720..000000000 --- a/Engine/lib/flac/oss-fuzz/tool_flac.c +++ /dev/null @@ -1,117 +0,0 @@ -/* fuzzer_tool_flac - * Copyright (C) 2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#include -#include /* for memcpy */ -#define FUZZ_TOOL_FLAC -#define fprintf(...) -#define printf(...) -#include "../src/flac/main.c" -#include "common.h" - -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); - -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - size_t size_left = size; - size_t arglen; - char * argv[67]; - char exename[] = "flac"; - char filename[] = "/tmp/fuzzXXXXXX"; - int numarg = 0, maxarg; - int file_to_fuzz; - int tmp_stdout, tmp_stdin; - fpos_t pos_stdout; - bool use_stdin = false; - - /* reset global vars */ - flac__utils_verbosity_ = 0; - share__opterr = 0; - share__optind = 0; - - if(size < 2) - return 0; - - maxarg = data[0] & 63; - use_stdin = data[0] & 64; - size_left--; - - argv[0] = exename; - numarg++; - - /* Check whether input is zero delimited */ - while((arglen = strnlen((char *)data+(size-size_left),size_left)) < size_left && numarg < maxarg) { - argv[numarg++] = (char *)data+(size-size_left); - size_left -= arglen + 1; - } - - file_to_fuzz = mkstemp(filename); - - if (file_to_fuzz < 0) - abort(); - write(file_to_fuzz,data+(size-size_left),size_left); - close(file_to_fuzz); - - /* redirect stdout */ - fflush(stdout); - fgetpos(stdout,&pos_stdout); - tmp_stdout = dup(fileno(stdout)); - freopen("/dev/null","w",stdout); - - /* redirect stdin */ - tmp_stdin = dup(fileno(stdin)); - - if(use_stdin) - freopen(filename,"r",stdin); - else { - freopen("/dev/null","r",stdin); - argv[numarg++] = filename; - } - - main_to_fuzz(numarg,argv); - - /* restore stdout */ - fflush(stdout); - dup2(tmp_stdout, fileno(stdout)); - close(tmp_stdout); - clearerr(stdout); - fsetpos(stdout,&pos_stdout); - - /* restore stdin */ - dup2(tmp_stdin, fileno(stdin)); - close(tmp_stdin); - clearerr(stdin); - - unlink(filename); - - return 0; -} - diff --git a/Engine/lib/flac/oss-fuzz/tool_metaflac.c b/Engine/lib/flac/oss-fuzz/tool_metaflac.c deleted file mode 100644 index a6fafa26b..000000000 --- a/Engine/lib/flac/oss-fuzz/tool_metaflac.c +++ /dev/null @@ -1,136 +0,0 @@ -/* fuzzer_tool_flac - * Copyright (C) 2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#include -#include -#include /* for memcpy */ -#define FUZZ_TOOL_METAFLAC -#define fprintf(...) -#define printf(...) -#include "../src/metaflac/main.c" -#include "common.h" - -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); - -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - size_t size_left = size; - size_t arglen; - char * argv[64]; - char exename[] = "metaflac"; - char filename[] = "/tmp/fuzzXXXXXX"; - char filename_stdin[] = "/tmp/fuzzXXXXXX"; - int numarg = 0, maxarg; - int file_to_fuzz; - int tmp_stdout, tmp_stdin; - fpos_t pos_stdout; - bool use_stdin = false; - - share__opterr = 0; - share__optind = 0; - - - if(size < 2) - return 0; - - maxarg = data[0] & 15; - use_stdin = data[0] & 16; - size_left--; - - argv[0] = exename; - numarg++; - - /* Check whether input is zero delimited */ - while((arglen = strnlen((char *)data+(size-size_left),size_left)) < size_left && numarg < maxarg) { - argv[numarg++] = (char *)data+(size-size_left); - size_left -= arglen + 1; - } - - /* Create file to feed directly */ - file_to_fuzz = mkstemp(filename); - if (file_to_fuzz < 0) - abort(); - if(use_stdin) { - write(file_to_fuzz,data+(size-size_left),size_left/2); - size_left -= size_left/2; - } - else - write(file_to_fuzz,data+(size-size_left),size_left); - close(file_to_fuzz); - - argv[numarg++] = filename; - - /* Create file to feed to stdin */ - if(use_stdin) { - file_to_fuzz = mkstemp(filename_stdin); - if (file_to_fuzz < 0) - abort(); - write(file_to_fuzz,data+(size-size_left),size_left); - close(file_to_fuzz); - } - - /* redirect stdout */ - fflush(stdout); - fgetpos(stdout,&pos_stdout); - tmp_stdout = dup(fileno(stdout)); - freopen("/dev/null","w",stdout); - - /* redirect stdin */ - tmp_stdin = dup(fileno(stdin)); - if(use_stdin) - freopen(filename_stdin,"r",stdin); - else { - freopen("/dev/null","r",stdin); - argv[numarg++] = filename; - } - - main_to_fuzz(numarg,argv); - - /* restore stdout */ - fflush(stdout); - dup2(tmp_stdout, fileno(stdout)); - close(tmp_stdout); - clearerr(stdout); - fsetpos(stdout,&pos_stdout); - - /* restore stdin */ - dup2(tmp_stdin, fileno(stdin)); - close(tmp_stdin); - clearerr(stdin); - - unlink(filename); - - if(use_stdin) - unlink(filename_stdin); - - return 0; -} - diff --git a/Engine/lib/flac/src/CMakeLists.txt b/Engine/lib/flac/src/CMakeLists.txt deleted file mode 100644 index 262feeadd..000000000 --- a/Engine/lib/flac/src/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.11) - -option(ENABLE_64_BIT_WORDS "Set FLAC__BYTES_PER_WORD to 8, for 64-bit machines. For 32-bit machines, turning this off might give a tiny speed improvement" ON) -option(BUILD_UTILS "Build utils" OFF) - -add_subdirectory("libFLAC") -if(BUILD_CXXLIBS) - add_subdirectory("libFLAC++") -endif() -add_subdirectory("share/replaygain_analysis") -add_subdirectory("share/replaygain_synthesis") -add_subdirectory("share/getopt") -add_subdirectory("share/utf8") -add_subdirectory("share/grabbag") - -if(BUILD_PROGRAMS) - add_subdirectory("flac") - add_subdirectory("metaflac") -endif() -if(BUILD_UTILS) - add_subdirectory(utils/flacdiff) - if(WIN32) - add_subdirectory(utils/flactimer) - endif() -endif() - -if(BUILD_TESTING) - add_subdirectory("test_libs_common") - add_subdirectory("test_libFLAC") - if(BUILD_CXXLIBS) - add_subdirectory("test_libFLAC++") - endif() - add_subdirectory("test_grabbag") - add_subdirectory("test_seeking") - add_subdirectory("test_streams") -endif() diff --git a/Engine/lib/flac/src/Makefile.am b/Engine/lib/flac/src/Makefile.am deleted file mode 100644 index e9d60a9bf..000000000 --- a/Engine/lib/flac/src/Makefile.am +++ /dev/null @@ -1,40 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -if FLaC__WITH_CPPLIBS -CPPLIBS_DIRS = libFLAC++ test_libFLAC++ -endif - -if FLaC__WITH_PROGRAMS -PROGRAMS_DIRS = flac metaflac -endif - -SUBDIRS = \ - libFLAC \ - share \ - $(PROGRAMS_DIRS) \ - test_grabbag \ - test_libs_common \ - test_libFLAC \ - test_seeking \ - test_streams \ - utils \ - $(CPPLIBS_DIRS) - -EXTRA_DIST = \ - CMakeLists.txt diff --git a/Engine/lib/flac/src/flac/CMakeLists.txt b/Engine/lib/flac/src/flac/CMakeLists.txt deleted file mode 100644 index da7ce8de9..000000000 --- a/Engine/lib/flac/src/flac/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H) -check_include_file("termios.h" HAVE_TERMIOS_H) - -add_executable(flacapp - analyze.c - decode.c - encode.c - foreign_metadata.c - main.c - local_string_utils.c - utils.c - vorbiscomment.c - version.rc - $<$:../../include/share/win_utf8_io.h> - $<$:../share/win_utf8_io/win_utf8_io.c>) -set_property(TARGET flacapp PROPERTY RUNTIME_OUTPUT_NAME flac) -set_property(TARGET flacapp PROPERTY PROJECT_LABEL "flac") -target_link_libraries(flacapp - FLAC - getopt - replaygain_synthesis - utf8) - -install(TARGETS flacapp EXPORT targets - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") diff --git a/Engine/lib/flac/src/flac/Makefile.am b/Engine/lib/flac/src/flac/Makefile.am deleted file mode 100644 index 279a7cb9b..000000000 --- a/Engine/lib/flac/src/flac/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -# flac - Command-line FLAC encoder/decoder -# Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -if OS_IS_WINDOWS -win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la -if HAVE_WINDRES -flac_DEPENDENCIES = version.o -windows_resource_link = -Wl,version.o -endif -endif - -bin_PROGRAMS = flac - -AM_CFLAGS = @OGG_CFLAGS@ -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -EXTRA_DIST = \ - CMakeLists.txt \ - iffscan.c \ - version.rc - -flac_SOURCES = \ - analyze.c \ - decode.c \ - encode.c \ - foreign_metadata.c \ - main.c \ - local_string_utils.c \ - utils.c \ - vorbiscomment.c \ - analyze.h \ - decode.h \ - encode.h \ - foreign_metadata.h \ - local_string_utils.h \ - utils.h \ - vorbiscomment.h - -flac_LDADD = \ - $(top_builddir)/src/share/utf8/libutf8.la \ - $(top_builddir)/src/share/grabbag/libgrabbag.la \ - $(top_builddir)/src/share/getopt/libgetopt.la \ - $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ - $(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - $(win_utf8_lib) \ - @LTLIBICONV@ \ - -lm - -flac_LDFLAGS = $(AM_LDFLAGS) $(windows_resource_link) - -CLEANFILES = flac.exe - -.rc.o: - $(RC) $(AM_CPPFLAGS) $< $@ diff --git a/Engine/lib/flac/src/flac/analyze.c b/Engine/lib/flac/src/flac/analyze.c deleted file mode 100644 index 0a85565e8..000000000 --- a/Engine/lib/flac/src/flac/analyze.c +++ /dev/null @@ -1,252 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include - -#include "FLAC/all.h" -#include "analyze.h" - -#include "share/compat.h" - -typedef struct { - FLAC__int32 residual; - uint32_t count; -} pair_t; - -typedef struct { - pair_t buckets[FLAC__MAX_BLOCK_SIZE]; - int peak_index; - uint32_t nbuckets; - uint32_t nsamples; - double sum, sos; - double variance; - double mean; - double stddev; -} subframe_stats_t; - -static subframe_stats_t all_; - -static void init_stats(subframe_stats_t *stats); -static void update_stats(subframe_stats_t *stats, FLAC__int32 residual, uint32_t incr); -static void compute_stats(subframe_stats_t *stats); -static FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename); - -void flac__analyze_init(analysis_options aopts) -{ - if(aopts.do_residual_gnuplot) { - init_stats(&all_); - } -} - -void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, FLAC__uint64 frame_bytes, analysis_options aopts, FILE *fout) -{ - const uint32_t channels = frame->header.channels; - char outfilename[1024]; - subframe_stats_t stats; - uint32_t i, channel, partitions; - - /* do the human-readable part first */ - fprintf(fout, "frame=%u\toffset=%" PRIu64 "\tbits=%" PRIu64 "\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]); - for(channel = 0; channel < channels; channel++) { - const FLAC__Subframe *subframe = frame->subframes+channel; - const FLAC__bool is_rice2 = subframe->data.fixed.entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2; - const uint32_t pesc = is_rice2? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; - fprintf(fout, "\tsubframe=%u\twasted_bits=%u\ttype=%s", channel, subframe->wasted_bits, FLAC__SubframeTypeString[subframe->type]); - switch(subframe->type) { - case FLAC__SUBFRAME_TYPE_CONSTANT: - fprintf(fout, "\tvalue=%" PRId64 "\n", subframe->data.constant.value); - break; - case FLAC__SUBFRAME_TYPE_FIXED: - FLAC__ASSERT(subframe->data.fixed.entropy_coding_method.type <= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2); - fprintf(fout, "\torder=%u\tresidual_type=%s\tpartition_order=%u\n", subframe->data.fixed.order, is_rice2? "RICE2":"RICE", subframe->data.fixed.entropy_coding_method.data.partitioned_rice.order); - for(i = 0; i < subframe->data.fixed.order; i++) - fprintf(fout, "\t\twarmup[%u]=%" PRId64 "\n", i, subframe->data.fixed.warmup[i]); - partitions = (1u << subframe->data.fixed.entropy_coding_method.data.partitioned_rice.order); - for(i = 0; i < partitions; i++) { - uint32_t parameter = subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents->parameters[i]; - if(parameter == pesc) - fprintf(fout, "\t\tparameter[%u]=ESCAPE, raw_bits=%u\n", i, subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents->raw_bits[i]); - else - fprintf(fout, "\t\tparameter[%u]=%u\n", i, parameter); - } - if(aopts.do_residual_text) { - for(i = 0; i < frame->header.blocksize-subframe->data.fixed.order; i++) - fprintf(fout, "\t\tresidual[%u]=%d\n", i, subframe->data.fixed.residual[i]); - } - break; - case FLAC__SUBFRAME_TYPE_LPC: - FLAC__ASSERT(subframe->data.lpc.entropy_coding_method.type <= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2); - fprintf(fout, "\torder=%u\tqlp_coeff_precision=%u\tquantization_level=%d\tresidual_type=%s\tpartition_order=%u\n", subframe->data.lpc.order, subframe->data.lpc.qlp_coeff_precision, subframe->data.lpc.quantization_level, is_rice2? "RICE2":"RICE", subframe->data.lpc.entropy_coding_method.data.partitioned_rice.order); - for(i = 0; i < subframe->data.lpc.order; i++) - fprintf(fout, "\t\tqlp_coeff[%u]=%d\n", i, subframe->data.lpc.qlp_coeff[i]); - for(i = 0; i < subframe->data.lpc.order; i++) - fprintf(fout, "\t\twarmup[%u]=%" PRId64 "\n", i, subframe->data.lpc.warmup[i]); - partitions = (1u << subframe->data.lpc.entropy_coding_method.data.partitioned_rice.order); - for(i = 0; i < partitions; i++) { - uint32_t parameter = subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents->parameters[i]; - if(parameter == pesc) - fprintf(fout, "\t\tparameter[%u]=ESCAPE, raw_bits=%u\n", i, subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents->raw_bits[i]); - else - fprintf(fout, "\t\tparameter[%u]=%u\n", i, parameter); - } - if(aopts.do_residual_text) { - for(i = 0; i < frame->header.blocksize-subframe->data.lpc.order; i++) - fprintf(fout, "\t\tresidual[%u]=%d\n", i, subframe->data.lpc.residual[i]); - } - break; - case FLAC__SUBFRAME_TYPE_VERBATIM: - fprintf(fout, "\n"); - break; - } - } - - /* now do the residual distributions if requested */ - if(aopts.do_residual_gnuplot) { - for(channel = 0; channel < channels; channel++) { - const FLAC__Subframe *subframe = frame->subframes+channel; - uint32_t residual_samples; - - init_stats(&stats); - - switch(subframe->type) { - case FLAC__SUBFRAME_TYPE_FIXED: - residual_samples = frame->header.blocksize - subframe->data.fixed.order; - for(i = 0; i < residual_samples; i++) - update_stats(&stats, subframe->data.fixed.residual[i], 1); - break; - case FLAC__SUBFRAME_TYPE_LPC: - residual_samples = frame->header.blocksize - subframe->data.lpc.order; - for(i = 0; i < residual_samples; i++) - update_stats(&stats, subframe->data.lpc.residual[i], 1); - break; - default: - break; - } - - /* update all_ */ - for(i = 0; i < stats.nbuckets; i++) { - update_stats(&all_, stats.buckets[i].residual, stats.buckets[i].count); - } - - if(stats.nsamples > 0) { - /* write the subframe */ - flac_snprintf(outfilename, sizeof (outfilename), "f%06u.s%u.gp", frame_number, channel); - compute_stats(&stats); - - (void)dump_stats(&stats, outfilename); - } - } - } -} - -void flac__analyze_finish(analysis_options aopts) -{ - if(aopts.do_residual_gnuplot && all_.nsamples > 0) { - compute_stats(&all_); - (void)dump_stats(&all_, "all"); - } -} - -void init_stats(subframe_stats_t *stats) -{ - stats->peak_index = -1; - stats->nbuckets = 0; - stats->nsamples = 0; - stats->sum = 0.0; - stats->sos = 0.0; -} - -void update_stats(subframe_stats_t *stats, FLAC__int32 residual, uint32_t incr) -{ - uint32_t i; - const double r = (double)residual, a = r*incr; - - stats->nsamples += incr; - stats->sum += a; - stats->sos += (a*r); - - for(i = 0; i < stats->nbuckets; i++) { - if(stats->buckets[i].residual == residual) { - stats->buckets[i].count += incr; - goto find_peak; - } - } - /* not found, make a new bucket */ - i = stats->nbuckets; - stats->buckets[i].residual = residual; - stats->buckets[i].count = incr; - stats->nbuckets++; -find_peak: - if(stats->peak_index < 0 || stats->buckets[i].count > stats->buckets[stats->peak_index].count) - stats->peak_index = i; -} - -void compute_stats(subframe_stats_t *stats) -{ - stats->mean = stats->sum / (double)stats->nsamples; - stats->variance = (stats->sos - (stats->sum * stats->sum / stats->nsamples)) / stats->nsamples; - stats->stddev = sqrt(stats->variance); -} - -FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename) -{ - FILE *outfile; - uint32_t i; - const double m = stats->mean; - const double s1 = stats->stddev, s2 = s1*2, s3 = s1*3, s4 = s1*4, s5 = s1*5, s6 = s1*6; - const double p = stats->buckets[stats->peak_index].count; - - outfile = flac_fopen(filename, "w"); - - if(0 == outfile) { - fprintf(stderr, "ERROR opening %s: %s\n", filename, strerror(errno)); - return false; - } - - fprintf(outfile, "plot '-' title 'PDF', '-' title 'mean' with impulses, '-' title '1-stddev' with histeps, '-' title '2-stddev' with histeps, '-' title '3-stddev' with histeps, '-' title '4-stddev' with histeps, '-' title '5-stddev' with histeps, '-' title '6-stddev' with histeps\n"); - - for(i = 0; i < stats->nbuckets; i++) { - fprintf(outfile, "%d %u\n", stats->buckets[i].residual, stats->buckets[i].count); - } - fprintf(outfile, "e\n"); - - fprintf(outfile, "%f %f\ne\n", stats->mean, p); - fprintf(outfile, "%f %f\n%f %f\ne\n", m-s1, p*0.8, m+s1, p*0.8); - fprintf(outfile, "%f %f\n%f %f\ne\n", m-s2, p*0.7, m+s2, p*0.7); - fprintf(outfile, "%f %f\n%f %f\ne\n", m-s3, p*0.6, m+s3, p*0.6); - fprintf(outfile, "%f %f\n%f %f\ne\n", m-s4, p*0.5, m+s4, p*0.5); - fprintf(outfile, "%f %f\n%f %f\ne\n", m-s5, p*0.4, m+s5, p*0.4); - fprintf(outfile, "%f %f\n%f %f\ne\n", m-s6, p*0.3, m+s6, p*0.3); - - fprintf(outfile, "pause -1 'waiting...'\n"); - - fclose(outfile); -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - unlink(filename); -#endif - return true; -} diff --git a/Engine/lib/flac/src/flac/analyze.h b/Engine/lib/flac/src/flac/analyze.h deleted file mode 100644 index ce07b145e..000000000 --- a/Engine/lib/flac/src/flac/analyze.h +++ /dev/null @@ -1,32 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef flac__analyze_h -#define flac__analyze_h - -typedef struct { - FLAC__bool do_residual_text; - FLAC__bool do_residual_gnuplot; -} analysis_options; - -void flac__analyze_init(analysis_options aopts); -void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, FLAC__uint64 frame_bytes, analysis_options aopts, FILE *fout); -void flac__analyze_finish(analysis_options aopts); - -#endif diff --git a/Engine/lib/flac/src/flac/decode.c b/Engine/lib/flac/src/flac/decode.c deleted file mode 100644 index 90f7a6c86..000000000 --- a/Engine/lib/flac/src/flac/decode.c +++ /dev/null @@ -1,1674 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include /* for floor() */ -#include /* for FILE etc. */ -#include /* for strcmp(), strerror() */ -#include /* for clock() */ -#include "FLAC/all.h" -#include "share/grabbag.h" -#include "share/replaygain_synthesis.h" -#include "share/compat.h" -#include "decode.h" - -typedef struct { -#if FLAC__HAS_OGG - FLAC__bool is_ogg; - FLAC__bool use_first_serial_number; - long serial_number; -#endif - - FileFormat format; - FileSubFormat subformat; - FLAC__bool treat_warnings_as_errors; - FLAC__bool continue_through_decode_errors; - FLAC__bool channel_map_none; - FLAC__bool relaxed_foreign_metadata_handling; - - struct { - replaygain_synthesis_spec_t spec; - FLAC__bool apply; /* 'spec.apply' is just a request; this 'apply' means we actually parsed the RG tags and are ready to go */ - double scale; - DitherContext dither_context; - } replaygain; - - FLAC__bool test_only; - FLAC__bool analysis_mode; - analysis_options aopts; - utils__SkipUntilSpecification *skip_specification; - utils__SkipUntilSpecification *until_specification; /* a canonicalized value of 0 mean end-of-stream (i.e. --until=-0) */ - utils__CueSpecification *cue_specification; - - const char *inbasefilename; - const char *infilename; - const char *outfilename; - - FLAC__uint64 samples_processed; - uint32_t frame_counter; - FLAC__bool abort_flag; - FLAC__bool aborting_due_to_until; /* true if we intentionally abort decoding prematurely because we hit the --until point */ - FLAC__bool aborting_due_to_unparseable; /* true if we abort decoding because we hit an unparseable frame */ - FLAC__bool error_callback_suppress_messages; /* turn on to prevent repeating messages from the error callback */ - FLAC__bool warn_user_about_foreign_metadata; /* to prevent more than one warning message per file */ - - FLAC__bool iff_headers_need_fixup; - - FLAC__bool is_big_endian; - FLAC__bool is_unsigned_samples; - FLAC__bool got_stream_info; - FLAC__bool has_md5sum; - FLAC__uint64 total_samples; - uint32_t bps; - uint32_t channels; - uint32_t sample_rate; - FLAC__uint32 channel_mask; - - /* these are used only in analyze mode */ - FLAC__uint64 decode_position; - - FLAC__StreamDecoder *decoder; - - FILE *fout; - - foreign_metadata_t *foreign_metadata; /* NULL unless --keep-foreign-metadata requested */ - FLAC__off_t fm_offset1, fm_offset2, fm_offset3; - - clock_t old_clock_t; -} DecoderSession; - - -static FLAC__bool is_big_endian_host_; - - -/* - * local routines - */ -static FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool use_first_serial_number, long serial_number, FileFormat format, FileSubFormat subformat, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, FLAC__bool relaxed_foreign_metadata_handling, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, foreign_metadata_t *foreign_metadata, const char *infilename, const char *outfilename); -static void DecoderSession_destroy(DecoderSession *d, FLAC__bool error_occurred); -static FLAC__bool DecoderSession_init_decoder(DecoderSession *d, const char *infilename); -static FLAC__bool DecoderSession_process(DecoderSession *d); -static int DecoderSession_finish_ok(DecoderSession *d); -static int DecoderSession_finish_error(DecoderSession *d); -static FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input); -static FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uint64 samples); -static FLAC__bool write_riff_wave_fmt_chunk_body(FILE *f, FLAC__bool is_waveformatextensible, uint32_t bps, uint32_t channels, uint32_t sample_rate, FLAC__uint32 channel_mask); -static FLAC__bool write_aiff_form_comm_chunk(FILE *f, FLAC__uint64 samples, uint32_t bps, uint32_t channels, uint32_t sample_rate, FileFormat format, FileSubFormat subformat, FLAC__uint32 comm_length); -static FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 val); -static FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 val); -static FLAC__bool write_little_endian_uint64(FILE *f, FLAC__uint64 val); -static FLAC__bool write_big_endian_uint16(FILE *f, FLAC__uint16 val); -static FLAC__bool write_big_endian_uint32(FILE *f, FLAC__uint32 val); -static FLAC__bool write_sane_extended(FILE *f, uint32_t val); -static FLAC__bool fixup_iff_headers(DecoderSession *d); -static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); -static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); -static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); -static void print_error_with_init_status(const DecoderSession *d, const char *message, FLAC__StreamDecoderInitStatus init_status); -static void print_error_with_state(const DecoderSession *d, const char *message); -static void print_stats(const DecoderSession *decoder_session); - - -/* - * public routines - */ -int flac__decode_file(const char *infilename, const char *outfilename, FLAC__bool analysis_mode, analysis_options aopts, decode_options_t options) -{ - DecoderSession decoder_session; - - FLAC__ASSERT( - options.format == FORMAT_WAVE || - options.format == FORMAT_WAVE64 || - options.format == FORMAT_RF64 || - options.format == FORMAT_AIFF || - options.format == FORMAT_AIFF_C || - options.format == FORMAT_RAW - ); - - if(options.format == FORMAT_RAW) { - decoder_session.is_big_endian = options.format_options.raw.is_big_endian; - decoder_session.is_unsigned_samples = options.format_options.raw.is_unsigned_samples; - } - - if(! - DecoderSession_construct( - &decoder_session, -#if FLAC__HAS_OGG - options.is_ogg, - options.use_first_serial_number, - options.serial_number, -#else - /*is_ogg=*/false, - /*use_first_serial_number=*/false, - /*serial_number=*/0, -#endif - options.format, - options.force_subformat, - options.treat_warnings_as_errors, - options.continue_through_decode_errors, - options.channel_map_none, - options.relaxed_foreign_metadata_handling, - options.replaygain_synthesis_spec, - analysis_mode, - aopts, - &options.skip_specification, - &options.until_specification, - options.has_cue_specification? &options.cue_specification : 0, - options.format == FORMAT_RAW? NULL : options.format_options.iff.foreign_metadata, - infilename, - outfilename - ) - ) - return 1; - - stats_new_file(); - if(!DecoderSession_init_decoder(&decoder_session, infilename)) - return DecoderSession_finish_error(&decoder_session); - - if(!DecoderSession_process(&decoder_session)) - return DecoderSession_finish_error(&decoder_session); - - return DecoderSession_finish_ok(&decoder_session); -} - -FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool use_first_serial_number, long serial_number, FileFormat format, FileSubFormat subformat, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, FLAC__bool relaxed_foreign_metadata_handling, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, foreign_metadata_t *foreign_metadata, const char *infilename, const char *outfilename) -{ -#if FLAC__HAS_OGG - d->is_ogg = is_ogg; - d->use_first_serial_number = use_first_serial_number; - d->serial_number = serial_number; -#else - (void)is_ogg; - (void)use_first_serial_number; - (void)serial_number; -#endif - - d->format = format; - d->subformat = subformat; - d->treat_warnings_as_errors = treat_warnings_as_errors; - d->continue_through_decode_errors = continue_through_decode_errors; - d->channel_map_none = channel_map_none; - d->relaxed_foreign_metadata_handling = relaxed_foreign_metadata_handling; - d->replaygain.spec = replaygain_synthesis_spec; - d->replaygain.apply = false; - d->replaygain.scale = 0.0; - /* d->replaygain.dither_context gets initialized later once we know the sample resolution */ - d->test_only = (0 == outfilename); - d->analysis_mode = analysis_mode; - d->aopts = aopts; - d->skip_specification = skip_specification; - d->until_specification = until_specification; - d->cue_specification = cue_specification; - - d->inbasefilename = grabbag__file_get_basename(infilename); - d->infilename = infilename; - d->outfilename = outfilename; - - d->samples_processed = 0; - d->frame_counter = 0; - d->abort_flag = false; - d->aborting_due_to_until = false; - d->aborting_due_to_unparseable = false; - d->error_callback_suppress_messages = false; - if(relaxed_foreign_metadata_handling) - d->warn_user_about_foreign_metadata = false; - else - d->warn_user_about_foreign_metadata = true; - - d->iff_headers_need_fixup = false; - - d->total_samples = 0; - d->got_stream_info = false; - d->has_md5sum = false; - d->bps = 0; - d->channels = 0; - d->sample_rate = UINT32_MAX; - d->channel_mask = 0; - - d->decode_position = 0; - - d->decoder = 0; - - d->fout = 0; /* initialized with an open file later if necessary */ - - d->foreign_metadata = foreign_metadata; - - d->old_clock_t = 0; - - FLAC__ASSERT(!(d->test_only && d->analysis_mode)); - - if(!d->test_only) { - if(0 == strcmp(outfilename, "-")) { - d->fout = grabbag__file_get_binary_stdout(); - } - else { - if(0 == (d->fout = flac_fopen(outfilename, "wb"))) { - flac__utils_printf(stderr, 1, "%s: ERROR: can't open output file %s: %s\n", d->inbasefilename, outfilename, strerror(errno)); - DecoderSession_destroy(d, /*error_occurred=*/true); - return false; - } - } - } - - if(analysis_mode) - flac__analyze_init(aopts); - - return true; -} - -void DecoderSession_destroy(DecoderSession *d, FLAC__bool error_occurred) -{ - if(0 != d->fout && d->fout != stdout) { -#if defined _WIN32 && !defined __CYGWIN__ - if(!error_occurred) { - FLAC__off_t written_size = ftello(d->fout); - if(written_size > 0) { - HANDLE fh = CreateFile_utf8(d->outfilename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if(fh != INVALID_HANDLE_VALUE) { - if(GetFileType(fh) == FILE_TYPE_DISK) { - LARGE_INTEGER size; - size.QuadPart = written_size; - if(SetFilePointerEx(fh, size, NULL, FILE_CURRENT)) /* correct the file size */ - SetEndOfFile(fh); - } - CloseHandle(fh); - } - } - } -#endif - fclose(d->fout); - -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* Always delete output file when fuzzing */ - if(error_occurred) -#endif - flac_unlink(d->outfilename); - } -} - -FLAC__bool DecoderSession_init_decoder(DecoderSession *decoder_session, const char *infilename) -{ - FLAC__StreamDecoderInitStatus init_status; - FLAC__uint32 test = 1; - - is_big_endian_host_ = (*((FLAC__byte*)(&test)))? false : true; - - if(decoder_session->test_only && strcmp(infilename, "-") != 0) { - /* When testing, we can be a little more pedantic, as long - * as we can seek properly */ - FLAC__byte buffer[3]; - FILE * f; - - if(0 == (f = flac_fopen(infilename, "rb"))) { - flac__utils_printf(stderr, 1, "ERROR: can't open input file %s: %s\n", infilename, strerror(errno)); - return false; - } - - if(fread(buffer, 1, 3, f) < 3) { - flac__utils_printf(stderr, 1, "%s: ERROR checking for ID3v2 tag\n", decoder_session->inbasefilename); - fclose(f); - return false; - } - if(memcmp(buffer, "ID3", 3) == 0){ - flac__utils_printf(stderr, 1, "%s: WARNING, ID3v2 tag found. This is non-standard and strongly discouraged\n", decoder_session->inbasefilename); - if(decoder_session->treat_warnings_as_errors) { - fclose(f); - return false; - } - } - fclose(f); - } - - decoder_session->decoder = FLAC__stream_decoder_new(); - - if(0 == decoder_session->decoder) { - flac__utils_printf(stderr, 1, "%s: ERROR creating the decoder instance\n", decoder_session->inbasefilename); - return false; - } - - FLAC__stream_decoder_set_md5_checking(decoder_session->decoder, true); - if (0 != decoder_session->cue_specification) - FLAC__stream_decoder_set_metadata_respond(decoder_session->decoder, FLAC__METADATA_TYPE_CUESHEET); - if (decoder_session->replaygain.spec.apply || !decoder_session->channel_map_none) - FLAC__stream_decoder_set_metadata_respond(decoder_session->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT); - - if(!decoder_session->analysis_mode && !decoder_session->test_only && decoder_session->foreign_metadata == NULL) { - /* Warn user if foreign metadata is found */ - uint32_t i; - for(i = 0; i < FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS; i++) - FLAC__stream_decoder_set_metadata_respond_application(decoder_session->decoder, (FLAC__byte *)FLAC__FOREIGN_METADATA_APPLICATION_ID[i]); - } - -#if FLAC__HAS_OGG - if(decoder_session->is_ogg) { - if(!decoder_session->use_first_serial_number) - FLAC__stream_decoder_set_ogg_serial_number(decoder_session->decoder, decoder_session->serial_number); - init_status = FLAC__stream_decoder_init_ogg_file(decoder_session->decoder, strcmp(infilename, "-")? infilename : 0, write_callback, metadata_callback, error_callback, /*client_data=*/decoder_session); - } - else -#endif - { - init_status = FLAC__stream_decoder_init_file(decoder_session->decoder, strcmp(infilename, "-")? infilename : 0, write_callback, metadata_callback, error_callback, /*client_data=*/decoder_session); - } - - if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - print_error_with_init_status(decoder_session, "ERROR initializing decoder", init_status); - return false; - } - - return true; -} - -FLAC__bool DecoderSession_process(DecoderSession *d) -{ - if(!FLAC__stream_decoder_process_until_end_of_metadata(d->decoder)) { - flac__utils_printf(stderr, 2, "\n"); - print_error_with_state(d, "ERROR while decoding metadata"); - return false; - } - if(FLAC__stream_decoder_get_state(d->decoder) > FLAC__STREAM_DECODER_END_OF_STREAM) { - flac__utils_printf(stderr, 2, "\n"); - print_error_with_state(d, "ERROR during metadata decoding"); - if(!d->continue_through_decode_errors) - return false; - } - - if(d->analysis_mode) - FLAC__stream_decoder_get_decode_position(d->decoder, &d->decode_position); - - if(d->abort_flag) - return false; - - /* set channel mapping */ - /* currently FLAC order matches SMPTE/WAVEFORMATEXTENSIBLE order, so no reordering is necessary; see encode.c */ - /* only the channel mask must be set if it was not already picked up from the WAVEFORMATEXTENSIBLE_CHANNEL_MASK tag */ - if(!d->channel_map_none && d->channel_mask == 0) { - if(d->channels == 1) { - d->channel_mask = 0x0004; - } - else if(d->channels == 2) { - d->channel_mask = 0x0003; - } - else if(d->channels == 3) { - d->channel_mask = 0x0007; - } - else if(d->channels == 4) { - d->channel_mask = 0x0033; - } - else if(d->channels == 5) { - d->channel_mask = 0x0607; - } - else if(d->channels == 6) { - d->channel_mask = 0x060f; - } - else if(d->channels == 7) { - d->channel_mask = 0x070f; - } - else if(d->channels == 8) { - d->channel_mask = 0x063f; - } - } - -#if defined _WIN32 && !defined __CYGWIN__ - if(!d->analysis_mode && !d->test_only && d->total_samples > 0 && d->fout != stdout) { - HANDLE fh = CreateFile_utf8(d->outfilename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if(fh != INVALID_HANDLE_VALUE) { - if (GetFileType(fh) == FILE_TYPE_DISK) { - LARGE_INTEGER size; - size.QuadPart = d->total_samples * d->channels * ((d->bps+7)/8); - if(d->format != FORMAT_RAW) { - size.QuadPart += 512; - if(d->foreign_metadata) { - size_t i; - for(i = d->format==FORMAT_RF64?2:1; i < d->foreign_metadata->num_blocks; i++) { - if(i != d->foreign_metadata->format_block && i != d->foreign_metadata->audio_block) - size.QuadPart += d->foreign_metadata->blocks[i].size; - } - } - } - - if(SetFilePointerEx(fh, size, NULL, FILE_CURRENT)) /* tell filesystem the expected filesize to eliminate fragmentation */ - SetEndOfFile(fh); - } - CloseHandle(fh); - } - } -#endif - - /* write the WAVE/AIFF headers if necessary */ - if(!d->analysis_mode && !d->test_only && d->format != FORMAT_RAW) { - if(!write_iff_headers(d->fout, d, d->total_samples)) { - d->abort_flag = true; - return false; - } - } - - if(d->skip_specification->value.samples > 0) { - const FLAC__uint64 skip = (FLAC__uint64)d->skip_specification->value.samples; - - if(!FLAC__stream_decoder_seek_absolute(d->decoder, skip)) { - print_error_with_state(d, "ERROR seeking while skipping bytes"); - return false; - } - } - if(!FLAC__stream_decoder_process_until_end_of_stream(d->decoder) && !d->aborting_due_to_until) { - flac__utils_printf(stderr, 2, "\n"); - print_error_with_state(d, "ERROR while decoding data"); - if(!d->continue_through_decode_errors) - return false; - } - if( - (d->abort_flag && !(d->aborting_due_to_until || d->continue_through_decode_errors)) || - (FLAC__stream_decoder_get_state(d->decoder) > FLAC__STREAM_DECODER_END_OF_STREAM && !d->aborting_due_to_until) - ) { - flac__utils_printf(stderr, 2, "\n"); - print_error_with_state(d, "ERROR during decoding"); - return false; - } - - /* write padding bytes for alignment if necessary */ - if(!d->analysis_mode && !d->test_only && d->format != FORMAT_RAW) { - const FLAC__uint64 data_size = d->total_samples * d->channels * ((d->bps+7)/8); - uint32_t padding; - if(d->format != FORMAT_WAVE64) { - padding = (uint32_t)(data_size & 1); - } - else { - /* 8-byte alignment for Wave64 */ - padding = (8 - (uint32_t)(data_size & 7)) & 7; - } - for( ; padding > 0; --padding) { - if(flac__utils_fwrite("\000", 1, 1, d->fout) != 1) { - print_error_with_state( - d, - d->format == FORMAT_WAVE? "ERROR writing pad byte to WAVE data chunk" : - d->format == FORMAT_WAVE64? "ERROR writing pad bytes to WAVE64 data chunk" : - d->format == FORMAT_RF64? "ERROR writing pad byte to RF64 data chunk" : - "ERROR writing pad byte to AIFF SSND chunk" - ); - return false; - } - } - } - - return true; -} - -int DecoderSession_finish_ok(DecoderSession *d) -{ - FLAC__bool ok = true, md5_failure = false; - - if(d->decoder) { - md5_failure = !FLAC__stream_decoder_finish(d->decoder) && !d->aborting_due_to_until; - print_stats(d); - FLAC__stream_decoder_delete(d->decoder); - } - if(d->analysis_mode) - flac__analyze_finish(d->aopts); - if(md5_failure) { - stats_print_name(1, d->inbasefilename); - flac__utils_printf(stderr, 1, "ERROR, MD5 signature mismatch\n"); - ok = d->continue_through_decode_errors; - } - else if(d->got_stream_info && d->total_samples && (d->total_samples > d->samples_processed)){ - stats_print_name(1, d->inbasefilename); - flac__utils_printf(stderr, 1, "ERROR, decoded number of samples is smaller than the total number of samples set in the STREAMINFO\n"); - ok = d->continue_through_decode_errors; - } - else { - if(!d->got_stream_info) { - stats_print_name(1, d->inbasefilename); - flac__utils_printf(stderr, 1, "WARNING, cannot check MD5 signature since there was no STREAMINFO\n"); - ok = !d->treat_warnings_as_errors; - } - else if(!d->has_md5sum) { - stats_print_name(1, d->inbasefilename); - flac__utils_printf(stderr, 1, "WARNING, cannot check MD5 signature since it was unset in the STREAMINFO\n"); - ok = !d->treat_warnings_as_errors; - } - else if(!d->total_samples) { - stats_print_name(1, d->inbasefilename); - flac__utils_printf(stderr, 1, "WARNING, cannot check total number of samples since it was unset in the STREAMINFO\n"); - ok = !d->treat_warnings_as_errors; - } - stats_print_name(2, d->inbasefilename); - flac__utils_printf(stderr, 2, "%s \n", d->test_only? "ok ":d->analysis_mode?"done ":"done"); - } - DecoderSession_destroy(d, /*error_occurred=*/!ok); - if(!d->analysis_mode && !d->test_only && d->format != FORMAT_RAW) { - if(d->iff_headers_need_fixup || (!d->got_stream_info && strcmp(d->outfilename, "-"))) { - if(!fixup_iff_headers(d)) - return 1; - } - if(d->foreign_metadata) { - const char *error; - if(!flac__foreign_metadata_write_to_iff(d->foreign_metadata, d->infilename, d->outfilename, d->fm_offset1, d->fm_offset2, d->fm_offset3, &error)) { - flac__utils_printf(stderr, 1, "ERROR updating foreign metadata from %s to %s: %s\n", d->infilename, d->outfilename, error); - return 1; - } - if(!flac__foreign_metadata_compare_with_iff(d->foreign_metadata, d->infilename, d->outfilename, d->fm_offset3, &error)) { - flac__utils_printf(stderr, 1, "ERROR verifying foreign metadata restore from %s to %s: %s\n", d->infilename, d->outfilename, error); - return 1; - } - } - } - return ok? 0 : 1; -} - -int DecoderSession_finish_error(DecoderSession *d) -{ - if(d->decoder) { - (void)FLAC__stream_decoder_finish(d->decoder); - FLAC__stream_decoder_delete(d->decoder); - } - if(d->analysis_mode) - flac__analyze_finish(d->aopts); - DecoderSession_destroy(d, /*error_occurred=*/true); - return 1; -} - -FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input) -{ - /* convert from mm:ss.sss to sample number if necessary */ - if(!flac__utils_canonicalize_skip_until_specification(spec, sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR, value of --until is too large\n", inbasefilename); - return false; - } - - /* special case: if "--until=-0", use the special value '0' to mean "end-of-stream" */ - if(spec->is_relative && spec->value.samples == 0) { - spec->is_relative = false; - return true; - } - - /* in any other case the total samples in the input must be known */ - if(total_samples_in_input == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --until when FLAC metadata has total sample count of 0\n", inbasefilename); - return false; - } - - FLAC__ASSERT(spec->value_is_samples); - - /* convert relative specifications to absolute */ - if(spec->is_relative) { - if(spec->value.samples <= 0) - spec->value.samples += (FLAC__int64)total_samples_in_input; - else - spec->value.samples += skip; - spec->is_relative = false; - } - - /* error check */ - if(spec->value.samples < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before beginning of input\n", inbasefilename); - return false; - } - if((FLAC__uint64)spec->value.samples <= skip) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before --skip point\n", inbasefilename); - return false; - } - if((FLAC__uint64)spec->value.samples > total_samples_in_input) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is after end of input\n", inbasefilename); - return false; - } - - return true; -} - -FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uint64 samples) -{ - const FileFormat format = decoder_session->format; - const FileSubFormat subformat = decoder_session->subformat; - const char *fmt_desc = - format==FORMAT_WAVE? "WAVE" : - format==FORMAT_WAVE64? "Wave64" : - format==FORMAT_RF64? "RF64" : - format==FORMAT_AIFF? "AIFF" : - "AIFC"; - const FLAC__bool is_waveformatextensible = - subformat == SUBFORMAT_WAVE_EXTENSIBLE || ( - (format == FORMAT_WAVE || format == FORMAT_WAVE64 || format == FORMAT_RF64) && - subformat != SUBFORMAT_WAVE_PCM && - ( - (decoder_session->channel_mask != 0 && decoder_session->channel_mask != 0x0004 && decoder_session->channel_mask != 0x0003) || - (decoder_session->bps != 8 && decoder_session->bps != 16) || - decoder_session->channels > 2 - )); - const FLAC__uint64 data_size = samples * decoder_session->channels * ((decoder_session->bps+7)/8); - const FLAC__uint64 aligned_data_size = - format == FORMAT_WAVE64? - (data_size+7) & (~(FLAC__uint64)7) : - (data_size+1) & (~(FLAC__uint64)1); - - FLAC__uint64 iff_size; - uint32_t foreign_metadata_size = 0; /* size of all non-audio non-fmt/COMM foreign metadata chunks */ - foreign_metadata_t *fm = decoder_session->foreign_metadata; - size_t i; - - FLAC__ASSERT( - format == FORMAT_WAVE || - format == FORMAT_WAVE64 || - format == FORMAT_RF64 || - format == FORMAT_AIFF || - format == FORMAT_AIFF_C - ); - - if(samples == 0) { - if(f == stdout) { - flac__utils_printf(stderr, 1, "%s: WARNING, don't have accurate sample count available for %s header.\n", decoder_session->inbasefilename, fmt_desc); - flac__utils_printf(stderr, 1, " Generated %s file will have a data chunk size of 0. Try\n", fmt_desc); - flac__utils_printf(stderr, 1, " decoding directly to a file instead.\n"); - if(decoder_session->treat_warnings_as_errors) - return false; - } - else { - decoder_session->iff_headers_need_fixup = true; - } - } - - if(fm) { - FLAC__ASSERT(fm->format_block); - FLAC__ASSERT(fm->audio_block); - FLAC__ASSERT(fm->format_block < fm->audio_block); - /* calc foreign metadata size; we always skip the first chunk, ds64 chunk, format chunk, and sound chunk since we write our own */ - for(i = format==FORMAT_RF64?2:1; i < fm->num_blocks; i++) { - if(i != fm->format_block && i != fm->audio_block) - foreign_metadata_size += fm->blocks[i].size; - } - } - - if(samples == 0) - iff_size = 0; - else if(format == FORMAT_WAVE || format == FORMAT_RF64) - /* 4 for WAVE form bytes */ - /* +{36,0} for ds64 chunk */ - /* +8+{40,16} for fmt chunk header and body */ - /* +8 for data chunk header */ - iff_size = 4 + (format==FORMAT_RF64?36:0) + 8+(is_waveformatextensible?40:16) + 8 + foreign_metadata_size + aligned_data_size; - else if(format == FORMAT_WAVE64) - /* 16+8 for RIFF GUID and size field */ - /* +16 for WAVE GUID */ - /* +16+8+{40,16} for fmt chunk header (GUID and size field) and body */ - /* +16+8 for data chunk header (GUID and size field) */ - iff_size = 16+8 + 16 + 16+8+(is_waveformatextensible?40:16) + 16+8 + foreign_metadata_size + aligned_data_size; - else if(format == FORMAT_AIFF) - iff_size = 46 + foreign_metadata_size + aligned_data_size; - else /* AIFF-C */ - iff_size = 16 + foreign_metadata_size + aligned_data_size + (fm?fm->aifc_comm_length:0); - - if(format != FORMAT_WAVE64 && format != FORMAT_RF64 && iff_size >= 0xFFFFFFF4) { - flac__utils_printf(stderr, 1, "%s: ERROR: stream is too big to fit in a single %s file\n", decoder_session->inbasefilename, fmt_desc); - return false; - } - - if(format == FORMAT_WAVE || format == FORMAT_WAVE64 || format == FORMAT_RF64) { - /* RIFF header */ - switch(format) { - case FORMAT_WAVE: - if(flac__utils_fwrite("RIFF", 1, 4, f) != 4) - return false; - if(!write_little_endian_uint32(f, (FLAC__uint32)iff_size)) /* filesize-8 */ - return false; - if(flac__utils_fwrite("WAVE", 1, 4, f) != 4) - return false; - break; - case FORMAT_WAVE64: - /* RIFF GUID 66666972-912E-11CF-A5D6-28DB04C10000 */ - if(flac__utils_fwrite("\x72\x69\x66\x66\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00", 1, 16, f) != 16) - return false; - if(!write_little_endian_uint64(f, iff_size)) - return false; - /* WAVE GUID 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */ - if(flac__utils_fwrite("\x77\x61\x76\x65\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16) - return false; - break; - case FORMAT_RF64: - if(flac__utils_fwrite("RF64", 1, 4, f) != 4) - return false; - if(!write_little_endian_uint32(f, 0xffffffff)) - return false; - if(flac__utils_fwrite("WAVE", 1, 4, f) != 4) - return false; - break; - default: - return false; - } - - /* ds64 chunk for RF64 */ - if(format == FORMAT_RF64) { - if(flac__utils_fwrite("ds64", 1, 4, f) != 4) - return false; - - if(!write_little_endian_uint32(f, 28)) /* chunk size */ - return false; - - if(!write_little_endian_uint64(f, iff_size)) - return false; - - if(!write_little_endian_uint64(f, data_size)) - return false; - - if(!write_little_endian_uint64(f, samples)) /*@@@@@@ correct? */ - return false; - - if(!write_little_endian_uint32(f, 0)) /* table size */ - return false; - } - - decoder_session->fm_offset1 = ftello(f); - - if(fm) { - /* seek forward to {allocate} or {skip over already-written chunks} before "fmt " */ - for(i = format==FORMAT_RF64?2:1; i < fm->format_block; i++) { - if(fseeko(f, fm->blocks[i].size, SEEK_CUR) < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: allocating/skipping foreign metadata before \"fmt \"\n", decoder_session->inbasefilename); - return false; - } - } - } - - if(format != FORMAT_WAVE64) { - if(flac__utils_fwrite("fmt ", 1, 4, f) != 4) - return false; - if(!write_little_endian_uint32(f, is_waveformatextensible? 40 : 16)) /* chunk size */ - return false; - } - else { /* Wave64 */ - /* fmt GUID 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */ - if(flac__utils_fwrite("\x66\x6D\x74\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16) - return false; - /* chunk size (+16+8 for GUID and size fields) */ - if(!write_little_endian_uint64(f, 16+8+(is_waveformatextensible?40:16))) - return false; - } - - if(!write_riff_wave_fmt_chunk_body(f, is_waveformatextensible, decoder_session->bps, decoder_session->channels, decoder_session->sample_rate, decoder_session->channel_mask)) - return false; - - decoder_session->fm_offset2 = ftello(f); - - if(fm) { - /* seek forward to {allocate} or {skip over already-written chunks} after "fmt " but before "data" */ - for(i = fm->format_block+1; i < fm->audio_block; i++) { - if(fseeko(f, fm->blocks[i].size, SEEK_CUR) < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: allocating/skipping foreign metadata after \"fmt \"\n", decoder_session->inbasefilename); - return false; - } - } - } - - if(format != FORMAT_WAVE64) { - if(flac__utils_fwrite("data", 1, 4, f) != 4) - return false; - if(!write_little_endian_uint32(f, format==FORMAT_RF64? 0xffffffff : (FLAC__uint32)data_size)) - return false; - } - else { /* Wave64 */ - /* data GUID 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */ - if(flac__utils_fwrite("\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16) - return false; - /* +16+8 for GUID and size fields */ - if(!write_little_endian_uint64(f, 16+8 + data_size)) - return false; - } - - decoder_session->fm_offset3 = ftello(f) + aligned_data_size; - } - else { - if(flac__utils_fwrite("FORM", 1, 4, f) != 4) - return false; - - if(!write_big_endian_uint32(f, (FLAC__uint32)iff_size)) /* filesize-8 */ - return false; - - if(format == FORMAT_AIFF) { - if(flac__utils_fwrite("AIFF", 1, 4, f) != 4) - return false; - } - else - if(flac__utils_fwrite("AIFC", 1, 4, f) != 4) - return false; - - decoder_session->fm_offset1 = ftello(f); - - if(fm) { - /* seek forward to {allocate} or {skip over already-written chunks} before "COMM" */ - for(i = 1; i < fm->format_block; i++) { - if(fseeko(f, fm->blocks[i].size, SEEK_CUR) < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: allocating/skipping foreign metadata before \"COMM\"\n", decoder_session->inbasefilename); - return false; - } - } - } - - if(!write_aiff_form_comm_chunk(f, samples, decoder_session->bps, decoder_session->channels, decoder_session->sample_rate, format, subformat, fm?fm->aifc_comm_length:0)) - return false; - - decoder_session->fm_offset2 = ftello(f); - - if(fm) { - /* seek forward to {allocate} or {skip over already-written chunks} after "COMM" but before "SSND" */ - for(i = fm->format_block+1; i < fm->audio_block; i++) { - if(fseeko(f, fm->blocks[i].size, SEEK_CUR) < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: allocating/skipping foreign metadata after \"COMM\"\n", decoder_session->inbasefilename); - return false; - } - } - } - - if(flac__utils_fwrite("SSND", 1, 4, f) != 4) - return false; - - if(!write_big_endian_uint32(f, (FLAC__uint32)data_size + 8)) /* data size */ - return false; - - if(!write_big_endian_uint32(f, 0/*offset_size*/)) - return false; - - if(!write_big_endian_uint32(f, 0/*block_size*/)) - return false; - - decoder_session->fm_offset3 = ftello(f) + aligned_data_size; - } - - return true; -} - -FLAC__bool write_riff_wave_fmt_chunk_body(FILE *f, FLAC__bool is_waveformatextensible, uint32_t bps, uint32_t channels, uint32_t sample_rate, FLAC__uint32 channel_mask) -{ - if(!write_little_endian_uint16(f, (FLAC__uint16)(is_waveformatextensible? 65534 : 1))) /* compression code */ - return false; - - if(!write_little_endian_uint16(f, (FLAC__uint16)channels)) - return false; - - if(!write_little_endian_uint32(f, sample_rate)) - return false; - - if(!write_little_endian_uint32(f, sample_rate * channels * ((bps+7) / 8))) - return false; - - if(!write_little_endian_uint16(f, (FLAC__uint16)(channels * ((bps+7) / 8)))) /* block align */ - return false; - - if(!write_little_endian_uint16(f, (FLAC__uint16)(((bps+7)/8)*8))) /* bits per sample */ - return false; - - if(is_waveformatextensible) { - if(!write_little_endian_uint16(f, (FLAC__uint16)22)) /* cbSize */ - return false; - - if(!write_little_endian_uint16(f, (FLAC__uint16)bps)) /* validBitsPerSample */ - return false; - - if(!write_little_endian_uint32(f, channel_mask)) - return false; - - /* GUID = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} */ - if(flac__utils_fwrite("\x01\x00\x00\x00\x00\x00\x10\x00\x80\x00\x00\xaa\x00\x38\x9b\x71", 1, 16, f) != 16) - return false; - } - - return true; -} - -FLAC__bool write_aiff_form_comm_chunk(FILE *f, FLAC__uint64 samples, uint32_t bps, uint32_t channels, uint32_t sample_rate, FileFormat format, FileSubFormat subformat, FLAC__uint32 comm_length) -{ - FLAC__uint32 i; - FLAC__ASSERT(samples <= 0xffffffff); - - if(comm_length == 0) { - if(format == FORMAT_AIFF) - comm_length = 30; - else - comm_length = 36; - } - - if(flac__utils_fwrite("COMM", 1, 4, f) != 4) - return false; - - if(!write_big_endian_uint32(f, comm_length-12)) /* chunk size = 18 */ - return false; - - if(!write_big_endian_uint16(f, (FLAC__uint16)channels)) - return false; - - if(!write_big_endian_uint32(f, (FLAC__uint32)samples)) - return false; - - if(!write_big_endian_uint16(f, (FLAC__uint16)bps)) - return false; - - if(!write_sane_extended(f, sample_rate)) - return false; - - if(format == FORMAT_AIFF_C) { - if(subformat == SUBFORMAT_AIFF_C_NONE) { - if(flac__utils_fwrite("NONE", 1, 4, f) != 4) - return false; - } - else if(subformat == SUBFORMAT_AIFF_C_SOWT) { - if(flac__utils_fwrite("sowt", 1, 4, f) != 4) - return false; - } - for(i = 34; i < comm_length; i++) { - if(flac__utils_fwrite("\x00", 1, 1, f) != 1) - return false; - } - } - - - - return true; -} - -FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 val) -{ - FLAC__byte *b = (FLAC__byte*)(&val); - if(is_big_endian_host_) { - FLAC__byte tmp; - tmp = b[1]; b[1] = b[0]; b[0] = tmp; - } - return flac__utils_fwrite(b, 1, 2, f) == 2; -} - -FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 val) -{ - FLAC__byte *b = (FLAC__byte*)(&val); - if(is_big_endian_host_) { - FLAC__byte tmp; - tmp = b[3]; b[3] = b[0]; b[0] = tmp; - tmp = b[2]; b[2] = b[1]; b[1] = tmp; - } - return flac__utils_fwrite(b, 1, 4, f) == 4; -} - -FLAC__bool write_little_endian_uint64(FILE *f, FLAC__uint64 val) -{ - FLAC__byte *b = (FLAC__byte*)(&val); - if(is_big_endian_host_) { - FLAC__byte tmp; - tmp = b[7]; b[7] = b[0]; b[0] = tmp; - tmp = b[6]; b[6] = b[1]; b[1] = tmp; - tmp = b[5]; b[5] = b[2]; b[2] = tmp; - tmp = b[4]; b[4] = b[3]; b[3] = tmp; - } - return flac__utils_fwrite(b, 1, 8, f) == 8; -} - -FLAC__bool write_big_endian_uint16(FILE *f, FLAC__uint16 val) -{ - FLAC__byte *b = (FLAC__byte*)(&val); - if(!is_big_endian_host_) { - FLAC__byte tmp; - tmp = b[1]; b[1] = b[0]; b[0] = tmp; - } - return flac__utils_fwrite(b, 1, 2, f) == 2; -} - -FLAC__bool write_big_endian_uint32(FILE *f, FLAC__uint32 val) -{ - FLAC__byte *b = (FLAC__byte*)(&val); - if(!is_big_endian_host_) { - FLAC__byte tmp; - tmp = b[3]; b[3] = b[0]; b[0] = tmp; - tmp = b[2]; b[2] = b[1]; b[1] = tmp; - } - return flac__utils_fwrite(b, 1, 4, f) == 4; -} - -FLAC__bool write_sane_extended(FILE *f, uint32_t val) - /* Write to 'f' a SANE extended representation of 'val'. Return false if - * the write succeeds; return true otherwise. - * - * SANE extended is an 80-bit IEEE-754 representation with sign bit, 15 bits - * of exponent, and 64 bits of significand (mantissa). Unlike most IEEE-754 - * representations, it does not imply a 1 above the MSB of the significand. - * - */ -{ - uint32_t shift, exponent; - - if(val == 0U) { - if(!write_big_endian_uint16(f, 0)) - return false; - if(!write_big_endian_uint32(f, 0)) - return false; - if(!write_big_endian_uint32(f, 0)) - return false; - return true; - } - - for(shift= 0U; (val>>(31-shift))==0U; ++shift) - ; - val<<= shift; - exponent= 63U-(shift+32U); /* add 32 for unused second word */ - - if(!write_big_endian_uint16(f, (FLAC__uint16)(exponent+0x3FFF))) - return false; - if(!write_big_endian_uint32(f, val)) - return false; - if(!write_big_endian_uint32(f, 0)) /* unused second word */ - return false; - - return true; -} - -FLAC__bool fixup_iff_headers(DecoderSession *d) -{ - const char *fmt_desc = - d->format==FORMAT_WAVE? "WAVE" : - d->format==FORMAT_WAVE64? "Wave64" : - d->format==FORMAT_RF64? "RF64" : - "AIFF"; - FILE *f = flac_fopen(d->outfilename, "r+b"); /* stream is positioned at beginning of file */ - - if(0 == f) { - flac__utils_printf(stderr, 1, "ERROR, couldn't open file %s while fixing up %s chunk size: %s\n", d->outfilename, fmt_desc, strerror(errno)); - return false; - } - - if(!write_iff_headers(f, d, d->samples_processed)) { - fclose(f); - return false; - } - - fclose(f); - return true; -} - -FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - DecoderSession *decoder_session = (DecoderSession*)client_data; - FILE *fout = decoder_session->fout; - const uint32_t bps = frame->header.bits_per_sample, channels = frame->header.channels; - const uint32_t shift = (bps%8)? 8-(bps%8): 0; - FLAC__bool is_big_endian = ( - (decoder_session->format == FORMAT_AIFF || (decoder_session->format == FORMAT_AIFF_C && decoder_session->subformat == SUBFORMAT_AIFF_C_NONE)) ? true : ( - decoder_session->format == FORMAT_WAVE || decoder_session->format == FORMAT_WAVE64 || decoder_session->format == FORMAT_RF64 || (decoder_session->format == FORMAT_AIFF_C && decoder_session->subformat == SUBFORMAT_AIFF_C_SOWT) ? false : - decoder_session->is_big_endian - )); - FLAC__bool is_unsigned_samples = ( - decoder_session->format == FORMAT_AIFF || decoder_session->format == FORMAT_AIFF_C ? false : ( - decoder_session->format == FORMAT_WAVE || decoder_session->format == FORMAT_WAVE64 || decoder_session->format == FORMAT_RF64 ? bps<=8 : - decoder_session->is_unsigned_samples - )); - uint32_t wide_samples = frame->header.blocksize, wide_sample, sample, channel; - FLAC__uint64 frame_bytes = 0; - - static union - { /* The arrays defined within this union are all the same size. */ - FLAC__int8 s8buffer [FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(FLAC__int32)]; /* WATCHOUT: can be up to 2 megs */ - FLAC__uint8 u8buffer [FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(FLAC__int32)]; - FLAC__int16 s16buffer [FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(FLAC__int16)]; - FLAC__uint16 u16buffer [FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(FLAC__int16)]; - FLAC__int32 s32buffer [FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS]; - FLAC__uint32 u32buffer [FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS]; - } ubuf; - - size_t bytes_to_write = 0; - - (void)decoder; - - if(decoder_session->abort_flag) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - - /* sanity-check the bits-per-sample */ - if(decoder_session->bps) { - if(bps != decoder_session->bps) { - if(decoder_session->got_stream_info) - flac__utils_printf(stderr, 1, "%s: ERROR, bits-per-sample is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, bps, decoder_session->bps); - else - flac__utils_printf(stderr, 1, "%s: ERROR, bits-per-sample is %u in this frame but %u in previous frames\n", decoder_session->inbasefilename, bps, decoder_session->bps); - if(!decoder_session->continue_through_decode_errors) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - else { - /* must not have gotten STREAMINFO, save the bps from the frame header */ - FLAC__ASSERT(!decoder_session->got_stream_info); - if(decoder_session->format == FORMAT_RAW && ((decoder_session->bps % 8) != 0 || decoder_session->bps < 4)) { - flac__utils_printf(stderr, 1, "%s: ERROR: bits per sample is %u, must be 8/16/24/32 for raw format output\n", decoder_session->inbasefilename, decoder_session->bps); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - decoder_session->bps = bps; - } - - /* sanity-check the #channels */ - if(decoder_session->channels) { - if(channels != decoder_session->channels) { - if(decoder_session->got_stream_info) - flac__utils_printf(stderr, 1, "%s: ERROR, channels is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, channels, decoder_session->channels); - else - flac__utils_printf(stderr, 1, "%s: ERROR, channels is %u in this frame but %u in previous frames\n", decoder_session->inbasefilename, channels, decoder_session->channels); - if(!decoder_session->continue_through_decode_errors) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - else { - /* must not have gotten STREAMINFO, save the #channels from the frame header */ - FLAC__ASSERT(!decoder_session->got_stream_info); - decoder_session->channels = channels; - } - - /* sanity-check the sample rate */ - if(decoder_session->sample_rate < UINT32_MAX) { - if(frame->header.sample_rate != decoder_session->sample_rate) { - if(decoder_session->got_stream_info) - flac__utils_printf(stderr, 1, "%s: ERROR, sample rate is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, frame->header.sample_rate, decoder_session->sample_rate); - else - flac__utils_printf(stderr, 1, "%s: ERROR, sample rate is %u in this frame but %u in previous frames\n", decoder_session->inbasefilename, frame->header.sample_rate, decoder_session->sample_rate); - if(!decoder_session->continue_through_decode_errors) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - else { - /* must not have gotten STREAMINFO, save the sample rate from the frame header */ - FLAC__ASSERT(!decoder_session->got_stream_info); - decoder_session->sample_rate = frame->header.sample_rate; - } - - /* - * limit the number of samples to accept based on --until - */ - /* if we never got the total_samples from the metadata, the skip and until specs would never have been canonicalized, so protect against that: */ - if(decoder_session->skip_specification->is_relative || !decoder_session->got_stream_info) { - if(decoder_session->skip_specification->value.samples == 0) /* special case for when no --skip was given */ - decoder_session->skip_specification->is_relative = false; /* convert to our meaning of beginning-of-stream */ - else { - flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --skip because the total sample count was not found in the metadata\n", decoder_session->inbasefilename); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - if(decoder_session->until_specification->is_relative || !decoder_session->got_stream_info) { - if(decoder_session->until_specification->value.samples == 0) /* special case for when no --until was given */ - decoder_session->until_specification->is_relative = false; /* convert to our meaning of end-of-stream */ - else { - flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --until because the total sample count was not found in the metadata\n", decoder_session->inbasefilename); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - FLAC__ASSERT(decoder_session->skip_specification->value.samples >= 0); - FLAC__ASSERT(decoder_session->until_specification->value.samples >= 0); - if(decoder_session->until_specification->value.samples > 0) { - const FLAC__uint64 skip = (FLAC__uint64)decoder_session->skip_specification->value.samples; - const FLAC__uint64 until = (FLAC__uint64)decoder_session->until_specification->value.samples; - const FLAC__uint64 input_samples_passed = skip + decoder_session->samples_processed; - FLAC__ASSERT(until >= input_samples_passed); - if(input_samples_passed + wide_samples > until) - wide_samples = (uint32_t)(until - input_samples_passed); - if (wide_samples == 0) { - decoder_session->abort_flag = true; - decoder_session->aborting_due_to_until = true; - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - - if(decoder_session->analysis_mode) { - FLAC__uint64 dpos; - FLAC__stream_decoder_get_decode_position(decoder_session->decoder, &dpos); - frame_bytes = (dpos-decoder_session->decode_position); - decoder_session->decode_position = dpos; - } - - if(wide_samples > 0) { - decoder_session->samples_processed += wide_samples; - decoder_session->frame_counter++; - -#if 0 /* in case time.h with clock() isn't available for some reason */ - if(!(decoder_session->frame_counter & 0x1ff)) - print_stats(decoder_session); -#else - if((clock() - decoder_session->old_clock_t) > (CLOCKS_PER_SEC/4)) { - print_stats(decoder_session); - decoder_session->old_clock_t = clock(); - } -#endif - - - if(decoder_session->analysis_mode) { - flac__analyze_frame(frame, decoder_session->frame_counter-1, decoder_session->decode_position-frame_bytes, frame_bytes, decoder_session->aopts, fout); - } - else if(!decoder_session->test_only) { - if(shift && !decoder_session->replaygain.apply) { - for(wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++) - ((uint32_t **)buffer)[channel][wide_sample] <<= shift;/*@@@@@@un-const'ing the buffer is hacky but safe*/ - } - if(decoder_session->replaygain.apply) { - bytes_to_write = FLAC__replaygain_synthesis__apply_gain( - ubuf.u8buffer, - !is_big_endian, - is_unsigned_samples, - buffer, - wide_samples, - channels, - bps, /* source_bps */ - bps+shift, /* target_bps */ - decoder_session->replaygain.scale, - decoder_session->replaygain.spec.limiter == RGSS_LIMIT__HARD, /* hard_limit */ - decoder_session->replaygain.spec.noise_shaping != NOISE_SHAPING_NONE, /* do_dithering */ - &decoder_session->replaygain.dither_context - ); - } - /* first some special code for common cases */ - else if(is_big_endian == is_big_endian_host_ && !is_unsigned_samples && channels == 2 && bps+shift == 16) { - FLAC__int16 *buf1_ = ubuf.s16buffer + 1; - if(is_big_endian) - memcpy(ubuf.s16buffer, ((FLAC__byte*)(buffer[0]))+2, sizeof(FLAC__int32) * wide_samples - 2); - else - memcpy(ubuf.s16buffer, buffer[0], sizeof(FLAC__int32) * wide_samples); - for(sample = 0; sample < wide_samples; sample++, buf1_+=2) - *buf1_ = (FLAC__int16)buffer[1][sample]; - bytes_to_write = 4 * sample; - } - else if(is_big_endian == is_big_endian_host_ && !is_unsigned_samples && channels == 1 && bps+shift == 16) { - FLAC__int16 *buf1_ = ubuf.s16buffer; - for(sample = 0; sample < wide_samples; sample++) - *buf1_++ = (FLAC__int16)buffer[0][sample]; - bytes_to_write = 2 * sample; - } - /* generic code for the rest */ - else if(bps+shift == 16) { - if(is_unsigned_samples) { - if(channels == 2) { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) { - ubuf.u16buffer[sample++] = (FLAC__uint16)(buffer[0][wide_sample] + 0x8000); - ubuf.u16buffer[sample++] = (FLAC__uint16)(buffer[1][wide_sample] + 0x8000); - } - } - else if(channels == 1) { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - ubuf.u16buffer[sample++] = (FLAC__uint16)(buffer[0][wide_sample] + 0x8000); - } - else { /* works for any 'channels' but above flavors are faster for 1 and 2 */ - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++, sample++) - ubuf.u16buffer[sample] = (FLAC__uint16)(buffer[channel][wide_sample] + 0x8000); - } - } - else { - if(channels == 2) { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) { - ubuf.s16buffer[sample++] = (FLAC__int16)(buffer[0][wide_sample]); - ubuf.s16buffer[sample++] = (FLAC__int16)(buffer[1][wide_sample]); - } - } - else if(channels == 1) { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - ubuf.s16buffer[sample++] = (FLAC__int16)(buffer[0][wide_sample]); - } - else { /* works for any 'channels' but above flavors are faster for 1 and 2 */ - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++, sample++) - ubuf.s16buffer[sample] = (FLAC__int16)(buffer[channel][wide_sample]); - } - } - if(is_big_endian != is_big_endian_host_) { - uint8_t tmp; - const uint32_t bytes = sample * 2; - uint32_t b; - for(b = 0; b < bytes; b += 2) { - tmp = ubuf.u8buffer[b]; - ubuf.u8buffer[b] = ubuf.u8buffer[b+1]; - ubuf.u8buffer[b+1] = tmp; - } - } - bytes_to_write = 2 * sample; - } - else if(bps+shift == 24) { - if(is_unsigned_samples) { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++, sample++) - ubuf.u32buffer[sample] = buffer[channel][wide_sample] + 0x800000; - } - else { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++, sample++) - ubuf.s32buffer[sample] = buffer[channel][wide_sample]; - } - if(is_big_endian != is_big_endian_host_) { - uint8_t tmp; - const uint32_t bytes = sample * 4; - uint32_t b; - for(b = 0; b < bytes; b += 4) { - tmp = ubuf.u8buffer[b]; - ubuf.u8buffer[b] = ubuf.u8buffer[b+3]; - ubuf.u8buffer[b+3] = tmp; - tmp = ubuf.u8buffer[b+1]; - ubuf.u8buffer[b+1] = ubuf.u8buffer[b+2]; - ubuf.u8buffer[b+2] = tmp; - } - } - if(is_big_endian) { - uint32_t b, lbyte; - const uint32_t bytes = sample * 4; - for(lbyte = b = 0; b < bytes; ) { - b++; - ubuf.u8buffer[lbyte++] = ubuf.u8buffer[b++]; - ubuf.u8buffer[lbyte++] = ubuf.u8buffer[b++]; - ubuf.u8buffer[lbyte++] = ubuf.u8buffer[b++]; - } - } - else { - uint32_t b, lbyte; - const uint32_t bytes = sample * 4; - for(lbyte = b = 0; b < bytes; ) { - ubuf.u8buffer[lbyte++] = ubuf.u8buffer[b++]; - ubuf.u8buffer[lbyte++] = ubuf.u8buffer[b++]; - ubuf.u8buffer[lbyte++] = ubuf.u8buffer[b++]; - b++; - } - } - bytes_to_write = 3 * sample; - } - else if(bps+shift == 8) { - if(is_unsigned_samples) { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++, sample++) - ubuf.u8buffer[sample] = (FLAC__uint8)(buffer[channel][wide_sample] + 0x80); - } - else { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++, sample++) - ubuf.s8buffer[sample] = (FLAC__int8)(buffer[channel][wide_sample]); - } - bytes_to_write = sample; - } - else if(bps+shift == 32) { - if(is_unsigned_samples) { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++, sample++) - ubuf.u32buffer[sample] = buffer[channel][wide_sample]; - } - else { - for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++, sample++) - ubuf.s32buffer[sample] = buffer[channel][wide_sample]; - } - if(is_big_endian != is_big_endian_host_) { - uint8_t tmp; - const uint32_t bytes = sample * 4; - uint32_t b; - for(b = 0; b < bytes; b += 4) { - tmp = ubuf.u8buffer[b]; - ubuf.u8buffer[b] = ubuf.u8buffer[b+3]; - ubuf.u8buffer[b+3] = tmp; - tmp = ubuf.u8buffer[b+1]; - ubuf.u8buffer[b+1] = ubuf.u8buffer[b+2]; - ubuf.u8buffer[b+2] = tmp; - } - } - bytes_to_write = 4 * sample; - } - else { - FLAC__ASSERT(0); - /* double protection */ - decoder_session->abort_flag = true; - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - } - if(bytes_to_write > 0) { - if(flac__utils_fwrite(ubuf.u8buffer, 1, bytes_to_write, fout) != bytes_to_write) { - /* if a pipe closed when writing to stdout, we let it go without an error message */ - if(errno == EPIPE && decoder_session->fout == stdout) - decoder_session->aborting_due_to_until = true; - decoder_session->abort_flag = true; - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - DecoderSession *decoder_session = (DecoderSession*)client_data; - - (void)decoder; - - if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { - FLAC__uint64 skip, until; - - if(decoder_session->got_stream_info){ - /* There was already a STREAMINFO received */ - flac__utils_printf(stderr, 1, "%s: ERROR, more than one STREAMINFO found\n", decoder_session->inbasefilename); - if(!decoder_session->continue_through_decode_errors) - decoder_session->abort_flag = true; - return; - } - - decoder_session->got_stream_info = true; - decoder_session->has_md5sum = memcmp(metadata->data.stream_info.md5sum, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) != 0; - decoder_session->bps = metadata->data.stream_info.bits_per_sample; - decoder_session->channels = metadata->data.stream_info.channels; - decoder_session->sample_rate = metadata->data.stream_info.sample_rate; - - if(!flac__utils_canonicalize_skip_until_specification(decoder_session->skip_specification, decoder_session->sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR, value of --skip is too large\n", decoder_session->inbasefilename); - decoder_session->abort_flag = true; - return; - } - FLAC__ASSERT(decoder_session->skip_specification->value.samples >= 0); - skip = (FLAC__uint64)decoder_session->skip_specification->value.samples; - - /* remember, metadata->data.stream_info.total_samples can be 0, meaning 'unknown' */ - if(metadata->data.stream_info.total_samples > 0 && skip >= metadata->data.stream_info.total_samples) { - flac__utils_printf(stderr, 1, "%s: ERROR trying to --skip more samples than in stream\n", decoder_session->inbasefilename); - decoder_session->abort_flag = true; - return; - } - else if(metadata->data.stream_info.total_samples == 0 && skip > 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, can't --skip when FLAC metadata has total sample count of 0\n", decoder_session->inbasefilename); - decoder_session->abort_flag = true; - return; - } - FLAC__ASSERT(skip == 0 || 0 == decoder_session->cue_specification); - decoder_session->total_samples = metadata->data.stream_info.total_samples - skip; - - /* note that we use metadata->data.stream_info.total_samples instead of decoder_session->total_samples */ - if(!canonicalize_until_specification(decoder_session->until_specification, decoder_session->inbasefilename, decoder_session->sample_rate, skip, metadata->data.stream_info.total_samples)) { - decoder_session->abort_flag = true; - return; - } - FLAC__ASSERT(decoder_session->until_specification->value.samples >= 0); - until = (FLAC__uint64)decoder_session->until_specification->value.samples; - - if(until > 0) { - FLAC__ASSERT(decoder_session->total_samples != 0); - FLAC__ASSERT(0 == decoder_session->cue_specification); - decoder_session->total_samples -= (metadata->data.stream_info.total_samples - until); - } - - if(decoder_session->format == FORMAT_RAW && ((decoder_session->bps % 8) != 0 || decoder_session->bps < 4)) { - flac__utils_printf(stderr, 1, "%s: ERROR: bits per sample is %u, must be 8/16/24/32 for raw format output\n", decoder_session->inbasefilename, decoder_session->bps); - decoder_session->abort_flag = true; - return; - } - - if(decoder_session->bps < 4 || decoder_session->bps > 32) { - flac__utils_printf(stderr, 1, "%s: ERROR: bits per sample is %u, must be 4-32\n", decoder_session->inbasefilename, decoder_session->bps); - decoder_session->abort_flag = true; - return; - } - } - else if(metadata->type == FLAC__METADATA_TYPE_CUESHEET) { - /* remember, at this point, decoder_session->total_samples can be 0, meaning 'unknown' */ - if(decoder_session->total_samples == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR can't use --cue when FLAC metadata has total sample count of 0\n", decoder_session->inbasefilename); - decoder_session->abort_flag = true; - return; - } - - flac__utils_canonicalize_cue_specification(decoder_session->cue_specification, &metadata->data.cue_sheet, decoder_session->total_samples, decoder_session->skip_specification, decoder_session->until_specification); - - FLAC__ASSERT(!decoder_session->skip_specification->is_relative); - FLAC__ASSERT(decoder_session->skip_specification->value_is_samples); - - FLAC__ASSERT(!decoder_session->until_specification->is_relative); - FLAC__ASSERT(decoder_session->until_specification->value_is_samples); - - FLAC__ASSERT(decoder_session->skip_specification->value.samples >= 0); - FLAC__ASSERT(decoder_session->until_specification->value.samples >= 0); - FLAC__ASSERT((FLAC__uint64)decoder_session->until_specification->value.samples <= decoder_session->total_samples); - FLAC__ASSERT(decoder_session->skip_specification->value.samples <= decoder_session->until_specification->value.samples); - - decoder_session->total_samples = decoder_session->until_specification->value.samples - decoder_session->skip_specification->value.samples; - } - else if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { - if (decoder_session->replaygain.spec.apply) { - double reference, gain, peak; - if (!(decoder_session->replaygain.apply = grabbag__replaygain_load_from_vorbiscomment(metadata, decoder_session->replaygain.spec.use_album_gain, /*strict=*/false, &reference, &gain, &peak))) { - flac__utils_printf(stderr, 1, "%s: WARNING: can't get %s (or even %s) ReplayGain tags\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track", decoder_session->replaygain.spec.use_album_gain? "track":"album"); - if(decoder_session->treat_warnings_as_errors) { - decoder_session->abort_flag = true; - return; - } - } - else if(decoder_session->bps == 0) { - flac__utils_printf(stderr, 1, "%s: WARNING: can't apply ReplayGain, bit-per-sample value is invalid\n", decoder_session->inbasefilename); - if(decoder_session->treat_warnings_as_errors) { - decoder_session->abort_flag = true; - return; - } - } - else { - const char *ls[] = { "no", "peak", "hard" }; - const char *ns[] = { "no", "low", "medium", "high" }; - decoder_session->replaygain.scale = grabbag__replaygain_compute_scale_factor(peak, gain, decoder_session->replaygain.spec.preamp, decoder_session->replaygain.spec.limiter == RGSS_LIMIT__PEAK); - FLAC__ASSERT(decoder_session->bps > 0 && decoder_session->bps <= 32); - FLAC__replaygain_synthesis__init_dither_context(&decoder_session->replaygain.dither_context, decoder_session->bps, decoder_session->replaygain.spec.noise_shaping); - flac__utils_printf(stderr, 1, "%s: INFO: applying %s ReplayGain (gain=%0.2fdB+preamp=%0.1fdB, %s noise shaping, %s limiting) to output\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track", gain, decoder_session->replaygain.spec.preamp, ns[decoder_session->replaygain.spec.noise_shaping], ls[decoder_session->replaygain.spec.limiter]); - flac__utils_printf(stderr, 1, "%s: WARNING: applying ReplayGain is not lossless\n", decoder_session->inbasefilename); - /* don't check if(decoder_session->treat_warnings_as_errors) because the user explicitly asked for it */ - } - } - (void)flac__utils_get_channel_mask_tag(metadata, &decoder_session->channel_mask); - } - else if(metadata->type == FLAC__METADATA_TYPE_APPLICATION && decoder_session->warn_user_about_foreign_metadata) { - /* Foreign metadata signalling */ - flac__utils_printf(stderr, 1, "%s: WARNING: found foreign metadata, use --keep-foreign-metadata to restore\n", decoder_session->inbasefilename); - decoder_session->warn_user_about_foreign_metadata = false; - } -} - -void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - DecoderSession *decoder_session = (DecoderSession*)client_data; - (void)decoder; - if(!decoder_session->error_callback_suppress_messages) { - stats_print_name(1, decoder_session->inbasefilename); - flac__utils_printf(stderr, 1, "*** Got error code %d:%s\n", status, FLAC__StreamDecoderErrorStatusString[status]); - } - if(!decoder_session->continue_through_decode_errors) { - /* if we got a sync error while looking for metadata, either it's not a FLAC file (more likely) or the file is corrupted */ - if( - !decoder_session->error_callback_suppress_messages && - status == FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC && - FLAC__stream_decoder_get_state(decoder) == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA - ) { - flac__utils_printf(stderr, 1, - "\n" - "The input file is either not a FLAC file or is corrupted. If you are\n" - "convinced it is a FLAC file, you can rerun the same command and add the\n" - "-F parameter to try and recover as much as possible from the file.\n" - ); - decoder_session->error_callback_suppress_messages = true; - } - else if(status == FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM) - decoder_session->aborting_due_to_unparseable = true; - decoder_session->abort_flag = true; - } -} - -void print_error_with_init_status(const DecoderSession *d, const char *message, FLAC__StreamDecoderInitStatus init_status) -{ - const int ilen = strlen(d->inbasefilename) + 1; - - flac__utils_printf(stderr, 1, "\n%s: %s\n", d->inbasefilename, message); - - flac__utils_printf(stderr, 1, "%*s init status = %s\n", ilen, "", FLAC__StreamDecoderInitStatusString[init_status]); - - /* print out some more info for some errors: */ - if (init_status == FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE) { - flac__utils_printf(stderr, 1, - "\n" -#ifdef _WIN32 - "An error occurred opening the input file; it is likely that it does not exist,\n" - "is not readable or has a filename that exceeds the path length limit.\n" -#else - "An error occurred opening the input file; it is likely that it does not exist\n" - "or is not readable.\n" -#endif - ); - } -} - -void print_error_with_state(const DecoderSession *d, const char *message) -{ - const int ilen = strlen(d->inbasefilename) + 1; - - flac__utils_printf(stderr, 1, "\n%s: %s\n", d->inbasefilename, message); - flac__utils_printf(stderr, 1, "%*s state = %s\n", ilen, "", FLAC__stream_decoder_get_resolved_state_string(d->decoder)); - - /* print out some more info for some errors: */ - if (d->aborting_due_to_unparseable) { - flac__utils_printf(stderr, 1, - "\n" - "The FLAC stream may have been created by a more advanced encoder. Try\n" - " metaflac --show-vendor-tag %s\n" - "If the version number is greater than %s, this decoder is probably\n" - "not able to decode the file. If the version number is not, the file\n" - "may be corrupted, or you may have found a bug. In this case please\n" - "submit a bug report to\n" - " https://github.com/xiph/flac/issues\n" - "Make sure to use the \"Monitor\" feature to monitor the bug status.\n", - d->inbasefilename, FLAC__VERSION_STRING - ); - } -} - -void print_stats(const DecoderSession *decoder_session) -{ - if(flac__utils_verbosity_ >= 2) { - const double progress = (double)decoder_session->samples_processed / (double)decoder_session->total_samples * 100.0; - - if(decoder_session->total_samples > 0) { - if ((uint32_t)floor(progress + 0.5) == 100) - return; - - stats_print_name(2, decoder_session->inbasefilename); - stats_print_info(2, "%s%u%% complete", - decoder_session->test_only? "testing, " : decoder_session->analysis_mode? "analyzing, " : "", - (uint32_t)floor(progress + 0.5) - ); - } - else { - stats_print_name(2, decoder_session->inbasefilename); - stats_print_info(2, "%s %" PRIu64 " samples", - decoder_session->test_only? "tested" : decoder_session->analysis_mode? "analyzed" : "wrote", - decoder_session->samples_processed - ); - } - } -} diff --git a/Engine/lib/flac/src/flac/decode.h b/Engine/lib/flac/src/flac/decode.h deleted file mode 100644 index 24f5723da..000000000 --- a/Engine/lib/flac/src/flac/decode.h +++ /dev/null @@ -1,73 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef flac__decode_h -#define flac__decode_h - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "analyze.h" -#include "foreign_metadata.h" -#include "utils.h" -#include "share/replaygain_synthesis.h" - - -typedef struct { - FLAC__bool apply; - FLAC__bool use_album_gain; /* false => use track gain */ - enum { RGSS_LIMIT__NONE, RGSS_LIMIT__PEAK, RGSS_LIMIT__HARD} limiter; - NoiseShaping noise_shaping; - double preamp; -} replaygain_synthesis_spec_t; - -typedef struct { - FLAC__bool treat_warnings_as_errors; - FLAC__bool continue_through_decode_errors; - replaygain_synthesis_spec_t replaygain_synthesis_spec; -#if FLAC__HAS_OGG - FLAC__bool is_ogg; - FLAC__bool use_first_serial_number; - long serial_number; -#endif - utils__SkipUntilSpecification skip_specification; - utils__SkipUntilSpecification until_specification; - FLAC__bool has_cue_specification; - utils__CueSpecification cue_specification; - FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */ - FLAC__bool relaxed_foreign_metadata_handling; - FileSubFormat force_subformat; - - FileFormat format; - union { - struct { - FLAC__bool is_big_endian; - FLAC__bool is_unsigned_samples; - } raw; - struct { - foreign_metadata_t *foreign_metadata; /* NULL unless --keep-foreign-metadata requested */ - } iff; - } format_options; -} decode_options_t; - -/* outfile == 0 => test only */ -int flac__decode_file(const char *infilename, const char *outfilename, FLAC__bool analysis_mode, analysis_options aopts, decode_options_t options); - -#endif diff --git a/Engine/lib/flac/src/flac/encode.c b/Engine/lib/flac/src/flac/encode.c deleted file mode 100644 index a945b356a..000000000 --- a/Engine/lib/flac/src/flac/encode.c +++ /dev/null @@ -1,2852 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include /* for LONG_MAX */ -#include /* for floor() */ -#include /* for FILE etc. */ -#include /* for malloc */ -#include /* for strcmp(), strerror() */ -#include /* for clock() */ -#include -#include "FLAC/all.h" -#include "share/alloc.h" -#include "share/grabbag.h" -#include "share/compat.h" -#include "share/private.h" -#include "share/safe_str.h" -#include "share/endswap.h" -#include "encode.h" - -#ifdef min -#undef min -#endif -#define min(x,y) ((x)<(y)?(x):(y)) -#ifdef max -#undef max -#endif -#define max(x,y) ((x)>(y)?(x):(y)) - -/* this MUST be < 2^sizeof(size_t) / ( FLAC__MAX_CHANNELS * (FLAC__MAX_BITS_PER_SAMPLE/8) ) */ -#define CHUNK_OF_SAMPLES 2048 - -typedef struct { - uint32_t sample_rate; - uint32_t channels; - uint32_t bits_per_sample; /* width of sample point, including 'shift' bits, valid bps is bits_per_sample-shift */ - uint32_t shift; /* # of LSBs samples have been shifted left by */ - uint32_t bytes_per_wide_sample; /* for convenience, always == channels*((bps+7)/8), or 0 if N/A to input format (like FLAC) */ - FLAC__bool is_unsigned_samples; - FLAC__bool is_big_endian; - FLAC__uint32 channel_mask; -} SampleInfo; - -/* this is the client_data attached to the FLAC decoder when encoding from a FLAC file */ -typedef struct { - FLAC__off_t filesize; - const FLAC__byte *lookahead; - uint32_t lookahead_length; - size_t num_metadata_blocks; - FLAC__StreamMetadata *metadata_blocks[1024]; /*@@@ BAD MAGIC number */ - FLAC__uint64 samples_left_to_process; - FLAC__bool fatal_error; -} FLACDecoderData; - -typedef struct { -#if FLAC__HAS_OGG - FLAC__bool use_ogg; -#endif - FLAC__bool verify; - FLAC__bool is_stdout; - FLAC__bool outputfile_opened; /* true if we successfully opened the output file and we want it to be deleted if there is an error */ - const char *inbasefilename; - const char *infilename; - const char *outfilename; - - FLAC__bool treat_warnings_as_errors; - FLAC__bool continue_through_decode_errors; - FLAC__bool replay_gain; - FLAC__uint64 total_samples_to_encode; /* (i.e. "wide samples" aka "sample frames") WATCHOUT: may be 0 to mean 'unknown' */ - FLAC__uint64 unencoded_size; /* an estimate of the input size, only used in the progress indicator */ - FLAC__uint64 bytes_written; - FLAC__uint64 samples_written; -#if 0 /* in case time.h with clock() isn't available for some reason */ - uint32_t stats_frames_interval; - uint32_t old_frames_written; -#else - clock_t old_clock_t; -#endif - - SampleInfo info; - - FileFormat format; - union { - struct { - FLAC__uint64 data_bytes; - } iff; - struct { - FLAC__StreamDecoder *decoder; - FLACDecoderData client_data; - } flac; - } fmt; - - FLAC__StreamEncoder *encoder; - - FILE *fin; - FLAC__StreamMetadata *seek_table_template; - double progress, compression_ratio; -} EncoderSession; - -const int FLAC_ENCODE__DEFAULT_PADDING = 8192; - -static FLAC__bool is_big_endian_host_; - -#define UBUFFER_INT8_SIZE 0x10000 - -static union { - FLAC__int8 s8[UBUFFER_INT8_SIZE]; - FLAC__uint8 u8[UBUFFER_INT8_SIZE]; - FLAC__int16 s16[UBUFFER_INT8_SIZE/2]; - FLAC__uint16 u16[UBUFFER_INT8_SIZE/2]; - FLAC__int32 s32[UBUFFER_INT8_SIZE/4]; - FLAC__uint32 u32[UBUFFER_INT8_SIZE/4]; -} ubuffer; - - -static FLAC__int32 in_[FLAC__MAX_CHANNELS][CHUNK_OF_SAMPLES]; -static FLAC__int32 *input_[FLAC__MAX_CHANNELS]; - - -/* - * local routines - */ -static FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, FLAC__off_t infilesize, FILE *infile, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length); -static void EncoderSession_destroy(EncoderSession *e); -static int EncoderSession_finish_ok(EncoderSession *e, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail); -static int EncoderSession_finish_error(EncoderSession *e); -static FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t options); -static FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const buffer[], uint32_t samples); -static FLAC__bool EncoderSession_format_is_iff(const EncoderSession *e); -static FLAC__bool convert_to_seek_table_template(const char *requested_seek_points, int num_requested_seek_points, FLAC__StreamMetadata *cuesheet, EncoderSession *e); -static FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input); -static FLAC__bool verify_metadata(const EncoderSession *e, FLAC__StreamMetadata **metadata, uint32_t num_metadata); -static FLAC__bool format_input(FLAC__int32 *dest[], uint32_t wide_samples, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, uint32_t channels, uint32_t bps, uint32_t shift, size_t *channel_map); -static void encoder_progress_callback(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data); -static FLAC__StreamDecoderReadStatus flac_decoder_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); -static FLAC__StreamDecoderSeekStatus flac_decoder_seek_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data); -static FLAC__StreamDecoderTellStatus flac_decoder_tell_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); -static FLAC__StreamDecoderLengthStatus flac_decoder_length_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data); -static FLAC__bool flac_decoder_eof_callback(const FLAC__StreamDecoder *decoder, void *client_data); -static FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); -static void flac_decoder_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); -static void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); -static FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors); -static void print_stats(const EncoderSession *encoder_session); -static void print_error_with_init_status(const EncoderSession *e, const char *message, FLAC__StreamEncoderInitStatus init_status); -static void print_error_with_state(const EncoderSession *e, const char *message); -static void print_verify_error(EncoderSession *e); -static FLAC__bool read_bytes(FILE *f, FLAC__byte *buf, size_t n, FLAC__bool eof_ok, const char *fn); -static FLAC__bool read_uint16(FILE *f, FLAC__bool big_endian, FLAC__uint16 *val, const char *fn); -static FLAC__bool read_uint32(FILE *f, FLAC__bool big_endian, FLAC__uint32 *val, const char *fn); -static FLAC__bool read_uint64(FILE *f, FLAC__bool big_endian, FLAC__uint64 *val, const char *fn); -static FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, const char *fn); -static FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset); -static uint32_t count_channel_mask_bits(FLAC__uint32 mask); - -static FLAC__bool get_sample_info_raw(EncoderSession *e, encode_options_t options) -{ - e->info.sample_rate = options.format_options.raw.sample_rate; - e->info.channels = options.format_options.raw.channels; - e->info.bits_per_sample = options.format_options.raw.bps; - e->info.shift = 0; - e->info.bytes_per_wide_sample = options.format_options.raw.channels * ((options.format_options.raw.bps+7)/8); - e->info.is_unsigned_samples = options.format_options.raw.is_unsigned_samples; - e->info.is_big_endian = options.format_options.raw.is_big_endian; - e->info.channel_mask = 0; - - return true; -} - -static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t options) -{ - FLAC__bool got_fmt_chunk = false, got_data_chunk = false, got_ds64_chunk = false; - uint32_t sample_rate = 0, channels = 0, bps = 0, shift = 0, block_align = 0; - FLAC__uint32 channel_mask = 0; - FLAC__uint64 ds64_data_size = 0; - - e->info.is_unsigned_samples = false; - e->info.is_big_endian = false; - - if(e->format == FORMAT_WAVE64) { - /* - * lookahead[] already has "riff\x2E\x91\xCF\x11\xA5\xD6\x28\xDB", skip over remaining header - */ - if(!fskip_ahead(e->fin, 16+8+16-12)) { /* riff GUID + riff size + WAVE GUID - lookahead */ - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over remaining \"riff\" header\n", e->inbasefilename); - return false; - } - } - /* else lookahead[] already has "RIFFxxxxWAVE" or "RF64xxxxWAVE" */ - - while(!feof(e->fin) && !got_data_chunk) { - /* chunk IDs are 4 bytes for WAVE/RF64, 16 for Wave64 */ - /* for WAVE/RF64 we want the 5th char zeroed so we can treat it like a C string */ - char chunk_id[16] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' }; - - if(!read_bytes(e->fin, (FLAC__byte*)chunk_id, e->format==FORMAT_WAVE64?16:4, /*eof_ok=*/true, e->inbasefilename)) { - flac__utils_printf(stderr, 1, "%s: ERROR: incomplete chunk identifier\n", e->inbasefilename); - return false; - } - if(feof(e->fin)) - break; - - if(e->format == FORMAT_RF64 && !memcmp(chunk_id, "ds64", 4)) { /* RF64 64-bit sizes chunk */ - FLAC__uint32 xx, data_bytes; - - if(got_ds64_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: file has multiple 'ds64' chunks\n", e->inbasefilename); - return false; - } - if(got_fmt_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: 'ds64' chunk appears after 'fmt ' or 'data' chunk\n", e->inbasefilename); - return false; - } - - /* ds64 chunk size */ - if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) - return false; - data_bytes = xx; - if(data_bytes < 28) { - flac__utils_printf(stderr, 1, "%s: ERROR: non-standard 'ds64' chunk has length = %u\n", e->inbasefilename, (uint32_t)data_bytes); - return false; - } - if(data_bytes & 1) /* should never happen, but enforce WAVE alignment rules */ - data_bytes++; - - /* RIFF 64-bit size, lo/hi */ - if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) - return false; - if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) - return false; - - /* 'data' 64-bit size */ - if(!read_uint64(e->fin, /*big_endian=*/false, &ds64_data_size, e->inbasefilename)) - return false; - - data_bytes -= 16; - - /* skip any extra data in the ds64 chunk */ - if(!fskip_ahead(e->fin, data_bytes)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over extra 'ds64' data\n", e->inbasefilename); - return false; - } - - got_ds64_chunk = true; - } - else if( - !memcmp(chunk_id, "fmt ", 4) && - (e->format!=FORMAT_WAVE64 || !memcmp(chunk_id, "fmt \xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)) - ) { /* format chunk */ - FLAC__uint16 x; - FLAC__uint32 xx, data_bytes; - FLAC__uint16 wFormatTag; /* wFormatTag word from the 'fmt ' chunk */ - - if(got_fmt_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: file has multiple 'fmt ' chunks\n", e->inbasefilename); - return false; - } - - /* see - * http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html - * http://windowssdk.msdn.microsoft.com/en-us/library/ms713497.aspx - * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/audio_r/hh/Audio_r/aud-prop_d40f094e-44f9-4baa-8a15-03e4fb369501.xml.asp - * - * WAVEFORMAT is - * 4 byte: chunk size - * 2 byte: format type: 1 for WAVE_FORMAT_PCM, 65534 for WAVE_FORMAT_EXTENSIBLE - * 2 byte: # channels - * 4 byte: sample rate (Hz) - * 4 byte: avg bytes per sec - * 2 byte: block align - * 2 byte: bits per sample (not necessarily all significant) - * WAVEFORMATEX adds - * 2 byte: extension size in bytes (usually 0 for WAVEFORMATEX and 22 for WAVEFORMATEXTENSIBLE with PCM) - * WAVEFORMATEXTENSIBLE adds - * 2 byte: valid bits per sample - * 4 byte: channel mask - * 16 byte: subformat GUID, first 2 bytes have format type, 1 being PCM - * - * Current spec says WAVEFORMATEX with PCM must have bps == 8 or 16, or any multiple of 8 for WAVEFORMATEXTENSIBLE. - * Lots of old broken WAVEs/apps have don't follow it, e.g. 20 bps but a block align of 3/6 for mono/stereo. - * - * Block align for WAVE_FORMAT_PCM or WAVE_FORMAT_EXTENSIBLE is also supposed to be channels*bps/8 - * - * If the channel mask has more set bits than # of channels, the extra MSBs are ignored. - * If the channel mask has less set bits than # of channels, the extra channels are unassigned to any speaker. - * - * Data is supposed to be uint32_t for bps <= 8 else signed. - */ - - /* fmt chunk size */ - if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) - return false; - data_bytes = xx; - if(e->format == FORMAT_WAVE64) { - /* other half of the size field should be 0 */ - if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) - return false; - if(xx) { - flac__utils_printf(stderr, 1, "%s: ERROR: freakishly large Wave64 'fmt ' chunk has length = 0x%08X%08X\n", e->inbasefilename, (uint32_t)xx, (uint32_t)data_bytes); - return false; - } - /* subtract size of header */ - if (data_bytes < 16+8) { - flac__utils_printf(stderr, 1, "%s: ERROR: freakishly small Wave64 'fmt ' chunk has length = 0x%08X%08X\n", e->inbasefilename, (uint32_t)xx, (uint32_t)data_bytes); - return false; - } - data_bytes -= (16+8); - } - if(data_bytes < 16 || data_bytes > (UINT32_MAX-8)) { - flac__utils_printf(stderr, 1, "%s: ERROR: non-standard 'fmt ' chunk has length = %u\n", e->inbasefilename, (uint32_t)data_bytes); - return false; - } - if(e->format != FORMAT_WAVE64) { - if(data_bytes & 1) /* should never happen, but enforce WAVE alignment rules */ - data_bytes++; - } - else { /* Wave64 */ - data_bytes = (data_bytes+7) & (~7u); /* should never happen, but enforce Wave64 alignment rules */ - } - - /* format code */ - if(!read_uint16(e->fin, /*big_endian=*/false, &wFormatTag, e->inbasefilename)) - return false; - if(wFormatTag != 1 /*WAVE_FORMAT_PCM*/ && wFormatTag != 65534 /*WAVE_FORMAT_EXTENSIBLE*/) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported format type %u\n", e->inbasefilename, (uint32_t)wFormatTag); - return false; - } - - /* number of channels */ - if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) - return false; - channels = (uint32_t)x; - - /* sample rate */ - if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) - return false; - sample_rate = xx; - - /* avg bytes per second (ignored) */ - if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) - return false; - /* block align */ - if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) - return false; - block_align = x; - /* bits per sample */ - if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) - return false; - bps = (uint32_t)x; - - e->info.is_unsigned_samples = (bps <= 8); - - if(wFormatTag == 1) { - if(bps != 8 && bps != 16) { - if(bps == 24 || bps == 32) { - /* let these slide with a warning since they're unambiguous */ - flac__utils_printf(stderr, 1, "%s: WARNING: legacy WAVE file has format type %u but bits-per-sample=%u\n", e->inbasefilename, (uint32_t)wFormatTag, bps); - if(e->treat_warnings_as_errors) - return false; - } - else { - /* @@@ we could add an option to specify left- or right-justified blocks so we knew how to set 'shift' */ - flac__utils_printf(stderr, 1, "%s: ERROR: legacy WAVE file has format type %u but bits-per-sample=%u\n", e->inbasefilename, (uint32_t)wFormatTag, bps); - return false; - } - } - if((bps+7)/8 * channels != block_align) { - flac__utils_printf(stderr, 1, "%s: ERROR: legacy WAVE file has block alignment=%u, bits-per-sample=%u, channels=%u\n", e->inbasefilename, (uint32_t)wFormatTag, block_align, bps, channels); - return false; - } - if(channels > 2 && !options.channel_map_none) { - flac__utils_printf(stderr, 1, "%s: ERROR: WAVE has >2 channels but is not WAVE_FORMAT_EXTENSIBLE; cannot assign channels\n", e->inbasefilename); - return false; - } - FLAC__ASSERT(data_bytes >= 16); - data_bytes -= 16; - } - else { - if(data_bytes < 40) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with size %u\n", e->inbasefilename, (uint32_t)data_bytes); - return false; - } - /* cbSize */ - if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) - return false; - if(x < 22) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with cbSize %u\n", e->inbasefilename, (uint32_t)x); - return false; - } - /* valid bps */ - if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) - return false; - if((uint32_t)x > bps) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with wValidBitsPerSample (%u) > wBitsPerSample (%u)\n", e->inbasefilename, (uint32_t)x, bps); - return false; - } - shift = bps - (uint32_t)x; - /* channel mask */ - if(!read_uint32(e->fin, /*big_endian=*/false, &channel_mask, e->inbasefilename)) - return false; - - if(count_channel_mask_bits(channel_mask) > channels) { - flac__utils_printf(stderr, 1, "%s: WARNING: WAVEFORMATEXTENSIBLE chunk: channel mask 0x%04X has extra bits for non-existant channels (#channels=%u)\n", e->inbasefilename, (uint32_t)channel_mask, channels); - if(e->treat_warnings_as_errors) - return false; - } - /* first part of GUID */ - if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) - return false; - if(x != 1) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported WAVEFORMATEXTENSIBLE chunk with non-PCM format %u\n", e->inbasefilename, (uint32_t)x); - return false; - } - data_bytes -= 26; - } - - e->info.bytes_per_wide_sample = channels * (bps / 8); - - /* skip any extra data in the fmt chunk */ - if(!fskip_ahead(e->fin, data_bytes)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over extra 'fmt' data\n", e->inbasefilename); - return false; - } - - got_fmt_chunk = true; - } - else if( - !memcmp(chunk_id, "data", 4) && - (e->format!=FORMAT_WAVE64 || !memcmp(chunk_id, "data\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)) - ) { /* data chunk */ - FLAC__uint32 xx; - FLAC__uint64 data_bytes; - - if(!got_fmt_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: got 'data' chunk before 'fmt' chunk\n", e->inbasefilename); - return false; - } - - /* data size */ - if(e->format != FORMAT_WAVE64) { - if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) - return false; - data_bytes = xx; - } - else { /* Wave64 */ - if(!read_uint64(e->fin, /*big_endian=*/false, &data_bytes, e->inbasefilename)) - return false; - /* subtract size of header */ - if (data_bytes < 16+8) { - flac__utils_printf(stderr, 1, "%s: ERROR: freakishly small Wave64 'data' chunk has length = 0x00000000%08X\n", e->inbasefilename, (uint32_t)data_bytes); - return false; - } - data_bytes -= (16+8); - } - if(e->format == FORMAT_RF64) { - if(!got_ds64_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: RF64 file has no 'ds64' chunk before 'data' chunk\n", e->inbasefilename); - return false; - } - if(data_bytes == 0xffffffff) - data_bytes = ds64_data_size; - } - if(options.ignore_chunk_sizes) { - if(data_bytes) { - flac__utils_printf(stderr, 1, "%s: WARNING: 'data' chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id); - if(e->treat_warnings_as_errors) - return false; - } - data_bytes = (FLAC__uint64)0 - (FLAC__uint64)e->info.bytes_per_wide_sample; /* max out data_bytes; we'll use EOF as signal to stop reading */ - } - else if(0 == data_bytes) { - flac__utils_printf(stderr, 1, "%s: ERROR: 'data' chunk has size of 0\n", e->inbasefilename); - return false; - } - - e->fmt.iff.data_bytes = data_bytes; - - got_data_chunk = true; - break; - } - else { - FLAC__uint32 xx; - FLAC__uint64 skip; - if(!options.format_options.iff.foreign_metadata) { - if(e->format != FORMAT_WAVE64) - flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown chunk '%s' (use --keep-foreign-metadata to keep)\n", e->inbasefilename, chunk_id); - else - flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown chunk %02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X (use --keep-foreign-metadata to keep)\n", - e->inbasefilename, - (uint32_t)((const uint8_t *)chunk_id)[3], - (uint32_t)((const uint8_t *)chunk_id)[2], - (uint32_t)((const uint8_t *)chunk_id)[1], - (uint32_t)((const uint8_t *)chunk_id)[0], - (uint32_t)((const uint8_t *)chunk_id)[5], - (uint32_t)((const uint8_t *)chunk_id)[4], - (uint32_t)((const uint8_t *)chunk_id)[7], - (uint32_t)((const uint8_t *)chunk_id)[6], - (uint32_t)((const uint8_t *)chunk_id)[9], - (uint32_t)((const uint8_t *)chunk_id)[8], - (uint32_t)((const uint8_t *)chunk_id)[10], - (uint32_t)((const uint8_t *)chunk_id)[11], - (uint32_t)((const uint8_t *)chunk_id)[12], - (uint32_t)((const uint8_t *)chunk_id)[13], - (uint32_t)((const uint8_t *)chunk_id)[14], - (uint32_t)((const uint8_t *)chunk_id)[15] - ); - if(e->treat_warnings_as_errors) - return false; - } - - /* chunk size */ - if(e->format != FORMAT_WAVE64) { - if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) - return false; - skip = xx; - skip += skip & 1; - } - else { /* Wave64 */ - if(!read_uint64(e->fin, /*big_endian=*/false, &skip, e->inbasefilename)) - return false; - skip = (skip+7) & (~(FLAC__uint64)7); - /* subtract size of header */ - if (skip < 16+8) { - flac__utils_printf(stderr, 1, "%s: ERROR: freakishly small Wave64 chunk has length = 0x00000000%08X\n", e->inbasefilename, (uint32_t)skip); - return false; - } - skip -= (16+8); - } - if(skip) { - if(!fskip_ahead(e->fin, skip)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over chunk\n", e->inbasefilename); - return false; - } - } - } - } - - if(!got_fmt_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: didn't find fmt chunk\n", e->inbasefilename); - return false; - } - if(!got_data_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: didn't find data chunk\n", e->inbasefilename); - return false; - } - - e->info.sample_rate = sample_rate; - e->info.channels = channels; - e->info.bits_per_sample = bps; - e->info.shift = shift; - e->info.channel_mask = channel_mask; - - return true; -} - -static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t options) -{ - FLAC__bool got_comm_chunk = false, got_ssnd_chunk = false; - uint32_t sample_rate = 0, channels = 0, bps = 0, shift = 0; - FLAC__uint64 sample_frames = 0; - FLAC__uint32 channel_mask = 0; - - e->info.is_unsigned_samples = false; - e->info.is_big_endian = true; - - /* - * lookahead[] already has "FORMxxxxAIFF", do chunks - */ - while(!feof(e->fin) && !got_ssnd_chunk) { - char chunk_id[5] = { '\0', '\0', '\0', '\0', '\0' }; /* one extra byte for terminating NUL so we can also treat it like a C string */ - if(!read_bytes(e->fin, (FLAC__byte*)chunk_id, 4, /*eof_ok=*/true, e->inbasefilename)) { - flac__utils_printf(stderr, 1, "%s: ERROR: incomplete chunk identifier\n", e->inbasefilename); - return false; - } - if(feof(e->fin)) - break; - - if(!memcmp(chunk_id, "COMM", 4)) { /* common chunk */ - FLAC__uint16 x; - FLAC__uint32 xx; - uint64_t skip; - const FLAC__bool is_aifc = e->format == FORMAT_AIFF_C; - const FLAC__uint32 minimum_comm_size = (is_aifc? 22 : 18); - - if(got_comm_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: file has multiple 'COMM' chunks\n", e->inbasefilename); - return false; - } - - /* COMM chunk size */ - if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) - return false; - else if(xx < minimum_comm_size) { - flac__utils_printf(stderr, 1, "%s: ERROR: non-standard %s 'COMM' chunk has length = %u\n", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (uint32_t)xx); - return false; - } - else if(!is_aifc && xx != minimum_comm_size) { - flac__utils_printf(stderr, 1, "%s: WARNING: non-standard %s 'COMM' chunk has length = %u, expected %u\n", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (uint32_t)xx, minimum_comm_size); - if(e->treat_warnings_as_errors) - return false; - } - skip = (xx-minimum_comm_size)+(xx & 1); - - /* number of channels */ - if(!read_uint16(e->fin, /*big_endian=*/true, &x, e->inbasefilename)) - return false; - channels = (uint32_t)x; - if(channels > 2 && !options.channel_map_none) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported number of channels %u for AIFF\n", e->inbasefilename, channels); - return false; - } - - /* number of sample frames */ - if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) - return false; - sample_frames = xx; - - /* bits per sample */ - if(!read_uint16(e->fin, /*big_endian=*/true, &x, e->inbasefilename)) - return false; - bps = (uint32_t)x; - shift = (bps%8)? 8-(bps%8) : 0; /* SSND data is always byte-aligned, left-justified but format_input() will double-check */ - bps += shift; - - /* sample rate */ - if(!read_sane_extended(e->fin, &xx, e->inbasefilename)) - return false; - sample_rate = xx; - - /* check compression type for AIFF-C */ - if(is_aifc) { - if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) - return false; - if(xx == 0x736F7774) /* "sowt" */ - e->info.is_big_endian = false; - else if(xx == 0x4E4F4E45) /* "NONE" */ - ; /* nothing to do, we already default to big-endian */ - else { - flac__utils_printf(stderr, 1, "%s: ERROR: can't handle AIFF-C compression type \"%c%c%c%c\"\n", e->inbasefilename, (char)(xx>>24), (char)((xx>>16)&8), (char)((xx>>8)&8), (char)(xx&8)); - return false; - } - } - - /* set channel mapping */ - /* FLAC order follows SMPTE and WAVEFORMATEXTENSIBLE but with fewer channels, which are: */ - /* front left, front right, center, LFE, back left, back right, surround left, surround right */ - /* specs say the channel ordering is: - * 1 2 3 4 5 6 - * ___________________________________________________ - * 2 stereo l r - * 3 l r c - * 4 l c r S - * quad (ambiguous with 4ch) Fl Fr Bl Br - * 5 Fl Fr Fc Sl Sr - * 6 l lc c r rc S - * l:left r:right c:center Fl:front-left Fr:front-right Bl:back-left Br:back-right Lc:left-center Rc:right-center S:surround - * so we only have unambiguous mappings for 2, 3, and 5 channels - */ - if( - options.channel_map_none || - channels == 1 || /* 1 channel: (mono) */ - channels == 2 || /* 2 channels: left, right */ - channels == 3 || /* 3 channels: left, right, center */ - channels == 5 /* 5 channels: front left, front right, center, surround left, surround right */ - ) { - /* keep default channel order */ - } - else { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported number of channels %u for AIFF\n", e->inbasefilename, channels); - return false; - } - - e->info.bytes_per_wide_sample = channels * (bps / 8); - - /* skip any extra data in the COMM chunk */ - if(!fskip_ahead(e->fin, skip)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over extra COMM data\n", e->inbasefilename); - return false; - } - - got_comm_chunk = true; - } - else if(!memcmp(chunk_id, "SSND", 4) && !got_ssnd_chunk) { /* sound data chunk */ - FLAC__uint32 xx; - FLAC__uint64 data_bytes; - uint32_t offset = 0; - - if(!got_comm_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: got 'SSND' chunk before 'COMM' chunk\n", e->inbasefilename); - return false; - } - - /* SSND chunk size */ - if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) - return false; - data_bytes = xx; - if(options.ignore_chunk_sizes) { - if(data_bytes) { - flac__utils_printf(stderr, 1, "%s: WARNING: 'SSND' chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id); - if(e->treat_warnings_as_errors) - return false; - } - data_bytes = (FLAC__uint64)0 - (FLAC__uint64)e->info.bytes_per_wide_sample; /* max out data_bytes; we'll use EOF as signal to stop reading */ - } - else if(data_bytes <= 8) { - flac__utils_printf(stderr, 1, "%s: ERROR: 'SSND' chunk has size <= 8\n", e->inbasefilename); - return false; - } - else { - data_bytes -= 8; /* discount the offset and block size fields */ - } - - /* offset */ - if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) - return false; - offset = xx; - data_bytes -= offset; - - /* block size */ - if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) - return false; - if(xx && !options.ignore_chunk_sizes) - data_bytes -= (xx - (data_bytes % xx)); - if(options.ignore_chunk_sizes) { - if(xx) { - flac__utils_printf(stderr, 1, "%s: WARNING: 'SSND' chunk has non-zero blocksize, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id); - if(e->treat_warnings_as_errors) - return false; - } - } - - /* skip any SSND offset bytes */ - if(!fskip_ahead(e->fin, offset)) { - flac__utils_printf(stderr, 1, "%s: ERROR: skipping offset in SSND chunk\n", e->inbasefilename); - return false; - } - - e->fmt.iff.data_bytes = data_bytes; - - got_ssnd_chunk = true; - } - else { - FLAC__uint32 xx; - if(!options.format_options.iff.foreign_metadata) { - flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown chunk '%s' (use --keep-foreign-metadata to keep)\n", e->inbasefilename, chunk_id); - if(e->treat_warnings_as_errors) - return false; - } - - /* chunk size */ - if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) - return false; - else { - uint64_t skip = xx + (xx & 1); - - FLAC__ASSERT(skip <= LONG_MAX); - if(!fskip_ahead(e->fin, skip)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over chunk\n", e->inbasefilename); - return false; - } - } - } - } - - if(!got_comm_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: didn't find COMM chunk\n", e->inbasefilename); - return false; - } - if(!got_ssnd_chunk && sample_frames) { - flac__utils_printf(stderr, 1, "%s: ERROR: didn't find SSND chunk\n", e->inbasefilename); - return false; - } - - e->info.sample_rate = sample_rate; - e->info.channels = channels; - e->info.bits_per_sample = bps; - e->info.shift = shift; - e->info.channel_mask = channel_mask; - - return true; -} - -static FLAC__bool get_sample_info_flac(EncoderSession *e) -{ - if (!( - FLAC__stream_decoder_set_md5_checking(e->fmt.flac.decoder, false) && - FLAC__stream_decoder_set_metadata_respond_all(e->fmt.flac.decoder) - )) { - flac__utils_printf(stderr, 1, "%s: ERROR: setting up decoder for FLAC input\n", e->inbasefilename); - return false; - } - - if (e->format == FORMAT_OGGFLAC) { - if (FLAC__stream_decoder_init_ogg_stream(e->fmt.flac.decoder, flac_decoder_read_callback, flac_decoder_seek_callback, flac_decoder_tell_callback, flac_decoder_length_callback, flac_decoder_eof_callback, flac_decoder_write_callback, flac_decoder_metadata_callback, flac_decoder_error_callback, /*client_data=*/e) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - flac__utils_printf(stderr, 1, "%s: ERROR: initializing decoder for Ogg FLAC input, state = %s\n", e->inbasefilename, FLAC__stream_decoder_get_resolved_state_string(e->fmt.flac.decoder)); - return false; - } - } - else if (FLAC__stream_decoder_init_stream(e->fmt.flac.decoder, flac_decoder_read_callback, flac_decoder_seek_callback, flac_decoder_tell_callback, flac_decoder_length_callback, flac_decoder_eof_callback, flac_decoder_write_callback, flac_decoder_metadata_callback, flac_decoder_error_callback, /*client_data=*/e) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - flac__utils_printf(stderr, 1, "%s: ERROR: initializing decoder for FLAC input, state = %s\n", e->inbasefilename, FLAC__stream_decoder_get_resolved_state_string(e->fmt.flac.decoder)); - return false; - } - - if (!FLAC__stream_decoder_process_until_end_of_metadata(e->fmt.flac.decoder) || e->fmt.flac.client_data.fatal_error) { - if (e->fmt.flac.client_data.fatal_error) - flac__utils_printf(stderr, 1, "%s: ERROR: out of memory or too many metadata blocks while reading metadata in FLAC input\n", e->inbasefilename); - else - flac__utils_printf(stderr, 1, "%s: ERROR: reading metadata in FLAC input, state = %s\n", e->inbasefilename, FLAC__stream_decoder_get_resolved_state_string(e->fmt.flac.decoder)); - return false; - } - - if (e->fmt.flac.client_data.num_metadata_blocks == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: reading metadata in FLAC input, got no metadata blocks\n", e->inbasefilename); - return false; - } - else if (e->fmt.flac.client_data.metadata_blocks[0]->type != FLAC__METADATA_TYPE_STREAMINFO) { - flac__utils_printf(stderr, 1, "%s: ERROR: reading metadata in FLAC input, first metadata block is not STREAMINFO\n", e->inbasefilename); - return false; - } - else if (e->fmt.flac.client_data.metadata_blocks[0]->data.stream_info.total_samples == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: FLAC input has STREAMINFO with unknown total samples which is not supported\n", e->inbasefilename); - return false; - } - - e->info.sample_rate = e->fmt.flac.client_data.metadata_blocks[0]->data.stream_info.sample_rate; - e->info.channels = e->fmt.flac.client_data.metadata_blocks[0]->data.stream_info.channels; - e->info.bits_per_sample = e->fmt.flac.client_data.metadata_blocks[0]->data.stream_info.bits_per_sample; - e->info.shift = 0; - e->info.bytes_per_wide_sample = 0; - e->info.is_unsigned_samples = false; /* not applicable for FLAC input */ - e->info.is_big_endian = false; /* not applicable for FLAC input */ - e->info.channel_mask = 0; - - return true; -} - -/* - * public routines - */ -int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length, encode_options_t options) -{ - EncoderSession encoder_session; - size_t channel_map[FLAC__MAX_CHANNELS]; - - if(!EncoderSession_construct(&encoder_session, options, infilesize, infile, infilename, outfilename, lookahead, lookahead_length)) - return 1; - - /* initialize default channel map that preserves channel order */ - { - size_t i; - for(i = 0; i < sizeof(channel_map)/sizeof(channel_map[0]); i++) - channel_map[i] = i; - } - - /* read foreign metadata if requested */ - if(EncoderSession_format_is_iff(&encoder_session) && options.format_options.iff.foreign_metadata) { - const char *error; - if(!( - options.format == FORMAT_WAVE || options.format == FORMAT_RF64? - flac__foreign_metadata_read_from_wave(options.format_options.iff.foreign_metadata, infilename, &error) : - options.format == FORMAT_WAVE64? - flac__foreign_metadata_read_from_wave64(options.format_options.iff.foreign_metadata, infilename, &error) : - flac__foreign_metadata_read_from_aiff(options.format_options.iff.foreign_metadata, infilename, &error) - )) { - if(options.relaxed_foreign_metadata_handling) { - flac__utils_printf(stderr, 1, "%s: WARNING reading foreign metadata: %s\n", encoder_session.inbasefilename, error); - if(encoder_session.treat_warnings_as_errors) - return EncoderSession_finish_error(&encoder_session); - } - else { - flac__utils_printf(stderr, 1, "%s: ERROR reading foreign metadata: %s\n", encoder_session.inbasefilename, error); - return EncoderSession_finish_error(&encoder_session); - } - } - } - - /* initialize encoder session with info about the audio (channels/bps/resolution/endianness/etc) */ - switch(options.format) { - case FORMAT_RAW: - if(!get_sample_info_raw(&encoder_session, options)) - return EncoderSession_finish_error(&encoder_session); - break; - case FORMAT_WAVE: - case FORMAT_WAVE64: - case FORMAT_RF64: - if(!get_sample_info_wave(&encoder_session, options)) - return EncoderSession_finish_error(&encoder_session); - break; - case FORMAT_AIFF: - case FORMAT_AIFF_C: - if(!get_sample_info_aiff(&encoder_session, options)) - return EncoderSession_finish_error(&encoder_session); - break; - case FORMAT_FLAC: - case FORMAT_OGGFLAC: - /* - * set up FLAC decoder for the input - */ - if (0 == (encoder_session.fmt.flac.decoder = FLAC__stream_decoder_new())) { - flac__utils_printf(stderr, 1, "%s: ERROR: creating decoder for FLAC input\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - if(!get_sample_info_flac(&encoder_session)) - return EncoderSession_finish_error(&encoder_session); - break; - default: - FLAC__ASSERT(0); - /* double protection */ - return EncoderSession_finish_error(&encoder_session); - } - - /* some more checks */ - if(encoder_session.info.channels == 0 || encoder_session.info.channels > FLAC__MAX_CHANNELS) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported number of channels %u\n", encoder_session.inbasefilename, encoder_session.info.channels); - return EncoderSession_finish_error(&encoder_session); - } - if(!FLAC__format_sample_rate_is_valid(encoder_session.info.sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported sample rate %u\n", encoder_session.inbasefilename, encoder_session.info.sample_rate); - return EncoderSession_finish_error(&encoder_session); - } - if(encoder_session.info.bits_per_sample-encoder_session.info.shift < 4 || encoder_session.info.bits_per_sample-encoder_session.info.shift > 32) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported bits-per-sample %u\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); - return EncoderSession_finish_error(&encoder_session); - } - - { - FLAC__uint64 total_samples_in_input; /* WATCHOUT: may be 0 to mean "unknown" */ - FLAC__uint64 skip; - FLAC__uint64 until; /* a value of 0 mean end-of-stream (i.e. --until=-0) */ - uint32_t consecutive_eos_count = 0; - - switch(options.format) { - case FORMAT_RAW: - if(infilesize < 0) - total_samples_in_input = 0; - else - total_samples_in_input = (FLAC__uint64)infilesize / encoder_session.info.bytes_per_wide_sample; - break; - case FORMAT_WAVE: - case FORMAT_WAVE64: - case FORMAT_RF64: - case FORMAT_AIFF: - case FORMAT_AIFF_C: - /* truncation in the division removes any padding byte that was counted in encoder_session.fmt.iff.data_bytes */ - total_samples_in_input = encoder_session.fmt.iff.data_bytes / encoder_session.info.bytes_per_wide_sample; - - /* check for chunks trailing the audio data */ - if(!options.ignore_chunk_sizes && !options.format_options.iff.foreign_metadata - && infilesize != (FLAC__off_t)(-1)) { - FLAC__off_t current_position = ftello(encoder_session.fin); - if(current_position > 0) { - FLAC__uint64 end_of_data_chunk = current_position + encoder_session.fmt.iff.data_bytes; - if(end_of_data_chunk < (FLAC__uint64)infilesize) { - flac__utils_printf(stderr, 1, "%s: WARNING: there is data trailing the audio data. Use --keep-foreign-metadata or --ignore-chunk-sizes to keep it\n", encoder_session.inbasefilename); - if(encoder_session.treat_warnings_as_errors) - return EncoderSession_finish_error(&encoder_session); - } - else if(end_of_data_chunk > (FLAC__uint64)infilesize) { - flac__utils_printf(stderr, 1, "%s: WARNING: the length of the data chunk overruns the end of the file. Please consult the manual on the --ignore-chunk-sizes option\n", encoder_session.inbasefilename); - if(encoder_session.treat_warnings_as_errors) - return EncoderSession_finish_error(&encoder_session); - } - } - } - break; - case FORMAT_FLAC: - case FORMAT_OGGFLAC: - total_samples_in_input = encoder_session.fmt.flac.client_data.metadata_blocks[0]->data.stream_info.total_samples; - break; - default: - FLAC__ASSERT(0); - /* double protection */ - return EncoderSession_finish_error(&encoder_session); - } - - /* - * now that we know the sample rate, canonicalize the - * --skip string to an absolute sample number: - */ - if(!flac__utils_canonicalize_skip_until_specification(&options.skip_specification, encoder_session.info.sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR: value of --skip is too large\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); - return EncoderSession_finish_error(&encoder_session); - } - FLAC__ASSERT(options.skip_specification.value.samples >= 0); - skip = (FLAC__uint64)options.skip_specification.value.samples; - - /* - * now that we possibly know the input size, canonicalize the - * --until string to an absolute sample number: - */ - if(!canonicalize_until_specification(&options.until_specification, encoder_session.inbasefilename, encoder_session.info.sample_rate, skip, total_samples_in_input)) - return EncoderSession_finish_error(&encoder_session); - until = (FLAC__uint64)options.until_specification.value.samples; - - /* adjust encoding parameters based on skip and until values */ - switch(options.format) { - case FORMAT_RAW: - FLAC__ASSERT(sizeof(FLAC__off_t) == 8); - if(skip >= INT64_MAX / encoder_session.info.bytes_per_wide_sample) { - flac__utils_printf(stderr, 1, "%s: ERROR: value of --skip is too large\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); - return EncoderSession_finish_error(&encoder_session); - } - infilesize -= (FLAC__off_t)skip * encoder_session.info.bytes_per_wide_sample; - encoder_session.total_samples_to_encode = total_samples_in_input - skip; - break; - case FORMAT_WAVE: - case FORMAT_WAVE64: - case FORMAT_RF64: - case FORMAT_AIFF: - case FORMAT_AIFF_C: - FLAC__ASSERT(sizeof(FLAC__off_t) == 8); - if(skip >= INT64_MAX / encoder_session.info.bytes_per_wide_sample) { - flac__utils_printf(stderr, 1, "%s: ERROR: value of --skip is too large\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); - return EncoderSession_finish_error(&encoder_session); - } - encoder_session.fmt.iff.data_bytes -= skip * encoder_session.info.bytes_per_wide_sample; - if(options.ignore_chunk_sizes) { - encoder_session.total_samples_to_encode = 0; - FLAC__ASSERT(0 == until); - } - else { - encoder_session.total_samples_to_encode = total_samples_in_input - skip; - } - break; - case FORMAT_FLAC: - case FORMAT_OGGFLAC: - encoder_session.total_samples_to_encode = total_samples_in_input - skip; - break; - default: - FLAC__ASSERT(0); - /* double protection */ - return EncoderSession_finish_error(&encoder_session); - } - if(until > 0) { - const FLAC__uint64 trim = total_samples_in_input - until; - FLAC__ASSERT(total_samples_in_input > 0); - if(options.format == FORMAT_RAW) - infilesize -= (FLAC__off_t)trim * encoder_session.info.bytes_per_wide_sample; - else if(EncoderSession_format_is_iff(&encoder_session)) - encoder_session.fmt.iff.data_bytes -= trim * encoder_session.info.bytes_per_wide_sample; - encoder_session.total_samples_to_encode -= trim; - } - switch(options.format) { - case FORMAT_RAW: - encoder_session.unencoded_size = encoder_session.total_samples_to_encode * encoder_session.info.bytes_per_wide_sample; - break; - case FORMAT_WAVE: - /* +44 for the size of the WAVE headers; this is just an estimate for the progress indicator and doesn't need to be exact */ - encoder_session.unencoded_size = encoder_session.total_samples_to_encode * encoder_session.info.bytes_per_wide_sample + 44; - break; - case FORMAT_WAVE64: - /* +44 for the size of the WAVE headers; this is just an estimate for the progress indicator and doesn't need to be exact */ - encoder_session.unencoded_size = encoder_session.total_samples_to_encode * encoder_session.info.bytes_per_wide_sample + 104; - break; - case FORMAT_RF64: - /* +72 for the size of the RF64 headers; this is just an estimate for the progress indicator and doesn't need to be exact */ - encoder_session.unencoded_size = encoder_session.total_samples_to_encode * encoder_session.info.bytes_per_wide_sample + 80; - break; - case FORMAT_AIFF: - case FORMAT_AIFF_C: - /* +54 for the size of the AIFF headers; this is just an estimate for the progress indicator and doesn't need to be exact */ - encoder_session.unencoded_size = encoder_session.total_samples_to_encode * encoder_session.info.bytes_per_wide_sample + 54; - break; - case FORMAT_FLAC: - case FORMAT_OGGFLAC: - if(infilesize < 0) - /* if we don't know, use 0 as hint to progress indicator (which is the only place this is used): */ - encoder_session.unencoded_size = 0; - else if(skip == 0 && until == 0) - encoder_session.unencoded_size = (FLAC__uint64)infilesize; - else if(total_samples_in_input) - encoder_session.unencoded_size = (FLAC__uint64)infilesize * encoder_session.total_samples_to_encode / total_samples_in_input; - else - encoder_session.unencoded_size = (FLAC__uint64)infilesize; - break; - default: - FLAC__ASSERT(0); - /* double protection */ - return EncoderSession_finish_error(&encoder_session); - } - - if(encoder_session.total_samples_to_encode == 0) { - encoder_session.unencoded_size = 0; - flac__utils_printf(stderr, 2, "(No runtime statistics possible; please wait for encoding to finish...)\n"); - } - - if(options.format == FORMAT_FLAC || options.format == FORMAT_OGGFLAC) - encoder_session.fmt.flac.client_data.samples_left_to_process = encoder_session.total_samples_to_encode; - - stats_new_file(); - /* init the encoder */ - if(!EncoderSession_init_encoder(&encoder_session, options)) - return EncoderSession_finish_error(&encoder_session); - - /* skip over any samples as requested */ - if(skip > 0) { - switch(options.format) { - case FORMAT_RAW: - { - uint32_t skip_bytes = encoder_session.info.bytes_per_wide_sample * (uint32_t)skip; - if(skip_bytes > lookahead_length) { - skip_bytes -= lookahead_length; - lookahead_length = 0; - if(!fskip_ahead(encoder_session.fin, skip_bytes)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - } - else { - lookahead += skip_bytes; - lookahead_length -= skip_bytes; - } - } - break; - case FORMAT_WAVE: - case FORMAT_WAVE64: - case FORMAT_RF64: - case FORMAT_AIFF: - case FORMAT_AIFF_C: - if(!fskip_ahead(encoder_session.fin, skip * encoder_session.info.bytes_per_wide_sample)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - break; - case FORMAT_FLAC: - case FORMAT_OGGFLAC: - /* - * have to wait until the FLAC encoder is set up for writing - * before any seeking in the input FLAC file, because the seek - * itself will usually call the decoder's write callback, and - * our decoder's write callback passes samples to our FLAC - * encoder - */ - if(!FLAC__stream_decoder_seek_absolute(encoder_session.fmt.flac.decoder, skip)) { - flac__utils_printf(stderr, 1, "%s: ERROR while skipping samples, FLAC decoder state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); - return EncoderSession_finish_error(&encoder_session); - } - break; - default: - FLAC__ASSERT(0); - /* double protection */ - return EncoderSession_finish_error(&encoder_session); - } - } - - /* - * now do samples from the file - */ - switch(options.format) { - case FORMAT_RAW: - if(infilesize < 0) { - size_t bytes_read; - while(!feof(infile)) { - if(lookahead_length > 0) { - FLAC__ASSERT(lookahead_length < CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample); - memcpy(ubuffer.u8, lookahead, lookahead_length); - bytes_read = fread(ubuffer.u8+lookahead_length, sizeof(uint8_t), CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample - lookahead_length, infile) + lookahead_length; - if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - lookahead_length = 0; - } - else - bytes_read = fread(ubuffer.u8, sizeof(uint8_t), CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample, infile); - - if(bytes_read == 0) { - if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - } - else if(bytes_read % encoder_session.info.bytes_per_wide_sample != 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - else { - uint32_t wide_samples = bytes_read / encoder_session.info.bytes_per_wide_sample; - if(!format_input(input_, wide_samples, encoder_session.info.is_big_endian, encoder_session.info.is_unsigned_samples, encoder_session.info.channels, encoder_session.info.bits_per_sample, encoder_session.info.shift, channel_map)) - return EncoderSession_finish_error(&encoder_session); - - if(!EncoderSession_process(&encoder_session, (const FLAC__int32 * const *)input_, wide_samples)) { - print_error_with_state(&encoder_session, "ERROR during encoding"); - return EncoderSession_finish_error(&encoder_session); - } - } - } - } - else { - size_t bytes_read; - const FLAC__uint64 max_input_bytes = infilesize; - FLAC__uint64 total_input_bytes_read = 0; - while(total_input_bytes_read < max_input_bytes) { - { - size_t wanted = (CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample); - wanted = (size_t) min((FLAC__uint64)wanted, max_input_bytes - total_input_bytes_read); - - if(lookahead_length > 0) { - if(lookahead_length <= wanted) { - memcpy(ubuffer.u8, lookahead, lookahead_length); - wanted -= lookahead_length; - bytes_read = lookahead_length; - } - else { - /* This happens when --until is used on a very short file */ - FLAC__ASSERT(lookahead_length < CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample); - memcpy(ubuffer.u8, lookahead, wanted); - wanted = 0; - bytes_read = wanted; - } - if(wanted > 0) { - bytes_read += fread(ubuffer.u8+lookahead_length, sizeof(uint8_t), wanted, infile); - if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - } - lookahead_length = 0; - } - else - bytes_read = fread(ubuffer.u8, sizeof(uint8_t), wanted, infile); - } - - if(bytes_read == 0) { - if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - else if(feof(infile)) { - flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %" PRIu64 " samples, got %" PRIu64 " samples\n", encoder_session.inbasefilename, encoder_session.total_samples_to_encode, encoder_session.samples_written); - if(encoder_session.treat_warnings_as_errors) - return EncoderSession_finish_error(&encoder_session); - total_input_bytes_read = max_input_bytes; - } - } - else { - if(bytes_read % encoder_session.info.bytes_per_wide_sample != 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - else { - uint32_t wide_samples = bytes_read / encoder_session.info.bytes_per_wide_sample; - if(!format_input(input_, wide_samples, encoder_session.info.is_big_endian, encoder_session.info.is_unsigned_samples, encoder_session.info.channels, encoder_session.info.bits_per_sample, encoder_session.info.shift, channel_map)) - return EncoderSession_finish_error(&encoder_session); - - if(!EncoderSession_process(&encoder_session, (const FLAC__int32 * const *)input_, wide_samples)) { - print_error_with_state(&encoder_session, "ERROR during encoding"); - return EncoderSession_finish_error(&encoder_session); - } - total_input_bytes_read += bytes_read; - } - } - } - } - break; - case FORMAT_WAVE: - case FORMAT_WAVE64: - case FORMAT_RF64: - case FORMAT_AIFF: - case FORMAT_AIFF_C: - while(encoder_session.fmt.iff.data_bytes > 0) { - const size_t bytes_to_read = - (size_t) min (sizeof (ubuffer.u8), - min (encoder_session.fmt.iff.data_bytes, - CHUNK_OF_SAMPLES * (uint64_t) encoder_session.info.bytes_per_wide_sample)); - size_t bytes_read = fread(ubuffer.u8, sizeof(uint8_t), bytes_to_read, infile); - if(bytes_read == 0) { - if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - else if(feof(infile)) { - if(options.ignore_chunk_sizes) { - flac__utils_printf(stderr, 1, "%s: INFO: hit EOF with --ignore-chunk-sizes, got %" PRIu64 " samples\n", encoder_session.inbasefilename, encoder_session.samples_written); - } - else { - flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %" PRIu64 " samples, got %" PRIu64 " samples\n", encoder_session.inbasefilename, encoder_session.total_samples_to_encode, encoder_session.samples_written); - if(encoder_session.treat_warnings_as_errors) - return EncoderSession_finish_error(&encoder_session); - } - encoder_session.fmt.iff.data_bytes = 0; - } - } - else { - if(bytes_read % encoder_session.info.bytes_per_wide_sample != 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename); - return EncoderSession_finish_error(&encoder_session); - } - else { - uint32_t wide_samples = bytes_read / encoder_session.info.bytes_per_wide_sample; - if(!format_input(input_, wide_samples, encoder_session.info.is_big_endian, encoder_session.info.is_unsigned_samples, encoder_session.info.channels, encoder_session.info.bits_per_sample, encoder_session.info.shift, channel_map)) - return EncoderSession_finish_error(&encoder_session); - - if(!EncoderSession_process(&encoder_session, (const FLAC__int32 * const *)input_, wide_samples)) { - print_error_with_state(&encoder_session, "ERROR during encoding"); - return EncoderSession_finish_error(&encoder_session); - } - encoder_session.fmt.iff.data_bytes -= bytes_read; - } - } - } - break; - case FORMAT_FLAC: - case FORMAT_OGGFLAC: - consecutive_eos_count = 0; - while(!encoder_session.fmt.flac.client_data.fatal_error && encoder_session.fmt.flac.client_data.samples_left_to_process > 0) { - FLAC__StreamDecoderState decoder_state; - /* We can also hit the end of stream without samples_left_to_process - * going to 0 if there are errors and continue_through_decode_errors - * is on, so we want to break in that case too: - */ - decoder_state = FLAC__stream_decoder_get_state(encoder_session.fmt.flac.decoder); - if(encoder_session.continue_through_decode_errors && decoder_state == FLAC__STREAM_DECODER_END_OF_STREAM) - break; - - consecutive_eos_count = decoder_state == FLAC__STREAM_DECODER_END_OF_STREAM ? consecutive_eos_count + 1 : 0; - - /* Exit loop if we get two or more consecutive FLAC__STREAM_DECODER_END_OF_STREAM events. */ - if(consecutive_eos_count >= 2) { - flac__utils_printf(stderr, 1, "%s: ERROR: %d consecutive FLAC__STREAM_DECODER_END_OF_STREAM events.\n", encoder_session.inbasefilename, consecutive_eos_count); - break; - } - - if(decoder_state == FLAC__STREAM_DECODER_ABORTED || !FLAC__stream_decoder_process_single(encoder_session.fmt.flac.decoder)) { - flac__utils_printf(stderr, 1, "%s: ERROR: while decoding FLAC input, state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); - return EncoderSession_finish_error(&encoder_session); - } - } - if(encoder_session.fmt.flac.client_data.fatal_error) { - flac__utils_printf(stderr, 1, "%s: ERROR: while decoding FLAC input, state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); - return EncoderSession_finish_error(&encoder_session); - } - break; - default: - FLAC__ASSERT(0); - /* double protection */ - return EncoderSession_finish_error(&encoder_session); - } - - } - - return EncoderSession_finish_ok( - &encoder_session, - EncoderSession_format_is_iff(&encoder_session)? options.format_options.iff.foreign_metadata : 0, - options.error_on_compression_fail - ); -} - -FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, FLAC__off_t infilesize, FILE *infile, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length) -{ - uint32_t i; - FLAC__uint32 test = 1; - - /* - * initialize globals - */ - - is_big_endian_host_ = (*((FLAC__byte*)(&test)))? false : true; - - for(i = 0; i < FLAC__MAX_CHANNELS; i++) - input_[i] = &(in_[i][0]); - - - /* - * initialize instance - */ - -#if FLAC__HAS_OGG - e->use_ogg = options.use_ogg; -#endif - e->verify = options.verify; - e->treat_warnings_as_errors = options.treat_warnings_as_errors; - e->continue_through_decode_errors = options.continue_through_decode_errors; - - e->is_stdout = (0 == strcmp(outfilename, "-")); - e->outputfile_opened = false; - - e->inbasefilename = grabbag__file_get_basename(infilename); - e->infilename = infilename; - e->outfilename = outfilename; - - e->total_samples_to_encode = 0; - e->unencoded_size = 0; - e->bytes_written = 0; - e->samples_written = 0; -#if 0 /* in case time.h with clock() isn't available for some reason */ - e->stats_frames_interval = 0; - e->old_frames_written = 0; -#else - e->old_clock_t = 0; -#endif - e->compression_ratio = 0.0; - - memset(&e->info, 0, sizeof(e->info)); - - e->format = options.format; - - switch(options.format) { - case FORMAT_RAW: - break; - case FORMAT_WAVE: - case FORMAT_WAVE64: - case FORMAT_RF64: - case FORMAT_AIFF: - case FORMAT_AIFF_C: - e->fmt.iff.data_bytes = 0; - break; - case FORMAT_FLAC: - case FORMAT_OGGFLAC: - e->fmt.flac.decoder = 0; - e->fmt.flac.client_data.filesize = infilesize; - e->fmt.flac.client_data.lookahead = lookahead; - e->fmt.flac.client_data.lookahead_length = lookahead_length; - e->fmt.flac.client_data.num_metadata_blocks = 0; - e->fmt.flac.client_data.samples_left_to_process = 0; - e->fmt.flac.client_data.fatal_error = false; - break; - default: -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - FLAC__ASSERT(0); -#endif - /* double protection */ - return false; - } - - e->encoder = 0; - - e->fin = infile; - e->seek_table_template = 0; - - if(0 == (e->seek_table_template = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE))) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for seek table\n", e->inbasefilename); - return false; - } - - e->encoder = FLAC__stream_encoder_new(); - if(0 == e->encoder) { - flac__utils_printf(stderr, 1, "%s: ERROR creating the encoder instance\n", e->inbasefilename); - EncoderSession_destroy(e); - return false; - } - - return true; -} - -void EncoderSession_destroy(EncoderSession *e) -{ - if(e->format == FORMAT_FLAC || e->format == FORMAT_OGGFLAC) { - size_t i; - if(e->fmt.flac.decoder) - FLAC__stream_decoder_delete(e->fmt.flac.decoder); - e->fmt.flac.decoder = 0; - for(i = 0; i < e->fmt.flac.client_data.num_metadata_blocks; i++) - FLAC__metadata_object_delete(e->fmt.flac.client_data.metadata_blocks[i]); - e->fmt.flac.client_data.num_metadata_blocks = 0; - } - - if(e->fin != stdin) - fclose(e->fin); - - if(0 != e->encoder) { - FLAC__stream_encoder_delete(e->encoder); - e->encoder = 0; - } - - if(0 != e->seek_table_template) { - FLAC__metadata_object_delete(e->seek_table_template); - e->seek_table_template = 0; - } -} - -int EncoderSession_finish_ok(EncoderSession *e, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail) -{ - FLAC__StreamEncoderState fse_state = FLAC__STREAM_ENCODER_OK; - int ret = 0; - FLAC__bool verify_error = false; - - if(e->encoder) { - fse_state = FLAC__stream_encoder_get_state(e->encoder); - ret = FLAC__stream_encoder_finish(e->encoder)? 0 : 1; - verify_error = - fse_state == FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA || - FLAC__stream_encoder_get_state(e->encoder) == FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA - ; - } - /* all errors except verify errors should interrupt the stats */ - if(ret && !verify_error) - print_error_with_state(e, "ERROR during encoding"); - else if(e->total_samples_to_encode > 0) { - print_stats(e); - flac__utils_printf(stderr, 2, "\n"); - } - - if(verify_error) { - print_verify_error(e); - ret = 1; - } - - /*@@@@@@ should this go here or somewhere else? */ - if(ret == 0 && foreign_metadata) { - const char *error; - if(!flac__foreign_metadata_write_to_flac(foreign_metadata, e->infilename, e->outfilename, &error)) { - flac__utils_printf(stderr, 1, "%s: ERROR: updating foreign metadata in FLAC file: %s\n", e->inbasefilename, error); - ret = 1; - } - } - - if (e->compression_ratio >= 1.0 && error_on_compression_fail) { - flac__utils_printf(stderr, 1, - "FAILURE: Compression failed (ratio %0.3f, should be < 1.0).\n" - "This happens for some files for one or more of the following reasons:\n" - " * Recompressing an existing FLAC from a higher to a lower compression setting.\n" - " * Insufficient input data (e.g. very short files, < 10000 frames).\n" - " * The audio data is not compressible (e.g. a full range white noise signal).\n" - , e->compression_ratio); - ret = 1; - } - -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* Always delete output file when fuzzing */ - flac_unlink(e->outfilename); -#endif - - EncoderSession_destroy(e); - - return ret; -} - -int EncoderSession_finish_error(EncoderSession *e) -{ - FLAC__ASSERT(e->encoder); - - if(e->total_samples_to_encode > 0) - flac__utils_printf(stderr, 2, "\n"); - - if(FLAC__stream_encoder_get_state(e->encoder) == FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA) { - print_verify_error(e); - EncoderSession_destroy(e); - } - else if(e->outputfile_opened) { - /* only want to delete the file if we opened it; otherwise it could be an existing file and our overwrite failed */ - /* Windows cannot unlink an open file, so close it first */ - EncoderSession_destroy(e); - flac_unlink(e->outfilename); - } - else - EncoderSession_destroy(e); - - return 1; -} - -typedef struct { - uint32_t num_metadata; - FLAC__bool *needs_delete; - FLAC__StreamMetadata **metadata; - FLAC__StreamMetadata *cuesheet; /* always needs to be deleted */ -} static_metadata_t; - -static void static_metadata_init(static_metadata_t *m) -{ - m->num_metadata = 0; - m->needs_delete = 0; - m->metadata = 0; - m->cuesheet = 0; -} - -static void static_metadata_clear(static_metadata_t *m) -{ - uint32_t i; - for(i = 0; i < m->num_metadata; i++) - if(m->needs_delete[i]) - FLAC__metadata_object_delete(m->metadata[i]); - if(m->metadata) - free(m->metadata); - if(m->needs_delete) - free(m->needs_delete); - if(m->cuesheet) - FLAC__metadata_object_delete(m->cuesheet); - static_metadata_init(m); -} - -static FLAC__bool static_metadata_append(static_metadata_t *m, FLAC__StreamMetadata *d, FLAC__bool needs_delete) -{ - void *x; - if(0 == (x = safe_realloc_nofree_muladd2_(m->metadata, sizeof(*m->metadata), /*times (*/m->num_metadata, /*+*/1/*)*/))) - return false; - m->metadata = (FLAC__StreamMetadata**)x; - if(0 == (x = safe_realloc_nofree_muladd2_(m->needs_delete, sizeof(*m->needs_delete), /*times (*/m->num_metadata, /*+*/1/*)*/))) - return false; - m->needs_delete = (FLAC__bool*)x; - m->metadata[m->num_metadata] = d; - m->needs_delete[m->num_metadata] = needs_delete; - m->num_metadata++; - return true; -} - -FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t options) -{ - const uint32_t channels = e->info.channels; - const uint32_t bps = e->info.bits_per_sample - e->info.shift; - const uint32_t sample_rate = e->info.sample_rate; - FLACDecoderData *flac_decoder_data = (e->format == FORMAT_FLAC || e->format == FORMAT_OGGFLAC)? &e->fmt.flac.client_data : 0; - FLAC__StreamMetadata padding; - FLAC__StreamMetadata **metadata = 0; - static_metadata_t static_metadata; - uint32_t num_metadata = 0, ic; - FLAC__StreamEncoderInitStatus init_status; - const FLAC__bool is_cdda = (channels == 1 || channels == 2) && (bps == 16) && (sample_rate == 44100); - char apodizations[2000]; - - FLAC__ASSERT(sizeof(options.pictures)/sizeof(options.pictures[0]) <= 64); - - static_metadata_init(&static_metadata); - - e->replay_gain = options.replay_gain; - - apodizations[0] = '\0'; - - if(e->replay_gain) { - if(channels != 1 && channels != 2) { - flac__utils_printf(stderr, 1, "%s: ERROR, number of channels (%u) must be 1 or 2 for --replay-gain\n", e->inbasefilename, channels); - return false; - } - if(!grabbag__replaygain_is_valid_sample_frequency(sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR, invalid sample rate (%u) for --replay-gain\n", e->inbasefilename, sample_rate); - return false; - } - if(options.is_first_file) { - if(!grabbag__replaygain_init(sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR initializing ReplayGain stage\n", e->inbasefilename); - return false; - } - } - } - - if(!parse_cuesheet(&static_metadata.cuesheet, options.cuesheet_filename, e->inbasefilename, sample_rate, is_cdda, e->total_samples_to_encode, e->treat_warnings_as_errors)) - return false; - - if(!convert_to_seek_table_template(options.requested_seek_points, options.num_requested_seek_points, options.cued_seekpoints? static_metadata.cuesheet : 0, e)) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for seek table\n", e->inbasefilename); - static_metadata_clear(&static_metadata); - return false; - } - - /* build metadata */ - if(flac_decoder_data) { - /* - * we're encoding from FLAC so we will use the FLAC file's - * metadata as the basis for the encoded file - */ - { - uint32_t i; - /* - * first handle pictures: simple append any --pictures - * specified. - */ - for(i = 0; i < options.num_pictures; i++) { - FLAC__StreamMetadata *pic = FLAC__metadata_object_clone(options.pictures[i]); - if(0 == pic) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for PICTURE block\n", e->inbasefilename); - static_metadata_clear(&static_metadata); - return false; - } - flac_decoder_data->metadata_blocks[flac_decoder_data->num_metadata_blocks++] = pic; - } - } - { - /* - * next handle vorbis comment: if any tags were specified - * or there is no existing vorbis comment, we create a - * new vorbis comment (discarding any existing one); else - * we keep the existing one. also need to make sure to - * propagate any channel mask tag. - */ - /* @@@ change to append -T values from options.vorbis_comment if input has VC already? */ - size_t i, j; - FLAC__bool vc_found = false; - for(i = 0, j = 0; i < flac_decoder_data->num_metadata_blocks; i++) { - if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) - vc_found = true; - if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_VORBIS_COMMENT && options.vorbis_comment->data.vorbis_comment.num_comments > 0) { - (void) flac__utils_get_channel_mask_tag(flac_decoder_data->metadata_blocks[i], &e->info.channel_mask); - flac__utils_printf(stderr, 1, "%s: WARNING, replacing tags from input FLAC file with those given on the command-line\n", e->inbasefilename); - if(e->treat_warnings_as_errors) { - static_metadata_clear(&static_metadata); - return false; - } - FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]); - flac_decoder_data->metadata_blocks[i] = 0; - } - else - flac_decoder_data->metadata_blocks[j++] = flac_decoder_data->metadata_blocks[i]; - } - flac_decoder_data->num_metadata_blocks = j; - if((!vc_found || options.vorbis_comment->data.vorbis_comment.num_comments > 0) && flac_decoder_data->num_metadata_blocks < sizeof(flac_decoder_data->metadata_blocks)/sizeof(flac_decoder_data->metadata_blocks[0])) { - /* prepend ours */ - FLAC__StreamMetadata *vc = FLAC__metadata_object_clone(options.vorbis_comment); - if(0 == vc || (e->info.channel_mask && !flac__utils_set_channel_mask_tag(vc, e->info.channel_mask))) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for VORBIS_COMMENT block\n", e->inbasefilename); - static_metadata_clear(&static_metadata); - return false; - } - for(i = flac_decoder_data->num_metadata_blocks; i > 1; i--) - flac_decoder_data->metadata_blocks[i] = flac_decoder_data->metadata_blocks[i-1]; - flac_decoder_data->metadata_blocks[1] = vc; - flac_decoder_data->num_metadata_blocks++; - } - } - { - /* - * next handle cuesheet: if --cuesheet was specified, use - * it; else if file has existing CUESHEET and cuesheet's - * lead-out offset is correct, keep it; else no CUESHEET - */ - size_t i, j; - for(i = 0, j = 0; i < flac_decoder_data->num_metadata_blocks; i++) { - FLAC__bool existing_cuesheet_is_bad = false; - /* check if existing cuesheet matches the input audio */ - if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_CUESHEET && 0 == static_metadata.cuesheet) { - const FLAC__StreamMetadata_CueSheet *cs = &flac_decoder_data->metadata_blocks[i]->data.cue_sheet; - if(e->total_samples_to_encode == 0) { - flac__utils_printf(stderr, 1, "%s: WARNING, cuesheet in input FLAC file cannot be kept if input size is not known, dropping it...\n", e->inbasefilename); - if(e->treat_warnings_as_errors) { - static_metadata_clear(&static_metadata); - return false; - } - existing_cuesheet_is_bad = true; - } - else if(cs->num_tracks > 0 && e->total_samples_to_encode != cs->tracks[cs->num_tracks-1].offset) { - flac__utils_printf(stderr, 1, "%s: WARNING, lead-out offset of cuesheet in input FLAC file does not match input length, dropping existing cuesheet...\n", e->inbasefilename); - if(e->treat_warnings_as_errors) { - static_metadata_clear(&static_metadata); - return false; - } - existing_cuesheet_is_bad = true; - } - } - if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_CUESHEET && (existing_cuesheet_is_bad || 0 != static_metadata.cuesheet)) { - if(0 != static_metadata.cuesheet) { - flac__utils_printf(stderr, 1, "%s: WARNING, replacing cuesheet in input FLAC file with the one given on the command-line\n", e->inbasefilename); - if(e->treat_warnings_as_errors) { - static_metadata_clear(&static_metadata); - return false; - } - } - FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]); - flac_decoder_data->metadata_blocks[i] = 0; - } - else - flac_decoder_data->metadata_blocks[j++] = flac_decoder_data->metadata_blocks[i]; - } - flac_decoder_data->num_metadata_blocks = j; - if(0 != static_metadata.cuesheet && flac_decoder_data->num_metadata_blocks < sizeof(flac_decoder_data->metadata_blocks)/sizeof(flac_decoder_data->metadata_blocks[0])) { - /* prepend ours */ - FLAC__StreamMetadata *cs = FLAC__metadata_object_clone(static_metadata.cuesheet); - if(0 == cs) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for CUESHEET block\n", e->inbasefilename); - static_metadata_clear(&static_metadata); - return false; - } - for(i = flac_decoder_data->num_metadata_blocks; i > 1; i--) - flac_decoder_data->metadata_blocks[i] = flac_decoder_data->metadata_blocks[i-1]; - flac_decoder_data->metadata_blocks[1] = cs; - flac_decoder_data->num_metadata_blocks++; - } - } - { - /* - * next handle seektable: if -S- was specified, no - * SEEKTABLE; else if -S was specified, use it/them; - * else if file has existing SEEKTABLE and input size is - * preserved (no --skip/--until/etc specified), keep it; - * else use default seektable options - * - * note: meanings of num_requested_seek_points: - * -1 : no -S option given, default to some value - * 0 : -S- given (no seektable) - * >0 : one or more -S options given - */ - size_t i, j; - FLAC__bool existing_seektable = false; - for(i = 0, j = 0; i < flac_decoder_data->num_metadata_blocks; i++) { - if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_SEEKTABLE) - existing_seektable = true; - if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_SEEKTABLE && (e->total_samples_to_encode != flac_decoder_data->metadata_blocks[0]->data.stream_info.total_samples || options.num_requested_seek_points >= 0)) { - if(options.num_requested_seek_points > 0) { - flac__utils_printf(stderr, 1, "%s: WARNING, replacing seektable in input FLAC file with the one given on the command-line\n", e->inbasefilename); - if(e->treat_warnings_as_errors) { - static_metadata_clear(&static_metadata); - return false; - } - } - else if(options.num_requested_seek_points == 0) - ; /* no warning, silently delete existing SEEKTABLE since user specified --no-seektable (-S-) */ - else { - flac__utils_printf(stderr, 1, "%s: WARNING, can't use existing seektable in input FLAC since the input size is changing or unknown, dropping existing SEEKTABLE block...\n", e->inbasefilename); - if(e->treat_warnings_as_errors) { - static_metadata_clear(&static_metadata); - return false; - } - } - FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]); - flac_decoder_data->metadata_blocks[i] = 0; - existing_seektable = false; - } - else - flac_decoder_data->metadata_blocks[j++] = flac_decoder_data->metadata_blocks[i]; - } - flac_decoder_data->num_metadata_blocks = j; - if((options.num_requested_seek_points > 0 || (options.num_requested_seek_points < 0 && !existing_seektable)) && flac_decoder_data->num_metadata_blocks < sizeof(flac_decoder_data->metadata_blocks)/sizeof(flac_decoder_data->metadata_blocks[0])) { - /* prepend ours */ - FLAC__StreamMetadata *st = FLAC__metadata_object_clone(e->seek_table_template); - if(0 == st) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for SEEKTABLE block\n", e->inbasefilename); - static_metadata_clear(&static_metadata); - return false; - } - for(i = flac_decoder_data->num_metadata_blocks; i > 1; i--) - flac_decoder_data->metadata_blocks[i] = flac_decoder_data->metadata_blocks[i-1]; - flac_decoder_data->metadata_blocks[1] = st; - flac_decoder_data->num_metadata_blocks++; - } - } - { - /* - * finally handle padding: if --no-padding was specified, - * then delete all padding; else if -P was specified, - * use that instead of existing padding (if any); else - * if existing file has padding, move all existing - * padding blocks to one padding block at the end; else - * use default padding. - */ - int p = -1; - size_t i, j; - for(i = 0, j = 0; i < flac_decoder_data->num_metadata_blocks; i++) { - if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_PADDING) { - if(p < 0) - p = 0; - p += flac_decoder_data->metadata_blocks[i]->length; - FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]); - flac_decoder_data->metadata_blocks[i] = 0; - } - else - flac_decoder_data->metadata_blocks[j++] = flac_decoder_data->metadata_blocks[i]; - } - flac_decoder_data->num_metadata_blocks = j; - if(options.padding > 0) - p = options.padding; - if(p < 0) { - if(sample_rate == 0) - p = FLAC_ENCODE__DEFAULT_PADDING; - else - p = e->total_samples_to_encode / sample_rate < 20*60? FLAC_ENCODE__DEFAULT_PADDING : FLAC_ENCODE__DEFAULT_PADDING*8; - } - if(p > 0) - p += (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0); - p = min(p, (int)((1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1)); - if(options.padding != 0) { - if(p > 0 && flac_decoder_data->num_metadata_blocks < sizeof(flac_decoder_data->metadata_blocks)/sizeof(flac_decoder_data->metadata_blocks[0])) { - flac_decoder_data->metadata_blocks[flac_decoder_data->num_metadata_blocks] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING); - if(0 == flac_decoder_data->metadata_blocks[flac_decoder_data->num_metadata_blocks]) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for PADDING block\n", e->inbasefilename); - static_metadata_clear(&static_metadata); - return false; - } - flac_decoder_data->metadata_blocks[flac_decoder_data->num_metadata_blocks]->is_last = false; /* the encoder will set this for us */ - flac_decoder_data->metadata_blocks[flac_decoder_data->num_metadata_blocks]->length = p; - flac_decoder_data->num_metadata_blocks++; - } - } - } - metadata = &flac_decoder_data->metadata_blocks[1]; /* don't include STREAMINFO */ - num_metadata = flac_decoder_data->num_metadata_blocks - 1; - } - else { - /* - * we're not encoding from FLAC so we will build the metadata - * from scratch - */ - const foreign_metadata_t *foreign_metadata = EncoderSession_format_is_iff(e)? options.format_options.iff.foreign_metadata : 0; - uint32_t i; - - if(e->seek_table_template->data.seek_table.num_points > 0) { - e->seek_table_template->is_last = false; /* the encoder will set this for us */ - static_metadata_append(&static_metadata, e->seek_table_template, /*needs_delete=*/false); - } - if(0 != static_metadata.cuesheet) - static_metadata_append(&static_metadata, static_metadata.cuesheet, /*needs_delete=*/false); - if(e->info.channel_mask) { - options.vorbis_comment_with_channel_mask_tag = FLAC__metadata_object_clone(options.vorbis_comment); - if(!flac__utils_set_channel_mask_tag(options.vorbis_comment_with_channel_mask_tag, e->info.channel_mask)) { - flac__utils_printf(stderr, 1, "%s: ERROR adding channel mask tag\n", e->inbasefilename); - static_metadata_clear(&static_metadata); - return false; - } - static_metadata_append(&static_metadata, options.vorbis_comment_with_channel_mask_tag, /*needs_delete=*/true); - } - else - static_metadata_append(&static_metadata, options.vorbis_comment, /*needs_delete=*/false); - for(i = 0; i < options.num_pictures; i++) - static_metadata_append(&static_metadata, options.pictures[i], /*needs_delete=*/false); - if(foreign_metadata) { - for(i = 0; i < foreign_metadata->num_blocks; i++) { - FLAC__StreamMetadata *p = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING); - if(!p) { - flac__utils_printf(stderr, 1, "%s: ERROR: out of memory\n", e->inbasefilename); - static_metadata_clear(&static_metadata); - return false; - } - static_metadata_append(&static_metadata, p, /*needs_delete=*/true); - static_metadata.metadata[static_metadata.num_metadata-1]->length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8 + foreign_metadata->blocks[i].size; - } - } - if(options.padding != 0) { - padding.is_last = false; /* the encoder will set this for us */ - padding.type = FLAC__METADATA_TYPE_PADDING; - if(sample_rate == 0) - padding.length = (uint32_t)(options.padding>0? options.padding : FLAC_ENCODE__DEFAULT_PADDING) + (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0); - else - padding.length = (uint32_t)(options.padding>0? options.padding : (e->total_samples_to_encode / sample_rate < 20*60? FLAC_ENCODE__DEFAULT_PADDING : FLAC_ENCODE__DEFAULT_PADDING*8)) + (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0); - padding.length = min(padding.length, (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1); - static_metadata_append(&static_metadata, &padding, /*needs_delete=*/false); - } - metadata = static_metadata.metadata; - num_metadata = static_metadata.num_metadata; - } - - /* check for a few things that have not already been checked. the - * FLAC__stream_encoder_init*() will check it but only return - * FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA so we check some - * up front to give a better error message. - */ - if(!verify_metadata(e, metadata, num_metadata)) { - static_metadata_clear(&static_metadata); - return false; - } - - FLAC__stream_encoder_set_verify(e->encoder, options.verify); - FLAC__stream_encoder_set_streamable_subset(e->encoder, !options.lax); - FLAC__stream_encoder_set_channels(e->encoder, channels); - FLAC__stream_encoder_set_bits_per_sample(e->encoder, bps); - FLAC__stream_encoder_set_sample_rate(e->encoder, sample_rate); - for(ic = 0; ic < options.num_compression_settings; ic++) { - switch(options.compression_settings[ic].type) { - case CST_BLOCKSIZE: - FLAC__stream_encoder_set_blocksize(e->encoder, options.compression_settings[ic].value.t_unsigned); - break; - case CST_COMPRESSION_LEVEL: - FLAC__stream_encoder_set_compression_level(e->encoder, options.compression_settings[ic].value.t_unsigned); - apodizations[0] = '\0'; - break; - case CST_DO_MID_SIDE: - FLAC__stream_encoder_set_do_mid_side_stereo(e->encoder, options.compression_settings[ic].value.t_bool); - break; - case CST_LOOSE_MID_SIDE: - FLAC__stream_encoder_set_loose_mid_side_stereo(e->encoder, options.compression_settings[ic].value.t_bool); - break; - case CST_APODIZATION: - if(strlen(apodizations)+strlen(options.compression_settings[ic].value.t_string)+2 >= sizeof(apodizations)) { - flac__utils_printf(stderr, 1, "%s: ERROR: too many apodization functions requested\n", e->inbasefilename); - static_metadata_clear(&static_metadata); - return false; - } - else { - safe_strncat(apodizations, options.compression_settings[ic].value.t_string, sizeof(apodizations)); - safe_strncat(apodizations, ";", sizeof(apodizations)); - } - break; - case CST_MAX_LPC_ORDER: -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - FLAC__stream_encoder_set_max_lpc_order(e->encoder, options.compression_settings[ic].value.t_unsigned); -#endif - break; - case CST_QLP_COEFF_PRECISION: - FLAC__stream_encoder_set_qlp_coeff_precision(e->encoder, options.compression_settings[ic].value.t_unsigned); - break; - case CST_DO_QLP_COEFF_PREC_SEARCH: -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - FLAC__stream_encoder_set_do_qlp_coeff_prec_search(e->encoder, options.compression_settings[ic].value.t_bool); -#endif - break; - case CST_DO_ESCAPE_CODING: - FLAC__stream_encoder_set_do_escape_coding(e->encoder, options.compression_settings[ic].value.t_bool); - break; - case CST_DO_EXHAUSTIVE_MODEL_SEARCH: -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - FLAC__stream_encoder_set_do_exhaustive_model_search(e->encoder, options.compression_settings[ic].value.t_bool); -#endif - break; - case CST_MIN_RESIDUAL_PARTITION_ORDER: - FLAC__stream_encoder_set_min_residual_partition_order(e->encoder, options.compression_settings[ic].value.t_unsigned); - break; - case CST_MAX_RESIDUAL_PARTITION_ORDER: - FLAC__stream_encoder_set_max_residual_partition_order(e->encoder, options.compression_settings[ic].value.t_unsigned); - break; - case CST_RICE_PARAMETER_SEARCH_DIST: - FLAC__stream_encoder_set_rice_parameter_search_dist(e->encoder, options.compression_settings[ic].value.t_unsigned); - break; - } - } -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - if(*apodizations) - FLAC__stream_encoder_set_apodization(e->encoder, apodizations); -#endif - FLAC__stream_encoder_set_total_samples_estimate(e->encoder, e->total_samples_to_encode); - FLAC__stream_encoder_set_metadata(e->encoder, (num_metadata > 0)? metadata : 0, num_metadata); - FLAC__stream_encoder_set_limit_min_bitrate(e->encoder, options.limit_min_bitrate); - - FLAC__stream_encoder_disable_constant_subframes(e->encoder, options.debug.disable_constant_subframes); - FLAC__stream_encoder_disable_fixed_subframes(e->encoder, options.debug.disable_fixed_subframes); - FLAC__stream_encoder_disable_verbatim_subframes(e->encoder, options.debug.disable_verbatim_subframes); - if(!options.debug.do_md5) { - flac__utils_printf(stderr, 1, "%s: WARNING, MD5 computation disabled, resulting file will not have MD5 sum\n", e->inbasefilename); - if(e->treat_warnings_as_errors) { - static_metadata_clear(&static_metadata); - return false; - } - FLAC__stream_encoder_set_do_md5(e->encoder, false); - } - else if(e->is_stdout) { - flac__utils_printf(stderr, 1, "%s: WARNING, cannot write back MD5 sum when encoding to stdout\n", e->inbasefilename); - if(e->treat_warnings_as_errors) { - static_metadata_clear(&static_metadata); - return false; - } - } - -#if FLAC__HAS_OGG - if(e->use_ogg) { - FLAC__stream_encoder_set_ogg_serial_number(e->encoder, options.serial_number); - - init_status = FLAC__stream_encoder_init_ogg_file(e->encoder, e->is_stdout? 0 : e->outfilename, encoder_progress_callback, /*client_data=*/e); - } - else -#endif - { - init_status = FLAC__stream_encoder_init_file(e->encoder, e->is_stdout? 0 : e->outfilename, encoder_progress_callback, /*client_data=*/e); - } - - if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { - print_error_with_init_status(e, "ERROR initializing encoder", init_status); - if(FLAC__stream_encoder_get_state(e->encoder) != FLAC__STREAM_ENCODER_IO_ERROR) - e->outputfile_opened = true; - static_metadata_clear(&static_metadata); - return false; - } - else - e->outputfile_opened = true; - -#if 0 /* in case time.h with clock() isn't available for some reason */ - e->stats_frames_interval = - (FLAC__stream_encoder_get_do_exhaustive_model_search(e->encoder) && FLAC__stream_encoder_get_do_qlp_coeff_prec_search(e->encoder))? 0x1f : - (FLAC__stream_encoder_get_do_exhaustive_model_search(e->encoder) || FLAC__stream_encoder_get_do_qlp_coeff_prec_search(e->encoder))? 0x3f : - 0xff; -#endif - - static_metadata_clear(&static_metadata); - - return true; -} - -FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const buffer[], uint32_t samples) -{ - if(e->replay_gain) { - if(!grabbag__replaygain_analyze(buffer, e->info.channels==2, e->info.bits_per_sample, samples)) { - flac__utils_printf(stderr, 1, "%s: WARNING, error while calculating ReplayGain\n", e->inbasefilename); - if(e->treat_warnings_as_errors) - return false; - } - } - - return FLAC__stream_encoder_process(e->encoder, buffer, samples); -} - -FLAC__bool EncoderSession_format_is_iff(const EncoderSession *e) -{ - return - e->format == FORMAT_WAVE || - e->format == FORMAT_WAVE64 || - e->format == FORMAT_RF64 || - e->format == FORMAT_AIFF || - e->format == FORMAT_AIFF_C; -} - -FLAC__bool convert_to_seek_table_template(const char *requested_seek_points, int num_requested_seek_points, FLAC__StreamMetadata *cuesheet, EncoderSession *e) -{ - const FLAC__bool only_placeholders = e->is_stdout; - FLAC__bool has_real_points; - - if(num_requested_seek_points == 0 && 0 == cuesheet) - return true; - -#if FLAC__HAS_OGG - if(e->use_ogg) - return true; -#endif - - if(num_requested_seek_points < 0) { - requested_seek_points = "10s;"; - num_requested_seek_points = 1; - } - - if(num_requested_seek_points > 0) { - if(!grabbag__seektable_convert_specification_to_template(requested_seek_points, only_placeholders, e->total_samples_to_encode, e->info.sample_rate, e->seek_table_template, &has_real_points)) - return false; - } - - if(0 != cuesheet) { - uint32_t i, j; - const FLAC__StreamMetadata_CueSheet *cs = &cuesheet->data.cue_sheet; - for(i = 0; i < cs->num_tracks; i++) { - const FLAC__StreamMetadata_CueSheet_Track *tr = cs->tracks+i; - for(j = 0; j < tr->num_indices; j++) { - if(!FLAC__metadata_object_seektable_template_append_point(e->seek_table_template, tr->offset + tr->indices[j].offset)) - return false; - has_real_points = true; - } - } - if(has_real_points) - if(!FLAC__metadata_object_seektable_template_sort(e->seek_table_template, /*compact=*/true)) - return false; - } - - if(has_real_points) { - if(e->is_stdout) { - flac__utils_printf(stderr, 1, "%s: WARNING, cannot write back seekpoints when encoding to stdout\n", e->inbasefilename); - if(e->treat_warnings_as_errors) - return false; - } - } - - return true; -} - -FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input) -{ - /* convert from mm:ss.sss to sample number if necessary */ - if(!flac__utils_canonicalize_skip_until_specification(spec, sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR, value of --until is too large\n", inbasefilename); - return false; - } - - /* special case: if "--until=-0", use the special value '0' to mean "end-of-stream" */ - if(spec->is_relative && spec->value.samples == 0) { - spec->is_relative = false; - return true; - } - - /* in any other case the total samples in the input must be known */ - if(total_samples_in_input == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --until when input length is unknown\n", inbasefilename); - return false; - } - - FLAC__ASSERT(spec->value_is_samples); - - /* convert relative specifications to absolute */ - if(spec->is_relative) { - if(spec->value.samples <= 0) - spec->value.samples += (FLAC__int64)total_samples_in_input; - else - spec->value.samples += skip; - spec->is_relative = false; - } - - /* error check */ - if(spec->value.samples < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before beginning of input\n", inbasefilename); - return false; - } - if((FLAC__uint64)spec->value.samples <= skip) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before --skip point\n", inbasefilename); - return false; - } - if((FLAC__uint64)spec->value.samples > total_samples_in_input) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is after end of input\n", inbasefilename); - return false; - } - - return true; -} - -FLAC__bool verify_metadata(const EncoderSession *e, FLAC__StreamMetadata **metadata, uint32_t num_metadata) -{ - FLAC__bool metadata_picture_has_type1 = false; - FLAC__bool metadata_picture_has_type2 = false; - uint32_t i; - - FLAC__ASSERT(0 != metadata); - for(i = 0; i < num_metadata; i++) { - const FLAC__StreamMetadata *m = metadata[i]; - if(m->type == FLAC__METADATA_TYPE_SEEKTABLE) { - if(!FLAC__format_seektable_is_legal(&m->data.seek_table)) { - flac__utils_printf(stderr, 1, "%s: ERROR: SEEKTABLE metadata block is invalid\n", e->inbasefilename); - return false; - } - } - else if(m->type == FLAC__METADATA_TYPE_CUESHEET) { - if(!FLAC__format_cuesheet_is_legal(&m->data.cue_sheet, m->data.cue_sheet.is_cd, /*violation=*/0)) { - flac__utils_printf(stderr, 1, "%s: ERROR: CUESHEET metadata block is invalid\n", e->inbasefilename); - return false; - } - } - else if(m->type == FLAC__METADATA_TYPE_PICTURE) { - const char *error = 0; - if(!FLAC__format_picture_is_legal(&m->data.picture, &error)) { - flac__utils_printf(stderr, 1, "%s: ERROR: PICTURE metadata block is invalid: %s\n", e->inbasefilename, error); - return false; - } - if(m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD) { - if(metadata_picture_has_type1) { - flac__utils_printf(stderr, 1, "%s: ERROR: there may only be one picture of type 1 (32x32 icon) in the file\n", e->inbasefilename); - return false; - } - metadata_picture_has_type1 = true; - } - else if(m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON) { - if(metadata_picture_has_type2) { - flac__utils_printf(stderr, 1, "%s: ERROR: there may only be one picture of type 2 (icon) in the file\n", e->inbasefilename); - return false; - } - metadata_picture_has_type2 = true; - } - } - } - - return true; -} - -FLAC__bool format_input(FLAC__int32 *dest[], uint32_t wide_samples, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, uint32_t channels, uint32_t bps, uint32_t shift, size_t *channel_map) -{ - uint32_t wide_sample, sample, channel; - FLAC__int32 *out[FLAC__MAX_CHANNELS]; - - if(0 == channel_map) { - for(channel = 0; channel < channels; channel++) - out[channel] = dest[channel]; - } - else { - for(channel = 0; channel < channels; channel++) - out[channel] = dest[channel_map[channel]]; - } - - if(bps == 8) { - if(is_unsigned_samples) { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = (FLAC__int32)ubuffer.u8[sample] - 0x80; - } - else { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = (FLAC__int32)ubuffer.s8[sample]; - } - } - else if(bps == 16) { - if(is_unsigned_samples) { - if(is_big_endian != is_big_endian_host_) { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = (FLAC__int32)(ENDSWAP_16(ubuffer.u16[sample])) - 0x8000; - } - else { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = (FLAC__int32)ubuffer.u16[sample] - 0x8000; - } - } - else { - if(is_big_endian != is_big_endian_host_) { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = (int16_t)(ENDSWAP_16(ubuffer.s16[sample])); - - } - else { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = ubuffer.s16[sample]; - } - } - } - else if(bps == 24) { - if(!is_big_endian) { - if(is_unsigned_samples) { - for(channel = 0; channel < channels; channel++) { - uint32_t b = 3*channel; - for(wide_sample = 0; wide_sample < wide_samples; wide_sample++) { - uint32_t t; - t = ubuffer.u8[b]; - t |= (uint32_t)(ubuffer.u8[b+1]) << 8; - t |= (uint32_t)(ubuffer.u8[b+2]) << 16; - out[channel][wide_sample] = (FLAC__int32)t - 0x800000; - b += 3*channels; - } - } - } - else { - for(channel = 0; channel < channels; channel++) { - uint32_t b = 3*channel; - for(wide_sample = 0; wide_sample < wide_samples; wide_sample++) { - uint32_t t; - t = ubuffer.u8[b]; - t |= (uint32_t)(ubuffer.u8[b+1]) << 8; - t |= (uint32_t)((int32_t)(ubuffer.s8[b+2])) << 16; - out[channel][wide_sample] = t; - b += 3*channels; - } - } - } - } - else { - if(is_unsigned_samples) { - for(channel = 0; channel < channels; channel++) { - uint32_t b = 3*channel; - for(wide_sample = 0; wide_sample < wide_samples; wide_sample++) { - uint32_t t; - t = ubuffer.u8[b]; t <<= 8; - t |= ubuffer.u8[b+1]; t <<= 8; - t |= ubuffer.u8[b+2]; - out[channel][wide_sample] = (FLAC__int32)t - 0x800000; - b += 3*channels; - } - } - } - else { - for(channel = 0; channel < channels; channel++) { - uint32_t b = 3*channel; - for(wide_sample = 0; wide_sample < wide_samples; wide_sample++) { - uint32_t t; - t = ubuffer.s8[b]; t <<= 8; - t |= ubuffer.u8[b+1]; t <<= 8; - t |= ubuffer.u8[b+2]; - out[channel][wide_sample] = t; - b += 3*channels; - } - } - } - } - } - else if(bps == 32) { - if(is_unsigned_samples) { - if(is_big_endian != is_big_endian_host_) { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = ENDSWAP_32(ubuffer.u32[sample]) - 0x80000000; - } - else { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = ubuffer.u32[sample] - 0x80000000; - } - } - else { - if(is_big_endian != is_big_endian_host_) { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = ENDSWAP_32(ubuffer.s32[sample]); - } - else { - for(channel = 0; channel < channels; channel++) - for(sample = channel, wide_sample = 0; wide_sample < wide_samples; wide_sample++, sample+=channels) - out[channel][wide_sample] = ubuffer.s32[sample]; - } - } - } - else { - flac__utils_printf(stderr, 1, "ERROR: unsupported input format\n"); - return false; - } - if(shift > 0) { - FLAC__int32 mask = (1<>= shift; - } - } - return true; -} - -void encoder_progress_callback(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data) -{ - EncoderSession *e = (EncoderSession*)client_data; - - const FLAC__uint64 uesize = e->unencoded_size; - - (void)encoder, (void)total_frames_estimate, (void) frames_written; - - e->bytes_written = bytes_written; - e->samples_written = samples_written; - - e->progress = e->total_samples_to_encode ? (double)samples_written / (double)e->total_samples_to_encode : 0; - e->compression_ratio = (e->progress && uesize) ? (double)e->bytes_written / ((double)uesize * min(1.0, e->progress)) : 0; - -#if 0 /* in case time.h with clock() isn't available for some reason */ - if(e->total_samples_to_encode > 0 && frames_written - e->old_frames_written > e->stats_frames_interval) { - print_stats(e); - e->old_frames_written = frames_written; - } -#else - if(e->total_samples_to_encode > 0 && (clock() - e->old_clock_t) > (CLOCKS_PER_SEC/4)) { - print_stats(e); - e->old_clock_t = clock(); - } - -#endif -} - -FLAC__StreamDecoderReadStatus flac_decoder_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - size_t n = 0; - EncoderSession *e = (EncoderSession*)client_data; - FLACDecoderData *data = &e->fmt.flac.client_data; - - (void)decoder; - - if (data->fatal_error) - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - - /* use up lookahead first */ - if (data->lookahead_length) { - n = min(data->lookahead_length, *bytes); - memcpy(buffer, data->lookahead, n); - buffer += n; - data->lookahead += n; - data->lookahead_length -= n; - } - - /* get the rest from file */ - if (*bytes > n) { - *bytes = n + fread(buffer, 1, *bytes-n, e->fin); - if(ferror(e->fin)) - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - else if(0 == *bytes) - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - else - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - else - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; -} - -FLAC__StreamDecoderSeekStatus flac_decoder_seek_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) -{ - EncoderSession *e = (EncoderSession*)client_data; - (void)decoder; - - if(fseeko(e->fin, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) - return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - else - return FLAC__STREAM_DECODER_SEEK_STATUS_OK; -} - -FLAC__StreamDecoderTellStatus flac_decoder_tell_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) -{ - EncoderSession *e = (EncoderSession*)client_data; - FLAC__off_t pos; - (void)decoder; - - if((pos = ftello(e->fin)) < 0) - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - else { - *absolute_byte_offset = (FLAC__uint64)pos; - return FLAC__STREAM_DECODER_TELL_STATUS_OK; - } -} - -FLAC__StreamDecoderLengthStatus flac_decoder_length_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) -{ - const EncoderSession *e = (EncoderSession*)client_data; - const FLACDecoderData *data = &e->fmt.flac.client_data; - (void)decoder; - - if(data->filesize < 0) - return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; - else { - *stream_length = (FLAC__uint64)data->filesize; - return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; - } -} - -FLAC__bool flac_decoder_eof_callback(const FLAC__StreamDecoder *decoder, void *client_data) -{ - EncoderSession *e = (EncoderSession*)client_data; - (void)decoder; - - return feof(e->fin)? true : false; -} - -FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - EncoderSession *e = (EncoderSession*)client_data; - FLACDecoderData *data = &e->fmt.flac.client_data; - FLAC__uint64 n = min(data->samples_left_to_process, frame->header.blocksize); - (void)decoder; - - /* Do some checks */ - if(frame->header.channels != e->info.channels) { - print_error_with_state(e, "ERROR: number of channels of input changed mid-stream"); - data->fatal_error = true; - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - if(frame->header.bits_per_sample > e->info.bits_per_sample) { - print_error_with_state(e, "ERROR: bits-per-sample of input changed mid-stream"); - data->fatal_error = true; - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - if(!EncoderSession_process(e, buffer, (uint32_t)n)) { - print_error_with_state(e, "ERROR during encoding"); - data->fatal_error = true; - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - data->samples_left_to_process -= n; - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void flac_decoder_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - EncoderSession *e = (EncoderSession*)client_data; - FLACDecoderData *data = &e->fmt.flac.client_data; - (void)decoder; - - if (data->fatal_error) - return; - - if ( - data->num_metadata_blocks == sizeof(data->metadata_blocks)/sizeof(data->metadata_blocks[0]) || - 0 == (data->metadata_blocks[data->num_metadata_blocks] = FLAC__metadata_object_clone(metadata)) - ) - data->fatal_error = true; - else - data->num_metadata_blocks++; -} - -void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - EncoderSession *e = (EncoderSession*)client_data; - FLACDecoderData *data = &e->fmt.flac.client_data; - (void)decoder; - - stats_print_name(1, e->inbasefilename); - flac__utils_printf(stderr, 1, "ERROR got %s while decoding FLAC input\n", FLAC__StreamDecoderErrorStatusString[status]); - if(!e->continue_through_decode_errors) - data->fatal_error = true; -} - -FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors) -{ - FILE *f; - uint32_t last_line_read; - const char *error_message; - - if(0 == cuesheet_filename) - return true; - - if(lead_out_offset == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR cannot import cuesheet when the number of input samples to encode is unknown\n", inbasefilename); - return false; - } - - if(0 == (f = flac_fopen(cuesheet_filename, "r"))) { - flac__utils_printf(stderr, 1, "%s: ERROR opening cuesheet \"%s\" for reading: %s\n", inbasefilename, cuesheet_filename, strerror(errno)); - return false; - } - - *cuesheet = grabbag__cuesheet_parse(f, &error_message, &last_line_read, sample_rate, is_cdda, lead_out_offset); - - fclose(f); - - if(0 == *cuesheet) { - flac__utils_printf(stderr, 1, "%s: ERROR parsing cuesheet \"%s\" on line %u: %s\n", inbasefilename, cuesheet_filename, last_line_read, error_message); - return false; - } - - if(!FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/false, &error_message)) { - flac__utils_printf(stderr, 1, "%s: ERROR parsing cuesheet \"%s\": %s\n", inbasefilename, cuesheet_filename, error_message); - return false; - } - - /* if we're expecting CDDA, warn about non-compliance */ - if(is_cdda && !FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/true, &error_message)) { - flac__utils_printf(stderr, 1, "%s: WARNING cuesheet \"%s\" is not audio CD compliant: %s\n", inbasefilename, cuesheet_filename, error_message); - if(treat_warnings_as_errors) - return false; - (*cuesheet)->data.cue_sheet.is_cd = false; - } - - return true; -} - -static void print_stats(const EncoderSession *encoder_session) -{ - if(flac__utils_verbosity_ >= 2) { - char ratiostr[16]; - - FLAC__ASSERT(encoder_session->total_samples_to_encode > 0); - - if (encoder_session->compression_ratio > 0.0) - flac_snprintf(ratiostr, sizeof(ratiostr), "%0.3f", encoder_session->compression_ratio); - else - flac_snprintf(ratiostr, sizeof(ratiostr), "N/A"); - - if(encoder_session->samples_written == encoder_session->total_samples_to_encode) { - stats_print_name(2, encoder_session->inbasefilename); - stats_print_info(2, "%swrote %" PRIu64 " bytes, ratio=%s", - encoder_session->verify? "Verify OK, " : "", - encoder_session->bytes_written, - ratiostr - ); - } - else { - stats_print_name(2, encoder_session->inbasefilename); - stats_print_info(2, "%u%% complete, ratio=%s", (uint32_t)floor(encoder_session->progress * 100.0 + 0.5), ratiostr); - } - } -} - -void print_error_with_init_status(const EncoderSession *e, const char *message, FLAC__StreamEncoderInitStatus init_status) -{ - const int ilen = strlen(e->inbasefilename) + 1; - const char *state_string = ""; - - flac__utils_printf(stderr, 1, "\n%s: %s\n", e->inbasefilename, message); - - flac__utils_printf(stderr, 1, "%*s init_status = %s\n", ilen, "", FLAC__StreamEncoderInitStatusString[init_status]); - - if(init_status == FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR) { - state_string = FLAC__stream_encoder_get_resolved_state_string(e->encoder); - - flac__utils_printf(stderr, 1, "%*s state = %s\n", ilen, "", state_string); - - /* print out some more info for some errors: */ - if(0 == strcmp(state_string, FLAC__StreamEncoderStateString[FLAC__STREAM_ENCODER_CLIENT_ERROR])) { - flac__utils_printf(stderr, 1, - "\n" - "An error occurred while writing; the most common cause is that the disk is full.\n" - ); - } - else if(0 == strcmp(state_string, FLAC__StreamEncoderStateString[FLAC__STREAM_ENCODER_IO_ERROR])) { - flac__utils_printf(stderr, 1, - "\n" - "An error occurred opening the output file; it is likely that the output\n" - "directory does not exist or is not writable, the output file already exists and\n" -#ifdef _WIN32 - "is not writeable, the disk is full or the file has a filename that exceeds the\n" - "path length limit.\n" -#else - "is not writable, or the disk is full.\n" -#endif - ); - } - } - else if(init_status == FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE) { - flac__utils_printf(stderr, 1, - "\n" - "The encoding parameters specified do not conform to the FLAC Subset and may not\n" - "be streamable or playable in hardware devices. If you really understand the\n" - "consequences, you can add --lax to the command-line options to encode with\n" - "these parameters anyway. See http://xiph.org/flac/format.html#subset\n" - ); - } -} - -void print_error_with_state(const EncoderSession *e, const char *message) -{ - const int ilen = strlen(e->inbasefilename) + 1; - const char *state_string; - - flac__utils_printf(stderr, 1, "\n%s: %s\n", e->inbasefilename, message); - - state_string = FLAC__stream_encoder_get_resolved_state_string(e->encoder); - - flac__utils_printf(stderr, 1, "%*s state = %s\n", ilen, "", state_string); - - /* print out some more info for some errors: */ - if(0 == strcmp(state_string, FLAC__StreamEncoderStateString[FLAC__STREAM_ENCODER_CLIENT_ERROR])) { - flac__utils_printf(stderr, 1, - "\n" - "An error occurred while writing; the most common cause is that the disk is full.\n" - ); - } -} - -void print_verify_error(EncoderSession *e) -{ - FLAC__uint64 absolute_sample; - uint32_t frame_number; - uint32_t channel; - uint32_t sample; - FLAC__int32 expected; - FLAC__int32 got; - - FLAC__stream_encoder_get_verify_decoder_error_stats(e->encoder, &absolute_sample, &frame_number, &channel, &sample, &expected, &got); - - flac__utils_printf(stderr, 1, "%s: ERROR: mismatch in decoded data, verify FAILED!\n", e->inbasefilename); - flac__utils_printf(stderr, 1, " Absolute sample=%" PRIu64 ", frame=%u, channel=%u, sample=%u, expected %d, got %d\n", absolute_sample, frame_number, channel, sample, expected, got); - flac__utils_printf(stderr, 1, " In all known cases, verify errors are caused by hardware problems,\n"); - flac__utils_printf(stderr, 1, " usually overclocking or bad RAM. Delete %s\n", e->outfilename); - flac__utils_printf(stderr, 1, " and repeat the flac command exactly as before. If it does not give a\n"); - flac__utils_printf(stderr, 1, " verify error in the exact same place each time you try it, then there is\n"); - flac__utils_printf(stderr, 1, " a problem with your hardware; please see the FAQ:\n"); - flac__utils_printf(stderr, 1, " http://xiph.org/flac/faq.html#tools__hardware_prob\n"); - flac__utils_printf(stderr, 1, " If it does fail in the exact same place every time, keep\n"); - flac__utils_printf(stderr, 1, " %s and submit a bug report to:\n", e->outfilename); - flac__utils_printf(stderr, 1, " https://github.com/xiph/flac/issues\n"); - flac__utils_printf(stderr, 1, " Make sure to upload the FLAC file and use the \"Monitor\" feature to\n"); - flac__utils_printf(stderr, 1, " monitor the bug status.\n"); - flac__utils_printf(stderr, 1, "Verify FAILED! Do not trust %s\n", e->outfilename); -} - -FLAC__bool read_bytes(FILE *f, FLAC__byte *buf, size_t n, FLAC__bool eof_ok, const char *fn) -{ - size_t bytes_read = fread(buf, 1, n, f); - - if(bytes_read == 0) { - if(!eof_ok) { - flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn); - return false; - } - else - return true; - } - if(bytes_read < n) { - flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn); - return false; - } - return true; -} - -FLAC__bool read_uint16(FILE *f, FLAC__bool big_endian, FLAC__uint16 *val, const char *fn) -{ - if(!read_bytes(f, (FLAC__byte*)val, 2, /*eof_ok=*/false, fn)) - return false; - if(is_big_endian_host_ != big_endian) { - FLAC__byte tmp, *b = (FLAC__byte*)val; - tmp = b[1]; b[1] = b[0]; b[0] = tmp; - } - return true; -} - -FLAC__bool read_uint32(FILE *f, FLAC__bool big_endian, FLAC__uint32 *val, const char *fn) -{ - if(!read_bytes(f, (FLAC__byte*)val, 4, /*eof_ok=*/false, fn)) - return false; - if(is_big_endian_host_ != big_endian) { - FLAC__byte tmp, *b = (FLAC__byte*)val; - tmp = b[3]; b[3] = b[0]; b[0] = tmp; - tmp = b[2]; b[2] = b[1]; b[1] = tmp; - } - return true; -} - -FLAC__bool read_uint64(FILE *f, FLAC__bool big_endian, FLAC__uint64 *val, const char *fn) -{ - if(!read_bytes(f, (FLAC__byte*)val, 8, /*eof_ok=*/false, fn)) - return false; - if(is_big_endian_host_ != big_endian) { - FLAC__byte tmp, *b = (FLAC__byte*)val; - tmp = b[7]; b[7] = b[0]; b[0] = tmp; - tmp = b[6]; b[6] = b[1]; b[1] = tmp; - tmp = b[5]; b[5] = b[2]; b[2] = tmp; - tmp = b[4]; b[4] = b[3]; b[3] = tmp; - } - return true; -} - -FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, const char *fn) - /* Read an IEEE 754 80-bit (aka SANE) extended floating point value from 'f', - * convert it into an integral value and store in 'val'. Return false if only - * between 1 and 9 bytes remain in 'f', if 0 bytes remain in 'f', or if the - * value is negative, between zero and one, or too large to be represented by - * 'val'; return true otherwise. - */ -{ - uint32_t i; - FLAC__byte buf[10]; - FLAC__uint64 p = 0; - FLAC__int16 e; - FLAC__int16 shift; - - if(!read_bytes(f, buf, sizeof(buf), /*eof_ok=*/false, fn)) - return false; - e = ((FLAC__uint16)(buf[0])<<8 | (FLAC__uint16)(buf[1]))-0x3FFF; - shift = 63-e; - if((buf[0]>>7)==1U || e<0 || e>=63) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid floating-point value\n", fn); - return false; - } - - for(i = 0; i < 8; ++i) - p |= (FLAC__uint64)(buf[i+2])<<(56U-i*8); - *val = (FLAC__uint32)((p>>shift)+(p>>(shift-1) & 0x1)); - - return true; -} - -FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset) -{ - static uint8_t dump[8192]; - struct flac_stat_s stb; - - if(flac_fstat(fileno(f), &stb) == 0 && (stb.st_mode & S_IFMT) == S_IFREG) - { - if(fseeko(f, offset, SEEK_CUR) == 0) - return true; - } - while(offset > 0) { - const long need = (long)min(offset, sizeof(dump)); - if((long)fread(dump, 1, need, f) < need) - return false; - offset -= need; - } - return true; -} - -uint32_t count_channel_mask_bits(FLAC__uint32 mask) -{ - uint32_t count = 0; - while(mask) { - if(mask & 1) - count++; - mask >>= 1; - } - return count; -} - diff --git a/Engine/lib/flac/src/flac/encode.h b/Engine/lib/flac/src/flac/encode.h deleted file mode 100644 index 2d65c5068..000000000 --- a/Engine/lib/flac/src/flac/encode.h +++ /dev/null @@ -1,116 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef flac__encode_h -#define flac__encode_h - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/metadata.h" -#include "foreign_metadata.h" -#include "utils.h" -#include "share/compat.h" - -extern const int FLAC_ENCODE__DEFAULT_PADDING; - -typedef enum { - CST_BLOCKSIZE, - CST_COMPRESSION_LEVEL, - CST_DO_MID_SIDE, - CST_LOOSE_MID_SIDE, - CST_APODIZATION, - CST_MAX_LPC_ORDER, - CST_QLP_COEFF_PRECISION, - CST_DO_QLP_COEFF_PREC_SEARCH, - CST_DO_ESCAPE_CODING, - CST_DO_EXHAUSTIVE_MODEL_SEARCH, - CST_MIN_RESIDUAL_PARTITION_ORDER, - CST_MAX_RESIDUAL_PARTITION_ORDER, - CST_RICE_PARAMETER_SEARCH_DIST -} compression_setting_type_t; - -typedef struct { - compression_setting_type_t type; - union { - FLAC__bool t_bool; - unsigned t_unsigned; - const char *t_string; - } value; -} compression_setting_t; - -typedef struct { - utils__SkipUntilSpecification skip_specification; - utils__SkipUntilSpecification until_specification; - FLAC__bool verify; -#if FLAC__HAS_OGG - FLAC__bool use_ogg; - long serial_number; -#endif - FLAC__bool lax; - int padding; - size_t num_compression_settings; - compression_setting_t compression_settings[64]; - char *requested_seek_points; - int num_requested_seek_points; - const char *cuesheet_filename; - FLAC__bool treat_warnings_as_errors; - FLAC__bool continue_through_decode_errors; /* currently only obeyed when encoding from FLAC or Ogg FLAC */ - FLAC__bool cued_seekpoints; - FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */ - - FLAC__bool is_first_file; - FLAC__bool is_last_file; - FLAC__bool replay_gain; - FLAC__bool ignore_chunk_sizes; - FLAC__bool error_on_compression_fail; - FLAC__bool limit_min_bitrate; - FLAC__bool relaxed_foreign_metadata_handling; - - FLAC__StreamMetadata *vorbis_comment; - FLAC__StreamMetadata *vorbis_comment_with_channel_mask_tag; - FLAC__StreamMetadata *pictures[64]; - unsigned num_pictures; - - FileFormat format; - union { - struct { - FLAC__bool is_big_endian; - FLAC__bool is_unsigned_samples; - unsigned channels; - unsigned bps; - unsigned sample_rate; - } raw; - struct { - foreign_metadata_t *foreign_metadata; /* NULL unless --keep-foreign-metadata requested */ - } iff; - } format_options; - - struct { - FLAC__bool disable_constant_subframes; - FLAC__bool disable_fixed_subframes; - FLAC__bool disable_verbatim_subframes; - FLAC__bool do_md5; - } debug; -} encode_options_t; - -int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length, encode_options_t options); - -#endif diff --git a/Engine/lib/flac/src/flac/foreign_metadata.c b/Engine/lib/flac/src/flac/foreign_metadata.c deleted file mode 100644 index f63fc3e60..000000000 --- a/Engine/lib/flac/src/flac/foreign_metadata.c +++ /dev/null @@ -1,952 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include /* for FILE etc. */ -#include /* for calloc() etc. */ -#include /* for memcmp() etc. */ -#include "FLAC/assert.h" -#include "FLAC/metadata.h" -#include "share/alloc.h" -#include "share/compat.h" -#include "foreign_metadata.h" - -#ifdef min -#undef min -#endif -#define min(x,y) ((x)<(y)?(x):(y)) - -const char *FLAC__FOREIGN_METADATA_APPLICATION_ID[FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS] = { "aiff" , "riff", "w64 " }; - -static FLAC__uint32 unpack32be_(const FLAC__byte *b) -{ - return ((FLAC__uint32)b[0]<<24) + ((FLAC__uint32)b[1]<<16) + ((FLAC__uint32)b[2]<<8) + (FLAC__uint32)b[3]; -} - -static FLAC__uint32 unpack32le_(const FLAC__byte *b) -{ - return (FLAC__uint32)b[0] + ((FLAC__uint32)b[1]<<8) + ((FLAC__uint32)b[2]<<16) + ((FLAC__uint32)b[3]<<24); -} - -static FLAC__uint64 unpack64le_(const FLAC__byte *b) -{ - return (FLAC__uint64)b[0] + ((FLAC__uint64)b[1]<<8) + ((FLAC__uint64)b[2]<<16) + ((FLAC__uint64)b[3]<<24) + ((FLAC__uint64)b[4]<<32) + ((FLAC__uint64)b[5]<<40) + ((FLAC__uint64)b[6]<<48) + ((FLAC__uint64)b[7]<<56); -} - -/* copies 'size' bytes from file 'fin' to 'fout', filling in *error with 'read_error' or 'write_error' as necessary */ -static FLAC__bool copy_data_(FILE *fin, FILE *fout, size_t size, const char **error, const char * const read_error, const char * const write_error) -{ - FLAC__byte buffer[4096]; - size_t left; - for(left = size; left > 0; ) { - size_t need = min(sizeof(buffer), left); - if(fread(buffer, 1, need, fin) < need) { - if(error) *error = read_error; - return false; - } - if(fwrite(buffer, 1, need, fout) < need) { - if(error) *error = write_error; - return false; - } - left -= need; - } - return true; -} - -/* compare 'size' bytes from file 'fin' to 'fout', filling in *error with 'read_error' or 'write_error' as necessary */ -static FLAC__bool compare_data_(FILE *fin, FILE *fout, size_t size, const char **error, const char * const read_error, const char * const write_error, const char * const compare_error) -{ - FLAC__byte buffer_in[4096]; - FLAC__byte buffer_out[4096]; /* sizes need to be the same */ - size_t left; - for(left = size; left > 0; ) { - size_t need = min(sizeof(buffer_in), left); - if(fread(buffer_in, 1, need, fin) < need) { - if(error) *error = read_error; - return false; - } - if(fread(buffer_out, 1, need, fout) < need) { - if(error) *error = write_error; - return false; - } - if(memcmp(buffer_in, buffer_out, need)) { - if(error) *error = compare_error; - return false; - } - left -= need; - } - return true; -} - -static FLAC__bool append_block_(foreign_metadata_t *fm, FLAC__off_t offset, FLAC__uint32 size, const char **error) -{ - foreign_block_t *fb; - if(size >= ((1u << FLAC__STREAM_METADATA_LENGTH_LEN) - FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)) { - if(error) *error = "found foreign metadata chunk is too large (max is 16MiB per chunk)"; - return false; - } - fb = safe_realloc_nofree_muladd2_(fm->blocks, sizeof(foreign_block_t), /*times (*/fm->num_blocks, /*+*/1/*)*/); - if(fb) { - fb[fm->num_blocks].offset = offset; - fb[fm->num_blocks].size = size; - fm->num_blocks++; - fm->blocks = fb; - return true; - } - if(error) *error = "out of memory"; - return false; -} - -static FLAC__bool read_from_aiff_(foreign_metadata_t *fm, FILE *f, const char **error) -{ - FLAC__byte buffer[12]; - FLAC__off_t offset, eof_offset; - if((offset = ftello(f)) < 0) { - if(error) *error = "ftello() error (001)"; - return false; - } - if(fread(buffer, 1, 12, f) < 12 || memcmp(buffer, "FORM", 4) || (memcmp(buffer+8, "AIFF", 4) && memcmp(buffer+8, "AIFC", 4))) { - if(error) *error = "unsupported FORM layout (002)"; - return false; - } - if(!append_block_(fm, offset, 12, error)) - return false; - eof_offset = (FLAC__off_t)8 + (FLAC__off_t)unpack32be_(buffer+4); - while(!feof(f)) { - FLAC__uint32 size; - if((offset = ftello(f)) < 0) { - if(error) *error = "ftello() error (003)"; - return false; - } - if((size = fread(buffer, 1, 8, f)) < 8) { - if(size == 0 && feof(f)) - break; - if(error) *error = "invalid AIFF file (004)"; - return false; - } - size = unpack32be_(buffer+4); - /* check if pad byte needed */ - if(size & 1) - size++; - if(!memcmp(buffer, "COMM", 4)) { - if(fm->format_block) { - if(error) *error = "invalid AIFF file: multiple \"COMM\" chunks (005)"; - return false; - } - if(fm->audio_block) { - if(error) *error = "invalid AIFF file: \"SSND\" chunk before \"COMM\" chunk (006)"; - return false; - } - fm->format_block = fm->num_blocks; - } - else if(!memcmp(buffer, "SSND", 4)) { - if(fm->audio_block) { - if(error) *error = "invalid AIFF file: multiple \"SSND\" chunks (007)"; - return false; - } - if(!fm->format_block) { - if(error) *error = "invalid AIFF file: \"SSND\" chunk before \"COMM\" chunk (008)"; - return false; - } - fm->audio_block = fm->num_blocks; - /* read #offset bytes */ - if(fread(buffer+8, 1, 4, f) < 4) { - if(error) *error = "invalid AIFF file (009)"; - return false; - } - fm->ssnd_offset_size = unpack32be_(buffer+8); - if(fseeko(f, -4, SEEK_CUR) < 0) { - if(error) *error = "invalid AIFF file: seek error (010)"; - return false; - } - /* WATCHOUT: For SSND we ignore the blockSize and are not saving any - * unaligned part at the end of the chunk. In retrospect it is pretty - * pointless to save the unaligned data before the PCM but now it is - * done and cast in stone. - */ - } - if(!append_block_(fm, offset, 8 + (memcmp(buffer, "SSND", 4)? size : 8 + fm->ssnd_offset_size), error)) - return false; - /* skip to next chunk */ - if(fseeko(f, size, SEEK_CUR) < 0) { - if(error) *error = "invalid AIFF file: seek error (011)"; - return false; - } - } - if(eof_offset != ftello(f)) { - if(error) *error = "invalid AIFF file: unexpected EOF (012)"; - return false; - } - if(!fm->format_block) { - if(error) *error = "invalid AIFF file: missing \"COMM\" chunk (013)"; - return false; - } - if(!fm->audio_block) { - if(error) *error = "invalid AIFF file: missing \"SSND\" chunk (014)"; - return false; - } - return true; -} - -static FLAC__bool read_from_wave_(foreign_metadata_t *fm, FILE *f, const char **error) -{ - FLAC__byte buffer[12]; - FLAC__off_t offset, eof_offset = -1, ds64_data_size = -1; - if((offset = ftello(f)) < 0) { - if(error) *error = "ftello() error (001)"; - return false; - } - if(fread(buffer, 1, 12, f) < 12 || (memcmp(buffer, "RIFF", 4) && memcmp(buffer, "RF64", 4)) || memcmp(buffer+8, "WAVE", 4)) { - if(error) *error = "unsupported RIFF layout (002)"; - return false; - } - if(!memcmp(buffer, "RF64", 4)) - fm->is_rf64 = true; - if(fm->is_rf64 && sizeof(FLAC__off_t) < 8) { - if(error) *error = "RF64 is not supported on this compile (r00)"; - return false; - } - if(!append_block_(fm, offset, 12, error)) - return false; - if(!fm->is_rf64 || unpack32le_(buffer+4) != 0xffffffff) { - eof_offset = (FLAC__off_t)8 + (FLAC__off_t)unpack32le_(buffer+4); - if(eof_offset & 1) /* fix odd RIFF size */ - eof_offset++; - } - while(!feof(f)) { - FLAC__off_t size; - if((offset = ftello(f)) < 0) { - if(error) *error = "ftello() error (003)"; - return false; - } - if((size = fread(buffer, 1, 8, f)) < 8) { - if(size == 0 && feof(f)) - break; - if(error) *error = "invalid WAVE file (004)"; - return false; - } - size = unpack32le_(buffer+4); - /* check if pad byte needed */ - if(size & 1) - size++; - if(!memcmp(buffer, "fmt ", 4)) { - if(fm->format_block) { - if(error) *error = "invalid WAVE file: multiple \"fmt \" chunks (005)"; - return false; - } - if(fm->audio_block) { - if(error) *error = "invalid WAVE file: \"data\" chunk before \"fmt \" chunk (006)"; - return false; - } - fm->format_block = fm->num_blocks; - } - else if(!memcmp(buffer, "data", 4)) { - if(fm->audio_block) { - if(error) *error = "invalid WAVE file: multiple \"data\" chunks (007)"; - return false; - } - if(!fm->format_block) { - if(error) *error = "invalid WAVE file: \"data\" chunk before \"fmt \" chunk (008)"; - return false; - } - fm->audio_block = fm->num_blocks; - if(fm->is_rf64 && fm->num_blocks < 2) { - if(error) *error = "invalid RF64 file: \"data\" chunk before \"ds64\" chunk (r01)"; - return false; - } - } - if(!append_block_(fm, offset, 8 + (memcmp(buffer, "data", 4)? size : 0), error)) - return false; - /* parse ds64 chunk if necessary */ - if(fm->is_rf64 && fm->num_blocks == 2) { - FLAC__byte buffer2[7*4]; - if(memcmp(buffer, "ds64", 4)) { - if(error) *error = "invalid RF64 file: \"ds64\" chunk does not immediately follow \"WAVE\" marker (r02)"; - return false; - } - /* unpack the size again since we don't want the padding byte effect */ - size = unpack32le_(buffer+4); - if(size < (FLAC__off_t)sizeof(buffer2)) { - if(error) *error = "invalid RF64 file: \"ds64\" chunk size is < 28 (r03)"; - return false; - } - if(size > (FLAC__off_t)sizeof(buffer2)) { - if(error) *error = "RF64 file has \"ds64\" chunk with extra size table, which is not currently supported (r04)"; - return false; - } - if(fread(buffer2, 1, sizeof(buffer2), f) < sizeof(buffer2)) { - if(error) *error = "unexpected EOF reading \"ds64\" chunk data in RF64 file (r05)"; - return false; - } - ds64_data_size = (FLAC__off_t)unpack64le_(buffer2+8); - if(ds64_data_size == (FLAC__off_t)(-1)) { - if(error) *error = "RF64 file has \"ds64\" chunk with data size == -1 (r08)"; - return false; - } - /* check if pad byte needed */ - if(ds64_data_size & 1) - ds64_data_size++; - /* @@@ [2^63 limit] */ - if(ds64_data_size < 0) { - if(error) *error = "RF64 file too large (r09)"; - return false; - } - if(unpack32le_(buffer2+24)) { - if(error) *error = "RF64 file has \"ds64\" chunk with extra size table, which is not currently supported (r06)"; - return false; - } - eof_offset = (FLAC__off_t)8 + (FLAC__off_t)unpack64le_(buffer2); - /* @@@ [2^63 limit] */ - if((FLAC__off_t)unpack64le_(buffer2) < 0 || eof_offset < 0) { - if(error) *error = "RF64 file too large (r07)"; - return false; - } - } - else { /* skip to next chunk */ - if(fm->is_rf64 && !memcmp(buffer, "data", 4) && unpack32le_(buffer+4) == 0xffffffff) { - if(fseeko(f, ds64_data_size, SEEK_CUR) < 0) { - if(error) *error = "invalid RF64 file: seek error (r10)"; - return false; - } - } - else { - if(fseeko(f, size, SEEK_CUR) < 0) { - if(error) *error = "invalid WAVE file: seek error (009)"; - return false; - } - } - } - } - if(fm->is_rf64 && eof_offset == (FLAC__off_t)(-1)) { - if(error) *error = "invalid RF64 file: all RIFF sizes are -1 (r11)"; - return false; - } - if(eof_offset != ftello(f)) { - if(error) *error = "invalid WAVE file: unexpected EOF (010)"; - return false; - } - if(!fm->format_block) { - if(error) *error = "invalid WAVE file: missing \"fmt \" chunk (011)"; - return false; - } - if(!fm->audio_block) { - if(error) *error = "invalid WAVE file: missing \"data\" chunk (012)"; - return false; - } - return true; -} - -static FLAC__bool read_from_wave64_(foreign_metadata_t *fm, FILE *f, const char **error) -{ - FLAC__byte buffer[40]; - FLAC__off_t offset, eof_offset = -1; - if((offset = ftello(f)) < 0) { - if(error) *error = "ftello() error (001)"; - return false; - } - if( - fread(buffer, 1, 40, f) < 40 || - /* RIFF GUID 66666972-912E-11CF-A5D6-28DB04C10000 */ - memcmp(buffer, "\x72\x69\x66\x66\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00", 16) || - /* WAVE GUID 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */ - memcmp(buffer+24, "\x77\x61\x76\x65\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16) - ) { - if(error) *error = "unsupported Wave64 layout (002)"; - return false; - } - if(sizeof(FLAC__off_t) < 8) { - if(error) *error = "Wave64 is not supported on this compile (r00)"; - return false; - } - if(!append_block_(fm, offset, 40, error)) - return false; - eof_offset = (FLAC__off_t)unpack64le_(buffer+16); /*@@@ [2^63 limit] */ - while(!feof(f)) { - FLAC__uint64 size; - if((offset = ftello(f)) < 0) { - if(error) *error = "ftello() error (003)"; - return false; - } - if((size = fread(buffer, 1, 24, f)) < 24) { - if(size == 0 && feof(f)) - break; - if(error) *error = "invalid Wave64 file (004)"; - return false; - } - size = unpack64le_(buffer+16); - /* check if pad bytes needed */ - if(size & 7) - size = (size+7) & (~((FLAC__uint64)7)); - /* fmt GUID 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */ - if(!memcmp(buffer, "\x66\x6D\x74\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)) { - if(fm->format_block) { - if(error) *error = "invalid Wave64 file: multiple \"fmt \" chunks (005)"; - return false; - } - if(fm->audio_block) { - if(error) *error = "invalid Wave64 file: \"data\" chunk before \"fmt \" chunk (006)"; - return false; - } - fm->format_block = fm->num_blocks; - } - /* data GUID 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */ - else if(!memcmp(buffer, "\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)) { - if(fm->audio_block) { - if(error) *error = "invalid Wave64 file: multiple \"data\" chunks (007)"; - return false; - } - if(!fm->format_block) { - if(error) *error = "invalid Wave64 file: \"data\" chunk before \"fmt \" chunk (008)"; - return false; - } - fm->audio_block = fm->num_blocks; - } - if(!append_block_(fm, offset, memcmp(buffer, "\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 16)? (FLAC__uint32)size : 16+8, error)) - return false; - /* skip to next chunk */ - if(fseeko(f, size-24, SEEK_CUR) < 0) { - if(error) *error = "invalid Wave64 file: seek error (009)"; - return false; - } - } - if(eof_offset != ftello(f)) { - if(error) *error = "invalid Wave64 file: unexpected EOF (010)"; - return false; - } - if(!fm->format_block) { - if(error) *error = "invalid Wave64 file: missing \"fmt \" chunk (011)"; - return false; - } - if(!fm->audio_block) { - if(error) *error = "invalid Wave64 file: missing \"data\" chunk (012)"; - return false; - } - return true; -} - -static FLAC__bool write_to_flac_(foreign_metadata_t *fm, FILE *fin, FILE *fout, FLAC__Metadata_SimpleIterator *it, const char **error) -{ - FLAC__byte buffer[4]; - const uint32_t ID_LEN = FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8; - size_t block_num = 0; - FLAC__ASSERT(sizeof(buffer) >= ID_LEN); - while(block_num < fm->num_blocks) { - /* find next matching padding block */ - do { - /* even on the first chunk's loop there will be a skippable STREAMINFO block, on subsequent loops we are first moving past the PADDING we just used */ - if(!FLAC__metadata_simple_iterator_next(it)) { - if(error) *error = "no matching PADDING block found (004)"; - return false; - } - } while(FLAC__metadata_simple_iterator_get_block_type(it) != FLAC__METADATA_TYPE_PADDING); - if(FLAC__metadata_simple_iterator_get_block_length(it) != ID_LEN+fm->blocks[block_num].size) { - if(error) *error = "PADDING block with wrong size found (005)"; - return false; - } - /* transfer chunk into APPLICATION block */ - /* first set up the file pointers */ - if(fseeko(fin, fm->blocks[block_num].offset, SEEK_SET) < 0) { - if(error) *error = "seek failed in WAVE/AIFF file (006)"; - return false; - } - if(fseeko(fout, FLAC__metadata_simple_iterator_get_block_offset(it), SEEK_SET) < 0) { - if(error) *error = "seek failed in FLAC file (007)"; - return false; - } - /* update the type */ - buffer[0] = FLAC__METADATA_TYPE_APPLICATION; - if(FLAC__metadata_simple_iterator_is_last(it)) - buffer[0] |= 0x80; /*MAGIC number*/ - if(fwrite(buffer, 1, 1, fout) < 1) { - if(error) *error = "write failed in FLAC file (008)"; - return false; - } - /* length stays the same so skip over it */ - if(fseeko(fout, FLAC__STREAM_METADATA_LENGTH_LEN/8, SEEK_CUR) < 0) { - if(error) *error = "seek failed in FLAC file (009)"; - return false; - } - /* write the APPLICATION ID */ - memcpy(buffer, FLAC__FOREIGN_METADATA_APPLICATION_ID[fm->type], ID_LEN); - if(fwrite(buffer, 1, ID_LEN, fout) < ID_LEN) { - if(error) *error = "write failed in FLAC file (010)"; - return false; - } - /* transfer the foreign metadata */ - if(!copy_data_(fin, fout, fm->blocks[block_num].size, error, "read failed in WAVE/AIFF file (011)", "write failed in FLAC file (012)")) - return false; - block_num++; - } - return true; -} - -static FLAC__bool read_from_flac_(foreign_metadata_t *fm, FILE *f, FLAC__Metadata_SimpleIterator *it, const char **error) -{ - FLAC__byte id[4], buffer[32]; - FLAC__off_t offset; - FLAC__uint32 length; - FLAC__bool first_block = true, type_found = false, ds64_found = false; - - FLAC__ASSERT(FLAC__STREAM_METADATA_APPLICATION_ID_LEN == sizeof(id)*8); - - while(FLAC__metadata_simple_iterator_next(it)) { - if(FLAC__metadata_simple_iterator_get_block_type(it) != FLAC__METADATA_TYPE_APPLICATION) - continue; - if(!FLAC__metadata_simple_iterator_get_application_id(it, id)) { - if(error) *error = "FLAC__metadata_simple_iterator_get_application_id() error (002)"; - return false; - } - if(first_block) { - uint32_t i; - for(i = 0; i < FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS; i++) - if(memcmp(id, FLAC__FOREIGN_METADATA_APPLICATION_ID[i], sizeof(id)) == 0) { - fm->type = i; - first_block = false; - } - if(first_block) /* means no first foreign metadata block was found yet */ - continue; - } - else if(memcmp(id, FLAC__FOREIGN_METADATA_APPLICATION_ID[fm->type], sizeof(id))) - continue; - offset = FLAC__metadata_simple_iterator_get_block_offset(it); - length = FLAC__metadata_simple_iterator_get_block_length(it); - /* skip over header and app ID */ - offset += (FLAC__STREAM_METADATA_IS_LAST_LEN + FLAC__STREAM_METADATA_TYPE_LEN + FLAC__STREAM_METADATA_LENGTH_LEN) / 8; - offset += sizeof(id); - /* look for format or audio blocks */ - if(fseeko(f, offset, SEEK_SET) < 0) { - if(error) *error = "seek error (003)"; - return false; - } - if(fread(buffer, 1, 4, f) != 4) { - if(error) *error = "read error (004)"; - return false; - } - if(fm->num_blocks == 0) { /* first block? */ - /* Initialize bools */ - fm->is_wavefmtex = 0; - fm->is_aifc = 0; - fm->is_sowt = 0; - fm->is_rf64 = 0 == memcmp(buffer, "RF64", 4); - - if(fm->type == FOREIGN_BLOCK_TYPE__RIFF && (0 == memcmp(buffer, "RIFF", 4) || fm->is_rf64)) - type_found = true; - else if(fm->type == FOREIGN_BLOCK_TYPE__WAVE64 && 0 == memcmp(buffer, "riff", 4)) /* use first 4 bytes instead of whole GUID */ - type_found = true; - else if(fm->type == FOREIGN_BLOCK_TYPE__AIFF && 0 == memcmp(buffer, "FORM", 4)) { - type_found = true; - if(fread(buffer+4, 1, 8, f) != 8) { - if(error) *error = "read error (020)"; - return false; - } - fm->is_aifc = 0 == memcmp(buffer+8, "AIFC", 4); - } - else { - if(error) *error = "unsupported foreign metadata found, may need newer FLAC decoder (005)"; - return false; - } - } - else if(!type_found) { - FLAC__ASSERT(0); - /* double protection: */ - if(error) *error = "unsupported foreign metadata found, may need newer FLAC decoder (006)"; - return false; - } - else if(fm->type == FOREIGN_BLOCK_TYPE__RIFF) { - if(!memcmp(buffer, "fmt ", 4)) { - if(fm->format_block) { - if(error) *error = "invalid WAVE metadata: multiple \"fmt \" chunks (007)"; - return false; - } - if(fm->audio_block) { - if(error) *error = "invalid WAVE metadata: \"data\" chunk before \"fmt \" chunk (008)"; - return false; - } - fm->format_block = fm->num_blocks; - if(fread(buffer+4, 1, 8, f) != 8) { - if(error) *error = "read error (020)"; - return false; - } - fm->is_wavefmtex = 0 == memcmp(buffer+8, "\xfe\xff", 2); - } - else if(!memcmp(buffer, "data", 4)) { - if(fm->audio_block) { - if(error) *error = "invalid WAVE metadata: multiple \"data\" chunks (009)"; - return false; - } - if(!fm->format_block) { - if(error) *error = "invalid WAVE metadata: \"data\" chunk before \"fmt \" chunk (010)"; - return false; - } - fm->audio_block = fm->num_blocks; - } - else if(fm->is_rf64 && fm->num_blocks == 1) { - if(memcmp(buffer, "ds64", 4)) { - if(error) *error = "invalid RF64 metadata: second chunk is not \"ds64\" (011)"; - return false; - } - ds64_found = true; - } - } - else if(fm->type == FOREIGN_BLOCK_TYPE__WAVE64) { - if(!memcmp(buffer, "fmt ", 4)) { /* use first 4 bytes instead of whole GUID */ - if(fm->format_block) { - if(error) *error = "invalid Wave64 metadata: multiple \"fmt \" chunks (012)"; - return false; - } - if(fm->audio_block) { - if(error) *error = "invalid Wave64 metadata: \"data\" chunk before \"fmt \" chunk (013)"; - return false; - } - fm->format_block = fm->num_blocks; - } - else if(!memcmp(buffer, "data", 4)) { /* use first 4 bytes instead of whole GUID */ - if(fm->audio_block) { - if(error) *error = "invalid Wave64 metadata: multiple \"data\" chunks (014)"; - return false; - } - if(!fm->format_block) { - if(error) *error = "invalid Wave64 metadata: \"data\" chunk before \"fmt \" chunk (015)"; - return false; - } - fm->audio_block = fm->num_blocks; - } - } - else if(fm->type == FOREIGN_BLOCK_TYPE__AIFF) { - if(!memcmp(buffer, "COMM", 4)) { - if(fm->format_block) { - if(error) *error = "invalid AIFF metadata: multiple \"COMM\" chunks (016)"; - return false; - } - if(fm->audio_block) { - if(error) *error = "invalid AIFF metadata: \"SSND\" chunk before \"COMM\" chunk (017)"; - return false; - } - fm->format_block = fm->num_blocks; - if(fm->is_aifc) { - if(fread(buffer+4, 1, 26, f) != 26) { - if(error) *error = "read error (020)"; - return false; - } - fm->is_sowt = 0 == memcmp(buffer+26, "sowt", 2); - fm->aifc_comm_length = length; - } - } - else if(!memcmp(buffer, "SSND", 4)) { - if(fm->audio_block) { - if(error) *error = "invalid AIFF metadata: multiple \"SSND\" chunks (018)"; - return false; - } - if(!fm->format_block) { - if(error) *error = "invalid AIFF metadata: \"SSND\" chunk before \"COMM\" chunk (019)"; - return false; - } - fm->audio_block = fm->num_blocks; - /* read SSND offset size */ - if(fread(buffer+4, 1, 8, f) != 8) { - if(error) *error = "read error (020)"; - return false; - } - fm->ssnd_offset_size = unpack32be_(buffer+8); - } - } - else { - FLAC__ASSERT(0); - /* double protection: */ - if(error) *error = "unsupported foreign metadata found, may need newer FLAC decoder (021)"; - return false; - } - if(!append_block_(fm, offset, FLAC__metadata_simple_iterator_get_block_length(it)-sizeof(id), error)) - return false; - } - if(fm->is_rf64 && !ds64_found) { - if(error) *error = "invalid RF64 file: second chunk is not \"ds64\" (023)"; - return false; - } - if(!fm->format_block) { - if(error) - *error = - fm->type==FOREIGN_BLOCK_TYPE__RIFF? "invalid WAVE file: missing \"fmt \" chunk (024)" : - fm->type==FOREIGN_BLOCK_TYPE__WAVE64? "invalid Wave64 file: missing \"fmt \" chunk (025)" : - "invalid AIFF file: missing \"COMM\" chunk (026)"; - return false; - } - if(!fm->audio_block) { - if(error) - *error = - fm->type==FOREIGN_BLOCK_TYPE__RIFF? "invalid WAVE file: missing \"data\" chunk (027)" : - fm->type==FOREIGN_BLOCK_TYPE__WAVE64? "invalid Wave64 file: missing \"data\" chunk (028)" : - "invalid AIFF file: missing \"SSND\" chunk (029)"; - return false; - } - return true; -} - -static FLAC__bool write_to_iff_(foreign_metadata_t *fm, FILE *fin, FILE *fout, FLAC__off_t offset1, FLAC__off_t offset2, FLAC__off_t offset3, const char **error) -{ - size_t i; - if(fseeko(fout, offset1, SEEK_SET) < 0) { - if(error) *error = "seek failed in WAVE/AIFF file"; - return false; - } - - /* don't write first (RIFF/RF64/FORM) chunk, or ds64 chunk in the case of RF64 */ - for(i = fm->is_rf64?2:1; i < fm->format_block; i++) { - if(fseeko(fin, fm->blocks[i].offset, SEEK_SET) < 0) { - if(error) *error = "seek failed in FLAC file"; - return false; - } - if(!copy_data_(fin, fout, fm->blocks[i].size, error, "read failed in FLAC file", "write failed in WAVE/AIFF file")) - return false; - } - - if(fm->is_aifc) { - /* Need to restore compression type name */ - if(fseeko(fout, 30, SEEK_CUR) < 0) { - if(error) *error = "seek failed in AIFF-C file"; - return false; - } - if(fseeko(fin, fm->blocks[i].offset+30, SEEK_SET) < 0) { - if(error) *error = "seek failed in FLAC file"; - return false; - } - if(!copy_data_(fin, fout, fm->aifc_comm_length-34, error, "read failed in FLAC file", "write failed in WAVE/AIFF file")) - return false; - /* Now seek back */ - if(fseeko(fout, ((FLAC__int32)(fm->aifc_comm_length) * -1) + 4, SEEK_CUR) < 0) { - if(error) *error = "seek failed in AIFF-C file"; - return false; - } - } - if(fseeko(fout, offset2, SEEK_SET) < 0) { - if(error) *error = "seek failed in WAVE/AIFF file (006)"; - return false; - } - for(i = fm->format_block+1; i < fm->audio_block; i++) { - if(fseeko(fin, fm->blocks[i].offset, SEEK_SET) < 0) { - if(error) *error = "seek failed in FLAC file"; - return false; - } - if(!copy_data_(fin, fout, fm->blocks[i].size, error, "read failed in FLAC file", "write failed in WAVE/AIFF file")) - return false; - } - if(fseeko(fout, offset3, SEEK_SET) < 0) { - if(error) *error = "seek failed in WAVE/AIFF file"; - return false; - } - for(i = fm->audio_block+1; i < fm->num_blocks; i++) { - if(fseeko(fin, fm->blocks[i].offset, SEEK_SET) < 0) { - if(error) *error = "seek failed in FLAC file"; - return false; - } - if(!copy_data_(fin, fout, fm->blocks[i].size, error, "read failed in FLAC file", "write failed in WAVE/AIFF file")) - return false; - } - return true; -} - -static FLAC__bool compare_with_iff_(foreign_metadata_t *fm, FILE *fin, FILE *fout, FLAC__off_t offset3, const char **error) -{ - size_t i; - - /* Compare blocks before audio data */ - for(i = 0; i <= (fm->audio_block); i++) { - if(fseeko(fin, fm->blocks[i].offset, SEEK_SET) < 0) { - if(error) *error = "seek failed in FLAC file"; - return false; - } - if(!compare_data_(fin, fout, fm->blocks[i].size, error, "read failed in FLAC file", "read failed in WAVE/AIFF file", - i==0?"stored main chunk length differs from written length":( - i==fm->format_block?"stored foreign format block differs from written block. Perhaps the file is being restored to a different format than that of the original file":( - i==fm->audio_block?"stored audio length differs from written length. Perhaps the file changed in length after being originally encoded":"restore of foreign metadata failed")))) - return false; - } - - /* Seek beyond audio */ - if(fseeko(fout, offset3, SEEK_SET) < 0) { - if(error) *error = "seek failed in WAVE/AIFF file"; - return false; - } - for(; i < fm->num_blocks; i++) { - if(fseeko(fin, fm->blocks[i].offset, SEEK_SET) < 0) { - if(error) *error = "seek failed in FLAC file"; - return false; - } - if(!compare_data_(fin, fout, fm->blocks[i].size, error, "read failed in FLAC file", "read failed in WAVE/AIFF file", "restore of foreign metadata failed")) - return false; - } - return true; -} - -foreign_metadata_t *flac__foreign_metadata_new(foreign_block_type_t type) -{ - /* calloc() to zero all the member variables */ - foreign_metadata_t *x = calloc(sizeof(foreign_metadata_t), 1); - if(x) { - x->type = type; - x->is_rf64 = false; - } - return x; -} - -void flac__foreign_metadata_delete(foreign_metadata_t *fm) -{ - if(fm) { - if(fm->blocks) - free(fm->blocks); - free(fm); - } -} - -FLAC__bool flac__foreign_metadata_read_from_aiff(foreign_metadata_t *fm, const char *filename, const char **error) -{ - FLAC__bool ok; - FILE *f = flac_fopen(filename, "rb"); - if(!f) { - if(error) *error = "can't open AIFF file for reading (000)"; - return false; - } - ok = read_from_aiff_(fm, f, error); - fclose(f); - return ok; -} - -FLAC__bool flac__foreign_metadata_read_from_wave(foreign_metadata_t *fm, const char *filename, const char **error) -{ - FLAC__bool ok; - FILE *f = flac_fopen(filename, "rb"); - if(!f) { - if(error) *error = "can't open WAVE file for reading (000)"; - return false; - } - ok = read_from_wave_(fm, f, error); - fclose(f); - return ok; -} - -FLAC__bool flac__foreign_metadata_read_from_wave64(foreign_metadata_t *fm, const char *filename, const char **error) -{ - FLAC__bool ok; - FILE *f = flac_fopen(filename, "rb"); - if(!f) { - if(error) *error = "can't open Wave64 file for reading (000)"; - return false; - } - ok = read_from_wave64_(fm, f, error); - fclose(f); - return ok; -} - -FLAC__bool flac__foreign_metadata_write_to_flac(foreign_metadata_t *fm, const char *infilename, const char *outfilename, const char **error) -{ - FLAC__bool ok; - FILE *fin, *fout; - FLAC__Metadata_SimpleIterator *it = FLAC__metadata_simple_iterator_new(); - if(!it) { - if(error) *error = "out of memory (000)"; - return false; - } - if(!FLAC__metadata_simple_iterator_init(it, outfilename, /*read_only=*/true, /*preserve_file_stats=*/false)) { - if(error) *error = "can't initialize iterator (001)"; - FLAC__metadata_simple_iterator_delete(it); - return false; - } - if(0 == (fin = flac_fopen(infilename, "rb"))) { - if(error) *error = "can't open WAVE/AIFF file for reading (002)"; - FLAC__metadata_simple_iterator_delete(it); - return false; - } - if(0 == (fout = flac_fopen(outfilename, "r+b"))) { - if(error) *error = "can't open FLAC file for updating (003)"; - FLAC__metadata_simple_iterator_delete(it); - fclose(fin); - return false; - } - ok = write_to_flac_(fm, fin, fout, it, error); - FLAC__metadata_simple_iterator_delete(it); - fclose(fin); - fclose(fout); - return ok; -} - -FLAC__bool flac__foreign_metadata_read_from_flac(foreign_metadata_t *fm, const char *filename, const char **error) -{ - FLAC__bool ok; - FILE *f; - FLAC__Metadata_SimpleIterator *it = FLAC__metadata_simple_iterator_new(); - if(!it) { - if(error) *error = "out of memory (000)"; - return false; - } - if(!FLAC__metadata_simple_iterator_init(it, filename, /*read_only=*/true, /*preserve_file_stats=*/false)) { - if(error) *error = "can't initialize iterator (001)"; - FLAC__metadata_simple_iterator_delete(it); - return false; - } - if(0 == (f = flac_fopen(filename, "rb"))) { - if(error) *error = "can't open FLAC file for reading (002)"; - FLAC__metadata_simple_iterator_delete(it); - return false; - } - ok = read_from_flac_(fm, f, it, error); - FLAC__metadata_simple_iterator_delete(it); - fclose(f); - return ok; -} - -FLAC__bool flac__foreign_metadata_write_to_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, FLAC__off_t offset1, FLAC__off_t offset2, FLAC__off_t offset3, const char **error) -{ - FLAC__bool ok; - FILE *fin, *fout; - if(0 == (fin = flac_fopen(infilename, "rb"))) { - if(error) *error = "can't open FLAC file for reading (000)"; - return false; - } - if(0 == (fout = flac_fopen(outfilename, "r+b"))) { - if(error) *error = "can't open WAVE/AIFF file for updating (001)"; - fclose(fin); - return false; - } - ok = write_to_iff_(fm, fin, fout, offset1, offset2, offset3, error); - fclose(fin); - fclose(fout); - return ok; -} - -FLAC__bool flac__foreign_metadata_compare_with_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, FLAC__off_t offset3, const char **error) -{ - FLAC__bool ok; - FILE *fin, *fout; - if(0 == (fin = flac_fopen(infilename, "rb"))) { - if(error) *error = "can't open FLAC file for reading"; - return false; - } - if(0 == (fout = flac_fopen(outfilename, "rb"))) { - if(error) *error = "can't open WAVE/AIFF file for comparing"; - fclose(fin); - return false; - } - ok = compare_with_iff_(fm, fin, fout, offset3, error); - fclose(fin); - fclose(fout); - return ok; -} diff --git a/Engine/lib/flac/src/flac/foreign_metadata.h b/Engine/lib/flac/src/flac/foreign_metadata.h deleted file mode 100644 index fa68d46f5..000000000 --- a/Engine/lib/flac/src/flac/foreign_metadata.h +++ /dev/null @@ -1,83 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef flac__foreign_metadata_h -#define flac__foreign_metadata_h - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/metadata.h" -#include "utils.h" -#include "share/compat.h" - -#define FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS 3 - -extern const char *FLAC__FOREIGN_METADATA_APPLICATION_ID[FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS]; - -/* WATCHOUT: these enums are used to index internal arrays */ -typedef enum { - FOREIGN_BLOCK_TYPE__AIFF = 0, /* for AIFF and AIFF-C */ - FOREIGN_BLOCK_TYPE__RIFF = 1, /* for WAVE and RF64 */ - FOREIGN_BLOCK_TYPE__WAVE64 = 2 /* only for Sony's flavor */ -} foreign_block_type_t; - -typedef struct { - /* for encoding, this will be the offset in the WAVE/AIFF file of the chunk */ - /* for decoding, this will be the offset in the FLAC file of the chunk data inside the APPLICATION block */ - FLAC__off_t offset; - /* size is the actual size in bytes of the chunk to be stored/recreated. */ - /* It includes the 8 bytes of chunk type and size, and any padding byte for alignment. */ - /* For 'data'/'SSND' chunks, the size does not include the actual sound or padding bytes */ - /* because these are not stored, they are recreated from the compressed FLAC stream. */ - /* So for RIFF 'data', size is 8, and for AIFF 'SSND', size is 8 + 8 + ssnd_offset_size */ - /* 32 bit size is OK because we only care about the non-sound data and FLAC metadata */ - /* only supports a few megs anyway. */ - FLAC__uint32 size; -} foreign_block_t; - -typedef struct { - foreign_block_type_t type; /* currently we don't support multiple foreign types in a stream (and maybe never will) */ - foreign_block_t *blocks; - size_t num_blocks; - size_t format_block; /* block number of 'fmt ' or 'COMM' chunk */ - size_t audio_block; /* block number of 'data' or 'SSND' chunk */ - FLAC__bool is_rf64; /* always false if type!=RIFF */ - FLAC__bool is_wavefmtex; /* always false if type!=RIFF */ - FLAC__bool is_aifc; /* always false if type!=AIFF */ - FLAC__bool is_sowt; /* always false if type!=AIFF */ - FLAC__uint32 aifc_comm_length; - FLAC__uint32 ssnd_offset_size; /* 0 if type!=AIFF */ -} foreign_metadata_t; - -foreign_metadata_t *flac__foreign_metadata_new(foreign_block_type_t type); - -void flac__foreign_metadata_delete(foreign_metadata_t *fm); - -FLAC__bool flac__foreign_metadata_read_from_aiff(foreign_metadata_t *fm, const char *filename, const char **error); -FLAC__bool flac__foreign_metadata_read_from_wave(foreign_metadata_t *fm, const char *filename, const char **error); -FLAC__bool flac__foreign_metadata_read_from_wave64(foreign_metadata_t *fm, const char *filename, const char **error); -FLAC__bool flac__foreign_metadata_write_to_flac(foreign_metadata_t *fm, const char *infilename, const char *outfilename, const char **error); - -FLAC__bool flac__foreign_metadata_read_from_flac(foreign_metadata_t *fm, const char *filename, const char **error); -FLAC__bool flac__foreign_metadata_write_to_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, FLAC__off_t offset1, FLAC__off_t offset2, FLAC__off_t offset3, const char **error); -FLAC__bool flac__foreign_metadata_compare_with_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, FLAC__off_t offset3, const char **error); - -#endif diff --git a/Engine/lib/flac/src/flac/iffscan.c b/Engine/lib/flac/src/flac/iffscan.c deleted file mode 100644 index a5472e0c0..000000000 --- a/Engine/lib/flac/src/flac/iffscan.c +++ /dev/null @@ -1,129 +0,0 @@ -/* iffscan - Simple AIFF/RIFF chunk scanner - * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include "share/compat.h" -#include "foreign_metadata.h" - -static FLAC__uint32 unpack32be_(const FLAC__byte *b) -{ - return ((FLAC__uint32)b[0]<<24) + ((FLAC__uint32)b[1]<<16) + ((FLAC__uint32)b[2]<<8) + (FLAC__uint32)b[3]; -} - -static FLAC__uint32 unpack32le_(const FLAC__byte *b) -{ - return (FLAC__uint32)b[0] + ((FLAC__uint32)b[1]<<8) + ((FLAC__uint32)b[2]<<16) + ((FLAC__uint32)b[3]<<24); -} - -static FLAC__uint64 unpack64le_(const FLAC__byte *b) -{ - return (FLAC__uint64)b[0] + ((FLAC__uint64)b[1]<<8) + ((FLAC__uint64)b[2]<<16) + ((FLAC__uint64)b[3]<<24) + ((FLAC__uint64)b[4]<<32) + ((FLAC__uint64)b[5]<<40) + ((FLAC__uint64)b[6]<<48) + ((FLAC__uint64)b[7]<<56); -} - -static FLAC__uint32 unpack32_(const FLAC__byte *b, foreign_block_type_t type) -{ - if(type == FOREIGN_BLOCK_TYPE__AIFF) - return unpack32be_(b); - else - return unpack32le_(b); -} - -int main(int argc, char *argv[]) -{ - FILE *f; - char buf[36]; - foreign_metadata_t *fm; - const char *fn, *error; - size_t i; - FLAC__uint32 size; - -#ifdef _WIN32 - if (get_utf8_argv(&argc, &argv) != 0) { - fprintf(stderr, "ERROR: failed to convert command line parameters to UTF-8\n"); - return 1; - } -#endif - - if(argc != 2) { - flac_fprintf(stderr, "usage: %s { file.wav | file.aif }\n", argv[0]); - return 1; - } - fn = argv[1]; - if(0 == (f = flac_fopen(fn, "rb")) || fread(buf, 1, 4, f) != 4) { - flac_fprintf(stderr, "ERROR opening %s for reading\n", fn); - return 1; - } - fclose(f); - if(0 == (fm = flac__foreign_metadata_new(memcmp(buf, "RIFF", 4) && memcmp(buf, "RF64", 4)? FOREIGN_BLOCK_TYPE__AIFF : FOREIGN_BLOCK_TYPE__RIFF))) { - flac_fprintf(stderr, "ERROR: out of memory\n"); - return 1; - } - if(fm->type == FOREIGN_BLOCK_TYPE__AIFF) { - if(!flac__foreign_metadata_read_from_aiff(fm, fn, &error)) { - flac_fprintf(stderr, "ERROR reading chunks from %s: %s\n", fn, error); - return 1; - } - } - else { - if(!flac__foreign_metadata_read_from_wave(fm, fn, &error)) { - flac_fprintf(stderr, "ERROR reading chunks from %s: %s\n", fn, error); - return 1; - } - } - if(0 == (f = flac_fopen(fn, "rb"))) { - flac_fprintf(stderr, "ERROR opening %s for reading\n", fn); - return 1; - } - for(i = 0; i < fm->num_blocks; i++) { - if(fseeko(f, fm->blocks[i].offset, SEEK_SET) < 0) { - flac_fprintf(stderr, "ERROR seeking in %s\n", fn); - return 1; - } - if(fread(buf, 1, i==0?12:8, f) != (i==0?12:8)) { - flac_fprintf(stderr, "ERROR reading %s\n", fn); - return 1; - } - size = unpack32_((FLAC__byte*)buf+4, fm->type); - printf("block:[%c%c%c%c] size=%08x=(%10u)", buf[0], buf[1], buf[2], buf[3], size, size); - if(i == 0) - printf(" type:[%c%c%c%c]", buf[8], buf[9], buf[10], buf[11]); - else if(fm->type == FOREIGN_BLOCK_TYPE__AIFF && i == fm->audio_block) - printf(" offset size=%08x=(%10u)", fm->ssnd_offset_size, fm->ssnd_offset_size); - else if(fm->type == FOREIGN_BLOCK_TYPE__RIFF && i == 1 && !memcmp(buf, "ds64", 4)) { - if(fread(buf+8, 1, 36-8, f) != 36-8) { - flac_fprintf(stderr, "ERROR reading %s\n", fn); - return 1; - } - printf("\n RIFF size=%016" PRIx64 "=(%20" PRIu64 ")", unpack64le_((FLAC__byte*)buf+8), unpack64le_((FLAC__byte*)buf+8)); - printf("\n data size=%016" PRIx64 "=(%20" PRIu64 ")", unpack64le_((FLAC__byte*)buf+16), unpack64le_((FLAC__byte*)buf+16)); - printf("\n sample count=%016" PRIx64 "=(%20" PRIu64 ")", unpack64le_((FLAC__byte*)buf+24), unpack64le_((FLAC__byte*)buf+24)); - printf("\n table size=%08x=(%10u)", unpack32le_((FLAC__byte*)buf+32), unpack32le_((FLAC__byte*)buf+32)); - } - printf("\n"); - } - fclose(f); - flac__foreign_metadata_delete(fm); - return 0; -} diff --git a/Engine/lib/flac/src/flac/local_string_utils.c b/Engine/lib/flac/src/flac/local_string_utils.c deleted file mode 100644 index 7e252334a..000000000 --- a/Engine/lib/flac/src/flac/local_string_utils.c +++ /dev/null @@ -1,109 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "utils.h" -#include "local_string_utils.h" - -/* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ - * - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -size_t -flac__strlcpy(char *dst, const char *src, size_t siz) -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -} - -/* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ - * - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * - * Appends src to string dst of size siz (unlike strncat, siz is the - * full size of dst, not space left). At most siz-1 characters - * will be copied. Always NUL terminates (unless siz <= strlen(dst)). - * Returns strlen(src) + MIN(siz, strlen(initial dst)). - * If retval >= siz, truncation occurred. - */ -size_t -flac__strlcat(char *dst, const char *src, size_t siz) -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = siz - dlen; - - if (n == 0) - return(dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return(dlen + (s - src)); /* count does not include NUL */ -} diff --git a/Engine/lib/flac/src/flac/local_string_utils.h b/Engine/lib/flac/src/flac/local_string_utils.h deleted file mode 100644 index 01f891f79..000000000 --- a/Engine/lib/flac/src/flac/local_string_utils.h +++ /dev/null @@ -1,28 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef flac__local_string_utils_h -#define flac__local_string_utils_h - -#include /* for size_t */ - -size_t flac__strlcpy(char *dst, const char *src, size_t siz); -size_t flac__strlcat(char *dst, const char *src, size_t siz); - -#endif diff --git a/Engine/lib/flac/src/flac/main.c b/Engine/lib/flac/src/flac/main.c deleted file mode 100644 index c22e602c1..000000000 --- a/Engine/lib/flac/src/flac/main.c +++ /dev/null @@ -1,2442 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#if !defined _MSC_VER && !defined __MINGW32__ -/* unlink is in stdio.h in VC++ */ -#include /* for unlink() */ -#endif -#include "FLAC/all.h" -#include "share/alloc.h" -#include "share/grabbag.h" -#include "share/compat.h" -#include "share/endswap.h" -#include "share/safe_str.h" -#include "analyze.h" -#include "decode.h" -#include "encode.h" -#include "local_string_utils.h" /* for flac__strlcat() and flac__strlcpy() */ -#include "utils.h" -#include "vorbiscomment.h" - -#if 0 -/*[JEC] was:#if HAVE_GETOPT_LONG*/ -/*[JEC] see flac/include/share/getopt.h as to why the change */ -# include -#else -# include "share/getopt.h" -#endif - -static int do_it(void); - -static FLAC__bool init_options(void); -static int parse_options(int argc, char *argv[]); -static int parse_option(int short_option, const char *long_option, const char *option_argument); -static void free_options(void); -static void add_compression_setting_bool(compression_setting_type_t type, FLAC__bool value); -static void add_compression_setting_string(compression_setting_type_t type, const char *value); -static void add_compression_setting_uint32_t(compression_setting_type_t type, uint32_t value); - -static int usage_error(const char *message, ...); -static void short_usage(void); -static void show_version(void); -static void show_help(void); -static void show_explain(void); -static void format_mistake(const char *infilename, FileFormat wrong, FileFormat right); - -static int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_last_file); -static int decode_file(const char *infilename); - -static const char *get_encoded_outfilename(const char *infilename); -static const char *get_decoded_outfilename(const char *infilename, const FileFormat format); -static const char *get_outfilename(const char *infilename, const char *suffix); - -static void die(const char *message); -static int conditional_fclose(FILE *f); -static char *local_strdup(const char *source); - -/* - * share__getopt format struct; note that for long options with no - * short option equivalent we just set the 'val' field to 0. - */ -static struct share__option long_options_[] = { - /* - * general options - */ - { "help" , share__no_argument, 0, 'h' }, - { "explain" , share__no_argument, 0, 'H' }, - { "version" , share__no_argument, 0, 'v' }, - { "decode" , share__no_argument, 0, 'd' }, - { "analyze" , share__no_argument, 0, 'a' }, - { "test" , share__no_argument, 0, 't' }, - { "stdout" , share__no_argument, 0, 'c' }, - { "silent" , share__no_argument, 0, 's' }, - { "totally-silent" , share__no_argument, 0, 0 }, - { "warnings-as-errors" , share__no_argument, 0, 'w' }, - { "force" , share__no_argument, 0, 'f' }, - { "delete-input-file" , share__no_argument, 0, 0 }, - { "preserve-modtime" , share__no_argument, 0, 0 }, - { "keep-foreign-metadata" , share__no_argument, 0, 0 }, - { "keep-foreign-metadata-if-present" , share__no_argument, 0, 0 }, - { "output-prefix" , share__required_argument, 0, 0 }, - { "output-name" , share__required_argument, 0, 'o' }, - { "skip" , share__required_argument, 0, 0 }, - { "until" , share__required_argument, 0, 0 }, - { "channel-map" , share__required_argument, 0, 0 }, /* undocumented */ - - /* - * decoding options - */ - { "decode-through-errors", share__no_argument, 0, 'F' }, - { "cue" , share__required_argument, 0, 0 }, - { "apply-replaygain-which-is-not-lossless", share__optional_argument, 0, 0 }, /* undocumented */ - - /* - * encoding options - */ - { "cuesheet" , share__required_argument, 0, 0 }, - { "no-cued-seekpoints" , share__no_argument, 0, 0 }, - { "picture" , share__required_argument, 0, 0 }, - { "tag" , share__required_argument, 0, 'T' }, - { "tag-from-file" , share__required_argument, 0, 0 }, - { "compression-level-0" , share__no_argument, 0, '0' }, - { "compression-level-1" , share__no_argument, 0, '1' }, - { "compression-level-2" , share__no_argument, 0, '2' }, - { "compression-level-3" , share__no_argument, 0, '3' }, - { "compression-level-4" , share__no_argument, 0, '4' }, - { "compression-level-5" , share__no_argument, 0, '5' }, - { "compression-level-6" , share__no_argument, 0, '6' }, - { "compression-level-7" , share__no_argument, 0, '7' }, - { "compression-level-8" , share__no_argument, 0, '8' }, - { "compression-level-9" , share__no_argument, 0, '9' }, - { "best" , share__no_argument, 0, '8' }, - { "fast" , share__no_argument, 0, '0' }, - { "verify" , share__no_argument, 0, 'V' }, - { "force-raw-format" , share__no_argument, 0, 0 }, - { "force-aiff-format" , share__no_argument, 0, 0 }, - { "force-rf64-format" , share__no_argument, 0, 0 }, - { "force-wave64-format" , share__no_argument, 0, 0 }, - { "force-legacy-wave-format" , share__no_argument, 0, 0 }, - { "force-extensible-wave-format",share__no_argument,0, 0 }, - { "force-aiff-c-none-format" , share__no_argument, 0, 0 }, - { "force-aiff-c-sowt-format" , share__no_argument, 0, 0 }, - { "lax" , share__no_argument, 0, 0 }, - { "replay-gain" , share__no_argument, 0, 0 }, - { "ignore-chunk-sizes" , share__no_argument, 0, 0 }, - { "seekpoint" , share__required_argument, 0, 'S' }, - { "padding" , share__required_argument, 0, 'P' }, -#if FLAC__HAS_OGG - { "ogg" , share__no_argument, 0, 0 }, - { "serial-number" , share__required_argument, 0, 0 }, -#endif - { "blocksize" , share__required_argument, 0, 'b' }, - { "exhaustive-model-search" , share__no_argument, 0, 'e' }, - { "max-lpc-order" , share__required_argument, 0, 'l' }, - { "apodization" , share__required_argument, 0, 'A' }, - { "mid-side" , share__no_argument, 0, 'm' }, - { "adaptive-mid-side" , share__no_argument, 0, 'M' }, - { "qlp-coeff-precision-search", share__no_argument, 0, 'p' }, - { "qlp-coeff-precision" , share__required_argument, 0, 'q' }, - { "rice-partition-order" , share__required_argument, 0, 'r' }, - { "endian" , share__required_argument, 0, 0 }, - { "channels" , share__required_argument, 0, 0 }, - { "bps" , share__required_argument, 0, 0 }, - { "sample-rate" , share__required_argument, 0, 0 }, - { "sign" , share__required_argument, 0, 0 }, - { "input-size" , share__required_argument, 0, 0 }, - { "error-on-compression-fail" , share__no_argument, 0, 0 }, - { "limit-min-bitrate" , share__no_argument, 0, 0 }, - - /* - * analysis options - */ - { "residual-gnuplot", share__no_argument, 0, 0 }, - { "residual-text", share__no_argument, 0, 0 }, - - /* - * negatives - */ - { "no-preserve-modtime" , share__no_argument, 0, 0 }, - { "no-decode-through-errors" , share__no_argument, 0, 0 }, - { "no-silent" , share__no_argument, 0, 0 }, - { "no-force" , share__no_argument, 0, 0 }, - { "no-seektable" , share__no_argument, 0, 0 }, - { "no-delete-input-file" , share__no_argument, 0, 0 }, - { "no-keep-foreign-metadata" , share__no_argument, 0, 0 }, - { "no-replay-gain" , share__no_argument, 0, 0 }, - { "no-ignore-chunk-sizes" , share__no_argument, 0, 0 }, - { "no-utf8-convert" , share__no_argument, 0, 0 }, - { "no-lax" , share__no_argument, 0, 0 }, -#if FLAC__HAS_OGG - { "no-ogg" , share__no_argument, 0, 0 }, -#endif - { "no-exhaustive-model-search", share__no_argument, 0, 0 }, - { "no-mid-side" , share__no_argument, 0, 0 }, - { "no-adaptive-mid-side" , share__no_argument, 0, 0 }, - { "no-qlp-coeff-prec-search" , share__no_argument, 0, 0 }, - { "no-padding" , share__no_argument, 0, 0 }, - { "no-verify" , share__no_argument, 0, 0 }, - { "no-warnings-as-errors" , share__no_argument, 0, 0 }, - { "no-residual-gnuplot" , share__no_argument, 0, 0 }, - { "no-residual-text" , share__no_argument, 0, 0 }, - { "no-error-on-compression-fail", share__no_argument, 0, 0 }, - /* - * undocumented debugging options for the test suite - */ - { "disable-constant-subframes", share__no_argument, 0, 0 }, - { "disable-fixed-subframes" , share__no_argument, 0, 0 }, - { "disable-verbatim-subframes", share__no_argument, 0, 0 }, - { "no-md5-sum" , share__no_argument, 0, 0 }, - - {0, 0, 0, 0} -}; - - -/* - * global to hold command-line option values - */ - -static struct { - FLAC__bool show_help; - FLAC__bool show_explain; - FLAC__bool show_version; - FLAC__bool mode_decode; - FLAC__bool verify; - FLAC__bool treat_warnings_as_errors; - FLAC__bool force_file_overwrite; - FLAC__bool continue_through_decode_errors; - replaygain_synthesis_spec_t replaygain_synthesis_spec; - FLAC__bool lax; - FLAC__bool test_only; - FLAC__bool analyze; - FLAC__bool use_ogg; - FLAC__bool has_serial_number; /* true iff --serial-number was used */ - long serial_number; /* this is the Ogg serial number and is unused for native FLAC */ - FLAC__bool force_to_stdout; - FLAC__bool force_raw_format; - FLAC__bool force_aiff_format; - FLAC__bool force_rf64_format; - FLAC__bool force_wave64_format; - FLAC__bool force_legacy_wave_format; - FLAC__bool force_extensible_wave_format; - FLAC__bool force_aiff_c_none_format; - FLAC__bool force_aiff_c_sowt_format; - FLAC__bool delete_input; - FLAC__bool preserve_modtime; - FLAC__bool keep_foreign_metadata; - FLAC__bool keep_foreign_metadata_if_present; - FLAC__bool replay_gain; - FLAC__bool ignore_chunk_sizes; - FLAC__bool utf8_convert; /* true by default, to convert tag strings from locale to utf-8, false if --no-utf8-convert used */ - const char *cmdline_forced_outfilename; - const char *output_prefix; - analysis_options aopts; - int padding; /* -1 => no -P options were given, 0 => -P- was given, else -P value */ - size_t num_compression_settings; - compression_setting_t compression_settings[64]; /* bad MAGIC NUMBER but buffer overflow is checked */ - const char *skip_specification; - const char *until_specification; - const char *cue_specification; - int format_is_big_endian; - int format_is_unsigned_samples; - int format_channels; - int format_bps; - int format_sample_rate; - FLAC__off_t format_input_size; - char requested_seek_points[5000]; /* bad MAGIC NUMBER but buffer overflow is checked */ - int num_requested_seek_points; /* -1 => no -S options were given, 0 => -S- was given */ - const char *cuesheet_filename; - FLAC__bool cued_seekpoints; - FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */ - FLAC__bool error_on_compression_fail; - FLAC__bool limit_min_bitrate; - - uint32_t num_files; - char **filenames; - - FLAC__StreamMetadata *vorbis_comment; - FLAC__StreamMetadata *pictures[64]; - uint32_t num_pictures; - - struct { - FLAC__bool disable_constant_subframes; - FLAC__bool disable_fixed_subframes; - FLAC__bool disable_verbatim_subframes; - FLAC__bool do_md5; - } debug; -} option_values; - - -/* - * miscellaneous globals - */ - - -#ifndef FUZZ_TOOL_FLAC -int main(int argc, char *argv[]) -#else -static int main_to_fuzz(int argc, char *argv[]) -#endif -{ - int retval = 0; - -#ifdef __EMX__ - _response(&argc, &argv); - _wildcard(&argc, &argv); -#endif -#ifdef _WIN32 - if (get_utf8_argv(&argc, &argv) != 0) { - fprintf(stderr, "ERROR: failed to convert command line parameters to UTF-8\n"); - return 1; - } -#endif - - srand((uint32_t)time(0)); -#ifdef _WIN32 - { - const char *var; - var = getenv("LC_ALL"); - if (!var) - var = getenv("LC_NUMERIC"); - if (!var) - var = getenv("LANG"); - if (!var || strcmp(var, "C") != 0) - setlocale(LC_ALL, ""); - } -#else - setlocale(LC_ALL, ""); -#endif - if(!init_options()) { - flac__utils_printf(stderr, 1, "ERROR: allocating memory\n"); - retval = 1; - } - else { - if((retval = parse_options(argc, argv)) == 0) - retval = do_it(); - } - - free_options(); - - return retval; -} - -int do_it(void) -{ - int retval = 0; - - if(option_values.show_version) { - show_version(); - return 0; - } - else if(option_values.show_explain) { - show_explain(); - return 0; - } - else if(option_values.show_help) { - show_help(); - return 0; - } - else { - if(option_values.num_files == 0) { - if(flac__utils_verbosity_ >= 1) - short_usage(); - return 0; - } - - /* - * tweak options; validate the values - */ - if(!option_values.mode_decode) { - if(0 != option_values.cue_specification) - return usage_error("ERROR: --cue is not allowed in test mode\n"); - } - else { - if(option_values.test_only) { - if(0 != option_values.skip_specification) - return usage_error("ERROR: --skip is not allowed in test mode\n"); - if(0 != option_values.until_specification) - return usage_error("ERROR: --until is not allowed in test mode\n"); - if(0 != option_values.cue_specification) - return usage_error("ERROR: --cue is not allowed in test mode\n"); - if(0 != option_values.analyze) - return usage_error("ERROR: analysis mode (-a/--analyze) and test mode (-t/--test) cannot be used together\n"); - } - } - - if(0 != option_values.cue_specification && (0 != option_values.skip_specification || 0 != option_values.until_specification)) - return usage_error("ERROR: --cue may not be combined with --skip or --until\n"); - - if(option_values.format_channels >= 0) { - if(option_values.format_channels == 0 || (uint32_t)option_values.format_channels > FLAC__MAX_CHANNELS) - return usage_error("ERROR: invalid number of channels '%u', must be > 0 and <= %u\n", option_values.format_channels, FLAC__MAX_CHANNELS); - } - if(option_values.format_bps >= 0) { - if(option_values.format_bps != 8 && option_values.format_bps != 16 && option_values.format_bps != 24 && option_values.format_bps != 32) - return usage_error("ERROR: invalid bits per sample '%u' (must be 8/16/24/32)\n", option_values.format_bps); - } - if(option_values.format_sample_rate >= 0) { - if(!FLAC__format_sample_rate_is_valid(option_values.format_sample_rate)) - return usage_error("ERROR: invalid sample rate '%u', must be > 0 and <= %u\n", option_values.format_sample_rate, FLAC__MAX_SAMPLE_RATE); - } - if((option_values.force_raw_format?1:0) + - (option_values.force_aiff_format?1:0) + - (option_values.force_rf64_format?1:0) + - (option_values.force_wave64_format?1:0) + - (option_values.force_legacy_wave_format?1:0) + - (option_values.force_extensible_wave_format?1:0) + - (option_values.force_aiff_c_none_format?1:0) + - (option_values.force_aiff_c_sowt_format?1:0) - > 1) - return usage_error("ERROR: only one of force format options allowed\n"); - if(option_values.mode_decode) { - if(!option_values.force_raw_format) { - if(option_values.format_is_big_endian >= 0) - return usage_error("ERROR: --endian only allowed with --force-raw-format\n"); - if(option_values.format_is_unsigned_samples >= 0) - return usage_error("ERROR: --sign only allowed with --force-raw-format\n"); - } - if(option_values.format_channels >= 0) - return usage_error("ERROR: --channels not allowed with --decode\n"); - if(option_values.format_bps >= 0) - return usage_error("ERROR: --bps not allowed with --decode\n"); - if(option_values.format_sample_rate >= 0) - return usage_error("ERROR: --sample-rate not allowed with --decode\n"); - } - - if(option_values.ignore_chunk_sizes) { - if(option_values.mode_decode) - return usage_error("ERROR: --ignore-chunk-sizes only allowed for encoding\n"); - if(0 != option_values.until_specification) - return usage_error("ERROR: --ignore-chunk-sizes not allowed with --until\n"); - if(0 != option_values.cue_specification) - return usage_error("ERROR: --ignore-chunk-sizes not allowed with --cue\n"); - if(0 != option_values.cuesheet_filename) - return usage_error("ERROR: --ignore-chunk-sizes not allowed with --cuesheet\n"); - } - if(option_values.replay_gain) { - if(option_values.force_to_stdout) - return usage_error("ERROR: --replay-gain not allowed with -c/--stdout\n"); - if(option_values.mode_decode) - return usage_error("ERROR: --replay-gain only allowed for encoding\n"); - if(option_values.format_channels > 2) - return usage_error("ERROR: --replay-gain can only be done with mono/stereo input\n"); - if(option_values.format_sample_rate >= 0 && !grabbag__replaygain_is_valid_sample_frequency(option_values.format_sample_rate)) - return usage_error("ERROR: invalid sample rate used with --replay-gain\n"); - if( - (option_values.padding >= 0 && option_values.padding < (int)GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED) || - (option_values.padding < 0 && FLAC_ENCODE__DEFAULT_PADDING < (int)GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED) - ) { - flac__utils_printf(stderr, 1, "NOTE: --replay-gain may leave a small PADDING block even with --no-padding\n"); - } - } - if(option_values.num_files > 1 && option_values.cmdline_forced_outfilename) { - return usage_error("ERROR: -o/--output-name cannot be used with multiple files\n"); - } - if(option_values.cmdline_forced_outfilename && option_values.output_prefix) { - return usage_error("ERROR: --output-prefix conflicts with -o/--output-name\n"); - } - if(!option_values.mode_decode && 0 != option_values.cuesheet_filename && option_values.num_files > 1) { - return usage_error("ERROR: --cuesheet cannot be used when encoding multiple files\n"); - } - if(option_values.keep_foreign_metadata || option_values.keep_foreign_metadata_if_present) { - /* we're not going to try and support the re-creation of broken WAVE files */ - if(option_values.ignore_chunk_sizes) - return usage_error("ERROR: using --keep-foreign-metadata cannot be used with --ignore-chunk-sizes\n"); - if(option_values.test_only) - return usage_error("ERROR: --keep-foreign-metadata is not allowed in test mode\n"); - if(option_values.analyze) - return usage_error("ERROR: --keep-foreign-metadata is not allowed in analyis mode\n"); - flac__utils_printf(stderr, 1, "NOTE: --keep-foreign-metadata is a new feature; make sure to test the output file before deleting the original.\n"); - } - } - - flac__utils_printf(stderr, 2, "\n"); - flac__utils_printf(stderr, 2, "flac %s\n", FLAC__VERSION_STRING); - flac__utils_printf(stderr, 2, "Copyright (C) 2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation\n"); - flac__utils_printf(stderr, 2, "flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are\n"); - flac__utils_printf(stderr, 2, "welcome to redistribute it under certain conditions. Type `flac' for details.\n\n"); - - if(option_values.mode_decode) { - FLAC__bool first = true; - - if(option_values.num_files == 0) { - retval = decode_file("-"); - } - else { - uint32_t i; - if(option_values.num_files > 1) - option_values.cmdline_forced_outfilename = 0; - for(i = 0, retval = 0; i < option_values.num_files; i++) { - if(0 == strcmp(option_values.filenames[i], "-") && !first) - continue; - retval |= decode_file(option_values.filenames[i]); - first = false; - } - } - } - else { /* encode */ - FLAC__bool first = true; - - if(option_values.ignore_chunk_sizes) - flac__utils_printf(stderr, 1, "INFO: Make sure you know what you're doing when using --ignore-chunk-sizes.\n Improper use can cause flac to encode non-audio data as audio.\n"); - - if(option_values.num_files == 0) { - retval = encode_file("-", first, true); - } - else { - uint32_t i; - if(option_values.num_files > 1) - option_values.cmdline_forced_outfilename = 0; - for(i = 0, retval = 0; i < option_values.num_files; i++) { - if(0 == strcmp(option_values.filenames[i], "-") && !first) - continue; - if(encode_file(option_values.filenames[i], first, i == (option_values.num_files-1))) - retval = 1; - else - first = false; - } - if(option_values.replay_gain && retval == 0) { - float album_gain, album_peak; - grabbag__replaygain_get_album(&album_gain, &album_peak); - for(i = 0; i < option_values.num_files; i++) { - const char *error, *outfilename = get_encoded_outfilename(option_values.filenames[i]); - if(0 == outfilename) { - flac__utils_printf(stderr, 1, "ERROR: filename too long: %s", option_values.filenames[i]); - return 1; - } - if(0 != (error = grabbag__replaygain_store_to_file_album(outfilename, album_gain, album_peak, option_values.preserve_modtime))) { - flac__utils_printf(stderr, 1, "%s: ERROR writing ReplayGain album tags (%s)\n", outfilename, error); - retval = 1; - } - } - } - } - } - - return retval; -} - -FLAC__bool init_options(void) -{ - option_values.show_help = false; - option_values.show_explain = false; - option_values.show_version = false; - option_values.mode_decode = false; - option_values.verify = false; - option_values.treat_warnings_as_errors = false; - option_values.force_file_overwrite = false; - option_values.continue_through_decode_errors = false; - option_values.replaygain_synthesis_spec.apply = false; - option_values.replaygain_synthesis_spec.use_album_gain = true; - option_values.replaygain_synthesis_spec.limiter = RGSS_LIMIT__HARD; - option_values.replaygain_synthesis_spec.noise_shaping = NOISE_SHAPING_LOW; - option_values.replaygain_synthesis_spec.preamp = 0.0; - option_values.lax = false; - option_values.test_only = false; - option_values.analyze = false; - option_values.use_ogg = false; - option_values.has_serial_number = false; - option_values.serial_number = 0; - option_values.force_to_stdout = false; - option_values.force_raw_format = false; - option_values.force_aiff_format = false; - option_values.force_rf64_format = false; - option_values.force_wave64_format = false; - option_values.force_legacy_wave_format = false; - option_values.force_extensible_wave_format = false; - option_values.force_aiff_c_none_format = false; - option_values.force_aiff_c_sowt_format = false; - option_values.delete_input = false; - option_values.preserve_modtime = true; - option_values.keep_foreign_metadata = false; - option_values.keep_foreign_metadata_if_present = false; - option_values.replay_gain = false; - option_values.ignore_chunk_sizes = false; - option_values.utf8_convert = true; - option_values.cmdline_forced_outfilename = 0; - option_values.output_prefix = 0; - option_values.aopts.do_residual_text = false; - option_values.aopts.do_residual_gnuplot = false; - option_values.padding = -1; - option_values.num_compression_settings = 1; - option_values.compression_settings[0].type = CST_COMPRESSION_LEVEL; - option_values.compression_settings[0].value.t_unsigned = 5; - option_values.skip_specification = 0; - option_values.until_specification = 0; - option_values.cue_specification = 0; - option_values.format_is_big_endian = -1; - option_values.format_is_unsigned_samples = -1; - option_values.format_channels = -1; - option_values.format_bps = -1; - option_values.format_sample_rate = -1; - option_values.format_input_size = (FLAC__off_t)(-1); - option_values.requested_seek_points[0] = '\0'; - option_values.num_requested_seek_points = -1; - option_values.cuesheet_filename = 0; - option_values.cued_seekpoints = true; - option_values.channel_map_none = false; - option_values.error_on_compression_fail = false; - option_values.limit_min_bitrate = false; - - option_values.num_files = 0; - option_values.filenames = 0; - - if(0 == (option_values.vorbis_comment = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT))) - return false; - option_values.num_pictures = 0; - - option_values.debug.disable_constant_subframes = false; - option_values.debug.disable_fixed_subframes = false; - option_values.debug.disable_verbatim_subframes = false; - option_values.debug.do_md5 = true; - - return true; -} - -int parse_options(int argc, char *argv[]) -{ - int short_option; - int option_index = 1; - FLAC__bool had_error = false; - const char *short_opts = "0123456789aA:b:cdefFhHl:mMo:pP:q:r:sS:tT:vVw"; - - while ((short_option = share__getopt_long(argc, argv, short_opts, long_options_, &option_index)) != -1) { - switch (short_option) { - case 0: /* long option with no equivalent short option */ - had_error |= (parse_option(short_option, long_options_[option_index].name, share__optarg) != 0); - break; - case '?': - case ':': - had_error = true; - break; - default: /* short option */ - had_error |= (parse_option(short_option, 0, share__optarg) != 0); - break; - } - } - - if(had_error) { - return 1; - } - - FLAC__ASSERT(share__optind <= argc); - - option_values.num_files = argc - share__optind; - - if(option_values.num_files > 0) { - uint32_t i = 0; - if(0 == (option_values.filenames = malloc(sizeof(char*) * option_values.num_files))) - die("out of memory allocating space for file names list"); - while(share__optind < argc) - option_values.filenames[i++] = local_strdup(argv[share__optind++]); - } - - return 0; -} - -int parse_option(int short_option, const char *long_option, const char *option_argument) -{ - const char *violation; - - if(short_option == 0) { - FLAC__ASSERT(0 != long_option); - if(0 == strcmp(long_option, "totally-silent")) { - flac__utils_verbosity_ = 0; - } - else if(0 == strcmp(long_option, "delete-input-file")) { - option_values.delete_input = true; - } - else if(0 == strcmp(long_option, "preserve-modtime")) { - option_values.preserve_modtime = true; - } - else if(0 == strcmp(long_option, "keep-foreign-metadata")) { - option_values.keep_foreign_metadata = true; - } - else if(0 == strcmp(long_option, "keep-foreign-metadata-if-present")) { - option_values.keep_foreign_metadata_if_present = true; - } - else if(0 == strcmp(long_option, "output-prefix")) { - FLAC__ASSERT(0 != option_argument); - option_values.output_prefix = option_argument; - } - else if(0 == strcmp(long_option, "skip")) { - FLAC__ASSERT(0 != option_argument); - option_values.skip_specification = option_argument; - } - else if(0 == strcmp(long_option, "until")) { - FLAC__ASSERT(0 != option_argument); - option_values.until_specification = option_argument; - } - else if(0 == strcmp(long_option, "input-size")) { - FLAC__ASSERT(0 != option_argument); - { - char *end; - FLAC__int64 ix; - ix = strtoll(option_argument, &end, 10); - if(0 == strlen(option_argument) || *end) - return usage_error("ERROR: --%s must be a number\n", long_option); - option_values.format_input_size = (FLAC__off_t)ix; - if(option_values.format_input_size != ix) /* check if FLAC__off_t is smaller than long long */ - return usage_error("ERROR: --%s too large; this build of flac does not support filesizes over 2GB\n", long_option); - if(option_values.format_input_size <= 0) - return usage_error("ERROR: --%s must be > 0\n", long_option); - } - } - else if(0 == strcmp(long_option, "cue")) { - FLAC__ASSERT(0 != option_argument); - option_values.cue_specification = option_argument; - } - else if(0 == strcmp(long_option, "apply-replaygain-which-is-not-lossless")) { - option_values.replaygain_synthesis_spec.apply = true; - if (0 != option_argument) { - char *p; - option_values.replaygain_synthesis_spec.limiter = RGSS_LIMIT__NONE; - option_values.replaygain_synthesis_spec.noise_shaping = NOISE_SHAPING_NONE; - option_values.replaygain_synthesis_spec.preamp = strtod(option_argument, &p); - for ( ; *p; p++) { - if (*p == 'a') - option_values.replaygain_synthesis_spec.use_album_gain = true; - else if (*p == 't') - option_values.replaygain_synthesis_spec.use_album_gain = false; - else if (*p == 'l') - option_values.replaygain_synthesis_spec.limiter = RGSS_LIMIT__PEAK; - else if (*p == 'L') - option_values.replaygain_synthesis_spec.limiter = RGSS_LIMIT__HARD; - else if (*p == 'n' && p[1] >= '0' && p[1] <= '3') { - option_values.replaygain_synthesis_spec.noise_shaping = p[1] - '0'; - p++; - } - else - return usage_error("ERROR: bad specification string \"%s\" for --%s\n", option_argument, long_option); - } - } - } - else if(0 == strcmp(long_option, "channel-map")) { - if (0 == option_argument || strcmp(option_argument, "none")) - return usage_error("ERROR: only --channel-map=none currently supported\n"); - option_values.channel_map_none = true; - } - else if(0 == strcmp(long_option, "cuesheet")) { - FLAC__ASSERT(0 != option_argument); - option_values.cuesheet_filename = option_argument; - } - else if(0 == strcmp(long_option, "picture")) { - const uint32_t max_pictures = sizeof(option_values.pictures)/sizeof(option_values.pictures[0]); - FLAC__ASSERT(0 != option_argument); - if(option_values.num_pictures >= max_pictures) - return usage_error("ERROR: too many --picture arguments, only %u allowed\n", max_pictures); - if(0 == (option_values.pictures[option_values.num_pictures] = grabbag__picture_parse_specification(option_argument, &violation))) - return usage_error("ERROR: (--picture) %s\n", violation); - option_values.num_pictures++; - } - else if(0 == strcmp(long_option, "tag-from-file")) { - FLAC__ASSERT(0 != option_argument); - if(!flac__vorbiscomment_add(option_values.vorbis_comment, option_argument, /*value_from_file=*/true, /*raw=*/!option_values.utf8_convert, &violation)) - return usage_error("ERROR: (--tag-from-file) %s\n", violation); - } - else if(0 == strcmp(long_option, "no-cued-seekpoints")) { - option_values.cued_seekpoints = false; - } - else if(0 == strcmp(long_option, "force-raw-format")) { - option_values.force_raw_format = true; - } - else if(0 == strcmp(long_option, "force-aiff-format")) { - option_values.force_aiff_format = true; - } - else if(0 == strcmp(long_option, "force-rf64-format")) { - option_values.force_rf64_format = true; - } - else if(0 == strcmp(long_option, "force-wave64-format")) { - option_values.force_wave64_format = true; - } - else if(0 == strcmp(long_option, "force-legacy-wave-format")) { - option_values.force_legacy_wave_format = true; - } - else if(0 == strcmp(long_option, "force-extensible-wave-format")) { - option_values.force_extensible_wave_format = true; - } - else if(0 == strcmp(long_option, "force-aiff-c-none-format")) { - option_values.force_aiff_c_none_format = true; - } - else if(0 == strcmp(long_option, "force-aiff-c-sowt-format")) { - option_values.force_aiff_c_sowt_format = true; - } - else if(0 == strcmp(long_option, "lax")) { - option_values.lax = true; - } - else if(0 == strcmp(long_option, "replay-gain")) { - option_values.replay_gain = true; - } - else if(0 == strcmp(long_option, "ignore-chunk-sizes")) { - option_values.ignore_chunk_sizes = true; - } -#if FLAC__HAS_OGG - else if(0 == strcmp(long_option, "ogg")) { - option_values.use_ogg = true; - } - else if(0 == strcmp(long_option, "serial-number")) { - option_values.has_serial_number = true; - option_values.serial_number = atol(option_argument); - } -#endif - else if(0 == strcmp(long_option, "endian")) { - FLAC__ASSERT(0 != option_argument); - if(0 == strncmp(option_argument, "big", strlen(option_argument))) - option_values.format_is_big_endian = true; - else if(0 == strncmp(option_argument, "little", strlen(option_argument))) - option_values.format_is_big_endian = false; - else - return usage_error("ERROR: argument to --endian must be \"big\" or \"little\"\n"); - } - else if(0 == strcmp(long_option, "channels")) { - FLAC__ASSERT(0 != option_argument); - option_values.format_channels = atoi(option_argument); - } - else if(0 == strcmp(long_option, "bps")) { - FLAC__ASSERT(0 != option_argument); - option_values.format_bps = atoi(option_argument); - } - else if(0 == strcmp(long_option, "sample-rate")) { - FLAC__ASSERT(0 != option_argument); - option_values.format_sample_rate = atoi(option_argument); - } - else if(0 == strcmp(long_option, "sign")) { - FLAC__ASSERT(0 != option_argument); - if(0 == strncmp(option_argument, "signed", strlen(option_argument))) - option_values.format_is_unsigned_samples = false; - else if(0 == strncmp(option_argument, "unsigned", strlen(option_argument))) - option_values.format_is_unsigned_samples = true; - else - return usage_error("ERROR: argument to --sign must be \"signed\" or \"unsigned\"\n"); - } - else if(0 == strcmp(long_option, "residual-gnuplot")) { - option_values.aopts.do_residual_gnuplot = true; - } - else if(0 == strcmp(long_option, "residual-text")) { - option_values.aopts.do_residual_text = true; - } - else if(0 == strcmp(long_option, "limit-min-bitrate")) { - option_values.limit_min_bitrate = true; - } - /* - * negatives - */ - else if(0 == strcmp(long_option, "no-preserve-modtime")) { - option_values.preserve_modtime = false; - } - else if(0 == strcmp(long_option, "no-decode-through-errors")) { - option_values.continue_through_decode_errors = false; - } - else if(0 == strcmp(long_option, "no-silent")) { -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - flac__utils_verbosity_ = 2; -#endif - } - else if(0 == strcmp(long_option, "no-force")) { - option_values.force_file_overwrite = false; - } - else if(0 == strcmp(long_option, "no-seektable")) { - option_values.num_requested_seek_points = 0; - option_values.requested_seek_points[0] = '\0'; - } - else if(0 == strcmp(long_option, "no-delete-input-file")) { - option_values.delete_input = false; - } - else if(0 == strcmp(long_option, "no-keep-foreign-metadata")) { - option_values.keep_foreign_metadata = false; - option_values.keep_foreign_metadata_if_present = false; - } - else if(0 == strcmp(long_option, "no-replay-gain")) { - option_values.replay_gain = false; - } - else if(0 == strcmp(long_option, "no-ignore-chunk-sizes")) { - option_values.ignore_chunk_sizes = false; - } - else if(0 == strcmp(long_option, "no-utf8-convert")) { - option_values.utf8_convert = false; - } - else if(0 == strcmp(long_option, "no-lax")) { - option_values.lax = false; - } -#if FLAC__HAS_OGG - else if(0 == strcmp(long_option, "no-ogg")) { - option_values.use_ogg = false; - } -#endif - else if(0 == strcmp(long_option, "no-exhaustive-model-search")) { - add_compression_setting_bool(CST_DO_EXHAUSTIVE_MODEL_SEARCH, false); - } - else if(0 == strcmp(long_option, "no-mid-side")) { - add_compression_setting_bool(CST_DO_MID_SIDE, false); - add_compression_setting_bool(CST_LOOSE_MID_SIDE, false); - } - else if(0 == strcmp(long_option, "no-adaptive-mid-side")) { - add_compression_setting_bool(CST_DO_MID_SIDE, false); - add_compression_setting_bool(CST_LOOSE_MID_SIDE, false); - } - else if(0 == strcmp(long_option, "no-qlp-coeff-prec-search")) { - add_compression_setting_bool(CST_DO_QLP_COEFF_PREC_SEARCH, false); - } - else if(0 == strcmp(long_option, "no-padding")) { - option_values.padding = 0; - } - else if(0 == strcmp(long_option, "no-verify")) { - option_values.verify = false; - } - else if(0 == strcmp(long_option, "no-warnings-as-errors")) { - option_values.treat_warnings_as_errors = false; - } - else if(0 == strcmp(long_option, "no-residual-gnuplot")) { - option_values.aopts.do_residual_gnuplot = false; - } - else if(0 == strcmp(long_option, "no-residual-text")) { - option_values.aopts.do_residual_text = false; - } - else if(0 == strcmp(long_option, "disable-constant-subframes")) { - option_values.debug.disable_constant_subframes = true; - } - else if(0 == strcmp(long_option, "disable-fixed-subframes")) { - option_values.debug.disable_fixed_subframes = true; - } - else if(0 == strcmp(long_option, "disable-verbatim-subframes")) { - option_values.debug.disable_verbatim_subframes = true; - } - else if(0 == strcmp(long_option, "no-md5-sum")) { - option_values.debug.do_md5 = false; - } - else if(0 == strcmp(long_option, "no-error-on-compression-fail")) { - option_values.error_on_compression_fail = false; - } - else if(0 == strcmp(long_option, "error-on-compression-fail")) { - option_values.error_on_compression_fail = true; - } - } - else { - switch(short_option) { - case 'h': - option_values.show_help = true; - break; - case 'H': - option_values.show_explain = true; - break; - case 'v': - option_values.show_version = true; - break; - case 'd': - option_values.mode_decode = true; - break; - case 'a': - option_values.mode_decode = true; - option_values.analyze = true; - break; - case 't': - option_values.mode_decode = true; - option_values.test_only = true; - break; - case 'c': - option_values.force_to_stdout = true; - break; - case 's': -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - flac__utils_verbosity_ = 1; -#endif - break; - case 'f': - option_values.force_file_overwrite = true; - break; - case 'o': - FLAC__ASSERT(0 != option_argument); - option_values.cmdline_forced_outfilename = option_argument; - break; - case 'F': - option_values.continue_through_decode_errors = true; - break; - case 'T': - FLAC__ASSERT(0 != option_argument); - if(!flac__vorbiscomment_add(option_values.vorbis_comment, option_argument, /*value_from_file=*/false, /*raw=*/!option_values.utf8_convert, &violation)) - return usage_error("ERROR: (-T/--tag) %s\n", violation); - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - add_compression_setting_uint32_t(CST_COMPRESSION_LEVEL, short_option-'0'); - break; - case '9': - return usage_error("ERROR: compression level '9' is reserved\n"); - case 'V': - option_values.verify = true; - break; - case 'w': - option_values.treat_warnings_as_errors = true; - break; - case 'S': - FLAC__ASSERT(0 != option_argument); - if(0 == strcmp(option_argument, "-")) { - option_values.num_requested_seek_points = 0; - option_values.requested_seek_points[0] = '\0'; - } - else { - if(option_values.num_requested_seek_points < 0) - option_values.num_requested_seek_points = 0; - option_values.num_requested_seek_points++; - if(strlen(option_values.requested_seek_points)+strlen(option_argument)+2 >= sizeof(option_values.requested_seek_points)) { - return usage_error("ERROR: too many seekpoints requested\n"); - } - else { - size_t len = strlen(option_values.requested_seek_points); - flac_snprintf(option_values.requested_seek_points+len, sizeof(option_values.requested_seek_points) - len, "%s;", option_argument); - } - } - break; - case 'P': - FLAC__ASSERT(0 != option_argument); - option_values.padding = atoi(option_argument); - if(option_values.padding < 0) - return usage_error("ERROR: argument to -%c must be >= 0; for no padding use -%c-\n", short_option, short_option); - break; - case 'b': - { - uint32_t i ; - FLAC__ASSERT(0 != option_argument); - i = atoi(option_argument); - if((i < (int)FLAC__MIN_BLOCK_SIZE || i > (int)FLAC__MAX_BLOCK_SIZE)) - return usage_error("ERROR: invalid blocksize (-%c) '%d', must be >= %u and <= %u\n", short_option, i, FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE); - add_compression_setting_uint32_t(CST_BLOCKSIZE, (uint32_t)i); - } - break; - case 'e': - add_compression_setting_bool(CST_DO_EXHAUSTIVE_MODEL_SEARCH, true); - break; - case 'E': - add_compression_setting_bool(CST_DO_ESCAPE_CODING, true); - break; - case 'l': - { - uint32_t i ; - FLAC__ASSERT(0 != option_argument); - i = atoi(option_argument); - if(i > FLAC__MAX_LPC_ORDER) - return usage_error("ERROR: invalid LPC order (-%c) '%d', must be >= %u and <= %u\n", short_option, i, 0, FLAC__MAX_LPC_ORDER); - add_compression_setting_uint32_t(CST_MAX_LPC_ORDER, i); - } - break; - case 'A': - FLAC__ASSERT(0 != option_argument); - add_compression_setting_string(CST_APODIZATION, option_argument); - break; - case 'm': - add_compression_setting_bool(CST_DO_MID_SIDE, true); - add_compression_setting_bool(CST_LOOSE_MID_SIDE, false); - break; - case 'M': - add_compression_setting_bool(CST_DO_MID_SIDE, true); - add_compression_setting_bool(CST_LOOSE_MID_SIDE, true); - break; - case 'p': - add_compression_setting_bool(CST_DO_QLP_COEFF_PREC_SEARCH, true); - break; - case 'q': - { - uint32_t i ; - FLAC__ASSERT(0 != option_argument); - i = atoi(option_argument); - if((i > 0 && (i < FLAC__MIN_QLP_COEFF_PRECISION || i > FLAC__MAX_QLP_COEFF_PRECISION))) - return usage_error("ERROR: invalid value '%d' for qlp coeff precision (-%c), must be 0 or between %u and %u, inclusive\n", i, short_option, FLAC__MIN_QLP_COEFF_PRECISION, FLAC__MAX_QLP_COEFF_PRECISION); - add_compression_setting_uint32_t(CST_QLP_COEFF_PRECISION, i); - } - break; - case 'r': - { - uint32_t i; - char * p; - FLAC__ASSERT(0 != option_argument); - p = strchr(option_argument, ','); - if(0 == p) { - add_compression_setting_uint32_t(CST_MIN_RESIDUAL_PARTITION_ORDER, 0); - i = atoi(option_argument); - if(i > FLAC__MAX_RICE_PARTITION_ORDER) - return usage_error("ERROR: invalid value '%d' for residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER); - add_compression_setting_uint32_t(CST_MAX_RESIDUAL_PARTITION_ORDER, i); - } - else { - i = atoi(option_argument); - if(i > FLAC__MAX_RICE_PARTITION_ORDER) - return usage_error("ERROR: invalid value '%d' for min residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER); - add_compression_setting_uint32_t(CST_MIN_RESIDUAL_PARTITION_ORDER, i); - i = atoi(++p); - if(i > FLAC__MAX_RICE_PARTITION_ORDER) - return usage_error("ERROR: invalid value '%d' for max residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER); - add_compression_setting_uint32_t(CST_MAX_RESIDUAL_PARTITION_ORDER, i); - } - } - break; - case 'R': - { - uint32_t i; - i = atoi(option_argument); - add_compression_setting_uint32_t(CST_RICE_PARAMETER_SEARCH_DIST, i); - } - break; - default: - FLAC__ASSERT(0); - } - } - - return 0; -} - -void free_options(void) -{ - uint32_t i; - if(0 != option_values.filenames) { - for(i = 0; i < option_values.num_files; i++) { - if(0 != option_values.filenames[i]) - free(option_values.filenames[i]); - } - free(option_values.filenames); - } - if(0 != option_values.vorbis_comment) - FLAC__metadata_object_delete(option_values.vorbis_comment); - for(i = 0; i < option_values.num_pictures; i++) - FLAC__metadata_object_delete(option_values.pictures[i]); -} - -void add_compression_setting_bool(compression_setting_type_t type, FLAC__bool value) -{ - if(option_values.num_compression_settings >= sizeof(option_values.compression_settings)/sizeof(option_values.compression_settings[0])) -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - die("too many compression settings"); -#else - return; -#endif - option_values.compression_settings[option_values.num_compression_settings].type = type; - option_values.compression_settings[option_values.num_compression_settings].value.t_bool = value; - option_values.num_compression_settings++; -} - -void add_compression_setting_string(compression_setting_type_t type, const char *value) -{ - if(option_values.num_compression_settings >= sizeof(option_values.compression_settings)/sizeof(option_values.compression_settings[0])) -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - die("too many compression settings"); -#else - return; -#endif - option_values.compression_settings[option_values.num_compression_settings].type = type; - option_values.compression_settings[option_values.num_compression_settings].value.t_string = value; - option_values.num_compression_settings++; -} - -void add_compression_setting_uint32_t(compression_setting_type_t type, uint32_t value) -{ - if(option_values.num_compression_settings >= sizeof(option_values.compression_settings)/sizeof(option_values.compression_settings[0])) -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - die("too many compression settings"); -#else - return; -#endif - if(type == CST_COMPRESSION_LEVEL) { - /* Compression level always goes first */ - option_values.compression_settings[0].type = type; - option_values.compression_settings[0].value.t_unsigned = value; - } - else { - option_values.compression_settings[option_values.num_compression_settings].type = type; - option_values.compression_settings[option_values.num_compression_settings].value.t_unsigned = value; - option_values.num_compression_settings++; - } -} - -int usage_error(const char *message, ...) -{ - if(flac__utils_verbosity_ >= 1) { - va_list args; - - FLAC__ASSERT(0 != message); - - va_start(args, message); - -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - (void) vfprintf(stderr, message, args); -#endif - - va_end(args); - - printf("Type \"flac\" for a usage summary or \"flac --help\" for all options\n"); - } - - return 1; -} - -void show_version(void) -{ - printf("flac %s\n", FLAC__VERSION_STRING); -} - -static void usage_header(void) -{ - printf("===============================================================================\n"); - printf("flac - Command-line FLAC encoder/decoder version %s\n", FLAC__VERSION_STRING); - printf("Copyright (C) 2000-2009 Josh Coalson\n"); - printf("Copyright (C) 2011-2023 Xiph.Org Foundation\n"); - printf("\n"); - printf("This program is free software; you can redistribute it and/or\n"); - printf("modify it under the terms of the GNU General Public License\n"); - printf("as published by the Free Software Foundation; either version 2\n"); - printf("of the License, or (at your option) any later version.\n"); - printf("\n"); - printf("This program is distributed in the hope that it will be useful,\n"); - printf("but WITHOUT ANY WARRANTY; without even the implied warranty of\n"); - printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"); - printf("GNU General Public License for more details.\n"); - printf("\n"); - printf("You should have received a copy of the GNU General Public License along\n"); - printf("with this program; if not, write to the Free Software Foundation, Inc.,\n"); - printf("51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n"); - printf("===============================================================================\n"); -} - -static void usage_summary(void) -{ - printf("Usage:\n"); - printf("\n"); - printf(" Encoding: flac [] [INPUTFILE [...]]\n"); - printf(" Decoding: flac -d [] [FLACFILE [...]]\n"); - printf(" Testing: flac -t [] [FLACFILE [...]]\n"); - printf("Analyzing: flac -a [] [FLACFILE [...]]\n"); - printf("\n"); - printf("Be sure to read the list of known bugs at:\n"); - printf("http://xiph.org/flac/documentation_bugs.html\n"); - printf("\n"); -} - -void short_usage(void) -{ - usage_header(); - printf("\n"); - printf("This is the short help; for all options use 'flac --help'; for even more\n"); - printf("instructions use 'flac --explain'\n"); - printf("\n"); - printf("Be sure to read the list of known bugs at:\n"); - printf("http://xiph.org/flac/documentation_bugs.html\n"); - printf("\n"); - printf("To encode:\n"); - printf(" flac [-#] [INPUTFILE [...]]\n"); - printf("\n"); - printf(" -# is -0 (fastest compression) to -8 (highest compression); -5 is the default\n"); - printf("\n"); - printf("To decode:\n"); - printf(" flac -d [INPUTFILE [...]]\n"); - printf("\n"); - printf("To test:\n"); - printf(" flac -t [INPUTFILE [...]]\n"); -} - -void show_help(void) -{ - usage_header(); - usage_summary(); - printf("general options:\n"); - printf(" -v, --version Show the flac version number\n"); - printf(" -h, --help Show this screen\n"); - printf(" -H, --explain Show detailed explanation of usage and options\n"); - printf(" -d, --decode Decode (the default behavior is to encode)\n"); - printf(" -t, --test Same as -d except no decoded file is written\n"); - printf(" -a, --analyze Same as -d except an analysis file is written\n"); - printf(" -c, --stdout Write output to stdout\n"); - printf(" -s, --silent Do not write runtime encode/decode statistics\n"); - printf(" --totally-silent Do not print anything, including errors\n"); - printf(" --no-utf8-convert Do not convert tags from local charset to UTF-8\n"); - printf(" -w, --warnings-as-errors Treat all warnings as errors\n"); - printf(" -f, --force Force overwriting of output files\n"); - printf(" -o, --output-name=FILENAME Force the output file name\n"); - printf(" --output-prefix=STRING Prepend STRING to output names\n"); - printf(" --delete-input-file Deletes after a successful encode/decode\n"); - printf(" --preserve-modtime Output files keep timestamp of input (default)\n"); - printf(" --keep-foreign-metadata Save/restore WAVE or AIFF non-audio chunks\n"); - printf(" --keep-foreign-metadata-if-present Save/restore WAVE or AIFF non-audio\n"); - printf(" but not return an error when no such chunks are found\n"); - printf(" --skip={#|mm:ss.ss} Skip the given initial samples for each input\n"); - printf(" --until={#|[+|-]mm:ss.ss} Stop at the given sample for each input file\n"); -#if FLAC__HAS_OGG - printf(" --ogg Use Ogg as transport layer\n"); - printf(" --serial-number Serial number to use for the FLAC stream\n"); -#endif - printf("analysis options:\n"); - printf(" --residual-text Include residual signal in text output\n"); - printf(" --residual-gnuplot Generate gnuplot files of residual distribution\n"); - printf("decoding options:\n"); - printf(" -F, --decode-through-errors Continue decoding through stream errors\n"); - printf(" --cue=[#.#][-[#.#]] Set the beginning and ending cuepoints to decode\n"); - printf("encoding options:\n"); - printf(" -V, --verify Verify a correct encoding\n"); - printf(" --lax Allow encoder to generate non-Subset files\n"); - printf(" --ignore-chunk-sizes Ignore data chunk sizes in WAVE/AIFF files\n"); - printf(" --replay-gain Calculate ReplayGain & store in FLAC tags\n"); - printf(" --cuesheet=FILENAME Import cuesheet and store in CUESHEET block\n"); - printf(" --picture=SPECIFICATION Import picture and store in PICTURE block\n"); - printf(" -T, --tag=FIELD=VALUE Add a FLAC tag; may appear multiple times\n"); - printf(" --tag-from-file=FIELD=FILENAME Like --tag but gets value from file\n"); - printf(" -S, --seekpoint={#|X|#x|#s} Add seek point(s)\n"); - printf(" -P, --padding=# Write a PADDING block of length #\n"); - printf(" -0, --compression-level-0, --fast Synonymous with -l 0 -b 1152 -r 3\n"); - printf(" -1, --compression-level-1 Synonymous with -l 0 -b 1152 -M -r 3\n"); - printf(" -2, --compression-level-2 Synonymous with -l 0 -b 1152 -m -r 3\n"); - printf(" -3, --compression-level-3 Synonymous with -l 6 -b 4096 -r 4\n"); - printf(" -4, --compression-level-4 Synonymous with -l 8 -b 4096 -M -r 4\n"); - printf(" -5, --compression-level-5 Synonymous with -l 8 -b 4096 -m -r 5\n"); - printf(" -6, --compression-level-6 Synonymous with -l 8 -b 4096 -m -r 6\n"); - printf(" -A subdivide_tukey(2)\n"); - printf(" -7, --compression-level-7 Synonymous with -l 12 -b 4096 -m -r 6\n"); - printf(" -A subdivide_tukey(2)\n"); - printf(" -8, --compression-level-8, --best Synonymous with -l 12 -b 4096 -m -r 6\n"); - printf(" -A subdivide_tukey(3)\n"); - printf(" -b, --blocksize=# Specify blocksize in samples\n"); - printf(" -m, --mid-side Try mid-side coding for each frame\n"); - printf(" -M, --adaptive-mid-side Adaptive mid-side coding for all frames\n"); - printf(" -e, --exhaustive-model-search Do exhaustive model search (expensive!)\n"); - printf(" -A, --apodization=\"function\" Window audio data with given the function\n"); - printf(" -l, --max-lpc-order=# Max LPC order; 0 => only fixed predictors\n"); - printf(" -p, --qlp-coeff-precision-search Exhaustively search LP coeff quantization\n"); - printf(" -q, --qlp-coeff-precision=# Specify precision in bits\n"); - printf(" -r, --rice-partition-order=[#,]# Set [min,]max residual partition order\n"); - printf(" --limit-min-bitrate Limit minimum bitrate (for streaming)\n"); - printf("format options:\n"); - printf(" --force-raw-format Treat input or output as raw samples\n"); - printf(" --force-aiff-format Decode to AIFF format\n"); - printf(" --force-rf64-format Decode to RF64 format\n"); - printf(" --force-wave64-format Decode to Wave64 format\n"); - printf(" --force-legacy-wave-format Decode to legacy wave format\n"); - printf(" --force-extensible-wave-format Decode to extensible wave format\n"); - printf(" --force-aiff-c-none-format Decode to AIFF-C NONE format\n"); - printf(" --force-aiff-c-sowt-format Decode to AIFF-C sowt format\n"); - printf("raw format options:\n"); - printf(" --endian={big|little} Set byte order for samples\n"); - printf(" --channels=# Number of channels\n"); - printf(" --bps=# Number of bits per sample\n"); - printf(" --sample-rate=# Sample rate in Hz\n"); - printf(" --sign={signed|unsigned} Sign of samples\n"); - printf(" --input-size=# Size of the raw input in bytes\n"); - printf("negative options:\n"); - printf(" --no-adaptive-mid-side\n"); - printf(" --no-cued-seekpoints\n"); - printf(" --no-decode-through-errors\n"); - printf(" --no-delete-input-file\n"); - printf(" --no-error-on-compression-fail\n"); - printf(" --no-preserve-modtime\n"); - printf(" --no-keep-foreign-metadata\n"); - printf(" --no-exhaustive-model-search\n"); - printf(" --no-lax\n"); - printf(" --no-mid-side\n"); -#if FLAC__HAS_OGG - printf(" --no-ogg\n"); -#endif - printf(" --no-padding\n"); - printf(" --no-qlp-coeff-prec-search\n"); - printf(" --no-replay-gain\n"); - printf(" --no-residual-gnuplot\n"); - printf(" --no-residual-text\n"); - printf(" --no-ignore-chunk-sizes\n"); - printf(" --no-seektable\n"); - printf(" --no-silent\n"); - printf(" --no-force\n"); - printf(" --no-verify\n"); - printf(" --no-warnings-as-errors\n"); -} - -void show_explain(void) -{ - usage_header(); - usage_summary(); - printf("For encoding:\n"); - printf(" The input file(s) may be a PCM WAVE, Wave64, RF64 file, AIFF (or uncompressed\n"); - printf(" AIFF-C) file, or raw samples. The output file(s) will be in native FLAC\n"); - printf(" or Ogg FLAC format\n"); - printf("For decoding, the reverse is true.\n"); - printf("\n"); - printf("A single INPUTFILE may be - for stdin. No INPUTFILE implies stdin. Use of\n"); - printf("stdin implies -c (write to stdout). Normally you should use:\n"); - printf(" flac [options] -o outfilename or flac -d [options] -o outfilename\n"); - printf("instead of:\n"); - printf(" flac [options] > outfilename or flac -d [options] > outfilename\n"); - printf("since the former allows flac to seek backwards to write the STREAMINFO or\n"); - printf("WAVE/AIFF header contents when necessary.\n"); - printf("\n"); - printf("general options:\n"); - printf(" -v, --version Show the flac version number\n"); - printf(" -h, --help Show basic usage a list of all options\n"); - printf(" -H, --explain Show this screen\n"); - printf(" -d, --decode Decode (the default behavior is to encode)\n"); - printf(" -t, --test Same as -d except no decoded file is written\n"); - printf(" -a, --analyze Same as -d except an analysis file is written\n"); - printf(" -c, --stdout Write output to stdout\n"); - printf(" -s, --silent Do not write runtime encode/decode statistics\n"); - printf(" --totally-silent Do not print anything of any kind, including\n"); - printf(" warnings or errors. The exit code will be the\n"); - printf(" only way to determine successful completion.\n"); - printf(" --no-utf8-convert Do not convert tags from local charset to UTF-8.\n"); - printf(" This is useful for scripts, and setting tags in\n"); - printf(" situations where the locale is wrong. This\n"); - printf(" option must appear before any tag options!\n"); - printf(" -w, --warnings-as-errors Treat all warnings as errors\n"); - printf(" -f, --force Force overwriting of output files\n"); - printf(" -o, --output-name=FILENAME Force the output file name; usually flac just\n"); - printf(" changes the extension. May only be used when\n"); - printf(" encoding a single file. May not be used in\n"); - printf(" conjunction with --output-prefix.\n"); - printf(" --output-prefix=STRING Prefix each output file name with the given\n"); - printf(" STRING. This can be useful for encoding or\n"); - printf(" decoding files to a different directory. Make\n"); - printf(" sure if your STRING is a path name that it ends\n"); - printf(" with a '/' slash.\n"); - printf(" --delete-input-file Automatically delete the input file after a\n"); - printf(" successful encode or decode. If there was an\n"); - printf(" error (including a verify error) the input file\n"); - printf(" is left intact.\n"); - printf(" --preserve-modtime Output files have their timestamps/permissions\n"); - printf(" set to match those of their inputs (this is\n"); - printf(" default). Use --no-preserve-modtime to make\n"); - printf(" output files have the current time and default\n"); - printf(" permissions.\n"); - printf(" --keep-foreign-metadata If encoding, save WAVE or AIFF non-audio chunks\n"); - printf(" in FLAC metadata. If decoding, restore any saved\n"); - printf(" non-audio chunks from FLAC metadata when writing\n"); - printf(" the decoded file. Foreign metadata cannot be\n"); - printf(" transcoded, e.g. WAVE chunks saved in a FLAC file\n"); - printf(" cannot be restored when decoding to AIFF. Input\n"); - printf(" and output must be regular files, not stdin/out.\n"); - printf(" With this option, FLAC will pick the right\n"); - printf(" output format on decoding.\n"); - printf(" --keep-foreign-metadata-if-present As previous option, but do not throw\n"); - printf(" an error in case no foreign metadata is found,\n"); - printf(" the wrong kind of foreign metadata is found (on\n"); - printf(" decoding) or if the foreign could not be parsed,\n"); - printf(" i.e. all foreign metadata related errors are\n"); - printf(" treated as warnings.\n"); - printf(" --skip={#|mm:ss.ss} Skip the first # samples of each input file; can\n"); - printf(" be used both for encoding and decoding. The\n"); - printf(" alternative form mm:ss.ss can be used to specify\n"); - printf(" minutes, seconds, and fractions of a second.\n"); - printf(" --until={#|[+|-]mm:ss.ss} Stop at the given sample number for each input\n"); - printf(" file. The given sample number is not included\n"); - printf(" in the decoded output. The alternative form\n"); - printf(" mm:ss.ss can be used to specify minutes,\n"); - printf(" seconds, and fractions of a second. If a `+'\n"); - printf(" sign is at the beginning, the --until point is\n"); - printf(" relative to the --skip point. If a `-' sign is\n"); - printf(" at the beginning, the --until point is relative\n"); - printf(" to end of the audio.\n"); -#if FLAC__HAS_OGG - printf(" --ogg When encoding, generate Ogg FLAC output instead\n"); - printf(" of native FLAC. Ogg FLAC streams are FLAC\n"); - printf(" streams wrapped in an Ogg transport layer. The\n"); - printf(" resulting file should have an '.oga' extension\n"); - printf(" and will still be decodable by flac. When\n"); - printf(" decoding, force the input to be treated as\n"); - printf(" Ogg FLAC. This is useful when piping input\n"); - printf(" from stdin or when the filename does not end in\n"); - printf(" '.oga' or '.ogg'.\n"); - printf(" --serial-number Serial number to use for the FLAC stream. When\n"); - printf(" encoding and no serial number is given, flac\n"); - printf(" uses a random one. If encoding to multiple files\n"); - printf(" the serial number is incremented for each file.\n"); - printf(" When decoding and no number is given, flac uses\n"); - printf(" the serial number of the first page.\n"); -#endif - printf("analysis options:\n"); - printf(" --residual-text Include residual signal in text output. This\n"); - printf(" will make the file very big, much larger than\n"); - printf(" even the decoded file.\n"); - printf(" --residual-gnuplot Generate gnuplot files of residual distribution\n"); - printf(" of each subframe\n"); - printf("decoding options:\n"); - printf(" -F, --decode-through-errors By default flac stops decoding with an error\n"); - printf(" and removes the partially decoded file if it\n"); - printf(" encounters a bitstream error. With -F, errors\n"); - printf(" are still printed but flac will continue\n"); - printf(" decoding to completion. Note that errors may\n"); - printf(" cause the decoded audio to be missing some\n"); - printf(" samples or have silent sections.\n"); - printf(" --cue=[#.#][-[#.#]] Set the beginning and ending cuepoints to\n"); - printf(" decode. The optional first #.# is the track and\n"); - printf(" index point at which decoding will start; the\n"); - printf(" default is the beginning of the stream. The\n"); - printf(" optional second #.# is the track and index point\n"); - printf(" at which decoding will end; the default is the\n"); - printf(" end of the stream. If the cuepoint does not\n"); - printf(" exist, the closest one before it (for the start\n"); - printf(" point) or after it (for the end point) will be\n"); - printf(" used. The cuepoints are merely translated into\n"); - printf(" sample numbers then used as --skip and --until.\n"); - printf(" A CD track can always be cued by, for example,\n"); - printf(" --cue=9.1-10.1 for track 9, even if the CD has\n"); - printf(" no 10th track.\n"); - printf("encoding options:\n"); - printf(" -V, --verify Verify a correct encoding by decoding the\n"); - printf(" output in parallel and comparing to the\n"); - printf(" original\n"); - printf(" --lax Allow encoder to generate non-Subset files\n"); - printf(" --ignore-chunk-sizes Ignore data chunk sizes in WAVE/AIFF files;\n"); - printf(" useful when piping data from programs which\n"); - printf(" generate bogus data chunk sizes.\n"); - printf(" --replay-gain Calculate ReplayGain values and store them as\n"); - printf(" FLAC tags. Title gains/peaks will be computed\n"); - printf(" for each file, and an album gain/peak will be\n"); - printf(" computed for all files. All input files must\n"); - printf(" have the same resolution, sample rate, and\n"); - printf(" number of channels. Only mono and stereo files\n"); - printf(" are allowed, and the sample rate must be 8,\n"); - printf(" 11.025, 12, 16, 18.9, 22.05, 24, 28, 32, 36,\n"); - printf(" 37.8, 44.1, 48, 56, 64, 72, 75.6, 88.2, 96, 112,\n"); - printf(" 128, 144, 151.2, 176.4, 192, 224, 256, 288,\n"); - printf(" 302.4, 352.8, 384, 448, 512, 576, or 604.8 kHz.\n"); - printf(" NOTE: this option may also leave a few extra\n"); - printf(" bytes in the PADDING block.\n"); - printf(" --cuesheet=FILENAME Import the given cuesheet file and store it in\n"); - printf(" a CUESHEET metadata block. This option may only\n"); - printf(" be used when encoding a single file. A\n"); - printf(" seekpoint will be added for each index point in\n"); - printf(" the cuesheet to the SEEKTABLE unless\n"); - printf(" --no-cued-seekpoints is specified.\n"); - printf(" --picture=SPECIFICATION Import a picture and store it in a PICTURE block.\n"); - printf(" More than one --picture command can be specified.\n"); - printf(" The SPECIFICATION can either be a simple filename\n"); - printf(" for the picture file, or a complete specification\n"); - printf(" whose parts are separated by | characters. Some\n"); - printf(" parts may be left empty to invoke default values.\n"); - printf(" Using a filename is shorthand for \"||||FILE\".\n"); - printf(" The SPECIFICATION format is:\n"); - printf(" [TYPE]|[MIME-TYPE]|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE\n"); - printf(" TYPE is optional; it is a number from one of:\n"); - printf(" 0: Other\n"); - printf(" 1: 32x32 pixels 'file icon' (PNG only)\n"); - printf(" 2: Other file icon\n"); - printf(" 3: Cover (front)\n"); - printf(" 4: Cover (back)\n"); - printf(" 5: Leaflet page\n"); - printf(" 6: Media (e.g. label side of CD)\n"); - printf(" 7: Lead artist/lead performer/soloist\n"); - printf(" 8: Artist/performer\n"); - printf(" 9: Conductor\n"); - printf(" 10: Band/Orchestra\n"); - printf(" 11: Composer\n"); - printf(" 12: Lyricist/text writer\n"); - printf(" 13: Recording Location\n"); - printf(" 14: During recording\n"); - printf(" 15: During performance\n"); - printf(" 16: Movie/video screen capture\n"); - printf(" 17: A bright coloured fish\n"); - printf(" 18: Illustration\n"); - printf(" 19: Band/artist logotype\n"); - printf(" 20: Publisher/Studio logotype\n"); - printf(" The default is 3 (front cover). There may only be one picture each\n"); - printf(" of type 1 and 2 in a file.\n"); - printf(" MIME-TYPE is optional; if left blank, it will be detected from the\n"); - printf(" file. For best compatibility with players, use pictures with MIME\n"); - printf(" type image/jpeg or image/png. The MIME type can also be --> to\n"); - printf(" mean that FILE is actually a URL to an image, though this use is\n"); - printf(" discouraged.\n"); - printf(" DESCRIPTION is optional; the default is an empty string\n"); - printf(" The next part specifies the resolution and color information. If\n"); - printf(" the MIME-TYPE is image/jpeg, image/png, or image/gif, you can\n"); - printf(" usually leave this empty and they can be detected from the file.\n"); - printf(" Otherwise, you must specify the width in pixels, height in pixels,\n"); - printf(" and color depth in bits-per-pixel. If the image has indexed colors\n"); - printf(" you should also specify the number of colors used.\n"); - printf(" FILE is the path to the picture file to be imported, or the URL if\n"); - printf(" MIME type is -->\n"); - printf(" -T, --tag=FIELD=VALUE Add a FLAC tag. Make sure to quote the\n"); - printf(" comment if necessary. This option may appear\n"); - printf(" more than once to add several comments. NOTE:\n"); - printf(" all tags will be added to all encoded files.\n"); - printf(" --tag-from-file=FIELD=FILENAME Like --tag, except FILENAME is a file\n"); - printf(" whose contents will be read verbatim to set the\n"); - printf(" tag value. The contents will be converted to\n"); - printf(" UTF-8 from the local charset. This can be used\n"); - printf(" to store a cuesheet in a tag (e.g.\n"); - printf(" --tag-from-file=\"CUESHEET=image.cue\"). Do not\n"); - printf(" try to store binary data in tag fields! Use\n"); - printf(" APPLICATION blocks for that.\n"); - printf(" -S, --seekpoint={#|X|#x|#s} Include a point or points in a SEEKTABLE\n"); - printf(" # : a specific sample number for a seek point\n"); - printf(" X : a placeholder point (always goes at the end of the SEEKTABLE)\n"); - printf(" #x : # evenly spaced seekpoints, the first being at sample 0\n"); - printf(" #s : a seekpoint every # seconds; # does not have to be a whole number\n"); - printf(" You may use many -S options; the resulting SEEKTABLE will be the unique-\n"); - printf(" ified union of all such values.\n"); - printf(" With no -S options, flac defaults to '-S 10s'. Use -S- for no SEEKTABLE.\n"); - printf(" Note: -S #x and -S #s will not work if the encoder can't determine the\n"); - printf(" input size before starting.\n"); - printf(" Note: if you use -S # and # is >= samples in the input, there will be\n"); - printf(" either no seek point entered (if the input size is determinable\n"); - printf(" before encoding starts) or a placeholder point (if input size is not\n"); - printf(" determinable)\n"); - printf(" -P, --padding=# Tell the encoder to write a PADDING metadata\n"); - printf(" block of the given length (in bytes) after the\n"); - printf(" STREAMINFO block. This is useful if you plan\n"); - printf(" to tag the file later with an APPLICATION\n"); - printf(" block; instead of having to rewrite the entire\n"); - printf(" file later just to insert your block, you can\n"); - printf(" write directly over the PADDING block. Note\n"); - printf(" that the total length of the PADDING block will\n"); - printf(" be 4 bytes longer than the length given because\n"); - printf(" of the 4 metadata block header bytes. You can\n"); - printf(" force no PADDING block at all to be written with\n"); - printf(" --no-padding. The encoder writes a PADDING\n"); - printf(" block of 8192 bytes by default, or 65536 bytes\n"); - printf(" if the input audio is more than 20 minutes long.\n"); - printf(" -b, --blocksize=# Specify the blocksize in samples; the default is\n"); - printf(" 1152 for -l 0, else 4096; for subset streams this\n"); - printf(" must be <= 4608 if the samplerate <= 48kHz,\n"); - printf(" for subset streams with a higher samplerates it\n"); - printf(" must be <= 16384.\n"); - printf(" -0, --compression-level-0, --fast Synonymous with -l 0 -b 1152 -r 3\n"); - printf(" --no-mid-side\n"); - printf(" -1, --compression-level-1 Synonymous with -l 0 -b 1152 -M -r 3\n"); - printf(" -2, --compression-level-2 Synonymous with -l 0 -b 1152 -m -r 3\n"); - printf(" -3, --compression-level-3 Synonymous with -l 6 -b 4096 -r 4\n"); - printf(" --no-mid-side\n"); - printf(" -4, --compression-level-4 Synonymous with -l 8 -b 4096 -M -r 4\n"); - printf(" -5, --compression-level-5 Synonymous with -l 8 -b 4096 -m -r 5\n"); - printf(" -5 is the default setting\n"); - printf(" -6, --compression-level-6 Synonymous with -l 8 -b 4096 -m -r 6\n"); - printf(" -A subdivide_tukey(2)\n"); - printf(" -7, --compression-level-7 Synonymous with -l 12 -b 4096 -m -r 6\n"); - printf(" -A subdivide_tukey(2)\n"); - printf(" -8, --compression-level-8, --best Synonymous with -l 12 -b 4096 -m -r 6\n"); - printf(" -A subdivide_tukey(3)\n"); - printf(" -m, --mid-side Try mid-side coding for each frame\n"); - printf(" (stereo only)\n"); - printf(" -M, --adaptive-mid-side Adaptive mid-side coding for all frames\n"); - printf(" (stereo only)\n"); - printf(" -e, --exhaustive-model-search Do exhaustive model search (expensive!)\n"); - printf(" -A, --apodization=\"function\" Window audio data with given the function.\n"); - printf(" The functions are: bartlett, bartlett_hann,\n"); - printf(" blackman, blackman_harris_4term_92db,\n"); - printf(" connes, flattop, gauss(STDDEV), hamming,\n"); - printf(" hann, kaiser_bessel, nuttall, rectangle,\n"); - printf(" triangle, tukey(P), welch, partial_tukey(n)\n"); - printf(" punchout_tukey(n) and subdivide_tukey(n).\n"); - printf(" More than one may be specified but encoding\n"); - printf(" time is a multiple of the number of\n"); - printf(" functions since they are each tried in \n"); - printf(" turn. The encoder chooses suitable\n"); - printf(" defaults in the absence of any -A options.\n"); - printf(" -l, --max-lpc-order=# Max LPC order; 0 => only fixed predictors.\n"); - printf(" Must be <= 12 for Subset streams if sample\n"); - printf(" rate is <=48kHz.\n"); - printf(" -p, --qlp-coeff-precision-search Do exhaustive search of LP coefficient\n"); - printf(" quantization (expensive!); overrides -q;\n"); - printf(" does nothing if using -l 0\n"); - printf(" -q, --qlp-coeff-precision=# Specify precision in bits of quantized\n"); - printf(" linear-predictor coefficients; 0 => let\n"); - printf(" encoder decide (the minimum is %u, the\n", FLAC__MIN_QLP_COEFF_PRECISION); - printf(" default is -q 0)\n"); - printf(" -r, --rice-partition-order=[#,]# Set [min,]max residual partition order\n"); - printf(" (# is 0 to 15 inclusive; min defaults to 0;\n"); - printf(" the default is -r 0; above 4 does not\n"); - printf(" usually help much)\n"); - printf(" --limit-min-bitrate Limit minimum bitrate by not allowing\n"); - printf(" frames consisting of only constant\n"); - printf(" subframes. This ensures a bitrate of at\n"); - printf(" least 1 bit/sample, for example 48kbit/s\n"); - printf(" for 48kHz input. This is mostly beneficial\n"); - printf(" for internet streaming.\n"); - printf("format options:\n"); - printf(" --force-raw-format Force input (when encoding) or output (when\n"); - printf(" decoding) to be treated as raw samples\n"); - printf(" --force-aiff-format\n"); - printf(" --force-rf64-format\n"); - printf(" --force-wave64-format\n"); - printf(" Force the decoder to output AIFF/RF64/WAVE64 format respectively.\n"); - printf(" This option is not needed if the output filename (as set by -o)\n"); - printf(" ends with *.aif* or *.aiff*, *.rf64* and *.w64* respectively. Also,\n"); - printf(" this option has no effect when encoding since input is\n"); - printf(" auto-detected. When none of these options nor\n"); - printf(" --keep-foreign-metadata are given and no output filename is set,\n"); - printf(" the output format is WAV by default.\n"); - printf(" --force-legacy-wave-format\n"); - printf(" --force-extensible-wave-format\n"); - printf(" Instruct the decoder to output a WAVE file with WAVE_FORMAT_PCM and\n"); - printf(" WAVE_FORMAT_EXTENSIBLE respectively. If none of these options nor\n"); - printf(" --keep-foreign-metadata are given, FLAC outputs WAVE_FORMAT_PCM\n"); - printf(" for mono or stereo with a bit depth of 8 or 16 bits, and\n"); - printf(" WAVE_FORMAT_EXTENSIBLE for all other audio formats.\n"); - printf(" --force-aiff-c-none-format\n"); - printf(" --force-aiff-c-sowt-format\n"); - printf(" Instruct the decoder to output an AIFF-C file with format NONE and\n"); - printf(" sowt respectively.\n"); - printf("raw format options:\n"); - printf(" --endian={big|little} Set byte order for samples\n"); - printf(" --channels=# Number of channels\n"); - printf(" --bps=# Number of bits per sample\n"); - printf(" --sample-rate=# Sample rate in Hz\n"); - printf(" --sign={signed|unsigned} Sign of samples\n"); - printf(" --input-size=# Size of the raw input in bytes. If you are\n"); - printf(" encoding raw samples from stdin, you must set\n"); - printf(" this option in order to be able to use --skip,\n"); - printf(" --until, --cuesheet, or other options that need\n"); - printf(" to know the size of the input beforehand. If\n"); - printf(" the size given is greater than what is found in\n"); - printf(" the input stream, the encoder will complain\n"); - printf(" about an unexpected end-of-file. If the size\n"); - printf(" given is less, samples will be truncated.\n"); - printf("negative options:\n"); - printf(" --no-adaptive-mid-side\n"); - printf(" --no-cued-seekpoints\n"); - printf(" --no-decode-through-errors\n"); - printf(" --no-delete-input-file\n"); - printf(" --no-preserve-modtime\n"); - printf(" --no-keep-foreign-metadata\n"); - printf(" --no-exhaustive-model-search\n"); - printf(" --no-lax\n"); - printf(" --no-mid-side\n"); -#if FLAC__HAS_OGG - printf(" --no-ogg\n"); -#endif - printf(" --no-padding\n"); - printf(" --no-qlp-coeff-prec-search\n"); - printf(" --no-residual-gnuplot\n"); - printf(" --no-residual-text\n"); - printf(" --no-ignore-chunk-sizes\n"); - printf(" --no-seektable\n"); - printf(" --no-silent\n"); - printf(" --no-force\n"); - printf(" --no-verify\n"); - printf(" --no-warnings-as-errors\n"); -} - -void format_mistake(const char *infilename, FileFormat wrong, FileFormat right) -{ - /* WATCHOUT: indexed by FileFormat */ - flac__utils_printf(stderr, 1, "WARNING: %s is not a%s file; treating as a%s file\n", infilename, FileFormatString[wrong], FileFormatString[right]); -} - -int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_last_file) -{ - FILE *encode_infile; - FLAC__byte lookahead[12]; - uint32_t lookahead_length = 0, master_chunk_size = 0; - FileFormat input_format = FORMAT_RAW; - int retval; - FLAC__off_t infilesize; - encode_options_t encode_options; - const char *outfilename = get_encoded_outfilename(infilename); /* the final name of the encoded file */ - /* internal_outfilename is the file we will actually write to; it will be a temporary name if infilename==outfilename */ - char *internal_outfilename = 0; /* NULL implies 'use outfilename' */ - size_t infilename_length; - - if(0 == outfilename) { - flac__utils_printf(stderr, 1, "ERROR: filename too long: %s", infilename); - return 1; - } - - if(0 == strcmp(infilename, "-")) { - infilesize = (FLAC__off_t)(-1); - encode_infile = grabbag__file_get_binary_stdin(); - } - else - { - infilesize = grabbag__file_get_filesize(infilename); - if(0 == (encode_infile = flac_fopen(infilename, "rb"))) { - flac__utils_printf(stderr, 1, "ERROR: can't open input file %s: %s\n", infilename, strerror(errno)); - return 1; - } - } - - if(!option_values.force_raw_format) { - /* first set format based on name */ - infilename_length = strlen(infilename); - if(infilename_length >= 4 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-4), ".wav")) - input_format = FORMAT_WAVE; - else if(infilename_length >= 5 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-5), ".rf64")) - input_format = FORMAT_RF64; - else if(infilename_length >= 4 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-4), ".w64")) - input_format = FORMAT_WAVE64; - else if(infilename_length >= 4 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-4), ".aif")) - input_format = FORMAT_AIFF; - else if(infilename_length >= 5 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-5), ".aiff")) - input_format = FORMAT_AIFF; - else if(infilename_length >= 5 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-5), ".flac")) - input_format = FORMAT_FLAC; - else if(infilename_length >= 4 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-4), ".oga")) - input_format = FORMAT_OGGFLAC; - else if(infilename_length >= 4 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-4), ".ogg")) - input_format = FORMAT_OGGFLAC; - - /* attempt to guess the file type based on the first 12 bytes */ - if((lookahead_length = fread(lookahead, 1, 12, encode_infile)) < 12) { - /* all supported non-raw formats have at least 12 bytes of header to read */ - if(input_format != FORMAT_RAW) { - format_mistake(infilename, input_format, FORMAT_RAW); - if(option_values.treat_warnings_as_errors) { - conditional_fclose(encode_infile); - return 1; - } - } - /* force to raw */ - input_format = FORMAT_RAW; - } - else { - if(!memcmp(lookahead, "ID3", 3)) { - flac__utils_printf(stderr, 1, "ERROR: input file %s has an ID3v2 tag\n", infilename); - conditional_fclose(encode_infile); - return 1; - } - else if(!memcmp(lookahead, "RIFF", 4) && !memcmp(lookahead+8, "WAVE", 4)) - input_format = FORMAT_WAVE; - else if(!memcmp(lookahead, "RF64", 4) && !memcmp(lookahead+8, "WAVE", 4)) - input_format = FORMAT_RF64; - else if(!memcmp(lookahead, "riff\x2E\x91\xCF\x11\xA5\xD6\x28\xDB", 12)) /* just check 1st 12 bytes of GUID */ - input_format = FORMAT_WAVE64; - else if(!memcmp(lookahead, "FORM", 4) && !memcmp(lookahead+8, "AIFF", 4)) - input_format = FORMAT_AIFF; - else if(!memcmp(lookahead, "FORM", 4) && !memcmp(lookahead+8, "AIFC", 4)) - input_format = FORMAT_AIFF_C; - else if(!memcmp(lookahead, FLAC__STREAM_SYNC_STRING, sizeof(FLAC__STREAM_SYNC_STRING))) - input_format = FORMAT_FLAC; - /*@@@ this could be made more accurate by looking at the first packet to make sure it's Ogg FLAC and not, say, Ogg Vorbis. we do catch such problems later though. */ - else if(!memcmp(lookahead, "OggS", 4)) - input_format = FORMAT_OGGFLAC; - else { - /* didn't find header of any supported format */ - if(input_format != FORMAT_RAW) { - format_mistake(infilename, input_format, FORMAT_RAW); - if(option_values.treat_warnings_as_errors) { - conditional_fclose(encode_infile); - return 1; - } - } - /* force to raw */ - input_format = FORMAT_RAW; - } - } - } - - if(!option_values.ignore_chunk_sizes - && (input_format == FORMAT_WAVE || input_format == FORMAT_AIFF || input_format == FORMAT_AIFF_C) - && infilesize >= UINT32_MAX) { - conditional_fclose(encode_infile); - return usage_error("ERROR: file %s is too large to be valid.\n" - "Please consult the manual on the --ignore-chunk-sizes option\n\n", infilename); - } - - if(input_format == FORMAT_WAVE || input_format == FORMAT_AIFF || input_format == FORMAT_AIFF_C) { - memcpy(&master_chunk_size,lookahead+4,sizeof(master_chunk_size)); - if((input_format != FORMAT_WAVE) != CPU_IS_BIG_ENDIAN /* logical xor */) - /* true for WAVE on big endian CPUs or AIFF/AIFF-C on little endian CPUs */ - master_chunk_size = ENDSWAP_32(master_chunk_size); - - if(infilesize != (FLAC__off_t)(-1) && infilesize > 8 && (infilesize - 8) != master_chunk_size) { - flac__utils_printf(stderr, 1, "WARNING: %s chunk size of file %s does not agree with filesize\n", (input_format == FORMAT_WAVE)?"RIFF":"FORM", infilename); - if(option_values.treat_warnings_as_errors) - return 1; - } - } - - if(option_values.keep_foreign_metadata || option_values.keep_foreign_metadata_if_present) { - if(encode_infile == stdin || option_values.force_to_stdout) { - conditional_fclose(encode_infile); - return usage_error("ERROR: --keep-foreign-metadata cannot be used when encoding from stdin or to stdout\n"); - } - if(input_format != FORMAT_WAVE && input_format != FORMAT_WAVE64 && input_format != FORMAT_RF64 && input_format != FORMAT_AIFF && input_format != FORMAT_AIFF_C) { - conditional_fclose(encode_infile); - return usage_error("ERROR: --keep-foreign-metadata can only be used with WAVE, Wave64, RF64, or AIFF input\n"); - } - } - - /* - * Error if output file already exists (and -f not used). - * Use grabbag__file_get_filesize() as a cheap way to check. - */ - if(!option_values.test_only && !option_values.force_file_overwrite && strcmp(outfilename, "-") && grabbag__file_get_filesize(outfilename) != (FLAC__off_t)(-1)) { - if(input_format == FORMAT_FLAC) { - /* need more detailed error message when re-flac'ing to avoid confusing the user */ - flac__utils_printf(stderr, 1, - "ERROR: output file %s already exists.\n\n" - "By default flac encodes files to FLAC format; if you meant to decode this file\n" - "from FLAC to something else, use -d. If you meant to re-encode this file from\n" - "FLAC to FLAC again, use -f to force writing to the same file, or -o to specify\n" - "a different output filename.\n", - outfilename - ); - } - else if(input_format == FORMAT_OGGFLAC) { - /* need more detailed error message when re-flac'ing to avoid confusing the user */ - flac__utils_printf(stderr, 1, - "ERROR: output file %s already exists.\n\n" - "By default 'flac -ogg' encodes files to Ogg FLAC format; if you meant to decode\n" - "this file from Ogg FLAC to something else, use -d. If you meant to re-encode\n" - "this file from Ogg FLAC to Ogg FLAC again, use -f to force writing to the same\n" - "file, or -o to specify a different output filename.\n", - outfilename - ); - } - else - flac__utils_printf(stderr, 1, "ERROR: output file %s already exists, use -f to override\n", outfilename); - conditional_fclose(encode_infile); - return 1; - } - - if(option_values.format_input_size >= 0) { - if (input_format != FORMAT_RAW || infilesize >= 0) { - flac__utils_printf(stderr, 1, "ERROR: can only use --input-size when encoding raw samples from stdin\n"); - conditional_fclose(encode_infile); - return 1; - } - else { - infilesize = option_values.format_input_size; - } - } - - if(input_format == FORMAT_RAW) { - if(option_values.format_is_big_endian < 0 || option_values.format_is_unsigned_samples < 0 || option_values.format_channels < 0 || option_values.format_bps < 0 || option_values.format_sample_rate < 0) { - conditional_fclose(encode_infile); - return usage_error("ERROR: for encoding a raw file you must specify a value for --endian, --sign, --channels, --bps, and --sample-rate\n"); - } - } - else { - if(option_values.format_is_big_endian >= 0 || option_values.format_is_unsigned_samples >= 0 || option_values.format_channels >= 0 || option_values.format_bps >= 0 || option_values.format_sample_rate >= 0) { - conditional_fclose(encode_infile); - return usage_error("ERROR: raw format options (--endian, --sign, --channels, --bps, and --sample-rate) are not allowed for non-raw input\n"); - } - } - - if(option_values.force_to_stdout) { - if(option_values.replay_gain) { - conditional_fclose(encode_infile); - return usage_error("ERROR: --replay-gain cannot be used when encoding to stdout\n"); - } - } - if(option_values.replay_gain && option_values.use_ogg) { - conditional_fclose(encode_infile); - return usage_error("ERROR: --replay-gain cannot be used when encoding to Ogg FLAC yet\n"); - } - - if(!flac__utils_parse_skip_until_specification(option_values.skip_specification, &encode_options.skip_specification) || encode_options.skip_specification.is_relative) { - conditional_fclose(encode_infile); - return usage_error("ERROR: invalid value for --skip\n"); - } - - if(!flac__utils_parse_skip_until_specification(option_values.until_specification, &encode_options.until_specification)) { /*@@@@ more checks: no + without --skip, no - unless known total_samples_to_{en,de}code */ - conditional_fclose(encode_infile); - return usage_error("ERROR: invalid value for --until\n"); - } - /* if there is no "--until" we want to default to "--until=-0" */ - if(0 == option_values.until_specification) - encode_options.until_specification.is_relative = true; - - encode_options.verify = option_values.verify; - encode_options.treat_warnings_as_errors = option_values.treat_warnings_as_errors; -#if FLAC__HAS_OGG - encode_options.use_ogg = option_values.use_ogg; - /* set a random serial number if one has not yet been specified */ - if(!option_values.has_serial_number) { - option_values.serial_number = rand(); - option_values.has_serial_number = true; - } - encode_options.serial_number = option_values.serial_number++; -#endif - encode_options.lax = option_values.lax; - encode_options.padding = option_values.padding; - encode_options.num_compression_settings = option_values.num_compression_settings; - FLAC__ASSERT(sizeof(encode_options.compression_settings) >= sizeof(option_values.compression_settings)); - memcpy(encode_options.compression_settings, option_values.compression_settings, sizeof(option_values.compression_settings)); - encode_options.requested_seek_points = option_values.requested_seek_points; - encode_options.num_requested_seek_points = option_values.num_requested_seek_points; - encode_options.cuesheet_filename = option_values.cuesheet_filename; - encode_options.continue_through_decode_errors = option_values.continue_through_decode_errors; - encode_options.cued_seekpoints = option_values.cued_seekpoints; - encode_options.channel_map_none = option_values.channel_map_none; - encode_options.is_first_file = is_first_file; - encode_options.is_last_file = is_last_file; - encode_options.replay_gain = option_values.replay_gain; - encode_options.ignore_chunk_sizes = option_values.ignore_chunk_sizes; - encode_options.vorbis_comment = option_values.vorbis_comment; - FLAC__ASSERT(sizeof(encode_options.pictures) >= sizeof(option_values.pictures)); - memcpy(encode_options.pictures, option_values.pictures, sizeof(option_values.pictures)); - encode_options.num_pictures = option_values.num_pictures; - encode_options.format = input_format; - encode_options.debug.disable_constant_subframes = option_values.debug.disable_constant_subframes; - encode_options.debug.disable_fixed_subframes = option_values.debug.disable_fixed_subframes; - encode_options.debug.disable_verbatim_subframes = option_values.debug.disable_verbatim_subframes; - encode_options.debug.do_md5 = option_values.debug.do_md5; - encode_options.error_on_compression_fail = option_values.error_on_compression_fail; - encode_options.limit_min_bitrate = option_values.limit_min_bitrate; - encode_options.relaxed_foreign_metadata_handling = option_values.keep_foreign_metadata_if_present; - - /* if infilename and outfilename point to the same file, we need to write to a temporary file */ - if(encode_infile != stdin && grabbag__file_are_same(infilename, outfilename)) { - static const char *tmp_suffix = ".tmp,fl-ac+en'c"; - size_t dest_len = strlen(outfilename) + strlen(tmp_suffix) + 1; - /*@@@@ still a remote possibility that a file with this filename exists */ - if((internal_outfilename = safe_malloc_(dest_len)) == NULL) { - flac__utils_printf(stderr, 1, "ERROR allocating memory for tempfile name\n"); - conditional_fclose(encode_infile); - return 1; - } - flac_snprintf(internal_outfilename, dest_len, "%s%s", outfilename, tmp_suffix); - } - - if(input_format == FORMAT_RAW) { - encode_options.format_options.raw.is_big_endian = option_values.format_is_big_endian; - encode_options.format_options.raw.is_unsigned_samples = option_values.format_is_unsigned_samples; - encode_options.format_options.raw.channels = option_values.format_channels; - encode_options.format_options.raw.bps = option_values.format_bps; - encode_options.format_options.raw.sample_rate = option_values.format_sample_rate; - - retval = flac__encode_file(encode_infile, infilesize, infilename, internal_outfilename? internal_outfilename : outfilename, lookahead, lookahead_length, encode_options); - } - else if(input_format == FORMAT_FLAC || input_format == FORMAT_OGGFLAC) { - retval = flac__encode_file(encode_infile, infilesize, infilename, internal_outfilename? internal_outfilename : outfilename, lookahead, lookahead_length, encode_options); - } - else if(input_format == FORMAT_WAVE || input_format == FORMAT_WAVE64 || input_format == FORMAT_RF64 || input_format == FORMAT_AIFF || input_format == FORMAT_AIFF_C) { - encode_options.format_options.iff.foreign_metadata = 0; - - /* initialize foreign metadata if requested */ - if(option_values.keep_foreign_metadata || option_values.keep_foreign_metadata_if_present) { - encode_options.format_options.iff.foreign_metadata = - flac__foreign_metadata_new( - input_format==FORMAT_WAVE || input_format==FORMAT_RF64? - FOREIGN_BLOCK_TYPE__RIFF : - input_format==FORMAT_WAVE64? - FOREIGN_BLOCK_TYPE__WAVE64 : - FOREIGN_BLOCK_TYPE__AIFF - ); - if(0 == encode_options.format_options.iff.foreign_metadata) { - flac__utils_printf(stderr, 1, "ERROR: creating foreign metadata object\n"); - conditional_fclose(encode_infile); - if(internal_outfilename != 0) - free(internal_outfilename); - return 1; - } - } - - retval = flac__encode_file(encode_infile, infilesize, infilename, internal_outfilename? internal_outfilename : outfilename, lookahead, lookahead_length, encode_options); - - if(encode_options.format_options.iff.foreign_metadata) - flac__foreign_metadata_delete(encode_options.format_options.iff.foreign_metadata); - } - else { - FLAC__ASSERT(0); - retval = 1; /* double protection */ - } - - if(retval == 0) { - if(strcmp(outfilename, "-")) { - if(option_values.replay_gain) { - float title_gain, title_peak; - const char *error; - grabbag__replaygain_get_title(&title_gain, &title_peak); - if( - 0 != (error = grabbag__replaygain_store_to_file_reference(internal_outfilename? internal_outfilename : outfilename, option_values.preserve_modtime)) || - 0 != (error = grabbag__replaygain_store_to_file_title(internal_outfilename? internal_outfilename : outfilename, title_gain, title_peak, option_values.preserve_modtime)) - ) { - flac__utils_printf(stderr, 1, "%s: ERROR writing ReplayGain reference/title tags (%s)\n", outfilename, error); - retval = 1; - } - } - if(option_values.preserve_modtime && strcmp(infilename, "-")) - grabbag__file_copy_metadata(infilename, internal_outfilename? internal_outfilename : outfilename); - } - } - - /* rename temporary file if necessary */ - if(retval == 0 && internal_outfilename != 0) { - if(flac_rename(internal_outfilename, outfilename) < 0) { -#if defined _MSC_VER || defined __MINGW32__ || defined __EMX__ - /* on some flavors of windows, flac_rename() will fail if the destination already exists, so we unlink and try again */ - if(flac_unlink(outfilename) < 0) { - flac__utils_printf(stderr, 1, "ERROR: moving new FLAC file %s back on top of original FLAC file %s, keeping both\n", internal_outfilename, outfilename); - retval = 1; - } - else if(flac_rename(internal_outfilename, outfilename) < 0) { - flac__utils_printf(stderr, 1, "ERROR: moving new FLAC file %s back on top of original FLAC file %s, you must do it\n", internal_outfilename, outfilename); - retval = 1; - } -#else - flac__utils_printf(stderr, 1, "ERROR: moving new FLAC file %s back on top of original FLAC file %s, keeping both\n", internal_outfilename, outfilename); - retval = 1; -#endif - } - } - - /* handle --delete-input-file, but don't want to delete if piping from stdin, or if input filename and output filename are the same */ - if(retval == 0 && option_values.delete_input && strcmp(infilename, "-") && internal_outfilename == 0) - flac_unlink(infilename); - - if(internal_outfilename != 0) - free(internal_outfilename); - - return retval; -} - -int decode_file(const char *infilename) -{ - int retval; - FLAC__bool treat_as_ogg = false; - FileFormat output_format = FORMAT_WAVE; - FileSubFormat output_subformat = SUBFORMAT_UNSPECIFIED; - decode_options_t decode_options; - foreign_metadata_t *foreign_metadata = 0; - const char *outfilename = get_outfilename(infilename, ". "); /* Placeholder until we know what the actual suffix is */ - size_t infilename_length; - - if(0 == outfilename) { - flac__utils_printf(stderr, 1, "ERROR: filename too long: %s", infilename); - return 1; - } - - if(!option_values.analyze && !option_values.test_only &&(option_values.keep_foreign_metadata || option_values.keep_foreign_metadata_if_present)) { - const char *error; - if(0 == strcmp(infilename, "-") || 0 == strcmp(outfilename, "-")) - return usage_error("ERROR: --keep-foreign-metadata cannot be used when decoding from stdin or to stdout\n"); - if(output_format == FORMAT_RAW) - return usage_error("ERROR: --keep-foreign-metadata cannot be used with raw output\n"); - decode_options.format_options.iff.foreign_metadata = 0; - /* initialize foreign metadata structure */ - foreign_metadata = flac__foreign_metadata_new(FOREIGN_BLOCK_TYPE__RIFF); /* RIFF is just a placeholder */ - if(0 == foreign_metadata) { - flac__utils_printf(stderr, 1, "ERROR: creating foreign metadata object\n"); - return 1; - } - if(!flac__foreign_metadata_read_from_flac(foreign_metadata, infilename, &error)) { - if(option_values.keep_foreign_metadata_if_present) { - flac__utils_printf(stderr, 1, "%s: WARNING reading foreign metadata: %s\n", infilename, error); - if(option_values.treat_warnings_as_errors) { - flac__foreign_metadata_delete(foreign_metadata); - return 1; - } - else { - /* Couldn't find foreign metadata, stop processing */ - flac__foreign_metadata_delete(foreign_metadata); - foreign_metadata = 0; - } - } - else { - flac__utils_printf(stderr, 1, "%s: ERROR reading foreign metadata: %s\n", infilename, error); - flac__foreign_metadata_delete(foreign_metadata); - return 1; - } - } - } - - if(option_values.force_raw_format) - output_format = FORMAT_RAW; - else if( - option_values.force_aiff_format || - (strlen(outfilename) >= 4 && 0 == FLAC__STRCASECMP(outfilename+(strlen(outfilename)-4), ".aif")) || - (strlen(outfilename) >= 5 && 0 == FLAC__STRCASECMP(outfilename+(strlen(outfilename)-5), ".aiff")) - ) - output_format = FORMAT_AIFF; - else if( - option_values.force_rf64_format || - (strlen(outfilename) >= 5 && 0 == FLAC__STRCASECMP(outfilename+(strlen(outfilename)-5), ".rf64")) - ) - output_format = FORMAT_RF64; - else if( - option_values.force_wave64_format || - (strlen(outfilename) >= 4 && 0 == FLAC__STRCASECMP(outfilename+(strlen(outfilename)-4), ".w64")) - ) - output_format = FORMAT_WAVE64; - else if(foreign_metadata != NULL) { - /* Pick a format based on what the foreign metadata contains */ - if(foreign_metadata->type == FOREIGN_BLOCK_TYPE__WAVE64) - output_format = FORMAT_WAVE64; - else if(foreign_metadata->is_rf64) - output_format = FORMAT_RF64; - else if(foreign_metadata->type == FOREIGN_BLOCK_TYPE__AIFF) { - output_format = FORMAT_AIFF; - if(foreign_metadata->is_aifc) { - output_format = FORMAT_AIFF_C; - } - } - else - output_format = FORMAT_WAVE; - } - else - output_format = FORMAT_WAVE; - - /* Now do subformats */ - if(option_values.force_legacy_wave_format) - output_subformat = SUBFORMAT_WAVE_PCM; - else if(option_values.force_extensible_wave_format) - output_subformat = SUBFORMAT_WAVE_EXTENSIBLE; - else if(option_values.force_aiff_c_none_format) { - output_format = FORMAT_AIFF_C; - output_subformat = SUBFORMAT_AIFF_C_NONE; - } - else if(option_values.force_aiff_c_sowt_format) { - output_format = FORMAT_AIFF_C; - output_subformat = SUBFORMAT_AIFF_C_SOWT; - } - else if(foreign_metadata != NULL) { - if(foreign_metadata->is_wavefmtex) - output_subformat = SUBFORMAT_WAVE_EXTENSIBLE; - else if(output_format == FORMAT_WAVE) - output_subformat = SUBFORMAT_WAVE_PCM; - else if(foreign_metadata->is_aifc) { - if(foreign_metadata->is_sowt) - output_subformat = SUBFORMAT_AIFF_C_SOWT; - else - output_subformat = SUBFORMAT_AIFF_C_NONE; - } - } - - - /* Check whether output format agrees with foreign metadata */ - if(foreign_metadata != NULL) { - if((output_format != FORMAT_WAVE && output_format != FORMAT_RF64) && foreign_metadata->type == FOREIGN_BLOCK_TYPE__RIFF) { - flac__foreign_metadata_delete(foreign_metadata); - return usage_error("ERROR: foreign metadata type RIFF cannot be restored to a%s file, only to WAVE and RF64\n",FileFormatString[output_format]); - } - if((output_format != FORMAT_AIFF && output_format != FORMAT_AIFF_C) && foreign_metadata->type == FOREIGN_BLOCK_TYPE__AIFF) { - flac__foreign_metadata_delete(foreign_metadata); - return usage_error("ERROR: foreign metadata type AIFF cannot be restored to a%s file, only to AIFF and AIFF-C\n",FileFormatString[output_format]); - } - if(output_format != FORMAT_WAVE64 && foreign_metadata->type == FOREIGN_BLOCK_TYPE__WAVE64) { - flac__foreign_metadata_delete(foreign_metadata); - return usage_error("ERROR: foreign metadata type Wave64 cannot be restored to a%s file, only to Wave64\n",FileFormatString[output_format]); - } - } - - /* Now reassemble outfilename */ - get_decoded_outfilename(infilename, output_format); - - /* - * Error if output file already exists (and -f not used). - * Use grabbag__file_get_filesize() as a cheap way to check. - */ - if(!option_values.test_only && !option_values.force_file_overwrite && strcmp(outfilename, "-") && grabbag__file_get_filesize(outfilename) != (FLAC__off_t)(-1)) { - flac__utils_printf(stderr, 1, "ERROR: output file %s already exists, use -f to override\n", outfilename); - flac__foreign_metadata_delete(foreign_metadata); - return 1; - } - - if(!option_values.test_only && !option_values.analyze) { - if(output_format == FORMAT_RAW && (option_values.format_is_big_endian < 0 || option_values.format_is_unsigned_samples < 0)) { - flac__foreign_metadata_delete(foreign_metadata); - return usage_error("ERROR: for decoding to a raw file you must specify a value for --endian and --sign\n"); - } - } - - infilename_length = strlen(infilename); - if(option_values.use_ogg) - treat_as_ogg = true; - else if(infilename_length >= 4 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-4), ".oga")) - treat_as_ogg = true; - else if(infilename_length >= 4 && 0 == FLAC__STRCASECMP(infilename+(infilename_length-4), ".ogg")) - treat_as_ogg = true; - else - treat_as_ogg = false; - -#if !FLAC__HAS_OGG - if(treat_as_ogg) { - flac__utils_printf(stderr, 1, "%s: Ogg support has not been built into this copy of flac\n", infilename); - flac__foreign_metadata_delete(foreign_metadata); - return 1; - } -#endif - - if(!flac__utils_parse_skip_until_specification(option_values.skip_specification, &decode_options.skip_specification) || decode_options.skip_specification.is_relative) { - flac__foreign_metadata_delete(foreign_metadata); - return usage_error("ERROR: invalid value for --skip\n"); - } - - if(!flac__utils_parse_skip_until_specification(option_values.until_specification, &decode_options.until_specification)) { /*@@@ more checks: no + without --skip, no - unless known total_samples_to_{en,de}code */ - flac__foreign_metadata_delete(foreign_metadata); - return usage_error("ERROR: invalid value for --until\n"); - } - /* if there is no "--until" we want to default to "--until=-0" */ - if(0 == option_values.until_specification) - decode_options.until_specification.is_relative = true; - - if(option_values.cue_specification) { - if(!flac__utils_parse_cue_specification(option_values.cue_specification, &decode_options.cue_specification)) { - flac__foreign_metadata_delete(foreign_metadata); - return usage_error("ERROR: invalid value for --cue\n"); - } - decode_options.has_cue_specification = true; - } - else - decode_options.has_cue_specification = false; - - decode_options.treat_warnings_as_errors = option_values.treat_warnings_as_errors; - decode_options.continue_through_decode_errors = option_values.continue_through_decode_errors; - decode_options.relaxed_foreign_metadata_handling = option_values.keep_foreign_metadata_if_present; - decode_options.replaygain_synthesis_spec = option_values.replaygain_synthesis_spec; - decode_options.force_subformat = output_subformat; -#if FLAC__HAS_OGG - decode_options.is_ogg = treat_as_ogg; - decode_options.use_first_serial_number = !option_values.has_serial_number; - decode_options.serial_number = option_values.serial_number; -#endif - decode_options.channel_map_none = option_values.channel_map_none; - decode_options.format = output_format; - - if(output_format == FORMAT_RAW) { - decode_options.format_options.raw.is_big_endian = option_values.format_is_big_endian; - decode_options.format_options.raw.is_unsigned_samples = option_values.format_is_unsigned_samples; - - retval = flac__decode_file(infilename, option_values.test_only? 0 : outfilename, option_values.analyze, option_values.aopts, decode_options); - } - else { - decode_options.format_options.iff.foreign_metadata = foreign_metadata; - - retval = flac__decode_file(infilename, option_values.test_only? 0 : outfilename, option_values.analyze, option_values.aopts, decode_options); - - } - - if(foreign_metadata) - flac__foreign_metadata_delete(foreign_metadata); - - if(retval == 0 && strcmp(infilename, "-")) { - if(option_values.preserve_modtime && strcmp(outfilename, "-")) - grabbag__file_copy_metadata(infilename, outfilename); - if(option_values.delete_input && !option_values.test_only && !option_values.analyze) - flac_unlink(infilename); - } - - return retval; -} - -const char *get_encoded_outfilename(const char *infilename) -{ - const char *suffix = (option_values.use_ogg? ".oga" : ".flac"); - const char *p; - - if(option_values.output_prefix) { - p = grabbag__file_get_basename(infilename); - } - else { - p = infilename; - } - - return get_outfilename(p, suffix); -} - -const char *get_decoded_outfilename(const char *infilename, const FileFormat format) -{ - const char *suffix; - const char *p; - - if(option_values.output_prefix) { - p = grabbag__file_get_basename(infilename); - } - else { - p = infilename; - } - - if(option_values.analyze) { - suffix = ".ana"; - } - else if(format == FORMAT_RAW) { - suffix = ".raw"; - } - else if(format == FORMAT_AIFF) { - suffix = ".aiff"; - } - else if(format == FORMAT_AIFF_C) { - suffix = ".aifc"; - } - else if(format == FORMAT_RF64) { - suffix = ".rf64"; - } - else if(format == FORMAT_WAVE64) { - suffix = ".w64"; - } - else { - suffix = ".wav"; - } - return get_outfilename(p, suffix); -} - -const char *get_outfilename(const char *infilename, const char *suffix) -{ - if(0 == option_values.cmdline_forced_outfilename) { - static char buffer[4096]; - - if(0 == strcmp(infilename, "-") || option_values.force_to_stdout) { - buffer [0] = '-'; - buffer [1] = 0; - } - else { - char *p; - if (flac__strlcpy(buffer, option_values.output_prefix? option_values.output_prefix : "", sizeof buffer) >= sizeof buffer) - return 0; - if (flac__strlcat(buffer, infilename, sizeof buffer) >= sizeof buffer) - return 0; - /* the . must come after any / to avoid problems with, e.g. "some.directory/extensionless-filename" */ - if(0 == (p = strrchr(buffer, '.')) || strchr(p, '/')) { - if (flac__strlcat(buffer, suffix, sizeof buffer) >= sizeof buffer) - return 0; - } - else { - *p = '\0'; - if (flac__strlcat(buffer, suffix, sizeof buffer) >= sizeof buffer) - return 0; - } - } - return buffer; - } - else - return option_values.cmdline_forced_outfilename; -} - -void die(const char *message) -{ - FLAC__ASSERT(0 != message); - flac__utils_printf(stderr, 1, "ERROR: %s\n", message); - exit(1); -} - -int conditional_fclose(FILE *f) -{ - if(f == 0 || f == stdin || f == stdout) - return 0; - else - return fclose(f); -} - -char *local_strdup(const char *source) -{ - char *ret; - FLAC__ASSERT(0 != source); - if(0 == (ret = strdup(source))) - die("out of memory during strdup()"); - return ret; -} diff --git a/Engine/lib/flac/src/flac/utils.c b/Engine/lib/flac/src/flac/utils.c deleted file mode 100644 index 446150d41..000000000 --- a/Engine/lib/flac/src/flac/utils.c +++ /dev/null @@ -1,439 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include "utils.h" -#include "FLAC/assert.h" -#include "FLAC/metadata.h" -#include "share/compat.h" -#ifndef _WIN32 -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE -#endif -#include -#ifdef HAVE_TERMIOS_H -# include -#endif -#ifdef HAVE_SYS_IOCTL_H -# include -#endif -#endif - -const char *CHANNEL_MASK_TAG = "WAVEFORMATEXTENSIBLE_CHANNEL_MASK"; - -int flac__utils_verbosity_ = 2; - -static FLAC__bool local__parse_uint64_(const char *s, FLAC__uint64 *value) -{ - FLAC__uint64 ret = 0; - char c; - - if(*s == '\0') - return false; - - while('\0' != (c = *s++)) - if(c >= '0' && c <= '9') { - if(ret > UINT64_MAX / 10) /* check for overflow */ - return false; - else if(ret == UINT64_MAX / 10) { - FLAC__uint64 tmp = ret; - ret = ret * 10 + (c - '0'); - if(ret < tmp) - return false; - } - else - ret = ret * 10 + (c - '0'); - } - else - return false; - - *value = ret; - return true; -} - -static FLAC__bool local__parse_timecode_(const char *s, double *value) -{ - double ret; - uint32_t i; - char c, *endptr; - - /* parse [0-9][0-9]*: */ - c = *s++; - if(c >= '0' && c <= '9') - i = (c - '0'); - else - return false; - while(':' != (c = *s++)) { - if(c >= '0' && c <= '9') - i = i * 10 + (c - '0'); - else - return false; - } - ret = (double)i * 60.; - - /* parse [0-9]*[.,]?[0-9]* i.e. a sign-less rational number (. or , OK for fractional seconds, to support different locales) */ - if(strspn(s, "1234567890.,") != strlen(s)) - return false; - ret += strtod(s, &endptr); - if (endptr == s || *endptr) - return false; - - *value = ret; - return true; -} - -static FLAC__bool local__parse_cue_(const char *s, const char *end, uint32_t *track, uint32_t *indx) -{ - FLAC__bool got_track = false, got_index = false; - uint32_t t = 0, i = 0; - char c; - - while(end? s < end : *s != '\0') { - c = *s++; - if(c >= '0' && c <= '9') { - t = t * 10 + (c - '0'); - got_track = true; - } - else if(c == '.') - break; - else - return false; - } - while(end? s < end : *s != '\0') { - c = *s++; - if(c >= '0' && c <= '9') { - i = i * 10 + (c - '0'); - got_index = true; - } - else - return false; - } - *track = t; - *indx = i; - return got_track && got_index; -} - -/* - * this only works with sorted cuesheets (the spec strongly recommends but - * does not require sorted cuesheets). but if it's not sorted, picking a - * nearest cue point has no significance. - */ -static FLAC__uint64 local__find_closest_cue_(const FLAC__StreamMetadata_CueSheet *cuesheet, uint32_t track, uint32_t indx, FLAC__uint64 total_samples, FLAC__bool look_forward) -{ - int t, i; - if(look_forward) { - for(t = 0; t < (int)cuesheet->num_tracks; t++) - for(i = 0; i < (int)cuesheet->tracks[t].num_indices; i++) - if(cuesheet->tracks[t].number > track || (cuesheet->tracks[t].number == track && cuesheet->tracks[t].indices[i].number >= indx)) - return cuesheet->tracks[t].offset + cuesheet->tracks[t].indices[i].offset; - return total_samples; - } - else { - for(t = (int)cuesheet->num_tracks - 1; t >= 0; t--) - for(i = (int)cuesheet->tracks[t].num_indices - 1; i >= 0; i--) - if(cuesheet->tracks[t].number < track || (cuesheet->tracks[t].number == track && cuesheet->tracks[t].indices[i].number <= indx)) - return cuesheet->tracks[t].offset + cuesheet->tracks[t].indices[i].offset; - return 0; - } -} - -void flac__utils_printf(FILE *stream, int level, const char *format, ...) -{ - if(flac__utils_verbosity_ >= level) { - va_list args; - - FLAC__ASSERT(0 != format); - - va_start(args, format); - - (void) flac_vfprintf(stream, format, args); - - va_end(args); - -#ifdef _MSC_VER - if(stream == stderr) - fflush(stream); /* for some reason stderr is buffered in at least some if not all MSC libs */ -#endif - } -} - -/* variables and functions for console status output */ -static FLAC__bool is_name_printed; -static int stats_char_count = 0; -static int console_width; -static int console_chars_left; - -int get_console_width(void) -{ - int width = 0; -#if defined _WIN32 - width = win_get_console_width(); -#elif defined __EMX__ - int s[2]; - _scrsize (s); - width = s[0]; -#elif defined TIOCGWINSZ - struct winsize w; - if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1) - width = w.ws_col; -#endif - if (width <= 0) - width = 80; - return width; -} - -size_t strlen_console(const char *text) -{ -#ifdef _WIN32 - return strlen_utf8(text); -#elif defined(__DJGPP__) /* workaround for DJGPP missing wcswidth() */ - return strlen(text); -#else - size_t len; - wchar_t *wtmp; - - len = strlen(text)+1; - wtmp = (wchar_t *)malloc(len*sizeof(wchar_t)); - if (wtmp == NULL) return len-1; - mbstowcs(wtmp, text, len); - len = wcswidth(wtmp, len); - free(wtmp); - - return len; -#endif -} - -void stats_new_file(void) -{ - is_name_printed = false; -} - -void stats_clear(void) -{ - while (stats_char_count > 0 && stats_char_count--) - fprintf(stderr, "\b"); -} - -void stats_print_name(int level, const char *name) -{ - int len; - - if (flac__utils_verbosity_ >= level) { - stats_clear(); - if(is_name_printed) return; - - console_width = get_console_width(); - len = strlen_console(name)+2; - console_chars_left = console_width - (len % console_width); - flac_fprintf(stderr, "%s: ", name); - is_name_printed = true; - } -} - -void stats_print_info(int level, const char *format, ...) -{ - char tmp[80]; - int len, clear_len; - - if (flac__utils_verbosity_ >= level) { - va_list args; - va_start(args, format); - len = flac_vsnprintf(tmp, sizeof(tmp), format, args); - va_end(args); - stats_clear(); - if (len >= console_chars_left) { - clear_len = console_chars_left; - while (clear_len > 0 && clear_len--) fprintf(stderr, " "); - fprintf(stderr, "\n"); - console_chars_left = console_width; - } - stats_char_count = fprintf(stderr, "%s", tmp); - fflush(stderr); - } -} - -#ifdef FLAC__VALGRIND_TESTING -size_t flac__utils_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - size_t ret = fwrite(ptr, size, nmemb, stream); - if(!ferror(stream)) - fflush(stream); - return ret; -} -#endif - -FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__SkipUntilSpecification *spec) -{ - FLAC__uint64 val; - FLAC__bool is_negative = false; - - FLAC__ASSERT(0 != spec); - - spec->is_relative = false; - spec->value_is_samples = true; - spec->value.samples = 0; - - if(0 != s) { - if(s[0] == '-') { - is_negative = true; - spec->is_relative = true; - s++; - } - else if(s[0] == '+') { - spec->is_relative = true; - s++; - } - - if(local__parse_uint64_(s, &val)) { - spec->value_is_samples = true; - if(val > INT64_MAX) - return false; - spec->value.samples = (FLAC__int64)val; - if(is_negative) - spec->value.samples = -(spec->value.samples); - } - else { - double d; - if(!local__parse_timecode_(s, &d)) - return false; - spec->value_is_samples = false; - spec->value.seconds = d; - if(is_negative) - spec->value.seconds = -(spec->value.seconds); - } - } - - return true; -} - -FLAC__bool flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, uint32_t sample_rate) -{ - FLAC__ASSERT(0 != spec); - if(!spec->value_is_samples) { - double samples = spec->value.seconds * (double)sample_rate; - if(samples >= (double)INT64_MAX || samples <= (double)INT64_MIN) - return false; - spec->value.samples = (FLAC__int64)(samples); - spec->value_is_samples = true; - } - return true; -} - -FLAC__bool flac__utils_parse_cue_specification(const char *s, utils__CueSpecification *spec) -{ - const char *start = s, *end = 0; - - FLAC__ASSERT(0 != spec); - - spec->has_start_point = spec->has_end_point = false; - - s = strchr(s, '-'); - - if(0 != s) { - if(s == start) - start = 0; - end = s+1; - if(*end == '\0') - end = 0; - } - - if(start) { - if(!local__parse_cue_(start, s, &spec->start_track, &spec->start_index)) - return false; - spec->has_start_point = true; - } - - if(end) { - if(!local__parse_cue_(end, 0, &spec->end_track, &spec->end_index)) - return false; - spec->has_end_point = true; - } - - return true; -} - -void flac__utils_canonicalize_cue_specification(const utils__CueSpecification *cue_spec, const FLAC__StreamMetadata_CueSheet *cuesheet, FLAC__uint64 total_samples, utils__SkipUntilSpecification *skip_spec, utils__SkipUntilSpecification *until_spec) -{ - FLAC__ASSERT(0 != cue_spec); - FLAC__ASSERT(0 != cuesheet); - FLAC__ASSERT(0 != total_samples); - FLAC__ASSERT(0 != skip_spec); - FLAC__ASSERT(0 != until_spec); - - skip_spec->is_relative = false; - skip_spec->value_is_samples = true; - - until_spec->is_relative = false; - until_spec->value_is_samples = true; - - if(cue_spec->has_start_point) - skip_spec->value.samples = local__find_closest_cue_(cuesheet, cue_spec->start_track, cue_spec->start_index, total_samples, /*look_forward=*/false); - else - skip_spec->value.samples = 0; - - if(cue_spec->has_end_point) - until_spec->value.samples = local__find_closest_cue_(cuesheet, cue_spec->end_track, cue_spec->end_index, total_samples, /*look_forward=*/true); - else - until_spec->value.samples = total_samples; -} - -FLAC__bool flac__utils_set_channel_mask_tag(FLAC__StreamMetadata *object, FLAC__uint32 channel_mask) -{ - FLAC__StreamMetadata_VorbisComment_Entry entry = { 0, 0 }; - char tag[128]; - - FLAC__ASSERT(object); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(strlen(CHANNEL_MASK_TAG)+1+2+16+1 <= sizeof(tag)); /* +1 for =, +2 for 0x, +16 for digits, +1 for NUL */ - entry.entry = (FLAC__byte*)tag; - if((entry.length = flac_snprintf(tag, sizeof(tag), "%s=0x%04X", CHANNEL_MASK_TAG, (uint32_t)channel_mask)) >= sizeof(tag)) - return false; - if(!FLAC__metadata_object_vorbiscomment_replace_comment(object, entry, /*all=*/true, /*copy=*/true)) - return false; - return true; -} - -FLAC__bool flac__utils_get_channel_mask_tag(const FLAC__StreamMetadata *object, FLAC__uint32 *channel_mask) -{ - int offset; - uint32_t val; - char *p; - FLAC__ASSERT(object); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - if(0 > (offset = FLAC__metadata_object_vorbiscomment_find_entry_from(object, /*offset=*/0, CHANNEL_MASK_TAG))) - return false; - if(object->data.vorbis_comment.comments[offset].length < strlen(CHANNEL_MASK_TAG)+4) - return false; - if(0 == (p = strchr((const char *)object->data.vorbis_comment.comments[offset].entry, '='))) /* should never happen, but just in case */ - return false; - if(FLAC__STRNCASECMP(p, "=0x", 3)) - return false; - if(sscanf(p+3, "%x", &val) != 1) - return false; - *channel_mask = val; - return true; -} diff --git a/Engine/lib/flac/src/flac/utils.h b/Engine/lib/flac/src/flac/utils.h deleted file mode 100644 index 931b4a6e5..000000000 --- a/Engine/lib/flac/src/flac/utils.h +++ /dev/null @@ -1,77 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef flac__utils_h -#define flac__utils_h - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/ordinals.h" -#include "FLAC/format.h" /* for FLAC__StreamMetadata_CueSheet */ -#include /* for FILE */ - -typedef enum { FORMAT_RAW, FORMAT_WAVE, FORMAT_WAVE64, FORMAT_RF64, FORMAT_AIFF, FORMAT_AIFF_C, FORMAT_FLAC, FORMAT_OGGFLAC } FileFormat; -static const char * const FileFormatString[] = { " raw", " WAVE", " Wave64", "n RF64", "n AIFF", "n AIFF-C", " FLAC", "n Ogg FLAC" }; - -typedef enum { SUBFORMAT_UNSPECIFIED = 0, SUBFORMAT_WAVE_PCM, SUBFORMAT_WAVE_EXTENSIBLE, SUBFORMAT_AIFF_C_NONE, SUBFORMAT_AIFF_C_SOWT } FileSubFormat; - - -typedef struct { - FLAC__bool is_relative; /* i.e. specification string started with + or - */ - FLAC__bool value_is_samples; - union { - double seconds; - FLAC__int64 samples; - } value; -} utils__SkipUntilSpecification; - -typedef struct { - FLAC__bool has_start_point, has_end_point; - unsigned start_track, start_index; - unsigned end_track, end_index; -} utils__CueSpecification; - -#ifdef FLAC__VALGRIND_TESTING -size_t flac__utils_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); -#else -#define flac__utils_fwrite fwrite -#endif - -extern int flac__utils_verbosity_; -void flac__utils_printf(FILE *stream, int level, const char *format, ...); - -int get_console_width(void); -size_t strlen_console(const char *text); -void stats_new_file(void); -void stats_clear(void); -void stats_print_name(int level, const char *name); -void stats_print_info(int level, const char *format, ...); - -FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__SkipUntilSpecification *spec); -FLAC__bool flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, uint32_t sample_rate); - -FLAC__bool flac__utils_parse_cue_specification(const char *s, utils__CueSpecification *spec); -void flac__utils_canonicalize_cue_specification(const utils__CueSpecification *cue_spec, const FLAC__StreamMetadata_CueSheet *cuesheet, FLAC__uint64 total_samples, utils__SkipUntilSpecification *skip_spec, utils__SkipUntilSpecification *until_spec); - -FLAC__bool flac__utils_set_channel_mask_tag(FLAC__StreamMetadata *object, FLAC__uint32 channel_mask); -FLAC__bool flac__utils_get_channel_mask_tag(const FLAC__StreamMetadata *object, FLAC__uint32 *channel_mask); - -#endif diff --git a/Engine/lib/flac/src/flac/version.rc b/Engine/lib/flac/src/flac/version.rc deleted file mode 100644 index 00842b924..000000000 --- a/Engine/lib/flac/src/flac/version.rc +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include "config.h" - -#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) -# ifdef GIT_COMMIT_TAG -# define VERSIONSTRING GIT_COMMIT_TAG -# else -# define VERSIONSTRING "git-" GIT_COMMIT_HASH -# endif -#else -# define VERSIONSTRING PACKAGE_VERSION -#endif - -#define xstr(s) str(s) -#define str(s) #s - -VS_VERSION_INFO VERSIONINFO -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -FILEFLAGS 0 -FILEOS VOS__WINDOWS32 -FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "flac command line tool for Windows" - VALUE "ProductName", "Free Lossless Audio Codec" - VALUE "ProductVersion", VERSIONSTRING - VALUE "CompanyName", "Xiph.Org" - VALUE "LegalCopyright", "2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/Engine/lib/flac/src/flac/vorbiscomment.c b/Engine/lib/flac/src/flac/vorbiscomment.c deleted file mode 100644 index 3941ec240..000000000 --- a/Engine/lib/flac/src/flac/vorbiscomment.c +++ /dev/null @@ -1,254 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "vorbiscomment.h" -#include "FLAC/assert.h" -#include "FLAC/metadata.h" -#include "share/grabbag.h" /* for grabbag__file_get_filesize() */ -#include "share/utf8.h" -#include -#include -#include -#include -#include "share/compat.h" - - -/* - * This struct and the following 4 static functions are copied from - * ../metaflac/. Maybe someday there will be a convenience - * library for Vorbis comment parsing. - */ -typedef struct { - char *field; /* the whole field as passed on the command line, i.e. "NAME=VALUE" */ - char *field_name; - /* according to the vorbis spec, field values can contain \0 so simple C strings are not enough here */ - uint32_t field_value_length; - char *field_value; - FLAC__bool field_value_from_file; /* true if field_value holds a filename for the value, false for plain value */ -} Argument_VcField; - -static void die(const char *message) -{ - FLAC__ASSERT(0 != message); - fprintf(stderr, "ERROR: %s\n", message); - exit(1); -} - -static char *local_strdup(const char *source) -{ - char *ret; - FLAC__ASSERT(0 != source); - if(0 == (ret = strdup(source))) - die("out of memory during strdup()"); - return ret; -} - -static FLAC__bool parse_vorbis_comment_field(const char *field_ref, char **field, char **name, char **value, uint32_t *length, const char **violation) -{ - static const char * const violations[] = { - "field name contains invalid character", - "field contains no '=' character" - }; - - char *p, *q, *s; - - if(0 != field) - *field = local_strdup(field_ref); - - s = local_strdup(field_ref); - - if(0 == (p = strchr(s, '='))) { - free(s); - *violation = violations[1]; - return false; - } - *p++ = '\0'; - - for(q = s; *q; q++) { - if(*q < 0x20 || *q > 0x7d || *q == 0x3d) { - free(s); - *violation = violations[0]; - return false; - } - } - - *name = local_strdup(s); - *value = local_strdup(p); - *length = strlen(p); - - free(s); - return true; -} - -/* slight modification: no 'filename' arg, and errors are passed back in 'violation' instead of printed to stderr */ -static FLAC__bool set_vc_field(FLAC__StreamMetadata *block, const Argument_VcField *field, FLAC__bool *needs_write, FLAC__bool raw, const char **violation) -{ - FLAC__StreamMetadata_VorbisComment_Entry entry; - char *converted = NULL; - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(0 != field); - FLAC__ASSERT(0 != needs_write); - - if(field->field_value_from_file) { - /* read the file into 'data' */ - FILE *f = 0; - char *data = 0; - const FLAC__off_t size = grabbag__file_get_filesize(field->field_value); - if(size < 0) { - *violation = "can't open file for tag value"; - return false; - } - if(size >= 0x100000) { /* magic arbitrary limit, actual format limit is near 16MB */ - *violation = "file for tag value is too large"; - return false; - } - if(0 == (data = malloc(size+1))) - die("out of memory allocating tag value"); - data[size] = '\0'; - if(0 == (f = flac_fopen(field->field_value, "rb")) || fread(data, 1, size, f) != (size_t)size) { - free(data); - if(f) - fclose(f); - *violation = "error while reading file for tag value"; - return false; - } - fclose(f); - if(strlen(data) != (size_t)size) { - free(data); - *violation = "file for tag value has embedded NULs"; - return false; - } - - /* move 'data' into 'converted', converting to UTF-8 if necessary */ - if(raw) { - converted = data; - } - else if(utf8_encode(data, &converted) >= 0) { - free(data); - } - else { - free(data); - *violation = "error converting file contents to UTF-8 for tag value"; - return false; - } - - /* create and entry and append it */ - if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, field->field_name, converted)) { - free(converted); - *violation = "file for tag value is not valid UTF-8"; - return false; - } - free(converted); - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) { - *violation = "memory allocation failure"; - return false; - } - - *needs_write = true; - return true; - } - else { - FLAC__bool needs_free = false; -#ifdef _WIN32 /* everything in UTF-8 already. Must not alter */ - entry.entry = (FLAC__byte *)field->field; -#else - if(raw) { - entry.entry = (FLAC__byte *)field->field; - } - else if(utf8_encode(field->field, &converted) >= 0) { - entry.entry = (FLAC__byte *)converted; - needs_free = true; - } - else { - *violation = "error converting comment to UTF-8"; - return false; - } -#endif - entry.length = strlen((const char *)entry.entry); - if(!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length)) { - if(needs_free) - free(converted); - /* - * our previous parsing has already established that the field - * name is OK, so it must be the field value - */ - *violation = "tag value is not valid UTF-8"; - return false; - } - - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) { - if(needs_free) - free(converted); - *violation = "memory allocation failure"; - return false; - } - - *needs_write = true; - if(needs_free) - free(converted); - return true; - } -} - -/* - * The rest of the code is novel - */ - -static void free_field(Argument_VcField *obj) -{ - if(0 != obj->field) - free(obj->field); - if(0 != obj->field_name) - free(obj->field_name); - if(0 != obj->field_value) - free(obj->field_value); -} - -FLAC__bool flac__vorbiscomment_add(FLAC__StreamMetadata *block, const char *comment, FLAC__bool value_from_file, FLAC__bool raw, const char **violation) -{ - Argument_VcField parsed; - FLAC__bool dummy; - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(0 != comment); - - memset(&parsed, 0, sizeof(parsed)); - - parsed.field_value_from_file = value_from_file; - if(!parse_vorbis_comment_field(comment, &(parsed.field), &(parsed.field_name), &(parsed.field_value), &(parsed.field_value_length), violation)) { - free_field(&parsed); - return false; - } - - if(parsed.field_value_length > 0 && !set_vc_field(block, &parsed, &dummy, raw, violation)) { - free_field(&parsed); - return false; - } - else { - free_field(&parsed); - return true; - } -} diff --git a/Engine/lib/flac/src/flac/vorbiscomment.h b/Engine/lib/flac/src/flac/vorbiscomment.h deleted file mode 100644 index a6dcb164b..000000000 --- a/Engine/lib/flac/src/flac/vorbiscomment.h +++ /dev/null @@ -1,27 +0,0 @@ -/* flac - Command-line FLAC encoder/decoder - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef flac__vorbiscomment_h -#define flac__vorbiscomment_h - -#include "FLAC/metadata.h" - -FLAC__bool flac__vorbiscomment_add(FLAC__StreamMetadata *block, const char *comment, FLAC__bool value_from_file, FLAC__bool raw, const char **violation); - -#endif diff --git a/Engine/lib/flac/src/libFLAC++/CMakeLists.txt b/Engine/lib/flac/src/libFLAC++/CMakeLists.txt deleted file mode 100644 index 3be43ba18..000000000 --- a/Engine/lib/flac/src/libFLAC++/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -add_library(FLAC++ - metadata.cpp - stream_decoder.cpp - stream_encoder.cpp - version.rc) -set_property(TARGET FLAC++ PROPERTY PROJECT_LABEL "libFLAC++") -target_compile_definitions(FLAC++ - PRIVATE $<$:FLACPP_API_EXPORTS> - PUBLIC $<$>:FLAC__NO_DLL>) -if(NOT WIN32) - target_compile_definitions(FLAC++ PRIVATE $<$:FLAC__USE_VISIBILITY_ATTR>) -endif() -target_include_directories(FLAC++ INTERFACE - "$" - "$") -target_link_libraries(FLAC++ PUBLIC FLAC) -if(BUILD_SHARED_LIBS) - set_target_properties(FLAC++ PROPERTIES - VERSION 10.0.1 - SOVERSION 10) - if(NOT WIN32) - set_target_properties(FLAC++ PROPERTIES CXX_VISIBILITY_PRESET hidden) - endif() -endif() - -add_library(FLAC::FLAC++ ALIAS FLAC++) - -install(TARGETS FLAC++ EXPORT targets - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") - -if(INSTALL_PKGCONFIG_MODULES) - set(prefix "${CMAKE_INSTALL_PREFIX}") - set(exec_prefix "${CMAKE_INSTALL_PREFIX}") - set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") - set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") - configure_file(flac++.pc.in flac++.pc @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac++.pc" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") -endif() diff --git a/Engine/lib/flac/src/libFLAC++/Makefile.am b/Engine/lib/flac/src/libFLAC++/Makefile.am deleted file mode 100644 index 0b2853b20..000000000 --- a/Engine/lib/flac/src/libFLAC++/Makefile.am +++ /dev/null @@ -1,68 +0,0 @@ -# libFLAC++ - Free Lossless Audio Codec library -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# 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 the Xiph.org Foundation nor the names of its -# 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 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. - -lib_LTLIBRARIES = libFLAC++.la -noinst_LTLIBRARIES = libFLAC++-static.la - -m4datadir = $(datadir)/aclocal -m4data_DATA = libFLAC++.m4 - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = flac++.pc -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -EXTRA_DIST = \ - CMakeLists.txt \ - flac++.pc.in \ - libFLAC++.m4 \ - version.rc - -libFLAC___sources = \ - metadata.cpp \ - stream_decoder.cpp \ - stream_encoder.cpp - -if OS_IS_WINDOWS -if HAVE_WINDRES -libFLAC___la_DEPENDENCIES = version.o -windows_resource_link = -Wl,version.o -endif -endif - -# see 'http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning' for numbering convention -libFLAC___la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 10:1:0 $(windows_resource_link) -libFLAC___la_LIBADD = ../libFLAC/libFLAC.la -libFLAC___la_SOURCES = $(libFLAC___sources) - -libFLAC___static_la_SOURCES = $(libFLAC___sources) -libFLAC___static_la_LIBADD = ../libFLAC/libFLAC-static.la - -.rc.o: - $(RC) $(AM_CPPFLAGS) $< $@ diff --git a/Engine/lib/flac/src/libFLAC++/flac++.pc.in b/Engine/lib/flac/src/libFLAC++/flac++.pc.in deleted file mode 100644 index f09c251a6..000000000 --- a/Engine/lib/flac/src/libFLAC++/flac++.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: FLAC++ -Description: Free Lossless Audio Codec Library (C++ API) -Version: @VERSION@ -Requires: flac -Libs: -L${libdir} -lFLAC++ -Cflags: -I${includedir} diff --git a/Engine/lib/flac/src/libFLAC++/libFLAC++.m4 b/Engine/lib/flac/src/libFLAC++/libFLAC++.m4 deleted file mode 100644 index e5e134505..000000000 --- a/Engine/lib/flac/src/libFLAC++/libFLAC++.m4 +++ /dev/null @@ -1,114 +0,0 @@ -# Configure paths for libFLAC++ -# "Inspired" by ogg.m4 -# Caller must first run AM_PATH_LIBFLAC - -dnl AM_PATH_LIBFLACPP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libFLAC++, and define LIBFLACPP_CFLAGS, LIBFLACPP_LIBS, LIBFLACPP_LIBDIR -dnl -AC_DEFUN([AM_PATH_LIBFLACPP], -[dnl -dnl Get the cflags and libraries -dnl -AC_ARG_WITH(libFLACPP,[ --with-libFLACPP=PFX Prefix where libFLAC++ is installed (optional)], libFLACPP_prefix="$withval", libFLACPP_prefix="") -AC_ARG_WITH(libFLACPP-libraries,[ --with-libFLACPP-libraries=DIR Directory where libFLAC++ library is installed (optional)], libFLACPP_libraries="$withval", libFLACPP_libraries="") -AC_ARG_WITH(libFLACPP-includes,[ --with-libFLACPP-includes=DIR Directory where libFLAC++ header files are installed (optional)], libFLACPP_includes="$withval", libFLACPP_includes="") -AC_ARG_ENABLE(libFLACPPtest, [ --disable-libFLACPPtest Do not try to compile and run a test libFLAC++ program],, enable_libFLACPPtest=yes) - - if test "x$libFLACPP_libraries" != "x" ; then - LIBFLACPP_LIBDIR="$libFLACPP_libraries" - elif test "x$libFLACPP_prefix" != "x" ; then - LIBFLACPP_LIBDIR="$libFLACPP_prefix/lib" - elif test "x$prefix" != "xNONE" ; then - LIBFLACPP_LIBDIR="$libdir" - fi - - LIBFLACPP_LIBS="-L$LIBFLACPP_LIBDIR -lFLAC++ $LIBFLAC_LIBS" - - if test "x$libFLACPP_includes" != "x" ; then - LIBFLACPP_CFLAGS="-I$libFLACPP_includes" - elif test "x$libFLACPP_prefix" != "x" ; then - LIBFLACPP_CFLAGS="-I$libFLACPP_prefix/include" - elif test "$prefix" != "xNONE"; then - LIBFLACPP_CFLAGS="" - fi - - LIBFLACPP_CFLAGS="$LIBFLACPP_CFLAGS $LIBFLAC_CFLAGS" - - AC_MSG_CHECKING(for libFLAC++) - no_libFLACPP="" - - - if test "x$enable_libFLACPPtest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_CXXFLAGS="$CXXFLAGS" - ac_save_LIBS="$LIBS" - ac_save_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" - CFLAGS="$CFLAGS $LIBFLACPP_CFLAGS" - CXXFLAGS="$CXXFLAGS $LIBFLACPP_CFLAGS" - LIBS="$LIBS $LIBFLACPP_LIBS" - LD_LIBRARY_PATH="$LIBFLACPP_LIBDIR:$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH" -dnl -dnl Now check if the installed libFLAC++ is sufficiently new. -dnl - rm -f conf.libFLAC++test - AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -#include -]],[[ - system("touch conf.libFLAC++test"); - return 0; -]])],[],[no_libFLACPP=yes],[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH" - fi - - if test "x$no_libFLACPP" = "x" ; then - AC_MSG_RESULT(yes) - ifelse([$1], , :, [$1]) - else - AC_MSG_RESULT(no) - if test -f conf.libFLAC++test ; then - : - else - echo "*** Could not run libFLAC++ test program, checking why..." - CFLAGS="$CFLAGS $LIBFLACPP_CFLAGS" - CXXFLAGS="$CXXFLAGS $LIBFLACPP_CFLAGS" - LIBS="$LIBS $LIBFLACPP_LIBS" - LD_LIBRARY_PATH="$LIBFLACPP_LIBDIR:$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH" - AC_TRY_LINK([ -#include -#include -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding libFLAC++ or finding the wrong" - echo "*** version of libFLAC++. If it is not finding libFLAC++, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occurred. This usually means libFLAC++ was incorrectly installed" - echo "*** or that you have moved libFLAC++ since it was installed. In the latter case, you" - echo "*** may want to edit the libFLAC++-config script: $LIBFLACPP_CONFIG" ]) - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH" - fi - LIBFLACPP_CFLAGS="" - LIBFLACPP_LIBDIR="" - LIBFLACPP_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(LIBFLACPP_CFLAGS) - AC_SUBST(LIBFLACPP_LIBDIR) - AC_SUBST(LIBFLACPP_LIBS) - rm -f conf.libFLAC++test -]) diff --git a/Engine/lib/flac/src/libFLAC++/metadata.cpp b/Engine/lib/flac/src/libFLAC++/metadata.cpp deleted file mode 100644 index beab11090..000000000 --- a/Engine/lib/flac/src/libFLAC++/metadata.cpp +++ /dev/null @@ -1,1745 +0,0 @@ -/* libFLAC++ - Free Lossless Audio Codec library - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#define __STDC_LIMIT_MACROS 1 /* otherwise SIZE_MAX is not defined for c++ */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "share/alloc.h" -#include "FLAC++/metadata.h" -#include "FLAC/assert.h" -#include // for malloc(), free() -#include // for memcpy() etc. - -#ifdef _MSC_VER -// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) -#pragma warning ( disable : 4800 ) -#endif - -namespace FLAC { - namespace Metadata { - - // local utility routines - - namespace local { - - Prototype *construct_block(::FLAC__StreamMetadata *object) - { - if (0 == object) - return 0; - - Prototype *ret = 0; - switch(object->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - ret = new StreamInfo(object, /*copy=*/false); - break; - case FLAC__METADATA_TYPE_PADDING: - ret = new Padding(object, /*copy=*/false); - break; - case FLAC__METADATA_TYPE_APPLICATION: - ret = new Application(object, /*copy=*/false); - break; - case FLAC__METADATA_TYPE_SEEKTABLE: - ret = new SeekTable(object, /*copy=*/false); - break; - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - ret = new VorbisComment(object, /*copy=*/false); - break; - case FLAC__METADATA_TYPE_CUESHEET: - ret = new CueSheet(object, /*copy=*/false); - break; - case FLAC__METADATA_TYPE_PICTURE: - ret = new Picture(object, /*copy=*/false); - break; - default: - ret = new Unknown(object, /*copy=*/false); - break; - } - return ret; - } - - } // namespace local - - FLACPP_API Prototype *clone(const Prototype *object) - { - FLAC__ASSERT(0 != object); - - const StreamInfo *streaminfo = dynamic_cast(object); - const Padding *padding = dynamic_cast(object); - const Application *application = dynamic_cast(object); - const SeekTable *seektable = dynamic_cast(object); - const VorbisComment *vorbiscomment = dynamic_cast(object); - const CueSheet *cuesheet = dynamic_cast(object); - const Picture *picture = dynamic_cast(object); - const Unknown *unknown = dynamic_cast(object); - - if(0 != streaminfo) - return new StreamInfo(*streaminfo); - if(0 != padding) - return new Padding(*padding); - if(0 != application) - return new Application(*application); - if(0 != seektable) - return new SeekTable(*seektable); - if(0 != vorbiscomment) - return new VorbisComment(*vorbiscomment); - if(0 != cuesheet) - return new CueSheet(*cuesheet); - if(0 != picture) - return new Picture(*picture); - if(0 != unknown) - return new Unknown(*unknown); - - FLAC__ASSERT(0); - return 0; - } - - // - // Prototype - // - - Prototype::Prototype(const Prototype &object): - object_(::FLAC__metadata_object_clone(object.object_)), - is_reference_(false) - { - FLAC__ASSERT(object.is_valid()); - } - - Prototype::Prototype(const ::FLAC__StreamMetadata &object): - object_(::FLAC__metadata_object_clone(&object)), - is_reference_(false) - { - } - - Prototype::Prototype(const ::FLAC__StreamMetadata *object): - object_(::FLAC__metadata_object_clone(object)), - is_reference_(false) - { - FLAC__ASSERT(0 != object); - } - - Prototype::Prototype(::FLAC__StreamMetadata *object, bool copy): - object_(copy? ::FLAC__metadata_object_clone(object) : object), - is_reference_(false) - { - FLAC__ASSERT(0 != object); - } - - Prototype::~Prototype() - { - clear(); - } - - void Prototype::clear() - { - if(0 != object_ && !is_reference_) - FLAC__metadata_object_delete(object_); - object_ = 0; - } - - Prototype &Prototype::operator=(const Prototype &object) - { - FLAC__ASSERT(object.is_valid()); - clear(); - is_reference_ = false; - object_ = ::FLAC__metadata_object_clone(object.object_); - return *this; - } - - Prototype &Prototype::operator=(const ::FLAC__StreamMetadata &object) - { - clear(); - is_reference_ = false; - object_ = ::FLAC__metadata_object_clone(&object); - return *this; - } - - Prototype &Prototype::operator=(const ::FLAC__StreamMetadata *object) - { - FLAC__ASSERT(0 != object); - clear(); - is_reference_ = false; - object_ = ::FLAC__metadata_object_clone(object); - return *this; - } - - Prototype &Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy) - { - FLAC__ASSERT(0 != object); - clear(); - object_ = (copy? ::FLAC__metadata_object_clone(object) : object); - is_reference_ = false; - return *this; - } - - bool Prototype::get_is_last() const - { - FLAC__ASSERT(is_valid()); - return static_cast(object_->is_last); - } - - FLAC__MetadataType Prototype::get_type() const - { - FLAC__ASSERT(is_valid()); - return object_->type; - } - - uint32_t Prototype::get_length() const - { - FLAC__ASSERT(is_valid()); - return object_->length; - } - - void Prototype::set_is_last(bool value) - { - FLAC__ASSERT(is_valid()); - object_->is_last = value; - } - - - // - // StreamInfo - // - - StreamInfo::StreamInfo(): - Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_STREAMINFO), /*copy=*/false) - { } - - StreamInfo::~StreamInfo() - { } - - uint32_t StreamInfo::get_min_blocksize() const - { - FLAC__ASSERT(is_valid()); - return object_->data.stream_info.min_blocksize; - } - - uint32_t StreamInfo::get_max_blocksize() const - { - FLAC__ASSERT(is_valid()); - return object_->data.stream_info.max_blocksize; - } - - uint32_t StreamInfo::get_min_framesize() const - { - FLAC__ASSERT(is_valid()); - return object_->data.stream_info.min_framesize; - } - - uint32_t StreamInfo::get_max_framesize() const - { - FLAC__ASSERT(is_valid()); - return object_->data.stream_info.max_framesize; - } - - uint32_t StreamInfo::get_sample_rate() const - { - FLAC__ASSERT(is_valid()); - return object_->data.stream_info.sample_rate; - } - - uint32_t StreamInfo::get_channels() const - { - FLAC__ASSERT(is_valid()); - return object_->data.stream_info.channels; - } - - uint32_t StreamInfo::get_bits_per_sample() const - { - FLAC__ASSERT(is_valid()); - return object_->data.stream_info.bits_per_sample; - } - - FLAC__uint64 StreamInfo::get_total_samples() const - { - FLAC__ASSERT(is_valid()); - return object_->data.stream_info.total_samples; - } - - const FLAC__byte *StreamInfo::get_md5sum() const - { - FLAC__ASSERT(is_valid()); - return object_->data.stream_info.md5sum; - } - - void StreamInfo::set_min_blocksize(uint32_t value) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(value >= FLAC__MIN_BLOCK_SIZE); - FLAC__ASSERT(value <= FLAC__MAX_BLOCK_SIZE); - object_->data.stream_info.min_blocksize = value; - } - - void StreamInfo::set_max_blocksize(uint32_t value) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(value >= FLAC__MIN_BLOCK_SIZE); - FLAC__ASSERT(value <= FLAC__MAX_BLOCK_SIZE); - object_->data.stream_info.max_blocksize = value; - } - - void StreamInfo::set_min_framesize(uint32_t value) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(value < (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN)); - object_->data.stream_info.min_framesize = value; - } - - void StreamInfo::set_max_framesize(uint32_t value) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(value < (1u << FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN)); - object_->data.stream_info.max_framesize = value; - } - - void StreamInfo::set_sample_rate(uint32_t value) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(FLAC__format_sample_rate_is_valid(value)); - object_->data.stream_info.sample_rate = value; - } - - void StreamInfo::set_channels(uint32_t value) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(value > 0); - FLAC__ASSERT(value <= FLAC__MAX_CHANNELS); - object_->data.stream_info.channels = value; - } - - void StreamInfo::set_bits_per_sample(uint32_t value) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(value >= FLAC__MIN_BITS_PER_SAMPLE); - FLAC__ASSERT(value <= FLAC__MAX_BITS_PER_SAMPLE); - object_->data.stream_info.bits_per_sample = value; - } - - void StreamInfo::set_total_samples(FLAC__uint64 value) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(value < (((FLAC__uint64)1) << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)); - object_->data.stream_info.total_samples = value; - } - - void StreamInfo::set_md5sum(const FLAC__byte value[16]) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(0 != value); - std::memcpy(object_->data.stream_info.md5sum, value, 16); - } - - - // - // Padding - // - - Padding::Padding(): - Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING), /*copy=*/false) - { } - - Padding::Padding(uint32_t length): - Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING), /*copy=*/false) - { - set_length(length); - } - - Padding::~Padding() - { } - - void Padding::set_length(uint32_t length) - { - FLAC__ASSERT(is_valid()); - object_->length = length; - } - - - // - // Application - // - - Application::Application(): - Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), /*copy=*/false) - { } - - Application::~Application() - { } - - const FLAC__byte *Application::get_id() const - { - FLAC__ASSERT(is_valid()); - return object_->data.application.id; - } - - const FLAC__byte *Application::get_data() const - { - FLAC__ASSERT(is_valid()); - return object_->data.application.data; - } - - void Application::set_id(const FLAC__byte value[4]) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(0 != value); - std::memcpy(object_->data.application.id, value, 4); - } - - bool Application::set_data(const FLAC__byte *data, uint32_t length) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_application_set_data(object_, const_cast(data), length, true)); - } - - bool Application::set_data(FLAC__byte *data, uint32_t length, bool copy) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_application_set_data(object_, data, length, copy)); - } - - - // - // SeekTable - // - - SeekTable::SeekTable(): - Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE), /*copy=*/false) - { } - - SeekTable::~SeekTable() - { } - - uint32_t SeekTable::get_num_points() const - { - FLAC__ASSERT(is_valid()); - return object_->data.seek_table.num_points; - } - - ::FLAC__StreamMetadata_SeekPoint SeekTable::get_point(uint32_t indx) const - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(indx < object_->data.seek_table.num_points); - return object_->data.seek_table.points[indx]; - } - - bool SeekTable::resize_points(uint32_t new_num_points) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_seektable_resize_points(object_, new_num_points)); - } - - void SeekTable::set_point(uint32_t indx, const ::FLAC__StreamMetadata_SeekPoint &point) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(indx < object_->data.seek_table.num_points); - ::FLAC__metadata_object_seektable_set_point(object_, indx, point); - } - - bool SeekTable::insert_point(uint32_t indx, const ::FLAC__StreamMetadata_SeekPoint &point) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(indx <= object_->data.seek_table.num_points); - return static_cast(::FLAC__metadata_object_seektable_insert_point(object_, indx, point)); - } - - bool SeekTable::delete_point(uint32_t indx) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(indx < object_->data.seek_table.num_points); - return static_cast(::FLAC__metadata_object_seektable_delete_point(object_, indx)); - } - - bool SeekTable::is_legal() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_seektable_is_legal(object_)); - } - - bool SeekTable::template_append_placeholders(uint32_t num) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_seektable_template_append_placeholders(object_, num)); - } - - bool SeekTable::template_append_point(FLAC__uint64 sample_number) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_seektable_template_append_point(object_, sample_number)); - } - - bool SeekTable::template_append_points(FLAC__uint64 sample_numbers[], uint32_t num) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_seektable_template_append_points(object_, sample_numbers, num)); - } - - bool SeekTable::template_append_spaced_points(uint32_t num, FLAC__uint64 total_samples) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_seektable_template_append_spaced_points(object_, num, total_samples)); - } - - bool SeekTable::template_append_spaced_points_by_samples(uint32_t samples, FLAC__uint64 total_samples) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(object_, samples, total_samples)); - } - - bool SeekTable::template_sort(bool compact) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_seektable_template_sort(object_, compact)); - } - - - // - // VorbisComment::Entry - // - - VorbisComment::Entry::Entry() : - is_valid_(true), - entry_(), - field_name_(0), - field_name_length_(0), - field_value_(0), - field_value_length_(0) - { - zero(); - } - - VorbisComment::Entry::Entry(const char *field, uint32_t field_length) : - is_valid_(true), - entry_(), - field_name_(0), - field_name_length_(0), - field_value_(0), - field_value_length_(0) - { - zero(); - construct(field, field_length); - } - - VorbisComment::Entry::Entry(const char *field) : - is_valid_(true), - entry_(), - field_name_(0), - field_name_length_(0), - field_value_(0), - field_value_length_(0) - { - zero(); - construct(field); - } - - VorbisComment::Entry::Entry(const char *field_name, const char *field_value, uint32_t field_value_length) : - is_valid_(true), - entry_(), - field_name_(0), - field_name_length_(0), - field_value_(0), - field_value_length_(0) - { - zero(); - construct(field_name, field_value, field_value_length); - } - - VorbisComment::Entry::Entry(const char *field_name, const char *field_value) : - is_valid_(true), - entry_(), - field_name_(0), - field_name_length_(0), - field_value_(0), - field_value_length_(0) - { - zero(); - construct(field_name, field_value); - } - - VorbisComment::Entry::Entry(const Entry &entry) : - is_valid_(true), - entry_(), - field_name_(0), - field_name_length_(0), - field_value_(0), - field_value_length_(0) - { - FLAC__ASSERT(entry.is_valid()); - zero(); - construct(reinterpret_cast(entry.entry_.entry), entry.entry_.length); - } - - VorbisComment::Entry &VorbisComment::Entry::operator=(const Entry &entry) - { - FLAC__ASSERT(entry.is_valid()); - clear(); - construct(reinterpret_cast(entry.entry_.entry), entry.entry_.length); - return *this; - } - - VorbisComment::Entry::~Entry() - { - clear(); - } - - bool VorbisComment::Entry::is_valid() const - { - return is_valid_; - } - - uint32_t VorbisComment::Entry::get_field_length() const - { - FLAC__ASSERT(is_valid()); - return entry_.length; - } - - uint32_t VorbisComment::Entry::get_field_name_length() const - { - FLAC__ASSERT(is_valid()); - return field_name_length_; - } - - uint32_t VorbisComment::Entry::get_field_value_length() const - { - FLAC__ASSERT(is_valid()); - return field_value_length_; - } - - ::FLAC__StreamMetadata_VorbisComment_Entry VorbisComment::Entry::get_entry() const - { - FLAC__ASSERT(is_valid()); - return entry_; - } - - const char *VorbisComment::Entry::get_field() const - { - FLAC__ASSERT(is_valid()); - return reinterpret_cast(entry_.entry); - } - - const char *VorbisComment::Entry::get_field_name() const - { - FLAC__ASSERT(is_valid()); - return field_name_; - } - - const char *VorbisComment::Entry::get_field_value() const - { - FLAC__ASSERT(is_valid()); - return field_value_; - } - - bool VorbisComment::Entry::set_field(const char *field, uint32_t field_length) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(0 != field); - - if(!::FLAC__format_vorbiscomment_entry_is_legal(reinterpret_cast(field), field_length)) - return is_valid_ = false; - - clear_entry(); - - if(0 == (entry_.entry = static_cast(safe_malloc_add_2op_(field_length, /*+*/1)))) { - is_valid_ = false; - } - else { - entry_.length = field_length; - std::memcpy(entry_.entry, field, field_length); - entry_.entry[field_length] = '\0'; - (void) parse_field(); - } - - return is_valid_; - } - - bool VorbisComment::Entry::set_field(const char *field) - { - return set_field(field, std::strlen(field)); - } - - bool VorbisComment::Entry::set_field_name(const char *field_name) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(0 != field_name); - - if(!::FLAC__format_vorbiscomment_entry_name_is_legal(field_name)) - return is_valid_ = false; - - clear_field_name(); - - if(0 == (field_name_ = strdup(field_name))) { - is_valid_ = false; - } - else { - field_name_length_ = std::strlen(field_name_); - compose_field(); - } - - return is_valid_; - } - - bool VorbisComment::Entry::set_field_value(const char *field_value, uint32_t field_value_length) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(0 != field_value); - - if(!::FLAC__format_vorbiscomment_entry_value_is_legal(reinterpret_cast(field_value), field_value_length)) - return is_valid_ = false; - - clear_field_value(); - - if(0 == (field_value_ = static_cast(safe_malloc_add_2op_(field_value_length, /*+*/1)))) { - is_valid_ = false; - } - else { - field_value_length_ = field_value_length; - std::memcpy(field_value_, field_value, field_value_length); - field_value_[field_value_length] = '\0'; - compose_field(); - } - - return is_valid_; - } - - bool VorbisComment::Entry::set_field_value(const char *field_value) - { - return set_field_value(field_value, std::strlen(field_value)); - } - - void VorbisComment::Entry::zero() - { - is_valid_ = true; - entry_.length = 0; - entry_.entry = 0; - field_name_ = 0; - field_name_length_ = 0; - field_value_ = 0; - field_value_length_ = 0; - } - - void VorbisComment::Entry::clear() - { - clear_entry(); - clear_field_name(); - clear_field_value(); - is_valid_ = true; - } - - void VorbisComment::Entry::clear_entry() - { - if(0 != entry_.entry) { - std::free(entry_.entry); - entry_.entry = 0; - entry_.length = 0; - } - } - - void VorbisComment::Entry::clear_field_name() - { - if(0 != field_name_) { - std::free(field_name_); - field_name_ = 0; - field_name_length_ = 0; - } - } - - void VorbisComment::Entry::clear_field_value() - { - if(0 != field_value_) { - std::free(field_value_); - field_value_ = 0; - field_value_length_ = 0; - } - } - - void VorbisComment::Entry::construct(const char *field, uint32_t field_length) - { - if(set_field(field, field_length)) - parse_field(); - } - - void VorbisComment::Entry::construct(const char *field) - { - construct(field, std::strlen(field)); - } - - void VorbisComment::Entry::construct(const char *field_name, const char *field_value, uint32_t field_value_length) - { - if(set_field_name(field_name) && set_field_value(field_value, field_value_length)) - compose_field(); - } - - void VorbisComment::Entry::construct(const char *field_name, const char *field_value) - { - construct(field_name, field_value, std::strlen(field_value)); - } - - void VorbisComment::Entry::compose_field() - { - clear_entry(); - - if(0 == (entry_.entry = static_cast(safe_malloc_add_4op_(field_name_length_, /*+*/1, /*+*/field_value_length_, /*+*/1)))) { - is_valid_ = false; - } - else { - std::memcpy(entry_.entry, field_name_, field_name_length_); - entry_.length += field_name_length_; - std::memcpy(entry_.entry + entry_.length, "=", 1); - entry_.length += 1; - if (field_value_length_ > 0) - std::memcpy(entry_.entry + entry_.length, field_value_, field_value_length_); - entry_.length += field_value_length_; - entry_.entry[entry_.length] = '\0'; - is_valid_ = true; - } - } - - void VorbisComment::Entry::parse_field() - { - clear_field_name(); - clear_field_value(); - - const char *p = static_cast(std::memchr(entry_.entry, '=', entry_.length)); - - if(0 == p) - p = reinterpret_cast(entry_.entry) + entry_.length; - - field_name_length_ = static_cast(p - reinterpret_cast(entry_.entry)); - if(0 == (field_name_ = static_cast(safe_malloc_add_2op_(field_name_length_, /*+*/1)))) { // +1 for the trailing \0 - is_valid_ = false; - return; - } - std::memcpy(field_name_, entry_.entry, field_name_length_); - field_name_[field_name_length_] = '\0'; - - if(entry_.length - field_name_length_ == 0) { - field_value_length_ = 0; - if(0 == (field_value_ = static_cast(safe_malloc_(0)))) { - is_valid_ = false; - return; - } - } - else { - field_value_length_ = entry_.length - field_name_length_ - 1; - if(0 == (field_value_ = static_cast(safe_malloc_add_2op_(field_value_length_, /*+*/1)))) { // +1 for the trailing \0 - is_valid_ = false; - return; - } - std::memcpy(field_value_, ++p, field_value_length_); - field_value_[field_value_length_] = '\0'; - } - - is_valid_ = true; - } - - - // - // VorbisComment - // - - VorbisComment::VorbisComment(): - Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT), /*copy=*/false) - { } - - VorbisComment::~VorbisComment() - { } - - uint32_t VorbisComment::get_num_comments() const - { - FLAC__ASSERT(is_valid()); - return object_->data.vorbis_comment.num_comments; - } - - const FLAC__byte *VorbisComment::get_vendor_string() const - { - FLAC__ASSERT(is_valid()); - return object_->data.vorbis_comment.vendor_string.entry; - } - - VorbisComment::Entry VorbisComment::get_comment(uint32_t indx) const - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(indx < object_->data.vorbis_comment.num_comments); - return Entry(reinterpret_cast(object_->data.vorbis_comment.comments[indx].entry), object_->data.vorbis_comment.comments[indx].length); - } - - bool VorbisComment::set_vendor_string(const FLAC__byte *string) - { - FLAC__ASSERT(is_valid()); - // vendor_string is a special kind of entry - const ::FLAC__StreamMetadata_VorbisComment_Entry vendor_string = { static_cast(std::strlen(reinterpret_cast(string))), const_cast(string) }; // we can cheat on const-ness because we make a copy below: - return static_cast(::FLAC__metadata_object_vorbiscomment_set_vendor_string(object_, vendor_string, /*copy=*/true)); - } - - bool VorbisComment::resize_comments(uint32_t new_num_comments) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_vorbiscomment_resize_comments(object_, new_num_comments)); - } - - bool VorbisComment::set_comment(uint32_t indx, const VorbisComment::Entry &entry) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(indx < object_->data.vorbis_comment.num_comments); - return static_cast(::FLAC__metadata_object_vorbiscomment_set_comment(object_, indx, entry.get_entry(), /*copy=*/true)); - } - - bool VorbisComment::insert_comment(uint32_t indx, const VorbisComment::Entry &entry) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(indx <= object_->data.vorbis_comment.num_comments); - return static_cast(::FLAC__metadata_object_vorbiscomment_insert_comment(object_, indx, entry.get_entry(), /*copy=*/true)); - } - - bool VorbisComment::append_comment(const VorbisComment::Entry &entry) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_vorbiscomment_append_comment(object_, entry.get_entry(), /*copy=*/true)); - } - - bool VorbisComment::replace_comment(const VorbisComment::Entry &entry, bool all) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_vorbiscomment_replace_comment(object_, entry.get_entry(), static_cast(all), /*copy=*/true)); - } - - bool VorbisComment::delete_comment(uint32_t indx) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(indx < object_->data.vorbis_comment.num_comments); - return static_cast(::FLAC__metadata_object_vorbiscomment_delete_comment(object_, indx)); - } - - int VorbisComment::find_entry_from(uint32_t offset, const char *field_name) - { - FLAC__ASSERT(is_valid()); - return ::FLAC__metadata_object_vorbiscomment_find_entry_from(object_, offset, field_name); - } - - int VorbisComment::remove_entry_matching(const char *field_name) - { - FLAC__ASSERT(is_valid()); - return ::FLAC__metadata_object_vorbiscomment_remove_entry_matching(object_, field_name); - } - - int VorbisComment::remove_entries_matching(const char *field_name) - { - FLAC__ASSERT(is_valid()); - return ::FLAC__metadata_object_vorbiscomment_remove_entries_matching(object_, field_name); - } - - - // - // CueSheet::Track - // - - CueSheet::Track::Track(): - object_(::FLAC__metadata_object_cuesheet_track_new()) - { } - - CueSheet::Track::Track(const ::FLAC__StreamMetadata_CueSheet_Track *track): - object_(::FLAC__metadata_object_cuesheet_track_clone(track)) - { } - - CueSheet::Track::Track(const Track &track): - object_(::FLAC__metadata_object_cuesheet_track_clone(track.object_)) - { } - - CueSheet::Track &CueSheet::Track::operator=(const Track &track) - { - if(0 != object_) - ::FLAC__metadata_object_cuesheet_track_delete(object_); - object_ = ::FLAC__metadata_object_cuesheet_track_clone(track.object_); - return *this; - } - - CueSheet::Track::~Track() - { - if(0 != object_) - ::FLAC__metadata_object_cuesheet_track_delete(object_); - } - - bool CueSheet::Track::is_valid() const - { - return(0 != object_); - } - - ::FLAC__StreamMetadata_CueSheet_Index CueSheet::Track::get_index(uint32_t i) const - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(i < object_->num_indices); - return object_->indices[i]; - } - - void CueSheet::Track::set_isrc(const char value[12]) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(0 != value); - std::memcpy(object_->isrc, value, 12); - object_->isrc[12] = '\0'; - } - - void CueSheet::Track::set_type(uint32_t value) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(value <= 1); - object_->type = value; - } - - void CueSheet::Track::set_index(uint32_t i, const ::FLAC__StreamMetadata_CueSheet_Index &indx) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(i < object_->num_indices); - object_->indices[i] = indx; - } - - - // - // CueSheet - // - - CueSheet::CueSheet(): - Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET), /*copy=*/false) - { } - - CueSheet::~CueSheet() - { } - - const char *CueSheet::get_media_catalog_number() const - { - FLAC__ASSERT(is_valid()); - return object_->data.cue_sheet.media_catalog_number; - } - - FLAC__uint64 CueSheet::get_lead_in() const - { - FLAC__ASSERT(is_valid()); - return object_->data.cue_sheet.lead_in; - } - - bool CueSheet::get_is_cd() const - { - FLAC__ASSERT(is_valid()); - return object_->data.cue_sheet.is_cd? true : false; - } - - uint32_t CueSheet::get_num_tracks() const - { - FLAC__ASSERT(is_valid()); - return object_->data.cue_sheet.num_tracks; - } - - CueSheet::Track CueSheet::get_track(uint32_t i) const - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(i < object_->data.cue_sheet.num_tracks); - return Track(object_->data.cue_sheet.tracks + i); - } - - void CueSheet::set_media_catalog_number(const char value[128]) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(0 != value); - std::memcpy(object_->data.cue_sheet.media_catalog_number, value, 128); - object_->data.cue_sheet.media_catalog_number[128] = '\0'; - } - - void CueSheet::set_lead_in(FLAC__uint64 value) - { - FLAC__ASSERT(is_valid()); - object_->data.cue_sheet.lead_in = value; - } - - void CueSheet::set_is_cd(bool value) - { - FLAC__ASSERT(is_valid()); - object_->data.cue_sheet.is_cd = value; - } - - void CueSheet::set_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &indx) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); - FLAC__ASSERT(index_num < object_->data.cue_sheet.tracks[track_num].num_indices); - object_->data.cue_sheet.tracks[track_num].indices[index_num] = indx; - } - - bool CueSheet::resize_indices(uint32_t track_num, uint32_t new_num_indices) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); - return static_cast(::FLAC__metadata_object_cuesheet_track_resize_indices(object_, track_num, new_num_indices)); - } - - bool CueSheet::insert_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &indx) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); - FLAC__ASSERT(index_num <= object_->data.cue_sheet.tracks[track_num].num_indices); - return static_cast(::FLAC__metadata_object_cuesheet_track_insert_index(object_, track_num, index_num, indx)); - } - - bool CueSheet::insert_blank_index(uint32_t track_num, uint32_t index_num) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); - FLAC__ASSERT(index_num <= object_->data.cue_sheet.tracks[track_num].num_indices); - return static_cast(::FLAC__metadata_object_cuesheet_track_insert_blank_index(object_, track_num, index_num)); - } - - bool CueSheet::delete_index(uint32_t track_num, uint32_t index_num) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks); - FLAC__ASSERT(index_num < object_->data.cue_sheet.tracks[track_num].num_indices); - return static_cast(::FLAC__metadata_object_cuesheet_track_delete_index(object_, track_num, index_num)); - } - - bool CueSheet::resize_tracks(uint32_t new_num_tracks) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_cuesheet_resize_tracks(object_, new_num_tracks)); - } - - bool CueSheet::set_track(uint32_t i, const CueSheet::Track &track) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(i < object_->data.cue_sheet.num_tracks); - // We can safely const_cast since copy=true - return static_cast(::FLAC__metadata_object_cuesheet_set_track(object_, i, const_cast< ::FLAC__StreamMetadata_CueSheet_Track*>(track.get_track()), /*copy=*/true)); - } - - bool CueSheet::insert_track(uint32_t i, const CueSheet::Track &track) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(i <= object_->data.cue_sheet.num_tracks); - // We can safely const_cast since copy=true - return static_cast(::FLAC__metadata_object_cuesheet_insert_track(object_, i, const_cast< ::FLAC__StreamMetadata_CueSheet_Track*>(track.get_track()), /*copy=*/true)); - } - - bool CueSheet::insert_blank_track(uint32_t i) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(i <= object_->data.cue_sheet.num_tracks); - return static_cast(::FLAC__metadata_object_cuesheet_insert_blank_track(object_, i)); - } - - bool CueSheet::delete_track(uint32_t i) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(i < object_->data.cue_sheet.num_tracks); - return static_cast(::FLAC__metadata_object_cuesheet_delete_track(object_, i)); - } - - bool CueSheet::is_legal(bool check_cd_da_subset, const char **violation) const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_cuesheet_is_legal(object_, check_cd_da_subset, violation)); - } - - FLAC__uint32 CueSheet::calculate_cddb_id() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__metadata_object_cuesheet_calculate_cddb_id(object_); - } - - - // - // Picture - // - - Picture::Picture(): - Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE), /*copy=*/false) - { } - - Picture::~Picture() - { } - - ::FLAC__StreamMetadata_Picture_Type Picture::get_type() const - { - FLAC__ASSERT(is_valid()); - return object_->data.picture.type; - } - - const char *Picture::get_mime_type() const - { - FLAC__ASSERT(is_valid()); - return object_->data.picture.mime_type; - } - - const FLAC__byte *Picture::get_description() const - { - FLAC__ASSERT(is_valid()); - return object_->data.picture.description; - } - - FLAC__uint32 Picture::get_width() const - { - FLAC__ASSERT(is_valid()); - return object_->data.picture.width; - } - - FLAC__uint32 Picture::get_height() const - { - FLAC__ASSERT(is_valid()); - return object_->data.picture.height; - } - - FLAC__uint32 Picture::get_depth() const - { - FLAC__ASSERT(is_valid()); - return object_->data.picture.depth; - } - - FLAC__uint32 Picture::get_colors() const - { - FLAC__ASSERT(is_valid()); - return object_->data.picture.colors; - } - - FLAC__uint32 Picture::get_data_length() const - { - FLAC__ASSERT(is_valid()); - return object_->data.picture.data_length; - } - - const FLAC__byte *Picture::get_data() const - { - FLAC__ASSERT(is_valid()); - return object_->data.picture.data; - } - - void Picture::set_type(::FLAC__StreamMetadata_Picture_Type type) - { - FLAC__ASSERT(is_valid()); - object_->data.picture.type = type; - } - - bool Picture::set_mime_type(const char *string) - { - FLAC__ASSERT(is_valid()); - // We can safely const_cast since copy=true - return static_cast(::FLAC__metadata_object_picture_set_mime_type(object_, const_cast(string), /*copy=*/true)); - } - - bool Picture::set_description(const FLAC__byte *string) - { - FLAC__ASSERT(is_valid()); - // We can safely const_cast since copy=true - return static_cast(::FLAC__metadata_object_picture_set_description(object_, const_cast(string), /*copy=*/true)); - } - - void Picture::set_width(FLAC__uint32 value) const - { - FLAC__ASSERT(is_valid()); - object_->data.picture.width = value; - } - - void Picture::set_height(FLAC__uint32 value) const - { - FLAC__ASSERT(is_valid()); - object_->data.picture.height = value; - } - - void Picture::set_depth(FLAC__uint32 value) const - { - FLAC__ASSERT(is_valid()); - object_->data.picture.depth = value; - } - - void Picture::set_colors(FLAC__uint32 value) const - { - FLAC__ASSERT(is_valid()); - object_->data.picture.colors = value; - } - - bool Picture::set_data(const FLAC__byte *data, FLAC__uint32 data_length) - { - FLAC__ASSERT(is_valid()); - // We can safely const_cast since copy=true - return static_cast(::FLAC__metadata_object_picture_set_data(object_, const_cast(data), data_length, /*copy=*/true)); - } - - bool Picture::is_legal(const char **violation) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_picture_is_legal(object_, violation)); - } - - - // - // Unknown - // - - Unknown::Unknown(): - Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), /*copy=*/false) - { } - - Unknown::~Unknown() - { } - - const FLAC__byte *Unknown::get_data() const - { - FLAC__ASSERT(is_valid()); - return object_->data.application.data; - } - - bool Unknown::set_data(const FLAC__byte *data, uint32_t length) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_application_set_data(object_, const_cast(data), length, true)); - } - - bool Unknown::set_data(FLAC__byte *data, uint32_t length, bool copy) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_object_application_set_data(object_, data, length, copy)); - } - - - // ============================================================ - // - // Level 0 - // - // ============================================================ - - FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo) - { - FLAC__ASSERT(0 != filename); - - ::FLAC__StreamMetadata object; - - if(::FLAC__metadata_get_streaminfo(filename, &object)) { - streaminfo = object; - return true; - } - else - return false; - } - - FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags) - { - FLAC__ASSERT(0 != filename); - - ::FLAC__StreamMetadata *object; - - tags = 0; - - if(::FLAC__metadata_get_tags(filename, &object)) { - tags = new VorbisComment(object, /*copy=*/false); - return true; - } - else - return false; - } - - FLACPP_API bool get_tags(const char *filename, VorbisComment &tags) - { - FLAC__ASSERT(0 != filename); - - ::FLAC__StreamMetadata *object; - - if(::FLAC__metadata_get_tags(filename, &object)) { - tags.assign(object, /*copy=*/false); - return true; - } - else - return false; - } - - FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet) - { - FLAC__ASSERT(0 != filename); - - ::FLAC__StreamMetadata *object; - - cuesheet = 0; - - if(::FLAC__metadata_get_cuesheet(filename, &object)) { - cuesheet = new CueSheet(object, /*copy=*/false); - return true; - } - else - return false; - } - - FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet) - { - FLAC__ASSERT(0 != filename); - - ::FLAC__StreamMetadata *object; - - if(::FLAC__metadata_get_cuesheet(filename, &object)) { - cuesheet.assign(object, /*copy=*/false); - return true; - } - else - return false; - } - - FLACPP_API bool get_picture(const char *filename, Picture *&picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors) - { - FLAC__ASSERT(0 != filename); - - ::FLAC__StreamMetadata *object; - - picture = 0; - - if(::FLAC__metadata_get_picture(filename, &object, type, mime_type, description, max_width, max_height, max_depth, max_colors)) { - picture = new Picture(object, /*copy=*/false); - return true; - } - else - return false; - } - - FLACPP_API bool get_picture(const char *filename, Picture &picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors) - { - FLAC__ASSERT(0 != filename); - - ::FLAC__StreamMetadata *object; - - if(::FLAC__metadata_get_picture(filename, &object, type, mime_type, description, max_width, max_height, max_depth, max_colors)) { - picture.assign(object, /*copy=*/false); - return true; - } - else - return false; - } - - - // ============================================================ - // - // Level 1 - // - // ============================================================ - - SimpleIterator::SimpleIterator(): - iterator_(::FLAC__metadata_simple_iterator_new()) - { } - - SimpleIterator::~SimpleIterator() - { - clear(); - } - - void SimpleIterator::clear() - { - if(0 != iterator_) - FLAC__metadata_simple_iterator_delete(iterator_); - iterator_ = 0; - } - - bool SimpleIterator::init(const char *filename, bool read_only, bool preserve_file_stats) - { - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_simple_iterator_init(iterator_, filename, read_only, preserve_file_stats)); - } - - bool SimpleIterator::is_valid() const - { - return 0 != iterator_; - } - - SimpleIterator::Status SimpleIterator::status() - { - FLAC__ASSERT(is_valid()); - return Status(::FLAC__metadata_simple_iterator_status(iterator_)); - } - - bool SimpleIterator::is_writable() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_simple_iterator_is_writable(iterator_)); - } - - bool SimpleIterator::next() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_simple_iterator_next(iterator_)); - } - - bool SimpleIterator::prev() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_simple_iterator_prev(iterator_)); - } - - //@@@@ add to tests - bool SimpleIterator::is_last() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_simple_iterator_is_last(iterator_)); - } - - //@@@@ add to tests - off_t SimpleIterator::get_block_offset() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__metadata_simple_iterator_get_block_offset(iterator_); - } - - ::FLAC__MetadataType SimpleIterator::get_block_type() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__metadata_simple_iterator_get_block_type(iterator_); - } - - //@@@@ add to tests - uint32_t SimpleIterator::get_block_length() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__metadata_simple_iterator_get_block_length(iterator_); - } - - //@@@@ add to tests - bool SimpleIterator::get_application_id(FLAC__byte *id) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_simple_iterator_get_application_id(iterator_, id)); - } - - Prototype *SimpleIterator::get_block() - { - FLAC__ASSERT(is_valid()); - return local::construct_block(::FLAC__metadata_simple_iterator_get_block(iterator_)); - } - - bool SimpleIterator::set_block(Prototype *block, bool use_padding) - { - FLAC__ASSERT(0 != block); - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_simple_iterator_set_block(iterator_, block->object_, use_padding)); - } - - bool SimpleIterator::insert_block_after(Prototype *block, bool use_padding) - { - FLAC__ASSERT(0 != block); - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_simple_iterator_insert_block_after(iterator_, block->object_, use_padding)); - } - - bool SimpleIterator::delete_block(bool use_padding) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_simple_iterator_delete_block(iterator_, use_padding)); - } - - - // ============================================================ - // - // Level 2 - // - // ============================================================ - - Chain::Chain(): - chain_(::FLAC__metadata_chain_new()) - { } - - Chain::~Chain() - { - clear(); - } - - void Chain::clear() - { - if(0 != chain_) - FLAC__metadata_chain_delete(chain_); - chain_ = 0; - } - - bool Chain::is_valid() const - { - return 0 != chain_; - } - - Chain::Status Chain::status() - { - FLAC__ASSERT(is_valid()); - return Status(::FLAC__metadata_chain_status(chain_)); - } - - bool Chain::read(const char *filename, bool is_ogg) - { - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(is_valid()); - return is_ogg? - static_cast(::FLAC__metadata_chain_read_ogg(chain_, filename)) : - static_cast(::FLAC__metadata_chain_read(chain_, filename)) - ; - } - - bool Chain::read(FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, bool is_ogg) - { - FLAC__ASSERT(is_valid()); - return is_ogg? - static_cast(::FLAC__metadata_chain_read_ogg_with_callbacks(chain_, handle, callbacks)) : - static_cast(::FLAC__metadata_chain_read_with_callbacks(chain_, handle, callbacks)) - ; - } - - bool Chain::check_if_tempfile_needed(bool use_padding) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_chain_check_if_tempfile_needed(chain_, use_padding)); - } - - bool Chain::write(bool use_padding, bool preserve_file_stats) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_chain_write(chain_, use_padding, preserve_file_stats)); - } - - bool Chain::write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_chain_write_with_callbacks(chain_, use_padding, handle, callbacks)); - } - - bool Chain::write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_chain_write_with_callbacks_and_tempfile(chain_, use_padding, handle, callbacks, temp_handle, temp_callbacks)); - } - - void Chain::merge_padding() - { - FLAC__ASSERT(is_valid()); - ::FLAC__metadata_chain_merge_padding(chain_); - } - - void Chain::sort_padding() - { - FLAC__ASSERT(is_valid()); - ::FLAC__metadata_chain_sort_padding(chain_); - } - - - Iterator::Iterator(): - iterator_(::FLAC__metadata_iterator_new()) - { } - - Iterator::~Iterator() - { - clear(); - } - - void Iterator::clear() - { - if(0 != iterator_) - FLAC__metadata_iterator_delete(iterator_); - iterator_ = 0; - } - - bool Iterator::is_valid() const - { - return 0 != iterator_; - } - - void Iterator::init(Chain &chain) - { - FLAC__ASSERT(is_valid()); - FLAC__ASSERT(chain.is_valid()); - ::FLAC__metadata_iterator_init(iterator_, chain.chain_); - } - - bool Iterator::next() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_iterator_next(iterator_)); - } - - bool Iterator::prev() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_iterator_prev(iterator_)); - } - - ::FLAC__MetadataType Iterator::get_block_type() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__metadata_iterator_get_block_type(iterator_); - } - - Prototype *Iterator::get_block() - { - FLAC__ASSERT(is_valid()); - Prototype *block = local::construct_block(::FLAC__metadata_iterator_get_block(iterator_)); - if(0 != block) - block->set_reference(true); - return block; - } - - bool Iterator::set_block(Prototype *block) - { - FLAC__ASSERT(0 != block); - FLAC__ASSERT(is_valid()); - bool ret = static_cast(::FLAC__metadata_iterator_set_block(iterator_, block->object_)); - if(ret) { - block->set_reference(true); - delete block; - } - return ret; - } - - bool Iterator::delete_block(bool replace_with_padding) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__metadata_iterator_delete_block(iterator_, replace_with_padding)); - } - - bool Iterator::insert_block_before(Prototype *block) - { - FLAC__ASSERT(0 != block); - FLAC__ASSERT(is_valid()); - bool ret = static_cast(::FLAC__metadata_iterator_insert_block_before(iterator_, block->object_)); - if(ret) { - block->set_reference(true); - delete block; - } - return ret; - } - - bool Iterator::insert_block_after(Prototype *block) - { - FLAC__ASSERT(0 != block); - FLAC__ASSERT(is_valid()); - bool ret = static_cast(::FLAC__metadata_iterator_insert_block_after(iterator_, block->object_)); - if(ret) { - block->set_reference(true); - delete block; - } - return ret; - } - - } // namespace Metadata -} // namespace FLAC diff --git a/Engine/lib/flac/src/libFLAC++/stream_decoder.cpp b/Engine/lib/flac/src/libFLAC++/stream_decoder.cpp deleted file mode 100644 index 6e351d94b..000000000 --- a/Engine/lib/flac/src/libFLAC++/stream_decoder.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/* libFLAC++ - Free Lossless Audio Codec library - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "FLAC++/decoder.h" -#include "FLAC/assert.h" - -#ifdef _MSC_VER -// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) -#pragma warning ( disable : 4800 ) -#endif - -namespace FLAC { - namespace Decoder { - - // ------------------------------------------------------------ - // - // Stream - // - // ------------------------------------------------------------ - - Stream::Stream(): - decoder_(::FLAC__stream_decoder_new()) - { } - - Stream::~Stream() - { - if(0 != decoder_) { - (void)::FLAC__stream_decoder_finish(decoder_); - ::FLAC__stream_decoder_delete(decoder_); - } - } - - bool Stream::is_valid() const - { - return 0 != decoder_; - } - - bool Stream::set_ogg_serial_number(long value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_set_ogg_serial_number(decoder_, value)); - } - - bool Stream::set_md5_checking(bool value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_set_md5_checking(decoder_, value)); - } - - bool Stream::set_metadata_respond(::FLAC__MetadataType type) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_set_metadata_respond(decoder_, type)); - } - - bool Stream::set_metadata_respond_application(const FLAC__byte id[4]) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_set_metadata_respond_application(decoder_, id)); - } - - bool Stream::set_metadata_respond_all() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_set_metadata_respond_all(decoder_)); - } - - bool Stream::set_metadata_ignore(::FLAC__MetadataType type) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_set_metadata_ignore(decoder_, type)); - } - - bool Stream::set_metadata_ignore_application(const FLAC__byte id[4]) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_set_metadata_ignore_application(decoder_, id)); - } - - bool Stream::set_metadata_ignore_all() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_set_metadata_ignore_all(decoder_)); - } - - Stream::State Stream::get_state() const - { - FLAC__ASSERT(is_valid()); - return State(::FLAC__stream_decoder_get_state(decoder_)); - } - - bool Stream::get_md5_checking() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_get_md5_checking(decoder_)); - } - - FLAC__uint64 Stream::get_total_samples() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_decoder_get_total_samples(decoder_); - } - - uint32_t Stream::get_channels() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_decoder_get_channels(decoder_); - } - - ::FLAC__ChannelAssignment Stream::get_channel_assignment() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_decoder_get_channel_assignment(decoder_); - } - - uint32_t Stream::get_bits_per_sample() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_decoder_get_bits_per_sample(decoder_); - } - - uint32_t Stream::get_sample_rate() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_decoder_get_sample_rate(decoder_); - } - - uint32_t Stream::get_blocksize() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_decoder_get_blocksize(decoder_); - } - - bool Stream::get_decode_position(FLAC__uint64 *position) const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_decoder_get_decode_position(decoder_, position); - } - - ::FLAC__StreamDecoderInitStatus Stream::init() - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_decoder_init_stream(decoder_, read_callback_, seek_callback_, tell_callback_, length_callback_, eof_callback_, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamDecoderInitStatus Stream::init_ogg() - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_decoder_init_ogg_stream(decoder_, read_callback_, seek_callback_, tell_callback_, length_callback_, eof_callback_, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); - } - - bool Stream::finish() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_finish(decoder_)); - } - - bool Stream::flush() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_flush(decoder_)); - } - - bool Stream::reset() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_reset(decoder_)); - } - - bool Stream::process_single() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_process_single(decoder_)); - } - - bool Stream::process_until_end_of_metadata() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_process_until_end_of_metadata(decoder_)); - } - - bool Stream::process_until_end_of_stream() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_process_until_end_of_stream(decoder_)); - } - - bool Stream::skip_single_frame() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_skip_single_frame(decoder_)); - } - - bool Stream::seek_absolute(FLAC__uint64 sample) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_decoder_seek_absolute(decoder_, sample)); - } - - ::FLAC__StreamDecoderSeekStatus Stream::seek_callback(FLAC__uint64 absolute_byte_offset) - { - (void)absolute_byte_offset; - return ::FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; - } - - ::FLAC__StreamDecoderTellStatus Stream::tell_callback(FLAC__uint64 *absolute_byte_offset) - { - (void)absolute_byte_offset; - return ::FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED; - } - - ::FLAC__StreamDecoderLengthStatus Stream::length_callback(FLAC__uint64 *stream_length) - { - (void)stream_length; - return ::FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; - } - - bool Stream::eof_callback() - { - return false; - } - - void Stream::metadata_callback(const ::FLAC__StreamMetadata *metadata) - { - (void)metadata; - } - - ::FLAC__StreamDecoderReadStatus Stream::read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) - { - (void)decoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->read_callback(buffer, bytes); - } - - ::FLAC__StreamDecoderSeekStatus Stream::seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) - { - (void) decoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->seek_callback(absolute_byte_offset); - } - - ::FLAC__StreamDecoderTellStatus Stream::tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) - { - (void) decoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->tell_callback(absolute_byte_offset); - } - - ::FLAC__StreamDecoderLengthStatus Stream::length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) - { - (void) decoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->length_callback(stream_length); - } - - FLAC__bool Stream::eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data) - { - (void) decoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->eof_callback(); - } - - ::FLAC__StreamDecoderWriteStatus Stream::write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) - { - (void)decoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->write_callback(frame, buffer); - } - - void Stream::metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data) - { - (void)decoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - instance->metadata_callback(metadata); - } - - void Stream::error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data) - { - (void)decoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - instance->error_callback(status); - } - - // ------------------------------------------------------------ - // - // File - // - // ------------------------------------------------------------ - - File::File(): - Stream() - { } - - File::~File() - { - } - - ::FLAC__StreamDecoderInitStatus File::init(FILE *file) - { - FLAC__ASSERT(0 != decoder_); - return ::FLAC__stream_decoder_init_FILE(decoder_, file, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamDecoderInitStatus File::init(const char *filename) - { - FLAC__ASSERT(0 != decoder_); - return ::FLAC__stream_decoder_init_file(decoder_, filename, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamDecoderInitStatus File::init(const std::string &filename) - { - return init(filename.c_str()); - } - - ::FLAC__StreamDecoderInitStatus File::init_ogg(FILE *file) - { - FLAC__ASSERT(0 != decoder_); - return ::FLAC__stream_decoder_init_ogg_FILE(decoder_, file, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamDecoderInitStatus File::init_ogg(const char *filename) - { - FLAC__ASSERT(0 != decoder_); - return ::FLAC__stream_decoder_init_ogg_file(decoder_, filename, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamDecoderInitStatus File::init_ogg(const std::string &filename) - { - return init_ogg(filename.c_str()); - } - - // This is a dummy to satisfy the pure virtual from Stream; the - // read callback will never be called since we are initializing - // with FLAC__stream_decoder_init_FILE() or - // FLAC__stream_decoder_init_file() and those supply the read - // callback internally. - ::FLAC__StreamDecoderReadStatus File::read_callback(FLAC__byte buffer[], size_t *bytes) - { - (void)buffer, (void)bytes; - FLAC__ASSERT(false); - return ::FLAC__STREAM_DECODER_READ_STATUS_ABORT; // double protection - } - - } // namespace Decoder -} // namespace FLAC diff --git a/Engine/lib/flac/src/libFLAC++/stream_encoder.cpp b/Engine/lib/flac/src/libFLAC++/stream_encoder.cpp deleted file mode 100644 index 837712948..000000000 --- a/Engine/lib/flac/src/libFLAC++/stream_encoder.cpp +++ /dev/null @@ -1,519 +0,0 @@ -/* libFLAC++ - Free Lossless Audio Codec library - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "FLAC++/encoder.h" -#include "FLAC++/metadata.h" -#include "FLAC/assert.h" - -#ifdef _MSC_VER -// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) -#pragma warning ( disable : 4800 ) -#endif - -namespace FLAC { - namespace Encoder { - - // ------------------------------------------------------------ - // - // Stream - // - // ------------------------------------------------------------ - - Stream::Stream(): - encoder_(::FLAC__stream_encoder_new()) - { } - - Stream::~Stream() - { - if(0 != encoder_) { - (void)::FLAC__stream_encoder_finish(encoder_); - ::FLAC__stream_encoder_delete(encoder_); - } - } - - bool Stream::is_valid() const - { - return 0 != encoder_; - } - - bool Stream::set_ogg_serial_number(long value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_ogg_serial_number(encoder_, value)); - } - - bool Stream::set_verify(bool value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_verify(encoder_, value)); - } - - bool Stream::set_streamable_subset(bool value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_streamable_subset(encoder_, value)); - } - - bool Stream::set_channels(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_channels(encoder_, value)); - } - - bool Stream::set_bits_per_sample(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_bits_per_sample(encoder_, value)); - } - - bool Stream::set_sample_rate(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_sample_rate(encoder_, value)); - } - - bool Stream::set_compression_level(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_compression_level(encoder_, value)); - } - - bool Stream::set_blocksize(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_blocksize(encoder_, value)); - } - - bool Stream::set_do_mid_side_stereo(bool value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_do_mid_side_stereo(encoder_, value)); - } - - bool Stream::set_loose_mid_side_stereo(bool value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_loose_mid_side_stereo(encoder_, value)); - } - - bool Stream::set_apodization(const char *specification) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_apodization(encoder_, specification)); - } - - bool Stream::set_max_lpc_order(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_max_lpc_order(encoder_, value)); - } - - bool Stream::set_qlp_coeff_precision(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_qlp_coeff_precision(encoder_, value)); - } - - bool Stream::set_do_qlp_coeff_prec_search(bool value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder_, value)); - } - - bool Stream::set_do_escape_coding(bool value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_do_escape_coding(encoder_, value)); - } - - bool Stream::set_do_exhaustive_model_search(bool value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_do_exhaustive_model_search(encoder_, value)); - } - - bool Stream::set_min_residual_partition_order(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_min_residual_partition_order(encoder_, value)); - } - - bool Stream::set_max_residual_partition_order(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_max_residual_partition_order(encoder_, value)); - } - - bool Stream::set_rice_parameter_search_dist(uint32_t value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_rice_parameter_search_dist(encoder_, value)); - } - - bool Stream::set_total_samples_estimate(FLAC__uint64 value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_total_samples_estimate(encoder_, value)); - } - - bool Stream::set_metadata(::FLAC__StreamMetadata **metadata, uint32_t num_blocks) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_metadata(encoder_, metadata, num_blocks)); - } - - bool Stream::set_metadata(FLAC::Metadata::Prototype **metadata, uint32_t num_blocks) - { - FLAC__ASSERT(is_valid()); - // because C++ doesn't have VLA's (variable length arrays) - // this ugly workaround is needed - ::FLAC__StreamMetadata **m = new ::FLAC__StreamMetadata*[num_blocks]; - for(uint32_t i = 0; i < num_blocks; i++) { - // we can get away with the const_cast since we know the encoder will only correct the is_last flags - m[i] = const_cast< ::FLAC__StreamMetadata*>(static_cast(*metadata[i])); - } - // complete the hack - const bool ok = static_cast(::FLAC__stream_encoder_set_metadata(encoder_, m, num_blocks)); - delete [] m; - return ok; - } - - bool Stream::set_limit_min_bitrate(bool value) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_set_limit_min_bitrate(encoder_, value)); - } - - Stream::State Stream::get_state() const - { - FLAC__ASSERT(is_valid()); - return State(::FLAC__stream_encoder_get_state(encoder_)); - } - - Decoder::Stream::State Stream::get_verify_decoder_state() const - { - FLAC__ASSERT(is_valid()); - return Decoder::Stream::State(::FLAC__stream_encoder_get_verify_decoder_state(encoder_)); - } - - void Stream::get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got) - { - FLAC__ASSERT(is_valid()); - ::FLAC__stream_encoder_get_verify_decoder_error_stats(encoder_, absolute_sample, frame_number, channel, sample, expected, got); - } - - bool Stream::get_verify() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_get_verify(encoder_)); - } - - bool Stream::get_streamable_subset() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_get_streamable_subset(encoder_)); - } - - bool Stream::get_do_mid_side_stereo() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_get_do_mid_side_stereo(encoder_)); - } - - bool Stream::get_loose_mid_side_stereo() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_get_loose_mid_side_stereo(encoder_)); - } - - uint32_t Stream::get_channels() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_channels(encoder_); - } - - uint32_t Stream::get_bits_per_sample() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_bits_per_sample(encoder_); - } - - uint32_t Stream::get_sample_rate() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_sample_rate(encoder_); - } - - uint32_t Stream::get_blocksize() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_blocksize(encoder_); - } - - uint32_t Stream::get_max_lpc_order() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_max_lpc_order(encoder_); - } - - uint32_t Stream::get_qlp_coeff_precision() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_qlp_coeff_precision(encoder_); - } - - bool Stream::get_do_qlp_coeff_prec_search() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_get_do_qlp_coeff_prec_search(encoder_)); - } - - bool Stream::get_do_escape_coding() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_get_do_escape_coding(encoder_)); - } - - bool Stream::get_do_exhaustive_model_search() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_get_do_exhaustive_model_search(encoder_)); - } - - uint32_t Stream::get_min_residual_partition_order() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_min_residual_partition_order(encoder_); - } - - uint32_t Stream::get_max_residual_partition_order() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_max_residual_partition_order(encoder_); - } - - uint32_t Stream::get_rice_parameter_search_dist() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_rice_parameter_search_dist(encoder_); - } - - FLAC__uint64 Stream::get_total_samples_estimate() const - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_get_total_samples_estimate(encoder_); - } - - bool Stream::get_limit_min_bitrate() const - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_get_limit_min_bitrate(encoder_)); - } - - ::FLAC__StreamEncoderInitStatus Stream::init() - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_init_stream(encoder_, write_callback_, seek_callback_, tell_callback_, metadata_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamEncoderInitStatus Stream::init_ogg() - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_init_ogg_stream(encoder_, read_callback_, write_callback_, seek_callback_, tell_callback_, metadata_callback_, /*client_data=*/(void*)this); - } - - bool Stream::finish() - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_finish(encoder_)); - } - - bool Stream::process(const FLAC__int32 * const buffer[], uint32_t samples) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_process(encoder_, buffer, samples)); - } - - bool Stream::process_interleaved(const FLAC__int32 buffer[], uint32_t samples) - { - FLAC__ASSERT(is_valid()); - return static_cast(::FLAC__stream_encoder_process_interleaved(encoder_, buffer, samples)); - } - - ::FLAC__StreamEncoderReadStatus Stream::read_callback(FLAC__byte buffer[], size_t *bytes) - { - (void)buffer, (void)bytes; - return ::FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED; - } - - ::FLAC__StreamEncoderSeekStatus Stream::seek_callback(FLAC__uint64 absolute_byte_offset) - { - (void)absolute_byte_offset; - return ::FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED; - } - - ::FLAC__StreamEncoderTellStatus Stream::tell_callback(FLAC__uint64 *absolute_byte_offset) - { - (void)absolute_byte_offset; - return ::FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED; - } - - void Stream::metadata_callback(const ::FLAC__StreamMetadata *metadata) - { - (void)metadata; - } - - ::FLAC__StreamEncoderReadStatus Stream::read_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data) - { - (void)encoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->read_callback(buffer, bytes); - } - - ::FLAC__StreamEncoderWriteStatus Stream::write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) - { - (void)encoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->write_callback(buffer, bytes, samples, current_frame); - } - - ::FLAC__StreamEncoderSeekStatus Stream::seek_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) - { - (void)encoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->seek_callback(absolute_byte_offset); - } - - ::FLAC__StreamEncoderTellStatus Stream::tell_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) - { - (void)encoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - return instance->tell_callback(absolute_byte_offset); - } - - void Stream::metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data) - { - (void)encoder; - FLAC__ASSERT(0 != client_data); - Stream *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - instance->metadata_callback(metadata); - } - - // ------------------------------------------------------------ - // - // File - // - // ------------------------------------------------------------ - - File::File(): - Stream() - { } - - File::~File() - { - } - - ::FLAC__StreamEncoderInitStatus File::init(FILE *file) - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_init_FILE(encoder_, file, progress_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamEncoderInitStatus File::init(const char *filename) - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_init_file(encoder_, filename, progress_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamEncoderInitStatus File::init(const std::string &filename) - { - return init(filename.c_str()); - } - - ::FLAC__StreamEncoderInitStatus File::init_ogg(FILE *file) - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_init_ogg_FILE(encoder_, file, progress_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamEncoderInitStatus File::init_ogg(const char *filename) - { - FLAC__ASSERT(is_valid()); - return ::FLAC__stream_encoder_init_ogg_file(encoder_, filename, progress_callback_, /*client_data=*/(void*)this); - } - - ::FLAC__StreamEncoderInitStatus File::init_ogg(const std::string &filename) - { - return init_ogg(filename.c_str()); - } - - // This is a dummy to satisfy the pure virtual from Stream; the - // read callback will never be called since we are initializing - // with FLAC__stream_decoder_init_FILE() or - // FLAC__stream_decoder_init_file() and those supply the read - // callback internally. - ::FLAC__StreamEncoderWriteStatus File::write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame) - { - (void)buffer, (void)bytes, (void)samples, (void)current_frame; - FLAC__ASSERT(false); - return ::FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; // double protection - } - - void File::progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate) - { - (void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate; - } - - void File::progress_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data) - { - (void)encoder; - FLAC__ASSERT(0 != client_data); - File *instance = reinterpret_cast(client_data); - FLAC__ASSERT(0 != instance); - instance->progress_callback(bytes_written, samples_written, frames_written, total_frames_estimate); - } - - } // namespace Encoder -} // namespace FLAC diff --git a/Engine/lib/flac/src/libFLAC++/version.rc b/Engine/lib/flac/src/libFLAC++/version.rc deleted file mode 100644 index 14efba068..000000000 --- a/Engine/lib/flac/src/libFLAC++/version.rc +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include "config.h" -#include "FLAC++/export.h" - -#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) -# ifdef GIT_COMMIT_TAG -# define VERSIONSTRING GIT_COMMIT_TAG -# else -# define VERSIONSTRING "git-" GIT_COMMIT_HASH -# endif -#else -# define VERSIONSTRING PACKAGE_VERSION -#endif - -#define xstr(s) str(s) -#define str(s) #s - -VS_VERSION_INFO VERSIONINFO -FILEVERSION FLACPP_API_VERSION_CURRENT,FLACPP_API_VERSION_REVISION,0,0 -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -FILEFLAGS 0 -FILEOS VOS__WINDOWS32 -FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "libFLAC++ for Windows" - VALUE "ProductName", "Free Lossless Audio Codec" - VALUE "ProductVersion", VERSIONSTRING - VALUE "CompanyName", "Xiph.Org" - VALUE "LegalCopyright", "2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/Engine/lib/flac/src/libFLAC/CMakeLists.txt b/Engine/lib/flac/src/libFLAC/CMakeLists.txt deleted file mode 100644 index cf7368f60..000000000 --- a/Engine/lib/flac/src/libFLAC/CMakeLists.txt +++ /dev/null @@ -1,126 +0,0 @@ -option(WITH_ASM "Use any assembly optimization routines" ON) - -check_include_file("cpuid.h" HAVE_CPUID_H) -check_include_file("sys/param.h" HAVE_SYS_PARAM_H) - -set(CMAKE_REQUIRED_LIBRARIES m) -check_function_exists(lround HAVE_LROUND) - -include(CheckCSourceCompiles) -include(CheckCPUArch) -include(CheckA64NEON) - -check_cpu_arch_x64(FLAC__CPU_X86_64) -if(NOT FLAC__CPU_X86_64) - check_cpu_arch_x86(FLAC__CPU_IA32) -endif() - -if(FLAC__CPU_X86_64 OR FLAC__CPU_IA32) - set(FLAC__ALIGN_MALLOC_DATA 1) - option(WITH_AVX "Enable AVX, AVX2 optimizations (with runtime detection, resulting binary does not require AVX2, so only necessary when a compiler doesn't know about AVX)" ON) - if(WITH_AVX AND MSVC) - set_source_files_properties(fixed_intrin_avx2.c lpc_intrin_avx2.c stream_encoder_intrin_avx2.c lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS /arch:AVX2) - endif() -else() - check_cpu_arch_arm64(FLAC__CPU_ARM64) - if(FLAC__CPU_ARM64) - check_a64neon(FLAC__HAS_A64NEONINTRIN) - endif() -endif() - -if(NOT WITH_ASM) - add_definitions(-DFLAC__NO_ASM) -endif() - -include_directories("include") - -add_library(FLAC - bitmath.c - bitreader.c - bitwriter.c - cpu.c - crc.c - fixed.c - fixed_intrin_sse2.c - fixed_intrin_ssse3.c - fixed_intrin_sse42.c - fixed_intrin_avx2.c - float.c - format.c - lpc.c - lpc_intrin_neon.c - lpc_intrin_sse2.c - lpc_intrin_sse41.c - lpc_intrin_avx2.c - lpc_intrin_fma.c - md5.c - memory.c - metadata_iterators.c - metadata_object.c - stream_decoder.c - stream_encoder.c - stream_encoder_intrin_sse2.c - stream_encoder_intrin_ssse3.c - stream_encoder_intrin_avx2.c - stream_encoder_framing.c - version.rc - window.c - $<$:../../include/share/win_utf8_io.h> - $<$:../share/win_utf8_io/win_utf8_io.c> - $<$:ogg_decoder_aspect.c> - $<$:ogg_encoder_aspect.c> - $<$:ogg_helper.c> - $<$:ogg_mapping.c>) -set_property(TARGET FLAC PROPERTY PROJECT_LABEL "libFLAC") -if(TARGET FLAC-asm) - target_sources(FLAC PRIVATE $) -endif() - -target_compile_definitions(FLAC - PRIVATE $<$:FLAC_API_EXPORTS> - PUBLIC $<$>:FLAC__NO_DLL>) -if(NOT WIN32) - target_compile_definitions(FLAC PRIVATE $<$:FLAC__USE_VISIBILITY_ATTR>) -endif() -target_include_directories(FLAC INTERFACE - "$" - "$") -target_link_libraries(FLAC PUBLIC $<$:m>) -if(TARGET Ogg::ogg) - target_link_libraries(FLAC PUBLIC Ogg::ogg) -endif() -if(BUILD_SHARED_LIBS) - set_target_properties(FLAC PROPERTIES - VERSION 12.1.0 - SOVERSION 12) - if(NOT WIN32) - set_target_properties(FLAC PROPERTIES C_VISIBILITY_PRESET hidden) - endif() -endif() - -check_c_compiler_flag("-fassociative-math -fno-signed-zeros -fno-trapping-math -freciprocal-math" HAVE_ASSOC_MATH) - -if(MSVC) - target_compile_options(FLAC BEFORE PRIVATE "/fp:fast") -else() - if(HAVE_ASSOC_MATH) - target_compile_options(FLAC BEFORE PRIVATE -fassociative-math -fno-signed-zeros -fno-trapping-math -freciprocal-math) - endif() -endif() - -add_library(FLAC::FLAC ALIAS FLAC) - -install(TARGETS FLAC EXPORT targets - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") - -if(INSTALL_PKGCONFIG_MODULES) - set(prefix "${CMAKE_INSTALL_PREFIX}") - set(exec_prefix "${CMAKE_INSTALL_PREFIX}") - set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") - set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") - configure_file(flac.pc.in flac.pc @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac.pc" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") -endif() diff --git a/Engine/lib/flac/src/libFLAC/Makefile.am b/Engine/lib/flac/src/libFLAC/Makefile.am deleted file mode 100644 index 618939dfc..000000000 --- a/Engine/lib/flac/src/libFLAC/Makefile.am +++ /dev/null @@ -1,123 +0,0 @@ -# libFLAC - Free Lossless Audio Codec library -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# 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 the Xiph.org Foundation nor the names of its -# 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 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. - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -lib_LTLIBRARIES = libFLAC.la -noinst_LTLIBRARIES = libFLAC-static.la -if DEBUG -DEBUGCFLAGS = -DFLAC__OVERFLOW_DETECT -else -if ASSOC_MATH_AVAILABLE -ASSOCMATHCFLAGS = -fassociative-math -fno-signed-zeros -fno-trapping-math -freciprocal-math -endif -endif - -AM_CFLAGS = $(DEBUGCFLAGS) ${ASSOCMATHCFLAGS} @OGG_CFLAGS@ - -libFLAC_la_LIBADD = @OGG_LIBS@ -lm - -SUBDIRS = include . - -m4datadir = $(datadir)/aclocal -m4data_DATA = libFLAC.m4 - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = flac.pc - -EXTRA_DIST = \ - CMakeLists.txt \ - flac.pc.in \ - libFLAC.m4 \ - version.rc \ - deduplication/bitreader_read_rice_signed_block.c \ - deduplication/lpc_compute_autocorrelation_intrin.c \ - deduplication/lpc_compute_autocorrelation_intrin_sse2.c \ - deduplication/lpc_compute_autocorrelation_intrin_neon.c - -if OS_IS_WINDOWS -windows_unicode_compat = ../share/win_utf8_io/win_utf8_io.c -if HAVE_WINDRES -libFLAC_la_DEPENDENCIES = version.o -windows_resource_link = -Wl,version.o -endif -endif - -if FLaC__HAS_OGG -extra_ogg_sources = \ - ogg_decoder_aspect.c \ - ogg_encoder_aspect.c \ - ogg_helper.c \ - ogg_mapping.c -endif - -# see 'http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning' for numbering convention -libFLAC_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 13:0:1 $(windows_resource_link) - -libFLAC_sources = \ - bitmath.c \ - bitreader.c \ - bitwriter.c \ - cpu.c \ - crc.c \ - fixed.c \ - fixed_intrin_sse2.c \ - fixed_intrin_ssse3.c \ - fixed_intrin_sse42.c \ - fixed_intrin_avx2.c \ - float.c \ - format.c \ - lpc.c \ - lpc_intrin_sse2.c \ - lpc_intrin_sse41.c \ - lpc_intrin_avx2.c \ - lpc_intrin_fma.c \ - lpc_intrin_neon.c \ - md5.c \ - memory.c \ - metadata_iterators.c \ - metadata_object.c \ - stream_decoder.c \ - stream_encoder.c \ - stream_encoder_intrin_sse2.c \ - stream_encoder_intrin_ssse3.c \ - stream_encoder_intrin_avx2.c \ - stream_encoder_framing.c \ - window.c \ - $(windows_unicode_compat) \ - $(extra_ogg_sources) - -libFLAC_la_SOURCES = $(libFLAC_sources) - -# needed for test_libFLAC -libFLAC_static_la_SOURCES = $(libFLAC_sources) - -.rc.o: - $(RC) $(AM_CPPFLAGS) $< $@ diff --git a/Engine/lib/flac/src/libFLAC/bitmath.c b/Engine/lib/flac/src/libFLAC/bitmath.c deleted file mode 100644 index 077486b69..000000000 --- a/Engine/lib/flac/src/libFLAC/bitmath.c +++ /dev/null @@ -1,73 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/bitmath.h" - -/* An example of what FLAC__bitmath_silog2() computes: - * - * silog2(-10) = 5 - * silog2(- 9) = 5 - * silog2(- 8) = 4 - * silog2(- 7) = 4 - * silog2(- 6) = 4 - * silog2(- 5) = 4 - * silog2(- 4) = 3 - * silog2(- 3) = 3 - * silog2(- 2) = 2 - * silog2(- 1) = 2 - * silog2( 0) = 0 - * silog2( 1) = 2 - * silog2( 2) = 3 - * silog2( 3) = 3 - * silog2( 4) = 4 - * silog2( 5) = 4 - * silog2( 6) = 4 - * silog2( 7) = 4 - * silog2( 8) = 5 - * silog2( 9) = 5 - * silog2( 10) = 5 - */ -uint32_t FLAC__bitmath_silog2(FLAC__int64 v) -{ - if(v == 0) - return 0; - - if(v == -1) - return 2; - - v = (v < 0) ? (-(v+1)) : v; - return FLAC__bitmath_ilog2_wide(v)+2; -} diff --git a/Engine/lib/flac/src/libFLAC/bitreader.c b/Engine/lib/flac/src/libFLAC/bitreader.c deleted file mode 100644 index 829b308e0..000000000 --- a/Engine/lib/flac/src/libFLAC/bitreader.c +++ /dev/null @@ -1,1052 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include "private/bitmath.h" -#include "private/bitreader.h" -#include "private/crc.h" -#include "private/cpu.h" -#include "private/macros.h" -#include "FLAC/assert.h" -#include "share/compat.h" -#include "share/endswap.h" - -/* Things should be fastest when this matches the machine word size */ -/* WATCHOUT: if you change this you must also change the following #defines down to COUNT_ZERO_MSBS2 below to match */ -/* WATCHOUT: there are a few places where the code will not work unless brword is >= 32 bits wide */ -/* also, some sections currently only have fast versions for 4 or 8 bytes per word */ - -#if (ENABLE_64_BIT_WORDS == 0) - -typedef FLAC__uint32 brword; -#define FLAC__BYTES_PER_WORD 4 /* sizeof brword */ -#define FLAC__BITS_PER_WORD 32 -#define FLAC__WORD_ALL_ONES ((FLAC__uint32)0xffffffff) -/* SWAP_BE_WORD_TO_HOST swaps bytes in a brword (which is always big-endian) if necessary to match host byte order */ -#if WORDS_BIGENDIAN -#define SWAP_BE_WORD_TO_HOST(x) (x) -#else -#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_32(x) -#endif -/* counts the # of zero MSBs in a word */ -#define COUNT_ZERO_MSBS(word) FLAC__clz_uint32(word) -#define COUNT_ZERO_MSBS2(word) FLAC__clz2_uint32(word) - -#else - -typedef FLAC__uint64 brword; -#define FLAC__BYTES_PER_WORD 8 /* sizeof brword */ -#define FLAC__BITS_PER_WORD 64 -#define FLAC__WORD_ALL_ONES ((FLAC__uint64)FLAC__U64L(0xffffffffffffffff)) -/* SWAP_BE_WORD_TO_HOST swaps bytes in a brword (which is always big-endian) if necessary to match host byte order */ -#if WORDS_BIGENDIAN -#define SWAP_BE_WORD_TO_HOST(x) (x) -#else -#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_64(x) -#endif -/* counts the # of zero MSBs in a word */ -#define COUNT_ZERO_MSBS(word) FLAC__clz_uint64(word) -#define COUNT_ZERO_MSBS2(word) FLAC__clz2_uint64(word) - -#endif - -/* - * This should be at least twice as large as the largest number of words - * required to represent any 'number' (in any encoding) you are going to - * read. With FLAC this is on the order of maybe a few hundred bits. - * If the buffer is smaller than that, the decoder won't be able to read - * in a whole number that is in a variable length encoding (e.g. Rice). - * But to be practical it should be at least 1K bytes. - * - * Increase this number to decrease the number of read callbacks, at the - * expense of using more memory. Or decrease for the reverse effect, - * keeping in mind the limit from the first paragraph. The optimal size - * also depends on the CPU cache size and other factors; some twiddling - * may be necessary to squeeze out the best performance. - */ -static const uint32_t FLAC__BITREADER_DEFAULT_CAPACITY = 65536u / FLAC__BITS_PER_WORD; /* in words */ - -struct FLAC__BitReader { - /* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */ - /* any incomplete word at the tail will be left-justified, and bytes from the read callback are added on the right */ - brword *buffer; - uint32_t capacity; /* in words */ - uint32_t words; /* # of completed words in buffer */ - uint32_t bytes; /* # of bytes in incomplete word at buffer[words] */ - uint32_t consumed_words; /* #words ... */ - uint32_t consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */ - uint32_t read_crc16; /* the running frame CRC */ - uint32_t crc16_offset; /* the number of words in the current buffer that should not be CRC'd */ - uint32_t crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */ - FLAC__bool read_limit_set; /* whether reads are limited */ - uint32_t read_limit; /* the remaining size of what can be read */ - uint32_t last_seen_framesync; /* the location of the last seen framesync, if it is in the buffer, in bits from front of buffer */ - FLAC__BitReaderReadCallback read_callback; - void *client_data; -}; - -static inline void crc16_update_word_(FLAC__BitReader *br, brword word) -{ - register uint32_t crc = br->read_crc16; - - for ( ; br->crc16_align < FLAC__BITS_PER_WORD ; br->crc16_align += 8) { - uint32_t shift = FLAC__BITS_PER_WORD - 8 - br->crc16_align ; - crc = FLAC__CRC16_UPDATE ((uint32_t) (shift < FLAC__BITS_PER_WORD ? (word >> shift) & 0xff : 0), crc); - } - - br->read_crc16 = crc; - br->crc16_align = 0; -} - -static inline void crc16_update_block_(FLAC__BitReader *br) -{ - if(br->consumed_words > br->crc16_offset && br->crc16_align) - crc16_update_word_(br, br->buffer[br->crc16_offset++]); - - /* Prevent OOB read due to wrap-around. */ - if (br->consumed_words > br->crc16_offset) { -#if FLAC__BYTES_PER_WORD == 4 - br->read_crc16 = FLAC__crc16_update_words32(br->buffer + br->crc16_offset, br->consumed_words - br->crc16_offset, br->read_crc16); -#elif FLAC__BYTES_PER_WORD == 8 - br->read_crc16 = FLAC__crc16_update_words64(br->buffer + br->crc16_offset, br->consumed_words - br->crc16_offset, br->read_crc16); -#else - unsigned i; - - for (i = br->crc16_offset; i < br->consumed_words; i++) - crc16_update_word_(br, br->buffer[i]); -#endif - } - - br->crc16_offset = 0; -} - -static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br) -{ - uint32_t start, end; - size_t bytes; - FLAC__byte *target; -#if WORDS_BIGENDIAN -#else - brword preswap_backup; -#endif - - /* first shift the unconsumed buffer data toward the front as much as possible */ - if(br->consumed_words > 0) { - /* invalidate last seen framesync */ - br->last_seen_framesync = -1; - - crc16_update_block_(br); /* CRC consumed words */ - - start = br->consumed_words; - end = br->words + (br->bytes? 1:0); - memmove(br->buffer, br->buffer+start, FLAC__BYTES_PER_WORD * (end - start)); - - br->words -= start; - br->consumed_words = 0; - } - - /* - * set the target for reading, taking into account word alignment and endianness - */ - bytes = (br->capacity - br->words) * FLAC__BYTES_PER_WORD - br->bytes; - if(bytes == 0) - return false; /* no space left, buffer is too small; see note for FLAC__BITREADER_DEFAULT_CAPACITY */ - target = ((FLAC__byte*)(br->buffer+br->words)) + br->bytes; - - /* before reading, if the existing reader looks like this (say brword is 32 bits wide) - * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 (partial tail word is left-justified) - * buffer[BE]: 11 22 33 44 55 ?? ?? ?? (shown laid out as bytes sequentially in memory) - * buffer[LE]: 44 33 22 11 ?? ?? ?? 55 (?? being don't-care) - * ^^-------target, bytes=3 - * on LE machines, have to byteswap the odd tail word so nothing is - * overwritten: - */ -#if WORDS_BIGENDIAN -#else - preswap_backup = br->buffer[br->words]; - if(br->bytes) - br->buffer[br->words] = SWAP_BE_WORD_TO_HOST(br->buffer[br->words]); -#endif - - /* now it looks like: - * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 - * buffer[BE]: 11 22 33 44 55 ?? ?? ?? - * buffer[LE]: 44 33 22 11 55 ?? ?? ?? - * ^^-------target, bytes=3 - */ - - /* read in the data; note that the callback may return a smaller number of bytes */ - if(!br->read_callback(target, &bytes, br->client_data)){ - /* Despite the read callback failing, the data in the target - * might be used later, when the buffer is rewound. Therefore - * we revert the swap that was just done */ -#if WORDS_BIGENDIAN -#else - br->buffer[br->words] = preswap_backup; -#endif - return false; - } - - /* after reading bytes 66 77 88 99 AA BB CC DD EE FF from the client: - * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF - * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ?? - * buffer[LE]: 44 33 22 11 55 66 77 88 99 AA BB CC DD EE FF ?? - * now have to byteswap on LE machines: - */ -#if WORDS_BIGENDIAN -#else - end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + (uint32_t)bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD; - for(start = br->words; start < end; start++) - br->buffer[start] = SWAP_BE_WORD_TO_HOST(br->buffer[start]); -#endif - - /* now it looks like: - * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF - * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ?? - * buffer[LE]: 44 33 22 11 88 77 66 55 CC BB AA 99 ?? FF EE DD - * finally we'll update the reader values: - */ - end = br->words*FLAC__BYTES_PER_WORD + br->bytes + (uint32_t)bytes; - br->words = end / FLAC__BYTES_PER_WORD; - br->bytes = end % FLAC__BYTES_PER_WORD; - - return true; -} - -/*********************************************************************** - * - * Class constructor/destructor - * - ***********************************************************************/ - -FLAC__BitReader *FLAC__bitreader_new(void) -{ - FLAC__BitReader *br = calloc(1, sizeof(FLAC__BitReader)); - - /* calloc() implies: - memset(br, 0, sizeof(FLAC__BitReader)); - br->buffer = 0; - br->capacity = 0; - br->words = br->bytes = 0; - br->consumed_words = br->consumed_bits = 0; - br->read_callback = 0; - br->client_data = 0; - */ - return br; -} - -void FLAC__bitreader_delete(FLAC__BitReader *br) -{ - FLAC__ASSERT(0 != br); - - FLAC__bitreader_free(br); - free(br); -} - -/*********************************************************************** - * - * Public class methods - * - ***********************************************************************/ - -FLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__BitReaderReadCallback rcb, void *cd) -{ - FLAC__ASSERT(0 != br); - - br->words = br->bytes = 0; - br->consumed_words = br->consumed_bits = 0; - br->capacity = FLAC__BITREADER_DEFAULT_CAPACITY; - br->buffer = malloc(sizeof(brword) * br->capacity); - if(br->buffer == 0) - return false; - br->read_callback = rcb; - br->client_data = cd; - br->read_limit_set = false; - br->read_limit = -1; - br->last_seen_framesync = -1; - - return true; -} - -void FLAC__bitreader_free(FLAC__BitReader *br) -{ - FLAC__ASSERT(0 != br); - - if(0 != br->buffer) - free(br->buffer); - br->buffer = 0; - br->capacity = 0; - br->words = br->bytes = 0; - br->consumed_words = br->consumed_bits = 0; - br->read_callback = 0; - br->client_data = 0; - br->read_limit_set = false; - br->read_limit = -1; - br->last_seen_framesync = -1; -} - -FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br) -{ - br->words = br->bytes = 0; - br->consumed_words = br->consumed_bits = 0; - br->read_limit_set = false; - br->read_limit = -1; - br->last_seen_framesync = -1; - return true; -} - -void FLAC__bitreader_set_framesync_location(FLAC__BitReader *br) -{ - br->last_seen_framesync = br->consumed_words * FLAC__BYTES_PER_WORD + br->consumed_bits / 8; -} - -FLAC__bool FLAC__bitreader_rewind_to_after_last_seen_framesync(FLAC__BitReader *br) -{ - if(br->last_seen_framesync == (uint32_t)-1) { - br->consumed_words = br->consumed_bits = 0; - return false; - } - else { - br->consumed_words = (br->last_seen_framesync + 1) / FLAC__BYTES_PER_WORD; - br->consumed_bits = ((br->last_seen_framesync + 1) % FLAC__BYTES_PER_WORD) * 8; - return true; - } -} - -void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed) -{ - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - FLAC__ASSERT((br->consumed_bits & 7) == 0); - - br->read_crc16 = (uint32_t)seed; - br->crc16_offset = br->consumed_words; - br->crc16_align = br->consumed_bits; -} - -FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br) -{ - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - - /* CRC consumed words up to here */ - crc16_update_block_(br); - - FLAC__ASSERT((br->consumed_bits & 7) == 0); - FLAC__ASSERT(br->crc16_align <= br->consumed_bits); - - /* CRC any tail bytes in a partially-consumed word */ - if(br->consumed_bits) { - const brword tail = br->buffer[br->consumed_words]; - for( ; br->crc16_align < br->consumed_bits; br->crc16_align += 8) - br->read_crc16 = FLAC__CRC16_UPDATE((uint32_t)((tail >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), br->read_crc16); - } - return br->read_crc16; -} - -inline FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br) -{ - return ((br->consumed_bits & 7) == 0); -} - -inline uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br) -{ - return 8 - (br->consumed_bits & 7); -} - -inline uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br) -{ - return (br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits; -} - -void FLAC__bitreader_set_limit(FLAC__BitReader *br, uint32_t limit) -{ - br->read_limit = limit; - br->read_limit_set = true; -} - -void FLAC__bitreader_remove_limit(FLAC__BitReader *br) -{ - br->read_limit_set = false; - br->read_limit = -1; -} - -uint32_t FLAC__bitreader_limit_remaining(FLAC__BitReader *br) -{ - FLAC__ASSERT(br->read_limit_set); - return br->read_limit; -} -void FLAC__bitreader_limit_invalidate(FLAC__BitReader *br) -{ - br->read_limit = -1; -} - -FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, uint32_t bits) -{ - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - - FLAC__ASSERT(bits <= 32); - FLAC__ASSERT((br->capacity*FLAC__BITS_PER_WORD) * 2 >= bits); - FLAC__ASSERT(br->consumed_words <= br->words); - - /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ - FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); - - if(bits == 0) { /* OPT: investigate if this can ever happen, maybe change to assertion */ - *val = 0; - return true; - } - - if(br->read_limit_set && br->read_limit < (uint32_t)-1){ - if(br->read_limit < bits) { - br->read_limit = -1; - return false; - } - else - br->read_limit -= bits; - } - - while((br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits < bits) { - if(!bitreader_read_from_client_(br)) - return false; - } - if(br->consumed_words < br->words) { /* if we've not consumed up to a partial tail word... */ - /* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */ - if(br->consumed_bits) { - /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ - const uint32_t n = FLAC__BITS_PER_WORD - br->consumed_bits; - const brword word = br->buffer[br->consumed_words]; - const brword mask = br->consumed_bits < FLAC__BITS_PER_WORD ? FLAC__WORD_ALL_ONES >> br->consumed_bits : 0; - if(bits < n) { - uint32_t shift = n - bits; - *val = shift < FLAC__BITS_PER_WORD ? (FLAC__uint32)((word & mask) >> shift) : 0; /* The result has <= 32 non-zero bits */ - br->consumed_bits += bits; - return true; - } - /* (FLAC__BITS_PER_WORD - br->consumed_bits <= bits) ==> (FLAC__WORD_ALL_ONES >> br->consumed_bits) has no more than 'bits' non-zero bits */ - *val = (FLAC__uint32)(word & mask); - bits -= n; - br->consumed_words++; - br->consumed_bits = 0; - if(bits) { /* if there are still bits left to read, there have to be less than 32 so they will all be in the next word */ - uint32_t shift = FLAC__BITS_PER_WORD - bits; - *val = bits < 32 ? *val << bits : 0; - *val |= shift < FLAC__BITS_PER_WORD ? (FLAC__uint32)(br->buffer[br->consumed_words] >> shift) : 0; - br->consumed_bits = bits; - } - return true; - } - else { /* br->consumed_bits == 0 */ - const brword word = br->buffer[br->consumed_words]; - if(bits < FLAC__BITS_PER_WORD) { - *val = (FLAC__uint32)(word >> (FLAC__BITS_PER_WORD-bits)); - br->consumed_bits = bits; - return true; - } - /* at this point bits == FLAC__BITS_PER_WORD == 32; because of previous assertions, it can't be larger */ - *val = (FLAC__uint32)word; - br->consumed_words++; - return true; - } - } - else { - /* in this case we're starting our read at a partial tail word; - * the reader has guaranteed that we have at least 'bits' bits - * available to read, which makes this case simpler. - */ - /* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */ - if(br->consumed_bits) { - /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ - FLAC__ASSERT(br->consumed_bits + bits <= br->bytes*8); - *val = (FLAC__uint32)((br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (FLAC__BITS_PER_WORD-br->consumed_bits-bits)); - br->consumed_bits += bits; - return true; - } - else { - *val = (FLAC__uint32)(br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits)); - br->consumed_bits += bits; - return true; - } - } -} - -FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, uint32_t bits) -{ - FLAC__uint32 uval, mask; - /* OPT: inline raw uint32 code here, or make into a macro if possible in the .h file */ - if (bits < 1 || ! FLAC__bitreader_read_raw_uint32(br, &uval, bits)) - return false; - /* sign-extend *val assuming it is currently bits wide. */ - /* From: https://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend */ - mask = bits >= 33 ? 0 : 1lu << (bits - 1); - *val = (uval ^ mask) - mask; - return true; -} - -FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, uint32_t bits) -{ - FLAC__uint32 hi, lo; - - if(bits > 32) { - if(!FLAC__bitreader_read_raw_uint32(br, &hi, bits-32)) - return false; - if(!FLAC__bitreader_read_raw_uint32(br, &lo, 32)) - return false; - *val = hi; - *val <<= 32; - *val |= lo; - } - else { - if(!FLAC__bitreader_read_raw_uint32(br, &lo, bits)) - return false; - *val = lo; - } - return true; -} - -FLAC__bool FLAC__bitreader_read_raw_int64(FLAC__BitReader *br, FLAC__int64 *val, uint32_t bits) -{ - FLAC__uint64 uval, mask; - /* OPT: inline raw uint64 code here, or make into a macro if possible in the .h file */ - if (bits < 1 || ! FLAC__bitreader_read_raw_uint64(br, &uval, bits)) - return false; - /* sign-extend *val assuming it is currently bits wide. */ - /* From: https://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend */ - mask = bits >= 65 ? 0 : 1llu << (bits - 1); - *val = (uval ^ mask) - mask; - return true; -} - -inline FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val) -{ - FLAC__uint32 x8, x32 = 0; - - /* this doesn't need to be that fast as currently it is only used for vorbis comments */ - - if(!FLAC__bitreader_read_raw_uint32(br, &x32, 8)) - return false; - - if(!FLAC__bitreader_read_raw_uint32(br, &x8, 8)) - return false; - x32 |= (x8 << 8); - - if(!FLAC__bitreader_read_raw_uint32(br, &x8, 8)) - return false; - x32 |= (x8 << 16); - - if(!FLAC__bitreader_read_raw_uint32(br, &x8, 8)) - return false; - x32 |= (x8 << 24); - - *val = x32; - return true; -} - -FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, uint32_t bits) -{ - /* - * OPT: a faster implementation is possible but probably not that useful - * since this is only called a couple of times in the metadata readers. - */ - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - - if(bits > 0) { - const uint32_t n = br->consumed_bits & 7; - uint32_t m; - FLAC__uint32 x; - - if(n != 0) { - m = flac_min(8-n, bits); - if(!FLAC__bitreader_read_raw_uint32(br, &x, m)) - return false; - bits -= m; - } - m = bits / 8; - if(m > 0) { - if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(br, m)) - return false; - bits %= 8; - } - if(bits > 0) { - if(!FLAC__bitreader_read_raw_uint32(br, &x, bits)) - return false; - } - } - - return true; -} - -FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, uint32_t nvals) -{ - FLAC__uint32 x; - - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(br)); - - if(br->read_limit_set && br->read_limit < (uint32_t)-1){ - if(br->read_limit < nvals*8){ - br->read_limit = -1; - return false; - } - } - - /* step 1: skip over partial head word to get word aligned */ - while(nvals && br->consumed_bits) { /* i.e. run until we read 'nvals' bytes or we hit the end of the head word */ - if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) - return false; - nvals--; - } - if(0 == nvals) - return true; - - /* step 2: skip whole words in chunks */ - while(nvals >= FLAC__BYTES_PER_WORD) { - if(br->consumed_words < br->words) { - br->consumed_words++; - nvals -= FLAC__BYTES_PER_WORD; - if(br->read_limit_set) - br->read_limit -= FLAC__BITS_PER_WORD; - } - else if(!bitreader_read_from_client_(br)) - return false; - } - /* step 3: skip any remainder from partial tail bytes */ - while(nvals) { - if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) - return false; - nvals--; - } - - return true; -} - -FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, uint32_t nvals) -{ - FLAC__uint32 x; - - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(br)); - - if(br->read_limit_set && br->read_limit < (uint32_t)-1){ - if(br->read_limit < nvals*8){ - br->read_limit = -1; - return false; - } - } - - /* step 1: read from partial head word to get word aligned */ - while(nvals && br->consumed_bits) { /* i.e. run until we read 'nvals' bytes or we hit the end of the head word */ - if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) - return false; - *val++ = (FLAC__byte)x; - nvals--; - } - if(0 == nvals) - return true; - /* step 2: read whole words in chunks */ - while(nvals >= FLAC__BYTES_PER_WORD) { - if(br->consumed_words < br->words) { - const brword word = br->buffer[br->consumed_words++]; -#if FLAC__BYTES_PER_WORD == 4 - val[0] = (FLAC__byte)(word >> 24); - val[1] = (FLAC__byte)(word >> 16); - val[2] = (FLAC__byte)(word >> 8); - val[3] = (FLAC__byte)word; -#elif FLAC__BYTES_PER_WORD == 8 - val[0] = (FLAC__byte)(word >> 56); - val[1] = (FLAC__byte)(word >> 48); - val[2] = (FLAC__byte)(word >> 40); - val[3] = (FLAC__byte)(word >> 32); - val[4] = (FLAC__byte)(word >> 24); - val[5] = (FLAC__byte)(word >> 16); - val[6] = (FLAC__byte)(word >> 8); - val[7] = (FLAC__byte)word; -#else - for(x = 0; x < FLAC__BYTES_PER_WORD; x++) - val[x] = (FLAC__byte)(word >> (8*(FLAC__BYTES_PER_WORD-x-1))); -#endif - val += FLAC__BYTES_PER_WORD; - nvals -= FLAC__BYTES_PER_WORD; - if(br->read_limit_set) - br->read_limit -= FLAC__BITS_PER_WORD; - } - else if(!bitreader_read_from_client_(br)) - return false; - } - /* step 3: read any remainder from partial tail bytes */ - while(nvals) { - if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) - return false; - *val++ = (FLAC__byte)x; - nvals--; - } - - return true; -} - -FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, uint32_t *val) -#if 0 /* slow but readable version */ -{ - uint32_t bit; - - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - - *val = 0; - while(1) { - if(!FLAC__bitreader_read_bit(br, &bit)) - return false; - if(bit) - break; - else - *val++; - } - return true; -} -#else -{ - uint32_t i; - - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - - *val = 0; - while(1) { - while(br->consumed_words < br->words) { /* if we've not consumed up to a partial tail word... */ - brword b = br->consumed_bits < FLAC__BITS_PER_WORD ? br->buffer[br->consumed_words] << br->consumed_bits : 0; - if(b) { - i = COUNT_ZERO_MSBS(b); - *val += i; - i++; - br->consumed_bits += i; - if(br->consumed_bits >= FLAC__BITS_PER_WORD) { /* faster way of testing if(br->consumed_bits == FLAC__BITS_PER_WORD) */ - br->consumed_words++; - br->consumed_bits = 0; - } - return true; - } - else { - *val += FLAC__BITS_PER_WORD - br->consumed_bits; - br->consumed_words++; - br->consumed_bits = 0; - /* didn't find stop bit yet, have to keep going... */ - } - } - /* at this point we've eaten up all the whole words; have to try - * reading through any tail bytes before calling the read callback. - * this is a repeat of the above logic adjusted for the fact we - * don't have a whole word. note though if the client is feeding - * us data a byte at a time (unlikely), br->consumed_bits may not - * be zero. - */ - if(br->bytes*8 > br->consumed_bits) { - const uint32_t end = br->bytes * 8; - brword b = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << br->consumed_bits; - if(b) { - i = COUNT_ZERO_MSBS(b); - *val += i; - i++; - br->consumed_bits += i; - FLAC__ASSERT(br->consumed_bits < FLAC__BITS_PER_WORD); - return true; - } - else { - *val += end - br->consumed_bits; - br->consumed_bits = end; - FLAC__ASSERT(br->consumed_bits < FLAC__BITS_PER_WORD); - /* didn't find stop bit yet, have to keep going... */ - } - } - if(!bitreader_read_from_client_(br)) - return false; - } -} -#endif - -#if 0 /* unused */ -FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint32_t parameter) -{ - FLAC__uint32 lsbs = 0, msbs = 0; - uint32_t uval; - - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - FLAC__ASSERT(parameter <= 31); - - /* read the unary MSBs and end bit */ - if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) - return false; - - /* read the binary LSBs */ - if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, parameter)) - return false; - - /* compose the value */ - uval = (msbs << parameter) | lsbs; - if(uval & 1) - *val = -((int)(uval >> 1)) - 1; - else - *val = (int)(uval >> 1); - - return true; -} -#endif - -/* this is by far the most heavily used reader call. it ain't pretty but it's fast */ -FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter) -#include "deduplication/bitreader_read_rice_signed_block.c" - -#ifdef FLAC__BMI2_SUPPORTED -FLAC__SSE_TARGET("bmi2") -FLAC__bool FLAC__bitreader_read_rice_signed_block_bmi2(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter) -#include "deduplication/bitreader_read_rice_signed_block.c" -#endif - -#if 0 /* UNUSED */ -FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter) -{ - FLAC__uint32 lsbs = 0, msbs = 0; - uint32_t bit, uval, k; - - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - - k = FLAC__bitmath_ilog2(parameter); - - /* read the unary MSBs and end bit */ - if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) - return false; - - /* read the binary LSBs */ - if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, k)) - return false; - - if(parameter == 1u<= d) { - if(!FLAC__bitreader_read_bit(br, &bit)) - return false; - lsbs <<= 1; - lsbs |= bit; - lsbs -= d; - } - /* compose the value */ - uval = msbs * parameter + lsbs; - } - - /* unfold uint32_t to signed */ - if(uval & 1) - *val = -((int)(uval >> 1)) - 1; - else - *val = (int)(uval >> 1); - - return true; -} - -FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, uint32_t *val, uint32_t parameter) -{ - FLAC__uint32 lsbs, msbs = 0; - uint32_t bit, k; - - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - - k = FLAC__bitmath_ilog2(parameter); - - /* read the unary MSBs and end bit */ - if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) - return false; - - /* read the binary LSBs */ - if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, k)) - return false; - - if(parameter == 1u<= d) { - if(!FLAC__bitreader_read_bit(br, &bit)) - return false; - lsbs <<= 1; - lsbs |= bit; - lsbs -= d; - } - /* compose the value */ - *val = msbs * parameter + lsbs; - } - - return true; -} -#endif /* UNUSED */ - -/* on return, if *val == 0xffffffff then the utf-8 sequence was invalid, but the return value will be true */ -FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, uint32_t *rawlen) -{ - FLAC__uint32 v = 0; - FLAC__uint32 x; - uint32_t i; - - if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) - return false; - if(raw) - raw[(*rawlen)++] = (FLAC__byte)x; - if(!(x & 0x80)) { /* 0xxxxxxx */ - v = x; - i = 0; - } - else if(x & 0xC0 && !(x & 0x20)) { /* 110xxxxx */ - v = x & 0x1F; - i = 1; - } - else if(x & 0xE0 && !(x & 0x10)) { /* 1110xxxx */ - v = x & 0x0F; - i = 2; - } - else if(x & 0xF0 && !(x & 0x08)) { /* 11110xxx */ - v = x & 0x07; - i = 3; - } - else if(x & 0xF8 && !(x & 0x04)) { /* 111110xx */ - v = x & 0x03; - i = 4; - } - else if(x & 0xFC && !(x & 0x02)) { /* 1111110x */ - v = x & 0x01; - i = 5; - } - else { - *val = 0xffffffff; - return true; - } - for( ; i; i--) { - if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) - return false; - if(raw) - raw[(*rawlen)++] = (FLAC__byte)x; - if(!(x & 0x80) || (x & 0x40)) { /* 10xxxxxx */ - *val = 0xffffffff; - return true; - } - v <<= 6; - v |= (x & 0x3F); - } - *val = v; - return true; -} - -/* on return, if *val == 0xffffffffffffffff then the utf-8 sequence was invalid, but the return value will be true */ -FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, uint32_t *rawlen) -{ - FLAC__uint64 v = 0; - FLAC__uint32 x; - uint32_t i; - - if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) - return false; - if(raw) - raw[(*rawlen)++] = (FLAC__byte)x; - if(!(x & 0x80)) { /* 0xxxxxxx */ - v = x; - i = 0; - } - else if(x & 0xC0 && !(x & 0x20)) { /* 110xxxxx */ - v = x & 0x1F; - i = 1; - } - else if(x & 0xE0 && !(x & 0x10)) { /* 1110xxxx */ - v = x & 0x0F; - i = 2; - } - else if(x & 0xF0 && !(x & 0x08)) { /* 11110xxx */ - v = x & 0x07; - i = 3; - } - else if(x & 0xF8 && !(x & 0x04)) { /* 111110xx */ - v = x & 0x03; - i = 4; - } - else if(x & 0xFC && !(x & 0x02)) { /* 1111110x */ - v = x & 0x01; - i = 5; - } - else if(x & 0xFE && !(x & 0x01)) { /* 11111110 */ - v = 0; - i = 6; - } - else { - *val = FLAC__U64L(0xffffffffffffffff); - return true; - } - for( ; i; i--) { - if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) - return false; - if(raw) - raw[(*rawlen)++] = (FLAC__byte)x; - if(!(x & 0x80) || (x & 0x40)) { /* 10xxxxxx */ - *val = FLAC__U64L(0xffffffffffffffff); - return true; - } - v <<= 6; - v |= (x & 0x3F); - } - *val = v; - return true; -} - -/* These functions are declared inline in this file but are also callable as - * externs from elsewhere. - * According to the C99 spec, section 6.7.4, simply providing a function - * prototype in a header file without 'inline' and making the function inline - * in this file should be sufficient. - * Unfortunately, the Microsoft VS compiler doesn't pick them up externally. To - * fix that we add extern declarations here. - */ -extern FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br); -extern uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br); -extern uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); -extern FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); diff --git a/Engine/lib/flac/src/libFLAC/bitwriter.c b/Engine/lib/flac/src/libFLAC/bitwriter.c deleted file mode 100644 index 1d7be8083..000000000 --- a/Engine/lib/flac/src/libFLAC/bitwriter.c +++ /dev/null @@ -1,955 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include "private/bitwriter.h" -#include "private/crc.h" -#include "private/format.h" -#include "private/macros.h" -#include "private/stream_encoder.h" -#include "FLAC/assert.h" -#include "share/alloc.h" -#include "share/compat.h" -#include "share/endswap.h" - -/* Things should be fastest when this matches the machine word size */ -/* WATCHOUT: if you change this you must also change the following #defines down to SWAP_BE_WORD_TO_HOST below to match */ -/* WATCHOUT: there are a few places where the code will not work unless bwword is >= 32 bits wide */ - -#if (ENABLE_64_BIT_WORDS == 0) - -typedef FLAC__uint32 bwword; -typedef FLAC__uint64 FLAC__bwtemp; -#define FLAC__BYTES_PER_WORD 4 /* sizeof bwword */ -#define FLAC__BITS_PER_WORD 32 -#define FLAC__TEMP_BITS 64 -#define FLAC__HALF_TEMP_BITS 32 -/* SWAP_BE_WORD_TO_HOST swaps bytes in a bwword (which is always big-endian) if necessary to match host byte order */ -#if WORDS_BIGENDIAN -#define SWAP_BE_WORD_TO_HOST(x) (x) -#else -#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_32(x) -#endif - -#else - -typedef FLAC__uint64 bwword; -typedef FLAC__uint64 FLAC__bwtemp; -#define FLAC__BYTES_PER_WORD 8 /* sizeof bwword */ -#define FLAC__BITS_PER_WORD 64 -#define FLAC__TEMP_BITS 64 -#define FLAC__HALF_TEMP_BITS 32 -/* SWAP_BE_WORD_TO_HOST swaps bytes in a bwword (which is always big-endian) if necessary to match host byte order */ -#if WORDS_BIGENDIAN -#define SWAP_BE_WORD_TO_HOST(x) (x) -#else -#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_64(x) -#endif - -#endif - -/* - * The default capacity here doesn't matter too much. The buffer always grows - * to hold whatever is written to it. Usually the encoder will stop adding at - * a frame or metadata block, then write that out and clear the buffer for the - * next one. - */ -static const uint32_t FLAC__BITWRITER_DEFAULT_CAPACITY = 32768u / sizeof(bwword); /* size in words */ -/* When growing, increment 4K at a time */ -static const uint32_t FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(bwword); /* size in words */ - -#define FLAC__WORDS_TO_BITS(words) ((words) * FLAC__BITS_PER_WORD) -#define FLAC__TOTAL_BITS(bw) (FLAC__WORDS_TO_BITS((bw)->words) + (bw)->bits) - -struct FLAC__BitWriter { - bwword *buffer; - bwword accum; /* accumulator; bits are right-justified; when full, accum is appended to buffer */ - uint32_t capacity; /* capacity of buffer in words */ - uint32_t words; /* # of complete words in buffer */ - uint32_t bits; /* # of used bits in accum */ -}; - -/* * WATCHOUT: The current implementation only grows the buffer. */ -#ifndef __SUNPRO_C -static -#endif -FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, uint32_t bits_to_add) -{ - uint32_t new_capacity; - bwword *new_buffer; - - FLAC__ASSERT(0 != bw); - FLAC__ASSERT(0 != bw->buffer); - - /* calculate total words needed to store 'bits_to_add' additional bits */ - new_capacity = bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORD - 1) / FLAC__BITS_PER_WORD); - - /* it's possible (due to pessimism in the growth estimation that - * leads to this call) that we don't actually need to grow - */ - if(bw->capacity >= new_capacity) - return true; - - if(new_capacity * sizeof(bwword) > (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) - /* Requested new capacity is larger than the largest possible metadata block, - * which is also larger than the largest sane framesize. That means something - * went very wrong somewhere and previous checks failed. - * To prevent chrashing, give up */ - return false; - - /* round up capacity increase to the nearest FLAC__BITWRITER_DEFAULT_INCREMENT */ - if((new_capacity - bw->capacity) % FLAC__BITWRITER_DEFAULT_INCREMENT) - new_capacity += FLAC__BITWRITER_DEFAULT_INCREMENT - ((new_capacity - bw->capacity) % FLAC__BITWRITER_DEFAULT_INCREMENT); - /* make sure we got everything right */ - FLAC__ASSERT(0 == (new_capacity - bw->capacity) % FLAC__BITWRITER_DEFAULT_INCREMENT); - FLAC__ASSERT(new_capacity > bw->capacity); - FLAC__ASSERT(new_capacity >= bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORD - 1) / FLAC__BITS_PER_WORD)); - - new_buffer = safe_realloc_nofree_mul_2op_(bw->buffer, sizeof(bwword), /*times*/new_capacity); - if(new_buffer == 0) - return false; - bw->buffer = new_buffer; - bw->capacity = new_capacity; - return true; -} - - -/*********************************************************************** - * - * Class constructor/destructor - * - ***********************************************************************/ - -FLAC__BitWriter *FLAC__bitwriter_new(void) -{ - FLAC__BitWriter *bw = calloc(1, sizeof(FLAC__BitWriter)); - /* note that calloc() sets all members to 0 for us */ - return bw; -} - -void FLAC__bitwriter_delete(FLAC__BitWriter *bw) -{ - FLAC__ASSERT(0 != bw); - - FLAC__bitwriter_free(bw); - free(bw); -} - -/*********************************************************************** - * - * Public class methods - * - ***********************************************************************/ - -FLAC__bool FLAC__bitwriter_init(FLAC__BitWriter *bw) -{ - FLAC__ASSERT(0 != bw); - - bw->words = bw->bits = 0; - bw->capacity = FLAC__BITWRITER_DEFAULT_CAPACITY; - bw->buffer = malloc(sizeof(bwword) * bw->capacity); - if(bw->buffer == 0) - return false; - - return true; -} - -void FLAC__bitwriter_free(FLAC__BitWriter *bw) -{ - FLAC__ASSERT(0 != bw); - - if(0 != bw->buffer) - free(bw->buffer); - bw->buffer = 0; - bw->capacity = 0; - bw->words = bw->bits = 0; -} - -void FLAC__bitwriter_clear(FLAC__BitWriter *bw) -{ - bw->words = bw->bits = 0; -} - -FLAC__bool FLAC__bitwriter_get_write_crc16(FLAC__BitWriter *bw, FLAC__uint16 *crc) -{ - const FLAC__byte *buffer; - size_t bytes; - - FLAC__ASSERT((bw->bits & 7) == 0); /* assert that we're byte-aligned */ - - if(!FLAC__bitwriter_get_buffer(bw, &buffer, &bytes)) - return false; - - *crc = (FLAC__uint16)FLAC__crc16(buffer, bytes); - FLAC__bitwriter_release_buffer(bw); - return true; -} - -FLAC__bool FLAC__bitwriter_get_write_crc8(FLAC__BitWriter *bw, FLAC__byte *crc) -{ - const FLAC__byte *buffer; - size_t bytes; - - FLAC__ASSERT((bw->bits & 7) == 0); /* assert that we're byte-aligned */ - - if(!FLAC__bitwriter_get_buffer(bw, &buffer, &bytes)) - return false; - - *crc = FLAC__crc8(buffer, bytes); - FLAC__bitwriter_release_buffer(bw); - return true; -} - -FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw) -{ - return ((bw->bits & 7) == 0); -} - -uint32_t FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw) -{ - return FLAC__TOTAL_BITS(bw); -} - -FLAC__bool FLAC__bitwriter_get_buffer(FLAC__BitWriter *bw, const FLAC__byte **buffer, size_t *bytes) -{ - FLAC__ASSERT((bw->bits & 7) == 0); - /* double protection */ - if(bw->bits & 7) - return false; - /* if we have bits in the accumulator we have to flush those to the buffer first */ - if(bw->bits) { - FLAC__ASSERT(bw->words <= bw->capacity); - if(bw->words == bw->capacity && !bitwriter_grow_(bw, FLAC__BITS_PER_WORD)) - return false; - /* append bits as complete word to buffer, but don't change bw->accum or bw->bits */ - bw->buffer[bw->words] = SWAP_BE_WORD_TO_HOST(bw->accum << (FLAC__BITS_PER_WORD-bw->bits)); - } - /* now we can just return what we have */ - *buffer = (FLAC__byte*)bw->buffer; - *bytes = (FLAC__BYTES_PER_WORD * bw->words) + (bw->bits >> 3); - return true; -} - -void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw) -{ - /* nothing to do. in the future, strict checking of a 'writer-is-in- - * get-mode' flag could be added everywhere and then cleared here - */ - (void)bw; -} - -inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits) -{ - uint32_t n; - - FLAC__ASSERT(0 != bw); - FLAC__ASSERT(0 != bw->buffer); - - if(bits == 0) - return true; - /* slightly pessimistic size check but faster than "<= bw->words + (bw->bits+bits+FLAC__BITS_PER_WORD-1)/FLAC__BITS_PER_WORD" */ - if(bw->capacity <= bw->words + bits && !bitwriter_grow_(bw, bits)) - return false; - /* first part gets to word alignment */ - if(bw->bits) { - n = flac_min(FLAC__BITS_PER_WORD - bw->bits, bits); - bw->accum <<= n; - bits -= n; - bw->bits += n; - if(bw->bits == FLAC__BITS_PER_WORD) { - bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum); - bw->bits = 0; - } - else - return true; - } - /* do whole words */ - while(bits >= FLAC__BITS_PER_WORD) { - bw->buffer[bw->words++] = 0; - bits -= FLAC__BITS_PER_WORD; - } - /* do any leftovers */ - if(bits > 0) { - bw->accum = 0; - bw->bits = bits; - } - return true; -} - -static inline FLAC__bool FLAC__bitwriter_write_raw_uint32_nocheck(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits) -{ - register uint32_t left; - - /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ - FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); - - if(bw == 0 || bw->buffer == 0) - return false; - - if (bits > 32) - return false; - - if(bits == 0) - return true; - - FLAC__ASSERT((bits == 32) || (val>>bits == 0)); - - /* slightly pessimistic size check but faster than "<= bw->words + (bw->bits+bits+FLAC__BITS_PER_WORD-1)/FLAC__BITS_PER_WORD" */ - if(bw->capacity <= bw->words + bits && !bitwriter_grow_(bw, bits)) - return false; - - left = FLAC__BITS_PER_WORD - bw->bits; - if(bits < left) { - bw->accum <<= bits; - bw->accum |= val; - bw->bits += bits; - } - else if(bw->bits) { /* WATCHOUT: if bw->bits == 0, left==FLAC__BITS_PER_WORD and bw->accum<<=left is a NOP instead of setting to 0 */ - bw->accum <<= left; - bw->accum |= val >> (bw->bits = bits - left); - bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum); - bw->accum = val; /* unused top bits can contain garbage */ - } - else { /* at this point bits == FLAC__BITS_PER_WORD == 32 and bw->bits == 0 */ - bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST((bwword)val); - } - - return true; -} - -inline FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits) -{ - /* check that unused bits are unset */ - if((bits < 32) && (val>>bits != 0)) - return false; - - return FLAC__bitwriter_write_raw_uint32_nocheck(bw, val, bits); -} - -inline FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t bits) -{ - /* zero-out unused bits */ - if(bits < 32) - val &= (~(0xffffffff << bits)); - - return FLAC__bitwriter_write_raw_uint32_nocheck(bw, (FLAC__uint32)val, bits); -} - -inline FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, uint32_t bits) -{ - /* this could be a little faster but it's not used for much */ - if(bits > 32) { - return - FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)(val>>32), bits-32) && - FLAC__bitwriter_write_raw_uint32_nocheck(bw, (FLAC__uint32)val, 32); - } - else - return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, bits); -} - -inline FLAC__bool FLAC__bitwriter_write_raw_int64(FLAC__BitWriter *bw, FLAC__int64 val, uint32_t bits) -{ - FLAC__uint64 uval = val; - /* zero-out unused bits */ - if(bits < 64) - uval &= (~(UINT64_MAX << bits)); - return FLAC__bitwriter_write_raw_uint64(bw, uval, bits); -} - -inline FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val) -{ - /* this doesn't need to be that fast as currently it is only used for vorbis comments */ - - if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, val & 0xff, 8)) - return false; - if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, (val>>8) & 0xff, 8)) - return false; - if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, (val>>16) & 0xff, 8)) - return false; - if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, val>>24, 8)) - return false; - - return true; -} - -inline FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], uint32_t nvals) -{ - uint32_t i; - - /* grow capacity upfront to prevent constant reallocation during writes */ - if(bw->capacity <= bw->words + nvals / (FLAC__BITS_PER_WORD / 8) + 1 && !bitwriter_grow_(bw, nvals * 8)) - return false; - - /* this could be faster but currently we don't need it to be since it's only used for writing metadata */ - for(i = 0; i < nvals; i++) { - if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, (FLAC__uint32)(vals[i]), 8)) - return false; - } - - return true; -} - -FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, uint32_t val) -{ - if(val < 32) - return FLAC__bitwriter_write_raw_uint32_nocheck(bw, 1, ++val); - else - return - FLAC__bitwriter_write_zeroes(bw, val) && - FLAC__bitwriter_write_raw_uint32_nocheck(bw, 1, 1); -} - -#if 0 /* UNUSED */ -uint32_t FLAC__bitwriter_rice_bits(FLAC__int32 val, uint32_t parameter) -{ - FLAC__uint32 uval; - - FLAC__ASSERT(parameter < 32); - - /* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */ - uval = val; - uval <<= 1; - uval ^= (val>>31); - - return 1 + parameter + (uval >> parameter); -} - -uint32_t FLAC__bitwriter_golomb_bits_signed(int val, uint32_t parameter) -{ - uint32_t bits, msbs, uval; - uint32_t k; - - FLAC__ASSERT(parameter > 0); - - /* fold signed to uint32_t */ - if(val < 0) - uval = (uint32_t)(((-(++val)) << 1) + 1); - else - uval = (uint32_t)(val << 1); - - k = FLAC__bitmath_ilog2(parameter); - if(parameter == 1u<> k; - bits = 1 + k + msbs; - } - else { - uint32_t q, r, d; - - d = (1 << (k+1)) - parameter; - q = uval / parameter; - r = uval - (q * parameter); - - bits = 1 + q + k; - if(r >= d) - bits++; - } - return bits; -} - -uint32_t FLAC__bitwriter_golomb_bits_unsigned(uint32_t uval, uint32_t parameter) -{ - uint32_t bits, msbs; - uint32_t k; - - FLAC__ASSERT(parameter > 0); - - k = FLAC__bitmath_ilog2(parameter); - if(parameter == 1u<> k; - bits = 1 + k + msbs; - } - else { - uint32_t q, r, d; - - d = (1 << (k+1)) - parameter; - q = uval / parameter; - r = uval - (q * parameter); - - bits = 1 + q + k; - if(r >= d) - bits++; - } - return bits; -} - -FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t parameter) -{ - uint32_t total_bits, interesting_bits, msbs; - FLAC__uint32 uval, pattern; - - FLAC__ASSERT(0 != bw); - FLAC__ASSERT(0 != bw->buffer); - FLAC__ASSERT(parameter < 32); - - /* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */ - uval = val; - uval <<= 1; - uval ^= (val>>31); - - msbs = uval >> parameter; - interesting_bits = 1 + parameter; - total_bits = interesting_bits + msbs; - pattern = 1 << parameter; /* the unary end bit */ - pattern |= (uval & ((1<accum = wide_accum >> FLAC__HALF_TEMP_BITS; \ - bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum); \ - wide_accum <<= FLAC__HALF_TEMP_BITS; \ - bitpointer += FLAC__HALF_TEMP_BITS; \ -} - -#else - -#define WIDE_ACCUM_TO_BW { \ - FLAC__ASSERT(bw->bits % FLAC__HALF_TEMP_BITS == 0); \ - if(bw->bits == 0) { \ - bw->accum = wide_accum >> FLAC__HALF_TEMP_BITS; \ - wide_accum <<= FLAC__HALF_TEMP_BITS; \ - bw->bits = FLAC__HALF_TEMP_BITS; \ - } \ - else { \ - bw->accum <<= FLAC__HALF_TEMP_BITS; \ - bw->accum += wide_accum >> FLAC__HALF_TEMP_BITS; \ - bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum); \ - wide_accum <<= FLAC__HALF_TEMP_BITS; \ - bw->bits = 0; \ - } \ - bitpointer += FLAC__HALF_TEMP_BITS; \ -} - -#endif - -FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, uint32_t nvals, uint32_t parameter) -{ - const FLAC__uint32 mask1 = (FLAC__uint32)0xffffffff << parameter; /* we val|=mask1 to set the stop bit above it... */ - const FLAC__uint32 mask2 = (FLAC__uint32)0xffffffff >> (31-parameter); /* ...then mask off the bits above the stop bit with val&=mask2 */ - FLAC__uint32 uval; - const uint32_t lsbits = 1 + parameter; - uint32_t msbits, total_bits; - FLAC__bwtemp wide_accum = 0; - FLAC__uint32 bitpointer = FLAC__TEMP_BITS; - - FLAC__ASSERT(0 != bw); - FLAC__ASSERT(0 != bw->buffer); - FLAC__ASSERT(parameter < 31); - /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ - FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); -#if (ENABLE_64_BIT_WORDS == 0) - if(bw->bits > 0) { - bitpointer -= bw->bits; - wide_accum = (FLAC__bwtemp)(bw->accum) << bitpointer; - bw->bits = 0; - } -#else - if(bw->bits > 0 && bw->bits < FLAC__HALF_TEMP_BITS) { - bitpointer -= bw->bits; - wide_accum = bw->accum << bitpointer; - bw->bits = 0; - } - else if(bw->bits > FLAC__HALF_TEMP_BITS) { - bitpointer -= (bw->bits - FLAC__HALF_TEMP_BITS); - wide_accum = bw->accum << bitpointer; - bw->accum >>= (bw->bits - FLAC__HALF_TEMP_BITS); - bw->bits = FLAC__HALF_TEMP_BITS; - } -#endif - - /* Reserve one FLAC__TEMP_BITS per symbol, so checks for space are only necessary when very large symbols are encountered - * this might be considered wasteful, but is only at most 8kB more than necessary for a blocksize of 4096 */ - if(bw->capacity * FLAC__BITS_PER_WORD <= bw->words * FLAC__BITS_PER_WORD + nvals * FLAC__TEMP_BITS + bw->bits && !bitwriter_grow_(bw, nvals * FLAC__TEMP_BITS)) - return false; - - while(nvals) { - /* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */ - uval = *vals; - uval <<= 1; - uval ^= (*vals>>31); - - msbits = uval >> parameter; - total_bits = lsbits + msbits; - - uval |= mask1; /* set stop bit */ - uval &= mask2; /* mask off unused top bits */ - - - if(total_bits <= bitpointer) { - /* There is room enough to store the symbol whole at once */ - wide_accum |= (FLAC__bwtemp)(uval) << (bitpointer - total_bits); - bitpointer -= total_bits; - if(bitpointer <= FLAC__HALF_TEMP_BITS) { - /* A word is finished, copy the upper 32 bits of the wide_accum */ - WIDE_ACCUM_TO_BW - } - } - else { - /* The symbol needs to be split. This code isn't used often */ - /* First check for space in the bitwriter */ - if(total_bits > FLAC__TEMP_BITS) { - FLAC__uint32 oversize_in_bits = total_bits - FLAC__TEMP_BITS; - FLAC__uint32 capacity_needed = bw->words * FLAC__BITS_PER_WORD + bw->bits + nvals * FLAC__TEMP_BITS + oversize_in_bits; - if(bw->capacity * FLAC__BITS_PER_WORD <= capacity_needed && !bitwriter_grow_(bw, nvals * FLAC__TEMP_BITS + oversize_in_bits)) - return false; - } - if(msbits > bitpointer) { - /* We have a lot of 0 bits to write, first align with bitwriter word */ - msbits -= bitpointer - FLAC__HALF_TEMP_BITS; - bitpointer = FLAC__HALF_TEMP_BITS; - WIDE_ACCUM_TO_BW - while(msbits > bitpointer) { - /* As the accumulator is already zero, we only need to - * assign zeroes to the bitbuffer */ - WIDE_ACCUM_TO_BW - bitpointer -= FLAC__HALF_TEMP_BITS; - msbits -= FLAC__HALF_TEMP_BITS; - } - /* The remaining bits are zero, and the accumulator already is zero, - * so just subtract the number of bits from bitpointer. When storing, - * we can also just store 0 */ - bitpointer -= msbits; - if(bitpointer <= FLAC__HALF_TEMP_BITS) - WIDE_ACCUM_TO_BW - } - else { - bitpointer -= msbits; - if(bitpointer <= FLAC__HALF_TEMP_BITS) - WIDE_ACCUM_TO_BW - } - /* The lsbs + stop bit always fit 32 bit, so this code mirrors the code above */ - wide_accum |= (FLAC__bwtemp)(uval) << (bitpointer - lsbits); - bitpointer -= lsbits; - if(bitpointer <= FLAC__HALF_TEMP_BITS) { - /* A word is finished, copy the upper 32 bits of the wide_accum */ - WIDE_ACCUM_TO_BW - } - } - vals++; - nvals--; - } - /* Now fixup remainder of wide_accum */ -#if (ENABLE_64_BIT_WORDS == 0) - if(bitpointer < FLAC__TEMP_BITS) { - bw->accum = wide_accum >> bitpointer; - bw->bits = FLAC__TEMP_BITS - bitpointer; - } -#else - if(bitpointer < FLAC__TEMP_BITS) { - if(bw->bits == 0) { - bw->accum = wide_accum >> bitpointer; - bw->bits = FLAC__TEMP_BITS - bitpointer; - } - else if (bw->bits == FLAC__HALF_TEMP_BITS) { - bw->accum <<= FLAC__TEMP_BITS - bitpointer; - bw->accum |= (wide_accum >> bitpointer); - bw->bits = FLAC__HALF_TEMP_BITS + FLAC__TEMP_BITS - bitpointer; - } - else { - FLAC__ASSERT(0); - } - } -#endif - - - return true; -} - -#if 0 /* UNUSED */ -FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uint32_t parameter) -{ - uint32_t total_bits, msbs, uval; - uint32_t k; - - FLAC__ASSERT(0 != bw); - FLAC__ASSERT(0 != bw->buffer); - FLAC__ASSERT(parameter > 0); - - /* fold signed to uint32_t */ - if(val < 0) - uval = (uint32_t)(((-(++val)) << 1) + 1); - else - uval = (uint32_t)(val << 1); - - k = FLAC__bitmath_ilog2(parameter); - if(parameter == 1u<> k; - total_bits = 1 + k + msbs; - pattern = 1 << k; /* the unary end bit */ - pattern |= (uval & ((1u<= d) { - if(!FLAC__bitwriter_write_raw_uint32(bw, r+d, k+1)) - return false; - } - else { - if(!FLAC__bitwriter_write_raw_uint32(bw, r, k)) - return false; - } - } - return true; -} - -FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, uint32_t uval, uint32_t parameter) -{ - uint32_t total_bits, msbs; - uint32_t k; - - FLAC__ASSERT(0 != bw); - FLAC__ASSERT(0 != bw->buffer); - FLAC__ASSERT(parameter > 0); - - k = FLAC__bitmath_ilog2(parameter); - if(parameter == 1u<> k; - total_bits = 1 + k + msbs; - pattern = 1 << k; /* the unary end bit */ - pattern |= (uval & ((1u<= d) { - if(!FLAC__bitwriter_write_raw_uint32(bw, r+d, k+1)) - return false; - } - else { - if(!FLAC__bitwriter_write_raw_uint32(bw, r, k)) - return false; - } - } - return true; -} -#endif /* UNUSED */ - -FLAC__bool FLAC__bitwriter_write_utf8_uint32(FLAC__BitWriter *bw, FLAC__uint32 val) -{ - FLAC__bool ok = 1; - - FLAC__ASSERT(0 != bw); - FLAC__ASSERT(0 != bw->buffer); - - if((val & 0x80000000) != 0) /* this version only handles 31 bits */ - return false; - - if(val < 0x80) { - return FLAC__bitwriter_write_raw_uint32_nocheck(bw, val, 8); - } - else if(val < 0x800) { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xC0 | (val>>6), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8); - } - else if(val < 0x10000) { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xE0 | (val>>12), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>6)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8); - } - else if(val < 0x200000) { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xF0 | (val>>18), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>12)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>6)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8); - } - else if(val < 0x4000000) { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xF8 | (val>>24), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>18)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>12)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>6)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8); - } - else { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xFC | (val>>30), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>24)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>18)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>12)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>6)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8); - } - - return ok; -} - -FLAC__bool FLAC__bitwriter_write_utf8_uint64(FLAC__BitWriter *bw, FLAC__uint64 val) -{ - FLAC__bool ok = 1; - - FLAC__ASSERT(0 != bw); - FLAC__ASSERT(0 != bw->buffer); - - if((val & FLAC__U64L(0xFFFFFFF000000000)) != 0) /* this version only handles 36 bits */ - return false; - - if(val < 0x80) { - return FLAC__bitwriter_write_raw_uint32_nocheck(bw, (FLAC__uint32)val, 8); - } - else if(val < 0x800) { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xC0 | (FLAC__uint32)(val>>6), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8); - } - else if(val < 0x10000) { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xE0 | (FLAC__uint32)(val>>12), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8); - } - else if(val < 0x200000) { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xF0 | (FLAC__uint32)(val>>18), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8); - } - else if(val < 0x4000000) { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xF8 | (FLAC__uint32)(val>>24), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8); - } - else if(val < 0x80000000) { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xFC | (FLAC__uint32)(val>>30), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8); - } - else { - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xFE, 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>30)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8); - } - - return ok; -} - -FLAC__bool FLAC__bitwriter_zero_pad_to_byte_boundary(FLAC__BitWriter *bw) -{ - /* 0-pad to byte boundary */ - if(bw->bits & 7u) - return FLAC__bitwriter_write_zeroes(bw, 8 - (bw->bits & 7u)); - else - return true; -} - -/* These functions are declared inline in this file but are also callable as - * externs from elsewhere. - * According to the C99 spec, section 6.7.4, simply providing a function - * prototype in a header file without 'inline' and making the function inline - * in this file should be sufficient. - * Unfortunately, the Microsoft VS compiler doesn't pick them up externally. To - * fix that we add extern declarations here. - */ -extern FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits); -extern FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits); -extern FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t bits); -extern FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, uint32_t bits); -extern FLAC__bool FLAC__bitwriter_write_raw_int64(FLAC__BitWriter *bw, FLAC__int64 val, uint32_t bits); -extern FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val); -extern FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], uint32_t nvals); diff --git a/Engine/lib/flac/src/libFLAC/cpu.c b/Engine/lib/flac/src/libFLAC/cpu.c deleted file mode 100644 index d088e3c0b..000000000 --- a/Engine/lib/flac/src/libFLAC/cpu.c +++ /dev/null @@ -1,255 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" -#include "share/compat.h" -#include -#include - -#if defined _MSC_VER -#include /* for __cpuid() and _xgetbv() */ -#elif defined __GNUC__ && defined HAVE_CPUID_H -#include /* for __get_cpuid() and __get_cpuid_max() */ -#endif - -#ifndef NDEBUG -#include -#define dfprintf fprintf -#else -/* This is bad practice, it should be a static void empty function */ -#define dfprintf(file, format, ...) -#endif - -#if defined(HAVE_SYS_AUXV_H) -#include -#endif - -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN && !defined FLAC__NO_ASM - -/* these are flags in EDX of CPUID AX=00000001 */ -static const uint32_t FLAC__CPUINFO_X86_CPUID_CMOV = 0x00008000; -static const uint32_t FLAC__CPUINFO_X86_CPUID_MMX = 0x00800000; -static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE = 0x02000000; -static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE2 = 0x04000000; - -/* these are flags in ECX of CPUID AX=00000001 */ -static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE3 = 0x00000001; -static const uint32_t FLAC__CPUINFO_X86_CPUID_SSSE3 = 0x00000200; -static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE41 = 0x00080000; -static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE42 = 0x00100000; -static const uint32_t FLAC__CPUINFO_X86_CPUID_OSXSAVE = 0x08000000; -static const uint32_t FLAC__CPUINFO_X86_CPUID_AVX = 0x10000000; -static const uint32_t FLAC__CPUINFO_X86_CPUID_FMA = 0x00001000; - -/* these are flags in EBX of CPUID AX=00000007 */ -static const uint32_t FLAC__CPUINFO_X86_CPUID_AVX2 = 0x00000020; -static const uint32_t FLAC__CPUINFO_X86_CPUID_BMI2 = 0x00000100; - -static uint32_t -cpu_xgetbv_x86(void) -{ -#if (defined _MSC_VER || defined __INTEL_COMPILER) && FLAC__AVX_SUPPORTED - return (uint32_t)_xgetbv(0); -#elif defined __GNUC__ - uint32_t lo, hi; - __asm__ volatile (".byte 0x0f, 0x01, 0xd0" : "=a"(lo), "=d"(hi) : "c" (0)); - return lo; -#else - return 0; -#endif -} - -static uint32_t -cpu_have_cpuid(void) -{ -#if defined FLAC__CPU_X86_64 || defined __i686__ || defined __SSE__ || (defined _M_IX86_FP && _M_IX86_FP > 0) - /* target CPU does have CPUID instruction */ - return 1; -#elif defined __GNUC__ && defined HAVE_CPUID_H - if (__get_cpuid_max(0, 0) != 0) - return 1; - else - return 0; -#elif defined _MSC_VER - FLAC__uint32 flags1, flags2; - __asm { - pushfd - pushfd - pop eax - mov flags1, eax - xor eax, 0x200000 - push eax - popfd - pushfd - pop eax - mov flags2, eax - popfd - } - if (((flags1^flags2) & 0x200000) != 0) - return 1; - else - return 0; -#else - return 0; -#endif -} - -static void -cpuinfo_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx) -{ -#if defined _MSC_VER - int cpuinfo[4]; - int ext = level & 0x80000000; - __cpuid(cpuinfo, ext); - if ((uint32_t)cpuinfo[0] >= level) { -#if FLAC__AVX_SUPPORTED - __cpuidex(cpuinfo, level, 0); /* for AVX2 detection */ -#else - __cpuid(cpuinfo, level); /* some old compilers don't support __cpuidex */ -#endif - *eax = cpuinfo[0]; *ebx = cpuinfo[1]; *ecx = cpuinfo[2]; *edx = cpuinfo[3]; - return; - } -#elif defined __GNUC__ && defined HAVE_CPUID_H - FLAC__uint32 ext = level & 0x80000000; - __cpuid(ext, *eax, *ebx, *ecx, *edx); - if (*eax >= level) { - __cpuid_count(level, 0, *eax, *ebx, *ecx, *edx); - return; - } -#endif - *eax = *ebx = *ecx = *edx = 0; -} - -#endif - -static void -x86_cpu_info (FLAC__CPUInfo *info) -{ -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN && !defined FLAC__NO_ASM - FLAC__bool x86_osxsave = false; - FLAC__bool os_avx = false; - FLAC__uint32 flags_eax, flags_ebx, flags_ecx, flags_edx; - - info->use_asm = true; /* we assume a minimum of 80386 */ - if (!cpu_have_cpuid()) - return; - - cpuinfo_x86(0, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx); - info->x86.intel = (flags_ebx == 0x756E6547 && flags_edx == 0x49656E69 && flags_ecx == 0x6C65746E) ? true : false; /* GenuineIntel */ - cpuinfo_x86(1, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx); - - info->x86.cmov = (flags_edx & FLAC__CPUINFO_X86_CPUID_CMOV ) ? true : false; - info->x86.mmx = (flags_edx & FLAC__CPUINFO_X86_CPUID_MMX ) ? true : false; - info->x86.sse = (flags_edx & FLAC__CPUINFO_X86_CPUID_SSE ) ? true : false; - info->x86.sse2 = (flags_edx & FLAC__CPUINFO_X86_CPUID_SSE2 ) ? true : false; - info->x86.sse3 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE3 ) ? true : false; - info->x86.ssse3 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSSE3) ? true : false; - info->x86.sse41 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE41) ? true : false; - info->x86.sse42 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE42) ? true : false; - - if (FLAC__AVX_SUPPORTED) { - x86_osxsave = (flags_ecx & FLAC__CPUINFO_X86_CPUID_OSXSAVE) ? true : false; - info->x86.avx = (flags_ecx & FLAC__CPUINFO_X86_CPUID_AVX ) ? true : false; - info->x86.fma = (flags_ecx & FLAC__CPUINFO_X86_CPUID_FMA ) ? true : false; - cpuinfo_x86(7, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx); - info->x86.avx2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_AVX2 ) ? true : false; - info->x86.bmi2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_BMI2 ) ? true : false; - } - -#if defined FLAC__CPU_IA32 - dfprintf(stderr, "CPU info (IA-32):\n"); -#else - dfprintf(stderr, "CPU info (x86-64):\n"); -#endif - dfprintf(stderr, " CMOV ....... %c\n", info->x86.cmov ? 'Y' : 'n'); - dfprintf(stderr, " MMX ........ %c\n", info->x86.mmx ? 'Y' : 'n'); - dfprintf(stderr, " SSE ........ %c\n", info->x86.sse ? 'Y' : 'n'); - dfprintf(stderr, " SSE2 ....... %c\n", info->x86.sse2 ? 'Y' : 'n'); - dfprintf(stderr, " SSE3 ....... %c\n", info->x86.sse3 ? 'Y' : 'n'); - dfprintf(stderr, " SSSE3 ...... %c\n", info->x86.ssse3 ? 'Y' : 'n'); - dfprintf(stderr, " SSE41 ...... %c\n", info->x86.sse41 ? 'Y' : 'n'); - dfprintf(stderr, " SSE42 ...... %c\n", info->x86.sse42 ? 'Y' : 'n'); - - if (FLAC__AVX_SUPPORTED) { - dfprintf(stderr, " AVX ........ %c\n", info->x86.avx ? 'Y' : 'n'); - dfprintf(stderr, " FMA ........ %c\n", info->x86.fma ? 'Y' : 'n'); - dfprintf(stderr, " AVX2 ....... %c\n", info->x86.avx2 ? 'Y' : 'n'); - dfprintf(stderr, " BMI2 ....... %c\n", info->x86.bmi2 ? 'Y' : 'n'); - } - - /* - * now have to check for OS support of AVX instructions - */ - if (FLAC__AVX_SUPPORTED && info->x86.avx && x86_osxsave && (cpu_xgetbv_x86() & 0x6) == 0x6) { - os_avx = true; - } - if (os_avx) { - dfprintf(stderr, " AVX OS sup . %c\n", info->x86.avx ? 'Y' : 'n'); - } - if (!os_avx) { - /* no OS AVX support */ - info->x86.avx = false; - info->x86.avx2 = false; - info->x86.fma = false; - } -#else - info->use_asm = false; -#endif -} - -void FLAC__cpu_info (FLAC__CPUInfo *info) -{ - memset(info, 0, sizeof(*info)); - -#ifdef FLAC__CPU_IA32 - info->type = FLAC__CPUINFO_TYPE_IA32; -#elif defined FLAC__CPU_X86_64 - info->type = FLAC__CPUINFO_TYPE_X86_64; -#else - info->type = FLAC__CPUINFO_TYPE_UNKNOWN; -#endif - - switch (info->type) { - case FLAC__CPUINFO_TYPE_IA32: /* fallthrough */ - case FLAC__CPUINFO_TYPE_X86_64: - x86_cpu_info (info); - break; - default: - info->use_asm = false; - break; - } -} diff --git a/Engine/lib/flac/src/libFLAC/crc.c b/Engine/lib/flac/src/libFLAC/crc.c deleted file mode 100644 index 9e488e9bc..000000000 --- a/Engine/lib/flac/src/libFLAC/crc.c +++ /dev/null @@ -1,436 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/crc.h" - -/* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */ - -FLAC__uint8 const FLAC__crc8_table[256] = { - 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, - 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, - 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, - 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, - 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, - 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD, - 0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, - 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD, - 0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, - 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA, - 0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, - 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A, - 0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, - 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A, - 0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, - 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A, - 0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, - 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4, - 0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, - 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4, - 0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, - 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44, - 0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, - 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34, - 0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, - 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63, - 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, - 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, - 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, - 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83, - 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, - 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3 -}; - -/* CRC-16, poly = x^16 + x^15 + x^2 + x^0, init = 0 */ - -FLAC__uint16 const FLAC__crc16_table[8][256] = { - { 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, - 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, - 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, - 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041, - 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2, - 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1, - 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1, - 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082, - 0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192, - 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1, - 0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1, - 0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2, - 0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151, - 0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162, - 0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132, - 0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101, - 0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312, - 0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321, - 0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371, - 0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342, - 0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1, - 0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2, - 0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2, - 0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381, - 0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291, - 0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2, - 0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2, - 0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1, - 0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252, - 0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261, - 0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231, - 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202 }, - - { 0x0000, 0x8603, 0x8c03, 0x0a00, 0x9803, 0x1e00, 0x1400, 0x9203, - 0xb003, 0x3600, 0x3c00, 0xba03, 0x2800, 0xae03, 0xa403, 0x2200, - 0xe003, 0x6600, 0x6c00, 0xea03, 0x7800, 0xfe03, 0xf403, 0x7200, - 0x5000, 0xd603, 0xdc03, 0x5a00, 0xc803, 0x4e00, 0x4400, 0xc203, - 0x4003, 0xc600, 0xcc00, 0x4a03, 0xd800, 0x5e03, 0x5403, 0xd200, - 0xf000, 0x7603, 0x7c03, 0xfa00, 0x6803, 0xee00, 0xe400, 0x6203, - 0xa000, 0x2603, 0x2c03, 0xaa00, 0x3803, 0xbe00, 0xb400, 0x3203, - 0x1003, 0x9600, 0x9c00, 0x1a03, 0x8800, 0x0e03, 0x0403, 0x8200, - 0x8006, 0x0605, 0x0c05, 0x8a06, 0x1805, 0x9e06, 0x9406, 0x1205, - 0x3005, 0xb606, 0xbc06, 0x3a05, 0xa806, 0x2e05, 0x2405, 0xa206, - 0x6005, 0xe606, 0xec06, 0x6a05, 0xf806, 0x7e05, 0x7405, 0xf206, - 0xd006, 0x5605, 0x5c05, 0xda06, 0x4805, 0xce06, 0xc406, 0x4205, - 0xc005, 0x4606, 0x4c06, 0xca05, 0x5806, 0xde05, 0xd405, 0x5206, - 0x7006, 0xf605, 0xfc05, 0x7a06, 0xe805, 0x6e06, 0x6406, 0xe205, - 0x2006, 0xa605, 0xac05, 0x2a06, 0xb805, 0x3e06, 0x3406, 0xb205, - 0x9005, 0x1606, 0x1c06, 0x9a05, 0x0806, 0x8e05, 0x8405, 0x0206, - 0x8009, 0x060a, 0x0c0a, 0x8a09, 0x180a, 0x9e09, 0x9409, 0x120a, - 0x300a, 0xb609, 0xbc09, 0x3a0a, 0xa809, 0x2e0a, 0x240a, 0xa209, - 0x600a, 0xe609, 0xec09, 0x6a0a, 0xf809, 0x7e0a, 0x740a, 0xf209, - 0xd009, 0x560a, 0x5c0a, 0xda09, 0x480a, 0xce09, 0xc409, 0x420a, - 0xc00a, 0x4609, 0x4c09, 0xca0a, 0x5809, 0xde0a, 0xd40a, 0x5209, - 0x7009, 0xf60a, 0xfc0a, 0x7a09, 0xe80a, 0x6e09, 0x6409, 0xe20a, - 0x2009, 0xa60a, 0xac0a, 0x2a09, 0xb80a, 0x3e09, 0x3409, 0xb20a, - 0x900a, 0x1609, 0x1c09, 0x9a0a, 0x0809, 0x8e0a, 0x840a, 0x0209, - 0x000f, 0x860c, 0x8c0c, 0x0a0f, 0x980c, 0x1e0f, 0x140f, 0x920c, - 0xb00c, 0x360f, 0x3c0f, 0xba0c, 0x280f, 0xae0c, 0xa40c, 0x220f, - 0xe00c, 0x660f, 0x6c0f, 0xea0c, 0x780f, 0xfe0c, 0xf40c, 0x720f, - 0x500f, 0xd60c, 0xdc0c, 0x5a0f, 0xc80c, 0x4e0f, 0x440f, 0xc20c, - 0x400c, 0xc60f, 0xcc0f, 0x4a0c, 0xd80f, 0x5e0c, 0x540c, 0xd20f, - 0xf00f, 0x760c, 0x7c0c, 0xfa0f, 0x680c, 0xee0f, 0xe40f, 0x620c, - 0xa00f, 0x260c, 0x2c0c, 0xaa0f, 0x380c, 0xbe0f, 0xb40f, 0x320c, - 0x100c, 0x960f, 0x9c0f, 0x1a0c, 0x880f, 0x0e0c, 0x040c, 0x820f }, - - { 0x0000, 0x8017, 0x802b, 0x003c, 0x8053, 0x0044, 0x0078, 0x806f, - 0x80a3, 0x00b4, 0x0088, 0x809f, 0x00f0, 0x80e7, 0x80db, 0x00cc, - 0x8143, 0x0154, 0x0168, 0x817f, 0x0110, 0x8107, 0x813b, 0x012c, - 0x01e0, 0x81f7, 0x81cb, 0x01dc, 0x81b3, 0x01a4, 0x0198, 0x818f, - 0x8283, 0x0294, 0x02a8, 0x82bf, 0x02d0, 0x82c7, 0x82fb, 0x02ec, - 0x0220, 0x8237, 0x820b, 0x021c, 0x8273, 0x0264, 0x0258, 0x824f, - 0x03c0, 0x83d7, 0x83eb, 0x03fc, 0x8393, 0x0384, 0x03b8, 0x83af, - 0x8363, 0x0374, 0x0348, 0x835f, 0x0330, 0x8327, 0x831b, 0x030c, - 0x8503, 0x0514, 0x0528, 0x853f, 0x0550, 0x8547, 0x857b, 0x056c, - 0x05a0, 0x85b7, 0x858b, 0x059c, 0x85f3, 0x05e4, 0x05d8, 0x85cf, - 0x0440, 0x8457, 0x846b, 0x047c, 0x8413, 0x0404, 0x0438, 0x842f, - 0x84e3, 0x04f4, 0x04c8, 0x84df, 0x04b0, 0x84a7, 0x849b, 0x048c, - 0x0780, 0x8797, 0x87ab, 0x07bc, 0x87d3, 0x07c4, 0x07f8, 0x87ef, - 0x8723, 0x0734, 0x0708, 0x871f, 0x0770, 0x8767, 0x875b, 0x074c, - 0x86c3, 0x06d4, 0x06e8, 0x86ff, 0x0690, 0x8687, 0x86bb, 0x06ac, - 0x0660, 0x8677, 0x864b, 0x065c, 0x8633, 0x0624, 0x0618, 0x860f, - 0x8a03, 0x0a14, 0x0a28, 0x8a3f, 0x0a50, 0x8a47, 0x8a7b, 0x0a6c, - 0x0aa0, 0x8ab7, 0x8a8b, 0x0a9c, 0x8af3, 0x0ae4, 0x0ad8, 0x8acf, - 0x0b40, 0x8b57, 0x8b6b, 0x0b7c, 0x8b13, 0x0b04, 0x0b38, 0x8b2f, - 0x8be3, 0x0bf4, 0x0bc8, 0x8bdf, 0x0bb0, 0x8ba7, 0x8b9b, 0x0b8c, - 0x0880, 0x8897, 0x88ab, 0x08bc, 0x88d3, 0x08c4, 0x08f8, 0x88ef, - 0x8823, 0x0834, 0x0808, 0x881f, 0x0870, 0x8867, 0x885b, 0x084c, - 0x89c3, 0x09d4, 0x09e8, 0x89ff, 0x0990, 0x8987, 0x89bb, 0x09ac, - 0x0960, 0x8977, 0x894b, 0x095c, 0x8933, 0x0924, 0x0918, 0x890f, - 0x0f00, 0x8f17, 0x8f2b, 0x0f3c, 0x8f53, 0x0f44, 0x0f78, 0x8f6f, - 0x8fa3, 0x0fb4, 0x0f88, 0x8f9f, 0x0ff0, 0x8fe7, 0x8fdb, 0x0fcc, - 0x8e43, 0x0e54, 0x0e68, 0x8e7f, 0x0e10, 0x8e07, 0x8e3b, 0x0e2c, - 0x0ee0, 0x8ef7, 0x8ecb, 0x0edc, 0x8eb3, 0x0ea4, 0x0e98, 0x8e8f, - 0x8d83, 0x0d94, 0x0da8, 0x8dbf, 0x0dd0, 0x8dc7, 0x8dfb, 0x0dec, - 0x0d20, 0x8d37, 0x8d0b, 0x0d1c, 0x8d73, 0x0d64, 0x0d58, 0x8d4f, - 0x0cc0, 0x8cd7, 0x8ceb, 0x0cfc, 0x8c93, 0x0c84, 0x0cb8, 0x8caf, - 0x8c63, 0x0c74, 0x0c48, 0x8c5f, 0x0c30, 0x8c27, 0x8c1b, 0x0c0c }, - - { 0x0000, 0x9403, 0xa803, 0x3c00, 0xd003, 0x4400, 0x7800, 0xec03, - 0x2003, 0xb400, 0x8800, 0x1c03, 0xf000, 0x6403, 0x5803, 0xcc00, - 0x4006, 0xd405, 0xe805, 0x7c06, 0x9005, 0x0406, 0x3806, 0xac05, - 0x6005, 0xf406, 0xc806, 0x5c05, 0xb006, 0x2405, 0x1805, 0x8c06, - 0x800c, 0x140f, 0x280f, 0xbc0c, 0x500f, 0xc40c, 0xf80c, 0x6c0f, - 0xa00f, 0x340c, 0x080c, 0x9c0f, 0x700c, 0xe40f, 0xd80f, 0x4c0c, - 0xc00a, 0x5409, 0x6809, 0xfc0a, 0x1009, 0x840a, 0xb80a, 0x2c09, - 0xe009, 0x740a, 0x480a, 0xdc09, 0x300a, 0xa409, 0x9809, 0x0c0a, - 0x801d, 0x141e, 0x281e, 0xbc1d, 0x501e, 0xc41d, 0xf81d, 0x6c1e, - 0xa01e, 0x341d, 0x081d, 0x9c1e, 0x701d, 0xe41e, 0xd81e, 0x4c1d, - 0xc01b, 0x5418, 0x6818, 0xfc1b, 0x1018, 0x841b, 0xb81b, 0x2c18, - 0xe018, 0x741b, 0x481b, 0xdc18, 0x301b, 0xa418, 0x9818, 0x0c1b, - 0x0011, 0x9412, 0xa812, 0x3c11, 0xd012, 0x4411, 0x7811, 0xec12, - 0x2012, 0xb411, 0x8811, 0x1c12, 0xf011, 0x6412, 0x5812, 0xcc11, - 0x4017, 0xd414, 0xe814, 0x7c17, 0x9014, 0x0417, 0x3817, 0xac14, - 0x6014, 0xf417, 0xc817, 0x5c14, 0xb017, 0x2414, 0x1814, 0x8c17, - 0x803f, 0x143c, 0x283c, 0xbc3f, 0x503c, 0xc43f, 0xf83f, 0x6c3c, - 0xa03c, 0x343f, 0x083f, 0x9c3c, 0x703f, 0xe43c, 0xd83c, 0x4c3f, - 0xc039, 0x543a, 0x683a, 0xfc39, 0x103a, 0x8439, 0xb839, 0x2c3a, - 0xe03a, 0x7439, 0x4839, 0xdc3a, 0x3039, 0xa43a, 0x983a, 0x0c39, - 0x0033, 0x9430, 0xa830, 0x3c33, 0xd030, 0x4433, 0x7833, 0xec30, - 0x2030, 0xb433, 0x8833, 0x1c30, 0xf033, 0x6430, 0x5830, 0xcc33, - 0x4035, 0xd436, 0xe836, 0x7c35, 0x9036, 0x0435, 0x3835, 0xac36, - 0x6036, 0xf435, 0xc835, 0x5c36, 0xb035, 0x2436, 0x1836, 0x8c35, - 0x0022, 0x9421, 0xa821, 0x3c22, 0xd021, 0x4422, 0x7822, 0xec21, - 0x2021, 0xb422, 0x8822, 0x1c21, 0xf022, 0x6421, 0x5821, 0xcc22, - 0x4024, 0xd427, 0xe827, 0x7c24, 0x9027, 0x0424, 0x3824, 0xac27, - 0x6027, 0xf424, 0xc824, 0x5c27, 0xb024, 0x2427, 0x1827, 0x8c24, - 0x802e, 0x142d, 0x282d, 0xbc2e, 0x502d, 0xc42e, 0xf82e, 0x6c2d, - 0xa02d, 0x342e, 0x082e, 0x9c2d, 0x702e, 0xe42d, 0xd82d, 0x4c2e, - 0xc028, 0x542b, 0x682b, 0xfc28, 0x102b, 0x8428, 0xb828, 0x2c2b, - 0xe02b, 0x7428, 0x4828, 0xdc2b, 0x3028, 0xa42b, 0x982b, 0x0c28 }, - - { 0x0000, 0x807b, 0x80f3, 0x0088, 0x81e3, 0x0198, 0x0110, 0x816b, - 0x83c3, 0x03b8, 0x0330, 0x834b, 0x0220, 0x825b, 0x82d3, 0x02a8, - 0x8783, 0x07f8, 0x0770, 0x870b, 0x0660, 0x861b, 0x8693, 0x06e8, - 0x0440, 0x843b, 0x84b3, 0x04c8, 0x85a3, 0x05d8, 0x0550, 0x852b, - 0x8f03, 0x0f78, 0x0ff0, 0x8f8b, 0x0ee0, 0x8e9b, 0x8e13, 0x0e68, - 0x0cc0, 0x8cbb, 0x8c33, 0x0c48, 0x8d23, 0x0d58, 0x0dd0, 0x8dab, - 0x0880, 0x88fb, 0x8873, 0x0808, 0x8963, 0x0918, 0x0990, 0x89eb, - 0x8b43, 0x0b38, 0x0bb0, 0x8bcb, 0x0aa0, 0x8adb, 0x8a53, 0x0a28, - 0x9e03, 0x1e78, 0x1ef0, 0x9e8b, 0x1fe0, 0x9f9b, 0x9f13, 0x1f68, - 0x1dc0, 0x9dbb, 0x9d33, 0x1d48, 0x9c23, 0x1c58, 0x1cd0, 0x9cab, - 0x1980, 0x99fb, 0x9973, 0x1908, 0x9863, 0x1818, 0x1890, 0x98eb, - 0x9a43, 0x1a38, 0x1ab0, 0x9acb, 0x1ba0, 0x9bdb, 0x9b53, 0x1b28, - 0x1100, 0x917b, 0x91f3, 0x1188, 0x90e3, 0x1098, 0x1010, 0x906b, - 0x92c3, 0x12b8, 0x1230, 0x924b, 0x1320, 0x935b, 0x93d3, 0x13a8, - 0x9683, 0x16f8, 0x1670, 0x960b, 0x1760, 0x971b, 0x9793, 0x17e8, - 0x1540, 0x953b, 0x95b3, 0x15c8, 0x94a3, 0x14d8, 0x1450, 0x942b, - 0xbc03, 0x3c78, 0x3cf0, 0xbc8b, 0x3de0, 0xbd9b, 0xbd13, 0x3d68, - 0x3fc0, 0xbfbb, 0xbf33, 0x3f48, 0xbe23, 0x3e58, 0x3ed0, 0xbeab, - 0x3b80, 0xbbfb, 0xbb73, 0x3b08, 0xba63, 0x3a18, 0x3a90, 0xbaeb, - 0xb843, 0x3838, 0x38b0, 0xb8cb, 0x39a0, 0xb9db, 0xb953, 0x3928, - 0x3300, 0xb37b, 0xb3f3, 0x3388, 0xb2e3, 0x3298, 0x3210, 0xb26b, - 0xb0c3, 0x30b8, 0x3030, 0xb04b, 0x3120, 0xb15b, 0xb1d3, 0x31a8, - 0xb483, 0x34f8, 0x3470, 0xb40b, 0x3560, 0xb51b, 0xb593, 0x35e8, - 0x3740, 0xb73b, 0xb7b3, 0x37c8, 0xb6a3, 0x36d8, 0x3650, 0xb62b, - 0x2200, 0xa27b, 0xa2f3, 0x2288, 0xa3e3, 0x2398, 0x2310, 0xa36b, - 0xa1c3, 0x21b8, 0x2130, 0xa14b, 0x2020, 0xa05b, 0xa0d3, 0x20a8, - 0xa583, 0x25f8, 0x2570, 0xa50b, 0x2460, 0xa41b, 0xa493, 0x24e8, - 0x2640, 0xa63b, 0xa6b3, 0x26c8, 0xa7a3, 0x27d8, 0x2750, 0xa72b, - 0xad03, 0x2d78, 0x2df0, 0xad8b, 0x2ce0, 0xac9b, 0xac13, 0x2c68, - 0x2ec0, 0xaebb, 0xae33, 0x2e48, 0xaf23, 0x2f58, 0x2fd0, 0xafab, - 0x2a80, 0xaafb, 0xaa73, 0x2a08, 0xab63, 0x2b18, 0x2b90, 0xabeb, - 0xa943, 0x2938, 0x29b0, 0xa9cb, 0x28a0, 0xa8db, 0xa853, 0x2828 }, - - { 0x0000, 0xf803, 0x7003, 0x8800, 0xe006, 0x1805, 0x9005, 0x6806, - 0x4009, 0xb80a, 0x300a, 0xc809, 0xa00f, 0x580c, 0xd00c, 0x280f, - 0x8012, 0x7811, 0xf011, 0x0812, 0x6014, 0x9817, 0x1017, 0xe814, - 0xc01b, 0x3818, 0xb018, 0x481b, 0x201d, 0xd81e, 0x501e, 0xa81d, - 0x8021, 0x7822, 0xf022, 0x0821, 0x6027, 0x9824, 0x1024, 0xe827, - 0xc028, 0x382b, 0xb02b, 0x4828, 0x202e, 0xd82d, 0x502d, 0xa82e, - 0x0033, 0xf830, 0x7030, 0x8833, 0xe035, 0x1836, 0x9036, 0x6835, - 0x403a, 0xb839, 0x3039, 0xc83a, 0xa03c, 0x583f, 0xd03f, 0x283c, - 0x8047, 0x7844, 0xf044, 0x0847, 0x6041, 0x9842, 0x1042, 0xe841, - 0xc04e, 0x384d, 0xb04d, 0x484e, 0x2048, 0xd84b, 0x504b, 0xa848, - 0x0055, 0xf856, 0x7056, 0x8855, 0xe053, 0x1850, 0x9050, 0x6853, - 0x405c, 0xb85f, 0x305f, 0xc85c, 0xa05a, 0x5859, 0xd059, 0x285a, - 0x0066, 0xf865, 0x7065, 0x8866, 0xe060, 0x1863, 0x9063, 0x6860, - 0x406f, 0xb86c, 0x306c, 0xc86f, 0xa069, 0x586a, 0xd06a, 0x2869, - 0x8074, 0x7877, 0xf077, 0x0874, 0x6072, 0x9871, 0x1071, 0xe872, - 0xc07d, 0x387e, 0xb07e, 0x487d, 0x207b, 0xd878, 0x5078, 0xa87b, - 0x808b, 0x7888, 0xf088, 0x088b, 0x608d, 0x988e, 0x108e, 0xe88d, - 0xc082, 0x3881, 0xb081, 0x4882, 0x2084, 0xd887, 0x5087, 0xa884, - 0x0099, 0xf89a, 0x709a, 0x8899, 0xe09f, 0x189c, 0x909c, 0x689f, - 0x4090, 0xb893, 0x3093, 0xc890, 0xa096, 0x5895, 0xd095, 0x2896, - 0x00aa, 0xf8a9, 0x70a9, 0x88aa, 0xe0ac, 0x18af, 0x90af, 0x68ac, - 0x40a3, 0xb8a0, 0x30a0, 0xc8a3, 0xa0a5, 0x58a6, 0xd0a6, 0x28a5, - 0x80b8, 0x78bb, 0xf0bb, 0x08b8, 0x60be, 0x98bd, 0x10bd, 0xe8be, - 0xc0b1, 0x38b2, 0xb0b2, 0x48b1, 0x20b7, 0xd8b4, 0x50b4, 0xa8b7, - 0x00cc, 0xf8cf, 0x70cf, 0x88cc, 0xe0ca, 0x18c9, 0x90c9, 0x68ca, - 0x40c5, 0xb8c6, 0x30c6, 0xc8c5, 0xa0c3, 0x58c0, 0xd0c0, 0x28c3, - 0x80de, 0x78dd, 0xf0dd, 0x08de, 0x60d8, 0x98db, 0x10db, 0xe8d8, - 0xc0d7, 0x38d4, 0xb0d4, 0x48d7, 0x20d1, 0xd8d2, 0x50d2, 0xa8d1, - 0x80ed, 0x78ee, 0xf0ee, 0x08ed, 0x60eb, 0x98e8, 0x10e8, 0xe8eb, - 0xc0e4, 0x38e7, 0xb0e7, 0x48e4, 0x20e2, 0xd8e1, 0x50e1, 0xa8e2, - 0x00ff, 0xf8fc, 0x70fc, 0x88ff, 0xe0f9, 0x18fa, 0x90fa, 0x68f9, - 0x40f6, 0xb8f5, 0x30f5, 0xc8f6, 0xa0f0, 0x58f3, 0xd0f3, 0x28f0 }, - - { 0x0000, 0x8113, 0x8223, 0x0330, 0x8443, 0x0550, 0x0660, 0x8773, - 0x8883, 0x0990, 0x0aa0, 0x8bb3, 0x0cc0, 0x8dd3, 0x8ee3, 0x0ff0, - 0x9103, 0x1010, 0x1320, 0x9233, 0x1540, 0x9453, 0x9763, 0x1670, - 0x1980, 0x9893, 0x9ba3, 0x1ab0, 0x9dc3, 0x1cd0, 0x1fe0, 0x9ef3, - 0xa203, 0x2310, 0x2020, 0xa133, 0x2640, 0xa753, 0xa463, 0x2570, - 0x2a80, 0xab93, 0xa8a3, 0x29b0, 0xaec3, 0x2fd0, 0x2ce0, 0xadf3, - 0x3300, 0xb213, 0xb123, 0x3030, 0xb743, 0x3650, 0x3560, 0xb473, - 0xbb83, 0x3a90, 0x39a0, 0xb8b3, 0x3fc0, 0xbed3, 0xbde3, 0x3cf0, - 0xc403, 0x4510, 0x4620, 0xc733, 0x4040, 0xc153, 0xc263, 0x4370, - 0x4c80, 0xcd93, 0xcea3, 0x4fb0, 0xc8c3, 0x49d0, 0x4ae0, 0xcbf3, - 0x5500, 0xd413, 0xd723, 0x5630, 0xd143, 0x5050, 0x5360, 0xd273, - 0xdd83, 0x5c90, 0x5fa0, 0xdeb3, 0x59c0, 0xd8d3, 0xdbe3, 0x5af0, - 0x6600, 0xe713, 0xe423, 0x6530, 0xe243, 0x6350, 0x6060, 0xe173, - 0xee83, 0x6f90, 0x6ca0, 0xedb3, 0x6ac0, 0xebd3, 0xe8e3, 0x69f0, - 0xf703, 0x7610, 0x7520, 0xf433, 0x7340, 0xf253, 0xf163, 0x7070, - 0x7f80, 0xfe93, 0xfda3, 0x7cb0, 0xfbc3, 0x7ad0, 0x79e0, 0xf8f3, - 0x0803, 0x8910, 0x8a20, 0x0b33, 0x8c40, 0x0d53, 0x0e63, 0x8f70, - 0x8080, 0x0193, 0x02a3, 0x83b0, 0x04c3, 0x85d0, 0x86e0, 0x07f3, - 0x9900, 0x1813, 0x1b23, 0x9a30, 0x1d43, 0x9c50, 0x9f60, 0x1e73, - 0x1183, 0x9090, 0x93a0, 0x12b3, 0x95c0, 0x14d3, 0x17e3, 0x96f0, - 0xaa00, 0x2b13, 0x2823, 0xa930, 0x2e43, 0xaf50, 0xac60, 0x2d73, - 0x2283, 0xa390, 0xa0a0, 0x21b3, 0xa6c0, 0x27d3, 0x24e3, 0xa5f0, - 0x3b03, 0xba10, 0xb920, 0x3833, 0xbf40, 0x3e53, 0x3d63, 0xbc70, - 0xb380, 0x3293, 0x31a3, 0xb0b0, 0x37c3, 0xb6d0, 0xb5e0, 0x34f3, - 0xcc00, 0x4d13, 0x4e23, 0xcf30, 0x4843, 0xc950, 0xca60, 0x4b73, - 0x4483, 0xc590, 0xc6a0, 0x47b3, 0xc0c0, 0x41d3, 0x42e3, 0xc3f0, - 0x5d03, 0xdc10, 0xdf20, 0x5e33, 0xd940, 0x5853, 0x5b63, 0xda70, - 0xd580, 0x5493, 0x57a3, 0xd6b0, 0x51c3, 0xd0d0, 0xd3e0, 0x52f3, - 0x6e03, 0xef10, 0xec20, 0x6d33, 0xea40, 0x6b53, 0x6863, 0xe970, - 0xe680, 0x6793, 0x64a3, 0xe5b0, 0x62c3, 0xe3d0, 0xe0e0, 0x61f3, - 0xff00, 0x7e13, 0x7d23, 0xfc30, 0x7b43, 0xfa50, 0xf960, 0x7873, - 0x7783, 0xf690, 0xf5a0, 0x74b3, 0xf3c0, 0x72d3, 0x71e3, 0xf0f0 }, - - { 0x0000, 0x1006, 0x200c, 0x300a, 0x4018, 0x501e, 0x6014, 0x7012, - 0x8030, 0x9036, 0xa03c, 0xb03a, 0xc028, 0xd02e, 0xe024, 0xf022, - 0x8065, 0x9063, 0xa069, 0xb06f, 0xc07d, 0xd07b, 0xe071, 0xf077, - 0x0055, 0x1053, 0x2059, 0x305f, 0x404d, 0x504b, 0x6041, 0x7047, - 0x80cf, 0x90c9, 0xa0c3, 0xb0c5, 0xc0d7, 0xd0d1, 0xe0db, 0xf0dd, - 0x00ff, 0x10f9, 0x20f3, 0x30f5, 0x40e7, 0x50e1, 0x60eb, 0x70ed, - 0x00aa, 0x10ac, 0x20a6, 0x30a0, 0x40b2, 0x50b4, 0x60be, 0x70b8, - 0x809a, 0x909c, 0xa096, 0xb090, 0xc082, 0xd084, 0xe08e, 0xf088, - 0x819b, 0x919d, 0xa197, 0xb191, 0xc183, 0xd185, 0xe18f, 0xf189, - 0x01ab, 0x11ad, 0x21a7, 0x31a1, 0x41b3, 0x51b5, 0x61bf, 0x71b9, - 0x01fe, 0x11f8, 0x21f2, 0x31f4, 0x41e6, 0x51e0, 0x61ea, 0x71ec, - 0x81ce, 0x91c8, 0xa1c2, 0xb1c4, 0xc1d6, 0xd1d0, 0xe1da, 0xf1dc, - 0x0154, 0x1152, 0x2158, 0x315e, 0x414c, 0x514a, 0x6140, 0x7146, - 0x8164, 0x9162, 0xa168, 0xb16e, 0xc17c, 0xd17a, 0xe170, 0xf176, - 0x8131, 0x9137, 0xa13d, 0xb13b, 0xc129, 0xd12f, 0xe125, 0xf123, - 0x0101, 0x1107, 0x210d, 0x310b, 0x4119, 0x511f, 0x6115, 0x7113, - 0x8333, 0x9335, 0xa33f, 0xb339, 0xc32b, 0xd32d, 0xe327, 0xf321, - 0x0303, 0x1305, 0x230f, 0x3309, 0x431b, 0x531d, 0x6317, 0x7311, - 0x0356, 0x1350, 0x235a, 0x335c, 0x434e, 0x5348, 0x6342, 0x7344, - 0x8366, 0x9360, 0xa36a, 0xb36c, 0xc37e, 0xd378, 0xe372, 0xf374, - 0x03fc, 0x13fa, 0x23f0, 0x33f6, 0x43e4, 0x53e2, 0x63e8, 0x73ee, - 0x83cc, 0x93ca, 0xa3c0, 0xb3c6, 0xc3d4, 0xd3d2, 0xe3d8, 0xf3de, - 0x8399, 0x939f, 0xa395, 0xb393, 0xc381, 0xd387, 0xe38d, 0xf38b, - 0x03a9, 0x13af, 0x23a5, 0x33a3, 0x43b1, 0x53b7, 0x63bd, 0x73bb, - 0x02a8, 0x12ae, 0x22a4, 0x32a2, 0x42b0, 0x52b6, 0x62bc, 0x72ba, - 0x8298, 0x929e, 0xa294, 0xb292, 0xc280, 0xd286, 0xe28c, 0xf28a, - 0x82cd, 0x92cb, 0xa2c1, 0xb2c7, 0xc2d5, 0xd2d3, 0xe2d9, 0xf2df, - 0x02fd, 0x12fb, 0x22f1, 0x32f7, 0x42e5, 0x52e3, 0x62e9, 0x72ef, - 0x8267, 0x9261, 0xa26b, 0xb26d, 0xc27f, 0xd279, 0xe273, 0xf275, - 0x0257, 0x1251, 0x225b, 0x325d, 0x424f, 0x5249, 0x6243, 0x7245, - 0x0202, 0x1204, 0x220e, 0x3208, 0x421a, 0x521c, 0x6216, 0x7210, - 0x8232, 0x9234, 0xa23e, 0xb238, 0xc22a, 0xd22c, 0xe226, 0xf220 } -}; - -#if 0 -void FLAC__crc16_init_table(void) -{ - int i, j; - FLAC__uint16 polynomial, crc; - polynomial = 0x8005; - - for(i = 0; i <= 0xFF; i++){ - crc = i << 8; - - for(j = 0; j < 8; j++) - crc = (crc << 1) ^ (crc & (1 << 15) ? polynomial : 0); - - FLAC__crc16_table[0][i] = crc; - } - - for(i = 0; i <= 0xFF; i++) - for(j = 1; j < 8; j++) - FLAC__crc16_table[j][i] = FLAC__crc16_table[0][FLAC__crc16_table[j - 1][i] >> 8] ^ (FLAC__crc16_table[j - 1][i] << 8); -} -#endif - -FLAC__uint8 FLAC__crc8(const FLAC__byte *data, uint32_t len) -{ - FLAC__uint8 crc = 0; - - while(len--) - crc = FLAC__crc8_table[crc ^ *data++]; - - return crc; -} - -FLAC__uint16 FLAC__crc16(const FLAC__byte *data, uint32_t len) -{ - FLAC__uint16 crc = 0; - - while(len >= 8){ - crc ^= data[0] << 8 | data[1]; - - crc = FLAC__crc16_table[7][crc >> 8] ^ FLAC__crc16_table[6][crc & 0xFF] ^ - FLAC__crc16_table[5][data[2] ] ^ FLAC__crc16_table[4][data[3] ] ^ - FLAC__crc16_table[3][data[4] ] ^ FLAC__crc16_table[2][data[5] ] ^ - FLAC__crc16_table[1][data[6] ] ^ FLAC__crc16_table[0][data[7] ]; - - data += 8; - len -= 8; - } - - while(len--) - crc = (crc<<8) ^ FLAC__crc16_table[0][(crc>>8) ^ *data++]; - - return crc; -} - -FLAC__uint16 FLAC__crc16_update_words32(const FLAC__uint32 *words, uint32_t len, FLAC__uint16 crc) -{ - while (len >= 2) { - crc ^= words[0] >> 16; - - crc = FLAC__crc16_table[7][crc >> 8 ] ^ FLAC__crc16_table[6][crc & 0xFF ] ^ - FLAC__crc16_table[5][(words[0] >> 8) & 0xFF] ^ FLAC__crc16_table[4][ words[0] & 0xFF] ^ - FLAC__crc16_table[3][ words[1] >> 24 ] ^ FLAC__crc16_table[2][(words[1] >> 16) & 0xFF] ^ - FLAC__crc16_table[1][(words[1] >> 8) & 0xFF] ^ FLAC__crc16_table[0][ words[1] & 0xFF]; - - words += 2; - len -= 2; - } - - if (len) { - crc ^= words[0] >> 16; - - crc = FLAC__crc16_table[3][crc >> 8 ] ^ FLAC__crc16_table[2][crc & 0xFF ] ^ - FLAC__crc16_table[1][(words[0] >> 8) & 0xFF] ^ FLAC__crc16_table[0][words[0] & 0xFF]; - } - - return crc; -} - -FLAC__uint16 FLAC__crc16_update_words64(const FLAC__uint64 *words, uint32_t len, FLAC__uint16 crc) -{ - while (len--) { - crc ^= words[0] >> 48; - - crc = FLAC__crc16_table[7][crc >> 8 ] ^ FLAC__crc16_table[6][crc & 0xFF ] ^ - FLAC__crc16_table[5][(words[0] >> 40) & 0xFF] ^ FLAC__crc16_table[4][(words[0] >> 32) & 0xFF] ^ - FLAC__crc16_table[3][(words[0] >> 24) & 0xFF] ^ FLAC__crc16_table[2][(words[0] >> 16) & 0xFF] ^ - FLAC__crc16_table[1][(words[0] >> 8) & 0xFF] ^ FLAC__crc16_table[0][ words[0] & 0xFF]; - - words++; - } - - return crc; -} diff --git a/Engine/lib/flac/src/libFLAC/deduplication/bitreader_read_rice_signed_block.c b/Engine/lib/flac/src/libFLAC/deduplication/bitreader_read_rice_signed_block.c deleted file mode 100644 index 75ed47f72..000000000 --- a/Engine/lib/flac/src/libFLAC/deduplication/bitreader_read_rice_signed_block.c +++ /dev/null @@ -1,143 +0,0 @@ -{ - /* try and get br->consumed_words and br->consumed_bits into register; - * must remember to flush them back to *br before calling other - * bitreader functions that use them, and before returning */ - uint32_t cwords, words, lsbs, msbs, x, y, limit; - uint32_t ucbits; /* keep track of the number of unconsumed bits in word */ - brword b; - int *val, *end; - - FLAC__ASSERT(0 != br); - FLAC__ASSERT(0 != br->buffer); - /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ - FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); - FLAC__ASSERT(parameter < 32); - /* the above two asserts also guarantee that the binary part never straddles more than 2 words, so we don't have to loop to read it */ - - limit = UINT32_MAX >> parameter; /* Maximal msbs that can occur with residual bounded to int32_t */ - - val = vals; - end = vals + nvals; - - if(parameter == 0) { - while(val < end) { - /* read the unary MSBs and end bit */ - if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) - return false; - /* Checking limit here would be overzealous: coding UINT32_MAX - * with parameter == 0 would take 4GiB */ - *val++ = (int)(msbs >> 1) ^ -(int)(msbs & 1); - } - - return true; - } - - FLAC__ASSERT(parameter > 0); - - cwords = br->consumed_words; - words = br->words; - - /* if we've not consumed up to a partial tail word... */ - if(cwords >= words) { - x = 0; - goto process_tail; - } - - ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; - b = br->buffer[cwords] << br->consumed_bits; /* keep unconsumed bits aligned to left */ - - while(val < end) { - /* read the unary MSBs and end bit */ - x = y = COUNT_ZERO_MSBS2(b); - if(x == FLAC__BITS_PER_WORD) { - x = ucbits; - do { - /* didn't find stop bit yet, have to keep going... */ - cwords++; - if (cwords >= words) - goto incomplete_msbs; - b = br->buffer[cwords]; - y = COUNT_ZERO_MSBS2(b); - x += y; - } while(y == FLAC__BITS_PER_WORD); - } - b <<= y; - b <<= 1; /* account for stop bit */ - ucbits = (ucbits - x - 1) % FLAC__BITS_PER_WORD; - msbs = x; - - if(x > limit) - return false; - - /* read the binary LSBs */ - x = (FLAC__uint32)(b >> (FLAC__BITS_PER_WORD - parameter)); /* parameter < 32, so we can cast to 32-bit uint32_t */ - if(parameter <= ucbits) { - ucbits -= parameter; - b <<= parameter; - } else { - /* there are still bits left to read, they will all be in the next word */ - cwords++; - if (cwords >= words) - goto incomplete_lsbs; - b = br->buffer[cwords]; - ucbits += FLAC__BITS_PER_WORD - parameter; - x |= (FLAC__uint32)(b >> ucbits); - b <<= FLAC__BITS_PER_WORD - ucbits; - } - lsbs = x; - - /* compose the value */ - x = (msbs << parameter) | lsbs; - *val++ = (int)(x >> 1) ^ -(int)(x & 1); - - continue; - - /* at this point we've eaten up all the whole words */ -process_tail: - do { - if(0) { -incomplete_msbs: - br->consumed_bits = 0; - br->consumed_words = cwords; - } - - /* read the unary MSBs and end bit */ - if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) - return false; - msbs += x; - x = ucbits = 0; - - if(0) { -incomplete_lsbs: - br->consumed_bits = 0; - br->consumed_words = cwords; - } - - /* read the binary LSBs */ - if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, parameter - ucbits)) - return false; - lsbs = x | lsbs; - - /* compose the value */ - x = (msbs << parameter) | lsbs; - *val++ = (int)(x >> 1) ^ -(int)(x & 1); - x = 0; - - cwords = br->consumed_words; - words = br->words; - ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; - b = cwords < br->capacity ? br->buffer[cwords] << br->consumed_bits : 0; - } while(cwords >= words && val < end); - } - - if(ucbits == 0 && cwords < words) { - /* don't leave the head word with no unconsumed bits */ - cwords++; - ucbits = FLAC__BITS_PER_WORD; - } - - br->consumed_bits = FLAC__BITS_PER_WORD - ucbits; - br->consumed_words = cwords; - - return true; -} diff --git a/Engine/lib/flac/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c b/Engine/lib/flac/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c deleted file mode 100644 index 76419db03..000000000 --- a/Engine/lib/flac/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin.c +++ /dev/null @@ -1,14 +0,0 @@ - int i, j; - (void) lag; - FLAC__ASSERT(lag <= MAX_LAG); - - for(i = 0; i < MAX_LAG; i++) - autoc[i] = 0.0; - - for(i = 0; i < MAX_LAG; i++) - for(j = 0; j <= i; j++) - autoc[j] += (double)data[i] * (double)data[i-j]; - - for(i = MAX_LAG; i < (int)data_len; i++) - for(j = 0; j < MAX_LAG; j++) - autoc[j] += (double)data[i] * (double)data[i-j]; diff --git a/Engine/lib/flac/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin_neon.c b/Engine/lib/flac/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin_neon.c deleted file mode 100644 index 4df3aee95..000000000 --- a/Engine/lib/flac/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin_neon.c +++ /dev/null @@ -1,70 +0,0 @@ - int i; - float64x2_t sum0 = vdupq_n_f64(0.0f); - float64x2_t sum1 = vdupq_n_f64(0.0f); - float64x2_t sum2 = vdupq_n_f64(0.0f); - float64x2_t sum3 = vdupq_n_f64(0.0f); - float64x2_t d0 = vdupq_n_f64(0.0f); - float64x2_t d1 = vdupq_n_f64(0.0f); - float64x2_t d2 = vdupq_n_f64(0.0f); - float64x2_t d3 = vdupq_n_f64(0.0f); -#if MAX_LAG > 8 - float64x2_t sum4 = vdupq_n_f64(0.0f); - float64x2_t d4 = vdupq_n_f64(0.0f); -#endif -#if MAX_LAG > 10 - float64x2_t sum5 = vdupq_n_f64(0.0f); - float64x2_t sum6 = vdupq_n_f64(0.0f); - float64x2_t d5 = vdupq_n_f64(0.0f); - float64x2_t d6 = vdupq_n_f64(0.0f); -#endif - float64x2_t d; - - (void)lag; - FLAC__ASSERT(lag <= MAX_LAG); - - // Loop backwards through samples from data_len to 0 - for (i = data_len - 1; i >= 0; i--) - { - d = vdupq_n_f64(data[i]); // Create vector with 2 entries data[i] - - // The next 6 lines of code right-shift the elements through the 7 vectors d0..d6. - // The 7th line adds the newly loaded element to d0. This works like a stack, where - // data[i] is pushed onto the stack every time and the 9th element falls off -#if MAX_LAG > 10 - d6 = vextq_f64(d5,d6,1); - d5 = vextq_f64(d4,d5,1); -#endif -#if MAX_LAG > 8 - d4 = vextq_f64(d3,d4,1); -#endif - d3 = vextq_f64(d2,d3,1); - d2 = vextq_f64(d1,d2,1); - d1 = vextq_f64(d0,d1,1); - d0 = vextq_f64(d,d0,1); - - // Fused multiply-add sum += d * d0..d6 - sum0 = vfmaq_f64(sum0, d, d0); - sum1 = vfmaq_f64(sum1, d, d1); - sum2 = vfmaq_f64(sum2, d, d2); - sum3 = vfmaq_f64(sum3, d, d3); -#if MAX_LAG > 8 - sum4 = vfmaq_f64(sum4, d, d4); -#endif -#if MAX_LAG > 10 - sum5 = vfmaq_f64(sum5, d, d5); - sum6 = vfmaq_f64(sum6, d, d6); -#endif - } - - // Store sum0..sum6 in autoc[0..14] - vst1q_f64(autoc, sum0); - vst1q_f64(autoc + 2, sum1); - vst1q_f64(autoc + 4, sum2); - vst1q_f64(autoc + 6, sum3); -#if MAX_LAG > 8 - vst1q_f64(autoc + 8, sum4); -#endif -#if MAX_LAG > 10 - vst1q_f64(autoc + 10, sum5); - vst1q_f64(autoc + 12, sum6); -#endif diff --git a/Engine/lib/flac/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin_sse2.c b/Engine/lib/flac/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin_sse2.c deleted file mode 100644 index 607b42f41..000000000 --- a/Engine/lib/flac/src/libFLAC/deduplication/lpc_compute_autocorrelation_intrin_sse2.c +++ /dev/null @@ -1,81 +0,0 @@ -/* This code is imported several times in lpc_intrin_sse2.c with different - * values for MAX_LAG. Comments are for MAX_LAG == 14 */ - int i; - __m128d sum0, sum1, sum2, sum3; - __m128d d0, d1, d2, d3; -#if MAX_LAG > 8 - __m128d d4; - __m128d sum4; -#endif -#if MAX_LAG > 10 - __m128d d5, d6; - __m128d sum5, sum6; -#endif - - (void) lag; - FLAC__ASSERT(lag <= MAX_LAG); - - /* Initialize all sum vectors with zero */ - sum0 = _mm_setzero_pd(); - sum1 = _mm_setzero_pd(); - sum2 = _mm_setzero_pd(); - sum3 = _mm_setzero_pd(); - d0 = _mm_setzero_pd(); - d1 = _mm_setzero_pd(); - d2 = _mm_setzero_pd(); - d3 = _mm_setzero_pd(); -#if MAX_LAG > 8 - sum4 = _mm_setzero_pd(); - d4 = _mm_setzero_pd(); -#endif -#if MAX_LAG > 10 - sum5 = _mm_setzero_pd(); - sum6 = _mm_setzero_pd(); - d5 = _mm_setzero_pd(); - d6 = _mm_setzero_pd(); -#endif - - /* Loop backwards through samples from data_len to limit */ - for(i = data_len-1; i >= 0; i--) { - __m128d d = _mm_set1_pd(data[i]); - - /* The next lines of code work like a queue. For more - * information see the lag8 version of this function */ -#if MAX_LAG > 10 - d6 = _mm_shuffle_pd(d5, d6, _MM_SHUFFLE(0,0,0,1)); - d5 = _mm_shuffle_pd(d4, d5, _MM_SHUFFLE(0,0,0,1)); -#endif -#if MAX_LAG > 8 - d4 = _mm_shuffle_pd(d3, d4, _MM_SHUFFLE(0,0,0,1)); -#endif - d3 = _mm_shuffle_pd(d2, d3, _MM_SHUFFLE(0,0,0,1)); - d2 = _mm_shuffle_pd(d1, d2, _MM_SHUFFLE(0,0,0,1)); - d1 = _mm_shuffle_pd(d0, d1, _MM_SHUFFLE(0,0,0,1)); - d0 = _mm_shuffle_pd(d, d0, _MM_SHUFFLE(0,0,0,1)); - - /* sumn += d*dn */ - sum0 = _mm_add_pd(sum0, _mm_mul_pd(d, d0)); - sum1 = _mm_add_pd(sum1, _mm_mul_pd(d, d1)); - sum2 = _mm_add_pd(sum2, _mm_mul_pd(d, d2)); - sum3 = _mm_add_pd(sum3, _mm_mul_pd(d, d3)); -#if MAX_LAG > 8 - sum4 = _mm_add_pd(sum4, _mm_mul_pd(d, d4)); -#endif -#if MAX_LAG > 10 - sum5 = _mm_add_pd(sum5, _mm_mul_pd(d, d5)); - sum6 = _mm_add_pd(sum6, _mm_mul_pd(d, d6)); -#endif - } - - /* Store sum0..sum6 in autoc[0..14] */ - _mm_storeu_pd(autoc, sum0); - _mm_storeu_pd(autoc+2, sum1); - _mm_storeu_pd(autoc+4, sum2); - _mm_storeu_pd(autoc+6 ,sum3); -#if MAX_LAG > 8 - _mm_storeu_pd(autoc+8, sum4); -#endif -#if MAX_LAG > 10 - _mm_storeu_pd(autoc+10,sum5); - _mm_storeu_pd(autoc+12,sum6); -#endif diff --git a/Engine/lib/flac/src/libFLAC/fixed.c b/Engine/lib/flac/src/libFLAC/fixed.c deleted file mode 100644 index 5c42570e7..000000000 --- a/Engine/lib/flac/src/libFLAC/fixed.c +++ /dev/null @@ -1,667 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include "share/compat.h" -#include "private/bitmath.h" -#include "private/fixed.h" -#include "private/macros.h" -#include "FLAC/assert.h" - -#ifdef local_abs -#undef local_abs -#endif -#define local_abs(x) ((uint32_t)((x)<0? -(x) : (x))) - -#ifdef local_abs64 -#undef local_abs64 -#endif -#define local_abs64(x) ((uint64_t)((x)<0? -(x) : (x))) - -#ifdef FLAC__INTEGER_ONLY_LIBRARY -/* rbps stands for residual bits per sample - * - * (ln(2) * err) - * rbps = log (-----------) - * 2 ( n ) - */ -static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__uint32 n) -{ - FLAC__uint32 rbps; - uint32_t bits; /* the number of bits required to represent a number */ - int fracbits; /* the number of bits of rbps that comprise the fractional part */ - - FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint)); - FLAC__ASSERT(err > 0); - FLAC__ASSERT(n > 0); - - FLAC__ASSERT(n <= FLAC__MAX_BLOCK_SIZE); - if(err <= n) - return 0; - /* - * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1. - * These allow us later to know we won't lose too much precision in the - * fixed-point division (err< 0); - bits = FLAC__bitmath_ilog2(err)+1; - if(bits > 16) { - err >>= (bits-16); - fracbits -= (bits-16); - } - rbps = (FLAC__uint32)err; - - /* Multiply by fixed-point version of ln(2), with 16 fractional bits */ - rbps *= FLAC__FP_LN2; - fracbits += 16; - FLAC__ASSERT(fracbits >= 0); - - /* FLAC__fixedpoint_log2 requires fracbits%4 to be 0 */ - { - const int f = fracbits & 3; - if(f) { - rbps >>= f; - fracbits -= f; - } - } - - rbps = FLAC__fixedpoint_log2(rbps, fracbits, (uint32_t)(-1)); - - if(rbps == 0) - return 0; - - /* - * The return value must have 16 fractional bits. Since the whole part - * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits - * must be >= -3, these assertion allows us to be able to shift rbps - * left if necessary to get 16 fracbits without losing any bits of the - * whole part of rbps. - * - * There is a slight chance due to accumulated error that the whole part - * will require 6 bits, so we use 6 in the assertion. Really though as - * long as it fits in 13 bits (32 - (16 - (-3))) we are fine. - */ - FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6); - FLAC__ASSERT(fracbits >= -3); - - /* now shift the decimal point into place */ - if(fracbits < 16) - return rbps << (16-fracbits); - else if(fracbits > 16) - return rbps >> (fracbits-16); - else - return rbps; -} - -static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, FLAC__uint32 n) -{ - FLAC__uint32 rbps; - uint32_t bits; /* the number of bits required to represent a number */ - int fracbits; /* the number of bits of rbps that comprise the fractional part */ - - FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint)); - FLAC__ASSERT(err > 0); - FLAC__ASSERT(n > 0); - - FLAC__ASSERT(n <= FLAC__MAX_BLOCK_SIZE); - if(err <= n) - return 0; - /* - * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1. - * These allow us later to know we won't lose too much precision in the - * fixed-point division (err< 0); - bits = FLAC__bitmath_ilog2_wide(err)+1; - if(bits > 16) { - err >>= (bits-16); - fracbits -= (bits-16); - } - rbps = (FLAC__uint32)err; - - /* Multiply by fixed-point version of ln(2), with 16 fractional bits */ - rbps *= FLAC__FP_LN2; - fracbits += 16; - FLAC__ASSERT(fracbits >= 0); - - /* FLAC__fixedpoint_log2 requires fracbits%4 to be 0 */ - { - const int f = fracbits & 3; - if(f) { - rbps >>= f; - fracbits -= f; - } - } - - rbps = FLAC__fixedpoint_log2(rbps, fracbits, (uint32_t)(-1)); - - if(rbps == 0) - return 0; - - /* - * The return value must have 16 fractional bits. Since the whole part - * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits - * must be >= -3, these assertion allows us to be able to shift rbps - * left if necessary to get 16 fracbits without losing any bits of the - * whole part of rbps. - * - * There is a slight chance due to accumulated error that the whole part - * will require 6 bits, so we use 6 in the assertion. Really though as - * long as it fits in 13 bits (32 - (16 - (-3))) we are fine. - */ - FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6); - FLAC__ASSERT(fracbits >= -3); - - /* now shift the decimal point into place */ - if(fracbits < 16) - return rbps << (16-fracbits); - else if(fracbits > 16) - return rbps >> (fracbits-16); - else - return rbps; -} -#endif - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) -#else -uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) -#endif -{ - FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; - uint32_t order; -#if 0 - /* This code has been around a long time, and was written when compilers weren't able - * to vectorize code. These days, compilers are better in optimizing the next block - * which is also much more readable - */ - FLAC__int32 last_error_0 = data[-1]; - FLAC__int32 last_error_1 = data[-1] - data[-2]; - FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]); - FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); - FLAC__int32 error, save; - uint32_t i; - /* total_error_* are 64-bits to avoid overflow when encoding - * erratic signals when the bits-per-sample and blocksize are - * large. - */ - for(i = 0; i < data_len; i++) { - error = data[i] ; total_error_0 += local_abs(error); save = error; - error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error; - error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error; - error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error; - error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save; - } -#else - int i; - for(i = 0; i < (int)data_len; i++) { - total_error_0 += local_abs(data[i]); - total_error_1 += local_abs(data[i] - data[i-1]); - total_error_2 += local_abs(data[i] - 2 * data[i-1] + data[i-2]); - total_error_3 += local_abs(data[i] - 3 * data[i-1] + 3 * data[i-2] - data[i-3]); - total_error_4 += local_abs(data[i] - 4 * data[i-1] + 6 * data[i-2] - 4 * data[i-3] + data[i-4]); - } -#endif - - - /* prefer lower order */ - if(total_error_0 <= flac_min(flac_min(flac_min(total_error_1, total_error_2), total_error_3), total_error_4)) - order = 0; - else if(total_error_1 <= flac_min(flac_min(total_error_2, total_error_3), total_error_4)) - order = 1; - else if(total_error_2 <= flac_min(total_error_3, total_error_4)) - order = 2; - else if(total_error_3 <= total_error_4) - order = 3; - else - order = 4; - - /* Estimate the expected number of bits per residual signal sample. */ - /* 'total_error*' is linearly related to the variance of the residual */ - /* signal, so we use it directly to compute E(|x|) */ - FLAC__ASSERT(data_len > 0 || total_error_0 == 0); - FLAC__ASSERT(data_len > 0 || total_error_1 == 0); - FLAC__ASSERT(data_len > 0 || total_error_2 == 0); - FLAC__ASSERT(data_len > 0 || total_error_3 == 0); - FLAC__ASSERT(data_len > 0 || total_error_4 == 0); -#ifndef FLAC__INTEGER_ONLY_LIBRARY - residual_bits_per_sample[0] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[1] = (float)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[2] = (float)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[3] = (float)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[4] = (float)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0); -#else - residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_integerized(total_error_0, data_len) : 0; - residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_integerized(total_error_1, data_len) : 0; - residual_bits_per_sample[2] = (total_error_2 > 0) ? local__compute_rbps_integerized(total_error_2, data_len) : 0; - residual_bits_per_sample[3] = (total_error_3 > 0) ? local__compute_rbps_integerized(total_error_3, data_len) : 0; - residual_bits_per_sample[4] = (total_error_4 > 0) ? local__compute_rbps_integerized(total_error_4, data_len) : 0; -#endif - - return order; -} - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) -#else -uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) -#endif -{ - FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; - uint32_t order; - int i; - - for(i = 0; i < (int)data_len; i++) { - total_error_0 += local_abs(data[i]); - total_error_1 += local_abs(data[i] - data[i-1]); - total_error_2 += local_abs(data[i] - 2 * data[i-1] + data[i-2]); - total_error_3 += local_abs(data[i] - 3 * data[i-1] + 3 * data[i-2] - data[i-3]); - total_error_4 += local_abs(data[i] - 4 * data[i-1] + 6 * data[i-2] - 4 * data[i-3] + data[i-4]); - } - - /* prefer lower order */ - if(total_error_0 <= flac_min(flac_min(flac_min(total_error_1, total_error_2), total_error_3), total_error_4)) - order = 0; - else if(total_error_1 <= flac_min(flac_min(total_error_2, total_error_3), total_error_4)) - order = 1; - else if(total_error_2 <= flac_min(total_error_3, total_error_4)) - order = 2; - else if(total_error_3 <= total_error_4) - order = 3; - else - order = 4; - - /* Estimate the expected number of bits per residual signal sample. */ - /* 'total_error*' is linearly related to the variance of the residual */ - /* signal, so we use it directly to compute E(|x|) */ - FLAC__ASSERT(data_len > 0 || total_error_0 == 0); - FLAC__ASSERT(data_len > 0 || total_error_1 == 0); - FLAC__ASSERT(data_len > 0 || total_error_2 == 0); - FLAC__ASSERT(data_len > 0 || total_error_3 == 0); - FLAC__ASSERT(data_len > 0 || total_error_4 == 0); -#ifndef FLAC__INTEGER_ONLY_LIBRARY - residual_bits_per_sample[0] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[1] = (float)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[2] = (float)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[3] = (float)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[4] = (float)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0); -#else - residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_wide_integerized(total_error_0, data_len) : 0; - residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_wide_integerized(total_error_1, data_len) : 0; - residual_bits_per_sample[2] = (total_error_2 > 0) ? local__compute_rbps_wide_integerized(total_error_2, data_len) : 0; - residual_bits_per_sample[3] = (total_error_3 > 0) ? local__compute_rbps_wide_integerized(total_error_3, data_len) : 0; - residual_bits_per_sample[4] = (total_error_4 > 0) ? local__compute_rbps_wide_integerized(total_error_4, data_len) : 0; -#endif - - return order; -} - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#define CHECK_ORDER_IS_VALID(macro_order) \ -if(order_##macro_order##_is_valid && total_error_##macro_order < smallest_error) { \ - order = macro_order; \ - smallest_error = total_error_##macro_order ; \ - residual_bits_per_sample[ macro_order ] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); \ -} \ -else \ - residual_bits_per_sample[ macro_order ] = 34.0f; -#else -#define CHECK_ORDER_IS_VALID(macro_order) \ -if(order_##macro_order##_is_valid && total_error_##macro_order < smallest_error) { \ - order = macro_order; \ - smallest_error = total_error_##macro_order ; \ - residual_bits_per_sample[ macro_order ] = (total_error_##macro_order > 0) ? local__compute_rbps_wide_integerized(total_error_##macro_order, data_len) : 0; \ -} \ -else \ - residual_bits_per_sample[ macro_order ] = 34 * FLAC__FP_ONE; -#endif - - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -uint32_t FLAC__fixed_compute_best_predictor_limit_residual(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) -#else -uint32_t FLAC__fixed_compute_best_predictor_limit_residual(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) -#endif -{ - FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0, smallest_error = UINT64_MAX; - FLAC__uint64 error_0, error_1, error_2, error_3, error_4; - FLAC__bool order_0_is_valid = true, order_1_is_valid = true, order_2_is_valid = true, order_3_is_valid = true, order_4_is_valid = true; - uint32_t order = 0; - int i; - - for(i = -4; i < (int)data_len; i++) { - error_0 = local_abs64((FLAC__int64)data[i]); - error_1 = (i > -4) ? local_abs64((FLAC__int64)data[i] - data[i-1]) : 0 ; - error_2 = (i > -3) ? local_abs64((FLAC__int64)data[i] - 2 * (FLAC__int64)data[i-1] + data[i-2]) : 0; - error_3 = (i > -2) ? local_abs64((FLAC__int64)data[i] - 3 * (FLAC__int64)data[i-1] + 3 * (FLAC__int64)data[i-2] - data[i-3]) : 0; - error_4 = (i > -1) ? local_abs64((FLAC__int64)data[i] - 4 * (FLAC__int64)data[i-1] + 6 * (FLAC__int64)data[i-2] - 4 * (FLAC__int64)data[i-3] + data[i-4]) : 0; - - total_error_0 += error_0; - total_error_1 += error_1; - total_error_2 += error_2; - total_error_3 += error_3; - total_error_4 += error_4; - - /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */ - if(error_0 > INT32_MAX) - order_0_is_valid = false; - if(error_1 > INT32_MAX) - order_1_is_valid = false; - if(error_2 > INT32_MAX) - order_2_is_valid = false; - if(error_3 > INT32_MAX) - order_3_is_valid = false; - if(error_4 > INT32_MAX) - order_4_is_valid = false; - } - - CHECK_ORDER_IS_VALID(0); - CHECK_ORDER_IS_VALID(1); - CHECK_ORDER_IS_VALID(2); - CHECK_ORDER_IS_VALID(3); - CHECK_ORDER_IS_VALID(4); - - return order; -} - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -uint32_t FLAC__fixed_compute_best_predictor_limit_residual_33bit(const FLAC__int64 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) -#else -uint32_t FLAC__fixed_compute_best_predictor_limit_residual_33bit(const FLAC__int64 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) -#endif -{ - FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0, smallest_error = UINT64_MAX; - FLAC__uint64 error_0, error_1, error_2, error_3, error_4; - FLAC__bool order_0_is_valid = true, order_1_is_valid = true, order_2_is_valid = true, order_3_is_valid = true, order_4_is_valid = true; - uint32_t order = 0; - int i; - - for(i = -4; i < (int)data_len; i++) { - error_0 = local_abs64(data[i]); - error_1 = (i > -4) ? local_abs64(data[i] - data[i-1]) : 0 ; - error_2 = (i > -3) ? local_abs64(data[i] - 2 * data[i-1] + data[i-2]) : 0; - error_3 = (i > -2) ? local_abs64(data[i] - 3 * data[i-1] + 3 * data[i-2] - data[i-3]) : 0; - error_4 = (i > -1) ? local_abs64(data[i] - 4 * data[i-1] + 6 * data[i-2] - 4 * data[i-3] + data[i-4]) : 0; - - total_error_0 += error_0; - total_error_1 += error_1; - total_error_2 += error_2; - total_error_3 += error_3; - total_error_4 += error_4; - - /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */ - if(error_0 > INT32_MAX) - order_0_is_valid = false; - if(error_1 > INT32_MAX) - order_1_is_valid = false; - if(error_2 > INT32_MAX) - order_2_is_valid = false; - if(error_3 > INT32_MAX) - order_3_is_valid = false; - if(error_4 > INT32_MAX) - order_4_is_valid = false; - } - - CHECK_ORDER_IS_VALID(0); - CHECK_ORDER_IS_VALID(1); - CHECK_ORDER_IS_VALID(2); - CHECK_ORDER_IS_VALID(3); - CHECK_ORDER_IS_VALID(4); - - return order; -} - -void FLAC__fixed_compute_residual(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]) -{ - const int idata_len = (int)data_len; - int i; - - switch(order) { - case 0: - FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); - memcpy(residual, data, sizeof(residual[0])*data_len); - break; - case 1: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - data[i-1]; - break; - case 2: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - 2*data[i-1] + data[i-2]; - break; - case 3: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3]; - break; - case 4: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4]; - break; - default: - FLAC__ASSERT(0); - } -} - -void FLAC__fixed_compute_residual_wide(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]) -{ - const int idata_len = (int)data_len; - int i; - - switch(order) { - case 0: - FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); - memcpy(residual, data, sizeof(residual[0])*data_len); - break; - case 1: - for(i = 0; i < idata_len; i++) - residual[i] = (FLAC__int64)data[i] - data[i-1]; - break; - case 2: - for(i = 0; i < idata_len; i++) - residual[i] = (FLAC__int64)data[i] - 2*(FLAC__int64)data[i-1] + data[i-2]; - break; - case 3: - for(i = 0; i < idata_len; i++) - residual[i] = (FLAC__int64)data[i] - 3*(FLAC__int64)data[i-1] + 3*(FLAC__int64)data[i-2] - data[i-3]; - break; - case 4: - for(i = 0; i < idata_len; i++) - residual[i] = (FLAC__int64)data[i] - 4*(FLAC__int64)data[i-1] + 6*(FLAC__int64)data[i-2] - 4*(FLAC__int64)data[i-3] + data[i-4]; - break; - default: - FLAC__ASSERT(0); - } -} - -void FLAC__fixed_compute_residual_wide_33bit(const FLAC__int64 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]) -{ - const int idata_len = (int)data_len; - int i; - - switch(order) { - case 0: - for(i = 0; i < idata_len; i++) - residual[i] = data[i]; - break; - case 1: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - data[i-1]; - break; - case 2: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - 2*data[i-1] + data[i-2]; - break; - case 3: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3]; - break; - case 4: - for(i = 0; i < idata_len; i++) - residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4]; - break; - default: - FLAC__ASSERT(0); - } -} - -#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) -/* The attribute below is to silence the undefined sanitizer of oss-fuzz. - * Because fuzzing feeds bogus predictors and residual samples to the - * decoder, having overflows in this section is unavoidable. Also, - * because the calculated values are audio path only, there is no - * potential for security problems */ -__attribute__((no_sanitize("signed-integer-overflow"))) -#endif -void FLAC__fixed_restore_signal(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]) -{ - int i, idata_len = (int)data_len; - - switch(order) { - case 0: - FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); - memcpy(data, residual, sizeof(residual[0])*data_len); - break; - case 1: - for(i = 0; i < idata_len; i++) - data[i] = residual[i] + data[i-1]; - break; - case 2: - for(i = 0; i < idata_len; i++) - data[i] = residual[i] + 2*data[i-1] - data[i-2]; - break; - case 3: - for(i = 0; i < idata_len; i++) - data[i] = residual[i] + 3*data[i-1] - 3*data[i-2] + data[i-3]; - break; - case 4: - for(i = 0; i < idata_len; i++) - data[i] = residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4]; - break; - default: - FLAC__ASSERT(0); - } -} - -void FLAC__fixed_restore_signal_wide(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]) -{ - int i, idata_len = (int)data_len; - - switch(order) { - case 0: - FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0])); - memcpy(data, residual, sizeof(residual[0])*data_len); - break; - case 1: - for(i = 0; i < idata_len; i++) - data[i] = (FLAC__int64)residual[i] + (FLAC__int64)data[i-1]; - break; - case 2: - for(i = 0; i < idata_len; i++) - data[i] = (FLAC__int64)residual[i] + 2*(FLAC__int64)data[i-1] - (FLAC__int64)data[i-2]; - break; - case 3: - for(i = 0; i < idata_len; i++) - data[i] = (FLAC__int64)residual[i] + 3*(FLAC__int64)data[i-1] - 3*(FLAC__int64)data[i-2] + (FLAC__int64)data[i-3]; - break; - case 4: - for(i = 0; i < idata_len; i++) - data[i] = (FLAC__int64)residual[i] + 4*(FLAC__int64)data[i-1] - 6*(FLAC__int64)data[i-2] + 4*(FLAC__int64)data[i-3] - (FLAC__int64)data[i-4]; - break; - default: - FLAC__ASSERT(0); - } -} - -#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) -/* The attribute below is to silence the undefined sanitizer of oss-fuzz. - * Because fuzzing feeds bogus predictors and residual samples to the - * decoder, having overflows in this section is unavoidable. Also, - * because the calculated values are audio path only, there is no - * potential for security problems */ -__attribute__((no_sanitize("signed-integer-overflow"))) -#endif -void FLAC__fixed_restore_signal_wide_33bit(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int64 data[]) -{ - int i, idata_len = (int)data_len; - - switch(order) { - case 0: - for(i = 0; i < idata_len; i++) - data[i] = residual[i]; - break; - case 1: - for(i = 0; i < idata_len; i++) - data[i] = (FLAC__int64)residual[i] + data[i-1]; - break; - case 2: - for(i = 0; i < idata_len; i++) - data[i] = (FLAC__int64)residual[i] + 2*data[i-1] - data[i-2]; - break; - case 3: - for(i = 0; i < idata_len; i++) - data[i] = (FLAC__int64)residual[i] + 3*data[i-1] - 3*data[i-2] + data[i-3]; - break; - case 4: - for(i = 0; i < idata_len; i++) - data[i] = (FLAC__int64)residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4]; - break; - default: - FLAC__ASSERT(0); - } -} diff --git a/Engine/lib/flac/src/libFLAC/fixed_intrin_avx2.c b/Engine/lib/flac/src/libFLAC/fixed_intrin_avx2.c deleted file mode 100644 index 85fc4a6d0..000000000 --- a/Engine/lib/flac/src/libFLAC/fixed_intrin_avx2.c +++ /dev/null @@ -1,343 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#include "private/fixed.h" -#ifdef FLAC__AVX2_SUPPORTED - -#include -#include -#include "private/macros.h" -#include "share/compat.h" -#include "FLAC/assert.h" - -#ifdef local_abs -#undef local_abs -#endif -#define local_abs(x) ((uint32_t)((x)<0? -(x) : (x))) - -FLAC__SSE_TARGET("avx2") -uint32_t FLAC__fixed_compute_best_predictor_wide_intrin_avx2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) -{ - FLAC__uint64 total_error_0, total_error_1, total_error_2, total_error_3, total_error_4; - FLAC__int32 i, data_len_int; - uint32_t order; - __m256i total_err0, total_err1, total_err2, total_err3, total_err4; - __m256i prev_err0, prev_err1, prev_err2, prev_err3; - __m256i tempA, tempB, bitmask; - FLAC__int64 data_scalar[4]; - FLAC__int64 prev_err0_scalar[4]; - FLAC__int64 prev_err1_scalar[4]; - FLAC__int64 prev_err2_scalar[4]; - FLAC__int64 prev_err3_scalar[4]; - total_err0 = _mm256_setzero_si256(); - total_err1 = _mm256_setzero_si256(); - total_err2 = _mm256_setzero_si256(); - total_err3 = _mm256_setzero_si256(); - total_err4 = _mm256_setzero_si256(); - data_len_int = data_len; - - for(i = 0; i < 4; i++){ - prev_err0_scalar[i] = data[-1+i*(data_len_int/4)]; - prev_err1_scalar[i] = data[-1+i*(data_len_int/4)] - data[-2+i*(data_len_int/4)]; - prev_err2_scalar[i] = prev_err1_scalar[i] - (data[-2+i*(data_len_int/4)] - data[-3+i*(data_len_int/4)]); - prev_err3_scalar[i] = prev_err2_scalar[i] - (data[-2+i*(data_len_int/4)] - 2*data[-3+i*(data_len_int/4)] + data[-4+i*(data_len_int/4)]); - } - prev_err0 = _mm256_loadu_si256((const __m256i*)(void*)prev_err0_scalar); - prev_err1 = _mm256_loadu_si256((const __m256i*)(void*)prev_err1_scalar); - prev_err2 = _mm256_loadu_si256((const __m256i*)(void*)prev_err2_scalar); - prev_err3 = _mm256_loadu_si256((const __m256i*)(void*)prev_err3_scalar); - for(i = 0; i < data_len_int / 4; i++){ - data_scalar[0] = data[i]; - data_scalar[1] = data[i+data_len/4]; - data_scalar[2] = data[i+2*data_len/4]; - data_scalar[3] = data[i+3*data_len/4]; - tempA = _mm256_loadu_si256((const __m256i*)(void*)data_scalar); - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempA); - tempB = _mm256_xor_si256(tempA, bitmask); - tempB = _mm256_sub_epi64(tempB, bitmask); - total_err0 = _mm256_add_epi64(total_err0,tempB); - tempB = _mm256_sub_epi64(tempA,prev_err0); - prev_err0 = tempA; - /* Next three intrinsics calculate tempA as abs of tempB */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempB); - tempA = _mm256_xor_si256(tempB, bitmask); - tempA = _mm256_sub_epi64(tempA, bitmask); - total_err1 = _mm256_add_epi64(total_err1,tempA); - tempA = _mm256_sub_epi64(tempB,prev_err1); - prev_err1 = tempB; - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempA); - tempB = _mm256_xor_si256(tempA, bitmask); - tempB = _mm256_sub_epi64(tempB, bitmask); - total_err2 = _mm256_add_epi64(total_err2,tempB); - tempB = _mm256_sub_epi64(tempA,prev_err2); - prev_err2 = tempA; - /* Next three intrinsics calculate tempA as abs of tempB */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempB); - tempA = _mm256_xor_si256(tempB, bitmask); - tempA = _mm256_sub_epi64(tempA, bitmask); - total_err3 = _mm256_add_epi64(total_err3,tempA); - tempA = _mm256_sub_epi64(tempB,prev_err3); - prev_err3 = tempB; - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempA); - tempB = _mm256_xor_si256(tempA, bitmask); - tempB = _mm256_sub_epi64(tempB, bitmask); - total_err4 = _mm256_add_epi64(total_err4,tempB); - } - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err0); - total_error_0 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err1); - total_error_1 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err2); - total_error_2 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err3); - total_error_3 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err4); - total_error_4 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - - /* Ignore the remainder, we're ignore the first few samples too */ - - /* prefer lower order */ - if(total_error_0 <= flac_min(flac_min(flac_min(total_error_1, total_error_2), total_error_3), total_error_4)) - order = 0; - else if(total_error_1 <= flac_min(flac_min(total_error_2, total_error_3), total_error_4)) - order = 1; - else if(total_error_2 <= flac_min(total_error_3, total_error_4)) - order = 2; - else if(total_error_3 <= total_error_4) - order = 3; - else - order = 4; - - /* Estimate the expected number of bits per residual signal sample. */ - /* 'total_error*' is linearly related to the variance of the residual */ - /* signal, so we use it directly to compute E(|x|) */ - FLAC__ASSERT(data_len > 0 || total_error_0 == 0); - FLAC__ASSERT(data_len > 0 || total_error_1 == 0); - FLAC__ASSERT(data_len > 0 || total_error_2 == 0); - FLAC__ASSERT(data_len > 0 || total_error_3 == 0); - FLAC__ASSERT(data_len > 0 || total_error_4 == 0); - - residual_bits_per_sample[0] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[1] = (float)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[2] = (float)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[3] = (float)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[4] = (float)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0); - - return order; -} - -#ifdef local_abs64 -#undef local_abs64 -#endif -#define local_abs64(x) ((uint64_t)((x)<0? -(x) : (x))) - -#define CHECK_ORDER_IS_VALID(macro_order) \ -if(shadow_error_##macro_order <= INT32_MAX) { \ - if(total_error_##macro_order < smallest_error) { \ - order = macro_order; \ - smallest_error = total_error_##macro_order ; \ - } \ - residual_bits_per_sample[ macro_order ] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); \ -} \ -else \ - residual_bits_per_sample[ macro_order ] = 34.0f; - -FLAC__SSE_TARGET("avx2") -uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) -{ - FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0, smallest_error = UINT64_MAX; - FLAC__uint64 shadow_error_0 = 0, shadow_error_1 = 0, shadow_error_2 = 0, shadow_error_3 = 0, shadow_error_4 = 0; - FLAC__uint64 error_0, error_1, error_2, error_3, error_4; - FLAC__int32 i, data_len_int; - uint32_t order = 0; - __m256i total_err0, total_err1, total_err2, total_err3, total_err4; - __m256i shadow_err0, shadow_err1, shadow_err2, shadow_err3, shadow_err4; - __m256i prev_err0, prev_err1, prev_err2, prev_err3; - __m256i tempA, tempB, bitmask; - FLAC__int64 data_scalar[4]; - FLAC__int64 prev_err0_scalar[4]; - FLAC__int64 prev_err1_scalar[4]; - FLAC__int64 prev_err2_scalar[4]; - FLAC__int64 prev_err3_scalar[4]; - total_err0 = _mm256_setzero_si256(); - total_err1 = _mm256_setzero_si256(); - total_err2 = _mm256_setzero_si256(); - total_err3 = _mm256_setzero_si256(); - total_err4 = _mm256_setzero_si256(); - shadow_err0 = _mm256_setzero_si256(); - shadow_err1 = _mm256_setzero_si256(); - shadow_err2 = _mm256_setzero_si256(); - shadow_err3 = _mm256_setzero_si256(); - shadow_err4 = _mm256_setzero_si256(); - data_len_int = data_len; - - /* First take care of preceding samples */ - for(i = -4; i < 0; i++) { - error_0 = local_abs64((FLAC__int64)data[i]); - error_1 = (i > -4) ? local_abs64((FLAC__int64)data[i] - data[i-1]) : 0 ; - error_2 = (i > -3) ? local_abs64((FLAC__int64)data[i] - 2 * (FLAC__int64)data[i-1] + data[i-2]) : 0; - error_3 = (i > -2) ? local_abs64((FLAC__int64)data[i] - 3 * (FLAC__int64)data[i-1] + 3 * (FLAC__int64)data[i-2] - data[i-3]) : 0; - - total_error_0 += error_0; - total_error_1 += error_1; - total_error_2 += error_2; - total_error_3 += error_3; - - shadow_error_0 |= error_0; - shadow_error_1 |= error_1; - shadow_error_2 |= error_2; - shadow_error_3 |= error_3; - } - - for(i = 0; i < 4; i++){ - prev_err0_scalar[i] = data[-1+i*(data_len_int/4)]; - prev_err1_scalar[i] = (FLAC__int64)(data[-1+i*(data_len_int/4)]) - data[-2+i*(data_len_int/4)]; - prev_err2_scalar[i] = prev_err1_scalar[i] - ((FLAC__int64)(data[-2+i*(data_len_int/4)]) - data[-3+i*(data_len_int/4)]); - prev_err3_scalar[i] = prev_err2_scalar[i] - ((FLAC__int64)(data[-2+i*(data_len_int/4)]) - 2*(FLAC__int64)(data[-3+i*(data_len_int/4)]) + data[-4+i*(data_len_int/4)]); - } - prev_err0 = _mm256_loadu_si256((const __m256i*)(void*)prev_err0_scalar); - prev_err1 = _mm256_loadu_si256((const __m256i*)(void*)prev_err1_scalar); - prev_err2 = _mm256_loadu_si256((const __m256i*)(void*)prev_err2_scalar); - prev_err3 = _mm256_loadu_si256((const __m256i*)(void*)prev_err3_scalar); - for(i = 0; i < data_len_int / 4; i++){ - data_scalar[0] = data[i]; - data_scalar[1] = data[i+data_len/4]; - data_scalar[2] = data[i+2*data_len/4]; - data_scalar[3] = data[i+3*data_len/4]; - tempA = _mm256_loadu_si256((const __m256i*)(void*)data_scalar); - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempA); - tempB = _mm256_xor_si256(tempA, bitmask); - tempB = _mm256_sub_epi64(tempB, bitmask); - total_err0 = _mm256_add_epi64(total_err0,tempB); - shadow_err0 = _mm256_or_si256(shadow_err0,tempB); - tempB = _mm256_sub_epi64(tempA,prev_err0); - prev_err0 = tempA; - /* Next three intrinsics calculate tempA as abs of tempB */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempB); - tempA = _mm256_xor_si256(tempB, bitmask); - tempA = _mm256_sub_epi64(tempA, bitmask); - total_err1 = _mm256_add_epi64(total_err1,tempA); - shadow_err1 = _mm256_or_si256(shadow_err1,tempA); - tempA = _mm256_sub_epi64(tempB,prev_err1); - prev_err1 = tempB; - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempA); - tempB = _mm256_xor_si256(tempA, bitmask); - tempB = _mm256_sub_epi64(tempB, bitmask); - total_err2 = _mm256_add_epi64(total_err2,tempB); - shadow_err2 = _mm256_or_si256(shadow_err2,tempB); - tempB = _mm256_sub_epi64(tempA,prev_err2); - prev_err2 = tempA; - /* Next three intrinsics calculate tempA as abs of tempB */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempB); - tempA = _mm256_xor_si256(tempB, bitmask); - tempA = _mm256_sub_epi64(tempA, bitmask); - total_err3 = _mm256_add_epi64(total_err3,tempA); - shadow_err3 = _mm256_or_si256(shadow_err3,tempA); - tempA = _mm256_sub_epi64(tempB,prev_err3); - prev_err3 = tempB; - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm256_cmpgt_epi64(_mm256_set1_epi64x(0), tempA); - tempB = _mm256_xor_si256(tempA, bitmask); - tempB = _mm256_sub_epi64(tempB, bitmask); - total_err4 = _mm256_add_epi64(total_err4,tempB); - shadow_err4 = _mm256_or_si256(shadow_err4,tempB); - } - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err0); - total_error_0 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err1); - total_error_1 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err2); - total_error_2 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err3); - total_error_3 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,total_err4); - total_error_4 += data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err0); - shadow_error_0 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err1); - shadow_error_1 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err2); - shadow_error_2 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err3); - shadow_error_3 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; - _mm256_storeu_si256((__m256i*)(void*)data_scalar,shadow_err4); - shadow_error_4 |= data_scalar[0] | data_scalar[1] | data_scalar[2] | data_scalar[3]; - - /* Take care of remaining sample */ - for(i = (data_len/4)*4; i < data_len_int; i++) { - error_0 = local_abs64((FLAC__int64)data[i]); - error_1 = local_abs64((FLAC__int64)data[i] - data[i-1]); - error_2 = local_abs64((FLAC__int64)data[i] - 2 * (FLAC__int64)data[i-1] + data[i-2]); - error_3 = local_abs64((FLAC__int64)data[i] - 3 * (FLAC__int64)data[i-1] + 3 * (FLAC__int64)data[i-2] - data[i-3]); - error_4 = local_abs64((FLAC__int64)data[i] - 4 * (FLAC__int64)data[i-1] + 6 * (FLAC__int64)data[i-2] - 4 * (FLAC__int64)data[i-3] + data[i-4]); - - total_error_0 += error_0; - total_error_1 += error_1; - total_error_2 += error_2; - total_error_3 += error_3; - total_error_4 += error_4; - - shadow_error_0 |= error_0; - shadow_error_1 |= error_1; - shadow_error_2 |= error_2; - shadow_error_3 |= error_3; - shadow_error_4 |= error_4; - } - - - CHECK_ORDER_IS_VALID(0); - CHECK_ORDER_IS_VALID(1); - CHECK_ORDER_IS_VALID(2); - CHECK_ORDER_IS_VALID(3); - CHECK_ORDER_IS_VALID(4); - - return order; -} - -#endif /* FLAC__AVX2_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ -#endif /* FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/fixed_intrin_sse2.c b/Engine/lib/flac/src/libFLAC/fixed_intrin_sse2.c deleted file mode 100644 index b92c13c10..000000000 --- a/Engine/lib/flac/src/libFLAC/fixed_intrin_sse2.c +++ /dev/null @@ -1,194 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X86INTRIN -#include "private/fixed.h" -#ifdef FLAC__SSE2_SUPPORTED - -#include /* SSE2 */ -#include -#include "private/macros.h" -#include "share/compat.h" -#include "FLAC/assert.h" - -#ifdef FLAC__CPU_IA32 -#define m128i_to_i64(dest, src) _mm_storel_epi64((__m128i*)&dest, src) -#else -#define m128i_to_i64(dest, src) dest = _mm_cvtsi128_si64(src) -#endif - -#ifdef local_abs -#undef local_abs -#endif -#define local_abs(x) ((uint32_t)((x)<0? -(x) : (x))) - -FLAC__SSE_TARGET("sse2") -uint32_t FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) -{ - FLAC__uint32 total_error_0, total_error_1, total_error_2, total_error_3, total_error_4; - FLAC__int32 i, data_len_int; - uint32_t order; - __m128i total_err0, total_err1, total_err2, total_err3, total_err4; - __m128i prev_err0, prev_err1, prev_err2, prev_err3; - __m128i tempA, tempB, bitmask; - FLAC__int32 data_scalar[4]; - FLAC__int32 prev_err0_scalar[4]; - FLAC__int32 prev_err1_scalar[4]; - FLAC__int32 prev_err2_scalar[4]; - FLAC__int32 prev_err3_scalar[4]; - total_err0 = _mm_setzero_si128(); - total_err1 = _mm_setzero_si128(); - total_err2 = _mm_setzero_si128(); - total_err3 = _mm_setzero_si128(); - total_err4 = _mm_setzero_si128(); - data_len_int = data_len; - - for(i = 0; i < 4; i++){ - prev_err0_scalar[i] = data[-1+i*(data_len_int/4)]; - prev_err1_scalar[i] = data[-1+i*(data_len_int/4)] - data[-2+i*(data_len_int/4)]; - prev_err2_scalar[i] = prev_err1_scalar[i] - (data[-2+i*(data_len_int/4)] - data[-3+i*(data_len_int/4)]); - prev_err3_scalar[i] = prev_err2_scalar[i] - (data[-2+i*(data_len_int/4)] - 2*data[-3+i*(data_len_int/4)] + data[-4+i*(data_len_int/4)]); - } - prev_err0 = _mm_loadu_si128((const __m128i*)prev_err0_scalar); - prev_err1 = _mm_loadu_si128((const __m128i*)prev_err1_scalar); - prev_err2 = _mm_loadu_si128((const __m128i*)prev_err2_scalar); - prev_err3 = _mm_loadu_si128((const __m128i*)prev_err3_scalar); - for(i = 0; i < data_len_int / 4; i++){ - data_scalar[0] = data[i]; - data_scalar[1] = data[i+data_len/4]; - data_scalar[2] = data[i+2*(data_len/4)]; - data_scalar[3] = data[i+3*(data_len/4)]; - tempA = _mm_loadu_si128((const __m128i*)data_scalar); - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm_srai_epi32(tempA, 31); - tempB = _mm_xor_si128(tempA, bitmask); - tempB = _mm_sub_epi32(tempB, bitmask); - total_err0 = _mm_add_epi32(total_err0,tempB); - tempB = _mm_sub_epi32(tempA,prev_err0); - prev_err0 = tempA; - /* Next three intrinsics calculate tempA as abs of tempB */ - bitmask = _mm_srai_epi32(tempB, 31); - tempA = _mm_xor_si128(tempB, bitmask); - tempA = _mm_sub_epi32(tempA, bitmask); - total_err1 = _mm_add_epi32(total_err1,tempA); - tempA = _mm_sub_epi32(tempB,prev_err1); - prev_err1 = tempB; - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm_srai_epi32(tempA, 31); - tempB = _mm_xor_si128(tempA, bitmask); - tempB = _mm_sub_epi32(tempB, bitmask); - total_err2 = _mm_add_epi32(total_err2,tempB); - tempB = _mm_sub_epi32(tempA,prev_err2); - prev_err2 = tempA; - /* Next three intrinsics calculate tempA as abs of tempB */ - bitmask = _mm_srai_epi32(tempB, 31); - tempA = _mm_xor_si128(tempB, bitmask); - tempA = _mm_sub_epi32(tempA, bitmask); - total_err3 = _mm_add_epi32(total_err3,tempA); - tempA = _mm_sub_epi32(tempB,prev_err3); - prev_err3 = tempB; - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm_srai_epi32(tempA, 31); - tempB = _mm_xor_si128(tempA, bitmask); - tempB = _mm_sub_epi32(tempB, bitmask); - total_err4 = _mm_add_epi32(total_err4,tempB); - } - _mm_storeu_si128((__m128i*)data_scalar,total_err0); - total_error_0 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm_storeu_si128((__m128i*)data_scalar,total_err1); - total_error_1 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm_storeu_si128((__m128i*)data_scalar,total_err2); - total_error_2 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm_storeu_si128((__m128i*)data_scalar,total_err3); - total_error_3 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm_storeu_si128((__m128i*)data_scalar,total_err4); - total_error_4 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - - /* Now the remainder of samples needs to be processed */ - i *= 4; - if(data_len % 4 > 0){ - FLAC__int32 last_error_0 = data[i-1]; - FLAC__int32 last_error_1 = data[i-1] - data[i-2]; - FLAC__int32 last_error_2 = last_error_1 - (data[i-2] - data[i-3]); - FLAC__int32 last_error_3 = last_error_2 - (data[i-2] - 2*data[i-3] + data[i-4]); - FLAC__int32 error, save; - for(; i < data_len_int; i++) { - error = data[i] ; total_error_0 += local_abs(error); save = error; - error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error; - error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error; - error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error; - error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save; - } - } - - /* prefer lower order */ - if(total_error_0 <= flac_min(flac_min(flac_min(total_error_1, total_error_2), total_error_3), total_error_4)) - order = 0; - else if(total_error_1 <= flac_min(flac_min(total_error_2, total_error_3), total_error_4)) - order = 1; - else if(total_error_2 <= flac_min(total_error_3, total_error_4)) - order = 2; - else if(total_error_3 <= total_error_4) - order = 3; - else - order = 4; - - /* Estimate the expected number of bits per residual signal sample. */ - /* 'total_error*' is linearly related to the variance of the residual */ - /* signal, so we use it directly to compute E(|x|) */ - FLAC__ASSERT(data_len > 0 || total_error_0 == 0); - FLAC__ASSERT(data_len > 0 || total_error_1 == 0); - FLAC__ASSERT(data_len > 0 || total_error_2 == 0); - FLAC__ASSERT(data_len > 0 || total_error_3 == 0); - FLAC__ASSERT(data_len > 0 || total_error_4 == 0); - - residual_bits_per_sample[0] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[1] = (float)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[2] = (float)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[3] = (float)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[4] = (float)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0); - - return order; -} - -#endif /* FLAC__SSE2_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ -#endif /* FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/fixed_intrin_sse42.c b/Engine/lib/flac/src/libFLAC/fixed_intrin_sse42.c deleted file mode 100644 index 0556eaadd..000000000 --- a/Engine/lib/flac/src/libFLAC/fixed_intrin_sse42.c +++ /dev/null @@ -1,223 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#include "private/fixed.h" -#ifdef FLAC__SSE4_2_SUPPORTED - -#include /* SSE4.2 */ -#include -#include "private/macros.h" -#include "share/compat.h" -#include "FLAC/assert.h" - -#ifdef local_abs64 -#undef local_abs64 -#endif -#define local_abs64(x) ((uint64_t)((x)<0? -(x) : (x))) - -#define CHECK_ORDER_IS_VALID(macro_order) \ -if(shadow_error_##macro_order <= INT32_MAX) { \ - if(total_error_##macro_order < smallest_error) { \ - order = macro_order; \ - smallest_error = total_error_##macro_order ; \ - } \ - residual_bits_per_sample[ macro_order ] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); \ -} \ -else \ - residual_bits_per_sample[ macro_order ] = 34.0f; - -FLAC__SSE_TARGET("sse4.2") -uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) -{ - FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0, smallest_error = UINT64_MAX; - FLAC__uint64 shadow_error_0 = 0, shadow_error_1 = 0, shadow_error_2 = 0, shadow_error_3 = 0, shadow_error_4 = 0; - FLAC__uint64 error_0, error_1, error_2, error_3, error_4; - FLAC__int32 i, data_len_int; - uint32_t order = 0; - __m128i total_err0, total_err1, total_err2, total_err3, total_err4; - __m128i shadow_err0, shadow_err1, shadow_err2, shadow_err3, shadow_err4; - __m128i prev_err0, prev_err1, prev_err2, prev_err3; - __m128i tempA, tempB, bitmask; - FLAC__int64 data_scalar[2]; - FLAC__int64 prev_err0_scalar[2]; - FLAC__int64 prev_err1_scalar[2]; - FLAC__int64 prev_err2_scalar[2]; - FLAC__int64 prev_err3_scalar[2]; - total_err0 = _mm_setzero_si128(); - total_err1 = _mm_setzero_si128(); - total_err2 = _mm_setzero_si128(); - total_err3 = _mm_setzero_si128(); - total_err4 = _mm_setzero_si128(); - shadow_err0 = _mm_setzero_si128(); - shadow_err1 = _mm_setzero_si128(); - shadow_err2 = _mm_setzero_si128(); - shadow_err3 = _mm_setzero_si128(); - shadow_err4 = _mm_setzero_si128(); - data_len_int = data_len; - - /* First take care of preceding samples */ - for(i = -4; i < 0; i++) { - error_0 = local_abs64((FLAC__int64)data[i]); - error_1 = (i > -4) ? local_abs64((FLAC__int64)data[i] - data[i-1]) : 0 ; - error_2 = (i > -3) ? local_abs64((FLAC__int64)data[i] - 2 * (FLAC__int64)data[i-1] + data[i-2]) : 0; - error_3 = (i > -2) ? local_abs64((FLAC__int64)data[i] - 3 * (FLAC__int64)data[i-1] + 3 * (FLAC__int64)data[i-2] - data[i-3]) : 0; - - total_error_0 += error_0; - total_error_1 += error_1; - total_error_2 += error_2; - total_error_3 += error_3; - - shadow_error_0 |= error_0; - shadow_error_1 |= error_1; - shadow_error_2 |= error_2; - shadow_error_3 |= error_3; - } - - for(i = 0; i < 2; i++){ - prev_err0_scalar[i] = data[-1+i*(data_len_int/2)]; - prev_err1_scalar[i] = (FLAC__int64)(data[-1+i*(data_len_int/2)]) - data[-2+i*(data_len_int/2)]; - prev_err2_scalar[i] = prev_err1_scalar[i] - ((FLAC__int64)(data[-2+i*(data_len_int/2)]) - data[-3+i*(data_len_int/2)]); - prev_err3_scalar[i] = prev_err2_scalar[i] - ((FLAC__int64)(data[-2+i*(data_len_int/2)]) - 2*(FLAC__int64)(data[-3+i*(data_len_int/2)]) + data[-4+i*(data_len_int/2)]); - } - prev_err0 = _mm_loadu_si128((const __m128i*)prev_err0_scalar); - prev_err1 = _mm_loadu_si128((const __m128i*)prev_err1_scalar); - prev_err2 = _mm_loadu_si128((const __m128i*)prev_err2_scalar); - prev_err3 = _mm_loadu_si128((const __m128i*)prev_err3_scalar); - for(i = 0; i < data_len_int / 2; i++){ - data_scalar[0] = data[i]; - data_scalar[1] = data[i+data_len/2]; - tempA = _mm_loadu_si128((const __m128i*)data_scalar); - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm_cmpgt_epi64(_mm_set1_epi64x(0), tempA); - tempB = _mm_xor_si128(tempA, bitmask); - tempB = _mm_sub_epi64(tempB, bitmask); - total_err0 = _mm_add_epi64(total_err0,tempB); - shadow_err0 = _mm_or_si128(shadow_err0,tempB); - tempB = _mm_sub_epi64(tempA,prev_err0); - prev_err0 = tempA; - /* Next three intrinsics calculate tempA as abs of tempB */ - bitmask = _mm_cmpgt_epi64(_mm_set1_epi64x(0), tempB); - tempA = _mm_xor_si128(tempB, bitmask); - tempA = _mm_sub_epi64(tempA, bitmask); - total_err1 = _mm_add_epi64(total_err1,tempA); - shadow_err1 = _mm_or_si128(shadow_err1,tempA); - tempA = _mm_sub_epi64(tempB,prev_err1); - prev_err1 = tempB; - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm_cmpgt_epi64(_mm_set1_epi64x(0), tempA); - tempB = _mm_xor_si128(tempA, bitmask); - tempB = _mm_sub_epi64(tempB, bitmask); - total_err2 = _mm_add_epi64(total_err2,tempB); - shadow_err2 = _mm_or_si128(shadow_err2,tempB); - tempB = _mm_sub_epi64(tempA,prev_err2); - prev_err2 = tempA; - /* Next three intrinsics calculate tempA as abs of tempB */ - bitmask = _mm_cmpgt_epi64(_mm_set1_epi64x(0), tempB); - tempA = _mm_xor_si128(tempB, bitmask); - tempA = _mm_sub_epi64(tempA, bitmask); - total_err3 = _mm_add_epi64(total_err3,tempA); - shadow_err3 = _mm_or_si128(shadow_err3,tempA); - tempA = _mm_sub_epi64(tempB,prev_err3); - prev_err3 = tempB; - /* Next three intrinsics calculate tempB as abs of tempA */ - bitmask = _mm_cmpgt_epi64(_mm_set1_epi64x(0), tempA); - tempB = _mm_xor_si128(tempA, bitmask); - tempB = _mm_sub_epi64(tempB, bitmask); - total_err4 = _mm_add_epi64(total_err4,tempB); - shadow_err4 = _mm_or_si128(shadow_err4,tempB); - } - _mm_storeu_si128((__m128i*)data_scalar,total_err0); - total_error_0 += data_scalar[0] + data_scalar[1]; - _mm_storeu_si128((__m128i*)data_scalar,total_err1); - total_error_1 += data_scalar[0] + data_scalar[1]; - _mm_storeu_si128((__m128i*)data_scalar,total_err2); - total_error_2 += data_scalar[0] + data_scalar[1]; - _mm_storeu_si128((__m128i*)data_scalar,total_err3); - total_error_3 += data_scalar[0] + data_scalar[1]; - _mm_storeu_si128((__m128i*)data_scalar,total_err4); - total_error_4 += data_scalar[0] + data_scalar[1]; - _mm_storeu_si128((__m128i*)data_scalar,shadow_err0); - shadow_error_0 |= data_scalar[0] | data_scalar[1]; - _mm_storeu_si128((__m128i*)data_scalar,shadow_err1); - shadow_error_1 |= data_scalar[0] | data_scalar[1]; - _mm_storeu_si128((__m128i*)data_scalar,shadow_err2); - shadow_error_2 |= data_scalar[0] | data_scalar[1]; - _mm_storeu_si128((__m128i*)data_scalar,shadow_err3); - shadow_error_3 |= data_scalar[0] | data_scalar[1]; - _mm_storeu_si128((__m128i*)data_scalar,shadow_err4); - shadow_error_4 |= data_scalar[0] | data_scalar[1]; - - /* Take care of remaining sample */ - if(data_len_int % 2 > 0) { - i += data_len/2; - error_0 = local_abs64((FLAC__int64)data[i]); - error_1 = local_abs64((FLAC__int64)data[i] - data[i-1]); - error_2 = local_abs64((FLAC__int64)data[i] - 2 * (FLAC__int64)data[i-1] + data[i-2]); - error_3 = local_abs64((FLAC__int64)data[i] - 3 * (FLAC__int64)data[i-1] + 3 * (FLAC__int64)data[i-2] - data[i-3]); - error_4 = local_abs64((FLAC__int64)data[i] - 4 * (FLAC__int64)data[i-1] + 6 * (FLAC__int64)data[i-2] - 4 * (FLAC__int64)data[i-3] + data[i-4]); - - total_error_0 += error_0; - total_error_1 += error_1; - total_error_2 += error_2; - total_error_3 += error_3; - total_error_4 += error_4; - - shadow_error_0 |= error_0; - shadow_error_1 |= error_1; - shadow_error_2 |= error_2; - shadow_error_3 |= error_3; - shadow_error_4 |= error_4; - } - - - CHECK_ORDER_IS_VALID(0); - CHECK_ORDER_IS_VALID(1); - CHECK_ORDER_IS_VALID(2); - CHECK_ORDER_IS_VALID(3); - CHECK_ORDER_IS_VALID(4); - - return order; -} - -#endif /* FLAC__SSE4_2_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ -#endif /* FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/fixed_intrin_ssse3.c b/Engine/lib/flac/src/libFLAC/fixed_intrin_ssse3.c deleted file mode 100644 index 551693bf8..000000000 --- a/Engine/lib/flac/src/libFLAC/fixed_intrin_ssse3.c +++ /dev/null @@ -1,179 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#include "private/fixed.h" -#ifdef FLAC__SSSE3_SUPPORTED - -#include /* SSSE3 */ -#include -#include "private/macros.h" -#include "share/compat.h" -#include "FLAC/assert.h" - -#ifdef FLAC__CPU_IA32 -#define m128i_to_i64(dest, src) _mm_storel_epi64((__m128i*)&dest, src) -#else -#define m128i_to_i64(dest, src) dest = _mm_cvtsi128_si64(src) -#endif - -#ifdef local_abs -#undef local_abs -#endif -#define local_abs(x) ((uint32_t)((x)<0? -(x) : (x))) - -FLAC__SSE_TARGET("ssse3") -uint32_t FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) -{ - FLAC__uint32 total_error_0, total_error_1, total_error_2, total_error_3, total_error_4; - FLAC__int32 i, data_len_int; - uint32_t order; - __m128i total_err0, total_err1, total_err2, total_err3, total_err4; - __m128i prev_err0, prev_err1, prev_err2, prev_err3; - __m128i tempA, tempB; - FLAC__int32 data_scalar[4]; - FLAC__int32 prev_err0_scalar[4]; - FLAC__int32 prev_err1_scalar[4]; - FLAC__int32 prev_err2_scalar[4]; - FLAC__int32 prev_err3_scalar[4]; - total_err0 = _mm_setzero_si128(); - total_err1 = _mm_setzero_si128(); - total_err2 = _mm_setzero_si128(); - total_err3 = _mm_setzero_si128(); - total_err4 = _mm_setzero_si128(); - data_len_int = data_len; - - for(i = 0; i < 4; i++){ - prev_err0_scalar[i] = data[-1+i*(data_len_int/4)]; - prev_err1_scalar[i] = data[-1+i*(data_len_int/4)] - data[-2+i*(data_len_int/4)]; - prev_err2_scalar[i] = prev_err1_scalar[i] - (data[-2+i*(data_len_int/4)] - data[-3+i*(data_len_int/4)]); - prev_err3_scalar[i] = prev_err2_scalar[i] - (data[-2+i*(data_len_int/4)] - 2*data[-3+i*(data_len_int/4)] + data[-4+i*(data_len_int/4)]); - } - prev_err0 = _mm_loadu_si128((const __m128i*)prev_err0_scalar); - prev_err1 = _mm_loadu_si128((const __m128i*)prev_err1_scalar); - prev_err2 = _mm_loadu_si128((const __m128i*)prev_err2_scalar); - prev_err3 = _mm_loadu_si128((const __m128i*)prev_err3_scalar); - for(i = 0; i < data_len_int / 4; i++){ - data_scalar[0] = data[i]; - data_scalar[1] = data[i+data_len/4]; - data_scalar[2] = data[i+2*(data_len/4)]; - data_scalar[3] = data[i+3*(data_len/4)]; - tempA = _mm_loadu_si128((const __m128i*)data_scalar); - tempB = _mm_abs_epi32(tempA); - total_err0 = _mm_add_epi32(total_err0,tempB); - tempB = _mm_sub_epi32(tempA,prev_err0); - prev_err0 = tempA; - tempA = _mm_abs_epi32(tempB); - total_err1 = _mm_add_epi32(total_err1,tempA); - tempA = _mm_sub_epi32(tempB,prev_err1); - prev_err1 = tempB; - tempB = _mm_abs_epi32(tempA); - total_err2 = _mm_add_epi32(total_err2,tempB); - tempB = _mm_sub_epi32(tempA,prev_err2); - prev_err2 = tempA; - tempA = _mm_abs_epi32(tempB); - total_err3 = _mm_add_epi32(total_err3,tempA); - tempA = _mm_sub_epi32(tempB,prev_err3); - prev_err3 = tempB; - tempB = _mm_abs_epi32(tempA); - total_err4 = _mm_add_epi32(total_err4,tempB); - } - _mm_storeu_si128((__m128i*)data_scalar,total_err0); - total_error_0 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm_storeu_si128((__m128i*)data_scalar,total_err1); - total_error_1 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm_storeu_si128((__m128i*)data_scalar,total_err2); - total_error_2 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm_storeu_si128((__m128i*)data_scalar,total_err3); - total_error_3 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - _mm_storeu_si128((__m128i*)data_scalar,total_err4); - total_error_4 = data_scalar[0] + data_scalar[1] + data_scalar[2] + data_scalar[3]; - - /* Now the remainder of samples needs to be processed */ - i *= 4; - if(data_len % 4 > 0){ - FLAC__int32 last_error_0 = data[i-1]; - FLAC__int32 last_error_1 = data[i-1] - data[i-2]; - FLAC__int32 last_error_2 = last_error_1 - (data[i-2] - data[i-3]); - FLAC__int32 last_error_3 = last_error_2 - (data[i-2] - 2*data[i-3] + data[i-4]); - FLAC__int32 error, save; - for(; i < data_len_int; i++) { - error = data[i] ; total_error_0 += local_abs(error); save = error; - error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error; - error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error; - error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error; - error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save; - } - } - - /* prefer lower order */ - if(total_error_0 <= flac_min(flac_min(flac_min(total_error_1, total_error_2), total_error_3), total_error_4)) - order = 0; - else if(total_error_1 <= flac_min(flac_min(total_error_2, total_error_3), total_error_4)) - order = 1; - else if(total_error_2 <= flac_min(total_error_3, total_error_4)) - order = 2; - else if(total_error_3 <= total_error_4) - order = 3; - else - order = 4; - - /* Estimate the expected number of bits per residual signal sample. */ - /* 'total_error*' is linearly related to the variance of the residual */ - /* signal, so we use it directly to compute E(|x|) */ - FLAC__ASSERT(data_len > 0 || total_error_0 == 0); - FLAC__ASSERT(data_len > 0 || total_error_1 == 0); - FLAC__ASSERT(data_len > 0 || total_error_2 == 0); - FLAC__ASSERT(data_len > 0 || total_error_3 == 0); - FLAC__ASSERT(data_len > 0 || total_error_4 == 0); - - residual_bits_per_sample[0] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[1] = (float)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[2] = (float)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[3] = (float)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0); - residual_bits_per_sample[4] = (float)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0); - - return order; -} - -#endif /* FLAC__SSSE3_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ -#endif /* FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/flac.pc.in b/Engine/lib/flac/src/libFLAC/flac.pc.in deleted file mode 100644 index 56e8594e8..000000000 --- a/Engine/lib/flac/src/libFLAC/flac.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: FLAC -Description: Free Lossless Audio Codec Library -Version: @VERSION@ -Requires.private: @OGG_PACKAGE@ -Libs: -L${libdir} -lFLAC -Libs.private: -lm -Cflags: -I${includedir} diff --git a/Engine/lib/flac/src/libFLAC/float.c b/Engine/lib/flac/src/libFLAC/float.c deleted file mode 100644 index a06ad285e..000000000 --- a/Engine/lib/flac/src/libFLAC/float.c +++ /dev/null @@ -1,302 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/assert.h" -#include "share/compat.h" -#include "private/float.h" - -#ifdef FLAC__INTEGER_ONLY_LIBRARY - -const FLAC__fixedpoint FLAC__FP_ZERO = 0; -const FLAC__fixedpoint FLAC__FP_ONE_HALF = 0x00008000; -const FLAC__fixedpoint FLAC__FP_ONE = 0x00010000; -const FLAC__fixedpoint FLAC__FP_LN2 = 45426; -const FLAC__fixedpoint FLAC__FP_E = 178145; - -/* Lookup tables for Knuth's logarithm algorithm */ -#define LOG2_LOOKUP_PRECISION 16 -static const FLAC__uint32 log2_lookup[][LOG2_LOOKUP_PRECISION] = { - { - /* - * 0 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ 0x00000001, - /* lg(4/3) = */ 0x00000000, - /* lg(8/7) = */ 0x00000000, - /* lg(16/15) = */ 0x00000000, - /* lg(32/31) = */ 0x00000000, - /* lg(64/63) = */ 0x00000000, - /* lg(128/127) = */ 0x00000000, - /* lg(256/255) = */ 0x00000000, - /* lg(512/511) = */ 0x00000000, - /* lg(1024/1023) = */ 0x00000000, - /* lg(2048/2047) = */ 0x00000000, - /* lg(4096/4095) = */ 0x00000000, - /* lg(8192/8191) = */ 0x00000000, - /* lg(16384/16383) = */ 0x00000000, - /* lg(32768/32767) = */ 0x00000000 - }, - { - /* - * 4 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ 0x00000010, - /* lg(4/3) = */ 0x00000007, - /* lg(8/7) = */ 0x00000003, - /* lg(16/15) = */ 0x00000001, - /* lg(32/31) = */ 0x00000001, - /* lg(64/63) = */ 0x00000000, - /* lg(128/127) = */ 0x00000000, - /* lg(256/255) = */ 0x00000000, - /* lg(512/511) = */ 0x00000000, - /* lg(1024/1023) = */ 0x00000000, - /* lg(2048/2047) = */ 0x00000000, - /* lg(4096/4095) = */ 0x00000000, - /* lg(8192/8191) = */ 0x00000000, - /* lg(16384/16383) = */ 0x00000000, - /* lg(32768/32767) = */ 0x00000000 - }, - { - /* - * 8 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ 0x00000100, - /* lg(4/3) = */ 0x0000006a, - /* lg(8/7) = */ 0x00000031, - /* lg(16/15) = */ 0x00000018, - /* lg(32/31) = */ 0x0000000c, - /* lg(64/63) = */ 0x00000006, - /* lg(128/127) = */ 0x00000003, - /* lg(256/255) = */ 0x00000001, - /* lg(512/511) = */ 0x00000001, - /* lg(1024/1023) = */ 0x00000000, - /* lg(2048/2047) = */ 0x00000000, - /* lg(4096/4095) = */ 0x00000000, - /* lg(8192/8191) = */ 0x00000000, - /* lg(16384/16383) = */ 0x00000000, - /* lg(32768/32767) = */ 0x00000000 - }, - { - /* - * 12 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ 0x00001000, - /* lg(4/3) = */ 0x000006a4, - /* lg(8/7) = */ 0x00000315, - /* lg(16/15) = */ 0x0000017d, - /* lg(32/31) = */ 0x000000bc, - /* lg(64/63) = */ 0x0000005d, - /* lg(128/127) = */ 0x0000002e, - /* lg(256/255) = */ 0x00000017, - /* lg(512/511) = */ 0x0000000c, - /* lg(1024/1023) = */ 0x00000006, - /* lg(2048/2047) = */ 0x00000003, - /* lg(4096/4095) = */ 0x00000001, - /* lg(8192/8191) = */ 0x00000001, - /* lg(16384/16383) = */ 0x00000000, - /* lg(32768/32767) = */ 0x00000000 - }, - { - /* - * 16 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ 0x00010000, - /* lg(4/3) = */ 0x00006a40, - /* lg(8/7) = */ 0x00003151, - /* lg(16/15) = */ 0x000017d6, - /* lg(32/31) = */ 0x00000bba, - /* lg(64/63) = */ 0x000005d1, - /* lg(128/127) = */ 0x000002e6, - /* lg(256/255) = */ 0x00000172, - /* lg(512/511) = */ 0x000000b9, - /* lg(1024/1023) = */ 0x0000005c, - /* lg(2048/2047) = */ 0x0000002e, - /* lg(4096/4095) = */ 0x00000017, - /* lg(8192/8191) = */ 0x0000000c, - /* lg(16384/16383) = */ 0x00000006, - /* lg(32768/32767) = */ 0x00000003 - }, - { - /* - * 20 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ 0x00100000, - /* lg(4/3) = */ 0x0006a3fe, - /* lg(8/7) = */ 0x00031513, - /* lg(16/15) = */ 0x00017d60, - /* lg(32/31) = */ 0x0000bb9d, - /* lg(64/63) = */ 0x00005d10, - /* lg(128/127) = */ 0x00002e59, - /* lg(256/255) = */ 0x00001721, - /* lg(512/511) = */ 0x00000b8e, - /* lg(1024/1023) = */ 0x000005c6, - /* lg(2048/2047) = */ 0x000002e3, - /* lg(4096/4095) = */ 0x00000171, - /* lg(8192/8191) = */ 0x000000b9, - /* lg(16384/16383) = */ 0x0000005c, - /* lg(32768/32767) = */ 0x0000002e - }, - { - /* - * 24 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ 0x01000000, - /* lg(4/3) = */ 0x006a3fe6, - /* lg(8/7) = */ 0x00315130, - /* lg(16/15) = */ 0x0017d605, - /* lg(32/31) = */ 0x000bb9ca, - /* lg(64/63) = */ 0x0005d0fc, - /* lg(128/127) = */ 0x0002e58f, - /* lg(256/255) = */ 0x0001720e, - /* lg(512/511) = */ 0x0000b8d8, - /* lg(1024/1023) = */ 0x00005c61, - /* lg(2048/2047) = */ 0x00002e2d, - /* lg(4096/4095) = */ 0x00001716, - /* lg(8192/8191) = */ 0x00000b8b, - /* lg(16384/16383) = */ 0x000005c5, - /* lg(32768/32767) = */ 0x000002e3 - }, - { - /* - * 28 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ 0x10000000, - /* lg(4/3) = */ 0x06a3fe5c, - /* lg(8/7) = */ 0x03151301, - /* lg(16/15) = */ 0x017d6049, - /* lg(32/31) = */ 0x00bb9ca6, - /* lg(64/63) = */ 0x005d0fba, - /* lg(128/127) = */ 0x002e58f7, - /* lg(256/255) = */ 0x001720da, - /* lg(512/511) = */ 0x000b8d87, - /* lg(1024/1023) = */ 0x0005c60b, - /* lg(2048/2047) = */ 0x0002e2d7, - /* lg(4096/4095) = */ 0x00017160, - /* lg(8192/8191) = */ 0x0000b8ad, - /* lg(16384/16383) = */ 0x00005c56, - /* lg(32768/32767) = */ 0x00002e2b - } -}; - -#if 0 -static const FLAC__uint64 log2_lookup_wide[] = { - { - /* - * 32 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ FLAC__U64L(0x100000000), - /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c6), - /* lg(8/7) = */ FLAC__U64L(0x31513015), - /* lg(16/15) = */ FLAC__U64L(0x17d60497), - /* lg(32/31) = */ FLAC__U64L(0x0bb9ca65), - /* lg(64/63) = */ FLAC__U64L(0x05d0fba2), - /* lg(128/127) = */ FLAC__U64L(0x02e58f74), - /* lg(256/255) = */ FLAC__U64L(0x01720d9c), - /* lg(512/511) = */ FLAC__U64L(0x00b8d875), - /* lg(1024/1023) = */ FLAC__U64L(0x005c60aa), - /* lg(2048/2047) = */ FLAC__U64L(0x002e2d72), - /* lg(4096/4095) = */ FLAC__U64L(0x00171600), - /* lg(8192/8191) = */ FLAC__U64L(0x000b8ad2), - /* lg(16384/16383) = */ FLAC__U64L(0x0005c55d), - /* lg(32768/32767) = */ FLAC__U64L(0x0002e2ac) - }, - { - /* - * 48 fraction bits - */ - /* undefined */ 0x00000000, - /* lg(2/1) = */ FLAC__U64L(0x1000000000000), - /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c60429), - /* lg(8/7) = */ FLAC__U64L(0x315130157f7a), - /* lg(16/15) = */ FLAC__U64L(0x17d60496cfbb), - /* lg(32/31) = */ FLAC__U64L(0xbb9ca64ecac), - /* lg(64/63) = */ FLAC__U64L(0x5d0fba187cd), - /* lg(128/127) = */ FLAC__U64L(0x2e58f7441ee), - /* lg(256/255) = */ FLAC__U64L(0x1720d9c06a8), - /* lg(512/511) = */ FLAC__U64L(0xb8d8752173), - /* lg(1024/1023) = */ FLAC__U64L(0x5c60aa252e), - /* lg(2048/2047) = */ FLAC__U64L(0x2e2d71b0d8), - /* lg(4096/4095) = */ FLAC__U64L(0x1716001719), - /* lg(8192/8191) = */ FLAC__U64L(0xb8ad1de1b), - /* lg(16384/16383) = */ FLAC__U64L(0x5c55d640d), - /* lg(32768/32767) = */ FLAC__U64L(0x2e2abcf52) - } -}; -#endif - -FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, uint32_t fracbits, uint32_t precision) -{ - const FLAC__uint32 ONE = (1u << fracbits); - const FLAC__uint32 *table = log2_lookup[fracbits >> 2]; - - FLAC__ASSERT(fracbits < 32); - FLAC__ASSERT((fracbits & 0x3) == 0); - - if(x < ONE) - return 0; - - if(precision > LOG2_LOOKUP_PRECISION) - precision = LOG2_LOOKUP_PRECISION; - - /* Knuth's algorithm for computing logarithms, optimized for base-2 with lookup tables */ - { - FLAC__uint32 y = 0; - FLAC__uint32 z = x >> 1, k = 1; - while (x > ONE && k < precision) { - if (x - z >= ONE) { - x -= z; - z = x >> k; - y += table[k]; - } - else { - z >>= 1; - k++; - } - } - return y; - } -} - -#endif /* defined FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/format.c b/Engine/lib/flac/src/libFLAC/format.c deleted file mode 100644 index 8bbffbef8..000000000 --- a/Engine/lib/flac/src/libFLAC/format.c +++ /dev/null @@ -1,608 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include /* for qsort() */ -#include /* for memset() */ -#include "FLAC/assert.h" -#include "FLAC/format.h" -#include "share/alloc.h" -#include "share/compat.h" -#include "private/format.h" -#include "private/macros.h" - -#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) -# ifdef GIT_COMMIT_TAG -FLAC_API const char *FLAC__VERSION_STRING = GIT_COMMIT_TAG; -FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " GIT_COMMIT_TAG " " GIT_COMMIT_DATE; -# else -FLAC_API const char *FLAC__VERSION_STRING = "git-" GIT_COMMIT_HASH " " GIT_COMMIT_DATE; -FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC git-" GIT_COMMIT_HASH " " GIT_COMMIT_DATE; -# endif -#else -/* PACKAGE_VERSION should come from configure */ -FLAC_API const char *FLAC__VERSION_STRING = PACKAGE_VERSION; -FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20230623"; -#endif - -FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' }; -FLAC_API const uint32_t FLAC__STREAM_SYNC = 0x664C6143; -FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN = 32; /* bits */ - -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN = 24; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN = 24; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN = 20; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN = 3; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN = 5; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN = 36; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN = 128; /* bits */ - -FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN = 32; /* bits */ - -FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */ - -FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = FLAC__U64L(0xffffffffffffffff); - -FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */ - -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN = 64; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN = 8; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN = 3*8; /* bits */ - -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN = 64; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN = 8; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN = 12*8; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN = 1; /* bit */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN = 1; /* bit */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN = 6+13*8; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8; /* bits */ - -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */ - -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */ - -FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */ -FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */ - -FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC = 0x3ffe; -FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN = 14; /* bits */ -FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN = 1; /* bits */ -FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN = 1; /* bits */ -FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN = 4; /* bits */ -FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN = 4; /* bits */ -FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN = 4; /* bits */ -FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN = 3; /* bits */ -FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN = 1; /* bits */ -FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN = 8; /* bits */ - -FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN = 16; /* bits */ - -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN = 2; /* bits */ -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN = 4; /* bits */ -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN = 4; /* bits */ -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN = 5; /* bits */ -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN = 5; /* bits */ - -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER = 15; /* == (1< FLAC__MAX_SAMPLE_RATE) { - return false; - } - else - return true; -} - -FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate) -{ - if(blocksize > 16384) - return false; - else if(sample_rate <= 48000 && blocksize > 4608) - return false; - else - return true; -} - -FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate) -{ - if( // sample rate is not subset if - !FLAC__format_sample_rate_is_valid(sample_rate) || // sample rate is invalid or - sample_rate >= ((1u << 16) * 10) || // sample rate is larger then or equal to 655360 or - (sample_rate >= (1u << 16) && sample_rate % 10 != 0) //sample rate is >= 65536 and not divisible by 10 - ) { - return false; - } - else - return true; -} - -/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ -FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table) -{ - uint32_t i; - FLAC__uint64 prev_sample_number = 0; - FLAC__bool got_prev = false; - - FLAC__ASSERT(0 != seek_table); - - if((FLAC__uint64)(seek_table->num_points) * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) - return false; - - for(i = 0; i < seek_table->num_points; i++) { - if(got_prev) { - if( - seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && - seek_table->points[i].sample_number <= prev_sample_number - ) - return false; - } - prev_sample_number = seek_table->points[i].sample_number; - got_prev = true; - } - - return true; -} - -/* used as the sort predicate for qsort() */ -static int seekpoint_compare_(const FLAC__StreamMetadata_SeekPoint *l, const FLAC__StreamMetadata_SeekPoint *r) -{ - /* we don't just 'return l->sample_number - r->sample_number' since the result (FLAC__int64) might overflow an 'int' */ - if(l->sample_number == r->sample_number) - return 0; - else if(l->sample_number < r->sample_number) - return -1; - else - return 1; -} - -/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ -FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table) -{ - uint32_t i, j; - FLAC__bool first; - - FLAC__ASSERT(0 != seek_table); - - if (seek_table->num_points == 0) - return 0; - - /* sort the seekpoints */ - qsort(seek_table->points, seek_table->num_points, sizeof(FLAC__StreamMetadata_SeekPoint), (int (*)(const void *, const void *))seekpoint_compare_); - - /* uniquify the seekpoints */ - first = true; - for(i = j = 0; i < seek_table->num_points; i++) { - if(seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) { - if(!first) { - if(seek_table->points[i].sample_number == seek_table->points[j-1].sample_number) - continue; - } - } - first = false; - seek_table->points[j++] = seek_table->points[i]; - } - - for(i = j; i < seek_table->num_points; i++) { - seek_table->points[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - seek_table->points[i].stream_offset = 0; - seek_table->points[i].frame_samples = 0; - } - - return j; -} - -/* - * also disallows non-shortest-form encodings, c.f. - * http://www.unicode.org/versions/corrigendum1.html - * and a more clear explanation at the end of this section: - * http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - */ -static uint32_t utf8len_(const FLAC__byte *utf8) -{ - FLAC__ASSERT(0 != utf8); - if ((utf8[0] & 0x80) == 0) { - return 1; - } - else if ((utf8[0] & 0xE0) == 0xC0 && (utf8[1] & 0xC0) == 0x80) { - if ((utf8[0] & 0xFE) == 0xC0) /* overlong sequence check */ - return 0; - return 2; - } - else if ((utf8[0] & 0xF0) == 0xE0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80) { - if (utf8[0] == 0xE0 && (utf8[1] & 0xE0) == 0x80) /* overlong sequence check */ - return 0; - /* illegal surrogates check (U+D800...U+DFFF and U+FFFE...U+FFFF) */ - if (utf8[0] == 0xED && (utf8[1] & 0xE0) == 0xA0) /* D800-DFFF */ - return 0; - if (utf8[0] == 0xEF && utf8[1] == 0xBF && (utf8[2] & 0xFE) == 0xBE) /* FFFE-FFFF */ - return 0; - return 3; - } - else if ((utf8[0] & 0xF8) == 0xF0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80) { - if (utf8[0] == 0xF0 && (utf8[1] & 0xF0) == 0x80) /* overlong sequence check */ - return 0; - return 4; - } - else if ((utf8[0] & 0xFC) == 0xF8 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80) { - if (utf8[0] == 0xF8 && (utf8[1] & 0xF8) == 0x80) /* overlong sequence check */ - return 0; - return 5; - } - else if ((utf8[0] & 0xFE) == 0xFC && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80 && (utf8[5] & 0xC0) == 0x80) { - if (utf8[0] == 0xFC && (utf8[1] & 0xFC) == 0x80) /* overlong sequence check */ - return 0; - return 6; - } - else { - return 0; - } -} - -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name) -{ - char c; - for(c = *name; c; c = *(++name)) - if(c < 0x20 || c == 0x3d || c > 0x7d) - return false; - return true; -} - -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, uint32_t length) -{ - if(length == (uint32_t)(-1)) { - while(*value) { - uint32_t n = utf8len_(value); - if(n == 0) - return false; - value += n; - } - } - else { - const FLAC__byte *end = value + length; - while(value < end) { - uint32_t n = utf8len_(value); - if(n == 0) - return false; - value += n; - } - if(value != end) - return false; - } - return true; -} - -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, uint32_t length) -{ - const FLAC__byte *s, *end; - - for(s = entry, end = s + length; s < end && *s != '='; s++) { - if(*s < 0x20 || *s > 0x7D) - return false; - } - if(s == end) - return false; - - s++; /* skip '=' */ - - while(s < end) { - uint32_t n = utf8len_(s); - if(n == 0) - return false; - s += n; - } - if(s != end) - return false; - - return true; -} - -/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ -FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation) -{ - uint32_t i, j; - - if(check_cd_da_subset) { - if(cue_sheet->lead_in < 2 * 44100) { - if(violation) *violation = "CD-DA cue sheet must have a lead-in length of at least 2 seconds"; - return false; - } - if(cue_sheet->lead_in % 588 != 0) { - if(violation) *violation = "CD-DA cue sheet lead-in length must be evenly divisible by 588 samples"; - return false; - } - } - - if(cue_sheet->num_tracks == 0) { - if(violation) *violation = "cue sheet must have at least one track (the lead-out)"; - return false; - } - - if(check_cd_da_subset && cue_sheet->tracks[cue_sheet->num_tracks-1].number != 170) { - if(violation) *violation = "CD-DA cue sheet must have a lead-out track number 170 (0xAA)"; - return false; - } - - for(i = 0; i < cue_sheet->num_tracks; i++) { - if(cue_sheet->tracks[i].number == 0) { - if(violation) *violation = "cue sheet may not have a track number 0"; - return false; - } - - if(check_cd_da_subset) { - if(!((cue_sheet->tracks[i].number >= 1 && cue_sheet->tracks[i].number <= 99) || cue_sheet->tracks[i].number == 170)) { - if(violation) *violation = "CD-DA cue sheet track number must be 1-99 or 170"; - return false; - } - } - - if(check_cd_da_subset && cue_sheet->tracks[i].offset % 588 != 0) { - if(violation) { - if(i == cue_sheet->num_tracks-1) /* the lead-out track... */ - *violation = "CD-DA cue sheet lead-out offset must be evenly divisible by 588 samples"; - else - *violation = "CD-DA cue sheet track offset must be evenly divisible by 588 samples"; - } - return false; - } - - if(i < cue_sheet->num_tracks - 1) { - if(cue_sheet->tracks[i].num_indices == 0) { - if(violation) *violation = "cue sheet track must have at least one index point"; - return false; - } - - if(cue_sheet->tracks[i].indices[0].number > 1) { - if(violation) *violation = "cue sheet track's first index number must be 0 or 1"; - return false; - } - } - - for(j = 0; j < cue_sheet->tracks[i].num_indices; j++) { - if(check_cd_da_subset && cue_sheet->tracks[i].indices[j].offset % 588 != 0) { - if(violation) *violation = "CD-DA cue sheet track index offset must be evenly divisible by 588 samples"; - return false; - } - - if(j > 0) { - if(cue_sheet->tracks[i].indices[j].number != cue_sheet->tracks[i].indices[j-1].number + 1) { - if(violation) *violation = "cue sheet track index numbers must increase by 1"; - return false; - } - } - } - } - - return true; -} - -/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ -FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation) -{ - char *p; - FLAC__byte *b; - - for(p = picture->mime_type; *p; p++) { - if(*p < 0x20 || *p > 0x7e) { - if(violation) *violation = "MIME type string must contain only printable ASCII characters (0x20-0x7e)"; - return false; - } - } - - for(b = picture->description; *b; ) { - uint32_t n = utf8len_(b); - if(n == 0) { - if(violation) *violation = "description string must be valid UTF-8"; - return false; - } - b += n; - } - - return true; -} - -/* - * These routines are private to libFLAC - */ -#if 0 /* UNUSED */ -uint32_t FLAC__format_get_max_rice_partition_order(uint32_t blocksize, uint32_t predictor_order) -{ - return - FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order( - FLAC__format_get_max_rice_partition_order_from_blocksize(blocksize), - blocksize, - predictor_order - ); -} -#endif - -uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize(uint32_t blocksize) -{ - uint32_t max_rice_partition_order = 0; - while(!(blocksize & 1)) { - max_rice_partition_order++; - blocksize >>= 1; - } - return flac_min(FLAC__MAX_RICE_PARTITION_ORDER, max_rice_partition_order); -} - -uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(uint32_t limit, uint32_t blocksize, uint32_t predictor_order) -{ - uint32_t max_rice_partition_order = limit; - - while(max_rice_partition_order > 0 && (blocksize >> max_rice_partition_order) <= predictor_order) - max_rice_partition_order--; - - FLAC__ASSERT( - (max_rice_partition_order == 0 && blocksize >= predictor_order) || - (max_rice_partition_order > 0 && blocksize >> max_rice_partition_order > predictor_order) - ); - - return max_rice_partition_order; -} - -void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object) -{ - FLAC__ASSERT(0 != object); - - object->parameters = 0; - object->raw_bits = 0; - object->capacity_by_order = 0; -} - -void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object) -{ - FLAC__ASSERT(0 != object); - - if(0 != object->parameters) - free(object->parameters); - if(0 != object->raw_bits) - free(object->raw_bits); - FLAC__format_entropy_coding_method_partitioned_rice_contents_init(object); -} - -#if defined(_MSC_VER) -// silence three MSVC warnings 'result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)' -#pragma warning ( disable : 4334 ) -#endif - -FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order) -{ - FLAC__ASSERT(0 != object); - - if(object->capacity_by_order < max_partition_order || object->parameters == NULL || object->raw_bits == NULL) { - if(0 == (object->parameters = safe_realloc_(object->parameters, sizeof(uint32_t)*(1 << max_partition_order)))) - return false; - if(0 == (object->raw_bits = safe_realloc_(object->raw_bits, sizeof(uint32_t)*(1 << max_partition_order)))) - return false; - memset(object->raw_bits, 0, sizeof(uint32_t)*(1 << max_partition_order)); - object->capacity_by_order = max_partition_order; - } - - return true; -} - -#if defined(_MSC_VER) -#pragma warning ( default : 4334 ) -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/Makefile.am b/Engine/lib/flac/src/libFLAC/include/Makefile.am deleted file mode 100644 index 8484d1284..000000000 --- a/Engine/lib/flac/src/libFLAC/include/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# libFLAC - Free Lossless Audio Codec library -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# 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 the Xiph.org Foundation nor the names of its -# 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 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. - -SUBDIRS = private protected diff --git a/Engine/lib/flac/src/libFLAC/include/private/Makefile.am b/Engine/lib/flac/src/libFLAC/include/private/Makefile.am deleted file mode 100644 index 3e63d3108..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -# libFLAC - Free Lossless Audio Codec library -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# 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 the Xiph.org Foundation nor the names of its -# 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 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. - -noinst_HEADERS = \ - all.h \ - bitmath.h \ - bitreader.h \ - bitwriter.h \ - cpu.h \ - crc.h \ - fixed.h \ - float.h \ - format.h \ - lpc.h \ - macros.h \ - md5.h \ - memory.h \ - metadata.h \ - ogg_decoder_aspect.h \ - ogg_encoder_aspect.h \ - ogg_helper.h \ - ogg_mapping.h \ - stream_encoder.h \ - stream_encoder_framing.h \ - window.h diff --git a/Engine/lib/flac/src/libFLAC/include/private/all.h b/Engine/lib/flac/src/libFLAC/include/private/all.h deleted file mode 100644 index 10b694952..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/all.h +++ /dev/null @@ -1,50 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__ALL_H -#define FLAC__PRIVATE__ALL_H - -#include "bitmath.h" -#include "bitreader.h" -#include "bitwriter.h" -#include "cpu.h" -#include "crc.h" -#include "fixed.h" -#include "float.h" -#include "format.h" -#include "lpc.h" -#include "md5.h" -#include "memory.h" -#include "metadata.h" -#include "stream_encoder_framing.h" - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/bitmath.h b/Engine/lib/flac/src/libFLAC/include/private/bitmath.h deleted file mode 100644 index 12e062f88..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/bitmath.h +++ /dev/null @@ -1,210 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__BITMATH_H -#define FLAC__PRIVATE__BITMATH_H - -#include "FLAC/ordinals.h" -#include "FLAC/assert.h" - -#include "share/compat.h" - -#if defined(_MSC_VER) -#include /* for _BitScanReverse* */ -#endif - -/* Will never be emitted for MSVC, GCC, Intel compilers */ -static inline uint32_t FLAC__clz_soft_uint32(FLAC__uint32 word) -{ - static const uint8_t byte_to_unary_table[] = { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - }; - - return word > 0xffffff ? byte_to_unary_table[word >> 24] : - word > 0xffff ? byte_to_unary_table[word >> 16] + 8 : - word > 0xff ? byte_to_unary_table[word >> 8] + 16 : - byte_to_unary_table[word] + 24; -} - -static inline uint32_t FLAC__clz_uint32(FLAC__uint32 v) -{ -/* Never used with input 0 */ - FLAC__ASSERT(v > 0); -#if defined(__INTEL_COMPILER) - return _bit_scan_reverse(v) ^ 31U; -#elif defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -/* This will translate either to (bsr ^ 31U), clz , ctlz, cntlz, lzcnt depending on - * -march= setting or to a software routine in exotic machines. */ - return __builtin_clz(v); -#elif defined(_MSC_VER) - { - uint32_t idx; - _BitScanReverse(&idx, v); - return idx ^ 31U; - } -#else - return FLAC__clz_soft_uint32(v); -#endif -} - -/* Used when 64-bit bsr/clz is unavailable; can use 32-bit bsr/clz when possible */ -static inline uint32_t FLAC__clz_soft_uint64(FLAC__uint64 word) -{ - return (FLAC__uint32)(word>>32) ? FLAC__clz_uint32((FLAC__uint32)(word>>32)) : - FLAC__clz_uint32((FLAC__uint32)word) + 32; -} - -static inline uint32_t FLAC__clz_uint64(FLAC__uint64 v) -{ - /* Never used with input 0 */ - FLAC__ASSERT(v > 0); -#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) - return __builtin_clzll(v); -#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64)) - { - uint32_t idx; - _BitScanReverse64(&idx, v); - return idx ^ 63U; - } -#else - return FLAC__clz_soft_uint64(v); -#endif -} - -/* These two functions work with input 0 */ -static inline uint32_t FLAC__clz2_uint32(FLAC__uint32 v) -{ - if (!v) - return 32; - return FLAC__clz_uint32(v); -} - -static inline uint32_t FLAC__clz2_uint64(FLAC__uint64 v) -{ - if (!v) - return 64; - return FLAC__clz_uint64(v); -} - -/* An example of what FLAC__bitmath_ilog2() computes: - * - * ilog2( 0) = assertion failure - * ilog2( 1) = 0 - * ilog2( 2) = 1 - * ilog2( 3) = 1 - * ilog2( 4) = 2 - * ilog2( 5) = 2 - * ilog2( 6) = 2 - * ilog2( 7) = 2 - * ilog2( 8) = 3 - * ilog2( 9) = 3 - * ilog2(10) = 3 - * ilog2(11) = 3 - * ilog2(12) = 3 - * ilog2(13) = 3 - * ilog2(14) = 3 - * ilog2(15) = 3 - * ilog2(16) = 4 - * ilog2(17) = 4 - * ilog2(18) = 4 - */ - -static inline uint32_t FLAC__bitmath_ilog2(FLAC__uint32 v) -{ - FLAC__ASSERT(v > 0); -#if defined(__INTEL_COMPILER) - return _bit_scan_reverse(v); -#elif defined(_MSC_VER) - { - uint32_t idx; - _BitScanReverse(&idx, v); - return idx; - } -#else - return FLAC__clz_uint32(v) ^ 31U; -#endif -} - -static inline uint32_t FLAC__bitmath_ilog2_wide(FLAC__uint64 v) -{ - FLAC__ASSERT(v > 0); -#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) - return __builtin_clzll(v) ^ 63U; -/* Sorry, only supported in x64/Itanium.. and both have fast FPU which makes integer-only encoder pointless */ -#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64)) - { - uint32_t idx; - _BitScanReverse64(&idx, v); - return idx; - } -#else -/* Brain-damaged compilers will use the fastest possible way that is, - de Bruijn sequences (http://supertech.csail.mit.edu/papers/debruijn.pdf) - (C) Timothy B. Terriberry (tterribe@xiph.org) 2001-2009 CC0 (Public domain). -*/ - { - static const uint8_t DEBRUIJN_IDX64[64]={ - 0, 1, 2, 7, 3,13, 8,19, 4,25,14,28, 9,34,20,40, - 5,17,26,38,15,46,29,48,10,31,35,54,21,50,41,57, - 63, 6,12,18,24,27,33,39,16,37,45,47,30,53,49,56, - 62,11,23,32,36,44,52,55,61,22,43,51,60,42,59,58 - }; - v|= v>>1; - v|= v>>2; - v|= v>>4; - v|= v>>8; - v|= v>>16; - v|= v>>32; - v= (v>>1)+1; - return DEBRUIJN_IDX64[v*FLAC__U64L(0x218A392CD3D5DBF)>>58&0x3F]; - } -#endif -} - -uint32_t FLAC__bitmath_silog2(FLAC__int64 v); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/bitreader.h b/Engine/lib/flac/src/libFLAC/include/private/bitreader.h deleted file mode 100644 index c36c92661..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/bitreader.h +++ /dev/null @@ -1,101 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__BITREADER_H -#define FLAC__PRIVATE__BITREADER_H - -#include /* for FILE */ -#include "FLAC/ordinals.h" -#include "cpu.h" - -/* - * opaque structure definition - */ -struct FLAC__BitReader; -typedef struct FLAC__BitReader FLAC__BitReader; - -typedef FLAC__bool (*FLAC__BitReaderReadCallback)(FLAC__byte buffer[], size_t *bytes, void *client_data); - -/* - * construction, deletion, initialization, etc functions - */ -FLAC__BitReader *FLAC__bitreader_new(void); -void FLAC__bitreader_delete(FLAC__BitReader *br); -FLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__BitReaderReadCallback rcb, void *cd); -void FLAC__bitreader_free(FLAC__BitReader *br); /* does not 'free(br)' */ -FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br); -void FLAC__bitreader_set_framesync_location(FLAC__BitReader *br); -FLAC__bool FLAC__bitreader_rewind_to_after_last_seen_framesync(FLAC__BitReader *br); - -/* - * CRC functions - */ -void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed); -FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br); - -/* - * info functions - */ -FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br); -uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br); -uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); -void FLAC__bitreader_set_limit(FLAC__BitReader *br, uint32_t limit); -void FLAC__bitreader_remove_limit(FLAC__BitReader *br); -uint32_t FLAC__bitreader_limit_remaining(FLAC__BitReader *br); -void FLAC__bitreader_limit_invalidate(FLAC__BitReader *br); - -/* - * read functions - */ - -FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, uint32_t bits); -FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, uint32_t bits); -FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, uint32_t bits); -FLAC__bool FLAC__bitreader_read_raw_int64(FLAC__BitReader *br, FLAC__int64 *val, uint32_t bits); -FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); /*only for bits=32*/ -FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, uint32_t bits); /* WATCHOUT: does not CRC the skipped data! */ /*@@@@ add to unit tests */ -FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, uint32_t nvals); /* WATCHOUT: does not CRC the read data! */ -FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, uint32_t nvals); /* WATCHOUT: does not CRC the read data! */ -FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, uint32_t *val); -FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint32_t parameter); -FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); -#ifdef FLAC__BMI2_SUPPORTED -FLAC__bool FLAC__bitreader_read_rice_signed_block_bmi2(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); -#endif - -#if 0 /* UNUSED */ -FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter); -FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, uint32_t *val, uint32_t parameter); -#endif -FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, uint32_t *rawlen); -FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, uint32_t *rawlen); -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/bitwriter.h b/Engine/lib/flac/src/libFLAC/include/private/bitwriter.h deleted file mode 100644 index 39bcf254d..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/bitwriter.h +++ /dev/null @@ -1,104 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__BITWRITER_H -#define FLAC__PRIVATE__BITWRITER_H - -#include /* for FILE */ -#include "FLAC/ordinals.h" - -/* - * opaque structure definition - */ -struct FLAC__BitWriter; -typedef struct FLAC__BitWriter FLAC__BitWriter; - -/* - * construction, deletion, initialization, etc functions - */ -FLAC__BitWriter *FLAC__bitwriter_new(void); -void FLAC__bitwriter_delete(FLAC__BitWriter *bw); -FLAC__bool FLAC__bitwriter_init(FLAC__BitWriter *bw); -void FLAC__bitwriter_free(FLAC__BitWriter *bw); /* does not 'free(buffer)' */ -void FLAC__bitwriter_clear(FLAC__BitWriter *bw); - -/* - * CRC functions - * - * non-const *bw because they have to cal FLAC__bitwriter_get_buffer() - */ -FLAC__bool FLAC__bitwriter_get_write_crc16(FLAC__BitWriter *bw, FLAC__uint16 *crc); -FLAC__bool FLAC__bitwriter_get_write_crc8(FLAC__BitWriter *bw, FLAC__byte *crc); - -/* - * info functions - */ -FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw); -uint32_t FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw); /* can be called anytime, returns total # of bits unconsumed */ - -/* - * direct buffer access - * - * there may be no calls on the bitwriter between get and release. - * the bitwriter continues to own the returned buffer. - * before get, bitwriter MUST be byte aligned: check with FLAC__bitwriter_is_byte_aligned() - */ -FLAC__bool FLAC__bitwriter_get_buffer(FLAC__BitWriter *bw, const FLAC__byte **buffer, size_t *bytes); -void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw); - -/* - * write functions - */ -FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits); -FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits); -FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t bits); -FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, uint32_t bits); -FLAC__bool FLAC__bitwriter_write_raw_int64(FLAC__BitWriter *bw, FLAC__int64 val, uint32_t bits); -FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val); /*only for bits=32*/ -FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], uint32_t nvals); -FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, uint32_t val); -#if 0 /* UNUSED */ -uint32_t FLAC__bitwriter_rice_bits(FLAC__int32 val, uint32_t parameter); -uint32_t FLAC__bitwriter_golomb_bits_signed(int val, uint32_t parameter); -uint32_t FLAC__bitwriter_golomb_bits_unsigned(uint32_t val, uint32_t parameter); -FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t parameter); -#endif -FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, uint32_t nvals, uint32_t parameter); -#if 0 /* UNUSED */ -FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uint32_t parameter); -FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, uint32_t val, uint32_t parameter); -#endif -FLAC__bool FLAC__bitwriter_write_utf8_uint32(FLAC__BitWriter *bw, FLAC__uint32 val); -FLAC__bool FLAC__bitwriter_write_utf8_uint64(FLAC__BitWriter *bw, FLAC__uint64 val); -FLAC__bool FLAC__bitwriter_zero_pad_to_byte_boundary(FLAC__BitWriter *bw); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/cpu.h b/Engine/lib/flac/src/libFLAC/include/private/cpu.h deleted file mode 100644 index 8843c74bf..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/cpu.h +++ /dev/null @@ -1,198 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__CPU_H -#define FLAC__PRIVATE__CPU_H - -#include "FLAC/ordinals.h" - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifndef FLAC__CPU_X86_64 - -#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) -#define FLAC__CPU_X86_64 -#endif - -#endif - -#ifndef FLAC__CPU_IA32 - -#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86) -#define FLAC__CPU_IA32 -#endif - -#endif - -#ifndef __has_attribute -#define __has_attribute(x) 0 -#endif - -#if FLAC__HAS_X86INTRIN -/* SSE intrinsics support by ICC/MSVC/GCC */ -#if defined __INTEL_COMPILER - #define FLAC__SSE_TARGET(x) - #define FLAC__SSE_SUPPORTED 1 - #define FLAC__SSE2_SUPPORTED 1 - #if (__INTEL_COMPILER >= 1000) /* Intel C++ Compiler 10.0 */ - #define FLAC__SSSE3_SUPPORTED 1 - #define FLAC__SSE4_1_SUPPORTED 1 - #define FLAC__SSE4_2_SUPPORTED 1 - #endif - #ifdef FLAC__USE_AVX - #if (__INTEL_COMPILER >= 1110) /* Intel C++ Compiler 11.1 */ - #define FLAC__AVX_SUPPORTED 1 - #endif - #if (__INTEL_COMPILER >= 1300) /* Intel C++ Compiler 13.0 */ - #define FLAC__AVX2_SUPPORTED 1 - #define FLAC__FMA_SUPPORTED 1 - #endif - #endif -#elif defined __clang__ && __has_attribute(__target__) /* clang */ - #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) - #define FLAC__SSE_SUPPORTED 1 - #define FLAC__SSE2_SUPPORTED 1 - #define FLAC__SSSE3_SUPPORTED 1 - #define FLAC__SSE4_1_SUPPORTED 1 - #define FLAC__SSE4_2_SUPPORTED 1 - #ifdef FLAC__USE_AVX - #define FLAC__AVX_SUPPORTED 1 - #define FLAC__AVX2_SUPPORTED 1 - #define FLAC__FMA_SUPPORTED 1 - #define FLAC__BMI2_SUPPORTED 1 - #endif -#elif defined __GNUC__ && !defined __clang__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* GCC 4.9+ */ - #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) - #define FLAC__SSE_SUPPORTED 1 - #define FLAC__SSE2_SUPPORTED 1 - #define FLAC__SSSE3_SUPPORTED 1 - #define FLAC__SSE4_1_SUPPORTED 1 - #define FLAC__SSE4_2_SUPPORTED 1 - #ifdef FLAC__USE_AVX - #define FLAC__AVX_SUPPORTED 1 - #define FLAC__AVX2_SUPPORTED 1 - #define FLAC__FMA_SUPPORTED 1 - #define FLAC__BMI2_SUPPORTED 1 - #endif -#elif defined _MSC_VER - #define FLAC__SSE_TARGET(x) - #define FLAC__SSE_SUPPORTED 1 - #define FLAC__SSE2_SUPPORTED 1 - #if (_MSC_VER >= 1500) /* MS Visual Studio 2008 */ - #define FLAC__SSSE3_SUPPORTED 1 - #define FLAC__SSE4_1_SUPPORTED 1 - #define FLAC__SSE4_2_SUPPORTED 1 - #endif - #ifdef FLAC__USE_AVX - #if (_MSC_FULL_VER >= 160040219) /* MS Visual Studio 2010 SP1 */ - #define FLAC__AVX_SUPPORTED 1 - #endif - #if (_MSC_VER >= 1700) /* MS Visual Studio 2012 */ - #define FLAC__AVX2_SUPPORTED 1 - #define FLAC__FMA_SUPPORTED 1 - #endif - #endif -#else - #define FLAC__SSE_TARGET(x) - #ifdef __SSE__ - #define FLAC__SSE_SUPPORTED 1 - #endif - #ifdef __SSE2__ - #define FLAC__SSE2_SUPPORTED 1 - #endif - #ifdef __SSSE3__ - #define FLAC__SSSE3_SUPPORTED 1 - #endif - #ifdef __SSE4_1__ - #define FLAC__SSE4_1_SUPPORTED 1 - #endif - #ifdef __SSE4_2__ - #define FLAC__SSE4_2_SUPPORTED 1 - #endif - #ifdef FLAC__USE_AVX - #ifdef __AVX__ - #define FLAC__AVX_SUPPORTED 1 - #endif - #ifdef __AVX2__ - #define FLAC__AVX2_SUPPORTED 1 - #endif - #ifdef __FMA__ - #define FLAC__FMA_SUPPORTED 1 - #endif - #endif -#endif /* compiler version */ -#endif /* intrinsics support */ - - -#ifndef FLAC__AVX_SUPPORTED -#define FLAC__AVX_SUPPORTED 0 -#endif - -typedef enum { - FLAC__CPUINFO_TYPE_IA32, - FLAC__CPUINFO_TYPE_X86_64, - FLAC__CPUINFO_TYPE_UNKNOWN -} FLAC__CPUInfo_Type; - -typedef struct { - FLAC__bool intel; - - FLAC__bool cmov; - FLAC__bool mmx; - FLAC__bool sse; - FLAC__bool sse2; - - FLAC__bool sse3; - FLAC__bool ssse3; - FLAC__bool sse41; - FLAC__bool sse42; - FLAC__bool avx; - FLAC__bool avx2; - FLAC__bool fma; - FLAC__bool bmi2; -} FLAC__CPUInfo_x86; - -typedef struct { - FLAC__bool use_asm; - FLAC__CPUInfo_Type type; - FLAC__CPUInfo_x86 x86; -} FLAC__CPUInfo; - -void FLAC__cpu_info(FLAC__CPUInfo *info); - -FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32(void); - -void FLAC__cpu_info_asm_ia32(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/crc.h b/Engine/lib/flac/src/libFLAC/include/private/crc.h deleted file mode 100644 index fe445020c..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/crc.h +++ /dev/null @@ -1,60 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__CRC_H -#define FLAC__PRIVATE__CRC_H - -#include "FLAC/ordinals.h" - -/* 8 bit CRC generator, MSB shifted first -** polynomial = x^8 + x^2 + x^1 + x^0 -** init = 0 -*/ -FLAC__uint8 FLAC__crc8(const FLAC__byte *data, uint32_t len); - -/* 16 bit CRC generator, MSB shifted first -** polynomial = x^16 + x^15 + x^2 + x^0 -** init = 0 -*/ -extern FLAC__uint16 const FLAC__crc16_table[8][256]; - -#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[0][((crc)>>8) ^ (data)]) -/* this alternate may be faster on some systems/compilers */ -#if 0 -#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[0][((crc)>>8) ^ (data)]) & 0xffff) -#endif - -FLAC__uint16 FLAC__crc16(const FLAC__byte *data, uint32_t len); -FLAC__uint16 FLAC__crc16_update_words32(const FLAC__uint32 *words, uint32_t len, FLAC__uint16 crc); -FLAC__uint16 FLAC__crc16_update_words64(const FLAC__uint64 *words, uint32_t len, FLAC__uint16 crc); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/fixed.h b/Engine/lib/flac/src/libFLAC/include/private/fixed.h deleted file mode 100644 index c4efecd5f..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/fixed.h +++ /dev/null @@ -1,117 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__FIXED_H -#define FLAC__PRIVATE__FIXED_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "private/cpu.h" -#include "private/float.h" -#include "FLAC/format.h" - -/* - * FLAC__fixed_compute_best_predictor() - * -------------------------------------------------------------------- - * Compute the best fixed predictor and the expected bits-per-sample - * of the residual signal for each order. The _wide() version uses - * 64-bit integers which is statistically necessary when bits-per- - * sample + log2(blocksize) > 30 - * - * IN data[0,data_len-1] - * IN data_len - * OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER] - */ -#ifndef FLAC__INTEGER_ONLY_LIBRARY -uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -uint32_t FLAC__fixed_compute_best_predictor_limit_residual(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -uint32_t FLAC__fixed_compute_best_predictor_limit_residual_33bit(const FLAC__int64 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -# ifndef FLAC__NO_ASM -# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -# ifdef FLAC__SSE2_SUPPORTED -uint32_t FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]); -# endif -# ifdef FLAC__SSSE3_SUPPORTED -uint32_t FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -# endif -# ifdef FLAC__SSE4_2_SUPPORTED -uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -# endif -# ifdef FLAC__AVX2_SUPPORTED -uint32_t FLAC__fixed_compute_best_predictor_wide_intrin_avx2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -uint32_t FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -# endif -# endif -# endif -#else -uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -uint32_t FLAC__fixed_compute_best_predictor_limit_residual(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -uint32_t FLAC__fixed_compute_best_predictor_limit_residual_33bit(const FLAC__int64 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -#endif - -/* - * FLAC__fixed_compute_residual() - * -------------------------------------------------------------------- - * Compute the residual signal obtained from sutracting the predicted - * signal from the original. - * - * IN data[-order,data_len-1] original signal (NOTE THE INDICES!) - * IN data_len length of original signal - * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order - * OUT residual[0,data_len-1] residual signal - */ -void FLAC__fixed_compute_residual(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]); -void FLAC__fixed_compute_residual_wide(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]); -void FLAC__fixed_compute_residual_wide_33bit(const FLAC__int64 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]); - -/* - * FLAC__fixed_restore_signal() - * -------------------------------------------------------------------- - * Restore the original signal by summing the residual and the - * predictor. - * - * IN residual[0,data_len-1] residual signal - * IN data_len length of original signal - * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order - * *** IMPORTANT: the caller must pass in the historical samples: - * IN data[-order,-1] previously-reconstructed historical samples - * OUT data[0,data_len-1] original signal - */ -void FLAC__fixed_restore_signal(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]); -void FLAC__fixed_restore_signal_wide(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]); -void FLAC__fixed_restore_signal_wide_33bit(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int64 data[]); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/float.h b/Engine/lib/flac/src/libFLAC/include/private/float.h deleted file mode 100644 index bec26345e..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/float.h +++ /dev/null @@ -1,95 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__FLOAT_H -#define FLAC__PRIVATE__FLOAT_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "FLAC/ordinals.h" - -/* - * All the code in libFLAC that uses float and double - * should be protected by checks of the macro - * FLAC__INTEGER_ONLY_LIBRARY. - * - */ -#ifndef FLAC__INTEGER_ONLY_LIBRARY -/* - * FLAC__real is the basic floating point type used in LPC analysis. - * - * WATCHOUT: changing FLAC__real will change the signatures of many - * functions that have assembly language equivalents and break them. - */ -typedef float FLAC__real; -#else -/* - * The convention for FLAC__fixedpoint is to use the upper 16 bits - * for the integer part and lower 16 bits for the fractional part. - */ -typedef FLAC__int32 FLAC__fixedpoint; -extern const FLAC__fixedpoint FLAC__FP_ZERO; -extern const FLAC__fixedpoint FLAC__FP_ONE_HALF; -extern const FLAC__fixedpoint FLAC__FP_ONE; -extern const FLAC__fixedpoint FLAC__FP_LN2; -extern const FLAC__fixedpoint FLAC__FP_E; - -#define FLAC__fixedpoint_trunc(x) ((x)>>16) - -#define FLAC__fixedpoint_mul(x, y) ( (FLAC__fixedpoint) ( ((FLAC__int64)(x)*(FLAC__int64)(y)) >> 16 ) ) - -#define FLAC__fixedpoint_div(x, y) ( (FLAC__fixedpoint) ( ( ((FLAC__int64)(x)<<32) / (FLAC__int64)(y) ) >> 16 ) ) - -/* - * FLAC__fixedpoint_log2() - * -------------------------------------------------------------------- - * Returns the base-2 logarithm of the fixed-point number 'x' using an - * algorithm by Knuth for x >= 1.0 - * - * 'fracbits' is the number of fractional bits of 'x'. 'fracbits' must - * be < 32 and evenly divisible by 4 (0 is OK but not very precise). - * - * 'precision' roughly limits the number of iterations that are done; - * use (uint32_t)(-1) for maximum precision. - * - * If 'x' is less than one -- that is, x < (1< -#endif - -#include "private/cpu.h" -#include "private/float.h" -#include "FLAC/format.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY - -/* - * FLAC__lpc_window_data() - * -------------------------------------------------------------------- - * Applies the given window to the data. - * OPT: asm implementation - * - * IN in[0,data_len-1] - * IN window[0,data_len-1] - * OUT out[0,lag-1] - * IN data_len - */ -void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len); -void FLAC__lpc_window_data_wide(const FLAC__int64 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len); -void FLAC__lpc_window_data_partial(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len, uint32_t part_size, uint32_t data_shift); -void FLAC__lpc_window_data_partial_wide(const FLAC__int64 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len, uint32_t part_size, uint32_t data_shift); - -/* - * FLAC__lpc_compute_autocorrelation() - * -------------------------------------------------------------------- - * Compute the autocorrelation for lags between 0 and lag-1. - * Assumes data[] outside of [0,data_len-1] == 0. - * Asserts that lag > 0. - * - * IN data[0,data_len-1] - * IN data_len - * IN 0 < lag <= data_len - * OUT autoc[0,lag-1] - */ -void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -#ifndef FLAC__NO_ASM -# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -# ifdef FLAC__SSE2_SUPPORTED -void FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_10(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_14(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -# endif -# endif -# if defined FLAC__CPU_X86_64 && FLAC__HAS_X86INTRIN -# ifdef FLAC__FMA_SUPPORTED -void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_12(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_16(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -# endif -# endif -#if defined FLAC__CPU_ARM64 && FLAC__HAS_NEONINTRIN && FLAC__HAS_A64NEONINTRIN -void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_10(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_14(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); -#endif -#endif /* FLAC__NO_ASM */ - -/* - * FLAC__lpc_compute_lp_coefficients() - * -------------------------------------------------------------------- - * Computes LP coefficients for orders 1..max_order. - * Do not call if autoc[0] == 0.0. This means the signal is zero - * and there is no point in calculating a predictor. - * - * IN autoc[0,max_order] autocorrelation values - * IN 0 < max_order <= FLAC__MAX_LPC_ORDER max LP order to compute - * OUT lp_coeff[0,max_order-1][0,max_order-1] LP coefficients for each order - * *** IMPORTANT: - * *** lp_coeff[0,max_order-1][max_order,FLAC__MAX_LPC_ORDER-1] are untouched - * OUT error[0,max_order-1] error for each order (more - * specifically, the variance of - * the error signal times # of - * samples in the signal) - * - * Example: if max_order is 9, the LP coefficients for order 9 will be - * in lp_coeff[8][0,8], the LP coefficients for order 8 will be - * in lp_coeff[7][0,7], etc. - */ -void FLAC__lpc_compute_lp_coefficients(const double autoc[], uint32_t *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[]); - -/* - * FLAC__lpc_quantize_coefficients() - * -------------------------------------------------------------------- - * Quantizes the LP coefficients. NOTE: precision + bits_per_sample - * must be less than 32 (sizeof(FLAC__int32)*8). - * - * IN lp_coeff[0,order-1] LP coefficients - * IN order LP order - * IN FLAC__MIN_QLP_COEFF_PRECISION < precision - * desired precision (in bits, including sign - * bit) of largest coefficient - * OUT qlp_coeff[0,order-1] quantized coefficients - * OUT shift # of bits to shift right to get approximated - * LP coefficients. NOTE: could be negative. - * RETURN 0 => quantization OK - * 1 => coefficients require too much shifting for *shift to - * fit in the LPC subframe header. 'shift' is unset. - * 2 => coefficients are all zero, which is bad. 'shift' is - * unset. - */ -int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], uint32_t order, uint32_t precision, FLAC__int32 qlp_coeff[], int *shift); - -/* - * FLAC__lpc_compute_residual_from_qlp_coefficients() - * -------------------------------------------------------------------- - * Compute the residual signal obtained from sutracting the predicted - * signal from the original. - * - * IN data[-order,data_len-1] original signal (NOTE THE INDICES!) - * IN data_len length of original signal - * IN qlp_coeff[0,order-1] quantized LP coefficients - * IN order > 0 LP order - * IN lp_quantization quantization of LP coefficients in bits - * OUT residual[0,data_len-1] residual signal - */ -void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -FLAC__bool FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -FLAC__bool FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual_33bit(const FLAC__int64 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -#ifndef FLAC__NO_ASM -# ifdef FLAC__CPU_ARM64 -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_neon(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_neon(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -# endif - -# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -# ifdef FLAC__SSE2_SUPPORTED -void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -# endif -# ifdef FLAC__SSE4_1_SUPPORTED -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -# endif -# ifdef FLAC__AVX2_SUPPORTED -void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -# endif -# endif -#endif - -#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ - -uint32_t FLAC__lpc_max_prediction_before_shift_bps(uint32_t subframe_bps, const FLAC__int32 qlp_coeff[], uint32_t order); -uint32_t FLAC__lpc_max_residual_bps(uint32_t subframe_bps, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization); - -/* - * FLAC__lpc_restore_signal() - * -------------------------------------------------------------------- - * Restore the original signal by summing the residual and the - * predictor. - * - * IN residual[0,data_len-1] residual signal - * IN data_len length of original signal - * IN qlp_coeff[0,order-1] quantized LP coefficients - * IN order > 0 LP order - * IN lp_quantization quantization of LP coefficients in bits - * *** IMPORTANT: the caller must pass in the historical samples: - * IN data[-order,-1] previously-reconstructed historical samples - * OUT data[0,data_len-1] original signal - */ -void FLAC__lpc_restore_signal(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); -void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); -void FLAC__lpc_restore_signal_wide_33bit(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int64 data[]); - -#ifndef FLAC__INTEGER_ONLY_LIBRARY - -/* - * FLAC__lpc_compute_expected_bits_per_residual_sample() - * -------------------------------------------------------------------- - * Compute the expected number of bits per residual signal sample - * based on the LP error (which is related to the residual variance). - * - * IN lpc_error >= 0.0 error returned from calculating LP coefficients - * IN total_samples > 0 # of samples in residual signal - * RETURN expected bits per sample - */ -double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, uint32_t total_samples); -double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(double lpc_error, double error_scale); - -/* - * FLAC__lpc_compute_best_order() - * -------------------------------------------------------------------- - * Compute the best order from the array of signal errors returned - * during coefficient computation. - * - * IN lpc_error[0,max_order-1] >= 0.0 error returned from calculating LP coefficients - * IN max_order > 0 max LP order - * IN total_samples > 0 # of samples in residual signal - * IN overhead_bits_per_order # of bits overhead for each increased LP order - * (includes warmup sample size and quantized LP coefficient) - * RETURN [1,max_order] best order - */ -uint32_t FLAC__lpc_compute_best_order(const double lpc_error[], uint32_t max_order, uint32_t total_samples, uint32_t overhead_bits_per_order); - -#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/macros.h b/Engine/lib/flac/src/libFLAC/include/private/macros.h deleted file mode 100644 index 8204ed544..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/macros.h +++ /dev/null @@ -1,74 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2012-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__MACROS_H -#define FLAC__PRIVATE__MACROS_H - -#if defined(__GNUC__) && (__GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3)) - -#define flac_max(a,b) \ - ({ __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - _a > _b ? _a : _b; }) - -#define MIN_PASTE(A,B) A##B -#define MIN_IMPL(A,B,L) ({ \ - __typeof__(A) MIN_PASTE(__a,L) = (A); \ - __typeof__(B) MIN_PASTE(__b,L) = (B); \ - MIN_PASTE(__a,L) < MIN_PASTE(__b,L) ? MIN_PASTE(__a,L) : MIN_PASTE(__b,L); \ - }) - -#define flac_min(A,B) MIN_IMPL(A,B,__COUNTER__) - -/* Whatever other unix that has sys/param.h */ -#elif defined(HAVE_SYS_PARAM_H) -#include -#if defined(MIN) && defined(MAX) -#define flac_max(a,b) MAX(a,b) -#define flac_min(a,b) MIN(a,b) -#endif - -/* Windows VS has them in stdlib.h.. XXX:Untested */ -#elif defined(_MSC_VER) -#include -#define flac_max(a,b) __max(a,b) -#define flac_min(a,b) __min(a,b) -#endif - -#ifndef flac_min -#define flac_min(x,y) ((x) <= (y) ? (x) : (y)) -#endif - -#ifndef flac_max -#define flac_max(x,y) ((x) >= (y) ? (x) : (y)) -#endif - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/md5.h b/Engine/lib/flac/src/libFLAC/include/private/md5.h deleted file mode 100644 index f9d79c3e3..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/md5.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef FLAC__PRIVATE__MD5_H -#define FLAC__PRIVATE__MD5_H - -/* - * This is the header file for the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was - * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. - * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which - * will fill a supplied 16-byte array with the digest. - * - * Changed so as no longer to depend on Colin Plumb's `usual.h' - * header definitions; now uses stuff from dpkg's config.h - * - Ian Jackson . - * Still in the public domain. - * - * Josh Coalson: made some changes to integrate with libFLAC. - * Still in the public domain, with no warranty. - */ - -#include "FLAC/ordinals.h" - -typedef union { - FLAC__byte *p8; - FLAC__int16 *p16; - FLAC__int32 *p32; -} FLAC__multibyte; - -typedef struct { - FLAC__uint32 in[16]; - FLAC__uint32 buf[4]; - FLAC__uint32 bytes[2]; - FLAC__multibyte internal_buf; - size_t capacity; -} FLAC__MD5Context; - -void FLAC__MD5Init(FLAC__MD5Context *context); -void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *context); - -FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/memory.h b/Engine/lib/flac/src/libFLAC/include/private/memory.h deleted file mode 100644 index 4221bcfde..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/memory.h +++ /dev/null @@ -1,58 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__MEMORY_H -#define FLAC__PRIVATE__MEMORY_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include /* for size_t */ - -#include "private/float.h" -#include "FLAC/ordinals.h" /* for FLAC__bool */ - -/* Returns the unaligned address returned by malloc. - * Use free() on this address to deallocate. - */ -void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address); -FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer); -FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer); -FLAC__bool FLAC__memory_alloc_aligned_int64_array(size_t elements, FLAC__int64 **unaligned_pointer, FLAC__int64 **aligned_pointer); -FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer); -#ifndef FLAC__INTEGER_ONLY_LIBRARY -FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); -#endif -void *safe_malloc_mul_2op_p(size_t size1, size_t size2); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/metadata.h b/Engine/lib/flac/src/libFLAC/include/private/metadata.h deleted file mode 100644 index d3ceb53fe..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/metadata.h +++ /dev/null @@ -1,46 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__METADATA_H -#define FLAC__PRIVATE__METADATA_H - -#include "FLAC/metadata.h" - -/* WATCHOUT: all malloc()ed data in the block is free()ed; this may not - * be a consistent state (e.g. PICTURE) or equivalent to the initial - * state after FLAC__metadata_object_new() - */ -void FLAC__metadata_object_delete_data(FLAC__StreamMetadata *object); - -void FLAC__metadata_object_cuesheet_track_delete_data(FLAC__StreamMetadata_CueSheet_Track *object); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/ogg_decoder_aspect.h b/Engine/lib/flac/src/libFLAC/include/private/ogg_decoder_aspect.h deleted file mode 100644 index c9236410e..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/ogg_decoder_aspect.h +++ /dev/null @@ -1,80 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__OGG_DECODER_ASPECT_H -#define FLAC__PRIVATE__OGG_DECODER_ASPECT_H - -#include - -#include "FLAC/ordinals.h" -#include "FLAC/stream_decoder.h" /* for FLAC__StreamDecoderReadStatus */ - -typedef struct FLAC__OggDecoderAspect { - /* these are storage for values that can be set through the API */ - FLAC__bool use_first_serial_number; - long serial_number; - - /* these are for internal state related to Ogg decoding */ - ogg_stream_state stream_state; - ogg_sync_state sync_state; - uint32_t version_major, version_minor; - FLAC__bool need_serial_number; - FLAC__bool end_of_stream; - FLAC__bool have_working_page; /* only if true will the following vars be valid */ - ogg_page working_page; - FLAC__bool have_working_packet; /* only if true will the following vars be valid */ - ogg_packet working_packet; /* as we work through the packet we will move working_packet.packet forward and working_packet.bytes down */ -} FLAC__OggDecoderAspect; - -void FLAC__ogg_decoder_aspect_set_serial_number(FLAC__OggDecoderAspect *aspect, long value); -void FLAC__ogg_decoder_aspect_set_defaults(FLAC__OggDecoderAspect *aspect); -FLAC__bool FLAC__ogg_decoder_aspect_init(FLAC__OggDecoderAspect *aspect); -void FLAC__ogg_decoder_aspect_finish(FLAC__OggDecoderAspect *aspect); -void FLAC__ogg_decoder_aspect_flush(FLAC__OggDecoderAspect *aspect); -void FLAC__ogg_decoder_aspect_reset(FLAC__OggDecoderAspect *aspect); - -typedef enum { - FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK = 0, - FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM, - FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC, - FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC, - FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION, - FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT, - FLAC__OGG_DECODER_ASPECT_READ_STATUS_ERROR, - FLAC__OGG_DECODER_ASPECT_READ_STATUS_MEMORY_ALLOCATION_ERROR -} FLAC__OggDecoderAspectReadStatus; - -typedef FLAC__OggDecoderAspectReadStatus (*FLAC__OggDecoderAspectReadCallbackProxy)(const void *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); - -FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper(FLAC__OggDecoderAspect *aspect, FLAC__byte buffer[], size_t *bytes, FLAC__OggDecoderAspectReadCallbackProxy read_callback, const FLAC__StreamDecoder *decoder, void *client_data); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/ogg_encoder_aspect.h b/Engine/lib/flac/src/libFLAC/include/private/ogg_encoder_aspect.h deleted file mode 100644 index 0e9bb4bca..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/ogg_encoder_aspect.h +++ /dev/null @@ -1,63 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__OGG_ENCODER_ASPECT_H -#define FLAC__PRIVATE__OGG_ENCODER_ASPECT_H - -#include - -#include "FLAC/ordinals.h" -#include "FLAC/stream_encoder.h" /* for FLAC__StreamEncoderWriteStatus */ - -typedef struct FLAC__OggEncoderAspect { - /* these are storage for values that can be set through the API */ - long serial_number; - uint32_t num_metadata; - - /* these are for internal state related to Ogg encoding */ - ogg_stream_state stream_state; - ogg_page page; - FLAC__bool seen_magic; /* true if we've seen the fLaC magic in the write callback yet */ - FLAC__bool is_first_packet; - FLAC__uint64 samples_written; -} FLAC__OggEncoderAspect; - -void FLAC__ogg_encoder_aspect_set_serial_number(FLAC__OggEncoderAspect *aspect, long value); -FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, uint32_t value); -void FLAC__ogg_encoder_aspect_set_defaults(FLAC__OggEncoderAspect *aspect); -FLAC__bool FLAC__ogg_encoder_aspect_init(FLAC__OggEncoderAspect *aspect); -void FLAC__ogg_encoder_aspect_finish(FLAC__OggEncoderAspect *aspect); - -typedef FLAC__StreamEncoderWriteStatus (*FLAC__OggEncoderAspectWriteCallbackProxy)(const void *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data); - -FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data); -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/ogg_helper.h b/Engine/lib/flac/src/libFLAC/include/private/ogg_helper.h deleted file mode 100644 index 67685787a..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/ogg_helper.h +++ /dev/null @@ -1,44 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__OGG_HELPER_H -#define FLAC__PRIVATE__OGG_HELPER_H - -#include -#include "FLAC/stream_encoder.h" /* for FLAC__StreamEncoder */ - -void simple_ogg_page__init(ogg_page *page); -void simple_ogg_page__clear(ogg_page *page); -FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderReadCallback read_callback, void *client_data); -FLAC__bool simple_ogg_page__set_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderWriteCallback write_callback, void *client_data); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/ogg_mapping.h b/Engine/lib/flac/src/libFLAC/include/private/ogg_mapping.h deleted file mode 100644 index 1a213a4f9..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/ogg_mapping.h +++ /dev/null @@ -1,64 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__OGG_MAPPING_H -#define FLAC__PRIVATE__OGG_MAPPING_H - -#include "FLAC/ordinals.h" - -/** The length of the packet type field in bytes. */ -#define FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH (1u) - -extern const uint32_t FLAC__OGG_MAPPING_PACKET_TYPE_LEN; /* = 8 bits */ - -extern const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE; /* = 0x7f */ - -/** The length of the 'FLAC' magic in bytes. */ -#define FLAC__OGG_MAPPING_MAGIC_LENGTH (4u) - -extern const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC; /* = "FLAC" */ - -extern const uint32_t FLAC__OGG_MAPPING_VERSION_MAJOR_LEN; /* = 8 bits */ -extern const uint32_t FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */ - -/** The length of the Ogg FLAC mapping major version number in bytes. */ -#define FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH (1u) - -/** The length of the Ogg FLAC mapping minor version number in bytes. */ -#define FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH (1u) - -extern const uint32_t FLAC__OGG_MAPPING_NUM_HEADERS_LEN; /* = 16 bits */ - -/** The length of the #-of-header-packets number bytes. */ -#define FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH (2u) - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/stream_encoder.h b/Engine/lib/flac/src/libFLAC/include/private/stream_encoder.h deleted file mode 100644 index 0a1b672ad..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/stream_encoder.h +++ /dev/null @@ -1,67 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__STREAM_ENCODER_H -#define FLAC__PRIVATE__STREAM_ENCODER_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* - * This is used to avoid overflow with unusual signals in 32-bit - * accumulator in the *precompute_partition_info_sums_* functions. - */ -#define FLAC__MAX_EXTRA_RESIDUAL_BPS 4 - -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X86INTRIN -#include "private/cpu.h" -#include "FLAC/format.h" - -#ifdef FLAC__SSE2_SUPPORTED -extern void FLAC__precompute_partition_info_sums_intrin_sse2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps); -#endif - -#ifdef FLAC__SSSE3_SUPPORTED -extern void FLAC__precompute_partition_info_sums_intrin_ssse3(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps); -#endif - -#ifdef FLAC__AVX2_SUPPORTED -extern void FLAC__precompute_partition_info_sums_intrin_avx2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps); -#endif - -#endif - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/stream_encoder_framing.h b/Engine/lib/flac/src/libFLAC/include/private/stream_encoder_framing.h deleted file mode 100644 index 705965aeb..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/stream_encoder_framing.h +++ /dev/null @@ -1,46 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__STREAM_ENCODER_FRAMING_H -#define FLAC__PRIVATE__STREAM_ENCODER_FRAMING_H - -#include "FLAC/format.h" -#include "bitwriter.h" - -FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw, FLAC__bool update_vendor_string); -FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw); -FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); -FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); -FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); -FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, uint32_t samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/private/window.h b/Engine/lib/flac/src/libFLAC/include/private/window.h deleted file mode 100644 index 87a3fdf1c..000000000 --- a/Engine/lib/flac/src/libFLAC/include/private/window.h +++ /dev/null @@ -1,74 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PRIVATE__WINDOW_H -#define FLAC__PRIVATE__WINDOW_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "private/float.h" -#include "FLAC/format.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY - -/* - * FLAC__window_*() - * -------------------------------------------------------------------- - * Calculates window coefficients according to different apodization - * functions. - * - * OUT window[0,L-1] - * IN L (number of points in window) - */ -void FLAC__window_bartlett(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_bartlett_hann(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_blackman(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_blackman_harris_4term_92db_sidelobe(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_connes(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_flattop(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_gauss(FLAC__real *window, const FLAC__int32 L, const FLAC__real stddev); /* 0.0 < stddev <= 0.5 */ -void FLAC__window_hamming(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_hann(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_kaiser_bessel(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_nuttall(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_rectangle(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_triangle(FLAC__real *window, const FLAC__int32 L); -void FLAC__window_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p); -void FLAC__window_partial_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p, const FLAC__real start, const FLAC__real end); -void FLAC__window_punchout_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p, const FLAC__real start, const FLAC__real end); -void FLAC__window_welch(FLAC__real *window, const FLAC__int32 L); - -#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/protected/Makefile.am b/Engine/lib/flac/src/libFLAC/include/protected/Makefile.am deleted file mode 100644 index 97e85a845..000000000 --- a/Engine/lib/flac/src/libFLAC/include/protected/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -# libFLAC - Free Lossless Audio Codec library -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# 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 the Xiph.org Foundation nor the names of its -# 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 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. - -noinst_HEADERS = \ - all.h \ - stream_decoder.h \ - stream_encoder.h diff --git a/Engine/lib/flac/src/libFLAC/include/protected/all.h b/Engine/lib/flac/src/libFLAC/include/protected/all.h deleted file mode 100644 index 9f6de97a7..000000000 --- a/Engine/lib/flac/src/libFLAC/include/protected/all.h +++ /dev/null @@ -1,39 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PROTECTED__ALL_H -#define FLAC__PROTECTED__ALL_H - -#include "stream_decoder.h" -#include "stream_encoder.h" - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/protected/stream_decoder.h b/Engine/lib/flac/src/libFLAC/include/protected/stream_decoder.h deleted file mode 100644 index 4a9c76865..000000000 --- a/Engine/lib/flac/src/libFLAC/include/protected/stream_decoder.h +++ /dev/null @@ -1,60 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PROTECTED__STREAM_DECODER_H -#define FLAC__PROTECTED__STREAM_DECODER_H - -#include "FLAC/stream_decoder.h" -#if FLAC__HAS_OGG -#include "private/ogg_decoder_aspect.h" -#endif - -typedef struct FLAC__StreamDecoderProtected { - FLAC__StreamDecoderState state; - FLAC__StreamDecoderInitStatus initstate; - uint32_t channels; - FLAC__ChannelAssignment channel_assignment; - uint32_t bits_per_sample; - uint32_t sample_rate; /* in Hz */ - uint32_t blocksize; /* in samples (per channel) */ - FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the STREAMINFO metadata block */ -#if FLAC__HAS_OGG - FLAC__OggDecoderAspect ogg_decoder_aspect; -#endif -} FLAC__StreamDecoderProtected; - -/* - * Return the number of input bytes consumed - */ -uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder); - -#endif diff --git a/Engine/lib/flac/src/libFLAC/include/protected/stream_encoder.h b/Engine/lib/flac/src/libFLAC/include/protected/stream_encoder.h deleted file mode 100644 index 863e43b36..000000000 --- a/Engine/lib/flac/src/libFLAC/include/protected/stream_encoder.h +++ /dev/null @@ -1,124 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifndef FLAC__PROTECTED__STREAM_ENCODER_H -#define FLAC__PROTECTED__STREAM_ENCODER_H - -#include "FLAC/stream_encoder.h" -#if FLAC__HAS_OGG -#include "private/ogg_encoder_aspect.h" -#endif - -#ifndef FLAC__INTEGER_ONLY_LIBRARY - -#include "private/float.h" - -#define FLAC__MAX_APODIZATION_FUNCTIONS 32 - -typedef enum { - FLAC__APODIZATION_BARTLETT, - FLAC__APODIZATION_BARTLETT_HANN, - FLAC__APODIZATION_BLACKMAN, - FLAC__APODIZATION_BLACKMAN_HARRIS_4TERM_92DB_SIDELOBE, - FLAC__APODIZATION_CONNES, - FLAC__APODIZATION_FLATTOP, - FLAC__APODIZATION_GAUSS, - FLAC__APODIZATION_HAMMING, - FLAC__APODIZATION_HANN, - FLAC__APODIZATION_KAISER_BESSEL, - FLAC__APODIZATION_NUTTALL, - FLAC__APODIZATION_RECTANGLE, - FLAC__APODIZATION_TRIANGLE, - FLAC__APODIZATION_TUKEY, - FLAC__APODIZATION_PARTIAL_TUKEY, - FLAC__APODIZATION_PUNCHOUT_TUKEY, - FLAC__APODIZATION_SUBDIVIDE_TUKEY, - FLAC__APODIZATION_WELCH -} FLAC__ApodizationFunction; - -typedef struct { - FLAC__ApodizationFunction type; - union { - struct { - FLAC__real stddev; - } gauss; - struct { - FLAC__real p; - } tukey; - struct { - FLAC__real p; - FLAC__real start; - FLAC__real end; - } multiple_tukey; - struct { - FLAC__real p; - FLAC__int32 parts; - } subdivide_tukey; - } parameters; -} FLAC__ApodizationSpecification; - -#endif // #ifndef FLAC__INTEGER_ONLY_LIBRARY - -typedef struct FLAC__StreamEncoderProtected { - FLAC__StreamEncoderState state; - FLAC__bool verify; - FLAC__bool streamable_subset; - FLAC__bool do_md5; - FLAC__bool do_mid_side_stereo; - FLAC__bool loose_mid_side_stereo; - uint32_t channels; - uint32_t bits_per_sample; - uint32_t sample_rate; - uint32_t blocksize; -#ifndef FLAC__INTEGER_ONLY_LIBRARY - uint32_t num_apodizations; - FLAC__ApodizationSpecification apodizations[FLAC__MAX_APODIZATION_FUNCTIONS]; -#endif - uint32_t max_lpc_order; - uint32_t qlp_coeff_precision; - FLAC__bool do_qlp_coeff_prec_search; - FLAC__bool do_exhaustive_model_search; - FLAC__bool do_escape_coding; - uint32_t min_residual_partition_order; - uint32_t max_residual_partition_order; - uint32_t rice_parameter_search_dist; - FLAC__uint64 total_samples_estimate; - FLAC__bool limit_min_bitrate; - FLAC__StreamMetadata **metadata; - uint32_t num_metadata_blocks; - FLAC__uint64 streaminfo_offset, seektable_offset, audio_offset; -#if FLAC__HAS_OGG - FLAC__OggEncoderAspect ogg_encoder_aspect; -#endif -} FLAC__StreamEncoderProtected; - -#endif diff --git a/Engine/lib/flac/src/libFLAC/libFLAC.m4 b/Engine/lib/flac/src/libFLAC/libFLAC.m4 deleted file mode 100644 index 5dfc5ea5d..000000000 --- a/Engine/lib/flac/src/libFLAC/libFLAC.m4 +++ /dev/null @@ -1,114 +0,0 @@ -# Configure paths for libFLAC -# "Inspired" by ogg.m4 - -dnl AM_PATH_LIBFLAC([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libFLAC, and define LIBFLAC_CFLAGS, LIBFLAC_LIBS, LIBFLAC_LIBDIR -dnl -AC_DEFUN([AM_PATH_LIBFLAC], -[dnl -dnl Get the cflags and libraries -dnl -AC_ARG_WITH(libFLAC,[ --with-libFLAC=PFX Prefix where libFLAC is installed (optional)], libFLAC_prefix="$withval", libFLAC_prefix="") -AC_ARG_WITH(libFLAC-libraries,[ --with-libFLAC-libraries=DIR Directory where libFLAC library is installed (optional)], libFLAC_libraries="$withval", libFLAC_libraries="") -AC_ARG_WITH(libFLAC-includes,[ --with-libFLAC-includes=DIR Directory where libFLAC header files are installed (optional)], libFLAC_includes="$withval", libFLAC_includes="") -AC_ARG_ENABLE(libFLACtest, [ --disable-libFLACtest Do not try to compile and run a test libFLAC program],, enable_libFLACtest=yes) - - if test "x$libFLAC_libraries" != "x" ; then - LIBFLAC_LIBS="-L$libFLAC_libraries" - elif test "x$libFLAC_prefix" = "xno" || test "x$libFLAC_prefix" = "xyes" ; then - LIBFLAC_LIBS="" - elif test "x$libFLAC_prefix" != "x" ; then - LIBFLAC_LIBS="-L$libFLAC_prefix/lib" - elif test "x$prefix" != "xNONE"; then - LIBFLAC_LIBS="-L$prefix/lib" - fi - - if test "x$libFLAC_prefix" != "xno" ; then - LIBFLAC_LIBS="$LIBFLAC_LIBS -lFLAC $OGG_LIBS -lm" - fi - - if test "x$libFLAC_includes" != "x" ; then - LIBFLAC_CFLAGS="-I$libFLAC_includes" - elif test "x$libFLAC_prefix" != "x" ; then - LIBFLAC_CFLAGS="-I$libFLAC_prefix/include" - elif test "$prefix" != "xNONE"; then - LIBFLAC_CFLAGS="" - fi - - AC_MSG_CHECKING(for libFLAC) - no_libFLAC="" - - - if test "x$enable_libFLACtest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_CXXFLAGS="$CXXFLAGS" - ac_save_LIBS="$LIBS" - ac_save_LD_LIBRARY_PATH="$LD_LIBRARY_PATH" - CFLAGS="$CFLAGS $LIBFLAC_CFLAGS" - CXXFLAGS="$CXXFLAGS $LIBFLAC_CFLAGS" - LIBS="$LIBS $LIBFLAC_LIBS" - LD_LIBRARY_PATH="$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH" -dnl -dnl Now check if the installed libFLAC is sufficiently new. -dnl - rm -f conf.libFLACtest - AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -#include -]],[[ - system("touch conf.libFLACtest"); - return 0; -]])],[],[no_libFLAC=yes],[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH" - fi - - if test "x$no_libFLAC" = "x" ; then - AC_MSG_RESULT(yes) - ifelse([$1], , :, [$1]) - else - AC_MSG_RESULT(no) - if test -f conf.libFLACtest ; then - : - else - echo "*** Could not run libFLAC test program, checking why..." - CFLAGS="$CFLAGS $LIBFLAC_CFLAGS" - CXXFLAGS="$CXXFLAGS $LIBFLAC_CFLAGS" - LIBS="$LIBS $LIBFLAC_LIBS" - LD_LIBRARY_PATH="$LIBFLAC_LIBDIR:$LD_LIBRARY_PATH" - AC_TRY_LINK([ -#include -#include -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding libFLAC or finding the wrong" - echo "*** version of libFLAC. If it is not finding libFLAC, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occurred. This usually means libFLAC was incorrectly installed" - echo "*** or that you have moved libFLAC since it was installed. In the latter case, you" - echo "*** may want to edit the libFLAC-config script: $LIBFLAC_CONFIG" ]) - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - LD_LIBRARY_PATH="$ac_save_LD_LIBRARY_PATH" - fi - LIBFLAC_CFLAGS="" - LIBFLAC_LIBDIR="" - LIBFLAC_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(LIBFLAC_CFLAGS) - AC_SUBST(LIBFLAC_LIBDIR) - AC_SUBST(LIBFLAC_LIBS) - rm -f conf.libFLACtest -]) diff --git a/Engine/lib/flac/src/libFLAC/lpc.c b/Engine/lib/flac/src/libFLAC/lpc.c deleted file mode 100644 index bcb8673c3..000000000 --- a/Engine/lib/flac/src/libFLAC/lpc.c +++ /dev/null @@ -1,1629 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#include "FLAC/assert.h" -#include "FLAC/format.h" -#include "share/compat.h" -#include "private/bitmath.h" -#include "private/lpc.h" -#include "private/macros.h" - -#if !defined(NDEBUG) || defined FLAC__OVERFLOW_DETECT || defined FLAC__OVERFLOW_DETECT_VERBOSE -#include -#endif - -/* OPT: #undef'ing this may improve the speed on some architectures */ -#define FLAC__LPC_UNROLLED_FILTER_LOOPS - -#ifndef FLAC__INTEGER_ONLY_LIBRARY - -#if defined(_MSC_VER) && (_MSC_VER < 1800) -#include -static inline long int lround(double x) { - return (long)(x + _copysign(0.5, x)); -} -#elif !defined(HAVE_LROUND) && defined(__GNUC__) -static inline long int lround(double x) { - return (long)(x + __builtin_copysign(0.5, x)); -} -/* If this fails, we are in the presence of a mid 90's compiler, move along... */ -#endif - -void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len) -{ - uint32_t i; - for(i = 0; i < data_len; i++) - out[i] = in[i] * window[i]; -} - -void FLAC__lpc_window_data_wide(const FLAC__int64 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len) -{ - uint32_t i; - for(i = 0; i < data_len; i++) - out[i] = in[i] * window[i]; -} - -void FLAC__lpc_window_data_partial(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len, uint32_t part_size, uint32_t data_shift) -{ - uint32_t i, j; - if((part_size + data_shift) < data_len){ - for(i = 0; i < part_size; i++) - out[i] = in[data_shift+i] * window[i]; - i = flac_min(i,data_len - part_size - data_shift); - for(j = data_len - part_size; j < data_len; i++, j++) - out[i] = in[data_shift+i] * window[j]; - if(i < data_len) - out[i] = 0.0f; - } -} - -void FLAC__lpc_window_data_partial_wide(const FLAC__int64 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len, uint32_t part_size, uint32_t data_shift) -{ - uint32_t i, j; - if((part_size + data_shift) < data_len){ - for(i = 0; i < part_size; i++) - out[i] = in[data_shift+i] * window[i]; - i = flac_min(i,data_len - part_size - data_shift); - for(j = data_len - part_size; j < data_len; i++, j++) - out[i] = in[data_shift+i] * window[j]; - if(i < data_len) - out[i] = 0.0f; - } -} - -void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ - /* a readable, but slower, version */ -#if 0 - double d; - uint32_t i; - - FLAC__ASSERT(lag > 0); - FLAC__ASSERT(lag <= data_len); - - /* - * Technically we should subtract the mean first like so: - * for(i = 0; i < data_len; i++) - * data[i] -= mean; - * but it appears not to make enough of a difference to matter, and - * most signals are already closely centered around zero - */ - while(lag--) { - for(i = lag, d = 0.0; i < data_len; i++) - d += data[i] * (double)data[i - lag]; - autoc[lag] = d; - } -#endif - if (data_len < FLAC__MAX_LPC_ORDER || lag > 16) { - /* - * this version tends to run faster because of better data locality - * ('data_len' is usually much larger than 'lag') - */ - double d; - uint32_t sample, coeff; - const uint32_t limit = data_len - lag; - - FLAC__ASSERT(lag > 0); - FLAC__ASSERT(lag <= data_len); - - for(coeff = 0; coeff < lag; coeff++) - autoc[coeff] = 0.0; - for(sample = 0; sample <= limit; sample++) { - d = data[sample]; - for(coeff = 0; coeff < lag; coeff++) - autoc[coeff] += d * data[sample+coeff]; - } - for(; sample < data_len; sample++) { - d = data[sample]; - for(coeff = 0; coeff < data_len - sample; coeff++) - autoc[coeff] += d * data[sample+coeff]; - } - } - else if(lag <= 8) { - #undef MAX_LAG - #define MAX_LAG 8 - #include "deduplication/lpc_compute_autocorrelation_intrin.c" - } - else if(lag <= 12) { - #undef MAX_LAG - #define MAX_LAG 12 - #include "deduplication/lpc_compute_autocorrelation_intrin.c" - } - else if(lag <= 16) { - #undef MAX_LAG - #define MAX_LAG 16 - #include "deduplication/lpc_compute_autocorrelation_intrin.c" - } - -} - -void FLAC__lpc_compute_lp_coefficients(const double autoc[], uint32_t *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[]) -{ - uint32_t i, j; - double r, err, lpc[FLAC__MAX_LPC_ORDER]; - - FLAC__ASSERT(0 != max_order); - FLAC__ASSERT(0 < *max_order); - FLAC__ASSERT(*max_order <= FLAC__MAX_LPC_ORDER); - FLAC__ASSERT(autoc[0] != 0.0); - - err = autoc[0]; - - for(i = 0; i < *max_order; i++) { - /* Sum up this iteration's reflection coefficient. */ - r = -autoc[i+1]; - for(j = 0; j < i; j++) - r -= lpc[j] * autoc[i-j]; - r /= err; - - /* Update LPC coefficients and total error. */ - lpc[i]=r; - for(j = 0; j < (i>>1); j++) { - double tmp = lpc[j]; - lpc[j] += r * lpc[i-1-j]; - lpc[i-1-j] += r * tmp; - } - if(i & 1) - lpc[j] += lpc[j] * r; - - err *= (1.0 - r * r); - - /* save this order */ - for(j = 0; j <= i; j++) - lp_coeff[i][j] = (FLAC__real)(-lpc[j]); /* negate FIR filter coeff to get predictor coeff */ - error[i] = err; - - /* see SF bug https://sourceforge.net/p/flac/bugs/234/ */ - if(err == 0.0) { - *max_order = i+1; - return; - } - } -} - -int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], uint32_t order, uint32_t precision, FLAC__int32 qlp_coeff[], int *shift) -{ - uint32_t i; - double cmax; - FLAC__int32 qmax, qmin; - - FLAC__ASSERT(precision > 0); - FLAC__ASSERT(precision >= FLAC__MIN_QLP_COEFF_PRECISION); - - /* drop one bit for the sign; from here on out we consider only |lp_coeff[i]| */ - precision--; - qmax = 1 << precision; - qmin = -qmax; - qmax--; - - /* calc cmax = max( |lp_coeff[i]| ) */ - cmax = 0.0; - for(i = 0; i < order; i++) { - const double d = fabs(lp_coeff[i]); - if(d > cmax) - cmax = d; - } - - if(cmax <= 0.0) { - /* => coefficients are all 0, which means our constant-detect didn't work */ - return 2; - } - else { - const int max_shiftlimit = (1 << (FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN-1)) - 1; - const int min_shiftlimit = -max_shiftlimit - 1; - int log2cmax; - - (void)frexp(cmax, &log2cmax); - log2cmax--; - *shift = (int)precision - log2cmax - 1; - - if(*shift > max_shiftlimit) - *shift = max_shiftlimit; - else if(*shift < min_shiftlimit) - return 1; - } - - if(*shift >= 0) { - double error = 0.0; - FLAC__int32 q; - for(i = 0; i < order; i++) { - error += lp_coeff[i] * (1 << *shift); - q = lround(error); - -#ifdef FLAC__OVERFLOW_DETECT - if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */ - fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]); - else if(q < qmin) - fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q qmax) - q = qmax; - else if(q < qmin) - q = qmin; - error -= q; - qlp_coeff[i] = q; - } - } - /* negative shift is very rare but due to design flaw, negative shift is - * not allowed in the decoder, so it must be handled specially by scaling - * down coeffs - */ - else { - const int nshift = -(*shift); - double error = 0.0; - FLAC__int32 q; -#ifndef NDEBUG - fprintf(stderr,"FLAC__lpc_quantize_coefficients: negative shift=%d order=%u cmax=%f\n", *shift, order, cmax); -#endif - for(i = 0; i < order; i++) { - error += lp_coeff[i] / (1 << nshift); - q = lround(error); -#ifdef FLAC__OVERFLOW_DETECT - if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */ - fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]); - else if(q < qmin) - fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q qmax) - q = qmax; - else if(q < qmin) - q = qmin; - error -= q; - qlp_coeff[i] = q; - } - *shift = 0; - } - - return 0; -} - -#if defined(_MSC_VER) -// silence MSVC warnings about __restrict modifier -#pragma warning ( disable : 4028 ) -#endif - -void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) -#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) -{ - FLAC__int64 sumo; - uint32_t i, j; - FLAC__int32 sum; - const FLAC__int32 *history; - -#ifdef FLAC__OVERFLOW_DETECT_VERBOSE - fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); - for(i=0;i 0); - - for(i = 0; i < data_len; i++) { - sumo = 0; - sum = 0; - history = data; - for(j = 0; j < order; j++) { - sum += qlp_coeff[j] * (*(--history)); - sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history); - if(sumo > 2147483647ll || sumo < -2147483648ll) - fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%" PRId64 "\n",i,j,qlp_coeff[j],*history,sumo); - } - *(residual++) = *(data++) - (sum >> lp_quantization); - } - - /* Here's a slower but clearer version: - for(i = 0; i < data_len; i++) { - sum = 0; - for(j = 0; j < order; j++) - sum += qlp_coeff[j] * data[i-j-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - */ -} -#else /* fully unrolled version for normal use */ -{ - int i; - FLAC__int32 sum; - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - /* - * We do unique versions up to 12th order since that's the subset limit. - * Also they are roughly ordered to match frequency of occurrence to - * minimize branching. - */ - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[9] * data[i-10]; - sum += qlp_coeff[8] * data[i-9]; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 11 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[9] * data[i-10]; - sum += qlp_coeff[8] * data[i-9]; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - else { - if(order == 10) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[9] * data[i-10]; - sum += qlp_coeff[8] * data[i-9]; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 9 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[8] * data[i-9]; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 7 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - else { - if(order == 6) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 5 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 3 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - else { - if(order == 2) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 1 */ - for(i = 0; i < (int)data_len; i++) - residual[i] = data[i] - ((qlp_coeff[0] * data[i-1]) >> lp_quantization); - } - } - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[ 9] * data[i-10]; - sum += qlp_coeff[ 8] * data[i- 9]; - sum += qlp_coeff[ 7] * data[i- 8]; - sum += qlp_coeff[ 6] * data[i- 7]; - sum += qlp_coeff[ 5] * data[i- 6]; - sum += qlp_coeff[ 4] * data[i- 5]; - sum += qlp_coeff[ 3] * data[i- 4]; - sum += qlp_coeff[ 2] * data[i- 3]; - sum += qlp_coeff[ 1] * data[i- 2]; - sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } -} -#endif - -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) -#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) -{ - uint32_t i, j; - FLAC__int64 sum; - const FLAC__int32 *history; - -#ifdef FLAC__OVERFLOW_DETECT_VERBOSE - fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); - for(i=0;i 0); - - for(i = 0; i < data_len; i++) { - sum = 0; - history = data; - for(j = 0; j < order; j++) - sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history)); - if(FLAC__bitmath_silog2((FLAC__int64)(*data) - (sum >> lp_quantization)) > 32) { - fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%" PRId64 ", residual=%" PRId64 "\n", i, *data, (int64_t)(sum >> lp_quantization), ((FLAC__int64)(*data) - (sum >> lp_quantization))); - break; - } - *(residual++) = *(data++) - (FLAC__int32)(sum >> lp_quantization); - } -} -#else /* fully unrolled version for normal use */ -{ - int i; - FLAC__int64 sum; - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - /* - * We do unique versions up to 12th order since that's the subset limit. - * Also they are roughly ordered to match frequency of occurrence to - * minimize branching. - */ - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; - sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; - sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 11 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; - sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - else { - if(order == 10) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 9 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 7 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - else { - if(order == 6) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 5 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 3 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - } - else { - if(order == 2) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order == 1 */ - for(i = 0; i < (int)data_len; i++) - residual[i] = data[i] - ((qlp_coeff[0] * (FLAC__int64)data[i-1]) >> lp_quantization); - } - } - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13]; - sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; - sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; - sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9]; - sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8]; - sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7]; - sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6]; - sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5]; - sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4]; - sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3]; - sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2]; - sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } -} -#endif - -FLAC__bool FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) -{ - int i; - FLAC__int64 sum, residual_to_check; - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13]; /* Falls through. */ - case 12: sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; /* Falls through. */ - case 11: sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; /* Falls through. */ - case 10: sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10]; /* Falls through. */ - case 9: sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9]; /* Falls through. */ - case 8: sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8]; /* Falls through. */ - case 7: sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7]; /* Falls through. */ - case 6: sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6]; /* Falls through. */ - case 5: sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5]; /* Falls through. */ - case 4: sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4]; /* Falls through. */ - case 3: sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3]; /* Falls through. */ - case 2: sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2]; /* Falls through. */ - case 1: sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1]; - } - residual_to_check = data[i] - (sum >> lp_quantization); - /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */ - if(residual_to_check <= INT32_MIN || residual_to_check > INT32_MAX) - return false; - else - residual[i] = residual_to_check; - } - return true; -} - -FLAC__bool FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual_33bit(const FLAC__int64 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) -{ - int i; - FLAC__int64 sum, residual_to_check; - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; /* Falls through. */ - case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */ - case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */ - case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */ - case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */ - case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */ - case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */ - case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */ - case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */ - case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */ - case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */ - case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */ - case 1: sum += qlp_coeff[ 0] * data[i- 1]; - } - residual_to_check = data[i] - (sum >> lp_quantization); - /* residual must not be INT32_MIN because abs(INT32_MIN) is undefined */ - if(residual_to_check <= INT32_MIN || residual_to_check > INT32_MAX) - return false; - else - residual[i] = residual_to_check; - } - return true; -} - -#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ - -uint32_t FLAC__lpc_max_prediction_before_shift_bps(uint32_t subframe_bps, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order) -{ - /* This used to be subframe_bps + qlp_coeff_precision + FLAC__bitmath_ilog2(order) - * but that treats both the samples as well as the predictor as unknown. The - * predictor is known however, so taking the log2 of the sum of the absolute values - * of all coefficients is a more accurate representation of the predictor */ - FLAC__int32 abs_sum_of_qlp_coeff = 0; - uint32_t i; - for(i = 0; i < order; i++) - abs_sum_of_qlp_coeff += abs(qlp_coeff[i]); - if(abs_sum_of_qlp_coeff == 0) - abs_sum_of_qlp_coeff = 1; - return subframe_bps + FLAC__bitmath_silog2(abs_sum_of_qlp_coeff); -} - - -uint32_t FLAC__lpc_max_residual_bps(uint32_t subframe_bps, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization) -{ - FLAC__int32 predictor_sum_bps = FLAC__lpc_max_prediction_before_shift_bps(subframe_bps, qlp_coeff, order) - lp_quantization; - if((int)subframe_bps > predictor_sum_bps) - return subframe_bps + 1; - else - return predictor_sum_bps + 1; -} - -#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) -/* The attribute below is to silence the undefined sanitizer of oss-fuzz. - * Because fuzzing feeds bogus predictors and residual samples to the - * decoder, having overflows in this section is unavoidable. Also, - * because the calculated values are audio path only, there is no - * potential for security problems */ -__attribute__((no_sanitize("signed-integer-overflow"))) -#endif -void FLAC__lpc_restore_signal(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict data) -#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) -{ - FLAC__int64 sumo; - uint32_t i, j; - FLAC__int32 sum; - const FLAC__int32 *r = residual, *history; - -#ifdef FLAC__OVERFLOW_DETECT_VERBOSE - fprintf(stderr,"FLAC__lpc_restore_signal: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); - for(i=0;i 0); - - for(i = 0; i < data_len; i++) { - sumo = 0; - sum = 0; - history = data; - for(j = 0; j < order; j++) { - sum += qlp_coeff[j] * (*(--history)); - sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history); -#ifdef FLAC__OVERFLOW_DETECT - if(sumo > 2147483647ll || sumo < -2147483648ll) - fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%" PRId64 "\n",i,j,qlp_coeff[j],*history,sumo); -#endif - } - *(data++) = *(r++) + (sum >> lp_quantization); - } - - /* Here's a slower but clearer version: - for(i = 0; i < data_len; i++) { - sum = 0; - for(j = 0; j < order; j++) - sum += qlp_coeff[j] * data[i-j-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - */ -} -#else /* fully unrolled version for normal use */ -{ - int i; - FLAC__int32 sum; - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - /* - * We do unique versions up to 12th order since that's the subset limit. - * Also they are roughly ordered to match frequency of occurrence to - * minimize branching. - */ - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[9] * data[i-10]; - sum += qlp_coeff[8] * data[i-9]; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - else { /* order == 11 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[9] * data[i-10]; - sum += qlp_coeff[8] * data[i-9]; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - } - else { - if(order == 10) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[9] * data[i-10]; - sum += qlp_coeff[8] * data[i-9]; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - else { /* order == 9 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[8] * data[i-9]; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[7] * data[i-8]; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - else { /* order == 7 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[6] * data[i-7]; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - } - else { - if(order == 6) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[5] * data[i-6]; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - else { /* order == 5 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[4] * data[i-5]; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[3] * data[i-4]; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - else { /* order == 3 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[2] * data[i-3]; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - } - else { - if(order == 2) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[1] * data[i-2]; - sum += qlp_coeff[0] * data[i-1]; - data[i] = residual[i] + (sum >> lp_quantization); - } - } - else { /* order == 1 */ - for(i = 0; i < (int)data_len; i++) - data[i] = residual[i] + ((qlp_coeff[0] * data[i-1]) >> lp_quantization); - } - } - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[ 9] * data[i-10]; - sum += qlp_coeff[ 8] * data[i- 9]; - sum += qlp_coeff[ 7] * data[i- 8]; - sum += qlp_coeff[ 6] * data[i- 7]; - sum += qlp_coeff[ 5] * data[i- 6]; - sum += qlp_coeff[ 4] * data[i- 5]; - sum += qlp_coeff[ 3] * data[i- 4]; - sum += qlp_coeff[ 2] * data[i- 3]; - sum += qlp_coeff[ 1] * data[i- 2]; - sum += qlp_coeff[ 0] * data[i- 1]; - } - data[i] = residual[i] + (sum >> lp_quantization); - } - } -} -#endif - -void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict data) -#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) -{ - uint32_t i, j; - FLAC__int64 sum; - const FLAC__int32 *r = residual, *history; - -#ifdef FLAC__OVERFLOW_DETECT_VERBOSE - fprintf(stderr,"FLAC__lpc_restore_signal_wide: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); - for(i=0;i 0); - - for(i = 0; i < data_len; i++) { - sum = 0; - history = data; - for(j = 0; j < order; j++) - sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history)); -#ifdef FLAC__OVERFLOW_DETECT - if(FLAC__bitmath_silog2((FLAC__int64)(*r) + (sum >> lp_quantization)) > 32) { - fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%" PRId64 ", data=%" PRId64 "\n", i, *r, (sum >> lp_quantization), ((FLAC__int64)(*r) + (sum >> lp_quantization))); - break; - } -#endif - *(data++) = (FLAC__int32)(*(r++) + (sum >> lp_quantization)); - } -} -#else /* fully unrolled version for normal use */ -{ - int i; - FLAC__int64 sum; - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - /* - * We do unique versions up to 12th order since that's the subset limit. - * Also they are roughly ordered to match frequency of occurrence to - * minimize branching. - */ - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; - sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; - sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - else { /* order == 11 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; - sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - } - else { - if(order == 10) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - else { /* order == 9 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - else { /* order == 7 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - } - else { - if(order == 6) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - else { /* order == 5 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - else { /* order == 3 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - } - else { - if(order == 2) { - for(i = 0; i < (int)data_len; i++) { - sum = 0; - sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } - else { /* order == 1 */ - for(i = 0; i < (int)data_len; i++) - data[i] = (FLAC__int32)(residual[i] + ((qlp_coeff[0] * (FLAC__int64)data[i-1]) >> lp_quantization)); - } - } - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13]; - sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; - sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; - sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9]; - sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8]; - sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7]; - sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6]; - sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5]; - sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4]; - sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3]; - sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2]; - sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1]; - } - data[i] = (FLAC__int32) (residual[i] + (sum >> lp_quantization)); - } - } -} -#endif - -#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) -/* The attribute below is to silence the undefined sanitizer of oss-fuzz. - * Because fuzzing feeds bogus predictors and residual samples to the - * decoder, having overflows in this section is unavoidable. Also, - * because the calculated values are audio path only, there is no - * potential for security problems */ -__attribute__((no_sanitize("signed-integer-overflow"))) -#endif -void FLAC__lpc_restore_signal_wide_33bit(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int64 * flac_restrict data) -#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) -{ - uint32_t i, j; - FLAC__int64 sum; - const FLAC__int32 *r = residual; - const FLAC__int64 *history; - - FLAC__ASSERT(order > 0); - - for(i = 0; i < data_len; i++) { - sum = 0; - history = data; - for(j = 0; j < order; j++) - sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history)); -#ifdef FLAC__OVERFLOW_DETECT - if(FLAC__bitmath_silog2((FLAC__int64)(*r) + (sum >> lp_quantization)) > 33) { - fprintf(stderr,"FLAC__lpc_restore_signal_33bit: OVERFLOW, i=%u, residual=%d, sum=%" PRId64 ", data=%" PRId64 "\n", i, *r, (sum >> lp_quantization), ((FLAC__int64)(*r) + (sum >> lp_quantization))); - break; - } -#endif - *(data++) = (FLAC__int64)(*(r++)) + (sum >> lp_quantization); - } -} -#else /* unrolled version for normal use */ -{ - int i; - FLAC__int64 sum; - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; /* Falls through. */ - case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */ - case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */ - case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */ - case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */ - case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */ - case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */ - case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */ - case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */ - case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */ - case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */ - case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */ - case 1: sum += qlp_coeff[ 0] * data[i- 1]; - } - data[i] = residual[i] + (sum >> lp_quantization); - } -} -#endif - -#if defined(_MSC_VER) -#pragma warning ( default : 4028 ) -#endif - -#ifndef FLAC__INTEGER_ONLY_LIBRARY - -double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, uint32_t total_samples) -{ - double error_scale; - - FLAC__ASSERT(total_samples > 0); - - error_scale = 0.5 / (double)total_samples; - - return FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error, error_scale); -} - -double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(double lpc_error, double error_scale) -{ - if(lpc_error > 0.0) { - double bps = (double)0.5 * log(error_scale * lpc_error) / M_LN2; - if(bps >= 0.0) - return bps; - else - return 0.0; - } - else if(lpc_error < 0.0) { /* error should not be negative but can happen due to inadequate floating-point resolution */ - return 1e32; - } - else { - return 0.0; - } -} - -uint32_t FLAC__lpc_compute_best_order(const double lpc_error[], uint32_t max_order, uint32_t total_samples, uint32_t overhead_bits_per_order) -{ - uint32_t order, indx, best_index; /* 'index' the index into lpc_error; index==order-1 since lpc_error[0] is for order==1, lpc_error[1] is for order==2, etc */ - double bits, best_bits, error_scale; - - FLAC__ASSERT(max_order > 0); - FLAC__ASSERT(total_samples > 0); - - error_scale = 0.5 / (double)total_samples; - - best_index = 0; - best_bits = (uint32_t)(-1); - - for(indx = 0, order = 1; indx < max_order; indx++, order++) { - bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[indx], error_scale) * (double)(total_samples - order) + (double)(order * overhead_bits_per_order); - if(bits < best_bits) { - best_index = indx; - best_bits = bits; - } - } - - return best_index+1; /* +1 since indx of lpc_error[] is order-1 */ -} - -#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/lpc_intrin_avx2.c b/Engine/lib/flac/src/libFLAC/lpc_intrin_avx2.c deleted file mode 100644 index 7f1c03ed2..000000000 --- a/Engine/lib/flac/src/libFLAC/lpc_intrin_avx2.c +++ /dev/null @@ -1,1122 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#include "private/lpc.h" -#ifdef FLAC__AVX2_SUPPORTED - -#include "FLAC/assert.h" -#include "FLAC/format.h" - -#include /* AVX2 */ - -FLAC__SSE_TARGET("avx2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) -{ - int i; - FLAC__int32 sum; - const __m128i cnt = _mm_cvtsi32_si128(lp_quantization); - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(0xffff & qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(0xffff & qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(0xffff & qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(0xffff & qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(0xffff & qlp_coeff[7 ]); - q8 = _mm256_set1_epi32(0xffff & qlp_coeff[8 ]); - q9 = _mm256_set1_epi32(0xffff & qlp_coeff[9 ]); - q10 = _mm256_set1_epi32(0xffff & qlp_coeff[10]); - q11 = _mm256_set1_epi32(0xffff & qlp_coeff[11]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q11, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-12))); - mull = _mm256_madd_epi16(q10, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-11))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q9, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-10))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q8, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-9 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 11 */ - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(0xffff & qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(0xffff & qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(0xffff & qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(0xffff & qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(0xffff & qlp_coeff[7 ]); - q8 = _mm256_set1_epi32(0xffff & qlp_coeff[8 ]); - q9 = _mm256_set1_epi32(0xffff & qlp_coeff[9 ]); - q10 = _mm256_set1_epi32(0xffff & qlp_coeff[10]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q10, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-11))); - mull = _mm256_madd_epi16(q9, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-10))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q8, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-9 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 10) { - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(0xffff & qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(0xffff & qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(0xffff & qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(0xffff & qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(0xffff & qlp_coeff[7 ]); - q8 = _mm256_set1_epi32(0xffff & qlp_coeff[8 ]); - q9 = _mm256_set1_epi32(0xffff & qlp_coeff[9 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q9, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-10))); - mull = _mm256_madd_epi16(q8, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-9 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 9 */ - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(0xffff & qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(0xffff & qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(0xffff & qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(0xffff & qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(0xffff & qlp_coeff[7 ]); - q8 = _mm256_set1_epi32(0xffff & qlp_coeff[8 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q8, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-9 ))); - mull = _mm256_madd_epi16(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - __m256i q0, q1, q2, q3, q4, q5, q6, q7; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(0xffff & qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(0xffff & qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(0xffff & qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(0xffff & qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(0xffff & qlp_coeff[7 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8 ))); - mull = _mm256_madd_epi16(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 7 */ - __m256i q0, q1, q2, q3, q4, q5, q6; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(0xffff & qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(0xffff & qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(0xffff & qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(0xffff & qlp_coeff[6 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7 ))); - mull = _mm256_madd_epi16(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 6) { - __m256i q0, q1, q2, q3, q4, q5; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(0xffff & qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(0xffff & qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(0xffff & qlp_coeff[5 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6 ))); - mull = _mm256_madd_epi16(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 5 */ - __m256i q0, q1, q2, q3, q4; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(0xffff & qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(0xffff & qlp_coeff[4 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5 ))); - mull = _mm256_madd_epi16(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - __m256i q0, q1, q2, q3; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(0xffff & qlp_coeff[3 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4 ))); - mull = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 3 */ - __m256i q0, q1, q2; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(0xffff & qlp_coeff[2 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3 ))); - mull = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 2) { - __m256i q0, q1; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(0xffff & qlp_coeff[1 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_madd_epi16(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2 ))); - mull = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 1 */ - __m256i q0; - q0 = _mm256_set1_epi32(0xffff & qlp_coeff[0 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ; - summ = _mm256_madd_epi16(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1 ))); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - } - for(; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */ - case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */ - case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */ - case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */ - case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */ - case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */ - case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */ - case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */ - case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */ - case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */ - case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */ - case 1: sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[ 9] * data[i-10]; - sum += qlp_coeff[ 8] * data[i- 9]; - sum += qlp_coeff[ 7] * data[i- 8]; - sum += qlp_coeff[ 6] * data[i- 7]; - sum += qlp_coeff[ 5] * data[i- 6]; - sum += qlp_coeff[ 4] * data[i- 5]; - sum += qlp_coeff[ 3] * data[i- 4]; - sum += qlp_coeff[ 2] * data[i- 3]; - sum += qlp_coeff[ 1] * data[i- 2]; - sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } - _mm256_zeroupper(); -} - -FLAC__SSE_TARGET("avx2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) -{ - int i; - FLAC__int32 sum; - const __m128i cnt = _mm_cvtsi32_si128(lp_quantization); - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(qlp_coeff[7 ]); - q8 = _mm256_set1_epi32(qlp_coeff[8 ]); - q9 = _mm256_set1_epi32(qlp_coeff[9 ]); - q10 = _mm256_set1_epi32(qlp_coeff[10]); - q11 = _mm256_set1_epi32(qlp_coeff[11]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q11, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-12))); - mull = _mm256_mullo_epi32(q10, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-11))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q9, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-10))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q8, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-9))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 11 */ - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(qlp_coeff[7 ]); - q8 = _mm256_set1_epi32(qlp_coeff[8 ]); - q9 = _mm256_set1_epi32(qlp_coeff[9 ]); - q10 = _mm256_set1_epi32(qlp_coeff[10]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q10, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-11))); - mull = _mm256_mullo_epi32(q9, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-10))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q8, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-9))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 10) { - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(qlp_coeff[7 ]); - q8 = _mm256_set1_epi32(qlp_coeff[8 ]); - q9 = _mm256_set1_epi32(qlp_coeff[9 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q9, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-10))); - mull = _mm256_mullo_epi32(q8, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-9))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 9 */ - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(qlp_coeff[7 ]); - q8 = _mm256_set1_epi32(qlp_coeff[8 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q8, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-9))); - mull = _mm256_mullo_epi32(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - __m256i q0, q1, q2, q3, q4, q5, q6, q7; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(qlp_coeff[6 ]); - q7 = _mm256_set1_epi32(qlp_coeff[7 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q7, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-8))); - mull = _mm256_mullo_epi32(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 7 */ - __m256i q0, q1, q2, q3, q4, q5, q6; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(qlp_coeff[5 ]); - q6 = _mm256_set1_epi32(qlp_coeff[6 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q6, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-7))); - mull = _mm256_mullo_epi32(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 6) { - __m256i q0, q1, q2, q3, q4, q5; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(qlp_coeff[4 ]); - q5 = _mm256_set1_epi32(qlp_coeff[5 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q5, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-6))); - mull = _mm256_mullo_epi32(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 5 */ - __m256i q0, q1, q2, q3, q4; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(qlp_coeff[3 ]); - q4 = _mm256_set1_epi32(qlp_coeff[4 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q4, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-5))); - mull = _mm256_mullo_epi32(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - __m256i q0, q1, q2, q3; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - q3 = _mm256_set1_epi32(qlp_coeff[3 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q3, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-4))); - mull = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 3 */ - __m256i q0, q1, q2; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - q2 = _mm256_set1_epi32(qlp_coeff[2 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q2, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-3))); - mull = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); summ = _mm256_add_epi32(summ, mull); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 2) { - __m256i q0, q1; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - q1 = _mm256_set1_epi32(qlp_coeff[1 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ, mull; - summ = _mm256_mullo_epi32(q1, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-2))); - mull = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); summ = _mm256_add_epi32(summ, mull); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 1 */ - __m256i q0; - q0 = _mm256_set1_epi32(qlp_coeff[0 ]); - - for(i = 0; i < (int)data_len-7; i+=8) { - __m256i summ; - summ = _mm256_mullo_epi32(q0, _mm256_loadu_si256((const __m256i*)(const void*)(data+i-1))); - summ = _mm256_sra_epi32(summ, cnt); - _mm256_storeu_si256((__m256i*)(void*)(residual+i), _mm256_sub_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(data+i)), summ)); - } - } - } - } - for(; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */ - case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */ - case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */ - case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */ - case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */ - case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */ - case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */ - case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */ - case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */ - case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */ - case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */ - case 1: sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[ 9] * data[i-10]; - sum += qlp_coeff[ 8] * data[i- 9]; - sum += qlp_coeff[ 7] * data[i- 8]; - sum += qlp_coeff[ 6] * data[i- 7]; - sum += qlp_coeff[ 5] * data[i- 6]; - sum += qlp_coeff[ 4] * data[i- 5]; - sum += qlp_coeff[ 3] * data[i- 4]; - sum += qlp_coeff[ 2] * data[i- 3]; - sum += qlp_coeff[ 1] * data[i- 2]; - sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } - _mm256_zeroupper(); -} - -static FLAC__int32 pack_arr[8] = { 0, 2, 4, 6, 1, 3, 5, 7 }; - -FLAC__SSE_TARGET("avx2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) -{ - int i; - FLAC__int64 sum; - const __m128i cnt = _mm_cvtsi32_si128(lp_quantization); - const __m256i pack = _mm256_loadu_si256((const __m256i *)(const void*)pack_arr); - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - FLAC__ASSERT(lp_quantization <= 32); /* there's no _mm256_sra_epi64() so we have to use _mm256_srl_epi64() */ - - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - q3 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[3 ])); - q4 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[4 ])); - q5 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[5 ])); - q6 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[6 ])); - q7 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[7 ])); - q8 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[8 ])); - q9 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[9 ])); - q10 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[10])); - q11 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[11])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q11, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-12)))); - mull = _mm256_mul_epi32(q10, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-11)))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q9, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-10)))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q8, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-9 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q7, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-8 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q6, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-7 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q5, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-6 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q4, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-5 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q3, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-4 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - else { /* order == 11 */ - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - q3 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[3 ])); - q4 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[4 ])); - q5 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[5 ])); - q6 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[6 ])); - q7 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[7 ])); - q8 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[8 ])); - q9 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[9 ])); - q10 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[10])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q10, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-11)))); - mull = _mm256_mul_epi32(q9, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-10)))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q8, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-9 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q7, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-8 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q6, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-7 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q5, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-6 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q4, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-5 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q3, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-4 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - } - else { - if(order == 10) { - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - q3 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[3 ])); - q4 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[4 ])); - q5 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[5 ])); - q6 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[6 ])); - q7 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[7 ])); - q8 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[8 ])); - q9 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[9 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q9, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-10)))); - mull = _mm256_mul_epi32(q8, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-9 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q7, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-8 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q6, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-7 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q5, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-6 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q4, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-5 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q3, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-4 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - else { /* order == 9 */ - __m256i q0, q1, q2, q3, q4, q5, q6, q7, q8; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - q3 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[3 ])); - q4 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[4 ])); - q5 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[5 ])); - q6 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[6 ])); - q7 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[7 ])); - q8 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[8 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q8, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-9 )))); - mull = _mm256_mul_epi32(q7, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-8 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q6, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-7 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q5, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-6 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q4, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-5 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q3, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-4 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - __m256i q0, q1, q2, q3, q4, q5, q6, q7; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - q3 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[3 ])); - q4 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[4 ])); - q5 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[5 ])); - q6 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[6 ])); - q7 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[7 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q7, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-8 )))); - mull = _mm256_mul_epi32(q6, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-7 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q5, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-6 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q4, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-5 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q3, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-4 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - else { /* order == 7 */ - __m256i q0, q1, q2, q3, q4, q5, q6; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - q3 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[3 ])); - q4 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[4 ])); - q5 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[5 ])); - q6 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[6 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q6, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-7 )))); - mull = _mm256_mul_epi32(q5, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-6 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q4, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-5 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q3, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-4 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - } - else { - if(order == 6) { - __m256i q0, q1, q2, q3, q4, q5; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - q3 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[3 ])); - q4 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[4 ])); - q5 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[5 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q5, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-6 )))); - mull = _mm256_mul_epi32(q4, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-5 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q3, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-4 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - else { /* order == 5 */ - __m256i q0, q1, q2, q3, q4; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - q3 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[3 ])); - q4 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[4 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q4, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-5 )))); - mull = _mm256_mul_epi32(q3, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-4 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - __m256i q0, q1, q2, q3; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - q3 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[3 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q3, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-4 )))); - mull = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - else { /* order == 3 */ - __m256i q0, q1, q2; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - q2 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[2 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q2, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-3 )))); - mull = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); summ = _mm256_add_epi64(summ, mull); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - } - else { - if(order == 2) { - __m256i q0, q1; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - q1 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[1 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ, mull; - summ = _mm256_mul_epi32(q1, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-2 )))); - mull = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); summ = _mm256_add_epi64(summ, mull); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - else { /* order == 1 */ - __m256i q0; - q0 = _mm256_cvtepu32_epi64(_mm_set1_epi32(qlp_coeff[0 ])); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m256i summ; - summ = _mm256_mul_epi32(q0, _mm256_cvtepu32_epi64(_mm_loadu_si128((const __m128i*)(const void*)(data+i-1 )))); - summ = _mm256_permutevar8x32_epi32(_mm256_srl_epi64(summ, cnt), pack); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), _mm256_castsi256_si128(summ))); - } - } - } - } - for(; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 12: sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; /* Falls through. */ - case 11: sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; /* Falls through. */ - case 10: sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10]; /* Falls through. */ - case 9: sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9]; /* Falls through. */ - case 8: sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8]; /* Falls through. */ - case 7: sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7]; /* Falls through. */ - case 6: sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6]; /* Falls through. */ - case 5: sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5]; /* Falls through. */ - case 4: sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4]; /* Falls through. */ - case 3: sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3]; /* Falls through. */ - case 2: sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2]; /* Falls through. */ - case 1: sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1]; - } - residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization); - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13]; - sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; - sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; - sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9]; - sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8]; - sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7]; - sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6]; - sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5]; - sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4]; - sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3]; - sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2]; - sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1]; - } - residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization); - } - } - _mm256_zeroupper(); -} - -#endif /* FLAC__AVX2_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ -#endif /* FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/lpc_intrin_fma.c b/Engine/lib/flac/src/libFLAC/lpc_intrin_fma.c deleted file mode 100644 index c0740a88a..000000000 --- a/Engine/lib/flac/src/libFLAC/lpc_intrin_fma.c +++ /dev/null @@ -1,73 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2022-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#ifndef FLAC__NO_ASM -#if defined FLAC__CPU_X86_64 && FLAC__HAS_X86INTRIN -#include "private/lpc.h" -#ifdef FLAC__FMA_SUPPORTED - -#include "FLAC/assert.h" - -FLAC__SSE_TARGET("fma") -void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ -#undef MAX_LAG -#define MAX_LAG 8 -#include "deduplication/lpc_compute_autocorrelation_intrin.c" -} - -FLAC__SSE_TARGET("fma") -void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_12(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ -#undef MAX_LAG -#define MAX_LAG 12 -#include "deduplication/lpc_compute_autocorrelation_intrin.c" -} -FLAC__SSE_TARGET("fma") -void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_16(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ -#undef MAX_LAG -#define MAX_LAG 16 -#include "deduplication/lpc_compute_autocorrelation_intrin.c" - -} - -#endif /* FLAC__FMA_SUPPORTED */ -#endif /* FLAC__CPU_X86_64 && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ -#endif /* FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/lpc_intrin_neon.c b/Engine/lib/flac/src/libFLAC/lpc_intrin_neon.c deleted file mode 100644 index b9945d58c..000000000 --- a/Engine/lib/flac/src/libFLAC/lpc_intrin_neon.c +++ /dev/null @@ -1,1273 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#include "private/cpu.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#ifndef FLAC__NO_ASM -#if defined FLAC__CPU_ARM64 && FLAC__HAS_NEONINTRIN -#include "private/lpc.h" -#include "FLAC/assert.h" -#include "FLAC/format.h" -#include "private/macros.h" -#include - -#if FLAC__HAS_A64NEONINTRIN -void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_14(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ -#undef MAX_LAG -#define MAX_LAG 14 -#include "deduplication/lpc_compute_autocorrelation_intrin_neon.c" -} - -void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_10(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ -#undef MAX_LAG -#define MAX_LAG 10 -#include "deduplication/lpc_compute_autocorrelation_intrin_neon.c" -} - -void FLAC__lpc_compute_autocorrelation_intrin_neon_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ -#undef MAX_LAG -#define MAX_LAG 8 -#include "deduplication/lpc_compute_autocorrelation_intrin_neon.c" -} - -#endif /* ifdef FLAC__HAS_A64NEONINTRIN */ - - -#define MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_vec, lane) \ - summ_0 = vmulq_laneq_s32(tmp_vec[0], qlp_coeff_vec, lane); \ - summ_1 = vmulq_laneq_s32(tmp_vec[4], qlp_coeff_vec, lane); \ - summ_2 = vmulq_laneq_s32(tmp_vec[8], qlp_coeff_vec, lane); - - -#define MACC_32BIT_LOOP_UNROOL_3(tmp_vec_ind, qlp_coeff_vec, lane) \ - summ_0 = vmlaq_laneq_s32(summ_0,tmp_vec[tmp_vec_ind] ,qlp_coeff_vec, lane); \ - summ_1 = vmlaq_laneq_s32(summ_1,tmp_vec[tmp_vec_ind+4] ,qlp_coeff_vec, lane); \ - summ_2 = vmlaq_laneq_s32(summ_2,tmp_vec[tmp_vec_ind+8] ,qlp_coeff_vec, lane); - -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_neon(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) -{ - int i; - FLAC__int32 sum; - int32x4_t tmp_vec[20]; - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - // Using prologue reads is valid as encoder->private_->local_lpc_compute_residual_from_qlp_coefficients(signal+order,....) - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if (order == 12) { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], qlp_coeff[7]}; - int32x4_t qlp_coeff_2 = {qlp_coeff[8], qlp_coeff[9], qlp_coeff[10], qlp_coeff[11]}; - - tmp_vec[0] = vld1q_s32(data - 12); - tmp_vec[1] = vld1q_s32(data - 11); - tmp_vec[2] = vld1q_s32(data - 10); - tmp_vec[3] = vld1q_s32(data - 9); - tmp_vec[4] = vld1q_s32(data - 8); - tmp_vec[5] = vld1q_s32(data - 7); - tmp_vec[6] = vld1q_s32(data - 6); - tmp_vec[7] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - - tmp_vec[8] = vld1q_s32(data + i - 4); - tmp_vec[9] = vld1q_s32(data+i-3); - tmp_vec[10] = vld1q_s32(data+i-2); - tmp_vec[11] = vld1q_s32(data+i-1); - tmp_vec[12] = vld1q_s32(data+i); - tmp_vec[13] = vld1q_s32(data+i+1); - tmp_vec[14] = vld1q_s32(data+i+2); - tmp_vec[15] = vld1q_s32(data+i+3); - tmp_vec[16] = vld1q_s32(data + i + 4); - tmp_vec[17] = vld1q_s32(data + i + 5); - tmp_vec[18] = vld1q_s32(data + i + 6); - tmp_vec[19] = vld1q_s32(data + i + 7); - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_2, 3) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_2, 2) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_2, 1) - MACC_32BIT_LOOP_UNROOL_3(3, qlp_coeff_2, 0) - MACC_32BIT_LOOP_UNROOL_3(4, qlp_coeff_1, 3) - MACC_32BIT_LOOP_UNROOL_3(5, qlp_coeff_1, 2) - MACC_32BIT_LOOP_UNROOL_3(6, qlp_coeff_1, 1) - MACC_32BIT_LOOP_UNROOL_3(7, qlp_coeff_1, 0) - MACC_32BIT_LOOP_UNROOL_3(8, qlp_coeff_0, 3) - MACC_32BIT_LOOP_UNROOL_3(9, qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(10, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(11, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - tmp_vec[4] = tmp_vec[16]; - tmp_vec[5] = tmp_vec[17]; - tmp_vec[6] = tmp_vec[18]; - tmp_vec[7] = tmp_vec[19]; - } - } - - else { /* order == 11 */ - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], qlp_coeff[7]}; - int32x4_t qlp_coeff_2 = {qlp_coeff[8], qlp_coeff[9], qlp_coeff[10], 0}; - - tmp_vec[0] = vld1q_s32(data - 11); - tmp_vec[1] = vld1q_s32(data - 10); - tmp_vec[2] = vld1q_s32(data - 9); - tmp_vec[3] = vld1q_s32(data - 8); - tmp_vec[4] = vld1q_s32(data - 7); - tmp_vec[5] = vld1q_s32(data - 6); - tmp_vec[6] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[7] = vld1q_s32(data + i - 4); - tmp_vec[8] = vld1q_s32(data + i - 3); - tmp_vec[9] = vld1q_s32(data + i - 2); - tmp_vec[10] = vld1q_s32(data + i - 1); - tmp_vec[11] = vld1q_s32(data + i - 0); - tmp_vec[12] = vld1q_s32(data + i + 1); - tmp_vec[13] = vld1q_s32(data + i + 2); - tmp_vec[14] = vld1q_s32(data + i + 3); - tmp_vec[15] = vld1q_s32(data + i + 4); - tmp_vec[16] = vld1q_s32(data + i + 5); - tmp_vec[17] = vld1q_s32(data + i + 6); - tmp_vec[18] = vld1q_s32(data + i + 7); - - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_2, 2) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_2, 1) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_2, 0) - MACC_32BIT_LOOP_UNROOL_3(3, qlp_coeff_1, 3) - MACC_32BIT_LOOP_UNROOL_3(4, qlp_coeff_1, 2) - MACC_32BIT_LOOP_UNROOL_3(5, qlp_coeff_1, 1) - MACC_32BIT_LOOP_UNROOL_3(6, qlp_coeff_1, 0) - MACC_32BIT_LOOP_UNROOL_3(7, qlp_coeff_0, 3) - MACC_32BIT_LOOP_UNROOL_3(8, qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(9, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(10, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - tmp_vec[4] = tmp_vec[16]; - tmp_vec[5] = tmp_vec[17]; - tmp_vec[6] = tmp_vec[18]; - } - } - } - else { - if(order == 10) { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], qlp_coeff[7]}; - int32x4_t qlp_coeff_2 = {qlp_coeff[8], qlp_coeff[9], 0, 0}; - - tmp_vec[0] = vld1q_s32(data - 10); - tmp_vec[1] = vld1q_s32(data - 9); - tmp_vec[2] = vld1q_s32(data - 8); - tmp_vec[3] = vld1q_s32(data - 7); - tmp_vec[4] = vld1q_s32(data - 6); - tmp_vec[5] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[6] = vld1q_s32(data + i - 4); - tmp_vec[7] = vld1q_s32(data + i - 3); - tmp_vec[8] = vld1q_s32(data + i - 2); - tmp_vec[9] = vld1q_s32(data + i - 1); - tmp_vec[10] = vld1q_s32(data + i - 0); - tmp_vec[11] = vld1q_s32(data + i + 1); - tmp_vec[12] = vld1q_s32(data + i + 2); - tmp_vec[13] = vld1q_s32(data + i + 3); - tmp_vec[14] = vld1q_s32(data + i + 4); - tmp_vec[15] = vld1q_s32(data + i + 5); - tmp_vec[16] = vld1q_s32(data + i + 6); - tmp_vec[17] = vld1q_s32(data + i + 7); - - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_2, 1) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_2, 0) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_1, 3) - MACC_32BIT_LOOP_UNROOL_3(3, qlp_coeff_1, 2) - MACC_32BIT_LOOP_UNROOL_3(4, qlp_coeff_1, 1) - MACC_32BIT_LOOP_UNROOL_3(5, qlp_coeff_1, 0) - MACC_32BIT_LOOP_UNROOL_3(6, qlp_coeff_0, 3) - MACC_32BIT_LOOP_UNROOL_3(7, qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(8, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(9, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - tmp_vec[4] = tmp_vec[16]; - tmp_vec[5] = tmp_vec[17]; - } - } - else { /* order == 9 */ - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], qlp_coeff[7]}; - int32x4_t qlp_coeff_2 = {qlp_coeff[8], 0, 0, 0}; - - tmp_vec[0] = vld1q_s32(data - 9); - tmp_vec[1] = vld1q_s32(data - 8); - tmp_vec[2] = vld1q_s32(data - 7); - tmp_vec[3] = vld1q_s32(data - 6); - tmp_vec[4] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[5] = vld1q_s32(data + i - 4); - tmp_vec[6] = vld1q_s32(data + i - 3); - tmp_vec[7] = vld1q_s32(data + i - 2); - tmp_vec[8] = vld1q_s32(data + i - 1); - tmp_vec[9] = vld1q_s32(data + i - 0); - tmp_vec[10] = vld1q_s32(data + i + 1); - tmp_vec[11] = vld1q_s32(data + i + 2); - tmp_vec[12] = vld1q_s32(data + i + 3); - tmp_vec[13] = vld1q_s32(data + i + 4); - tmp_vec[14] = vld1q_s32(data + i + 5); - tmp_vec[15] = vld1q_s32(data + i + 6); - tmp_vec[16] = vld1q_s32(data + i + 7); - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_2, 0) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_1, 3) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_1, 2) - MACC_32BIT_LOOP_UNROOL_3(3, qlp_coeff_1, 1) - MACC_32BIT_LOOP_UNROOL_3(4, qlp_coeff_1, 0) - MACC_32BIT_LOOP_UNROOL_3(5, qlp_coeff_0, 3) - MACC_32BIT_LOOP_UNROOL_3(6, qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(7, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(8, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - tmp_vec[4] = tmp_vec[16]; - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], qlp_coeff[7]}; - - tmp_vec[0] = vld1q_s32(data - 8); - tmp_vec[1] = vld1q_s32(data - 7); - tmp_vec[2] = vld1q_s32(data - 6); - tmp_vec[3] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[4] = vld1q_s32(data + i - 4); - tmp_vec[5] = vld1q_s32(data + i - 3); - tmp_vec[6] = vld1q_s32(data + i - 2); - tmp_vec[7] = vld1q_s32(data + i - 1); - tmp_vec[8] = vld1q_s32(data + i - 0); - tmp_vec[9] = vld1q_s32(data + i + 1); - tmp_vec[10] = vld1q_s32(data + i + 2); - tmp_vec[11] = vld1q_s32(data + i + 3); - tmp_vec[12] = vld1q_s32(data + i + 4); - tmp_vec[13] = vld1q_s32(data + i + 5); - tmp_vec[14] = vld1q_s32(data + i + 6); - tmp_vec[15] = vld1q_s32(data + i + 7); - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_1, 3) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_1, 2) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_1, 1) - MACC_32BIT_LOOP_UNROOL_3(3, qlp_coeff_1, 0) - MACC_32BIT_LOOP_UNROOL_3(4, qlp_coeff_0, 3) - MACC_32BIT_LOOP_UNROOL_3(5, qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(6, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(7, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - } - } - else { /* order == 7 */ - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], 0}; - - tmp_vec[0] = vld1q_s32(data - 7); - tmp_vec[1] = vld1q_s32(data - 6); - tmp_vec[2] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[3] = vld1q_s32(data + i - 4); - tmp_vec[4] = vld1q_s32(data + i - 3); - tmp_vec[5] = vld1q_s32(data + i - 2); - tmp_vec[6] = vld1q_s32(data + i - 1); - tmp_vec[7] = vld1q_s32(data + i - 0); - tmp_vec[8] = vld1q_s32(data + i + 1); - tmp_vec[9] = vld1q_s32(data + i + 2); - tmp_vec[10] = vld1q_s32(data + i + 3); - tmp_vec[11] = vld1q_s32(data + i + 4); - tmp_vec[12] = vld1q_s32(data + i + 5); - tmp_vec[13] = vld1q_s32(data + i + 6); - tmp_vec[14] = vld1q_s32(data + i + 7); - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_1, 2) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_1, 1) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_1, 0) - MACC_32BIT_LOOP_UNROOL_3(3, qlp_coeff_0, 3) - MACC_32BIT_LOOP_UNROOL_3(4, qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(5, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(6, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - } - } - } - else { - if(order == 6) { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], 0, 0}; - - tmp_vec[0] = vld1q_s32(data - 6); - tmp_vec[1] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[2] = vld1q_s32(data + i - 4); - tmp_vec[3] = vld1q_s32(data + i - 3); - tmp_vec[4] = vld1q_s32(data + i - 2); - tmp_vec[5] = vld1q_s32(data + i - 1); - tmp_vec[6] = vld1q_s32(data + i - 0); - tmp_vec[7] = vld1q_s32(data + i + 1); - tmp_vec[8] = vld1q_s32(data + i + 2); - tmp_vec[9] = vld1q_s32(data + i + 3); - tmp_vec[10] = vld1q_s32(data + i + 4); - tmp_vec[11] = vld1q_s32(data + i + 5); - tmp_vec[12] = vld1q_s32(data + i + 6); - tmp_vec[13] = vld1q_s32(data + i + 7); - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_1, 1) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_1, 0) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_0, 3) - MACC_32BIT_LOOP_UNROOL_3(3, qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(4, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(5, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - } - } - else { /* order == 5 */ - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], 0, 0, 0}; - - tmp_vec[0] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - - tmp_vec[1] = vld1q_s32(data + i - 4); - tmp_vec[2] = vld1q_s32(data + i - 3); - tmp_vec[3] = vld1q_s32(data + i - 2); - tmp_vec[4] = vld1q_s32(data + i - 1); - tmp_vec[5] = vld1q_s32(data + i - 0); - tmp_vec[6] = vld1q_s32(data + i + 1); - tmp_vec[7] = vld1q_s32(data + i + 2); - tmp_vec[8] = vld1q_s32(data + i + 3); - tmp_vec[9] = vld1q_s32(data + i + 4); - tmp_vec[10] = vld1q_s32(data + i + 5); - tmp_vec[11] = vld1q_s32(data + i + 6); - tmp_vec[12] = vld1q_s32(data + i + 7); - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_1, 0) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_0, 3) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(3, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(4, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - - tmp_vec[0] = tmp_vec[12]; - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[0] = vld1q_s32(data + i - 4); - tmp_vec[1] = vld1q_s32(data + i - 3); - tmp_vec[2] = vld1q_s32(data + i - 2); - tmp_vec[3] = vld1q_s32(data + i - 1); - tmp_vec[4] = vld1q_s32(data + i - 0); - tmp_vec[5] = vld1q_s32(data + i + 1); - tmp_vec[6] = vld1q_s32(data + i + 2); - tmp_vec[7] = vld1q_s32(data + i + 3); - tmp_vec[8] = vld1q_s32(data + i + 4); - tmp_vec[9] = vld1q_s32(data + i + 5); - tmp_vec[10] = vld1q_s32(data + i + 6); - tmp_vec[11] = vld1q_s32(data + i + 7); - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_0, 3) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(3, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - } - } - else { /* order == 3 */ - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], 0}; - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[0] = vld1q_s32(data + i - 3); - tmp_vec[1] = vld1q_s32(data + i - 2); - tmp_vec[2] = vld1q_s32(data + i - 1); - tmp_vec[4] = vld1q_s32(data + i + 1); - tmp_vec[5] = vld1q_s32(data + i + 2); - tmp_vec[6] = vld1q_s32(data + i + 3); - tmp_vec[8] = vld1q_s32(data + i + 5); - tmp_vec[9] = vld1q_s32(data + i + 6); - tmp_vec[10] = vld1q_s32(data + i + 7); - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_0, 2) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(2, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - } - } - } - else { - if(order == 2) { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], 0, 0}; - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[0] = vld1q_s32(data + i - 2); - tmp_vec[1] = vld1q_s32(data + i - 1); - tmp_vec[4] = vld1q_s32(data + i + 2); - tmp_vec[5] = vld1q_s32(data + i + 3); - tmp_vec[8] = vld1q_s32(data + i + 6); - tmp_vec[9] = vld1q_s32(data + i + 7); - - MUL_32_BIT_LOOP_UNROOL_3(qlp_coeff_0, 1) - MACC_32BIT_LOOP_UNROOL_3(1, qlp_coeff_0, 0) - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - } - } - else { /* order == 1 */ - int32x4_t qlp_coeff_0 = vdupq_n_s32(qlp_coeff[0]); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int32x4_t summ_0, summ_1, summ_2; - tmp_vec[0] = vld1q_s32(data + i - 1); - tmp_vec[4] = vld1q_s32(data + i + 3); - tmp_vec[8] = vld1q_s32(data + i + 7); - - summ_0 = vmulq_s32(tmp_vec[0], qlp_coeff_0); - summ_1 = vmulq_s32(tmp_vec[4], qlp_coeff_0); - summ_2 = vmulq_s32(tmp_vec[8], qlp_coeff_0); - - vst1q_s32(residual+i + 0, vsubq_s32(vld1q_s32(data+i + 0) , vshlq_s32(summ_0,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 4, vsubq_s32(vld1q_s32(data+i + 4) , vshlq_s32(summ_1,vdupq_n_s32(-lp_quantization)))); - vst1q_s32(residual+i + 8, vsubq_s32(vld1q_s32(data+i + 8) , vshlq_s32(summ_2,vdupq_n_s32(-lp_quantization)))); - } - } - } - } - for(; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */ - case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */ - case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */ - case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */ - case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */ - case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */ - case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */ - case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */ - case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */ - case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */ - case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */ - case 1: sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[ 9] * data[i-10]; - sum += qlp_coeff[ 8] * data[i- 9]; - sum += qlp_coeff[ 7] * data[i- 8]; - sum += qlp_coeff[ 6] * data[i- 7]; - sum += qlp_coeff[ 5] * data[i- 6]; - sum += qlp_coeff[ 4] * data[i- 5]; - sum += qlp_coeff[ 3] * data[i- 4]; - sum += qlp_coeff[ 2] * data[i- 3]; - sum += qlp_coeff[ 1] * data[i- 2]; - sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } -} - - - -#define MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_vec, lane) \ - summ_l_0 = vmull_laneq_s32(vget_low_s32(tmp_vec[0]),qlp_coeff_vec, lane); \ - summ_h_0 = vmull_high_laneq_s32(tmp_vec[0], qlp_coeff_vec, lane);\ - summ_l_1 = vmull_laneq_s32(vget_low_s32(tmp_vec[4]),qlp_coeff_vec, lane); \ - summ_h_1 = vmull_high_laneq_s32(tmp_vec[4], qlp_coeff_vec, lane);\ - summ_l_2 = vmull_laneq_s32(vget_low_s32(tmp_vec[8]),qlp_coeff_vec, lane);\ - summ_h_2 = vmull_high_laneq_s32(tmp_vec[8], qlp_coeff_vec, lane); - - -#define MACC_64_BIT_LOOP_UNROOL_3(tmp_vec_ind, qlp_coeff_vec, lane) \ - summ_l_0 = vmlal_laneq_s32(summ_l_0,vget_low_s32(tmp_vec[tmp_vec_ind]),qlp_coeff_vec, lane); \ - summ_h_0 = vmlal_high_laneq_s32(summ_h_0, tmp_vec[tmp_vec_ind], qlp_coeff_vec, lane); \ - summ_l_1 = vmlal_laneq_s32(summ_l_1, vget_low_s32(tmp_vec[tmp_vec_ind+4]),qlp_coeff_vec, lane); \ - summ_h_1 = vmlal_high_laneq_s32(summ_h_1, tmp_vec[tmp_vec_ind+4], qlp_coeff_vec, lane); \ - summ_l_2 = vmlal_laneq_s32(summ_l_2, vget_low_s32(tmp_vec[tmp_vec_ind+8]),qlp_coeff_vec, lane);\ - summ_h_2 = vmlal_high_laneq_s32(summ_h_2,tmp_vec[tmp_vec_ind+8], qlp_coeff_vec, lane); - -#define SHIFT_SUMS_64BITS_AND_STORE_SUB() \ - res0 = vuzp1q_s32(vreinterpretq_s32_s64(vshlq_s64(summ_l_0,lp_quantization_vec)), vreinterpretq_s32_s64(vshlq_s64(summ_h_0,lp_quantization_vec))); \ - res1 = vuzp1q_s32(vreinterpretq_s32_s64(vshlq_s64(summ_l_1,lp_quantization_vec)), vreinterpretq_s32_s64(vshlq_s64(summ_h_1,lp_quantization_vec))); \ - res2 = vuzp1q_s32(vreinterpretq_s32_s64(vshlq_s64(summ_l_2,lp_quantization_vec)), vreinterpretq_s32_s64(vshlq_s64(summ_h_2,lp_quantization_vec))); \ - vst1q_s32(residual+i+0, vsubq_s32(vld1q_s32(data+i+0), res0));\ - vst1q_s32(residual+i+4, vsubq_s32(vld1q_s32(data+i+4), res1));\ - vst1q_s32(residual+i+8, vsubq_s32(vld1q_s32(data+i+8), res2)); - -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_neon(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) { - int i; - FLAC__int64 sum; - - int32x4_t tmp_vec[20]; - int32x4_t res0, res1, res2; - int64x2_t lp_quantization_vec = vdupq_n_s64(-lp_quantization); - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - // Using prologue reads is valid as encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit(signal+order,....) - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4],qlp_coeff[5],qlp_coeff[6],qlp_coeff[7]}; - int32x4_t qlp_coeff_2 = {qlp_coeff[8],qlp_coeff[9],qlp_coeff[10],qlp_coeff[11]}; - - tmp_vec[0] = vld1q_s32(data - 12); - tmp_vec[1] = vld1q_s32(data - 11); - tmp_vec[2] = vld1q_s32(data - 10); - tmp_vec[3] = vld1q_s32(data - 9); - tmp_vec[4] = vld1q_s32(data - 8); - tmp_vec[5] = vld1q_s32(data - 7); - tmp_vec[6] = vld1q_s32(data - 6); - tmp_vec[7] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - - tmp_vec[8] = vld1q_s32(data+i-4); - tmp_vec[9] = vld1q_s32(data+i-3); - tmp_vec[10] = vld1q_s32(data+i-2); - tmp_vec[11] = vld1q_s32(data+i-1); - tmp_vec[12] = vld1q_s32(data+i); - tmp_vec[13] = vld1q_s32(data+i+1); - tmp_vec[14] = vld1q_s32(data+i+2); - tmp_vec[15] = vld1q_s32(data+i+3); - tmp_vec[16] = vld1q_s32(data + i + 4); - tmp_vec[17] = vld1q_s32(data + i + 5); - tmp_vec[18] = vld1q_s32(data + i + 6); - tmp_vec[19] = vld1q_s32(data + i + 7); - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_2, 3) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_2, 2) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_2, 1) - MACC_64_BIT_LOOP_UNROOL_3(3, qlp_coeff_2, 0) - MACC_64_BIT_LOOP_UNROOL_3(4, qlp_coeff_1, 3) - MACC_64_BIT_LOOP_UNROOL_3(5, qlp_coeff_1, 2) - MACC_64_BIT_LOOP_UNROOL_3(6, qlp_coeff_1, 1) - MACC_64_BIT_LOOP_UNROOL_3(7, qlp_coeff_1, 0) - MACC_64_BIT_LOOP_UNROOL_3(8, qlp_coeff_0, 3) - MACC_64_BIT_LOOP_UNROOL_3(9, qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(10,qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(11,qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - tmp_vec[4] = tmp_vec[16]; - tmp_vec[5] = tmp_vec[17]; - tmp_vec[6] = tmp_vec[18]; - tmp_vec[7] = tmp_vec[19]; - } - } - else { /* order == 11 */ - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4],qlp_coeff[5],qlp_coeff[6],qlp_coeff[7]}; - int32x4_t qlp_coeff_2 = {qlp_coeff[8],qlp_coeff[9],qlp_coeff[10],0}; - - tmp_vec[0] = vld1q_s32(data - 11); - tmp_vec[1] = vld1q_s32(data - 10); - tmp_vec[2] = vld1q_s32(data - 9); - tmp_vec[3] = vld1q_s32(data - 8); - tmp_vec[4] = vld1q_s32(data - 7); - tmp_vec[5] = vld1q_s32(data - 6); - tmp_vec[6] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - - tmp_vec[7] = vld1q_s32(data+i-4); - tmp_vec[8] = vld1q_s32(data+i-3); - tmp_vec[9] = vld1q_s32(data+i-2); - tmp_vec[10] = vld1q_s32(data+i-1); - tmp_vec[11] = vld1q_s32(data+i); - tmp_vec[12] = vld1q_s32(data+i+1); - tmp_vec[13] = vld1q_s32(data+i+2); - tmp_vec[14] = vld1q_s32(data+i+3); - tmp_vec[15] = vld1q_s32(data + i + 4); - tmp_vec[16] = vld1q_s32(data + i + 5); - tmp_vec[17] = vld1q_s32(data + i + 6); - tmp_vec[18] = vld1q_s32(data + i + 7); - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_2, 2) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_2, 1) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_2, 0) - MACC_64_BIT_LOOP_UNROOL_3(3, qlp_coeff_1, 3) - MACC_64_BIT_LOOP_UNROOL_3(4, qlp_coeff_1, 2) - MACC_64_BIT_LOOP_UNROOL_3(5, qlp_coeff_1, 1) - MACC_64_BIT_LOOP_UNROOL_3(6, qlp_coeff_1, 0) - MACC_64_BIT_LOOP_UNROOL_3(7, qlp_coeff_0, 3) - MACC_64_BIT_LOOP_UNROOL_3(8, qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(9, qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(10,qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - tmp_vec[4] = tmp_vec[16]; - tmp_vec[5] = tmp_vec[17]; - tmp_vec[6] = tmp_vec[18]; - } - } - } - else - { - if (order == 10) { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], qlp_coeff[7]}; - int32x4_t qlp_coeff_2 = {qlp_coeff[8], qlp_coeff[9], 0, 0}; - - tmp_vec[0] = vld1q_s32(data - 10); - tmp_vec[1] = vld1q_s32(data - 9); - tmp_vec[2] = vld1q_s32(data - 8); - tmp_vec[3] = vld1q_s32(data - 7); - tmp_vec[4] = vld1q_s32(data - 6); - tmp_vec[5] = vld1q_s32(data - 5); - - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - - tmp_vec[6] = vld1q_s32(data + i - 4); - tmp_vec[7] = vld1q_s32(data + i - 3); - tmp_vec[8] = vld1q_s32(data + i - 2); - tmp_vec[9] = vld1q_s32(data + i - 1); - tmp_vec[10] = vld1q_s32(data + i - 0); - tmp_vec[11] = vld1q_s32(data + i + 1); - tmp_vec[12] = vld1q_s32(data + i + 2); - tmp_vec[13] = vld1q_s32(data + i + 3); - tmp_vec[14] = vld1q_s32(data + i + 4); - tmp_vec[15] = vld1q_s32(data + i + 5); - tmp_vec[16] = vld1q_s32(data + i + 6); - tmp_vec[17] = vld1q_s32(data + i + 7); - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_2, 1) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_2, 0) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_1, 3) - MACC_64_BIT_LOOP_UNROOL_3(3, qlp_coeff_1, 2) - MACC_64_BIT_LOOP_UNROOL_3(4, qlp_coeff_1, 1) - MACC_64_BIT_LOOP_UNROOL_3(5, qlp_coeff_1, 0) - MACC_64_BIT_LOOP_UNROOL_3(6, qlp_coeff_0, 3) - MACC_64_BIT_LOOP_UNROOL_3(7, qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(8, qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(9, qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - tmp_vec[4] = tmp_vec[16]; - tmp_vec[5] = tmp_vec[17]; - } - } - - else /* order == 9 */ { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], qlp_coeff[7]}; - int32x4_t qlp_coeff_2 = {qlp_coeff[8], 0, 0, 0}; - - tmp_vec[0] = vld1q_s32(data - 9); - tmp_vec[1] = vld1q_s32(data - 8); - tmp_vec[2] = vld1q_s32(data - 7); - tmp_vec[3] = vld1q_s32(data - 6); - tmp_vec[4] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - - tmp_vec[5] = vld1q_s32(data + i - 4); - tmp_vec[6] = vld1q_s32(data + i - 3); - tmp_vec[7] = vld1q_s32(data + i - 2); - tmp_vec[8] = vld1q_s32(data + i - 1); - tmp_vec[9] = vld1q_s32(data + i - 0); - tmp_vec[10] = vld1q_s32(data + i + 1); - tmp_vec[11] = vld1q_s32(data + i + 2); - tmp_vec[12] = vld1q_s32(data + i + 3); - tmp_vec[13] = vld1q_s32(data + i + 4); - tmp_vec[14] = vld1q_s32(data + i + 5); - tmp_vec[15] = vld1q_s32(data + i + 6); - tmp_vec[16] = vld1q_s32(data + i + 7); - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_2, 0) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_1, 3) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_1, 2) - MACC_64_BIT_LOOP_UNROOL_3(3, qlp_coeff_1, 1) - MACC_64_BIT_LOOP_UNROOL_3(4, qlp_coeff_1, 0) - MACC_64_BIT_LOOP_UNROOL_3(5, qlp_coeff_0, 3) - MACC_64_BIT_LOOP_UNROOL_3(6, qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(7, qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(8, qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - tmp_vec[4] = tmp_vec[16]; - } - } - } - } - else if (order > 4) - { - if (order > 6) - { - if (order == 8) - { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], qlp_coeff[7]}; - - tmp_vec[0] = vld1q_s32(data - 8); - tmp_vec[1] = vld1q_s32(data - 7); - tmp_vec[2] = vld1q_s32(data - 6); - tmp_vec[3] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - - tmp_vec[4] = vld1q_s32(data + i - 4); - tmp_vec[5] = vld1q_s32(data + i - 3); - tmp_vec[6] = vld1q_s32(data + i - 2); - tmp_vec[7] = vld1q_s32(data + i - 1); - tmp_vec[8] = vld1q_s32(data + i - 0); - tmp_vec[9] = vld1q_s32(data + i + 1); - tmp_vec[10] = vld1q_s32(data + i + 2); - tmp_vec[11] = vld1q_s32(data + i + 3); - tmp_vec[12] = vld1q_s32(data + i + 4); - tmp_vec[13] = vld1q_s32(data + i + 5); - tmp_vec[14] = vld1q_s32(data + i + 6); - tmp_vec[15] = vld1q_s32(data + i + 7); - - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_1, 3) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_1, 2) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_1, 1) - MACC_64_BIT_LOOP_UNROOL_3(3, qlp_coeff_1, 0) - MACC_64_BIT_LOOP_UNROOL_3(4, qlp_coeff_0, 3) - MACC_64_BIT_LOOP_UNROOL_3(5, qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(6, qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(7, qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - tmp_vec[3] = tmp_vec[15]; - } - } - else /* order == 7 */ - { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], qlp_coeff[6], 0}; - - tmp_vec[0] = vld1q_s32(data - 7); - tmp_vec[1] = vld1q_s32(data - 6); - tmp_vec[2] = vld1q_s32(data - 5); - - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - tmp_vec[3] = vld1q_s32(data +i - 4); - tmp_vec[4] = vld1q_s32(data + i - 3); - tmp_vec[5] = vld1q_s32(data + i - 2); - tmp_vec[6] = vld1q_s32(data + i - 1); - tmp_vec[7] = vld1q_s32(data + i - 0); - tmp_vec[8] = vld1q_s32(data + i + 1); - tmp_vec[9] = vld1q_s32(data + i + 2); - tmp_vec[10] = vld1q_s32(data + i + 3); - tmp_vec[11] = vld1q_s32(data + i + 4); - tmp_vec[12] = vld1q_s32(data + i + 5); - tmp_vec[13] = vld1q_s32(data + i + 6); - tmp_vec[14] = vld1q_s32(data + i + 7); - - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_1, 2) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_1, 1) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_1, 0) - MACC_64_BIT_LOOP_UNROOL_3(3, qlp_coeff_0, 3) - MACC_64_BIT_LOOP_UNROOL_3(4, qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(5, qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(6, qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - tmp_vec[2] = tmp_vec[14]; - } - } - } - else - { - if (order == 6) { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], qlp_coeff[5], 0, 0}; - - tmp_vec[0] = vld1q_s32(data - 6); - tmp_vec[1] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - - tmp_vec[2] = vld1q_s32(data + i - 4); - tmp_vec[3] = vld1q_s32(data + i - 3); - tmp_vec[4] = vld1q_s32(data + i - 2); - tmp_vec[5] = vld1q_s32(data + i - 1); - tmp_vec[6] = vld1q_s32(data + i - 0); - tmp_vec[7] = vld1q_s32(data + i + 1); - tmp_vec[8] = vld1q_s32(data + i + 2); - tmp_vec[9] = vld1q_s32(data + i + 3); - tmp_vec[10] = vld1q_s32(data + i + 4); - tmp_vec[11] = vld1q_s32(data + i + 5); - tmp_vec[12] = vld1q_s32(data + i + 6); - tmp_vec[13] = vld1q_s32(data + i + 7); - - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_1, 1) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_1, 0) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_0, 3) - MACC_64_BIT_LOOP_UNROOL_3(3, qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(4, qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(5, qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - - tmp_vec[0] = tmp_vec[12]; - tmp_vec[1] = tmp_vec[13]; - } - } - - else - { /* order == 5 */ - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - int32x4_t qlp_coeff_1 = {qlp_coeff[4], 0, 0, 0}; - - tmp_vec[0] = vld1q_s32(data - 5); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - tmp_vec[1] = vld1q_s32(data + i - 4); - tmp_vec[2] = vld1q_s32(data + i - 3); - tmp_vec[3] = vld1q_s32(data + i - 2); - tmp_vec[4] = vld1q_s32(data + i - 1); - tmp_vec[5] = vld1q_s32(data + i - 0); - tmp_vec[6] = vld1q_s32(data + i + 1); - tmp_vec[7] = vld1q_s32(data + i + 2); - tmp_vec[8] = vld1q_s32(data + i + 3); - tmp_vec[9] = vld1q_s32(data + i + 4); - tmp_vec[10] = vld1q_s32(data + i + 5); - tmp_vec[11] = vld1q_s32(data + i + 6); - tmp_vec[12] = vld1q_s32(data + i + 7); - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_1, 0) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_0, 3) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(3, qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(4, qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - - tmp_vec[0] = tmp_vec[12]; - } - } - } - } - else - { - if (order > 2) - { - if (order == 4) - { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], qlp_coeff[3]}; - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - tmp_vec[0] = vld1q_s32(data + i - 4); - tmp_vec[1] = vld1q_s32(data + i - 3); - tmp_vec[2] = vld1q_s32(data + i - 2); - tmp_vec[3] = vld1q_s32(data + i - 1); - tmp_vec[4] = vld1q_s32(data + i - 0); - tmp_vec[5] = vld1q_s32(data + i + 1); - tmp_vec[6] = vld1q_s32(data + i + 2); - tmp_vec[7] = vld1q_s32(data + i + 3); - tmp_vec[8] = vld1q_s32(data + i + 4); - tmp_vec[9] = vld1q_s32(data + i + 5); - tmp_vec[10] = vld1q_s32(data + i + 6); - tmp_vec[11] = vld1q_s32(data + i + 7); - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_0, 3) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(3, qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - } - } - else - { /* order == 3 */ - - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], qlp_coeff[2], 0}; - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - tmp_vec[0] = vld1q_s32(data + i - 3); - tmp_vec[1] = vld1q_s32(data + i - 2); - tmp_vec[2] = vld1q_s32(data + i - 1); - tmp_vec[4] = vld1q_s32(data + i + 1); - tmp_vec[5] = vld1q_s32(data + i + 2); - tmp_vec[6] = vld1q_s32(data + i + 3); - tmp_vec[8] = vld1q_s32(data + i + 5); - tmp_vec[9] = vld1q_s32(data + i + 6); - tmp_vec[10] = vld1q_s32(data + i + 7); - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_0, 2) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(2, qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - } - } - } - else - { - if (order == 2) - { - int32x4_t qlp_coeff_0 = {qlp_coeff[0], qlp_coeff[1], 0, 0}; - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - tmp_vec[0] = vld1q_s32(data + i - 2); - tmp_vec[1] = vld1q_s32(data + i - 1); - tmp_vec[4] = vld1q_s32(data + i + 2); - tmp_vec[5] = vld1q_s32(data + i + 3); - tmp_vec[8] = vld1q_s32(data + i + 6); - tmp_vec[9] = vld1q_s32(data + i + 7); - - MUL_64_BIT_LOOP_UNROOL_3(qlp_coeff_0, 1) - MACC_64_BIT_LOOP_UNROOL_3(1, qlp_coeff_0, 0) - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - } - } - - else - { /* order == 1 */ - - int32x2_t qlp_coeff_0_2 = vdup_n_s32(qlp_coeff[0]); - int32x4_t qlp_coeff_0_4 = vdupq_n_s32(qlp_coeff[0]); - - for (i = 0; i < (int)data_len - 11; i += 12) - { - int64x2_t summ_l_0, summ_h_0, summ_l_1, summ_h_1, summ_l_2, summ_h_2; - tmp_vec[0] = vld1q_s32(data + i - 1); - tmp_vec[4] = vld1q_s32(data + i + 3); - tmp_vec[8] = vld1q_s32(data + i + 7); - - summ_l_0 = vmull_s32(vget_low_s32(tmp_vec[0]), qlp_coeff_0_2); - summ_h_0 = vmull_high_s32(tmp_vec[0], qlp_coeff_0_4); - - summ_l_1 = vmull_s32(vget_low_s32(tmp_vec[4]), qlp_coeff_0_2); - summ_h_1 = vmull_high_s32(tmp_vec[4], qlp_coeff_0_4); - - summ_l_2 = vmull_s32(vget_low_s32(tmp_vec[8]), qlp_coeff_0_2); - summ_h_2 = vmull_high_s32(tmp_vec[8], qlp_coeff_0_4); - - SHIFT_SUMS_64BITS_AND_STORE_SUB() - } - } - } - } - for (; i < (int)data_len; i++) - { - sum = 0; - switch (order) - { - case 12: - sum += qlp_coeff[11] * (FLAC__int64)data[i - 12]; /* Falls through. */ - case 11: - sum += qlp_coeff[10] * (FLAC__int64)data[i - 11]; /* Falls through. */ - case 10: - sum += qlp_coeff[9] * (FLAC__int64)data[i - 10]; /* Falls through. */ - case 9: - sum += qlp_coeff[8] * (FLAC__int64)data[i - 9]; /* Falls through. */ - case 8: - sum += qlp_coeff[7] * (FLAC__int64)data[i - 8]; /* Falls through. */ - case 7: - sum += qlp_coeff[6] * (FLAC__int64)data[i - 7]; /* Falls through. */ - case 6: - sum += qlp_coeff[5] * (FLAC__int64)data[i - 6]; /* Falls through. */ - case 5: - sum += qlp_coeff[4] * (FLAC__int64)data[i - 5]; /* Falls through. */ - case 4: - sum += qlp_coeff[3] * (FLAC__int64)data[i - 4]; /* Falls through. */ - case 3: - sum += qlp_coeff[2] * (FLAC__int64)data[i - 3]; /* Falls through. */ - case 2: - sum += qlp_coeff[1] * (FLAC__int64)data[i - 2]; /* Falls through. */ - case 1: - sum += qlp_coeff[0] * (FLAC__int64)data[i - 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else - { /* order > 12 */ - for (i = 0; i < (int)data_len; i++) - { - sum = 0; - switch (order) - { - case 32: - sum += qlp_coeff[31] * (FLAC__int64)data[i - 32]; /* Falls through. */ - case 31: - sum += qlp_coeff[30] * (FLAC__int64)data[i - 31]; /* Falls through. */ - case 30: - sum += qlp_coeff[29] * (FLAC__int64)data[i - 30]; /* Falls through. */ - case 29: - sum += qlp_coeff[28] * (FLAC__int64)data[i - 29]; /* Falls through. */ - case 28: - sum += qlp_coeff[27] * (FLAC__int64)data[i - 28]; /* Falls through. */ - case 27: - sum += qlp_coeff[26] * (FLAC__int64)data[i - 27]; /* Falls through. */ - case 26: - sum += qlp_coeff[25] * (FLAC__int64)data[i - 26]; /* Falls through. */ - case 25: - sum += qlp_coeff[24] * (FLAC__int64)data[i - 25]; /* Falls through. */ - case 24: - sum += qlp_coeff[23] * (FLAC__int64)data[i - 24]; /* Falls through. */ - case 23: - sum += qlp_coeff[22] * (FLAC__int64)data[i - 23]; /* Falls through. */ - case 22: - sum += qlp_coeff[21] * (FLAC__int64)data[i - 22]; /* Falls through. */ - case 21: - sum += qlp_coeff[20] * (FLAC__int64)data[i - 21]; /* Falls through. */ - case 20: - sum += qlp_coeff[19] * (FLAC__int64)data[i - 20]; /* Falls through. */ - case 19: - sum += qlp_coeff[18] * (FLAC__int64)data[i - 19]; /* Falls through. */ - case 18: - sum += qlp_coeff[17] * (FLAC__int64)data[i - 18]; /* Falls through. */ - case 17: - sum += qlp_coeff[16] * (FLAC__int64)data[i - 17]; /* Falls through. */ - case 16: - sum += qlp_coeff[15] * (FLAC__int64)data[i - 16]; /* Falls through. */ - case 15: - sum += qlp_coeff[14] * (FLAC__int64)data[i - 15]; /* Falls through. */ - case 14: - sum += qlp_coeff[13] * (FLAC__int64)data[i - 14]; /* Falls through. */ - case 13: - sum += qlp_coeff[12] * (FLAC__int64)data[i - 13]; - sum += qlp_coeff[11] * (FLAC__int64)data[i - 12]; - sum += qlp_coeff[10] * (FLAC__int64)data[i - 11]; - sum += qlp_coeff[9] * (FLAC__int64)data[i - 10]; - sum += qlp_coeff[8] * (FLAC__int64)data[i - 9]; - sum += qlp_coeff[7] * (FLAC__int64)data[i - 8]; - sum += qlp_coeff[6] * (FLAC__int64)data[i - 7]; - sum += qlp_coeff[5] * (FLAC__int64)data[i - 6]; - sum += qlp_coeff[4] * (FLAC__int64)data[i - 5]; - sum += qlp_coeff[3] * (FLAC__int64)data[i - 4]; - sum += qlp_coeff[2] * (FLAC__int64)data[i - 3]; - sum += qlp_coeff[1] * (FLAC__int64)data[i - 2]; - sum += qlp_coeff[0] * (FLAC__int64)data[i - 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } - - return; -} - -#endif /* FLAC__CPU_ARM64 && FLAC__HAS_ARCH64INTRIN */ -#endif /* FLAC__NO_ASM */ -#endif /* FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/lpc_intrin_sse2.c b/Engine/lib/flac/src/libFLAC/lpc_intrin_sse2.c deleted file mode 100644 index d16a085fb..000000000 --- a/Engine/lib/flac/src/libFLAC/lpc_intrin_sse2.c +++ /dev/null @@ -1,966 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#include "private/lpc.h" -#ifdef FLAC__SSE2_SUPPORTED - -#include "FLAC/assert.h" -#include "FLAC/format.h" - -#include /* SSE2 */ - -#define RESIDUAL32_RESULT(xmmN) residual[i] = data[i] - (_mm_cvtsi128_si32(xmmN) >> lp_quantization); -#define DATA32_RESULT(xmmN) data[i] = residual[i] + (_mm_cvtsi128_si32(xmmN) >> lp_quantization); - - -FLAC__SSE_TARGET("sse2") -void FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ -#undef MAX_LAG -#define MAX_LAG 8 -#include "deduplication/lpc_compute_autocorrelation_intrin_sse2.c" -} - -FLAC__SSE_TARGET("sse2") -void FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_10(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ -#undef MAX_LAG -#define MAX_LAG 10 -#include "deduplication/lpc_compute_autocorrelation_intrin_sse2.c" -} - - -FLAC__SSE_TARGET("sse2") -void FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_14(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]) -{ -#undef MAX_LAG -#define MAX_LAG 14 -#include "deduplication/lpc_compute_autocorrelation_intrin_sse2.c" -} - -FLAC__SSE_TARGET("sse2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) -{ - int i; - FLAC__int32 sum; - const __m128i cnt = _mm_cvtsi32_si128(lp_quantization); - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - __m128i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(0xffff & qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(0xffff & qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(0xffff & qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(0xffff & qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(0xffff & qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - q8 = _mm_cvtsi32_si128(0xffff & qlp_coeff[8]); q8 = _mm_shuffle_epi32(q8, _MM_SHUFFLE(0,0,0,0)); - q9 = _mm_cvtsi32_si128(0xffff & qlp_coeff[9]); q9 = _mm_shuffle_epi32(q9, _MM_SHUFFLE(0,0,0,0)); - q10 = _mm_cvtsi32_si128(0xffff & qlp_coeff[10]); q10 = _mm_shuffle_epi32(q10, _MM_SHUFFLE(0,0,0,0)); - q11 = _mm_cvtsi32_si128(0xffff & qlp_coeff[11]); q11 = _mm_shuffle_epi32(q11, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q11, _mm_loadu_si128((const __m128i*)(const void*)(data+i-12))); - mull = _mm_madd_epi16(q10, _mm_loadu_si128((const __m128i*)(const void*)(data+i-11))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q9, _mm_loadu_si128((const __m128i*)(const void*)(data+i-10))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q8, _mm_loadu_si128((const __m128i*)(const void*)(data+i-9))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 11 */ - __m128i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(0xffff & qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(0xffff & qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(0xffff & qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(0xffff & qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(0xffff & qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - q8 = _mm_cvtsi32_si128(0xffff & qlp_coeff[8]); q8 = _mm_shuffle_epi32(q8, _MM_SHUFFLE(0,0,0,0)); - q9 = _mm_cvtsi32_si128(0xffff & qlp_coeff[9]); q9 = _mm_shuffle_epi32(q9, _MM_SHUFFLE(0,0,0,0)); - q10 = _mm_cvtsi32_si128(0xffff & qlp_coeff[10]); q10 = _mm_shuffle_epi32(q10, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q10, _mm_loadu_si128((const __m128i*)(const void*)(data+i-11))); - mull = _mm_madd_epi16(q9, _mm_loadu_si128((const __m128i*)(const void*)(data+i-10))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q8, _mm_loadu_si128((const __m128i*)(const void*)(data+i-9))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 10) { - __m128i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(0xffff & qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(0xffff & qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(0xffff & qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(0xffff & qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(0xffff & qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - q8 = _mm_cvtsi32_si128(0xffff & qlp_coeff[8]); q8 = _mm_shuffle_epi32(q8, _MM_SHUFFLE(0,0,0,0)); - q9 = _mm_cvtsi32_si128(0xffff & qlp_coeff[9]); q9 = _mm_shuffle_epi32(q9, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q9, _mm_loadu_si128((const __m128i*)(const void*)(data+i-10))); - mull = _mm_madd_epi16(q8, _mm_loadu_si128((const __m128i*)(const void*)(data+i-9))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 9 */ - __m128i q0, q1, q2, q3, q4, q5, q6, q7, q8; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(0xffff & qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(0xffff & qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(0xffff & qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(0xffff & qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(0xffff & qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - q8 = _mm_cvtsi32_si128(0xffff & qlp_coeff[8]); q8 = _mm_shuffle_epi32(q8, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q8, _mm_loadu_si128((const __m128i*)(const void*)(data+i-9))); - mull = _mm_madd_epi16(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - __m128i q0, q1, q2, q3, q4, q5, q6, q7; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(0xffff & qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(0xffff & qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(0xffff & qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(0xffff & qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(0xffff & qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); - mull = _mm_madd_epi16(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 7 */ - __m128i q0, q1, q2, q3, q4, q5, q6; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(0xffff & qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(0xffff & qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(0xffff & qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(0xffff & qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); - mull = _mm_madd_epi16(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 6) { - __m128i q0, q1, q2, q3, q4, q5; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(0xffff & qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(0xffff & qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(0xffff & qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); - mull = _mm_madd_epi16(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 5 */ - __m128i q0, q1, q2, q3, q4; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(0xffff & qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(0xffff & qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); - mull = _mm_madd_epi16(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - __m128i q0, q1, q2, q3; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(0xffff & qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); - mull = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 3 */ - __m128i q0, q1, q2; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(0xffff & qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); - mull = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 2) { - __m128i q0, q1; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(0xffff & qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_madd_epi16(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); - mull = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 1 */ - __m128i q0; - q0 = _mm_cvtsi32_si128(0xffff & qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ; - summ = _mm_madd_epi16(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - } - for(; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */ - case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */ - case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */ - case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */ - case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */ - case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */ - case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */ - case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */ - case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */ - case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */ - case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */ - case 1: sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[ 9] * data[i-10]; - sum += qlp_coeff[ 8] * data[i- 9]; - sum += qlp_coeff[ 7] * data[i- 8]; - sum += qlp_coeff[ 6] * data[i- 7]; - sum += qlp_coeff[ 5] * data[i- 6]; - sum += qlp_coeff[ 4] * data[i- 5]; - sum += qlp_coeff[ 3] * data[i- 4]; - sum += qlp_coeff[ 2] * data[i- 3]; - sum += qlp_coeff[ 1] * data[i- 2]; - sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } -} - -#if defined FLAC__CPU_IA32 /* unused for x86_64 */ - -FLAC__SSE_TARGET("sse2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) -{ - int i; - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - if(order <= 12) { - if(order > 8) { /* order == 9, 10, 11, 12 */ - if(order > 10) { /* order == 11, 12 */ - if(order == 12) { - __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); // 0 0 q[1] q[0] - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); // 0 0 q[3] q[2] - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); // 0 0 q[5] q[4] - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); // 0 0 q[7] q[6] - xmm4 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+8)); // 0 0 q[9] q[8] - xmm5 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+10)); // 0 0 q[11] q[10] - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); // 0 q[1] 0 q[0] - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); // 0 q[3] 0 q[2] - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); // 0 q[5] 0 q[4] - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); // 0 q[7] 0 q[6] - xmm4 = _mm_shuffle_epi32(xmm4, _MM_SHUFFLE(3,1,2,0)); // 0 q[9] 0 q[8] - xmm5 = _mm_shuffle_epi32(xmm5, _MM_SHUFFLE(3,1,2,0)); // 0 q[11] 0 q[10] - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[11] * data[i-12]; - //sum += qlp_coeff[10] * data[i-11]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-12)); // 0 0 d[i-11] d[i-12] - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); // 0 d[i-12] 0 d[i-11] - xmm7 = _mm_mul_epu32(xmm7, xmm5); /* we use _unsigned_ multiplication and discard high dword of the result values */ - - //sum += qlp_coeff[9] * data[i-10]; - //sum += qlp_coeff[8] * data[i-9]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-10)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm4); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[7] * data[i-8]; - //sum += qlp_coeff[6] * data[i-7]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm3); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[5] * data[i-6]; - //sum += qlp_coeff[4] * data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm2); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[3] * data[i-4]; - //sum += qlp_coeff[2] * data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm1); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - else { /* order == 11 */ - __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); - xmm4 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+8)); - xmm5 = _mm_cvtsi32_si128(qlp_coeff[10]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); - xmm4 = _mm_shuffle_epi32(xmm4, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[10] * data[i-11]; - xmm7 = _mm_cvtsi32_si128(data[i-11]); - xmm7 = _mm_mul_epu32(xmm7, xmm5); - - //sum += qlp_coeff[9] * data[i-10]; - //sum += qlp_coeff[8] * data[i-9]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-10)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm4); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[7] * data[i-8]; - //sum += qlp_coeff[6] * data[i-7]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm3); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[5] * data[i-6]; - //sum += qlp_coeff[4] * data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm2); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[3] * data[i-4]; - //sum += qlp_coeff[2] * data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm1); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - } - else { /* order == 9, 10 */ - if(order == 10) { - __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); - xmm4 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+8)); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); - xmm4 = _mm_shuffle_epi32(xmm4, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[9] * data[i-10]; - //sum += qlp_coeff[8] * data[i-9]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-10)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epu32(xmm7, xmm4); - - //sum += qlp_coeff[7] * data[i-8]; - //sum += qlp_coeff[6] * data[i-7]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm3); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[5] * data[i-6]; - //sum += qlp_coeff[4] * data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm2); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[3] * data[i-4]; - //sum += qlp_coeff[2] * data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm1); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - else { /* order == 9 */ - __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); - xmm4 = _mm_cvtsi32_si128(qlp_coeff[8]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[8] * data[i-9]; - xmm7 = _mm_cvtsi32_si128(data[i-9]); - xmm7 = _mm_mul_epu32(xmm7, xmm4); - - //sum += qlp_coeff[7] * data[i-8]; - //sum += qlp_coeff[6] * data[i-7]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm3); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[5] * data[i-6]; - //sum += qlp_coeff[4] * data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm2); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[3] * data[i-4]; - //sum += qlp_coeff[2] * data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm1); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - } - } - else if(order > 4) { /* order == 5, 6, 7, 8 */ - if(order > 6) { /* order == 7, 8 */ - if(order == 8) { - __m128i xmm0, xmm1, xmm2, xmm3, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[7] * data[i-8]; - //sum += qlp_coeff[6] * data[i-7]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epu32(xmm7, xmm3); - - //sum += qlp_coeff[5] * data[i-6]; - //sum += qlp_coeff[4] * data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm2); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[3] * data[i-4]; - //sum += qlp_coeff[2] * data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm1); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - else { /* order == 7 */ - __m128i xmm0, xmm1, xmm2, xmm3, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_cvtsi32_si128(qlp_coeff[6]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[6] * data[i-7]; - xmm7 = _mm_cvtsi32_si128(data[i-7]); - xmm7 = _mm_mul_epu32(xmm7, xmm3); - - //sum += qlp_coeff[5] * data[i-6]; - //sum += qlp_coeff[4] * data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm2); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[3] * data[i-4]; - //sum += qlp_coeff[2] * data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm1); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - } - else { /* order == 5, 6 */ - if(order == 6) { - __m128i xmm0, xmm1, xmm2, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[5] * data[i-6]; - //sum += qlp_coeff[4] * data[i-5]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epu32(xmm7, xmm2); - - //sum += qlp_coeff[3] * data[i-4]; - //sum += qlp_coeff[2] * data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm1); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - else { /* order == 5 */ - __m128i xmm0, xmm1, xmm2, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_cvtsi32_si128(qlp_coeff[4]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[4] * data[i-5]; - xmm7 = _mm_cvtsi32_si128(data[i-5]); - xmm7 = _mm_mul_epu32(xmm7, xmm2); - - //sum += qlp_coeff[3] * data[i-4]; - //sum += qlp_coeff[2] * data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm1); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - } - } - else { /* order == 1, 2, 3, 4 */ - if(order > 2) { /* order == 3, 4 */ - if(order == 4) { - __m128i xmm0, xmm1, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[3] * data[i-4]; - //sum += qlp_coeff[2] * data[i-3]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epu32(xmm7, xmm1); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - else { /* order == 3 */ - __m128i xmm0, xmm1, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_cvtsi32_si128(qlp_coeff[2]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[2] * data[i-3]; - xmm7 = _mm_cvtsi32_si128(data[i-3]); - xmm7 = _mm_mul_epu32(xmm7, xmm1); - - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epu32(xmm6, xmm0); - xmm7 = _mm_add_epi32(xmm7, xmm6); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - } - else { /* order == 1, 2 */ - if(order == 2) { - __m128i xmm0, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[1] * data[i-2]; - //sum += qlp_coeff[0] * data[i-1]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epu32(xmm7, xmm0); - - xmm7 = _mm_add_epi32(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL32_RESULT(xmm7); - } - } - else { /* order == 1 */ - for(i = 0; i < (int)data_len; i++) - residual[i] = data[i] - ((qlp_coeff[0] * data[i-1]) >> lp_quantization); - } - } - } - } - else { /* order > 12 */ - FLAC__int32 sum; - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[ 9] * data[i-10]; - sum += qlp_coeff[ 8] * data[i- 9]; - sum += qlp_coeff[ 7] * data[i- 8]; - sum += qlp_coeff[ 6] * data[i- 7]; - sum += qlp_coeff[ 5] * data[i- 6]; - sum += qlp_coeff[ 4] * data[i- 5]; - sum += qlp_coeff[ 3] * data[i- 4]; - sum += qlp_coeff[ 2] * data[i- 3]; - sum += qlp_coeff[ 1] * data[i- 2]; - sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } -} - -#endif /* FLAC__CPU_IA32 */ -#endif /* FLAC__SSE2_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ -#endif /* FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/lpc_intrin_sse41.c b/Engine/lib/flac/src/libFLAC/lpc_intrin_sse41.c deleted file mode 100644 index 756c5dd80..000000000 --- a/Engine/lib/flac/src/libFLAC/lpc_intrin_sse41.c +++ /dev/null @@ -1,950 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#include "private/lpc.h" -#ifdef FLAC__SSE4_1_SUPPORTED - -#include "FLAC/assert.h" -#include "FLAC/format.h" - -#include /* SSE4.1 */ - -#if defined FLAC__CPU_IA32 /* unused for x64 */ - -#define RESIDUAL64_RESULT(xmmN) residual[i] = data[i] - _mm_cvtsi128_si32(_mm_srl_epi64(xmmN, cnt)) -#define RESIDUAL64_RESULT1(xmmN) residual[i] = data[i] - _mm_cvtsi128_si32(_mm_srli_epi64(xmmN, lp_quantization)) - -FLAC__SSE_TARGET("sse4.1") -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) -{ - int i; - const __m128i cnt = _mm_cvtsi32_si128(lp_quantization); - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - FLAC__ASSERT(lp_quantization <= 32); /* there's no _mm_sra_epi64() so we have to use _mm_srl_epi64() */ - - if(order <= 12) { - if(order > 8) { /* order == 9, 10, 11, 12 */ - if(order > 10) { /* order == 11, 12 */ - if(order == 12) { - __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); // 0 0 q[1] q[0] - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); // 0 0 q[3] q[2] - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); // 0 0 q[5] q[4] - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); // 0 0 q[7] q[6] - xmm4 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+8)); // 0 0 q[9] q[8] - xmm5 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+10)); // 0 0 q[11] q[10] - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); // 0 q[1] 0 q[0] - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); // 0 q[3] 0 q[2] - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); // 0 q[5] 0 q[4] - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); // 0 q[7] 0 q[6] - xmm4 = _mm_shuffle_epi32(xmm4, _MM_SHUFFLE(3,1,2,0)); // 0 q[9] 0 q[8] - xmm5 = _mm_shuffle_epi32(xmm5, _MM_SHUFFLE(3,1,2,0)); // 0 q[11] 0 q[10] - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; - //sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-12)); // 0 0 d[i-11] d[i-12] - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); // 0 d[i-12] 0 d[i-11] - xmm7 = _mm_mul_epi32(xmm7, xmm5); - - //sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; - //sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-10)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm4); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - //sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm3); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - //sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm2); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - //sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm1); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT1(xmm7); - } - } - else { /* order == 11 */ - __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); - xmm4 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+8)); - xmm5 = _mm_cvtsi32_si128(qlp_coeff[10]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); - xmm4 = _mm_shuffle_epi32(xmm4, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[10] * (FLAC__int64)data[i-11]; - xmm7 = _mm_cvtsi32_si128(data[i-11]); - xmm7 = _mm_mul_epi32(xmm7, xmm5); - - //sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; - //sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-10)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm4); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - //sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm3); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - //sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm2); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - //sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm1); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT1(xmm7); - } - } - } - else { /* order == 9, 10 */ - if(order == 10) { - __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); - xmm4 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+8)); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); - xmm4 = _mm_shuffle_epi32(xmm4, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[9] * (FLAC__int64)data[i-10]; - //sum += qlp_coeff[8] * (FLAC__int64)data[i-9]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-10)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epi32(xmm7, xmm4); - - //sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - //sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm3); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - //sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm2); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - //sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm1); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT(xmm7); - } - } - else { /* order == 9 */ - __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); - xmm4 = _mm_cvtsi32_si128(qlp_coeff[8]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[8] * (FLAC__int64)data[i-9]; - xmm7 = _mm_cvtsi32_si128(data[i-9]); - xmm7 = _mm_mul_epi32(xmm7, xmm4); - - //sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - //sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm3); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - //sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm2); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - //sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm1); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT(xmm7); - } - } - } - } - else if(order > 4) { /* order == 5, 6, 7, 8 */ - if(order > 6) { /* order == 7, 8 */ - if(order == 8) { - __m128i xmm0, xmm1, xmm2, xmm3, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+6)); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - xmm3 = _mm_shuffle_epi32(xmm3, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[7] * (FLAC__int64)data[i-8]; - //sum += qlp_coeff[6] * (FLAC__int64)data[i-7]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-8)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epi32(xmm7, xmm3); - - //sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - //sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm2); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - //sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm1); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT(xmm7); - } - } - else { /* order == 7 */ - __m128i xmm0, xmm1, xmm2, xmm3, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - xmm3 = _mm_cvtsi32_si128(qlp_coeff[6]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[6] * (FLAC__int64)data[i-7]; - xmm7 = _mm_cvtsi32_si128(data[i-7]); - xmm7 = _mm_mul_epi32(xmm7, xmm3); - - //sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - //sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm2); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - //sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm1); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT(xmm7); - } - } - } - else { /* order == 5, 6 */ - if(order == 6) { - __m128i xmm0, xmm1, xmm2, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+4)); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - xmm2 = _mm_shuffle_epi32(xmm2, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[5] * (FLAC__int64)data[i-6]; - //sum += qlp_coeff[4] * (FLAC__int64)data[i-5]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-6)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epi32(xmm7, xmm2); - - //sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - //sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm1); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT(xmm7); - } - } - else { /* order == 5 */ - __m128i xmm0, xmm1, xmm2, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - xmm2 = _mm_cvtsi32_si128(qlp_coeff[4]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[4] * (FLAC__int64)data[i-5]; - xmm7 = _mm_cvtsi32_si128(data[i-5]); - xmm7 = _mm_mul_epi32(xmm7, xmm2); - - //sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - //sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm1); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT(xmm7); - } - } - } - } - else { /* order == 1, 2, 3, 4 */ - if(order > 2) { /* order == 3, 4 */ - if(order == 4) { - __m128i xmm0, xmm1, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+2)); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - xmm1 = _mm_shuffle_epi32(xmm1, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[3] * (FLAC__int64)data[i-4]; - //sum += qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-4)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epi32(xmm7, xmm1); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT(xmm7); - } - } - else { /* order == 3 */ - __m128i xmm0, xmm1, xmm6, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm1 = _mm_cvtsi32_si128(qlp_coeff[2]); - - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum = qlp_coeff[2] * (FLAC__int64)data[i-3]; - xmm7 = _mm_cvtsi32_si128(data[i-3]); - xmm7 = _mm_mul_epi32(xmm7, xmm1); - - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm6 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm6 = _mm_shuffle_epi32(xmm6, _MM_SHUFFLE(2,0,3,1)); - xmm6 = _mm_mul_epi32(xmm6, xmm0); - xmm7 = _mm_add_epi64(xmm7, xmm6); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT(xmm7); - } - } - } - else { /* order == 1, 2 */ - if(order == 2) { - __m128i xmm0, xmm7; - xmm0 = _mm_loadl_epi64((const __m128i*)(const void*)(qlp_coeff+0)); - xmm0 = _mm_shuffle_epi32(xmm0, _MM_SHUFFLE(3,1,2,0)); - - for(i = 0; i < (int)data_len; i++) { - //sum = 0; - //sum += qlp_coeff[1] * (FLAC__int64)data[i-2]; - //sum += qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm7 = _mm_loadl_epi64((const __m128i*)(const void*)(data+i-2)); - xmm7 = _mm_shuffle_epi32(xmm7, _MM_SHUFFLE(2,0,3,1)); - xmm7 = _mm_mul_epi32(xmm7, xmm0); - - xmm7 = _mm_add_epi64(xmm7, _mm_srli_si128(xmm7, 8)); - RESIDUAL64_RESULT(xmm7); - } - } - else { /* order == 1 */ - __m128i xmm0, xmm7; - xmm0 = _mm_cvtsi32_si128(qlp_coeff[0]); - - for(i = 0; i < (int)data_len; i++) { - //sum = qlp_coeff[0] * (FLAC__int64)data[i-1]; - xmm7 = _mm_cvtsi32_si128(data[i-1]); - xmm7 = _mm_mul_epi32(xmm7, xmm0); - RESIDUAL64_RESULT(xmm7); - } - } - } - } - } - else { /* order > 12 */ - FLAC__int64 sum; - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13]; - sum += qlp_coeff[11] * (FLAC__int64)data[i-12]; - sum += qlp_coeff[10] * (FLAC__int64)data[i-11]; - sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10]; - sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9]; - sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8]; - sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7]; - sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6]; - sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5]; - sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4]; - sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3]; - sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2]; - sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1]; - } - residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization); - } - } -} - -#endif /* defined FLAC__CPU_IA32 */ - -FLAC__SSE_TARGET("sse4.1") -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) -{ - int i; - FLAC__int32 sum; - const __m128i cnt = _mm_cvtsi32_si128(lp_quantization); - - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= 32); - - if(order <= 12) { - if(order > 8) { - if(order > 10) { - if(order == 12) { - __m128i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - q8 = _mm_cvtsi32_si128(qlp_coeff[8]); q8 = _mm_shuffle_epi32(q8, _MM_SHUFFLE(0,0,0,0)); - q9 = _mm_cvtsi32_si128(qlp_coeff[9]); q9 = _mm_shuffle_epi32(q9, _MM_SHUFFLE(0,0,0,0)); - q10 = _mm_cvtsi32_si128(qlp_coeff[10]); q10 = _mm_shuffle_epi32(q10, _MM_SHUFFLE(0,0,0,0)); - q11 = _mm_cvtsi32_si128(qlp_coeff[11]); q11 = _mm_shuffle_epi32(q11, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q11, _mm_loadu_si128((const __m128i*)(const void*)(data+i-12))); - mull = _mm_mullo_epi32(q10, _mm_loadu_si128((const __m128i*)(const void*)(data+i-11))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q9, _mm_loadu_si128((const __m128i*)(const void*)(data+i-10))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q8, _mm_loadu_si128((const __m128i*)(const void*)(data+i-9))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 11 */ - __m128i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - q8 = _mm_cvtsi32_si128(qlp_coeff[8]); q8 = _mm_shuffle_epi32(q8, _MM_SHUFFLE(0,0,0,0)); - q9 = _mm_cvtsi32_si128(qlp_coeff[9]); q9 = _mm_shuffle_epi32(q9, _MM_SHUFFLE(0,0,0,0)); - q10 = _mm_cvtsi32_si128(qlp_coeff[10]); q10 = _mm_shuffle_epi32(q10, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q10, _mm_loadu_si128((const __m128i*)(const void*)(data+i-11))); - mull = _mm_mullo_epi32(q9, _mm_loadu_si128((const __m128i*)(const void*)(data+i-10))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q8, _mm_loadu_si128((const __m128i*)(const void*)(data+i-9))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 10) { - __m128i q0, q1, q2, q3, q4, q5, q6, q7, q8, q9; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - q8 = _mm_cvtsi32_si128(qlp_coeff[8]); q8 = _mm_shuffle_epi32(q8, _MM_SHUFFLE(0,0,0,0)); - q9 = _mm_cvtsi32_si128(qlp_coeff[9]); q9 = _mm_shuffle_epi32(q9, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q9, _mm_loadu_si128((const __m128i*)(const void*)(data+i-10))); - mull = _mm_mullo_epi32(q8, _mm_loadu_si128((const __m128i*)(const void*)(data+i-9))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 9 */ - __m128i q0, q1, q2, q3, q4, q5, q6, q7, q8; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - q8 = _mm_cvtsi32_si128(qlp_coeff[8]); q8 = _mm_shuffle_epi32(q8, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q8, _mm_loadu_si128((const __m128i*)(const void*)(data+i-9))); - mull = _mm_mullo_epi32(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - } - else if(order > 4) { - if(order > 6) { - if(order == 8) { - __m128i q0, q1, q2, q3, q4, q5, q6, q7; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - q7 = _mm_cvtsi32_si128(qlp_coeff[7]); q7 = _mm_shuffle_epi32(q7, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q7, _mm_loadu_si128((const __m128i*)(const void*)(data+i-8))); - mull = _mm_mullo_epi32(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 7 */ - __m128i q0, q1, q2, q3, q4, q5, q6; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - q6 = _mm_cvtsi32_si128(qlp_coeff[6]); q6 = _mm_shuffle_epi32(q6, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q6, _mm_loadu_si128((const __m128i*)(const void*)(data+i-7))); - mull = _mm_mullo_epi32(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 6) { - __m128i q0, q1, q2, q3, q4, q5; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - q5 = _mm_cvtsi32_si128(qlp_coeff[5]); q5 = _mm_shuffle_epi32(q5, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q5, _mm_loadu_si128((const __m128i*)(const void*)(data+i-6))); - mull = _mm_mullo_epi32(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 5 */ - __m128i q0, q1, q2, q3, q4; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - q4 = _mm_cvtsi32_si128(qlp_coeff[4]); q4 = _mm_shuffle_epi32(q4, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q4, _mm_loadu_si128((const __m128i*)(const void*)(data+i-5))); - mull = _mm_mullo_epi32(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - } - else { - if(order > 2) { - if(order == 4) { - __m128i q0, q1, q2, q3; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - q3 = _mm_cvtsi32_si128(qlp_coeff[3]); q3 = _mm_shuffle_epi32(q3, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q3, _mm_loadu_si128((const __m128i*)(const void*)(data+i-4))); - mull = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 3 */ - __m128i q0, q1, q2; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - q2 = _mm_cvtsi32_si128(qlp_coeff[2]); q2 = _mm_shuffle_epi32(q2, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q2, _mm_loadu_si128((const __m128i*)(const void*)(data+i-3))); - mull = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); summ = _mm_add_epi32(summ, mull); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - else { - if(order == 2) { - __m128i q0, q1; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - q1 = _mm_cvtsi32_si128(qlp_coeff[1]); q1 = _mm_shuffle_epi32(q1, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ, mull; - summ = _mm_mullo_epi32(q1, _mm_loadu_si128((const __m128i*)(const void*)(data+i-2))); - mull = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); summ = _mm_add_epi32(summ, mull); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - else { /* order == 1 */ - __m128i q0; - q0 = _mm_cvtsi32_si128(qlp_coeff[0]); q0 = _mm_shuffle_epi32(q0, _MM_SHUFFLE(0,0,0,0)); - - for(i = 0; i < (int)data_len-3; i+=4) { - __m128i summ; - summ = _mm_mullo_epi32(q0, _mm_loadu_si128((const __m128i*)(const void*)(data+i-1))); - summ = _mm_sra_epi32(summ, cnt); - _mm_storeu_si128((__m128i*)(void*)(residual+i), _mm_sub_epi32(_mm_loadu_si128((const __m128i*)(const void*)(data+i)), summ)); - } - } - } - } - for(; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 12: sum += qlp_coeff[11] * data[i-12]; /* Falls through. */ - case 11: sum += qlp_coeff[10] * data[i-11]; /* Falls through. */ - case 10: sum += qlp_coeff[ 9] * data[i-10]; /* Falls through. */ - case 9: sum += qlp_coeff[ 8] * data[i- 9]; /* Falls through. */ - case 8: sum += qlp_coeff[ 7] * data[i- 8]; /* Falls through. */ - case 7: sum += qlp_coeff[ 6] * data[i- 7]; /* Falls through. */ - case 6: sum += qlp_coeff[ 5] * data[i- 6]; /* Falls through. */ - case 5: sum += qlp_coeff[ 4] * data[i- 5]; /* Falls through. */ - case 4: sum += qlp_coeff[ 3] * data[i- 4]; /* Falls through. */ - case 3: sum += qlp_coeff[ 2] * data[i- 3]; /* Falls through. */ - case 2: sum += qlp_coeff[ 1] * data[i- 2]; /* Falls through. */ - case 1: sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } - else { /* order > 12 */ - for(i = 0; i < (int)data_len; i++) { - sum = 0; - switch(order) { - case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */ - case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */ - case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */ - case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */ - case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */ - case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */ - case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */ - case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */ - case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */ - case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */ - case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */ - case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */ - case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */ - case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */ - case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */ - case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */ - case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */ - case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */ - case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */ - case 13: sum += qlp_coeff[12] * data[i-13]; - sum += qlp_coeff[11] * data[i-12]; - sum += qlp_coeff[10] * data[i-11]; - sum += qlp_coeff[ 9] * data[i-10]; - sum += qlp_coeff[ 8] * data[i- 9]; - sum += qlp_coeff[ 7] * data[i- 8]; - sum += qlp_coeff[ 6] * data[i- 7]; - sum += qlp_coeff[ 5] * data[i- 6]; - sum += qlp_coeff[ 4] * data[i- 5]; - sum += qlp_coeff[ 3] * data[i- 4]; - sum += qlp_coeff[ 2] * data[i- 3]; - sum += qlp_coeff[ 1] * data[i- 2]; - sum += qlp_coeff[ 0] * data[i- 1]; - } - residual[i] = data[i] - (sum >> lp_quantization); - } - } -} - -#endif /* FLAC__SSE4_1_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ -#endif /* FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/libFLAC/md5.c b/Engine/lib/flac/src/libFLAC/md5.c deleted file mode 100644 index 09933d7ec..000000000 --- a/Engine/lib/flac/src/libFLAC/md5.c +++ /dev/null @@ -1,517 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include /* for malloc() */ -#include /* for memcpy() */ - -#include "private/md5.h" -#include "share/alloc.h" -#include "share/compat.h" -#include "share/endswap.h" - -/* - * This code implements the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was - * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. - * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which - * will fill a supplied 16-byte array with the digest. - * - * Changed so as no longer to depend on Colin Plumb's `usual.h' header - * definitions; now uses stuff from dpkg's config.h. - * - Ian Jackson . - * Still in the public domain. - * - * Josh Coalson: made some changes to integrate with libFLAC. - * Still in the public domain. - */ - -/* The four core functions - F1 is optimized somewhat */ - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f,w,x,y,z,in,s) \ - (w += f(x,y,z) + in, w = (w<>(32-s)) + x) - -/* - * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks - * the data and converts bytes into longwords for this routine. - */ -static void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16]) -{ - register FLAC__uint32 a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - -#if WORDS_BIGENDIAN -//@@@@@@ OPT: use bswap/intrinsics -static void byteSwap(FLAC__uint32 *buf, uint32_t words) -{ - register FLAC__uint32 x; - do { - x = *buf; - x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); - *buf++ = (x >> 16) | (x << 16); - } while (--words); -} -static void byteSwapX16(FLAC__uint32 *buf) -{ - register FLAC__uint32 x; - - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16); - x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf = (x >> 16) | (x << 16); -} -#else -#define byteSwap(buf, words) -#define byteSwapX16(buf) -#endif - -/* - * Update context to reflect the concatenation of another buffer full - * of bytes. - */ -static void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, uint32_t len) -{ - FLAC__uint32 t; - - /* Update byte count */ - - t = ctx->bytes[0]; - if ((ctx->bytes[0] = t + len) < t) - ctx->bytes[1]++; /* Carry from low to high */ - - t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */ - if (t > len) { - memcpy((FLAC__byte *)ctx->in + 64 - t, buf, len); - return; - } - /* First chunk is an odd size */ - memcpy((FLAC__byte *)ctx->in + 64 - t, buf, t); - byteSwapX16(ctx->in); - FLAC__MD5Transform(ctx->buf, ctx->in); - buf += t; - len -= t; - - /* Process data in 64-byte chunks */ - while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteSwapX16(ctx->in); - FLAC__MD5Transform(ctx->buf, ctx->in); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - memcpy(ctx->in, buf, len); -} - -/* - * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious - * initialization constants. - */ -void FLAC__MD5Init(FLAC__MD5Context *ctx) -{ - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; - - ctx->bytes[0] = 0; - ctx->bytes[1] = 0; - - ctx->internal_buf.p8 = 0; - ctx->capacity = 0; -} - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx) -{ - int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */ - FLAC__byte *p = (FLAC__byte *)ctx->in + count; - - /* Set the first char of padding to 0x80. There is always room. */ - *p++ = 0x80; - - /* Bytes of padding needed to make 56 bytes (-8..55) */ - count = 56 - 1 - count; - - if (count < 0) { /* Padding forces an extra block */ - memset(p, 0, count + 8); - byteSwapX16(ctx->in); - FLAC__MD5Transform(ctx->buf, ctx->in); - p = (FLAC__byte *)ctx->in; - count = 56; - } - memset(p, 0, count); - byteSwap(ctx->in, 14); - - /* Append length in bits and transform */ - ctx->in[14] = ctx->bytes[0] << 3; - ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29; - FLAC__MD5Transform(ctx->buf, ctx->in); - - byteSwap(ctx->buf, 4); - memcpy(digest, ctx->buf, 16); - if (0 != ctx->internal_buf.p8) { - free(ctx->internal_buf.p8); - ctx->internal_buf.p8 = 0; - ctx->capacity = 0; - } - memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ -} - -/* - * Convert the incoming audio signal to a byte stream - */ -static void format_input_(FLAC__multibyte *mbuf, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample) -{ - FLAC__byte *buf_ = mbuf->p8; - FLAC__int16 *buf16 = mbuf->p16; - FLAC__int32 *buf32 = mbuf->p32; - FLAC__int32 a_word; - uint32_t channel, sample; - - /* Storage in the output buffer, buf, is little endian. */ - -#define BYTES_CHANNEL_SELECTOR(bytes, channels) (bytes * 100 + channels) - - /* First do the most commonly used combinations. */ - switch (BYTES_CHANNEL_SELECTOR (bytes_per_sample, channels)) { - /* One byte per sample. */ - case (BYTES_CHANNEL_SELECTOR (1, 1)): - for (sample = 0; sample < samples; sample++) - *buf_++ = signal[0][sample]; - return; - - case (BYTES_CHANNEL_SELECTOR (1, 2)): - for (sample = 0; sample < samples; sample++) { - *buf_++ = signal[0][sample]; - *buf_++ = signal[1][sample]; - } - return; - - case (BYTES_CHANNEL_SELECTOR (1, 4)): - for (sample = 0; sample < samples; sample++) { - *buf_++ = signal[0][sample]; - *buf_++ = signal[1][sample]; - *buf_++ = signal[2][sample]; - *buf_++ = signal[3][sample]; - } - return; - - case (BYTES_CHANNEL_SELECTOR (1, 6)): - for (sample = 0; sample < samples; sample++) { - *buf_++ = signal[0][sample]; - *buf_++ = signal[1][sample]; - *buf_++ = signal[2][sample]; - *buf_++ = signal[3][sample]; - *buf_++ = signal[4][sample]; - *buf_++ = signal[5][sample]; - } - return; - - case (BYTES_CHANNEL_SELECTOR (1, 8)): - for (sample = 0; sample < samples; sample++) { - *buf_++ = signal[0][sample]; - *buf_++ = signal[1][sample]; - *buf_++ = signal[2][sample]; - *buf_++ = signal[3][sample]; - *buf_++ = signal[4][sample]; - *buf_++ = signal[5][sample]; - *buf_++ = signal[6][sample]; - *buf_++ = signal[7][sample]; - } - return; - - /* Two bytes per sample. */ - case (BYTES_CHANNEL_SELECTOR (2, 1)): - for (sample = 0; sample < samples; sample++) - *buf16++ = H2LE_16(signal[0][sample]); - return; - - case (BYTES_CHANNEL_SELECTOR (2, 2)): - for (sample = 0; sample < samples; sample++) { - *buf16++ = H2LE_16(signal[0][sample]); - *buf16++ = H2LE_16(signal[1][sample]); - } - return; - - case (BYTES_CHANNEL_SELECTOR (2, 4)): - for (sample = 0; sample < samples; sample++) { - *buf16++ = H2LE_16(signal[0][sample]); - *buf16++ = H2LE_16(signal[1][sample]); - *buf16++ = H2LE_16(signal[2][sample]); - *buf16++ = H2LE_16(signal[3][sample]); - } - return; - - case (BYTES_CHANNEL_SELECTOR (2, 6)): - for (sample = 0; sample < samples; sample++) { - *buf16++ = H2LE_16(signal[0][sample]); - *buf16++ = H2LE_16(signal[1][sample]); - *buf16++ = H2LE_16(signal[2][sample]); - *buf16++ = H2LE_16(signal[3][sample]); - *buf16++ = H2LE_16(signal[4][sample]); - *buf16++ = H2LE_16(signal[5][sample]); - } - return; - - case (BYTES_CHANNEL_SELECTOR (2, 8)): - for (sample = 0; sample < samples; sample++) { - *buf16++ = H2LE_16(signal[0][sample]); - *buf16++ = H2LE_16(signal[1][sample]); - *buf16++ = H2LE_16(signal[2][sample]); - *buf16++ = H2LE_16(signal[3][sample]); - *buf16++ = H2LE_16(signal[4][sample]); - *buf16++ = H2LE_16(signal[5][sample]); - *buf16++ = H2LE_16(signal[6][sample]); - *buf16++ = H2LE_16(signal[7][sample]); - } - return; - - /* Three bytes per sample. */ - case (BYTES_CHANNEL_SELECTOR (3, 1)): - for (sample = 0; sample < samples; sample++) { - a_word = signal[0][sample]; - *buf_++ = (FLAC__byte)a_word; a_word >>= 8; - *buf_++ = (FLAC__byte)a_word; a_word >>= 8; - *buf_++ = (FLAC__byte)a_word; - } - return; - - case (BYTES_CHANNEL_SELECTOR (3, 2)): - for (sample = 0; sample < samples; sample++) { - a_word = signal[0][sample]; - *buf_++ = (FLAC__byte)a_word; a_word >>= 8; - *buf_++ = (FLAC__byte)a_word; a_word >>= 8; - *buf_++ = (FLAC__byte)a_word; - a_word = signal[1][sample]; - *buf_++ = (FLAC__byte)a_word; a_word >>= 8; - *buf_++ = (FLAC__byte)a_word; a_word >>= 8; - *buf_++ = (FLAC__byte)a_word; - } - return; - - /* Four bytes per sample. */ - case (BYTES_CHANNEL_SELECTOR (4, 1)): - for (sample = 0; sample < samples; sample++) - *buf32++ = H2LE_32(signal[0][sample]); - return; - - case (BYTES_CHANNEL_SELECTOR (4, 2)): - for (sample = 0; sample < samples; sample++) { - *buf32++ = H2LE_32(signal[0][sample]); - *buf32++ = H2LE_32(signal[1][sample]); - } - return; - - case (BYTES_CHANNEL_SELECTOR (4, 4)): - for (sample = 0; sample < samples; sample++) { - *buf32++ = H2LE_32(signal[0][sample]); - *buf32++ = H2LE_32(signal[1][sample]); - *buf32++ = H2LE_32(signal[2][sample]); - *buf32++ = H2LE_32(signal[3][sample]); - } - return; - - case (BYTES_CHANNEL_SELECTOR (4, 6)): - for (sample = 0; sample < samples; sample++) { - *buf32++ = H2LE_32(signal[0][sample]); - *buf32++ = H2LE_32(signal[1][sample]); - *buf32++ = H2LE_32(signal[2][sample]); - *buf32++ = H2LE_32(signal[3][sample]); - *buf32++ = H2LE_32(signal[4][sample]); - *buf32++ = H2LE_32(signal[5][sample]); - } - return; - - case (BYTES_CHANNEL_SELECTOR (4, 8)): - for (sample = 0; sample < samples; sample++) { - *buf32++ = H2LE_32(signal[0][sample]); - *buf32++ = H2LE_32(signal[1][sample]); - *buf32++ = H2LE_32(signal[2][sample]); - *buf32++ = H2LE_32(signal[3][sample]); - *buf32++ = H2LE_32(signal[4][sample]); - *buf32++ = H2LE_32(signal[5][sample]); - *buf32++ = H2LE_32(signal[6][sample]); - *buf32++ = H2LE_32(signal[7][sample]); - } - return; - - default: - break; - } - - /* General version. */ - switch (bytes_per_sample) { - case 1: - for (sample = 0; sample < samples; sample++) - for (channel = 0; channel < channels; channel++) - *buf_++ = signal[channel][sample]; - return; - - case 2: - for (sample = 0; sample < samples; sample++) - for (channel = 0; channel < channels; channel++) - *buf16++ = H2LE_16(signal[channel][sample]); - return; - - case 3: - for (sample = 0; sample < samples; sample++) - for (channel = 0; channel < channels; channel++) { - a_word = signal[channel][sample]; - *buf_++ = (FLAC__byte)a_word; a_word >>= 8; - *buf_++ = (FLAC__byte)a_word; a_word >>= 8; - *buf_++ = (FLAC__byte)a_word; - } - return; - - case 4: - for (sample = 0; sample < samples; sample++) - for (channel = 0; channel < channels; channel++) - *buf32++ = H2LE_32(signal[channel][sample]); - return; - - default: - break; - } -} - -/* - * Convert the incoming audio signal to a byte stream and FLAC__MD5Update it. - */ -FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample) -{ - const size_t bytes_needed = (size_t)channels * (size_t)samples * (size_t)bytes_per_sample; - - /* overflow check */ - if ((size_t)channels > SIZE_MAX / (size_t)bytes_per_sample) - return false; - if ((size_t)channels * (size_t)bytes_per_sample > SIZE_MAX / (size_t)samples) - return false; - - if (ctx->capacity < bytes_needed) { - if (0 == (ctx->internal_buf.p8 = safe_realloc_(ctx->internal_buf.p8, bytes_needed))) { - if (0 == (ctx->internal_buf.p8 = safe_malloc_(bytes_needed))) { - ctx->capacity = 0; - return false; - } - } - ctx->capacity = bytes_needed; - } - - format_input_(&ctx->internal_buf, signal, channels, samples, bytes_per_sample); - - FLAC__MD5Update(ctx, ctx->internal_buf.p8, bytes_needed); - - return true; -} diff --git a/Engine/lib/flac/src/libFLAC/memory.c b/Engine/lib/flac/src/libFLAC/memory.c deleted file mode 100644 index ad5371ee9..000000000 --- a/Engine/lib/flac/src/libFLAC/memory.c +++ /dev/null @@ -1,219 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifdef HAVE_STDINT_H -#include -#endif - -#include "private/memory.h" -#include "FLAC/assert.h" -#include "share/compat.h" -#include "share/alloc.h" - -void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address) -{ - void *x; - - FLAC__ASSERT(0 != aligned_address); - -#ifdef FLAC__ALIGN_MALLOC_DATA - /* align on 32-byte (256-bit) boundary */ - x = safe_malloc_add_2op_(bytes, /*+*/31L); - *aligned_address = (void*)(((uintptr_t)x + 31L) & -32L); -#else - x = safe_malloc_(bytes); - *aligned_address = x; -#endif - return x; -} - -FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer) -{ - FLAC__int32 *pu; /* unaligned pointer */ - union { /* union needed to comply with C99 pointer aliasing rules */ - FLAC__int32 *pa; /* aligned pointer */ - void *pv; /* aligned pointer alias */ - } u; - - FLAC__ASSERT(elements > 0); - FLAC__ASSERT(0 != unaligned_pointer); - FLAC__ASSERT(0 != aligned_pointer); - FLAC__ASSERT(unaligned_pointer != aligned_pointer); - - if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - - pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); - if(0 == pu) { - return false; - } - else { - if(*unaligned_pointer != 0) - free(*unaligned_pointer); - *unaligned_pointer = pu; - *aligned_pointer = u.pa; - return true; - } -} - -FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer) -{ - FLAC__uint32 *pu; /* unaligned pointer */ - union { /* union needed to comply with C99 pointer aliasing rules */ - FLAC__uint32 *pa; /* aligned pointer */ - void *pv; /* aligned pointer alias */ - } u; - - FLAC__ASSERT(elements > 0); - FLAC__ASSERT(0 != unaligned_pointer); - FLAC__ASSERT(0 != aligned_pointer); - FLAC__ASSERT(unaligned_pointer != aligned_pointer); - - if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - - pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); - if(0 == pu) { - return false; - } - else { - if(*unaligned_pointer != 0) - free(*unaligned_pointer); - *unaligned_pointer = pu; - *aligned_pointer = u.pa; - return true; - } -} - -FLAC__bool FLAC__memory_alloc_aligned_int64_array(size_t elements, FLAC__int64 **unaligned_pointer, FLAC__int64 **aligned_pointer) -{ - FLAC__int64 *pu; /* unaligned pointer */ - union { /* union needed to comply with C99 pointer aliasing rules */ - FLAC__int64 *pa; /* aligned pointer */ - void *pv; /* aligned pointer alias */ - } u; - - FLAC__ASSERT(elements > 0); - FLAC__ASSERT(0 != unaligned_pointer); - FLAC__ASSERT(0 != aligned_pointer); - FLAC__ASSERT(unaligned_pointer != aligned_pointer); - - if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - - pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); - if(0 == pu) { - return false; - } - else { - if(*unaligned_pointer != 0) - free(*unaligned_pointer); - *unaligned_pointer = pu; - *aligned_pointer = u.pa; - return true; - } -} - -FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer) -{ - FLAC__uint64 *pu; /* unaligned pointer */ - union { /* union needed to comply with C99 pointer aliasing rules */ - FLAC__uint64 *pa; /* aligned pointer */ - void *pv; /* aligned pointer alias */ - } u; - - FLAC__ASSERT(elements > 0); - FLAC__ASSERT(0 != unaligned_pointer); - FLAC__ASSERT(0 != aligned_pointer); - FLAC__ASSERT(unaligned_pointer != aligned_pointer); - - if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - - pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); - if(0 == pu) { - return false; - } - else { - if(*unaligned_pointer != 0) - free(*unaligned_pointer); - *unaligned_pointer = pu; - *aligned_pointer = u.pa; - return true; - } -} - -#ifndef FLAC__INTEGER_ONLY_LIBRARY - -FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer) -{ - FLAC__real *pu; /* unaligned pointer */ - union { /* union needed to comply with C99 pointer aliasing rules */ - FLAC__real *pa; /* aligned pointer */ - void *pv; /* aligned pointer alias */ - } u; - - FLAC__ASSERT(elements > 0); - FLAC__ASSERT(0 != unaligned_pointer); - FLAC__ASSERT(0 != aligned_pointer); - FLAC__ASSERT(unaligned_pointer != aligned_pointer); - - if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - - pu = FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); - if(0 == pu) { - return false; - } - else { - if(*unaligned_pointer != 0) - free(*unaligned_pointer); - *unaligned_pointer = pu; - *aligned_pointer = u.pa; - return true; - } -} - -#endif - -void *safe_malloc_mul_2op_p(size_t size1, size_t size2) -{ - if(!size1 || !size2) - return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ - if(size1 > SIZE_MAX / size2) - return 0; - return malloc(size1*size2); -} diff --git a/Engine/lib/flac/src/libFLAC/metadata_iterators.c b/Engine/lib/flac/src/libFLAC/metadata_iterators.c deleted file mode 100644 index 20e926bec..000000000 --- a/Engine/lib/flac/src/libFLAC/metadata_iterators.c +++ /dev/null @@ -1,3554 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include - -#include /* for stat(), maybe chmod() */ - -#include "private/metadata.h" - -#include "FLAC/assert.h" -#include "FLAC/stream_decoder.h" -#include "share/alloc.h" -#include "share/compat.h" -#include "share/macros.h" -#include "private/macros.h" -#include "private/memory.h" - -/* Alias the first (in share/alloc.h) to the second (in src/libFLAC/memory.c). */ -#define safe_malloc_mul_2op_ safe_malloc_mul_2op_p - -/**************************************************************************** - * - * Local function declarations - * - ***************************************************************************/ - -static void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes); -static void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes); -static void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, uint32_t bytes); -static FLAC__uint32 unpack_uint32_(FLAC__byte *b, uint32_t bytes); -static FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, uint32_t bytes); -static FLAC__uint64 unpack_uint64_(FLAC__byte *b, uint32_t bytes); - -static FLAC__bool read_metadata_block_header_(FLAC__Metadata_SimpleIterator *iterator); -static FLAC__bool read_metadata_block_data_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block); -static FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, uint32_t *length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata *block); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_StreamInfo *block); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, uint32_t block_length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, uint32_t block_length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, uint32_t block_length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, uint32_t max_length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, uint32_t block_length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet_Track *track); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet *block); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Picture *block); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, uint32_t block_length); - -static FLAC__bool write_metadata_block_header_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block); -static FLAC__bool write_metadata_block_data_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block); -static FLAC__bool write_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block); -static FLAC__bool write_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block); -static FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_StreamInfo *block); -static FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, uint32_t block_length); -static FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, uint32_t block_length); -static FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_SeekTable *block); -static FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_VorbisComment *block); -static FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_CueSheet *block); -static FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Picture *block); -static FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, uint32_t block_length); - -static FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *iterator, const FLAC__StreamMetadata *block); -static FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, uint32_t padding_length, FLAC__bool padding_is_last); -static FLAC__bool rewrite_whole_file_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool append); - -static void simple_iterator_push_(FLAC__Metadata_SimpleIterator *iterator); -static FLAC__bool simple_iterator_pop_(FLAC__Metadata_SimpleIterator *iterator); - -static uint32_t seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb); -static uint32_t seek_to_first_metadata_block_(FILE *f); - -static FLAC__bool simple_iterator_copy_file_prefix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, FLAC__bool append); -static FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, FLAC__off_t fixup_is_last_flag_offset, FLAC__bool backup); - -static FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, FLAC__off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status); -static FLAC__bool copy_n_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, FLAC__off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status); -static FLAC__bool copy_remaining_bytes_from_file_(FILE *file, FILE *tempfile, FLAC__Metadata_SimpleIteratorStatus *status); -static FLAC__bool copy_remaining_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Eof eof_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, FLAC__Metadata_SimpleIteratorStatus *status); - -static FLAC__bool open_tempfile_(const char *filename, const char *tempfile_path_prefix, FILE **tempfile, char **tempfilename, FLAC__Metadata_SimpleIteratorStatus *status); -static FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename, FLAC__Metadata_SimpleIteratorStatus *status); -static void cleanup_tempfile_(FILE **tempfile, char **tempfilename); - -static FLAC__bool get_file_stats_(const char *filename, struct flac_stat_s *stats); -static void set_file_stats_(const char *filename, struct flac_stat_s *stats); - -static int fseek_wrapper_(FLAC__IOHandle handle, FLAC__int64 offset, int whence); -static FLAC__int64 ftell_wrapper_(FLAC__IOHandle handle); - -static FLAC__Metadata_ChainStatus get_equivalent_status_(FLAC__Metadata_SimpleIteratorStatus status); - - -#ifdef FLAC__VALGRIND_TESTING -static size_t local__fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - size_t ret = fwrite(ptr, size, nmemb, stream); - if(!ferror(stream)) - fflush(stream); - return ret; -} -#else -#define local__fwrite fwrite -#endif - -/**************************************************************************** - * - * Level 0 implementation - * - ***************************************************************************/ - -static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); -static void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); -static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); - -typedef struct { - FLAC__bool got_error; - FLAC__StreamMetadata *object; -} level0_client_data; - -static FLAC__StreamMetadata *get_one_metadata_block_(const char *filename, FLAC__MetadataType type) -{ - level0_client_data cd; - FLAC__StreamDecoder *decoder; - - FLAC__ASSERT(0 != filename); - - cd.got_error = false; - cd.object = 0; - - decoder = FLAC__stream_decoder_new(); - - if(0 == decoder) - return 0; - - FLAC__stream_decoder_set_md5_checking(decoder, false); - FLAC__stream_decoder_set_metadata_ignore_all(decoder); - FLAC__stream_decoder_set_metadata_respond(decoder, type); - - if(FLAC__stream_decoder_init_file(decoder, filename, write_callback_, metadata_callback_, error_callback_, &cd) != FLAC__STREAM_DECODER_INIT_STATUS_OK || cd.got_error) { - (void)FLAC__stream_decoder_finish(decoder); - FLAC__stream_decoder_delete(decoder); - return 0; - } - - if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder) || cd.got_error) { - (void)FLAC__stream_decoder_finish(decoder); - FLAC__stream_decoder_delete(decoder); - if(0 != cd.object) - FLAC__metadata_object_delete(cd.object); - return 0; - } - - (void)FLAC__stream_decoder_finish(decoder); - FLAC__stream_decoder_delete(decoder); - - return cd.object; -} - -FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo) -{ - FLAC__StreamMetadata *object; - - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != streaminfo); - - object = get_one_metadata_block_(filename, FLAC__METADATA_TYPE_STREAMINFO); - - if (object) { - /* can just copy the contents since STREAMINFO has no internal structure */ - *streaminfo = *object; - FLAC__metadata_object_delete(object); - return true; - } - else { - return false; - } -} - -FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != tags); - - *tags = get_one_metadata_block_(filename, FLAC__METADATA_TYPE_VORBIS_COMMENT); - - return 0 != *tags; -} - -FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__StreamMetadata **cuesheet) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != cuesheet); - - *cuesheet = get_one_metadata_block_(filename, FLAC__METADATA_TYPE_CUESHEET); - - return 0 != *cuesheet; -} - -FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - (void)decoder, (void)frame, (void)buffer, (void)client_data; - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - level0_client_data *cd = (level0_client_data *)client_data; - (void)decoder; - - /* - * we assume we only get here when the one metadata block we were - * looking for was passed to us - */ - if(!cd->got_error && 0 == cd->object) { - if(0 == (cd->object = FLAC__metadata_object_clone(metadata))) - cd->got_error = true; - } -} - -void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - level0_client_data *cd = (level0_client_data *)client_data; - (void)decoder; - - if(status != FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC) - cd->got_error = true; -} - -FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors) -{ - FLAC__Metadata_SimpleIterator *it; - FLAC__uint64 max_area_seen = 0; - FLAC__uint64 max_depth_seen = 0; - - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != picture); - - *picture = 0; - - it = FLAC__metadata_simple_iterator_new(); - if(0 == it) - return false; - if(!FLAC__metadata_simple_iterator_init(it, filename, /*read_only=*/true, /*preserve_file_stats=*/true)) { - FLAC__metadata_simple_iterator_delete(it); - return false; - } - do { - if(FLAC__metadata_simple_iterator_get_block_type(it) == FLAC__METADATA_TYPE_PICTURE) { - FLAC__StreamMetadata *obj = FLAC__metadata_simple_iterator_get_block(it); - if(0 != obj) { - FLAC__uint64 area = (FLAC__uint64)obj->data.picture.width * (FLAC__uint64)obj->data.picture.height; - - /* check constraints */ - if( - (type == (FLAC__StreamMetadata_Picture_Type)(-1) || type == obj->data.picture.type) && - (mime_type == 0 || !strcmp(mime_type, obj->data.picture.mime_type)) && - (description == 0 || !strcmp((const char *)description, (const char *)obj->data.picture.description)) && - obj->data.picture.width <= max_width && - obj->data.picture.height <= max_height && - obj->data.picture.depth <= max_depth && - obj->data.picture.colors <= max_colors && - (area > max_area_seen || (area == max_area_seen && obj->data.picture.depth > max_depth_seen)) - ) { - if(*picture) - FLAC__metadata_object_delete(*picture); - *picture = obj; - max_area_seen = area; - max_depth_seen = obj->data.picture.depth; - } - else { - FLAC__metadata_object_delete(obj); - } - } - else - break; - } - } while(FLAC__metadata_simple_iterator_next(it)); - - FLAC__metadata_simple_iterator_delete(it); - - return (0 != *picture); -} - - -/**************************************************************************** - * - * Level 1 implementation - * - ***************************************************************************/ - -#define SIMPLE_ITERATOR_MAX_PUSH_DEPTH (1+4) -/* 1 for initial offset, +4 for our own personal use */ - -struct FLAC__Metadata_SimpleIterator { - FILE *file; - char *filename, *tempfile_path_prefix; - struct flac_stat_s stats; - FLAC__bool has_stats; - FLAC__bool is_writable; - FLAC__Metadata_SimpleIteratorStatus status; - FLAC__off_t offset[SIMPLE_ITERATOR_MAX_PUSH_DEPTH]; - FLAC__off_t first_offset; /* this is the offset to the STREAMINFO block */ - uint32_t depth; - /* this is the metadata block header of the current block we are pointing to: */ - FLAC__bool is_last; - FLAC__MetadataType type; - uint32_t length; -}; - -FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[] = { - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR", - "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR" -}; - - -FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new(void) -{ - FLAC__Metadata_SimpleIterator *iterator = calloc(1, sizeof(FLAC__Metadata_SimpleIterator)); - - if(0 != iterator) { - iterator->file = 0; - iterator->filename = 0; - iterator->tempfile_path_prefix = 0; - iterator->has_stats = false; - iterator->is_writable = false; - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; - iterator->first_offset = iterator->offset[0] = -1; - iterator->depth = 0; - } - - return iterator; -} - -static void simple_iterator_free_guts_(FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - - if(0 != iterator->file) { - fclose(iterator->file); - iterator->file = 0; - if(iterator->has_stats) - set_file_stats_(iterator->filename, &iterator->stats); - } - if(0 != iterator->filename) { - free(iterator->filename); - iterator->filename = 0; - } - if(0 != iterator->tempfile_path_prefix) { - free(iterator->tempfile_path_prefix); - iterator->tempfile_path_prefix = 0; - } -} - -FLAC_API void FLAC__metadata_simple_iterator_delete(FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - - simple_iterator_free_guts_(iterator); - free(iterator); -} - -FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status(FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__Metadata_SimpleIteratorStatus status; - - FLAC__ASSERT(0 != iterator); - - status = iterator->status; - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; - return status; -} - -static FLAC__bool simple_iterator_prime_input_(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool read_only) -{ - uint32_t ret; - - FLAC__ASSERT(0 != iterator); - - if(read_only || 0 == (iterator->file = flac_fopen(iterator->filename, "r+b"))) { - iterator->is_writable = false; - if(read_only || errno == EACCES) { - if(0 == (iterator->file = flac_fopen(iterator->filename, "rb"))) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE; - return false; - } - } - else { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE; - return false; - } - } - else { - iterator->is_writable = true; - } - - ret = seek_to_first_metadata_block_(iterator->file); - switch(ret) { - case 0: - iterator->depth = 0; - iterator->first_offset = iterator->offset[iterator->depth] = ftello(iterator->file); - ret = read_metadata_block_header_(iterator); - /* The first metadata block must be a streaminfo. If this is not the - * case, the file is invalid and assumptions made elsewhere in the - * code are invalid */ - if(iterator->type != FLAC__METADATA_TYPE_STREAMINFO) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA; - return false; - } - return ret; - case 1: - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - return false; - case 2: - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - case 3: - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE; - return false; - default: - FLAC__ASSERT(0); - return false; - } -} - -#if 0 -@@@ If we decide to finish implementing this, put this comment back in metadata.h -/* - * The 'tempfile_path_prefix' allows you to specify a directory where - * tempfiles should go. Remember that if your metadata edits cause the - * FLAC file to grow, the entire file will have to be rewritten. If - * 'tempfile_path_prefix' is NULL, the temp file will be written in the - * same directory as the original FLAC file. This makes replacing the - * original with the tempfile fast but requires extra space in the same - * partition for the tempfile. If space is a problem, you can pass a - * directory name belonging to a different partition in - * 'tempfile_path_prefix'. Note that you should use the forward slash - * '/' as the directory separator. A trailing slash is not needed; it - * will be added automatically. - */ -FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool preserve_file_stats, const char *tempfile_path_prefix); -#endif - -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool read_only, FLAC__bool preserve_file_stats) -{ - const char *tempfile_path_prefix = 0; /*@@@ search for comments near 'flac_rename(...)' for what it will take to finish implementing this */ - - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != filename); - - simple_iterator_free_guts_(iterator); - - if(!read_only && preserve_file_stats) - iterator->has_stats = get_file_stats_(filename, &iterator->stats); - - if(0 == (iterator->filename = strdup(filename))) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - return false; - } - if(0 != tempfile_path_prefix && 0 == (iterator->tempfile_path_prefix = strdup(tempfile_path_prefix))) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - return false; - } - - return simple_iterator_prime_input_(iterator, read_only); -} - -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable(const FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - - return iterator->is_writable; -} - -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - if(iterator->is_last) - return false; - - if(0 != fseeko(iterator->file, iterator->length, SEEK_CUR)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - - iterator->offset[iterator->depth] = ftello(iterator->file); - - return read_metadata_block_header_(iterator); -} - -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__off_t this_offset; - - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - if(iterator->offset[iterator->depth] == iterator->first_offset) - return false; - - if(0 != fseeko(iterator->file, iterator->first_offset, SEEK_SET)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - this_offset = iterator->first_offset; - if(!read_metadata_block_header_(iterator)) - return false; - - /* we ignore any error from ftello() and catch it in fseeko() */ - while(ftello(iterator->file) + (FLAC__off_t)iterator->length < iterator->offset[iterator->depth]) { - if(0 != fseeko(iterator->file, iterator->length, SEEK_CUR)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - this_offset = ftello(iterator->file); - if(!read_metadata_block_header_(iterator)) - return false; - } - - iterator->offset[iterator->depth] = this_offset; - - return true; -} - -/*@@@@add to tests*/ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - return iterator->is_last; -} - -/*@@@@add to tests*/ -FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - return (off_t)iterator->offset[iterator->depth]; -} - -FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - return iterator->type; -} - -/*@@@@add to tests*/ -FLAC_API uint32_t FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - return iterator->length; -} - -/*@@@@add to tests*/ -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id) -{ - const uint32_t id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; - - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(0 != id); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - if(iterator->type != FLAC__METADATA_TYPE_APPLICATION) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT; - return false; - } - - if(fread(id, 1, id_bytes, iterator->file) != id_bytes) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - return false; - } - - /* back up */ - if(0 != fseeko(iterator->file, -((int)id_bytes), SEEK_CUR)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - - return true; -} - -FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__StreamMetadata *block = FLAC__metadata_object_new(iterator->type); - - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - if(0 != block) { - block->is_last = iterator->is_last; - block->length = iterator->length; - - if(!read_metadata_block_data_(iterator, block)) { - FLAC__metadata_object_delete(block); - return 0; - } - - /* back up to the beginning of the block data to stay consistent */ - if(0 != fseeko(iterator->file, iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH, SEEK_SET)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - FLAC__metadata_object_delete(block); - return 0; - } - } - else - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - - return block; -} - -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding) -{ - FLAC__ASSERT_DECLARATION(FLAC__off_t debug_target_offset = iterator->offset[iterator->depth];) - FLAC__bool ret; - - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(0 != block); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - if(!iterator->is_writable) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE; - return false; - } - - if(iterator->type == FLAC__METADATA_TYPE_STREAMINFO || block->type == FLAC__METADATA_TYPE_STREAMINFO) { - if(iterator->type != block->type) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT; - return false; - } - } - - block->is_last = iterator->is_last; - - if(iterator->length == block->length) - return write_metadata_block_stationary_(iterator, block); - else if(iterator->length > block->length) { - if(use_padding && iterator->length >= FLAC__STREAM_METADATA_HEADER_LENGTH + block->length) { - ret = write_metadata_block_stationary_with_padding_(iterator, block, iterator->length - FLAC__STREAM_METADATA_HEADER_LENGTH - block->length, block->is_last); - FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); - return ret; - } - else { - if((ret = rewrite_whole_file_(iterator, block, /*append=*/false))) { - FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); - } - return ret; - } - } - else /* iterator->length < block->length */ { - uint32_t padding_leftover = 0; - FLAC__bool padding_is_last = false; - if(use_padding) { - /* first see if we can even use padding */ - if(iterator->is_last) { - use_padding = false; - } - else { - const uint32_t extra_padding_bytes_required = block->length - iterator->length; - simple_iterator_push_(iterator); - if(!FLAC__metadata_simple_iterator_next(iterator)) { - (void)simple_iterator_pop_(iterator); - return false; - } - if(iterator->type != FLAC__METADATA_TYPE_PADDING) { - use_padding = false; - } - else { - if(FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length == extra_padding_bytes_required) { - padding_leftover = 0; - block->is_last = iterator->is_last; - } - else if(iterator->length < extra_padding_bytes_required) - use_padding = false; - else { - padding_leftover = FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length - extra_padding_bytes_required; - padding_is_last = iterator->is_last; - block->is_last = false; - } - } - if(!simple_iterator_pop_(iterator)) - return false; - } - } - if(use_padding) { - if(padding_leftover == 0) { - ret = write_metadata_block_stationary_(iterator, block); - FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); - return ret; - } - else { - FLAC__ASSERT(padding_leftover >= FLAC__STREAM_METADATA_HEADER_LENGTH); - ret = write_metadata_block_stationary_with_padding_(iterator, block, padding_leftover - FLAC__STREAM_METADATA_HEADER_LENGTH, padding_is_last); - FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); - return ret; - } - } - else { - if((ret = rewrite_whole_file_(iterator, block, /*append=*/false))) { - FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); - } - return ret; - } - } -} - -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding) -{ - uint32_t padding_leftover = 0; - FLAC__bool padding_is_last = false; - - FLAC__ASSERT_DECLARATION(FLAC__off_t debug_target_offset = iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length;) - FLAC__bool ret; - - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - FLAC__ASSERT(0 != block); - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - if(!iterator->is_writable) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE; - return false; - } - - if(block->type == FLAC__METADATA_TYPE_STREAMINFO) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT; - return false; - } - - block->is_last = iterator->is_last; - - if(use_padding) { - /* first see if we can even use padding */ - if(iterator->is_last) { - use_padding = false; - } - else { - simple_iterator_push_(iterator); - if(!FLAC__metadata_simple_iterator_next(iterator)) { - (void)simple_iterator_pop_(iterator); - return false; - } - if(iterator->type != FLAC__METADATA_TYPE_PADDING) { - use_padding = false; - } - else { - if(iterator->length == block->length) { - padding_leftover = 0; - block->is_last = iterator->is_last; - } - else if(iterator->length < FLAC__STREAM_METADATA_HEADER_LENGTH + block->length) - use_padding = false; - else { - padding_leftover = iterator->length - block->length; - padding_is_last = iterator->is_last; - block->is_last = false; - } - } - if(!simple_iterator_pop_(iterator)) - return false; - } - } - if(use_padding) { - /* move to the next block, which is suitable padding */ - if(!FLAC__metadata_simple_iterator_next(iterator)) - return false; - if(padding_leftover == 0) { - ret = write_metadata_block_stationary_(iterator, block); - FLAC__ASSERT(iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(ftello(iterator->file) == debug_target_offset + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); - return ret; - } - else { - FLAC__ASSERT(padding_leftover >= FLAC__STREAM_METADATA_HEADER_LENGTH); - ret = write_metadata_block_stationary_with_padding_(iterator, block, padding_leftover - FLAC__STREAM_METADATA_HEADER_LENGTH, padding_is_last); - FLAC__ASSERT(iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(ftello(iterator->file) == debug_target_offset + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); - return ret; - } - } - else { - if((ret = rewrite_whole_file_(iterator, block, /*append=*/true))) { - FLAC__ASSERT(iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(ftello(iterator->file) == debug_target_offset + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); - } - return ret; - } -} - -FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding) -{ - FLAC__ASSERT_DECLARATION(FLAC__off_t debug_target_offset = iterator->offset[iterator->depth];) - FLAC__bool ret; - - FLAC__ASSERT(iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); - - if(!iterator->is_writable) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE; - return false; - } - - if(iterator->type == FLAC__METADATA_TYPE_STREAMINFO) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT; - return false; - } - - if(use_padding) { - FLAC__StreamMetadata *padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING); - if(0 == padding) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - return false; - } - padding->length = iterator->length; - if(!FLAC__metadata_simple_iterator_set_block(iterator, padding, false)) { - FLAC__metadata_object_delete(padding); - return false; - } - FLAC__metadata_object_delete(padding); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return false; - FLAC__ASSERT(iterator->offset[iterator->depth] + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (FLAC__off_t)iterator->length == debug_target_offset); - FLAC__ASSERT(ftello(iterator->file) + (FLAC__off_t)iterator->length == debug_target_offset); - return true; - } - else { - if((ret = rewrite_whole_file_(iterator, 0, /*append=*/false))) { - FLAC__ASSERT(iterator->offset[iterator->depth] + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (FLAC__off_t)iterator->length == debug_target_offset); - FLAC__ASSERT(ftello(iterator->file) + (FLAC__off_t)iterator->length == debug_target_offset); - } - return ret; - } -} - - - -/**************************************************************************** - * - * Level 2 implementation - * - ***************************************************************************/ - - -typedef struct FLAC__Metadata_Node { - FLAC__StreamMetadata *data; - struct FLAC__Metadata_Node *prev, *next; -} FLAC__Metadata_Node; - -struct FLAC__Metadata_Chain { - char *filename; /* will be NULL if using callbacks */ - FLAC__bool is_ogg; - FLAC__Metadata_Node *head; - FLAC__Metadata_Node *tail; - uint32_t nodes; - FLAC__Metadata_ChainStatus status; - FLAC__off_t first_offset, last_offset; - /* - * This is the length of the chain initially read from the FLAC file. - * it is used to compare against the current length to decide whether - * or not the whole file has to be rewritten. - */ - FLAC__off_t initial_length; - /* @@@ hacky, these are currently only needed by ogg reader */ - FLAC__IOHandle handle; - FLAC__IOCallback_Read read_cb; -}; - -struct FLAC__Metadata_Iterator { - FLAC__Metadata_Chain *chain; - FLAC__Metadata_Node *current; -}; - -FLAC_API const char * const FLAC__Metadata_ChainStatusString[] = { - "FLAC__METADATA_CHAIN_STATUS_OK", - "FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT", - "FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE", - "FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE", - "FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE", - "FLAC__METADATA_CHAIN_STATUS_BAD_METADATA", - "FLAC__METADATA_CHAIN_STATUS_READ_ERROR", - "FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR", - "FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR", - "FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR", - "FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR", - "FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR", - "FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR", - "FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS", - "FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH", - "FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL" -}; - - -static FLAC__Metadata_Node *node_new_(void) -{ - return calloc(1, sizeof(FLAC__Metadata_Node)); -} - -static void node_delete_(FLAC__Metadata_Node *node) -{ - FLAC__ASSERT(0 != node); - if(0 != node->data) - FLAC__metadata_object_delete(node->data); - free(node); -} - -static void chain_init_(FLAC__Metadata_Chain *chain) -{ - FLAC__ASSERT(0 != chain); - - chain->filename = 0; - chain->is_ogg = false; - chain->head = chain->tail = 0; - chain->nodes = 0; - chain->status = FLAC__METADATA_CHAIN_STATUS_OK; - chain->initial_length = 0; - chain->read_cb = 0; -} - -static void chain_clear_(FLAC__Metadata_Chain *chain) -{ - FLAC__Metadata_Node *node, *next; - - FLAC__ASSERT(0 != chain); - - for(node = chain->head; node; ) { - next = node->next; - node_delete_(node); - node = next; - } - - if(0 != chain->filename) - free(chain->filename); - - chain_init_(chain); -} - -static void chain_append_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node) -{ - FLAC__ASSERT(0 != chain); - FLAC__ASSERT(0 != node); - FLAC__ASSERT(0 != node->data); - - node->next = node->prev = 0; - node->data->is_last = true; - if(0 != chain->tail) - chain->tail->data->is_last = false; - - if(0 == chain->head) - chain->head = node; - else { - FLAC__ASSERT(0 != chain->tail); - chain->tail->next = node; - node->prev = chain->tail; - } - chain->tail = node; - chain->nodes++; -} - -static void chain_remove_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node) -{ - FLAC__ASSERT(0 != chain); - FLAC__ASSERT(0 != node); - - if(node == chain->head) - chain->head = node->next; - else - node->prev->next = node->next; - - if(node == chain->tail) - chain->tail = node->prev; - else - node->next->prev = node->prev; - - if(0 != chain->tail) - chain->tail->data->is_last = true; - - chain->nodes--; -} - -static void chain_delete_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node) -{ - chain_remove_node_(chain, node); - node_delete_(node); -} - -static FLAC__off_t chain_calculate_length_(FLAC__Metadata_Chain *chain) -{ - const FLAC__Metadata_Node *node; - FLAC__off_t length = 0; - for(node = chain->head; node; node = node->next) - length += (FLAC__STREAM_METADATA_HEADER_LENGTH + node->data->length); - return length; -} - -static void iterator_insert_node_(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Node *node) -{ - FLAC__ASSERT(0 != node); - FLAC__ASSERT(0 != node->data); - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->current); - FLAC__ASSERT(0 != iterator->chain); - FLAC__ASSERT(0 != iterator->chain->head); - FLAC__ASSERT(0 != iterator->chain->tail); - - node->data->is_last = false; - - node->prev = iterator->current->prev; - node->next = iterator->current; - - if(0 == node->prev) - iterator->chain->head = node; - else - node->prev->next = node; - - iterator->current->prev = node; - - iterator->chain->nodes++; -} - -static void iterator_insert_node_after_(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Node *node) -{ - FLAC__ASSERT(0 != node); - FLAC__ASSERT(0 != node->data); - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->current); - FLAC__ASSERT(0 != iterator->chain); - FLAC__ASSERT(0 != iterator->chain->head); - FLAC__ASSERT(0 != iterator->chain->tail); - - iterator->current->data->is_last = false; - - node->prev = iterator->current; - node->next = iterator->current->next; - - if(0 == node->next) - iterator->chain->tail = node; - else - node->next->prev = node; - - node->prev->next = node; - - iterator->chain->tail->data->is_last = true; - - iterator->chain->nodes++; -} - -/* return true iff node and node->next are both padding */ -static FLAC__bool chain_merge_adjacent_padding_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node) -{ - if(node->data->type == FLAC__METADATA_TYPE_PADDING && 0 != node->next && node->next->data->type == FLAC__METADATA_TYPE_PADDING) { - const uint32_t growth = FLAC__STREAM_METADATA_HEADER_LENGTH + node->next->data->length; - node->data->length += growth; /* new block size can be greater than max metadata block size, but it'll be fixed later in chain_prepare_for_write_() */ - - chain_delete_node_(chain, node->next); - return true; - } - else - return false; -} - -#if defined(_MSC_VER) -// silence three MSVC warnings 'conversion from 'conversion from 'const __int64' to 'uint32_t', possible loss of data' -#pragma warning ( disable : 4244 ) -#endif - -/* Returns the new length of the chain, or 0 if there was an error. */ -/* WATCHOUT: This can get called multiple times before a write, so - * it should still work when this happens. - */ -/* WATCHOUT: Make sure to also update the logic in - * FLAC__metadata_chain_check_if_tempfile_needed() if the logic here changes. - */ -static FLAC__off_t chain_prepare_for_write_(FLAC__Metadata_Chain *chain, FLAC__bool use_padding) -{ - FLAC__off_t current_length = chain_calculate_length_(chain); - FLAC__Metadata_Node * i; - - /* Check all is_last settings on the blocks */ - for(i = chain->head; i->next != NULL; i = i->next) - i->data->is_last = 0; - chain->tail->data->is_last = 1; - - if(use_padding) { - /* if the metadata shrank and the last block is padding, we just extend the last padding block */ - if(current_length < chain->initial_length && chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) { - const FLAC__off_t delta = chain->initial_length - current_length; - chain->tail->data->length += delta; - current_length += delta; - FLAC__ASSERT(current_length == chain->initial_length); - } - /* if the metadata shrank more than 4 bytes then there's room to add another padding block */ - else if(current_length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length) { - FLAC__StreamMetadata *padding; - FLAC__Metadata_Node *node; - if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING))) { - chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; - return 0; - } - padding->length = chain->initial_length - (FLAC__STREAM_METADATA_HEADER_LENGTH + current_length); - if(0 == (node = node_new_())) { - FLAC__metadata_object_delete(padding); - chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; - return 0; - } - node->data = padding; - chain_append_node_(chain, node); - current_length = chain_calculate_length_(chain); - FLAC__ASSERT(current_length == chain->initial_length); - } - /* if the metadata grew but the last block is padding, try cutting the padding to restore the original length so we don't have to rewrite the whole file */ - else if(current_length > chain->initial_length) { - const FLAC__off_t delta = current_length - chain->initial_length; - if(chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) { - /* if the delta is exactly the size of the last padding block, remove the padding block */ - if((FLAC__off_t)chain->tail->data->length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH == delta) { - chain_delete_node_(chain, chain->tail); - current_length = chain_calculate_length_(chain); - FLAC__ASSERT(current_length == chain->initial_length); - } - /* if there is at least 'delta' bytes of padding, trim the padding down */ - else if((FLAC__off_t)chain->tail->data->length >= delta) { - chain->tail->data->length -= delta; - current_length -= delta; - FLAC__ASSERT(current_length == chain->initial_length); - } - } - } - } - - /* check sizes of all metadata blocks; reduce padding size if necessary */ - { - FLAC__Metadata_Node *node; - for (node = chain->head; node; node = node->next) { - if(node->data->length >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) { - if(node->data->type == FLAC__METADATA_TYPE_PADDING) { - node->data->length = (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1; - current_length = chain_calculate_length_(chain); - } else { - chain->status = FLAC__METADATA_CHAIN_STATUS_BAD_METADATA; - return 0; - } - } - } - } - - return current_length; -} - -#if defined(_MSC_VER) -#pragma warning ( default : 4244 ) -#endif - -static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__IOCallback_Tell tell_cb) -{ - FLAC__Metadata_Node *node; - - FLAC__ASSERT(0 != chain); - - /* we assume we're already at the beginning of the file */ - - switch(seek_to_first_metadata_block_cb_(handle, read_cb, seek_cb)) { - case 0: - break; - case 1: - chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; - return false; - case 2: - chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; - return false; - case 3: - chain->status = FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE; - return false; - default: - FLAC__ASSERT(0); - return false; - } - - { - FLAC__int64 pos = tell_cb(handle); - if(pos < 0) { - chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; - return false; - } - chain->first_offset = (FLAC__off_t)pos; - } - - { - FLAC__bool is_last; - FLAC__MetadataType type; - uint32_t length; - - do { - node = node_new_(); - if(0 == node) { - chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; - return false; - } - - if(!read_metadata_block_header_cb_(handle, read_cb, &is_last, &type, &length)) { - node_delete_(node); - chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; - return false; - } - - node->data = FLAC__metadata_object_new(type); - if(0 == node->data) { - node_delete_(node); - chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; - return false; - } - - node->data->is_last = is_last; - node->data->length = length; - - chain->status = get_equivalent_status_(read_metadata_block_data_cb_(handle, read_cb, seek_cb, node->data)); - if(chain->status != FLAC__METADATA_CHAIN_STATUS_OK) { - node_delete_(node); - return false; - } - chain_append_node_(chain, node); - } while(!is_last); - } - - { - FLAC__int64 pos = tell_cb(handle); - if(pos < 0) { - chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; - return false; - } - chain->last_offset = (FLAC__off_t)pos; - } - - if(chain->head->data->type != FLAC__METADATA_TYPE_STREAMINFO) { - chain->status = FLAC__METADATA_CHAIN_STATUS_BAD_METADATA; - return false; - } - - chain->initial_length = chain_calculate_length_(chain); - - return true; -} - -static FLAC__StreamDecoderReadStatus chain_read_ogg_read_cb_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data; - (void)decoder; - if(*bytes > 0 && chain->status == FLAC__METADATA_CHAIN_STATUS_OK) { - *bytes = chain->read_cb(buffer, sizeof(FLAC__byte), *bytes, chain->handle); - if(*bytes == 0) - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - else - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - else - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; -} - -static FLAC__StreamDecoderWriteStatus chain_read_ogg_write_cb_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - (void)decoder, (void)frame, (void)buffer, (void)client_data; - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; -} - -static void chain_read_ogg_metadata_cb_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data; - FLAC__Metadata_Node *node; - - (void)decoder; - - node = node_new_(); - if(0 == node) { - chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; - return; - } - - node->data = FLAC__metadata_object_clone(metadata); - if(0 == node->data) { - node_delete_(node); - chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; - return; - } - - chain_append_node_(chain, node); -} - -static void chain_read_ogg_error_cb_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data; - (void)decoder, (void)status; - chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; /*@@@ maybe needs better error code */ -} - -static FLAC__bool chain_read_ogg_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb) -{ - FLAC__StreamDecoder *decoder; - - FLAC__ASSERT(0 != chain); - - /* we assume we're already at the beginning of the file */ - - chain->handle = handle; - chain->read_cb = read_cb; - if(0 == (decoder = FLAC__stream_decoder_new())) { - chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; - return false; - } - FLAC__stream_decoder_set_metadata_respond_all(decoder); - if(FLAC__stream_decoder_init_ogg_stream(decoder, chain_read_ogg_read_cb_, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, /*eof_callback=*/0, chain_read_ogg_write_cb_, chain_read_ogg_metadata_cb_, chain_read_ogg_error_cb_, chain) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - FLAC__stream_decoder_delete(decoder); - chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; /*@@@ maybe needs better error code */ - return false; - } - - chain->first_offset = 0; /*@@@ wrong; will need to be set correctly to implement metadata writing for Ogg FLAC */ - - if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) - chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; /*@@@ maybe needs better error code */ - if(chain->status != FLAC__METADATA_CHAIN_STATUS_OK) { - FLAC__stream_decoder_delete(decoder); - return false; - } - - FLAC__stream_decoder_delete(decoder); - - chain->last_offset = 0; /*@@@ wrong; will need to be set correctly to implement metadata writing for Ogg FLAC */ - - chain->initial_length = chain_calculate_length_(chain); - - if(chain->initial_length == 0 || chain->head->data->type != FLAC__METADATA_TYPE_STREAMINFO) { - /* Ogg FLAC file must have at least streaminfo and vorbis comment */ - chain->status = FLAC__METADATA_CHAIN_STATUS_BAD_METADATA; - return false; - } - - return true; -} - -static FLAC__bool chain_rewrite_metadata_in_place_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, FLAC__IOCallback_Seek seek_cb) -{ - FLAC__Metadata_Node *node; - - FLAC__ASSERT(0 != chain); - FLAC__ASSERT(0 != chain->head); - - if(0 != seek_cb(handle, chain->first_offset, SEEK_SET)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; - return false; - } - - for(node = chain->head; node; node = node->next) { - if(!write_metadata_block_header_cb_(handle, write_cb, node->data)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR; - return false; - } - if(!write_metadata_block_data_cb_(handle, write_cb, node->data)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR; - return false; - } - } - - /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/ - - chain->status = FLAC__METADATA_CHAIN_STATUS_OK; - return true; -} - -static FLAC__bool chain_rewrite_metadata_in_place_(FLAC__Metadata_Chain *chain) -{ - FILE *file; - FLAC__bool ret; - - FLAC__ASSERT(0 != chain->filename); - - if(0 == (file = flac_fopen(chain->filename, "r+b"))) { - chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; - return false; - } - - /* chain_rewrite_metadata_in_place_cb_() sets chain->status for us */ - ret = chain_rewrite_metadata_in_place_cb_(chain, (FLAC__IOHandle)file, (FLAC__IOCallback_Write)fwrite, fseek_wrapper_); - - fclose(file); - - return ret; -} - -static FLAC__bool chain_rewrite_file_(FLAC__Metadata_Chain *chain, const char *tempfile_path_prefix) -{ - FILE *f, *tempfile = NULL; - char *tempfilename; - FLAC__Metadata_SimpleIteratorStatus status; - const FLAC__Metadata_Node *node; - - FLAC__ASSERT(0 != chain); - FLAC__ASSERT(0 != chain->filename); - FLAC__ASSERT(0 != chain->head); - - /* copy the file prefix (data up to first metadata block */ - if(0 == (f = flac_fopen(chain->filename, "rb"))) { - chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; - return false; - } - if(!open_tempfile_(chain->filename, tempfile_path_prefix, &tempfile, &tempfilename, &status)) { - chain->status = get_equivalent_status_(status); - goto err; - } - if(!copy_n_bytes_from_file_(f, tempfile, chain->first_offset, &status)) { - chain->status = get_equivalent_status_(status); - goto err; - } - - /* write the metadata */ - for(node = chain->head; node; node = node->next) { - if(!write_metadata_block_header_(tempfile, &status, node->data)) { - chain->status = get_equivalent_status_(status); - goto err; - } - if(!write_metadata_block_data_(tempfile, &status, node->data)) { - chain->status = get_equivalent_status_(status); - goto err; - } - } - /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/ - - /* copy the file postfix (everything after the metadata) */ - if(0 != fseeko(f, chain->last_offset, SEEK_SET)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; - goto err; - } - if(!copy_remaining_bytes_from_file_(f, tempfile, &status)) { - chain->status = get_equivalent_status_(status); - goto err; - } - - /* move the tempfile on top of the original */ - (void)fclose(f); - if(!transport_tempfile_(chain->filename, &tempfile, &tempfilename, &status)) - return false; - - return true; - -err: - (void)fclose(f); - cleanup_tempfile_(&tempfile, &tempfilename); - return false; -} - -/* assumes 'handle' is already at beginning of file */ -static FLAC__bool chain_rewrite_file_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__IOCallback_Eof eof_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb) -{ - FLAC__Metadata_SimpleIteratorStatus status; - const FLAC__Metadata_Node *node; - - FLAC__ASSERT(0 != chain); - FLAC__ASSERT(0 == chain->filename); - FLAC__ASSERT(0 != chain->head); - - /* copy the file prefix (data up to first metadata block */ - if(!copy_n_bytes_from_file_cb_(handle, read_cb, temp_handle, temp_write_cb, chain->first_offset, &status)) { - chain->status = get_equivalent_status_(status); - return false; - } - - /* write the metadata */ - for(node = chain->head; node; node = node->next) { - if(!write_metadata_block_header_cb_(temp_handle, temp_write_cb, node->data)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR; - return false; - } - if(!write_metadata_block_data_cb_(temp_handle, temp_write_cb, node->data)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR; - return false; - } - } - /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/ - - /* copy the file postfix (everything after the metadata) */ - if(0 != seek_cb(handle, chain->last_offset, SEEK_SET)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; - return false; - } - if(!copy_remaining_bytes_from_file_cb_(handle, read_cb, eof_cb, temp_handle, temp_write_cb, &status)) { - chain->status = get_equivalent_status_(status); - return false; - } - - return true; -} - -FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new(void) -{ - FLAC__Metadata_Chain *chain = calloc(1, sizeof(FLAC__Metadata_Chain)); - - if(0 != chain) - chain_init_(chain); - - return chain; -} - -FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain) -{ - FLAC__ASSERT(0 != chain); - - chain_clear_(chain); - - free(chain); -} - -FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain) -{ - FLAC__Metadata_ChainStatus status; - - FLAC__ASSERT(0 != chain); - - status = chain->status; - chain->status = FLAC__METADATA_CHAIN_STATUS_OK; - return status; -} - -static FLAC__bool chain_read_(FLAC__Metadata_Chain *chain, const char *filename, FLAC__bool is_ogg) -{ - FILE *file; - FLAC__bool ret; - - FLAC__ASSERT(0 != chain); - FLAC__ASSERT(0 != filename); - - chain_clear_(chain); - - if(0 == (chain->filename = strdup(filename))) { - chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; - return false; - } - - chain->is_ogg = is_ogg; - - if(0 == (file = flac_fopen(filename, "rb"))) { - chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; - return false; - } - - /* the function also sets chain->status for us */ - ret = is_ogg? - chain_read_ogg_cb_(chain, file, (FLAC__IOCallback_Read)fread) : - chain_read_cb_(chain, file, (FLAC__IOCallback_Read)fread, fseek_wrapper_, ftell_wrapper_) - ; - - fclose(file); - - return ret; -} - -FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename) -{ - return chain_read_(chain, filename, /*is_ogg=*/false); -} - -/*@@@@add to tests*/ -FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg(FLAC__Metadata_Chain *chain, const char *filename) -{ - return chain_read_(chain, filename, /*is_ogg=*/true); -} - -static FLAC__bool chain_read_with_callbacks_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__bool is_ogg) -{ - FLAC__bool ret; - - FLAC__ASSERT(0 != chain); - - chain_clear_(chain); - - if (0 == callbacks.read || 0 == callbacks.seek || 0 == callbacks.tell) { - chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS; - return false; - } - - chain->is_ogg = is_ogg; - - /* rewind */ - if(0 != callbacks.seek(handle, 0, SEEK_SET)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; - return false; - } - - /* the function also sets chain->status for us */ - ret = is_ogg? - chain_read_ogg_cb_(chain, handle, callbacks.read) : - chain_read_cb_(chain, handle, callbacks.read, callbacks.seek, callbacks.tell) - ; - - return ret; -} - -FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks) -{ - return chain_read_with_callbacks_(chain, handle, callbacks, /*is_ogg=*/false); -} - -/*@@@@add to tests*/ -FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks) -{ - return chain_read_with_callbacks_(chain, handle, callbacks, /*is_ogg=*/true); -} - -typedef enum { - LBS_NONE = 0, - LBS_SIZE_CHANGED, - LBS_BLOCK_ADDED, - LBS_BLOCK_REMOVED -} LastBlockState; - -#if defined(_MSC_VER) -// silence three MSVC warnings 'conversion from 'conversion from 'const __int64' to 'uint32_t', possible loss of data' -#pragma warning ( disable : 4244 ) -#endif - -FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding) -{ - /* This does all the same checks that are in chain_prepare_for_write_() - * but doesn't actually alter the chain. Make sure to update the logic - * here if chain_prepare_for_write_() changes. - */ - FLAC__off_t current_length; - LastBlockState lbs_state = LBS_NONE; - uint32_t lbs_size = 0; - - FLAC__ASSERT(0 != chain); - - current_length = chain_calculate_length_(chain); - - if(use_padding) { - const FLAC__Metadata_Node * const node = chain->tail; - /* if the metadata shrank and the last block is padding, we just extend the last padding block */ - if(current_length < chain->initial_length && node->data->type == FLAC__METADATA_TYPE_PADDING) { - lbs_state = LBS_SIZE_CHANGED; - lbs_size = node->data->length + (chain->initial_length - current_length); - } - /* if the metadata shrank more than 4 bytes then there's room to add another padding block */ - else if(current_length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length) { - lbs_state = LBS_BLOCK_ADDED; - lbs_size = chain->initial_length - (current_length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); - } - /* if the metadata grew but the last block is padding, try cutting the padding to restore the original length so we don't have to rewrite the whole file */ - else if(current_length > chain->initial_length) { - const FLAC__off_t delta = current_length - chain->initial_length; - if(node->data->type == FLAC__METADATA_TYPE_PADDING) { - /* if the delta is exactly the size of the last padding block, remove the padding block */ - if((FLAC__off_t)node->data->length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH == delta) { - lbs_state = LBS_BLOCK_REMOVED; - lbs_size = 0; - } - /* if there is at least 'delta' bytes of padding, trim the padding down */ - else if((FLAC__off_t)node->data->length >= delta) { - lbs_state = LBS_SIZE_CHANGED; - lbs_size = node->data->length - delta; - } - } - } - } - - current_length = 0; - /* check sizes of all metadata blocks; reduce padding size if necessary */ - { - const FLAC__Metadata_Node *node; - for(node = chain->head; node; node = node->next) { - uint32_t block_len = node->data->length; - if(node == chain->tail) { - if(lbs_state == LBS_BLOCK_REMOVED) - continue; - else if(lbs_state == LBS_SIZE_CHANGED) - block_len = lbs_size; - } - if(block_len >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) { - if(node->data->type == FLAC__METADATA_TYPE_PADDING) - block_len = (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1; - else - return false /* the return value doesn't matter */; - } - current_length += (FLAC__STREAM_METADATA_HEADER_LENGTH + block_len); - } - - if(lbs_state == LBS_BLOCK_ADDED) { - /* test added padding block */ - uint32_t block_len = lbs_size; - if(block_len >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) - block_len = (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1; - current_length += (FLAC__STREAM_METADATA_HEADER_LENGTH + block_len); - } - } - - return (current_length != chain->initial_length); -} - -#if defined(_MSC_VER) -#pragma warning ( default : 4244 ) -#endif - -FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats) -{ - struct flac_stat_s stats; - const char *tempfile_path_prefix = 0; - FLAC__off_t current_length; - - FLAC__ASSERT(0 != chain); - - if (chain->is_ogg) { /* cannot write back to Ogg FLAC yet */ - chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; - return false; - } - - if (0 == chain->filename) { - chain->status = FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH; - return false; - } - - current_length = chain_prepare_for_write_(chain, use_padding); - - /* a return value of 0 means there was an error; chain->status is already set */ - if (0 == current_length) - return false; - - if(preserve_file_stats) - get_file_stats_(chain->filename, &stats); - - if(current_length == chain->initial_length) { - if(!chain_rewrite_metadata_in_place_(chain)) - return false; - } - else { - if(!chain_rewrite_file_(chain, tempfile_path_prefix)) - return false; - - /* recompute lengths and offsets */ - { - const FLAC__Metadata_Node *node; - chain->initial_length = current_length; - chain->last_offset = chain->first_offset; - for(node = chain->head; node; node = node->next) - chain->last_offset += (FLAC__STREAM_METADATA_HEADER_LENGTH + node->data->length); - } - } - - if(preserve_file_stats) - set_file_stats_(chain->filename, &stats); - - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks) -{ - FLAC__off_t current_length; - - FLAC__ASSERT(0 != chain); - - if (chain->is_ogg) { /* cannot write back to Ogg FLAC yet */ - chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; - return false; - } - - if (0 != chain->filename) { - chain->status = FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH; - return false; - } - - if (0 == callbacks.write || 0 == callbacks.seek) { - chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS; - return false; - } - - if (FLAC__metadata_chain_check_if_tempfile_needed(chain, use_padding)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL; - return false; - } - - current_length = chain_prepare_for_write_(chain, use_padding); - - /* a return value of 0 means there was an error; chain->status is already set */ - if (0 == current_length) - return false; - - FLAC__ASSERT(current_length == chain->initial_length); - - return chain_rewrite_metadata_in_place_cb_(chain, handle, callbacks.write, callbacks.seek); -} - -FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__IOHandle temp_handle, FLAC__IOCallbacks temp_callbacks) -{ - FLAC__off_t current_length; - - FLAC__ASSERT(0 != chain); - - if (chain->is_ogg) { /* cannot write back to Ogg FLAC yet */ - chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; - return false; - } - - if (0 != chain->filename) { - chain->status = FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH; - return false; - } - - if (0 == callbacks.read || 0 == callbacks.seek || 0 == callbacks.eof) { - chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS; - return false; - } - if (0 == temp_callbacks.write) { - chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS; - return false; - } - - if (!FLAC__metadata_chain_check_if_tempfile_needed(chain, use_padding)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL; - return false; - } - - current_length = chain_prepare_for_write_(chain, use_padding); - - /* a return value of 0 means there was an error; chain->status is already set */ - if (0 == current_length) - return false; - - FLAC__ASSERT(current_length != chain->initial_length); - - /* rewind */ - if(0 != callbacks.seek(handle, 0, SEEK_SET)) { - chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; - return false; - } - - if(!chain_rewrite_file_cb_(chain, handle, callbacks.read, callbacks.seek, callbacks.eof, temp_handle, temp_callbacks.write)) - return false; - - /* recompute lengths and offsets */ - { - const FLAC__Metadata_Node *node; - chain->initial_length = current_length; - chain->last_offset = chain->first_offset; - for(node = chain->head; node; node = node->next) - chain->last_offset += (FLAC__STREAM_METADATA_HEADER_LENGTH + node->data->length); - } - - return true; -} - -FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain) -{ - FLAC__Metadata_Node *node; - - FLAC__ASSERT(0 != chain); - - for(node = chain->head; node; ) { - if(!chain_merge_adjacent_padding_(chain, node)) - node = node->next; - } -} - -FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain) -{ - FLAC__Metadata_Node *node, *save; - uint32_t i; - - FLAC__ASSERT(0 != chain); - - /* - * Don't try and be too smart... this simple algo is good enough for - * the small number of nodes that we deal with. - */ - for(i = 0, node = chain->head; i < chain->nodes; i++) { - if(node->data->type == FLAC__METADATA_TYPE_PADDING) { - save = node->next; - chain_remove_node_(chain, node); - chain_append_node_(chain, node); - node = save; - } - else { - node = node->next; - } - } - - FLAC__metadata_chain_merge_padding(chain); -} - - -FLAC_API FLAC__Metadata_Iterator *FLAC__metadata_iterator_new(void) -{ - FLAC__Metadata_Iterator *iterator = calloc(1, sizeof(FLAC__Metadata_Iterator)); - - /* calloc() implies: - iterator->current = 0; - iterator->chain = 0; - */ - - return iterator; -} - -FLAC_API void FLAC__metadata_iterator_delete(FLAC__Metadata_Iterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - - free(iterator); -} - -FLAC_API void FLAC__metadata_iterator_init(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != chain); - FLAC__ASSERT(0 != chain->head); - - iterator->chain = chain; - iterator->current = chain->head; -} - -FLAC_API FLAC__bool FLAC__metadata_iterator_next(FLAC__Metadata_Iterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - - if(0 == iterator->current || 0 == iterator->current->next) - return false; - - iterator->current = iterator->current->next; - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_iterator_prev(FLAC__Metadata_Iterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - - if(0 == iterator->current || 0 == iterator->current->prev) - return false; - - iterator->current = iterator->current->prev; - return true; -} - -FLAC_API FLAC__MetadataType FLAC__metadata_iterator_get_block_type(const FLAC__Metadata_Iterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->current); - FLAC__ASSERT(0 != iterator->current->data); - - return iterator->current->data->type; -} - -FLAC_API FLAC__StreamMetadata *FLAC__metadata_iterator_get_block(FLAC__Metadata_Iterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->current); - - return iterator->current->data; -} - -FLAC_API FLAC__bool FLAC__metadata_iterator_set_block(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != block); - return FLAC__metadata_iterator_delete_block(iterator, false) && FLAC__metadata_iterator_insert_block_after(iterator, block); -} - -FLAC_API FLAC__bool FLAC__metadata_iterator_delete_block(FLAC__Metadata_Iterator *iterator, FLAC__bool replace_with_padding) -{ - FLAC__Metadata_Node *save; - - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->current); - - if(0 == iterator->current->prev) { - FLAC__ASSERT(iterator->current->data->type == FLAC__METADATA_TYPE_STREAMINFO); - return false; - } - - save = iterator->current->prev; - - if(replace_with_padding) { - FLAC__metadata_object_delete_data(iterator->current->data); - iterator->current->data->type = FLAC__METADATA_TYPE_PADDING; - } - else { - chain_delete_node_(iterator->chain, iterator->current); - } - - iterator->current = save; - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_before(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block) -{ - FLAC__Metadata_Node *node; - - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->current); - FLAC__ASSERT(0 != block); - - if(block->type == FLAC__METADATA_TYPE_STREAMINFO) - return false; - - if(0 == iterator->current->prev) { - FLAC__ASSERT(iterator->current->data->type == FLAC__METADATA_TYPE_STREAMINFO); - return false; - } - - if(0 == (node = node_new_())) - return false; - - node->data = block; - iterator_insert_node_(iterator, node); - iterator->current = node; - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block) -{ - FLAC__Metadata_Node *node; - - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->current); - FLAC__ASSERT(0 != block); - - if(block->type == FLAC__METADATA_TYPE_STREAMINFO) - return false; - - if(0 == (node = node_new_())) - return false; - - node->data = block; - iterator_insert_node_after_(iterator, node); - iterator->current = node; - return true; -} - - -/**************************************************************************** - * - * Local function definitions - * - ***************************************************************************/ - -void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes) -{ - uint32_t i; - - b += bytes; - - for(i = 0; i < bytes; i++) { - *(--b) = (FLAC__byte)(val & 0xff); - val >>= 8; - } -} - -void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes) -{ - uint32_t i; - - for(i = 0; i < bytes; i++) { - *(b++) = (FLAC__byte)(val & 0xff); - val >>= 8; - } -} - -void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, uint32_t bytes) -{ - uint32_t i; - - b += bytes; - - for(i = 0; i < bytes; i++) { - *(--b) = (FLAC__byte)(val & 0xff); - val >>= 8; - } -} - -FLAC__uint32 unpack_uint32_(FLAC__byte *b, uint32_t bytes) -{ - FLAC__uint32 ret = 0; - uint32_t i; - - for(i = 0; i < bytes; i++) - ret = (ret << 8) | (FLAC__uint32)(*b++); - - return ret; -} - -FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, uint32_t bytes) -{ - FLAC__uint32 ret = 0; - uint32_t i; - - b += bytes; - - for(i = 0; i < bytes; i++) - ret = (ret << 8) | (FLAC__uint32)(*--b); - - return ret; -} - -FLAC__uint64 unpack_uint64_(FLAC__byte *b, uint32_t bytes) -{ - FLAC__uint64 ret = 0; - uint32_t i; - - for(i = 0; i < bytes; i++) - ret = (ret << 8) | (FLAC__uint64)(*b++); - - return ret; -} - -FLAC__bool read_metadata_block_header_(FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - - if(!read_metadata_block_header_cb_((FLAC__IOHandle)iterator->file, (FLAC__IOCallback_Read)fread, &iterator->is_last, &iterator->type, &iterator->length)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - return false; - } - - return true; -} - -FLAC__bool read_metadata_block_data_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block) -{ - FLAC__ASSERT(0 != iterator); - FLAC__ASSERT(0 != iterator->file); - - iterator->status = read_metadata_block_data_cb_((FLAC__IOHandle)iterator->file, (FLAC__IOCallback_Read)fread, fseek_wrapper_, block); - - return (iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); -} - -FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, uint32_t *length) -{ - FLAC__byte raw_header[FLAC__STREAM_METADATA_HEADER_LENGTH]; - - if(read_cb(raw_header, 1, FLAC__STREAM_METADATA_HEADER_LENGTH, handle) != FLAC__STREAM_METADATA_HEADER_LENGTH) - return false; - - *is_last = raw_header[0] & 0x80? true : false; - *type = (FLAC__MetadataType)(raw_header[0] & 0x7f); - *length = unpack_uint32_(raw_header + 1, 3); - - /* Note that we don't check: - * if(iterator->type >= FLAC__METADATA_TYPE_UNDEFINED) - * we just will read in an opaque block - */ - - return true; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata *block) -{ - switch(block->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - return read_metadata_block_data_streaminfo_cb_(handle, read_cb, &block->data.stream_info); - case FLAC__METADATA_TYPE_PADDING: - return read_metadata_block_data_padding_cb_(handle, seek_cb, &block->data.padding, block->length); - case FLAC__METADATA_TYPE_APPLICATION: - return read_metadata_block_data_application_cb_(handle, read_cb, &block->data.application, block->length); - case FLAC__METADATA_TYPE_SEEKTABLE: - return read_metadata_block_data_seektable_cb_(handle, read_cb, &block->data.seek_table, block->length); - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - return read_metadata_block_data_vorbis_comment_cb_(handle, read_cb, seek_cb, &block->data.vorbis_comment, block->length); - case FLAC__METADATA_TYPE_CUESHEET: - return read_metadata_block_data_cuesheet_cb_(handle, read_cb, &block->data.cue_sheet); - case FLAC__METADATA_TYPE_PICTURE: - return read_metadata_block_data_picture_cb_(handle, read_cb, &block->data.picture); - default: - return read_metadata_block_data_unknown_cb_(handle, read_cb, &block->data.unknown, block->length); - } -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_StreamInfo *block) -{ - FLAC__byte buffer[FLAC__STREAM_METADATA_STREAMINFO_LENGTH], *b; - - if(read_cb(buffer, 1, FLAC__STREAM_METADATA_STREAMINFO_LENGTH, handle) != FLAC__STREAM_METADATA_STREAMINFO_LENGTH) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - - b = buffer; - - /* we are using hardcoded numbers for simplicity but we should - * probably eventually write a bit-level unpacker and use the - * _STREAMINFO_ constants. - */ - block->min_blocksize = unpack_uint32_(b, 2); b += 2; - block->max_blocksize = unpack_uint32_(b, 2); b += 2; - block->min_framesize = unpack_uint32_(b, 3); b += 3; - block->max_framesize = unpack_uint32_(b, 3); b += 3; - block->sample_rate = (unpack_uint32_(b, 2) << 4) | ((uint32_t)(b[2] & 0xf0) >> 4); - block->channels = (uint32_t)((b[2] & 0x0e) >> 1) + 1; - block->bits_per_sample = ((((uint32_t)(b[2] & 0x01)) << 4) | (((uint32_t)(b[3] & 0xf0)) >> 4)) + 1; - block->total_samples = (((FLAC__uint64)(b[3] & 0x0f)) << 32) | unpack_uint64_(b+4, 4); - memcpy(block->md5sum, b+8, 16); - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, uint32_t block_length) -{ - (void)block; /* nothing to do; we don't care about reading the padding bytes */ - - if(0 != seek_cb(handle, block_length, SEEK_CUR)) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, uint32_t block_length) -{ - const uint32_t id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; - - if(read_cb(block->id, 1, id_bytes, handle) != id_bytes) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - - if(block_length < id_bytes) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - - block_length -= id_bytes; - - if(block_length == 0) { - block->data = 0; - } - else { - if(0 == (block->data = malloc(block_length))) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - - if(read_cb(block->data, 1, block_length, handle) != block_length) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - } - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, uint32_t block_length) -{ - uint32_t i; - FLAC__byte buffer[FLAC__STREAM_METADATA_SEEKPOINT_LENGTH]; - - if(block_length % FLAC__STREAM_METADATA_SEEKPOINT_LENGTH != 0) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA; - - block->num_points = block_length / FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; - - if(block->num_points == 0) - block->points = 0; - else if(0 == (block->points = safe_malloc_mul_2op_p(block->num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint)))) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - - for(i = 0; i < block->num_points; i++) { - if(read_cb(buffer, 1, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH, handle) != FLAC__STREAM_METADATA_SEEKPOINT_LENGTH) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - /* some MAGIC NUMBERs here */ - block->points[i].sample_number = unpack_uint64_(buffer, 8); - block->points[i].stream_offset = unpack_uint64_(buffer+8, 8); - block->points[i].frame_samples = unpack_uint32_(buffer+16, 2); - } - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, uint32_t max_length) -{ - const uint32_t entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8; - FLAC__byte buffer[4]; /* magic number is asserted below */ - - FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8 == sizeof(buffer)); - - if(max_length < entry_length_len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA; - - max_length -= entry_length_len; - if(read_cb(buffer, 1, entry_length_len, handle) != entry_length_len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - entry->length = unpack_uint32_little_endian_(buffer, entry_length_len); - if(max_length < entry->length) { - entry->length = 0; - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA; - } - - if(0 != entry->entry) - free(entry->entry); - - if(0 == (entry->entry = safe_malloc_add_2op_(entry->length, /*+*/1))) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - - if(entry->length > 0 && read_cb(entry->entry, 1, entry->length, handle) != entry->length) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - - entry->entry[entry->length] = '\0'; - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, uint32_t block_length) -{ - uint32_t i; - FLAC__Metadata_SimpleIteratorStatus status; - const uint32_t num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8; - FLAC__byte buffer[4]; /* magic number is asserted below */ - - FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8 == sizeof(buffer)); - - status = read_metadata_block_data_vorbis_comment_entry_cb_(handle, read_cb, &(block->vendor_string), block_length); - if(block_length >= 4) - block_length -= 4; - if(status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA) - goto skip; - else if(status != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK) - return status; - block_length -= block->vendor_string.length; - - if(block_length < num_comments_len) goto skip; else block_length -= num_comments_len; - if(read_cb(buffer, 1, num_comments_len, handle) != num_comments_len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - block->num_comments = unpack_uint32_little_endian_(buffer, num_comments_len); - - if(block->num_comments == 0) { - block->comments = 0; - } - else if(block->num_comments > (block_length >> 2)) { /* each comment needs at least 4 byte */ - block->num_comments = 0; - status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA; - goto skip; - } - else if(0 == (block->comments = calloc(block->num_comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) { - block->num_comments = 0; - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - } - - for(i = 0; i < block->num_comments; i++) { - status = read_metadata_block_data_vorbis_comment_entry_cb_(handle, read_cb, block->comments + i, block_length); - if(block_length >= 4) block_length -= 4; - if(status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA) { - block->num_comments = i; - goto skip; - } - else if(status != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK) return status; - block_length -= block->comments[i].length; - } - - skip: - if(block_length > 0) { - /* bad metadata */ - if(0 != seek_cb(handle, block_length, SEEK_CUR)) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - } - - return status; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet_Track *track) -{ - uint32_t i, len; - FLAC__byte buffer[32]; /* asserted below that this is big enough */ - - FLAC__ASSERT(sizeof(buffer) >= sizeof(FLAC__uint64)); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) / 8); - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - track->offset = unpack_uint64_(buffer, len); - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - track->number = (FLAC__byte)unpack_uint32_(buffer, len); - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN / 8; - if(read_cb(track->isrc, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - - FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) % 8 == 0); - len = (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN == 1); - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN == 1); - track->type = buffer[0] >> 7; - track->pre_emphasis = (buffer[0] >> 6) & 1; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - track->num_indices = (FLAC__byte)unpack_uint32_(buffer, len); - - if(track->num_indices == 0) { - track->indices = 0; - } - else if(0 == (track->indices = calloc(track->num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)))) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - - for(i = 0; i < track->num_indices; i++) { - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - track->indices[i].offset = unpack_uint64_(buffer, len); - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - track->indices[i].number = (FLAC__byte)unpack_uint32_(buffer, len); - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - } - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet *block) -{ - uint32_t i, len; - FLAC__Metadata_SimpleIteratorStatus status; - FLAC__byte buffer[1024]; /* MSVC needs a constant expression so we put a magic number and assert */ - - FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN)/8 <= sizeof(buffer)); - FLAC__ASSERT(sizeof(FLAC__uint64) <= sizeof(buffer)); - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN / 8; - if(read_cb(block->media_catalog_number, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - block->lead_in = unpack_uint64_(buffer, len); - - FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) % 8 == 0); - len = (FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - block->is_cd = buffer[0]&0x80? true : false; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - block->num_tracks = unpack_uint32_(buffer, len); - - if(block->num_tracks == 0) { - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA; - } - else if(0 == (block->tracks = calloc(block->num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)))) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - - for(i = 0; i < block->num_tracks; i++) { - if(FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK != (status = read_metadata_block_data_cuesheet_track_cb_(handle, read_cb, block->tracks + i))) - return status; - } - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cstring_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__byte **data, FLAC__uint32 *length, FLAC__uint32 length_len) -{ - FLAC__byte buffer[sizeof(FLAC__uint32)]; - - FLAC__ASSERT(0 != data); - FLAC__ASSERT(length_len%8 == 0); - - length_len /= 8; /* convert to bytes */ - - FLAC__ASSERT(sizeof(buffer) >= length_len); - - if(read_cb(buffer, 1, length_len, handle) != length_len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - *length = unpack_uint32_(buffer, length_len); - - if(*length > (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) /* data cannot be larger than FLAC metadata block */ - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA; - - if(0 != *data) - free(*data); - - if(0 == (*data = safe_malloc_add_2op_(*length, /*+*/1))) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - - if(*length > 0) { - if(read_cb(*data, 1, *length, handle) != *length) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - } - - (*data)[*length] = '\0'; - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Picture *block) -{ - FLAC__Metadata_SimpleIteratorStatus status; - FLAC__byte buffer[4]; /* asserted below that this is big enough */ - FLAC__uint32 len; - - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_TYPE_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_COLORS_LEN/8); - - FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_TYPE_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_PICTURE_TYPE_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - block->type = (FLAC__StreamMetadata_Picture_Type)unpack_uint32_(buffer, len); - - if((status = read_metadata_block_data_picture_cstring_cb_(handle, read_cb, (FLAC__byte**)(&(block->mime_type)), &len, FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN)) != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK) - return status; - - if((status = read_metadata_block_data_picture_cstring_cb_(handle, read_cb, &(block->description), &len, FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN)) != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK) - return status; - - FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - block->width = unpack_uint32_(buffer, len); - - FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - block->height = unpack_uint32_(buffer, len); - - FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - block->depth = unpack_uint32_(buffer, len); - - FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_COLORS_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_PICTURE_COLORS_LEN / 8; - if(read_cb(buffer, 1, len, handle) != len) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - block->colors = unpack_uint32_(buffer, len); - - /* for convenience we use read_metadata_block_data_picture_cstring_cb_() even though it adds an extra terminating NUL we don't use */ - if((status = read_metadata_block_data_picture_cstring_cb_(handle, read_cb, &(block->data), &(block->data_length), FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN)) != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK) - return status; - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, uint32_t block_length) -{ - if(block_length == 0) { - block->data = 0; - } - else { - if(0 == (block->data = malloc(block_length))) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - - if(read_cb(block->data, 1, block_length, handle) != block_length) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - } - - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; -} - -FLAC__bool write_metadata_block_header_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block) -{ - FLAC__ASSERT(0 != file); - FLAC__ASSERT(0 != status); - - if(!write_metadata_block_header_cb_((FLAC__IOHandle)file, (FLAC__IOCallback_Write)fwrite, block)) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR; - return false; - } - - return true; -} - -FLAC__bool write_metadata_block_data_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block) -{ - FLAC__ASSERT(0 != file); - FLAC__ASSERT(0 != status); - - if (write_metadata_block_data_cb_((FLAC__IOHandle)file, (FLAC__IOCallback_Write)fwrite, block)) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; - return true; - } - else { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR; - return false; - } -} - -FLAC__bool write_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block) -{ - FLAC__byte buffer[FLAC__STREAM_METADATA_HEADER_LENGTH]; - - FLAC__ASSERT(block->length < (1u << FLAC__STREAM_METADATA_LENGTH_LEN)); - /* double protection */ - if(block->length >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) - return false; - - buffer[0] = (block->is_last? 0x80 : 0) | (FLAC__byte)block->type; - pack_uint32_(block->length, buffer + 1, 3); - - if(write_cb(buffer, 1, FLAC__STREAM_METADATA_HEADER_LENGTH, handle) != FLAC__STREAM_METADATA_HEADER_LENGTH) - return false; - - return true; -} - -FLAC__bool write_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block) -{ - FLAC__ASSERT(0 != block); - - switch(block->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - return write_metadata_block_data_streaminfo_cb_(handle, write_cb, &block->data.stream_info); - case FLAC__METADATA_TYPE_PADDING: - return write_metadata_block_data_padding_cb_(handle, write_cb, &block->data.padding, block->length); - case FLAC__METADATA_TYPE_APPLICATION: - return write_metadata_block_data_application_cb_(handle, write_cb, &block->data.application, block->length); - case FLAC__METADATA_TYPE_SEEKTABLE: - return write_metadata_block_data_seektable_cb_(handle, write_cb, &block->data.seek_table); - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - return write_metadata_block_data_vorbis_comment_cb_(handle, write_cb, &block->data.vorbis_comment); - case FLAC__METADATA_TYPE_CUESHEET: - return write_metadata_block_data_cuesheet_cb_(handle, write_cb, &block->data.cue_sheet); - case FLAC__METADATA_TYPE_PICTURE: - return write_metadata_block_data_picture_cb_(handle, write_cb, &block->data.picture); - default: - return write_metadata_block_data_unknown_cb_(handle, write_cb, &block->data.unknown, block->length); - } -} - -FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_StreamInfo *block) -{ - FLAC__byte buffer[FLAC__STREAM_METADATA_STREAMINFO_LENGTH]; - const uint32_t channels1 = block->channels - 1; - const uint32_t bps1 = block->bits_per_sample - 1; - - /* we are using hardcoded numbers for simplicity but we should - * probably eventually write a bit-level packer and use the - * _STREAMINFO_ constants. - */ - pack_uint32_(block->min_blocksize, buffer, 2); - pack_uint32_(block->max_blocksize, buffer+2, 2); - pack_uint32_(block->min_framesize, buffer+4, 3); - pack_uint32_(block->max_framesize, buffer+7, 3); - buffer[10] = (block->sample_rate >> 12) & 0xff; - buffer[11] = (block->sample_rate >> 4) & 0xff; - buffer[12] = ((block->sample_rate & 0x0f) << 4) | (channels1 << 1) | (bps1 >> 4); - buffer[13] = (FLAC__byte)(((bps1 & 0x0f) << 4) | ((block->total_samples >> 32) & 0x0f)); - pack_uint32_((FLAC__uint32)block->total_samples, buffer+14, 4); - memcpy(buffer+18, block->md5sum, 16); - - if(write_cb(buffer, 1, FLAC__STREAM_METADATA_STREAMINFO_LENGTH, handle) != FLAC__STREAM_METADATA_STREAMINFO_LENGTH) - return false; - - return true; -} - -FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, uint32_t block_length) -{ - uint32_t i, n = block_length; - FLAC__byte buffer[1024]; - - (void)block; - - memset(buffer, 0, 1024); - - for(i = 0; i < n/1024; i++) - if(write_cb(buffer, 1, 1024, handle) != 1024) - return false; - - n %= 1024; - - if(write_cb(buffer, 1, n, handle) != n) - return false; - - return true; -} - -FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, uint32_t block_length) -{ - const uint32_t id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; - - if(write_cb(block->id, 1, id_bytes, handle) != id_bytes) - return false; - - block_length -= id_bytes; - - if(write_cb(block->data, 1, block_length, handle) != block_length) - return false; - - return true; -} - -FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_SeekTable *block) -{ - uint32_t i; - FLAC__byte buffer[FLAC__STREAM_METADATA_SEEKPOINT_LENGTH]; - - for(i = 0; i < block->num_points; i++) { - /* some MAGIC NUMBERs here */ - pack_uint64_(block->points[i].sample_number, buffer, 8); - pack_uint64_(block->points[i].stream_offset, buffer+8, 8); - pack_uint32_(block->points[i].frame_samples, buffer+16, 2); - if(write_cb(buffer, 1, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH, handle) != FLAC__STREAM_METADATA_SEEKPOINT_LENGTH) - return false; - } - - return true; -} - -FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_VorbisComment *block) -{ - uint32_t i; - const uint32_t entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8; - const uint32_t num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8; - FLAC__byte buffer[4]; /* magic number is asserted below */ - - FLAC__ASSERT(flac_max(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN, FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN) / 8 == sizeof(buffer)); - - pack_uint32_little_endian_(block->vendor_string.length, buffer, entry_length_len); - if(write_cb(buffer, 1, entry_length_len, handle) != entry_length_len) - return false; - if(write_cb(block->vendor_string.entry, 1, block->vendor_string.length, handle) != block->vendor_string.length) - return false; - - pack_uint32_little_endian_(block->num_comments, buffer, num_comments_len); - if(write_cb(buffer, 1, num_comments_len, handle) != num_comments_len) - return false; - - for(i = 0; i < block->num_comments; i++) { - pack_uint32_little_endian_(block->comments[i].length, buffer, entry_length_len); - if(write_cb(buffer, 1, entry_length_len, handle) != entry_length_len) - return false; - if(write_cb(block->comments[i].entry, 1, block->comments[i].length, handle) != block->comments[i].length) - return false; - } - - return true; -} - -FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_CueSheet *block) -{ - uint32_t i, j, len; - FLAC__byte buffer[1024]; /* asserted below that this is big enough */ - - FLAC__ASSERT(sizeof(buffer) >= sizeof(FLAC__uint64)); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN)/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN/8); - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN / 8; - if(write_cb(block->media_catalog_number, 1, len, handle) != len) - return false; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN / 8; - pack_uint64_(block->lead_in, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) % 8 == 0); - len = (FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) / 8; - memset(buffer, 0, len); - if(block->is_cd) - buffer[0] |= 0x80; - if(write_cb(buffer, 1, len, handle) != len) - return false; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN / 8; - pack_uint32_(block->num_tracks, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - for(i = 0; i < block->num_tracks; i++) { - FLAC__StreamMetadata_CueSheet_Track *track = block->tracks + i; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN / 8; - pack_uint64_(track->offset, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN / 8; - pack_uint32_(track->number, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN / 8; - if(write_cb(track->isrc, 1, len, handle) != len) - return false; - - FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) % 8 == 0); - len = (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) / 8; - memset(buffer, 0, len); - buffer[0] = (track->type << 7) | (track->pre_emphasis << 6); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN / 8; - pack_uint32_(track->num_indices, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - for(j = 0; j < track->num_indices; j++) { - FLAC__StreamMetadata_CueSheet_Index *indx = track->indices + j; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN / 8; - pack_uint64_(indx->offset, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN / 8; - pack_uint32_(indx->number, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN % 8 == 0); - len = FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN / 8; - memset(buffer, 0, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - } - } - - return true; -} - -FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Picture *block) -{ - uint32_t len; - size_t slen; - FLAC__byte buffer[4]; /* magic number is asserted below */ - - FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_TYPE_LEN%8); - FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN%8); - FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN%8); - FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN%8); - FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN%8); - FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN%8); - FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_COLORS_LEN%8); - FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN%8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_TYPE_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_COLORS_LEN/8); - FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN/8); - - len = FLAC__STREAM_METADATA_PICTURE_TYPE_LEN/8; - pack_uint32_(block->type, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - len = FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN/8; - slen = strlen(block->mime_type); - pack_uint32_(slen, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - if(write_cb(block->mime_type, 1, slen, handle) != slen) - return false; - - len = FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN/8; - slen = strlen((const char *)block->description); - pack_uint32_(slen, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - if(write_cb(block->description, 1, slen, handle) != slen) - return false; - - len = FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN/8; - pack_uint32_(block->width, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - len = FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN/8; - pack_uint32_(block->height, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - len = FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN/8; - pack_uint32_(block->depth, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - len = FLAC__STREAM_METADATA_PICTURE_COLORS_LEN/8; - pack_uint32_(block->colors, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - - len = FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN/8; - pack_uint32_(block->data_length, buffer, len); - if(write_cb(buffer, 1, len, handle) != len) - return false; - if(write_cb(block->data, 1, block->data_length, handle) != block->data_length) - return false; - - return true; -} - -FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, uint32_t block_length) -{ - if(write_cb(block->data, 1, block_length, handle) != block_length) - return false; - - return true; -} - -FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *iterator, const FLAC__StreamMetadata *block) -{ - if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - - if(!write_metadata_block_header_(iterator->file, &iterator->status, block)) - return false; - - if(!write_metadata_block_data_(iterator->file, &iterator->status, block)) - return false; - - if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - - return read_metadata_block_header_(iterator); -} - -FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, uint32_t padding_length, FLAC__bool padding_is_last) -{ - FLAC__StreamMetadata *padding; - - if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - - block->is_last = false; - - if(!write_metadata_block_header_(iterator->file, &iterator->status, block)) - return false; - - if(!write_metadata_block_data_(iterator->file, &iterator->status, block)) - return false; - - if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING))) - return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - - padding->is_last = padding_is_last; - padding->length = padding_length; - - if(!write_metadata_block_header_(iterator->file, &iterator->status, padding)) { - FLAC__metadata_object_delete(padding); - return false; - } - - if(!write_metadata_block_data_(iterator->file, &iterator->status, padding)) { - FLAC__metadata_object_delete(padding); - return false; - } - - FLAC__metadata_object_delete(padding); - - if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - - return read_metadata_block_header_(iterator); -} - -FLAC__bool rewrite_whole_file_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool append) -{ - FILE *tempfile = NULL; - char *tempfilename = NULL; - int fixup_is_last_code = 0; /* 0 => no need to change any is_last flags */ - FLAC__off_t fixup_is_last_flag_offset = -1; - - FLAC__ASSERT(0 != block || append == false); - - if(iterator->is_last) { - if(append) { - fixup_is_last_code = 1; /* 1 => clear the is_last flag at the following offset */ - fixup_is_last_flag_offset = iterator->offset[iterator->depth]; - } - else if(0 == block) { - simple_iterator_push_(iterator); - if(!FLAC__metadata_simple_iterator_prev(iterator)) { - (void)simple_iterator_pop_(iterator); - return false; - } - fixup_is_last_code = -1; /* -1 => set the is_last the flag at the following offset */ - fixup_is_last_flag_offset = iterator->offset[iterator->depth]; - if(!simple_iterator_pop_(iterator)) - return false; - } - } - - if(!simple_iterator_copy_file_prefix_(iterator, &tempfile, &tempfilename, append)) - return false; - - if(0 != block) { - if(!write_metadata_block_header_(tempfile, &iterator->status, block)) { - cleanup_tempfile_(&tempfile, &tempfilename); - return false; - } - - if(!write_metadata_block_data_(tempfile, &iterator->status, block)) { - cleanup_tempfile_(&tempfile, &tempfilename); - return false; - } - } - - if(!simple_iterator_copy_file_postfix_(iterator, &tempfile, &tempfilename, fixup_is_last_code, fixup_is_last_flag_offset, block==0)) - return false; - - if(append) - return FLAC__metadata_simple_iterator_next(iterator); - - return true; -} - -void simple_iterator_push_(FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(iterator->depth+1 < SIMPLE_ITERATOR_MAX_PUSH_DEPTH); - iterator->offset[iterator->depth+1] = iterator->offset[iterator->depth]; - iterator->depth++; -} - -FLAC__bool simple_iterator_pop_(FLAC__Metadata_SimpleIterator *iterator) -{ - FLAC__ASSERT(iterator->depth > 0); - iterator->depth--; - if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - - return read_metadata_block_header_(iterator); -} - -/* return meanings: - * 0: ok - * 1: read error - * 2: seek error - * 3: not a FLAC file - */ -uint32_t seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb) -{ - FLAC__byte buffer[4]; - size_t n; - uint32_t i; - - FLAC__ASSERT(FLAC__STREAM_SYNC_LENGTH == sizeof(buffer)); - - /* skip any id3v2 tag */ - errno = 0; - n = read_cb(buffer, 1, 4, handle); - if(errno) - return 1; - else if(n != 4) - return 3; - else if(0 == memcmp(buffer, "ID3", 3)) { - uint32_t tag_length = 0; - - /* skip to the tag length */ - if(seek_cb(handle, 2, SEEK_CUR) < 0) - return 2; - - /* read the length */ - for(i = 0; i < 4; i++) { - if(read_cb(buffer, 1, 1, handle) < 1 || buffer[0] & 0x80) - return 1; - tag_length <<= 7; - tag_length |= (buffer[0] & 0x7f); - } - - /* skip the rest of the tag */ - if(seek_cb(handle, tag_length, SEEK_CUR) < 0) - return 2; - - /* read the stream sync code */ - errno = 0; - n = read_cb(buffer, 1, 4, handle); - if(errno) - return 1; - else if(n != 4) - return 3; - } - - /* check for the fLaC signature */ - if(0 == memcmp(FLAC__STREAM_SYNC_STRING, buffer, FLAC__STREAM_SYNC_LENGTH)) - return 0; - else - return 3; -} - -uint32_t seek_to_first_metadata_block_(FILE *f) -{ - return seek_to_first_metadata_block_cb_((FLAC__IOHandle)f, (FLAC__IOCallback_Read)fread, fseek_wrapper_); -} - -FLAC__bool simple_iterator_copy_file_prefix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, FLAC__bool append) -{ - const FLAC__off_t offset_end = append? iterator->offset[iterator->depth] + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (FLAC__off_t)iterator->length : iterator->offset[iterator->depth]; - - if(0 != fseeko(iterator->file, 0, SEEK_SET)) { - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - if(!open_tempfile_(iterator->filename, iterator->tempfile_path_prefix, tempfile, tempfilename, &iterator->status)) { - cleanup_tempfile_(tempfile, tempfilename); - return false; - } - if(!copy_n_bytes_from_file_(iterator->file, *tempfile, offset_end, &iterator->status)) { - cleanup_tempfile_(tempfile, tempfilename); - return false; - } - - return true; -} - -FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, FLAC__off_t fixup_is_last_flag_offset, FLAC__bool backup) -{ - FLAC__off_t save_offset = iterator->offset[iterator->depth]; - FLAC__ASSERT(0 != *tempfile); - - if(0 != fseeko(iterator->file, save_offset + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (FLAC__off_t)iterator->length, SEEK_SET)) { - cleanup_tempfile_(tempfile, tempfilename); - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - if(!copy_remaining_bytes_from_file_(iterator->file, *tempfile, &iterator->status)) { - cleanup_tempfile_(tempfile, tempfilename); - return false; - } - - if(fixup_is_last_code != 0) { - /* - * if code == 1, it means a block was appended to the end so - * we have to clear the is_last flag of the previous block - * if code == -1, it means the last block was deleted so - * we have to set the is_last flag of the previous block - */ - /* MAGIC NUMBERs here; we know the is_last flag is the high bit of the byte at this location */ - FLAC__byte x; - if(0 != fseeko(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) { - cleanup_tempfile_(tempfile, tempfilename); - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - if(fread(&x, 1, 1, *tempfile) != 1) { - cleanup_tempfile_(tempfile, tempfilename); - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - return false; - } - if(fixup_is_last_code > 0) { - FLAC__ASSERT(x & 0x80); - x &= 0x7f; - } - else { - FLAC__ASSERT(!(x & 0x80)); - x |= 0x80; - } - if(0 != fseeko(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) { - cleanup_tempfile_(tempfile, tempfilename); - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; - return false; - } - if(local__fwrite(&x, 1, 1, *tempfile) != 1) { - cleanup_tempfile_(tempfile, tempfilename); - iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR; - return false; - } - } - - (void)fclose(iterator->file); - - if(!transport_tempfile_(iterator->filename, tempfile, tempfilename, &iterator->status)) - return false; - - if(iterator->has_stats) - set_file_stats_(iterator->filename, &iterator->stats); - - if(!simple_iterator_prime_input_(iterator, !iterator->is_writable)) - return false; - if(backup) { - while(iterator->offset[iterator->depth] + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (FLAC__off_t)iterator->length < save_offset) - if(!FLAC__metadata_simple_iterator_next(iterator)) - return false; - return true; - } - else { - /* move the iterator to it's original block faster by faking a push, then doing a pop_ */ - FLAC__ASSERT(iterator->depth == 0); - iterator->offset[0] = save_offset; - iterator->depth++; - return simple_iterator_pop_(iterator); - } -} - -FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, FLAC__off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status) -{ - FLAC__byte buffer[8192]; - size_t n; - - FLAC__ASSERT(bytes >= 0); - while(bytes > 0) { - n = flac_min(sizeof(buffer), (size_t)bytes); - if(fread(buffer, 1, n, file) != n) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - return false; - } - if(local__fwrite(buffer, 1, n, tempfile) != n) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR; - return false; - } - bytes -= n; - } - - return true; -} - -FLAC__bool copy_n_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, FLAC__off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status) -{ - FLAC__byte buffer[8192]; - size_t n; - - FLAC__ASSERT(bytes >= 0); - while(bytes > 0) { - n = flac_min(sizeof(buffer), (size_t)bytes); - if(read_cb(buffer, 1, n, handle) != n) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - return false; - } - if(temp_write_cb(buffer, 1, n, temp_handle) != n) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR; - return false; - } - bytes -= n; - } - - return true; -} - -FLAC__bool copy_remaining_bytes_from_file_(FILE *file, FILE *tempfile, FLAC__Metadata_SimpleIteratorStatus *status) -{ - FLAC__byte buffer[8192]; - size_t n; - - while(!feof(file)) { - n = fread(buffer, 1, sizeof(buffer), file); - if(n == 0 && !feof(file)) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - return false; - } - if(n > 0 && local__fwrite(buffer, 1, n, tempfile) != n) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR; - return false; - } - } - - return true; -} - -FLAC__bool copy_remaining_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Eof eof_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, FLAC__Metadata_SimpleIteratorStatus *status) -{ - FLAC__byte buffer[8192]; - size_t n; - - while(!eof_cb(handle)) { - n = read_cb(buffer, 1, sizeof(buffer), handle); - if(n == 0 && !eof_cb(handle)) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; - return false; - } - if(n > 0 && temp_write_cb(buffer, 1, n, temp_handle) != n) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR; - return false; - } - } - - return true; -} - -static int -local_snprintf(char *str, size_t size, const char *fmt, ...) -{ - va_list va; - int rc; - -#if defined _MSC_VER - if (size == 0) - return 1024; -#endif - - va_start (va, fmt); - -#if defined _MSC_VER - rc = vsnprintf_s (str, size, _TRUNCATE, fmt, va); - if (rc < 0) - rc = size - 1; -#elif defined __MINGW32__ - rc = __mingw_vsnprintf (str, size, fmt, va); -#else - rc = vsnprintf (str, size, fmt, va); -#endif - va_end (va); - - return rc; -} - -FLAC__bool open_tempfile_(const char *filename, const char *tempfile_path_prefix, FILE **tempfile, char **tempfilename, FLAC__Metadata_SimpleIteratorStatus *status) -{ - static const char *tempfile_suffix = ".metadata_edit"; - if(0 == tempfile_path_prefix) { - size_t dest_len = strlen(filename) + strlen(tempfile_suffix) + 1; - if(0 == (*tempfilename = safe_malloc_(dest_len))) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - return false; - } - local_snprintf(*tempfilename, dest_len, "%s%s", filename, tempfile_suffix); - } - else { - const char *p = strrchr(filename, '/'); - size_t dest_len; - if(0 == p) - p = filename; - else - p++; - - dest_len = strlen(tempfile_path_prefix) + strlen(p) + strlen(tempfile_suffix) + 2; - - if(0 == (*tempfilename = safe_malloc_(dest_len))) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR; - return false; - } - local_snprintf(*tempfilename, dest_len, "%s/%s%s", tempfile_path_prefix, p, tempfile_suffix); - } - - if(0 == (*tempfile = flac_fopen(*tempfilename, "w+b"))) { - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE; - return false; - } - - return true; -} - -FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename, FLAC__Metadata_SimpleIteratorStatus *status) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != tempfile); - FLAC__ASSERT(0 != *tempfile); - FLAC__ASSERT(0 != tempfilename); - FLAC__ASSERT(0 != *tempfilename); - FLAC__ASSERT(0 != status); - - (void)fclose(*tempfile); - *tempfile = 0; - -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ || defined __EMX__ - /* on some flavors of windows, flac_rename() will fail if the destination already exists */ - if(flac_unlink(filename) < 0) { - cleanup_tempfile_(tempfile, tempfilename); - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR; - return false; - } -#endif - - /*@@@ to fully support the tempfile_path_prefix we need to update this piece to actually copy across filesystems instead of just flac_rename(): */ - if(0 != flac_rename(*tempfilename, filename)) { - cleanup_tempfile_(tempfile, tempfilename); - *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR; - return false; - } - - cleanup_tempfile_(tempfile, tempfilename); - - return true; -} - -void cleanup_tempfile_(FILE **tempfile, char **tempfilename) -{ - if(0 != *tempfile) { - (void)fclose(*tempfile); - *tempfile = 0; - } - - if(0 != *tempfilename) { - (void)flac_unlink(*tempfilename); - free(*tempfilename); - *tempfilename = 0; - } -} - -FLAC__bool get_file_stats_(const char *filename, struct flac_stat_s *stats) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != stats); - return (0 == flac_stat(filename, stats)); -} - -void set_file_stats_(const char *filename, struct flac_stat_s *stats) -{ -#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) && !defined(_WIN32) - struct timespec srctime[2] = {}; - srctime[0].tv_sec = stats->st_atime; - srctime[1].tv_sec = stats->st_mtime; -#else - struct utimbuf srctime; - srctime.actime = stats->st_atime; - srctime.modtime = stats->st_mtime; -#endif - - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != stats); - - (void)flac_chmod(filename, stats->st_mode); - (void)flac_utime(filename, &srctime); -#if !defined _MSC_VER && !defined __BORLANDC__ && !defined __MINGW32__ - FLAC_CHECK_RETURN(chown(filename, stats->st_uid, -1)); - FLAC_CHECK_RETURN(chown(filename, -1, stats->st_gid)); -#endif -} - -int fseek_wrapper_(FLAC__IOHandle handle, FLAC__int64 offset, int whence) -{ - return fseeko((FILE*)handle, (FLAC__off_t)offset, whence); -} - -FLAC__int64 ftell_wrapper_(FLAC__IOHandle handle) -{ - return ftello((FILE*)handle); -} - -FLAC__Metadata_ChainStatus get_equivalent_status_(FLAC__Metadata_SimpleIteratorStatus status) -{ - switch(status) { - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK: - return FLAC__METADATA_CHAIN_STATUS_OK; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT: - return FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE: - return FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE: - return FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE: - return FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA: - return FLAC__METADATA_CHAIN_STATUS_BAD_METADATA; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR: - return FLAC__METADATA_CHAIN_STATUS_READ_ERROR; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR: - return FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR: - return FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR: - return FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR: - return FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR: - return FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; - case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR: - default: - return FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; - } -} diff --git a/Engine/lib/flac/src/libFLAC/metadata_object.c b/Engine/lib/flac/src/libFLAC/metadata_object.c deleted file mode 100644 index 73e76076e..000000000 --- a/Engine/lib/flac/src/libFLAC/metadata_object.c +++ /dev/null @@ -1,2018 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#include "private/metadata.h" -#include "private/memory.h" -#include "private/stream_encoder_framing.h" - -#include "FLAC/assert.h" -#include "FLAC/stream_decoder.h" -#include "share/alloc.h" -#include "share/compat.h" - -/* Alias the first (in share/alloc.h) to the second (in src/libFLAC/memory.c). */ -#define safe_malloc_mul_2op_ safe_malloc_mul_2op_p - - -/**************************************************************************** - * - * Local routines - * - ***************************************************************************/ - -/* copy bytes: - * from = NULL && bytes = 0 - * to <- NULL - * from != NULL && bytes > 0 - * to <- copy of from - * else ASSERT - * malloc error leaves 'to' unchanged - */ -static FLAC__bool copy_bytes_(FLAC__byte **to, const FLAC__byte *from, uint32_t bytes) -{ - FLAC__ASSERT(to != NULL); - if (bytes > 0 && from != NULL) { - FLAC__byte *x; - if ((x = safe_malloc_(bytes)) == NULL) - return false; - memcpy(x, from, bytes); - *to = x; - } - else { - *to = 0; - } - return true; -} - -#if 0 /* UNUSED */ -/* like copy_bytes_(), but free()s the original '*to' if the copy succeeds and the original '*to' is non-NULL */ -static FLAC__bool free_copy_bytes_(FLAC__byte **to, const FLAC__byte *from, uint32_t bytes) -{ - FLAC__byte *copy; - FLAC__ASSERT(to != NULL); - if (copy_bytes_(©, from, bytes)) { - free(*to); - *to = copy; - return true; - } - else - return false; -} -#endif - -/* reallocate entry to 1 byte larger and add a terminating NUL */ -/* realloc() failure leaves entry unchanged */ -static FLAC__bool ensure_null_terminated_(FLAC__byte **entry, uint32_t length) -{ - FLAC__byte *x = safe_realloc_nofree_add_2op_(*entry, length, /*+*/1); - if (x != NULL) { - x[length] = '\0'; - *entry = x; - return true; - } - else - return false; -} - -/* copies the NUL-terminated C-string 'from' to '*to', leaving '*to' - * unchanged if malloc fails, free()ing the original '*to' if it - * succeeds and the original '*to' was not NULL - */ -static FLAC__bool copy_cstring_(char **to, const char *from) -{ - char *copy = strdup(from); - FLAC__ASSERT(to != NULL); - if (copy) { - free(*to); - *to = copy; - return true; - } - else - return false; -} - -static FLAC__bool copy_vcentry_(FLAC__StreamMetadata_VorbisComment_Entry *to, const FLAC__StreamMetadata_VorbisComment_Entry *from) -{ - to->length = from->length; - if (from->entry == 0) { - FLAC__ASSERT(from->length == 0); - if ((to->entry = safe_malloc_(1)) == NULL) - return false; - to->entry[0] = '\0'; - } - else { - FLAC__byte *x; - if ((x = safe_malloc_add_2op_(from->length, /*+*/1)) == NULL) - return false; - memcpy(x, from->entry, from->length); - x[from->length] = '\0'; - to->entry = x; - } - return true; -} - -static FLAC__bool copy_track_(FLAC__StreamMetadata_CueSheet_Track *to, const FLAC__StreamMetadata_CueSheet_Track *from) -{ - memcpy(to, from, sizeof(FLAC__StreamMetadata_CueSheet_Track)); - if (from->indices == 0) { - FLAC__ASSERT(from->num_indices == 0); - } - else { - FLAC__StreamMetadata_CueSheet_Index *x; - FLAC__ASSERT(from->num_indices > 0); - if ((x = safe_malloc_mul_2op_p(from->num_indices, /*times*/sizeof(FLAC__StreamMetadata_CueSheet_Index))) == NULL) - return false; - memcpy(x, from->indices, from->num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index)); - to->indices = x; - } - return true; -} - -static void seektable_calculate_length_(FLAC__StreamMetadata *object) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - - object->length = object->data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; -} - -static FLAC__StreamMetadata_SeekPoint *seekpoint_array_new_(uint32_t num_points) -{ - FLAC__StreamMetadata_SeekPoint *object_array; - - FLAC__ASSERT(num_points > 0); - - object_array = safe_malloc_mul_2op_p(num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint)); - - if (object_array != NULL) { - uint32_t i; - for (i = 0; i < num_points; i++) { - object_array[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - object_array[i].stream_offset = 0; - object_array[i].frame_samples = 0; - } - } - - return object_array; -} - -static void vorbiscomment_calculate_length_(FLAC__StreamMetadata *object) -{ - uint32_t i; - - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - object->length = (FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN) / 8; - object->length += object->data.vorbis_comment.vendor_string.length; - object->length += (FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN) / 8; - for (i = 0; i < object->data.vorbis_comment.num_comments; i++) { - object->length += (FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8); - object->length += object->data.vorbis_comment.comments[i].length; - } -} - -static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_new_(uint32_t num_comments) -{ - FLAC__ASSERT(num_comments > 0); - - return safe_calloc_(num_comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)); -} - -static void vorbiscomment_entry_array_delete_(FLAC__StreamMetadata_VorbisComment_Entry *object_array, uint32_t num_comments) -{ - uint32_t i; - - FLAC__ASSERT(object_array != NULL); - - for (i = 0; i < num_comments; i++) - free(object_array[i].entry); - - free(object_array); -} - -static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_copy_(const FLAC__StreamMetadata_VorbisComment_Entry *object_array, uint32_t num_comments) -{ - FLAC__StreamMetadata_VorbisComment_Entry *return_array; - - FLAC__ASSERT(object_array != NULL); - FLAC__ASSERT(num_comments > 0); - - return_array = vorbiscomment_entry_array_new_(num_comments); - - if (return_array != NULL) { - uint32_t i; - - for (i = 0; i < num_comments; i++) { - if (!copy_vcentry_(return_array+i, object_array+i)) { - vorbiscomment_entry_array_delete_(return_array, num_comments); - return 0; - } - } - } - - return return_array; -} - -static FLAC__bool vorbiscomment_set_entry_(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry *dest, const FLAC__StreamMetadata_VorbisComment_Entry *src, FLAC__bool copy) -{ - FLAC__byte *save; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(dest != NULL); - FLAC__ASSERT(src != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT((src->entry != NULL && src->length > 0) || (src->entry == NULL && src->length == 0)); - - save = dest->entry; - - if (src->entry != NULL) { - if (copy) { - /* do the copy first so that if we fail we leave the dest object untouched */ - if (!copy_vcentry_(dest, src)) - return false; - } - else { - /* we have to make sure that the string we're taking over is null-terminated */ - - /* - * Stripping the const from src->entry is OK since we're taking - * ownership of the pointer. This is a hack around a deficiency - * in the API where the same function is used for 'copy' and - * 'own', but the source entry is a const pointer. If we were - * precise, the 'own' flavor would be a separate function with a - * non-const source pointer. But it's not, so we hack away. - */ - if (!ensure_null_terminated_((FLAC__byte**)(&src->entry), src->length)) - return false; - *dest = *src; - } - } - else { - /* the src is null */ - *dest = *src; - } - - free(save); - - vorbiscomment_calculate_length_(object); - return true; -} - -static int vorbiscomment_find_entry_from_(const FLAC__StreamMetadata *object, uint32_t offset, const char *field_name, uint32_t field_name_length) -{ - uint32_t i; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(field_name != NULL); - - for (i = offset; i < object->data.vorbis_comment.num_comments; i++) { - if (FLAC__metadata_object_vorbiscomment_entry_matches(object->data.vorbis_comment.comments[i], field_name, field_name_length)) - return (int)i; - } - - return -1; -} - -static void cuesheet_calculate_length_(FLAC__StreamMetadata *object) -{ - uint32_t i; - - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - - object->length = ( - FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN + - FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + - FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN - ) / 8; - - object->length += object->data.cue_sheet.num_tracks * ( - FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN - ) / 8; - - for (i = 0; i < object->data.cue_sheet.num_tracks; i++) { - object->length += object->data.cue_sheet.tracks[i].num_indices * ( - FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN + - FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN - ) / 8; - } -} - -static FLAC__StreamMetadata_CueSheet_Index *cuesheet_track_index_array_new_(uint32_t num_indices) -{ - FLAC__ASSERT(num_indices > 0); - - return safe_calloc_(num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)); -} - -static FLAC__StreamMetadata_CueSheet_Track *cuesheet_track_array_new_(uint32_t num_tracks) -{ - FLAC__ASSERT(num_tracks > 0); - - return safe_calloc_(num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)); -} - -static void cuesheet_track_array_delete_(FLAC__StreamMetadata_CueSheet_Track *object_array, uint32_t num_tracks) -{ - uint32_t i; - - FLAC__ASSERT(object_array != NULL && num_tracks > 0); - - for (i = 0; i < num_tracks; i++) { - if (object_array[i].indices != 0) { - FLAC__ASSERT(object_array[i].num_indices > 0); - free(object_array[i].indices); - } - } - - free(object_array); -} - -static FLAC__StreamMetadata_CueSheet_Track *cuesheet_track_array_copy_(const FLAC__StreamMetadata_CueSheet_Track *object_array, uint32_t num_tracks) -{ - FLAC__StreamMetadata_CueSheet_Track *return_array; - - FLAC__ASSERT(object_array != NULL); - FLAC__ASSERT(num_tracks > 0); - - return_array = cuesheet_track_array_new_(num_tracks); - - if (return_array != NULL) { - uint32_t i; - - for (i = 0; i < num_tracks; i++) { - if (!copy_track_(return_array+i, object_array+i)) { - cuesheet_track_array_delete_(return_array, num_tracks); - return 0; - } - } - } - - return return_array; -} - -static FLAC__bool cuesheet_set_track_(FLAC__StreamMetadata *object, FLAC__StreamMetadata_CueSheet_Track *dest, const FLAC__StreamMetadata_CueSheet_Track *src, FLAC__bool copy) -{ - FLAC__StreamMetadata_CueSheet_Index *save; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(dest != NULL); - FLAC__ASSERT(src != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - FLAC__ASSERT((src->indices != NULL && src->num_indices > 0) || (src->indices == NULL && src->num_indices == 0)); - - save = dest->indices; - - /* do the copy first so that if we fail we leave the object untouched */ - if (copy) { - if (!copy_track_(dest, src)) - return false; - } - else { - *dest = *src; - } - - free(save); - - cuesheet_calculate_length_(object); - return true; -} - - -/**************************************************************************** - * - * Metadata object routines - * - ***************************************************************************/ - -FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type) -{ - FLAC__StreamMetadata *object; - - if (type > FLAC__MAX_METADATA_TYPE) - return 0; - - object = calloc(1, sizeof(FLAC__StreamMetadata)); - if (object != NULL) { - object->is_last = false; - object->type = type; - switch(type) { - case FLAC__METADATA_TYPE_STREAMINFO: - object->length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; - break; - case FLAC__METADATA_TYPE_PADDING: - /* calloc() took care of this for us: - object->length = 0; - */ - break; - case FLAC__METADATA_TYPE_APPLICATION: - object->length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; - /* calloc() took care of this for us: - object->data.application.data = 0; - */ - break; - case FLAC__METADATA_TYPE_SEEKTABLE: - /* calloc() took care of this for us: - object->length = 0; - object->data.seek_table.num_points = 0; - object->data.seek_table.points = 0; - */ - break; - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - object->data.vorbis_comment.vendor_string.length = (uint32_t)strlen(FLAC__VENDOR_STRING); - if (!copy_bytes_(&object->data.vorbis_comment.vendor_string.entry, (const FLAC__byte*)FLAC__VENDOR_STRING, object->data.vorbis_comment.vendor_string.length+1)) { - free(object); - return 0; - } - vorbiscomment_calculate_length_(object); - break; - case FLAC__METADATA_TYPE_CUESHEET: - cuesheet_calculate_length_(object); - break; - case FLAC__METADATA_TYPE_PICTURE: - object->length = ( - FLAC__STREAM_METADATA_PICTURE_TYPE_LEN + - FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN + /* empty mime_type string */ - FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN + /* empty description string */ - FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN + - FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN + - FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN + - FLAC__STREAM_METADATA_PICTURE_COLORS_LEN + - FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN + - 0 /* no data */ - ) / 8; - object->data.picture.type = FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER; - object->data.picture.mime_type = 0; - object->data.picture.description = 0; - /* calloc() took care of this for us: - object->data.picture.width = 0; - object->data.picture.height = 0; - object->data.picture.depth = 0; - object->data.picture.colors = 0; - object->data.picture.data_length = 0; - object->data.picture.data = 0; - */ - /* now initialize mime_type and description with empty strings to make things easier on the client */ - if (!copy_cstring_(&object->data.picture.mime_type, "")) { - free(object); - return 0; - } - if (!copy_cstring_((char**)(&object->data.picture.description), "")) { - free(object->data.picture.mime_type); - free(object); - return 0; - } - break; - default: - /* calloc() took care of this for us: - object->length = 0; - object->data.unknown.data = 0; - */ - break; - } - } - - return object; -} - -FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_clone(const FLAC__StreamMetadata *object) -{ - FLAC__StreamMetadata *to; - - FLAC__ASSERT(object != NULL); - - if ((to = FLAC__metadata_object_new(object->type)) != NULL) { - to->is_last = object->is_last; - to->type = object->type; - to->length = object->length; - switch(to->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - memcpy(&to->data.stream_info, &object->data.stream_info, sizeof(FLAC__StreamMetadata_StreamInfo)); - break; - case FLAC__METADATA_TYPE_PADDING: - break; - case FLAC__METADATA_TYPE_APPLICATION: - if (to->length < FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8) { /* underflow check */ - FLAC__metadata_object_delete(to); - return 0; - } - memcpy(&to->data.application.id, &object->data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8); - if (!copy_bytes_(&to->data.application.data, object->data.application.data, object->length - FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8)) { - FLAC__metadata_object_delete(to); - return 0; - } - break; - case FLAC__METADATA_TYPE_SEEKTABLE: - to->data.seek_table.num_points = object->data.seek_table.num_points; - if (to->data.seek_table.num_points > UINT32_MAX / sizeof(FLAC__StreamMetadata_SeekPoint)) { /* overflow check */ - FLAC__metadata_object_delete(to); - return 0; - } - if (!copy_bytes_((FLAC__byte**)&to->data.seek_table.points, (FLAC__byte*)object->data.seek_table.points, object->data.seek_table.num_points * sizeof(FLAC__StreamMetadata_SeekPoint))) { - FLAC__metadata_object_delete(to); - return 0; - } - break; - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - if (to->data.vorbis_comment.vendor_string.entry != NULL) { - free(to->data.vorbis_comment.vendor_string.entry); - to->data.vorbis_comment.vendor_string.entry = 0; - } - if (!copy_vcentry_(&to->data.vorbis_comment.vendor_string, &object->data.vorbis_comment.vendor_string)) { - FLAC__metadata_object_delete(to); - return 0; - } - if (object->data.vorbis_comment.num_comments == 0) { - to->data.vorbis_comment.comments = 0; - } - else { - to->data.vorbis_comment.comments = vorbiscomment_entry_array_copy_(object->data.vorbis_comment.comments, object->data.vorbis_comment.num_comments); - if (to->data.vorbis_comment.comments == NULL) { - to->data.vorbis_comment.num_comments = 0; - FLAC__metadata_object_delete(to); - return 0; - } - } - to->data.vorbis_comment.num_comments = object->data.vorbis_comment.num_comments; - break; - case FLAC__METADATA_TYPE_CUESHEET: - memcpy(&to->data.cue_sheet, &object->data.cue_sheet, sizeof(FLAC__StreamMetadata_CueSheet)); - if (object->data.cue_sheet.num_tracks == 0) { - FLAC__ASSERT(object->data.cue_sheet.tracks == NULL); - } - else { - FLAC__ASSERT(object->data.cue_sheet.tracks != 0); - to->data.cue_sheet.tracks = cuesheet_track_array_copy_(object->data.cue_sheet.tracks, object->data.cue_sheet.num_tracks); - if (to->data.cue_sheet.tracks == NULL) { - FLAC__metadata_object_delete(to); - return 0; - } - } - break; - case FLAC__METADATA_TYPE_PICTURE: - to->data.picture.type = object->data.picture.type; - if (!copy_cstring_(&to->data.picture.mime_type, object->data.picture.mime_type)) { - FLAC__metadata_object_delete(to); - return 0; - } - if (!copy_cstring_((char**)(&to->data.picture.description), (const char*)object->data.picture.description)) { - FLAC__metadata_object_delete(to); - return 0; - } - to->data.picture.width = object->data.picture.width; - to->data.picture.height = object->data.picture.height; - to->data.picture.depth = object->data.picture.depth; - to->data.picture.colors = object->data.picture.colors; - to->data.picture.data_length = object->data.picture.data_length; - if (!copy_bytes_((&to->data.picture.data), object->data.picture.data, object->data.picture.data_length)) { - FLAC__metadata_object_delete(to); - return 0; - } - break; - default: - if (!copy_bytes_(&to->data.unknown.data, object->data.unknown.data, object->length)) { - FLAC__metadata_object_delete(to); - return 0; - } - break; - } - } - - return to; -} - -void FLAC__metadata_object_delete_data(FLAC__StreamMetadata *object) -{ - FLAC__ASSERT(object != NULL); - - switch(object->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - case FLAC__METADATA_TYPE_PADDING: - break; - case FLAC__METADATA_TYPE_APPLICATION: - if (object->data.application.data != NULL) { - free(object->data.application.data); - object->data.application.data = NULL; - } - break; - case FLAC__METADATA_TYPE_SEEKTABLE: - if (object->data.seek_table.points != NULL) { - free(object->data.seek_table.points); - object->data.seek_table.points = NULL; - } - break; - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - if (object->data.vorbis_comment.vendor_string.entry != NULL) { - free(object->data.vorbis_comment.vendor_string.entry); - object->data.vorbis_comment.vendor_string.entry = 0; - } - if (object->data.vorbis_comment.comments != NULL) { - vorbiscomment_entry_array_delete_(object->data.vorbis_comment.comments, object->data.vorbis_comment.num_comments); - object->data.vorbis_comment.comments = NULL; - object->data.vorbis_comment.num_comments = 0; - } - break; - case FLAC__METADATA_TYPE_CUESHEET: - if (object->data.cue_sheet.tracks != NULL) { - FLAC__ASSERT(object->data.cue_sheet.num_tracks > 0); - cuesheet_track_array_delete_(object->data.cue_sheet.tracks, object->data.cue_sheet.num_tracks); - object->data.cue_sheet.tracks = NULL; - object->data.cue_sheet.num_tracks = 0; - } - break; - case FLAC__METADATA_TYPE_PICTURE: - if (object->data.picture.mime_type != NULL) { - free(object->data.picture.mime_type); - object->data.picture.mime_type = NULL; - } - if (object->data.picture.description != NULL) { - free(object->data.picture.description); - object->data.picture.description = NULL; - } - if (object->data.picture.data != NULL) { - free(object->data.picture.data); - object->data.picture.data = NULL; - } - break; - default: - if (object->data.unknown.data != NULL) { - free(object->data.unknown.data); - object->data.unknown.data = NULL; - } - break; - } -} - -FLAC_API void FLAC__metadata_object_delete(FLAC__StreamMetadata *object) -{ - FLAC__metadata_object_delete_data(object); - free(object); -} - -static FLAC__bool compare_block_data_streaminfo_(const FLAC__StreamMetadata_StreamInfo *block1, const FLAC__StreamMetadata_StreamInfo *block2) -{ - if (block1->min_blocksize != block2->min_blocksize) - return false; - if (block1->max_blocksize != block2->max_blocksize) - return false; - if (block1->min_framesize != block2->min_framesize) - return false; - if (block1->max_framesize != block2->max_framesize) - return false; - if (block1->sample_rate != block2->sample_rate) - return false; - if (block1->channels != block2->channels) - return false; - if (block1->bits_per_sample != block2->bits_per_sample) - return false; - if (block1->total_samples != block2->total_samples) - return false; - if (memcmp(block1->md5sum, block2->md5sum, 16) != 0) - return false; - return true; -} - -static FLAC__bool compare_block_data_application_(const FLAC__StreamMetadata_Application *block1, const FLAC__StreamMetadata_Application *block2, uint32_t block_length) -{ - FLAC__ASSERT(block1 != NULL); - FLAC__ASSERT(block2 != NULL); - FLAC__ASSERT(block_length >= sizeof(block1->id)); - - if (memcmp(block1->id, block2->id, sizeof(block1->id)) != 0) - return false; - if (block1->data != NULL && block2->data != NULL) - return memcmp(block1->data, block2->data, block_length - sizeof(block1->id)) == 0; - else - return block1->data == block2->data; -} - -static FLAC__bool compare_block_data_seektable_(const FLAC__StreamMetadata_SeekTable *block1, const FLAC__StreamMetadata_SeekTable *block2) -{ - uint32_t i; - - FLAC__ASSERT(block1 != NULL); - FLAC__ASSERT(block2 != NULL); - - if (block1->num_points != block2->num_points) - return false; - - if (block1->points != NULL && block2->points != NULL) { - for (i = 0; i < block1->num_points; i++) { - if (block1->points[i].sample_number != block2->points[i].sample_number) - return false; - if (block1->points[i].stream_offset != block2->points[i].stream_offset) - return false; - if (block1->points[i].frame_samples != block2->points[i].frame_samples) - return false; - } - return true; - } - else - return block1->points == block2->points; -} - -static FLAC__bool compare_block_data_vorbiscomment_(const FLAC__StreamMetadata_VorbisComment *block1, const FLAC__StreamMetadata_VorbisComment *block2) -{ - uint32_t i; - - if (block1->vendor_string.length != block2->vendor_string.length) - return false; - - if (block1->vendor_string.entry != NULL && block2->vendor_string.entry != NULL) { - if (memcmp(block1->vendor_string.entry, block2->vendor_string.entry, block1->vendor_string.length) != 0) - return false; - } - else if (block1->vendor_string.entry != block2->vendor_string.entry) - return false; - - if (block1->num_comments != block2->num_comments) - return false; - - for (i = 0; i < block1->num_comments; i++) { - if (block1->comments[i].entry != NULL && block2->comments[i].entry != NULL) { - if (memcmp(block1->comments[i].entry, block2->comments[i].entry, block1->comments[i].length) != 0) - return false; - } - else if (block1->comments[i].entry != block2->comments[i].entry) - return false; - } - return true; -} - -static FLAC__bool compare_block_data_cuesheet_(const FLAC__StreamMetadata_CueSheet *block1, const FLAC__StreamMetadata_CueSheet *block2) -{ - uint32_t i, j; - - if (strcmp(block1->media_catalog_number, block2->media_catalog_number) != 0) - return false; - - if (block1->lead_in != block2->lead_in) - return false; - - if (block1->is_cd != block2->is_cd) - return false; - - if (block1->num_tracks != block2->num_tracks) - return false; - - if (block1->tracks != NULL && block2->tracks != NULL) { - FLAC__ASSERT(block1->num_tracks > 0); - for (i = 0; i < block1->num_tracks; i++) { - if (block1->tracks[i].offset != block2->tracks[i].offset) - return false; - if (block1->tracks[i].number != block2->tracks[i].number) - return false; - if (memcmp(block1->tracks[i].isrc, block2->tracks[i].isrc, sizeof(block1->tracks[i].isrc)) != 0) - return false; - if (block1->tracks[i].type != block2->tracks[i].type) - return false; - if (block1->tracks[i].pre_emphasis != block2->tracks[i].pre_emphasis) - return false; - if (block1->tracks[i].num_indices != block2->tracks[i].num_indices) - return false; - if (block1->tracks[i].indices != NULL && block2->tracks[i].indices != NULL) { - FLAC__ASSERT(block1->tracks[i].num_indices > 0); - for (j = 0; j < block1->tracks[i].num_indices; j++) { - if (block1->tracks[i].indices[j].offset != block2->tracks[i].indices[j].offset) - return false; - if (block1->tracks[i].indices[j].number != block2->tracks[i].indices[j].number) - return false; - } - } - else if (block1->tracks[i].indices != block2->tracks[i].indices) - return false; - } - } - else if (block1->tracks != block2->tracks) - return false; - return true; -} - -static FLAC__bool compare_block_data_picture_(const FLAC__StreamMetadata_Picture *block1, const FLAC__StreamMetadata_Picture *block2) -{ - if (block1->type != block2->type) - return false; - if (block1->mime_type != block2->mime_type && (block1->mime_type == 0 || block2->mime_type == 0 || strcmp(block1->mime_type, block2->mime_type))) - return false; - if (block1->description != block2->description && (block1->description == 0 || block2->description == 0 || strcmp((const char *)block1->description, (const char *)block2->description))) - return false; - if (block1->width != block2->width) - return false; - if (block1->height != block2->height) - return false; - if (block1->depth != block2->depth) - return false; - if (block1->colors != block2->colors) - return false; - if (block1->data_length != block2->data_length) - return false; - if (block1->data != block2->data && (block1->data == NULL || block2->data == NULL || memcmp(block1->data, block2->data, block1->data_length))) - return false; - return true; -} - -static FLAC__bool compare_block_data_unknown_(const FLAC__StreamMetadata_Unknown *block1, const FLAC__StreamMetadata_Unknown *block2, uint32_t block_length) -{ - FLAC__ASSERT(block1 != NULL); - FLAC__ASSERT(block2 != NULL); - - if (block1->data != NULL && block2->data != NULL) - return memcmp(block1->data, block2->data, block_length) == 0; - else - return block1->data == block2->data; -} - -FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2) -{ - FLAC__ASSERT(block1 != NULL); - FLAC__ASSERT(block2 != NULL); - - if (block1->type != block2->type) { - return false; - } - if (block1->is_last != block2->is_last) { - return false; - } - if (block1->length != block2->length) { - return false; - } - switch(block1->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - return compare_block_data_streaminfo_(&block1->data.stream_info, &block2->data.stream_info); - case FLAC__METADATA_TYPE_PADDING: - return true; /* we don't compare the padding guts */ - case FLAC__METADATA_TYPE_APPLICATION: - return compare_block_data_application_(&block1->data.application, &block2->data.application, block1->length); - case FLAC__METADATA_TYPE_SEEKTABLE: - return compare_block_data_seektable_(&block1->data.seek_table, &block2->data.seek_table); - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - return compare_block_data_vorbiscomment_(&block1->data.vorbis_comment, &block2->data.vorbis_comment); - case FLAC__METADATA_TYPE_CUESHEET: - return compare_block_data_cuesheet_(&block1->data.cue_sheet, &block2->data.cue_sheet); - case FLAC__METADATA_TYPE_PICTURE: - return compare_block_data_picture_(&block1->data.picture, &block2->data.picture); - default: - return compare_block_data_unknown_(&block1->data.unknown, &block2->data.unknown, block1->length); - } -} - -FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, uint32_t length, FLAC__bool copy) -{ - FLAC__byte *save; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_APPLICATION); - FLAC__ASSERT((data != NULL && length > 0) || (data == NULL && length == 0 && copy == false)); - - save = object->data.application.data; - - /* do the copy first so that if we fail we leave the object untouched */ - if (copy) { - if (!copy_bytes_(&object->data.application.data, data, length)) - return false; - } - else { - object->data.application.data = data; - } - - free(save); - - object->length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8 + length; - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, uint32_t new_num_points) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - - if((FLAC__uint64)(new_num_points) * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) - return false; - - if (object->data.seek_table.points == 0) { - FLAC__ASSERT(object->data.seek_table.num_points == 0); - if (new_num_points == 0) - return true; - else if ((object->data.seek_table.points = seekpoint_array_new_(new_num_points)) == 0) - return false; - } - else { - const size_t old_size = object->data.seek_table.num_points * sizeof(FLAC__StreamMetadata_SeekPoint); - const size_t new_size = new_num_points * sizeof(FLAC__StreamMetadata_SeekPoint); - - /* overflow check */ - if (new_num_points > UINT32_MAX / sizeof(FLAC__StreamMetadata_SeekPoint)) - return false; - - FLAC__ASSERT(object->data.seek_table.num_points > 0); - - if (new_size == 0) { - free(object->data.seek_table.points); - object->data.seek_table.points = 0; - } - else { - /* Leave object->data.seek_table.points untouched if realloc fails */ - FLAC__StreamMetadata_SeekPoint *tmpptr; - if ((tmpptr = realloc(object->data.seek_table.points, new_size)) == NULL) - return false; - object->data.seek_table.points = tmpptr; - } - - /* if growing, set new elements to placeholders */ - if (new_size > old_size) { - uint32_t i; - for (i = object->data.seek_table.num_points; i < new_num_points; i++) { - object->data.seek_table.points[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - object->data.seek_table.points[i].stream_offset = 0; - object->data.seek_table.points[i].frame_samples = 0; - } - } - } - - object->data.seek_table.num_points = new_num_points; - - seektable_calculate_length_(object); - return true; -} - -FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - FLAC__ASSERT(point_num < object->data.seek_table.num_points); - - object->data.seek_table.points[point_num] = point; -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point) -{ - int i; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - FLAC__ASSERT(point_num <= object->data.seek_table.num_points); - - if (!FLAC__metadata_object_seektable_resize_points(object, object->data.seek_table.num_points+1)) - return false; - - /* move all points >= point_num forward one space */ - for (i = (int)object->data.seek_table.num_points-1; i > (int)point_num; i--) - object->data.seek_table.points[i] = object->data.seek_table.points[i-1]; - - FLAC__metadata_object_seektable_set_point(object, point_num, point); - seektable_calculate_length_(object); - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, uint32_t point_num) -{ - uint32_t i; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - FLAC__ASSERT(point_num < object->data.seek_table.num_points); - - /* move all points > point_num backward one space */ - for (i = point_num; i < object->data.seek_table.num_points-1; i++) - object->data.seek_table.points[i] = object->data.seek_table.points[i+1]; - - return FLAC__metadata_object_seektable_resize_points(object, object->data.seek_table.num_points-1); -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetadata *object) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - - return FLAC__format_seektable_is_legal(&object->data.seek_table); -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, uint32_t num) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - - if (num > 0) - /* WATCHOUT: we rely on the fact that growing the array adds PLACEHOLDERS at the end */ - return FLAC__metadata_object_seektable_resize_points(object, object->data.seek_table.num_points + num); - else - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__StreamMetadata *object, FLAC__uint64 sample_number) -{ - FLAC__StreamMetadata_SeekTable *seek_table; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - - seek_table = &object->data.seek_table; - - if (!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + 1)) - return false; - - seek_table->points[seek_table->num_points - 1].sample_number = sample_number; - seek_table->points[seek_table->num_points - 1].stream_offset = 0; - seek_table->points[seek_table->num_points - 1].frame_samples = 0; - - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], uint32_t num) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - FLAC__ASSERT(sample_numbers != 0 || num == 0); - - if (num > 0) { - FLAC__StreamMetadata_SeekTable *seek_table = &object->data.seek_table; - uint32_t i, j; - - i = seek_table->num_points; - - if (!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + num)) - return false; - - for (j = 0; j < num; i++, j++) { - seek_table->points[i].sample_number = sample_numbers[j]; - seek_table->points[i].stream_offset = 0; - seek_table->points[i].frame_samples = 0; - } - } - - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, uint32_t num, FLAC__uint64 total_samples) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - - if (num > 0 && total_samples > 0) { - FLAC__StreamMetadata_SeekTable *seek_table = &object->data.seek_table; - uint32_t i, j; - - i = seek_table->num_points; - - if (!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + num)) - return false; - - for (j = 0; j < num; i++, j++) { - seek_table->points[i].sample_number = total_samples * (FLAC__uint64)j / (FLAC__uint64)num; - seek_table->points[i].stream_offset = 0; - seek_table->points[i].frame_samples = 0; - } - } - - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, uint32_t samples, FLAC__uint64 total_samples) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - - if (samples > 0 && total_samples > 0) { - FLAC__StreamMetadata_SeekTable *seek_table = &object->data.seek_table; - uint32_t i, j; - FLAC__uint64 num, sample; - - num = 1 + total_samples / samples; /* 1+ for the first sample at 0 */ - /* now account for the fact that we don't place a seekpoint at "total_samples" since samples are number from 0: */ - if (total_samples % samples == 0) - num--; - - /* Put a strict upper bound on the number of allowed seek points. */ - if (num > 32768) { - /* Set the bound and recalculate samples accordingly. */ - num = 32768; - samples = (uint32_t)(total_samples / num); - } - - i = seek_table->num_points; - - if (!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + (uint32_t)num)) - return false; - - sample = 0; - for (j = 0; j < num; i++, j++, sample += samples) { - seek_table->points[i].sample_number = sample; - seek_table->points[i].stream_offset = 0; - seek_table->points[i].frame_samples = 0; - } - } - - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact) -{ - uint32_t unique; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); - - unique = FLAC__format_seektable_sort(&object->data.seek_table); - - return !compact || FLAC__metadata_object_seektable_resize_points(object, unique); -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy) -{ - if (!FLAC__format_vorbiscomment_entry_value_is_legal(entry.entry, entry.length)) - return false; - return vorbiscomment_set_entry_(object, &object->data.vorbis_comment.vendor_string, &entry, copy); -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, uint32_t new_num_comments) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - if (object->data.vorbis_comment.comments == NULL) { - FLAC__ASSERT(object->data.vorbis_comment.num_comments == 0); - if (new_num_comments == 0) - return true; - else { - uint32_t i; - if ((object->data.vorbis_comment.comments = vorbiscomment_entry_array_new_(new_num_comments)) == NULL) - return false; - for (i = 0; i < new_num_comments; i++) { - object->data.vorbis_comment.comments[i].length = 0; - if ((object->data.vorbis_comment.comments[i].entry = safe_malloc_(1)) == NULL) { - object->data.vorbis_comment.num_comments = i+1; - return false; - } - object->data.vorbis_comment.comments[i].entry[0] = '\0'; - } - } - } - else { - const size_t old_size = object->data.vorbis_comment.num_comments * sizeof(FLAC__StreamMetadata_VorbisComment_Entry); - const size_t new_size = new_num_comments * sizeof(FLAC__StreamMetadata_VorbisComment_Entry); - - /* overflow check */ - if (new_num_comments > UINT32_MAX / sizeof(FLAC__StreamMetadata_VorbisComment_Entry)) - return false; - - FLAC__ASSERT(object->data.vorbis_comment.num_comments > 0); - - /* if shrinking, free the truncated entries */ - if (new_num_comments < object->data.vorbis_comment.num_comments) { - uint32_t i; - for (i = new_num_comments; i < object->data.vorbis_comment.num_comments; i++) - if (object->data.vorbis_comment.comments[i].entry != NULL) - free(object->data.vorbis_comment.comments[i].entry); - } - - if (new_size == 0) { - free(object->data.vorbis_comment.comments); - object->data.vorbis_comment.comments = 0; - } - else { - /* Leave object->data.vorbis_comment.comments untouched if realloc fails */ - FLAC__StreamMetadata_VorbisComment_Entry *tmpptr; - if ((tmpptr = realloc(object->data.vorbis_comment.comments, new_size)) == NULL) - return false; - object->data.vorbis_comment.comments = tmpptr; - } - - /* if growing, zero all the length/pointers of new elements */ - if (new_size > old_size) { - uint32_t i; - for (i = object->data.vorbis_comment.num_comments; i < new_num_comments; i++) { - object->data.vorbis_comment.comments[i].length = 0; - if ((object->data.vorbis_comment.comments[i].entry = safe_malloc_(1)) == NULL) { - object->data.vorbis_comment.num_comments = i+1; - return false; - } - object->data.vorbis_comment.comments[i].entry[0] = '\0'; - } - } - } - - object->data.vorbis_comment.num_comments = new_num_comments; - - vorbiscomment_calculate_length_(object); - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(comment_num < object->data.vorbis_comment.num_comments); - - if (!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length)) - return false; - return vorbiscomment_set_entry_(object, &object->data.vorbis_comment.comments[comment_num], &entry, copy); -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy) -{ - FLAC__StreamMetadata_VorbisComment *vc; - FLAC__StreamMetadata_VorbisComment_Entry temp; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(comment_num <= object->data.vorbis_comment.num_comments); - - if (!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length)) - return false; - - vc = &object->data.vorbis_comment; - - if (!FLAC__metadata_object_vorbiscomment_resize_comments(object, vc->num_comments+1)) - return false; - - /* move all comments >= comment_num forward one space */ - /* reuse newly added empty comment */ - temp = vc->comments[vc->num_comments-1]; - memmove(&vc->comments[comment_num+1], &vc->comments[comment_num], sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(vc->num_comments-1-comment_num)); - vc->comments[comment_num] = temp; - - return FLAC__metadata_object_vorbiscomment_set_comment(object, comment_num, entry, copy); -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - return FLAC__metadata_object_vorbiscomment_insert_comment(object, object->data.vorbis_comment.num_comments, entry, copy); -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool all, FLAC__bool copy) -{ - FLAC__ASSERT(entry.entry != NULL); - - if (!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length)) - return false; - - { - int i; - size_t field_name_length; - const FLAC__byte *eq = (FLAC__byte*)memchr(entry.entry, '=', entry.length); - - if (eq == NULL) - return false; /* double protection */ - - field_name_length = eq-entry.entry; - - i = vorbiscomment_find_entry_from_(object, 0, (const char *)entry.entry, field_name_length); - if (i >= 0) { - uint32_t indx = (uint32_t)i; - if (!FLAC__metadata_object_vorbiscomment_set_comment(object, indx, entry, copy)) - return false; - entry = object->data.vorbis_comment.comments[indx]; - indx++; /* skip over replaced comment */ - if (all && indx < object->data.vorbis_comment.num_comments) { - i = vorbiscomment_find_entry_from_(object, indx, (const char *)entry.entry, field_name_length); - while (i >= 0) { - indx = (uint32_t)i; - if (!FLAC__metadata_object_vorbiscomment_delete_comment(object, indx)) - return false; - if (indx < object->data.vorbis_comment.num_comments) - i = vorbiscomment_find_entry_from_(object, indx, (const char *)entry.entry, field_name_length); - else - i = -1; - } - } - return true; - } - else - return FLAC__metadata_object_vorbiscomment_append_comment(object, entry, copy); - } -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, uint32_t comment_num) -{ - FLAC__StreamMetadata_VorbisComment *vc; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(comment_num < object->data.vorbis_comment.num_comments); - - vc = &object->data.vorbis_comment; - - /* free the comment at comment_num */ - free(vc->comments[comment_num].entry); - - /* move all comments > comment_num backward one space */ - memmove(&vc->comments[comment_num], &vc->comments[comment_num+1], sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(vc->num_comments-comment_num-1)); - vc->comments[vc->num_comments-1].length = 0; - vc->comments[vc->num_comments-1].entry = 0; - - return FLAC__metadata_object_vorbiscomment_resize_comments(object, vc->num_comments-1); -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, const char *field_value) -{ - FLAC__ASSERT(entry != NULL); - FLAC__ASSERT(field_name != NULL); - FLAC__ASSERT(field_value != NULL); - - if (!FLAC__format_vorbiscomment_entry_name_is_legal(field_name)) - return false; - if (!FLAC__format_vorbiscomment_entry_value_is_legal((const FLAC__byte *)field_value, (uint32_t)(-1))) - return false; - - { - const size_t nn = strlen(field_name); - const size_t nv = strlen(field_value); - entry->length = nn + 1 /*=*/ + nv; - if ((entry->entry = safe_malloc_add_4op_(nn, /*+*/1, /*+*/nv, /*+*/1)) == NULL) - return false; - memcpy(entry->entry, field_name, nn); - entry->entry[nn] = '='; - memcpy(entry->entry+nn+1, field_value, nv); - entry->entry[entry->length] = '\0'; - } - - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(const FLAC__StreamMetadata_VorbisComment_Entry entry, char **field_name, char **field_value) -{ - FLAC__ASSERT(entry.entry != NULL); - FLAC__ASSERT(field_name != NULL); - FLAC__ASSERT(field_value != NULL); - - if (!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length)) - return false; - - { - const FLAC__byte *eq = (FLAC__byte*)memchr(entry.entry, '=', entry.length); - const size_t nn = eq-entry.entry; - const size_t nv = entry.length-nn-1; /* -1 for the '=' */ - - if (eq == NULL) - return false; /* double protection */ - if ((*field_name = safe_malloc_add_2op_(nn, /*+*/1)) == NULL) - return false; - if ((*field_value = safe_malloc_add_2op_(nv, /*+*/1)) == NULL) { - free(*field_name); - return false; - } - memcpy(*field_name, entry.entry, nn); - memcpy(*field_value, entry.entry+nn+1, nv); - (*field_name)[nn] = '\0'; - (*field_value)[nv] = '\0'; - } - - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, uint32_t field_name_length) -{ - FLAC__ASSERT(entry.entry != NULL); - { - const FLAC__byte *eq = (FLAC__byte*)memchr(entry.entry, '=', entry.length); - return (eq != NULL && (uint32_t)(eq-entry.entry) == field_name_length && FLAC__STRNCASECMP(field_name, (const char *)entry.entry, field_name_length) == 0); - } -} - -FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, uint32_t offset, const char *field_name) -{ - FLAC__ASSERT(field_name != NULL); - - return vorbiscomment_find_entry_from_(object, offset, field_name, strlen(field_name)); -} - -FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entry_matching(FLAC__StreamMetadata *object, const char *field_name) -{ - const uint32_t field_name_length = strlen(field_name); - uint32_t i; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - for (i = 0; i < object->data.vorbis_comment.num_comments; i++) { - if (FLAC__metadata_object_vorbiscomment_entry_matches(object->data.vorbis_comment.comments[i], field_name, field_name_length)) { - if (!FLAC__metadata_object_vorbiscomment_delete_comment(object, i)) - return -1; - else - return 1; - } - } - - return 0; -} - -FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entries_matching(FLAC__StreamMetadata *object, const char *field_name) -{ - FLAC__bool ok = true; - uint32_t matching = 0; - const uint32_t field_name_length = strlen(field_name); - int i; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - /* must delete from end to start otherwise it will interfere with our iteration */ - for (i = (int)object->data.vorbis_comment.num_comments - 1; ok && i >= 0; i--) { - if (FLAC__metadata_object_vorbiscomment_entry_matches(object->data.vorbis_comment.comments[i], field_name, field_name_length)) { - matching++; - ok &= FLAC__metadata_object_vorbiscomment_delete_comment(object, (uint32_t)i); - } - } - - return ok? (int)matching : -1; -} - -FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_new(void) -{ - return calloc(1, sizeof(FLAC__StreamMetadata_CueSheet_Track)); -} - -FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_clone(const FLAC__StreamMetadata_CueSheet_Track *object) -{ - FLAC__StreamMetadata_CueSheet_Track *to; - - FLAC__ASSERT(object != NULL); - - if ((to = FLAC__metadata_object_cuesheet_track_new()) != NULL) { - if (!copy_track_(to, object)) { - FLAC__metadata_object_cuesheet_track_delete(to); - return 0; - } - } - - return to; -} - -void FLAC__metadata_object_cuesheet_track_delete_data(FLAC__StreamMetadata_CueSheet_Track *object) -{ - FLAC__ASSERT(object != NULL); - - if (object->indices != NULL) { - FLAC__ASSERT(object->num_indices > 0); - free(object->indices); - } -} - -FLAC_API void FLAC__metadata_object_cuesheet_track_delete(FLAC__StreamMetadata_CueSheet_Track *object) -{ - FLAC__metadata_object_cuesheet_track_delete_data(object); - free(object); -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t new_num_indices) -{ - FLAC__StreamMetadata_CueSheet_Track *track; - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks); - - track = &object->data.cue_sheet.tracks[track_num]; - - if (track->indices == NULL) { - FLAC__ASSERT(track->num_indices == 0); - if (new_num_indices == 0) - return true; - else if ((track->indices = cuesheet_track_index_array_new_(new_num_indices)) == NULL) - return false; - } - else { - const size_t old_size = track->num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index); - const size_t new_size = new_num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index); - - /* overflow check */ - if (new_num_indices > UINT32_MAX / sizeof(FLAC__StreamMetadata_CueSheet_Index)) - return false; - - FLAC__ASSERT(track->num_indices > 0); - - if (new_size == 0) { - free(track->indices); - track->indices = 0; - } - else { - /* Leave track->indices untouched if realloc fails */ - FLAC__StreamMetadata_CueSheet_Index *tmpptr; - if ((tmpptr = realloc(track->indices, new_size)) == NULL) - return false; - track->indices = tmpptr; - } - - /* if growing, zero all the lengths/pointers of new elements */ - if (new_size > old_size) - memset(track->indices + track->num_indices, 0, new_size - old_size); - } - - track->num_indices = new_num_indices; - - cuesheet_calculate_length_(object); - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num, FLAC__StreamMetadata_CueSheet_Index indx) -{ - FLAC__StreamMetadata_CueSheet_Track *track; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks); - FLAC__ASSERT(index_num <= object->data.cue_sheet.tracks[track_num].num_indices); - - track = &object->data.cue_sheet.tracks[track_num]; - - if (!FLAC__metadata_object_cuesheet_track_resize_indices(object, track_num, track->num_indices+1)) - return false; - - /* move all indices >= index_num forward one space */ - memmove(&track->indices[index_num+1], &track->indices[index_num], sizeof(FLAC__StreamMetadata_CueSheet_Index)*(track->num_indices-1-index_num)); - - track->indices[index_num] = indx; - cuesheet_calculate_length_(object); - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num) -{ - FLAC__StreamMetadata_CueSheet_Index indx; - memset(&indx, 0, sizeof(indx)); - return FLAC__metadata_object_cuesheet_track_insert_index(object, track_num, index_num, indx); -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num) -{ - FLAC__StreamMetadata_CueSheet_Track *track; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks); - FLAC__ASSERT(index_num < object->data.cue_sheet.tracks[track_num].num_indices); - - track = &object->data.cue_sheet.tracks[track_num]; - - /* move all indices > index_num backward one space */ - memmove(&track->indices[index_num], &track->indices[index_num+1], sizeof(FLAC__StreamMetadata_CueSheet_Index)*(track->num_indices-index_num-1)); - - FLAC__metadata_object_cuesheet_track_resize_indices(object, track_num, track->num_indices-1); - cuesheet_calculate_length_(object); - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, uint32_t new_num_tracks) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - - if (object->data.cue_sheet.tracks == NULL) { - FLAC__ASSERT(object->data.cue_sheet.num_tracks == 0); - if (new_num_tracks == 0) - return true; - else if ((object->data.cue_sheet.tracks = cuesheet_track_array_new_(new_num_tracks)) == NULL) - return false; - } - else { - const size_t old_size = object->data.cue_sheet.num_tracks * sizeof(FLAC__StreamMetadata_CueSheet_Track); - const size_t new_size = new_num_tracks * sizeof(FLAC__StreamMetadata_CueSheet_Track); - - /* overflow check */ - if (new_num_tracks > UINT32_MAX / sizeof(FLAC__StreamMetadata_CueSheet_Track)) - return false; - - FLAC__ASSERT(object->data.cue_sheet.num_tracks > 0); - - /* if shrinking, free the truncated entries */ - if (new_num_tracks < object->data.cue_sheet.num_tracks) { - uint32_t i; - for (i = new_num_tracks; i < object->data.cue_sheet.num_tracks; i++) - free(object->data.cue_sheet.tracks[i].indices); - } - - if (new_size == 0) { - free(object->data.cue_sheet.tracks); - object->data.cue_sheet.tracks = 0; - } - else { - /* Leave object->data.cue_sheet.tracks untouched if realloc fails */ - FLAC__StreamMetadata_CueSheet_Track *tmpptr; - if ((tmpptr = realloc(object->data.cue_sheet.tracks, new_size)) == NULL) - return false; - object->data.cue_sheet.tracks = tmpptr; - } - - /* if growing, zero all the lengths/pointers of new elements */ - if (new_size > old_size) - memset(object->data.cue_sheet.tracks + object->data.cue_sheet.num_tracks, 0, new_size - old_size); - } - - object->data.cue_sheet.num_tracks = new_num_tracks; - - cuesheet_calculate_length_(object); - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks); - - return cuesheet_set_track_(object, object->data.cue_sheet.tracks + track_num, track, copy); -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy) -{ - FLAC__StreamMetadata_CueSheet *cs; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - FLAC__ASSERT(track_num <= object->data.cue_sheet.num_tracks); - - cs = &object->data.cue_sheet; - - if (!FLAC__metadata_object_cuesheet_resize_tracks(object, cs->num_tracks+1)) - return false; - - /* move all tracks >= track_num forward one space */ - memmove(&cs->tracks[track_num+1], &cs->tracks[track_num], sizeof(FLAC__StreamMetadata_CueSheet_Track)*(cs->num_tracks-1-track_num)); - cs->tracks[track_num].num_indices = 0; - cs->tracks[track_num].indices = 0; - - return FLAC__metadata_object_cuesheet_set_track(object, track_num, track, copy); -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, uint32_t track_num) -{ - FLAC__StreamMetadata_CueSheet_Track track; - memset(&track, 0, sizeof(track)); - return FLAC__metadata_object_cuesheet_insert_track(object, track_num, &track, /*copy=*/false); -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, uint32_t track_num) -{ - FLAC__StreamMetadata_CueSheet *cs; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks); - - cs = &object->data.cue_sheet; - - /* free the track at track_num */ - free(cs->tracks[track_num].indices); - - /* move all tracks > track_num backward one space */ - memmove(&cs->tracks[track_num], &cs->tracks[track_num+1], sizeof(FLAC__StreamMetadata_CueSheet_Track)*(cs->num_tracks-track_num-1)); - cs->tracks[cs->num_tracks-1].num_indices = 0; - cs->tracks[cs->num_tracks-1].indices = 0; - - return FLAC__metadata_object_cuesheet_resize_tracks(object, cs->num_tracks-1); -} - -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_is_legal(const FLAC__StreamMetadata *object, FLAC__bool check_cd_da_subset, const char **violation) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - - return FLAC__format_cuesheet_is_legal(&object->data.cue_sheet, check_cd_da_subset, violation); -} - -static FLAC__uint64 get_index_01_offset_(const FLAC__StreamMetadata_CueSheet *cs, uint32_t track) -{ - if (track >= (cs->num_tracks-1) || cs->tracks[track].num_indices < 1) - return 0; - else if (cs->tracks[track].indices[0].number == 1) - return cs->tracks[track].indices[0].offset + cs->tracks[track].offset + cs->lead_in; - else if (cs->tracks[track].num_indices < 2) - return 0; - else if (cs->tracks[track].indices[1].number == 1) - return cs->tracks[track].indices[1].offset + cs->tracks[track].offset + cs->lead_in; - else - return 0; -} - -static FLAC__uint32 cddb_add_digits_(FLAC__uint32 x) -{ - FLAC__uint32 n = 0; - while (x) { - n += (x%10); - x /= 10; - } - return n; -} - -/*@@@@add to tests*/ -FLAC_API FLAC__uint32 FLAC__metadata_object_cuesheet_calculate_cddb_id(const FLAC__StreamMetadata *object) -{ - const FLAC__StreamMetadata_CueSheet *cs; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); - - cs = &object->data.cue_sheet; - - if (cs->num_tracks < 2) /* need at least one real track and the lead-out track */ - return 0; - - { - FLAC__uint32 i, length, sum = 0; - for (i = 0; i < (cs->num_tracks-1); i++) /* -1 to avoid counting the lead-out */ - sum += cddb_add_digits_((FLAC__uint32)(get_index_01_offset_(cs, i) / 44100)); - length = (FLAC__uint32)((cs->tracks[cs->num_tracks-1].offset+cs->lead_in) / 44100) - (FLAC__uint32)(get_index_01_offset_(cs, 0) / 44100); - - return (sum % 0xFF) << 24 | length << 8 | (FLAC__uint32)(cs->num_tracks-1); - } -} - -FLAC_API FLAC__bool FLAC__metadata_object_picture_set_mime_type(FLAC__StreamMetadata *object, char *mime_type, FLAC__bool copy) -{ - char *old; - size_t old_length, new_length; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_PICTURE); - FLAC__ASSERT(mime_type != NULL); - - old = object->data.picture.mime_type; - old_length = old? strlen(old) : 0; - new_length = strlen(mime_type); - - /* do the copy first so that if we fail we leave the object untouched */ - if (copy) { - if (new_length >= SIZE_MAX) /* overflow check */ - return false; - if (!copy_bytes_((FLAC__byte**)(&object->data.picture.mime_type), (FLAC__byte*)mime_type, new_length+1)) - return false; - } - else { - object->data.picture.mime_type = mime_type; - } - - free(old); - - object->length -= old_length; - object->length += new_length; - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_picture_set_description(FLAC__StreamMetadata *object, FLAC__byte *description, FLAC__bool copy) -{ - FLAC__byte *old; - size_t old_length, new_length; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_PICTURE); - FLAC__ASSERT(description != NULL); - - old = object->data.picture.description; - old_length = old? strlen((const char *)old) : 0; - new_length = strlen((const char *)description); - - /* do the copy first so that if we fail we leave the object untouched */ - if (copy) { - if (new_length >= SIZE_MAX) /* overflow check */ - return false; - if (!copy_bytes_(&object->data.picture.description, description, new_length+1)) - return false; - } - else { - object->data.picture.description = description; - } - - free(old); - - object->length -= old_length; - object->length += new_length; - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, FLAC__uint32 length, FLAC__bool copy) -{ - FLAC__byte *old; - - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_PICTURE); - FLAC__ASSERT((data != NULL && length > 0) || (data == NULL && length == 0 && copy == false)); - - old = object->data.picture.data; - - /* do the copy first so that if we fail we leave the object untouched */ - if (copy) { - if (!copy_bytes_(&object->data.picture.data, data, length)) - return false; - } - else { - object->data.picture.data = data; - } - - free(old); - - object->length -= object->data.picture.data_length; - object->data.picture.data_length = length; - object->length += length; - return true; -} - -FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMetadata *object, const char **violation) -{ - FLAC__ASSERT(object != NULL); - FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_PICTURE); - - return FLAC__format_picture_is_legal(&object->data.picture, violation); -} - -FLAC_API FLAC__byte * FLAC__metadata_object_get_raw(const FLAC__StreamMetadata *object) -{ - FLAC__BitWriter *bw; - const FLAC__byte * buffer; - FLAC__byte * output; - size_t bytes; - - FLAC__ASSERT(object != NULL); - - if((bw = FLAC__bitwriter_new()) == NULL) - return 0; - if(!FLAC__bitwriter_init(bw)) { - FLAC__bitwriter_delete(bw); - return 0; - } - if(!FLAC__add_metadata_block(object, bw, false)) { - FLAC__bitwriter_delete(bw); - return 0; - } - - if(!FLAC__bitwriter_get_buffer(bw, &buffer, &bytes)) { - FLAC__bitwriter_delete(bw); - return 0; - } - - /* Extra check whether length of bitwriter agrees with length of metadata block */ - if(bytes != (object->length+FLAC__STREAM_METADATA_HEADER_LENGTH)) { - FLAC__bitwriter_delete(bw); - return 0; - } - - output = safe_malloc_(bytes); - if(output == 0) { - FLAC__bitwriter_delete(bw); - return 0; - } - - memcpy(output,buffer,bytes); - FLAC__bitwriter_delete(bw); - return output; -} - -/* The following callbacks are for FLAC__metadata_object_set_raw */ - -static FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte *buffer, size_t *bytes, void *client_data); -static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); -static void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); -static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); - -typedef struct { - FLAC__StreamMetadata *object; - FLAC__bool got_error; - FLAC__byte *buffer; - FLAC__int32 length; - FLAC__int32 tell; -} set_raw_client_data; - -FLAC_API FLAC__StreamMetadata * FLAC__metadata_object_set_raw(FLAC__byte *buffer, FLAC__uint32 length) -{ - set_raw_client_data cd; - FLAC__StreamDecoder * decoder; - - cd.buffer = buffer; - cd.length = length; - cd.got_error = false; - cd.object = 0; - cd.tell = -4; - - decoder = FLAC__stream_decoder_new(); - - if(0 == decoder) - return 0; - - FLAC__stream_decoder_set_md5_checking(decoder, false); - FLAC__stream_decoder_set_metadata_respond_all(decoder); - - if(FLAC__stream_decoder_init_stream(decoder, read_callback_, NULL, NULL, NULL, NULL, write_callback_, metadata_callback_, error_callback_, &cd) != FLAC__STREAM_DECODER_INIT_STATUS_OK || cd.got_error) { - (void)FLAC__stream_decoder_finish(decoder); - FLAC__stream_decoder_delete(decoder); - return 0; - } - - if((!FLAC__stream_decoder_process_until_end_of_metadata(decoder) && FLAC__stream_decoder_get_state(decoder) != FLAC__STREAM_DECODER_END_OF_STREAM) || cd.got_error) { - (void)FLAC__stream_decoder_finish(decoder); - FLAC__stream_decoder_delete(decoder); - if(0 != cd.object) - FLAC__metadata_object_delete(cd.object); - return 0; - } - - (void)FLAC__stream_decoder_finish(decoder); - FLAC__stream_decoder_delete(decoder); - - return cd.object; - -} - -FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte *buffer, size_t *bytes, void *client_data) -{ - set_raw_client_data *cd = (set_raw_client_data *)client_data; - (void)decoder; - - if(cd->tell == -4) { - if(*bytes < 4) - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - buffer[0] = 'f'; - buffer[1] = 'L'; - buffer[2] = 'a'; - buffer[3] = 'C'; - *bytes = 4; - cd->tell = 0; - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - else if(cd->tell < 0) - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - else if(cd->tell == cd->length) { - *bytes = 0; - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } - else { - if((FLAC__int32)(*bytes) > (cd->length - cd->tell)) - *bytes = cd->length - cd->tell; - memcpy(buffer, cd->buffer+cd->tell, *bytes); - cd->tell += *bytes; - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } -} - -FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - (void)decoder, (void)frame, (void)buffer, (void)client_data; - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - set_raw_client_data *cd = (set_raw_client_data *)client_data; - (void)decoder; - - /* - * we assume we only get here when the one metadata block we were - * looking for was passed to us - */ - if(!cd->got_error && 0 == cd->object) { - if(0 == (cd->object = FLAC__metadata_object_clone(metadata))) - cd->got_error = true; - } -} - -void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - set_raw_client_data *cd = (set_raw_client_data *)client_data; - (void)decoder; - - if(status != FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC) - cd->got_error = true; -} diff --git a/Engine/lib/flac/src/libFLAC/ogg_decoder_aspect.c b/Engine/lib/flac/src/libFLAC/ogg_decoder_aspect.c deleted file mode 100644 index 58a293460..000000000 --- a/Engine/lib/flac/src/libFLAC/ogg_decoder_aspect.c +++ /dev/null @@ -1,251 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include /* for memcpy() */ -#include "FLAC/assert.h" -#include "private/ogg_decoder_aspect.h" -#include "private/ogg_mapping.h" -#include "private/macros.h" - - -/*********************************************************************** - * - * Public class methods - * - ***********************************************************************/ - -FLAC__bool FLAC__ogg_decoder_aspect_init(FLAC__OggDecoderAspect *aspect) -{ - /* we will determine the serial number later if necessary */ - if(ogg_stream_init(&aspect->stream_state, aspect->serial_number) != 0) - return false; - - if(ogg_sync_init(&aspect->sync_state) != 0) - return false; - - aspect->version_major = ~(0u); - aspect->version_minor = ~(0u); - - aspect->need_serial_number = aspect->use_first_serial_number; - - aspect->end_of_stream = false; - aspect->have_working_page = false; - - return true; -} - -void FLAC__ogg_decoder_aspect_finish(FLAC__OggDecoderAspect *aspect) -{ - (void)ogg_sync_clear(&aspect->sync_state); - (void)ogg_stream_clear(&aspect->stream_state); -} - -void FLAC__ogg_decoder_aspect_set_serial_number(FLAC__OggDecoderAspect *aspect, long value) -{ - aspect->use_first_serial_number = false; - aspect->serial_number = value; -} - -void FLAC__ogg_decoder_aspect_set_defaults(FLAC__OggDecoderAspect *aspect) -{ - aspect->use_first_serial_number = true; -} - -void FLAC__ogg_decoder_aspect_flush(FLAC__OggDecoderAspect *aspect) -{ - (void)ogg_stream_reset(&aspect->stream_state); - (void)ogg_sync_reset(&aspect->sync_state); - aspect->end_of_stream = false; - aspect->have_working_page = false; -} - -void FLAC__ogg_decoder_aspect_reset(FLAC__OggDecoderAspect *aspect) -{ - FLAC__ogg_decoder_aspect_flush(aspect); - - if(aspect->use_first_serial_number) - aspect->need_serial_number = true; -} - -FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper(FLAC__OggDecoderAspect *aspect, FLAC__byte buffer[], size_t *bytes, FLAC__OggDecoderAspectReadCallbackProxy read_callback, const FLAC__StreamDecoder *decoder, void *client_data) -{ - static const size_t OGG_BYTES_CHUNK = 8192; - const size_t bytes_requested = *bytes; - - /* - * The FLAC decoding API uses pull-based reads, whereas Ogg decoding - * is push-based. In libFLAC, when you ask to decode a frame, the - * decoder will eventually call the read callback to supply some data, - * but how much it asks for depends on how much free space it has in - * its internal buffer. It does not try to grow its internal buffer - * to accommodate a whole frame because then the internal buffer size - * could not be limited, which is necessary in embedded applications. - * - * Ogg however grows its internal buffer until a whole page is present; - * only then can you get decoded data out. So we can't just ask for - * the same number of bytes from Ogg, then pass what's decoded down to - * libFLAC. If what libFLAC is asking for will not contain a whole - * page, then we will get no data from ogg_sync_pageout(), and at the - * same time cannot just read more data from the client for the purpose - * of getting a whole decoded page because the decoded size might be - * larger than libFLAC's internal buffer. - * - * Instead, whenever this read callback wrapper is called, we will - * continually request data from the client until we have at least one - * page, and manage pages internally so that we can send pieces of - * pages down to libFLAC in such a way that we obey its size - * requirement. To limit the amount of callbacks, we will always try - * to read in enough pages to return the full number of bytes - * requested. - */ - *bytes = 0; - while (*bytes < bytes_requested && !aspect->end_of_stream) { - if (aspect->have_working_page) { - if (aspect->have_working_packet) { - size_t n = bytes_requested - *bytes; - if ((size_t)aspect->working_packet.bytes <= n) { - /* the rest of the packet will fit in the buffer */ - n = aspect->working_packet.bytes; - memcpy(buffer, aspect->working_packet.packet, n); - *bytes += n; - buffer += n; - aspect->have_working_packet = false; - } - else { - /* only n bytes of the packet will fit in the buffer */ - memcpy(buffer, aspect->working_packet.packet, n); - *bytes += n; - buffer += n; - aspect->working_packet.packet += n; - aspect->working_packet.bytes -= n; - } - } - else { - /* try and get another packet */ - const int ret = ogg_stream_packetout(&aspect->stream_state, &aspect->working_packet); - if (ret > 0) { - aspect->have_working_packet = true; - /* if it is the first header packet, check for magic and a supported Ogg FLAC mapping version */ - if (aspect->working_packet.bytes > 0 && aspect->working_packet.packet[0] == FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE) { - const FLAC__byte *b = aspect->working_packet.packet; - const uint32_t header_length = - FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH + - FLAC__OGG_MAPPING_MAGIC_LENGTH + - FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH + - FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH + - FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH; - if (aspect->working_packet.bytes < (long)header_length) - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC; - b += FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH; - if (memcmp(b, FLAC__OGG_MAPPING_MAGIC, FLAC__OGG_MAPPING_MAGIC_LENGTH)) - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC; - b += FLAC__OGG_MAPPING_MAGIC_LENGTH; - aspect->version_major = (uint32_t)(*b); - b += FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH; - aspect->version_minor = (uint32_t)(*b); - if (aspect->version_major != 1) - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION; - aspect->working_packet.packet += header_length; - aspect->working_packet.bytes -= header_length; - } - } - else if (ret == 0) { - aspect->have_working_page = false; - } - else { /* ret < 0 */ - /* lost sync, we'll leave the working page for the next call */ - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC; - } - } - } - else { - /* try and get another page */ - const int ret = ogg_sync_pageout(&aspect->sync_state, &aspect->working_page); - if (ret > 0) { - /* got a page, grab the serial number if necessary */ - if(aspect->need_serial_number) { - aspect->stream_state.serialno = aspect->serial_number = ogg_page_serialno(&aspect->working_page); - aspect->need_serial_number = false; - } - if(ogg_stream_pagein(&aspect->stream_state, &aspect->working_page) == 0) { - aspect->have_working_page = true; - aspect->have_working_packet = false; - } - /* else do nothing, could be a page from another stream */ - } - else if (ret == 0) { - /* need more data */ - const size_t ogg_bytes_to_read = flac_max(bytes_requested - *bytes, OGG_BYTES_CHUNK); - char *oggbuf = ogg_sync_buffer(&aspect->sync_state, ogg_bytes_to_read); - - if(0 == oggbuf) { - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_MEMORY_ALLOCATION_ERROR; - } - else { - size_t ogg_bytes_read = ogg_bytes_to_read; - - switch(read_callback(decoder, (FLAC__byte*)oggbuf, &ogg_bytes_read, client_data)) { - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK: - break; - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM: - aspect->end_of_stream = true; - break; - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT: - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT; - default: - FLAC__ASSERT(0); - } - - if(ogg_sync_wrote(&aspect->sync_state, ogg_bytes_read) < 0) { - /* double protection; this will happen if the read callback returns more bytes than the max requested, which would overflow Ogg's internal buffer */ - FLAC__ASSERT(0); - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ERROR; - } - } - } - else { /* ret < 0 */ - /* lost sync, bail out */ - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC; - } - } - } - - if (aspect->end_of_stream && *bytes == 0) { - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM; - } - - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK; -} diff --git a/Engine/lib/flac/src/libFLAC/ogg_encoder_aspect.c b/Engine/lib/flac/src/libFLAC/ogg_encoder_aspect.c deleted file mode 100644 index a88713b14..000000000 --- a/Engine/lib/flac/src/libFLAC/ogg_encoder_aspect.c +++ /dev/null @@ -1,228 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include /* for memset() */ -#include "FLAC/assert.h" -#include "private/ogg_encoder_aspect.h" -#include "private/ogg_mapping.h" - -static const FLAC__byte FLAC__OGG_MAPPING_VERSION_MAJOR = 1; -static const FLAC__byte FLAC__OGG_MAPPING_VERSION_MINOR = 0; - -/*********************************************************************** - * - * Public class methods - * - ***********************************************************************/ - -FLAC__bool FLAC__ogg_encoder_aspect_init(FLAC__OggEncoderAspect *aspect) -{ - /* we will determine the serial number later if necessary */ - if(ogg_stream_init(&aspect->stream_state, aspect->serial_number) != 0) - return false; - - aspect->seen_magic = false; - aspect->is_first_packet = true; - aspect->samples_written = 0; - - return true; -} - -void FLAC__ogg_encoder_aspect_finish(FLAC__OggEncoderAspect *aspect) -{ - (void)ogg_stream_clear(&aspect->stream_state); - /*@@@ what about the page? */ -} - -void FLAC__ogg_encoder_aspect_set_serial_number(FLAC__OggEncoderAspect *aspect, long value) -{ - aspect->serial_number = value; -} - -FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, uint32_t value) -{ - if(value < (1u << FLAC__OGG_MAPPING_NUM_HEADERS_LEN)) { - aspect->num_metadata = value; - return true; - } - else - return false; -} - -void FLAC__ogg_encoder_aspect_set_defaults(FLAC__OggEncoderAspect *aspect) -{ - aspect->serial_number = 0; - aspect->num_metadata = 0; -} - -/* - * The basic FLAC -> Ogg mapping goes like this: - * - * - 'fLaC' magic and STREAMINFO block get combined into the first - * packet. The packet is prefixed with - * + the one-byte packet type 0x7F - * + 'FLAC' magic - * + the 2 byte Ogg FLAC mapping version number - * + tne 2 byte big-endian # of header packets - * - The first packet is flushed to the first page. - * - Each subsequent metadata block goes into its own packet. - * - Each metadata packet is flushed to page (this is not required, - * the mapping only requires that a flush must occur after all - * metadata is written). - * - Each subsequent FLAC audio frame goes into its own packet. - * - * WATCHOUT: - * This depends on the behavior of FLAC__StreamEncoder that we get a - * separate write callback for the fLaC magic, and then separate write - * callbacks for each metadata block and audio frame. - */ -FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data) -{ - /* WATCHOUT: - * This depends on the behavior of FLAC__StreamEncoder that 'samples' - * will be 0 for metadata writes. - */ - const FLAC__bool is_metadata = (samples == 0); - - /* - * Treat fLaC magic packet specially. We will note when we see it, then - * wait until we get the STREAMINFO and prepend it in that packet - */ - if(aspect->seen_magic) { - ogg_packet packet; - FLAC__byte synthetic_first_packet_body[ - FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH + - FLAC__OGG_MAPPING_MAGIC_LENGTH + - FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH + - FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH + - FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH + - FLAC__STREAM_SYNC_LENGTH + - FLAC__STREAM_METADATA_HEADER_LENGTH + - FLAC__STREAM_METADATA_STREAMINFO_LENGTH - ]; - - memset(&packet, 0, sizeof(packet)); - packet.granulepos = aspect->samples_written + samples; - - if(aspect->is_first_packet) { - FLAC__byte *b = synthetic_first_packet_body; - if(bytes != FLAC__STREAM_METADATA_HEADER_LENGTH + FLAC__STREAM_METADATA_STREAMINFO_LENGTH) { - /* - * If we get here, our assumption about the way write callbacks happen - * (explained above) is wrong - */ - FLAC__ASSERT(0); - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - } - /* add first header packet type */ - *b = FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE; - b += FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH; - /* add 'FLAC' mapping magic */ - memcpy(b, FLAC__OGG_MAPPING_MAGIC, FLAC__OGG_MAPPING_MAGIC_LENGTH); - b += FLAC__OGG_MAPPING_MAGIC_LENGTH; - /* add Ogg FLAC mapping major version number */ - memcpy(b, &FLAC__OGG_MAPPING_VERSION_MAJOR, FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH); - b += FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH; - /* add Ogg FLAC mapping minor version number */ - memcpy(b, &FLAC__OGG_MAPPING_VERSION_MINOR, FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH); - b += FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH; - /* add number of header packets */ - *b = (FLAC__byte)(aspect->num_metadata >> 8); - b++; - *b = (FLAC__byte)(aspect->num_metadata); - b++; - /* add native FLAC 'fLaC' magic */ - memcpy(b, FLAC__STREAM_SYNC_STRING, FLAC__STREAM_SYNC_LENGTH); - b += FLAC__STREAM_SYNC_LENGTH; - /* add STREAMINFO */ - memcpy(b, buffer, bytes); - FLAC__ASSERT(b + bytes - synthetic_first_packet_body == sizeof(synthetic_first_packet_body)); - packet.packet = (uint8_t *)synthetic_first_packet_body; - packet.bytes = sizeof(synthetic_first_packet_body); - - packet.b_o_s = 1; - aspect->is_first_packet = false; - } - else { - packet.packet = (uint8_t *)buffer; - packet.bytes = bytes; - } - - if(is_last_block) { - /* we used to check: - * FLAC__ASSERT(total_samples_estimate == 0 || total_samples_estimate == aspect->samples_written + samples); - * but it's really not useful since total_samples_estimate is an estimate and can be inexact - */ - packet.e_o_s = 1; - } - - if(ogg_stream_packetin(&aspect->stream_state, &packet) != 0) - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - - /*@@@ can't figure out a way to pass a useful number for 'samples' to the write_callback, so we'll just pass 0 */ - if(is_metadata) { - while(ogg_stream_flush(&aspect->stream_state, &aspect->page) != 0) { - if(write_callback(encoder, aspect->page.header, aspect->page.header_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - if(write_callback(encoder, aspect->page.body, aspect->page.body_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - } - } - else { - while(ogg_stream_pageout(&aspect->stream_state, &aspect->page) != 0) { - if(write_callback(encoder, aspect->page.header, aspect->page.header_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - if(write_callback(encoder, aspect->page.body, aspect->page.body_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - } - } - } - else if(is_metadata && current_frame == 0 && samples == 0 && bytes == 4 && 0 == memcmp(buffer, FLAC__STREAM_SYNC_STRING, sizeof(FLAC__STREAM_SYNC_STRING))) { - aspect->seen_magic = true; - } - else { - /* - * If we get here, our assumption about the way write callbacks happen - * explained above is wrong - */ - FLAC__ASSERT(0); - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - } - - aspect->samples_written += samples; - - return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; -} diff --git a/Engine/lib/flac/src/libFLAC/ogg_helper.c b/Engine/lib/flac/src/libFLAC/ogg_helper.c deleted file mode 100644 index a4be34d22..000000000 --- a/Engine/lib/flac/src/libFLAC/ogg_helper.c +++ /dev/null @@ -1,210 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include /* for malloc() */ -#include /* for memcmp(), memcpy() */ -#include "FLAC/assert.h" -#include "share/alloc.h" -#include "private/ogg_helper.h" -#include "protected/stream_encoder.h" - - -static FLAC__bool full_read_(FLAC__StreamEncoder *encoder, FLAC__byte *buffer, size_t bytes, FLAC__StreamEncoderReadCallback read_callback, void *client_data) -{ - while(bytes > 0) { - size_t bytes_read = bytes; - switch(read_callback(encoder, buffer, &bytes_read, client_data)) { - case FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE: - bytes -= bytes_read; - buffer += bytes_read; - break; - case FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM: - if(bytes_read == 0) { - encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; - return false; - } - bytes -= bytes_read; - buffer += bytes_read; - break; - case FLAC__STREAM_ENCODER_READ_STATUS_ABORT: - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - case FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED: - return false; - default: - /* double protection: */ - FLAC__ASSERT(0); - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - } - } - - return true; -} - -void simple_ogg_page__init(ogg_page *page) -{ - page->header = 0; - page->header_len = 0; - page->body = 0; - page->body_len = 0; -} - -void simple_ogg_page__clear(ogg_page *page) -{ - if(page->header) - free(page->header); - if(page->body) - free(page->body); - simple_ogg_page__init(page); -} - -FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderReadCallback read_callback, void *client_data) -{ - static const uint32_t OGG_HEADER_FIXED_PORTION_LEN = 27; - static const uint32_t OGG_MAX_HEADER_LEN = 27/*OGG_HEADER_FIXED_PORTION_LEN*/ + 255; - FLAC__byte crc[4]; - FLAC__StreamEncoderSeekStatus seek_status; - - FLAC__ASSERT(page->header == 0); - FLAC__ASSERT(page->header_len == 0); - FLAC__ASSERT(page->body == 0); - FLAC__ASSERT(page->body_len == 0); - - /* move the stream pointer to the supposed beginning of the page */ - if(0 == seek_callback) - return false; - if((seek_status = seek_callback((FLAC__StreamEncoder*)encoder, position, client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) { - if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR) - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - } - - /* allocate space for the page header */ - if(0 == (page->header = safe_malloc_(OGG_MAX_HEADER_LEN))) { - encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; - return false; - } - - /* read in the fixed part of the page header (up to but not including - * the segment table */ - if(!full_read_(encoder, page->header, OGG_HEADER_FIXED_PORTION_LEN, read_callback, client_data)) - return false; - - page->header_len = OGG_HEADER_FIXED_PORTION_LEN + page->header[26]; - - /* check to see if it's a correct, "simple" page (one packet only) */ - if( - memcmp(page->header, "OggS", 4) || /* doesn't start with OggS */ - (page->header[5] & 0x01) || /* continued packet */ - memcmp(page->header+6, "\0\0\0\0\0\0\0\0", 8) || /* granulepos is non-zero */ - page->header[26] == 0 /* packet is 0-size */ - ) { - encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; - return false; - } - - /* read in the segment table */ - if(!full_read_(encoder, page->header + OGG_HEADER_FIXED_PORTION_LEN, page->header[26], read_callback, client_data)) - return false; - - { - uint32_t i; - - /* check to see that it specifies a single packet */ - for(i = 0; i < (uint32_t)page->header[26] - 1; i++) { - if(page->header[i + OGG_HEADER_FIXED_PORTION_LEN] != 255) { - encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; - return false; - } - } - - page->body_len = 255 * i + page->header[i + OGG_HEADER_FIXED_PORTION_LEN]; - } - - /* allocate space for the page body */ - if(0 == (page->body = safe_malloc_(page->body_len))) { - encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; - return false; - } - - /* read in the page body */ - if(!full_read_(encoder, page->body, page->body_len, read_callback, client_data)) - return false; - - /* check the CRC */ - memcpy(crc, page->header+22, 4); - ogg_page_checksum_set(page); - if(memcmp(crc, page->header+22, 4)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; - return false; - } - - return true; -} - -FLAC__bool simple_ogg_page__set_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderWriteCallback write_callback, void *client_data) -{ - FLAC__StreamEncoderSeekStatus seek_status; - - FLAC__ASSERT(page->header != 0); - FLAC__ASSERT(page->header_len != 0); - FLAC__ASSERT(page->body != 0); - FLAC__ASSERT(page->body_len != 0); - - /* move the stream pointer to the supposed beginning of the page */ - if(0 == seek_callback) - return false; - if((seek_status = seek_callback((FLAC__StreamEncoder*)encoder, position, client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) { - if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR) - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - } - - ogg_page_checksum_set(page); - - /* re-write the page */ - if(write_callback((FLAC__StreamEncoder*)encoder, page->header, page->header_len, 0, 0, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - } - if(write_callback((FLAC__StreamEncoder*)encoder, page->body, page->body_len, 0, 0, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - } - - return true; -} diff --git a/Engine/lib/flac/src/libFLAC/ogg_mapping.c b/Engine/lib/flac/src/libFLAC/ogg_mapping.c deleted file mode 100644 index 756c7165b..000000000 --- a/Engine/lib/flac/src/libFLAC/ogg_mapping.c +++ /dev/null @@ -1,48 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/ogg_mapping.h" - -const uint32_t FLAC__OGG_MAPPING_PACKET_TYPE_LEN = 8; /* bits */ - -const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE = 0x7f; - -const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC = (const FLAC__byte * const)"FLAC"; - -const uint32_t FLAC__OGG_MAPPING_VERSION_MAJOR_LEN = 8; /* bits */ -const uint32_t FLAC__OGG_MAPPING_VERSION_MINOR_LEN = 8; /* bits */ - -const uint32_t FLAC__OGG_MAPPING_NUM_HEADERS_LEN = 16; /* bits */ diff --git a/Engine/lib/flac/src/libFLAC/stream_decoder.c b/Engine/lib/flac/src/libFLAC/stream_decoder.c deleted file mode 100644 index 18d8dd3b2..000000000 --- a/Engine/lib/flac/src/libFLAC/stream_decoder.c +++ /dev/null @@ -1,3731 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include /* for malloc() */ -#include /* for memset/memcpy() */ -#include /* for off_t */ -#include /* for stat() */ -#include "share/compat.h" -#include "FLAC/assert.h" -#include "share/alloc.h" -#include "protected/stream_decoder.h" -#include "private/bitreader.h" -#include "private/bitmath.h" -#include "private/cpu.h" -#include "private/crc.h" -#include "private/fixed.h" -#include "private/format.h" -#include "private/lpc.h" -#include "private/md5.h" -#include "private/memory.h" -#include "private/macros.h" - - -/* technically this should be in an "export.c" but this is convenient enough */ -FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC = FLAC__HAS_OGG; - - -/*********************************************************************** - * - * Private static data - * - ***********************************************************************/ - -static const FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' }; - -/*********************************************************************** - * - * Private class method prototypes - * - ***********************************************************************/ - -static void set_defaults_(FLAC__StreamDecoder *decoder); -static FILE *get_binary_stdin_(void); -static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_t bps); -static FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id); -static FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder); -static FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder); -static FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length); -static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length); -static FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, uint32_t length); -static FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj); -static FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj); -static FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder); -static FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder); -static FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode); -static FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder); -static FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode); -static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode); -static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode); -static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode); -static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode); -static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, uint32_t partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended); -static FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder); -static void undo_channel_coding(FLAC__StreamDecoder *decoder); -static FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data); -#if FLAC__HAS_OGG -static FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes); -static FLAC__OggDecoderAspectReadStatus read_callback_proxy_(const void *void_decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); -#endif -static FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[]); -static void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status); -static FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample); -#if FLAC__HAS_OGG -static FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample); -#endif -static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); -static FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data); -static FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); -static FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data); -static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data); - -/*********************************************************************** - * - * Private class data - * - ***********************************************************************/ - -typedef struct FLAC__StreamDecoderPrivate { - FLAC__bool is_ogg; - FLAC__StreamDecoderReadCallback read_callback; - FLAC__StreamDecoderSeekCallback seek_callback; - FLAC__StreamDecoderTellCallback tell_callback; - FLAC__StreamDecoderLengthCallback length_callback; - FLAC__StreamDecoderEofCallback eof_callback; - FLAC__StreamDecoderWriteCallback write_callback; - FLAC__StreamDecoderMetadataCallback metadata_callback; - FLAC__StreamDecoderErrorCallback error_callback; - void *client_data; - FILE *file; /* only used if FLAC__stream_decoder_init_file()/FLAC__stream_decoder_init_file() called, else NULL */ - FLAC__BitReader *input; - FLAC__int32 *output[FLAC__MAX_CHANNELS]; - FLAC__int32 *residual[FLAC__MAX_CHANNELS]; /* WATCHOUT: these are the aligned pointers; the real pointers that should be free()'d are residual_unaligned[] below */ - FLAC__int64 *side_subframe; - FLAC__bool side_subframe_in_use; - FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents[FLAC__MAX_CHANNELS]; - uint32_t output_capacity, output_channels; - FLAC__uint32 fixed_block_size, next_fixed_block_size; - FLAC__uint64 samples_decoded; - FLAC__bool has_stream_info, has_seek_table; - FLAC__StreamMetadata stream_info; - FLAC__StreamMetadata seek_table; - FLAC__bool metadata_filter[128]; /* MAGIC number 128 == total number of metadata block types == 1 << 7 */ - FLAC__byte *metadata_filter_ids; - size_t metadata_filter_ids_count, metadata_filter_ids_capacity; /* units for both are IDs, not bytes */ - FLAC__Frame frame; - FLAC__bool cached; /* true if there is a byte in lookahead */ - FLAC__CPUInfo cpuinfo; - FLAC__byte header_warmup[2]; /* contains the sync code and reserved bits */ - FLAC__byte lookahead; /* temp storage when we need to look ahead one byte in the stream */ - /* unaligned (original) pointers to allocated data */ - FLAC__int32 *residual_unaligned[FLAC__MAX_CHANNELS]; - FLAC__bool do_md5_checking; /* initially gets protected_->md5_checking but is turned off after a seek or if the metadata has a zero MD5 */ - FLAC__bool internal_reset_hack; /* used only during init() so we can call reset to set up the decoder without rewinding the input */ - FLAC__bool is_seeking; - FLAC__MD5Context md5context; - FLAC__byte computed_md5sum[16]; /* this is the sum we computed from the decoded data */ - /* (the rest of these are only used for seeking) */ - FLAC__Frame last_frame; /* holds the info of the last frame we decoded or seeked to */ - FLAC__bool last_frame_is_set; - FLAC__uint64 first_frame_offset; /* hint to the seek routine of where in the stream the first audio frame starts */ - FLAC__uint64 last_seen_framesync; /* if tell callback works, the location of the last seen frame sync code, to rewind to if needed */ - FLAC__uint64 target_sample; - uint32_t unparseable_frame_count; /* used to tell whether we're decoding a future version of FLAC or just got a bad sync */ - FLAC__bool got_a_frame; /* hack needed in Ogg FLAC seek routine to check when process_single() actually writes a frame */ - FLAC__bool (*local_bitreader_read_rice_signed_block)(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); -} FLAC__StreamDecoderPrivate; - -/*********************************************************************** - * - * Public static class data - * - ***********************************************************************/ - -FLAC_API const char * const FLAC__StreamDecoderStateString[] = { - "FLAC__STREAM_DECODER_SEARCH_FOR_METADATA", - "FLAC__STREAM_DECODER_READ_METADATA", - "FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC", - "FLAC__STREAM_DECODER_READ_FRAME", - "FLAC__STREAM_DECODER_END_OF_STREAM", - "FLAC__STREAM_DECODER_OGG_ERROR", - "FLAC__STREAM_DECODER_SEEK_ERROR", - "FLAC__STREAM_DECODER_ABORTED", - "FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR", - "FLAC__STREAM_DECODER_UNINITIALIZED" -}; - -FLAC_API const char * const FLAC__StreamDecoderInitStatusString[] = { - "FLAC__STREAM_DECODER_INIT_STATUS_OK", - "FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER", - "FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS", - "FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR", - "FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE", - "FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED" -}; - -FLAC_API const char * const FLAC__StreamDecoderReadStatusString[] = { - "FLAC__STREAM_DECODER_READ_STATUS_CONTINUE", - "FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM", - "FLAC__STREAM_DECODER_READ_STATUS_ABORT" -}; - -FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[] = { - "FLAC__STREAM_DECODER_SEEK_STATUS_OK", - "FLAC__STREAM_DECODER_SEEK_STATUS_ERROR", - "FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED" -}; - -FLAC_API const char * const FLAC__StreamDecoderTellStatusString[] = { - "FLAC__STREAM_DECODER_TELL_STATUS_OK", - "FLAC__STREAM_DECODER_TELL_STATUS_ERROR", - "FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED" -}; - -FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[] = { - "FLAC__STREAM_DECODER_LENGTH_STATUS_OK", - "FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR", - "FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED" -}; - -FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[] = { - "FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE", - "FLAC__STREAM_DECODER_WRITE_STATUS_ABORT" -}; - -FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[] = { - "FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC", - "FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER", - "FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH", - "FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM", - "FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA" -}; - -/*********************************************************************** - * - * Class constructor/destructor - * - ***********************************************************************/ -FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void) -{ - FLAC__StreamDecoder *decoder; - uint32_t i; - - FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */ - - decoder = calloc(1, sizeof(FLAC__StreamDecoder)); - if(decoder == 0) { - return 0; - } - - decoder->protected_ = calloc(1, sizeof(FLAC__StreamDecoderProtected)); - if(decoder->protected_ == 0) { - free(decoder); - return 0; - } - - decoder->private_ = calloc(1, sizeof(FLAC__StreamDecoderPrivate)); - if(decoder->private_ == 0) { - free(decoder->protected_); - free(decoder); - return 0; - } - - decoder->private_->input = FLAC__bitreader_new(); - if(decoder->private_->input == 0) { - free(decoder->private_); - free(decoder->protected_); - free(decoder); - return 0; - } - - decoder->private_->metadata_filter_ids_capacity = 16; - if(0 == (decoder->private_->metadata_filter_ids = malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) * decoder->private_->metadata_filter_ids_capacity))) { - FLAC__bitreader_delete(decoder->private_->input); - free(decoder->private_); - free(decoder->protected_); - free(decoder); - return 0; - } - - for(i = 0; i < FLAC__MAX_CHANNELS; i++) { - decoder->private_->output[i] = 0; - decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; - } - - decoder->private_->side_subframe = 0; - - decoder->private_->output_capacity = 0; - decoder->private_->output_channels = 0; - decoder->private_->has_seek_table = false; - - for(i = 0; i < FLAC__MAX_CHANNELS; i++) - FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&decoder->private_->partitioned_rice_contents[i]); - - decoder->private_->file = 0; - - set_defaults_(decoder); - - decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; - - return decoder; -} - -FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder) -{ - uint32_t i; - - if (decoder == NULL) - return ; - - FLAC__ASSERT(0 != decoder->protected_); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->private_->input); - - (void)FLAC__stream_decoder_finish(decoder); - - if(0 != decoder->private_->metadata_filter_ids) - free(decoder->private_->metadata_filter_ids); - - FLAC__bitreader_delete(decoder->private_->input); - - for(i = 0; i < FLAC__MAX_CHANNELS; i++) - FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&decoder->private_->partitioned_rice_contents[i]); - - free(decoder->private_); - free(decoder->protected_); - free(decoder); -} - -/*********************************************************************** - * - * Public class methods - * - ***********************************************************************/ - -static FLAC__StreamDecoderInitStatus init_stream_internal_( - FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderReadCallback read_callback, - FLAC__StreamDecoderSeekCallback seek_callback, - FLAC__StreamDecoderTellCallback tell_callback, - FLAC__StreamDecoderLengthCallback length_callback, - FLAC__StreamDecoderEofCallback eof_callback, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data, - FLAC__bool is_ogg -) -{ - FLAC__ASSERT(0 != decoder); - - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; - - if(FLAC__HAS_OGG == 0 && is_ogg) - return FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER; - - if( - 0 == read_callback || - 0 == write_callback || - 0 == error_callback || - (seek_callback && (0 == tell_callback || 0 == length_callback || 0 == eof_callback)) - ) - return FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; - -#if FLAC__HAS_OGG - decoder->private_->is_ogg = is_ogg; - if(is_ogg && !FLAC__ogg_decoder_aspect_init(&decoder->protected_->ogg_decoder_aspect)) - return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE; -#endif - - FLAC__cpu_info(&decoder->private_->cpuinfo); - decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block; - -#ifdef FLAC__BMI2_SUPPORTED - if (decoder->private_->cpuinfo.x86.bmi2) { - decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block_bmi2; - } -#endif - - /* from here on, errors are fatal */ - - if(!FLAC__bitreader_init(decoder->private_->input, read_callback_, decoder)) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR; - } - - decoder->private_->read_callback = read_callback; - decoder->private_->seek_callback = seek_callback; - decoder->private_->tell_callback = tell_callback; - decoder->private_->length_callback = length_callback; - decoder->private_->eof_callback = eof_callback; - decoder->private_->write_callback = write_callback; - decoder->private_->metadata_callback = metadata_callback; - decoder->private_->error_callback = error_callback; - decoder->private_->client_data = client_data; - decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; - decoder->private_->samples_decoded = 0; - decoder->private_->has_stream_info = false; - decoder->private_->cached = false; - - decoder->private_->do_md5_checking = decoder->protected_->md5_checking; - decoder->private_->is_seeking = false; - - decoder->private_->internal_reset_hack = true; /* so the following reset does not try to rewind the input */ - if(!FLAC__stream_decoder_reset(decoder)) { - /* above call sets the state for us */ - return FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR; - } - - return FLAC__STREAM_DECODER_INIT_STATUS_OK; -} - -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream( - FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderReadCallback read_callback, - FLAC__StreamDecoderSeekCallback seek_callback, - FLAC__StreamDecoderTellCallback tell_callback, - FLAC__StreamDecoderLengthCallback length_callback, - FLAC__StreamDecoderEofCallback eof_callback, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -) -{ - return init_stream_internal_( - decoder, - read_callback, - seek_callback, - tell_callback, - length_callback, - eof_callback, - write_callback, - metadata_callback, - error_callback, - client_data, - /*is_ogg=*/false - ); -} - -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream( - FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderReadCallback read_callback, - FLAC__StreamDecoderSeekCallback seek_callback, - FLAC__StreamDecoderTellCallback tell_callback, - FLAC__StreamDecoderLengthCallback length_callback, - FLAC__StreamDecoderEofCallback eof_callback, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -) -{ - return init_stream_internal_( - decoder, - read_callback, - seek_callback, - tell_callback, - length_callback, - eof_callback, - write_callback, - metadata_callback, - error_callback, - client_data, - /*is_ogg=*/true - ); -} - -static FLAC__StreamDecoderInitStatus init_FILE_internal_( - FLAC__StreamDecoder *decoder, - FILE *file, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data, - FLAC__bool is_ogg -) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != file); - - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; - - if(0 == write_callback || 0 == error_callback) - return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; - - /* - * To make sure that our file does not go unclosed after an error, we - * must assign the FILE pointer before any further error can occur in - * this routine. - */ - if(file == stdin) - file = get_binary_stdin_(); /* just to be safe */ - - decoder->private_->file = file; - - return init_stream_internal_( - decoder, - file_read_callback_, - decoder->private_->file == stdin? 0: file_seek_callback_, - decoder->private_->file == stdin? 0: file_tell_callback_, - decoder->private_->file == stdin? 0: file_length_callback_, - file_eof_callback_, - write_callback, - metadata_callback, - error_callback, - client_data, - is_ogg - ); -} - -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE( - FLAC__StreamDecoder *decoder, - FILE *file, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -) -{ - return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/false); -} - -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE( - FLAC__StreamDecoder *decoder, - FILE *file, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -) -{ - return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/true); -} - -static FLAC__StreamDecoderInitStatus init_file_internal_( - FLAC__StreamDecoder *decoder, - const char *filename, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data, - FLAC__bool is_ogg -) -{ - FILE *file; - - FLAC__ASSERT(0 != decoder); - - /* - * To make sure that our file does not go unclosed after an error, we - * have to do the same entrance checks here that are later performed - * in FLAC__stream_decoder_init_FILE() before the FILE* is assigned. - */ - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; - - if(0 == write_callback || 0 == error_callback) - return decoder->protected_->initstate = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; - - file = filename? flac_fopen(filename, "rb") : stdin; - - if(0 == file) - return FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE; - - return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, is_ogg); -} - -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file( - FLAC__StreamDecoder *decoder, - const char *filename, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -) -{ - return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/false); -} - -FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file( - FLAC__StreamDecoder *decoder, - const char *filename, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data -) -{ - return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/true); -} - -FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder) -{ - FLAC__bool md5_failed = false; - uint32_t i; - - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - - if(decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED) - return true; - - /* see the comment in FLAC__stream_decoder_reset() as to why we - * always call FLAC__MD5Final() - */ - FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); - - free(decoder->private_->seek_table.data.seek_table.points); - decoder->private_->seek_table.data.seek_table.points = 0; - decoder->private_->has_seek_table = false; - - FLAC__bitreader_free(decoder->private_->input); - for(i = 0; i < FLAC__MAX_CHANNELS; i++) { - /* WATCHOUT: - * FLAC__lpc_restore_signal_asm_ia32_mmx() and ..._intrin_sseN() - * require that the output arrays have a buffer of up to 3 zeroes - * in front (at negative indices) for alignment purposes; - * we use 4 to keep the data well-aligned. - */ - if(0 != decoder->private_->output[i]) { - free(decoder->private_->output[i]-4); - decoder->private_->output[i] = 0; - } - if(0 != decoder->private_->residual_unaligned[i]) { - free(decoder->private_->residual_unaligned[i]); - decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; - } - } - if(0 != decoder->private_->side_subframe) { - free(decoder->private_->side_subframe); - decoder->private_->side_subframe = 0; - } - decoder->private_->output_capacity = 0; - decoder->private_->output_channels = 0; - -#if FLAC__HAS_OGG - if(decoder->private_->is_ogg) - FLAC__ogg_decoder_aspect_finish(&decoder->protected_->ogg_decoder_aspect); -#endif - - if(0 != decoder->private_->file) { - if(decoder->private_->file != stdin) - fclose(decoder->private_->file); - decoder->private_->file = 0; - } - - if(decoder->private_->do_md5_checking) { - if(memcmp(decoder->private_->stream_info.data.stream_info.md5sum, decoder->private_->computed_md5sum, 16)) - md5_failed = true; - } - decoder->private_->is_seeking = false; - - set_defaults_(decoder); - - decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED; - - return !md5_failed; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long value) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return false; -#if FLAC__HAS_OGG - /* can't check decoder->private_->is_ogg since that's not set until init time */ - FLAC__ogg_decoder_aspect_set_serial_number(&decoder->protected_->ogg_decoder_aspect, value); - return true; -#else - (void)value; - return false; -#endif -} - -FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return false; - decoder->protected_->md5_checking = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - FLAC__ASSERT((uint32_t)type <= FLAC__MAX_METADATA_TYPE_CODE); - /* double protection */ - if((uint32_t)type > FLAC__MAX_METADATA_TYPE_CODE) - return false; - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return false; - decoder->private_->metadata_filter[type] = true; - if(type == FLAC__METADATA_TYPE_APPLICATION) - decoder->private_->metadata_filter_ids_count = 0; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - FLAC__ASSERT(0 != id); - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return false; - - if(decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) - return true; - - FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); - - if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) { - if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - decoder->private_->metadata_filter_ids_capacity *= 2; - } - - memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), id, (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)); - decoder->private_->metadata_filter_ids_count++; - - return true; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder) -{ - uint32_t i; - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return false; - for(i = 0; i < sizeof(decoder->private_->metadata_filter) / sizeof(decoder->private_->metadata_filter[0]); i++) - decoder->private_->metadata_filter[i] = true; - decoder->private_->metadata_filter_ids_count = 0; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - FLAC__ASSERT((uint32_t)type <= FLAC__MAX_METADATA_TYPE_CODE); - /* double protection */ - if((uint32_t)type > FLAC__MAX_METADATA_TYPE_CODE) - return false; - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return false; - decoder->private_->metadata_filter[type] = false; - if(type == FLAC__METADATA_TYPE_APPLICATION) - decoder->private_->metadata_filter_ids_count = 0; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - FLAC__ASSERT(0 != id); - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return false; - - if(!decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION]) - return true; - - FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids); - - if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) { - if(0 == (decoder->private_->metadata_filter_ids = safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - decoder->private_->metadata_filter_ids_capacity *= 2; - } - - memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), id, (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)); - decoder->private_->metadata_filter_ids_count++; - - return true; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) - return false; - memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); - decoder->private_->metadata_filter_ids_count = 0; - return true; -} - -FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - return decoder->protected_->state; -} - -FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder) -{ - return FLAC__StreamDecoderStateString[decoder->protected_->state]; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - return decoder->protected_->md5_checking; -} - -FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - return decoder->private_->has_stream_info? decoder->private_->stream_info.data.stream_info.total_samples : 0; -} - -FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - return decoder->protected_->channels; -} - -FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - return decoder->protected_->channel_assignment; -} - -FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - return decoder->protected_->bits_per_sample; -} - -FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - return decoder->protected_->sample_rate; -} - -FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - return decoder->protected_->blocksize; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != position); - - if(FLAC__HAS_OGG && decoder->private_->is_ogg) - return false; - - if(0 == decoder->private_->tell_callback) - return false; - if(decoder->private_->tell_callback(decoder, position, decoder->private_->client_data) != FLAC__STREAM_DECODER_TELL_STATUS_OK) - return false; - /* should never happen since all FLAC frames and metadata blocks are byte aligned, but check just in case */ - if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) - return false; - FLAC__ASSERT(*position >= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder)); - *position -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder); - return true; -} - -FLAC_API const void *FLAC__stream_decoder_get_client_data(FLAC__StreamDecoder *decoder) -{ - return decoder->private_->client_data; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - - if(!decoder->private_->internal_reset_hack && decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED) - return false; - - decoder->private_->samples_decoded = 0; - decoder->private_->do_md5_checking = false; - decoder->private_->last_seen_framesync = 0; - decoder->private_->last_frame_is_set = false; - -#if FLAC__HAS_OGG - if(decoder->private_->is_ogg) - FLAC__ogg_decoder_aspect_flush(&decoder->protected_->ogg_decoder_aspect); -#endif - - if(!FLAC__bitreader_clear(decoder->private_->input)) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - - return true; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - FLAC__ASSERT(0 != decoder->protected_); - - if(!FLAC__stream_decoder_flush(decoder)) { - /* above call sets the state for us */ - return false; - } - -#if FLAC__HAS_OGG - /*@@@ could go in !internal_reset_hack block below */ - if(decoder->private_->is_ogg) - FLAC__ogg_decoder_aspect_reset(&decoder->protected_->ogg_decoder_aspect); -#endif - - /* Rewind if necessary. If FLAC__stream_decoder_init() is calling us, - * (internal_reset_hack) don't try to rewind since we are already at - * the beginning of the stream and don't want to fail if the input is - * not seekable. - */ - if(!decoder->private_->internal_reset_hack) { - if(decoder->private_->file == stdin) - return false; /* can't rewind stdin, reset fails */ - if(decoder->private_->seek_callback && decoder->private_->seek_callback(decoder, 0, decoder->private_->client_data) == FLAC__STREAM_DECODER_SEEK_STATUS_ERROR) - return false; /* seekable and seek fails, reset fails */ - } - - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA; - - decoder->private_->has_stream_info = false; - - free(decoder->private_->seek_table.data.seek_table.points); - decoder->private_->seek_table.data.seek_table.points = 0; - decoder->private_->has_seek_table = false; - - decoder->private_->do_md5_checking = decoder->protected_->md5_checking; - /* - * This goes in reset() and not flush() because according to the spec, a - * fixed-blocksize stream must stay that way through the whole stream. - */ - decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; - - /* We initialize the FLAC__MD5Context even though we may never use it. This - * is because md5 checking may be turned on to start and then turned off if - * a seek occurs. So we init the context here and finalize it in - * FLAC__stream_decoder_finish() to make sure things are always cleaned up - * properly. - */ - if(!decoder->private_->internal_reset_hack) { - /* Only finish MD5 context when it has been initialized - * (i.e. when internal_reset_hack is not set) */ - FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); - } - else - decoder->private_->internal_reset_hack = false; - FLAC__MD5Init(&decoder->private_->md5context); - - decoder->private_->first_frame_offset = 0; - decoder->private_->unparseable_frame_count = 0; - decoder->private_->last_seen_framesync = 0; - decoder->private_->last_frame_is_set = false; - - return true; -} - -FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder) -{ - FLAC__bool got_a_frame; - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - - while(1) { - switch(decoder->protected_->state) { - case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: - if(!find_metadata_(decoder)) - return false; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_READ_METADATA: - if(!read_metadata_(decoder)) - return false; /* above function sets the status for us */ - else - return true; - case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: - if(!frame_sync_(decoder)) - return true; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_READ_FRAME: - if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/true)) - return false; /* above function sets the status for us */ - if(got_a_frame) - return true; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_END_OF_STREAM: - case FLAC__STREAM_DECODER_ABORTED: - return true; - default: - return false; - } - } -} - -FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - - while(1) { - switch(decoder->protected_->state) { - case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: - if(!find_metadata_(decoder)) - return false; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_READ_METADATA: - if(!read_metadata_(decoder)) - return false; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: - case FLAC__STREAM_DECODER_READ_FRAME: - case FLAC__STREAM_DECODER_END_OF_STREAM: - case FLAC__STREAM_DECODER_ABORTED: - return true; - default: - return false; - } - } -} - -FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder) -{ - FLAC__bool dummy; - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - - while(1) { - switch(decoder->protected_->state) { - case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: - if(!find_metadata_(decoder)) - return false; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_READ_METADATA: - if(!read_metadata_(decoder)) - return false; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: - if(!frame_sync_(decoder)) - return true; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_READ_FRAME: - if(!read_frame_(decoder, &dummy, /*do_full_decode=*/true)) - return false; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_END_OF_STREAM: - case FLAC__STREAM_DECODER_ABORTED: - return true; - default: - return false; - } - } -} - -FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder) -{ - FLAC__bool got_a_frame; - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->protected_); - - while(1) { - switch(decoder->protected_->state) { - case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: - case FLAC__STREAM_DECODER_READ_METADATA: - return false; /* above function sets the status for us */ - case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: - if(!frame_sync_(decoder)) - return true; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_READ_FRAME: - if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/false)) - return false; /* above function sets the status for us */ - if(got_a_frame) - return true; /* above function sets the status for us */ - break; - case FLAC__STREAM_DECODER_END_OF_STREAM: - case FLAC__STREAM_DECODER_ABORTED: - return true; - default: - return false; - } - } -} - -FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample) -{ - FLAC__uint64 length; - - FLAC__ASSERT(0 != decoder); - - if( - decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA && - decoder->protected_->state != FLAC__STREAM_DECODER_READ_METADATA && - decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && - decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME && - decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM - ) - return false; - - if(0 == decoder->private_->seek_callback) - return false; - - FLAC__ASSERT(decoder->private_->seek_callback); - FLAC__ASSERT(decoder->private_->tell_callback); - FLAC__ASSERT(decoder->private_->length_callback); - FLAC__ASSERT(decoder->private_->eof_callback); - - if(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_samples(decoder)) - return false; - - decoder->private_->is_seeking = true; - - /* turn off md5 checking if a seek is attempted */ - decoder->private_->do_md5_checking = false; - - /* get the file length (currently our algorithm needs to know the length so it's also an error to get FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED) */ - if(decoder->private_->length_callback(decoder, &length, decoder->private_->client_data) != FLAC__STREAM_DECODER_LENGTH_STATUS_OK) { - decoder->private_->is_seeking = false; - return false; - } - - /* if we haven't finished processing the metadata yet, do that so we have the STREAMINFO, SEEK_TABLE, and first_frame_offset */ - if( - decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA || - decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA - ) { - if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) { - /* above call sets the state for us */ - decoder->private_->is_seeking = false; - return false; - } - /* check this again in case we didn't know total_samples the first time */ - if(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_samples(decoder)) { - decoder->private_->is_seeking = false; - return false; - } - } - - { - const FLAC__bool ok = -#if FLAC__HAS_OGG - decoder->private_->is_ogg? - seek_to_absolute_sample_ogg_(decoder, length, sample) : -#endif - seek_to_absolute_sample_(decoder, length, sample) - ; - decoder->private_->is_seeking = false; - return ok; - } -} - -/*********************************************************************** - * - * Protected class methods - * - ***********************************************************************/ - -uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder) -{ - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); - FLAC__ASSERT(!(FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) & 7)); - return FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) / 8; -} - -/*********************************************************************** - * - * Private class methods - * - ***********************************************************************/ - -void set_defaults_(FLAC__StreamDecoder *decoder) -{ - decoder->private_->is_ogg = false; - decoder->private_->read_callback = 0; - decoder->private_->seek_callback = 0; - decoder->private_->tell_callback = 0; - decoder->private_->length_callback = 0; - decoder->private_->eof_callback = 0; - decoder->private_->write_callback = 0; - decoder->private_->metadata_callback = 0; - decoder->private_->error_callback = 0; - decoder->private_->client_data = 0; - - memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter)); - decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] = true; - decoder->private_->metadata_filter_ids_count = 0; - - decoder->protected_->md5_checking = false; - -#if FLAC__HAS_OGG - FLAC__ogg_decoder_aspect_set_defaults(&decoder->protected_->ogg_decoder_aspect); -#endif -} - -/* - * This will forcibly set stdin to binary mode (for OSes that require it) - */ -FILE *get_binary_stdin_(void) -{ - /* if something breaks here it is probably due to the presence or - * absence of an underscore before the identifiers 'setmode', - * 'fileno', and/or 'O_BINARY'; check your system header files. - */ -#if defined _MSC_VER || defined __MINGW32__ - _setmode(_fileno(stdin), _O_BINARY); -#elif defined __EMX__ - setmode(fileno(stdin), O_BINARY); -#endif - - return stdin; -} - -FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_t bps) -{ - uint32_t i; - FLAC__int32 *tmp; - - if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels && - (bps < 32 || decoder->private_->side_subframe != 0)) - return true; - - /* simply using realloc() is not practical because the number of channels may change mid-stream */ - - for(i = 0; i < FLAC__MAX_CHANNELS; i++) { - if(0 != decoder->private_->output[i]) { - free(decoder->private_->output[i]-4); - decoder->private_->output[i] = 0; - } - if(0 != decoder->private_->residual_unaligned[i]) { - free(decoder->private_->residual_unaligned[i]); - decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0; - } - } - - if(0 != decoder->private_->side_subframe) { - free(decoder->private_->side_subframe); - decoder->private_->side_subframe = 0; - } - - for(i = 0; i < channels; i++) { - /* WATCHOUT: - * FLAC__lpc_restore_signal_asm_ia32_mmx() and ..._intrin_sseN() - * require that the output arrays have a buffer of up to 3 zeroes - * in front (at negative indices) for alignment purposes; - * we use 4 to keep the data well-aligned. - */ - tmp = safe_malloc_muladd2_(sizeof(FLAC__int32), /*times (*/size, /*+*/4/*)*/); - if(tmp == 0) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - memset(tmp, 0, sizeof(FLAC__int32)*4); - decoder->private_->output[i] = tmp + 4; - - if(!FLAC__memory_alloc_aligned_int32_array(size, &decoder->private_->residual_unaligned[i], &decoder->private_->residual[i])) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - } - - if(bps == 32) { - decoder->private_->side_subframe = safe_malloc_mul_2op_p(sizeof(FLAC__int64), /*times (*/size); - if(decoder->private_->side_subframe == NULL) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - } - - decoder->private_->output_capacity = size; - decoder->private_->output_channels = channels; - - return true; -} - -FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id) -{ - size_t i; - - FLAC__ASSERT(0 != decoder); - FLAC__ASSERT(0 != decoder->private_); - - for(i = 0; i < decoder->private_->metadata_filter_ids_count; i++) - if(0 == memcmp(decoder->private_->metadata_filter_ids + i * (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), id, (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8))) - return true; - - return false; -} - -FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder) -{ - FLAC__uint32 x; - uint32_t i, id; - FLAC__bool first = true; - - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); - - for(i = id = 0; i < 4; ) { - if(decoder->private_->cached) { - x = (FLAC__uint32)decoder->private_->lookahead; - decoder->private_->cached = false; - } - else { - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) - return false; /* read_callback_ sets the state for us */ - } - if(x == FLAC__STREAM_SYNC_STRING[i]) { - first = true; - i++; - id = 0; - continue; - } - - if(id >= 3) - return false; - - if(x == ID3V2_TAG_[id]) { - id++; - i = 0; - if(id == 3) { - if(!skip_id3v2_tag_(decoder)) - return false; /* skip_id3v2_tag_ sets the state for us */ - } - continue; - } - id = 0; - if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ - decoder->private_->header_warmup[0] = (FLAC__byte)x; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) - return false; /* read_callback_ sets the state for us */ - - /* we have to check if we just read two 0xff's in a row; the second may actually be the beginning of the sync code */ - /* else we have to check if the second byte is the end of a sync code */ - if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ - decoder->private_->lookahead = (FLAC__byte)x; - decoder->private_->cached = true; - } - else if(x >> 1 == 0x7c) { /* MAGIC NUMBER for the last 6 sync bits and reserved 7th bit */ - decoder->private_->header_warmup[1] = (FLAC__byte)x; - decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; - return true; - } - } - i = 0; - if(first) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - first = false; - } - } - - decoder->protected_->state = FLAC__STREAM_DECODER_READ_METADATA; - return true; -} - -FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder) -{ - FLAC__bool is_last; - FLAC__uint32 i, x, type, length; - - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_IS_LAST_LEN)) - return false; /* read_callback_ sets the state for us */ - is_last = x? true : false; - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &type, FLAC__STREAM_METADATA_TYPE_LEN)) - return false; /* read_callback_ sets the state for us */ - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &length, FLAC__STREAM_METADATA_LENGTH_LEN)) - return false; /* read_callback_ sets the state for us */ - - if(type == FLAC__METADATA_TYPE_STREAMINFO) { - if(!read_metadata_streaminfo_(decoder, is_last, length)) - return false; - - decoder->private_->has_stream_info = true; - if(0 == memcmp(decoder->private_->stream_info.data.stream_info.md5sum, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16)) - decoder->private_->do_md5_checking = false; - if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] && decoder->private_->metadata_callback) - decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->client_data); - } - else if(type == FLAC__METADATA_TYPE_SEEKTABLE) { - /* just in case we already have a seek table, and reading the next one fails: */ - decoder->private_->has_seek_table = false; - - if(length > 0) { - if(!read_metadata_seektable_(decoder, is_last, length)) - return false; - - decoder->private_->has_seek_table = true; - if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_SEEKTABLE] && decoder->private_->metadata_callback) - decoder->private_->metadata_callback(decoder, &decoder->private_->seek_table, decoder->private_->client_data); - } - } - else { - FLAC__bool skip_it = !decoder->private_->metadata_filter[type]; - uint32_t real_length = length; - FLAC__StreamMetadata block; - - memset(&block, 0, sizeof(block)); - block.is_last = is_last; - block.type = (FLAC__MetadataType)type; - block.length = length; - - if(type == FLAC__METADATA_TYPE_APPLICATION) { - if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)) - return false; /* read_callback_ sets the state for us */ - - if(real_length < FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) { /* underflow check */ - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;/*@@@@@@ maybe wrong error? need to resync?*/ - return false; - } - - real_length -= FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8; - - if(decoder->private_->metadata_filter_ids_count > 0 && has_id_filtered_(decoder, block.data.application.id)) - skip_it = !skip_it; - } - - if(skip_it) { - if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) - return false; /* read_callback_ sets the state for us */ - } - else { - FLAC__bool ok = true; - FLAC__bitreader_set_limit(decoder->private_->input, real_length*8); - switch(type) { - case FLAC__METADATA_TYPE_PADDING: - /* skip the padding bytes */ - if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length)) - ok = false; /* read_callback_ sets the state for us */ - break; - case FLAC__METADATA_TYPE_APPLICATION: - /* remember, we read the ID already */ - if(real_length > 0) { - if(0 == (block.data.application.data = malloc(real_length))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - ok = false; - } - else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.application.data, real_length)) - ok = false; /* read_callback_ sets the state for us */ - } - else - block.data.application.data = 0; - break; - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - if(!read_metadata_vorbiscomment_(decoder, &block.data.vorbis_comment, real_length)) - ok = false; - break; - case FLAC__METADATA_TYPE_CUESHEET: - if(!read_metadata_cuesheet_(decoder, &block.data.cue_sheet)) - ok = false; - break; - case FLAC__METADATA_TYPE_PICTURE: - if(!read_metadata_picture_(decoder, &block.data.picture)) - ok = false; - break; - case FLAC__METADATA_TYPE_STREAMINFO: - case FLAC__METADATA_TYPE_SEEKTABLE: - FLAC__ASSERT(0); - break; - default: - if(real_length > 0) { - if(0 == (block.data.unknown.data = malloc(real_length))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - ok = false; - } - else if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.unknown.data, real_length)) - ok = false; /* read_callback_ sets the state for us */ - } - else - block.data.unknown.data = 0; - break; - } - if(FLAC__bitreader_limit_remaining(decoder->private_->input) > 0) { - /* Content in metadata block didn't fit in block length - * We cannot know whether the length or the content was - * corrupt, so stop parsing metadata */ - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA); - if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA) - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - ok = false; - } - FLAC__bitreader_remove_limit(decoder->private_->input); - if(ok && !decoder->private_->is_seeking && decoder->private_->metadata_callback) - decoder->private_->metadata_callback(decoder, &block, decoder->private_->client_data); - - /* now we have to free any malloc()ed data in the block */ - switch(type) { - case FLAC__METADATA_TYPE_PADDING: - break; - case FLAC__METADATA_TYPE_APPLICATION: - if(0 != block.data.application.data) - free(block.data.application.data); - break; - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - if(0 != block.data.vorbis_comment.vendor_string.entry) - free(block.data.vorbis_comment.vendor_string.entry); - if(block.data.vorbis_comment.num_comments > 0) - for(i = 0; i < block.data.vorbis_comment.num_comments; i++) - if(0 != block.data.vorbis_comment.comments[i].entry) - free(block.data.vorbis_comment.comments[i].entry); - if(0 != block.data.vorbis_comment.comments) - free(block.data.vorbis_comment.comments); - break; - case FLAC__METADATA_TYPE_CUESHEET: - if(block.data.cue_sheet.num_tracks > 0 && 0 != block.data.cue_sheet.tracks) - for(i = 0; i < block.data.cue_sheet.num_tracks; i++) - if(0 != block.data.cue_sheet.tracks[i].indices) - free(block.data.cue_sheet.tracks[i].indices); - if(0 != block.data.cue_sheet.tracks) - free(block.data.cue_sheet.tracks); - break; - case FLAC__METADATA_TYPE_PICTURE: - if(0 != block.data.picture.mime_type) - free(block.data.picture.mime_type); - if(0 != block.data.picture.description) - free(block.data.picture.description); - if(0 != block.data.picture.data) - free(block.data.picture.data); - break; - case FLAC__METADATA_TYPE_STREAMINFO: - case FLAC__METADATA_TYPE_SEEKTABLE: - FLAC__ASSERT(0); - default: - if(0 != block.data.unknown.data) - free(block.data.unknown.data); - break; - } - - if(!ok) /* anything that unsets "ok" should also make sure decoder->protected_->state is updated */ - return false; - } - } - - if(is_last) { - /* if this fails, it's OK, it's just a hint for the seek routine */ - if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->first_frame_offset)) - decoder->private_->first_frame_offset = 0; - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - } - - return true; -} - -FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length) -{ - FLAC__uint32 x; - uint32_t bits, used_bits = 0; - - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); - - decoder->private_->stream_info.type = FLAC__METADATA_TYPE_STREAMINFO; - decoder->private_->stream_info.is_last = is_last; - decoder->private_->stream_info.length = length; - - bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, bits)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->stream_info.data.stream_info.min_blocksize = x; - used_bits += bits; - - bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->stream_info.data.stream_info.max_blocksize = x; - used_bits += bits; - - bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->stream_info.data.stream_info.min_framesize = x; - used_bits += bits; - - bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->stream_info.data.stream_info.max_framesize = x; - used_bits += bits; - - bits = FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->stream_info.data.stream_info.sample_rate = x; - used_bits += bits; - - bits = FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->stream_info.data.stream_info.channels = x+1; - used_bits += bits; - - bits = FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1; - used_bits += bits; - - bits = FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; - if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &decoder->private_->stream_info.data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)) - return false; /* read_callback_ sets the state for us */ - used_bits += bits; - - if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, decoder->private_->stream_info.data.stream_info.md5sum, 16)) - return false; /* read_callback_ sets the state for us */ - used_bits += 16*8; - - /* skip the rest of the block */ - FLAC__ASSERT(used_bits % 8 == 0); - if (length < (used_bits / 8)) - return false; /* read_callback_ sets the state for us */ - length -= (used_bits / 8); - if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length)) - return false; /* read_callback_ sets the state for us */ - - return true; -} - -FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length) -{ - FLAC__uint32 i, x; - FLAC__uint64 xx; - - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); - - decoder->private_->seek_table.type = FLAC__METADATA_TYPE_SEEKTABLE; - decoder->private_->seek_table.is_last = is_last; - decoder->private_->seek_table.length = length; - - if(length % FLAC__STREAM_METADATA_SEEKPOINT_LENGTH) { - FLAC__bitreader_limit_invalidate(decoder->private_->input); - return false; - } - - decoder->private_->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; - - /* use realloc since we may pass through here several times (e.g. after seeking) */ - if(0 == (decoder->private_->seek_table.data.seek_table.points = safe_realloc_mul_2op_(decoder->private_->seek_table.data.seek_table.points, decoder->private_->seek_table.data.seek_table.num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint)))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - for(i = 0; i < decoder->private_->seek_table.data.seek_table.num_points; i++) { - if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->seek_table.data.seek_table.points[i].sample_number = xx; - - if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->seek_table.data.seek_table.points[i].stream_offset = xx; - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->seek_table.data.seek_table.points[i].frame_samples = x; - } - length -= (decoder->private_->seek_table.data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH); - - FLAC__ASSERT(length == 0); - - return true; -} - -FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, uint32_t length) -{ - FLAC__uint32 i; - - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); - - /* read vendor string */ - if (length >= 8) { - length -= 8; /* vendor string length + num comments entries alone take 8 bytes */ - FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32); - if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.length)) - return false; /* read_callback_ sets the state for us */ - if (length < obj->vendor_string.length) { - obj->vendor_string.length = 0; - obj->vendor_string.entry = 0; - goto skip; - } - else - length -= obj->vendor_string.length; - if (0 == (obj->vendor_string.entry = safe_malloc_add_2op_(obj->vendor_string.length, /*+*/1))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.entry, obj->vendor_string.length)) - return false; /* read_callback_ sets the state for us */ - obj->vendor_string.entry[obj->vendor_string.length] = '\0'; - - /* read num comments */ - FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN == 32); - if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->num_comments)) - return false; /* read_callback_ sets the state for us */ - - /* read comments */ - if (obj->num_comments > 100000) { - /* Possibly malicious file. */ - obj->num_comments = 0; - return false; - } - if (obj->num_comments > 0) { - if (0 == (obj->comments = safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) { - obj->num_comments = 0; - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - for (i = 0; i < obj->num_comments; i++) { - /* Initialize here just to make sure. */ - obj->comments[i].length = 0; - obj->comments[i].entry = 0; - - FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32); - if (length < 4) { - obj->num_comments = i; - goto skip; - } - else - length -= 4; - if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length)) { - obj->num_comments = i; - return false; /* read_callback_ sets the state for us */ - } - if (length < obj->comments[i].length) { - obj->num_comments = i; - FLAC__bitreader_limit_invalidate(decoder->private_->input); - return false; - } - else - length -= obj->comments[i].length; - if (0 == (obj->comments[i].entry = safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - obj->num_comments = i; - return false; - } - memset (obj->comments[i].entry, 0, obj->comments[i].length) ; - if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length)) { - /* Current i-th entry is bad, so we delete it. */ - free (obj->comments[i].entry) ; - obj->comments[i].entry = NULL ; - obj->num_comments = i; - goto skip; - } - obj->comments[i].entry[obj->comments[i].length] = '\0'; - } - } - } - else { - FLAC__bitreader_limit_invalidate(decoder->private_->input); - return false; - } - - skip: - if (length > 0) { - /* length > 0 can only happen on files with invalid data in comments */ - if(obj->num_comments < 1) { - free(obj->comments); - obj->comments = NULL; - } - FLAC__bitreader_limit_invalidate(decoder->private_->input); - return false; - } - - return true; -} - -FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj) -{ - FLAC__uint32 i, j, x; - - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); - - memset(obj, 0, sizeof(FLAC__StreamMetadata_CueSheet)); - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0); - if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->media_catalog_number, FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN/8)) - return false; /* read_callback_ sets the state for us */ - - if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN)) - return false; /* read_callback_ sets the state for us */ - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN)) - return false; /* read_callback_ sets the state for us */ - obj->is_cd = x? true : false; - - if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN)) - return false; /* read_callback_ sets the state for us */ - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN)) - return false; /* read_callback_ sets the state for us */ - obj->num_tracks = x; - - if(obj->num_tracks > 0) { - if(0 == (obj->tracks = safe_calloc_(obj->num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - for(i = 0; i < obj->num_tracks; i++) { - FLAC__StreamMetadata_CueSheet_Track *track = &obj->tracks[i]; - if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &track->offset, FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN)) - return false; /* read_callback_ sets the state for us */ - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN)) - return false; /* read_callback_ sets the state for us */ - track->number = (FLAC__byte)x; - - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0); - if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)track->isrc, FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN/8)) - return false; /* read_callback_ sets the state for us */ - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN)) - return false; /* read_callback_ sets the state for us */ - track->type = x; - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN)) - return false; /* read_callback_ sets the state for us */ - track->pre_emphasis = x; - - if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN)) - return false; /* read_callback_ sets the state for us */ - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN)) - return false; /* read_callback_ sets the state for us */ - track->num_indices = (FLAC__byte)x; - - if(track->num_indices > 0) { - if(0 == (track->indices = safe_calloc_(track->num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - for(j = 0; j < track->num_indices; j++) { - FLAC__StreamMetadata_CueSheet_Index *indx = &track->indices[j]; - if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &indx->offset, FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN)) - return false; /* read_callback_ sets the state for us */ - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN)) - return false; /* read_callback_ sets the state for us */ - indx->number = (FLAC__byte)x; - - if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN)) - return false; /* read_callback_ sets the state for us */ - } - } - } - } - else { /* obj->num_tracks == 0 */ - FLAC__bitreader_limit_invalidate(decoder->private_->input); - return false; - } - - return true; -} - -FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj) -{ - FLAC__uint32 x; - - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); - - /* read type */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_TYPE_LEN)) - return false; /* read_callback_ sets the state for us */ - if(x < FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED) - obj->type = x; - else - obj->type = FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER; - - /* read MIME type */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN)) - return false; /* read_callback_ sets the state for us */ - if(FLAC__bitreader_limit_remaining(decoder->private_->input) < x){ - FLAC__bitreader_limit_invalidate(decoder->private_->input); - return false; - } - if(0 == (obj->mime_type = safe_malloc_add_2op_(x, /*+*/1))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - if(x > 0) { - if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->mime_type, x)) - return false; /* read_callback_ sets the state for us */ - } - obj->mime_type[x] = '\0'; - - /* read description */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN)) - return false; /* read_callback_ sets the state for us */ - if(FLAC__bitreader_limit_remaining(decoder->private_->input) < x){ - FLAC__bitreader_limit_invalidate(decoder->private_->input); - return false; - } - if(0 == (obj->description = safe_malloc_add_2op_(x, /*+*/1))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - if(x > 0) { - if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->description, x)) - return false; /* read_callback_ sets the state for us */ - } - obj->description[x] = '\0'; - - /* read width */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->width, FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN)) - return false; /* read_callback_ sets the state for us */ - - /* read height */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->height, FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN)) - return false; /* read_callback_ sets the state for us */ - - /* read depth */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->depth, FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN)) - return false; /* read_callback_ sets the state for us */ - - /* read colors */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->colors, FLAC__STREAM_METADATA_PICTURE_COLORS_LEN)) - return false; /* read_callback_ sets the state for us */ - - /* read data */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &(obj->data_length), FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN)) - return false; /* read_callback_ sets the state for us */ - if(FLAC__bitreader_limit_remaining(decoder->private_->input) < obj->data_length){ - FLAC__bitreader_limit_invalidate(decoder->private_->input); - return false; - } - if(0 == (obj->data = safe_malloc_(obj->data_length))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - if(obj->data_length > 0) { - if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->data, obj->data_length)) - return false; /* read_callback_ sets the state for us */ - } - - return true; -} - -FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder) -{ - FLAC__uint32 x; - uint32_t i, skip; - - /* skip the version and flags bytes */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 24)) - return false; /* read_callback_ sets the state for us */ - /* get the size (in bytes) to skip */ - skip = 0; - for(i = 0; i < 4; i++) { - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) - return false; /* read_callback_ sets the state for us */ - skip <<= 7; - skip |= (x & 0x7f); - } - /* skip the rest of the tag */ - if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, skip)) - return false; /* read_callback_ sets the state for us */ - return true; -} - -FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder) -{ - FLAC__uint32 x; - FLAC__bool first = true; - - /* make sure we're byte aligned */ - if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__bitreader_bits_left_for_byte_alignment(decoder->private_->input))) - return false; /* read_callback_ sets the state for us */ - } - - while(1) { - if(decoder->private_->cached) { - x = (FLAC__uint32)decoder->private_->lookahead; - decoder->private_->cached = false; - } - else { - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) - return false; /* read_callback_ sets the state for us */ - } - if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ - decoder->private_->header_warmup[0] = (FLAC__byte)x; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) - return false; /* read_callback_ sets the state for us */ - - /* we have to check if we just read two 0xff's in a row; the second may actually be the beginning of the sync code */ - /* else we have to check if the second byte is the end of a sync code */ - if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ - decoder->private_->lookahead = (FLAC__byte)x; - decoder->private_->cached = true; - } - else if(x >> 1 == 0x7c) { /* MAGIC NUMBER for the last 6 sync bits and reserved 7th bit */ - decoder->private_->header_warmup[1] = (FLAC__byte)x; - decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME; - - /* Save location so we can rewind in case the frame turns - * out to be invalid after the header */ - FLAC__bitreader_set_framesync_location(decoder->private_->input); - if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->last_seen_framesync)) - decoder->private_->last_seen_framesync = 0; - return true; - } - } - if(first) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - first = false; - } - } - - return true; -} - -FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode) -{ - uint32_t channel; - uint32_t i; - uint32_t frame_crc; /* the one we calculate from the input stream */ - FLAC__uint32 x; - - *got_a_frame = false; - decoder->private_->side_subframe_in_use = false; - - /* init the CRC */ - frame_crc = 0; - frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[0], frame_crc); - frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[1], frame_crc); - FLAC__bitreader_reset_read_crc16(decoder->private_->input, (FLAC__uint16)frame_crc); - - if(!read_frame_header_(decoder)) - return false; - if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means we didn't sync on a valid header */ - return true; - if(!allocate_output_(decoder, decoder->private_->frame.header.blocksize, decoder->private_->frame.header.channels, decoder->private_->frame.header.bits_per_sample)) - return false; - for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { - /* - * first figure the correct bits-per-sample of the subframe - */ - uint32_t bps = decoder->private_->frame.header.bits_per_sample; - switch(decoder->private_->frame.header.channel_assignment) { - case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: - /* no adjustment needed */ - break; - case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: - FLAC__ASSERT(decoder->private_->frame.header.channels == 2); - if(channel == 1) - bps++; - break; - case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: - FLAC__ASSERT(decoder->private_->frame.header.channels == 2); - if(channel == 0) - bps++; - break; - case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: - FLAC__ASSERT(decoder->private_->frame.header.channels == 2); - if(channel == 1) - bps++; - break; - default: - FLAC__ASSERT(0); - } - /* - * now read it - */ - if(!read_subframe_(decoder, channel, bps, do_full_decode)){ - /* read_callback_ sets the state for us */ - if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM) - break; - else - return false; - } - if(decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME) - break; - } - - if(decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) - if(!read_zero_padding_(decoder)) - return false; - - /* - * Read the frame CRC-16 from the footer and check - */ - if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { - frame_crc = FLAC__bitreader_get_read_crc16(decoder->private_->input); - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN)) { - /* read_callback_ sets the state for us */ - if(decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) - return false; - } -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - } - if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME && frame_crc == x) { -#endif - if(do_full_decode) { - /* Undo any special channel coding */ - undo_channel_coding(decoder); - /* Check whether decoded data actually fits bps */ - for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { - int shift_bits = 32 - decoder->private_->frame.header.bits_per_sample; - /* Check whether shift_bits MSBs are 'empty' by shifting up and down */ - if((decoder->private_->output[channel][i] < (INT32_MIN >> shift_bits)) || - (decoder->private_->output[channel][i] > (INT32_MAX >> shift_bits))) { - /* Bad frame, emit error */ - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - break; - } - } - } - } - } -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - else if (decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { - /* Bad frame, emit error */ - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - } -#endif - - /* Check whether frames are missing, if so, add silence to compensate */ - if(decoder->private_->last_frame_is_set && decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME && !decoder->private_->is_seeking && do_full_decode) { - FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); - FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); - if(decoder->private_->last_frame.header.number.sample_number + decoder->private_->last_frame.header.blocksize < decoder->private_->frame.header.number.sample_number) { - uint32_t padding_samples_needed = decoder->private_->frame.header.number.sample_number - (decoder->private_->last_frame.header.number.sample_number + decoder->private_->last_frame.header.blocksize); - - /* Do some extra validation to assure last frame an current frame - * header are both valid before adding silence inbetween - * Technically both frames could be valid with differing sample_rates, - * channels and bits_per_sample, but it is quite rare */ - if(decoder->private_->last_frame.header.sample_rate == decoder->private_->frame.header.sample_rate && - decoder->private_->last_frame.header.channels == decoder->private_->frame.header.channels && - decoder->private_->last_frame.header.bits_per_sample == decoder->private_->frame.header.bits_per_sample && - decoder->private_->last_frame.header.blocksize >= 16) { - FLAC__Frame empty_frame; - FLAC__int32 * empty_buffer[FLAC__MAX_CHANNELS] = {NULL}; - empty_frame.header = decoder->private_->last_frame.header; - empty_frame.footer.crc = 0; - for(i = 0; i < empty_frame.header.channels; i++) { - empty_buffer[i] = safe_calloc_(empty_frame.header.blocksize, sizeof(FLAC__int32)); - if(empty_buffer[i] == NULL) { - for(i = 0; i < empty_frame.header.channels; i++) - if(empty_buffer[i] != NULL) - free(empty_buffer[i]); - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - } - /* No repairs larger than 5 seconds or 50 frames are made, to not - * unexpectedly create enormous files when one of the headers was - * corrupt after all */ - if(padding_samples_needed > (5*empty_frame.header.sample_rate)) - padding_samples_needed = 5*empty_frame.header.sample_rate; - if(padding_samples_needed > (50*empty_frame.header.blocksize)) - padding_samples_needed = 50*empty_frame.header.blocksize; - while(padding_samples_needed){ - empty_frame.header.number.sample_number += empty_frame.header.blocksize; - if(padding_samples_needed < empty_frame.header.blocksize) - empty_frame.header.blocksize = padding_samples_needed; - padding_samples_needed -= empty_frame.header.blocksize; - decoder->protected_->blocksize = empty_frame.header.blocksize; - - FLAC__ASSERT(empty_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); - decoder->private_->samples_decoded = empty_frame.header.number.sample_number + empty_frame.header.blocksize; - - for(channel = 0; channel < empty_frame.header.channels; channel++) { - empty_frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; - empty_frame.subframes[channel].data.constant.value = 0; - empty_frame.subframes[channel].wasted_bits = 0; - } - - if(write_audio_frame_to_client_(decoder, &empty_frame, (const FLAC__int32 * const *)empty_buffer) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE) { - decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; - for(i = 0; i < empty_frame.header.channels; i++) - if(empty_buffer[i] != NULL) - free(empty_buffer[i]); - return false; - } - } - for(i = 0; i < empty_frame.header.channels; i++) - if(empty_buffer[i] != NULL) - free(empty_buffer[i]); - - } - } - } - - if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC || decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM) { - /* Got corruption, rewind if possible. Return value of seek - * isn't checked, if the seek fails the decoder will continue anyway */ - if(!FLAC__bitreader_rewind_to_after_last_seen_framesync(decoder->private_->input)){ -#ifndef NDEBUG - fprintf(stderr, "Rewinding, seeking necessary\n"); -#endif - if(decoder->private_->seek_callback && decoder->private_->last_seen_framesync){ - /* Last framesync isn't in bitreader anymore, rewind with seek if possible */ -#ifndef NDEBUG - FLAC__uint64 current_decode_position; - if(FLAC__stream_decoder_get_decode_position(decoder, ¤t_decode_position)) - fprintf(stderr, "Bitreader was %" PRIu64 " bytes short\n", current_decode_position-decoder->private_->last_seen_framesync); -#endif - if(decoder->private_->seek_callback(decoder, decoder->private_->last_seen_framesync, decoder->private_->client_data) == FLAC__STREAM_DECODER_SEEK_STATUS_ERROR) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - if(!FLAC__bitreader_clear(decoder->private_->input)) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - } - } -#ifndef NDEBUG - else{ - fprintf(stderr, "Rewinding, seeking not necessary\n"); - } -#endif - } - else { - *got_a_frame = true; - - /* we wait to update fixed_block_size until here, when we're sure we've got a proper frame and hence a correct blocksize */ - if(decoder->private_->next_fixed_block_size) - decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size; - - /* put the latest values into the public section of the decoder instance */ - decoder->protected_->channels = decoder->private_->frame.header.channels; - decoder->protected_->channel_assignment = decoder->private_->frame.header.channel_assignment; - decoder->protected_->bits_per_sample = decoder->private_->frame.header.bits_per_sample; - decoder->protected_->sample_rate = decoder->private_->frame.header.sample_rate; - decoder->protected_->blocksize = decoder->private_->frame.header.blocksize; - - FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); - decoder->private_->samples_decoded = decoder->private_->frame.header.number.sample_number + decoder->private_->frame.header.blocksize; - - /* write it */ - if(do_full_decode) { - if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)decoder->private_->output) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE) { - decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; - return false; - } - } - } - - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; -} - -FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) -{ - FLAC__uint32 x; - FLAC__uint64 xx; - uint32_t i, blocksize_hint = 0, sample_rate_hint = 0; - FLAC__byte crc8, raw_header[16]; /* MAGIC NUMBER based on the maximum frame header size, including CRC */ - uint32_t raw_header_len; - FLAC__bool is_unparseable = false; - - FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); - - /* init the raw header with the saved bits from synchronization */ - raw_header[0] = decoder->private_->header_warmup[0]; - raw_header[1] = decoder->private_->header_warmup[1]; - raw_header_len = 2; - - /* check to make sure that reserved bit is 0 */ - if(raw_header[1] & 0x02) /* MAGIC NUMBER */ - is_unparseable = true; - - /* - * Note that along the way as we read the header, we look for a sync - * code inside. If we find one it would indicate that our original - * sync was bad since there cannot be a sync code in a valid header. - * - * Three kinds of things can go wrong when reading the frame header: - * 1) We may have sync'ed incorrectly and not landed on a frame header. - * If we don't find a sync code, it can end up looking like we read - * a valid but unparseable header, until getting to the frame header - * CRC. Even then we could get a false positive on the CRC. - * 2) We may have sync'ed correctly but on an unparseable frame (from a - * future encoder). - * 3) We may be on a damaged frame which appears valid but unparseable. - * - * For all these reasons, we try and read a complete frame header as - * long as it seems valid, even if unparseable, up until the frame - * header CRC. - */ - - /* - * read in the raw header as bytes so we can CRC it, and parse it on the way - */ - for(i = 0; i < 2; i++) { - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) - return false; /* read_callback_ sets the state for us */ - if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ - /* if we get here it means our original sync was erroneous since the sync code cannot appear in the header */ - decoder->private_->lookahead = (FLAC__byte)x; - decoder->private_->cached = true; - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - raw_header[raw_header_len++] = (FLAC__byte)x; - } - - switch(x = raw_header[2] >> 4) { - case 0: - is_unparseable = true; - break; - case 1: - decoder->private_->frame.header.blocksize = 192; - break; - case 2: - case 3: - case 4: - case 5: - decoder->private_->frame.header.blocksize = 576 << (x-2); - break; - case 6: - case 7: - blocksize_hint = x; - break; - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - decoder->private_->frame.header.blocksize = 256 << (x-8); - break; - default: - FLAC__ASSERT(0); - break; - } - - switch(x = raw_header[2] & 0x0f) { - case 0: - if(decoder->private_->has_stream_info) - decoder->private_->frame.header.sample_rate = decoder->private_->stream_info.data.stream_info.sample_rate; - else - is_unparseable = true; - break; - case 1: - decoder->private_->frame.header.sample_rate = 88200; - break; - case 2: - decoder->private_->frame.header.sample_rate = 176400; - break; - case 3: - decoder->private_->frame.header.sample_rate = 192000; - break; - case 4: - decoder->private_->frame.header.sample_rate = 8000; - break; - case 5: - decoder->private_->frame.header.sample_rate = 16000; - break; - case 6: - decoder->private_->frame.header.sample_rate = 22050; - break; - case 7: - decoder->private_->frame.header.sample_rate = 24000; - break; - case 8: - decoder->private_->frame.header.sample_rate = 32000; - break; - case 9: - decoder->private_->frame.header.sample_rate = 44100; - break; - case 10: - decoder->private_->frame.header.sample_rate = 48000; - break; - case 11: - decoder->private_->frame.header.sample_rate = 96000; - break; - case 12: - case 13: - case 14: - sample_rate_hint = x; - break; - case 15: - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - default: - FLAC__ASSERT(0); - } - - x = (uint32_t)(raw_header[3] >> 4); - if(x & 8) { - decoder->private_->frame.header.channels = 2; - switch(x & 7) { - case 0: - decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE; - break; - case 1: - decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE; - break; - case 2: - decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE; - break; - default: - is_unparseable = true; - break; - } - } - else { - decoder->private_->frame.header.channels = (uint32_t)x + 1; - decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; - } - - switch(x = (uint32_t)(raw_header[3] & 0x0e) >> 1) { - case 0: - if(decoder->private_->has_stream_info) - decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.bits_per_sample; - else - is_unparseable = true; - break; - case 1: - decoder->private_->frame.header.bits_per_sample = 8; - break; - case 2: - decoder->private_->frame.header.bits_per_sample = 12; - break; - case 3: - is_unparseable = true; - break; - case 4: - decoder->private_->frame.header.bits_per_sample = 16; - break; - case 5: - decoder->private_->frame.header.bits_per_sample = 20; - break; - case 6: - decoder->private_->frame.header.bits_per_sample = 24; - break; - case 7: - decoder->private_->frame.header.bits_per_sample = 32; - break; - default: - FLAC__ASSERT(0); - break; - } - -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* check to make sure that reserved bit is 0 */ - if(raw_header[3] & 0x01) /* MAGIC NUMBER */ - is_unparseable = true; -#endif - - /* read the frame's starting sample number (or frame number as the case may be) */ - if( - raw_header[1] & 0x01 || - /*@@@ this clause is a concession to the old way of doing variable blocksize; the only known implementation is flake and can probably be removed without inconveniencing anyone */ - (decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.min_blocksize != decoder->private_->stream_info.data.stream_info.max_blocksize) - ) { /* variable blocksize */ - if(!FLAC__bitreader_read_utf8_uint64(decoder->private_->input, &xx, raw_header, &raw_header_len)) - return false; /* read_callback_ sets the state for us */ - if(xx == FLAC__U64L(0xffffffffffffffff)) { /* i.e. non-UTF8 code... */ - decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ - decoder->private_->cached = true; - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; - decoder->private_->frame.header.number.sample_number = xx; - } - else { /* fixed blocksize */ - if(!FLAC__bitreader_read_utf8_uint32(decoder->private_->input, &x, raw_header, &raw_header_len)) - return false; /* read_callback_ sets the state for us */ - if(x == 0xffffffff) { /* i.e. non-UTF8 code... */ - decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ - decoder->private_->cached = true; - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER; - decoder->private_->frame.header.number.frame_number = x; - } - - if(blocksize_hint) { - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) - return false; /* read_callback_ sets the state for us */ - raw_header[raw_header_len++] = (FLAC__byte)x; - if(blocksize_hint == 7) { - FLAC__uint32 _x; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) - return false; /* read_callback_ sets the state for us */ - raw_header[raw_header_len++] = (FLAC__byte)_x; - x = (x << 8) | _x; - } - decoder->private_->frame.header.blocksize = x+1; - if(decoder->private_->frame.header.blocksize > 65535) { /* invalid blocksize (65536) specified */ - decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */ - decoder->private_->cached = true; - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - - } - - if(sample_rate_hint) { - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) - return false; /* read_callback_ sets the state for us */ - raw_header[raw_header_len++] = (FLAC__byte)x; - if(sample_rate_hint != 12) { - FLAC__uint32 _x; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8)) - return false; /* read_callback_ sets the state for us */ - raw_header[raw_header_len++] = (FLAC__byte)_x; - x = (x << 8) | _x; - } - if(sample_rate_hint == 12) - decoder->private_->frame.header.sample_rate = x*1000; - else if(sample_rate_hint == 13) - decoder->private_->frame.header.sample_rate = x; - else - decoder->private_->frame.header.sample_rate = x*10; - } - - /* read the CRC-8 byte */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) - return false; /* read_callback_ sets the state for us */ - crc8 = (FLAC__byte)x; - -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - if(FLAC__crc8(raw_header, raw_header_len) != crc8) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } -#endif - - /* calculate the sample number from the frame number if needed */ - decoder->private_->next_fixed_block_size = 0; - if(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER) { - x = decoder->private_->frame.header.number.frame_number; - decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER; - if(decoder->private_->fixed_block_size) - decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->fixed_block_size * (FLAC__uint64)x; - else if(decoder->private_->has_stream_info) { - if(decoder->private_->stream_info.data.stream_info.min_blocksize == decoder->private_->stream_info.data.stream_info.max_blocksize) { - decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->stream_info.data.stream_info.min_blocksize * (FLAC__uint64)x; - decoder->private_->next_fixed_block_size = decoder->private_->stream_info.data.stream_info.max_blocksize; - } - else - is_unparseable = true; - } - else if(x == 0) { - decoder->private_->frame.header.number.sample_number = 0; - decoder->private_->next_fixed_block_size = decoder->private_->frame.header.blocksize; - } - else { - /* can only get here if the stream has invalid frame numbering and no STREAMINFO, so assume it's not the last (possibly short) frame */ - decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->frame.header.blocksize * (FLAC__uint64)x; - } - } - - if(is_unparseable) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - - return true; -} - -FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode) -{ - FLAC__uint32 x; - FLAC__bool wasted_bits; - uint32_t i; - - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) /* MAGIC NUMBER */ - return false; /* read_callback_ sets the state for us */ - - wasted_bits = (x & 1); - x &= 0xfe; - - if(wasted_bits) { - uint32_t u; - if(!FLAC__bitreader_read_unary_unsigned(decoder->private_->input, &u)) - return false; /* read_callback_ sets the state for us */ - decoder->private_->frame.subframes[channel].wasted_bits = u+1; - if (decoder->private_->frame.subframes[channel].wasted_bits >= bps) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - bps -= decoder->private_->frame.subframes[channel].wasted_bits; - } - else - decoder->private_->frame.subframes[channel].wasted_bits = 0; - - /* - * Lots of magic numbers here - */ - if(x & 0x80) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - else if(x == 0) { - if(!read_subframe_constant_(decoder, channel, bps, do_full_decode)) - return false; - } - else if(x == 2) { - if(!read_subframe_verbatim_(decoder, channel, bps, do_full_decode)) - return false; - } - else if(x < 16) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - else if(x <= 24) { - uint32_t predictor_order = (x>>1)&7; - if(decoder->private_->frame.header.blocksize <= predictor_order){ - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - if(!read_subframe_fixed_(decoder, channel, bps, predictor_order, do_full_decode)) - return false; - if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption */ - return true; - } - else if(x < 64) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - else { - uint32_t predictor_order = ((x>>1)&31)+1; - if(decoder->private_->frame.header.blocksize <= predictor_order){ - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - if(!read_subframe_lpc_(decoder, channel, bps, predictor_order, do_full_decode)) - return false; - if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption */ - return true; - } - - if(wasted_bits && do_full_decode) { - x = decoder->private_->frame.subframes[channel].wasted_bits; - if((bps + x) < 33) { - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { - uint32_t val = decoder->private_->output[channel][i]; - decoder->private_->output[channel][i] = (val << x); - } - } - else { - /* When there are wasted bits, bps is never 33 and so - * side_subframe is never already in use */ - FLAC__ASSERT(!decoder->private_->side_subframe_in_use); - decoder->private_->side_subframe_in_use = true; - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { - uint64_t val = decoder->private_->output[channel][i]; - decoder->private_->side_subframe[i] = (val << x); - } - } - } - - return true; -} - -FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode) -{ - FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant; - FLAC__int64 x; - uint32_t i; - - decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; - - if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &x, bps)) - return false; /* read_callback_ sets the state for us */ - - subframe->value = x; - - /* decode the subframe */ - if(do_full_decode) { - if(bps <= 32) { - FLAC__int32 *output = decoder->private_->output[channel]; - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) - output[i] = x; - } else { - FLAC__int64 *output = decoder->private_->side_subframe; - decoder->private_->side_subframe_in_use = true; - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) - output[i] = x; - } - } - - return true; -} - -FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode) -{ - FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed; - FLAC__int64 i64; - FLAC__uint32 u32; - uint32_t u; - - decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED; - - subframe->residual = decoder->private_->residual[channel]; - subframe->order = order; - - /* read warm-up samples */ - for(u = 0; u < order; u++) { - if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &i64, bps)) - return false; /* read_callback_ sets the state for us */ - subframe->warmup[u] = i64; - } - - /* read entropy coding method info */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN)) - return false; /* read_callback_ sets the state for us */ - subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32; - switch(subframe->entropy_coding_method.type) { - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN)) - return false; /* read_callback_ sets the state for us */ - if((decoder->private_->frame.header.blocksize >> u32 < order) || - (decoder->private_->frame.header.blocksize % (1 << u32) > 0)) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - subframe->entropy_coding_method.data.partitioned_rice.order = u32; - subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel]; - break; - default: - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - - /* read residual */ - switch(subframe->entropy_coding_method.type) { - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: - if(!read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->private_->partitioned_rice_contents[channel], decoder->private_->residual[channel], /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2)) - return false; - break; - default: - FLAC__ASSERT(0); - } - - /* decode the subframe */ - if(do_full_decode) { - if(bps < 33){ - uint32_t i; - for(i = 0; i < order; i++) - decoder->private_->output[channel][i] = subframe->warmup[i]; - if(bps+order <= 32) - FLAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->output[channel]+order); - else - FLAC__fixed_restore_signal_wide(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->output[channel]+order); - } - else { - decoder->private_->side_subframe_in_use = true; - memcpy(decoder->private_->side_subframe, subframe->warmup, sizeof(FLAC__int64) * order); - FLAC__fixed_restore_signal_wide_33bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->side_subframe+order); - } - } - - return true; -} - -FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode) -{ - FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc; - FLAC__int32 i32; - FLAC__int64 i64; - FLAC__uint32 u32; - uint32_t u; - - decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; - - subframe->residual = decoder->private_->residual[channel]; - subframe->order = order; - - /* read warm-up samples */ - for(u = 0; u < order; u++) { - if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &i64, bps)) - return false; /* read_callback_ sets the state for us */ - subframe->warmup[u] = i64; - } - - /* read qlp coeff precision */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN)) - return false; /* read_callback_ sets the state for us */ - if(u32 == (1u << FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN) - 1) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - subframe->qlp_coeff_precision = u32+1; - - /* read qlp shift */ - if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN)) - return false; /* read_callback_ sets the state for us */ - if(i32 < 0) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - subframe->quantization_level = i32; - - /* read quantized lp coefficiencts */ - for(u = 0; u < order; u++) { - if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, subframe->qlp_coeff_precision)) - return false; /* read_callback_ sets the state for us */ - subframe->qlp_coeff[u] = i32; - } - - /* read entropy coding method info */ - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN)) - return false; /* read_callback_ sets the state for us */ - subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32; - switch(subframe->entropy_coding_method.type) { - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN)) - return false; /* read_callback_ sets the state for us */ - if((decoder->private_->frame.header.blocksize >> u32 < order) || - (decoder->private_->frame.header.blocksize % (1 << u32) > 0)) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - subframe->entropy_coding_method.data.partitioned_rice.order = u32; - subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel]; - break; - default: - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - - /* read residual */ - switch(subframe->entropy_coding_method.type) { - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: - if(!read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->private_->partitioned_rice_contents[channel], decoder->private_->residual[channel], /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2)) - return false; - break; - default: - FLAC__ASSERT(0); - } - - /* decode the subframe */ - if(do_full_decode) { - if(bps <= 32) { - uint32_t i; - for(i = 0; i < order; i++) - decoder->private_->output[channel][i] = subframe->warmup[i]; - if(FLAC__lpc_max_residual_bps(bps, subframe->qlp_coeff, order, subframe->quantization_level) <= 32 && - FLAC__lpc_max_prediction_before_shift_bps(bps, subframe->qlp_coeff, order) <= 32) - FLAC__lpc_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); - else - FLAC__lpc_restore_signal_wide(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order); - } - else { - decoder->private_->side_subframe_in_use = true; - memcpy(decoder->private_->side_subframe, subframe->warmup, sizeof(FLAC__int64) * order); - FLAC__lpc_restore_signal_wide_33bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->side_subframe+order); - } - } - - return true; -} - -FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode) -{ - FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim; - uint32_t i; - - decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; - - if(bps < 33) { - FLAC__int32 x, *residual = decoder->private_->residual[channel]; - - subframe->data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32; - subframe->data.int32 = residual; - - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { - if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps)) - return false; /* read_callback_ sets the state for us */ - residual[i] = x; - } - - /* decode the subframe */ - if(do_full_decode) - memcpy(decoder->private_->output[channel], subframe->data.int32, sizeof(FLAC__int32) * decoder->private_->frame.header.blocksize); - } - else { - FLAC__int64 x, *side = decoder->private_->side_subframe; - - subframe->data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT64; - subframe->data.int64 = side; - decoder->private_->side_subframe_in_use = true; - - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { - if(!FLAC__bitreader_read_raw_int64(decoder->private_->input, &x, bps)) - return false; /* read_callback_ sets the state for us */ - side[i] = x; - } - } - - return true; -} - -FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, uint32_t partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended) -{ - FLAC__uint32 rice_parameter; - int i; - uint32_t partition, sample, u; - const uint32_t partitions = 1u << partition_order; - const uint32_t partition_samples = decoder->private_->frame.header.blocksize >> partition_order; - const uint32_t plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; - const uint32_t pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; - - /* invalid predictor and partition orders mush be handled in the callers */ - FLAC__ASSERT(partition_order > 0? partition_samples >= predictor_order : decoder->private_->frame.header.blocksize >= predictor_order); - - if(!FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(partitioned_rice_contents, flac_max(6u, partition_order))) { - decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; - return false; - } - - sample = 0; - for(partition = 0; partition < partitions; partition++) { - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, plen)) - return false; /* read_callback_ sets the state for us */ - partitioned_rice_contents->parameters[partition] = rice_parameter; - if(rice_parameter < pesc) { - partitioned_rice_contents->raw_bits[partition] = 0; - u = (partition == 0) ? partition_samples - predictor_order : partition_samples; - if(!decoder->private_->local_bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_parameter)){ - if(decoder->protected_->state == FLAC__STREAM_DECODER_READ_FRAME) { - /* no error was set, read_callback_ didn't set it, so - * invalid rice symbol was found */ - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - return true; - } - else - return false; /* read_callback_ sets the state for us */ - } - sample += u; - } - else { - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN)) - return false; /* read_callback_ sets the state for us */ - partitioned_rice_contents->raw_bits[partition] = rice_parameter; - if(rice_parameter == 0) { - for(u = (partition == 0)? predictor_order : 0; u < partition_samples; u++, sample++) - residual[sample] = 0; - } - else{ - for(u = (partition == 0)? predictor_order : 0; u < partition_samples; u++, sample++) { - if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter)) - return false; /* read_callback_ sets the state for us */ - residual[sample] = i; - } - } - } - } - - return true; -} - -FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder) -{ - if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) { - FLAC__uint32 zero = 0; - if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &zero, FLAC__bitreader_bits_left_for_byte_alignment(decoder->private_->input))) - return false; /* read_callback_ sets the state for us */ -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - if(zero != 0) { - send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); - decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; - } -#endif - } - return true; -} - -FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data; - - if( -#if FLAC__HAS_OGG - /* see [1] HACK NOTE below for why we don't call the eof_callback when decoding Ogg FLAC */ - !decoder->private_->is_ogg && -#endif - decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->client_data) - ) { - *bytes = 0; - decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; - return false; - } - else if(*bytes > 0) { - /* While seeking, it is possible for our seek to land in the - * middle of audio data that looks exactly like a frame header - * from a future version of an encoder. When that happens, our - * error callback will get an - * FLAC__STREAM_DECODER_UNPARSEABLE_STREAM and increment its - * unparseable_frame_count. But there is a remote possibility - * that it is properly synced at such a "future-codec frame", - * so to make sure, we wait to see many "unparseable" errors in - * a row before bailing out. - */ - if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) { - decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; - return false; - } - else { - const FLAC__StreamDecoderReadStatus status = -#if FLAC__HAS_OGG - decoder->private_->is_ogg? - read_callback_ogg_aspect_(decoder, buffer, bytes) : -#endif - decoder->private_->read_callback(decoder, buffer, bytes, decoder->private_->client_data) - ; - if(status == FLAC__STREAM_DECODER_READ_STATUS_ABORT) { - decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; - return false; - } - else if(*bytes == 0) { - if( - status == FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM || - ( -#if FLAC__HAS_OGG - /* see [1] HACK NOTE below for why we don't call the eof_callback when decoding Ogg FLAC */ - !decoder->private_->is_ogg && -#endif - decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->client_data) - ) - ) { - decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM; - return false; - } - else - return true; - } - else - return true; - } - } - else { - /* abort to avoid a deadlock */ - decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; - return false; - } - /* [1] @@@ HACK NOTE: The end-of-stream checking has to be hacked around - * for Ogg FLAC. This is because the ogg decoder aspect can lose sync - * and at the same time hit the end of the stream (for example, seeking - * to a point that is after the beginning of the last Ogg page). There - * is no way to report an Ogg sync loss through the callbacks (see note - * in read_callback_ogg_aspect_()) so it returns CONTINUE with *bytes==0. - * So to keep the decoder from stopping at this point we gate the call - * to the eof_callback and let the Ogg decoder aspect set the - * end-of-stream state when it is needed. - */ -} - -#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) && !defined(FUZZING_BUILD_MODE_FLAC_SANITIZE_SIGNED_INTEGER_OVERFLOW) -/* The attribute below is to silence the undefined sanitizer of oss-fuzz. - * Because fuzzing feeds bogus predictors and residual samples to the - * decoder, having overflows in this section is unavoidable. Also, - * because the calculated values are audio path only, there is no - * potential for security problems */ -__attribute__((no_sanitize("signed-integer-overflow"))) -#endif -void undo_channel_coding(FLAC__StreamDecoder *decoder) { - uint32_t i; - switch(decoder->private_->frame.header.channel_assignment) { - case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: - /* do nothing */ - break; - case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: - FLAC__ASSERT(decoder->private_->frame.header.channels == 2); - FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32)); - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) - if(decoder->private_->side_subframe_in_use) - decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->side_subframe[i]; - else - decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->output[1][i]; - break; - case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: - FLAC__ASSERT(decoder->private_->frame.header.channels == 2); - FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32)); - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) - if(decoder->private_->side_subframe_in_use) - decoder->private_->output[0][i] = decoder->private_->output[1][i] + decoder->private_->side_subframe[i]; - else - decoder->private_->output[0][i] += decoder->private_->output[1][i]; - break; - case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: - FLAC__ASSERT(decoder->private_->frame.header.channels == 2); - FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32)); - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { - if(!decoder->private_->side_subframe_in_use){ - FLAC__int32 mid, side; - mid = decoder->private_->output[0][i]; - side = decoder->private_->output[1][i]; - mid = ((uint32_t) mid) << 1; - mid |= (side & 1); /* i.e. if 'side' is odd... */ - decoder->private_->output[0][i] = (mid + side) >> 1; - decoder->private_->output[1][i] = (mid - side) >> 1; - } - else { /* bps == 32 */ - FLAC__int64 mid; - mid = ((uint64_t)decoder->private_->output[0][i]) << 1; - mid |= (decoder->private_->side_subframe[i] & 1); /* i.e. if 'side' is odd... */ - decoder->private_->output[0][i] = (mid + decoder->private_->side_subframe[i]) >> 1; - decoder->private_->output[1][i] = (mid - decoder->private_->side_subframe[i]) >> 1; - } - } - break; - default: - FLAC__ASSERT(0); - break; - } -} - -#if FLAC__HAS_OGG -FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes) -{ - switch(FLAC__ogg_decoder_aspect_read_callback_wrapper(&decoder->protected_->ogg_decoder_aspect, buffer, bytes, read_callback_proxy_, decoder, decoder->private_->client_data)) { - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK: - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - /* we don't really have a way to handle lost sync via read - * callback so we'll let it pass and let the underlying - * FLAC decoder catch the error - */ - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC: - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM: - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC: - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION: - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT: - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_ERROR: - case FLAC__OGG_DECODER_ASPECT_READ_STATUS_MEMORY_ALLOCATION_ERROR: - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - default: - FLAC__ASSERT(0); - /* double protection */ - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - } -} - -FLAC__OggDecoderAspectReadStatus read_callback_proxy_(const void *void_decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder*)void_decoder; - - switch(decoder->private_->read_callback(decoder, buffer, bytes, client_data)) { - case FLAC__STREAM_DECODER_READ_STATUS_CONTINUE: - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK; - case FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM: - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM; - case FLAC__STREAM_DECODER_READ_STATUS_ABORT: - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT; - default: - /* double protection: */ - FLAC__ASSERT(0); - return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT; - } -} -#endif - -FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[]) -{ - decoder->private_->last_frame = *frame; /* save the frame */ - decoder->private_->last_frame_is_set = true; - if(decoder->private_->is_seeking) { - FLAC__uint64 this_frame_sample = frame->header.number.sample_number; - FLAC__uint64 next_frame_sample = this_frame_sample + (FLAC__uint64)frame->header.blocksize; - FLAC__uint64 target_sample = decoder->private_->target_sample; - - FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); - -#if FLAC__HAS_OGG - decoder->private_->got_a_frame = true; -#endif - if(this_frame_sample <= target_sample && target_sample < next_frame_sample) { /* we hit our target frame */ - uint32_t delta = (uint32_t)(target_sample - this_frame_sample); - /* kick out of seek mode */ - decoder->private_->is_seeking = false; - /* shift out the samples before target_sample */ - if(delta > 0) { - uint32_t channel; - const FLAC__int32 *newbuffer[FLAC__MAX_CHANNELS]; - for(channel = 0; channel < frame->header.channels; channel++) { - newbuffer[channel] = buffer[channel] + delta; - decoder->private_->last_frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; - decoder->private_->last_frame.subframes[channel].data.verbatim.data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32; - decoder->private_->last_frame.subframes[channel].data.verbatim.data.int32 = newbuffer[channel]; - } - decoder->private_->last_frame.header.blocksize -= delta; - decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta; - /* write the relevant samples */ - return decoder->private_->write_callback(decoder, &decoder->private_->last_frame, newbuffer, decoder->private_->client_data); - } - else { - /* write the relevant samples */ - return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); - } - } - else { - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; - } - } - else { - /* - * If we never got STREAMINFO, turn off MD5 checking to save - * cycles since we don't have a sum to compare to anyway - */ - if(!decoder->private_->has_stream_info) - decoder->private_->do_md5_checking = false; - if(decoder->private_->do_md5_checking) { - if(!FLAC__MD5Accumulate(&decoder->private_->md5context, buffer, frame->header.channels, frame->header.blocksize, (frame->header.bits_per_sample+7) / 8)) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data); - } -} - -void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status) -{ - if(!decoder->private_->is_seeking) - decoder->private_->error_callback(decoder, status, decoder->private_->client_data); - else if(status == FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM) - decoder->private_->unparseable_frame_count++; -} - -FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample) -{ - FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound, lower_bound_sample, upper_bound_sample, this_frame_sample; - FLAC__int64 pos = -1; - int i; - uint32_t approx_bytes_per_frame; - FLAC__bool first_seek = true, seek_from_lower_bound = false; - const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder); - const uint32_t min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize; - const uint32_t max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize; - const uint32_t max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize; - const uint32_t min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize; - /* take these from the current frame in case they've changed mid-stream */ - uint32_t channels = FLAC__stream_decoder_get_channels(decoder); - uint32_t bps = FLAC__stream_decoder_get_bits_per_sample(decoder); - const FLAC__StreamMetadata_SeekTable *seek_table = decoder->private_->has_seek_table? &decoder->private_->seek_table.data.seek_table : 0; - - /* use values from stream info if we didn't decode a frame */ - if(channels == 0) - channels = decoder->private_->stream_info.data.stream_info.channels; - if(bps == 0) - bps = decoder->private_->stream_info.data.stream_info.bits_per_sample; - - /* we are just guessing here */ - if(max_framesize > 0) - approx_bytes_per_frame = (max_framesize + min_framesize) / 2 + 1; - /* - * Check if it's a known fixed-blocksize stream. Note that though - * the spec doesn't allow zeroes in the STREAMINFO block, we may - * never get a STREAMINFO block when decoding so the value of - * min_blocksize might be zero. - */ - else if(min_blocksize == max_blocksize && min_blocksize > 0) { - /* note there are no () around 'bps/8' to keep precision up since it's an integer calculation */ - approx_bytes_per_frame = min_blocksize * channels * bps/8 + 64; - } - else - approx_bytes_per_frame = 4096 * channels * bps/8 + 64; - - /* - * First, we set an upper and lower bound on where in the - * stream we will search. For now we take the current position - * as one bound and, depending on where the target position lies, - * the beginning of the first frame or the end of the stream as - * the other bound. - */ - lower_bound = first_frame_offset; - lower_bound_sample = 0; - upper_bound = stream_length; - upper_bound_sample = total_samples > 0 ? total_samples : target_sample /*estimate it*/; - - if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC && - decoder->private_->samples_decoded != 0) { - if(target_sample < decoder->private_->samples_decoded) { - if(FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) - upper_bound_sample = decoder->private_->samples_decoded; - } else { - if(FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) - lower_bound_sample = decoder->private_->samples_decoded; - } - } - - /* - * Now we refine the bounds if we have a seektable with - * suitable points. Note that according to the spec they - * must be ordered by ascending sample number. - * - * Note: to protect against invalid seek tables we will ignore points - * that have frame_samples==0 or sample_number>=total_samples. Also, - * because math is limited to 64-bit ints, seekpoints with an offset - * larger than 2^63 (8 exbibyte) are rejected. - */ - if(seek_table) { - FLAC__uint64 new_lower_bound = lower_bound; - FLAC__uint64 new_upper_bound = upper_bound; - FLAC__uint64 new_lower_bound_sample = lower_bound_sample; - FLAC__uint64 new_upper_bound_sample = upper_bound_sample; - - /* find the closest seek point <= target_sample, if it exists */ - for(i = (int)seek_table->num_points - 1; i >= 0; i--) { - if( - seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && - seek_table->points[i].frame_samples > 0 && /* defense against bad seekpoints */ - (total_samples <= 0 || seek_table->points[i].sample_number < total_samples) && /* defense against bad seekpoints */ - seek_table->points[i].sample_number <= target_sample - ) - break; - } - if(i >= 0) { /* i.e. we found a suitable seek point... */ - new_lower_bound = first_frame_offset + seek_table->points[i].stream_offset; - new_lower_bound_sample = seek_table->points[i].sample_number; - } - - /* find the closest seek point > target_sample, if it exists */ - for(i = 0; i < (int)seek_table->num_points; i++) { - if( - seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && - seek_table->points[i].frame_samples > 0 && /* defense against bad seekpoints */ - (total_samples <= 0 || seek_table->points[i].sample_number < total_samples) && /* defense against bad seekpoints */ - seek_table->points[i].sample_number > target_sample - ) - break; - } - if(i < (int)seek_table->num_points) { /* i.e. we found a suitable seek point... */ - new_upper_bound = first_frame_offset + seek_table->points[i].stream_offset; - new_upper_bound_sample = seek_table->points[i].sample_number; - } - /* final protection against unsorted seek tables; keep original values if bogus */ - if(new_upper_bound >= new_lower_bound) { - lower_bound = new_lower_bound; - upper_bound = new_upper_bound; - lower_bound_sample = new_lower_bound_sample; - upper_bound_sample = new_upper_bound_sample; - } - } - - FLAC__ASSERT(upper_bound_sample >= lower_bound_sample); - /* there are 2 insidious ways that the following equality occurs, which - * we need to fix: - * 1) total_samples is 0 (unknown) and target_sample is 0 - * 2) total_samples is 0 (unknown) and target_sample happens to be - * exactly equal to the last seek point in the seek table; this - * means there is no seek point above it, and upper_bound_samples - * remains equal to the estimate (of target_samples) we made above - * in either case it does not hurt to move upper_bound_sample up by 1 - */ - if(upper_bound_sample == lower_bound_sample) - upper_bound_sample++; - - decoder->private_->target_sample = target_sample; - while(1) { - /* check whether decoder is still valid so bad state isn't overwritten - * with seek error */ - if(decoder->protected_->state == FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR || - decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) - return false; - /* check if the bounds are still ok */ - if (lower_bound_sample >= upper_bound_sample || - lower_bound > upper_bound || - upper_bound >= INT64_MAX) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - if(seek_from_lower_bound) { - pos = lower_bound; - } - else { -#ifndef FLAC__INTEGER_ONLY_LIBRARY - pos = (FLAC__int64)lower_bound + (FLAC__int64)((double)(target_sample - lower_bound_sample) / (double)(upper_bound_sample - lower_bound_sample) * (double)(upper_bound - lower_bound)) - approx_bytes_per_frame; -#else - /* a little less accurate: */ - if(upper_bound - lower_bound < 0xffffffff) - pos = (FLAC__int64)lower_bound + (FLAC__int64)(((target_sample - lower_bound_sample) * (upper_bound - lower_bound)) / (upper_bound_sample - lower_bound_sample)) - approx_bytes_per_frame; - else { /* @@@ WATCHOUT, ~2TB limit */ - FLAC__uint64 ratio = (1<<16) / (upper_bound_sample - lower_bound_sample); - pos = (FLAC__int64)lower_bound + (FLAC__int64)((((target_sample - lower_bound_sample)>>8) * ((upper_bound - lower_bound)>>8) * ratio)) - approx_bytes_per_frame; - } -#endif - } - if(pos >= (FLAC__int64)upper_bound) - pos = (FLAC__int64)upper_bound - 1; - if(pos < (FLAC__int64)lower_bound) - pos = (FLAC__int64)lower_bound; - if(decoder->private_->seek_callback(decoder, (FLAC__uint64)pos, decoder->private_->client_data) != FLAC__STREAM_DECODER_SEEK_STATUS_OK) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - if(!FLAC__stream_decoder_flush(decoder)) { - /* above call sets the state for us */ - return false; - } - /* Now we need to get a frame. First we need to reset our - * unparseable_frame_count; if we get too many unparseable - * frames in a row, the read callback will return - * FLAC__STREAM_DECODER_READ_STATUS_ABORT, causing - * FLAC__stream_decoder_process_single() to return false. - */ - decoder->private_->unparseable_frame_count = 0; - if(!FLAC__stream_decoder_process_single(decoder) || decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED || 0 == decoder->private_->samples_decoded) { - /* No frame could be decoded */ - if(decoder->protected_->state != FLAC__STREAM_DECODER_ABORTED && decoder->private_->eof_callback(decoder, decoder->private_->client_data) && !seek_from_lower_bound){ - /* decoder has hit end of stream while processing corrupt - * frame. To remedy this, try decoding a frame at the lower - * bound so the seek after that hopefully ends up somewhere - * else */ - seek_from_lower_bound = true; - continue; - } - else { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - } - seek_from_lower_bound = false; - - /* our write callback will change the state when it gets to the target frame */ - /* actually, we could have got_a_frame if our decoder is at FLAC__STREAM_DECODER_END_OF_STREAM so we need to check for that also */ - if(!decoder->private_->is_seeking) - break; - - FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); - this_frame_sample = decoder->private_->last_frame.header.number.sample_number; - - if(this_frame_sample + decoder->private_->last_frame.header.blocksize >= upper_bound_sample && !first_seek) { - if (pos == (FLAC__int64)lower_bound) { - /* can't move back any more than the first frame, something is fatally wrong */ - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - /* our last move backwards wasn't big enough, try again */ - approx_bytes_per_frame = approx_bytes_per_frame? approx_bytes_per_frame * 2 : 16; - continue; - } - /* allow one seek over upper bound, so we can get a correct upper_bound_sample for streams with unknown total_samples */ - first_seek = false; - - /* make sure we are not seeking in corrupted stream */ - if (this_frame_sample < lower_bound_sample) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - - /* we need to narrow the search */ - if(target_sample < this_frame_sample) { - upper_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; -/*@@@@@@ what will decode position be if at end of stream? */ - if(!FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - approx_bytes_per_frame = (uint32_t)(2 * (upper_bound - pos) / 3 + 16); - } - else { /* target_sample >= this_frame_sample + this frame's blocksize */ - lower_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; - if(!FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - approx_bytes_per_frame = (uint32_t)(2 * (lower_bound - pos) / 3 + 16); - } - } - - return true; -} - -#if FLAC__HAS_OGG -FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample) -{ - FLAC__uint64 left_pos = 0, right_pos = stream_length; - FLAC__uint64 left_sample = 0, right_sample = FLAC__stream_decoder_get_total_samples(decoder); - FLAC__uint64 this_frame_sample = (FLAC__uint64)0 - 1; - FLAC__uint64 pos = 0; /* only initialized to avoid compiler warning */ - FLAC__bool did_a_seek; - uint32_t iteration = 0; - - /* In the first iterations, we will calculate the target byte position - * by the distance from the target sample to left_sample and - * right_sample (let's call it "proportional search"). After that, we - * will switch to binary search. - */ - uint32_t BINARY_SEARCH_AFTER_ITERATION = 2; - - /* We will switch to a linear search once our current sample is less - * than this number of samples ahead of the target sample - */ - static const FLAC__uint64 LINEAR_SEARCH_WITHIN_SAMPLES = FLAC__MAX_BLOCK_SIZE * 2; - - /* If the total number of samples is unknown, use a large value, and - * force binary search immediately. - */ - if(right_sample == 0) { - right_sample = (FLAC__uint64)(-1); - BINARY_SEARCH_AFTER_ITERATION = 0; - } - - decoder->private_->target_sample = target_sample; - for( ; ; iteration++) { - /* Do sanity checks on bounds */ - if(right_pos <= left_pos || right_pos - left_pos < 9) { - /* FLAC frame is at least 9 byte in size */ - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - if (iteration == 0 || this_frame_sample > target_sample || target_sample - this_frame_sample > LINEAR_SEARCH_WITHIN_SAMPLES) { - if (iteration >= BINARY_SEARCH_AFTER_ITERATION) { - pos = (right_pos + left_pos) / 2; - } - else { -#ifndef FLAC__INTEGER_ONLY_LIBRARY - pos = (FLAC__uint64)((double)(target_sample - left_sample) / (double)(right_sample - left_sample) * (double)(right_pos - left_pos)); -#else - /* a little less accurate: */ - if ((target_sample-left_sample <= 0xffffffff) && (right_pos-left_pos <= 0xffffffff)) - pos = (FLAC__int64)(((target_sample-left_sample) * (right_pos-left_pos)) / (right_sample-left_sample)); - else /* @@@ WATCHOUT, ~2TB limit */ - pos = (FLAC__int64)((((target_sample-left_sample)>>8) * ((right_pos-left_pos)>>8)) / ((right_sample-left_sample)>>16)); -#endif - /* @@@ TODO: might want to limit pos to some distance - * before EOF, to make sure we land before the last frame, - * thereby getting a this_frame_sample and so having a better - * estimate. - */ - } - - /* physical seek */ - if(decoder->private_->seek_callback((FLAC__StreamDecoder*)decoder, (FLAC__uint64)pos, decoder->private_->client_data) != FLAC__STREAM_DECODER_SEEK_STATUS_OK) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - if(!FLAC__stream_decoder_flush(decoder)) { - /* above call sets the state for us */ - return false; - } - did_a_seek = true; - } - else - did_a_seek = false; - - decoder->private_->got_a_frame = false; - if(!FLAC__stream_decoder_process_single(decoder) || - decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - if(!decoder->private_->got_a_frame) { - if(did_a_seek) { - /* this can happen if we seek to a point after the last frame; we drop - * to binary search right away in this case to avoid any wasted - * iterations of proportional search. - */ - right_pos = pos; - BINARY_SEARCH_AFTER_ITERATION = 0; - } - else { - /* this can probably only happen if total_samples is unknown and the - * target_sample is past the end of the stream - */ - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - } - /* our write callback will change the state when it gets to the target frame */ - else if(!decoder->private_->is_seeking) { - break; - } - else { - this_frame_sample = decoder->private_->last_frame.header.number.sample_number; - FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); - - if (did_a_seek) { - if (this_frame_sample <= target_sample) { - /* The 'equal' case should not happen, since - * FLAC__stream_decoder_process_single() - * should recognize that it has hit the - * target sample and we would exit through - * the 'break' above. - */ - FLAC__ASSERT(this_frame_sample != target_sample); - - left_sample = this_frame_sample; - /* sanity check to avoid infinite loop */ - if (left_pos == pos) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - left_pos = pos; - } - else { - right_sample = this_frame_sample; - /* sanity check to avoid infinite loop */ - if (right_pos == pos) { - decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; - return false; - } - right_pos = pos; - } - } - } - } - - return true; -} -#endif - -FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - (void)client_data; - - if(*bytes > 0) { - *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, decoder->private_->file); - if(ferror(decoder->private_->file)) - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - else if(*bytes == 0) - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - else - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - else - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */ -} - -FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) -{ - (void)client_data; - - if(decoder->private_->file == stdin) - return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; - else if(fseeko(decoder->private_->file, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) - return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - else - return FLAC__STREAM_DECODER_SEEK_STATUS_OK; -} - -FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) -{ - FLAC__off_t pos; - (void)client_data; - - if(decoder->private_->file == stdin) - return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED; - else if((pos = ftello(decoder->private_->file)) < 0) - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - else { - *absolute_byte_offset = (FLAC__uint64)pos; - return FLAC__STREAM_DECODER_TELL_STATUS_OK; - } -} - -FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) -{ - struct flac_stat_s filestats; - (void)client_data; - - if(decoder->private_->file == stdin) - return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; - -#ifndef FLAC__USE_FILELENGTHI64 - if(flac_fstat(fileno(decoder->private_->file), &filestats) != 0) -#else - filestats.st_size = _filelengthi64(fileno(decoder->private_->file)); - if(filestats.st_size < 0) -#endif - return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; - else { - *stream_length = (FLAC__uint64)filestats.st_size; - return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; - } -} - -FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data) -{ - (void)client_data; - - return feof(decoder->private_->file)? true : false; -} diff --git a/Engine/lib/flac/src/libFLAC/stream_encoder.c b/Engine/lib/flac/src/libFLAC/stream_encoder.c deleted file mode 100644 index c1c03e49e..000000000 --- a/Engine/lib/flac/src/libFLAC/stream_encoder.c +++ /dev/null @@ -1,4738 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include /* for malloc() */ -#include /* for memcpy() */ -#include /* for off_t */ -#ifdef _WIN32 -#include /* for GetFileType() */ -#include /* for _get_osfhandle() */ -#endif -#include "share/compat.h" -#include "FLAC/assert.h" -#include "FLAC/stream_decoder.h" -#include "protected/stream_encoder.h" -#include "private/bitwriter.h" -#include "private/bitmath.h" -#include "private/crc.h" -#include "private/cpu.h" -#include "private/fixed.h" -#include "private/format.h" -#include "private/lpc.h" -#include "private/md5.h" -#include "private/memory.h" -#include "private/macros.h" -#if FLAC__HAS_OGG -#include "private/ogg_helper.h" -#include "private/ogg_mapping.h" -#endif -#include "private/stream_encoder.h" -#include "private/stream_encoder_framing.h" -#include "private/window.h" -#include "share/alloc.h" -#include "share/private.h" - - -/* Exact Rice codeword length calculation is off by default. The simple - * (and fast) estimation (of how many bits a residual value will be - * encoded with) in this encoder is very good, almost always yielding - * compression within 0.1% of exact calculation. - */ -#undef EXACT_RICE_BITS_CALCULATION -/* Rice parameter searching is off by default. The simple (and fast) - * parameter estimation in this encoder is very good, almost always - * yielding compression within 0.1% of the optimal parameters. - */ -#undef ENABLE_RICE_PARAMETER_SEARCH - - -typedef struct { - FLAC__int32 *data[FLAC__MAX_CHANNELS]; - uint32_t size; /* of each data[] in samples */ - uint32_t tail; -} verify_input_fifo; - -typedef struct { - const FLAC__byte *data; - uint32_t capacity; - uint32_t bytes; -} verify_output; - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -typedef struct { - uint32_t a, b, c; - FLAC__ApodizationSpecification * current_apodization; - double autoc_root[FLAC__MAX_LPC_ORDER+1]; - double autoc[FLAC__MAX_LPC_ORDER+1]; -} apply_apodization_state_struct; -#endif - -typedef enum { - ENCODER_IN_MAGIC = 0, - ENCODER_IN_METADATA = 1, - ENCODER_IN_AUDIO = 2 -} EncoderStateHint; - -static const struct CompressionLevels { - FLAC__bool do_mid_side_stereo; - FLAC__bool loose_mid_side_stereo; - uint32_t max_lpc_order; - uint32_t qlp_coeff_precision; - FLAC__bool do_qlp_coeff_prec_search; - FLAC__bool do_escape_coding; - FLAC__bool do_exhaustive_model_search; - uint32_t min_residual_partition_order; - uint32_t max_residual_partition_order; - uint32_t rice_parameter_search_dist; - const char *apodization; -} compression_levels_[] = { - { false, false, 0, 0, false, false, false, 0, 3, 0, "tukey(5e-1)" }, - { true , true , 0, 0, false, false, false, 0, 3, 0, "tukey(5e-1)" }, - { true , false, 0, 0, false, false, false, 0, 3, 0, "tukey(5e-1)" }, - { false, false, 6, 0, false, false, false, 0, 4, 0, "tukey(5e-1)" }, - { true , true , 8, 0, false, false, false, 0, 4, 0, "tukey(5e-1)" }, - { true , false, 8, 0, false, false, false, 0, 5, 0, "tukey(5e-1)" }, - { true , false, 8, 0, false, false, false, 0, 6, 0, "subdivide_tukey(2)" }, - { true , false, 12, 0, false, false, false, 0, 6, 0, "subdivide_tukey(2)" }, - { true , false, 12, 0, false, false, false, 0, 6, 0, "subdivide_tukey(3)" } - /* here we use locale-independent 5e-1 instead of 0.5 or 0,5 */ -}; - - -/*********************************************************************** - * - * Private class method prototypes - * - ***********************************************************************/ - -static void set_defaults_(FLAC__StreamEncoder *encoder); -static void free_(FLAC__StreamEncoder *encoder); -static FLAC__bool resize_buffers_(FLAC__StreamEncoder *encoder, uint32_t new_blocksize); -static FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, uint32_t samples, FLAC__bool is_last_block); -static FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, FLAC__bool is_last_block); -static void update_metadata_(const FLAC__StreamEncoder *encoder); -#if FLAC__HAS_OGG -static void update_ogg_metadata_(FLAC__StreamEncoder *encoder); -#endif -static FLAC__bool process_frame_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_block); -static FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder); - -static FLAC__bool process_subframe_( - FLAC__StreamEncoder *encoder, - uint32_t min_partition_order, - uint32_t max_partition_order, - const FLAC__FrameHeader *frame_header, - uint32_t subframe_bps, - const void *integer_signal, - FLAC__Subframe *subframe[2], - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents[2], - FLAC__int32 *residual[2], - uint32_t *best_subframe, - uint32_t *best_bits -); - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -static FLAC__bool apply_apodization_( - FLAC__StreamEncoder *encoder, - apply_apodization_state_struct *apply_apodization_state, - uint32_t blocksize, - double *lpc_error, - uint32_t *max_lpc_order_this_apodization, - uint32_t subframe_bps, - const void *integer_signal, - uint32_t *guess_lpc_order -); -#endif - -static FLAC__bool add_subframe_( - FLAC__StreamEncoder *encoder, - uint32_t blocksize, - uint32_t subframe_bps, - const FLAC__Subframe *subframe, - FLAC__BitWriter *frame -); - -static uint32_t evaluate_constant_subframe_( - FLAC__StreamEncoder *encoder, - const FLAC__int64 signal, - uint32_t blocksize, - uint32_t subframe_bps, - FLAC__Subframe *subframe -); - -static uint32_t evaluate_fixed_subframe_( - FLAC__StreamEncoder *encoder, - const void *signal, - FLAC__int32 residual[], - FLAC__uint64 abs_residual_partition_sums[], - uint32_t raw_bits_per_partition[], - uint32_t blocksize, - uint32_t subframe_bps, - uint32_t order, - uint32_t rice_parameter_limit, - uint32_t min_partition_order, - uint32_t max_partition_order, - FLAC__bool do_escape_coding, - uint32_t rice_parameter_search_dist, - FLAC__Subframe *subframe, - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents -); - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -static uint32_t evaluate_lpc_subframe_( - FLAC__StreamEncoder *encoder, - const void *signal, - FLAC__int32 residual[], - FLAC__uint64 abs_residual_partition_sums[], - uint32_t raw_bits_per_partition[], - const FLAC__real lp_coeff[], - uint32_t blocksize, - uint32_t subframe_bps, - uint32_t order, - uint32_t qlp_coeff_precision, - uint32_t rice_parameter_limit, - uint32_t min_partition_order, - uint32_t max_partition_order, - FLAC__bool do_escape_coding, - uint32_t rice_parameter_search_dist, - FLAC__Subframe *subframe, - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents -); -#endif - -static uint32_t evaluate_verbatim_subframe_( - FLAC__StreamEncoder *encoder, - const void *signal, - uint32_t blocksize, - uint32_t subframe_bps, - FLAC__Subframe *subframe -); - -static uint32_t find_best_partition_order_( - struct FLAC__StreamEncoderPrivate *private_, - const FLAC__int32 residual[], - FLAC__uint64 abs_residual_partition_sums[], - uint32_t raw_bits_per_partition[], - uint32_t residual_samples, - uint32_t predictor_order, - uint32_t rice_parameter_limit, - uint32_t min_partition_order, - uint32_t max_partition_order, - uint32_t bps, - FLAC__bool do_escape_coding, - uint32_t rice_parameter_search_dist, - FLAC__EntropyCodingMethod *best_ecm -); - -static void precompute_partition_info_sums_( - const FLAC__int32 residual[], - FLAC__uint64 abs_residual_partition_sums[], - uint32_t residual_samples, - uint32_t predictor_order, - uint32_t min_partition_order, - uint32_t max_partition_order, - uint32_t bps -); - -static void precompute_partition_info_escapes_( - const FLAC__int32 residual[], - uint32_t raw_bits_per_partition[], - uint32_t residual_samples, - uint32_t predictor_order, - uint32_t min_partition_order, - uint32_t max_partition_order -); - -static FLAC__bool set_partitioned_rice_( -#ifdef EXACT_RICE_BITS_CALCULATION - const FLAC__int32 residual[], -#endif - const FLAC__uint64 abs_residual_partition_sums[], - const uint32_t raw_bits_per_partition[], - const uint32_t residual_samples, - const uint32_t predictor_order, - const uint32_t rice_parameter_limit, - const uint32_t rice_parameter_search_dist, - const uint32_t partition_order, - const FLAC__bool search_for_escapes, - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, - uint32_t *bits -); - -static uint32_t get_wasted_bits_(FLAC__int32 signal[], uint32_t samples); -static uint32_t get_wasted_bits_wide_(FLAC__int64 signal_wide[], FLAC__int32 signal[], uint32_t samples); - -/* verify-related routines: */ -static void append_to_verify_fifo_( - verify_input_fifo *fifo, - const FLAC__int32 * const input[], - uint32_t input_offset, - uint32_t channels, - uint32_t wide_samples -); - -static void append_to_verify_fifo_interleaved_( - verify_input_fifo *fifo, - const FLAC__int32 input[], - uint32_t input_offset, - uint32_t channels, - uint32_t wide_samples -); - -static FLAC__StreamDecoderReadStatus verify_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); -static FLAC__StreamDecoderWriteStatus verify_write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); -static void verify_metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); -static void verify_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); - -static FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data); -static FLAC__StreamEncoderSeekStatus file_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data); -static FLAC__StreamEncoderTellStatus file_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data); -static FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data); -static FILE *get_binary_stdout_(void); - - -/*********************************************************************** - * - * Private class data - * - ***********************************************************************/ - -typedef struct FLAC__StreamEncoderPrivate { - uint32_t input_capacity; /* current size (in samples) of the signal and residual buffers */ - FLAC__int32 *integer_signal[FLAC__MAX_CHANNELS]; /* the integer version of the input signal */ - FLAC__int32 *integer_signal_mid_side[2]; /* the integer version of the mid-side input signal (stereo only) */ - FLAC__int64 *integer_signal_33bit_side; /* 33-bit side for 32-bit stereo decorrelation */ -#ifndef FLAC__INTEGER_ONLY_LIBRARY - FLAC__real *real_signal[FLAC__MAX_CHANNELS]; /* (@@@ currently unused) the floating-point version of the input signal */ - FLAC__real *real_signal_mid_side[2]; /* (@@@ currently unused) the floating-point version of the mid-side input signal (stereo only) */ - FLAC__real *window[FLAC__MAX_APODIZATION_FUNCTIONS]; /* the pre-computed floating-point window for each apodization function */ - FLAC__real *windowed_signal; /* the integer_signal[] * current window[] */ -#endif - uint32_t subframe_bps[FLAC__MAX_CHANNELS]; /* the effective bits per sample of the input signal (stream bps - wasted bits) */ - uint32_t subframe_bps_mid_side[2]; /* the effective bits per sample of the mid-side input signal (stream bps - wasted bits + 0/1) */ - FLAC__int32 *residual_workspace[FLAC__MAX_CHANNELS][2]; /* each channel has a candidate and best workspace where the subframe residual signals will be stored */ - FLAC__int32 *residual_workspace_mid_side[2][2]; - FLAC__Subframe subframe_workspace[FLAC__MAX_CHANNELS][2]; - FLAC__Subframe subframe_workspace_mid_side[2][2]; - FLAC__Subframe *subframe_workspace_ptr[FLAC__MAX_CHANNELS][2]; - FLAC__Subframe *subframe_workspace_ptr_mid_side[2][2]; - FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents_workspace[FLAC__MAX_CHANNELS][2]; - FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents_workspace_mid_side[FLAC__MAX_CHANNELS][2]; - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents_workspace_ptr[FLAC__MAX_CHANNELS][2]; - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents_workspace_ptr_mid_side[FLAC__MAX_CHANNELS][2]; - uint32_t best_subframe[FLAC__MAX_CHANNELS]; /* index (0 or 1) into 2nd dimension of the above workspaces */ - uint32_t best_subframe_mid_side[2]; - uint32_t best_subframe_bits[FLAC__MAX_CHANNELS]; /* size in bits of the best subframe for each channel */ - uint32_t best_subframe_bits_mid_side[2]; - FLAC__uint64 *abs_residual_partition_sums; /* workspace where the sum of abs(candidate residual) for each partition is stored */ - uint32_t *raw_bits_per_partition; /* workspace where the sum of silog2(candidate residual) for each partition is stored */ - FLAC__BitWriter *frame; /* the current frame being worked on */ - uint32_t loose_mid_side_stereo_frames; /* rounded number of frames the encoder will use before trying both independent and mid/side frames again */ - uint32_t loose_mid_side_stereo_frame_count; /* number of frames using the current channel assignment */ - FLAC__ChannelAssignment last_channel_assignment; - FLAC__StreamMetadata streaminfo; /* scratchpad for STREAMINFO as it is built */ - FLAC__StreamMetadata_SeekTable *seek_table; /* pointer into encoder->protected_->metadata_ where the seek table is */ - uint32_t current_sample_number; - uint32_t current_frame_number; - FLAC__MD5Context md5context; - FLAC__CPUInfo cpuinfo; - void (*local_precompute_partition_info_sums)(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps); -#ifndef FLAC__INTEGER_ONLY_LIBRARY - uint32_t (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); - uint32_t (*local_fixed_compute_best_predictor_wide)(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); - uint32_t (*local_fixed_compute_best_predictor_limit_residual)(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -#else - uint32_t (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); - uint32_t (*local_fixed_compute_best_predictor_wide)(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); - uint32_t (*local_fixed_compute_best_predictor_limit_residual)(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -#endif -#ifndef FLAC__INTEGER_ONLY_LIBRARY - void (*local_lpc_compute_autocorrelation)(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[]); - void (*local_lpc_compute_residual_from_qlp_coefficients)(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); - void (*local_lpc_compute_residual_from_qlp_coefficients_64bit)(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); - void (*local_lpc_compute_residual_from_qlp_coefficients_16bit)(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); -#endif - FLAC__bool disable_mmx; - FLAC__bool disable_sse2; - FLAC__bool disable_ssse3; - FLAC__bool disable_sse41; - FLAC__bool disable_sse42; - FLAC__bool disable_avx2; - FLAC__bool disable_fma; - FLAC__bool disable_constant_subframes; - FLAC__bool disable_fixed_subframes; - FLAC__bool disable_verbatim_subframes; - FLAC__bool is_ogg; - FLAC__StreamEncoderReadCallback read_callback; /* currently only needed for Ogg FLAC */ - FLAC__StreamEncoderSeekCallback seek_callback; - FLAC__StreamEncoderTellCallback tell_callback; - FLAC__StreamEncoderWriteCallback write_callback; - FLAC__StreamEncoderMetadataCallback metadata_callback; - FLAC__StreamEncoderProgressCallback progress_callback; - void *client_data; - uint32_t first_seekpoint_to_check; - FILE *file; /* only used when encoding to a file */ - FLAC__uint64 bytes_written; - FLAC__uint64 samples_written; - uint32_t frames_written; - uint32_t total_frames_estimate; - /* unaligned (original) pointers to allocated data */ - FLAC__int32 *integer_signal_unaligned[FLAC__MAX_CHANNELS]; - FLAC__int32 *integer_signal_mid_side_unaligned[2]; - FLAC__int64 *integer_signal_33bit_side_unaligned; -#ifndef FLAC__INTEGER_ONLY_LIBRARY - FLAC__real *real_signal_unaligned[FLAC__MAX_CHANNELS]; /* (@@@ currently unused) */ - FLAC__real *real_signal_mid_side_unaligned[2]; /* (@@@ currently unused) */ - FLAC__real *window_unaligned[FLAC__MAX_APODIZATION_FUNCTIONS]; - FLAC__real *windowed_signal_unaligned; -#endif - FLAC__int32 *residual_workspace_unaligned[FLAC__MAX_CHANNELS][2]; - FLAC__int32 *residual_workspace_mid_side_unaligned[2][2]; - FLAC__uint64 *abs_residual_partition_sums_unaligned; - uint32_t *raw_bits_per_partition_unaligned; - /* - * These fields have been moved here from private function local - * declarations merely to save stack space during encoding. - */ -#ifndef FLAC__INTEGER_ONLY_LIBRARY - FLAC__real lp_coeff[FLAC__MAX_LPC_ORDER][FLAC__MAX_LPC_ORDER]; /* from process_subframe_() */ -#endif - FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents_extra[2]; /* from find_best_partition_order_() */ - /* - * The data for the verify section - */ - struct { - FLAC__StreamDecoder *decoder; - EncoderStateHint state_hint; - FLAC__bool needs_magic_hack; - verify_input_fifo input_fifo; - verify_output output; - struct { - FLAC__uint64 absolute_sample; - uint32_t frame_number; - uint32_t channel; - uint32_t sample; - FLAC__int32 expected; - FLAC__int32 got; - } error_stats; - } verify; - FLAC__bool is_being_deleted; /* if true, call to ..._finish() from ..._delete() will not call the callbacks */ -} FLAC__StreamEncoderPrivate; - -/*********************************************************************** - * - * Public static class data - * - ***********************************************************************/ - -FLAC_API const char * const FLAC__StreamEncoderStateString[] = { - "FLAC__STREAM_ENCODER_OK", - "FLAC__STREAM_ENCODER_UNINITIALIZED", - "FLAC__STREAM_ENCODER_OGG_ERROR", - "FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR", - "FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA", - "FLAC__STREAM_ENCODER_CLIENT_ERROR", - "FLAC__STREAM_ENCODER_IO_ERROR", - "FLAC__STREAM_ENCODER_FRAMING_ERROR", - "FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR" -}; - -FLAC_API const char * const FLAC__StreamEncoderInitStatusString[] = { - "FLAC__STREAM_ENCODER_INIT_STATUS_OK", - "FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR", - "FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER", - "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS", - "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS", - "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE", - "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE", - "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE", - "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER", - "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION", - "FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER", - "FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE", - "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA", - "FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED" -}; - -FLAC_API const char * const FLAC__StreamEncoderReadStatusString[] = { - "FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE", - "FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM", - "FLAC__STREAM_ENCODER_READ_STATUS_ABORT", - "FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED" -}; - -FLAC_API const char * const FLAC__StreamEncoderWriteStatusString[] = { - "FLAC__STREAM_ENCODER_WRITE_STATUS_OK", - "FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR" -}; - -FLAC_API const char * const FLAC__StreamEncoderSeekStatusString[] = { - "FLAC__STREAM_ENCODER_SEEK_STATUS_OK", - "FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR", - "FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED" -}; - -FLAC_API const char * const FLAC__StreamEncoderTellStatusString[] = { - "FLAC__STREAM_ENCODER_TELL_STATUS_OK", - "FLAC__STREAM_ENCODER_TELL_STATUS_ERROR", - "FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED" -}; - -/* Number of samples that will be overread to watch for end of stream. By - * 'overread', we mean that the FLAC__stream_encoder_process*() calls will - * always try to read blocksize+1 samples before encoding a block, so that - * even if the stream has a total sample count that is an integral multiple - * of the blocksize, we will still notice when we are encoding the last - * block. This is needed, for example, to correctly set the end-of-stream - * marker in Ogg FLAC. - * - * WATCHOUT: some parts of the code assert that OVERREAD_ == 1 and there's - * not really any reason to change it. - */ -static const uint32_t OVERREAD_ = 1; - -/*********************************************************************** - * - * Class constructor/destructor - * - */ -FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void) -{ - FLAC__StreamEncoder *encoder; - uint32_t i; - - FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */ - - encoder = calloc(1, sizeof(FLAC__StreamEncoder)); - if(encoder == 0) { - return 0; - } - - encoder->protected_ = calloc(1, sizeof(FLAC__StreamEncoderProtected)); - if(encoder->protected_ == 0) { - free(encoder); - return 0; - } - - encoder->private_ = calloc(1, sizeof(FLAC__StreamEncoderPrivate)); - if(encoder->private_ == 0) { - free(encoder->protected_); - free(encoder); - return 0; - } - - encoder->private_->frame = FLAC__bitwriter_new(); - if(encoder->private_->frame == 0) { - free(encoder->private_); - free(encoder->protected_); - free(encoder); - return 0; - } - - encoder->private_->file = 0; - - encoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED; - - set_defaults_(encoder); - - encoder->private_->is_being_deleted = false; - - for(i = 0; i < FLAC__MAX_CHANNELS; i++) { - encoder->private_->subframe_workspace_ptr[i][0] = &encoder->private_->subframe_workspace[i][0]; - encoder->private_->subframe_workspace_ptr[i][1] = &encoder->private_->subframe_workspace[i][1]; - } - for(i = 0; i < 2; i++) { - encoder->private_->subframe_workspace_ptr_mid_side[i][0] = &encoder->private_->subframe_workspace_mid_side[i][0]; - encoder->private_->subframe_workspace_ptr_mid_side[i][1] = &encoder->private_->subframe_workspace_mid_side[i][1]; - } - for(i = 0; i < FLAC__MAX_CHANNELS; i++) { - encoder->private_->partitioned_rice_contents_workspace_ptr[i][0] = &encoder->private_->partitioned_rice_contents_workspace[i][0]; - encoder->private_->partitioned_rice_contents_workspace_ptr[i][1] = &encoder->private_->partitioned_rice_contents_workspace[i][1]; - } - for(i = 0; i < 2; i++) { - encoder->private_->partitioned_rice_contents_workspace_ptr_mid_side[i][0] = &encoder->private_->partitioned_rice_contents_workspace_mid_side[i][0]; - encoder->private_->partitioned_rice_contents_workspace_ptr_mid_side[i][1] = &encoder->private_->partitioned_rice_contents_workspace_mid_side[i][1]; - } - - for(i = 0; i < FLAC__MAX_CHANNELS; i++) { - FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_workspace[i][0]); - FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_workspace[i][1]); - } - for(i = 0; i < 2; i++) { - FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_workspace_mid_side[i][0]); - FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_workspace_mid_side[i][1]); - } - for(i = 0; i < 2; i++) - FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_extra[i]); - - return encoder; -} - -FLAC_API void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder) -{ - uint32_t i; - - if (encoder == NULL) - return ; - - FLAC__ASSERT(0 != encoder->protected_); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->private_->frame); - - encoder->private_->is_being_deleted = true; - - (void)FLAC__stream_encoder_finish(encoder); - - if(0 != encoder->private_->verify.decoder) - FLAC__stream_decoder_delete(encoder->private_->verify.decoder); - - for(i = 0; i < FLAC__MAX_CHANNELS; i++) { - FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_workspace[i][0]); - FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_workspace[i][1]); - } - for(i = 0; i < 2; i++) { - FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_workspace_mid_side[i][0]); - FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_workspace_mid_side[i][1]); - } - for(i = 0; i < 2; i++) - FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_extra[i]); - - FLAC__bitwriter_delete(encoder->private_->frame); - free(encoder->private_); - free(encoder->protected_); - free(encoder); -} - -/*********************************************************************** - * - * Public class methods - * - ***********************************************************************/ - -static FLAC__StreamEncoderInitStatus init_stream_internal_( - FLAC__StreamEncoder *encoder, - FLAC__StreamEncoderReadCallback read_callback, - FLAC__StreamEncoderWriteCallback write_callback, - FLAC__StreamEncoderSeekCallback seek_callback, - FLAC__StreamEncoderTellCallback tell_callback, - FLAC__StreamEncoderMetadataCallback metadata_callback, - void *client_data, - FLAC__bool is_ogg -) -{ - uint32_t i; - FLAC__bool metadata_has_seektable, metadata_has_vorbis_comment, metadata_picture_has_type1, metadata_picture_has_type2; - - FLAC__ASSERT(0 != encoder); - - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED; - - if(FLAC__HAS_OGG == 0 && is_ogg) - return FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER; - - if(0 == write_callback || (seek_callback && 0 == tell_callback)) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS; - - if(encoder->protected_->channels == 0 || encoder->protected_->channels > FLAC__MAX_CHANNELS) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS; - - if(encoder->protected_->channels != 2) { - encoder->protected_->do_mid_side_stereo = false; - encoder->protected_->loose_mid_side_stereo = false; - } - else if(!encoder->protected_->do_mid_side_stereo) - encoder->protected_->loose_mid_side_stereo = false; - - if(encoder->protected_->bits_per_sample < FLAC__MIN_BITS_PER_SAMPLE || encoder->protected_->bits_per_sample > FLAC__MAX_BITS_PER_SAMPLE) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE; - - if(!FLAC__format_sample_rate_is_valid(encoder->protected_->sample_rate)) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE; - - if(encoder->protected_->blocksize == 0) { - if(encoder->protected_->max_lpc_order == 0) - encoder->protected_->blocksize = 1152; - else - encoder->protected_->blocksize = 4096; - } - - if(encoder->protected_->blocksize < FLAC__MIN_BLOCK_SIZE || encoder->protected_->blocksize > FLAC__MAX_BLOCK_SIZE) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE; - - if(encoder->protected_->max_lpc_order > FLAC__MAX_LPC_ORDER) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER; - - if(encoder->protected_->blocksize < encoder->protected_->max_lpc_order) - return FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER; - - if(encoder->protected_->qlp_coeff_precision == 0) { - if(encoder->protected_->bits_per_sample < 16) { - /* @@@ need some data about how to set this here w.r.t. blocksize and sample rate */ - /* @@@ until then we'll make a guess */ - encoder->protected_->qlp_coeff_precision = flac_max(FLAC__MIN_QLP_COEFF_PRECISION, 2 + encoder->protected_->bits_per_sample / 2); - } - else if(encoder->protected_->bits_per_sample == 16) { - if(encoder->protected_->blocksize <= 192) - encoder->protected_->qlp_coeff_precision = 7; - else if(encoder->protected_->blocksize <= 384) - encoder->protected_->qlp_coeff_precision = 8; - else if(encoder->protected_->blocksize <= 576) - encoder->protected_->qlp_coeff_precision = 9; - else if(encoder->protected_->blocksize <= 1152) - encoder->protected_->qlp_coeff_precision = 10; - else if(encoder->protected_->blocksize <= 2304) - encoder->protected_->qlp_coeff_precision = 11; - else if(encoder->protected_->blocksize <= 4608) - encoder->protected_->qlp_coeff_precision = 12; - else - encoder->protected_->qlp_coeff_precision = 13; - } - else { - if(encoder->protected_->blocksize <= 384) - encoder->protected_->qlp_coeff_precision = FLAC__MAX_QLP_COEFF_PRECISION-2; - else if(encoder->protected_->blocksize <= 1152) - encoder->protected_->qlp_coeff_precision = FLAC__MAX_QLP_COEFF_PRECISION-1; - else - encoder->protected_->qlp_coeff_precision = FLAC__MAX_QLP_COEFF_PRECISION; - } - FLAC__ASSERT(encoder->protected_->qlp_coeff_precision <= FLAC__MAX_QLP_COEFF_PRECISION); - } - else if(encoder->protected_->qlp_coeff_precision < FLAC__MIN_QLP_COEFF_PRECISION || encoder->protected_->qlp_coeff_precision > FLAC__MAX_QLP_COEFF_PRECISION) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION; - - if(encoder->protected_->streamable_subset) { - if(!FLAC__format_blocksize_is_subset(encoder->protected_->blocksize, encoder->protected_->sample_rate)) - return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE; - if(!FLAC__format_sample_rate_is_subset(encoder->protected_->sample_rate)) - return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE; - if( - encoder->protected_->bits_per_sample != 8 && - encoder->protected_->bits_per_sample != 12 && - encoder->protected_->bits_per_sample != 16 && - encoder->protected_->bits_per_sample != 20 && - encoder->protected_->bits_per_sample != 24 && - encoder->protected_->bits_per_sample != 32 - ) - return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE; - if(encoder->protected_->max_residual_partition_order > FLAC__SUBSET_MAX_RICE_PARTITION_ORDER) - return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE; - if( - encoder->protected_->sample_rate <= 48000 && - ( - encoder->protected_->blocksize > FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ || - encoder->protected_->max_lpc_order > FLAC__SUBSET_MAX_LPC_ORDER_48000HZ - ) - ) { - return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE; - } - } - - if(encoder->protected_->max_residual_partition_order >= (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN)) - encoder->protected_->max_residual_partition_order = (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN) - 1; - if(encoder->protected_->min_residual_partition_order >= encoder->protected_->max_residual_partition_order) - encoder->protected_->min_residual_partition_order = encoder->protected_->max_residual_partition_order; - -#if FLAC__HAS_OGG - /* drop any seektable for ogg */ - if(is_ogg && 0 != encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 0) { - uint32_t i1; - for(i1 = 0; i1 < encoder->protected_->num_metadata_blocks; i1++) { - if(0 != encoder->protected_->metadata[i1] && encoder->protected_->metadata[i1]->type == FLAC__METADATA_TYPE_SEEKTABLE) { - encoder->protected_->num_metadata_blocks--; - for( ; i1 < encoder->protected_->num_metadata_blocks; i1++) - encoder->protected_->metadata[i1] = encoder->protected_->metadata[i1+1]; - break; - } - } - } - /* reorder metadata if necessary to ensure that any VORBIS_COMMENT is the first, according to the mapping spec */ - if(is_ogg && 0 != encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 1) { - uint32_t i1; - for(i1 = 1; i1 < encoder->protected_->num_metadata_blocks; i1++) { - if(0 != encoder->protected_->metadata[i1] && encoder->protected_->metadata[i1]->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { - FLAC__StreamMetadata *vc = encoder->protected_->metadata[i1]; - for( ; i1 > 0; i1--) - encoder->protected_->metadata[i1] = encoder->protected_->metadata[i1-1]; - encoder->protected_->metadata[0] = vc; - break; - } - } - } -#endif - /* keep track of any SEEKTABLE block */ - if(0 != encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 0) { - uint32_t i2; - for(i2 = 0; i2 < encoder->protected_->num_metadata_blocks; i2++) { - if(0 != encoder->protected_->metadata[i2] && encoder->protected_->metadata[i2]->type == FLAC__METADATA_TYPE_SEEKTABLE) { - encoder->private_->seek_table = &encoder->protected_->metadata[i2]->data.seek_table; - break; /* take only the first one */ - } - } - } - - /* validate metadata */ - if(0 == encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 0) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - metadata_has_seektable = false; - metadata_has_vorbis_comment = false; - metadata_picture_has_type1 = false; - metadata_picture_has_type2 = false; - for(i = 0; i < encoder->protected_->num_metadata_blocks; i++) { - const FLAC__StreamMetadata *m = encoder->protected_->metadata[i]; - if(m->type == FLAC__METADATA_TYPE_STREAMINFO) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - else if(m->type == FLAC__METADATA_TYPE_SEEKTABLE) { - if(metadata_has_seektable) /* only one is allowed */ - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - metadata_has_seektable = true; - if(!FLAC__format_seektable_is_legal(&m->data.seek_table)) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - } - else if(m->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { - if(metadata_has_vorbis_comment) /* only one is allowed */ - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - metadata_has_vorbis_comment = true; - } - else if(m->type == FLAC__METADATA_TYPE_CUESHEET) { - if(!FLAC__format_cuesheet_is_legal(&m->data.cue_sheet, m->data.cue_sheet.is_cd, /*violation=*/0)) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - } - else if(m->type == FLAC__METADATA_TYPE_PICTURE) { - if(!FLAC__format_picture_is_legal(&m->data.picture, /*violation=*/0)) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - if(m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD) { - if(metadata_picture_has_type1) /* there should only be 1 per stream */ - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - metadata_picture_has_type1 = true; - /* standard icon must be 32x32 pixel PNG */ - if( - m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD && - ( - (strcmp(m->data.picture.mime_type, "image/png") && strcmp(m->data.picture.mime_type, "-->")) || - m->data.picture.width != 32 || - m->data.picture.height != 32 - ) - ) - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - } - else if(m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON) { - if(metadata_picture_has_type2) /* there should only be 1 per stream */ - return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA; - metadata_picture_has_type2 = true; - } - } - } - - encoder->private_->input_capacity = 0; - for(i = 0; i < encoder->protected_->channels; i++) { - encoder->private_->integer_signal_unaligned[i] = encoder->private_->integer_signal[i] = 0; -#ifndef FLAC__INTEGER_ONLY_LIBRARY - encoder->private_->real_signal_unaligned[i] = encoder->private_->real_signal[i] = 0; -#endif - } - for(i = 0; i < 2; i++) { - encoder->private_->integer_signal_mid_side_unaligned[i] = encoder->private_->integer_signal_mid_side[i] = 0; -#ifndef FLAC__INTEGER_ONLY_LIBRARY - encoder->private_->real_signal_mid_side_unaligned[i] = encoder->private_->real_signal_mid_side[i] = 0; -#endif - } - encoder->private_->integer_signal_33bit_side_unaligned = encoder->private_->integer_signal_33bit_side = 0; -#ifndef FLAC__INTEGER_ONLY_LIBRARY - for(i = 0; i < encoder->protected_->num_apodizations; i++) - encoder->private_->window_unaligned[i] = encoder->private_->window[i] = 0; - encoder->private_->windowed_signal_unaligned = encoder->private_->windowed_signal = 0; -#endif - for(i = 0; i < encoder->protected_->channels; i++) { - encoder->private_->residual_workspace_unaligned[i][0] = encoder->private_->residual_workspace[i][0] = 0; - encoder->private_->residual_workspace_unaligned[i][1] = encoder->private_->residual_workspace[i][1] = 0; - encoder->private_->best_subframe[i] = 0; - } - for(i = 0; i < 2; i++) { - encoder->private_->residual_workspace_mid_side_unaligned[i][0] = encoder->private_->residual_workspace_mid_side[i][0] = 0; - encoder->private_->residual_workspace_mid_side_unaligned[i][1] = encoder->private_->residual_workspace_mid_side[i][1] = 0; - encoder->private_->best_subframe_mid_side[i] = 0; - } - encoder->private_->abs_residual_partition_sums_unaligned = encoder->private_->abs_residual_partition_sums = 0; - encoder->private_->raw_bits_per_partition_unaligned = encoder->private_->raw_bits_per_partition = 0; -#ifndef FLAC__INTEGER_ONLY_LIBRARY - encoder->private_->loose_mid_side_stereo_frames = (uint32_t)((double)encoder->protected_->sample_rate * 0.4 / (double)encoder->protected_->blocksize + 0.5); -#else - /* 26214 is the approximate fixed-point equivalent to 0.4 (0.4 * 2^16) */ - /* sample rate can be up to 1048575 Hz, and thus use 20 bits, so we do the multiply÷ by hand */ - FLAC__ASSERT(FLAC__MAX_SAMPLE_RATE <= 1048575); - FLAC__ASSERT(FLAC__MAX_BLOCK_SIZE <= 65535); - FLAC__ASSERT(encoder->protected_->sample_rate <= 1048575); - FLAC__ASSERT(encoder->protected_->blocksize <= 65535); - encoder->private_->loose_mid_side_stereo_frames = (uint32_t)FLAC__fixedpoint_trunc((((FLAC__uint64)(encoder->protected_->sample_rate) * (FLAC__uint64)(26214)) << 16) / (encoder->protected_->blocksize<<16) + FLAC__FP_ONE_HALF); -#endif - if(encoder->private_->loose_mid_side_stereo_frames == 0) - encoder->private_->loose_mid_side_stereo_frames = 1; - encoder->private_->loose_mid_side_stereo_frame_count = 0; - encoder->private_->current_sample_number = 0; - encoder->private_->current_frame_number = 0; - - /* - * get the CPU info and set the function pointers - */ - FLAC__cpu_info(&encoder->private_->cpuinfo); - /* remove cpu info as requested by - * FLAC__stream_encoder_disable_instruction_set */ - if(encoder->private_->disable_mmx) - encoder->private_->cpuinfo.x86.mmx = false; - if(encoder->private_->disable_sse2) - encoder->private_->cpuinfo.x86.sse2 = false; - if(encoder->private_->disable_ssse3) - encoder->private_->cpuinfo.x86.ssse3 = false; - if(encoder->private_->disable_sse41) - encoder->private_->cpuinfo.x86.sse41 = false; - if(encoder->private_->disable_sse42) - encoder->private_->cpuinfo.x86.sse42 = false; - if(encoder->private_->disable_avx2) - encoder->private_->cpuinfo.x86.avx2 = false; - if(encoder->private_->disable_fma) - encoder->private_->cpuinfo.x86.fma = false; - /* first default to the non-asm routines */ -#ifndef FLAC__INTEGER_ONLY_LIBRARY - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation; -#endif - encoder->private_->local_precompute_partition_info_sums = precompute_partition_info_sums_; - encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor; - encoder->private_->local_fixed_compute_best_predictor_wide = FLAC__fixed_compute_best_predictor_wide; - encoder->private_->local_fixed_compute_best_predictor_limit_residual = FLAC__fixed_compute_best_predictor_limit_residual; -#ifndef FLAC__INTEGER_ONLY_LIBRARY - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit = FLAC__lpc_compute_residual_from_qlp_coefficients_wide; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients; -#endif - /* now override with asm where appropriate */ -#ifndef FLAC__INTEGER_ONLY_LIBRARY -# ifndef FLAC__NO_ASM -#if defined FLAC__CPU_ARM64 && FLAC__HAS_NEONINTRIN -#if FLAC__HAS_A64NEONINTRIN - if(encoder->protected_->max_lpc_order < 8) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_neon_lag_8; - else if(encoder->protected_->max_lpc_order < 10) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_neon_lag_10; - else if(encoder->protected_->max_lpc_order < 14) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_neon_lag_14; - else - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation; -#endif - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_neon; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_neon; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit = FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_neon; -#endif /* defined FLAC__CPU_ARM64 && FLAC__HAS_NEONINTRIN */ - - if(encoder->private_->cpuinfo.use_asm) { -# ifdef FLAC__CPU_IA32 - FLAC__ASSERT(encoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32); -# if FLAC__HAS_X86INTRIN -# ifdef FLAC__SSE2_SUPPORTED - if (encoder->private_->cpuinfo.x86.sse2) { - if(encoder->protected_->max_lpc_order < 8) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_8; - else if(encoder->protected_->max_lpc_order < 10) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_10; - else if(encoder->protected_->max_lpc_order < 14) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_14; - - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2; - } -# endif -# ifdef FLAC__SSE4_1_SUPPORTED - if (encoder->private_->cpuinfo.x86.sse41) { - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit = FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41; - } -# endif -# ifdef FLAC__AVX2_SUPPORTED - if (encoder->private_->cpuinfo.x86.avx2) { - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit = FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2; - } -# endif - -# ifdef FLAC__SSE2_SUPPORTED - if (encoder->private_->cpuinfo.x86.sse2) { - encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_intrin_sse2; - } -# endif -# ifdef FLAC__SSSE3_SUPPORTED - if (encoder->private_->cpuinfo.x86.ssse3) { - encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_intrin_ssse3; - } -# endif -# ifdef FLAC__SSE4_2_SUPPORTED - if (encoder->private_->cpuinfo.x86.sse42) { - encoder->private_->local_fixed_compute_best_predictor_limit_residual = FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42; - } -# endif -# ifdef FLAC__AVX2_SUPPORTED - if (encoder->private_->cpuinfo.x86.avx2) { - encoder->private_->local_fixed_compute_best_predictor_wide = FLAC__fixed_compute_best_predictor_wide_intrin_avx2; - encoder->private_->local_fixed_compute_best_predictor_limit_residual = FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2; - } -# endif -# endif /* FLAC__HAS_X86INTRIN */ -# elif defined FLAC__CPU_X86_64 - FLAC__ASSERT(encoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_X86_64); -# if FLAC__HAS_X86INTRIN -# ifdef FLAC__SSE2_SUPPORTED - if(encoder->private_->cpuinfo.x86.sse2) { /* For fuzzing */ - if(encoder->protected_->max_lpc_order < 8) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_8; - else if(encoder->protected_->max_lpc_order < 10) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_10; - else if(encoder->protected_->max_lpc_order < 14) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_sse2_lag_14; - - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2; - } -# endif -# ifdef FLAC__SSE4_1_SUPPORTED - if(encoder->private_->cpuinfo.x86.sse41) { - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41; - } -# endif -# ifdef FLAC__AVX2_SUPPORTED - if(encoder->private_->cpuinfo.x86.avx2) { - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2; - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit = FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2; - } -# endif -# ifdef FLAC__FMA_SUPPORTED - if(encoder->private_->cpuinfo.x86.fma) { - if(encoder->protected_->max_lpc_order < 8) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_fma_lag_8; - else if(encoder->protected_->max_lpc_order < 12) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_fma_lag_12; - else if(encoder->protected_->max_lpc_order < 16) - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_intrin_fma_lag_16; - } -# endif - - -# ifdef FLAC__SSE2_SUPPORTED - if(encoder->private_->cpuinfo.x86.sse2) { /* For fuzzing */ - encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_intrin_sse2; - } -# endif -# ifdef FLAC__SSSE3_SUPPORTED - if (encoder->private_->cpuinfo.x86.ssse3) { - encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_intrin_ssse3; - } -# endif -# ifdef FLAC__SSE4_2_SUPPORTED - if (encoder->private_->cpuinfo.x86.sse42) { - encoder->private_->local_fixed_compute_best_predictor_limit_residual = FLAC__fixed_compute_best_predictor_limit_residual_intrin_sse42; - } -# endif -# ifdef FLAC__AVX2_SUPPORTED - if (encoder->private_->cpuinfo.x86.avx2) { - encoder->private_->local_fixed_compute_best_predictor_wide = FLAC__fixed_compute_best_predictor_wide_intrin_avx2; - encoder->private_->local_fixed_compute_best_predictor_limit_residual = FLAC__fixed_compute_best_predictor_limit_residual_intrin_avx2; - } -# endif -# endif /* FLAC__HAS_X86INTRIN */ -# endif /* FLAC__CPU_... */ - } -# endif /* !FLAC__NO_ASM */ - -#endif /* !FLAC__INTEGER_ONLY_LIBRARY */ -#if !defined FLAC__NO_ASM && FLAC__HAS_X86INTRIN - if(encoder->private_->cpuinfo.use_asm) { -# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) -# ifdef FLAC__SSE2_SUPPORTED - if (encoder->private_->cpuinfo.x86.sse2) - encoder->private_->local_precompute_partition_info_sums = FLAC__precompute_partition_info_sums_intrin_sse2; -# endif -# ifdef FLAC__SSSE3_SUPPORTED - if (encoder->private_->cpuinfo.x86.ssse3) - encoder->private_->local_precompute_partition_info_sums = FLAC__precompute_partition_info_sums_intrin_ssse3; -# endif -# ifdef FLAC__AVX2_SUPPORTED - if (encoder->private_->cpuinfo.x86.avx2) - encoder->private_->local_precompute_partition_info_sums = FLAC__precompute_partition_info_sums_intrin_avx2; -# endif -# endif /* FLAC__CPU_... */ - } -#endif /* !FLAC__NO_ASM && FLAC__HAS_X86INTRIN */ - - /* set state to OK; from here on, errors are fatal and we'll override the state then */ - encoder->protected_->state = FLAC__STREAM_ENCODER_OK; - -#if FLAC__HAS_OGG - encoder->private_->is_ogg = is_ogg; - if(is_ogg && !FLAC__ogg_encoder_aspect_init(&encoder->protected_->ogg_encoder_aspect)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } -#endif - - encoder->private_->read_callback = read_callback; - encoder->private_->write_callback = write_callback; - encoder->private_->seek_callback = seek_callback; - encoder->private_->tell_callback = tell_callback; - encoder->private_->metadata_callback = metadata_callback; - encoder->private_->client_data = client_data; - - if(!resize_buffers_(encoder, encoder->protected_->blocksize)) { - /* the above function sets the state for us in case of an error */ - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - - if(!FLAC__bitwriter_init(encoder->private_->frame)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - - /* - * Set up the verify stuff if necessary - */ - if(encoder->protected_->verify) { - /* - * First, set up the fifo which will hold the - * original signal to compare against - */ - encoder->private_->verify.input_fifo.size = encoder->protected_->blocksize+OVERREAD_; - for(i = 0; i < encoder->protected_->channels; i++) { - if(0 == (encoder->private_->verify.input_fifo.data[i] = safe_malloc_mul_2op_p(sizeof(FLAC__int32), /*times*/encoder->private_->verify.input_fifo.size))) { - encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - } - encoder->private_->verify.input_fifo.tail = 0; - - /* - * Now set up a stream decoder for verification - */ - if(0 == encoder->private_->verify.decoder) { - encoder->private_->verify.decoder = FLAC__stream_decoder_new(); - if(0 == encoder->private_->verify.decoder) { - encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - } - - if(FLAC__stream_decoder_init_stream(encoder->private_->verify.decoder, verify_read_callback_, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, /*eof_callback=*/0, verify_write_callback_, verify_metadata_callback_, verify_error_callback_, /*client_data=*/encoder) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - } - encoder->private_->verify.error_stats.absolute_sample = 0; - encoder->private_->verify.error_stats.frame_number = 0; - encoder->private_->verify.error_stats.channel = 0; - encoder->private_->verify.error_stats.sample = 0; - encoder->private_->verify.error_stats.expected = 0; - encoder->private_->verify.error_stats.got = 0; - - /* - * These must be done before we write any metadata, because that - * calls the write_callback, which uses these values. - */ - encoder->private_->first_seekpoint_to_check = 0; - encoder->private_->samples_written = 0; - encoder->protected_->streaminfo_offset = 0; - encoder->protected_->seektable_offset = 0; - encoder->protected_->audio_offset = 0; - - /* - * write the stream header - */ - if(encoder->protected_->verify) - encoder->private_->verify.state_hint = ENCODER_IN_MAGIC; - if(!FLAC__bitwriter_write_raw_uint32(encoder->private_->frame, FLAC__STREAM_SYNC, FLAC__STREAM_SYNC_LEN)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - if(!write_bitbuffer_(encoder, 0, /*is_last_block=*/false)) { - /* the above function sets the state for us in case of an error */ - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - - /* - * write the STREAMINFO metadata block - */ - if(encoder->protected_->verify) - encoder->private_->verify.state_hint = ENCODER_IN_METADATA; - encoder->private_->streaminfo.type = FLAC__METADATA_TYPE_STREAMINFO; - encoder->private_->streaminfo.is_last = false; /* we will have at a minimum a VORBIS_COMMENT afterwards */ - encoder->private_->streaminfo.length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; - encoder->private_->streaminfo.data.stream_info.min_blocksize = encoder->protected_->blocksize; /* this encoder uses the same blocksize for the whole stream */ - encoder->private_->streaminfo.data.stream_info.max_blocksize = encoder->protected_->blocksize; - encoder->private_->streaminfo.data.stream_info.min_framesize = 0; /* we don't know this yet; have to fill it in later */ - encoder->private_->streaminfo.data.stream_info.max_framesize = 0; /* we don't know this yet; have to fill it in later */ - encoder->private_->streaminfo.data.stream_info.sample_rate = encoder->protected_->sample_rate; - encoder->private_->streaminfo.data.stream_info.channels = encoder->protected_->channels; - encoder->private_->streaminfo.data.stream_info.bits_per_sample = encoder->protected_->bits_per_sample; - encoder->private_->streaminfo.data.stream_info.total_samples = encoder->protected_->total_samples_estimate; /* we will replace this later with the real total */ - memset(encoder->private_->streaminfo.data.stream_info.md5sum, 0, 16); /* we don't know this yet; have to fill it in later */ - if(encoder->protected_->do_md5) - FLAC__MD5Init(&encoder->private_->md5context); - if(!FLAC__add_metadata_block(&encoder->private_->streaminfo, encoder->private_->frame, true)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - if(!write_bitbuffer_(encoder, 0, /*is_last_block=*/false)) { - /* the above function sets the state for us in case of an error */ - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - - /* - * Now that the STREAMINFO block is written, we can init this to an - * absurdly-high value... - */ - encoder->private_->streaminfo.data.stream_info.min_framesize = (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN) - 1; - /* ... and clear this to 0 */ - encoder->private_->streaminfo.data.stream_info.total_samples = 0; - - /* - * Check to see if the supplied metadata contains a VORBIS_COMMENT; - * if not, we will write an empty one (FLAC__add_metadata_block() - * automatically supplies the vendor string). - * - * WATCHOUT: the Ogg FLAC mapping requires us to write this block after - * the STREAMINFO. (In the case that metadata_has_vorbis_comment is - * true it will have already insured that the metadata list is properly - * ordered.) - */ - if(!metadata_has_vorbis_comment) { - FLAC__StreamMetadata vorbis_comment; - vorbis_comment.type = FLAC__METADATA_TYPE_VORBIS_COMMENT; - vorbis_comment.is_last = (encoder->protected_->num_metadata_blocks == 0); - vorbis_comment.length = 4 + 4; /* MAGIC NUMBER */ - vorbis_comment.data.vorbis_comment.vendor_string.length = 0; - vorbis_comment.data.vorbis_comment.vendor_string.entry = 0; - vorbis_comment.data.vorbis_comment.num_comments = 0; - vorbis_comment.data.vorbis_comment.comments = 0; - if(!FLAC__add_metadata_block(&vorbis_comment, encoder->private_->frame, true)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - if(!write_bitbuffer_(encoder, 0, /*is_last_block=*/false)) { - /* the above function sets the state for us in case of an error */ - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - } - - /* - * write the user's metadata blocks - */ - for(i = 0; i < encoder->protected_->num_metadata_blocks; i++) { - encoder->protected_->metadata[i]->is_last = (i == encoder->protected_->num_metadata_blocks - 1); - if(!FLAC__add_metadata_block(encoder->protected_->metadata[i], encoder->private_->frame, true)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - if(!write_bitbuffer_(encoder, 0, /*is_last_block=*/false)) { - /* the above function sets the state for us in case of an error */ - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - } - - /* now that all the metadata is written, we save the stream offset */ - if(encoder->private_->tell_callback && encoder->private_->tell_callback(encoder, &encoder->protected_->audio_offset, encoder->private_->client_data) == FLAC__STREAM_ENCODER_TELL_STATUS_ERROR) { /* FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED just means we didn't get the offset; no error */ - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - - if(encoder->protected_->verify) - encoder->private_->verify.state_hint = ENCODER_IN_AUDIO; - - return FLAC__STREAM_ENCODER_INIT_STATUS_OK; -} - -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream( - FLAC__StreamEncoder *encoder, - FLAC__StreamEncoderWriteCallback write_callback, - FLAC__StreamEncoderSeekCallback seek_callback, - FLAC__StreamEncoderTellCallback tell_callback, - FLAC__StreamEncoderMetadataCallback metadata_callback, - void *client_data -) -{ - return init_stream_internal_( - encoder, - /*read_callback=*/0, - write_callback, - seek_callback, - tell_callback, - metadata_callback, - client_data, - /*is_ogg=*/false - ); -} - -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream( - FLAC__StreamEncoder *encoder, - FLAC__StreamEncoderReadCallback read_callback, - FLAC__StreamEncoderWriteCallback write_callback, - FLAC__StreamEncoderSeekCallback seek_callback, - FLAC__StreamEncoderTellCallback tell_callback, - FLAC__StreamEncoderMetadataCallback metadata_callback, - void *client_data -) -{ - return init_stream_internal_( - encoder, - read_callback, - write_callback, - seek_callback, - tell_callback, - metadata_callback, - client_data, - /*is_ogg=*/true - ); -} - -static FLAC__StreamEncoderInitStatus init_FILE_internal_( - FLAC__StreamEncoder *encoder, - FILE *file, - FLAC__StreamEncoderProgressCallback progress_callback, - void *client_data, - FLAC__bool is_ogg -) -{ - FLAC__StreamEncoderInitStatus init_status; - - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != file); - - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED; - - /* double protection */ - if(file == 0) { - encoder->protected_->state = FLAC__STREAM_ENCODER_IO_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - - /* - * To make sure that our file does not go unclosed after an error, we - * must assign the FILE pointer before any further error can occur in - * this routine. - */ - if(file == stdout) - file = get_binary_stdout_(); /* just to be safe */ - -#ifdef _WIN32 - /* - * Windows can suffer quite badly from disk fragmentation. This can be - * reduced significantly by setting the output buffer size to be 10MB. - */ - if(GetFileType((HANDLE)_get_osfhandle(_fileno(file))) == FILE_TYPE_DISK) - setvbuf(file, NULL, _IOFBF, 10*1024*1024); -#endif - encoder->private_->file = file; - - encoder->private_->progress_callback = progress_callback; - encoder->private_->bytes_written = 0; - encoder->private_->samples_written = 0; - encoder->private_->frames_written = 0; - - init_status = init_stream_internal_( - encoder, - encoder->private_->file == stdout? 0 : is_ogg? file_read_callback_ : 0, - file_write_callback_, - encoder->private_->file == stdout? 0 : file_seek_callback_, - encoder->private_->file == stdout? 0 : file_tell_callback_, - /*metadata_callback=*/0, - client_data, - is_ogg - ); - if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { - /* the above function sets the state for us in case of an error */ - return init_status; - } - - { - uint32_t blocksize = FLAC__stream_encoder_get_blocksize(encoder); - - FLAC__ASSERT(blocksize != 0); - encoder->private_->total_frames_estimate = (uint32_t)((FLAC__stream_encoder_get_total_samples_estimate(encoder) + blocksize - 1) / blocksize); - } - - return init_status; -} - -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE( - FLAC__StreamEncoder *encoder, - FILE *file, - FLAC__StreamEncoderProgressCallback progress_callback, - void *client_data -) -{ - return init_FILE_internal_(encoder, file, progress_callback, client_data, /*is_ogg=*/false); -} - -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE( - FLAC__StreamEncoder *encoder, - FILE *file, - FLAC__StreamEncoderProgressCallback progress_callback, - void *client_data -) -{ - return init_FILE_internal_(encoder, file, progress_callback, client_data, /*is_ogg=*/true); -} - -static FLAC__StreamEncoderInitStatus init_file_internal_( - FLAC__StreamEncoder *encoder, - const char *filename, - FLAC__StreamEncoderProgressCallback progress_callback, - void *client_data, - FLAC__bool is_ogg -) -{ - FILE *file; - - FLAC__ASSERT(0 != encoder); - - /* - * To make sure that our file does not go unclosed after an error, we - * have to do the same entrance checks here that are later performed - * in FLAC__stream_encoder_init_FILE() before the FILE* is assigned. - */ - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED; - - file = filename? flac_fopen(filename, "w+b") : stdout; - - if(file == 0) { - encoder->protected_->state = FLAC__STREAM_ENCODER_IO_ERROR; - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - - return init_FILE_internal_(encoder, file, progress_callback, client_data, is_ogg); -} - -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_file( - FLAC__StreamEncoder *encoder, - const char *filename, - FLAC__StreamEncoderProgressCallback progress_callback, - void *client_data -) -{ - return init_file_internal_(encoder, filename, progress_callback, client_data, /*is_ogg=*/false); -} - -FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file( - FLAC__StreamEncoder *encoder, - const char *filename, - FLAC__StreamEncoderProgressCallback progress_callback, - void *client_data -) -{ - return init_file_internal_(encoder, filename, progress_callback, client_data, /*is_ogg=*/true); -} - -FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder) -{ - FLAC__bool error = false; - - if (encoder == NULL) - return false; - - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - - if(encoder->protected_->state == FLAC__STREAM_ENCODER_UNINITIALIZED){ - if(encoder->protected_->metadata){ // True in case FLAC__stream_encoder_set_metadata was used but init failed - free(encoder->protected_->metadata); - encoder->protected_->metadata = 0; - encoder->protected_->num_metadata_blocks = 0; - } - if(0 != encoder->private_->file) { - if(encoder->private_->file != stdout) - fclose(encoder->private_->file); - encoder->private_->file = 0; - } - return true; - } - - if(encoder->protected_->state == FLAC__STREAM_ENCODER_OK && !encoder->private_->is_being_deleted) { - if(encoder->private_->current_sample_number != 0) { - encoder->protected_->blocksize = encoder->private_->current_sample_number; - if(!resize_buffers_(encoder, encoder->protected_->blocksize)) { - /* the above function sets the state for us in case of an error */ - return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; - } - if(!process_frame_(encoder, /*is_last_block=*/true)) - error = true; - } - } - - if(encoder->protected_->do_md5) - FLAC__MD5Final(encoder->private_->streaminfo.data.stream_info.md5sum, &encoder->private_->md5context); - - if(!encoder->private_->is_being_deleted) { - if(encoder->protected_->state == FLAC__STREAM_ENCODER_OK) { - if(encoder->private_->seek_callback) { -#if FLAC__HAS_OGG - if(encoder->private_->is_ogg) - update_ogg_metadata_(encoder); - else -#endif - update_metadata_(encoder); - - /* check if an error occurred while updating metadata */ - if(encoder->protected_->state != FLAC__STREAM_ENCODER_OK) - error = true; - } - if(encoder->private_->metadata_callback) - encoder->private_->metadata_callback(encoder, &encoder->private_->streaminfo, encoder->private_->client_data); - } - - if(encoder->protected_->verify && 0 != encoder->private_->verify.decoder && !FLAC__stream_decoder_finish(encoder->private_->verify.decoder)) { - if(!error) - encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA; - error = true; - } - } - - if(0 != encoder->private_->file) { - if(encoder->private_->file != stdout) - fclose(encoder->private_->file); - encoder->private_->file = 0; - } - -#if FLAC__HAS_OGG - if(encoder->private_->is_ogg) - FLAC__ogg_encoder_aspect_finish(&encoder->protected_->ogg_encoder_aspect); -#endif - - free_(encoder); - set_defaults_(encoder); - - if(!error) - encoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED; - - return !error; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_ogg_serial_number(FLAC__StreamEncoder *encoder, long value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; -#if FLAC__HAS_OGG - /* can't check encoder->private_->is_ogg since that's not set until init time */ - FLAC__ogg_encoder_aspect_set_serial_number(&encoder->protected_->ogg_encoder_aspect, value); - return true; -#else - (void)value; - return false; -#endif -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; -#ifndef FLAC__MANDATORY_VERIFY_WHILE_ENCODING - encoder->protected_->verify = value; -#endif - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->streamable_subset = value; - return true; -} - -/* - * The following routine was intended as debug routine and is not in the - * public headers, but SHOULD NOT CHANGE! It is known is is used in - * some non-audio projects needing every last bit of performance. - * See https://github.com/xiph/flac/issues/547 for details. These projects - * provide their own prototype, so changing the signature of this function - * would break building. - */ -FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->do_md5 = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->channels = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->bits_per_sample = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->sample_rate = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__bool ok = true; - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - if(value >= sizeof(compression_levels_)/sizeof(compression_levels_[0])) - value = sizeof(compression_levels_)/sizeof(compression_levels_[0]) - 1; - ok &= FLAC__stream_encoder_set_do_mid_side_stereo (encoder, compression_levels_[value].do_mid_side_stereo); - ok &= FLAC__stream_encoder_set_loose_mid_side_stereo (encoder, compression_levels_[value].loose_mid_side_stereo); -#ifndef FLAC__INTEGER_ONLY_LIBRARY -#if 1 - ok &= FLAC__stream_encoder_set_apodization (encoder, compression_levels_[value].apodization); -#else - /* equivalent to -A tukey(0.5) */ - encoder->protected_->num_apodizations = 1; - encoder->protected_->apodizations[0].type = FLAC__APODIZATION_TUKEY; - encoder->protected_->apodizations[0].parameters.tukey.p = 0.5; -#endif -#endif - ok &= FLAC__stream_encoder_set_max_lpc_order (encoder, compression_levels_[value].max_lpc_order); - ok &= FLAC__stream_encoder_set_qlp_coeff_precision (encoder, compression_levels_[value].qlp_coeff_precision); - ok &= FLAC__stream_encoder_set_do_qlp_coeff_prec_search (encoder, compression_levels_[value].do_qlp_coeff_prec_search); - ok &= FLAC__stream_encoder_set_do_escape_coding (encoder, compression_levels_[value].do_escape_coding); - ok &= FLAC__stream_encoder_set_do_exhaustive_model_search (encoder, compression_levels_[value].do_exhaustive_model_search); - ok &= FLAC__stream_encoder_set_min_residual_partition_order(encoder, compression_levels_[value].min_residual_partition_order); - ok &= FLAC__stream_encoder_set_max_residual_partition_order(encoder, compression_levels_[value].max_residual_partition_order); - ok &= FLAC__stream_encoder_set_rice_parameter_search_dist (encoder, compression_levels_[value].rice_parameter_search_dist); - return ok; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->blocksize = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->do_mid_side_stereo = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->loose_mid_side_stereo = value; - return true; -} - -/*@@@@add to tests*/ -FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *encoder, const char *specification) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - FLAC__ASSERT(0 != specification); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; -#ifdef FLAC__INTEGER_ONLY_LIBRARY - (void)specification; /* silently ignore since we haven't integerized; will always use a rectangular window */ -#else - encoder->protected_->num_apodizations = 0; - while(1) { - const char *s = strchr(specification, ';'); - const size_t n = s? (size_t)(s - specification) : strlen(specification); - if (n==8 && 0 == strncmp("bartlett" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BARTLETT; - else if(n==13 && 0 == strncmp("bartlett_hann", specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BARTLETT_HANN; - else if(n==8 && 0 == strncmp("blackman" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BLACKMAN; - else if(n==26 && 0 == strncmp("blackman_harris_4term_92db", specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BLACKMAN_HARRIS_4TERM_92DB_SIDELOBE; - else if(n==6 && 0 == strncmp("connes" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_CONNES; - else if(n==7 && 0 == strncmp("flattop" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_FLATTOP; - else if(n>7 && 0 == strncmp("gauss(" , specification, 6)) { - FLAC__real stddev = (FLAC__real)strtod(specification+6, 0); - if (stddev > 0.0 && stddev <= 0.5) { - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.gauss.stddev = stddev; - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_GAUSS; - } - } - else if(n==7 && 0 == strncmp("hamming" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_HAMMING; - else if(n==4 && 0 == strncmp("hann" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_HANN; - else if(n==13 && 0 == strncmp("kaiser_bessel", specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_KAISER_BESSEL; - else if(n==7 && 0 == strncmp("nuttall" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_NUTTALL; - else if(n==9 && 0 == strncmp("rectangle" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_RECTANGLE; - else if(n==8 && 0 == strncmp("triangle" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TRIANGLE; - else if(n>7 && 0 == strncmp("tukey(" , specification, 6)) { - FLAC__real p = (FLAC__real)strtod(specification+6, 0); - if (p >= 0.0 && p <= 1.0) { - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.tukey.p = p; - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TUKEY; - } - } - else if(n>15 && 0 == strncmp("partial_tukey(", specification, 14)) { - FLAC__int32 tukey_parts = (FLAC__int32)strtod(specification+14, 0); - const char *si_1 = strchr(specification, '/'); - FLAC__real overlap = si_1?flac_min((FLAC__real)strtod(si_1+1, 0),0.99f):0.1f; - FLAC__real overlap_units = 1.0f/(1.0f - overlap) - 1.0f; - const char *si_2 = strchr((si_1?(si_1+1):specification), '/'); - FLAC__real tukey_p = si_2?(FLAC__real)strtod(si_2+1, 0):0.2f; - - if (tukey_parts <= 1) { - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.tukey.p = tukey_p; - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TUKEY; - }else if (encoder->protected_->num_apodizations + tukey_parts < 32){ - FLAC__int32 m; - for(m = 0; m < tukey_parts; m++){ - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.p = tukey_p; - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.start = m/(tukey_parts+overlap_units); - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.end = (m+1+overlap_units)/(tukey_parts+overlap_units); - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_PARTIAL_TUKEY; - } - } - } - else if(n>16 && 0 == strncmp("punchout_tukey(", specification, 15)) { - FLAC__int32 tukey_parts = (FLAC__int32)strtod(specification+15, 0); - const char *si_1 = strchr(specification, '/'); - FLAC__real overlap = si_1?flac_min((FLAC__real)strtod(si_1+1, 0),0.99f):0.2f; - FLAC__real overlap_units = 1.0f/(1.0f - overlap) - 1.0f; - const char *si_2 = strchr((si_1?(si_1+1):specification), '/'); - FLAC__real tukey_p = si_2?(FLAC__real)strtod(si_2+1, 0):0.2f; - - if (tukey_parts <= 1) { - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.tukey.p = tukey_p; - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TUKEY; - }else if (encoder->protected_->num_apodizations + tukey_parts < 32){ - FLAC__int32 m; - for(m = 0; m < tukey_parts; m++){ - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.p = tukey_p; - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.start = m/(tukey_parts+overlap_units); - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.end = (m+1+overlap_units)/(tukey_parts+overlap_units); - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_PUNCHOUT_TUKEY; - } - } - } - else if(n>17 && 0 == strncmp("subdivide_tukey(", specification, 16)){ - FLAC__int32 parts = (FLAC__int32)strtod(specification+16, 0); - if(parts > 1){ - const char *si_1 = strchr(specification, '/'); - FLAC__real p = si_1?(FLAC__real)strtod(si_1+1, 0):5e-1; - if(p > 1) - p = 1; - else if(p < 0) - p = 0; - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.subdivide_tukey.parts = parts; - encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.subdivide_tukey.p = p/parts; - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_SUBDIVIDE_TUKEY; - } - } - else if(n==5 && 0 == strncmp("welch" , specification, n)) - encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_WELCH; - if (encoder->protected_->num_apodizations == 32) - break; - if (s) - specification = s+1; - else - break; - } - if(encoder->protected_->num_apodizations == 0) { - encoder->protected_->num_apodizations = 1; - encoder->protected_->apodizations[0].type = FLAC__APODIZATION_TUKEY; - encoder->protected_->apodizations[0].parameters.tukey.p = 0.5; - } -#endif - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->max_lpc_order = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->qlp_coeff_precision = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->do_qlp_coeff_prec_search = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_do_escape_coding(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* was deprecated since FLAC 1.0.4 (24-Sep-2002), but is needed for - * full spec coverage, so this should be reenabled at some point. - * For now only enable while fuzzing */ - encoder->protected_->do_escape_coding = value; -#else - (void)value; -#endif - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->do_exhaustive_model_search = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->min_residual_partition_order = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->max_residual_partition_order = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, uint32_t value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; -#if 0 - /*@@@ deprecated: */ - encoder->protected_->rice_parameter_search_dist = value; -#else - (void)value; -#endif - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - value = flac_min(value, (FLAC__U64L(1) << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN) - 1); - encoder->protected_->total_samples_estimate = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, uint32_t num_blocks) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - if(0 == metadata) - num_blocks = 0; - if(0 == num_blocks) - metadata = 0; - /* realloc() does not do exactly what we want so... */ - if(encoder->protected_->metadata) { - free(encoder->protected_->metadata); - encoder->protected_->metadata = 0; - encoder->protected_->num_metadata_blocks = 0; - } - if(num_blocks) { - FLAC__StreamMetadata **m; - if(0 == (m = safe_malloc_mul_2op_p(sizeof(m[0]), /*times*/num_blocks))) - return false; - memcpy(m, metadata, sizeof(m[0]) * num_blocks); - encoder->protected_->metadata = m; - encoder->protected_->num_metadata_blocks = num_blocks; - } -#if FLAC__HAS_OGG - if(!FLAC__ogg_encoder_aspect_set_num_metadata(&encoder->protected_->ogg_encoder_aspect, num_blocks)) - return false; -#endif - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_set_limit_min_bitrate(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->protected_->limit_min_bitrate = value; - return true; -} - -/* - * These four functions are not static, but not publicly exposed in - * include/FLAC/ either. They are used by the test suite and in fuzzing - */ -FLAC_API FLAC__bool FLAC__stream_encoder_disable_instruction_set(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->private_->disable_mmx = value & 1; - encoder->private_->disable_sse2 = value & 2; - encoder->private_->disable_ssse3 = value & 4; - encoder->private_->disable_sse41 = value & 8; - encoder->private_->disable_avx2 = value & 16; - encoder->private_->disable_fma = value & 32; - encoder->private_->disable_sse42 = value & 64; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->private_->disable_constant_subframes = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->private_->disable_fixed_subframes = value; - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) - return false; - encoder->private_->disable_verbatim_subframes = value; - return true; -} - -FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->state; -} - -FLAC_API FLAC__StreamDecoderState FLAC__stream_encoder_get_verify_decoder_state(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->verify) - return FLAC__stream_decoder_get_state(encoder->private_->verify.decoder); - else - return FLAC__STREAM_DECODER_UNINITIALIZED; -} - -FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) - return FLAC__StreamEncoderStateString[encoder->protected_->state]; - else - return FLAC__stream_decoder_get_resolved_state_string(encoder->private_->verify.decoder); -} - -FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - if(0 != absolute_sample) - *absolute_sample = encoder->private_->verify.error_stats.absolute_sample; - if(0 != frame_number) - *frame_number = encoder->private_->verify.error_stats.frame_number; - if(0 != channel) - *channel = encoder->private_->verify.error_stats.channel; - if(0 != sample) - *sample = encoder->private_->verify.error_stats.sample; - if(0 != expected) - *expected = encoder->private_->verify.error_stats.expected; - if(0 != got) - *got = encoder->private_->verify.error_stats.got; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->verify; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->streamable_subset; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->do_md5; -} - -FLAC_API uint32_t FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->channels; -} - -FLAC_API uint32_t FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->bits_per_sample; -} - -FLAC_API uint32_t FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->sample_rate; -} - -FLAC_API uint32_t FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->blocksize; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->do_mid_side_stereo; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->loose_mid_side_stereo; -} - -FLAC_API uint32_t FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->max_lpc_order; -} - -FLAC_API uint32_t FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->qlp_coeff_precision; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->do_qlp_coeff_prec_search; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->do_escape_coding; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->do_exhaustive_model_search; -} - -FLAC_API uint32_t FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->min_residual_partition_order; -} - -FLAC_API uint32_t FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->max_residual_partition_order; -} - -FLAC_API uint32_t FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->rice_parameter_search_dist; -} - -FLAC_API FLAC__uint64 FLAC__stream_encoder_get_total_samples_estimate(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->total_samples_estimate; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_get_limit_min_bitrate(const FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - return encoder->protected_->limit_min_bitrate; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], uint32_t samples) -{ - uint32_t i, j = 0, k = 0, channel; - const uint32_t channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize; - const FLAC__int32 sample_max = INT32_MAX >> (32 - encoder->protected_->bits_per_sample); - const FLAC__int32 sample_min = INT32_MIN >> (32 - encoder->protected_->bits_per_sample); - - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - - if(encoder->protected_->state != FLAC__STREAM_ENCODER_OK) - return false; - - do { - const uint32_t n = flac_min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j); - - if(encoder->protected_->verify) - append_to_verify_fifo_(&encoder->private_->verify.input_fifo, buffer, j, channels, n); - - for(channel = 0; channel < channels; channel++) { - if (buffer[channel] == NULL) { - return false; - } - for(i = encoder->private_->current_sample_number, k = j; i <= blocksize && k < samples; i++, k++) { - if(buffer[channel][k] < sample_min || buffer[channel][k] > sample_max){ - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - } - } - memcpy(&encoder->private_->integer_signal[channel][encoder->private_->current_sample_number], &buffer[channel][j], sizeof(buffer[channel][0]) * n); - } - j += n; - encoder->private_->current_sample_number += n; - - /* we only process if we have a full block + 1 extra sample; final block is always handled by FLAC__stream_encoder_finish() */ - if(encoder->private_->current_sample_number > blocksize) { - FLAC__ASSERT(encoder->private_->current_sample_number == blocksize+OVERREAD_); - FLAC__ASSERT(OVERREAD_ == 1); /* assert we only overread 1 sample which simplifies the rest of the code below */ - if(!process_frame_(encoder, /*is_last_block=*/false)) - return false; - /* move unprocessed overread samples to beginnings of arrays */ - for(channel = 0; channel < channels; channel++) - encoder->private_->integer_signal[channel][0] = encoder->private_->integer_signal[channel][blocksize]; - encoder->private_->current_sample_number = 1; - } - } while(j < samples); - - return true; -} - -FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], uint32_t samples) -{ - uint32_t i, j, k, channel; - const uint32_t channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize; - const FLAC__int32 sample_max = INT32_MAX >> (32 - encoder->protected_->bits_per_sample); - const FLAC__int32 sample_min = INT32_MIN >> (32 - encoder->protected_->bits_per_sample); - - FLAC__ASSERT(0 != encoder); - FLAC__ASSERT(0 != encoder->private_); - FLAC__ASSERT(0 != encoder->protected_); - - if(encoder->protected_->state != FLAC__STREAM_ENCODER_OK) - return false; - - j = k = 0; - do { - if(encoder->protected_->verify) - append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, flac_min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); - - /* "i <= blocksize" to overread 1 sample; see comment in OVERREAD_ decl */ - for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) { - for(channel = 0; channel < channels; channel++){ - if(buffer[k] < sample_min || buffer[k] > sample_max){ - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - } - encoder->private_->integer_signal[channel][i] = buffer[k++]; - } - } - encoder->private_->current_sample_number = i; - /* we only process if we have a full block + 1 extra sample; final block is always handled by FLAC__stream_encoder_finish() */ - if(i > blocksize) { - if(!process_frame_(encoder, /*is_last_block=*/false)) - return false; - /* move unprocessed overread samples to beginnings of arrays */ - FLAC__ASSERT(i == blocksize+OVERREAD_); - FLAC__ASSERT(OVERREAD_ == 1); /* assert we only overread 1 sample which simplifies the rest of the code below */ - for(channel = 0; channel < channels; channel++) - encoder->private_->integer_signal[channel][0] = encoder->private_->integer_signal[channel][blocksize]; - encoder->private_->current_sample_number = 1; - } - } while(j < samples); - - return true; -} - -/*********************************************************************** - * - * Private class methods - * - ***********************************************************************/ - -void set_defaults_(FLAC__StreamEncoder *encoder) -{ - FLAC__ASSERT(0 != encoder); - -#ifdef FLAC__MANDATORY_VERIFY_WHILE_ENCODING - encoder->protected_->verify = true; -#else - encoder->protected_->verify = false; -#endif - encoder->protected_->streamable_subset = true; - encoder->protected_->do_md5 = true; - encoder->protected_->do_mid_side_stereo = false; - encoder->protected_->loose_mid_side_stereo = false; - encoder->protected_->channels = 2; - encoder->protected_->bits_per_sample = 16; - encoder->protected_->sample_rate = 44100; - encoder->protected_->blocksize = 0; -#ifndef FLAC__INTEGER_ONLY_LIBRARY - encoder->protected_->num_apodizations = 1; - encoder->protected_->apodizations[0].type = FLAC__APODIZATION_TUKEY; - encoder->protected_->apodizations[0].parameters.tukey.p = 0.5; -#endif - encoder->protected_->max_lpc_order = 0; - encoder->protected_->qlp_coeff_precision = 0; - encoder->protected_->do_qlp_coeff_prec_search = false; - encoder->protected_->do_exhaustive_model_search = false; - encoder->protected_->do_escape_coding = false; - encoder->protected_->min_residual_partition_order = 0; - encoder->protected_->max_residual_partition_order = 0; - encoder->protected_->rice_parameter_search_dist = 0; - encoder->protected_->total_samples_estimate = 0; - encoder->protected_->limit_min_bitrate = false; - encoder->protected_->metadata = 0; - encoder->protected_->num_metadata_blocks = 0; - - encoder->private_->seek_table = 0; - encoder->private_->disable_mmx = false; - encoder->private_->disable_sse2 = false; - encoder->private_->disable_ssse3 = false; - encoder->private_->disable_sse41 = false; - encoder->private_->disable_sse42 = false; - encoder->private_->disable_avx2 = false; - encoder->private_->disable_constant_subframes = false; - encoder->private_->disable_fixed_subframes = false; - encoder->private_->disable_verbatim_subframes = false; - encoder->private_->is_ogg = false; - encoder->private_->read_callback = 0; - encoder->private_->write_callback = 0; - encoder->private_->seek_callback = 0; - encoder->private_->tell_callback = 0; - encoder->private_->metadata_callback = 0; - encoder->private_->progress_callback = 0; - encoder->private_->client_data = 0; - -#if FLAC__HAS_OGG - FLAC__ogg_encoder_aspect_set_defaults(&encoder->protected_->ogg_encoder_aspect); -#endif - - FLAC__stream_encoder_set_compression_level(encoder, 5); -} - -void free_(FLAC__StreamEncoder *encoder) -{ - uint32_t i, channel; - - FLAC__ASSERT(0 != encoder); - if(encoder->protected_->metadata) { - free(encoder->protected_->metadata); - encoder->protected_->metadata = 0; - encoder->protected_->num_metadata_blocks = 0; - } - for(i = 0; i < encoder->protected_->channels; i++) { - if(0 != encoder->private_->integer_signal_unaligned[i]) { - free(encoder->private_->integer_signal_unaligned[i]); - encoder->private_->integer_signal_unaligned[i] = 0; - } -#ifndef FLAC__INTEGER_ONLY_LIBRARY - if(0 != encoder->private_->real_signal_unaligned[i]) { - free(encoder->private_->real_signal_unaligned[i]); - encoder->private_->real_signal_unaligned[i] = 0; - } -#endif - } - for(i = 0; i < 2; i++) { - if(0 != encoder->private_->integer_signal_mid_side_unaligned[i]) { - free(encoder->private_->integer_signal_mid_side_unaligned[i]); - encoder->private_->integer_signal_mid_side_unaligned[i] = 0; - } -#ifndef FLAC__INTEGER_ONLY_LIBRARY - if(0 != encoder->private_->real_signal_mid_side_unaligned[i]) { - free(encoder->private_->real_signal_mid_side_unaligned[i]); - encoder->private_->real_signal_mid_side_unaligned[i] = 0; - } -#endif - } - if(0 != encoder->private_->integer_signal_33bit_side_unaligned){ - free(encoder->private_->integer_signal_33bit_side_unaligned); - encoder->private_->integer_signal_33bit_side_unaligned = 0; - } -#ifndef FLAC__INTEGER_ONLY_LIBRARY - for(i = 0; i < encoder->protected_->num_apodizations; i++) { - if(0 != encoder->private_->window_unaligned[i]) { - free(encoder->private_->window_unaligned[i]); - encoder->private_->window_unaligned[i] = 0; - } - } - if(0 != encoder->private_->windowed_signal_unaligned) { - free(encoder->private_->windowed_signal_unaligned); - encoder->private_->windowed_signal_unaligned = 0; - } -#endif - for(channel = 0; channel < encoder->protected_->channels; channel++) { - for(i = 0; i < 2; i++) { - if(0 != encoder->private_->residual_workspace_unaligned[channel][i]) { - free(encoder->private_->residual_workspace_unaligned[channel][i]); - encoder->private_->residual_workspace_unaligned[channel][i] = 0; - } - } - } - for(channel = 0; channel < 2; channel++) { - for(i = 0; i < 2; i++) { - if(0 != encoder->private_->residual_workspace_mid_side_unaligned[channel][i]) { - free(encoder->private_->residual_workspace_mid_side_unaligned[channel][i]); - encoder->private_->residual_workspace_mid_side_unaligned[channel][i] = 0; - } - } - } - if(0 != encoder->private_->abs_residual_partition_sums_unaligned) { - free(encoder->private_->abs_residual_partition_sums_unaligned); - encoder->private_->abs_residual_partition_sums_unaligned = 0; - } - if(0 != encoder->private_->raw_bits_per_partition_unaligned) { - free(encoder->private_->raw_bits_per_partition_unaligned); - encoder->private_->raw_bits_per_partition_unaligned = 0; - } - if(encoder->protected_->verify) { - for(i = 0; i < encoder->protected_->channels; i++) { - if(0 != encoder->private_->verify.input_fifo.data[i]) { - free(encoder->private_->verify.input_fifo.data[i]); - encoder->private_->verify.input_fifo.data[i] = 0; - } - } - } - FLAC__bitwriter_free(encoder->private_->frame); -} - -FLAC__bool resize_buffers_(FLAC__StreamEncoder *encoder, uint32_t new_blocksize) -{ - FLAC__bool ok; - uint32_t i, channel; - - FLAC__ASSERT(new_blocksize > 0); - FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK); - - ok = true; - - /* To avoid excessive malloc'ing, we only grow the buffer; no shrinking. */ - if(new_blocksize > encoder->private_->input_capacity) { - - /* WATCHOUT: FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx() and ..._intrin_sse2() - * require that the input arrays (in our case the integer signals) - * have a buffer of up to 3 zeroes in front (at negative indices) for - * alignment purposes; we use 4 in front to keep the data well-aligned. - */ - - for(i = 0; ok && i < encoder->protected_->channels; i++) { - ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_unaligned[i], &encoder->private_->integer_signal[i]); - if(ok) { - memset(encoder->private_->integer_signal[i], 0, sizeof(FLAC__int32)*4); - encoder->private_->integer_signal[i] += 4; - } - } - for(i = 0; ok && i < 2; i++) { - ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_mid_side_unaligned[i], &encoder->private_->integer_signal_mid_side[i]); - if(ok) { - memset(encoder->private_->integer_signal_mid_side[i], 0, sizeof(FLAC__int32)*4); - encoder->private_->integer_signal_mid_side[i] += 4; - } - } - ok = ok && FLAC__memory_alloc_aligned_int64_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_33bit_side_unaligned, &encoder->private_->integer_signal_33bit_side); -#ifndef FLAC__INTEGER_ONLY_LIBRARY - if(ok && encoder->protected_->max_lpc_order > 0) { - for(i = 0; ok && i < encoder->protected_->num_apodizations; i++) - ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize, &encoder->private_->window_unaligned[i], &encoder->private_->window[i]); - ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize, &encoder->private_->windowed_signal_unaligned, &encoder->private_->windowed_signal); - } -#endif - for(channel = 0; ok && channel < encoder->protected_->channels; channel++) { - for(i = 0; ok && i < 2; i++) { - ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize, &encoder->private_->residual_workspace_unaligned[channel][i], &encoder->private_->residual_workspace[channel][i]); - } - } - - - for(channel = 0; ok && channel < encoder->protected_->channels; channel++) { - for(i = 0; ok && i < 2; i++) { - ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_workspace[channel][i], encoder->protected_->max_residual_partition_order); - ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_workspace[channel][i], encoder->protected_->max_residual_partition_order); - } - } - - for(channel = 0; ok && channel < 2; channel++) { - for(i = 0; ok && i < 2; i++) { - ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize, &encoder->private_->residual_workspace_mid_side_unaligned[channel][i], &encoder->private_->residual_workspace_mid_side[channel][i]); - } - } - - for(channel = 0; ok && channel < 2; channel++) { - for(i = 0; ok && i < 2; i++) { - ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_workspace_mid_side[channel][i], encoder->protected_->max_residual_partition_order); - } - } - - for(i = 0; ok && i < 2; i++) { - ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_extra[i], encoder->protected_->max_residual_partition_order); - } - - - /* the *2 is an approximation to the series 1 + 1/2 + 1/4 + ... that sums tree occupies in a flat array */ - /*@@@ new_blocksize*2 is too pessimistic, but to fix, we need smarter logic because a smaller new_blocksize can actually increase the # of partitions; would require moving this out into a separate function, then checking its capacity against the need of the current blocksize&min/max_partition_order (and maybe predictor order) */ - ok = ok && FLAC__memory_alloc_aligned_uint64_array(new_blocksize * 2, &encoder->private_->abs_residual_partition_sums_unaligned, &encoder->private_->abs_residual_partition_sums); - if(encoder->protected_->do_escape_coding) - ok = ok && FLAC__memory_alloc_aligned_uint32_array(new_blocksize * 2, &encoder->private_->raw_bits_per_partition_unaligned, &encoder->private_->raw_bits_per_partition); -} - if(ok) - encoder->private_->input_capacity = new_blocksize; - else { - encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; - return ok; - } - - - /* now adjust the windows if the blocksize has changed */ -#ifndef FLAC__INTEGER_ONLY_LIBRARY - if(encoder->protected_->max_lpc_order > 0 && new_blocksize > 1) { - for(i = 0; i < encoder->protected_->num_apodizations; i++) { - switch(encoder->protected_->apodizations[i].type) { - case FLAC__APODIZATION_BARTLETT: - FLAC__window_bartlett(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_BARTLETT_HANN: - FLAC__window_bartlett_hann(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_BLACKMAN: - FLAC__window_blackman(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_BLACKMAN_HARRIS_4TERM_92DB_SIDELOBE: - FLAC__window_blackman_harris_4term_92db_sidelobe(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_CONNES: - FLAC__window_connes(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_FLATTOP: - FLAC__window_flattop(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_GAUSS: - FLAC__window_gauss(encoder->private_->window[i], new_blocksize, encoder->protected_->apodizations[i].parameters.gauss.stddev); - break; - case FLAC__APODIZATION_HAMMING: - FLAC__window_hamming(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_HANN: - FLAC__window_hann(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_KAISER_BESSEL: - FLAC__window_kaiser_bessel(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_NUTTALL: - FLAC__window_nuttall(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_RECTANGLE: - FLAC__window_rectangle(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_TRIANGLE: - FLAC__window_triangle(encoder->private_->window[i], new_blocksize); - break; - case FLAC__APODIZATION_TUKEY: - FLAC__window_tukey(encoder->private_->window[i], new_blocksize, encoder->protected_->apodizations[i].parameters.tukey.p); - break; - case FLAC__APODIZATION_PARTIAL_TUKEY: - FLAC__window_partial_tukey(encoder->private_->window[i], new_blocksize, encoder->protected_->apodizations[i].parameters.multiple_tukey.p, encoder->protected_->apodizations[i].parameters.multiple_tukey.start, encoder->protected_->apodizations[i].parameters.multiple_tukey.end); - break; - case FLAC__APODIZATION_PUNCHOUT_TUKEY: - FLAC__window_punchout_tukey(encoder->private_->window[i], new_blocksize, encoder->protected_->apodizations[i].parameters.multiple_tukey.p, encoder->protected_->apodizations[i].parameters.multiple_tukey.start, encoder->protected_->apodizations[i].parameters.multiple_tukey.end); - break; - case FLAC__APODIZATION_SUBDIVIDE_TUKEY: - FLAC__window_tukey(encoder->private_->window[i], new_blocksize, encoder->protected_->apodizations[i].parameters.tukey.p); - break; - case FLAC__APODIZATION_WELCH: - FLAC__window_welch(encoder->private_->window[i], new_blocksize); - break; - default: - FLAC__ASSERT(0); - /* double protection */ - FLAC__window_hann(encoder->private_->window[i], new_blocksize); - break; - } - } - } - if (new_blocksize <= FLAC__MAX_LPC_ORDER) { - /* intrinsics autocorrelation routines do not all handle cases in which lag might be - * larger than data_len. Lag is one larger than the LPC order */ - encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation; - } -#endif - - return true; -} - -FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, uint32_t samples, FLAC__bool is_last_block) -{ - const FLAC__byte *buffer; - size_t bytes; - - FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(encoder->private_->frame)); - - if(!FLAC__bitwriter_get_buffer(encoder->private_->frame, &buffer, &bytes)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; - return false; - } - - if(encoder->protected_->verify) { - encoder->private_->verify.output.data = buffer; - encoder->private_->verify.output.bytes = bytes; - if(encoder->private_->verify.state_hint == ENCODER_IN_MAGIC) { - encoder->private_->verify.needs_magic_hack = true; - } - else { - if(!FLAC__stream_decoder_process_single(encoder->private_->verify.decoder) - || (!is_last_block - && (FLAC__stream_encoder_get_verify_decoder_state(encoder) == FLAC__STREAM_DECODER_END_OF_STREAM)) - || encoder->protected_->state == FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR /* Happens when error callback was used */) { - FLAC__bitwriter_release_buffer(encoder->private_->frame); - FLAC__bitwriter_clear(encoder->private_->frame); - if(encoder->protected_->state != FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA) - encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR; - return false; - } - } - } - - if(write_frame_(encoder, buffer, bytes, samples, is_last_block) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { - FLAC__bitwriter_release_buffer(encoder->private_->frame); - FLAC__bitwriter_clear(encoder->private_->frame); - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return false; - } - - FLAC__bitwriter_release_buffer(encoder->private_->frame); - FLAC__bitwriter_clear(encoder->private_->frame); - - if(samples > 0) { - encoder->private_->streaminfo.data.stream_info.min_framesize = flac_min(bytes, encoder->private_->streaminfo.data.stream_info.min_framesize); - encoder->private_->streaminfo.data.stream_info.max_framesize = flac_max(bytes, encoder->private_->streaminfo.data.stream_info.max_framesize); - } - - return true; -} - -FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, FLAC__bool is_last_block) -{ - FLAC__StreamEncoderWriteStatus status; - FLAC__uint64 output_position = 0; - -#if FLAC__HAS_OGG == 0 - (void)is_last_block; -#endif - - /* FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED just means we didn't get the offset; no error */ - if(encoder->private_->tell_callback && encoder->private_->tell_callback(encoder, &output_position, encoder->private_->client_data) == FLAC__STREAM_ENCODER_TELL_STATUS_ERROR) { - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - } - - /* - * Watch for the STREAMINFO block and first SEEKTABLE block to go by and store their offsets. - */ - if(samples == 0) { - FLAC__MetadataType type = (buffer[0] & 0x7f); - if(type == FLAC__METADATA_TYPE_STREAMINFO) - encoder->protected_->streaminfo_offset = output_position; - else if(type == FLAC__METADATA_TYPE_SEEKTABLE && encoder->protected_->seektable_offset == 0) - encoder->protected_->seektable_offset = output_position; - } - - /* - * Mark the current seek point if hit (if audio_offset == 0 that - * means we're still writing metadata and haven't hit the first - * frame yet) - */ - if(0 != encoder->private_->seek_table && encoder->protected_->audio_offset > 0 && encoder->private_->seek_table->num_points > 0) { - const uint32_t blocksize = FLAC__stream_encoder_get_blocksize(encoder); - const FLAC__uint64 frame_first_sample = encoder->private_->samples_written; - const FLAC__uint64 frame_last_sample = frame_first_sample + (FLAC__uint64)blocksize - 1; - FLAC__uint64 test_sample; - uint32_t i; - for(i = encoder->private_->first_seekpoint_to_check; i < encoder->private_->seek_table->num_points; i++) { - test_sample = encoder->private_->seek_table->points[i].sample_number; - if(test_sample > frame_last_sample) { - break; - } - else if(test_sample >= frame_first_sample) { - encoder->private_->seek_table->points[i].sample_number = frame_first_sample; - encoder->private_->seek_table->points[i].stream_offset = output_position - encoder->protected_->audio_offset; - encoder->private_->seek_table->points[i].frame_samples = blocksize; - encoder->private_->first_seekpoint_to_check++; - /* DO NOT: "break;" and here's why: - * The seektable template may contain more than one target - * sample for any given frame; we will keep looping, generating - * duplicate seekpoints for them, and we'll clean it up later, - * just before writing the seektable back to the metadata. - */ - } - else { - encoder->private_->first_seekpoint_to_check++; - } - } - } - -#if FLAC__HAS_OGG - if(encoder->private_->is_ogg) { - status = FLAC__ogg_encoder_aspect_write_callback_wrapper( - &encoder->protected_->ogg_encoder_aspect, - buffer, - bytes, - samples, - encoder->private_->current_frame_number, - is_last_block, - (FLAC__OggEncoderAspectWriteCallbackProxy)encoder->private_->write_callback, - encoder, - encoder->private_->client_data - ); - } - else -#endif - status = encoder->private_->write_callback(encoder, buffer, bytes, samples, encoder->private_->current_frame_number, encoder->private_->client_data); - - if(status == FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { - encoder->private_->bytes_written += bytes; - encoder->private_->samples_written += samples; - /* we keep a high watermark on the number of frames written because - * when the encoder goes back to write metadata, 'current_frame' - * will drop back to 0. - */ - encoder->private_->frames_written = flac_max(encoder->private_->frames_written, encoder->private_->current_frame_number+1); - } - else - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - - return status; -} - -/* Gets called when the encoding process has finished so that we can update the STREAMINFO and SEEKTABLE blocks. */ -void update_metadata_(const FLAC__StreamEncoder *encoder) -{ - FLAC__byte b[flac_max(6u, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)]; - const FLAC__StreamMetadata *metadata = &encoder->private_->streaminfo; - FLAC__uint64 samples = metadata->data.stream_info.total_samples; - const uint32_t min_framesize = metadata->data.stream_info.min_framesize; - const uint32_t max_framesize = metadata->data.stream_info.max_framesize; - const uint32_t bps = metadata->data.stream_info.bits_per_sample; - FLAC__StreamEncoderSeekStatus seek_status; - - FLAC__ASSERT(metadata->type == FLAC__METADATA_TYPE_STREAMINFO); - - /* All this is based on intimate knowledge of the stream header - * layout, but a change to the header format that would break this - * would also break all streams encoded in the previous format. - */ - - /* - * Write MD5 signature - */ - { - const uint32_t md5_offset = - FLAC__STREAM_METADATA_HEADER_LENGTH + - ( - FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN + - FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN - ) / 8; - - if((seek_status = encoder->private_->seek_callback(encoder, encoder->protected_->streaminfo_offset + md5_offset, encoder->private_->client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) { - if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR) - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return; - } - if(encoder->private_->write_callback(encoder, metadata->data.stream_info.md5sum, 16, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return; - } - } - - /* - * Write total samples - */ - { - const uint32_t total_samples_byte_offset = - FLAC__STREAM_METADATA_HEADER_LENGTH + - ( - FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN + - FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN - - 4 - ) / 8; - if(samples > (FLAC__U64L(1) << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)) - samples = 0; - - b[0] = ((FLAC__byte)(bps-1) << 4) | (FLAC__byte)((samples >> 32) & 0x0F); - b[1] = (FLAC__byte)((samples >> 24) & 0xFF); - b[2] = (FLAC__byte)((samples >> 16) & 0xFF); - b[3] = (FLAC__byte)((samples >> 8) & 0xFF); - b[4] = (FLAC__byte)(samples & 0xFF); - if((seek_status = encoder->private_->seek_callback(encoder, encoder->protected_->streaminfo_offset + total_samples_byte_offset, encoder->private_->client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) { - if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR) - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return; - } - if(encoder->private_->write_callback(encoder, b, 5, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return; - } - } - - /* - * Write min/max framesize - */ - { - const uint32_t min_framesize_offset = - FLAC__STREAM_METADATA_HEADER_LENGTH + - ( - FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN - ) / 8; - - b[0] = (FLAC__byte)((min_framesize >> 16) & 0xFF); - b[1] = (FLAC__byte)((min_framesize >> 8) & 0xFF); - b[2] = (FLAC__byte)(min_framesize & 0xFF); - b[3] = (FLAC__byte)((max_framesize >> 16) & 0xFF); - b[4] = (FLAC__byte)((max_framesize >> 8) & 0xFF); - b[5] = (FLAC__byte)(max_framesize & 0xFF); - if((seek_status = encoder->private_->seek_callback(encoder, encoder->protected_->streaminfo_offset + min_framesize_offset, encoder->private_->client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) { - if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR) - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return; - } - if(encoder->private_->write_callback(encoder, b, 6, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return; - } - } - - /* - * Write seektable - */ - if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) { - uint32_t i; - - FLAC__format_seektable_sort(encoder->private_->seek_table); - - FLAC__ASSERT(FLAC__format_seektable_is_legal(encoder->private_->seek_table)); - - if((seek_status = encoder->private_->seek_callback(encoder, encoder->protected_->seektable_offset + FLAC__STREAM_METADATA_HEADER_LENGTH, encoder->private_->client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) { - if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR) - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return; - } - - for(i = 0; i < encoder->private_->seek_table->num_points; i++) { - FLAC__uint64 xx; - uint32_t x; - xx = encoder->private_->seek_table->points[i].sample_number; - b[7] = (FLAC__byte)xx; xx >>= 8; - b[6] = (FLAC__byte)xx; xx >>= 8; - b[5] = (FLAC__byte)xx; xx >>= 8; - b[4] = (FLAC__byte)xx; xx >>= 8; - b[3] = (FLAC__byte)xx; xx >>= 8; - b[2] = (FLAC__byte)xx; xx >>= 8; - b[1] = (FLAC__byte)xx; xx >>= 8; - b[0] = (FLAC__byte)xx; xx >>= 8; - xx = encoder->private_->seek_table->points[i].stream_offset; - b[15] = (FLAC__byte)xx; xx >>= 8; - b[14] = (FLAC__byte)xx; xx >>= 8; - b[13] = (FLAC__byte)xx; xx >>= 8; - b[12] = (FLAC__byte)xx; xx >>= 8; - b[11] = (FLAC__byte)xx; xx >>= 8; - b[10] = (FLAC__byte)xx; xx >>= 8; - b[9] = (FLAC__byte)xx; xx >>= 8; - b[8] = (FLAC__byte)xx; xx >>= 8; - x = encoder->private_->seek_table->points[i].frame_samples; - b[17] = (FLAC__byte)x; x >>= 8; - b[16] = (FLAC__byte)x; x >>= 8; - if(encoder->private_->write_callback(encoder, b, 18, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) { - encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; - return; - } - } - } -} - -#if FLAC__HAS_OGG -/* Gets called when the encoding process has finished so that we can update the STREAMINFO and SEEKTABLE blocks. */ -void update_ogg_metadata_(FLAC__StreamEncoder *encoder) -{ - /* the # of bytes in the 1st packet that precede the STREAMINFO */ - static const uint32_t FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH = - FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH + - FLAC__OGG_MAPPING_MAGIC_LENGTH + - FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH + - FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH + - FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH + - FLAC__STREAM_SYNC_LENGTH - ; - FLAC__byte b[flac_max(6u, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)]; - const FLAC__StreamMetadata *metadata = &encoder->private_->streaminfo; - const FLAC__uint64 samples = metadata->data.stream_info.total_samples; - const uint32_t min_framesize = metadata->data.stream_info.min_framesize; - const uint32_t max_framesize = metadata->data.stream_info.max_framesize; - ogg_page page; - - FLAC__ASSERT(metadata->type == FLAC__METADATA_TYPE_STREAMINFO); - FLAC__ASSERT(0 != encoder->private_->seek_callback); - - /* Pre-check that client supports seeking, since we don't want the - * ogg_helper code to ever have to deal with this condition. - */ - if(encoder->private_->seek_callback(encoder, 0, encoder->private_->client_data) == FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED) - return; - - /* All this is based on intimate knowledge of the stream header - * layout, but a change to the header format that would break this - * would also break all streams encoded in the previous format. - */ - - /** - ** Write STREAMINFO stats - **/ - simple_ogg_page__init(&page); - if(!simple_ogg_page__get_at(encoder, encoder->protected_->streaminfo_offset, &page, encoder->private_->seek_callback, encoder->private_->read_callback, encoder->private_->client_data)) { - simple_ogg_page__clear(&page); - return; /* state already set */ - } - - /* - * Write MD5 signature - */ - { - const uint32_t md5_offset = - FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH + - FLAC__STREAM_METADATA_HEADER_LENGTH + - ( - FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN + - FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN - ) / 8; - - if(md5_offset + 16 > (uint32_t)page.body_len) { - encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; - simple_ogg_page__clear(&page); - return; - } - memcpy(page.body + md5_offset, metadata->data.stream_info.md5sum, 16); - } - - /* - * Write total samples - */ - { - const uint32_t total_samples_byte_offset = - FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH + - FLAC__STREAM_METADATA_HEADER_LENGTH + - ( - FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN + - FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN - - 4 - ) / 8; - - if(total_samples_byte_offset + 5 > (uint32_t)page.body_len) { - encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; - simple_ogg_page__clear(&page); - return; - } - b[0] = (FLAC__byte)page.body[total_samples_byte_offset] & 0xF0; - b[0] |= (FLAC__byte)((samples >> 32) & 0x0F); - b[1] = (FLAC__byte)((samples >> 24) & 0xFF); - b[2] = (FLAC__byte)((samples >> 16) & 0xFF); - b[3] = (FLAC__byte)((samples >> 8) & 0xFF); - b[4] = (FLAC__byte)(samples & 0xFF); - memcpy(page.body + total_samples_byte_offset, b, 5); - } - - /* - * Write min/max framesize - */ - { - const uint32_t min_framesize_offset = - FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH + - FLAC__STREAM_METADATA_HEADER_LENGTH + - ( - FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN + - FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN - ) / 8; - - if(min_framesize_offset + 6 > (uint32_t)page.body_len) { - encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; - simple_ogg_page__clear(&page); - return; - } - b[0] = (FLAC__byte)((min_framesize >> 16) & 0xFF); - b[1] = (FLAC__byte)((min_framesize >> 8) & 0xFF); - b[2] = (FLAC__byte)(min_framesize & 0xFF); - b[3] = (FLAC__byte)((max_framesize >> 16) & 0xFF); - b[4] = (FLAC__byte)((max_framesize >> 8) & 0xFF); - b[5] = (FLAC__byte)(max_framesize & 0xFF); - memcpy(page.body + min_framesize_offset, b, 6); - } - if(!simple_ogg_page__set_at(encoder, encoder->protected_->streaminfo_offset, &page, encoder->private_->seek_callback, encoder->private_->write_callback, encoder->private_->client_data)) { - simple_ogg_page__clear(&page); - return; /* state already set */ - } - simple_ogg_page__clear(&page); -} -#endif - -FLAC__bool process_frame_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_block) -{ - FLAC__uint16 crc; - FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK); - - /* - * Accumulate raw signal to the MD5 signature - */ - if(encoder->protected_->do_md5 && !FLAC__MD5Accumulate(&encoder->private_->md5context, (const FLAC__int32 * const *)encoder->private_->integer_signal, encoder->protected_->channels, encoder->protected_->blocksize, (encoder->protected_->bits_per_sample+7) / 8)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; - return false; - } - - /* - * Process the frame header and subframes into the frame bitbuffer - */ - if(!process_subframes_(encoder)) { - /* the above function sets the state for us in case of an error */ - return false; - } - - /* - * Zero-pad the frame to a byte_boundary - */ - if(!FLAC__bitwriter_zero_pad_to_byte_boundary(encoder->private_->frame)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; - return false; - } - - /* - * CRC-16 the whole thing - */ - FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(encoder->private_->frame)); - if( - !FLAC__bitwriter_get_write_crc16(encoder->private_->frame, &crc) || - !FLAC__bitwriter_write_raw_uint32(encoder->private_->frame, crc, FLAC__FRAME_FOOTER_CRC_LEN) - ) { - encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; - return false; - } - - /* - * Write it - */ - if(!write_bitbuffer_(encoder, encoder->protected_->blocksize, is_last_block)) { - /* the above function sets the state for us in case of an error */ - return false; - } - - /* - * Get ready for the next frame - */ - encoder->private_->current_sample_number = 0; - encoder->private_->current_frame_number++; - encoder->private_->streaminfo.data.stream_info.total_samples += (FLAC__uint64)encoder->protected_->blocksize; - - return true; -} - -FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder) -{ - FLAC__FrameHeader frame_header; - uint32_t channel, min_partition_order = encoder->protected_->min_residual_partition_order, max_partition_order; - FLAC__bool do_independent, do_mid_side, backup_disable_constant_subframes = encoder->private_->disable_constant_subframes, all_subframes_constant = true; - - /* - * Calculate the min,max Rice partition orders - */ - - max_partition_order = FLAC__format_get_max_rice_partition_order_from_blocksize(encoder->protected_->blocksize); - max_partition_order = flac_min(max_partition_order, encoder->protected_->max_residual_partition_order); - min_partition_order = flac_min(min_partition_order, max_partition_order); - - /* - * Setup the frame - */ - frame_header.blocksize = encoder->protected_->blocksize; - frame_header.sample_rate = encoder->protected_->sample_rate; - frame_header.channels = encoder->protected_->channels; - frame_header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; /* the default unless the encoder determines otherwise */ - frame_header.bits_per_sample = encoder->protected_->bits_per_sample; - frame_header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER; - frame_header.number.frame_number = encoder->private_->current_frame_number; - - /* - * Figure out what channel assignments to try - */ - if(encoder->protected_->do_mid_side_stereo) { - if(encoder->protected_->loose_mid_side_stereo) { - if(encoder->private_->loose_mid_side_stereo_frame_count == 0) { - do_independent = true; - do_mid_side = true; - } - else { - do_independent = (encoder->private_->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT); - do_mid_side = !do_independent; - } - } - else { - do_independent = true; - do_mid_side = true; - } - } - else { - do_independent = true; - do_mid_side = false; - } - - FLAC__ASSERT(do_independent || do_mid_side); - - /* - * Prepare mid-side signals if applicable - */ - if(do_mid_side) { - uint32_t i; - FLAC__ASSERT(encoder->protected_->channels == 2); - if(encoder->protected_->bits_per_sample < 32) - for(i = 0; i < encoder->protected_->blocksize; i++) { - encoder->private_->integer_signal_mid_side[1][i] = encoder->private_->integer_signal[0][i] - encoder->private_->integer_signal[1][i]; - encoder->private_->integer_signal_mid_side[0][i] = (encoder->private_->integer_signal[0][i] + encoder->private_->integer_signal[1][i]) >> 1; /* NOTE: not the same as 'mid = (signal[0][j] + signal[1][j]) / 2' ! */ - } - else - for(i = 0; i <= encoder->protected_->blocksize; i++) { - encoder->private_->integer_signal_33bit_side[i] = (FLAC__int64)encoder->private_->integer_signal[0][i] - (FLAC__int64)encoder->private_->integer_signal[1][i]; - encoder->private_->integer_signal_mid_side[0][i] = ((FLAC__int64)encoder->private_->integer_signal[0][i] + (FLAC__int64)encoder->private_->integer_signal[1][i]) >> 1; /* NOTE: not the same as 'mid = (signal[0][j] + signal[1][j]) / 2' ! */ - } - } - - - /* - * Check for wasted bits; set effective bps for each subframe - */ - if(do_independent) { - for(channel = 0; channel < encoder->protected_->channels; channel++) { - uint32_t w = get_wasted_bits_(encoder->private_->integer_signal[channel], encoder->protected_->blocksize); - if (w > encoder->protected_->bits_per_sample) { - w = encoder->protected_->bits_per_sample; - } - encoder->private_->subframe_workspace[channel][0].wasted_bits = encoder->private_->subframe_workspace[channel][1].wasted_bits = w; - encoder->private_->subframe_bps[channel] = encoder->protected_->bits_per_sample - w; - } - } - if(do_mid_side) { - FLAC__ASSERT(encoder->protected_->channels == 2); - for(channel = 0; channel < 2; channel++) { - uint32_t w; - if(encoder->protected_->bits_per_sample < 32 || channel == 0) - w = get_wasted_bits_(encoder->private_->integer_signal_mid_side[channel], encoder->protected_->blocksize); - else - w = get_wasted_bits_wide_(encoder->private_->integer_signal_33bit_side, encoder->private_->integer_signal_mid_side[channel], encoder->protected_->blocksize); - - if (w > encoder->protected_->bits_per_sample) { - w = encoder->protected_->bits_per_sample; - } - encoder->private_->subframe_workspace_mid_side[channel][0].wasted_bits = encoder->private_->subframe_workspace_mid_side[channel][1].wasted_bits = w; - encoder->private_->subframe_bps_mid_side[channel] = encoder->protected_->bits_per_sample - w + (channel==0? 0:1); - } - } - - /* - * First do a normal encoding pass of each independent channel - */ - if(do_independent) { - for(channel = 0; channel < encoder->protected_->channels; channel++) { - if(encoder->protected_->limit_min_bitrate && all_subframes_constant && (channel + 1) == encoder->protected_->channels){ - /* This frame contains only constant subframes at this point. - * To prevent the frame from becoming too small, make sure - * the last subframe isn't constant */ - encoder->private_->disable_constant_subframes = true; - } - if(! - process_subframe_( - encoder, - min_partition_order, - max_partition_order, - &frame_header, - encoder->private_->subframe_bps[channel], - encoder->private_->integer_signal[channel], - encoder->private_->subframe_workspace_ptr[channel], - encoder->private_->partitioned_rice_contents_workspace_ptr[channel], - encoder->private_->residual_workspace[channel], - encoder->private_->best_subframe+channel, - encoder->private_->best_subframe_bits+channel - ) - ) - return false; - if(encoder->private_->subframe_workspace[channel][encoder->private_->best_subframe[channel]].type != FLAC__SUBFRAME_TYPE_CONSTANT) - all_subframes_constant = false; - } - } - - /* - * Now do mid and side channels if requested - */ - if(do_mid_side) { - FLAC__ASSERT(encoder->protected_->channels == 2); - - for(channel = 0; channel < 2; channel++) { - void *integer_signal_; - if(encoder->private_->subframe_bps_mid_side[channel] <= 32) - integer_signal_ = encoder->private_->integer_signal_mid_side[channel]; - else - integer_signal_ = encoder->private_->integer_signal_33bit_side; - if(! - process_subframe_( - encoder, - min_partition_order, - max_partition_order, - &frame_header, - encoder->private_->subframe_bps_mid_side[channel], - integer_signal_, - encoder->private_->subframe_workspace_ptr_mid_side[channel], - encoder->private_->partitioned_rice_contents_workspace_ptr_mid_side[channel], - encoder->private_->residual_workspace_mid_side[channel], - encoder->private_->best_subframe_mid_side+channel, - encoder->private_->best_subframe_bits_mid_side+channel - ) - ) - return false; - } - } - - /* - * Compose the frame bitbuffer - */ - if(do_mid_side) { - uint32_t left_bps = 0, right_bps = 0; /* initialized only to prevent superfluous compiler warning */ - FLAC__Subframe *left_subframe = 0, *right_subframe = 0; /* initialized only to prevent superfluous compiler warning */ - FLAC__ChannelAssignment channel_assignment; - - FLAC__ASSERT(encoder->protected_->channels == 2); - - if(encoder->protected_->loose_mid_side_stereo && encoder->private_->loose_mid_side_stereo_frame_count > 0) { - channel_assignment = (encoder->private_->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT? FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT : FLAC__CHANNEL_ASSIGNMENT_MID_SIDE); - } - else { - uint32_t bits[4]; /* WATCHOUT - indexed by FLAC__ChannelAssignment */ - uint32_t min_bits; - int ca; - - FLAC__ASSERT(FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT == 0); - FLAC__ASSERT(FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE == 1); - FLAC__ASSERT(FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE == 2); - FLAC__ASSERT(FLAC__CHANNEL_ASSIGNMENT_MID_SIDE == 3); - FLAC__ASSERT(do_independent && do_mid_side); - - /* We have to figure out which channel assignent results in the smallest frame */ - bits[FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT] = encoder->private_->best_subframe_bits [0] + encoder->private_->best_subframe_bits [1]; - bits[FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE ] = encoder->private_->best_subframe_bits [0] + encoder->private_->best_subframe_bits_mid_side[1]; - bits[FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE ] = encoder->private_->best_subframe_bits [1] + encoder->private_->best_subframe_bits_mid_side[1]; - bits[FLAC__CHANNEL_ASSIGNMENT_MID_SIDE ] = encoder->private_->best_subframe_bits_mid_side[0] + encoder->private_->best_subframe_bits_mid_side[1]; - - channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; - min_bits = bits[channel_assignment]; - - /* When doing loose mid-side stereo, ignore left-side - * and right-side options */ - ca = encoder->protected_->loose_mid_side_stereo ? 3 : 1; - for( ; ca <= 3; ca++) { - if(bits[ca] < min_bits) { - min_bits = bits[ca]; - channel_assignment = (FLAC__ChannelAssignment)ca; - } - } - } - - frame_header.channel_assignment = channel_assignment; - - if(!FLAC__frame_add_header(&frame_header, encoder->private_->frame)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return false; - } - - switch(channel_assignment) { - case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: - left_subframe = &encoder->private_->subframe_workspace [0][encoder->private_->best_subframe [0]]; - right_subframe = &encoder->private_->subframe_workspace [1][encoder->private_->best_subframe [1]]; - break; - case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: - left_subframe = &encoder->private_->subframe_workspace [0][encoder->private_->best_subframe [0]]; - right_subframe = &encoder->private_->subframe_workspace_mid_side[1][encoder->private_->best_subframe_mid_side[1]]; - break; - case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: - left_subframe = &encoder->private_->subframe_workspace_mid_side[1][encoder->private_->best_subframe_mid_side[1]]; - right_subframe = &encoder->private_->subframe_workspace [1][encoder->private_->best_subframe [1]]; - break; - case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: - left_subframe = &encoder->private_->subframe_workspace_mid_side[0][encoder->private_->best_subframe_mid_side[0]]; - right_subframe = &encoder->private_->subframe_workspace_mid_side[1][encoder->private_->best_subframe_mid_side[1]]; - break; - default: - FLAC__ASSERT(0); - } - - switch(channel_assignment) { - case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: - left_bps = encoder->private_->subframe_bps [0]; - right_bps = encoder->private_->subframe_bps [1]; - break; - case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: - left_bps = encoder->private_->subframe_bps [0]; - right_bps = encoder->private_->subframe_bps_mid_side[1]; - break; - case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: - left_bps = encoder->private_->subframe_bps_mid_side[1]; - right_bps = encoder->private_->subframe_bps [1]; - break; - case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: - left_bps = encoder->private_->subframe_bps_mid_side[0]; - right_bps = encoder->private_->subframe_bps_mid_side[1]; - break; - default: - FLAC__ASSERT(0); - } - - /* note that encoder_add_subframe_ sets the state for us in case of an error */ - if(!add_subframe_(encoder, frame_header.blocksize, left_bps , left_subframe , encoder->private_->frame)) - return false; - if(!add_subframe_(encoder, frame_header.blocksize, right_bps, right_subframe, encoder->private_->frame)) - return false; - } - else { - if(!FLAC__frame_add_header(&frame_header, encoder->private_->frame)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return false; - } - - for(channel = 0; channel < encoder->protected_->channels; channel++) { - if(!add_subframe_(encoder, frame_header.blocksize, encoder->private_->subframe_bps[channel], &encoder->private_->subframe_workspace[channel][encoder->private_->best_subframe[channel]], encoder->private_->frame)) { - /* the above function sets the state for us in case of an error */ - return false; - } - } - } - - if(encoder->protected_->loose_mid_side_stereo) { - encoder->private_->loose_mid_side_stereo_frame_count++; - if(encoder->private_->loose_mid_side_stereo_frame_count >= encoder->private_->loose_mid_side_stereo_frames) - encoder->private_->loose_mid_side_stereo_frame_count = 0; - } - - encoder->private_->last_channel_assignment = frame_header.channel_assignment; - encoder->private_->disable_constant_subframes = backup_disable_constant_subframes; - - return true; -} - -FLAC__bool process_subframe_( - FLAC__StreamEncoder *encoder, - uint32_t min_partition_order, - uint32_t max_partition_order, - const FLAC__FrameHeader *frame_header, - uint32_t subframe_bps, - const void *integer_signal, - FLAC__Subframe *subframe[2], - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents[2], - FLAC__int32 *residual[2], - uint32_t *best_subframe, - uint32_t *best_bits -) -{ -#ifndef FLAC__INTEGER_ONLY_LIBRARY - float fixed_residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]; -#else - FLAC__fixedpoint fixed_residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]; -#endif -#ifndef FLAC__INTEGER_ONLY_LIBRARY - double lpc_residual_bits_per_sample; - apply_apodization_state_struct apply_apodization_state; - double lpc_error[FLAC__MAX_LPC_ORDER]; - uint32_t min_lpc_order, max_lpc_order, lpc_order, guess_lpc_order; - uint32_t min_qlp_coeff_precision, max_qlp_coeff_precision, qlp_coeff_precision; -#endif - uint32_t min_fixed_order, max_fixed_order, guess_fixed_order, fixed_order; - uint32_t _candidate_bits, _best_bits; - uint32_t _best_subframe; - /* only use RICE2 partitions if stream bps > 16 */ - const uint32_t rice_parameter_limit = FLAC__stream_encoder_get_bits_per_sample(encoder) > 16? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; - - FLAC__ASSERT(frame_header->blocksize > 0); - - /* verbatim subframe is the baseline against which we measure other compressed subframes */ - _best_subframe = 0; - if(encoder->private_->disable_verbatim_subframes && frame_header->blocksize >= FLAC__MAX_FIXED_ORDER) - _best_bits = UINT32_MAX; - else - _best_bits = evaluate_verbatim_subframe_(encoder, integer_signal, frame_header->blocksize, subframe_bps, subframe[_best_subframe]); - *best_bits = _best_bits; - - if(frame_header->blocksize > FLAC__MAX_FIXED_ORDER) { - uint32_t signal_is_constant = false; - /* The next formula determines when to use a 64-bit accumulator - * for the error of a fixed predictor, and when a 32-bit one. As - * the error of a 4th order predictor for a given sample is the - * sum of 17 sample values (1+4+6+4+1) and there are blocksize - - * order error values to be summed, the maximum total error is - * maximum_sample_value * (blocksize - order) * 17. As ilog2(x) - * calculates floor(2log(x)), the result must be 31 or lower - */ - if(subframe_bps < 28){ - if(subframe_bps + FLAC__bitmath_ilog2((frame_header->blocksize-FLAC__MAX_FIXED_ORDER)*17) < 32) - guess_fixed_order = encoder->private_->local_fixed_compute_best_predictor(((FLAC__int32 *)integer_signal)+FLAC__MAX_FIXED_ORDER, frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample); - else - guess_fixed_order = encoder->private_->local_fixed_compute_best_predictor_wide(((FLAC__int32 *)integer_signal)+FLAC__MAX_FIXED_ORDER, frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample); - } - else - if(subframe_bps <= 32) - guess_fixed_order = encoder->private_->local_fixed_compute_best_predictor_limit_residual(((FLAC__int32 *)integer_signal+FLAC__MAX_FIXED_ORDER),frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample); - else - guess_fixed_order = FLAC__fixed_compute_best_predictor_limit_residual_33bit(((FLAC__int64 *)integer_signal+FLAC__MAX_FIXED_ORDER),frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample); - - /* check for constant subframe */ - if( - !encoder->private_->disable_constant_subframes && -#ifndef FLAC__INTEGER_ONLY_LIBRARY - fixed_residual_bits_per_sample[1] == 0.0 -#else - fixed_residual_bits_per_sample[1] == FLAC__FP_ZERO -#endif - ) { - /* the above means it's possible all samples are the same value; now double-check it: */ - uint32_t i; - signal_is_constant = true; - if(subframe_bps <= 32){ - const FLAC__int32 *integer_signal_ = integer_signal; - for(i = 1; i < frame_header->blocksize; i++) { - if(integer_signal_[0] != integer_signal_[i]) { - signal_is_constant = false; - break; - } - } - } - else { - const FLAC__int64 *integer_signal_ = integer_signal; - for(i = 1; i < frame_header->blocksize; i++) { - if(integer_signal_[0] != integer_signal_[i]) { - signal_is_constant = false; - break; - } - } - } - } - if(signal_is_constant) { - if(subframe_bps <= 32) - _candidate_bits = evaluate_constant_subframe_(encoder, ((FLAC__int32 *)integer_signal)[0], frame_header->blocksize, subframe_bps, subframe[!_best_subframe]); - else - _candidate_bits = evaluate_constant_subframe_(encoder, ((FLAC__int64 *)integer_signal)[0], frame_header->blocksize, subframe_bps, subframe[!_best_subframe]); - - if(_candidate_bits < _best_bits) { - _best_subframe = !_best_subframe; - _best_bits = _candidate_bits; - } - } - else { - if(!encoder->private_->disable_fixed_subframes || (encoder->protected_->max_lpc_order == 0 && _best_bits == UINT_MAX)) { - /* encode fixed */ - if(encoder->protected_->do_exhaustive_model_search) { - min_fixed_order = 0; - max_fixed_order = FLAC__MAX_FIXED_ORDER; - } - else { - min_fixed_order = max_fixed_order = guess_fixed_order; - } - if(max_fixed_order >= frame_header->blocksize) - max_fixed_order = frame_header->blocksize - 1; - for(fixed_order = min_fixed_order; fixed_order <= max_fixed_order; fixed_order++) { -#ifndef FLAC__INTEGER_ONLY_LIBRARY - if(fixed_residual_bits_per_sample[fixed_order] >= (float)subframe_bps) - continue; /* don't even try */ -#else - if(FLAC__fixedpoint_trunc(fixed_residual_bits_per_sample[fixed_order]) >= (int)subframe_bps) - continue; /* don't even try */ -#endif - _candidate_bits = - evaluate_fixed_subframe_( - encoder, - integer_signal, - residual[!_best_subframe], - encoder->private_->abs_residual_partition_sums, - encoder->private_->raw_bits_per_partition, - frame_header->blocksize, - subframe_bps, - fixed_order, - rice_parameter_limit, - min_partition_order, - max_partition_order, - encoder->protected_->do_escape_coding, - encoder->protected_->rice_parameter_search_dist, - subframe[!_best_subframe], - partitioned_rice_contents[!_best_subframe] - ); - if(_candidate_bits < _best_bits) { - _best_subframe = !_best_subframe; - _best_bits = _candidate_bits; - } - } - } - -#ifndef FLAC__INTEGER_ONLY_LIBRARY - /* encode lpc */ - if(encoder->protected_->max_lpc_order > 0) { - if(encoder->protected_->max_lpc_order >= frame_header->blocksize) - max_lpc_order = frame_header->blocksize-1; - else - max_lpc_order = encoder->protected_->max_lpc_order; - if(max_lpc_order > 0) { - apply_apodization_state.a = 0; - apply_apodization_state.b = 1; - apply_apodization_state.c = 0; - while (apply_apodization_state.a < encoder->protected_->num_apodizations) { - uint32_t max_lpc_order_this_apodization = max_lpc_order; - - if(!apply_apodization_(encoder, &apply_apodization_state, - frame_header->blocksize, lpc_error, - &max_lpc_order_this_apodization, - subframe_bps, integer_signal, - &guess_lpc_order)) - /* If apply_apodization_ fails, try next apodization */ - continue; - - if(encoder->protected_->do_exhaustive_model_search) { - min_lpc_order = 1; - } - else { - min_lpc_order = max_lpc_order_this_apodization = guess_lpc_order; - } - for(lpc_order = min_lpc_order; lpc_order <= max_lpc_order_this_apodization; lpc_order++) { - lpc_residual_bits_per_sample = FLAC__lpc_compute_expected_bits_per_residual_sample(lpc_error[lpc_order-1], frame_header->blocksize-lpc_order); - if(lpc_residual_bits_per_sample >= (double)subframe_bps) - continue; /* don't even try */ - if(encoder->protected_->do_qlp_coeff_prec_search) { - min_qlp_coeff_precision = FLAC__MIN_QLP_COEFF_PRECISION; - /* try to keep qlp coeff precision such that only 32-bit math is required for decode of <=16bps(+1bps for side channel) streams */ - if(subframe_bps <= 17) { - max_qlp_coeff_precision = flac_min(32 - subframe_bps - FLAC__bitmath_ilog2(lpc_order), FLAC__MAX_QLP_COEFF_PRECISION); - max_qlp_coeff_precision = flac_max(max_qlp_coeff_precision, min_qlp_coeff_precision); - } - else - max_qlp_coeff_precision = FLAC__MAX_QLP_COEFF_PRECISION; - } - else { - min_qlp_coeff_precision = max_qlp_coeff_precision = encoder->protected_->qlp_coeff_precision; - } - for(qlp_coeff_precision = min_qlp_coeff_precision; qlp_coeff_precision <= max_qlp_coeff_precision; qlp_coeff_precision++) { - _candidate_bits = - evaluate_lpc_subframe_( - encoder, - integer_signal, - residual[!_best_subframe], - encoder->private_->abs_residual_partition_sums, - encoder->private_->raw_bits_per_partition, - encoder->private_->lp_coeff[lpc_order-1], - frame_header->blocksize, - subframe_bps, - lpc_order, - qlp_coeff_precision, - rice_parameter_limit, - min_partition_order, - max_partition_order, - encoder->protected_->do_escape_coding, - encoder->protected_->rice_parameter_search_dist, - subframe[!_best_subframe], - partitioned_rice_contents[!_best_subframe] - ); - if(_candidate_bits > 0) { /* if == 0, there was a problem quantizing the lpcoeffs */ - if(_candidate_bits < _best_bits) { - _best_subframe = !_best_subframe; - _best_bits = _candidate_bits; - } - } - } - } - } - } - } -#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ - } - } - - /* under rare circumstances this can happen when all but lpc subframe types are disabled: */ - if(_best_bits == UINT32_MAX) { - FLAC__ASSERT(_best_subframe == 0); - _best_bits = evaluate_verbatim_subframe_(encoder, integer_signal, frame_header->blocksize, subframe_bps, subframe[_best_subframe]); - } - - *best_subframe = _best_subframe; - *best_bits = _best_bits; - - return true; -} - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -static inline void set_next_subdivide_tukey(FLAC__int32 parts, uint32_t * apodizations, uint32_t * current_depth, uint32_t * current_part){ - // current_part is interleaved: even are partial, odd are punchout - if(*current_depth == 2){ - // For depth 2, we only do partial, no punchout as that is almost redundant - if(*current_part == 0){ - *current_part = 2; - }else{ /* *current_path == 2 */ - *current_part = 0; - (*current_depth)++; - } - }else if((*current_part) < (2*(*current_depth)-1)){ - (*current_part)++; - }else{ /* (*current_part) >= (2*(*current_depth)-1) */ - *current_part = 0; - (*current_depth)++; - } - - /* Now check if we are done with this SUBDIVIDE_TUKEY apodization */ - if(*current_depth > (uint32_t) parts){ - (*apodizations)++; - *current_depth = 1; - *current_part = 0; - } -} - -FLAC__bool apply_apodization_(FLAC__StreamEncoder *encoder, - apply_apodization_state_struct *apply_apodization_state, - uint32_t blocksize, - double *lpc_error, - uint32_t *max_lpc_order_this_apodization, - uint32_t subframe_bps, - const void *integer_signal, - uint32_t *guess_lpc_order) -{ - apply_apodization_state->current_apodization = &encoder->protected_->apodizations[apply_apodization_state->a]; - - if(apply_apodization_state->b == 1) { - /* window full subblock */ - if(subframe_bps <= 32) - FLAC__lpc_window_data(integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize); - else - FLAC__lpc_window_data_wide(integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize); - encoder->private_->local_lpc_compute_autocorrelation(encoder->private_->windowed_signal, blocksize, (*max_lpc_order_this_apodization)+1, apply_apodization_state->autoc); - if(apply_apodization_state->current_apodization->type == FLAC__APODIZATION_SUBDIVIDE_TUKEY){ - uint32_t i; - for(i = 0; i < *max_lpc_order_this_apodization; i++) - memcpy(apply_apodization_state->autoc_root, apply_apodization_state->autoc, *max_lpc_order_this_apodization*sizeof(apply_apodization_state->autoc[0])); - - (apply_apodization_state->b)++; - }else{ - (apply_apodization_state->a)++; - } - } - else { - /* window part of subblock */ - if(blocksize/apply_apodization_state->b <= FLAC__MAX_LPC_ORDER) { - /* intrinsics autocorrelation routines do not all handle cases in which lag might be - * larger than data_len, and some routines round lag up to the nearest multiple of 4 - * As little gain is expected from using LPC on part of a signal as small as 32 samples - * and to enable widening this rounding up to larger values in the future, windowing - * parts smaller than or equal to FLAC__MAX_LPC_ORDER (which is 32) samples is not supported */ - set_next_subdivide_tukey(apply_apodization_state->current_apodization->parameters.subdivide_tukey.parts, &apply_apodization_state->a, &apply_apodization_state->b, &apply_apodization_state->c); - return false; - } - if(!(apply_apodization_state->c % 2)) { - /* on even c, evaluate the (c/2)th partial window of size blocksize/b */ - if(subframe_bps <= 32) - FLAC__lpc_window_data_partial(integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize, blocksize/apply_apodization_state->b/2, (apply_apodization_state->c/2*blocksize)/apply_apodization_state->b); - else - FLAC__lpc_window_data_partial_wide(integer_signal, encoder->private_->window[apply_apodization_state->a], encoder->private_->windowed_signal, blocksize, blocksize/apply_apodization_state->b/2, (apply_apodization_state->c/2*blocksize)/apply_apodization_state->b); - encoder->private_->local_lpc_compute_autocorrelation(encoder->private_->windowed_signal, blocksize/apply_apodization_state->b, (*max_lpc_order_this_apodization)+1, apply_apodization_state->autoc); - } - else { - /* on uneven c, evaluate the root window (over the whole block) minus the previous partial window - * similar to tukey_punchout apodization but more efficient */ - uint32_t i; - for(i = 0; i < *max_lpc_order_this_apodization; i++) - apply_apodization_state->autoc[i] = apply_apodization_state->autoc_root[i] - apply_apodization_state->autoc[i]; - } - /* Next function sets a, b and c appropriate for next iteration */ - set_next_subdivide_tukey(apply_apodization_state->current_apodization->parameters.subdivide_tukey.parts, &apply_apodization_state->a, &apply_apodization_state->b, &apply_apodization_state->c); - } - - if(apply_apodization_state->autoc[0] == 0.0) /* Signal seems to be constant, so we can't do lp. Constant detection is probably disabled */ - return false; - FLAC__lpc_compute_lp_coefficients(apply_apodization_state->autoc, max_lpc_order_this_apodization, encoder->private_->lp_coeff, lpc_error); - *guess_lpc_order = - FLAC__lpc_compute_best_order( - lpc_error, - *max_lpc_order_this_apodization, - blocksize, - subframe_bps + ( - encoder->protected_->do_qlp_coeff_prec_search? - FLAC__MIN_QLP_COEFF_PRECISION : /* have to guess; use the min possible size to avoid accidentally favoring lower orders */ - encoder->protected_->qlp_coeff_precision - ) - ); - return true; -} -#endif - -FLAC__bool add_subframe_( - FLAC__StreamEncoder *encoder, - uint32_t blocksize, - uint32_t subframe_bps, - const FLAC__Subframe *subframe, - FLAC__BitWriter *frame -) -{ - switch(subframe->type) { - case FLAC__SUBFRAME_TYPE_CONSTANT: - if(!FLAC__subframe_add_constant(&(subframe->data.constant), subframe_bps, subframe->wasted_bits, frame)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return false; - } - break; - case FLAC__SUBFRAME_TYPE_FIXED: - if(!FLAC__subframe_add_fixed(&(subframe->data.fixed), blocksize - subframe->data.fixed.order, subframe_bps, subframe->wasted_bits, frame)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return false; - } - break; - case FLAC__SUBFRAME_TYPE_LPC: - if(!FLAC__subframe_add_lpc(&(subframe->data.lpc), blocksize - subframe->data.lpc.order, subframe_bps, subframe->wasted_bits, frame)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return false; - } - break; - case FLAC__SUBFRAME_TYPE_VERBATIM: - if(!FLAC__subframe_add_verbatim(&(subframe->data.verbatim), blocksize, subframe_bps, subframe->wasted_bits, frame)) { - encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR; - return false; - } - break; - default: - FLAC__ASSERT(0); - } - - return true; -} - -#define SPOTCHECK_ESTIMATE 0 -#if SPOTCHECK_ESTIMATE -static void spotcheck_subframe_estimate_( - FLAC__StreamEncoder *encoder, - uint32_t blocksize, - uint32_t subframe_bps, - const FLAC__Subframe *subframe, - uint32_t estimate -) -{ - FLAC__bool ret; - FLAC__BitWriter *frame = FLAC__bitwriter_new(); - if(frame == 0) { - fprintf(stderr, "EST: can't allocate frame\n"); - return; - } - if(!FLAC__bitwriter_init(frame)) { - fprintf(stderr, "EST: can't init frame\n"); - return; - } - ret = add_subframe_(encoder, blocksize, subframe_bps, subframe, frame); - FLAC__ASSERT(ret); - { - const uint32_t actual = FLAC__bitwriter_get_input_bits_unconsumed(frame); - if(estimate != actual) - fprintf(stderr, "EST: bad, frame#%u sub#%%d type=%8s est=%u, actual=%u, delta=%d\n", encoder->private_->current_frame_number, FLAC__SubframeTypeString[subframe->type], estimate, actual, (int)actual-(int)estimate); - } - FLAC__bitwriter_delete(frame); -} -#endif - -uint32_t evaluate_constant_subframe_( - FLAC__StreamEncoder *encoder, - const FLAC__int64 signal, - uint32_t blocksize, - uint32_t subframe_bps, - FLAC__Subframe *subframe -) -{ - uint32_t estimate; - subframe->type = FLAC__SUBFRAME_TYPE_CONSTANT; - subframe->data.constant.value = signal; - - estimate = FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe->wasted_bits + subframe_bps; - -#if SPOTCHECK_ESTIMATE - spotcheck_subframe_estimate_(encoder, blocksize, subframe_bps, subframe, estimate); -#else - (void)encoder, (void)blocksize; -#endif - - return estimate; -} - -uint32_t evaluate_fixed_subframe_( - FLAC__StreamEncoder *encoder, - const void *signal, - FLAC__int32 residual[], - FLAC__uint64 abs_residual_partition_sums[], - uint32_t raw_bits_per_partition[], - uint32_t blocksize, - uint32_t subframe_bps, - uint32_t order, - uint32_t rice_parameter_limit, - uint32_t min_partition_order, - uint32_t max_partition_order, - FLAC__bool do_escape_coding, - uint32_t rice_parameter_search_dist, - FLAC__Subframe *subframe, - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents -) -{ - uint32_t i, residual_bits, estimate; - const uint32_t residual_samples = blocksize - order; - - if((subframe_bps + order) <= 32) - FLAC__fixed_compute_residual(((FLAC__int32 *)signal)+order, residual_samples, order, residual); - else if(subframe_bps <= 32) - FLAC__fixed_compute_residual_wide(((FLAC__int32 *)signal)+order, residual_samples, order, residual); - else - FLAC__fixed_compute_residual_wide_33bit(((FLAC__int64 *)signal)+order, residual_samples, order, residual); - - subframe->type = FLAC__SUBFRAME_TYPE_FIXED; - - subframe->data.fixed.entropy_coding_method.type = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE; - subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents = partitioned_rice_contents; - subframe->data.fixed.residual = residual; - - residual_bits = - find_best_partition_order_( - encoder->private_, - residual, - abs_residual_partition_sums, - raw_bits_per_partition, - residual_samples, - order, - rice_parameter_limit, - min_partition_order, - max_partition_order, - subframe_bps, - do_escape_coding, - rice_parameter_search_dist, - &subframe->data.fixed.entropy_coding_method - ); - - subframe->data.fixed.order = order; - if(subframe_bps <= 32) - for(i = 0; i < order; i++) - subframe->data.fixed.warmup[i] = ((FLAC__int32 *)signal)[i]; - else - for(i = 0; i < order; i++) - subframe->data.fixed.warmup[i] = ((FLAC__int64 *)signal)[i]; - - estimate = FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe->wasted_bits + (order * subframe_bps); - if(residual_bits < UINT32_MAX - estimate) // To make sure estimate doesn't overflow - estimate += residual_bits; - else - estimate = UINT32_MAX; - -#if SPOTCHECK_ESTIMATE - spotcheck_subframe_estimate_(encoder, blocksize, subframe_bps, subframe, estimate); -#endif - - return estimate; -} - -#ifndef FLAC__INTEGER_ONLY_LIBRARY -uint32_t evaluate_lpc_subframe_( - FLAC__StreamEncoder *encoder, - const void *signal, - FLAC__int32 residual[], - FLAC__uint64 abs_residual_partition_sums[], - uint32_t raw_bits_per_partition[], - const FLAC__real lp_coeff[], - uint32_t blocksize, - uint32_t subframe_bps, - uint32_t order, - uint32_t qlp_coeff_precision, - uint32_t rice_parameter_limit, - uint32_t min_partition_order, - uint32_t max_partition_order, - FLAC__bool do_escape_coding, - uint32_t rice_parameter_search_dist, - FLAC__Subframe *subframe, - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents -) -{ - FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; /* WATCHOUT: the size is important; some x86 intrinsic routines need more than lpc order elements */ - uint32_t i, residual_bits, estimate; - int quantization, ret; - const uint32_t residual_samples = blocksize - order; - - /* try to keep qlp coeff precision such that only 32-bit math is required for decode of <=16bps(+1bps for side channel) streams */ - if(subframe_bps <= 17) { - FLAC__ASSERT(order > 0); - FLAC__ASSERT(order <= FLAC__MAX_LPC_ORDER); - qlp_coeff_precision = flac_min(qlp_coeff_precision, 32 - subframe_bps - FLAC__bitmath_ilog2(order)); - } - - ret = FLAC__lpc_quantize_coefficients(lp_coeff, order, qlp_coeff_precision, qlp_coeff, &quantization); - if(ret != 0) - return 0; /* this is a hack to indicate to the caller that we can't do lp at this order on this subframe */ - - if(FLAC__lpc_max_residual_bps(subframe_bps, qlp_coeff, order, quantization) > 32) { - if(subframe_bps <= 32){ - if(!FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual(((FLAC__int32 *)signal)+order, residual_samples, qlp_coeff, order, quantization, residual)) - return 0; - } - else - if(!FLAC__lpc_compute_residual_from_qlp_coefficients_limit_residual_33bit(((FLAC__int64 *)signal)+order, residual_samples, qlp_coeff, order, quantization, residual)) - return 0; - } - else - if(FLAC__lpc_max_prediction_before_shift_bps(subframe_bps, qlp_coeff, order) <= 32) - if(subframe_bps <= 16 && qlp_coeff_precision <= 16) - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit(((FLAC__int32 *)signal)+order, residual_samples, qlp_coeff, order, quantization, residual); - else - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients(((FLAC__int32 *)signal)+order, residual_samples, qlp_coeff, order, quantization, residual); - else - encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit(((FLAC__int32 *)signal)+order, residual_samples, qlp_coeff, order, quantization, residual); - - subframe->type = FLAC__SUBFRAME_TYPE_LPC; - - subframe->data.lpc.entropy_coding_method.type = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE; - subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents = partitioned_rice_contents; - subframe->data.lpc.residual = residual; - - residual_bits = - find_best_partition_order_( - encoder->private_, - residual, - abs_residual_partition_sums, - raw_bits_per_partition, - residual_samples, - order, - rice_parameter_limit, - min_partition_order, - max_partition_order, - subframe_bps, - do_escape_coding, - rice_parameter_search_dist, - &subframe->data.lpc.entropy_coding_method - ); - - subframe->data.lpc.order = order; - subframe->data.lpc.qlp_coeff_precision = qlp_coeff_precision; - subframe->data.lpc.quantization_level = quantization; - memcpy(subframe->data.lpc.qlp_coeff, qlp_coeff, sizeof(FLAC__int32)*FLAC__MAX_LPC_ORDER); - if(subframe_bps <= 32) - for(i = 0; i < order; i++) - subframe->data.lpc.warmup[i] = ((FLAC__int32 *)signal)[i]; - else - for(i = 0; i < order; i++) - subframe->data.lpc.warmup[i] = ((FLAC__int64 *)signal)[i]; - - - estimate = FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe->wasted_bits + FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN + FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN + (order * (qlp_coeff_precision + subframe_bps)); - if(residual_bits < UINT32_MAX - estimate) // To make sure estimate doesn't overflow - estimate += residual_bits; - else - estimate = UINT32_MAX; - -#if SPOTCHECK_ESTIMATE - spotcheck_subframe_estimate_(encoder, blocksize, subframe_bps, subframe, estimate); -#endif - - return estimate; -} -#endif - -uint32_t evaluate_verbatim_subframe_( - FLAC__StreamEncoder *encoder, - const void *signal, - uint32_t blocksize, - uint32_t subframe_bps, - FLAC__Subframe *subframe -) -{ - uint32_t estimate; - - subframe->type = FLAC__SUBFRAME_TYPE_VERBATIM; - - if(subframe_bps <= 32){ - subframe->data.verbatim.data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32; - subframe->data.verbatim.data.int32 = signal; - } - else { - subframe->data.verbatim.data_type = FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT64; - subframe->data.verbatim.data.int64 = signal; - } - - estimate = FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe->wasted_bits + (blocksize * subframe_bps); - -#if SPOTCHECK_ESTIMATE - spotcheck_subframe_estimate_(encoder, blocksize, subframe_bps, subframe, estimate); -#else - (void)encoder; -#endif - - return estimate; -} - -uint32_t find_best_partition_order_( - FLAC__StreamEncoderPrivate *private_, - const FLAC__int32 residual[], - FLAC__uint64 abs_residual_partition_sums[], - uint32_t raw_bits_per_partition[], - uint32_t residual_samples, - uint32_t predictor_order, - uint32_t rice_parameter_limit, - uint32_t min_partition_order, - uint32_t max_partition_order, - uint32_t bps, - FLAC__bool do_escape_coding, - uint32_t rice_parameter_search_dist, - FLAC__EntropyCodingMethod *best_ecm -) -{ - uint32_t residual_bits, best_residual_bits = 0; - uint32_t best_parameters_index = 0; - uint32_t best_partition_order = 0; - const uint32_t blocksize = residual_samples + predictor_order; - - max_partition_order = FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(max_partition_order, blocksize, predictor_order); - min_partition_order = flac_min(min_partition_order, max_partition_order); - - private_->local_precompute_partition_info_sums(residual, abs_residual_partition_sums, residual_samples, predictor_order, min_partition_order, max_partition_order, bps); - - if(do_escape_coding) - precompute_partition_info_escapes_(residual, raw_bits_per_partition, residual_samples, predictor_order, min_partition_order, max_partition_order); - - { - int partition_order; - uint32_t sum; - - for(partition_order = (int)max_partition_order, sum = 0; partition_order >= (int)min_partition_order; partition_order--) { - if(! - set_partitioned_rice_( -#ifdef EXACT_RICE_BITS_CALCULATION - residual, -#endif - abs_residual_partition_sums+sum, - raw_bits_per_partition+sum, - residual_samples, - predictor_order, - rice_parameter_limit, - rice_parameter_search_dist, - (uint32_t)partition_order, - do_escape_coding, - &private_->partitioned_rice_contents_extra[!best_parameters_index], - &residual_bits - ) - ) - { - FLAC__ASSERT(best_residual_bits != 0); - break; - } - sum += 1u << partition_order; - if(best_residual_bits == 0 || residual_bits < best_residual_bits) { - best_residual_bits = residual_bits; - best_parameters_index = !best_parameters_index; - best_partition_order = partition_order; - } - } - } - - best_ecm->data.partitioned_rice.order = best_partition_order; - - { - /* - * We are allowed to de-const the pointer based on our special - * knowledge; it is const to the outside world. - */ - FLAC__EntropyCodingMethod_PartitionedRiceContents* prc = (FLAC__EntropyCodingMethod_PartitionedRiceContents*)best_ecm->data.partitioned_rice.contents; - uint32_t partition; - - /* save best parameters and raw_bits */ - memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, (uint32_t)sizeof(uint32_t)*(1<<(best_partition_order))); - if(do_escape_coding) - memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, (uint32_t)sizeof(uint32_t)*(1<<(best_partition_order))); - /* - * Now need to check if the type should be changed to - * FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the - * size of the rice parameters. - */ - for(partition = 0; partition < (1u<parameters[partition] >= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) { - best_ecm->type = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2; - break; - } - } - } - - return best_residual_bits; -} - -void precompute_partition_info_sums_( - const FLAC__int32 residual[], - FLAC__uint64 abs_residual_partition_sums[], - uint32_t residual_samples, - uint32_t predictor_order, - uint32_t min_partition_order, - uint32_t max_partition_order, - uint32_t bps -) -{ - const uint32_t default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; - uint32_t partitions = 1u << max_partition_order; - - FLAC__ASSERT(default_partition_samples > predictor_order); - - /* first do max_partition_order */ - { - const uint32_t threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); - uint32_t partition, residual_sample, end = (uint32_t)(-(int)predictor_order); - /* WATCHOUT: "bps + FLAC__MAX_EXTRA_RESIDUAL_BPS" is the maximum assumed size of the average residual magnitude */ - if(bps + FLAC__MAX_EXTRA_RESIDUAL_BPS < threshold) { - for(partition = residual_sample = 0; partition < partitions; partition++) { - FLAC__uint32 abs_residual_partition_sum = 0; - end += default_partition_samples; - for( ; residual_sample < end; residual_sample++) - abs_residual_partition_sum += abs(residual[residual_sample]); /* abs(INT_MIN) is undefined, but if the residual is INT_MIN we have bigger problems */ - abs_residual_partition_sums[partition] = abs_residual_partition_sum; - } - } - else { /* have to pessimistically use 64 bits for accumulator */ - for(partition = residual_sample = 0; partition < partitions; partition++) { - FLAC__uint64 abs_residual_partition_sum64 = 0; - end += default_partition_samples; - for( ; residual_sample < end; residual_sample++) - abs_residual_partition_sum64 += abs(residual[residual_sample]); /* abs(INT_MIN) is undefined, but if the residual is INT_MIN we have bigger problems */ - abs_residual_partition_sums[partition] = abs_residual_partition_sum64; - } - } - } - - /* now merge partitions for lower orders */ - { - uint32_t from_partition = 0, to_partition = partitions; - int partition_order; - for(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) { - uint32_t i; - partitions >>= 1; - for(i = 0; i < partitions; i++) { - abs_residual_partition_sums[to_partition++] = - abs_residual_partition_sums[from_partition ] + - abs_residual_partition_sums[from_partition+1]; - from_partition += 2; - } - } - } -} - -void precompute_partition_info_escapes_( - const FLAC__int32 residual[], - uint32_t raw_bits_per_partition[], - uint32_t residual_samples, - uint32_t predictor_order, - uint32_t min_partition_order, - uint32_t max_partition_order -) -{ - int partition_order; - uint32_t from_partition, to_partition = 0; - const uint32_t blocksize = residual_samples + predictor_order; - - /* first do max_partition_order */ - for(partition_order = (int)max_partition_order; partition_order >= 0; partition_order--) { - FLAC__int32 r; - FLAC__uint32 rmax; - uint32_t partition, partition_sample, partition_samples, residual_sample; - const uint32_t partitions = 1u << partition_order; - const uint32_t default_partition_samples = blocksize >> partition_order; - - FLAC__ASSERT(default_partition_samples > predictor_order); - - for(partition = residual_sample = 0; partition < partitions; partition++) { - partition_samples = default_partition_samples; - if(partition == 0) - partition_samples -= predictor_order; - rmax = 0; - for(partition_sample = 0; partition_sample < partition_samples; partition_sample++) { - r = residual[residual_sample++]; - /* OPT: maybe faster: rmax |= r ^ (r>>31) */ - if(r < 0) - rmax |= ~r; - else - rmax |= r; - } - /* now we know all residual values are in the range [-rmax-1,rmax] */ - raw_bits_per_partition[partition] = rmax? FLAC__bitmath_ilog2(rmax) + 2 : 1; - } - to_partition = partitions; - break; /*@@@ yuck, should remove the 'for' loop instead */ - } - - /* now merge partitions for lower orders */ - for(from_partition = 0, --partition_order; partition_order >= (int)min_partition_order; partition_order--) { - uint32_t m; - uint32_t i; - const uint32_t partitions = 1u << partition_order; - for(i = 0; i < partitions; i++) { - m = raw_bits_per_partition[from_partition]; - from_partition++; - raw_bits_per_partition[to_partition] = flac_max(m, raw_bits_per_partition[from_partition]); - from_partition++; - to_partition++; - } - } -} - -#ifdef EXACT_RICE_BITS_CALCULATION -static inline uint32_t count_rice_bits_in_partition_( - const uint32_t rice_parameter, - const uint32_t partition_samples, - const FLAC__int32 *residual -) -{ - uint32_t i; - uint64_t partition_bits = - FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN + /* actually could end up being FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN but err on side of 16bps */ - (1+rice_parameter) * partition_samples /* 1 for unary stop bit + rice_parameter for the binary portion */ - ; - for(i = 0; i < partition_samples; i++) - partition_bits += ( (FLAC__uint32)((residual[i]<<1)^(residual[i]>>31)) >> rice_parameter ); - return (uint32_t)(flac_min(partition_bits,UINT32_MAX)); // To make sure the return value doesn't overflow -} -#else -static inline uint32_t count_rice_bits_in_partition_( - const uint32_t rice_parameter, - const uint32_t partition_samples, - const FLAC__uint64 abs_residual_partition_sum -) -{ - return (uint32_t)(flac_min( // To make sure the return value doesn't overflow - FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN + /* actually could end up being FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN but err on side of 16bps */ - (1+rice_parameter) * partition_samples + /* 1 for unary stop bit + rice_parameter for the binary portion */ - ( - rice_parameter? - (abs_residual_partition_sum >> (rice_parameter-1)) /* rice_parameter-1 because the real coder sign-folds instead of using a sign bit */ - : (abs_residual_partition_sum << 1) /* can't shift by negative number, so reverse */ - ) - - (partition_samples >> 1),UINT32_MAX)); - /* -(partition_samples>>1) to subtract out extra contributions to the abs_residual_partition_sum. - * The actual number of bits used is closer to the sum(for all i in the partition) of abs(residual[i])>>(rice_parameter-1) - * By using the abs_residual_partition sum, we also add in bits in the LSBs that would normally be shifted out. - * So the subtraction term tries to guess how many extra bits were contributed. - * If the LSBs are randomly distributed, this should average to 0.5 extra bits per sample. - */ - ; -} -#endif - -FLAC__bool set_partitioned_rice_( -#ifdef EXACT_RICE_BITS_CALCULATION - const FLAC__int32 residual[], -#endif - const FLAC__uint64 abs_residual_partition_sums[], - const uint32_t raw_bits_per_partition[], - const uint32_t residual_samples, - const uint32_t predictor_order, - const uint32_t rice_parameter_limit, - const uint32_t rice_parameter_search_dist, - const uint32_t partition_order, - const FLAC__bool search_for_escapes, - FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, - uint32_t *bits -) -{ - uint32_t rice_parameter, partition_bits; - uint32_t best_partition_bits, best_rice_parameter = 0; - uint32_t bits_ = FLAC__ENTROPY_CODING_METHOD_TYPE_LEN + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; - uint32_t *parameters, *raw_bits; - uint32_t partition, residual_sample; - uint32_t partition_samples, partition_samples_base; - uint32_t partition_samples_fixed_point_divisor, partition_samples_fixed_point_divisor_base; - const uint32_t partitions = 1u << partition_order; - FLAC__uint64 mean; -#ifdef ENABLE_RICE_PARAMETER_SEARCH - uint32_t min_rice_parameter, max_rice_parameter; -#else - (void)rice_parameter_search_dist; -#endif - - FLAC__ASSERT(rice_parameter_limit <= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER); - - parameters = partitioned_rice_contents->parameters; - raw_bits = partitioned_rice_contents->raw_bits; - - partition_samples_base = (residual_samples+predictor_order) >> partition_order; - - /* Integer division is slow. To speed up things, precalculate a fixed point - * divisor, as all partitions except the first are the same size. 18 bits - * are taken because maximum block size is 65535, max partition size for - * partitions other than 0 is 32767 (15 bit), max abs residual is 2^31, - * which leaves 18 bit */ - partition_samples_fixed_point_divisor_base = 0x40000 / partition_samples_base; - - for(partition = residual_sample = 0; partition < partitions; partition++) { - partition_samples = partition_samples_base; - if(partition > 0) { - partition_samples_fixed_point_divisor = partition_samples_fixed_point_divisor_base; - } - else { - if(partition_samples <= predictor_order) - return false; - else - partition_samples -= predictor_order; - partition_samples_fixed_point_divisor = 0x40000 / partition_samples; - } - mean = abs_residual_partition_sums[partition]; - /* 'mean' is not a good name for the variable, it is - * actually the sum of magnitudes of all residual values - * in the partition, so the actual mean is - * mean/partition_samples - */ - if(mean < 2 || (((mean - 1)*partition_samples_fixed_point_divisor)>>18) == 0) - rice_parameter = 0; - else - rice_parameter = FLAC__bitmath_ilog2_wide(((mean - 1)*partition_samples_fixed_point_divisor)>>18) + 1; - - if(rice_parameter >= rice_parameter_limit) { -#ifndef NDEBUG - fprintf(stderr, "clipping rice_parameter (%u -> %u) @6\n", rice_parameter, rice_parameter_limit - 1); -#endif - rice_parameter = rice_parameter_limit - 1; - } - - best_partition_bits = UINT32_MAX; -#ifdef ENABLE_RICE_PARAMETER_SEARCH - if(rice_parameter_search_dist) { - if(rice_parameter < rice_parameter_search_dist) - min_rice_parameter = 0; - else - min_rice_parameter = rice_parameter - rice_parameter_search_dist; - max_rice_parameter = rice_parameter + rice_parameter_search_dist; - if(max_rice_parameter >= rice_parameter_limit) { -#ifndef NDEBUG - fprintf(stderr, "clipping rice_parameter (%u -> %u) @7\n", max_rice_parameter, rice_parameter_limit - 1); -#endif - max_rice_parameter = rice_parameter_limit - 1; - } - } - else - min_rice_parameter = max_rice_parameter = rice_parameter; - - for(rice_parameter = min_rice_parameter; rice_parameter <= max_rice_parameter; rice_parameter++) { -#endif -#ifdef EXACT_RICE_BITS_CALCULATION - partition_bits = count_rice_bits_in_partition_(rice_parameter, partition_samples, residual+residual_sample); -#else - partition_bits = count_rice_bits_in_partition_(rice_parameter, partition_samples, abs_residual_partition_sums[partition]); -#endif - if(partition_bits < best_partition_bits) { - best_rice_parameter = rice_parameter; - best_partition_bits = partition_bits; - } -#ifdef ENABLE_RICE_PARAMETER_SEARCH - } -#endif - if(search_for_escapes) { - partition_bits = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN + raw_bits_per_partition[partition] * partition_samples; - if(partition_bits <= best_partition_bits && raw_bits_per_partition[partition] < 32) { - raw_bits[partition] = raw_bits_per_partition[partition]; - best_rice_parameter = 0; /* will be converted to appropriate escape parameter later */ - best_partition_bits = partition_bits; - } - else - raw_bits[partition] = 0; - } - parameters[partition] = best_rice_parameter; - if(best_partition_bits < UINT32_MAX - bits_) // To make sure _bits doesn't overflow - bits_ += best_partition_bits; - else - bits_ = UINT32_MAX; - residual_sample += partition_samples; - } - - *bits = bits_; - return true; -} - -uint32_t get_wasted_bits_(FLAC__int32 signal[], uint32_t samples) -{ - uint32_t i, shift; - FLAC__int32 x = 0; - - for(i = 0; i < samples && !(x&1); i++) - x |= signal[i]; - - if(x == 0) { - shift = 0; - } - else { - for(shift = 0; !(x&1); shift++) - x >>= 1; - } - - if(shift > 0) { - for(i = 0; i < samples; i++) - signal[i] >>= shift; - } - - return shift; -} - -uint32_t get_wasted_bits_wide_(FLAC__int64 signal_wide[], FLAC__int32 signal[], uint32_t samples) -{ - uint32_t i, shift; - FLAC__int64 x = 0; - - for(i = 0; i < samples && !(x&1); i++) - x |= signal_wide[i]; - - if(x == 0) { - shift = 1; - } - else { - for(shift = 0; !(x&1); shift++) - x >>= 1; - } - - if(shift > 0) { - for(i = 0; i < samples; i++) - signal[i] = (FLAC__int32)(signal_wide[i] >> shift); - } - - return shift; -} - - -void append_to_verify_fifo_(verify_input_fifo *fifo, const FLAC__int32 * const input[], uint32_t input_offset, uint32_t channels, uint32_t wide_samples) -{ - uint32_t channel; - - for(channel = 0; channel < channels; channel++) - memcpy(&fifo->data[channel][fifo->tail], &input[channel][input_offset], sizeof(FLAC__int32) * wide_samples); - - fifo->tail += wide_samples; - - FLAC__ASSERT(fifo->tail <= fifo->size); -} - -void append_to_verify_fifo_interleaved_(verify_input_fifo *fifo, const FLAC__int32 input[], uint32_t input_offset, uint32_t channels, uint32_t wide_samples) -{ - uint32_t channel; - uint32_t sample, wide_sample; - uint32_t tail = fifo->tail; - - sample = input_offset * channels; - for(wide_sample = 0; wide_sample < wide_samples; wide_sample++) { - for(channel = 0; channel < channels; channel++) - fifo->data[channel][tail] = input[sample++]; - tail++; - } - fifo->tail = tail; - - FLAC__ASSERT(fifo->tail <= fifo->size); -} - -FLAC__StreamDecoderReadStatus verify_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - FLAC__StreamEncoder *encoder = (FLAC__StreamEncoder*)client_data; - const size_t encoded_bytes = encoder->private_->verify.output.bytes; - (void)decoder; - - if(encoder->private_->verify.needs_magic_hack) { - FLAC__ASSERT(*bytes >= FLAC__STREAM_SYNC_LENGTH); - *bytes = FLAC__STREAM_SYNC_LENGTH; - memcpy(buffer, FLAC__STREAM_SYNC_STRING, *bytes); - encoder->private_->verify.needs_magic_hack = false; - } - else { - if(encoded_bytes == 0) { - /* - * If we get here, a FIFO underflow has occurred, - * which means there is a bug somewhere. - */ - FLAC__ASSERT(0); - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - } - else if(encoded_bytes < *bytes) - *bytes = encoded_bytes; - memcpy(buffer, encoder->private_->verify.output.data, *bytes); - encoder->private_->verify.output.data += *bytes; - encoder->private_->verify.output.bytes -= *bytes; - } - - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; -} - -FLAC__StreamDecoderWriteStatus verify_write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - FLAC__StreamEncoder *encoder = (FLAC__StreamEncoder *)client_data; - uint32_t channel; - const uint32_t channels = frame->header.channels; - const uint32_t blocksize = frame->header.blocksize; - const uint32_t bytes_per_block = sizeof(FLAC__int32) * blocksize; - - (void)decoder; - - if(encoder->protected_->state == FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) { - /* This is set when verify_error_callback_ was called */ - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - for(channel = 0; channel < channels; channel++) { - if(0 != memcmp(buffer[channel], encoder->private_->verify.input_fifo.data[channel], bytes_per_block)) { - uint32_t i, sample = 0; - FLAC__int32 expect = 0, got = 0; - - for(i = 0; i < blocksize; i++) { - if(buffer[channel][i] != encoder->private_->verify.input_fifo.data[channel][i]) { - sample = i; - expect = (FLAC__int32)encoder->private_->verify.input_fifo.data[channel][i]; - got = (FLAC__int32)buffer[channel][i]; - break; - } - } - FLAC__ASSERT(i < blocksize); - FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); - encoder->private_->verify.error_stats.absolute_sample = frame->header.number.sample_number + sample; - encoder->private_->verify.error_stats.frame_number = (uint32_t)(frame->header.number.sample_number / blocksize); - encoder->private_->verify.error_stats.channel = channel; - encoder->private_->verify.error_stats.sample = sample; - encoder->private_->verify.error_stats.expected = expect; - encoder->private_->verify.error_stats.got = got; - encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA; - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - /* dequeue the frame from the fifo */ - encoder->private_->verify.input_fifo.tail -= blocksize; - FLAC__ASSERT(encoder->private_->verify.input_fifo.tail <= OVERREAD_); - for(channel = 0; channel < channels; channel++) - memmove(&encoder->private_->verify.input_fifo.data[channel][0], &encoder->private_->verify.input_fifo.data[channel][blocksize], encoder->private_->verify.input_fifo.tail * sizeof(encoder->private_->verify.input_fifo.data[0][0])); - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void verify_metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - (void)decoder, (void)metadata, (void)client_data; -} - -void verify_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - FLAC__StreamEncoder *encoder = (FLAC__StreamEncoder*)client_data; - (void)decoder, (void)status; - encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR; -} - -FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - (void)client_data; - - *bytes = fread(buffer, 1, *bytes, encoder->private_->file); - if (*bytes == 0) { - if (feof(encoder->private_->file)) - return FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM; - else if (ferror(encoder->private_->file)) - return FLAC__STREAM_ENCODER_READ_STATUS_ABORT; - } - return FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE; -} - -FLAC__StreamEncoderSeekStatus file_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) -{ - (void)client_data; - - if(fseeko(encoder->private_->file, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) - return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR; - else - return FLAC__STREAM_ENCODER_SEEK_STATUS_OK; -} - -FLAC__StreamEncoderTellStatus file_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) -{ - FLAC__off_t offset; - - (void)client_data; - - offset = ftello(encoder->private_->file); - - if(offset < 0) { - return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR; - } - else { - *absolute_byte_offset = (FLAC__uint64)offset; - return FLAC__STREAM_ENCODER_TELL_STATUS_OK; - } -} - -#ifdef FLAC__VALGRIND_TESTING -static size_t local__fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - size_t ret = fwrite(ptr, size, nmemb, stream); - if(!ferror(stream)) - fflush(stream); - return ret; -} -#else -#define local__fwrite fwrite -#endif - -FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) -{ - (void)client_data, (void)current_frame; - - if(local__fwrite(buffer, sizeof(FLAC__byte), bytes, encoder->private_->file) == bytes) { - FLAC__bool call_it = 0 != encoder->private_->progress_callback && ( -#if FLAC__HAS_OGG - /* We would like to be able to use 'samples > 0' in the - * clause here but currently because of the nature of our - * Ogg writing implementation, 'samples' is always 0 (see - * ogg_encoder_aspect.c). The downside is extra progress - * callbacks. - */ - encoder->private_->is_ogg? true : -#endif - samples > 0 - ); - if(call_it) { - /* NOTE: We have to add +bytes, +samples, and +1 to the stats - * because at this point in the callback chain, the stats - * have not been updated. Only after we return and control - * gets back to write_frame_() are the stats updated - */ - encoder->private_->progress_callback(encoder, encoder->private_->bytes_written+bytes, encoder->private_->samples_written+samples, encoder->private_->frames_written+(samples?1:0), encoder->private_->total_frames_estimate, encoder->private_->client_data); - } - return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; - } - else - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; -} - -/* - * This will forcibly set stdout to binary mode (for OSes that require it) - */ -FILE *get_binary_stdout_(void) -{ - /* if something breaks here it is probably due to the presence or - * absence of an underscore before the identifiers 'setmode', - * 'fileno', and/or 'O_BINARY'; check your system header files. - */ -#if defined _MSC_VER || defined __MINGW32__ - _setmode(_fileno(stdout), _O_BINARY); -#elif defined __EMX__ - setmode(fileno(stdout), O_BINARY); -#endif - - return stdout; -} diff --git a/Engine/lib/flac/src/libFLAC/stream_encoder_framing.c b/Engine/lib/flac/src/libFLAC/stream_encoder_framing.c deleted file mode 100644 index 0e07a3176..000000000 --- a/Engine/lib/flac/src/libFLAC/stream_encoder_framing.c +++ /dev/null @@ -1,594 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include /* for strlen() */ -#include "private/stream_encoder_framing.h" -#include "private/crc.h" -#include "FLAC/assert.h" -#include "share/compat.h" - -static FLAC__bool add_entropy_coding_method_(FLAC__BitWriter *bw, const FLAC__EntropyCodingMethod *method); -static FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const uint32_t residual_samples, const uint32_t predictor_order, const uint32_t rice_parameters[], const uint32_t raw_bits[], const uint32_t partition_order, const FLAC__bool is_extended); - -FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw, FLAC__bool update_vendor_string) -{ - uint32_t i, j, metadata_length; - const uint32_t vendor_string_length = (uint32_t)strlen(FLAC__VENDOR_STRING); - const uint32_t start_bits = FLAC__bitwriter_get_input_bits_unconsumed(bw); - - FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(bw)); - - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->is_last, FLAC__STREAM_METADATA_IS_LAST_LEN)) - return false; - - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->type, FLAC__STREAM_METADATA_TYPE_LEN)) - return false; - - /* - * First, for VORBIS_COMMENTs, adjust the length to reflect our vendor string - */ - metadata_length = metadata->length; - if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT && update_vendor_string) { - FLAC__ASSERT(metadata->data.vorbis_comment.vendor_string.length == 0 || 0 != metadata->data.vorbis_comment.vendor_string.entry); - metadata_length -= metadata->data.vorbis_comment.vendor_string.length; - metadata_length += vendor_string_length; - } - FLAC__ASSERT(metadata_length < (1u << FLAC__STREAM_METADATA_LENGTH_LEN)); - /* double protection */ - if(metadata_length >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata_length, FLAC__STREAM_METADATA_LENGTH_LEN)) - return false; - - switch(metadata->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - FLAC__ASSERT(metadata->data.stream_info.min_blocksize < (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN)); - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.min_blocksize, FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN)) - return false; - FLAC__ASSERT(metadata->data.stream_info.max_blocksize < (1u << FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN)); - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.max_blocksize, FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN)) - return false; - FLAC__ASSERT(metadata->data.stream_info.min_framesize < (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN)); - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.min_framesize, FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN)) - return false; - FLAC__ASSERT(metadata->data.stream_info.max_framesize < (1u << FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN)); - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.max_framesize, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN)) - return false; - FLAC__ASSERT(FLAC__format_sample_rate_is_valid(metadata->data.stream_info.sample_rate)); - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.sample_rate, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN)) - return false; - FLAC__ASSERT(metadata->data.stream_info.channels > 0); - FLAC__ASSERT(metadata->data.stream_info.channels <= (1u << FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN)); - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.channels-1, FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN)) - return false; - FLAC__ASSERT(metadata->data.stream_info.bits_per_sample > 0); - FLAC__ASSERT(metadata->data.stream_info.bits_per_sample <= (1u << FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN)); - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.bits_per_sample-1, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN)) - return false; - if(metadata->data.stream_info.total_samples >= (FLAC__U64L(1) << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)){ - if(!FLAC__bitwriter_write_raw_uint64(bw, 0, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)) - return false; - }else{ - if(!FLAC__bitwriter_write_raw_uint64(bw, metadata->data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN)) - return false; - } - if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.stream_info.md5sum, 16)) - return false; - break; - case FLAC__METADATA_TYPE_PADDING: - if(!FLAC__bitwriter_write_zeroes(bw, metadata->length * 8)) - return false; - break; - case FLAC__METADATA_TYPE_APPLICATION: - if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8)) - return false; - if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.application.data, metadata->length - (FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8))) - return false; - break; - case FLAC__METADATA_TYPE_SEEKTABLE: - for(i = 0; i < metadata->data.seek_table.num_points; i++) { - if(!FLAC__bitwriter_write_raw_uint64(bw, metadata->data.seek_table.points[i].sample_number, FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint64(bw, metadata->data.seek_table.points[i].stream_offset, FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.seek_table.points[i].frame_samples, FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN)) - return false; - } - break; - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - if(update_vendor_string) { - if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, vendor_string_length)) - return false; - if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)FLAC__VENDOR_STRING, vendor_string_length)) - return false; - } - else { - if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, metadata->data.vorbis_comment.vendor_string.length)) - return false; - if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.vorbis_comment.vendor_string.entry, metadata->data.vorbis_comment.vendor_string.length)) - return false; - } - if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, metadata->data.vorbis_comment.num_comments)) - return false; - for(i = 0; i < metadata->data.vorbis_comment.num_comments; i++) { - if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, metadata->data.vorbis_comment.comments[i].length)) - return false; - if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.vorbis_comment.comments[i].entry, metadata->data.vorbis_comment.comments[i].length)) - return false; - } - break; - case FLAC__METADATA_TYPE_CUESHEET: - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0); - if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)metadata->data.cue_sheet.media_catalog_number, FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN/8)) - return false; - if(!FLAC__bitwriter_write_raw_uint64(bw, metadata->data.cue_sheet.lead_in, FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.cue_sheet.is_cd? 1 : 0, FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN)) - return false; - if(!FLAC__bitwriter_write_zeroes(bw, FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.cue_sheet.num_tracks, FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN)) - return false; - for(i = 0; i < metadata->data.cue_sheet.num_tracks; i++) { - const FLAC__StreamMetadata_CueSheet_Track *track = metadata->data.cue_sheet.tracks + i; - - if(!FLAC__bitwriter_write_raw_uint64(bw, track->offset, FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, track->number, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN)) - return false; - FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0); - if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)track->isrc, FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN/8)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, track->type, FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, track->pre_emphasis, FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN)) - return false; - if(!FLAC__bitwriter_write_zeroes(bw, FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, track->num_indices, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN)) - return false; - for(j = 0; j < track->num_indices; j++) { - const FLAC__StreamMetadata_CueSheet_Index *indx = track->indices + j; - - if(!FLAC__bitwriter_write_raw_uint64(bw, indx->offset, FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, indx->number, FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN)) - return false; - if(!FLAC__bitwriter_write_zeroes(bw, FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN)) - return false; - } - } - break; - case FLAC__METADATA_TYPE_PICTURE: - { - size_t len; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.type, FLAC__STREAM_METADATA_PICTURE_TYPE_LEN)) - return false; - len = strlen(metadata->data.picture.mime_type); - if(!FLAC__bitwriter_write_raw_uint32(bw, len, FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN)) - return false; - if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)metadata->data.picture.mime_type, len)) - return false; - len = strlen((const char *)metadata->data.picture.description); - if(!FLAC__bitwriter_write_raw_uint32(bw, len, FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN)) - return false; - if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.picture.description, len)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.width, FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.height, FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.depth, FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.colors, FLAC__STREAM_METADATA_PICTURE_COLORS_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.data_length, FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN)) - return false; - if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.picture.data, metadata->data.picture.data_length)) - return false; - } - break; - default: - if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.unknown.data, metadata->length)) - return false; - break; - } - - /* Now check whether metadata block length was correct */ - { - uint32_t length_in_bits = FLAC__bitwriter_get_input_bits_unconsumed(bw); - if(length_in_bits < start_bits) - return false; - length_in_bits -= start_bits; - if(length_in_bits % 8 != 0 || length_in_bits != (metadata_length*8+32)) - return false; - } - - FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(bw)); - return true; -} - -FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw) -{ - uint32_t u, blocksize_hint, sample_rate_hint; - FLAC__byte crc; - - FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(bw)); - - if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__FRAME_HEADER_SYNC, FLAC__FRAME_HEADER_SYNC_LEN)) - return false; - - if(!FLAC__bitwriter_write_raw_uint32(bw, 0, FLAC__FRAME_HEADER_RESERVED_LEN)) - return false; - - if(!FLAC__bitwriter_write_raw_uint32(bw, (header->number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER)? 0 : 1, FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN)) - return false; - - FLAC__ASSERT(header->blocksize > 0 && header->blocksize <= FLAC__MAX_BLOCK_SIZE); - /* when this assertion holds true, any legal blocksize can be expressed in the frame header */ - FLAC__ASSERT(FLAC__MAX_BLOCK_SIZE <= 65535u); - blocksize_hint = 0; - switch(header->blocksize) { - case 192: u = 1; break; - case 576: u = 2; break; - case 1152: u = 3; break; - case 2304: u = 4; break; - case 4608: u = 5; break; - case 256: u = 8; break; - case 512: u = 9; break; - case 1024: u = 10; break; - case 2048: u = 11; break; - case 4096: u = 12; break; - case 8192: u = 13; break; - case 16384: u = 14; break; - case 32768: u = 15; break; - default: - if(header->blocksize <= 0x100) - blocksize_hint = u = 6; - else - blocksize_hint = u = 7; - break; - } - if(!FLAC__bitwriter_write_raw_uint32(bw, u, FLAC__FRAME_HEADER_BLOCK_SIZE_LEN)) - return false; - - FLAC__ASSERT(FLAC__format_sample_rate_is_valid(header->sample_rate)); - sample_rate_hint = 0; - switch(header->sample_rate) { - case 88200: u = 1; break; - case 176400: u = 2; break; - case 192000: u = 3; break; - case 8000: u = 4; break; - case 16000: u = 5; break; - case 22050: u = 6; break; - case 24000: u = 7; break; - case 32000: u = 8; break; - case 44100: u = 9; break; - case 48000: u = 10; break; - case 96000: u = 11; break; - default: - if(header->sample_rate <= 255000 && header->sample_rate % 1000 == 0) - sample_rate_hint = u = 12; - else if(header->sample_rate <= 655350 && header->sample_rate % 10 == 0) - sample_rate_hint = u = 14; - else if(header->sample_rate <= 0xffff) - sample_rate_hint = u = 13; - else - u = 0; - break; - } - if(!FLAC__bitwriter_write_raw_uint32(bw, u, FLAC__FRAME_HEADER_SAMPLE_RATE_LEN)) - return false; - - FLAC__ASSERT(header->channels > 0 && header->channels <= (1u << FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN) && header->channels <= FLAC__MAX_CHANNELS); - switch(header->channel_assignment) { - case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: - u = header->channels - 1; - break; - case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: - FLAC__ASSERT(header->channels == 2); - u = 8; - break; - case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: - FLAC__ASSERT(header->channels == 2); - u = 9; - break; - case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: - FLAC__ASSERT(header->channels == 2); - u = 10; - break; - default: - FLAC__ASSERT(0); - } - if(!FLAC__bitwriter_write_raw_uint32(bw, u, FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN)) - return false; - - FLAC__ASSERT(header->bits_per_sample > 0 && header->bits_per_sample <= (1u << FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN)); - switch(header->bits_per_sample) { - case 8 : u = 1; break; - case 12: u = 2; break; - case 16: u = 4; break; - case 20: u = 5; break; - case 24: u = 6; break; - case 32: u = 7; break; - default: u = 0; break; - } - if(!FLAC__bitwriter_write_raw_uint32(bw, u, FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN)) - return false; - - if(!FLAC__bitwriter_write_raw_uint32(bw, 0, FLAC__FRAME_HEADER_ZERO_PAD_LEN)) - return false; - - if(header->number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER) { - if(!FLAC__bitwriter_write_utf8_uint32(bw, header->number.frame_number)) - return false; - } - else { - if(!FLAC__bitwriter_write_utf8_uint64(bw, header->number.sample_number)) - return false; - } - - if(blocksize_hint) - if(!FLAC__bitwriter_write_raw_uint32(bw, header->blocksize-1, (blocksize_hint==6)? 8:16)) - return false; - - switch(sample_rate_hint) { - case 12: - if(!FLAC__bitwriter_write_raw_uint32(bw, header->sample_rate / 1000, 8)) - return false; - break; - case 13: - if(!FLAC__bitwriter_write_raw_uint32(bw, header->sample_rate, 16)) - return false; - break; - case 14: - if(!FLAC__bitwriter_write_raw_uint32(bw, header->sample_rate / 10, 16)) - return false; - break; - } - - /* write the CRC */ - if(!FLAC__bitwriter_get_write_crc8(bw, &crc)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, crc, FLAC__FRAME_HEADER_CRC_LEN)) - return false; - - return true; -} - -FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw) -{ - FLAC__bool ok; - - ok = - FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN) && - (wasted_bits? FLAC__bitwriter_write_unary_unsigned(bw, wasted_bits-1) : true) && - FLAC__bitwriter_write_raw_int64(bw, subframe->value, subframe_bps) - ; - - return ok; -} - -FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw) -{ - uint32_t i; - - if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK | (subframe->order<<1) | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN)) - return false; - if(wasted_bits) - if(!FLAC__bitwriter_write_unary_unsigned(bw, wasted_bits-1)) - return false; - - for(i = 0; i < subframe->order; i++) - if(!FLAC__bitwriter_write_raw_int64(bw, subframe->warmup[i], subframe_bps)) - return false; - - if(!add_entropy_coding_method_(bw, &subframe->entropy_coding_method)) - return false; - switch(subframe->entropy_coding_method.type) { - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: - if(!add_residual_partitioned_rice_( - bw, - subframe->residual, - residual_samples, - subframe->order, - subframe->entropy_coding_method.data.partitioned_rice.contents->parameters, - subframe->entropy_coding_method.data.partitioned_rice.contents->raw_bits, - subframe->entropy_coding_method.data.partitioned_rice.order, - /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 - )) - return false; - break; - default: - FLAC__ASSERT(0); - } - - return true; -} - -FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw) -{ - uint32_t i; - - if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK | ((subframe->order-1)<<1) | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN)) - return false; - if(wasted_bits) - if(!FLAC__bitwriter_write_unary_unsigned(bw, wasted_bits-1)) - return false; - - for(i = 0; i < subframe->order; i++) - if(!FLAC__bitwriter_write_raw_int64(bw, subframe->warmup[i], subframe_bps)) - return false; - - if(!FLAC__bitwriter_write_raw_uint32(bw, subframe->qlp_coeff_precision-1, FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN)) - return false; - if(!FLAC__bitwriter_write_raw_int32(bw, subframe->quantization_level, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN)) - return false; - for(i = 0; i < subframe->order; i++) - if(!FLAC__bitwriter_write_raw_int32(bw, subframe->qlp_coeff[i], subframe->qlp_coeff_precision)) - return false; - - if(!add_entropy_coding_method_(bw, &subframe->entropy_coding_method)) - return false; - switch(subframe->entropy_coding_method.type) { - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: - if(!add_residual_partitioned_rice_( - bw, - subframe->residual, - residual_samples, - subframe->order, - subframe->entropy_coding_method.data.partitioned_rice.contents->parameters, - subframe->entropy_coding_method.data.partitioned_rice.contents->raw_bits, - subframe->entropy_coding_method.data.partitioned_rice.order, - /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 - )) - return false; - break; - default: - FLAC__ASSERT(0); - } - - return true; -} - -FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, uint32_t samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw) -{ - uint32_t i; - - if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN)) - return false; - if(wasted_bits) - if(!FLAC__bitwriter_write_unary_unsigned(bw, wasted_bits-1)) - return false; - - if(subframe->data_type == FLAC__VERBATIM_SUBFRAME_DATA_TYPE_INT32) { - const FLAC__int32 *signal = subframe->data.int32; - - FLAC__ASSERT(subframe_bps < 33); - - for(i = 0; i < samples; i++) - if(!FLAC__bitwriter_write_raw_int32(bw, signal[i], subframe_bps)) - return false; - } - else { - const FLAC__int64 *signal = subframe->data.int64; - - FLAC__ASSERT(subframe_bps == 33); - - for(i = 0; i < samples; i++) - if(!FLAC__bitwriter_write_raw_int64(bw, (FLAC__int64)signal[i], subframe_bps)) - return false; - } - - return true; -} - -FLAC__bool add_entropy_coding_method_(FLAC__BitWriter *bw, const FLAC__EntropyCodingMethod *method) -{ - if(!FLAC__bitwriter_write_raw_uint32(bw, method->type, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN)) - return false; - switch(method->type) { - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE: - case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2: - if(!FLAC__bitwriter_write_raw_uint32(bw, method->data.partitioned_rice.order, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN)) - return false; - break; - default: - FLAC__ASSERT(0); - } - return true; -} - -FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const uint32_t residual_samples, const uint32_t predictor_order, const uint32_t rice_parameters[], const uint32_t raw_bits[], const uint32_t partition_order, const FLAC__bool is_extended) -{ - const uint32_t plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; - const uint32_t pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; - - if(partition_order == 0) { - uint32_t i; - - if(raw_bits[0] == 0) { - if(!FLAC__bitwriter_write_raw_uint32(bw, rice_parameters[0], plen)) - return false; - if(!FLAC__bitwriter_write_rice_signed_block(bw, residual, residual_samples, rice_parameters[0])) - return false; - } - else { - FLAC__ASSERT(rice_parameters[0] == 0); - if(!FLAC__bitwriter_write_raw_uint32(bw, pesc, plen)) - return false; - if(!FLAC__bitwriter_write_raw_uint32(bw, raw_bits[0], FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN)) - return false; - for(i = 0; i < residual_samples; i++) { - if(!FLAC__bitwriter_write_raw_int32(bw, residual[i], raw_bits[0])) - return false; - } - } - return true; - } - else { - uint32_t i, j, k = 0, k_last = 0; - uint32_t partition_samples; - const uint32_t default_partition_samples = (residual_samples+predictor_order) >> partition_order; - for(i = 0; i < (1u< -#endif - -#include "private/cpu.h" - -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#include "private/stream_encoder.h" -#include "private/bitmath.h" -#ifdef FLAC__AVX2_SUPPORTED - -#include /* for abs() */ -#include /* AVX2 */ -#include "FLAC/assert.h" - -FLAC__SSE_TARGET("avx2") -void FLAC__precompute_partition_info_sums_intrin_avx2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps) -{ - const uint32_t default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; - uint32_t partitions = 1u << max_partition_order; - - FLAC__ASSERT(default_partition_samples > predictor_order); - - /* first do max_partition_order */ - { - const uint32_t threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); - uint32_t partition, residual_sample, end = (uint32_t)(-(int32_t)predictor_order); - - if(bps + FLAC__MAX_EXTRA_RESIDUAL_BPS < threshold) { - for(partition = residual_sample = 0; partition < partitions; partition++) { - __m256i sum256 = _mm256_setzero_si256(); - __m128i sum128; - end += default_partition_samples; - - for( ; (int)residual_sample < (int)end-7; residual_sample+=8) { - __m256i res256 = _mm256_abs_epi32(_mm256_loadu_si256((const __m256i*)(const void*)(residual+residual_sample))); - sum256 = _mm256_add_epi32(sum256, res256); - } - - sum128 = _mm_add_epi32(_mm256_extracti128_si256(sum256, 1), _mm256_castsi256_si128(sum256)); - - for( ; (int)residual_sample < (int)end-3; residual_sample+=4) { - __m128i res128 = _mm_abs_epi32(_mm_loadu_si128((const __m128i*)(const void*)(residual+residual_sample))); - sum128 = _mm_add_epi32(sum128, res128); - } - - for( ; residual_sample < end; residual_sample++) { - __m128i res128 = _mm_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); - sum128 = _mm_add_epi32(sum128, res128); - } - - sum128 = _mm_add_epi32(sum128, _mm_shuffle_epi32(sum128, _MM_SHUFFLE(1,0,3,2))); - sum128 = _mm_add_epi32(sum128, _mm_shufflelo_epi16(sum128, _MM_SHUFFLE(1,0,3,2))); - abs_residual_partition_sums[partition] = (FLAC__uint32)_mm_cvtsi128_si32(sum128); -/* workaround for MSVC bugs (at least versions 2015 and 2017 are affected) */ -#if (defined _MSC_VER) && (defined FLAC__CPU_X86_64) - abs_residual_partition_sums[partition] &= 0xFFFFFFFF; /**/ -#endif - } - } - else { /* have to pessimistically use 64 bits for accumulator */ - for(partition = residual_sample = 0; partition < partitions; partition++) { - __m256i sum256 = _mm256_setzero_si256(); - __m128i sum128; - end += default_partition_samples; - - for( ; (int)residual_sample < (int)end-3; residual_sample+=4) { - __m128i res128 = _mm_abs_epi32(_mm_loadu_si128((const __m128i*)(const void*)(residual+residual_sample))); - __m256i res256 = _mm256_cvtepu32_epi64(res128); - sum256 = _mm256_add_epi64(sum256, res256); - } - - sum128 = _mm_add_epi64(_mm256_extracti128_si256(sum256, 1), _mm256_castsi256_si128(sum256)); - - for( ; (int)residual_sample < (int)end-1; residual_sample+=2) { - __m128i res128 = _mm_abs_epi32(_mm_loadl_epi64((const __m128i*)(const void*)(residual+residual_sample))); - res128 = _mm_cvtepu32_epi64(res128); - sum128 = _mm_add_epi64(sum128, res128); - } - - for( ; residual_sample < end; residual_sample++) { - __m128i res128 = _mm_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); - sum128 = _mm_add_epi64(sum128, res128); - } - - sum128 = _mm_add_epi64(sum128, _mm_srli_si128(sum128, 8)); - _mm_storel_epi64((__m128i*)(void*)(abs_residual_partition_sums+partition), sum128); - } - } - } - - /* now merge partitions for lower orders */ - { - uint32_t from_partition = 0, to_partition = partitions; - int partition_order; - for(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) { - uint32_t i; - partitions >>= 1; - for(i = 0; i < partitions; i++) { - abs_residual_partition_sums[to_partition++] = - abs_residual_partition_sums[from_partition ] + - abs_residual_partition_sums[from_partition+1]; - from_partition += 2; - } - } - } - _mm256_zeroupper(); -} - -#endif /* FLAC__AVX2_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ diff --git a/Engine/lib/flac/src/libFLAC/stream_encoder_intrin_sse2.c b/Engine/lib/flac/src/libFLAC/stream_encoder_intrin_sse2.c deleted file mode 100644 index dd25fa65b..000000000 --- a/Engine/lib/flac/src/libFLAC/stream_encoder_intrin_sse2.c +++ /dev/null @@ -1,159 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#include "private/stream_encoder.h" -#include "private/bitmath.h" -#ifdef FLAC__SSE2_SUPPORTED - -#include /* for abs() */ -#include /* SSE2 */ -#include "FLAC/assert.h" -#include "share/compat.h" - -FLAC__SSE_TARGET("sse2") -static inline __m128i local_abs_epi32(__m128i val) -{ - __m128i mask = _mm_srai_epi32(val, 31); - val = _mm_xor_si128(val, mask); - val = _mm_sub_epi32(val, mask); - return val; -} - - -FLAC__SSE_TARGET("sse2") -void FLAC__precompute_partition_info_sums_intrin_sse2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps) -{ - const uint32_t default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; - uint32_t partitions = 1u << max_partition_order; - - FLAC__ASSERT(default_partition_samples > predictor_order); - - /* first do max_partition_order */ - { - const uint32_t threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); - uint32_t partition, residual_sample, end = (uint32_t)(-(int32_t)predictor_order); - - if(bps + FLAC__MAX_EXTRA_RESIDUAL_BPS < threshold) { - for(partition = residual_sample = 0; partition < partitions; partition++) { - __m128i mm_sum = _mm_setzero_si128(); - uint32_t e1, e3; - end += default_partition_samples; - - e1 = (residual_sample + 3) & ~3; e3 = end & ~3; - if(e1 > end) - e1 = end; /* try flac -l 1 -b 16 and you'll be here */ - - /* assumption: residual[] is properly aligned so (residual + e1) is properly aligned too and _mm_loadu_si128() is fast */ - for( ; residual_sample < e1; residual_sample++) { - __m128i mm_res = local_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); - mm_sum = _mm_add_epi32(mm_sum, mm_res); - } - - for( ; residual_sample < e3; residual_sample+=4) { - __m128i mm_res = local_abs_epi32(_mm_loadu_si128((const __m128i*)(const void*)(residual+residual_sample))); - mm_sum = _mm_add_epi32(mm_sum, mm_res); - } - - for( ; residual_sample < end; residual_sample++) { - __m128i mm_res = local_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); - mm_sum = _mm_add_epi32(mm_sum, mm_res); - } - - mm_sum = _mm_add_epi32(mm_sum, _mm_shuffle_epi32(mm_sum, _MM_SHUFFLE(1,0,3,2))); - mm_sum = _mm_add_epi32(mm_sum, _mm_shufflelo_epi16(mm_sum, _MM_SHUFFLE(1,0,3,2))); - abs_residual_partition_sums[partition] = (FLAC__uint32)_mm_cvtsi128_si32(mm_sum); -/* workaround for MSVC bugs (at least versions 2015 and 2017 are affected) */ -#if (defined _MSC_VER) && (defined FLAC__CPU_X86_64) - abs_residual_partition_sums[partition] &= 0xFFFFFFFF; -#endif - } - } - else { /* have to pessimistically use 64 bits for accumulator */ - for(partition = residual_sample = 0; partition < partitions; partition++) { - __m128i mm_sum = _mm_setzero_si128(); - uint32_t e1, e3; - end += default_partition_samples; - - e1 = (residual_sample + 1) & ~1; e3 = end & ~1; - FLAC__ASSERT(e1 <= end); - - for( ; residual_sample < e1; residual_sample++) { - __m128i mm_res = local_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); /* 0 0 0 |r0| == 00 |r0_64| */ - mm_sum = _mm_add_epi64(mm_sum, mm_res); - } - - for( ; residual_sample < e3; residual_sample+=2) { - __m128i mm_res = local_abs_epi32(_mm_loadl_epi64((const __m128i*)(const void*)(residual+residual_sample))); /* 0 0 |r1| |r0| */ - mm_res = _mm_shuffle_epi32(mm_res, _MM_SHUFFLE(3,1,2,0)); /* 0 |r1| 0 |r0| == |r1_64| |r0_64| */ - mm_sum = _mm_add_epi64(mm_sum, mm_res); - } - - for( ; residual_sample < end; residual_sample++) { - __m128i mm_res = local_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); - mm_sum = _mm_add_epi64(mm_sum, mm_res); - } - - mm_sum = _mm_add_epi64(mm_sum, _mm_srli_si128(mm_sum, 8)); - _mm_storel_epi64((__m128i*)(void*)(abs_residual_partition_sums+partition), mm_sum); - } - } - } - - /* now merge partitions for lower orders */ - { - uint32_t from_partition = 0, to_partition = partitions; - int partition_order; - for(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) { - uint32_t i; - partitions >>= 1; - for(i = 0; i < partitions; i++) { - abs_residual_partition_sums[to_partition++] = - abs_residual_partition_sums[from_partition ] + - abs_residual_partition_sums[from_partition+1]; - from_partition += 2; - } - } - } -} - -#endif /* FLAC__SSE2_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ diff --git a/Engine/lib/flac/src/libFLAC/stream_encoder_intrin_ssse3.c b/Engine/lib/flac/src/libFLAC/stream_encoder_intrin_ssse3.c deleted file mode 100644 index 241f723a6..000000000 --- a/Engine/lib/flac/src/libFLAC/stream_encoder_intrin_ssse3.c +++ /dev/null @@ -1,148 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "private/cpu.h" - -#ifndef FLAC__NO_ASM -#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#include "private/stream_encoder.h" -#include "private/bitmath.h" -#ifdef FLAC__SSSE3_SUPPORTED - -#include /* for abs() */ -#include /* SSSE3 */ -#include "FLAC/assert.h" - -FLAC__SSE_TARGET("ssse3") -void FLAC__precompute_partition_info_sums_intrin_ssse3(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps) -{ - const uint32_t default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; - uint32_t partitions = 1u << max_partition_order; - - FLAC__ASSERT(default_partition_samples > predictor_order); - - /* first do max_partition_order */ - { - const uint32_t threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); - uint32_t partition, residual_sample, end = (uint32_t)(-(int32_t)predictor_order); - - if(bps + FLAC__MAX_EXTRA_RESIDUAL_BPS < threshold) { - for(partition = residual_sample = 0; partition < partitions; partition++) { - __m128i mm_sum = _mm_setzero_si128(); - uint32_t e1, e3; - end += default_partition_samples; - - e1 = (residual_sample + 3) & ~3; e3 = end & ~3; - if(e1 > end) - e1 = end; /* try flac -l 1 -b 16 and you'll be here */ - - /* assumption: residual[] is properly aligned so (residual + e1) is properly aligned too and _mm_loadu_si128() is fast */ - for( ; residual_sample < e1; residual_sample++) { - __m128i mm_res = _mm_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); - mm_sum = _mm_add_epi32(mm_sum, mm_res); - } - - for( ; residual_sample < e3; residual_sample+=4) { - __m128i mm_res = _mm_abs_epi32(_mm_loadu_si128((const __m128i*)(const void*)(residual+residual_sample))); - mm_sum = _mm_add_epi32(mm_sum, mm_res); - } - - for( ; residual_sample < end; residual_sample++) { - __m128i mm_res = _mm_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); - mm_sum = _mm_add_epi32(mm_sum, mm_res); - } - - mm_sum = _mm_add_epi32(mm_sum, _mm_shuffle_epi32(mm_sum, _MM_SHUFFLE(1,0,3,2))); - mm_sum = _mm_add_epi32(mm_sum, _mm_shufflelo_epi16(mm_sum, _MM_SHUFFLE(1,0,3,2))); - abs_residual_partition_sums[partition] = (FLAC__uint32)_mm_cvtsi128_si32(mm_sum); -/* workaround for MSVC bugs (at least versions 2015 and 2017 are affected) */ -#if (defined _MSC_VER) && (defined FLAC__CPU_X86_64) - abs_residual_partition_sums[partition] &= 0xFFFFFFFF; -#endif - } - } - else { /* have to pessimistically use 64 bits for accumulator */ - for(partition = residual_sample = 0; partition < partitions; partition++) { - __m128i mm_sum = _mm_setzero_si128(); - uint32_t e1, e3; - end += default_partition_samples; - - e1 = (residual_sample + 1) & ~1; e3 = end & ~1; - FLAC__ASSERT(e1 <= end); - - for( ; residual_sample < e1; residual_sample++) { - __m128i mm_res = _mm_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); /* 0 0 0 |r0| == 00 |r0_64| */ - mm_sum = _mm_add_epi64(mm_sum, mm_res); - } - - for( ; residual_sample < e3; residual_sample+=2) { - __m128i mm_res = _mm_abs_epi32(_mm_loadl_epi64((const __m128i*)(const void*)(residual+residual_sample))); /* 0 0 |r1| |r0| */ - mm_res = _mm_shuffle_epi32(mm_res, _MM_SHUFFLE(3,1,2,0)); /* 0 |r1| 0 |r0| == |r1_64| |r0_64| */ - mm_sum = _mm_add_epi64(mm_sum, mm_res); - } - - for( ; residual_sample < end; residual_sample++) { - __m128i mm_res = _mm_abs_epi32(_mm_cvtsi32_si128(residual[residual_sample])); - mm_sum = _mm_add_epi64(mm_sum, mm_res); - } - - mm_sum = _mm_add_epi64(mm_sum, _mm_srli_si128(mm_sum, 8)); - _mm_storel_epi64((__m128i*)(void*)(abs_residual_partition_sums+partition), mm_sum); - } - } - } - - /* now merge partitions for lower orders */ - { - uint32_t from_partition = 0, to_partition = partitions; - int partition_order; - for(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) { - uint32_t i; - partitions >>= 1; - for(i = 0; i < partitions; i++) { - abs_residual_partition_sums[to_partition++] = - abs_residual_partition_sums[from_partition ] + - abs_residual_partition_sums[from_partition+1]; - from_partition += 2; - } - } - } -} - -#endif /* FLAC__SSSE3_SUPPORTED */ -#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */ -#endif /* FLAC__NO_ASM */ diff --git a/Engine/lib/flac/src/libFLAC/version.rc b/Engine/lib/flac/src/libFLAC/version.rc deleted file mode 100644 index 019da1dd2..000000000 --- a/Engine/lib/flac/src/libFLAC/version.rc +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include "config.h" -#include "FLAC/export.h" - -#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) -# ifdef GIT_COMMIT_TAG -# define VERSIONSTRING GIT_COMMIT_TAG -# else -# define VERSIONSTRING "git-" GIT_COMMIT_HASH -# endif -#else -# define VERSIONSTRING PACKAGE_VERSION -#endif - -#define xstr(s) str(s) -#define str(s) #s - -VS_VERSION_INFO VERSIONINFO -FILEVERSION FLAC_API_VERSION_CURRENT,FLAC_API_VERSION_REVISION,0,0 -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -FILEFLAGS 0 -FILEOS VOS__WINDOWS32 -FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "libFLAC for Windows" - VALUE "ProductName", "Free Lossless Audio Codec" - VALUE "ProductVersion", VERSIONSTRING - VALUE "CompanyName", "Xiph.Org" - VALUE "LegalCopyright", "2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/Engine/lib/flac/src/libFLAC/window.c b/Engine/lib/flac/src/libFLAC/window.c deleted file mode 100644 index 69d5464af..000000000 --- a/Engine/lib/flac/src/libFLAC/window.c +++ /dev/null @@ -1,308 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include "share/compat.h" -#include "FLAC/assert.h" -#include "FLAC/format.h" -#include "private/window.h" - -#ifndef FLAC__INTEGER_ONLY_LIBRARY - -#if defined(_MSC_VER) -// silence 25 MSVC warnings 'conversion from 'double' to 'float', possible loss of data' -#pragma warning ( disable : 4244 ) -#endif - -void FLAC__window_bartlett(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - FLAC__int32 n; - - if (L & 1) { - for (n = 0; n <= N/2; n++) - window[n] = 2.0f * n / (float)N; - for (; n <= N; n++) - window[n] = 2.0f - 2.0f * n / (float)N; - } - else { - for (n = 0; n <= L/2-1; n++) - window[n] = 2.0f * n / (float)N; - for (; n <= N; n++) - window[n] = 2.0f - 2.0f * n / (float)N; - } -} - -void FLAC__window_bartlett_hann(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - FLAC__int32 n; - - for (n = 0; n < L; n++) - window[n] = (FLAC__real)(0.62f - 0.48f * fabsf((float)n/(float)N-0.5f) - 0.38f * cosf(2.0f * M_PI * ((float)n/(float)N))); -} - -void FLAC__window_blackman(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - FLAC__int32 n; - - for (n = 0; n < L; n++) - window[n] = (FLAC__real)(0.42f - 0.5f * cosf(2.0f * M_PI * n / N) + 0.08f * cosf(4.0f * M_PI * n / N)); -} - -/* 4-term -92dB side-lobe */ -void FLAC__window_blackman_harris_4term_92db_sidelobe(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - FLAC__int32 n; - - for (n = 0; n <= N; n++) - window[n] = (FLAC__real)(0.35875f - 0.48829f * cosf(2.0f * M_PI * n / N) + 0.14128f * cosf(4.0f * M_PI * n / N) - 0.01168f * cosf(6.0f * M_PI * n / N)); -} - -void FLAC__window_connes(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - const double N2 = (double)N / 2.; - FLAC__int32 n; - - for (n = 0; n <= N; n++) { - double k = ((double)n - N2) / N2; - k = 1.0f - k * k; - window[n] = (FLAC__real)(k * k); - } -} - -void FLAC__window_flattop(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - FLAC__int32 n; - - for (n = 0; n < L; n++) - window[n] = (FLAC__real)(0.21557895f - 0.41663158f * cosf(2.0f * M_PI * n / N) + 0.277263158f * cosf(4.0f * M_PI * n / N) - 0.083578947f * cosf(6.0f * M_PI * n / N) + 0.006947368f * cosf(8.0f * M_PI * n / N)); -} - -void FLAC__window_gauss(FLAC__real *window, const FLAC__int32 L, const FLAC__real stddev) -{ - const FLAC__int32 N = L - 1; - const double N2 = (double)N / 2.; - FLAC__int32 n; - - if(!(stddev > 0.0f && stddev <= 0.5f)) - /* stddev is not between 0 and 0.5, might be NaN. - * Default to 0.5 */ - FLAC__window_gauss(window, L, 0.25f); - else { - for (n = 0; n <= N; n++) { - const double k = ((double)n - N2) / (stddev * N2); - window[n] = (FLAC__real)exp(-0.5f * k * k); - } - } -} - -void FLAC__window_hamming(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - FLAC__int32 n; - - for (n = 0; n < L; n++) - window[n] = (FLAC__real)(0.54f - 0.46f * cosf(2.0f * M_PI * n / N)); -} - -void FLAC__window_hann(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - FLAC__int32 n; - - for (n = 0; n < L; n++) - window[n] = (FLAC__real)(0.5f - 0.5f * cosf(2.0f * M_PI * n / N)); -} - -void FLAC__window_kaiser_bessel(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - FLAC__int32 n; - - for (n = 0; n < L; n++) - window[n] = (FLAC__real)(0.402f - 0.498f * cosf(2.0f * M_PI * n / N) + 0.098f * cosf(4.0f * M_PI * n / N) - 0.001f * cosf(6.0f * M_PI * n / N)); -} - -void FLAC__window_nuttall(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - FLAC__int32 n; - - for (n = 0; n < L; n++) - window[n] = (FLAC__real)(0.3635819f - 0.4891775f*cosf(2.0f*M_PI*n/N) + 0.1365995f*cosf(4.0f*M_PI*n/N) - 0.0106411f*cosf(6.0f*M_PI*n/N)); -} - -void FLAC__window_rectangle(FLAC__real *window, const FLAC__int32 L) -{ - FLAC__int32 n; - - for (n = 0; n < L; n++) - window[n] = 1.0f; -} - -void FLAC__window_triangle(FLAC__real *window, const FLAC__int32 L) -{ - FLAC__int32 n; - - if (L & 1) { - for (n = 1; n <= (L+1)/2; n++) - window[n-1] = 2.0f * n / ((float)L + 1.0f); - for (; n <= L; n++) - window[n-1] = (float)(2 * (L - n + 1)) / ((float)L + 1.0f); - } - else { - for (n = 1; n <= L/2; n++) - window[n-1] = 2.0f * n / ((float)L + 1.0f); - for (; n <= L; n++) - window[n-1] = (float)(2 * (L - n + 1)) / ((float)L + 1.0f); - } -} - -void FLAC__window_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p) -{ - if (p <= 0.0) - FLAC__window_rectangle(window, L); - else if (p >= 1.0) - FLAC__window_hann(window, L); - else if (!(p > 0.0f && p < 1.0f)) - /* p is not between 0 and 1, probably NaN. - * Default to 0.5 */ - FLAC__window_tukey(window, L, 0.5f); - else { - const FLAC__int32 Np = (FLAC__int32)(p / 2.0f * L) - 1; - FLAC__int32 n; - /* start with rectangle... */ - FLAC__window_rectangle(window, L); - /* ...replace ends with hann */ - if (Np > 0) { - for (n = 0; n <= Np; n++) { - window[n] = (FLAC__real)(0.5f - 0.5f * cosf(M_PI * n / Np)); - window[L-Np-1+n] = (FLAC__real)(0.5f - 0.5f * cosf(M_PI * (n+Np) / Np)); - } - } - } -} - -void FLAC__window_partial_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p, const FLAC__real start, const FLAC__real end) -{ - const FLAC__int32 start_n = (FLAC__int32)(start * L); - const FLAC__int32 end_n = (FLAC__int32)(end * L); - const FLAC__int32 N = end_n - start_n; - FLAC__int32 Np, n, i; - - if (p <= 0.0f) - FLAC__window_partial_tukey(window, L, 0.05f, start, end); - else if (p >= 1.0f) - FLAC__window_partial_tukey(window, L, 0.95f, start, end); - else if (!(p > 0.0f && p < 1.0f)) - /* p is not between 0 and 1, probably NaN. - * Default to 0.5 */ - FLAC__window_partial_tukey(window, L, 0.5f, start, end); - else { - - Np = (FLAC__int32)(p / 2.0f * N); - - for (n = 0; n < start_n && n < L; n++) - window[n] = 0.0f; - for (i = 1; n < (start_n+Np) && n < L; n++, i++) - window[n] = (FLAC__real)(0.5f - 0.5f * cosf(M_PI * i / Np)); - for (; n < (end_n-Np) && n < L; n++) - window[n] = 1.0f; - for (i = Np; n < end_n && n < L; n++, i--) - window[n] = (FLAC__real)(0.5f - 0.5f * cosf(M_PI * i / Np)); - for (; n < L; n++) - window[n] = 0.0f; - } -} - -void FLAC__window_punchout_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p, const FLAC__real start, const FLAC__real end) -{ - const FLAC__int32 start_n = (FLAC__int32)(start * L); - const FLAC__int32 end_n = (FLAC__int32)(end * L); - FLAC__int32 Ns, Ne, n, i; - - if (p <= 0.0f) - FLAC__window_punchout_tukey(window, L, 0.05f, start, end); - else if (p >= 1.0f) - FLAC__window_punchout_tukey(window, L, 0.95f, start, end); - else if (!(p > 0.0f && p < 1.0f)) - /* p is not between 0 and 1, probably NaN. - * Default to 0.5 */ - FLAC__window_punchout_tukey(window, L, 0.5f, start, end); - else { - - Ns = (FLAC__int32)(p / 2.0f * start_n); - Ne = (FLAC__int32)(p / 2.0f * (L - end_n)); - - for (n = 0, i = 1; n < Ns && n < L; n++, i++) - window[n] = (FLAC__real)(0.5f - 0.5f * cosf(M_PI * i / Ns)); - for (; n < start_n-Ns && n < L; n++) - window[n] = 1.0f; - for (i = Ns; n < start_n && n < L; n++, i--) - window[n] = (FLAC__real)(0.5f - 0.5f * cosf(M_PI * i / Ns)); - for (; n < end_n && n < L; n++) - window[n] = 0.0f; - for (i = 1; n < end_n+Ne && n < L; n++, i++) - window[n] = (FLAC__real)(0.5f - 0.5f * cosf(M_PI * i / Ne)); - for (; n < L - (Ne) && n < L; n++) - window[n] = 1.0f; - for (i = Ne; n < L; n++, i--) - window[n] = (FLAC__real)(0.5f - 0.5f * cosf(M_PI * i / Ne)); - } -} - -void FLAC__window_welch(FLAC__real *window, const FLAC__int32 L) -{ - const FLAC__int32 N = L - 1; - const double N2 = (double)N / 2.; - FLAC__int32 n; - - for (n = 0; n <= N; n++) { - const double k = ((double)n - N2) / N2; - window[n] = (FLAC__real)(1.0f - k * k); - } -} - -#if defined(_MSC_VER) -#pragma warning ( default : 4244 ) -#endif - -#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/Engine/lib/flac/src/metaflac/CMakeLists.txt b/Engine/lib/flac/src/metaflac/CMakeLists.txt deleted file mode 100644 index b8af70583..000000000 --- a/Engine/lib/flac/src/metaflac/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -add_executable(metaflac - main.c - operations.c - operations_shorthand_cuesheet.c - operations_shorthand_picture.c - operations_shorthand_seektable.c - operations_shorthand_streaminfo.c - operations_shorthand_vorbiscomment.c - options.c - usage.c - utils.c - version.rc - $<$:../../include/share/win_utf8_io.h> - $<$:../share/win_utf8_io/win_utf8_io.c>) -target_link_libraries(metaflac FLAC getopt utf8) - -install(TARGETS metaflac EXPORT targets - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") diff --git a/Engine/lib/flac/src/metaflac/Makefile.am b/Engine/lib/flac/src/metaflac/Makefile.am deleted file mode 100644 index 8c212ff40..000000000 --- a/Engine/lib/flac/src/metaflac/Makefile.am +++ /dev/null @@ -1,65 +0,0 @@ -# metaflac - Command-line FLAC metadata editor -# Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -if OS_IS_WINDOWS -win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la -if HAVE_WINDRES -metaflac_DEPENDENCIES = version.o -windows_resource_link = -Wl,version.o -endif -endif - -bin_PROGRAMS = metaflac - -AM_CFLAGS = @OGG_CFLAGS@ -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -EXTRA_DIST = \ - CMakeLists.txt \ - version.rc - -metaflac_SOURCES = \ - main.c \ - operations.c \ - operations_shorthand_cuesheet.c \ - operations_shorthand_picture.c \ - operations_shorthand_seektable.c \ - operations_shorthand_streaminfo.c \ - operations_shorthand_vorbiscomment.c \ - options.c \ - usage.c \ - utils.c \ - operations.h \ - operations_shorthand.h \ - options.h \ - usage.h \ - utils.h -metaflac_LDFLAGS = $(AM_LDFLAGS) $(windows_resource_link) - -metaflac_LDADD = \ - $(top_builddir)/src/share/grabbag/libgrabbag.la \ - $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ - $(top_builddir)/src/share/getopt/libgetopt.la \ - $(top_builddir)/src/share/utf8/libutf8.la \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - $(win_utf8_lib) \ - @LTLIBICONV@ - -CLEANFILES = metaflac.exe - -.rc.o: - $(RC) $(AM_CPPFLAGS) $< $@ diff --git a/Engine/lib/flac/src/metaflac/main.c b/Engine/lib/flac/src/metaflac/main.c deleted file mode 100644 index bb6629358..000000000 --- a/Engine/lib/flac/src/metaflac/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "operations.h" -#include "options.h" -#include -#include -#include -#include "share/compat.h" - -#ifndef FUZZ_TOOL_METAFLAC -int main(int argc, char *argv[]) -#else -static int main_to_fuzz(int argc, char *argv[]) -#endif -{ - CommandLineOptions options; - int ret = 0; - -#ifdef __EMX__ - _response(&argc, &argv); - _wildcard(&argc, &argv); -#endif -#ifdef _WIN32 - if (get_utf8_argv(&argc, &argv) != 0) { - fputs("ERROR: failed to convert command line parameters to UTF-8\n", stderr); - return 1; - } -#endif - -#ifdef _WIN32 - { - const char *var; - var = getenv("LC_ALL"); - if (!var) - var = getenv("LC_NUMERIC"); - if (!var) - var = getenv("LANG"); - if (!var || strcmp(var, "C") != 0) - setlocale(LC_ALL, ""); - } -#else - setlocale(LC_ALL, ""); -#endif - init_options(&options); - - if ((ret = parse_options(argc, argv, &options)) == 0) - ret = !do_operations(&options); - else - ret = 1; - - free_options(&options); - - return ret; -} diff --git a/Engine/lib/flac/src/metaflac/operations.c b/Engine/lib/flac/src/metaflac/operations.c deleted file mode 100644 index d81d87a79..000000000 --- a/Engine/lib/flac/src/metaflac/operations.c +++ /dev/null @@ -1,823 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "operations.h" -#include "usage.h" -#include "utils.h" -#include "FLAC/assert.h" -#include "FLAC/metadata.h" -#include "share/alloc.h" -#include "share/grabbag.h" -#include "share/compat.h" -#include -#include -#include -#include "operations_shorthand.h" - -static void show_version(void); -static FLAC__bool do_major_operation(const CommandLineOptions *options); -static FLAC__bool do_major_operation_on_file(const char *filename, const CommandLineOptions *options); -static FLAC__bool do_major_operation__list(const char *filename, FLAC__Metadata_Chain *chain, const CommandLineOptions *options); -static FLAC__bool do_major_operation__append(FLAC__Metadata_Chain *chain, const CommandLineOptions *options); -static FLAC__bool do_major_operation__remove(FLAC__Metadata_Chain *chain, const CommandLineOptions *options); -static FLAC__bool do_major_operation__remove_all(FLAC__Metadata_Chain *chain, const CommandLineOptions *options); -static FLAC__bool do_shorthand_operations(const CommandLineOptions *options); -static FLAC__bool do_shorthand_operations_on_file(const char *filename, const CommandLineOptions *options); -static FLAC__bool do_shorthand_operation(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool utf8_convert); -static FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned num_files, FLAC__bool preserve_modtime, FLAC__bool scan); -static FLAC__bool do_shorthand_operation__add_padding(const char *filename, FLAC__Metadata_Chain *chain, unsigned length, FLAC__bool *needs_write); - -static FLAC__bool passes_filter(const CommandLineOptions *options, const FLAC__StreamMetadata *block, unsigned block_number); -static void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned block_number, FLAC__bool raw, FLAC__bool hexdump_application); -static void write_metadata_binary(FLAC__StreamMetadata *block, FLAC__byte *block_raw, FLAC__bool headerless); - -/* from operations_shorthand_seektable.c */ -extern FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Metadata_Chain *chain, const char *specification, FLAC__bool *needs_write); - -/* from operations_shorthand_streaminfo.c */ -extern FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write); - -/* from operations_shorthand_vorbiscomment.c */ -extern FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool raw); - -/* from operations_shorthand_cuesheet.c */ -extern FLAC__bool do_shorthand_operation__cuesheet(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write); - -/* from operations_shorthand_picture.c */ -extern FLAC__bool do_shorthand_operation__picture(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write); - - -FLAC__bool do_operations(const CommandLineOptions *options) -{ - FLAC__bool ok = true; - - if(options->show_long_help) { - long_usage(0); - } - if(options->show_version) { - show_version(); - } - else if(options->args.checks.num_major_ops > 0) { - FLAC__ASSERT(options->args.checks.num_shorthand_ops == 0); - FLAC__ASSERT(options->args.checks.num_major_ops == 1); - FLAC__ASSERT(options->args.checks.num_major_ops == options->ops.num_operations); - ok = do_major_operation(options); - } - else if(options->args.checks.num_shorthand_ops > 0) { - FLAC__ASSERT(options->args.checks.num_shorthand_ops == options->ops.num_operations); - ok = do_shorthand_operations(options); - } - - return ok; -} - -/* - * local routines - */ - -void show_version(void) -{ - printf("metaflac %s\n", FLAC__VERSION_STRING); -} - -FLAC__bool do_major_operation(const CommandLineOptions *options) -{ - unsigned i; - FLAC__bool ok = true; - - /* to die after first error, v--- add '&& ok' here */ - for(i = 0; i < options->num_files; i++) - ok &= do_major_operation_on_file(options->filenames[i], options); - - return ok; -} - -FLAC__bool do_major_operation_on_file(const char *filename, const CommandLineOptions *options) -{ - FLAC__bool ok = true, needs_write = false, is_ogg = false; - FLAC__Metadata_Chain *chain = FLAC__metadata_chain_new(); - - if(0 == chain) - die("out of memory allocating chain"); - - /*@@@@ lame way of guessing the file type */ - if(strlen(filename) >= 4 && (0 == strcmp(filename+strlen(filename)-4, ".oga") || 0 == strcmp(filename+strlen(filename)-4, ".ogg"))) - is_ogg = true; - - if(! (is_ogg? FLAC__metadata_chain_read_ogg(chain, filename) : FLAC__metadata_chain_read(chain, filename)) ) { - print_error_with_chain_status(chain, "%s: ERROR: reading metadata", filename); - FLAC__metadata_chain_delete(chain); - return false; - } - - switch(options->ops.operations[0].type) { - case OP__LIST: - ok = do_major_operation__list(options->prefix_with_filename? filename : 0, chain, options); - break; - case OP__APPEND: - ok = do_major_operation__append(chain, options); - needs_write = true; - break; - case OP__REMOVE: - ok = do_major_operation__remove(chain, options); - needs_write = true; - break; - case OP__REMOVE_ALL: - ok = do_major_operation__remove_all(chain, options); - needs_write = true; - break; - case OP__MERGE_PADDING: - FLAC__metadata_chain_merge_padding(chain); - needs_write = true; - break; - case OP__SORT_PADDING: - FLAC__metadata_chain_sort_padding(chain); - needs_write = true; - break; - default: - FLAC__ASSERT(0); - return false; - } - - if(ok && needs_write) { - if(options->use_padding) - FLAC__metadata_chain_sort_padding(chain); - ok = FLAC__metadata_chain_write(chain, options->use_padding, options->preserve_modtime); - if(!ok) - print_error_with_chain_status(chain, "%s: ERROR: writing FLAC file", filename); - } - - FLAC__metadata_chain_delete(chain); - - return ok; -} - -FLAC__bool do_major_operation__list(const char *filename, FLAC__Metadata_Chain *chain, const CommandLineOptions *options) -{ - FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new(); - FLAC__StreamMetadata *block; - FLAC__bool ok = true; - unsigned block_number; - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - block_number = 0; - do { - block = FLAC__metadata_iterator_get_block(iterator); - ok &= (0 != block); - if(!ok) - flac_fprintf(stderr, "%s: ERROR: couldn't get block from chain\n", filename); - else if(passes_filter(options, FLAC__metadata_iterator_get_block(iterator), block_number)) { - if(!options->data_format_is_binary && !options->data_format_is_binary_headerless) - write_metadata(filename, block, block_number, !options->utf8_convert, options->application_data_format_is_hexdump); - else { - FLAC__byte * block_raw = FLAC__metadata_object_get_raw(block); - if(block_raw == 0) { - flac_fprintf(stderr, "%s: ERROR: couldn't get block in raw form\n", filename); - FLAC__metadata_iterator_delete(iterator); - return false; - } - write_metadata_binary(block, block_raw, options->data_format_is_binary_headerless); - free(block_raw); - } - } - block_number++; - } while(ok && FLAC__metadata_iterator_next(iterator)); - - FLAC__metadata_iterator_delete(iterator); - - return ok; -} - -FLAC__bool do_major_operation__append(FLAC__Metadata_Chain *chain, const CommandLineOptions *options) -{ - FLAC__byte header[FLAC__STREAM_METADATA_HEADER_LENGTH]; - FLAC__byte *buffer; - FLAC__uint32 buffer_size, num_objects = 0, i, append_after = UINT32_MAX; - FLAC__StreamMetadata *object; - FLAC__Metadata_Iterator *iterator = 0; - FLAC__bool has_vorbiscomment = false; - - /* First, find out after which block appending should take place */ - for(i = 0; i < options->args.num_arguments; i++) { - if(options->args.arguments[i].type == ARG__BLOCK_NUMBER) { - if(append_after != UINT32_MAX || options->args.arguments[i].value.block_number.num_entries > 1) { - flac_fprintf(stderr, "ERROR: more than one block number specified with --append\n"); - return false; - } - append_after = options->args.arguments[i].value.block_number.entries[0]; - } - } - - iterator = FLAC__metadata_iterator_new(); - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - /* Find out whether there is already a vorbis comment block present */ - do { - FLAC__MetadataType type = FLAC__metadata_iterator_get_block_type(iterator); - if(type == FLAC__METADATA_TYPE_VORBIS_COMMENT) - has_vorbiscomment = true; - } - while(FLAC__metadata_iterator_next(iterator)); - - /* Reset iterator */ - FLAC__metadata_iterator_init(iterator, chain); - - /* Go to requested block */ - for(i = 0; i < append_after; i++) { - if(!FLAC__metadata_iterator_next(iterator)) - break; - } - -#ifdef _WIN32 - _setmode(fileno(stdin),_O_BINARY); -#endif - - /* Read header from stdin */ - while(fread(header, 1, FLAC__STREAM_METADATA_HEADER_LENGTH, stdin) == FLAC__STREAM_METADATA_HEADER_LENGTH) { - - buffer_size = ((FLAC__uint32)(header[1]) << 16) + ((FLAC__uint32)(header[2]) << 8) + header[3]; - buffer = safe_malloc_(buffer_size + FLAC__STREAM_METADATA_HEADER_LENGTH); - if(0 == buffer) - die("out of memory allocating read buffer"); - memcpy(buffer, header, FLAC__STREAM_METADATA_HEADER_LENGTH); - - num_objects++; - - if(fread(buffer+FLAC__STREAM_METADATA_HEADER_LENGTH, 1, buffer_size, stdin) < buffer_size) { - flac_fprintf(stderr, "ERROR: couldn't read metadata block #%u from stdin\n",(num_objects)); - free(buffer); - FLAC__metadata_iterator_delete(iterator); - return false; - } - - if((object = FLAC__metadata_object_set_raw(buffer, buffer_size + FLAC__STREAM_METADATA_HEADER_LENGTH)) == NULL) { - flac_fprintf(stderr, "ERROR: couldn't parse supplied metadata block #%u\n",(num_objects)); - free(buffer); - FLAC__metadata_iterator_delete(iterator); - return false; - } - free(buffer); - - if(has_vorbiscomment && object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { - flac_fprintf(stderr, "ERROR: can't add another vorbis comment block to file, it already has one\n"); - FLAC__metadata_object_delete(object); - FLAC__metadata_iterator_delete(iterator); - return false; - } - - - if(object->type == FLAC__METADATA_TYPE_STREAMINFO) { - flac_fprintf(stderr, "ERROR: can't add streaminfo to file\n"); - FLAC__metadata_object_delete(object); - FLAC__metadata_iterator_delete(iterator); - return false; - } - - if(object->type == FLAC__METADATA_TYPE_SEEKTABLE) { - flac_fprintf(stderr, "ERROR: can't add seektable to file, please use --add-seekpoint instead\n"); - FLAC__metadata_object_delete(object); - FLAC__metadata_iterator_delete(iterator); - return false; - } - - if(!FLAC__metadata_iterator_insert_block_after(iterator, object)) { - flac_fprintf(stderr, "ERROR: couldn't add supplied metadata block #%u to file\n",(num_objects)); - FLAC__metadata_object_delete(object); - FLAC__metadata_iterator_delete(iterator); - return false; - } - /* Now check whether what type of block was added */ - { - FLAC__MetadataType type = FLAC__metadata_iterator_get_block_type(iterator); - if(type == FLAC__METADATA_TYPE_VORBIS_COMMENT) - has_vorbiscomment = true; - } - } - -#ifdef _WIN32 - _setmode(fileno(stdin),_O_TEXT); -#endif - - if(num_objects == 0) - flac_fprintf(stderr, "ERROR: unable to find a metadata block in the supplied input\n"); - - FLAC__metadata_iterator_delete(iterator); - - return true; -} - -FLAC__bool do_major_operation__remove(FLAC__Metadata_Chain *chain, const CommandLineOptions *options) -{ - FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new(); - FLAC__bool ok = true; - unsigned block_number; - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - block_number = 0; - while(ok && FLAC__metadata_iterator_next(iterator)) { - block_number++; - if(passes_filter(options, FLAC__metadata_iterator_get_block(iterator), block_number)) { - ok &= FLAC__metadata_iterator_delete_block(iterator, options->use_padding); - if(options->use_padding) - ok &= FLAC__metadata_iterator_next(iterator); - } - } - - FLAC__metadata_iterator_delete(iterator); - - return ok; -} - -FLAC__bool do_major_operation__remove_all(FLAC__Metadata_Chain *chain, const CommandLineOptions *options) -{ - FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new(); - FLAC__bool ok = true; - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - while(ok && FLAC__metadata_iterator_next(iterator)) { - ok &= FLAC__metadata_iterator_delete_block(iterator, options->use_padding); - if(options->use_padding) - ok &= FLAC__metadata_iterator_next(iterator); - } - - FLAC__metadata_iterator_delete(iterator); - - return ok; -} - -FLAC__bool do_shorthand_operations(const CommandLineOptions *options) -{ - unsigned i; - FLAC__bool ok = true; - - /* to die after first error, v--- add '&& ok' here */ - for(i = 0; i < options->num_files; i++) - ok &= do_shorthand_operations_on_file(options->filenames[i], options); - - /* check if OP__ADD_REPLAY_GAIN requested */ - if(ok && options->num_files > 0) { - for(i = 0; i < options->ops.num_operations; i++) { - if(options->ops.operations[i].type == OP__ADD_REPLAY_GAIN) - ok = do_shorthand_operation__add_replay_gain(options->filenames, options->num_files, options->preserve_modtime, false); - else if(options->ops.operations[i].type == OP__SCAN_REPLAY_GAIN) - ok = do_shorthand_operation__add_replay_gain(options->filenames, options->num_files, options->preserve_modtime, true); - } - } - - return ok; -} - -FLAC__bool do_shorthand_operations_on_file(const char *filename, const CommandLineOptions *options) -{ - unsigned i; - FLAC__bool ok = true, needs_write = false, use_padding = options->use_padding; - FLAC__Metadata_Chain *chain = FLAC__metadata_chain_new(); - - if(0 == chain) - die("out of memory allocating chain"); - - if(!FLAC__metadata_chain_read(chain, filename)) { - print_error_with_chain_status(chain, "%s: ERROR: reading metadata", filename); - ok = false; - goto cleanup; - } - - for(i = 0; i < options->ops.num_operations && ok; i++) { - /* - * Do OP__ADD_SEEKPOINT last to avoid decoding twice if both - * --add-seekpoint and --import-cuesheet-from are used. - */ - if(options->ops.operations[i].type != OP__ADD_SEEKPOINT) - ok &= do_shorthand_operation(filename, options->prefix_with_filename, chain, &options->ops.operations[i], &needs_write, options->utf8_convert); - - /* The following seems counterintuitive but the meaning - * of 'use_padding' is 'try to keep the overall metadata - * to its original size, adding or truncating extra - * padding if necessary' which is why we need to turn it - * off in this case. If we don't, the extra padding block - * will just be truncated. - */ - if(options->ops.operations[i].type == OP__ADD_PADDING) - use_padding = false; - } - - /* - * Do OP__ADD_SEEKPOINT last to avoid decoding twice if both - * --add-seekpoint and --import-cuesheet-from are used. - */ - for(i = 0; i < options->ops.num_operations && ok; i++) { - if(options->ops.operations[i].type == OP__ADD_SEEKPOINT) - ok &= do_shorthand_operation(filename, options->prefix_with_filename, chain, &options->ops.operations[i], &needs_write, options->utf8_convert); - } - - if(ok && needs_write) { - if(use_padding) - FLAC__metadata_chain_sort_padding(chain); - ok = FLAC__metadata_chain_write(chain, use_padding, options->preserve_modtime); - if(!ok) - print_error_with_chain_status(chain, "%s: ERROR: writing FLAC file", filename); - } - - cleanup : - FLAC__metadata_chain_delete(chain); - - return ok; -} - -FLAC__bool do_shorthand_operation(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool utf8_convert) -{ - FLAC__bool ok = true; - - switch(operation->type) { - case OP__SHOW_MD5SUM: - case OP__SHOW_MIN_BLOCKSIZE: - case OP__SHOW_MAX_BLOCKSIZE: - case OP__SHOW_MIN_FRAMESIZE: - case OP__SHOW_MAX_FRAMESIZE: - case OP__SHOW_SAMPLE_RATE: - case OP__SHOW_CHANNELS: - case OP__SHOW_BPS: - case OP__SHOW_TOTAL_SAMPLES: - case OP__SET_MD5SUM: - case OP__SET_MIN_BLOCKSIZE: - case OP__SET_MAX_BLOCKSIZE: - case OP__SET_MIN_FRAMESIZE: - case OP__SET_MAX_FRAMESIZE: - case OP__SET_SAMPLE_RATE: - case OP__SET_CHANNELS: - case OP__SET_BPS: - case OP__SET_TOTAL_SAMPLES: - ok = do_shorthand_operation__streaminfo(filename, prefix_with_filename, chain, operation, needs_write); - break; - case OP__SHOW_VC_VENDOR: - case OP__SHOW_VC_FIELD: - case OP__REMOVE_VC_ALL: - case OP__REMOVE_VC_ALL_EXCEPT: - case OP__REMOVE_VC_FIELD: - case OP__REMOVE_VC_FIRSTFIELD: - case OP__SET_VC_FIELD: - case OP__IMPORT_VC_FROM: - case OP__EXPORT_VC_TO: - ok = do_shorthand_operation__vorbis_comment(filename, prefix_with_filename, chain, operation, needs_write, !utf8_convert); - break; - case OP__IMPORT_CUESHEET_FROM: - case OP__EXPORT_CUESHEET_TO: - ok = do_shorthand_operation__cuesheet(filename, chain, operation, needs_write); - break; - case OP__IMPORT_PICTURE_FROM: - case OP__EXPORT_PICTURE_TO: - ok = do_shorthand_operation__picture(filename, chain, operation, needs_write); - break; - case OP__ADD_SEEKPOINT: - ok = do_shorthand_operation__add_seekpoints(filename, chain, operation->argument.add_seekpoint.specification, needs_write); - break; - case OP__ADD_REPLAY_GAIN: - case OP__SCAN_REPLAY_GAIN: - /* these commands are always executed last */ - ok = true; - break; - case OP__ADD_PADDING: - ok = do_shorthand_operation__add_padding(filename, chain, operation->argument.add_padding.length, needs_write); - break; - default: - ok = false; - FLAC__ASSERT(0); - break; - }; - - return ok; -} - -FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned num_files, FLAC__bool preserve_modtime, FLAC__bool scan) -{ - FLAC__StreamMetadata streaminfo; - float *title_gains = 0, *title_peaks = 0; - float album_gain, album_peak; - unsigned sample_rate = 0; - unsigned bits_per_sample = 0; - unsigned channels = 0; - unsigned i; - const char *error; - FLAC__bool first = true; - - FLAC__ASSERT(num_files > 0); - - for(i = 0; i < num_files; i++) { - FLAC__ASSERT(0 != filenames[i]); - if(!FLAC__metadata_get_streaminfo(filenames[i], &streaminfo)) { - flac_fprintf(stderr, "%s: ERROR: can't open file or get STREAMINFO block\n", filenames[i]); - return false; - } - if(first) { - first = false; - sample_rate = streaminfo.data.stream_info.sample_rate; - bits_per_sample = streaminfo.data.stream_info.bits_per_sample; - channels = streaminfo.data.stream_info.channels; - } - else { - if(sample_rate != streaminfo.data.stream_info.sample_rate) { - flac_fprintf(stderr, "%s: ERROR: sample rate of %u Hz does not match previous files' %u Hz\n", filenames[i], streaminfo.data.stream_info.sample_rate, sample_rate); - return false; - } - if(bits_per_sample != streaminfo.data.stream_info.bits_per_sample) { - flac_fprintf(stderr, "%s: ERROR: resolution of %u bps does not match previous files' %u bps\n", filenames[i], streaminfo.data.stream_info.bits_per_sample, bits_per_sample); - return false; - } - if(channels != streaminfo.data.stream_info.channels) { - flac_fprintf(stderr, "%s: ERROR: # channels (%u) does not match previous files' (%u)\n", filenames[i], streaminfo.data.stream_info.channels, channels); - return false; - } - } - if(!grabbag__replaygain_is_valid_sample_frequency(sample_rate)) { - flac_fprintf(stderr, "%s: ERROR: sample rate of %u Hz is not supported\n", filenames[i], sample_rate); - return false; - } - if(channels != 1 && channels != 2) { - flac_fprintf(stderr, "%s: ERROR: # of channels (%u) is not supported, must be 1 or 2\n", filenames[i], channels); - return false; - } - if(bits_per_sample < FLAC__MIN_BITS_PER_SAMPLE || bits_per_sample > FLAC__MAX_BITS_PER_SAMPLE) { - flac_fprintf(stderr, "%s: ERROR: resolution (%u) is not supported, must be between %u and %u\n", filenames[i], bits_per_sample, FLAC__MIN_BITS_PER_SAMPLE, FLAC__MAX_BITS_PER_SAMPLE); - return false; - } - } - - if(!grabbag__replaygain_init(sample_rate)) { - FLAC__ASSERT(0); - /* double protection */ - flac_fprintf(stderr, "internal error\n"); - return false; - } - - if( - 0 == (title_gains = safe_malloc_mul_2op_(sizeof(float), /*times*/num_files)) || - 0 == (title_peaks = safe_malloc_mul_2op_(sizeof(float), /*times*/num_files)) - ) - die("out of memory allocating space for title gains/peaks"); - - for(i = 0; i < num_files; i++) { - if(0 != (error = grabbag__replaygain_analyze_file(filenames[i], title_gains+i, title_peaks+i))) { - flac_fprintf(stderr, "%s: ERROR: during analysis (%s)\n", filenames[i], error); - free(title_gains); - free(title_peaks); - return false; - } - } - grabbag__replaygain_get_album(&album_gain, &album_peak); - - for(i = 0; i < num_files; i++) { - if(!scan) { - if(0 != (error = grabbag__replaygain_store_to_file(filenames[i], album_gain, album_peak, title_gains[i], title_peaks[i], preserve_modtime))) { - flac_fprintf(stderr, "%s: ERROR: writing tags (%s)\n", filenames[i], error); - free(title_gains); - free(title_peaks); - return false; - } - } else { - flac_fprintf(stdout, "%s: %f %f %f %f\n", filenames[i], album_gain, album_peak, title_gains[i], title_peaks[i]); - } - } - - free(title_gains); - free(title_peaks); - return true; -} - -FLAC__bool do_shorthand_operation__add_padding(const char *filename, FLAC__Metadata_Chain *chain, unsigned length, FLAC__bool *needs_write) -{ - FLAC__StreamMetadata *padding = 0; - FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new(); - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - while(FLAC__metadata_iterator_next(iterator)) - ; - - padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING); - if(0 == padding) - die("out of memory allocating PADDING block"); - - padding->length = length; - - if(!FLAC__metadata_iterator_insert_block_after(iterator, padding)) { - print_error_with_chain_status(chain, "%s: ERROR: adding new PADDING block to metadata", filename); - FLAC__metadata_object_delete(padding); - FLAC__metadata_iterator_delete(iterator); - return false; - } - - FLAC__metadata_iterator_delete(iterator); - *needs_write = true; - return true; -} - -FLAC__bool passes_filter(const CommandLineOptions *options, const FLAC__StreamMetadata *block, unsigned block_number) -{ - unsigned i, j; - FLAC__bool matches_number = false, matches_type = false; - FLAC__bool has_block_number_arg = false; - - for(i = 0; i < options->args.num_arguments; i++) { - if(options->args.arguments[i].type == ARG__BLOCK_TYPE || options->args.arguments[i].type == ARG__EXCEPT_BLOCK_TYPE) { - for(j = 0; j < options->args.arguments[i].value.block_type.num_entries; j++) { - if(options->args.arguments[i].value.block_type.entries[j].type == block->type) { - if(block->type != FLAC__METADATA_TYPE_APPLICATION || !options->args.arguments[i].value.block_type.entries[j].filter_application_by_id || 0 == memcmp(options->args.arguments[i].value.block_type.entries[j].application_id, block->data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)) - matches_type = true; - } - } - } - else if(options->args.arguments[i].type == ARG__BLOCK_NUMBER) { - has_block_number_arg = true; - for(j = 0; j < options->args.arguments[i].value.block_number.num_entries; j++) { - if(options->args.arguments[i].value.block_number.entries[j] == block_number) - matches_number = true; - } - } - } - - if(!has_block_number_arg) - matches_number = true; - - if(options->args.checks.has_block_type) { - FLAC__ASSERT(!options->args.checks.has_except_block_type); - } - else if(options->args.checks.has_except_block_type) - matches_type = !matches_type; - else - matches_type = true; - - return matches_number && matches_type; -} - -void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned block_number, FLAC__bool raw, FLAC__bool hexdump_application) -{ - unsigned i, j; - -/*@@@ yuck, should do this with a varargs function or something: */ -#define PPR if(filename) { if(raw) printf("%s:",filename); else flac_printf("%s:",filename); } - PPR; printf("METADATA block #%u\n", block_number); - PPR; printf(" type: %u (%s)\n", (unsigned)block->type, block->type < FLAC__METADATA_TYPE_UNDEFINED? FLAC__MetadataTypeString[block->type] : "UNKNOWN"); - PPR; printf(" is last: %s\n", block->is_last? "true":"false"); - PPR; printf(" length: %u\n", block->length); - - switch(block->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - PPR; printf(" minimum blocksize: %u samples\n", block->data.stream_info.min_blocksize); - PPR; printf(" maximum blocksize: %u samples\n", block->data.stream_info.max_blocksize); - PPR; printf(" minimum framesize: %u bytes\n", block->data.stream_info.min_framesize); - PPR; printf(" maximum framesize: %u bytes\n", block->data.stream_info.max_framesize); - PPR; printf(" sample_rate: %u Hz\n", block->data.stream_info.sample_rate); - PPR; printf(" channels: %u\n", block->data.stream_info.channels); - PPR; printf(" bits-per-sample: %u\n", block->data.stream_info.bits_per_sample); - PPR; printf(" total samples: %" PRIu64 "\n", block->data.stream_info.total_samples); - PPR; printf(" MD5 signature: "); - for(i = 0; i < 16; i++) { - printf("%02x", (unsigned)block->data.stream_info.md5sum[i]); - } - printf("\n"); - break; - case FLAC__METADATA_TYPE_PADDING: - /* nothing to print */ - break; - case FLAC__METADATA_TYPE_APPLICATION: - PPR; printf(" application ID: "); - for(i = 0; i < 4; i++) - printf("%02x", block->data.application.id[i]); - printf("\n"); - PPR; printf(" data contents:\n"); - if(0 != block->data.application.data) { - if(hexdump_application) - hexdump(filename, block->data.application.data, block->length - FLAC__STREAM_METADATA_HEADER_LENGTH, " "); - else - (void) local_fwrite(block->data.application.data, 1, block->length - FLAC__STREAM_METADATA_HEADER_LENGTH, stdout); - } - break; - case FLAC__METADATA_TYPE_SEEKTABLE: - PPR; printf(" seek points: %u\n", block->data.seek_table.num_points); - for(i = 0; i < block->data.seek_table.num_points; i++) { - if(block->data.seek_table.points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) { - PPR; printf(" point %u: sample_number=%" PRIu64 ", stream_offset=%" PRIu64 ", frame_samples=%u\n", i, block->data.seek_table.points[i].sample_number, block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples); - } - else { - PPR; printf(" point %u: PLACEHOLDER\n", i); - } - } - break; - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - PPR; printf(" vendor string: "); - write_vc_field(0, &block->data.vorbis_comment.vendor_string, raw, stdout); - PPR; printf(" comments: %u\n", block->data.vorbis_comment.num_comments); - for(i = 0; i < block->data.vorbis_comment.num_comments; i++) { - PPR; printf(" comment[%u]: ", i); - write_vc_field(0, &block->data.vorbis_comment.comments[i], raw, stdout); - } - break; - case FLAC__METADATA_TYPE_CUESHEET: - PPR; printf(" media catalog number: %s\n", block->data.cue_sheet.media_catalog_number); - PPR; printf(" lead-in: %" PRIu64 "\n", block->data.cue_sheet.lead_in); - PPR; printf(" is CD: %s\n", block->data.cue_sheet.is_cd? "true":"false"); - PPR; printf(" number of tracks: %u\n", block->data.cue_sheet.num_tracks); - for(i = 0; i < block->data.cue_sheet.num_tracks; i++) { - const FLAC__StreamMetadata_CueSheet_Track *track = block->data.cue_sheet.tracks+i; - const FLAC__bool is_last = (i == block->data.cue_sheet.num_tracks-1); - const FLAC__bool is_leadout = is_last && track->num_indices == 0; - PPR; printf(" track[%u]\n", i); - PPR; printf(" offset: %" PRIu64 "\n", track->offset); - if(is_last) { - PPR; printf(" number: %u (%s)\n", (unsigned)track->number, is_leadout? "LEAD-OUT" : "INVALID"); - } - else { - PPR; printf(" number: %u\n", (unsigned)track->number); - } - if(!is_leadout) { - PPR; printf(" ISRC: %s\n", track->isrc); - PPR; printf(" type: %s\n", track->type == 1? "DATA" : "AUDIO"); - PPR; printf(" pre-emphasis: %s\n", track->pre_emphasis? "true":"false"); - PPR; printf(" number of index points: %u\n", track->num_indices); - for(j = 0; j < track->num_indices; j++) { - const FLAC__StreamMetadata_CueSheet_Index *indx = track->indices+j; - PPR; printf(" index[%u]\n", j); - PPR; printf(" offset: %" PRIu64 "\n", indx->offset); - PPR; printf(" number: %u\n", (unsigned)indx->number); - } - } - } - break; - case FLAC__METADATA_TYPE_PICTURE: - PPR; printf(" type: %u (%s)\n", block->data.picture.type, block->data.picture.type < FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED? FLAC__StreamMetadata_Picture_TypeString[block->data.picture.type] : "UNDEFINED"); - PPR; printf(" MIME type: %s\n", block->data.picture.mime_type); - PPR; printf(" description: %s\n", block->data.picture.description); - PPR; printf(" width: %u\n", (unsigned)block->data.picture.width); - PPR; printf(" height: %u\n", (unsigned)block->data.picture.height); - PPR; printf(" depth: %u\n", (unsigned)block->data.picture.depth); - PPR; printf(" colors: %u%s\n", (unsigned)block->data.picture.colors, block->data.picture.colors? "" : " (unindexed)"); - PPR; printf(" data length: %u\n", (unsigned)block->data.picture.data_length); - PPR; printf(" data:\n"); - if(0 != block->data.picture.data) - hexdump(filename, block->data.picture.data, block->data.picture.data_length, " "); - break; - default: - PPR; printf(" data contents:\n"); - if(0 != block->data.unknown.data) - hexdump(filename, block->data.unknown.data, block->length, " "); - break; - } -#undef PPR -} - -void write_metadata_binary(FLAC__StreamMetadata *block, FLAC__byte *block_raw, FLAC__bool headerless) -{ -#ifdef _WIN32 - fflush(stdout); - _setmode(fileno(stdout),_O_BINARY); -#endif - if(!headerless) - local_fwrite(block_raw, 1, block->length+FLAC__STREAM_METADATA_HEADER_LENGTH, stdout); - else if(block->type == FLAC__METADATA_TYPE_APPLICATION && block->length > 3) - local_fwrite(block_raw+FLAC__STREAM_METADATA_HEADER_LENGTH+4, 1, block->length-4, stdout); - else - local_fwrite(block_raw+FLAC__STREAM_METADATA_HEADER_LENGTH, 1, block->length, stdout); -#ifdef _WIN32 - fflush(stdout); - _setmode(fileno(stdout),_O_TEXT); -#endif -} diff --git a/Engine/lib/flac/src/metaflac/operations.h b/Engine/lib/flac/src/metaflac/operations.h deleted file mode 100644 index 79e1c3ba7..000000000 --- a/Engine/lib/flac/src/metaflac/operations.h +++ /dev/null @@ -1,27 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef metaflac__operations_h -#define metaflac__operations_h - -#include "options.h" - -FLAC__bool do_operations(const CommandLineOptions *options); - -#endif diff --git a/Engine/lib/flac/src/metaflac/operations_shorthand.h b/Engine/lib/flac/src/metaflac/operations_shorthand.h deleted file mode 100644 index 1877c2685..000000000 --- a/Engine/lib/flac/src/metaflac/operations_shorthand.h +++ /dev/null @@ -1,26 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "options.h" - -FLAC__bool do_shorthand_operation__picture(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write); -FLAC__bool do_shorthand_operation__cuesheet(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write); -FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Metadata_Chain *chain, const char *specification, FLAC__bool *needs_write); -FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write); -FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool raw); diff --git a/Engine/lib/flac/src/metaflac/operations_shorthand_cuesheet.c b/Engine/lib/flac/src/metaflac/operations_shorthand_cuesheet.c deleted file mode 100644 index 13c4dedb4..000000000 --- a/Engine/lib/flac/src/metaflac/operations_shorthand_cuesheet.c +++ /dev/null @@ -1,226 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include "options.h" -#include "utils.h" -#include "FLAC/assert.h" -#include "share/grabbag.h" -#include "share/compat.h" -#include "operations_shorthand.h" - -static FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, unsigned sample_rate, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link); -static FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename); - -FLAC__bool do_shorthand_operation__cuesheet(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write) -{ - FLAC__bool ok = true; - FLAC__StreamMetadata *cuesheet = 0; - FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new(); - FLAC__uint64 lead_out_offset = 0; - FLAC__bool is_cdda = false; - unsigned sample_rate = 0; - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - do { - FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iterator); - if(block->type == FLAC__METADATA_TYPE_STREAMINFO) { - lead_out_offset = block->data.stream_info.total_samples; - if(lead_out_offset == 0) { - flac_fprintf(stderr, "%s: ERROR: FLAC file must have total_samples set in STREAMINFO in order to import/export cuesheet\n", filename); - FLAC__metadata_iterator_delete(iterator); - return false; - } - sample_rate = block->data.stream_info.sample_rate; - is_cdda = (block->data.stream_info.channels == 1 || block->data.stream_info.channels == 2) && (block->data.stream_info.bits_per_sample == 16) && (sample_rate == 44100); - } - else if(block->type == FLAC__METADATA_TYPE_CUESHEET) - cuesheet = block; - } while(FLAC__metadata_iterator_next(iterator)); - - if(lead_out_offset == 0) { - flac_fprintf(stderr, "%s: ERROR: FLAC stream has no STREAMINFO block\n", filename); - FLAC__metadata_iterator_delete(iterator); - return false; - } - - if(sample_rate == 0) { - flac_fprintf(stderr, "%s: ERROR: cannot parse cuesheet when sample rate is unknown\n", filename); - FLAC__metadata_iterator_delete(iterator); - return false; - } - - switch(operation->type) { - case OP__IMPORT_CUESHEET_FROM: - if(0 != cuesheet) { - flac_fprintf(stderr, "%s: ERROR: FLAC file already has CUESHEET block\n", filename); - ok = false; - } - else { - ok = import_cs_from(filename, &cuesheet, operation->argument.import_cuesheet_from.filename, needs_write, lead_out_offset, sample_rate, is_cdda, operation->argument.import_cuesheet_from.add_seekpoint_link); - if(ok) { - /* append CUESHEET block */ - while(FLAC__metadata_iterator_next(iterator)) - ; - if(!FLAC__metadata_iterator_insert_block_after(iterator, cuesheet)) { - print_error_with_chain_status(chain, "%s: ERROR: adding new CUESHEET block to metadata", filename); - FLAC__metadata_object_delete(cuesheet); - ok = false; - } - } - } - break; - case OP__EXPORT_CUESHEET_TO: - if(0 == cuesheet) { - flac_fprintf(stderr, "%s: ERROR: FLAC file has no CUESHEET block\n", filename); - ok = false; - } - else - ok = export_cs_to(filename, cuesheet, operation->argument.filename.value); - break; - default: - ok = false; - FLAC__ASSERT(0); - break; - }; - - FLAC__metadata_iterator_delete(iterator); - return ok; -} - -/* - * local routines - */ - -FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, unsigned sample_rate, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link) -{ - FILE *f; - const char *error_message; - char **seekpoint_specification = add_seekpoint_link? &(add_seekpoint_link->specification) : 0; - unsigned last_line_read; - - if(0 == cs_filename || strlen(cs_filename) == 0) { - flac_fprintf(stderr, "%s: ERROR: empty import file name\n", filename); - return false; - } - if(0 == strcmp(cs_filename, "-")) - f = stdin; - else - f = flac_fopen(cs_filename, "r"); - - if(0 == f) { - flac_fprintf(stderr, "%s: ERROR: can't open import file %s: %s\n", filename, cs_filename, strerror(errno)); - return false; - } - - *cuesheet = grabbag__cuesheet_parse(f, &error_message, &last_line_read, sample_rate, is_cdda, lead_out_offset); - - if(f != stdin) - fclose(f); - - if(0 == *cuesheet) { - flac_fprintf(stderr, "%s: ERROR: while parsing cuesheet \"%s\" on line %u: %s\n", filename, cs_filename, last_line_read, error_message); - return false; - } - - if(!FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/false, &error_message)) { - flac_fprintf(stderr, "%s: ERROR parsing cuesheet \"%s\": %s\n", filename, cs_filename, error_message); - FLAC__metadata_object_delete(*cuesheet); - return false; - } - - /* if we're expecting CDDA, warn about non-compliance */ - if(is_cdda && !FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/true, &error_message)) { - flac_fprintf(stderr, "%s: WARNING cuesheet \"%s\" is not audio CD compliant: %s\n", filename, cs_filename, error_message); - (*cuesheet)->data.cue_sheet.is_cd = false; - } - - /* add seekpoints for each index point if required */ - if(0 != seekpoint_specification) { - char spec[128]; - unsigned track, indx; - const FLAC__StreamMetadata_CueSheet *cs = &(*cuesheet)->data.cue_sheet; - if(0 == *seekpoint_specification) - *seekpoint_specification = local_strdup(""); - for(track = 0; track < cs->num_tracks; track++) { - const FLAC__StreamMetadata_CueSheet_Track *tr = cs->tracks+track; - for(indx = 0; indx < tr->num_indices; indx++) { - flac_snprintf(spec, sizeof (spec), "%" PRIu64 ";", (tr->offset + tr->indices[indx].offset)); - local_strcat(seekpoint_specification, spec); - } - } - } - - *needs_write = true; - return true; -} - -FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename) -{ - FILE *f; - char *ref = 0; - size_t reflen; - - if(0 == cs_filename || strlen(cs_filename) == 0) { - flac_fprintf(stderr, "%s: ERROR: empty export file name\n", filename); - return false; - } - if(0 == strcmp(cs_filename, "-")) - f = stdout; - else - f = flac_fopen(cs_filename, "w"); - - if(0 == f) { - flac_fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, cs_filename, strerror(errno)); - return false; - } - - reflen = strlen(filename) + 7 + 1; - if(0 == (ref = malloc(reflen))) { - flac_fprintf(stderr, "%s: ERROR: allocating memory\n", filename); - if(f != stdout) - fclose(f); - return false; - } - - flac_snprintf(ref, reflen, "\"%s\" FLAC", filename); - - grabbag__cuesheet_emit(f, cuesheet, ref); - - free(ref); - - if(f != stdout) - fclose(f); -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* Delete output file when fuzzing */ - if(f != stdout) - flac_unlink(cs_filename); -#endif - - return true; -} diff --git a/Engine/lib/flac/src/metaflac/operations_shorthand_picture.c b/Engine/lib/flac/src/metaflac/operations_shorthand_picture.c deleted file mode 100644 index 6bb459baa..000000000 --- a/Engine/lib/flac/src/metaflac/operations_shorthand_picture.c +++ /dev/null @@ -1,184 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include "options.h" -#include "utils.h" -#include "FLAC/assert.h" -#include "share/grabbag.h" /* for grabbag__picture_parse_specification() etc */ - -#include "operations_shorthand.h" - -static FLAC__bool import_pic_from(const char *filename, FLAC__StreamMetadata **picture, const char *specification, FLAC__bool *needs_write); -static FLAC__bool export_pic_to(const char *filename, const FLAC__StreamMetadata *picture, const char *pic_filename); - -FLAC__bool do_shorthand_operation__picture(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write) -{ - FLAC__bool ok = true, has_type1 = false, has_type2 = false; - FLAC__StreamMetadata *picture = 0; - FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new(); - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - switch(operation->type) { - case OP__IMPORT_PICTURE_FROM: - ok = import_pic_from(filename, &picture, operation->argument.specification.value, needs_write); - if(ok) { - /* append PICTURE block */ - while(FLAC__metadata_iterator_next(iterator)) - ; - if(!FLAC__metadata_iterator_insert_block_after(iterator, picture)) { - print_error_with_chain_status(chain, "%s: ERROR: adding new PICTURE block to metadata", filename); - FLAC__metadata_object_delete(picture); - ok = false; - } - } - if(ok) { - /* check global PICTURE constraints (max 1 block each of type=1 and type=2) */ - while(FLAC__metadata_iterator_prev(iterator)) - ; - do { - FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iterator); - if(block->type == FLAC__METADATA_TYPE_PICTURE) { - if(block->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD) { - if(has_type1) { - print_error_with_chain_status(chain, "%s: ERROR: FLAC stream can only have one 32x32 standard icon (type=1) PICTURE block", filename); - ok = false; - } - has_type1 = true; - } - else if(block->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON) { - if(has_type2) { - print_error_with_chain_status(chain, "%s: ERROR: FLAC stream can only have one icon (type=2) PICTURE block", filename); - ok = false; - } - has_type2 = true; - } - } - } while(FLAC__metadata_iterator_next(iterator)); - } - break; - case OP__EXPORT_PICTURE_TO: - { - const Argument_BlockNumber *a = operation->argument.export_picture_to.block_number_link; - int block_number = (a && a->num_entries > 0)? (int)a->entries[0] : -1; - unsigned i = 0; - do { - FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iterator); - if(block->type == FLAC__METADATA_TYPE_PICTURE && (block_number < 0 || i == (unsigned)block_number)) - picture = block; - i++; - } while(FLAC__metadata_iterator_next(iterator) && 0 == picture); - if(0 == picture) { - if(block_number < 0) - flac_fprintf(stderr, "%s: ERROR: FLAC file has no PICTURE block\n", filename); - else - flac_fprintf(stderr, "%s: ERROR: FLAC file has no PICTURE block at block #%d\n", filename, block_number); - ok = false; - } - else - ok = export_pic_to(filename, picture, operation->argument.filename.value); - } - break; - default: - ok = false; - FLAC__ASSERT(0); - break; - }; - - FLAC__metadata_iterator_delete(iterator); - return ok; -} - -/* - * local routines - */ - -FLAC__bool import_pic_from(const char *filename, FLAC__StreamMetadata **picture, const char *specification, FLAC__bool *needs_write) -{ - const char *error_message; - - if(0 == specification || strlen(specification) == 0) { - flac_fprintf(stderr, "%s: ERROR: empty picture specification\n", filename); - return false; - } - - *picture = grabbag__picture_parse_specification(specification, &error_message); - - if(0 == *picture) { - flac_fprintf(stderr, "%s: ERROR: while parsing picture specification \"%s\": %s\n", filename, specification, error_message); - return false; - } - - if(!FLAC__format_picture_is_legal(&(*picture)->data.picture, &error_message)) { - flac_fprintf(stderr, "%s: ERROR: new PICTURE block for \"%s\" is illegal: %s\n", filename, specification, error_message); - FLAC__metadata_object_delete(*picture); - *picture = 0; - return false; - } - - *needs_write = true; - return true; -} - -FLAC__bool export_pic_to(const char *filename, const FLAC__StreamMetadata *picture, const char *pic_filename) -{ - FILE *f; - const FLAC__uint32 len = picture->data.picture.data_length; - - if(0 == pic_filename || strlen(pic_filename) == 0) { - flac_fprintf(stderr, "%s: ERROR: empty export file name\n", filename); - return false; - } - if(0 == strcmp(pic_filename, "-")) - f = grabbag__file_get_binary_stdout(); - else - f = flac_fopen(pic_filename, "wb"); - - if(0 == f) { - flac_fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, pic_filename, strerror(errno)); - return false; - } - - if(fwrite(picture->data.picture.data, 1, len, f) != len) { - flac_fprintf(stderr, "%s: ERROR: writing PICTURE data to file\n", filename); - if(f != stdout) - fclose(f); - return false; - } - - if(f != stdout) - fclose(f); - -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* Delete output file when fuzzing */ - if(f != stdout) - flac_unlink(pic_filename); -#endif - - return true; -} diff --git a/Engine/lib/flac/src/metaflac/operations_shorthand_seektable.c b/Engine/lib/flac/src/metaflac/operations_shorthand_seektable.c deleted file mode 100644 index c9175b368..000000000 --- a/Engine/lib/flac/src/metaflac/operations_shorthand_seektable.c +++ /dev/null @@ -1,220 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "utils.h" -#include "FLAC/assert.h" -#include "FLAC/stream_decoder.h" -#include "FLAC/metadata.h" -#include "share/grabbag.h" -#include "operations_shorthand.h" - -static FLAC__bool populate_seekpoint_values(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write); - -FLAC__bool do_shorthand_operation__add_seekpoints(const char *filename, FLAC__Metadata_Chain *chain, const char *specification, FLAC__bool *needs_write) -{ - FLAC__bool ok = true, found_seektable_block = false; - FLAC__StreamMetadata *block = 0; - FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new(); - FLAC__uint64 total_samples = 0; - unsigned sample_rate = 0; - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - do { - block = FLAC__metadata_iterator_get_block(iterator); - if(block->type == FLAC__METADATA_TYPE_STREAMINFO) { - sample_rate = block->data.stream_info.sample_rate; - total_samples = block->data.stream_info.total_samples; - } - else if(block->type == FLAC__METADATA_TYPE_SEEKTABLE) - found_seektable_block = true; - } while(!found_seektable_block && FLAC__metadata_iterator_next(iterator)); - - if(total_samples == 0) { - flac_fprintf(stderr, "%s: ERROR: cannot add seekpoints because STREAMINFO block does not specify total_samples\n", filename); - FLAC__metadata_iterator_delete(iterator); - return false; - } - - if(!found_seektable_block) { - /* create a new block */ - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE); - if(0 == block) - die("out of memory allocating SEEKTABLE block"); - while(FLAC__metadata_iterator_prev(iterator)) - ; - if(!FLAC__metadata_iterator_insert_block_after(iterator, block)) { - print_error_with_chain_status(chain, "%s: ERROR: adding new SEEKTABLE block to metadata", filename); - FLAC__metadata_object_delete(block); - FLAC__metadata_iterator_delete(iterator); - return false; - } - /* iterator is left pointing to new block */ - FLAC__ASSERT(FLAC__metadata_iterator_get_block(iterator) == block); - } - - FLAC__metadata_iterator_delete(iterator); - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_SEEKTABLE); - - if(!grabbag__seektable_convert_specification_to_template(specification, /*only_explicit_placeholders=*/false, total_samples, sample_rate, block, /*spec_has_real_points=*/0)) { - flac_fprintf(stderr, "%s: ERROR (internal) preparing seektable with seekpoints\n", filename); - return false; - } - - ok = populate_seekpoint_values(filename, block, needs_write); - - if(ok) - (void) FLAC__format_seektable_sort(&block->data.seek_table); - - return ok; -} - -/* - * local routines - */ - -typedef struct { - FLAC__StreamMetadata_SeekTable *seektable_template; - FLAC__uint64 samples_written; - FLAC__uint64 audio_offset, last_offset; - unsigned first_seekpoint_to_check; - FLAC__bool error_occurred; - FLAC__StreamDecoderErrorStatus error_status; -} ClientData; - -static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - ClientData *cd = (ClientData*)client_data; - - (void)buffer; - FLAC__ASSERT(0 != cd); - - if(!cd->error_occurred) { - const unsigned blocksize = frame->header.blocksize; - const FLAC__uint64 frame_first_sample = cd->samples_written; - const FLAC__uint64 frame_last_sample = frame_first_sample + (FLAC__uint64)blocksize - 1; - FLAC__uint64 test_sample; - unsigned i; - for(i = cd->first_seekpoint_to_check; i < cd->seektable_template->num_points; i++) { - test_sample = cd->seektable_template->points[i].sample_number; - if(test_sample > frame_last_sample) { - break; - } - else if(test_sample >= frame_first_sample) { - cd->seektable_template->points[i].sample_number = frame_first_sample; - cd->seektable_template->points[i].stream_offset = cd->last_offset - cd->audio_offset; - cd->seektable_template->points[i].frame_samples = blocksize; - cd->first_seekpoint_to_check++; - /* DO NOT: "break;" and here's why: - * The seektable template may contain more than one target - * sample for any given frame; we will keep looping, generating - * duplicate seekpoints for them, and we'll clean it up later, - * just before writing the seektable back to the metadata. - */ - } - else { - cd->first_seekpoint_to_check++; - } - } - cd->samples_written += blocksize; - if(!FLAC__stream_decoder_get_decode_position(decoder, &cd->last_offset)) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; - } - else - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; -} - -static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - ClientData *cd = (ClientData*)client_data; - - (void)decoder; - FLAC__ASSERT(0 != cd); - - if(!cd->error_occurred) { /* don't let multiple errors overwrite the first one */ - cd->error_occurred = true; - cd->error_status = status; - } -} - -FLAC__bool populate_seekpoint_values(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write) -{ - FLAC__StreamDecoder *decoder; - ClientData client_data; - FLAC__bool ok = true; - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_SEEKTABLE); - - client_data.seektable_template = &block->data.seek_table; - client_data.samples_written = 0; - /* client_data.audio_offset must be determined later */ - client_data.first_seekpoint_to_check = 0; - client_data.error_occurred = false; - - decoder = FLAC__stream_decoder_new(); - - if(0 == decoder) { - flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) creating the decoder instance\n", filename); - return false; - } - - FLAC__stream_decoder_set_md5_checking(decoder, false); - FLAC__stream_decoder_set_metadata_ignore_all(decoder); - - if(FLAC__stream_decoder_init_file(decoder, filename, write_callback_, /*metadata_callback=*/0, error_callback_, &client_data) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) initializing the decoder instance (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder)); - ok = false; - } - - if(ok && !FLAC__stream_decoder_process_until_end_of_metadata(decoder)) { - flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder)); - ok = false; - } - - if(ok && !FLAC__stream_decoder_get_decode_position(decoder, &client_data.audio_offset)) { - flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file\n", filename); - ok = false; - } - client_data.last_offset = client_data.audio_offset; - - if(ok && !FLAC__stream_decoder_process_until_end_of_stream(decoder)) { - flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder)); - ok = false; - } - - if(ok && client_data.error_occurred) { - flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%u:%s)\n", filename, (unsigned)client_data.error_status, FLAC__StreamDecoderErrorStatusString[client_data.error_status]); - ok = false; - } - - *needs_write = true; - FLAC__stream_decoder_delete(decoder); - return ok; -} diff --git a/Engine/lib/flac/src/metaflac/operations_shorthand_streaminfo.c b/Engine/lib/flac/src/metaflac/operations_shorthand_streaminfo.c deleted file mode 100644 index 321984169..000000000 --- a/Engine/lib/flac/src/metaflac/operations_shorthand_streaminfo.c +++ /dev/null @@ -1,127 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "options.h" -#include "utils.h" -#include "FLAC/assert.h" -#include "FLAC/metadata.h" -#include "share/compat.h" -#include -#include "operations_shorthand.h" - -FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write) -{ - unsigned i; - FLAC__bool ok = true; - FLAC__StreamMetadata *block; - FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new(); - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - block = FLAC__metadata_iterator_get_block(iterator); - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_STREAMINFO); - - if(prefix_with_filename) - flac_printf("%s:", filename); - - switch(operation->type) { - case OP__SHOW_MD5SUM: - for(i = 0; i < 16; i++) - printf("%02x", block->data.stream_info.md5sum[i]); - printf("\n"); - break; - case OP__SHOW_MIN_BLOCKSIZE: - printf("%u\n", block->data.stream_info.min_blocksize); - break; - case OP__SHOW_MAX_BLOCKSIZE: - printf("%u\n", block->data.stream_info.max_blocksize); - break; - case OP__SHOW_MIN_FRAMESIZE: - printf("%u\n", block->data.stream_info.min_framesize); - break; - case OP__SHOW_MAX_FRAMESIZE: - printf("%u\n", block->data.stream_info.max_framesize); - break; - case OP__SHOW_SAMPLE_RATE: - printf("%u\n", block->data.stream_info.sample_rate); - break; - case OP__SHOW_CHANNELS: - printf("%u\n", block->data.stream_info.channels); - break; - case OP__SHOW_BPS: - printf("%u\n", block->data.stream_info.bits_per_sample); - break; - case OP__SHOW_TOTAL_SAMPLES: - printf("%" PRIu64 "\n", block->data.stream_info.total_samples); - break; - case OP__SET_MD5SUM: - memcpy(block->data.stream_info.md5sum, operation->argument.streaminfo_md5.value, 16); - *needs_write = true; - break; - case OP__SET_MIN_BLOCKSIZE: - block->data.stream_info.min_blocksize = operation->argument.streaminfo_uint32.value; - *needs_write = true; - break; - case OP__SET_MAX_BLOCKSIZE: - block->data.stream_info.max_blocksize = operation->argument.streaminfo_uint32.value; - *needs_write = true; - break; - case OP__SET_MIN_FRAMESIZE: - block->data.stream_info.min_framesize = operation->argument.streaminfo_uint32.value; - *needs_write = true; - break; - case OP__SET_MAX_FRAMESIZE: - block->data.stream_info.max_framesize = operation->argument.streaminfo_uint32.value; - *needs_write = true; - break; - case OP__SET_SAMPLE_RATE: - block->data.stream_info.sample_rate = operation->argument.streaminfo_uint32.value; - *needs_write = true; - break; - case OP__SET_CHANNELS: - block->data.stream_info.channels = operation->argument.streaminfo_uint32.value; - *needs_write = true; - break; - case OP__SET_BPS: - block->data.stream_info.bits_per_sample = operation->argument.streaminfo_uint32.value; - *needs_write = true; - break; - case OP__SET_TOTAL_SAMPLES: - block->data.stream_info.total_samples = operation->argument.streaminfo_uint64.value; - *needs_write = true; - break; - default: - ok = false; - FLAC__ASSERT(0); - break; - }; - - FLAC__metadata_iterator_delete(iterator); - - return ok; -} diff --git a/Engine/lib/flac/src/metaflac/operations_shorthand_vorbiscomment.c b/Engine/lib/flac/src/metaflac/operations_shorthand_vorbiscomment.c deleted file mode 100644 index 27c9e4c87..000000000 --- a/Engine/lib/flac/src/metaflac/operations_shorthand_vorbiscomment.c +++ /dev/null @@ -1,430 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "options.h" -#include "utils.h" -#include "FLAC/assert.h" -#include "share/grabbag.h" /* for grabbag__file_get_filesize() */ -#include "share/utf8.h" -#include -#include -#include -#include "operations_shorthand.h" -#include "share/compat.h" - -static FLAC__bool remove_vc_all(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write); -static FLAC__bool remove_vc_all_except(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write); -static FLAC__bool remove_vc_field(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write); -static FLAC__bool remove_vc_firstfield(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write); -static FLAC__bool set_vc_field(const char *filename, FLAC__StreamMetadata *block, const Argument_VcField *field, FLAC__bool *needs_write, FLAC__bool raw); -static FLAC__bool import_vc_from(const char *filename, FLAC__StreamMetadata *block, const Argument_String *vc_filename, FLAC__bool *needs_write, FLAC__bool raw); -static FLAC__bool export_vc_to(const char *filename, FLAC__StreamMetadata *block, const Argument_String *vc_filename, FLAC__bool raw); - -FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool raw) -{ - FLAC__bool ok = true, found_vc_block = false; - FLAC__StreamMetadata *block = 0; - FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new(); - - if(0 == iterator) - die("out of memory allocating iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - do { - block = FLAC__metadata_iterator_get_block(iterator); - if(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) - found_vc_block = true; - } while(!found_vc_block && FLAC__metadata_iterator_next(iterator)); - - if(!found_vc_block) { - /* create a new block if necessary */ - if(operation->type == OP__SET_VC_FIELD || operation->type == OP__IMPORT_VC_FROM) { - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); - if(0 == block) - die("out of memory allocating VORBIS_COMMENT block"); - while(FLAC__metadata_iterator_next(iterator)) - ; - if(!FLAC__metadata_iterator_insert_block_after(iterator, block)) { - print_error_with_chain_status(chain, "%s: ERROR: adding new VORBIS_COMMENT block to metadata", filename); - return false; - } - /* iterator is left pointing to new block */ - FLAC__ASSERT(FLAC__metadata_iterator_get_block(iterator) == block); - } - else { - FLAC__metadata_iterator_delete(iterator); - return ok; - } - } - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - switch(operation->type) { - case OP__SHOW_VC_VENDOR: - write_vc_field(prefix_with_filename? filename : 0, &block->data.vorbis_comment.vendor_string, raw, stdout); - break; - case OP__SHOW_VC_FIELD: - write_vc_fields(prefix_with_filename? filename : 0, operation->argument.vc_field_name.value, block->data.vorbis_comment.comments, block->data.vorbis_comment.num_comments, raw, stdout); - break; - case OP__REMOVE_VC_ALL: - ok = remove_vc_all(filename, block, needs_write); - break; - case OP__REMOVE_VC_ALL_EXCEPT: - ok = remove_vc_all_except(filename, block, operation->argument.vc_field_name.value, needs_write); - break; - case OP__REMOVE_VC_FIELD: - ok = remove_vc_field(filename, block, operation->argument.vc_field_name.value, needs_write); - break; - case OP__REMOVE_VC_FIRSTFIELD: - ok = remove_vc_firstfield(filename, block, operation->argument.vc_field_name.value, needs_write); - break; - case OP__SET_VC_FIELD: -#ifdef _WIN32 /* do not convert anything or things will break */ - ok = set_vc_field(filename, block, &operation->argument.vc_field, needs_write, true); -#else - ok = set_vc_field(filename, block, &operation->argument.vc_field, needs_write, raw); -#endif - break; - case OP__IMPORT_VC_FROM: - ok = import_vc_from(filename, block, &operation->argument.filename, needs_write, raw); - break; - case OP__EXPORT_VC_TO: - ok = export_vc_to(filename, block, &operation->argument.filename, raw); - break; - default: - ok = false; - FLAC__ASSERT(0); - break; - }; - - FLAC__metadata_iterator_delete(iterator); - return ok; -} - -/* - * local routines - */ - -FLAC__bool remove_vc_all(const char *filename, FLAC__StreamMetadata *block, FLAC__bool *needs_write) -{ - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(0 != needs_write); - - if(0 != block->data.vorbis_comment.comments) { - FLAC__ASSERT(block->data.vorbis_comment.num_comments > 0); - if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, 0)) { - flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename); - return false; - } - *needs_write = true; - } - else { - FLAC__ASSERT(block->data.vorbis_comment.num_comments == 0); - } - - return true; -} - -FLAC__bool remove_vc_all_except(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write) -{ - char * field_names[200]; - uint32_t field_name_length, i; - int j, num_field_names; - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(0 != needs_write); - - field_name_length = strlen(field_name); - field_names[0] = (void *)field_name; - - for(num_field_names = 1; num_field_names < 200; num_field_names++) { - char * separator = strchr(field_names[num_field_names-1], '='); - if(separator == 0 || separator >= field_name + field_name_length) - break; - field_names[num_field_names] = separator+1; - } - - if(num_field_names > 200) { - flac_fprintf(stderr, "%s: ERROR: too many field names\n", filename); - return false; - } - - for(i = 0; i < block->data.vorbis_comment.num_comments; ) { - int field_name_found = false; - for(j = 0; j < num_field_names; j++) { - const uint32_t length = (j == (num_field_names - 1))?(uint32_t)strlen(field_names[j]):(uint32_t)(strchr(field_names[j],'=')-field_names[j]); - if(FLAC__metadata_object_vorbiscomment_entry_matches(block->data.vorbis_comment.comments[i], field_names[j], length)) { - field_name_found = true; - break; - } - } - if(!field_name_found) { - FLAC__metadata_object_vorbiscomment_delete_comment(block, i); - *needs_write = true; - } - else - i++; - } - - return true; -} - -FLAC__bool remove_vc_field(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write) -{ - int n; - - FLAC__ASSERT(0 != needs_write); - - n = FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, field_name); - - if(n < 0) { - flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename); - return false; - } - else if(n > 0) - *needs_write = true; - - return true; -} - -FLAC__bool remove_vc_firstfield(const char *filename, FLAC__StreamMetadata *block, const char *field_name, FLAC__bool *needs_write) -{ - int n; - - FLAC__ASSERT(0 != needs_write); - - n = FLAC__metadata_object_vorbiscomment_remove_entry_matching(block, field_name); - - if(n < 0) { - flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename); - return false; - } - else if(n > 0) - *needs_write = true; - - return true; -} - -FLAC__bool set_vc_field(const char *filename, FLAC__StreamMetadata *block, const Argument_VcField *field, FLAC__bool *needs_write, FLAC__bool raw) -{ - FLAC__StreamMetadata_VorbisComment_Entry entry; - char *converted; - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(0 != field); - FLAC__ASSERT(0 != needs_write); - - if(field->field_value_from_file) { - /* read the file into 'data' */ - FILE *f = 0; - char *data = 0; - const FLAC__off_t size = grabbag__file_get_filesize(field->field_value); - if(size < 0) { - flac_fprintf(stderr, "%s: ERROR: can't open file '%s' for '%s' tag value\n", filename, field->field_value, field->field_name); - return false; - } - if(size >= 0x100000) { /* magic arbitrary limit, actual format limit is near 16MB */ - flac_fprintf(stderr, "%s: ERROR: file '%s' for '%s' tag value is too large\n", filename, field->field_value, field->field_name); - return false; - } - if(0 == (data = malloc(size+1))) - die("out of memory allocating tag value"); - data[size] = '\0'; - if(0 == (f = flac_fopen(field->field_value, "rb")) || fread(data, 1, size, f) != (size_t)size) { - flac_fprintf(stderr, "%s: ERROR: while reading file '%s' for '%s' tag value: %s\n", filename, field->field_value, field->field_name, strerror(errno)); - free(data); - if(f) - fclose(f); - return false; - } - fclose(f); - if(strlen(data) != (size_t)size) { - free(data); - flac_fprintf(stderr, "%s: ERROR: file '%s' for '%s' tag value has embedded NULs\n", filename, field->field_value, field->field_name); - return false; - } - - /* move 'data' into 'converted', converting to UTF-8 if necessary */ - if(raw) { - converted = data; - } - else if(utf8_encode(data, &converted) >= 0) { - free(data); - } - else { - free(data); - flac_fprintf(stderr, "%s: ERROR: converting file '%s' contents to UTF-8 for tag value\n", filename, field->field_value); - return false; - } - - /* create and entry and append it */ - if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, field->field_name, converted)) { - free(converted); - flac_fprintf(stderr, "%s: ERROR: file '%s' for '%s' tag value is not valid UTF-8\n", filename, field->field_value, field->field_name); - return false; - } - free(converted); - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) { - flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename); - return false; - } - - *needs_write = true; - return true; - } - else { - FLAC__bool needs_free = false; - entry.entry = (FLAC__byte *)field->field; - if(raw) { - entry.entry = (FLAC__byte *)field->field; - } - else if(utf8_encode(field->field, &converted) >= 0) { - entry.entry = (FLAC__byte *)converted; - needs_free = true; - } - else { - flac_fprintf(stderr, "%s: ERROR: converting comment '%s' to UTF-8\n", filename, field->field); - return false; - } - entry.length = strlen((const char *)entry.entry); - if(!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length)) { - if(needs_free) - free(converted); - /* - * our previous parsing has already established that the field - * name is OK, so it must be the field value - */ - flac_fprintf(stderr, "%s: ERROR: tag value for '%s' is not valid UTF-8\n", filename, field->field_name); - return false; - } - - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) { - if(needs_free) - free(converted); - flac_fprintf(stderr, "%s: ERROR: memory allocation failure\n", filename); - return false; - } - - *needs_write = true; - if(needs_free) - free(converted); - return true; - } -} - -FLAC__bool import_vc_from(const char *filename, FLAC__StreamMetadata *block, const Argument_String *vc_filename, FLAC__bool *needs_write, FLAC__bool raw) -{ - FILE *f; - char line[65536]; - FLAC__bool ret; - - if(0 == vc_filename->value || strlen(vc_filename->value) == 0) { - flac_fprintf(stderr, "%s: ERROR: empty import file name\n", filename); - return false; - } - if(0 == strcmp(vc_filename->value, "-")) - f = stdin; - else - f = flac_fopen(vc_filename->value, "r"); - - if(0 == f) { - flac_fprintf(stderr, "%s: ERROR: can't open import file %s: %s\n", filename, vc_filename->value, strerror(errno)); - return false; - } - - ret = true; - while(ret && !feof(f) && fgets(line, sizeof(line), f) != NULL) { - if(!feof(f)) { - char *p = strchr(line, '\n'); - if(0 == p) { - flac_fprintf(stderr, "%s: ERROR: line too long, aborting\n", vc_filename->value); - ret = false; - } - else { - const char *violation; - Argument_VcField field; - *p = '\0'; - memset(&field, 0, sizeof(Argument_VcField)); - field.field_value_from_file = false; - if(!parse_vorbis_comment_field(line, &field.field, &field.field_name, &field.field_value, &field.field_value_length, &violation)) { - FLAC__ASSERT(0 != violation); - flac_fprintf(stderr, "%s: ERROR: malformed vorbis comment field \"%s\",\n %s\n", vc_filename->value, line, violation); - ret = false; - } - else { - ret = set_vc_field(filename, block, &field, needs_write, raw); - } - if(0 != field.field) - free(field.field); - if(0 != field.field_name) - free(field.field_name); - if(0 != field.field_value) - free(field.field_value); - } - } - }; - - if(f != stdin) - fclose(f); - return ret; -} - -FLAC__bool export_vc_to(const char *filename, FLAC__StreamMetadata *block, const Argument_String *vc_filename, FLAC__bool raw) -{ - FILE *f; - FLAC__bool ret; - - if(0 == vc_filename->value || strlen(vc_filename->value) == 0) { - flac_fprintf(stderr, "%s: ERROR: empty export file name\n", filename); - return false; - } - if(0 == strcmp(vc_filename->value, "-")) - f = stdout; - else - f = flac_fopen(vc_filename->value, "w"); - - if(0 == f) { - flac_fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, vc_filename->value, strerror(errno)); - return false; - } - - ret = true; - - write_vc_fields(0, 0, block->data.vorbis_comment.comments, block->data.vorbis_comment.num_comments, raw, f); - - if(f != stdout) - fclose(f); - -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - /* Delete output file when fuzzing */ - if(f != stdout) - flac_unlink(vc_filename->value); -#endif - - return ret; -} diff --git a/Engine/lib/flac/src/metaflac/options.c b/Engine/lib/flac/src/metaflac/options.c deleted file mode 100644 index 1b4b6f624..000000000 --- a/Engine/lib/flac/src/metaflac/options.c +++ /dev/null @@ -1,1146 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "options.h" -#include "usage.h" -#include "utils.h" -#include "FLAC/assert.h" -#include "share/alloc.h" -#include "share/compat.h" -#include "share/grabbag/replaygain.h" -#include -#include -#include -#include - -/* - share__getopt format struct; note we don't use short options so we just - set the 'val' field to 0 everywhere to indicate a valid option. -*/ -struct share__option long_options_[] = { - /* global options */ - { "preserve-modtime", 0, 0, 0 }, - { "with-filename", 0, 0, 0 }, - { "no-filename", 0, 0, 0 }, - { "no-utf8-convert", 0, 0, 0 }, - { "dont-use-padding", 0, 0, 0 }, - { "no-cued-seekpoints", 0, 0, 0 }, - /* shorthand operations */ - { "show-md5sum", 0, 0, 0 }, - { "show-min-blocksize", 0, 0, 0 }, - { "show-max-blocksize", 0, 0, 0 }, - { "show-min-framesize", 0, 0, 0 }, - { "show-max-framesize", 0, 0, 0 }, - { "show-sample-rate", 0, 0, 0 }, - { "show-channels", 0, 0, 0 }, - { "show-bps", 0, 0, 0 }, - { "show-total-samples", 0, 0, 0 }, - { "set-md5sum", 1, 0, 0 }, /* undocumented */ - { "set-min-blocksize", 1, 0, 0 }, /* undocumented */ - { "set-max-blocksize", 1, 0, 0 }, /* undocumented */ - { "set-min-framesize", 1, 0, 0 }, /* undocumented */ - { "set-max-framesize", 1, 0, 0 }, /* undocumented */ - { "set-sample-rate", 1, 0, 0 }, /* undocumented */ - { "set-channels", 1, 0, 0 }, /* undocumented */ - { "set-bps", 1, 0, 0 }, /* undocumented */ - { "set-total-samples", 1, 0, 0 }, /* undocumented */ /* WATCHOUT: used by test/test_flac.sh on windows */ - { "show-vendor-tag", 0, 0, 0 }, - { "show-all-tags", 0, 0, 0 }, - { "show-tag", 1, 0, 0 }, - { "remove-all-tags", 0, 0, 0 }, - { "remove-all-tags-except", 1, 0, 0 }, - { "remove-tag", 1, 0, 0 }, - { "remove-first-tag", 1, 0, 0 }, - { "set-tag", 1, 0, 0 }, - { "set-tag-from-file", 1, 0, 0 }, - { "import-tags-from", 1, 0, 0 }, - { "export-tags-to", 1, 0, 0 }, - { "import-cuesheet-from", 1, 0, 0 }, - { "export-cuesheet-to", 1, 0, 0 }, - { "import-picture-from", 1, 0, 0 }, - { "export-picture-to", 1, 0, 0 }, - { "add-seekpoint", 1, 0, 0 }, - { "add-replay-gain", 0, 0, 0 }, - { "scan-replay-gain", 0, 0, 0 }, - { "remove-replay-gain", 0, 0, 0 }, - { "add-padding", 1, 0, 0 }, - /* major operations */ - { "help", 0, 0, 0 }, - { "version", 0, 0, 0 }, - { "list", 0, 0, 0 }, - { "append", 0, 0, 0 }, - { "remove", 0, 0, 0 }, - { "remove-all", 0, 0, 0 }, - { "merge-padding", 0, 0, 0 }, - { "sort-padding", 0, 0, 0 }, - /* major operation arguments */ - { "block-number", 1, 0, 0 }, - { "block-type", 1, 0, 0 }, - { "except-block-type", 1, 0, 0 }, - { "data-format", 1, 0, 0 }, - { "application-data-format", 1, 0, 0 }, - { "from-file", 1, 0, 0 }, - {0, 0, 0, 0} -}; - -static FLAC__bool parse_option(int option_index, const char *option_argument, CommandLineOptions *options); -static void append_new_operation(CommandLineOptions *options, Operation operation); -static void append_new_argument(CommandLineOptions *options, Argument argument); -static Operation *append_major_operation(CommandLineOptions *options, OperationType type); -static Operation *append_shorthand_operation(CommandLineOptions *options, OperationType type); -static Argument *find_argument(CommandLineOptions *options, ArgumentType type); -static Operation *find_shorthand_operation(CommandLineOptions *options, OperationType type); -static Argument *append_argument(CommandLineOptions *options, ArgumentType type); -static FLAC__bool parse_md5(const char *src, FLAC__byte dest[16]); -static FLAC__bool parse_uint32(const char *src, FLAC__uint32 *dest); -static FLAC__bool parse_uint64(const char *src, FLAC__uint64 *dest); -static FLAC__bool parse_string(const char *src, char **dest); -static FLAC__bool parse_vorbis_comment_field_name(const char *field_ref, char **name, const char **violation); -static FLAC__bool parse_vorbis_comment_field_names(const char *field_ref, char **names, const char **violation); -static FLAC__bool parse_add_seekpoint(const char *in, char **out, const char **violation); -static FLAC__bool parse_add_padding(const char *in, unsigned *out); -static FLAC__bool parse_block_number(const char *in, Argument_BlockNumber *out); -static FLAC__bool parse_block_type(const char *in, Argument_BlockType *out); -static FLAC__bool parse_data_format(const char *in, Argument_DataFormat *out); -static FLAC__bool parse_application_data_format(const char *in, FLAC__bool *out); -static void undocumented_warning(const char *opt); - - -void init_options(CommandLineOptions *options) -{ - options->preserve_modtime = false; - - /* '2' is a hack to mean "use default if not forced on command line" */ - FLAC__ASSERT(true != 2); - options->prefix_with_filename = 2; - - options->utf8_convert = true; - options->use_padding = true; - options->cued_seekpoints = true; - options->show_long_help = false; - options->show_version = false; - options->data_format_is_binary = false; - options->data_format_is_binary_headerless = false; - options->application_data_format_is_hexdump = false; - - options->ops.operations = 0; - options->ops.num_operations = 0; - options->ops.capacity = 0; - - options->args.arguments = 0; - options->args.num_arguments = 0; - options->args.capacity = 0; - - options->args.checks.num_shorthand_ops = 0; - options->args.checks.num_major_ops = 0; - options->args.checks.has_block_type = false; - options->args.checks.has_except_block_type = false; - - options->num_files = 0; - options->filenames = 0; -} - -FLAC__bool parse_options(int argc, char *argv[], CommandLineOptions *options) -{ - int ret; - int option_index = 1; - FLAC__bool had_error = false; - - while ((ret = share__getopt_long(argc, argv, "", long_options_, &option_index)) != -1) { - switch (ret) { - case 0: - had_error |= !parse_option(option_index, share__optarg, options); - break; - case '?': - case ':': - had_error = true; - break; - default: - FLAC__ASSERT(0); - break; - } - } - - if(options->prefix_with_filename == 2) - options->prefix_with_filename = (argc - share__optind > 1); - - if(share__optind >= argc && !options->show_long_help && !options->show_version) { - flac_fprintf(stderr,"ERROR: you must specify at least one FLAC file;\n"); - flac_fprintf(stderr," metaflac cannot be used as a pipe\n"); - had_error = true; - } - - options->num_files = argc - share__optind; - - if(options->num_files > 0) { - unsigned i = 0; - if(0 == (options->filenames = safe_malloc_mul_2op_(sizeof(char*), /*times*/options->num_files))) - die("out of memory allocating space for file names list"); - while(share__optind < argc) - options->filenames[i++] = local_strdup(argv[share__optind++]); - } - - if(options->args.checks.num_major_ops > 0) { - if(options->args.checks.num_major_ops > 1) { - flac_fprintf(stderr, "ERROR: you may only specify one major operation at a time\n"); - had_error = true; - } - else if(options->args.checks.num_shorthand_ops > 0) { - flac_fprintf(stderr, "ERROR: you may not mix shorthand and major operations\n"); - had_error = true; - } - } - - /* check for only one FLAC file used with certain options */ - if(!had_error && options->num_files > 1) { - if(0 != find_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM)) { - flac_fprintf(stderr, "ERROR: you may only specify one FLAC file when using '--import-cuesheet-from'\n"); - had_error = true; - } - if(0 != find_shorthand_operation(options, OP__EXPORT_CUESHEET_TO)) { - flac_fprintf(stderr, "ERROR: you may only specify one FLAC file when using '--export-cuesheet-to'\n"); - had_error = true; - } - if(0 != find_shorthand_operation(options, OP__EXPORT_PICTURE_TO)) { - flac_fprintf(stderr, "ERROR: you may only specify one FLAC file when using '--export-picture-to'\n"); - had_error = true; - } - if( - 0 != find_shorthand_operation(options, OP__IMPORT_VC_FROM) && - 0 == strcmp(find_shorthand_operation(options, OP__IMPORT_VC_FROM)->argument.filename.value, "-") - ) { - flac_fprintf(stderr, "ERROR: you may only specify one FLAC file when using '--import-tags-from=-'\n"); - had_error = true; - } - } - - if(options->args.checks.has_block_type && options->args.checks.has_except_block_type) { - flac_fprintf(stderr, "ERROR: you may not specify both '--block-type' and '--except-block-type'\n"); - had_error = true; - } - - if(had_error) - short_usage(0); - - /* - * We need to create an OP__ADD_SEEKPOINT operation if there is - * not one already, and --import-cuesheet-from was specified but - * --no-cued-seekpoints was not: - */ - if(options->cued_seekpoints) { - Operation *op = find_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM); - if(0 != op) { - Operation *op2 = find_shorthand_operation(options, OP__ADD_SEEKPOINT); - if(0 == op2) - op2 = append_shorthand_operation(options, OP__ADD_SEEKPOINT); - op->argument.import_cuesheet_from.add_seekpoint_link = &(op2->argument.add_seekpoint); - } - } - - return had_error; -} - -void free_options(CommandLineOptions *options) -{ - unsigned i; - Operation *op; - Argument *arg; - - FLAC__ASSERT(0 == options->ops.operations || options->ops.num_operations > 0); - FLAC__ASSERT(0 == options->args.arguments || options->args.num_arguments > 0); - - for(i = 0, op = options->ops.operations; i < options->ops.num_operations; i++, op++) { - switch(op->type) { - case OP__SHOW_VC_FIELD: - case OP__REMOVE_VC_FIELD: - case OP__REMOVE_VC_FIRSTFIELD: - case OP__REMOVE_VC_ALL_EXCEPT: - if(0 != op->argument.vc_field_name.value) - free(op->argument.vc_field_name.value); - break; - case OP__SET_VC_FIELD: - if(0 != op->argument.vc_field.field) - free(op->argument.vc_field.field); - if(0 != op->argument.vc_field.field_name) - free(op->argument.vc_field.field_name); - if(0 != op->argument.vc_field.field_value) - free(op->argument.vc_field.field_value); - break; - case OP__IMPORT_VC_FROM: - case OP__EXPORT_VC_TO: - case OP__EXPORT_CUESHEET_TO: - if(0 != op->argument.filename.value) - free(op->argument.filename.value); - break; - case OP__IMPORT_CUESHEET_FROM: - if(0 != op->argument.import_cuesheet_from.filename) - free(op->argument.import_cuesheet_from.filename); - break; - case OP__IMPORT_PICTURE_FROM: - if(0 != op->argument.specification.value) - free(op->argument.specification.value); - break; - case OP__EXPORT_PICTURE_TO: - if(0 != op->argument.export_picture_to.filename) - free(op->argument.export_picture_to.filename); - break; - case OP__ADD_SEEKPOINT: - if(0 != op->argument.add_seekpoint.specification) - free(op->argument.add_seekpoint.specification); - break; - default: - break; - } - } - - for(i = 0, arg = options->args.arguments; i < options->args.num_arguments; i++, arg++) { - switch(arg->type) { - case ARG__BLOCK_NUMBER: - if(0 != arg->value.block_number.entries) - free(arg->value.block_number.entries); - break; - case ARG__BLOCK_TYPE: - case ARG__EXCEPT_BLOCK_TYPE: - if(0 != arg->value.block_type.entries) - free(arg->value.block_type.entries); - break; - case ARG__FROM_FILE: - if(0 != arg->value.from_file.file_name) - free(arg->value.from_file.file_name); - break; - default: - break; - } - } - - if(0 != options->ops.operations) - free(options->ops.operations); - - if(0 != options->args.arguments) - free(options->args.arguments); - - if(0 != options->filenames) { - for(i = 0; i < options->num_files; i++) { - if(0 != options->filenames[i]) - free(options->filenames[i]); - } - free(options->filenames); - } -} - -/* - * local routines - */ - -FLAC__bool parse_option(int option_index, const char *option_argument, CommandLineOptions *options) -{ - const char *opt = long_options_[option_index].name; - Operation *op; - Argument *arg; - FLAC__bool ok = true; - - if(0 == strcmp(opt, "preserve-modtime")) { - options->preserve_modtime = true; - } - else if(0 == strcmp(opt, "with-filename")) { - options->prefix_with_filename = true; - } - else if(0 == strcmp(opt, "no-filename")) { - options->prefix_with_filename = false; - } - else if(0 == strcmp(opt, "no-utf8-convert")) { - options->utf8_convert = false; - } - else if(0 == strcmp(opt, "dont-use-padding")) { - options->use_padding = false; - } - else if(0 == strcmp(opt, "no-cued-seekpoints")) { - options->cued_seekpoints = false; - } - else if(0 == strcmp(opt, "show-md5sum")) { - (void) append_shorthand_operation(options, OP__SHOW_MD5SUM); - } - else if(0 == strcmp(opt, "show-min-blocksize")) { - (void) append_shorthand_operation(options, OP__SHOW_MIN_BLOCKSIZE); - } - else if(0 == strcmp(opt, "show-max-blocksize")) { - (void) append_shorthand_operation(options, OP__SHOW_MAX_BLOCKSIZE); - } - else if(0 == strcmp(opt, "show-min-framesize")) { - (void) append_shorthand_operation(options, OP__SHOW_MIN_FRAMESIZE); - } - else if(0 == strcmp(opt, "show-max-framesize")) { - (void) append_shorthand_operation(options, OP__SHOW_MAX_FRAMESIZE); - } - else if(0 == strcmp(opt, "show-sample-rate")) { - (void) append_shorthand_operation(options, OP__SHOW_SAMPLE_RATE); - } - else if(0 == strcmp(opt, "show-channels")) { - (void) append_shorthand_operation(options, OP__SHOW_CHANNELS); - } - else if(0 == strcmp(opt, "show-bps")) { - (void) append_shorthand_operation(options, OP__SHOW_BPS); - } - else if(0 == strcmp(opt, "show-total-samples")) { - (void) append_shorthand_operation(options, OP__SHOW_TOTAL_SAMPLES); - } - else if(0 == strcmp(opt, "set-md5sum")) { - op = append_shorthand_operation(options, OP__SET_MD5SUM); - FLAC__ASSERT(0 != option_argument); - if(!parse_md5(option_argument, op->argument.streaminfo_md5.value)) { - flac_fprintf(stderr, "ERROR (--%s): bad MD5 sum\n", opt); - ok = false; - } - else - undocumented_warning(opt); - } - else if(0 == strcmp(opt, "set-min-blocksize")) { - op = append_shorthand_operation(options, OP__SET_MIN_BLOCKSIZE); - if(!parse_uint32(option_argument, &(op->argument.streaminfo_uint32.value)) || op->argument.streaminfo_uint32.value < FLAC__MIN_BLOCK_SIZE || op->argument.streaminfo_uint32.value > FLAC__MAX_BLOCK_SIZE) { - flac_fprintf(stderr, "ERROR (--%s): value must be >= %u and <= %u\n", opt, FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE); - ok = false; - } - else - undocumented_warning(opt); - } - else if(0 == strcmp(opt, "set-max-blocksize")) { - op = append_shorthand_operation(options, OP__SET_MAX_BLOCKSIZE); - if(!parse_uint32(option_argument, &(op->argument.streaminfo_uint32.value)) || op->argument.streaminfo_uint32.value < FLAC__MIN_BLOCK_SIZE || op->argument.streaminfo_uint32.value > FLAC__MAX_BLOCK_SIZE) { - flac_fprintf(stderr, "ERROR (--%s): value must be >= %u and <= %u\n", opt, FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE); - ok = false; - } - else - undocumented_warning(opt); - } - else if(0 == strcmp(opt, "set-min-framesize")) { - op = append_shorthand_operation(options, OP__SET_MIN_FRAMESIZE); - if(!parse_uint32(option_argument, &(op->argument.streaminfo_uint32.value)) || op->argument.streaminfo_uint32.value >= (1u<argument.streaminfo_uint32.value)) || op->argument.streaminfo_uint32.value >= (1u<argument.streaminfo_uint32.value)) || !FLAC__format_sample_rate_is_valid(op->argument.streaminfo_uint32.value)) { - flac_fprintf(stderr, "ERROR (--%s): invalid sample rate\n", opt); - ok = false; - } - else - undocumented_warning(opt); - } - else if(0 == strcmp(opt, "set-channels")) { - op = append_shorthand_operation(options, OP__SET_CHANNELS); - if(!parse_uint32(option_argument, &(op->argument.streaminfo_uint32.value)) || op->argument.streaminfo_uint32.value > FLAC__MAX_CHANNELS) { - flac_fprintf(stderr, "ERROR (--%s): value must be > 0 and <= %u\n", opt, FLAC__MAX_CHANNELS); - ok = false; - } - else - undocumented_warning(opt); - } - else if(0 == strcmp(opt, "set-bps")) { - op = append_shorthand_operation(options, OP__SET_BPS); - if(!parse_uint32(option_argument, &(op->argument.streaminfo_uint32.value)) || op->argument.streaminfo_uint32.value < FLAC__MIN_BITS_PER_SAMPLE || op->argument.streaminfo_uint32.value > FLAC__MAX_BITS_PER_SAMPLE) { - flac_fprintf(stderr, "ERROR (--%s): value must be >= %u and <= %u\n", opt, FLAC__MIN_BITS_PER_SAMPLE, FLAC__MAX_BITS_PER_SAMPLE); - ok = false; - } - else - undocumented_warning(opt); - } - else if(0 == strcmp(opt, "set-total-samples")) { - op = append_shorthand_operation(options, OP__SET_TOTAL_SAMPLES); - if(!parse_uint64(option_argument, &(op->argument.streaminfo_uint64.value)) || op->argument.streaminfo_uint64.value >= (((FLAC__uint64)1)<argument.vc_field_name.value), &violation)) { - FLAC__ASSERT(0 != violation); - flac_fprintf(stderr, "ERROR (--%s): malformed vorbis comment field name \"%s\",\n %s\n", opt, option_argument, violation); - ok = false; - } - } - else if(0 == strcmp(opt, "show-all-tags")) { - op = append_shorthand_operation(options, OP__EXPORT_VC_TO); - parse_string("-",&op->argument.filename.value); - } - else if(0 == strcmp(opt, "remove-all-tags")) { - (void) append_shorthand_operation(options, OP__REMOVE_VC_ALL); - } - else if(0 == strcmp(opt, "remove-all-tags-except")) { - const char *violation; - op = append_shorthand_operation(options, OP__REMOVE_VC_ALL_EXCEPT); - FLAC__ASSERT(0 != option_argument); - if(!parse_vorbis_comment_field_names(option_argument, &(op->argument.vc_field_name.value), &violation)) { - FLAC__ASSERT(0 != violation); - flac_fprintf(stderr, "ERROR (--%s): malformed vorbis comment field name \"%s\",\n %s\n", opt, option_argument, violation); - ok = false; - } - } - else if(0 == strcmp(opt, "remove-tag")) { - const char *violation; - op = append_shorthand_operation(options, OP__REMOVE_VC_FIELD); - FLAC__ASSERT(0 != option_argument); - if(!parse_vorbis_comment_field_name(option_argument, &(op->argument.vc_field_name.value), &violation)) { - FLAC__ASSERT(0 != violation); - flac_fprintf(stderr, "ERROR (--%s): malformed vorbis comment field name \"%s\",\n %s\n", opt, option_argument, violation); - ok = false; - } - } - else if(0 == strcmp(opt, "remove-first-tag")) { - const char *violation; - op = append_shorthand_operation(options, OP__REMOVE_VC_FIRSTFIELD); - FLAC__ASSERT(0 != option_argument); - if(!parse_vorbis_comment_field_name(option_argument, &(op->argument.vc_field_name.value), &violation)) { - FLAC__ASSERT(0 != violation); - flac_fprintf(stderr, "ERROR (--%s): malformed vorbis comment field name \"%s\",\n %s\n", opt, option_argument, violation); - ok = false; - } - } - else if(0 == strcmp(opt, "set-tag")) { - const char *violation; - op = append_shorthand_operation(options, OP__SET_VC_FIELD); - FLAC__ASSERT(0 != option_argument); - op->argument.vc_field.field_value_from_file = false; - if(!parse_vorbis_comment_field(option_argument, &(op->argument.vc_field.field), &(op->argument.vc_field.field_name), &(op->argument.vc_field.field_value), &(op->argument.vc_field.field_value_length), &violation)) { - FLAC__ASSERT(0 != violation); - flac_fprintf(stderr, "ERROR (--%s): malformed vorbis comment field \"%s\",\n %s\n", opt, option_argument, violation); - ok = false; - } - } - else if(0 == strcmp(opt, "set-tag-from-file")) { - const char *violation; - op = append_shorthand_operation(options, OP__SET_VC_FIELD); - FLAC__ASSERT(0 != option_argument); - op->argument.vc_field.field_value_from_file = true; - if(!parse_vorbis_comment_field(option_argument, &(op->argument.vc_field.field), &(op->argument.vc_field.field_name), &(op->argument.vc_field.field_value), &(op->argument.vc_field.field_value_length), &violation)) { - FLAC__ASSERT(0 != violation); - flac_fprintf(stderr, "ERROR (--%s): malformed vorbis comment field \"%s\",\n %s\n", opt, option_argument, violation); - ok = false; - } - } - else if(0 == strcmp(opt, "import-tags-from")) { - op = append_shorthand_operation(options, OP__IMPORT_VC_FROM); - FLAC__ASSERT(0 != option_argument); - if(!parse_string(option_argument, &(op->argument.filename.value))) { - flac_fprintf(stderr, "ERROR (--%s): missing filename\n", opt); - ok = false; - } - } - else if(0 == strcmp(opt, "export-tags-to")) { - op = append_shorthand_operation(options, OP__EXPORT_VC_TO); - FLAC__ASSERT(0 != option_argument); - if(!parse_string(option_argument, &(op->argument.filename.value))) { - flac_fprintf(stderr, "ERROR (--%s): missing filename\n", opt); - ok = false; - } - } - else if(0 == strcmp(opt, "import-cuesheet-from")) { - if(0 != find_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM)) { - flac_fprintf(stderr, "ERROR (--%s): may be specified only once\n", opt); - ok = false; - } - op = append_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM); - FLAC__ASSERT(0 != option_argument); - if(!parse_string(option_argument, &(op->argument.import_cuesheet_from.filename))) { - flac_fprintf(stderr, "ERROR (--%s): missing filename\n", opt); - ok = false; - } - } - else if(0 == strcmp(opt, "export-cuesheet-to")) { - op = append_shorthand_operation(options, OP__EXPORT_CUESHEET_TO); - FLAC__ASSERT(0 != option_argument); - if(!parse_string(option_argument, &(op->argument.filename.value))) { - flac_fprintf(stderr, "ERROR (--%s): missing filename\n", opt); - ok = false; - } - } - else if(0 == strcmp(opt, "import-picture-from")) { - op = append_shorthand_operation(options, OP__IMPORT_PICTURE_FROM); - FLAC__ASSERT(0 != option_argument); - if(!parse_string(option_argument, &(op->argument.specification.value))) { - flac_fprintf(stderr, "ERROR (--%s): missing specification\n", opt); - ok = false; - } - } - else if(0 == strcmp(opt, "export-picture-to")) { - arg = find_argument(options, ARG__BLOCK_NUMBER); - op = append_shorthand_operation(options, OP__EXPORT_PICTURE_TO); - FLAC__ASSERT(0 != option_argument); - if(!parse_string(option_argument, &(op->argument.export_picture_to.filename))) { - flac_fprintf(stderr, "ERROR (--%s): missing filename\n", opt); - ok = false; - } - op->argument.export_picture_to.block_number_link = arg? &(arg->value.block_number) : 0; - } - else if(0 == strcmp(opt, "add-seekpoint")) { - const char *violation; - char *spec; - FLAC__ASSERT(0 != option_argument); - if(!parse_add_seekpoint(option_argument, &spec, &violation)) { - FLAC__ASSERT(0 != violation); - flac_fprintf(stderr, "ERROR (--%s): malformed seekpoint specification \"%s\",\n %s\n", opt, option_argument, violation); - ok = false; - } - else { - op = find_shorthand_operation(options, OP__ADD_SEEKPOINT); - if(0 == op) - op = append_shorthand_operation(options, OP__ADD_SEEKPOINT); - local_strcat(&(op->argument.add_seekpoint.specification), spec); - local_strcat(&(op->argument.add_seekpoint.specification), ";"); - free(spec); - } - } - else if(0 == strcmp(opt, "add-replay-gain")) { - (void) append_shorthand_operation(options, OP__ADD_REPLAY_GAIN); - } - else if(0 == strcmp(opt, "scan-replay-gain")) { - (void) append_shorthand_operation(options, OP__SCAN_REPLAY_GAIN); - } - else if(0 == strcmp(opt, "remove-replay-gain")) { - const FLAC__byte * const tags[5] = { - GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS, - GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN, - GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK, - GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN, - GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK - }; - size_t i; - for(i = 0; i < sizeof(tags)/sizeof(tags[0]); i++) { - op = append_shorthand_operation(options, OP__REMOVE_VC_FIELD); - op->argument.vc_field_name.value = local_strdup((const char *)tags[i]); - } - } - else if(0 == strcmp(opt, "add-padding")) { - op = append_shorthand_operation(options, OP__ADD_PADDING); - FLAC__ASSERT(0 != option_argument); - if(!parse_add_padding(option_argument, &(op->argument.add_padding.length))) { - flac_fprintf(stderr, "ERROR (--%s): illegal length \"%s\", length must be >= 0 and < 2^%u\n", opt, option_argument, FLAC__STREAM_METADATA_LENGTH_LEN); - ok = false; - } - } - else if(0 == strcmp(opt, "help")) { - options->show_long_help = true; - } - else if(0 == strcmp(opt, "version")) { - options->show_version = true; - } - else if(0 == strcmp(opt, "list")) { - (void) append_major_operation(options, OP__LIST); - } - else if(0 == strcmp(opt, "append")) { - (void) append_major_operation(options, OP__APPEND); - } - else if(0 == strcmp(opt, "remove")) { - (void) append_major_operation(options, OP__REMOVE); - } - else if(0 == strcmp(opt, "remove-all")) { - (void) append_major_operation(options, OP__REMOVE_ALL); - } - else if(0 == strcmp(opt, "merge-padding")) { - (void) append_major_operation(options, OP__MERGE_PADDING); - } - else if(0 == strcmp(opt, "sort-padding")) { - (void) append_major_operation(options, OP__SORT_PADDING); - } - else if(0 == strcmp(opt, "block-number")) { - arg = append_argument(options, ARG__BLOCK_NUMBER); - FLAC__ASSERT(0 != option_argument); - if(!parse_block_number(option_argument, &(arg->value.block_number))) { - flac_fprintf(stderr, "ERROR: malformed block number specification \"%s\"\n", option_argument); - ok = false; - } - } - else if(0 == strcmp(opt, "block-type")) { - arg = append_argument(options, ARG__BLOCK_TYPE); - FLAC__ASSERT(0 != option_argument); - if(!parse_block_type(option_argument, &(arg->value.block_type))) { - flac_fprintf(stderr, "ERROR (--%s): malformed block type specification \"%s\"\n", opt, option_argument); - ok = false; - } - options->args.checks.has_block_type = true; - } - else if(0 == strcmp(opt, "except-block-type")) { - arg = append_argument(options, ARG__EXCEPT_BLOCK_TYPE); - FLAC__ASSERT(0 != option_argument); - if(!parse_block_type(option_argument, &(arg->value.block_type))) { - flac_fprintf(stderr, "ERROR (--%s): malformed block type specification \"%s\"\n", opt, option_argument); - ok = false; - } - options->args.checks.has_except_block_type = true; - } - else if(0 == strcmp(opt, "data-format")) { - arg = append_argument(options, ARG__DATA_FORMAT); - FLAC__ASSERT(0 != option_argument); - if(!parse_data_format(option_argument, &(arg->value.data_format))) { - flac_fprintf(stderr, "ERROR (--%s): illegal data format \"%s\"\n", opt, option_argument); - ok = false; - } - options->data_format_is_binary = arg->value.data_format.is_binary; - options->data_format_is_binary_headerless = arg->value.data_format.is_headerless; - } - else if(0 == strcmp(opt, "application-data-format")) { - FLAC__ASSERT(0 != option_argument); - if(!parse_application_data_format(option_argument, &(options->application_data_format_is_hexdump))) { - flac_fprintf(stderr, "ERROR (--%s): illegal application data format \"%s\"\n", opt, option_argument); - ok = false; - } - } - else if(0 == strcmp(opt, "from-file")) { - arg = append_argument(options, ARG__FROM_FILE); - FLAC__ASSERT(0 != option_argument); - arg->value.from_file.file_name = local_strdup(option_argument); - } - else { - FLAC__ASSERT(0); - } - - return ok; -} - -void append_new_operation(CommandLineOptions *options, Operation operation) -{ - if(options->ops.capacity == 0) { - options->ops.capacity = 50; - if(0 == (options->ops.operations = malloc(sizeof(Operation) * options->ops.capacity))) - die("out of memory allocating space for option list"); - memset(options->ops.operations, 0, sizeof(Operation) * options->ops.capacity); - } - if(options->ops.capacity <= options->ops.num_operations) { - unsigned original_capacity = options->ops.capacity; - if(options->ops.capacity > UINT32_MAX / 2) /* overflow check */ - die("out of memory allocating space for option list"); - options->ops.capacity *= 2; - if(0 == (options->ops.operations = safe_realloc_mul_2op_(options->ops.operations, sizeof(Operation), /*times*/options->ops.capacity))) - die("out of memory allocating space for option list"); - memset(options->ops.operations + original_capacity, 0, sizeof(Operation) * (options->ops.capacity - original_capacity)); - } - - options->ops.operations[options->ops.num_operations++] = operation; -} - -void append_new_argument(CommandLineOptions *options, Argument argument) -{ - if(options->args.capacity == 0) { - options->args.capacity = 50; - if(0 == (options->args.arguments = malloc(sizeof(Argument) * options->args.capacity))) - die("out of memory allocating space for option list"); - memset(options->args.arguments, 0, sizeof(Argument) * options->args.capacity); - } - if(options->args.capacity <= options->args.num_arguments) { - unsigned original_capacity = options->args.capacity; - if(options->args.capacity > UINT32_MAX / 2) /* overflow check */ - die("out of memory allocating space for option list"); - options->args.capacity *= 2; - if(0 == (options->args.arguments = safe_realloc_mul_2op_(options->args.arguments, sizeof(Argument), /*times*/options->args.capacity))) - die("out of memory allocating space for option list"); - memset(options->args.arguments + original_capacity, 0, sizeof(Argument) * (options->args.capacity - original_capacity)); - } - - options->args.arguments[options->args.num_arguments++] = argument; -} - -Operation *append_major_operation(CommandLineOptions *options, OperationType type) -{ - Operation op; - memset(&op, 0, sizeof(op)); - op.type = type; - append_new_operation(options, op); - options->args.checks.num_major_ops++; - return options->ops.operations + (options->ops.num_operations - 1); -} - -Operation *append_shorthand_operation(CommandLineOptions *options, OperationType type) -{ - Operation op; - memset(&op, 0, sizeof(op)); - op.type = type; - append_new_operation(options, op); - options->args.checks.num_shorthand_ops++; - return options->ops.operations + (options->ops.num_operations - 1); -} - -Argument *find_argument(CommandLineOptions *options, ArgumentType type) -{ - unsigned i; - for(i = 0; i < options->args.num_arguments; i++) - if(options->args.arguments[i].type == type) - return &options->args.arguments[i]; - return 0; -} - -Operation *find_shorthand_operation(CommandLineOptions *options, OperationType type) -{ - unsigned i; - for(i = 0; i < options->ops.num_operations; i++) - if(options->ops.operations[i].type == type) - return &options->ops.operations[i]; - return 0; -} - -Argument *append_argument(CommandLineOptions *options, ArgumentType type) -{ - Argument arg; - memset(&arg, 0, sizeof(arg)); - arg.type = type; - append_new_argument(options, arg); - return options->args.arguments + (options->args.num_arguments - 1); -} - -FLAC__bool parse_md5(const char *src, FLAC__byte dest[16]) -{ - unsigned i, d; - int c; - FLAC__ASSERT(0 != src); - if(strlen(src) != 32) - return false; - /* strtoul() accepts negative numbers which we do not want, so we do it the hard way */ - for(i = 0; i < 16; i++) { - c = (int)(*src++); - if(isdigit(c)) - d = (unsigned)(c - '0'); - else if(c >= 'a' && c <= 'f') - d = (unsigned)(c - 'a') + 10u; - else if(c >= 'A' && c <= 'F') - d = (unsigned)(c - 'A') + 10u; - else - return false; - d <<= 4; - c = (int)(*src++); - if(isdigit(c)) - d |= (unsigned)(c - '0'); - else if(c >= 'a' && c <= 'f') - d |= (unsigned)(c - 'a') + 10u; - else if(c >= 'A' && c <= 'F') - d |= (unsigned)(c - 'A') + 10u; - else - return false; - dest[i] = (FLAC__byte)d; - } - return true; -} - -FLAC__bool parse_uint32(const char *src, FLAC__uint32 *dest) -{ - FLAC__ASSERT(0 != src); - if(strlen(src) == 0 || strspn(src, "0123456789") != strlen(src)) - return false; - *dest = strtoul(src, 0, 10); - return true; -} - -FLAC__bool parse_uint64(const char *src, FLAC__uint64 *dest) -{ - FLAC__ASSERT(0 != src); - if(strlen(src) == 0 || strspn(src, "0123456789") != strlen(src)) - return false; - *dest = strtoull(src, 0, 10); - return true; -} - -FLAC__bool parse_string(const char *src, char **dest) -{ - if(0 == src || strlen(src) == 0) - return false; - *dest = strdup(src); - return true; -} - -FLAC__bool parse_vorbis_comment_field_name(const char *field_ref, char **name, const char **violation) -{ - static const char * const violations[] = { - "field name contains invalid character" - }; - - char *q, *s; - - s = local_strdup(field_ref); - - for(q = s; *q; q++) { - if(*q < 0x20 || *q > 0x7d || *q == 0x3d) { - free(s); - *violation = violations[0]; - return false; - } - } - - *name = s; - - return true; -} - -FLAC__bool parse_vorbis_comment_field_names(const char *field_ref, char **names, const char **violation) -{ - static const char * const violations[] = { - "field name contains invalid character" - }; - - char *q, *s; - - s = local_strdup(field_ref); - - for(q = s; *q; q++) { - if(*q < 0x20 || *q > 0x7d) { - free(s); - *violation = violations[0]; - return false; - } - } - - *names = s; - - return true; -} - -FLAC__bool parse_add_seekpoint(const char *in, char **out, const char **violation) -{ - static const char *garbled_ = "garbled specification"; - const unsigned n = strlen(in); - - FLAC__ASSERT(0 != in); - FLAC__ASSERT(0 != out); - - if(n == 0) { - *violation = "specification is empty"; - return false; - } - - if(n > strspn(in, "0123456789.Xsx")) { - *violation = "specification contains invalid character"; - return false; - } - - if(in[n-1] == 'X') { - if(n > 1) { - *violation = garbled_; - return false; - } - } - else if(in[n-1] == 's') { - if(n-1 > strspn(in, "0123456789.")) { - *violation = garbled_; - return false; - } - } - else if(in[n-1] == 'x') { - if(n-1 > strspn(in, "0123456789")) { - *violation = garbled_; - return false; - } - } - else { - if(n > strspn(in, "0123456789")) { - *violation = garbled_; - return false; - } - } - - *out = local_strdup(in); - return true; -} - -FLAC__bool parse_add_padding(const char *in, unsigned *out) -{ - FLAC__ASSERT(0 != in); - FLAC__ASSERT(0 != out); - *out = (unsigned)strtoul(in, 0, 10); - return *out < (1u << FLAC__STREAM_METADATA_LENGTH_LEN); -} - -FLAC__bool parse_block_number(const char *in, Argument_BlockNumber *out) -{ - char *p, *q, *s, *end; - long i; - unsigned entry; - - if(*in == '\0') - return false; - - s = local_strdup(in); - - /* first count the entries */ - for(out->num_entries = 1, p = strchr(s, ','); p; out->num_entries++, p = strchr(++p, ',')) - ; - - /* make space */ - FLAC__ASSERT(out->num_entries > 0); - if(0 == (out->entries = safe_malloc_mul_2op_(sizeof(unsigned), /*times*/out->num_entries))) - die("out of memory allocating space for option list"); - - /* load 'em up */ - entry = 0; - q = s; - while(q) { - FLAC__ASSERT(entry < out->num_entries); - if(0 != (p = strchr(q, ','))) - *p++ = '\0'; - if(!isdigit((int)(*q)) || (i = strtol(q, &end, 10)) < 0 || *end) { - free(s); - return false; - } - out->entries[entry++] = (unsigned)i; - q = p; - } - FLAC__ASSERT(entry == out->num_entries); - - free(s); - return true; -} - -FLAC__bool parse_block_type(const char *in, Argument_BlockType *out) -{ - char *p, *q, *r, *s; - unsigned entry; - - if(*in == '\0') - return false; - - s = local_strdup(in); - - /* first count the entries */ - for(out->num_entries = 1, p = strchr(s, ','); p; out->num_entries++, p = strchr(++p, ',')) - ; - - /* make space */ - FLAC__ASSERT(out->num_entries > 0); - if(0 == (out->entries = safe_malloc_mul_2op_(sizeof(Argument_BlockTypeEntry), /*times*/out->num_entries))) - die("out of memory allocating space for option list"); - - /* load 'em up */ - entry = 0; - q = s; - while(q) { - FLAC__ASSERT(entry < out->num_entries); - if(0 != (p = strchr(q, ','))) - *p++ = 0; - r = strchr(q, ':'); - if(r) - *r++ = '\0'; - if(0 != r && 0 != strcmp(q, "APPLICATION")) { - free(s); - return false; - } - if(0 == strcmp(q, "STREAMINFO")) { - out->entries[entry++].type = FLAC__METADATA_TYPE_STREAMINFO; - } - else if(0 == strcmp(q, "PADDING")) { - out->entries[entry++].type = FLAC__METADATA_TYPE_PADDING; - } - else if(0 == strcmp(q, "APPLICATION")) { - out->entries[entry].type = FLAC__METADATA_TYPE_APPLICATION; - out->entries[entry].filter_application_by_id = (0 != r); - if(0 != r) { - if(strlen(r) == sizeof (out->entries[entry].application_id)) { - memcpy(out->entries[entry].application_id, r, sizeof (out->entries[entry].application_id)); - } - else if(strlen(r) == 10 && FLAC__STRNCASECMP(r, "0x", 2) == 0 && strspn(r+2, "0123456789ABCDEFabcdef") == 8) { - FLAC__uint32 x = strtoul(r+2, 0, 16); - out->entries[entry].application_id[3] = (FLAC__byte)(x & 0xff); - out->entries[entry].application_id[2] = (FLAC__byte)((x>>=8) & 0xff); - out->entries[entry].application_id[1] = (FLAC__byte)((x>>=8) & 0xff); - out->entries[entry].application_id[0] = (FLAC__byte)((x>>=8) & 0xff); - } - else { - free(s); - return false; - } - } - entry++; - } - else if(0 == strcmp(q, "SEEKTABLE")) { - out->entries[entry++].type = FLAC__METADATA_TYPE_SEEKTABLE; - } - else if(0 == strcmp(q, "VORBIS_COMMENT")) { - out->entries[entry++].type = FLAC__METADATA_TYPE_VORBIS_COMMENT; - } - else if(0 == strcmp(q, "CUESHEET")) { - out->entries[entry++].type = FLAC__METADATA_TYPE_CUESHEET; - } - else if(0 == strcmp(q, "PICTURE")) { - out->entries[entry++].type = FLAC__METADATA_TYPE_PICTURE; - } - else { - free(s); - return false; - } - q = p; - } - FLAC__ASSERT(entry == out->num_entries); - - free(s); - return true; -} - -FLAC__bool parse_data_format(const char *in, Argument_DataFormat *out) -{ - if(0 == strcmp(in, "binary-headerless")) { - out->is_binary = false; - out->is_headerless = true; - } - else if(0 == strcmp(in, "binary")) { - out->is_binary = true; - out->is_headerless = false; - } - else if(0 == strcmp(in, "text")) { - out->is_binary = false; - out->is_headerless = false; - } - else - return false; - return true; -} - -FLAC__bool parse_application_data_format(const char *in, FLAC__bool *out) -{ - if(0 == strcmp(in, "hexdump")) - *out = true; - else if(0 == strcmp(in, "text")) - *out = false; - else - return false; - return true; -} - -void undocumented_warning(const char *opt) -{ - flac_fprintf(stderr, "WARNING: undocumented option --%s should be used with caution,\n only for repairing a damaged STREAMINFO block\n", opt); -} diff --git a/Engine/lib/flac/src/metaflac/options.h b/Engine/lib/flac/src/metaflac/options.h deleted file mode 100644 index 984f2e114..000000000 --- a/Engine/lib/flac/src/metaflac/options.h +++ /dev/null @@ -1,221 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef metaflac__options_h -#define metaflac__options_h - -#include "FLAC/format.h" - -#if 0 -/*[JEC] was:#if HAVE_GETOPT_LONG*/ -/*[JEC] see flac/include/share/getopt.h as to why the change */ -# include -#else -# include "share/getopt.h" -#endif - -extern struct share__option long_options_[]; - -typedef enum { - OP__SHOW_MD5SUM, - OP__SHOW_MIN_BLOCKSIZE, - OP__SHOW_MAX_BLOCKSIZE, - OP__SHOW_MIN_FRAMESIZE, - OP__SHOW_MAX_FRAMESIZE, - OP__SHOW_SAMPLE_RATE, - OP__SHOW_CHANNELS, - OP__SHOW_BPS, - OP__SHOW_TOTAL_SAMPLES, - OP__SET_MD5SUM, - OP__SET_MIN_BLOCKSIZE, - OP__SET_MAX_BLOCKSIZE, - OP__SET_MIN_FRAMESIZE, - OP__SET_MAX_FRAMESIZE, - OP__SET_SAMPLE_RATE, - OP__SET_CHANNELS, - OP__SET_BPS, - OP__SET_TOTAL_SAMPLES, - OP__SHOW_VC_VENDOR, - OP__SHOW_VC_FIELD, - OP__REMOVE_VC_ALL, - OP__REMOVE_VC_ALL_EXCEPT, - OP__REMOVE_VC_FIELD, - OP__REMOVE_VC_FIRSTFIELD, - OP__SET_VC_FIELD, - OP__IMPORT_VC_FROM, - OP__EXPORT_VC_TO, - OP__IMPORT_CUESHEET_FROM, - OP__EXPORT_CUESHEET_TO, - OP__IMPORT_PICTURE_FROM, - OP__EXPORT_PICTURE_TO, - OP__ADD_SEEKPOINT, - OP__ADD_REPLAY_GAIN, - OP__SCAN_REPLAY_GAIN, - OP__ADD_PADDING, - OP__LIST, - OP__APPEND, - OP__REMOVE, - OP__REMOVE_ALL, - OP__MERGE_PADDING, - OP__SORT_PADDING -} OperationType; - -typedef enum { - ARG__BLOCK_NUMBER, - ARG__BLOCK_TYPE, - ARG__EXCEPT_BLOCK_TYPE, - ARG__DATA_FORMAT, - ARG__FROM_FILE -} ArgumentType; - -typedef struct { - FLAC__byte value[16]; -} Argument_StreaminfoMD5; - -typedef struct { - FLAC__uint32 value; -} Argument_StreaminfoUInt32; - -typedef struct { - FLAC__uint64 value; -} Argument_StreaminfoUInt64; - -typedef struct { - char *value; -} Argument_VcFieldName; - -typedef struct { - char *field; /* the whole field as passed on the command line, i.e. "NAME=VALUE" */ - char *field_name; - /* according to the vorbis spec, field values can contain \0 so simple C strings are not enough here */ - unsigned field_value_length; - char *field_value; - FLAC__bool field_value_from_file; /* true if field_value holds a filename for the value, false for plain value */ -} Argument_VcField; - -typedef struct { - char *value; -} Argument_String; - -typedef struct { - unsigned num_entries; - unsigned *entries; -} Argument_BlockNumber; - -typedef struct { - FLAC__MetadataType type; - char application_id[4]; /* only relevant if type == FLAC__STREAM_METADATA_TYPE_APPLICATION */ - FLAC__bool filter_application_by_id; -} Argument_BlockTypeEntry; - -typedef struct { - unsigned num_entries; - Argument_BlockTypeEntry *entries; -} Argument_BlockType; - -typedef struct { - FLAC__bool is_binary; - FLAC__bool is_headerless; -} Argument_DataFormat; - -typedef struct { - char *file_name; -} Argument_FromFile; - -typedef struct { - char *specification; -} Argument_AddSeekpoint; - -typedef struct { - char *filename; - Argument_AddSeekpoint *add_seekpoint_link; -} Argument_ImportCuesheetFrom; - -typedef struct { - char *filename; - const Argument_BlockNumber *block_number_link; /* may be NULL to mean 'first PICTURE block' */ -} Argument_ExportPictureTo; - -typedef struct { - unsigned length; -} Argument_AddPadding; - -typedef struct { - OperationType type; - union { - Argument_StreaminfoMD5 streaminfo_md5; - Argument_StreaminfoUInt32 streaminfo_uint32; - Argument_StreaminfoUInt64 streaminfo_uint64; - Argument_VcFieldName vc_field_name; - Argument_VcField vc_field; - Argument_String filename; - Argument_String specification; - Argument_ImportCuesheetFrom import_cuesheet_from; - Argument_ExportPictureTo export_picture_to; - Argument_AddSeekpoint add_seekpoint; - Argument_AddPadding add_padding; - } argument; -} Operation; - -typedef struct { - ArgumentType type; - union { - Argument_BlockNumber block_number; - Argument_BlockType block_type; - Argument_DataFormat data_format; - Argument_FromFile from_file; - } value; -} Argument; - -typedef struct { - FLAC__bool preserve_modtime; - FLAC__bool prefix_with_filename; - FLAC__bool utf8_convert; - FLAC__bool use_padding; - FLAC__bool cued_seekpoints; - FLAC__bool show_long_help; - FLAC__bool show_version; - FLAC__bool data_format_is_binary; - FLAC__bool data_format_is_binary_headerless; - FLAC__bool application_data_format_is_hexdump; - struct { - Operation *operations; - unsigned num_operations; - unsigned capacity; - } ops; - struct { - struct { - unsigned num_shorthand_ops; - unsigned num_major_ops; - FLAC__bool has_block_type; - FLAC__bool has_except_block_type; - } checks; - Argument *arguments; - unsigned num_arguments; - unsigned capacity; - } args; - unsigned num_files; - char **filenames; -} CommandLineOptions; - -void init_options(CommandLineOptions *options); -FLAC__bool parse_options(int argc, char *argv[], CommandLineOptions *options); -void free_options(CommandLineOptions *options); - -#endif diff --git a/Engine/lib/flac/src/metaflac/usage.c b/Engine/lib/flac/src/metaflac/usage.c deleted file mode 100644 index 58afc0ea0..000000000 --- a/Engine/lib/flac/src/metaflac/usage.c +++ /dev/null @@ -1,349 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "utils.h" -#include "usage.h" -#include "FLAC/format.h" -#include -#include -#include "share/compat.h" - -static void usage_header(FILE *out) -{ - fprintf(out, "==============================================================================\n"); - fprintf(out, "metaflac - Command-line FLAC metadata editor version %s\n", FLAC__VERSION_STRING); - fprintf(out, "Copyright (C) 2001-2009 Josh Coalson\n"); - fprintf(out, "Copyright (C) 2011-2023 Xiph.Org Foundation\n"); - fprintf(out, "\n"); - fprintf(out, "This program is free software; you can redistribute it and/or\n"); - fprintf(out, "modify it under the terms of the GNU General Public License\n"); - fprintf(out, "as published by the Free Software Foundation; either version 2\n"); - fprintf(out, "of the License, or (at your option) any later version.\n"); - fprintf(out, "\n"); - fprintf(out, "This program is distributed in the hope that it will be useful,\n"); - fprintf(out, "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"); - fprintf(out, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"); - fprintf(out, "GNU General Public License for more details.\n"); - fprintf(out, "\n"); - fprintf(out, "You should have received a copy of the GNU General Public License along\n"); - fprintf(out, "with this program; if not, write to the Free Software Foundation, Inc.,\n"); - fprintf(out, "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n"); - fprintf(out, "==============================================================================\n"); -} - -static void usage_summary(FILE *out) -{ - fprintf(out, "Usage:\n"); - fprintf(out, " metaflac [options] [operations] FLACfile [FLACfile ...]\n"); - fprintf(out, "\n"); - fprintf(out, "Use metaflac to list, add, remove, or edit metadata in one or more FLAC files.\n"); - fprintf(out, "You may perform one major operation, or many shorthand operations at a time.\n"); - fprintf(out, "\n"); - fprintf(out, "Options:\n"); - fprintf(out, "--preserve-modtime Preserve the original modification time in spite of edits\n"); - fprintf(out, "--with-filename Prefix each output line with the FLAC file name\n"); - fprintf(out, " (the default if more than one FLAC file is specified).\n"); - fprintf(out, " This option has no effect for options exporting to a\n"); - fprintf(out, " file, like --export-tags-to.\n"); - fprintf(out, "--no-filename Do not prefix each output line with the FLAC file name\n"); - fprintf(out, " (the default if only one FLAC file is specified)\n"); - fprintf(out, "--no-utf8-convert Do not convert tags from UTF-8 to local charset,\n"); - fprintf(out, " or vice versa. This is useful for scripts, and setting\n"); - fprintf(out, " tags in situations where the locale is wrong.\n"); - fprintf(out, "--dont-use-padding By default metaflac tries to use padding where possible\n"); - fprintf(out, " to avoid rewriting the entire file if the metadata size\n"); - fprintf(out, " changes. Use this option to tell metaflac to not take\n"); - fprintf(out, " advantage of padding this way.\n"); -} - -int short_usage(const char *message, ...) -{ - va_list args; - - if(message) { - va_start(args, message); - - (void) vfprintf(stderr, message, args); - - va_end(args); - - } - usage_header(stderr); - flac_fprintf(stderr, "\n"); - flac_fprintf(stderr, "This is the short help; for full help use 'metaflac --help'\n"); - flac_fprintf(stderr, "\n"); - usage_summary(stderr); - - return message? 1 : 0; -} - -int long_usage(const char *message, ...) -{ - FILE *out = (message? stderr : stdout); - va_list args; - - if(message) { - va_start(args, message); - - (void) vfprintf(stderr, message, args); - - va_end(args); - - } - usage_header(out); - fprintf(out, "\n"); - usage_summary(out); - fprintf(out, "\n"); - fprintf(out, "Shorthand operations:\n"); - fprintf(out, "--show-md5sum Show the MD5 signature from the STREAMINFO block.\n"); - fprintf(out, "--show-min-blocksize Show the minimum block size from the STREAMINFO block.\n"); - fprintf(out, "--show-max-blocksize Show the maximum block size from the STREAMINFO block.\n"); - fprintf(out, "--show-min-framesize Show the minimum frame size from the STREAMINFO block.\n"); - fprintf(out, "--show-max-framesize Show the maximum frame size from the STREAMINFO block.\n"); - fprintf(out, "--show-sample-rate Show the sample rate from the STREAMINFO block.\n"); - fprintf(out, "--show-channels Show the number of channels from the STREAMINFO block.\n"); - fprintf(out, "--show-bps Show the # of bits per sample from the STREAMINFO block.\n"); - fprintf(out, "--show-total-samples Show the total # of samples from the STREAMINFO block.\n"); - fprintf(out, "\n"); - fprintf(out, "--show-vendor-tag Show the vendor string from the VORBIS_COMMENT block.\n"); - fprintf(out, "--show-tag=NAME Show all tags where the field name matches 'NAME'.\n"); - fprintf(out, "--show-all-tags Show all tags. This is an alias for --export-tags-to=-.\n"); - fprintf(out, "--remove-tag=NAME Remove all tags whose field name is 'NAME'.\n"); - fprintf(out, "--remove-first-tag=NAME Remove first tag whose field name is 'NAME'.\n"); - fprintf(out, "--remove-all-tags Remove all tags, leaving only the vendor string.\n"); - fprintf(out, "--remove-all-tags-except=NAME1[=NAME2[=...]] Remove all tags, except the vendor\n"); - fprintf(out, " string and the tag names specified. Tag names must be\n"); - fprintf(out, " separated by an = character.\n"); - fprintf(out, "--set-tag=FIELD Add a tag. The FIELD must comply with the Vorbis comment\n"); - fprintf(out, " spec, of the form \"NAME=VALUE\". If there is currently\n"); - fprintf(out, " no tag block, one will be created.\n"); - fprintf(out, "--set-tag-from-file=FIELD Like --set-tag, except the VALUE is a filename\n"); - fprintf(out, " whose contents will be read verbatim to set the tag value.\n"); - fprintf(out, " Unless --no-utf8-convert is specified, the contents will\n"); - fprintf(out, " be converted to UTF-8 from the local charset. This can\n"); - fprintf(out, " be used to store a cuesheet in a tag (e.g.\n"); - fprintf(out, " --set-tag-from-file=\"CUESHEET=image.cue\"). Do not try\n"); - fprintf(out, " to store binary data in tag fields! Use APPLICATION\n"); - fprintf(out, " blocks for that.\n"); - fprintf(out, "--import-tags-from=FILE Import tags from a file. Use '-' for stdin. Each line\n"); - fprintf(out, " should be of the form NAME=VALUE. Multi-line comments\n"); - fprintf(out, " are currently not supported. Specify --remove-all-tags\n"); - fprintf(out, " and/or --no-utf8-convert before --import-tags-from if\n"); - fprintf(out, " necessary. If FILE is '-' (stdin), only one FLAC file\n"); - fprintf(out, " may be specified.\n"); - fprintf(out, "--export-tags-to=FILE Export tags to a file. Use '-' for stdout. Each line\n"); - fprintf(out, " will be of the form NAME=VALUE. Specify\n"); - fprintf(out, " --no-utf8-convert if necessary.\n"); - fprintf(out, "--import-cuesheet-from=FILE Import a cuesheet from a file. Use '-' for stdin.\n"); - fprintf(out, " Only one FLAC file may be specified. A seekpoint will be\n"); - fprintf(out, " added for each index point in the cuesheet to the\n"); - fprintf(out, " SEEKTABLE unless --no-cued-seekpoints is specified.\n"); - fprintf(out, "--export-cuesheet-to=FILE Export CUESHEET block to a cuesheet file, suitable\n"); - fprintf(out, " for use by CD authoring software. Use '-' for stdout.\n"); - fprintf(out, " Only one FLAC file may be specified on the command line.\n"); - fprintf(out, "--import-picture-from=FILENAME|SPECIFICATION Import a picture and store it in a\n"); - fprintf(out, " PICTURE block. Either a filename for the picture file or\n"); - fprintf(out, " a more complete specification form can be used. The\n"); - fprintf(out, " SPECIFICATION is a string whose parts are separated by |\n"); - fprintf(out, " characters. Some parts may be left empty to invoke\n"); - fprintf(out, " default values. FILENAME is just shorthand for\n"); - fprintf(out, " \"||||FILENAME\". The format of SPECIFICATION is:\n"); - fprintf(out, " [TYPE]|[MIME-TYPE]|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE\n"); - fprintf(out, " TYPE is optional; it is a number from one of:\n"); - fprintf(out, " 0: Other\n"); - fprintf(out, " 1: 32x32 pixels 'file icon' (PNG only)\n"); - fprintf(out, " 2: Other file icon\n"); - fprintf(out, " 3: Cover (front)\n"); - fprintf(out, " 4: Cover (back)\n"); - fprintf(out, " 5: Leaflet page\n"); - fprintf(out, " 6: Media (e.g. label side of CD)\n"); - fprintf(out, " 7: Lead artist/lead performer/soloist\n"); - fprintf(out, " 8: Artist/performer\n"); - fprintf(out, " 9: Conductor\n"); - fprintf(out, " 10: Band/Orchestra\n"); - fprintf(out, " 11: Composer\n"); - fprintf(out, " 12: Lyricist/text writer\n"); - fprintf(out, " 13: Recording Location\n"); - fprintf(out, " 14: During recording\n"); - fprintf(out, " 15: During performance\n"); - fprintf(out, " 16: Movie/video screen capture\n"); - fprintf(out, " 17: A bright coloured fish\n"); - fprintf(out, " 18: Illustration\n"); - fprintf(out, " 19: Band/artist logotype\n"); - fprintf(out, " 20: Publisher/Studio logotype\n"); - fprintf(out, " The default is 3 (front cover). There may only be one picture each\n"); - fprintf(out, " of type 1 and 2 in a file.\n"); - fprintf(out, " MIME-TYPE is optional; if left blank, it will be detected from the\n"); - fprintf(out, " file. For best compatibility with players, use pictures with MIME\n"); - fprintf(out, " type image/jpeg or image/png. The MIME type can also be --> to\n"); - fprintf(out, " mean that FILE is actually a URL to an image, though this use is\n"); - fprintf(out, " discouraged.\n"); - fprintf(out, " DESCRIPTION is optional; the default is an empty string\n"); - fprintf(out, " The next part specifies the resolution and color information. If\n"); - fprintf(out, " the MIME-TYPE is image/jpeg, image/png, or image/gif, you can\n"); - fprintf(out, " usually leave this empty and they can be detected from the file.\n"); - fprintf(out, " Otherwise, you must specify the width in pixels, height in pixels,\n"); - fprintf(out, " and color depth in bits-per-pixel. If the image has indexed colors\n"); - fprintf(out, " you should also specify the number of colors used.\n"); - fprintf(out, " FILE is the path to the picture file to be imported, or the URL if\n"); - fprintf(out, " MIME type is -->\n"); - fprintf(out, "--export-picture-to=FILE Export PICTURE block to a file. Use '-' for stdout.\n"); - fprintf(out, " Only one FLAC file may be specified. The first PICTURE\n"); - fprintf(out, " block will be exported unless --export-picture-to is\n"); - fprintf(out, " preceded by a --block-number=# option to specify the exact\n"); - fprintf(out, " metadata block to extract. Note that the block number is\n"); - fprintf(out, " the one shown by --list.\n"); - fprintf(out, "--add-replay-gain Calculates the title and album gains/peaks of the given\n"); - fprintf(out, " FLAC files as if all the files were part of one album,\n"); - fprintf(out, " then stores them in the VORBIS_COMMENT block. The tags\n"); - fprintf(out, " are the same as those used by vorbisgain. Existing\n"); - fprintf(out, " ReplayGain tags will be replaced. If only one FLAC file\n"); - fprintf(out, " is given, the album and title gains will be the same.\n"); - fprintf(out, " Since this operation requires two passes, it is always\n"); - fprintf(out, " executed last, after all other operations have been\n"); - fprintf(out, " completed and written to disk. All FLAC files specified\n"); - fprintf(out, " must have the same resolution, sample rate, and number\n"); - fprintf(out, " of channels. Only mono and stereo files are allowed,\n"); - fprintf(out, " and the sample rate must be 8, 11.025, 12, 16, 18.9,\n"); - fprintf(out, " 22.05, 24, 28, 32, 36, 37.8, 44.1, 48, 56, 64, 72, 75.6,\n"); - fprintf(out, " 88.2, 96, 112, 128, 144, 151.2, 176.4, 192, 224, 256,\n"); - fprintf(out, " 288, 302.4, 352.8, 384, 448, 512, 576, or 604.8 kHz.\n"); - fprintf(out, "--scan-replay-gain Like --add-replay-gain, but only analyzes the files\n"); - fprintf(out, " rather than writing them to tags.\n"); - fprintf(out, "--remove-replay-gain Removes the ReplayGain tags.\n"); - fprintf(out, "--add-seekpoint={#|X|#x|#s} Add seek points to a SEEKTABLE block\n"); - fprintf(out, " # : a specific sample number for a seek point\n"); - fprintf(out, " X : a placeholder point (always goes at the end of the SEEKTABLE)\n"); - fprintf(out, " #x : # evenly spaced seekpoints, the first being at sample 0\n"); - fprintf(out, " #s : a seekpoint every # seconds; # does not have to be a whole number\n"); - fprintf(out, " If no SEEKTABLE block exists, one will be created. If\n"); - fprintf(out, " one already exists, points will be added to the existing\n"); - fprintf(out, " table, and any duplicates will be turned into placeholder\n"); - fprintf(out, " points. You may use many --add-seekpoint options; the\n"); - fprintf(out, " resulting SEEKTABLE will be the unique-ified union of\n"); - fprintf(out, " all such values. Example: --add-seekpoint=100x\n"); - fprintf(out, " --add-seekpoint=3.5s will add 100 evenly spaced\n"); - fprintf(out, " seekpoints and a seekpoint every 3.5 seconds.\n"); - fprintf(out, "--add-padding=length Add a padding block of the given length (in bytes).\n"); - fprintf(out, " The overall length of the new block will be 4 + length;\n"); - fprintf(out, " the extra 4 bytes is for the metadata block header.\n"); - fprintf(out, "\n"); - fprintf(out, "Major operations:\n"); - fprintf(out, "--version\n"); - fprintf(out, " Show the metaflac version number.\n"); - fprintf(out, "--list\n"); - fprintf(out, " List the contents of one or more metadata blocks to stdout. By default,\n"); - fprintf(out, " all metadata blocks are listed in text format. Use the following options\n"); - fprintf(out, " to change this behavior:\n"); - fprintf(out, "\n"); - fprintf(out, " --block-number=#[,#[...]]\n"); - fprintf(out, " An optional comma-separated list of block numbers to display. The first\n"); - fprintf(out, " block, the STREAMINFO block, is block 0.\n"); - fprintf(out, "\n"); - fprintf(out, " --block-type=type[,type[...]]\n"); - fprintf(out, " --except-block-type=type[,type[...]]\n"); - fprintf(out, " An optional comma-separated list of block types to be included or ignored\n"); - fprintf(out, " with this option. Use only one of --block-type or --except-block-type.\n"); - fprintf(out, " The valid block types are: STREAMINFO, PADDING, APPLICATION, SEEKTABLE,\n"); - fprintf(out, " VORBIS_COMMENT. You may narrow down the types of APPLICATION blocks\n"); - fprintf(out, " displayed as follows:\n"); - fprintf(out, " APPLICATION:abcd The APPLICATION block(s) whose textual repre-\n"); - fprintf(out, " sentation of the 4-byte ID is \"abcd\"\n"); - fprintf(out, " APPLICATION:0xXXXXXXXX The APPLICATION block(s) whose hexadecimal big-\n"); - fprintf(out, " endian representation of the 4-byte ID is\n"); - fprintf(out, " \"0xXXXXXXXX\". For the example \"abcd\" above the\n"); - fprintf(out, " hexadecimal equivalalent is 0x61626364\n"); - fprintf(out, "\n"); - fprintf(out, " NOTE: if both --block-number and --[except-]block-type are specified,\n"); - fprintf(out, " the result is the logical AND of both arguments.\n"); - fprintf(out, "\n"); - fprintf(out, " --data-format=binary|binary-headerless|text\n"); - fprintf(out, " By default a human-readable text representation of the data is displayed.\n"); - fprintf(out, " You may specify --data-format=binary to dump the raw binary form of each\n"); - fprintf(out, " metadata block. Specify --data-format=binary-headerless to omit output of\n"); - fprintf(out, " metadata block headers, including the id of APPLICATION metadata blocks.\n"); - fprintf(out, " The output can be read in using a subsequent call to\n"); - fprintf(out, " \"metaflac --append\"\n"); - fprintf(out, "\n"); - fprintf(out, " --application-data-format=hexdump|text\n"); - fprintf(out, " If the application block you are displaying contains binary data but your\n"); - fprintf(out, " --data-format=text, you can display a hex dump of the application data\n"); - fprintf(out, " contents instead using --application-data-format=hexdump\n"); - fprintf(out, "\n"); - fprintf(out, "--append\n"); - fprintf(out, " Insert a metadata block from a file. This must be a binary block as\n"); - fprintf(out, " exported with --list --data-format=binary. The insertion point is\n"); - fprintf(out, " defined with --block-number=#. The new block will be added after the\n"); - fprintf(out, " given block number. This prevents the illegal insertion of a block\n"); - fprintf(out, " before the first STREAMINFO block. You may not --append another\n"); - fprintf(out, " STREAMINFO block. It is possible to copy a metadata block from one\n"); - fprintf(out, " file to another with this option. For example use\n"); - fprintf(out, " metaflac --list --data-format=binary --block-number=6 file.flac > block\n"); - fprintf(out, " to export the block, and then import it with\n"); - fprintf(out, " metaflac --append anotherfile.flac < block\n"); - fprintf(out, " Insert a metadata block from a file. The input file must be in the same\n"); - fprintf(out, " format as generated with --list.\n"); - fprintf(out, "\n"); - fprintf(out, " --block-number=#\n"); - fprintf(out, " Specify the insertion point (defaults to last block). The new block will\n"); - fprintf(out, " be added after the given block number. This prevents the illegal insertion\n"); - fprintf(out, " of a block before the first STREAMINFO block. You may not --append another\n"); - fprintf(out, " STREAMINFO block.\n"); - fprintf(out, "\n"); -#if 0 - /*@@@ not implemented yet */ - fprintf(out, " --from-file=filename\n"); - fprintf(out, " Mandatory 'option' to specify the input file containing the block contents.\n"); - fprintf(out, "\n"); - fprintf(out, " --data-format=binary|text\n"); - fprintf(out, " By default the block contents are assumed to be in binary format. You can\n"); - fprintf(out, " override this by specifying --data-format=text\n"); - fprintf(out, "\n"); -#endif - fprintf(out, "--remove\n"); - fprintf(out, " Remove one or more metadata blocks from the metadata. Unless\n"); - fprintf(out, " --dont-use-padding is specified, the blocks will be replaced with padding.\n"); - fprintf(out, " You may not remove the STREAMINFO block.\n"); - fprintf(out, "\n"); - fprintf(out, " --block-number=#[,#[...]]\n"); - fprintf(out, " --block-type=type[,type[...]]\n"); - fprintf(out, " --except-block-type=type[,type[...]]\n"); - fprintf(out, " See --list above for usage.\n"); - fprintf(out, "\n"); - fprintf(out, " NOTE: if both --block-number and --[except-]block-type are specified,\n"); - fprintf(out, " the result is the logical AND of both arguments.\n"); - fprintf(out, "\n"); - fprintf(out, "--remove-all\n"); - fprintf(out, " Remove all metadata blocks (except the STREAMINFO block) from the\n"); - fprintf(out, " metadata. Unless --dont-use-padding is specified, the blocks will be\n"); - fprintf(out, " replaced with padding.\n"); - fprintf(out, "\n"); - fprintf(out, "--merge-padding\n"); - fprintf(out, " Merge adjacent PADDING blocks into single blocks.\n"); - fprintf(out, "\n"); - fprintf(out, "--sort-padding\n"); - fprintf(out, " Move all PADDING blocks to the end of the metadata and merge them into a\n"); - fprintf(out, " single block.\n"); - - return message? 1 : 0; -} diff --git a/Engine/lib/flac/src/metaflac/usage.h b/Engine/lib/flac/src/metaflac/usage.h deleted file mode 100644 index 1366417a7..000000000 --- a/Engine/lib/flac/src/metaflac/usage.h +++ /dev/null @@ -1,26 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef metaflac__usage_h -#define metaflac__usage_h - -int short_usage(const char *message, ...); -int long_usage(const char *message, ...); - -#endif diff --git a/Engine/lib/flac/src/metaflac/utils.c b/Engine/lib/flac/src/metaflac/utils.c deleted file mode 100644 index 045719a74..000000000 --- a/Engine/lib/flac/src/metaflac/utils.c +++ /dev/null @@ -1,282 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include "utils.h" -#include "FLAC/assert.h" -#include "share/alloc.h" -#include "share/safe_str.h" -#include "share/utf8.h" -#include "share/compat.h" - -void die(const char *message) -{ - FLAC__ASSERT(0 != message); - flac_fprintf(stderr, "ERROR: %s\n", message); - exit(1); -} - -#ifdef FLAC__VALGRIND_TESTING -size_t local_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - size_t ret = fwrite(ptr, size, nmemb, stream); - if(!ferror(stream)) - fflush(stream); - return ret; -} -#endif - -char *local_strdup(const char *source) -{ - char *ret; - FLAC__ASSERT(0 != source); - if(0 == (ret = strdup(source))) - die("out of memory during strdup()"); - return ret; -} - -void local_strcat(char **dest, const char *source) -{ - size_t ndest, nsource, outlen; - - FLAC__ASSERT(0 != dest); - FLAC__ASSERT(0 != source); - - ndest = *dest ? strlen(*dest) : 0; - nsource = strlen(source); - outlen = ndest + nsource + 1; - - if(nsource == 0) - return; - - *dest = safe_realloc_add_3op_(*dest, ndest, /*+*/nsource, /*+*/1); - if(*dest == NULL) - die("out of memory growing string"); - /* If ndest == 0, strlen in safe_strncat reads - * uninitialized data. To prevent that, set first character - * to zero */ - if(ndest == 0) - *dest[0] = 0; - safe_strncat(*dest, source, outlen); -} - -static inline int local_isprint(int c) -{ - if (c < 32) return 0; - if (c > 127) return 0; - return isprint(c); -} - -void hexdump(const char *filename, const FLAC__byte *buf, unsigned bytes, const char *indent) -{ - unsigned i, left = bytes; - const FLAC__byte *b = buf; - - for(i = 0; i < bytes; i += 16) { - flac_printf("%s%s", filename? filename:"", filename? ":":""); - printf("%s%08X: " - "%02X %02X %02X %02X %02X %02X %02X %02X " - "%02X %02X %02X %02X %02X %02X %02X %02X " - "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", - indent, i, - left > 0? (unsigned char)b[ 0] : 0, - left > 1? (unsigned char)b[ 1] : 0, - left > 2? (unsigned char)b[ 2] : 0, - left > 3? (unsigned char)b[ 3] : 0, - left > 4? (unsigned char)b[ 4] : 0, - left > 5? (unsigned char)b[ 5] : 0, - left > 6? (unsigned char)b[ 6] : 0, - left > 7? (unsigned char)b[ 7] : 0, - left > 8? (unsigned char)b[ 8] : 0, - left > 9? (unsigned char)b[ 9] : 0, - left > 10? (unsigned char)b[10] : 0, - left > 11? (unsigned char)b[11] : 0, - left > 12? (unsigned char)b[12] : 0, - left > 13? (unsigned char)b[13] : 0, - left > 14? (unsigned char)b[14] : 0, - left > 15? (unsigned char)b[15] : 0, - (left > 0) ? (local_isprint(b[ 0]) ? b[ 0] : '.') : ' ', - (left > 1) ? (local_isprint(b[ 1]) ? b[ 1] : '.') : ' ', - (left > 2) ? (local_isprint(b[ 2]) ? b[ 2] : '.') : ' ', - (left > 3) ? (local_isprint(b[ 3]) ? b[ 3] : '.') : ' ', - (left > 4) ? (local_isprint(b[ 4]) ? b[ 4] : '.') : ' ', - (left > 5) ? (local_isprint(b[ 5]) ? b[ 5] : '.') : ' ', - (left > 6) ? (local_isprint(b[ 6]) ? b[ 6] : '.') : ' ', - (left > 7) ? (local_isprint(b[ 7]) ? b[ 7] : '.') : ' ', - (left > 8) ? (local_isprint(b[ 8]) ? b[ 8] : '.') : ' ', - (left > 9) ? (local_isprint(b[ 9]) ? b[ 9] : '.') : ' ', - (left > 10) ? (local_isprint(b[10]) ? b[10] : '.') : ' ', - (left > 11) ? (local_isprint(b[11]) ? b[11] : '.') : ' ', - (left > 12) ? (local_isprint(b[12]) ? b[12] : '.') : ' ', - (left > 13) ? (local_isprint(b[13]) ? b[13] : '.') : ' ', - (left > 14) ? (local_isprint(b[14]) ? b[14] : '.') : ' ', - (left > 15) ? (local_isprint(b[15]) ? b[15] : '.') : ' ' - ); - left -= 16; - b += 16; - } -} - -void print_error_with_chain_status(FLAC__Metadata_Chain *chain, const char *format, ...) -{ - const FLAC__Metadata_ChainStatus status = FLAC__metadata_chain_status(chain); - va_list args; - - FLAC__ASSERT(0 != format); - - va_start(args, format); - - (void) flac_vfprintf(stderr, format, args); - - va_end(args); - - flac_fprintf(stderr, ", status = \"%s\"\n", FLAC__Metadata_ChainStatusString[status]); - - if(status == FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE) { - flac_fprintf(stderr, "\n" - "The FLAC file could not be opened. Most likely the file does not exist\n" - "or is not readable.\n" - ); - } - else if(status == FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE) { - flac_fprintf(stderr, "\n" - "The file does not appear to be a FLAC file.\n" - ); - } - else if(status == FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE) { - flac_fprintf(stderr, "\n" - "The FLAC file does not have write permissions.\n" - ); - } - else if(status == FLAC__METADATA_CHAIN_STATUS_BAD_METADATA) { - flac_fprintf(stderr, "\n" - "The metadata to be written does not conform to the FLAC metadata\n" - "specifications.\n" - ); - } - else if(status == FLAC__METADATA_CHAIN_STATUS_READ_ERROR) { - flac_fprintf(stderr, "\n" - "There was an error while reading the FLAC file.\n" - ); - } - else if(status == FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR) { - flac_fprintf(stderr, "\n" - "There was an error while writing FLAC file; most probably the disk is\n" - "full.\n" - ); - } - else if(status == FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR) { - flac_fprintf(stderr, "\n" - "There was an error removing the temporary FLAC file.\n" - ); - } -} - -FLAC__bool parse_vorbis_comment_field(const char *field_ref, char **field, char **name, char **value, unsigned *length, const char **violation) -{ - static const char * const violations[] = { - "field name contains invalid character", - "field contains no '=' character" - }; - - char *p, *q, *s; - - if(0 != field) - *field = local_strdup(field_ref); - - s = local_strdup(field_ref); - - if(0 == (p = strchr(s, '='))) { - free(s); - *violation = violations[1]; - return false; - } - *p++ = '\0'; - - for(q = s; *q; q++) { - if(*q < 0x20 || *q > 0x7d || *q == 0x3d) { - free(s); - *violation = violations[0]; - return false; - } - } - - *name = local_strdup(s); - *value = local_strdup(p); - *length = strlen(p); - - free(s); - return true; -} - -void write_vc_field(const char *filename, const FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__bool raw, FILE *f) -{ - if(0 != entry->entry) { - if(filename) - flac_fprintf(f, "%s:", filename); - - if(!raw) { - /* - * WATCHOUT: comments that contain an embedded null will - * be truncated by utf_decode(). - */ -#ifdef _WIN32 /* if we are outputting to console, we need to use proper print functions to show unicode characters */ - if (f == stdout || f == stderr) { - flac_fprintf(f, "%s", entry->entry); - } else { -#endif - char *converted; - - if(utf8_decode((const char *)entry->entry, &converted) >= 0) { - (void) local_fwrite(converted, 1, strlen(converted), f); - free(converted); - } - else { - (void) local_fwrite(entry->entry, 1, entry->length, f); - } -#ifdef _WIN32 - } -#endif - } - else { - (void) local_fwrite(entry->entry, 1, entry->length, f); - } - } - - putc('\n', f); -} - -void write_vc_fields(const char *filename, const char *field_name, const FLAC__StreamMetadata_VorbisComment_Entry entry[], unsigned num_entries, FLAC__bool raw, FILE *f) -{ - unsigned i; - const unsigned field_name_length = (0 != field_name)? strlen(field_name) : 0; - - for(i = 0; i < num_entries; i++) { - if(0 == field_name || FLAC__metadata_object_vorbiscomment_entry_matches(entry[i], field_name, field_name_length)) - write_vc_field(filename, entry + i, raw, f); - } -} diff --git a/Engine/lib/flac/src/metaflac/utils.h b/Engine/lib/flac/src/metaflac/utils.h deleted file mode 100644 index 972a4501c..000000000 --- a/Engine/lib/flac/src/metaflac/utils.h +++ /dev/null @@ -1,47 +0,0 @@ -/* metaflac - Command-line FLAC metadata editor - * Copyright (C) 2001-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef metaflac__utils_h -#define metaflac__utils_h - -#include "FLAC/metadata.h" -#include /* for FILE */ - -#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -#undef stderr -#define stderr stdout -#endif - -void die(const char *message); -#ifdef FLAC__VALGRIND_TESTING -size_t local_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); -#else -#define local_fwrite fwrite -#endif -char *local_strdup(const char *source); -void local_strcat(char **dest, const char *source); -void hexdump(const char *filename, const FLAC__byte *buf, unsigned bytes, const char *indent); -void print_error_with_chain_status(FLAC__Metadata_Chain *chain, const char *format, ...); - -FLAC__bool parse_vorbis_comment_field(const char *field_ref, char **field, char **name, char **value, unsigned *length, const char **violation); - -void write_vc_field(const char *filename, const FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__bool raw, FILE *f); -void write_vc_fields(const char *filename, const char *field_name, const FLAC__StreamMetadata_VorbisComment_Entry entry[], unsigned num_entries, FLAC__bool raw, FILE *f); - -#endif diff --git a/Engine/lib/flac/src/metaflac/version.rc b/Engine/lib/flac/src/metaflac/version.rc deleted file mode 100644 index 511720247..000000000 --- a/Engine/lib/flac/src/metaflac/version.rc +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include "config.h" - -#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE) -# ifdef GIT_COMMIT_TAG -# define VERSIONSTRING GIT_COMMIT_TAG -# else -# define VERSIONSTRING "git-" GIT_COMMIT_HASH -# endif -#else -# define VERSIONSTRING PACKAGE_VERSION -#endif - -#define xstr(s) str(s) -#define str(s) #s - -VS_VERSION_INFO VERSIONINFO -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -FILEFLAGS 0 -FILEOS VOS__WINDOWS32 -FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "metaflac command line tool for Windows" - VALUE "ProductName", "Free Lossless Audio Codec" - VALUE "ProductVersion", VERSIONSTRING - VALUE "CompanyName", "Xiph.Org" - VALUE "LegalCopyright", "2000-2009 Josh Coalson, 2011-2023 Xiph.Org Foundation" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/Engine/lib/flac/src/share/Makefile.am b/Engine/lib/flac/src/share/Makefile.am deleted file mode 100644 index caf61226b..000000000 --- a/Engine/lib/flac/src/share/Makefile.am +++ /dev/null @@ -1,73 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -AUTOMAKE_OPTIONS = subdir-objects - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include - -EXTRA_DIST = \ - README \ - getopt/CMakeLists.txt \ - grabbag/CMakeLists.txt \ - replaygain_analysis/CMakeLists.txt \ - replaygain_synthesis/CMakeLists.txt \ - utf8/CMakeLists.txt \ - utf8/charmaps.h \ - utf8/makemap.c \ - utf8/charset_test.c - - -noinst_LTLIBRARIES = \ - getopt/libgetopt.la \ - grabbag/libgrabbag.la \ - utf8/libutf8.la \ - $(libwin_utf8_io) \ - replaygain_analysis/libreplaygain_analysis.la \ - replaygain_synthesis/libreplaygain_synthesis.la - - -if OS_IS_WINDOWS -win_utf8_io_libwin_utf8_io_la_SOURCES = win_utf8_io/win_utf8_io.c -libwin_utf8_io = win_utf8_io/libwin_utf8_io.la -else -win_utf8_io_libwin_utf8_io_la_SOURCES = -libwin_utf8_io = -endif - -getopt_libgetopt_la_SOURCES = getopt/getopt.c getopt/getopt1.c - -grabbag_libgrabbag_la_SOURCES = \ - grabbag/alloc.c \ - grabbag/cuesheet.c \ - grabbag/file.c \ - grabbag/picture.c \ - grabbag/replaygain.c \ - grabbag/seektable.c \ - grabbag/snprintf.c - -utf8_libutf8_la_SOURCES = \ - utf8/charset.c \ - utf8/charset.h \ - utf8/iconvert.c \ - utf8/iconvert.h \ - utf8/utf8.c - -replaygain_analysis_libreplaygain_analysis_la_SOURCES = replaygain_analysis/replaygain_analysis.c - -replaygain_synthesis_libreplaygain_synthesis_la_CFLAGS = -I $(top_srcdir)/src/share/replaygain_synthesis/include -replaygain_synthesis_libreplaygain_synthesis_la_SOURCES = replaygain_synthesis/replaygain_synthesis.c diff --git a/Engine/lib/flac/src/share/README b/Engine/lib/flac/src/share/README deleted file mode 100644 index 1d4fededa..000000000 --- a/Engine/lib/flac/src/share/README +++ /dev/null @@ -1,5 +0,0 @@ -This directory contains several convenience libraries used by the rest of the -tools and plugins. Two of them (getopt and utf8) are shamelessly copied from -vorbistools, one for manipulating UTF-8 strings (GPL) and one for implementing -getopt (LGPL). libFLAC does not link to either; the only FLAC tools that do -are GPL'ed. diff --git a/Engine/lib/flac/src/share/getopt/CMakeLists.txt b/Engine/lib/flac/src/share/getopt/CMakeLists.txt deleted file mode 100644 index d905615e1..000000000 --- a/Engine/lib/flac/src/share/getopt/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -check_include_file("string.h" HAVE_STRING_H) - -if(NOT WIN32) - find_package(Intl) -endif() - -add_library(getopt STATIC getopt.c getopt1.c) - -if(Intl_FOUND) - target_include_directories(getopt PRIVATE ${Intl_INCLUDE_DIRS}) - target_link_libraries(getopt PUBLIC ${Intl_LIBRARIES}) - target_compile_definitions(getopt PRIVATE HAVE_LIBINTL_H) -endif() diff --git a/Engine/lib/flac/src/share/getopt/getopt.c b/Engine/lib/flac/src/share/getopt/getopt.c deleted file mode 100644 index 39fab80e2..000000000 --- a/Engine/lib/flac/src/share/getopt/getopt.c +++ /dev/null @@ -1,1053 +0,0 @@ -/* - NOTE: - I cannot get the vanilla getopt code to work (i.e. compile only what - is needed and not duplicate symbols found in the standard library) - on all the platforms that FLAC supports. In particular the gating - of code with the ELIDE_CODE #define is not accurate enough on systems - that are POSIX but not glibc. If someone has a patch that works on - GNU/Linux, Darwin, AND Solaris please submit it on the project page: - https://sourceforge.net/p/flac/patches/ - - In the meantime I have munged the global symbols and removed gates - around code, while at the same time trying to touch the original as - little as possible. -*/ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to drepper@gnu.org - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 - Free Software Foundation, Inc. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* This tells Alpha OSF/1 not to define a getopt prototype in . - Ditto for AIX 3.2 and . */ -#ifndef _NO_PROTO -# define _NO_PROTO -#endif - -#ifdef HAVE_CONFIG_H -# include -#endif - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -# ifndef const -# define const -# endif -#endif - -#include - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -# include -# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -# define ELIDE_CODE -# endif -#endif - -#if 1 -/*[JEC] was:#ifndef ELIDE_CODE*/ - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -# include -# include -#endif /* GNU C library. */ - -#ifdef VMS -# include -# ifdef HAVE_STRING_H -# include -# endif -#endif - -#ifndef _ -/* This is for other GNU distributions with internationalized messages. - When compiling libc, the _ macro is predefined. */ -# ifdef HAVE_LIBINTL_H -# include -# define _(msgid) gettext (msgid) -# else -# define _(msgid) (msgid) -# endif -#endif - -/* This version of `share__getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `share__getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "share/getopt.h" -/*[JEC] was:#include "getopt.h"*/ - -/* For communication from `share__getopt' to the caller. - When `share__getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *share__optarg = 0; /*[JEC] initialize to avoid being a 'Common' symbol */ - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `share__getopt'. - - On entry to `share__getopt', zero means this is the first call; initialize. - - When `share__getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `share__optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -/* 1003.2 says this must be 1 before any call. */ -int share__optind = 1; - -/* Formerly, initialization of getopt depended on share__optind==0, which - causes problems with re-calling getopt as programs generally don't - know that. */ - -static int share____getopt_initialized = 0; - -/* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - -static char *nextchar; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int share__opterr = 1; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int share__optopt = '?'; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `share__getopt' to return -1 with `share__optind' != ARGC. */ - -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering; - -/* Value of POSIXLY_CORRECT environment variable. */ -static char *posixly_correct; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -# include -# define my_index strchr -#else - -#include - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -#ifndef getenv -extern char *getenv (const char * name); -#endif - -static char * -my_index (const char *str, int chr) -{ - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; -} - -/* If using GCC, we can safely declare strlen this way. - If not using GCC, it is ok not to declare it. */ -#ifdef __GNUC__ -/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. - That was relevant to code that was here before. */ -# if (!defined __STDC__ || !__STDC__) && !defined strlen -/* gcc with -traditional declares the built-in strlen to return int, - and has done so at least since version 2.4.5. -- rms. */ -extern int strlen (const char *); -# endif /* not __STDC__ */ -#endif /* __GNUC__ */ - -#endif /* not __GNU_LIBRARY__ */ - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -#ifdef _LIBC -/* Bash 2.0 gives us an environment variable containing flags - indicating ARGV elements that should not be considered arguments. */ - -/* Defined in getopt_init.c */ -extern char *__getopt_nonoption_flags; - -static int nonoption_flags_max_len; -static int nonoption_flags_len; - -static int original_argc; -static char *const *original_argv; - -/* Make sure the environment variable bash 2.0 puts in the environment - is valid for the getopt call we must make sure that the ARGV passed - to getopt is that one passed to the process. */ -static void -__attribute__ ((unused)) -store_args_and_env (int argc, char *const *argv) -{ - /* XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ - original_argc = argc; - original_argv = argv; -} -# ifdef text_set_element -text_set_element (__libc_subinit, store_args_and_env); -# endif /* text_set_element */ - -# define SWAP_FLAGS(ch1, ch2) \ - if (nonoption_flags_len > 0) \ - { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ - } -#else /* !_LIBC */ -# define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,share__optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -#if defined __STDC__ && __STDC__ -static void exchange (char **); -#endif - -static void -exchange (char **argv) -{ - int bottom = first_nonopt; - int middle = last_nonopt; - int top = share__optind; - char *tem; - - /* Exchange the shorter segment with the far end of the longer segment. - That puts the shorter segment into the right place. - It leaves the longer segment in the right place overall, - but it consists of two parts that need to be swapped next. */ - -#ifdef _LIBC - /* First make sure the handling of the `__getopt_nonoption_flags' - string can work normally. Our top argument must be in the range - of the string. */ - if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) - { - /* We must extend the array. The user plays games with us and - presents new arguments. */ - char *new_str = malloc (top + 1); - if (new_str == NULL) - nonoption_flags_len = nonoption_flags_max_len = 0; - else - { - memset (__mempcpy (new_str, __getopt_nonoption_flags, - nonoption_flags_max_len), - '\0', top + 1 - nonoption_flags_max_len); - nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; - } - } -#endif - - while (top > middle && middle > bottom) - { - if (top - middle > middle - bottom) - { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; - - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } - else - { - /* Top segment is the short one. */ - int len = top - middle; - register int i; - - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS (bottom + i, middle + i); - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } - } - - /* Update records for the slots the non-options now occupy. */ - - first_nonopt += (share__optind - last_nonopt); - last_nonopt = share__optind; -} - -/* Initialize the internal data when the first call is made. */ - -#if defined __STDC__ && __STDC__ -static const char *share___getopt_initialize (int, char *const *, const char *); -#endif -static const char * -share___getopt_initialize (int argc, char *const *argv, const char *optstring ) -{ - /* Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - first_nonopt = last_nonopt = share__optind; - - nextchar = NULL; - - posixly_correct = getenv ("POSIXLY_CORRECT"); - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (posixly_correct != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - -#ifdef _LIBC - if (posixly_correct == NULL - && argc == original_argc && argv == original_argv) - { - if (nonoption_flags_max_len == 0) - { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') - nonoption_flags_max_len = -1; - else - { - const char *orig_str = __getopt_nonoption_flags; - int len = nonoption_flags_max_len = strlen (orig_str); - if (nonoption_flags_max_len < argc) - nonoption_flags_max_len = argc; - __getopt_nonoption_flags = - malloc (nonoption_flags_max_len); - if (__getopt_nonoption_flags == NULL) - nonoption_flags_max_len = -1; - else - memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), - '\0', nonoption_flags_max_len - len); - } - } - nonoption_flags_len = nonoption_flags_max_len; - } - else - nonoption_flags_len = 0; -#else - (void)argc, (void)argv; -#endif - - return optstring; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `share__getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If `share__getopt' finds another option character, it returns that character, - updating `share__optind' and `nextchar' so that the next call to `share__getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, `share__getopt' returns -1. - Then `share__optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `share__opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `share__optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `share__optarg', otherwise `share__optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `share__getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct share__option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -share___getopt_internal ( - int argc, - char *const *argv, - const char *optstring, - const struct share__option *longopts, - int *longind, - int long_only ) -{ - share__optarg = NULL; - - if (share__optind == 0 || !share____getopt_initialized) - { - if (share__optind == 0) - share__optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = share___getopt_initialize (argc, argv, optstring); - share____getopt_initialized = 1; - } - - /* Test whether ARGV[share__optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ -#ifdef _LIBC -# define NONOPTION_P (argv[share__optind][0] != '-' || argv[share__optind][1] == '\0' \ - || (share__optind < nonoption_flags_len \ - && __getopt_nonoption_flags[share__optind] == '1')) -#else -# define NONOPTION_P (argv[share__optind][0] != '-' || argv[share__optind][1] == '\0') -#endif - - if (nextchar == NULL || *nextchar == '\0') - { - /* Advance to the next ARGV-element. */ - - /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ - if (last_nonopt > share__optind) - last_nonopt = share__optind; - if (first_nonopt > share__optind) - first_nonopt = share__optind; - - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt && last_nonopt != share__optind) - exchange ((char **) argv); - else if (last_nonopt != share__optind) - first_nonopt = share__optind; - - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ - - while (share__optind < argc && NONOPTION_P) - share__optind++; - last_nonopt = share__optind; - } - - /* The special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (share__optind != argc && !strcmp (argv[share__optind], "--")) - { - share__optind++; - - if (first_nonopt != last_nonopt && last_nonopt != share__optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = share__optind; - last_nonopt = argc; - - share__optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (share__optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - share__optind = first_nonopt; - return -1; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if (NONOPTION_P) - { - if (ordering == REQUIRE_ORDER) - return -1; - share__optarg = argv[share__optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Skip the initial punctuation. */ - - nextchar = (argv[share__optind] + 1 - + (longopts != NULL && argv[share__optind][1] == '-')); - } - - /* Decode the current option-ARGV-element. */ - - /* Check whether the ARGV-element is a long option. - - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. - - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". - - This distinction seems to be the most useful approach. */ - - if (longopts != NULL - && (argv[share__optind][1] == '-' - || (long_only && (argv[share__optind][2] || !my_index (optstring, argv[share__optind][1]))))) - { - char *nameend; - const struct share__option *p; - const struct share__option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; - - for (nameend = nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((size_t) (nameend - nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (share__opterr) - fprintf (stderr, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[share__optind]); - nextchar += strlen (nextchar); - share__optind++; - share__optopt = 0; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - share__optind++; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - share__optarg = nameend + 1; - else - { - if (share__opterr) - { - if (argv[share__optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - _("%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - _("%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[share__optind - 1][0], pfound->name); - } - - nextchar += strlen (nextchar); - - share__optopt = pfound->val; - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (share__optind < argc) - share__optarg = argv[share__optind++]; - else - { - if (share__opterr) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[share__optind - 1]); - nextchar += strlen (nextchar); - share__optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - /* Can't find it as a long option. If this is not share__getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[share__optind][1] == '-' - || my_index (optstring, *nextchar) == NULL) - { - if (share__opterr) - { - if (argv[share__optind][1] == '-') - /* --option */ - fprintf (stderr, _("%s: unrecognized option `--%s'\n"), - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[share__optind][0], nextchar); - } - nextchar = (char *) ""; - share__optind++; - share__optopt = 0; - return '?'; - } - } - - /* Look at and handle the next short option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `share__optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++share__optind; - - if (temp == NULL || c == ':') - { - if (share__opterr) - { - if (posixly_correct) - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: illegal option -- %c\n"), - argv[0], c); - else - fprintf (stderr, _("%s: invalid option -- %c\n"), - argv[0], c); - } - share__optopt = c; - return '?'; - } - /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') - { - char *nameend; - const struct share__option *p; - const struct share__option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - share__optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - share__optind++; - } - else if (share__optind == argc) - { - if (share__opterr) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - share__optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - /* We already incremented `share__optind' once; - increment it again when taking next ARGV-elt as argument. */ - share__optarg = argv[share__optind++]; - - /* share__optarg is now the argument, see if it's in the - table of longopts. */ - - for (nextchar = nameend = share__optarg; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((size_t) (nameend - nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) - { - if (share__opterr) - fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[share__optind]); - nextchar += strlen (nextchar); - share__optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - share__optarg = nameend + 1; - else - { - if (share__opterr) - fprintf (stderr, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); - - nextchar += strlen (nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (share__optind < argc) - share__optarg = argv[share__optind++]; - else - { - if (share__opterr) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[share__optind - 1]); - nextchar += strlen (nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - nextchar = NULL; - return 'W'; /* Let the application handle it. */ - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*nextchar != '\0') - { - share__optarg = nextchar; - share__optind++; - } - else - share__optarg = NULL; - nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - share__optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - share__optind++; - } - else if (share__optind == argc) - { - if (share__opterr) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, - _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - share__optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `share__optind' once; - increment it again when taking next ARGV-elt as argument. */ - share__optarg = argv[share__optind++]; - nextchar = NULL; - } - } - return c; - } -} - -int -share__getopt (int argc, char *const *argv, const char *optstring) -{ - return share___getopt_internal (argc, argv, optstring, - (const struct share__option *) 0, - (int *) 0, - 0); -} - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of `share__getopt'. */ - -int -main (int argc, char **argv) -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = share__optind ? share__optind : 1; - - c = share__getopt (argc, argv, "abc:d:0123456789"); - if (c == -1) - break; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", share__optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (share__optind < argc) - { - printf ("non-option ARGV-elements: "); - while (share__optind < argc) - printf ("%s ", argv[share__optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/Engine/lib/flac/src/share/getopt/getopt1.c b/Engine/lib/flac/src/share/getopt/getopt1.c deleted file mode 100644 index fc5267846..000000000 --- a/Engine/lib/flac/src/share/getopt/getopt1.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - NOTE: - I cannot get the vanilla getopt code to work (i.e. compile only what - is needed and not duplicate symbols found in the standard library) - on all the platforms that FLAC supports. In particular the gating - of code with the ELIDE_CODE #define is not accurate enough on systems - that are POSIX but not glibc. If someone has a patch that works on - GNU/Linux, Darwin, AND Solaris please submit it on the project page: - https://sourceforge.net/p/flac/patches/ - - In the meantime I have munged the global symbols and removed gates - around code, while at the same time trying to touch the original as - little as possible. -*/ -/* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -#ifndef const -#define const -#endif -#endif - -#include - -#include "share/getopt.h" -/*[JEC] was:#include "getopt.h"*/ - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -#include -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - -#if 1 -/*[JEC] was:#ifndef ELIDE_CODE*/ - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include -#endif - -#ifndef NULL -#define NULL 0 -#endif - -int share__getopt_long(int argc, char *const *argv, const char *options, const struct share__option *long_options, int *opt_index) -{ - return share___getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like share__getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') doesn't match a long option, - but does match a short option, it is parsed as a short option - instead. */ - -int share__getopt_long_only(int argc, char *const *argv, const char *options, const struct share__option *long_options, int *opt_index) -{ - return share___getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -#include - -int main(int argc, char **argv) -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = share__optind ? share__optind : 1; - int option_index = 0; - static struct share__option long_options[] = - { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; - - c = share__getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); - if (c == -1) - break; - - switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (share__optarg) - printf (" with arg %s", share__optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", share__optarg); - break; - - case 'd': - printf ("option d with value `%s'\n", share__optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (share__optind < argc) - { - printf ("non-option ARGV-elements: "); - while (share__optind < argc) - printf ("%s ", argv[share__optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/Engine/lib/flac/src/share/grabbag/CMakeLists.txt b/Engine/lib/flac/src/share/grabbag/CMakeLists.txt deleted file mode 100644 index 203ae3f4c..000000000 --- a/Engine/lib/flac/src/share/grabbag/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -add_library(grabbag STATIC - alloc.c - cuesheet.c - file.c - picture.c - replaygain.c - seektable.c - snprintf.c) -target_link_libraries(grabbag PUBLIC - FLAC - replaygain_analysis) -if(TARGET win_utf8_io) - target_link_libraries(grabbag PUBLIC win_utf8_io) -endif() diff --git a/Engine/lib/flac/src/share/grabbag/alloc.c b/Engine/lib/flac/src/share/grabbag/alloc.c deleted file mode 100644 index 4e5fb60c8..000000000 --- a/Engine/lib/flac/src/share/grabbag/alloc.c +++ /dev/null @@ -1,48 +0,0 @@ -/* alloc - Convenience routines for safely allocating memory - * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "share/alloc.h" - -void *safe_malloc_mul_2op_(size_t size1, size_t size2) -{ - if(!size1 || !size2) - return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ - if(size1 > SIZE_MAX / size2) - return 0; - return malloc(size1*size2); -} diff --git a/Engine/lib/flac/src/share/grabbag/cuesheet.c b/Engine/lib/flac/src/share/grabbag/cuesheet.c deleted file mode 100644 index 0d19ee725..000000000 --- a/Engine/lib/flac/src/share/grabbag/cuesheet.c +++ /dev/null @@ -1,681 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include "FLAC/assert.h" -#include "share/compat.h" -#include "share/grabbag.h" -#include "share/safe_str.h" - -uint32_t grabbag__cuesheet_msf_to_frame(uint32_t minutes, uint32_t seconds, uint32_t frames) -{ - return ((minutes * 60) + seconds) * 75 + frames; -} - -void grabbag__cuesheet_frame_to_msf(uint32_t frame, uint32_t *minutes, uint32_t *seconds, uint32_t *frames) -{ - *frames = frame % 75; - frame /= 75; - *seconds = frame % 60; - frame /= 60; - *minutes = frame; -} - -/* since we only care about values >= 0 or error, returns < 0 for any illegal string, else value */ -static FLAC__int64 local__parse_int64_(const char *s) -{ - FLAC__int64 ret = 0; - char c; - - if(*s == '\0') - return -1; - - while('\0' != (c = *s++)) - if(c >= '0' && c <= '9') { - if(ret >= (INT64_MAX / 10)) - return -1; - else - ret = ret * 10 + (c - '0'); - } - else - return -1; - - return ret; -} - -/* since we only care about values >= 0 or error, returns < 0 for any illegal string, else value */ -static int local__parse_int_(const char *s) -{ - FLAC__int64 ret64 = local__parse_int64_(s); - if(ret64 < 0 || ret64 > INT_MAX) - return -1; - return ret64; -} - -/* accept minute:second:frame syntax of '[0-9]+:[0-9][0-9]?:[0-9][0-9]?', but max second of 59 and max frame of 74, e.g. 0:0:0, 123:45:67 - * return sample number or <0 for error - * WATCHOUT: if sample rate is not evenly divisible by 75, the resulting sample number will be approximate - */ -static FLAC__int64 local__parse_msf_(const char *s, uint32_t sample_rate) -{ - FLAC__int64 ret, field; - char c; - - if(sample_rate == 0) - return -1; - - c = *s++; - if(c >= '0' && c <= '9') - field = (c - '0'); - else - return -1; - while(':' != (c = *s++)) { - if(c >= '0' && c <= '9') { - if(field >= (INT64_MAX / 10)) - return -1; - else - field = field * 10 + (c - '0'); - } - else - return -1; - } - - if(field >= INT64_MAX / (60 * sample_rate)) - return -1; - ret = field * 60 * sample_rate; - - c = *s++; - if(c >= '0' && c <= '9') - field = (c - '0'); - else - return -1; - if(':' != (c = *s++)) { - if(c >= '0' && c <= '9') { - field = field * 10 + (c - '0'); - c = *s++; - if(c != ':') - return -1; - } - else - return -1; - } - - if(field >= 60) - return -1; - - { - FLAC__int64 tmp = ret; - ret += field * sample_rate; - if(ret < tmp) - return -1; - } - - c = *s++; - if(c >= '0' && c <= '9') - field = (c - '0'); - else - return -1; - if('\0' != (c = *s++)) { - if(c >= '0' && c <= '9') { - field = field * 10 + (c - '0'); - c = *s++; - } - else - return -1; - } - - if(c != '\0') - return -1; - - if(field >= 75) - return -1; - - { - FLAC__int64 tmp = ret; - ret += field * (sample_rate / 75); - if(ret < tmp) - return -1; - } - - return ret; -} - -/* accept minute:second syntax of '[0-9]+:[0-9][0-9]?{,.[0-9]+}', but second < 60, e.g. 0:0.0, 3:5, 15:31.731 - * return sample number or <0 for error - * WATCHOUT: depending on the sample rate, the resulting sample number may be approximate with fractional seconds - */ -static FLAC__int64 local__parse_ms_(const char *s, uint32_t sample_rate) -{ - FLAC__int64 ret, field; - double x; - char c, *end; - - if(sample_rate == 0) - return -1; - - c = *s++; - if(c >= '0' && c <= '9') - field = (c - '0'); - else - return -1; - while(':' != (c = *s++)) { - if(c >= '0' && c <= '9') { - if(field >= (INT64_MAX / 10)) - return -1; - else - field = field * 10 + (c - '0'); - } - else - return -1; - } - - if(field >= INT64_MAX / (60 * sample_rate)) - return -1; - ret = field * 60 * sample_rate; - - if(strspn(s, "0123456789.") != strlen(s)) - return -1; - x = strtod(s, &end); - if(*end || end == s) - return -1; - if(x < 0.0 || x >= 60.0) - return -1; - - ret += (FLAC__int64)(x * sample_rate); - - return ret; -} - -static char *local__get_field_(char **s, FLAC__bool allow_quotes) -{ - FLAC__bool has_quote = false; - char *p; - - FLAC__ASSERT(0 != s); - - if(0 == *s) - return 0; - - /* skip leading whitespace */ - while(**s && 0 != strchr(" \t\r\n", **s)) - (*s)++; - - if(**s == 0) { - *s = 0; - return 0; - } - - if(allow_quotes && (**s == '"')) { - has_quote = true; - (*s)++; - if(**s == 0) { - *s = 0; - return 0; - } - } - - p = *s; - - if(has_quote) { - *s = strchr(*s, '\"'); - /* if there is no matching end quote, it's an error */ - if(0 == *s) - p = *s = 0; - else { - **s = '\0'; - (*s)++; - } - } - else { - while(**s && 0 == strchr(" \t\r\n", **s)) - (*s)++; - if(**s) { - **s = '\0'; - (*s)++; - } - else - *s = 0; - } - - return p; -} - -static FLAC__bool local__cuesheet_parse_(FILE *file, const char **error_message, uint32_t *last_line_read, FLAC__StreamMetadata *cuesheet, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) -{ - char buffer[4096], *line, *field; - uint32_t forced_leadout_track_num = 0; - FLAC__uint64 forced_leadout_track_offset = 0; - int in_track_num = -1, in_index_num = -1; - FLAC__bool disc_has_catalog = false, track_has_flags = false, track_has_isrc = false, has_forced_leadout = false; - FLAC__StreamMetadata_CueSheet *cs = &cuesheet->data.cue_sheet; - - FLAC__ASSERT(!is_cdda || sample_rate == 44100); - /* double protection */ - if(is_cdda && sample_rate != 44100) { - *error_message = "CD-DA cuesheet only allowed with 44.1kHz sample rate"; - return false; - } - - cs->lead_in = is_cdda? 2 * 44100 /* The default lead-in size for CD-DA */ : 0; - cs->is_cd = is_cdda; - - while(0 != fgets(buffer, sizeof(buffer), file)) { - (*last_line_read)++; - line = buffer; - - { - size_t linelen = strlen(line); - if((linelen == sizeof(buffer)-1) && line[linelen-1] != '\n') { - *error_message = "line too long"; - return false; - } - } - - if(0 != (field = local__get_field_(&line, /*allow_quotes=*/false))) { - if(0 == FLAC__STRCASECMP(field, "CATALOG")) { - if(disc_has_catalog) { - *error_message = "found multiple CATALOG commands"; - return false; - } - if(0 == (field = local__get_field_(&line, /*allow_quotes=*/true))) { - *error_message = "CATALOG is missing catalog number"; - return false; - } - if(strlen(field) >= sizeof(cs->media_catalog_number)) { - *error_message = "CATALOG number is too long"; - return false; - } - if(is_cdda && (strlen(field) != 13 || strspn(field, "0123456789") != 13)) { - *error_message = "CD-DA CATALOG number must be 13 decimal digits"; - return false; - } - safe_strncpy(cs->media_catalog_number, field, sizeof(cs->media_catalog_number)); - disc_has_catalog = true; - } - else if(0 == FLAC__STRCASECMP(field, "FLAGS")) { - if(track_has_flags) { - *error_message = "found multiple FLAGS commands"; - return false; - } - if(in_track_num < 0 || in_index_num >= 0) { - *error_message = "FLAGS command must come after TRACK but before INDEX"; - return false; - } - while(0 != (field = local__get_field_(&line, /*allow_quotes=*/false))) { - if(0 == FLAC__STRCASECMP(field, "PRE")) - cs->tracks[cs->num_tracks-1].pre_emphasis = 1; - } - track_has_flags = true; - } - else if(0 == FLAC__STRCASECMP(field, "INDEX")) { - FLAC__int64 xx; - FLAC__StreamMetadata_CueSheet_Track *track = &cs->tracks[cs->num_tracks-1]; - if(in_track_num < 0) { - *error_message = "found INDEX before any TRACK"; - return false; - } - if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) { - *error_message = "INDEX is missing index number"; - return false; - } - in_index_num = local__parse_int_(field); - if(in_index_num < 0) { - *error_message = "INDEX has invalid index number"; - return false; - } - FLAC__ASSERT(cs->num_tracks > 0); - if(track->num_indices == 0) { - /* it's the first index point of the track */ - if(in_index_num > 1) { - *error_message = "first INDEX number of a TRACK must be 0 or 1"; - return false; - } - } - else { - if(in_index_num != track->indices[track->num_indices-1].number + 1) { - *error_message = "INDEX numbers must be sequential"; - return false; - } - } - if(is_cdda && in_index_num > 99) { - *error_message = "CD-DA INDEX number must be between 0 and 99, inclusive"; - return false; - } - /*@@@ search for duplicate track number? */ - if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) { - *error_message = "INDEX is missing an offset after the index number"; - return false; - } - /* first parse as minute:second:frame format */ - xx = local__parse_msf_(field, sample_rate); - if(xx < 0) { - /* CD-DA must use only MM:SS:FF format */ - if(is_cdda) { - *error_message = "illegal INDEX offset (not of the form MM:SS:FF)"; - return false; - } - /* as an extension for non-CD-DA we allow MM:SS.SS or raw sample number */ - xx = local__parse_ms_(field, sample_rate); - if(xx < 0) { - xx = local__parse_int64_(field); - if(xx < 0) { - *error_message = "illegal INDEX offset"; - return false; - } - } - } - else if(sample_rate % 75 && xx) { - /* only sample zero is exact */ - *error_message = "illegal INDEX offset (MM:SS:FF form not allowed if sample rate is not a multiple of 75)"; - return false; - } - if(is_cdda && cs->num_tracks == 1 && cs->tracks[0].num_indices == 0 && xx != 0) { - *error_message = "first INDEX of first TRACK must have an offset of 00:00:00"; - return false; - } - if(is_cdda && track->num_indices > 0 && (FLAC__uint64)xx <= track->indices[track->num_indices-1].offset) { - *error_message = "CD-DA INDEX offsets must increase in time"; - return false; - } - /* fill in track offset if it's the first index of the track */ - if(track->num_indices == 0) - track->offset = (FLAC__uint64)xx; - if(is_cdda && cs->num_tracks > 1) { - const FLAC__StreamMetadata_CueSheet_Track *prev = &cs->tracks[cs->num_tracks-2]; - if((FLAC__uint64)xx <= prev->offset + prev->indices[prev->num_indices-1].offset) { - *error_message = "CD-DA INDEX offsets must increase in time"; - return false; - } - } - if(!FLAC__metadata_object_cuesheet_track_insert_blank_index(cuesheet, cs->num_tracks-1, track->num_indices)) { - *error_message = "memory allocation error"; - return false; - } - track->indices[track->num_indices-1].offset = (FLAC__uint64)xx - track->offset; - track->indices[track->num_indices-1].number = in_index_num; - } - else if(0 == FLAC__STRCASECMP(field, "ISRC")) { - char *l, *r; - if(track_has_isrc) { - *error_message = "found multiple ISRC commands"; - return false; - } - if(in_track_num < 0 || in_index_num >= 0) { - *error_message = "ISRC command must come after TRACK but before INDEX"; - return false; - } - if(0 == (field = local__get_field_(&line, /*allow_quotes=*/true))) { - *error_message = "ISRC is missing ISRC number"; - return false; - } - /* strip out dashes */ - for(l = r = field; *r; r++) { - if(*r != '-') - *l++ = *r; - } - *l = '\0'; - if(strlen(field) != 12 || strspn(field, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") < 5 || strspn(field+5, "1234567890") != 7) { - *error_message = "invalid ISRC number"; - return false; - } - safe_strncpy(cs->tracks[cs->num_tracks-1].isrc, field, sizeof(cs->tracks[cs->num_tracks-1].isrc)); - track_has_isrc = true; - } - else if(0 == FLAC__STRCASECMP(field, "TRACK")) { - if(cs->num_tracks > 0) { - const FLAC__StreamMetadata_CueSheet_Track *prev = &cs->tracks[cs->num_tracks-1]; - if( - prev->num_indices == 0 || - ( - is_cdda && - ( - (prev->num_indices == 1 && prev->indices[0].number != 1) || - (prev->num_indices == 2 && prev->indices[0].number != 1 && prev->indices[1].number != 1) - ) - ) - ) { - *error_message = is_cdda? - "previous TRACK must specify at least one INDEX 01" : - "previous TRACK must specify at least one INDEX"; - return false; - } - } - if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) { - *error_message = "TRACK is missing track number"; - return false; - } - in_track_num = local__parse_int_(field); - if(in_track_num < 0) { - *error_message = "TRACK has invalid track number"; - return false; - } - if(in_track_num == 0) { - *error_message = "TRACK number must be greater than 0"; - return false; - } - if(is_cdda) { - if(in_track_num > 99) { - *error_message = "CD-DA TRACK number must be between 1 and 99, inclusive"; - return false; - } - } - else { - if(in_track_num == 255) { - *error_message = "TRACK number 255 is reserved for the lead-out"; - return false; - } - else if(in_track_num > 255) { - *error_message = "TRACK number must be between 1 and 254, inclusive"; - return false; - } - } - if(is_cdda && cs->num_tracks > 0 && in_track_num != cs->tracks[cs->num_tracks-1].number + 1) { - *error_message = "CD-DA TRACK numbers must be sequential"; - return false; - } - /*@@@ search for duplicate track number? */ - if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) { - *error_message = "TRACK is missing a track type after the track number"; - return false; - } - if(!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, cs->num_tracks)) { - *error_message = "memory allocation error"; - return false; - } - cs->tracks[cs->num_tracks-1].number = in_track_num; - cs->tracks[cs->num_tracks-1].type = (0 == FLAC__STRCASECMP(field, "AUDIO"))? 0 : 1; /*@@@ should we be more strict with the value here? */ - in_index_num = -1; - track_has_flags = false; - track_has_isrc = false; - } - else if(0 == FLAC__STRCASECMP(field, "REM")) { - if(0 != (field = local__get_field_(&line, /*allow_quotes=*/false))) { - if(0 == strcmp(field, "FLAC__lead-in")) { - FLAC__int64 xx; - if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) { - *error_message = "FLAC__lead-in is missing offset"; - return false; - } - xx = local__parse_int64_(field); - if(xx < 0) { - *error_message = "illegal FLAC__lead-in offset"; - return false; - } - if(is_cdda && xx % 588 != 0) { - *error_message = "illegal CD-DA FLAC__lead-in offset, must be even multiple of 588 samples"; - return false; - } - cs->lead_in = (FLAC__uint64)xx; - } - else if(0 == strcmp(field, "FLAC__lead-out")) { - int track_num; - FLAC__int64 offset; - if(has_forced_leadout) { - *error_message = "multiple FLAC__lead-out commands"; - return false; - } - if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) { - *error_message = "FLAC__lead-out is missing track number"; - return false; - } - track_num = local__parse_int_(field); - if(track_num < 0) { - *error_message = "illegal FLAC__lead-out track number"; - return false; - } - forced_leadout_track_num = (uint32_t)track_num; - /*@@@ search for duplicate track number? */ - if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) { - *error_message = "FLAC__lead-out is missing offset"; - return false; - } - offset = local__parse_int64_(field); - if(offset < 0) { - *error_message = "illegal FLAC__lead-out offset"; - return false; - } - forced_leadout_track_offset = (FLAC__uint64)offset; - if(forced_leadout_track_offset != lead_out_offset) { - *error_message = "FLAC__lead-out offset does not match end-of-stream offset"; - return false; - } - has_forced_leadout = true; - } - } - } - } - } - - if(cs->num_tracks == 0) { - *error_message = "there must be at least one TRACK command"; - return false; - } - else { - const FLAC__StreamMetadata_CueSheet_Track *prev = &cs->tracks[cs->num_tracks-1]; - if( - prev->num_indices == 0 || - ( - is_cdda && - ( - (prev->num_indices == 1 && prev->indices[0].number != 1) || - (prev->num_indices == 2 && prev->indices[0].number != 1 && prev->indices[1].number != 1) - ) - ) - ) { - *error_message = is_cdda? - "previous TRACK must specify at least one INDEX 01" : - "previous TRACK must specify at least one INDEX"; - return false; - } - } - - if(!has_forced_leadout) { - forced_leadout_track_num = is_cdda? 170 : 255; - forced_leadout_track_offset = lead_out_offset; - } - if(!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, cs->num_tracks)) { - *error_message = "memory allocation error"; - return false; - } - cs->tracks[cs->num_tracks-1].number = forced_leadout_track_num; - cs->tracks[cs->num_tracks-1].offset = forced_leadout_track_offset; - - if(!feof(file)) { - *error_message = "read error"; - return false; - } - return true; -} - -FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, uint32_t *last_line_read, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) -{ - FLAC__StreamMetadata *cuesheet; - - FLAC__ASSERT(0 != file); - FLAC__ASSERT(0 != error_message); - FLAC__ASSERT(0 != last_line_read); - - *last_line_read = 0; - cuesheet = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET); - - if(0 == cuesheet) { - *error_message = "memory allocation error"; - return 0; - } - - if(!local__cuesheet_parse_(file, error_message, last_line_read, cuesheet, sample_rate, is_cdda, lead_out_offset)) { - FLAC__metadata_object_delete(cuesheet); - return 0; - } - - return cuesheet; -} - -void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference) -{ - const FLAC__StreamMetadata_CueSheet *cs; - uint32_t track_num, index_num; - - FLAC__ASSERT(0 != file); - FLAC__ASSERT(0 != cuesheet); - FLAC__ASSERT(cuesheet->type == FLAC__METADATA_TYPE_CUESHEET); - - cs = &cuesheet->data.cue_sheet; - - if(*(cs->media_catalog_number)) - fprintf(file, "CATALOG %s\n", cs->media_catalog_number); - fprintf(file, "FILE %s\n", file_reference); - - FLAC__ASSERT(cs->num_tracks > 0); - - for(track_num = 0; track_num < cs->num_tracks-1; track_num++) { - const FLAC__StreamMetadata_CueSheet_Track *track = cs->tracks + track_num; - - fprintf(file, " TRACK %02u %s\n", (uint32_t)track->number, track->type == 0? "AUDIO" : "DATA"); - - if(track->pre_emphasis) - fprintf(file, " FLAGS PRE\n"); - if(*(track->isrc)) - fprintf(file, " ISRC %s\n", track->isrc); - - for(index_num = 0; index_num < track->num_indices; index_num++) { - const FLAC__StreamMetadata_CueSheet_Index *indx = track->indices + index_num; - - fprintf(file, " INDEX %02u ", (uint32_t)indx->number); - if(cs->is_cd) { - const uint32_t logical_frame = (uint32_t)((track->offset + indx->offset) / (44100 / 75)); - uint32_t m, s, f; - grabbag__cuesheet_frame_to_msf(logical_frame, &m, &s, &f); - fprintf(file, "%02u:%02u:%02u\n", m, s, f); - } - else - fprintf(file, "%" PRIu64 "\n", (track->offset + indx->offset)); - } - } - - fprintf(file, "REM FLAC__lead-in %" PRIu64 "\n", cs->lead_in); - fprintf(file, "REM FLAC__lead-out %u %" PRIu64 "\n", (uint32_t)cs->tracks[track_num].number, cs->tracks[track_num].offset); -} diff --git a/Engine/lib/flac/src/share/grabbag/file.c b/Engine/lib/flac/src/share/grabbag/file.c deleted file mode 100644 index 307645f57..000000000 --- a/Engine/lib/flac/src/share/grabbag/file.c +++ /dev/null @@ -1,207 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#if defined _MSC_VER || defined __MINGW32__ -#include /* for utime() */ -#include /* for chmod(), _setmode(), unlink() */ -#include /* for _O_BINARY */ -#else -#include /* some flavors of BSD (like OS X) require this to get time_t */ -#endif -#if defined __EMX__ -#include /* for setmode(), O_BINARY */ -#include /* for _O_BINARY */ -#endif -#include /* for stat(), maybe chmod() */ -#if defined _WIN32 && !defined __CYGWIN__ -#else -#include /* for unlink() */ -#endif -#include -#include -#include /* for strrchr() */ -#if defined _WIN32 && !defined __CYGWIN__ -// for GetFileInformationByHandle() etc -#include -#include -#endif -#include "share/grabbag.h" -#include "share/compat.h" - - -void grabbag__file_copy_metadata(const char *srcpath, const char *destpath) -{ - struct flac_stat_s srcstat; - - if(0 == flac_stat(srcpath, &srcstat)) { -#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) && !defined(_WIN32) - struct timespec srctime[2] = {}; - srctime[0].tv_sec = srcstat.st_atime; - srctime[1].tv_sec = srcstat.st_mtime; -#else - struct utimbuf srctime; - srctime.actime = srcstat.st_atime; - srctime.modtime = srcstat.st_mtime; -#endif - (void)flac_chmod(destpath, srcstat.st_mode); - (void)flac_utime(destpath, &srctime); - } -} - -FLAC__off_t grabbag__file_get_filesize(const char *srcpath) -{ - struct flac_stat_s srcstat; - - if(0 == flac_stat(srcpath, &srcstat)) - return srcstat.st_size; - else - return -1; -} - -const char *grabbag__file_get_basename(const char *srcpath) -{ - const char *p; - - p = strrchr(srcpath, '/'); - if(0 == p) { -#if defined _WIN32 && !defined __CYGWIN__ - p = strrchr(srcpath, '\\'); - if(0 == p) -#endif - return srcpath; - } - return ++p; -} - -FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only) -{ - struct flac_stat_s stats; - - if(0 == flac_stat(filename, &stats)) { -#if !defined _MSC_VER && !defined __MINGW32__ - if(read_only) { - stats.st_mode &= ~S_IWUSR; - stats.st_mode &= ~S_IWGRP; - stats.st_mode &= ~S_IWOTH; - } - else { - stats.st_mode |= S_IWUSR; - } -#else - if(read_only) - stats.st_mode &= ~S_IWRITE; - else - stats.st_mode |= S_IWRITE; -#endif - if(0 != flac_chmod(filename, stats.st_mode)) - return false; - } - else - return false; - - return true; -} - -FLAC__bool grabbag__file_are_same(const char *f1, const char *f2) -{ -#if defined _WIN32 && !defined __CYGWIN__ -#if !defined(WINAPI_FAMILY_PARTITION) -#define WINAPI_FAMILY_PARTITION(x) x -#define WINAPI_PARTITION_DESKTOP 1 -#endif - /* see - * http://www.hydrogenaudio.org/forums/index.php?showtopic=49439&pid=444300&st=0 - * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getfileinformationbyhandle.asp - * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/by_handle_file_information_str.asp - * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/createfile.asp - * apparently both the files have to be open at the same time for the comparison to work - */ - FLAC__bool same = false; - BY_HANDLE_FILE_INFORMATION info1, info2; - HANDLE h1, h2; - BOOL ok = 1; - h1 = CreateFile_utf8(f1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - h2 = CreateFile_utf8(f2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if(h1 == INVALID_HANDLE_VALUE || h2 == INVALID_HANDLE_VALUE) - ok = 0; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - ok &= GetFileInformationByHandle(h1, &info1); - ok &= GetFileInformationByHandle(h2, &info2); - if(ok) - same = - info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber && - info1.nFileIndexHigh == info2.nFileIndexHigh && - info1.nFileIndexLow == info2.nFileIndexLow - ; -#else // !WINAPI_PARTITION_DESKTOP - FILE_ID_INFO id_info1, id_info2; - same = GetFileInformationByHandleEx(h1, FileIdInfo, &id_info1, sizeof (id_info1)) && - GetFileInformationByHandleEx(h2, FileIdInfo, &id_info2, sizeof (id_info2)) && - id_info1.VolumeSerialNumber == id_info2.VolumeSerialNumber && - memcmp(&id_info1.FileId, &id_info2.FileId, sizeof(id_info1.FileId)) == 0; -#endif // !WINAPI_PARTITION_DESKTOP - if(h1 != INVALID_HANDLE_VALUE) - CloseHandle(h1); - if(h2 != INVALID_HANDLE_VALUE) - CloseHandle(h2); - return same; -#else - struct flac_stat_s s1, s2; - return f1 && f2 && flac_stat(f1, &s1) == 0 && flac_stat(f2, &s2) == 0 && s1.st_ino == s2.st_ino && s1.st_dev == s2.st_dev; -#endif -} - -FLAC__bool grabbag__file_remove_file(const char *filename) -{ - return grabbag__file_change_stats(filename, /*read_only=*/false) && 0 == flac_unlink(filename); -} - -FILE *grabbag__file_get_binary_stdin(void) -{ - /* if something breaks here it is probably due to the presence or - * absence of an underscore before the identifiers 'setmode', - * 'fileno', and/or 'O_BINARY'; check your system header files. - */ -#if defined _MSC_VER || defined __MINGW32__ - _setmode(_fileno(stdin), _O_BINARY); -#elif defined __EMX__ - setmode(fileno(stdin), O_BINARY); -#endif - - return stdin; -} - -FILE *grabbag__file_get_binary_stdout(void) -{ - /* if something breaks here it is probably due to the presence or - * absence of an underscore before the identifiers 'setmode', - * 'fileno', and/or 'O_BINARY'; check your system header files. - */ -#if defined _MSC_VER || defined __MINGW32__ - _setmode(_fileno(stdout), _O_BINARY); -#elif defined __EMX__ - setmode(fileno(stdout), O_BINARY); -#endif - - return stdout; -} diff --git a/Engine/lib/flac/src/share/grabbag/picture.c b/Engine/lib/flac/src/share/grabbag/picture.c deleted file mode 100644 index 9a4aafe27..000000000 --- a/Engine/lib/flac/src/share/grabbag/picture.c +++ /dev/null @@ -1,515 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "share/alloc.h" -#include "share/grabbag.h" -#include "FLAC/assert.h" -#include -#include -#include -#include "share/compat.h" -#include "share/safe_str.h" - -/* slightly different that strndup(): this always copies 'size' bytes starting from s into a NUL-terminated string. */ -static char *local__strndup_(const char *s, size_t size) -{ - char *x = safe_malloc_add_2op_(size, /*+*/1); - if(x) { - memcpy(x, s, size); - x[size] = '\0'; - } - return x; -} - -static FLAC__bool local__parse_type_(const char *s, size_t len, FLAC__StreamMetadata_Picture *picture) -{ - size_t i; - FLAC__uint32 val = 0; - - picture->type = FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER; - - if(len == 0) - return true; /* empty string implies default to 'front cover' */ - - for(i = 0; i < len; i++) { - if(s[i] >= '0' && s[i] <= '9') - val = 10*val + (FLAC__uint32)(s[i] - '0'); - else - return false; - } - - if(i == len) - picture->type = val; - else - return false; - - return true; -} - -static FLAC__bool local__parse_resolution_(const char *s, size_t len, FLAC__StreamMetadata_Picture *picture) -{ - int state = 0; - size_t i; - FLAC__uint32 val = 0; - - picture->width = picture->height = picture->depth = picture->colors = 0; - - if(len == 0) - return true; /* empty string implies client wants to get info from the file itself */ - - for(i = 0; i < len; i++) { - if(s[i] == 'x') { - if(state == 0) - picture->width = val; - else if(state == 1) - picture->height = val; - else - return false; - state++; - val = 0; - } - else if(s[i] == '/') { - if(state == 2) - picture->depth = val; - else - return false; - state++; - val = 0; - } - else if(s[i] >= '0' && s[i] <= '9') - val = 10*val + (FLAC__uint32)(s[i] - '0'); - else - return false; - } - - if(state < 2) - return false; - else if(state == 2) - picture->depth = val; - else if(state == 3) - picture->colors = val; - else - return false; - if(picture->depth < 32 && 1u<depth < picture->colors) - return false; - - return true; -} - -static FLAC__bool local__extract_mime_type_(FLAC__StreamMetadata *obj) -{ - if(obj->data.picture.data_length >= 8 && 0 == memcmp(obj->data.picture.data, "\x89PNG\x0d\x0a\x1a\x0a", 8)) - return FLAC__metadata_object_picture_set_mime_type(obj, "image/png", /*copy=*/true); - else if(obj->data.picture.data_length >= 6 && (0 == memcmp(obj->data.picture.data, "GIF87a", 6) || 0 == memcmp(obj->data.picture.data, "GIF89a", 6))) - return FLAC__metadata_object_picture_set_mime_type(obj, "image/gif", /*copy=*/true); - else if(obj->data.picture.data_length >= 2 && 0 == memcmp(obj->data.picture.data, "\xff\xd8", 2)) - return FLAC__metadata_object_picture_set_mime_type(obj, "image/jpeg", /*copy=*/true); - return false; -} - -static FLAC__bool local__extract_resolution_color_info_(FLAC__StreamMetadata_Picture *picture) -{ - const FLAC__byte *data = picture->data; - FLAC__uint32 len = picture->data_length; - - if(0 == strcmp(picture->mime_type, "image/png")) { - /* c.f. http://www.w3.org/TR/PNG/ */ - FLAC__bool need_palette = false; /* if IHDR has color_type=3, we need to also read the PLTE chunk to get the #colors */ - if(len < 8 || memcmp(data, "\x89PNG\x0d\x0a\x1a\x0a", 8)) - return false; - /* try to find IHDR chunk */ - data += 8; - len -= 8; - while(len > 12) { /* every PNG chunk must be at least 12 bytes long */ - const FLAC__uint32 clen = (FLAC__uint32)data[0] << 24 | (FLAC__uint32)data[1] << 16 | (FLAC__uint32)data[2] << 8 | (FLAC__uint32)data[3]; - /* First check whether clen makes sense or causes overflow in this bit of code */ - if(clen + 12 <= clen || clen + 12 > len) - return false; - else if(0 == memcmp(data+4, "IHDR", 4) && clen == 13) { - uint32_t color_type = data[17]; - picture->width = (FLAC__uint32)data[8] << 24 | (FLAC__uint32)data[9] << 16 | (FLAC__uint32)data[10] << 8 | (FLAC__uint32)data[11]; - picture->height = (FLAC__uint32)data[12] << 24 | (FLAC__uint32)data[13] << 16 | (FLAC__uint32)data[14] << 8 | (FLAC__uint32)data[15]; - if(color_type == 3) { - /* even though the bit depth for color_type==3 can be 1,2,4,or 8, - * the spec in 11.2.2 of http://www.w3.org/TR/PNG/ says that the - * sample depth is always 8 - */ - picture->depth = 8 * 3u; - need_palette = true; - data += 12 + clen; - len -= 12 + clen; - } - else { - if(color_type == 0) /* greyscale, 1 sample per pixel */ - picture->depth = (FLAC__uint32)data[16]; - if(color_type == 2) /* truecolor, 3 samples per pixel */ - picture->depth = (FLAC__uint32)data[16] * 3u; - if(color_type == 4) /* greyscale+alpha, 2 samples per pixel */ - picture->depth = (FLAC__uint32)data[16] * 2u; - if(color_type == 6) /* truecolor+alpha, 4 samples per pixel */ - picture->depth = (FLAC__uint32)data[16] * 4u; - picture->colors = 0; - return true; - } - } - else if(need_palette && 0 == memcmp(data+4, "PLTE", 4)) { - picture->colors = clen / 3u; - return true; - } - else { - data += 12 + clen; - len -= 12 + clen; - } - } - } - else if(0 == strcmp(picture->mime_type, "image/jpeg")) { - /* c.f. http://www.w3.org/Graphics/JPEG/itu-t81.pdf and Q22 of http://www.faqs.org/faqs/jpeg-faq/part1/ */ - if(len < 2 || memcmp(data, "\xff\xd8", 2)) - return false; - data += 2; - len -= 2; - while(1) { - /* look for sync FF byte */ - for( ; len > 0; data++, len--) { - if(*data == 0xff) - break; - } - if(len == 0) - return false; - /* eat any extra pad FF bytes before marker */ - for( ; len > 0; data++, len--) { - if(*data != 0xff) - break; - } - if(len == 0) - return false; - /* if we hit SOS or EOI, bail */ - if(*data == 0xda || *data == 0xd9) - return false; - /* looking for some SOFn */ - else if(memchr("\xc0\xc1\xc2\xc3\xc5\xc6\xc7\xc9\xca\xcb\xcd\xce\xcf", *data, 13)) { - data++; len--; /* skip marker byte */ - if(len < 2) - return false; - else { - const FLAC__uint32 clen = (FLAC__uint32)data[0] << 8 | (FLAC__uint32)data[1]; - if(clen < 8 || len < clen) - return false; - picture->width = (FLAC__uint32)data[5] << 8 | (FLAC__uint32)data[6]; - picture->height = (FLAC__uint32)data[3] << 8 | (FLAC__uint32)data[4]; - picture->depth = (FLAC__uint32)data[2] * (FLAC__uint32)data[7]; - picture->colors = 0; - return true; - } - } - /* else skip it */ - else { - data++; len--; /* skip marker byte */ - if(len < 2) - return false; - else { - const FLAC__uint32 clen = (FLAC__uint32)data[0] << 8 | (FLAC__uint32)data[1]; - if(clen < 2 || len < clen) - return false; - data += clen; - len -= clen; - } - } - } - } - else if(0 == strcmp(picture->mime_type, "image/gif")) { - /* c.f. http://www.w3.org/Graphics/GIF/spec-gif89a.txt */ - if(len < 14) - return false; - if(memcmp(data, "GIF87a", 6) && memcmp(data, "GIF89a", 6)) - return false; -#if 0 - /* according to the GIF spec, even if the GCTF is 0, the low 3 bits should still tell the total # colors used */ - if(data[10] & 0x80 == 0) - return false; -#endif - picture->width = (FLAC__uint32)data[6] | ((FLAC__uint32)data[7] << 8); - picture->height = (FLAC__uint32)data[8] | ((FLAC__uint32)data[9] << 8); -#if 0 - /* this value doesn't seem to be reliable... */ - picture->depth = (((FLAC__uint32)(data[10] & 0x70) >> 4) + 1) * 3u; -#else - /* ...just pessimistically assume it's 24-bit color without scanning all the color tables */ - picture->depth = 8u * 3u; -#endif - picture->colors = 1u << ((FLAC__uint32)(data[10] & 0x07) + 1u); - return true; - } - return false; -} - -static const char *error_messages[] = { - "memory allocation error", - "invalid picture specification", - "invalid picture specification: can't parse resolution/color part", - "unable to extract resolution and color info from URL, user must set explicitly", - "unable to extract resolution and color info from file, user must set explicitly", - "error opening picture file", - "error reading picture file", - "invalid picture type", - "unable to guess MIME type from file, user must set explicitly", - "type 1 icon must be a 32x32 pixel PNG", - "file not found", /* currently unused */ - "file is too large", - "empty file" -}; - -static const char * read_file (const char * filepath, FLAC__StreamMetadata * obj) -{ - const FLAC__off_t size = grabbag__file_get_filesize(filepath); - FLAC__byte *buffer; - FILE *file; - const char *error_message=NULL; - - if (size < 0) - return error_messages[5]; - - if (size == 0) - return error_messages[12]; - - if (size >= (FLAC__off_t)(1u << FLAC__STREAM_METADATA_LENGTH_LEN)) /* actual limit is less because of other fields in the PICTURE metadata block */ - return error_messages[11]; - - if ((buffer = safe_malloc_(size)) == NULL) - return error_messages[0]; - - if ((file = flac_fopen(filepath, "rb")) == NULL) { - free(buffer); - return error_messages[5]; - } - - if (fread(buffer, 1, size, file) != (size_t) size) { - fclose(file); - free(buffer); - return error_messages[6]; - } - fclose(file); - - if (!FLAC__metadata_object_picture_set_data(obj, buffer, (FLAC__uint32)size, /*copy=*/false)) - error_message = error_messages[6]; - /* try to extract MIME type if user left it blank */ - else if (*obj->data.picture.mime_type == '\0' && !local__extract_mime_type_(obj)) - error_message = error_messages[8]; - /* try to extract resolution/color info if user left it blank */ - else if ((obj->data.picture.width == 0 || obj->data.picture.height == 0 || obj->data.picture.depth == 0) && !local__extract_resolution_color_info_(&obj->data.picture)) - error_message = error_messages[4]; - /* check metadata block size */ - else if (obj->length >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) - error_message = error_messages[11]; - - return error_message; -} - -FLAC__StreamMetadata *grabbag__picture_parse_specification(const char *spec, const char **error_message) -{ - FLAC__StreamMetadata *obj; - int state = 0; - - FLAC__ASSERT(0 != spec); - FLAC__ASSERT(0 != error_message); - - /* double protection */ - if(0 == spec) - return 0; - if(0 == error_message) - return 0; - - *error_message = 0; - - if(0 == (obj = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE))) { - *error_message = error_messages[0]; - return obj; - } - - if(strchr(spec, '|')) { /* full format */ - const char *p; - char *q; - for(p = spec; *error_message==0 && *p; ) { - if(*p == '|') { - switch(state) { - case 0: /* type */ - if(!local__parse_type_(spec, p-spec, &obj->data.picture)) - *error_message = error_messages[7]; - break; - case 1: /* mime type */ - if(p-spec) { /* if blank, we'll try to guess later from the picture data */ - if(0 == (q = local__strndup_(spec, p-spec))) - *error_message = error_messages[0]; - else if(!FLAC__metadata_object_picture_set_mime_type(obj, q, /*copy=*/false)) - *error_message = error_messages[0]; - } - break; - case 2: /* description */ - if(0 == (q = local__strndup_(spec, p-spec))) - *error_message = error_messages[0]; - else if(!FLAC__metadata_object_picture_set_description(obj, (FLAC__byte*)q, /*copy=*/false)) - *error_message = error_messages[0]; - break; - case 3: /* resolution/color (e.g. [300x300x16[/1234]] */ - if(!local__parse_resolution_(spec, p-spec, &obj->data.picture)) - *error_message = error_messages[2]; - break; - default: - *error_message = error_messages[1]; - break; - } - p++; - spec = p; - state++; - } - else - p++; - } - } - else { /* simple format, filename only, everything else guessed */ - if(!local__parse_type_("", 0, &obj->data.picture)) /* use default picture type */ - *error_message = error_messages[7]; - /* leave MIME type to be filled in later */ - /* leave description empty */ - /* leave the rest to be filled in later: */ - else if(!local__parse_resolution_("", 0, &obj->data.picture)) - *error_message = error_messages[2]; - else - state = 4; - } - - /* parse filename, read file, try to extract resolution/color info if needed */ - if(*error_message == 0) { - if(state != 4) - *error_message = error_messages[1]; - else { /* 'spec' points to filename/URL */ - if(0 == strcmp(obj->data.picture.mime_type, "-->")) { /* magic MIME type means URL */ - if(strlen(spec) == 0) - *error_message = error_messages[1]; - else if(!FLAC__metadata_object_picture_set_data(obj, (FLAC__byte*)spec, strlen(spec), /*copy=*/true)) - *error_message = error_messages[0]; - else if(obj->data.picture.width == 0 || obj->data.picture.height == 0 || obj->data.picture.depth == 0) - *error_message = error_messages[3]; - } - else { /* regular picture file */ - *error_message = read_file (spec, obj); - } - } - } - - if(*error_message == 0) { - if( - obj->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD && - ( - (strcmp(obj->data.picture.mime_type, "image/png") && strcmp(obj->data.picture.mime_type, "-->")) || - obj->data.picture.width != 32 || - obj->data.picture.height != 32 - ) - ) - *error_message = error_messages[9]; - } - - if(*error_message && obj) { - FLAC__metadata_object_delete(obj); - obj = 0; - } - - return obj; -} - -FLAC__StreamMetadata *grabbag__picture_from_specification(int type, const char *mime_type_in, const char * description, - const PictureResolution * res, const char * filepath, const char **error_message) -{ - - FLAC__StreamMetadata *obj; - char mime_type [64] ; - - if (error_message == 0) - return 0; - - safe_strncpy(mime_type, mime_type_in, sizeof (mime_type)); - - *error_message = 0; - - if ((obj = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE)) == 0) { - *error_message = error_messages[0]; - return obj; - } - - /* Picture type if known. */ - obj->data.picture.type = type >= 0 ? type : FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER; - - /* Mime type if known. */ - if (mime_type_in && ! FLAC__metadata_object_picture_set_mime_type(obj, mime_type, /*copy=*/true)) { - *error_message = error_messages[0]; - return obj; - } - - /* Description if present. */ - if (description && ! FLAC__metadata_object_picture_set_description(obj, (FLAC__byte*) description, /*copy=*/true)) { - *error_message = error_messages[0]; - return obj; - } - - if (res == NULL) { - obj->data.picture.width = 0; - obj->data.picture.height = 0; - obj->data.picture.depth = 0; - obj->data.picture.colors = 0; - } - else { - obj->data.picture.width = res->width; - obj->data.picture.height = res->height; - obj->data.picture.depth = res->depth; - obj->data.picture.colors = res->colors; - } - - if (strcmp(obj->data.picture.mime_type, "-->") == 0) { /* magic MIME type means URL */ - if (!FLAC__metadata_object_picture_set_data(obj, (FLAC__byte*)filepath, strlen(filepath), /*copy=*/true)) - *error_message = error_messages[0]; - else if (obj->data.picture.width == 0 || obj->data.picture.height == 0 || obj->data.picture.depth == 0) - *error_message = error_messages[3]; - } - else { - *error_message = read_file (filepath, obj); - } - - if (*error_message == NULL) { - if ( - obj->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD && - ( - (strcmp(obj->data.picture.mime_type, "image/png") && strcmp(obj->data.picture.mime_type, "-->")) || - obj->data.picture.width != 32 || - obj->data.picture.height != 32 - ) - ) - *error_message = error_messages[9]; - } - - if (*error_message && obj) { - FLAC__metadata_object_delete(obj); - obj = 0; - } - - return obj; -} diff --git a/Engine/lib/flac/src/share/grabbag/replaygain.c b/Engine/lib/flac/src/share/grabbag/replaygain.c deleted file mode 100644 index 32c960318..000000000 --- a/Engine/lib/flac/src/share/grabbag/replaygain.c +++ /dev/null @@ -1,669 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#if defined _MSC_VER || defined __MINGW32__ -#include /* for chmod() */ -#endif -#include /* for stat(), maybe chmod() */ - -#include "FLAC/assert.h" -#include "FLAC/metadata.h" -#include "FLAC/stream_decoder.h" -#include "share/grabbag.h" -#include "share/replaygain_analysis.h" -#include "share/safe_str.h" - -#ifdef local_min -#undef local_min -#endif -#define local_min(a,b) ((a)<(b)?(a):(b)) - -#ifdef local_max -#undef local_max -#endif -#define local_max(a,b) ((a)>(b)?(a):(b)) - -#ifdef abs32 -#undef abs32 -#endif -#define abs32(a) (((a)==INT32_MIN)?INT32_MAX:abs(a)) - -static const char *reference_format_ = "%s=%2.1f dB"; -static const char *gain_format_ = "%s=%+2.2f dB"; -static const char *peak_format_ = "%s=%1.8f"; - -static double album_peak_, title_peak_; - -const uint32_t GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED = 190; -/* - FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + 29 + 1 + 8 + - FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + 21 + 1 + 10 + - FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + 21 + 1 + 12 + - FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + 21 + 1 + 10 + - FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + 21 + 1 + 12 -*/ - -const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS = (const FLAC__byte * const)"REPLAYGAIN_REFERENCE_LOUDNESS"; -const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN = (const FLAC__byte * const)"REPLAYGAIN_TRACK_GAIN"; -const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK = (const FLAC__byte * const)"REPLAYGAIN_TRACK_PEAK"; -const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN = (const FLAC__byte * const)"REPLAYGAIN_ALBUM_GAIN"; -const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK = (const FLAC__byte * const)"REPLAYGAIN_ALBUM_PEAK"; - - -static FLAC__bool get_file_stats_(const char *filename, struct flac_stat_s *stats) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != stats); - return (0 == flac_stat(filename, stats)); -} - -static void set_file_stats_(const char *filename, struct flac_stat_s *stats) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != stats); - - (void)flac_chmod(filename, stats->st_mode); -} - -static FLAC__bool append_tag_(FLAC__StreamMetadata *block, const char *format, const FLAC__byte *name, float value) -{ - char buffer[256]; - char *saved_locale; - FLAC__StreamMetadata_VorbisComment_Entry entry; - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - FLAC__ASSERT(0 != format); - FLAC__ASSERT(0 != name); - - buffer[sizeof(buffer)-1] = '\0'; - /* - * We need to save the old locale and switch to "C" because the locale - * influences the formatting of %f and we want it a certain way. - */ - saved_locale = strdup(setlocale(LC_ALL, 0)); - if (0 == saved_locale) - return false; - setlocale(LC_ALL, "C"); - flac_snprintf(buffer, sizeof(buffer), format, name, value); - setlocale(LC_ALL, saved_locale); - free(saved_locale); - - entry.entry = (FLAC__byte *)buffer; - entry.length = strlen(buffer); - - return FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true); -} - -FLAC__bool grabbag__replaygain_is_valid_sample_frequency(uint32_t sample_frequency) -{ - return ValidGainFrequency( sample_frequency ); -} - -FLAC__bool grabbag__replaygain_init(uint32_t sample_frequency) -{ - title_peak_ = album_peak_ = 0.0; - return InitGainAnalysis((long)sample_frequency) == INIT_GAIN_ANALYSIS_OK; -} - -FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, uint32_t bps, uint32_t samples) -{ - /* using a small buffer improves data locality; we'd like it to fit easily in the dcache */ - static flac_float_t lbuffer[2048], rbuffer[2048]; - static const uint32_t nbuffer = sizeof(lbuffer) / sizeof(lbuffer[0]); - FLAC__int32 block_peak = 0, s; - uint32_t i, j; - - FLAC__ASSERT(bps >= FLAC__MIN_BITS_PER_SAMPLE && bps <= FLAC__MAX_BITS_PER_SAMPLE); - FLAC__ASSERT(FLAC__MIN_BITS_PER_SAMPLE == 4 && FLAC__MAX_BITS_PER_SAMPLE == 32); - - if(bps == 16) { - if(is_stereo) { - j = 0; - while(samples > 0) { - const uint32_t n = local_min(samples, nbuffer); - for(i = 0; i < n; i++, j++) { - s = input[0][j]; - lbuffer[i] = (flac_float_t)s; - s = abs(s); - block_peak = local_max(block_peak, s); - - s = input[1][j]; - rbuffer[i] = (flac_float_t)s; - s = abs(s); - block_peak = local_max(block_peak, s); - } - samples -= n; - if(AnalyzeSamples(lbuffer, rbuffer, n, 2) != GAIN_ANALYSIS_OK) - return false; - } - } - else { - j = 0; - while(samples > 0) { - const uint32_t n = local_min(samples, nbuffer); - for(i = 0; i < n; i++, j++) { - s = input[0][j]; - lbuffer[i] = (flac_float_t)s; - s = abs(s); - block_peak = local_max(block_peak, s); - } - samples -= n; - if(AnalyzeSamples(lbuffer, 0, n, 1) != GAIN_ANALYSIS_OK) - return false; - } - } - } - else { - const double scale = ( - (bps > 16)? - (double)1. / (double)(1u << (bps - 16)) : - (double)(1u << (16 - bps)) - ); - - if(is_stereo) { - j = 0; - while(samples > 0) { - const uint32_t n = local_min(samples, nbuffer); - for(i = 0; i < n; i++, j++) { - s = input[0][j]; - lbuffer[i] = (flac_float_t)(scale * (double)s); - s = abs32(s); - block_peak = local_max(block_peak, s); - - s = input[1][j]; - rbuffer[i] = (flac_float_t)(scale * (double)s); - s = abs32(s); - block_peak = local_max(block_peak, s); - } - samples -= n; - if(AnalyzeSamples(lbuffer, rbuffer, n, 2) != GAIN_ANALYSIS_OK) - return false; - } - } - else { - j = 0; - while(samples > 0) { - const uint32_t n = local_min(samples, nbuffer); - for(i = 0; i < n; i++, j++) { - s = input[0][j]; - lbuffer[i] = (flac_float_t)(scale * (double)s); - s = abs32(s); - block_peak = local_max(block_peak, s); - } - samples -= n; - if(AnalyzeSamples(lbuffer, 0, n, 1) != GAIN_ANALYSIS_OK) - return false; - } - } - } - - { - const double peak_scale = (double)(1u << (bps - 1)); - double peak = (double)block_peak / peak_scale; - if(peak > title_peak_) - title_peak_ = peak; - if(peak > album_peak_) - album_peak_ = peak; - } - - return true; -} - -void grabbag__replaygain_get_album(float *gain, float *peak) -{ - *gain = (float)GetAlbumGain(); - *peak = (float)album_peak_; - album_peak_ = 0.0; -} - -void grabbag__replaygain_get_title(float *gain, float *peak) -{ - *gain = (float)GetTitleGain(); - *peak = (float)title_peak_; - title_peak_ = 0.0; -} - - -typedef struct { - uint32_t channels; - uint32_t bits_per_sample; - uint32_t sample_rate; - FLAC__bool error; -} DecoderInstance; - -static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - DecoderInstance *instance = (DecoderInstance*)client_data; - const uint32_t bits_per_sample = frame->header.bits_per_sample; - const uint32_t channels = frame->header.channels; - const uint32_t sample_rate = frame->header.sample_rate; - const uint32_t samples = frame->header.blocksize; - - (void)decoder; - - if( - !instance->error && - (channels == 2 || channels == 1) && - bits_per_sample == instance->bits_per_sample && - channels == instance->channels && - sample_rate == instance->sample_rate - ) { - instance->error = !grabbag__replaygain_analyze(buffer, channels==2, bits_per_sample, samples); - } - else { - instance->error = true; - } - - if(!instance->error) - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; - else - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; -} - -static void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - DecoderInstance *instance = (DecoderInstance*)client_data; - - (void)decoder; - - if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { - instance->bits_per_sample = metadata->data.stream_info.bits_per_sample; - instance->channels = metadata->data.stream_info.channels; - instance->sample_rate = metadata->data.stream_info.sample_rate; - - if(instance->channels != 1 && instance->channels != 2) { - instance->error = true; - return; - } - - if(!grabbag__replaygain_is_valid_sample_frequency(instance->sample_rate)) { - instance->error = true; - return; - } - } -} - -static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - DecoderInstance *instance = (DecoderInstance*)client_data; - - (void)decoder, (void)status; - - instance->error = true; -} - -const char *grabbag__replaygain_analyze_file(const char *filename, float *title_gain, float *title_peak) -{ - DecoderInstance instance; - FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new(); - - if(0 == decoder) - return "memory allocation error"; - - instance.error = false; - - /* It does these three by default but lets be explicit: */ - FLAC__stream_decoder_set_md5_checking(decoder, false); - FLAC__stream_decoder_set_metadata_ignore_all(decoder); - FLAC__stream_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_STREAMINFO); - - if(FLAC__stream_decoder_init_file(decoder, filename, write_callback_, metadata_callback_, error_callback_, &instance) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - FLAC__stream_decoder_delete(decoder); - return "initializing decoder"; - } - - if(!FLAC__stream_decoder_process_until_end_of_stream(decoder) || instance.error) { - FLAC__stream_decoder_delete(decoder); - return "decoding file"; - } - - FLAC__stream_decoder_delete(decoder); - - grabbag__replaygain_get_title(title_gain, title_peak); - - return 0; -} - -const char *grabbag__replaygain_store_to_vorbiscomment(FLAC__StreamMetadata *block, float album_gain, float album_peak, float title_gain, float title_peak) -{ - const char *error; - - if(0 != (error = grabbag__replaygain_store_to_vorbiscomment_reference(block))) - return error; - - if(0 != (error = grabbag__replaygain_store_to_vorbiscomment_title(block, title_gain, title_peak))) - return error; - - if(0 != (error = grabbag__replaygain_store_to_vorbiscomment_album(block, album_gain, album_peak))) - return error; - - return 0; -} - -const char *grabbag__replaygain_store_to_vorbiscomment_reference(FLAC__StreamMetadata *block) -{ - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - if(FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *)GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS) < 0) - return "memory allocation error"; - - if(!append_tag_(block, reference_format_, GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS, ReplayGainReferenceLoudness)) - return "memory allocation error"; - - return 0; -} - -const char *grabbag__replaygain_store_to_vorbiscomment_album(FLAC__StreamMetadata *block, float album_gain, float album_peak) -{ - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - if( - FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *)GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN) < 0 || - FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *)GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK) < 0 - ) - return "memory allocation error"; - - if( - !append_tag_(block, gain_format_, GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN, album_gain) || - !append_tag_(block, peak_format_, GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK, album_peak) - ) - return "memory allocation error"; - - return 0; -} - -const char *grabbag__replaygain_store_to_vorbiscomment_title(FLAC__StreamMetadata *block, float title_gain, float title_peak) -{ - FLAC__ASSERT(0 != block); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - if( - FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *)GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN) < 0 || - FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *)GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK) < 0 - ) - return "memory allocation error"; - - if( - !append_tag_(block, gain_format_, GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN, title_gain) || - !append_tag_(block, peak_format_, GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK, title_peak) - ) - return "memory allocation error"; - - return 0; -} - -static const char *store_to_file_pre_(const char *filename, FLAC__Metadata_Chain **chain, FLAC__StreamMetadata **block) -{ - FLAC__Metadata_Iterator *iterator; - const char *error; - FLAC__bool found_vc_block = false; - - if(0 == (*chain = FLAC__metadata_chain_new())) - return "memory allocation error"; - - if(!FLAC__metadata_chain_read(*chain, filename)) { - error = FLAC__Metadata_ChainStatusString[FLAC__metadata_chain_status(*chain)]; - FLAC__metadata_chain_delete(*chain); - return error; - } - - if(0 == (iterator = FLAC__metadata_iterator_new())) { - FLAC__metadata_chain_delete(*chain); - return "memory allocation error"; - } - - FLAC__metadata_iterator_init(iterator, *chain); - - do { - *block = FLAC__metadata_iterator_get_block(iterator); - if((*block)->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) - found_vc_block = true; - } while(!found_vc_block && FLAC__metadata_iterator_next(iterator)); - - if(!found_vc_block) { - /* create a new block */ - *block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); - if(0 == *block) { - FLAC__metadata_chain_delete(*chain); - FLAC__metadata_iterator_delete(iterator); - return "memory allocation error"; - } - while(FLAC__metadata_iterator_next(iterator)) - ; - if(!FLAC__metadata_iterator_insert_block_after(iterator, *block)) { - error = FLAC__Metadata_ChainStatusString[FLAC__metadata_chain_status(*chain)]; - FLAC__metadata_chain_delete(*chain); - FLAC__metadata_iterator_delete(iterator); - return error; - } - /* iterator is left pointing to new block */ - FLAC__ASSERT(FLAC__metadata_iterator_get_block(iterator) == *block); - } - - FLAC__metadata_iterator_delete(iterator); - - FLAC__ASSERT(0 != *block); - FLAC__ASSERT((*block)->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - return 0; -} - -static const char *store_to_file_post_(const char *filename, FLAC__Metadata_Chain *chain, FLAC__bool preserve_modtime) -{ - struct flac_stat_s stats; - const FLAC__bool have_stats = get_file_stats_(filename, &stats); - - (void)grabbag__file_change_stats(filename, /*read_only=*/false); - - FLAC__metadata_chain_sort_padding(chain); - if(!FLAC__metadata_chain_write(chain, /*use_padding=*/true, preserve_modtime)) { - const char *error; - error = FLAC__Metadata_ChainStatusString[FLAC__metadata_chain_status(chain)]; - FLAC__metadata_chain_delete(chain); - return error; - } - - FLAC__metadata_chain_delete(chain); - - if(have_stats) - set_file_stats_(filename, &stats); - - return 0; -} - -const char *grabbag__replaygain_store_to_file(const char *filename, float album_gain, float album_peak, float title_gain, float title_peak, FLAC__bool preserve_modtime) -{ - FLAC__Metadata_Chain *chain; - FLAC__StreamMetadata *block = NULL; - const char *error; - - if(0 != (error = store_to_file_pre_(filename, &chain, &block))) - return error; - - if(0 != (error = grabbag__replaygain_store_to_vorbiscomment(block, album_gain, album_peak, title_gain, title_peak))) { - FLAC__metadata_chain_delete(chain); - return error; - } - - if(0 != (error = store_to_file_post_(filename, chain, preserve_modtime))) - return error; - - return 0; -} - -const char *grabbag__replaygain_store_to_file_reference(const char *filename, FLAC__bool preserve_modtime) -{ - FLAC__Metadata_Chain *chain; - FLAC__StreamMetadata *block = NULL; - const char *error; - - if(0 != (error = store_to_file_pre_(filename, &chain, &block))) - return error; - - if(0 != (error = grabbag__replaygain_store_to_vorbiscomment_reference(block))) { - FLAC__metadata_chain_delete(chain); - return error; - } - - if(0 != (error = store_to_file_post_(filename, chain, preserve_modtime))) - return error; - - return 0; -} - -const char *grabbag__replaygain_store_to_file_album(const char *filename, float album_gain, float album_peak, FLAC__bool preserve_modtime) -{ - FLAC__Metadata_Chain *chain; - FLAC__StreamMetadata *block = NULL; - const char *error; - - if(0 != (error = store_to_file_pre_(filename, &chain, &block))) - return error; - - if(0 != (error = grabbag__replaygain_store_to_vorbiscomment_album(block, album_gain, album_peak))) { - FLAC__metadata_chain_delete(chain); - return error; - } - - if(0 != (error = store_to_file_post_(filename, chain, preserve_modtime))) - return error; - - return 0; -} - -const char *grabbag__replaygain_store_to_file_title(const char *filename, float title_gain, float title_peak, FLAC__bool preserve_modtime) -{ - FLAC__Metadata_Chain *chain; - FLAC__StreamMetadata *block = NULL; - const char *error; - - if(0 != (error = store_to_file_pre_(filename, &chain, &block))) - return error; - - if(0 != (error = grabbag__replaygain_store_to_vorbiscomment_title(block, title_gain, title_peak))) { - FLAC__metadata_chain_delete(chain); - return error; - } - - if(0 != (error = store_to_file_post_(filename, chain, preserve_modtime))) - return error; - - return 0; -} - -static FLAC__bool parse_double_(const FLAC__StreamMetadata_VorbisComment_Entry *entry, double *val) -{ - char s[32], *end; - const char *p, *q; - double v; - - FLAC__ASSERT(0 != entry); - FLAC__ASSERT(0 != val); - - p = (const char *)entry->entry; - q = strchr(p, '='); - if(0 == q) - return false; - q++; - safe_strncpy(s, q, local_min(sizeof(s), (size_t) (entry->length - (q-p)))); - - v = strtod(s, &end); - if(end == s) - return false; - - *val = v; - return true; -} - -FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *reference, double *gain, double *peak) -{ - int reference_offset, gain_offset, peak_offset; - char *saved_locale; - FLAC__bool res = true; - - FLAC__ASSERT(0 != block); - FLAC__ASSERT(0 != reference); - FLAC__ASSERT(0 != gain); - FLAC__ASSERT(0 != peak); - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - - /* Default to current level until overridden by a detected tag; this - * will always be true until we change replaygain_analysis.c - */ - *reference = ReplayGainReferenceLoudness; - - /* - * We need to save the old locale and switch to "C" because the locale - * influences the behaviour of strtod and we want it a certain way. - */ - saved_locale = strdup(setlocale(LC_ALL, 0)); - if (0 == saved_locale) - return false; - setlocale(LC_ALL, "C"); - - if(0 <= (reference_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS))) - (void)parse_double_(block->data.vorbis_comment.comments + reference_offset, reference); - - if(0 > (gain_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)(album_mode? GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN : GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN)))) - res = false; - if(0 > (peak_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *)(album_mode? GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK : GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK)))) - res = false; - - if(res && !parse_double_(block->data.vorbis_comment.comments + gain_offset, gain)) - res = false; - if(res && !parse_double_(block->data.vorbis_comment.comments + peak_offset, peak)) - res = false; - if(res && *peak < 0.0) - res = false; - - setlocale(LC_ALL, saved_locale); - free(saved_locale); - - /* something failed; retry with strict */ - if (!res && !strict) - res = grabbag__replaygain_load_from_vorbiscomment(block, !album_mode, /*strict=*/true, reference, gain, peak); - - return res; -} - -double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping) -{ - double scale; - FLAC__ASSERT(peak >= 0.0); - gain += preamp; - scale = (float) pow(10.0, gain * 0.05); - if(prevent_clipping && peak > 0.0) { - const double max_scale = (float)(1.0 / peak); - if(scale > max_scale) - scale = max_scale; - } - return scale; -} diff --git a/Engine/lib/flac/src/share/grabbag/seektable.c b/Engine/lib/flac/src/share/grabbag/seektable.c deleted file mode 100644 index 01caa998f..000000000 --- a/Engine/lib/flac/src/share/grabbag/seektable.c +++ /dev/null @@ -1,105 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "share/grabbag.h" -#include "share/compat.h" -#include "FLAC/assert.h" -#include /* for atoi() */ -#include - -FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, uint32_t sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points) -{ - uint32_t i; - const char *pt; - - FLAC__ASSERT(0 != spec); - FLAC__ASSERT(0 != seektable_template); - FLAC__ASSERT(seektable_template->type == FLAC__METADATA_TYPE_SEEKTABLE); - - if(0 != spec_has_real_points) - *spec_has_real_points = false; - - for(pt = spec, i = 0; pt && *pt; i++) { - const char *q = strchr(pt, ';'); - FLAC__ASSERT(0 != q); - - if(q > pt) { - if(0 == strncmp(pt, "X;", 2)) { /* -S X */ - if(!FLAC__metadata_object_seektable_template_append_placeholders(seektable_template, 1)) - return false; - } - else if(q[-1] == 'x') { /* -S #x */ - if(total_samples_to_encode > 0) { /* we can only do these if we know the number of samples to encode up front */ - if(0 != spec_has_real_points) - *spec_has_real_points = true; - if(!only_explicit_placeholders) { - const int n = (uint32_t)atoi(pt); - if(n > 0) - if(!FLAC__metadata_object_seektable_template_append_spaced_points(seektable_template, (uint32_t)n, total_samples_to_encode)) - return false; - } - } - } - else if(q[-1] == 's') { /* -S #s */ - if(total_samples_to_encode > 0 && sample_rate > 0) { /* we can only do these if we know the number of samples and sample rate to encode up front */ - if(0 != spec_has_real_points) - *spec_has_real_points = true; - if(!only_explicit_placeholders) { - const double sec = atof(pt); - if(sec > 0.0) { - uint32_t samples = (uint32_t)(sec * (double)sample_rate); - /* Restrict seekpoints to two per second of audio. */ - samples = samples < sample_rate / 2 ? sample_rate / 2 : samples; - if(samples > 0) { - /* +1 for the initial point at sample 0 */ - if(!FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(seektable_template, samples, total_samples_to_encode)) - return false; - } - } - } - } - } - else { /* -S # */ - if(0 != spec_has_real_points) - *spec_has_real_points = true; - if(!only_explicit_placeholders) { - char *endptr; - const FLAC__int64 n = (FLAC__int64)strtoll(pt, &endptr, 10); - if( - (n > 0 || (endptr > pt && *endptr == ';')) && /* is a valid number (extra check needed for "0") */ - (total_samples_to_encode == 0 || (FLAC__uint64)n < total_samples_to_encode) /* number is not >= the known total_samples_to_encode */ - ) - if(!FLAC__metadata_object_seektable_template_append_point(seektable_template, (FLAC__uint64)n)) - return false; - } - } - } - - pt = ++q; - } - - if(!FLAC__metadata_object_seektable_template_sort(seektable_template, /*compact=*/true)) - return false; - - return true; -} diff --git a/Engine/lib/flac/src/share/grabbag/snprintf.c b/Engine/lib/flac/src/share/grabbag/snprintf.c deleted file mode 100644 index bd7ffba8e..000000000 --- a/Engine/lib/flac/src/share/grabbag/snprintf.c +++ /dev/null @@ -1,101 +0,0 @@ -/* grabbag - Convenience lib for various routines common to several tools - * Copyright (C) 2013-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#include "share/compat.h" - -/* - * FLAC needs to compile and work correctly on systems with a normal ISO C99 - * snprintf as well as Microsoft Visual Studio which has an non-standards - * conformant snprint_s function. - * - * The important difference occurs when the resultant string (plus string - * terminator) would have been longer than the supplied size parameter. When - * this happens, ISO C's snprintf returns the length of resultant string, but - * does not over-write the end of the buffer. MS's snprintf_s in this case - * returns -1. - * - * The _MSC_VER code below attempts to modify the return code for vsnprintf_s - * to something that is more compatible with the behaviour of the ISO C version. - */ - -int -flac_snprintf(char *str, size_t size, const char *fmt, ...) -{ - va_list va; - int rc; - -#if defined _MSC_VER - if (size == 0) - return 1024; -#endif - - va_start (va, fmt); - -#if defined _MSC_VER - rc = vsnprintf_s (str, size, _TRUNCATE, fmt, va); - if (rc < 0) - rc = size - 1; -#elif defined __MINGW32__ - rc = __mingw_vsnprintf (str, size, fmt, va); -#else - rc = vsnprintf (str, size, fmt, va); -#endif - va_end (va); - - return rc; -} - -int -flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va) -{ - int rc; - -#if defined _MSC_VER - if (size == 0) - return 1024; - rc = vsnprintf_s (str, size, _TRUNCATE, fmt, va); - if (rc < 0) - rc = size - 1; -#elif defined __MINGW32__ - rc = __mingw_vsnprintf (str, size, fmt, va); -#else - rc = vsnprintf (str, size, fmt, va); -#endif - - return rc; -} diff --git a/Engine/lib/flac/src/share/replaygain_analysis/CMakeLists.txt b/Engine/lib/flac/src/share/replaygain_analysis/CMakeLists.txt deleted file mode 100644 index 4362b9025..000000000 --- a/Engine/lib/flac/src/share/replaygain_analysis/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_library(replaygain_analysis STATIC - replaygain_analysis.c) diff --git a/Engine/lib/flac/src/share/replaygain_analysis/replaygain_analysis.c b/Engine/lib/flac/src/share/replaygain_analysis/replaygain_analysis.c deleted file mode 100644 index 37b77ab09..000000000 --- a/Engine/lib/flac/src/share/replaygain_analysis/replaygain_analysis.c +++ /dev/null @@ -1,575 +0,0 @@ -/* - * ReplayGainAnalysis - analyzes input samples and give the recommended dB change - * Copyright (C) 2001 David Robinson and Glen Sawyer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * concept and filter values by David Robinson (David@Robinson.org) - * -- blame him if you think the idea is flawed - * original coding by Glen Sawyer (glensawyer@hotmail.com) - * -- blame him if you think this runs too slowly, or the coding is otherwise flawed - * - * lots of code improvements by Frank Klemm ( http://www.uni-jena.de/~pfk/mpp/ ) - * -- credit him for all the _good_ programming ;) - * - * minor cosmetic tweaks to integrate with FLAC by Josh Coalson - * - * - * For an explanation of the concepts and the basic algorithms involved, go to: - * http://www.replaygain.org/ - */ - -/* - * Here's the deal. Call - * - * InitGainAnalysis ( long samplefreq ); - * - * to initialize everything. Call - * - * AnalyzeSamples ( const flac_float_t* left_samples, - * const flac_float_t* right_samples, - * size_t num_samples, - * int num_channels ); - * - * as many times as you want, with as many or as few samples as you want. - * If mono, pass the sample buffer in through left_samples, leave - * right_samples NULL, and make sure num_channels = 1. - * - * GetTitleGain() - * - * will return the recommended dB level change for all samples analyzed - * SINCE THE LAST TIME you called GetTitleGain() OR InitGainAnalysis(). - * - * GetAlbumGain() - * - * will return the recommended dB level change for all samples analyzed - * since InitGainAnalysis() was called and finalized with GetTitleGain(). - * - * Pseudo-code to process an album: - * - * flac_float_t l_samples [4096]; - * flac_float_t r_samples [4096]; - * size_t num_samples; - * uint32_t num_songs; - * uint32_t i; - * - * InitGainAnalysis ( 44100 ); - * for ( i = 1; i <= num_songs; i++ ) { - * while ( ( num_samples = getSongSamples ( song[i], left_samples, right_samples ) ) > 0 ) - * AnalyzeSamples ( left_samples, right_samples, num_samples, 2 ); - * fprintf ("Recommended dB change for song %2d: %+6.2f dB\n", i, GetTitleGain() ); - * } - * fprintf ("Recommended dB change for whole album: %+6.2f dB\n", GetAlbumGain() ); - */ - -/* - * So here's the main source of potential code confusion: - * - * The filters applied to the incoming samples are IIR filters, - * meaning they rely on up to number of previous samples - * AND up to number of previous filtered samples. - * - * I set up the AnalyzeSamples routine to minimize memory usage and interface - * complexity. The speed isn't compromised too much (I don't think), but the - * internal complexity is higher than it should be for such a relatively - * simple routine. - * - * Optimization/clarity suggestions are welcome. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include "share/alloc.h" -#include "share/compat.h" -#include "share/replaygain_analysis.h" - -flac_float_t ReplayGainReferenceLoudness = 89.0; /* in dB SPL */ - -#define YULE_ORDER 10 -#define BUTTER_ORDER 2 -#define RMS_PERCENTILE 0.95 /* percentile which is louder than the proposed level */ -#define RMS_WINDOW_TIME 50 /* Time slice size [ms] */ -#define STEPS_per_dB 100. /* Table entries per dB */ -#define MAX_dB 120. /* Table entries for 0...MAX_dB (normal max. values are 70...80 dB) */ - -#define MAX_ORDER (BUTTER_ORDER > YULE_ORDER ? BUTTER_ORDER : YULE_ORDER) -#define PINK_REF 64.82 /* 298640883795 */ /* calibration value */ - -static flac_float_t linprebuf [MAX_ORDER * 2]; -static flac_float_t* linpre; /* left input samples, with pre-buffer */ -static flac_float_t* lstepbuf; -static flac_float_t* lstep; /* left "first step" (i.e. post first filter) samples */ -static flac_float_t* loutbuf; -static flac_float_t* lout; /* left "out" (i.e. post second filter) samples */ -static flac_float_t rinprebuf [MAX_ORDER * 2]; -static flac_float_t* rinpre; /* right input samples ... */ -static flac_float_t* rstepbuf; -static flac_float_t* rstep; -static flac_float_t* routbuf; -static flac_float_t* rout; -static uint32_t sampleWindow; /* number of samples required to reach number of milliseconds required for RMS window */ -static uint64_t totsamp; -static double lsum; -static double rsum; -#if 0 -static uint32_t A [(size_t)(STEPS_per_dB * MAX_dB)]; -static uint32_t B [(size_t)(STEPS_per_dB * MAX_dB)]; -#else -/* [JEC] Solaris Forte compiler doesn't like float calc in array indices */ -static uint32_t A [120 * 100]; -static uint32_t B [120 * 100]; -#endif - -#ifdef _MSC_VER -#pragma warning ( disable : 4305 ) -#endif - -struct ReplayGainFilter { - long rate; - uint32_t downsample; - flac_float_t BYule[YULE_ORDER+1]; - flac_float_t AYule[YULE_ORDER+1]; - flac_float_t BButter[BUTTER_ORDER+1]; - flac_float_t AButter[BUTTER_ORDER+1]; -}; - -static struct ReplayGainFilter *replaygainfilter; - -static const struct ReplayGainFilter ReplayGainFilters[] = { - - { - 48000, 0, /* ORIGINAL */ - { 0.03857599435200, -0.02160367184185, -0.00123395316851, -0.00009291677959, -0.01655260341619, 0.02161526843274, -0.02074045215285, 0.00594298065125, 0.00306428023191, 0.00012025322027, 0.00288463683916 }, - { 1.00000000000000, -3.84664617118067, 7.81501653005538, -11.34170355132042, 13.05504219327545, -12.28759895145294, 9.48293806319790, -5.87257861775999, 2.75465861874613, -0.86984376593551, 0.13919314567432 }, - { 0.98621192462708, -1.97242384925416, 0.98621192462708 }, - { 1.00000000000000, -1.97223372919527, 0.97261396931306 }, - }, - - { - 44100, 0, /* ORIGINAL */ - { 0.05418656406430, -0.02911007808948, -0.00848709379851, -0.00851165645469, -0.00834990904936, 0.02245293253339, -0.02596338512915, 0.01624864962975, -0.00240879051584, 0.00674613682247, -0.00187763777362 }, - { 1.00000000000000, -3.47845948550071, 6.36317777566148, -8.54751527471874, 9.47693607801280, -8.81498681370155, 6.85401540936998, -4.39470996079559, 2.19611684890774, -0.75104302451432, 0.13149317958808 }, - { 0.98500175787242, -1.97000351574484, 0.98500175787242 }, - { 1.00000000000000, -1.96977855582618, 0.97022847566350 }, - }, - - { - 37800, 0, - { 0.10296717174470, -0.04877975583256, -0.02878009075237, -0.03519509188311, 0.02888717172493, -0.00609872684844, 0.00209851217112, 0.00911704668543, 0.01154404718589, -0.00630293688700, 0.00107527155228 }, - { 1.00000000000000, -2.64848054923531, 3.58406058405771, -3.83794914179161, 3.90142345804575, -3.50179818637243, 2.67085284083076, -1.82581142372418, 1.09530368139801, -0.47689017820395, 0.11171431535905 }, - { 0.98252400815195, -1.96504801630391, 0.98252400815195 }, - { 1.00000000000000, -1.96474258269041, 0.96535344991740 }, - }, - - { - 36000, 0, - { 0.11572297028613, -0.04120916051252, -0.04977731768022, -0.01047308680426, 0.00750863219157, 0.00055507694408, 0.00140344192886, 0.01286095246036, 0.00998223033885, -0.00725013810661, 0.00326503346879 }, - { 1.00000000000000, -2.43606802820871, 3.01907406973844, -2.90372016038192, 2.67947188094303, -2.17606479220391, 1.44912956803015, -0.87785765549050, 0.53592202672557, -0.26469344817509, 0.07495878059717 }, - { 0.98165826840326, -1.96331653680652, 0.98165826840326 }, - { 1.00000000000000, -1.96298008938934, 0.96365298422371 }, - }, - - { - 32000, 0, /* ORIGINAL */ - { 0.15457299681924, -0.09331049056315, -0.06247880153653, 0.02163541888798, -0.05588393329856, 0.04781476674921, 0.00222312597743, 0.03174092540049, -0.01390589421898, 0.00651420667831, -0.00881362733839 }, - { 1.00000000000000, -2.37898834973084, 2.84868151156327, -2.64577170229825, 2.23697657451713, -1.67148153367602, 1.00595954808547, -0.45953458054983, 0.16378164858596, -0.05032077717131, 0.02347897407020 }, - { 0.97938932735214, -1.95877865470428, 0.97938932735214 }, - { 1.00000000000000, -1.95835380975398, 0.95920349965459 }, - }, - - { - 28000, 0, - { 0.23882392323383, -0.22007791534089, -0.06014581950332, 0.05004458058021, -0.03293111254977, 0.02348678189717, 0.04290549799671, -0.00938141862174, 0.00015095146303, -0.00712601540885, -0.00626520210162 }, - { 1.00000000000000, -2.06894080899139, 1.76944699577212, -0.81404732584187, 0.25418286850232, -0.30340791669762, 0.35616884070937, -0.14967310591258, -0.07024154183279, 0.11078404345174, -0.03551838002425 }, - { 0.97647981663949, -1.95295963327897, 0.97647981663949 }, - { 1.00000000000000, -1.95240635772520, 0.95351290883275 }, - - }, - - { - 24000, 0, /* ORIGINAL */ - { 0.30296907319327, -0.22613988682123, -0.08587323730772, 0.03282930172664, -0.00915702933434, -0.02364141202522, -0.00584456039913, 0.06276101321749, -0.00000828086748, 0.00205861885564, -0.02950134983287 }, - { 1.00000000000000, -1.61273165137247, 1.07977492259970, -0.25656257754070, -0.16276719120440, -0.22638893773906, 0.39120800788284, -0.22138138954925, 0.04500235387352, 0.02005851806501, 0.00302439095741 }, - { 0.97531843204928, -1.95063686409857, 0.97531843204928 }, - { 1.00000000000000, -1.95002759149878, 0.95124613669835 }, - }, - - { - 22050, 0, /* ORIGINAL */ - { 0.33642304856132, -0.25572241425570, -0.11828570177555, 0.11921148675203, -0.07834489609479, -0.00469977914380, -0.00589500224440, 0.05724228140351, 0.00832043980773, -0.01635381384540, -0.01760176568150 }, - { 1.00000000000000, -1.49858979367799, 0.87350271418188, 0.12205022308084, -0.80774944671438, 0.47854794562326, -0.12453458140019, -0.04067510197014, 0.08333755284107, -0.04237348025746, 0.02977207319925 }, - { 0.97316523498161, -1.94633046996323, 0.97316523498161 }, - { 1.00000000000000, -1.94561023566527, 0.94705070426118 }, - }, - - { - 18900, 0, - { 0.38412657295385, -0.44533729608120, 0.20426638066221, -0.28031676047946, 0.31484202614802, -0.26078311203207, 0.12925201224848, -0.01141164696062, 0.03036522115769, -0.03776339305406, 0.00692036603586 }, - { 1.00000000000000, -1.74403915585708, 1.96686095832499, -2.10081452941881, 1.90753918182846, -1.83814263754422, 1.36971352214969, -0.77883609116398, 0.39266422457649, -0.12529383592986, 0.05424760697665 }, - { 0.96535326815829, -1.93070653631658, 0.96535326815829 }, - { 1.00000000000000, -1.92950577983524, 0.93190729279793 }, - }, - - { - 16000, 0, /* ORIGINAL */ - { 0.44915256608450, -0.14351757464547, -0.22784394429749, -0.01419140100551, 0.04078262797139, -0.12398163381748, 0.04097565135648, 0.10478503600251, -0.01863887810927, -0.03193428438915, 0.00541907748707 }, - { 1.00000000000000, -0.62820619233671, 0.29661783706366, -0.37256372942400, 0.00213767857124, -0.42029820170918, 0.22199650564824, 0.00613424350682, 0.06747620744683, 0.05784820375801, 0.03222754072173 }, - { 0.96454515552826, -1.92909031105652, 0.96454515552826 }, - { 1.00000000000000, -1.92783286977036, 0.93034775234268 }, - }, - - { - 12000, 0, /* ORIGINAL */ - { 0.56619470757641, -0.75464456939302, 0.16242137742230, 0.16744243493672, -0.18901604199609, 0.30931782841830, -0.27562961986224, 0.00647310677246, 0.08647503780351, -0.03788984554840, -0.00588215443421 }, - { 1.00000000000000, -1.04800335126349, 0.29156311971249, -0.26806001042947, 0.00819999645858, 0.45054734505008, -0.33032403314006, 0.06739368333110, -0.04784254229033, 0.01639907836189, 0.01807364323573 }, - { 0.96009142950541, -1.92018285901082, 0.96009142950541 }, - { 1.00000000000000, -1.91858953033784, 0.92177618768381 }, - }, - - { - 11025, 0, /* ORIGINAL */ - { 0.58100494960553, -0.53174909058578, -0.14289799034253, 0.17520704835522, 0.02377945217615, 0.15558449135573, -0.25344790059353, 0.01628462406333, 0.06920467763959, -0.03721611395801, -0.00749618797172 }, - { 1.00000000000000, -0.51035327095184, -0.31863563325245, -0.20256413484477, 0.14728154134330, 0.38952639978999, -0.23313271880868, -0.05246019024463, -0.02505961724053, 0.02442357316099, 0.01818801111503 }, - { 0.95856916599601, -1.91713833199203, 0.95856916599601 }, - { 1.00000000000000, -1.91542108074780, 0.91885558323625 }, - }, - - { - 8000, 0, /* ORIGINAL */ - { 0.53648789255105, -0.42163034350696, -0.00275953611929, 0.04267842219415, -0.10214864179676, 0.14590772289388, -0.02459864859345, -0.11202315195388, -0.04060034127000, 0.04788665548180, -0.02217936801134 }, - { 1.00000000000000, -0.25049871956020, -0.43193942311114, -0.03424681017675, -0.04678328784242, 0.26408300200955, 0.15113130533216, -0.17556493366449, -0.18823009262115, 0.05477720428674, 0.04704409688120 }, - { 0.94597685600279, -1.89195371200558, 0.94597685600279 }, - { 1.00000000000000, -1.88903307939452, 0.89487434461664 }, - }, - -}; - -#ifdef _MSC_VER -#pragma warning ( default : 4305 ) -#endif - -/* When calling this procedure, make sure that ip[-order] and op[-order] point to real data! */ - -static void -filter ( const flac_float_t* input, flac_float_t* output, size_t nSamples, const flac_float_t* a, const flac_float_t* b, size_t order, uint32_t downsample ) -{ - double y; - size_t i; - size_t k; - - const flac_float_t* input_head = input; - const flac_float_t* input_tail; - - flac_float_t* output_head = output; - flac_float_t* output_tail; - - for ( i = 0; i < nSamples; i++, input_head += downsample, ++output_head ) { - - input_tail = input_head; - output_tail = output_head; - - y = *input_head * b[0]; - - for ( k = 1; k <= order; k++ ) { - input_tail -= downsample; - --output_tail; - y += *input_tail * b[k] - *output_tail * a[k]; - } - - output[i] = (flac_float_t)y; - } -} - -/* returns a INIT_GAIN_ANALYSIS_OK if successful, INIT_GAIN_ANALYSIS_ERROR if not */ - -static struct ReplayGainFilter* -CreateGainFilter ( long samplefreq ) -{ - uint32_t i; - long maxrate = 0; - uint32_t downsample = 1; - struct ReplayGainFilter* gainfilter = malloc(sizeof(*gainfilter)); - - if ( !gainfilter ) - return 0; - - while (1) { - for ( i = 0; i < sizeof(ReplayGainFilters)/sizeof(ReplayGainFilters[0]); ++i ) { - if (maxrate < ReplayGainFilters[i].rate) - maxrate = ReplayGainFilters[i].rate; - - if ( ReplayGainFilters[i].rate == samplefreq ) { - *gainfilter = ReplayGainFilters[i]; - gainfilter->downsample = downsample; - return gainfilter; - } - } - - if (samplefreq < maxrate) - break; - - while (samplefreq > maxrate) { - downsample *= 2; - samplefreq /= 2; - } - } - - free(gainfilter); - - return 0; -} - -static void* -ReallocateWindowBuffer(uint32_t window_size, flac_float_t **window_buffer) -{ - *window_buffer = safe_realloc_(*window_buffer, sizeof(**window_buffer) * (window_size + MAX_ORDER)); - return *window_buffer; -} - -static int -ResetSampleFrequency ( long samplefreq ) { - int i; - - free(replaygainfilter); - - replaygainfilter = CreateGainFilter( samplefreq ); - - if ( ! replaygainfilter) - return INIT_GAIN_ANALYSIS_ERROR; - - sampleWindow = - (replaygainfilter->rate * RMS_WINDOW_TIME + 1000-1) / 1000; - - if ( ! ReallocateWindowBuffer(sampleWindow, &lstepbuf) || - ! ReallocateWindowBuffer(sampleWindow, &rstepbuf) || - ! ReallocateWindowBuffer(sampleWindow, &loutbuf) || - ! ReallocateWindowBuffer(sampleWindow, &routbuf) ) { - - return INIT_GAIN_ANALYSIS_ERROR; - } - - /* zero out initial values */ - for ( i = 0; i < MAX_ORDER; i++ ) - linprebuf[i] = lstepbuf[i] = loutbuf[i] = rinprebuf[i] = rstepbuf[i] = routbuf[i] = 0.; - - lsum = 0.; - rsum = 0.; - totsamp = 0; - - memset ( A, 0, sizeof(A) ); - - return INIT_GAIN_ANALYSIS_OK; -} - -int -ValidGainFrequency ( long samplefreq ) -{ - struct ReplayGainFilter* gainfilter = CreateGainFilter( samplefreq ); - - if (gainfilter == 0) { - return 0; - } else { - free(gainfilter); - return 1; - } -} - -int -InitGainAnalysis ( long samplefreq ) -{ - if (ResetSampleFrequency(samplefreq) != INIT_GAIN_ANALYSIS_OK) { - return INIT_GAIN_ANALYSIS_ERROR; - } - - linpre = linprebuf + MAX_ORDER; - rinpre = rinprebuf + MAX_ORDER; - lstep = lstepbuf + MAX_ORDER; - rstep = rstepbuf + MAX_ORDER; - lout = loutbuf + MAX_ORDER; - rout = routbuf + MAX_ORDER; - - memset ( B, 0, sizeof(B) ); - - return INIT_GAIN_ANALYSIS_OK; -} - -/* returns GAIN_ANALYSIS_OK if successful, GAIN_ANALYSIS_ERROR if not */ - -int -AnalyzeSamples ( const flac_float_t* left_samples, const flac_float_t* right_samples, size_t num_samples, int num_channels ) -{ - uint32_t downsample = replaygainfilter->downsample; - const flac_float_t* curleft; - const flac_float_t* curright; - long prebufsamples; - long batchsamples; - long cursamples; - long cursamplepos; - int i; - - num_samples /= downsample; - - if ( num_samples == 0 ) - return GAIN_ANALYSIS_OK; - - cursamplepos = 0; - batchsamples = num_samples; - - switch ( num_channels) { - case 1: right_samples = left_samples; - case 2: break; - default: return GAIN_ANALYSIS_ERROR; - } - - prebufsamples = MAX_ORDER; - if ((size_t) prebufsamples > num_samples) - prebufsamples = num_samples; - - for ( i = 0; i < prebufsamples; ++i ) { - linprebuf[i+MAX_ORDER] = left_samples [i * downsample]; - rinprebuf[i+MAX_ORDER] = right_samples[i * downsample]; - } - - while ( batchsamples > 0 ) { - cursamples = batchsamples > (long)(sampleWindow-totsamp) ? (long)(sampleWindow - totsamp) : batchsamples; - if ( cursamplepos < MAX_ORDER ) { - downsample = 1; - curleft = linpre+cursamplepos; - curright = rinpre+cursamplepos; - if (cursamples > MAX_ORDER - cursamplepos ) - cursamples = MAX_ORDER - cursamplepos; - } - else { - downsample = replaygainfilter->downsample; - curleft = left_samples + cursamplepos * downsample; - curright = right_samples + cursamplepos * downsample; - } - - filter ( curleft , lstep + totsamp, cursamples, replaygainfilter->AYule, replaygainfilter->BYule, YULE_ORDER, downsample ); - filter ( curright, rstep + totsamp, cursamples, replaygainfilter->AYule, replaygainfilter->BYule, YULE_ORDER, downsample ); - - filter ( lstep + totsamp, lout + totsamp, cursamples, replaygainfilter->AButter, replaygainfilter->BButter, BUTTER_ORDER, 1 ); - filter ( rstep + totsamp, rout + totsamp, cursamples, replaygainfilter->AButter, replaygainfilter->BButter, BUTTER_ORDER, 1 ); - - for ( i = 0; i < cursamples; i++ ) { /* Get the squared values */ - lsum += lout [totsamp+i] * lout [totsamp+i]; - rsum += rout [totsamp+i] * rout [totsamp+i]; - } - - batchsamples -= cursamples; - cursamplepos += cursamples; - totsamp += cursamples; - if ( totsamp == sampleWindow ) { /* Get the Root Mean Square (RMS) for this set of samples */ - double val = STEPS_per_dB * 10. * log10 ( (lsum+rsum) / totsamp * 0.5 + 1.e-37 ); - int ival = (int) val; - if ( ival < 0 ) ival = 0; - if ( ival >= (int)(sizeof(A)/sizeof(*A)) ) ival = (int)(sizeof(A)/sizeof(*A)) - 1; - A [ival]++; - lsum = rsum = 0.; - memmove ( loutbuf , loutbuf + totsamp, MAX_ORDER * sizeof(flac_float_t) ); - memmove ( routbuf , routbuf + totsamp, MAX_ORDER * sizeof(flac_float_t) ); - memmove ( lstepbuf, lstepbuf + totsamp, MAX_ORDER * sizeof(flac_float_t) ); - memmove ( rstepbuf, rstepbuf + totsamp, MAX_ORDER * sizeof(flac_float_t) ); - totsamp = 0; - } - if ( totsamp > sampleWindow ) /* somehow I really screwed up: Error in programming! Contact author about totsamp > sampleWindow */ - return GAIN_ANALYSIS_ERROR; - } - - if ( num_samples < MAX_ORDER ) { - memmove ( linprebuf, linprebuf + num_samples, (MAX_ORDER-num_samples) * sizeof(flac_float_t) ); - memmove ( rinprebuf, rinprebuf + num_samples, (MAX_ORDER-num_samples) * sizeof(flac_float_t) ); - memcpy ( linprebuf + MAX_ORDER - num_samples, left_samples, num_samples * sizeof(flac_float_t) ); - memcpy ( rinprebuf + MAX_ORDER - num_samples, right_samples, num_samples * sizeof(flac_float_t) ); - } - else { - downsample = replaygainfilter->downsample; - - left_samples += (num_samples - MAX_ORDER) * downsample; - right_samples += (num_samples - MAX_ORDER) * downsample; - - for ( i = 0; i < MAX_ORDER; ++i ) { - linprebuf[i] = left_samples [i * downsample]; - rinprebuf[i] = right_samples[i * downsample]; - } - } - - return GAIN_ANALYSIS_OK; -} - - -static flac_float_t -analyzeResult ( uint32_t* Array, size_t len ) -{ - uint32_t elems; - int32_t upper; - size_t i; - - elems = 0; - for ( i = 0; i < len; i++ ) - elems += Array[i]; - if ( elems == 0 ) - return GAIN_NOT_ENOUGH_SAMPLES; - -/* workaround for GCC bug #61423: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61423 */ -#if 0 - upper = (int32_t) ceil (elems * (1. - RMS_PERCENTILE)); -#else - upper = (int32_t) (elems / 20 + ((elems % 20) ? 1 : 0)); -#endif - for ( i = len; i-- > 0; ) { - if ( (upper -= Array[i]) <= 0 ) - break; - } - - return (flac_float_t) ((flac_float_t)PINK_REF - (flac_float_t)i / (flac_float_t)STEPS_per_dB); -} - - -flac_float_t -GetTitleGain ( void ) -{ - flac_float_t retval; - uint32_t i; - - retval = analyzeResult ( A, sizeof(A)/sizeof(*A) ); - - for ( i = 0; i < sizeof(A)/sizeof(*A); i++ ) { - B[i] += A[i]; - A[i] = 0; - } - - for ( i = 0; i < MAX_ORDER; i++ ) - linprebuf[i] = lstepbuf[i] = loutbuf[i] = rinprebuf[i] = rstepbuf[i] = routbuf[i] = 0.f; - - totsamp = 0; - lsum = rsum = 0.; - return retval; -} - - -flac_float_t -GetAlbumGain ( void ) -{ - return analyzeResult ( B, sizeof(B)/sizeof(*B) ); -} - -/* end of replaygain_analysis.c */ diff --git a/Engine/lib/flac/src/share/replaygain_synthesis/CMakeLists.txt b/Engine/lib/flac/src/share/replaygain_synthesis/CMakeLists.txt deleted file mode 100644 index 0736f4fce..000000000 --- a/Engine/lib/flac/src/share/replaygain_synthesis/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_library(replaygain_synthesis STATIC - replaygain_synthesis.c) diff --git a/Engine/lib/flac/src/share/replaygain_synthesis/replaygain_synthesis.c b/Engine/lib/flac/src/share/replaygain_synthesis/replaygain_synthesis.c deleted file mode 100644 index 8d4fda6b9..000000000 --- a/Engine/lib/flac/src/share/replaygain_synthesis/replaygain_synthesis.c +++ /dev/null @@ -1,429 +0,0 @@ -/* replaygain_synthesis - Routines for applying ReplayGain to a signal - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -/* - * This is an aggregation of pieces of code from John Edwards' WaveGain - * program. Mostly cosmetic changes were made; otherwise, the dithering - * code is almost untouched and the gain processing was converted from - * processing a whole file to processing chunks of samples. - * - * The original copyright notices for WaveGain's dither.c and wavegain.c - * appear below: - */ -/* - * (c) 2002 John Edwards - * mostly lifted from work by Frank Klemm - * random functions for dithering. - */ -/* - * Copyright (C) 2002 John Edwards - * Additional code by Magnus Holmgren and Gian-Carlo Pascutto - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include /* for memset() */ -#include -#include "share/compat.h" -#include "share/replaygain_synthesis.h" -#include "FLAC/assert.h" - -#define FLAC__I64L(x) x##LL - - -/* - * the following is based on parts of dither.c - */ - - -/* - * This is a simple random number generator with good quality for audio purposes. - * It consists of two polycounters with opposite rotation direction and different - * periods. The periods are coprime, so the total period is the product of both. - * - * ------------------------------------------------------------------------------------------------- - * +-> |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| - * | ------------------------------------------------------------------------------------------------- - * | | | | | | | - * | +--+--+--+-XOR-+--------+ - * | | - * +--------------------------------------------------------------------------------------+ - * - * ------------------------------------------------------------------------------------------------- - * |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| <-+ - * ------------------------------------------------------------------------------------------------- | - * | | | | | - * +--+----XOR----+--+ | - * | | - * +----------------------------------------------------------------------------------------+ - * - * - * The first has an period of 3*5*17*257*65537, the second of 7*47*73*178481, - * which gives a period of 18.410.713.077.675.721.215. The result is the - * XORed values of both generators. - */ - -static uint32_t random_int_(void) -{ - static const uint8_t parity_[256] = { - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 - }; - static uint32_t r1_ = 1; - static uint32_t r2_ = 1; - - uint32_t t1, t2, t3, t4; - - /* Parity calculation is done via table lookup, this is also available - * on CPUs without parity, can be implemented in C and avoid unpredictable - * jumps and slow rotate through the carry flag operations. - */ - t3 = t1 = r1_; t4 = t2 = r2_; - t1 &= 0xF5; t2 >>= 25; - t1 = parity_[t1]; t2 &= 0x63; - t1 <<= 31; t2 = parity_[t2]; - - return (r1_ = (t3 >> 1) | t1 ) ^ (r2_ = (t4 + t4) | t2 ); -} - -/* gives a equal distributed random number */ -/* between -2^31*mult and +2^31*mult */ -static double random_equi_(double mult) -{ - return mult * (int) random_int_(); -} - -/* gives a triangular distributed random number */ -/* between -2^32*mult and +2^32*mult */ -static double random_triangular_(double mult) -{ - return mult * ( (double) (int) random_int_() + (double) (int) random_int_() ); -} - - -static const float F44_0 [16 + 32] = { - (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, - (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, - - (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, - (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, - - (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, - (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0, (float)0 -}; - - -static const float F44_1 [16 + 32] = { /* SNR(w) = 4.843163 dB, SNR = -3.192134 dB */ - (float) 0.85018292704024355931, (float) 0.29089597350995344721, (float)-0.05021866022121039450, (float)-0.23545456294599161833, - (float)-0.58362726442227032096, (float)-0.67038978965193036429, (float)-0.38566861572833459221, (float)-0.15218663390367969967, - (float)-0.02577543084864530676, (float) 0.14119295297688728127, (float) 0.22398848581628781612, (float) 0.15401727203382084116, - (float) 0.05216161232906000929, (float)-0.00282237820999675451, (float)-0.03042794608323867363, (float)-0.03109780942998826024, - - (float) 0.85018292704024355931, (float) 0.29089597350995344721, (float)-0.05021866022121039450, (float)-0.23545456294599161833, - (float)-0.58362726442227032096, (float)-0.67038978965193036429, (float)-0.38566861572833459221, (float)-0.15218663390367969967, - (float)-0.02577543084864530676, (float) 0.14119295297688728127, (float) 0.22398848581628781612, (float) 0.15401727203382084116, - (float) 0.05216161232906000929, (float)-0.00282237820999675451, (float)-0.03042794608323867363, (float)-0.03109780942998826024, - - (float) 0.85018292704024355931, (float) 0.29089597350995344721, (float)-0.05021866022121039450, (float)-0.23545456294599161833, - (float)-0.58362726442227032096, (float)-0.67038978965193036429, (float)-0.38566861572833459221, (float)-0.15218663390367969967, - (float)-0.02577543084864530676, (float) 0.14119295297688728127, (float) 0.22398848581628781612, (float) 0.15401727203382084116, - (float) 0.05216161232906000929, (float)-0.00282237820999675451, (float)-0.03042794608323867363, (float)-0.03109780942998826024, -}; - - -static const float F44_2 [16 + 32] = { /* SNR(w) = 10.060213 dB, SNR = -12.766730 dB */ - (float) 1.78827593892108555290, (float) 0.95508210637394326553, (float)-0.18447626783899924429, (float)-0.44198126506275016437, - (float)-0.88404052492547413497, (float)-1.42218907262407452967, (float)-1.02037566838362314995, (float)-0.34861755756425577264, - (float)-0.11490230170431934434, (float) 0.12498899339968611803, (float) 0.38065885268563131927, (float) 0.31883491321310506562, - (float) 0.10486838686563442765, (float)-0.03105361685110374845, (float)-0.06450524884075370758, (float)-0.02939198261121969816, - - (float) 1.78827593892108555290, (float) 0.95508210637394326553, (float)-0.18447626783899924429, (float)-0.44198126506275016437, - (float)-0.88404052492547413497, (float)-1.42218907262407452967, (float)-1.02037566838362314995, (float)-0.34861755756425577264, - (float)-0.11490230170431934434, (float) 0.12498899339968611803, (float) 0.38065885268563131927, (float) 0.31883491321310506562, - (float) 0.10486838686563442765, (float)-0.03105361685110374845, (float)-0.06450524884075370758, (float)-0.02939198261121969816, - - (float) 1.78827593892108555290, (float) 0.95508210637394326553, (float)-0.18447626783899924429, (float)-0.44198126506275016437, - (float)-0.88404052492547413497, (float)-1.42218907262407452967, (float)-1.02037566838362314995, (float)-0.34861755756425577264, - (float)-0.11490230170431934434, (float) 0.12498899339968611803, (float) 0.38065885268563131927, (float) 0.31883491321310506562, - (float) 0.10486838686563442765, (float)-0.03105361685110374845, (float)-0.06450524884075370758, (float)-0.02939198261121969816, -}; - - -static const float F44_3 [16 + 32] = { /* SNR(w) = 15.382598 dB, SNR = -29.402334 dB */ - (float) 2.89072132015058161445, (float) 2.68932810943698754106, (float) 0.21083359339410251227, (float)-0.98385073324997617515, - (float)-1.11047823227097316719, (float)-2.18954076314139673147, (float)-2.36498032881953056225, (float)-0.95484132880101140785, - (float)-0.23924057925542965158, (float)-0.13865235703915925642, (float) 0.43587843191057992846, (float) 0.65903257226026665927, - (float) 0.24361815372443152787, (float)-0.00235974960154720097, (float) 0.01844166574603346289, (float) 0.01722945988740875099, - - (float) 2.89072132015058161445, (float) 2.68932810943698754106, (float) 0.21083359339410251227, (float)-0.98385073324997617515, - (float)-1.11047823227097316719, (float)-2.18954076314139673147, (float)-2.36498032881953056225, (float)-0.95484132880101140785, - (float)-0.23924057925542965158, (float)-0.13865235703915925642, (float) 0.43587843191057992846, (float) 0.65903257226026665927, - (float) 0.24361815372443152787, (float)-0.00235974960154720097, (float) 0.01844166574603346289, (float) 0.01722945988740875099, - - (float) 2.89072132015058161445, (float) 2.68932810943698754106, (float) 0.21083359339410251227, (float)-0.98385073324997617515, - (float)-1.11047823227097316719, (float)-2.18954076314139673147, (float)-2.36498032881953056225, (float)-0.95484132880101140785, - (float)-0.23924057925542965158, (float)-0.13865235703915925642, (float) 0.43587843191057992846, (float) 0.65903257226026665927, - (float) 0.24361815372443152787, (float)-0.00235974960154720097, (float) 0.01844166574603346289, (float) 0.01722945988740875099 -}; - - -static double scalar16_(const float* x, const float* y) -{ - return - x[ 0]*y[ 0] + x[ 1]*y[ 1] + x[ 2]*y[ 2] + x[ 3]*y[ 3] + - x[ 4]*y[ 4] + x[ 5]*y[ 5] + x[ 6]*y[ 6] + x[ 7]*y[ 7] + - x[ 8]*y[ 8] + x[ 9]*y[ 9] + x[10]*y[10] + x[11]*y[11] + - x[12]*y[12] + x[13]*y[13] + x[14]*y[14] + x[15]*y[15]; -} - - -void FLAC__replaygain_synthesis__init_dither_context(DitherContext *d, int bits, int shapingtype) -{ - static uint8_t default_dither [] = { 92, 92, 88, 84, 81, 78, 74, 67, 0, 0 }; - static const float* F [] = { F44_0, F44_1, F44_2, F44_3 }; - - int indx; - - if (shapingtype < 0) shapingtype = 0; - if (shapingtype > 3) shapingtype = 3; - d->ShapingType = (NoiseShaping)shapingtype; - indx = bits - 11 - shapingtype; - if (indx < 0) indx = 0; - if (indx > 9) indx = 9; - - memset ( d->ErrorHistory , 0, sizeof (d->ErrorHistory ) ); - memset ( d->DitherHistory, 0, sizeof (d->DitherHistory) ); - - d->FilterCoeff = F [shapingtype]; - d->Mask = ((FLAC__uint64)-1) << (32 - bits); - d->Add = 0.5 * ((1L << (32 - bits)) - 1); - d->Dither = 0.01f*default_dither[indx] / (((FLAC__int64)1) << bits); - d->LastHistoryIndex = 0; -} - -static inline int64_t -ROUND64 (DitherContext *d, double x) -{ - union { - double d; - int64_t i; - } doubletmp; - - doubletmp.d = x + d->Add + (int64_t)FLAC__I64L(0x001FFFFD80000000); - - return doubletmp.i - (int64_t)FLAC__I64L(0x433FFFFD80000000); -} - -/* - * the following is based on parts of wavegain.c - */ - -static int64_t dither_output_(DitherContext *d, FLAC__bool do_dithering, int shapingtype, int i, double Sum, int k) -{ - double Sum2; - int64_t val; - - if(do_dithering) { - if(shapingtype == 0) { - double tmp = random_equi_(d->Dither); - Sum2 = tmp - d->LastRandomNumber [k]; - d->LastRandomNumber [k] = (int)tmp; - Sum2 = Sum += Sum2; - val = ROUND64(d, Sum2) & d->Mask; - } - else { - Sum2 = random_triangular_(d->Dither) - scalar16_(d->DitherHistory[k], d->FilterCoeff + i); - Sum += d->DitherHistory [k] [(-1-i)&15] = (float)Sum2; - Sum2 = Sum + scalar16_(d->ErrorHistory [k], d->FilterCoeff + i); - val = ROUND64(d, Sum2) & d->Mask; - d->ErrorHistory [k] [(-1-i)&15] = (float)(Sum - val); - } - return val; - } - - return ROUND64(d, Sum); -} - -#if 0 - float peak = 0.f, - new_peak, - factor_clip - double scale, - dB; - - ... - - peak is in the range -32768.0 .. 32767.0 - - /* calculate factors for ReplayGain and ClippingPrevention */ - *track_gain = GetTitleGain() + settings->man_gain; - scale = (float) pow(10., *track_gain * 0.05); - if(settings->clip_prev) { - factor_clip = (float) (32767./( peak + 1)); - if(scale < factor_clip) - factor_clip = 1.f; - else - factor_clip /= scale; - scale *= factor_clip; - } - new_peak = (float) peak * scale; - - dB = 20. * log10(scale); - *track_gain = (float) dB; - - const double scale = pow(10., (double)gain * 0.05); -#endif - - -size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool uint32_t_data_out, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, const uint32_t source_bps, const uint32_t target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context) -{ - static const FLAC__int64 hard_clip_factors_[33] = { - 0, /* 0 bits-per-sample (not supported) */ - 0, /* 1 bits-per-sample (not supported) */ - 0, /* 2 bits-per-sample (not supported) */ - 0, /* 3 bits-per-sample (not supported) */ - -8, /* 4 bits-per-sample */ - -16, /* 5 bits-per-sample */ - -32, /* 6 bits-per-sample */ - -64, /* 7 bits-per-sample */ - -128, /* 8 bits-per-sample */ - -256, /* 9 bits-per-sample */ - -512, /* 10 bits-per-sample */ - -1024, /* 11 bits-per-sample */ - -2048, /* 12 bits-per-sample */ - -4096, /* 13 bits-per-sample */ - -8192, /* 14 bits-per-sample */ - -16384, /* 15 bits-per-sample */ - -32768, /* 16 bits-per-sample */ - -65536, /* 17 bits-per-sample */ - -131072, /* 18 bits-per-sample */ - -262144, /* 19 bits-per-sample */ - -524288, /* 20 bits-per-sample */ - -1048576, /* 21 bits-per-sample */ - -2097152, /* 22 bits-per-sample */ - -4194304, /* 23 bits-per-sample */ - -8388608, /* 24 bits-per-sample */ - -16777216, /* 25 bits-per-sample */ - -33554432, /* 26 bits-per-sample */ - -67108864, /* 27 bits-per-sample */ - -134217728, /* 28 bits-per-sample */ - -268435456, /* 29 bits-per-sample */ - -536870912, /* 30 bits-per-sample */ - -1073741824, /* 31 bits-per-sample */ - (FLAC__int64)(-1073741824) * 2 /* 32 bits-per-sample */ - }; - const FLAC__int32 conv_shift = 32 - target_bps; - const FLAC__int64 hard_clip_factor = hard_clip_factors_[target_bps]; - /* - * The integer input coming in has a varying range based on the - * source_bps. We want to normalize it to [-1.0, 1.0) so instead - * of doing two multiplies on each sample, we just multiple - * 'scale' by 1/(2^(source_bps-1)) - */ - const double multi_scale = scale / (double)(1u << (source_bps-1)); - - FLAC__byte * const start = data_out; - uint32_t i, channel; - const FLAC__int32 *input_; - double sample; - const uint32_t bytes_per_sample = target_bps / 8; - const uint32_t last_history_index = dither_context->LastHistoryIndex; - NoiseShaping noise_shaping = dither_context->ShapingType; - FLAC__int64 val64; - FLAC__int32 val32; - FLAC__int32 uval32; - const FLAC__uint32 twiggle = 1u << (target_bps - 1); - - FLAC__ASSERT(channels > 0 && channels <= FLAC_SHARE__MAX_SUPPORTED_CHANNELS); - FLAC__ASSERT(source_bps >= 4); - FLAC__ASSERT(target_bps >= 4); - FLAC__ASSERT(source_bps <= 32); - FLAC__ASSERT(target_bps < 32); - FLAC__ASSERT((target_bps & 7) == 0); - - for(channel = 0; channel < channels; channel++) { - const uint32_t incr = bytes_per_sample * channels; - data_out = start + bytes_per_sample * channel; - input_ = input[channel]; - for(i = 0; i < wide_samples; i++, data_out += incr) { - sample = (double)input_[i] * multi_scale; - - if(hard_limit) { - /* hard 6dB limiting */ - if(sample < -0.5) - sample = tanh((sample + 0.5) / (1-0.5)) * (1-0.5) - 0.5; - else if(sample > 0.5) - sample = tanh((sample - 0.5) / (1-0.5)) * (1-0.5) + 0.5; - } - sample *= 2147483647.; - - val64 = dither_output_(dither_context, do_dithering, noise_shaping, (i + last_history_index) % 32, sample, channel) >> conv_shift; - - val32 = (FLAC__int32)val64; - if(val64 >= -hard_clip_factor) - val32 = (FLAC__int32)(-(hard_clip_factor+1)); - else if(val64 < hard_clip_factor) - val32 = (FLAC__int32)hard_clip_factor; - - uval32 = (FLAC__uint32)val32; - if (uint32_t_data_out) - uval32 ^= twiggle; - - if (little_endian_data_out) { - switch(target_bps) { - case 24: - data_out[2] = (FLAC__byte)(uval32 >> 16); - /* fall through */ - case 16: - data_out[1] = (FLAC__byte)(uval32 >> 8); - /* fall through */ - case 8: - data_out[0] = (FLAC__byte)uval32; - break; - } - } - else { - switch(target_bps) { - case 24: - data_out[0] = (FLAC__byte)(uval32 >> 16); - data_out[1] = (FLAC__byte)(uval32 >> 8); - data_out[2] = (FLAC__byte)uval32; - break; - case 16: - data_out[0] = (FLAC__byte)(uval32 >> 8); - data_out[1] = (FLAC__byte)uval32; - break; - case 8: - data_out[0] = (FLAC__byte)uval32; - break; - } - } - } - } - dither_context->LastHistoryIndex = (last_history_index + wide_samples) % 32; - - return wide_samples * channels * (target_bps/8); -} diff --git a/Engine/lib/flac/src/share/utf8/CMakeLists.txt b/Engine/lib/flac/src/share/utf8/CMakeLists.txt deleted file mode 100644 index 389b09e26..000000000 --- a/Engine/lib/flac/src/share/utf8/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.12) - -add_library(utf8 STATIC - charset.c - iconvert.c - utf8.c) - -target_link_libraries(utf8 PUBLIC grabbag $) diff --git a/Engine/lib/flac/src/share/utf8/charmaps.h b/Engine/lib/flac/src/share/utf8/charmaps.h deleted file mode 100644 index 16d049a2a..000000000 --- a/Engine/lib/flac/src/share/utf8/charmaps.h +++ /dev/null @@ -1,57 +0,0 @@ - -/* - * If you need to generate more maps, use makemap.c on a system - * with a decent iconv. - */ - -static const uint16_t mapping_iso_8859_2[256] = { - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, - 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, - 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, - 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, - 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, - 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, - 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, - 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, - 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, - 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, - 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, - 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, - 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, - 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, - 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, - 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f, - 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, - 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, - 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, - 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f, - 0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7, - 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b, - 0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7, - 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, - 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, - 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, - 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, - 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, - 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, - 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, - 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, - 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9 -}; - -static struct { - const char *name; - const uint16_t *map; - struct charset *charset; -} maps[] = { - { "ISO-8859-2", mapping_iso_8859_2, 0 }, - { 0, 0, 0 } -}; - -static const struct { - const char *bad; - const char *good; -} names[] = { - { "ANSI_X3.4-1968", "us-ascii" }, - { 0, 0 } -}; diff --git a/Engine/lib/flac/src/share/utf8/charset.c b/Engine/lib/flac/src/share/utf8/charset.c deleted file mode 100644 index 5c5693d15..000000000 --- a/Engine/lib/flac/src/share/utf8/charset.c +++ /dev/null @@ -1,534 +0,0 @@ -/* - * Copyright (C) 2001 Edmund Grimley Evans - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * See the corresponding header file for a description of the functions - * that this file provides. - * - * This was first written for Ogg Vorbis but could be of general use. - * - * The only deliberate assumption about data sizes is that a short has - * at least 16 bits, but this code has only been tested on systems with - * 8-bit char, 16-bit short and 32-bit int. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#if !defined _WIN32 && !defined HAVE_ICONV /* should be && defined USE_CHARSET_CONVERT */ - -#include - -#include "share/alloc.h" -#include "charset.h" - -#include "charmaps.h" - -/* - * This is like the standard strcasecmp, but it does not depend - * on the locale. Locale-dependent functions can be dangerous: - * we once had a bug involving strcasecmp("iso", "ISO") in a - * Turkish locale! - * - * (I'm not really sure what the official standard says - * about the sign of strcasecmp("Z", "["), but usually - * we're only interested in whether it's zero.) - */ - -static int ascii_strcasecmp(const char *s1, const char *s2) -{ - char c1, c2; - - for (;; s1++, s2++) { - if (!*s1 || !*s2) - break; - if (*s1 == *s2) - continue; - c1 = *s1; - if ('a' <= c1 && c1 <= 'z') - c1 += 'A' - 'a'; - c2 = *s2; - if ('a' <= c2 && c2 <= 'z') - c2 += 'A' - 'a'; - if (c1 != c2) - break; - } - return (uint8_t)*s1 - (uint8_t)*s2; -} - -/* - * UTF-8 equivalents of the C library's wctomb() and mbtowc(). - */ - -int utf8_mbtowc(int *pwc, const char *s, size_t n) -{ - uint8_t c; - int wc, i, k; - - if (!n || !s) - return 0; - - c = *s; - if (c < 0x80) { - if (pwc) - *pwc = c; - return c ? 1 : 0; - } - else if (c < 0xc2) - return -1; - else if (c < 0xe0) { - if (n >= 2 && (s[1] & 0xc0) == 0x80) { - if (pwc) - *pwc = ((c & 0x1f) << 6) | (s[1] & 0x3f); - return 2; - } - else - return -1; - } - else if (c < 0xf0) - k = 3; - else if (c < 0xf8) - k = 4; - else if (c < 0xfc) - k = 5; - else if (c < 0xfe) - k = 6; - else - return -1; - - if (n < (size_t)k) - return -1; - wc = *s++ & ((1 << (7 - k)) - 1); - for (i = 1; i < k; i++) { - if ((*s & 0xc0) != 0x80) - return -1; - wc = (wc << 6) | (*s++ & 0x3f); - } - if (wc < (1 << (5 * k - 4))) - return -1; - if (pwc) - *pwc = wc; - return k; -} - -int utf8_wctomb(char *s, int wc1) -{ - uint32_t wc = wc1; - - if (!s) - return 0; - if (wc < (1u << 7)) { - *s++ = wc; - return 1; - } - else if (wc < (1u << 11)) { - *s++ = 0xc0 | (wc >> 6); - *s++ = 0x80 | (wc & 0x3f); - return 2; - } - else if (wc < (1u << 16)) { - *s++ = 0xe0 | (wc >> 12); - *s++ = 0x80 | ((wc >> 6) & 0x3f); - *s++ = 0x80 | (wc & 0x3f); - return 3; - } - else if (wc < (1u << 21)) { - *s++ = 0xf0 | (wc >> 18); - *s++ = 0x80 | ((wc >> 12) & 0x3f); - *s++ = 0x80 | ((wc >> 6) & 0x3f); - *s++ = 0x80 | (wc & 0x3f); - return 4; - } - else if (wc < (1u << 26)) { - *s++ = 0xf8 | (wc >> 24); - *s++ = 0x80 | ((wc >> 18) & 0x3f); - *s++ = 0x80 | ((wc >> 12) & 0x3f); - *s++ = 0x80 | ((wc >> 6) & 0x3f); - *s++ = 0x80 | (wc & 0x3f); - return 5; - } - else if (wc < (1u << 31)) { - *s++ = 0xfc | (wc >> 30); - *s++ = 0x80 | ((wc >> 24) & 0x3f); - *s++ = 0x80 | ((wc >> 18) & 0x3f); - *s++ = 0x80 | ((wc >> 12) & 0x3f); - *s++ = 0x80 | ((wc >> 6) & 0x3f); - *s++ = 0x80 | (wc & 0x3f); - return 6; - } - else - return -1; -} - -/* - * The charset "object" and methods. - */ - -struct charset { - int max; - int (*mbtowc)(void *table, int *pwc, const char *s, size_t n); - int (*wctomb)(void *table, char *s, int wc); - void *map; -}; - -int charset_mbtowc(struct charset *charset, int *pwc, const char *s, size_t n) -{ - return (*charset->mbtowc)(charset->map, pwc, s, n); -} - -int charset_wctomb(struct charset *charset, char *s, int wc) -{ - return (*charset->wctomb)(charset->map, s, wc); -} - -int charset_max(struct charset *charset) -{ - return charset->max; -} - -/* - * Implementation of UTF-8. - */ - -static int mbtowc_utf8(void *map, int *pwc, const char *s, size_t n) -{ - (void)map; - return utf8_mbtowc(pwc, s, n); -} - -static int wctomb_utf8(void *map, char *s, int wc) -{ - (void)map; - return utf8_wctomb(s, wc); -} - -/* - * Implementation of US-ASCII. - * Probably on most architectures this compiles to less than 256 bytes - * of code, so we can save space by not having a table for this one. - */ - -static int mbtowc_ascii(void *map, int *pwc, const char *s, size_t n) -{ - int wc; - - (void)map; - if (!n || !s) - return 0; - wc = (uint8_t)*s; - if (wc & ~0x7f) - return -1; - if (pwc) - *pwc = wc; - return wc ? 1 : 0; -} - -static int wctomb_ascii(void *map, char *s, int wc) -{ - (void)map; - if (!s) - return 0; - if (wc & ~0x7f) - return -1; - *s = wc; - return 1; -} - -/* - * Implementation of ISO-8859-1. - * Probably on most architectures this compiles to less than 256 bytes - * of code, so we can save space by not having a table for this one. - */ - -static int mbtowc_iso1(void *map, int *pwc, const char *s, size_t n) -{ - int wc; - - (void)map; - if (!n || !s) - return 0; - wc = (uint8_t)*s; - if (wc & ~0xff) - return -1; - if (pwc) - *pwc = wc; - return wc ? 1 : 0; -} - -static int wctomb_iso1(void *map, char *s, int wc) -{ - (void)map; - if (!s) - return 0; - if (wc & ~0xff) - return -1; - *s = wc; - return 1; -} - -/* - * Implementation of any 8-bit charset. - */ - -struct map { - const uint16_t *from; - struct inverse_map *to; -}; - -static int mbtowc_8bit(void *map1, int *pwc, const char *s, size_t n) -{ - struct map *map = map1; - uint16_t wc; - - if (!n || !s) - return 0; - wc = map->from[(uint8_t)*s]; - if (wc == 0xffff) - return -1; - if (pwc) - *pwc = (int)wc; - return wc ? 1 : 0; -} - -/* - * For the inverse map we use a hash table, which has the advantages - * of small constant memory requirement and simple memory allocation, - * but the disadvantage of slow conversion in the worst case. - * If you need real-time performance while letting a potentially - * malicious user define their own map, then the method used in - * linux/drivers/char/consolemap.c would be more appropriate. - */ - -struct inverse_map { - uint8_t first[256]; - uint8_t next[256]; -}; - -/* - * The simple hash is good enough for this application. - * Use the alternative trivial hashes for testing. - */ -#define HASH(i) ((i) & 0xff) -/* #define HASH(i) 0 */ -/* #define HASH(i) 99 */ - -static struct inverse_map *make_inverse_map(const uint16_t *from) -{ - struct inverse_map *to; - char used[256]; - int i, j, k; - - to = malloc(sizeof(struct inverse_map)); - if (!to) - return 0; - for (i = 0; i < 256; i++) - to->first[i] = to->next[i] = used[i] = 0; - for (i = 255; i >= 0; i--) - if (from[i] != 0xffff) { - k = HASH(from[i]); - to->next[i] = to->first[k]; - to->first[k] = i; - used[k] = 1; - } - - /* Point the empty buckets at an empty list. */ - for (i = 0; i < 256; i++) - if (!to->next[i]) - break; - if (i < 256) - for (j = 0; j < 256; j++) - if (!used[j]) - to->first[j] = i; - - return to; -} - -static int wctomb_8bit(void *map1, char *s, int wc1) -{ - struct map *map = map1; - uint16_t wc = wc1; - int i; - - if (!s) - return 0; - - if (wc1 & ~0xffff) - return -1; - - if (1) /* Change 1 to 0 to test the case where malloc fails. */ - if (!map->to) - map->to = make_inverse_map(map->from); - - if (map->to) { - /* Use the inverse map. */ - i = map->to->first[HASH(wc)]; - for (;;) { - if (map->from[i] == wc) { - *s = i; - return 1; - } - if (!(i = map->to->next[i])) - break; - } - } - else { - /* We don't have an inverse map, so do a linear search. */ - for (i = 0; i < 256; i++) - if (map->from[i] == wc) { - *s = i; - return 1; - } - } - - return -1; -} - -/* - * The "constructor" charset_find(). - */ - -struct charset charset_utf8 = { - 6, - &mbtowc_utf8, - &wctomb_utf8, - 0 -}; - -struct charset charset_iso1 = { - 1, - &mbtowc_iso1, - &wctomb_iso1, - 0 -}; - -struct charset charset_ascii = { - 1, - &mbtowc_ascii, - &wctomb_ascii, - 0 -}; - -struct charset *charset_find(const char *code) -{ - int i; - - /* Find good (MIME) name. */ - for (i = 0; names[i].bad; i++) - if (!ascii_strcasecmp(code, names[i].bad)) { - code = names[i].good; - break; - } - - /* Recognise some charsets for which we avoid using a table. */ - if (!ascii_strcasecmp(code, "UTF-8")) - return &charset_utf8; - if (!ascii_strcasecmp(code, "US-ASCII")) - return &charset_ascii; - if (!ascii_strcasecmp(code, "ISO-8859-1")) - return &charset_iso1; - - /* Look for a mapping for a simple 8-bit encoding. */ - for (i = 0; maps[i].name; i++) - if (!ascii_strcasecmp(code, maps[i].name)) { - if (!maps[i].charset) { - maps[i].charset = malloc(sizeof(struct charset)); - if (maps[i].charset) { - struct map *map = malloc(sizeof(struct map)); - if (!map) { - free(maps[i].charset); - maps[i].charset = 0; - } - else { - maps[i].charset->max = 1; - maps[i].charset->mbtowc = &mbtowc_8bit; - maps[i].charset->wctomb = &wctomb_8bit; - maps[i].charset->map = map; - map->from = maps[i].map; - map->to = 0; /* inverse mapping is created when required */ - } - } - } - return maps[i].charset; - } - - return 0; -} - -/* - * Function to convert a buffer from one encoding to another. - * Invalid bytes are replaced by '#', and characters that are - * not available in the target encoding are replaced by '?'. - * Each of TO and TOLEN may be zero, if the result is not needed. - * The output buffer is null-terminated, so it is all right to - * use charset_convert(fromcode, tocode, s, strlen(s), &t, 0). - */ - -int charset_convert(const char *fromcode, const char *tocode, - const char *from, size_t fromlen, - char **to, size_t *tolen) -{ - int ret = 0; - struct charset *charset1, *charset2; - char *tobuf, *p; - int i, j, wc; - - charset1 = charset_find(fromcode); - charset2 = charset_find(tocode); - if (!charset1 || !charset2 ) - return -1; - - tobuf = safe_malloc_mul2add_(fromlen, /*times*/charset2->max, /*+*/1); - if (!tobuf) - return -2; - - for (p = tobuf; fromlen; from += i, fromlen -= i, p += j) { - i = charset_mbtowc(charset1, &wc, from, fromlen); - if (!i) - i = 1; - else if (i == -1) { - i = 1; - wc = '#'; - ret = 2; - } - j = charset_wctomb(charset2, p, wc); - if (j == -1) { - if (!ret) - ret = 1; - j = charset_wctomb(charset2, p, '?'); - if (j == -1) - j = 0; - } - } - - if (tolen) - *tolen = p - tobuf; - *p++ = '\0'; - if (to) { - char *tobuf_saved = tobuf; - *to = realloc(tobuf, p - tobuf); - if (*to == NULL) - *to = tobuf_saved; - } - else - free(tobuf); - - return ret; -} - -#endif /* USE_CHARSET_ICONV */ diff --git a/Engine/lib/flac/src/share/utf8/charset.h b/Engine/lib/flac/src/share/utf8/charset.h deleted file mode 100644 index ea8e31e1e..000000000 --- a/Engine/lib/flac/src/share/utf8/charset.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2001 Edmund Grimley Evans - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include - -/* - * These functions are like the C library's mbtowc() and wctomb(), - * but instead of depending on the locale they always work in UTF-8, - * and they use int instead of wchar_t. - */ - -int utf8_mbtowc(int *pwc, const char *s, size_t n); -int utf8_wctomb(char *s, int wc); - -/* - * This is an object-oriented version of mbtowc() and wctomb(). - * The caller first uses charset_find() to get a pointer to struct - * charset, then uses the mbtowc() and wctomb() methods on it. - * The function charset_max() gives the maximum length of a - * multibyte character in that encoding. - * This API is only appropriate for stateless encodings like UTF-8 - * or ISO-8859-3, but I have no intention of implementing anything - * other than UTF-8 and 8-bit encodings. - * - * MINOR BUG: If there is no memory charset_find() may return 0 and - * there is no way to distinguish this case from an unknown encoding. - */ - -struct charset; - -struct charset *charset_find(const char *code); - -int charset_mbtowc(struct charset *charset, int *pwc, const char *s, size_t n); -int charset_wctomb(struct charset *charset, char *s, int wc); -int charset_max(struct charset *charset); - -/* - * Function to convert a buffer from one encoding to another. - * Invalid bytes are replaced by '#', and characters that are - * not available in the target encoding are replaced by '?'. - * Each of TO and TOLEN may be zero if the result is not wanted. - * The input or output may contain null bytes, but the output - * buffer is also null-terminated, so it is all right to - * use charset_convert(fromcode, tocode, s, strlen(s), &t, 0). - * - * Return value: - * - * -2 : memory allocation failed - * -1 : unknown encoding - * 0 : data was converted exactly - * 1 : valid data was converted approximately (using '?') - * 2 : input was invalid (but still converted, using '#') - */ - -int charset_convert(const char *fromcode, const char *tocode, - const char *from, size_t fromlen, - char **to, size_t *tolen); diff --git a/Engine/lib/flac/src/share/utf8/charset_test.c b/Engine/lib/flac/src/share/utf8/charset_test.c deleted file mode 100644 index 6761100ce..000000000 --- a/Engine/lib/flac/src/share/utf8/charset_test.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (C) 2001 Edmund Grimley Evans - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#include "charset.h" - -void test_any(struct charset *charset) -{ - int wc; - char s[2]; - - assert(charset); - - /* Decoder */ - - assert(charset_mbtowc(charset, 0, 0, 0) == 0); - assert(charset_mbtowc(charset, 0, 0, 1) == 0); - assert(charset_mbtowc(charset, 0, (char *)(-1), 0) == 0); - - assert(charset_mbtowc(charset, 0, "a", 0) == 0); - assert(charset_mbtowc(charset, 0, "", 1) == 0); - assert(charset_mbtowc(charset, 0, "b", 1) == 1); - assert(charset_mbtowc(charset, 0, "", 2) == 0); - assert(charset_mbtowc(charset, 0, "c", 2) == 1); - - wc = 'x'; - assert(charset_mbtowc(charset, &wc, "a", 0) == 0 && wc == 'x'); - assert(charset_mbtowc(charset, &wc, "", 1) == 0 && wc == 0); - assert(charset_mbtowc(charset, &wc, "b", 1) == 1 && wc == 'b'); - assert(charset_mbtowc(charset, &wc, "", 2) == 0 && wc == 0); - assert(charset_mbtowc(charset, &wc, "c", 2) == 1 && wc == 'c'); - - /* Encoder */ - - assert(charset_wctomb(charset, 0, 0) == 0); - - s[0] = s[1] = '.'; - assert(charset_wctomb(charset, s, 0) == 1 && - s[0] == '\0' && s[1] == '.'); - assert(charset_wctomb(charset, s, 'x') == 1 && - s[0] == 'x' && s[1] == '.'); -} - -void test_utf8() -{ - struct charset *charset; - int wc; - char s[8]; - - charset = charset_find("UTF-8"); - test_any(charset); - - /* Decoder */ - wc = 0; - assert(charset_mbtowc(charset, &wc, "\177", 1) == 1 && wc == 127); - assert(charset_mbtowc(charset, &wc, "\200", 2) == -1); - assert(charset_mbtowc(charset, &wc, "\301\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\302\200", 1) == -1); - assert(charset_mbtowc(charset, &wc, "\302\200", 2) == 2 && wc == 128); - assert(charset_mbtowc(charset, &wc, "\302\200", 3) == 2 && wc == 128); - assert(charset_mbtowc(charset, &wc, "\340\237\200", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\340\240\200", 9) == 3 && - wc == 1 << 11); - assert(charset_mbtowc(charset, &wc, "\360\217\277\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\360\220\200\200", 9) == 4 && - wc == 1 << 16); - assert(charset_mbtowc(charset, &wc, "\370\207\277\277\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\370\210\200\200\200", 9) == 5 && - wc == 1 << 21); - assert(charset_mbtowc(charset, &wc, "\374\203\277\277\277\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\374\204\200\200\200\200", 9) == 6 && - wc == 1 << 26); - assert(charset_mbtowc(charset, &wc, "\375\277\277\277\277\277", 9) == 6 && - wc == 0x7fffffff); - - assert(charset_mbtowc(charset, &wc, "\302\000", 2) == -1); - assert(charset_mbtowc(charset, &wc, "\302\300", 2) == -1); - assert(charset_mbtowc(charset, &wc, "\340\040\200", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\340\340\200", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\340\240\000", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\340\240\300", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\360\020\200\200", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\360\320\200\200", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\360\220\000\200", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\360\220\300\200", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\360\220\200\000", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\360\220\200\300", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\375\077\277\277\277\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\375\377\277\277\277\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\375\277\077\277\277\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\375\277\377\277\277\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\375\277\277\277\077\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\375\277\277\277\377\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\375\277\277\277\277\077", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\375\277\277\277\277\377", 9) == -1); - - assert(charset_mbtowc(charset, &wc, "\376\277\277\277\277\277", 9) == -1); - assert(charset_mbtowc(charset, &wc, "\377\277\277\277\277\277", 9) == -1); - - /* Encoder */ - safe_strncpy(s, ".......", sizeof(s)); - assert(charset_wctomb(charset, s, 1u << 31) == -1 && - !strcmp(s, ".......")); - assert(charset_wctomb(charset, s, 127) == 1 && - !strcmp(s, "\177......")); - assert(charset_wctomb(charset, s, 128) == 2 && - !strcmp(s, "\302\200.....")); - assert(charset_wctomb(charset, s, 0x7ff) == 2 && - !strcmp(s, "\337\277.....")); - assert(charset_wctomb(charset, s, 0x800) == 3 && - !strcmp(s, "\340\240\200....")); - assert(charset_wctomb(charset, s, 0xffff) == 3 && - !strcmp(s, "\357\277\277....")); - assert(charset_wctomb(charset, s, 0x10000) == 4 && - !strcmp(s, "\360\220\200\200...")); - assert(charset_wctomb(charset, s, 0x1fffff) == 4 && - !strcmp(s, "\367\277\277\277...")); - assert(charset_wctomb(charset, s, 0x200000) == 5 && - !strcmp(s, "\370\210\200\200\200..")); - assert(charset_wctomb(charset, s, 0x3ffffff) == 5 && - !strcmp(s, "\373\277\277\277\277..")); - assert(charset_wctomb(charset, s, 0x4000000) == 6 && - !strcmp(s, "\374\204\200\200\200\200.")); - assert(charset_wctomb(charset, s, 0x7fffffff) == 6 && - !strcmp(s, "\375\277\277\277\277\277.")); -} - -void test_ascii() -{ - struct charset *charset; - int wc; - char s[3]; - - charset = charset_find("us-ascii"); - test_any(charset); - - /* Decoder */ - wc = 0; - assert(charset_mbtowc(charset, &wc, "\177", 2) == 1 && wc == 127); - assert(charset_mbtowc(charset, &wc, "\200", 2) == -1); - - /* Encoder */ - safe_strncpy(s, "..", sizeof(s)); - assert(charset_wctomb(charset, s, 256) == -1 && !strcmp(s, "..")); - assert(charset_wctomb(charset, s, 255) == -1); - assert(charset_wctomb(charset, s, 128) == -1); - assert(charset_wctomb(charset, s, 127) == 1 && !strcmp(s, "\177.")); -} - -void test_iso1() -{ - struct charset *charset; - int wc; - char s[3]; - - charset = charset_find("iso-8859-1"); - test_any(charset); - - /* Decoder */ - wc = 0; - assert(charset_mbtowc(charset, &wc, "\302\200", 9) == 1 && wc == 0xc2); - - /* Encoder */ - safe_strncpy(s, "..", sizeof(s)); - assert(charset_wctomb(charset, s, 256) == -1 && !strcmp(s, "..")); - assert(charset_wctomb(charset, s, 255) == 1 && !strcmp(s, "\377.")); - assert(charset_wctomb(charset, s, 128) == 1 && !strcmp(s, "\200.")); -} - -void test_iso2() -{ - struct charset *charset; - int wc; - char s[3]; - - charset = charset_find("iso-8859-2"); - test_any(charset); - - /* Decoder */ - wc = 0; - assert(charset_mbtowc(charset, &wc, "\302\200", 9) == 1 && wc == 0xc2); - assert(charset_mbtowc(charset, &wc, "\377", 2) == 1 && wc == 0x2d9); - - /* Encoder */ - safe_strncpy(s, "..", sizeof(s)); - assert(charset_wctomb(charset, s, 256) == -1 && !strcmp(s, "..")); - assert(charset_wctomb(charset, s, 255) == -1 && !strcmp(s, "..")); - assert(charset_wctomb(charset, s, 258) == 1 && !strcmp(s, "\303.")); - assert(charset_wctomb(charset, s, 128) == 1 && !strcmp(s, "\200.")); -} - -void test_convert() -{ - const char *p; - char *q, *r; - char s[256]; - size_t n, n2; - int i; - - p = "\000x\302\200\375\277\277\277\277\277"; - assert(charset_convert("UTF-8", "UTF-8", p, 10, &q, &n) == 0 && - n == 10 && !strcmp(p, q)); - assert(charset_convert("UTF-8", "UTF-8", "x\301\277y", 4, &q, &n) == 2 && - n == 4 && !strcmp(q, "x##y")); - assert(charset_convert("UTF-8", "UTF-8", "x\301\277y", 4, 0, &n) == 2 && - n == 4); - assert(charset_convert("UTF-8", "UTF-8", "x\301\277y", 4, &q, 0) == 2 && - !strcmp(q, "x##y")); - assert(charset_convert("UTF-8", "iso-8859-1", - "\302\200\304\200x", 5, &q, &n) == 1 && - n == 3 && !strcmp(q, "\200?x")); - assert(charset_convert("iso-8859-1", "UTF-8", - "\000\200\377", 3, &q, &n) == 0 && - n == 5 && !memcmp(q, "\000\302\200\303\277", 5)); - assert(charset_convert("iso-8859-1", "iso-8859-1", - "\000\200\377", 3, &q, &n) == 0 && - n == 3 && !memcmp(q, "\000\200\377", 3)); - - assert(charset_convert("iso-8859-2", "utf-8", "\300", 1, &q, &n) == 0 && - n == 2 && !strcmp(q, "\305\224")); - assert(charset_convert("utf-8", "iso-8859-2", "\305\224", 2, &q, &n) == 0 && - n == 1 && !strcmp(q, "\300")); - - for (i = 0; i < 256; i++) - s[i] = i; - - assert(charset_convert("iso-8859-2", "utf-8", s, 256, &q, &n) == 0); - assert(charset_convert("utf-8", "iso-8859-2", q, n, &r, &n2) == 0); - assert(n2 == 256 && !memcmp(r, s, n2)); -} - -int main() -{ - test_utf8(); - test_ascii(); - test_iso1(); - test_iso2(); - - test_convert(); - - return 0; -} diff --git a/Engine/lib/flac/src/share/utf8/iconvert.c b/Engine/lib/flac/src/share/utf8/iconvert.c deleted file mode 100644 index 9a1e3f6b2..000000000 --- a/Engine/lib/flac/src/share/utf8/iconvert.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) 2001 Edmund Grimley Evans - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#if !defined _WIN32 && defined HAVE_ICONV - -#include -#include -#include -#include -#include -#include - -#include "iconvert.h" -#include "share/alloc.h" -#include "share/safe_str.h" - -/* - * Convert data from one encoding to another. Return: - * - * -2 : memory allocation failed - * -1 : unknown encoding - * 0 : data was converted exactly - * 1 : data was converted inexactly - * 2 : data was invalid (but still converted) - * - * We convert in two steps, via UTF-8, as this is the only - * reliable way of distinguishing between invalid input - * and valid input which iconv refuses to transliterate. - * We convert from UTF-8 twice, because we have no way of - * knowing whether the conversion was exact if iconv returns - * E2BIG (due to a bug in the specification of iconv). - * An alternative approach is to assume that the output of - * iconv is never more than 4 times as long as the input, - * but I prefer to avoid that assumption if possible. - */ - -int iconvert(const char *fromcode, const char *tocode, - const char *from, size_t fromlen, - char **to, size_t *tolen) -{ - int ret = 0; - iconv_t cd1, cd2; - char *ib; - char *ob; - char *utfbuf = 0, *outbuf, *newbuf; - size_t utflen, outlen, ibl, obl, obp, k; - char tbuf[2048]; - - cd1 = iconv_open("UTF-8", fromcode); - if (cd1 == (iconv_t)(-1)) - return -1; - - cd2 = (iconv_t)(-1); - /* Don't use strcasecmp() as it's locale-dependent. */ - if (!strchr("Uu", tocode[0]) || - !strchr("Tt", tocode[1]) || - !strchr("Ff", tocode[2]) || - tocode[3] != '-' || - tocode[4] != '8' || - tocode[5] != '\0') { - char *tocode1; - int rc; - /* - * Try using this non-standard feature of glibc and libiconv. - * This is deliberately not a config option as people often - * change their iconv library without rebuilding applications. - */ - - rc = asprintf(&tocode1, "%s//TRANSLIT", tocode); - if (rc < 0 || ! tocode1) - goto fail; - - cd2 = iconv_open(tocode1, "UTF-8"); - free(tocode1); - - if (cd2 == (iconv_t)(-1)) - cd2 = iconv_open(tocode, fromcode); - - if (cd2 == (iconv_t)(-1)) { - iconv_close(cd1); - return -1; - } - } - - utflen = 1; /*fromlen * 2 + 1; XXX */ - utfbuf = malloc(utflen); - if (!utfbuf) - goto fail; - - /* Convert to UTF-8 */ - ib = (char *)from; - ibl = fromlen; - ob = utfbuf; - obl = utflen; - for (;;) { - k = iconv(cd1, &ib, &ibl, &ob, &obl); - assert((!k && !ibl) || - (k == (size_t)(-1) && errno == E2BIG && ibl && obl < 6) || - (k == (size_t)(-1) && - (errno == EILSEQ || errno == EINVAL) && ibl)); - if (!ibl) - break; - if (obl < 6) { - /* Enlarge the buffer */ - if(utflen*2 < utflen) /* overflow check */ - goto fail; - utflen *= 2; - obp = ob - utfbuf; /* save position */ - newbuf = realloc(utfbuf, utflen); - if (!newbuf) - goto fail; - ob = newbuf + obp; - obl = utflen - obp; - utfbuf = newbuf; - } - else { - /* Invalid input */ - ib++, ibl--; - *ob++ = '#', obl--; - ret = 2; - iconv(cd1, 0, 0, 0, 0); - } - } - - if (cd2 == (iconv_t)(-1)) { - /* The target encoding was UTF-8 */ - if (tolen) - *tolen = ob - utfbuf; - if (!to) { - free(utfbuf); - iconv_close(cd1); - return ret; - } - newbuf = safe_realloc_nofree_add_2op_(utfbuf, (ob - utfbuf), /*+*/1); - if (!newbuf) - goto fail; - ob = (ob - utfbuf) + newbuf; - *ob = '\0'; - *to = newbuf; - iconv_close(cd1); - return ret; - } - - /* Truncate the buffer to be tidy */ - utflen = ob - utfbuf; - if (utflen == 0) - goto fail; - newbuf = realloc(utfbuf, utflen); - if (!newbuf) - goto fail; - utfbuf = newbuf; - - /* Convert from UTF-8 to discover how long the output is */ - outlen = 0; - ib = utfbuf; - ibl = utflen; - while (ibl) { - ob = tbuf; - obl = sizeof(tbuf); - k = iconv(cd2, &ib, &ibl, &ob, &obl); - assert((k != (size_t)(-1) && !ibl) || - (k == (size_t)(-1) && errno == E2BIG && ibl) || - (k == (size_t)(-1) && errno == EILSEQ && ibl)); - if (ibl && !(k == (size_t)(-1) && errno == E2BIG)) { - /* Replace one character */ - char *tb = "?"; - size_t tbl = 1; - - outlen += ob - tbuf; - ob = tbuf; - obl = sizeof(tbuf); - k = iconv(cd2, &tb, &tbl, &ob, &obl); - assert((!k && !tbl) || - (k == (size_t)(-1) && errno == EILSEQ && tbl)); - for (++ib, --ibl; ibl && (*ib & 0x80); ib++, ibl--) - ; - } - outlen += ob - tbuf; - } - ob = tbuf; - obl = sizeof(tbuf); - k = iconv(cd2, 0, 0, &ob, &obl); - assert(!k); - outlen += ob - tbuf; - - /* Convert from UTF-8 for real */ - outbuf = safe_malloc_add_2op_(outlen, /*+*/1); - if (!outbuf) - goto fail; - ib = utfbuf; - ibl = utflen; - ob = outbuf; - obl = outlen; - while (ibl) { - k = iconv(cd2, &ib, &ibl, &ob, &obl); - assert((k != (size_t)(-1) && !ibl) || - (k == (size_t)(-1) && errno == EILSEQ && ibl)); - if (k && !ret) - ret = 1; - if (ibl && !(k == (size_t)(-1) && errno == E2BIG)) { - /* Replace one character */ - char *tb = "?"; - size_t tbl = 1; - - k = iconv(cd2, &tb, &tbl, &ob, &obl); - assert((!k && !tbl) || - (k == (size_t)(-1) && errno == EILSEQ && tbl)); - for (++ib, --ibl; ibl && (*ib & 0x80); ib++, ibl--) - ; - } - } - k = iconv(cd2, 0, 0, &ob, &obl); - assert(!k); - assert(!obl); - *ob = '\0'; - - free(utfbuf); - iconv_close(cd1); - iconv_close(cd2); - if (tolen) - *tolen = outlen; - if (!to) { - free(outbuf); - return ret; - } - *to = outbuf; - return ret; - - fail: - if(0 != utfbuf) - free(utfbuf); - iconv_close(cd1); - if (cd2 != (iconv_t)(-1)) - iconv_close(cd2); - return -2; -} - -#endif /* HAVE_ICONV */ diff --git a/Engine/lib/flac/src/share/utf8/iconvert.h b/Engine/lib/flac/src/share/utf8/iconvert.h deleted file mode 100644 index a2d75a270..000000000 --- a/Engine/lib/flac/src/share/utf8/iconvert.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2001 Edmund Grimley Evans - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifdef HAVE_ICONV - -/* - * Convert data from one encoding to another. Return: - * - * -2 : memory allocation failed - * -1 : unknown encoding - * 0 : data was converted exactly - * 1 : data was converted inexactly - * 2 : data was invalid (but still converted) - * - * We convert in two steps, via UTF-8, as this is the only - * reliable way of distinguishing between invalid input - * and valid input which iconv refuses to transliterate. - * We convert from UTF-8 twice, because we have no way of - * knowing whether the conversion was exact if iconv returns - * E2BIG (due to a bug in the specification of iconv). - * An alternative approach is to assume that the output of - * iconv is never more than 4 times as long as the input, - * but I prefer to avoid that assumption if possible. - */ - -int iconvert(const char *fromcode, const char *tocode, - const char *from, size_t fromlen, - char **to, size_t *tolen) ; - -#endif /* HAVE_ICONV */ diff --git a/Engine/lib/flac/src/share/utf8/makemap.c b/Engine/lib/flac/src/share/utf8/makemap.c deleted file mode 100644 index 790021c69..000000000 --- a/Engine/lib/flac/src/share/utf8/makemap.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2001 Edmund Grimley Evans - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include - -int main(int argc, char *argv[]) -{ - iconv_t cd; - const char *ib; - char *ob; - size_t ibl, obl, k; - uint8_t c, buf[4]; - int i, wc; - - if (argc != 2) { - printf("Usage: %s ENCODING\n", argv[0]); - printf("Output a charset map for the 8-bit ENCODING.\n"); - return 1; - } - - cd = iconv_open("UCS-4", argv[1]); - if (cd == (iconv_t)(-1)) { - perror("iconv_open"); - return 1; - } - - for (i = 0; i < 256; i++) { - c = i; - ib = &c; - ibl = 1; - ob = buf; - obl = 4; - k = iconv(cd, &ib, &ibl, &ob, &obl); - if (!k && !ibl && !obl) { - wc = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]; - if (wc >= 0xffff) { - printf("Dodgy value.\n"); - return 1; - } - } - else if (k == (size_t)(-1) && errno == EILSEQ) - wc = 0xffff; - else { - printf("Non-standard iconv.\n"); - return 1; - } - - if (i % 8 == 0) - printf(" "); - printf("0x%04x", wc); - if (i == 255) - printf("\n"); - else if (i % 8 == 7) - printf(",\n"); - else - printf(", "); - } - - return 0; -} diff --git a/Engine/lib/flac/src/share/utf8/utf8.c b/Engine/lib/flac/src/share/utf8/utf8.c deleted file mode 100644 index 34af187b8..000000000 --- a/Engine/lib/flac/src/share/utf8/utf8.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2001 Peter Harris - * Copyright (C) 2001 Edmund Grimley Evans - * - * Buffer overflow checking added: Josh Coalson, 9/9/2007 - * - * Win32 part rewritten: lvqcl, 2/2/2016 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * Convert a string between UTF-8 and the locale's charset. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#include "share/alloc.h" -#include "share/utf8.h" - -#ifdef _WIN32 - -#include - -int utf8_encode(const char *from, char **to) -{ - wchar_t *unicode = NULL; - char *utf8 = NULL; - int ret = -1; - - do { - int len; - - len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, -1, NULL, 0); - if(len == 0) break; - unicode = (wchar_t*) safe_malloc_mul_2op_((size_t)len, sizeof(wchar_t)); - if(unicode == NULL) break; - len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, from, -1, unicode, len); - if(len == 0) break; - - len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, NULL, 0, NULL, NULL); - if(len == 0) break; - utf8 = (char*) safe_malloc_mul_2op_((size_t)len, sizeof(char)); - if(utf8 == NULL) break; - len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, utf8, len, NULL, NULL); - if(len == 0) break; - - ret = 0; - - } while(0); - - free(unicode); - - if(ret == 0) { - *to = utf8; - } else { - free(utf8); - *to = NULL; - } - - return ret; -} - -int utf8_decode(const char *from, char **to) -{ - wchar_t *unicode = NULL; - char *acp = NULL; - int ret = -1; - - do { - int len; - - len = MultiByteToWideChar(CP_UTF8, 0, from, -1, NULL, 0); - if(len == 0) break; - unicode = (wchar_t*) safe_malloc_mul_2op_((size_t)len, sizeof(wchar_t)); - if(unicode == NULL) break; - len = MultiByteToWideChar(CP_UTF8, 0, from, -1, unicode, len); - if(len == 0) break; - - len = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, -1, NULL, 0, NULL, NULL); - if(len == 0) break; - acp = (char*) safe_malloc_mul_2op_((size_t)len, sizeof(char)); - if(acp == NULL) break; - len = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, unicode, -1, acp, len, NULL, NULL); - if(len == 0) break; - - ret = 0; - - } while(0); - - free(unicode); - - if(ret == 0) { - *to = acp; - } else { - free(acp); - *to = NULL; - } - - return ret; -} - -#else /* End win32. Rest is for real operating systems */ - - -#ifdef HAVE_LANGINFO_CODESET -#include -#endif - -#include - -#include "share/safe_str.h" -#include "iconvert.h" -#include "charset.h" - -static const char *current_charset(void) -{ - const char *c = 0; -#ifdef HAVE_LANGINFO_CODESET - c = nl_langinfo(CODESET); -#endif - - if (!c) - c = getenv("CHARSET"); - - return c? c : "US-ASCII"; -} - -static int convert_buffer(const char *fromcode, const char *tocode, - const char *from, size_t fromlen, - char **to, size_t *tolen) -{ - int ret = -1; - -#ifdef HAVE_ICONV - ret = iconvert(fromcode, tocode, from, fromlen, to, tolen); - if (ret != -1) - return ret; -#endif - -#ifndef HAVE_ICONV /* should be ifdef USE_CHARSET_CONVERT */ - ret = charset_convert(fromcode, tocode, from, fromlen, to, tolen); - if (ret != -1) - return ret; -#endif - - return ret; -} - -static int convert_string(const char *fromcode, const char *tocode, - const char *from, char **to, char replace) -{ - int ret; - size_t fromlen; - char *s; - - fromlen = strlen(from); - ret = convert_buffer(fromcode, tocode, from, fromlen, to, 0); - if (ret == -2) - return -1; - if (ret != -1) - return ret; - - s = safe_malloc_add_2op_(fromlen, /*+*/1); - if (!s) - return -1; - snprintf(s, fromlen + 1, "%s", from); - *to = s; - for (; *s; s++) - if (*s & ~0x7f) - *s = replace; - return 3; -} - -int utf8_encode(const char *from, char **to) -{ - return convert_string(current_charset(), "UTF-8", from, to, '#'); -} - -int utf8_decode(const char *from, char **to) -{ - return convert_string("UTF-8", current_charset(), from, to, '?'); -} - -#endif diff --git a/Engine/lib/flac/src/share/win_utf8_io/win_utf8_io.c b/Engine/lib/flac/src/share/win_utf8_io/win_utf8_io.c deleted file mode 100644 index 3ae35b31b..000000000 --- a/Engine/lib/flac/src/share/win_utf8_io/win_utf8_io.c +++ /dev/null @@ -1,398 +0,0 @@ -/* libFLAC - Free Lossless Audio Codec library - * Copyright (C) 2013-2023 Xiph.Org Foundation - * - * 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 the Xiph.org Foundation nor the names of its - * 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 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. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include "share/win_utf8_io.h" - -#define UTF8_BUFFER_SIZE 32768 - -/* detect whether it is Windows APP (UWP) or standard Win32 envionment */ -#ifdef WINAPI_FAMILY_PARTITION - #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - #define FLAC_WINDOWS_APP 1 - #else - #define FLAC_WINDOWS_APP 0 - #endif -#else - #define FLAC_WINDOWS_APP 0 -#endif - -static int local_vsnprintf(char *str, size_t size, const char *fmt, va_list va) -{ - int rc; - -#if defined _MSC_VER - if (size == 0) - return 1024; - rc = vsnprintf_s(str, size, _TRUNCATE, fmt, va); - if (rc < 0) - rc = size - 1; -#elif defined __MINGW32__ - rc = __mingw_vsnprintf(str, size, fmt, va); -#else - rc = vsnprintf(str, size, fmt, va); -#endif - - return rc; -} - -/* convert WCHAR stored Unicode string to UTF-8. Caller is responsible for freeing memory */ -static char *utf8_from_wchar(const wchar_t *wstr) -{ - char *utf8str; - int len; - - if (!wstr) - return NULL; - if ((len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL)) == 0) - return NULL; - if ((utf8str = (char *)malloc(len)) == NULL) - return NULL; - if (WideCharToMultiByte(CP_UTF8, 0, wstr, -1, utf8str, len, NULL, NULL) == 0) { - free(utf8str); - utf8str = NULL; - } - - return utf8str; -} - -/* convert UTF-8 back to WCHAR. Caller is responsible for freeing memory */ -static wchar_t *wchar_from_utf8(const char *str) -{ - wchar_t *widestr; - int len; - - if (!str) - return NULL; - if ((len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0)) == 0) - return NULL; - if ((widestr = (wchar_t *)malloc(len*sizeof(wchar_t))) == NULL) - return NULL; - if (MultiByteToWideChar(CP_UTF8, 0, str, -1, widestr, len) == 0) { - free(widestr); - widestr = NULL; - } - - return widestr; -} - -/* retrieve WCHAR commandline, expand wildcards and convert everything to UTF-8 */ -int get_utf8_argv(int *argc, char ***argv) -{ -#if !FLAC_WINDOWS_APP - typedef int (__cdecl *wgetmainargs_t)(int*, wchar_t***, wchar_t***, int, int*); - wgetmainargs_t wgetmainargs; - HMODULE handle; -#endif // !FLAC_WINDOWS_APP - int wargc; - wchar_t **wargv; - wchar_t **wenv; - char **utf8argv; - int ret, i; - -#if FLAC_WINDOWS_APP - wargc = __argc; - wargv = __wargv; - wenv = _wenviron; -#else // !FLAC_WINDOWS_APP - if ((handle = LoadLibraryW(L"msvcrt.dll")) == NULL) return 1; - if ((wgetmainargs = (wgetmainargs_t)GetProcAddress(handle, "__wgetmainargs")) == NULL) { - FreeLibrary(handle); - return 1; - } - i = 0; - /* when the 4th argument is 1, __wgetmainargs expands wildcards but also erroneously converts \\?\c:\path\to\file.flac to \\file.flac */ - if (wgetmainargs(&wargc, &wargv, &wenv, 1, &i) != 0) { - FreeLibrary(handle); - return 1; - } -#endif // !FLAC_WINDOWS_APP - if ((utf8argv = (char **)calloc(wargc, sizeof(char*))) == NULL) { - #if !FLAC_WINDOWS_APP - FreeLibrary(handle); - #endif // !FLAC_WINDOWS_APP - return 1; - } - - ret = 0; - for (i=0; iactime; - ut.modtime = times->modtime; - ret = _wutime64(wname, &ut); - free(wname); - - return ret; -} - -int unlink_utf8(const char *filename) -{ - wchar_t *wname; - int ret; - - if (!(wname = wchar_from_utf8(filename))) return -1; - ret = _wunlink(wname); - free(wname); - - return ret; -} - -int rename_utf8(const char *oldname, const char *newname) -{ - wchar_t *wold = NULL; - wchar_t *wnew = NULL; - int ret = -1; - - do { - if (!(wold = wchar_from_utf8(oldname))) break; - if (!(wnew = wchar_from_utf8(newname))) break; - ret = _wrename(wold, wnew); - } while(0); - - free(wold); - free(wnew); - - return ret; -} diff --git a/Engine/lib/flac/src/test_grabbag/CMakeLists.txt b/Engine/lib/flac/src/test_grabbag/CMakeLists.txt deleted file mode 100644 index 56abe8109..000000000 --- a/Engine/lib/flac/src/test_grabbag/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory(cuesheet) -add_subdirectory(picture) diff --git a/Engine/lib/flac/src/test_grabbag/Makefile.am b/Engine/lib/flac/src/test_grabbag/Makefile.am deleted file mode 100644 index ea710091f..000000000 --- a/Engine/lib/flac/src/test_grabbag/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -SUBDIRS = cuesheet picture - -EXTRA_DIST = \ - CMakeLists.txt diff --git a/Engine/lib/flac/src/test_grabbag/cuesheet/CMakeLists.txt b/Engine/lib/flac/src/test_grabbag/cuesheet/CMakeLists.txt deleted file mode 100644 index 5f9a646c9..000000000 --- a/Engine/lib/flac/src/test_grabbag/cuesheet/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_executable(test_cuesheet - main.c - $<$:../../../include/share/win_utf8_io.h> - $<$:../../share/win_utf8_io/win_utf8_io.c>) -target_link_libraries(test_cuesheet FLAC grabbag) diff --git a/Engine/lib/flac/src/test_grabbag/cuesheet/Makefile.am b/Engine/lib/flac/src/test_grabbag/cuesheet/Makefile.am deleted file mode 100644 index 1cee37072..000000000 --- a/Engine/lib/flac/src/test_grabbag/cuesheet/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -# test_cuesheet - Simple tester for cuesheet routines in grabbag -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -check_PROGRAMS = test_cuesheet -test_cuesheet_SOURCES = \ - main.c - -if OS_IS_WINDOWS -win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la -endif - -test_cuesheet_LDADD = \ - $(top_builddir)/src/share/grabbag/libgrabbag.la \ - $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - $(win_utf8_lib) - -CLEANFILES = test_cuesheet.exe diff --git a/Engine/lib/flac/src/test_grabbag/cuesheet/main.c b/Engine/lib/flac/src/test_grabbag/cuesheet/main.c deleted file mode 100644 index b3d0e9abf..000000000 --- a/Engine/lib/flac/src/test_grabbag/cuesheet/main.c +++ /dev/null @@ -1,147 +0,0 @@ -/* test_cuesheet - Simple tester for cuesheet routines in grabbag - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include "FLAC/assert.h" -#include "FLAC/metadata.h" -#include "share/grabbag.h" - -static int do_cuesheet(const char *infilename, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) -{ - FILE *fin, *fout; - const char *error_message, *tmpfilenamebase; - char tmpfilename[4096]; - uint32_t last_line_read; - FLAC__StreamMetadata *cuesheet; - - FLAC__ASSERT(strlen(infilename) + 2 < sizeof(tmpfilename)); - - /* - * pass 1 - */ - if(0 == strcmp(infilename, "-")) { - fin = stdin; - } - else if(0 == (fin = flac_fopen(infilename, "r"))) { - fprintf(stderr, "can't open file %s for reading: %s\n", infilename, strerror(errno)); - return 255; - } - if(0 != (cuesheet = grabbag__cuesheet_parse(fin, &error_message, &last_line_read, sample_rate, is_cdda, lead_out_offset))) { - if(fin != stdin) - fclose(fin); - } - else { - printf("pass1: parse error, line %u: \"%s\"\n", last_line_read, error_message); - if(fin != stdin) - fclose(fin); - return 1; - } - if(!FLAC__metadata_object_cuesheet_is_legal(cuesheet, is_cdda, &error_message)) { - printf("pass1: illegal cuesheet: \"%s\"\n", error_message); - FLAC__metadata_object_delete(cuesheet); - return 1; - } - - tmpfilenamebase = strstr(infilename, "cuesheets/"); - tmpfilenamebase = tmpfilenamebase == NULL ? infilename : tmpfilenamebase; - - flac_snprintf(tmpfilename, sizeof (tmpfilename), "%s.1", tmpfilenamebase); - if(0 == (fout = flac_fopen(tmpfilename, "w"))) { - fprintf(stderr, "can't open file %s for writing: %s\n", tmpfilename, strerror(errno)); - FLAC__metadata_object_delete(cuesheet); - return 255; - } - grabbag__cuesheet_emit(fout, cuesheet, "\"dummy.wav\" WAVE"); - FLAC__metadata_object_delete(cuesheet); - fclose(fout); - - /* - * pass 2 - */ - if(0 == (fin = flac_fopen(tmpfilename, "r"))) { - fprintf(stderr, "can't open file %s for reading: %s\n", tmpfilename, strerror(errno)); - return 255; - } - if(0 != (cuesheet = grabbag__cuesheet_parse(fin, &error_message, &last_line_read, sample_rate, is_cdda, lead_out_offset))) { - if(fin != stdin) - fclose(fin); - } - else { - printf("pass2: parse error, line %u: \"%s\"\n", last_line_read, error_message); - if(fin != stdin) - fclose(fin); - return 1; - } - if(!FLAC__metadata_object_cuesheet_is_legal(cuesheet, is_cdda, &error_message)) { - printf("pass2: illegal cuesheet: \"%s\"\n", error_message); - FLAC__metadata_object_delete(cuesheet); - return 1; - } - flac_snprintf(tmpfilename, sizeof (tmpfilename), "%s.2", tmpfilenamebase); - if(0 == (fout = flac_fopen(tmpfilename, "w"))) { - fprintf(stderr, "can't open file %s for writing: %s\n", tmpfilename, strerror(errno)); - FLAC__metadata_object_delete(cuesheet); - return 255; - } - grabbag__cuesheet_emit(fout, cuesheet, "\"dummy.wav\" WAVE"); - FLAC__metadata_object_delete(cuesheet); - fclose(fout); - - return 0; -} - -int main(int argc, char *argv[]) -{ - FLAC__uint64 lead_out_offset; - uint32_t sample_rate = 48000; - FLAC__bool is_cdda = false; - const char *usage = "usage: test_cuesheet cuesheet_file lead_out_offset [ [ sample_rate ] cdda ]\n"; - - if(argc > 1 && 0 == strcmp(argv[1], "-h")) { - puts(usage); - return 0; - } - - if(argc < 3 || argc > 5) { - fputs(usage, stderr); - return 255; - } - - lead_out_offset = (FLAC__uint64)strtoul(argv[2], 0, 10); - if(argc >= 4) { - sample_rate = (uint32_t)atoi(argv[3]); - if(argc >= 5) { - if(0 == strcmp(argv[4], "cdda")) - is_cdda = true; - else { - fputs(usage, stderr); - return 255; - } - } - } - - return do_cuesheet(argv[1], sample_rate, is_cdda, lead_out_offset); -} diff --git a/Engine/lib/flac/src/test_grabbag/picture/CMakeLists.txt b/Engine/lib/flac/src/test_grabbag/picture/CMakeLists.txt deleted file mode 100644 index 77f1a3887..000000000 --- a/Engine/lib/flac/src/test_grabbag/picture/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_executable(test_picture - main.c - $<$:../../../include/share/win_utf8_io.h> - $<$:../../share/win_utf8_io/win_utf8_io.c>) -target_link_libraries(test_picture FLAC grabbag) diff --git a/Engine/lib/flac/src/test_grabbag/picture/Makefile.am b/Engine/lib/flac/src/test_grabbag/picture/Makefile.am deleted file mode 100644 index 45e145718..000000000 --- a/Engine/lib/flac/src/test_grabbag/picture/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -# test_picture - Simple tester for picture routines in grabbag -# Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -check_PROGRAMS = test_picture -test_picture_SOURCES = \ - main.c - -if OS_IS_WINDOWS -win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la -endif - -test_picture_LDADD = \ - $(top_builddir)/src/share/grabbag/libgrabbag.la \ - $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - $(win_utf8_lib) - -CLEANFILES = test_picture.exe diff --git a/Engine/lib/flac/src/test_grabbag/picture/main.c b/Engine/lib/flac/src/test_grabbag/picture/main.c deleted file mode 100644 index fe43be94c..000000000 --- a/Engine/lib/flac/src/test_grabbag/picture/main.c +++ /dev/null @@ -1,222 +0,0 @@ -/* test_picture - Simple tester for picture routines in grabbag - * Copyright (C) 2006-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include "FLAC/assert.h" -#include "share/grabbag.h" - -typedef struct { - const char *path; - const char *mime_type; - const char *description; - FLAC__uint32 width; - FLAC__uint32 height; - FLAC__uint32 depth; - FLAC__uint32 colors; - FLAC__StreamMetadata_Picture_Type type; -} PictureFile; - -PictureFile picturefiles[] = { - { "0.gif", "image/gif" , "", 24, 24, 24, 2, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "1.gif", "image/gif" , "", 12, 8, 24, 256, FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER }, - { "2.gif", "image/gif" , "", 16, 14, 24, 128, FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER }, - { "0.jpg", "image/jpeg", "", 30, 20, 8, 0, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "4.jpg", "image/jpeg", "", 31, 47, 24, 0, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "0.png", "image/png" , "", 30, 20, 8, 0, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "1.png", "image/png" , "", 30, 20, 8, 0, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "2.png", "image/png" , "", 30, 20, 24, 7, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "3.png", "image/png" , "", 30, 20, 24, 7, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "4.png", "image/png" , "", 31, 47, 24, 0, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "5.png", "image/png" , "", 31, 47, 24, 0, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "6.png", "image/png" , "", 31, 47, 24, 23, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "7.png", "image/png" , "", 31, 47, 24, 23, FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER }, - { "8.png", "image/png" , "", 32, 32, 32, 0, 999 } -}; - -static FLAC__bool debug_ = false; - -static FLAC__bool failed_(const char *msg) -{ - if(msg) - printf("FAILED, %s\n", msg); - else - printf("FAILED\n"); - - return false; -} - -static FLAC__bool test_one_picture(const char *prefix, const PictureFile *pf, const PictureResolution * res, FLAC__bool fn_only) -{ - FLAC__StreamMetadata *obj; - const char *error; - char s[4096]; - if(fn_only) - flac_snprintf(s, sizeof(s), "pictures/%s", pf->path); - else if (res == NULL) - flac_snprintf(s, sizeof(s), "%u|%s|%s||pictures/%s", (uint32_t)pf->type, pf->mime_type, pf->description, pf->path); - else - flac_snprintf(s, sizeof(s), "%u|%s|%s|%dx%dx%d/%d|pictures/%s", (uint32_t)pf->type, pf->mime_type, pf->description, res->width, res->height, res->depth, res->colors, pf->path); - - printf("testing grabbag__picture_parse_specification(\"%s\")... ", s); - - flac_snprintf(s, sizeof(s), "%s/%s", prefix, pf->path); - if((obj = grabbag__picture_from_specification(fn_only? FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER : pf->type, pf->mime_type, pf->description, res, s, &error)) == 0) - return failed_(error); - if(debug_) { - printf("\ntype=%u (%s)\nmime_type=%s\ndescription=%s\nwidth=%u\nheight=%u\ndepth=%u\ncolors=%u\ndata_length=%u\n", - obj->data.picture.type, - obj->data.picture.type < FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED? - FLAC__StreamMetadata_Picture_TypeString[obj->data.picture.type] : "UNDEFINED", - obj->data.picture.mime_type, - obj->data.picture.description, - obj->data.picture.width, - obj->data.picture.height, - obj->data.picture.depth, - obj->data.picture.colors, - obj->data.picture.data_length - ); - } - if(obj->data.picture.type != (fn_only? FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER : pf->type)) - return failed_("picture type mismatch"); - if(strcmp(obj->data.picture.mime_type, pf->mime_type)) - return failed_("picture MIME type mismatch"); - if(strcmp((const char *)obj->data.picture.description, (const char *)pf->description)) - return failed_("picture description mismatch"); - if(obj->data.picture.width != pf->width) - return failed_("picture width mismatch"); - if(obj->data.picture.height != pf->height) - return failed_("picture height mismatch"); - if(obj->data.picture.depth != pf->depth) - return failed_("picture depth mismatch"); - if(obj->data.picture.colors != pf->colors) - return failed_("picture colors mismatch"); - printf("OK\n"); - FLAC__metadata_object_delete(obj); - return true; -} - -static FLAC__bool do_picture(const char *prefix) -{ - FLAC__StreamMetadata *obj; - PictureResolution res; - const char *error; - size_t i; - - printf("\n+++ grabbag unit test: picture\n\n"); - - /* invalid spec: no filename */ - printf("testing grabbag__picture_parse_specification(\"\")... "); - if(0 != (obj = grabbag__picture_parse_specification("", &error))) - return failed_("expected error, got object"); - printf("OK (failed as expected, error: %s)\n", error); - - /* invalid spec: no filename */ - printf("testing grabbag__picture_parse_specification(\"||||\")... "); - if(0 != (obj = grabbag__picture_parse_specification("||||", &error))) - return failed_("expected error, got object"); - printf("OK (failed as expected: %s)\n", error); - - /* invalid spec: no filename */ - printf("testing grabbag__picture_parse_specification(\"|image/gif|||\")... "); - if(0 != (obj = grabbag__picture_parse_specification("|image/gif|||", &error))) - return failed_("expected error, got object"); - printf("OK (failed as expected: %s)\n", error); - - /* invalid spec: bad resolution */ - printf("testing grabbag__picture_parse_specification(\"|image/gif|desc|320|0.gif\")... "); - if(0 != (obj = grabbag__picture_parse_specification("|image/gif|desc|320|0.gif", &error))) - return failed_("expected error, got object"); - printf("OK (failed as expected: %s)\n", error); - - /* invalid spec: bad resolution */ - printf("testing grabbag__picture_parse_specification(\"|image/gif|desc|320x240|0.gif\")... "); - if(0 != (obj = grabbag__picture_parse_specification("|image/gif|desc|320x240|0.gif", &error))) - return failed_("expected error, got object"); - printf("OK (failed as expected: %s)\n", error); - - /* invalid spec: no filename */ - printf("testing grabbag__picture_parse_specification(\"|image/gif|desc|320x240x9|\")... "); - if(0 != (obj = grabbag__picture_parse_specification("|image/gif|desc|320x240x9|", &error))) - return failed_("expected error, got object"); - printf("OK (failed as expected: %s)\n", error); - - /* invalid spec: #colors exceeds color depth */ - printf("testing grabbag__picture_parse_specification(\"|image/gif|desc|320x240x9/2345|0.gif\")... "); - if(0 != (obj = grabbag__picture_parse_specification("|image/gif|desc|320x240x9/2345|0.gif", &error))) - return failed_("expected error, got object"); - printf("OK (failed as expected: %s)\n", error); - - /* invalid spec: standard icon has to be 32x32 PNG */ - printf("testing grabbag__picture_parse_specification(\"1|-->|desc|32x24x9|0.gif\")... "); - if(0 != (obj = grabbag__picture_parse_specification("1|-->|desc|32x24x9|0.gif", &error))) - return failed_("expected error, got object"); - printf("OK (failed as expected: %s)\n", error); - - /* invalid spec: need resolution for linked URL */ - printf("testing grabbag__picture_parse_specification(\"|-->|desc||http://blah.blah.blah/z.gif\")... "); - if(0 != (obj = grabbag__picture_parse_specification("|-->|desc||http://blah.blah.blah/z.gif", &error))) - return failed_("expected error, got object"); - printf("OK (failed as expected: %s)\n", error); - - printf("testing grabbag__picture_parse_specification(\"|-->|desc|320x240x9|http://blah.blah.blah/z.gif\")... "); - if(0 == (obj = grabbag__picture_parse_specification("|-->|desc|320x240x9|http://blah.blah.blah/z.gif", &error))) - return failed_(error); - printf("OK\n"); - FLAC__metadata_object_delete(obj); - - /* test automatic parsing of picture files from only the file name */ - for(i = 0; i < sizeof(picturefiles)/sizeof(picturefiles[0]); i++) - if(!test_one_picture(prefix, picturefiles+i, NULL, /*fn_only=*/true)) - return false; - - /* test automatic parsing of picture files to get resolution/color info */ - for(i = 0; i < sizeof(picturefiles)/sizeof(picturefiles[0]); i++) - if(!test_one_picture(prefix, picturefiles+i, NULL, /*fn_only=*/false)) - return false; - - res.width = picturefiles[0].width = 320; - res.height = picturefiles[0].height = 240; - res.depth = picturefiles[0].depth = 3; - res.colors = picturefiles[0].colors = 2; - if(!test_one_picture(prefix, picturefiles+0, &res, /*fn_only=*/false)) - return false; - - return true; -} - -int main(int argc, char *argv[]) -{ - const char *usage = "usage: test_pictures path_prefix\n"; - - if(argc > 1 && 0 == strcmp(argv[1], "-h")) { - puts(usage); - return 0; - } - - if(argc != 2) { - fputs(usage, stderr); - return 255; - } - - return do_picture(argv[1])? 0 : 1; -} diff --git a/Engine/lib/flac/src/test_libFLAC++/CMakeLists.txt b/Engine/lib/flac/src/test_libFLAC++/CMakeLists.txt deleted file mode 100644 index 2fa7b1e77..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -add_executable(test_libFLAC++ - decoders.cpp - encoders.cpp - main.cpp - metadata.cpp - metadata_manip.cpp - metadata_object.cpp - $<$:../../include/share/win_utf8_io.h> - $<$:../share/win_utf8_io/win_utf8_io.c>) -target_link_libraries(test_libFLAC++ FLAC++ test_libs_common grabbag) diff --git a/Engine/lib/flac/src/test_libFLAC++/Makefile.am b/Engine/lib/flac/src/test_libFLAC++/Makefile.am deleted file mode 100644 index 8bf746f72..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -# test_libFLAC++ - Unit tester for libFLAC++ -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -check_PROGRAMS = test_libFLAC++ - -if OS_IS_WINDOWS -win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la -endif - -test_libFLAC___LDADD = \ - $(top_builddir)/src/share/grabbag/libgrabbag.la \ - $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ - $(top_builddir)/src/test_libs_common/libtest_libs_common.la \ - $(top_builddir)/src/libFLAC++/libFLAC++.la \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - $(win_utf8_lib) \ - @OGG_LIBS@ \ - -lm - -test_libFLAC___SOURCES = \ - decoders.cpp \ - encoders.cpp \ - main.cpp \ - metadata.cpp \ - metadata_manip.cpp \ - metadata_object.cpp \ - decoders.h \ - encoders.h \ - metadata.h - -CLEANFILES = test_libFLAC++.exe diff --git a/Engine/lib/flac/src/test_libFLAC++/decoders.cpp b/Engine/lib/flac/src/test_libFLAC++/decoders.cpp deleted file mode 100644 index 9f375f346..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/decoders.cpp +++ /dev/null @@ -1,1179 +0,0 @@ -/* test_libFLAC++ - Unit tester for libFLAC++ - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include "decoders.h" -#include "FLAC/assert.h" -#include "FLAC/metadata.h" // for ::FLAC__metadata_object_is_equal() -#include "FLAC++/decoder.h" -#include "share/grabbag.h" -#include "share/compat.h" -extern "C" { -#include "test_libs_common/file_utils_flac.h" -#include "test_libs_common/metadata_utils.h" -} - -#ifdef _MSC_VER -// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) -#pragma warning ( disable : 4800 ) -#endif - -typedef enum { - LAYER_STREAM = 0, /* FLAC__stream_decoder_init_stream() without seeking */ - LAYER_SEEKABLE_STREAM, /* FLAC__stream_decoder_init_stream() with seeking */ - LAYER_FILE, /* FLAC__stream_decoder_init_FILE() */ - LAYER_FILENAME /* FLAC__stream_decoder_init_file() */ -} Layer; - -static const char * const LayerString[] = { - "Stream", - "Seekable Stream", - "FILE*", - "Filename" -}; - -static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_; -static ::FLAC__StreamMetadata *expected_metadata_sequence_[9]; -static uint32_t num_expected_; -static FLAC__off_t flacfilesize_; - -static const char *flacfilename(bool is_ogg) -{ - return is_ogg? "metadata.oga" : "metadata.flac"; -} - -static bool die_(const char *msg) -{ - printf("ERROR: %s\n", msg); - return false; -} - -static FLAC__bool die_s_(const char *msg, const FLAC::Decoder::Stream *decoder) -{ - FLAC::Decoder::Stream::State state = decoder->get_state(); - - if(msg) - printf("FAILED, %s", msg); - else - printf("FAILED"); - - printf(", state = %u (%s)\n", (uint32_t)((::FLAC__StreamDecoderState)state), state.as_cstring()); - - return false; -} - -static void init_metadata_blocks_() -{ - mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_); -} - -static void free_metadata_blocks_() -{ - mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_); -} - -static bool generate_file_(FLAC__bool is_ogg) -{ - printf("\n\ngenerating %sFLAC file for decoder tests...\n", is_ogg? "Ogg ":""); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - /* WATCHOUT: for Ogg FLAC the encoder should move the VORBIS_COMMENT block to the front, right after STREAMINFO */ - - if(!file_utils__generate_flacfile(is_ogg, flacfilename(is_ogg), &flacfilesize_, 512 * 1024, &streaminfo_, expected_metadata_sequence_, num_expected_)) - return die_("creating the encoded file"); - - return true; -} - - -class DecoderCommon { -public: - Layer layer_; - uint32_t current_metadata_number_; - bool ignore_errors_; - bool error_occurred_; - - DecoderCommon(Layer layer): layer_(layer), current_metadata_number_(0), ignore_errors_(false), error_occurred_(false) { } - virtual ~DecoderCommon(void) { } - ::FLAC__StreamDecoderWriteStatus common_write_callback_(const ::FLAC__Frame *frame); - void common_metadata_callback_(const ::FLAC__StreamMetadata *metadata); - void common_error_callback_(::FLAC__StreamDecoderErrorStatus status); -}; - -::FLAC__StreamDecoderWriteStatus DecoderCommon::common_write_callback_(const ::FLAC__Frame *frame) -{ - if(error_occurred_) - return ::FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - - if( - (frame->header.number_type == ::FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER && frame->header.number.frame_number == 0) || - (frame->header.number_type == ::FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER && frame->header.number.sample_number == 0) - ) { - printf("content... "); - fflush(stdout); - } - - return ::FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void DecoderCommon::common_metadata_callback_(const ::FLAC__StreamMetadata *metadata) -{ - if(error_occurred_) - return; - - printf("%u... ", current_metadata_number_); - fflush(stdout); - - if(current_metadata_number_ >= num_expected_) { - (void)die_("got more metadata blocks than expected"); - error_occurred_ = true; - } - else { - if(!::FLAC__metadata_object_is_equal(expected_metadata_sequence_[current_metadata_number_], metadata)) { - (void)die_("metadata block mismatch"); - error_occurred_ = true; - } - } - current_metadata_number_++; -} - -void DecoderCommon::common_error_callback_(::FLAC__StreamDecoderErrorStatus status) -{ - if(!ignore_errors_) { - printf("ERROR: got error callback: err = %u (%s)\n", (uint32_t)status, ::FLAC__StreamDecoderErrorStatusString[status]); - error_occurred_ = true; - } -} - -class StreamDecoder : public FLAC::Decoder::Stream, public DecoderCommon { -public: - FILE *file_; - - StreamDecoder(Layer layer): FLAC::Decoder::Stream(), DecoderCommon(layer), file_(0) { } - ~StreamDecoder() { } - - // from FLAC::Decoder::Stream - ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes); - ::FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset); - ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset); - ::FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length); - bool eof_callback(); - ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]); - void metadata_callback(const ::FLAC__StreamMetadata *metadata); - void error_callback(::FLAC__StreamDecoderErrorStatus status); - - bool test_respond(bool is_ogg); -private: - StreamDecoder(const StreamDecoder&); - StreamDecoder&operator=(const StreamDecoder&); -}; - -::FLAC__StreamDecoderReadStatus StreamDecoder::read_callback(FLAC__byte buffer[], size_t *bytes) -{ - const size_t requested_bytes = *bytes; - - if(error_occurred_) - return ::FLAC__STREAM_DECODER_READ_STATUS_ABORT; - - if(feof(file_)) { - *bytes = 0; - return ::FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } - else if(requested_bytes > 0) { - *bytes = ::fread(buffer, 1, requested_bytes, file_); - if(*bytes == 0) { - if(feof(file_)) - return ::FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - else - return ::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - else { - return ::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - } - else - return ::FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */ -} - -::FLAC__StreamDecoderSeekStatus StreamDecoder::seek_callback(FLAC__uint64 absolute_byte_offset) -{ - if(layer_ == LAYER_STREAM) - return ::FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; - - if(error_occurred_) - return ::FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - - if(fseeko(file_, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) { - error_occurred_ = true; - return ::FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - } - - return ::FLAC__STREAM_DECODER_SEEK_STATUS_OK; -} - -::FLAC__StreamDecoderTellStatus StreamDecoder::tell_callback(FLAC__uint64 *absolute_byte_offset) -{ - if(layer_ == LAYER_STREAM) - return ::FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED; - - if(error_occurred_) - return ::FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - - FLAC__off_t offset = ftello(file_); - *absolute_byte_offset = (FLAC__uint64)offset; - - if(offset < 0) { - error_occurred_ = true; - return ::FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - } - - return ::FLAC__STREAM_DECODER_TELL_STATUS_OK; -} - -::FLAC__StreamDecoderLengthStatus StreamDecoder::length_callback(FLAC__uint64 *stream_length) -{ - if(layer_ == LAYER_STREAM) - return ::FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; - - if(error_occurred_) - return ::FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; - - *stream_length = (FLAC__uint64)flacfilesize_; - return ::FLAC__STREAM_DECODER_LENGTH_STATUS_OK; -} - -bool StreamDecoder::eof_callback() -{ - if(layer_ == LAYER_STREAM) - return false; - - if(error_occurred_) - return true; - - return (bool)feof(file_); -} - -::FLAC__StreamDecoderWriteStatus StreamDecoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) -{ - (void)buffer; - - return common_write_callback_(frame); -} - -void StreamDecoder::metadata_callback(const ::FLAC__StreamMetadata *metadata) -{ - common_metadata_callback_(metadata); -} - -void StreamDecoder::error_callback(::FLAC__StreamDecoderErrorStatus status) -{ - common_error_callback_(status); -} - -bool StreamDecoder::test_respond(bool is_ogg) -{ - ::FLAC__StreamDecoderInitStatus init_status; - - if(!set_md5_checking(true)) { - printf("FAILED at set_md5_checking(), returned false\n"); - return false; - } - - printf("testing init%s()... ", is_ogg? "_ogg":""); - init_status = is_ogg? init_ogg() : init(); - if(init_status != ::FLAC__STREAM_DECODER_INIT_STATUS_OK) - return die_s_(0, this); - printf("OK\n"); - - current_metadata_number_ = 0; - - if(fseeko(file_, 0, SEEK_SET) < 0) { - printf("FAILED rewinding input, errno = %d\n", errno); - return false; - } - - printf("testing process_until_end_of_stream()... "); - if(!process_until_end_of_stream()) { - State state = get_state(); - printf("FAILED, returned false, state = %u (%s)\n", (uint32_t)((::FLAC__StreamDecoderState)state), state.as_cstring()); - return false; - } - printf("OK\n"); - - printf("testing finish()... "); - if(!finish()) { - State state = get_state(); - printf("FAILED, returned false, state = %u (%s)\n", (uint32_t)((::FLAC__StreamDecoderState)state), state.as_cstring()); - return false; - } - printf("OK\n"); - - return true; -} - -class FileDecoder : public FLAC::Decoder::File, public DecoderCommon { -public: - FileDecoder(Layer layer): FLAC::Decoder::File(), DecoderCommon(layer) { } - ~FileDecoder() { } - - // from FLAC::Decoder::Stream - ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]); - void metadata_callback(const ::FLAC__StreamMetadata *metadata); - void error_callback(::FLAC__StreamDecoderErrorStatus status); - - bool test_respond(bool is_ogg); -}; - -::FLAC__StreamDecoderWriteStatus FileDecoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) -{ - (void)buffer; - return common_write_callback_(frame); -} - -void FileDecoder::metadata_callback(const ::FLAC__StreamMetadata *metadata) -{ - common_metadata_callback_(metadata); -} - -void FileDecoder::error_callback(::FLAC__StreamDecoderErrorStatus status) -{ - common_error_callback_(status); -} - -bool FileDecoder::test_respond(bool is_ogg) -{ - ::FLAC__StreamDecoderInitStatus init_status; - - if(!set_md5_checking(true)) { - printf("FAILED at set_md5_checking(), returned false\n"); - return false; - } - - switch(layer_) { - case LAYER_FILE: - { - printf("opening %sFLAC file... ", is_ogg? "Ogg ":""); - FILE *file = ::flac_fopen(flacfilename(is_ogg), "rb"); - if(0 == file) { - printf("ERROR (%s)\n", strerror(errno)); - return false; - } - printf("OK\n"); - - printf("testing init%s()... ", is_ogg? "_ogg":""); - init_status = is_ogg? init_ogg(file) : init(file); - } - break; - case LAYER_FILENAME: - printf("testing init%s()... ", is_ogg? "_ogg":""); - init_status = is_ogg? init_ogg(flacfilename(is_ogg)) : init(flacfilename(is_ogg)); - break; - default: - die_("internal error 001"); - return false; - } - if(init_status != ::FLAC__STREAM_DECODER_INIT_STATUS_OK) - return die_s_(0, this); - printf("OK\n"); - - current_metadata_number_ = 0; - - printf("testing process_until_end_of_stream()... "); - if(!process_until_end_of_stream()) { - State state = get_state(); - printf("FAILED, returned false, state = %u (%s)\n", (uint32_t)((::FLAC__StreamDecoderState)state), state.as_cstring()); - return false; - } - printf("OK\n"); - - printf("testing finish()... "); - if(!finish()) { - State state = get_state(); - printf("FAILED, returned false, state = %u (%s)\n", (uint32_t)((::FLAC__StreamDecoderState)state), state.as_cstring()); - return false; - } - printf("OK\n"); - - return true; -} - - -static FLAC::Decoder::Stream *new_by_layer(Layer layer) -{ - if(layer < LAYER_FILE) - return new StreamDecoder(layer); - else - return new FileDecoder(layer); -} - -static bool test_stream_decoder(Layer layer, bool is_ogg) -{ - FLAC::Decoder::Stream *decoder; - ::FLAC__StreamDecoderInitStatus init_status; - bool expect; - - printf("\n+++ libFLAC++ unit test: FLAC::Decoder::%s (layer: %s, format: %s)\n\n", layer delete - // - printf("allocating decoder instance... "); - decoder = new_by_layer(layer); - if(0 == decoder) { - printf("FAILED, new returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing is_valid()... "); - if(!decoder->is_valid()) { - printf("FAILED, returned false\n"); - delete decoder; - return false; - } - printf("OK\n"); - - printf("freeing decoder instance... "); - delete decoder; - printf("OK\n"); - - // - // test new -> init -> delete - // - printf("allocating decoder instance... "); - decoder = new_by_layer(layer); - if(0 == decoder) { - printf("FAILED, new returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing is_valid()... "); - if(!decoder->is_valid()) { - printf("FAILED, returned false\n"); - delete decoder; - return false; - } - printf("OK\n"); - - printf("testing init%s()... ", is_ogg? "_ogg":""); - switch(layer) { - case LAYER_STREAM: - case LAYER_SEEKABLE_STREAM: - dynamic_cast(decoder)->file_ = stdin; - init_status = is_ogg? decoder->init_ogg() : decoder->init(); - break; - case LAYER_FILE: - init_status = is_ogg? - dynamic_cast(decoder)->init_ogg(stdin) : - dynamic_cast(decoder)->init(stdin); - break; - case LAYER_FILENAME: - init_status = is_ogg? - dynamic_cast(decoder)->init_ogg(flacfilename(is_ogg)) : - dynamic_cast(decoder)->init(flacfilename(is_ogg)); - break; - default: - die_("internal error 006"); - delete decoder; - return false; - } - if(init_status != ::FLAC__STREAM_DECODER_INIT_STATUS_OK) - return die_s_(0, decoder); - printf("OK\n"); - - printf("freeing decoder instance... "); - delete decoder; - printf("OK\n"); - - // - // test normal usage - // - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - - printf("allocating decoder instance... "); - decoder = new_by_layer(layer); - if(0 == decoder) { - printf("FAILED, new returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing is_valid()... "); - if(!decoder->is_valid()) { - printf("FAILED, returned false\n"); - delete decoder; - return false; - } - printf("OK\n"); - - if(is_ogg) { - printf("testing set_ogg_serial_number()... "); - if(!decoder->set_ogg_serial_number(file_utils__ogg_serial_number)) - return die_s_("returned false", decoder); - printf("OK\n"); - } - - if(!decoder->set_md5_checking(true)) { - printf("FAILED at set_md5_checking(), returned false\n"); - return false; - } - - switch(layer) { - case LAYER_STREAM: - case LAYER_SEEKABLE_STREAM: - printf("opening %sFLAC file... ", is_ogg? "Ogg ":""); - dynamic_cast(decoder)->file_ = ::flac_fopen(flacfilename(is_ogg), "rb"); - if(0 == dynamic_cast(decoder)->file_) { - printf("ERROR (%s)\n", strerror(errno)); - return false; - } - printf("OK\n"); - - printf("testing init%s()... ", is_ogg? "_ogg":""); - init_status = is_ogg? decoder->init_ogg() : decoder->init(); - break; - case LAYER_FILE: - { - printf("opening FLAC file... "); - FILE *file = ::flac_fopen(flacfilename(is_ogg), "rb"); - if(0 == file) { - printf("ERROR (%s)\n", strerror(errno)); - return false; - } - printf("OK\n"); - - printf("testing init%s()... ", is_ogg? "_ogg":""); - init_status = is_ogg? - dynamic_cast(decoder)->init_ogg(file) : - dynamic_cast(decoder)->init(file); - } - break; - case LAYER_FILENAME: - printf("testing init%s()... ", is_ogg? "_ogg":""); - init_status = is_ogg? - dynamic_cast(decoder)->init_ogg(flacfilename(is_ogg)) : - dynamic_cast(decoder)->init(flacfilename(is_ogg)); - break; - default: - die_("internal error 009"); - return false; - } - if(init_status != ::FLAC__STREAM_DECODER_INIT_STATUS_OK) - return die_s_(0, decoder); - printf("OK\n"); - - printf("testing get_state()... "); - FLAC::Decoder::Stream::State state = decoder->get_state(); - printf("returned state = %u (%s)... OK\n", (uint32_t)((::FLAC__StreamDecoderState)state), state.as_cstring()); - - dynamic_cast(decoder)->current_metadata_number_ = 0; - dynamic_cast(decoder)->ignore_errors_ = false; - dynamic_cast(decoder)->error_occurred_ = false; - - printf("testing get_md5_checking()... "); - if(!decoder->get_md5_checking()) { - printf("FAILED, returned false, expected true\n"); - return false; - } - printf("OK\n"); - - printf("testing process_until_end_of_metadata()... "); - if(!decoder->process_until_end_of_metadata()) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing process_single()... "); - if(!decoder->process_single()) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing skip_single_frame()... "); - if(!decoder->skip_single_frame()) - return die_s_("returned false", decoder); - printf("OK\n"); - - if(layer < LAYER_FILE) { - printf("testing flush()... "); - if(!decoder->flush()) - return die_s_("returned false", decoder); - printf("OK\n"); - - dynamic_cast(decoder)->ignore_errors_ = true; - printf("testing process_single()... "); - if(!decoder->process_single()) - return die_s_("returned false", decoder); - printf("OK\n"); - dynamic_cast(decoder)->ignore_errors_ = false; - } - - expect = (layer != LAYER_STREAM); - printf("testing seek_absolute()... "); - if(decoder->seek_absolute(0) != expect) - return die_s_(expect? "returned false" : "returned true", decoder); - printf("OK\n"); - - printf("testing process_until_end_of_stream()... "); - if(!decoder->process_until_end_of_stream()) - return die_s_("returned false", decoder); - printf("OK\n"); - - expect = (layer != LAYER_STREAM); - printf("testing seek_absolute()... "); - if(decoder->seek_absolute(0) != expect) - return die_s_(expect? "returned false" : "returned true", decoder); - printf("OK\n"); - - printf("testing get_channels()... "); - { - uint32_t channels = decoder->get_channels(); - if(channels != streaminfo_.data.stream_info.channels) { - printf("FAILED, returned %u, expected %u\n", channels, streaminfo_.data.stream_info.channels); - return false; - } - } - printf("OK\n"); - - printf("testing get_bits_per_sample()... "); - { - uint32_t bits_per_sample = decoder->get_bits_per_sample(); - if(bits_per_sample != streaminfo_.data.stream_info.bits_per_sample) { - printf("FAILED, returned %u, expected %u\n", bits_per_sample, streaminfo_.data.stream_info.bits_per_sample); - return false; - } - } - printf("OK\n"); - - printf("testing get_sample_rate()... "); - { - uint32_t sample_rate = decoder->get_sample_rate(); - if(sample_rate != streaminfo_.data.stream_info.sample_rate) { - printf("FAILED, returned %u, expected %u\n", sample_rate, streaminfo_.data.stream_info.sample_rate); - return false; - } - } - printf("OK\n"); - - printf("testing get_blocksize()... "); - { - uint32_t blocksize = decoder->get_blocksize(); - /* value could be anything since we're at the last block, so accept any reasonable answer */ - printf("returned %u... %s\n", blocksize, blocksize>0? "OK" : "FAILED"); - if(blocksize == 0) - return false; - } - - printf("testing get_channel_assignment()... "); - { - ::FLAC__ChannelAssignment ca = decoder->get_channel_assignment(); - printf("returned %u (%s)... OK\n", (uint32_t)ca, ::FLAC__ChannelAssignmentString[ca]); - } - - if(layer < LAYER_FILE) { - printf("testing reset()... "); - if(!decoder->reset()) - return die_s_("returned false", decoder); - printf("OK\n"); - - if(layer == LAYER_STREAM) { - /* after a reset() we have to rewind the input ourselves */ - printf("rewinding input... "); - if(fseeko(dynamic_cast(decoder)->file_, 0, SEEK_SET) < 0) { - printf("FAILED, errno = %d\n", errno); - return false; - } - printf("OK\n"); - } - - dynamic_cast(decoder)->current_metadata_number_ = 0; - - printf("testing process_until_end_of_stream()... "); - if(!decoder->process_until_end_of_stream()) - return die_s_("returned false", decoder); - printf("OK\n"); - } - - printf("testing finish()... "); - if(!decoder->finish()) { - state = decoder->get_state(); - printf("FAILED, returned false, state = %u (%s)\n", (uint32_t)((::FLAC__StreamDecoderState)state), state.as_cstring()); - return false; - } - printf("OK\n"); - - /* - * respond all - */ - - printf("testing set_metadata_respond_all()... "); - if(!decoder->set_metadata_respond_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * ignore all - */ - - printf("testing set_metadata_ignore_all()... "); - if(!decoder->set_metadata_ignore_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * respond all, ignore VORBIS_COMMENT - */ - - printf("testing set_metadata_respond_all()... "); - if(!decoder->set_metadata_respond_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_ignore(VORBIS_COMMENT)... "); - if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_VORBIS_COMMENT)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - if(!is_ogg) /* encoder removes seektable for ogg */ - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * respond all, ignore APPLICATION - */ - - printf("testing set_metadata_respond_all()... "); - if(!decoder->set_metadata_respond_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_ignore(APPLICATION)... "); - if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * respond all, ignore APPLICATION id of app#1 - */ - - printf("testing set_metadata_respond_all()... "); - if(!decoder->set_metadata_respond_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_ignore_application(of app block #1)... "); - if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * respond all, ignore APPLICATION id of app#1 & app#2 - */ - - printf("testing set_metadata_respond_all()... "); - if(!decoder->set_metadata_respond_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_ignore_application(of app block #1)... "); - if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_ignore_application(of app block #2)... "); - if(!decoder->set_metadata_ignore_application(application2_.data.application.id)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * ignore all, respond VORBIS_COMMENT - */ - - printf("testing set_metadata_ignore_all()... "); - if(!decoder->set_metadata_ignore_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_respond(VORBIS_COMMENT)... "); - if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_VORBIS_COMMENT)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * ignore all, respond APPLICATION - */ - - printf("testing set_metadata_ignore_all()... "); - if(!decoder->set_metadata_ignore_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_respond(APPLICATION)... "); - if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * ignore all, respond APPLICATION id of app#1 - */ - - printf("testing set_metadata_ignore_all()... "); - if(!decoder->set_metadata_ignore_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_respond_application(of app block #1)... "); - if(!decoder->set_metadata_respond_application(application1_.data.application.id)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &application1_; - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * ignore all, respond APPLICATION id of app#1 & app#2 - */ - - printf("testing set_metadata_ignore_all()... "); - if(!decoder->set_metadata_ignore_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_respond_application(of app block #1)... "); - if(!decoder->set_metadata_respond_application(application1_.data.application.id)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_respond_application(of app block #2)... "); - if(!decoder->set_metadata_respond_application(application2_.data.application.id)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * respond all, ignore APPLICATION, respond APPLICATION id of app#1 - */ - - printf("testing set_metadata_respond_all()... "); - if(!decoder->set_metadata_respond_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_ignore(APPLICATION)... "); - if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_respond_application(of app block #1)... "); - if(!decoder->set_metadata_respond_application(application1_.data.application.id)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - /* - * ignore all, respond APPLICATION, ignore APPLICATION id of app#1 - */ - - printf("testing set_metadata_ignore_all()... "); - if(!decoder->set_metadata_ignore_all()) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_respond(APPLICATION)... "); - if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing set_metadata_ignore_application(of app block #1)... "); - if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &application2_; - - if(!(layer < LAYER_FILE? dynamic_cast(decoder)->test_respond(is_ogg) : dynamic_cast(decoder)->test_respond(is_ogg))) - return false; - - if(layer < LAYER_FILE) /* for LAYER_FILE, FLAC__stream_decoder_finish() closes the file */ - ::fclose(dynamic_cast(decoder)->file_); - - printf("freeing decoder instance... "); - delete decoder; - printf("OK\n"); - - printf("\nPASSED!\n"); - - return true; -} - -bool test_decoders() -{ - FLAC__bool is_ogg = false; - - while(1) { - init_metadata_blocks_(); - - if(!generate_file_(is_ogg)) - return false; - - if(!test_stream_decoder(LAYER_STREAM, is_ogg)) - return false; - - if(!test_stream_decoder(LAYER_SEEKABLE_STREAM, is_ogg)) - return false; - - if(!test_stream_decoder(LAYER_FILE, is_ogg)) - return false; - - if(!test_stream_decoder(LAYER_FILENAME, is_ogg)) - return false; - - (void) grabbag__file_remove_file(flacfilename(is_ogg)); - - free_metadata_blocks_(); - - if(!FLAC_API_SUPPORTS_OGG_FLAC || is_ogg) - break; - is_ogg = true; - } - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC++/decoders.h b/Engine/lib/flac/src/test_libFLAC++/decoders.h deleted file mode 100644 index 4bbce132b..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/decoders.h +++ /dev/null @@ -1,25 +0,0 @@ -/* test_libFLAC++ - Unit tester for libFLAC++ - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLACPP_DECODERS_H -#define FLAC__TEST_LIBFLACPP_DECODERS_H - -bool test_decoders(); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC++/encoders.cpp b/Engine/lib/flac/src/test_libFLAC++/encoders.cpp deleted file mode 100644 index 0e356afe4..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/encoders.cpp +++ /dev/null @@ -1,576 +0,0 @@ -/* test_libFLAC++ - Unit tester for libFLAC++ - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "encoders.h" -#include "FLAC/assert.h" -#include "FLAC++/encoder.h" -#include "share/grabbag.h" -extern "C" { -#include "test_libs_common/file_utils_flac.h" -#include "test_libs_common/metadata_utils.h" -} -#include -#include -#include -#include -#include "share/compat.h" - -#ifdef _MSC_VER -// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) -#pragma warning ( disable : 4800 ) -#endif - -typedef enum { - LAYER_STREAM = 0, /* FLAC__stream_encoder_init_stream() without seeking */ - LAYER_SEEKABLE_STREAM, /* FLAC__stream_encoder_init_stream() with seeking */ - LAYER_FILE, /* FLAC__stream_encoder_init_FILE() */ - LAYER_FILENAME /* FLAC__stream_encoder_init_file() */ -} Layer; - -static const char * const LayerString[] = { - "Stream", - "Seekable Stream", - "FILE*", - "Filename" -}; - -static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_; -static ::FLAC__StreamMetadata *metadata_sequence_[] = { &vorbiscomment_, &padding_, &seektable_, &application1_, &application2_, &cuesheet_, &picture_, &unknown_ }; -static const uint32_t num_metadata_ = sizeof(metadata_sequence_) / sizeof(metadata_sequence_[0]); - -static const char *flacfilename(bool is_ogg) -{ - return is_ogg? "metadata.oga" : "metadata.flac"; -} - -static bool die_(const char *msg) -{ - printf("ERROR: %s\n", msg); - return false; -} - -static bool die_s_(const char *msg, const FLAC::Encoder::Stream *encoder) -{ - FLAC::Encoder::Stream::State state = encoder->get_state(); - - if(msg) - printf("FAILED, %s", msg); - else - printf("FAILED"); - - printf(", state = %u (%s)\n", (uint32_t)((::FLAC__StreamEncoderState)state), state.as_cstring()); - if(state == ::FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) { - FLAC::Decoder::Stream::State dstate = encoder->get_verify_decoder_state(); - printf(" verify decoder state = %u (%s)\n", (uint32_t)((::FLAC__StreamDecoderState)dstate), dstate.as_cstring()); - } - - return false; -} - -static void init_metadata_blocks_() -{ - mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_); -} - -static void free_metadata_blocks_() -{ - mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_); -} - -class StreamEncoder : public FLAC::Encoder::Stream { -public: - Layer layer_; - FILE *file_; - - StreamEncoder(Layer layer): FLAC::Encoder::Stream(), layer_(layer), file_(0) { } - ~StreamEncoder() { } - - // from FLAC::Encoder::Stream - ::FLAC__StreamEncoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes); - ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame); - ::FLAC__StreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset); - ::FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset); - void metadata_callback(const ::FLAC__StreamMetadata *metadata); -private: - StreamEncoder(const StreamEncoder&); - StreamEncoder&operator=(const StreamEncoder&); -}; - -::FLAC__StreamEncoderReadStatus StreamEncoder::read_callback(FLAC__byte buffer[], size_t *bytes) -{ - if(*bytes > 0) { - *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file_); - if(ferror(file_)) - return ::FLAC__STREAM_ENCODER_READ_STATUS_ABORT; - else if(*bytes == 0) - return ::FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM; - else - return ::FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE; - } - else - return ::FLAC__STREAM_ENCODER_READ_STATUS_ABORT; -} - -::FLAC__StreamEncoderWriteStatus StreamEncoder::write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame) -{ - (void)samples, (void)current_frame; - - if(fwrite(buffer, 1, bytes, file_) != bytes) - return ::FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - else - return ::FLAC__STREAM_ENCODER_WRITE_STATUS_OK; -} - -::FLAC__StreamEncoderSeekStatus StreamEncoder::seek_callback(FLAC__uint64 absolute_byte_offset) -{ - if(layer_==LAYER_STREAM) - return ::FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED; - else if(fseeko(file_, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) - return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR; - else - return FLAC__STREAM_ENCODER_SEEK_STATUS_OK; -} - -::FLAC__StreamEncoderTellStatus StreamEncoder::tell_callback(FLAC__uint64 *absolute_byte_offset) -{ - FLAC__off_t pos; - if(layer_==LAYER_STREAM) - return ::FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED; - else if((pos = ftello(file_)) < 0) - return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR; - else { - *absolute_byte_offset = (FLAC__uint64)pos; - return FLAC__STREAM_ENCODER_TELL_STATUS_OK; - } -} - -void StreamEncoder::metadata_callback(const ::FLAC__StreamMetadata *metadata) -{ - (void)metadata; -} - -class FileEncoder : public FLAC::Encoder::File { -public: - Layer layer_; - - FileEncoder(Layer layer): FLAC::Encoder::File(), layer_(layer) { } - ~FileEncoder() { } - - // from FLAC::Encoder::File - void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate); -}; - -void FileEncoder::progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate) -{ - (void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate; -} - -static FLAC::Encoder::Stream *new_by_layer(Layer layer) -{ - if(layer < LAYER_FILE) - return new StreamEncoder(layer); - else - return new FileEncoder(layer); -} - -static bool test_stream_encoder(Layer layer, bool is_ogg) -{ - FLAC::Encoder::Stream *encoder; - ::FLAC__StreamEncoderInitStatus init_status; - FILE *file = 0; - FLAC__int32 samples[1024]; - FLAC__int32 *samples_array[1] = { samples }; - uint32_t i; - - printf("\n+++ libFLAC++ unit test: FLAC::Encoder::%s (layer: %s, format: %s)\n\n", layeris_valid()) { - printf("FAILED, returned false\n"); - delete encoder; - return false; - } - printf("OK\n"); - - if(is_ogg) { - printf("testing set_ogg_serial_number()... "); - if(!encoder->set_ogg_serial_number(file_utils__ogg_serial_number)) - return die_s_("returned false", encoder); - printf("OK\n"); - } - - printf("testing set_verify()... "); - if(!encoder->set_verify(true)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_streamable_subset()... "); - if(!encoder->set_streamable_subset(true)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_channels()... "); - if(!encoder->set_channels(streaminfo_.data.stream_info.channels)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_bits_per_sample()... "); - if(!encoder->set_bits_per_sample(streaminfo_.data.stream_info.bits_per_sample)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_sample_rate()... "); - if(!encoder->set_sample_rate(streaminfo_.data.stream_info.sample_rate)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_compression_level()... "); - if(!encoder->set_compression_level((uint32_t)(-1))) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_blocksize()... "); - if(!encoder->set_blocksize(streaminfo_.data.stream_info.min_blocksize)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_do_mid_side_stereo()... "); - if(!encoder->set_do_mid_side_stereo(false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_loose_mid_side_stereo()... "); - if(!encoder->set_loose_mid_side_stereo(false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_max_lpc_order()... "); - if(!encoder->set_max_lpc_order(0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_qlp_coeff_precision()... "); - if(!encoder->set_qlp_coeff_precision(0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_do_qlp_coeff_prec_search()... "); - if(!encoder->set_do_qlp_coeff_prec_search(false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_do_escape_coding()... "); - if(!encoder->set_do_escape_coding(false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_do_exhaustive_model_search()... "); - if(!encoder->set_do_exhaustive_model_search(false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_min_residual_partition_order()... "); - if(!encoder->set_min_residual_partition_order(0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_max_residual_partition_order()... "); - if(!encoder->set_max_residual_partition_order(0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_rice_parameter_search_dist()... "); - if(!encoder->set_rice_parameter_search_dist(0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_total_samples_estimate()... "); - if(!encoder->set_total_samples_estimate(streaminfo_.data.stream_info.total_samples)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_metadata()... "); - if(!encoder->set_metadata(metadata_sequence_, num_metadata_)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing set_limit_min_bitrate()... "); - if(!encoder->set_limit_min_bitrate(true)) - return die_s_("returned false", encoder); - printf("OK\n"); - - if(layer < LAYER_FILENAME) { - printf("opening file for FLAC output... "); - file = ::flac_fopen(flacfilename(is_ogg), "w+b"); - if(0 == file) { - printf("ERROR (%s)\n", strerror(errno)); - return false; - } - printf("OK\n"); - if(layer < LAYER_FILE) - dynamic_cast(encoder)->file_ = file; - } - - switch(layer) { - case LAYER_STREAM: - case LAYER_SEEKABLE_STREAM: - printf("testing init%s()... ", is_ogg? "_ogg":""); - init_status = is_ogg? encoder->init_ogg() : encoder->init(); - break; - case LAYER_FILE: - printf("testing init%s()... ", is_ogg? "_ogg":""); - init_status = is_ogg? - dynamic_cast(encoder)->init_ogg(file) : - dynamic_cast(encoder)->init(file); - break; - case LAYER_FILENAME: - printf("testing init%s()... ", is_ogg? "_ogg":""); - init_status = is_ogg? - dynamic_cast(encoder)->init_ogg(flacfilename(is_ogg)) : - dynamic_cast(encoder)->init(flacfilename(is_ogg)); - break; - default: - die_("internal error 001"); - return false; - } - if(init_status != ::FLAC__STREAM_ENCODER_INIT_STATUS_OK) - return die_s_(0, encoder); - printf("OK\n"); - - printf("testing get_state()... "); - FLAC::Encoder::Stream::State state = encoder->get_state(); - printf("returned state = %u (%s)... OK\n", (uint32_t)((::FLAC__StreamEncoderState)state), state.as_cstring()); - - printf("testing get_verify_decoder_state()... "); - FLAC::Decoder::Stream::State dstate = encoder->get_verify_decoder_state(); - printf("returned state = %u (%s)... OK\n", (uint32_t)((::FLAC__StreamDecoderState)dstate), dstate.as_cstring()); - - { - FLAC__uint64 absolute_sample; - uint32_t frame_number; - uint32_t channel; - uint32_t sample; - FLAC__int32 expected; - FLAC__int32 got; - - printf("testing get_verify_decoder_error_stats()... "); - encoder->get_verify_decoder_error_stats(&absolute_sample, &frame_number, &channel, &sample, &expected, &got); - printf("OK\n"); - } - - printf("testing get_verify()... "); - if(encoder->get_verify() != true) { - printf("FAILED, expected true, got false\n"); - return false; - } - printf("OK\n"); - - printf("testing get_streamable_subset()... "); - if(encoder->get_streamable_subset() != true) { - printf("FAILED, expected true, got false\n"); - return false; - } - printf("OK\n"); - - printf("testing get_do_mid_side_stereo()... "); - if(encoder->get_do_mid_side_stereo() != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing get_loose_mid_side_stereo()... "); - if(encoder->get_loose_mid_side_stereo() != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing get_channels()... "); - if(encoder->get_channels() != streaminfo_.data.stream_info.channels) { - printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.channels, encoder->get_channels()); - return false; - } - printf("OK\n"); - - printf("testing get_bits_per_sample()... "); - if(encoder->get_bits_per_sample() != streaminfo_.data.stream_info.bits_per_sample) { - printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.bits_per_sample, encoder->get_bits_per_sample()); - return false; - } - printf("OK\n"); - - printf("testing get_sample_rate()... "); - if(encoder->get_sample_rate() != streaminfo_.data.stream_info.sample_rate) { - printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.sample_rate, encoder->get_sample_rate()); - return false; - } - printf("OK\n"); - - printf("testing get_blocksize()... "); - if(encoder->get_blocksize() != streaminfo_.data.stream_info.min_blocksize) { - printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.min_blocksize, encoder->get_blocksize()); - return false; - } - printf("OK\n"); - - printf("testing get_max_lpc_order()... "); - if(encoder->get_max_lpc_order() != 0) { - printf("FAILED, expected %d, got %u\n", 0, encoder->get_max_lpc_order()); - return false; - } - printf("OK\n"); - - printf("testing get_qlp_coeff_precision()... "); - (void)encoder->get_qlp_coeff_precision(); - /* we asked the encoder to auto select this so we accept anything */ - printf("OK\n"); - - printf("testing get_do_qlp_coeff_prec_search()... "); - if(encoder->get_do_qlp_coeff_prec_search() != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing get_do_escape_coding()... "); - if(encoder->get_do_escape_coding() != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing get_do_exhaustive_model_search()... "); - if(encoder->get_do_exhaustive_model_search() != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing get_min_residual_partition_order()... "); - if(encoder->get_min_residual_partition_order() != 0) { - printf("FAILED, expected %d, got %u\n", 0, encoder->get_min_residual_partition_order()); - return false; - } - printf("OK\n"); - - printf("testing get_max_residual_partition_order()... "); - if(encoder->get_max_residual_partition_order() != 0) { - printf("FAILED, expected %d, got %u\n", 0, encoder->get_max_residual_partition_order()); - return false; - } - printf("OK\n"); - - printf("testing get_rice_parameter_search_dist()... "); - if(encoder->get_rice_parameter_search_dist() != 0) { - printf("FAILED, expected %d, got %u\n", 0, encoder->get_rice_parameter_search_dist()); - return false; - } - printf("OK\n"); - - printf("testing get_total_samples_estimate()... "); - if(encoder->get_total_samples_estimate() != streaminfo_.data.stream_info.total_samples) { - printf("FAILED, expected %" PRIu64 ", got %" PRIu64 "\n", streaminfo_.data.stream_info.total_samples, encoder->get_total_samples_estimate()); - return false; - } - printf("OK\n"); - - printf("testing get_limit_min_bitrate()... "); - if(encoder->get_limit_min_bitrate() != true) { - printf("FAILED, expected true, got false\n"); - return false; - } - printf("OK\n"); - - /* init the dummy sample buffer */ - for(i = 0; i < sizeof(samples) / sizeof(FLAC__int32); i++) - samples[i] = i & 7; - - printf("testing process()... "); - if(!encoder->process(samples_array, sizeof(samples) / sizeof(FLAC__int32))) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing process_interleaved()... "); - if(!encoder->process_interleaved(samples, sizeof(samples) / sizeof(FLAC__int32))) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing finish()... "); - if(!encoder->finish()) { - state = encoder->get_state(); - printf("FAILED, returned false, state = %u (%s)\n", (uint32_t)((::FLAC__StreamEncoderState)state), state.as_cstring()); - return false; - } - printf("OK\n"); - - if(layer < LAYER_FILE) - ::fclose(dynamic_cast(encoder)->file_); - - printf("freeing encoder instance... "); - delete encoder; - printf("OK\n"); - - printf("\nPASSED!\n"); - - return true; -} - -bool test_encoders() -{ - FLAC__bool is_ogg = false; - - while(1) { - init_metadata_blocks_(); - - if(!test_stream_encoder(LAYER_STREAM, is_ogg)) - return false; - - if(!test_stream_encoder(LAYER_SEEKABLE_STREAM, is_ogg)) - return false; - - if(!test_stream_encoder(LAYER_FILE, is_ogg)) - return false; - - if(!test_stream_encoder(LAYER_FILENAME, is_ogg)) - return false; - - (void) grabbag__file_remove_file(flacfilename(is_ogg)); - - free_metadata_blocks_(); - - if(!FLAC_API_SUPPORTS_OGG_FLAC || is_ogg) - break; - is_ogg = true; - } - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC++/encoders.h b/Engine/lib/flac/src/test_libFLAC++/encoders.h deleted file mode 100644 index 9da415c52..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/encoders.h +++ /dev/null @@ -1,25 +0,0 @@ -/* test_libFLAC++ - Unit tester for libFLAC++ - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLACPP_ENCODERS_H -#define FLAC__TEST_LIBFLACPP_ENCODERS_H - -bool test_encoders(); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC++/main.cpp b/Engine/lib/flac/src/test_libFLAC++/main.cpp deleted file mode 100644 index 7183def77..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/main.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* test_libFLAC++ - Unit tester for libFLAC++ - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "decoders.h" -#include "encoders.h" -#include "metadata.h" - -int main(int argc, char *argv[]) -{ - (void)argc, (void)argv; - - if(!test_encoders()) - return 1; - - if(!test_decoders()) - return 1; - - if(!test_metadata()) - return 1; - - return 0; -} diff --git a/Engine/lib/flac/src/test_libFLAC++/metadata.cpp b/Engine/lib/flac/src/test_libFLAC++/metadata.cpp deleted file mode 100644 index a31031b62..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/metadata.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* test_libFLAC++ - Unit tester for libFLAC++ - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "metadata.h" -#include - -extern bool test_metadata_object(); -extern bool test_metadata_file_manipulation(); - -bool test_metadata() -{ - if(!test_metadata_object()) - return false; - - if(!test_metadata_file_manipulation()) - return false; - - printf("\nPASSED!\n"); - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC++/metadata.h b/Engine/lib/flac/src/test_libFLAC++/metadata.h deleted file mode 100644 index 8c45bc0a2..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/metadata.h +++ /dev/null @@ -1,25 +0,0 @@ -/* test_libFLAC++ - Unit tester for libFLAC++ - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLACPP_METADATA_H -#define FLAC__TEST_LIBFLACPP_METADATA_H - -bool test_metadata(); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC++/metadata_manip.cpp b/Engine/lib/flac/src/test_libFLAC++/metadata_manip.cpp deleted file mode 100644 index 5d395dbd4..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/metadata_manip.cpp +++ /dev/null @@ -1,2241 +0,0 @@ -/* test_libFLAC++ - Unit tester for libFLAC++ - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include /* for malloc() */ -#include /* for memcpy()/memset() */ -#include /* some flavors of BSD (like OS X) require this to get time_t */ -#ifdef _MSC_VER -#include -#endif -#if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__ -#include /* for chown(), unlink() */ -#endif -#include /* for stat(), maybe chmod() */ -#include "FLAC/assert.h" -#include "FLAC++/decoder.h" -#include "FLAC++/metadata.h" -#include "share/grabbag.h" -#include "share/compat.h" -#include "share/macros.h" -#include "share/safe_str.h" -extern "C" { -#include "test_libs_common/file_utils_flac.h" -} - -/****************************************************************************** - The general strategy of these tests (for interface levels 1 and 2) is - to create a dummy FLAC file with a known set of initial metadata - blocks, then keep a mirror locally of what we expect the metadata to be - after each operation. Then testing becomes a simple matter of running - a FLAC::Decoder::File over the dummy file after each operation, comparing - the decoded metadata to what's in our local copy. If there are any - differences in the metadata, or the actual audio data is corrupted, we - will catch it while decoding. -******************************************************************************/ - -class OurFileDecoder: public FLAC::Decoder::File { -public: - inline OurFileDecoder(bool ignore_metadata): ignore_metadata_(ignore_metadata), error_occurred_(false) { } - - bool ignore_metadata_; - bool error_occurred_; -protected: - ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]); - void metadata_callback(const ::FLAC__StreamMetadata *metadata); - void error_callback(::FLAC__StreamDecoderErrorStatus status); -}; - -struct OurMetadata { - FLAC::Metadata::Prototype *blocks[64]; - uint32_t num_blocks; -}; - -/* our copy of the metadata in flacfilename() */ -static OurMetadata our_metadata_; - -/* the current block number that corresponds to the position of the iterator we are testing */ -static uint32_t mc_our_block_number_ = 0; - -static const char *flacfilename(bool is_ogg) -{ - return is_ogg? "metadata.oga" : "metadata.flac"; -} - -static bool die_(const char *msg) -{ - printf("ERROR: %s\n", msg); - return false; -} - -static bool die_c_(const char *msg, FLAC::Metadata::Chain::Status status) -{ - printf("ERROR: %s\n", msg); - printf(" status=%u (%s)\n", (uint32_t)((::FLAC__Metadata_ChainStatus)status), status.as_cstring()); - return false; -} - -static bool die_ss_(const char *msg, FLAC::Metadata::SimpleIterator &iterator) -{ - const FLAC::Metadata::SimpleIterator::Status status = iterator.status(); - printf("ERROR: %s\n", msg); - printf(" status=%u (%s)\n", (uint32_t)((::FLAC__Metadata_SimpleIteratorStatus)status), status.as_cstring()); - return false; -} - -static void *malloc_or_die_(size_t size) -{ - void *x = malloc(size); - if(0 == x) { - fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (uint32_t)size); - exit(1); - } - return x; -} - -static char *strdup_or_die_(const char *s) -{ - char *x = strdup(s); - if(0 == x) { - fprintf(stderr, "ERROR: out of memory copying string \"%s\"\n", s); - exit(1); - } - return x; -} - -/* functions for working with our metadata copy */ - -static bool replace_in_our_metadata_(FLAC::Metadata::Prototype *block, uint32_t position, bool copy) -{ - uint32_t i; - FLAC::Metadata::Prototype *obj = block; - FLAC__ASSERT(position < our_metadata_.num_blocks); - if(copy) { - if(0 == (obj = FLAC::Metadata::clone(block))) - return die_("during FLAC::Metadata::clone()"); - } - delete our_metadata_.blocks[position]; - our_metadata_.blocks[position] = obj; - - /* set the is_last flags */ - for(i = 0; i < our_metadata_.num_blocks - 1; i++) - our_metadata_.blocks[i]->set_is_last(false); - our_metadata_.blocks[i]->set_is_last(true); - - return true; -} - -static bool insert_to_our_metadata_(FLAC::Metadata::Prototype *block, uint32_t position, bool copy) -{ - uint32_t i; - FLAC::Metadata::Prototype *obj = block; - if(copy) { - if(0 == (obj = FLAC::Metadata::clone(block))) - return die_("during FLAC::Metadata::clone()"); - } - if(position > our_metadata_.num_blocks) { - position = our_metadata_.num_blocks; - } - else { - for(i = our_metadata_.num_blocks; i > position; i--) - our_metadata_.blocks[i] = our_metadata_.blocks[i-1]; - } - our_metadata_.blocks[position] = obj; - our_metadata_.num_blocks++; - - /* set the is_last flags */ - for(i = 0; i < our_metadata_.num_blocks - 1; i++) - our_metadata_.blocks[i]->set_is_last(false); - our_metadata_.blocks[i]->set_is_last(true); - - return true; -} - -static void delete_from_our_metadata_(uint32_t position) -{ - uint32_t i; - FLAC__ASSERT(position < our_metadata_.num_blocks); - delete our_metadata_.blocks[position]; - for(i = position; i < our_metadata_.num_blocks - 1; i++) - our_metadata_.blocks[i] = our_metadata_.blocks[i+1]; - our_metadata_.num_blocks--; - - /* set the is_last flags */ - if(our_metadata_.num_blocks > 0) { - for(i = 0; i < our_metadata_.num_blocks - 1; i++) - our_metadata_.blocks[i]->set_is_last(false); - our_metadata_.blocks[i]->set_is_last(true); - } -} - -void add_to_padding_length_(uint32_t indx, int delta) -{ - FLAC::Metadata::Padding *padding = dynamic_cast(our_metadata_.blocks[indx]); - FLAC__ASSERT(0 != padding); - padding->set_length((uint32_t)((int)padding->get_length() + delta)); -} - -/* - * This wad of functions supports filename- and callback-based chain reading/writing. - * Everything up to set_file_stats_() is copied from libFLAC/metadata_iterators.c - */ -bool open_tempfile_(const char *filename, FILE **tempfile, char **tempfilename) -{ - static const char *tempfile_suffix = ".metadata_edit"; - size_t destlen = strlen(filename) + strlen(tempfile_suffix) + 1; - - *tempfilename = (char*)malloc(destlen); - if (*tempfilename == 0) - return false; - flac_snprintf(*tempfilename, destlen, "%s%s", filename, tempfile_suffix); - - *tempfile = flac_fopen(*tempfilename, "wb"); - if (*tempfile == 0) - return false; - - return true; -} - -void cleanup_tempfile_(FILE **tempfile, char **tempfilename) -{ - if (*tempfile != 0) { - (void)fclose(*tempfile); - *tempfile = 0; - } - - if (*tempfilename != 0) { - (void)flac_unlink(*tempfilename); - free(*tempfilename); - *tempfilename = 0; - } -} - -bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != tempfile); - FLAC__ASSERT(0 != tempfilename); - FLAC__ASSERT(0 != *tempfilename); - - if(0 != *tempfile) { - (void)fclose(*tempfile); - *tempfile = 0; - } - -#if defined _MSC_VER || defined __MINGW32__ || defined __EMX__ - /* on some flavors of windows, flac_rename() will fail if the destination already exists */ - if(flac_unlink(filename) < 0) { - cleanup_tempfile_(tempfile, tempfilename); - return false; - } -#endif - - if(0 != flac_rename(*tempfilename, filename)) { - cleanup_tempfile_(tempfile, tempfilename); - return false; - } - - cleanup_tempfile_(tempfile, tempfilename); - - return true; -} - -bool get_file_stats_(const char *filename, struct flac_stat_s *stats) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != stats); - return (0 == flac_stat(filename, stats)); -} - -void set_file_stats_(const char *filename, struct flac_stat_s *stats) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != stats); - -#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) && !defined(_WIN32) - struct timespec srctime[2] = {}; - srctime[0].tv_sec = stats->st_atime; - srctime[1].tv_sec = stats->st_mtime; -#else - struct utimbuf srctime; - srctime.actime = stats->st_atime; - srctime.modtime = stats->st_mtime; -#endif - (void)flac_chmod(filename, stats->st_mode); - (void)flac_utime(filename, &srctime); -#if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__ - FLAC_CHECK_RETURN(chown(filename, stats->st_uid, (gid_t)(-1))); - FLAC_CHECK_RETURN(chown(filename, (uid_t)(-1), stats->st_gid)); -#endif -} - -#ifdef FLAC__VALGRIND_TESTING -static size_t chain_write_cb_(const void *ptr, size_t size, size_t nmemb, ::FLAC__IOHandle handle) -{ - FILE *stream = (FILE*)handle; - size_t ret = fwrite(ptr, size, nmemb, stream); - if(!ferror(stream)) - fflush(stream); - return ret; -} -#endif - -static int chain_seek_cb_(::FLAC__IOHandle handle, FLAC__int64 offset, int whence) -{ - FLAC__off_t o = (FLAC__off_t)offset; - FLAC__ASSERT(offset == o); - return fseeko((FILE*)handle, o, whence); -} - -static FLAC__int64 chain_tell_cb_(::FLAC__IOHandle handle) -{ - return ftello((FILE*)handle); -} - -static int chain_eof_cb_(::FLAC__IOHandle handle) -{ - return feof((FILE*)handle); -} - -static bool write_chain_(FLAC::Metadata::Chain &chain, bool use_padding, bool preserve_file_stats, bool filename_based, const char *filename) -{ - if(filename_based) - return chain.write(use_padding, preserve_file_stats); - else { - ::FLAC__IOCallbacks callbacks; - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read = (::FLAC__IOCallback_Read)fread; -#ifdef FLAC__VALGRIND_TESTING - callbacks.write = chain_write_cb_; -#else - callbacks.write = (::FLAC__IOCallback_Write)fwrite; -#endif - callbacks.seek = chain_seek_cb_; - callbacks.eof = chain_eof_cb_; - - if(chain.check_if_tempfile_needed(use_padding)) { - struct flac_stat_s stats; - FILE *file, *tempfile; - char *tempfilename; - if(preserve_file_stats) { - if(!get_file_stats_(filename, &stats)) - return false; - } - if(0 == (file = flac_fopen(filename, "rb"))) - return false; /*@@@@ chain status still says OK though */ - if(!open_tempfile_(filename, &tempfile, &tempfilename)) { - fclose(file); - cleanup_tempfile_(&tempfile, &tempfilename); - return false; /*@@@@ chain status still says OK though */ - } - if(!chain.write(use_padding, (::FLAC__IOHandle)file, callbacks, (::FLAC__IOHandle)tempfile, callbacks)) { - fclose(file); - fclose(tempfile); - return false; - } - fclose(file); - fclose(tempfile); - file = tempfile = 0; - if(!transport_tempfile_(filename, &tempfile, &tempfilename)) - return false; - if(preserve_file_stats) - set_file_stats_(filename, &stats); - } - else { - FILE *file = flac_fopen(filename, "r+b"); - if(0 == file) - return false; /*@@@@ chain status still says OK though */ - if(!chain.write(use_padding, (::FLAC__IOHandle)file, callbacks)) { - fclose(file); - return false; - } - fclose(file); - } - } - - return true; -} - -static bool read_chain_(FLAC::Metadata::Chain &chain, const char *filename, bool filename_based, bool is_ogg) -{ - if(filename_based) - return chain.read(filename, is_ogg); - else { - ::FLAC__IOCallbacks callbacks; - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read = (::FLAC__IOCallback_Read)fread; - callbacks.seek = chain_seek_cb_; - callbacks.tell = chain_tell_cb_; - - { - bool ret; - FILE *file = flac_fopen(filename, "rb"); - if(0 == file) - return false; /*@@@@ chain status still says OK though */ - ret = chain.read((::FLAC__IOHandle)file, callbacks, is_ogg); - fclose(file); - return ret; - } - } -} - -/* function for comparing our metadata to a FLAC::Metadata::Chain */ - -static bool compare_chain_(FLAC::Metadata::Chain &chain, uint32_t current_position, FLAC::Metadata::Prototype *current_block) -{ - uint32_t i; - FLAC::Metadata::Iterator iterator; - bool next_ok = true; - - printf("\tcomparing chain... "); - fflush(stdout); - - if(!iterator.is_valid()) - return die_("allocating memory for iterator"); - - iterator.init(chain); - - i = 0; - do { - FLAC::Metadata::Prototype *block; - - printf("%u... ", i); - fflush(stdout); - - if(0 == (block = iterator.get_block())) - return die_("getting block from iterator"); - - if(*block != *our_metadata_.blocks[i]) - return die_("metadata block mismatch"); - - delete block; - i++; - next_ok = iterator.next(); - } while(i < our_metadata_.num_blocks && next_ok); - - if(next_ok) - return die_("chain has more blocks than expected"); - - if(i < our_metadata_.num_blocks) - return die_("short block count in chain"); - - if(0 != current_block) { - printf("CURRENT_POSITION... "); - fflush(stdout); - - if(*current_block != *our_metadata_.blocks[current_position]) - return die_("metadata block mismatch"); - } - - printf("PASSED\n"); - - return true; -} - -::FLAC__StreamDecoderWriteStatus OurFileDecoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) -{ - (void)buffer; - - if( - (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER && frame->header.number.frame_number == 0) || - (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER && frame->header.number.sample_number == 0) - ) { - printf("content... "); - fflush(stdout); - } - - return ::FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void OurFileDecoder::metadata_callback(const ::FLAC__StreamMetadata *metadata) -{ - /* don't bother checking if we've already hit an error */ - if(error_occurred_) - return; - - printf("%u... ", mc_our_block_number_); - fflush(stdout); - - if(!ignore_metadata_) { - if(mc_our_block_number_ >= our_metadata_.num_blocks) { - (void)die_("got more metadata blocks than expected"); - error_occurred_ = true; - } - else { - if(*our_metadata_.blocks[mc_our_block_number_] != metadata) { - (void)die_("metadata block mismatch"); - error_occurred_ = true; - } - } - } - - mc_our_block_number_++; -} - -void OurFileDecoder::error_callback(::FLAC__StreamDecoderErrorStatus status) -{ - error_occurred_ = true; - printf("ERROR: got error callback, status = %s (%u)\n", FLAC__StreamDecoderErrorStatusString[status], (uint32_t)status); -} - -static bool generate_file_(bool include_extras, bool is_ogg) -{ - ::FLAC__StreamMetadata streaminfo, vorbiscomment, *cuesheet, picture, padding; - ::FLAC__StreamMetadata *metadata[4]; - uint32_t i = 0, n = 0; - - printf("generating %sFLAC file for test\n", is_ogg? "Ogg " : ""); - - while(our_metadata_.num_blocks > 0) - delete_from_our_metadata_(0); - - streaminfo.is_last = false; - streaminfo.type = ::FLAC__METADATA_TYPE_STREAMINFO; - streaminfo.length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; - streaminfo.data.stream_info.min_blocksize = 576; - streaminfo.data.stream_info.max_blocksize = 576; - streaminfo.data.stream_info.min_framesize = 0; - streaminfo.data.stream_info.max_framesize = 0; - streaminfo.data.stream_info.sample_rate = 44100; - streaminfo.data.stream_info.channels = 1; - streaminfo.data.stream_info.bits_per_sample = 8; - streaminfo.data.stream_info.total_samples = 0; - memset(streaminfo.data.stream_info.md5sum, 0, 16); - - { - const uint32_t vendor_string_length = (uint32_t)strlen(FLAC__VENDOR_STRING); - vorbiscomment.is_last = false; - vorbiscomment.type = ::FLAC__METADATA_TYPE_VORBIS_COMMENT; - vorbiscomment.length = (4 + vendor_string_length) + 4; - vorbiscomment.data.vorbis_comment.vendor_string.length = vendor_string_length; - vorbiscomment.data.vorbis_comment.vendor_string.entry = (FLAC__byte*)malloc_or_die_(vendor_string_length+1); - memcpy(vorbiscomment.data.vorbis_comment.vendor_string.entry, FLAC__VENDOR_STRING, vendor_string_length+1); - vorbiscomment.data.vorbis_comment.num_comments = 0; - vorbiscomment.data.vorbis_comment.comments = 0; - } - - { - if (0 == (cuesheet = ::FLAC__metadata_object_new(::FLAC__METADATA_TYPE_CUESHEET))) - return die_("priming our metadata"); - cuesheet->is_last = false; - safe_strncpy(cuesheet->data.cue_sheet.media_catalog_number, "bogo-MCN", sizeof(cuesheet->data.cue_sheet.media_catalog_number)); - cuesheet->data.cue_sheet.lead_in = 123; - cuesheet->data.cue_sheet.is_cd = false; - if (!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, 0)) - return die_("priming our metadata"); - cuesheet->data.cue_sheet.tracks[0].number = 1; - if (!FLAC__metadata_object_cuesheet_track_insert_blank_index(cuesheet, 0, 0)) - return die_("priming our metadata"); - } - - { - picture.is_last = false; - picture.type = ::FLAC__METADATA_TYPE_PICTURE; - picture.length = - ( - FLAC__STREAM_METADATA_PICTURE_TYPE_LEN + - FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN + /* will add the length for the string later */ - FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN + /* will add the length for the string later */ - FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN + - FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN + - FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN + - FLAC__STREAM_METADATA_PICTURE_COLORS_LEN + - FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN /* will add the length for the data later */ - ) / 8 - ; - picture.data.picture.type = ::FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER; - picture.data.picture.mime_type = strdup_or_die_("image/jpeg"); - picture.length += strlen(picture.data.picture.mime_type); - picture.data.picture.description = (FLAC__byte*)strdup_or_die_("desc"); - picture.length += strlen((const char *)picture.data.picture.description); - picture.data.picture.width = 300; - picture.data.picture.height = 300; - picture.data.picture.depth = 24; - picture.data.picture.colors = 0; - picture.data.picture.data = (FLAC__byte*)strdup_or_die_("SOMEJPEGDATA"); - picture.data.picture.data_length = strlen((const char *)picture.data.picture.data); - picture.length += picture.data.picture.data_length; - } - - padding.is_last = true; - padding.type = ::FLAC__METADATA_TYPE_PADDING; - padding.length = 1234; - - metadata[n++] = &vorbiscomment; - if(include_extras) { - metadata[n++] = cuesheet; - metadata[n++] = &picture; - } - metadata[n++] = &padding; - - FLAC::Metadata::StreamInfo s(&streaminfo); - FLAC::Metadata::VorbisComment v(&vorbiscomment); - FLAC::Metadata::CueSheet c(cuesheet, /*copy=*/false); - FLAC::Metadata::Picture pi(&picture); - FLAC::Metadata::Padding p(&padding); - if( - !insert_to_our_metadata_(&s, i++, /*copy=*/true) || - !insert_to_our_metadata_(&v, i++, /*copy=*/true) || - (include_extras && !insert_to_our_metadata_(&c, i++, /*copy=*/true)) || - (include_extras && !insert_to_our_metadata_(&pi, i++, /*copy=*/true)) || - !insert_to_our_metadata_(&p, i++, /*copy=*/true) - ) - return die_("priming our metadata"); - - if(!file_utils__generate_flacfile(is_ogg, flacfilename(is_ogg), 0, 512 * 1024, &streaminfo, metadata, n)) - return die_("creating the encoded file"); - - free(vorbiscomment.data.vorbis_comment.vendor_string.entry); - free(picture.data.picture.mime_type); - free(picture.data.picture.description); - free(picture.data.picture.data); - - return true; -} - -static bool test_file_(bool is_ogg, bool ignore_metadata) -{ - const char *filename = flacfilename(is_ogg); - OurFileDecoder decoder(ignore_metadata); - - mc_our_block_number_ = 0; - decoder.error_occurred_ = false; - - printf("\ttesting '%s'... ", filename); - fflush(stdout); - - if(!decoder.is_valid()) - return die_("couldn't allocate decoder instance"); - - decoder.set_md5_checking(true); - decoder.set_metadata_respond_all(); - if((is_ogg? decoder.init_ogg(filename) : decoder.init(filename)) != ::FLAC__STREAM_DECODER_INIT_STATUS_OK) { - (void)decoder.finish(); - return die_("initializing decoder\n"); - } - if(!decoder.process_until_end_of_stream()) { - (void)decoder.finish(); - return die_("decoding file\n"); - } - - (void)decoder.finish(); - - if(decoder.error_occurred_) - return false; - - if(mc_our_block_number_ != our_metadata_.num_blocks) - return die_("short metadata block count"); - - printf("PASSED\n"); - return true; -} - -static bool change_stats_(const char *filename, bool read_only) -{ - if(!grabbag__file_change_stats(filename, read_only)) - return die_("during grabbag__file_change_stats()"); - - return true; -} - -static bool remove_file_(const char *filename) -{ - while(our_metadata_.num_blocks > 0) - delete_from_our_metadata_(0); - - if(!grabbag__file_remove_file(filename)) - return die_("removing file"); - - return true; -} - -static bool test_level_0_() -{ - FLAC::Metadata::StreamInfo streaminfo; - - printf("\n\n++++++ testing level 0 interface\n"); - - if(!generate_file_(/*include_extras=*/true, /*is_ogg=*/false)) - return false; - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/true)) - return false; - - printf("testing FLAC::Metadata::get_streaminfo()... "); - - if(!FLAC::Metadata::get_streaminfo(flacfilename(/*is_ogg=*/false), streaminfo)) - return die_("during FLAC::Metadata::get_streaminfo()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(streaminfo.get_channels() != 1) - return die_("mismatch in streaminfo.get_channels()"); - if(streaminfo.get_bits_per_sample() != 8) - return die_("mismatch in streaminfo.get_bits_per_sample()"); - if(streaminfo.get_sample_rate() != 44100) - return die_("mismatch in streaminfo.get_sample_rate()"); - if(streaminfo.get_min_blocksize() != 576) - return die_("mismatch in streaminfo.get_min_blocksize()"); - if(streaminfo.get_max_blocksize() != 576) - return die_("mismatch in streaminfo.get_max_blocksize()"); - - printf("OK\n"); - - { - printf("testing FLAC::Metadata::get_tags(VorbisComment *&)... "); - - FLAC::Metadata::VorbisComment *tags = 0; - - if(!FLAC::Metadata::get_tags(flacfilename(/*is_ogg=*/false), tags)) - return die_("during FLAC::Metadata::get_tags()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(tags->get_num_comments() != 0) - return die_("mismatch in tags->get_num_comments()"); - - printf("OK\n"); - - delete tags; - } - - { - printf("testing FLAC::Metadata::get_tags(VorbisComment &)... "); - - FLAC::Metadata::VorbisComment tags; - - if(!FLAC::Metadata::get_tags(flacfilename(/*is_ogg=*/false), tags)) - return die_("during FLAC::Metadata::get_tags()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(tags.get_num_comments() != 0) - return die_("mismatch in tags.get_num_comments()"); - - printf("OK\n"); - } - - { - printf("testing FLAC::Metadata::get_cuesheet(CueSheet *&)... "); - - FLAC::Metadata::CueSheet *cuesheet = 0; - - if(!FLAC::Metadata::get_cuesheet(flacfilename(/*is_ogg=*/false), cuesheet)) - return die_("during FLAC::Metadata::get_cuesheet()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(cuesheet->get_lead_in() != 123) - return die_("mismatch in cuesheet->get_lead_in()"); - - printf("OK\n"); - - delete cuesheet; - } - - { - printf("testing FLAC::Metadata::get_cuesheet(CueSheet &)... "); - - FLAC::Metadata::CueSheet cuesheet; - - if(!FLAC::Metadata::get_cuesheet(flacfilename(/*is_ogg=*/false), cuesheet)) - return die_("during FLAC::Metadata::get_cuesheet()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(cuesheet.get_lead_in() != 123) - return die_("mismatch in cuesheet.get_lead_in()"); - - printf("OK\n"); - } - - { - printf("testing FLAC::Metadata::get_picture(Picture *&)... "); - - FLAC::Metadata::Picture *picture = 0; - - if(!FLAC::Metadata::get_picture(flacfilename(/*is_ogg=*/false), picture, /*type=*/(::FLAC__StreamMetadata_Picture_Type)(-1), /*mime_type=*/0, /*description=*/0, /*max_width=*/(uint32_t)(-1), /*max_height=*/(uint32_t)(-1), /*max_depth=*/(uint32_t)(-1), /*max_colors=*/(uint32_t)(-1))) - return die_("during FLAC::Metadata::get_picture()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(picture->get_type () != ::FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER) - return die_("mismatch in picture->get_type ()"); - - printf("OK\n"); - - delete picture; - } - - { - printf("testing FLAC::Metadata::get_picture(Picture &)... "); - - FLAC::Metadata::Picture picture; - - if(!FLAC::Metadata::get_picture(flacfilename(/*is_ogg=*/false), picture, /*type=*/(::FLAC__StreamMetadata_Picture_Type)(-1), /*mime_type=*/0, /*description=*/0, /*max_width=*/(uint32_t)(-1), /*max_height=*/(uint32_t)(-1), /*max_depth=*/(uint32_t)(-1), /*max_colors=*/(uint32_t)(-1))) - return die_("during FLAC::Metadata::get_picture()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(picture.get_type () != ::FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER) - return die_("mismatch in picture->get_type ()"); - - printf("OK\n"); - } - - if(!remove_file_(flacfilename(/*is_ogg=*/false))) - return false; - - return true; -} - -static bool test_level_1_() -{ - FLAC::Metadata::Prototype *block; - FLAC::Metadata::StreamInfo *streaminfo; - FLAC::Metadata::Padding *padding; - FLAC::Metadata::Application *app; - FLAC__byte data[1000]; - uint32_t our_current_position = 0; - - // initialize 'data' to avoid Valgrind errors - memset(data, 0, sizeof(data)); - - printf("\n\n++++++ testing level 1 interface\n"); - - /************************************************************/ - { - printf("simple iterator on read-only file\n"); - - if(!generate_file_(/*include_extras=*/false, /*is_ogg=*/false)) - return false; - - if(!change_stats_(flacfilename(/*is_ogg=*/false), /*read_only=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/true)) - return false; - - FLAC::Metadata::SimpleIterator iterator; - - if(!iterator.is_valid()) - return die_("iterator.is_valid() returned false"); - - if(!iterator.init(flacfilename(/*is_ogg=*/false), /*read_only=*/false, /*preserve_file_stats=*/false)) - return die_("iterator.init() returned false"); - - printf("is writable = %u\n", (uint32_t)iterator.is_writable()); - if(iterator.is_writable()) - return die_("iterator claims file is writable when tester thinks it should not be; are you running as root?\n"); - - printf("iterate forwards\n"); - - if(iterator.get_block_type() != ::FLAC__METADATA_TYPE_STREAMINFO) - return die_("expected STREAMINFO type from iterator.get_block_type()"); - if(0 == (block = iterator.get_block())) - return die_("getting block 0"); - if(block->get_type() != ::FLAC__METADATA_TYPE_STREAMINFO) - return die_("expected STREAMINFO type"); - if(block->get_is_last()) - return die_("expected is_last to be false"); - if(block->get_length() != FLAC__STREAM_METADATA_STREAMINFO_LENGTH) - return die_("bad STREAMINFO length"); - /* check to see if some basic data matches (c.f. generate_file_()) */ - streaminfo = dynamic_cast(block); - FLAC__ASSERT(0 != streaminfo); - if(streaminfo->get_channels() != 1) - return die_("mismatch in channels"); - if(streaminfo->get_bits_per_sample() != 8) - return die_("mismatch in bits_per_sample"); - if(streaminfo->get_sample_rate() != 44100) - return die_("mismatch in sample_rate"); - if(streaminfo->get_min_blocksize() != 576) - return die_("mismatch in min_blocksize"); - if(streaminfo->get_max_blocksize() != 576) - return die_("mismatch in max_blocksize"); - // we will delete streaminfo a little later when we're really done with it... - - if(!iterator.next()) - return die_("forward iterator ended early"); - our_current_position++; - - if(!iterator.next()) - return die_("forward iterator ended early"); - our_current_position++; - - if(iterator.get_block_type() != ::FLAC__METADATA_TYPE_PADDING) - return die_("expected PADDING type from iterator.get_block_type()"); - if(0 == (block = iterator.get_block())) - return die_("getting block 1"); - if(block->get_type() != ::FLAC__METADATA_TYPE_PADDING) - return die_("expected PADDING type"); - if(!block->get_is_last()) - return die_("expected is_last to be true"); - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(block->get_length() != 1234) - return die_("bad PADDING length"); - delete block; - - if(iterator.next()) - return die_("forward iterator returned true but should have returned false"); - - printf("iterate backwards\n"); - if(!iterator.prev()) - return die_("reverse iterator ended early"); - if(!iterator.prev()) - return die_("reverse iterator ended early"); - if(iterator.prev()) - return die_("reverse iterator returned true but should have returned false"); - - printf("testing iterator.set_block() on read-only file...\n"); - - if(!iterator.set_block(streaminfo, false)) - printf("PASSED. iterator.set_block() returned false like it should\n"); - else - return die_("iterator.set_block() returned true but shouldn't have"); - delete streaminfo; - } - - /************************************************************/ - { - printf("simple iterator on writable file\n"); - - if(!change_stats_(flacfilename(/*is_ogg=*/false), /*read-only=*/false)) - return false; - - printf("creating APPLICATION block\n"); - - if(0 == (app = new FLAC::Metadata::Application())) - return die_("new FLAC::Metadata::Application()"); - app->set_id((const uint8_t *)"duh"); - - printf("creating PADDING block\n"); - - if(0 == (padding = new FLAC::Metadata::Padding())) { - delete app; - return die_("new FLAC::Metadata::Padding()"); - } - padding->set_length(20); - - FLAC::Metadata::SimpleIterator iterator; - - if(!iterator.is_valid()) { - delete app; - delete padding; - return die_("iterator.is_valid() returned false"); - } - - if(!iterator.init(flacfilename(/*is_ogg=*/false), /*read_only=*/false, /*preserve_file_stats=*/false)) { - delete app; - delete padding; - return die_("iterator.init() returned false"); - } - our_current_position = 0; - - printf("is writable = %u\n", (uint32_t)iterator.is_writable()); - - printf("[S]VP\ttry to write over STREAMINFO block...\n"); - if(!iterator.set_block(app, false)) - printf("\titerator.set_block() returned false like it should\n"); - else { - delete app; - delete padding; - return die_("iterator.set_block() returned true but shouldn't have"); - } - - if(iterator.status() != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT) - return die_("iterator.status() should have been FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT"); - - printf("[S]VP\tnext\n"); - if(!iterator.next()) { - delete app; - delete padding; - return die_("iterator ended early\n"); - } - our_current_position++; - - printf("S[V]P\tnext\n"); - if(!iterator.next()) { - delete app; - delete padding; - return die_("iterator ended early\n"); - } - our_current_position++; - - printf("SV[P]\tinsert PADDING after, don't expand into padding\n"); - padding->set_length(25); - if(!iterator.insert_block_after(padding, false)) - return die_ss_("iterator.insert_block_after(padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - printf("SVP[P]\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SV[P]P\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]PP\tinsert PADDING after, don't expand into padding\n"); - padding->set_length(30); - if(!iterator.insert_block_after(padding, false)) - return die_ss_("iterator.insert_block_after(padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[P]PP\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]PPP\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("[S]VPPP\tdelete (STREAMINFO block), must fail\n"); - if(iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false) should have returned false", iterator); - - if(iterator.status() != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT) - return die_("iterator.status() should have been FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT"); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("[S]VPPP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]PPP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]PP\tdelete (middle block), replace with padding\n"); - if(!iterator.delete_block(true)) - return die_ss_("iterator.delete_block(true)", iterator); - our_current_position--; - - printf("S[V]PPP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]PP\tdelete (middle block), don't replace with padding\n"); - if(!iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("S[V]PP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]P\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVP[P]\tdelete (last block), replace with padding\n"); - if(!iterator.delete_block(true)) - return die_ss_("iterator.delete_block(false)", iterator); - our_current_position--; - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[P]P\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVP[P]\tdelete (last block), don't replace with padding\n"); - if(!iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[P]\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]P\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("[S]VP\tset STREAMINFO (change sample rate)\n"); - FLAC__ASSERT(our_current_position == 0); - block = iterator.get_block(); - streaminfo = dynamic_cast(block); - FLAC__ASSERT(0 != streaminfo); - streaminfo->set_sample_rate(32000); - if(!replace_in_our_metadata_(block, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(block, false)) - return die_ss_("iterator.set_block(block, false)", iterator); - delete block; - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("[S]VP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]P\tinsert APPLICATION after, expand into padding of exceeding size\n"); - app->set_id((const uint8_t *)"euh"); /* twiddle the id so that our comparison doesn't miss transposition */ - if(!iterator.insert_block_after(app, true)) - return die_ss_("iterator.insert_block_after(app, true)", iterator); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return false; - add_to_padding_length_(our_current_position+1, -((int)(FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) + (int)app->get_length())); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]P\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVA[P]\tset APPLICATION, expand into padding of exceeding size\n"); - app->set_id((const uint8_t *)"fuh"); /* twiddle the id */ - if(!iterator.set_block(app, true)) - return die_ss_("iterator.set_block(app, true)", iterator); - if(!insert_to_our_metadata_(app, our_current_position, /*copy=*/true)) - return false; - add_to_padding_length_(our_current_position+1, -((int)(FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) + (int)app->get_length())); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVA[A]P\tset APPLICATION (grow), don't expand into padding\n"); - app->set_id((const uint8_t *)"guh"); /* twiddle the id */ - if(!app->set_data(data, sizeof(data), true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app, false)) - return die_ss_("iterator.set_block(app, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVA[A]P\tset APPLICATION (shrink), don't fill in with padding\n"); - app->set_id((const uint8_t *)"huh"); /* twiddle the id */ - if(!app->set_data(data, 12, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app, false)) - return die_ss_("iterator.set_block(app, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVA[A]P\tset APPLICATION (grow), expand into padding of exceeding size\n"); - app->set_id((const uint8_t *)"iuh"); /* twiddle the id */ - if(!app->set_data(data, sizeof(data), true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - add_to_padding_length_(our_current_position+1, -((int)sizeof(data) - 12)); - if(!iterator.set_block(app, true)) - return die_ss_("iterator.set_block(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVA[A]P\tset APPLICATION (shrink), fill in with padding\n"); - app->set_id((const uint8_t *)"juh"); /* twiddle the id */ - if(!app->set_data(data, 23, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!insert_to_our_metadata_(padding, our_current_position+1, /*copy=*/true)) - return die_("copying object"); - dynamic_cast(our_metadata_.blocks[our_current_position+1])->set_length(sizeof(data) - 23 - FLAC__STREAM_METADATA_HEADER_LENGTH); - if(!iterator.set_block(app, true)) - return die_ss_("iterator.set_block(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVA[A]PP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVAA[P]P\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVAAP[P]\tset PADDING (shrink), don't fill in with padding\n"); - padding->set_length(5); - if(!replace_in_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(padding, false)) - return die_ss_("iterator.set_block(padding, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVAAP[P]\tset APPLICATION (grow)\n"); - app->set_id((const uint8_t *)"kuh"); /* twiddle the id */ - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app, false)) - return die_ss_("iterator.set_block(app, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVAAP[A]\tset PADDING (equal)\n"); - padding->set_length(27); - if(!replace_in_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(padding, false)) - return die_ss_("iterator.set_block(padding, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVAAP[P]\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SVAA[P]P\tdelete (middle block), don't replace with padding\n"); - if(!iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVA[A]P\tdelete (middle block), don't replace with padding\n"); - if(!iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]P\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVA[P]\tinsert PADDING after\n"); - padding->set_length(5); - if(!iterator.insert_block_after(padding, false)) - return die_ss_("iterator.insert_block_after(padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVAP[P]\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SVA[P]P\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SV[A]PP\tset APPLICATION (grow), try to expand into padding which is too small\n"); - if(!app->set_data(data, 32, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app, true)) - return die_ss_("iterator.set_block(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]PP\tset APPLICATION (grow), try to expand into padding which is 'close' but still too small\n"); - if(!app->set_data(data, 60, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app, true)) - return die_ss_("iterator.set_block(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]PP\tset APPLICATION (grow), expand into padding which will leave 0-length pad\n"); - if(!app->set_data(data, 87, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - dynamic_cast(our_metadata_.blocks[our_current_position+1])->set_length(0); - if(!iterator.set_block(app, true)) - return die_ss_("iterator.set_block(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]PP\tset APPLICATION (grow), expand into padding which is exactly consumed\n"); - if(!app->set_data(data, 91, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - if(!iterator.set_block(app, true)) - return die_ss_("iterator.set_block(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]P\tset APPLICATION (grow), expand into padding which is exactly consumed\n"); - if(!app->set_data(data, 100, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - our_metadata_.blocks[our_current_position]->set_is_last(true); - if(!iterator.set_block(app, true)) - return die_ss_("iterator.set_block(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]\tset PADDING (equal size)\n"); - padding->set_length(app->get_length()); - if(!replace_in_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(padding, true)) - return die_ss_("iterator.set_block(padding, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[P]\tinsert PADDING after\n"); - if(!iterator.insert_block_after(padding, false)) - return die_ss_("iterator.insert_block_after(padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVP[P]\tinsert PADDING after\n"); - padding->set_length(5); - if(!iterator.insert_block_after(padding, false)) - return die_ss_("iterator.insert_block_after(padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SVPP[P]\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SVP[P]P\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SV[P]PP\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]PPP\tinsert APPLICATION after, try to expand into padding which is too small\n"); - if(!app->set_data(data, 101, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.insert_block_after(app, true)) - return die_ss_("iterator.insert_block_after(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]PPP\tdelete (middle block), don't replace with padding\n"); - if(!iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("S[V]PPP\tinsert APPLICATION after, try to expand into padding which is 'close' but still too small\n"); - if(!app->set_data(data, 97, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.insert_block_after(app, true)) - return die_ss_("iterator.insert_block_after(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]PPP\tdelete (middle block), don't replace with padding\n"); - if(!iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("S[V]PPP\tinsert APPLICATION after, expand into padding which is exactly consumed\n"); - if(!app->set_data(data, 100, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - if(!iterator.insert_block_after(app, true)) - return die_ss_("iterator.insert_block_after(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]PP\tdelete (middle block), don't replace with padding\n"); - if(!iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("S[V]PP\tinsert APPLICATION after, expand into padding which will leave 0-length pad\n"); - if(!app->set_data(data, 96, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - dynamic_cast(our_metadata_.blocks[our_current_position+1])->set_length(0); - if(!iterator.insert_block_after(app, true)) - return die_ss_("iterator.insert_block_after(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]PP\tdelete (middle block), don't replace with padding\n"); - if(!iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("S[V]PP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]P\tdelete (middle block), don't replace with padding\n"); - if(!iterator.delete_block(false)) - return die_ss_("iterator.delete_block(false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - - printf("S[V]P\tinsert APPLICATION after, expand into padding which is exactly consumed\n"); - if(!app->set_data(data, 1, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - if(!iterator.insert_block_after(app, true)) - return die_ss_("iterator.insert_block_after(app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, /*ignore_metadata=*/false)) - return false; - } - - delete app; - delete padding; - - if(!remove_file_(flacfilename(/*is_ogg=*/false))) - return false; - - return true; -} - -static bool test_level_2_(bool filename_based, bool is_ogg) -{ - FLAC::Metadata::Prototype *block; - FLAC::Metadata::StreamInfo *streaminfo; - FLAC::Metadata::Application *app; - FLAC::Metadata::Padding *padding; - FLAC__byte data[2000]; - uint32_t our_current_position; - - // initialize 'data' to avoid Valgrind errors - memset(data, 0, sizeof(data)); - - printf("\n\n++++++ testing level 2 interface (%s-based, %s FLAC)\n", filename_based? "filename":"callback", is_ogg? "Ogg":"native"); - - printf("generate read-only file\n"); - - if(!generate_file_(/*include_extras=*/false, is_ogg)) - return false; - - if(!change_stats_(flacfilename(is_ogg), /*read_only=*/true)) - return false; - - printf("create chain\n"); - FLAC::Metadata::Chain chain; - if(!chain.is_valid()) - return die_("allocating memory for chain"); - - printf("read chain\n"); - - if(!read_chain_(chain, flacfilename(is_ogg), filename_based, is_ogg)) - return die_c_("reading chain", chain.status()); - - printf("[S]VP\ttest initial metadata\n"); - - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - if(is_ogg) - goto end; - - printf("switch file to read-write\n"); - - if(!change_stats_(flacfilename(is_ogg), /*read-only=*/false)) - return false; - - printf("create iterator\n"); - { - FLAC::Metadata::Iterator iterator; - if(!iterator.is_valid()) - return die_("allocating memory for iterator"); - - our_current_position = 0; - - iterator.init(chain); - - if(0 == (block = iterator.get_block())) - return die_("getting block from iterator"); - - FLAC__ASSERT(block->get_type() == FLAC__METADATA_TYPE_STREAMINFO); - - printf("[S]VP\tmodify STREAMINFO, write\n"); - - streaminfo = dynamic_cast(block); - FLAC__ASSERT(0 != streaminfo); - streaminfo->set_sample_rate(32000); - if(!replace_in_our_metadata_(block, our_current_position, /*copy=*/true)) - return die_("copying object"); - delete block; - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/true, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(false, true)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("[S]VP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]P\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]\treplace PADDING with identical-size APPLICATION\n"); - if(0 == (block = iterator.get_block())) - return die_("getting block from iterator"); - if(0 == (app = new FLAC::Metadata::Application())) - return die_("new FLAC::Metadata::Application()"); - app->set_id((const uint8_t *)"duh"); - if(!app->set_data(data, block->get_length()-(FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), true)) - return die_("setting APPLICATION data"); - delete block; - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(false, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]\tshrink APPLICATION, don't use padding\n"); - if(0 == (app = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("copying object"); - if(!app->set_data(data, 26, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(false, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]\tgrow APPLICATION, don't use padding\n"); - if(0 == (app = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("copying object"); - if(!app->set_data(data, 28, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(false, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]\tgrow APPLICATION, use padding, but last block is not padding\n"); - if(0 == (app = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("copying object"); - if(!app->set_data(data, 36, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(false, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]\tshrink APPLICATION, use padding, last block is not padding, but delta is too small for new PADDING block\n"); - if(0 == (app = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("copying object"); - if(!app->set_data(data, 33, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(true, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]\tshrink APPLICATION, use padding, last block is not padding, delta is enough for new PADDING block\n"); - if(0 == (padding = new FLAC::Metadata::Padding())) - return die_("creating PADDING block"); - if(0 == (app = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("copying object"); - if(!app->set_data(data, 29, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - padding->set_length(0); - if(!insert_to_our_metadata_(padding, our_current_position+1, /*copy=*/false)) - return die_("internal error"); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(true, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]P\tshrink APPLICATION, use padding, last block is padding\n"); - if(0 == (app = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("copying object"); - if(!app->set_data(data, 16, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - dynamic_cast(our_metadata_.blocks[our_current_position+1])->set_length(13); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(true, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]P\tgrow APPLICATION, use padding, last block is padding, but delta is too small\n"); - if(0 == (app = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("copying object"); - if(!app->set_data(data, 50, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(true, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]P\tgrow APPLICATION, use padding, last block is padding of exceeding size\n"); - if(0 == (app = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("copying object"); - if(!app->set_data(data, 56, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - add_to_padding_length_(our_current_position+1, -(56 - 50)); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(true, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]P\tgrow APPLICATION, use padding, last block is padding of exact size\n"); - if(0 == (app = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("copying object"); - if(!app->set_data(data, 67, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - if(!iterator.set_block(app)) - return die_c_("iterator.set_block(app)", chain.status()); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(true, false)", chain.status()); - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV[A]\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]A\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("[S]VA\tinsert PADDING before STREAMINFO (should fail)\n"); - if(0 == (padding = new FLAC::Metadata::Padding())) - return die_("creating PADDING block"); - padding->set_length(30); - if(!iterator.insert_block_before(padding)) - printf("\titerator.insert_block_before() returned false like it should\n"); - else - return die_("iterator.insert_block_before() should have returned false"); - - printf("[S]VA\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]A\tinsert PADDING after\n"); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!iterator.insert_block_after(padding)) - return die_("iterator.insert_block_after(padding)"); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - printf("SV[P]A\tinsert PADDING before\n"); - if(0 == (padding = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("creating PADDING block"); - padding->set_length(17); - if(!insert_to_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!iterator.insert_block_before(padding)) - return die_("iterator.insert_block_before(padding)"); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - printf("SV[P]PA\tinsert PADDING before\n"); - if(0 == (padding = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[our_current_position])))) - return die_("creating PADDING block"); - padding->set_length(0); - if(!insert_to_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!iterator.insert_block_before(padding)) - return die_("iterator.insert_block_before(padding)"); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - printf("SV[P]PPA\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVP[P]PA\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVPP[P]A\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVPPP[A]\tinsert PADDING after\n"); - if(0 == (padding = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[2])))) - return die_("creating PADDING block"); - padding->set_length(57); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!iterator.insert_block_after(padding)) - return die_("iterator.insert_block_after(padding)"); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - printf("SVPPPA[P]\tinsert PADDING before\n"); - if(0 == (padding = dynamic_cast(FLAC::Metadata::clone(our_metadata_.blocks[2])))) - return die_("creating PADDING block"); - padding->set_length(99); - if(!insert_to_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!iterator.insert_block_before(padding)) - return die_("iterator.insert_block_before(padding)"); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - } - our_current_position = 0; - - printf("SVPPPAPP\tmerge padding\n"); - chain.merge_padding(); - add_to_padding_length_(2, FLAC__STREAM_METADATA_HEADER_LENGTH + our_metadata_.blocks[3]->get_length()); - add_to_padding_length_(2, FLAC__STREAM_METADATA_HEADER_LENGTH + our_metadata_.blocks[4]->get_length()); - add_to_padding_length_(6, FLAC__STREAM_METADATA_HEADER_LENGTH + our_metadata_.blocks[7]->get_length()); - delete_from_our_metadata_(7); - delete_from_our_metadata_(4); - delete_from_our_metadata_(3); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(true, false)", chain.status()); - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SVPAP\tsort padding\n"); - chain.sort_padding(); - add_to_padding_length_(4, FLAC__STREAM_METADATA_HEADER_LENGTH + our_metadata_.blocks[2]->get_length()); - delete_from_our_metadata_(2); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(true, false)", chain.status()); - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("create iterator\n"); - { - FLAC::Metadata::Iterator iterator; - if(!iterator.is_valid()) - return die_("allocating memory for iterator"); - - our_current_position = 0; - - iterator.init(chain); - - printf("[S]VAP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]AP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[A]P\tdelete middle block, replace with padding\n"); - if(0 == (padding = new FLAC::Metadata::Padding())) - return die_("creating PADDING block"); - padding->set_length(71); - if(!replace_in_our_metadata_(padding, our_current_position--, /*copy=*/false)) - return die_("copying object"); - if(!iterator.delete_block(/*replace_with_padding=*/true)) - return die_c_("iterator.delete_block(true)", chain.status()); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - printf("S[V]PP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]P\tdelete middle block, don't replace with padding\n"); - delete_from_our_metadata_(our_current_position--); - if(!iterator.delete_block(/*replace_with_padding=*/false)) - return die_c_("iterator.delete_block(false)", chain.status()); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - printf("S[V]P\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]\tdelete last block, replace with padding\n"); - if(0 == (padding = new FLAC::Metadata::Padding())) - return die_("creating PADDING block"); - padding->set_length(219); - if(!replace_in_our_metadata_(padding, our_current_position--, /*copy=*/false)) - return die_("copying object"); - if(!iterator.delete_block(/*replace_with_padding=*/true)) - return die_c_("iterator.delete_block(true)", chain.status()); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - printf("S[V]P\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]\tdelete last block, don't replace with padding\n"); - delete_from_our_metadata_(our_current_position--); - if(!iterator.delete_block(/*replace_with_padding=*/false)) - return die_c_("iterator.delete_block(false)", chain.status()); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - printf("S[V]\tprev\n"); - if(!iterator.prev()) - return die_("iterator ended early\n"); - our_current_position--; - - printf("[S]V\tdelete STREAMINFO block, should fail\n"); - if(iterator.delete_block(/*replace_with_padding=*/false)) - return die_("iterator.delete_block() on STREAMINFO should have failed but didn't"); - - block = iterator.get_block(); - if(!compare_chain_(chain, our_current_position, block)) - return false; - delete block; - - } // delete iterator - our_current_position = 0; - - printf("SV\tmerge padding\n"); - chain.merge_padding(); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(false, false)", chain.status()); - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - - printf("SV\tsort padding\n"); - chain.sort_padding(); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during chain.write(false, false)", chain.status()); - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, /*ignore_metadata=*/false)) - return false; - -end: - if(!remove_file_(flacfilename(is_ogg))) - return false; - - return true; -} - -static bool test_level_2_misc_(bool is_ogg) -{ - ::FLAC__IOCallbacks callbacks; - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read = (::FLAC__IOCallback_Read)fread; -#ifdef FLAC__VALGRIND_TESTING - callbacks.write = chain_write_cb_; -#else - callbacks.write = (::FLAC__IOCallback_Write)fwrite; -#endif - callbacks.seek = chain_seek_cb_; - callbacks.tell = chain_tell_cb_; - callbacks.eof = chain_eof_cb_; - - printf("\n\n++++++ testing level 2 interface (mismatched read/write protections)\n"); - - printf("generate file\n"); - - if(!generate_file_(/*include_extras=*/false, is_ogg)) - return false; - - printf("create chain\n"); - FLAC::Metadata::Chain chain; - if(!chain.is_valid()) - return die_("allocating chain"); - - printf("read chain (filename-based)\n"); - - if(!chain.read(flacfilename(is_ogg))) - return die_c_("reading chain", chain.status()); - - printf("write chain with wrong method Chain::write(with callbacks)\n"); - { - if(chain.write(/*use_padding=*/false, 0, callbacks)) - return die_c_("mismatched write should have failed", chain.status()); - if(chain.status() != ::FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH", chain.status()); - printf(" OK: Chain::write(with callbacks) returned false,FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH like it should\n"); - } - - printf("read chain (filename-based)\n"); - - if(!chain.read(flacfilename(is_ogg))) - return die_c_("reading chain", chain.status()); - - printf("write chain with wrong method Chain::write(with callbacks and tempfile)\n"); - { - if(chain.write(/*use_padding=*/false, 0, callbacks, 0, callbacks)) - return die_c_("mismatched write should have failed", chain.status()); - if(chain.status() != ::FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH", chain.status()); - printf(" OK: Chain::write(with callbacks and tempfile) returned false,FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH like it should\n"); - } - - printf("read chain (callback-based)\n"); - { - FILE *file = flac_fopen(flacfilename(is_ogg), "rb"); - if(0 == file) - return die_("opening file"); - if(!chain.read((::FLAC__IOHandle)file, callbacks)) { - fclose(file); - return die_c_("reading chain", chain.status()); - } - fclose(file); - } - - printf("write chain with wrong method write()\n"); - { - if(chain.write(/*use_padding=*/false, /*preserve_file_stats=*/false)) - return die_c_("mismatched write should have failed", chain.status()); - if(chain.status() != ::FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH", chain.status()); - printf(" OK: write() returned false,FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH like it should\n"); - } - - printf("read chain (callback-based)\n"); - { - FILE *file = flac_fopen(flacfilename(is_ogg), "rb"); - if(0 == file) - return die_("opening file"); - if(!chain.read((::FLAC__IOHandle)file, callbacks)) { - fclose(file); - return die_c_("reading chain", chain.status()); - } - fclose(file); - } - - printf("testing Chain::check_if_tempfile_needed()... "); - - if(!chain.check_if_tempfile_needed(/*use_padding=*/false)) - printf("OK: Chain::check_if_tempfile_needed() returned false like it should\n"); - else - return die_("Chain::check_if_tempfile_needed() returned true but shouldn't have"); - - printf("write chain with wrong method Chain::write(with callbacks and tempfile)\n"); - { - if(chain.write(/*use_padding=*/false, 0, callbacks, 0, callbacks)) - return die_c_("mismatched write should have failed", chain.status()); - if(chain.status() != ::FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL", chain.status()); - printf(" OK: Chain::write(with callbacks and tempfile) returned false,FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL like it should\n"); - } - - printf("read chain (callback-based)\n"); - { - FILE *file = flac_fopen(flacfilename(is_ogg), "rb"); - if(0 == file) - return die_("opening file"); - if(!chain.read((::FLAC__IOHandle)file, callbacks)) { - fclose(file); - return die_c_("reading chain", chain.status()); - } - fclose(file); - } - - printf("create iterator\n"); - { - FLAC::Metadata::Iterator iterator; - if(!iterator.is_valid()) - return die_("allocating memory for iterator"); - - iterator.init(chain); - - printf("[S]VP\tnext\n"); - if(!iterator.next()) - return die_("iterator ended early\n"); - - printf("S[V]P\tdelete VORBIS_COMMENT, write\n"); - if(!iterator.delete_block(/*replace_with_padding=*/false)) - return die_c_("block delete failed\n", chain.status()); - - printf("testing Chain::check_if_tempfile_needed()... "); - - if(chain.check_if_tempfile_needed(/*use_padding=*/false)) - printf("OK: Chain::check_if_tempfile_needed() returned true like it should\n"); - else - return die_("Chain::check_if_tempfile_needed() returned false but shouldn't have"); - - printf("write chain with wrong method Chain::write(with callbacks)\n"); - { - if(chain.write(/*use_padding=*/false, 0, callbacks)) - return die_c_("mismatched write should have failed", chain.status()); - if(chain.status() != ::FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL", chain.status()); - printf(" OK: Chain::write(with callbacks) returned false,FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL like it should\n"); - } - - } // delete iterator - - if(!remove_file_(flacfilename(is_ogg))) - return false; - - return true; -} - -bool test_metadata_file_manipulation() -{ - printf("\n+++ libFLAC++ unit test: metadata manipulation\n\n"); - - our_metadata_.num_blocks = 0; - - if(!test_level_0_()) - return false; - - if(!test_level_1_()) - return false; - - if(!test_level_2_(/*filename_based=*/true, /*is_ogg=*/false)) /* filename-based */ - return false; - if(!test_level_2_(/*filename_based=*/false, /*is_ogg=*/false)) /* callback-based */ - return false; - if(!test_level_2_misc_(/*is_ogg=*/false)) - return false; - - if(FLAC_API_SUPPORTS_OGG_FLAC) { - if(!test_level_2_(/*filename_based=*/true, /*is_ogg=*/true)) /* filename-based */ - return false; - if(!test_level_2_(/*filename_based=*/false, /*is_ogg=*/true)) /* callback-based */ - return false; -#if 0 - /* when ogg flac write is supported, will have to add this: */ - if(!test_level_2_misc_(/*is_ogg=*/true)) - return false; -#endif - } - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC++/metadata_object.cpp b/Engine/lib/flac/src/test_libFLAC++/metadata_object.cpp deleted file mode 100644 index ab4cfbfee..000000000 --- a/Engine/lib/flac/src/test_libFLAC++/metadata_object.cpp +++ /dev/null @@ -1,2099 +0,0 @@ -/* test_libFLAC++ - Unit tester for libFLAC++ - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include /* for malloc() */ -#include /* for memcmp() */ -#include "FLAC/assert.h" -#include "FLAC++/metadata.h" -#include "share/safe_str.h" - -static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application_, vorbiscomment_, cuesheet_, picture_; - -static bool die_(const char *msg) -{ - printf("FAILED, %s\n", msg); - return false; -} - -static void *malloc_or_die_(size_t size) -{ - void *x = malloc(size); - if(0 == x) { - fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (uint32_t)size); - exit(1); - } - return x; -} - -static char *strdup_or_die_(const char *s) -{ - char *x = strdup(s); - if(0 == x) { - fprintf(stderr, "ERROR: out of memory copying string \"%s\"\n", s); - exit(1); - } - return x; -} - -static bool index_is_equal_(const ::FLAC__StreamMetadata_CueSheet_Index &indx, const ::FLAC__StreamMetadata_CueSheet_Index &indxcopy) -{ - if(indxcopy.offset != indx.offset) - return false; - if(indxcopy.number != indx.number) - return false; - return true; -} - -static bool track_is_equal_(const ::FLAC__StreamMetadata_CueSheet_Track *track, const ::FLAC__StreamMetadata_CueSheet_Track *trackcopy) -{ - uint32_t i; - - if(trackcopy->offset != track->offset) - return false; - if(trackcopy->number != track->number) - return false; - if(0 != strcmp(trackcopy->isrc, track->isrc)) - return false; - if(trackcopy->type != track->type) - return false; - if(trackcopy->pre_emphasis != track->pre_emphasis) - return false; - if(trackcopy->num_indices != track->num_indices) - return false; - if(0 == track->indices || 0 == trackcopy->indices) { - if(track->indices != trackcopy->indices) - return false; - } - else { - for(i = 0; i < track->num_indices; i++) { - if(!index_is_equal_(trackcopy->indices[i], track->indices[i])) - return false; - } - } - return true; -} - -static void init_metadata_blocks_() -{ - streaminfo_.is_last = false; - streaminfo_.type = ::FLAC__METADATA_TYPE_STREAMINFO; - streaminfo_.length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; - streaminfo_.data.stream_info.min_blocksize = 576; - streaminfo_.data.stream_info.max_blocksize = 576; - streaminfo_.data.stream_info.min_framesize = 0; - streaminfo_.data.stream_info.max_framesize = 0; - streaminfo_.data.stream_info.sample_rate = 44100; - streaminfo_.data.stream_info.channels = 1; - streaminfo_.data.stream_info.bits_per_sample = 8; - streaminfo_.data.stream_info.total_samples = 0; - memset(streaminfo_.data.stream_info.md5sum, 0, 16); - - padding_.is_last = false; - padding_.type = ::FLAC__METADATA_TYPE_PADDING; - padding_.length = 1234; - - seektable_.is_last = false; - seektable_.type = ::FLAC__METADATA_TYPE_SEEKTABLE; - seektable_.data.seek_table.num_points = 2; - seektable_.length = seektable_.data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; - seektable_.data.seek_table.points = (::FLAC__StreamMetadata_SeekPoint*)malloc_or_die_(seektable_.data.seek_table.num_points * sizeof(::FLAC__StreamMetadata_SeekPoint)); - seektable_.data.seek_table.points[0].sample_number = 0; - seektable_.data.seek_table.points[0].stream_offset = 0; - seektable_.data.seek_table.points[0].frame_samples = streaminfo_.data.stream_info.min_blocksize; - seektable_.data.seek_table.points[1].sample_number = ::FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - seektable_.data.seek_table.points[1].stream_offset = 1000; - seektable_.data.seek_table.points[1].frame_samples = streaminfo_.data.stream_info.min_blocksize; - - application_.is_last = false; - application_.type = ::FLAC__METADATA_TYPE_APPLICATION; - application_.length = 8; - memcpy(application_.data.application.id, "\xfe\xdc\xba\x98", 4); - application_.data.application.data = (FLAC__byte*)malloc_or_die_(4); - memcpy(application_.data.application.data, "\xf0\xe1\xd2\xc3", 4); - - vorbiscomment_.is_last = false; - vorbiscomment_.type = ::FLAC__METADATA_TYPE_VORBIS_COMMENT; - vorbiscomment_.length = (4 + 5) + 4 + (4 + 12) + (4 + 12); - vorbiscomment_.data.vorbis_comment.vendor_string.length = 5; - vorbiscomment_.data.vorbis_comment.vendor_string.entry = (FLAC__byte*)malloc_or_die_(5+1); - memcpy(vorbiscomment_.data.vorbis_comment.vendor_string.entry, "name0", 5+1); - vorbiscomment_.data.vorbis_comment.num_comments = 2; - vorbiscomment_.data.vorbis_comment.comments = (::FLAC__StreamMetadata_VorbisComment_Entry*)malloc_or_die_(vorbiscomment_.data.vorbis_comment.num_comments * sizeof(::FLAC__StreamMetadata_VorbisComment_Entry)); - vorbiscomment_.data.vorbis_comment.comments[0].length = 12; - vorbiscomment_.data.vorbis_comment.comments[0].entry = (FLAC__byte*)malloc_or_die_(12+1); - memcpy(vorbiscomment_.data.vorbis_comment.comments[0].entry, "name2=value2", 12+1); - vorbiscomment_.data.vorbis_comment.comments[1].length = 12; - vorbiscomment_.data.vorbis_comment.comments[1].entry = (FLAC__byte*)malloc_or_die_(12+1); - memcpy(vorbiscomment_.data.vorbis_comment.comments[1].entry, "name3=value3", 12+1); - - cuesheet_.is_last = false; - cuesheet_.type = ::FLAC__METADATA_TYPE_CUESHEET; - cuesheet_.length = - /* cuesheet guts */ - ( - FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN + - FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + - FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN - ) / 8 + - /* 2 tracks */ - 2 * ( - FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN - ) / 8 + - /* 3 index points */ - 3 * ( - FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN + - FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN - ) / 8 - ; - memset(cuesheet_.data.cue_sheet.media_catalog_number, 0, sizeof(cuesheet_.data.cue_sheet.media_catalog_number)); - cuesheet_.data.cue_sheet.media_catalog_number[0] = 'j'; - cuesheet_.data.cue_sheet.media_catalog_number[1] = 'C'; - cuesheet_.data.cue_sheet.lead_in = 159; - cuesheet_.data.cue_sheet.is_cd = true; - cuesheet_.data.cue_sheet.num_tracks = 2; - cuesheet_.data.cue_sheet.tracks = (FLAC__StreamMetadata_CueSheet_Track*)malloc_or_die_(cuesheet_.data.cue_sheet.num_tracks * sizeof(FLAC__StreamMetadata_CueSheet_Track)); - cuesheet_.data.cue_sheet.tracks[0].offset = 1; - cuesheet_.data.cue_sheet.tracks[0].number = 1; - memcpy(cuesheet_.data.cue_sheet.tracks[0].isrc, "ACBDE1234567", sizeof(cuesheet_.data.cue_sheet.tracks[0].isrc)); - cuesheet_.data.cue_sheet.tracks[0].type = 0; - cuesheet_.data.cue_sheet.tracks[0].pre_emphasis = 1; - cuesheet_.data.cue_sheet.tracks[0].num_indices = 2; - cuesheet_.data.cue_sheet.tracks[0].indices = (FLAC__StreamMetadata_CueSheet_Index*)malloc_or_die_(cuesheet_.data.cue_sheet.tracks[0].num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index)); - cuesheet_.data.cue_sheet.tracks[0].indices[0].offset = 0; - cuesheet_.data.cue_sheet.tracks[0].indices[0].number = 0; - cuesheet_.data.cue_sheet.tracks[0].indices[1].offset = 1234567890; - cuesheet_.data.cue_sheet.tracks[0].indices[1].number = 1; - cuesheet_.data.cue_sheet.tracks[1].offset = 2345678901u; - cuesheet_.data.cue_sheet.tracks[1].number = 2; - memcpy(cuesheet_.data.cue_sheet.tracks[1].isrc, "ACBDE7654321", sizeof(cuesheet_.data.cue_sheet.tracks[1].isrc)); - cuesheet_.data.cue_sheet.tracks[1].type = 1; - cuesheet_.data.cue_sheet.tracks[1].pre_emphasis = 0; - cuesheet_.data.cue_sheet.tracks[1].num_indices = 1; - cuesheet_.data.cue_sheet.tracks[1].indices = (FLAC__StreamMetadata_CueSheet_Index*)malloc_or_die_(cuesheet_.data.cue_sheet.tracks[1].num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index)); - cuesheet_.data.cue_sheet.tracks[1].indices[0].offset = 0; - cuesheet_.data.cue_sheet.tracks[1].indices[0].number = 1; - - picture_.is_last = true; - picture_.type = FLAC__METADATA_TYPE_PICTURE; - picture_.length = - ( - FLAC__STREAM_METADATA_PICTURE_TYPE_LEN + - FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN + /* will add the length for the string later */ - FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN + /* will add the length for the string later */ - FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN + - FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN + - FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN + - FLAC__STREAM_METADATA_PICTURE_COLORS_LEN + - FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN /* will add the length for the data later */ - ) / 8 - ; - picture_.data.picture.type = FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER; - picture_.data.picture.mime_type = strdup_or_die_("image/jpeg"); - picture_.length += strlen(picture_.data.picture.mime_type); - picture_.data.picture.description = (FLAC__byte*)strdup_or_die_("desc"); - picture_.length += strlen((const char *)picture_.data.picture.description); - picture_.data.picture.width = 300; - picture_.data.picture.height = 300; - picture_.data.picture.depth = 24; - picture_.data.picture.colors = 0; - picture_.data.picture.data = (FLAC__byte*)strdup_or_die_("SOMEJPEGDATA"); - picture_.data.picture.data_length = strlen((const char *)picture_.data.picture.data); - picture_.length += picture_.data.picture.data_length; -} - -static void free_metadata_blocks_() -{ - free(seektable_.data.seek_table.points); - free(application_.data.application.data); - free(vorbiscomment_.data.vorbis_comment.vendor_string.entry); - free(vorbiscomment_.data.vorbis_comment.comments[0].entry); - free(vorbiscomment_.data.vorbis_comment.comments[1].entry); - free(vorbiscomment_.data.vorbis_comment.comments); - free(cuesheet_.data.cue_sheet.tracks[0].indices); - free(cuesheet_.data.cue_sheet.tracks[1].indices); - free(cuesheet_.data.cue_sheet.tracks); - free(picture_.data.picture.mime_type); - free(picture_.data.picture.description); - free(picture_.data.picture.data); -} - -bool test_metadata_object_streaminfo() -{ - uint32_t expected_length; - - printf("testing class FLAC::Metadata::StreamInfo\n"); - - printf("testing StreamInfo::StreamInfo()... "); - FLAC::Metadata::StreamInfo block; - if(!block.is_valid()) - return die_("!block.is_valid()"); - expected_length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; - if(block.get_length() != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block.get_length()); - return false; - } - printf("OK\n"); - - printf("testing StreamInfo::StreamInfo(const StreamInfo &)... +\n"); - printf(" StreamInfo::operator!=(const StreamInfo &)... "); - { - FLAC::Metadata::StreamInfo blockcopy(block); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != block) - return die_("copy is not identical to original"); - printf("OK\n"); - - printf("testing StreamInfo::~StreamInfo()... "); - } - printf("OK\n"); - - printf("testing StreamInfo::StreamInfo(const ::FLAC__StreamMetadata &)... +\n"); - printf(" StreamInfo::operator!=(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::StreamInfo blockcopy(streaminfo_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != streaminfo_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing StreamInfo::StreamInfo(const ::FLAC__StreamMetadata *)... +\n"); - printf(" StreamInfo::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::StreamInfo blockcopy(&streaminfo_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != streaminfo_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing StreamInfo::StreamInfo(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" StreamInfo::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::StreamInfo blockcopy(&streaminfo_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != streaminfo_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing StreamInfo::StreamInfo(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" StreamInfo::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&streaminfo_); - FLAC::Metadata::StreamInfo blockcopy(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != streaminfo_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing StreamInfo::assign(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" StreamInfo::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::StreamInfo blockcopy; - blockcopy.assign(&streaminfo_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != streaminfo_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing StreamInfo::assign(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" StreamInfo::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&streaminfo_); - FLAC::Metadata::StreamInfo blockcopy; - blockcopy.assign(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != streaminfo_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing StreamInfo::operator=(const StreamInfo &)... +\n"); - printf(" StreamInfo::operator==(const StreamInfo &)... "); - { - FLAC::Metadata::StreamInfo blockcopy = block; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == block)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing StreamInfo::operator=(const ::FLAC__StreamMetadata &)... +\n"); - printf(" StreamInfo::operator==(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::StreamInfo blockcopy = streaminfo_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == streaminfo_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing StreamInfo::operator=(const ::FLAC__StreamMetadata *)... +\n"); - printf(" StreamInfo::operator==(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::StreamInfo blockcopy = &streaminfo_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == streaminfo_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing StreamInfo::set_min_blocksize()... "); - block.set_min_blocksize(streaminfo_.data.stream_info.min_blocksize); - printf("OK\n"); - - printf("testing StreamInfo::set_max_blocksize()... "); - block.set_max_blocksize(streaminfo_.data.stream_info.max_blocksize); - printf("OK\n"); - - printf("testing StreamInfo::set_min_framesize()... "); - block.set_min_framesize(streaminfo_.data.stream_info.min_framesize); - printf("OK\n"); - - printf("testing StreamInfo::set_max_framesize()... "); - block.set_max_framesize(streaminfo_.data.stream_info.max_framesize); - printf("OK\n"); - - printf("testing StreamInfo::set_sample_rate()... "); - block.set_sample_rate(streaminfo_.data.stream_info.sample_rate); - printf("OK\n"); - - printf("testing StreamInfo::set_channels()... "); - block.set_channels(streaminfo_.data.stream_info.channels); - printf("OK\n"); - - printf("testing StreamInfo::set_bits_per_sample()... "); - block.set_bits_per_sample(streaminfo_.data.stream_info.bits_per_sample); - printf("OK\n"); - - printf("testing StreamInfo::set_total_samples()... "); - block.set_total_samples(streaminfo_.data.stream_info.total_samples); - printf("OK\n"); - - printf("testing StreamInfo::set_md5sum()... "); - block.set_md5sum(streaminfo_.data.stream_info.md5sum); - printf("OK\n"); - - printf("testing StreamInfo::get_min_blocksize()... "); - if(block.get_min_blocksize() != streaminfo_.data.stream_info.min_blocksize) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing StreamInfo::get_max_blocksize()... "); - if(block.get_max_blocksize() != streaminfo_.data.stream_info.max_blocksize) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing StreamInfo::get_min_framesize()... "); - if(block.get_min_framesize() != streaminfo_.data.stream_info.min_framesize) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing StreamInfo::get_max_framesize()... "); - if(block.get_max_framesize() != streaminfo_.data.stream_info.max_framesize) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing StreamInfo::get_sample_rate()... "); - if(block.get_sample_rate() != streaminfo_.data.stream_info.sample_rate) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing StreamInfo::get_channels()... "); - if(block.get_channels() != streaminfo_.data.stream_info.channels) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing StreamInfo::get_bits_per_sample()... "); - if(block.get_bits_per_sample() != streaminfo_.data.stream_info.bits_per_sample) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing StreamInfo::get_total_samples()... "); - if(block.get_total_samples() != streaminfo_.data.stream_info.total_samples) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing StreamInfo::get_md5sum()... "); - if(0 != memcmp(block.get_md5sum(), streaminfo_.data.stream_info.md5sum, 16)) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing FLAC::Metadata::clone(const FLAC::Metadata::Prototype *)... "); - FLAC::Metadata::Prototype *clone_ = FLAC::Metadata::clone(&block); - if(0 == clone_) - return die_("returned NULL"); - if(0 == dynamic_cast(clone_)) - return die_("downcast is NULL"); - if(*dynamic_cast(clone_) != block) - return die_("clone is not identical"); - printf("OK\n"); - printf("testing StreamInfo::~StreamInfo()... "); - delete clone_; - printf("OK\n"); - - - printf("PASSED\n\n"); - return true; -} - -bool test_metadata_object_padding() -{ - uint32_t expected_length; - - printf("testing class FLAC::Metadata::Padding\n"); - - printf("testing Padding::Padding()... "); - FLAC::Metadata::Padding block; - if(!block.is_valid()) - return die_("!block.is_valid()"); - expected_length = 0; - if(block.get_length() != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block.get_length()); - return false; - } - printf("OK\n"); - - printf("testing Padding::Padding(const Padding &)... +\n"); - printf(" Padding::operator!=(const Padding &)... "); - { - FLAC::Metadata::Padding blockcopy(block); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != block) - return die_("copy is not identical to original"); - printf("OK\n"); - - printf("testing Padding::~Padding()... "); - } - printf("OK\n"); - - printf("testing Padding::Padding(const ::FLAC__StreamMetadata &)... +\n"); - printf(" Padding::operator!=(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::Padding blockcopy(padding_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != padding_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Padding::Padding(const ::FLAC__StreamMetadata *)... +\n"); - printf(" Padding::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Padding blockcopy(&padding_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != padding_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Padding::Padding(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" Padding::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Padding blockcopy(&padding_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != padding_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Padding::Padding(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" Padding::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&padding_); - FLAC::Metadata::Padding blockcopy(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != padding_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Padding::assign(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" Padding::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Padding blockcopy; - blockcopy.assign(&padding_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != padding_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Padding::assign(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" Padding::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&padding_); - FLAC::Metadata::Padding blockcopy; - blockcopy.assign(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != padding_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Padding::operator=(const Padding &)... +\n"); - printf(" Padding::operator==(const Padding &)... "); - { - FLAC::Metadata::Padding blockcopy = block; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == block)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Padding::operator=(const ::FLAC__StreamMetadata &)... +\n"); - printf(" Padding::operator==(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::Padding blockcopy = padding_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == padding_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Padding::operator=(const ::FLAC__StreamMetadata *)... +\n"); - printf(" Padding::operator==(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Padding blockcopy = &padding_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == padding_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Padding::set_length()... "); - block.set_length(padding_.length); - printf("OK\n"); - - printf("testing Prototype::get_length()... "); - if(block.get_length() != padding_.length) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing FLAC::Metadata::clone(const FLAC::Metadata::Prototype *)... "); - FLAC::Metadata::Prototype *clone_ = FLAC::Metadata::clone(&block); - if(0 == clone_) - return die_("returned NULL"); - if(0 == dynamic_cast(clone_)) - return die_("downcast is NULL"); - if(*dynamic_cast(clone_) != block) - return die_("clone is not identical"); - printf("OK\n"); - printf("testing Padding::~Padding()... "); - delete clone_; - printf("OK\n"); - - - printf("PASSED\n\n"); - return true; -} - -bool test_metadata_object_application() -{ - uint32_t expected_length; - - printf("testing class FLAC::Metadata::Application\n"); - - printf("testing Application::Application()... "); - FLAC::Metadata::Application block; - if(!block.is_valid()) - return die_("!block.is_valid()"); - expected_length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; - if(block.get_length() != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block.get_length()); - return false; - } - printf("OK\n"); - - printf("testing Application::Application(const Application &)... +\n"); - printf(" Application::operator!=(const Application &)... "); - { - FLAC::Metadata::Application blockcopy(block); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != block) - return die_("copy is not identical to original"); - printf("OK\n"); - - printf("testing Application::~Application()... "); - } - printf("OK\n"); - - printf("testing Application::Application(const ::FLAC__StreamMetadata &)... +\n"); - printf(" Application::operator!=(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::Application blockcopy(application_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != application_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Application::Application(const ::FLAC__StreamMetadata *)... +\n"); - printf(" Application::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Application blockcopy(&application_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != application_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Application::Application(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" Application::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Application blockcopy(&application_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != application_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Application::Application(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" Application::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&application_); - FLAC::Metadata::Application blockcopy(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != application_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Application::assign(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" Application::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Application blockcopy; - blockcopy.assign(&application_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != application_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Application::assign(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" Application::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&application_); - FLAC::Metadata::Application blockcopy; - blockcopy.assign(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != application_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Application::operator=(const Application &)... +\n"); - printf(" Application::operator==(const Application &)... "); - { - FLAC::Metadata::Application blockcopy = block; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == block)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Application::operator=(const ::FLAC__StreamMetadata &)... +\n"); - printf(" Application::operator==(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::Application blockcopy = application_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == application_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Application::operator=(const ::FLAC__StreamMetadata *)... +\n"); - printf(" Application::operator==(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Application blockcopy = &application_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == application_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Application::set_id()... "); - block.set_id(application_.data.application.id); - printf("OK\n"); - - printf("testing Application::set_data()... "); - block.set_data(application_.data.application.data, application_.length - sizeof(application_.data.application.id), /*copy=*/true); - printf("OK\n"); - - printf("testing Application::get_id()... "); - if(0 != memcmp(block.get_id(), application_.data.application.id, sizeof(application_.data.application.id))) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing Application::get_data()... "); - if(0 != memcmp(block.get_data(), application_.data.application.data, application_.length - sizeof(application_.data.application.id))) - return die_("value mismatch, doesn't match previously set value"); - printf("OK\n"); - - printf("testing FLAC::Metadata::clone(const FLAC::Metadata::Prototype *)... "); - FLAC::Metadata::Prototype *clone_ = FLAC::Metadata::clone(&block); - if(0 == clone_) - return die_("returned NULL"); - if(0 == dynamic_cast(clone_)) - return die_("downcast is NULL"); - if(*dynamic_cast(clone_) != block) - return die_("clone is not identical"); - printf("OK\n"); - printf("testing Application::~Application()... "); - delete clone_; - printf("OK\n"); - - - printf("PASSED\n\n"); - return true; -} - -bool test_metadata_object_seektable() -{ - uint32_t expected_length; - - printf("testing class FLAC::Metadata::SeekTable\n"); - - printf("testing SeekTable::SeekTable()... "); - FLAC::Metadata::SeekTable block; - if(!block.is_valid()) - return die_("!block.is_valid()"); - expected_length = 0; - if(block.get_length() != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block.get_length()); - return false; - } - printf("OK\n"); - - printf("testing SeekTable::SeekTable(const SeekTable &)... +\n"); - printf(" SeekTable::operator!=(const SeekTable &)... "); - { - FLAC::Metadata::SeekTable blockcopy(block); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != block) - return die_("copy is not identical to original"); - printf("OK\n"); - - printf("testing SeekTable::~SeekTable()... "); - } - printf("OK\n"); - - printf("testing SeekTable::SeekTable(const ::FLAC__StreamMetadata &)... +\n"); - printf(" SeekTable::operator!=(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::SeekTable blockcopy(seektable_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != seektable_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing SeekTable::SeekTable(const ::FLAC__StreamMetadata *)... +\n"); - printf(" SeekTable::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::SeekTable blockcopy(&seektable_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != seektable_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing SeekTable::SeekTable(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" SeekTable::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::SeekTable blockcopy(&seektable_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != seektable_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing SeekTable::SeekTable(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" SeekTable::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&seektable_); - FLAC::Metadata::SeekTable blockcopy(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != seektable_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing SeekTable::assign(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" SeekTable::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::SeekTable blockcopy; - blockcopy.assign(&seektable_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != seektable_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing SeekTable::assign(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" SeekTable::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&seektable_); - FLAC::Metadata::SeekTable blockcopy; - blockcopy.assign(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != seektable_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing SeekTable::operator=(const SeekTable &)... +\n"); - printf(" SeekTable::operator==(const SeekTable &)... "); - { - FLAC::Metadata::SeekTable blockcopy = block; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == block)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing SeekTable::operator=(const ::FLAC__StreamMetadata &)... +\n"); - printf(" SeekTable::operator==(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::SeekTable blockcopy = seektable_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == seektable_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing SeekTable::operator=(const ::FLAC__StreamMetadata *)... +\n"); - printf(" SeekTable::operator==(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::SeekTable blockcopy = &seektable_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == seektable_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing SeekTable::insert_point() x 3... "); - if(!block.insert_point(0, seektable_.data.seek_table.points[1])) - return die_("returned false"); - if(!block.insert_point(0, seektable_.data.seek_table.points[1])) - return die_("returned false"); - if(!block.insert_point(1, seektable_.data.seek_table.points[0])) - return die_("returned false"); - printf("OK\n"); - - printf("testing SeekTable::is_legal()... "); - if(block.is_legal()) - return die_("returned true"); - printf("OK\n"); - - printf("testing SeekTable::set_point()... "); - block.set_point(0, seektable_.data.seek_table.points[0]); - printf("OK\n"); - - printf("testing SeekTable::delete_point()... "); - if(!block.delete_point(0)) - return die_("returned false"); - printf("OK\n"); - - printf("testing SeekTable::is_legal()... "); - if(!block.is_legal()) - return die_("returned false"); - printf("OK\n"); - - printf("testing SeekTable::get_num_points()... "); - if(block.get_num_points() != seektable_.data.seek_table.num_points) - return die_("number mismatch"); - printf("OK\n"); - - printf("testing SeekTable::operator!=(const ::FLAC__StreamMetadata &)... "); - if(block != seektable_) - return die_("data mismatch"); - printf("OK\n"); - - printf("testing SeekTable::get_point()... "); - if( - block.get_point(1).sample_number != seektable_.data.seek_table.points[1].sample_number || - block.get_point(1).stream_offset != seektable_.data.seek_table.points[1].stream_offset || - block.get_point(1).frame_samples != seektable_.data.seek_table.points[1].frame_samples - ) - return die_("point mismatch"); - printf("OK\n"); - - printf("testing FLAC::Metadata::clone(const FLAC::Metadata::Prototype *)... "); - FLAC::Metadata::Prototype *clone_ = FLAC::Metadata::clone(&block); - if(0 == clone_) - return die_("returned NULL"); - if(0 == dynamic_cast(clone_)) - return die_("downcast is NULL"); - if(*dynamic_cast(clone_) != block) - return die_("clone is not identical"); - printf("OK\n"); - printf("testing SeekTable::~SeekTable()... "); - delete clone_; - printf("OK\n"); - - - printf("PASSED\n\n"); - return true; -} - -bool test_metadata_object_vorbiscomment() -{ - uint32_t expected_length; - - printf("testing class FLAC::Metadata::VorbisComment::Entry\n"); - - printf("testing Entry::Entry()... "); - { - FLAC::Metadata::VorbisComment::Entry entry1; - if(!entry1.is_valid()) - return die_("!is_valid()"); - printf("OK\n"); - - printf("testing Entry::~Entry()... "); - } - printf("OK\n"); - - printf("testing Entry::Entry(const char *field, uint32_t field_length)... "); - FLAC::Metadata::VorbisComment::Entry entry2("name2=value2", strlen("name2=value2")); - if(!entry2.is_valid()) - return die_("!is_valid()"); - printf("OK\n"); - - { - printf("testing Entry::Entry(const char *field)... "); - FLAC::Metadata::VorbisComment::Entry entry2z("name2=value2"); - if(!entry2z.is_valid()) - return die_("!is_valid()"); - if(strcmp(entry2.get_field(), entry2z.get_field())) - return die_("bad value"); - printf("OK\n"); - } - - printf("testing Entry::Entry(const char *field_name, const char *field_value, uint32_t field_value_length)... "); - FLAC::Metadata::VorbisComment::Entry entry3("name3", "value3", strlen("value3")); - if(!entry3.is_valid()) - return die_("!is_valid()"); - printf("OK\n"); - - { - printf("testing Entry::Entry(const char *field_name, const char *field_value)... "); - FLAC::Metadata::VorbisComment::Entry entry3z("name3", "value3"); - if(!entry3z.is_valid()) - return die_("!is_valid()"); - if(strcmp(entry3.get_field(), entry3z.get_field())) - return die_("bad value"); - printf("OK\n"); - } - - printf("testing Entry::Entry(const Entry &entry)... "); - { - FLAC::Metadata::VorbisComment::Entry entry2copy(entry2); - if(!entry2copy.is_valid()) - return die_("!is_valid()"); - printf("OK\n"); - - printf("testing Entry::~Entry()... "); - } - printf("OK\n"); - - printf("testing Entry::operator=(const Entry &entry)... "); - FLAC::Metadata::VorbisComment::Entry entry1 = entry2; - if(!entry2.is_valid()) - return die_("!is_valid()"); - printf("OK\n"); - - printf("testing Entry::get_field_length()... "); - if(entry1.get_field_length() != strlen("name2=value2")) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Entry::get_field_name_length()... "); - if(entry1.get_field_name_length() != strlen("name2")) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Entry::get_field_value_length()... "); - if(entry1.get_field_value_length() != strlen("value2")) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Entry::get_entry()... "); - { - ::FLAC__StreamMetadata_VorbisComment_Entry entry = entry1.get_entry(); - if(entry.length != strlen("name2=value2")) - return die_("entry length mismatch"); - if(0 != memcmp(entry.entry, "name2=value2", entry.length)) - return die_("entry value mismatch"); - } - printf("OK\n"); - - printf("testing Entry::get_field()... "); - if(0 != memcmp(entry1.get_field(), "name2=value2", strlen("name2=value2"))) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Entry::get_field_name()... "); - if(0 != memcmp(entry1.get_field_name(), "name2", strlen("name2"))) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Entry::get_field_value()... "); - if(0 != memcmp(entry1.get_field_value(), "value2", strlen("value2"))) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Entry::set_field_name()... "); - if(!entry1.set_field_name("name1")) - return die_("returned false"); - if(0 != memcmp(entry1.get_field_name(), "name1", strlen("name1"))) - return die_("value mismatch"); - if(0 != memcmp(entry1.get_field(), "name1=value2", strlen("name1=value2"))) - return die_("entry mismatch"); - printf("OK\n"); - - printf("testing Entry::set_field_value(const char *field_value, uint32_t field_value_length)... "); - if(!entry1.set_field_value("value1", strlen("value1"))) - return die_("returned false"); - if(0 != memcmp(entry1.get_field_value(), "value1", strlen("value1"))) - return die_("value mismatch"); - if(0 != memcmp(entry1.get_field(), "name1=value1", strlen("name1=value1"))) - return die_("entry mismatch"); - printf("OK\n"); - - printf("testing Entry::set_field_value(const char *field_value)... "); - if(!entry1.set_field_value("value1")) - return die_("returned false"); - if(0 != memcmp(entry1.get_field_value(), "value1", strlen("value1"))) - return die_("value mismatch"); - if(0 != memcmp(entry1.get_field(), "name1=value1", strlen("name1=value1"))) - return die_("entry mismatch"); - printf("OK\n"); - - printf("testing Entry::set_field(const char *field, uint32_t field_length)... "); - if(!entry1.set_field("name0=value0", strlen("name0=value0"))) - return die_("returned false"); - if(0 != memcmp(entry1.get_field_name(), "name0", strlen("name0"))) - return die_("value mismatch"); - if(0 != memcmp(entry1.get_field_value(), "value0", strlen("value0"))) - return die_("value mismatch"); - if(0 != memcmp(entry1.get_field(), "name0=value0", strlen("name0=value0"))) - return die_("entry mismatch"); - printf("OK\n"); - - printf("testing Entry::set_field(const char *field)... "); - if(!entry1.set_field("name0=value0")) - return die_("returned false"); - if(0 != memcmp(entry1.get_field_name(), "name0", strlen("name0"))) - return die_("value mismatch"); - if(0 != memcmp(entry1.get_field_value(), "value0", strlen("value0"))) - return die_("value mismatch"); - if(0 != memcmp(entry1.get_field(), "name0=value0", strlen("name0=value0"))) - return die_("entry mismatch"); - printf("OK\n"); - - printf("PASSED\n\n"); - - - printf("testing class FLAC::Metadata::VorbisComment\n"); - - printf("testing VorbisComment::VorbisComment()... "); - FLAC::Metadata::VorbisComment block; - if(!block.is_valid()) - return die_("!block.is_valid()"); - expected_length = (FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + strlen(::FLAC__VENDOR_STRING) + FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN/8); - if(block.get_length() != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block.get_length()); - return false; - } - printf("OK\n"); - - printf("testing VorbisComment::VorbisComment(const VorbisComment &)... +\n"); - printf(" VorbisComment::operator!=(const VorbisComment &)... "); - { - FLAC::Metadata::VorbisComment blockcopy(block); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != block) - return die_("copy is not identical to original"); - printf("OK\n"); - - printf("testing VorbisComment::~VorbisComment()... "); - } - printf("OK\n"); - - printf("testing VorbisComment::VorbisComment(const ::FLAC__StreamMetadata &)... +\n"); - printf(" VorbisComment::operator!=(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::VorbisComment blockcopy(vorbiscomment_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != vorbiscomment_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing VorbisComment::VorbisComment(const ::FLAC__StreamMetadata *)... +\n"); - printf(" VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::VorbisComment blockcopy(&vorbiscomment_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != vorbiscomment_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing VorbisComment::VorbisComment(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::VorbisComment blockcopy(&vorbiscomment_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != vorbiscomment_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing VorbisComment::VorbisComment(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&vorbiscomment_); - FLAC::Metadata::VorbisComment blockcopy(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != vorbiscomment_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing VorbisComment::assign(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::VorbisComment blockcopy; - blockcopy.assign(&vorbiscomment_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != vorbiscomment_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing VorbisComment::assign(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" VorbisComment::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&vorbiscomment_); - FLAC::Metadata::VorbisComment blockcopy; - blockcopy.assign(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != vorbiscomment_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing VorbisComment::operator=(const VorbisComment &)... +\n"); - printf(" VorbisComment::operator==(const VorbisComment &)... "); - { - FLAC::Metadata::VorbisComment blockcopy = block; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == block)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing VorbisComment::operator=(const ::FLAC__StreamMetadata &)... +\n"); - printf(" VorbisComment::operator==(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::VorbisComment blockcopy = vorbiscomment_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == vorbiscomment_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing VorbisComment::operator=(const ::FLAC__StreamMetadata *)... +\n"); - printf(" VorbisComment::operator==(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::VorbisComment blockcopy = &vorbiscomment_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == vorbiscomment_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing VorbisComment::get_num_comments()... "); - if(block.get_num_comments() != 0) - return die_("value mismatch, expected 0"); - printf("OK\n"); - - printf("testing VorbisComment::set_vendor_string()... "); - if(!block.set_vendor_string((const FLAC__byte *)"mame0")) - return die_("returned false"); - printf("OK\n"); - vorbiscomment_.data.vorbis_comment.vendor_string.entry[0] = 'm'; - - printf("testing VorbisComment::get_vendor_string()... "); - if(strlen((const char *)block.get_vendor_string()) != vorbiscomment_.data.vorbis_comment.vendor_string.length) - return die_("length mismatch"); - if(0 != memcmp(block.get_vendor_string(), vorbiscomment_.data.vorbis_comment.vendor_string.entry, vorbiscomment_.data.vorbis_comment.vendor_string.length)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing VorbisComment::append_comment()... +\n"); - printf(" VorbisComment::get_comment()... "); - if(!block.append_comment(entry3)) - return die_("returned false"); - if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[1].length) - return die_("length mismatch"); - if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[1].entry, vorbiscomment_.data.vorbis_comment.comments[1].length)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing VorbisComment::append_comment()... +\n"); - printf(" VorbisComment::get_comment()... "); - if(!block.append_comment(entry2)) - return die_("returned false"); - if(block.get_comment(1).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length) - return die_("length mismatch"); - if(0 != memcmp(block.get_comment(1).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing VorbisComment::delete_comment()... +\n"); - printf(" VorbisComment::get_comment()... "); - if(!block.delete_comment(0)) - return die_("returned false"); - if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length) - return die_("length[0] mismatch"); - if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length)) - return die_("value[0] mismatch"); - printf("OK\n"); - - printf("testing VorbisComment::delete_comment()... +\n"); - printf(" VorbisComment::get_comment()... "); - if(!block.delete_comment(0)) - return die_("returned false"); - if(block.get_num_comments() != 0) - return die_("block mismatch, expected num_comments = 0"); - printf("OK\n"); - - printf("testing VorbisComment::insert_comment()... +\n"); - printf(" VorbisComment::get_comment()... "); - if(!block.insert_comment(0, entry3)) - return die_("returned false"); - if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[1].length) - return die_("length mismatch"); - if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[1].entry, vorbiscomment_.data.vorbis_comment.comments[1].length)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing VorbisComment::insert_comment()... +\n"); - printf(" VorbisComment::get_comment()... "); - if(!block.insert_comment(0, entry3)) - return die_("returned false"); - if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[1].length) - return die_("length mismatch"); - if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[1].entry, vorbiscomment_.data.vorbis_comment.comments[1].length)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing VorbisComment::insert_comment()... +\n"); - printf(" VorbisComment::get_comment()... "); - if(!block.insert_comment(1, entry2)) - return die_("returned false"); - if(block.get_comment(1).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length) - return die_("length mismatch"); - if(0 != memcmp(block.get_comment(1).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing VorbisComment::set_comment()... +\n"); - printf(" VorbisComment::get_comment()... "); - if(!block.set_comment(0, entry2)) - return die_("returned false"); - if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length) - return die_("length mismatch"); - if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing VorbisComment::delete_comment()... +\n"); - printf(" VorbisComment::get_comment()... "); - if(!block.delete_comment(0)) - return die_("returned false"); - if(block.get_comment(0).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[0].length) - return die_("length[0] mismatch"); - if(0 != memcmp(block.get_comment(0).get_field(), vorbiscomment_.data.vorbis_comment.comments[0].entry, vorbiscomment_.data.vorbis_comment.comments[0].length)) - return die_("value[0] mismatch"); - if(block.get_comment(1).get_field_length() != vorbiscomment_.data.vorbis_comment.comments[1].length) - return die_("length[1] mismatch"); - if(0 != memcmp(block.get_comment(1).get_field(), vorbiscomment_.data.vorbis_comment.comments[1].entry, vorbiscomment_.data.vorbis_comment.comments[1].length)) - return die_("value[0] mismatch"); - printf("OK\n"); - - printf("testing FLAC::Metadata::clone(const FLAC::Metadata::Prototype *)... "); - FLAC::Metadata::Prototype *clone_ = FLAC::Metadata::clone(&block); - if(0 == clone_) - return die_("returned NULL"); - if(0 == dynamic_cast(clone_)) - return die_("downcast is NULL"); - if(*dynamic_cast(clone_) != block) - return die_("clone is not identical"); - printf("OK\n"); - printf("testing VorbisComment::~VorbisComment()... "); - delete clone_; - printf("OK\n"); - - - printf("PASSED\n\n"); - return true; -} - -bool test_metadata_object_cuesheet() -{ - uint32_t expected_length; - - printf("testing class FLAC::Metadata::CueSheet::Track\n"); - - printf("testing Track::Track()... "); - FLAC::Metadata::CueSheet::Track track0; - if(!track0.is_valid()) - return die_("!is_valid()"); - printf("OK\n"); - - { - printf("testing Track::get_track()... "); - const ::FLAC__StreamMetadata_CueSheet_Track *trackp = track0.get_track(); - if(0 == trackp) - return die_("returned pointer is NULL"); - printf("OK\n"); - - printf("testing Track::Track(const ::FLAC__StreamMetadata_CueSheet_Track*)... "); - FLAC::Metadata::CueSheet::Track track2(trackp); - if(!track2.is_valid()) - return die_("!is_valid()"); - if(!track_is_equal_(track2.get_track(), trackp)) - return die_("copy is not equal"); - printf("OK\n"); - - printf("testing Track::~Track()... "); - } - printf("OK\n"); - - printf("testing Track::Track(const Track &track)... "); - { - FLAC::Metadata::CueSheet::Track track0copy(track0); - if(!track0copy.is_valid()) - return die_("!is_valid()"); - if(!track_is_equal_(track0copy.get_track(), track0.get_track())) - return die_("copy is not equal"); - printf("OK\n"); - - printf("testing Track::~Track()... "); - } - printf("OK\n"); - - printf("testing Track::operator=(const Track &track)... "); - FLAC::Metadata::CueSheet::Track track1 = track0; - if(!track0.is_valid()) - return die_("!is_valid()"); - if(!track_is_equal_(track1.get_track(), track0.get_track())) - return die_("copy is not equal"); - printf("OK\n"); - - printf("testing Track::get_offset()... "); - if(track1.get_offset() != 0) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::get_number()... "); - if(track1.get_number() != 0) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::get_isrc()... "); - if(0 != memcmp(track1.get_isrc(), "\0\0\0\0\0\0\0\0\0\0\0\0\0", 13)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::get_type()... "); - if(track1.get_type() != 0) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::get_pre_emphasis()... "); - if(track1.get_pre_emphasis() != 0) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::get_num_indices()... "); - if(track1.get_num_indices() != 0) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::set_offset()... "); - track1.set_offset(588); - if(track1.get_offset() != 588) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::set_number()... "); - track1.set_number(1); - if(track1.get_number() != 1) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::set_isrc()... "); - track1.set_isrc("ABCDE1234567"); - if(0 != memcmp(track1.get_isrc(), "ABCDE1234567", 13)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::set_type()... "); - track1.set_type(1); - if(track1.get_type() != 1) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Track::set_pre_emphasis()... "); - track1.set_pre_emphasis(1); - if(track1.get_pre_emphasis() != 1) - return die_("value mismatch"); - printf("OK\n"); - - printf("PASSED\n\n"); - - printf("testing class FLAC::Metadata::CueSheet\n"); - - printf("testing CueSheet::CueSheet()... "); - FLAC::Metadata::CueSheet block; - if(!block.is_valid()) - return die_("!block.is_valid()"); - expected_length = ( - FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN + - FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + - FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN - ) / 8; - if(block.get_length() != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block.get_length()); - return false; - } - printf("OK\n"); - - printf("testing CueSheet::CueSheet(const CueSheet &)... +\n"); - printf(" CueSheet::operator!=(const CueSheet &)... "); - { - FLAC::Metadata::CueSheet blockcopy(block); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != block) - return die_("copy is not identical to original"); - printf("OK\n"); - - printf("testing CueSheet::~CueSheet()... "); - } - printf("OK\n"); - - printf("testing CueSheet::CueSheet(const ::FLAC__StreamMetadata &)... +\n"); - printf(" CueSheet::operator!=(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::CueSheet blockcopy(cuesheet_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != cuesheet_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing CueSheet::CueSheet(const ::FLAC__StreamMetadata *)... +\n"); - printf(" CueSheet::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::CueSheet blockcopy(&cuesheet_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != cuesheet_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing CueSheet::CueSheet(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" CueSheet::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::CueSheet blockcopy(&cuesheet_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != cuesheet_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing CueSheet::CueSheet(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" CueSheet::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&cuesheet_); - FLAC::Metadata::CueSheet blockcopy(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != cuesheet_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing CueSheet::assign(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" CueSheet::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::CueSheet blockcopy; - blockcopy.assign(&cuesheet_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != cuesheet_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing CueSheet::assign(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" CueSheet::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&cuesheet_); - FLAC::Metadata::CueSheet blockcopy; - blockcopy.assign(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != cuesheet_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing CueSheet::operator=(const CueSheet &)... +\n"); - printf(" CueSheet::operator==(const CueSheet &)... "); - { - FLAC::Metadata::CueSheet blockcopy = block; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == block)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing CueSheet::operator=(const ::FLAC__StreamMetadata &)... +\n"); - printf(" CueSheet::operator==(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::CueSheet blockcopy = cuesheet_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == cuesheet_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing CueSheet::operator=(const ::FLAC__StreamMetadata *)... +\n"); - printf(" CueSheet::operator==(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::CueSheet blockcopy = &cuesheet_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == cuesheet_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing CueSheet::get_media_catalog_number()... "); - if(0 != strcmp(block.get_media_catalog_number(), "")) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing CueSheet::get_lead_in()... "); - if(block.get_lead_in() != 0) - return die_("value mismatch, expected 0"); - printf("OK\n"); - - printf("testing CueSheet::get_is_cd()... "); - if(block.get_is_cd()) - return die_("value mismatch, expected false"); - printf("OK\n"); - - printf("testing CueSheet::get_num_tracks()... "); - if(block.get_num_tracks() != 0) - return die_("value mismatch, expected 0"); - printf("OK\n"); - - printf("testing CueSheet::set_media_catalog_number()... "); - { - char mcn[129]; - memset(mcn, 0, sizeof(mcn)); - safe_strncpy(mcn, "1234567890123", sizeof(mcn)); - block.set_media_catalog_number(mcn); - if(0 != memcmp(block.get_media_catalog_number(), mcn, sizeof(mcn))) - return die_("value mismatch"); - } - printf("OK\n"); - - printf("testing CueSheet::set_lead_in()... "); - block.set_lead_in(588); - if(block.get_lead_in() != 588) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing CueSheet::set_is_cd()... "); - block.set_is_cd(true); - if(!block.get_is_cd()) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing CueSheet::insert_track()... +\n"); - printf(" CueSheet::get_track()... "); - if(!block.insert_track(0, track0)) - return die_("returned false"); - if(!track_is_equal_(block.get_track(0).get_track(), track0.get_track())) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing CueSheet::insert_track()... +\n"); - printf(" CueSheet::get_track()... "); - if(!block.insert_track(1, track1)) - return die_("returned false"); - if(!track_is_equal_(block.get_track(1).get_track(), track1.get_track())) - return die_("value mismatch"); - printf("OK\n"); - - ::FLAC__StreamMetadata_CueSheet_Index index0; - index0.offset = 588*4; - index0.number = 1; - - printf("testing CueSheet::insert_index(0)... +\n"); - printf(" CueSheet::get_track()... +\n"); - printf(" CueSheet::Track::get_index()... "); - if(!block.insert_index(0, 0, index0)) - return die_("returned false"); - if(!index_is_equal_(block.get_track(0).get_index(0), index0)) - return die_("value mismatch"); - printf("OK\n"); - - index0.offset = 588*5; - printf("testing CueSheet::Track::set_index()... "); - { - FLAC::Metadata::CueSheet::Track track_ = block.get_track(0); - track_.set_index(0, index0); - if(!index_is_equal_(track_.get_index(0), index0)) - return die_("value mismatch"); - } - printf("OK\n"); - - index0.offset = 588*6; - printf("testing CueSheet::set_index()... "); - block.set_index(0, 0, index0); - if(!index_is_equal_(block.get_track(0).get_index(0), index0)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing CueSheet::delete_index()... "); - if(!block.delete_index(0, 0)) - return die_("returned false"); - if(block.get_track(0).get_num_indices() != 0) - return die_("num_indices mismatch"); - printf("OK\n"); - - - printf("testing CueSheet::set_track()... +\n"); - printf(" CueSheet::get_track()... "); - if(!block.set_track(0, track1)) - return die_("returned false"); - if(!track_is_equal_(block.get_track(0).get_track(), track1.get_track())) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing CueSheet::delete_track()... "); - if(!block.delete_track(0)) - return die_("returned false"); - if(block.get_num_tracks() != 1) - return die_("num_tracks mismatch"); - printf("OK\n"); - - printf("testing FLAC::Metadata::clone(const FLAC::Metadata::Prototype *)... "); - FLAC::Metadata::Prototype *clone_ = FLAC::Metadata::clone(&block); - if(0 == clone_) - return die_("returned NULL"); - if(0 == dynamic_cast(clone_)) - return die_("downcast is NULL"); - if(*dynamic_cast(clone_) != block) - return die_("clone is not identical"); - printf("OK\n"); - printf("testing CueSheet::~CueSheet()... "); - delete clone_; - printf("OK\n"); - - printf("PASSED\n\n"); - return true; -} - -bool test_metadata_object_picture() -{ - uint32_t expected_length; - - printf("testing class FLAC::Metadata::Picture\n"); - - printf("testing Picture::Picture()... "); - FLAC::Metadata::Picture block; - if(!block.is_valid()) - return die_("!block.is_valid()"); - expected_length = ( - FLAC__STREAM_METADATA_PICTURE_TYPE_LEN + - FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN + - FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN + - FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN + - FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN + - FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN + - FLAC__STREAM_METADATA_PICTURE_COLORS_LEN + - FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN - ) / 8; - if(block.get_length() != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block.get_length()); - return false; - } - printf("OK\n"); - - printf("testing Picture::Picture(const Picture &)... +\n"); - printf(" Picture::operator!=(const Picture &)... "); - { - FLAC::Metadata::Picture blockcopy(block); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != block) - return die_("copy is not identical to original"); - printf("OK\n"); - - printf("testing Picture::~Picture()... "); - } - printf("OK\n"); - - printf("testing Picture::Picture(const ::FLAC__StreamMetadata &)... +\n"); - printf(" Picture::operator!=(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::Picture blockcopy(picture_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != picture_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Picture::Picture(const ::FLAC__StreamMetadata *)... +\n"); - printf(" Picture::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Picture blockcopy(&picture_); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != picture_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Picture::Picture(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" Picture::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Picture blockcopy(&picture_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != picture_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Picture::Picture(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" Picture::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&picture_); - FLAC::Metadata::Picture blockcopy(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != picture_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Picture::assign(const ::FLAC__StreamMetadata *, copy=true)... +\n"); - printf(" Picture::operator!=(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Picture blockcopy; - blockcopy.assign(&picture_, /*copy=*/true); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != picture_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Picture::assign(const ::FLAC__StreamMetadata *, copy=false)... +\n"); - printf(" Picture::operator!=(const ::FLAC__StreamMetadata *)... "); - { - ::FLAC__StreamMetadata *copy = ::FLAC__metadata_object_clone(&picture_); - FLAC::Metadata::Picture blockcopy; - blockcopy.assign(copy, /*copy=*/false); - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(blockcopy != picture_) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Picture::operator=(const Picture &)... +\n"); - printf(" Picture::operator==(const Picture &)... "); - { - FLAC::Metadata::Picture blockcopy = block; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == block)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Picture::operator=(const ::FLAC__StreamMetadata &)... +\n"); - printf(" Picture::operator==(const ::FLAC__StreamMetadata &)... "); - { - FLAC::Metadata::Picture blockcopy = picture_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == picture_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Picture::operator=(const ::FLAC__StreamMetadata *)... +\n"); - printf(" Picture::operator==(const ::FLAC__StreamMetadata *)... "); - { - FLAC::Metadata::Picture blockcopy = &picture_; - if(!blockcopy.is_valid()) - return die_("!blockcopy.is_valid()"); - if(!(blockcopy == picture_)) - return die_("copy is not identical to original"); - printf("OK\n"); - } - - printf("testing Picture::get_type()... "); - if(block.get_type() != ::FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER) - return die_("value mismatch, expected ::FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER"); - printf("OK\n"); - - printf("testing Picture::set_type()... +\n"); - printf(" Picture::get_type()... "); - block.set_type(::FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA); - if(block.get_type() != ::FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA) - return die_("value mismatch, expected ::FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA"); - printf("OK\n"); - - printf("testing Picture::set_mime_type()... "); - if(!block.set_mime_type("qmage/jpeg")) - return die_("returned false"); - printf("OK\n"); - picture_.data.picture.mime_type[0] = 'q'; - - printf("testing Picture::get_mime_type()... "); - if(0 != strcmp(block.get_mime_type(), picture_.data.picture.mime_type)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Picture::set_description()... "); - if(!block.set_description((const FLAC__byte*)"qesc")) - return die_("returned false"); - printf("OK\n"); - picture_.data.picture.description[0] = 'q'; - - printf("testing Picture::get_description()... "); - if(0 != strcmp((const char *)block.get_description(), (const char *)picture_.data.picture.description)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing Picture::get_width()... "); - if(block.get_width() != 0) - return die_("value mismatch, expected 0"); - printf("OK\n"); - - printf("testing Picture::set_width()... +\n"); - printf(" Picture::get_width()... "); - block.set_width(400); - if(block.get_width() != 400) - return die_("value mismatch, expected 400"); - printf("OK\n"); - - printf("testing Picture::get_height()... "); - if(block.get_height() != 0) - return die_("value mismatch, expected 0"); - printf("OK\n"); - - printf("testing Picture::set_height()... +\n"); - printf(" Picture::get_height()... "); - block.set_height(200); - if(block.get_height() != 200) - return die_("value mismatch, expected 200"); - printf("OK\n"); - - printf("testing Picture::get_depth()... "); - if(block.get_depth() != 0) - return die_("value mismatch, expected 0"); - printf("OK\n"); - - printf("testing Picture::set_depth()... +\n"); - printf(" Picture::get_depth()... "); - block.set_depth(16); - if(block.get_depth() != 16) - return die_("value mismatch, expected 16"); - printf("OK\n"); - - printf("testing Picture::get_colors()... "); - if(block.get_colors() != 0) - return die_("value mismatch, expected 0"); - printf("OK\n"); - - printf("testing Picture::set_colors()... +\n"); - printf(" Picture::get_colors()... "); - block.set_colors(1u>16); - if(block.get_colors() != (1u>16)) - return die_("value mismatch, expected 2^16"); - printf("OK\n"); - - printf("testing Picture::get_data_length()... "); - if(block.get_data_length() != 0) - return die_("value mismatch, expected 0"); - printf("OK\n"); - - printf("testing Picture::set_data()... "); - if(!block.set_data((const FLAC__byte*)"qOMEJPEGDATA", strlen("qOMEJPEGDATA"))) - return die_("returned false"); - printf("OK\n"); - picture_.data.picture.data[0] = 'q'; - - printf("testing Picture::get_data()... "); - if(block.get_data_length() != picture_.data.picture.data_length) - return die_("length mismatch"); - if(0 != memcmp(block.get_data(), picture_.data.picture.data, picture_.data.picture.data_length)) - return die_("value mismatch"); - printf("OK\n"); - - printf("testing FLAC::Metadata::clone(const FLAC::Metadata::Prototype *)... "); - FLAC::Metadata::Prototype *clone_ = FLAC::Metadata::clone(&block); - if(0 == clone_) - return die_("returned NULL"); - if(0 == dynamic_cast(clone_)) - return die_("downcast is NULL"); - if(*dynamic_cast(clone_) != block) - return die_("clone is not identical"); - printf("OK\n"); - printf("testing Picture::~Picture()... "); - delete clone_; - printf("OK\n"); - - - printf("PASSED\n\n"); - return true; -} - -bool test_metadata_object() -{ - printf("\n+++ libFLAC++ unit test: metadata objects\n\n"); - - init_metadata_blocks_(); - - if(!test_metadata_object_streaminfo()) - return false; - - if(!test_metadata_object_padding()) - return false; - - if(!test_metadata_object_application()) - return false; - - if(!test_metadata_object_seektable()) - return false; - - if(!test_metadata_object_vorbiscomment()) - return false; - - if(!test_metadata_object_cuesheet()) - return false; - - if(!test_metadata_object_picture()) - return false; - - free_metadata_blocks_(); - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/CMakeLists.txt b/Engine/lib/flac/src/test_libFLAC/CMakeLists.txt deleted file mode 100644 index 36a582008..000000000 --- a/Engine/lib/flac/src/test_libFLAC/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -add_executable(test_libFLAC - bitreader.c - bitwriter.c - crc.c - decoders.c - encoders.c - endswap.c - format.c - main.c - metadata.c - metadata_manip.c - metadata_object.c - md5.c - "$/bitreader.c" - "$/bitwriter.c" - "$/crc.c" - "$/md5.c" - $<$:../../include/share/win_utf8_io.h> - $<$:../share/win_utf8_io/win_utf8_io.c>) - -target_compile_definitions(test_libFLAC PRIVATE - $<$:ENABLE_64_BIT_WORDS>) -target_include_directories(test_libFLAC PRIVATE - "$/include") -target_link_libraries(test_libFLAC FLAC grabbag test_libs_common) diff --git a/Engine/lib/flac/src/test_libFLAC/Makefile.am b/Engine/lib/flac/src/test_libFLAC/Makefile.am deleted file mode 100644 index c77f87e85..000000000 --- a/Engine/lib/flac/src/test_libFLAC/Makefile.am +++ /dev/null @@ -1,63 +0,0 @@ -# test_libFLAC - Unit tester for libFLAC -# Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -check_PROGRAMS = test_libFLAC - -if OS_IS_WINDOWS -win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la -flac__no_dll = -DFLAC__NO_DLL -endif - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -I$(top_srcdir)/src/libFLAC/include $(flac__no_dll) - -test_libFLAC_LDADD = \ - $(top_builddir)/src/share/grabbag/libgrabbag.la \ - $(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \ - $(top_builddir)/src/test_libs_common/libtest_libs_common.la \ - $(top_builddir)/src/libFLAC/libFLAC-static.la \ - $(win_utf8_lib) \ - @OGG_LIBS@ \ - -lm - -test_libFLAC_SOURCES = \ - bitreader.c \ - bitwriter.c \ - crc.c \ - decoders.c \ - encoders.c \ - endswap.c \ - format.c \ - main.c \ - metadata.c \ - metadata_manip.c \ - metadata_object.c \ - md5.c \ - bitreader.h \ - bitwriter.h \ - crc.h \ - decoders.h \ - encoders.h \ - endswap.h \ - format.h \ - metadata.h \ - md5.h - -CLEANFILES = test_libFLAC.exe diff --git a/Engine/lib/flac/src/test_libFLAC/bitreader.c b/Engine/lib/flac/src/test_libFLAC/bitreader.c deleted file mode 100644 index d40bd1f2e..000000000 --- a/Engine/lib/flac/src/test_libFLAC/bitreader.c +++ /dev/null @@ -1,355 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/assert.h" -#include "share/compat.h" -#include "private/bitreader.h" /* from the libFLAC private include area */ -#include "bitreader.h" -#include -#include /* for memcpy() */ - -/* - * WATCHOUT! Since FLAC__BitReader is a private structure, we use a copy of - * the definition here to get at the internals. Make sure this is kept up - * to date with what is in ../libFLAC/bitreader.c - */ -#if (ENABLE_64_BIT_WORDS == 0) - -typedef FLAC__uint32 brword; -#define FLAC__BYTES_PER_WORD 4 -#define FLAC__BITS_PER_WORD 32 - -#else - -typedef FLAC__uint64 brword; -#define FLAC__BYTES_PER_WORD 8 -#define FLAC__BITS_PER_WORD 64 - -#endif - -struct FLAC__BitReader { - /* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */ - /* any incomplete word at the tail will be left-justified, and bytes from the read callback are added on the right */ - brword *buffer; - uint32_t capacity; /* in words */ - uint32_t words; /* # of completed words in buffer */ - uint32_t bytes; /* # of bytes in incomplete word at buffer[words] */ - uint32_t consumed_words; /* #words ... */ - uint32_t consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */ - uint32_t read_crc16; /* the running frame CRC */ - uint32_t crc16_offset; /* the number of words in the current buffer that should not be CRC'd */ - uint32_t crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */ - FLAC__bool read_limit_set; /* whether reads are limited */ - uint32_t read_limit; /* the remaining size of what can be read */ - uint32_t last_seen_framesync; /* the location of the last seen framesync, if it is in the buffer, in bits from front of buffer */ - FLAC__BitReaderReadCallback read_callback; - void *client_data; -}; - -static FLAC__bool read_callback(FLAC__byte buffer[], size_t *bytes, void *data); - -static void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out) -{ - uint32_t i, j; - if(br == 0) { - fprintf(out, "bitreader is NULL\n"); - } - else { - fprintf(out, "bitreader: capacity=%u words=%u bytes=%u consumed: words=%u, bits=%u\n", br->capacity, br->words, br->bytes, br->consumed_words, br->consumed_bits); - - for(i = 0; i < br->words; i++) { - fprintf(out, "%08X: ", i); - for(j = 0; j < FLAC__BITS_PER_WORD; j++) - if(i < br->consumed_words || (i == br->consumed_words && j < br->consumed_bits)) - fprintf(out, "."); - else - fprintf(out, "%01d", br->buffer[i] & ((brword)1 << (FLAC__BITS_PER_WORD-j-1)) ? 1:0); - fprintf(out, "\n"); - } - if(br->bytes > 0) { - fprintf(out, "%08X: ", i); - for(j = 0; j < br->bytes*8; j++) - if(i < br->consumed_words || (i == br->consumed_words && j < br->consumed_bits)) - fprintf(out, "."); - else - fprintf(out, "%01d", br->buffer[i] & ((brword)1 << (br->bytes*8-j-1)) ? 1:0); - fprintf(out, "\n"); - } - } -} - -FLAC__bool test_bitreader(void) -{ - FLAC__BitReader *br; - FLAC__bool ok; - uint32_t i; - uint32_t words, bits; /* what we think br->consumed_words and br->consumed_bits should be */ - - FLAC__uint16 crc,expected_crcs[4] = { 0x5e4c, 0x7f6b, 0x2272, 0x42bf }; - FLAC__byte data[32]; - - FLAC__uint32 val_uint32; - FLAC__uint64 val_uint64; - - for (i = 0; i < 32; i++) - data[i] = i * 8 + 7; - - printf("\n+++ libFLAC unit test: bitreader\n\n"); - - /* - * test new -> delete - */ - printf("testing new... "); - br = FLAC__bitreader_new(); - if(0 == br) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing delete... "); - FLAC__bitreader_delete(br); - printf("OK\n"); - - /* - * test new -> init -> delete - */ - printf("testing new... "); - br = FLAC__bitreader_new(); - if(0 == br) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing init... "); - if(!FLAC__bitreader_init(br, read_callback, data)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing delete... "); - FLAC__bitreader_delete(br); - printf("OK\n"); - - /* - * test new -> init -> clear -> delete - */ - printf("testing new... "); - br = FLAC__bitreader_new(); - if(0 == br) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing init... "); - if(!FLAC__bitreader_init(br, read_callback, data)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing clear... "); - if(!FLAC__bitreader_clear(br)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing delete... "); - FLAC__bitreader_delete(br); - printf("OK\n"); - - /* - * test normal usage - */ - printf("testing new... "); - br = FLAC__bitreader_new(); - if(0 == br) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing init... "); - if(!FLAC__bitreader_init(br, read_callback, data)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing clear... "); - if(!FLAC__bitreader_clear(br)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - words = bits = 0; - - printf("capacity = %u\n", br->capacity); - - printf("testing raw reads... "); - ok = - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 1) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 2) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 5) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 8) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 10) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 4) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 32) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 4) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 2) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 8) && - FLAC__bitreader_read_raw_uint64(br, &val_uint64, 64) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 12) - ; - if(!ok) { - printf("FAILED\n"); - FLAC__bitreader_dump(br, stdout); - return false; - } - /* we read 152 bits (=19 bytes) from the bitreader */ - words = 152 / FLAC__BITS_PER_WORD; - bits = 152 - words*FLAC__BITS_PER_WORD; - - if(br->consumed_words != words) { - printf("FAILED word count %u != %u\n", br->consumed_words, words); - FLAC__bitreader_dump(br, stdout); - return false; - } - if(br->consumed_bits != bits) { - printf("FAILED bit count %u != %u\n", br->consumed_bits, bits); - FLAC__bitreader_dump(br, stdout); - return false; - } - crc = FLAC__bitreader_get_read_crc16(br); - if(crc != expected_crcs[0]) { - printf("FAILED reported CRC 0x%04x does not match expected 0x%04x\n", crc, expected_crcs[0]); - FLAC__bitreader_dump(br, stdout); - return false; - } - printf("OK\n"); - FLAC__bitreader_dump(br, stdout); - - printf("testing CRC reset... "); - FLAC__bitreader_clear(br); - FLAC__bitreader_reset_read_crc16(br, 0xFFFF); - crc = FLAC__bitreader_get_read_crc16(br); - if(crc != 0xFFFF) { - printf("FAILED reported CRC 0x%04x does not match expected 0xFFFF\n", crc); - FLAC__bitreader_dump(br, stdout); - return false; - } - FLAC__bitreader_reset_read_crc16(br, 0); - crc = FLAC__bitreader_get_read_crc16(br); - if(crc != 0) { - printf("FAILED reported CRC 0x%04x does not match expected 0x0000\n", crc); - FLAC__bitreader_dump(br, stdout); - return false; - } - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 16); - FLAC__bitreader_reset_read_crc16(br, 0); - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 32); - crc = FLAC__bitreader_get_read_crc16(br); - if(crc != expected_crcs[1]) { - printf("FAILED reported CRC 0x%04x does not match expected 0x%04x\n", crc, expected_crcs[1]); - FLAC__bitreader_dump(br, stdout); - return false; - } - printf("OK\n"); - - printf("testing unaligned < 32 bit reads... "); - FLAC__bitreader_clear(br); - FLAC__bitreader_skip_bits_no_crc(br, 8); - FLAC__bitreader_reset_read_crc16(br, 0); - ok = - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 1) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 2) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 5) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 8) - ; - if(!ok) { - printf("FAILED\n"); - FLAC__bitreader_dump(br, stdout); - return false; - } - crc = FLAC__bitreader_get_read_crc16(br); - if(crc != expected_crcs[2]) { - printf("FAILED reported CRC 0x%04x does not match expected 0x%04x\n", crc, expected_crcs[2]); - FLAC__bitreader_dump(br, stdout); - return false; - } - printf("OK\n"); - FLAC__bitreader_dump(br, stdout); - - printf("testing unaligned < 64 bit reads... "); - FLAC__bitreader_clear(br); - FLAC__bitreader_skip_bits_no_crc(br, 8); - FLAC__bitreader_reset_read_crc16(br, 0); - ok = - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 1) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 2) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 5) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 8) && - FLAC__bitreader_read_raw_uint32(br, &val_uint32, 32) - ; - if(!ok) { - printf("FAILED\n"); - FLAC__bitreader_dump(br, stdout); - return false; - } - crc = FLAC__bitreader_get_read_crc16(br); - if(crc != expected_crcs[3]) { - printf("FAILED reported CRC 0x%04x does not match expected 0x%04x\n", crc, expected_crcs[3]); - FLAC__bitreader_dump(br, stdout); - return false; - } - printf("OK\n"); - FLAC__bitreader_dump(br, stdout); - - printf("testing free... "); - FLAC__bitreader_free(br); - printf("OK\n"); - - printf("testing delete... "); - FLAC__bitreader_delete(br); - printf("OK\n"); - - printf("\nPASSED!\n"); - return true; -} - -/*----------------------------------------------------------------------------*/ - -static FLAC__bool read_callback(FLAC__byte buffer[], size_t *bytes, void *data) -{ - if (*bytes > 32) - *bytes = 32; - - memcpy(buffer, data, *bytes); - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/bitreader.h b/Engine/lib/flac/src/test_libFLAC/bitreader.h deleted file mode 100644 index f497acf6f..000000000 --- a/Engine/lib/flac/src/test_libFLAC/bitreader.h +++ /dev/null @@ -1,27 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_BITREADER_H -#define FLAC__TEST_LIBFLAC_BITREADER_H - -#include "FLAC/ordinals.h" - -FLAC__bool test_bitreader(void); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/bitwriter.c b/Engine/lib/flac/src/test_libFLAC/bitwriter.c deleted file mode 100644 index 0aafff2f1..000000000 --- a/Engine/lib/flac/src/test_libFLAC/bitwriter.c +++ /dev/null @@ -1,688 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/assert.h" -#include "share/compat.h" -#include "private/bitwriter.h" /* from the libFLAC private include area */ -#include "bitwriter.h" -#include -#include /* for memcmp() */ - -/* - * WATCHOUT! Since FLAC__BitWriter is a private structure, we use a copy of - * the definition here to get at the internals. Make sure this is kept up - * to date with what is in ../libFLAC/bitwriter.c - */ -#if (ENABLE_64_BIT_WORDS == 0) - -typedef FLAC__uint32 bwword; -#define FLAC__BYTES_PER_WORD 4 -#define FLAC__BITS_PER_WORD 32 -#define PRI_BWWORD "08x" - -#else - -typedef FLAC__uint64 bwword; -#define FLAC__BYTES_PER_WORD 8 -#define FLAC__BITS_PER_WORD 64 -#define PRI_BWWORD "016" PRIx64 - -#endif - -struct FLAC__BitWriter { - bwword *buffer; - bwword accum; /* accumulator; bits are right-justified; when full, accum is appended to buffer */ - uint32_t capacity; /* capacity of buffer in words */ - uint32_t words; /* # of complete words in buffer */ - uint32_t bits; /* # of used bits in accum */ -}; - -#define WORDS_TO_BITS(words) ((words) * FLAC__BITS_PER_WORD) -#define TOTAL_BITS(bw) (WORDS_TO_BITS((bw)->words) + (bw)->bits) - -static void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out) -{ - uint32_t i, j; - if(bw == 0) { - fprintf(out, "bitwriter is NULL\n"); - } - else { - fprintf(out, "bitwriter: capacity=%u words=%u bits=%u total_bits=%u\n", bw->capacity, bw->words, bw->bits, TOTAL_BITS(bw)); - - for(i = 0; i < bw->words; i++) { - fprintf(out, "%08X: ", i); - for(j = 0; j < FLAC__BITS_PER_WORD; j++) - fprintf(out, "%01d", bw->buffer[i] & ((bwword)1 << (FLAC__BITS_PER_WORD-j-1)) ? 1:0); - fprintf(out, "\n"); - } - if(bw->bits > 0) { - fprintf(out, "%08X: ", i); - for(j = 0; j < bw->bits; j++) - fprintf(out, "%01d", bw->accum & ((bwword)1 << (bw->bits-j-1)) ? 1:0); - fprintf(out, "\n"); - } - } -} - -FLAC__bool test_bitwriter(void) -{ - FLAC__BitWriter *bw; - FLAC__bool ok; - uint32_t i, j; -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - static bwword test_pattern1[5] = { 0xaaf0aabe, 0xaaaaaaa8, 0x300aaaaa, 0xaaadeadb, 0x00eeface }; -#else - static bwword test_pattern1[5] = { 0xbeaaf0aa, 0xa8aaaaaa, 0xaaaa0a30, 0xdbeaadaa, 0x00eeface }; -#endif -#elif FLAC__BYTES_PER_WORD == 8 -#if WORDS_BIGENDIAN - static bwword test_pattern1[3] = { FLAC__U64L(0xaaf0aabeaaaaaaa8), FLAC__U64L(0x300aaaaaaaadeadb), FLAC__U64L(0x0000000000eeface) }; -#else - static bwword test_pattern1[3] = { FLAC__U64L(0xa8aaaaaabeaaf0aa), FLAC__U64L(0xdbeaadaaaaaa0a30), FLAC__U64L(0x0000000000eeface) }; -#endif -#else -#error FLAC__BYTES_PER_WORD is neither 4 nor 8 -- not implemented -#endif - uint32_t words, bits; /* what we think bw->words and bw->bits should be */ - - printf("\n+++ libFLAC unit test: bitwriter\n\n"); - - /* - * test new -> delete - */ - printf("testing new... "); - bw = FLAC__bitwriter_new(); - if(0 == bw) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing delete... "); - FLAC__bitwriter_delete(bw); - printf("OK\n"); - - /* - * test new -> init -> delete - */ - printf("testing new... "); - bw = FLAC__bitwriter_new(); - if(0 == bw) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing init... "); - if(!FLAC__bitwriter_init(bw)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing delete... "); - FLAC__bitwriter_delete(bw); - printf("OK\n"); - - /* - * test new -> init -> clear -> delete - */ - printf("testing new... "); - bw = FLAC__bitwriter_new(); - if(0 == bw) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing init... "); - if(!FLAC__bitwriter_init(bw)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing clear... "); - FLAC__bitwriter_clear(bw); - printf("OK\n"); - - printf("testing delete... "); - FLAC__bitwriter_delete(bw); - printf("OK\n"); - - /* - * test normal usage - */ - printf("testing new... "); - bw = FLAC__bitwriter_new(); - if(0 == bw) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing init... "); - if(!FLAC__bitwriter_init(bw)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing clear... "); - FLAC__bitwriter_clear(bw); - printf("OK\n"); - - words = bits = 0; - - printf("capacity = %u\n", bw->capacity); - - printf("testing zeroes, raw_uint32*... "); - ok = - FLAC__bitwriter_write_raw_uint32(bw, 0x1, 1) && - FLAC__bitwriter_write_raw_uint32(bw, 0x1, 2) && - FLAC__bitwriter_write_raw_uint32(bw, 0xa, 5) && - FLAC__bitwriter_write_raw_uint32(bw, 0xf0, 8) && - FLAC__bitwriter_write_raw_uint32(bw, 0x2aa, 10) && - FLAC__bitwriter_write_raw_uint32(bw, 0xf, 4) && - FLAC__bitwriter_write_raw_uint32(bw, 0xaaaaaaaa, 32) && - FLAC__bitwriter_write_zeroes(bw, 4) && - FLAC__bitwriter_write_raw_uint32(bw, 0x3, 2) && - FLAC__bitwriter_write_zeroes(bw, 8) && - FLAC__bitwriter_write_raw_uint64(bw, FLAC__U64L(0xaaaaaaaadeadbeef), 64) && - FLAC__bitwriter_write_raw_uint32(bw, 0xace, 12) - ; - if(!ok) { - printf("FAILED\n"); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - /* we wrote 152 bits (=19 bytes) to the bitwriter */ - words = 152 / FLAC__BITS_PER_WORD; - bits = 152 - words*FLAC__BITS_PER_WORD; - - if(bw->words != words) { - printf("FAILED word count %u != %u\n", bw->words, words); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - if(bw->bits != bits) { - printf("FAILED bit count %u != %u\n", bw->bits, bits); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - if(memcmp(bw->buffer, test_pattern1, sizeof(bwword)*words) != 0) { - printf("FAILED pattern match (buffer)\n"); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - if((bw->accum & 0x00ffffff) != test_pattern1[words]) { - printf("FAILED pattern match (bw->accum=%" PRI_BWWORD " != %" PRI_BWWORD ")\n", bw->accum&0x00ffffff, test_pattern1[words]); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - printf("OK\n"); - FLAC__bitwriter_dump(bw, stdout); - - printf("testing raw_uint32 some more... "); - ok = FLAC__bitwriter_write_raw_uint32(bw, 0x3d, 6); - if(!ok) { - printf("FAILED\n"); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - bits += 6; - test_pattern1[words] <<= 6; - test_pattern1[words] |= 0x3d; - if(bw->words != words) { - printf("FAILED word count %u != %u\n", bw->words, words); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - if(bw->bits != bits) { - printf("FAILED bit count %u != %u\n", bw->bits, bits); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - if(memcmp(bw->buffer, test_pattern1, sizeof(bwword)*words) != 0) { - printf("FAILED pattern match (buffer)\n"); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - if((bw->accum & 0x3fffffff) != test_pattern1[words]) { - printf("FAILED pattern match (bw->accum=%" PRI_BWWORD " != %" PRI_BWWORD ")\n", bw->accum&0x3fffffff, test_pattern1[words]); - FLAC__bitwriter_dump(bw, stdout); - return false; - } - printf("OK\n"); - FLAC__bitwriter_dump(bw, stdout); - - printf("testing utf8_uint32(0x00000000)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x00000000); - ok = TOTAL_BITS(bw) == 8 && (bw->accum & 0xff) == 0; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x0000007F)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x0000007F); - ok = TOTAL_BITS(bw) == 8 && (bw->accum & 0xff) == 0x7F; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x00000080)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x00000080); - ok = TOTAL_BITS(bw) == 16 && (bw->accum & 0xffff) == 0xC280; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x000007FF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x000007FF); - ok = TOTAL_BITS(bw) == 16 && (bw->accum & 0xffff) == 0xDFBF; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x00000800)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x00000800); - ok = TOTAL_BITS(bw) == 24 && (bw->accum & 0xffffff) == 0xE0A080; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x0000FFFF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x0000FFFF); - ok = TOTAL_BITS(bw) == 24 && (bw->accum & 0xffffff) == 0xEFBFBF; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x00010000)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x00010000); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 32 && bw->buffer[0] == 0xF0908080; -#else - ok = TOTAL_BITS(bw) == 32 && bw->buffer[0] == 0x808090F0; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 32 && (bw->accum & 0xffffffff) == 0xF0908080; -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x001FFFFF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x001FFFFF); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 32 && bw->buffer[0] == 0xF7BFBFBF; -#else - ok = TOTAL_BITS(bw) == 32 && bw->buffer[0] == 0xBFBFBFF7; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 32 && (bw->accum & 0xffffffff) == 0xF7BFBFBF; -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x00200000)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x00200000); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 40 && bw->buffer[0] == 0xF8888080 && (bw->accum & 0xff) == 0x80; -#else - ok = TOTAL_BITS(bw) == 40 && bw->buffer[0] == 0x808088F8 && (bw->accum & 0xff) == 0x80; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 40 && (bw->accum & FLAC__U64L(0xffffffffff)) == FLAC__U64L(0xF888808080); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x03FFFFFF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x03FFFFFF); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 40 && bw->buffer[0] == 0xFBBFBFBF && (bw->accum & 0xff) == 0xBF; -#else - ok = TOTAL_BITS(bw) == 40 && bw->buffer[0] == 0xBFBFBFFB && (bw->accum & 0xff) == 0xBF; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 40 && (bw->accum & FLAC__U64L(0xffffffffff)) == FLAC__U64L(0xFBBFBFBFBF); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x04000000)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x04000000); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 48 && bw->buffer[0] == 0xFC848080 && (bw->accum & 0xffff) == 0x8080; -#else - ok = TOTAL_BITS(bw) == 48 && bw->buffer[0] == 0x808084FC && (bw->accum & 0xffff) == 0x8080; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 48 && (bw->accum & FLAC__U64L(0xffffffffffff)) == FLAC__U64L(0xFC8480808080); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint32(0x7FFFFFFF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint32(bw, 0x7FFFFFFF); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 48 && bw->buffer[0] == 0xFDBFBFBF && (bw->accum & 0xffff) == 0xBFBF; -#else - ok = TOTAL_BITS(bw) == 48 && bw->buffer[0] == 0xBFBFBFFD && (bw->accum & 0xffff) == 0xBFBF; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 48 && (bw->accum & FLAC__U64L(0xffffffffffff)) == FLAC__U64L(0xFDBFBFBFBFBF); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x0000000000000000)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x0000000000000000)); - ok = TOTAL_BITS(bw) == 8 && (bw->accum & 0xff) == 0; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x000000000000007F)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x000000000000007F)); - ok = TOTAL_BITS(bw) == 8 && (bw->accum & 0xff) == 0x7F; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x0000000000000080)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x0000000000000080)); - ok = TOTAL_BITS(bw) == 16 && (bw->accum & 0xffff) == 0xC280; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x00000000000007FF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x00000000000007FF)); - ok = TOTAL_BITS(bw) == 16 && (bw->accum & 0xffff) == 0xDFBF; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x0000000000000800)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x0000000000000800)); - ok = TOTAL_BITS(bw) == 24 && (bw->accum & 0xffffff) == 0xE0A080; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x000000000000FFFF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x000000000000FFFF)); - ok = TOTAL_BITS(bw) == 24 && (bw->accum & 0xffffff) == 0xEFBFBF; - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x0000000000010000)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x0000000000010000)); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 32 && bw->buffer[0] == 0xF0908080; -#else - ok = TOTAL_BITS(bw) == 32 && bw->buffer[0] == 0x808090F0; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 32 && (bw->accum & 0xffffffff) == 0xF0908080; -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x00000000001FFFFF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x00000000001FFFFF)); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 32 && bw->buffer[0] == 0xF7BFBFBF; -#else - ok = TOTAL_BITS(bw) == 32 && bw->buffer[0] == 0xBFBFBFF7; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 32 && (bw->accum & 0xffffffff) == 0xF7BFBFBF; -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x0000000000200000)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x0000000000200000)); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 40 && bw->buffer[0] == 0xF8888080 && (bw->accum & 0xff) == 0x80; -#else - ok = TOTAL_BITS(bw) == 40 && bw->buffer[0] == 0x808088F8 && (bw->accum & 0xff) == 0x80; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 40 && (bw->accum & FLAC__U64L(0xffffffffff)) == FLAC__U64L(0xF888808080); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x0000000003FFFFFF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x0000000003FFFFFF)); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 40 && bw->buffer[0] == 0xFBBFBFBF && (bw->accum & 0xff) == 0xBF; -#else - ok = TOTAL_BITS(bw) == 40 && bw->buffer[0] == 0xBFBFBFFB && (bw->accum & 0xff) == 0xBF; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 40 && (bw->accum & FLAC__U64L(0xffffffffff)) == FLAC__U64L(0xFBBFBFBFBF); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x0000000004000000)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x0000000004000000)); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 48 && bw->buffer[0] == 0xFC848080 && (bw->accum & 0xffff) == 0x8080; -#else - ok = TOTAL_BITS(bw) == 48 && bw->buffer[0] == 0x808084FC && (bw->accum & 0xffff) == 0x8080; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 48 && (bw->accum & FLAC__U64L(0xffffffffffff)) == FLAC__U64L(0xFC8480808080); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x000000007FFFFFFF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x000000007FFFFFFF)); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 48 && bw->buffer[0] == 0xFDBFBFBF && (bw->accum & 0xffff) == 0xBFBF; -#else - ok = TOTAL_BITS(bw) == 48 && bw->buffer[0] == 0xBFBFBFFD && (bw->accum & 0xffff) == 0xBFBF; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 48 && (bw->accum & FLAC__U64L(0xffffffffffff)) == FLAC__U64L(0xFDBFBFBFBFBF); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x0000000080000000)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x0000000080000000)); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 56 && bw->buffer[0] == 0xFE828080 && (bw->accum & 0xffffff) == 0x808080; -#else - ok = TOTAL_BITS(bw) == 56 && bw->buffer[0] == 0x808082FE && (bw->accum & 0xffffff) == 0x808080; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 56 && (bw->accum & FLAC__U64L(0xffffffffffffff)) == FLAC__U64L(0xFE828080808080); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing utf8_uint64(0x0000000FFFFFFFFF)... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_utf8_uint64(bw, FLAC__U64L(0x0000000FFFFFFFFF)); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == 56 && bw->buffer[0] == 0xFEBFBFBF && (bw->accum & 0xffffff) == 0xBFBFBF; -#else - ok = TOTAL_BITS(bw) == 56 && bw->buffer[0] == 0xBFBFBFFE && (bw->accum & 0xffffff) == 0xBFBFBF; -#endif -#elif FLAC__BYTES_PER_WORD == 8 - ok = TOTAL_BITS(bw) == 56 && (bw->accum & FLAC__U64L(0xffffffffffffff)) == FLAC__U64L(0xFEBFBFBFBFBFBF); -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - - printf("testing grow... "); - FLAC__bitwriter_clear(bw); - FLAC__bitwriter_write_raw_uint32(bw, 0x5, 4); - j = bw->capacity; - for(i = 0; i < j; i++) - FLAC__bitwriter_write_raw_uint32(bw, 0xaaaaaaaa, 32); -#if FLAC__BYTES_PER_WORD == 4 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == i*32+4 && bw->buffer[0] == 0x5aaaaaaa && (bw->accum & 0xf) == 0xa; -#else - ok = TOTAL_BITS(bw) == i*32+4 && bw->buffer[0] == 0xaaaaaa5a && (bw->accum & 0xf) == 0xa; -#endif -#elif FLAC__BYTES_PER_WORD == 8 -#if WORDS_BIGENDIAN - ok = TOTAL_BITS(bw) == i*32+4 && bw->buffer[0] == FLAC__U64L(0x5aaaaaaaaaaaaaaa) && (bw->accum & 0xf) == 0xa; -#else - ok = TOTAL_BITS(bw) == i*32+4 && bw->buffer[0] == FLAC__U64L(0xaaaaaaaaaaaaaa5a) && (bw->accum & 0xf) == 0xa; -#endif -#endif - printf("%s\n", ok?"OK":"FAILED"); - if(!ok) { - FLAC__bitwriter_dump(bw, stdout); - return false; - } - printf("capacity = %u\n", bw->capacity); - - printf("testing free... "); - FLAC__bitwriter_free(bw); - printf("OK\n"); - - printf("testing delete... "); - FLAC__bitwriter_delete(bw); - printf("OK\n"); - - printf("\nPASSED!\n"); - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/bitwriter.h b/Engine/lib/flac/src/test_libFLAC/bitwriter.h deleted file mode 100644 index 9b6a82488..000000000 --- a/Engine/lib/flac/src/test_libFLAC/bitwriter.h +++ /dev/null @@ -1,27 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_BITBUFFER_H -#define FLAC__TEST_LIBFLAC_BITBUFFER_H - -#include "FLAC/ordinals.h" - -FLAC__bool test_bitwriter(void); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/crc.c b/Engine/lib/flac/src/test_libFLAC/crc.c deleted file mode 100644 index 8b8767119..000000000 --- a/Engine/lib/flac/src/test_libFLAC/crc.c +++ /dev/null @@ -1,274 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "FLAC/assert.h" -#include "share/compat.h" -#include "private/crc.h" -#include "crc.h" - -static FLAC__uint8 crc8_update_ref(FLAC__byte byte, FLAC__uint8 crc); -static FLAC__uint16 crc16_update_ref(FLAC__byte byte, FLAC__uint16 crc); - -static FLAC__bool test_crc8(const FLAC__byte *data, size_t size); -static FLAC__bool test_crc16(const FLAC__byte *data, size_t size); -static FLAC__bool test_crc16_update(const FLAC__byte *data, size_t size); -static FLAC__bool test_crc16_32bit_words(const FLAC__uint32 *words, size_t size); -static FLAC__bool test_crc16_64bit_words(const FLAC__uint64 *words, size_t size); - -#define DATA_SIZE 32768 - -FLAC__bool test_crc(void) -{ - uint32_t i; - FLAC__byte data[DATA_SIZE] = { 0 }; - - /* Initialize data reproducibly with pseudo-random values. */ - for (i = 1; i < DATA_SIZE; i++) - data[i] = crc8_update_ref(i % 256, data[i - 1]); - - printf("\n+++ libFLAC unit test: crc\n\n"); - - if (! test_crc8(data, DATA_SIZE)) - return false; - - if (! test_crc16(data, DATA_SIZE)) - return false; - - if (! test_crc16_update(data, DATA_SIZE)) - return false; - - if (! test_crc16_32bit_words((FLAC__uint32 *)data, DATA_SIZE / 4)) - return false; - - if (! test_crc16_64bit_words((FLAC__uint64 *)data, DATA_SIZE / 8)) - return false; - - printf("\nPASSED!\n"); - return true; -} - -/*----------------------------------------------------------------------------*/ - -/* Reference implementations of CRC-8 and CRC-16 to check against. */ - -#define CRC8_POLYNOMIAL 0x07 - -static FLAC__uint8 crc8_update_ref(FLAC__byte byte, FLAC__uint8 crc) -{ - uint32_t i; - - crc ^= byte; - - for (i = 0; i < 8; i++) { - crc = (crc << 1) ^ ((crc >> 7) ? CRC8_POLYNOMIAL : 0); - } - - return crc; -} - -#define CRC16_POLYNOMIAL 0x8005 - -static FLAC__uint16 crc16_update_ref(FLAC__byte byte, FLAC__uint16 crc) -{ - uint32_t i; - - crc ^= byte << 8; - - for (i = 0; i < 8; i++) { - crc = (crc << 1) ^ ((crc >> 15) ? CRC16_POLYNOMIAL : 0); - } - - return crc; -} - -/*----------------------------------------------------------------------------*/ - -static FLAC__bool test_crc8(const FLAC__byte *data, size_t size) -{ - uint32_t i; - FLAC__uint8 crc0,crc1; - - printf("testing FLAC__crc8 ... "); - - crc0 = 0; - crc1 = FLAC__crc8(data, 0); - - if (crc1 != crc0) { - printf("FAILED, FLAC__crc8 returned non-zero CRC for zero bytes of data\n"); - return false; - } - - for (i = 0; i < size; i++) { - crc0 = crc8_update_ref(data[i], crc0); - crc1 = FLAC__crc8(data, i + 1); - - if (crc1 != crc0) { - printf("FAILED, FLAC__crc8 result did not match reference CRC for %u bytes of test data\n", i + 1); - return false; - } - } - - printf("OK\n"); - - return true; -} - -static FLAC__bool test_crc16(const FLAC__byte *data, size_t size) -{ - uint32_t i; - FLAC__uint16 crc0,crc1; - - printf("testing FLAC__crc16 ... "); - - crc0 = 0; - crc1 = FLAC__crc16(data, 0); - - if (crc1 != crc0) { - printf("FAILED, FLAC__crc16 returned non-zero CRC for zero bytes of data\n"); - return false; - } - - for (i = 0; i < size; i++) { - crc0 = crc16_update_ref(data[i], crc0); - crc1 = FLAC__crc16(data, i + 1); - - if (crc1 != crc0) { - printf("FAILED, FLAC__crc16 result did not match reference CRC for %u bytes of test data\n", i + 1); - return false; - } - } - - printf("OK\n"); - - return true; -} - -static FLAC__bool test_crc16_update(const FLAC__byte *data, size_t size) -{ - uint32_t i; - FLAC__uint16 crc0,crc1; - - printf("testing FLAC__CRC16_UPDATE macro ... "); - - crc0 = 0; - crc1 = 0; - - for (i = 0; i < size; i++) { - crc0 = crc16_update_ref(data[i], crc0); - crc1 = FLAC__CRC16_UPDATE(data[i], crc1); - - if (crc1 != crc0) { - printf("FAILED, FLAC__CRC16_UPDATE result did not match reference CRC after %u bytes of test data\n", i + 1); - return false; - } - } - - printf("OK\n"); - - return true; -} - -static FLAC__bool test_crc16_32bit_words(const FLAC__uint32 *words, size_t size) -{ - uint32_t n,i,k; - FLAC__uint16 crc0,crc1; - - for (n = 1; n <= 16; n++) { - printf("testing FLAC__crc16_update_words32 (length=%i) ... ", n); - - crc0 = 0; - crc1 = 0; - - for (i = 0; i <= size - n; i += n) { - for (k = 0; k < n; k++) { - crc0 = crc16_update_ref( words[i + k] >> 24, crc0); - crc0 = crc16_update_ref((words[i + k] >> 16) & 0xFF, crc0); - crc0 = crc16_update_ref((words[i + k] >> 8) & 0xFF, crc0); - crc0 = crc16_update_ref( words[i + k] & 0xFF, crc0); - } - - crc1 = FLAC__crc16_update_words32(words + i, n, crc1); - - if (crc1 != crc0) { - printf("FAILED, FLAC__crc16_update_words32 result did not match reference CRC after %u words of test data\n", i + n); - return false; - } - } - - crc1 = FLAC__crc16_update_words32(words, 0, crc1); - - if (crc1 != crc0) { - printf("FAILED, FLAC__crc16_update_words32 called with zero bytes changed CRC value\n"); - return false; - } - - printf("OK\n"); - } - - return true; -} - -static FLAC__bool test_crc16_64bit_words(const FLAC__uint64 *words, size_t size) -{ - uint32_t n,i,k; - FLAC__uint16 crc0,crc1; - - for (n = 1; n <= 16; n++) { - printf("testing FLAC__crc16_update_words64 (length=%i) ... ", n); - - crc0 = 0; - crc1 = 0; - - for (i = 0; i <= size - n; i += n) { - for (k = 0; k < n; k++) { - crc0 = crc16_update_ref( words[i + k] >> 56, crc0); - crc0 = crc16_update_ref((words[i + k] >> 48) & 0xFF, crc0); - crc0 = crc16_update_ref((words[i + k] >> 40) & 0xFF, crc0); - crc0 = crc16_update_ref((words[i + k] >> 32) & 0xFF, crc0); - crc0 = crc16_update_ref((words[i + k] >> 24) & 0xFF, crc0); - crc0 = crc16_update_ref((words[i + k] >> 16) & 0xFF, crc0); - crc0 = crc16_update_ref((words[i + k] >> 8) & 0xFF, crc0); - crc0 = crc16_update_ref( words[i + k] & 0xFF, crc0); - } - - crc1 = FLAC__crc16_update_words64(words + i, n, crc1); - - if (crc1 != crc0) { - printf("FAILED, FLAC__crc16_update_words64 result did not match reference CRC after %u words of test data\n", i + n); - return false; - } - } - - crc1 = FLAC__crc16_update_words64(words, 0, crc1); - - if (crc1 != crc0) { - printf("FAILED, FLAC__crc16_update_words64 called with zero bytes changed CRC value\n"); - return false; - } - - printf("OK\n"); - } - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/crc.h b/Engine/lib/flac/src/test_libFLAC/crc.h deleted file mode 100644 index 11523cd89..000000000 --- a/Engine/lib/flac/src/test_libFLAC/crc.h +++ /dev/null @@ -1,26 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_CRC_H -#define FLAC__TEST_LIBFLAC_CRC_H - -#include "FLAC/ordinals.h" - -FLAC__bool test_crc(void); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/decoders.c b/Engine/lib/flac/src/test_libFLAC/decoders.c deleted file mode 100644 index ae114ceda..000000000 --- a/Engine/lib/flac/src/test_libFLAC/decoders.c +++ /dev/null @@ -1,1054 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include "decoders.h" -#include "FLAC/assert.h" -#include "FLAC/stream_decoder.h" -#include "share/grabbag.h" -#include "share/compat.h" -#include "share/safe_str.h" -#include "test_libs_common/file_utils_flac.h" -#include "test_libs_common/metadata_utils.h" - -typedef enum { - LAYER_STREAM = 0, /* FLAC__stream_decoder_init_[ogg_]stream() without seeking */ - LAYER_SEEKABLE_STREAM, /* FLAC__stream_decoder_init_[ogg_]stream() with seeking */ - LAYER_FILE, /* FLAC__stream_decoder_init_[ogg_]FILE() */ - LAYER_FILENAME /* FLAC__stream_decoder_init_[ogg_]file() */ -} Layer; - -static const char * const LayerString[] = { - "Stream", - "Seekable Stream", - "FILE*", - "Filename" -}; - -typedef struct { - Layer layer; - FILE *file; - char filename[512]; - uint32_t current_metadata_number; - FLAC__bool ignore_errors; - FLAC__bool error_occurred; -} StreamDecoderClientData; - -static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_; -static FLAC__StreamMetadata *expected_metadata_sequence_[9]; -static uint32_t num_expected_; -static FLAC__off_t flacfilesize_; - -static const char *flacfilename(FLAC__bool is_ogg) -{ - return is_ogg? "metadata.oga" : "metadata.flac"; -} - -static FLAC__bool die_(const char *msg) -{ - printf("ERROR: %s\n", msg); - return false; -} - -static FLAC__bool die_s_(const char *msg, const FLAC__StreamDecoder *decoder) -{ - FLAC__StreamDecoderState state = FLAC__stream_decoder_get_state(decoder); - - if(msg) - printf("FAILED, %s", msg); - else - printf("FAILED"); - - printf(", state = %u (%s)\n", (uint32_t)state, FLAC__StreamDecoderStateString[state]); - - return false; -} - -static void open_test_file(StreamDecoderClientData * pdcd, int is_ogg, const char * mode) -{ - pdcd->file = flac_fopen(flacfilename(is_ogg), mode); - safe_strncpy(pdcd->filename, flacfilename(is_ogg), sizeof (pdcd->filename)); -} - -static void init_metadata_blocks_(void) -{ - mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_); -} - -static void free_metadata_blocks_(void) -{ - mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_); -} - -static FLAC__bool generate_file_(FLAC__bool is_ogg) -{ - printf("\n\ngenerating %sFLAC file for decoder tests...\n", is_ogg? "Ogg ":""); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - /* WATCHOUT: for Ogg FLAC the encoder should move the VORBIS_COMMENT block to the front, right after STREAMINFO */ - - if(!file_utils__generate_flacfile(is_ogg, flacfilename(is_ogg), &flacfilesize_, 512 * 1024, &streaminfo_, expected_metadata_sequence_, num_expected_)) - return die_("creating the encoded file"); - - return true; -} - -static FLAC__StreamDecoderReadStatus stream_decoder_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - StreamDecoderClientData *dcd = (StreamDecoderClientData*)client_data; - const size_t requested_bytes = *bytes; - - (void)decoder; - - if(0 == dcd) { - printf("ERROR: client_data in read callback is NULL\n"); - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - } - - if(dcd->error_occurred) - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - - if(feof(dcd->file)) { - *bytes = 0; - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } - else if(requested_bytes > 0) { - *bytes = fread(buffer, 1, requested_bytes, dcd->file); - if(*bytes == 0) { - if(feof(dcd->file)) - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - else - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - } - else { - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - } - else - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */ -} - -static FLAC__StreamDecoderSeekStatus stream_decoder_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) -{ - StreamDecoderClientData *dcd = (StreamDecoderClientData*)client_data; - - (void)decoder; - - if(0 == dcd) { - printf("ERROR: client_data in seek callback is NULL\n"); - return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - } - - if(dcd->error_occurred) - return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - - if(fseeko(dcd->file, (FLAC__off_t)absolute_byte_offset, SEEK_SET) < 0) { - dcd->error_occurred = true; - return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - } - - return FLAC__STREAM_DECODER_SEEK_STATUS_OK; -} - -static FLAC__StreamDecoderTellStatus stream_decoder_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) -{ - StreamDecoderClientData *dcd = (StreamDecoderClientData*)client_data; - FLAC__off_t offset; - - (void)decoder; - - if(0 == dcd) { - printf("ERROR: client_data in tell callback is NULL\n"); - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - } - - if(dcd->error_occurred) - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - - offset = ftello(dcd->file); - *absolute_byte_offset = (FLAC__uint64)offset; - - if(offset < 0) { - dcd->error_occurred = true; - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - } - - return FLAC__STREAM_DECODER_TELL_STATUS_OK; -} - -static FLAC__StreamDecoderLengthStatus stream_decoder_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) -{ - StreamDecoderClientData *dcd = (StreamDecoderClientData*)client_data; - - (void)decoder; - - if(0 == dcd) { - printf("ERROR: client_data in length callback is NULL\n"); - return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; - } - - if(dcd->error_occurred) - return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; - - *stream_length = (FLAC__uint64)flacfilesize_; - return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; -} - -static FLAC__bool stream_decoder_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data) -{ - StreamDecoderClientData *dcd = (StreamDecoderClientData*)client_data; - - (void)decoder; - - if(0 == dcd) { - printf("ERROR: client_data in eof callback is NULL\n"); - return true; - } - - if(dcd->error_occurred) - return true; - - return feof(dcd->file); -} - -static FLAC__StreamDecoderWriteStatus stream_decoder_write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - StreamDecoderClientData *dcd = (StreamDecoderClientData*)client_data; - - (void)decoder, (void)buffer; - - if(0 == dcd) { - printf("ERROR: client_data in write callback is NULL\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - if(dcd->error_occurred) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - - if( - (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER && frame->header.number.frame_number == 0) || - (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER && frame->header.number.sample_number == 0) - ) { - printf("content... "); - fflush(stdout); - } - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -static void stream_decoder_metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - StreamDecoderClientData *dcd = (StreamDecoderClientData*)client_data; - - (void)decoder; - - if(0 == dcd) { - printf("ERROR: client_data in metadata callback is NULL\n"); - return; - } - - if(dcd->error_occurred) - return; - - if (metadata->type == FLAC__METADATA_TYPE_APPLICATION) { - printf ("%u ('%c%c%c%c')... ", dcd->current_metadata_number, metadata->data.application.id [0], metadata->data.application.id [1], metadata->data.application.id [2], metadata->data.application.id [3]); - } - else { - printf("%u... ", dcd->current_metadata_number); - } - fflush(stdout); - - - if(dcd->current_metadata_number >= num_expected_) { - (void)die_("got more metadata blocks than expected"); - dcd->error_occurred = true; - } - else { - if(!mutils__compare_block(expected_metadata_sequence_[dcd->current_metadata_number], metadata)) { - (void)die_("metadata block mismatch"); - dcd->error_occurred = true; - } - } - dcd->current_metadata_number++; -} - -static void stream_decoder_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - StreamDecoderClientData *dcd = (StreamDecoderClientData*)client_data; - - (void)decoder; - - if(0 == dcd) { - printf("ERROR: client_data in error callback is NULL\n"); - return; - } - - if(!dcd->ignore_errors) { - printf("ERROR: got error callback: err = %u (%s)\n", (uint32_t)status, FLAC__StreamDecoderErrorStatusString[status]); - dcd->error_occurred = true; - } -} - -static FLAC__bool stream_decoder_test_respond_(FLAC__StreamDecoder *decoder, StreamDecoderClientData *dcd, FLAC__bool is_ogg) -{ - FLAC__StreamDecoderInitStatus init_status; - - if(!FLAC__stream_decoder_set_md5_checking(decoder, true)) - return die_s_("at FLAC__stream_decoder_set_md5_checking(), returned false", decoder); - - /* for FLAC__stream_encoder_init_FILE(), the FLAC__stream_encoder_finish() closes the file so we have to keep re-opening: */ - if(dcd->layer == LAYER_FILE) { - printf("opening %sFLAC file... ", is_ogg? "Ogg ":""); - open_test_file(dcd, is_ogg, "rb"); - if(0 == dcd->file) { - printf("ERROR (%s)\n", strerror(errno)); - return false; - } - printf("OK\n"); - } - - switch(dcd->layer) { - case LAYER_STREAM: - printf("testing FLAC__stream_decoder_init_%sstream()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_stream(decoder, stream_decoder_read_callback_, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, /*eof_callback=*/0, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, dcd) : - FLAC__stream_decoder_init_stream(decoder, stream_decoder_read_callback_, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, /*eof_callback=*/0, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, dcd) - ; - break; - case LAYER_SEEKABLE_STREAM: - printf("testing FLAC__stream_decoder_init_%sstream()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_stream(decoder, stream_decoder_read_callback_, stream_decoder_seek_callback_, stream_decoder_tell_callback_, stream_decoder_length_callback_, stream_decoder_eof_callback_, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, dcd) : - FLAC__stream_decoder_init_stream(decoder, stream_decoder_read_callback_, stream_decoder_seek_callback_, stream_decoder_tell_callback_, stream_decoder_length_callback_, stream_decoder_eof_callback_, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, dcd); - break; - case LAYER_FILE: - printf("testing FLAC__stream_decoder_init_%sFILE()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_FILE(decoder, dcd->file, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, dcd) : - FLAC__stream_decoder_init_FILE(decoder, dcd->file, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, dcd); - break; - case LAYER_FILENAME: - printf("testing FLAC__stream_decoder_init_%sfile()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_file(decoder, flacfilename(is_ogg), stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, dcd) : - FLAC__stream_decoder_init_file(decoder, flacfilename(is_ogg), stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, dcd); - break; - default: - die_("internal error 000"); - return false; - } - if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) - return die_s_(0, decoder); - printf("OK\n"); - - dcd->current_metadata_number = 0; - - if(dcd->layer < LAYER_FILE && fseeko(dcd->file, 0, SEEK_SET) < 0) { - printf("FAILED rewinding input, errno = %d\n", errno); - return false; - } - - printf("testing FLAC__stream_decoder_process_until_end_of_stream()... "); - if(!FLAC__stream_decoder_process_until_end_of_stream(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_finish()... "); - if(!FLAC__stream_decoder_finish(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - return true; -} - -static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg) -{ - FLAC__StreamDecoder *decoder; - FLAC__StreamDecoderInitStatus init_status; - FLAC__StreamDecoderState state; - StreamDecoderClientData decoder_client_data; - FLAC__bool expect; - - decoder_client_data.layer = layer; - - printf("\n+++ libFLAC unit test: FLAC__StreamDecoder (layer: %s, format: %s)\n\n", LayerString[layer], is_ogg? "Ogg FLAC" : "FLAC"); - - printf("testing FLAC__stream_decoder_new()... "); - decoder = FLAC__stream_decoder_new(); - if(0 == decoder) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_decoder_delete()... "); - FLAC__stream_decoder_delete(decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_new()... "); - decoder = FLAC__stream_decoder_new(); - if(0 == decoder) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - switch(layer) { - case LAYER_STREAM: - case LAYER_SEEKABLE_STREAM: - printf("testing FLAC__stream_decoder_init_%sstream()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_stream(decoder, 0, 0, 0, 0, 0, 0, 0, 0, 0) : - FLAC__stream_decoder_init_stream(decoder, 0, 0, 0, 0, 0, 0, 0, 0, 0); - break; - case LAYER_FILE: - printf("testing FLAC__stream_decoder_init_%sFILE()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_FILE(decoder, stdin, 0, 0, 0, 0) : - FLAC__stream_decoder_init_FILE(decoder, stdin, 0, 0, 0, 0); - break; - case LAYER_FILENAME: - printf("testing FLAC__stream_decoder_init_%sfile()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_file(decoder, flacfilename(is_ogg), 0, 0, 0, 0) : - FLAC__stream_decoder_init_file(decoder, flacfilename(is_ogg), 0, 0, 0, 0); - break; - default: - die_("internal error 003"); - return false; - } - if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS) - return die_s_(0, decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_delete()... "); - FLAC__stream_decoder_delete(decoder); - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - - printf("testing FLAC__stream_decoder_new()... "); - decoder = FLAC__stream_decoder_new(); - if(0 == decoder) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - if(is_ogg) { - printf("testing FLAC__stream_decoder_set_ogg_serial_number()... "); - if(!FLAC__stream_decoder_set_ogg_serial_number(decoder, file_utils__ogg_serial_number)) - return die_s_("returned false", decoder); - printf("OK\n"); - } - - printf("testing FLAC__stream_decoder_set_md5_checking()... "); - if(!FLAC__stream_decoder_set_md5_checking(decoder, true)) - return die_s_("returned false", decoder); - printf("OK\n"); - - if(layer < LAYER_FILENAME) { - printf("opening %sFLAC file... ", is_ogg? "Ogg ":""); - open_test_file(&decoder_client_data, is_ogg, "rb"); - if(0 == decoder_client_data.file) { - printf("ERROR (%s)\n", strerror(errno)); - return false; - } - printf("OK\n"); - } - - switch(layer) { - case LAYER_STREAM: - printf("testing FLAC__stream_decoder_init_%sstream()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_stream(decoder, stream_decoder_read_callback_, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, /*eof_callback=*/0, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, &decoder_client_data) : - FLAC__stream_decoder_init_stream(decoder, stream_decoder_read_callback_, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, /*eof_callback=*/0, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, &decoder_client_data); - break; - case LAYER_SEEKABLE_STREAM: - printf("testing FLAC__stream_decoder_init_%sstream()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_stream(decoder, stream_decoder_read_callback_, stream_decoder_seek_callback_, stream_decoder_tell_callback_, stream_decoder_length_callback_, stream_decoder_eof_callback_, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, &decoder_client_data) : - FLAC__stream_decoder_init_stream(decoder, stream_decoder_read_callback_, stream_decoder_seek_callback_, stream_decoder_tell_callback_, stream_decoder_length_callback_, stream_decoder_eof_callback_, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, &decoder_client_data); - break; - case LAYER_FILE: - printf("testing FLAC__stream_decoder_init_%sFILE()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_FILE(decoder, decoder_client_data.file, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, &decoder_client_data) : - FLAC__stream_decoder_init_FILE(decoder, decoder_client_data.file, stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, &decoder_client_data); - break; - case LAYER_FILENAME: - printf("testing FLAC__stream_decoder_init_%sfile()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_decoder_init_ogg_file(decoder, flacfilename(is_ogg), stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, &decoder_client_data) : - FLAC__stream_decoder_init_file(decoder, flacfilename(is_ogg), stream_decoder_write_callback_, stream_decoder_metadata_callback_, stream_decoder_error_callback_, &decoder_client_data); - break; - default: - die_("internal error 009"); - return false; - } - if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) - return die_s_(0, decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_get_state()... "); - state = FLAC__stream_decoder_get_state(decoder); - printf("returned state = %u (%s)... OK\n", state, FLAC__StreamDecoderStateString[state]); - - decoder_client_data.current_metadata_number = 0; - decoder_client_data.ignore_errors = false; - decoder_client_data.error_occurred = false; - - printf("testing FLAC__stream_decoder_get_md5_checking()... "); - if(!FLAC__stream_decoder_get_md5_checking(decoder)) { - printf("FAILED, returned false, expected true\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_decoder_process_until_end_of_metadata()... "); - if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_process_single()... "); - if(!FLAC__stream_decoder_process_single(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_skip_single_frame()... "); - if(!FLAC__stream_decoder_skip_single_frame(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - if(layer < LAYER_FILE) { - printf("testing FLAC__stream_decoder_flush()... "); - if(!FLAC__stream_decoder_flush(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - decoder_client_data.ignore_errors = true; - printf("testing FLAC__stream_decoder_process_single()... "); - if(!FLAC__stream_decoder_process_single(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - decoder_client_data.ignore_errors = false; - } - - expect = (layer != LAYER_STREAM); - printf("testing FLAC__stream_decoder_seek_absolute()... "); - if(FLAC__stream_decoder_seek_absolute(decoder, 0) != expect) - return die_s_(expect? "returned false" : "returned true", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_process_until_end_of_stream()... "); - if(!FLAC__stream_decoder_process_until_end_of_stream(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - expect = (layer != LAYER_STREAM); - printf("testing FLAC__stream_decoder_seek_absolute()... "); - if(FLAC__stream_decoder_seek_absolute(decoder, 0) != expect) - return die_s_(expect? "returned false" : "returned true", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_get_channels()... "); - { - uint32_t channels = FLAC__stream_decoder_get_channels(decoder); - if(channels != streaminfo_.data.stream_info.channels) { - printf("FAILED, returned %u, expected %u\n", channels, streaminfo_.data.stream_info.channels); - return false; - } - } - printf("OK\n"); - - printf("testing FLAC__stream_decoder_get_bits_per_sample()... "); - { - uint32_t bits_per_sample = FLAC__stream_decoder_get_bits_per_sample(decoder); - if(bits_per_sample != streaminfo_.data.stream_info.bits_per_sample) { - printf("FAILED, returned %u, expected %u\n", bits_per_sample, streaminfo_.data.stream_info.bits_per_sample); - return false; - } - } - printf("OK\n"); - - printf("testing FLAC__stream_decoder_get_sample_rate()... "); - { - uint32_t sample_rate = FLAC__stream_decoder_get_sample_rate(decoder); - if(sample_rate != streaminfo_.data.stream_info.sample_rate) { - printf("FAILED, returned %u, expected %u\n", sample_rate, streaminfo_.data.stream_info.sample_rate); - return false; - } - } - printf("OK\n"); - - printf("testing FLAC__stream_decoder_get_blocksize()... "); - { - uint32_t blocksize = FLAC__stream_decoder_get_blocksize(decoder); - /* value could be anything since we're at the last block, so accept any reasonable answer */ - printf("returned %u... %s\n", blocksize, blocksize>0? "OK" : "FAILED"); - if(blocksize == 0) - return false; - } - - printf("testing FLAC__stream_decoder_get_channel_assignment()... "); - { - FLAC__ChannelAssignment ca = FLAC__stream_decoder_get_channel_assignment(decoder); - printf("returned %u (%s)... OK\n", (uint32_t)ca, FLAC__ChannelAssignmentString[ca]); - } - - if(layer < LAYER_FILE) { - printf("testing FLAC__stream_decoder_reset()... "); - if(!FLAC__stream_decoder_reset(decoder)) { - state = FLAC__stream_decoder_get_state(decoder); - printf("FAILED, returned false, state = %u (%s)\n", state, FLAC__StreamDecoderStateString[state]); - return false; - } - printf("OK\n"); - - if(layer == LAYER_STREAM) { - /* after a reset() we have to rewind the input ourselves */ - printf("rewinding input... "); - if(fseeko(decoder_client_data.file, 0, SEEK_SET) < 0) { - printf("FAILED, errno = %d\n", errno); - return false; - } - printf("OK\n"); - } - - decoder_client_data.current_metadata_number = 0; - - printf("testing FLAC__stream_decoder_process_until_end_of_stream()... "); - if(!FLAC__stream_decoder_process_until_end_of_stream(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - } - - printf("testing FLAC__stream_decoder_finish()... "); - if(!FLAC__stream_decoder_finish(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - /* - * respond all - */ - - printf("testing FLAC__stream_decoder_set_metadata_respond_all()... "); - if(!FLAC__stream_decoder_set_metadata_respond_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * ignore all - */ - - printf("testing FLAC__stream_decoder_set_metadata_ignore_all()... "); - if(!FLAC__stream_decoder_set_metadata_ignore_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * respond all, ignore VORBIS_COMMENT - */ - - printf("testing FLAC__stream_decoder_set_metadata_respond_all()... "); - if(!FLAC__stream_decoder_set_metadata_respond_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_ignore(VORBIS_COMMENT)... "); - if(!FLAC__stream_decoder_set_metadata_ignore(decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - if(!is_ogg) /* encoder removes seektable for ogg */ - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * respond all, ignore APPLICATION - */ - - printf("testing FLAC__stream_decoder_set_metadata_respond_all()... "); - if(!FLAC__stream_decoder_set_metadata_respond_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_ignore(APPLICATION)... "); - if(!FLAC__stream_decoder_set_metadata_ignore(decoder, FLAC__METADATA_TYPE_APPLICATION)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * respond all, ignore APPLICATION id of app#1 - */ - - printf("testing FLAC__stream_decoder_set_metadata_respond_all()... "); - if(!FLAC__stream_decoder_set_metadata_respond_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_ignore_application(of app block #1)... "); - if(!FLAC__stream_decoder_set_metadata_ignore_application(decoder, application1_.data.application.id)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application2_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * respond all, ignore APPLICATION id of app#1 & app#2 - */ - - printf("testing FLAC__stream_decoder_set_metadata_respond_all()... "); - if(!FLAC__stream_decoder_set_metadata_respond_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_ignore_application(of app block #1)... "); - if(!FLAC__stream_decoder_set_metadata_ignore_application(decoder, application1_.data.application.id)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_ignore_application(of app block #2)... "); - if(!FLAC__stream_decoder_set_metadata_ignore_application(decoder, application2_.data.application.id)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * ignore all, respond VORBIS_COMMENT - */ - - printf("testing FLAC__stream_decoder_set_metadata_ignore_all()... "); - if(!FLAC__stream_decoder_set_metadata_ignore_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_respond(VORBIS_COMMENT)... "); - if(!FLAC__stream_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * ignore all, respond APPLICATION - */ - - printf("testing FLAC__stream_decoder_set_metadata_ignore_all()... "); - if(!FLAC__stream_decoder_set_metadata_ignore_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_respond(APPLICATION)... "); - if(!FLAC__stream_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_APPLICATION)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * ignore all, respond APPLICATION id of app#1 - */ - - printf("testing FLAC__stream_decoder_set_metadata_ignore_all()... "); - if(!FLAC__stream_decoder_set_metadata_ignore_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_respond_application(of app block #1)... "); - if(!FLAC__stream_decoder_set_metadata_respond_application(decoder, application1_.data.application.id)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &application1_; - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * ignore all, respond APPLICATION id of app#1 & app#2 - */ - - printf("testing FLAC__stream_decoder_set_metadata_ignore_all()... "); - if(!FLAC__stream_decoder_set_metadata_ignore_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_respond_application(of app block #1)... "); - if(!FLAC__stream_decoder_set_metadata_respond_application(decoder, application1_.data.application.id)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_respond_application(of app block #2)... "); - if(!FLAC__stream_decoder_set_metadata_respond_application(decoder, application2_.data.application.id)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &application2_; - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * respond all, ignore APPLICATION, respond APPLICATION id of app#1 - */ - - printf("testing FLAC__stream_decoder_set_metadata_respond_all()... "); - if(!FLAC__stream_decoder_set_metadata_respond_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_ignore(APPLICATION)... "); - if(!FLAC__stream_decoder_set_metadata_ignore(decoder, FLAC__METADATA_TYPE_APPLICATION)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_respond_application(of app block #1)... "); - if(!FLAC__stream_decoder_set_metadata_respond_application(decoder, application1_.data.application.id)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - if(is_ogg) { /* encoder moves vorbis comment after streaminfo according to ogg mapping. Also removes the seektable */ - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - else { - expected_metadata_sequence_[num_expected_++] = &streaminfo_; - expected_metadata_sequence_[num_expected_++] = &padding_; - expected_metadata_sequence_[num_expected_++] = &seektable_; - expected_metadata_sequence_[num_expected_++] = &application1_; - expected_metadata_sequence_[num_expected_++] = &vorbiscomment_; - expected_metadata_sequence_[num_expected_++] = &cuesheet_; - expected_metadata_sequence_[num_expected_++] = &picture_; - expected_metadata_sequence_[num_expected_++] = &unknown_; - } - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - /* - * ignore all, respond APPLICATION, ignore APPLICATION id of app#1 - */ - - printf("testing FLAC__stream_decoder_set_metadata_ignore_all()... "); - if(!FLAC__stream_decoder_set_metadata_ignore_all(decoder)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_respond(APPLICATION)... "); - if(!FLAC__stream_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_APPLICATION)) - return die_s_("returned false", decoder); - printf("OK\n"); - - printf("testing FLAC__stream_decoder_set_metadata_ignore_application(of app block #1)... "); - if(!FLAC__stream_decoder_set_metadata_ignore_application(decoder, application1_.data.application.id)) - return die_s_("returned false", decoder); - printf("OK\n"); - - num_expected_ = 0; - expected_metadata_sequence_[num_expected_++] = &application2_; - - if(!stream_decoder_test_respond_(decoder, &decoder_client_data, is_ogg)) - return false; - - if(layer < LAYER_FILE) /* for LAYER_FILE, FLAC__stream_decoder_finish() closes the file */ - fclose(decoder_client_data.file); - - printf("testing FLAC__stream_decoder_delete()... "); - FLAC__stream_decoder_delete(decoder); - printf("OK\n"); - - printf("\nPASSED!\n"); - - return true; -} - -FLAC__bool test_decoders(void) -{ - FLAC__bool is_ogg = false; - - while(1) { - init_metadata_blocks_(); - - if(!generate_file_(is_ogg)) - return false; - - if(!test_stream_decoder(LAYER_STREAM, is_ogg)) - return false; - - if(!test_stream_decoder(LAYER_SEEKABLE_STREAM, is_ogg)) - return false; - - if(!test_stream_decoder(LAYER_FILE, is_ogg)) - return false; - - if(!test_stream_decoder(LAYER_FILENAME, is_ogg)) - return false; - - (void) grabbag__file_remove_file(flacfilename(is_ogg)); - - free_metadata_blocks_(); - - if(!FLAC_API_SUPPORTS_OGG_FLAC || is_ogg) - break; - is_ogg = true; - } - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/decoders.h b/Engine/lib/flac/src/test_libFLAC/decoders.h deleted file mode 100644 index 431eb176d..000000000 --- a/Engine/lib/flac/src/test_libFLAC/decoders.h +++ /dev/null @@ -1,27 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_DECODERS_H -#define FLAC__TEST_LIBFLAC_DECODERS_H - -#include "FLAC/ordinals.h" - -FLAC__bool test_decoders(void); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/encoders.c b/Engine/lib/flac/src/test_libFLAC/encoders.c deleted file mode 100644 index d3fd39dd7..000000000 --- a/Engine/lib/flac/src/test_libFLAC/encoders.c +++ /dev/null @@ -1,530 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include "encoders.h" -#include "FLAC/assert.h" -#include "FLAC/stream_encoder.h" -#include "share/grabbag.h" -#include "share/compat.h" -#include "test_libs_common/file_utils_flac.h" -#include "test_libs_common/metadata_utils.h" - -typedef enum { - LAYER_STREAM = 0, /* FLAC__stream_encoder_init_[ogg_]stream() without seeking */ - LAYER_SEEKABLE_STREAM, /* FLAC__stream_encoder_init_[ogg_]stream() with seeking */ - LAYER_FILE, /* FLAC__stream_encoder_init_[ogg_]FILE() */ - LAYER_FILENAME /* FLAC__stream_encoder_init_[ogg_]file() */ -} Layer; - -static const char * const LayerString[] = { - "Stream", - "Seekable Stream", - "FILE*", - "Filename" -}; - -static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_; -static FLAC__StreamMetadata *metadata_sequence_[] = { &vorbiscomment_, &padding_, &seektable_, &application1_, &application2_, &cuesheet_, &picture_, &unknown_ }; -static const uint32_t num_metadata_ = sizeof(metadata_sequence_) / sizeof(metadata_sequence_[0]); - -static const char *flacfilename(FLAC__bool is_ogg) -{ - return is_ogg? "metadata.oga" : "metadata.flac"; -} - -static FLAC__bool die_(const char *msg) -{ - printf("ERROR: %s\n", msg); - return false; -} - -static FLAC__bool die_s_(const char *msg, const FLAC__StreamEncoder *encoder) -{ - FLAC__StreamEncoderState state = FLAC__stream_encoder_get_state(encoder); - - if(msg) - printf("FAILED, %s", msg); - else - printf("FAILED"); - - printf(", state = %u (%s)\n", (uint32_t)state, FLAC__StreamEncoderStateString[state]); - if(state == FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) { - FLAC__StreamDecoderState dstate = FLAC__stream_encoder_get_verify_decoder_state(encoder); - printf(" verify decoder state = %u (%s)\n", (uint32_t)dstate, FLAC__StreamDecoderStateString[dstate]); - } - - return false; -} - -static void init_metadata_blocks_(void) -{ - mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_); -} - -static void free_metadata_blocks_(void) -{ - mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_); -} - -static FLAC__StreamEncoderReadStatus stream_encoder_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - FILE *f = (FILE*)client_data; - (void)encoder; - if(*bytes > 0) { - *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, f); - if(ferror(f)) - return FLAC__STREAM_ENCODER_READ_STATUS_ABORT; - else if(*bytes == 0) - return FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM; - else - return FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE; - } - else - return FLAC__STREAM_ENCODER_READ_STATUS_ABORT; -} - -static FLAC__StreamEncoderWriteStatus stream_encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) -{ - FILE *f = (FILE*)client_data; - (void)encoder, (void)samples, (void)current_frame; - if(fwrite(buffer, 1, bytes, f) != bytes) - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - else - return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; -} - -static FLAC__StreamEncoderSeekStatus stream_encoder_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) -{ - FILE *f = (FILE*)client_data; - (void)encoder; - if(fseeko(f, (long)absolute_byte_offset, SEEK_SET) < 0) - return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR; - else - return FLAC__STREAM_ENCODER_SEEK_STATUS_OK; -} - -static FLAC__StreamEncoderTellStatus stream_encoder_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) -{ - FILE *f = (FILE*)client_data; - FLAC__off_t pos; - (void)encoder; - if((pos = ftello(f)) < 0) - return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR; - else { - *absolute_byte_offset = (FLAC__uint64)pos; - return FLAC__STREAM_ENCODER_TELL_STATUS_OK; - } -} - -static void stream_encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - (void)encoder, (void)metadata, (void)client_data; -} - -static void stream_encoder_progress_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data) -{ - (void)encoder, (void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate, (void)client_data; -} - -static FLAC__bool test_stream_encoder(Layer layer, FLAC__bool is_ogg) -{ - FLAC__StreamEncoder *encoder; - FLAC__StreamEncoderInitStatus init_status; - FLAC__StreamEncoderState state; - FLAC__StreamDecoderState dstate; - FILE *file = 0; - FLAC__int32 samples[1024]; - FLAC__int32 *samples_array[1]; - uint32_t i; - - samples_array[0] = samples; - - printf("\n+++ libFLAC unit test: FLAC__StreamEncoder (layer: %s, format: %s)\n\n", LayerString[layer], is_ogg? "Ogg FLAC":"FLAC"); - - printf("testing FLAC__stream_encoder_new()... "); - encoder = FLAC__stream_encoder_new(); - if(0 == encoder) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - if(is_ogg) { - printf("testing FLAC__stream_encoder_set_ogg_serial_number()... "); - if(!FLAC__stream_encoder_set_ogg_serial_number(encoder, file_utils__ogg_serial_number)) - return die_s_("returned false", encoder); - printf("OK\n"); - } - - printf("testing FLAC__stream_encoder_set_verify()... "); - if(!FLAC__stream_encoder_set_verify(encoder, true)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_streamable_subset()... "); - if(!FLAC__stream_encoder_set_streamable_subset(encoder, true)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_channels()... "); - if(!FLAC__stream_encoder_set_channels(encoder, streaminfo_.data.stream_info.channels)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_bits_per_sample()... "); - if(!FLAC__stream_encoder_set_bits_per_sample(encoder, streaminfo_.data.stream_info.bits_per_sample)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_sample_rate()... "); - if(!FLAC__stream_encoder_set_sample_rate(encoder, streaminfo_.data.stream_info.sample_rate)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_compression_level()... "); - if(!FLAC__stream_encoder_set_compression_level(encoder, (uint32_t)(-1))) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_blocksize()... "); - if(!FLAC__stream_encoder_set_blocksize(encoder, streaminfo_.data.stream_info.min_blocksize)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_do_mid_side_stereo()... "); - if(!FLAC__stream_encoder_set_do_mid_side_stereo(encoder, false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_loose_mid_side_stereo()... "); - if(!FLAC__stream_encoder_set_loose_mid_side_stereo(encoder, false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_max_lpc_order()... "); - if(!FLAC__stream_encoder_set_max_lpc_order(encoder, 0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_qlp_coeff_precision()... "); - if(!FLAC__stream_encoder_set_qlp_coeff_precision(encoder, 0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_do_qlp_coeff_prec_search()... "); - if(!FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_do_escape_coding()... "); - if(!FLAC__stream_encoder_set_do_escape_coding(encoder, false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_do_exhaustive_model_search()... "); - if(!FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, false)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_min_residual_partition_order()... "); - if(!FLAC__stream_encoder_set_min_residual_partition_order(encoder, 0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_max_residual_partition_order()... "); - if(!FLAC__stream_encoder_set_max_residual_partition_order(encoder, 0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_rice_parameter_search_dist()... "); - if(!FLAC__stream_encoder_set_rice_parameter_search_dist(encoder, 0)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_total_samples_estimate()... "); - if(!FLAC__stream_encoder_set_total_samples_estimate(encoder, streaminfo_.data.stream_info.total_samples)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_metadata()... "); - if(!FLAC__stream_encoder_set_metadata(encoder, metadata_sequence_, num_metadata_)) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_set_limit_min_bitrate()... "); - if(!FLAC__stream_encoder_set_limit_min_bitrate(encoder, true)) - return die_s_("returned false", encoder); - printf("OK\n"); - - if(layer < LAYER_FILENAME) { - printf("opening file for FLAC output... "); - file = flac_fopen(flacfilename(is_ogg), "w+b"); - if(0 == file) { - printf("ERROR (%s)\n", strerror(errno)); - return false; - } - printf("OK\n"); - } - - switch(layer) { - case LAYER_STREAM: - printf("testing FLAC__stream_encoder_init_%sstream()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_encoder_init_ogg_stream(encoder, /*read_callback=*/0, stream_encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, stream_encoder_metadata_callback_, /*client_data=*/file) : - FLAC__stream_encoder_init_stream(encoder, stream_encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, stream_encoder_metadata_callback_, /*client_data=*/file); - break; - case LAYER_SEEKABLE_STREAM: - printf("testing FLAC__stream_encoder_init_%sstream()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_encoder_init_ogg_stream(encoder, stream_encoder_read_callback_, stream_encoder_write_callback_, stream_encoder_seek_callback_, stream_encoder_tell_callback_, /*metadata_callback=*/0, /*client_data=*/file) : - FLAC__stream_encoder_init_stream(encoder, stream_encoder_write_callback_, stream_encoder_seek_callback_, stream_encoder_tell_callback_, /*metadata_callback=*/0, /*client_data=*/file); - break; - case LAYER_FILE: - printf("testing FLAC__stream_encoder_init_%sFILE()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_encoder_init_ogg_FILE(encoder, file, stream_encoder_progress_callback_, /*client_data=*/0) : - FLAC__stream_encoder_init_FILE(encoder, file, stream_encoder_progress_callback_, /*client_data=*/0); - break; - case LAYER_FILENAME: - printf("testing FLAC__stream_encoder_init_%sfile()... ", is_ogg? "ogg_":""); - init_status = is_ogg? - FLAC__stream_encoder_init_ogg_file(encoder, flacfilename(is_ogg), stream_encoder_progress_callback_, /*client_data=*/0) : - FLAC__stream_encoder_init_file(encoder, flacfilename(is_ogg), stream_encoder_progress_callback_, /*client_data=*/0); - break; - default: - die_("internal error 001"); - return false; - } - if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) - return die_s_(0, encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_state()... "); - state = FLAC__stream_encoder_get_state(encoder); - printf("returned state = %u (%s)... OK\n", (uint32_t)state, FLAC__StreamEncoderStateString[state]); - - printf("testing FLAC__stream_encoder_get_verify_decoder_state()... "); - dstate = FLAC__stream_encoder_get_verify_decoder_state(encoder); - printf("returned state = %u (%s)... OK\n", (uint32_t)dstate, FLAC__StreamDecoderStateString[dstate]); - - { - FLAC__uint64 absolute_sample; - uint32_t frame_number; - uint32_t channel; - uint32_t sample; - FLAC__int32 expected; - FLAC__int32 got; - - printf("testing FLAC__stream_encoder_get_verify_decoder_error_stats()... "); - FLAC__stream_encoder_get_verify_decoder_error_stats(encoder, &absolute_sample, &frame_number, &channel, &sample, &expected, &got); - printf("OK\n"); - } - - printf("testing FLAC__stream_encoder_get_verify()... "); - if(FLAC__stream_encoder_get_verify(encoder) != true) { - printf("FAILED, expected true, got false\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_streamable_subset()... "); - if(FLAC__stream_encoder_get_streamable_subset(encoder) != true) { - printf("FAILED, expected true, got false\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_do_mid_side_stereo()... "); - if(FLAC__stream_encoder_get_do_mid_side_stereo(encoder) != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_loose_mid_side_stereo()... "); - if(FLAC__stream_encoder_get_loose_mid_side_stereo(encoder) != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_channels()... "); - if(FLAC__stream_encoder_get_channels(encoder) != streaminfo_.data.stream_info.channels) { - printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.channels, FLAC__stream_encoder_get_channels(encoder)); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_bits_per_sample()... "); - if(FLAC__stream_encoder_get_bits_per_sample(encoder) != streaminfo_.data.stream_info.bits_per_sample) { - printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.bits_per_sample, FLAC__stream_encoder_get_bits_per_sample(encoder)); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_sample_rate()... "); - if(FLAC__stream_encoder_get_sample_rate(encoder) != streaminfo_.data.stream_info.sample_rate) { - printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.sample_rate, FLAC__stream_encoder_get_sample_rate(encoder)); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_blocksize()... "); - if(FLAC__stream_encoder_get_blocksize(encoder) != streaminfo_.data.stream_info.min_blocksize) { - printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.min_blocksize, FLAC__stream_encoder_get_blocksize(encoder)); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_max_lpc_order()... "); - if(FLAC__stream_encoder_get_max_lpc_order(encoder) != 0) { - printf("FAILED, expected %d, got %u\n", 0, FLAC__stream_encoder_get_max_lpc_order(encoder)); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_qlp_coeff_precision()... "); - (void)FLAC__stream_encoder_get_qlp_coeff_precision(encoder); - /* we asked the encoder to auto select this so we accept anything */ - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_do_qlp_coeff_prec_search()... "); - if(FLAC__stream_encoder_get_do_qlp_coeff_prec_search(encoder) != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_do_escape_coding()... "); - if(FLAC__stream_encoder_get_do_escape_coding(encoder) != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_do_exhaustive_model_search()... "); - if(FLAC__stream_encoder_get_do_exhaustive_model_search(encoder) != false) { - printf("FAILED, expected false, got true\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_min_residual_partition_order()... "); - if(FLAC__stream_encoder_get_min_residual_partition_order(encoder) != 0) { - printf("FAILED, expected %d, got %u\n", 0, FLAC__stream_encoder_get_min_residual_partition_order(encoder)); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_max_residual_partition_order()... "); - if(FLAC__stream_encoder_get_max_residual_partition_order(encoder) != 0) { - printf("FAILED, expected %d, got %u\n", 0, FLAC__stream_encoder_get_max_residual_partition_order(encoder)); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_rice_parameter_search_dist()... "); - if(FLAC__stream_encoder_get_rice_parameter_search_dist(encoder) != 0) { - printf("FAILED, expected %d, got %u\n", 0, FLAC__stream_encoder_get_rice_parameter_search_dist(encoder)); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_total_samples_estimate()... "); - if(FLAC__stream_encoder_get_total_samples_estimate(encoder) != streaminfo_.data.stream_info.total_samples) { - printf("FAILED, expected %" PRIu64 ", got %" PRIu64 "\n", streaminfo_.data.stream_info.total_samples, FLAC__stream_encoder_get_total_samples_estimate(encoder)); - return false; - } - printf("OK\n"); - - printf("testing FLAC__stream_encoder_get_limit_min_bitrate()... "); - if(FLAC__stream_encoder_get_limit_min_bitrate(encoder) != true) { - printf("FAILED, expected true, got false\n"); - return false; - } - - /* init the dummy sample buffer */ - for(i = 0; i < sizeof(samples) / sizeof(FLAC__int32); i++) - samples[i] = i & 7; - - printf("testing FLAC__stream_encoder_process()... "); - if(!FLAC__stream_encoder_process(encoder, (const FLAC__int32 * const *)samples_array, sizeof(samples) / sizeof(FLAC__int32))) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_process_interleaved()... "); - if(!FLAC__stream_encoder_process_interleaved(encoder, samples, sizeof(samples) / sizeof(FLAC__int32))) - return die_s_("returned false", encoder); - printf("OK\n"); - - printf("testing FLAC__stream_encoder_finish()... "); - if(!FLAC__stream_encoder_finish(encoder)) - return die_s_("returned false", encoder); - printf("OK\n"); - - if(layer < LAYER_FILE) - fclose(file); - - printf("testing FLAC__stream_encoder_delete()... "); - FLAC__stream_encoder_delete(encoder); - printf("OK\n"); - - printf("\nPASSED!\n"); - - return true; -} - -FLAC__bool test_encoders(void) -{ - FLAC__bool is_ogg = false; - - while(1) { - init_metadata_blocks_(); - - if(!test_stream_encoder(LAYER_STREAM, is_ogg)) - return false; - - if(!test_stream_encoder(LAYER_SEEKABLE_STREAM, is_ogg)) - return false; - - if(!test_stream_encoder(LAYER_FILE, is_ogg)) - return false; - - if(!test_stream_encoder(LAYER_FILENAME, is_ogg)) - return false; - - (void) grabbag__file_remove_file(flacfilename(is_ogg)); - - free_metadata_blocks_(); - - if(!FLAC_API_SUPPORTS_OGG_FLAC || is_ogg) - break; - is_ogg = true; - } - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/encoders.h b/Engine/lib/flac/src/test_libFLAC/encoders.h deleted file mode 100644 index 7bdcaf5c0..000000000 --- a/Engine/lib/flac/src/test_libFLAC/encoders.h +++ /dev/null @@ -1,27 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_ENCODERS_H -#define FLAC__TEST_LIBFLAC_ENCODERS_H - -#include "FLAC/ordinals.h" - -FLAC__bool test_encoders(void); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/endswap.c b/Engine/lib/flac/src/test_libFLAC/endswap.c deleted file mode 100644 index 808f81f3a..000000000 --- a/Engine/lib/flac/src/test_libFLAC/endswap.c +++ /dev/null @@ -1,111 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#include "share/compat.h" -#include "FLAC/assert.h" -#include "share/endswap.h" -#include "private/md5.h" -#include "endswap.h" - - -FLAC__bool test_endswap(void) -{ - int16_t i16 = 0x1234; - uint16_t u16 = 0xabcd; - int32_t i32 = 0x12345678; - uint32_t u32 = 0xabcdef01; - - union { - uint8_t bytes[4]; - uint16_t u16; - uint32_t u32; - } data; - - printf("\n+++ libFLAC unit test: endswap (%s endian host)\n\n", CPU_IS_BIG_ENDIAN ? "big" : "little"); - - printf("testing ENDSWAP_16 on int16_t ... "); - if (((int16_t) ENDSWAP_16(i16)) == i16) { - printf("\nFAILED, ENDSWAP_16(0x%04x) -> 0x%04x == 0x%04x\n", i16, ENDSWAP_16(i16), i16); - return false; - } - if (((int16_t) ENDSWAP_16(ENDSWAP_16(i16))) != i16) { - printf("\nFAILED, ENDSWAP_16(ENDSWAP_16(0x%04x)) -> 0x%04x != 0x%04x\n", i16, ENDSWAP_16(ENDSWAP_16(i16)), i16); - return false; - } - puts("OK"); - - printf("testing ENDSWAP_16 on uint16_t ... "); - if (((uint16_t) ENDSWAP_16(u16)) == u16) { - printf("\nFAILED, ENDSWAP_16(0x%04x) -> 0x%04x == 0x%04x\n", u16, ENDSWAP_16(u16), u16); - return false; - } - if (((uint16_t) ENDSWAP_16(ENDSWAP_16(u16))) != u16) { - printf("\nFAILED, ENDSWAP_16(ENDSWAP_16(0x%04x)) -> 0x%04x != 0x%04x\n", u16, ENDSWAP_16(ENDSWAP_16(u16)), u16); - return false; - } - puts("OK"); - - printf("testing ENDSWAP_32 on int32_t ... "); - if (((int32_t) ENDSWAP_32 (i32)) == i32) { - printf("\nFAILED, ENDSWAP_32(0x%08x) -> 0x%08x == 0x%08x\n", i32, (uint32_t) ENDSWAP_32 (i32), i32); - return false; - } - if (((int32_t) ENDSWAP_32 (ENDSWAP_32 (i32))) != i32) { - printf("\nFAILED, ENDSWAP_32(ENDSWAP_32(0x%08x)) -> 0x%08x != 0x%08x\n", i32, (uint32_t) ENDSWAP_32(ENDSWAP_32 (i32)), i32); - return false; - } - puts("OK"); - - printf("testing ENDSWAP_32 on uint32_t ... "); - if (((uint32_t) ENDSWAP_32(u32)) == u32) { - printf("\nFAILED, ENDSWAP_32(0x%08x) -> 0x%08x == 0x%08x\n", u32, (uint32_t) ENDSWAP_32(u32), u32); - return false; - } - if (((uint32_t) ENDSWAP_32 (ENDSWAP_32(u32))) != u32) { - printf("\nFAILED, ENDSWAP_32(ENDSWAP_32(0x%08x)) -> 0x%08x != 0%08x\n", u32, (uint32_t) ENDSWAP_32(ENDSWAP_32(u32)), u32); - return false; - } - puts("OK"); - - printf("testing H2LE_16 on uint16_t ... "); - data.u16 = H2LE_16(0x1234); - if (data.bytes [0] != 0x34 || data.bytes [1] != 0x12) { - printf("\nFAILED, H2LE_16(0x%04x) -> { 0x%02x, 0x%02x }\n", data.u16, data.bytes [0] & 0xff, data.bytes [1] & 0xff); - return false; - } - puts("OK"); - - printf("testing H2LE_32 on uint32_t ... "); - data.u32 = H2LE_32(0x12345678); - if (data.bytes [0] != 0x78 || data.bytes [1] != 0x56 || data.bytes [2] != 0x34 || data.bytes [3] != 0x12) { - printf("\nFAILED, H2LE_32(0x%08x) -> { 0x%02x, 0x%02x, 0x%02x, 0x%02x }\n", - data.u32, data.bytes [0] & 0xff, data.bytes [1] & 0xff, data.bytes [2] & 0xff, data.bytes [3] & 0xff); - return false; - } - puts("OK"); - - printf("\nPASSED!\n"); - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/endswap.h b/Engine/lib/flac/src/test_libFLAC/endswap.h deleted file mode 100644 index 952b17f09..000000000 --- a/Engine/lib/flac/src/test_libFLAC/endswap.h +++ /dev/null @@ -1,26 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_ENDSWAP_H -#define FLAC__TEST_LIBFLAC_ENDSWAP_H - -#include "FLAC/ordinals.h" - -FLAC__bool test_endswap(void); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/format.c b/Engine/lib/flac/src/test_libFLAC/format.c deleted file mode 100644 index c5e8bf278..000000000 --- a/Engine/lib/flac/src/test_libFLAC/format.c +++ /dev/null @@ -1,260 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/assert.h" -#include "FLAC/format.h" -#include "format.h" -#include - -static const char *true_false_string_[2] = { "false", "true" }; - -static struct { - uint32_t rate; - FLAC__bool valid; - FLAC__bool subset; -} SAMPLE_RATES[] = { - { 0 , true , true }, - { 1 , true , true }, - { 9 , true , true }, - { 10 , true , true }, - { 4000 , true , true }, - { 8000 , true , true }, - { 11025 , true , true }, - { 12000 , true , true }, - { 16000 , true , true }, - { 22050 , true , true }, - { 24000 , true , true }, - { 32000 , true , true }, - { 32768 , true , true }, - { 44100 , true , true }, - { 48000 , true , true }, - { 65000 , true , true }, - { 65535 , true , true }, - { 65536 , true , false }, - { 65540 , true , true }, - { 65550 , true , true }, - { 65555 , true , false }, - { 66000 , true , true }, - { 66001 , true , false }, - { 96000 , true , true }, - { 100000 , true , true }, - { 100001 , true , false }, - { 192000 , true , true }, - { 500000 , true , true }, - { 500001 , true , false }, - { 500010 , true , true }, - { 655349 , true , false }, - { 655350 , true , true }, - { 655351 , true , false }, - { 655360 , true , false }, - { 700000 , true , false }, - { 700010 , true , false }, - { 705600 , true , false }, - { 768000 , true , false }, - { 1000000, true , false }, - { 1048575, true , false }, - { 1100000, false, false } -}; - -static struct { - const char *string; - FLAC__bool valid; -} VCENTRY_NAMES[] = { - { "" , true }, - { "a" , true }, - { "=" , false }, - { "a=" , false }, - { "\x01", false }, - { "\x1f", false }, - { "\x7d", true }, - { "\x7e", false }, - { "\xff", false } -}; - -static struct { - uint32_t length; - const FLAC__byte *string; - FLAC__bool valid; -} VCENTRY_VALUES[] = { - { 0, (const FLAC__byte*)"" , true }, - { 1, (const FLAC__byte*)"" , true }, - { 1, (const FLAC__byte*)"\x01" , true }, - { 1, (const FLAC__byte*)"\x7f" , true }, - { 1, (const FLAC__byte*)"\x80" , false }, - { 1, (const FLAC__byte*)"\x81" , false }, - { 1, (const FLAC__byte*)"\xc0" , false }, - { 1, (const FLAC__byte*)"\xe0" , false }, - { 1, (const FLAC__byte*)"\xf0" , false }, - { 2, (const FLAC__byte*)"\xc0\x41" , false }, - { 2, (const FLAC__byte*)"\xc1\x41" , false }, - { 2, (const FLAC__byte*)"\xc0\x85" , false }, /* non-shortest form */ - { 2, (const FLAC__byte*)"\xc1\x85" , false }, /* non-shortest form */ - { 2, (const FLAC__byte*)"\xc2\x85" , true }, - { 2, (const FLAC__byte*)"\xe0\x41" , false }, - { 2, (const FLAC__byte*)"\xe1\x41" , false }, - { 2, (const FLAC__byte*)"\xe0\x85" , false }, - { 2, (const FLAC__byte*)"\xe1\x85" , false }, - { 3, (const FLAC__byte*)"\xe0\x85\x41", false }, - { 3, (const FLAC__byte*)"\xe1\x85\x41", false }, - { 3, (const FLAC__byte*)"\xe0\x85\x80", false }, /* non-shortest form */ - { 3, (const FLAC__byte*)"\xe0\x95\x80", false }, /* non-shortest form */ - { 3, (const FLAC__byte*)"\xe0\xa5\x80", true }, - { 3, (const FLAC__byte*)"\xe1\x85\x80", true }, - { 3, (const FLAC__byte*)"\xe1\x95\x80", true }, - { 3, (const FLAC__byte*)"\xe1\xa5\x80", true } -}; - -static struct { - const FLAC__byte *string; - FLAC__bool valid; -} VCENTRY_VALUES_NT[] = { - { (const FLAC__byte*)"" , true }, - { (const FLAC__byte*)"\x01" , true }, - { (const FLAC__byte*)"\x7f" , true }, - { (const FLAC__byte*)"\x80" , false }, - { (const FLAC__byte*)"\x81" , false }, - { (const FLAC__byte*)"\xc0" , false }, - { (const FLAC__byte*)"\xe0" , false }, - { (const FLAC__byte*)"\xf0" , false }, - { (const FLAC__byte*)"\xc0\x41" , false }, - { (const FLAC__byte*)"\xc1\x41" , false }, - { (const FLAC__byte*)"\xc0\x85" , false }, /* non-shortest form */ - { (const FLAC__byte*)"\xc1\x85" , false }, /* non-shortest form */ - { (const FLAC__byte*)"\xc2\x85" , true }, - { (const FLAC__byte*)"\xe0\x41" , false }, - { (const FLAC__byte*)"\xe1\x41" , false }, - { (const FLAC__byte*)"\xe0\x85" , false }, - { (const FLAC__byte*)"\xe1\x85" , false }, - { (const FLAC__byte*)"\xe0\x85\x41", false }, - { (const FLAC__byte*)"\xe1\x85\x41", false }, - { (const FLAC__byte*)"\xe0\x85\x80", false }, /* non-shortest form */ - { (const FLAC__byte*)"\xe0\x95\x80", false }, /* non-shortest form */ - { (const FLAC__byte*)"\xe0\xa5\x80", true }, - { (const FLAC__byte*)"\xe1\x85\x80", true }, - { (const FLAC__byte*)"\xe1\x95\x80", true }, - { (const FLAC__byte*)"\xe1\xa5\x80", true } -}; - -static struct { - uint32_t length; - const FLAC__byte *string; - FLAC__bool valid; -} VCENTRIES[] = { - { 0, (const FLAC__byte*)"" , false }, - { 1, (const FLAC__byte*)"a" , false }, - { 1, (const FLAC__byte*)"=" , true }, - { 2, (const FLAC__byte*)"a=" , true }, - { 2, (const FLAC__byte*)"\x01=" , false }, - { 2, (const FLAC__byte*)"\x1f=" , false }, - { 2, (const FLAC__byte*)"\x7d=" , true }, - { 2, (const FLAC__byte*)"\x7e=" , false }, - { 2, (const FLAC__byte*)"\xff=" , false }, - { 3, (const FLAC__byte*)"a=\x01" , true }, - { 3, (const FLAC__byte*)"a=\x7f" , true }, - { 3, (const FLAC__byte*)"a=\x80" , false }, - { 3, (const FLAC__byte*)"a=\x81" , false }, - { 3, (const FLAC__byte*)"a=\xc0" , false }, - { 3, (const FLAC__byte*)"a=\xe0" , false }, - { 3, (const FLAC__byte*)"a=\xf0" , false }, - { 4, (const FLAC__byte*)"a=\xc0\x41" , false }, - { 4, (const FLAC__byte*)"a=\xc1\x41" , false }, - { 4, (const FLAC__byte*)"a=\xc0\x85" , false }, /* non-shortest form */ - { 4, (const FLAC__byte*)"a=\xc1\x85" , false }, /* non-shortest form */ - { 4, (const FLAC__byte*)"a=\xc2\x85" , true }, - { 4, (const FLAC__byte*)"a=\xe0\x41" , false }, - { 4, (const FLAC__byte*)"a=\xe1\x41" , false }, - { 4, (const FLAC__byte*)"a=\xe0\x85" , false }, - { 4, (const FLAC__byte*)"a=\xe1\x85" , false }, - { 5, (const FLAC__byte*)"a=\xe0\x85\x41", false }, - { 5, (const FLAC__byte*)"a=\xe1\x85\x41", false }, - { 5, (const FLAC__byte*)"a=\xe0\x85\x80", false }, /* non-shortest form */ - { 5, (const FLAC__byte*)"a=\xe0\x95\x80", false }, /* non-shortest form */ - { 5, (const FLAC__byte*)"a=\xe0\xa5\x80", true }, - { 5, (const FLAC__byte*)"a=\xe1\x85\x80", true }, - { 5, (const FLAC__byte*)"a=\xe1\x95\x80", true }, - { 5, (const FLAC__byte*)"a=\xe1\xa5\x80", true } -}; - -FLAC__bool test_format(void) -{ - uint32_t i; - - printf("\n+++ libFLAC unit test: format\n\n"); - - for(i = 0; i < sizeof(SAMPLE_RATES)/sizeof(SAMPLE_RATES[0]); i++) { - printf("testing FLAC__format_sample_rate_is_valid(%u)... ", SAMPLE_RATES[i].rate); - if(FLAC__format_sample_rate_is_valid(SAMPLE_RATES[i].rate) != SAMPLE_RATES[i].valid) { - printf("FAILED, expected %s, got %s\n", true_false_string_[SAMPLE_RATES[i].valid], true_false_string_[!SAMPLE_RATES[i].valid]); - return false; - } - printf("OK\n"); - } - - for(i = 0; i < sizeof(SAMPLE_RATES)/sizeof(SAMPLE_RATES[0]); i++) { - printf("testing FLAC__format_sample_rate_is_subset(%u)... ", SAMPLE_RATES[i].rate); - if(FLAC__format_sample_rate_is_subset(SAMPLE_RATES[i].rate) != SAMPLE_RATES[i].subset) { - printf("FAILED, expected %s, got %s\n", true_false_string_[SAMPLE_RATES[i].subset], true_false_string_[!SAMPLE_RATES[i].subset]); - return false; - } - printf("OK\n"); - } - - for(i = 0; i < sizeof(VCENTRY_NAMES)/sizeof(VCENTRY_NAMES[0]); i++) { - printf("testing FLAC__format_vorbiscomment_entry_name_is_legal(\"%s\")... ", VCENTRY_NAMES[i].string); - if(FLAC__format_vorbiscomment_entry_name_is_legal(VCENTRY_NAMES[i].string) != VCENTRY_NAMES[i].valid) { - printf("FAILED, expected %s, got %s\n", true_false_string_[VCENTRY_NAMES[i].valid], true_false_string_[!VCENTRY_NAMES[i].valid]); - return false; - } - printf("OK\n"); - } - - for(i = 0; i < sizeof(VCENTRY_VALUES)/sizeof(VCENTRY_VALUES[0]); i++) { - printf("testing FLAC__format_vorbiscomment_entry_value_is_legal(\"%s\", %u)... ", VCENTRY_VALUES[i].string, VCENTRY_VALUES[i].length); - if(FLAC__format_vorbiscomment_entry_value_is_legal(VCENTRY_VALUES[i].string, VCENTRY_VALUES[i].length) != VCENTRY_VALUES[i].valid) { - printf("FAILED, expected %s, got %s\n", true_false_string_[VCENTRY_VALUES[i].valid], true_false_string_[!VCENTRY_VALUES[i].valid]); - return false; - } - printf("OK\n"); - } - - for(i = 0; i < sizeof(VCENTRY_VALUES_NT)/sizeof(VCENTRY_VALUES_NT[0]); i++) { - printf("testing FLAC__format_vorbiscomment_entry_value_is_legal(\"%s\", -1)... ", VCENTRY_VALUES_NT[i].string); - if(FLAC__format_vorbiscomment_entry_value_is_legal(VCENTRY_VALUES_NT[i].string, (uint32_t)(-1)) != VCENTRY_VALUES_NT[i].valid) { - printf("FAILED, expected %s, got %s\n", true_false_string_[VCENTRY_VALUES_NT[i].valid], true_false_string_[!VCENTRY_VALUES_NT[i].valid]); - return false; - } - printf("OK\n"); - } - - for(i = 0; i < sizeof(VCENTRIES)/sizeof(VCENTRIES[0]); i++) { - printf("testing FLAC__format_vorbiscomment_entry_is_legal(\"%s\", %u)... ", VCENTRIES[i].string, VCENTRIES[i].length); - if(FLAC__format_vorbiscomment_entry_is_legal(VCENTRIES[i].string, VCENTRIES[i].length) != VCENTRIES[i].valid) { - printf("FAILED, expected %s, got %s\n", true_false_string_[VCENTRIES[i].valid], true_false_string_[!VCENTRIES[i].valid]); - return false; - } - printf("OK\n"); - } - - printf("\nPASSED!\n"); - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/format.h b/Engine/lib/flac/src/test_libFLAC/format.h deleted file mode 100644 index f78d55df2..000000000 --- a/Engine/lib/flac/src/test_libFLAC/format.h +++ /dev/null @@ -1,27 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_FORMAT_H -#define FLAC__TEST_LIBFLAC_FORMAT_H - -#include "FLAC/ordinals.h" - -FLAC__bool test_format(void); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/main.c b/Engine/lib/flac/src/test_libFLAC/main.c deleted file mode 100644 index a4be0fee0..000000000 --- a/Engine/lib/flac/src/test_libFLAC/main.c +++ /dev/null @@ -1,64 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "bitreader.h" -#include "bitwriter.h" -#include "crc.h" -#include "decoders.h" -#include "encoders.h" -#include "endswap.h" -#include "format.h" -#include "metadata.h" -#include "md5.h" - -int main(void) -{ - if(!test_endswap()) - return 1; - - if(!test_crc()) - return 1; - - if(!test_md5()) - return 1; - - if(!test_bitreader()) - return 1; - - if(!test_bitwriter()) - return 1; - - if(!test_format()) - return 1; - - if(!test_encoders()) - return 1; - - if(!test_decoders()) - return 1; - - if(!test_metadata()) - return 1; - - return 0; -} diff --git a/Engine/lib/flac/src/test_libFLAC/matrix b/Engine/lib/flac/src/test_libFLAC/matrix deleted file mode 100644 index a78ecf3af..000000000 --- a/Engine/lib/flac/src/test_libFLAC/matrix +++ /dev/null @@ -1,69 +0,0 @@ -#if 0 -level 1 - -4 delete middle block nopad -1 delete middle block pad -1 delete last block nopad -1 delete last block pad -1 insert middle block nopad -1 insert middle block equalpad -1 insert middle block smallpad -1 insert middle block smallpad+1 -1 insert middle block biggerpad -1 insert last block X -1 set middle block smaller nopad -1 set middle block smaller pad -1 set last block smaller nopad -1 set last block smaller pad -1 set middle block bigger nopad -1 set middle block bigger equalpad -1 set middle block bigger smallpad -1 set middle block bigger smallpad+1 -1 set middle block bigger biggerpad -1 set last block bigger nopad -1 set middle block equal X -2 set last block equal X - -level 2 - -FLAC__bool FLAC__metadata_chain_write() - -1 newsize==oldsize - newsize>oldsize -b no use_padding -c use_padding, last block is not padding -g use_padding, last block is padding of insufficient length -h use_padding, last block is padding, but padding header straddles border (can't do it) -j use_padding, last block is padding of exact sufficient length (padding totally consumed) -i use_padding, last block is padding of abundant length (padding is reduced) - newsize= 4 -f use_padding, last block is padding - -void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain); -void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain); - -S:34 A:1234 -a:shrink A->30 write nopad -S:34 A:30 -b:grow A->32 write nopad -S:34 A:32 -c:grow A->40 write pad -S:34 A:40 -d:shrink A->37 write pad -S:34 A:37 -e:shrink A->33 write pad -S:34 A:33 P:0 -f:shrink A->20 write pad -S:34 A:20 P:13 -g:grow A->40 write pad -S:34 A:40 P:13 -h:grow A->54 write pad -S:34 A:54 P:13 -i:grow A->60 write pad -S:34 A:60 P:7 -j:grow A->71 write pad -S:34 A:71 -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/md5.c b/Engine/lib/flac/src/test_libFLAC/md5.c deleted file mode 100644 index bac4a74ad..000000000 --- a/Engine/lib/flac/src/test_libFLAC/md5.c +++ /dev/null @@ -1,221 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#include "FLAC/assert.h" -#include "share/compat.h" -#include "private/md5.h" -#include "md5.h" - - -static FLAC__bool test_md5_clear_context(void); -static FLAC__bool test_md5_codec(void); -static FLAC__bool test_md5_accumulate(const FLAC__int32 * const * signal,uint32_t channels, uint32_t samples, uint32_t bytes_per_sample, const FLAC__byte target_digest [16]); - -FLAC__bool test_md5(void) -{ - printf("\n+++ libFLAC unit test: md5\n\n"); - - if (! test_md5_clear_context()) - return false; - - if (! test_md5_codec()) - return false; - - printf("\nPASSED!\n"); - return true; -} - -/*----------------------------------------------------------------------------*/ - -static FLAC__bool test_md5_clear_context(void) -{ - FLAC__MD5Context ctx; - FLAC__byte digest[16]; - FLAC__byte target[16] = { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e }; - uint32_t k ; - char * cptr; - - printf("testing FLAC__MD5Init ... "); - FLAC__MD5Init (&ctx); - if (ctx.buf[0] != 0x67452301) { - printf("FAILED!\n"); - return false; - } - printf("OK\n"); - - printf("testing that FLAC__MD5Final clears the MD5Context ... "); - FLAC__MD5Final(digest, &ctx); - cptr = (char*) &ctx ; - for (k = 0 ; k < sizeof (ctx) ; k++) { - if (cptr [k]) { - printf("FAILED, MD5 ctx has not been cleared after FLAC__MD5Final\n"); - return false; - } - } - printf("OK\n"); - - printf("testing digest correct for zero data ... "); - if (memcmp(digest, target, sizeof (digest))) { - printf("\nFAILED, expected MD5 sum "); - for (k = 0 ; k < 16 ; k++) - printf("%02x", (target [k] & 0xff)); - printf (" but got "); - for (k = 0 ; k < 16 ; k++) - printf("%02x", (digest [k] & 0xff)); - puts("\n"); - return false; - } - puts("OK"); - - return true; -} - -static FLAC__byte target_digests [8][4][16] = -{ /* 1 channel */ - { /* 1 byte per sample */ - { 0xc1, 0x9a, 0x5b, 0xeb, 0x57, 0x8f, 0x26, 0xeb, 0xfb, 0x34, 0x7c, 0xef, 0x04, 0x31, 0x6d, 0x7d }, - /* 2 bytes per sample */ - { 0xd4, 0x78, 0x90, 0xd3, 0xa9, 0x17, 0x4e, 0x76, 0xca, 0x4d, 0x27, 0x20, 0x98, 0x36, 0x8b, 0x2e }, - /* 3 bytes per sample */ - { 0x5a, 0x4b, 0xd6, 0xac, 0xa1, 0x70, 0x84, 0x19, 0x7c, 0x0d, 0xfb, 0x5b, 0xa9, 0x7b, 0xcb, 0x54 }, - /* 4 bytes per sample */ - { 0x79, 0xd5, 0x7a, 0x32, 0x06, 0x0b, 0xfe, 0x46, 0xa3, 0xe7, 0xba, 0xc5, 0xf7, 0x48, 0x6f, 0x50 } - }, - - /* 2 channels */ - { - { 0x89, 0xac, 0xcf, 0x91, 0xf1, 0x8c, 0xea, 0xab, 0x46, 0x12, 0x74, 0xbc, 0x4e, 0x82, 0xbe, 0x7d }, - { 0xb9, 0x17, 0x16, 0x5b, 0xd8, 0x1c, 0xc8, 0x4e, 0x5a, 0x28, 0xfb, 0xba, 0x87, 0x74, 0x76, 0x44 }, - { 0xec, 0x63, 0x92, 0xca, 0x4f, 0x6b, 0x9e, 0xb1, 0x9f, 0xec, 0x3b, 0x2c, 0x15, 0x30, 0xfd, 0x2a }, - { 0x05, 0x4d, 0xfd, 0xb8, 0x9d, 0x8a, 0xa2, 0xdd, 0x26, 0x47, 0xc6, 0xfb, 0x4f, 0x23, 0x67, 0x6d } - }, - - /* 3 channels */ - { - { 0xad, 0x05, 0xda, 0xf3, 0x7a, 0xa1, 0x94, 0xdb, 0x0c, 0x61, 0x06, 0xb2, 0x94, 0x39, 0x6c, 0xa9 }, - { 0x8b, 0xcc, 0x41, 0x4d, 0xe9, 0xe3, 0xc2, 0x61, 0x61, 0x8a, 0x8b, 0x22, 0xc6, 0x4e, 0xac, 0xa7 }, - { 0x8a, 0xce, 0x97, 0xc1, 0x86, 0xae, 0xbc, 0x73, 0x88, 0x8b, 0x35, 0x5a, 0x37, 0x33, 0xf9, 0xcf }, - { 0x69, 0x59, 0xe8, 0x38, 0x29, 0x80, 0x80, 0x21, 0xb1, 0xd2, 0xba, 0xf6, 0x28, 0xd6, 0x6a, 0x83 } - }, - - /* 4 channels */ - { - { 0x61, 0x40, 0x75, 0xef, 0x22, 0xf1, 0x0f, 0xa6, 0x08, 0x6c, 0x88, 0xff, 0x2c, 0x4e, 0x98, 0x0b }, - { 0xa0, 0x77, 0x3a, 0x59, 0x4a, 0xbf, 0xd0, 0x5c, 0xcc, 0xe3, 0xb9, 0x83, 0x2b, 0xf3, 0xdf, 0x1a }, - { 0xdb, 0xd7, 0xf1, 0x82, 0x13, 0x60, 0x42, 0x7c, 0x84, 0xe6, 0xcf, 0x30, 0xab, 0xa2, 0x64, 0xf1 }, - { 0x4a, 0x9a, 0xad, 0x53, 0x05, 0x74, 0xb1, 0x1c, 0xb8, 0xd4, 0xae, 0x78, 0x13, 0xf6, 0x2a, 0x11 } - }, - - /* 5 channels */ - { - { 0xcc, 0xca, 0x44, 0xc0, 0x54, 0xe2, 0xc9, 0xba, 0x99, 0x32, 0xc9, 0x65, 0xf3, 0x3e, 0x44, 0x34}, - { 0x40, 0x38, 0x6a, 0xdd, 0xde, 0x89, 0x10, 0x3c, 0x8e, 0xec, 0xdf, 0x15, 0x53, 0x4c, 0x2c, 0x92 }, - { 0xc8, 0x95, 0x0a, 0x7c, 0x17, 0x30, 0xc0, 0xac, 0x8e, 0x34, 0xdb, 0x79, 0x76, 0x64, 0x7c, 0x6e }, - { 0x3f, 0x06, 0x11, 0x8a, 0x8d, 0x80, 0xb5, 0x4f, 0x8b, 0xb5, 0x8e, 0xb3, 0x27, 0x3e, 0x41, 0xe8 } - }, - - /* 6 channels */ - { - { 0x61, 0xe4, 0xbd, 0xb1, 0xc0, 0x2f, 0xf4, 0x4c, 0x6e, 0x09, 0x5a, 0xbd, 0x90, 0x18, 0x8b, 0x62 }, - { 0x47, 0xe7, 0x6e, 0x3b, 0x18, 0x86, 0x60, 0x1b, 0x09, 0x62, 0xc6, 0xc9, 0x7c, 0x4c, 0x03, 0xb5 }, - { 0x70, 0x57, 0xbf, 0x67, 0x66, 0x0f, 0xe3, 0x0a, 0x6c, 0xd2, 0x97, 0x66, 0xa2, 0xd2, 0xe4, 0x79 }, - { 0xaa, 0x3f, 0xc7, 0xf5, 0x7a, 0xa5, 0x46, 0xf7, 0xea, 0xe3, 0xd5, 0x1a, 0xa4, 0x62, 0xbe, 0xfa } - }, - - /* 7 channels */ - { - { 0x7c, 0x8d, 0xd2, 0x8c, 0xfd, 0x91, 0xbb, 0x77, 0x6f, 0x0e, 0xf0, 0x39, 0x1f, 0x39, 0xc4, 0xac }, - { 0xfb, 0xab, 0x18, 0x3f, 0x1e, 0x1d, 0xa5, 0x77, 0xe0, 0x5c, 0xea, 0x45, 0x6f, 0x64, 0xa4, 0x64 }, - { 0xe3, 0xac, 0x33, 0x50, 0xc1, 0xb1, 0x93, 0xfb, 0xca, 0x4b, 0x15, 0xcb, 0x2d, 0xcd, 0xd5, 0xef }, - { 0x10, 0xfb, 0x02, 0x83, 0x76, 0x0d, 0xe5, 0xd2, 0x3b, 0xb1, 0x4c, 0x78, 0x3b, 0x73, 0xf7, 0x1a } - }, - - /* 8 channels */ - { - { 0x65, 0x7b, 0xe5, 0x92, 0xe2, 0x1c, 0x95, 0x3e, 0xd7, 0x2f, 0x64, 0xa0, 0x86, 0xec, 0x1a, 0xed }, - { 0x9d, 0x04, 0x8f, 0xa4, 0xea, 0x10, 0xec, 0xb8, 0xa3, 0x88, 0xe2, 0x5d, 0x3c, 0xe2, 0xfb, 0x94 }, - { 0x5a, 0xd3, 0xd2, 0x75, 0x6a, 0xfa, 0xa7, 0x42, 0xf3, 0xbf, 0x0e, 0xbc, 0x90, 0x2a, 0xf8, 0x5f }, - { 0x76, 0xe1, 0xe5, 0xf6, 0xe3, 0x44, 0x08, 0x29, 0xae, 0x79, 0x19, 0xeb, 0xa8, 0x57, 0x16, 0x2a } - } -}; - -#define MAX_CHANNEL_COUNT 8 -#define MD5_SAMPLE_COUNT 64 - -static FLAC__bool test_md5_codec(void) -{ - FLAC__int32 arrays[MAX_CHANNEL_COUNT][MD5_SAMPLE_COUNT], *pointer[MAX_CHANNEL_COUNT], **signal; - uint32_t chan, byte_size, seed = 0x12345679; - - /* Set up signal data using a trivial Linear Congruent PRNG. */ - signal = &pointer[0]; - for (chan = 0 ; chan < MAX_CHANNEL_COUNT ; chan ++) { - uint32_t k; - pointer[chan] = arrays [chan]; - for (k = 0 ; k < MD5_SAMPLE_COUNT ; k++) { - seed = seed * 1103515245 + 12345; - arrays[chan][k] = seed; - } - } - - for (chan = 1 ; chan <= MAX_CHANNEL_COUNT ; chan ++) { - for (byte_size = 1 ; byte_size <= 4 ; byte_size ++) { - if (! test_md5_accumulate((const FLAC__int32 * const *) signal, chan, MD5_SAMPLE_COUNT, byte_size, target_digests[chan-1][byte_size-1])) - return false; - } - } - - return true; -} - -static FLAC__bool test_md5_accumulate(const FLAC__int32 * const * signal, uint32_t channels, uint32_t samples, uint32_t bytes_per_sample, const FLAC__byte target_digest [16]) -{ - FLAC__MD5Context ctx; - FLAC__byte digest[16]; - - memset(&ctx, 0, sizeof (ctx)); - - printf("testing FLAC__MD5Accumulate (samples=%u, channels=%u, bytes_per_sample=%u) ... ", samples, channels, bytes_per_sample); - - FLAC__MD5Init(&ctx); - FLAC__MD5Accumulate(&ctx, signal, channels, samples, bytes_per_sample); - FLAC__MD5Final(digest, &ctx); - - if (memcmp(digest, target_digest, sizeof (digest))) { - int k ; - - printf("\nFAILED, expected MD5 sum "); - for (k = 0 ; k < 16 ; k++) - printf("%02x", (target_digest [k] & 0xff)); - printf (" but got "); - for (k = 0 ; k < 16 ; k++) - printf("%02x", (digest [k] & 0xff)); - puts("\n"); - return false; - } - - printf("OK\n"); - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/md5.h b/Engine/lib/flac/src/test_libFLAC/md5.h deleted file mode 100644 index 6863268d3..000000000 --- a/Engine/lib/flac/src/test_libFLAC/md5.h +++ /dev/null @@ -1,26 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2014-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_MD5_H -#define FLAC__TEST_LIBFLAC_MD5_H - -#include "FLAC/ordinals.h" - -FLAC__bool test_md5(void); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/metadata.c b/Engine/lib/flac/src/test_libFLAC/metadata.c deleted file mode 100644 index 0347f6d2b..000000000 --- a/Engine/lib/flac/src/test_libFLAC/metadata.c +++ /dev/null @@ -1,41 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "metadata.h" -#include - -extern FLAC__bool test_metadata_object(void); -extern FLAC__bool test_metadata_file_manipulation(void); - -FLAC__bool test_metadata(void) -{ - if(!test_metadata_object()) - return false; - - if(!test_metadata_file_manipulation()) - return false; - - printf("\nPASSED!\n"); - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/metadata.h b/Engine/lib/flac/src/test_libFLAC/metadata.h deleted file mode 100644 index 51bdf7aab..000000000 --- a/Engine/lib/flac/src/test_libFLAC/metadata.h +++ /dev/null @@ -1,29 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef FLAC__TEST_LIBFLAC_METADATA_H -#define FLAC__TEST_LIBFLAC_METADATA_H - -#include "FLAC/ordinals.h" - -FLAC__bool test_metadata(void); -FLAC__bool test_metadata_file_manipulation(void); -FLAC__bool test_metadata_object(void); - -#endif diff --git a/Engine/lib/flac/src/test_libFLAC/metadata_manip.c b/Engine/lib/flac/src/test_libFLAC/metadata_manip.c deleted file mode 100644 index 334dc3ae8..000000000 --- a/Engine/lib/flac/src/test_libFLAC/metadata_manip.c +++ /dev/null @@ -1,2146 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include /* for malloc() */ -#include /* for memcpy()/memset() */ -#if defined _MSC_VER || defined __MINGW32__ -#include /* for utime() */ -#include /* for chmod() */ -#else -#include /* some flavors of BSD (like OS X) require this to get time_t */ -#include /* for chown(), unlink() */ -#endif -#include /* for stat(), maybe chmod() */ -#include "FLAC/assert.h" -#include "FLAC/stream_decoder.h" -#include "FLAC/metadata.h" -#include "share/grabbag.h" -#include "share/compat.h" -#include "share/macros.h" -#include "share/safe_str.h" -#include "test_libs_common/file_utils_flac.h" -#include "test_libs_common/metadata_utils.h" -#include "metadata.h" - - -/****************************************************************************** - The general strategy of these tests (for interface levels 1 and 2) is - to create a dummy FLAC file with a known set of initial metadata - blocks, then keep a mirror locally of what we expect the metadata to be - after each operation. Then testing becomes a simple matter of running - a FLAC__StreamDecoder over the dummy file after each operation, comparing - the decoded metadata to what's in our local copy. If there are any - differences in the metadata, or the actual audio data is corrupted, we - will catch it while decoding. -******************************************************************************/ - -typedef struct { - FLAC__bool error_occurred; -} decoder_client_struct; - -typedef struct { - FLAC__StreamMetadata *blocks[64]; - uint32_t num_blocks; -} our_metadata_struct; - -/* our copy of the metadata in flacfilename() */ -static our_metadata_struct our_metadata_; - -/* the current block number that corresponds to the position of the iterator we are testing */ -static uint32_t mc_our_block_number_ = 0; - -static const char *flacfilename(FLAC__bool is_ogg) -{ - return is_ogg? "metadata.oga" : "metadata.flac"; -} - -static FLAC__bool die_(const char *msg) -{ - printf("ERROR: %s\n", msg); - return false; -} - -static FLAC__bool die_c_(const char *msg, FLAC__Metadata_ChainStatus status) -{ - printf("ERROR: %s\n", msg); - printf(" status=%s\n", FLAC__Metadata_ChainStatusString[status]); - return false; -} - -static FLAC__bool die_ss_(const char *msg, FLAC__Metadata_SimpleIterator *iterator) -{ - printf("ERROR: %s\n", msg); - printf(" status=%s\n", FLAC__Metadata_SimpleIteratorStatusString[FLAC__metadata_simple_iterator_status(iterator)]); - return false; -} - -static void *malloc_or_die_(size_t size) -{ - void *x = malloc(size); - if(0 == x) { - fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (uint32_t)size); - exit(1); - } - return x; -} - -static char *strdup_or_die_(const char *s) -{ - char *x = strdup(s); - if(0 == x) { - fprintf(stderr, "ERROR: out of memory copying string \"%s\"\n", s); - exit(1); - } - return x; -} - -/* functions for working with our metadata copy */ - -static FLAC__bool replace_in_our_metadata_(FLAC__StreamMetadata *block, uint32_t position, FLAC__bool copy) -{ - uint32_t i; - FLAC__StreamMetadata *obj = block; - FLAC__ASSERT(position < our_metadata_.num_blocks); - if(copy) { - if(0 == (obj = FLAC__metadata_object_clone(block))) - return die_("during FLAC__metadata_object_clone()"); - } - FLAC__metadata_object_delete(our_metadata_.blocks[position]); - our_metadata_.blocks[position] = obj; - - /* set the is_last flags */ - for(i = 0; i < our_metadata_.num_blocks - 1; i++) - our_metadata_.blocks[i]->is_last = false; - our_metadata_.blocks[i]->is_last = true; - - return true; -} - -static FLAC__bool insert_to_our_metadata_(FLAC__StreamMetadata *block, uint32_t position, FLAC__bool copy) -{ - uint32_t i; - FLAC__StreamMetadata *obj = block; - if(copy) { - if(0 == (obj = FLAC__metadata_object_clone(block))) - return die_("during FLAC__metadata_object_clone()"); - } - if(position > our_metadata_.num_blocks) { - position = our_metadata_.num_blocks; - } - else { - for(i = our_metadata_.num_blocks; i > position; i--) - our_metadata_.blocks[i] = our_metadata_.blocks[i-1]; - } - our_metadata_.blocks[position] = obj; - our_metadata_.num_blocks++; - - /* set the is_last flags */ - for(i = 0; i < our_metadata_.num_blocks - 1; i++) - our_metadata_.blocks[i]->is_last = false; - our_metadata_.blocks[i]->is_last = true; - - return true; -} - -static void delete_from_our_metadata_(uint32_t position) -{ - uint32_t i; - FLAC__ASSERT(position < our_metadata_.num_blocks); - FLAC__metadata_object_delete(our_metadata_.blocks[position]); - for(i = position; i < our_metadata_.num_blocks - 1; i++) - our_metadata_.blocks[i] = our_metadata_.blocks[i+1]; - our_metadata_.num_blocks--; - - /* set the is_last flags */ - if(our_metadata_.num_blocks > 0) { - for(i = 0; i < our_metadata_.num_blocks - 1; i++) - our_metadata_.blocks[i]->is_last = false; - our_metadata_.blocks[i]->is_last = true; - } -} - -/* - * This wad of functions supports filename- and callback-based chain reading/writing. - * Everything up to set_file_stats_() is copied from libFLAC/metadata_iterators.c - */ -static FLAC__bool open_tempfile_(const char *filename, FILE **tempfile, char **tempfilename) -{ - static const char *tempfile_suffix = ".metadata_edit"; - size_t dest_len = strlen(filename) + strlen(tempfile_suffix) + 1; - - *tempfilename = malloc(dest_len); - if (*tempfilename == NULL) - return false; - safe_strncpy(*tempfilename, filename, dest_len); - safe_strncat(*tempfilename, tempfile_suffix, dest_len); - - *tempfile = flac_fopen(*tempfilename, "wb"); - if (*tempfile == NULL) - return false; - - return true; -} - -static void cleanup_tempfile_(FILE **tempfile, char **tempfilename) -{ - if (*tempfile != NULL) { - (void)fclose(*tempfile); - *tempfile = 0; - } - - if (*tempfilename != NULL) { - (void)flac_unlink(*tempfilename); - free(*tempfilename); - *tempfilename = 0; - } -} - -static FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != tempfile); - FLAC__ASSERT(0 != tempfilename); - FLAC__ASSERT(0 != *tempfilename); - - if(0 != *tempfile) { - (void)fclose(*tempfile); - *tempfile = 0; - } - -#if defined _MSC_VER || defined __MINGW32__ || defined __EMX__ - /* on some flavors of windows, flac_rename() will fail if the destination already exists */ - if(flac_unlink(filename) < 0) { - cleanup_tempfile_(tempfile, tempfilename); - return false; - } -#endif - - if(0 != flac_rename(*tempfilename, filename)) { - cleanup_tempfile_(tempfile, tempfilename); - return false; - } - - cleanup_tempfile_(tempfile, tempfilename); - - return true; -} - -static FLAC__bool get_file_stats_(const char *filename, struct flac_stat_s *stats) -{ - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != stats); - return (0 == flac_stat(filename, stats)); -} - -static void set_file_stats_(const char *filename, struct flac_stat_s *stats) -{ -#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) && !defined(_WIN32) - struct timespec srctime[2] = {}; - srctime[0].tv_sec = stats->st_atime; - srctime[1].tv_sec = stats->st_mtime; -#else - struct utimbuf srctime; - srctime.actime = stats->st_atime; - srctime.modtime = stats->st_mtime; -#endif - FLAC__ASSERT(0 != filename); - FLAC__ASSERT(0 != stats); - - (void)flac_chmod(filename, stats->st_mode); - (void)flac_utime(filename, &srctime); -#if !defined _MSC_VER && !defined __MINGW32__ - FLAC_CHECK_RETURN(chown(filename, stats->st_uid, -1)); - FLAC_CHECK_RETURN(chown(filename, -1, stats->st_gid)); -#endif -} - -#ifdef FLAC__VALGRIND_TESTING -static size_t chain_write_cb_(const void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle) -{ - FILE *stream = (FILE*)handle; - size_t ret = fwrite(ptr, size, nmemb, stream); - if(!ferror(stream)) - fflush(stream); - return ret; -} -#endif - -static int chain_seek_cb_(FLAC__IOHandle handle, FLAC__int64 offset, int whence) -{ - FLAC__off_t o = (FLAC__off_t)offset; - FLAC__ASSERT(offset == o); - return fseeko((FILE*)handle, o, whence); -} - -static FLAC__int64 chain_tell_cb_(FLAC__IOHandle handle) -{ - return ftello((FILE*)handle); -} - -static int chain_eof_cb_(FLAC__IOHandle handle) -{ - return feof((FILE*)handle); -} - -static FLAC__bool write_chain_(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats, FLAC__bool filename_based, const char *filename) -{ - if(filename_based) - return FLAC__metadata_chain_write(chain, use_padding, preserve_file_stats); - else { - FLAC__IOCallbacks callbacks; - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read = (FLAC__IOCallback_Read)fread; -#ifdef FLAC__VALGRIND_TESTING - callbacks.write = chain_write_cb_; -#else - callbacks.write = (FLAC__IOCallback_Write)fwrite; -#endif - callbacks.seek = chain_seek_cb_; - callbacks.eof = chain_eof_cb_; - - if(FLAC__metadata_chain_check_if_tempfile_needed(chain, use_padding)) { - struct flac_stat_s stats; - FILE *file, *tempfile = 0; - char *tempfilename; - if(preserve_file_stats) { - if(!get_file_stats_(filename, &stats)) - return false; - } - if(0 == (file = flac_fopen(filename, "rb"))) - return false; /*@@@@ chain status still says OK though */ - if(!open_tempfile_(filename, &tempfile, &tempfilename)) { - fclose(file); - cleanup_tempfile_(&tempfile, &tempfilename); - return false; /*@@@@ chain status still says OK though */ - } - if(!FLAC__metadata_chain_write_with_callbacks_and_tempfile(chain, use_padding, (FLAC__IOHandle)file, callbacks, (FLAC__IOHandle)tempfile, callbacks)) { - fclose(file); - fclose(tempfile); - return false; - } - fclose(file); - fclose(tempfile); - file = tempfile = 0; - if(!transport_tempfile_(filename, &tempfile, &tempfilename)) - return false; - if(preserve_file_stats) - set_file_stats_(filename, &stats); - } - else { - FILE *file = flac_fopen(filename, "r+b"); - if(0 == file) - return false; /*@@@@ chain status still says OK though */ - if(!FLAC__metadata_chain_write_with_callbacks(chain, use_padding, (FLAC__IOHandle)file, callbacks)) - return false; - fclose(file); - } - } - - return true; -} - -static FLAC__bool read_chain_(FLAC__Metadata_Chain *chain, const char *filename, FLAC__bool filename_based, FLAC__bool is_ogg) -{ - if(filename_based) - return is_ogg? - FLAC__metadata_chain_read_ogg(chain, flacfilename(is_ogg)) : - FLAC__metadata_chain_read(chain, flacfilename(is_ogg)) - ; - else { - FLAC__IOCallbacks callbacks; - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read = (FLAC__IOCallback_Read)fread; - callbacks.seek = chain_seek_cb_; - callbacks.tell = chain_tell_cb_; - - { - FLAC__bool ret; - FILE *file = flac_fopen(filename, "rb"); - if(0 == file) - return false; /*@@@@ chain status still says OK though */ - ret = is_ogg? - FLAC__metadata_chain_read_ogg_with_callbacks(chain, (FLAC__IOHandle)file, callbacks) : - FLAC__metadata_chain_read_with_callbacks(chain, (FLAC__IOHandle)file, callbacks) - ; - fclose(file); - return ret; - } - } -} - -/* function for comparing our metadata to a FLAC__Metadata_Chain */ - -static FLAC__bool compare_chain_(FLAC__Metadata_Chain *chain, uint32_t current_position, FLAC__StreamMetadata *current_block) -{ - uint32_t i; - FLAC__Metadata_Iterator *iterator; - FLAC__StreamMetadata *block; - FLAC__bool next_ok = true; - - FLAC__ASSERT(0 != chain); - - printf("\tcomparing chain... "); - fflush(stdout); - - if(0 == (iterator = FLAC__metadata_iterator_new())) - return die_("allocating memory for iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - i = 0; - do { - printf("%u... ", i); - fflush(stdout); - - if(0 == (block = FLAC__metadata_iterator_get_block(iterator))) { - FLAC__metadata_iterator_delete(iterator); - return die_("getting block from iterator"); - } - - if(!mutils__compare_block(our_metadata_.blocks[i], block)) { - FLAC__metadata_iterator_delete(iterator); - return die_("metadata block mismatch"); - } - - i++; - next_ok = FLAC__metadata_iterator_next(iterator); - } while(i < our_metadata_.num_blocks && next_ok); - - FLAC__metadata_iterator_delete(iterator); - - if(next_ok) - return die_("chain has more blocks than expected"); - - if(i < our_metadata_.num_blocks) - return die_("short block count in chain"); - - if(0 != current_block) { - printf("CURRENT_POSITION... "); - fflush(stdout); - - if(!mutils__compare_block(our_metadata_.blocks[current_position], current_block)) - return die_("metadata block mismatch"); - } - - printf("PASSED\n"); - - return true; -} - -/* decoder callbacks for checking the file */ - -static FLAC__StreamDecoderWriteStatus decoder_write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - (void)decoder, (void)buffer, (void)client_data; - - if( - (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER && frame->header.number.frame_number == 0) || - (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER && frame->header.number.sample_number == 0) - ) { - printf("content... "); - fflush(stdout); - } - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -/* this version pays no attention to the metadata */ -static void decoder_metadata_callback_null_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - (void)decoder, (void)metadata, (void)client_data; - - printf("%u... ", mc_our_block_number_); - fflush(stdout); - - mc_our_block_number_++; -} - -/* this version is used when we want to compare to our metadata copy */ -static void decoder_metadata_callback_compare_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - decoder_client_struct *dcd = (decoder_client_struct*)client_data; - - (void)decoder; - - /* don't bother checking if we've already hit an error */ - if(dcd->error_occurred) - return; - - printf("%u... ", mc_our_block_number_); - fflush(stdout); - - if(mc_our_block_number_ >= our_metadata_.num_blocks) { - (void)die_("got more metadata blocks than expected"); - dcd->error_occurred = true; - } - else { - if(!mutils__compare_block(our_metadata_.blocks[mc_our_block_number_], metadata)) { - (void)die_("metadata block mismatch"); - dcd->error_occurred = true; - } - } - mc_our_block_number_++; -} - -static void decoder_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - decoder_client_struct *dcd = (decoder_client_struct*)client_data; - (void)decoder; - - dcd->error_occurred = true; - printf("ERROR: got error callback, status = %s (%u)\n", FLAC__StreamDecoderErrorStatusString[status], (uint32_t)status); -} - -static FLAC__bool generate_file_(FLAC__bool include_extras, FLAC__bool is_ogg) -{ - FLAC__StreamMetadata streaminfo, vorbiscomment, *cuesheet, picture, padding; - FLAC__StreamMetadata *metadata[4]; - uint32_t i = 0, n = 0; - - printf("generating %sFLAC file for test\n", is_ogg? "Ogg " : ""); - - while(our_metadata_.num_blocks > 0) - delete_from_our_metadata_(0); - - streaminfo.is_last = false; - streaminfo.type = FLAC__METADATA_TYPE_STREAMINFO; - streaminfo.length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; - streaminfo.data.stream_info.min_blocksize = 576; - streaminfo.data.stream_info.max_blocksize = 576; - streaminfo.data.stream_info.min_framesize = 0; - streaminfo.data.stream_info.max_framesize = 0; - streaminfo.data.stream_info.sample_rate = 44100; - streaminfo.data.stream_info.channels = 1; - streaminfo.data.stream_info.bits_per_sample = 8; - streaminfo.data.stream_info.total_samples = 0; - memset(streaminfo.data.stream_info.md5sum, 0, 16); - - { - const uint32_t vendor_string_length = (uint32_t)strlen(FLAC__VENDOR_STRING); - vorbiscomment.is_last = false; - vorbiscomment.type = FLAC__METADATA_TYPE_VORBIS_COMMENT; - vorbiscomment.length = (4 + vendor_string_length) + 4; - vorbiscomment.data.vorbis_comment.vendor_string.length = vendor_string_length; - vorbiscomment.data.vorbis_comment.vendor_string.entry = malloc_or_die_(vendor_string_length+1); - memcpy(vorbiscomment.data.vorbis_comment.vendor_string.entry, FLAC__VENDOR_STRING, vendor_string_length+1); - vorbiscomment.data.vorbis_comment.num_comments = 0; - vorbiscomment.data.vorbis_comment.comments = 0; - } - - { - if (0 == (cuesheet = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET))) - return die_("priming our metadata"); - cuesheet->is_last = false; - safe_strncpy(cuesheet->data.cue_sheet.media_catalog_number, "bogo-MCN", sizeof(cuesheet->data.cue_sheet.media_catalog_number)); - cuesheet->data.cue_sheet.lead_in = 123; - cuesheet->data.cue_sheet.is_cd = false; - if (!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, 0)) - return die_("priming our metadata"); - cuesheet->data.cue_sheet.tracks[0].number = 1; - if (!FLAC__metadata_object_cuesheet_track_insert_blank_index(cuesheet, 0, 0)) - return die_("priming our metadata"); - } - - { - picture.is_last = false; - picture.type = FLAC__METADATA_TYPE_PICTURE; - picture.length = - ( - FLAC__STREAM_METADATA_PICTURE_TYPE_LEN + - FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN + /* will add the length for the string later */ - FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN + /* will add the length for the string later */ - FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN + - FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN + - FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN + - FLAC__STREAM_METADATA_PICTURE_COLORS_LEN + - FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN /* will add the length for the data later */ - ) / 8 - ; - picture.data.picture.type = FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER; - picture.data.picture.mime_type = strdup_or_die_("image/jpeg"); - picture.length += strlen(picture.data.picture.mime_type); - picture.data.picture.description = (FLAC__byte*)strdup_or_die_("desc"); - picture.length += strlen((const char *)picture.data.picture.description); - picture.data.picture.width = 300; - picture.data.picture.height = 300; - picture.data.picture.depth = 24; - picture.data.picture.colors = 0; - picture.data.picture.data = (FLAC__byte*)strdup_or_die_("SOMEJPEGDATA"); - picture.data.picture.data_length = strlen((const char *)picture.data.picture.data); - picture.length += picture.data.picture.data_length; - } - - padding.is_last = true; - padding.type = FLAC__METADATA_TYPE_PADDING; - padding.length = 1234; - - metadata[n++] = &vorbiscomment; - if(include_extras) { - metadata[n++] = cuesheet; - metadata[n++] = &picture; - } - metadata[n++] = &padding; - - if( - !insert_to_our_metadata_(&streaminfo, i++, /*copy=*/true) || - !insert_to_our_metadata_(&vorbiscomment, i++, /*copy=*/true) || - (include_extras && !insert_to_our_metadata_(cuesheet, i++, /*copy=*/false)) || - (include_extras && !insert_to_our_metadata_(&picture, i++, /*copy=*/true)) || - !insert_to_our_metadata_(&padding, i++, /*copy=*/true) - ) - return die_("priming our metadata"); - - if(!file_utils__generate_flacfile(is_ogg, flacfilename(is_ogg), 0, 512 * 1024, &streaminfo, metadata, n)) - return die_("creating the encoded file"); - - free(vorbiscomment.data.vorbis_comment.vendor_string.entry); - free(picture.data.picture.mime_type); - free(picture.data.picture.description); - free(picture.data.picture.data); - if(!include_extras) - FLAC__metadata_object_delete(cuesheet); - - return true; -} - -static FLAC__bool test_file_(FLAC__bool is_ogg, FLAC__StreamDecoderMetadataCallback metadata_callback) -{ - const char *filename = flacfilename(is_ogg); - FLAC__StreamDecoder *decoder; - decoder_client_struct decoder_client_data; - - FLAC__ASSERT(0 != metadata_callback); - - mc_our_block_number_ = 0; - decoder_client_data.error_occurred = false; - - printf("\ttesting '%s'... ", filename); - fflush(stdout); - - if(0 == (decoder = FLAC__stream_decoder_new())) - return die_("couldn't allocate decoder instance"); - - FLAC__stream_decoder_set_md5_checking(decoder, true); - FLAC__stream_decoder_set_metadata_respond_all(decoder); - if( - (is_ogg? - FLAC__stream_decoder_init_ogg_file(decoder, filename, decoder_write_callback_, metadata_callback, decoder_error_callback_, &decoder_client_data) : - FLAC__stream_decoder_init_file(decoder, filename, decoder_write_callback_, metadata_callback, decoder_error_callback_, &decoder_client_data) - ) != FLAC__STREAM_DECODER_INIT_STATUS_OK - ) { - (void)FLAC__stream_decoder_finish(decoder); - FLAC__stream_decoder_delete(decoder); - return die_("initializing decoder\n"); - } - if(!FLAC__stream_decoder_process_until_end_of_stream(decoder)) { - (void)FLAC__stream_decoder_finish(decoder); - FLAC__stream_decoder_delete(decoder); - return die_("decoding file\n"); - } - - (void)FLAC__stream_decoder_finish(decoder); - FLAC__stream_decoder_delete(decoder); - - if(decoder_client_data.error_occurred) - return false; - - if(mc_our_block_number_ != our_metadata_.num_blocks) - return die_("short metadata block count"); - - printf("PASSED\n"); - return true; -} - -static FLAC__bool change_stats_(const char *filename, FLAC__bool read_only) -{ - if(!grabbag__file_change_stats(filename, read_only)) - return die_("during grabbag__file_change_stats()"); - - return true; -} - -static FLAC__bool remove_file_(const char *filename) -{ - while(our_metadata_.num_blocks > 0) - delete_from_our_metadata_(0); - - if(!grabbag__file_remove_file(filename)) - return die_("removing file"); - - return true; -} - -static FLAC__bool test_level_0_(void) -{ - FLAC__StreamMetadata streaminfo; - FLAC__StreamMetadata *tags = 0; - FLAC__StreamMetadata *cuesheet = 0; - FLAC__StreamMetadata *picture = 0; - - printf("\n\n++++++ testing level 0 interface\n"); - - if(!generate_file_(/*include_extras=*/true, /*is_ogg=*/false)) - return false; - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_null_)) - return false; - - printf("testing FLAC__metadata_get_streaminfo()... "); - - if(!FLAC__metadata_get_streaminfo(flacfilename(/*is_ogg=*/false), &streaminfo)) - return die_("during FLAC__metadata_get_streaminfo()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(streaminfo.data.stream_info.channels != 1) - return die_("mismatch in streaminfo.data.stream_info.channels"); - if(streaminfo.data.stream_info.bits_per_sample != 8) - return die_("mismatch in streaminfo.data.stream_info.bits_per_sample"); - if(streaminfo.data.stream_info.sample_rate != 44100) - return die_("mismatch in streaminfo.data.stream_info.sample_rate"); - if(streaminfo.data.stream_info.min_blocksize != 576) - return die_("mismatch in streaminfo.data.stream_info.min_blocksize"); - if(streaminfo.data.stream_info.max_blocksize != 576) - return die_("mismatch in streaminfo.data.stream_info.max_blocksize"); - - printf("OK\n"); - - printf("testing FLAC__metadata_get_tags()... "); - - if(!FLAC__metadata_get_tags(flacfilename(/*is_ogg=*/false), &tags)) - return die_("during FLAC__metadata_get_tags()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(tags->data.vorbis_comment.num_comments != 0) - return die_("mismatch in tags->data.vorbis_comment.num_comments"); - - printf("OK\n"); - - FLAC__metadata_object_delete(tags); - - printf("testing FLAC__metadata_get_cuesheet()... "); - - if(!FLAC__metadata_get_cuesheet(flacfilename(/*is_ogg=*/false), &cuesheet)) - return die_("during FLAC__metadata_get_cuesheet()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(cuesheet->data.cue_sheet.lead_in != 123) - return die_("mismatch in cuesheet->data.cue_sheet.lead_in"); - - printf("OK\n"); - - FLAC__metadata_object_delete(cuesheet); - - printf("testing FLAC__metadata_get_picture()... "); - - if(!FLAC__metadata_get_picture(flacfilename(/*is_ogg=*/false), &picture, /*type=*/(FLAC__StreamMetadata_Picture_Type)(-1), /*mime_type=*/0, /*description=*/0, /*max_width=*/(uint32_t)(-1), /*max_height=*/(uint32_t)(-1), /*max_depth=*/(uint32_t)(-1), /*max_colors=*/(uint32_t)(-1))) - return die_("during FLAC__metadata_get_picture()"); - - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(picture->data.picture.type != FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER) - return die_("mismatch in picture->data.picture.type"); - - printf("OK\n"); - - FLAC__metadata_object_delete(picture); - - if(!remove_file_(flacfilename(/*is_ogg=*/false))) - return false; - - return true; -} - -static FLAC__bool test_level_1_(void) -{ - FLAC__Metadata_SimpleIterator *iterator; - FLAC__StreamMetadata *block, *app, *padding; - FLAC__byte data[1000]; - uint32_t our_current_position = 0; - - /* initialize 'data' to avoid Valgrind errors */ - memset(data, 0, sizeof(data)); - - printf("\n\n++++++ testing level 1 interface\n"); - - /************************************************************/ - - printf("simple iterator on read-only file\n"); - - if(!generate_file_(/*include_extras=*/false, /*is_ogg=*/false)) - return false; - - if(!change_stats_(flacfilename(/*is_ogg=*/false), /*read_only=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_null_)) - return false; - - if(0 == (iterator = FLAC__metadata_simple_iterator_new())) - return die_("FLAC__metadata_simple_iterator_new()"); - - if(!FLAC__metadata_simple_iterator_init(iterator, flacfilename(/*is_ogg=*/false), /*read_only=*/false, /*preserve_file_stats=*/false)) - return die_("FLAC__metadata_simple_iterator_init() returned false"); - - printf("is writable = %u\n", (uint32_t)FLAC__metadata_simple_iterator_is_writable(iterator)); - if(FLAC__metadata_simple_iterator_is_writable(iterator)) - return die_("iterator claims file is writable when tester thinks it should not be; are you running as root?\n"); - - printf("iterate forwards\n"); - - if(FLAC__metadata_simple_iterator_get_block_type(iterator) != FLAC__METADATA_TYPE_STREAMINFO) - return die_("expected STREAMINFO type from FLAC__metadata_simple_iterator_get_block_type()"); - if(0 == (block = FLAC__metadata_simple_iterator_get_block(iterator))) - return die_("getting block 0"); - if(block->type != FLAC__METADATA_TYPE_STREAMINFO) - return die_("expected STREAMINFO type"); - if(block->is_last) - return die_("expected is_last to be false"); - if(block->length != FLAC__STREAM_METADATA_STREAMINFO_LENGTH) - return die_("bad STREAMINFO length"); - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(block->data.stream_info.channels != 1) - return die_("mismatch in channels"); - if(block->data.stream_info.bits_per_sample != 8) - return die_("mismatch in bits_per_sample"); - if(block->data.stream_info.sample_rate != 44100) - return die_("mismatch in sample_rate"); - if(block->data.stream_info.min_blocksize != 576) - return die_("mismatch in min_blocksize"); - if(block->data.stream_info.max_blocksize != 576) - return die_("mismatch in max_blocksize"); - FLAC__metadata_object_delete(block); - - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("forward iterator ended early"); - our_current_position++; - - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("forward iterator ended early"); - our_current_position++; - - if(FLAC__metadata_simple_iterator_get_block_type(iterator) != FLAC__METADATA_TYPE_PADDING) - return die_("expected PADDING type from FLAC__metadata_simple_iterator_get_block_type()"); - if(0 == (block = FLAC__metadata_simple_iterator_get_block(iterator))) - return die_("getting block 2"); - if(block->type != FLAC__METADATA_TYPE_PADDING) - return die_("expected PADDING type"); - if(!block->is_last) - return die_("expected is_last to be true"); - /* check to see if some basic data matches (c.f. generate_file_()) */ - if(block->length != 1234) - return die_("bad PADDING length"); - FLAC__metadata_object_delete(block); - - if(FLAC__metadata_simple_iterator_next(iterator)) - return die_("forward iterator returned true but should have returned false"); - - printf("iterate backwards\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("reverse iterator ended early"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("reverse iterator ended early"); - if(FLAC__metadata_simple_iterator_prev(iterator)) - return die_("reverse iterator returned true but should have returned false"); - - printf("testing FLAC__metadata_simple_iterator_set_block() on read-only file...\n"); - - if(!FLAC__metadata_simple_iterator_set_block(iterator, (FLAC__StreamMetadata*)99, false)) - printf("OK: FLAC__metadata_simple_iterator_set_block() returned false like it should\n"); - else - return die_("FLAC__metadata_simple_iterator_set_block() returned true but shouldn't have"); - - FLAC__metadata_simple_iterator_delete(iterator); - - /************************************************************/ - - printf("simple iterator on writable file\n"); - - if(!change_stats_(flacfilename(/*is_ogg=*/false), /*read-only=*/false)) - return false; - - printf("creating APPLICATION block\n"); - - if(0 == (app = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION))) - return die_("FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)"); - memcpy(app->data.application.id, "duh", (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)); - - printf("creating PADDING block\n"); - - if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING))) - return die_("FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)"); - padding->length = 20; - - if(0 == (iterator = FLAC__metadata_simple_iterator_new())) - return die_("FLAC__metadata_simple_iterator_new()"); - - if(!FLAC__metadata_simple_iterator_init(iterator, flacfilename(/*is_ogg=*/false), /*read_only=*/false, /*preserve_file_stats=*/false)) - return die_("FLAC__metadata_simple_iterator_init() returned false"); - our_current_position = 0; - - printf("is writable = %u\n", (uint32_t)FLAC__metadata_simple_iterator_is_writable(iterator)); - - printf("[S]VP\ttry to write over STREAMINFO block...\n"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, false)) - printf("\tFLAC__metadata_simple_iterator_set_block() returned false like it should\n"); - else - return die_("FLAC__metadata_simple_iterator_set_block() returned true but shouldn't have"); - - if(FLAC__metadata_simple_iterator_status(iterator) != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT) - return die_("FLAC__metadata_simple_iterator_status() should have been FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT"); - - printf("[S]VP\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]P\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]\tinsert PADDING after, don't expand into padding\n"); - padding->length = 25; - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - printf("SVP[P]\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SV[P]P\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]PP\tinsert PADDING after, don't expand into padding\n"); - padding->length = 30; - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[P]PP\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]PPP\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("[S]VPPP\tdelete (STREAMINFO block), must fail\n"); - if(FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false) should have returned false", iterator); - - if(FLAC__metadata_simple_iterator_status(iterator) != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT) - return die_("FLAC__metadata_simple_iterator_status() should have been FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT"); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("[S]VPPP\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]PPP\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]PP\tdelete (middle block), replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, true)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, true)", iterator); - our_current_position--; - - printf("S[V]PPP\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]PP\tdelete (middle block), don't replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("S[V]PP\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]P\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVP[P]\tdelete (last block), replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, true)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - our_current_position--; - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[P]P\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVP[P]\tdelete (last block), don't replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[P]\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]P\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("[S]VP\tset STREAMINFO (change sample rate)\n"); - FLAC__ASSERT(our_current_position == 0); - block = FLAC__metadata_simple_iterator_get_block(iterator); - block->data.stream_info.sample_rate = 32000; - if(!replace_in_our_metadata_(block, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, block, false)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, block, false)", iterator); - FLAC__metadata_object_delete(block); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("[S]VP\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]P\tinsert APPLICATION after, expand into padding of exceeding size\n"); - app->data.application.id[0] = 'e'; /* twiddle the id so that our comparison doesn't miss transposition */ - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)", iterator); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return false; - our_metadata_.blocks[our_current_position+1]->length -= (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) + app->length; - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]P\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVA[P]\tset APPLICATION, expand into padding of exceeding size\n"); - app->data.application.id[0] = 'f'; /* twiddle the id */ - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, true)", iterator); - if(!insert_to_our_metadata_(app, our_current_position, /*copy=*/true)) - return false; - our_metadata_.blocks[our_current_position+1]->length -= (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) + app->length; - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVA[A]P\tset APPLICATION (grow), don't expand into padding\n"); - app->data.application.id[0] = 'g'; /* twiddle the id */ - if(!FLAC__metadata_object_application_set_data(app, data, sizeof(data), true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, false)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVA[A]P\tset APPLICATION (shrink), don't fill in with padding\n"); - app->data.application.id[0] = 'h'; /* twiddle the id */ - if(!FLAC__metadata_object_application_set_data(app, data, 12, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, false)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVA[A]P\tset APPLICATION (grow), expand into padding of exceeding size\n"); - app->data.application.id[0] = 'i'; /* twiddle the id */ - if(!FLAC__metadata_object_application_set_data(app, data, sizeof(data), true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - our_metadata_.blocks[our_current_position+1]->length -= (sizeof(data) - 12); - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVA[A]P\tset APPLICATION (shrink), fill in with padding\n"); - app->data.application.id[0] = 'j'; /* twiddle the id */ - if(!FLAC__metadata_object_application_set_data(app, data, 23, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!insert_to_our_metadata_(padding, our_current_position+1, /*copy=*/true)) - return die_("copying object"); - our_metadata_.blocks[our_current_position+1]->length = sizeof(data) - 23 - FLAC__STREAM_METADATA_HEADER_LENGTH; - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVA[A]PP\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVAA[P]P\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVAAP[P]\tset PADDING (shrink), don't fill in with padding\n"); - padding->length = 5; - if(!replace_in_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, padding, false)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, padding, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVAAP[P]\tset APPLICATION (grow)\n"); - app->data.application.id[0] = 'k'; /* twiddle the id */ - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, false)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVAAP[A]\tset PADDING (equal)\n"); - padding->length = 27; - if(!replace_in_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, padding, false)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, padding, false)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVAAP[P]\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SVAA[P]P\tdelete (middle block), don't replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVA[A]P\tdelete (middle block), don't replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]P\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVA[P]\tinsert PADDING after\n"); - padding->length = 5; - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVAP[P]\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SVA[P]P\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SV[A]PP\tset APPLICATION (grow), try to expand into padding which is too small\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 32, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]PP\tset APPLICATION (grow), try to expand into padding which is 'close' but still too small\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 60, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]PP\tset APPLICATION (grow), expand into padding which will leave 0-length pad\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 87, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - our_metadata_.blocks[our_current_position+1]->length = 0; - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]PP\tset APPLICATION (grow), expand into padding which is exactly consumed\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 91, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]P\tset APPLICATION (grow), expand into padding which is exactly consumed\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 100, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - our_metadata_.blocks[our_current_position]->is_last = true; - if(!FLAC__metadata_simple_iterator_set_block(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]\tset PADDING (equal size)\n"); - padding->length = app->length; - if(!replace_in_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_set_block(iterator, padding, true)) - return die_ss_("FLAC__metadata_simple_iterator_set_block(iterator, padding, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[P]\tinsert PADDING after\n"); - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVP[P]\tinsert PADDING after\n"); - padding->length = 5; - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, padding, false)", iterator); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return false; - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SVPP[P]\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SVP[P]P\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("SV[P]PP\tprev\n"); - if(!FLAC__metadata_simple_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]PPP\tinsert APPLICATION after, try to expand into padding which is too small\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 101, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]PPP\tdelete (middle block), don't replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("S[V]PPP\tinsert APPLICATION after, try to expand into padding which is 'close' but still too small\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 97, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]PPP\tdelete (middle block), don't replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("S[V]PPP\tinsert APPLICATION after, expand into padding which is exactly consumed\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 100, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]PP\tdelete (middle block), don't replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("S[V]PP\tinsert APPLICATION after, expand into padding which will leave 0-length pad\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 96, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - our_metadata_.blocks[our_current_position+1]->length = 0; - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]PP\tdelete (middle block), don't replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("S[V]PP\tnext\n"); - if(!FLAC__metadata_simple_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]P\tdelete (middle block), don't replace with padding\n"); - if(!FLAC__metadata_simple_iterator_delete_block(iterator, false)) - return die_ss_("FLAC__metadata_simple_iterator_delete_block(iterator, false)", iterator); - delete_from_our_metadata_(our_current_position--); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("S[V]P\tinsert APPLICATION after, expand into padding which is exactly consumed\n"); - if(!FLAC__metadata_object_application_set_data(app, data, 1, true)) - return die_("setting APPLICATION data"); - if(!insert_to_our_metadata_(app, ++our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - if(!FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)) - return die_ss_("FLAC__metadata_simple_iterator_insert_block_after(iterator, app, true)", iterator); - - if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_compare_)) - return false; - - printf("delete simple iterator\n"); - - FLAC__metadata_simple_iterator_delete(iterator); - - FLAC__metadata_object_delete(app); - FLAC__metadata_object_delete(padding); - - if(!remove_file_(flacfilename(/*is_ogg=*/false))) - return false; - - return true; -} - -static FLAC__bool test_level_2_(FLAC__bool filename_based, FLAC__bool is_ogg) -{ - FLAC__Metadata_Iterator *iterator; - FLAC__Metadata_Chain *chain; - FLAC__StreamMetadata *block, *app, *padding; - FLAC__byte data[2000]; - uint32_t our_current_position; - - /* initialize 'data' to avoid Valgrind errors */ - memset(data, 0, sizeof(data)); - - printf("\n\n++++++ testing level 2 interface (%s-based, %s FLAC)\n", filename_based? "filename":"callback", is_ogg? "Ogg":"native"); - - printf("generate read-only file\n"); - - if(!generate_file_(/*include_extras=*/false, is_ogg)) - return false; - - if(!change_stats_(flacfilename(is_ogg), /*read_only=*/true)) - return false; - - printf("create chain\n"); - - if(0 == (chain = FLAC__metadata_chain_new())) - return die_("allocating chain"); - - printf("read chain\n"); - - if(!read_chain_(chain, flacfilename(is_ogg), filename_based, is_ogg)) - return die_c_("reading chain", FLAC__metadata_chain_status(chain)); - - printf("[S]VP\ttest initial metadata\n"); - - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - if(is_ogg) - goto end; - - printf("switch file to read-write\n"); - - if(!change_stats_(flacfilename(is_ogg), /*read-only=*/false)) - return false; - - printf("create iterator\n"); - if(0 == (iterator = FLAC__metadata_iterator_new())) - return die_("allocating memory for iterator"); - - our_current_position = 0; - - FLAC__metadata_iterator_init(iterator, chain); - - if(0 == (block = FLAC__metadata_iterator_get_block(iterator))) - return die_("getting block from iterator"); - - FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_STREAMINFO); - - printf("[S]VP\tmodify STREAMINFO, write\n"); - - block->data.stream_info.sample_rate = 32000; - if(!replace_in_our_metadata_(block, our_current_position, /*copy=*/true)) - return die_("copying object"); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/true, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, false, true)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("[S]VP\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]P\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]\treplace PADDING with identical-size APPLICATION\n"); - if(0 == (block = FLAC__metadata_iterator_get_block(iterator))) - return die_("getting block from iterator"); - if(0 == (app = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION))) - return die_("FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)"); - memcpy(app->data.application.id, "duh", (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)); - if(!FLAC__metadata_object_application_set_data(app, data, block->length-(FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, false, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]\tshrink APPLICATION, don't use padding\n"); - if(0 == (app = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("copying object"); - if(!FLAC__metadata_object_application_set_data(app, data, 26, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, false, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]\tgrow APPLICATION, don't use padding\n"); - if(0 == (app = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("copying object"); - if(!FLAC__metadata_object_application_set_data(app, data, 28, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, false, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]\tgrow APPLICATION, use padding, but last block is not padding\n"); - if(0 == (app = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("copying object"); - if(!FLAC__metadata_object_application_set_data(app, data, 36, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, false, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]\tshrink APPLICATION, use padding, last block is not padding, but delta is too small for new PADDING block\n"); - if(0 == (app = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("copying object"); - if(!FLAC__metadata_object_application_set_data(app, data, 33, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, true, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]\tshrink APPLICATION, use padding, last block is not padding, delta is enough for new PADDING block\n"); - if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING))) - return die_("creating PADDING block"); - if(0 == (app = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("copying object"); - if(!FLAC__metadata_object_application_set_data(app, data, 29, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - padding->length = 0; - if(!insert_to_our_metadata_(padding, our_current_position+1, /*copy=*/false)) - return die_("internal error"); - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, true, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]P\tshrink APPLICATION, use padding, last block is padding\n"); - if(0 == (app = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("copying object"); - if(!FLAC__metadata_object_application_set_data(app, data, 16, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - our_metadata_.blocks[our_current_position+1]->length = 13; - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, true, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]P\tgrow APPLICATION, use padding, last block is padding, but delta is too small\n"); - if(0 == (app = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("copying object"); - if(!FLAC__metadata_object_application_set_data(app, data, 50, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, true, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]P\tgrow APPLICATION, use padding, last block is padding of exceeding size\n"); - if(0 == (app = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("copying object"); - if(!FLAC__metadata_object_application_set_data(app, data, 56, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - our_metadata_.blocks[our_current_position+1]->length -= (56 - 50); - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, true, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]P\tgrow APPLICATION, use padding, last block is padding of exact size\n"); - if(0 == (app = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("copying object"); - if(!FLAC__metadata_object_application_set_data(app, data, 67, true)) - return die_("setting APPLICATION data"); - if(!replace_in_our_metadata_(app, our_current_position, /*copy=*/true)) - return die_("copying object"); - delete_from_our_metadata_(our_current_position+1); - if(!FLAC__metadata_iterator_set_block(iterator, app)) - return die_c_("FLAC__metadata_iterator_set_block(iterator, app)", FLAC__metadata_chain_status(chain)); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, true, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV[A]\tprev\n"); - if(!FLAC__metadata_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("S[V]A\tprev\n"); - if(!FLAC__metadata_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("[S]VA\tinsert PADDING before STREAMINFO (should fail)\n"); - if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING))) - return die_("creating PADDING block"); - padding->length = 30; - if(!FLAC__metadata_iterator_insert_block_before(iterator, padding)) - printf("\tFLAC__metadata_iterator_insert_block_before() returned false like it should\n"); - else - return die_("FLAC__metadata_iterator_insert_block_before() should have returned false"); - - printf("[S]VP\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]A\tinsert PADDING after\n"); - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!FLAC__metadata_iterator_insert_block_after(iterator, padding)) - return die_("FLAC__metadata_iterator_insert_block_after(iterator, padding)"); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("SV[P]A\tinsert PADDING before\n"); - if(0 == (padding = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("creating PADDING block"); - padding->length = 17; - if(!insert_to_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!FLAC__metadata_iterator_insert_block_before(iterator, padding)) - return die_("FLAC__metadata_iterator_insert_block_before(iterator, padding)"); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("SV[P]PA\tinsert PADDING before\n"); - if(0 == (padding = FLAC__metadata_object_clone(our_metadata_.blocks[our_current_position]))) - return die_("creating PADDING block"); - padding->length = 0; - if(!insert_to_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!FLAC__metadata_iterator_insert_block_before(iterator, padding)) - return die_("FLAC__metadata_iterator_insert_block_before(iterator, padding)"); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("SV[P]PPA\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVP[P]PA\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVPP[P]A\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SVPPP[A]\tinsert PADDING after\n"); - if(0 == (padding = FLAC__metadata_object_clone(our_metadata_.blocks[2]))) - return die_("creating PADDING block"); - padding->length = 57; - if(!insert_to_our_metadata_(padding, ++our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!FLAC__metadata_iterator_insert_block_after(iterator, padding)) - return die_("FLAC__metadata_iterator_insert_block_after(iterator, padding)"); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("SVPPPA[P]\tinsert PADDING before\n"); - if(0 == (padding = FLAC__metadata_object_clone(our_metadata_.blocks[2]))) - return die_("creating PADDING block"); - padding->length = 99; - if(!insert_to_our_metadata_(padding, our_current_position, /*copy=*/true)) - return die_("copying metadata"); - if(!FLAC__metadata_iterator_insert_block_before(iterator, padding)) - return die_("FLAC__metadata_iterator_insert_block_before(iterator, padding)"); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("delete iterator\n"); - FLAC__metadata_iterator_delete(iterator); - our_current_position = 0; - - printf("SVPPPAPP\tmerge padding\n"); - FLAC__metadata_chain_merge_padding(chain); - our_metadata_.blocks[2]->length += (FLAC__STREAM_METADATA_HEADER_LENGTH + our_metadata_.blocks[3]->length); - our_metadata_.blocks[2]->length += (FLAC__STREAM_METADATA_HEADER_LENGTH + our_metadata_.blocks[4]->length); - our_metadata_.blocks[6]->length += (FLAC__STREAM_METADATA_HEADER_LENGTH + our_metadata_.blocks[7]->length); - delete_from_our_metadata_(7); - delete_from_our_metadata_(4); - delete_from_our_metadata_(3); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, true, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SVPAP\tsort padding\n"); - FLAC__metadata_chain_sort_padding(chain); - our_metadata_.blocks[4]->length += (FLAC__STREAM_METADATA_HEADER_LENGTH + our_metadata_.blocks[2]->length); - delete_from_our_metadata_(2); - - if(!write_chain_(chain, /*use_padding=*/true, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, true, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("create iterator\n"); - if(0 == (iterator = FLAC__metadata_iterator_new())) - return die_("allocating memory for iterator"); - - our_current_position = 0; - - FLAC__metadata_iterator_init(iterator, chain); - - printf("[S]VAP\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("S[V]AP\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[A]P\tdelete middle block, replace with padding\n"); - if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING))) - return die_("creating PADDING block"); - padding->length = 71; - if(!replace_in_our_metadata_(padding, our_current_position--, /*copy=*/false)) - return die_("copying object"); - if(!FLAC__metadata_iterator_delete_block(iterator, /*replace_with_padding=*/true)) - return die_c_("FLAC__metadata_iterator_delete_block(iterator, true)", FLAC__metadata_chain_status(chain)); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("S[V]PP\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]P\tdelete middle block, don't replace with padding\n"); - delete_from_our_metadata_(our_current_position--); - if(!FLAC__metadata_iterator_delete_block(iterator, /*replace_with_padding=*/false)) - return die_c_("FLAC__metadata_iterator_delete_block(iterator, false)", FLAC__metadata_chain_status(chain)); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("S[V]P\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]\tdelete last block, replace with padding\n"); - if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING))) - return die_("creating PADDING block"); - padding->length = 219; - if(!replace_in_our_metadata_(padding, our_current_position--, /*copy=*/false)) - return die_("copying object"); - if(!FLAC__metadata_iterator_delete_block(iterator, /*replace_with_padding=*/true)) - return die_c_("FLAC__metadata_iterator_delete_block(iterator, true)", FLAC__metadata_chain_status(chain)); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("S[V]P\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - our_current_position++; - - printf("SV[P]\tdelete last block, don't replace with padding\n"); - delete_from_our_metadata_(our_current_position--); - if(!FLAC__metadata_iterator_delete_block(iterator, /*replace_with_padding=*/false)) - return die_c_("FLAC__metadata_iterator_delete_block(iterator, false)", FLAC__metadata_chain_status(chain)); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("S[V]\tprev\n"); - if(!FLAC__metadata_iterator_prev(iterator)) - return die_("iterator ended early\n"); - our_current_position--; - - printf("[S]V\tdelete STREAMINFO block, should fail\n"); - if(FLAC__metadata_iterator_delete_block(iterator, /*replace_with_padding=*/false)) - return die_("FLAC__metadata_iterator_delete_block() on STREAMINFO should have failed but didn't"); - - if(!compare_chain_(chain, our_current_position, FLAC__metadata_iterator_get_block(iterator))) - return false; - - printf("delete iterator\n"); - FLAC__metadata_iterator_delete(iterator); - our_current_position = 0; - - printf("SV\tmerge padding\n"); - FLAC__metadata_chain_merge_padding(chain); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, false, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - - printf("SV\tsort padding\n"); - FLAC__metadata_chain_sort_padding(chain); - - if(!write_chain_(chain, /*use_padding=*/false, /*preserve_file_stats=*/false, filename_based, flacfilename(is_ogg))) - return die_c_("during FLAC__metadata_chain_write(chain, false, false)", FLAC__metadata_chain_status(chain)); - if(!compare_chain_(chain, 0, 0)) - return false; - if(!test_file_(is_ogg, decoder_metadata_callback_compare_)) - return false; - -end: - printf("delete chain\n"); - - FLAC__metadata_chain_delete(chain); - - if(!remove_file_(flacfilename(is_ogg))) - return false; - - return true; -} - -static FLAC__bool test_level_2_misc_(FLAC__bool is_ogg) -{ - FLAC__Metadata_Iterator *iterator; - FLAC__Metadata_Chain *chain; - FLAC__IOCallbacks callbacks; - - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.read = (FLAC__IOCallback_Read)fread; -#ifdef FLAC__VALGRIND_TESTING - callbacks.write = chain_write_cb_; -#else - callbacks.write = (FLAC__IOCallback_Write)fwrite; -#endif - callbacks.seek = chain_seek_cb_; - callbacks.tell = chain_tell_cb_; - callbacks.eof = chain_eof_cb_; - - printf("\n\n++++++ testing level 2 interface (mismatched read/write protections)\n"); - - printf("generate file\n"); - - if(!generate_file_(/*include_extras=*/false, is_ogg)) - return false; - - printf("create chain\n"); - - if(0 == (chain = FLAC__metadata_chain_new())) - return die_("allocating chain"); - - printf("read chain (filename-based)\n"); - - if(!FLAC__metadata_chain_read(chain, flacfilename(is_ogg))) - return die_c_("reading chain", FLAC__metadata_chain_status(chain)); - - printf("write chain with wrong method FLAC__metadata_chain_write_with_callbacks()\n"); - { - if(FLAC__metadata_chain_write_with_callbacks(chain, /*use_padding=*/false, 0, callbacks)) - return die_c_("mismatched write should have failed", FLAC__metadata_chain_status(chain)); - if(FLAC__metadata_chain_status(chain) != FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH", FLAC__metadata_chain_status(chain)); - printf(" OK: FLAC__metadata_chain_write_with_callbacks() returned false,FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH like it should\n"); - } - - printf("read chain (filename-based)\n"); - - if(!FLAC__metadata_chain_read(chain, flacfilename(is_ogg))) - return die_c_("reading chain", FLAC__metadata_chain_status(chain)); - - printf("write chain with wrong method FLAC__metadata_chain_write_with_callbacks_and_tempfile()\n"); - { - if(FLAC__metadata_chain_write_with_callbacks_and_tempfile(chain, /*use_padding=*/false, 0, callbacks, 0, callbacks)) - return die_c_("mismatched write should have failed", FLAC__metadata_chain_status(chain)); - if(FLAC__metadata_chain_status(chain) != FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH", FLAC__metadata_chain_status(chain)); - printf(" OK: FLAC__metadata_chain_write_with_callbacks_and_tempfile() returned false,FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH like it should\n"); - } - - printf("read chain (callback-based)\n"); - { - FILE *file = flac_fopen(flacfilename(is_ogg), "rb"); - if(0 == file) - return die_("opening file"); - if(!FLAC__metadata_chain_read_with_callbacks(chain, (FLAC__IOHandle)file, callbacks)) { - fclose(file); - return die_c_("reading chain", FLAC__metadata_chain_status(chain)); - } - fclose(file); - } - - printf("write chain with wrong method FLAC__metadata_chain_write()\n"); - { - if(FLAC__metadata_chain_write(chain, /*use_padding=*/false, /*preserve_file_stats=*/false)) - return die_c_("mismatched write should have failed", FLAC__metadata_chain_status(chain)); - if(FLAC__metadata_chain_status(chain) != FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH", FLAC__metadata_chain_status(chain)); - printf(" OK: FLAC__metadata_chain_write() returned false,FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH like it should\n"); - } - - printf("read chain (callback-based)\n"); - { - FILE *file = flac_fopen(flacfilename(is_ogg), "rb"); - if(0 == file) - return die_("opening file"); - if(!FLAC__metadata_chain_read_with_callbacks(chain, (FLAC__IOHandle)file, callbacks)) { - fclose(file); - return die_c_("reading chain", FLAC__metadata_chain_status(chain)); - } - fclose(file); - } - - printf("testing FLAC__metadata_chain_check_if_tempfile_needed()... "); - - if(!FLAC__metadata_chain_check_if_tempfile_needed(chain, /*use_padding=*/false)) - printf("OK: FLAC__metadata_chain_check_if_tempfile_needed() returned false like it should\n"); - else - return die_("FLAC__metadata_chain_check_if_tempfile_needed() returned true but shouldn't have"); - - printf("write chain with wrong method FLAC__metadata_chain_write_with_callbacks_and_tempfile()\n"); - { - if(FLAC__metadata_chain_write_with_callbacks_and_tempfile(chain, /*use_padding=*/false, 0, callbacks, 0, callbacks)) - return die_c_("mismatched write should have failed", FLAC__metadata_chain_status(chain)); - if(FLAC__metadata_chain_status(chain) != FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL", FLAC__metadata_chain_status(chain)); - printf(" OK: FLAC__metadata_chain_write_with_callbacks_and_tempfile() returned false,FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL like it should\n"); - } - - printf("read chain (callback-based)\n"); - { - FILE *file = flac_fopen(flacfilename(is_ogg), "rb"); - if(0 == file) - return die_("opening file"); - if(!FLAC__metadata_chain_read_with_callbacks(chain, (FLAC__IOHandle)file, callbacks)) { - fclose(file); - return die_c_("reading chain", FLAC__metadata_chain_status(chain)); - } - fclose(file); - } - - printf("create iterator\n"); - if(0 == (iterator = FLAC__metadata_iterator_new())) - return die_("allocating memory for iterator"); - - FLAC__metadata_iterator_init(iterator, chain); - - printf("[S]VP\tnext\n"); - if(!FLAC__metadata_iterator_next(iterator)) - return die_("iterator ended early\n"); - - printf("S[V]P\tdelete VORBIS_COMMENT, write\n"); - if(!FLAC__metadata_iterator_delete_block(iterator, /*replace_with_padding=*/false)) - return die_c_("block delete failed\n", FLAC__metadata_chain_status(chain)); - - printf("testing FLAC__metadata_chain_check_if_tempfile_needed()... "); - - if(FLAC__metadata_chain_check_if_tempfile_needed(chain, /*use_padding=*/false)) - printf("OK: FLAC__metadata_chain_check_if_tempfile_needed() returned true like it should\n"); - else - return die_("FLAC__metadata_chain_check_if_tempfile_needed() returned false but shouldn't have"); - - printf("write chain with wrong method FLAC__metadata_chain_write_with_callbacks()\n"); - { - if(FLAC__metadata_chain_write_with_callbacks(chain, /*use_padding=*/false, 0, callbacks)) - return die_c_("mismatched write should have failed", FLAC__metadata_chain_status(chain)); - if(FLAC__metadata_chain_status(chain) != FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL) - return die_c_("expected FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL", FLAC__metadata_chain_status(chain)); - printf(" OK: FLAC__metadata_chain_write_with_callbacks() returned false,FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL like it should\n"); - } - - printf("delete iterator\n"); - - FLAC__metadata_iterator_delete(iterator); - - printf("delete chain\n"); - - FLAC__metadata_chain_delete(chain); - - if(!remove_file_(flacfilename(is_ogg))) - return false; - - return true; -} - -FLAC__bool test_metadata_file_manipulation(void) -{ - printf("\n+++ libFLAC unit test: metadata manipulation\n\n"); - - our_metadata_.num_blocks = 0; - - if(!test_level_0_()) - return false; - - if(!test_level_1_()) - return false; - - if(!test_level_2_(/*filename_based=*/true, /*is_ogg=*/false)) /* filename-based */ - return false; - if(!test_level_2_(/*filename_based=*/false, /*is_ogg=*/false)) /* callback-based */ - return false; - if(!test_level_2_misc_(/*is_ogg=*/false)) - return false; - - if(FLAC_API_SUPPORTS_OGG_FLAC) { - if(!test_level_2_(/*filename_based=*/true, /*is_ogg=*/true)) /* filename-based */ - return false; - if(!test_level_2_(/*filename_based=*/false, /*is_ogg=*/true)) /* callback-based */ - return false; -#if 0 - /* when ogg flac write is supported, will have to add this: */ - if(!test_level_2_misc_(/*is_ogg=*/true)) - return false; -#endif - } - - return true; -} diff --git a/Engine/lib/flac/src/test_libFLAC/metadata_object.c b/Engine/lib/flac/src/test_libFLAC/metadata_object.c deleted file mode 100644 index ea6b69fd7..000000000 --- a/Engine/lib/flac/src/test_libFLAC/metadata_object.c +++ /dev/null @@ -1,2291 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/assert.h" -#include "FLAC/metadata.h" -#include "test_libs_common/metadata_utils.h" -#include "share/compat.h" -#include "metadata.h" -#include -#include /* for malloc() */ -#include /* for memcmp() */ - -static FLAC__byte *make_dummydata_(FLAC__byte *dummydata, uint32_t len) -{ - FLAC__byte *ret; - - if(0 == (ret = malloc(len))) { - printf("FAILED, malloc error\n"); - exit(1); - } - else - memcpy(ret, dummydata, len); - - return ret; -} - -static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from, const FLAC__StreamMetadata_CueSheet_Track *to) -{ - uint32_t i; - - if(from->offset != to->offset) { - printf("FAILED, track offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", to->offset, from->offset); - return false; - } - if(from->number != to->number) { - printf("FAILED, track number mismatch, expected %u, got %u\n", (uint32_t)to->number, (uint32_t)from->number); - return false; - } - if(0 != strcmp(from->isrc, to->isrc)) { - printf("FAILED, track number mismatch, expected %s, got %s\n", to->isrc, from->isrc); - return false; - } - if(from->type != to->type) { - printf("FAILED, track type mismatch, expected %u, got %u\n", (uint32_t)to->type, (uint32_t)from->type); - return false; - } - if(from->pre_emphasis != to->pre_emphasis) { - printf("FAILED, track pre_emphasis mismatch, expected %u, got %u\n", (uint32_t)to->pre_emphasis, (uint32_t)from->pre_emphasis); - return false; - } - if(from->num_indices != to->num_indices) { - printf("FAILED, track num_indices mismatch, expected %u, got %u\n", (uint32_t)to->num_indices, (uint32_t)from->num_indices); - return false; - } - if(0 == to->indices || 0 == from->indices) { - if(to->indices != from->indices) { - printf("FAILED, track indices mismatch\n"); - return false; - } - } - else { - for(i = 0; i < to->num_indices; i++) { - if(from->indices[i].offset != to->indices[i].offset) { - printf("FAILED, track indices[%u].offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, to->indices[i].offset, from->indices[i].offset); - return false; - } - if(from->indices[i].number != to->indices[i].number) { - printf("FAILED, track indices[%u].number mismatch, expected %u, got %u\n", i, (uint32_t)to->indices[i].number, (uint32_t)from->indices[i].number); - return false; - } - } - } - - return true; -} - -static FLAC__bool compare_seekpoint_array_(const FLAC__StreamMetadata_SeekPoint *from, const FLAC__StreamMetadata_SeekPoint *to, uint32_t n) -{ - uint32_t i; - - FLAC__ASSERT(0 != from); - FLAC__ASSERT(0 != to); - - for(i = 0; i < n; i++) { - if(from[i].sample_number != to[i].sample_number) { - printf("FAILED, point[%u].sample_number mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, to[i].sample_number, from[i].sample_number); - return false; - } - if(from[i].stream_offset != to[i].stream_offset) { - printf("FAILED, point[%u].stream_offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, to[i].stream_offset, from[i].stream_offset); - return false; - } - if(from[i].frame_samples != to[i].frame_samples) { - printf("FAILED, point[%u].frame_samples mismatch, expected %u, got %u\n", i, to[i].frame_samples, from[i].frame_samples); - return false; - } - } - - return true; -} - -static FLAC__bool check_seektable_(const FLAC__StreamMetadata *block, uint32_t num_points, const FLAC__StreamMetadata_SeekPoint *array) -{ - const uint32_t expected_length = num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; - - if(block->length != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); - return false; - } - if(block->data.seek_table.num_points != num_points) { - printf("FAILED, expected %u point, got %u\n", num_points, block->data.seek_table.num_points); - return false; - } - if(0 == array) { - if(0 != block->data.seek_table.points) { - printf("FAILED, 'points' pointer is not null\n"); - return false; - } - } - else { - if(!compare_seekpoint_array_(block->data.seek_table.points, array, num_points)) - return false; - } - printf("OK\n"); - - return true; -} - -static void entry_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field) -{ - entry->length = strlen(field); - entry->entry = malloc(entry->length+1); - FLAC__ASSERT(0 != entry->entry); - memcpy(entry->entry, field, entry->length); - entry->entry[entry->length] = '\0'; -} - -static void entry_clone_(FLAC__StreamMetadata_VorbisComment_Entry *entry) -{ - FLAC__byte *x = malloc(entry->length+1); - FLAC__ASSERT(0 != x); - memcpy(x, entry->entry, entry->length); - x[entry->length] = '\0'; - entry->entry = x; -} - -static void vc_calc_len_(FLAC__StreamMetadata *block) -{ - const FLAC__StreamMetadata_VorbisComment *vc = &block->data.vorbis_comment; - uint32_t i; - - block->length = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8; - block->length += vc->vendor_string.length; - block->length += FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8; - for(i = 0; i < vc->num_comments; i++) { - block->length += FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8; - block->length += vc->comments[i].length; - } -} - -static void vc_resize_(FLAC__StreamMetadata *block, uint32_t num) -{ - FLAC__StreamMetadata_VorbisComment *vc = &block->data.vorbis_comment; - - if(vc->num_comments != 0) { - FLAC__ASSERT(0 != vc->comments); - if(num < vc->num_comments) { - uint32_t i; - for(i = num; i < vc->num_comments; i++) { - if(0 != vc->comments[i].entry) - free(vc->comments[i].entry); - } - } - } - if(num == 0) { - if(0 != vc->comments) { - free(vc->comments); - vc->comments = 0; - } - } - else { - uint32_t i; - vc->comments = realloc(vc->comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*num); - FLAC__ASSERT(0 != vc->comments); - for(i = vc->num_comments; i < num; i++) { - vc->comments[i].length = 0; - vc->comments[i].entry = malloc(1); - vc->comments[i].entry[0] = '\0'; - } - } - - vc->num_comments = num; - vc_calc_len_(block); -} - -static int vc_find_from_(FLAC__StreamMetadata *block, const char *name, uint32_t start) -{ - const uint32_t n = strlen(name); - uint32_t i; - for(i = start; i < block->data.vorbis_comment.num_comments; i++) { - const FLAC__StreamMetadata_VorbisComment_Entry *entry = &block->data.vorbis_comment.comments[i]; - if(entry->length > n && 0 == strncmp((const char *)entry->entry, name, n) && entry->entry[n] == '=') - return (int)i; - } - return -1; -} - -static void vc_set_vs_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, const char *field) -{ - if(0 != block->data.vorbis_comment.vendor_string.entry) - free(block->data.vorbis_comment.vendor_string.entry); - entry_new_(entry, field); - block->data.vorbis_comment.vendor_string = *entry; - vc_calc_len_(block); -} - -static void vc_set_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, uint32_t pos, const char *field) -{ - if(0 != block->data.vorbis_comment.comments[pos].entry) - free(block->data.vorbis_comment.comments[pos].entry); - entry_new_(entry, field); - block->data.vorbis_comment.comments[pos] = *entry; - vc_calc_len_(block); -} - -static void vc_insert_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, uint32_t pos, const char *field) -{ - FLAC__StreamMetadata_VorbisComment_Entry temp; - vc_resize_(block, block->data.vorbis_comment.num_comments+1); - temp = block->data.vorbis_comment.comments[block->data.vorbis_comment.num_comments-1]; - memmove(&block->data.vorbis_comment.comments[pos+1], &block->data.vorbis_comment.comments[pos], sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(block->data.vorbis_comment.num_comments-1-pos)); - block->data.vorbis_comment.comments[pos] = temp; - vc_set_new_(entry, block, pos, field); - vc_calc_len_(block); -} - -static void vc_delete_(FLAC__StreamMetadata *block, uint32_t pos) -{ - if(0 != block->data.vorbis_comment.comments[pos].entry) - free(block->data.vorbis_comment.comments[pos].entry); - memmove(&block->data.vorbis_comment.comments[pos], &block->data.vorbis_comment.comments[pos+1], sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(block->data.vorbis_comment.num_comments-pos-1)); - block->data.vorbis_comment.comments[block->data.vorbis_comment.num_comments-1].entry = 0; - block->data.vorbis_comment.comments[block->data.vorbis_comment.num_comments-1].length = 0; - vc_resize_(block, block->data.vorbis_comment.num_comments-1); - vc_calc_len_(block); -} - -static void vc_replace_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, const char *field, FLAC__bool all) -{ - int indx; - char field_name[256]; - const char *eq = strchr(field, '='); - FLAC__ASSERT(eq>field && (uint32_t)(eq-field) < sizeof(field_name)); - memcpy(field_name, field, eq-field); - field_name[eq-field]='\0'; - - indx = vc_find_from_(block, field_name, 0); - if(indx < 0) - vc_insert_new_(entry, block, block->data.vorbis_comment.num_comments, field); - else { - vc_set_new_(entry, block, (uint32_t)indx, field); - if(all) { - for(indx = indx+1; indx >= 0 && (uint32_t)indx < block->data.vorbis_comment.num_comments; ) - if((indx = vc_find_from_(block, field_name, (uint32_t)indx)) >= 0) - vc_delete_(block, (uint32_t)indx); - } - } - - vc_calc_len_(block); -} - -static void track_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em) -{ - track->offset = offset; - track->number = number; - memcpy(track->isrc, isrc, sizeof(track->isrc)); - track->type = data; - track->pre_emphasis = pre_em; - track->num_indices = 0; - track->indices = 0; -} - -static void track_clone_(FLAC__StreamMetadata_CueSheet_Track *track) -{ - if(track->num_indices > 0) { - size_t bytes = sizeof(FLAC__StreamMetadata_CueSheet_Index) * track->num_indices; - FLAC__StreamMetadata_CueSheet_Index *x = malloc(bytes); - FLAC__ASSERT(0 != x); - memcpy(x, track->indices, bytes); - track->indices = x; - } -} - -static void cs_calc_len_(FLAC__StreamMetadata *block) -{ - const FLAC__StreamMetadata_CueSheet *cs = &block->data.cue_sheet; - uint32_t i; - - block->length = ( - FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN + - FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + - FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN - ) / 8; - block->length += cs->num_tracks * ( - FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN - ) / 8; - for(i = 0; i < cs->num_tracks; i++) { - block->length += cs->tracks[i].num_indices * ( - FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN + - FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN - ) / 8; - } -} - -static void tr_resize_(FLAC__StreamMetadata *block, uint32_t track_num, uint32_t num) -{ - FLAC__StreamMetadata_CueSheet_Track *tr; - - FLAC__ASSERT(track_num < block->data.cue_sheet.num_tracks); - - tr = &block->data.cue_sheet.tracks[track_num]; - - if(tr->num_indices != 0) { - FLAC__ASSERT(0 != tr->indices); - } - if(num == 0) { - if(0 != tr->indices) { - free(tr->indices); - tr->indices = 0; - } - } - else { - tr->indices = realloc(tr->indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)*num); - FLAC__ASSERT(0 != tr->indices); - if(num > tr->num_indices) - memset(tr->indices+tr->num_indices, 0, sizeof(FLAC__StreamMetadata_CueSheet_Index)*(num-tr->num_indices)); - } - - tr->num_indices = num; - cs_calc_len_(block); -} - -static void tr_set_new_(FLAC__StreamMetadata *block, uint32_t track_num, uint32_t pos, FLAC__StreamMetadata_CueSheet_Index indx) -{ - FLAC__StreamMetadata_CueSheet_Track *tr; - - FLAC__ASSERT(track_num < block->data.cue_sheet.num_tracks); - - tr = &block->data.cue_sheet.tracks[track_num]; - - FLAC__ASSERT(pos < tr->num_indices); - - tr->indices[pos] = indx; - - cs_calc_len_(block); -} - -static void tr_insert_new_(FLAC__StreamMetadata *block, uint32_t track_num, uint32_t pos, FLAC__StreamMetadata_CueSheet_Index indx) -{ - FLAC__StreamMetadata_CueSheet_Track *tr; - - FLAC__ASSERT(track_num < block->data.cue_sheet.num_tracks); - - tr = &block->data.cue_sheet.tracks[track_num]; - - FLAC__ASSERT(pos <= tr->num_indices); - - tr_resize_(block, track_num, tr->num_indices+1); - memmove(&tr->indices[pos+1], &tr->indices[pos], sizeof(FLAC__StreamMetadata_CueSheet_Index)*(tr->num_indices-1-pos)); - tr_set_new_(block, track_num, pos, indx); - cs_calc_len_(block); -} - -static void tr_delete_(FLAC__StreamMetadata *block, uint32_t track_num, uint32_t pos) -{ - FLAC__StreamMetadata_CueSheet_Track *tr; - - FLAC__ASSERT(track_num < block->data.cue_sheet.num_tracks); - - tr = &block->data.cue_sheet.tracks[track_num]; - - FLAC__ASSERT(pos <= tr->num_indices); - - memmove(&tr->indices[pos], &tr->indices[pos+1], sizeof(FLAC__StreamMetadata_CueSheet_Index)*(tr->num_indices-pos-1)); - tr_resize_(block, track_num, tr->num_indices-1); - cs_calc_len_(block); -} - -static void cs_resize_(FLAC__StreamMetadata *block, uint32_t num) -{ - FLAC__StreamMetadata_CueSheet *cs = &block->data.cue_sheet; - - if(cs->num_tracks != 0) { - FLAC__ASSERT(0 != cs->tracks); - if(num < cs->num_tracks) { - uint32_t i; - for(i = num; i < cs->num_tracks; i++) { - if(0 != cs->tracks[i].indices) - free(cs->tracks[i].indices); - } - } - } - if(num == 0) { - if(0 != cs->tracks) { - free(cs->tracks); - cs->tracks = 0; - } - } - else { - cs->tracks = realloc(cs->tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)*num); - FLAC__ASSERT(0 != cs->tracks); - if(num > cs->num_tracks) - memset(cs->tracks+cs->num_tracks, 0, sizeof(FLAC__StreamMetadata_CueSheet_Track)*(num-cs->num_tracks)); - } - - cs->num_tracks = num; - cs_calc_len_(block); -} - -static void cs_set_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__StreamMetadata *block, uint32_t pos, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em) -{ - track_new_(track, offset, number, isrc, data, pre_em); - block->data.cue_sheet.tracks[pos] = *track; - cs_calc_len_(block); -} - -static void cs_insert_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__StreamMetadata *block, uint32_t pos, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em) -{ - cs_resize_(block, block->data.cue_sheet.num_tracks+1); - memmove(&block->data.cue_sheet.tracks[pos+1], &block->data.cue_sheet.tracks[pos], sizeof(FLAC__StreamMetadata_CueSheet_Track)*(block->data.cue_sheet.num_tracks-1-pos)); - cs_set_new_(track, block, pos, offset, number, isrc, data, pre_em); - cs_calc_len_(block); -} - -static void cs_delete_(FLAC__StreamMetadata *block, uint32_t pos) -{ - if(0 != block->data.cue_sheet.tracks[pos].indices) - free(block->data.cue_sheet.tracks[pos].indices); - memmove(&block->data.cue_sheet.tracks[pos], &block->data.cue_sheet.tracks[pos+1], sizeof(FLAC__StreamMetadata_CueSheet_Track)*(block->data.cue_sheet.num_tracks-pos-1)); - block->data.cue_sheet.tracks[block->data.cue_sheet.num_tracks-1].indices = 0; - block->data.cue_sheet.tracks[block->data.cue_sheet.num_tracks-1].num_indices = 0; - cs_resize_(block, block->data.cue_sheet.num_tracks-1); - cs_calc_len_(block); -} - -static void pi_set_mime_type(FLAC__StreamMetadata *block, const char *s) -{ - if(block->data.picture.mime_type) { - block->length -= strlen(block->data.picture.mime_type); - free(block->data.picture.mime_type); - } - block->data.picture.mime_type = strdup(s); - FLAC__ASSERT(block->data.picture.mime_type); - block->length += strlen(block->data.picture.mime_type); -} - -static void pi_set_description(FLAC__StreamMetadata *block, const FLAC__byte *s) -{ - if(block->data.picture.description) { - block->length -= strlen((const char *)block->data.picture.description); - free(block->data.picture.description); - } - block->data.picture.description = (FLAC__byte*)strdup((const char *)s); - FLAC__ASSERT(block->data.picture.description); - block->length += strlen((const char *)block->data.picture.description); -} - -static void pi_set_data(FLAC__StreamMetadata *block, const FLAC__byte *data, FLAC__uint32 len) -{ - if(block->data.picture.data) { - block->length -= block->data.picture.data_length; - free(block->data.picture.data); - } - block->data.picture.data = (FLAC__byte*)strdup((const char *)data); - FLAC__ASSERT(block->data.picture.data); - block->data.picture.data_length = len; - block->length += len; -} - -FLAC__bool test_metadata_object(void) -{ - FLAC__StreamMetadata *block, *blockcopy, *vorbiscomment, *cuesheet, *picture; - FLAC__StreamMetadata_SeekPoint seekpoint_array[14]; - FLAC__StreamMetadata_VorbisComment_Entry entry; - FLAC__StreamMetadata_CueSheet_Index indx; - FLAC__StreamMetadata_CueSheet_Track track; - uint32_t i, expected_length, seekpoints; - int j; - static FLAC__byte dummydata[4] = { 'a', 'b', 'c', 'd' }; - - printf("\n+++ libFLAC unit test: metadata objects\n\n"); - - - printf("testing STREAMINFO\n"); - - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_STREAMINFO); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - expected_length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; - if(block->length != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - - printf("testing PADDING\n"); - - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - expected_length = 0; - if(block->length != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - - printf("testing APPLICATION\n"); - - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - expected_length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; - if(block->length != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - printf("OK\n"); - - printf("testing FLAC__metadata_object_application_set_data(copy)... "); - if(!FLAC__metadata_object_application_set_data(block, dummydata, sizeof(dummydata), true/*copy*/)) { - printf("FAILED, returned false\n"); - return false; - } - expected_length = (FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8) + sizeof(dummydata); - if(block->length != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); - return false; - } - if(0 != memcmp(block->data.application.data, dummydata, sizeof(dummydata))) { - printf("FAILED, data mismatch\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - printf("OK\n"); - - printf("testing FLAC__metadata_object_application_set_data(own)... "); - if(!FLAC__metadata_object_application_set_data(block, make_dummydata_(dummydata, sizeof(dummydata)), sizeof(dummydata), false/*own*/)) { - printf("FAILED, returned false\n"); - return false; - } - expected_length = (FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8) + sizeof(dummydata); - if(block->length != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); - return false; - } - if(0 != memcmp(block->data.application.data, dummydata, sizeof(dummydata))) { - printf("FAILED, data mismatch\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - - printf("testing SEEKTABLE\n"); - - for(i = 0; i < sizeof(seekpoint_array) / sizeof(FLAC__StreamMetadata_SeekPoint); i++) { - seekpoint_array[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - seekpoint_array[i].stream_offset = 0; - seekpoint_array[i].frame_samples = 0; - } - - seekpoints = 0; - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!check_seektable_(block, seekpoints, 0)) - return false; - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - printf("OK\n"); - - seekpoints = 2; - printf("testing FLAC__metadata_object_seektable_resize_points(grow to %u)...", seekpoints); - if(!FLAC__metadata_object_seektable_resize_points(block, seekpoints)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoints = 1; - printf("testing FLAC__metadata_object_seektable_resize_points(shrink to %u)...", seekpoints); - if(!FLAC__metadata_object_seektable_resize_points(block, seekpoints)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - printf("testing FLAC__metadata_object_seektable_is_legal()..."); - if(!FLAC__metadata_object_seektable_is_legal(block)) { - printf("FAILED, returned false\n"); - return false; - } - printf("OK\n"); - - seekpoints = 0; - printf("testing FLAC__metadata_object_seektable_resize_points(shrink to %u)...", seekpoints); - if(!FLAC__metadata_object_seektable_resize_points(block, seekpoints)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, 0)) - return false; - - seekpoints++; - printf("testing FLAC__metadata_object_seektable_insert_point() on empty array..."); - if(!FLAC__metadata_object_seektable_insert_point(block, 0, seekpoint_array[0])) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoint_array[0].sample_number = 1; - seekpoints++; - printf("testing FLAC__metadata_object_seektable_insert_point() on beginning of non-empty array..."); - if(!FLAC__metadata_object_seektable_insert_point(block, 0, seekpoint_array[0])) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoint_array[1].sample_number = 2; - seekpoints++; - printf("testing FLAC__metadata_object_seektable_insert_point() on middle of non-empty array..."); - if(!FLAC__metadata_object_seektable_insert_point(block, 1, seekpoint_array[1])) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoint_array[3].sample_number = 3; - seekpoints++; - printf("testing FLAC__metadata_object_seektable_insert_point() on end of non-empty array..."); - if(!FLAC__metadata_object_seektable_insert_point(block, 3, seekpoint_array[3])) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - printf("OK\n"); - - seekpoint_array[2].sample_number = seekpoint_array[3].sample_number; - seekpoints--; - printf("testing FLAC__metadata_object_seektable_delete_point() on middle of array..."); - if(!FLAC__metadata_object_seektable_delete_point(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoints--; - printf("testing FLAC__metadata_object_seektable_delete_point() on end of array..."); - if(!FLAC__metadata_object_seektable_delete_point(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoints--; - printf("testing FLAC__metadata_object_seektable_delete_point() on beginning of array..."); - if(!FLAC__metadata_object_seektable_delete_point(block, 0)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array+1)) - return false; - - printf("testing FLAC__metadata_object_seektable_set_point()..."); - FLAC__metadata_object_seektable_set_point(block, 0, seekpoint_array[0]); - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - /* seektable template functions */ - - for(i = 0; i < sizeof(seekpoint_array) / sizeof(FLAC__StreamMetadata_SeekPoint); i++) { - seekpoint_array[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - seekpoint_array[i].stream_offset = 0; - seekpoint_array[i].frame_samples = 0; - } - - seekpoints = 0; - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!check_seektable_(block, seekpoints, 0)) - return false; - - seekpoints += 2; - printf("testing FLAC__metadata_object_seekpoint_template_append_placeholders()... "); - if(!FLAC__metadata_object_seektable_template_append_placeholders(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoint_array[seekpoints++].sample_number = 7; - printf("testing FLAC__metadata_object_seekpoint_template_append_point()... "); - if(!FLAC__metadata_object_seektable_template_append_point(block, 7)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - { - FLAC__uint64 nums[2] = { 3, 7 }; - seekpoint_array[seekpoints++].sample_number = nums[0]; - seekpoint_array[seekpoints++].sample_number = nums[1]; - printf("testing FLAC__metadata_object_seekpoint_template_append_points()... "); - if(!FLAC__metadata_object_seektable_template_append_points(block, nums, sizeof(nums)/sizeof(FLAC__uint64))) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - } - - seekpoint_array[seekpoints++].sample_number = 0; - seekpoint_array[seekpoints++].sample_number = 10; - seekpoint_array[seekpoints++].sample_number = 20; - printf("testing FLAC__metadata_object_seekpoint_template_append_spaced_points()... "); - if(!FLAC__metadata_object_seektable_template_append_spaced_points(block, 3, 30)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoints--; - seekpoint_array[0].sample_number = 0; - seekpoint_array[1].sample_number = 3; - seekpoint_array[2].sample_number = 7; - seekpoint_array[3].sample_number = 10; - seekpoint_array[4].sample_number = 20; - seekpoint_array[5].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - seekpoint_array[6].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - printf("testing FLAC__metadata_object_seekpoint_template_sort(compact=true)... "); - if(!FLAC__metadata_object_seektable_template_sort(block, /*compact=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!FLAC__metadata_object_seektable_is_legal(block)) { - printf("FAILED, seek table is illegal\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - printf("testing FLAC__metadata_object_seekpoint_template_sort(compact=false)... "); - if(!FLAC__metadata_object_seektable_template_sort(block, /*compact=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!FLAC__metadata_object_seektable_is_legal(block)) { - printf("FAILED, seek table is illegal\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoint_array[seekpoints++].sample_number = 0; - seekpoint_array[seekpoints++].sample_number = 10; - seekpoint_array[seekpoints++].sample_number = 20; - printf("testing FLAC__metadata_object_seekpoint_template_append_spaced_points_by_samples()... "); - if(!FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(block, 10, 30)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - seekpoint_array[seekpoints++].sample_number = 0; - seekpoint_array[seekpoints++].sample_number = 11; - seekpoint_array[seekpoints++].sample_number = 22; - printf("testing FLAC__metadata_object_seekpoint_template_append_spaced_points_by_samples()... "); - if(!FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(block, 11, 30)) { - printf("FAILED, returned false\n"); - return false; - } - if(!check_seektable_(block, seekpoints, seekpoint_array)) - return false; - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - - printf("testing VORBIS_COMMENT\n"); - - { - FLAC__StreamMetadata_VorbisComment_Entry entry_; - char *field_name, *field_value; - - printf("testing FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair()... "); - if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry_, "name", "value")) { - printf("FAILED, returned false\n"); - return false; - } - if(strcmp((const char *)entry_.entry, "name=value")) { - printf("FAILED, field mismatch\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair()... "); - if(!FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(entry_, &field_name, &field_value)) { - printf("FAILED, returned false\n"); - return false; - } - if(strcmp(field_name, "name")) { - printf("FAILED, field name mismatch\n"); - return false; - } - if(strcmp(field_value, "value")) { - printf("FAILED, field value mismatch\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_entry_matches()... "); - if(!FLAC__metadata_object_vorbiscomment_entry_matches(entry_, field_name, strlen(field_name))) { - printf("FAILED, expected true, returned false\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_entry_matches()... "); - if(FLAC__metadata_object_vorbiscomment_entry_matches(entry_, "blah", strlen("blah"))) { - printf("FAILED, expected false, returned true\n"); - return false; - } - printf("OK\n"); - - free(entry_.entry); - free(field_name); - free(field_value); - } - - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - expected_length = (FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + strlen(FLAC__VENDOR_STRING) + FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN/8); - if(block->length != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - vorbiscomment = FLAC__metadata_object_clone(block); - if(0 == vorbiscomment) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - vc_resize_(vorbiscomment, 2); - printf("testing FLAC__metadata_object_vorbiscomment_resize_comments(grow to %u)...", vorbiscomment->data.vorbis_comment.num_comments); - if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, vorbiscomment->data.vorbis_comment.num_comments)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - vc_resize_(vorbiscomment, 1); - printf("testing FLAC__metadata_object_vorbiscomment_resize_comments(shrink to %u)...", vorbiscomment->data.vorbis_comment.num_comments); - if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, vorbiscomment->data.vorbis_comment.num_comments)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - vc_resize_(vorbiscomment, 0); - printf("testing FLAC__metadata_object_vorbiscomment_resize_comments(shrink to %u)...", vorbiscomment->data.vorbis_comment.num_comments); - if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, vorbiscomment->data.vorbis_comment.num_comments)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on empty array..."); - vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1"); - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 1, "name2=field2"); - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - vc_resize_(vorbiscomment, 0); - printf("testing FLAC__metadata_object_vorbiscomment_resize_comments(shrink to %u)...", vorbiscomment->data.vorbis_comment.num_comments); - if(!FLAC__metadata_object_vorbiscomment_resize_comments(block, vorbiscomment->data.vorbis_comment.num_comments)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on empty array..."); - vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1"); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on beginning of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 0, "name2=field2"); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on middle of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 1, "name3=field3"); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 1, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on end of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 3, "name4=field4"); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 3, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on end of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 4, "name3=field3dup1"); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 4, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(copy) on end of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 5, "name3=field3dup1"); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 5, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()..."); - if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, "name3")) != 1) { - printf("FAILED, expected 1, got %d\n", j); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()..."); - if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, j+1, "name3")) != 4) { - printf("FAILED, expected 4, got %d\n", j); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()..."); - if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, j+1, "name3")) != 5) { - printf("FAILED, expected 5, got %d\n", j); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()..."); - if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, "name2")) != 0) { - printf("FAILED, expected 0, got %d\n", j); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()..."); - if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, j+1, "name2")) != -1) { - printf("FAILED, expected -1, got %d\n", j); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_find_entry_from()..."); - if((j = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, "blah")) != -1) { - printf("FAILED, expected -1, got %d\n", j); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(first, copy)..."); - vc_replace_new_(&entry, vorbiscomment, "name3=field3new1", /*all=*/false); - if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/false, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - if(block->data.vorbis_comment.num_comments != 6) { - printf("FAILED, expected 6 comments, got %u\n", block->data.vorbis_comment.num_comments); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(all, copy)..."); - vc_replace_new_(&entry, vorbiscomment, "name3=field3new2", /*all=*/true); - if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/true, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - if(block->data.vorbis_comment.num_comments != 4) { - printf("FAILED, expected 4 comments, got %u\n", block->data.vorbis_comment.num_comments); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on middle of array..."); - vc_delete_(vorbiscomment, 2); - if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on end of array..."); - vc_delete_(vorbiscomment, 2); - if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on beginning of array..."); - vc_delete_(vorbiscomment, 0); - if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 0)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 1, "rem0=val0"); - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 2, "rem0=val1"); - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_append_comment(copy) on non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 3, "rem0=val2"); - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_remove_entry_matching(\"blah\")..."); - if((j = FLAC__metadata_object_vorbiscomment_remove_entry_matching(block, "blah")) != 0) { - printf("FAILED, expected 0, got %d\n", j); - return false; - } - if(block->data.vorbis_comment.num_comments != 4) { - printf("FAILED, expected 4 comments, got %u\n", block->data.vorbis_comment.num_comments); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_remove_entry_matching(\"rem0\")..."); - vc_delete_(vorbiscomment, 1); - if((j = FLAC__metadata_object_vorbiscomment_remove_entry_matching(block, "rem0")) != 1) { - printf("FAILED, expected 1, got %d\n", j); - return false; - } - if(block->data.vorbis_comment.num_comments != 3) { - printf("FAILED, expected 3 comments, got %u\n", block->data.vorbis_comment.num_comments); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_remove_entries_matching(\"blah\")..."); - if((j = FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, "blah")) != 0) { - printf("FAILED, expected 0, got %d\n", j); - return false; - } - if(block->data.vorbis_comment.num_comments != 3) { - printf("FAILED, expected 3 comments, got %u\n", block->data.vorbis_comment.num_comments); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_remove_entries_matching(\"rem0\")..."); - vc_delete_(vorbiscomment, 1); - vc_delete_(vorbiscomment, 1); - if((j = FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, "rem0")) != 2) { - printf("FAILED, expected 2, got %d\n", j); - return false; - } - if(block->data.vorbis_comment.num_comments != 1) { - printf("FAILED, expected 1 comments, got %u\n", block->data.vorbis_comment.num_comments); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_set_comment(copy)..."); - vc_set_new_(&entry, vorbiscomment, 0, "name5=field5"); - FLAC__metadata_object_vorbiscomment_set_comment(block, 0, entry, /*copy=*/true); - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_set_vendor_string(copy)..."); - vc_set_vs_new_(&entry, vorbiscomment, "name6=field6"); - FLAC__metadata_object_vorbiscomment_set_vendor_string(block, entry, /*copy=*/true); - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(vorbiscomment); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - vorbiscomment = FLAC__metadata_object_clone(block); - if(0 == vorbiscomment) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_append_comment(own) on empty array..."); - vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1"); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_append_comment(own) on non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 1, "name2=field2"); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(vorbiscomment); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - vorbiscomment = FLAC__metadata_object_clone(block); - if(0 == vorbiscomment) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on empty array..."); - vc_insert_new_(&entry, vorbiscomment, 0, "name1=field1"); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on beginning of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 0, "name2=field2"); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 0, entry, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on middle of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 1, "name3=field3"); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 1, entry, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on end of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 3, "name4=field4"); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 3, entry, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on end of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 4, "name3=field3dup1"); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 4, entry, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_insert_comment(own) on end of non-empty array..."); - vc_insert_new_(&entry, vorbiscomment, 5, "name3=field3dup1"); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, 5, entry, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(first, own)..."); - vc_replace_new_(&entry, vorbiscomment, "name3=field3new1", /*all=*/false); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/false, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - if(block->data.vorbis_comment.num_comments != 6) { - printf("FAILED, expected 6 comments, got %u\n", block->data.vorbis_comment.num_comments); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_replace_comment(all, own)..."); - vc_replace_new_(&entry, vorbiscomment, "name3=field3new2", /*all=*/true); - entry_clone_(&entry); - if(!FLAC__metadata_object_vorbiscomment_replace_comment(block, entry, /*all=*/true, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - if(block->data.vorbis_comment.num_comments != 4) { - printf("FAILED, expected 4 comments, got %u\n", block->data.vorbis_comment.num_comments); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on middle of array..."); - vc_delete_(vorbiscomment, 2); - if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on end of array..."); - vc_delete_(vorbiscomment, 2); - if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_delete_comment() on beginning of array..."); - vc_delete_(vorbiscomment, 0); - if(!FLAC__metadata_object_vorbiscomment_delete_comment(block, 0)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_set_comment(own)..."); - vc_set_new_(&entry, vorbiscomment, 0, "name5=field5"); - entry_clone_(&entry); - FLAC__metadata_object_vorbiscomment_set_comment(block, 0, entry, /*copy=*/false); - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_vorbiscomment_set_vendor_string(own)..."); - vc_set_vs_new_(&entry, vorbiscomment, "name6=field6"); - entry_clone_(&entry); - FLAC__metadata_object_vorbiscomment_set_vendor_string(block, entry, /*copy=*/false); - if(!mutils__compare_block(vorbiscomment, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(vorbiscomment); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - - printf("testing CUESHEET\n"); - - { - FLAC__StreamMetadata_CueSheet_Track *track_, *trackcopy_; - - printf("testing FLAC__metadata_object_cuesheet_track_new()... "); - track_ = FLAC__metadata_object_cuesheet_track_new(); - if(0 == track_) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_track_clone()... "); - trackcopy_ = FLAC__metadata_object_cuesheet_track_clone(track_); - if(0 == trackcopy_) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!compare_track_(trackcopy_, track_)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_track_delete()... "); - FLAC__metadata_object_cuesheet_track_delete(trackcopy_); - FLAC__metadata_object_cuesheet_track_delete(track_); - printf("OK\n"); - } - - - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - expected_length = ( - FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN + - FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + - FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN - ) / 8; - if(block->length != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - cuesheet = FLAC__metadata_object_clone(block); - if(0 == cuesheet) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - cs_resize_(cuesheet, 2); - printf("testing FLAC__metadata_object_cuesheet_resize_tracks(grow to %u)...", cuesheet->data.cue_sheet.num_tracks); - if(!FLAC__metadata_object_cuesheet_resize_tracks(block, cuesheet->data.cue_sheet.num_tracks)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - cs_resize_(cuesheet, 1); - printf("testing FLAC__metadata_object_cuesheet_resize_tracks(shrink to %u)...", cuesheet->data.cue_sheet.num_tracks); - if(!FLAC__metadata_object_cuesheet_resize_tracks(block, cuesheet->data.cue_sheet.num_tracks)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - cs_resize_(cuesheet, 0); - printf("testing FLAC__metadata_object_cuesheet_resize_tracks(shrink to %u)...", cuesheet->data.cue_sheet.num_tracks); - if(!FLAC__metadata_object_cuesheet_resize_tracks(block, cuesheet->data.cue_sheet.num_tracks)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_insert_track(copy) on empty array..."); - cs_insert_new_(&track, cuesheet, 0, 0, 1, "ABCDE1234567", false, false); - if(!FLAC__metadata_object_cuesheet_insert_track(block, 0, &track, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_insert_track(copy) on beginning of non-empty array..."); - cs_insert_new_(&track, cuesheet, 0, 10, 2, "BBCDE1234567", false, false); - if(!FLAC__metadata_object_cuesheet_insert_track(block, 0, &track, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_insert_track(copy) on middle of non-empty array..."); - cs_insert_new_(&track, cuesheet, 1, 20, 3, "CBCDE1234567", false, false); - if(!FLAC__metadata_object_cuesheet_insert_track(block, 1, &track, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_insert_track(copy) on end of non-empty array..."); - cs_insert_new_(&track, cuesheet, 3, 30, 4, "DBCDE1234567", false, false); - if(!FLAC__metadata_object_cuesheet_insert_track(block, 3, &track, /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_insert_blank_track() on end of non-empty array..."); - cs_insert_new_(&track, cuesheet, 4, 0, 0, "\0\0\0\0\0\0\0\0\0\0\0\0", false, false); - if(!FLAC__metadata_object_cuesheet_insert_blank_track(block, 4)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_delete_track() on end of array..."); - cs_delete_(cuesheet, 4); - if(!FLAC__metadata_object_cuesheet_delete_track(block, 4)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_delete_track() on middle of array..."); - cs_delete_(cuesheet, 2); - if(!FLAC__metadata_object_cuesheet_delete_track(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_delete_track() on end of array..."); - cs_delete_(cuesheet, 2); - if(!FLAC__metadata_object_cuesheet_delete_track(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_delete_track() on beginning of array..."); - cs_delete_(cuesheet, 0); - if(!FLAC__metadata_object_cuesheet_delete_track(block, 0)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_set_track(copy)..."); - cs_set_new_(&track, cuesheet, 0, 40, 5, "EBCDE1234567", false, false); - FLAC__metadata_object_cuesheet_set_track(block, 0, &track, /*copy=*/true); - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - tr_resize_(cuesheet, 0, 2); - printf("testing FLAC__metadata_object_cuesheet_track_resize_indices(grow to %u)...", cuesheet->data.cue_sheet.tracks[0].num_indices); - if(!FLAC__metadata_object_cuesheet_track_resize_indices(block, 0, cuesheet->data.cue_sheet.tracks[0].num_indices)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - tr_resize_(cuesheet, 0, 1); - printf("testing FLAC__metadata_object_cuesheet_track_resize_indices(shrink to %u)...", cuesheet->data.cue_sheet.tracks[0].num_indices); - if(!FLAC__metadata_object_cuesheet_track_resize_indices(block, 0, cuesheet->data.cue_sheet.tracks[0].num_indices)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - tr_resize_(cuesheet, 0, 0); - printf("testing FLAC__metadata_object_cuesheet_track_resize_indices(shrink to %u)...", cuesheet->data.cue_sheet.tracks[0].num_indices); - if(!FLAC__metadata_object_cuesheet_track_resize_indices(block, 0, cuesheet->data.cue_sheet.tracks[0].num_indices)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - indx.offset = 0; - indx.number = 1; - printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on empty array..."); - tr_insert_new_(cuesheet, 0, 0, indx); - if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 0, indx)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - indx.offset = 10; - indx.number = 2; - printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on beginning of non-empty array..."); - tr_insert_new_(cuesheet, 0, 0, indx); - if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 0, indx)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - indx.offset = 20; - indx.number = 3; - printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on middle of non-empty array..."); - tr_insert_new_(cuesheet, 0, 1, indx); - if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 1, indx)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - indx.offset = 30; - indx.number = 4; - printf("testing FLAC__metadata_object_cuesheet_track_insert_index() on end of non-empty array..."); - tr_insert_new_(cuesheet, 0, 3, indx); - if(!FLAC__metadata_object_cuesheet_track_insert_index(block, 0, 3, indx)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - indx.offset = 0; - indx.number = 0; - printf("testing FLAC__metadata_object_cuesheet_track_insert_blank_index() on end of non-empty array..."); - tr_insert_new_(cuesheet, 0, 4, indx); - if(!FLAC__metadata_object_cuesheet_track_insert_blank_index(block, 0, 4)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_track_delete_index() on end of array..."); - tr_delete_(cuesheet, 0, 4); - if(!FLAC__metadata_object_cuesheet_track_delete_index(block, 0, 4)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_track_delete_index() on middle of array..."); - tr_delete_(cuesheet, 0, 2); - if(!FLAC__metadata_object_cuesheet_track_delete_index(block, 0, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_track_delete_index() on end of array..."); - tr_delete_(cuesheet, 0, 2); - if(!FLAC__metadata_object_cuesheet_track_delete_index(block, 0, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_track_delete_index() on beginning of array..."); - tr_delete_(cuesheet, 0, 0); - if(!FLAC__metadata_object_cuesheet_track_delete_index(block, 0, 0)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(cuesheet); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - cuesheet = FLAC__metadata_object_clone(block); - if(0 == cuesheet) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_insert_track(own) on empty array..."); - cs_insert_new_(&track, cuesheet, 0, 60, 7, "GBCDE1234567", false, false); - track_clone_(&track); - if(!FLAC__metadata_object_cuesheet_insert_track(block, 0, &track, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_insert_track(own) on beginning of non-empty array..."); - cs_insert_new_(&track, cuesheet, 0, 70, 8, "HBCDE1234567", false, false); - track_clone_(&track); - if(!FLAC__metadata_object_cuesheet_insert_track(block, 0, &track, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_insert_track(own) on middle of non-empty array..."); - cs_insert_new_(&track, cuesheet, 1, 80, 9, "IBCDE1234567", false, false); - track_clone_(&track); - if(!FLAC__metadata_object_cuesheet_insert_track(block, 1, &track, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_insert_track(own) on end of non-empty array..."); - cs_insert_new_(&track, cuesheet, 3, 90, 10, "JBCDE1234567", false, false); - track_clone_(&track); - if(!FLAC__metadata_object_cuesheet_insert_track(block, 3, &track, /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_delete_track() on middle of array..."); - cs_delete_(cuesheet, 2); - if(!FLAC__metadata_object_cuesheet_delete_track(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_delete_track() on end of array..."); - cs_delete_(cuesheet, 2); - if(!FLAC__metadata_object_cuesheet_delete_track(block, 2)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_delete_track() on beginning of array..."); - cs_delete_(cuesheet, 0); - if(!FLAC__metadata_object_cuesheet_delete_track(block, 0)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_set_track(own)..."); - cs_set_new_(&track, cuesheet, 0, 100, 11, "KBCDE1234567", false, false); - track_clone_(&track); - FLAC__metadata_object_cuesheet_set_track(block, 0, &track, /*copy=*/false); - if(!mutils__compare_block(cuesheet, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_cuesheet_is_legal()..."); - { - const char *violation; - if(FLAC__metadata_object_cuesheet_is_legal(block, /*check_cd_da_subset=*/true, &violation)) { - printf("FAILED, returned true when expecting false\n"); - return false; - } - printf("returned false as expected, violation=\"%s\" OK\n", violation); - } - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(cuesheet); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - - printf("testing PICTURE\n"); - - printf("testing FLAC__metadata_object_new()... "); - block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE); - if(0 == block) { - printf("FAILED, returned NULL\n"); - return false; - } - expected_length = ( - FLAC__STREAM_METADATA_PICTURE_TYPE_LEN + - FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN + - FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN + - FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN + - FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN + - FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN + - FLAC__STREAM_METADATA_PICTURE_COLORS_LEN + - FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN - ) / 8; - if(block->length != expected_length) { - printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); - return false; - } - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - picture = FLAC__metadata_object_clone(block); - if(0 == picture) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - pi_set_mime_type(picture, "image/png\t"); - printf("testing FLAC__metadata_object_picture_set_mime_type(copy)..."); - if(!FLAC__metadata_object_picture_set_mime_type(block, "image/png\t", /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_picture_is_legal()..."); - { - const char *violation; - if(FLAC__metadata_object_picture_is_legal(block, &violation)) { - printf("FAILED, returned true when expecting false\n"); - return false; - } - printf("returned false as expected, violation=\"%s\" OK\n", violation); - } - - pi_set_mime_type(picture, "image/png"); - printf("testing FLAC__metadata_object_picture_set_mime_type(copy)..."); - if(!FLAC__metadata_object_picture_set_mime_type(block, "image/png", /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_picture_is_legal()..."); - { - const char *violation; - if(!FLAC__metadata_object_picture_is_legal(block, &violation)) { - printf("FAILED, returned false, violation=\"%s\"\n", violation); - return false; - } - printf("OK\n"); - } - - pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION\xff"); - printf("testing FLAC__metadata_object_picture_set_description(copy)..."); - if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)"DESCRIPTION\xff", /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_picture_is_legal()..."); - { - const char *violation; - if(FLAC__metadata_object_picture_is_legal(block, &violation)) { - printf("FAILED, returned true when expecting false\n"); - return false; - } - printf("returned false as expected, violation=\"%s\" OK\n", violation); - } - - pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION"); - printf("testing FLAC__metadata_object_picture_set_description(copy)..."); - if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)"DESCRIPTION", /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_picture_is_legal()..."); - { - const char *violation; - if(!FLAC__metadata_object_picture_is_legal(block, &violation)) { - printf("FAILED, returned false, violation=\"%s\"\n", violation); - return false; - } - printf("OK\n"); - } - - - pi_set_data(picture, (const FLAC__byte*)"PNGDATA", strlen("PNGDATA")); - printf("testing FLAC__metadata_object_picture_set_data(copy)..."); - if(!FLAC__metadata_object_picture_set_data(block, (FLAC__byte*)"PNGDATA", strlen("PNGDATA"), /*copy=*/true)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - printf("OK\n"); - - pi_set_mime_type(picture, "image/png\t"); - printf("testing FLAC__metadata_object_picture_set_mime_type(own)..."); - if(!FLAC__metadata_object_picture_set_mime_type(block, strdup("image/png\t"), /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_picture_is_legal()..."); - { - const char *violation; - if(FLAC__metadata_object_picture_is_legal(block, &violation)) { - printf("FAILED, returned true when expecting false\n"); - return false; - } - printf("returned false as expected, violation=\"%s\" OK\n", violation); - } - - pi_set_mime_type(picture, "image/png"); - printf("testing FLAC__metadata_object_picture_set_mime_type(own)..."); - if(!FLAC__metadata_object_picture_set_mime_type(block, strdup("image/png"), /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_picture_is_legal()..."); - { - const char *violation; - if(!FLAC__metadata_object_picture_is_legal(block, &violation)) { - printf("FAILED, returned false, violation=\"%s\"\n", violation); - return false; - } - printf("OK\n"); - } - - pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION\xff"); - printf("testing FLAC__metadata_object_picture_set_description(own)..."); - if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)strdup("DESCRIPTION\xff"), /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_picture_is_legal()..."); - { - const char *violation; - if(FLAC__metadata_object_picture_is_legal(block, &violation)) { - printf("FAILED, returned true when expecting false\n"); - return false; - } - printf("returned false as expected, violation=\"%s\" OK\n", violation); - } - - pi_set_description(picture, (const FLAC__byte *)"DESCRIPTION"); - printf("testing FLAC__metadata_object_picture_set_description(own)..."); - if(!FLAC__metadata_object_picture_set_description(block, (FLAC__byte *)strdup("DESCRIPTION"), /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_picture_is_legal()..."); - { - const char *violation; - if(!FLAC__metadata_object_picture_is_legal(block, &violation)) { - printf("FAILED, returned false, violation=\"%s\"\n", violation); - return false; - } - printf("OK\n"); - } - - pi_set_data(picture, (const FLAC__byte*)"PNGDATA", strlen("PNGDATA")); - printf("testing FLAC__metadata_object_picture_set_data(own)..."); - if(!FLAC__metadata_object_picture_set_data(block, (FLAC__byte*)strdup("PNGDATA"), strlen("PNGDATA"), /*copy=*/false)) { - printf("FAILED, returned false\n"); - return false; - } - if(!mutils__compare_block(picture, block)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_clone()... "); - blockcopy = FLAC__metadata_object_clone(block); - if(0 == blockcopy) { - printf("FAILED, returned NULL\n"); - return false; - } - if(!mutils__compare_block(block, blockcopy)) - return false; - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(blockcopy); - printf("OK\n"); - - printf("testing FLAC__metadata_object_delete()... "); - FLAC__metadata_object_delete(picture); - FLAC__metadata_object_delete(block); - printf("OK\n"); - - - return true; -} diff --git a/Engine/lib/flac/src/test_libs_common/CMakeLists.txt b/Engine/lib/flac/src/test_libs_common/CMakeLists.txt deleted file mode 100644 index 8a0c87125..000000000 --- a/Engine/lib/flac/src/test_libs_common/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_library(test_libs_common STATIC - file_utils_flac.c - metadata_utils.c) -target_link_libraries(test_libs_common PUBLIC FLAC) diff --git a/Engine/lib/flac/src/test_libs_common/Makefile.am b/Engine/lib/flac/src/test_libs_common/Makefile.am deleted file mode 100644 index 30e1f157d..000000000 --- a/Engine/lib/flac/src/test_libs_common/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# test_libs_common - Common code to library unit tests -# Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include - -noinst_LTLIBRARIES = libtest_libs_common.la - -libtest_libs_common_la_SOURCES = \ - file_utils_flac.c \ - metadata_utils.c - -EXTRA_DIST = \ - CMakeLists.txt \ - README diff --git a/Engine/lib/flac/src/test_libs_common/README b/Engine/lib/flac/src/test_libs_common/README deleted file mode 100644 index 6a704c204..000000000 --- a/Engine/lib/flac/src/test_libs_common/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains a convenience library of routines that are -common to the library unit testers. diff --git a/Engine/lib/flac/src/test_libs_common/file_utils_flac.c b/Engine/lib/flac/src/test_libs_common/file_utils_flac.c deleted file mode 100644 index 3cc8c308a..000000000 --- a/Engine/lib/flac/src/test_libs_common/file_utils_flac.c +++ /dev/null @@ -1,155 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/assert.h" -#include "FLAC/stream_encoder.h" -#include "test_libs_common/file_utils_flac.h" -#include -#include -#include /* for stat() */ -#include "share/compat.h" - -#ifdef min -#undef min -#endif -#define min(a,b) ((a)<(b)?(a):(b)) - -const long file_utils__ogg_serial_number = 12345; - -#ifdef FLAC__VALGRIND_TESTING -static size_t local__fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - size_t ret = fwrite(ptr, size, nmemb, stream); - if(!ferror(stream)) - fflush(stream); - return ret; -} -#else -#define local__fwrite fwrite -#endif - -typedef struct { - FILE *file; -} encoder_client_struct; - -static FLAC__StreamEncoderWriteStatus encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) -{ - encoder_client_struct *ecd = (encoder_client_struct*)client_data; - - (void)encoder, (void)samples, (void)current_frame; - - if(local__fwrite(buffer, 1, bytes, ecd->file) != bytes) - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - else - return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; -} - -static void encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - (void)encoder, (void)metadata, (void)client_data; -} - -FLAC__bool file_utils__generate_flacfile(FLAC__bool is_ogg, const char *output_filename, FLAC__off_t *output_filesize, uint32_t length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, uint32_t num_metadata) -{ - FLAC__int32 samples[1024]; - FLAC__StreamEncoder *encoder; - FLAC__StreamEncoderInitStatus init_status; - encoder_client_struct encoder_client_data; - uint32_t i, n; - - FLAC__ASSERT(0 != output_filename); - FLAC__ASSERT(0 != streaminfo); - FLAC__ASSERT(streaminfo->type == FLAC__METADATA_TYPE_STREAMINFO); - FLAC__ASSERT((streaminfo->is_last && num_metadata == 0) || (!streaminfo->is_last && num_metadata > 0)); - - if(0 == (encoder_client_data.file = flac_fopen(output_filename, "wb"))) - return false; - - encoder = FLAC__stream_encoder_new(); - if(0 == encoder) { - fclose(encoder_client_data.file); - return false; - } - - FLAC__stream_encoder_set_ogg_serial_number(encoder, file_utils__ogg_serial_number); - FLAC__stream_encoder_set_verify(encoder, true); - FLAC__stream_encoder_set_streamable_subset(encoder, true); - FLAC__stream_encoder_set_do_mid_side_stereo(encoder, false); - FLAC__stream_encoder_set_loose_mid_side_stereo(encoder, false); - FLAC__stream_encoder_set_channels(encoder, streaminfo->data.stream_info.channels); - FLAC__stream_encoder_set_bits_per_sample(encoder, streaminfo->data.stream_info.bits_per_sample); - FLAC__stream_encoder_set_sample_rate(encoder, streaminfo->data.stream_info.sample_rate); - FLAC__stream_encoder_set_blocksize(encoder, streaminfo->data.stream_info.min_blocksize); - FLAC__stream_encoder_set_max_lpc_order(encoder, 0); - FLAC__stream_encoder_set_qlp_coeff_precision(encoder, 0); - FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, false); - FLAC__stream_encoder_set_do_escape_coding(encoder, false); - FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, false); - FLAC__stream_encoder_set_min_residual_partition_order(encoder, 0); - FLAC__stream_encoder_set_max_residual_partition_order(encoder, 0); - FLAC__stream_encoder_set_rice_parameter_search_dist(encoder, 0); - FLAC__stream_encoder_set_total_samples_estimate(encoder, streaminfo->data.stream_info.total_samples); - FLAC__stream_encoder_set_metadata(encoder, metadata, num_metadata); - - if(is_ogg) - init_status = FLAC__stream_encoder_init_ogg_stream(encoder, /*read_callback=*/0, encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, encoder_metadata_callback_, &encoder_client_data); - else - init_status = FLAC__stream_encoder_init_stream(encoder, encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, encoder_metadata_callback_, &encoder_client_data); - - if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { - fclose(encoder_client_data.file); - return false; - } - - /* init the dummy sample buffer */ - for(i = 0; i < sizeof(samples) / sizeof(FLAC__int32); i++) - samples[i] = i & 7; - - while(length > 0) { - n = min(length, sizeof(samples) / sizeof(FLAC__int32)); - - if(!FLAC__stream_encoder_process_interleaved(encoder, samples, n)) { - fclose(encoder_client_data.file); - return false; - } - - length -= n; - } - - (void)FLAC__stream_encoder_finish(encoder); - - fclose(encoder_client_data.file); - - FLAC__stream_encoder_delete(encoder); - - if(0 != output_filesize) { - struct flac_stat_s filestats; - - if(flac_stat(output_filename, &filestats) != 0) - return false; - else - *output_filesize = filestats.st_size; - } - - return true; -} diff --git a/Engine/lib/flac/src/test_libs_common/metadata_utils.c b/Engine/lib/flac/src/test_libs_common/metadata_utils.c deleted file mode 100644 index 929ca6391..000000000 --- a/Engine/lib/flac/src/test_libs_common/metadata_utils.c +++ /dev/null @@ -1,636 +0,0 @@ -/* test_libFLAC - Unit tester for libFLAC - * Copyright (C) 2002-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * These are not tests, just utility functions used by the metadata tests - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "FLAC/metadata.h" -#include "test_libs_common/metadata_utils.h" -#include "share/compat.h" -#include -#include /* for malloc() */ -#include /* for memcmp() */ - -FLAC__bool mutils__compare_block_data_streaminfo(const FLAC__StreamMetadata_StreamInfo *block, const FLAC__StreamMetadata_StreamInfo *blockcopy) -{ - if(blockcopy->min_blocksize != block->min_blocksize) { - printf("FAILED, min_blocksize mismatch, expected %u, got %u\n", block->min_blocksize, blockcopy->min_blocksize); - return false; - } - if(blockcopy->max_blocksize != block->max_blocksize) { - printf("FAILED, max_blocksize mismatch, expected %u, got %u\n", block->max_blocksize, blockcopy->max_blocksize); - return false; - } - if(blockcopy->min_framesize != block->min_framesize) { - printf("FAILED, min_framesize mismatch, expected %u, got %u\n", block->min_framesize, blockcopy->min_framesize); - return false; - } - if(blockcopy->max_framesize != block->max_framesize) { - printf("FAILED, max_framesize mismatch, expected %u, got %u\n", block->max_framesize, blockcopy->max_framesize); - return false; - } - if(blockcopy->sample_rate != block->sample_rate) { - printf("FAILED, sample_rate mismatch, expected %u, got %u\n", block->sample_rate, blockcopy->sample_rate); - return false; - } - if(blockcopy->channels != block->channels) { - printf("FAILED, channels mismatch, expected %u, got %u\n", block->channels, blockcopy->channels); - return false; - } - if(blockcopy->bits_per_sample != block->bits_per_sample) { - printf("FAILED, bits_per_sample mismatch, expected %u, got %u\n", block->bits_per_sample, blockcopy->bits_per_sample); - return false; - } - if(blockcopy->total_samples != block->total_samples) { - printf("FAILED, total_samples mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", block->total_samples, blockcopy->total_samples); - return false; - } - if(0 != memcmp(blockcopy->md5sum, block->md5sum, sizeof(block->md5sum))) { - printf("FAILED, md5sum mismatch, expected %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X, got %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n", - (uint32_t)block->md5sum[0], - (uint32_t)block->md5sum[1], - (uint32_t)block->md5sum[2], - (uint32_t)block->md5sum[3], - (uint32_t)block->md5sum[4], - (uint32_t)block->md5sum[5], - (uint32_t)block->md5sum[6], - (uint32_t)block->md5sum[7], - (uint32_t)block->md5sum[8], - (uint32_t)block->md5sum[9], - (uint32_t)block->md5sum[10], - (uint32_t)block->md5sum[11], - (uint32_t)block->md5sum[12], - (uint32_t)block->md5sum[13], - (uint32_t)block->md5sum[14], - (uint32_t)block->md5sum[15], - (uint32_t)blockcopy->md5sum[0], - (uint32_t)blockcopy->md5sum[1], - (uint32_t)blockcopy->md5sum[2], - (uint32_t)blockcopy->md5sum[3], - (uint32_t)blockcopy->md5sum[4], - (uint32_t)blockcopy->md5sum[5], - (uint32_t)blockcopy->md5sum[6], - (uint32_t)blockcopy->md5sum[7], - (uint32_t)blockcopy->md5sum[8], - (uint32_t)blockcopy->md5sum[9], - (uint32_t)blockcopy->md5sum[10], - (uint32_t)blockcopy->md5sum[11], - (uint32_t)blockcopy->md5sum[12], - (uint32_t)blockcopy->md5sum[13], - (uint32_t)blockcopy->md5sum[14], - (uint32_t)blockcopy->md5sum[15] - ); - return false; - } - return true; -} - -FLAC__bool mutils__compare_block_data_padding(const FLAC__StreamMetadata_Padding *block, const FLAC__StreamMetadata_Padding *blockcopy, uint32_t block_length) -{ - /* we don't compare the padding guts */ - (void)block, (void)blockcopy, (void)block_length; - return true; -} - -FLAC__bool mutils__compare_block_data_application(const FLAC__StreamMetadata_Application *block, const FLAC__StreamMetadata_Application *blockcopy, uint32_t block_length) -{ - if(block_length < sizeof(block->id)) { - printf("FAILED, bad block length = %u\n", block_length); - return false; - } - if(0 != memcmp(blockcopy->id, block->id, sizeof(block->id))) { - printf("FAILED, id mismatch, expected %02X%02X%02X%02X, got %02X%02X%02X%02X\n", - (uint32_t)block->id[0], - (uint32_t)block->id[1], - (uint32_t)block->id[2], - (uint32_t)block->id[3], - (uint32_t)blockcopy->id[0], - (uint32_t)blockcopy->id[1], - (uint32_t)blockcopy->id[2], - (uint32_t)blockcopy->id[3] - ); - return false; - } - if(0 == block->data || 0 == blockcopy->data) { - if(block->data != blockcopy->data) { - printf("FAILED, data mismatch (%s's data pointer is null)\n", 0==block->data?"original":"copy"); - return false; - } - else if(block_length - sizeof(block->id) > 0) { - printf("FAILED, data pointer is null but block length is not 0\n"); - return false; - } - } - else { - if(block_length - sizeof(block->id) == 0) { - printf("FAILED, data pointer is not null but block length is 0\n"); - return false; - } - else if(0 != memcmp(blockcopy->data, block->data, block_length - sizeof(block->id))) { - printf("FAILED, data mismatch\n"); - return false; - } - } - return true; -} - -FLAC__bool mutils__compare_block_data_seektable(const FLAC__StreamMetadata_SeekTable *block, const FLAC__StreamMetadata_SeekTable *blockcopy) -{ - uint32_t i; - if(blockcopy->num_points != block->num_points) { - printf("FAILED, num_points mismatch, expected %u, got %u\n", block->num_points, blockcopy->num_points); - return false; - } - for(i = 0; i < block->num_points; i++) { - if(blockcopy->points[i].sample_number != block->points[i].sample_number) { - printf("FAILED, points[%u].sample_number mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, block->points[i].sample_number, blockcopy->points[i].sample_number); - return false; - } - if(blockcopy->points[i].stream_offset != block->points[i].stream_offset) { - printf("FAILED, points[%u].stream_offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, block->points[i].stream_offset, blockcopy->points[i].stream_offset); - return false; - } - if(blockcopy->points[i].frame_samples != block->points[i].frame_samples) { - printf("FAILED, points[%u].frame_samples mismatch, expected %u, got %u\n", i, block->points[i].frame_samples, blockcopy->points[i].frame_samples); - return false; - } - } - return true; -} - -FLAC__bool mutils__compare_block_data_vorbiscomment(const FLAC__StreamMetadata_VorbisComment *block, const FLAC__StreamMetadata_VorbisComment *blockcopy) -{ - uint32_t i; - if(blockcopy->vendor_string.length != block->vendor_string.length) { - printf("FAILED, vendor_string.length mismatch, expected %u, got %u\n", block->vendor_string.length, blockcopy->vendor_string.length); - return false; - } - if(0 == block->vendor_string.entry || 0 == blockcopy->vendor_string.entry) { - if(block->vendor_string.entry != blockcopy->vendor_string.entry) { - printf("FAILED, vendor_string.entry mismatch\n"); - return false; - } - } - else if(0 != memcmp(blockcopy->vendor_string.entry, block->vendor_string.entry, block->vendor_string.length)) { - printf("FAILED, vendor_string.entry mismatch\n"); - return false; - } - if(blockcopy->num_comments != block->num_comments) { - printf("FAILED, num_comments mismatch, expected %u, got %u\n", block->num_comments, blockcopy->num_comments); - return false; - } - for(i = 0; i < block->num_comments; i++) { - if(blockcopy->comments[i].length != block->comments[i].length) { - printf("FAILED, comments[%u].length mismatch, expected %u, got %u\n", i, block->comments[i].length, blockcopy->comments[i].length); - return false; - } - if(0 == block->comments[i].entry || 0 == blockcopy->comments[i].entry) { - if(block->comments[i].entry != blockcopy->comments[i].entry) { - printf("FAILED, comments[%u].entry mismatch\n", i); - return false; - } - } - else { - if(0 != memcmp(blockcopy->comments[i].entry, block->comments[i].entry, block->comments[i].length)) { - printf("FAILED, comments[%u].entry mismatch\n", i); - return false; - } - } - } - return true; -} - -FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueSheet *block, const FLAC__StreamMetadata_CueSheet *blockcopy) -{ - uint32_t i, j; - - if(0 != strcmp(blockcopy->media_catalog_number, block->media_catalog_number)) { - printf("FAILED, media_catalog_number mismatch, expected %s, got %s\n", block->media_catalog_number, blockcopy->media_catalog_number); - return false; - } - if(blockcopy->lead_in != block->lead_in) { - printf("FAILED, lead_in mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", block->lead_in, blockcopy->lead_in); - return false; - } - if(blockcopy->is_cd != block->is_cd) { - printf("FAILED, is_cd mismatch, expected %u, got %u\n", (uint32_t)block->is_cd, (uint32_t)blockcopy->is_cd); - return false; - } - if(blockcopy->num_tracks != block->num_tracks) { - printf("FAILED, num_tracks mismatch, expected %u, got %u\n", block->num_tracks, blockcopy->num_tracks); - return false; - } - for(i = 0; i < block->num_tracks; i++) { - if(blockcopy->tracks[i].offset != block->tracks[i].offset) { - printf("FAILED, tracks[%u].offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, block->tracks[i].offset, blockcopy->tracks[i].offset); - return false; - } - if(blockcopy->tracks[i].number != block->tracks[i].number) { - printf("FAILED, tracks[%u].number mismatch, expected %u, got %u\n", i, (uint32_t)block->tracks[i].number, (uint32_t)blockcopy->tracks[i].number); - return false; - } - if(blockcopy->tracks[i].num_indices != block->tracks[i].num_indices) { - printf("FAILED, tracks[%u].num_indices mismatch, expected %u, got %u\n", i, (uint32_t)block->tracks[i].num_indices, (uint32_t)blockcopy->tracks[i].num_indices); - return false; - } - /* num_indices == 0 means lead-out track so only the track offset and number are valid */ - if(block->tracks[i].num_indices > 0) { - if(0 != strcmp(blockcopy->tracks[i].isrc, block->tracks[i].isrc)) { - printf("FAILED, tracks[%u].isrc mismatch, expected %s, got %s\n", i, block->tracks[i].isrc, blockcopy->tracks[i].isrc); - return false; - } - if(blockcopy->tracks[i].type != block->tracks[i].type) { - printf("FAILED, tracks[%u].type mismatch, expected %u, got %u\n", i, (uint32_t)block->tracks[i].type, (uint32_t)blockcopy->tracks[i].type); - return false; - } - if(blockcopy->tracks[i].pre_emphasis != block->tracks[i].pre_emphasis) { - printf("FAILED, tracks[%u].pre_emphasis mismatch, expected %u, got %u\n", i, (uint32_t)block->tracks[i].pre_emphasis, (uint32_t)blockcopy->tracks[i].pre_emphasis); - return false; - } - if(0 == block->tracks[i].indices || 0 == blockcopy->tracks[i].indices) { - if(block->tracks[i].indices != blockcopy->tracks[i].indices) { - printf("FAILED, tracks[%u].indices mismatch\n", i); - return false; - } - } - else { - for(j = 0; j < block->tracks[i].num_indices; j++) { - if(blockcopy->tracks[i].indices[j].offset != block->tracks[i].indices[j].offset) { - printf("FAILED, tracks[%u].indices[%u].offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, j, block->tracks[i].indices[j].offset, blockcopy->tracks[i].indices[j].offset); - return false; - } - if(blockcopy->tracks[i].indices[j].number != block->tracks[i].indices[j].number) { - printf("FAILED, tracks[%u].indices[%u].number mismatch, expected %u, got %u\n", i, j, (uint32_t)block->tracks[i].indices[j].number, (uint32_t)blockcopy->tracks[i].indices[j].number); - return false; - } - } - } - } - } - return true; -} - -FLAC__bool mutils__compare_block_data_picture(const FLAC__StreamMetadata_Picture *block, const FLAC__StreamMetadata_Picture *blockcopy) -{ - size_t len, lencopy; - if(blockcopy->type != block->type) { - printf("FAILED, type mismatch, expected %u, got %u\n", (uint32_t)block->type, (uint32_t)blockcopy->type); - return false; - } - len = strlen(block->mime_type); - lencopy = strlen(blockcopy->mime_type); - if(lencopy != len) { - printf("FAILED, mime_type length mismatch, expected %u, got %u\n", (uint32_t)len, (uint32_t)lencopy); - return false; - } - if(strcmp(blockcopy->mime_type, block->mime_type)) { - printf("FAILED, mime_type mismatch, expected %s, got %s\n", block->mime_type, blockcopy->mime_type); - return false; - } - len = strlen((const char *)block->description); - lencopy = strlen((const char *)blockcopy->description); - if(lencopy != len) { - printf("FAILED, description length mismatch, expected %u, got %u\n", (uint32_t)len, (uint32_t)lencopy); - return false; - } - if(strcmp((const char *)blockcopy->description, (const char *)block->description)) { - printf("FAILED, description mismatch, expected %s, got %s\n", block->description, blockcopy->description); - return false; - } - if(blockcopy->width != block->width) { - printf("FAILED, width mismatch, expected %u, got %u\n", block->width, blockcopy->width); - return false; - } - if(blockcopy->height != block->height) { - printf("FAILED, height mismatch, expected %u, got %u\n", block->height, blockcopy->height); - return false; - } - if(blockcopy->depth != block->depth) { - printf("FAILED, depth mismatch, expected %u, got %u\n", block->depth, blockcopy->depth); - return false; - } - if(blockcopy->colors != block->colors) { - printf("FAILED, colors mismatch, expected %u, got %u\n", block->colors, blockcopy->colors); - return false; - } - if(blockcopy->data_length != block->data_length) { - printf("FAILED, data_length mismatch, expected %u, got %u\n", block->data_length, blockcopy->data_length); - return false; - } - if(block->data_length > 0 && memcmp(blockcopy->data, block->data, block->data_length)) { - printf("FAILED, data mismatch\n"); - return false; - } - return true; -} - -FLAC__bool mutils__compare_block_data_unknown(const FLAC__StreamMetadata_Unknown *block, const FLAC__StreamMetadata_Unknown *blockcopy, uint32_t block_length) -{ - if(0 == block->data || 0 == blockcopy->data) { - if(block->data != blockcopy->data) { - printf("FAILED, data mismatch (%s's data pointer is null)\n", 0==block->data?"original":"copy"); - return false; - } - else if(block_length > 0) { - printf("FAILED, data pointer is null but block length is not 0\n"); - return false; - } - } - else { - if(block_length == 0) { - printf("FAILED, data pointer is not null but block length is 0\n"); - return false; - } - else if(0 != memcmp(blockcopy->data, block->data, block_length)) { - printf("FAILED, data mismatch\n"); - return false; - } - } - return true; -} - -FLAC__bool mutils__compare_block(const FLAC__StreamMetadata *block, const FLAC__StreamMetadata *blockcopy) -{ - if(blockcopy->type != block->type) { - printf("FAILED, type mismatch, expected %s, got %s\n", FLAC__MetadataTypeString[block->type], FLAC__MetadataTypeString[blockcopy->type]); - return false; - } - if(blockcopy->is_last != block->is_last) { - printf("FAILED, is_last mismatch, expected %u, got %u\n", (uint32_t)block->is_last, (uint32_t)blockcopy->is_last); - return false; - } - if(blockcopy->length != block->length) { - printf("FAILED, length mismatch, expected %u, got %u\n", block->length, blockcopy->length); - return false; - } - switch(block->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - return mutils__compare_block_data_streaminfo(&block->data.stream_info, &blockcopy->data.stream_info); - case FLAC__METADATA_TYPE_PADDING: - return mutils__compare_block_data_padding(&block->data.padding, &blockcopy->data.padding, block->length); - case FLAC__METADATA_TYPE_APPLICATION: - return mutils__compare_block_data_application(&block->data.application, &blockcopy->data.application, block->length); - case FLAC__METADATA_TYPE_SEEKTABLE: - return mutils__compare_block_data_seektable(&block->data.seek_table, &blockcopy->data.seek_table); - case FLAC__METADATA_TYPE_VORBIS_COMMENT: - return mutils__compare_block_data_vorbiscomment(&block->data.vorbis_comment, &blockcopy->data.vorbis_comment); - case FLAC__METADATA_TYPE_CUESHEET: - return mutils__compare_block_data_cuesheet(&block->data.cue_sheet, &blockcopy->data.cue_sheet); - case FLAC__METADATA_TYPE_PICTURE: - return mutils__compare_block_data_picture(&block->data.picture, &blockcopy->data.picture); - default: - return mutils__compare_block_data_unknown(&block->data.unknown, &blockcopy->data.unknown, block->length); - } -} - -static void *malloc_or_die_(size_t size) -{ - void *x = malloc(size); - if(0 == x) { - fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (uint32_t)size); - exit(1); - } - return x; -} - -static void *calloc_or_die_(size_t n, size_t size) -{ - void *x = calloc(n, size); - if(0 == x) { - fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (uint32_t)n * (uint32_t)size); - exit(1); - } - return x; -} - -static char *strdup_or_die_(const char *s) -{ - char *x = strdup(s); - if(0 == x) { - fprintf(stderr, "ERROR: out of memory copying string \"%s\"\n", s); - exit(1); - } - return x; -} - -void mutils__init_metadata_blocks( - FLAC__StreamMetadata *streaminfo, - FLAC__StreamMetadata *padding, - FLAC__StreamMetadata *seektable, - FLAC__StreamMetadata *application1, - FLAC__StreamMetadata *application2, - FLAC__StreamMetadata *vorbiscomment, - FLAC__StreamMetadata *cuesheet, - FLAC__StreamMetadata *picture, - FLAC__StreamMetadata *unknown -) -{ - /* - most of the actual numbers and data in the blocks don't matter, - we just want to make sure the decoder parses them correctly - - remember, the metadata interface gets tested after the decoders, - so we do all the metadata manipulation here without it. - */ - - /* min/max_framesize and md5sum don't get written at first, so we have to leave them 0 */ - streaminfo->is_last = false; - streaminfo->type = FLAC__METADATA_TYPE_STREAMINFO; - streaminfo->length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH; - streaminfo->data.stream_info.min_blocksize = 576; - streaminfo->data.stream_info.max_blocksize = 576; - streaminfo->data.stream_info.min_framesize = 0; - streaminfo->data.stream_info.max_framesize = 0; - streaminfo->data.stream_info.sample_rate = 44100; - streaminfo->data.stream_info.channels = 1; - streaminfo->data.stream_info.bits_per_sample = 8; - streaminfo->data.stream_info.total_samples = 0; - memset(streaminfo->data.stream_info.md5sum, 0, 16); - - padding->is_last = false; - padding->type = FLAC__METADATA_TYPE_PADDING; - padding->length = 1234; - - seektable->is_last = false; - seektable->type = FLAC__METADATA_TYPE_SEEKTABLE; - seektable->data.seek_table.num_points = 2; - seektable->length = seektable->data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; - seektable->data.seek_table.points = malloc_or_die_(seektable->data.seek_table.num_points * sizeof(FLAC__StreamMetadata_SeekPoint)); - seektable->data.seek_table.points[0].sample_number = 0; - seektable->data.seek_table.points[0].stream_offset = 0; - seektable->data.seek_table.points[0].frame_samples = streaminfo->data.stream_info.min_blocksize; - seektable->data.seek_table.points[1].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; - seektable->data.seek_table.points[1].stream_offset = 1000; - seektable->data.seek_table.points[1].frame_samples = streaminfo->data.stream_info.min_blocksize; - - application1->is_last = false; - application1->type = FLAC__METADATA_TYPE_APPLICATION; - application1->length = 8; - memcpy(application1->data.application.id, "This", 4); - application1->data.application.data = malloc_or_die_(4); - memcpy(application1->data.application.data, "\xf0\xe1\xd2\xc3", 4); - - application2->is_last = false; - application2->type = FLAC__METADATA_TYPE_APPLICATION; - application2->length = 4; - memcpy(application2->data.application.id, "Here", 4); - application2->data.application.data = 0; - - { - const uint32_t vendor_string_length = (uint32_t)strlen(FLAC__VENDOR_STRING); - vorbiscomment->is_last = false; - vorbiscomment->type = FLAC__METADATA_TYPE_VORBIS_COMMENT; - vorbiscomment->length = (4 + vendor_string_length) + 4 + (4 + 5) + (4 + 0); - vorbiscomment->data.vorbis_comment.vendor_string.length = vendor_string_length; - vorbiscomment->data.vorbis_comment.vendor_string.entry = malloc_or_die_(vendor_string_length+1); - memcpy(vorbiscomment->data.vorbis_comment.vendor_string.entry, FLAC__VENDOR_STRING, vendor_string_length+1); - vorbiscomment->data.vorbis_comment.num_comments = 2; - vorbiscomment->data.vorbis_comment.comments = malloc_or_die_(vorbiscomment->data.vorbis_comment.num_comments * sizeof(FLAC__StreamMetadata_VorbisComment_Entry)); - vorbiscomment->data.vorbis_comment.comments[0].length = 5; - vorbiscomment->data.vorbis_comment.comments[0].entry = malloc_or_die_(5+1); - memcpy(vorbiscomment->data.vorbis_comment.comments[0].entry, "ab=cd", 5+1); - vorbiscomment->data.vorbis_comment.comments[1].length = 0; - vorbiscomment->data.vorbis_comment.comments[1].entry = malloc_or_die_(1); - vorbiscomment->data.vorbis_comment.comments[1].entry[0] = '\0'; - } - - cuesheet->is_last = false; - cuesheet->type = FLAC__METADATA_TYPE_CUESHEET; - cuesheet->length = - /* cuesheet guts */ - ( - FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN + - FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + - FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN - ) / 8 + - /* 2 tracks */ - 3 * ( - FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN + - FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN - ) / 8 + - /* 3 index points */ - 3 * ( - FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN + - FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN + - FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN - ) / 8 - ; - memset(cuesheet->data.cue_sheet.media_catalog_number, 0, sizeof(cuesheet->data.cue_sheet.media_catalog_number)); - cuesheet->data.cue_sheet.media_catalog_number[0] = 'j'; - cuesheet->data.cue_sheet.media_catalog_number[1] = 'C'; - cuesheet->data.cue_sheet.lead_in = 2 * 44100; - cuesheet->data.cue_sheet.is_cd = true; - cuesheet->data.cue_sheet.num_tracks = 3; - cuesheet->data.cue_sheet.tracks = calloc_or_die_(cuesheet->data.cue_sheet.num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)); - cuesheet->data.cue_sheet.tracks[0].offset = 0; - cuesheet->data.cue_sheet.tracks[0].number = 1; - memcpy(cuesheet->data.cue_sheet.tracks[0].isrc, "ACBDE1234567", sizeof(cuesheet->data.cue_sheet.tracks[0].isrc)); - cuesheet->data.cue_sheet.tracks[0].type = 0; - cuesheet->data.cue_sheet.tracks[0].pre_emphasis = 1; - cuesheet->data.cue_sheet.tracks[0].num_indices = 2; - cuesheet->data.cue_sheet.tracks[0].indices = malloc_or_die_(cuesheet->data.cue_sheet.tracks[0].num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index)); - cuesheet->data.cue_sheet.tracks[0].indices[0].offset = 0; - cuesheet->data.cue_sheet.tracks[0].indices[0].number = 0; - cuesheet->data.cue_sheet.tracks[0].indices[1].offset = 123 * 588; - cuesheet->data.cue_sheet.tracks[0].indices[1].number = 1; - cuesheet->data.cue_sheet.tracks[1].offset = 1234 * 588; - cuesheet->data.cue_sheet.tracks[1].number = 2; - memcpy(cuesheet->data.cue_sheet.tracks[1].isrc, "ACBDE7654321", sizeof(cuesheet->data.cue_sheet.tracks[1].isrc)); - cuesheet->data.cue_sheet.tracks[1].type = 1; - cuesheet->data.cue_sheet.tracks[1].pre_emphasis = 0; - cuesheet->data.cue_sheet.tracks[1].num_indices = 1; - cuesheet->data.cue_sheet.tracks[1].indices = malloc_or_die_(cuesheet->data.cue_sheet.tracks[1].num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index)); - cuesheet->data.cue_sheet.tracks[1].indices[0].offset = 0; - cuesheet->data.cue_sheet.tracks[1].indices[0].number = 1; - cuesheet->data.cue_sheet.tracks[2].offset = 12345 * 588; - cuesheet->data.cue_sheet.tracks[2].number = 170; - cuesheet->data.cue_sheet.tracks[2].num_indices = 0; - - picture->is_last = false; - picture->type = FLAC__METADATA_TYPE_PICTURE; - picture->length = - ( - FLAC__STREAM_METADATA_PICTURE_TYPE_LEN + - FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN + /* will add the length for the string later */ - FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN + /* will add the length for the string later */ - FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN + - FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN + - FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN + - FLAC__STREAM_METADATA_PICTURE_COLORS_LEN + - FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN /* will add the length for the data later */ - ) / 8 - ; - picture->data.picture.type = FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER; - picture->data.picture.mime_type = strdup_or_die_("image/jpeg"); - picture->length += strlen(picture->data.picture.mime_type); - picture->data.picture.description = (FLAC__byte*)strdup_or_die_("desc"); - picture->length += strlen((const char *)picture->data.picture.description); - picture->data.picture.width = 300; - picture->data.picture.height = 300; - picture->data.picture.depth = 24; - picture->data.picture.colors = 0; - picture->data.picture.data = (FLAC__byte*)strdup_or_die_("SOMEJPEGDATA"); - picture->data.picture.data_length = strlen((const char *)picture->data.picture.data); - picture->length += picture->data.picture.data_length; - - unknown->is_last = true; - unknown->type = 126; - unknown->length = 8; - unknown->data.unknown.data = malloc_or_die_(unknown->length); - memcpy(unknown->data.unknown.data, "\xfe\xdc\xba\x98\xf0\xe1\xd2\xc3", unknown->length); -} - -void mutils__free_metadata_blocks( - FLAC__StreamMetadata *streaminfo, - FLAC__StreamMetadata *padding, - FLAC__StreamMetadata *seektable, - FLAC__StreamMetadata *application1, - FLAC__StreamMetadata *application2, - FLAC__StreamMetadata *vorbiscomment, - FLAC__StreamMetadata *cuesheet, - FLAC__StreamMetadata *picture, - FLAC__StreamMetadata *unknown -) -{ - (void)streaminfo, (void)padding, (void)application2; - free(seektable->data.seek_table.points); - free(application1->data.application.data); - free(vorbiscomment->data.vorbis_comment.vendor_string.entry); - free(vorbiscomment->data.vorbis_comment.comments[0].entry); - free(vorbiscomment->data.vorbis_comment.comments); - free(cuesheet->data.cue_sheet.tracks[0].indices); - free(cuesheet->data.cue_sheet.tracks[1].indices); - free(cuesheet->data.cue_sheet.tracks); - free(picture->data.picture.mime_type); - free(picture->data.picture.description); - free(picture->data.picture.data); - free(unknown->data.unknown.data); -} diff --git a/Engine/lib/flac/src/test_seeking/CMakeLists.txt b/Engine/lib/flac/src/test_seeking/CMakeLists.txt deleted file mode 100644 index 51442916c..000000000 --- a/Engine/lib/flac/src/test_seeking/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_executable(test_seeking - main.c - $<$:../../include/share/win_utf8_io.h> - $<$:../share/win_utf8_io/win_utf8_io.c>) -target_link_libraries(test_seeking FLAC) diff --git a/Engine/lib/flac/src/test_seeking/Makefile.am b/Engine/lib/flac/src/test_seeking/Makefile.am deleted file mode 100644 index 9c9b8da89..000000000 --- a/Engine/lib/flac/src/test_seeking/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# test_seeking - Seeking tester for libFLAC -# Copyright (C) 2004-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -AM_CFLAGS = @OGG_CFLAGS@ - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include - -check_PROGRAMS = test_seeking - -if OS_IS_WINDOWS -win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la -endif - -test_seeking_LDADD = \ - $(top_builddir)/src/libFLAC/libFLAC.la \ - $(win_utf8_lib) - -test_seeking_SOURCES = \ - main.c - -CLEANFILES = test_seeking.exe diff --git a/Engine/lib/flac/src/test_seeking/main.c b/Engine/lib/flac/src/test_seeking/main.c deleted file mode 100644 index 16ab9f40f..000000000 --- a/Engine/lib/flac/src/test_seeking/main.c +++ /dev/null @@ -1,473 +0,0 @@ -/* test_seeking - Seeking tester for libFLAC - * Copyright (C) 2004-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#if defined _MSC_VER || defined __MINGW32__ -#include -#else -#include -#endif -#include /* for stat() */ -#include "FLAC/assert.h" -#include "FLAC/metadata.h" -#include "FLAC/stream_decoder.h" -#include "share/compat.h" - -typedef struct { - FLAC__int32 **pcm; - FLAC__bool got_data; - FLAC__uint64 total_samples; - uint32_t channels; - uint32_t bits_per_sample; - FLAC__bool quiet; - FLAC__bool ignore_errors; - FLAC__bool error_occurred; -} DecoderClientData; - -static FLAC__bool stop_signal_ = false; - -static void our_sigint_handler_(int signum) -{ - (void)signum; - printf("(caught SIGINT) "); - fflush(stdout); - stop_signal_ = true; -} - -static FLAC__bool die_(const char *msg) -{ - printf("ERROR: %s\n", msg); - return false; -} - -static FLAC__bool die_s_(const char *msg, const FLAC__StreamDecoder *decoder) -{ - FLAC__StreamDecoderState state = FLAC__stream_decoder_get_state(decoder); - - if(msg) - printf("FAILED, %s", msg); - else - printf("FAILED"); - - printf(", state = %u (%s)\n", (uint32_t)state, FLAC__StreamDecoderStateString[state]); - - return false; -} - -static uint32_t local_rand_(void) -{ -#if !defined _MSC_VER && !defined __MINGW32__ -#define RNDFUNC random -#else -#define RNDFUNC rand -#endif - /* every RAND_MAX I've ever seen is 2^15-1 or 2^31-1, so a little hackery here: */ - if (RAND_MAX > 32767) - return RNDFUNC(); - else /* usually MSVC, some solaris */ - return (RNDFUNC()<<15) | RNDFUNC(); -#undef RNDFUNC -} - -static FLAC__off_t get_filesize_(const char *srcpath) -{ - struct flac_stat_s srcstat; - - if(0 == flac_stat(srcpath, &srcstat)) - return srcstat.st_size; - else - return -1; -} - -static FLAC__bool read_pcm_(FLAC__int32 *pcm[], const char *rawfilename, const char *flacfilename) -{ - FILE *f; - uint32_t channels = 0, bps = 0, samples, i, j; - - FLAC__off_t rawfilesize = get_filesize_(rawfilename); - if (rawfilesize < 0) { - fprintf(stderr, "ERROR: can't determine filesize for %s\n", rawfilename); - return false; - } - /* get sample format from flac file; would just use FLAC__metadata_get_streaminfo() except it doesn't work for Ogg FLAC yet */ - { -#if 0 - FLAC__StreamMetadata streaminfo; - if(!FLAC__metadata_get_streaminfo(flacfilename, &streaminfo)) { - printf("ERROR: getting STREAMINFO from %s\n", flacfilename); - return false; - } - channels = streaminfo.data.stream_info.channels; - bps = streaminfo.data.stream_info.bits_per_sample; -#else - FLAC__bool ok = true; - FLAC__Metadata_Chain *chain = FLAC__metadata_chain_new(); - FLAC__Metadata_Iterator *it = 0; - ok = ok && chain && (FLAC__metadata_chain_read(chain, flacfilename) || FLAC__metadata_chain_read_ogg(chain, flacfilename)); - ok = ok && (it = FLAC__metadata_iterator_new()); - if(ok) FLAC__metadata_iterator_init(it, chain); - ok = ok && (FLAC__metadata_iterator_get_block(it)->type == FLAC__METADATA_TYPE_STREAMINFO); - ok = ok && (channels = FLAC__metadata_iterator_get_block(it)->data.stream_info.channels); - ok = ok && (bps = FLAC__metadata_iterator_get_block(it)->data.stream_info.bits_per_sample); - if(it) FLAC__metadata_iterator_delete(it); - if(chain) FLAC__metadata_chain_delete(chain); - if(!ok) { - printf("ERROR: getting STREAMINFO from %s\n", flacfilename); - return false; - } -#endif - } - if(channels > 2) { - printf("ERROR: PCM verification requires 1 or 2 channels, got %u\n", channels); - return false; - } - if(bps != 8 && bps != 16) { - printf("ERROR: PCM verification requires 8 or 16 bps, got %u\n", bps); - return false; - } - samples = (uint32_t)(rawfilesize / channels / (bps>>3)); - if (samples > 10000000) { - fprintf(stderr, "ERROR: %s is too big\n", rawfilename); - return false; - } - for(i = 0; i < channels; i++) { - if(0 == (pcm[i] = malloc(sizeof(FLAC__int32)*samples))) { - printf("ERROR: allocating space for PCM samples\n"); - return false; - } - } - if(0 == (f = flac_fopen(rawfilename, "rb"))) { - printf("ERROR: opening %s for reading\n", rawfilename); - return false; - } - /* assumes signed big-endian data */ - if(bps == 8) { - signed char c; - for(i = 0; i < samples; i++) { - for(j = 0; j < channels; j++) { - if (fread(&c, 1, 1, f) == 1) - pcm[j][i] = c; - } - } - } - else { /* bps == 16 */ - uint8_t c[2]; - uint16_t value; - for(i = 0; i < samples; i++) { - for(j = 0; j < channels; j++) { - if (fread(&c, 1, 2, f) == 2) { - value = (c[0] << 8) | c[1]; - pcm[j][i] = value & 0x8000 ? 0xffff0000 | value : value; - } - } - } - } - fclose(f); - return true; -} - -static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) -{ - DecoderClientData *dcd = (DecoderClientData*)client_data; - - (void)decoder, (void)buffer; - - if(0 == dcd) { - printf("ERROR: client_data in write callback is NULL\n"); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - if(dcd->error_occurred) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - - FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); /* decoder guarantees this */ - if (!dcd->quiet) - printf("frame@%" PRIu64 "(%u)... ", frame->header.number.sample_number, frame->header.blocksize); - fflush(stdout); - - /* check against PCM data if we have it */ - if (dcd->pcm) { - uint32_t c, i, j; - for (c = 0; c < frame->header.channels; c++) - for (i = (uint32_t)frame->header.number.sample_number, j = 0; j < frame->header.blocksize; i++, j++) - if (buffer[c][j] != dcd->pcm[c][i]) { - printf("ERROR: sample mismatch at sample#%u(%u), channel=%u, expected %d, got %d\n", i, j, c, buffer[c][j], dcd->pcm[c][i]); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -static void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - DecoderClientData *dcd = (DecoderClientData*)client_data; - - (void)decoder; - - if(0 == dcd) { - printf("ERROR: client_data in metadata callback is NULL\n"); - return; - } - - if(dcd->error_occurred) - return; - - if (!dcd->got_data && metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { - dcd->got_data = true; - dcd->total_samples = metadata->data.stream_info.total_samples; - dcd->channels = metadata->data.stream_info.channels; - dcd->bits_per_sample = metadata->data.stream_info.bits_per_sample; - } -} - -static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) -{ - DecoderClientData *dcd = (DecoderClientData*)client_data; - - (void)decoder; - - if(0 == dcd) { - printf("ERROR: client_data in error callback is NULL\n"); - return; - } - - if(!dcd->ignore_errors) { - printf("ERROR: got error callback: err = %u (%s)\n", (uint32_t)status, FLAC__StreamDecoderErrorStatusString[status]); - dcd->error_occurred = true; - } -} - -/* read mode: - * 0 - no read after seek - * 1 - read 2 frames - * 2 - read until end - */ -static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, FLAC__off_t filesize, uint32_t count, FLAC__int64 total_samples, uint32_t read_mode, FLAC__int32 **pcm) -{ - FLAC__StreamDecoder *decoder; - DecoderClientData decoder_client_data; - uint32_t i; - long int n; - - decoder_client_data.pcm = pcm; - decoder_client_data.got_data = false; - decoder_client_data.total_samples = 0; - decoder_client_data.quiet = false; - decoder_client_data.ignore_errors = false; - decoder_client_data.error_occurred = false; - - printf("\n+++ seek test: FLAC__StreamDecoder (%s FLAC, read_mode=%u)\n\n", is_ogg? "Ogg":"native", read_mode); - - decoder = FLAC__stream_decoder_new(); - if(0 == decoder) - return die_("FLAC__stream_decoder_new() FAILED, returned NULL\n"); - - if(is_ogg) { - if(FLAC__stream_decoder_init_ogg_file(decoder, filename, write_callback_, metadata_callback_, error_callback_, &decoder_client_data) != FLAC__STREAM_DECODER_INIT_STATUS_OK) - return die_s_("FLAC__stream_decoder_init_file() FAILED", decoder); - } - else { - if(FLAC__stream_decoder_init_file(decoder, filename, write_callback_, metadata_callback_, error_callback_, &decoder_client_data) != FLAC__STREAM_DECODER_INIT_STATUS_OK) - return die_s_("FLAC__stream_decoder_init_file() FAILED", decoder); - } - - if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) - return die_s_("FLAC__stream_decoder_process_until_end_of_metadata() FAILED", decoder); - - if(!is_ogg) { /* not necessary to do this for Ogg because of its seeking method */ - /* process until end of stream to make sure we can still seek in that state */ - decoder_client_data.quiet = true; - if(!FLAC__stream_decoder_process_until_end_of_stream(decoder)) - return die_s_("FLAC__stream_decoder_process_until_end_of_stream() FAILED", decoder); - decoder_client_data.quiet = false; - - printf("stream decoder state is %s\n", FLAC__stream_decoder_get_resolved_state_string(decoder)); - if(FLAC__stream_decoder_get_state(decoder) != FLAC__STREAM_DECODER_END_OF_STREAM) - return die_s_("expected FLAC__STREAM_DECODER_END_OF_STREAM", decoder); - } - - printf("file's total_samples is %" PRIu64 "\n", decoder_client_data.total_samples); - n = (long int)decoder_client_data.total_samples; - - if(n == 0 && total_samples >= 0) - n = (long int)total_samples; - - /* if we don't have a total samples count, just guess based on the file size */ - /* @@@ for is_ogg we should get it from last page's granulepos */ - if(n == 0) { - /* 8 would imply no compression, 9 guarantees that we will get some samples off the end of the stream to test that case */ - n = (long int)(9 * filesize / (decoder_client_data.channels * decoder_client_data.bits_per_sample)); - } - - printf("Begin seek barrage, count=%u\n", count); - - for (i = 0; !stop_signal_ && (count == 0 || i < count); i++) { - FLAC__uint64 pos; - - /* for the first 10, seek to the first 10 samples */ - if (n >= 10 && i < 10) { - pos = i; - } - /* for the second 10, seek to the last 10 samples */ - else if (n >= 10 && i < 20) { - pos = n - 1 - (i-10); - } - /* for the third 10, seek past the end and make sure we fail properly as expected */ - else if (i < 30) { - pos = n + (i-20); - } - else { - pos = (FLAC__uint64)(local_rand_() % n); - } - - printf("#%u:seek(%" PRIu64 ")... ", i, pos); - fflush(stdout); - if(!FLAC__stream_decoder_seek_absolute(decoder, pos)) { - if(pos >= (FLAC__uint64)n) - printf("seek past end failed as expected... "); - else if(decoder_client_data.total_samples == 0 && total_samples <= 0) - printf("seek failed, assuming it was past EOF... "); - else - return die_s_("FLAC__stream_decoder_seek_absolute() FAILED", decoder); - if(!FLAC__stream_decoder_flush(decoder)) - return die_s_("FLAC__stream_decoder_flush() FAILED", decoder); - } - else if(read_mode == 1) { - printf("decode_frame... "); - fflush(stdout); - if(!FLAC__stream_decoder_process_single(decoder)) - return die_s_("FLAC__stream_decoder_process_single() FAILED", decoder); - - printf("decode_frame... "); - fflush(stdout); - if(!FLAC__stream_decoder_process_single(decoder)) - return die_s_("FLAC__stream_decoder_process_single() FAILED", decoder); - } - else if(read_mode == 2) { - printf("decode_all... "); - fflush(stdout); - decoder_client_data.quiet = true; - if(!FLAC__stream_decoder_process_until_end_of_stream(decoder)) - return die_s_("FLAC__stream_decoder_process_until_end_of_stream() FAILED", decoder); - decoder_client_data.quiet = false; - } - - printf("OK\n"); - fflush(stdout); - } - stop_signal_ = false; - - if(FLAC__stream_decoder_get_state(decoder) != FLAC__STREAM_DECODER_UNINITIALIZED) { - if(!FLAC__stream_decoder_finish(decoder)) - return die_s_("FLAC__stream_decoder_finish() FAILED", decoder); - } - - FLAC__stream_decoder_delete(decoder); - printf("\nPASSED!\n"); - - return true; -} - - -int main(int argc, char *argv[]) -{ - const char *flacfilename, *rawfilename = 0; - uint32_t count = 0, read_mode; - FLAC__int64 samples = -1; - FLAC__off_t flacfilesize; - FLAC__int32 *pcm[2] = { 0, 0 }; - FLAC__bool ok = true; - - static const char * const usage = "usage: test_seeking file.flac [#seeks] [#samples-in-file.flac] [file.raw]\n"; - - if (argc < 2 || argc > 5) { - fputs(usage, stderr); - return 1; - } - - flacfilename = argv[1]; - - if (argc > 2) - count = strtoul(argv[2], 0, 10); - if (argc > 3) - samples = strtoull(argv[3], 0, 10); - if (argc > 4) - rawfilename = argv[4]; - - if (count < 30) - fprintf(stderr, "WARNING: random seeks don't kick in until after 30 preprogrammed ones\n"); - -#if !defined _MSC_VER && !defined __MINGW32__ - { - struct timeval tv; - - if (gettimeofday(&tv, 0) < 0) { - fprintf(stderr, "WARNING: couldn't seed RNG with time\n"); - tv.tv_usec = 4321; - } - srandom(tv.tv_usec); - } -#else - srand((uint32_t)time(0)); -#endif - - flacfilesize = get_filesize_(flacfilename); - if (flacfilesize < 0) { - fprintf(stderr, "ERROR: can't determine filesize for %s\n", flacfilename); - return 1; - } - - if (rawfilename && !read_pcm_(pcm, rawfilename, flacfilename)) { - free(pcm[0]); - free(pcm[1]); - return 1; - } - - (void) signal(SIGINT, our_sigint_handler_); - - for (read_mode = 0; ok && read_mode <= 2; read_mode++) { - /* no need to do "decode all" read_mode if PCM checking is available */ - if (rawfilename && read_mode > 1) - continue; - if (strlen(flacfilename) > 4 && (0 == strcmp(flacfilename+strlen(flacfilename)-4, ".oga") || 0 == strcmp(flacfilename+strlen(flacfilename)-4, ".ogg"))) { -#if FLAC__HAS_OGG - ok = seek_barrage(/*is_ogg=*/true, flacfilename, flacfilesize, count, samples, read_mode, rawfilename? pcm : 0); -#else - fprintf(stderr, "ERROR: Ogg FLAC not supported\n"); - ok = false; -#endif - } - else { - ok = seek_barrage(/*is_ogg=*/false, flacfilename, flacfilesize, count, samples, read_mode, rawfilename? pcm : 0); - } - } - - free(pcm[0]); - free(pcm[1]); - - return ok? 0 : 2; -} diff --git a/Engine/lib/flac/src/test_streams/CMakeLists.txt b/Engine/lib/flac/src/test_streams/CMakeLists.txt deleted file mode 100644 index f9fafb9d6..000000000 --- a/Engine/lib/flac/src/test_streams/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(test_streams main.c) -target_link_libraries(test_streams FLAC grabbag) diff --git a/Engine/lib/flac/src/test_streams/Makefile.am b/Engine/lib/flac/src/test_streams/Makefile.am deleted file mode 100644 index 9aa4b025e..000000000 --- a/Engine/lib/flac/src/test_streams/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# test_streams - Simple test pattern generator -# Copyright (C) 2000-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt - -AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include -check_PROGRAMS = test_streams -test_streams_SOURCES = \ - main.c - -test_streams_LDADD = $(top_builddir)/src/share/grabbag/libgrabbag.la -lm - -CLEANFILES = test_streams.exe diff --git a/Engine/lib/flac/src/test_streams/main.c b/Engine/lib/flac/src/test_streams/main.c deleted file mode 100644 index 466bf8ef2..000000000 --- a/Engine/lib/flac/src/test_streams/main.c +++ /dev/null @@ -1,1398 +0,0 @@ -/* test_streams - Simple test pattern generator - * Copyright (C) 2000-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include "share/compat.h" -#if defined _MSC_VER || defined __MINGW32__ -#include -#else -#include -#endif -#include "FLAC/assert.h" -#include "FLAC/ordinals.h" -#include "share/compat.h" - -#if !defined _MSC_VER && !defined __MINGW32__ -#define GET_RANDOM_BYTE (((unsigned)random()) & 0xff) -#else -#define GET_RANDOM_BYTE (((unsigned)rand()) & 0xff) -#endif - -static FLAC__bool is_big_endian_host; - - -static FLAC__bool write_little_endian_unsigned(FILE *f, FLAC__uint32 x, size_t bytes) -{ - while(bytes) { - if(fputc(x, f) == EOF) - return false; - x >>= 8; - bytes--; - } - return true; -} - -static FLAC__bool write_little_endian_signed(FILE *f, FLAC__int32 x, size_t bytes) -{ - return write_little_endian_unsigned(f, (FLAC__uint32) x, bytes); -} - -static FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 x) -{ - return - fputc(x, f) != EOF && - fputc(x >> 8, f) != EOF - ; -} - -static FLAC__bool write_little_endian_int16(FILE *f, FLAC__int16 x) -{ - return write_little_endian_uint16(f, (FLAC__uint16)x); -} - -static FLAC__bool write_little_endian_uint24(FILE *f, FLAC__uint32 x) -{ - return - fputc(x, f) != EOF && - fputc(x >> 8, f) != EOF && - fputc(x >> 16, f) != EOF - ; -} - -static FLAC__bool write_little_endian_int24(FILE *f, FLAC__int32 x) -{ - return write_little_endian_uint24(f, (FLAC__uint32)x); -} - -static FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 x) -{ - return - fputc(x, f) != EOF && - fputc(x >> 8, f) != EOF && - fputc(x >> 16, f) != EOF && - fputc(x >> 24, f) != EOF - ; -} - -static FLAC__bool write_little_endian_int32(FILE *f, FLAC__int32 x) -{ - return write_little_endian_uint32(f, (FLAC__uint32)x); -} - -#if defined(_MSC_VER) -// silence 4 MSVC warnings 'conversion from 'FLAC__uint64' to 'int', possible loss of data' -#pragma warning ( disable : 4244 ) -#endif -static FLAC__bool write_little_endian_uint64(FILE *f, FLAC__uint64 x) -{ - return - fputc(x, f) != EOF && - fputc(x >> 8, f) != EOF && - fputc(x >> 16, f) != EOF && - fputc(x >> 24, f) != EOF && - fputc(x >> 32, f) != EOF && - fputc(x >> 40, f) != EOF && - fputc(x >> 48, f) != EOF && - fputc(x >> 56, f) != EOF - ; -} -#if defined(_MSC_VER) -#pragma warning ( default : 4244 ) -#endif - -static FLAC__bool write_big_endian(FILE *f, FLAC__int32 x, size_t bytes) -{ - if(bytes < 4) - x <<= 8*(4-bytes); - while(bytes) { - if(fputc(x>>24, f) == EOF) - return false; - x <<= 8; - bytes--; - } - return true; -} - -static FLAC__bool write_big_endian_uint16(FILE *f, FLAC__uint16 x) -{ - return - fputc(x >> 8, f) != EOF && - fputc(x, f) != EOF - ; -} - -#if 0 -/* @@@ not used (yet) */ -static FLAC__bool write_big_endian_int16(FILE *f, FLAC__int16 x) -{ - return write_big_endian_uint16(f, (FLAC__uint16)x); -} -#endif - -#if 0 -/* @@@ not used (yet) */ -static FLAC__bool write_big_endian_uint24(FILE *f, FLAC__uint32 x) -{ - return - fputc(x >> 16, f) != EOF && - fputc(x >> 8, f) != EOF && - fputc(x, f) != EOF - ; -} -#endif - -#if 0 -/* @@@ not used (yet) */ -static FLAC__bool write_big_endian_int24(FILE *f, FLAC__int32 x) -{ - return write_big_endian_uint24(f, (FLAC__uint32)x); -} -#endif - -static FLAC__bool write_big_endian_uint32(FILE *f, FLAC__uint32 x) -{ - return - fputc(x >> 24, f) != EOF && - fputc(x >> 16, f) != EOF && - fputc(x >> 8, f) != EOF && - fputc(x, f) != EOF - ; -} - -#if 0 -/* @@@ not used (yet) */ -static FLAC__bool write_big_endian_int32(FILE *f, FLAC__int32 x) -{ - return write_big_endian_uint32(f, (FLAC__uint32)x); -} -#endif - -static FLAC__bool write_sane_extended(FILE *f, unsigned val) - /* Write to 'f' a SANE extended representation of 'val'. Return false if - * the write succeeds; return true otherwise. - * - * SANE extended is an 80-bit IEEE-754 representation with sign bit, 15 bits - * of exponent, and 64 bits of significand (mantissa). Unlike most IEEE-754 - * representations, it does not imply a 1 above the MSB of the significand. - * - * Preconditions: - * val!=0U - */ -{ - unsigned int shift, exponent; - - FLAC__ASSERT(val!=0U); /* handling 0 would require a special case */ - - for(shift= 0U; (val>>(31-shift))==0U; ++shift) - ; - val<<= shift; - exponent= 63U-(shift+32U); /* add 32 for unused second word */ - - if(!write_big_endian_uint16(f, (FLAC__uint16)(exponent+0x3FFF))) - return false; - if(!write_big_endian_uint32(f, val)) - return false; - if(!write_big_endian_uint32(f, 0)) /* unused second word */ - return false; - - return true; -} - -/* a mono one-sample 16bps stream */ -static FLAC__bool generate_01(void) -{ - FILE *f; - FLAC__int16 x = -32768; - - if(0 == (f = fopen("test01.raw", "wb"))) - return false; - - if(!write_little_endian_int16(f, x)) - goto foo; - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a stereo one-sample 16bps stream */ -static FLAC__bool generate_02(void) -{ - FILE *f; - FLAC__int16 xl = -32768, xr = 32767; - - if(0 == (f = fopen("test02.raw", "wb"))) - return false; - - if(!write_little_endian_int16(f, xl)) - goto foo; - if(!write_little_endian_int16(f, xr)) - goto foo; - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a mono five-sample 16bps stream */ -static FLAC__bool generate_03(void) -{ - FILE *f; - FLAC__int16 x[] = { -25, 0, 25, 50, 100 }; - unsigned i; - - if(0 == (f = fopen("test03.raw", "wb"))) - return false; - - for(i = 0; i < 5; i++) - if(!write_little_endian_int16(f, x[i])) - goto foo; - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a stereo five-sample 16bps stream */ -static FLAC__bool generate_04(void) -{ - FILE *f; - FLAC__int16 x[] = { -25, 500, 0, 400, 25, 300, 50, 200, 100, 100 }; - unsigned i; - - if(0 == (f = fopen("test04.raw", "wb"))) - return false; - - for(i = 0; i < 10; i++) - if(!write_little_endian_int16(f, x[i])) - goto foo; - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a mono full-scale deflection 8bps stream */ -static FLAC__bool generate_fsd8(const char *fn, const int pattern[], unsigned reps) -{ - FILE *f; - unsigned rep, p; - - FLAC__ASSERT(pattern != 0); - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(rep = 0; rep < reps; rep++) { - for(p = 0; pattern[p]; p++) { - signed char x = pattern[p] > 0? 127 : -128; - if(fwrite(&x, sizeof(x), 1, f) < 1) - goto foo; - } - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a mono full-scale deflection 16bps stream */ -static FLAC__bool generate_fsd16(const char *fn, const int pattern[], unsigned reps) -{ - FILE *f; - unsigned rep, p; - - FLAC__ASSERT(pattern != 0); - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(rep = 0; rep < reps; rep++) { - for(p = 0; pattern[p]; p++) { - FLAC__int16 x = pattern[p] > 0? 32767 : -32768; - if(!write_little_endian_int16(f, x)) - goto foo; - } - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a stereo wasted-bits-per-sample 16bps stream */ -static FLAC__bool generate_wbps16(const char *fn, unsigned samples) -{ - FILE *f; - unsigned sample; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(sample = 0; sample < samples; sample++) { - FLAC__int16 l = (sample % 2000) << 2; - FLAC__int16 r = (sample % 1000) << 3; - if(!write_little_endian_int16(f, l)) - goto foo; - if(!write_little_endian_int16(f, r)) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a mono full-scale deflection 24bps stream */ -static FLAC__bool generate_fsd24(const char *fn, const int pattern[], unsigned reps) -{ - FILE *f; - unsigned rep, p; - - FLAC__ASSERT(pattern != 0); - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(rep = 0; rep < reps; rep++) { - for(p = 0; pattern[p]; p++) { - FLAC__int32 x = pattern[p] > 0? 8388607 : -8388608; - if(!write_little_endian_int24(f, x)) - goto foo; - } - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a mono full-scale deflection 32bps stream */ -static FLAC__bool generate_fsd32(const char *fn, const int pattern[], unsigned reps) -{ - FILE *f; - unsigned rep, p; - - FLAC__ASSERT(pattern != 0); - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(rep = 0; rep < reps; rep++) { - for(p = 0; pattern[p]; p++) { - FLAC__int32 x = pattern[p] > 0? 2147483647 : -2147483648; - if(!write_little_endian_int32(f, x)) - goto foo; - } - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a mono sine-wave 8bps stream */ -static FLAC__bool generate_sine8_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2) -{ - const FLAC__int8 full_scale = 127; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - FILE *f; - double theta1, theta2; - unsigned i; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int8 v = (FLAC__int8)(val + 0.5); - if(fwrite(&v, sizeof(v), 1, f) < 1) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a stereo sine-wave 8bps stream */ -static FLAC__bool generate_sine8_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult) -{ - const FLAC__int8 full_scale = 127; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - FILE *f; - double theta1, theta2; - unsigned i; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int8 v = (FLAC__int8)(val + 0.5); - if(fwrite(&v, sizeof(v), 1, f) < 1) - goto foo; - val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale; - v = (FLAC__int8)(val + 0.5); - if(fwrite(&v, sizeof(v), 1, f) < 1) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a mono sine-wave 16bps stream */ -static FLAC__bool generate_sine16_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2) -{ - const FLAC__int16 full_scale = 32767; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - FILE *f; - double theta1, theta2; - unsigned i; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int16 v = (FLAC__int16)(val + 0.5); - if(!write_little_endian_int16(f, v)) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a stereo sine-wave 16bps stream */ -static FLAC__bool generate_sine16_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult) -{ - const FLAC__int16 full_scale = 32767; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - FILE *f; - double theta1, theta2; - unsigned i; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int16 v = (FLAC__int16)(val + 0.5); - if(!write_little_endian_int16(f, v)) - goto foo; - val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale; - v = (FLAC__int16)(val + 0.5); - if(!write_little_endian_int16(f, v)) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a mono sine-wave 24bps stream */ -static FLAC__bool generate_sine24_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2) -{ - const FLAC__int32 full_scale = 0x7fffff; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - FILE *f; - double theta1, theta2; - unsigned i; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int32 v = (FLAC__int32)(val + 0.5); - if(!write_little_endian_int24(f, v)) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a stereo sine-wave 24bps stream */ -static FLAC__bool generate_sine24_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult) -{ - const FLAC__int32 full_scale = 0x7fffff; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - FILE *f; - double theta1, theta2; - unsigned i; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int32 v = (FLAC__int32)(val + 0.5); - if(!write_little_endian_int24(f, v)) - goto foo; - val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale; - v = (FLAC__int32)(val + 0.5); - if(!write_little_endian_int24(f, v)) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a mono sine-wave 32bps stream */ -static FLAC__bool generate_sine32_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2) -{ - const FLAC__int32 full_scale = 0x7fffffff; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - FILE *f; - double theta1, theta2; - unsigned i; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int32 v = (FLAC__int32)(val + 0.5); - if(!write_little_endian_int32(f, v)) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* a stereo sine-wave 32bps stream */ -static FLAC__bool generate_sine32_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult) -{ - const FLAC__int32 full_scale = 0x7fffffff; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - FILE *f; - double theta1, theta2; - unsigned i; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int32 v = (FLAC__int32)(val + 0.5); - if(!write_little_endian_int32(f, v)) - goto foo; - val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale; - v = (FLAC__int32)(val + 0.5); - if(!write_little_endian_int32(f, v)) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -static FLAC__bool generate_noise(const char *fn, unsigned bytes) -{ - FILE *f; - unsigned b; - - if(0 == (f = fopen(fn, "wb"))) - return false; - - for(b = 0; b < bytes; b++) { -#if !defined _MSC_VER && !defined __MINGW32__ - FLAC__byte x = (FLAC__byte)(((unsigned)random()) & 0xff); -#else - FLAC__byte x = (FLAC__byte)(((unsigned)rand()) & 0xff); -#endif - if(fwrite(&x, sizeof(x), 1, f) < 1) - goto foo; - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -static FLAC__bool generate_signed_raw(const char *filename, unsigned channels, unsigned bytes_per_sample, unsigned samples) -{ - const FLAC__int32 full_scale = (1 << (bytes_per_sample*8-1)) - 1; - const double f1 = 441.0, a1 = 0.61, f2 = 661.5, a2 = 0.37; - const double delta1 = 2.0 * M_PI / ( 44100.0 / f1); - const double delta2 = 2.0 * M_PI / ( 44100.0 / f2); - double theta1, theta2; - FILE *f; - unsigned i, j; - - if(0 == (f = fopen(filename, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - for(j = 0; j < channels; j++) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int32 v = (FLAC__int32)(val + 0.5) + ((GET_RANDOM_BYTE>>4)-8); - if(!write_little_endian_signed(f, v, bytes_per_sample)) - goto foo; - } - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -static FLAC__bool generate_unsigned_raw(const char *filename, unsigned channels, unsigned bytes_per_sample, unsigned samples) -{ - const FLAC__int32 full_scale = (1 << (bytes_per_sample*8-1)) - 1; - const double f1 = 441.0, a1 = 0.61, f2 = 661.5, a2 = 0.37; - const double delta1 = 2.0 * M_PI / ( 44100.0 / f1); - const double delta2 = 2.0 * M_PI / ( 44100.0 / f2); - const double half_scale = 0.5 * full_scale; - double theta1, theta2; - FILE *f; - unsigned i, j; - - if(0 == (f = fopen(filename, "wb"))) - return false; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - for(j = 0; j < channels; j++) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int32 v = (FLAC__int32)(half_scale + val + 0.5) + ((GET_RANDOM_BYTE>>4)-8); - if(!write_little_endian_unsigned(f, v, bytes_per_sample)) - goto foo; - } - } - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -static FLAC__bool generate_aiff(const char *filename, unsigned sample_rate, unsigned channels, unsigned bps, unsigned samples) -{ - const unsigned bytes_per_sample = (bps+7)/8; - const unsigned true_size = channels * bytes_per_sample * samples; - const unsigned padded_size = (true_size + 1) & (~1u); - const unsigned shift = (bps%8)? 8 - (bps%8) : 0; - const FLAC__int32 full_scale = (1 << (bps-1)) - 1; - const double f1 = 441.0, a1 = 0.61, f2 = 661.5, a2 = 0.37; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - double theta1, theta2; - FILE *f; - unsigned i, j; - - if(0 == (f = fopen(filename, "wb"))) - return false; - if(fwrite("FORM", 1, 4, f) < 4) - goto foo; - if(!write_big_endian_uint32(f, padded_size + 46)) - goto foo; - if(fwrite("AIFFCOMM\000\000\000\022", 1, 12, f) < 12) - goto foo; - if(!write_big_endian_uint16(f, (FLAC__uint16)channels)) - goto foo; - if(!write_big_endian_uint32(f, samples)) - goto foo; - if(!write_big_endian_uint16(f, (FLAC__uint16)bps)) - goto foo; - if(!write_sane_extended(f, sample_rate)) - goto foo; - if(fwrite("SSND", 1, 4, f) < 4) - goto foo; - if(!write_big_endian_uint32(f, true_size + 8)) - goto foo; - if(fwrite("\000\000\000\000\000\000\000\000", 1, 8, f) < 8) - goto foo; - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - for(j = 0; j < channels; j++) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int32 v = ((FLAC__int32)(val + 0.5) + ((GET_RANDOM_BYTE>>4)-8)) << shift; - if(!write_big_endian(f, v, bytes_per_sample)) - goto foo; - } - } - for(i = true_size; i < padded_size; i++) - if(fputc(0, f) == EOF) - goto foo; - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -/* flavor is: 0:WAVE, 1:RF64, 2:WAVE64 */ -static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsigned channels, unsigned bps, unsigned samples, FLAC__bool strict, int flavor) -{ - const FLAC__bool waveformatextensible = strict && (channels > 2 || (bps != 8 && bps != 16)); - - const unsigned bytes_per_sample = (bps+7)/8; - const unsigned shift = (bps%8)? 8 - (bps%8) : 0; - /* this rig is not going over 4G so we're ok with 32-bit sizes here */ - const FLAC__uint32 true_size = channels * bytes_per_sample * samples; - const FLAC__uint32 padded_size = flavor<2? (true_size + 1) & (~1u) : (true_size + 7) & (~7u); - const FLAC__int32 full_scale = (1 << (bps-1)) - 1; - const double f1 = 441.0, a1 = 0.61, f2 = 661.5, a2 = 0.37; - const double delta1 = 2.0 * M_PI / ( sample_rate / f1); - const double delta2 = 2.0 * M_PI / ( sample_rate / f2); - double theta1, theta2; - FILE *f; - unsigned i, j; - - if(0 == (f = fopen(filename, "wb"))) - return false; - /* RIFFxxxxWAVE or equivalent: */ - switch(flavor) { - case 0: - if(fwrite("RIFF", 1, 4, f) < 4) - goto foo; - /* +4 for WAVE */ - /* +8+{40,16} for fmt chunk */ - /* +8 for data chunk header */ - if(!write_little_endian_uint32(f, 4 + 8+(waveformatextensible?40:16) + 8 + padded_size)) - goto foo; - if(fwrite("WAVE", 1, 4, f) < 4) - goto foo; - break; - case 1: - if(fwrite("RF64", 1, 4, f) < 4) - goto foo; - if(!write_little_endian_uint32(f, 0xffffffff)) - goto foo; - if(fwrite("WAVE", 1, 4, f) < 4) - goto foo; - break; - case 2: - /* RIFF GUID 66666972-912E-11CF-A5D6-28DB04C10000 */ - if(fwrite("\x72\x69\x66\x66\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00", 1, 16, f) < 16) - goto foo; - /* +(16+8) for RIFF GUID + size */ - /* +16 for WAVE GUID */ - /* +16+8+{40,16} for fmt chunk */ - /* +16+8 for data chunk header */ - if(!write_little_endian_uint64(f, (16+8) + 16 + 16+8+(waveformatextensible?40:16) + (16+8) + padded_size)) - goto foo; - /* WAVE GUID 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */ - if(fwrite("\x77\x61\x76\x65\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) < 16) - goto foo; - break; - default: - goto foo; - } - if(flavor == 1) { /* rf64 */ - if(fwrite("ds64", 1, 4, f) < 4) - goto foo; - if(!write_little_endian_uint32(f, 28)) /* ds64 chunk size */ - goto foo; - if(!write_little_endian_uint64(f, 36 + padded_size + (waveformatextensible?60:36))) - goto foo; - if(!write_little_endian_uint64(f, true_size)) - goto foo; - if(!write_little_endian_uint64(f, samples)) - goto foo; - if(!write_little_endian_uint32(f, 0)) /* table size */ - goto foo; - } - /* fmt chunk */ - if(flavor < 2) { - if(fwrite("fmt ", 1, 4, f) < 4) - goto foo; - /* chunk size */ - if(!write_little_endian_uint32(f, waveformatextensible?40:16)) - goto foo; - } - else { /* wave64 */ - /* fmt GUID 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */ - if(fwrite("\x66\x6D\x74\x20\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) < 16) - goto foo; - /* chunk size (+16+8 for GUID and size fields) */ - if(!write_little_endian_uint64(f, 16+8+(waveformatextensible?40:16))) - goto foo; - } - if(!write_little_endian_uint16(f, (FLAC__uint16)(waveformatextensible?65534:1))) - goto foo; - if(!write_little_endian_uint16(f, (FLAC__uint16)channels)) - goto foo; - if(!write_little_endian_uint32(f, sample_rate)) - goto foo; - if(!write_little_endian_uint32(f, sample_rate * channels * bytes_per_sample)) - goto foo; - if(!write_little_endian_uint16(f, (FLAC__uint16)(channels * bytes_per_sample))) /* block align */ - goto foo; - if(!write_little_endian_uint16(f, (FLAC__uint16)(bps+shift))) - goto foo; - if(waveformatextensible) { - if(!write_little_endian_uint16(f, (FLAC__uint16)22)) /* cbSize */ - goto foo; - if(!write_little_endian_uint16(f, (FLAC__uint16)bps)) /* validBitsPerSample */ - goto foo; - if(!write_little_endian_uint32(f, 0)) /* channelMask */ - goto foo; - /* GUID = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} */ - if(fwrite("\x01\x00\x00\x00\x00\x00\x10\x00\x80\x00\x00\xaa\x00\x38\x9b\x71", 1, 16, f) != 16) - goto foo; - } - /* data chunk */ - if(flavor < 2) { - if(fwrite("data", 1, 4, f) < 4) - goto foo; - if(!write_little_endian_uint32(f, flavor==1? 0xffffffff : true_size)) - goto foo; - } - else { /* wave64 */ - /* data GUID 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */ - if(fwrite("\x64\x61\x74\x61\xF3\xAC\xD3\x11\x8C\xD1\x00\xC0\x4F\x8E\xDB\x8A", 1, 16, f) != 16) - goto foo; - /* +16+8 for GUID and size fields */ - if(!write_little_endian_uint64(f, 16+8 + true_size)) - goto foo; - } - - for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { - for(j = 0; j < channels; j++) { - double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - FLAC__int32 v = ((FLAC__int32)(val + 0.5) + ((GET_RANDOM_BYTE>>4)-8)) << shift; - if(!write_little_endian_signed(f, v, bytes_per_sample)) - goto foo; - } - } - for(i = true_size; i < padded_size; i++) - if(fputc(0, f) == EOF) - goto foo; - - fclose(f); - return true; -foo: - fclose(f); - return false; -} - -static FLAC__bool generate_wackywavs(void) -{ - FILE *f; - FLAC__byte wav[] = { - 'R', 'I', 'F', 'F', 76, 0, 0, 0, - 'W', 'A', 'V', 'E', 'j', 'u', 'n', 'k', - 4, 0, 0, 0 , 'b', 'l', 'a', 'h', - 'p', 'a', 'd', ' ', 4, 0, 0, 0, - 'B', 'L', 'A', 'H', 'f', 'm', 't', ' ', - 16, 0, 0, 0, 1, 0, 1, 0, - 0x44,0xAC, 0, 0,0x88,0x58,0x01, 0, - 2, 0, 16, 0, 'd', 'a', 't', 'a', - 16, 0, 0, 0, 0, 0, 1, 0, - 4, 0, 9, 0, 16, 0, 25, 0, - 36, 0, 49, 0, 'p', 'a', 'd', ' ', - 4, 0, 0, 0, 'b', 'l', 'a', 'h' - }; - - if(0 == (f = fopen("wacky1.wav", "wb"))) - return false; - if(fwrite(wav, 1, 84, f) < 84) - goto foo; - fclose(f); - - wav[4] += 12; - if(0 == (f = fopen("wacky2.wav", "wb"))) - return false; - if(fwrite(wav, 1, 96, f) < 96) - goto foo; - fclose(f); - - return true; -foo: - fclose(f); - return false; -} - -static FLAC__bool write_simple_wavex_header (FILE * f, unsigned samplerate, unsigned channels, unsigned bytespersample, unsigned frames) -{ - unsigned datalen = channels * bytespersample * frames ; - - if (fwrite("RIFF", 1, 4, f) != 4) - return false; - if (!write_little_endian_uint32(f, 60 + datalen)) - return false; - - if (fwrite("WAVEfmt ", 8, 1, f) != 1) - return false; - if (!write_little_endian_uint32(f, 40)) - return false; - - if(!write_little_endian_uint16(f, 65534)) /* WAVEFORMATEXTENSIBLE tag */ - return false; - if(!write_little_endian_uint16(f, channels)) - return false; - if(!write_little_endian_uint32(f, samplerate)) - return false; - if(!write_little_endian_uint32(f, samplerate * channels * bytespersample)) - return false; - if(!write_little_endian_uint16(f, channels * bytespersample)) /* block align */ - return false; - if(!write_little_endian_uint16(f, bytespersample * 8)) - return false; - - if(!write_little_endian_uint16(f, 22)) /* cbSize */ - return false; - if(!write_little_endian_uint16(f, bytespersample * 8)) /* validBitsPerSample */ - return false; - if(!write_little_endian_uint32(f, 0)) /* channelMask */ - return false; - /* GUID = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} */ - if(fwrite("\x01\x00\x00\x00\x00\x00\x10\x00\x80\x00\x00\xaa\x00\x38\x9b\x71", 1, 16, f) != 16) - return false; - - if (fwrite("data", 1, 4, f) != 4) - return false; - if (!write_little_endian_uint32(f, datalen)) - return false; - - return true; -} - -static FLAC__bool generate_noisy_sine(void) -{ - FILE *f; - int64_t randstate = 0x1243456; - double sample, last_val = 0.0; - int k; - int seconds = 300; - - if(0 == (f = fopen("noisy-sine.wav", "wb"))) - return false; - - if(!write_simple_wavex_header (f, 44100, 1, 2, 44100*seconds)) - goto foo; - - for (k = 0 ; k < seconds * 44100 ; k++) { - /* Obvioulsy not a crypto quality RNG. */ - randstate = 11117 * randstate + 211231; - randstate = 11117 * randstate + 211231; - randstate = 11117 * randstate + 211231; - - sample = ((int32_t) randstate) / (0x7fffffff * 1.000001); - sample = 0.2 * sample - 0.9 * last_val; - - last_val = sample; - - sample += sin (2.0 * k * M_PI * 1.0 / 32.0); - sample *= 0.4; -#if !defined _MSC_VER - write_little_endian_int16(f, lrintf(sample * 32700.0)); -#else - write_little_endian_int16(f, (FLAC__int16)(sample * 32700.0)); -#endif - }; - - fclose(f); - - return true; -foo: - fclose(f); - return false; -} - -static FLAC__bool generate_wackywav64s(void) -{ - FILE *f; - FLAC__byte wav[] = { - 0x72,0x69,0x66,0x66,0x2E,0x91,0xCF,0x11, /* RIFF GUID */ - 0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00, - 152, 0, 0, 0, 0, 0, 0, 0, - 0x77,0x61,0x76,0x65,0xF3,0xAC,0xD3,0x11, /* WAVE GUID */ - 0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A, - 0x6A,0x75,0x6E,0x6B,0xF3,0xAC,0xD3,0x11, /* junk GUID */ - 0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A, - 32, 0, 0, 0 , 0, 0, 0, 0, - 'b', 'l', 'a', 'h', 'b', 'l', 'a', 'h', - 0x66,0x6D,0x74,0x20,0xF3,0xAC,0xD3,0x11, /* fmt GUID */ - 0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A, - 40, 0, 0, 0 , 0, 0, 0, 0, - 1, 0, 1, 0,0x44,0xAC, 0, 0, - 0x88,0x58,0x01, 0, 2, 0, 16, 0, - 0x64,0x61,0x74,0x61,0xF3,0xAC,0xD3,0x11, /* data GUID */ - 0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A, - 40, 0, 0, 0 , 0, 0, 0, 0, - 0, 0, 1, 0, 4, 0, 9, 0, - 16, 0, 25, 0, 36, 0, 49, 0, - 0x6A,0x75,0x6E,0x6B,0xF3,0xAC,0xD3,0x11, /* junk GUID */ - 0x8C,0xD1,0x00,0xC0,0x4F,0x8E,0xDB,0x8A, - 32, 0, 0, 0 , 0, 0, 0, 0, - 'b', 'l', 'a', 'h', 'b', 'l', 'a', 'h' - }; - - if(0 == (f = fopen("wacky1.w64", "wb"))) - return false; - if(fwrite(wav, 1, wav[16], f) < wav[16]) - goto foo; - fclose(f); - - wav[16] += 32; - if(0 == (f = fopen("wacky2.w64", "wb"))) - return false; - if(fwrite(wav, 1, wav[16], f) < wav[16]) - goto foo; - fclose(f); - - return true; -foo: - fclose(f); - return false; -} - -static FLAC__bool generate_wackyrf64s(void) -{ - FILE *f; - FLAC__byte wav[] = { - 'R', 'F', '6', '4', 255, 255, 255, 255, - 'W', 'A', 'V', 'E', 'd', 's', '6', '4', - 28, 0, 0, 0, 112, 0, 0, 0, - 0, 0, 0, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 8, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 'j', 'u', 'n', 'k', - 4, 0, 0, 0, 'b', 'l', 'a', 'h', - 'p', 'a', 'd', ' ', 4, 0, 0, 0, - 'B', 'L', 'A', 'H', 'f', 'm', 't', ' ', - 16, 0, 0, 0, 1, 0, 1, 0, - 0x44,0xAC, 0, 0,0x88,0x58,0x01, 0, - 2, 0, 16, 0, 'd', 'a', 't', 'a', - 255, 255, 255, 255, 0, 0, 1, 0, - 4, 0, 9, 0, 16, 0, 25, 0, - 36, 0, 49, 0, 'p', 'a', 'd', ' ', - 4, 0, 0, 0, 'b', 'l', 'a', 'h' - }; - - if(0 == (f = fopen("wacky1.rf64", "wb"))) - return false; - if(fwrite(wav, 1, 120, f) < 120) - goto foo; - fclose(f); - - wav[20] += 12; - if(0 == (f = fopen("wacky2.rf64", "wb"))) - return false; - if(fwrite(wav, 1, 132, f) < 132) - goto foo; - fclose(f); - - return true; -foo: - fclose(f); - return false; -} - -static FLAC__bool generate_replaygain_tone (unsigned samplerate) -{ - FILE *f; - char fname [256] ; - double tone, sample, samplerange; - int k; - - flac_snprintf(fname, sizeof(fname), "rpg-tone-%u.wav", samplerate); - - if(0 == (f = fopen(fname, "wb"))) - return false; - - if(!write_simple_wavex_header (f, samplerate, 1, 3, 220500)) - goto foo; - - - samplerange = 0x7fffff; /* Largest sample value allowed for a 24 bit PCM file. */ - tone = 1000.0; /* 1 kHz */ - - for (k = 0 ; k < 5 * 44100 ; k++) { - sample = sin(2 * M_PI * tone * k / samplerate); - sample *= samplerange; - if (!write_little_endian_uint24(f, (FLAC__int32) sample)) - goto foo; - }; - - fclose(f); - - return true; -foo: - fclose(f); - return false; -} - -int main(int argc, char *argv[]) -{ - FLAC__uint32 test = 1; - unsigned channels; - - int pattern01[] = { 1, -1, 0 }; - int pattern02[] = { 1, 1, -1, 0 }; - int pattern03[] = { 1, -1, -1, 0 }; - int pattern04[] = { 1, -1, 1, -1, 0 }; - int pattern05[] = { 1, -1, -1, 1, 0 }; - int pattern06[] = { 1, -1, 1, 1, -1, 0 }; - int pattern07[] = { 1, -1, -1, 1, -1, 0 }; - - (void)argc; - (void)argv; - is_big_endian_host = (*((FLAC__byte*)(&test)))? false : true; - -#if !defined _MSC_VER && !defined __MINGW32__ - { - struct timeval tv; - - if(gettimeofday(&tv, 0) < 0) { - fprintf(stderr, "WARNING: couldn't seed RNG with time\n"); - tv.tv_usec = 4321; - } - srandom(tv.tv_usec); - } -#else - srand((unsigned)time(0)); -#endif - - if(!generate_01()) return 1; - if(!generate_02()) return 1; - if(!generate_03()) return 1; - if(!generate_04()) return 1; - - if(!generate_fsd8("fsd8-01.raw", pattern01, 100)) return 1; - if(!generate_fsd8("fsd8-02.raw", pattern02, 100)) return 1; - if(!generate_fsd8("fsd8-03.raw", pattern03, 100)) return 1; - if(!generate_fsd8("fsd8-04.raw", pattern04, 100)) return 1; - if(!generate_fsd8("fsd8-05.raw", pattern05, 100)) return 1; - if(!generate_fsd8("fsd8-06.raw", pattern06, 100)) return 1; - if(!generate_fsd8("fsd8-07.raw", pattern07, 100)) return 1; - - if(!generate_fsd16("fsd16-01.raw", pattern01, 100)) return 1; - if(!generate_fsd16("fsd16-02.raw", pattern02, 100)) return 1; - if(!generate_fsd16("fsd16-03.raw", pattern03, 100)) return 1; - if(!generate_fsd16("fsd16-04.raw", pattern04, 100)) return 1; - if(!generate_fsd16("fsd16-05.raw", pattern05, 100)) return 1; - if(!generate_fsd16("fsd16-06.raw", pattern06, 100)) return 1; - if(!generate_fsd16("fsd16-07.raw", pattern07, 100)) return 1; - - if(!generate_fsd24("fsd24-01.raw", pattern01, 100)) return 1; - if(!generate_fsd24("fsd24-02.raw", pattern02, 100)) return 1; - if(!generate_fsd24("fsd24-03.raw", pattern03, 100)) return 1; - if(!generate_fsd24("fsd24-04.raw", pattern04, 100)) return 1; - if(!generate_fsd24("fsd24-05.raw", pattern05, 100)) return 1; - if(!generate_fsd24("fsd24-06.raw", pattern06, 100)) return 1; - if(!generate_fsd24("fsd24-07.raw", pattern07, 100)) return 1; - - if(!generate_fsd32("fsd32-01.raw", pattern01, 100)) return 1; - if(!generate_fsd32("fsd32-02.raw", pattern02, 100)) return 1; - if(!generate_fsd32("fsd32-03.raw", pattern03, 100)) return 1; - if(!generate_fsd32("fsd32-04.raw", pattern04, 100)) return 1; - if(!generate_fsd32("fsd32-05.raw", pattern05, 100)) return 1; - if(!generate_fsd32("fsd32-06.raw", pattern06, 100)) return 1; - if(!generate_fsd32("fsd32-07.raw", pattern07, 100)) return 1; - - if(!generate_wbps16("wbps16-01.raw", 1000)) return 1; - - if(!generate_sine8_1("sine8-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1; - if(!generate_sine8_1("sine8-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1; - if(!generate_sine8_1("sine8-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1; - if(!generate_sine8_1("sine8-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1; - if(!generate_sine8_1("sine8-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1; - - if(!generate_sine8_2("sine8-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1; - if(!generate_sine8_2("sine8-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1; - if(!generate_sine8_2("sine8-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1; - if(!generate_sine8_2("sine8-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1; - if(!generate_sine8_2("sine8-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1; - if(!generate_sine8_2("sine8-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1; - if(!generate_sine8_2("sine8-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1; - if(!generate_sine8_2("sine8-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1; - if(!generate_sine8_2("sine8-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1; - if(!generate_sine8_2("sine8-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1; - - if(!generate_sine16_1("sine16-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1; - if(!generate_sine16_1("sine16-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1; - if(!generate_sine16_1("sine16-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1; - if(!generate_sine16_1("sine16-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1; - if(!generate_sine16_1("sine16-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1; - - if(!generate_sine16_2("sine16-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1; - if(!generate_sine16_2("sine16-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1; - if(!generate_sine16_2("sine16-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1; - if(!generate_sine16_2("sine16-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1; - if(!generate_sine16_2("sine16-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1; - if(!generate_sine16_2("sine16-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1; - if(!generate_sine16_2("sine16-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1; - if(!generate_sine16_2("sine16-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1; - if(!generate_sine16_2("sine16-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1; - if(!generate_sine16_2("sine16-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1; - - if(!generate_sine24_1("sine24-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1; - if(!generate_sine24_1("sine24-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1; - if(!generate_sine24_1("sine24-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1; - if(!generate_sine24_1("sine24-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1; - if(!generate_sine24_1("sine24-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1; - - if(!generate_sine24_2("sine24-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1; - if(!generate_sine24_2("sine24-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1; - if(!generate_sine24_2("sine24-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1; - if(!generate_sine24_2("sine24-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1; - if(!generate_sine24_2("sine24-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1; - if(!generate_sine24_2("sine24-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1; - if(!generate_sine24_2("sine24-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1; - if(!generate_sine24_2("sine24-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1; - if(!generate_sine24_2("sine24-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1; - if(!generate_sine24_2("sine24-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1; - - if(!generate_sine32_1("sine32-00.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49)) return 1; - if(!generate_sine32_1("sine32-01.raw", 96000.0, 200000, 441.0, 0.61, 661.5, 0.37)) return 1; - if(!generate_sine32_1("sine32-02.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49)) return 1; - if(!generate_sine32_1("sine32-03.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49)) return 1; - if(!generate_sine32_1("sine32-04.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29)) return 1; - - if(!generate_sine32_2("sine32-10.raw", 48000.0, 200000, 441.0, 0.50, 441.0, 0.49, 1.0)) return 1; - if(!generate_sine32_2("sine32-11.raw", 48000.0, 200000, 441.0, 0.61, 661.5, 0.37, 1.0)) return 1; - if(!generate_sine32_2("sine32-12.raw", 96000.0, 200000, 441.0, 0.50, 882.0, 0.49, 1.0)) return 1; - if(!generate_sine32_2("sine32-13.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.0)) return 1; - if(!generate_sine32_2("sine32-14.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 1.0)) return 1; - if(!generate_sine32_2("sine32-15.raw", 44100.0, 200000, 441.0, 0.50, 441.0, 0.49, 0.5)) return 1; - if(!generate_sine32_2("sine32-16.raw", 44100.0, 200000, 441.0, 0.61, 661.5, 0.37, 2.0)) return 1; - if(!generate_sine32_2("sine32-17.raw", 44100.0, 200000, 441.0, 0.50, 882.0, 0.49, 0.7)) return 1; - if(!generate_sine32_2("sine32-18.raw", 44100.0, 200000, 441.0, 0.50, 4410.0, 0.49, 1.3)) return 1; - if(!generate_sine32_2("sine32-19.raw", 44100.0, 200000, 8820.0, 0.70, 4410.0, 0.29, 0.1)) return 1; - - if(!generate_replaygain_tone(8000)) return 1; - if(!generate_replaygain_tone(11025)) return 1; - if(!generate_replaygain_tone(12000)) return 1; - if(!generate_replaygain_tone(16000)) return 1; - if(!generate_replaygain_tone(18900)) return 1; - if(!generate_replaygain_tone(22050)) return 1; - if(!generate_replaygain_tone(24000)) return 1; - if(!generate_replaygain_tone(28000)) return 1; - if(!generate_replaygain_tone(32000)) return 1; - if(!generate_replaygain_tone(36000)) return 1; - if(!generate_replaygain_tone(37800)) return 1; - if(!generate_replaygain_tone(44100)) return 1; - if(!generate_replaygain_tone(48000)) return 1; - if(!generate_replaygain_tone(96000)) return 1; - if(!generate_replaygain_tone(192000)) return 1; - - /* WATCHOUT: the size of noise.raw is hardcoded into test/test_flac.sh */ - if(!generate_noise("noise.raw", 65536 * 8 * 3)) return 1; - if(!generate_noise("noise8m32.raw", 32)) return 1; - if(!generate_wackywavs()) return 1; - if(!generate_wackywav64s()) return 1; - if(!generate_wackyrf64s()) return 1; - if(!generate_noisy_sine()) return 1; - for(channels = 1; channels <= 8; channels *= 2) { - unsigned bits_per_sample; - for(bits_per_sample = 8; bits_per_sample <= 24; bits_per_sample += 4) { - static const unsigned nsamples[] = { 1, 111, 4777 } ; - unsigned samples; - for(samples = 0; samples < sizeof(nsamples)/sizeof(nsamples[0]); samples++) { - char fn[64]; - - flac_snprintf(fn, sizeof (fn), "rt-%u-%u-%u.aiff", channels, bits_per_sample, nsamples[samples]); - if(!generate_aiff(fn, 44100, channels, bits_per_sample, nsamples[samples])) - return 1; - - flac_snprintf(fn, sizeof (fn), "rt-%u-%u-%u.wav", channels, bits_per_sample, nsamples[samples]); - if(!generate_wav(fn, 44100, channels, bits_per_sample, nsamples[samples], /*strict=*/true, /*flavor=*/0)) - return 1; - - flac_snprintf(fn, sizeof (fn), "rt-%u-%u-%u.rf64", channels, bits_per_sample, nsamples[samples]); - if(!generate_wav(fn, 44100, channels, bits_per_sample, nsamples[samples], /*strict=*/true, /*flavor=*/1)) - return 1; - - flac_snprintf(fn, sizeof (fn), "rt-%u-%u-%u.w64", channels, bits_per_sample, nsamples[samples]); - if(!generate_wav(fn, 44100, channels, bits_per_sample, nsamples[samples], /*strict=*/true, /*flavor=*/2)) - return 1; - - if(bits_per_sample % 8 == 0) { - flac_snprintf(fn, sizeof (fn), "rt-%u-%u-signed-%u.raw", channels, bits_per_sample, nsamples[samples]); - if(!generate_signed_raw(fn, channels, bits_per_sample/8, nsamples[samples])) - return 1; - flac_snprintf(fn, sizeof (fn), "rt-%u-%u-unsigned-%u.raw", channels, bits_per_sample, nsamples[samples]); - if(!generate_unsigned_raw(fn, channels, bits_per_sample/8, nsamples[samples])) - return 1; - } - } - } - } - - return 0; -} diff --git a/Engine/lib/flac/src/utils/Makefile.am b/Engine/lib/flac/src/utils/Makefile.am deleted file mode 100644 index 5207b13c8..000000000 --- a/Engine/lib/flac/src/utils/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -SUBDIRS = flacdiff flactimer diff --git a/Engine/lib/flac/src/utils/flacdiff/CMakeLists.txt b/Engine/lib/flac/src/utils/flacdiff/CMakeLists.txt deleted file mode 100644 index ec9f771cb..000000000 --- a/Engine/lib/flac/src/utils/flacdiff/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_executable(flacdiff - main.cpp - $<$:../../../include/share/win_utf8_io.h> - $<$:../../share/win_utf8_io/win_utf8_io.c>) -target_link_libraries(flacdiff FLAC++) diff --git a/Engine/lib/flac/src/utils/flacdiff/Makefile.am b/Engine/lib/flac/src/utils/flacdiff/Makefile.am deleted file mode 100644 index b181d9807..000000000 --- a/Engine/lib/flac/src/utils/flacdiff/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -# flacdiff - Displays where two FLAC streams differ -# Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt \ - main.cpp diff --git a/Engine/lib/flac/src/utils/flacdiff/main.cpp b/Engine/lib/flac/src/utils/flacdiff/main.cpp deleted file mode 100644 index 358fe047e..000000000 --- a/Engine/lib/flac/src/utils/flacdiff/main.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* flacdiff - Displays where two FLAC streams differ - * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include "FLAC++/decoder.h" -#include "share/compat.h" - -#ifdef _MSC_VER -// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) -#pragma warning ( disable : 4800 ) -#endif - -class AutoFILE { -protected: - ::FILE *f_; -public: - inline AutoFILE(const char *path, const char *mode): f_(::fopen(path, mode)) { } - inline virtual ~AutoFILE() { if (f_) (void)::fclose(f_); } - - inline operator bool() const { return 0 != f_; } - inline operator const ::FILE *() const { return f_; } - inline operator ::FILE *() { return f_; } -private: - AutoFILE(); - AutoFILE(const AutoFILE &); - void operator=(const AutoFILE &); -}; - -class Decoder: public FLAC::Decoder::Stream { -public: - Decoder(AutoFILE &f, FLAC__off_t tgt): tgtpos_((FLAC__uint64)tgt), curpos_(0), go_(true), err_(false), frame_(), f_(f) { memset(&frame_, 0, sizeof(::FLAC__Frame)); } - FLAC__uint64 tgtpos_, curpos_; - bool go_, err_; - ::FLAC__Frame frame_; -protected: - AutoFILE &f_; - // from FLAC::Decoder::Stream - virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) - { - *bytes = fread(buffer, 1, *bytes, f_); - if(ferror((FILE*)f_)) - return ::FLAC__STREAM_DECODER_READ_STATUS_ABORT; - else if(*bytes == 0 && feof((FILE*)f_)) - return ::FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - else - return ::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - - virtual ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) - { - FLAC__off_t off = ftello(f_); - if(off < 0) - return ::FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - *absolute_byte_offset = off; - return ::FLAC__STREAM_DECODER_TELL_STATUS_OK; - } - - virtual bool eof_callback() - { - return (bool)feof((FILE*)f_); - } - - virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const /*buffer*/[]) - { - FLAC__uint64 pos; - if(!get_decode_position(&pos)) { - go_ = false; - err_ = true; - return ::FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - if(pos > tgtpos_) { - go_ = false; - frame_ = *frame; - } - else - curpos_ = pos; - return ::FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; - } - - virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) - { - fprintf(stderr, "got error %d:%s\n", status, ::FLAC__StreamDecoderErrorStatusString[status]); - go_ = false; - err_ = true; - } -}; - -static bool show_diff(AutoFILE &f1, AutoFILE &f2, FLAC__off_t off) -{ - Decoder d1(f1, off), d2(f2, off); - if(!d1) { - fprintf(stderr, "ERROR: setting up decoder1, state=%s\n", d1.get_state().resolved_as_cstring(d1)); - return false; - } - if(!d2) { - fprintf(stderr, "ERROR: setting up decoder2, state=%s\n", d2.get_state().resolved_as_cstring(d2)); - return false; - } - ::FLAC__StreamDecoderInitStatus is; - if((is = d1.init()) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - fprintf(stderr, "ERROR: initializing decoder1, status=%s state=%s\n", FLAC__StreamDecoderInitStatusString[is], d1.get_state().resolved_as_cstring(d1)); - return false; - } - if((is = d2.init()) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - fprintf(stderr, "ERROR: initializing decoder2, status=%s state=%s\n", FLAC__StreamDecoderInitStatusString[is], d2.get_state().resolved_as_cstring(d2)); - return false; - } - if(!d1.process_until_end_of_metadata()) { - fprintf(stderr, "ERROR: skipping metadata in decoder1, state=%s\n", d1.get_state().resolved_as_cstring(d1)); - return false; - } - if(!d2.process_until_end_of_metadata()) { - fprintf(stderr, "ERROR: skipping metadata in decoder2, state=%s\n", d2.get_state().resolved_as_cstring(d2)); - return false; - } - while(d1.go_ && d2.go_) { - if(!d1.process_single()) { - fprintf(stderr, "ERROR: decoding frame in decoder1, state=%s\n", d1.get_state().resolved_as_cstring(d1)); - return false; - } - if(!d2.process_single()) { - fprintf(stderr, "ERROR: decoding frame in decoder2, state=%s\n", d2.get_state().resolved_as_cstring(d2)); - return false; - } - } - if(d1.err_) { - fprintf(stderr, "ERROR: got err_ in decoder1, state=%s\n", d1.get_state().resolved_as_cstring(d1)); - return false; - } - if(d2.err_) { - fprintf(stderr, "ERROR: got err_ in decoder2, state=%s\n", d2.get_state().resolved_as_cstring(d2)); - return false; - } - if(d1.go_ != d2.go_) { - fprintf(stderr, "ERROR: d1.go_(%s) != d2.go_(%s)\n", d1.go_?"true":"false", d2.go_?"true":"false"); - return false; - } - fprintf(stdout, "pos1 = %" PRIu64 " blocksize=%u sample#%" PRIu64 " frame#%" PRIu64 "\n", d1.curpos_, d1.frame_.header.blocksize, d1.frame_.header.number.sample_number, d1.frame_.header.number.sample_number / d1.frame_.header.blocksize); - fprintf(stdout, "pos2 = %" PRIu64 " blocksize=%u sample#%" PRIu64 " frame#%" PRIu64 "\n", d2.curpos_, d2.frame_.header.blocksize, d2.frame_.header.number.sample_number, d2.frame_.header.number.sample_number / d2.frame_.header.blocksize); - - return true; -} - -static FLAC__off_t get_diff_offset(AutoFILE &f1, AutoFILE &f2) -{ - FLAC__off_t off = 0; - while(1) { - if(feof((FILE*)f1) && feof((FILE*)f2)) { - fprintf(stderr, "ERROR: files are identical\n"); - return -1; - } - if(feof((FILE*)f1)) { - fprintf(stderr, "ERROR: file1 EOF\n"); - return -1; - } - if(feof((FILE*)f2)) { - fprintf(stderr, "ERROR: file2 EOF\n"); - return -1; - } - if(fgetc(f1) != fgetc(f2)) - return off; - off++; - } -} - -static bool run(const char *fn1, const char *fn2) -{ - FLAC__off_t off; - AutoFILE f1(fn1, "rb"), f2(fn2, "rb"); - - if(!f1) { - flac_fprintf(stderr, "ERROR: opening %s for reading\n", fn1); - return false; - } - if(!f2) { - flac_fprintf(stderr, "ERROR: opening %s for reading\n", fn2); - return false; - } - - if((off = get_diff_offset(f1, f2)) < 0) - return false; - - fprintf(stdout, "got diff offset = %" PRId64 "\n", off); - - return show_diff(f1, f2, off); -} - -int main(int argc, char *argv[]) -{ - const char *usage = "usage: flacdiff flacfile1 flacfile2\n"; - -#ifdef _WIN32 - if (get_utf8_argv(&argc, &argv) != 0) { - fprintf(stderr, "ERROR: failed to convert command line parameters to UTF-8\n"); - return 1; - } -#endif - - if(argc > 1 && 0 == strcmp(argv[1], "-h")) { - printf("%s", usage); - return 0; - } - else if(argc != 3) { - fprintf(stderr, "%s", usage); - return 255; - } - - return run(argv[1], argv[2])? 0 : 1; -} diff --git a/Engine/lib/flac/src/utils/flactimer/CMakeLists.txt b/Engine/lib/flac/src/utils/flactimer/CMakeLists.txt deleted file mode 100644 index 47bf1e5ff..000000000 --- a/Engine/lib/flac/src/utils/flactimer/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(flactimer main.cpp) -target_link_libraries(flactimer FLAC++) diff --git a/Engine/lib/flac/src/utils/flactimer/Makefile.am b/Engine/lib/flac/src/utils/flactimer/Makefile.am deleted file mode 100644 index 073786307..000000000 --- a/Engine/lib/flac/src/utils/flactimer/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -# flactimer - Runs a command and prints timing information -# Copyright (C) 2007-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -EXTRA_DIST = \ - CMakeLists.txt \ - main.cpp diff --git a/Engine/lib/flac/src/utils/flactimer/main.cpp b/Engine/lib/flac/src/utils/flactimer/main.cpp deleted file mode 100644 index 120a37ff3..000000000 --- a/Engine/lib/flac/src/utils/flactimer/main.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* flactimer - Runs a command and prints timing information - * Copyright (C) 2007-2009 Josh Coalson - * Copyright (C) 2011-2023 Xiph.Org Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include "share/compat.h" -#include "share/safe_str.h" - -static inline uint64_t time2nsec(const FILETIME &t) -{ - uint64_t n = t.dwHighDateTime; - n <<= 32; - n |= (uint64_t)t.dwLowDateTime; - return n * 100; -} - -static void printtime(FILE *fout, uint64_t nsec, uint64_t total) -{ - uint32_t pct = (uint32_t)(100.0 * ((double)nsec / (double)total)); - uint64_t msec = nsec / 1000000; nsec -= msec * 1000000; - uint64_t sec = msec / 1000; msec -= sec * 1000; - uint64_t min = sec / 60; sec -= min * 60; - uint64_t hour = min / 60; min -= hour * 60; - fprintf(fout, " %5u.%03u = %02u:%02u:%02u.%03u = %3u%%\n", - (uint32_t)((hour*60+min)*60+sec), - (uint32_t)msec, - (uint32_t)hour, - (uint32_t)min, - (uint32_t)sec, - (uint32_t)msec, - pct - ); -} - -int main(int argc, char *argv[]) -{ - const char *usage = "usage: flactimer [-1 | -2 | -o outputfile] command\n"; - FILE *fout = stderr; - - if(argc == 1 || (argc > 1 && 0 == strcmp(argv[1], "-h"))) { - fprintf(stderr, usage); - return 0; - } - argv++; - argc--; - if(0 == strcmp(argv[0], "-1") || 0 == strcmp(argv[0], "/1")) { - fout = stdout; - argv++; - argc--; - } - else if(0 == strcmp(argv[0], "-2") || 0 == strcmp(argv[0], "/2")) { - fout = stdout; - argv++; - argc--; - } - else if(0 == strcmp(argv[0], "-o")) { - if(argc < 2) { - fprintf(stderr, usage); - return 1; - } - fout = fopen(argv[1], "w"); - if(!fout) { - fprintf(stderr, "ERROR opening file %s for writing\n", argv[1]); - return 1; - } - argv += 2; - argc -= 2; - } - if(argc <= 0) { - fprintf(fout, "ERROR, no command!\n\n"); - fprintf(fout, usage); - fclose(fout); - return 1; - } - - // improvement: double-quote all args - int i, n = 0; - for(i = 0; i < argc; i++) { - if(i > 0) - n++; - n += strlen(argv[i]); - } - char *args = (char*)malloc(n+1); - if(!args) { - fprintf(fout, "ERROR, no memory\n"); - fclose(fout); - return 1; - } - args[0] = '\0'; - for(i = 0; i < argc; i++) { - if(i > 0) - safe_strncat(args, " ", sizeof(args)); - safe_strncat(args, argv[i], sizeof(args)); - } - - //fprintf(stderr, "@@@ cmd=[%s] args=[%s]\n", argv[0], args); - - STARTUPINFOA si; - GetStartupInfoA(&si); - - DWORD wallclock_msec = GetTickCount(); - - PROCESS_INFORMATION pi; - BOOL ok = CreateProcessA( - argv[0], // lpApplicationName - args, // lpCommandLine - NULL, // lpProcessAttributes - NULL, // lpThreadAttributes - FALSE, // bInheritHandles - 0, // dwCreationFlags - NULL, // lpEnvironment - NULL, // lpCurrentDirectory - &si, // lpStartupInfo (inherit from this proc?) - &pi // lpProcessInformation - ); - - if(!ok) { - fprintf(fout, "ERROR running command\n"); - free(args); //@@@ ok to free here or have to wait to wait till process is reaped? - fclose(fout); - return 1; - } - - //fprintf(stderr, "@@@ waiting...\n"); - WaitForSingleObject(pi.hProcess, INFINITE); - //fprintf(stderr, "@@@ done\n"); - - wallclock_msec = GetTickCount() - wallclock_msec; - - FILETIME creation_time; - FILETIME exit_time; - FILETIME kernel_time; - FILETIME user_time; - if(!GetProcessTimes(pi.hProcess, &creation_time, &exit_time, &kernel_time, &user_time)) { - fprintf(fout, "ERROR getting time info\n"); - free(args); //@@@ ok to free here or have to wait to wait till process is reaped? - fclose(fout); - return 1; - } - uint64_t kernel_nsec = time2nsec(kernel_time); - uint64_t user_nsec = time2nsec(user_time); - - fprintf(fout, "Kernel Time = "); printtime(fout, kernel_nsec, (uint64_t)wallclock_msec * 1000000); - fprintf(fout, "User Time = "); printtime(fout, user_nsec, (uint64_t)wallclock_msec * 1000000); - fprintf(fout, "Process Time = "); printtime(fout, kernel_nsec+user_nsec, (uint64_t)wallclock_msec * 1000000); - fprintf(fout, "Global Time = "); printtime(fout, (uint64_t)wallclock_msec * 1000000, (uint64_t)wallclock_msec * 1000000); - - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - - free(args); //@@@ always causes crash, maybe CreateProcess takes ownership? - fclose(fout); - return 0; -} diff --git a/Engine/lib/flac/src/utils/loudness/loudness.sci b/Engine/lib/flac/src/utils/loudness/loudness.sci deleted file mode 100644 index a476a1701..000000000 --- a/Engine/lib/flac/src/utils/loudness/loudness.sci +++ /dev/null @@ -1,115 +0,0 @@ -// Equal Loudness Filter -// -// Adapted from original MATLAB code written by David Robinson -// -// http://replaygain.hydrogenaudio.org/proposal/equal_loudness.html -// http://replaygain.hydrogenaudio.org/proposal/mfiles/equalloudfilt.m - -// ***************************************************************************** -// Print Filter Coefficients -// -// This function takes a vector of filter tap settings, and prints -// each tap setting from least significant to most significant. - -function c=printcoeff(p) - - c=coeff(p); - c=c($:-1:1); - - for ix = 1:1:length(c) - if ix > 1 - printf(" ") - end - printf("%.14f", c(ix)); - end - -endfunction - -// ***************************************************************************** -// Equal Loudness Filter -// -// This function is adapted from David Robison's original MATLAB code. -// Apart from changes to port it to scilab, the other change is to -// use a single specification of the frequency points in the 80dB Equal -// Loudness curve. -// -// The original code had different curves for different sampling -// frequencies. This code dynamically computes the current data -// points to use as determined by the Nyquist frequency. - -function [a1,b1,a2,b2]=equalloudfilt(fs); -// Design a filter to match equal loudness curves -// 9/7/2001 - -[%nargout,%nargin]=argn(0); - -// If the user hasn't specified a sampling frequency, use the CD default -if %nargin<1 then - fs=44100; -end - -// Specify the 80 dB Equal Loudness curve -EL80=[0,120;20,113;30,103;40,97;50,93;60,91;70,89;80,87;90,86; .. - .. - 100,85;200,78;300,76;400,76;500,76;600,76;700,77;800,78;900,79.5; .. - .. - 1000,80;1500,79;2000,77;2500,74;3000,71.5;3700,70;4000,70.5; .. - 5000,74;6000,79;7000,84;8000,86;9000,86; .. - .. - 10000,85;12000,95;15000,110;20000,125;24000,140]; - -for ex = 1:1:length(EL80(:,1)) - if EL80(ex,1) > fs/2 - EL80 = [ EL80(1:ex-1,:); fs/2, EL80(ex-1,2) ]; - break - elseif EL80(ex,1) == fs/2 - EL80 = EL80(1:ex,:); - break - end - if ex == length(EL80(:,1)) - EL80 = [ EL80(1:$, :); fs/2, EL80($,2) ]; - end -end - -// convert frequency and amplitude of the equal loudness curve into format suitable for yulewalk -f=EL80(:,1)./(fs/2); -m=10.^((70-EL80(:,2))/20); - -// Use a MATLAB utility to design a best bit IIR filter -[b1,a1]=yulewalk(10,f,m); - -// Add a 2nd order high pass filter at 150Hz to finish the job -hz=iir(2,'hp','butt',[150/fs,0],[1e-3 1e-3]); -b2=numer(hz); // b2=b2($:-1:1); -a2=denom(hz); // a2=a2($:-1:1); - -endfunction - -// ***************************************************************************** -// Generate Filter Taps -// -// Generate the filter taps for each of the desired frequencies. - -format('v', 16); - -freqs = [ 8000 11025 12000 16000 18900 22050 24000 .. - 28000 32000 36000 37800 44100 48000 ]; - -for fx = 1:1:length(freqs) - - printf("\n%d\n", freqs(fx)); - - [a1,b1,a2,b2] = equalloudfilt(freqs(fx)); - - printf("{ "); bb=printcoeff(b1); printf(" }\n"); - printf("{ "); aa=printcoeff(a1); printf(" }\n"); - - printf("{ "); printcoeff(b2); printf(" }\n"); - printf("{ "); printcoeff(a2); printf(" }\n"); - -// freqz_fwd(bb,aa,1024,freqs(fx)); - -end - - -quit diff --git a/Engine/lib/flac/test/CMakeLists.txt b/Engine/lib/flac/test/CMakeLists.txt deleted file mode 100644 index 1699e1731..000000000 --- a/Engine/lib/flac/test/CMakeLists.txt +++ /dev/null @@ -1,103 +0,0 @@ -if(WIN32) - set(EXEEXT .exe) -endif() - -if(NOT UNIX) - find_program(BUSYBOX_EXE busybox) - if(NOT BUSYBOX_EXE) - message(STATUS "Could NOT find busybox, only basic tests are enabled") - add_test(NAME libFLAC - COMMAND $ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) - if(BUILD_CXXLIBS) - add_test(NAME libFLAC++ - COMMAND $ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) - endif() - if(BUILD_PROGRAMS) - add_test(NAME flac_help - COMMAND $ --help - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) - add_test(NAME flac_utf8_test COMMAND $ -t - "${CMAKE_CURRENT_SOURCE_DIR}/flac-to-flac-metadata-test-files/שלום.flac" - "${CMAKE_CURRENT_SOURCE_DIR}/flac-to-flac-metadata-test-files/Prøve.flac" - "${CMAKE_CURRENT_SOURCE_DIR}/flac-to-flac-metadata-test-files/🤔.flac") - add_test(NAME metaflac_help - COMMAND $ --help - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) - endif() - return() - else() - set(BUSYBOX_CMD "sh") - endif() -endif() - -set(top_srcdir "${PROJECT_SOURCE_DIR}") -set(top_builddir "${PROJECT_BINARY_DIR}") -if(NOT GIT_COMMIT_TAG AND GIT_COMMIT_HASH AND GIT_COMMIT_DATE) - set(GIT_COMMIT_VERSION_HASH yes) -endif() - -configure_file(common.sh.in common.sh @ONLY) - -set(ALL_TESTS libFLAC grabbag) - -add_test(NAME libFLAC - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_libFLAC.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") -if(BUILD_CXXLIBS) - add_test(NAME libFLAC++ - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_libFLAC++.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - list(APPEND ALL_TESTS libFLAC++) - set_tests_properties(libFLAC++ PROPERTIES DEPENDS libFLAC) -endif() -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/cuesheets") -add_test(NAME grabbag - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_grabbag.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") -if(BUILD_PROGRAMS) - add_test(NAME generate_streams - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/generate_streams.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - add_test(NAME flac - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_flac.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - # UTF-8 must be tested separately on Windows because busybox-w32 doesn't support UTF-8 - if(BUSYBOX_EXE) - add_test(NAME flac_utf8_test COMMAND $ -t - "${CMAKE_CURRENT_SOURCE_DIR}/flac-to-flac-metadata-test-files/שלום.flac" - "${CMAKE_CURRENT_SOURCE_DIR}/flac-to-flac-metadata-test-files/Prøve.flac" - "${CMAKE_CURRENT_SOURCE_DIR}/flac-to-flac-metadata-test-files/🤔.flac") - list(APPEND ALL_TESTS flac_utf8_test) - endif() - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/metaflac-test-files") - add_test(NAME metaflac - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_metaflac.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - add_test(NAME replaygain - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_replaygain.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - add_test(NAME seeking - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_seeking.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - add_test(NAME streams - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_streams.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - # increase this if standard 1500 seconds are not enough - # set_tests_properties(streams PROPERTIES TIMEOUT 1500) - add_test(NAME compression - COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_compression.sh" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - set_tests_properties(flac metaflac replaygain seeking streams compression PROPERTIES DEPENDS generate_streams) - list(APPEND ALL_TESTS generate_streams flac metaflac replaygain seeking streams compression) -endif() - - -set_property(TEST ${ALL_TESTS} APPEND PROPERTY ENVIRONMENT FLAC__TEST_LEVEL=1) -if(BUSYBOX_EXE) - set_property(TEST ${ALL_TESTS} APPEND PROPERTY ENVIRONMENT ECHO_N=-n) - set_property(TEST ${ALL_TESTS} APPEND PROPERTY ENVIRONMENT WIN32BUSYBOX=yes) -else() - set_property(TEST ${ALL_TESTS} APPEND PROPERTY ENVIRONMENT ECHO_C=\\c) -endif() diff --git a/Engine/lib/flac/test/Makefile.am b/Engine/lib/flac/test/Makefile.am deleted file mode 100644 index 2d69fea62..000000000 --- a/Engine/lib/flac/test/Makefile.am +++ /dev/null @@ -1,62 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -TESTS_ENVIRONMENT = FLAC__TEST_LEVEL=@FLAC__TEST_LEVEL@ FLAC__TEST_WITH_VALGRIND=@FLAC__TEST_WITH_VALGRIND@ ECHO_N="@ECHO_N@" ECHO_C="@ECHO_C@" - -SUBDIRS = cuesheets foreign-metadata-test-files flac-to-flac-metadata-test-files metaflac-test-files pictures - -check_SCRIPTS = \ - test_libFLAC.sh \ - test_libFLAC++.sh \ - test_grabbag.sh \ - test_flac.sh \ - test_metaflac.sh \ - test_replaygain.sh \ - test_seeking.sh \ - test_streams.sh \ - test_compression.sh - -# This one should pass when building out-of-tree (e.g. 'make distcheck'). -check: $(check_SCRIPTS) - $(TESTS_ENVIRONMENT) $(srcdir)/test_libFLAC.sh -if FLaC__WITH_CPPLIBS - $(TESTS_ENVIRONMENT) $(srcdir)/test_libFLAC++.sh -endif - $(TESTS_ENVIRONMENT) $(srcdir)/test_grabbag.sh - $(TESTS_ENVIRONMENT) $(srcdir)/test_flac.sh - $(TESTS_ENVIRONMENT) $(srcdir)/test_metaflac.sh - $(TESTS_ENVIRONMENT) $(srcdir)/test_replaygain.sh - $(TESTS_ENVIRONMENT) $(srcdir)/test_seeking.sh - $(TESTS_ENVIRONMENT) $(srcdir)/test_streams.sh - $(TESTS_ENVIRONMENT) $(srcdir)/test_compression.sh - @echo "----------------" - @echo "All tests passed" - @echo "----------------" - -EXTRA_DIST = \ - CMakeLists.txt \ - cuesheet.ok \ - generate_streams.sh \ - metaflac.flac.in \ - metaflac.flac.ok \ - picture.ok \ - $(check_SCRIPTS) \ - write_iff.pl - -clean-local: - -rm -f *.raw *.flac *.oga *.ogg *.cmp *.aiff *.wav *.w64 *.rf64 *.diff *.log *.cue core diff --git a/Engine/lib/flac/test/abi/abi-descriptor-libFLAC++-1.4.3.xml b/Engine/lib/flac/test/abi/abi-descriptor-libFLAC++-1.4.3.xml deleted file mode 100644 index 18d6ccdda..000000000 --- a/Engine/lib/flac/test/abi/abi-descriptor-libFLAC++-1.4.3.xml +++ /dev/null @@ -1,11 +0,0 @@ - - 1.4.3 - - - - include/FLAC++/all.h - - - - src/libFLAC++/.libs/libFLAC++.so.10.0.1 - diff --git a/Engine/lib/flac/test/abi/abi-descriptor-libFLAC-1.4.3.xml b/Engine/lib/flac/test/abi/abi-descriptor-libFLAC-1.4.3.xml deleted file mode 100644 index 1b083862e..000000000 --- a/Engine/lib/flac/test/abi/abi-descriptor-libFLAC-1.4.3.xml +++ /dev/null @@ -1,11 +0,0 @@ - - 1.4.3 - - - - include/FLAC/all.h - - - - src/libFLAC/.libs/libFLAC.so.12.1.0 - diff --git a/Engine/lib/flac/test/abi/abi-libFLAC++-1.4.0.dump.xz b/Engine/lib/flac/test/abi/abi-libFLAC++-1.4.0.dump.xz deleted file mode 100644 index f8457fa3a..000000000 Binary files a/Engine/lib/flac/test/abi/abi-libFLAC++-1.4.0.dump.xz and /dev/null differ diff --git a/Engine/lib/flac/test/abi/abi-libFLAC-1.4.0.dump.xz b/Engine/lib/flac/test/abi/abi-libFLAC-1.4.0.dump.xz deleted file mode 100644 index 655c1f758..000000000 Binary files a/Engine/lib/flac/test/abi/abi-libFLAC-1.4.0.dump.xz and /dev/null differ diff --git a/Engine/lib/flac/test/common.sh.in b/Engine/lib/flac/test/common.sh.in deleted file mode 100644 index b958f30e7..000000000 --- a/Engine/lib/flac/test/common.sh.in +++ /dev/null @@ -1,87 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -export MALLOC_CHECK_=3 -export MALLOC_PERTURB_=$((RANDOM % 255 + 1)) - -if [ -z "$1" ] ; then - BUILD=debug -else - BUILD="$1" -fi - -LD_LIBRARY_PATH=../objs/$BUILD/lib:$LD_LIBRARY_PATH -LD_LIBRARY_PATH="$(pwd)/../objs/$BUILD/lib:$LD_LIBRARY_PATH" -LD_LIBRARY_PATH="$(pwd)/../src/libFLAC/.libs:$LD_LIBRARY_PATH" -LD_LIBRARY_PATH="$(pwd)/../src/share/getopt/.libs:$LD_LIBRARY_PATH" -LD_LIBRARY_PATH="$(pwd)/../src/share/grabbag/.libs:$LD_LIBRARY_PATH" -LD_LIBRARY_PATH="$(pwd)/../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH" -LD_LIBRARY_PATH="$(pwd)/../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH" -LD_LIBRARY_PATH="$(pwd)/../src/share/utf8/.libs:$LD_LIBRARY_PATH" -LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH -LD_LIBRARY_PATH=../src/libFLAC++/.libs:$LD_LIBRARY_PATH -LD_LIBRARY_PATH=../src/share/getopt/.libs:$LD_LIBRARY_PATH -LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH -LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH -LD_LIBRARY_PATH=../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH -LD_LIBRARY_PATH=../src/share/utf8/.libs:$LD_LIBRARY_PATH - -export LD_LIBRARY_PATH - -PATH="$(pwd)/../objs/$CMAKE_CONFIG_TYPE:$PATH" -PATH="$(pwd)/../objs:$PATH" - -EXE=@EXEEXT@ - -# Needed for building out-of-tree where source files are in the $top_srcdir tree -# and build products in the $top_builddir tree. -top_srcdir=@top_srcdir@ -top_builddir=@top_builddir@ -git_commit_version_hash=@GIT_COMMIT_VERSION_HASH@ - -# Set `is_win` variable which is used in other scripts that source this one. -if test $(env | grep -ic '^comspec=') != 0 ; then - is_win=yes -else - is_win=no -fi - -# change to 'false' to show all flac/metaflac output (useful for debugging) -if true ; then - SILENT='--silent' - TOTALLY_SILENT='--totally-silent' -else - SILENT='' - TOTALLY_SILENT='' -fi - -# Functions - -die () -{ - echo $* 1>&2 - exit 1 -} - -make_streams () -{ - echo "Generating streams..." - if [ ! -f wacky1.wav ] ; then - test_streams${EXE} || die "ERROR during test_streams" - fi -} diff --git a/Engine/lib/flac/test/cuesheet.ok b/Engine/lib/flac/test/cuesheet.ok deleted file mode 100644 index dc9c82f09..000000000 --- a/Engine/lib/flac/test/cuesheet.ok +++ /dev/null @@ -1,94 +0,0 @@ -NEGATIVE cuesheets/bad.000.CATALOG_multiple.cue -pass1: parse error, line 2: "found multiple CATALOG commands" -NEGATIVE cuesheets/bad.001.CATALOG_missing_number.cue -pass1: parse error, line 1: "CATALOG is missing catalog number" -NEGATIVE cuesheets/bad.002.CATALOG_number_too_long.cue -pass1: parse error, line 1: "CATALOG number is too long" -NEGATIVE cuesheets/bad.003.CATALOG_not_13_digits.cue -pass1: parse error, line 1: "CD-DA CATALOG number must be 13 decimal digits" -NEGATIVE cuesheets/bad.030.FLAGS_multiple.cue -pass1: parse error, line 4: "found multiple FLAGS commands" -NEGATIVE cuesheets/bad.031.FLAGS_wrong_place_1.cue -pass1: parse error, line 1: "FLAGS command must come after TRACK but before INDEX" -NEGATIVE cuesheets/bad.032.FLAGS_wrong_place_2.cue -pass1: parse error, line 4: "FLAGS command must come after TRACK but before INDEX" -NEGATIVE cuesheets/bad.060.INDEX_wrong_place.cue -pass1: parse error, line 2: "found INDEX before any TRACK" -NEGATIVE cuesheets/bad.061.INDEX_missing_number.cue -pass1: parse error, line 4: "INDEX is missing index number" -NEGATIVE cuesheets/bad.062.INDEX_invalid_number_1.cue -pass1: parse error, line 4: "INDEX has invalid index number" -NEGATIVE cuesheets/bad.063.first_INDEX_not_0_or_1.cue -pass1: parse error, line 4: "first INDEX number of a TRACK must be 0 or 1" -NEGATIVE cuesheets/bad.064.INDEX_num_non_sequential.cue -pass1: parse error, line 5: "INDEX numbers must be sequential" -NEGATIVE cuesheets/bad.065.INDEX_num_out_of_range.cue -pass1: parse error, line 104: "CD-DA INDEX number must be between 0 and 99, inclusive" -NEGATIVE cuesheets/bad.066.INDEX_missing_offset.cue -pass1: parse error, line 4: "INDEX is missing an offset after the index number" -NEGATIVE cuesheets/bad.067.INDEX_illegal_offset.cue -pass1: parse error, line 4: "illegal INDEX offset (not of the form MM:SS:FF)" -NEGATIVE cuesheets/bad.068.INDEX_cdda_illegal_offset.cue -pass1: parse error, line 4: "illegal INDEX offset (not of the form MM:SS:FF)" -NEGATIVE cuesheets/bad.069.nonzero_first_INDEX.cue -pass1: parse error, line 4: "first INDEX of first TRACK must have an offset of 00:00:00" -NEGATIVE cuesheets/bad.070.INDEX_offset_not_ascending_1.cue -pass1: parse error, line 5: "CD-DA INDEX offsets must increase in time" -NEGATIVE cuesheets/bad.071.INDEX_offset_not_ascending_2.cue -pass1: parse error, line 6: "CD-DA INDEX offsets must increase in time" -NEGATIVE cuesheets/bad.110.ISRC_multiple.cue -pass1: parse error, line 4: "found multiple ISRC commands" -NEGATIVE cuesheets/bad.111.ISRC_wrong_place_1.cue -pass1: parse error, line 2: "ISRC command must come after TRACK but before INDEX" -NEGATIVE cuesheets/bad.112.ISRC_wrong_place_2.cue -pass1: parse error, line 4: "ISRC command must come after TRACK but before INDEX" -NEGATIVE cuesheets/bad.113.ISRC_missing_number.cue -pass1: parse error, line 3: "ISRC is missing ISRC number" -NEGATIVE cuesheets/bad.114.ISRC_invalid_number.cue -pass1: parse error, line 3: "invalid ISRC number" -NEGATIVE cuesheets/bad.130.TRACK_missing_INDEX_01_1.cue -pass1: parse error, line 2: "previous TRACK must specify at least one INDEX 01" -NEGATIVE cuesheets/bad.131.TRACK_missing_INDEX_01_2.cue -pass1: parse error, line 3: "previous TRACK must specify at least one INDEX 01" -NEGATIVE cuesheets/bad.132.TRACK_missing_INDEX_01_3.cue -pass1: parse error, line 3: "previous TRACK must specify at least one INDEX 01" -NEGATIVE cuesheets/bad.133.TRACK_missing_INDEX_01_4.cue -pass1: parse error, line 4: "previous TRACK must specify at least one INDEX 01" -NEGATIVE cuesheets/bad.134.TRACK_missing_number.cue -pass1: parse error, line 2: "TRACK is missing track number" -NEGATIVE cuesheets/bad.135.TRACK_invalid_number_1.cue -pass1: parse error, line 2: "TRACK has invalid track number" -NEGATIVE cuesheets/bad.136.TRACK_invalid_number_2.cue -pass1: parse error, line 2: "TRACK number must be greater than 0" -NEGATIVE cuesheets/bad.137.TRACK_cdda_out_of_range.cue -pass1: parse error, line 2: "CD-DA TRACK number must be between 1 and 99, inclusive" -NEGATIVE cuesheets/bad.138.TRACK_num_non_sequential.cue -pass1: parse error, line 6: "CD-DA TRACK numbers must be sequential" -NEGATIVE cuesheets/bad.139.TRACK_missing_type.cue -pass1: parse error, line 2: "TRACK is missing a track type after the track number" -NEGATIVE cuesheets/bad.140.no_TRACKs.cue -pass1: parse error, line 1: "there must be at least one TRACK command" -NEGATIVE cuesheets/bad.200.FLAC_leadin_missing_offset.cue -pass1: parse error, line 1: "FLAC__lead-in is missing offset" -NEGATIVE cuesheets/bad.201.FLAC_leadin_illegal_offset.cue -pass1: parse error, line 1: "illegal FLAC__lead-in offset" -NEGATIVE cuesheets/bad.202.FLAC_leadin_cdda_illegal_offset.cue -pass1: parse error, line 1: "illegal CD-DA FLAC__lead-in offset, must be even multiple of 588 samples" -NEGATIVE cuesheets/bad.230.FLAC_leadout_multiple.cue -pass1: parse error, line 3: "multiple FLAC__lead-out commands" -NEGATIVE cuesheets/bad.231.FLAC_leadout_missing_track.cue -pass1: parse error, line 1: "FLAC__lead-out is missing track number" -NEGATIVE cuesheets/bad.232.FLAC_leadout_illegal_track.cue -pass1: parse error, line 1: "illegal FLAC__lead-out track number" -NEGATIVE cuesheets/bad.233.FLAC_leadout_missing_offset.cue -pass1: parse error, line 1: "FLAC__lead-out is missing offset" -NEGATIVE cuesheets/bad.234.FLAC_leadout_illegal_offset.cue -pass1: parse error, line 1: "illegal FLAC__lead-out offset" -NEGATIVE cuesheets/bad.235.FLAC_leadout_offset_not_211680000.cue -pass1: parse error, line 1: "FLAC__lead-out offset does not match end-of-stream offset" -POSITIVE cuesheets/good.000.cue -POSITIVE cuesheets/good.001.cue -POSITIVE cuesheets/good.002.dos_format.cue -POSITIVE cuesheets/good.003.missing_final_newline.cue -POSITIVE cuesheets/good.004.dos_format.missing_final_newline.cue -POSITIVE cuesheets/good.005.quoted.isrc.cue diff --git a/Engine/lib/flac/test/cuesheets/Makefile.am b/Engine/lib/flac/test/cuesheets/Makefile.am deleted file mode 100644 index 8db5c5fe8..000000000 --- a/Engine/lib/flac/test/cuesheets/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -EXTRA_DIST = \ - bad.000.CATALOG_multiple.cue \ - bad.001.CATALOG_missing_number.cue \ - bad.002.CATALOG_number_too_long.cue \ - bad.003.CATALOG_not_13_digits.cue \ - bad.030.FLAGS_multiple.cue \ - bad.031.FLAGS_wrong_place_1.cue \ - bad.032.FLAGS_wrong_place_2.cue \ - bad.060.INDEX_wrong_place.cue \ - bad.061.INDEX_missing_number.cue \ - bad.062.INDEX_invalid_number_1.cue \ - bad.063.first_INDEX_not_0_or_1.cue \ - bad.064.INDEX_num_non_sequential.cue \ - bad.065.INDEX_num_out_of_range.cue \ - bad.066.INDEX_missing_offset.cue \ - bad.067.INDEX_illegal_offset.cue \ - bad.068.INDEX_cdda_illegal_offset.cue \ - bad.069.nonzero_first_INDEX.cue \ - bad.070.INDEX_offset_not_ascending_1.cue \ - bad.071.INDEX_offset_not_ascending_2.cue \ - bad.110.ISRC_multiple.cue \ - bad.111.ISRC_wrong_place_1.cue \ - bad.112.ISRC_wrong_place_2.cue \ - bad.113.ISRC_missing_number.cue \ - bad.114.ISRC_invalid_number.cue \ - bad.130.TRACK_missing_INDEX_01_1.cue \ - bad.131.TRACK_missing_INDEX_01_2.cue \ - bad.132.TRACK_missing_INDEX_01_3.cue \ - bad.133.TRACK_missing_INDEX_01_4.cue \ - bad.134.TRACK_missing_number.cue \ - bad.135.TRACK_invalid_number_1.cue \ - bad.136.TRACK_invalid_number_2.cue \ - bad.137.TRACK_cdda_out_of_range.cue \ - bad.138.TRACK_num_non_sequential.cue \ - bad.139.TRACK_missing_type.cue \ - bad.140.no_TRACKs.cue \ - bad.200.FLAC_leadin_missing_offset.cue \ - bad.201.FLAC_leadin_illegal_offset.cue \ - bad.202.FLAC_leadin_cdda_illegal_offset.cue \ - bad.230.FLAC_leadout_multiple.cue \ - bad.231.FLAC_leadout_missing_track.cue \ - bad.232.FLAC_leadout_illegal_track.cue \ - bad.233.FLAC_leadout_missing_offset.cue \ - bad.234.FLAC_leadout_illegal_offset.cue \ - bad.235.FLAC_leadout_offset_not_211680000.cue \ - good.000.cue \ - good.001.cue \ - good.002.dos_format.cue \ - good.003.missing_final_newline.cue \ - good.004.dos_format.missing_final_newline.cue \ - good.005.quoted.isrc.cue diff --git a/Engine/lib/flac/test/cuesheets/bad.000.CATALOG_multiple.cue b/Engine/lib/flac/test/cuesheets/bad.000.CATALOG_multiple.cue deleted file mode 100644 index ef2769bf6..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.000.CATALOG_multiple.cue +++ /dev/null @@ -1,5 +0,0 @@ -CATALOG 1234567890123 -CATALOG 0234567890123 -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.001.CATALOG_missing_number.cue b/Engine/lib/flac/test/cuesheets/bad.001.CATALOG_missing_number.cue deleted file mode 100644 index ce2334f13..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.001.CATALOG_missing_number.cue +++ /dev/null @@ -1,4 +0,0 @@ -CATALOG -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.002.CATALOG_number_too_long.cue b/Engine/lib/flac/test/cuesheets/bad.002.CATALOG_number_too_long.cue deleted file mode 100644 index 8585a0ae0..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.002.CATALOG_number_too_long.cue +++ /dev/null @@ -1,4 +0,0 @@ -CATALOG 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.003.CATALOG_not_13_digits.cue b/Engine/lib/flac/test/cuesheets/bad.003.CATALOG_not_13_digits.cue deleted file mode 100644 index c75d4c0e3..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.003.CATALOG_not_13_digits.cue +++ /dev/null @@ -1,4 +0,0 @@ -CATALOG 123456789012z -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.030.FLAGS_multiple.cue b/Engine/lib/flac/test/cuesheets/bad.030.FLAGS_multiple.cue deleted file mode 100644 index ee82b137f..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.030.FLAGS_multiple.cue +++ /dev/null @@ -1,5 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - FLAGS 4CH - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.031.FLAGS_wrong_place_1.cue b/Engine/lib/flac/test/cuesheets/bad.031.FLAGS_wrong_place_1.cue deleted file mode 100644 index 3b7f01805..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.031.FLAGS_wrong_place_1.cue +++ /dev/null @@ -1,4 +0,0 @@ -FLAGS PRE -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.032.FLAGS_wrong_place_2.cue b/Engine/lib/flac/test/cuesheets/bad.032.FLAGS_wrong_place_2.cue deleted file mode 100644 index 926cc9155..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.032.FLAGS_wrong_place_2.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 - FLAGS PRE diff --git a/Engine/lib/flac/test/cuesheets/bad.060.INDEX_wrong_place.cue b/Engine/lib/flac/test/cuesheets/bad.060.INDEX_wrong_place.cue deleted file mode 100644 index fb175f273..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.060.INDEX_wrong_place.cue +++ /dev/null @@ -1,5 +0,0 @@ -FILE "z.wav" WAVE -INDEX 00 00:00:00 - TRACK 01 AUDIO - FLAGS PRE - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.061.INDEX_missing_number.cue b/Engine/lib/flac/test/cuesheets/bad.061.INDEX_missing_number.cue deleted file mode 100644 index bf72604b0..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.061.INDEX_missing_number.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX diff --git a/Engine/lib/flac/test/cuesheets/bad.062.INDEX_invalid_number_1.cue b/Engine/lib/flac/test/cuesheets/bad.062.INDEX_invalid_number_1.cue deleted file mode 100644 index fcb4dd305..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.062.INDEX_invalid_number_1.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX thhpt! diff --git a/Engine/lib/flac/test/cuesheets/bad.063.first_INDEX_not_0_or_1.cue b/Engine/lib/flac/test/cuesheets/bad.063.first_INDEX_not_0_or_1.cue deleted file mode 100644 index a136f3f6b..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.063.first_INDEX_not_0_or_1.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX 02 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.064.INDEX_num_non_sequential.cue b/Engine/lib/flac/test/cuesheets/bad.064.INDEX_num_non_sequential.cue deleted file mode 100644 index 9df3b47bb..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.064.INDEX_num_non_sequential.cue +++ /dev/null @@ -1,5 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX 01 00:00:00 - INDEX 00 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.065.INDEX_num_out_of_range.cue b/Engine/lib/flac/test/cuesheets/bad.065.INDEX_num_out_of_range.cue deleted file mode 100644 index a72d7e03d..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.065.INDEX_num_out_of_range.cue +++ /dev/null @@ -1,104 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX 00 00:00:00 - INDEX 01 02:10:15 - INDEX 02 02:20:15 - INDEX 03 02:30:15 - INDEX 04 03:30:15 - INDEX 05 03:31:15 - INDEX 06 03:32:06 - INDEX 07 03:32:07 - INDEX 08 03:32:08 - INDEX 09 03:32:09 - INDEX 10 03:32:10 - INDEX 11 03:32:11 - INDEX 12 03:32:12 - INDEX 13 03:32:13 - INDEX 14 03:32:14 - INDEX 15 03:32:15 - INDEX 16 03:32:16 - INDEX 17 03:32:17 - INDEX 18 03:32:18 - INDEX 19 03:32:19 - INDEX 20 03:32:20 - INDEX 21 03:32:21 - INDEX 22 03:32:22 - INDEX 23 03:32:23 - INDEX 24 03:32:24 - INDEX 25 03:32:25 - INDEX 26 03:32:26 - INDEX 27 03:32:27 - INDEX 28 03:32:28 - INDEX 29 03:32:29 - INDEX 30 03:32:30 - INDEX 31 03:32:31 - INDEX 32 03:32:32 - INDEX 33 03:32:33 - INDEX 34 03:32:34 - INDEX 35 03:32:35 - INDEX 36 03:32:36 - INDEX 37 03:32:37 - INDEX 38 03:32:38 - INDEX 39 03:32:39 - INDEX 40 03:32:40 - INDEX 41 03:32:41 - INDEX 42 03:32:42 - INDEX 43 03:32:43 - INDEX 44 03:32:44 - INDEX 45 03:32:45 - INDEX 46 03:32:46 - INDEX 47 03:32:47 - INDEX 48 03:32:48 - INDEX 49 03:32:49 - INDEX 50 03:32:50 - INDEX 51 03:32:51 - INDEX 52 03:32:52 - INDEX 53 03:32:53 - INDEX 54 03:32:54 - INDEX 55 03:32:55 - INDEX 56 03:32:56 - INDEX 57 03:32:57 - INDEX 58 03:32:58 - INDEX 59 03:32:59 - INDEX 60 03:32:60 - INDEX 61 03:32:61 - INDEX 62 03:32:62 - INDEX 63 03:32:63 - INDEX 64 03:32:64 - INDEX 65 03:32:65 - INDEX 66 03:32:66 - INDEX 67 03:32:67 - INDEX 68 03:32:68 - INDEX 69 03:32:69 - INDEX 70 03:40:50 - INDEX 71 03:40:51 - INDEX 72 03:40:52 - INDEX 73 03:40:53 - INDEX 74 03:40:54 - INDEX 75 03:40:55 - INDEX 76 03:40:56 - INDEX 77 03:40:57 - INDEX 78 03:40:58 - INDEX 79 03:40:59 - INDEX 80 03:41:50 - INDEX 81 03:41:51 - INDEX 82 03:41:52 - INDEX 83 03:41:53 - INDEX 84 03:41:54 - INDEX 85 03:41:55 - INDEX 86 03:41:56 - INDEX 87 03:41:57 - INDEX 88 03:41:58 - INDEX 89 03:41:59 - INDEX 90 03:42:50 - INDEX 91 03:42:51 - INDEX 92 03:42:52 - INDEX 93 03:42:53 - INDEX 94 03:42:54 - INDEX 95 03:42:55 - INDEX 96 03:42:56 - INDEX 97 03:42:57 - INDEX 98 03:42:58 - INDEX 99 03:42:59 - INDEX 100 04:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.066.INDEX_missing_offset.cue b/Engine/lib/flac/test/cuesheets/bad.066.INDEX_missing_offset.cue deleted file mode 100644 index 1e78bc619..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.066.INDEX_missing_offset.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX 01 diff --git a/Engine/lib/flac/test/cuesheets/bad.067.INDEX_illegal_offset.cue b/Engine/lib/flac/test/cuesheets/bad.067.INDEX_illegal_offset.cue deleted file mode 100644 index 874202969..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.067.INDEX_illegal_offset.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX 01 00:00.00 diff --git a/Engine/lib/flac/test/cuesheets/bad.068.INDEX_cdda_illegal_offset.cue b/Engine/lib/flac/test/cuesheets/bad.068.INDEX_cdda_illegal_offset.cue deleted file mode 100644 index 6e00fed7f..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.068.INDEX_cdda_illegal_offset.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX 01 588 diff --git a/Engine/lib/flac/test/cuesheets/bad.069.nonzero_first_INDEX.cue b/Engine/lib/flac/test/cuesheets/bad.069.nonzero_first_INDEX.cue deleted file mode 100644 index 746494978..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.069.nonzero_first_INDEX.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX 01 00:02:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.070.INDEX_offset_not_ascending_1.cue b/Engine/lib/flac/test/cuesheets/bad.070.INDEX_offset_not_ascending_1.cue deleted file mode 100644 index a4fe0638e..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.070.INDEX_offset_not_ascending_1.cue +++ /dev/null @@ -1,5 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 - INDEX 02 00:02:00 - INDEX 03 00:01:74 diff --git a/Engine/lib/flac/test/cuesheets/bad.071.INDEX_offset_not_ascending_2.cue b/Engine/lib/flac/test/cuesheets/bad.071.INDEX_offset_not_ascending_2.cue deleted file mode 100644 index 8983a03c4..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.071.INDEX_offset_not_ascending_2.cue +++ /dev/null @@ -1,6 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 - INDEX 02 00:02:00 - TRACK 02 AUDIO - INDEX 01 00:01:74 diff --git a/Engine/lib/flac/test/cuesheets/bad.110.ISRC_multiple.cue b/Engine/lib/flac/test/cuesheets/bad.110.ISRC_multiple.cue deleted file mode 100644 index 907c1b802..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.110.ISRC_multiple.cue +++ /dev/null @@ -1,5 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - ISRC ABCDE1234567 - ISRC ABCD01234567 - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.111.ISRC_wrong_place_1.cue b/Engine/lib/flac/test/cuesheets/bad.111.ISRC_wrong_place_1.cue deleted file mode 100644 index 86fbe905f..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.111.ISRC_wrong_place_1.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE -ISRC ABCD01234567 - TRACK 01 AUDIO - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.112.ISRC_wrong_place_2.cue b/Engine/lib/flac/test/cuesheets/bad.112.ISRC_wrong_place_2.cue deleted file mode 100644 index e0b4e772d..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.112.ISRC_wrong_place_2.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 - ISRC ABCD01234567 diff --git a/Engine/lib/flac/test/cuesheets/bad.113.ISRC_missing_number.cue b/Engine/lib/flac/test/cuesheets/bad.113.ISRC_missing_number.cue deleted file mode 100644 index 742e054dc..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.113.ISRC_missing_number.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - ISRC - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.114.ISRC_invalid_number.cue b/Engine/lib/flac/test/cuesheets/bad.114.ISRC_invalid_number.cue deleted file mode 100644 index 362130a01..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.114.ISRC_invalid_number.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - ISRC ABCD0123456Z - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.130.TRACK_missing_INDEX_01_1.cue b/Engine/lib/flac/test/cuesheets/bad.130.TRACK_missing_INDEX_01_1.cue deleted file mode 100644 index 069707402..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.130.TRACK_missing_INDEX_01_1.cue +++ /dev/null @@ -1,2 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO diff --git a/Engine/lib/flac/test/cuesheets/bad.131.TRACK_missing_INDEX_01_2.cue b/Engine/lib/flac/test/cuesheets/bad.131.TRACK_missing_INDEX_01_2.cue deleted file mode 100644 index 554cf12c7..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.131.TRACK_missing_INDEX_01_2.cue +++ /dev/null @@ -1,3 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 00 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.132.TRACK_missing_INDEX_01_3.cue b/Engine/lib/flac/test/cuesheets/bad.132.TRACK_missing_INDEX_01_3.cue deleted file mode 100644 index 5618db897..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.132.TRACK_missing_INDEX_01_3.cue +++ /dev/null @@ -1,4 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - TRACK 02 AUDIO - INDEX 01 00:02:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.133.TRACK_missing_INDEX_01_4.cue b/Engine/lib/flac/test/cuesheets/bad.133.TRACK_missing_INDEX_01_4.cue deleted file mode 100644 index f74a9e408..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.133.TRACK_missing_INDEX_01_4.cue +++ /dev/null @@ -1,5 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 00 00:00:00 - TRACK 02 AUDIO - INDEX 01 00:02:00 diff --git a/Engine/lib/flac/test/cuesheets/bad.134.TRACK_missing_number.cue b/Engine/lib/flac/test/cuesheets/bad.134.TRACK_missing_number.cue deleted file mode 100644 index f95180b85..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.134.TRACK_missing_number.cue +++ /dev/null @@ -1,2 +0,0 @@ -FILE "z.wav" WAVE - TRACK diff --git a/Engine/lib/flac/test/cuesheets/bad.135.TRACK_invalid_number_1.cue b/Engine/lib/flac/test/cuesheets/bad.135.TRACK_invalid_number_1.cue deleted file mode 100644 index 9c3c9ea1f..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.135.TRACK_invalid_number_1.cue +++ /dev/null @@ -1,2 +0,0 @@ -FILE "z.wav" WAVE - TRACK thhpt! AUDIO diff --git a/Engine/lib/flac/test/cuesheets/bad.136.TRACK_invalid_number_2.cue b/Engine/lib/flac/test/cuesheets/bad.136.TRACK_invalid_number_2.cue deleted file mode 100644 index 69caafa8b..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.136.TRACK_invalid_number_2.cue +++ /dev/null @@ -1,2 +0,0 @@ -FILE "z.wav" WAVE - TRACK 0 AUDIO diff --git a/Engine/lib/flac/test/cuesheets/bad.137.TRACK_cdda_out_of_range.cue b/Engine/lib/flac/test/cuesheets/bad.137.TRACK_cdda_out_of_range.cue deleted file mode 100644 index 8696f5203..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.137.TRACK_cdda_out_of_range.cue +++ /dev/null @@ -1,2 +0,0 @@ -FILE "z.wav" WAVE - TRACK 100 AUDIO diff --git a/Engine/lib/flac/test/cuesheets/bad.138.TRACK_num_non_sequential.cue b/Engine/lib/flac/test/cuesheets/bad.138.TRACK_num_non_sequential.cue deleted file mode 100644 index 37870c39e..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.138.TRACK_num_non_sequential.cue +++ /dev/null @@ -1,6 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 0:0:0 - TRACK 02 AUDIO - INDEX 01 2:0:0 - TRACK 01 AUDIO diff --git a/Engine/lib/flac/test/cuesheets/bad.139.TRACK_missing_type.cue b/Engine/lib/flac/test/cuesheets/bad.139.TRACK_missing_type.cue deleted file mode 100644 index 01fca6a19..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.139.TRACK_missing_type.cue +++ /dev/null @@ -1,2 +0,0 @@ -FILE "z.wav" WAVE - TRACK 01 diff --git a/Engine/lib/flac/test/cuesheets/bad.140.no_TRACKs.cue b/Engine/lib/flac/test/cuesheets/bad.140.no_TRACKs.cue deleted file mode 100644 index 73cb8cf5c..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.140.no_TRACKs.cue +++ /dev/null @@ -1 +0,0 @@ -FILE "z.wav" WAVE diff --git a/Engine/lib/flac/test/cuesheets/bad.200.FLAC_leadin_missing_offset.cue b/Engine/lib/flac/test/cuesheets/bad.200.FLAC_leadin_missing_offset.cue deleted file mode 100644 index 7441aa532..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.200.FLAC_leadin_missing_offset.cue +++ /dev/null @@ -1 +0,0 @@ -REM FLAC__lead-in diff --git a/Engine/lib/flac/test/cuesheets/bad.201.FLAC_leadin_illegal_offset.cue b/Engine/lib/flac/test/cuesheets/bad.201.FLAC_leadin_illegal_offset.cue deleted file mode 100644 index acf69409b..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.201.FLAC_leadin_illegal_offset.cue +++ /dev/null @@ -1 +0,0 @@ -REM FLAC__lead-in thhpt! diff --git a/Engine/lib/flac/test/cuesheets/bad.202.FLAC_leadin_cdda_illegal_offset.cue b/Engine/lib/flac/test/cuesheets/bad.202.FLAC_leadin_cdda_illegal_offset.cue deleted file mode 100644 index 6f2d0f7d8..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.202.FLAC_leadin_cdda_illegal_offset.cue +++ /dev/null @@ -1 +0,0 @@ -REM FLAC__lead-in 123 diff --git a/Engine/lib/flac/test/cuesheets/bad.230.FLAC_leadout_multiple.cue b/Engine/lib/flac/test/cuesheets/bad.230.FLAC_leadout_multiple.cue deleted file mode 100644 index 656fe9d96..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.230.FLAC_leadout_multiple.cue +++ /dev/null @@ -1,3 +0,0 @@ -REM FLAC__lead-in 88200 -REM FLAC__lead-out 170 211680000 -REM FLAC__lead-out 170 211680588 diff --git a/Engine/lib/flac/test/cuesheets/bad.231.FLAC_leadout_missing_track.cue b/Engine/lib/flac/test/cuesheets/bad.231.FLAC_leadout_missing_track.cue deleted file mode 100644 index a723b7a61..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.231.FLAC_leadout_missing_track.cue +++ /dev/null @@ -1 +0,0 @@ -REM FLAC__lead-out diff --git a/Engine/lib/flac/test/cuesheets/bad.232.FLAC_leadout_illegal_track.cue b/Engine/lib/flac/test/cuesheets/bad.232.FLAC_leadout_illegal_track.cue deleted file mode 100644 index 6001826b5..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.232.FLAC_leadout_illegal_track.cue +++ /dev/null @@ -1 +0,0 @@ -REM FLAC__lead-out thhpt! diff --git a/Engine/lib/flac/test/cuesheets/bad.233.FLAC_leadout_missing_offset.cue b/Engine/lib/flac/test/cuesheets/bad.233.FLAC_leadout_missing_offset.cue deleted file mode 100644 index ef5f1dc3a..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.233.FLAC_leadout_missing_offset.cue +++ /dev/null @@ -1 +0,0 @@ -REM FLAC__lead-out 170 diff --git a/Engine/lib/flac/test/cuesheets/bad.234.FLAC_leadout_illegal_offset.cue b/Engine/lib/flac/test/cuesheets/bad.234.FLAC_leadout_illegal_offset.cue deleted file mode 100644 index 01c69f40d..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.234.FLAC_leadout_illegal_offset.cue +++ /dev/null @@ -1 +0,0 @@ -REM FLAC__lead-out 170 thhpt! diff --git a/Engine/lib/flac/test/cuesheets/bad.235.FLAC_leadout_offset_not_211680000.cue b/Engine/lib/flac/test/cuesheets/bad.235.FLAC_leadout_offset_not_211680000.cue deleted file mode 100644 index 8add1d6e3..000000000 --- a/Engine/lib/flac/test/cuesheets/bad.235.FLAC_leadout_offset_not_211680000.cue +++ /dev/null @@ -1 +0,0 @@ -REM FLAC__lead-out 170 211680588 diff --git a/Engine/lib/flac/test/cuesheets/good.000.cue b/Engine/lib/flac/test/cuesheets/good.000.cue deleted file mode 100644 index bdfbccf9c..000000000 --- a/Engine/lib/flac/test/cuesheets/good.000.cue +++ /dev/null @@ -1,4 +0,0 @@ -CATALOG "1234567890123" -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/good.001.cue b/Engine/lib/flac/test/cuesheets/good.001.cue deleted file mode 100644 index f9887cfa5..000000000 --- a/Engine/lib/flac/test/cuesheets/good.001.cue +++ /dev/null @@ -1,184 +0,0 @@ -REM FLAC__lead-in 88200 -REM FLAC__lead-out 170 211680000 -CATALOG 1234567890123 -FILE "z.wav" WAVE - TRACK 01 AUDIO - FLAGS PRE - INDEX 01 00:00:00 - TRACK 02 AUDIO - FLAGS PRE - ISRC ABCDE7654321 - INDEX 00 02:09:12 - INDEX 01 02:10:15 - INDEX 02 02:20:15 - INDEX 03 02:30:15 - INDEX 04 03:30:15 - INDEX 05 03:31:15 - INDEX 06 03:32:06 - INDEX 07 03:32:07 - INDEX 08 03:32:08 - INDEX 09 03:32:09 - INDEX 10 03:32:10 - INDEX 11 03:32:11 - INDEX 12 03:32:12 - INDEX 13 03:32:13 - INDEX 14 03:32:14 - INDEX 15 03:32:15 - INDEX 16 03:32:16 - INDEX 17 03:32:17 - INDEX 18 03:32:18 - INDEX 19 03:32:19 - INDEX 20 03:32:20 - INDEX 21 03:32:21 - INDEX 22 03:32:22 - INDEX 23 03:32:23 - INDEX 24 03:32:24 - INDEX 25 03:32:25 - INDEX 26 03:32:26 - INDEX 27 03:32:27 - INDEX 28 03:32:28 - INDEX 29 03:32:29 - INDEX 30 03:32:30 - INDEX 31 03:32:31 - INDEX 32 03:32:32 - INDEX 33 03:32:33 - INDEX 34 03:32:34 - INDEX 35 03:32:35 - INDEX 36 03:32:36 - INDEX 37 03:32:37 - INDEX 38 03:32:38 - INDEX 39 03:32:39 - INDEX 40 03:32:40 - INDEX 41 03:32:41 - INDEX 42 03:32:42 - INDEX 43 03:32:43 - INDEX 44 03:32:44 - INDEX 45 03:32:45 - INDEX 46 03:32:46 - INDEX 47 03:32:47 - INDEX 48 03:32:48 - INDEX 49 03:32:49 - INDEX 50 03:32:50 - INDEX 51 03:32:51 - INDEX 52 03:32:52 - INDEX 53 03:32:53 - INDEX 54 03:32:54 - INDEX 55 03:32:55 - INDEX 56 03:32:56 - INDEX 57 03:32:57 - INDEX 58 03:32:58 - INDEX 59 03:32:59 - INDEX 60 03:32:60 - INDEX 61 03:32:61 - INDEX 62 03:32:62 - INDEX 63 03:32:63 - INDEX 64 03:32:64 - INDEX 65 03:32:65 - INDEX 66 03:32:66 - INDEX 67 03:32:67 - INDEX 68 03:32:68 - INDEX 69 03:32:69 - INDEX 70 03:40:50 - INDEX 71 03:40:51 - INDEX 72 03:40:52 - INDEX 73 03:40:53 - INDEX 74 03:40:54 - INDEX 75 03:40:55 - INDEX 76 03:40:56 - INDEX 77 03:40:57 - INDEX 78 03:40:58 - INDEX 79 03:40:59 - INDEX 80 03:41:50 - INDEX 81 03:41:51 - INDEX 82 03:41:52 - INDEX 83 03:41:53 - INDEX 84 03:41:54 - INDEX 85 03:41:55 - INDEX 86 03:41:56 - INDEX 87 03:41:57 - INDEX 88 03:41:58 - INDEX 89 03:41:59 - INDEX 90 03:42:50 - INDEX 91 03:42:51 - INDEX 92 03:42:52 - INDEX 93 03:42:53 - INDEX 94 03:42:54 - INDEX 95 03:42:55 - INDEX 96 03:42:56 - INDEX 97 03:42:57 - INDEX 98 03:42:58 - INDEX 99 03:42:59 - TRACK 03 AUDIO - ISRC AB-CD7-65-43210 - INDEX 00 04:50:12 - INDEX 01 04:51:72 - TRACK 04 AUDIO - INDEX 00 06:36:10 - INDEX 01 06:38:47 - TRACK 05 AUDIO - INDEX 00 08:34:45 - INDEX 01 08:36:15 - TRACK 06 AUDIO - INDEX 00 13:20:22 - INDEX 01 13:22:12 - TRACK 07 AUDIO - INDEX 00 16:08:20 - INDEX 01 16:11:17 - TRACK 08 AUDIO - INDEX 01 17:48:37 - TRACK 09 AUDIO - INDEX 00 19:38:17 - INDEX 01 19:39:30 - TRACK 10 AUDIO - INDEX 00 22:07:07 - INDEX 01 22:08:20 - TRACK 11 AUDIO - INDEX 01 24:16:45 - TRACK 12 AUDIO - INDEX 01 26:13:67 - TRACK 13 AUDIO - INDEX 01 28:03:27 - TRACK 14 AUDIO - INDEX 00 30:22:42 - INDEX 01 30:24:45 - TRACK 15 AUDIO - INDEX 00 34:06:22 - INDEX 01 34:07:62 - TRACK 16 AUDIO - INDEX 00 35:54:30 - INDEX 01 35:56:60 - TRACK 17 AUDIO - INDEX 00 38:49:10 - INDEX 01 38:51:22 - TRACK 18 AUDIO - INDEX 00 41:14:15 - INDEX 01 41:17:15 - TRACK 19 AUDIO - INDEX 00 44:27:15 - INDEX 01 44:28:45 - TRACK 20 AUDIO - INDEX 00 48:07:17 - INDEX 01 48:09:72 - TRACK 21 AUDIO - INDEX 00 50:48:05 - INDEX 01 50:49:27 - TRACK 22 AUDIO - INDEX 00 53:29:72 - INDEX 01 53:31:20 - TRACK 23 AUDIO - INDEX 00 57:57:60 - INDEX 01 58:00:40 - TRACK 24 AUDIO - INDEX 00 61:52:65 - INDEX 01 61:55:37 - TRACK 25 AUDIO - INDEX 00 65:07:50 - INDEX 01 65:10:52 - TRACK 26 AUDIO - INDEX 00 68:30:05 - INDEX 01 68:32:45 - TRACK 27 AUDIO - INDEX 01 71:45:17 - TRACK 28 AUDIO - INDEX 00 74:49:07 - INDEX 01 74:51:47 diff --git a/Engine/lib/flac/test/cuesheets/good.002.dos_format.cue b/Engine/lib/flac/test/cuesheets/good.002.dos_format.cue deleted file mode 100644 index bdfbccf9c..000000000 --- a/Engine/lib/flac/test/cuesheets/good.002.dos_format.cue +++ /dev/null @@ -1,4 +0,0 @@ -CATALOG "1234567890123" -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/cuesheets/good.003.missing_final_newline.cue b/Engine/lib/flac/test/cuesheets/good.003.missing_final_newline.cue deleted file mode 100644 index a4c298f3f..000000000 --- a/Engine/lib/flac/test/cuesheets/good.003.missing_final_newline.cue +++ /dev/null @@ -1,4 +0,0 @@ -CATALOG "1234567890123" -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 \ No newline at end of file diff --git a/Engine/lib/flac/test/cuesheets/good.004.dos_format.missing_final_newline.cue b/Engine/lib/flac/test/cuesheets/good.004.dos_format.missing_final_newline.cue deleted file mode 100644 index a4c298f3f..000000000 --- a/Engine/lib/flac/test/cuesheets/good.004.dos_format.missing_final_newline.cue +++ /dev/null @@ -1,4 +0,0 @@ -CATALOG "1234567890123" -FILE "z.wav" WAVE - TRACK 01 AUDIO - INDEX 01 00:00:00 \ No newline at end of file diff --git a/Engine/lib/flac/test/cuesheets/good.005.quoted.isrc.cue b/Engine/lib/flac/test/cuesheets/good.005.quoted.isrc.cue deleted file mode 100644 index 24f8d7d3e..000000000 --- a/Engine/lib/flac/test/cuesheets/good.005.quoted.isrc.cue +++ /dev/null @@ -1,6 +0,0 @@ -TRACK 01 AUDIO -TITLE "Foo" -PERFORMER "Bar" -DISC_ID "" -ISRC "US-SM1-23-45678" -INDEX 01 00:00:00 diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/Makefile.am b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/Makefile.am deleted file mode 100644 index d76843d11..000000000 --- a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -EXTRA_DIST = \ - case00a-expect.meta \ - case01a-expect.meta \ - case01b-expect.meta \ - case01c-expect.meta \ - case01d-expect.meta \ - case01e-expect.meta \ - case02a-expect.meta \ - case02b-expect.meta \ - case02c-expect.meta \ - case03a-expect.meta \ - case03b-expect.meta \ - case03c-expect.meta \ - case04a-expect.meta \ - case04b-expect.meta \ - case04c-expect.meta \ - case04d-expect.meta \ - case04e-expect.meta \ - input-SCPAP.flac \ - input-SCVA.flac \ - input-SCVAUP.flac \ - input-SCVPAP.flac \ - input-SVAUP.flac \ - input-VA.flac \ - 🤔.flac \ - Prøve.flac \ - שלום.flac \ - input0.cue - -clean-local: - -rm -f out.* diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/Prøve.flac b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/Prøve.flac deleted file mode 100644 index 18830754e..000000000 Binary files a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/Prøve.flac and /dev/null differ diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCPAP.flac b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCPAP.flac deleted file mode 100644 index 6fde318d1..000000000 Binary files a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCPAP.flac and /dev/null differ diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCVA.flac b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCVA.flac deleted file mode 100644 index 4bb692629..000000000 Binary files a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCVA.flac and /dev/null differ diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCVAUP.flac b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCVAUP.flac deleted file mode 100644 index e4ecc9521..000000000 Binary files a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCVAUP.flac and /dev/null differ diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCVPAP.flac b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCVPAP.flac deleted file mode 100644 index 747492880..000000000 Binary files a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SCVPAP.flac and /dev/null differ diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SVAUP.flac b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SVAUP.flac deleted file mode 100644 index e3fa5c18f..000000000 Binary files a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-SVAUP.flac and /dev/null differ diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-VA.flac b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-VA.flac deleted file mode 100644 index 4fac8781b..000000000 Binary files a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input-VA.flac and /dev/null differ diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input0.cue b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input0.cue deleted file mode 100644 index 2894bd06a..000000000 --- a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/input0.cue +++ /dev/null @@ -1,7 +0,0 @@ -CATALOG 9294969890929 -FILE "blah" FLAC - TRACK 01 AUDIO - INDEX 01 00:00:00 - TRACK 02 AUDIO - INDEX 01 00:00:01 - INDEX 02 00:00:05 diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/שלום.flac b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/שלום.flac deleted file mode 100644 index 0e6686811..000000000 Binary files a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/שלום.flac and /dev/null differ diff --git a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/🤔.flac b/Engine/lib/flac/test/flac-to-flac-metadata-test-files/🤔.flac deleted file mode 100644 index 7373da6b1..000000000 Binary files a/Engine/lib/flac/test/flac-to-flac-metadata-test-files/🤔.flac and /dev/null differ diff --git a/Engine/lib/flac/test/foreign-metadata-test-files/24bit-WaveFmtPCM.wav b/Engine/lib/flac/test/foreign-metadata-test-files/24bit-WaveFmtPCM.wav deleted file mode 100644 index 2479974ec..000000000 Binary files a/Engine/lib/flac/test/foreign-metadata-test-files/24bit-WaveFmtPCM.wav and /dev/null differ diff --git a/Engine/lib/flac/test/foreign-metadata-test-files/AIFF-C-sowt-compression-type-name.aifc b/Engine/lib/flac/test/foreign-metadata-test-files/AIFF-C-sowt-compression-type-name.aifc deleted file mode 100644 index ca0963af3..000000000 Binary files a/Engine/lib/flac/test/foreign-metadata-test-files/AIFF-C-sowt-compression-type-name.aifc and /dev/null differ diff --git a/Engine/lib/flac/test/foreign-metadata-test-files/AIFF-C-sowt-tag.aifc b/Engine/lib/flac/test/foreign-metadata-test-files/AIFF-C-sowt-tag.aifc deleted file mode 100644 index 381d52e7d..000000000 Binary files a/Engine/lib/flac/test/foreign-metadata-test-files/AIFF-C-sowt-tag.aifc and /dev/null differ diff --git a/Engine/lib/flac/test/foreign-metadata-test-files/AIFF-ID3.aiff b/Engine/lib/flac/test/foreign-metadata-test-files/AIFF-ID3.aiff deleted file mode 100644 index 517c5ac36..000000000 Binary files a/Engine/lib/flac/test/foreign-metadata-test-files/AIFF-ID3.aiff and /dev/null differ diff --git a/Engine/lib/flac/test/foreign-metadata-test-files/BWF-WaveFmtEx.wav b/Engine/lib/flac/test/foreign-metadata-test-files/BWF-WaveFmtEx.wav deleted file mode 100644 index 244985d67..000000000 Binary files a/Engine/lib/flac/test/foreign-metadata-test-files/BWF-WaveFmtEx.wav and /dev/null differ diff --git a/Engine/lib/flac/test/foreign-metadata-test-files/Makefile.am b/Engine/lib/flac/test/foreign-metadata-test-files/Makefile.am deleted file mode 100644 index bdb2ed2df..000000000 --- a/Engine/lib/flac/test/foreign-metadata-test-files/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -EXTRA_DIST = \ - 24bit-WaveFmtPCM.wav \ - AIFF-C-sowt-compression-type-name.aifc \ - AIFF-C-sowt-tag.aifc \ - AIFF-ID3.aiff \ - BWF-WaveFmtEx.wav diff --git a/Engine/lib/flac/test/generate_streams.sh b/Engine/lib/flac/test/generate_streams.sh deleted file mode 100644 index 29e32dcbc..000000000 --- a/Engine/lib/flac/test/generate_streams.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -PATH="$(pwd)/../src/test_streams:$PATH" -PATH="$(pwd)/../objs/$BUILD/bin:$PATH" - -echo "Generating streams..." -if [ ! -f wacky1.wav ] ; then - test_streams || die "ERROR during test_streams" -fi diff --git a/Engine/lib/flac/test/metaflac-test-files/Makefile.am b/Engine/lib/flac/test/metaflac-test-files/Makefile.am deleted file mode 100644 index 6f089610e..000000000 --- a/Engine/lib/flac/test/metaflac-test-files/Makefile.am +++ /dev/null @@ -1,90 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -EXTRA_DIST = \ - case00-expect.meta \ - case01-expect.meta \ - case02-expect.meta \ - case03-expect.meta \ - case04-expect.meta \ - case05-expect.meta \ - case06-expect.meta \ - case07-expect.meta \ - case08-expect.meta \ - case09-expect.meta \ - case10-expect.meta \ - case11-expect.meta \ - case12-expect.meta \ - case13-expect.meta \ - case14-expect.meta \ - case15-expect.meta \ - case16-expect.meta \ - case17-expect.meta \ - case18-expect.meta \ - case19-expect.meta \ - case20-expect.meta \ - case21-expect.meta \ - case22-expect.meta \ - case23-expect.meta \ - case24-expect.meta \ - case25-expect.meta \ - case26-expect.meta \ - case27-expect.meta \ - case28-expect.meta \ - case29-expect.meta \ - case30-expect.meta \ - case31-expect.meta \ - case32-expect.meta \ - case33-expect.meta \ - case34-expect.meta \ - case35-expect.meta \ - case36-expect.meta \ - case37-expect.meta \ - case38-expect.meta \ - case39-expect.meta \ - case40-expect.meta \ - case41-expect.meta \ - case42-expect.meta \ - case43-expect.meta \ - case44-expect.meta \ - case45-expect.meta \ - case46-expect.meta \ - case47-expect.meta \ - case48-expect.meta \ - case49-expect.meta \ - case50-expect.meta \ - case51-expect.meta \ - case52-expect.meta \ - case53-expect.meta \ - case54-expect.meta \ - case55-expect.meta \ - case56-expect.meta \ - case57-expect.meta \ - case58-expect.meta \ - case59-expect.meta \ - case60-expect.meta \ - case61-expect.meta \ - case62-expect.meta \ - case63-expect.meta \ - case64-expect.meta \ - case65-expect.meta \ - case66-expect.meta \ - case67-expect.meta - -clean-local: - -rm -f out.* diff --git a/Engine/lib/flac/test/metaflac.flac.in b/Engine/lib/flac/test/metaflac.flac.in deleted file mode 100644 index 79892630f..000000000 Binary files a/Engine/lib/flac/test/metaflac.flac.in and /dev/null differ diff --git a/Engine/lib/flac/test/metaflac.flac.ok b/Engine/lib/flac/test/metaflac.flac.ok deleted file mode 100644 index 82ad84cca..000000000 Binary files a/Engine/lib/flac/test/metaflac.flac.ok and /dev/null differ diff --git a/Engine/lib/flac/test/picture.ok b/Engine/lib/flac/test/picture.ok deleted file mode 100644 index 4b7e55d61..000000000 --- a/Engine/lib/flac/test/picture.ok +++ /dev/null @@ -1,42 +0,0 @@ - -+++ grabbag unit test: picture - -testing grabbag__picture_parse_specification("")... OK (failed as expected, error: error opening picture file) -testing grabbag__picture_parse_specification("||||")... OK (failed as expected: error opening picture file) -testing grabbag__picture_parse_specification("|image/gif|||")... OK (failed as expected: error opening picture file) -testing grabbag__picture_parse_specification("|image/gif|desc|320|0.gif")... OK (failed as expected: invalid picture specification: can't parse resolution/color part) -testing grabbag__picture_parse_specification("|image/gif|desc|320x240|0.gif")... OK (failed as expected: invalid picture specification: can't parse resolution/color part) -testing grabbag__picture_parse_specification("|image/gif|desc|320x240x9|")... OK (failed as expected: error opening picture file) -testing grabbag__picture_parse_specification("|image/gif|desc|320x240x9/2345|0.gif")... OK (failed as expected: invalid picture specification: can't parse resolution/color part) -testing grabbag__picture_parse_specification("1|-->|desc|32x24x9|0.gif")... OK (failed as expected: type 1 icon must be a 32x32 pixel PNG) -testing grabbag__picture_parse_specification("|-->|desc||http://blah.blah.blah/z.gif")... OK (failed as expected: unable to extract resolution and color info from URL, user must set explicitly) -testing grabbag__picture_parse_specification("|-->|desc|320x240x9|http://blah.blah.blah/z.gif")... OK -testing grabbag__picture_parse_specification("pictures/0.gif")... OK -testing grabbag__picture_parse_specification("pictures/1.gif")... OK -testing grabbag__picture_parse_specification("pictures/2.gif")... OK -testing grabbag__picture_parse_specification("pictures/0.jpg")... OK -testing grabbag__picture_parse_specification("pictures/4.jpg")... OK -testing grabbag__picture_parse_specification("pictures/0.png")... OK -testing grabbag__picture_parse_specification("pictures/1.png")... OK -testing grabbag__picture_parse_specification("pictures/2.png")... OK -testing grabbag__picture_parse_specification("pictures/3.png")... OK -testing grabbag__picture_parse_specification("pictures/4.png")... OK -testing grabbag__picture_parse_specification("pictures/5.png")... OK -testing grabbag__picture_parse_specification("pictures/6.png")... OK -testing grabbag__picture_parse_specification("pictures/7.png")... OK -testing grabbag__picture_parse_specification("pictures/8.png")... OK -testing grabbag__picture_parse_specification("3|image/gif|||pictures/0.gif")... OK -testing grabbag__picture_parse_specification("4|image/gif|||pictures/1.gif")... OK -testing grabbag__picture_parse_specification("0|image/gif|||pictures/2.gif")... OK -testing grabbag__picture_parse_specification("3|image/jpeg|||pictures/0.jpg")... OK -testing grabbag__picture_parse_specification("3|image/jpeg|||pictures/4.jpg")... OK -testing grabbag__picture_parse_specification("3|image/png|||pictures/0.png")... OK -testing grabbag__picture_parse_specification("3|image/png|||pictures/1.png")... OK -testing grabbag__picture_parse_specification("3|image/png|||pictures/2.png")... OK -testing grabbag__picture_parse_specification("3|image/png|||pictures/3.png")... OK -testing grabbag__picture_parse_specification("3|image/png|||pictures/4.png")... OK -testing grabbag__picture_parse_specification("3|image/png|||pictures/5.png")... OK -testing grabbag__picture_parse_specification("3|image/png|||pictures/6.png")... OK -testing grabbag__picture_parse_specification("3|image/png|||pictures/7.png")... OK -testing grabbag__picture_parse_specification("999|image/png|||pictures/8.png")... OK -testing grabbag__picture_parse_specification("3|image/gif||320x240x3/2|pictures/0.gif")... OK diff --git a/Engine/lib/flac/test/pictures/0.gif b/Engine/lib/flac/test/pictures/0.gif deleted file mode 100644 index c9f3d71d2..000000000 Binary files a/Engine/lib/flac/test/pictures/0.gif and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/0.jpg b/Engine/lib/flac/test/pictures/0.jpg deleted file mode 100644 index 54b9a7c88..000000000 Binary files a/Engine/lib/flac/test/pictures/0.jpg and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/0.png b/Engine/lib/flac/test/pictures/0.png deleted file mode 100644 index 2f3ec8000..000000000 Binary files a/Engine/lib/flac/test/pictures/0.png and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/1.gif b/Engine/lib/flac/test/pictures/1.gif deleted file mode 100644 index c40eeae83..000000000 Binary files a/Engine/lib/flac/test/pictures/1.gif and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/1.png b/Engine/lib/flac/test/pictures/1.png deleted file mode 100644 index 2b487c07f..000000000 Binary files a/Engine/lib/flac/test/pictures/1.png and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/2.gif b/Engine/lib/flac/test/pictures/2.gif deleted file mode 100644 index 632098be6..000000000 Binary files a/Engine/lib/flac/test/pictures/2.gif and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/2.png b/Engine/lib/flac/test/pictures/2.png deleted file mode 100644 index a7ca42b20..000000000 Binary files a/Engine/lib/flac/test/pictures/2.png and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/3.png b/Engine/lib/flac/test/pictures/3.png deleted file mode 100644 index 9d117b64f..000000000 Binary files a/Engine/lib/flac/test/pictures/3.png and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/4.jpg b/Engine/lib/flac/test/pictures/4.jpg deleted file mode 100644 index da78796c2..000000000 Binary files a/Engine/lib/flac/test/pictures/4.jpg and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/4.png b/Engine/lib/flac/test/pictures/4.png deleted file mode 100644 index 72c0a4523..000000000 Binary files a/Engine/lib/flac/test/pictures/4.png and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/5.png b/Engine/lib/flac/test/pictures/5.png deleted file mode 100644 index abefad599..000000000 Binary files a/Engine/lib/flac/test/pictures/5.png and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/6.png b/Engine/lib/flac/test/pictures/6.png deleted file mode 100644 index 4953ceb65..000000000 Binary files a/Engine/lib/flac/test/pictures/6.png and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/7.png b/Engine/lib/flac/test/pictures/7.png deleted file mode 100644 index c8934c1b0..000000000 Binary files a/Engine/lib/flac/test/pictures/7.png and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/8.png b/Engine/lib/flac/test/pictures/8.png deleted file mode 100644 index 01e411840..000000000 Binary files a/Engine/lib/flac/test/pictures/8.png and /dev/null differ diff --git a/Engine/lib/flac/test/pictures/Makefile.am b/Engine/lib/flac/test/pictures/Makefile.am deleted file mode 100644 index a1bf9e71b..000000000 --- a/Engine/lib/flac/test/pictures/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2006-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -EXTRA_DIST = \ - 0.gif \ - 0.jpg \ - 0.png \ - 1.gif \ - 1.png \ - 2.gif \ - 2.png \ - 3.png \ - 4.jpg \ - 4.png \ - 5.png \ - 6.png \ - 7.png \ - 8.png diff --git a/Engine/lib/flac/test/test_compression.sh b/Engine/lib/flac/test/test_compression.sh deleted file mode 100644 index 60c23993b..000000000 --- a/Engine/lib/flac/test/test_compression.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2012-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -PATH="$(pwd)/../src/flac:$PATH" - -printf "Using FLAC binary : %s\n" "$(which flac)" - -date="$(date "+%Y%m%dT%H%M%S")" -fname="comp${date}.flac" - -last_k=0 -last_size=$(wc -c < noisy-sine.wav) - -echo "Original file size ${last_size} bytes." - -for k in 0 1 2 3 4 5 6 7 8 ; do - flac${EXE} -${k} --silent noisy-sine.wav -o ${fname} - size=$(wc -c < ${fname}) - echo "Compression level ${k}, file size ${size} bytes." - if test ${last_size} -lt ${size} ; then - echo "Error : Compression ${last_k} size ${last_size} >= compression ${k} size ${size}." - exit 1 - fi - # Need this because OSX's 'wc -c' returns a number with leading whitespace. - last_size=$((size+10)) - last_k=${k} - rm -f ${fname} - done diff --git a/Engine/lib/flac/test/test_flac.sh b/Engine/lib/flac/test/test_flac.sh deleted file mode 100644 index df2d10e45..000000000 --- a/Engine/lib/flac/test/test_flac.sh +++ /dev/null @@ -1,1338 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -# we use '.' as decimal separator in --skip/--until tests -export LANG=C LC_ALL=C - -dddie="die ERROR: creating files with dd" - -PATH="$(pwd)/../src/flac:$PATH" -PATH="$(pwd)/../src/metaflac:$PATH" -PATH="$(pwd)/../src/test_streams:$PATH" -PATH="$(pwd)/../objs/$BUILD/bin:$PATH" - -flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" - -run_flac () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_flac.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $* 4>>test_flac.valgrind.log - else - flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $* - fi -} - -run_metaflac () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_flac.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_flac.valgrind.log - else - metaflac${EXE} $* - fi -} - -md5cmp () -{ - n=$( ( [ -f "$1" ] && [ -f "$2" ] && metaflac${EXE} --show-md5sum --no-filename "$1" "$2" 2>/dev/null || exit 1 ) | uniq | wc -l) - [ "$n" != "" ] && [ $n = 1 ] -} - -echo "Checking for --ogg support in flac..." -if flac${EXE} --ogg $TOTTALY_SILENT --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then - has_ogg=yes; - echo "flac --ogg works" -else - has_ogg=no; - echo "flac --ogg doesn't work" -fi - -echo "Generating streams..." -if [ ! -f wacky1.wav ] ; then - test_streams || die "ERROR during test_streams" -fi - -############################################################################ -# test that flac doesn't automatically overwrite files unless -f is used -############################################################################ - -echo "Try encoding to a file that exists; should fail" -cp wacky1.wav exist.wav -touch exist.flac -if run_flac -0 exist.wav ; then - die "ERROR: it should have failed but didn't" -else - echo "OK, it failed as it should" -fi - -echo "Try encoding with -f to a file that exists; should succeed" -if run_flac -0 --force exist.wav ; then - echo "OK, it succeeded as it should" -else - die "ERROR: it should have succeeded but didn't" -fi - -echo "Try decoding to a file that exists; should fail" -if run_flac -d exist.flac ; then - die "ERROR: it should have failed but didn't" -else - echo "OK, it failed as it should" -fi - -echo "Try decoding with -f to a file that exists; should succeed" -if run_flac -d -f exist.flac ; then - echo "OK, it succeeded as it should" -else - die "ERROR: it should have succeeded but didn't" -fi - -rm -f exist.wav exist.flac - -############################################################################ -# test fractional block sizes -############################################################################ - -test_fractional () -{ - blocksize=$1 - samples=$2 - dd if=noise.raw ibs=4 count=$samples of=pbs.raw 2>/dev/null || $dddie - echo $ECHO_N "fractional block size test (blocksize=$blocksize samples=$samples) encode... " $ECHO_C - run_flac --force --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=$blocksize --no-padding --lax -o pbs.flac pbs.raw || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --force-raw-format --endian=little --sign=signed -o pbs.cmp pbs.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp pbs.raw pbs.cmp || die "ERROR: file mismatch" - echo "OK" - rm -f pbs.raw pbs.flac pbs.cmp -} - -# The special significance of 2048 is it's the # of samples that flac calls -# FLAC__stream_encoder_process() on. -# -# We're trying to make sure the 1-sample overread logic in the stream encoder -# (used for last-block checking) works; these values probe around common -# multiples of the flac sample chunk size (2048) and the blocksize. -for samples in 31 32 33 34 35 2046 2047 2048 2049 2050 ; do - test_fractional 33 $samples -done -for samples in 254 255 256 257 258 510 511 512 513 514 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do - test_fractional 256 $samples -done -for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do - test_fractional 2048 $samples -done -for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 4606 4607 4608 4609 4610 8190 8191 8192 8193 8194 16382 16383 16384 16385 16386 ; do - test_fractional 4608 $samples -done - -############################################################################ -# basic 'round-trip' tests of various kinds of streams -############################################################################ - -rt_test_raw () -{ - f="$1" - extra="$2" - channels="$(echo $f | awk -F- '{print $2}')" - bps="$(echo $f | awk -F- '{print $3}')" - sign="$(echo $f | awk -F- '{print $4}')" - - echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C - run_flac --force --verify --force-raw-format --endian=little --sign=$sign --sample-rate=44100 --bps=$bps --channels=$channels --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --force-raw-format --endian=little --sign=$sign -o rt.raw $extra rt.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.raw || die "ERROR: file mismatch" - echo "OK" - rm -f rt.flac rt.raw -} - -rt_test_wav () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C - run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --channel-map=none -o rt.wav $extra rt.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.wav || die "ERROR: file mismatch" - echo "OK" - rm -f rt.flac rt.wav -} - -rt_test_wav_autokf () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C - run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --channel-map=none $extra rt.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.wav || die "ERROR: file mismatch" - echo "OK" - rm -f rt.flac rt.wav -} - -rt_test_w64 () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C - run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --channel-map=none -o rt.w64 $extra rt.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.w64 || die "ERROR: file mismatch" - echo "OK" - rm -f rt.flac rt.w64 -} - -rt_test_w64_autokf () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C - run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --channel-map=none $extra rt.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.w64 || die "ERROR: file mismatch" - echo "OK" - rm -f rt.flac rt.w64 -} - -rt_test_rf64 () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C - run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --channel-map=none -o rt.rf64 $extra rt.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.rf64 || die "ERROR: file mismatch" - echo "OK" - rm -f rt.flac rt.rf64 -} - -rt_test_rf64_autokf () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C - run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --channel-map=none $extra rt.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.rf64 || die "ERROR: file mismatch" - echo "OK" - rm -f rt.flac rt.rf64 -} - -rt_test_aiff () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C - run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --channel-map=none -o rt.aiff $extra rt.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.aiff || die "ERROR: file mismatch" - echo "OK" - rm -f rt.flac rt.aiff -} - -rt_test_autokf () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C - run_flac --force --verify --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode $extra rt.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f $3 || die "ERROR: file mismatch" - echo "OK" - rm -f rt.flac $3 -} - -# assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later -rt_test_flac () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f->flac->flac->wav) encode... " $ECHO_C - run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR" - echo $ECHO_N "re-encode... " $ECHO_C - run_flac --force --verify --lax -o rt2.flac rt.flac || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --channel-map=none -o rt.wav $extra rt2.flac || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.wav || die "ERROR: file mismatch" - echo "OK" - rm -f rt.wav rt.flac rt2.flac -} - -# assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later -rt_test_ogg_flac () -{ - f="$1" - extra="$2" - echo $ECHO_N "round-trip test ($f->oggflac->oggflac->wav) encode... " $ECHO_C - run_flac --force --verify --channel-map=none --no-padding --lax -o rt.oga --ogg $extra $f || die "ERROR" - echo $ECHO_N "re-encode... " $ECHO_C - run_flac --force --verify --lax -o rt2.oga --ogg rt.oga || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac --force --decode --channel-map=none -o rt.wav $extra rt2.oga || die "ERROR" - echo $ECHO_N "compare... " $ECHO_C - cmp $f rt.wav || die "ERROR: file mismatch" - echo "OK" - rm -f rt.wav rt.oga rt2.oga -} - -for f in rt-*.raw ; do - rt_test_raw $f -done -for f in rt-*.wav ; do - rt_test_wav $f -done -for f in rt-*.w64 ; do - rt_test_w64 $f -done -for f in rt-*.rf64 ; do - rt_test_rf64 $f -done -for f in rt-*.aiff ; do - rt_test_aiff $f -done -for f in rt-*.wav ; do - rt_test_flac $f -done -if [ $has_ogg = yes ] ; then - for f in rt-*.wav ; do - rt_test_ogg_flac $f - done -fi - -############################################################################ -# test --skip and --until -############################################################################ - -# -# first make some chopped-up raw files -# -echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw -dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=20 count=30 of=50c.skip20.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=30 count=20 of=50c.skip30.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=40 count=10 of=50c.skip40.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 count=10 of=50c.until10.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 count=20 of=50c.until20.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 count=30 of=50c.until30.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=10 count=20 of=50c.skip10.until30.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie -dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie - -wav_eopt="--force --verify --no-padding --lax" -wav_dopt="--force --decode" - -raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1" -raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed" - -# -# convert them to WAVE/AIFF/Ogg FLAC files -# -convert_to_wav () -{ - run_flac "$2" $1.raw || die "ERROR converting $1.raw to WAVE" - run_flac "$3" $1.flac || die "ERROR converting $1.raw to WAVE" -} -convert_to_wav 50c "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip10 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip11 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip20 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip30 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip40 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.until10 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.until20 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.until30 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.until39 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.until40 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip10.until30 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip10.until39 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip10.until40 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip20.until30 "$raw_eopt" "$wav_dopt" -convert_to_wav 50c.skip20.until40 "$raw_eopt" "$wav_dopt" - -convert_to_aiff () -{ - run_flac "$2" $1.raw || die "ERROR converting $1.raw to AIFF" - run_flac "$3" $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF" -} -convert_to_aiff 50c "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip10 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip11 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip20 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip30 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip40 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.until10 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.until20 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.until30 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.until39 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.until40 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip10.until30 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip10.until39 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip10.until40 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip20.until30 "$raw_eopt" "$wav_dopt" -convert_to_aiff 50c.skip20.until40 "$raw_eopt" "$wav_dopt" - -convert_to_ogg () -{ - run_flac "$wav_eopt" --ogg $1.wav || die "ERROR converting $1.raw to Ogg FLAC" -} -if [ $has_ogg = yes ] ; then - convert_to_ogg 50c - convert_to_ogg 50c.skip10 - convert_to_ogg 50c.skip11 - convert_to_ogg 50c.skip20 - convert_to_ogg 50c.skip30 - convert_to_ogg 50c.skip40 - convert_to_ogg 50c.until10 - convert_to_ogg 50c.until20 - convert_to_ogg 50c.until30 - convert_to_ogg 50c.until39 - convert_to_ogg 50c.until40 - convert_to_ogg 50c.skip10.until30 - convert_to_ogg 50c.skip10.until39 - convert_to_ogg 50c.skip10.until40 - convert_to_ogg 50c.skip20.until30 - convert_to_ogg 50c.skip20.until40 -fi - -test_skip_until () -{ - in_fmt=$1 - out_fmt=$2 - - [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'" - - [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'" - - if [ $in_fmt = raw ] ; then - eopt="$raw_eopt" - dopt="$raw_dopt" - else - eopt="$wav_eopt" - dopt="$wav_dopt" - fi - - if [ $in_fmt = flac -o $in_fmt = ogg ] && [ $out_fmt = flac -o $out_fmt = ogg ]; then - CMP=md5cmp - else - CMP=cmp - fi - - if [ $out_fmt = ogg ] ; then - eopt="--ogg $eopt" - fi - - # - # test --skip when encoding - # - - desc="($in_fmt<->$out_fmt)" - - echo $ECHO_N "testing --skip=# (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc" - rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=mm:ss (encode) $desc... " $ECHO_C - run_flac $eopt --skip=0:01 -o z50c.skip0_01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0_01.$in_fmt z50c.skip0_01.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.$in_fmt z50c.skip0_01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc" - rm -f z50c.skip0_01.$out_fmt z50c.skip0_01.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=mm:ss.sss (encode) $desc... " $ECHO_C - run_flac $eopt --skip=0:01.1001 -o z50c.skip0_01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0_01.1001.$in_fmt z50c.skip0_01.1001.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip11.$in_fmt z50c.skip0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc" - rm -f z50c.skip0_01.1001.$out_fmt z50c.skip0_01.1001.$in_fmt - echo OK - - # - # test --skip when decoding - # - - if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc" - - echo $ECHO_N "testing --skip=# (decode) $desc... " $ECHO_C - run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc" - rm -f z50c.skip10.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=mm:ss (decode) $desc... " $ECHO_C - run_flac $dopt --skip=0:01 -o z50c.skip0_01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.$in_fmt z50c.skip0_01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc" - rm -f z50c.skip0_01.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=mm:ss.sss (decode) $desc... " $ECHO_C - run_flac $dopt --skip=0:01.1001 -o z50c.skip0_01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip11.$in_fmt z50c.skip0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc" - rm -f z50c.skip0_01.1001.$in_fmt - echo OK - - rm -f z50c.$out_fmt - - # - # test --until when encoding - # - - echo $ECHO_N "testing --until=# (encode) $desc... " $ECHO_C - run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc" - rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt - echo OK - - echo $ECHO_N "testing --until=mm:ss (encode) $desc... " $ECHO_C - run_flac $eopt --until=0:04 -o z50c.until0_04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0_04.$in_fmt z50c.until0_04.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.until0_04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc" - rm -f z50c.until0_04.$out_fmt z50c.until0_04.$in_fmt - echo OK - - echo $ECHO_N "testing --until=mm:ss.sss (encode) $desc... " $ECHO_C - run_flac $eopt --until=0:03.9001 -o z50c.until0_03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0_03.9001.$in_fmt z50c.until0_03.9001.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until39.$in_fmt z50c.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc" - rm -f z50c.until0_03.9001.$out_fmt z50c.until0_03.9001.$in_fmt - echo OK - - echo $ECHO_N "testing --until=-# (encode) $desc... " $ECHO_C - run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (encode) $desc" - rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt - echo OK - - echo $ECHO_N "testing --until=-mm:ss (encode) $desc... " $ECHO_C - run_flac $eopt --until=-0:01 -o z50c.until-0_01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-0_01.$in_fmt z50c.until-0_01.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.until-0_01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc" - rm -f z50c.until-0_01.$out_fmt z50c.until-0_01.$in_fmt - echo OK - - echo $ECHO_N "testing --until=-mm:ss.sss (encode) $desc... " $ECHO_C - run_flac $eopt --until=-0:01.1001 -o z50c.until-0_01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-0_01.1001.$in_fmt z50c.until-0_01.1001.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until39.$in_fmt z50c.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc" - rm -f z50c.until-0_01.1001.$out_fmt z50c.until-0_01.1001.$in_fmt - echo OK - - # - # test --until when decoding - # - - if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc" - - echo $ECHO_N "testing --until=# (decode) $desc... " $ECHO_C - run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc" - rm -f z50c.until40.$in_fmt - echo OK - - echo $ECHO_N "testing --until=mm:ss (decode) $desc... " $ECHO_C - run_flac $dopt --until=0:04 -o z50c.until0_04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.until0_04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc" - rm -f z50c.until0_04.$in_fmt - echo OK - - echo $ECHO_N "testing --until=mm:ss.sss (decode) $desc... " $ECHO_C - run_flac $dopt --until=0:03.9001 -o z50c.until0_03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until39.$in_fmt z50c.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc" - rm -f z50c.until0_03.9001.$in_fmt - echo OK - - echo $ECHO_N "testing --until=-# (decode) $desc... " $ECHO_C - run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc" - rm -f z50c.until-10.$in_fmt - echo OK - - echo $ECHO_N "testing --until=-mm:ss (decode) $desc... " $ECHO_C - run_flac $dopt --until=-0:01 -o z50c.until-0_01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.until-0_01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc" - rm -f z50c.until-0_01.$in_fmt - echo OK - - echo $ECHO_N "testing --until=-mm:ss.sss (decode) $desc... " $ECHO_C - run_flac $dopt --until=-0:01.1001 -o z50c.until-0_01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until39.$in_fmt z50c.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc" - rm -f z50c.until-0_01.1001.$in_fmt - echo OK - - rm -f z50c.$out_fmt - - # - # test --skip and --until when encoding - # - - echo $ECHO_N "testing --skip=10 --until=# (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc" - rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=mm:ss (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0_04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until0_04.$in_fmt z50c.skip10.until0_04.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0_04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc" - rm -f z50c.skip10.until0_04.$out_fmt z50c.skip10.until0_04.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=mm:ss.sss (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0_03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until0_03.9001.$in_fmt z50c.skip10.until0_03.9001.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (encode) $desc" - rm -f z50c.skip10.until0_03.9001.$out_fmt z50c.skip10.until0_03.9001.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=+# (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+30.$in_fmt z50c.skip10.until+30.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc" - rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=+mm:ss (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 --until=+0:03 -o z50c.skip10.until+0_03.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+0_03.$in_fmt z50c.skip10.until+0_03.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+0_03.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+0:03 (encode) $desc" - rm -f z50c.skip10.until+0_03.$out_fmt z50c.skip10.until+0_03.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=+mm:ss.sss (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 --until=+0:02.9001 -o z50c.skip10.until+0_02.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+0_02.9001.$in_fmt z50c.skip10.until+0_02.9001.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until+0_02.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+0:02.9001 (encode) $desc" - rm -f z50c.skip10.until+0_02.9001.$out_fmt z50c.skip10.until+0_02.9001.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=-# (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-10.$in_fmt z50c.skip10.until-10.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc" - rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=-mm:ss (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 --until=-0:01 -o z50c.skip10.until-0_01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-0_01.$in_fmt z50c.skip10.until-0_01.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-0_01.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (encode) $desc" - rm -f z50c.skip10.until-0_01.$out_fmt z50c.skip10.until-0_01.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=-mm:ss.sss (encode) $desc... " $ECHO_C - run_flac $eopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0_01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - [ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-0_01.1001.$in_fmt z50c.skip10.until-0_01.1001.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (encode) $desc" - rm -f z50c.skip10.until-0_01.1001.$out_fmt z50c.skip10.until-0_01.1001.$in_fmt - echo OK - - # - # test --skip and --until when decoding - # - - if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc" - - - echo $ECHO_N "testing --skip=10 --until=# (decode) $desc... " $ECHO_C - run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc" - rm -f z50c.skip10.until40.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=mm:ss (decode) $desc... " $ECHO_C - run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0_04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0_04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc" - rm -f z50c.skip10.until0_04.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=mm:ss.sss (decode) $desc... " $ECHO_C - run_flac $dopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0_03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (decode) $desc" - rm -f z50c.skip10.until0_03.9001.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=-# (decode) $desc... " $ECHO_C - run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc" - rm -f z50c.skip10.until-10.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=-mm:ss (decode) $desc... " $ECHO_C - run_flac $dopt --skip=10 --until=-0:01 -o z50c.skip10.until-0_01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-0_01.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (decode) $desc" - rm -f z50c.skip10.until-0_01.$in_fmt - echo OK - - echo $ECHO_N "testing --skip=10 --until=-mm:ss.sss (decode) $desc... " $ECHO_C - run_flac $dopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0_01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until39.$in_fmt z50c.skip10.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (decode) $desc" - rm -f z50c.skip10.until-0_01.1001.$in_fmt - echo OK - - rm -f z50c.$out_fmt -} - -test_skip_until raw flac -test_skip_until wav flac -test_skip_until aiff flac -test_skip_until flac flac -#@@@if [ $has_ogg = yes ] ; then -#@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet -#@@@ test_skip_until ogg flac -#@@@fi - -if [ $has_ogg = yes ] ; then - test_skip_until raw ogg - test_skip_until wav ogg - test_skip_until aiff ogg - #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet - #@@@test_skip_until flac ogg - #@@@test_skip_until ogg ogg -fi - -echo "testing seek extremes:" - -run_flac --verify --force --no-padding --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 noise.raw || die "ERROR generating FLAC file" - -if [ $is_win = no ] ; then - total_noise_cdda_samples="$(run_metaflac --show-total-samples noise.flac)" - [ $? = 0 ] || die "ERROR getting total sample count from noise.flac" -else - # some flavors of cygwin don't seem to treat the \x0d as a word - # separator, so we hard code it. we'll just have to fix it later - # if we change the way noise.flac is made. - total_noise_cdda_samples=393216 -fi - -echo $ECHO_N "testing --skip=0... " $ECHO_C -run_flac $wav_dopt --skip=0 -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac" -echo OK - -for delta in 2 1 ; do - n=$((total_noise_cdda_samples - delta)) - echo $ECHO_N "testing --skip=$n... " $ECHO_C - run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac" - echo OK -done - -rm noise.flac z.wav - -############################################################################ -# test --input-size -############################################################################ - -#@@@ cat will not work on old cygwin, need to fix -if [ $is_win = no ] ; then - echo $ECHO_N "testing --input-size=50 --skip=10... " $ECHO_C - run_flac $raw_eopt --input-size=50 --skip=10 -o z50c.skip10.flac - < 50c.raw || die "ERROR generating FLAC file" - run_flac $raw_dopt -o z50c.skip10.raw z50c.skip10.flac || die "ERROR decoding FLAC file" - cmp 50c.skip10.raw z50c.skip10.raw || die "ERROR: file mismatch for --input-size=50 --skip=10" - rm -f z50c.skip10.raw z50c.skip10.flac - echo OK -fi - -############################################################################ -# test --output-prefix -############################################################################ - -in_dir=./tmp_in -out_dir=./tmp_out -mkdir $in_dir $out_dir || die "ERROR failed to create temp directories" - -cp 50c.raw 50c.flac $in_dir - -# -# test --output-prefix when encoding -# - -echo $ECHO_N "testing --output-prefix=$out_dir/ (encode)... " $ECHO_C -run_flac $raw_eopt --output-prefix=$out_dir/ $in_dir/50c.raw || die "ERROR generating FLAC file in $out_dir (encode)" -[ -f $out_dir/50c.flac ] || die "ERROR FLAC file not in $out_dir (encode)" -run_flac $raw_dopt $out_dir/50c.flac || die "ERROR decoding FLAC file (encode)" -[ -f $out_dir/50c.raw ] || die "ERROR RAW file not in $out_dir (encode)" -cmp 50c.raw $out_dir/50c.raw || die "ERROR: file mismatch for --output-prefix=$out_dir (encode)" -rm -f $out_dir/50c.flac $out_dir/50c.raw -echo OK - -# -# test --ouput-prefix when decoding -# - -echo $ECHO_N "testing --output-prefix=$out_dir/ (decode)... " $ECHO_C -run_flac $raw_dopt --output-prefix=$out_dir/ $in_dir/50c.flac || die "ERROR deocding FLAC file in $out_dir (decode)" -[ -f $out_dir/50c.raw ] || die "ERROR RAW file not in $out_dir (decode)" -run_flac $raw_eopt $out_dir/50c.raw || die "ERROR generating FLAC file (decode)" -[ -f $out_dir/50c.flac ] || die "ERROR FLAC file not in $out_dir (decode)" -cmp 50c.flac $out_dir/50c.flac || die "ERROR: file mismatch for --output-prefix=$out_dir (decode)" -rm -f $out_dir/50c.flac $out_dir/50c.raw -echo OK - -rm -rf $in_dir $out_dir - -############################################################################ -# test --cue -############################################################################ - -# -# create the cue sheet -# -cuesheet=cuetest.cue -cat > $cuesheet << EOF -CATALOG 1234567890123 -FILE "blah" WAVE - TRACK 01 AUDIO - INDEX 01 0 - INDEX 02 10 - INDEX 03 20 - TRACK 02 AUDIO - INDEX 01 30 - TRACK 04 AUDIO - INDEX 01 40 -EOF - -test_cue () -{ - in_fmt=$1 - out_fmt=$2 - - [ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'" - - [ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'" - - if [ $in_fmt = raw ] ; then - eopt="$raw_eopt" - dopt="$raw_dopt" - else - eopt="$wav_eopt" - dopt="$wav_dopt" - fi - - if [ $in_fmt = flac -o $in_fmt = ogg ] && [ $out_fmt = flac -o $out_fmt = ogg ]; then - CMP=md5cmp - else - CMP=cmp - fi - - if [ $out_fmt = ogg ] ; then - eopt="--ogg $eopt" - fi - - desc="($in_fmt<->$out_fmt)" - - # - # for this we need just need just one FLAC file; --cue only works while decoding - # - run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc" - - # To make it easy to translate from cue point to sample numbers, the - # file has a sample rate of 10 Hz and a cuesheet like so: - # - # TRACK 01, INDEX 01 : 0:00.00 -> sample 0 - # TRACK 01, INDEX 02 : 0:01.00 -> sample 10 - # TRACK 01, INDEX 03 : 0:02.00 -> sample 20 - # TRACK 02, INDEX 01 : 0:03.00 -> sample 30 - # TRACK 04, INDEX 01 : 0:04.00 -> sample 40 - # - echo $ECHO_N "testing --cue=- $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=- $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.0 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.0- $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.1 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.1- $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.2 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.2- $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.4 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.4- $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=-5.0 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=-4.1 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=-3.1 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=-1.4 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.0-5.0 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.1-5.0 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.2-4.1 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip10.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - echo $ECHO_N "testing --cue=1.4-2.0 $desc... " $ECHO_C - run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc" - $CMP 50c.skip20.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc" - rm -f z50c.cued.$in_fmt - echo OK - - rm -f z50c.cue.$out_fmt -} - -test_cue raw flac -test_cue wav flac -test_cue aiff flac -test_cue flac flac -#@@@if [ $has_ogg = yes ] ; then -#@@@ #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet -#@@@ test_cue ogg flac -#@@@fi - -if [ $has_ogg = yes ] ; then - test_cue raw ogg - test_cue wav ogg - test_cue aiff ogg - #@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet - #@@@test_cue flac ogg - #@@@test_cue ogg ogg -fi - -############################################################################ -# test 'fixup' code that happens when a FLAC file with total_samples == 0 -# in the STREAMINFO block is converted to WAVE or AIFF, requiring the -# decoder go back and fix up the chunk headers -############################################################################ - -echo $ECHO_N "WAVE fixup test... " $ECHO_C - -echo $ECHO_N "prepare... " $ECHO_C -convert_to_wav noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference WAVE" - -echo $ECHO_N "encode... " $ECHO_C -# the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/ -# binary-mode stdin problem, so we use an undocumented option to metaflac to -# set the total sample count to 0 -if [ $is_win = yes ] ; then - run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file" - run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null -else - run_flac $raw_eopt - -c < noise.raw > fixup.flac || die "ERROR generating FLAC file" -fi - -echo $ECHO_N "decode... " $ECHO_C -run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file" - -echo $ECHO_N "compare... " $ECHO_C -cmp noise.wav fixup.wav || die "ERROR: file mismatch" - -echo OK -rm -f noise.wav fixup.wav fixup.flac - -echo $ECHO_N "AIFF fixup test... " $ECHO_C - -echo $ECHO_N "prepare... " $ECHO_C -convert_to_aiff noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference AIFF" - -echo $ECHO_N "encode... " $ECHO_C -# the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/ -# binary-mode stdin problem, so we use an undocumented option to metaflac to -# set the total sample count to 0 -if [ $is_win = yes ] ; then - run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file" - run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null -else - run_flac $raw_eopt - -c < noise.raw > fixup.flac || die "ERROR generating FLAC file" -fi - -echo $ECHO_N "decode... " $ECHO_C -run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file" - -echo $ECHO_N "compare... " $ECHO_C -cmp noise.aiff fixup.aiff || die "ERROR: file mismatch" - -echo OK -rm -f noise.aiff fixup.aiff fixup.flac - - -############################################################################ -# multi-file tests -############################################################################ - -echo "Generating multiple input files from noise..." -multifile_format_decode="--endian=big --sign=signed" -multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2 --no-padding" -short_noise_cdda_samples=$((total_noise_cdda_samples / 8)) -run_flac --verify --force --force-raw-format $multifile_format_encode --until=$short_noise_cdda_samples -o shortnoise.flac noise.raw || die "ERROR generating FLAC file" -run_flac --decode --force shortnoise.flac -o shortnoise.raw --force-raw-format $multifile_format_decode || die "ERROR generating RAW file" -run_flac --decode --force shortnoise.flac || die "ERROR generating WAVE file" -run_flac --decode --force shortnoise.flac -o shortnoise.aiff || die "ERROR generating AIFF file" -cp shortnoise.flac file0.flac -cp shortnoise.flac file1.flac -cp shortnoise.flac file2.flac -rm -f shortnoise.flac -cp shortnoise.wav file0.wav -cp shortnoise.wav file1.wav -cp shortnoise.wav file2.wav -rm -f shortnoise.wav -cp shortnoise.aiff file0.aiff -cp shortnoise.aiff file1.aiff -cp shortnoise.aiff file2.aiff -rm -f shortnoise.aiff -cp shortnoise.raw file0.raw -cp shortnoise.raw file1.raw -cp shortnoise.raw file2.raw -rm -f shortnoise.raw - -test_multifile () -{ - input_type=$1 - streamtype=$2 - encode_options="$3" - - extra_encode_options="" - extra_decode_options="" - if [ $input_type = "raw" ] ; then - extra_encode_options="--force-raw-format $multifile_format_encode" - extra_decode_options="--force-raw-format $multifile_format_decode" - else - if [ $input_type = "aiff" ] ; then - extra_decode_options="--force-aiff-format" - fi - fi - - if [ $streamtype = ogg ] ; then - suffix=oga - encode_options="$encode_options --ogg" - else - suffix=flac - fi - - if [ $input_type = flac ] || [ $input_type = ogg ] ; then - CMP=md5cmp - else - CMP=cmp - fi - - for n in 0 1 2 ; do - cp file$n.$input_type file${n}x.$input_type - done - run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR" - run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR" - for n in 0 1 2 ; do - $CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n" - done - for n in 0 1 2 ; do - rm -f file${n}x.$suffix file${n}x.$input_type - done -} - -input_types="raw wav aiff flac" -#@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet -#@@@if [ $has_ogg = yes ] ; then -#@@@ input_types="$input_types ogg" -#@@@fi -for input_type in $input_types ; do - echo "Testing multiple $input_type files without verify..." - test_multifile $input_type flac "" - - echo "Testing multiple $input_type files with verify..." - test_multifile $input_type flac "--verify" - - if [ $has_ogg = yes ] ; then - echo "Testing multiple $input_type files with --ogg, without verify..." - test_multifile $input_type ogg "" - - echo "Testing multiple $input_type files with --ogg, with verify..." - test_multifile $input_type ogg "--verify" - - echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..." - test_multifile $input_type ogg "--serial-number=321 --verify" - fi -done - - -############################################################################ -# test --keep-foreign-metadata -############################################################################ - -echo "Testing --keep-foreign-metadata..." - -rt_test_wav wacky1.wav '--keep-foreign-metadata' -rt_test_wav wacky2.wav '--keep-foreign-metadata' -rt_test_w64 wacky1.w64 '--keep-foreign-metadata' -rt_test_w64 wacky2.w64 '--keep-foreign-metadata' -rt_test_rf64 wacky1.rf64 '--keep-foreign-metadata' -rt_test_rf64 wacky2.rf64 '--keep-foreign-metadata' - -rt_test_wav_autokf wacky1.wav '--keep-foreign-metadata' -rt_test_wav_autokf wacky2.wav '--keep-foreign-metadata' -rt_test_w64_autokf wacky1.w64 '--keep-foreign-metadata' -rt_test_w64_autokf wacky2.w64 '--keep-foreign-metadata' -rt_test_rf64_autokf wacky1.rf64 '--keep-foreign-metadata' -rt_test_rf64_autokf wacky2.rf64 '--keep-foreign-metadata' - -testdatadir=${top_srcdir}/test/foreign-metadata-test-files - -rt_test_autokf "$testdatadir/BWF-WaveFmtEx.wav" '--keep-foreign-metadata' 'rt.wav' -rt_test_autokf "$testdatadir/AIFF-ID3.aiff" '--keep-foreign-metadata' 'rt.aiff' -rt_test_autokf "$testdatadir/AIFF-C-sowt-tag.aifc" '--keep-foreign-metadata' 'rt.aifc' -rt_test_autokf "$testdatadir/AIFF-C-sowt-compression-type-name.aifc" '--keep-foreign-metadata' 'rt.aifc' -rt_test_autokf "$testdatadir/24bit-WaveFmtPCM.wav" '--keep-foreign-metadata' 'rt.wav' - -############################################################################ -# test the metadata-handling properties of flac-to-flac encoding -############################################################################ - -echo "Testing the metadata-handling properties of flac-to-flac encoding..." - -testdatadir=${top_srcdir}/test/flac-to-flac-metadata-test-files - -filter () -{ - # minor danger, changing vendor strings might change the length of the - # VORBIS_COMMENT block, but if we add "^ length: " to the patterns, - # we lose info about PADDING size that we need - grep -Ev '^ vendor string: |^ m..imum .....size: ' | sed -e 's/, stream_offset.*//' -} -flac2flac () -{ - file="$testdatadir/$1" - case="$testdatadir/$2" - args="$3" - expect="$case-expect.meta" - echo $ECHO_N "$2... " $ECHO_C - # The 'make distcheck' target needs this. - chmod u+w $file - run_flac -f -o out.flac $args $file || die "ERROR encoding FLAC file" - run_metaflac --list out.flac | filter > out1.meta || die "ERROR listing metadata of output FLAC file" - # Ignore lengths which can be affected by the version string. - sed "s/length:.*/length: XXX/" out1.meta > out.meta - diff -q -w $expect out.meta 2>/dev/null || die "ERROR: metadata does not match expected $expect" - echo OK -} - -#filter=', stream_offset.*|^ vendor string: |^ length: |^ m..imum .....size: ' - -# case 00a: no alterations on a file with all metadata types, keep all metadata, in same order -flac2flac input-SCVAUP.flac case00a "" -# case 01a: on file with multiple PADDING blocks, they should be aggregated into one at the end -flac2flac input-SCVPAP.flac case01a "" -# case 01b: on file with multiple PADDING blocks and --no-padding specified, they should all be deleted -flac2flac input-SCVPAP.flac case01b "--no-padding" -# case 01c: on file with multiple PADDING blocks and -P specified, they should all be overwritten with -P value -flac2flac input-SCVPAP.flac case01c "-P 1234" -# case 01d: on file with no PADDING blocks, use -P setting -flac2flac input-SCVA.flac case01d "-P 1234" -# case 01e: on file with no PADDING blocks and no -P given, use default padding -flac2flac input-SCVA.flac case01e "" -# case 02a: on file with no VORBIS_COMMENT block, add new VORBIS_COMMENT -flac2flac input-SCPAP.flac case02a "" -# case 02b: on file with no VORBIS_COMMENT block and --tag, add new VORBIS_COMMENT with tags -flac2flac input-SCPAP.flac case02b "--tag=artist=0" -# case 02c: on file with VORBIS_COMMENT block and --tag, replace existing VORBIS_COMMENT with new tags -flac2flac input-SCVAUP.flac case02c "--tag=artist=0" -# case 03a: on file with no CUESHEET block and --cuesheet specified, add it -flac2flac input-SVAUP.flac case03a "--cuesheet=$testdatadir/input0.cue" -# case 03b: on file with CUESHEET block and --cuesheet specified, overwrite existing CUESHEET -flac2flac input-SCVAUP.flac case03b "--cuesheet=$testdatadir/input0.cue" -# case 03c: on file with CUESHEET block and size-changing option specified, drop existing CUESHEET -flac2flac input-SCVAUP.flac case03c "--skip=1" -# case 04a: on file with no SEEKTABLE block and --no-seektable specified, no SEEKTABLE -flac2flac input-VA.flac case04a "--no-padding --no-seektable" -# case 04b: on file with no SEEKTABLE block and -S specified, new SEEKTABLE -flac2flac input-VA.flac case04b "--no-padding -S 5x" -# case 04c: on file with no SEEKTABLE block and no seektable options specified, new SEEKTABLE with default points -flac2flac input-VA.flac case04c "--no-padding" -# case 04d: on file with SEEKTABLE block and --no-seektable specified, drop existing SEEKTABLE -flac2flac input-SCVA.flac case04d "--no-padding --no-seektable" -# case 04e: on file with SEEKTABLE block and -S specified, overwrite existing SEEKTABLE -flac2flac input-SCVA.flac case04e "--no-padding -S 5x" -# case 04f: on file with SEEKTABLE block and size-changing option specified, drop existing SEEKTABLE, new SEEKTABLE with default points -#(already covered by case03c) - -############################################################################ -# test limiting minimum bitrate -############################################################################ - -echo $ECHO_N "Testing --limit-min-bitrate" $ECHO_C - -run_flac -f -o out.flac --no-padding --no-seektable --limit-min-bitrate "$testdatadir/input-VA.flac" -size=$(wc -c < out.flac) - -if [ "$size" -lt "1022" ]; then - die "ERROR: filesize of flac file encoded with --limit-min-bitrate is smaller than expected" -fi - -echo OK - -############################################################################ -# test overflow of total samples field in STREAMINFO -############################################################################ - -test_total_samples_overflow () -{ - total_samples=$1 - expected_stored_total_samples=$2 - echo $ECHO_N "total_samples overflow test (samples=$total_samples) encode... " $ECHO_C - head -c $total_samples /dev/zero | run_flac --force --verify --sign=signed --sample-rate=96000 -b 16384 --channels=1 --endian=little --bps=8 -o big-$total_samples.flac - || die "ERROR" - echo $ECHO_N "decode... " $ECHO_C - run_flac -t big-$total_samples.flac || die "ERROR" - echo $ECHO_N "check... " $ECHO_C - run_metaflac --show-total-samples big-$total_samples.flac > big-$total_samples.cmp1 - echo $expected_stored_total_samples > big-$total_samples.cmp2 - diff -q -w big-$total_samples.cmp1 big-$total_samples.cmp2 || die "ERROR" - echo "OK" - rm -f big-$total_samples.flac big-$total_samples.cmp1 big-$total_samples.cmp2 -} - -if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then - test_total_samples_overflow 68719476735 68719476735 - test_total_samples_overflow 68719476736 0 - test_total_samples_overflow 68719476737 0 -fi - -############################################################################ -# test handling of UTF-8 filenames -############################################################################ - - -test_utf8_handling () -{ - echo $ECHO_N "Test decoding from $1... " $ECHO_C - run_flac -d $testdatadir/$1 -o out.wav - if [ -f out.wav ] ; then - echo "OK" - else - die "Decoding failed" - fi - echo $ECHO_N "Test encoding to $1... " $ECHO_C - run_flac out.wav -o $1 - if [ -f $1 ] ; then - echo "OK" - else - die "Encoding failed" - fi - rm -f $1 out.wav -} - -if [ "$WIN32BUSYBOX" != "yes" ]; then - test_utf8_handling שלום.flac - test_utf8_handling 🤔.flac - test_utf8_handling Prøve.flac -fi - -rm -f out.flac out.meta out1.meta - -#@@@ when metaflac handles ogg flac, duplicate flac2flac tests here - -cd .. diff --git a/Engine/lib/flac/test/test_grabbag.sh b/Engine/lib/flac/test/test_grabbag.sh deleted file mode 100644 index 6f2aca121..000000000 --- a/Engine/lib/flac/test/test_grabbag.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -PATH=../src/test_grabbag/cuesheet:$PATH -PATH=../src/test_grabbag/picture:$PATH -PATH=../objs/$BUILD/bin:$PATH - -test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable" -test_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable" - -run_test_cuesheet () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_cuesheet $*" >>test_grabbag.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_cuesheet${EXE} $* 4>>test_grabbag.valgrind.log - else - test_cuesheet${EXE} $* - fi -} - -run_test_picture () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_picture $*" >>test_grabbag.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_picture${EXE} $* 4>>test_grabbag.valgrind.log - else - test_picture${EXE} $* - fi -} - -######################################################################## -# -# test_picture -# -######################################################################## - -log=picture.log -picture_dir=${top_srcdir}/test/pictures - -echo "Running test_picture..." - -rm -f $log - -run_test_picture $picture_dir >> $log 2>&1 - -if [ $is_win = yes ] ; then - diff -w ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff" -else - diff ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff" -fi - -echo "PASSED (results are in $log)" - -######################################################################## -# -# test_cuesheet -# -######################################################################## - -log=cuesheet.log -bad_cuesheets=${top_srcdir}/test/cuesheets/bad.*.cue -good_cuesheets=${top_srcdir}/test/cuesheets/good.*.cue -good_leadout=$((80 * 60 * 44100)) -bad_leadout=$((good_leadout + 1)) - -echo "Running test_cuesheet..." - -rm -f $log - -# -# negative tests -# -for cuesheet in $bad_cuesheets ; do - echo "NEGATIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1 - run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 || exit_code=$? - if [ "$exit_code" = 255 ] ; then - die "Error: test script is broken" - fi - cuesheet_pass1=${cuesheet}.1 - cuesheet_pass2=${cuesheet}.2 - rm -f $cuesheet_pass1 $cuesheet_pass2 -done - -# -# positive tests -# -for cuesheet in $good_cuesheets ; do - echo "POSITIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1 - run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 - exit_code=$? - if [ "$exit_code" = 255 ] ; then - die "Error: test script is broken" - elif [ "$exit_code" != 0 ] ; then - die "Error: good cuesheet is broken" - fi - cuesheet_out=$(echo $cuesheet | sed "s|${top_srcdir}/test/||") - cuesheet_pass1=${cuesheet_out}.1 - cuesheet_pass2=${cuesheet_out}.2 - diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ" - rm -f $cuesheet_pass1 $cuesheet_pass2 -done - -if [ $is_win = yes ] ; then - diff -w ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff" -else - diff ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff" -fi - -echo "PASSED (results are in $log)" diff --git a/Engine/lib/flac/test/test_libFLAC++.sh b/Engine/lib/flac/test/test_libFLAC++.sh deleted file mode 100644 index 089ec1653..000000000 --- a/Engine/lib/flac/test/test_libFLAC++.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -PATH=../src/test_libFLAC++:$PATH -PATH=../objs/$BUILD/bin:$PATH - -run_test_libFLACpp () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_libFLAC++${EXE} $* 4>>test_libFLAC++.valgrind.log - else - test_libFLAC++${EXE} $* - fi -} - -run_test_libFLACpp "$@" || die "ERROR during test_libFLAC++" diff --git a/Engine/lib/flac/test/test_libFLAC.sh b/Engine/lib/flac/test/test_libFLAC.sh deleted file mode 100644 index a3a1f0e51..000000000 --- a/Engine/lib/flac/test/test_libFLAC.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -PATH=../src/test_libFLAC:$PATH -PATH=../objs/$BUILD/bin:$PATH - -run_test_libFLAC () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_libFLAC${EXE} $* 4>>test_libFLAC.valgrind.log - else - test_libFLAC${EXE} $* - fi -} - -run_test_libFLAC "$@"|| die "ERROR during test_libFLAC" diff --git a/Engine/lib/flac/test/test_metaflac.sh b/Engine/lib/flac/test/test_metaflac.sh deleted file mode 100644 index b2dbee07a..000000000 --- a/Engine/lib/flac/test/test_metaflac.sh +++ /dev/null @@ -1,478 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -PATH="$(pwd)/../src/flac:$PATH" -PATH="$(pwd)/../src/metaflac:$PATH" -PATH="$(pwd)/../objs/$BUILD/bin:$PATH" - -if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then EGREP='grep -E' - else EGREP='egrep' -fi - -testdir="metaflac-test-files" -flacfile="metaflac1.flac" - -flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" -metaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable" - -run_flac () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_metaflac.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} ${TOTALLY_SILENT} --no-error-on-compression-fail $* 4>>test_metaflac.valgrind.log - else - flac${EXE} ${TOTALLY_SILENT} --no-error-on-compression-fail $* - fi -} - -run_metaflac () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_metaflac.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_metaflac.valgrind.log - else - metaflac${EXE} $* - fi -} - -run_metaflac_silent () -{ - if [ -z "$SILENT" ] ; then - run_metaflac $* - else - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_metaflac.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 2>/dev/null 4>>test_metaflac.valgrind.log - else - metaflac${EXE} $* 2>/dev/null - fi - fi -} - -run_metaflac_to_metaflac_silent () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_metaflac.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 2>/dev/null 4>>test_metaflac.valgrind.log - else - metaflac${EXE} $1 | metaflac${EXE} $2 2>/dev/null - fi -} - - -check_flac () -{ - run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2 -} - -echo "Generating stream..." -bytes=80000 -if dd if=/dev/zero ibs=1 count=$bytes 2>/dev/null | flac${EXE} ${TOTALLY_SILENT} --force --verify -0 --input-size=$bytes --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=8000 - ; then - chmod +w $flacfile -else - die "ERROR during generation" -fi - -check_flac - -testdatadir=${top_srcdir}/test/metaflac-test-files - -filter () -{ - # minor danger, changing vendor strings will change the length of the - # VORBIS_COMMENT block, but if we add "^ length: " to the patterns, - # we lose info about PADDING size that we need - # grep pattern 1: remove vendor string - # grep pattern 2: remove minimum/maximum frame and block size from STREAMINFO - # grep pattern 3: remove hexdump data from PICTURE metadata blocks - # sed pattern 1: remove stream offset values from SEEKTABLE points - $EGREP -v '^ vendor string: |^ m..imum .....size: |^ 0000[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]: ' \ - | sed -e 's/, stream_offset.*//' -} -metaflac_test () -{ - case="$testdatadir/$1" - desc="$2" - args="$3" - expect="$case-expect.meta" - echo $ECHO_N "test $1: $desc... " $ECHO_C - run_metaflac $args $flacfile | filter > $testdir/out1.meta || die "ERROR running metaflac" - # Ignore lengths which can be affected by the version string. - sed "s/length:.*/length: XXX/" $testdir/out1.meta > $testdir/out.meta - diff -w $expect $testdir/out.meta > /dev/null 2>&1 || die "ERROR: metadata does not match expected $expect" - # To blindly accept (and check later): cp -f $testdir/out.meta $expect - echo OK -} - -metaflac_test_nofilter () -{ - case="$testdatadir/$1" - desc="$2" - args="$3" - expect="$case-expect.meta" - echo $ECHO_N "test $1: $desc... " $ECHO_C - run_metaflac $args $flacfile > $testdir/out.meta || die "ERROR running metaflac" - diff -w $expect $testdir/out.meta || die "ERROR: metadata does not match expected $expect" - echo OK -} - -metaflac_test_binary () -{ - case="$testdatadir/$1" - desc="$2" - args="$3" - expect="$case-expect.meta" - echo $ECHO_N "test $1: $desc... " $ECHO_C - run_metaflac $args $flacfile > $testdir/out.meta || die "ERROR running metaflac" - cmp $expect $testdir/out.meta || die "ERROR: metadata does not match expected $expect" - echo OK -} - -metaflac_test case00 "--list" "--list" - -metaflac_test case01 "STREAMINFO --show-* shortcuts" " - --show-md5sum - --show-min-blocksize - --show-max-blocksize - --show-min-framesize - --show-max-framesize - --show-sample-rate - --show-channels - --show-bps - --show-total-samples" - -run_metaflac --preserve-modtime --add-padding=12345 $flacfile -check_flac -metaflac_test case02 "--add-padding" "--list" - -# some flavors of /bin/sh (e.g. Darwin's) won't even handle quoted spaces, so we underscore: -run_metaflac --set-tag="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile -check_flac -metaflac_test case03 "--set-tag=ARTIST" "--list" - -run_metaflac --set-tag="ARTIST=Chuck_Woolery" $flacfile -check_flac -metaflac_test case04 "--set-tag=ARTIST" "--list" - -run_metaflac --set-tag="ARTIST=Vern" $flacfile -check_flac -metaflac_test case05 "--set-tag=ARTIST" "--list" - -run_metaflac --set-tag="TITLE=He_who_smelt_it_dealt_it" $flacfile -check_flac -metaflac_test case06 "--set-tag=TITLE" "--list" - -if [ ! $git_commit_version_hash ] ; then - metaflac_test case07 "--show-vendor-tag --show-tag=ARTIST" "--show-vendor-tag --show-tag=ARTIST" -else - echo "test case07 is skipped because version is taken from git" -fi - -run_metaflac --remove-first-tag=ARTIST $flacfile -check_flac -metaflac_test case08 "--remove-first-tag=ARTIST" "--list" - -run_metaflac --remove-tag=ARTIST $flacfile -check_flac -metaflac_test case09 "--remove-tag=ARTIST" "--list" - -metaflac_test case10 "--list --block-type=VORBIS_COMMENT" "--list --block-type=VORBIS_COMMENT" -metaflac_test case11 "--list --block-number=0" "--list --block-number=0" -metaflac_test case12 "--list --block-number=1,2,999" "--list --block-number=1,2,999" -metaflac_test case13 "--list --block-type=VORBIS_COMMENT,PADDING" "--list --block-type=VORBIS_COMMENT,PADDING" -metaflac_test case14 "--list --except-block-type=SEEKTABLE,VORBIS_COMMENT" "--list --except-block-type=SEEKTABLE,VORBIS_COMMENT" -metaflac_test case15 "--list --except-block-type=STREAMINFO" "--list --except-block-type=STREAMINFO" - -run_metaflac --add-padding=4321 $flacfile $flacfile -check_flac -metaflac_test case16 "--add-padding=4321 * 2" "--list" - -run_metaflac --merge-padding $flacfile -check_flac -metaflac_test case17 "--merge-padding" "--list" - -run_metaflac --add-padding=0 $flacfile -check_flac -metaflac_test case18 "--add-padding=0" "--list" - -run_metaflac --sort-padding $flacfile -check_flac -metaflac_test case19 "--sort-padding" "--list" - -run_metaflac --add-padding=0 $flacfile -check_flac -metaflac_test case20 "--add-padding=0" "--list" - -run_metaflac --remove-all-tags $flacfile -check_flac -metaflac_test case21 "--remove-all-tags" "--list" - -run_metaflac --remove --block-number=1,99 --dont-use-padding $flacfile -check_flac -metaflac_test case22 "--remove --block-number=1,99 --dont-use-padding" "--list" - -run_metaflac --remove --block-number=99 --dont-use-padding $flacfile -check_flac -metaflac_test case23 "--remove --block-number=99 --dont-use-padding" "--list" - -run_metaflac --remove --block-type=PADDING $flacfile -check_flac -metaflac_test case24 "--remove --block-type=PADDING" "--list" - -run_metaflac --remove --block-type=PADDING --dont-use-padding $flacfile -check_flac -metaflac_test case25 "--remove --block-type=PADDING --dont-use-padding" "--list" - -run_metaflac --add-padding=0 $flacfile $flacfile -check_flac -metaflac_test case26 "--add-padding=0 * 2" "--list" - -run_metaflac --remove --except-block-type=PADDING $flacfile -check_flac -metaflac_test case27 "--remove --except-block-type=PADDING" "--list" - -run_metaflac --remove-all $flacfile -check_flac -metaflac_test case28 "--remove-all" "--list" - -run_metaflac --remove-all --dont-use-padding $flacfile -check_flac -metaflac_test case29 "--remove-all --dont-use-padding" "--list" - -run_metaflac --remove-all --dont-use-padding $flacfile -check_flac -metaflac_test case30 "--remove-all --dont-use-padding" "--list" - -run_metaflac --set-tag="f=0123456789abcdefghij" $flacfile -check_flac -metaflac_test case31 "--set-tag=..." "--list" - -run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile -check_flac -metaflac_test case32 "--remove-all-tags --set-tag=..." "--list" - -run_metaflac --remove-all-tags --set-tag="f=0123456789abcde" $flacfile -check_flac -metaflac_test case33 "--remove-all-tags --set-tag=..." "--list" - -run_metaflac --remove-all-tags --set-tag="f=0" $flacfile -check_flac -metaflac_test case34 "--remove-all-tags --set-tag=..." "--list" - -run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile -check_flac -metaflac_test case35 "--remove-all-tags --set-tag=..." "--list" - -run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile -check_flac -metaflac_test case36 "--remove-all-tags --set-tag=..." "--list" - -run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile -check_flac -metaflac_test case37 "--remove-all-tags --set-tag=..." "--list" - -run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghij" $flacfile -check_flac -metaflac_test case38 "--remove-all-tags --set-tag=..." "--list" - -echo "TITLE=Tittle" | run_metaflac --import-tags-from=- $flacfile -check_flac -metaflac_test case39 "--import-tags-from=-" "--list" - -cat > vc.txt << EOF -artist=Fartist -artist=artits -EOF -run_metaflac --import-tags-from=vc.txt $flacfile -check_flac -metaflac_test case40 "--import-tags-from=[FILE]" "--list" - -rm vc.txt - -run_metaflac --add-replay-gain $flacfile -check_flac -metaflac_test case41 "--add-replay-gain" "--list" - -run_metaflac --remove-replay-gain $flacfile -check_flac -metaflac_test case42 "--remove-replay-gain" "--list" - -run_metaflac --scan-replay-gain $flacfile -check_flac -metaflac_test case42 "--scan-replay-gain" "--list" - -# CUESHEET blocks -cs_in=${top_srcdir}/test/cuesheets/good.000.cue -cs_out=metaflac.cue -cs_out2=metaflac2.cue -run_metaflac --import-cuesheet-from="$cs_in" $flacfile -check_flac -metaflac_test case43 "--import-cuesheet-from" "--list" -run_metaflac --export-cuesheet-to=$cs_out $flacfile -run_metaflac --remove --block-type=CUESHEET $flacfile -check_flac -metaflac_test case44 "--remove --block-type=CUESHEET" "--list" -run_metaflac --import-cuesheet-from=$cs_out $flacfile -check_flac -metaflac_test case45 "--import-cuesheet-from" "--list" -run_metaflac --export-cuesheet-to=$cs_out2 $flacfile -echo "comparing cuesheets:" -diff $cs_out $cs_out2 || die "ERROR, cuesheets should be identical" -echo identical - -rm -f $cs_out $cs_out2 - -# PICTURE blocks -ncase=46 -for f in \ - 0.gif \ - 1.gif \ - 2.gif \ -; do - run_metaflac --import-picture-from="|image/gif|$f||${top_srcdir}/test/pictures/$f" $flacfile - check_flac - metaflac_test "case$ncase" "--import-picture-from" "--list" - ncase=$((ncase + 1)) -done -for f in \ - 0.jpg \ - 4.jpg \ -; do - run_metaflac --import-picture-from="4|image/jpeg|$f||${top_srcdir}/test/pictures/$f" $flacfile - check_flac - metaflac_test "case$ncase" "--import-picture-from" "--list" - ncase=$((ncase + 1)) -done -for f in \ - 0.png \ - 1.png \ - 2.png \ - 3.png \ - 4.png \ - 5.png \ - 6.png \ - 7.png \ - 8.png \ -; do - run_metaflac --import-picture-from="5|image/png|$f||${top_srcdir}/test/pictures/$f" $flacfile - check_flac - metaflac_test "case$ncase" "--import-picture-from" "--list" - ncase=$((ncase + 1)) -done -[ $ncase = 60 ] || die "expected case# to be 60" - -fn=export-picture-check -echo $ECHO_N "Testing --export-picture-to... " $ECHO_C -run_metaflac --export-picture-to=$fn $flacfile -check_flac -cmp $fn ${top_srcdir}/test/pictures/0.gif || die "ERROR, exported picture file and original differ" -echo OK -rm -f $fn -echo $ECHO_N "Testing --block-number --export-picture-to... " $ECHO_C -run_metaflac --block-number=9 --export-picture-to=$fn $flacfile -check_flac -cmp $fn ${top_srcdir}/test/pictures/0.png || die "ERROR, exported picture file and original differ" -echo OK -rm -f $fn - -run_metaflac --remove --block-type=PICTURE $flacfile -check_flac -metaflac_test case60 "--remove --block-type=PICTURE" "--list" -run_metaflac --import-picture-from="1|image/png|standard_icon|32x32x24|${top_srcdir}/test/pictures/0.png" $flacfile -check_flac -metaflac_test case61 "--import-picture-from" "--list" -run_metaflac --import-picture-from="2|image/png|icon|64x64x24|${top_srcdir}/test/pictures/1.png" $flacfile -check_flac -metaflac_test case62 "--import-picture-from" "--list" -run_metaflac --remove-all-tags-except=artist=title $flacfile -check_flac -metaflac_test case63 "--remove-all-tags-except=artist=title" "--list" -metaflac_test case64 "--export-tags-to=-" "--export-tags-to=-" -metaflac_test case64 "--show-all-tags" "--show-all-tags" - -run_flac ${top_srcdir}/test/foreign-metadata-test-files/AIFF-ID3.aiff --keep-foreign-metadata -f -o $flacfile -metaflac_test_binary case65 "--data-format=binary" "--list --data-format=binary-headerless --block-type=APPLICATION:aiff" - -# UNKNOWN blocks -flacfile=metaflac2.flac -echo $ECHO_N "Testing FLAC file with unknown metadata... " $ECHO_C -cp -p ${top_srcdir}/test/metaflac.flac.in $flacfile -# remove the VORBIS_COMMENT block so vendor string changes don't interfere with the comparison: -run_metaflac --remove --block-type=VORBIS_COMMENT --dont-use-padding $flacfile -cmp $flacfile ${top_srcdir}/test/metaflac.flac.ok || die "ERROR, $flacfile and metaflac.flac.ok differ" -echo OK - -flacfile=metaflac3.flac -cp -p ${top_srcdir}/test/metaflac.flac.in $flacfile - -flacfile2=metaflac4.flac -cp $flacfile $flacfile2 -run_metaflac --remove-all --dont-use-padding $flacfile - -echo $ECHO_N "Appending a streaminfo metadata block... " $ECHO_C -if run_metaflac_to_metaflac_silent "--list --data-format=binary $flacfile2" "--append $flacfile" ; then - die "ERROR: it should have failed but didn't" -else - echo "OK, it failed as it should" -fi - -echo $ECHO_N "Appending a seektable metadata block... " $ECHO_C -if run_metaflac_to_metaflac_silent "--list --data-format=binary --except-block-type=STREAMINFO $flacfile2" "--append $flacfile" ; then - die "ERROR: it should have failed but didn't" -else - echo "OK, it failed as it should" -fi - -run_metaflac --add-seekpoint=0 $flacfile - -echo $ECHO_N "Appending a vorbis comment metadata block... " $ECHO_C -if run_metaflac_to_metaflac_silent "--list --data-format=binary --block-type=VORBIS_COMMENT $flacfile2" "--append $flacfile" ; then - echo "OK" -else - die "ERROR, couldn't add vorbis comment metadata block" -fi - -echo $ECHO_N "Appending another vorbis comment metadata block... " $ECHO_C -if run_metaflac_to_metaflac_silent "--list --data-format=binary --block-type=VORBIS_COMMENT $flacfile2" "--append $flacfile" ; then - die "ERROR: it should have failed but didn't" -else - echo "OK, it failed as it should" -fi - -if run_metaflac_to_metaflac_silent "--list --data-format=binary --except-block-type=STREAMINFO,SEEKTABLE,VORBIS_COMMENT $flacfile2" "--append $flacfile" ; then - : -else - die "ERROR, couldn't add vorbis comment metadata block" -fi - -metaflac_test_nofilter case66 "--append" "--list" - -if run_metaflac_to_metaflac_silent "--list --data-format=binary --except-block-type=STREAMINFO,SEEKTABLE,VORBIS_COMMENT $flacfile2" "--append --block-number=0 $flacfile" ; then - : -else - die "ERROR, couldn't add vorbis comment metadata block" -fi - -metaflac_test_nofilter case67 "--append --block-number=0" "--list" - -rm -f metaflac-test-files/out.meta metaflac-test-files/out1.meta diff --git a/Engine/lib/flac/test/test_replaygain.sh b/Engine/lib/flac/test/test_replaygain.sh deleted file mode 100644 index 69ed99309..000000000 --- a/Engine/lib/flac/test/test_replaygain.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2002-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -PATH="$(pwd)/../src/flac:$PATH" -PATH="$(pwd)/../src/metaflac:$PATH" -PATH="$(pwd)/../objs/$BUILD/bin:$PATH" - -if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then EGREP='grep -E' - else EGREP='egrep' -fi - -testdir="metaflac-test-files" -flacfile="replaygain.flac" - -run_flac () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_replaygain.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac --no-error-on-compression-fail $* 4>>test_replaygain.valgrind.log - else - flac${EXE} --no-error-on-compression-fail $* - fi -} - -run_metaflac () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_replaygain.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 4>>test_replaygain.valgrind.log - else - metaflac${EXE} $* - fi -} - -run_metaflac_silent () -{ - if [ -z "$SILENT" ] ; then - run_metaflac $* - else - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_replaygain.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 2>/dev/null 4>>test_replaygain.valgrind.log - else - metaflac${EXE} $* 2>/dev/null - fi - fi -} - -check_flac () -{ - run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2 -} - -echo "Generating stream..." -bytes=80000 -if dd if=/dev/zero ibs=1 count=$bytes 2>/dev/null | flac${EXE} --silent --force --verify -0 --input-size=$bytes --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=8000 - ; then - chmod +w $flacfile -else - die "ERROR during generation" -fi - -check_flac - -# Replay gain tests - Test the rates which have specific filter table entries -# and verify that harmonics can be processed correctly. - -tonegenerator () -{ - flac${EXE} --force --output-name=$2 --silent --no-seektable --no-error-on-compression-fail rpg-tone-$1.wav -} - -REPLAYGAIN_FREQ= -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 8000/-12.73" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 11025/-12.91" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 12000/-12.98" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 16000/-13.27" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 18900/-13.41" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 22050/-13.77" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 24000/-13.82" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 28000/-14.06" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 32000/-14.08" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 36000/-14.12" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 37800/-14.18" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 44100/-14.17" -REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 48000/-14.16:1:2:4" - -set -e - -for ACTION in $REPLAYGAIN_FREQ ; do - if [ -n "${ACTION##*:*}" ] ; then - HARMONICS=1 - else - HARMONICS="${ACTION#*:}" - fi - FREQ="${ACTION%%/*}" - GAIN="${ACTION#*/}" - GAIN="${GAIN%%:*}" - while [ -n "$HARMONICS" ] ; do - MULTIPLE="${HARMONICS%%:*}" - if [ "$MULTIPLE" = "$HARMONICS" ] ; then - HARMONICS= - else - HARMONICS="${HARMONICS#*:}" - fi - RATE=$((MULTIPLE * FREQ)) - [ $MULTIPLE -eq 1 -o -n "${REPLAYGAIN_FREQ##* $RATE/*}" ] || break - echo $ECHO_N "Testing FLAC replaygain $RATE ($FREQ x $MULTIPLE) ... " $ECHO_C - tonegenerator $RATE $flacfile - run_metaflac --scan-replay-gain $flacfile - run_metaflac --add-replay-gain $flacfile - run_metaflac --list $flacfile | grep "REPLAYGAIN.*GAIN=" | - while read -r REPLAYGAIN ; do - MEASUREDGAIN="${REPLAYGAIN##*=}" - MEASUREDGAIN="${MEASUREDGAIN%% *}" - if [ x"$MEASUREDGAIN" != x"$GAIN" ] ; then - die "ERROR, Expected $GAIN db instead of $REPLAYGAIN" - fi - done - echo OK - done -done - - -rm -f $testdir/out.flac $testdir/out.meta - -exit 0 diff --git a/Engine/lib/flac/test/test_seeking.sh b/Engine/lib/flac/test/test_seeking.sh deleted file mode 100644 index a00e7d1cc..000000000 --- a/Engine/lib/flac/test/test_seeking.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2004-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -PATH=../src/flac:$PATH -PATH=../src/metaflac:$PATH -PATH=../src/test_seeking:$PATH -PATH=../src/test_streams:$PATH -PATH=../objs/$BUILD/bin:$PATH - -if [ -z "$FLAC__TEST_LEVEL" ] ; then - FLAC__TEST_LEVEL=1 -fi - -flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" -metaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable" - -run_flac () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_seeking.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} --no-error-on-compression-fail $* 4>>test_seeking.valgrind.log - else - flac${EXE} --no-error-on-compression-fail $* - fi -} - -run_metaflac () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_seeking.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_seeking.valgrind.log - else - metaflac${EXE} $* - fi -} - -run_test_seeking () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_seeking $*" >>test_seeking.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_seeking $* 4>>test_seeking.valgrind.log - else - test_seeking${EXE} $* - fi -} - -echo $ECHO_N "Checking for --ogg support in flac ... " $ECHO_C -if flac${EXE} --ogg --no-error-on-compression-fail --silent --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then - has_ogg=yes; -else - has_ogg=no; -fi -echo ${has_ogg} - -echo "Generating streams..." -if [ ! -f noise.raw ] ; then - test_streams || die "ERROR during test_streams" -fi - -echo "generating FLAC files for seeking:" -run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 -S- --output-name=tiny.flac noise8m32.raw || die "ERROR generating FLAC file" -run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 -S- --output-name=small.flac noise.raw || die "ERROR generating FLAC file" -run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 -S10x --output-name=tiny-s.flac noise8m32.raw || die "ERROR generating FLAC file" -run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 -S10x --output-name=small-s.flac noise.raw || die "ERROR generating FLAC file" - -tiny_samples="$(metaflac${EXE} --show-total-samples tiny.flac)" -small_samples="$(metaflac${EXE} --show-total-samples small.flac)" - -tiny_seek_count=100 -if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then - small_seek_count=10000 -else - small_seek_count=100 -fi - -for suffix in '' '-s' ; do - echo "testing tiny$suffix.flac:" - if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else - die "ERROR: during test_seeking" - fi - - echo "testing small$suffix.flac:" - if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else - die "ERROR: during test_seeking" - fi - - echo "removing sample count from tiny$suffix.flac and small$suffix.flac:" - if run_metaflac --no-filename --set-total-samples=0 tiny$suffix.flac small$suffix.flac ; then : ; else - die "ERROR: during metaflac" - fi - - echo "testing tiny$suffix.flac with total_samples=0:" - if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else - die "ERROR: during test_seeking" - fi - - echo "testing small$suffix.flac with total_samples=0:" - if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else - die "ERROR: during test_seeking" - fi -done - -if [ $has_ogg = "yes" ] ; then - - echo "generating Ogg FLAC files for seeking:" - run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 --output-name=tiny.oga --ogg noise8m32.raw || die "ERROR generating Ogg FLAC file" - run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 --output-name=small.oga --ogg noise.raw || die "ERROR generating Ogg FLAC file" - # seek tables are not used in Ogg FLAC - - echo "testing tiny.oga:" - if run_test_seeking tiny.oga $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else - die "ERROR: during test_seeking" - fi - - echo "testing small.oga:" - if run_test_seeking small.oga $small_seek_count $small_samples noise.raw ; then : ; else - die "ERROR: during test_seeking" - fi - -fi - -rm -f tiny.flac tiny.oga small.flac small.oga tiny-s.flac small-s.flac diff --git a/Engine/lib/flac/test/test_streams.sh b/Engine/lib/flac/test/test_streams.sh deleted file mode 100644 index 22dd747da..000000000 --- a/Engine/lib/flac/test/test_streams.sh +++ /dev/null @@ -1,331 +0,0 @@ -#!/bin/sh -e - -# FLAC - Free Lossless Audio Codec -# Copyright (C) 2001-2009 Josh Coalson -# Copyright (C) 2011-2023 Xiph.Org Foundation -# -# This file is part the FLAC project. FLAC is comprised of several -# components distributed under different licenses. The codec libraries -# are distributed under Xiph.Org's BSD-like license (see the file -# COPYING.Xiph in this distribution). All other programs, libraries, and -# plugins are distributed under the GPL (see COPYING.GPL). The documentation -# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the -# FLAC distribution contains at the top the terms under which it may be -# distributed. -# -# Since this particular file is relevant to all components of FLAC, -# it may be distributed under the Xiph.Org license, which is the least -# restrictive of those mentioned above. See the file COPYING.Xiph in this -# distribution. - -. ./common.sh - -PATH=../src/flac:$PATH -PATH=../src/test_streams:$PATH -PATH=../objs/$BUILD/bin:$PATH - -if [ -z "$FLAC__TEST_LEVEL" ] ; then - FLAC__TEST_LEVEL=1 -fi - -flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" - -run_flac () -{ - if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then - echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_streams.valgrind.log - valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac --no-error-on-compression-fail $* 4>>test_streams.valgrind.log - else - flac${EXE} --no-error-on-compression-fail $* - fi -} - -echo "Generating streams..." -if [ ! -f wacky1.wav ] ; then - test_streams || die "ERROR: missing files" -fi - -# -# single-file test routines -# - -test_file () -{ - name=$1 - channels=$2 - bps=$3 - encode_options="$4" - - echo $ECHO_N "$name (--channels=$channels --bps=$bps $encode_options): encode..." $ECHO_C - cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding $name.raw" - echo "### ENCODE $name #######################################################" >> ./streams.log - echo "### cmd=$cmd" >> ./streams.log - $cmd 2>>./streams.log || die "ERROR during encode of $name" - - echo $ECHO_N "decode..." $ECHO_C - cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --output-name=$name.cmp $name.flac" - echo "### DECODE $name #######################################################" >> ./streams.log - echo "### cmd=$cmd" >> ./streams.log - $cmd 2>>./streams.log || die "ERROR during decode of $name" - - ls -1l $name.raw >> ./streams.log - ls -1l $name.flac >> ./streams.log - ls -1l $name.cmp >> ./streams.log - - echo $ECHO_N "compare..." $ECHO_C - cmp $name.raw $name.cmp || die "ERROR during compare of $name" - - echo OK -} - -test_file_piped () -{ - name=$1 - channels=$2 - bps=$3 - encode_options="$4" - - if [ "$(env | grep -ic '^comspec=')" != 0 ] ; then - is_win=yes - else - is_win=no - fi - - echo $ECHO_N "$name: encode via pipes..." $ECHO_C - if [ $is_win = yes ] ; then - cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding --stdout $name.raw" - echo "### ENCODE $name #######################################################" >> ./streams.log - echo "### cmd=$cmd" >> ./streams.log - $cmd 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name" - else - cmd="run_flac --verify --silent --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding --stdout -" - echo "### ENCODE $name #######################################################" >> ./streams.log - echo "### cmd=$cmd" >> ./streams.log - $cmd < $name.raw 1>$name.flac 2>>./streams.log || die "ERROR during encode of $name" - fi - echo $ECHO_N "decode via pipes..." $ECHO_C - if [ $is_win = yes ] ; then - cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout $name.flac" - echo "### DECODE $name #######################################################" >> ./streams.log - echo "### cmd=$cmd" >> ./streams.log - $cmd 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name" - else - cmd="run_flac --silent --force --endian=little --sign=signed --decode --force-raw-format --stdout -" - echo "### DECODE $name #######################################################" >> ./streams.log - echo "### cmd=$cmd" >> ./streams.log - $cmd < $name.flac 1>$name.cmp 2>>./streams.log || die "ERROR during decode of $name" - fi - ls -1l $name.raw >> ./streams.log - ls -1l $name.flac >> ./streams.log - ls -1l $name.cmp >> ./streams.log - - echo $ECHO_N "compare..." $ECHO_C - cmp $name.raw $name.cmp || die "ERROR during compare of $name" - - echo OK -} - -test_corrupted_file () -{ - name=$1 - channels=$2 - bps=$3 - encode_options="$4" - - echo $ECHO_N "$name (--channels=$channels --bps=$bps $encode_options): encode..." $ECHO_C - cmd="run_flac --verify --silent --no-padding --force --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --no-padding $name.raw" - echo "### ENCODE $name #######################################################" >> ./streams.log - echo "### cmd=$cmd" >> ./streams.log - $cmd 2>>./streams.log || die "ERROR during encode of $name" - - filesize=$(wc -c < $name.flac) - bs=$((filesize/13)) - - # Overwrite with 'garbagegarbagegarbage....' - yes garbage 2>/dev/null | dd of=$name.flac conv=notrunc bs=$bs seek=1 count=2 2>> ./streams.log - # Overwrite with 0x00 - dd if=/dev/zero of=$name.flac conv=notrunc bs=$bs seek=4 count=2 2>> ./streams.log - # Overwrite with 0xFF - tr '\0' '\377' < /dev/zero | dd of=$name.flac conv=notrunc bs=$bs seek=7 count=2 2>> ./streams.log - # Remove section - cp $name.flac $name.tmp.flac - dd if=$name.tmp.flac of=$name.flac bs=$bs skip=12 seek=10 2>> ./streams.log - - echo $ECHO_N "decode..." $ECHO_C - cmd="run_flac --silent --decode-through-errors --force --endian=little --sign=signed --decode --force-raw-format --output-name=$name.cmp $name.flac" - echo "### DECODE $name.corrupt #######################################################" >> ./streams.log - echo "### cmd=$cmd" >> ./streams.log - $cmd 2>>./streams.log || die "ERROR during decode of $name" - - ls -1l $name.raw >> ./streams.log - ls -1l $name.flac >> ./streams.log - ls -1l $name.cmp >> ./streams.log - - echo $ECHO_N "compare..." $ECHO_C - if [ "$(wc -c < $name.raw)" -ne "$(wc -c < $name.cmp)" ]; then - die "ERROR, length of decoded file not equal to length of original" - fi - - echo OK -} - -if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then - max_lpc_order=32 -else - max_lpc_order=16 -fi - -echo "Testing noise through pipes..." -test_file_piped noise 1 8 "-0" - -echo "Testing small files..." -test_file test01 1 16 "-0 -l $max_lpc_order --lax -m -e -p" -test_file test02 2 16 "-0 -l $max_lpc_order --lax -m -e -p" -test_file test03 1 16 "-0 -l $max_lpc_order --lax -m -e -p" -test_file test04 2 16 "-0 -l $max_lpc_order --lax -m -e -p" - -for bps in 8 16 24 32 ; do - echo "Testing $bps-bit full-scale deflection streams..." - for b in 01 02 03 04 05 06 07 ; do - test_file fsd$bps-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e -p" - done -done - -echo "Testing 16-bit wasted-bits-per-sample streams..." -for b in 01 ; do - test_file wbps16-$b 1 16 "-0 -l $max_lpc_order --lax -m -e -p" -done - -for bps in 8 16 24 32; do - echo "Testing $bps-bit sine wave streams..." - for b in 00 ; do - test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000" - done - for b in 01 ; do - test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000" - done - for b in 02 03 04 ; do - test_file sine${bps}-$b 1 $bps "-0 -l $max_lpc_order --lax -m -e" - done - for b in 10 11 ; do - test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=48000" - done - for b in 12 ; do - test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e --sample-rate=96000" - done - for b in 13 14 15 16 17 18 19 ; do - test_file sine${bps}-$b 2 $bps "-0 -l $max_lpc_order --lax -m -e" - done -done - -echo "Testing blocksize variations..." -for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do - for blocksize in 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do - for lpc_order in 0 1 2 3 4 5 7 8 9 15 16 17 31 32 ; do - if [ $lpc_order = 0 ] || [ $lpc_order -le $blocksize ] ; then - test_file noise8m32 1 8 "-8 -p -e -l $lpc_order --lax --blocksize=$blocksize $disable" - fi - done - done -done - -echo "Testing blocksize variations with subdivide apodization..." -for blocksize in 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do - for lpc_order in 0 1 2 3 4 5 7 8 9 15 16 17 31 32 ; do - if [ $lpc_order = 0 ] || [ $lpc_order -le $blocksize ] ; then - test_file noise8m32 1 8 "-8 -p -e -A \"subdivide_tukey(32)\" -l $lpc_order --lax --blocksize=$blocksize" - fi - done -done - -echo "Testing some frame header variations..." -test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b $max_lpc_order" -test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax -b 65535" -test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9" -test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90" -test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000" -test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=9" -test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90" -test_file sine16-01 1 16 "-0 -l $max_lpc_order -m -e -p --lax --sample-rate=90000" - -echo "Testing option variations..." -for f in 00 01 02 03 04 ; do - for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do - if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then - for opt in 0 1 2 4 5 6 8 ; do - for extras in '' '-p' '-e' ; do - if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then - test_file sine16-$f 1 16 "-$opt $extras $disable" - fi - done - done - if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then - test_file sine16-$f 1 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable" - fi - fi - done -done - -for f in 10 11 12 13 14 15 16 17 18 19 ; do - for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do - if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then - for opt in 0 1 2 4 5 6 8 ; do - for extras in '' '-p' '-e' ; do - if [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then - test_file sine16-$f 2 16 "-$opt $extras $disable" - fi - done - done - if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then - test_file sine16-$f 2 16 "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable" - fi - fi - done -done - -echo "Testing corruption handling..." -for bps in 8 16 24 ; do - for f in 00 01 02 03 04 10 11 12 13 14 15 16 17 18 19; do - for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do - if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then - for opt in 0 1 2 4 5 6 8 ; do - for extras in '' '-p' '-e' ; do - if [ -z "$extras" -o "$FLAC__TEST_LEVEL" -gt 0 ] && { [ "$bps" -eq 16 -a "$f" -lt 15 ] || [ "$FLAC__TEST_LEVEL" -gt 1 ]; } ; then - if [ "$f" -lt 10 ] ; then - test_corrupted_file sine$bps-$f 1 $bps "-$opt $extras $disable" - else - test_corrupted_file sine$bps-$f 2 $bps "-$opt $extras $disable" - fi - fi - done - done - fi - done - done -done - -echo "Testing noise..." -for disable in '' '--disable-verbatim-subframes --disable-constant-subframes' '--disable-verbatim-subframes --disable-constant-subframes --disable-fixed-subframes' ; do - if [ -z "$disable" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then - for channels in 1 2 4 8 ; do - if [ $channels -le 2 ] || [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then - for bps in 8 16 24 32; do - for opt in 0 1 2 3 4 5 6 7 8 ; do - for extras in '' '-p' '-e' ; do - if { [ -z "$extras" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ]; } && { [ "$extras" != '-p' ] || [ "$opt" -gt 2 ]; } ; then - for blocksize in '' '--lax -b 32' '--lax -b 32768' '--lax -b 65535' ; do - if [ -z "$blocksize" ] || [ "$FLAC__TEST_LEVEL" -gt 0 ] ; then - test_file noise $channels $bps "-$opt $extras $blocksize $disable" - fi - done - fi - done - done - if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then - test_file noise $channels $bps "-b 16384 -m -r 8 -l $max_lpc_order --lax -e -p $disable" - fi - done - fi - done - fi -done diff --git a/Engine/lib/flac/test/write_iff.pl b/Engine/lib/flac/test/write_iff.pl deleted file mode 100644 index f9efa74d1..000000000 --- a/Engine/lib/flac/test/write_iff.pl +++ /dev/null @@ -1,211 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -require Math::BigInt; - -my $usage = " -$0 <#samples> - - is one of aiff,wave,wave64,rf64 - is 8,16,24,32 - is 1-8 - is any 32-bit value - <#samples> is 0-2^64-1 - is one of zero,rand - -"; - -die $usage unless @ARGV == 6; - -my %formats = ( 'aiff'=>1, 'wave'=>1, 'wave64'=>1, 'rf64'=>1 ); -my %sampletypes = ( 'zero'=>1, 'rand'=>1 ); -my @channelmask = ( 0, 1, 3, 7, 0x33, 0x607, 0x60f, 0, 0 ); #@@@@@@ need proper masks for 7,8 - -my ($format, $bps, $channels, $samplerate, $samples, $sampletype) = @ARGV; -my $bigsamples = new Math::BigInt $samples; - -die $usage unless defined $formats{$format}; -die $usage unless $bps == 8 || $bps == 16 || $bps == 24 || $bps == 32; -die $usage unless $channels >= 1 && $channels <= 8; -die $usage unless $samplerate >= 0 && $samplerate <= 4294967295; -die $usage unless defined $sampletypes{$sampletype}; - -# convert bits-per-sample to bytes-per-sample -$bps /= 8; - -my $datasize = $samples * $bps * $channels; -my $bigdatasize = $bigsamples * $bps * $channels; - -my $padding = int($bigdatasize & 1); # for aiff/wave/rf64 chunk alignment -my $padding8 = 8 - int($bigdatasize & 7); $padding8 = 0 if $padding8 == 8; # for wave64 alignment -# wave-ish file needs to be WAVEFORMATEXTENSIBLE? -my $wavx = ($format eq 'wave' || $format eq 'wave64' || $format eq 'rf64') && ($channels > 2 || ($bps != 8 && $bps != 16)); - -# write header - -if ($format eq 'aiff') { - die "sample data too big for format\n" if 46 + $datasize + $padding > 4294967295; - # header - print "FORM"; - print pack('N', 46 + $datasize + $padding); - print "AIFF"; - # COMM chunk - print "COMM"; - print pack('N', 18); # chunk size = 18 - print pack('n', $channels); - print pack('N', $samples); - print pack('n', $bps * 8); - print pack_sane_extended($samplerate); - # SSND header - print "SSND"; - print pack('N', $datasize + 8); # chunk size - print pack('N', 0); # ssnd_offset_size - print pack('N', 0); # blocksize -} -elsif ($format eq 'wave' || $format eq 'wave64' || $format eq 'rf64') { - die "sample data too big for format\n" if $format eq 'wave' && ($wavx?60:36) + $datasize + $padding > 4294967295; - # header - if ($format eq 'wave') { - print "RIFF"; - # +4 for WAVE - # +8+{40,16} for fmt chunk - # +8 for data chunk header - print pack('V', 4 + 8+($wavx?40:16) + 8 + $datasize + $padding); - print "WAVE"; - } - elsif ($format eq 'wave64') { - # RIFF GUID 66666972-912E-11CF-A5D6-28DB04C10000 - print "\x72\x69\x66\x66\x2E\x91\xCF\x11\xD6\xA5\x28\xDB\x04\xC1\x00\x00"; - # +(16+8) for RIFF GUID + size - # +16 for WAVE GUID - # +16+8+{40,16} for fmt chunk - # +16+8 for data chunk header - my $bigriffsize = $bigdatasize + (16+8) + 16 + 16+8+($wavx?40:16) + (16+8) + $padding8; - print pack_64('V', $bigriffsize); - # WAVE GUID 65766177-ACF3-11D3-8CD1-00C04F8EDB8A - print "\x77\x61\x76\x65\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A"; - } - else { - print "RF64"; - print pack('V', 0xffffffff); - print "WAVE"; - # ds64 chunk - print "ds64"; - print pack('V', 28); # chunk size - # +4 for WAVE - # +(8+28) for ds64 chunk - # +8+{40,16} for fmt chunk - # +8 for data chunk header - my $bigriffsize = $bigdatasize + 4 + (8+28) + 8+($wavx?40:16) + 8 + $padding; - print pack_64('V', $bigriffsize); - print pack_64('V', $bigdatasize); - print pack_64('V', $bigsamples); - print pack('V', 0); # table size - } - # fmt chunk - if ($format ne 'wave64') { - print "fmt "; - print pack('V', $wavx?40:16); # chunk size - } - else { # wave64 - # fmt GUID 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A - print "\x66\x6D\x74\x20\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A"; - print pack('V', 16+8+($wavx?40:16)); # chunk size (+16+8 for GUID and size fields) - print pack('V', 0); # ...is 8 bytes for wave64 - } - print pack('v', $wavx?65534:1); # compression code - print pack('v', $channels); - print pack('V', $samplerate); - print pack('V', $samplerate * $channels * $bps); - print pack('v', $channels * $bps); # block align = channels*((bps+7)/8) - print pack('v', $bps * 8); # bits per sample = ((bps+7)/8)*8 - if ($wavx) { - print pack('v', 22); # cbSize - print pack('v', $bps * 8); # validBitsPerSample - print pack('V', $channelmask[$channels]); - # GUID = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} - print "\x01\x00\x00\x00\x00\x00\x10\x00\x80\x00\x00\xaa\x00\x38\x9b\x71"; - } - # data header - if ($format ne 'wave64') { - print "data"; - print pack('V', $format eq 'wave'? $datasize : 0xffffffff); - } - else { # wave64 - # data GUID 61746164-ACF3-11D3-8CD1-00C04F8EDB8A - print "\x64\x61\x74\x61\xF3\xAC\xD3\x11\xD1\x8C\x00\xC0\x4F\x8E\xDB\x8A"; - print pack_64('V', $bigdatasize+16+8); # +16+8 for GUID and size fields - } -} -else { - die; -} - -# write sample data - -if ($sampletype eq 'zero') { - my $chunk = 4096; - my $buf = pack("x[".($channels*$bps*$chunk)."]"); - for (my $s = $samples; $s > 0; $s -= $chunk) { - if ($s < $chunk) { - print substr($buf, 0, $channels*$bps*$s); - } - else { - print $buf; - } - } -} -elsif ($sampletype eq 'rand') { - for (my $s = 0; $s < $samples; $s++) { - for (my $c = 0; $c < $channels; $c++) { - for (my $b = 0; $b < $bps; $b++) { - print pack('C', int(rand(256))); - } - } - } -} -else { - die; -} - -# write padding -if ($format eq 'wave64') { - print pack("x[$padding8]") if $padding8; -} -else { - print "\x00" if $padding; -} - -exit 0; - -sub pack_sane_extended -{ - my $val = shift; - die unless $val > 0; - my $shift; - for ($shift = 0; ($val>>(31-$shift)) == 0; ++$shift) { - } - $val <<= $shift; - my $exponent = 63 - ($shift + 32); - return pack('nNN', $exponent + 16383, $val, 0); -} - -sub pack_64 -{ - my $c = shift; # 'N' for big-endian, 'V' for little-endian, ala pack() - my $v1 = shift; # value, must be Math::BigInt - my $v2 = $v1->copy(); - if ($c eq 'V') { - $v1->band(0xffffffff); - $v2->brsft(32); - } - elsif ($c eq 'N') { - $v2->band(0xffffffff); - $v1->brsft(32); - } - else { - die; - } - return pack("$c$c", 0+$v1->bstr(), 0+$v2->bstr()); -} diff --git a/Engine/lib/libogg/.github/workflows/autotools.yml b/Engine/lib/libogg/.github/workflows/autotools.yml deleted file mode 100644 index 0ae340ee9..000000000 --- a/Engine/lib/libogg/.github/workflows/autotools.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Autotools build - -on: - push: - pull_request: - schedule: - - cron: '0 0 1 * *' - -jobs: - build: - strategy: - matrix: - os: - [ - ubuntu-latest, - macos-latest, - ] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - - name: Install macOS dependencies - if: startsWith(matrix.os,'macos') - run: brew install automake pkg-config libtool - - - name: configure - run: | - ./autogen.sh - ./configure - - - name: build - run: make - - - name: test - run: make check - - - name: distcheck - run: make distcheck diff --git a/Engine/lib/libogg/.github/workflows/cmake.yml b/Engine/lib/libogg/.github/workflows/cmake.yml deleted file mode 100644 index dfb78b237..000000000 --- a/Engine/lib/libogg/.github/workflows/cmake.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: CMake build - -on: - push: - pull_request: - schedule: - - cron: '0 0 1 * *' - -jobs: - build: - strategy: - matrix: - os: - [ - ubuntu-latest, - macos-latest, - windows-latest, - ] - - runs-on: ${{ matrix.os }} - - env: - BUILD: _build - - steps: - - uses: actions/checkout@v2 - - - name: Prepare build directory - run: mkdir ${{ env.BUILD }} - - - name: Configure - run: cmake -S . -B ${{ env.BUILD }} - - - name: Build - run: cmake --build ${{ env.BUILD }} - - - name: Test - run: ctest --test-dir ${{ env.BUILD }} -V -C Debug diff --git a/Engine/lib/libogg/.gitignore b/Engine/lib/libogg/.gitignore deleted file mode 100644 index 1f256634d..000000000 --- a/Engine/lib/libogg/.gitignore +++ /dev/null @@ -1,50 +0,0 @@ -aclocal.m4 -autom4te.cache -ChangeLog -compile -config.guess -config.h -config.h.in -config.h.in~ -config.log -config.status -config.sub -configure -depcomp -install-sh -libogg.spec -libtool -ltmain.sh -Makefile -Makefile.in -missing -mkinstalldirs -ogg.pc -ogg-uninstalled.pc -stamp-h1 -.project -include/ogg/config_types.h -src/*.o -src/*.lo -src/lib*.la -src/.libs -src/.deps -src/test_* -macosx/build/ -/m4 - -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -CMakeSettings.json - -*[Bb]uild*/ - -.vs/ -.vscode/ diff --git a/Engine/lib/libogg/.gitlab-ci.yml b/Engine/lib/libogg/.gitlab-ci.yml deleted file mode 100644 index 584480a9b..000000000 --- a/Engine/lib/libogg/.gitlab-ci.yml +++ /dev/null @@ -1,85 +0,0 @@ -default: - tags: - - docker - # Image from https://hub.docker.com/_/gcc/ based on Debian. - image: gcc:14 - -.autotools: - stage: build - before_script: - - apt-get update && - apt-get install -y zip ${INSTALL_COMPILER} ${INSTALL_EXTRA} - script: - - ./autogen.sh - - ./configure ${CONFIG_FLAGS} || cat config.log - - make - - make check - variables: - INSTALL_COMPILER: gcc - -autotools-gcc: - extends: .autotools - script: - - ./autogen.sh - - ./configure ${CONFIG_FLAGS} || cat config.log - - make - - make distcheck - variables: - INSTALL_EXTRA: cmake - artifacts: - paths: - - libogg-*.tar.gz - expire_in: 2 week - -autotools-gcc-builddir: - extends: .autotools - script: - - ./autogen.sh - - mkdir build - - (cd build && ../configure ${CONFIG_FLAGS}) || cat config.log - - (cd build && make) - - (cd build && make check) - -autotools-clang: - extends: .autotools - script: - - ./autogen.sh - - ./configure ${CONFIG_FLAGS} || cat config.log - - make - - make distcheck - variables: - INSTALL_EXTRA: cmake - INSTALL_COMPILER: clang - CC: clang - -autotools-mingw: - extends: .autotools - script: - - mkdir build-mingw - - ./autogen.sh - - (cd build-mingw && ../configure ${CONFIG_FLAGS}) - - (cd build-mingw && make) - variables: - CONFIG_FLAGS: --disable-shared --host=x86_64-pc-linux-gnu - INSTALL_COMPILER: gcc-mingw-w64 - CC: x86_64-w64-mingw32-gcc - -autotools-enable-gcc-sanitizers: - extends: .autotools - variables: - CONFIG_FLAGS: --enable-gcc-sanitizers - -autotools-enable-valgrind-testing: - extends: .autotools - variables: - CONFIG_FLAGS: --enable-valgrind-testing - -cmake: - stage: build - before_script: - - apt-get update && - apt-get install -y cmake ninja-build - script: - - mkdir build - - cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release - - cmake --build build diff --git a/Engine/lib/libogg/.travis.yml b/Engine/lib/libogg/.travis.yml deleted file mode 100644 index f7187cba8..000000000 --- a/Engine/lib/libogg/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: c - -os: - - linux - - osx - -compiler: - - gcc - - clang - -env: - - BUILD=AUTOTOOLS - - BUILD=CMAKE - -script: - - if [[ "$BUILD" == "AUTOTOOLS" ]] ; then ./autogen.sh ; fi - - if [[ "$BUILD" == "AUTOTOOLS" ]] ; then ./configure ; fi - - if [[ "$BUILD" == "AUTOTOOLS" ]] ; then make distcheck ; fi - - if [[ "$BUILD" == "CMAKE" ]] ; then mkdir build ; fi - - if [[ "$BUILD" == "CMAKE" ]] ; then pushd build ; fi - - if [[ "$BUILD" == "CMAKE" ]] ; then cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCPACK_PACKAGE_CONTACT="Xiph.Org Foundation" .. ; fi - - if [[ "$BUILD" == "CMAKE" ]] ; then cmake --build . ; fi - - if [[ "$BUILD" == "CMAKE" ]] ; then ctest ; fi - - if [[ "$BUILD" == "CMAKE" && "$TRAVIS_OS_NAME" == "linux" ]] ; then cpack -G DEB ; fi - - if [[ "$BUILD" == "CMAKE" ]] ; then popd ; fi diff --git a/Engine/lib/libogg/AUTHORS b/Engine/lib/libogg/AUTHORS deleted file mode 100644 index a0023f2c1..000000000 --- a/Engine/lib/libogg/AUTHORS +++ /dev/null @@ -1,7 +0,0 @@ -Monty -Greg Maxwell -Ralph Giles -Cristian Adam -Tim Terriberry - -and the rest of the Xiph.Org Foundation. diff --git a/Engine/lib/libogg/CHANGES b/Engine/lib/libogg/CHANGES deleted file mode 100644 index 48f671e59..000000000 --- a/Engine/lib/libogg/CHANGES +++ /dev/null @@ -1,112 +0,0 @@ -Version 1.3.5 (2020 June 3) - - * Fix unsigned typedef problem on macOS. - * Fix overflow check in ogg_sync_buffer. - * Clean up cmake and autotools build files. - * Remove Symbian and Apple XCode build files. - * Fix documentation cross-reference links. - -Version 1.3.4 (2019 August 30) - -* Faster slice-by-8 CRC32 implementation. - see https://lwn.net/Articles/453931/ for motivation. -* Add CMake build. -* Deprecate Visual Studio project files in favor of CMake. -* configure --disable-crc option for fuzzing. -* Various build fixes. -* Documentation and example code fixes. - -Version 1.3.3 (2017 November 7) - - * Fix an issue with corrupt continued packet handling. - * Update Windows projects and build settings. - * Remove Mac OS 9 build support. - -Version 1.3.2 (2014 May 27) - - * Fix an bug in oggpack_writecopy(). - -Version 1.3.1 (2013 May 12) - -* Guard against very large packets. -* Respect the configure --docdir override. -* Documentation fixes. -* More Windows build fixes. - -Version 1.3.0 (2011 August 4) - -* Add ogg_stream_flush_fill() call - This produces longer packets on flush, similar to - what ogg_stream_pageout_fill() does for single pages. -* Windows build fixes - -Version 1.2.2 (2010 December 07) - -* Build fix (types correction) for Mac OS X -* Update win32 project files to Visual Studio 2008 -* ogg_stream_pageout_fill documentation fix - -Version 1.2.1 (2010 November 01) - -* Various build updates (see SVN) -* Add ogg_stream_pageout_fill() to API to allow applications - greater explicit flexibility in page sizing. -* Documentation updates including multiplexing description, - terminology and API (incl. ogg_packet_clear(), - ogg_stream_pageout_fill()) -* Correct possible buffer overwrite in stream encoding on 32 bit - when a single packet exceed 250MB. -* Correct read-buffer overrun [without side effects] under - similar circumstances. -* Update unit testing to work properly with new page spill - heuristic. - -Version 1.2.0 (2010 March 25) - -* Alter default flushing behavior to span less often and use larger page - sizes when packet sizes are large. -* Build fixes for additional compilers -* Documentation updates - -Version 1.1.4 (2009 June 24) - -* New async error reporting mechanism. Calls made after a fatal error are - now safely handled in the event an error code is ignored -* Added allocation checks useful to some embedded applications -* fix possible read past end of buffer when reading 0 bits -* Updates to API documentation -* Build fixes - -Version 1.1.3 (2005 November 27) - - * Correct a bug in the granulepos field of pages where no packet ends - * New VS2003 and XCode builds, minor fixes to other builds - * documentation fixes and cleanup - -Version 1.1.2 (2004 September 23) - - * fix a bug with multipage packet assembly after seek - -Version 1.1.1 (2004 September 12) - - * various bugfixes - * important bugfix for 64-bit platforms - * various portability fixes - * autotools cleanup from Thomas Vander Stichele - * Symbian OS build support from Colin Ward at CSIRO - * new multiplexed Ogg stream documentation - -Version 1.1 (2003 November 17) - - * big-endian bitpacker routines for Theora - * various portability fixes - * improved API documentation - * RFC 3533 documentation of the format by Silvia Pfeiffer at CSIRO - * RFC 3534 documentation of the application/ogg mime-type by Linus Walleij - -Version 1.0 (2002 July 19) - - * First stable release - * little-endian bitpacker routines for Vorbis - * basic Ogg bitstream sync and coding support - diff --git a/Engine/lib/libogg/CMakeLists.txt b/Engine/lib/libogg/CMakeLists.txt deleted file mode 100644 index 93a24baf3..000000000 --- a/Engine/lib/libogg/CMakeLists.txt +++ /dev/null @@ -1,198 +0,0 @@ -cmake_minimum_required(VERSION 3.6) - -# Extract project version from configure.ac -file(READ configure.ac CONFIGURE_AC_CONTENTS) -string(REGEX MATCH "AC_INIT\\(\\[libogg\\],\\[([0-9]*\\.[0-9]*\\.[0-9]*)\\]" DUMMY ${CONFIGURE_AC_CONTENTS}) - -project(ogg VERSION ${CMAKE_MATCH_1} LANGUAGES C) - -# Required modules -include(GNUInstallDirs) -include(CheckIncludeFiles) -include(CMakePackageConfigHelpers) - -# Build options -option(BUILD_SHARED_LIBS "Build shared library" OFF) -if(APPLE) - option(BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF) -endif() - -# Install options -option(INSTALL_DOCS "Install documentation" ON) -option(INSTALL_PKG_CONFIG_MODULE "Install ogg.pc file" ON) -option(INSTALL_CMAKE_PACKAGE_MODULE "Install CMake package configuration module" ON) - -# Extract library version from configure.ac -string(REGEX MATCH "LIB_CURRENT=([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS}) -set(LIB_CURRENT ${CMAKE_MATCH_1}) - -string(REGEX MATCH "LIB_AGE=([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS}) -set(LIB_AGE ${CMAKE_MATCH_1}) - -string(REGEX MATCH "LIB_REVISION=([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS}) -set(LIB_REVISION ${CMAKE_MATCH_1}) - -math(EXPR LIB_SOVERSION "${LIB_CURRENT} - ${LIB_AGE}") -set(LIB_VERSION "${LIB_SOVERSION}.${LIB_AGE}.${LIB_REVISION}") - - -# Helper function to configure pkg-config files -function(configure_pkg_config_file pkg_config_file_in) - set(prefix ${CMAKE_INSTALL_PREFIX}) - set(exec_prefix ${CMAKE_INSTALL_FULL_BINDIR}) - set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) - set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) - set(VERSION ${PROJECT_VERSION}) - string(REPLACE ".in" "" pkg_config_file ${pkg_config_file_in}) - configure_file(${pkg_config_file_in} ${pkg_config_file} @ONLY) -endfunction() - -message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}") - -# Configure config_type.h -check_include_files(inttypes.h INCLUDE_INTTYPES_H) -check_include_files(stdint.h INCLUDE_STDINT_H) -check_include_files(sys/types.h INCLUDE_SYS_TYPES_H) - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -set(SIZE16 int16_t) -set(USIZE16 uint16_t) -set(SIZE32 int32_t) -set(USIZE32 uint32_t) -set(SIZE64 int64_t) -set(USIZE64 uint64_t) - -include(CheckSizes) - -configure_file(include/ogg/config_types.h.in include/ogg/config_types.h @ONLY) - -set(OGG_HEADERS - ${CMAKE_CURRENT_BINARY_DIR}/include/ogg/config_types.h - include/ogg/ogg.h - include/ogg/os_types.h -) - -set(OGG_SOURCES - src/bitwise.c - src/framing.c - src/crctable.h -) - -if(WIN32 AND BUILD_SHARED_LIBS) - list(APPEND OGG_SOURCES win32/ogg.def) -endif() - -if(BUILD_FRAMEWORK) - set(BUILD_SHARED_LIBS TRUE) -endif() - -add_library(ogg ${OGG_HEADERS} ${OGG_SOURCES}) -add_library(Ogg::ogg ALIAS ogg) -target_include_directories(ogg PUBLIC - $ - $ - $ -) - -set_target_properties( - ogg PROPERTIES - SOVERSION ${LIB_SOVERSION} - VERSION ${LIB_VERSION} - PUBLIC_HEADER "${OGG_HEADERS}" -) - -if(BUILD_FRAMEWORK) - set_target_properties(ogg PROPERTIES - FRAMEWORK TRUE - FRAMEWORK_VERSION ${PROJECT_VERSION} - MACOSX_FRAMEWORK_IDENTIFIER org.xiph.ogg - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} - MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION} - XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" - OUTPUT_NAME Ogg - ) -endif() - -configure_pkg_config_file(ogg.pc.in) - -install(TARGETS ogg - EXPORT OggTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ogg -) - -export(EXPORT OggTargets NAMESPACE Ogg:: FILE OggTargets.cmake) - -if(INSTALL_CMAKE_PACKAGE_MODULE) - set(CMAKE_INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Ogg) - install(EXPORT OggTargets - DESTINATION ${CMAKE_INSTALL_CONFIGDIR} - NAMESPACE Ogg:: - ) - - include(CMakePackageConfigHelpers) - - configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/OggConfig.cmake.in ${PROJECT_BINARY_DIR}/OggConfig.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_CONFIGDIR} - PATH_VARS CMAKE_INSTALL_FULL_INCLUDEDIR - ) - - write_basic_package_version_file(${PROJECT_BINARY_DIR}/OggConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion - ) - - install(FILES ${PROJECT_BINARY_DIR}/OggConfig.cmake ${PROJECT_BINARY_DIR}/OggConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_CONFIGDIR} - ) -endif() - -if(INSTALL_PKG_CONFIG_MODULE) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ogg.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - ) -endif() - -if(INSTALL_DOCS) - set(OGG_DOCS - doc/framing.html - doc/index.html - doc/oggstream.html - doc/ogg-multiplex.html - doc/fish_xiph_org.png - doc/multiplex1.png - doc/packets.png - doc/pages.png - doc/stream.png - doc/vorbisword2.png - doc/white-ogg.png - doc/white-xifish.png - doc/rfc3533.txt - doc/rfc5334.txt - doc/skeleton.html - ) - install(FILES ${OGG_DOCS} DESTINATION ${CMAKE_INSTALL_DOCDIR}/html) - install(DIRECTORY doc/libogg DESTINATION ${CMAKE_INSTALL_DOCDIR}/html PATTERN "*.am" EXCLUDE) -endif() - -if(BUILD_TESTING) - add_executable(test_bitwise src/bitwise.c ${OGG_HEADERS}) - target_compile_definitions(test_bitwise PRIVATE _V_SELFTEST) - target_include_directories(test_bitwise PRIVATE - include - ${CMAKE_CURRENT_BINARY_DIR}/include - ) - add_test(NAME test_bitwise COMMAND $) - - add_executable(test_framing src/framing.c ${OGG_HEADERS}) - target_compile_definitions(test_framing PRIVATE _V_SELFTEST) - target_include_directories(test_framing PRIVATE - include - ${CMAKE_CURRENT_BINARY_DIR}/include - ) - add_test(NAME test_framing COMMAND $) -endif() - diff --git a/Engine/lib/libogg/COPYING b/Engine/lib/libogg/COPYING deleted file mode 100644 index 6111c6c5a..000000000 --- a/Engine/lib/libogg/COPYING +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2002, Xiph.org Foundation - -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 the Xiph.org Foundation nor the names of its -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 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. diff --git a/Engine/lib/libogg/Makefile.am b/Engine/lib/libogg/Makefile.am deleted file mode 100644 index a12c0be8c..000000000 --- a/Engine/lib/libogg/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -## Process this file with automake to produce Makefile.in - - -#AUTOMAKE_OPTIONS = foreign 1.6 dist-zip -AUTOMAKE_OPTIONS = foreign 1.11 dist-zip dist-xz -ACLOCAL_AMFLAGS = -I m4 - -SUBDIRS = src include doc - -m4datadir = $(datadir)/aclocal -m4data_DATA = ogg.m4 - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = ogg.pc - -EXTRA_DIST = README.md AUTHORS CHANGES COPYING \ - libogg.spec libogg.spec.in \ - ogg.m4 ogg.pc.in ogg-uninstalled.pc.in \ - win32 CMakeLists.txt cmake - -dist-hook: - for item in $(EXTRA_DIST); do \ - if test -d $$item; then \ - echo -n "cleaning dir $$item for distribution..."; \ - rm -rf `find $(distdir)/$$item -name .svn`; \ - echo "OK"; \ - fi; \ - done - -# Verify cmake works with the dist tarball. -cmake_builddir = _build.cmake -distcheck-hook: - $(RM) -rf $(cmake_builddir) - mkdir $(cmake_builddir) - cd $(cmake_builddir) && cmake ../$(top_distdir) - cd $(cmake_builddir) && cmake --build . - cd $(cmake_builddir) && ctest - $(RM) -rf $(cmake_builddir) - -debug: - $(MAKE) all CFLAGS="@DEBUG@" - -profile: - $(MAKE) all CFLAGS="@PROFILE@" diff --git a/Engine/lib/libogg/README.md b/Engine/lib/libogg/README.md deleted file mode 100644 index 0101cb14d..000000000 --- a/Engine/lib/libogg/README.md +++ /dev/null @@ -1,160 +0,0 @@ -# Ogg - -[![Travis Build Status](https://travis-ci.org/xiph/ogg.svg?branch=master)](https://travis-ci.org/xiph/ogg) -[![Jenkins Build Status](https://mf4.xiph.org/jenkins/job/libogg/badge/icon)](https://mf4.xiph.org/jenkins/job/libogg/) -[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/xiph/ogg?branch=master&svg=true)](https://ci.appveyor.com/project/rillian/ogg) - -Ogg project codecs use the Ogg bitstream format to arrange the raw, -compressed bitstream into a more robust, useful form. For example, -the Ogg bitstream makes seeking, time stamping and error recovery -possible, as well as mixing several sepearate, concurrent media -streams into a single physical bitstream. - -## What's here ## -This source distribution includes libogg and nothing else. Other modules -(eg, the modules libvorbis, vorbis-tools for the Vorbis music codec, -libtheora for the Theora video codec) contain the codec libraries for -use with Ogg bitstreams. - -Directory: - -- `src` The source for libogg, a BSD-license inplementation of the public domain Ogg bitstream format - -- `include` Library API headers - -- `doc` Ogg specification and libogg API documents - -- `win32` Win32 projects and build automation - -## Contact ## - -The Ogg homepage is located at https://www.xiph.org/ogg/ . -Up to date technical documents, contact information, source code and -pre-built utilities may be found there. - -## Building ## - -#### Building from tarball distributions #### - - ./configure - make - -and optionally (as root): - - make install - -This will install the Ogg libraries (static and shared) into -/usr/local/lib, includes into /usr/local/include and API -documentation into /usr/local/share/doc. - -#### Building from repository source #### - -A standard svn build should consist of nothing more than: - - ./autogen.sh - ./configure - make - -and as root if desired : - - make install - -#### Building on Windows #### - -Use the project file in the win32 directory. It should compile out of the box. - -#### Cross-compiling from Linux to Windows #### - -It is also possible to cross compile from Linux to windows using the MinGW -cross tools and even to run the test suite under Wine, the Linux/*nix -windows emulator. - -On Debian and Ubuntu systems, these cross compiler tools can be installed -by doing: - - sudo apt-get mingw32 mingw32-binutils mingw32-runtime wine - -Once these tools are installed its possible to compile and test by -executing the following commands, or something similar depending on -your system: - - ./configure --host=i586-mingw32msvc --target=i586-mingw32msvc --build=i586-linux - make - make check - -(Build instructions for Ogg codecs such as vorbis are similar and may -be found in those source modules' README files) - -## Building with CMake ## - -Ogg supports building using [CMake](http://www.cmake.org/). CMake is a meta build system that generates native projects for each platform. -To generate projects just run cmake replacing `YOUR-PROJECT-GENERATOR` with a proper generator from a list [here](http://www.cmake.org/cmake/help/v3.2/manual/cmake-generators.7.html): - - mkdir build - cd build - cmake -G YOUR-PROJECT-GENERATOR .. - -Note that by default cmake generates projects that will build static libraries. -To generate projects that will build dynamic library use `BUILD_SHARED_LIBS` option like this: - - cmake -G YOUR-PROJECT-GENERATOR -DBUILD_SHARED_LIBS=1 .. - -After projects are generated use them as usual - -#### Building on Windows #### - -Use proper generator for your Visual Studio version like: - - cmake -G "Visual Studio 12 2013" .. - -#### Building on Mac OS X #### - -Use Xcode generator. To build framework run: - - cmake -G Xcode -DBUILD_FRAMEWORK=1 .. - -#### Building on Linux #### - -Use Makefile generator which is default one. - - cmake .. - make - -## Testing ## - -This package includes a collection of automated tests. -Running them is not part of building nor installation but optional. - -### Unix-like System or MinGW ### - -If build under automake: - - make check - -If build under CMake: - - make test - -or: - - ctest - -### Windows with MSBuild ### - -If build with configuration type "Debug", then: - - ctest -C Debug - -If build with configuration type "Release", then: - - ctest -C Release - -## License ## - -THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. -USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS -GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE -IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. - -THE OggVorbis SOURCE CODE IS COPYRIGHT (C) 1994-2019 -by the Xiph.Org Foundation https://www.xiph.org/ diff --git a/Engine/lib/libogg/appveyor.yml b/Engine/lib/libogg/appveyor.yml deleted file mode 100644 index 653d8ace9..000000000 --- a/Engine/lib/libogg/appveyor.yml +++ /dev/null @@ -1,33 +0,0 @@ -image: Visual Studio 2015 -configuration: -- Debug -- Release - -platform: -- Win32 -- x64 - -environment: - matrix: - - BUILD_SYSTEM: MSVC - - BUILD_SYSTEM: CMAKE - -build_script: - - if "%BUILD_SYSTEM%" == "MSVC" ( - msbuild "%APPVEYOR_BUILD_FOLDER%\win32\VS2015\libogg.sln" /m /v:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /property:Configuration=%CONFIGURATION%;Platform=%PLATFORM% - ) - - if "%BUILD_SYSTEM%" == "CMAKE" ( - mkdir "%APPVEYOR_BUILD_FOLDER%\build" && - pushd "%APPVEYOR_BUILD_FOLDER%\build" && - cmake -A "%PLATFORM%" -G "Visual Studio 14 2015" .. && - cmake --build . --config "%CONFIGURATION%" -- /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" && - popd - ) - -after_build: - - if "%BUILD_SYSTEM%" == "MSVC" ( - 7z a ogg.zip win32\VS2015\%PLATFORM%\%CONFIGURATION%\libogg.lib include\ogg\*.h - ) - -artifacts: -- path: ogg.zip diff --git a/Engine/lib/libogg/autogen.sh b/Engine/lib/libogg/autogen.sh deleted file mode 100644 index f6490cc0e..000000000 --- a/Engine/lib/libogg/autogen.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Run this to set up the build system: configure, makefiles, etc. -set -e - -package="libogg" - -srcdir=`dirname $0` -test -n "$srcdir" && cd "$srcdir" - -echo "Updating build configuration files for $package, please wait...." - -mkdir -p m4 -autoreconf -if diff --git a/Engine/lib/libogg/cmake/CheckSizes.cmake b/Engine/lib/libogg/cmake/CheckSizes.cmake deleted file mode 100644 index 4d6c8a0b8..000000000 --- a/Engine/lib/libogg/cmake/CheckSizes.cmake +++ /dev/null @@ -1,73 +0,0 @@ -include(CheckTypeSize) - -check_type_size("int16_t" INT16_SIZE LANGUAGE C) -check_type_size("uint16_t" UINT16_SIZE LANGUAGE C) -check_type_size("u_int16_t" U_INT16_SIZE LANGUAGE C) -check_type_size("int32_t" INT32_SIZE LANGUAGE C) -check_type_size("uint32_t" UINT32_SIZE LANGUAGE C) -check_type_size("u_int32_t" U_INT32_SIZE LANGUAGE C) -check_type_size("int64_t" INT64_SIZE LANGUAGE C) -check_type_size("short" SHORT_SIZE LANGUAGE C) -check_type_size("int" INT_SIZE LANGUAGE C) -check_type_size("long" LONG_SIZE LANGUAGE C) -check_type_size("long long" LONG_LONG_SIZE LANGUAGE C) - -if(INT16_SIZE EQUAL 2) - set(SIZE16 "int16_t") -elseif(SHORT_SIZE EQUAL 2) - set(SIZE16 "short") -elseif(INT_SIZE EQUAL 2) - set(SIZE16 "int") -else() - message(FATAL_ERROR "No 16 bit type found on this platform!") -endif() - -if(UINT16_SIZE EQUAL 2) - set(USIZE16 "uint16_t") -elseif(SHORT_SIZE EQUAL 2) - set(USIZE16 "unsigned short") -elseif(INT_SIZE EQUAL 2) - set(USIZE16 "unsigned int") -elseif(U_INT_SIZE EQUAL 2) - set(USIZE16 "u_int16_t") -else() - message(FATAL_ERROR "No unsigned 16 bit type found on this platform!") -endif() - -if(INT32_SIZE EQUAL 4) - set(SIZE32 "int32_t") -elseif(SHORT_SIZE EQUAL 4) - set(SIZE32 "short") -elseif(INT_SIZE EQUAL 4) - set(SIZE32 "int") -elseif(LONG_SIZE EQUAL 4) - set(SIZE16 "long") -else() - message(FATAL_ERROR "No 32 bit type found on this platform!") -endif() - -if(UINT32_SIZE EQUAL 4) - set(USIZE32 "uint32_t") -elseif(SHORT_SIZE EQUAL 4) - set(USIZE32 "unsigned short") -elseif(INT_SIZE EQUAL 4) - set(USIZE32 "unsigned int") -elseif(LONG_SIZE EQUAL 4) - set(USIZE32 "unsigned long") -elseif(U_INT_SIZE EQUAL 4) - set(USIZE32 "u_int32_t") -else() - message(FATAL_ERROR "No unsigned 32 bit type found on this platform!") -endif() - -if(INT64_SIZE EQUAL 8) - set(SIZE64 "int64_t") -elseif(INT_SIZE EQUAL 8) - set(SIZE64 "int") -elseif(LONG_SIZE EQUAL 8) - set(SIZE64 "long") -elseif(LONG_LONG_SIZE EQUAL 8) - set(SIZE64 "long long") -else() - message(FATAL_ERROR "No 64 bit type found on this platform!") -endif() diff --git a/Engine/lib/libogg/cmake/OggConfig.cmake.in b/Engine/lib/libogg/cmake/OggConfig.cmake.in deleted file mode 100644 index 43de6a933..000000000 --- a/Engine/lib/libogg/cmake/OggConfig.cmake.in +++ /dev/null @@ -1,16 +0,0 @@ -@PACKAGE_INIT@ - -set(Ogg_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@") -set(OGG_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@") -set(Ogg_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@") -set(OGG_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@") - -include(${CMAKE_CURRENT_LIST_DIR}/OggTargets.cmake) - -set(Ogg_LIBRARY Ogg::ogg) -set(OGG_LIBRARY Ogg::ogg) -set(Ogg_LIBRARIES Ogg::ogg) -set(OGG_LIBRARIES Ogg::ogg) - -check_required_components(Ogg) -set(OGG_FOUND 1) diff --git a/Engine/lib/libogg/configure.ac b/Engine/lib/libogg/configure.ac deleted file mode 100644 index 11ade65c8..000000000 --- a/Engine/lib/libogg/configure.ac +++ /dev/null @@ -1,238 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. - -AC_INIT([libogg],[1.3.5],[ogg-dev@xiph.org]) - -LT_INIT -AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_SRCDIR(src/framing.c) - -AM_INIT_AUTOMAKE -AM_MAINTAINER_MODE([enable]) - -dnl Library versioning - -LIB_CURRENT=8 -LIB_REVISION=5 -LIB_AGE=8 -AC_SUBST(LIB_CURRENT) -AC_SUBST(LIB_REVISION) -AC_SUBST(LIB_AGE) - -AC_PROG_CC -AM_PROG_CC_C_O - -dnl Set some options based on environment - -cflags_save="$CFLAGS" -if test -z "$GCC"; then - case $host in - *-*-irix*) - DEBUG="-g -signed" - CFLAGS="-O2 -w -signed" - PROFILE="-p -g3 -O2 -signed" - ;; - sparc-sun-solaris*) - DEBUG="-v -g" - CFLAGS="-xO4 -fast -w -fsimple -native -xcg92" - PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc" - ;; - *) - DEBUG="-g" - CFLAGS="-O" - PROFILE="-g -p" - ;; - esac -else - case $host in - *-*-linux*) - DEBUG="-g -Wall -Wextra -fsigned-char" - CFLAGS="-O2 -Wall -Wextra -ffast-math -fsigned-char" - PROFILE="-Wall -Wextra -W -pg -g -O2 -ffast-math -fsigned-char" - ;; - sparc-sun-*) - DEBUG="-g -Wall -Wextra -fsigned-char" - CFLAGS="-O2 -ffast-math -fsigned-char" - PROFILE="-pg -g -O2 -fsigned-char" - ;; - *-*-darwin*) - DEBUG="-fno-common -g -Wall -Wextra -fsigned-char" - CFLAGS="-fno-common -O4 -Wall -Wextra -fsigned-char -ffast-math" - PROFILE="-fno-common -O4 -Wall -Wextra -pg -g -fsigned-char -ffast-math" - ;; - *) - DEBUG="-g -Wall -Wextra -fsigned-char" - CFLAGS="-O2 -fsigned-char" - PROFILE="-O2 -g -pg -fsigned-char" - ;; - esac -fi -CFLAGS="$CFLAGS $cflags_save" -DEBUG="$DEBUG $cflags_save" -PROFILE="$PROFILE $cflags_save" - -dnl Checks for programs. - -dnl Checks for libraries. - -dnl Checks for header files. -INCLUDE_INTTYPES_H=0 -INCLUDE_STDINT_H=0 -INCLUDE_SYS_TYPES_H=0 -AC_CHECK_HEADER(inttypes.h,INCLUDE_INTTYPES_H=1) -AC_CHECK_HEADER(stdint.h,INCLUDE_STDINT_H=1) -AC_CHECK_HEADER(sys/types.h,INCLUDE_SYS_TYPES_H=1) - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST - -dnl Check for types - -AC_CHECK_SIZEOF(int16_t) -AC_CHECK_SIZEOF(uint16_t) -AC_CHECK_SIZEOF(u_int16_t) -AC_CHECK_SIZEOF(int32_t) -AC_CHECK_SIZEOF(uint32_t) -AC_CHECK_SIZEOF(u_int32_t) -AC_CHECK_SIZEOF(int64_t) -AC_CHECK_SIZEOF(uint64_t) -AC_CHECK_SIZEOF(short) -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(long) -AC_CHECK_SIZEOF(long long) - -case 2 in - $ac_cv_sizeof_int16_t) SIZE16="int16_t";; - $ac_cv_sizeof_short) SIZE16="short";; - $ac_cv_sizeof_int) SIZE16="int";; -esac - -case 2 in - $ac_cv_sizeof_uint16_t) USIZE16="uint16_t";; - $ac_cv_sizeof_short) USIZE16="unsigned short";; - $ac_cv_sizeof_int) USIZE16="unsigned int";; - $ac_cv_sizeof_u_int16_t) USIZE16="u_int16_t";; -esac - -case 4 in - $ac_cv_sizeof_int32_t) SIZE32="int32_t";; - $ac_cv_sizeof_short) SIZE32="short";; - $ac_cv_sizeof_int) SIZE32="int";; - $ac_cv_sizeof_long) SIZE32="long";; -esac - -case 4 in - $ac_cv_sizeof_uint32_t) USIZE32="uint32_t";; - $ac_cv_sizeof_short) USIZE32="unsigned short";; - $ac_cv_sizeof_int) USIZE32="unsigned int";; - $ac_cv_sizeof_long) USIZE32="unsigned long";; - $ac_cv_sizeof_u_int32_t) USIZE32="u_int32_t";; -esac - -case 8 in - $ac_cv_sizeof_int64_t) SIZE64="int64_t";; - $ac_cv_sizeof_int) SIZE64="int";; - $ac_cv_sizeof_long) SIZE64="long";; - $ac_cv_sizeof_long_long) SIZE64="long long";; -esac - -case 8 in - $ac_cv_sizeof_uint64_t) USIZE64="uint64_t";; - $ac_cv_sizeof_unsigned_int) USIZE64="unsigned int";; - $ac_cv_sizeof_unsigned_long) USIZE64="unsigned long";; - $ac_cv_sizeof_unsigned_long_long) USIZE64="unsigned long long";; -esac - -if test -z "$SIZE16"; then - AC_MSG_ERROR(No 16 bit type found on this platform!) -fi -if test -z "$USIZE16"; then - AC_MSG_ERROR(No unsigned 16 bit type found on this platform!) -fi -if test -z "$SIZE32"; then - AC_MSG_ERROR(No 32 bit type found on this platform!) -fi -if test -z "$USIZE32"; then - AC_MSG_ERROR(No unsigned 32 bit type found on this platform!) -fi -if test -z "$SIZE64"; then - AC_MSG_WARN(No 64 bit type found on this platform!) -fi -if test -z "$USIZE64"; then - AC_MSG_WARN(No unsigned 64 bit type found on this platform!) -fi - -AC_ARG_ENABLE([crc], - [AS_HELP_STRING([--disable-crc], - [Disable CRC in the demuxer])],, - [enable_crc=yes]) - -AM_CONDITIONAL([DISABLE_CRC], [test "$enable_crc" = "no"]) - -AS_IF([test "$enable_crc" = "no"],[ - AC_DEFINE([DISABLE_CRC], [1], [Do not build with CRC]) -]) - -dnl Checks for library functions. -AC_FUNC_MEMCMP - -AC_ARG_ENABLE(gcc-sanitizers, - AS_HELP_STRING([--enable-gcc-sanitizers], [Enable GCC sanitizers]), - [ ac_enable_gcc_sanitizers=$enableval ], [ ac_enable_gcc_sanitizers=no] ) - -if test "$GCC" && test "x${ac_enable_gcc_sanitizers}" = xyes; then - CFLAGS="${CFLAGS} -fsanitize=address -fsanitize=undefined -g" - LDFLAGS="${CFLAGS} -fsanitize=address" - - TEST_ENV="env UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1" - AC_SUBST(TEST_ENV) -fi - -# Check for valgrind -AC_ARG_ENABLE(valgrind-testing, - AS_HELP_STRING([--enable-valgrind-testing],[enable running of tests inside Valgrind (default disabled)])) -if test "x$enable_valgrind_testing" = "xyes" -then - AC_PATH_PROG(VALGRIND,valgrind,) - if test "x$VALGRIND" != "x" - then - VALGRIND="$VALGRIND -q --error-exitcode=99 --leak-check=full --show-reachable=yes --num-callers=50" - TESTS_INFO="Test suite will be run under: - ${VALGRIND}" - else - TESTS_INFO="Type 'make check' to run test suite (Valgrind not found)" - fi -else - TESTS_INFO="Type 'make check' to run test suite (Valgrind testing not enabled)" -fi - -dnl Make substitutions - -AC_SUBST(LIBTOOL_DEPS) -AC_SUBST(INCLUDE_INTTYPES_H) -AC_SUBST(INCLUDE_STDINT_H) -AC_SUBST(INCLUDE_SYS_TYPES_H) -AC_SUBST(SIZE16) -AC_SUBST(USIZE16) -AC_SUBST(SIZE32) -AC_SUBST(USIZE32) -AC_SUBST(SIZE64) -AC_SUBST(USIZE64) -AC_SUBST(OPT) -AC_SUBST(LIBS) -AC_SUBST(DEBUG) -AC_SUBST(CFLAGS) -AC_SUBST(PROFILE) - - -AC_CONFIG_FILES([ -Makefile -src/Makefile -doc/Makefile doc/libogg/Makefile -include/Makefile include/ogg/Makefile include/ogg/config_types.h -libogg.spec -ogg.pc -ogg-uninstalled.pc -]) -AC_CONFIG_HEADERS([config.h]) - -AC_OUTPUT diff --git a/Engine/lib/libogg/doc/Makefile.am b/Engine/lib/libogg/doc/Makefile.am deleted file mode 100644 index 3dd47b92c..000000000 --- a/Engine/lib/libogg/doc/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -## Process this with automake to create Makefile.in - -SUBDIRS = libogg - -dist_html_DATA = framing.html index.html oggstream.html ogg-multiplex.html \ - fish_xiph_org.png multiplex1.png packets.png pages.png stream.png \ - vorbisword2.png white-ogg.png white-xifish.png \ - rfc3533.txt rfc5334.txt skeleton.html - diff --git a/Engine/lib/libogg/doc/fish_xiph_org.png b/Engine/lib/libogg/doc/fish_xiph_org.png deleted file mode 100644 index b398c06cf..000000000 Binary files a/Engine/lib/libogg/doc/fish_xiph_org.png and /dev/null differ diff --git a/Engine/lib/libogg/doc/framing.html b/Engine/lib/libogg/doc/framing.html deleted file mode 100644 index b5ac6ac2d..000000000 --- a/Engine/lib/libogg/doc/framing.html +++ /dev/null @@ -1,429 +0,0 @@ - - - - - -Ogg Documentation - - - - - - - - - -

Ogg logical bitstream framing

- -

Ogg bitstreams

- -

The Ogg transport bitstream is designed to provide framing, error -protection and seeking structure for higher-level codec streams that -consist of raw, unencapsulated data packets, such as the Vorbis audio -codec or Theora video codec.

- -

Application example: Vorbis

- -

Vorbis encodes short-time blocks of PCM data into raw packets of -bit-packed data. These raw packets may be used directly by transport -mechanisms that provide their own framing and packet-separation -mechanisms (such as UDP datagrams). For stream based storage (such as -files) and transport (such as TCP streams or pipes), Vorbis uses the -Ogg bitstream format to provide framing/sync, sync recapture -after error, landmarks during seeking, and enough information to -properly separate data back into packets at the original packet -boundaries without relying on decoding to find packet boundaries.

- -

Design constraints for Ogg bitstreams

- -
    -
  1. True streaming; we must not need to seek to build a 100% - complete bitstream.
  2. -
  3. Use no more than approximately 1-2% of bitstream bandwidth for - packet boundary marking, high-level framing, sync and seeking.
  4. -
  5. Specification of absolute position within the original sample - stream.
  6. -
  7. Simple mechanism to ease limited editing, such as a simplified - concatenation mechanism.
  8. -
  9. Detection of corruption, recapture after error and direct, random - access to data at arbitrary positions in the bitstream.
  10. -
- -

Logical and Physical Bitstreams

- -

A logical Ogg bitstream is a contiguous stream of -sequential pages belonging only to the logical bitstream. A -physical Ogg bitstream is constructed from one or more -than one logical Ogg bitstream (the simplest physical bitstream -is simply a single logical bitstream). We describe below the exact -formatting of an Ogg logical bitstream. Combining logical -bitstreams into more complex physical bitstreams is described in the -Ogg bitstream overview. The exact -mapping of raw Vorbis packets into a valid Ogg Vorbis physical -bitstream is described in the Vorbis I Specification.

- -

Bitstream structure

- -

An Ogg stream is structured by dividing incoming packets into -segments of up to 255 bytes and then wrapping a group of contiguous -packet segments into a variable length page preceded by a page -header. Both the header size and page size are variable; the page -header contains sizing information and checksum data to determine -header/page size and data integrity.

- -

The bitstream is captured (or recaptured) by looking for the beginning -of a page, specifically the capture pattern. Once the capture pattern -is found, the decoder verifies page sync and integrity by computing -and comparing the checksum. At that point, the decoder can extract the -packets themselves.

- -

Packet segmentation

- -

Packets are logically divided into multiple segments before encoding -into a page. Note that the segmentation and fragmentation process is a -logical one; it's used to compute page header values and the original -page data need not be disturbed, even when a packet spans page -boundaries.

- -

The raw packet is logically divided into [n] 255 byte segments and a -last fractional segment of < 255 bytes. A packet size may well -consist only of the trailing fractional segment, and a fractional -segment may be zero length. These values, called "lacing values" are -then saved and placed into the header segment table.

- -

An example should make the basic concept clear:

- -
-
-raw packet:
-  ___________________________________________
- |______________packet data__________________| 753 bytes
-
-lacing values for page header segment table: 255,255,243
-
-
- -

We simply add the lacing values for the total size; the last lacing -value for a packet is always the value that is less than 255. Note -that this encoding both avoids imposing a maximum packet size as well -as imposing minimum overhead on small packets (as opposed to, eg, -simply using two bytes at the head of every packet and having a max -packet size of 32k. Small packets (<255, the typical case) are -penalized with twice the segmentation overhead). Using the lacing -values as suggested, small packets see the minimum possible -byte-aligned overhead (1 byte) and large packets, over 512 bytes or -so, see a fairly constant ~.5% overhead on encoding space.

- -

Note that a lacing value of 255 implies that a second lacing value -follows in the packet, and a value of < 255 marks the end of the -packet after that many additional bytes. A packet of 255 bytes (or a -multiple of 255 bytes) is terminated by a lacing value of 0:

- -

-raw packet:
-  _______________________________
- |________packet data____________|          255 bytes
-
-lacing values: 255, 0
-
- -

Note also that a 'nil' (zero length) packet is not an error; it -consists of nothing more than a lacing value of zero in the header.

- -

Packets spanning pages

- -

Packets are not restricted to beginning and ending within a page, -although individual segments are, by definition, required to do so. -Packets are not restricted to a maximum size, although excessively -large packets in the data stream are discouraged.

- -

After segmenting a packet, the encoder may decide not to place all the -resulting segments into the current page; to do so, the encoder places -the lacing values of the segments it wishes to belong to the current -page into the current segment table, then finishes the page. The next -page is begun with the first value in the segment table belonging to -the next packet segment, thus continuing the packet (data in the -packet body must also correspond properly to the lacing values in the -spanned pages. The segment data in the first packet corresponding to -the lacing values of the first page belong in that page; packet -segments listed in the segment table of the following page must begin -the page body of the subsequent page).

- -

The last mechanic to spanning a page boundary is to set the header -flag in the new page to indicate that the first lacing value in the -segment table continues rather than begins a packet; a header flag of -0x01 is set to indicate a continued packet. Although mandatory, it -is not actually algorithmically necessary; one could inspect the -preceding segment table to determine if the packet is new or -continued. Adding the information to the packet_header flag allows a -simpler design (with no overhead) that needs only inspect the current -page header after frame capture. This also allows faster error -recovery in the event that the packet originates in a corrupt -preceding page, implying that the previous page's segment table -cannot be trusted.

- -

Note that a packet can span an arbitrary number of pages; the above -spanning process is repeated for each spanned page boundary. Also a -'zero termination' on a packet size that is an even multiple of 255 -must appear even if the lacing value appears in the next page as a -zero-length continuation of the current packet. The header flag -should be set to 0x01 to indicate that the packet spanned, even though -the span is a nil case as far as data is concerned.

- -

The encoding looks odd, but is properly optimized for speed and the -expected case of the majority of packets being between 50 and 200 -bytes (note that it is designed such that packets of wildly different -sizes can be handled within the model; placing packet size -restrictions on the encoder would have only slightly simplified design -in page generation and increased overall encoder complexity).

- -

The main point behind tracking individual packets (and packet -segments) is to allow more flexible encoding tricks that requiring -explicit knowledge of packet size. An example is simple bandwidth -limiting, implemented by simply truncating packets in the nominal case -if the packet is arranged so that the least sensitive portion of the -data comes last.

- - -

Page header

- -

The headering mechanism is designed to avoid copying and re-assembly -of the packet data (ie, making the packet segmentation process a -logical one); the header can be generated directly from incoming -packet data. The encoder buffers packet data until it finishes a -complete page at which point it writes the header followed by the -buffered packet segments.

- -

capture_pattern

- -

A header begins with a capture pattern that simplifies identifying -pages; once the decoder has found the capture pattern it can do a more -intensive job of verifying that it has in fact found a page boundary -(as opposed to an inadvertent coincidence in the byte stream).

- -

- byte value
-
-  0  0x4f 'O'
-  1  0x67 'g'
-  2  0x67 'g'
-  3  0x53 'S'  
-
- -

stream_structure_version

- -

The capture pattern is followed by the stream structure revision:

- -

- byte value
-
-  4  0x00
-
- -

header_type_flag

- -

The header type flag identifies this page's context in the bitstream:

- -

- byte value
-
-  5  bitflags: 0x01: unset = fresh packet
-	               set = continued packet
-	       0x02: unset = not first page of logical bitstream
-                       set = first page of logical bitstream (bos)
-	       0x04: unset = not last page of logical bitstream
-                       set = last page of logical bitstream (eos)
-
- -

absolute granule position

- -

(This is packed in the same way the rest of Ogg data is packed; LSb -of LSB first. Note that the 'position' data specifies a 'sample' -number (eg, in a CD quality sample is four octets, 16 bits for left -and 16 bits for right; in video it would likely be the frame number. -It is up to the specific codec in use to define the semantic meaning -of the granule position value). The position specified is the total -samples encoded after including all packets finished on this page -(packets begun on this page but continuing on to the next page do not -count). The rationale here is that the position specified in the -frame header of the last page tells how long the data coded by the -bitstream is. A truncated stream will still return the proper number -of samples that can be decoded fully.

- -

A special value of '-1' (in two's complement) indicates that no packets -finish on this page.

- -

- byte value
-
-  6  0xXX LSB
-  7  0xXX
-  8  0xXX
-  9  0xXX
- 10  0xXX
- 11  0xXX
- 12  0xXX
- 13  0xXX MSB
-
- -

stream serial number

- -

Ogg allows for separate logical bitstreams to be mixed at page -granularity in a physical bitstream. The most common case would be -sequential arrangement, but it is possible to interleave pages for -two separate bitstreams to be decoded concurrently. The serial -number is the means by which pages physical pages are associated with -a particular logical stream. Each logical stream must have a unique -serial number within a physical stream:

- -

- byte value
-
- 14  0xXX LSB
- 15  0xXX
- 16  0xXX
- 17  0xXX MSB
-
- -

page sequence no

- -

Page counter; lets us know if a page is lost (useful where packets -span page boundaries).

- -

- byte value
-
- 18  0xXX LSB
- 19  0xXX
- 20  0xXX
- 21  0xXX MSB
-
- -

page checksum

- -

32 bit CRC value (direct algorithm, initial val and final XOR = 0, -generator polynomial=0x04c11db7). The value is computed over the -entire header (with the CRC field in the header set to zero) and then -continued over the page. The CRC field is then filled with the -computed value.

- -

(A thorough discussion of CRC algorithms can be found in "A -Painless Guide to CRC Error Detection Algorithms" by Ross -Williams ross@ross.net.)

- -

- byte value
-
- 22  0xXX LSB
- 23  0xXX
- 24  0xXX
- 25  0xXX MSB
-
- -

page_segments

- -

The number of segment entries to appear in the segment table. The -maximum number of 255 segments (255 bytes each) sets the maximum -possible physical page size at 65307 bytes or just under 64kB (thus -we know that a header corrupted so as destroy sizing/alignment -information will not cause a runaway bitstream. We'll read in the -page according to the corrupted size information that's guaranteed to -be a reasonable size regardless, notice the checksum mismatch, drop -sync and then look for recapture).

- -

- byte value
-
- 26 0x00-0xff (0-255)
-
- -

segment_table (containing packet lacing values)

- -

The lacing values for each packet segment physically appearing in -this page are listed in contiguous order.

- -

- byte value
-
- 27 0x00-0xff (0-255)
- [...]
- n  0x00-0xff (0-255, n=page_segments+26)
-
- -

Total page size is calculated directly from the known header size and -lacing values in the segment table. Packet data segments follow -immediately after the header.

- -

Page headers typically impose a flat .25-.5% space overhead assuming -nominal ~8k page sizes. The segmentation table needed for exact -packet recovery in the streaming layer adds approximately .5-1% -nominal assuming expected encoder behavior in the 44.1kHz, 128kbps -stereo encodings.

- - - - - diff --git a/Engine/lib/libogg/doc/index.html b/Engine/lib/libogg/doc/index.html deleted file mode 100644 index 6e02f7971..000000000 --- a/Engine/lib/libogg/doc/index.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - -Ogg Documentation - - - - - - - - - -

Ogg Documentation

- -

Ogg programming documentation

- - - -

Ogg bitstream documentation

- - - -

RFC documentation

- - - - - - - diff --git a/Engine/lib/libogg/doc/libogg/Makefile.am b/Engine/lib/libogg/doc/libogg/Makefile.am deleted file mode 100644 index 4007907a9..000000000 --- a/Engine/lib/libogg/doc/libogg/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -## Process this file with automake to produce Makefile.in - -apidocdir = $(htmldir)/libogg - -dist_apidoc_DATA = bitpacking.html datastructures.html decoding.html encoding.html\ - general.html index.html ogg_iovec_t.html ogg_packet.html ogg_packet_clear.html\ - ogg_page.html ogg_page_bos.html ogg_page_checksum_set.html\ - ogg_page_continued.html ogg_page_eos.html ogg_page_granulepos.html\ - ogg_page_packets.html ogg_page_pageno.html ogg_page_serialno.html\ - ogg_page_version.html ogg_stream_check.html ogg_stream_clear.html ogg_stream_destroy.html\ - ogg_stream_eos.html ogg_stream_flush.html ogg_stream_flush_fill.html ogg_stream_init.html\ - ogg_stream_iovecin.html ogg_stream_packetin.html ogg_stream_packetout.html\ - ogg_stream_packetpeek.html ogg_stream_pagein.html\ - ogg_stream_pageout.html ogg_stream_pageout_fill.html ogg_stream_reset.html\ - ogg_stream_reset_serialno.html ogg_stream_state.html\ - ogg_sync_buffer.html ogg_sync_check.html ogg_sync_clear.html ogg_sync_destroy.html\ - ogg_sync_init.html ogg_sync_pageout.html ogg_sync_pageseek.html\ - ogg_sync_reset.html ogg_sync_state.html ogg_sync_wrote.html\ - oggpack_adv.html oggpack_adv1.html oggpack_bits.html\ - oggpack_buffer.html oggpack_bytes.html oggpack_get_buffer.html\ - oggpack_look.html oggpack_look1.html oggpack_read.html\ - oggpack_read1.html oggpack_readinit.html oggpack_reset.html\ - oggpack_write.html oggpack_writealign.html oggpack_writecheck.html oggpack_writeclear.html\ - oggpack_writecopy.html oggpack_writeinit.html oggpack_writetrunc.html\ - overview.html reference.html style.css - -update-doc-version: - @YEAR=$$(date +%Y); DAY=$$(date +%Y%m%d); \ - for f in $(srcdir)/*.html; do \ - sed -e "s/2000-[0-9]\{4\} Xiph.Org/2000-$$YEAR Xiph.Org/g" \ - -e "s/libogg release [0-9. -]\+/libogg release $(VERSION) - $$DAY/g"\ - < $$f > $$f.tmp; \ - if diff -q $$f $$f.tmp > /dev/null; then \ - rm $$f.tmp; \ - else \ - mv $$f.tmp $$f; \ - fi; \ - done; - diff --git a/Engine/lib/libogg/doc/libogg/bitpacking.html b/Engine/lib/libogg/doc/libogg/bitpacking.html deleted file mode 100644 index c61550044..000000000 --- a/Engine/lib/libogg/doc/libogg/bitpacking.html +++ /dev/null @@ -1,103 +0,0 @@ - - - -libogg - Bitpacking Functions - - - - - - - - - -

libogg documentation

libogg release 1.3.5 - 20210603

- -

Bitpacking Functions

-

Libogg contains a basic bitpacking library that is useful for manipulating data within a buffer. -

-All the libogg specific functions are declared in "ogg/ogg.h". -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
functionpurpose
oggpack_writeinitInitializes a buffer for writing using this bitpacking library.
oggpack_writecheckAsynchronously checks error status of bitpacker write buffer.
oggpack_resetClears and resets the buffer to the initial position.
oggpack_writeclearFrees the memory used by the buffer.
oggpack_readinitInitializes a buffer for reading using this bitpacking library.
oggpack_writeWrites bytes to the specified location within the buffer.
oggpack_lookLook at a specified number of bits, <=32, without advancing the location pointer.
oggpack_look1Looks at one bit without advancing the location pointer.
oggpack_advAdvances the location pointer by a specified number of bits.
oggpack_adv1Advances the location pointer by one bit.
oggpack_readReads a specified number of bits from the buffer.
oggpack_read1Reads one bit from the buffer.
oggpack_bytesReturns the total number of bytes contained within the buffer.
oggpack_bitsReturns the total number of bits contained within the buffer.
oggpack_get_bufferReturns a pointer to the buffer encapsulated within the oggpack_buffer struct.
- -

-


- - - - - - - - -

copyright © 2000-2021 Xiph.Org Foundation

Ogg Container Format

libogg documentation

libogg release 1.3.5 - 20210603

- - - - diff --git a/Engine/lib/libogg/doc/libogg/datastructures.html b/Engine/lib/libogg/doc/libogg/datastructures.html deleted file mode 100644 index 208ccfc42..000000000 --- a/Engine/lib/libogg/doc/libogg/datastructures.html +++ /dev/null @@ -1,59 +0,0 @@ - - - -libogg - Base Data Structures - - - - - - - - - -

libogg documentation

libogg release 1.3.5 - 20210603

- -

Base Data Structures

-

Libogg uses several data structures to hold data and state information. -

-All the libogg specific data structures are declared in "ogg/ogg.h". -

- - - - - - - - - - - - - - - - - - - - - - -
datatypepurpose
ogg_pageThis structure encapsulates data into one ogg bitstream page.
ogg_stream_stateThis structure contains current encode/decode data for a logical bitstream.
ogg_packetThis structure encapsulates the data and metadata for a single Ogg packet.
ogg_sync_stateContains bitstream synchronization information.
- -

-


- - - - - - - - -

copyright © 2000-2021 Xiph.Org Foundation

Ogg Container Format

libogg documentation

libogg release 1.3.5 - 20210603

- - - - diff --git a/Engine/lib/libogg/doc/libogg/decoding.html b/Engine/lib/libogg/doc/libogg/decoding.html deleted file mode 100644 index 43cdf6fc1..000000000 --- a/Engine/lib/libogg/doc/libogg/decoding.html +++ /dev/null @@ -1,104 +0,0 @@ - - - -libogg - Decoding - - - - - - - - - -

libogg documentation

libogg release 1.3.5 - 20210603

- -

Decoding

-

Libogg contains a set of functions used in the decoding process. -

-All the libogg specific functions are declared in "ogg/ogg.h". -

-

Decoding is based around the ogg synchronization layer. The ogg_sync_state struct coordinates between incoming data and the decoder. We read data into the synchronization layer, submit the data to the stream, and output raw packets to the decoder. -

Decoding through the Ogg layer follows a specific logical sequence. A read loop follows these logical steps: -

-

In practice, streams are more complex, and Ogg also must handle headers, incomplete or dropped pages, and other errors in input. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
functionpurpose
ogg_sync_initInitializes an Ogg bitstream.
ogg_sync_clearClears the status information from the synchronization struct. -
ogg_sync_resetResets the synchronization status to initial values.
ogg_sync_destroyFrees the synchronization struct.
ogg_sync_checkCheck for asynchronous errors.
ogg_sync_bufferExposes a buffer from the synchronization layer in order to read data.
ogg_sync_wroteTells the synchronization layer how many bytes were written into the buffer.
ogg_sync_pageseekFinds the borders of pages and resynchronizes the stream.
ogg_sync_pageoutOutputs a page from the synchronization layer.
ogg_stream_pageinSubmits a complete page to the stream layer.
ogg_stream_packetoutOutputs a packet to the codec-specific decoding engine.
ogg_stream_packetpeekProvides access to the next packet in the bitstream without -advancing decoding.
- -

-


- - - - - - - - -

copyright © 2000-2021 Xiph.Org Foundation

Ogg Container Format

libogg documentation

libogg release 1.3.5 - 20210603

- - - - diff --git a/Engine/lib/libogg/doc/libogg/encoding.html b/Engine/lib/libogg/doc/libogg/encoding.html deleted file mode 100644 index 0bc5a4fb2..000000000 --- a/Engine/lib/libogg/doc/libogg/encoding.html +++ /dev/null @@ -1,76 +0,0 @@ - - - -libogg - Encoding - - - - - - - - - -

libogg documentation

libogg release 1.3.5 - 20210603

- -

Encoding

-

Libogg contains a set of functions used in the encoding process. -

-All the libogg specific functions are declared in "ogg/ogg.h". -

-

When encoding, the encoding engine will output raw packets which must be placed into an Ogg bitstream. -

Raw packets are inserted into the stream, and an ogg_page is output when enough packets have been written to create a full page. The pages output are pointers to buffered packet segments, and can then be written out and saved as an ogg stream. -

There are a couple of basic steps: -

    -
  • Use the encoding engine to produce a raw packet of data. -
  • Call ogg_stream_packetin to submit a raw packet to the stream. -
  • Use ogg_stream_pageout to output a page, if enough data has been submitted. Otherwise, continue submitting data. -
-

- - - - - - - - - - - - - - - - - - - - - - - - - - -
functionpurpose
ogg_stream_packetinSubmits a raw packet to the streaming layer, so that it can be formed into a page.
ogg_stream_ioveciniovec version of ogg_stream_packetin() above.
ogg_stream_pageoutOutputs a completed page if the stream contains enough packets to form a full page. -
ogg_stream_pageout_fillSimilar to ogg_stream_pageout(), but specifies a page spill threshold in bytes. -
ogg_stream_flushForces any remaining packets in the stream to be returned as a page of any size. -
ogg_stream_flush_fillSimilar to ogg_stream_flush(), but specifies a page spill threshold in bytes. -
- -

-
- - - - - - - - -

copyright © 2000-2021 Xiph.Org Foundation

Ogg Container Format

libogg documentation

libogg release 1.3.5 - 20210603

- - - - diff --git a/Engine/lib/libogg/doc/libogg/general.html b/Engine/lib/libogg/doc/libogg/general.html deleted file mode 100644 index 286d29cf3..000000000 --- a/Engine/lib/libogg/doc/libogg/general.html +++ /dev/null @@ -1,109 +0,0 @@ - - - -libogg - General Functions - - - - - - - - - -

libogg documentation

libogg release 1.3.5 - 20210603

- -

General Functions

-

Libogg contains several functions which are generally useful when using Ogg streaming, whether encoding or decoding. -

-All the libogg specific functions are declared in "ogg/ogg.h". -

-

These functions can be used to manipulate some of the basic elements of Ogg - streams and pages. Streams and pages are important during both the encode and decode process. -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
functionpurpose
ogg_stream_initInitializes an Ogg bitstream.
ogg_stream_clearClears the storage within the Ogg stream, but does not free the stream itself. -
ogg_stream_resetResets the stream status to its initial position.
ogg_stream_destroyFrees the entire Ogg stream.
ogg_stream_checkCheck for asynchronous errors.
ogg_stream_eosIndicates whether we are at the end of the stream.
ogg_page_versionReturns the version of ogg_page that this stream/page uses
ogg_page_continuedIndicates if the current page contains a continued packet from the last page.
ogg_page_packetsIndicates the number of packets contained in a page.
ogg_page_bosIndicates if the current page is the beginning of the stream.
ogg_page_eosIndicates if the current page is the end of the stream.
ogg_page_granuleposReturns the precise playback location of this page.
ogg_page_serialnoReturns the unique serial number of the logical bitstream associated with this page.
ogg_page_pagenoReturns the sequential page number for this page.
ogg_packet_clearClears the ogg_packet structure.
ogg_page_checksum_setChecksums an ogg_page.
- -

-


- - - - - - - - -

copyright © 2000-2021 Xiph.Org Foundation

Ogg Container Format

libogg documentation

libogg release 1.3.5 - 20210603

- - - - diff --git a/Engine/lib/libogg/doc/libogg/index.html b/Engine/lib/libogg/doc/libogg/index.html deleted file mode 100644 index ff8fd59c4..000000000 --- a/Engine/lib/libogg/doc/libogg/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - -libogg - Documentation - - - - - - - - - -

libogg documentation

libogg release 1.3.5 - 20210603

- -

Libogg Documentation

- -

-Libogg contains necessary functionality to create, decode, and work with Ogg bitstreams. -

This document explains how to use the libogg API in detail. -

-libogg api overview
-libogg api reference
- -

-


- - - - - - - - -

copyright © 2000-2021 Xiph.Org Foundation

Ogg Container Format

libogg documentation

libogg release 1.3.5 - 20210603

- - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_iovec_t.html b/Engine/lib/libogg/doc/libogg/ogg_iovec_t.html deleted file mode 100644 index 8087440d5..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_iovec_t.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libogg - datatype - ogg_iovec_t - - - - - - - - - -

libogg documentation

libogg release 1.3.5 - 20210603

- -

ogg_iovec_t

- -

declared in "ogg/ogg.h"

- -

-The ogg_iovec_t struct encapsulates a length-encoded buffer. An array -of ogg_iovec_t is used to pass a list of buffers to functions that -accept data in ogg_iovec_t* form. -

- - - - - -
-

-typedef struct {
-  void *iov_base;
-  size_t iov_len;
-} ogg_iovec_t;
-
-
- -

Relevant Struct Members

-
-
iov_base
-
Pointer to the buffer data.
-
iov_len
-
Length of buffer data in bytes.
-
- - -

-
- - - - - - - - -

copyright © 2000-2021 Xiph.Org Foundation

Ogg Container Format

libogg documentation

libogg release 1.3.5 - 20210603

- - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_packet.html b/Engine/lib/libogg/doc/libogg/ogg_packet.html deleted file mode 100644 index 9cb4bab78..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_packet.html +++ /dev/null @@ -1,75 +0,0 @@ - - - -libogg - datatype - ogg_packet - - - - - - - - - -

libogg documentation

libogg release 1.3.5 - 20210603

- -

ogg_packet

- -

declared in "ogg/ogg.h"

- -

-The ogg_packet struct encapsulates the data for a single raw packet of data -and is used to transfer data between the ogg framing layer and the handling codec. -

- - - - - -
-

-typedef struct {
-  unsigned char *packet;
-  long  bytes;
-  long  b_o_s;
-  long  e_o_s;
-
-  ogg_int64_t  granulepos;
-  ogg_int64_t  packetno;
-
-} ogg_packet;
-
-
- -

Relevant Struct Members

-
-
packet
-
Pointer to the packet's data. This is treated as an opaque type by the ogg layer.
-
bytes
-
Indicates the size of the packet data in bytes. Packets can be of arbitrary size.
-
b_o_s
-
Flag indicating whether this packet begins a logical bitstream. 1 indicates this is the first packet, 0 indicates any other position in the stream.
-
e_o_s
-
Flag indicating whether this packet ends a bitstream. 1 indicates the last packet, 0 indicates any other position in the stream.
-
granulepos
-
A number indicating the position of this packet in the decoded data. This is the last sample, frame or other unit of information ('granule') that can be completely decoded from this packet.
-
packetno
-
Sequential number of this packet in the ogg bitstream.
-
- - -

-
- - - - - - - - -

copyright © 2000-2021 Xiph.Org Foundation

Ogg Container Format

libogg documentation

libogg release 1.3.5 - 20210603

- - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_packet_clear.html b/Engine/lib/libogg/doc/libogg/ogg_packet_clear.html deleted file mode 100644 index ba3a455ca..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_packet_clear.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -libogg - function - ogg_packet_clear - - - - - - - - - -

libogg documentation

libogg release 1.3.5 - 20210603

- -

ogg_packet_clear

- -

declared in "ogg/ogg.h";

- -

This function clears the memory used by the ogg_packet struct, -but does not free the structure itself. -It unconditionally frees the packet data buffer, -then it zeros all structure members. -

- - - - -
-

-void ogg_packet_clear(ogg_packet *op);
-
-
- -

Parameters

-
-
op
-
Pointer to the ogg_packet struct to be cleared.
-
- - -

Return Values

-
-
  • -None.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page.html b/Engine/lib/libogg/doc/libogg/ogg_page.html deleted file mode 100644 index 0151a21dc..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page.html +++ /dev/null @@ -1,75 +0,0 @@ - - - -libogg - datatype - ogg_page - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page

    - -

    declared in "ogg/ogg.h"

    - -

    -The ogg_page struct encapsulates the data for an Ogg page. -

    -Ogg pages are the fundamental unit of framing and interleave in an ogg bitstream. -They are made up of packet segments of 255 bytes each. There can be as many as -255 packet segments per page, for a maximum page size of a little under 64 kB. -This is not a practical limitation as the segments can be joined across -page boundaries allowing packets of arbitrary size. In practice many -applications will not completely fill all pages because they flush the -accumulated packets periodically order to bound latency more tightly. -

    -

    For a complete description of ogg pages and headers, please refer to the framing document. - - - - - -
    -
    
    -typedef struct {
    -  unsigned char *header;
    -  long           header_len;
    -  unsigned char *body;
    -  long           body_len;
    -} ogg_page;
    -
    -
    - -

    Relevant Struct Members

    -
    -
    header
    -
    Pointer to the page header for this page. The exact contents of this header are defined in the framing spec document.
    -
    header_len
    -
    Length of the page header in bytes. -
    body
    -
    Pointer to the data for this page.
    -
    body_len
    -
    Length of the body data in bytes.
    -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page_bos.html b/Engine/lib/libogg/doc/libogg/ogg_page_bos.html deleted file mode 100644 index 684b45f65..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page_bos.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -libogg - function - ogg_page_bos - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page_bos

    - -

    declared in "ogg/ogg.h";

    - -

    Indicates whether this page is at the beginning of the logical bitstream. -

    -

    - - - - -
    -
    
    -int ogg_page_bos(ogg_page *og);
    -
    -
    -
    - -

    Parameters

    -
    -
    og
    -
    Pointer to the current ogg_page struct.
    -
    - - -

    Return Values

    -
    -
  • -greater than 0 if this page is the beginning of a bitstream.
  • -
  • -0 if this page is from any other location in the stream.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page_checksum_set.html b/Engine/lib/libogg/doc/libogg/ogg_page_checksum_set.html deleted file mode 100644 index 788a38c14..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page_checksum_set.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libogg - function - ogg_page_checksum_set - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page_checksum_set

    - -

    declared in "ogg/ogg.h";

    - -

    Checksums an ogg_page. -

    -

    - - - - -
    -
    
    -int ogg_page_checksum_set(ogg_page *og);
    -
    -
    -
    - -

    Parameters

    -
    -
    og
    -
    Pointer to an ogg_page struct.
    -
    - - -

    Return Values

    -
    -None. -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page_continued.html b/Engine/lib/libogg/doc/libogg/ogg_page_continued.html deleted file mode 100644 index 6d482d101..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page_continued.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -libogg - function - ogg_page_version - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page_continued

    - -

    declared in "ogg/ogg.h";

    - -

    Indicates whether this page contains packet data which has been continued from the previous page. -

    - - - - -
    -
    
    -int ogg_page_continued(ogg_page *og);
    -
    -
    -
    - -

    Parameters

    -
    -
    og
    -
    Pointer to the current ogg_page struct.
    -
    - - -

    Return Values

    -
    -
  • -1 if this page contains packet data continued from the last page.
  • -
  • -0 if this page does not contain continued data.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page_eos.html b/Engine/lib/libogg/doc/libogg/ogg_page_eos.html deleted file mode 100644 index c1722d124..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page_eos.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -libogg - function - ogg_page_eos - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page_eos

    - -

    declared in "ogg/ogg.h";

    - -

    Indicates whether this page is at the end of the logical bitstream. -

    -

    - - - - -
    -
    
    -int ogg_page_eos(ogg_page *og);
    -
    -
    -
    - -

    Parameters

    -
    -
    og
    -
    Pointer to the current ogg_page struct.
    -
    - - -

    Return Values

    -
    -
  • -greater than zero if this page contains the end of a bitstream.
  • -
  • -0 if this page is from any other location in the stream.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page_granulepos.html b/Engine/lib/libogg/doc/libogg/ogg_page_granulepos.html deleted file mode 100644 index 60c2c91d2..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page_granulepos.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -libogg - function - ogg_page_granulepos - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page_granulepos

    - -

    declared in "ogg/ogg.h";

    - -

    Returns the exact granular position of the packet data contained at the end of this page. -

    This is useful for tracking location when seeking or decoding. -

    For example, in audio codecs this position is the pcm sample number and in video this is the frame number. -

    -

    - - - - -
    -
    
    -ogg_int64_t ogg_page_granulepos(ogg_page *og);
    -
    -
    -
    - -

    Parameters

    -
    -
    og
    -
    Pointer to the current ogg_page struct.
    -
    - - -

    Return Values

    -
    -
  • -n is the specific last granular position of the decoded data contained in the page.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page_packets.html b/Engine/lib/libogg/doc/libogg/ogg_page_packets.html deleted file mode 100644 index 38cfd0586..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page_packets.html +++ /dev/null @@ -1,75 +0,0 @@ - - - -libogg - function - ogg_page_packets - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page_packets

    - -

    declared in "ogg/ogg.h";

    - -

    Returns the number of packets that are completed on this page. If the -leading packet is begun on a previous page, but ends on this page, it's -counted. -

    -

    - - - - -
    -
    
    -int ogg_page_packets(ogg_page *og);
    -
    -
    -
    - -

    Parameters

    -
    -
    og
    -
    Pointer to the current ogg_page struct.
    -
    - - -

    Return Values

    -
    -If a page consists of a packet begun on a previous page, and a new packet -begun (but not completed) on this page, the return will be:
    -
    -ogg_page_packets(page) will return 1,
    -ogg_page_continued(paged) will return non-zero.
    -

    -If a page happens to be a single packet that was begun on a previous page, and -spans to the next page (in the case of a three or more page packet), the -return will be:
    -
    -ogg_page_packets(page) will return 0,
    -ogg_page_continued(page) will return non-zero.
    -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page_pageno.html b/Engine/lib/libogg/doc/libogg/ogg_page_pageno.html deleted file mode 100644 index 9761a5eca..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page_pageno.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -libogg - function - ogg_page_pageno - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page_pageno

    - -

    declared in "ogg/ogg.h";

    - -

    Returns the sequential page number. -

    This is useful for ordering pages or determining when pages have been lost. -

    - - - - -
    -
    
    -long ogg_page_pageno(ogg_page *og);
    -
    -
    -
    - -

    Parameters

    -
    -
    og
    -
    Pointer to the current ogg_page struct.
    -
    - - -

    Return Values

    -
    -
  • -n is the page number for this page.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page_serialno.html b/Engine/lib/libogg/doc/libogg/ogg_page_serialno.html deleted file mode 100644 index 7d288af26..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page_serialno.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -libogg - function - ogg_page_serialno - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page_serialno

    - -

    declared in "ogg/ogg.h";

    - -

    Returns the unique serial number for the logical bitstream of this page. Each page contains the serial number for the logical bitstream that it belongs to. -

    -

    - - - - -
    -
    
    -int ogg_page_serialno(ogg_page *og);
    -
    -
    -
    - -

    Parameters

    -
    -
    og
    -
    Pointer to the current ogg_page struct.
    -
    - - -

    Return Values

    -
    -
  • -n is the serial number for this page.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_page_version.html b/Engine/lib/libogg/doc/libogg/ogg_page_version.html deleted file mode 100644 index 747a696ad..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_page_version.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -libogg - function - ogg_page_version - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_page_version

    - -

    declared in "ogg/ogg.h";

    - -

    This function returns the version of ogg_page used in this page. -

    In current versions of libogg, all ogg_page structs have the same version, so 0 should always be returned. -

    - - - - -
    -
    
    -int ogg_page_version(ogg_page *og);
    -
    -
    -
    - -

    Parameters

    -
    -
    og
    -
    Pointer to the current ogg_page struct.
    -
    - - -

    Return Values

    -
    -
  • -n is the version number. In the current version of Ogg, the version number is always 0. Nonzero return values indicate an error in page encoding.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_check.html b/Engine/lib/libogg/doc/libogg/ogg_stream_check.html deleted file mode 100644 index a84055ea4..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_check.html +++ /dev/null @@ -1,71 +0,0 @@ - - - -libogg - function - ogg_stream_check - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_check

    - -

    declared in "ogg/ogg.h";

    - -

    This function is used to check the error or readiness condition of an ogg_stream_state structure. -

    It is safe practice to ignore unrecoverable errors (such as an internal error caused by a malloc() failure) returned by ogg stream synchronization calls. Should an -internal error occur, the ogg_stream_state structure will be cleared (equivalent to a -call to -ogg_stream_clear) and subsequent calls -using this ogg_stream_state will be -noops. Error detection is then handled via a single call to -ogg_stream_check at the end of the operational block.

    - -

    - - - - -
    -
    
    -int ogg_stream_check(ogg_stream_state *os);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared ogg_stream_state struct.
    -
    - - -

    Return Values

    -
    -
  • -0 is returned if the ogg_stream_state structure is initialized and ready.
  • -
  • -nonzero is returned if the structure was never initialized, or if an unrecoverable internal error occurred in a previous call using the passed in ogg_stream_state struct.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_clear.html b/Engine/lib/libogg/doc/libogg/ogg_stream_clear.html deleted file mode 100644 index d5c5a9bc6..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_clear.html +++ /dev/null @@ -1,61 +0,0 @@ - - - -libogg - function - ogg_stream_clear - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_clear

    - -

    declared in "ogg/ogg.h";

    - -

    This function clears and frees the internal memory used by the ogg_stream_state struct, but does not free the structure itself. It is safe to call ogg_stream_clear on the same structure more than once. -

    - - - - -
    -
    
    -int ogg_stream_clear(ogg_stream_state *os);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to the ogg_stream_state struct to be cleared.
    -
    - - -

    Return Values

    -
    -
  • -0 is always returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_destroy.html b/Engine/lib/libogg/doc/libogg/ogg_stream_destroy.html deleted file mode 100644 index e507f8396..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_destroy.html +++ /dev/null @@ -1,71 +0,0 @@ - - - -libogg - function - ogg_stream_destroy - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_destroy

    - -

    declared in "ogg/ogg.h";

    - -

    This function frees the internal memory used by -the ogg_stream_state struct as -well as the structure itself. - -

    This should be called when you are done working with an ogg stream. -It can also be called to make sure that the struct does not exist.

    - -

    It calls free() on its argument, so if the ogg_stream_state -is not malloc()'d or will otherwise be freed by your own code, use -ogg_stream_clear instead.

    - -

    - - - - -
    -
    
    -int ogg_stream_destroy(ogg_stream_state *os);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to the ogg_stream_state struct to be destroyed.
    -
    - - -

    Return Values

    -
    -
  • -0 is always returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_eos.html b/Engine/lib/libogg/doc/libogg/ogg_stream_eos.html deleted file mode 100644 index 7a08dc34c..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_eos.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libogg - function - ogg_stream_eos - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_eos

    - -

    declared in "ogg/ogg.h";

    - -

    This function indicates whether we have reached the end of the stream or not. -

    - - - - -
    -
    
    -int ogg_stream_eos(ogg_stream_state *os);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to the current ogg_stream_state struct.
    -
    - - -

    Return Values

    -
    -
  • 1 if we are at the end of the stream or an internal error occurred.
  • -
  • -0 if we have not yet reached the end of the stream.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_flush.html b/Engine/lib/libogg/doc/libogg/ogg_stream_flush.html deleted file mode 100644 index 9ce840466..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_flush.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -libogg - function - ogg_stream_flush - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_flush

    - -

    declared in "ogg/ogg.h";

    - -

    This function checks for remaining packets inside the stream and forces remaining packets into a page, regardless of the size of the page. -

    This should only be used when you want to flush an undersized page from the middle of the stream. Otherwise, ogg_stream_pageout or ogg_stream_pageout_fill should always be used. -

    This function can also be used to verify that all packets have been flushed. If the return value is 0, all packets have been placed into a page. Like ogg_stream_pageout, it should generally be called in a loop until available packet data has been flushes, since even a single packet may span multiple pages. - -

    - - - - -
    -
    
    -int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared ogg_stream_state struct, which represents the current logical bitstream.
    -
    og
    -
    Pointer to a page of data. The remaining packets in the stream will be placed into this page, if any remain. -
    - - -

    Return Values

    -
    -
  • 0 means that all packet data has already been flushed into pages, and there are no packets to put into the page. 0 is also returned in the case of an ogg_stream_state that has been cleared explicitly or implicitly due to an internal error.
  • -
  • -Nonzero means that remaining packets have successfully been flushed into the page.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_flush_fill.html b/Engine/lib/libogg/doc/libogg/ogg_stream_flush_fill.html deleted file mode 100644 index 68988e881..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_flush_fill.html +++ /dev/null @@ -1,74 +0,0 @@ - - - -libogg - function - ogg_stream_flush_fill - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_flush_fill

    - -

    declared in "ogg/ogg.h";

    - -

    This function flushes available packets into pages, similar to -ogg_stream_flush(), but -allows applications to explicitly request a specific page spill -size.

    - -

    This function checks for remaining packets inside the stream and forces remaining packets into pages of approximately the requested size. -This should be used when you want to flush all remaining data from a stream. ogg_stream_flush may be used instead if a particular page size isn't important. -

    This function can be used to verify that all packets have been flushed. If the return value is 0, all packets have been placed into a page. Generally speaking, it should be called in a loop until all packets are flushed, since even a single packet may span multiple pages. - -

    - - - - -
    -
    
    -int ogg_stream_flush_fill(ogg_stream_state *os, ogg_page *og, int fillbytes);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared ogg_stream_state struct, which represents the current logical bitstream.
    -
    og
    -
    Pointer to a page of data. The remaining packets in the stream will be placed into this page, if any remain. -
    fillbytes
    -
    Packet data watermark in bytes.
    -
    - - -

    Return Values

    -
    -
  • 0 means that all packet data has already been flushed into pages, and there are no packets to put into the page. 0 is also returned in the case of an ogg_stream_state that has been cleared explicitly or implicitly due to an internal error.
  • -
  • -Nonzero means that remaining packets have successfully been flushed into the page.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_init.html b/Engine/lib/libogg/doc/libogg/ogg_stream_init.html deleted file mode 100644 index cdd3ecb48..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_init.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -libogg - function - ogg_stream_init - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_init

    - -

    declared in "ogg/ogg.h";

    - -

    This function is used to initialize an ogg_stream_state struct and allocates appropriate memory in preparation for encoding or decoding. -

    It also assigns the stream a given serial number. -

    - - - - -
    -
    
    -int ogg_stream_init(ogg_stream_state *os,int serialno);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to the ogg_stream_state struct that we will be initializing.
    -
    serialno
    -
    Serial number that we will attach to this stream.
    -
    - - -

    Return Values

    -
    -
  • -0 if successful
  • -
  • --1 if unsuccessful.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_iovecin.html b/Engine/lib/libogg/doc/libogg/ogg_stream_iovecin.html deleted file mode 100644 index 92499a110..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_iovecin.html +++ /dev/null @@ -1,80 +0,0 @@ - - - -libogg - function - ogg_stream_iovecin - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_iovecin

    - -

    declared in "ogg/ogg.h";

    - -

    This function submits packet data (in the form of -an array of ogg_iovec_t, rather than using -an ogg_packet structure) to the -bitstream for page encapsulation. After this is called, more packets -can be submitted, or pages can be written out.

    - -

    In a typical encoding situation, this should be used after filling a -packet with data. -The data in the packet is copied into the internal storage managed by -the ogg_stream_state, so the caller -is free to alter the contents of os after this call has returned. - -

    - - - - -
    -
    
    -int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, int count, long e_o_s, ogg_int64_t granulepos);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared ogg_stream_state struct.
    -
    iov
    -
    Length-encoded buffers held in an array of ogg_iovec_t. -
    count
    -
    Length of the iov array. -
    e_o_s
    -
    End of stream flag, analogous to the e_o_s field in an ogg_packet. -
    granulepos
    -
    Granule position value, analogous to the granpos field in an ogg_packet. -
    - - -

    Return Values

    -
    -
  • -0 returned on success. -1 returned in the event of internal error.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_packetin.html b/Engine/lib/libogg/doc/libogg/ogg_stream_packetin.html deleted file mode 100644 index b36f11553..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_packetin.html +++ /dev/null @@ -1,72 +0,0 @@ - - - -libogg - function - ogg_stream_packetin - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_packetin

    - -

    declared in "ogg/ogg.h";

    - -

    This function submits a packet to the bitstream for page -encapsulation. After this is called, more packets can be submitted, -or pages can be written out.

    - -

    In a typical encoding situation, this should be used after filling a -packet with data. -The data in the packet is copied into the internal storage managed by -the ogg_stream_state, so the caller -is free to alter the contents of op after this call has returned. - -

    - - - - -
    -
    
    -int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared ogg_stream_state struct.
    -
    op
    -
    Pointer to the packet we are putting into the bitstream. -
    - - -

    Return Values

    -
    -
  • -0 returned on success. -1 returned in the event of internal error.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_packetout.html b/Engine/lib/libogg/doc/libogg/ogg_stream_packetout.html deleted file mode 100644 index 6e12dc9fb..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_packetout.html +++ /dev/null @@ -1,85 +0,0 @@ - - - -libogg - function - ogg_stream_packetout - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_packetout

    - -

    declared in "ogg/ogg.h";

    - -

    This function assembles a data packet for output to the codec -decoding engine. The data has already been submitted to the -ogg_stream_state and broken -into segments. Each successive call returns the next complete packet -built from those segments.

    - -

    In a typical decoding situation, this should be used after calling -ogg_stream_pagein() to submit a -page of data to the bitstream. If the function returns 0, more data is -needed and another page should be submitted. A non-zero return value -indicates successful return of a packet.

    - -

    The op is filled in with pointers to memory managed by -the stream state and is only valid until the next call. The client -must copy the packet data if a longer lifetime is required.

    - -

    - - - - -
    -
    
    -int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared ogg_stream_state struct. Before this function is called, an ogg_page should be submitted to the stream using ogg_stream_pagein().
    -
    op
    -
    Pointer to the packet to be filled in with pointers to the new data. -This will typically be submitted to a codec for decode after this -function is called. The pointers are only valid until the next call -on this stream state.
    -
    - - -

    Return Values

    -
    -
      -
    • -1 if we are out of sync and there is a gap in the data. This is usually a recoverable error and subsequent calls to ogg_stream_packetout are likely to succeed. op has not been updated.
    • -
    • 0 if there is insufficient data available to complete a packet, or on unrecoverable internal error occurred. op has not been updated. -
    • 1 if a packet was assembled normally. op contains the next packet from the stream.
    • -
    -
    - -

    - -
    - - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_packetpeek.html b/Engine/lib/libogg/doc/libogg/ogg_stream_packetpeek.html deleted file mode 100644 index 2f90e32dc..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_packetpeek.html +++ /dev/null @@ -1,85 +0,0 @@ - - - -libogg - function - ogg_stream_packetpeek - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_packetpeek

    - -

    declared in "ogg/ogg.h";

    - -

    This function attempts to assemble a raw data packet and returns -it without advancing decoding.

    - -

    In a typical situation, this would be called -speculatively after ogg_stream_pagein() to check -the packet contents before handing it off to a codec for -decompression. To advance page decoding and remove -the packet from the sync structure, call -ogg_stream_packetout().

    - -

    - - - - - -
    -
    
    -int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared -ogg_stream_state struct. Before this -function is called, an ogg_page should be -submitted to the stream using -ogg_stream_pagein().
    -
    op
    -
    Pointer to the next packet available in the bitstream, if -any. A NULL value may be passed in the case of a simple "is there a -packet?" check.
    -
    - - -

    Return Values

    -
    -
      -
    • -1 if there's no packet available due to lost sync or a hole in the data.
    • -
    • 0 if there is insufficient data available to complete a packet, or on unrecoverable internal error occurred.
    • -
    • 1 if a packet is available.
    • -
    -
    - - -

    - -
    - - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_pagein.html b/Engine/lib/libogg/doc/libogg/ogg_stream_pagein.html deleted file mode 100644 index db52b9197..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_pagein.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -libogg - function - ogg_stream_pagein - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_pagein

    - -

    declared in "ogg/ogg.h";

    - -

    This function adds a complete page to the bitstream. -

    In a typical decoding situation, this function would be called after using ogg_sync_pageout to create a valid ogg_page struct. -

    Internally, this function breaks the page into packet segments in preparation for outputting a valid packet to the codec decoding layer. - -

    - - - - -
    -
    
    -int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared ogg_stream_state struct, which represents the current logical bitstream.
    -
    og
    -
    Pointer to a page of data. The data inside this page is being submitted to the streaming layer in order to be allocated into packets. -
    - - -

    Return Values

    -
    -
  • -1 indicates failure. This means that the serial number of the page did not match the serial number of the bitstream, the page version was incorrect, or an internal error occurred.
  • -
  • -0 means that the page was successfully submitted to the bitstream.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_pageout.html b/Engine/lib/libogg/doc/libogg/ogg_stream_pageout.html deleted file mode 100644 index 991536848..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_pageout.html +++ /dev/null @@ -1,84 +0,0 @@ - - - -libogg - function - ogg_stream_pageout - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_pageout

    - -

    declared in "ogg/ogg.h";

    - -

    This function forms packets into pages.

    - -

    In a typical encoding situation, this would be called after using ogg_stream_packetin() to submit -data packets to the bitstream. Internally, this function assembles -the accumulated packet bodies into an Ogg page suitable for writing -to a stream. The function is typically called in a loop until there -are no more pages ready for output.

    - -

    This function will only return a page when a "reasonable" amount of -packet data is available. Normally this is appropriate since it -limits the overhead of the Ogg page headers in the bitstream, and so -calling ogg_stream_pageout() after ogg_stream_packetin() should be the -common case. Call ogg_stream_flush() -if immediate page generation is desired. This may be occasionally -necessary, for example, to limit the temporal latency of a variable -bitrate stream.

    - -

    - - - - -
    -
    
    -int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared ogg_stream struct, which represents the current logical bitstream.
    -
    og
    -
    Pointer to an ogg_page structure to fill -in. Data pointed to is owned by libogg. The structure is valid until the -next call to ogg_stream_pageout(), ogg_stream_packetin(), or -ogg_stream_flush().
    -
    - - -

    Return Values

    -
    -
  • Zero means that insufficient data has accumulated to fill a page, or an internal error occurred. In -this case og is not modified.
  • -
  • Non-zero means that a page has been completed and returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_pageout_fill.html b/Engine/lib/libogg/doc/libogg/ogg_stream_pageout_fill.html deleted file mode 100644 index 22edfa8b2..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_pageout_fill.html +++ /dev/null @@ -1,89 +0,0 @@ - - - -libogg - function - ogg_stream_pageout_fill - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_pageout_fill

    - -

    declared in "ogg/ogg.h";

    - -

    This function forms packets into pages, similar -to ogg_stream_pageout(), but -allows applications to explicitly request a specific page spill -size.

    - -

    In a typical encoding situation, this would be called after using ogg_stream_packetin() to submit -data packets to the bitstream. Internally, this function assembles -the accumulated packet bodies into an Ogg page suitable for writing -to a stream. The function is typically called in a loop until there -are no more pages ready for output.

    - -

    This function will return a page when at least four packets have -been accumulated and accumulated packet data meets or exceeds the -specified number of bytes, and/or when the accumulated packet -data meets/exceeds the maximum page size regardless of accumulated -packet count. -Call ogg_stream_flush() or -ogg_stream_flush_fill() if -immediate page generation is desired regardless of accumulated data.

    - -

    - - - - -
    -
    
    -int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int fillbytes);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to a previously declared ogg_stream struct, which represents the current logical bitstream.
    -
    og
    -
    Pointer to an ogg_page structure to fill -in. Data pointed to is owned by libogg. The structure is valid until the -next call to ogg_stream_pageout(), ogg_stream_packetin(), or -ogg_stream_flush().
    -
    fillbytes
    -
    Packet data watermark in bytes.
    -
    - - -

    Return Values

    -
    -
  • Zero means that insufficient data has accumulated to fill a page, or an internal error occurred. In -this case og is not modified.
  • -
  • Non-zero means that a page has been completed and returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_reset.html b/Engine/lib/libogg/doc/libogg/ogg_stream_reset.html deleted file mode 100644 index 068541a80..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_reset.html +++ /dev/null @@ -1,61 +0,0 @@ - - - -libogg - function - ogg_stream_reset - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_reset

    - -

    declared in "ogg/ogg.h";

    - -

    This function sets values in the ogg_stream_state struct back to initial values. -

    - - - - -
    -
    
    -int ogg_stream_reset(ogg_stream_state *os);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to the ogg_stream_state struct to be reset.
    -
    - - -

    Return Values

    -
    -
  • -0 indicates success. nonzero is returned on internal error.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_reset_serialno.html b/Engine/lib/libogg/doc/libogg/ogg_stream_reset_serialno.html deleted file mode 100644 index a80c5908f..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_reset_serialno.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -libogg - function - ogg_stream_reset_serialno - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_reset

    - -

    declared in "ogg/ogg.h";

    - -

    This function reinitializes the values in the -ogg_stream_state, -just like ogg_stream_reset(). -Additionally, it sets the stream serial number to the given value.

    - -

    - - - - -
    -
    
    -int ogg_stream_reset_serialno(ogg_stream_state *os, int serialno);
    -
    -
    - -

    Parameters

    -
    -
    os
    -
    Pointer to the ogg_stream_state struct to be reset.
    -
    serialno
    -
    New stream serial number to use
    -
    - - -

    Return Values

    -
    -
  • -0 indicates success. nonzero is returned on internal error.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_stream_state.html b/Engine/lib/libogg/doc/libogg/ogg_stream_state.html deleted file mode 100644 index f6fa437a6..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_stream_state.html +++ /dev/null @@ -1,122 +0,0 @@ - - - -libogg - datatype - ogg_stream_state - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_stream_state

    - -

    declared in "ogg/ogg.h"

    - -

    -The ogg_stream_state struct tracks the current encode/decode state -of the current logical bitstream. -

    - - - - - -
    -
    
    -typedef struct {
    -  unsigned char   *body_data;    /* bytes from packet bodies */
    -  long    body_storage;          /* storage elements allocated */
    -  long    body_fill;             /* elements stored; fill mark */
    -  long    body_returned;         /* elements of fill returned */
    -
    -
    -  int     *lacing_vals;      /* The values that will go to the segment table */
    -  ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
    -                                this way, but it is simple coupled to the
    -                                lacing fifo */
    -  long    lacing_storage;
    -  long    lacing_fill;
    -  long    lacing_packet;
    -  long    lacing_returned;
    -
    -  unsigned char    header[282];      /* working space for header encode */
    -  int              header_fill;
    -
    -  int     e_o_s;          /* set when we have buffered the last packet in the
    -                             logical bitstream */
    -  int     b_o_s;          /* set after we've written the initial page
    -                             of a logical bitstream */
    -  long    serialno;
    -  long    pageno;
    -  ogg_int64_t  packetno;  /* sequence number for decode; the framing
    -                             knows where there's a hole in the data,
    -                             but we need coupling so that the codec
    -                             (which is in a separate abstraction
    -                             layer) also knows about the gap */
    -  ogg_int64_t   granulepos;
    -
    -} ogg_stream_state;
    -
    -
    - -

    Relevant Struct Members

    -
    -
    body_data
    -
    Pointer to data from packet bodies.
    -
    body_storage
    -
    Storage allocated for bodies in bytes (filled or unfilled).
    -
    body_fill
    -
    Amount of storage filled with stored packet bodies.
    -
    body_returned
    -
    Number of elements returned from storage.
    -
    lacing_vals
    -
    String of lacing values for the packet segments within the current page. Each value is a byte, indicating packet segment length.
    -
    granule_vals
    -
    Pointer to the lacing values for the packet segments within the current page.
    -
    lacing_storage
    -
    Total amount of storage (in bytes) allocated for storing lacing values.
    -
    lacing_fill
    -
    Fill marker for the current vs. total allocated storage of lacing values for the page.
    -
    lacing_packet
    -
    Lacing value for current packet segment.
    -
    lacing_returned
    -
    Number of lacing values returned from lacing_storage.
    -
    header
    -
    Temporary storage for page header during encode process, while the header is being created.
    -
    header_fill
    -
    Fill marker for header storage allocation. Used during the header creation process.
    -
    e_o_s
    -
    Marker set when the last packet of the logical bitstream has been buffered.
    -
    b_o_s
    -
    Marker set after we have written the first page in the logical bitstream.
    -
    serialno
    -
    Serial number of this logical bitstream.
    -
    pageno
    -
    Number of the current page within the stream.
    -
    packetno
    -
    Number of the current packet.
    -
    granulepos
    -
    Exact position of decoding/encoding process.
    -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_buffer.html b/Engine/lib/libogg/doc/libogg/ogg_sync_buffer.html deleted file mode 100644 index 45d9aff97..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_buffer.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -libogg - function - ogg_sync_buffer - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_buffer

    - -

    declared in "ogg/ogg.h";

    - -

    This function is used to provide a properly-sized buffer for writing. -

    Buffer space which has already been returned is cleared, and the buffer is extended as necessary by the size plus some additional bytes. Within the current implementation, an extra 4096 bytes are allocated, but applications should not rely on this additional buffer space. -

    The buffer exposed by this function is empty internal storage from the ogg_sync_state struct, beginning at the fill mark within the struct. -

    A pointer to this buffer is returned to be used by the calling application. - -

    - - - - -
    -
    
    -char *ogg_sync_buffer(ogg_sync_state *oy, long size);
    -
    -
    - -

    Parameters

    -
    -
    oy
    -
    Pointer to a previously declared ogg_sync_state struct.
    -
    size
    -
    Size of the desired buffer. The actual size of the buffer returned will be this size plus some extra bytes (currently 4096). -
    - - -

    Return Values

    -
    -
  • -Returns a pointer to the newly allocated buffer or NULL on error
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_check.html b/Engine/lib/libogg/doc/libogg/ogg_sync_check.html deleted file mode 100644 index f96187a62..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_check.html +++ /dev/null @@ -1,71 +0,0 @@ - - - -libogg - function - ogg_sync_check - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_check

    - -

    declared in "ogg/ogg.h";

    - -

    This function is used to check the error or readiness condition of an ogg_sync_state structure. -

    It is safe practice to ignore unrecoverable errors (such as an internal error caused by a malloc() failure) returned by ogg stream synchronization calls. Should an -internal error occur, the ogg_sync_state structure will be cleared (equivalent to a -call to -ogg_sync_clear) and subsequent calls -using this ogg_sync_state will be -noops. Error detection is then handled via a single call to -ogg_sync_check at the end of the operational block.

    - -

    - - - - -
    -
    
    -int ogg_sync_check(ogg_sync_state *oy);
    -
    -
    - -

    Parameters

    -
    -
    oy
    -
    Pointer to a previously declared ogg_sync_state struct.
    -
    - - -

    Return Values

    -
    -
  • -0 is returned if the ogg_sync_state structure is initialized and ready.
  • -
  • -nonzero is returned if the structure was never initialized, or if an unrecoverable internal error occurred in a previous call using the passed in ogg_sync_state struct.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_clear.html b/Engine/lib/libogg/doc/libogg/ogg_sync_clear.html deleted file mode 100644 index f8df0af48..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_clear.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libogg - function - ogg_sync_clear - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_clear

    - -

    declared in "ogg/ogg.h";

    - -

    This function is used to free the internal storage of an ogg_sync_state struct and resets the struct to the initial state. To free the entire struct, ogg_sync_destroy should be used instead. In situations where the struct needs to be reset but the internal storage does not need to be freed, ogg_sync_reset should be used. - -

    - - - - -
    -
    
    -int ogg_sync_clear(ogg_sync_state *oy);
    -
    -
    - -

    Parameters

    -
    -
    oy
    -
    Pointer to a previously declared ogg_sync_state struct.
    -
    - - -

    Return Values

    -
    -
  • -0 is always returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_destroy.html b/Engine/lib/libogg/doc/libogg/ogg_sync_destroy.html deleted file mode 100644 index efebf3df8..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_destroy.html +++ /dev/null @@ -1,68 +0,0 @@ - - - -libogg - function - ogg_sync_destroy - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_destroy

    - -

    declared in "ogg/ogg.h";

    - -

    This function is used to destroy an ogg_sync_state struct and free all memory used.

    - -

    Note this calls free() on its argument so you should only use this -function if you've allocated the ogg_sync_state on the heap. If it is -allocated on the stack, or it will otherwise be freed by your -own code, use ogg_sync_clear instead -to release just the internal memory.

    - -

    - - - - -
    -
    
    -int ogg_sync_destroy(ogg_sync_state *oy);
    -
    -
    - -

    Parameters

    -
    -
    oy
    -
    Pointer to a previously declared ogg_sync_state struct.
    -
    - - -

    Return Values

    -
    -
  • -0 is always returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_init.html b/Engine/lib/libogg/doc/libogg/ogg_sync_init.html deleted file mode 100644 index 50c09715e..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_init.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -libogg - function - ogg_sync_init - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_init

    - -

    declared in "ogg/ogg.h";

    - -

    This function is used to initialize an ogg_sync_state struct to a known initial value in preparation for manipulation of an Ogg bitstream. -

    The ogg_sync struct is important when decoding, as it synchronizes retrieval and return of data. - -

    - - - - -
    -
    
    -int ogg_sync_init(ogg_sync_state *oy);
    -
    -
    - -

    Parameters

    -
    -
    oy
    -
    Pointer to a previously declared ogg_sync_state struct. After this function call, this struct has been initialized.
    -
    - - -

    Return Values

    -
    -
  • -0 is always returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_pageout.html b/Engine/lib/libogg/doc/libogg/ogg_sync_pageout.html deleted file mode 100644 index 4430692c3..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_pageout.html +++ /dev/null @@ -1,77 +0,0 @@ - - - -libogg - function - ogg_sync_pageout - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_pageout

    - -

    declared in "ogg/ogg.h";

    - -

    This function takes the data stored in the buffer of the ogg_sync_state struct and inserts them into an ogg_page. - -

    In an actual decoding loop, this function should be called first to ensure that the buffer is cleared. The example code below illustrates a clean reading loop which will fill and output pages. -

    Caution:This function should be called before reading into the buffer to ensure that data does not remain in the ogg_sync_state struct. Failing to do so may result in a memory leak. See the example code below for details. - -

    - - - - -
    -
    
    -int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
    -
    -
    - -

    Parameters

    -
    -
    oy
    -
    Pointer to a previously declared ogg_sync_state struct. Normally, the internal storage of this struct should be filled with newly read data and verified using ogg_sync_wrote.
    -
    og
    -
    Pointer to page struct filled by this function. -
    - - -

    Return Values

    -
    -
  • -1 returned if stream has not yet captured sync (bytes were skipped).
  • -
  • 0 returned if more data needed or an internal error occurred.
  • -
  • 1 indicated a page was synced and returned.
  • -
    -

    - -

    Example Usage

    -
    -if (ogg_sync_pageout(&oy, &og) != 1) {
    -	buffer = ogg_sync_buffer(&oy, 8192);
    -	bytes = fread(buffer, 1, 8192, stdin);
    -	ogg_sync_wrote(&oy, bytes);
    -}
    -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_pageseek.html b/Engine/lib/libogg/doc/libogg/ogg_sync_pageseek.html deleted file mode 100644 index d76a7847f..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_pageseek.html +++ /dev/null @@ -1,68 +0,0 @@ - - - -libogg - function - ogg_sync_pageseek - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_pageseek

    - -

    declared in "ogg/ogg.h";

    - -

    This function synchronizes the ogg_sync_state struct to the next ogg_page. -

    This is useful when seeking within a bitstream. ogg_sync_pageseek will synchronize to the next page in the bitstream and return information about how many bytes we advanced or skipped in order to do so. - -

    - - - - -
    -
    
    -int ogg_sync_pageseek(ogg_sync_state *oy, ogg_page *og);
    -
    -
    - -

    Parameters

    -
    -
    oy
    -
    Pointer to a previously declared ogg_sync_state struct.
    -
    og
    -
    Pointer to a page (or an incomplete page) of data. This is the page we are attempting to sync. -
    - - -

    Return Values

    -
    -
  • -n means that we skipped n bytes within the bitstream.
  • -
  • -0 means that the page isn't ready and we need more data, or than an internal error occurred. No bytes have been skipped.
  • -
  • -n means that the page was synced at the current location, with a page length of n bytes. -
  • -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_reset.html b/Engine/lib/libogg/doc/libogg/ogg_sync_reset.html deleted file mode 100644 index 32df6da0e..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_reset.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -libogg - function - ogg_sync_reset - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_reset

    - -

    declared in "ogg/ogg.h";

    - -

    This function is used to reset the internal counters of the ogg_sync_state struct to initial values. -

    It is a good idea to call this before seeking within a bitstream. - -

    - - - - -
    -
    
    -int ogg_sync_reset(ogg_sync_state *oy);
    -
    -
    - -

    Parameters

    -
    -
    oy
    -
    Pointer to a previously declared ogg_sync_state struct.
    -
    - - -

    Return Values

    -
    -
  • -0 is always returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_state.html b/Engine/lib/libogg/doc/libogg/ogg_sync_state.html deleted file mode 100644 index 78d6f2029..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_state.html +++ /dev/null @@ -1,77 +0,0 @@ - - - -libogg - datatype - ogg_sync_state - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_state

    - -

    declared in "ogg/ogg.h"

    - -

    -The ogg_sync_state struct tracks the synchronization of the current page. -

    It is used during decoding to track the status of data as it is read in, synchronized, verified, and parsed into pages belonging to the various logical bistreams in the current physical bitstream link. -

    - - - - - -
    -
    
    -typedef struct {
    -  unsigned char *data;
    -  int storage;
    -  int fill;
    -  int returned;
    -
    -  int unsynced;
    -  int headerbytes;
    -  int bodybytes;
    -} ogg_sync_state;
    -
    -
    - -

    Relevant Struct Members

    -
    -
    data
    -
    Pointer to buffered stream data.
    -
    storage
    -
    Current allocated size of the stream buffer held in *data.
    -
    fill
    -
    The number of valid bytes currently held in *data; functions as the buffer head pointer.
    -
    returned
    -
    The number of bytes at the head of *data that have already been returned as pages; functions as the buffer tail pointer.
    -
    unsynced
    -
    Synchronization state flag; nonzero if sync has not yet been attained or has been lost.
    -
    headerbytes
    -
    If synced, the number of bytes used by the synced page's header.
    -
    bodybytes
    -
    If synced, the number of bytes used by the synced page's body.
    -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - diff --git a/Engine/lib/libogg/doc/libogg/ogg_sync_wrote.html b/Engine/lib/libogg/doc/libogg/ogg_sync_wrote.html deleted file mode 100644 index 638913b3e..000000000 --- a/Engine/lib/libogg/doc/libogg/ogg_sync_wrote.html +++ /dev/null @@ -1,73 +0,0 @@ - - - -libogg - function - ogg_sync_wrote - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    ogg_sync_wrote

    - -

    declared in "ogg/ogg.h";

    - -

    This function is used to tell the ogg_sync_state struct how many bytes we wrote into the buffer. - -

    -The general procedure is to request a pointer into an internal -ogg_sync_state buffer by calling -ogg_sync_buffer(). The buffer -is then filled up to the requested size with new input, and -ogg_sync_wrote() is called to advance the fill pointer by however -much data was actually available.

    - -
    - - - - -
    -
    
    -int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
    -
    -
    - -

    Parameters

    -
    -
    oy
    -
    Pointer to a previously declared ogg_sync_state struct.
    -
    bytes
    -
    Number of bytes of new data written.
    -
    - - -

    Return Values

    -
    -
  • -1 if the number of bytes written overflows the internal storage of the ogg_sync_state struct or an internal error occurred. -
  • -0 in all other cases.
  • -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_adv.html b/Engine/lib/libogg/doc/libogg/oggpack_adv.html deleted file mode 100644 index d44715601..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_adv.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -libogg - function - oggpack_adv - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_adv

    - -

    declared in "ogg/ogg.h";

    - -

    This function advances the location pointer by the specified number of bits without reading any data. - -

    - - - - -
    -
    
    -void  oggpack_adv(oggpack_buffer *b,int bits);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Pointer to the current oggpack_buffer.
    -
    bits
    -
    Number of bits to advance.
    -
    - - -

    Return Values

    -
    -
  • -No values are returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_adv1.html b/Engine/lib/libogg/doc/libogg/oggpack_adv1.html deleted file mode 100644 index a76ba58f4..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_adv1.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libogg - function - oggpack_adv1 - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_adv1

    - -

    declared in "ogg/ogg.h";

    - -

    This function advances the location pointer by one bit without reading any data. - -

    - - - - -
    -
    
    -void  oggpack_adv1(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Pointer to the current oggpack_buffer.
    -
    - - -

    Return Values

    -
    -
  • No values are returned. -
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_bits.html b/Engine/lib/libogg/doc/libogg/oggpack_bits.html deleted file mode 100644 index eccd9aef4..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_bits.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libogg - function - oggpack_bits - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_bits

    - -

    declared in "ogg/ogg.h";

    - -

    This function returns the total number of bits currently in the oggpack_buffer's internal buffer. - -

    - - - - -
    -
    
    -long oggpack_bits(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    oggpack_buffer struct to be .
    -
    - - -

    Return Values

    -
    -
  • -n is the total number of bits within the current buffer.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_buffer.html b/Engine/lib/libogg/doc/libogg/oggpack_buffer.html deleted file mode 100644 index 5562c923a..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_buffer.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -libogg - datatype - oggpack_buffer - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_buffer

    - -

    declared in "ogg/ogg.h"

    - -

    -The oggpack_buffer struct is used with libogg's bitpacking functions. You should never need to directly access anything in this structure. -

    - - - - - -
    -
    
    -typedef struct {
    -  long endbyte;
    -  int  endbit;
    -
    -  unsigned char *buffer;
    -  unsigned char *ptr;
    -  long storage;
    -} oggpack_buffer;
    -
    -
    - -

    Relevant Struct Members

    -
    -
    buffer
    -
    Pointer to data being manipulated.
    -
    ptr
    -
    Location pointer to mark which data has been read.
    -
    storage
    -
    Size of buffer. -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_bytes.html b/Engine/lib/libogg/doc/libogg/oggpack_bytes.html deleted file mode 100644 index 4503e36f3..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_bytes.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -libogg - function - oggpack_bytes - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_bytes

    - -

    declared in "ogg/ogg.h";

    - -

    This function returns the total number of bytes behind the current -access point in the oggpack_buffer. -For write-initialized buffers, this is the number of complete bytes -written so far. For read-initialized buffers, it is the number of -complete bytes that have been read so far. -

    The return value is the number of complete bytes in the buffer. -There may be extra (<8) bits. -

    - - - - -
    -
    
    -long oggpack_bytes(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    oggpack_buffer struct to be checked.
    -
    - - -

    Return Values

    -
    -
  • -n is the total number of bytes within the current buffer.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_get_buffer.html b/Engine/lib/libogg/doc/libogg/oggpack_get_buffer.html deleted file mode 100644 index 538bc9664..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_get_buffer.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libogg - function - oggpack_get_buffer - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_get_buffer

    - -

    declared in "ogg/ogg.h";

    - -

    This function returns a pointer to the data buffer within the given oggpack_buffer struct. - -

    - - - - -
    -
    
    -unsigned char *oggpack_get_buffer(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Pointer to the current oggpack_buffer.
    -
    - - -

    Return Values

    -
    -
  • -No values are returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_look.html b/Engine/lib/libogg/doc/libogg/oggpack_look.html deleted file mode 100644 index c5c2da8cf..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_look.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -libogg - function - oggpack_look - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_look

    - -

    declared in "ogg/ogg.h";

    - -

    This function looks at a specified number of bits inside the buffer without advancing the location pointer. -

    The specified number of bits are read, starting from the location pointer. -

    This function can be used to read 32 or fewer bits. - -

    - - - - -
    -
    
    -long  oggpack_look(oggpack_buffer *b,int bits);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Pointer to oggpack_buffer to be read.
    -
    bits
    -
    Number of bits to look at. For this function, must be 32 or fewer.
    -
    - - -

    Return Values

    -
    -
  • -n represents the requested bits.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_look1.html b/Engine/lib/libogg/doc/libogg/oggpack_look1.html deleted file mode 100644 index c0c771d40..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_look1.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -libogg - function - oggpack_look1 - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_look1

    - -

    declared in "ogg/ogg.h";

    - -

    This function looks at the next bit without advancing the location pointer. -

    The next bit is read starting from the location pointer. - -

    - - - - -
    -
    
    -long  oggpack_look1(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Pointer to an oggpack_buffer struct containing our buffer.
    -
    - - -

    Return Values

    -
    -
  • -n represents the value of the next bit after the location pointer.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_read.html b/Engine/lib/libogg/doc/libogg/oggpack_read.html deleted file mode 100644 index 670cc9dc6..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_read.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -libogg - function - oggpack_read - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_read

    - -

    declared in "ogg/ogg.h";

    - -

    This function reads the requested number of bits from the buffer and advances the location pointer. -

    Before reading, the buffer should be initialized using oggpack_readinit. - -

    - - - - -
    -
    
    -long oggpack_read(oggpack_buffer *b,int bits);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Pointer to an oggpack_buffer struct containing buffered data to be read.
    -
    bits
    -
    Number of bits to read.
    -
    - - -

    Return Values

    -
    -
  • -n represents the requested bits.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_read1.html b/Engine/lib/libogg/doc/libogg/oggpack_read1.html deleted file mode 100644 index a0e73db8b..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_read1.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -libogg - function - oggpack_read1 - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_read1

    - -

    declared in "ogg/ogg.h";

    - -

    This function reads one bit from the oggpack_buffer data buffer and advances the location pointer. -

    Before reading, the buffer should be initialized using oggpack_readinit. - -

    - - - - -
    -
    
    -long  oggpack_read1(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Pointer to an oggpack_buffer struct containing buffered data to be read.
    -
    - - -

    Return Values

    -
    -
  • -n is the bit read by this function.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_readinit.html b/Engine/lib/libogg/doc/libogg/oggpack_readinit.html deleted file mode 100644 index cba730df3..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_readinit.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -libogg - function - oggpack_readinit - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_readinit

    - -

    declared in "ogg/ogg.h";

    - -

    This function takes an ordinary buffer and prepares an oggpack_buffer for reading using the Ogg bitpacking functions. - -

    - - - - -
    -
    
    -void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Pointer to oggpack_buffer to be initialized with some extra markers to ease bit navigation and manipulation.
    -
    buf
    -
    Original data buffer, to be inserted into the oggpack_buffer so that it can be read using bitpacking functions. -
    - - -

    Return Values

    -
    -
  • -No values are returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_reset.html b/Engine/lib/libogg/doc/libogg/oggpack_reset.html deleted file mode 100644 index 9dae86cbc..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_reset.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libogg - function - oggpack_reset - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_reset

    - -

    declared in "ogg/ogg.h";

    - -

    This function resets the contents of an oggpack_buffer to their original state but does not free the memory used. - -

    - - - - -
    -
    
    -void  oggpack_reset(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    oggpack_buffer to be reset.
    -
    - - -

    Return Values

    -
    -
  • -No values are returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_write.html b/Engine/lib/libogg/doc/libogg/oggpack_write.html deleted file mode 100644 index 25d058ba9..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_write.html +++ /dev/null @@ -1,68 +0,0 @@ - - - -libogg - function - oggpack_write - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_write

    - -

    declared in "ogg/ogg.h";

    - -

    This function writes bits into an oggpack_buffer. -

    The oggpack_buffer must already be initialized for writing using oggpack_writeinit. -

    Only 32 bits can be written at a time. - -

    - - - - -
    -
    
    -void  oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Buffer to be used for writing.
    -
    value
    -
    The data to be written into the buffer. This must be 32 bits or fewer.
    -
    bits
    -
    The number of bits being written into the buffer.
    -
    - - -

    Return Values

    -
    -
  • -No values are returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_writealign.html b/Engine/lib/libogg/doc/libogg/oggpack_writealign.html deleted file mode 100644 index 01f4b0b9e..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_writealign.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -libogg - function - oggpack_writealign - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_writealign

    - -

    declared in "ogg/ogg.h";

    - -

    This function pads the oggpack_buffer with zeros out to the -next byte boundary.

    -

    The oggpack_buffer must already be initialized for writing using oggpack_writeinit. -

    Only 32 bits can be written at a time.

    - -

    - - - - -
    -
    
    -void  oggpack_writetrunc(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Buffer to be used for writing.
    -
    - - -

    Return Values

    -
    -
  • -No values are returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_writecheck.html b/Engine/lib/libogg/doc/libogg/oggpack_writecheck.html deleted file mode 100644 index dd0a7d990..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_writecheck.html +++ /dev/null @@ -1,81 +0,0 @@ - - - -libogg - function - oggpack_writecheck - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_writecheck

    - -

    declared in "ogg/ogg.h";

    - -

    This function checks the readiness status of -an oggpack_buffer previously -initialized for writing using the -Ogg bitpacking functions. A write -buffer that encounters an error (such as a failed malloc) will clear -its internal state and release any in-use memory, flagging itself as -'not ready'. Subsequent attempts to write using the buffer will -silently fail. This error state may be detected at any later time by -using oggpack_writecheck(). It is safe but not necessary to -call oggpack_writeclear() on a buffer that -has flagged an error and released its resources. - -

    Important note to developers: Although libogg checks the -results of memory allocations, these checks are only useful on a -narrow range of embedded platforms. Allocation checks perform no -useful service on a general purpose desktop OS where pages are -routinely overallocated and all allocations succeed whether memory is -available or not. The only way to detect an out of memory condition -on the vast majority of OSes is to watch for and capture segmentation -faults. This function is useful only to embedded developers. - -

    - - - - -
    -
    
    -int  oggpack_writecheck(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    An oggpack_buffer previously initialized for writing.
    -
    - - -

    Return Values

    -
    -
  • zero: buffer is ready for writing
  • -
  • nonzero: buffer is not ready or encountered an error
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_writeclear.html b/Engine/lib/libogg/doc/libogg/oggpack_writeclear.html deleted file mode 100644 index 37c471401..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_writeclear.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libogg - function - oggpack_reset - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_writeclear

    - -

    declared in "ogg/ogg.h";

    - -

    This function clears the buffer after writing and frees the memory used by the oggpack_buffer. - -

    - - - - -
    -
    
    -void oggpack_writeclear(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Our oggpack_buffer. This is an ordinary data buffer with some extra markers to ease bit navigation and manipulation.
    -
    - - -

    Return Values

    -
    -
  • -No values are returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_writecopy.html b/Engine/lib/libogg/doc/libogg/oggpack_writecopy.html deleted file mode 100644 index ec8d6134c..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_writecopy.html +++ /dev/null @@ -1,69 +0,0 @@ - - - -libogg - function - oggpack_writecopy - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_writecopy

    - -

    declared in "ogg/ogg.h";

    - -

    This function copies a sequence of bits from a source buffer into an -oggpack_buffer.

    -

    The oggpack_buffer must already be initialized for writing using oggpack_writeinit.

    -

    Only 32 bits can be written at a time.

    - -

    - - - - -
    -
    
    -void  oggpack_writecopy(oggpack_buffer *b, void *source, long bits);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Buffer to be used for writing.
    -
    source
    -
    A pointer to the data to be written into the buffer.
    -
    bits
    -
    The number of bits to be copied into the buffer.
    -
    - - -

    Return Values

    -
    -
  • -No values are returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_writeinit.html b/Engine/lib/libogg/doc/libogg/oggpack_writeinit.html deleted file mode 100644 index dabd342cd..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_writeinit.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -libogg - function - oggpack_writeinit - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_writeinit

    - -

    declared in "ogg/ogg.h";

    - -

    This function initializes an oggpack_buffer for writing using the Ogg bitpacking functions. - -

    - - - - -
    -
    
    -void  oggpack_writeinit(oggpack_buffer *b);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Buffer to be used for writing. This is an ordinary data buffer with some extra markers to ease bit navigation and manipulation.
    -
    - - -

    Return Values

    -
    -

    No values are returned. If initialization fail, the buffer is - unusable and calls to - oggpack_writecheck() will - report the error.

    -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/oggpack_writetrunc.html b/Engine/lib/libogg/doc/libogg/oggpack_writetrunc.html deleted file mode 100644 index 3488640cd..000000000 --- a/Engine/lib/libogg/doc/libogg/oggpack_writetrunc.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -libogg - function - oggpack_writetrunc - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    oggpack_writetrunc

    - -

    declared in "ogg/ogg.h";

    - -

    This function truncates an already written-to oggpack_buffer.

    -

    The oggpack_buffer must already be initialized for writing using oggpack_writeinit.

    - -

    - - - - -
    -
    
    -void  oggpack_writetrunc(oggpack_buffer *b, long bits);
    -
    -
    - -

    Parameters

    -
    -
    b
    -
    Buffer to be truncated.
    -
    bits
    -
    Number of bits to keep in the buffer (size after truncation)
    -
    - - -

    Return Values

    -
    -
  • -No values are returned.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - - diff --git a/Engine/lib/libogg/doc/libogg/overview.html b/Engine/lib/libogg/doc/libogg/overview.html deleted file mode 100644 index 3a731b4a4..000000000 --- a/Engine/lib/libogg/doc/libogg/overview.html +++ /dev/null @@ -1,44 +0,0 @@ - - - -libogg - API Overview - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    Libogg API Overview

    - -

    -The libogg API consists of the following functional categories: -

    -

    - -

    -
    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - diff --git a/Engine/lib/libogg/doc/libogg/reference.html b/Engine/lib/libogg/doc/libogg/reference.html deleted file mode 100644 index 3eac3f8ed..000000000 --- a/Engine/lib/libogg/doc/libogg/reference.html +++ /dev/null @@ -1,98 +0,0 @@ - - - -Libogg API Reference - - - - - - - - - -

    libogg documentation

    libogg release 1.3.5 - 20210603

    - -

    Libogg API Reference

    - -

    -Data Structures
    -oggpack_buffer
    -ogg_page
    -ogg_stream_state
    -ogg_packet
    -ogg_sync_state
    -
    -Bitpacking
    -oggpack_writeinit()
    -oggpack_writecheck()
    -oggpack_reset()
    -oggpack_writetrunc()
    -oggpack_writealign()
    -oggpack_writecopy()
    -oggpack_writeclear()
    -oggpack_readinit()
    -oggpack_write()
    -oggpack_look()
    -oggpack_look1()
    -oggpack_adv()
    -oggpack_adv1()
    -oggpack_read()
    -oggpack_read1()
    -oggpack_bytes()
    -oggpack_bits()
    -oggpack_get_buffer()
    -
    -Decoding-Related
    -ogg_sync_init()
    -ogg_sync_check()
    -ogg_sync_clear()
    -ogg_sync_destroy()
    -ogg_sync_reset()
    -ogg_sync_buffer()
    -ogg_sync_wrote()
    -ogg_sync_pageseek()
    -ogg_sync_pageout()
    -ogg_stream_pagein()
    -ogg_stream_packetout()
    -ogg_stream_packetpeek()
    -
    -Encoding-Related
    -ogg_stream_packetin()
    -ogg_stream_pageout()
    -ogg_stream_pageout_fill()
    -ogg_stream_flush()
    -ogg_stream_flush_fill()
    -
    -General
    -ogg_stream_init()
    -ogg_stream_check()
    -ogg_stream_clear()
    -ogg_stream_reset()
    -ogg_stream_reset_serialno()
    -ogg_stream_destroy()
    -ogg_page_version()
    -ogg_page_continued()
    -ogg_page_packets()
    -ogg_page_bos()
    -ogg_page_eos()
    -ogg_page_granulepos()
    -ogg_page_serialno()
    -ogg_page_pageno()
    -ogg_packet_clear()
    -ogg_page_checksum_set()
    -

    -


    - - - - - - - - -

    copyright © 2000-2021 Xiph.Org Foundation

    Ogg Container Format

    libogg documentation

    libogg release 1.3.5 - 20210603

    - - - - diff --git a/Engine/lib/libogg/doc/libogg/style.css b/Engine/lib/libogg/doc/libogg/style.css deleted file mode 100644 index 81cf41795..000000000 --- a/Engine/lib/libogg/doc/libogg/style.css +++ /dev/null @@ -1,7 +0,0 @@ -BODY { font-family: Helvetica, sans-serif } -TD { font-family: Helvetica, sans-serif } -P { font-family: Helvetica, sans-serif } -H1 { font-family: Helvetica, sans-serif } -H2 { font-family: Helvetica, sans-serif } -H4 { font-family: Helvetica, sans-serif } -P.tiny { font-size: 8pt } diff --git a/Engine/lib/libogg/doc/multiplex1.png b/Engine/lib/libogg/doc/multiplex1.png deleted file mode 100644 index e48d1dd6b..000000000 Binary files a/Engine/lib/libogg/doc/multiplex1.png and /dev/null differ diff --git a/Engine/lib/libogg/doc/multiplex1.svg b/Engine/lib/libogg/doc/multiplex1.svg deleted file mode 100644 index 46e6d52c3..000000000 --- a/Engine/lib/libogg/doc/multiplex1.svg +++ /dev/null @@ -1,632 +0,0 @@ - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - elementary physical bitstream A - logical bitstream A - OggS - OggS - OggS - OggS - OggS - OggS - - - - - - - - - - - - - elementary physical bitstream B - logical bitstream B - OggS - OggS - OggS - OggS - OggS - OggS - - - - - - - - - - - - - - - multiplexed physical bitstream - - - - - - - - - - OggS - OggS - OggS - OggS - OggS - OggS - - diff --git a/Engine/lib/libogg/doc/ogg-multiplex.html b/Engine/lib/libogg/doc/ogg-multiplex.html deleted file mode 100644 index 0674400a0..000000000 --- a/Engine/lib/libogg/doc/ogg-multiplex.html +++ /dev/null @@ -1,446 +0,0 @@ - - - - - -Ogg Documentation - - - - - - - - - -

    Page Multiplexing and Ordering in a Physical Ogg Stream

    - -

    The low-level mechanisms of an Ogg stream (as described in the Ogg -Bitstream Overview) provide means for mixing multiple logical streams -and media types into a single linear-chronological stream. This -document specifies the high-level arrangement and use of page -structure to multiplex multiple streams of mixed media type within a -physical Ogg stream.

    - -

    Design Elements

    - -

    The design and arrangement of the Ogg container format is governed by -several high-level design decisions that form the reasoning behind -specific low-level design decisions.

    - -

    Linear media

    - -

    The Ogg bitstream is intended to encapsulate chronological, -time-linear mixed media into a single delivery stream or file. The -design is such that an application can always encode and/or decode a -full-featured bitstream in one pass with no seeking and minimal -buffering. Seeking to provide optimized encoding (such as two-pass -encoding) or interactive decoding (such as scrubbing or instant -replay) is not disallowed or discouraged, however no bitstream feature -must require nonlinear operation on the bitstream.

    - -

    Multiplexing

    - -

    Ogg bitstreams multiplex multiple logical streams into a single -physical stream at the page level. Each page contains an abstract -time stamp (the Granule Position) that represents an absolute time -landmark within the stream. After the pages representing stream -headers (all logical stream headers occur at the beginning of a -physical bitstream section before any logical stream data), logical -stream data pages are arranged in a physical bitstream in strict -non-decreasing order by chronological absolute time as -specified by the granule position.

    - -

    The only exception to arranging pages in strictly ascending time order -by granule position is those pages that do not set the granule -position value. This is a special case when exceptionally large -packets span multiple pages; the specifics of handling this special -case are described later under 'Continuous and Discontinuous -Streams'.

    - -

    Seeking

    - -

    Ogg is designed to use an interpolated bisection search to -implement exact positional seeking. Interpolated bisection search is -a spec-mandated mechanism.

    - -

    An index may improve objective performance, but it seldom -improves subjective performance outside of a few high-latency use -cases and adds no additional functionality as bisection search -delivers the same functionality for both one- and two-pass stream -types. For these reasons, use of indexes is discouraged, except in -cases where an index provides demonstrable and noticeable performance -improvement.

    - -

    Seek operations are by absolute time; a direct bisection search must -find the exact time position requested. Information in the Ogg -bitstream is arranged such that all information to be presented for -playback from the desired seek point will occur at or after the -desired seek point. Seek operations are neither 'fuzzy' nor -heuristic.

    - -

    Although key frame handling in video appears to be an exception to -"all needed playback information lies ahead of a given seek", -key frames can still be handled directly within this indexless -framework. Seeking to a key frame in video (as well as seeking in other -media types with analogous restraints) is handled as two seeks; first -a seek to the desired time which extracts state information that -decodes to the time of the last key frame, followed by a second seek -directly to the key frame. The location of the previous key frame is -embedded as state information in the granulepos; this mechanism is -described in more detail later.

    - -

    Continuous and Discontinuous Streams

    - -

    Logical streams within a physical Ogg stream belong to one of two -categories, "Continuous" streams and "Discontinuous" streams. -Although these are discussed in more detail later, the distinction is -important to a high-level understanding of how to buffer an Ogg -stream.

    - -

    A stream that provides a gapless, time-continuous media type with a -fine-grained timebase is considered to be 'Continuous'. A continuous -stream should never be starved of data. Clear examples of continuous -data types include broadcast audio and video.

    - -

    A stream that delivers data in a potentially irregular pattern or with -widely spaced timing gaps is considered to be 'Discontinuous'. A -discontinuous stream may be best thought of as data representing -scattered events; although they happen in order, they are typically -unconnected data often located far apart. One possible example of a -discontinuous stream types would be captioning. Although it's -possible to design captions as a continuous stream type, it's most -natural to think of captions as widely spaced pieces of text with -little happening between.

    - -

    The fundamental design distinction between continuous and -discontinuous streams concerns buffering.

    - -

    Buffering

    - -

    Because a continuous stream is, by definition, gapless, Ogg buffering -is based on the simple premise of never allowing any active continuous -stream to starve for data during decode; buffering proceeds ahead -until all continuous streams in a physical stream have data ready to -decode on demand.

    - -

    Discontinuous stream data may occur on a fairly regular basis, but the -timing of, for example, a specific caption is impossible to predict -with certainty in most captioning systems. Thus the buffering system -should take discontinuous data 'as it comes' rather than working ahead -(for a potentially unbounded period) to look for future discontinuous -data. As such, discontinuous streams are ignored when managing -buffering; their pages simply 'fall out' of the stream when continuous -streams are handled properly.

    - -

    Buffering requirements need not be explicitly declared or managed for -the encoded stream; the decoder simply reads as much data as is -necessary to keep all continuous stream types gapless (also ensuring -discontinuous data arrives in time) and no more, resulting in optimum -implicit buffer usage for a given stream. Because all pages of all -data types are stamped with absolute timing information within the -stream, inter-stream synchronization timing is always explicitly -maintained without the need for explicitly declared buffer-ahead -hinting.

    - -

    Further details, mechanisms and reasons for the differing arrangement -and behavior of continuous and discontinuous streams is discussed -later.

    - -

    Whole-stream navigation

    - -

    Ogg is designed so that the simplest navigation operations treat the -physical Ogg stream as a whole summary of its streams, rather than -navigating each interleaved stream as a separate entity.

    - -

    First Example: seeking to a desired time position in a multiplexed (or -unmultiplexed) Ogg stream can be accomplished through a bisection -search on time position of all pages in the stream (as encoded in the -granule position). More powerful searches (such as a key frame-aware -seek within video) are also possible with additional search -complexity, but similar computational complexity.

    - -

    Second Example: A bitstream section may consist of three multiplexed -streams of differing lengths. The result of multiplexing these -streams should be thought of as a single mixed stream with a length -equal to the longest of the three component streams. Although it is -also possible to think of the multiplexed results as three concurrent -streams of different lengths and it is possible to recover the three -original streams, it will also become obvious that once multiplexed, -it isn't possible to find the internal lengths of the component -streams without a linear search of the whole bitstream section. -However, it is possible to find the length of the whole bitstream -section easily (in near-constant time per section) just as it is for a -single-media unmultiplexed stream.

    - -

    Granule Position

    - -

    Description

    - -

    The Granule Position is a signed 64 bit field appearing in the header -of every Ogg page. Although the granule position represents absolute -time within a logical stream, its value does not necessarily directly -encode a simple timestamp. It may represent frames elapsed (as in -Vorbis), a simple timestamp, or a more complex bit-division encoding -(such as in Theora). The exact encoding of the granule position is up -to a specific codec.

    - -

    The granule position is governed by the following rules:

    - -
      - -
    • Granule Position must always increase forward or remain equal from -page to page, be unset, or be zero for a header page. The absolute -time to which any correct sequence of granule position maps must -similarly always increase forward or remain equal. (A codec may -make use of data, such as a control sequence, that only affects codec -working state without producing data and thus advancing granule -position and time. Although the packet sequence number increases in -this case, the granule position, and thus the time position, do -not.)
    • - -
    • Granule position may only be unset if there no packet defining a -time boundary on the page (that is, if no packet in a continuous -stream ends on the page, or no packet in a discontinuous stream begins -on the page. This will be discussed in more detail under Continuous -and Discontinuous streams).
    • - -
    • A codec must be able to translate a given granule position value -to a unique, deterministic absolute time value through direct -calculation. A codec is not required to be able to translate an -absolute time value into a unique granule position value.
    • - -
    • Codecs shall choose a granule position definition that allows that -codec means to seek as directly as possible to an immediately -decodable point, such as the bit-divided granule position encoding of -Theora allows the codec to seek efficiently to key frame without using -an index. That is, additional information other than absolute time -may be encoded into a granule position value so long as the granule -position obeys the above points.
    • - -
    - -

    Example: timestamp

    - -

    In general, a codec/stream type should choose the simplest granule -position encoding that addresses its requirements. The examples here -are by no means exhaustive of the possibilities within Ogg.

    - -

    A simple granule position could encode a timestamp directly. For -example, a granule position that encoded milliseconds from beginning -of stream would allow a logical stream length of over 100,000,000,000 -days before beginning a new logical stream (to avoid the granule -position wrapping).

    - -

    Example: framestamp

    - -

    A simple millisecond timestamp granule encoding might suit many stream -types, but a millisecond resolution is inappropriate to, eg, most -audio encodings where exact single-sample resolution is generally a -requirement. A millisecond is both too large a granule and often does -not represent an integer number of samples.

    - -

    In the event that audio frames are always encoded as the same number of -samples, the granule position could simply be a linear count of frames -since beginning of stream. This has the advantages of being exact and -efficient. Position in time would simply be [granule_position] * -[samples_per_frame] / [samples_per_second].

    - -

    Example: samplestamp (Vorbis)

    - -

    Frame counting is insufficient in codecs such as Vorbis where an audio -frame [packet] encodes a variable number of samples. In Vorbis's -case, the granule position is a count of the number of raw samples -from the beginning of stream; the absolute time of -a granule position is [granule_position] / -[samples_per_second].

    - -

    Example: bit-divided framestamp (Theora)

    - -

    Some video codecs may be able to use the simple framestamp scheme for -granule position. However, most modern video codecs introduce at -least the following complications:

    - -
      - -
    • video frames are relatively far apart compared to audio samples; -for this reason, the point at which a video frame changes to the next -frame is usually a strictly defined offset within the frame 'period'. -That is, video at 50fps could just as easily define frame transitions -<.015, .035, .055...> as at <.00, .02, .04...>.
    • - -
    • frame rates often include drop-frames, leap-frames or other -rational-but-non-integer timings.
    • - -
    • Decode must begin at a 'key frame' or 'I frame'. Keyframes usually -occur relatively seldom.
    • - -
    - -

    The first two points can be handled straightforwardly via the fact -that the codec has complete control mapping granule position to -absolute time; non-integer frame rates and offsets can be set in the -codec's initial header, and the rest is just arithmetic.

    - -

    The third point appears trickier at first glance, but it too can be -handled through the granule position mapping mechanism. Here we -arrange the granule position in such a way that granule positions of -key frames are easy to find. Divide the granule position into two -fields; the most-significant bits are an absolute frame counter, but -it's only updated at each key frame. The least significant bits encode -the number of frames since the last key frame. In this way, each -granule position both encodes the absolute time of the current frame -as well as the absolute time of the last key frame.

    - -

    Seeking to a most recent preceding key frame is then accomplished by -first seeking to the original desired point, inspecting the granulepos -of the resulting video page, extracting from that granulepos the -absolute time of the desired key frame, and then seeking directly to -that key frame's page. Of course, it's still possible for an -application to ignore key frames and use a simpler seeking algorithm -(decode would be unable to present decoded video until the next -key frame). Surprisingly many player applications do choose the -simpler approach.

    - -

    granule position, packets and pages

    - -

    Although each packet of data in a logical stream theoretically has a -specific granule position, only one granule position is encoded -per page. It is possible to encode a logical stream such that each -page contains only a single packet (so that granule positions are -preserved for each packet), however a one-to-one packet/page mapping -is not intended to be the general case.

    - -

    Because Ogg functions at the page, not packet, level, this -once-per-page time information provides Ogg with the finest-grained -time information is can use. Ogg passes this granule positioning data -to the codec (along with the packets extracted from a page); it is the -responsibility of codecs to track timing information at granularities -finer than a single page.

    - -

    start-time and end-time positioning

    - -

    A granule position represents the instantaneous time location -between two pages. However, continuous streams and discontinuous -streams differ on whether the granulepos represents the end-time of -the data on a page or the start-time. Continuous streams are -'end-time' encoded; the granulepos represents the point in time -immediately after the last data decoded from a page. Discontinuous -streams are 'start-time' encoded; the granulepos represents the point -in time of the first data decoded from the page.

    - -

    An Ogg stream type is declared continuous or discontinuous by its -codec. A given codec may support both continuous and discontinuous -operation so long as any given logical stream is continuous or -discontinuous for its entirety and the codec is able to ascertain (and -inform the Ogg layer) as to which after decoding the initial stream -header. The majority of codecs will always be continuous (such as -Vorbis) or discontinuous (such as Writ).

    - -

    Start- and end-time encoding do not affect multiplexing sort-order; -pages are still sorted by the absolute time a given granulepos maps to -regardless of whether that granulepos represents start- or -end-time.

    - -

    Multiplex/Demultiplex Division of Labor

    - -

    The Ogg multiplex/demultiplex layer provides mechanisms for encoding -raw packets into Ogg pages, decoding Ogg pages back into the original -codec packets, determining the logical structure of an Ogg stream, and -navigating through and synchronizing with an Ogg stream at a desired -stream location. Strict multiplex/demultiplex operations are entirely -in the Ogg domain and require no intervention from codecs.

    - -

    Implementation of more complex operations does require codec -knowledge, however. Unlike other framing systems, Ogg maintains -strict separation between framing and the framed bitstream data; Ogg -does not replicate codec-specific information in the page/framing -data, nor does Ogg blur the line between framing and stream -data/metadata. Because Ogg is fully data-agnostic toward the data it -frames, operations which require specifics of bitstream data (such as -'seek to key frame') also require interaction with the codec layer -(because, in this example, the Ogg layer is not aware of the concept -of key frames). This is different from systems that blur the -separation between framing and stream data in order to simplify the -separation of code. The Ogg system purposely keeps the distinction in -data simple so that later codec innovations are not constrained by -framing design.

    - -

    For this reason, however, complex seeking operations require -interaction with the codecs in order to decode the granule position of -a given stream type back to absolute time or in order to find -'decodable points' such as key frames in video.

    - -

    Unsorted Discussion Points

    - -

    flushes around key frames? RFC suggestion: repaginating or building a -stream this way is nice but not required

    - -

    Appendix A: multiplexing examples

    - - - - - diff --git a/Engine/lib/libogg/doc/oggstream.html b/Engine/lib/libogg/doc/oggstream.html deleted file mode 100644 index 9769d5aa9..000000000 --- a/Engine/lib/libogg/doc/oggstream.html +++ /dev/null @@ -1,594 +0,0 @@ - - - - - -Ogg Documentation - - - - - - -
    - - - -

    Ogg bitstream overview

    - -

    This document serves as starting point for understanding the design -and implementation of the Ogg container format. If you're new to Ogg -or merely want a high-level technical overview, start reading here. -Other documents linked from the index page -give distilled technical descriptions and references of the container -mechanisms. This document is intended to aid understanding. - -

    Container format design points

    - -

    Ogg is intended to be a simplest-possible container, concerned only -with framing, ordering, and interleave. It can be used as a stream delivery -mechanism, for media file storage, or as a building block toward -implementing a more complex, non-linear container (for example, see -the Skeleton or Annodex/CMML). - -

    The Ogg container is not intended to be a monolithic -'kitchen-sink'. It exists only to frame and deliver in-order stream -data and as such is vastly simpler than most other containers. -Elementary and multiplexed streams are both constructed entirely from a -single building block (an Ogg page) comprised of eight fields -totalling twenty-eight bytes (the page header) a list of packet lengths -(up to 255 bytes) and payload data (up to 65025 bytes). The structure -of every page is the same. There are no optional fields or alternate -encodings. - -

    Stream and media metadata is contained in Ogg and not built into -the Ogg container itself. Metadata is thus compartmentalized and -layered rather than part of a monolithic design, an especially good -idea as no two groups seem able to agree on what a complete or -complete-enough metadata set should be. In this way, the container and -container implementation are isolated from unnecessary metadata design -flux. - -

    Streaming

    - -

    The Ogg container is primarily a streaming format, -encapsulating chronological, time-linear mixed media into a single -delivery stream or file. The design is such that an application can -always encode and/or decode all features of a bitstream in one pass -with no seeking and minimal buffering. Seeking to provide optimized -encoding (such as two-pass encoding) or interactive decoding (such as -scrubbing or instant replay) is not disallowed or discouraged, however -no container feature requires nonlinear access of the bitstream. - -

    Variable Bit Rate, Variable Payload Size

    - -

    Ogg is designed to contain any size data payload with bounded, -predictable efficiency. Ogg packets have no maximum size and a -zero-byte minimum size. There is no restriction on size changes from -packet to packet. Variable size packets do not require the use of any -optional or additional container features. There is no optimal -suggested packet size, though special consideration was paid to make -sure 50-200 byte packets were no less efficient than larger packet -sizes. The original design criteria was a 2% overhead at 50 byte -packets, dropping to a maximum working overhead of 1% with larger -packets, and a typical working overhead of .5-.7% for most practical -uses. - -

    Simple pagination

    - -

    Ogg is a byte-aligned container with no context-dependent, optional -or variable-length fields. Ogg requires no repacking of codec data. -The page structure is written out in-line as packet data is submitted -to the streaming abstraction. In addition, it is possible to -implement both Ogg mux and demux as MT-hot zero-copy abstractions (as -is done in the Tremor sourcebase). - -

    Capture

    - -

    Ogg is designed for efficient and immediate stream capture with -high confidence. Although packets have no size limit in Ogg, pages -are a maximum of just under 64kB meaning that any Ogg stream can be -captured with confidence after seeing 128kB of data or less [worst -case; typical figure is 6kB] from any random starting point in the -stream. - -

    Seeking

    - -

    Ogg implements simple coarse- and fine-grained seeking by design. - -

    Coarse seeking may be performed by simply 'moving the tone arm' to a -new position and 'dropping the needle'. Rapid capture with -accompanying timecode from any location in an Ogg file is guaranteed -by the stream design. From the acquisition of the first timecode, -all data needed to play back from that time code forward is ahead of -the stream cursor. - -

    Ogg implements full sample-granularity seeking using an -interpolated bisection search built on the capture and timecode -mechanisms used by coarse seeking. As above, once a search finds -the desired timecode, all data needed to play back from that time code -forward is ahead of the stream cursor. - -

    Both coarse and fine seeking use the page structure and sequencing -inherent to the Ogg format. All Ogg streams are fully seekable from -creation; seekability is unaffected by truncation or missing data, and -is tolerant of gross corruption. Seek operations are neither 'fuzzy' nor -heuristic. - -

    Seeking without use of an index is a major point of the Ogg -design. There two primary reasons why Ogg transport forgoes an index: - -

      - -
    1. An index is only marginally useful in Ogg for the complexity -added; it adds no new functionality and seldom improves performance -noticeably. Empirical testing shows that indexless interpolation -search does not require many more seeks in practice than using an -index would. - -
    2. 'Optional' indexes encourage lazy implementations that can seek -only when indexes are present, or that implement indexless seeking -only by building an internal index after reading the entire file -beginning to end. This has been the fate of other containers that -specify optional indexing. - -
    - -

    In addition, it must be possible to create an Ogg stream in a -single pass. Although an optional index can simply be tacked on the -end of the created stream, some software groups object to -end-positioned indexes and claim to be unwilling to support indexes -not located at the stream beginning. - -

    All this said, it's become clear that an optional index is a -demanded feature. For this reason, the OggSkeleton now defines a -proposed index. - -

    Simple multiplexing

    - -

    Ogg multiplexes streams by interleaving pages from multiple elementary streams into a -multiplexed stream in time order. The multiplexed pages are not -altered. Muxing an Ogg AV stream out of separate audio, -video and data streams is akin to shuffling several decks of cards -together into a single deck; the cards themselves remain unchanged. -Demultiplexing is similarly simple (as the cards are marked). - -

    The goal of this design is to make the mux/demux operation as -trivial as possible to allow live streaming systems to build and -rebuild streams on the fly with minimal CPU usage and no additional -storage or latency requirements. - -

    Continuous and Discontinuous Media

    - -

    Ogg streams belong to one of two categories, "Continuous" streams and -"Discontinuous" streams. - -

    A stream that provides a gapless, time-continuous media type with a -fine-grained timebase is considered to be 'Continuous'. A continuous -stream should never be starved of data. Examples of continuous data -types include broadcast audio and video. - -

    A stream that delivers data in a potentially irregular pattern or -with widely spaced timing gaps is considered to be 'Discontinuous'. A -discontinuous stream may be best thought of as data representing -scattered events; although they happen in order, they are typically -unconnected data often located far apart. One example of a -discontinuous stream types would be captioning such as Ogg Kate. Although it's -possible to design captions as a continuous stream type, it's most -natural to think of captions as widely spaced pieces of text with -little happening between. - -

    The fundamental reason for distinction between continuous and -discontinuous streams concerns buffering. - -

    Buffering

    - -

    A continuous stream is, by definition, gapless. Ogg buffering is based -on the simple premise of never allowing an active continuous stream -to starve for data during decode; buffering works ahead until all -continuous streams in a physical stream have data ready and no further. - -

    Discontinuous stream data is not assumed to be predictable. The -buffering design takes discontinuous data 'as it comes' rather than -working ahead to look for future discontinuous data for a potentially -unbounded period. Thus, the buffering process makes no attempt to fill -discontinuous stream buffers; their pages simply 'fall out' of the -stream when continuous streams are handled properly. - -

    Buffering requirements in this design need not be explicitly -declared or managed in the encoded stream. The decoder simply reads as -much data as is necessary to keep all continuous stream types gapless -and no more, with discontinuous data processed as it arrives in the -continuous data. Buffering is implicitly optimal for the given -stream. Because all pages of all data types are stamped with absolute -timing information within the stream, inter-stream synchronization -timing is always maintained without the need for explicitly declared -buffer-ahead hinting. - -

    Codec metadata

    - -

    Ogg does not replicate codec-specific metadata into the mux layer -in an attempt to make the mux and codec layer implementations 'fully -separable'. Things like specific timebase, keyframing strategy, frame -duration, etc, do not appear in the Ogg container. The mux layer is, -instead, expected to query a codec through a centralized interface, -left to the implementation, for this data when it is needed. - -

    Though modern design wisdom usually prefers to predict all possible -needs of current and future codecs then embed these dependencies and -the required metadata into the container itself, this strategy -increases container specification complexity, fragility, and rigidity. -The mux and codec code becomes more independent, but the -specifications become logically less independent. A codec can't do -what a container hasn't already provided for. Novel codecs are harder -to support, and you can do fewer useful things with the ones you've -already got (eg, try to make a good splitter without using any codecs. -Such a splitter is limited to splitting at keyframes only, or building -yet another new mechanism into the container layer to mark what frames -to skip displaying). - -

    Ogg's design goes the opposite direction, where the specification -is to be as simple, easy to understand, and 'proofed' against novel -codecs as possible. When an Ogg mux layer requires codec-specific -information, it queries the codec (or a codec stub). This trades a -more complex implementation for a simpler, more flexible -specification. - -

    Stream structure metadata

    - -

    The Ogg container itself does not define a metadata system for -declaring the structure and interrelations between multiple media -types in a muxed stream. That is, the Ogg container itself does not -specify data like 'which steam is the subtitle stream?' or 'which -video stream is the primary angle?'. This metadata still exists, but -is stored by the Ogg container rather than being built into the Ogg -container itself. Xiph specifies the 'Skeleton' metadata format for Ogg -streams, but this decoupling of container and stream structure -metadata means it is possible to use Ogg with any metadata -specification without altering the container itself, or without stream -structure metadata at all. - -

    Frame accurate absolute position

    - -

    Every Ogg page is stamped with a 64 bit 'granule position' that -serves as an absolute timestamp for mux and seeking. A few nifty -little tricks are usually also embedded in the granpos state, but -we'll leave those aside for the moment (strictly speaking, they're -part of each codec's mapping, not Ogg). - -

    As previously mentioned above, granule positions are mapped into -absolute timestamps by the codec, rather than being a hard timestamp. -This allows maximally efficient use of the available 64 bits to -address every sample/frame position without approximation while -supporting new and previously unknown timebase encodings without -needing to extend or update the mux layer. When a codec needs a novel -timebase, it simply brings the code for that mapping along with it. -This is not a theoretical curiosity; new, wholly novel timebases were -deployed with the adoption of both Theora and Dirac. "Rolling INTRA" -(keyframeless video) also benefits from novel use of the granule -position. - -

    Ogg stream arrangement

    - -

    Packets, pages, and bitstreams

    - -

    Ogg codecs place raw compressed data into packets. -Packets are octet payloads containing the data needed for a single -decompressed unit, eg, one video frame. Packets have no maximum size -and may be zero length. They do not generally have any framing -information; strung together, the unframed packets form a logical -bitstream of codec data with no internal landmarks. - -

    - - -

    Packets of raw codec data are not typically internally framed. - When they are strung together into a stream without any container to - provide framing, they lose their individual boundaries. Seek and - capture are not possible within an unframed stream, and for many - codecs with variable length payloads and/or early-packet termination - (such as Vorbis), it may become impossible to recover the original - frame boundaries even if the stream is scanned linearly from - beginning to end. - -

    - -

    Logical bitstream packets are grouped and framed into Ogg pages -along with a unique stream serial number to produce a -physical bitstream. An elementary stream is a -physical bitstream containing only a single logical bitstream. Each -page is a self contained entity, although a packet may be split and -encoded across one or more pages. The page decode mechanism is -designed to recognize, verify and handle single pages at a time from -the overall bitstream. - -

    - - -

    The primary purpose of a container is to provide framing for raw - packets, marking the packet boundaries so the exact packets can be - retrieved for decode later. The container also provides secondary - functions such as capture, timestamping, sequencing, stream - identification and so on. Not all of these functions are represented in the diagram. - -

    In the Ogg container, pages do not necessarily contain - integer numbers of packets. Packets may span across page boundaries - or even multiple pages. This is necessary as pages have a maximum - possible size in order to provide capture guarantees, but packet - size is unbounded. -

    - - -

    Ogg Bitstream Framing specifies -the page format of an Ogg bitstream, the packet coding process -and elementary bitstreams in detail. - -

    Multiplexed bitstreams

    - -

    Multiple logical/elementary bitstreams can be combined into a single -multiplexed bitstream by interleaving whole pages from each -contributing elementary stream in time order. The result is a single -physical stream that multiplexes and frames multiple logical streams. -Each logical stream is identified by the unique stream serial number -stamped in its pages. A physical stream may include a 'meta-header' -(such as the Ogg Skeleton) comprising its -own Ogg page at the beginning of the physical stream. A decoder -recovers the original logical/elementary bitstreams out of the -physical bitstream by taking the pages in order from the physical -bitstream and redirecting them into the appropriate logical decoding -entity. - -

    - - -

    Multiple media types are mutliplexed into a single Ogg stream by -interleaving the pages from each elementary physical stream. - -

    - -

    Ogg Bitstream Multiplexing specifies -proper multiplexing of an Ogg bitstream in detail. - -

    Chaining

    - -

    Multiple Ogg physical bitstreams may be concatenated into a single new -stream; this is chaining. The bitstreams do not overlap; the -final page of a given logical bitstream is immediately followed by the -initial page of the next.

    - -

    Each logical bitstream in a chain must have a unique serial number -within the scope of the full physical bitstream, not only within a -particular link or segment of the chain.

    - -

    Continuous and discontinuous streams

    - -

    Within Ogg, each stream must be declared (by the codec) to be -continuous- or discontinuous-time. Most codecs treat all streams they -use as either inherently continuous- or discontinuous-time, although -this is not a requirement. A codec may, as part of its mapping, choose -according to data in the initial header. - -

    Continuous-time pages are stamped by end-time, discontinuous pages -are stamped by begin-time. Pages in a multiplexed stream are -interleaved in order of the time stamp regardless of stream type. -Both continuous and discontinuous logical streams are used to seek -within a physical stream, however only continuous streams are used to -determine buffering depth; because discontinuous streams are stamped -by start time, they will always 'fall out' at the proper time when -buffering the continuous streams. See 'Examples' for an illustration -of the buffering mechanism. - -

    Multiplexing Requirements

    - -

    Multiplexing requirements within Ogg are straightforward. When -constructing a single-link (unchained) physical bitstream consisting -of multiple elementary streams: - -

      - -
    1. The initial header for each stream appears in sequence, each -header on a single page. All initial headers must appear with no -intervening data (no auxiliary header pages or packets, no data pages -or packets). Order of the initial headers is unspecified. The -'beginning of stream' flag is set on each initial header. - -

    2. All auxiliary headers for all streams must follow. Order -is unspecified. The final auxiliary header of each stream must flush -its page. - -

    3. Data pages for each stream follow, interleaved in time order. - -

    4. The final page of each stream sets the 'end of stream' flag. -Unlike initial pages, terminal pages for the logical bitstreams need -not occur contiguously; indeed it may not be possible for them to do so. -

    - -

    Each grouped bitstream must have a unique serial number within the -scope of the physical bitstream.

    - -

    chaining and multiplexing

    - -

    Multiplexed and/or unmultiplexed bitstreams may be chained -consecutively. Such a physical bitstream obeys all the rules of both -chained and multiplexed streams. Each link, when unchained, must -stand on its own as a valid physical bitstream. Chained streams do -not mix or interleave; a new segment may not begin until all streams -in the preceding segment have terminated.

    - -

    Codec Mapping Requirements

    - -

    Each codec is allowed some freedom in deciding how its logical -bitstream is encapsulated into an Ogg bitstream (even if it is a -trivial mapping, eg, 'plop the packets in and go'). This is the -codec's mapping. Ogg imposes a few mapping requirements -on any codec. - -

      - -
    1. The framing specification defines -'beginning of stream' and 'end of stream' page markers via a header -flag (it is possible for a stream to consist of a single page). A -correct stream always consists of an integer number of pages, an easy -requirement given the variable size nature of pages.

      - -
    2. The first page of an elementary Ogg bitstream consists of a single, -small 'initial header' packet that must include sufficient information -to identify the exact CODEC type. From this initial header, the codec -must also be able to determine its timebase and whether or not it is a -continuous- or discontinuous-time stream. The initial header must fit -on a single page. If a codec makes use of auxiliary headers (for -example, Vorbis uses two auxiliary headers), these headers must follow -the initial header immediately. The last header finishes its page; -data begins on a fresh page. - -

      As an example, Ogg Vorbis places the name and revision of the -Vorbis CODEC, the audio rate and the audio quality into this initial -header. Vorbis comments and detailed codec setup appears in the larger -auxiliary headers.

      - -
    3. Granule positions must be translatable to an exact absolute -time value. As described above, the mux layer is permitted to query a -codec or codec stub plugin to perform this mapping. It is not -necessary for an absolute time to be mappable into a single unique -granule position value. - -

    4. Codecs are not required to use a fixed duration-per-packet (for -example, Vorbis does not). the mux layer is permitted to query a -codec or codec stub plugin for the time duration of a packet. - -

    5. Although an absolute time need not be translatable to a unique -granule position, a codec must be able to determine the unique granule -position of the current packet using the granule position of a -preceding packet. - -

    6. Packets and pages must be arranged in ascending -granule-position and time order. - -

    - -

    Examples

    - -[More to come shortly; this section is currently being revised and expanded] - -

    Below, we present an example of a multiplexed and chained bitstream:

    - -

    stream

    - -

    In this example, we see pages from five total logical bitstreams -multiplexed into a physical bitstream. Note the following -characteristics:

    - -
      -
    1. Multiplexed bitstreams in a given link begin together; all of the -initial pages must appear before any data pages. When concurrently -multiplexed groups are chained, the new group does not begin until all -the bitstreams in the previous group have terminated.
    2. - -
    3. The ordering of pages of concurrently multiplexed bitstreams is -goverened by timestamp (not shown here); there is no regular -interleaving order. Pages within a logical bitstream appear in -sequence order.
    4. -
    - - - -
    - - diff --git a/Engine/lib/libogg/doc/packets.png b/Engine/lib/libogg/doc/packets.png deleted file mode 100644 index 917b6c167..000000000 Binary files a/Engine/lib/libogg/doc/packets.png and /dev/null differ diff --git a/Engine/lib/libogg/doc/packets.svg b/Engine/lib/libogg/doc/packets.svg deleted file mode 100644 index 6b426c7e5..000000000 --- a/Engine/lib/libogg/doc/packets.svg +++ /dev/null @@ -1,876 +0,0 @@ - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - - - - - - - - - - - - - - - - - - - - - - - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - - packet stream - unframed logical bitstream - - diff --git a/Engine/lib/libogg/doc/pages.png b/Engine/lib/libogg/doc/pages.png deleted file mode 100644 index b4b431e99..000000000 Binary files a/Engine/lib/libogg/doc/pages.png and /dev/null differ diff --git a/Engine/lib/libogg/doc/pages.svg b/Engine/lib/libogg/doc/pages.svg deleted file mode 100644 index 436849ceb..000000000 --- a/Engine/lib/libogg/doc/pages.svg +++ /dev/null @@ -1,1219 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - OggS - OggS - OggS - - - - - - - - - - - - - - - 23 - 24 - 25 - - ... - ... - physical bitstream - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - framed logical bitstream - - - - - - - - - - - - - - - - - - - - - - - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - packet - - - diff --git a/Engine/lib/libogg/doc/release.txt b/Engine/lib/libogg/doc/release.txt deleted file mode 100644 index f72985ff1..000000000 --- a/Engine/lib/libogg/doc/release.txt +++ /dev/null @@ -1,29 +0,0 @@ -= Release checklist = - -Source release: - -- Update CHANGES with notable specifics. -- Update version and LIB_* API soname suffix in configure.ac. - - If the source code changed, incremement REVISION. - - If interfaces changed, increment CURRENT and zero REVISION. - - If interfaces were added, increment AGE. - - If interfaces were removed, set AGE to zero. -- Update the version and release date in doc/libogg/*.html. - - `make -C doc/libogg update-doc-version` -- Check for uncommitted changes to master. -- Tag the release commit with 'git tag -s vN.M'. - - Include release notes in the tag annotation. -- Verify 'make distcheck' produces a tarball with the desired name. -- Push tag to public repo. -- Upload source package 'libogg-${version}.tar.gz' et al. - to the website and verify file permissions. -- Update checksum files on website. -- Update links on . -- Add a copy of the documentation to - and update the links. - -Releases are committed to https://svn.xiph.org/releases/ogg/ -which propagates to downloads.xiph.org. - -Release packages should also be manually attached to the corresponding -tag on the github mirror https://github.com/xiph/ogg/releases diff --git a/Engine/lib/libogg/doc/rfc3533.txt b/Engine/lib/libogg/doc/rfc3533.txt deleted file mode 100644 index f2fcd1a0c..000000000 --- a/Engine/lib/libogg/doc/rfc3533.txt +++ /dev/null @@ -1,843 +0,0 @@ - - - - - - -Network Working Group S. Pfeiffer -Request for Comments: 3533 CSIRO -Category: Informational May 2003 - - - The Ogg Encapsulation Format Version 0 - -Status of this Memo - - This memo provides information for the Internet community. It does - not specify an Internet standard of any kind. Distribution of this - memo is unlimited. - -Copyright Notice - - Copyright (C) The Internet Society (2003). All Rights Reserved. - -Abstract - - This document describes the Ogg bitstream format version 0, which is - a general, freely-available encapsulation format for media streams. - It is able to encapsulate any kind and number of video and audio - encoding formats as well as other data streams in a single bitstream. - -Terminology - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this - document are to be interpreted as described in BCP 14, RFC 2119 [2]. - -Table of Contents - - 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2 - 2. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 2 - 3. Requirements for a generic encapsulation format . . . . . . . 3 - 4. The Ogg bitstream format . . . . . . . . . . . . . . . . . . . 3 - 5. The encapsulation process . . . . . . . . . . . . . . . . . . 6 - 6. The Ogg page format . . . . . . . . . . . . . . . . . . . . . 9 - 7. Security Considerations . . . . . . . . . . . . . . . . . . . 11 - 8. References . . . . . . . . . . . . . . . . . . . . . . . . . . 12 - A. Glossary of terms and abbreviations . . . . . . . . . . . . . 13 - B. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 14 - Author's Address . . . . . . . . . . . . . . . . . . . . . . . 14 - Full Copyright Statement . . . . . . . . . . . . . . . . . . . 15 - - - - - - - -Pfeiffer Informational [Page 1] - -RFC 3533 OGG May 2003 - - -1. Introduction - - The Ogg bitstream format has been developed as a part of a larger - project aimed at creating a set of components for the coding and - decoding of multimedia content (codecs) which are to be freely - available and freely re-implementable, both in software and in - hardware for the computing community at large, including the Internet - community. It is the intention of the Ogg developers represented by - Xiph.Org that it be usable without intellectual property concerns. - - This document describes the Ogg bitstream format and how to use it to - encapsulate one or several media bitstreams created by one or several - encoders. The Ogg transport bitstream is designed to provide - framing, error protection and seeking structure for higher-level - codec streams that consist of raw, unencapsulated data packets, such - as the Vorbis audio codec or the upcoming Tarkin and Theora video - codecs. It is capable of interleaving different binary media and - other time-continuous data streams that are prepared by an encoder as - a sequence of data packets. Ogg provides enough information to - properly separate data back into such encoder created data packets at - the original packet boundaries without relying on decoding to find - packet boundaries. - - Please note that the MIME type application/ogg has been registered - with the IANA [1]. - -2. Definitions - - For describing the Ogg encapsulation process, a set of terms will be - used whose meaning needs to be well understood. Therefore, some of - the most fundamental terms are defined now before we start with the - description of the requirements for a generic media stream - encapsulation format, the process of encapsulation, and the concrete - format of the Ogg bitstream. See the Appendix for a more complete - glossary. - - The result of an Ogg encapsulation is called the "Physical (Ogg) - Bitstream". It encapsulates one or several encoder-created - bitstreams, which are called "Logical Bitstreams". A logical - bitstream, provided to the Ogg encapsulation process, has a - structure, i.e., it is split up into a sequence of so-called - "Packets". The packets are created by the encoder of that logical - bitstream and represent meaningful entities for that encoder only - (e.g., an uncompressed stream may use video frames as packets). They - do not contain boundary information - strung together they appear to - be streams of random bytes with no landmarks. - - - - - -Pfeiffer Informational [Page 2] - -RFC 3533 OGG May 2003 - - - Please note that the term "packet" is not used in this document to - signify entities for transport over a network. - -3. Requirements for a generic encapsulation format - - The design idea behind Ogg was to provide a generic, linear media - transport format to enable both file-based storage and stream-based - transmission of one or several interleaved media streams independent - of the encoding format of the media data. Such an encapsulation - format needs to provide: - - o framing for logical bitstreams. - - o interleaving of different logical bitstreams. - - o detection of corruption. - - o recapture after a parsing error. - - o position landmarks for direct random access of arbitrary positions - in the bitstream. - - o streaming capability (i.e., no seeking is needed to build a 100% - complete bitstream). - - o small overhead (i.e., use no more than approximately 1-2% of - bitstream bandwidth for packet boundary marking, high-level - framing, sync and seeking). - - o simplicity to enable fast parsing. - - o simple concatenation mechanism of several physical bitstreams. - - All of these design considerations have been taken into consideration - for Ogg. Ogg supports framing and interleaving of logical - bitstreams, seeking landmarks, detection of corruption, and stream - resynchronisation after a parsing error with no more than - approximately 1-2% overhead. It is a generic framework to perform - encapsulation of time-continuous bitstreams. It does not know any - specifics about the codec data that it encapsulates and is thus - independent of any media codec. - -4. The Ogg bitstream format - - A physical Ogg bitstream consists of multiple logical bitstreams - interleaved in so-called "Pages". Whole pages are taken in order - from multiple logical bitstreams multiplexed at the page level. The - logical bitstreams are identified by a unique serial number in the - - - -Pfeiffer Informational [Page 3] - -RFC 3533 OGG May 2003 - - - header of each page of the physical bitstream. This unique serial - number is created randomly and does not have any connection to the - content or encoder of the logical bitstream it represents. Pages of - all logical bitstreams are concurrently interleaved, but they need - not be in a regular order - they are only required to be consecutive - within the logical bitstream. Ogg demultiplexing reconstructs the - original logical bitstreams from the physical bitstream by taking the - pages in order from the physical bitstream and redirecting them into - the appropriate logical decoding entity. - - Each Ogg page contains only one type of data as it belongs to one - logical bitstream only. Pages are of variable size and have a page - header containing encapsulation and error recovery information. Each - logical bitstream in a physical Ogg bitstream starts with a special - start page (bos=beginning of stream) and ends with a special page - (eos=end of stream). - - The bos page contains information to uniquely identify the codec type - and MAY contain information to set up the decoding process. The bos - page SHOULD also contain information about the encoded media - for - example, for audio, it should contain the sample rate and number of - channels. By convention, the first bytes of the bos page contain - magic data that uniquely identifies the required codec. It is the - responsibility of anyone fielding a new codec to make sure it is - possible to reliably distinguish his/her codec from all other codecs - in use. There is no fixed way to detect the end of the codec- - identifying marker. The format of the bos page is dependent on the - codec and therefore MUST be given in the encapsulation specification - of that logical bitstream type. Ogg also allows but does not require - secondary header packets after the bos page for logical bitstreams - and these must also precede any data packets in any logical - bitstream. These subsequent header packets are framed into an - integral number of pages, which will not contain any data packets. - So, a physical bitstream begins with the bos pages of all logical - bitstreams containing one initial header packet per page, followed by - the subsidiary header packets of all streams, followed by pages - containing data packets. - - The encapsulation specification for one or more logical bitstreams is - called a "media mapping". An example for a media mapping is "Ogg - Vorbis", which uses the Ogg framework to encapsulate Vorbis-encoded - audio data for stream-based storage (such as files) and transport - (such as TCP streams or pipes). Ogg Vorbis provides the name and - revision of the Vorbis codec, the audio rate and the audio quality on - the Ogg Vorbis bos page. It also uses two additional header pages - per logical bitstream. The Ogg Vorbis bos page starts with the byte - 0x01, followed by "vorbis" (a total of 7 bytes of identifier). - - - - -Pfeiffer Informational [Page 4] - -RFC 3533 OGG May 2003 - - - Ogg knows two types of multiplexing: concurrent multiplexing (so- - called "Grouping") and sequential multiplexing (so-called - "Chaining"). Grouping defines how to interleave several logical - bitstreams page-wise in the same physical bitstream. Grouping is for - example needed for interleaving a video stream with several - synchronised audio tracks using different codecs in different logical - bitstreams. Chaining on the other hand, is defined to provide a - simple mechanism to concatenate physical Ogg bitstreams, as is often - needed for streaming applications. - - In grouping, all bos pages of all logical bitstreams MUST appear - together at the beginning of the Ogg bitstream. The media mapping - specifies the order of the initial pages. For example, the grouping - of a specific Ogg video and Ogg audio bitstream may specify that the - physical bitstream MUST begin with the bos page of the logical video - bitstream, followed by the bos page of the audio bitstream. Unlike - bos pages, eos pages for the logical bitstreams need not all occur - contiguously. Eos pages may be 'nil' pages, that is, pages - containing no content but simply a page header with position - information and the eos flag set in the page header. Each grouped - logical bitstream MUST have a unique serial number within the scope - of the physical bitstream. - - In chaining, complete logical bitstreams are concatenated. The - bitstreams do not overlap, i.e., the eos page of a given logical - bitstream is immediately followed by the bos page of the next. Each - chained logical bitstream MUST have a unique serial number within the - scope of the physical bitstream. - - It is possible to consecutively chain groups of concurrently - multiplexed bitstreams. The groups, when unchained, MUST stand on - their own as a valid concurrently multiplexed bitstream. The - following diagram shows a schematic example of such a physical - bitstream that obeys all the rules of both grouped and chained - multiplexed bitstreams. - - physical bitstream with pages of - different logical bitstreams grouped and chained - ------------------------------------------------------------- - |*A*|*B*|*C*|A|A|C|B|A|B|#A#|C|...|B|C|#B#|#C#|*D*|D|...|#D#| - ------------------------------------------------------------- - bos bos bos eos eos eos bos eos - - In this example, there are two chained physical bitstreams, the first - of which is a grouped stream of three logical bitstreams A, B, and C. - The second physical bitstream is chained after the end of the grouped - bitstream, which ends after the last eos page of all its grouped - logical bitstreams. As can be seen, grouped bitstreams begin - - - -Pfeiffer Informational [Page 5] - -RFC 3533 OGG May 2003 - - - together - all of the bos pages MUST appear before any data pages. - It can also be seen that pages of concurrently multiplexed bitstreams - need not conform to a regular order. And it can be seen that a - grouped bitstream can end long before the other bitstreams in the - group end. - - Ogg does not know any specifics about the codec data except that each - logical bitstream belongs to a different codec, the data from the - codec comes in order and has position markers (so-called "Granule - positions"). Ogg does not have a concept of 'time': it only knows - about sequentially increasing, unitless position markers. An - application can only get temporal information through higher layers - which have access to the codec APIs to assign and convert granule - positions or time. - - A specific definition of a media mapping using Ogg may put further - constraints on its specific use of the Ogg bitstream format. For - example, a specific media mapping may require that all the eos pages - for all grouped bitstreams need to appear in direct sequence. An - example for a media mapping is the specification of "Ogg Vorbis". - Another example is the upcoming "Ogg Theora" specification which - encapsulates Theora-encoded video data and usually comes multiplexed - with a Vorbis stream for an Ogg containing synchronised audio and - video. As Ogg does not specify temporal relationships between the - encapsulated concurrently multiplexed bitstreams, the temporal - synchronisation between the audio and video stream will be specified - in this media mapping. To enable streaming, pages from various - logical bitstreams will typically be interleaved in chronological - order. - -5. The encapsulation process - - The process of multiplexing different logical bitstreams happens at - the level of pages as described above. The bitstreams provided by - encoders are however handed over to Ogg as so-called "Packets" with - packet boundaries dependent on the encoding format. The process of - encapsulating packets into pages will be described now. - - From Ogg's perspective, packets can be of any arbitrary size. A - specific media mapping will define how to group or break up packets - from a specific media encoder. As Ogg pages have a maximum size of - about 64 kBytes, sometimes a packet has to be distributed over - several pages. To simplify that process, Ogg divides each packet - into 255 byte long chunks plus a final shorter chunk. These chunks - are called "Ogg Segments". They are only a logical construct and do - not have a header for themselves. - - - - - -Pfeiffer Informational [Page 6] - -RFC 3533 OGG May 2003 - - - A group of contiguous segments is wrapped into a variable length page - preceded by a header. A segment table in the page header tells about - the "Lacing values" (sizes) of the segments included in the page. A - flag in the page header tells whether a page contains a packet - continued from a previous page. Note that a lacing value of 255 - implies that a second lacing value follows in the packet, and a value - of less than 255 marks the end of the packet after that many - additional bytes. A packet of 255 bytes (or a multiple of 255 bytes) - is terminated by a lacing value of 0. Note also that a 'nil' (zero - length) packet is not an error; it consists of nothing more than a - lacing value of zero in the header. - - The encoding is optimized for speed and the expected case of the - majority of packets being between 50 and 200 bytes large. This is a - design justification rather than a recommendation. This encoding - both avoids imposing a maximum packet size as well as imposing - minimum overhead on small packets. In contrast, e.g., simply using - two bytes at the head of every packet and having a max packet size of - 32 kBytes would always penalize small packets (< 255 bytes, the - typical case) with twice the segmentation overhead. Using the lacing - values as suggested, small packets see the minimum possible byte- - aligned overhead (1 byte) and large packets (>512 bytes) see a fairly - constant ~0.5% overhead on encoding space. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Pfeiffer Informational [Page 7] - -RFC 3533 OGG May 2003 - - - The following diagram shows a schematic example of a media mapping - using Ogg and grouped logical bitstreams: - - logical bitstream with packet boundaries - ----------------------------------------------------------------- - > | packet_1 | packet_2 | packet_3 | < - ----------------------------------------------------------------- - - |segmentation (logically only) - v - - packet_1 (5 segments) packet_2 (4 segs) p_3 (2 segs) - ------------------------------ -------------------- ------------ - .. |seg_1|seg_2|seg_3|seg_4|s_5 | |seg_1|seg_2|seg_3|| |seg_1|s_2 | .. - ------------------------------ -------------------- ------------ - - | page encapsulation - v - - page_1 (packet_1 data) page_2 (pket_1 data) page_3 (packet_2 data) ------------------------- ---------------- ------------------------ -|H|------------------- | |H|----------- | |H|------------------- | -|D||seg_1|seg_2|seg_3| | |D|seg_4|s_5 | | |D||seg_1|seg_2|seg_3| | ... -|R|------------------- | |R|----------- | |R|------------------- | ------------------------- ---------------- ------------------------ - - | -pages of | -other --------| | -logical ------- -bitstreams | MUX | - ------- - | - v - - page_1 page_2 page_3 - ------ ------ ------- ----- ------- - ... || | || | || | || | || | ... - ------ ------ ------- ----- ------- - physical Ogg bitstream - - In this example we take a snapshot of the encapsulation process of - one logical bitstream. We can see part of that bitstream's - subdivision into packets as provided by the codec. The Ogg - encapsulation process chops up the packets into segments. The - packets in this example are rather large such that packet_1 is split - into 5 segments - 4 segments with 255 bytes and a final smaller one. - Packet_2 is split into 4 segments - 3 segments with 255 bytes and a - - - -Pfeiffer Informational [Page 8] - -RFC 3533 OGG May 2003 - - - final very small one - and packet_3 is split into two segments. The - encapsulation process then creates pages, which are quite small in - this example. Page_1 consists of the first three segments of - packet_1, page_2 contains the remaining 2 segments from packet_1, and - page_3 contains the first three pages of packet_2. Finally, this - logical bitstream is multiplexed into a physical Ogg bitstream with - pages of other logical bitstreams. - -6. The Ogg page format - - A physical Ogg bitstream consists of a sequence of concatenated - pages. Pages are of variable size, usually 4-8 kB, maximum 65307 - bytes. A page header contains all the information needed to - demultiplex the logical bitstreams out of the physical bitstream and - to perform basic error recovery and landmarks for seeking. Each page - is a self-contained entity such that the page decode mechanism can - recognize, verify, and handle single pages at a time without - requiring the overall bitstream. - - The Ogg page header has the following format: - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| capture_pattern: Magic number for page start "OggS" | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| version | header_type | granule_position | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | bitstream_serial_number | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | page_sequence_number | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | CRC_checksum | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| |page_segments | segment_table | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| ... | 28- -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - The LSb (least significant bit) comes first in the Bytes. Fields - with more than one byte length are encoded LSB (least significant - byte) first. - - - - - - - -Pfeiffer Informational [Page 9] - -RFC 3533 OGG May 2003 - - - The fields in the page header have the following meaning: - - 1. capture_pattern: a 4 Byte field that signifies the beginning of a - page. It contains the magic numbers: - - 0x4f 'O' - - 0x67 'g' - - 0x67 'g' - - 0x53 'S' - - It helps a decoder to find the page boundaries and regain - synchronisation after parsing a corrupted stream. Once the - capture pattern is found, the decoder verifies page sync and - integrity by computing and comparing the checksum. - - 2. stream_structure_version: 1 Byte signifying the version number of - the Ogg file format used in this stream (this document specifies - version 0). - - 3. header_type_flag: the bits in this 1 Byte field identify the - specific type of this page. - - * bit 0x01 - - set: page contains data of a packet continued from the previous - page - - unset: page contains a fresh packet - - * bit 0x02 - - set: this is the first page of a logical bitstream (bos) - - unset: this page is not a first page - - * bit 0x04 - - set: this is the last page of a logical bitstream (eos) - - unset: this page is not a last page - - 4. granule_position: an 8 Byte field containing position information. - For example, for an audio stream, it MAY contain the total number - of PCM samples encoded after including all frames finished on this - page. For a video stream it MAY contain the total number of video - - - -Pfeiffer Informational [Page 10] - -RFC 3533 OGG May 2003 - - - frames encoded after this page. This is a hint for the decoder - and gives it some timing and position information. Its meaning is - dependent on the codec for that logical bitstream and specified in - a specific media mapping. A special value of -1 (in two's - complement) indicates that no packets finish on this page. - - 5. bitstream_serial_number: a 4 Byte field containing the unique - serial number by which the logical bitstream is identified. - - 6. page_sequence_number: a 4 Byte field containing the sequence - number of the page so the decoder can identify page loss. This - sequence number is increasing on each logical bitstream - separately. - - 7. CRC_checksum: a 4 Byte field containing a 32 bit CRC checksum of - the page (including header with zero CRC field and page content). - The generator polynomial is 0x04c11db7. - - 8. number_page_segments: 1 Byte giving the number of segment entries - encoded in the segment table. - - 9. segment_table: number_page_segments Bytes containing the lacing - values of all segments in this page. Each Byte contains one - lacing value. - - The total header size in bytes is given by: - header_size = number_page_segments + 27 [Byte] - - The total page size in Bytes is given by: - page_size = header_size + sum(lacing_values: 1..number_page_segments) - [Byte] - -7. Security Considerations - - The Ogg encapsulation format is a container format and only - encapsulates content (such as Vorbis-encoded audio). It does not - provide for any generic encryption or signing of itself or its - contained content bitstreams. However, it encapsulates any kind of - content bitstream as long as there is a codec for it, and is thus - able to contain encrypted and signed content data. It is also - possible to add an external security mechanism that encrypts or signs - an Ogg physical bitstream and thus provides content confidentiality - and authenticity. - - As Ogg encapsulates binary data, it is possible to include executable - content in an Ogg bitstream. This can be an issue with applications - that are implemented using the Ogg format, especially when Ogg is - used for streaming or file transfer in a networking scenario. As - - - -Pfeiffer Informational [Page 11] - -RFC 3533 OGG May 2003 - - - such, Ogg does not pose a threat there. However, an application - decoding Ogg and its encapsulated content bitstreams has to ensure - correct handling of manipulated bitstreams, of buffer overflows and - the like. - -8. References - - [1] Walleij, L., "The application/ogg Media Type", RFC 3534, May - 2003. - - [2] Bradner, S., "Key words for use in RFCs to Indicate Requirement - Levels", BCP 14, RFC 2119, March 1997. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Pfeiffer Informational [Page 12] - -RFC 3533 OGG May 2003 - - -Appendix A. Glossary of terms and abbreviations - - bos page: The initial page (beginning of stream) of a logical - bitstream which contains information to identify the codec type - and other decoding-relevant information. - - chaining (or sequential multiplexing): Concatenation of two or more - complete physical Ogg bitstreams. - - eos page: The final page (end of stream) of a logical bitstream. - - granule position: An increasing position number for a specific - logical bitstream stored in the page header. Its meaning is - dependent on the codec for that logical bitstream and specified in - a specific media mapping. - - grouping (or concurrent multiplexing): Interleaving of pages of - several logical bitstreams into one complete physical Ogg - bitstream under the restriction that all bos pages of all grouped - logical bitstreams MUST appear before any data pages. - - lacing value: An entry in the segment table of a page header - representing the size of the related segment. - - logical bitstream: A sequence of bits being the result of an encoded - media stream. - - media mapping: A specific use of the Ogg encapsulation format - together with a specific (set of) codec(s). - - (Ogg) packet: A subpart of a logical bitstream that is created by the - encoder for that bitstream and represents a meaningful entity for - the encoder, but only a sequence of bits to the Ogg encapsulation. - - (Ogg) page: A physical bitstream consists of a sequence of Ogg pages - containing data of one logical bitstream only. It usually - contains a group of contiguous segments of one packet only, but - sometimes packets are too large and need to be split over several - pages. - - physical (Ogg) bitstream: The sequence of bits resulting from an Ogg - encapsulation of one or several logical bitstreams. It consists - of a sequence of pages from the logical bitstreams with the - restriction that the pages of one logical bitstream MUST come in - their correct temporal order. - - - - - - -Pfeiffer Informational [Page 13] - -RFC 3533 OGG May 2003 - - - (Ogg) segment: The Ogg encapsulation process splits each packet into - chunks of 255 bytes plus a last fractional chunk of less than 255 - bytes. These chunks are called segments. - -Appendix B. Acknowledgements - - The author gratefully acknowledges the work that Christopher - Montgomery and the Xiph.Org foundation have done in defining the Ogg - multimedia project and as part of it the open file format described - in this document. The author hopes that providing this document to - the Internet community will help in promoting the Ogg multimedia - project at http://www.xiph.org/. Many thanks also for the many - technical and typo corrections that C. Montgomery and the Ogg - community provided as feedback to this RFC. - -Author's Address - - Silvia Pfeiffer - CSIRO, Australia - Locked Bag 17 - North Ryde, NSW 2113 - Australia - - Phone: +61 2 9325 3141 - EMail: Silvia.Pfeiffer@csiro.au - URI: http://www.cmis.csiro.au/Silvia.Pfeiffer/ - - - - - - - - - - - - - - - - - - - - - - - - - -Pfeiffer Informational [Page 14] - -RFC 3533 OGG May 2003 - - -Full Copyright Statement - - Copyright (C) The Internet Society (2003). All Rights Reserved. - - This document and translations of it may be copied and furnished to - others, and derivative works that comment on or otherwise explain it - or assist in its implementation may be prepared, copied, published - and distributed, in whole or in part, without restriction of any - kind, provided that the above copyright notice and this paragraph are - included on all such copies and derivative works. However, this - document itself may not be modified in any way, such as by removing - the copyright notice or references to the Internet Society or other - Internet organizations, except as needed for the purpose of - developing Internet standards in which case the procedures for - copyrights defined in the Internet Standards process must be - followed, or as required to translate it into languages other than - English. - - The limited permissions granted above are perpetual and will not be - revoked by the Internet Society or its successors or assigns. - - This document and the information contained herein is provided on an - "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING - TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -Acknowledgement - - Funding for the RFC Editor function is currently provided by the - Internet Society. - - - - - - - - - - - - - - - - - - - -Pfeiffer Informational [Page 15] - diff --git a/Engine/lib/libogg/doc/rfc3534.txt b/Engine/lib/libogg/doc/rfc3534.txt deleted file mode 100644 index 840f1ecc0..000000000 --- a/Engine/lib/libogg/doc/rfc3534.txt +++ /dev/null @@ -1,339 +0,0 @@ - - - - - - -Network Working Group L. Walleij -Request for Comments: 3534 The Ogg Vorbis Community -Category: Standards Track May 2003 - - - The application/ogg Media Type - -Status of this Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Copyright Notice - - Copyright (C) The Internet Society (2003). All Rights Reserved. - -Abstract - - The Ogg Bitstream Format aims at becoming a general, freely-available - standard for transporting multimedia content across computing - platforms and networks. The intention of this document is to define - the MIME media type application/ogg to refer to this kind of content - when transported across the Internet. It is the intention of the Ogg - Bitstream Format developers that it be usable without intellectual - property concerns. - -Conventions used in this Document - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this - document are to be interpreted as described in RFC 2119 [2]. - -1. The Ogg Bitstream Format - - The Ogg Bitstream format has been developed as a part of a larger - project aimed at creating a set of components for the coding and - decoding of multimedia content (codecs) which are to be freely - available and freely re-implementable both in software and in - hardware for the computing community at large, including the Internet - community. - - Raw packets from these codecs may be used directly by transport - mechanisms that provide their own framing and packet-separation - mechanisms (such as UDP datagrams). - - - - -Walleij Standards Track [Page 1] - -RFC 3534 The application/ogg Media Type May 2003 - - - One such framing and content-separation mechanism is the real-time - transport protocol (RTP). RTP allows the streaming of synchronous - lossy data for broadcasting and similar purposes. If this function - is desired then a separate RTP wrapping mechanism should be used. A - wrapping mechanism is currently under development. - - For stream based storage (such as files) and transport (such as TCP - streams or pipes), Ogg codecs use the Ogg Bitstream Format to provide - framing/sync, sync recapture after error, landmarks during seeking, - and enough information to properly separate data back into packets at - the original packet boundaries without relying on decoding to find - packet boundaries. The application/ogg MIME type refers to this kind - of bitstreams, when no further knowledge of the bitstream content - exists. - - The bitstream format in itself is documented in [1]. - -2. Registration Information - - To: ietf-types@iana.org - - Subject: Registration of MIME media type application/ogg - - MIME media type name: application - - MIME subtype name: ogg - - Required parameters: none - - Optional parameters: none - - Encoding Considerations: - - The Ogg bitstream format is binary data, and must be encoded for - non-binary transport; the Base64 encoding is suitable for Email. - Binary encoding could also be used. - - Security Considerations: - - As the Ogg bitstream file is a container format and only a carrier of - content (such as Vorbis audio) with a very rigid definition (see - [1]), this format in itself is not more vulnerable than any other - content framing mechanism. The main security consideration for the - receiving application is to ensure that manipulated packages can not - cause buffer overflows and the like. It is possible to encapsulate - even executable content in the bitstream, so for such uses additional - security considerations must be taken. - - - - -Walleij Standards Track [Page 2] - -RFC 3534 The application/ogg Media Type May 2003 - - - Ogg bitstream files are not signed or encrypted using any applicable - encryption schemes. External security mechanisms must be added if - content confidentiality and authenticity is to be achieved. - - Interoperability considerations: - - The Ogg bitstream format has proved to be widely implementable across - different computing platforms. A broadly portable reference - implementation is available under a BSD license. - - The Ogg bitstream format is not patented and can be implemented by - third parties without patent considerations. - - Published specification: - - See [1]. - - Applications which use this media type: - - Any application that implements the specification will be able to - encode or decode Ogg bitstream files. Specifically, the format is - supposed to be used by subcodecs that implement, for example, Vorbis - audio. - - Additional information: - - Magic number(s): - - In Ogg bitstream files, the first four bytes are 0x4f 0x67 0x67 0x53 - corresponding to the string "OggS". - - File extension: .ogg - - Macintosh File Type Code(s): OggS - - Object Identifier(s) or OID(s): none - - Person & email address to contact for further information: - - Questions about this proposal should be directed to Linus Walleij - . Technical questions about the Ogg bitstream - standard may be asked on the mailing lists for the developer - community. - - Intended usage: COMMON - - - - - - -Walleij Standards Track [Page 3] - -RFC 3534 The application/ogg Media Type May 2003 - - - Author/Change controller: - - This document was written by Linus Walleij . - Changes to this document will either be handled by him, a - representative of the Xiph.org, or the associated development - communities. - - The Ogg bitstream format is controlled by the Xiph.org and the - respective development communities. - -3. Security Considerations - - Security considerations are discussed in the security considerations - clause of the MIME registration in section 2. - -4. Normative References - - [1] Pfeiffer, S., "The Ogg encapsulation format version 0", RFC - 3533, May 2003. - - [2] Bradner, S., "Key words for use in RFCs to Indicate Requirement - Levels", BCP 14, RFC 2119, March 1997. - -5. Intellectual Property Statement - - The IETF takes no position regarding the validity or scope of any - intellectual property or other rights that might be claimed to - pertain to the implementation or use of the technology described in - this document or the extent to which any license under such rights - might or might not be available; neither does it represent that it - has made any effort to identify any such rights. Information on the - IETF's procedures with respect to rights in standards-track and - standards-related documentation can be found in BCP-11. Copies of - claims of rights made available for publication and any assurances of - licenses to be made available, or the result of an attempt made to - obtain a general license or permission for the use of such - proprietary rights by implementors or users of this specification can - be obtained from the IETF Secretariat. - - The IETF invites any interested party to bring to its attention any - copyrights, patents or patent applications, or other proprietary - rights which may cover technology that may be required to practice - this standard. Please address the information to the IETF Executive - Director. - - - - - - - -Walleij Standards Track [Page 4] - -RFC 3534 The application/ogg Media Type May 2003 - - -6. Author's Address - - Linus Walleij - The Ogg Vorbis Community - Master Olofs Vag 24 - Lund 224 66 - SE - - Phone: +46 703 193678 - EMail: triad@df.lth.se - URI: http://www.xiph.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Walleij Standards Track [Page 5] - -RFC 3534 The application/ogg Media Type May 2003 - - -7. Full Copyright Statement - - Copyright (C) The Internet Society (2003). All Rights Reserved. - - This document and translations of it may be copied and furnished to - others, and derivative works that comment on or otherwise explain it - or assist in its implementation may be prepared, copied, published - and distributed, in whole or in part, without restriction of any - kind, provided that the above copyright notice and this paragraph are - included on all such copies and derivative works. However, this - document itself may not be modified in any way, such as by removing - the copyright notice or references to the Internet Society or other - Internet organizations, except as needed for the purpose of - developing Internet standards in which case the procedures for - copyrights defined in the Internet Standards process must be - followed, or as required to translate it into languages other than - English. - - The limited permissions granted above are perpetual and will not be - revoked by the Internet Society or its successors or assigns. - - This document and the information contained herein is provided on an - "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING - TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -Acknowledgement - - Funding for the RFC Editor function is currently provided by the - Internet Society. - - - - - - - - - - - - - - - - - - - -Walleij Standards Track [Page 6] - diff --git a/Engine/lib/libogg/doc/rfc5334.txt b/Engine/lib/libogg/doc/rfc5334.txt deleted file mode 100644 index fea91fb14..000000000 --- a/Engine/lib/libogg/doc/rfc5334.txt +++ /dev/null @@ -1,787 +0,0 @@ - - - - - - -Network Working Group I. Goncalves -Request for Comments: 5334 S. Pfeiffer -Obsoletes: 3534 C. Montgomery -Category: Standards Track Xiph - September 2008 - - - Ogg Media Types - -Status of This Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Abstract - - This document describes the registration of media types for the Ogg - container format and conformance requirements for implementations of - these types. This document obsoletes RFC 3534. - -Table of Contents - - 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . 2 - 2. Changes Since RFC 3534 . . . . . . . . . . . . . . . . . . 2 - 3. Conformance and Document Conventions . . . . . . . . . . . 3 - 4. Deployed Media Types and Compatibility . . . . . . . . . . 3 - 5. Relation between the Media Types . . . . . . . . . . . . . 5 - 6. Encoding Considerations . . . . . . . . . . . . . . . . . . 5 - 7. Security Considerations . . . . . . . . . . . . . . . . . . 6 - 8. Interoperability Considerations . . . . . . . . . . . . . . 7 - 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . 7 - 10. Ogg Media Types . . . . . . . . . . . . . . . . . . . . . . 7 - 10.1. application/ogg . . . . . . . . . . . . . . . . . . . . . . 7 - 10.2. video/ogg . . . . . . . . . . . . . . . . . . . . . . . . . 8 - 10.3. audio/ogg . . . . . . . . . . . . . . . . . . . . . . . . . 9 - 11. Acknowledgements . . . . . . . . . . . . . . . . . . . . . 10 - 12. Copying Conditions . . . . . . . . . . . . . . . . . . . . 10 - 13. References . . . . . . . . . . . . . . . . . . . . . . . . 11 - 13.1. Normative References . . . . . . . . . . . . . . . . . . . 11 - 13.2. Informative References . . . . . . . . . . . . . . . . . . 11 - - - - - - - - -Goncalves, et al. Standards Track [Page 1] - -RFC 5334 Ogg Media Types September 2008 - - -1. Introduction - - This document describes media types for Ogg, a data encapsulation - format defined by the Xiph.Org Foundation for public use. Refer to - "Introduction" in [RFC3533] and "Overview" in [Ogg] for background - information on this container format. - - Binary data contained in Ogg, such as Vorbis and Theora, has - historically been interchanged using the application/ogg media type - as defined by [RFC3534]. This document obsoletes [RFC3534] and - defines three media types for different types of content in Ogg to - reflect this usage in the IANA media type registry, to foster - interoperability by defining underspecified aspects, and to provide - general security considerations. - - The Ogg container format is known to contain [Theora] or [Dirac] - video, [Speex] (narrow-band and wide-band) speech, [Vorbis] or [FLAC] - audio, and [CMML] timed text/metadata. As Ogg encapsulates binary - data, it is possible to include any other type of video, audio, - image, text, or, generally speaking, any time-continuously sampled - data. - - While raw packets from these data sources may be used directly by - transport mechanisms that provide their own framing and packet- - separation mechanisms (such as UDP datagrams or RTP), Ogg is a - solution for stream based storage (such as files) and transport (such - as TCP streams or pipes). The media types defined in this document - are needed to correctly identify such content when it is served over - HTTP, included in multi-part documents, or used in other places where - media types [RFC2045] are used. - -2. Changes Since RFC 3534 - - o The type "application/ogg" is redefined. - - o The types "video/ogg" and "audio/ogg" are defined. - - o New file extensions are defined. - - o New Macintosh file type codes are defined. - - o The codecs parameter is defined for optional use. - - o The Ogg Skeleton extension becomes a recommended addition for - content served under the new types. - - - - - - -Goncalves, et al. Standards Track [Page 2] - -RFC 5334 Ogg Media Types September 2008 - - -3. Conformance and Document Conventions - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this - document are to be interpreted as described in BCP 14, [RFC2119] and - indicate requirement levels for compliant implementations. - Requirements apply to all implementations unless otherwise stated. - - An implementation is a software module that supports one of the media - types defined in this document. Software modules may support - multiple media types, but conformance is considered individually for - each type. - - Implementations that fail to satisfy one or more "MUST" requirements - are considered non-compliant. Implementations that satisfy all - "MUST" requirements, but fail to satisfy one or more "SHOULD" - requirements, are said to be "conditionally compliant". All other - implementations are "unconditionally compliant". - -4. Deployed Media Types and Compatibility - - The application/ogg media type has been used in an ad hoc fashion to - label and exchange multimedia content in Ogg containers. - - Use of the "application" top-level type for this kind of content is - known to be problematic, in particular since it obfuscates video and - audio content. This document thus defines the media types, - - o video/ogg - - o audio/ogg - - which are intended for common use and SHOULD be used when dealing - with video or audio content, respectively. This document also - obsoletes the [RFC3534] definition of application/ogg and marks it - for complex data (e.g., multitrack visual, audio, textual, and other - time-continuously sampled data), which is not clearly video or audio - data and thus not suited for either the video/ogg or audio/ogg types. - Refer to the following section for more details. - - An Ogg bitstream generally consists of one or more logical bitstreams - that each consist of a series of header and data pages packetising - time-continuous binary data [RFC3533]. The content types of the - logical bitstreams may be identified without decoding the header - pages of the logical bitstreams through use of a [Skeleton] - bitstream. Using Ogg Skeleton is REQUIRED for content served under - - - - - -Goncalves, et al. Standards Track [Page 3] - -RFC 5334 Ogg Media Types September 2008 - - - the application/ogg type and RECOMMENDED for video/ogg and audio/ogg, - as Skeleton contains identifiers to describe the different - encapsulated data. - - Furthermore, it is RECOMMENDED that implementations that identify a - logical bitstream that they cannot decode SHOULD ignore it, while - continuing to decode the ones they can. Such precaution ensures - backward and forward compatibility with existing and future data. - - These media types can optionally use the "codecs" parameter described - in [RFC4281]. Codecs encapsulated in Ogg require a text identifier - at the beginning of the first header page, hence a machine-readable - method to identify the encapsulated codecs would be through this - header. The following table illustrates how those header values map - into strings that are used in the "codecs" parameter when dealing - with Ogg media types. - - Codec Identifier | Codecs Parameter - ----------------------------------------------------------- - char[5]: 'BBCD\0' | dirac - char[5]: '\177FLAC' | flac - char[7]: '\x80theora' | theora - char[7]: '\x01vorbis' | vorbis - char[8]: 'CELT ' | celt - char[8]: 'CMML\0\0\0\0' | cmml - char[8]: '\213JNG\r\n\032\n' | jng - char[8]: '\x80kate\0\0\0' | kate - char[8]: 'OggMIDI\0' | midi - char[8]: '\212MNG\r\n\032\n' | mng - char[8]: 'PCM ' | pcm - char[8]: '\211PNG\r\n\032\n' | png - char[8]: 'Speex ' | speex - char[8]: 'YUV4MPEG' | yuv4mpeg - - An up-to-date version of this table is kept at Xiph.org (see - [Codecs]). - - Possible examples include: - - o application/ogg; codecs="theora, cmml, ecmascript" - - o video/ogg; codecs="theora, vorbis" - - o audio/ogg; codecs=speex - - - - - - - -Goncalves, et al. Standards Track [Page 4] - -RFC 5334 Ogg Media Types September 2008 - - -5. Relation between the Media Types - - As stated in the previous section, this document describes three - media types that are targeted at different data encapsulated in Ogg. - Since Ogg is capable of encapsulating any kind of data, the multiple - usage scenarios have revealed interoperability issues between - implementations when dealing with content served solely under the - application/ogg type. - - While this document does redefine the earlier definition of - application/ogg, this media type will continue to embrace the widest - net possible of content with the video/ogg and audio/ogg types being - smaller subsets of it. However, the video/ogg and audio/ogg types - take precedence in a subset of the usages, specifically when serving - multimedia content that is not complex enough to warrant the use of - application/ogg. Following this line of thought, the audio/ogg type - is an even smaller subset within video/ogg, as it is not intended to - refer to visual content. - - As such, the application/ogg type is the recommended choice to serve - content aimed at scientific and other applications that require - various multiplexed signals or streams of continuous data, with or - without scriptable control of content. For bitstreams containing - visual, timed text, and any other type of material that requires a - visual interface, but that is not complex enough to warrant serving - under application/ogg, the video/ogg type is recommended. In - situations where the Ogg bitstream predominantly contains audio data - (lyrics, metadata, or cover art notwithstanding), it is recommended - to use the audio/ogg type. - -6. Encoding Considerations - - Binary: The content consists of an unrestricted sequence of octets. - - Note: - - o Ogg encapsulated content is binary data and should be transmitted - in a suitable encoding without CR/LF conversion, 7-bit stripping, - etc.; base64 [RFC4648] is generally preferred for binary-to-text - encoding. - - o Media types described in this document are used for stream based - storage (such as files) and transport (such as TCP streams or - pipes); separate types are used to identify codecs such as in - real-time applications for the RTP payload formats of Theora - [ThRTP] video, Vorbis [RFC5215], or Speex [SpRTP] audio, as well - as for identification of encapsulated data within Ogg through - Skeleton. - - - -Goncalves, et al. Standards Track [Page 5] - -RFC 5334 Ogg Media Types September 2008 - - -7. Security Considerations - - Refer to [RFC3552] for a discussion of terminology used in this - section. - - The Ogg encapsulation format is a container and only a carrier of - content (such as audio, video, and displayable text data) with a very - rigid definition. This format in itself is not more vulnerable than - any other content framing mechanism. - - Ogg does not provide for any generic encryption or signing of itself - or its contained bitstreams. However, it encapsulates any kind of - binary content and is thus able to contain encrypted and signed - content data. It is also possible to add an external security - mechanism that encrypts or signs an Ogg bitstream and thus provides - content confidentiality and authenticity. - - As Ogg encapsulates binary data, it is possible to include executable - content in an Ogg bitstream. Implementations SHOULD NOT execute such - content without prior validation of its origin by the end-user. - - Issues may arise on applications that use Ogg for streaming or file - transfer in a networking scenario. In such cases, implementations - decoding Ogg and its encapsulated bitstreams have to ensure correct - handling of manipulated bitstreams, of buffer overflows, and similar - issues. - - It is also possible to author malicious Ogg bitstreams, which attempt - to call for an excessively large picture size, high sampling-rate - audio, etc. Implementations SHOULD protect themselves against this - kind of attack. - - Ogg has an extensible structure, so that it is theoretically possible - that metadata fields or media formats might be defined in the future - which might be used to induce particular actions on the part of the - recipient, thus presenting additional security risks. However, this - type of capability is currently not supported in the referenced - specification. - - Implementations may fail to implement a specific security model or - other means to prevent possibly dangerous operations. Such failure - might possibly be exploited to gain unauthorized access to a system - or sensitive information; such failure constitutes an unknown factor - and is thus considered out of the scope of this document. - - - - - - - -Goncalves, et al. Standards Track [Page 6] - -RFC 5334 Ogg Media Types September 2008 - - -8. Interoperability Considerations - - The Ogg container format is device-, platform-, and vendor-neutral - and has proved to be widely implementable across different computing - platforms through a wide range of encoders and decoders. A broadly - portable reference implementation [libogg] is available under the - revised (3-clause) BSD license, which is a Free Software license. - - The Xiph.Org Foundation has defined the specification, - interoperability, and conformance and conducts regular - interoperability testing. - - The use of the Ogg Skeleton extension has been confirmed to not cause - interoperability issues with existing implementations. Third parties - are, however, welcome to conduct their own testing. - -9. IANA Considerations - - In accordance with the procedures set forth in [RFC4288], this - document registers two new media types and redefines the existing - application/ogg as defined in the following section. - -10. Ogg Media Types - -10.1. application/ogg - - Type name: application - - Subtype name: ogg - - Required parameters: none - - Optional parameters: codecs, whose syntax is defined in RFC 4281. - See section 4 of RFC 5334 for a list of allowed values. - - Encoding considerations: See section 6 of RFC 5334. - - Security considerations: See section 7 of RFC 5334. - - Interoperability considerations: None, as noted in section 8 of RFC - 5334. - - Published specification: RFC 3533 - - Applications which use this media type: Scientific and otherwise that - require various multiplexed signals or streams of data, with or - without scriptable control of content. - - - - -Goncalves, et al. Standards Track [Page 7] - -RFC 5334 Ogg Media Types September 2008 - - - Additional information: - - Magic number(s): The first four bytes, 0x4f 0x67 0x67 0x53, - correspond to the string "OggS". - - File extension(s): .ogx - - RFC 3534 defined the file extension .ogg for application/ogg, - which RFC 5334 obsoletes in favor of .ogx due to concerns where, - historically, some implementations expect .ogg files to be solely - Vorbis-encoded audio. - - Macintosh File Type Code(s): OggX - - Person & Email address to contact for further information: See - "Authors' Addresses" section. - - Intended usage: COMMON - - Restrictions on usage: The type application/ogg SHOULD only be used - in situations where it is not appropriate to serve data under the - video/ogg or audio/ogg types. Data served under the application/ogg - type SHOULD use the .ogx file extension and MUST contain an Ogg - Skeleton logical bitstream to identify all other contained logical - bitstreams. - - Author: See "Authors' Addresses" section. - - Change controller: The Xiph.Org Foundation. - -10.2. video/ogg - - Type name: video - - Subtype name: ogg - - Required parameters: none - - Optional parameters: codecs, whose syntax is defined in RFC 4281. - See section 4 of RFC 5334 for a list of allowed values. - - Encoding considerations: See section 6 of RFC 5334. - - Security considerations: See section 7 of RFC 5334. - - Interoperability considerations: None, as noted in section 8 of RFC - 5334. - - - - -Goncalves, et al. Standards Track [Page 8] - -RFC 5334 Ogg Media Types September 2008 - - - Published specification: RFC 3533 - - Applications which use this media type: Multimedia applications, - including embedded, streaming, and conferencing tools. - - Additional information: - - Magic number(s): The first four bytes, 0x4f 0x67 0x67 0x53, - correspond to the string "OggS". - - File extension(s): .ogv - - Macintosh File Type Code(s): OggV - - Person & Email address to contact for further information: See - "Authors' Addresses" section. - - Intended usage: COMMON - - Restrictions on usage: The type "video/ogg" SHOULD be used for Ogg - bitstreams containing visual, audio, timed text, or any other type of - material that requires a visual interface. It is intended for - content not complex enough to warrant serving under "application/ - ogg"; for example, a combination of Theora video, Vorbis audio, - Skeleton metadata, and CMML captioning. Data served under the type - "video/ogg" SHOULD contain an Ogg Skeleton logical bitstream. - Implementations interacting with the type "video/ogg" SHOULD support - multiplexed bitstreams. - - Author: See "Authors' Addresses" section. - - Change controller: The Xiph.Org Foundation. - -10.3. audio/ogg - - Type name: audio - - Subtype name: ogg - - Required parameters: none - - Optional parameters: codecs, whose syntax is defined in RFC 4281. - See section 4 of RFC 5334 for a list of allowed values. - - Encoding considerations: See section 6 of RFC 5334. - - Security considerations: See section 7 of RFC 5334. - - - - -Goncalves, et al. Standards Track [Page 9] - -RFC 5334 Ogg Media Types September 2008 - - - Interoperability considerations: None, as noted in section 8 of RFC - 5334. - - Published specification: RFC 3533 - - Applications which use this media type: Multimedia applications, - including embedded, streaming, and conferencing tools. - - Additional information: - - Magic number(s): The first four bytes, 0x4f 0x67 0x67 0x53, - correspond to the string "OggS". - - File extension(s): .oga, .ogg, .spx - - Macintosh File Type Code(s): OggA - - Person & Email address to contact for further information: See - "Authors' Addresses" section. - - Intended usage: COMMON - - Restrictions on usage: The type "audio/ogg" SHOULD be used when the - Ogg bitstream predominantly contains audio data. Content served - under the "audio/ogg" type SHOULD have an Ogg Skeleton logical - bitstream when using the default .oga file extension. The .ogg and - .spx file extensions indicate a specialization that requires no - Skeleton due to backward compatibility concerns with existing - implementations. In particular, .ogg is used for Ogg files that - contain only a Vorbis bitstream, while .spx is used for Ogg files - that contain only a Speex bitstream. - - Author: See "Authors' Addresses" section. - - Change controller: The Xiph.Org Foundation. - -11. Acknowledgements - - The authors gratefully acknowledge the contributions of Magnus - Westerlund, Alfred Hoenes, and Peter Saint-Andre. - -12. Copying Conditions - - The authors agree to grant third parties the irrevocable right to - copy, use and distribute the work, with or without modification, in - any medium, without royalty, provided that, unless separate - permission is granted, redistributed modified works do not contain - misleading author, version, name of work, or endorsement information. - - - -Goncalves, et al. Standards Track [Page 10] - -RFC 5334 Ogg Media Types September 2008 - - -13. References - -13.1. Normative References - - [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail - Extensions (MIME) Part One: Format of Internet Message - Bodies", RFC 2045, November 1996. - - [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate - Requirement Levels", BCP 14, RFC 2119, March 1997. - - [RFC3533] Pfeiffer, S., "The Ogg Encapsulation Format Version 0", - RFC 3533, May 2003. - - [RFC4281] Gellens, R., Singer, D., and P. Frojdh, "The Codecs - Parameter for "Bucket" Media Types", RFC 4281, - November 2005. - - [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and - Registration Procedures", BCP 13, RFC 4288, - December 2005. - -13.2. Informative References - - [CMML] Pfeiffer, S., Parker, C., and A. Pang, "The Continuous - Media Markup Language (CMML)", Work in Progress, - March 2006. - - [Codecs] Pfeiffer, S. and I. Goncalves, "Specification of MIME - types and respective codecs parameter", July 2008, - . - - [Dirac] Dirac Group, "Dirac Specification", - . - - [FLAC] Coalson, J., "The FLAC Format", - . - - [libogg] Xiph.Org Foundation, "The libogg API", June 2000, - . - - [Ogg] Xiph.Org Foundation, "Ogg bitstream documentation: Ogg - logical and physical bitstream overview, Ogg logical - bitstream framing, Ogg multi-stream multiplexing", - . - - [RFC3534] Walleij, L., "The application/ogg Media Type", RFC 3534, - May 2003. - - - -Goncalves, et al. Standards Track [Page 11] - -RFC 5334 Ogg Media Types September 2008 - - - [RFC3552] Rescorla, E. and B. Korver, "Guidelines for Writing RFC - Text on Security Considerations", BCP 72, RFC 3552, - July 2003. - - [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data - Encodings", RFC 4648, October 2006. - - [RFC5215] Barbato, L., "RTP Payload Format for Vorbis Encoded - Audio", RFC 5215, August 2008. - - [Skeleton] Pfeiffer, S. and C. Parker, "The Ogg Skeleton Metadata - Bitstream", November 2007, - . - - [Speex] Valin, J., "The Speex Codec Manual", February 2002, - . - - [SpRTP] Herlein, G., Valin, J., Heggestad, A., and A. Moizard, - "RTP Payload Format for the Speex Codec", Work - in Progress, February 2008. - - [Theora] Xiph.Org Foundation, "Theora Specification", - October 2007, . - - [ThRTP] Barbato, L., "RTP Payload Format for Theora Encoded - Video", Work in Progress, June 2006. - - [Vorbis] Xiph.Org Foundation, "Vorbis I Specification", July 2004, - . - - - - - - - - - - - - - - - - - - - - - - -Goncalves, et al. Standards Track [Page 12] - -RFC 5334 Ogg Media Types September 2008 - - -Authors' Addresses - - Ivo Emanuel Goncalves - Xiph.Org Foundation - 21 College Hill Road - Somerville, MA 02144 - US - - EMail: justivo@gmail.com - URI: xmpp:justivo@gmail.com - - - Silvia Pfeiffer - Xiph.Org Foundation - - EMail: silvia@annodex.net - URI: http://annodex.net/ - - - Christopher Montgomery - Xiph.Org Foundation - - EMail: monty@xiph.org - URI: http://xiph.org - - - - - - - - - - - - - - - - - - - - - - - - - - - -Goncalves, et al. Standards Track [Page 13] - -RFC 5334 Ogg Media Types September 2008 - - -Full Copyright Statement - - Copyright (C) The IETF Trust (2008). - - This document is subject to the rights, licenses and restrictions - contained in BCP 78, and except as set forth therein, the authors - retain all their rights. - - This document and the information contained herein are provided on an - "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS - OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND - THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF - THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED - WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -Intellectual Property - - The IETF takes no position regarding the validity or scope of any - Intellectual Property Rights or other rights that might be claimed to - pertain to the implementation or use of the technology described in - this document or the extent to which any license under such rights - might or might not be available; nor does it represent that it has - made any independent effort to identify any such rights. Information - on the procedures with respect to rights in RFC documents can be - found in BCP 78 and BCP 79. - - Copies of IPR disclosures made to the IETF Secretariat and any - assurances of licenses to be made available, or the result of an - attempt made to obtain a general license or permission for the use of - such proprietary rights by implementers or users of this - specification can be obtained from the IETF on-line IPR repository at - http://www.ietf.org/ipr. - - The IETF invites any interested party to bring to its attention any - copyrights, patents or patent applications, or other proprietary - rights that may cover technology that may be required to implement - this standard. Please address the information to the IETF at - ietf-ipr@ietf.org. - - - - - - - - - - - - -Goncalves, et al. Standards Track [Page 14] - diff --git a/Engine/lib/libogg/doc/skeleton.html b/Engine/lib/libogg/doc/skeleton.html deleted file mode 100644 index 8b29c18af..000000000 --- a/Engine/lib/libogg/doc/skeleton.html +++ /dev/null @@ -1,222 +0,0 @@ - - - - - -The Ogg Skeleton Metadata Bitstream - - - - - - - - - -

    The Ogg Skeleton Metadata Bitstream

    - -

    Overview

    - -

    Ogg Skeleton provides structuring information for multitrack Ogg files. It is compatible with Ogg Theora and provides extra clues for synchronization and content negotiation such as language selection.

    - -

    Ogg is a generic container format for time-continuous data streams, enabling interleaving of several tracks of frame-wise encoded content in a time-multiplexed manner. As an example, an Ogg physical bitstream could encapsulate several tracks of video encoded in Theora and multiple tracks of audio encoded in Speex or Vorbis or FLAC at the same time. A player that decodes such a bitstream could then, for example, play one video channel as the main video playback, alpha-blend another one on top of it (e.g. a caption track), play a main Vorbis audio together with several FLAC audio tracks simultaneously (e.g. as sound effects), and provide a choice of Speex channels (e.g. providing commentary in different languages). Such a file is generally possible to create with Ogg, it is however not possible to generically parse such a file, seek on it, understand what codecs are contained in such a file, and dynamically handle and play back such content.

    - -

    Ogg does not know anything about the content it carries and leaves it to the media mapping of each codec to declare and describe itself. There is no meta information available at the Ogg level about the content tracks encapsulated within an Ogg physical bitstream. This is particularly a problem if you don't have all the decoder libraries available and just want to parse an Ogg file to find out what type of data it encapsulates (such as the "file" command under *nix to determine what file it is through magic numbers), or want to seek to a temporal offset without having to decode the data (such as on a Web server that just serves out Ogg files and parts thereof).

    - -

    Ogg Skeleton is being designed to overcome these problems. Ogg Skeleton is a logical bitstream within an Ogg stream that contains information about the other encapsulated logical bitstreams. For each logical bitstream it provides information such as its media type, and explains the way the granulepos field in Ogg pages is mapped to time.

    - -

    Ogg Skeleton is also designed to allow the creation of substreams from Ogg physical bitstreams that retain the original timing information. For example, when cutting out the segment between the 7th and the 59th second of an Ogg file, it would be nice to continue to start this cut out file with a playback time of 7 seconds and not of 0. This is of particular interest if you're streaming this file from a Web server after a query for a temporal subpart such as in http://example.com/video.ogv?t=7-59

    - -

    Specification

    - -

    How to describe the logical bitstreams within an Ogg container?

    - -

    The following information about a logical bitstream is of interest to contain as meta information in the Skeleton:

    -
      -
    • the serial number: it identifies a content track
    • -
    • the mime type: it identifies the content type
    • -
    • other generic name-value fields that can provide meta information such as the language of a track or the video height and width
    • -
    • the number of header packets: this informs a parser about the number of actual header packets in an Ogg logical bitstream
    • -
    • the granule rate: the granule rate represents the data rate in Hz at which content is sampled for the particular logical bitstream, allowing to map a granule position to time by calculating "granulepos / granulerate"
    • -
    • the preroll: the number of past content packets to take into account when decoding the current Ogg page, which is necessary for seeking (vorbis has generally 2, speex 3)
    • -
    • the granuleshift: the number of lower bits from the granulepos field that are used to provide position information for sub-seekable units (like the keyframe shift in theora)
    • -
    • a basetime: it provides a mapping for granule position 0 (for all logical bitstreams) to a playback time; an example use: most content in professional analog video creation actually starts at a time of 1 hour and thus adding this additional field allows them retain this mapping on digitizing their content
    • -
    • a UTC time: it provides a mapping for granule position 0 (for all logical bitstreams) to a real-world clock time allowing to remember e.g. the recording or broadcast time of some content
    • -
    - -

    How to allow the creation of substreams from an Ogg physical bitstream?

    - -

    When cutting out a subpart of an Ogg physical bitstream, the aim is to keep all the content pages intact (including the framing and granule positions) and just change some information in the Skeleton that allows reconstruction of the accurate time mapping. When remultiplexing such a bitstream, it is necessary to take into account all the different contained logical bitstreams. A given cut-in time maps to several different byte positions in the Ogg physical bitstream because each logical bitstream has its relevant information for that time at a different location. In addition, the resolution of each logical bitstream may not be high enough to accommodate for the given cut-in time and thus there may be some surplus information necessary to be remuxed into the new bitstream.

    - -

    The following information is necessary to be added to the Skeleton to allow a correct presentation of a subpart of an Ogg bitstream:

    -
      -
    • the presentation time: this is the actual cut-in time and all logical bitstreams are meant to start presenting from this time onwards, not from the time their data starts, which may be some time before that (because this time may have mapped right into the middle of a packet, or because the logical bitstream has a preroll or a keyframe shift)
    • -
    • the basegranule: this represents the granule number with which this logical bitstream starts in the remuxed stream and provides for each logical bitstream the accurate start time of its data stream; this information is necessary to allow correct decoding and timing of the first data packets contained in a logcial bitstream of a remuxed Ogg stream
    • -
    - -

    Ogg Skeleton version 3.0 Format Specification

    - -

    Adding the above information into an Ogg bitstream without breaking existing Ogg functionality and code requires the use of a logical bitstream for Ogg Skeleton. This logical bitstream may be ignored on decoding such that existing players can still continue to play back Ogg files that have a Skeleton bitstream. Skeleton enriches the Ogg bitstream to provide meta information about structure and content of the Ogg bitstream.

    - -

    The Skeleton logical bitstream starts with an ident header that contains information about all of the logical bitstreams and is mapped into the Skeleton bos page. The first 8 bytes provide the magic identifier "fishead\0". -After the fishead follows a set of secondary header packets, each of which contains information about one logical bitstream. These secondary header packets are identified by an 8 byte code of "fisbone\0". The Skeleton logical bitstream has no actual content packets. Its eos page is included into the stream before any data pages of the other logical bitstreams appear and contains a packet of length 0.

    - -

    The fishead ident header looks as follows:

    -
    -
    -  0                   1                   2                   3
    -  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Identifier 'fishead\0'                                        | 0-3
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 4-7
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Version major                 | Version minor                 | 8-11
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Presentationtime numerator                                    | 12-15
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 16-19
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Presentationtime denominator                                  | 20-23
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 24-27
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Basetime numerator                                            | 28-31
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 32-35
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Basetime denominator                                          | 36-39
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 40-43
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | UTC                                                           | 44-47
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 48-51
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 52-55
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 56-59
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 60-63
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    -
    -
    -

    The version fields provide version information for the Skeleton track, currently being 3.0 (the number having evolved within the Annodex project).

    - -

    Presentation time and basetime are specified as a rational number, the denominator providing the temporal resolution at which the time is given (e.g. to specify time in milliseconds, provide a denominator of 1000).

    - -

    The fisbone secondary header packet looks as follows:

    -
    -
    -  0                   1                   2                   3
    -  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Identifier 'fisbone\0'                                        | 0-3
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 4-7
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Offset to message header fields                               | 8-11
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Serial number                                                 | 12-15
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Number of header packets                                      | 16-19
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Granulerate numerator                                         | 20-23
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 24-27
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Granulerate denominator                                       | 28-31
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 32-35
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Basegranule                                                   | 36-39
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - |                                                               | 40-43
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Preroll                                                       | 44-47
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Granuleshift  | Padding/future use                            | 48-51
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    - | Message header fields ...                                     | 52-
    - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    -
    -
    -

    The mime type is provided as a message header field specified in the same way that HTTP header fields are given (e.g. "Content-Type: audio/vorbis"). Further meta information (such as language and screen size) are also included as message header fields. The offset to the message header fields at the beginning of a fisbone packet is included for forward compatibility - to allow further fields to be included into the packet without disrupting the message header field parsing.

    - -

    The granule rate is again given as a rational number in the same way that presentation time and basetime were provided above.

    - -

    A further restriction on how to encapsulate Skeleton into Ogg is proposed to allow for easier parsing:

    -
      -
    • there can only be one Skeleton logical bitstream in a Ogg bitstream
    • -
    • the Skeleton bos page is the very first bos page in the Ogg stream such that it can be identified straight away and decoders don't get confused about it being e.g. Ogg Vorbis without this meta information
    • -
    • the bos pages of all the other logical bistreams come next (a requirement of Ogg)
    • -
    • the secondary header pages of all logical bitstreams come next, including Skeleton's secondary header packets
    • -
    • the Skeleton eos page end the control section of the Ogg stream before any content pages of any of the other logical bitstreams appear
    • -
    - - - - - \ No newline at end of file diff --git a/Engine/lib/libogg/doc/stream.png b/Engine/lib/libogg/doc/stream.png deleted file mode 100644 index ce2d2da67..000000000 Binary files a/Engine/lib/libogg/doc/stream.png and /dev/null differ diff --git a/Engine/lib/libogg/doc/vorbisword2.png b/Engine/lib/libogg/doc/vorbisword2.png deleted file mode 100644 index 12e3d3162..000000000 Binary files a/Engine/lib/libogg/doc/vorbisword2.png and /dev/null differ diff --git a/Engine/lib/libogg/doc/white-ogg.png b/Engine/lib/libogg/doc/white-ogg.png deleted file mode 100644 index 2694296b2..000000000 Binary files a/Engine/lib/libogg/doc/white-ogg.png and /dev/null differ diff --git a/Engine/lib/libogg/doc/white-xifish.png b/Engine/lib/libogg/doc/white-xifish.png deleted file mode 100644 index ab25cc8f9..000000000 Binary files a/Engine/lib/libogg/doc/white-xifish.png and /dev/null differ diff --git a/Engine/lib/libogg/include/Makefile.am b/Engine/lib/libogg/include/Makefile.am deleted file mode 100644 index 0084e4d82..000000000 --- a/Engine/lib/libogg/include/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = ogg diff --git a/Engine/lib/libogg/include/ogg/Makefile.am b/Engine/lib/libogg/include/ogg/Makefile.am deleted file mode 100644 index 142699d35..000000000 --- a/Engine/lib/libogg/include/ogg/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -## Process this file with automake to produce Makefile.in - -oggincludedir = $(includedir)/ogg - -ogginclude_HEADERS = ogg.h os_types.h -nodist_ogginclude_HEADERS = config_types.h diff --git a/Engine/lib/libogg/include/ogg/config_types.h.in b/Engine/lib/libogg/include/ogg/config_types.h.in deleted file mode 100644 index 898c3f13b..000000000 --- a/Engine/lib/libogg/include/ogg/config_types.h.in +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __CONFIG_TYPES_H__ -#define __CONFIG_TYPES_H__ - -/* these are filled in by configure or cmake*/ -#define INCLUDE_INTTYPES_H @INCLUDE_INTTYPES_H@ -#define INCLUDE_STDINT_H @INCLUDE_STDINT_H@ -#define INCLUDE_SYS_TYPES_H @INCLUDE_SYS_TYPES_H@ - -#if INCLUDE_INTTYPES_H -# include -#endif -#if INCLUDE_STDINT_H -# include -#endif -#if INCLUDE_SYS_TYPES_H -# include -#endif - -typedef @SIZE16@ ogg_int16_t; -typedef @USIZE16@ ogg_uint16_t; -typedef @SIZE32@ ogg_int32_t; -typedef @USIZE32@ ogg_uint32_t; -typedef @SIZE64@ ogg_int64_t; -typedef @USIZE64@ ogg_uint64_t; - -#endif diff --git a/Engine/lib/libogg/include/ogg/ogg.h b/Engine/lib/libogg/include/ogg/ogg.h deleted file mode 100644 index c4325aa76..000000000 --- a/Engine/lib/libogg/include/ogg/ogg.h +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: toplevel libogg include - - ********************************************************************/ -#ifndef _OGG_H -#define _OGG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -typedef struct { - void *iov_base; - size_t iov_len; -} ogg_iovec_t; - -typedef struct { - long endbyte; - int endbit; - - unsigned char *buffer; - unsigned char *ptr; - long storage; -} oggpack_buffer; - -/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ - -typedef struct { - unsigned char *header; - long header_len; - unsigned char *body; - long body_len; -} ogg_page; - -/* ogg_stream_state contains the current encode/decode state of a logical - Ogg bitstream **********************************************************/ - -typedef struct { - unsigned char *body_data; /* bytes from packet bodies */ - long body_storage; /* storage elements allocated */ - long body_fill; /* elements stored; fill mark */ - long body_returned; /* elements of fill returned */ - - - int *lacing_vals; /* The values that will go to the segment table */ - ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact - this way, but it is simple coupled to the - lacing fifo */ - long lacing_storage; - long lacing_fill; - long lacing_packet; - long lacing_returned; - - unsigned char header[282]; /* working space for header encode */ - int header_fill; - - int e_o_s; /* set when we have buffered the last packet in the - logical bitstream */ - int b_o_s; /* set after we've written the initial page - of a logical bitstream */ - long serialno; - long pageno; - ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a separate abstraction - layer) also knows about the gap */ - ogg_int64_t granulepos; - -} ogg_stream_state; - -/* ogg_packet is used to encapsulate the data and metadata belonging - to a single raw Ogg/Vorbis packet *************************************/ - -typedef struct { - unsigned char *packet; - long bytes; - long b_o_s; - long e_o_s; - - ogg_int64_t granulepos; - - ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a separate abstraction - layer) also knows about the gap */ -} ogg_packet; - -typedef struct { - unsigned char *data; - int storage; - int fill; - int returned; - - int unsynced; - int headerbytes; - int bodybytes; -} ogg_sync_state; - -/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ - -extern void oggpack_writeinit(oggpack_buffer *b); -extern int oggpack_writecheck(oggpack_buffer *b); -extern void oggpack_writetrunc(oggpack_buffer *b,long bits); -extern void oggpack_writealign(oggpack_buffer *b); -extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpack_reset(oggpack_buffer *b); -extern void oggpack_writeclear(oggpack_buffer *b); -extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpack_look(oggpack_buffer *b,int bits); -extern long oggpack_look1(oggpack_buffer *b); -extern void oggpack_adv(oggpack_buffer *b,int bits); -extern void oggpack_adv1(oggpack_buffer *b); -extern long oggpack_read(oggpack_buffer *b,int bits); -extern long oggpack_read1(oggpack_buffer *b); -extern long oggpack_bytes(oggpack_buffer *b); -extern long oggpack_bits(oggpack_buffer *b); -extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); - -extern void oggpackB_writeinit(oggpack_buffer *b); -extern int oggpackB_writecheck(oggpack_buffer *b); -extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); -extern void oggpackB_writealign(oggpack_buffer *b); -extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpackB_reset(oggpack_buffer *b); -extern void oggpackB_writeclear(oggpack_buffer *b); -extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpackB_look(oggpack_buffer *b,int bits); -extern long oggpackB_look1(oggpack_buffer *b); -extern void oggpackB_adv(oggpack_buffer *b,int bits); -extern void oggpackB_adv1(oggpack_buffer *b); -extern long oggpackB_read(oggpack_buffer *b,int bits); -extern long oggpackB_read1(oggpack_buffer *b); -extern long oggpackB_bytes(oggpack_buffer *b); -extern long oggpackB_bits(oggpack_buffer *b); -extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); - -/* Ogg BITSTREAM PRIMITIVES: encoding **************************/ - -extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); -extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, - int count, long e_o_s, ogg_int64_t granulepos); -extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill); -extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_flush_fill(ogg_stream_state *os, ogg_page *og, int nfill); - -/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ - -extern int ogg_sync_init(ogg_sync_state *oy); -extern int ogg_sync_clear(ogg_sync_state *oy); -extern int ogg_sync_reset(ogg_sync_state *oy); -extern int ogg_sync_destroy(ogg_sync_state *oy); -extern int ogg_sync_check(ogg_sync_state *oy); - -extern char *ogg_sync_buffer(ogg_sync_state *oy, long size); -extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes); -extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og); -extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); -extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); -extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op); - -/* Ogg BITSTREAM PRIMITIVES: general ***************************/ - -extern int ogg_stream_init(ogg_stream_state *os,int serialno); -extern int ogg_stream_clear(ogg_stream_state *os); -extern int ogg_stream_reset(ogg_stream_state *os); -extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno); -extern int ogg_stream_destroy(ogg_stream_state *os); -extern int ogg_stream_check(ogg_stream_state *os); -extern int ogg_stream_eos(ogg_stream_state *os); - -extern void ogg_page_checksum_set(ogg_page *og); - -extern int ogg_page_version(const ogg_page *og); -extern int ogg_page_continued(const ogg_page *og); -extern int ogg_page_bos(const ogg_page *og); -extern int ogg_page_eos(const ogg_page *og); -extern ogg_int64_t ogg_page_granulepos(const ogg_page *og); -extern int ogg_page_serialno(const ogg_page *og); -extern long ogg_page_pageno(const ogg_page *og); -extern int ogg_page_packets(const ogg_page *og); - -extern void ogg_packet_clear(ogg_packet *op); - - -#ifdef __cplusplus -} -#endif - -#endif /* _OGG_H */ diff --git a/Engine/lib/libogg/include/ogg/os_types.h b/Engine/lib/libogg/include/ogg/os_types.h deleted file mode 100644 index e655a1d62..000000000 --- a/Engine/lib/libogg/include/ogg/os_types.h +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: Define a consistent set of types on each platform. - - ********************************************************************/ -#ifndef _OS_TYPES_H -#define _OS_TYPES_H - -/* make it easy on the folks that want to compile the libs with a - different malloc than stdlib */ -#define _ogg_malloc malloc -#define _ogg_calloc calloc -#define _ogg_realloc realloc -#define _ogg_free free - -#if defined(_WIN32) - -# if defined(__CYGWIN__) -# include - typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - typedef uint64_t ogg_uint64_t; -# elif defined(__MINGW32__) -# include - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; -# elif defined(__MWERKS__) - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; -# else -# if defined(_MSC_VER) && (_MSC_VER >= 1800) /* MSVC 2013 and newer */ -# include - typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - typedef uint64_t ogg_uint64_t; -# else - /* MSVC/Borland */ - typedef __int64 ogg_int64_t; - typedef __int32 ogg_int32_t; - typedef unsigned __int32 ogg_uint32_t; - typedef unsigned __int64 ogg_uint64_t; - typedef __int16 ogg_int16_t; - typedef unsigned __int16 ogg_uint16_t; -# endif -# endif - -#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ - -# include - typedef int16_t ogg_int16_t; - typedef u_int16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef u_int32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - typedef u_int64_t ogg_uint64_t; - -#elif defined(__HAIKU__) - - /* Haiku */ -# include - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; - -#elif defined(__BEOS__) - - /* Be */ -# include - typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - typedef uint64_t ogg_uint64_t; - -#elif defined (__EMX__) - - /* OS/2 GCC */ - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; - - -#elif defined (DJGPP) - - /* DJGPP */ - typedef short ogg_int16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; - -#elif defined(R5900) - - /* PS2 EE */ - typedef long ogg_int64_t; - typedef unsigned long ogg_uint64_t; - typedef int ogg_int32_t; - typedef unsigned ogg_uint32_t; - typedef short ogg_int16_t; - -#elif defined(__SYMBIAN32__) - - /* Symbian GCC */ - typedef signed short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef signed int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long int ogg_int64_t; - typedef unsigned long long int ogg_uint64_t; - -#elif defined(__TMS320C6X__) - - /* TI C64x compiler */ - typedef signed short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef signed int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long int ogg_int64_t; - typedef unsigned long long int ogg_uint64_t; - -#else - -# include - -#endif - -#endif /* _OS_TYPES_H */ diff --git a/Engine/lib/libogg/libogg.spec.in b/Engine/lib/libogg/libogg.spec.in deleted file mode 100644 index 41e930731..000000000 --- a/Engine/lib/libogg/libogg.spec.in +++ /dev/null @@ -1,109 +0,0 @@ -Name: libogg -Version: @VERSION@ -Release: 0.xiph.1 -Summary: Ogg Bitstream Library. - -Group: System Environment/Libraries -License: BSD -URL: http://www.xiph.org/ -Vendor: Xiph.org Foundation -Source: http://www.vorbis.com/files/1.0.1/unix/%{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-root - -# We're forced to use an epoch since both Red Hat and Ximian use it in their -# rc packages -Epoch: 2 -# Dirty trick to tell rpm that this package actually provides what the -# last rc and beta was offering -Provides: %{name} = %{epoch}:1.0rc3-%{release} -Provides: %{name} = %{epoch}:1.0beta4-%{release} - -%description -Libogg is a library for manipulating ogg bitstreams. It handles -both making ogg bitstreams and getting packets from ogg bitstreams. - -%package devel -Summary: Ogg Bitstream Library Development -Group: Development/Libraries -Requires: libogg = %{version} -# Dirty trick to tell rpm that this package actually provides what the -# last rc and beta was offering -Provides: %{name}-devel = %{epoch}:1.0rc3-%{release} -Provides: %{name}-devel = %{epoch}:1.0beta4-%{release} - -%description devel -The libogg-devel package contains the header files, static libraries -and documentation needed to develop applications with libogg. - -%prep -%setup -q -n %{name}-%{version} - -%build -CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{_prefix} --enable-static -make - -%install -rm -rf $RPM_BUILD_ROOT - -make DESTDIR=$RPM_BUILD_ROOT install - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig - -%files -%defattr(-,root,root) -%doc AUTHORS CHANGES COPYING README -%{_libdir}/libogg.so.* - -%files devel -%defattr(-,root,root) -%doc doc/index.html -%doc doc/framing.html -%doc doc/oggstream.html -%doc doc/white-ogg.png -%doc doc/white-xifish.png -%doc doc/stream.png -%doc doc/libogg/*.html -%doc doc/libogg/style.css -%dir %{_includedir}/ogg -%{_includedir}/ogg/ogg.h -%{_includedir}/ogg/os_types.h -%{_includedir}/ogg/config_types.h -%{_libdir}/libogg.a -%{_libdir}/libogg.la -%{_libdir}/libogg.so -%{_libdir}/pkgconfig/ogg.pc -%{_datadir}/aclocal/ogg.m4 - -%changelog -* Thu Nov 08 2007 Conrad Parker -- update doc dir (reported by thosmos on #vorbis) - -* Thu Jun 10 2004 Thomas Vander Stichele -- autogenerate from configure -- fix download location -- remove Prefix -- own include dir -- move ldconfig runs to -p scripts -- change Release tag to include xiph - -* Tue Oct 07 2003 Warren Dukes -- update for 1.1 release - -* Sun Jul 14 2002 Thomas Vander Stichele -- update for 1.0 release -- conform Group to Red Hat's idea of it -- take out case where configure doesn't exist; a tarball should have it - -* Tue Dec 18 2001 Jack Moffitt -- Update for RC3 release - -* Sun Oct 07 2001 Jack Moffitt -- add support for configurable prefixes - -* Sat Sep 02 2000 Jack Moffitt -- initial spec file created diff --git a/Engine/lib/libogg/ogg-uninstalled.pc.in b/Engine/lib/libogg/ogg-uninstalled.pc.in deleted file mode 100644 index 7acad7877..000000000 --- a/Engine/lib/libogg/ogg-uninstalled.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -# ogg uninstalled pkg-config file - -prefix= -exec_prefix= -libdir=${pcfiledir}/src -includedir=${pcfiledir}/@top_srcdir@/include - -Name: ogg -Description: ogg is a library for manipulating ogg bitstreams (not installed) -Version: @VERSION@ -Requires: -Conflicts: -Libs: ${libdir}/.libs/libogg.la -Cflags: -I${includedir} diff --git a/Engine/lib/libogg/ogg.m4 b/Engine/lib/libogg/ogg.m4 deleted file mode 100644 index 1d8d77ff1..000000000 --- a/Engine/lib/libogg/ogg.m4 +++ /dev/null @@ -1,114 +0,0 @@ -# Configure paths for libogg -# Jack Moffitt 10-21-2000 -# Shamelessly stolen from Owen Taylor and Manish Singh - -dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS -dnl -AC_DEFUN([XIPH_PATH_OGG], -[dnl -dnl Get the cflags and libraries -dnl -AC_ARG_WITH(ogg,AS_HELP_STRING([--with-ogg=PFX],[Prefix where libogg is installed (optional)]), ogg_prefix="$withval", ogg_prefix="") -AC_ARG_WITH(ogg-libraries,AS_HELP_STRING([--with-ogg-libraries=DIR],[Directory where libogg library is installed (optional)]), ogg_libraries="$withval", ogg_libraries="") -AC_ARG_WITH(ogg-includes,AS_HELP_STRING([--with-ogg-includes=DIR],[Directory where libogg header files are installed (optional)]), ogg_includes="$withval", ogg_includes="") -AC_ARG_ENABLE(oggtest,AS_HELP_STRING([--disable-oggtest],[Do not try to compile and run a test Ogg program]),, enable_oggtest=yes) - - if test "x$ogg_libraries" != "x" ; then - OGG_LIBS="-L$ogg_libraries" - elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then - OGG_LIBS="" - elif test "x$ogg_prefix" != "x" ; then - OGG_LIBS="-L$ogg_prefix/lib" - elif test "x$prefix" != "xNONE" && test "x$prefix" != "x/usr" ; then - OGG_LIBS="-L$prefix/lib" - fi - - if test "x$ogg_prefix" != "xno" ; then - OGG_LIBS="$OGG_LIBS -logg" - fi - - if test "x$ogg_includes" != "x" ; then - OGG_CFLAGS="-I$ogg_includes" - elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then - OGG_CFLAGS="" - elif test "x$ogg_prefix" != "x" ; then - OGG_CFLAGS="-I$ogg_prefix/include" - elif test "x$prefix" != "xNONE" && test "x$prefix" != "x/usr" ; then - OGG_CFLAGS="-I$prefix/include" - fi - - AC_MSG_CHECKING(for Ogg) - if test "x$ogg_prefix" = "xno" ; then - no_ogg="disabled" - enable_oggtest="no" - else - no_ogg="" - fi - - - if test "x$enable_oggtest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $OGG_CFLAGS" - LIBS="$LIBS $OGG_LIBS" -dnl -dnl Now check if the installed Ogg is sufficiently new. -dnl - rm -f conf.oggtest - AC_RUN_IFELSE([AC_LANG_SOURCE([ -#include -#include -#include -#include - -int main () -{ - system("touch conf.oggtest"); - return 0; -} - -])],[],[no_ogg=yes],[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - - if test "x$no_ogg" = "xdisabled" ; then - AC_MSG_RESULT(no) - ifelse([$2], , :, [$2]) - elif test "x$no_ogg" = "x" ; then - AC_MSG_RESULT(yes) - ifelse([$1], , :, [$1]) - else - AC_MSG_RESULT(no) - if test -f conf.oggtest ; then - : - else - echo "*** Could not run Ogg test program, checking why..." - CFLAGS="$CFLAGS $OGG_CFLAGS" - LIBS="$LIBS $OGG_LIBS" - AC_LINK_IFELSE([AC_LANG_PROGRAM([ -#include -#include -], [ return 0; ])],[echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding Ogg or finding the wrong" - echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],[echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occurred. This usually means Ogg was incorrectly installed" - echo "*** or that you have moved Ogg since it was installed."]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - OGG_CFLAGS="" - OGG_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(OGG_CFLAGS) - AC_SUBST(OGG_LIBS) - rm -f conf.oggtest -]) diff --git a/Engine/lib/libogg/ogg.pc.in b/Engine/lib/libogg/ogg.pc.in deleted file mode 100644 index 9e84375d9..000000000 --- a/Engine/lib/libogg/ogg.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -# ogg pkg-config file - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: ogg -Description: ogg is a library for manipulating ogg bitstreams -Version: @VERSION@ -Requires: -Conflicts: -Libs: -L${libdir} -logg -Cflags: -I${includedir} diff --git a/Engine/lib/libogg/releases.sha2 b/Engine/lib/libogg/releases.sha2 deleted file mode 100644 index cb5c79edd..000000000 --- a/Engine/lib/libogg/releases.sha2 +++ /dev/null @@ -1,43 +0,0 @@ -c8a4157b0194962aa885e2088cf8561c65ce2eee36a77ca6325c6c36c842b2a9 libogg-1.0beta4.tar.gz -37bec40bf26ba6af8e98f2996051079cd2fbc4c401960fadb15c9e75383f3361 libogg-1.0rc1.tar.gz -c5f5924f25402a59a2586c3d037d3e79dae97de30531b8dd8b8b4abc20d5f036 libogg-1.0rc2.tar.gz -e907b7bc56de5a9dd0c5f062c7b0340a6295671cf2c6ad994d5f62919c9e1b0b libogg-1.0rc3.tar.gz -920fa2a0924d66884825d36a2e843de069cfdf1af01945d05da25999bbd6396c libogg-1.0.tar.gz -269f8f6b11b8ac737cbd8ed8cfa244cc51ca42b6da6683336ba1413d2a00ceb3 libogg-1.1.1.tar.gz -b72f4d716d8e1339469a874962aae5f055ba618772f00f43d3c6d0b543cdfadd libogg-1.1.1.zip -7934f3bf689c6ea0870bc73fcf40b00d5050044b03e558819a1ed333dc3cfadf libogg-1.1.2.tar.gz -01e97dd79336db38b31003ff956c7e29ebcfd8ceef8175cf17cf4f339a8c1a54 libogg-1.1.2.zip -bae29e79fbc50bbedf1235852094b71c8c910a1ef0cd42fe4163b7b545630b65 libogg-1.1.3.tar.gz -11c0202bc8f8e6fa361051a7d2dbc7ec95195b126c0407c5fc851d01c2a2ad6b libogg-1.1.3.zip -253d138b8c062db4d8446be1522162940dd89cad35c8332c3127d2e842850f31 libogg-1.1.4rc1.tar.gz -6bb65e5eafc75cc2ef7ccc37aea81749f1e72e503f7614e6748c06f532c42707 libogg-1.1.4rc1.zip -9354c183fd88417c2860778b60b7896c9487d8f6e58b9fec3fdbf971142ce103 libogg-1.1.4.tar.gz -0e9eb2370ba8d28ee6f6ccf27779c154fbfbd9c5e9d3a09e4419a85112a900ce libogg-1.1.4.zip -01453d561255b5fcb361997904752860e4f8c6b9742f290578a44615fcc94356 libogg-1.1.tar.gz -f30d983e238acd94e80ae551327ea2f83cdc330470b4188564bef28fec59eb69 libogg-1.2.0.tar.gz -6bf8650f0f3651fa4714ab9d03a5f781879e697d85d776f4dabc31877f42a0b2 libogg-1.2.0.zip -da222202be8be48149f0a0668f3d2445a166b1f9f40a25e27cd222bfa9c1d4d4 libogg-1.2.1.tar.bz2 -6858848617bca6eab01e7d8526bc0d2a417e95070a255cbf9c881881365e36c0 libogg-1.2.1.tar.gz -21e0a61e15e9dd294587bcd39d81fbe1998b27b1c525e15ecfaba94344f921b4 libogg-1.2.1.tar.xz -2d799a043865edc030ae56186a44624deb6365d59bcd8b3ae96384ccf613189d libogg-1.2.1.zip -ab000574bc26d5f01284f5b0f50e12dc761d035c429f2e9c70cb2a9487d8cfba libogg-1.2.2.tar.gz -559f1ea72a559520298e518865e488eb9a7185c6b9279f70602b01a87f7defed libogg-1.2.2.tar.xz -3f3bec05106d852da5ae3899ac2047dd14e2009bba872524eeade2d0bda42da0 libogg-1.2.2.zip -a8de807631014615549d2356fd36641833b8288221cea214f8a72750efe93780 libogg-1.3.0.tar.gz -231725029c843492914f24e74085e734bca6f1d6446ac72df39b0c3a9d4bc74b libogg-1.3.0.tar.xz -56db84601e7e855d1b9095ccba73d8ef98f063a2384f2239a7042070a3f1cde3 libogg-1.3.0.zip -4e343f07aa5a1de8e0fa1107042d472186b3470d846b20b115b964eba5bae554 libogg-1.3.1.tar.gz -3a5bad78d81afb78908326d11761c0fb1a0662ee7150b6ad587cc586838cdcfa libogg-1.3.1.tar.xz -131ae1f65f65e0ed70db03fbe3a9d9f2e8c24ac43754ae5e055fc55e6f750bc7 libogg-1.3.1.zip -e19ee34711d7af328cb26287f4137e70630e7261b17cbe3cd41011d73a654692 libogg-1.3.2.tar.gz -3f687ccdd5ac8b52d76328fbbfebc70c459a40ea891dbf3dccb74a210826e79b libogg-1.3.2.tar.xz -957b4168a03932e02853db340cfddd0fa89b6ca80073a54f7c827372c3606350 libogg-1.3.2.zip -c2e8a485110b97550f453226ec644ebac6cb29d1caef2902c007edab4308d985 libogg-1.3.3.tar.gz -4f3fc6178a533d392064f14776b23c397ed4b9f48f5de297aba73b643f955c08 libogg-1.3.3.tar.xz -ddbb0884406ea2b30d831dc7304fd4a958a05d62f24429d8fa83e1c9d620e7f8 libogg-1.3.3.zip -fe5670640bd49e828d64d2879c31cb4dde9758681bb664f9bdbf159a01b0c76e libogg-1.3.4.tar.gz -c163bc12bc300c401b6aa35907ac682671ea376f13ae0969a220f7ddf71893fe libogg-1.3.4.tar.xz -dd74e3ae52beab6c894d4b721db786961e64f073f28ef823c5d2a3558d4fab2d libogg-1.3.4.zip -0eb4b4b9420a0f51db142ba3f9c64b333f826532dc0f48c6410ae51f4799b664 libogg-1.3.5.tar.gz -c4d91be36fc8e54deae7575241e03f4211eb102afb3fc0775fbbc1b740016705 libogg-1.3.5.tar.xz -fd4e5ba7e93b84b3ec41cdf01494cc586ef6e912b313dbab25512dd02665dfaf libogg-1.3.5.zip diff --git a/Engine/lib/libogg/src/Makefile.am b/Engine/lib/libogg/src/Makefile.am deleted file mode 100644 index f914a7899..000000000 --- a/Engine/lib/libogg/src/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -## Process this file with automake to produce Makefile.in - -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include - -lib_LTLIBRARIES = libogg.la - -libogg_la_SOURCES = framing.c bitwise.c crctable.h -libogg_la_LDFLAGS = -no-undefined -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@ - -# build and run the self tests on 'make check' - -noinst_PROGRAMS = test_bitwise test_framing - -test_bitwise_SOURCES = bitwise.c -test_bitwise_CFLAGS = -D_V_SELFTEST - -test_framing_SOURCES = framing.c crctable.h -test_framing_CFLAGS = -D_V_SELFTEST - -TEST_ENV = @TEST_ENV@ -LOG_COMPILER=$(LIBTOOL) --mode=execute $(VALGRIND) $(TEST_ENV) - -TESTS = $(noinst_PROGRAMS) -check_PROGRAMS = $(noinst_PROGRAMS) - -debug: - $(MAKE) all CFLAGS="@DEBUG@" - -profile: - $(MAKE) all CFLAGS="@PROFILE@" diff --git a/Engine/lib/libogg/src/bitwise.c b/Engine/lib/libogg/src/bitwise.c deleted file mode 100644 index 00b5053ba..000000000 --- a/Engine/lib/libogg/src/bitwise.c +++ /dev/null @@ -1,1089 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE Ogg CONTAINER SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2014 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: packing variable sized words into an octet stream - - ********************************************************************/ - -/* We're 'LSb' endian; if we write a word but read individual bits, - then we'll read the lsb first */ - -#include -#include -#include -#include - -#define BUFFER_INCREMENT 256 - -static const unsigned long mask[]= -{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f, - 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff, - 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff, - 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff, - 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff, - 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff, - 0x3fffffff,0x7fffffff,0xffffffff }; - -static const unsigned int mask8B[]= -{0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff}; - -void oggpack_writeinit(oggpack_buffer *b){ - memset(b,0,sizeof(*b)); - b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT); - if (!b->buffer) - return; - b->buffer[0]='\0'; - b->storage=BUFFER_INCREMENT; -} - -void oggpackB_writeinit(oggpack_buffer *b){ - oggpack_writeinit(b); -} - -int oggpack_writecheck(oggpack_buffer *b){ - if(!b->ptr || !b->storage)return -1; - return 0; -} - -int oggpackB_writecheck(oggpack_buffer *b){ - return oggpack_writecheck(b); -} - -void oggpack_writetrunc(oggpack_buffer *b,long bits){ - long bytes=bits>>3; - if(b->ptr){ - bits-=bytes*8; - b->ptr=b->buffer+bytes; - b->endbit=bits; - b->endbyte=bytes; - *b->ptr&=mask[bits]; - } -} - -void oggpackB_writetrunc(oggpack_buffer *b,long bits){ - long bytes=bits>>3; - if(b->ptr){ - bits-=bytes*8; - b->ptr=b->buffer+bytes; - b->endbit=bits; - b->endbyte=bytes; - *b->ptr&=mask8B[bits]; - } -} - -/* Takes only up to 32 bits. */ -void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){ - if(bits<0 || bits>32) goto err; - if(b->endbyte>=b->storage-4){ - void *ret; - if(!b->ptr)return; - if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err; - ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT); - if(!ret) goto err; - b->buffer=ret; - b->storage+=BUFFER_INCREMENT; - b->ptr=b->buffer+b->endbyte; - } - - value&=mask[bits]; - bits+=b->endbit; - - b->ptr[0]|=value<endbit; - - if(bits>=8){ - b->ptr[1]=(unsigned char)(value>>(8-b->endbit)); - if(bits>=16){ - b->ptr[2]=(unsigned char)(value>>(16-b->endbit)); - if(bits>=24){ - b->ptr[3]=(unsigned char)(value>>(24-b->endbit)); - if(bits>=32){ - if(b->endbit) - b->ptr[4]=(unsigned char)(value>>(32-b->endbit)); - else - b->ptr[4]=0; - } - } - } - } - - b->endbyte+=bits/8; - b->ptr+=bits/8; - b->endbit=bits&7; - return; - err: - oggpack_writeclear(b); -} - -/* Takes only up to 32 bits. */ -void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){ - if(bits<0 || bits>32) goto err; - if(b->endbyte>=b->storage-4){ - void *ret; - if(!b->ptr)return; - if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err; - ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT); - if(!ret) goto err; - b->buffer=ret; - b->storage+=BUFFER_INCREMENT; - b->ptr=b->buffer+b->endbyte; - } - - value=(value&mask[bits])<<(32-bits); - bits+=b->endbit; - - b->ptr[0]|=value>>(24+b->endbit); - - if(bits>=8){ - b->ptr[1]=(unsigned char)(value>>(16+b->endbit)); - if(bits>=16){ - b->ptr[2]=(unsigned char)(value>>(8+b->endbit)); - if(bits>=24){ - b->ptr[3]=(unsigned char)(value>>(b->endbit)); - if(bits>=32){ - if(b->endbit) - b->ptr[4]=(unsigned char)(value<<(8-b->endbit)); - else - b->ptr[4]=0; - } - } - } - } - - b->endbyte+=bits/8; - b->ptr+=bits/8; - b->endbit=bits&7; - return; - err: - oggpack_writeclear(b); -} - -void oggpack_writealign(oggpack_buffer *b){ - int bits=8-b->endbit; - if(bits<8) - oggpack_write(b,0,bits); -} - -void oggpackB_writealign(oggpack_buffer *b){ - int bits=8-b->endbit; - if(bits<8) - oggpackB_write(b,0,bits); -} - -static void oggpack_writecopy_helper(oggpack_buffer *b, - void *source, - long bits, - void (*w)(oggpack_buffer *, - unsigned long, - int), - int msb){ - unsigned char *ptr=(unsigned char *)source; - - long bytes=bits/8; - long pbytes=(b->endbit+bits)/8; - bits-=bytes*8; - - /* expand storage up-front */ - if(b->endbyte+pbytes>=b->storage){ - void *ret; - if(!b->ptr) goto err; - if(b->storage>b->endbyte+pbytes+BUFFER_INCREMENT) goto err; - b->storage=b->endbyte+pbytes+BUFFER_INCREMENT; - ret=_ogg_realloc(b->buffer,b->storage); - if(!ret) goto err; - b->buffer=ret; - b->ptr=b->buffer+b->endbyte; - } - - /* copy whole octets */ - if(b->endbit){ - int i; - /* unaligned copy. Do it the hard way. */ - for(i=0;iptr,source,bytes); - b->ptr+=bytes; - b->endbyte+=bytes; - *b->ptr=0; - } - - /* copy trailing bits */ - if(bits){ - if(msb) - w(b,(unsigned long)(ptr[bytes]>>(8-bits)),bits); - else - w(b,(unsigned long)(ptr[bytes]),bits); - } - return; - err: - oggpack_writeclear(b); -} - -void oggpack_writecopy(oggpack_buffer *b,void *source,long bits){ - oggpack_writecopy_helper(b,source,bits,oggpack_write,0); -} - -void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits){ - oggpack_writecopy_helper(b,source,bits,oggpackB_write,1); -} - -void oggpack_reset(oggpack_buffer *b){ - if(!b->ptr)return; - b->ptr=b->buffer; - b->buffer[0]=0; - b->endbit=b->endbyte=0; -} - -void oggpackB_reset(oggpack_buffer *b){ - oggpack_reset(b); -} - -void oggpack_writeclear(oggpack_buffer *b){ - if(b->buffer)_ogg_free(b->buffer); - memset(b,0,sizeof(*b)); -} - -void oggpackB_writeclear(oggpack_buffer *b){ - oggpack_writeclear(b); -} - -void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){ - memset(b,0,sizeof(*b)); - b->buffer=b->ptr=buf; - b->storage=bytes; -} - -void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){ - oggpack_readinit(b,buf,bytes); -} - -/* Read in bits without advancing the bitptr; bits <= 32 */ -long oggpack_look(oggpack_buffer *b,int bits){ - unsigned long ret; - unsigned long m; - - if(bits<0 || bits>32) return -1; - m=mask[bits]; - bits+=b->endbit; - - if(b->endbyte >= b->storage-4){ - /* not the main path */ - if(b->endbyte > b->storage-((bits+7)>>3)) return -1; - /* special case to avoid reading b->ptr[0], which might be past the end of - the buffer; also skips some useless accounting */ - else if(!bits)return(0L); - } - - ret=b->ptr[0]>>b->endbit; - if(bits>8){ - ret|=(unsigned long)b->ptr[1]<<(8-b->endbit); - if(bits>16){ - ret|=(unsigned long)b->ptr[2]<<(16-b->endbit); - if(bits>24){ - ret|=(unsigned long)b->ptr[3]<<(24-b->endbit); - if(bits>32 && b->endbit) - ret|=(unsigned long)b->ptr[4]<<(32-b->endbit); - } - } - } - return(m&ret); -} - -/* Read in bits without advancing the bitptr; bits <= 32 */ -long oggpackB_look(oggpack_buffer *b,int bits){ - unsigned long ret; - int m=32-bits; - - if(m<0 || m>32) return -1; - bits+=b->endbit; - - if(b->endbyte >= b->storage-4){ - /* not the main path */ - if(b->endbyte > b->storage-((bits+7)>>3)) return -1; - /* special case to avoid reading b->ptr[0], which might be past the end of - the buffer; also skips some useless accounting */ - else if(!bits)return(0L); - } - - ret=(unsigned long)b->ptr[0]<<(24+b->endbit); - if(bits>8){ - ret|=(unsigned long)b->ptr[1]<<(16+b->endbit); - if(bits>16){ - ret|=(unsigned long)b->ptr[2]<<(8+b->endbit); - if(bits>24){ - ret|=(unsigned long)b->ptr[3]<<(b->endbit); - if(bits>32 && b->endbit) - ret|=b->ptr[4]>>(8-b->endbit); - } - } - } - return ((ret&0xffffffff)>>(m>>1))>>((m+1)>>1); -} - -long oggpack_look1(oggpack_buffer *b){ - if(b->endbyte>=b->storage)return(-1); - return((b->ptr[0]>>b->endbit)&1); -} - -long oggpackB_look1(oggpack_buffer *b){ - if(b->endbyte>=b->storage)return(-1); - return((b->ptr[0]>>(7-b->endbit))&1); -} - -void oggpack_adv(oggpack_buffer *b,int bits){ - bits+=b->endbit; - - if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow; - - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; - return; - - overflow: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; -} - -void oggpackB_adv(oggpack_buffer *b,int bits){ - oggpack_adv(b,bits); -} - -void oggpack_adv1(oggpack_buffer *b){ - if(++(b->endbit)>7){ - b->endbit=0; - b->ptr++; - b->endbyte++; - } -} - -void oggpackB_adv1(oggpack_buffer *b){ - oggpack_adv1(b); -} - -/* bits <= 32 */ -long oggpack_read(oggpack_buffer *b,int bits){ - long ret; - unsigned long m; - - if(bits<0 || bits>32) goto err; - m=mask[bits]; - bits+=b->endbit; - - if(b->endbyte >= b->storage-4){ - /* not the main path */ - if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow; - /* special case to avoid reading b->ptr[0], which might be past the end of - the buffer; also skips some useless accounting */ - else if(!bits)return(0L); - } - - ret=b->ptr[0]>>b->endbit; - if(bits>8){ - ret|=(unsigned long)b->ptr[1]<<(8-b->endbit); - if(bits>16){ - ret|=(unsigned long)b->ptr[2]<<(16-b->endbit); - if(bits>24){ - ret|=(unsigned long)b->ptr[3]<<(24-b->endbit); - if(bits>32 && b->endbit){ - ret|=(unsigned long)b->ptr[4]<<(32-b->endbit); - } - } - } - } - ret&=m; - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; - return ret; - - overflow: - err: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; - return -1L; -} - -/* bits <= 32 */ -long oggpackB_read(oggpack_buffer *b,int bits){ - long ret; - long m=32-bits; - - if(m<0 || m>32) goto err; - bits+=b->endbit; - - if(b->endbyte+4>=b->storage){ - /* not the main path */ - if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow; - /* special case to avoid reading b->ptr[0], which might be past the end of - the buffer; also skips some useless accounting */ - else if(!bits)return(0L); - } - - ret=(unsigned long)b->ptr[0]<<(24+b->endbit); - if(bits>8){ - ret|=(unsigned long)b->ptr[1]<<(16+b->endbit); - if(bits>16){ - ret|=(unsigned long)b->ptr[2]<<(8+b->endbit); - if(bits>24){ - ret|=(unsigned long)b->ptr[3]<<(b->endbit); - if(bits>32 && b->endbit) - ret|=b->ptr[4]>>(8-b->endbit); - } - } - } - ret=((ret&0xffffffffUL)>>(m>>1))>>((m+1)>>1); - - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; - return ret; - - overflow: - err: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; - return -1L; -} - -long oggpack_read1(oggpack_buffer *b){ - long ret; - - if(b->endbyte >= b->storage) goto overflow; - ret=(b->ptr[0]>>b->endbit)&1; - - b->endbit++; - if(b->endbit>7){ - b->endbit=0; - b->ptr++; - b->endbyte++; - } - return ret; - - overflow: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; - return -1L; -} - -long oggpackB_read1(oggpack_buffer *b){ - long ret; - - if(b->endbyte >= b->storage) goto overflow; - ret=(b->ptr[0]>>(7-b->endbit))&1; - - b->endbit++; - if(b->endbit>7){ - b->endbit=0; - b->ptr++; - b->endbyte++; - } - return ret; - - overflow: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; - return -1L; -} - -long oggpack_bytes(oggpack_buffer *b){ - return(b->endbyte+(b->endbit+7)/8); -} - -long oggpack_bits(oggpack_buffer *b){ - return(b->endbyte*8+b->endbit); -} - -long oggpackB_bytes(oggpack_buffer *b){ - return oggpack_bytes(b); -} - -long oggpackB_bits(oggpack_buffer *b){ - return oggpack_bits(b); -} - -unsigned char *oggpack_get_buffer(oggpack_buffer *b){ - return(b->buffer); -} - -unsigned char *oggpackB_get_buffer(oggpack_buffer *b){ - return oggpack_get_buffer(b); -} - -/* Self test of the bitwise routines; everything else is based on - them, so they damned well better be solid. */ - -#ifdef _V_SELFTEST -#include - -static int ilog(unsigned int v){ - int ret=0; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - -oggpack_buffer o; -oggpack_buffer r; - -void report(char *in){ - fprintf(stderr,"%s",in); - exit(1); -} - -void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){ - long bytes,i; - unsigned char *buffer; - - oggpack_reset(&o); - for(i=0;i - -static const ogg_uint32_t crc_lookup[8][256]={ -{0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005, - 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd, - 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9,0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75, - 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd, - 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039,0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5, - 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81,0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d, - 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95, - 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1,0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d, - 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae,0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072, - 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca, - 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde,0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02, - 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066,0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba, - 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692, - 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6,0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a, - 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e,0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2, - 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a, - 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637,0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb, - 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f,0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53, - 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b, - 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff,0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623, - 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7,0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b, - 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3, - 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7,0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b, - 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f,0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3, - 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c, - 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8,0x68860bfd,0x6c47164a,0x61043093,0x65c52d24, - 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30,0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec, - 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654, - 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0,0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c, - 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18,0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4, - 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c, - 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668,0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4}, - -{0x00000000,0xd219c1dc,0xa0f29e0f,0x72eb5fd3,0x452421a9,0x973de075,0xe5d6bfa6,0x37cf7e7a, - 0x8a484352,0x5851828e,0x2abadd5d,0xf8a31c81,0xcf6c62fb,0x1d75a327,0x6f9efcf4,0xbd873d28, - 0x10519b13,0xc2485acf,0xb0a3051c,0x62bac4c0,0x5575baba,0x876c7b66,0xf58724b5,0x279ee569, - 0x9a19d841,0x4800199d,0x3aeb464e,0xe8f28792,0xdf3df9e8,0x0d243834,0x7fcf67e7,0xadd6a63b, - 0x20a33626,0xf2baf7fa,0x8051a829,0x524869f5,0x6587178f,0xb79ed653,0xc5758980,0x176c485c, - 0xaaeb7574,0x78f2b4a8,0x0a19eb7b,0xd8002aa7,0xefcf54dd,0x3dd69501,0x4f3dcad2,0x9d240b0e, - 0x30f2ad35,0xe2eb6ce9,0x9000333a,0x4219f2e6,0x75d68c9c,0xa7cf4d40,0xd5241293,0x073dd34f, - 0xbabaee67,0x68a32fbb,0x1a487068,0xc851b1b4,0xff9ecfce,0x2d870e12,0x5f6c51c1,0x8d75901d, - 0x41466c4c,0x935fad90,0xe1b4f243,0x33ad339f,0x04624de5,0xd67b8c39,0xa490d3ea,0x76891236, - 0xcb0e2f1e,0x1917eec2,0x6bfcb111,0xb9e570cd,0x8e2a0eb7,0x5c33cf6b,0x2ed890b8,0xfcc15164, - 0x5117f75f,0x830e3683,0xf1e56950,0x23fca88c,0x1433d6f6,0xc62a172a,0xb4c148f9,0x66d88925, - 0xdb5fb40d,0x094675d1,0x7bad2a02,0xa9b4ebde,0x9e7b95a4,0x4c625478,0x3e890bab,0xec90ca77, - 0x61e55a6a,0xb3fc9bb6,0xc117c465,0x130e05b9,0x24c17bc3,0xf6d8ba1f,0x8433e5cc,0x562a2410, - 0xebad1938,0x39b4d8e4,0x4b5f8737,0x994646eb,0xae893891,0x7c90f94d,0x0e7ba69e,0xdc626742, - 0x71b4c179,0xa3ad00a5,0xd1465f76,0x035f9eaa,0x3490e0d0,0xe689210c,0x94627edf,0x467bbf03, - 0xfbfc822b,0x29e543f7,0x5b0e1c24,0x8917ddf8,0xbed8a382,0x6cc1625e,0x1e2a3d8d,0xcc33fc51, - 0x828cd898,0x50951944,0x227e4697,0xf067874b,0xc7a8f931,0x15b138ed,0x675a673e,0xb543a6e2, - 0x08c49bca,0xdadd5a16,0xa83605c5,0x7a2fc419,0x4de0ba63,0x9ff97bbf,0xed12246c,0x3f0be5b0, - 0x92dd438b,0x40c48257,0x322fdd84,0xe0361c58,0xd7f96222,0x05e0a3fe,0x770bfc2d,0xa5123df1, - 0x189500d9,0xca8cc105,0xb8679ed6,0x6a7e5f0a,0x5db12170,0x8fa8e0ac,0xfd43bf7f,0x2f5a7ea3, - 0xa22feebe,0x70362f62,0x02dd70b1,0xd0c4b16d,0xe70bcf17,0x35120ecb,0x47f95118,0x95e090c4, - 0x2867adec,0xfa7e6c30,0x889533e3,0x5a8cf23f,0x6d438c45,0xbf5a4d99,0xcdb1124a,0x1fa8d396, - 0xb27e75ad,0x6067b471,0x128ceba2,0xc0952a7e,0xf75a5404,0x254395d8,0x57a8ca0b,0x85b10bd7, - 0x383636ff,0xea2ff723,0x98c4a8f0,0x4add692c,0x7d121756,0xaf0bd68a,0xdde08959,0x0ff94885, - 0xc3cab4d4,0x11d37508,0x63382adb,0xb121eb07,0x86ee957d,0x54f754a1,0x261c0b72,0xf405caae, - 0x4982f786,0x9b9b365a,0xe9706989,0x3b69a855,0x0ca6d62f,0xdebf17f3,0xac544820,0x7e4d89fc, - 0xd39b2fc7,0x0182ee1b,0x7369b1c8,0xa1707014,0x96bf0e6e,0x44a6cfb2,0x364d9061,0xe45451bd, - 0x59d36c95,0x8bcaad49,0xf921f29a,0x2b383346,0x1cf74d3c,0xceee8ce0,0xbc05d333,0x6e1c12ef, - 0xe36982f2,0x3170432e,0x439b1cfd,0x9182dd21,0xa64da35b,0x74546287,0x06bf3d54,0xd4a6fc88, - 0x6921c1a0,0xbb38007c,0xc9d35faf,0x1bca9e73,0x2c05e009,0xfe1c21d5,0x8cf77e06,0x5eeebfda, - 0xf33819e1,0x2121d83d,0x53ca87ee,0x81d34632,0xb61c3848,0x6405f994,0x16eea647,0xc4f7679b, - 0x79705ab3,0xab699b6f,0xd982c4bc,0x0b9b0560,0x3c547b1a,0xee4dbac6,0x9ca6e515,0x4ebf24c9}, - -{0x00000000,0x01d8ac87,0x03b1590e,0x0269f589,0x0762b21c,0x06ba1e9b,0x04d3eb12,0x050b4795, - 0x0ec56438,0x0f1dc8bf,0x0d743d36,0x0cac91b1,0x09a7d624,0x087f7aa3,0x0a168f2a,0x0bce23ad, - 0x1d8ac870,0x1c5264f7,0x1e3b917e,0x1fe33df9,0x1ae87a6c,0x1b30d6eb,0x19592362,0x18818fe5, - 0x134fac48,0x129700cf,0x10fef546,0x112659c1,0x142d1e54,0x15f5b2d3,0x179c475a,0x1644ebdd, - 0x3b1590e0,0x3acd3c67,0x38a4c9ee,0x397c6569,0x3c7722fc,0x3daf8e7b,0x3fc67bf2,0x3e1ed775, - 0x35d0f4d8,0x3408585f,0x3661add6,0x37b90151,0x32b246c4,0x336aea43,0x31031fca,0x30dbb34d, - 0x269f5890,0x2747f417,0x252e019e,0x24f6ad19,0x21fdea8c,0x2025460b,0x224cb382,0x23941f05, - 0x285a3ca8,0x2982902f,0x2beb65a6,0x2a33c921,0x2f388eb4,0x2ee02233,0x2c89d7ba,0x2d517b3d, - 0x762b21c0,0x77f38d47,0x759a78ce,0x7442d449,0x714993dc,0x70913f5b,0x72f8cad2,0x73206655, - 0x78ee45f8,0x7936e97f,0x7b5f1cf6,0x7a87b071,0x7f8cf7e4,0x7e545b63,0x7c3daeea,0x7de5026d, - 0x6ba1e9b0,0x6a794537,0x6810b0be,0x69c81c39,0x6cc35bac,0x6d1bf72b,0x6f7202a2,0x6eaaae25, - 0x65648d88,0x64bc210f,0x66d5d486,0x670d7801,0x62063f94,0x63de9313,0x61b7669a,0x606fca1d, - 0x4d3eb120,0x4ce61da7,0x4e8fe82e,0x4f5744a9,0x4a5c033c,0x4b84afbb,0x49ed5a32,0x4835f6b5, - 0x43fbd518,0x4223799f,0x404a8c16,0x41922091,0x44996704,0x4541cb83,0x47283e0a,0x46f0928d, - 0x50b47950,0x516cd5d7,0x5305205e,0x52dd8cd9,0x57d6cb4c,0x560e67cb,0x54679242,0x55bf3ec5, - 0x5e711d68,0x5fa9b1ef,0x5dc04466,0x5c18e8e1,0x5913af74,0x58cb03f3,0x5aa2f67a,0x5b7a5afd, - 0xec564380,0xed8eef07,0xefe71a8e,0xee3fb609,0xeb34f19c,0xeaec5d1b,0xe885a892,0xe95d0415, - 0xe29327b8,0xe34b8b3f,0xe1227eb6,0xe0fad231,0xe5f195a4,0xe4293923,0xe640ccaa,0xe798602d, - 0xf1dc8bf0,0xf0042777,0xf26dd2fe,0xf3b57e79,0xf6be39ec,0xf766956b,0xf50f60e2,0xf4d7cc65, - 0xff19efc8,0xfec1434f,0xfca8b6c6,0xfd701a41,0xf87b5dd4,0xf9a3f153,0xfbca04da,0xfa12a85d, - 0xd743d360,0xd69b7fe7,0xd4f28a6e,0xd52a26e9,0xd021617c,0xd1f9cdfb,0xd3903872,0xd24894f5, - 0xd986b758,0xd85e1bdf,0xda37ee56,0xdbef42d1,0xdee40544,0xdf3ca9c3,0xdd555c4a,0xdc8df0cd, - 0xcac91b10,0xcb11b797,0xc978421e,0xc8a0ee99,0xcdaba90c,0xcc73058b,0xce1af002,0xcfc25c85, - 0xc40c7f28,0xc5d4d3af,0xc7bd2626,0xc6658aa1,0xc36ecd34,0xc2b661b3,0xc0df943a,0xc10738bd, - 0x9a7d6240,0x9ba5cec7,0x99cc3b4e,0x981497c9,0x9d1fd05c,0x9cc77cdb,0x9eae8952,0x9f7625d5, - 0x94b80678,0x9560aaff,0x97095f76,0x96d1f3f1,0x93dab464,0x920218e3,0x906bed6a,0x91b341ed, - 0x87f7aa30,0x862f06b7,0x8446f33e,0x859e5fb9,0x8095182c,0x814db4ab,0x83244122,0x82fceda5, - 0x8932ce08,0x88ea628f,0x8a839706,0x8b5b3b81,0x8e507c14,0x8f88d093,0x8de1251a,0x8c39899d, - 0xa168f2a0,0xa0b05e27,0xa2d9abae,0xa3010729,0xa60a40bc,0xa7d2ec3b,0xa5bb19b2,0xa463b535, - 0xafad9698,0xae753a1f,0xac1ccf96,0xadc46311,0xa8cf2484,0xa9178803,0xab7e7d8a,0xaaa6d10d, - 0xbce23ad0,0xbd3a9657,0xbf5363de,0xbe8bcf59,0xbb8088cc,0xba58244b,0xb831d1c2,0xb9e97d45, - 0xb2275ee8,0xb3fff26f,0xb19607e6,0xb04eab61,0xb545ecf4,0xb49d4073,0xb6f4b5fa,0xb72c197d}, - -{0x00000000,0xdc6d9ab7,0xbc1a28d9,0x6077b26e,0x7cf54c05,0xa098d6b2,0xc0ef64dc,0x1c82fe6b, - 0xf9ea980a,0x258702bd,0x45f0b0d3,0x999d2a64,0x851fd40f,0x59724eb8,0x3905fcd6,0xe5686661, - 0xf7142da3,0x2b79b714,0x4b0e057a,0x97639fcd,0x8be161a6,0x578cfb11,0x37fb497f,0xeb96d3c8, - 0x0efeb5a9,0xd2932f1e,0xb2e49d70,0x6e8907c7,0x720bf9ac,0xae66631b,0xce11d175,0x127c4bc2, - 0xeae946f1,0x3684dc46,0x56f36e28,0x8a9ef49f,0x961c0af4,0x4a719043,0x2a06222d,0xf66bb89a, - 0x1303defb,0xcf6e444c,0xaf19f622,0x73746c95,0x6ff692fe,0xb39b0849,0xd3ecba27,0x0f812090, - 0x1dfd6b52,0xc190f1e5,0xa1e7438b,0x7d8ad93c,0x61082757,0xbd65bde0,0xdd120f8e,0x017f9539, - 0xe417f358,0x387a69ef,0x580ddb81,0x84604136,0x98e2bf5d,0x448f25ea,0x24f89784,0xf8950d33, - 0xd1139055,0x0d7e0ae2,0x6d09b88c,0xb164223b,0xade6dc50,0x718b46e7,0x11fcf489,0xcd916e3e, - 0x28f9085f,0xf49492e8,0x94e32086,0x488eba31,0x540c445a,0x8861deed,0xe8166c83,0x347bf634, - 0x2607bdf6,0xfa6a2741,0x9a1d952f,0x46700f98,0x5af2f1f3,0x869f6b44,0xe6e8d92a,0x3a85439d, - 0xdfed25fc,0x0380bf4b,0x63f70d25,0xbf9a9792,0xa31869f9,0x7f75f34e,0x1f024120,0xc36fdb97, - 0x3bfad6a4,0xe7974c13,0x87e0fe7d,0x5b8d64ca,0x470f9aa1,0x9b620016,0xfb15b278,0x277828cf, - 0xc2104eae,0x1e7dd419,0x7e0a6677,0xa267fcc0,0xbee502ab,0x6288981c,0x02ff2a72,0xde92b0c5, - 0xcceefb07,0x108361b0,0x70f4d3de,0xac994969,0xb01bb702,0x6c762db5,0x0c019fdb,0xd06c056c, - 0x3504630d,0xe969f9ba,0x891e4bd4,0x5573d163,0x49f12f08,0x959cb5bf,0xf5eb07d1,0x29869d66, - 0xa6e63d1d,0x7a8ba7aa,0x1afc15c4,0xc6918f73,0xda137118,0x067eebaf,0x660959c1,0xba64c376, - 0x5f0ca517,0x83613fa0,0xe3168dce,0x3f7b1779,0x23f9e912,0xff9473a5,0x9fe3c1cb,0x438e5b7c, - 0x51f210be,0x8d9f8a09,0xede83867,0x3185a2d0,0x2d075cbb,0xf16ac60c,0x911d7462,0x4d70eed5, - 0xa81888b4,0x74751203,0x1402a06d,0xc86f3ada,0xd4edc4b1,0x08805e06,0x68f7ec68,0xb49a76df, - 0x4c0f7bec,0x9062e15b,0xf0155335,0x2c78c982,0x30fa37e9,0xec97ad5e,0x8ce01f30,0x508d8587, - 0xb5e5e3e6,0x69887951,0x09ffcb3f,0xd5925188,0xc910afe3,0x157d3554,0x750a873a,0xa9671d8d, - 0xbb1b564f,0x6776ccf8,0x07017e96,0xdb6ce421,0xc7ee1a4a,0x1b8380fd,0x7bf43293,0xa799a824, - 0x42f1ce45,0x9e9c54f2,0xfeebe69c,0x22867c2b,0x3e048240,0xe26918f7,0x821eaa99,0x5e73302e, - 0x77f5ad48,0xab9837ff,0xcbef8591,0x17821f26,0x0b00e14d,0xd76d7bfa,0xb71ac994,0x6b775323, - 0x8e1f3542,0x5272aff5,0x32051d9b,0xee68872c,0xf2ea7947,0x2e87e3f0,0x4ef0519e,0x929dcb29, - 0x80e180eb,0x5c8c1a5c,0x3cfba832,0xe0963285,0xfc14ccee,0x20795659,0x400ee437,0x9c637e80, - 0x790b18e1,0xa5668256,0xc5113038,0x197caa8f,0x05fe54e4,0xd993ce53,0xb9e47c3d,0x6589e68a, - 0x9d1cebb9,0x4171710e,0x2106c360,0xfd6b59d7,0xe1e9a7bc,0x3d843d0b,0x5df38f65,0x819e15d2, - 0x64f673b3,0xb89be904,0xd8ec5b6a,0x0481c1dd,0x18033fb6,0xc46ea501,0xa419176f,0x78748dd8, - 0x6a08c61a,0xb6655cad,0xd612eec3,0x0a7f7474,0x16fd8a1f,0xca9010a8,0xaae7a2c6,0x768a3871, - 0x93e25e10,0x4f8fc4a7,0x2ff876c9,0xf395ec7e,0xef171215,0x337a88a2,0x530d3acc,0x8f60a07b}, - -{0x00000000,0x490d678d,0x921acf1a,0xdb17a897,0x20f48383,0x69f9e40e,0xb2ee4c99,0xfbe32b14, - 0x41e90706,0x08e4608b,0xd3f3c81c,0x9afeaf91,0x611d8485,0x2810e308,0xf3074b9f,0xba0a2c12, - 0x83d20e0c,0xcadf6981,0x11c8c116,0x58c5a69b,0xa3268d8f,0xea2bea02,0x313c4295,0x78312518, - 0xc23b090a,0x8b366e87,0x5021c610,0x192ca19d,0xe2cf8a89,0xabc2ed04,0x70d54593,0x39d8221e, - 0x036501af,0x4a686622,0x917fceb5,0xd872a938,0x2391822c,0x6a9ce5a1,0xb18b4d36,0xf8862abb, - 0x428c06a9,0x0b816124,0xd096c9b3,0x999bae3e,0x6278852a,0x2b75e2a7,0xf0624a30,0xb96f2dbd, - 0x80b70fa3,0xc9ba682e,0x12adc0b9,0x5ba0a734,0xa0438c20,0xe94eebad,0x3259433a,0x7b5424b7, - 0xc15e08a5,0x88536f28,0x5344c7bf,0x1a49a032,0xe1aa8b26,0xa8a7ecab,0x73b0443c,0x3abd23b1, - 0x06ca035e,0x4fc764d3,0x94d0cc44,0xddddabc9,0x263e80dd,0x6f33e750,0xb4244fc7,0xfd29284a, - 0x47230458,0x0e2e63d5,0xd539cb42,0x9c34accf,0x67d787db,0x2edae056,0xf5cd48c1,0xbcc02f4c, - 0x85180d52,0xcc156adf,0x1702c248,0x5e0fa5c5,0xa5ec8ed1,0xece1e95c,0x37f641cb,0x7efb2646, - 0xc4f10a54,0x8dfc6dd9,0x56ebc54e,0x1fe6a2c3,0xe40589d7,0xad08ee5a,0x761f46cd,0x3f122140, - 0x05af02f1,0x4ca2657c,0x97b5cdeb,0xdeb8aa66,0x255b8172,0x6c56e6ff,0xb7414e68,0xfe4c29e5, - 0x444605f7,0x0d4b627a,0xd65ccaed,0x9f51ad60,0x64b28674,0x2dbfe1f9,0xf6a8496e,0xbfa52ee3, - 0x867d0cfd,0xcf706b70,0x1467c3e7,0x5d6aa46a,0xa6898f7e,0xef84e8f3,0x34934064,0x7d9e27e9, - 0xc7940bfb,0x8e996c76,0x558ec4e1,0x1c83a36c,0xe7608878,0xae6deff5,0x757a4762,0x3c7720ef, - 0x0d9406bc,0x44996131,0x9f8ec9a6,0xd683ae2b,0x2d60853f,0x646de2b2,0xbf7a4a25,0xf6772da8, - 0x4c7d01ba,0x05706637,0xde67cea0,0x976aa92d,0x6c898239,0x2584e5b4,0xfe934d23,0xb79e2aae, - 0x8e4608b0,0xc74b6f3d,0x1c5cc7aa,0x5551a027,0xaeb28b33,0xe7bfecbe,0x3ca84429,0x75a523a4, - 0xcfaf0fb6,0x86a2683b,0x5db5c0ac,0x14b8a721,0xef5b8c35,0xa656ebb8,0x7d41432f,0x344c24a2, - 0x0ef10713,0x47fc609e,0x9cebc809,0xd5e6af84,0x2e058490,0x6708e31d,0xbc1f4b8a,0xf5122c07, - 0x4f180015,0x06156798,0xdd02cf0f,0x940fa882,0x6fec8396,0x26e1e41b,0xfdf64c8c,0xb4fb2b01, - 0x8d23091f,0xc42e6e92,0x1f39c605,0x5634a188,0xadd78a9c,0xe4daed11,0x3fcd4586,0x76c0220b, - 0xccca0e19,0x85c76994,0x5ed0c103,0x17dda68e,0xec3e8d9a,0xa533ea17,0x7e244280,0x3729250d, - 0x0b5e05e2,0x4253626f,0x9944caf8,0xd049ad75,0x2baa8661,0x62a7e1ec,0xb9b0497b,0xf0bd2ef6, - 0x4ab702e4,0x03ba6569,0xd8adcdfe,0x91a0aa73,0x6a438167,0x234ee6ea,0xf8594e7d,0xb15429f0, - 0x888c0bee,0xc1816c63,0x1a96c4f4,0x539ba379,0xa878886d,0xe175efe0,0x3a624777,0x736f20fa, - 0xc9650ce8,0x80686b65,0x5b7fc3f2,0x1272a47f,0xe9918f6b,0xa09ce8e6,0x7b8b4071,0x328627fc, - 0x083b044d,0x413663c0,0x9a21cb57,0xd32cacda,0x28cf87ce,0x61c2e043,0xbad548d4,0xf3d82f59, - 0x49d2034b,0x00df64c6,0xdbc8cc51,0x92c5abdc,0x692680c8,0x202be745,0xfb3c4fd2,0xb231285f, - 0x8be90a41,0xc2e46dcc,0x19f3c55b,0x50fea2d6,0xab1d89c2,0xe210ee4f,0x390746d8,0x700a2155, - 0xca000d47,0x830d6aca,0x581ac25d,0x1117a5d0,0xeaf48ec4,0xa3f9e949,0x78ee41de,0x31e32653}, - -{0x00000000,0x1b280d78,0x36501af0,0x2d781788,0x6ca035e0,0x77883898,0x5af02f10,0x41d82268, - 0xd9406bc0,0xc26866b8,0xef107130,0xf4387c48,0xb5e05e20,0xaec85358,0x83b044d0,0x989849a8, - 0xb641ca37,0xad69c74f,0x8011d0c7,0x9b39ddbf,0xdae1ffd7,0xc1c9f2af,0xecb1e527,0xf799e85f, - 0x6f01a1f7,0x7429ac8f,0x5951bb07,0x4279b67f,0x03a19417,0x1889996f,0x35f18ee7,0x2ed9839f, - 0x684289d9,0x736a84a1,0x5e129329,0x453a9e51,0x04e2bc39,0x1fcab141,0x32b2a6c9,0x299aabb1, - 0xb102e219,0xaa2aef61,0x8752f8e9,0x9c7af591,0xdda2d7f9,0xc68ada81,0xebf2cd09,0xf0dac071, - 0xde0343ee,0xc52b4e96,0xe853591e,0xf37b5466,0xb2a3760e,0xa98b7b76,0x84f36cfe,0x9fdb6186, - 0x0743282e,0x1c6b2556,0x311332de,0x2a3b3fa6,0x6be31dce,0x70cb10b6,0x5db3073e,0x469b0a46, - 0xd08513b2,0xcbad1eca,0xe6d50942,0xfdfd043a,0xbc252652,0xa70d2b2a,0x8a753ca2,0x915d31da, - 0x09c57872,0x12ed750a,0x3f956282,0x24bd6ffa,0x65654d92,0x7e4d40ea,0x53355762,0x481d5a1a, - 0x66c4d985,0x7decd4fd,0x5094c375,0x4bbcce0d,0x0a64ec65,0x114ce11d,0x3c34f695,0x271cfbed, - 0xbf84b245,0xa4acbf3d,0x89d4a8b5,0x92fca5cd,0xd32487a5,0xc80c8add,0xe5749d55,0xfe5c902d, - 0xb8c79a6b,0xa3ef9713,0x8e97809b,0x95bf8de3,0xd467af8b,0xcf4fa2f3,0xe237b57b,0xf91fb803, - 0x6187f1ab,0x7aaffcd3,0x57d7eb5b,0x4cffe623,0x0d27c44b,0x160fc933,0x3b77debb,0x205fd3c3, - 0x0e86505c,0x15ae5d24,0x38d64aac,0x23fe47d4,0x622665bc,0x790e68c4,0x54767f4c,0x4f5e7234, - 0xd7c63b9c,0xccee36e4,0xe196216c,0xfabe2c14,0xbb660e7c,0xa04e0304,0x8d36148c,0x961e19f4, - 0xa5cb3ad3,0xbee337ab,0x939b2023,0x88b32d5b,0xc96b0f33,0xd243024b,0xff3b15c3,0xe41318bb, - 0x7c8b5113,0x67a35c6b,0x4adb4be3,0x51f3469b,0x102b64f3,0x0b03698b,0x267b7e03,0x3d53737b, - 0x138af0e4,0x08a2fd9c,0x25daea14,0x3ef2e76c,0x7f2ac504,0x6402c87c,0x497adff4,0x5252d28c, - 0xcaca9b24,0xd1e2965c,0xfc9a81d4,0xe7b28cac,0xa66aaec4,0xbd42a3bc,0x903ab434,0x8b12b94c, - 0xcd89b30a,0xd6a1be72,0xfbd9a9fa,0xe0f1a482,0xa12986ea,0xba018b92,0x97799c1a,0x8c519162, - 0x14c9d8ca,0x0fe1d5b2,0x2299c23a,0x39b1cf42,0x7869ed2a,0x6341e052,0x4e39f7da,0x5511faa2, - 0x7bc8793d,0x60e07445,0x4d9863cd,0x56b06eb5,0x17684cdd,0x0c4041a5,0x2138562d,0x3a105b55, - 0xa28812fd,0xb9a01f85,0x94d8080d,0x8ff00575,0xce28271d,0xd5002a65,0xf8783ded,0xe3503095, - 0x754e2961,0x6e662419,0x431e3391,0x58363ee9,0x19ee1c81,0x02c611f9,0x2fbe0671,0x34960b09, - 0xac0e42a1,0xb7264fd9,0x9a5e5851,0x81765529,0xc0ae7741,0xdb867a39,0xf6fe6db1,0xedd660c9, - 0xc30fe356,0xd827ee2e,0xf55ff9a6,0xee77f4de,0xafafd6b6,0xb487dbce,0x99ffcc46,0x82d7c13e, - 0x1a4f8896,0x016785ee,0x2c1f9266,0x37379f1e,0x76efbd76,0x6dc7b00e,0x40bfa786,0x5b97aafe, - 0x1d0ca0b8,0x0624adc0,0x2b5cba48,0x3074b730,0x71ac9558,0x6a849820,0x47fc8fa8,0x5cd482d0, - 0xc44ccb78,0xdf64c600,0xf21cd188,0xe934dcf0,0xa8ecfe98,0xb3c4f3e0,0x9ebce468,0x8594e910, - 0xab4d6a8f,0xb06567f7,0x9d1d707f,0x86357d07,0xc7ed5f6f,0xdcc55217,0xf1bd459f,0xea9548e7, - 0x720d014f,0x69250c37,0x445d1bbf,0x5f7516c7,0x1ead34af,0x058539d7,0x28fd2e5f,0x33d52327}, - -{0x00000000,0x4f576811,0x9eaed022,0xd1f9b833,0x399cbdf3,0x76cbd5e2,0xa7326dd1,0xe86505c0, - 0x73397be6,0x3c6e13f7,0xed97abc4,0xa2c0c3d5,0x4aa5c615,0x05f2ae04,0xd40b1637,0x9b5c7e26, - 0xe672f7cc,0xa9259fdd,0x78dc27ee,0x378b4fff,0xdfee4a3f,0x90b9222e,0x41409a1d,0x0e17f20c, - 0x954b8c2a,0xda1ce43b,0x0be55c08,0x44b23419,0xacd731d9,0xe38059c8,0x3279e1fb,0x7d2e89ea, - 0xc824f22f,0x87739a3e,0x568a220d,0x19dd4a1c,0xf1b84fdc,0xbeef27cd,0x6f169ffe,0x2041f7ef, - 0xbb1d89c9,0xf44ae1d8,0x25b359eb,0x6ae431fa,0x8281343a,0xcdd65c2b,0x1c2fe418,0x53788c09, - 0x2e5605e3,0x61016df2,0xb0f8d5c1,0xffafbdd0,0x17cab810,0x589dd001,0x89646832,0xc6330023, - 0x5d6f7e05,0x12381614,0xc3c1ae27,0x8c96c636,0x64f3c3f6,0x2ba4abe7,0xfa5d13d4,0xb50a7bc5, - 0x9488f9e9,0xdbdf91f8,0x0a2629cb,0x457141da,0xad14441a,0xe2432c0b,0x33ba9438,0x7cedfc29, - 0xe7b1820f,0xa8e6ea1e,0x791f522d,0x36483a3c,0xde2d3ffc,0x917a57ed,0x4083efde,0x0fd487cf, - 0x72fa0e25,0x3dad6634,0xec54de07,0xa303b616,0x4b66b3d6,0x0431dbc7,0xd5c863f4,0x9a9f0be5, - 0x01c375c3,0x4e941dd2,0x9f6da5e1,0xd03acdf0,0x385fc830,0x7708a021,0xa6f11812,0xe9a67003, - 0x5cac0bc6,0x13fb63d7,0xc202dbe4,0x8d55b3f5,0x6530b635,0x2a67de24,0xfb9e6617,0xb4c90e06, - 0x2f957020,0x60c21831,0xb13ba002,0xfe6cc813,0x1609cdd3,0x595ea5c2,0x88a71df1,0xc7f075e0, - 0xbadefc0a,0xf589941b,0x24702c28,0x6b274439,0x834241f9,0xcc1529e8,0x1dec91db,0x52bbf9ca, - 0xc9e787ec,0x86b0effd,0x574957ce,0x181e3fdf,0xf07b3a1f,0xbf2c520e,0x6ed5ea3d,0x2182822c, - 0x2dd0ee65,0x62878674,0xb37e3e47,0xfc295656,0x144c5396,0x5b1b3b87,0x8ae283b4,0xc5b5eba5, - 0x5ee99583,0x11befd92,0xc04745a1,0x8f102db0,0x67752870,0x28224061,0xf9dbf852,0xb68c9043, - 0xcba219a9,0x84f571b8,0x550cc98b,0x1a5ba19a,0xf23ea45a,0xbd69cc4b,0x6c907478,0x23c71c69, - 0xb89b624f,0xf7cc0a5e,0x2635b26d,0x6962da7c,0x8107dfbc,0xce50b7ad,0x1fa90f9e,0x50fe678f, - 0xe5f41c4a,0xaaa3745b,0x7b5acc68,0x340da479,0xdc68a1b9,0x933fc9a8,0x42c6719b,0x0d91198a, - 0x96cd67ac,0xd99a0fbd,0x0863b78e,0x4734df9f,0xaf51da5f,0xe006b24e,0x31ff0a7d,0x7ea8626c, - 0x0386eb86,0x4cd18397,0x9d283ba4,0xd27f53b5,0x3a1a5675,0x754d3e64,0xa4b48657,0xebe3ee46, - 0x70bf9060,0x3fe8f871,0xee114042,0xa1462853,0x49232d93,0x06744582,0xd78dfdb1,0x98da95a0, - 0xb958178c,0xf60f7f9d,0x27f6c7ae,0x68a1afbf,0x80c4aa7f,0xcf93c26e,0x1e6a7a5d,0x513d124c, - 0xca616c6a,0x8536047b,0x54cfbc48,0x1b98d459,0xf3fdd199,0xbcaab988,0x6d5301bb,0x220469aa, - 0x5f2ae040,0x107d8851,0xc1843062,0x8ed35873,0x66b65db3,0x29e135a2,0xf8188d91,0xb74fe580, - 0x2c139ba6,0x6344f3b7,0xb2bd4b84,0xfdea2395,0x158f2655,0x5ad84e44,0x8b21f677,0xc4769e66, - 0x717ce5a3,0x3e2b8db2,0xefd23581,0xa0855d90,0x48e05850,0x07b73041,0xd64e8872,0x9919e063, - 0x02459e45,0x4d12f654,0x9ceb4e67,0xd3bc2676,0x3bd923b6,0x748e4ba7,0xa577f394,0xea209b85, - 0x970e126f,0xd8597a7e,0x09a0c24d,0x46f7aa5c,0xae92af9c,0xe1c5c78d,0x303c7fbe,0x7f6b17af, - 0xe4376989,0xab600198,0x7a99b9ab,0x35ced1ba,0xddabd47a,0x92fcbc6b,0x43050458,0x0c526c49}, - -{0x00000000,0x5ba1dcca,0xb743b994,0xece2655e,0x6a466e9f,0x31e7b255,0xdd05d70b,0x86a40bc1, - 0xd48cdd3e,0x8f2d01f4,0x63cf64aa,0x386eb860,0xbecab3a1,0xe56b6f6b,0x09890a35,0x5228d6ff, - 0xadd8a7cb,0xf6797b01,0x1a9b1e5f,0x413ac295,0xc79ec954,0x9c3f159e,0x70dd70c0,0x2b7cac0a, - 0x79547af5,0x22f5a63f,0xce17c361,0x95b61fab,0x1312146a,0x48b3c8a0,0xa451adfe,0xfff07134, - 0x5f705221,0x04d18eeb,0xe833ebb5,0xb392377f,0x35363cbe,0x6e97e074,0x8275852a,0xd9d459e0, - 0x8bfc8f1f,0xd05d53d5,0x3cbf368b,0x671eea41,0xe1bae180,0xba1b3d4a,0x56f95814,0x0d5884de, - 0xf2a8f5ea,0xa9092920,0x45eb4c7e,0x1e4a90b4,0x98ee9b75,0xc34f47bf,0x2fad22e1,0x740cfe2b, - 0x262428d4,0x7d85f41e,0x91679140,0xcac64d8a,0x4c62464b,0x17c39a81,0xfb21ffdf,0xa0802315, - 0xbee0a442,0xe5417888,0x09a31dd6,0x5202c11c,0xd4a6cadd,0x8f071617,0x63e57349,0x3844af83, - 0x6a6c797c,0x31cda5b6,0xdd2fc0e8,0x868e1c22,0x002a17e3,0x5b8bcb29,0xb769ae77,0xecc872bd, - 0x13380389,0x4899df43,0xa47bba1d,0xffda66d7,0x797e6d16,0x22dfb1dc,0xce3dd482,0x959c0848, - 0xc7b4deb7,0x9c15027d,0x70f76723,0x2b56bbe9,0xadf2b028,0xf6536ce2,0x1ab109bc,0x4110d576, - 0xe190f663,0xba312aa9,0x56d34ff7,0x0d72933d,0x8bd698fc,0xd0774436,0x3c952168,0x6734fda2, - 0x351c2b5d,0x6ebdf797,0x825f92c9,0xd9fe4e03,0x5f5a45c2,0x04fb9908,0xe819fc56,0xb3b8209c, - 0x4c4851a8,0x17e98d62,0xfb0be83c,0xa0aa34f6,0x260e3f37,0x7dafe3fd,0x914d86a3,0xcaec5a69, - 0x98c48c96,0xc365505c,0x2f873502,0x7426e9c8,0xf282e209,0xa9233ec3,0x45c15b9d,0x1e608757, - 0x79005533,0x22a189f9,0xce43eca7,0x95e2306d,0x13463bac,0x48e7e766,0xa4058238,0xffa45ef2, - 0xad8c880d,0xf62d54c7,0x1acf3199,0x416eed53,0xc7cae692,0x9c6b3a58,0x70895f06,0x2b2883cc, - 0xd4d8f2f8,0x8f792e32,0x639b4b6c,0x383a97a6,0xbe9e9c67,0xe53f40ad,0x09dd25f3,0x527cf939, - 0x00542fc6,0x5bf5f30c,0xb7179652,0xecb64a98,0x6a124159,0x31b39d93,0xdd51f8cd,0x86f02407, - 0x26700712,0x7dd1dbd8,0x9133be86,0xca92624c,0x4c36698d,0x1797b547,0xfb75d019,0xa0d40cd3, - 0xf2fcda2c,0xa95d06e6,0x45bf63b8,0x1e1ebf72,0x98bab4b3,0xc31b6879,0x2ff90d27,0x7458d1ed, - 0x8ba8a0d9,0xd0097c13,0x3ceb194d,0x674ac587,0xe1eece46,0xba4f128c,0x56ad77d2,0x0d0cab18, - 0x5f247de7,0x0485a12d,0xe867c473,0xb3c618b9,0x35621378,0x6ec3cfb2,0x8221aaec,0xd9807626, - 0xc7e0f171,0x9c412dbb,0x70a348e5,0x2b02942f,0xada69fee,0xf6074324,0x1ae5267a,0x4144fab0, - 0x136c2c4f,0x48cdf085,0xa42f95db,0xff8e4911,0x792a42d0,0x228b9e1a,0xce69fb44,0x95c8278e, - 0x6a3856ba,0x31998a70,0xdd7bef2e,0x86da33e4,0x007e3825,0x5bdfe4ef,0xb73d81b1,0xec9c5d7b, - 0xbeb48b84,0xe515574e,0x09f73210,0x5256eeda,0xd4f2e51b,0x8f5339d1,0x63b15c8f,0x38108045, - 0x9890a350,0xc3317f9a,0x2fd31ac4,0x7472c60e,0xf2d6cdcf,0xa9771105,0x4595745b,0x1e34a891, - 0x4c1c7e6e,0x17bda2a4,0xfb5fc7fa,0xa0fe1b30,0x265a10f1,0x7dfbcc3b,0x9119a965,0xcab875af, - 0x3548049b,0x6ee9d851,0x820bbd0f,0xd9aa61c5,0x5f0e6a04,0x04afb6ce,0xe84dd390,0xb3ec0f5a, - 0xe1c4d9a5,0xba65056f,0x56876031,0x0d26bcfb,0x8b82b73a,0xd0236bf0,0x3cc10eae,0x6760d264}}; diff --git a/Engine/lib/libogg/src/framing.c b/Engine/lib/libogg/src/framing.c deleted file mode 100644 index 0ddf0fcf8..000000000 --- a/Engine/lib/libogg/src/framing.c +++ /dev/null @@ -1,2138 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE Ogg CONTAINER SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2018 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: code raw packets into framed OggSquish stream and - decode Ogg streams back into raw packets - - note: The CRC code is directly derived from public domain code by - Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html - for details. - - ********************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include - -/* A complete description of Ogg framing exists in docs/framing.html */ - -int ogg_page_version(const ogg_page *og){ - return((int)(og->header[4])); -} - -int ogg_page_continued(const ogg_page *og){ - return((int)(og->header[5]&0x01)); -} - -int ogg_page_bos(const ogg_page *og){ - return((int)(og->header[5]&0x02)); -} - -int ogg_page_eos(const ogg_page *og){ - return((int)(og->header[5]&0x04)); -} - -ogg_int64_t ogg_page_granulepos(const ogg_page *og){ - unsigned char *page=og->header; - ogg_uint64_t granulepos=page[13]&(0xff); - granulepos= (granulepos<<8)|(page[12]&0xff); - granulepos= (granulepos<<8)|(page[11]&0xff); - granulepos= (granulepos<<8)|(page[10]&0xff); - granulepos= (granulepos<<8)|(page[9]&0xff); - granulepos= (granulepos<<8)|(page[8]&0xff); - granulepos= (granulepos<<8)|(page[7]&0xff); - granulepos= (granulepos<<8)|(page[6]&0xff); - return((ogg_int64_t)granulepos); -} - -int ogg_page_serialno(const ogg_page *og){ - return((int)((ogg_uint32_t)og->header[14]) | - ((ogg_uint32_t)og->header[15]<<8) | - ((ogg_uint32_t)og->header[16]<<16) | - ((ogg_uint32_t)og->header[17]<<24)); -} - -long ogg_page_pageno(const ogg_page *og){ - return((long)((ogg_uint32_t)og->header[18]) | - ((ogg_uint32_t)og->header[19]<<8) | - ((ogg_uint32_t)og->header[20]<<16) | - ((ogg_uint32_t)og->header[21]<<24)); -} - - - -/* returns the number of packets that are completed on this page (if - the leading packet is begun on a previous page, but ends on this - page, it's counted */ - -/* NOTE: - If a page consists of a packet begun on a previous page, and a new - packet begun (but not completed) on this page, the return will be: - ogg_page_packets(page) ==1, - ogg_page_continued(page) !=0 - - If a page happens to be a single packet that was begun on a - previous page, and spans to the next page (in the case of a three or - more page packet), the return will be: - ogg_page_packets(page) ==0, - ogg_page_continued(page) !=0 -*/ - -int ogg_page_packets(const ogg_page *og){ - int i,n=og->header[26],count=0; - for(i=0;iheader[27+i]<255)count++; - return(count); -} - - -#if 0 -/* helper to initialize lookup for direct-table CRC (illustrative; we - use the static init in crctable.h) */ - -static void _ogg_crc_init(){ - int i, j; - ogg_uint32_t polynomial, crc; - polynomial = 0x04c11db7; /* The same as the ethernet generator - polynomial, although we use an - unreflected alg and an init/final - of 0, not 0xffffffff */ - for (i = 0; i <= 0xFF; i++){ - crc = i << 24; - - for (j = 0; j < 8; j++) - crc = (crc << 1) ^ (crc & (1 << 31) ? polynomial : 0); - - crc_lookup[0][i] = crc; - } - - for (i = 0; i <= 0xFF; i++) - for (j = 1; j < 8; j++) - crc_lookup[j][i] = crc_lookup[0][(crc_lookup[j - 1][i] >> 24) & 0xFF] ^ (crc_lookup[j - 1][i] << 8); -} -#endif - -#include "crctable.h" - -/* init the encode/decode logical stream state */ - -int ogg_stream_init(ogg_stream_state *os,int serialno){ - if(os){ - memset(os,0,sizeof(*os)); - os->body_storage=16*1024; - os->lacing_storage=1024; - - os->body_data=_ogg_malloc(os->body_storage*sizeof(*os->body_data)); - os->lacing_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals)); - os->granule_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals)); - - if(!os->body_data || !os->lacing_vals || !os->granule_vals){ - ogg_stream_clear(os); - return -1; - } - - os->serialno=serialno; - - return(0); - } - return(-1); -} - -/* async/delayed error detection for the ogg_stream_state */ -int ogg_stream_check(ogg_stream_state *os){ - if(!os || !os->body_data) return -1; - return 0; -} - -/* _clear does not free os, only the non-flat storage within */ -int ogg_stream_clear(ogg_stream_state *os){ - if(os){ - if(os->body_data)_ogg_free(os->body_data); - if(os->lacing_vals)_ogg_free(os->lacing_vals); - if(os->granule_vals)_ogg_free(os->granule_vals); - - memset(os,0,sizeof(*os)); - } - return(0); -} - -int ogg_stream_destroy(ogg_stream_state *os){ - if(os){ - ogg_stream_clear(os); - _ogg_free(os); - } - return(0); -} - -/* Helpers for ogg_stream_encode; this keeps the structure and - what's happening fairly clear */ - -static int _os_body_expand(ogg_stream_state *os,long needed){ - if(os->body_storage-needed<=os->body_fill){ - long body_storage; - void *ret; - if(os->body_storage>LONG_MAX-needed){ - ogg_stream_clear(os); - return -1; - } - body_storage=os->body_storage+needed; - if(body_storagebody_data,body_storage*sizeof(*os->body_data)); - if(!ret){ - ogg_stream_clear(os); - return -1; - } - os->body_storage=body_storage; - os->body_data=ret; - } - return 0; -} - -static int _os_lacing_expand(ogg_stream_state *os,long needed){ - if(os->lacing_storage-needed<=os->lacing_fill){ - long lacing_storage; - void *ret; - if(os->lacing_storage>LONG_MAX-needed){ - ogg_stream_clear(os); - return -1; - } - lacing_storage=os->lacing_storage+needed; - if(lacing_storagelacing_vals,lacing_storage*sizeof(*os->lacing_vals)); - if(!ret){ - ogg_stream_clear(os); - return -1; - } - os->lacing_vals=ret; - ret=_ogg_realloc(os->granule_vals,lacing_storage* - sizeof(*os->granule_vals)); - if(!ret){ - ogg_stream_clear(os); - return -1; - } - os->granule_vals=ret; - os->lacing_storage=lacing_storage; - } - return 0; -} - -/* checksum the page */ -/* Direct table CRC; note that this will be faster in the future if we - perform the checksum simultaneously with other copies */ - -static ogg_uint32_t _os_update_crc(ogg_uint32_t crc, unsigned char *buffer, int size){ - while (size>=8){ - crc^=((ogg_uint32_t)buffer[0]<<24)|((ogg_uint32_t)buffer[1]<<16)|((ogg_uint32_t)buffer[2]<<8)|((ogg_uint32_t)buffer[3]); - - crc=crc_lookup[7][ crc>>24 ]^crc_lookup[6][(crc>>16)&0xFF]^ - crc_lookup[5][(crc>> 8)&0xFF]^crc_lookup[4][ crc &0xFF]^ - crc_lookup[3][buffer[4] ]^crc_lookup[2][buffer[5] ]^ - crc_lookup[1][buffer[6] ]^crc_lookup[0][buffer[7] ]; - - buffer+=8; - size-=8; - } - - while (size--) - crc=(crc<<8)^crc_lookup[0][((crc >> 24)&0xff)^*buffer++]; - return crc; -} - -void ogg_page_checksum_set(ogg_page *og){ - if(og){ - ogg_uint32_t crc_reg=0; - - /* safety; needed for API behavior, but not framing code */ - og->header[22]=0; - og->header[23]=0; - og->header[24]=0; - og->header[25]=0; - - crc_reg=_os_update_crc(crc_reg,og->header,og->header_len); - crc_reg=_os_update_crc(crc_reg,og->body,og->body_len); - - og->header[22]=(unsigned char)(crc_reg&0xff); - og->header[23]=(unsigned char)((crc_reg>>8)&0xff); - og->header[24]=(unsigned char)((crc_reg>>16)&0xff); - og->header[25]=(unsigned char)((crc_reg>>24)&0xff); - } -} - -/* submit data to the internal buffer of the framing engine */ -int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, int count, - long e_o_s, ogg_int64_t granulepos){ - - long bytes = 0, lacing_vals; - int i; - - if(ogg_stream_check(os)) return -1; - if(!iov) return 0; - - for (i = 0; i < count; ++i){ - if(iov[i].iov_len>LONG_MAX) return -1; - if(bytes>LONG_MAX-(long)iov[i].iov_len) return -1; - bytes += (long)iov[i].iov_len; - } - lacing_vals=bytes/255+1; - - if(os->body_returned){ - /* advance packet data according to the body_returned pointer. We - had to keep it around to return a pointer into the buffer last - call */ - - os->body_fill-=os->body_returned; - if(os->body_fill) - memmove(os->body_data,os->body_data+os->body_returned, - os->body_fill); - os->body_returned=0; - } - - /* make sure we have the buffer storage */ - if(_os_body_expand(os,bytes) || _os_lacing_expand(os,lacing_vals)) - return -1; - - /* Copy in the submitted packet. Yes, the copy is a waste; this is - the liability of overly clean abstraction for the time being. It - will actually be fairly easy to eliminate the extra copy in the - future */ - - for (i = 0; i < count; ++i) { - memcpy(os->body_data+os->body_fill, iov[i].iov_base, iov[i].iov_len); - os->body_fill += (int)iov[i].iov_len; - } - - /* Store lacing vals for this packet */ - for(i=0;ilacing_vals[os->lacing_fill+i]=255; - os->granule_vals[os->lacing_fill+i]=os->granulepos; - } - os->lacing_vals[os->lacing_fill+i]=bytes%255; - os->granulepos=os->granule_vals[os->lacing_fill+i]=granulepos; - - /* flag the first segment as the beginning of the packet */ - os->lacing_vals[os->lacing_fill]|= 0x100; - - os->lacing_fill+=lacing_vals; - - /* for the sake of completeness */ - os->packetno++; - - if(e_o_s)os->e_o_s=1; - - return(0); -} - -int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){ - ogg_iovec_t iov; - iov.iov_base = op->packet; - iov.iov_len = op->bytes; - return ogg_stream_iovecin(os, &iov, 1, op->e_o_s, op->granulepos); -} - -/* Conditionally flush a page; force==0 will only flush nominal-size - pages, force==1 forces us to flush a page regardless of page size - so long as there's any data available at all. */ -static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force, int nfill){ - int i; - int vals=0; - int maxvals; - int bytes=0; - long acc=0; - ogg_int64_t granule_pos=-1; - - if(ogg_stream_check(os)) return(0); - maxvals=(os->lacing_fill>255?255:os->lacing_fill); - if(maxvals==0) return(0); - - /* construct a page */ - /* decide how many segments to include */ - - /* If this is the initial header case, the first page must only include - the initial header packet */ - if(os->b_o_s==0){ /* 'initial header page' case */ - granule_pos=0; - for(vals=0;valslacing_vals[vals]&0x0ff)<255){ - vals++; - break; - } - } - }else{ - - /* The extra packets_done, packet_just_done logic here attempts to do two things: - 1) Don't unnecessarily span pages. - 2) Unless necessary, don't flush pages if there are less than four packets on - them; this expands page size to reduce unnecessary overhead if incoming packets - are large. - These are not necessary behaviors, just 'always better than naive flushing' - without requiring an application to explicitly request a specific optimized - behavior. We'll want an explicit behavior setup pathway eventually as well. */ - - int packets_done=0; - int packet_just_done=0; - for(vals=0;valsnfill && packet_just_done>=4){ - force=1; - break; - } - acc+=os->lacing_vals[vals]&0x0ff; - if((os->lacing_vals[vals]&0xff)<255){ - granule_pos=os->granule_vals[vals]; - packet_just_done=++packets_done; - }else - packet_just_done=0; - } - if(vals==255)force=1; - } - - if(!force) return(0); - - /* construct the header in temp storage */ - memcpy(os->header,"OggS",4); - - /* stream structure version */ - os->header[4]=0x00; - - /* continued packet flag? */ - os->header[5]=0x00; - if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01; - /* first page flag? */ - if(os->b_o_s==0)os->header[5]|=0x02; - /* last page flag? */ - if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04; - os->b_o_s=1; - - /* 64 bits of PCM position */ - for(i=6;i<14;i++){ - os->header[i]=(unsigned char)(granule_pos&0xff); - granule_pos>>=8; - } - - /* 32 bits of stream serial number */ - { - long serialno=os->serialno; - for(i=14;i<18;i++){ - os->header[i]=(unsigned char)(serialno&0xff); - serialno>>=8; - } - } - - /* 32 bits of page counter (we have both counter and page header - because this val can roll over) */ - if(os->pageno==-1)os->pageno=0; /* because someone called - stream_reset; this would be a - strange thing to do in an - encode stream, but it has - plausible uses */ - { - long pageno=os->pageno++; - for(i=18;i<22;i++){ - os->header[i]=(unsigned char)(pageno&0xff); - pageno>>=8; - } - } - - /* zero for computation; filled in later */ - os->header[22]=0; - os->header[23]=0; - os->header[24]=0; - os->header[25]=0; - - /* segment table */ - os->header[26]=(unsigned char)(vals&0xff); - for(i=0;iheader[i+27]=(unsigned char)(os->lacing_vals[i]&0xff); - - /* set pointers in the ogg_page struct */ - og->header=os->header; - og->header_len=os->header_fill=vals+27; - og->body=os->body_data+os->body_returned; - og->body_len=bytes; - - /* advance the lacing data and set the body_returned pointer */ - - os->lacing_fill-=vals; - memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals)); - memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals)); - os->body_returned+=bytes; - - /* calculate the checksum */ - - ogg_page_checksum_set(og); - - /* done */ - return(1); -} - -/* This will flush remaining packets into a page (returning nonzero), - even if there is not enough data to trigger a flush normally - (undersized page). If there are no packets or partial packets to - flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will - try to flush a normal sized page like ogg_stream_pageout; a call to - ogg_stream_flush does not guarantee that all packets have flushed. - Only a return value of 0 from ogg_stream_flush indicates all packet - data is flushed into pages. - - since ogg_stream_flush will flush the last page in a stream even if - it's undersized, you almost certainly want to use ogg_stream_pageout - (and *not* ogg_stream_flush) unless you specifically need to flush - a page regardless of size in the middle of a stream. */ - -int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){ - return ogg_stream_flush_i(os,og,1,4096); -} - -/* Like the above, but an argument is provided to adjust the nominal - page size for applications which are smart enough to provide their - own delay based flushing */ - -int ogg_stream_flush_fill(ogg_stream_state *os,ogg_page *og, int nfill){ - return ogg_stream_flush_i(os,og,1,nfill); -} - -/* This constructs pages from buffered packet segments. The pointers -returned are to static buffers; do not free. The returned buffers are -good only until the next call (using the same ogg_stream_state) */ - -int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){ - int force=0; - if(ogg_stream_check(os)) return 0; - - if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ - (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */ - force=1; - - return(ogg_stream_flush_i(os,og,force,4096)); -} - -/* Like the above, but an argument is provided to adjust the nominal -page size for applications which are smart enough to provide their -own delay based flushing */ - -int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill){ - int force=0; - if(ogg_stream_check(os)) return 0; - - if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ - (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */ - force=1; - - return(ogg_stream_flush_i(os,og,force,nfill)); -} - -int ogg_stream_eos(ogg_stream_state *os){ - if(ogg_stream_check(os)) return 1; - return os->e_o_s; -} - -/* DECODING PRIMITIVES: packet streaming layer **********************/ - -/* This has two layers to place more of the multi-serialno and paging - control in the application's hands. First, we expose a data buffer - using ogg_sync_buffer(). The app either copies into the - buffer, or passes it directly to read(), etc. We then call - ogg_sync_wrote() to tell how many bytes we just added. - - Pages are returned (pointers into the buffer in ogg_sync_state) - by ogg_sync_pageout(). The page is then submitted to - ogg_stream_pagein() along with the appropriate - ogg_stream_state* (ie, matching serialno). We then get raw - packets out calling ogg_stream_packetout() with a - ogg_stream_state. */ - -/* initialize the struct to a known state */ -int ogg_sync_init(ogg_sync_state *oy){ - if(oy){ - oy->storage = -1; /* used as a readiness flag */ - memset(oy,0,sizeof(*oy)); - } - return(0); -} - -/* clear non-flat storage within */ -int ogg_sync_clear(ogg_sync_state *oy){ - if(oy){ - if(oy->data)_ogg_free(oy->data); - memset(oy,0,sizeof(*oy)); - } - return(0); -} - -int ogg_sync_destroy(ogg_sync_state *oy){ - if(oy){ - ogg_sync_clear(oy); - _ogg_free(oy); - } - return(0); -} - -int ogg_sync_check(ogg_sync_state *oy){ - if(oy->storage<0) return -1; - return 0; -} - -char *ogg_sync_buffer(ogg_sync_state *oy, long size){ - if(ogg_sync_check(oy)) return NULL; - - /* first, clear out any space that has been previously returned */ - if(oy->returned){ - oy->fill-=oy->returned; - if(oy->fill>0) - memmove(oy->data,oy->data+oy->returned,oy->fill); - oy->returned=0; - } - - if(size>oy->storage-oy->fill){ - /* We need to extend the internal buffer */ - long newsize; - void *ret; - - if(size>INT_MAX-4096-oy->fill){ - ogg_sync_clear(oy); - return NULL; - } - newsize=size+oy->fill+4096; /* an extra page to be nice */ - if(oy->data) - ret=_ogg_realloc(oy->data,newsize); - else - ret=_ogg_malloc(newsize); - if(!ret){ - ogg_sync_clear(oy); - return NULL; - } - oy->data=ret; - oy->storage=newsize; - } - - /* expose a segment at least as large as requested at the fill mark */ - return((char *)oy->data+oy->fill); -} - -int ogg_sync_wrote(ogg_sync_state *oy, long bytes){ - if(ogg_sync_check(oy))return -1; - if(oy->fill+bytes>oy->storage)return -1; - oy->fill+=bytes; - return(0); -} - -/* sync the stream. This is meant to be useful for finding page - boundaries. - - return values for this: - -n) skipped n bytes - 0) page not ready; more data (no bytes skipped) - n) page synced at current location; page length n bytes - -*/ - -long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){ - unsigned char *page; - unsigned char *next; - long bytes; - - if(ogg_sync_check(oy))return 0; - - page=oy->data+oy->returned; - bytes=oy->fill-oy->returned; - - if(oy->headerbytes==0){ - int headerbytes,i; - if(bytes<27)return(0); /* not enough for a header */ - - /* verify capture pattern */ - if(memcmp(page,"OggS",4))goto sync_fail; - - headerbytes=page[26]+27; - if(bytesbodybytes+=page[27+i]; - oy->headerbytes=headerbytes; - } - - if(oy->bodybytes+oy->headerbytes>bytes)return(0); - - /* The whole test page is buffered. Verify the checksum */ - { - /* Grab the checksum bytes, set the header field to zero */ - char chksum[4]; - ogg_page log; - - memcpy(chksum,page+22,4); - memset(page+22,0,4); - - /* set up a temp page struct and recompute the checksum */ - log.header=page; - log.header_len=oy->headerbytes; - log.body=page+oy->headerbytes; - log.body_len=oy->bodybytes; - ogg_page_checksum_set(&log); - - /* Compare */ - if(memcmp(chksum,page+22,4)){ - /* D'oh. Mismatch! Corrupt page (or miscapture and not a page - at all) */ - /* replace the computed checksum with the one actually read in */ - memcpy(page+22,chksum,4); - -#ifndef DISABLE_CRC - /* Bad checksum. Lose sync */ - goto sync_fail; -#endif - } - } - - /* yes, have a whole page all ready to go */ - { - if(og){ - og->header=page; - og->header_len=oy->headerbytes; - og->body=page+oy->headerbytes; - og->body_len=oy->bodybytes; - } - - oy->unsynced=0; - oy->returned+=(bytes=oy->headerbytes+oy->bodybytes); - oy->headerbytes=0; - oy->bodybytes=0; - return(bytes); - } - - sync_fail: - - oy->headerbytes=0; - oy->bodybytes=0; - - /* search for possible capture */ - next=memchr(page+1,'O',bytes-1); - if(!next) - next=oy->data+oy->fill; - - oy->returned=(int)(next-oy->data); - return((long)-(next-page)); -} - -/* sync the stream and get a page. Keep trying until we find a page. - Suppress 'sync errors' after reporting the first. - - return values: - -1) recapture (hole in data) - 0) need more data - 1) page returned - - Returns pointers into buffered data; invalidated by next call to - _stream, _clear, _init, or _buffer */ - -int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){ - - if(ogg_sync_check(oy))return 0; - - /* all we need to do is verify a page at the head of the stream - buffer. If it doesn't verify, we look for the next potential - frame */ - - for(;;){ - long ret=ogg_sync_pageseek(oy,og); - if(ret>0){ - /* have a page */ - return(1); - } - if(ret==0){ - /* need more data */ - return(0); - } - - /* head did not start a synced page... skipped some bytes */ - if(!oy->unsynced){ - oy->unsynced=1; - return(-1); - } - - /* loop. keep looking */ - - } -} - -/* add the incoming page to the stream state; we decompose the page - into packet segments here as well. */ - -int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og){ - unsigned char *header=og->header; - unsigned char *body=og->body; - long bodysize=og->body_len; - int segptr=0; - - int version=ogg_page_version(og); - int continued=ogg_page_continued(og); - int bos=ogg_page_bos(og); - int eos=ogg_page_eos(og); - ogg_int64_t granulepos=ogg_page_granulepos(og); - int serialno=ogg_page_serialno(og); - long pageno=ogg_page_pageno(og); - int segments=header[26]; - - if(ogg_stream_check(os)) return -1; - - /* clean up 'returned data' */ - { - long lr=os->lacing_returned; - long br=os->body_returned; - - /* body data */ - if(br){ - os->body_fill-=br; - if(os->body_fill) - memmove(os->body_data,os->body_data+br,os->body_fill); - os->body_returned=0; - } - - if(lr){ - /* segment table */ - if(os->lacing_fill-lr){ - memmove(os->lacing_vals,os->lacing_vals+lr, - (os->lacing_fill-lr)*sizeof(*os->lacing_vals)); - memmove(os->granule_vals,os->granule_vals+lr, - (os->lacing_fill-lr)*sizeof(*os->granule_vals)); - } - os->lacing_fill-=lr; - os->lacing_packet-=lr; - os->lacing_returned=0; - } - } - - /* check the serial number */ - if(serialno!=os->serialno)return(-1); - if(version>0)return(-1); - - if(_os_lacing_expand(os,segments+1)) return -1; - - /* are we in sequence? */ - if(pageno!=os->pageno){ - int i; - - /* unroll previous partial packet (if any) */ - for(i=os->lacing_packet;ilacing_fill;i++) - os->body_fill-=os->lacing_vals[i]&0xff; - os->lacing_fill=os->lacing_packet; - - /* make a note of dropped data in segment table */ - if(os->pageno!=-1){ - os->lacing_vals[os->lacing_fill++]=0x400; - os->lacing_packet++; - } - } - - /* are we a 'continued packet' page? If so, we may need to skip - some segments */ - if(continued){ - if(os->lacing_fill<1 || - (os->lacing_vals[os->lacing_fill-1]&0xff)<255 || - os->lacing_vals[os->lacing_fill-1]==0x400){ - bos=0; - for(;segptrbody_data+os->body_fill,body,bodysize); - os->body_fill+=bodysize; - } - - { - int saved=-1; - while(segptrlacing_vals[os->lacing_fill]=val; - os->granule_vals[os->lacing_fill]=-1; - - if(bos){ - os->lacing_vals[os->lacing_fill]|=0x100; - bos=0; - } - - if(val<255)saved=os->lacing_fill; - - os->lacing_fill++; - segptr++; - - if(val<255)os->lacing_packet=os->lacing_fill; - } - - /* set the granulepos on the last granuleval of the last full packet */ - if(saved!=-1){ - os->granule_vals[saved]=granulepos; - } - - } - - if(eos){ - os->e_o_s=1; - if(os->lacing_fill>0) - os->lacing_vals[os->lacing_fill-1]|=0x200; - } - - os->pageno=pageno+1; - - return(0); -} - -/* clear things to an initial state. Good to call, eg, before seeking */ -int ogg_sync_reset(ogg_sync_state *oy){ - if(ogg_sync_check(oy))return -1; - - oy->fill=0; - oy->returned=0; - oy->unsynced=0; - oy->headerbytes=0; - oy->bodybytes=0; - return(0); -} - -int ogg_stream_reset(ogg_stream_state *os){ - if(ogg_stream_check(os)) return -1; - - os->body_fill=0; - os->body_returned=0; - - os->lacing_fill=0; - os->lacing_packet=0; - os->lacing_returned=0; - - os->header_fill=0; - - os->e_o_s=0; - os->b_o_s=0; - os->pageno=-1; - os->packetno=0; - os->granulepos=0; - - return(0); -} - -int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno){ - if(ogg_stream_check(os)) return -1; - ogg_stream_reset(os); - os->serialno=serialno; - return(0); -} - -static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){ - - /* The last part of decode. We have the stream broken into packet - segments. Now we need to group them into packets (or return the - out of sync markers) */ - - int ptr=os->lacing_returned; - - if(os->lacing_packet<=ptr)return(0); - - if(os->lacing_vals[ptr]&0x400){ - /* we need to tell the codec there's a gap; it might need to - handle previous packet dependencies. */ - os->lacing_returned++; - os->packetno++; - return(-1); - } - - if(!op && !adv)return(1); /* just using peek as an inexpensive way - to ask if there's a whole packet - waiting */ - - /* Gather the whole packet. We'll have no holes or a partial packet */ - { - int size=os->lacing_vals[ptr]&0xff; - long bytes=size; - int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */ - int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */ - - while(size==255){ - int val=os->lacing_vals[++ptr]; - size=val&0xff; - if(val&0x200)eos=0x200; - bytes+=size; - } - - if(op){ - op->e_o_s=eos; - op->b_o_s=bos; - op->packet=os->body_data+os->body_returned; - op->packetno=os->packetno; - op->granulepos=os->granule_vals[ptr]; - op->bytes=bytes; - } - - if(adv){ - os->body_returned+=bytes; - os->lacing_returned=ptr+1; - os->packetno++; - } - } - return(1); -} - -int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){ - if(ogg_stream_check(os)) return 0; - return _packetout(os,op,1); -} - -int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){ - if(ogg_stream_check(os)) return 0; - return _packetout(os,op,0); -} - -void ogg_packet_clear(ogg_packet *op) { - _ogg_free(op->packet); - memset(op, 0, sizeof(*op)); -} - -#ifdef _V_SELFTEST -#include - -ogg_stream_state os_en, os_de; -ogg_sync_state oy; - -void checkpacket(ogg_packet *op,long len, int no, long pos){ - long j; - static int sequence=0; - static int lastno=0; - - if(op->bytes!=len){ - fprintf(stderr,"incorrect packet length (%ld != %ld)!\n",op->bytes,len); - exit(1); - } - if(op->granulepos!=pos){ - fprintf(stderr,"incorrect packet granpos (%ld != %ld)!\n",(long)op->granulepos,pos); - exit(1); - } - - /* packet number just follows sequence/gap; adjust the input number - for that */ - if(no==0){ - sequence=0; - }else{ - sequence++; - if(no>lastno+1) - sequence++; - } - lastno=no; - if(op->packetno!=sequence){ - fprintf(stderr,"incorrect packet sequence %ld != %d\n", - (long)(op->packetno),sequence); - exit(1); - } - - /* Test data */ - for(j=0;jbytes;j++) - if(op->packet[j]!=((j+no)&0xff)){ - fprintf(stderr,"body data mismatch (1) at pos %ld: %x!=%lx!\n\n", - j,op->packet[j],(j+no)&0xff); - exit(1); - } -} - -void check_page(unsigned char *data,const int *header,ogg_page *og){ - long j; - /* Test data */ - for(j=0;jbody_len;j++) - if(og->body[j]!=data[j]){ - fprintf(stderr,"body data mismatch (2) at pos %ld: %x!=%x!\n\n", - j,data[j],og->body[j]); - exit(1); - } - - /* Test header */ - for(j=0;jheader_len;j++){ - if(og->header[j]!=header[j]){ - fprintf(stderr,"header content mismatch at pos %ld:\n",j); - for(j=0;jheader[j]); - fprintf(stderr,"\n"); - exit(1); - } - } - if(og->header_len!=header[26]+27){ - fprintf(stderr,"header length incorrect! (%ld!=%d)\n", - og->header_len,header[26]+27); - exit(1); - } -} - -void print_header(ogg_page *og){ - int j; - fprintf(stderr,"\nHEADER:\n"); - fprintf(stderr," capture: %c %c %c %c version: %d flags: %x\n", - og->header[0],og->header[1],og->header[2],og->header[3], - (int)og->header[4],(int)og->header[5]); - - fprintf(stderr," granulepos: %d serialno: %d pageno: %ld\n", - ((unsigned)og->header[9]<<24)|(og->header[8]<<16)| - (og->header[7]<<8)|og->header[6], - ((unsigned)og->header[17]<<24)|(og->header[16]<<16)| - (og->header[15]<<8)|og->header[14], - ((long)((unsigned)og->header[21])<<24)|(og->header[20]<<16)| - (og->header[19]<<8)|og->header[18]); - - fprintf(stderr," checksum: %02x:%02x:%02x:%02x\n segments: %d (", - (int)og->header[22],(int)og->header[23], - (int)og->header[24],(int)og->header[25], - (int)og->header[26]); - - for(j=27;jheader_len;j++) - fprintf(stderr,"%d ",(int)og->header[j]); - fprintf(stderr,")\n\n"); -} - -static int copy_page(ogg_page *og){ - unsigned char *temp=_ogg_malloc(og->header_len); - if (!temp) - return -1; - memcpy(temp,og->header,og->header_len); - og->header=temp; - - temp=_ogg_malloc(og->body_len); - if (!temp) - return -1; - memcpy(temp,og->body,og->body_len); - og->body=temp; - return 0; -} - -static void free_page(ogg_page *og){ - _ogg_free (og->header); - og->header=NULL; - _ogg_free (og->body); - og->body=NULL; -} - -void error(void){ - fprintf(stderr,"error!\n"); - exit(1); -} - -/* 17 only */ -const int head1_0[] = {0x4f,0x67,0x67,0x53,0,0x06, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0x15,0xed,0xec,0x91, - 1, - 17}; - -/* 17, 254, 255, 256, 500, 510, 600 byte, pad */ -const int head1_1[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0x59,0x10,0x6c,0x2c, - 1, - 17}; -const int head2_1[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x18,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x89,0x33,0x85,0xce, - 13, - 254,255,0,255,1,255,245,255,255,0, - 255,255,90}; - -/* nil packets; beginning,middle,end */ -const int head1_2[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; -const int head2_2[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x28,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x5c,0x3f,0x66,0xcb, - 17, - 17,254,255,0,0,255,1,0,255,245,255,255,0, - 255,255,90,0}; - -/* large initial packet */ -const int head1_3[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0x01,0x27,0x31,0xaa, - 18, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,10}; - -const int head2_3[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x7f,0x4e,0x8a,0xd2, - 4, - 255,4,255,0}; - - -/* continuing packet test */ -const int head1_4[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_4[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0xf8,0x3c,0x19,0x79, - 255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255}; - -const int head3_4[] = {0x4f,0x67,0x67,0x53,0,0x05, - 0x07,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0x38,0xe6,0xb6,0x28, - 6, - 255,220,255,4,255,0}; - - -/* spill expansion test */ -const int head1_4b[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_4b[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0xce,0x8f,0x17,0x1a, - 23, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,10,255,4,255,0,0}; - - -const int head3_4b[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x14,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0x9b,0xb2,0x50,0xa1, - 1, - 0}; - -/* page with the 255 segment limit */ -const int head1_5[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_5[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0x07,0xfc,0x03,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0xed,0x2a,0x2e,0xa7, - 255, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10}; - -const int head3_5[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0x6c,0x3b,0x82,0x3d, - 1, - 50}; - - -/* packet that overspans over an entire page */ -const int head1_6[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_6[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x68,0x22,0x7c,0x3d, - 255, - 100, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255}; - -const int head3_6[] = {0x4f,0x67,0x67,0x53,0,0x01, - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0xf4,0x87,0xba,0xf3, - 255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255}; - -const int head4_6[] = {0x4f,0x67,0x67,0x53,0,0x05, - 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,3,0,0,0, - 0xf7,0x2f,0x6c,0x60, - 5, - 254,255,4,255,0}; - -/* packet that overspans over an entire page */ -const int head1_7[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_7[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x68,0x22,0x7c,0x3d, - 255, - 100, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255}; - -const int head3_7[] = {0x4f,0x67,0x67,0x53,0,0x05, - 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0xd4,0xe0,0x60,0xe5, - 1, - 0}; - -int compare_packet(const ogg_packet *op1, const ogg_packet *op2){ - if(op1->packet!=op2->packet){ - fprintf(stderr,"op1->packet != op2->packet\n"); - return(1); - } - if(op1->bytes!=op2->bytes){ - fprintf(stderr,"op1->bytes != op2->bytes\n"); - return(1); - } - if(op1->b_o_s!=op2->b_o_s){ - fprintf(stderr,"op1->b_o_s != op2->b_o_s\n"); - return(1); - } - if(op1->e_o_s!=op2->e_o_s){ - fprintf(stderr,"op1->e_o_s != op2->e_o_s\n"); - return(1); - } - if(op1->granulepos!=op2->granulepos){ - fprintf(stderr,"op1->granulepos != op2->granulepos\n"); - return(1); - } - if(op1->packetno!=op2->packetno){ - fprintf(stderr,"op1->packetno != op2->packetno\n"); - return(1); - } - return(0); -} - -void test_pack(const int *pl, const int **headers, int byteskip, - int pageskip, int packetskip){ - unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */ - long inptr=0; - long outptr=0; - long deptr=0; - long depacket=0; - long granule_pos=7,pageno=0; - int i,j,packets,pageout=pageskip; - int eosflag=0; - int bosflag=0; - - int byteskipcount=0; - - if (!data) { - fprintf(stderr,"unable to allocate requried data buffer!\n"); - exit(1); - } - - ogg_stream_reset(&os_en); - ogg_stream_reset(&os_de); - ogg_sync_reset(&oy); - - for(packets=0;packetsbyteskip){ - memcpy(next,og.header,byteskipcount-byteskip); - next+=byteskipcount-byteskip; - byteskipcount=byteskip; - } - - byteskipcount+=og.body_len; - if(byteskipcount>byteskip){ - memcpy(next,og.body,byteskipcount-byteskip); - next+=byteskipcount-byteskip; - byteskipcount=byteskip; - } - - ogg_sync_wrote(&oy,(long)(next-buf)); - - while(1){ - int ret=ogg_sync_pageout(&oy,&og_de); - if(ret==0)break; - if(ret<0)continue; - /* got a page. Happy happy. Verify that it's good. */ - - fprintf(stderr,"(%d), ",pageout); - - check_page(data+deptr,headers[pageout],&og_de); - deptr+=og_de.body_len; - pageout++; - - /* submit it to deconstitution */ - ogg_stream_pagein(&os_de,&og_de); - - /* packets out? */ - while(ogg_stream_packetpeek(&os_de,&op_de2)>0){ - ogg_stream_packetpeek(&os_de,NULL); - ogg_stream_packetout(&os_de,&op_de); /* just catching them all */ - - /* verify peek and out match */ - if(compare_packet(&op_de,&op_de2)){ - fprintf(stderr,"packetout != packetpeek! pos=%ld\n", - depacket); - exit(1); - } - - /* verify the packet! */ - /* check data */ - if(memcmp(data+depacket,op_de.packet,op_de.bytes)){ - fprintf(stderr,"packet data mismatch in decode! pos=%ld\n", - depacket); - exit(1); - } - /* check bos flag */ - if(bosflag==0 && op_de.b_o_s==0){ - fprintf(stderr,"b_o_s flag not set on packet!\n"); - exit(1); - } - if(bosflag && op_de.b_o_s){ - fprintf(stderr,"b_o_s flag incorrectly set on packet!\n"); - exit(1); - } - bosflag=1; - depacket+=op_de.bytes; - - /* check eos flag */ - if(eosflag){ - fprintf(stderr,"Multiple decoded packets with eos flag!\n"); - exit(1); - } - - if(op_de.e_o_s)eosflag=1; - - /* check granulepos flag */ - if(op_de.granulepos!=-1){ - fprintf(stderr," granule:%ld ",(long)op_de.granulepos); - } - } - } - } - } - } - } - _ogg_free(data); - if(headers[pageno]!=NULL){ - fprintf(stderr,"did not write last page!\n"); - exit(1); - } - if(headers[pageout]!=NULL){ - fprintf(stderr,"did not decode last page!\n"); - exit(1); - } - if(inptr!=outptr){ - fprintf(stderr,"encoded page data incomplete!\n"); - exit(1); - } - if(inptr!=deptr){ - fprintf(stderr,"decoded page data incomplete!\n"); - exit(1); - } - if(inptr!=depacket){ - fprintf(stderr,"decoded packet data incomplete!\n"); - exit(1); - } - if(!eosflag){ - fprintf(stderr,"Never got a packet with EOS set!\n"); - exit(1); - } - fprintf(stderr,"ok.\n"); -} - -int main(void){ - - ogg_stream_init(&os_en,0x04030201); - ogg_stream_init(&os_de,0x04030201); - ogg_sync_init(&oy); - - /* Exercise each code path in the framing code. Also verify that - the checksums are working. */ - - { - /* 17 only */ - const int packets[]={17, -1}; - const int *headret[]={head1_0,NULL}; - - fprintf(stderr,"testing single page encoding... "); - test_pack(packets,headret,0,0,0); - } - - { - /* 17, 254, 255, 256, 500, 510, 600 byte, pad */ - const int packets[]={17, 254, 255, 256, 500, 510, 600, -1}; - const int *headret[]={head1_1,head2_1,NULL}; - - fprintf(stderr,"testing basic page encoding... "); - test_pack(packets,headret,0,0,0); - } - - { - /* nil packets; beginning,middle,end */ - const int packets[]={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1}; - const int *headret[]={head1_2,head2_2,NULL}; - - fprintf(stderr,"testing basic nil packets... "); - test_pack(packets,headret,0,0,0); - } - - { - /* large initial packet */ - const int packets[]={4345,259,255,-1}; - const int *headret[]={head1_3,head2_3,NULL}; - - fprintf(stderr,"testing initial-packet lacing > 4k... "); - test_pack(packets,headret,0,0,0); - } - - { - /* continuing packet test; with page spill expansion, we have to - overflow the lacing table. */ - const int packets[]={0,65500,259,255,-1}; - const int *headret[]={head1_4,head2_4,head3_4,NULL}; - - fprintf(stderr,"testing single packet page span... "); - test_pack(packets,headret,0,0,0); - } - - { - /* spill expand packet test */ - const int packets[]={0,4345,259,255,0,0,-1}; - const int *headret[]={head1_4b,head2_4b,head3_4b,NULL}; - - fprintf(stderr,"testing page spill expansion... "); - test_pack(packets,headret,0,0,0); - } - - /* page with the 255 segment limit */ - { - - const int packets[]={0,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,50,-1}; - const int *headret[]={head1_5,head2_5,head3_5,NULL}; - - fprintf(stderr,"testing max packet segments... "); - test_pack(packets,headret,0,0,0); - } - - { - /* packet that overspans over an entire page */ - const int packets[]={0,100,130049,259,255,-1}; - const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL}; - - fprintf(stderr,"testing very large packets... "); - test_pack(packets,headret,0,0,0); - } - -#ifndef DISABLE_CRC - { - /* test for the libogg 1.1.1 resync in large continuation bug - found by Josh Coalson) */ - const int packets[]={0,100,130049,259,255,-1}; - const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL}; - - fprintf(stderr,"testing continuation resync in very large packets... "); - test_pack(packets,headret,100,2,3); - } -#else - fprintf(stderr,"Skipping continuation resync test due to --disable-crc\n"); -#endif - - { - /* term only page. why not? */ - const int packets[]={0,100,64770,-1}; - const int *headret[]={head1_7,head2_7,head3_7,NULL}; - - fprintf(stderr,"testing zero data page (1 nil packet)... "); - test_pack(packets,headret,0,0,0); - } - - - - { - /* build a bunch of pages for testing */ - unsigned char *data=_ogg_malloc(1024*1024); - int pl[]={0, 1,1,98,4079, 1,1,2954,2057, 76,34,912,0,234,1000,1000, 1000,300,-1}; - int inptr=0,i,j; - ogg_page og[5]; - - if (!data) { - fprintf(stderr,"unable to allocate requried packet data buffer!\n"); - exit(1); - } - - ogg_stream_reset(&os_en); - - for(i=0;pl[i]!=-1;i++){ - ogg_packet op; - int len=pl[i]; - - op.packet=data+inptr; - op.bytes=len; - op.e_o_s=(pl[i+1]<0?1:0); - op.granulepos=(i+1)*1000; - - for(j=0;j0)error(); - - /* Test fractional page inputs: incomplete fixed header */ - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+3, - 20); - ogg_sync_wrote(&oy,20); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - /* Test fractional page inputs: incomplete header */ - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+23, - 5); - ogg_sync_wrote(&oy,5); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - /* Test fractional page inputs: incomplete body */ - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+28, - og[1].header_len-28); - ogg_sync_wrote(&oy,og[1].header_len-28); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,1000); - ogg_sync_wrote(&oy,1000); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body+1000, - og[1].body_len-1000); - ogg_sync_wrote(&oy,og[1].body_len-1000); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - fprintf(stderr,"ok.\n"); - } - - /* Test fractional page inputs: page + incomplete capture */ - { - ogg_page og_de; - fprintf(stderr,"Testing sync on 1+partial inputs... "); - ogg_sync_reset(&oy); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, - og[1].header_len); - ogg_sync_wrote(&oy,og[1].header_len); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, - 20); - ogg_sync_wrote(&oy,20); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+20, - og[1].header_len-20); - ogg_sync_wrote(&oy,og[1].header_len-20); - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - fprintf(stderr,"ok.\n"); - } - - /* Test recapture: garbage + page */ - { - ogg_page og_de; - fprintf(stderr,"Testing search for capture... "); - ogg_sync_reset(&oy); - - /* 'garbage' */ - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, - og[1].header_len); - ogg_sync_wrote(&oy,og[1].header_len); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - - memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header, - 20); - ogg_sync_wrote(&oy,20); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header+20, - og[2].header_len-20); - ogg_sync_wrote(&oy,og[2].header_len-20); - memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body, - og[2].body_len); - ogg_sync_wrote(&oy,og[2].body_len); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - fprintf(stderr,"ok.\n"); - } - -#ifndef DISABLE_CRC - /* Test recapture: page + garbage + page */ - { - ogg_page og_de; - fprintf(stderr,"Testing recapture... "); - ogg_sync_reset(&oy); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, - og[1].header_len); - ogg_sync_wrote(&oy,og[1].header_len); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - - memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header, - og[2].header_len); - ogg_sync_wrote(&oy,og[2].header_len); - - memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header, - og[2].header_len); - ogg_sync_wrote(&oy,og[2].header_len); - - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body, - og[2].body_len-5); - ogg_sync_wrote(&oy,og[2].body_len-5); - - memcpy(ogg_sync_buffer(&oy,og[3].header_len),og[3].header, - og[3].header_len); - ogg_sync_wrote(&oy,og[3].header_len); - - memcpy(ogg_sync_buffer(&oy,og[3].body_len),og[3].body, - og[3].body_len); - ogg_sync_wrote(&oy,og[3].body_len); - - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - fprintf(stderr,"ok.\n"); - } -#else - fprintf(stderr,"Skipping recapture test due to --disable-crc\n"); -#endif - - /* Free page data that was previously copied */ - { - for(i=0;i<5;i++){ - free_page(&og[i]); - } - } - } - ogg_sync_clear(&oy); - ogg_stream_clear(&os_en); - ogg_stream_clear(&os_de); - - return(0); -} - -#endif diff --git a/Engine/lib/libogg/win32/.gitignore b/Engine/lib/libogg/win32/.gitignore deleted file mode 100644 index eb2b1eefa..000000000 --- a/Engine/lib/libogg/win32/.gitignore +++ /dev/null @@ -1,105 +0,0 @@ -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# Build results -[Dd]ebug/ -[Dd]ebugDLL/ -[Rr]elease/ -[Rr]eleaseDLL/ -x64/ -x86/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Local History for Visual Studio -.localhistory/ diff --git a/Engine/lib/libogg/win32/ogg.def b/Engine/lib/libogg/win32/ogg.def deleted file mode 100644 index 030b644b6..000000000 --- a/Engine/lib/libogg/win32/ogg.def +++ /dev/null @@ -1,80 +0,0 @@ -; -; ogg.def -; List of exported functions for Windows builds. -; -LIBRARY ogg -EXPORTS -; -oggpack_writeinit -oggpack_writetrunc -oggpack_writealign -oggpack_writecopy -oggpack_reset -oggpack_writeclear -oggpack_readinit -oggpack_write -oggpack_look -oggpack_look1 -oggpack_adv -oggpack_adv1 -oggpack_read -oggpack_read1 -oggpack_bytes -oggpack_bits -oggpack_get_buffer -; -oggpackB_writeinit -oggpackB_writetrunc -oggpackB_writealign -oggpackB_writecopy -oggpackB_reset -oggpackB_writeclear -oggpackB_readinit -oggpackB_write -oggpackB_look -oggpackB_look1 -oggpackB_adv -oggpackB_adv1 -oggpackB_read -oggpackB_read1 -oggpackB_bytes -oggpackB_bits -oggpackB_get_buffer -; -ogg_stream_packetin -ogg_stream_pageout -ogg_stream_flush -; -ogg_sync_init -ogg_sync_clear -ogg_sync_reset -ogg_sync_destroy -ogg_sync_buffer -ogg_sync_wrote -ogg_sync_pageseek -ogg_sync_pageout -ogg_stream_pagein -ogg_stream_packetout -ogg_stream_packetpeek -; -ogg_stream_init -ogg_stream_clear -ogg_stream_reset -ogg_stream_reset_serialno -ogg_stream_destroy -ogg_stream_eos -ogg_stream_pageout_fill -ogg_stream_flush_fill -; -ogg_page_checksum_set -ogg_page_version -ogg_page_continued -ogg_page_bos -ogg_page_eos -ogg_page_granulepos -ogg_page_serialno -ogg_page_pageno -ogg_page_packets -ogg_packet_clear - - diff --git a/Engine/lib/libsndfile-libsndfile-1.2.2.tar.gz b/Engine/lib/libsndfile-libsndfile-1.2.2.tar.gz new file mode 100644 index 000000000..3199fcd00 Binary files /dev/null and b/Engine/lib/libsndfile-libsndfile-1.2.2.tar.gz differ diff --git a/Engine/lib/libsndfile/.editorconfig b/Engine/lib/libsndfile/.editorconfig deleted file mode 100644 index f8911427f..000000000 --- a/Engine/lib/libsndfile/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root = true - -[*] -insert_final_newline = true - -[*.{h,hpp,c,tpl,def}] -indent_style = tab -tab_width = 4 - -[*.py] -indent_style = space -indent_size = 4 - -[*.yml] -indent_style = space -indent_size = 2 diff --git a/Engine/lib/libsndfile/AUTHORS b/Engine/lib/libsndfile/AUTHORS deleted file mode 100644 index 9ef64da31..000000000 --- a/Engine/lib/libsndfile/AUTHORS +++ /dev/null @@ -1,235 +0,0 @@ -Original author: - -The main author of libsndfile is Erik de Castro Lopo -apart from code in the following directories: - - - src/GSM610 : Written by Jutta Degener and Carsten - Bormann . They should not be contacted in relation to - libsndfile or the GSM 6.10 code that is part of libsndfile. Their original - code can be found at: - - http://kbs.cs.tu-berlin.de/~jutta/toast.html - - - src/G72x : Released by Sun Microsystems, Inc. to the public domain. Minor - modifications were required to integrate these files into libsndfile. The - changes are listed in src/G72x/ChangeLog. - -Current maintainers: - -After the release of version 1.0.30, @erikd transferred the project to -[the libsndfile team](https://github.com/libsndfile) consisting of: - -* Erik de Castro Lopo aka @erikd -* David Seifert aka @SoapGentoo -* Arthur Taylor aka @arthurt -* @evpobr - -Current releaser is David Seifert: - ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v2 - -mQINBFppABgBEAC42ZiNvV7BTIgR6TQy0YnF54fx3mVRP1u8Mq00UZa7reAsNKh7 -1H60j0W4s6+4pVVIKGfpVGxLwUdJe+KVCYw1Cd3YW6uMf5zZrC/ZWqnJiH/n6S6o -1l4INII2o6YbGBnzIWBPRo7PlOL+mvgKTLpBSJPnhD8XDGN5wRiV8rL2+6Dptg0F -nJt7oxECGF3OD3gk6HMel0o82CVkIqMtNaX1L/bhcdF7K0Rp2MXPZMmpn1izW5sI -asN1G9+w+Zwj7kMJzq1Aw3ac+rsX4SEYdvXjS2QhDHQUIr6LXri3D2WbcEqIZj2R -JVoVwblsrG11dYXFDBbgrq4NhgTBsxHYDlkr/qF2W+kbPC/nhSqTVZeCYvTBZbOQ -+RqyN/I0izukglnWmV1jGijFA8snyP8efx732hw/24zRYmtXOtnEITUpw8WOeZCq -6uiHaQ+eopnY2ojBg9BI7WZm0AFn58xxT9soMsyFOUFgXTqaWFZWlJ3fhZE8/0v8 -JEu/kPGE5aJReT3b34B+Bojkj74XR+h2u7iJJBHMTE8RwGoUOZHer/XsL9xlcdks -I+7TCjiq++ShaSSt2XsJmw2BhREohrjW/2KkwmvT3b44RMpKPB4WTH+++aqJQNeM -IqmswOMoZvzEZezInj7WVY/r0WEei1Y6wt1tBrJ/cFf1oQBM1UmphxcrfQARAQAB -tB9EYXZpZCBTZWlmZXJ0IDxzb2FwQGdlbnRvby5vcmc+iQJUBBMBCgA+BQsJCAcD -BRUKCQgLBRYCAwEAAh4BAheAAhsBFiEEMdlcq22A0mIkShdQpHYg6AHkfpUFAl/V -CvoFCQkuceIACgkQpHYg6AHkfpXYxA//aiJW1NwunpmzEc62id8lRMnoLHWVjISZ -b+xSlm+hk4LYq+ZbthJDzKcT86/3DJOSE1zQw9wLuCao9IW2UfFJQBtR+TAfbagG -0Yyk/kMcLoFJxnG1ywdJWypCAauuIhia52Z7PmmjsBbFwr6LygDwSQmZAyACMAs7 -TLQe+yERc2RNDsIEsquLSxxRF0Spk9gagWtKgrPc2XBjuNtQDwW7JgsOUoEeHyxC -29fRUjC3o/pG2I6iAZp17OROZI5yl4TSORrSBDGIi2sayxyxP0x+IPKtrCUcBGNx -wGp+56bP/V0hA6sgCPh/iwvqLoeibso6l/Kd4ltVAEQnHTd6fr8g+wLEUXfbJVTR -7aeFUoaFmWjSPlQrNr6HlxSLV/kRx9kVJp1Pn16vkfVBF7fG7iDLiqphwEeQg5ND -nmGeKAbRRNxFHyBHf0XRsaYiFZQckguO+71XSRtVx8/YP5nyNbtl9y1h/4JlT6Gy -t7hb5twYFQyQrKss83E/Bo1sRdHpj0ibtqb4ZbYANbh482E6yFhAkuo8YjVTJipI -1Ve8EBKnX3R+pDt147uyysNvtPVXML+sWpGSMVSm4NA8uT3F5nqxVwj+SeXy3Wq/ -CHQ2VBKGBC655G+wFD5C6O7cTx2MwH+2H8tzhWm+gFlI3MFKEXa/PC+YUC/diYcb -BrApavriTRa5Ag0EWmkAZgEQAPXMD3mZI+ChvBysXZWksC88/uSEwFeb3XkcRm7v -04GN7hcz+bfrmnUTB3tuE/ZQgv+u7ZjetvH1aEKieznn/GjnWoOBoJusOYvfAQeF -0mQVi118QiOZRCnEZpkz+RY9TiXVgrZJg+AGqHZ3Ol4GkInEV2NWgH37Xal+HkFl -rwI2U7mL0kZRG+LAVCQHKzqU0R0HE1XyJ4qf0awtG5Qi/TZvgXBdZPDXgr8i9Vlf -UUu10c2XnXM0Av/YAlZmBFjVYrSOUCFenqSVqL+s9sTCVdWlJrGjrr3Ja4uT3kl2 -rLva0AR4oSQoxt8adKohmFz0vzOkQtCoRzhrCwoo3JvNjKdSNoOP1nSsxlO5ji8r -ih5d+ajPgi580XyHLnrvG7vobR48qqscv1hizKuCgTacOTe6Db2Gqc8xF6v8HhJa -KwWJtmFllIfN/tIvZ6BbbgHQn0IGf4CYnWf0SksPZqpBmTRpD2jfBxcj2UEg+AR3 -LARjuyUVpFJScyu6ExQG+6O+ByLL31iWP5MgUrza1rIpriPa3NT3rZ3DG2pvQrS3 -ySsrPzH7VRX8L1ThSMSzjwF96aMsd14s7XzR4EzNuWwZDukfs0yavZk6l4o1M0mb -tbJi7hE4cz13KRHYvIkKMdZGYUnzRzZUDlsj2imakk3BR6GXnxZ1ST6062g+QxiL -AJFLABEBAAGJBHIEGAEKACYCGwIWIQQx2VyrbYDSYiRKF1CkdiDoAeR+lQUCX9UL -DQUJCS5xpwJAwXQgBBkBCgAdFiEEuNUxXaAAcsCoYIifzjbhFyAuOEIFAlppAGYA -CgkQzjbhFyAuOELmrQ/9H9wrWsWa21STZdxUmyU2sh9VXAWEHl1Ey0fVTznDM0Fl -zx5YSR/TmmnE36rpaz31Ttkx8SP914oV+mMgseecdya9Bf6uZL9Cv7V3KEsJBRL/ -ncrOWQBHP/Xy1X+mLD6A19xq7H4RihSLj0LeK2YVjrJzJ7wMf4mKXuBayQeAHImU -WRCRTbmK3umh2nB5V0iPd/XZEIiYtiTPe+7E/va6+0bBvOumF3a+Z0iui7eU4hFC -7Jk71D0dcg09SlIaNoMOrw7cMC3j2pMdKtsj8+0I6WBv14PhhqPAsnjdf7I/4NfK -L7Jav8T/gDS01uA2Jxm72d+wr+eSjOBXa6x8CEbTqfkjAGxsWENThCp6zDkaXSDd -JsV0va47vjzG8+wTDAvPy5IxIM/KZZdl4uWM+mF5K+q+eSTOHe7aLF2OdcussoBA -A18zm994dAkG1COX/qpxanxx2bv/2IvCGPg+x6JtAN8ji2kncWu3dWGQdE5XbVjc -fDwgsUPpp04G27Mr/x+HpEbgZ5SdA0dAqJktlNvCcHALhlblCWrsh/1QNjT/2iG8 -wsjcpEy/s4tWAuV4PTa4xvZ1JPS7Z7Eo5aBy9ZGOWG9SrHEiHnhkUsiswbHBOEjd -pBSkmNElDcv9fRUahVCTPfvWBATFDrQyMjJBSm+cV8c/iFQM7isVSu8W7E0eetsJ -EKR2IOgB5H6Vv9sP/1dxTvH0N0UoEoxIG/hnirEkbRpljdvqy4/uikYBKyQgSbo8 -VITTjea7gIhDztil9WZYt35jbOmoaGM2Z6TP2LEDOWgljYUNq9pl9Sc2GS8cNtEO -WxExzGOc1Flo730dX3A85Ks3+0WPXZjLDcRRcPVkFd5WLQQDV1YVYopWkuQBC+Br -4q3uv+sk+bw6gDa9+zFBbDuegdsYuTXrFHoxHz2GRv9Yb7ULCMgpFeNKDgtQq91u -RqewoTwQp9tlp91LH/hh7R0Q4DRgeFDkLnVRXwSKjVvCrT5cBgImGwtFTGS4egoy -MDKd/KKjZllp1ahRCln1XfmFQyQVMVvuF/JTtt31n6KwXwK2yxIlXB01xvRH+Ees -AWeRYWKWXydaAY/9Ve0/PLFlgsr/XUGvt0GoEKe7odD3nZgg6015+/8JTroKw19L -NZkhdfFMl11Zi0j5k3UbyzjYVpFSd8K2o0VoOG1LFsPp8tlRxNoVzpId0CX1au/p -y1H7Wy/39mzriRG3rw+mJAQbBjN09putCltXFXpOEWk08n/N3vufCVQUoSu/2Bqw -2HYj8VtToQp+O5dG3XxvDHINtInP1yr2Wcw2plna0KoXLwv/lZgDm3LN+eCWpG6d -N/xk25DTSqTHArUQIEkhcHYK6GnyxUcvoKtG88hXtqEPYXiK08FZYAUPTnDYuQIN -BFppAIkBEADDjvQZUs1NoqJpxkD2QDBudU1DBCaeI1D6CancMtb5FebPUxgFlDMd -CBGOun48dY5i87gDhT/qS3gP/Mv9rjKJmcG9JHfhpXdW73owxrcsQ96nxxVJNEVl -UHJw00z8C9eGWqr0SzSoE33K/PkzSkgtsaotF6+3uCerWulweulmGa5dpVfV0mbS -aVw8VmrhZ5NmCeodyy/lR85rPik5pb32NT6v7xBkgkfS0VYtPB2E5gW1pXX/jEOi -Mfq9idOEP9lxrNXV9j49Lr0JQCwAcrYbQ2+VPe6eacJEjzJ/6HiUqhPrYdnvydmb -hU+xmv2NjGp2UnDZDEhzQfwm6fMx+8Nx2uPzCnXQGoyRBwiC/KcdW0F1ZPKdSXqH -NKoOF62pLvIMSmfI3ZVOrTohArfr1kFEYVDv9Nl7oY+qg2rZEc2srOF74a9Z46bR -TDPsEQzE2UMCvu3+rofhSD7aRotlKeDCvbe2s0yE4Man457Xc3LXh8Gva8CzCOLE -2eMhNTsHIZk68WgXp3/uvE4Xy42myrk1AV8XXDdlWgx0Kc/I6tE59O5NVPSfuGvH -1a15KKx0F6euEnYDKKpQ5PDR6dSn61po0tfbt96m044G/xQFjrfhHei4jji9Ogd9 -vlXVAi2vn3+NCSHFP5l3igLByBHy9iLIdmz7yQuus/1nwRmxOHOf2QARAQABiQI8 -BBgBCgAmAhsMFiEEMdlcq22A0mIkShdQpHYg6AHkfpUFAl/VCxkFCQkucZAACgkQ -pHYg6AHkfpVPSRAAmheYkYJmtDbkzPBBnj5mbCIQN1/G5PI9eixc/TXWFOXtcjU1 -mJlJpSidHJyLRrx7r0c+N+s8vnY/JuUBsNoMJMER+Mv/CFW4iFi59V534SyAb2S0 -7NINJnFNkXBY62CDz9KsMuv/MdSv2yLhPH2Tfrm/eDRQesj1PanE4U1cgjWyJRc/ -IOlaRHvTasWDLgwbQi8ykt+4xUWzL/YKHzB+KyyzBK7vPBXqySX8ka4BOw7SDwG5 -lX2gtmhk4AGBwVChLXKflqVx1WXj4DPOt0kmOKVnKFyvUijK58M0A2FMgFMXDTIS -DRtoZPdx/rkODXxgS+W+27NcYAnxJiM0cQqizEnQh7PQ1KzgdChPejYXMKe9lwdn -ssMUxrBpbuAuagEf+pebNjD2eaNR4p8kfaDdGn53q55ysDvoyxKvnVQGSk1FAR9Q -s4N5a4f02U7dzlyEhEfIcuUlRCfnlpn4n725YIhHheDig5zKWoEZCkNIfiRcGzDl -8Drj+tlZiUR+gDkIoWSBaCkKbIQlc8qCYy6Hm7oZBaol6xKlUnTMK2rjK8fR4i8r -bVDWBAaWj3jcDHJ0Jg3fS/qBpeya/JXMp89TR8NK5Ys7PZpWbor+puXBYyXDAVx3 -rXQ7JBA5klHPxrgjso1S/LqwscKLENtrVjdjhryLBmPifrmofJRnrpiHIEa5Ag0E -WmkAswEQAL0hKwsRybQzkNGpJP+ElLSwFHd7XQhr+qIwLllpumWtnIK/DHmv8SpW -FqAYajmRTXipFcBHH25x2jIIliZidn0a9826l+sMzrFadMC6/W4pitP71TeqZzwn -pAuHs14YL7Wiy0aJQnfbCpRzPq3kYyOXmhmY7lPWO0WdUpR6W8wUbleK5XOVDDRx -aIC/M3hhDOxZOMzQ+pdn4BaOFQQ0ygsRkqOudbuc0R1giYRt1i6gMeT8gfzL9jlw -HcJ+aVnxdUQQ4uC47oKo/+lg7qh7LsiW79pQC1Bcdm8lhRmqtxe6ub60ecjax3XU -1ILIEfIFCv6M7LRUAwz0bqk35spgkJqrGGKkdeWEKAFHg2QWR2F0zy+HdlPLfKxO -uhaccpwc9EJtf744GS0SXa2AXr32j56n7CFcEjFcIQPBC6OJn6eA3hOVUYGZ7SrT -4fsmZiFAdGEkvLKFuNhju1Hj2EJQUY1pm4GSBco7BR8x+QqoYrt5clU3WxRMNfTR -0Rtuzsh4xskXNVMMgvKOahAtxENv2M2Cx6zJPVL5dmaysP7d6QRVeOQA5PwkcZ5Q -qK6JtDZj2jpaKQH4Za715kiIcdqMDSkwxa6avc0kARHvfFcBR4hwDm1GAlaKG7eH -8TOGGQIk8x2F3s4l8mTJVLWTP/uJYnkYBdqANYo5t1NIQLvwLFV3ABEBAAGJAjwE -GAEKACYCGyAWIQQx2VyrbYDSYiRKF1CkdiDoAeR+lQUCX9ULIwUJCS5xcAAKCRCk -diDoAeR+leekD/sF7aHH0W35ckWrXZlfSp0qHPWrBUaLBI9OAUHenRhgs4SbK0D4 -wqEiu0C5iDQojpXAeALQ8g/1pUsZ1yuFqYbGYWrHkA0Pm+P3tAGB4LMZ41YfvROP -uaiW/+IMJbWllgRtaDt8/NtCgs30WI9I+az5M29HcGfvEwEUykrBx3dE9T+1ui3O -capdd+GMvdAAsX5PyVkjWgZ7GrZeH8mG7UysYfT4qthxEtQfZ/u8ceSduKA46ugh -C2eafIDNvluqn7BU4oKxME61u6C8BN2yHLI6LV0Tr4z5H8joVbM4BSFMwLVGlsXf -HhB8kLiErN6bXolxsjARlmYiD9S9H2AcYidr6RYXf2EVFSpBG59xn1WTDN+DsHQf -7btNPEPl/OPxa3OQjG+xn8USddiP0N0B4xsyzMNCCKDgvXXcIhX55KG9eh3Tc98S -fEyhxu8ybZBIGmTJysPKxijfvSgQF+RPNTsz9lvXqkoK7RTgeYMschpjJEznCLbt -M6eTDb5z0G5uLXh6+dYxtDOlPogI5OHd+G51LwCjvrQ+AtIUCgafuemwA9mpFT2b -svb/qcxSVUb44bVaNHn1JHebX2YbokGtBOm1x2PI5fT8n6YIIYz3jKYOZAYdUT7x -6qURyNjOfG4aPJIATwuh4GSNuxUG40+yuT+XfQF24mu1esS1J3wzRloJ7w== -=K3x+ ------END PGP PUBLIC KEY BLOCK----- - -Previous releasers: - -Version 1.0.29-1.0.30 - @evpobr. - -The public GPG key: - ------BEGIN PGP MESSAGE----- - -yMMwAnicrVJ7UFRVHF50SdiJ2AknHmYM19IhFrmPva91hnBKHMkcSyAyY7nn3nN3 -L7AP9qVoO5Lja1YUycgJ4iUFWYluTlE4Oi6PxdhpCkesIWiAQIbXqlSs1Ex1l7H/ -6r/OP2fOd77vm+/3za8nZqVCFVEfk/xkgPyrMiLgO+FUFIze8R5AgEUoR3QHkBK4 -fMFSAdod+hJJQHQIiqEYBzECYByBs4AnGBYDGIYDjqEYHMc4nKB5ntICkQSAxCke -RTEaJ3AthWJaWccItIhyiAYRJbMB2qw2yeyQbVmA8aKAQxbHCZbXApxhIIqTIiug -AiZiPA8IUhQZXhYaLfawQg4HODvcKFlkTH7ol+P9C/9/zu1cthMJlJG5NM+RFEUC -nsIomiJIBhMIUmAwNky0Q5uZM0GZDV1WC7Ahbg0iYy6Jh+FaH/4ZJIfRCf6L7yi3 -hoG9EOgfSvVAMgtyd7LCBW12yWJGdJjM5B1SWItpWQwjtBjOahC4zyrZoF4KM0ia -YlD5aBCrDbpkSxrwIkpwUO6YIHCUAjwOKEIUBFaAIsWKAJfrF7XyoJAGkIaUPD9g -aSBwIkUIOIqEhykzWxAdKcfkDLKlXTKYOYfTBhF3l2+PUhGhUjwSuSK8UwpVtPqf -TTv+gVoRyKt70PuZxj6oi7ZkZP481vcc2vJ6cV774dld3s3n3+3w+cXdW9YaVvc9 -ni8Nv6aOUqx5b/+Lexria1wn7c1DOxVnikYSV50eY0o7Lwatz3qqg6RHWVOVF3zm -lai7u7ud7r7vh5Lrm+95j06OeWN+29SbkNVeW9X1Vs651NsF9K1jV7xzkRdz6N4f -Vy+5B37qTr18Lclk9lx7o3cmP/+6Jbbl3qvj7w/PvTnVDyYiuxtSZlvtCZ2JT6yv -21rw8tLXnDHhwv0/7kfnpgSNXxKLA/tyPRsunLxp8tw4e6zx6PGbwsxKsTopg9u1 -dkdzBxWf+VVb/tbUzZNtUzUpj0l1fiSUtu1UaHxwdOnj2JlI4fdfdyAh/5GqvbY5 -7YKy0hgabi89Ffen+qUNtZ+f90258OevKhf6S+p+qelSRh/64ZOihg87D857slVZ -5wqttfExWb7LymH/oVjTpcWFt4u/uP3pC8YrwfY+ad2NpDuW5oqPZrKOFCoGzqgb -t1jSF1Vph1c0qtZUds+PaAqpp/Mqhjo0yavKiid91emBiPaeb3s2uW8d9J6YXZiu -T8p7tK+8yHp3ov4dcCk3lNY28s13ZePrW8ceVGc3zOT01/ibotLjdFZn9tmd67a3 -iCrDaJM7Y/9TY8XzHdPbTZ2wPG7bxFBg2LSx6WootqI1dF2fGutPzE0bzJzW/w3x -usYz -=XFTp ------END PGP MESSAGE----- - -Versions before 1.0.29 - Erik de Castro Lopo. - -The public GPG key: - ------BEGIN PGP SIGNATURE----- - -iQIzBAABCAAdFiEEapGlzyLCTJmjXgE/z9z5H7JCrO0FAljgv0wACgkQz9z5H7JC -rO2RhxAAnIuHquhkhaY8CVsIOGImMxEF8RKDyFoioV9RnckNzBb592EYxU9hS0MM -cT6xPZU0bJa8CvmCxEABMlkk60JP4VmmOtWxD8EEyktbHGyao80mDR82yVKYv78L -zTRzz/JoTncgwWz/QataMbkAfy3KpxkwDW87az0kzkqGuSm3Jg3medt+t/iBe0Wm -jcxIexxEZCmIhty6VyaVEkGWax0zdJHe7aD9FK2C/R3DU5Byp4e9pcp/a8v74G1n -dgD4S3YlqvJGuU9S6QD4PzsoWD1X8f6pHzxpRP/OkqHAe11sSRo6sSYYCjsYi9Ca -IJSlVC1nMx9OUxxAA8ZqtnztOo7GZcJ5NAL5X3GNV6YfQ7Bqxvtr6QG26F06MB6i -p08UC7NC0bxFsD3f07wY22QnbnM052rniTn5sqQZv+GVls6t1b3u1iHzEjAjlgvi -eOjVVt/A8iaOzMbKC/3+SZ9/GYqbSAQOCIoWAXmhV9IaMQyQeLCIC1YD5NMGBXal -HPfSHV0hSUDbKjAYXFigJRzFU125bXTgg+v13Kd0KklIEjoaZYZLAYs0BupXdjBf -jSPv8pwUaXJkv9/bGH0Ot1fvwDqPDOlGFINQbGAWdxwsdhiYBeXMFeFNTEfiqEMz -BhhMxKa+Mfd9fkrX4NNigGW5QgRBS+FHNLf6ZfiXSnBGjjxMcbI= -=UUA0 ------END PGP SIGNATURE----- - -Others: - - 2013-03-07 Michael Pruett - 2013-02-11 Chris Roberts c.roberts@csrfm.com - 2012-03-17 IOhannes m zmoelnig - 2013-02-21 Jan Starry - 2012-01-20 Bodo - 2011-06-23 Tim van der Molen - 2010-12-01 Tim Blechmann - 2010-10-04 Matti Nykyri - 2010-09-17 Brian Lewis - 2010-02-22 Robin Gareus - 2010-01-07 Christian Weisgerber and Jacob Meuserto - 2009-10-18 Olivier Tristan - 2009-10-14, 2009-08-30 Uli Franke - 2009-06-24, 2008-11-19, 2004-09-22, 2004-06-17, 2003-05-03, 2003-05-02 Conrad Parker - 2009-05-22 Lennart Poettering - 2008-07-03, 2006-10-22, 2006-10-18 Fons Adriaensen - 2008-04-19 David Yeo - 2008-01-20 Yair K. - 2007-12-03 Robs - 2007-07-12 Ed Schouten - 2007-06-07 Trent Apted - 2007-04-14, 2003-12-12 André Pang - 2007-04-14 Reuben Thomas - 2006-11-09 Jonathan Woithe - 2006-03-26 Diego 'Flameeyes' Pettenò - 2006-03-17 Paul Davis - 2006-03-09 Jesse Chappell - 2006-01-09, 2005-12-28 John ffitch - 2005-09-21 David A. van Leeuwen - 2005-08-15 Mo DeJong - 2005-04-30 David Viens - 2004-12-29 Steve Baker - 2004-09-05 Denis Cote - 2004-06-28 Stanko Juzbasic - 2004-02-14 Frank Neumann - 2003-08-15 Axel Röbel - 2003-08-06 Peter Miller - 2003-07-21 Tero Pelander - 2003-02-10 Antoine Mathys - 2002-12-30 Marek Peteraj diff --git a/Engine/lib/libsndfile/Building-for-Android.md b/Engine/lib/libsndfile/Building-for-Android.md deleted file mode 100644 index eb5a0d350..000000000 --- a/Engine/lib/libsndfile/Building-for-Android.md +++ /dev/null @@ -1,46 +0,0 @@ -# Building for Android - -Assuming the Android Ndk is installed at location `/path/to/toolchain`, building -libsndfile for Android (arm-linux-androideabi) should be as simple as: -``` -autoreconf -vif -export ANDROID_TOOLCHAIN_HOME=/path/to/android/toolchain -./Scripts/android-configure.sh -make -``` -The `Scripts/android-configure.sh` contains four of variables; `ANDROID_NDK_VER`, -`ANDROID_GCC_VER`, `ANDROID_API_VER` and `ANDROID_TARGET` that can be overridden -by setting them before the script is run. - -Since I (erikd), do almost zero Android development, I am happy accept patches -for this documentation and script to improve its utility for real Android -developers. - ---- - -## Using CMake - -(Tested on Linux) - -For convenience, export the following variables: - -``` -export ANDROID_ABI=arm64-v8a -export ANDROID_PLATFORM_API_LEVEL=29 -export NDK_ROOT=/path/to/android/ndk -``` - -Set `ANDROID_ABI`, `ANDROID_PLATFORM_API_LEVEL` according to your target system. Now cd into the libsndfile root directory, and run - -``` -cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_ABI=$ANDROID_ABI -DANDROID_PLATFORM=$ANDROID_PLATFORM_API_LEVEL -``` - -cd into `build` and run make - -``` -cd build -make [-j ] -``` - -This will build libsndfile for android. diff --git a/Engine/lib/libsndfile/CHANGELOG.md b/Engine/lib/libsndfile/CHANGELOG.md deleted file mode 100644 index 122085300..000000000 --- a/Engine/lib/libsndfile/CHANGELOG.md +++ /dev/null @@ -1,190 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [1.2.2] - 2023-08-13 - -### Fixed - -* Fixed invalid regex in src/create_symbols_file.py -* Fixed passing null pointer to printf %s in tests - -## [1.2.1] - 2023-08-12 - -### Added - -* RISC OS support to `sndfile-play`, thanks @ccawley2011 -* Move semantics to `SndFileHandle` C++ class, thanks @haydaralaidrus - -### Fixed - -* Various typos, thanks @@uniontech-lilinjie -* Handling of absolute `CMAKE_INSTALL_LIBDIR`/`CMAKE_INSTALL_INCLUDEDIR`, thanks - @Staudey (issue #908) -* Add `localtime_s` support to `sndfile-metadata-set`, thanks @neheb (issue #907) -* Linking with CMake against `Ogg::ogg`, thanks @FtZPetruska -* CMake `mpg123` module handling bugs, thanks @FtZPetruska -* CMake dependencies handling, thanks @FtZPetruska -* Various `Ogg` & `Opus` format fixes, thanks @weiliang (issue #888) -* Redefining `ssize_t` when building with Autotools, thanks @ccawley2011 - (issue #934) -* Bug related to incorrect `realloc` use, thanks @Halmoni100 -* Style errors, thanks to @arthurt -* AIFF format related bugs, thanks to @arthurt -* Reading of MP3 files without Xing or INFO headers, thanks @arthurt -* Coding style of `src/mpeg_decode.c`, thanks @arthurt -* Various documentation types, thanks @luzpaz -* Intrinsics inclusion for MSVC and ARM64/ARM64EC, thanks @frysee -* `sf_open_fd`() regression, thanks @brentr (PR #950) -* WAV format related bug, thanks @magnus-nomono (issue #930) - -### Removed - -* Obsolete file `libsndfile.spec.in``, thanks @janstary - -## [1.2.0] - 2022-12-25 - -### Fixed - -* Searching for LAME dependency with CMake build system (issue #821). -* CMake build from Autotools tarball (issue #816). -* Build on UWP platform (issue #824). -* Fix signed integer overflow (issue #785). -* Skipping large wav chunks on stdin (PR #819). - -### Removed - -* Maximum samplerate limit, thanks @drmpeg, @justacec (issue #850). - - In version 1.1.0, an artificial limit of 655350 Hz was created, but as it - turned out, this is not enough for some scenarios. - -## [1.1.0] - 2022-03-27 - -### Added - -* MPEG Encode/Decode Support. - - Uses libmpg123 for decode, liblame for encode. Encoding and decoding support - is independent of each other and is split into separate files. MPEG support - is generalized as subformats, `SF_FORMAT_MPEG_LAYER`(I,II,III) so that it - might be used by other containers (`MPEG1WAVEFORMAT` for example), but also - contains a major format `SF_FORMAT_MPEG` for 'mp3 files.' - - Encoding Status: - * Layer III encoding - * ID3v1 writing - * ID3v2 writing - * Lame/Xing Tag writing - * Bitrate selection command - * VBR or CBR - - Decoding Status: - * Layers I/II/III decoding - * ID3v1 reading - * ID3v2 reading - * Seeking -* New fuzzer for OSS-Fuzz, thanks @DavidKorczynski. -* This `CHANGELOG.md`. All notable changes to this project will be documented in - this file. The old `NEWS` file has been renamed to `NEWS.OLD` and is no longer - updated. -* Add support for decoding MPEG III Audio in WAV files. -* `SECURITY.md` file to give people instructions for reporting security - vulnerabilities, thanks @zidingz. -* Support for [Vcpkg manifest mode](https://vcpkg.readthedocs.io/en/latest/users/manifests/). - - If you have problems with manifest mode, disable it with `VCPKG_MANIFEST_MODE` - switch. -* [Export CMake targets from the build tree (PR #802)](https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#exporting-targets-from-the-build-tree) -* CIFuzz fuzzer, thanks to @AdamKorcz (PR #796) - -### Changed - -* `SFC_SET_DITHER_ON_READ` and `SFC_SET_DITHER_ON_WRITE` enums comments in - public header, thanks @SmiVan (issue #677). -* `ENABLE_SNDFILE_WINDOWS_PROTOTYPES` define is deprecated and not needed - anymore. - - Previously, in order for the [`sf_wchar_open`()](http://libsndfile.github.io/libsndfile/api.html#open) - function to become available on the Windows platform, it was required to - perform certain actions: - - ```c - #include - #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 - #including - ``` - - These steps are no longer required and the `sf_wchar_open`() function is - always available on the Windows platform. -* Use UTF-8 as internal path encoding on Windows platform. - - This is an internal change to unify and simplify the handling of file paths. - - On the Windows platform, the file path is always converted to UTF-8 and - converted to UTF-16 only for calls to WinAPI functions. - - The behavior of the functions for opening files on other platforms does not - change. -* Switch to .xz over .bz2 for release tarballs. -* Disable static builds using Autotools by default. If you want static - libraries, pass --enable-static to ./configure - -### Fixed - -* Typo in `docs/index.md`. -* Typo in `programs/sndfile-convert.c`, thanks @fjl. -* Memory leak in `caf_read_header`(), credit to OSS-Fuzz ([issue 30375](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30375)). -* Stack overflow in `guess_file_type`(), thanks @bobsayshilol, credit to - OSS-Fuzz ([issue 29339](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29339)). -* Abort in fuzzer, thanks @bobsayshilol, credit to OSS-Fuzz - ([issue 26257](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26257)). -* Infinite loop in `svx_read_header`(), thanks @bobsayshilol, credit to OSS-Fuzz - ([issue 25442](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25442)). -* GCC and Clang pedantic warnings, thanks @bobsayshilol. -* Normalisation issue when scaling floating point data to `int` in - `replace_read_f2i`(), thanks @bobsayshilol, (issue #702). -* Missing samples when doing a partial read of Ogg file from index till the end - of file, thanks @arthurt (issue #643). -* sndfile-salvage: Handle files > 4 GB on Windows OS -* Undefined shift in `dyn_get_32bit`(), credit to OSS-Fuzz - ([issue 27366](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27366)). -* Integer overflow in `nms_adpcm_update`(), credit to OSS-Fuzz - ([issue 25522](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25522)). -* Integer overflow in `psf_log_printf`(), credit to OSS-Fuzz - ([issue 28441](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28441)), - ([issue 25624](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25624)). -* ABI version incompatibility between Autotools and CMake build on Apple - platforms. - - Now ABI must be compatible with Autotools builds. Note that this change - requires CMake >= 3.17 for building dylib on Apple platforms. - -* Fix build with Autotools + MinGW toolchain on Windows platform. - - See https://github.com/msys2/MINGW-packages/issues/5803 for details. - -### Security - -* Heap buffer overflow in `wavlike_ima_decode_block`(), thanks @bobsayshilol, - credit to OSS-Fuzz ([issue 25530](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25530)). -* Heap buffer overflow in `msadpcm_decode_block`(), thanks @bobsayshilol, - credit to OSS-Fuzz ([issue 26803](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26803)). -* Heap buffer overflow in `psf_binheader_readf`(), thanks @bobsayshilol, - credit to OSS-Fuzz ([issue 26026](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26026)). -* Index out of bounds in `psf_nms_adpcm_decode_block`(), credit to OSS-Fuzz - ([issue 25561](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25561)). -* Heap buffer overflow in `flac_buffer_copy`(), thanks @yuawn, @bobsayshilol. -* Heap buffer overflow in `copyPredictorTo24`(), thanks @bobsayshilol, - credit to OSS-Fuzz ([issue 27503](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27503)). -* Uninitialized variable in `psf_binheader_readf`(), thanks @shao-hua-li, - credit to OSS-Fuzz ([issue 25364](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25364)). - -[Unreleased]: https://github.com/libsndfile/libsndfile/compare/1.2.2...HEAD -[1.2.2]: https://github.com/libsndfile/libsndfile/compare/1.2.1...1.2.2 -[1.2.1]: https://github.com/libsndfile/libsndfile/compare/1.2.0...1.2.1 -[1.2.0]: https://github.com/libsndfile/libsndfile/compare/1.1.0...1.2.0 -[1.1.0]: https://github.com/libsndfile/libsndfile/compare/1.0.31...1.1.0 diff --git a/Engine/lib/libsndfile/CMakeLists.txt b/Engine/lib/libsndfile/CMakeLists.txt deleted file mode 100644 index de6c3b0ad..000000000 --- a/Engine/lib/libsndfile/CMakeLists.txt +++ /dev/null @@ -1,1604 +0,0 @@ -cmake_minimum_required (VERSION 3.5..3.18) - -# MSVC runtime library flags are selected by an abstraction, CMake >= 3.15 -# This policy still need to be set even with cmake_minimum_required() command above. -if (POLICY CMP0091) - if ((DEFINED ENABLE_STATIC_RUNTIME) AND (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)) - message (FATAL_ERROR "Both ENABLE_STATIC_RUNTIME and CMAKE_MSVC_RUNTIME_LIBRARY are set.") - return () - endif () - - if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) - cmake_policy (SET CMP0091 NEW) - else () - cmake_policy (SET CMP0091 OLD) - endif () -endif () - -option (ENABLE_EXTERNAL_LIBS "Enable FLAC, Vorbis, and Opus codecs" ON) -if (ENABLE_EXTERNAL_LIBS) - list (APPEND VCPKG_MANIFEST_FEATURES "external-libs") -endif () - -option (ENABLE_MPEG "Enable MPEG codecs" ON) -if (ENABLE_MPEG) - list (APPEND VCPKG_MANIFEST_FEATURES "mpeg") -endif () - -option (ENABLE_EXPERIMENTAL "Enable experimental code" OFF) -if (ENABLE_EXPERIMENTAL) - list (APPEND VCPKG_MANIFEST_FEATURES "speex") -endif () - -option (BUILD_REGTEST "Build regtest" OFF) -if (BUILD_REGTEST) - list (APPEND VCPKG_MANIFEST_FEATURES "regtest") -endif () - -project(libsndfile VERSION 1.2.2) - -# -# Variables -# - -set (CMAKE_C_STANDARD 99) -set (CMAKE_C_STANDARD_REQUIRED TRUE) -set_property(GLOBAL PROPERTY USE_FOLDERS ON) - -set (PACKAGE_NAME ${PROJECT_NAME}) -set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) -set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) -set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) -set (CPACK_PACKAGE_VERSION_STAGE "") -set (CPACK_PACKAGE_VERSION_FULL "${PROJECT_VERSION}${CPACK_PACKAGE_VERSION_STAGE}") - -# -# System-wide includes -# - -include (GNUInstallDirs) -include (FeatureSummary) -include (CMakeDependentOption) -include (CTest) -include (CheckCCompilerFlag) - -# -# Options -# - -option (BUILD_SHARED_LIBS "Build shared libraries" OFF) -if (BUILD_SHARED_LIBS AND BUILD_TESTING) - set (BUILD_TESTING OFF) - message ("Build testing required static libraries. To prevent build errors BUILD_TESTING disabled.") -endif () -option (BUILD_PROGRAMS "Build programs" ON) -option (BUILD_EXAMPLES "Build examples" ON) -option (ENABLE_CPACK "Enable CPack support" ON) -option (ENABLE_BOW_DOCS "Enable black-on-white html docs" OFF) -if (MSVC AND (DEFINED ENABLE_STATIC_RUNTIME)) - option (ENABLE_STATIC_RUNTIME "Enable static runtime" ${ENABLE_STATIC_RUNTIME}) -elseif (MINGW) - option (ENABLE_STATIC_RUNTIME "Enable static runtime" OFF) -endif () -option (ENABLE_PACKAGE_CONFIG "Generate and install package config file" ON) -option (INSTALL_PKGCONFIG_MODULE "Generate and install pkg-config module" ON) - -list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -if (CMAKE_VERSION VERSION_LESS 3.14) - list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sqlite") -endif () - -# -# Setup definitions -# - -include(SndFileChecks) - -if (ENABLE_EXTERNAL_LIBS AND NOT (Vorbis_FOUND OR FLAC_FOUND OR OPUS_FOUND)) - set (ENABLE_EXTERNAL_LIBS OFF) -endif() -if(ENABLE_MPEG AND (NOT HAVE_MPEG_LIBS)) - set (ENABLE_MPEG OFF) -endif() -if (BUILD_REGTEST AND (NOT SQLITE3_FOUND)) - set (BUILD_REGTEST OFF) -endif() - -cmake_dependent_option (ENABLE_CPU_CLIP "Enable tricky cpu specific clipper" ON "CPU_CLIPS_POSITIVE;CPU_CLIPS_NEGATIVE" OFF) -if (NOT ENABLE_CPU_CLIP) - set (CPU_CLIPS_POSITIVE FALSE) - set (CPU_CLIPS_NEGATIVE FALSE) -endif () -cmake_dependent_option (ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise" OFF "WIN32;BUILD_SHARED_LIBS" OFF) -cmake_dependent_option (INSTALL_MANPAGES "Install man pages for programs" ON "BUILD_PROGRAMS" OFF) - -if (NOT MSVC) - if (CPU_IS_X86) - check_c_compiler_flag (-msse2 HAVE_MSSE2_COMPILER_FLAG) - if (HAVE_MSSE2_COMPILER_FLAG) - cmake_dependent_option (ENABLE_SSE2 "Add SSE2 compiler flag" ON "HAVE_MSSE2_COMPILER_FLAG" OFF) - endif () - endif () -endif () -if (ENABLE_SSE2) - add_compile_options (-msse2) -endif () - -set (HAVE_EXTERNAL_XIPH_LIBS ${ENABLE_EXTERNAL_LIBS}) -set (HAVE_SQLITE3 ${BUILD_REGTEST}) -set (HAVE_ALSA_ASOUNDLIB_H ${ALSA_FOUND}) -set (HAVE_SNDIO_H ${SNDIO_FOUND}) - -set (ENABLE_EXPERIMENTAL_CODE ${ENABLE_EXPERIMENTAL}) -set (HAVE_MPEG ${ENABLE_MPEG}) -set (HAVE_SPEEX ${ENABLE_EXPERIMENTAL}) - -add_feature_info (BUILD_SHARED_LIBS BUILD_SHARED_LIBS "build shared libraries") -add_feature_info (ENABLE_EXTERNAL_LIBS ENABLE_EXTERNAL_LIBS "enable FLAC, Vorbis, and Opus codecs") -add_feature_info (ENABLE_MPEG ENABLE_MPEG "enable MPEG audio (including mp3) codecs") -add_feature_info (ENABLE_EXPERIMENTAL ENABLE_EXPERIMENTAL "enable experimental code") -add_feature_info (BUILD_TESTING BUILD_TESTING "build tests") -add_feature_info (BUILD_REGTEST BUILD_REGTEST "build regtest") -add_feature_info (ENABLE_CPACK ENABLE_CPACK "enable CPack support") -add_feature_info (ENABLE_CPU_CLIP ENABLE_CPU_CLIP "Enable tricky cpu specific clipper") -add_feature_info (ENABLE_BOW_DOCS ENABLE_BOW_DOCS "enable black-on-white html docs") -add_feature_info (ENABLE_PACKAGE_CONFIG ENABLE_PACKAGE_CONFIG "generate and install package config file") -add_feature_info (INSTALL_PKGCONFIG_MODULE INSTALL_PKGCONFIG_MODULE "generate and install pkg-config module") -add_feature_info (INSTALL_MANPAGES INSTALL_MANPAGES "install man pages for programs") -if (WIN32 AND BUILD_SHARED_LIBS) - add_feature_info (ENABLE_COMPATIBLE_LIBSNDFILE_NAME ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise") -endif () - -if (HAVE_MSSE2_COMPILER_FLAG) - add_feature_info (ENABLE_SSE2 ENABLE_SSE2 "add SSE2 compiler flag") -endif () - - - - -set_package_properties (Ogg PROPERTIES - TYPE RECOMMENDED - URL "www.xiph.org/ogg/" - DESCRIPTION "library for manipulating ogg bitstreams" - PURPOSE "Required to enable Vorbis, Speex, and Opus support" - ) -set_package_properties (Vorbis PROPERTIES - TYPE RECOMMENDED - URL "www.vorbis.com/" - DESCRIPTION "open source lossy audio codec" - PURPOSE "Enables Vorbis support" - ) -set_package_properties (FLAC PROPERTIES - TYPE RECOMMENDED - URL "www.xiph.org/flac/" - DESCRIPTION "Free Lossless Audio Codec Library" - PURPOSE "Enables FLAC support" - ) -set_package_properties (mp3lame PROPERTIES - TYPE RECOMMENDED - URL "https://lame.sourceforge.io/" - DESCRIPTION "High quality MPEG Audio Layer III (MP3) encoder" - PURPOSE "Enables MPEG layer III (MP3) writing support" - ) -set_package_properties (mpg123 PROPERTIES - TYPE RECOMMENDED - URL "https://www.mpg123.de/" - DESCRIPTION "MPEG Audio Layer I/II/III decoder" - PURPOSE "Enables MPEG Audio reading support" - ) -set_package_properties(Opus PROPERTIES - TYPE RECOMMENDED - URL "www.opus-codec.org/" - DESCRIPTION "Standardized open source low-latency fullband codec" - PURPOSE "Enables experimental Opus support" - ) -set_package_properties(Speex PROPERTIES TYPE OPTIONAL - URL "www.speex.org/" - DESCRIPTION "an audio codec tuned for speech" - PURPOSE "Enables experemental Speex support" - ) -set_package_properties (SQLite3 PROPERTIES - TYPE OPTIONAL - URL "www.sqlite.org/" - DESCRIPTION "light weight SQL database engine." - PURPOSE "Enables regtest" - ) -if (BUILD_SHARED_LIBS) - set_package_properties (PythonInterp PROPERTIES - TYPE REQUIRED - URL "www.python.org/" - DESCRIPTION "Python is a widely used high-level programming language." - PURPOSE "Required to build shared libraries" - ) -endif() - -feature_summary (WHAT ALL) - -# -# Setup configuration -# - -configure_file (src/config.h.cmake src/config.h) - -if (INSTALL_PKGCONFIG_MODULE) - - set (prefix ${CMAKE_INSTALL_PREFIX}) - set (exec_prefix "\$\{prefix\}") - set (libdir "${CMAKE_INSTALL_FULL_LIBDIR}") - set (includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") - set (VERSION ${PROJECT_VERSION}) - if (ENABLE_EXTERNAL_LIBS) - set (EXTERNAL_XIPH_REQUIRE "flac ogg vorbis vorbisenc opus") - if (ENABLE_EXPERIMENTAL) - set (EXTERNAL_XIPH_REQUIRE "${EXTERNAL_XIPH_REQUIRE} speex") - endif () - endif () - if (ENABLE_MPEG) - set (EXTERNAL_MPEG_REQUIRE "libmpg123") - set (EXTERNAL_MPEG_LIBS "-lmp3lame") - endif () - - configure_file (sndfile.pc.in sndfile.pc @ONLY) - -endif () - -# -# libsndfile -# - -# Public libsndfile headers -set (sndfile_HDRS - include/sndfile.h - include/sndfile.hh - ) - -# -# libsndfile static library -# - -add_library (sndfile - src/sfconfig.h - src/sfendian.h - src/sf_unistd.h - src/common.h - src/common.c - src/file_io.c - src/command.c - src/pcm.c - src/ulaw.c - src/alaw.c - src/float32.c - src/double64.c - src/ima_adpcm.c - src/ms_adpcm.c - src/gsm610.c - src/dwvw.c - src/vox_adpcm.c - src/interleave.c - src/strings.c - src/dither.c - src/cart.c - src/broadcast.c - src/audio_detect.c - src/ima_oki_adpcm.c - src/ima_oki_adpcm.h - src/alac.c - src/chunk.c - src/ogg.h - src/ogg.c - src/chanmap.h - src/chanmap.c - src/id3.h - src/id3.c - $<$:src/windows.c> - src/sndfile.c - src/aiff.c - src/au.c - src/avr.c - src/caf.c - src/dwd.c - src/flac.c - src/g72x.c - src/htk.c - src/ircam.c - src/macos.c - src/mat4.c - src/mat5.c - src/nist.c - src/paf.c - src/pvf.c - src/raw.c - src/rx2.c - src/sd2.c - src/sds.c - src/svx.c - src/txw.c - src/voc.c - src/wve.c - src/w64.c - src/wavlike.h - src/wavlike.c - src/wav.c - src/xi.c - src/mpc2k.c - src/rf64.c - src/ogg_vorbis.c - src/ogg_speex.c - src/ogg_pcm.c - src/ogg_opus.c - src/ogg_vcomment.h - src/ogg_vcomment.c - src/nms_adpcm.c - src/mpeg.c - src/mpeg_decode.c - src/mpeg_l3_encode.c - src/GSM610/config.h - src/GSM610/gsm.h - src/GSM610/gsm610_priv.h - src/GSM610/add.c - src/GSM610/code.c - src/GSM610/decode.c - src/GSM610/gsm_create.c - src/GSM610/gsm_decode.c - src/GSM610/gsm_destroy.c - src/GSM610/gsm_encode.c - src/GSM610/gsm_option.c - src/GSM610/long_term.c - src/GSM610/lpc.c - src/GSM610/preprocess.c - src/GSM610/rpe.c - src/GSM610/short_term.c - src/GSM610/table.c - src/G72x/g72x.h - src/G72x/g72x_priv.h - src/G72x/g721.c - src/G72x/g723_16.c - src/G72x/g723_24.c - src/G72x/g723_40.c - src/G72x/g72x.c - src/ALAC/ALACAudioTypes.h - src/ALAC/ALACBitUtilities.h - src/ALAC/EndianPortable.h - src/ALAC/aglib.h - src/ALAC/dplib.h - src/ALAC/matrixlib.h - src/ALAC/alac_codec.h - src/ALAC/shift.h - src/ALAC/ALACBitUtilities.c - src/ALAC/ag_dec.c - src/ALAC/ag_enc.c - src/ALAC/dp_dec.c - src/ALAC/dp_enc.c - src/ALAC/matrix_dec.c - src/ALAC/matrix_enc.c - src/ALAC/alac_decoder.c - src/ALAC/alac_encoder.c - ${sndfile_HDRS} - ${CMAKE_CURRENT_BINARY_DIR}/src/config.h - ) - -add_library (SndFile::sndfile ALIAS sndfile) - -target_include_directories (sndfile - PUBLIC - $ - $ - $ - PRIVATE - src - $ - ) -target_link_libraries (sndfile - PRIVATE - $<$:m> - $<$:Ogg::ogg> - $<$:Vorbis::vorbisenc> - $<$:FLAC::FLAC> - $<$,$,$>:Speex::Speex> - $<$:Opus::opus> - $<$:MPG123::libmpg123> - $<$:mp3lame::mp3lame> - ) -set_target_properties (sndfile PROPERTIES - PUBLIC_HEADER "${sndfile_HDRS}" - ) - -if (ENABLE_COMPATIBLE_LIBSNDFILE_NAME) - if (MINGW OR CYGWIN) - set_target_properties (sndfile PROPERTIES - RUNTIME_OUTPUT_NAME "sndfile-1" - ) - else () - set_target_properties (sndfile PROPERTIES - RUNTIME_OUTPUT_NAME "libsndfile-1" - ) - endif () -endif () - -if (BUILD_SHARED_LIBS) - - # - # ABI version of library. - # - - # - # Read libtool version from `configure.ac` and set libsndfile ABI version: - # - # SNDFILE_ABI_VERSION_MAJOR - # SNDFILE_ABI_VERSION_MINOR - # SNDFILE_ABI_VERSION_PATCH - # SNDFILE_ABI_VERSION - # - # and Mach-O current and compatibility versions: - # - # SNDFILE_MACHO_CURRENT_VERSION - # SNDFILE_MACHO_COMPATIBILITY_VERSION - # - - include (SetupABIVersions) - - setup_abi_versions() - - if (WIN32) - set (VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}) - set (GEN_TOOL cmake) - - set (WIN_RC_VERSION "${CPACK_PACKAGE_VERSION_MAJOR},${CPACK_PACKAGE_VERSION_MINOR},${CPACK_PACKAGE_VERSION_PATCH}") - set (CLEAN_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") - set (PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) - - configure_file (src/version-metadata.rc.in src/version-metadata.rc @ONLY) - target_sources (sndfile PRIVATE ${PROJECT_BINARY_DIR}/src/version-metadata.rc) - endif () - - - set_target_properties (sndfile PROPERTIES - SOVERSION ${SNDFILE_ABI_VERSION_MAJOR} - VERSION ${SNDFILE_ABI_VERSION} - ) - - if (APPLE) - if (NOT (CMAKE_VERSION VERSION_LESS 3.17)) - set_target_properties (sndfile PROPERTIES - MACHO_CURRENT_VERSION ${SNDFILE_MACHO_CURRENT_VERSION} - MACHO_COMPATIBILITY_VERSION ${SNDFILE_MACHO_COMPATIBILITY_VERSION} - ) - else () - message (FATAL_ERROR "Apple platform requires cmake >= 3.17 to build dylib.") - endif () - endif () - - # Symbol files generation - - if (WIN32) - set (SYMBOL_FILENAME "sndfile.def") - set (SYMBOL_OS "win32") - elseif ((CMAKE_SYSTEM_NAME MATCHES "Darwin") OR (CMAKE_SYSTEM_NAME MATCHES "Rhapsody")) - set (SYMBOL_FILENAME "Symbols.darwin") - set (SYMBOL_OS "darwin") - elseif (CMAKE_SYSTEM_NAME MATCHES "OS2") - set (SYMBOL_FILENAME "Symbols.os2") - set (SYMBOL_OS "os2") - elseif (UNIX) - set (SYMBOL_FILENAME "Symbols.gnu-binutils") - set (SYMBOL_OS "linux") - endif () - - if (DEFINED SYMBOL_OS) - add_custom_command ( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/create_symbols_file.py ${SYMBOL_OS} ${SNDFILE_ABI_VERSION} > ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME} - COMMENT "Generating ${SYMBOL_FILENAME}..." - ) - - add_custom_target (GENFILES DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}) - if (SYMBOL_OS MATCHES "win32") - target_sources (sndfile - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME} - ) - elseif (SYMBOL_OS MATCHES "darwin") - add_dependencies (sndfile GENFILES) - if (CMAKE_VERSION VERSION_LESS 3.13) - set_property (TARGET sndfile APPEND_STRING PROPERTY - LINK_FLAGS "-Wl,-exported_symbols_list -Wl,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}" - ) - else () - target_link_options (sndfile PRIVATE "LINKER:-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}") - endif() - elseif (SYMBOL_OS MATCHES "os") - add_dependencies (sndfile GENFILES) - if (CMAKE_VERSION VERSION_LESS 3.13) - set_property (TARGET sndfile APPEND_STRING PROPERTY - LINK_FLAGS "-Wl,-export-symbols ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}" - ) - else () - target_link_options (sndfile PRIVATE "LINKER:-export-symbols ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}") - endif() - elseif (UNIX) - add_dependencies (sndfile GENFILES) - if (CMAKE_VERSION VERSION_LESS 3.13) - set_property (TARGET sndfile APPEND_STRING PROPERTY - LINK_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}" - ) - else () - target_link_options (sndfile PRIVATE "LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}") - endif() - endif() - endif() - -endif () - -# -# Programs -# - -if (BUILD_PROGRAMS) - -# sndfile-info - - add_executable (sndfile-info - programs/sndfile-info.c - programs/common.c - programs/common.h - ) - target_link_libraries (sndfile-info - PRIVATE - sndfile - $<$:m> - ) - -# sndfile-play - - add_executable (sndfile-play - $<$>:programs/sndfile-play.c> - $<$>:programs/common.c> - $<$>:programs/sndfile-play.c> - $<$:programs/sndfile-play-beos.cpp> - ) - target_include_directories (sndfile-play - PRIVATE - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ) - target_link_libraries (sndfile-play PRIVATE $<$:m>) - target_link_libraries (sndfile-play PRIVATE sndfile) - if (WIN32) - target_link_libraries(sndfile-play PRIVATE winmm) - # Maybe ALSA & Sndio are present in BeOS. They are not required - # so skip them anyway. - elseif ((NOT BEOS) AND ALSA_FOUND) - target_include_directories (sndfile-play PRIVATE ${ALSA_INCLUDE_DIRS}) - target_link_libraries (sndfile-play PRIVATE ${ALSA_LIBRARIES}) - elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") - target_link_libraries (sndfile-play PRIVATE Sndio::Sndio) - endif () - -# sndfile-convert - - add_executable (sndfile-convert - programs/sndfile-convert.c - programs/common.c - programs/common.h - ) - target_link_libraries (sndfile-convert PRIVATE sndfile $<$:m>) - -# sndfile-cmp - - add_executable (sndfile-cmp - programs/sndfile-cmp.c - programs/common.c - programs/common.h - ) - target_include_directories (sndfile-cmp - PUBLIC - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR}/tests - ) - target_link_libraries (sndfile-cmp PRIVATE sndfile $<$:m>) - -# sndfile-metadata-set - - add_executable (sndfile-metadata-set - programs/sndfile-metadata-set.c - programs/common.c - programs/common.h - ) - target_include_directories (sndfile-metadata-set - PUBLIC - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR}/tests - ) - target_link_libraries (sndfile-metadata-set PRIVATE sndfile $<$:m>) - -# sndfile-metadata-get - - add_executable (sndfile-metadata-get - programs/sndfile-metadata-get.c - programs/common.c - programs/common.h - ) - target_include_directories (sndfile-metadata-get - PUBLIC - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR}/tests - ) - target_link_libraries (sndfile-metadata-get PRIVATE sndfile $<$:m>) - -# sndfile-interleave - - add_executable (sndfile-interleave - programs/sndfile-interleave.c - programs/common.c - programs/common.h - ) - target_link_libraries (sndfile-interleave PRIVATE sndfile $<$:m>) - -# sndfile-deinterleave - - add_executable (sndfile-deinterleave - programs/sndfile-deinterleave.c - programs/common.c - programs/common.h - ) - target_link_libraries (sndfile-deinterleave PRIVATE sndfile $<$:m>) - -# sndfile-concat - - add_executable (sndfile-concat - programs/sndfile-concat.c - programs/common.c - programs/common.h - ) - target_link_libraries (sndfile-concat PRIVATE sndfile $<$:m>) - -# sndfile-salvage - - add_executable (sndfile-salvage - programs/sndfile-salvage.c - programs/common.c - programs/common.h - ) - target_include_directories (sndfile-salvage - PUBLIC - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR}/tests - ) - target_link_libraries (sndfile-salvage PRIVATE sndfile $<$:m>) - - set (SNDFILE_PROGRAM_TARGETS - sndfile-info - sndfile-play - sndfile-convert - sndfile-cmp - sndfile-metadata-set - sndfile-metadata-get - sndfile-interleave - sndfile-deinterleave - sndfile-concat - sndfile-salvage - ) - - set_target_properties(${SNDFILE_PROGRAM_TARGETS} PROPERTIES FOLDER Programs) - -endif () - -# -# Examples -# - -if (BUILD_EXAMPLES) - -# sndfile-to-text - - add_executable (sndfile-to-text examples/sndfile-to-text.c) - target_link_libraries (sndfile-to-text PRIVATE sndfile) - -# sndfile-loopify - - add_executable (sndfile-loopify examples/sndfile-loopify.c) - target_link_libraries (sndfile-loopify PRIVATE sndfile) - -# make_sine - - add_executable (make_sine examples/make_sine.c) - target_link_libraries (make_sine - PRIVATE - sndfile - $<$:m> - ) - -# sfprocess - - add_executable (sfprocess examples/sfprocess.c) - target_link_libraries (sfprocess - PRIVATE - sndfile - $<$:m> - ) - -# list_formats - - add_executable (list_formats examples/list_formats.c) - target_link_libraries (list_formats - PRIVATE - sndfile - $<$:m> - ) - -# generate - - add_executable (generate examples/generate.c) - target_link_libraries (generate PRIVATE sndfile) - -# sndfilehandle - - add_executable (sndfilehandle examples/sndfilehandle.cc) - target_link_libraries (sndfilehandle PUBLIC sndfile) - - set (SNDFILE_EXAMPLE_TARGETS - sndfile-to-text - sndfile-loopify - make_sine - sfprocess - list_formats - generate - sndfilehandle - ) - - set_target_properties(${SNDFILE_EXAMPLE_TARGETS} PROPERTIES FOLDER Examples) - - -endif () - -# -# sndfile-regtest -# - -if (BUILD_REGTEST) - - add_executable (sndfile-regtest - regtest/sndfile-regtest.c - regtest/database.c - regtest/checksum.c - ) - target_include_directories (sndfile-regtest - PUBLIC - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR}/tests - ) - target_link_libraries(sndfile-regtest - PRIVATE - sndfile - SQLite::SQLite3 - $<$:m> - ) - -endif () - -# -# Installation -# - -if (ENABLE_PACKAGE_CONFIG) - - if (WIN32 AND (NOT MINGW) AND (NOT CYGWIN)) - set (CMAKE_INSTALL_PACKAGEDIR cmake) - else () - set (CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/SndFile) - endif() - - install (TARGETS ${SNDFILE_PROGRAM_TARGETS} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ) - - install (TARGETS sndfile - EXPORT SndFileTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - ) - - export (EXPORT SndFileTargets NAMESPACE SndFile:: FILE ${PROJECT_BINARY_DIR}/SndFileTargets.cmake) - - include (CMakePackageConfigHelpers) - - if (ENABLE_EXTERNAL_LIBS) - set (SndFile_WITH_EXTERNAL_LIBS 1) - list (APPEND FIND_MODULES_INSTALL_LIST - ${CMAKE_CURRENT_LIST_DIR}/cmake/FindFLAC.cmake - ${CMAKE_CURRENT_LIST_DIR}/cmake/FindOgg.cmake - ${CMAKE_CURRENT_LIST_DIR}/cmake/FindOpus.cmake - ${CMAKE_CURRENT_LIST_DIR}/cmake/FindVorbis.cmake) - else () - set (SndFile_WITH_EXTERNAL_LIBS 0) - endif () - - if(ENABLE_MPEG) - set (SndFile_WITH_MPEG 1) - list (APPEND FIND_MODULES_INSTALL_LIST - ${CMAKE_CURRENT_LIST_DIR}/cmake/Findmpg123.cmake - ${CMAKE_CURRENT_LIST_DIR}/cmake/Findmp3lame.cmake) - else () - set (SndFile_WITH_MPEG 0) - endif () - - set (INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) - configure_package_config_file(cmake/SndFileConfig.cmake.in SndFileConfig.cmake - INSTALL_DESTINATION ${PROJECT_BINARY_DIR} - INSTALL_PREFIX ${PROJECT_BINARY_DIR} - PATH_VARS INCLUDE_INSTALL_DIR - ) - configure_package_config_file(cmake/SndFileConfig.cmake.in SndFileConfig2.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} - PATH_VARS INCLUDE_INSTALL_DIR - ) - write_basic_package_version_file (SndFileConfigVersion.cmake COMPATIBILITY SameMajorVersion) - - install(EXPORT SndFileTargets - NAMESPACE SndFile:: - DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} - ) - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/SndFileConfig2.cmake - RENAME SndFileConfig.cmake - DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} - ) - install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/SndFileConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} - ) - - if (NOT BUILD_SHARED_LIBS AND FIND_MODULES_INSTALL_LIST) - file(COPY ${FIND_MODULES_INSTALL_LIST} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - install(FILES ${FIND_MODULES_INSTALL_LIST} DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) - endif () -else () - - install (TARGETS sndfile ${sdnfile_PROGRAMS} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -endif () - -if (INSTALL_MANPAGES) - - set (man_MANS - man/sndfile-info.1 - man/sndfile-play.1 - man/sndfile-convert.1 - man/sndfile-cmp.1 - man/sndfile-metadata-get.1 - man/sndfile-concat.1 - man/sndfile-interleave.1 - man/sndfile-salvage.1 - ) - install (FILES ${man_MANS} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) - install (FILES man/sndfile-metadata-get.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME sndfile-metadata-set.1) - install (FILES man/sndfile-interleave.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME sndfile-deinterleave.1) -endif () - -if (ENABLE_BOW_DOCS) - set (HTML_BGCOLOUR "white") - set (HTML_FGCOLOUR "black") -else () - set (HTML_BGCOLOUR "black") - set (HTML_FGCOLOUR "white") -endif () -set (dist_doc_DATA - docs/index.md - docs/libsndfile.jpg - docs/libsndfile.css - docs/print.css - docs/api.md - docs/command.md - docs/bugs.md - docs/formats.md - docs/sndfile_info.md - docs/new_file_type_howto.md - docs/win32.md - docs/FAQ.md - docs/lists.md - docs/embedded_files.md - docs/octave.md - docs/tutorial.md - ) -install (FILES ${dist_doc_DATA} DESTINATION ${CMAKE_INSTALL_DOCDIR}) - -if (INSTALL_PKGCONFIG_MODULE) - install (FILES ${CMAKE_CURRENT_BINARY_DIR}/sndfile.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -endif () - -# -# Testing -# - -if (BUILD_TESTING) - - enable_testing () - - include (CMakeAutoGen) - - # generate tests sources from autogen templates - lsf_autogen (tests benchmark c) - lsf_autogen (tests floating_point_test c) - lsf_autogen (tests header_test c) - lsf_autogen (tests pcm_test c) - lsf_autogen (tests pipe_test c) - lsf_autogen (tests rdwr_test c) - lsf_autogen (tests scale_clip_test c) - lsf_autogen (tests utils c h) - lsf_autogen (tests write_read_test c) - lsf_autogen (src test_endswap c) - - # utils static library - add_library(test_utils STATIC tests/utils.c) - target_include_directories (test_utils - PUBLIC - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR}/tests - ) - target_link_libraries(test_utils PRIVATE sndfile) - - ### test_main - - add_executable (test_main - src/test_main.c - src/test_main.h - src/test_conversions.c - src/test_float.c - src/test_endswap.c - src/test_audio_detect.c - src/test_log_printf.c - src/test_file_io.c - src/test_ima_oki_adpcm.c - src/test_strncpy_crlf.c - src/test_broadcast_var.c - src/test_cart_var.c - src/test_binheader_writef.c - src/test_nms_adpcm.c - ) - target_include_directories (test_main - PUBLIC - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR}/tests - ) - target_link_libraries (test_main PRIVATE sndfile) - if (MSVC) - target_compile_definitions (test_main PRIVATE _USE_MATH_DEFINES) - endif () - add_test (test_main test_main) - - ### sfversion_test - - add_executable (sfversion tests/sfversion.c) - target_include_directories (sfversion - PRIVATE - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ) - target_link_libraries (sfversion sndfile) - add_test (sfversion sfversion) - set_tests_properties (sfversion PROPERTIES - PASS_REGULAR_EXPRESSION "${PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_FULL}" - ) - - ### error_test - - add_executable (error_test tests/error_test.c) - target_link_libraries (error_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (error_test error_test) - - ### ulaw_test - add_executable (ulaw_test tests/ulaw_test.c) - target_link_libraries (ulaw_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (ulaw_test ulaw_test) - - ### alaw_test - add_executable (alaw_test tests/alaw_test.c) - target_link_libraries (alaw_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (alaw_test alaw_test) - - ### dwvw_test - - add_executable (dwvw_test tests/dwvw_test.c) - target_link_libraries (dwvw_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (dwvw_test dwvw_test) - - ### command_test - - add_executable (command_test tests/command_test.c) - target_link_libraries (command_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (command_test command_test all) - - ### floating_point_test - - add_executable (floating_point_test - tests/dft_cmp.c - tests/floating_point_test.c - ) - target_link_libraries (floating_point_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - target_include_directories (floating_point_test PRIVATE tests) - add_test (floating_point_test floating_point_test) - - ### checksum_test - - add_executable (checksum_test tests/checksum_test.c) - target_link_libraries (checksum_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (checksum_test checksum_test) - - ### scale_clip_test - - add_executable (scale_clip_test tests/scale_clip_test.c) - target_link_libraries (scale_clip_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (scale_clip_test scale_clip_test) - - ### headerless_test - - add_executable (headerless_test tests/headerless_test.c) - target_link_libraries (headerless_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (headerless_test headerless_test) - - ### rdwr_test - - add_executable (rdwr_test tests/rdwr_test.c) - target_link_libraries (rdwr_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (rdwr_test rdwr_test) - - ### locale_test - - add_executable (locale_test tests/locale_test.c) - target_link_libraries (locale_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (locale_test locale_test) - - ### win32_ordinal_test - -# Disabled because we cannot test with shared sndfile library -# if (WIN32 AND BUILD_SHARED_LIBS) -# add_executable (win32_ordinal_test tests/win32_ordinal_test.c) -# target_link_libraries (win32_ordinal_test PRIVATE sndfile test_utils) -# add_test (win32_ordinal_test win32_ordinal_test) -# endif () - - ### cpp_test - - add_executable (cpp_test tests/cpp_test.cc) - target_link_libraries (cpp_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (cpp_test cpp_test) - - ### external_libs_test - - add_executable (external_libs_test tests/external_libs_test.c) - target_link_libraries (external_libs_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (external_libs_test external_libs_test) - - ### format_check_test - - add_executable (format_check_test tests/format_check_test.c) - target_link_libraries (format_check_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (format_check_test format_check_test) - - ### channel_test - - add_executable (channel_test tests/channel_test.c) - target_link_libraries (channel_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (channel_test channel_test) - - ### pcm_test - - add_executable (pcm_test tests/pcm_test.c) - target_link_libraries (pcm_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - add_test (pcm_test pcm_test) - - ### common test executables - - add_executable (write_read_test - tests/generate.c - tests/write_read_test.c - ) - target_link_libraries (write_read_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - target_include_directories (write_read_test PRIVATE tests) - - add_executable (lossy_comp_test tests/lossy_comp_test.c) - target_link_libraries (lossy_comp_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (peak_chunk_test tests/peak_chunk_test.c) - target_link_libraries (peak_chunk_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (header_test tests/header_test.c) - target_link_libraries (header_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (misc_test tests/misc_test.c) - target_link_libraries (misc_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (string_test tests/string_test.c) - target_link_libraries (string_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (multi_file_test tests/multi_file_test.c) - target_link_libraries (multi_file_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (aiff_rw_test tests/aiff_rw_test.c) - target_link_libraries (aiff_rw_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (chunk_test tests/chunk_test.c) - target_link_libraries (chunk_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (long_read_write_test tests/long_read_write_test.c) - target_link_libraries (long_read_write_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (raw_test tests/raw_test.c) - target_link_libraries (raw_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (compression_size_test tests/compression_size_test.c) - target_link_libraries (compression_size_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (ogg_test tests/ogg_test.c) - target_link_libraries (ogg_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (ogg_opus_test tests/ogg_opus_test.c) - target_link_libraries (ogg_opus_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (mpeg_test tests/mpeg_test.c) - target_link_libraries (mpeg_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (stdin_test tests/stdin_test.c) - target_link_libraries (stdin_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - set_target_properties (stdin_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "tests") - - add_executable (stdout_test tests/stdout_test.c) - target_link_libraries (stdout_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - set_target_properties (stdout_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "tests") - - add_executable (stdio_test tests/stdio_test.c) - target_link_libraries (stdio_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (pipe_test tests/pipe_test.c) - target_link_libraries (pipe_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - add_executable (virtual_io_test tests/virtual_io_test.c) - target_link_libraries (virtual_io_test - PRIVATE - sndfile - test_utils - $<$:m> - ) - - ### g72x_test - - add_executable (g72x_test src/G72x/g72x_test.c) - target_include_directories (g72x_test - PRIVATE - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ) - target_link_libraries (g72x_test - PRIVATE - sndfile - $<$:m> - ) - add_test (g72x_test g72x_test all) - - ### aiff-tests - - add_test (write_read_test_aiff write_read_test aiff) - add_test (lossy_comp_test_aiff_ulaw lossy_comp_test aiff_ulaw) - add_test (lossy_comp_test_aiff_alaw lossy_comp_test aiff_alaw) - add_test (lossy_comp_test_aiff_gsm610 lossy_comp_test aiff_gsm610) - add_test (peak_chunk_test_aiff peak_chunk_test aiff) - add_test (header_test_aiff header_test aiff) - add_test (misc_test_aiff misc_test aiff) - add_test (string_test_aiff string_test aiff) - add_test (multi_file_test_aiff multi_file_test aiff) - add_test (aiff_rw_test aiff_rw_test) - - ### au-tests - - add_test (write_read_test_au write_read_test au) - add_test (lossy_comp_test_au_ulaw lossy_comp_test au_ulaw) - add_test (lossy_comp_test_au_alaw lossy_comp_test au_alaw) - add_test (lossy_comp_test_au_g721 lossy_comp_test au_g721) - add_test (lossy_comp_test_au_g723 lossy_comp_test au_g723) - add_test (header_test_au header_test au) - add_test (misc_test_au misc_test au) - add_test (multi_file_test_au multi_file_test au) - - ### caf-tests - - add_test (write_read_test_caf write_read_test caf) - add_test (lossy_comp_test_caf_ulaw lossy_comp_test caf_ulaw) - add_test (lossy_comp_test_caf_alaw lossy_comp_test caf_alaw) - add_test (header_test_caf header_test caf) - add_test (peak_chunk_test_caf peak_chunk_test caf) - add_test (misc_test_caf misc_test caf) - add_test (chunk_test_caf chunk_test caf) - add_test (string_test_caf string_test caf) - add_test (long_read_write_test_alac long_read_write_test alac) - - # wav-tests - add_test (write_read_test_wav write_read_test wav) - add_test (lossy_comp_test_wav_pcm lossy_comp_test wav_pcm) - add_test (lossy_comp_test_wav_ima lossy_comp_test wav_ima) - add_test (lossy_comp_test_wav_msadpcm lossy_comp_test wav_msadpcm) - add_test (lossy_comp_test_wav_ulaw lossy_comp_test wav_ulaw) - add_test (lossy_comp_test_wav_alaw lossy_comp_test wav_alaw) - add_test (lossy_comp_test_wav_gsm610 lossy_comp_test wav_gsm610) - add_test (lossy_comp_test_wav_g721 lossy_comp_test wav_g721) - add_test (lossy_comp_test_wav_nmsadpcm lossy_comp_test wav_nmsadpcm) - add_test (peak_chunk_test_wav peak_chunk_test wav) - add_test (header_test_wav header_test wav) - add_test (misc_test_wav misc_test wav) - add_test (string_test_wav string_test wav) - add_test (multi_file_test_wav multi_file_test wav) - add_test (chunk_test_wav chunk_test wav) - - ### w64-tests - - add_test (write_read_test_w64 write_read_test w64) - add_test (lossy_comp_test_w64_ima lossy_comp_test w64_ima) - add_test (lossy_comp_test_w64_msadpcm lossy_comp_test w64_msadpcm) - add_test (lossy_comp_test_w64_ulaw lossy_comp_test w64_ulaw) - add_test (lossy_comp_test_w64_alaw lossy_comp_test w64_alaw) - add_test (lossy_comp_test_w64_gsm610 lossy_comp_test w64_gsm610) - add_test (header_test_w64 header_test w64) - add_test (misc_test_w64 misc_test w64) - - ### rf64-tests - - add_test (write_read_test_rf64 write_read_test rf64) - add_test (header_test_rf64 header_test rf64) - add_test (misc_test_rf64 misc_test rf64) - add_test (string_test_rf64 string_test rf64) - add_test (peak_chunk_test_rf64 peak_chunk_test rf64) - add_test (chunk_test_rf64 chunk_test rf64) - - ### raw-tests - add_test (write_read_test_raw write_read_test raw) - add_test (lossy_comp_test_raw_ulaw lossy_comp_test raw_ulaw) - add_test (lossy_comp_test_raw_alaw lossy_comp_test raw_alaw) - add_test (lossy_comp_test_raw_gsm610 lossy_comp_test raw_gsm610) - add_test (lossy_comp_test_vox_adpcm lossy_comp_test vox_adpcm) - add_test (raw_test raw_test) - - ### paf-tests - add_test (write_read_test_paf write_read_test paf) - add_test (header_test_paf header_test paf) - add_test (misc_test_paf misc_test paf) - - ### svx-tests - add_test (write_read_test_svx write_read_test svx) - add_test (header_test_svx header_test svx) - add_test (misc_test_svx misc_test svx) - - ### nist-tests - add_test (write_read_test_nist write_read_test nist) - add_test (lossy_comp_test_nist_ulaw lossy_comp_test nist_ulaw) - add_test (lossy_comp_test_nist_alaw lossy_comp_test nist_alaw) - add_test (header_test_nist header_test nist) - add_test (misc_test_nist misc_test nist) - - ### ircam-tests - add_test (write_read_test_ircam write_read_test ircam) - add_test (lossy_comp_test_ircam_ulaw lossy_comp_test ircam_ulaw) - add_test (lossy_comp_test_ircam_alaw lossy_comp_test ircam_alaw) - add_test (header_test_ircam header_test ircam) - add_test (misc_test_ircam misc_test ircam) - - ### voc-tests - add_test (write_read_test_voc write_read_test voc) - add_test (lossy_comp_test_voc_ulaw lossy_comp_test voc_ulaw) - add_test (lossy_comp_test_voc_alaw lossy_comp_test voc_alaw) - add_test (header_test_voc header_test voc) - add_test (misc_test_voc misc_test voc) - - ### mat4-tests - add_test (write_read_test_mat4 write_read_test mat4) - add_test (header_test_mat4 header_test mat4) - add_test (misc_test_mat4 misc_test mat4) - - ### mat5-tests - add_test (write_read_test_mat5 write_read_test mat5) - add_test (header_test_mat5 header_test mat5) - add_test (misc_test_mat5 misc_test mat5) - - ### pvf-tests - add_test (write_read_test_pvf write_read_test pvf) - add_test (header_test_pvf header_test pvf) - add_test (misc_test_pvf misc_test pvf) - - ### xi-tests - add_test (lossy_comp_test_xi_dpcm lossy_comp_test xi_dpcm) - - ### htk-tests - add_test (write_read_test_htk write_read_test htk) - add_test (header_test_htk header_test htk) - add_test (misc_test_htk misc_test htk) - - ### avr-tests - add_test (write_read_test_avr write_read_test avr) - add_test (header_test_avr header_test avr) - add_test (misc_test_avr misc_test avr) - - ### sds-tests - add_test (write_read_test_sds write_read_test sds) - add_test (header_test_sds header_test sds) - add_test (misc_test_sds misc_test sds) - - # sd2-tests - add_test (write_read_test_sd2 write_read_test sd2) - - ### wve-tests - add_test (lossy_comp_test_wve lossy_comp_test wve) - - ### mpc2k-tests - add_test (write_read_test_mpc2k write_read_test mpc2k) - add_test (header_test_mpc2k header_test mpc2k) - add_test (misc_test_mpc2k misc_test mpc2k) - - ### flac-tests - add_test (write_read_test_flac write_read_test flac) - add_test (compression_size_test_flac compression_size_test flac) - add_test (string_test_flac string_test flac) - - ### vorbis-tests - add_test (ogg_test ogg_test) - add_test (compression_size_test_vorbis compression_size_test vorbis) - add_test (lossy_comp_test_ogg_vorbis lossy_comp_test ogg_vorbis) - add_test (string_test_ogg string_test ogg) - add_test (misc_test_ogg misc_test ogg) - - ### opus-tests ### - add_test (ogg_opus_test ogg_opus_test) - add_test (compression_size_test_opus compression_size_test opus) - add_test (lossy_comp_test_ogg_opus lossy_comp_test ogg_opus) - add_test (string_test_opus string_test opus) - - ### mpeg-tests ### - add_test (mpeg_test mpeg_test) - add_test (compression_size_test_mpeg compression_size_test mpeg) - - ### io-tests - add_test (stdio_test stdio_test) - add_test (pipe_test pipe_test) - add_test (virtual_io_test virtual_io_test) - - set (SNDFILE_TEST_TARGETS - test_utils - test_main - sfversion - error_test - ulaw_test - alaw_test - dwvw_test - command_test - floating_point_test - checksum_test - scale_clip_test - headerless_test - rdwr_test - locale_test - cpp_test - external_libs_test - format_check_test - channel_test - pcm_test - write_read_test - lossy_comp_test - peak_chunk_test - header_test - misc_test - string_test - multi_file_test - aiff_rw_test - chunk_test - long_read_write_test - raw_test - compression_size_test - ogg_test - stdin_test - stdout_test - stdio_test - pipe_test - virtual_io_test - g72x_test - ) - -# if (WIN32 AND BUILD_SHARED_LIBS) -# list (APPEND SNDFILE_TEST_TARGETS win32_ordinal_test) -# endif () - - set_target_properties(${SNDFILE_TEST_TARGETS} PROPERTIES FOLDER Tests) - -endif () - -if (ENABLE_CPACK) - if ((NOT CPACK_PACKAGE_VERSION) AND CPACK_PACKAGE_VERSION_STAGE) - set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_FULL}") - endif () - include (CPack) -endif () diff --git a/Engine/lib/libsndfile/CODEOWNERS b/Engine/lib/libsndfile/CODEOWNERS deleted file mode 100644 index d67616ee2..000000000 --- a/Engine/lib/libsndfile/CODEOWNERS +++ /dev/null @@ -1,14 +0,0 @@ -# The owners of this repository. In order of suggestions as reviewers. -* @evpobr @SoapGentoo @arthurt @erikd - -# Autotools -configure.ac Makefile.am @SoapGentoo @erikd - -# CMake -CMakeLists.txt /cmake/ @evpobr - -# Ogg Opus format -/src/ogg_opus.c @arthurt - -# Documentation -/doc/ /man/ @evpobr diff --git a/Engine/lib/libsndfile/CONTRIBUTING.md b/Engine/lib/libsndfile/CONTRIBUTING.md deleted file mode 100644 index 0bf14b764..000000000 --- a/Engine/lib/libsndfile/CONTRIBUTING.md +++ /dev/null @@ -1,49 +0,0 @@ -# Contributing - -## Submitting Issues - -* If your issue is that libsndfile is not able to or is incorrectly reading one - of your files, please include the output of the `sndfile-info` program run - against the file. -* If you are writing a program that uses libsndfile and you think there is a bug - in libsndfile, reduce your program to the minimal example, make sure you compile - it with warnings on (for GCC I would recommend at least `-Wall -Wextra`) and that - your program is warning free, and that is is error free when run under Valgrind - or compiled with AddressSanitizer. - -## Submitting Patches - -* Patches should pass all existing tests -* Patches should pass all pre-commit hook tests. -* Patches should always be submitted via a either Github "pull request" or a - via emailed patches created using "git format-patch". -* Patches for new features should include tests and documentation. -* Commit messages should follow the ["How to Write a Git Commit Message"](https://chris.beams.io/posts/git-commit/) guide: - 1. Separate subject from body with a blank line - 2. Limit the subject line to 50 characters - 3. Capitalize the subject line - 4. Do not end the subject line with a period - 5. Use the imperative mood in the subject line - 6. Wrap the body at 72 characters - 7. Use the body to explain what and why vs. how - - Additional rule: the commit message may contain a prefix. The prefix must - contain the name of the feature or source file related to the commit and must - end with a colon followed by the message body. - - Examples of good commit messages: - 1. Fix typo - 2. Update CHANGELOG.md - 3. Add ACT file format support - 4. ogg_vorbis: Fix granule position when seeking Vorbis streams - - Examples of bad commit messages: - 1. Fixed bug (rule 5) - 2. update docs (rule 3) - 3. Add very cool feature. (rule 4) - -* Patches to fix bugs should either pass all tests, or modify the tests in some - sane way. -* When a new feature is added for a particular file format and that feature - makes sense for other formats, then it should also be implemented for one - or two of the other formats. diff --git a/Engine/lib/libsndfile/COPYING b/Engine/lib/libsndfile/COPYING deleted file mode 100644 index c396169ee..000000000 --- a/Engine/lib/libsndfile/COPYING +++ /dev/null @@ -1,503 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - diff --git a/Engine/lib/libsndfile/ChangeLog b/Engine/lib/libsndfile/ChangeLog deleted file mode 100644 index 3843688df..000000000 --- a/Engine/lib/libsndfile/ChangeLog +++ /dev/null @@ -1,3 +0,0 @@ -For changes, please see the git commit history on github: - - https://github.com/libsndfile/libsndfile/commits/master diff --git a/Engine/lib/libsndfile/Makefile.am b/Engine/lib/libsndfile/Makefile.am deleted file mode 100644 index 54035f20b..000000000 --- a/Engine/lib/libsndfile/Makefile.am +++ /dev/null @@ -1,546 +0,0 @@ -## Process this file with automake to produce Makefile.in - -AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include -I$(top_builddir)/include $(OS_SPECIFIC_CFLAGS) - -DISTCHECK_CONFIGURE_FLAGS = --enable-werror - -CLEANFILES = programs/*.wav octave-workspace - -if FULL_SUITE -if BUILD_OCTAVE_MOD -SUBDIRS = Octave -endif -endif - -EXTRA_DIST = sndfile.pc.in Scripts/android-configure.sh \ - NEWS.OLD CHANGELOG.md Scripts/linux-to-win-cross-configure.sh \ - CMakeLists.txt $(cmake_files) Win32 SECURITY.md - -cmake_files = cmake/ClipMode.cmake cmake/FindFLAC.cmake \ - cmake/CMakeAutoGen.cmake cmake/CMakeAutoGenScript.cmake \ - cmake/FindOgg.cmake cmake/FindVorbis.cmake cmake/FindSndio.cmake \ - cmake/FindSpeex.cmake cmake/sqlite/FindSQLite3.cmake \ - cmake/SndFileChecks.cmake cmake/TestInline.cmake \ - cmake/TestLargeFiles.cmake cmake/TestInline.c.in \ - cmake/FindOpus.cmake cmake/SndFileConfig.cmake.in \ - cmake/CheckCPUArch.cmake cmake/CheckCPUArch.c.in \ - cmake/Findmp3lame.cmake cmake/Findmpg123.cmake \ - cmake/SetupABIVersions.cmake - -pkgconfig_DATA = sndfile.pc - -noinst_PROGRAMS = - -#=============================================================================== - -test: check - -# Need this target to force building of test programs. -checkprograms: $(check_PROGRAMS) - -######## -# src/ # -######## - -BUILT_SOURCES = src/test_endswap.c - -SYMBOL_FILES = src/Symbols.gnu-binutils src/Symbols.darwin src/libsndfile-1.def src/Symbols.os2 src/Symbols.static - -EXTRA_DIST += src/config.h.in src/test_endswap.tpl src/test_endswap.def \ - $(SYMBOL_FILES) src/create_symbols_file.py src/binheader_writef_check.py \ - src/GSM610/README src/GSM610/COPYRIGHT src/GSM610/ChangeLog \ - src/G72x/README src/G72x/README.original src/G72x/ChangeLog \ - src/make-static-lib-hidden-privates.sh \ - src/config.h.cmake - -if USE_WIN_VERSION_FILE -WIN_VERSION_FILE = src/version-metadata.rc -else -WIN_VERSION_FILE = -endif - -#=============================================================================== - -lib_LTLIBRARIES = src/libsndfile.la -include_HEADERS = include/sndfile.h include/sndfile.hh -src_libsndfile_la_CFLAGS = $(EXTERNAL_XIPH_CFLAGS) $(MPEG_CFLAGS) -# MinGW requires -no-undefined if a DLL is to be built. -src_libsndfile_la_LDFLAGS = -no-undefined -version-info $(SHARED_VERSION_INFO) $(SHLIB_VERSION_ARG) -src_libsndfile_la_SOURCES = src/sndfile.c src/aiff.c src/au.c src/avr.c src/caf.c src/dwd.c src/flac.c src/g72x.c src/htk.c src/ircam.c \ - src/macos.c src/mat4.c src/mat5.c src/nist.c src/paf.c src/pvf.c src/raw.c src/rx2.c src/sd2.c \ - src/sds.c src/svx.c src/txw.c src/voc.c src/wve.c src/w64.c src/wavlike.c src/wav.c src/xi.c src/mpc2k.c src/rf64.c \ - src/ogg.c src/ogg.h src/ogg_vorbis.c src/ogg_speex.c src/ogg_pcm.c src/ogg_opus.c src/ogg_vcomment.c src/ogg_vcomment.h \ - src/common.h src/sfconfig.h src/sfendian.h src/wavlike.h src/sf_unistd.h src/chanmap.h src/mpeg.c -nodist_src_libsndfile_la_SOURCES = $(nodist_include_HEADERS) -src_libsndfile_la_LIBADD = src/GSM610/libgsm.la src/G72x/libg72x.la src/ALAC/libalac.la \ - src/libcommon.la $(EXTERNAL_XIPH_LIBS) -lm $(MPEG_LIBS) -EXTRA_src_libsndfile_la_DEPENDENCIES = $(SYMBOL_FILES) - -noinst_LTLIBRARIES = src/libcommon.la -src_libcommon_la_CFLAGS = $(EXTERNAL_XIPH_CFLAGS) $(MPEG_CFLAGS) -src_libcommon_la_SOURCES = src/common.c src/file_io.c src/command.c src/pcm.c src/ulaw.c src/alaw.c \ - src/float32.c src/double64.c src/ima_adpcm.c src/ms_adpcm.c src/gsm610.c src/dwvw.c src/vox_adpcm.c \ - src/interleave.c src/strings.c src/dither.c src/cart.c src/broadcast.c src/audio_detect.c \ - src/ima_oki_adpcm.c src/ima_oki_adpcm.h src/alac.c src/chunk.c src/chanmap.c \ - src/windows.c src/id3.c src/id3.h src/nms_adpcm.c src/mpeg_decode.c src/mpeg_l3_encode.c src/mpeg.h $(WIN_VERSION_FILE) - -check_PROGRAMS = src/test_main -src_test_main_SOURCES = src/test_main.c src/test_main.h src/test_conversions.c src/test_float.c src/test_endswap.c \ - src/test_audio_detect.c src/test_log_printf.c src/test_file_io.c src/test_ima_oki_adpcm.c \ - src/test_strncpy_crlf.c src/test_broadcast_var.c src/test_cart_var.c \ - src/test_binheader_writef.c src/test_nms_adpcm.c -src_test_main_LDADD = src/libcommon.la - -############## -# src/GSM610 # -############## - -noinst_LTLIBRARIES += src/GSM610/libgsm.la -src_GSM610_libgsm_la_SOURCES = src/GSM610/config.h src/GSM610/gsm.h src/GSM610/gsm610_priv.h \ - src/GSM610/add.c src/GSM610/code.c src/GSM610/decode.c src/GSM610/gsm_create.c \ - src/GSM610/gsm_decode.c src/GSM610/gsm_destroy.c src/GSM610/gsm_encode.c \ - src/GSM610/gsm_option.c src/GSM610/long_term.c src/GSM610/lpc.c src/GSM610/preprocess.c \ - src/GSM610/rpe.c src/GSM610/short_term.c src/GSM610/table.c - -############ -# src/G72x # -############ - -noinst_LTLIBRARIES += src/G72x/libg72x.la -src_G72x_libg72x_la_SOURCES = src/G72x/g72x.h src/G72x/g72x_priv.h \ - src/G72x/g721.c src/G72x/g723_16.c src/G72x/g723_24.c src/G72x/g723_40.c src/G72x/g72x.c - -check_PROGRAMS += src/G72x/g72x_test -src_G72x_g72x_test_SOURCES = src/G72x/g72x_test.c -src_G72x_g72x_test_LDADD = src/G72x/libg72x.la - -############ -# src/ALAC # -############ - -noinst_LTLIBRARIES += src/ALAC/libalac.la -src_ALAC_libalac_la_SOURCES = src/ALAC/ALACAudioTypes.h src/ALAC/ALACBitUtilities.h \ - src/ALAC/EndianPortable.h src/ALAC/aglib.h src/ALAC/dplib.h src/ALAC/matrixlib.h \ - src/ALAC/alac_codec.h src/ALAC/shift.h \ - src/ALAC/ALACBitUtilities.c src/ALAC/ag_dec.c \ - src/ALAC/ag_enc.c src/ALAC/dp_dec.c src/ALAC/dp_enc.c src/ALAC/matrix_dec.c \ - src/ALAC/matrix_enc.c src/ALAC/alac_decoder.c src/ALAC/alac_encoder.c - -#=============================================================================== -# Generate an OS specific Symbols files. This is done when the author -# builds the distribution tarball. There should be not need for the -# end user to create these files. - -# "$<" cannot portably be used in the recipe across Make implementations -# https://www.gnu.org/software/autoconf/manual/autoconf.html#g_t_0024_003c-in-Ordinary-Make-Rules -SYMBOL_SCRIPT = $(top_srcdir)/src/create_symbols_file.py - -src/Symbols.gnu-binutils: $(SYMBOL_SCRIPT) - $(PYTHON) $(SYMBOL_SCRIPT) linux $(ABI_VERSION) > $(top_srcdir)/$@ - -src/Symbols.darwin: $(SYMBOL_SCRIPT) - $(PYTHON) $(SYMBOL_SCRIPT) darwin $(ABI_VERSION) > $(top_srcdir)/$@ - -src/libsndfile-1.def: $(SYMBOL_SCRIPT) - $(PYTHON) $(SYMBOL_SCRIPT) win32 $(ABI_VERSION) > $(top_srcdir)/$@ - -src/Symbols.os2: $(SYMBOL_SCRIPT) - $(PYTHON) $(SYMBOL_SCRIPT) os2 $(ABI_VERSION) > $(top_srcdir)/$@ - -src/Symbols.static: $(SYMBOL_SCRIPT) - $(PYTHON) $(SYMBOL_SCRIPT) static $(ABI_VERSION) > $(top_srcdir)/$@ - -#=============================================================================== -# Building windows resource files (if needed). - -.rc.lo: - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) $< -o $@ - -#=============================================================================== -# Disable autoheader. -AUTOHEADER=echo - -######## -# docs/ # -######## - -if FULL_SUITE -dist_doc_DATA = docs/index.md docs/libsndfile.jpg docs/libsndfile.css docs/print.css docs/api.md \ - docs/command.md docs/bugs.md docs/formats.md docs/sndfile_info.md docs/new_file_type_howto.md \ - docs/win32.md docs/FAQ.md docs/lists.md docs/embedded_files.md docs/octave.md \ - docs/tutorial.md -endif - -############# -# examples/ # -############# - -check_PROGRAMS += examples/make_sine examples/sfprocess examples/list_formats examples/generate examples/sndfilehandle \ - examples/sndfile-to-text examples/sndfile-loopify - -examples_sndfile_to_text_SOURCES = examples/sndfile-to-text.c -examples_sndfile_to_text_LDADD = src/libsndfile.la - -examples_sndfile_loopify_SOURCES = examples/sndfile-loopify.c -examples_sndfile_loopify_LDADD = src/libsndfile.la - -examples_make_sine_SOURCES = examples/make_sine.c -examples_make_sine_LDADD = src/libsndfile.la - -examples_sfprocess_SOURCES = examples/sfprocess.c -examples_sfprocess_LDADD = src/libsndfile.la - -examples_list_formats_SOURCES = examples/list_formats.c -examples_list_formats_LDADD = src/libsndfile.la - -examples_generate_SOURCES = examples/generate.c -examples_generate_LDADD = src/libsndfile.la - -examples_sndfilehandle_SOURCES = examples/sndfilehandle.cc -examples_sndfilehandle_LDADD = src/libsndfile.la - -########## -# tests/ # -########## - -TESTS_ENVIRONMENT = $(SHELL) tests/test_wrapper.sh - -if ENABLE_TEST_COVERAGE -CPP_TEST = -else -CPP_TEST = tests/cpp_test -endif - -TESTS = tests/pedantic-header-test.sh - -check_PROGRAMS += tests/sfversion tests/floating_point_test tests/write_read_test \ - tests/lossy_comp_test tests/error_test tests/ulaw_test tests/alaw_test tests/dwvw_test \ - tests/peak_chunk_test tests/command_test tests/stdio_test \ - tests/pcm_test tests/headerless_test tests/pipe_test tests/header_test tests/misc_test \ - tests/raw_test tests/string_test tests/multi_file_test tests/chunk_test \ - tests/scale_clip_test tests/win32_test tests/aiff_rw_test tests/virtual_io_test \ - tests/locale_test tests/win32_ordinal_test tests/ogg_test tests/compression_size_test \ - tests/checksum_test tests/external_libs_test tests/rdwr_test tests/format_check_test $(CPP_TEST) \ - tests/channel_test tests/long_read_write_test tests/stdin_test tests/stdout_test \ - tests/dither_test tests/fix_this tests/largefile_test tests/benchmark tests/ogg_opus_test \ - tests/mpeg_test - -BUILT_SOURCES += \ - tests/write_read_test.c \ - tests/pcm_test.c \ - tests/header_test.c \ - tests/utils.c \ - tests/scale_clip_test.c \ - tests/pipe_test.c \ - tests/rdwr_test.c \ - tests/floating_point_test.c \ - tests/benchmark.c - -EXTRA_DIST += $(BUILT_SOURCES) \ - tests/write_read_test.tpl tests/write_read_test.def \ - tests/pcm_test.tpl tests/pcm_test.def \ - tests/header_test.tpl tests/header_test.def \ - tests/utils.tpl tests/utils.def \ - tests/scale_clip_test.tpl tests/scale_clip_test.def \ - tests/pipe_test.tpl tests/pipe_test.def \ - tests/rdwr_test.tpl tests/rdwr_test.def \ - tests/floating_point_test.tpl tests/floating_point_test.def \ - tests/benchmark.tpl tests/benchmark.def - -# If we're cross compiling from Linux to Windows and running the test suite -# under Wine, we need a symbolic link to the generated libsndfile DLL. - -if LINUX_MINGW_CROSS_TEST - -$(check_PROGRAMS) : libsndfile-1.dll - -libsndfile-1.dll : - $(LN_S) src/.libs/$@ $@ - -clean-local : - -rm -f libsndfile-1.dll - -endif - -#=============================================================================== - -tests_sfversion_SOURCES = tests/sfversion.c -tests_sfversion_LDADD = src/libsndfile.la - -tests_write_read_test_SOURCES = tests/utils.c tests/generate.c tests/generate.h tests/write_read_test.c tests/utils.h -tests_write_read_test_LDADD = src/libsndfile.la - -tests_lossy_comp_test_SOURCES = tests/utils.c tests/lossy_comp_test.c tests/utils.h -tests_lossy_comp_test_LDADD = src/libsndfile.la - -tests_fix_this_SOURCES = tests/utils.c tests/fix_this.c tests/utils.h -tests_fix_this_LDADD = src/libsndfile.la - -tests_error_test_SOURCES = tests/error_test.c tests/utils.c tests/utils.h -tests_error_test_LDADD = src/libsndfile.la - -tests_ulaw_test_SOURCES = tests/utils.c tests/ulaw_test.c tests/utils.h -tests_ulaw_test_LDADD = src/libsndfile.la - -tests_alaw_test_SOURCES = tests/utils.c tests/alaw_test.c tests/utils.h -tests_alaw_test_LDADD = src/libsndfile.la - -tests_aiff_rw_test_SOURCES = tests/utils.c tests/aiff_rw_test.c tests/utils.h -tests_aiff_rw_test_LDADD = src/libsndfile.la - -tests_command_test_SOURCES = tests/command_test.c tests/utils.c tests/utils.h -tests_command_test_LDADD = src/libsndfile.la - -tests_locale_test_SOURCES = tests/locale_test.c tests/utils.c tests/utils.h -tests_locale_test_LDADD = src/libsndfile.la - -tests_largefile_test_SOURCES = tests/largefile_test.c tests/utils.c tests/utils.h -tests_largefile_test_LDADD = src/libsndfile.la - -tests_pcm_test_SOURCES = tests/pcm_test.c tests/utils.c tests/utils.h -tests_pcm_test_LDADD = src/libsndfile.la - -tests_headerless_test_SOURCES = tests/utils.c tests/headerless_test.c tests/utils.h -tests_headerless_test_LDADD = src/libsndfile.la - -tests_stdin_test_SOURCES = tests/stdin_test.c tests/utils.c tests/utils.h -tests_stdin_test_LDADD = src/libsndfile.la - -tests_stdout_test_SOURCES = tests/stdout_test.c tests/utils.h -tests_stdout_test_LDADD = src/libsndfile.la - -tests_stdio_test_SOURCES = tests/stdio_test.c tests/utils.c tests/utils.h -tests_stdio_test_LDADD = src/libsndfile.la - -tests_pipe_test_SOURCES = tests/pipe_test.c tests/utils.c tests/utils.h -tests_pipe_test_LDADD = src/libsndfile.la - -tests_benchmark_SOURCES = tests/benchmark.c tests/utils.h -tests_benchmark_LDADD = src/libsndfile.la - -tests_header_test_SOURCES = tests/header_test.c tests/utils.c tests/utils.h -tests_header_test_LDADD = src/libsndfile.la - -tests_misc_test_SOURCES = tests/misc_test.c tests/utils.c tests/utils.h -tests_misc_test_LDADD = src/libsndfile.la - -tests_raw_test_SOURCES = tests/raw_test.c tests/utils.c tests/utils.h -tests_raw_test_LDADD = src/libsndfile.la - -tests_string_test_SOURCES = tests/string_test.c tests/utils.c tests/utils.h -tests_string_test_LDADD = src/libsndfile.la - -tests_dither_test_SOURCES = tests/dither_test.c tests/utils.c tests/utils.h -tests_dither_test_LDADD = src/libsndfile.la - -tests_chunk_test_SOURCES = tests/chunk_test.c tests/utils.c tests/utils.h -tests_chunk_test_LDADD = src/libsndfile.la - -tests_multi_file_test_SOURCES = tests/multi_file_test.c tests/utils.c tests/utils.h -tests_multi_file_test_LDADD = src/libsndfile.la - -tests_virtual_io_test_SOURCES = tests/virtual_io_test.c tests/utils.c tests/utils.h -tests_virtual_io_test_LDADD = src/libsndfile.la - -tests_ogg_test_SOURCES = tests/ogg_test.c tests/utils.c tests/utils.h -tests_ogg_test_LDADD = src/libsndfile.la - -tests_ogg_opus_test_SOURCES = tests/ogg_opus_test.c tests/utils.c tests/utils.h -tests_ogg_opus_test_LDADD = src/libsndfile.la - -tests_compression_size_test_SOURCES = tests/compression_size_test.c tests/utils.c tests/utils.h tests/dft_cmp.h -tests_compression_size_test_LDADD = src/libsndfile.la - -tests_rdwr_test_SOURCES = tests/rdwr_test.c tests/utils.c tests/utils.h -tests_rdwr_test_LDADD = src/libsndfile.la - -tests_win32_test_SOURCES = tests/win32_test.c -# Link lib here so that generating the testsuite tarball works correctly. -tests_win32_test_LDADD = src/libsndfile.la - -tests_win32_ordinal_test_SOURCES = tests/win32_ordinal_test.c tests/utils.c tests/utils.h -tests_win32_ordinal_test_LDADD = src/libsndfile.la - -tests_external_libs_test_SOURCES = tests/external_libs_test.c tests/utils.c tests/utils.h -tests_external_libs_test_LDADD = src/libsndfile.la - -tests_format_check_test_SOURCES = tests/format_check_test.c tests/utils.c tests/utils.h -tests_format_check_test_LDADD = src/libsndfile.la - -tests_channel_test_SOURCES = tests/channel_test.c tests/utils.c tests/utils.h -tests_channel_test_LDADD = src/libsndfile.la - -tests_long_read_write_test_SOURCES = tests/long_read_write_test.c tests/utils.c tests/utils.h tests/dft_cmp.h -tests_long_read_write_test_LDADD = src/libsndfile.la - -tests_cpp_test_SOURCES = tests/cpp_test.cc tests/utils.c tests/utils.h -tests_cpp_test_LDADD = src/libsndfile.la - -tests_checksum_test_SOURCES = tests/checksum_test.c tests/utils.c tests/utils.h -tests_checksum_test_LDADD = src/libsndfile.la - -tests_mpeg_test_SOURCES = tests/mpeg_test.c tests/utils.c tests/utils.h -tests_mpeg_test_LDADD = src/libsndfile.la - -# Lite remove start -tests_dwvw_test_SOURCES = tests/dwvw_test.c tests/utils.c tests/utils.h -tests_dwvw_test_LDADD = src/libsndfile.la - -tests_floating_point_test_SOURCES = tests/utils.c tests/utils.h tests/dft_cmp.c tests/dft_cmp.h tests/floating_point_test.c -tests_floating_point_test_LDADD = src/libsndfile.la - -tests_peak_chunk_test_SOURCES = tests/peak_chunk_test.c tests/utils.c tests/utils.h -tests_peak_chunk_test_LDADD = src/libsndfile.la - -tests_scale_clip_test_SOURCES = tests/scale_clip_test.c tests/utils.c tests/utils.h -tests_scale_clip_test_LDADD = src/libsndfile.la -# Lite remove end - -#=============================================================================== -# Autogen generated sources. -# Coerce the multiple inputs -> multiple outputs problem -# into suffix rules by "linearising" the dependency graph. -# Yes, this sucks, but GNU make patterns aren't portable, -# see also https://github.com/libsndfile/libsndfile/issues/369 - -SUFFIXES = .tpl .def - -.tpl.def: - touch $@ - -# unconditionally running touch on the .def -# files is necessary to keep all timestamps -# consistent, in order to prevent stale files -# from calling autogen in tarball releases. -.def.c: - $(MAKE) $(AM_MAKEFLAGS) $< - cd $(top_srcdir)/$(@D) && autogen --writable $(= 3.15 without error. - * You can use your our method to set MSVC runtime library flags if none of - ENABLE_STATIC_RUNTIME and CMAKE_MSVC_RUNTIME_LIBRARY were set. - Advanced information: - * If this option is defined (set to ON or OFF), set CMP0091 policy to OLD - (we handle MSVC runtime library flags using compiler flags), set - corresponding compiler flags for user. - * NEW: If this option is not defined, set CMP0091 policy to OLD (we handle - MSVC runtime library flags using compiler flags), don't touch compiler - options, allow user to set it manually. - * NEW: If new CMake option CMAKE_MSVC_RUNTIME_LIBRARY is set, change - CMP0091 policy to NEW (we handle MSVC runtime library flags using that - option), don't touch compiler flags. - * NEW: If both ENABLE_STATIC_RUNTIME and CMAKE_MSVC_RUNTIME_LIBRARY are set, - terminate configuration with fatal error. - * For MinGW toolchain this option is experimental. If you enabled it and - then disabled again, you need to clear CMake cache (delete - CMakeCache.txt). - * Make CMake clip test faster. - * Fix CMake bug with sndio library dependency, thanks to @drhenault. - * Fix memory leak in wav_read_smpl_chunk() function, credit to OSS-Fuzz. - * Fix aiff_read_header() memory leak(), credit to OSS-Fuzz. - * Fix leak in wav_read_header(), credit to OSS-Fuzz. - * Fix leak in wavlike_read_cart_chunk(), credit to OSS-Fuzz. - * Fix memory leak in wav_read_acid_chunk(), credit to OSS-Fuzz. - * Fix memory leak in aiff_read_basc_chunk(), credit to OSS-Fuzz. - * Fix memory leak in wavlike_read_peak_chunk(), credit to OSS-Fuzz. - * Fix memory leak in aiff_read_header(), credit to OSS-Fuzz. - * Fix use of uninitialized value in exif_subchunk_parse(), credit to OSS-Fuzz. - * Fix use of uninitialized value in endswap_int64_t_array(), credit to - OSS-Fuzz. - * Fix up the fuzzer so that it can't under or overseek, - thanks to Max Dymond . - * Fix Autotools configure on macOS, thanks to @tmcguire and @nwh. - * Exclude repository-configuration from git-archive, thanks to @umlaeute. - * Use version-script when compiling with clang on Unix with Autotools, thanks - to @tstellar. - * Improve handling of SMPL chunks in WAV files, thanks to @zodf0055980. - -Version 1.0.30 (2020-09-18) - - * Fix critical CMake bug with broken ABI of shared libsndfile library. - * CMake build system considered to be stable. - * Move sndfile.h.in from src/ to include/ directory. To avoid problems, - delete old generated sndfile.h from $(top_builddir)/src. - * Huge documentation update. - * Fix opus test failures on BE platforms, thanks to - Arthur Taylor . - * Fix bug when sf_open_fd() function sometimes leaves filehandle open, even - if `close_desc` parameter is TRUE, thanks to @umläute. - * Fix infinite loops on some pathological SD2 files, thanks to - Jeremy Friesner . - * Switch to GitHub Actions for continuous integration. - * Add OSS-Fuzz tests to GitHub Actions workflow, thanks to - Max Dymond . - * Fix memory leak in wavlike_read_bext_chunk() function, credit to OSS-Fuzz. - * Fix undefined behavior in avr-read_header() function, credit to OSS-Fuzz. - * Add INSTALL_PKGCONFIG_MODULE CMake option to control sndfile.pc file - installation, see README.md for details. - * Add INSTALL_MANPAGES CMake option, see README.md for details. - * Fix ENABLE_COMPATIBLE_LIBSNDFILE_NAME CMake option, now it works on MinGW - platform too. - * Fix ENABLE_CPACK CMake option, see README.md for details. - * Fix ENABLE_STATIC_RUNTIME and CMAKE_MSVC_RUNTIME_LIBRARY behavior, see - README.md for details. - * Fix CMake man pages installation bug when sndfile-deinterleave.1 and - sndfile-metadata-set.1 were not installed. - * Fix sndfile-regtest paths handling on Windows platform, thanks to - Gisle Vanem . - -Version 1.0.29 (2020-08-15) - * Add support for Opus files. - * Autotool build system improvements. - * CMake build system improvements. - * Fixes for: CVE-2017-12562, CVE-2017-17456, CVE-2017-17457, CVE-2018-19661, - CVE-2018-19662, CVE-2018-19758 and CVE-2019-3832. - * Add BWF v2 loudness parameters. - * Wave64: Permit and skip arbitrary chunks prior to the data chunk. - * Fix ASAN crash in wavlike_ima_seek(). - * Fix IMA-ADPCM encoding for AIFF files. - * sndfile-convert: Handle gsm, vox and opus extensions the same way. - * Add SFC_SET_OGG_PAGE_LATENCY_MS command to get Ogg page latency for Ogg Opus - files. - * Fix parsing of some SD2 files. - * Documentation updates. - * Minor bug fixes and improvements. - -Version 1.0.28 (2017-04-02) - * Fix buffer overruns in FLAC and ID3 handling code. - * Move to variable length header storage. - * Fix detection of Large File Support for 32 bit systems. - * Remove large stack allocations in ALAC handling code. - * Remove all use of Variable Length Arrays. - * Minor bug fixes and improvements. - -Version 1.0.27 (2016-06-19) - * Fix an SF_INFO seekable flag regression introduced in 1.0.26. - * Fix potential infinite loops on malformed input files. - * Add string metadata read/write for CAF and RF64. - * Add handling of CUE chunks. - * Fix endian-ness issues in PAF files. - * Minor bug fixes and improvements. - -Version 1.0.26 (2015-11-22) - * Fix for CVE-2014-9496, SD2 buffer read overflow. - * Fix for CVE-2014-9756, file_io.c divide by zero. - * Fix for CVE-2015-7805, AIFF heap write overflow. - * Add support for ALAC encoder in a CAF container. - * Add support for Cart chunks in WAV files. - * Minor bug fixes and improvements. - -Version 1.0.25 (2011-07-13) - * Fix for Secunia Advisory SA45125, heap overflow in PAF file handler. - * Accept broken WAV files with blockalign == 0. - * Minor bug fixes and improvements. - -Version 1.0.24 (2011-03-23) - * WAV files now have an 18 byte u-law and A-law fmt chunk. - * Document virtual I/O functionality. - * Two new methods rawHandle() and takeOwnership() in sndfile.hh. - * AIFF fix for non-zero offset value in SSND chunk. - * Minor bug fixes and improvements. - -Version 1.0.23 (2010-10-10) - * Add version metadata to Windows DLL. - * Add a missing 'inline' to sndfile.hh. - * Update docs. - * Minor bug fixes and improvements. - -Version 1.0.22 (2010-10-04) - * Couple of fixes for SDS file writer. - * Fixes arising from static analysis. - * Handle FLAC files with ID3 meta data at start of file. - * Handle FLAC files which report zero length. - * Other minor bug fixes and improvements. - -Version 1.0.21 (2009-12-13) - * Add a couple of new binary programs to programs/ dir. - * Remove sndfile-jackplay (now in sndfile-tools package). - * Add windows only function sf_wchar_open(). - * Bunch of minor bug fixes. - -Version 1.0.20 (2009-05-14) - * Fix potential heap overflow in VOC file parser (Tobias Klein, http://www.trapkit.de/). - -Version 1.0.19 (2009-03-02) - * Fix for CVE-2009-0186 (Alin Rad Pop, Secunia Research). - * Huge number of minor bug fixes as a result of static analysis. - -Version 1.0.18 (2009-02-07) - * Add Ogg/Vorbis support (thanks to John ffitch). - * Remove captive FLAC library. - * Many new features and bug fixes. - * Generate Win32 and Win64 pre-compiled binaries. - -Version 1.0.17 (2006-08-31) - * Add sndfile.hh C++ wrapper. - * Update Win32 MinGW build instructions. - * Minor bug fixes and cleanups. - -Version 1.0.16 (2006-04-30) - * Add support for Broadcast (BEXT) chunks in WAV files. - * Implement new commands SFC_GET_SIGNAL_MAX and SFC_GET_MAX_ALL_CHANNELS. - * Add support for RIFX (big endian WAV variant). - * Fix configure script bugs. - * Fix bug in INST and MARK chunk writing for AIFF files. - -Version 1.0.15 (2006-03-16) - * Fix some ia64 issues. - * Fix precompiled DLL. - * Minor bug fixes. - -Version 1.0.14 (2006-02-19) - * Really fix MinGW compile problems. - * Minor bug fixes. - -Version 1.0.13 (2006-01-21) - * Fix for MinGW compiler problems. - * Allow readin/write of instrument chunks from WAV and AIFF files. - * Compile problem fix for Solaris compiler. - * Minor cleanups and bug fixes. - -Version 1.0.12 (2005-09-30) - * Add support for FLAC and Apple's Core Audio Format (CAF). - * Add virtual I/O interface (still needs docs). - * Cygwin and other Win32 fixes. - * Minor bug fixes and cleanups. - -Version 1.0.11 (2004-11-15) - * Add support for SD2 files. - * Add read support for loop info in WAV and AIFF files. - * Add more tests. - * Improve type safety. - * Minor optimisations and bug fixes. - -Version 1.0.10 (2004-06-15) - * Fix AIFF read/write mode bugs. - * Add support for compiling Win32 DLLS using MinGW. - * Fix problems resulting in failed compiles with gcc-2.95. - * Improve test suite. - * Minor bug fixes. - -Version 1.0.9 (2004-03-30) - * Add handling of AVR (Audio Visual Research) files. - * Improve handling of WAVEFORMATEXTENSIBLE WAV files. - * Fix for using pipes on Win32. - -Version 1.0.8 (2004-03-14) - * Correct peak chunk handing for files with > 16 tracks. - * Fix for WAV files with huge number of CUE chunks. - -Version 1.0.7 (2004-02-25) - * Fix clip mode detection on ia64, MIPS and other CPUs. - * Fix two MacOSX build problems. - -Version 1.0.6 (2004-02-08) - * Added support for native Win32 file access API (Ross Bencina). - * New mode to add clippling then a converting from float/double to integer - would otherwise wrap around. - * Fixed a bug in reading/writing files > 2Gig on Linux, Solaris and others. - * Many minor bug fixes. - * Other random fixes for Win32. - -Version 1.0.5 (2003-05-03) - * Added support for HTK files. - * Added new function sf_open_fd() to allow for secure opening of temporary - files as well as reading/writing sound files embedded within larger - container files. - * Added string support for AIFF files. - * Minor bug fixes and code cleanups. - -Version 1.0.4 (2003-02-02) - * Added suport of PVF and XI files. - * Added functionality for setting and retreiving strings from sound files. - * Minor code cleanups and bug fixes. - -Version 1.0.3 (2002-12-09) - * Minor bug fixes. - -Version 1.0.2 (2002-11-24) - * Added support for VOX ADPCM. - * Improved error reporting. - * Added version scripting on Linux and Solaris. - * Minor bug fixes. - -Version 1.0.1 (2002-09-14) - * Added MAT and MAT5 file formats. - * Minor bug fixes. - -Version 1.0.0 (2002-08-16) - * Final release for 1.0.0. - -Version 1.0.0rc6 (2002-08-14) - * Release candidate 6 for the 1.0.0 series. - * MacOS9 fixes. - -Version 1.0.0rc5 (2002-08-10) - * Release candidate 5 for the 1.0.0 series. - * Changed the definition of sf_count_t which was causing problems when - libsndfile was compiled with other libraries (ie WxWindows). - * Minor bug fixes. - * Documentation cleanup. - -Version 1.0.0rc4 (2002-08-03) - * Release candidate 4 for the 1.0.0 series. - * Minor bug fixes. - * Fix broken Win32 "make check". - -Version 1.0.0rc3 (2002-08-02) - * Release candidate 3 for the 1.0.0 series. - * Fix bug where libsndfile was reading beyond the end of the data chunk. - * Added on-the-fly header updates on write. - * Fix a couple of documentation issues. - -Version 1.0.0rc2 (2002-06-24) - * Release candidate 2 for the 1.0.0 series. - * Fix compile problem for Win32. - -Version 1.0.0rc1 (2002-06-24) - * Release candidate 1 for the 1.0.0 series. - -Version 0.0.28 (2002-04-27) - * Last official release of 0.0.X series of the library. - -Version 0.0.8 (1999-02-16) - * First official release. diff --git a/Engine/lib/libsndfile/Octave/Makefile.am b/Engine/lib/libsndfile/Octave/Makefile.am deleted file mode 100644 index 3f0078e18..000000000 --- a/Engine/lib/libsndfile/Octave/Makefile.am +++ /dev/null @@ -1,79 +0,0 @@ -## Process this file with automake to produce Makefile.in - -# Prevent any extension. -EXEEXT = - -CXXLD = $(CXX) -CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ - $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ - -EXTRA_DIST = sndfile_load.m sndfile_save.m sndfile_play.m \ - octave_test.m octave_test.sh $(oct_module_srcs) PKG_ADD - -octconfigdir = $(exec_prefix)/share/octave/site/m -octconfig_DATA = sndfile_load.m sndfile_save.m sndfile_play.m - -OCTAVE_DEST_MDIR = @OCTAVE_DEST_MDIR@ -OCTAVE_DEST_ODIR = @OCTAVE_DEST_ODIR@/sndfile - -OCT_CXXFLAGS = @OCT_CXXFLAGS@ -OCT_LIB_DIR = @OCT_LIB_DIR@ -OCT_LIBS = @OCT_LIBS@ - -SNDFILEDIR = $(top_builddir)/src -AM_CPPFLAGS = -I$(SNDFILEDIR) - -oct_module_srcs = sndfile.cc -oct_module_files = sndfile.oct PKG_ADD - -# Make these noinst so they can be installed manually. -noinst_DATA = $(oct_module_files) - - -# Used by shave which cleans up automake generated Makefile output. -V = @ -Q = $(V:1=) -QUIET_GEN = $(Q:@=@echo ' GEN '$@;) - - -# Use Octave's mkoctfile to do all the heavy lifting. Unfortunately, its -# a little dumb so we need to guide it carefully. -sndfile.oct : sndfile.o - $(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) $(top_builddir)/Octave/$+ -L$(SNDFILEDIR)/.libs -L$(SNDFILEDIR) -lsndfile -o $(top_builddir)/Octave/$@ > /dev/null - -sndfile.o : sndfile.cc - $(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) -c $+ -o $(top_builddir)/Octave/$@ > /dev/null - -# Allow for the test being run in the build dir, but the test script -# being located in the source dir. -check : - octave_src_dir=$(srcdir) $(srcdir)/octave_test.sh - - -# Since the octave modules are installed in a special location, a custom install -# and uninstall routine must be specified. -install-exec-local : $(oct_module_files) - @$(NORMAL_INSTALL) - test -z "$(OCTAVE_DEST_ODIR)" || $(mkdir_p) "$(DESTDIR)$(OCTAVE_DEST_ODIR)" - @list='$(oct_module_files)'; for p in $$list; do \ - p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - if test -f $$p \ - || test -f $$p1 \ - ; then \ - f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL) '$$p' '$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL) "$$p" "$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f" || exit 1; \ - else :; fi; \ - done - -uninstall-local : - @$(NORMAL_UNINSTALL) - @list='$(oct_module_files)'; for p in $$list; do \ - f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f '$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f'"; \ - rm -f "$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f"; \ - done - -clean-local : - rm -f sndfile.o sndfile.oct - @if test $(abs_builddir) != $(abs_srcdir) ; then rm -f PKG_ADD ; fi diff --git a/Engine/lib/libsndfile/Octave/PKG_ADD b/Engine/lib/libsndfile/Octave/PKG_ADD deleted file mode 100644 index 3efd68855..000000000 --- a/Engine/lib/libsndfile/Octave/PKG_ADD +++ /dev/null @@ -1,3 +0,0 @@ -autoload ("sfread", "sndfile.oct"); -autoload ("sfversion", "sndfile.oct"); -autoload ("sfwrite", "sndfile.oct"); diff --git a/Engine/lib/libsndfile/Octave/Readme.txt b/Engine/lib/libsndfile/Octave/Readme.txt deleted file mode 100644 index c38605bff..000000000 --- a/Engine/lib/libsndfile/Octave/Readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -The libsndfile Modules for GNU Octave -===================================== - -These modules are currently known to work with version 3.0 of GNU Octave on -Linux. They have not been tested elsewhere. - - -Build Requirements ------------------- - -In order to build these libsndfile related modules for GNU Octave on a Debian -GNU/Linux (or Debian derived) system, you will need (on top of what is normally -required to build libsndfile) the package: - - octaveX.Y-headers - -where X.Y matches the version number of your installation of GNU Octave. - -The configure script in the top level libsndfile directory will detect the -presence and correct versions of the Octave build tools. The building of these -modules will only go ahead if everything is correct. - - diff --git a/Engine/lib/libsndfile/Octave/format.h b/Engine/lib/libsndfile/Octave/format.h deleted file mode 100644 index ce769b2c6..000000000 --- a/Engine/lib/libsndfile/Octave/format.h +++ /dev/null @@ -1,21 +0,0 @@ -/* -** Copyright (C) 2007-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -int format_of_str (const std::string & fmt) ; - -void string_of_format (std::string & fmt, int format) ; diff --git a/Engine/lib/libsndfile/Octave/octave_test.m b/Engine/lib/libsndfile/Octave/octave_test.m deleted file mode 100644 index 25a922e89..000000000 --- a/Engine/lib/libsndfile/Octave/octave_test.m +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2007-2011 Erik de Castro Lopo -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -# These tests are nowhere near comprehensive. - -printf (" Running Octave tests : ") ; -fflush (stdout) ; - -filename = "whatever" ; -srate_out = 32000 ; -fmt_out = "wav-float" ; - -t = (2 * pi / srate_out * (0:srate_out-1))' ; -data_out = sin (440.0 * t) ; - -# Write out a file. -sfwrite (filename, data_out, srate_out, fmt_out) ; - -# Read it back in again. -[ data_in, srate_in, fmt_in ] = sfread (filename) ; - -if (srate_in != srate_out) - error ("\n\nSample rate mismatch : %d -> %d.\n\n", srate_out, srate_in) ; - endif - -# Octave strcmp return 1 for the same. -if (strcmp (fmt_in, fmt_out) != 1) - error ("\n\nFormat error : '%s' -> '%s'.\n\n", fmt_out, fmt_in) ; - endif - -err = max (abs (data_out - data_in)) ; - -if (err > 1e-7) - error ("err : %g\n", err) ; - endif - -printf ("ok") ; - -unlink (filename) ; diff --git a/Engine/lib/libsndfile/Octave/octave_test.sh b/Engine/lib/libsndfile/Octave/octave_test.sh deleted file mode 100644 index 3c6f36e23..000000000 --- a/Engine/lib/libsndfile/Octave/octave_test.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - - -# Check where we're being run from. -if test -d Octave ; then - cd Octave - octave_src_dir=$(pwd) -elif test -z "$octave_src_dir" ; then - echo - echo "Error : \$octave_src_dir is undefined." - echo - exit 1 -else - octave_src_dir=$(cd $octave_src_dir && pwd) - fi - -# Find libsndfile shared object. -libsndfile_lib_location="" - -if test -f "../src/.libs/libsndfile.so" ; then - libsndfile_lib_location="../src/.libs/" -elif test -f "../src/libsndfile.so" ; then - libsndfile_lib_location="../src/" -elif test -f "../src/.libs/libsndfile.dylib" ; then - libsndfile_lib_location="../src/.libs/" -elif test -f "../src/libsndfile.dylib" ; then - libsndfile_lib_location="../src/" -else - echo - echo "Not able to find the libsndfile shared lib we've just built." - echo "This may cause the following test to fail." - echo - fi - -libsndfile_lib_location=`(cd $libsndfile_lib_location && pwd)` - - -# Find sndfile.oct -sndfile_oct_location="" - -if test -f .libs/sndfile.oct ; then - sndfile_oct_location=".libs" -elif test -f sndfile.oct ; then - sndfile_oct_location="." -else - echo "Not able to find the sndfile.oct binaries we've just built." - exit 1 - fi - -case `file -b $sndfile_oct_location/sndfile.oct` in - ELF*) - ;; - Mach*) - echo "Tests don't work on this platform." - exit 0 - ;; - *) - echo "Not able to find the sndfile.oct binary we just built." - exit 1 - ;; - esac - - -# Make sure the TERM environment variable doesn't contain anything wrong. -unset TERM -# echo "octave_src_dir : $octave_src_dir" -# echo "libsndfile_lib_location : $libsndfile_lib_location" -# echo "sndfile_oct_location : $sndfile_oct_location" - -if test ! -f PKG_ADD ; then - cp $octave_src_dir/PKG_ADD . - fi - -export LD_LIBRARY_PATH="$libsndfile_lib_location:$LD_LIBRARY_PATH" - -octave_script="$octave_src_dir/octave_test.m" - -(cd $sndfile_oct_location && octave -qH $octave_script) -res=$? -echo -exit $res diff --git a/Engine/lib/libsndfile/Octave/sndfile.cc b/Engine/lib/libsndfile/Octave/sndfile.cc deleted file mode 100644 index 6e9cd44cc..000000000 --- a/Engine/lib/libsndfile/Octave/sndfile.cc +++ /dev/null @@ -1,405 +0,0 @@ -/* -** Copyright (C) 2007-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include - -#include "sndfile.h" - -#define FOUR_GIG (0x100000000LL) -#define BUFFER_FRAMES 8192 - - -static int format_of_str (const std::string & fmt) ; -static void string_of_format (std::string & fmt, int format) ; - - -DEFUN_DLD (sfversion, args, nargout , -"-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {@var{version} =} sfversion ()\n\ -@cindex Reading sound files\n\ -Return a string containing the libsndfile version.\n\ -@seealso{sfread, sfwrite}\n\ -@end deftypefn") -{ char buffer [256] ; - octave_value_list retval ; - - /* Bail out if the input parameters are bad. */ - if (args.length () != 0 || nargout > 1) - { print_usage () ; - return retval ; - } ; - - sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ; - - std::string version (buffer) ; - - retval.append (version) ; - return retval ; -} /* sfversion */ - - -DEFUN_DLD (sfread, args, nargout , -"-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {@var{data},@var{srate},@var{format} =} sfread (@var{filename})\n\ -@cindex Reading sound files\n\ -Read a sound file from disk using libsndfile.\n\ -@seealso{sfversion, sfwrite}\n\ -@end deftypefn") -{ SNDFILE * file ; - SF_INFO sfinfo ; - - octave_value_list retval ; - - int nargin = args.length () ; - - /* Bail out if the input parameters are bad. */ - if ((nargin != 1) || !args (0) .is_string () || nargout < 1 || nargout > 3) - { print_usage () ; - return retval ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - std::string filename = args (0).string_value () ; - - if ((file = sf_open (filename.c_str (), SFM_READ, &sfinfo)) == NULL) - { error ("sfread: couldn't open file %s : %s", filename.c_str (), sf_strerror (NULL)) ; - return retval ; - } ; - - if (sfinfo.frames > FOUR_GIG) - printf ("This is a really huge file (%lld frames).\nYou may run out of memory trying to load it.\n", (long long) sfinfo.frames) ; - - dim_vector dim = dim_vector () ; - dim.resize (2) ; - dim (0) = sfinfo.frames ; - dim (1) = sfinfo.channels ; - - /* Should I be using Matrix instead? */ - NDArray out (dim, 0.0) ; - - float buffer [BUFFER_FRAMES * sfinfo.channels] ; - int readcount ; - sf_count_t total = 0 ; - - do - { readcount = sf_readf_float (file, buffer, BUFFER_FRAMES) ; - - /* Make sure we don't read more frames than we allocated. */ - if (total + readcount > sfinfo.frames) - readcount = sfinfo.frames - total ; - - for (int ch = 0 ; ch < sfinfo.channels ; ch++) - { for (int k = 0 ; k < readcount ; k++) - out (total + k, ch) = buffer [k * sfinfo.channels + ch] ; - } ; - - total += readcount ; - } while (readcount > 0 && total < sfinfo.frames) ; - - retval.append (out.squeeze ()) ; - - if (nargout >= 2) - retval.append ((octave_uint32) sfinfo.samplerate) ; - - if (nargout >= 3) - { std::string fmt ("") ; - string_of_format (fmt, sfinfo.format) ; - retval.append (fmt) ; - } ; - - /* Clean up. */ - sf_close (file) ; - - return retval ; -} /* sfread */ - -DEFUN_DLD (sfwrite, args, nargout , -"-*- texinfo -*-\n\ -@deftypefn {Function File} sfwrite (@var{filename},@var{data},@var{srate},@var{format})\n\ -Write a sound file to disk using libsndfile.\n\ -@seealso{sfread, sfversion}\n\ -@end deftypefn\n\ -") -{ SNDFILE * file ; - SF_INFO sfinfo ; - - octave_value_list retval ; - - int nargin = args.length () ; - - /* Bail out if the input parameters are bad. */ - if (nargin != 4 || !args (0).is_string () || !args (1).is_real_matrix () - || !args (2).is_real_scalar () || !args (3).is_string () - || nargout != 0) - { print_usage () ; - return retval ; - } ; - - std::string filename = args (0).string_value () ; - std::string format = args (3).string_value () ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - sfinfo.format = format_of_str (format) ; - if (sfinfo.format == 0) - { error ("Bad format '%s'", format.c_str ()) ; - return retval ; - } ; - - sfinfo.samplerate = lrint (args (2).scalar_value ()) ; - if (sfinfo.samplerate < 1) - { error ("Bad sample rate : %d.\n", sfinfo.samplerate) ; - return retval ; - } ; - - Matrix data = args (1).matrix_value () ; - long rows = args (1).rows () ; - long cols = args (1).columns () ; - - if (cols > rows) - { error ("Audio data should have one column per channel, but supplied data " - "has %ld rows and %ld columns.\n", rows, cols) ; - return retval ; - } ; - - sfinfo.channels = cols ; - - if ((file = sf_open (filename.c_str (), SFM_WRITE, &sfinfo)) == NULL) - { error ("Couldn't open file %s : %s", filename.c_str (), sf_strerror (NULL)) ; - return retval ; - } ; - - float buffer [BUFFER_FRAMES * sfinfo.channels] ; - int writecount ; - long total = 0 ; - - do - { - writecount = BUFFER_FRAMES ; - - /* Make sure we don't read more frames than we allocated. */ - if (total + writecount > rows) - writecount = rows - total ; - - for (int ch = 0 ; ch < sfinfo.channels ; ch++) - { for (int k = 0 ; k < writecount ; k++) - buffer [k * sfinfo.channels + ch] = data (total + k, ch) ; - } ; - - if (writecount > 0) - sf_writef_float (file, buffer, writecount) ; - - total += writecount ; - } while (writecount > 0 && total < rows) ; - - /* Clean up. */ - sf_close (file) ; - - return retval ; -} /* sfwrite */ - - -static void -str_split (const std::string & str, const std::string & delim, std::vector & output) -{ - unsigned int offset = 0 ; - size_t delim_index = 0 ; - - delim_index = str.find (delim, offset) ; - - while (delim_index != std::string::npos) - { - output.push_back (str.substr(offset, delim_index - offset)) ; - offset += delim_index - offset + delim.length () ; - delim_index = str.find (delim, offset) ; - } - - output.push_back (str.substr (offset)) ; -} /* str_split */ - -static int -hash_of_str (const std::string & str) -{ - int hash = 0 ; - - for (unsigned k = 0 ; k < str.length () ; k++) - hash = (hash * 3) + tolower (str [k]) ; - - return hash ; -} /* hash_of_str */ - -static int -major_format_of_hash (const std::string & str) -{ int hash ; - - hash = hash_of_str (str) ; - - switch (hash) - { - case 0x5c8 : /* 'wav' */ return SF_FORMAT_WAV ; - case 0xf84 : /* 'aiff' */ return SF_FORMAT_AIFF ; - case 0x198 : /* 'au' */ return SF_FORMAT_AU ; - case 0x579 : /* 'paf' */ return SF_FORMAT_PAF ; - case 0x5e5 : /* 'svx' */ return SF_FORMAT_SVX ; - case 0x1118 : /* 'nist' */ return SF_FORMAT_NIST ; - case 0x5d6 : /* 'voc' */ return SF_FORMAT_VOC ; - case 0x324a : /* 'ircam' */ return SF_FORMAT_IRCAM ; - case 0x505 : /* 'w64' */ return SF_FORMAT_W64 ; - case 0x1078 : /* 'mat4' */ return SF_FORMAT_MAT4 ; - case 0x1079 : /* 'mat5' */ return SF_FORMAT_MAT5 ; - case 0x5b8 : /* 'pvf' */ return SF_FORMAT_PVF ; - case 0x1d1 : /* 'xi' */ return SF_FORMAT_XI ; - case 0x56f : /* 'htk' */ return SF_FORMAT_HTK ; - case 0x5aa : /* 'sds' */ return SF_FORMAT_SDS ; - case 0x53d : /* 'avr' */ return SF_FORMAT_AVR ; - case 0x11d0 : /* 'wavx' */ return SF_FORMAT_WAVEX ; - case 0x569 : /* 'sd2' */ return SF_FORMAT_SD2 ; - case 0x1014 : /* 'flac' */ return SF_FORMAT_FLAC ; - case 0x504 : /* 'caf' */ return SF_FORMAT_CAF ; - case 0x5f6 : /* 'wve' */ return SF_FORMAT_WVE ; - default : break ; - } ; - - printf ("%s : hash '%s' -> 0x%x\n", __func__, str.c_str (), hash) ; - - return 0 ; -} /* major_format_of_hash */ - -static int -minor_format_of_hash (const std::string & str) -{ int hash ; - - hash = hash_of_str (str) ; - - switch (hash) - { - case 0x1085 : /* 'int8' */ return SF_FORMAT_PCM_S8 ; - case 0x358a : /* 'uint8' */ return SF_FORMAT_PCM_U8 ; - case 0x31b0 : /* 'int16' */ return SF_FORMAT_PCM_16 ; - case 0x31b1 : /* 'int24' */ return SF_FORMAT_PCM_24 ; - case 0x31b2 : /* 'int32' */ return SF_FORMAT_PCM_32 ; - case 0x3128 : /* 'float' */ return SF_FORMAT_FLOAT ; - case 0x937d : /* 'double' */ return SF_FORMAT_DOUBLE ; - case 0x11bd : /* 'ulaw' */ return SF_FORMAT_ULAW ; - case 0xfa1 : /* 'alaw' */ return SF_FORMAT_ALAW ; - case 0xfc361 : /* 'ima_adpcm' */ return SF_FORMAT_IMA_ADPCM ; - case 0x5739a : /* 'ms_adpcm' */ return SF_FORMAT_MS_ADPCM ; - case 0x9450 : /* 'gsm610' */ return SF_FORMAT_GSM610 ; - case 0x172a3 : /* 'g721_32' */ return SF_FORMAT_G721_32 ; - case 0x172d8 : /* 'g723_24' */ return SF_FORMAT_G723_24 ; - case 0x172da : /* 'g723_40' */ return SF_FORMAT_G723_40 ; - default : break ; - } ; - - printf ("%s : hash '%s' -> 0x%x\n", __func__, str.c_str (), hash) ; - - return 0 ; -} /* minor_format_of_hash */ - - -static const char * -string_of_major_format (int format) -{ - switch (format & SF_FORMAT_TYPEMASK) - { - case SF_FORMAT_WAV : return "wav" ; - case SF_FORMAT_AIFF : return "aiff" ; - case SF_FORMAT_AU : return "au" ; - case SF_FORMAT_PAF : return "paf" ; - case SF_FORMAT_SVX : return "svx" ; - case SF_FORMAT_NIST : return "nist" ; - case SF_FORMAT_VOC : return "voc" ; - case SF_FORMAT_IRCAM : return "ircam" ; - case SF_FORMAT_W64 : return "w64" ; - case SF_FORMAT_MAT4 : return "mat4" ; - case SF_FORMAT_MAT5 : return "mat5" ; - case SF_FORMAT_PVF : return "pvf" ; - case SF_FORMAT_XI : return "xi" ; - case SF_FORMAT_HTK : return "htk" ; - case SF_FORMAT_SDS : return "sds" ; - case SF_FORMAT_AVR : return "avr" ; - case SF_FORMAT_WAVEX : return "wavx" ; - case SF_FORMAT_SD2 : return "sd2" ; - case SF_FORMAT_FLAC : return "flac" ; - case SF_FORMAT_CAF : return "caf" ; - case SF_FORMAT_WVE : return "wfe" ; - default : break ; - } ; - - return "unknown" ; -} /* string_of_major_format */ - -static const char * -string_of_minor_format (int format) -{ - switch (format & SF_FORMAT_SUBMASK) - { - case SF_FORMAT_PCM_S8 : return "int8" ; - case SF_FORMAT_PCM_U8 : return "uint8" ; - case SF_FORMAT_PCM_16 : return "int16" ; - case SF_FORMAT_PCM_24 : return "int24" ; - case SF_FORMAT_PCM_32 : return "int32" ; - case SF_FORMAT_FLOAT : return "float" ; - case SF_FORMAT_DOUBLE : return "double" ; - case SF_FORMAT_ULAW : return "ulaw" ; - case SF_FORMAT_ALAW : return "alaw" ; - case SF_FORMAT_IMA_ADPCM : return "ima_adpcm" ; - case SF_FORMAT_MS_ADPCM : return "ms_adpcm" ; - case SF_FORMAT_GSM610 : return "gsm610" ; - case SF_FORMAT_G721_32 : return "g721_32" ; - case SF_FORMAT_G723_24 : return "g723_24" ; - case SF_FORMAT_G723_40 : return "g723_40" ; - default : break ; - } ; - - return "unknown" ; -} /* string_of_minor_format */ - -static int -format_of_str (const std::string & fmt) -{ - std::vector split ; - - str_split (fmt, "-", split) ; - - if (split.size () != 2) - return 0 ; - - int major_fmt = major_format_of_hash (split.at (0)) ; - if (major_fmt == 0) - return 0 ; - - int minor_fmt = minor_format_of_hash (split.at (1)) ; - if (minor_fmt == 0) - return 0 ; - - return major_fmt | minor_fmt ; -} /* format_of_str */ - -static void -string_of_format (std::string & fmt, int format) -{ - char buffer [64] ; - - snprintf (buffer, sizeof (buffer), "%s-%s", string_of_major_format (format), string_of_minor_format (format)) ; - - fmt = buffer ; - - return ; -} /* string_of_format */ diff --git a/Engine/lib/libsndfile/Octave/sndfile_load.m b/Engine/lib/libsndfile/Octave/sndfile_load.m deleted file mode 100644 index c66198fa3..000000000 --- a/Engine/lib/libsndfile/Octave/sndfile_load.m +++ /dev/null @@ -1,52 +0,0 @@ -## Copyright (C) 2002-2011 Erik de Castro Lopo -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this file. If not, write to the Free Software Foundation, -## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} sndfile_load (@var{filename}) -## Load data from the file given by @var{filename}. -## @end deftypefn - -## Author: Erik de Castro Lopo -## Description: Load the sound data from the given file name - -function [data fs] = sndfile_load (filename) - -if (nargin != 1), - error ("Need an input filename") ; - endif - -samplerate = -1 ; -samplingrate = -1 ; -wavedata = -1 ; - - -eval (sprintf ('load -f %s', filename)) ; - -if (samplerate > 0), - fs = samplerate ; -elseif (samplingrate > 0), - fs = samplingrate ; -else - error ("Not able to find sample rate.") ; - endif - -if (max (size (wavedata)) > 1), - data = wavedata ; -else - error ("Not able to find waveform data.") ; - endif - -endfunction diff --git a/Engine/lib/libsndfile/Octave/sndfile_play.m b/Engine/lib/libsndfile/Octave/sndfile_play.m deleted file mode 100644 index e8a34a74c..000000000 --- a/Engine/lib/libsndfile/Octave/sndfile_play.m +++ /dev/null @@ -1,59 +0,0 @@ -## Copyright (C) 2002-2011 Erik de Castro Lopo -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this file. If not, write to the Free Software Foundation, -## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} sndfile_play (@var{data, fs}) -## Play @var{data} at sample rate @var{fs} using the sndfile-play -## program. -## @end deftypefn - -## Author: Erik de Castro Lopo -## Description: Play the given data as a sound file - -function sndfile_play (data, fs) - -if nargin != 2, - error ("Need two input arguments: data and fs.") ; - endif - -if (max (size (fs)) > 1), - error ("Second parameter fs must be a single value.") ; - endif - -[nr nc] = size (data) ; - -if (nr > nc), - data = data' ; - endif - -samplerate = fs ; -wavedata = data ; - -filename = tmpnam () ; - -cmd = sprintf ("save -mat-binary %s fs data", filename) ; - -eval (cmd) ; - -cmd = sprintf ("sndfile-play %s", filename) ; - -[output, status] = system (cmd) ; - -if (status), - disp (outout) ; - endif - -endfunction diff --git a/Engine/lib/libsndfile/Octave/sndfile_save.m b/Engine/lib/libsndfile/Octave/sndfile_save.m deleted file mode 100644 index 5b7e7c7d0..000000000 --- a/Engine/lib/libsndfile/Octave/sndfile_save.m +++ /dev/null @@ -1,53 +0,0 @@ -## Copyright (C) 2002-2011 Erik de Castro Lopo -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this file. If not, write to the Free Software Foundation, -## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -## -*- texinfo -*- -## @deftypefn {Function File} {} sndfile_save (@var{filename, data, fs}) -## Save the given @var{data} as audio data to the given at @var{fs}. Set -## the sample rate to @var{fs}. -## @end deftypefn - -## Author: Erik de Castro Lopo -## Description: Save data as a sound file - -function sndfile_save (filename, data, fs) - -if nargin != 3, - error ("Need three input arguments: filename, data and fs.") ; - endif - -if (! isstr (filename)), - error ("First parameter 'filename' is must be a string.") ; - endif - -if (max (size (fs)) > 1), - error ("Second parameter 'fs' must be a single value, not an array or matrix.") ; - endif - -[nr nc] = size (data) ; - -if (nr > nc), - data = data' ; - endif - -samplerate = fs ; -wavedata = data ; - -str = sprintf ("save -mat-binary %s samplerate wavedata", filename) ; - -eval (str) ; - -endfunction diff --git a/Engine/lib/libsndfile/README b/Engine/lib/libsndfile/README deleted file mode 100644 index cb580f141..000000000 --- a/Engine/lib/libsndfile/README +++ /dev/null @@ -1,74 +0,0 @@ -libsndfile is a library of C routines for reading and writing -files containing sampled audio data. - -The src/ directory contains the source code for library itself. - -The doc/ directory contains the libsndfile documentation. - -The examples/ directory contains examples of how to write code using -libsndfile. - -The tests/ directory contains programs which link against libsndfile -and test its functionality. - -The src/GSM610 directory contains code written by Jutta Degener and Carsten -Bormann. Their original code can be found at : - http://kbs.cs.tu-berlin.de/~jutta/toast.html - -The src/G72x directory contains code written and released by Sun Microsystems -under a suitably free license. - -The src/ALAC directory contains code written and released by Apple Inc and -released under the Apache license. - - -LINUX ------ -Wherever possible, you should use the packages supplied by your Linux -distribution. - -If you really do need to compile from source it should be as easy as: - - ./configure - make - make install - -Since libsndfile optionally links against libFLAC, libogg, libvorbis and -libopus, you will need to install appropriate versions of these libraries -before running configure as above. - -You can use CMake now to build under Linux, also under Windows and MacOS, see -README.md for details. CMake toolchain is usable, but still exterimental. - - -UNIX ----- -Compile as for Linux. - - -Win32/Win64 ------------ - -Official Windows binaries are compiled with Autotools and MinGW, but you can use -CMake to generate solution for Visual Studio. Details are described in -README.md. - -It is still recommended to use the libsndfile binaries available on the -libsndfile web site. - -MacOSX ------- -Building on MacOSX should be the same as building it on any other Unix. - - -CONTACTS --------- - -libsndfile was written by Erik de Castro Lopo (erikd AT mega-nerd DOT com). -The libsndfile home page is at : - - http://libsndfile.github.io/libsndfile/ - -Bugs and support questions can be raised at : - - https://github.com/libsndfile/libsndfile/issues diff --git a/Engine/lib/libsndfile/README.md b/Engine/lib/libsndfile/README.md deleted file mode 100644 index f14afcd6a..000000000 --- a/Engine/lib/libsndfile/README.md +++ /dev/null @@ -1,315 +0,0 @@ -# libsndfile - -![C/C++ CI](https://github.com/libsndfile/libsndfile/workflows/C/C++%20CI/badge.svg) - -libsndfile is a C library for reading and writing files containing sampled audio -data. - -## Authors - -The libsndfile project was originally developed and maintained by -Erik de Castro Lopo aka @erikd. The project was developed -on Github at . - -After the release of version 1.0.30, @erikd transferred the project to -[the libsndfile team](https://github.com/libsndfile), see [AUTHORS](AUTHORS) -for details. - -## Hacking - -The canonical source code repository for libsndfile is at -. - -You can grab the source code using: - - git clone https://github.com/libsndfile/libsndfile.git - -For building for Android see [BuildingForAndroid][BuildingForAndroid]. - -There are currently two build systems: the traditional GNU autotool based one and -modern CMake based build system. Use of the CMake build system is documented -below. - -Setting up a build environment for libsndfile on Debian or Ubuntu is as simple as: - - sudo apt install autoconf autogen automake build-essential libasound2-dev \ - libflac-dev libogg-dev libtool libvorbis-dev libopus-dev libmp3lame-dev \ - libmpg123-dev pkg-config python - -For other Linux distributions or any of the *BSDs, the setup should be similar -although the package install tools and package names may be slightly different. - -Similarly on Mac OS X, assuming [brew] is already installed: - - brew install autoconf autogen automake flac libogg libtool libvorbis opus mpg123 pkg-config - -Once the build environment has been set up, building and testing libsndfile is -as simple as: - - autoreconf -vif - ./configure --enable-werror - make - make check - -## The CMake build system - -Although Autotools is the primary and recommended build toolchain, CMake meta -build generator is also available. The build process with CMake takes -place in two stages. First, standard build files are created from configuration -scripts. Then the platform's native build tools are used for the actual -building. CMake can produce Microsoft Visual Studio project and solution files, -Unix Makefiles, Xcode projects and [many more](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html). - -Some IDE support CMake natively or with plugins, check you IDE documentation - for details. - -### Requirements - -1. C99-compliant compiler toolchain (tested with GCC, Clang and Visual - Studio 2015) -2. CMake 3.1.3 or newer - -There are some recommended packages to enable all features of libsndfile: - -1. Ogg, Vorbis and FLAC libraries and headers to enable these formats support -2. ALSA development package under Linux to build sndfile-play utility -3. Sndio development package under BSD to build sndfile-play utility - -### Building from command line - -CMake can handle out-of-place builds, enabling several builds from -the same source tree, and cross-compilation. The ability to build a directory -tree outside the source tree is a key feature, ensuring that if a build -directory is removed, the source files remain unaffected. - - mkdir CMakeBuild - cd CMakeBuild - -Then run `cmake` command with directory where CMakeLists.txt script is located -as argument (relative paths are supported): - - cmake .. - -This command will configure and write build script or solution to CMakeBuild -directory. CMake is smart enough to create Unix makefiles under Linux or Visual -Studio solution if you have Visual Studio installed, but you can configure -[generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html) -with `-G` command line parameter: - - cmake .. -G"Unix Makefiles" - -The build procedure depends on the selected generator. With "Unix Makefiles" you -can type: - - make & make install - -With "Visual Studio" and some other generators you can open solution or project -from `CMakeBuild` directory and build using IDE. - -Finally, you can use unified command: - - cmake --build . - -CMake also provides Qt-based cross platform GUI, cmake-gui. Using it is trivial -and does not require detailed explanations. - -### Configuring CMake - -You can pass additional options with `/D=` when you run -`cmake` command. Some useful system options: - -* `CMAKE_C_FLAGS` - additional C compiler flags -* `CMAKE_BUILD_TYPE` - configuration type, `DEBUG`, `RELEASE`, `RELWITHDEBINFO` - or `MINSIZEREL`. `DEBUG` is default -* `CMAKE_INSTALL_PREFIX` - build install location, the same as `--prefix` option - of `configure` script - - Useful libsndfile options: - -* `BUILD_SHARED_LIBS` - build shared library (DLL under Windows) when `ON`, - build static library othervise. This option is `OFF` by default. -* `BUILD_PROGRAMS` - build libsndfile's utilities from `programs/` directory, - `ON` by default. -* `BUILD_EXAMPLES` - build examples, `ON` by default. -* `BUILD_TESTING` - build tests. Then you can run tests with `ctest` command, - `ON` by default. Setting `BUILD_SHARED_LIBS` to `ON` disables this option. -* `ENABLE_EXTERNAL_LIBS` - enable Ogg, Vorbis, FLAC and Opus support. This - option is available and set to `ON` if all dependency libraries were found. -* `ENABLE_MPEG` - MP3 support. This option is available and set to `ON` if all - dependency libraries were found. -* `ENABLE_CPU_CLIP` - enable tricky cpu specific clipper. Enabled and set to - `ON` when CPU clips negative\positive. Don't touch it if you are not sure -* `ENABLE_BOW_DOCS` - enable black-on-white documentation theme, `OFF` by - default. -* `ENABLE_EXPERIMENTAL` - enable experimental code. Don't use it if you are - not sure. This option is `OFF` by default. -* `ENABLE_CPACK` - enable [CPack](https://cmake.org/cmake/help/latest/module/CPack.html) support. - This option is `ON` by default. -* `ENABLE_PACKAGE_CONFIG` - generate and install [package config file](https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#config-file-packages). -* `INSTALL_PKGCONFIG_MODULE` - generate and install [pkg-config module](https://people.freedesktop.org/~dbn/pkg-config-guide.html). -* `INSTALL_MANPAGES` - install [man pages](https://en.wikipedia.org/wiki/Man_page) for programs. This option is `ON` by default -* `ENABLE_STATIC_RUNTIME` - enable static runtime on Windows platform (MSVC and - MinGW), `OFF` by default. - - **Note**: For MSVC compiler this option is deprecated for CMake >= 3.15, see - policy [CMP0091](https://cmake.org/cmake/help/latest/policy/CMP0091.html). - Use `CMAKE_MSVC_RUNTIME_LIBRARY` option instead. - - **Note**: For MinGW toolchain this option is experimental. If you enabled it - and then disabled again, you need to clear CMake cache (delete CMakeCache.txt). -* `ENABLE_COMPATIBLE_LIBSNDFILE_NAME` - set DLL name to `libsndfile-1.dll` - (canonical name) on Windows platform, `sndfile.dll` otherwise, `OFF` by - default. Library name can be different depending on platform. The well known - DLL name on Windows platform is `libsndfile-1.dll`, because the only way to - build Windows library before was MinGW toolchain with Autotools. This name - is native for MinGW ecosystem, Autotools constructs it using MinGW platform - rules from `sndfile` target. But when you build with CMake using native - Windows compiler, the name is `sndfile.dll`. This is name for native Windows - platform, because Windows has no library naming rules. It is preffered - because you can search library using package manager or CMake's - `find_library` command on any platform using the same `sndfile` name. - -* `ENABLE_SSE2` - add compiler flag to enable SSE2 if required, `ON` by default. - - This option is for X86 and GCC compatible compilers configurations only. - - If you compile for other SIMD set, e.g. AVX2, you may want to set - `ENABLE_SSE2` to `OFF`. - - **Note**: This option is not active for X64 configuration, because SSE2 is - always available in this mode and all optimizations are enabled by default. - -Deprecated options: - -* `DISABLE_EXTERNAL_LIBS` - disable Ogg, Vorbis and FLAC support. Replaced by - `ENABLE_EXTERNAL_LIBS` -* `DISABLE_CPU_CLIP` - disable tricky cpu specific clipper. Replaced by - `ENABLE_CPU_CLIP` -* `BUILD_STATIC_LIBS` - build static library. Use `BUILD_SHARED_LIBS` instead - -### Linking from CMake projects - -First you need to add `FindOgg.cmake`, `FindVorbis.cmake`, `FindFLAC.cmake` and -`FindOpus.cmake` files to some directory inside your CMake project (usually -`cmake`) and add it to `CMAKE_MODULE_PATH`: - - project(SomeApplication) - - list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -Now you can search `libsndfile` library from your `CMakeLists.txt` - with this command: - - find_package(SndFile) - -`SndFile_FOUND` is set to `ON` when library is found. - -If `libsndfile` dependency is critical, you can add `REQUIRED` to - `find_package`: - - find_package(SndFile REQUIRED) - -With with option `find_package` will terminate configuration process - if `libsndfile` is not found. - -You can also add version check: - - find_package(SndFile 1.0.29) - -`find_package` will report error, if `libsndfile` version is < 1.0.29. - -You can combine `REQUIRED` and version if you need. - -To link `libsndfile` library use: - - target_link_libraries(my_application PRIVATE SndFile::sndfile) - -### Notes for Windows users - -#### System CRT library - -First advice about Visual Studio [system CRT libraries](https://docs.microsoft.com/en-us/cpp/c-runtime-library/c-run-time-library-reference?view=vs-2019), -it is system code linked as static or dynamic library to every C application. - -You can find related option in Visual Studio project properties: - - C/C++ -> Code Generation -> Runtime Library - -Dynamic version of system CRT library is default and it means that end user needs -to have the same runtime library installed on his system. Most likely it is so, -but if it is not, the user will see this error message using libsndfile DLL: - - "The program can't start because .dll is missing from your computer. Try reinstalling the program to fix this problem. " - -To avoid this, you may want to enable static CRT library linking. In this case -the size of your DLL will increase slightly the size will increase slightly, but -you can redistribute the libsndfile DLL without having to install the correct -version of the system CRT library. - -CMake project will use dynamic system CRT libraries by default, just like -Visual Studio does. But you can change it using `ENABLE_STATIC_RUNTIME` or -`CMAKE_MSVC_RUNTIME_LIBRARY` options. - -**Note**: You cannot use both options at the same time, it will lead to a -configuration error. - -If you have CMake >= 3.15 you should use -[`CMAKE_MSVC_RUNTIME_LIBRARY`](https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html) option. - -This will enable static linking: - - cmake .. -D"MultiThreaded$<$:Debug>" - -You can use libsndfile `ENABLE_STATIC_RUNTIME` option to to control CRT library -linking for CMake project: `OFF` or unset (default) for dynamic, and `ON` for -static linking: - - cmake .. -DENABLE_STATIC_RUNTIME=ON - -**Note**: This option is deprecated and may be removed in far future because we -have standard option `CMAKE_MSVC_RUNTIME_LIBRARY` now. - -#### Using Vcpkg package manager - -Second advice is about Ogg, Vorbis FLAC and Opus support. Searching external -libraries under Windows is a little bit tricky. The best way is to use -[Vcpkg](https://github.com/Microsoft/vcpkg). - -Install Vcpkg and then add this parameter to cmake command line: - - -DCMAKE_TOOLCHAIN_FILE=/scripts/buildsystems/vcpkg.cmake - -You also need to set `VCPKG_TARGET_TRIPLET` if you want to use static libraries: - - -DVCPKG_TARGET_TRIPLET=x64-windows-static - -Then you need to install static libogg, libvorbis, libflac, libopus, mpg123 and -mp3lame Vcpkg packages. - -After 1.1.0beta2 you don't need to install dependencies manually. Libsndfile -now supports [Vcpkg manifest mode](https://vcpkg.readthedocs.io/en/latest/users/manifests/) -and all dependencies are installed automatically. - -However, you can turn off the manifest mode and return to the classic mode using -the `VCPKG_MANIFEST_MODE` parameter from the command line: - - -DVCPKG_MANIFEST_MODE=OFF - -In classic mode, you need to install the required libraries manually: - - vcpkg install libvorbis:x64-windows-static libflac:x64-windows-static - opus:x64-windows-static mp3lame:x86-windows-static mpg123:x86-windows-static - libvorbis:x86-windows-static libflac:x86-windows-static - opus:x86-windows-static mp3lame:x86-windows-static mpg123:x86-windows-static - -**Note**: Use must use the same CRT library for external libraries and the -libsndfile library itself. For `*-static` triplets Vcpkg uses -[static CRT](https://vcpkg.readthedocs.io/en/latest/users/triplets/). - -## Submitting Patches - -See [CONTRIBUTING.md](CONTRIBUTING.md) for details. - -[brew]: http://brew.sh/ -[github]: http://libsndfile.github.io/libsndfile/ -[BuildingForAndroid]: https://github.com/libsndfile/libsndfile/blob/master/Building-for-Android.md diff --git a/Engine/lib/libsndfile/SECURITY.md b/Engine/lib/libsndfile/SECURITY.md deleted file mode 100644 index b75e7be2d..000000000 --- a/Engine/lib/libsndfile/SECURITY.md +++ /dev/null @@ -1,11 +0,0 @@ -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| 1.1.x | :white_check_mark: | - -## Reporting a Vulnerability - -Please send report privately to evpobr@gmail.com, and include how would you like to be credited. diff --git a/Engine/lib/libsndfile/Scripts/android-configure.sh b/Engine/lib/libsndfile/Scripts/android-configure.sh deleted file mode 100644 index accb386ca..000000000 --- a/Engine/lib/libsndfile/Scripts/android-configure.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -e - -# Copyright (C) 2013-2016 Erik de Castro Lopo -# -# 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. -# * Neither the author nor the names of any 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. - -# Android NDK version number; eg r10, r10b etc -ANDROID_NDK_VER=${ANDROID_NDK_VER:-r10} - -# Android NDK gcc version; eg 4.8, 4.9 etc. -ANDROID_GCC_VER=${ANDROID_GCC_VER:-4.9} - -# Android API version; eg 14 (Android 4.0), 21 (Android 5.0) etc. -ANDROID_API_VER=${ANDROID_API_VER:-14} - -ANDROID_TARGET=${ANDROID_TARGET:-arm-linux-androideabi} - -if test -z ${ANDROID_TOOLCHAIN_HOME} ; then - echo "Environment variable ANDROID_TOOLCHAIN_HOME not defined." - echo "This should point to the directory containing the Android NDK." - exit 1 - fi - -#------------------------------------------------------------------------------- -# No more user config beyond here. - -BUILD_MACHINE=$(uname -s | tr 'A-Z' 'a-z')-$(uname -m) - -function die_with { - echo $1 - exit 1 -} - -export CROSS_COMPILE=${ANDROID_TARGET} - -# Don't forget to adjust this to your NDK path -export ANDROID_NDK=${ANDROID_TOOLCHAIN_HOME}/android-ndk-${ANDROID_NDK_VER} -test -d ${ANDROID_NDK} || die_with "Error : ANDROID_NDK '$ANDROID_NDK' does not exist." - -export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/arm-linux-androideabi-${ANDROID_GCC_VER}/prebuilt/${BUILD_MACHINE} -test -d ${ANDROID_PREFIX} || die_with "Error : ANDROID_PREFIX '$ANDROID_PREFIX' does not exist." - -export SYSROOT=${ANDROID_NDK}/platforms/android-${ANDROID_API_VER}/arch-arm -test -d ${SYSROOT} || die_with "Error : SYSROOT '$SYSROOT' does not exist." - -export CROSS_PREFIX=${ANDROID_PREFIX}/bin/${CROSS_COMPILE} -test -f ${CROSS_PREFIX}-gcc || die_with "Error : CROSS_PREFIX compiler '${CROSS_PREFIX}-gcc' does not exist." - - -# Non-exhaustive lists of compiler + binutils -# Depending on what you compile, you might need more binutils than that -export CPP=${CROSS_PREFIX}-cpp -export AR=${CROSS_PREFIX}-ar -export AS=${CROSS_PREFIX}-as -export NM=${CROSS_PREFIX}-nm -export CC=${CROSS_PREFIX}-gcc -export CXX=${CROSS_PREFIX}-g++ -export LD=${CROSS_PREFIX}-ld -export RANLIB=${CROSS_PREFIX}-ranlib - -# Don't mix up .pc files from your host and build target -export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig - -# Set up the needed FLAGS. -export CFLAGS="${CFLAGS} -gstabs --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include" -export CXXFLAGS="${CXXFLAGS} -gstabs -fno-exceptions --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/include/ -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/libs/armeabi/include" - -export CPPFLAGS="${CFLAGS}" -export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib" - -# Create a symlink to the gdbclient. -test -h gdbclient || ln -s ${ANDROID_PREFIX}/bin/arm-linux-androideabi-gdb gdbclient - -./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} "$@" diff --git a/Engine/lib/libsndfile/Scripts/asan-configure.sh b/Engine/lib/libsndfile/Scripts/asan-configure.sh deleted file mode 100644 index 0ac43b946..000000000 --- a/Engine/lib/libsndfile/Scripts/asan-configure.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -eu - -CFLAGS="-fsanitize=address -g" CXXFLAGS=${CFLAGS} ./configure - diff --git a/Engine/lib/libsndfile/Scripts/build-test-tarball.mk.in b/Engine/lib/libsndfile/Scripts/build-test-tarball.mk.in deleted file mode 100644 index 5dac9d94b..000000000 --- a/Engine/lib/libsndfile/Scripts/build-test-tarball.mk.in +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/make -f - -# This is probably only going to work with GNU Make. -# This in a separate file instead of in Makefile.am because Automake complains -# about the GNU Make-isms. - -EXEEXT = @EXEEXT@ - -PACKAGE_VERSION = @PACKAGE_VERSION@ - -HOST_TRIPLET = @HOST_TRIPLET@ - -SRC_BINDIR = @SRC_BINDIR@ -TEST_BINDIR = @TEST_BINDIR@ - -LIBRARY := $(SRC_BINDIR)libsndfile.so.$(LIB_VERSION) - -LIB_VERSION := $(shell echo $(PACKAGE_VERSION) | sed -e 's/[a-z].*//') - -TESTNAME = libsndfile-testsuite-$(HOST_TRIPLET)-$(PACKAGE_VERSION) - -TARBALL = $(TESTNAME).tar.gz - -# Find the test programs by grepping the script for the programs it executes. -testprogs := $(shell grep '^\./' tests/test_wrapper.sh | sed -e "s|./||" -e "s/ .*//" | sort | uniq) -# Also add the programs not found by the above. -testprogs += tests/sfversion$(EXEEXT) tests/stdin_test$(EXEEXT) tests/stdout_test$(EXEEXT) \ - tests/cpp_test$(EXEEXT) tests/win32_test$(EXEEXT) - -libfiles := $(shell if test ! -z $(EXEEXT) ; then echo "src/libsndfile-1.def src/.libs/libsndfile-1.dll" ; elif test -f $(LIBRARY) ; then echo $(LIBRARY) ; fi ; fi) - -testbins := $(testprogs) $(libfiles) - -all : $(TARBALL) - -clean : - rm -rf $(TARBALL) $(TESTNAME)/ - -check : $(TESTNAME)/test_wrapper.sh - (cd ./$(TESTNAME)/ && ./test_wrapper.sh) - -$(TARBALL) : $(TESTNAME)/test_wrapper.sh - tar zcf $@ $(TESTNAME) - rm -rf $(TESTNAME) - @echo - @echo "Created : $(TARBALL)" - @echo - -$(TESTNAME)/test_wrapper.sh : tests/test_wrapper.sh tests/pedantic-header-test.sh - rm -rf $(TESTNAME) - mkdir -p $(TESTNAME)/tests/ - echo - echo $(testbins) - echo - cp $(testbins) $(TESTNAME)/tests/ - cp tests/test_wrapper.sh $(TESTNAME)/ - cp tests/pedantic-header-test.sh $(TESTNAME)/tests/ - chmod u+x $@ - -tests/test_wrapper.sh : tests/test_wrapper.sh.in - make $@ diff --git a/Engine/lib/libsndfile/Scripts/clang-sanitize.sh b/Engine/lib/libsndfile/Scripts/clang-sanitize.sh deleted file mode 100644 index 2898883c2..000000000 --- a/Engine/lib/libsndfile/Scripts/clang-sanitize.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# This is known to work with clang-3.4 from Debian testing/unstable. -# 2013/07/14 - -export CC=clang -export CXX=clang++ -export CFLAGS="-O3 -fsanitize=address,integer,undefined" -export CXXFLAGS="-O3 -fsanitize=address,integer,undefined" - -./configure --enable-gcc-werror - -make clean all check diff --git a/Engine/lib/libsndfile/Scripts/cmake-build.sh b/Engine/lib/libsndfile/Scripts/cmake-build.sh deleted file mode 100644 index 10260f3f0..000000000 --- a/Engine/lib/libsndfile/Scripts/cmake-build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -eu - -rm -rf CMakeCache.txt CMakeFiles/ _Build - -mkdir _Build -cd _Build -cmake .. -cmake --build . -ctest -V diff --git a/Engine/lib/libsndfile/Scripts/cstyle.py b/Engine/lib/libsndfile/Scripts/cstyle.py deleted file mode 100644 index 8e1df27e3..000000000 --- a/Engine/lib/libsndfile/Scripts/cstyle.py +++ /dev/null @@ -1,256 +0,0 @@ -#!/usr/bin/python -tt -# -# Copyright (C) 2005-2017 Erik de Castro Lopo -# -# Released under the 2 clause BSD license. - -""" -This program checks C code for compliance to coding standards used in -libsndfile and other projects I run. -""" - -import re -import sys - - -class Preprocessor: - """ - Preprocess lines of C code to make it easier for the CStyleChecker class to - test for correctness. Preprocessing works on a single line at a time but - maintains state between consecutive lines so it can preprocessess multi-line - comments. - Preprocessing involves: - - Strip C++ style comments from a line. - - Strip C comments from a series of lines. When a C comment starts and - ends on the same line it will be replaced with 'comment'. - - Replace arbitrary C strings with the zero length string. - - Replace '#define f(x)' with '#define f (c)' (The C #define requires that - there be no space between defined macro name and the open paren of the - argument list). - Used by the CStyleChecker class. - """ - def __init__ (self): - self.comment_nest = 0 - self.leading_space_re = re.compile ('^(\t+| )') - self.trailing_space_re = re.compile ('(\t+| )$') - self.define_hack_re = re.compile ("(#\s*define\s+[a-zA-Z0-9_]+)\(") - - def comment_nesting (self): - """ - Return the currect comment nesting. At the start and end of the file, - this value should be zero. Inside C comments it should be 1 or - (possibly) more. - """ - return self.comment_nest - - def __call__ (self, line): - """ - Strip the provided line of C and C++ comments. Stripping of multi-line - C comments works as expected. - """ - - line = self.define_hack_re.sub (r'\1 (', line) - - line = self.process_strings (line) - - # Strip C++ style comments. - if self.comment_nest == 0: - line = re.sub ("( |\t*)//.*", '', line) - - # Strip C style comments. - open_comment = line.find ('/*') - close_comment = line.find ('*/') - - if self.comment_nest > 0 and close_comment < 0: - # Inside a comment block that does not close on this line. - return "" - - if open_comment >= 0 and close_comment < 0: - # A comment begins on this line but doesn't close on this line. - self.comment_nest += 1 - return self.trailing_space_re.sub ('', line [:open_comment]) - - if open_comment < 0 and close_comment >= 0: - # Currently open comment ends on this line. - self.comment_nest -= 1 - return self.trailing_space_re.sub ('', line [close_comment + 2:]) - - if open_comment >= 0 and close_comment > 0 and self.comment_nest == 0: - # Comment begins and ends on this line. Replace it with 'comment' - # so we don't need to check whitespace before and after the comment - # we're removing. - newline = line [:open_comment] + "comment" + line [close_comment + 2:] - return self.__call__ (newline) - - return line - - def process_strings (self, line): - """ - Given a line of C code, return a string where all literal C strings have - been replaced with the empty string literal "". - """ - for k in range (0, len (line)): - if line [k] == '"': - start = k - for k in range (start + 1, len (line)): - if line [k] == '"' and line [k - 1] != '\\': - return line [:start + 1] + '"' + self.process_strings (line [k + 1:]) - return line - - -class CStyleChecker: - """ - A class for checking the whitespace and layout of a C code. - """ - def __init__ (self, debug): - self.debug = debug - self.filename = None - self.error_count = 0 - self.line_num = 1 - self.orig_line = '' - self.trailing_newline_re = re.compile ('[\r\n]+$') - self.indent_re = re.compile ("^\s*") - self.last_line_indent = "" - self.last_line_indent_curly = False - self.re_checks = \ - [ ( re.compile (" "), "multiple space instead of tab" ) - , ( re.compile ("\t "), "space after tab" ) - , ( re.compile ("[^ ];"), "missing space before semi-colon" ) - , ( re.compile ("{[^\s}]"), "missing space after open brace" ) - , ( re.compile ("[^{\s]}"), "missing space before close brace" ) - , ( re.compile ("[ \t]+$"), "contains trailing whitespace" ) - - , ( re.compile (",[^\s\n]"), "missing space after comma" ) - , ( re.compile (";[^\s]"), "missing space after semi-colon" ) - , ( re.compile ("=[^\s\"'=]"), "missing space after assignment" ) - - # Open and close parenthesis. - , ( re.compile ("[^\s\(\[\*&']\("), "missing space before open parenthesis" ) - , ( re.compile ("\)(-[^>]|[^,'\s\n\)\]-])"), "missing space after close parenthesis" ) - , ( re.compile ("\s(do|for|if|when)\s.*{$"), "trailing open parenthesis at end of line" ) - , ( re.compile ("\( [^;]"), "space after open parenthesis" ) - , ( re.compile ("[^;] \)"), "space before close parenthesis" ) - - # Open and close square brace. - , ( re.compile ("[^\s\(\]]\["), "missing space before open square brace" ) - , ( re.compile ("\][^,\)\]\[\s\.-]"), "missing space after close square brace" ) - , ( re.compile ("\[ "), "space after open square brace" ) - , ( re.compile (" \]"), "space before close square brace" ) - - # Space around operators. - , ( re.compile ("[^\s][\*/%+-][=][^\s]"), "missing space around opassign" ) - , ( re.compile ("[^\s][<>!=^/][=]{1,2}[^\s]"), "missing space around comparison" ) - - # Parens around single argument to return. - , ( re.compile ("\s+return\s+\([a-zA-Z0-9_]+\)\s+;"), "parens around return value" ) - - # Parens around single case argument. - , ( re.compile ("\s+case\s+\([a-zA-Z0-9_]+\)\s+:"), "parens around single case argument" ) - - # Open curly at end of line. - , ( re.compile ("\)\s*{\s*$"), "open curly brace at end of line" ) - - # Pre and post increment/decrment. - , ( re.compile ("[^\(\[][+-]{2}[a-zA-Z0-9_]"), "space after pre increment/decrement" ) - , ( re.compile ("[a-zA-Z0-9_][+-]{2}[^\)\,]]"), "space before post increment/decrement" ) - ] - - def get_error_count (self): - """ - Return the current error count for this CStyleChecker object. - """ - return self.error_count - - def check_files (self, files): - """ - Run the style checker on all the specified files. - """ - for filename in files: - self.check_file (filename) - - def check_file (self, filename): - """ - Run the style checker on the specified file. - """ - self.filename = filename - cfile = open (filename, "r") - - self.line_num = 1 - - preprocess = Preprocessor () - while 1: - line = cfile.readline () - if not line: - break - - line = self.trailing_newline_re.sub ('', line) - self.orig_line = line - - self.line_checks (preprocess (line)) - - self.line_num += 1 - - cfile.close () - self.filename = None - - # Check for errors finding comments. - if preprocess.comment_nesting () != 0: - print ("Weird, comments nested incorrectly.") - sys.exit (1) - - return - - def line_checks (self, line): - """ - Run the style checker on provided line of text, but within the context - of how the line fits within the file. - """ - - indent = len (self.indent_re.search (line).group ()) - if re.search ("^\s+}", line): - if not self.last_line_indent_curly and indent != self.last_line_indent: - None # self.error ("bad indent on close curly brace") - self.last_line_indent_curly = True - else: - self.last_line_indent_curly = False - - # Now all the regex checks. - for (check_re, msg) in self.re_checks: - if check_re.search (line): - self.error (msg) - - if re.search ("[a-zA-Z0-9][<>!=^/&\|]{1,2}[a-zA-Z0-9]", line): - if not re.search (".*#include.*[a-zA-Z0-9]/[a-zA-Z]", line): - self.error ("missing space around operator") - - self.last_line_indent = indent - return - - def error (self, msg): - """ - Print an error message and increment the error count. - """ - print ("%s (%d) : %s" % (self.filename, self.line_num, msg)) - if self.debug: - print ("'" + self.orig_line + "'") - self.error_count += 1 - -#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -if len (sys.argv) < 1: - print ("Usage : yada yada") - sys.exit (1) - -# Create a new CStyleChecker object -if sys.argv [1] == '-d' or sys.argv [1] == '--debug': - cstyle = CStyleChecker (True) - cstyle.check_files (sys.argv [2:]) -else: - cstyle = CStyleChecker (False) - cstyle.check_files (sys.argv [1:]) - - -if cstyle.get_error_count (): - sys.exit (1) - -sys.exit (0) diff --git a/Engine/lib/libsndfile/Scripts/git-pre-commit-hook b/Engine/lib/libsndfile/Scripts/git-pre-commit-hook deleted file mode 100644 index dc70e735f..000000000 --- a/Engine/lib/libsndfile/Scripts/git-pre-commit-hook +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh - -if git rev-parse --verify HEAD >/dev/null 2>&1 ; then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 - fi - -# Redirect output to stderr. -exec 1>&2 - -#------------------------------------------------------------------------------- -# Prevent files with non-ascii filenames from being committed. - -if test $(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 ; then - echo "Error: Attempt to add a non-ascii file name." - echo - echo "This can cause problems if you want to work" - echo "with people on other platforms." - echo - echo "To be portable it is advisable to rename the file ..." - echo - echo "Commit aborted." - exit 1 - fi - -#------------------------------------------------------------------------------- -# Check the formatting of all C files. - -# http://man.openbsd.org/sed#r -# http://man.openbsd.org/sed#E -# http://netbsd.gw.com/cgi-bin/man-cgi?sed++NetBSD-current -# https://github.com/freebsd/freebsd/blob/master/usr.bin/sed/main.c -# http://git.savannah.gnu.org/gitweb/?p=sed.git;a=blob;f=sed/sed.c -# GNU has -r and -E (undocumented); MacOS has -E but not -r; Sunos has neither. -files=$(git diff-index --name-status --cached HEAD | grep -v ^D | sed -E "s/^[A-Z]+[A-Z0-9]*[ \t]+/ /") - -cfiles="" -for f in $files ; do - if test `dirname $f` = "src/ALAC" ; then - echo "Skipping cstyle checking on $f" - elif test `echo $f | grep -c "\.[ch]$"` -gt 0 ; then - cfiles="$cfiles $f" - fi - done - -if test -n "$cfiles" ; then - Scripts/cstyle.py $cfiles - if test $? -ne 0 ; then - echo - echo "Commit aborted. Fix the above error before trying again." - exit 1 - fi - fi - -#------------------------------------------------------------------------------- -# Check the copyright notice of all files to be commited. - -user=`git config --global user.email` -year=`date +"%Y"` - -missing_copyright_year="" -if test $user = "erikd@mega-nerd.com" ; then - for f in $files ; do - if test `head -5 $f | grep -i copyright | grep -c -i $user` -gt 0 ; then - user_copyright=`grep -i copyright $f | grep $user | grep -c $year` - if test $user_copyright -lt 1 ; then - missing_copyright_year="$missing_copyright_year $f" - fi - fi - done - fi - -if test -n "$missing_copyright_year" ; then - echo "Missing current year in the copyright notice of the following files:" - for f in $missing_copyright_year ; do - echo " $f" - done - echo "Commit aborted." - exit 1 - fi - -exit 0 diff --git a/Engine/lib/libsndfile/Scripts/linux-to-win-cross-configure.sh b/Engine/lib/libsndfile/Scripts/linux-to-win-cross-configure.sh deleted file mode 100644 index c1fdc072b..000000000 --- a/Engine/lib/libsndfile/Scripts/linux-to-win-cross-configure.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -case "$1" in - w32) - compiler_name=i686-w64-mingw32 - ;; - w64) - compiler_name=x86_64-w64-mingw32 - ;; - *) - echo "$0 (w32|w64) " - exit 0 - ;; - esac - -shift - -build_cpu=$(dpkg-architecture -qDEB_BUILD_GNU_CPU) -build_host=$build_cpu-linux - -./configure --host=$compiler_name --target=$compiler_name --build=$build_host \ - --program-prefix='' --disable-sqlite --disable-static $@ diff --git a/Engine/lib/libsndfile/Scripts/static-deps-build.mk b/Engine/lib/libsndfile/Scripts/static-deps-build.mk deleted file mode 100644 index bbf2f0d7d..000000000 --- a/Engine/lib/libsndfile/Scripts/static-deps-build.mk +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/make -f - -# If this is set to true (via the environment) then CRC checking will be -# disabled in libogg giving fuzzers a better chance at finding something. -disable_ogg_crc ?= false - -# Build libsndfile as a dynamic/shared library, but statically link to -# libFLAC, libogg, libopus and libvorbis - -ogg_version = libogg-1.3.4 -ogg_sha256sum = c163bc12bc300c401b6aa35907ac682671ea376f13ae0969a220f7ddf71893fe - -vorbis_version = libvorbis-1.3.7 -vorbis_sha256sum = b33cc4934322bcbf6efcbacf49e3ca01aadbea4114ec9589d1b1e9d20f72954b - -flac_version = flac-1.3.3 -flac_sha256sum = 213e82bd716c9de6db2f98bcadbc4c24c7e2efe8c75939a1a84e28539c4e1748 - -opus_version = opus-1.3.1 -opus_sha256sum = 65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d - -#------------------------------------------------------------------------------- -# Code follows. - -ogg_tarball = $(ogg_version).tar.xz -vorbis_tarball = $(vorbis_version).tar.xz -flac_tarball = $(flac_version).tar.xz -opus_tarball = $(opus_version).tar.gz - -download_url = http://downloads.xiph.org/releases/ -tarball_dir = Build/Tarballs -stamp_dir = Build/Stamp - -build_dir = $(shell pwd)/Build -config_options = --prefix=$(build_dir) --disable-shared --enable-option-checking - -pwd = $(shell pwd) - -help : - @echo - @echo "This script will build libsndfile as a dynamic/shared library but statically linked" - @echo "to libFLAC, libogg and libvorbis. It should work on Linux and Mac OS X. It might" - @echo "work on Windows with a correctly set up MinGW." - @echo - @echo "It requires all the normal build tools require to build libsndfile plus wget." - @echo - -config : Build/Stamp/configure - -build : Build/Stamp/build - -clean : - rm -rf Build/flac-* Build/libogg-* Build/libvorbis-* Build/opus-* - rm -rf Build/bin Build/include Build/lib Build/share - rm -f Build/Stamp/install Build/Stamp/extract Build/Stamp/sha256sum Build/Stamp/build-ogg - -Build/Stamp/init : - mkdir -p $(stamp_dir) $(tarball_dir) - touch $@ - -Build/Tarballs/$(flac_tarball) : Build/Stamp/init - (cd $(tarball_dir) && wget $(download_url)flac/$(flac_tarball) -O $(flac_tarball)) - touch $@ - -Build/Tarballs/$(ogg_tarball) : Build/Stamp/init - (cd $(tarball_dir) && wget $(download_url)ogg/$(ogg_tarball) -O $(ogg_tarball)) - touch $@ - -Build/Tarballs/$(vorbis_tarball) : Build/Stamp/init - (cd $(tarball_dir) && wget $(download_url)vorbis/$(vorbis_tarball) -O $(vorbis_tarball)) - touch $@ - -Build/Tarballs/$(opus_tarball) : Build/Stamp/init - (cd $(tarball_dir) && wget https://archive.mozilla.org/pub/opus/$(opus_tarball) -O $(opus_tarball)) - touch $@ - -Build/Stamp/tarballs : Build/Tarballs/$(flac_tarball) Build/Tarballs/$(ogg_tarball) Build/Tarballs/$(vorbis_tarball) Build/Tarballs/$(opus_tarball) - touch $@ - -Build/Stamp/sha256sum : Build/Stamp/tarballs - test `sha256sum $(tarball_dir)/$(ogg_tarball) | sed "s/ .*//"` = $(ogg_sha256sum) - test `sha256sum $(tarball_dir)/$(vorbis_tarball) | sed "s/ .*//"` = $(vorbis_sha256sum) - test `sha256sum $(tarball_dir)/$(flac_tarball) | sed "s/ .*//"` = $(flac_sha256sum) - test `sha256sum $(tarball_dir)/$(opus_tarball) | sed "s/ .*//"` = $(opus_sha256sum) - touch $@ - -Build/Stamp/extract : Build/Stamp/sha256sum - # (cd Build && tar xf Tarballs/$(ogg_tarball)) - (cd Build && tar xf Tarballs/$(flac_tarball)) - (cd Build && tar xf Tarballs/$(vorbis_tarball)) - (cd Build && tar xf Tarballs/$(opus_tarball)) - touch $@ - -Build/Stamp/build-ogg : Build/Stamp/sha256sum -ifeq ($(disable_ogg_crc), true) - echo "Ogg/CRC enabled" - (cd Build && git clone https://github.com/xiph/ogg $(ogg_version)) - (cd Build/$(ogg_version) && autoreconf -vif && CFLAGS=-fPIC ./configure $(config_options) --disable-crc && make all install) -else - echo "Ogg/CRC disabled" - (cd Build && tar xf Tarballs/$(ogg_tarball)) - (cd Build/$(ogg_version) && CFLAGS=-fPIC ./configure $(config_options) && make all install) -endif - touch $@ - -Build/Stamp/install-libs : Build/Stamp/extract Build/Stamp/build-ogg - (cd Build/$(vorbis_version) && CFLAGS=-fPIC ./configure $(config_options) && make all install) - (cd Build/$(flac_version) && CFLAGS=-fPIC ./configure $(config_options) && make all install) - (cd Build/$(opus_version) && CFLAGS=-fPIC ./configure $(config_options) && make all install) - touch $@ - -configure : configure.ac - autoreconf -vif - -Build/Stamp/configure : Build/Stamp/install-libs configure - PKG_CONFIG_LIBDIR=Build/lib/pkgconfig ./configure - sed -i 's#^EXTERNAL_XIPH_CFLAGS.*#EXTERNAL_XIPH_CFLAGS = -I$(pwd)/Build/include#' Makefile - sed -i 's#^EXTERNAL_XIPH_LIBS.*#EXTERNAL_XIPH_LIBS = -static $(pwd)/Build/lib/libFLAC.la $(pwd)/Build/lib/libvorbis.la $(pwd)/Build/lib/libvorbisenc.la $(pwd)/Build/lib/libopus.la $(pwd)/Build/lib/libogg.la -dynamic #' Makefile - make clean - touch $@ - -Build/Stamp/build : Build/Stamp/configure - make all check - touch $@ - diff --git a/Engine/lib/libsndfile/Win32/README-precompiled-dll.txt b/Engine/lib/libsndfile/Win32/README-precompiled-dll.txt deleted file mode 100644 index bde812421..000000000 --- a/Engine/lib/libsndfile/Win32/README-precompiled-dll.txt +++ /dev/null @@ -1,40 +0,0 @@ -Notes on Using the Pre-compiled libsndfile DLL. -=============================================== - -In order to use this pre-compiled DLL with Visual Studio, you will need to -generate a .LIB file from the DLL. - -This can be achieved as follows: - - 1) In a CMD window, change to the directory containing this file and - run the command: - - lib /machine:i386 /def:libsndfile-1.def - -You now have two files: - - libsndfile-1.dll - libsndfile-1.lib - -to be used with VisualStudio. - -If the lib command fails with a command saying "'lib' is not recognized as -an internal or external command, operable program or batch file", you need -to find the location of "lib.exe" and add that directory to your PATH -environment variable. Another alternative is to use the "Visual Studio 2005 -Command Prompt" Start menu item: - - Start -> - All Programs -> - Visual Studio 2005 -> - Visual Studio Tools -> - Visual Studio 2005 Command Prompt - -If for some reason these instructions don't work for you or you are still -not able to use the libsndfile DLL with you project, please do not contact -the main author of libsndfile. Instead, join the libsndfile-users mailing -list : - - http://www.mega-nerd.com/libsndfile/lists.html - -and ask a question there. diff --git a/Engine/lib/libsndfile/Win32/testprog.c b/Engine/lib/libsndfile/Win32/testprog.c deleted file mode 100644 index d26d844ad..000000000 --- a/Engine/lib/libsndfile/Win32/testprog.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Simple test program to make sure that Win32 linking to libsndfile is -** working. -*/ - -#include - -#include "sndfile.h" - -int -main (void) -{ static char strbuffer [256] ; - sf_command (NULL, SFC_GET_LIB_VERSION, strbuffer, sizeof (strbuffer)) ; - puts (strbuffer) ; - return 0 ; -} - diff --git a/Engine/lib/libsndfile/cmake/CMakeAutoGen.cmake b/Engine/lib/libsndfile/cmake/CMakeAutoGen.cmake deleted file mode 100644 index f82dc137c..000000000 --- a/Engine/lib/libsndfile/cmake/CMakeAutoGen.cmake +++ /dev/null @@ -1,46 +0,0 @@ -# CMake implementation of AutoGen -# Copyright (C) 2017 Anonymous Maarten - -set(AUTOGEN_SCRIPT "${CMAKE_MODULE_PATH}/CMakeAutoGenScript.cmake") - -function(lsf_autogen DIR_REL NAME_WE) - set(EXTS ${ARGN}) - set(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/${DIR_REL}/${NAME_WE}.def") - set(OUTPUTS) - foreach(EXT ${EXTS}) - list(APPEND OUTPUTS "${NAME_WE}.${EXT}") - endforeach() - add_autogen_target("${INPUT}" "${CMAKE_CURRENT_BINARY_DIR}/${DIR_REL}" ${OUTPUTS}) -endfunction() - -function(add_autogen_target INPUT OUTPUTDIR) - set(OUTPUTFILES "${ARGN}") - - if (OUTPUTDIR) - set(PREFIX "${OUTPUTDIR}/") - else() - set(PREFIX "") - endif() - - set(ARTIFACTS) - foreach(OUTPUTFILE ${OUTPUTFILES}) - list(APPEND ARTIFACTS "${PREFIX}${OUTPUTFILE}") - endforeach() - - set(EXTRA_ARGS) - if (AUTOGEN_DEBUG) - list(APPEND EXTRA_ARGS "-DDEBUG=1") - endif() - if (OUTPUTDIR) - list(APPEND EXTRA_ARGS "-DOUTPUTDIR=${OUTPUTDIR}") - endif() - - add_custom_command( - OUTPUT ${ARTIFACTS} - COMMAND ${CMAKE_COMMAND} "-DDEFINITION=${INPUT}" ${EXTRA_ARGS} -P "${AUTOGEN_SCRIPT}" - MAIN_DEPENDENCY "${INPUT}" - DEPENDS "${AUTOGEN_SCRIPT}" - COMMENT "CMakeAutoGen: generating ${OUTPUTFILES}" - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - ) -endfunction() diff --git a/Engine/lib/libsndfile/cmake/CMakeAutoGenScript.cmake b/Engine/lib/libsndfile/cmake/CMakeAutoGenScript.cmake deleted file mode 100644 index ade53e198..000000000 --- a/Engine/lib/libsndfile/cmake/CMakeAutoGenScript.cmake +++ /dev/null @@ -1,442 +0,0 @@ -# CMake implementation of AutoGen -# Copyright (C) 2017 Anonymous Maarten - -set(WS " \t\r\n") - -function(cutoff_first_occurrence TEXT OCCURRENCE RESULT) - string(FIND "${TEXT}" "${OCCURRENCE}" OCCURRENCE_INDEX) - if (OCCURRENCE_INDEX EQUAL -1) - set(${TEXT} "" PARENT_SCOPE) - return() - endif() - - string(LENGTH "${OCCURRENCE}" OCCURRENCE_LENGTH) - math(EXPR CUTOFF_INDEX "${OCCURRENCE_INDEX}+${OCCURRENCE_LENGTH}") - string(SUBSTRING "${TEXT}" ${CUTOFF_INDEX} -1 TEXT_REMAINDER) - set(${RESULT} "${TEXT_REMAINDER}" PARENT_SCOPE) - - endfunction() - -function(read_definition DEFINITION_FILENAME TEMPLATE_FILENAME DATA) - file(READ "${DEFINITION_FILENAME}" DEFINITION_CONTENTS) - - string(REGEX MATCH "autogen definitions ([a-zA-Z\\._-]+);[${WS}]*" TEMPLATE_MATCH "${DEFINITION_CONTENTS}") - if (NOT TEMPLATE_MATCH) - message(FATAL_ERROR "${DEFINITION_FILENAME} doest not contain an AutoGen definition.") - endif() - - get_filename_component(DEFINITION_DIR "${DEFINITION_FILENAME}" PATH) - set(${TEMPLATE_FILENAME} "${DEFINITION_DIR}/${CMAKE_MATCH_1}" PARENT_SCOPE) - if (DEBUG) - message("found: TEMPLATE_FILENAME=${CMAKE_MATCH_1}") - endif() - - cutoff_first_occurrence("${DEFINITION_CONTENTS}" "${TEMPLATE_MATCH}" DEFINITION_CONTENTS) - - set(DEFINITION "") - - while (1) - string(REGEX MATCH "([a-zA-Z_][a-zA-Z0-9_]*)[${WS}]*=[${WS}]*{[${WS}]*" GROUPSTART_MATCH "${DEFINITION_CONTENTS}") - if (NOT GROUPSTART_MATCH) - break() - endif() - set(GROUPNAME "${CMAKE_MATCH_1}") - cutoff_first_occurrence("${DEFINITION_CONTENTS}" "${GROUPSTART_MATCH}" DEFINITION_CONTENTS) - if (DEBUG) - message("found: GROUPNAME=${GROUPNAME}") - endif() - set(NBKEYS 0) - set(GROUP_KEY_VALUES "") - while (1) - string(REGEX MATCH "^([a-zA-Z_][a-zA-Z0-9_]*)[${WS}]*=[${WS}]*(([\"']([${WS}a-zA-Z0-9_%\\\"<>\(\)\\.*+/?:,\\-]+)[\"'])|([a-zA-Z0-9_%\\]+))[${WS}]*;[${WS}]*" KEY_VALUE_MATCH "${DEFINITION_CONTENTS}") - if (NOT KEY_VALUE_MATCH) - break() - endif() - set(KEY "${CMAKE_MATCH_1}") - if ("${CMAKE_MATCH_4}" STREQUAL "") - set(VALUE "${CMAKE_MATCH_5}") - else() - string(REPLACE "\\\"" "\"" VALUE "${CMAKE_MATCH_4}") - #set(VALUE "${CMAKE_MATCH_4}") - endif() - - if (DEBUG) - message("found: KEY=${KEY}, VALUE=${VALUE}") - endif() - math(EXPR NBKEYS "${NBKEYS}+1") - list(APPEND GROUP_KEY_VALUES "${KEY}" "${VALUE}") - cutoff_first_occurrence("${DEFINITION_CONTENTS}" "${KEY_VALUE_MATCH}" DEFINITION_CONTENTS) - endwhile() - string(REGEX MATCH "^[${WS}]*}[${WS}]*;[${WS}]*" GROUPEND_MATCH "${DEFINITION_CONTENTS}") - if (NOT GROUPEND_MATCH) - message(FATAL_ERROR "Group ${GROUPNAME} did not finish.") - endif() - cutoff_first_occurrence("${DEFINITION_CONTENTS}" "${GROUPEND_MATCH}" DEFINITION_CONTENTS) - list(APPEND DEFINITION "${GROUPNAME}" ${NBKEYS} ${GROUP_KEY_VALUES}) - endwhile() - set(${DATA} "${DEFINITION}" PARENT_SCOPE) -endfunction() - -function(match_autogen_group TEXT START POS0 POS1 MATCH FOUND) - string(SUBSTRING "${TEXT}" "${START}" -1 TEXT) - string(REGEX MATCH "\\[\\+[${WS}]*([ a-zA-Z0-9=_$%\\(\\)\"\\+\\-]+)[${WS}]*\\+\\]" MATCH_GROUP "${TEXT}") - if ("${MATCH_GROUP}" STREQUAL "") - set(${FOUND} 0 PARENT_SCOPE) - return() - endif() - string(FIND "${TEXT}" "${MATCH_GROUP}" START_TEXT) - math(EXPR POS0_var "${START}+${START_TEXT}") - string(LENGTH "${MATCH_GROUP}" MATCH_LENGTH) - math(EXPR POS1_var "${POS0_var}+${MATCH_LENGTH}") - set(${POS0} "${POS0_var}" PARENT_SCOPE) - set(${POS1} "${POS1_var}" PARENT_SCOPE) - set(${FOUND} 1 PARENT_SCOPE) - string(STRIP "${CMAKE_MATCH_1}" CONTENT) - set("${MATCH}" "${CONTENT}" PARENT_SCOPE) -endfunction() - -function(append_output SUFFICES_FILENAMES TEXT POS0 POS1 FILTER) - math(EXPR POS_LENGTH "${POS1}-${POS0}") - string(LENGTH "${TEXT}" TEXT_LENGTH) - string(SUBSTRING "${TEXT}" "${POS0}" "${POS_LENGTH}" TEXT_APPEND) - if (DEBUG) - message("appending ${POS0}:${POS1}, length=${POS_LENGTH}") - endif() - append_output_text("${SUFFICES_FILENAMES}" "${TEXT_APPEND}" "${FILTER}") -endfunction() - -function(append_output_text SUFFICES_FILENAMES TEXT_APPEND FILTER) - string(LENGTH "${TEXT_APPEND}" TEXT_LENGTH) - list(LENGTH SUFFICES_FILENAMES NB) - math(EXPR NB_END "${NB}-1") - foreach(INDEX RANGE 0 ${NB_END} 3) - math(EXPR INDEX_1 "${INDEX}+1") - math(EXPR INDEX_2 "${INDEX}+2") - list(GET SUFFICES_FILENAMES ${INDEX} SUFFIX) - list(GET SUFFICES_FILENAMES ${INDEX_1} FILENAME) - list(GET SUFFICES_FILENAMES ${INDEX_2} TEMPFILENAME) - set(WRITE_OK 1) - if (FILTER) - if (NOT "${SUFFIX}" STREQUAL "${FILTER}") - set(WRITE_OK 0) - endif() - endif() - if (WRITE_OK) - if (DEBUG) - message("Write: ${TEXT_LENGTH} characters to ${FILENAME}") - endif() - file(APPEND "${TEMPFILENAME}" "${TEXT_APPEND}") - endif() - endforeach() -endfunction() - -function(output_finish SUFFICES_FILENAMES) - list(LENGTH SUFFICES_FILENAMES NB) - math(EXPR NB_END "${NB}-1") - foreach(INDEX RANGE 0 ${NB_END} 3) - math(EXPR INDEX_1 "${INDEX}+1") - math(EXPR INDEX_2 "${INDEX}+2") - list(GET SUFFICES_FILENAMES ${INDEX_1} FILENAME) - list(GET SUFFICES_FILENAMES ${INDEX_2} TEMPFILENAME) - file(RENAME "${TEMPFILENAME}" "${FILENAME}") - endforeach() -endfunction() - -function(stack_push STACK_ARG) - set(STACK_LIST "${${STACK_ARG}}") - string(REPLACE ";" " " NEWITEM "${ARGN}") - if (DEBUG) - list(LENGTH STACK_LIST STACK_LENGTH) - message("Pushing \"${NEWITEM}\" onto stack (length=${STACK_LENGTH})") - endif() - list(APPEND STACK_LIST "${NEWITEM}") - set(${STACK_ARG} "${STACK_LIST}" PARENT_SCOPE) -endfunction() - -function(stack_pop STACK_ARG ITEM) - set(STACK_LIST "${${STACK_ARG}}") - list(LENGTH STACK_LIST STACK_LENGTH) - if (STACK_LENGTH EQUAL 0) - message(FATAL_ERROR "ENDFOR: stack is empty") - endif() - math(EXPR LAST_ITEM_INDEX "${STACK_LENGTH}-1") - list(GET STACK_LIST "${LAST_ITEM_INDEX}" LAST_ITEM) - list(REMOVE_AT STACK_LIST "${LAST_ITEM_INDEX}") - string(REPLACE " " ";" LAST_ITEM_LIST "${LAST_ITEM}") - if (DEBUG) - message("Popping \"${LAST_ITEM}\" from stack (length=${STACK_LENGTH})") - endif() - set(${ITEM} "${LAST_ITEM_LIST}" PARENT_SCOPE) - set(${STACK_ARG} "${STACK_LIST}" PARENT_SCOPE) -endfunction() - -function(stack_top STACK_ARG ITEM) - set(STACK_LIST "${${STACK_ARG}}") - list(LENGTH STACK_LIST STACK_LENGTH) - if (STACK_LENGTH EQUAL 0) - message(FATAL_ERROR "ENDFOR: stack is empty") - endif() - math(EXPR LAST_ITEM_INDEX "${STACK_LENGTH}-1") - list(GET STACK_LIST "${LAST_ITEM_INDEX}" LAST_ITEM) - string(REPLACE " " ";" LAST_ITEM_LIST "${LAST_ITEM}") - if (DEBUG) - message("Top of stack: \"${LAST_ITEM}\" from stack (length=${STACK_LENGTH})") - endif() - set(${ITEM} "${LAST_ITEM_LIST}" PARENT_SCOPE) -endfunction() - -function(stack_find_key STACK_LIST TEMPLATE_PARAMETERS KEY VALUE) - list(REVERSE STACK_LIST) - foreach(STACK_ITEM ${STACK_LIST}) - string(REPLACE " " ";" STACK_ITEM_LIST "${STACK_ITEM}") - list(GET STACK_ITEM_LIST 3 TP_INDEX) - math(EXPR TP_SIZE_INDEX "${TP_INDEX}+1") - list(GET TEMPLATE_PARAMETERS ${TP_SIZE_INDEX} TP_SIZE) - math(EXPR TP_KV_INDEX_START "${TP_INDEX}+2") - math(EXPR TP_KV_INDEX_END "${TP_KV_INDEX_START}+2*${TP_SIZE}-1") - foreach(TP_KV_INDEX RANGE ${TP_KV_INDEX_START} ${TP_KV_INDEX_END} 2) - list(GET TEMPLATE_PARAMETERS ${TP_KV_INDEX} TP_KEY) - if("${TP_KEY}" STREQUAL "${KEY}") - math(EXPR TP_VALUE_INDEX "${TP_KV_INDEX}+1") - list(GET TEMPLATE_PARAMETERS ${TP_VALUE_INDEX} TP_VALUE) - set(${VALUE} "${TP_VALUE}" PARENT_SCOPE) - return() - endif() - endforeach() - endforeach() - message(FATAL_ERROR "Unknown KEY=${KEY}") -endfunction() - -function(template_parameters_find_next_groupname_index TEMPLATE_PARAMETERS GROUPNAME INDEX_LAST INDEX_NEXT) - if (${INDEX_LAST} LESS 0) - set(INDEX 0) - else () - math(EXPR INDEX_1 "1+(${INDEX_LAST})") - list(GET TEMPLATE_PARAMETERS ${INDEX_1} GROUPNAME_INDEX_SIZE) - math(EXPR INDEX "${INDEX_LAST}+1+2*${GROUPNAME_INDEX_SIZE}+1") - endif() - list(LENGTH TEMPLATE_PARAMETERS PARAMETERS_LENGTH) - while (${INDEX} LESS ${PARAMETERS_LENGTH}) - list(GET TEMPLATE_PARAMETERS ${INDEX} GROUPNAME_AT_INDEX) - if ("${GROUPNAME}" STREQUAL "${GROUPNAME_AT_INDEX}") - set("${INDEX_NEXT}" ${INDEX} PARENT_SCOPE) - return() - endif() - math(EXPR INDEX_1 "${INDEX}+1") - list(GET TEMPLATE_PARAMETERS ${INDEX_1} GROUPNAME_INDEX_SIZE) - math(EXPR INDEX "${INDEX}+1+2*${GROUPNAME_INDEX_SIZE}+1") - endwhile() - set("${INDEX_NEXT}" -1 PARENT_SCOPE) -endfunction() - -function(calculate_line_number TEXT POSITION LINENUMBER_ARG) - #math(EXPR INDEX_MAX "${POSITION}-1") - string(SUBSTRING "${TEXT}" 0 ${POSITION} SUBTEXT) - string(REGEX MATCHALL "\n" MATCH_NEWLINES "${SUBTEXT}") - list(LENGTH MATCH_NEWLINES NBLINES) - math(EXPR NBLINES "${NBLINES}+1") - set(${LINENUMBER_ARG} ${NBLINES} PARENT_SCOPE) -endfunction() - -function(parse_template TEMPLATE_FILENAME OUTPUT_DIR TEMPLATE_PARAMETERS) - file(READ ${TEMPLATE_FILENAME} TEMPLATE_CONTENTS) - set(POSITION 0) - match_autogen_group("${TEMPLATE_CONTENTS}" "${POSITION}" POS0 POS1 AUTOGEN FOUND) - if (NOT FOUND) - message(FATAL_ERROR "Header of template not found") - endif() - string(REGEX MATCH "AutoGen5 template ([ a-zA-Z0-9]*)" SUFFICES_MATCH "${AUTOGEN}") - if (NOT SUFFICES_MATCH) - message(FATAL_ERROR "No output suffices found") - endif() - string(STRIP "${CMAKE_MATCH_1}" SUFFICES) - string(REPLACE " " ";" SUFFICES "${SUFFICES}") - set(SUFFICES_FILENAMES "") - get_filename_component(TEMPLATE_NAME_WE "${TEMPLATE_FILENAME}" NAME_WE) - foreach(SUFFIX ${SUFFICES}) - if ("${OUTPUT_DIR}" STREQUAL "") - set(DIR_PREFIX "") - else() - set(DIR_PREFIX "${OUTPUT_DIR}/") - endif() - string(RANDOM LENGTH 64 RANDOMSTRING) - set(FILENAME "${DIR_PREFIX}${TEMPLATE_NAME_WE}.${SUFFIX}") - set(TEMPFILENAME "${DIR_PREFIX}${TEMPLATE_NAME_WE}${RANDOMSTRING}.${SUFFIX}") - list(APPEND SUFFICES_FILENAMES "${SUFFIX}" "${FILENAME}" "${TEMPFILENAME}") - file(WRITE "${FILENAME}" "") - endforeach() - if (DEBUG) - message("Output files: ${SUFFICES_FILENAMES}") - endif() - set(WRITE_FILTER "") - append_output("${SUFFICES_FILENAMES}" "${TEMPLATE_CONTENTS}" 0 "${POS0}" "${WRITE_FILTER}") - math(EXPR POS1 "${POS1}+1") - set(POSITION "${POS1}") - if (DEBUG) - message("Output: ${SUFFICES_FILENAMES}") - endif() - - set(STACK "") - while (1) - match_autogen_group("${TEMPLATE_CONTENTS}" "${POSITION}" POS0 POS1 GROUP_MATCH FOUND) - if (NOT FOUND) - if (DEBUG) - message("No group found. Dumping rest of file.") - endif() - if (NOT "${STACK}" STREQUAL "") - message(FATAL_ERROR "Stack not empty at end of file") - endif() - string(LENGTH "${TEMPLATE_CONTENTS}" TEXT_LENGTH) - append_output("${SUFFICES_FILENAMES}" "${TEMPLATE_CONTENTS}" ${POSITION} ${TEXT_LENGTH} "${WRITE_FILTER}") - break() - endif() - append_output("${SUFFICES_FILENAMES}" "${TEMPLATE_CONTENTS}" ${POSITION} ${POS0} "${WRITE_FILTER}") - set(POSITION "${POS1}") - - if (GROUP_MATCH MATCHES "^FOR") - string(REPLACE " " ";" GROUP_MATCH_LIST "${GROUP_MATCH}") - list(GET GROUP_MATCH_LIST 1 FOR_KEY) - template_parameters_find_next_groupname_index("${TEMPLATE_PARAMETERS}" "${FOR_KEY}" -1 FOR_INDEX) - if (DEBUG) - message("FOR_KEY: ${FOR_KEY}") - message("FOR_INDEX: ${FOR_INDEX}") - endif() - if (${FOR_KEY} LESS 0) - message(FATAL_ERROR "FOR has key with empty list. Not implemented yet..") - endif() - stack_push(STACK FOR ${POSITION} ${FOR_KEY} ${FOR_INDEX}) - elseif (GROUP_MATCH MATCHES "^ENDFOR") - string(REPLACE " " ";" GROUP_MATCH_LIST "${GROUP_MATCH}") - list(GET GROUP_MATCH_LIST 1 ENDFOR_KEY) - stack_pop(STACK FOR_ITEM) - list(GET FOR_ITEM 0 FOR_FOR) - if (NOT "${FOR_FOR}" STREQUAL "FOR") - message(FATAL_ERROR "ENDFOR does not match last item: ${FOR_FOR}") - endif() - list(GET FOR_ITEM 1 FOR_POSITION) - list(GET FOR_ITEM 2 FOR_KEY) - if (NOT "${FOR_KEY}" STREQUAL "${ENDFOR_KEY}") - calculate_line_number("${TEMPLATE_CONTENTS}" "${POSITION}" LINENUMBER) - message("FOR and ENDFOR do not match. (line number ${LINENUMBER}) (FOR:${FOR_KEY}, ENDFOR:${ENDFOR_KEY})") - endif() - list(GET FOR_ITEM 3 FOR_INDEX_PREV) - template_parameters_find_next_groupname_index("${TEMPLATE_PARAMETERS}" "${FOR_KEY}" ${FOR_INDEX_PREV} FOR_INDEX) - if (DEBUG) - message("FOR_INDEX was ${FOR_INDEX_PREV}, is now ${FOR_INDEX}") - endif() - if (${FOR_INDEX} LESS 0) - if (DEBUG) - message("ENDFOR: FOR_INDEX < 0 (no more key) ==> Continue") - endif() - else() - set(POSITION ${FOR_POSITION}) - stack_push(STACK FOR ${FOR_POSITION} ${FOR_KEY} ${FOR_INDEX}) - if (DEBUG) - message("ENDFOR: FOR_INDEX >= 0 (more keys available) ==> Back to position=${FOR_POSITION}") - endif() - endif() - elseif (GROUP_MATCH MATCHES "^CASE") - string(REGEX MATCH "^CASE[${WS}]+\\(([a-zA-Z]+)\\)" CASE_MATCH "${GROUP_MATCH}") - if ("${CASE_MATCH}" STREQUAL "") - message(FATAL_ERROR "Wrong CASE syntax") - endif() - set(CASE_KEY "${CMAKE_MATCH_1}") - if (DEBUG) - message("CASE: KEY=${CASE_KEY}") - endif() - stack_push(STACK CASE "${CASE_KEY}" ${POSITION}) - elseif (GROUP_MATCH MATCHES "^==") - math(EXPR POSITION "${POSITION}+1") - string(REGEX MATCH "^==[${WS}]+([a-zA-Z_][a-zA-Z0-9_]*)" CASE_MATCH "${GROUP_MATCH}") - if ("${CASE_MATCH}" STREQUAL "") - message(FATAL_ERROR "Wrong == syntax") - endif() - stack_top(STACK CASE_ITEM) - list(GET CASE_ITEM 0 CASE_CASE) - if(NOT "${CASE_CASE}" STREQUAL "CASE") - message(FATAL_ERROR "== block must be in CASE. Top of stack=${CASE_CASE}") - endif() - set(CASE_VALUE "${CMAKE_MATCH_1}") - if (DEBUG) - message("case: == VALUE=${CASE_VALUE}") - endif() - list(GET CASE_ITEM 1 CASE_KEY) - if ("${CASE_KEY}" STREQUAL "suffix") - if (DEBUG) - message("Setting write filter to ${CASE_VALUE}") - endif() - set(WRITE_FILTER "${CASE_VALUE}") - else() - message(FATAL_ERROR "CASE: unsupported argument ${CASE_KEY}") - endif() - elseif (GROUP_MATCH MATCHES "^ESAC") - stack_pop(STACK CASE_ITEM) - if (DEBUG) - message("ESAC") - endif() - list(GET CASE_ITEM 0 CASE_CASE) - if (NOT "${CASE_CASE}" STREQUAL "CASE") - message(FATAL_ERROR "ESAC does not match last item: ${CASE_CASE}") - endif() - if ("${CASE_KEY}" STREQUAL "suffix") - if (DEBUG) - message("Removing write filter") - endif() - set(WRITE_FILTER "") - else() - message(FATAL_ERROR "CASE: unsupported argument ${CASE_KEY}") - endif() - else() - string(REGEX MATCH "\\(([a-zA-Z0-9_$%\"${WS}\\+\\-]+)\\)" PARENTHESE_MATCH "${GROUP_MATCH}") - if (NOT "${PARENTHESE_MATCH}" STREQUAL "") - set(PARENTHESE_CONTENT "${CMAKE_MATCH_1}") - string(REPLACE " " ";" PARENTHESE_LIST "${PARENTHESE_CONTENT}") - list(GET PARENTHESE_LIST 0 PARENTHESE_COMMAND) - if ("${PARENTHESE_COMMAND}" STREQUAL "get") - list(GET PARENTHESE_LIST 1 KEY_QUOTED) - string(REGEX MATCH "\\\"([a-zA-Z_${WS}]+)\\\"" KEY_MATCH "${KEY_QUOTED}") - if ("${KEY_MATCH}" STREQUAL "") - message(FATAL_ERROR "get: empty key") - endif() - set(KEY "${CMAKE_MATCH_1}") - if (DEBUG) - message("Get: key=${KEY}") - endif() - stack_find_key("${STACK}" "${TEMPLATE_PARAMETERS}" "${KEY}" VALUE) - if (DEBUG) - message("Get key=${KEY} ==> value=${VALUE}") - endif() - append_output_text("${SUFFICES_FILENAMES}" "${VALUE}" "${WRITE_FILTER}") - elseif("${PARENTHESE_COMMAND}" STREQUAL "tpl-file-line") - list(GET PARENTHESE_LIST 1 FORMAT_LINE) - calculate_line_number("${TEMPLATE_CONTENTS}" "${POSITION}" LINENUMBER) - append_output_text("${SUFFICES_FILENAMES}" "${LINENUMBER}" "${WRITE_FILTER}") - else() - message(FATAL_ERROR "Unknown parenthese command: ${PARENTHESE_COMMAND}") - endif() - else() - message(FATAL_ERROR "Unknown command: ${GROUP_MATCH}") - endif() - endif() - - endwhile() - if (NOT "${STACK}" STREQUAL "") - message(FATAL_ERROR "STACK was not empty at EOF") - endif() - output_finish("${SUFFICES_FILENAMES}") -endfunction() - -if ("${DEFINITION}" STREQUAL "") - message(FATAL_ERROR "Need definition file") -endif() -if (NOT EXISTS "${DEFINITION}") - message(FATAL_ERROR "Definition file does not exist (${DEFINITION})") -endif() - -read_definition("${DEFINITION}" TEMPLATE_FILENAME DATA) -if (DEBUG) - message("${TEMPLATE_FILENAME}") - message("${DATA}") -endif() - -parse_template("${TEMPLATE_FILENAME}" "${OUTPUTDIR}" "${DATA}") diff --git a/Engine/lib/libsndfile/cmake/CheckCPUArch.c.in b/Engine/lib/libsndfile/cmake/CheckCPUArch.c.in deleted file mode 100644 index 549313947..000000000 --- a/Engine/lib/libsndfile/cmake/CheckCPUArch.c.in +++ /dev/null @@ -1,7 +0,0 @@ -int main(void) { -#if @CHECK_CPU_ARCH_DEFINES@ - return 0; -#else - fail -#endif -} diff --git a/Engine/lib/libsndfile/cmake/CheckCPUArch.cmake b/Engine/lib/libsndfile/cmake/CheckCPUArch.cmake deleted file mode 100644 index 1fdb3c864..000000000 --- a/Engine/lib/libsndfile/cmake/CheckCPUArch.cmake +++ /dev/null @@ -1,23 +0,0 @@ -macro (_CHECK_CPU_ARCH ARCH ARCH_DEFINES VARIABLE) - if (NOT DEFINED HAVE_${VARIABLE}) - message (STATUS "Check CPU architecture is ${ARCH}") - set (CHECK_CPU_ARCH_DEFINES ${ARCH_DEFINES}) - configure_file (${PROJECT_SOURCE_DIR}/cmake/CheckCPUArch.c.in ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c @ONLY) - try_compile (HAVE_${VARIABLE} "${PROJECT_BINARY_DIR}" - "${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c") - if(HAVE_${VARIABLE}) - message (STATUS "Check CPU architecture is ${ARCH} - yes") - set (${VARIABLE} 1 CACHE INTERNAL "Result of CHECK_CPU_ARCH_X64" FORCE) - else () - message (STATUS "Check CPU architecture is ${ARCH} - no") - endif () - endif () -endmacro (_CHECK_CPU_ARCH) - -macro (CHECK_CPU_ARCH_X64 VARIABLE) - _CHECK_CPU_ARCH (x64 "defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" ${VARIABLE}) -endmacro (CHECK_CPU_ARCH_X64) - -macro (CHECK_CPU_ARCH_X86 VARIABLE) - _CHECK_CPU_ARCH (x86 "defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" ${VARIABLE}) -endmacro (CHECK_CPU_ARCH_X86) diff --git a/Engine/lib/libsndfile/cmake/ClipMode.cmake b/Engine/lib/libsndfile/cmake/ClipMode.cmake deleted file mode 100644 index 0241e0379..000000000 --- a/Engine/lib/libsndfile/cmake/ClipMode.cmake +++ /dev/null @@ -1,92 +0,0 @@ -include (CheckCSourceRuns) -include (CMakePushCheckState) - -macro (CLIP_MODE) - if ((NOT DEFINED CPU_CLIPS_NEGATIVE) AND (NOT DEFINED CPU_CLIPS_POSITIVE)) - set (CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion") - set (CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion") - - message (STATUS "Checking processor clipping capabilities...") - - if (CMAKE_CROSSCOMPILING) - - set (CLIP_MSG "disabled") - set (CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE}) - set (CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE}) - - else (NOT CMAKE_CROSSCOMPILING) - - cmake_push_check_state () - - set (CMAKE_REQUIRED_QUIET TRUE) - if (LIBM_REQUIRED) - set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY}) - endif () - - check_c_source_runs ( - " - #define _ISOC9X_SOURCE 1 - #define _ISOC99_SOURCE 1 - #define __USE_ISOC99 1 - #define __USE_ISOC9X 1 - #include - int main (void) - { double fval ; - int k, ival ; - - fval = 1.0 * 0x7FFFFFFF ; - for (k = 0 ; k < 100 ; k++) - { ival = (lrint (fval)) >> 24 ; - if (ival != 127) - return 1 ; - - fval *= 1.2499999 ; - } ; - - return 0 ; - } - " - CPU_CLIPS_POSITIVE) - - check_c_source_runs ( - " - #define _ISOC9X_SOURCE 1 - #define _ISOC99_SOURCE 1 - #define __USE_ISOC99 1 - #define __USE_ISOC9X 1 - #include - int main (void) - { double fval ; - int k, ival ; - - fval = -8.0 * 0x10000000 ; - for (k = 0 ; k < 100 ; k++) - { ival = (lrint (fval)) >> 24 ; - if (ival != -128) - return 1 ; - - fval *= 1.2499999 ; - } ; - - return 0 ; - } - " - CPU_CLIPS_NEGATIVE) - - cmake_pop_check_state () - - if (CPU_CLIPS_POSITIVE AND (NOT CPU_CLIPS_NEGATIVE)) - set (CLIP_MSG "positive") - elseif (CPU_CLIPS_NEGATIVE AND (NOT CPU_CLIPS_POSITIVE)) - set (CLIP_MSG "negative") - elseif (CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE) - set (CLIP_MSG "both") - else () - set (CLIP_MSG "none") - endif () - - endif (CMAKE_CROSSCOMPILING) - - message (STATUS "Checking processor clipping capabilities... ${CLIP_MSG}") - endif () -endmacro (CLIP_MODE) diff --git a/Engine/lib/libsndfile/cmake/FindFLAC.cmake b/Engine/lib/libsndfile/cmake/FindFLAC.cmake deleted file mode 100644 index 34917067c..000000000 --- a/Engine/lib/libsndfile/cmake/FindFLAC.cmake +++ /dev/null @@ -1,67 +0,0 @@ -# - Find FLAC -# Find the native FLAC includes and libraries -# -# FLAC_INCLUDE_DIRS - where to find FLAC headers. -# FLAC_LIBRARIES - List of libraries when using libFLAC. -# FLAC_FOUND - True if libFLAC found. -# FLAC_DEFINITIONS - FLAC compile definitons - -if (FLAC_INCLUDE_DIR) - # Already in cache, be silent - set (FLAC_FIND_QUIETLY TRUE) -endif () - -find_package (Ogg QUIET) - -find_package (PkgConfig QUIET) -pkg_check_modules(PC_FLAC QUIET flac) - -set(FLAC_VERSION ${PC_FLAC_VERSION}) - -find_path (FLAC_INCLUDE_DIR FLAC/stream_decoder.h - HINTS - ${PC_FLAC_INCLUDEDIR} - ${PC_FLAC_INCLUDE_DIRS} - ${FLAC_ROOT} - ) - -# MSVC built libraries can name them *_static, which is good as it -# distinguishes import libraries from static libraries with the same extension. -find_library (FLAC_LIBRARY - NAMES - FLAC - libFLAC - libFLAC_dynamic - libFLAC_static - HINTS - ${PC_FLAC_LIBDIR} - ${PC_FLAC_LIBRARY_DIRS} - ${FLAC_ROOT} - ) - -# Handle the QUIETLY and REQUIRED arguments and set FLAC_FOUND to TRUE if -# all listed variables are TRUE. -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (FLAC - REQUIRED_VARS - FLAC_LIBRARY - FLAC_INCLUDE_DIR - Ogg_FOUND - VERSION_VAR - FLAC_VERSION - ) - -if (FLAC_FOUND) - set (FLAC_INCLUDE_DIRS ${FLAC_INCLUDE_DIR}) - set (FLAC_LIBRARIES ${FLAC_LIBRARY} ${OGG_LIBRARIES}) - if (NOT TARGET FLAC::FLAC) - add_library(FLAC::FLAC UNKNOWN IMPORTED) - set_target_properties(FLAC::FLAC PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}" - IMPORTED_LOCATION "${FLAC_LIBRARY}" - INTERFACE_LINK_LIBRARIES Ogg::ogg - ) - endif () -endif () - -mark_as_advanced(FLAC_INCLUDE_DIR FLAC_LIBRARY) diff --git a/Engine/lib/libsndfile/cmake/FindOgg.cmake b/Engine/lib/libsndfile/cmake/FindOgg.cmake deleted file mode 100644 index 9cf5ce430..000000000 --- a/Engine/lib/libsndfile/cmake/FindOgg.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# - Find ogg -# Find the native ogg includes and libraries -# -# OGG_INCLUDE_DIRS - where to find ogg.h, etc. -# OGG_LIBRARIES - List of libraries when using ogg. -# OGG_FOUND - True if ogg found. - -if (OGG_INCLUDE_DIR) - # Already in cache, be silent - set(OGG_FIND_QUIETLY TRUE) -endif () - -find_package (PkgConfig QUIET) -pkg_check_modules (PC_OGG QUIET ogg>=1.3.0) - -set (OGG_VERSION ${PC_OGG_VERSION}) - -find_path (OGG_INCLUDE_DIR ogg/ogg.h - HINTS - ${PC_OGG_INCLUDEDIR} - ${PC_OGG_INCLUDE_DIRS} - ${OGG_ROOT} - ) -# MSVC built ogg may be named ogg_static. -# The provided project files name the library with the lib prefix. -find_library (OGG_LIBRARY - NAMES - ogg - ogg_static - libogg - libogg_static - HINTS - ${PC_OGG_LIBDIR} - ${PC_OGG_LIBRARY_DIRS} - ${OGG_ROOT} - ) -# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND -# to TRUE if all listed variables are TRUE. -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (Ogg - REQUIRED_VARS - OGG_LIBRARY - OGG_INCLUDE_DIR - VERSION_VAR - OGG_VERSION - ) - -if (OGG_FOUND) - set (OGG_LIBRARIES ${OGG_LIBRARY}) - set (OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR}) - - if(NOT TARGET Ogg::ogg) - add_library(Ogg::ogg UNKNOWN IMPORTED) - set_target_properties(Ogg::ogg PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}" - IMPORTED_LOCATION "${OGG_LIBRARIES}" - ) - endif () -endif () - -mark_as_advanced (OGG_INCLUDE_DIR OGG_LIBRARY) diff --git a/Engine/lib/libsndfile/cmake/FindOpus.cmake b/Engine/lib/libsndfile/cmake/FindOpus.cmake deleted file mode 100644 index a83686bdd..000000000 --- a/Engine/lib/libsndfile/cmake/FindOpus.cmake +++ /dev/null @@ -1,67 +0,0 @@ -# - Find opus -# Find the native opus includes and libraries -# -# OPUS_INCLUDE_DIRS - where to find opus.h, etc. -# OPUS_LIBRARIES - List of libraries when using opus. -# OPUS_FOUND - True if Opus found. - -if (OPUS_INCLUDE_DIR) - # Already in cache, be silent - set(OPUS_FIND_QUIETLY TRUE) -endif () - -find_package (Ogg QUIET) - -find_package (PkgConfig QUIET) -pkg_check_modules(PC_OPUS QUIET opus>=1.1) - -set (OPUS_VERSION ${PC_OPUS_VERSION}) - -find_path (OPUS_INCLUDE_DIR opus/opus.h - HINTS - ${PC_OPUS_INCLUDEDIR} - ${PC_OPUS_INCLUDE_DIRS} - ${OPUS_ROOT} - ) - -# MSVC built opus may be named opus_static. -# The provided project files name the library with the lib prefix. - -find_library (OPUS_LIBRARY - NAMES - opus - opus_static - libopus - libopus_static - HINTS - ${PC_OPUS_LIBDIR} - ${PC_OPUS_LIBRARY_DIRS} - ${OPUS_ROOT} - ) - -# Handle the QUIETLY and REQUIRED arguments and set OPUS_FOUND -# to TRUE if all listed variables are TRUE. -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args (Opus - REQUIRED_VARS - OPUS_LIBRARY - OPUS_INCLUDE_DIR - OGG_FOUND - VERSION_VAR - OPUS_VERSION - ) - -if (OPUS_FOUND) - set (OPUS_LIBRARIES ${OPUS_LIBRARY}) - set (OPUS_INCLUDE_DIRS ${OPUS_INCLUDE_DIR}) - - if (NOT TARGET Opus::opus) - add_library (Opus::opus UNKNOWN IMPORTED) - set_target_properties (Opus::opus PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPUS_INCLUDE_DIRS}" - IMPORTED_LOCATION "${OPUS_LIBRARIES}" - ) - endif () -endif () - -mark_as_advanced(OPUS_INCLUDE_DIR OPUS_LIBRARY) diff --git a/Engine/lib/libsndfile/cmake/FindSndio.cmake b/Engine/lib/libsndfile/cmake/FindSndio.cmake deleted file mode 100644 index 6b9b40986..000000000 --- a/Engine/lib/libsndfile/cmake/FindSndio.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# - Find SoundIO (sndio) includes and libraries -# -# SNDIO_FOUND - True if SNDIO_INCLUDE_DIR & SNDIO_LIBRARY are -# found -# SNDIO_LIBRARIES - Set when SNDIO_LIBRARY is found -# SNDIO_INCLUDE_DIRS - Set when SNDIO_INCLUDE_DIR is found -# -# SNDIO_INCLUDE_DIR - where to find sndio.h, etc. -# SNDIO_LIBRARY - the sndio library -# - -if (SNDIO_INCLUDE_DIR) - # Already in cache, be silent - set (SNDIO_FIND_QUIETLY TRUE) -endif () - -find_package (PkgConfig QUIET) -pkg_check_modules (PC_SNDIO QUIET sndio) - -set (SNDIO_VERSION ${PC_SNDIO_VERSION}) - -find_path (SNDIO_INCLUDE_DIR - NAMES - sndio.h - HINTS - ${PC_SNDIO_INCLUDEDIR} - ${PC_SNDIO_INCLUDE_DIRS} - ${SNDIO_ROOT} - ) - -find_library (SNDIO_LIBRARY - NAMES - sndio - HINTS - ${PC_SNDIO_LIBDIR} - ${PC_SNDIO_LIBRARY_DIRS} - ${SNDIO_ROOT} - ) - -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (Sndio - REQUIRED_VARS - SNDIO_LIBRARY - SNDIO_INCLUDE_DIR - VERSION_VAR - SNDIO_VERSION - ) - -if (SNDIO_FOUND) - set (SNDIO_LIBRARIES ${SNDIO_LIBRARY}) - set (SNDIO_INCLUDE_DIRS ${SNDIO_INCLUDE_DIR}) - if (NOT TARGET Sndio::Sndio) - add_library (Sndio::Sndio UNKNOWN IMPORTED) - set_target_properties (Sndio::Sndio PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${SNDIO_INCLUDE_DIRS}" - IMPORTED_LOCATION "${SNDIO_LIBRARIES}" - ) - endif() -endif() - -mark_as_advanced (SNDIO_INCLUDE_DIR SNDIO_LIBRARY) diff --git a/Engine/lib/libsndfile/cmake/FindSpeex.cmake b/Engine/lib/libsndfile/cmake/FindSpeex.cmake deleted file mode 100644 index c28fe60cb..000000000 --- a/Engine/lib/libsndfile/cmake/FindSpeex.cmake +++ /dev/null @@ -1,55 +0,0 @@ -# - Find Speex -# Find the native Speex includes and libraries -# -# SPEEX_INCLUDE_DIRS - where to find speex.h, etc. -# SPEEX_LIBRARIES - List of libraries when using Speex. -# SPEEX_FOUND - True if Speex found. - -if (SPEEX_INCLUDE_DIR) - set (SPEEX_FIND_QUIETLY TRUE) -endif () - -find_package (PkgConfig QUIET) -pkg_check_modules (PC_SPEEX QUIET speex) - -set (SPEEX_VERSION ${PC_SPEEX_VERSION}) - -find_path (SPEEX_INCLUDE_DIR speex/speex.h - HINTS - ${PC_SPEEX_INCLUDEDIR} - ${PC_SPEEX_INCLUDE_DIRS} - ${SPEEX_ROOT} - ) -find_library (SPEEX_LIBRARY - NAMES - speex - libspeex - HINTS - ${PC_SPEEX_LIBDIR} - ${PC_SPEEX_LIBRARY_DIRS} - ${SPEEX_ROOT} - ) - -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (Speex - REQUIRED_VARS - SPEEX_LIBRARY - SPEEX_INCLUDE_DIR - VERSION_VAR - SPEEX_VERSION - ) - -if (SPEEX_FOUND) - set (SPEEX_LIBRARIES ${SPEEX_LIBRARY}) - set (SPEEX_INCLUDE_DIRS ${SPEEX_INCLUDE_DIR}) - - if (NOT TARGET Speex::Speex) - add_library (Speex::Speex UNKNOWN IMPORTED) - set_target_properties (Speex::Speex PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${SPEEX_INCLUDE_DIRS}" - IMPORTED_LOCATION "${SPEEX_LIBRARIES}" - ) - endif () -endif () - -mark_as_advanced (SPEEX_INCLUDE_DIR SPEEX_LIBRARY) diff --git a/Engine/lib/libsndfile/cmake/FindVorbis.cmake b/Engine/lib/libsndfile/cmake/FindVorbis.cmake deleted file mode 100644 index 57e60557f..000000000 --- a/Engine/lib/libsndfile/cmake/FindVorbis.cmake +++ /dev/null @@ -1,210 +0,0 @@ -#[=======================================================================[.rst: -FindVorbis ----------- - -Finds the native vorbis, vorbisenc amd vorbisfile includes and libraries. - -Imported Targets -^^^^^^^^^^^^^^^^ - -This module provides the following imported targets, if found: - -``Vorbis::vorbis`` - The Vorbis library -``Vorbis::vorbisenc`` - The VorbisEnc library -``Vorbis::vorbisfile`` - The VorbisFile library - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables: - -``Vorbis_Vorbis_INCLUDE_DIRS`` - List of include directories when using vorbis. -``Vorbis_Enc_INCLUDE_DIRS`` - List of include directories when using vorbisenc. -``Vorbis_File_INCLUDE_DIRS`` - List of include directories when using vorbisfile. -``Vorbis_Vorbis_LIBRARIES`` - List of libraries when using vorbis. -``Vorbis_Enc_LIBRARIES`` - List of libraries when using vorbisenc. -``Vorbis_File_LIBRARIES`` - List of libraries when using vorbisfile. -``Vorbis_FOUND`` - True if vorbis and requested components found. -``Vorbis_Vorbis_FOUND`` - True if vorbis found. -``Vorbis_Enc_FOUND`` - True if vorbisenc found. -``Vorbis_Enc_FOUND`` - True if vorbisfile found. - -Cache variables -^^^^^^^^^^^^^^^ - -The following cache variables may also be set: - -``Vorbis_Vorbis_INCLUDE_DIR`` - The directory containing ``vorbis/vorbis.h``. -``Vorbis_Enc_INCLUDE_DIR`` - The directory containing ``vorbis/vorbisenc.h``. -``Vorbis_File_INCLUDE_DIR`` - The directory containing ``vorbis/vorbisenc.h``. -``Vorbis_Vorbis_LIBRARY`` - The path to the vorbis library. -``Vorbis_Enc_LIBRARY`` - The path to the vorbisenc library. -``Vorbis_File_LIBRARY`` - The path to the vorbisfile library. - -Hints -^^^^^ - -A user may set ``Vorbis_ROOT`` to a vorbis installation root to tell this module where to look. - -#]=======================================================================] - -if (Vorbis_Vorbis_INCLUDE_DIR) - # Already in cache, be silent - set (Vorbis_FIND_QUIETLY TRUE) -endif () - -set (Vorbis_Vorbis_FIND_QUIETLY TRUE) -set (Vorbis_Enc_FIND_QUIETLY TRUE) -set (Vorbis_File_FIND_QUIETLY TRUE) - -find_package (Ogg QUIET) - -find_package (PkgConfig QUIET) -pkg_check_modules (PC_Vorbis_Vorbis QUIET vorbis) -pkg_check_modules (PC_Vorbis_Enc QUIET vorbisenc) -pkg_check_modules (PC_Vorbis_File QUIET vorbisfile) - -set (Vorbis_VERSION ${PC_Vorbis_Vorbis_VERSION}) - -find_path (Vorbis_Vorbis_INCLUDE_DIR vorbis/codec.h - HINTS - ${PC_Vorbis_Vorbis_INCLUDEDIR} - ${PC_Vorbis_Vorbis_INCLUDE_DIRS} - ${Vorbis_ROOT} - ) - -find_path (Vorbis_Enc_INCLUDE_DIR vorbis/vorbisenc.h - HINTS - ${PC_Vorbis_Enc_INCLUDEDIR} - ${PC_Vorbis_Enc_INCLUDE_DIRS} - ${Vorbis_ROOT} - ) - -find_path (Vorbis_File_INCLUDE_DIR vorbis/vorbisfile.h - HINTS - ${PC_Vorbis_File_INCLUDEDIR} - ${PC_Vorbis_File_INCLUDE_DIRS} - ${Vorbis_ROOT} - ) - -find_library (Vorbis_Vorbis_LIBRARY - NAMES - vorbis - vorbis_static - libvorbis - libvorbis_static - HINTS - ${PC_Vorbis_Vorbis_LIBDIR} - ${PC_Vorbis_Vorbis_LIBRARY_DIRS} - ${Vorbis_ROOT} - ) - -find_library (Vorbis_Enc_LIBRARY - NAMES - vorbisenc - vorbisenc_static - libvorbisenc - libvorbisenc_static - HINTS - ${PC_Vorbis_Enc_LIBDIR} - ${PC_Vorbis_Enc_LIBRARY_DIRS} - ${Vorbis_ROOT} - ) - -find_library (Vorbis_File_LIBRARY - NAMES - vorbisfile - vorbisfile_static - libvorbisfile - libvorbisfile_static - HINTS - ${PC_Vorbis_File_LIBDIR} - ${PC_Vorbis_File_LIBRARY_DIRS} - ${Vorbis_ROOT} - ) - -include (FindPackageHandleStandardArgs) - -if (Vorbis_Vorbis_LIBRARY AND Vorbis_Vorbis_INCLUDE_DIR AND Ogg_FOUND) - set (Vorbis_Vorbis_FOUND TRUE) -endif () - -if (Vorbis_Enc_LIBRARY AND Vorbis_Enc_INCLUDE_DIR AND Vorbis_Vorbis_FOUND) - set (Vorbis_Enc_FOUND TRUE) -endif () - -if (Vorbis_Vorbis_FOUND AND Vorbis_File_LIBRARY AND Vorbis_File_INCLUDE_DIR) - set (Vorbis_File_FOUND TRUE) -endif () - -find_package_handle_standard_args (Vorbis - REQUIRED_VARS - Vorbis_Vorbis_LIBRARY - Vorbis_Vorbis_INCLUDE_DIR - Ogg_FOUND - HANDLE_COMPONENTS - VERSION_VAR Vorbis_VERSION) - - -if (Vorbis_Vorbis_FOUND) - set (Vorbis_Vorbis_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR}) - set (Vorbis_Vorbis_LIBRARIES ${VORBIS_LIBRARY} ${OGG_LIBRARIES}) - if (NOT TARGET Vorbis::vorbis) - add_library (Vorbis::vorbis UNKNOWN IMPORTED) - set_target_properties (Vorbis::vorbis PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Vorbis_INCLUDE_DIR}" - IMPORTED_LOCATION "${Vorbis_Vorbis_LIBRARY}" - INTERFACE_LINK_LIBRARIES Ogg::ogg - ) - endif () - - if (Vorbis_Enc_FOUND) - set (Vorbis_Enc_INCLUDE_DIRS ${Vorbis_Enc_INCLUDE_DIR}) - set (Vorbis_Enc_LIBRARIES ${Vorbis_Enc_LIBRARY} ${Vorbis_Enc_LIBRARIES}) - if (NOT TARGET Vorbis::vorbisenc) - add_library (Vorbis::vorbisenc UNKNOWN IMPORTED) - set_target_properties (Vorbis::vorbisenc PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Enc_INCLUDE_DIR}" - IMPORTED_LOCATION "${Vorbis_Enc_LIBRARY}" - INTERFACE_LINK_LIBRARIES Vorbis::vorbis - ) - endif () - endif () - - if (Vorbis_File_FOUND) - set (Vorbis_File_INCLUDE_DIRS ${Vorbis_File_INCLUDE_DIR}) - set (Vorbis_File_LIBRARIES ${Vorbis_File_LIBRARY} ${Vorbis_File_LIBRARIES}) - if (NOT TARGET Vorbis::vorbisfile) - add_library (Vorbis::vorbisfile UNKNOWN IMPORTED) - set_target_properties (Vorbis::vorbisfile PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_File_INCLUDE_DIR}" - IMPORTED_LOCATION "${Vorbis_File_LIBRARY}" - INTERFACE_LINK_LIBRARIES Vorbis::vorbis - ) - endif () - endif () - -endif () - -mark_as_advanced (Vorbis_Vorbis_INCLUDE_DIR Vorbis_Vorbis_LIBRARY) -mark_as_advanced (Vorbis_Enc_INCLUDE_DIR Vorbis_Enc_LIBRARY) -mark_as_advanced (Vorbis_File_INCLUDE_DIR Vorbis_File_LIBRARY) diff --git a/Engine/lib/libsndfile/cmake/Findmp3lame.cmake b/Engine/lib/libsndfile/cmake/Findmp3lame.cmake deleted file mode 100644 index 223dd08f5..000000000 --- a/Engine/lib/libsndfile/cmake/Findmp3lame.cmake +++ /dev/null @@ -1,67 +0,0 @@ -# - Find lame -# Find the native lame includes and libraries -# -# MP3LAME_INCLUDE_DIRS - where to find lame.h, etc. -# MP3LAME_LIBRARIES - List of libraries when using lame. -# MP3LAME_FOUND - True if Lame found. - -if (MP3LAME_INCLUDE_DIR) - # Already in cache, be silent - set(MP3LAME_FIND_QUIETLY TRUE) -endif () - -find_path (MP3LAME_INCLUDE_DIR lame/lame.h - HINTS - ${LAME_ROOT} - ) - -# MSVC built lame may be named mp3lame_static. -# The provided project files name the library with the lib prefix. - -find_library (MP3LAME_LIBRARY - NAMES - mp3lame - mp3lame_static - libmp3lame - libmp3lame_static - libmp3lame-static - HINTS - ${MP3LAME_ROOT} - ) - -find_library (MP3LAME_HIP_LIBRARY - NAMES - mpghip-static - libmpghip-static - HINTS - ${MP3LAME_ROOT} - ) - -# Handle the QUIETLY and REQUIRED arguments and set LAME_FOUND -# to TRUE if all listed variables are TRUE. -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args (mp3lame - REQUIRED_VARS - MP3LAME_LIBRARY - MP3LAME_INCLUDE_DIR - ) - -if (MP3LAME_FOUND) - set (MP3LAME_LIBRARIES ${MP3LAME_LIBRARY} ${MP3LAME_HIP_LIBRARY}) - set (MP3LAME_INCLUDE_DIRS ${MP3LAME_INCLUDE_DIR}) - - if (NOT TARGET mp3lame::mp3lame) - add_library (mp3lame::mp3lame UNKNOWN IMPORTED) - set_target_properties (mp3lame::mp3lame PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${MP3LAME_INCLUDE_DIRS}" - IMPORTED_LOCATION "${MP3LAME_LIBRARY}" - ) - if (MP3LAME_HIP_LIBRARY AND (NOT TARGET mp3lame::mpghip)) - add_library (mp3lame::mpghip STATIC IMPORTED) - set_property (mp3lame::mpghip PROPERTY IMPORTED_LOCATION "${MP3LAME_HIP_LIBRARY}") - set_property (TARGET mp3lame::mp3lame PROPERTY INTERFACE_LINK_LIBRARIES "mp3lame::mpghip") - endif () - endif () -endif () - -mark_as_advanced(MP3LAME_INCLUDE_DIR MP3LAME_LIBRARY MP3LAME_HIP_LIBRARY) diff --git a/Engine/lib/libsndfile/cmake/Findmpg123.cmake b/Engine/lib/libsndfile/cmake/Findmpg123.cmake deleted file mode 100644 index 36bb2389a..000000000 --- a/Engine/lib/libsndfile/cmake/Findmpg123.cmake +++ /dev/null @@ -1,95 +0,0 @@ -#[=======================================================================[.rst: -Findmpg123 -------- - -Finds the mpg123 library. - -Imported Targets -^^^^^^^^^^^^^^^^ - -This module provides the following imported targets, if found: - -``MPG123::libmpg123`` - The mpg123 library - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables: - -``mpg123_FOUND`` - True if the system has the mpg123 package. -``mpg123_VERSION`` - The version of mpg123 that was found on the system. - -Cache Variables -^^^^^^^^^^^^^^^ - -The following cache variables may also be set: - -``mpg123_INCLUDE_DIR`` - The directory containing ``mpg123.h``. -``mpg123_LIBRARY`` - The path to the mpg123 library. - -#]=======================================================================] - -if (mpg123_INCLUDE_DIR) - # Already in cache, be silent - set(mpg123_FIND_QUIETLY TRUE) -endif () - -find_package (PkgConfig QUIET) -pkg_check_modules(PC_MPG123 QUIET libmpg123>=1.25.10) - -find_path (mpg123_INCLUDE_DIR mpg123.h - HINTS - ${PC_MPG123_INCLUDEDIR} - ${PC_MPG123_INCLUDE_DIRS} - ${mpg123_ROOT} - ) - -# MSVC built mpg123 may be named mpg123_static. -# The provided project files name the library with the lib prefix. - -find_library (mpg123_LIBRARY - NAMES - mpg123 - mpg123_static - libmpg123 - libmpg123_static - HINTS - ${PC_MPG123_LIBDIR} - ${PC_MPG123_LIBRARY_DIRS} - ${mpg123_ROOT} - ) - -if (PC_MPG123_FOUND) - set (mpg123_VERSION ${PC_MPG123_VERSION}) -elseif (mpg123_INCLUDE_DIR) - file (READ "${mpg123_INCLUDE_DIR}/mpg123.h" _mpg123_h) - string (REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" _mpg123_version_re "${_mpg123_h}") - set (mpg123_VERSION "${_mpg123_version_re}") -endif () - -# Handle the QUIETLY and REQUIRED arguments and set mpg123_FOUND -# to TRUE if all listed variables are TRUE. -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args (mpg123 - REQUIRED_VARS - mpg123_LIBRARY - mpg123_INCLUDE_DIR - VERSION_VAR - mpg123_VERSION - ) - -if (mpg123_FOUND AND NOT TARGET MPG123::libmpg123) - add_library (MPG123::libmpg123 UNKNOWN IMPORTED) - set_target_properties (MPG123::libmpg123 - PROPERTIES - IMPORTED_LOCATION "${mpg123_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${mpg123_INCLUDE_DIR}" - ) -endif () - -mark_as_advanced(mpg123_INCLUDE_DIR mpg123_LIBRARY) diff --git a/Engine/lib/libsndfile/cmake/SetupABIVersions.cmake b/Engine/lib/libsndfile/cmake/SetupABIVersions.cmake deleted file mode 100644 index 331a2bd9a..000000000 --- a/Engine/lib/libsndfile/cmake/SetupABIVersions.cmake +++ /dev/null @@ -1,56 +0,0 @@ -# Inspiration: https://github.com/ros2-dotnet/Fast-RTPS - -macro (SETUP_ABI_VERSIONS) - - file (STRINGS ${PROJECT_SOURCE_DIR}/configure.ac CONFIGURE_AC_CONTENT) - file (STRINGS - configure.ac - SNDFILE_LT_CURRENT_TMP - REGEX "^m4_define\\(\\[?lt_current\\]?, *\\[?[0-9]+\\]?\\)" - ) - string (REGEX REPLACE "m4_define\\(\\[?lt_current\\]?, *\\[?([0-9]+)\\]?\\)" - "\\1" - SNDFILE_LT_CURRENT - ${SNDFILE_LT_CURRENT_TMP} - ) - - file (STRINGS - configure.ac - SNDFILE_LT_REVISION_TMP - REGEX "^m4_define\\(\\[?lt_revision\\]?, *\\[?[0-9]+\\]?\\)" - ) - string (REGEX REPLACE "m4_define\\(\\[?lt_revision\\]?, *\\[?([0-9]+)\\]?\\)" - "\\1" - SNDFILE_LT_REVISION - ${SNDFILE_LT_REVISION_TMP} - ) - - file (STRINGS - configure.ac - SNDFILE_LT_AGE_TMP - REGEX "^m4_define\\(\\[?lt_age\\]?, *\\[?[0-9]+\\]?\\)" - ) - string (REGEX REPLACE "m4_define\\(\\[?lt_age\\]?, *\\[?([0-9]+)\\]?\\)" - "\\1" - SNDFILE_LT_AGE - ${SNDFILE_LT_AGE_TMP} - ) - - # - # Calculate CMake compatible ABI version from libtool version. - # - - math (EXPR SNDFILE_ABI_VERSION_MAJOR "${SNDFILE_LT_CURRENT} - ${SNDFILE_LT_AGE}") - set (SNDFILE_ABI_VERSION_MINOR ${SNDFILE_LT_AGE}) - set (SNDFILE_ABI_VERSION_PATCH ${SNDFILE_LT_REVISION}) - set (SNDFILE_ABI_VERSION "${SNDFILE_ABI_VERSION_MAJOR}.${SNDFILE_ABI_VERSION_MINOR}.${SNDFILE_ABI_VERSION_PATCH}") - - # - # Apple platform current and compatibility versions. - # - - math (EXPR SNDFILE_MACHO_CURRENT_VERSION_MAJOR "${SNDFILE_ABI_VERSION_MAJOR} + ${SNDFILE_ABI_VERSION_MINOR} + 1") - set (SNDFILE_MACHO_CURRENT_VERSION "${SNDFILE_MACHO_CURRENT_VERSION_MAJOR}.${SNDFILE_ABI_VERSION_PATCH}.0") - set (SNDFILE_MACHO_COMPATIBILITY_VERSION "${SNDFILE_MACHO_CURRENT_VERSION_MAJOR}.0.0") - -endmacro (SETUP_ABI_VERSIONS) diff --git a/Engine/lib/libsndfile/cmake/SndFileChecks.cmake b/Engine/lib/libsndfile/cmake/SndFileChecks.cmake deleted file mode 100644 index 2ad8ccde0..000000000 --- a/Engine/lib/libsndfile/cmake/SndFileChecks.cmake +++ /dev/null @@ -1,256 +0,0 @@ -include (CheckFunctionExists) -include (CheckIncludeFile) -include (CheckLibraryExists) -include (CheckSymbolExists) -include (CheckTypeSize) -include (TestBigEndian) - -include (TestInline) -include (ClipMode) -include (TestLargeFiles) -include (CheckCPUArch) - -test_large_files (_LARGEFILES) - -if (LARGE_FILES_DEFINITIONS) - add_definitions(${LARGE_FILES_DEFINITIONS}) -endif () - -if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") - find_package (Sndio) -elseif (NOT WIN32) - find_package (ALSA) -endif () - -if (VCPKG_TOOLCHAIN AND (NOT CMAKE_VERSION VERSION_LESS 3.15)) - set (CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) -endif () - -if (CMAKE_FIND_PACKAGE_PREFER_CONFIG) - find_package (Ogg 1.3 CONFIG) - find_package (Vorbis CONFIG COMPONENTS Enc) - find_package (FLAC CONFIG) - find_package (Opus CONFIG) - - include (FindPackageHandleStandardArgs) - find_package_handle_standard_args (Ogg CONFIG_MODE) - find_package_handle_standard_args (Vorbis CONFIG_MODE) - find_package_handle_standard_args (FLAC CONFIG_MODE) - find_package_handle_standard_args (Opus CONFIG_MODE) -else () - find_package (Ogg 1.3) - find_package (Vorbis COMPONENTS Enc) - find_package (FLAC) - find_package (Opus) -endif () -if (Vorbis_FOUND AND FLAC_FOUND AND Opus_FOUND) - set (HAVE_EXTERNAL_XIPH_LIBS 1) -else () - set (HAVE_EXTERNAL_XIPH_LIBS 0) -endif () - -find_package (mp3lame) -find_package (mpg123 1.25.10) -if (TARGET mp3lame::mp3lame AND (TARGET MPG123::libmpg123)) - set (HAVE_MPEG_LIBS 1) -else () - set (HAVE_MPEG_LIBS 0) -endif() - -find_package (Speex) -find_package (SQLite3) - -check_include_file (byteswap.h HAVE_BYTESWAP_H) -check_include_file (dlfcn.h HAVE_DLFCN_H) -check_include_file (direct.h HAVE_DIRECT_H) -check_include_file (endian.h HAVE_ENDIAN_H) -check_include_file (inttypes.h HAVE_INTTYPES_H) -check_include_file (io.h HAVE_IO_H) -check_include_file (stdint.h HAVE_STDINT_H) -check_include_file (sys/time.h HAVE_SYS_TIME_H) -check_include_file (sys/types.h HAVE_SYS_TYPES_H) -check_include_file (unistd.h HAVE_UNISTD_H) -check_include_file (immintrin.h HAVE_IMMINTRIN_H) -check_include_file (stdbool.h HAVE_STDBOOL_H) - -check_cpu_arch_x86 (CPU_IS_X86) -check_cpu_arch_x64 (CPU_IS_X64) -if ((CPU_IS_X86 OR CPU_IS_X64) AND HAVE_IMMINTRIN_H) - set (HAVE_SSE2 1) -endif () - -# Never checked -# check_include_file (stdlib.h HAVE_STDLIB_H) -# check_include_file (string.h HAVE_STRING_H) -# check_include_file (strings.h HAVE_STRINGS_H) -# check_include_file (sys/stat.h HAVE_SYS_STAT_H) -# check_include_file (memory.h HAVE_MEMORY_H) - -if (BUILD_TESTING) - check_include_file (locale.h HAVE_LOCALE_H) - check_include_file (sys/wait.h HAVE_SYS_WAIT_H) -endif () - -check_type_size (int64_t SIZEOF_INT64_T) -check_type_size (long SIZEOF_LONG) -check_type_size (long\ long SIZEOF_LONG_LONG) -check_type_size (ssize_t SIZEOF_SSIZE_T) -check_type_size (wchar_t SIZEOF_WCHAR_T) - -# Never used -# check_type_size (loff_t SIZEOF_LOFF_T) -# check_type_size (offt64_t SIZEOF_OFF64_T) - -# Never checked -# check_type_size (size_t SIZEOF_SIZE_T) - -# Used in configre.ac -# check_type_size (double SIZEOF_DOUBLE) -# check_type_size (float SIZEOF_FLOAT) -# check_type_size (int SIZEOF_INT) -# check_type_size (short SIZEOF_SHORT) - -if (ENABLE_TESTING) - check_type_size (void* SIZEOF_VOIDP) -endif() - -if (NOT WIN32) - check_library_exists (m floor "" LIBM_REQUIRED) - if (LIBM_REQUIRED) - list (APPEND CMAKE_REQUIRED_LIBRARIES m) - endif () -endif () - -check_library_exists (sqlite3 sqlite3_close "" HAVE_SQLITE3) - -check_function_exists (fstat HAVE_FSTAT) -check_function_exists (fstat64 HAVE_FSTAT64) -check_function_exists (gettimeofday HAVE_GETTIMEOFDAY) -check_function_exists (gmtime HAVE_GMTIME) -check_function_exists (gmtime_r HAVE_GMTIME_R) -check_function_exists (localtime HAVE_LOCALTIME) -check_function_exists (localtime_r HAVE_LOCALTIME_R) -check_function_exists (lseek HAVE_LSEEK) -check_function_exists (open HAVE_OPEN) -check_function_exists (read HAVE_READ) -check_function_exists (write HAVE_WRITE) -check_function_exists (lrint HAVE_LRINT) -check_function_exists (lrintf HAVE_LRINTF) - -if (NOT WIN32) - check_function_exists (ftruncate HAVE_FTRUNCATE) - check_function_exists (fsync HAVE_FSYNC) -endif () - -if (BUILD_TESTING) - check_function_exists (pipe HAVE_PIPE) - check_function_exists (setlocale HAVE_SETLOCALE) - check_function_exists (waitpid HAVE_WAITPID) -endif () - -# Never checked -# check_function_exists (calloc HAVE_CALLOC) -# check_function_exists (free HAVE_FREE) -# check_function_exists (getpagesize HAVE_GETPAGESIZE) -# check_function_exists (malloc HAVE_MALLOC) -# check_function_exists (realloc HAVE_REALLOC) -# check_function_exists (snprintf HAVE_SNPRINTF) -# check_function_exists (vsnprintf HAVE_VSNPRINTF) -# check_function_exists (floor HAVE_FLOOR) -# check_function_exists (fmod HAVE_FMOD) - -# Never used -# check_function_exists (mmap HAVE_MMAP) -# check_function_exists (ceil HAVE_CEIL) -# check_function_exists (lround HAVE_LROUND) -# check_function_exists (lseek64 HAVE_LSEEK64) - - -check_symbol_exists (S_IRGRP sys/stat.h HAVE_DECL_S_IRGRP) - -test_big_endian (WORDS_BIGENDIAN) -if (WORDS_BIGENDIAN) - set (CPU_IS_BIG_ENDIAN 1) -else () - set (CPU_IS_LITTLE_ENDIAN 1) -endif () - -if (WIN32) - set (OS_IS_WIN32 1) - set (USE_WINDOWS_API 1) - if (BUILD_SHARED_LIBS) - set (WIN32_TARGET_DLL 1) - endif () - if (MINGW) - add_definitions (-D__USE_MINGW_ANSI_STDIO=1) - endif () -endif () - -if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") - set (OS_IS_OPENBSD 1) -endif () - - -if (CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang")) - set (COMPILER_IS_GCC 1) -endif () - -test_inline () -clip_mode () - -if (MSVC) - add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) -endif (MSVC) - -if (DEFINED ENABLE_STATIC_RUNTIME) - if (MSVC) - if (ENABLE_STATIC_RUNTIME) - foreach (flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO - CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO - ) - if (${flag_var} MATCHES "/MD") - string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - endif () - endforeach (flag_var) - else () - foreach (flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO - CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO - ) - if (${flag_var} MATCHES "/MT") - string (REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}") - endif (${flag_var} MATCHES "/MT") - endforeach (flag_var) - endif ( ) - elseif (MINGW) - if (ENABLE_STATIC_RUNTIME) - if (CMAKE_C_COMPILER_ID STREQUAL GNU) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc") - set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s") - endif () - if (CMAKE_CXX_COMPILER_ID STREQUAL GNU) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") - set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++ -s") - endif () - if (CMAKE_C_COMPILER_ID STREQUAL Clang) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static") - set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static") - endif () - if (CMAKE_CXX_COMPILER_ID STREQUAL Clang) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") - set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static") - endif () - endif () - else () - message (AUTHOR_WARNING "ENABLE_STATIC_RUNTIME option is for MSVC or MinGW only.") - endif () -endif () - -if (BUILD_SHARED_LIBS) - find_package (PythonInterp REQUIRED) -endif() diff --git a/Engine/lib/libsndfile/cmake/SndFileConfig.cmake.in b/Engine/lib/libsndfile/cmake/SndFileConfig.cmake.in deleted file mode 100644 index f3923357b..000000000 --- a/Engine/lib/libsndfile/cmake/SndFileConfig.cmake.in +++ /dev/null @@ -1,46 +0,0 @@ -set(SndFile_VERSION @PROJECT_VERSION@) -set(SndFile_VERSION_MAJOR @PROJECT_VERSION_MAJOR@) -set(SndFile_VERSION_MINOR @PROJECT_VERSION_MINOR@) -set(SndFile_VERSION_PATCH @PROJECT_VERSION_PATCH@) - -set (SndFile_WITH_EXTERNAL_LIBS @SndFile_WITH_EXTERNAL_LIBS@) -set (SndFile_WITH_MPEG @SndFile_WITH_MPEG@) - -@PACKAGE_INIT@ - -include (CMakeFindDependencyMacro) - -if (NOT @BUILD_SHARED_LIBS@) - list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) -endif () - -if (SndFile_WITH_EXTERNAL_LIBS AND NOT @BUILD_SHARED_LIBS@) - find_dependency (Ogg 1.3) - find_dependency (Vorbis) - find_dependency (FLAC) - find_dependency (Opus) -endif () - -if (SndFile_WITH_MPEG AND NOT @BUILD_SHARED_LIBS@) - find_dependency (mp3lame) - find_dependency (mpg123) -endif () - -if (NOT @BUILD_SHARED_LIBS@) - list (REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) -endif () - -include (${CMAKE_CURRENT_LIST_DIR}/SndFileTargets.cmake) - -set_and_check (SndFile_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") -set (SNDFILE_INCLUDE_DIR ${SndFile_INCLUDE_DIR}) - -set (SndFile_LIBRARY SndFile::sndfile) -set (SNDFILE_LIBRARY SndFile::sndfile) -set (SndFile_LIBRARIES SndFile::sndfile) -set (SNDFILE_LIBRARIES SndFile::sndfile) - - -check_required_components(SndFile) - -set (SNDFILE_FOUND 1) diff --git a/Engine/lib/libsndfile/cmake/TestInline.c.in b/Engine/lib/libsndfile/cmake/TestInline.c.in deleted file mode 100644 index 2aed64334..000000000 --- a/Engine/lib/libsndfile/cmake/TestInline.c.in +++ /dev/null @@ -1,10 +0,0 @@ -static @INLINE_KEYWORD@ void test_inline(void) -{ - return; -} - -int main (void) -{ - test_inline (); - return 0; -} diff --git a/Engine/lib/libsndfile/cmake/TestInline.cmake b/Engine/lib/libsndfile/cmake/TestInline.cmake deleted file mode 100644 index ef15c0785..000000000 --- a/Engine/lib/libsndfile/cmake/TestInline.cmake +++ /dev/null @@ -1,54 +0,0 @@ -macro (TEST_INLINE) - if (NOT DEFINED INLINE_CODE) - message (STATUS "Checking for inline...") - set (INLINE_KEYWORD "inline") - configure_file (cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c) - try_compile (HAVE_INLINE "${CMAKE_CURRENT_BINARY_DIR}" - "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c") - if (HAVE_INLINE) - message (STATUS "Checking for inline... supported") - else () - message (STATUS "Checking for inline... not supported") - - message (STATUS "Checking for __inline...") - set (INLINE_KEYWORD "__inline") - configure_file (cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c) - try_compile (HAVE___INLINE "${CMAKE_CURRENT_BINARY_DIR}" - "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c") - if (HAVE___INLINE) - message (STATUS "Checking for __inline... supported") - else () - message (STATUS "Checking for __inline... not supported") - - message (STATUS "Checking for __inline__...") - set (INLINE_KEYWORD "__inline__") - configure_file (cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c) - try_compile (HAVE___INLINE "${CMAKE_CURRENT_BINARY_DIR}" - "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c") - if (HAVE___INLINE) - message (STATUS "Checking for __inline__... supported") - - message (STATUS "Checking for __inline__...") - set (INLINE_KEYWORD "__inline__") - configure_file (cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/cmake/TestInline.c) - try_compile (HAVE___INLINE__ "${CMAKE_CURRENT_BINARY_DIR}" - "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c") - else () - message (STATUS "Checking for __inline__... not supported") - set (INLINE_KEYWORD "") - endif () - - endif () - endif () - - if (HAVE_INLINE) - set (INLINE_CODE "/* #undef inline */" CACHE INTERNAL "") - elseif (HAVE___INLINE) - set (INLINE_CODE "#define inline __inline" CACHE INTERNAL "") - elseif (HAVE___INLINE__) - set (INLINE_CODE "#define inline __inline__" CACHE INTERNAL "") - else () - set (INLINE_CODE "#define inline " CACHE INTERNAL "") - endif () - endif () -endmacro (TEST_INLINE) diff --git a/Engine/lib/libsndfile/cmake/TestLargeFiles.cmake b/Engine/lib/libsndfile/cmake/TestLargeFiles.cmake deleted file mode 100644 index 075407b4a..000000000 --- a/Engine/lib/libsndfile/cmake/TestLargeFiles.cmake +++ /dev/null @@ -1,121 +0,0 @@ -include (CheckIncludeFile) -include (CheckTypeSize) -include (CMakePushCheckState) - -macro (TEST_LARGE_FILES VARIABLE) - -if (NOT DEFINED ${VARIABLE}) - - cmake_push_check_state() - - message (STATUS "") - message (STATUS "") - message (STATUS "Checking large files support...") - - if (WIN32) - set (${VARIABLE} 1 CACHE INTERNAL "Result of tests for large file support" FORCE) - message (STATUS "") - message (STATUS "Result of checking large files support: supported with WinAPI") - else () - - message (STATUS "") - check_include_file(sys/types.h HAVE_SYS_TYPES_H) - check_include_file(stdint.h HAVE_STDINT_H) - check_include_file(stddef.h HAVE_STDDEF_H) - message (STATUS "") - - message (STATUS "Checking size of off_t without any definitions:") - check_type_size (off_t SIZEOF_OFF_T) - message (STATUS "Checking of off_t without any definitions: ${SIZEOF_OFF_T}") - if (SIZEOF_OFF_T EQUAL 8) - set (LARGE_FILES_DEFINITIONS "" CACHE INTERNAL "64-bit off_t required definitions") - set (FILE64 TRUE) - else () - unset (HAVE_SIZEOF_OFF_T CACHE) - unset (SIZEOF_OFF_T CACHE) - unset (SIZEOF_OFF_T_CODE CACHE) - cmake_pop_check_state() - set (FILE64 FALSE) - endif () - - if (NOT FILE64) - set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_FILE_OFFSET_BITS=64) - message (STATUS "") - message (STATUS "Checking size of off_t with _FILE_OFFSET_BITS=64:") - check_type_size (off_t SIZEOF_OFF_T) - message (STATUS "Checking size of off_t with _FILE_OFFSET_BITS=64: ${SIZEOF_OFF_T}") - if (SIZEOF_OFF_T EQUAL 8) - set (_FILE_OFFSET_BITS 64 CACHE INTERNAL "") - set (_FILE_OFFSET_BITS_CODE "#define _FILE_OFFSET_BITS 64" CACHE INTERNAL "") - set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_FILE_OFFSET_BITS=64" CACHE INTERNAL "64-bit off_t required definitions") - set (FILE64 TRUE) - else () - set (_FILE_OFFSET_BITS_CODE "" CACHE INTERNAL "") - unset (HAVE_SIZEOF_OFF_T CACHE) - unset (SIZEOF_OFF_T CACHE) - unset (SIZEOF_OFF_T_CODE CACHE) - cmake_pop_check_state() - set (FILE64 FALSE) - endif () - endif () - - if (NOT FILE64) - set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_LARGE_FILES) - message (STATUS "") - message (STATUS "Checking size of off_t with _LARGE_FILES:") - check_type_size (off_t SIZEOF_OFF_T) - message (STATUS "Checking size of off_t with _LARGE_FILES: ${SIZEOF_OFF_T}") - if (SIZEOF_OFF_T EQUAL 8) - set (_LARGE_FILES 1 CACHE INTERNAL "") - set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_LARGE_FILES" CACHE INTERNAL "64-bit off_t required definitions") - set (FILE64 TRUE) - else () - unset (HAVE_SIZEOF_OFF_T CACHE) - unset (SIZEOF_OFF_T CACHE) - unset (SIZEOF_OFF_T_CODE CACHE) - cmake_pop_check_state() - set (FILE64 FALSE) - endif () - endif () - - if (NOT FILE64) - set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_LARGEFILE_SOURCE) - unset (HAVE_SIZEOF_OFF_T CACHE) - unset (SIZEOF_OFF_T CACHE) - unset (SIZEOF_OFF_T_CODE CACHE) - message (STATUS "") - message (STATUS "Checking size of off_t with _LARGEFILE_SOURCE:") - check_type_size (off_t SIZEOF_OFF_T) - message (STATUS "Checking size of off_t with _LARGEFILE_SOURCE: ${SIZEOF_OFF_T}") - if (SIZEOF_OFF_T EQUAL 8) - set (_LARGEFILE_SOURCE 1 CACHE INTERNAL "") - set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_LARGEFILE_SOURCE" CACHE INTERNAL "64-bit off_t required definitions") - set (FILE64 TRUE) - else () - cmake_pop_check_state() - set (FILE64 FALSE) - endif () - endif () - - message (STATUS "") - if (FILE64) - set (${VARIABLE} 1 CACHE INTERNAL "Result of tests for large file support" FORCE) - if (NOT SIZEOF_OFF_T_REQURED_DEFINITIONS) - message (STATUS "Result of checking large files support: supported") - else () - message (STATUS "Result of checking large files support: supported with ${LARGE_FILES_DEFINITIONS}") - message (STATUS "Add LARGE_FILES_DEFINITIONS to your compiler definitions or configure with _FILE_OFFSET_BITS,") - message (STATUS "_FILE_OFFSET_BITS_CODE, _LARGE_FILES and _LARGEFILE_SOURCE variables.") - endif () - else () - message ("Result of checking large files support: not supported") - set (${VARIABLE} 0 CACHE INTERNAL "Result of test for large file support" FORCE) - endif () - message ("") - message ("") - - endif () - -endif (NOT DEFINED ${VARIABLE}) - -endmacro (TEST_LARGE_FILES VARIABLE) diff --git a/Engine/lib/libsndfile/cmake/sqlite/FindSQLite3.cmake b/Engine/lib/libsndfile/cmake/sqlite/FindSQLite3.cmake deleted file mode 100644 index a0385caaa..000000000 --- a/Engine/lib/libsndfile/cmake/sqlite/FindSQLite3.cmake +++ /dev/null @@ -1,56 +0,0 @@ -# - Find SQLite3 -# Find the native SQLite3 includes and libraries -# -# SQLite3_INCLUDE_DIRS - where to find sqlite3.h, etc. -# SQLite3_LIBRARIES - List of libraries when using SQLite3. -# SQLite3_FOUND - True if SQLite3 found. - -if (SQLite3_INCLUDE_DIR) - # Already in cache, be silent - set (SQLite3_FIND_QUIETLY TRUE) -endif () - -find_package (PkgConfig QUIET) -pkg_check_modules (PC_SQLite3 QUIET sqlite3) - -set (SQLite3_VERSION ${PC_SQLite3_VERSION}) - -find_path (SQLite3_INCLUDE_DIR sqlite3.h - HINTS - ${PC_SQLite3_INCLUDEDIR} - ${PC_SQLite3_INCLUDE_DIRS} - ${SQLite3_ROOT} - ) - -find_library (SQLite3_LIBRARY - NAMES - sqlite3 - HINTS - ${PC_SQLite3_LIBDIR} - ${PC_SQLite3_LIBRARY_DIRS} - ${SQLite3_ROOT} - ) - -include (FindPackageHandleStandardArgs) - -find_package_handle_standard_args (SQLite3 - REQUIRED_VARS - SQLite3_LIBRARY - SQLite3_INCLUDE_DIR - VERSION_VAR - SQLite3_VERSION - ) - -if (SQLite3_FOUND) - set (SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR}) - set (SQLite3_LIBRARIES ${SQLite3_LIBRARY}) - if (NOT TARGET SQLite::SQLite3) - add_library (SQLite::SQLite3 UNKNOWN IMPORTED) - set_target_properties (SQLite::SQLite3 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIRS}" - IMPORTED_LOCATION "${SQLite3_LIBRARIES}" - ) - endif () -endif () - -mark_as_advanced (SQLite3_INCLUDE_DIR SQLite3_LIBRARY) diff --git a/Engine/lib/libsndfile/configure.ac b/Engine/lib/libsndfile/configure.ac deleted file mode 100644 index dc0d5e1d7..000000000 --- a/Engine/lib/libsndfile/configure.ac +++ /dev/null @@ -1,761 +0,0 @@ -dnl Copyright (C) 1999-2022 Erik de Castro Lopo . - -dnl Require autoconf version >= 2.69 -AC_PREREQ([2.69]) - -AC_INIT([libsndfile],[1.2.2],[sndfile@mega-nerd.com], - [libsndfile],[http://libsndfile.github.io/libsndfile/]) - -dnl Check whether we want to set defaults for CFLAGS, CXXFLAGS, CPPFLAGS and LDFLAGS -AC_MSG_CHECKING([whether configure should try to set CFLAGS/CXXFLAGS/CPPFLAGS/LDFLAGS]) -AS_IF([test "x${CFLAGS+set}" = "xset" || test "x${CXXFLAGS+set}" = "xset" || test "x${CPPFLAGS+set}" = "xset" || test "x${LDFLAGS+set}" = "xset"], [ - enable_flags_setting=no - : ${CFLAGS=""} - : ${CXXFLAGS=""} - ], [ - enable_flags_setting=yes - dnl Set to empty flags so AC_PROG_CC and - dnl AC_PROG_CXX do not add -g -O2 - CFLAGS="" - CXXFLAGS="" - ]) -AC_MSG_RESULT([${enable_flags_setting}]) - -dnl Put config stuff in 'build-aux'. -AC_CONFIG_AUX_DIR([build-aux]) - -AC_CONFIG_SRCDIR([src/sndfile.c]) -AC_CANONICAL_HOST - -AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_HEADERS([src/config.h]) - -AM_INIT_AUTOMAKE([1.14 foreign dist-xz no-dist-gzip serial-tests subdir-objects]) -AM_SILENT_RULES([yes]) - -dnl ==================================================================================== - -AC_PROG_CC -AC_PROG_CC_C99 - -AS_IF([test "x$ac_cv_prog_cc_c99" = "xno"], [ - AC_MSG_ERROR([libsndfile requires a C99 capable compiler!]) - ]) - -AC_USE_SYSTEM_EXTENSIONS -AC_PROG_CXX - -AC_LANG([C]) -AX_COMPILER_VENDOR -AX_COMPILER_VERSION - -AC_LANG_PUSH([C++]) -AX_COMPILER_VENDOR -AX_COMPILER_VERSION -AC_LANG_POP([C++]) - -AC_PROG_SED -AM_PROG_AR - -LT_INIT([disable-static win32-dll]) -LT_PROG_RC - -AC_PROG_INSTALL -AC_PROG_LN_S - -AM_PATH_PYTHON - -AC_CHECK_PROG([HAVE_AUTOGEN], [autogen], [yes], [no]) -AC_CHECK_PROG([HAVE_WINE], [wine], [yes], [no]) -AC_CHECK_PROG([HAVE_XCODE_SELECT], [xcode-select], [yes], [no]) - -dnl ------------------------------------------------------------------------------------ -dnl Rules for library version information: -dnl -dnl 1. Start with version information of `0:0:0' for each libtool library. -dnl 2. Update the version information only immediately before a public release of -dnl your software. More frequent updates are unnecessary, and only guarantee -dnl that the current interface number gets larger faster. -dnl 3. If the library source code has changed at all since the last update, then -dnl increment revision (`c:r:a' becomes `c:r+1:a'). -dnl 4. If any interfaces have been added, removed, or changed since the last update, -dnl increment current, and set revision to 0. -dnl 5. If any interfaces have been added since the last public release, then increment -dnl age. -dnl 6. If any interfaces have been removed since the last public release, then set age -dnl to 0. - -dnl This is libtool version of library, we add it to `--version-info` property. - -m4_define([lt_current], [1]) -m4_define([lt_revision], [37]) -m4_define([lt_age], [0]) - -dnl This is ABI version for linker scripts, CMake uses the same format for -dnl VERSION property of shared library. -dnl The formula is: c:r:a -> c-a:a:r - -m4_define([abi_version_major], [m4_eval(lt_current - lt_age)]) -m4_define([abi_version_minor], [lt_age]) -m4_define([abi_version_patch], [lt_revision]) - -dnl ------------------------------------------------------------------------------------ - -AC_CHECK_HEADERS([endian.h]) -AC_CHECK_HEADERS([byteswap.h]) -AC_CHECK_HEADERS([locale.h]) -AC_CHECK_HEADERS([sys/time.h]) -AC_CHECK_HEADERS([immintrin.h]) -AC_CHECK_HEADERS([stdbool.h]) - -AC_HEADER_SYS_WAIT - -AC_CHECK_DECLS([S_IRGRP]) -AS_IF([test "x$ac_cv_have_decl_S_IRGRP" = "xyes"], [ - AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP], [1], [Set to 1 if S_IRGRP is defined.]) - ], [ - AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP], [0], [Set to 0 if S_IRGRP is not defined.]) - ]) - -AM_CONDITIONAL([LINUX_MINGW_CROSS_TEST], - [test "x${build_os}:${host_os}:${HAVE_WINE}" = "xlinux-gnu:mingw32msvc:yes"]) - -dnl ==================================================================================== -dnl Couple of initializations here. Fill in real values later. - -SHLIB_VERSION_ARG="" - -dnl ==================================================================================== -dnl Finished checking, handle options. - -AC_ARG_ENABLE(experimental, - AS_HELP_STRING([--enable-experimental], [enable experimental code])) - -AS_IF([test "x$enable_experimental" = "xyes"], [ - EXPERIMENTAL_CODE=1 - ], [ - EXPERIMENTAL_CODE=0 - ]) -AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_CODE], [${EXPERIMENTAL_CODE}], [Set to 1 to enable experimental code.]) - -AC_ARG_ENABLE([werror], - [AS_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles])]) - -AC_ARG_ENABLE([cpu-clip], - [AS_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper])]) - -AC_ARG_ENABLE([bow-docs], - [AS_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs])]) - -AC_ARG_ENABLE([sqlite], - [AS_HELP_STRING([--disable-sqlite], [disable use of sqlite])]) - -AC_ARG_ENABLE([alsa], - [AS_HELP_STRING([--disable-alsa], [disable ALSA support (default=autodetect)])], [], [enable_alsa=auto]) - -AC_ARG_ENABLE([external-libs], - [AS_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]])]) - -AC_ARG_ENABLE([mpeg], - [AS_HELP_STRING([--disable-mpeg], [disable use of LAME/MPG123 for MPEG (MP3) [[defaults=no]]])]) - -AC_ARG_ENABLE(octave, - [AS_HELP_STRING([--enable-octave], [enable building of GNU Octave module])]) - -AC_ARG_ENABLE([full-suite], - [AS_HELP_STRING([--disable-full-suite], [disable building and installing programs, documentation, only build library [[default=no]]])]) -AM_CONDITIONAL([FULL_SUITE], [test "x$enable_full_suite" != "xno"]) - -AC_ARG_ENABLE([test-coverage], - [AS_HELP_STRING([--enable-test-coverage], [enable test coverage])]) -AM_CONDITIONAL([ENABLE_TEST_COVERAGE], [test "x$enable_test_coverage" = "xyes"]) - -AC_ARG_ENABLE([ossfuzzers], - [AS_HELP_STRING([--enable-ossfuzzers], [Whether to generate the fuzzers for OSS-Fuzz])]) -AM_CONDITIONAL([USE_OSSFUZZERS], [test "x$enable_ossfuzzers" = "xyes"]) - -AC_SUBST([LIB_FUZZING_ENGINE]) -AM_CONDITIONAL([USE_OSSFUZZ_FLAG], [test "x$LIB_FUZZING_ENGINE" = "x-fsanitize=fuzzer"]) -AM_CONDITIONAL([USE_OSSFUZZ_STATIC], [test -f "$LIB_FUZZING_ENGINE"]) - -dnl ==================================================================================== -dnl Check types and their sizes. - -AC_CHECK_SIZEOF([wchar_t], [4]) -AC_CHECK_SIZEOF([short], [2]) -AC_CHECK_SIZEOF([int], [4]) -AC_CHECK_SIZEOF([long], [4]) -AC_CHECK_SIZEOF([float], [4]) -AC_CHECK_SIZEOF([double], [4]) -AC_CHECK_SIZEOF([void*], [8]) -AC_CHECK_SIZEOF([size_t], [4]) -AC_CHECK_SIZEOF([int64_t], [8]) -AC_CHECK_SIZEOF([long long], [8]) - -dnl Check for common 64 bit file offset types. -AC_CHECK_SIZEOF([off_t], [1]) - -AS_IF([test "x$enable_largefile:$ac_cv_sizeof_off_t" = "xno:8"], [ - AC_MSG_ERROR(["Error : Cannot disable large file support because sizeof (off_t) == 8."]) - ]) - -AS_CASE([$host_os], - [mingw32*], [ - AC_DEFINE([__USE_MINGW_ANSI_STDIO], [1], [Set to 1 to use C99 printf/snprintf in MinGW.]) - ], - - [ - AS_IF([test "x$ac_cv_sizeof_off_t" = "x8"], [ - dnl If sizeof (off_t) is 8, no further checking is needed. - ], [ - dnl Save the old sizeof (off_t) value and then unset it to see if it - dnl changes when Large File Support is enabled. - pre_largefile_sizeof_off_t=$ac_cv_sizeof_off_t - unset ac_cv_sizeof_off_t - - AC_SYS_LARGEFILE - AS_IF([test "x$ac_cv_sys_largefile_CFLAGS" = "xno"], [ - ac_cv_sys_largefile_CFLAGS="" - ]) - AS_IF([test "x$ac_cv_sys_largefile_LDFLAGS" = "xno"], [ - ac_cv_sys_largefile_LDFLAGS="" - ]) - AS_IF([test "x$ac_cv_sys_largefile_LIBS" = "xno"], [ - ac_cv_sys_largefile_LIBS="" - ]) - - AC_CHECK_SIZEOF(off_t,1) - ]) - ]) - -AC_TYPE_SSIZE_T - -dnl ==================================================================================== -dnl Determine endian-ness of host processor. - -AC_C_BIGENDIAN([ - dnl big-endian - ac_cv_c_big_endian=1 - ac_cv_c_little_endian=0 - ], [ - dnl little-endian - ac_cv_c_big_endian=0 - ac_cv_c_little_endian=1 - ]) - -AC_DEFINE_UNQUOTED([CPU_IS_BIG_ENDIAN], [${ac_cv_c_big_endian}], [Host processor is big endian.]) -AC_DEFINE_UNQUOTED([CPU_IS_LITTLE_ENDIAN], [${ac_cv_c_little_endian}], [Host processor is little endian.]) - -dnl ==================================================================================== -dnl Check for functions. - -AC_CHECK_FUNCS([malloc calloc realloc free]) -AC_CHECK_FUNCS([open read write lseek lseek64]) -AC_CHECK_FUNCS([fstat fstat64 ftruncate fsync]) -AC_CHECK_FUNCS([snprintf vsnprintf]) -AC_CHECK_FUNCS([gmtime gmtime_r localtime localtime_r gettimeofday]) -AC_CHECK_FUNCS([mmap getpagesize]) -AC_CHECK_FUNCS([setlocale]) -AC_CHECK_FUNCS([pipe waitpid]) - -AC_SEARCH_LIBS([floor], [m], [], [ - AC_MSG_ERROR([unable to find the floor() function!]) - ]) -AC_CHECK_FUNCS([floor ceil fmod lrint lrintf]) - -dnl ==================================================================================== -dnl Check for requirements for building plugins for other languages/enviroments. - -dnl Octave maths environment http://www.octave.org/ -AS_IF([test "x$cross_compiling" = "xno"], [ - AS_IF([test "x$enable_octave" = "xno"], [ - AM_CONDITIONAL(BUILD_OCTAVE_MOD, false) - ], [ - AC_OCTAVE_BUILD - ]) - ], [ - AM_CONDITIONAL(BUILD_OCTAVE_MOD, false) - ]) - -dnl ==================================================================================== -dnl Check for Ogg, Vorbis and FLAC. - -HAVE_EXTERNAL_XIPH_LIBS=0 -EXTERNAL_XIPH_CFLAGS="" -EXTERNAL_XIPH_LIBS="" -EXTERNAL_XIPH_REQUIRE="" - -dnl Check for pkg-config outside the if statement. -PKG_PROG_PKG_CONFIG -AX_REQUIRE_DEFINED([PKG_INSTALLDIR]) -PKG_INSTALLDIR - -AS_IF([test -n "$PKG_CONFIG"], [ - AS_IF([test "x$enable_external_libs" = "xno"], [ - AC_MSG_WARN([[*** External libs (FLAC, Ogg, Vorbis) disabled. ***]]) - ], [ - PKG_CHECK_MOD_VERSION(FLAC, flac >= 1.3.1, ac_cv_flac=yes, ac_cv_flac=no) - - dnl Make sure the FLAC_CFLAGS value is sane. - FLAC_CFLAGS=`echo $FLAC_CFLAGS | $SED "s|include/FLAC|include|"` - - PKG_CHECK_MOD_VERSION(OGG, ogg >= 1.3.0, ac_cv_ogg=yes, ac_cv_ogg=no) - - AS_IF([test "x$enable_experimental" = "xyes"], [ - PKG_CHECK_MOD_VERSION(SPEEX, speex >= 1.2, ac_cv_speex=yes, ac_cv_speex=no) - ], [ - SPEEX_CFLAGS="" - SPEEX_LIBS="" - ]) - - dnl Vorbis versions earlier than 1.2.3 have bugs that cause the libsndfile - dnl test suite to fail on MIPS, PowerPC and others. - dnl See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549899 - PKG_CHECK_MOD_VERSION(VORBIS, vorbis >= 1.2.3, ac_cv_vorbis=yes, ac_cv_vorbis=no) - PKG_CHECK_MOD_VERSION(VORBISENC, vorbisenc >= 1.2.3, ac_cv_vorbisenc=yes, ac_cv_vorbisenc=no) - - PKG_CHECK_MOD_VERSION(OPUS, opus >= 1.1, ac_cv_opus=yes, ac_cv_opus=no) - enable_external_libs=yes - ]) - - AS_IF([test "x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc$ac_cv_opus" = "xyesyesyesyesyes"], [ - HAVE_EXTERNAL_XIPH_LIBS=1 - enable_external_libs=yes - - EXTERNAL_XIPH_CFLAGS="$FLAC_CFLAGS $VORBIS_CFLAGS $VORBISENC_CFLAGS $SPEEX_CFLAGS $OPUS_CFLAGS $OGG_CFLAGS " - EXTERNAL_XIPH_LIBS="$FLAC_LIBS $VORBIS_LIBS $VORBISENC_LIBS $SPEEX_LIBS $OPUS_LIBS $OGG_LIBS " - EXTERNAL_XIPH_REQUIRE="flac ogg vorbis vorbisenc opus" - - if test x$ac_cv_speex = "xyes" ; then - EXTERNAL_XIPH_REQUIRE="$EXTERNAL_XIPH_REQUIRE speex" - fi - ], [ - AS_ECHO([""]) - AC_MSG_WARN([[*** One or more of the external libraries (ie libflac, libogg,]]) - AC_MSG_WARN([[*** libvorbis and libopus) is either missing (possibly only the development]]) - AC_MSG_WARN([[*** headers) or is of an unsupported version.]]) - AC_MSG_WARN([[***]]) - AC_MSG_WARN([[*** Unfortunately, for ease of maintenance, the external libs]]) - AC_MSG_WARN([[*** are an all or nothing affair.]]) - AS_ECHO([""]) - enable_external_libs=no - ]) - ]) - -AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_XIPH_LIBS], [$HAVE_EXTERNAL_XIPH_LIBS], [Will be set to 1 if flac, ogg, vorbis, and opus are available.]) - -dnl ==================================================================================== -dnl Check for MPEG libraris liblame - -ac_cv_lame="no" -ac_cv_mpg123="no" -HAVE_MPEG=0 -EXTERNAL_MPEG_REQUIRE="" -EXTERNAL_MPEG_LIBS="" - -AS_IF([test -n "$PKG_CONFIG"], [ - AS_IF([test "x$enable_mpeg" = "xno"], [ - AC_MSG_WARN([[*** MPEG (Lame/MPG123) disabled. ***]]) - ], [ - AC_CHECK_HEADER(lame/lame.h, - lame_header_found="yes", - lame_header_found="no") - AC_SEARCH_LIBS(lame_set_VBR_q, [lame mp3lame], [lame_lib_found="yes"], [lame_lib_found="no"]) - AS_IF([test "x$lame_lib_found$lame_header_found" = "xyesyes"], [ - ac_cv_lame="yes" - ], [ - AC_MSG_WARN([["MPEG support selected but external Lame library cannot be found.]]) - ]) - - PKG_CHECK_MOD_VERSION([MPG123], [libmpg123 >= 1.25.10], [ - ac_cv_mpg123="yes" - ], [ - AC_MSG_WARN([["MPEG support selected but external MPG123 library cannot be found.]]) - ]) - - AS_IF([test "x$ac_cv_lame$ac_cv_mpg123" = "xyesyes"], [ - enable_mpeg="yes" - HAVE_MPEG=1 - EXTERNAL_MPEG_REQUIRE="libmpg123" - EXTERNAL_MPEG_LIBS="-lmp3lame" - MPEG_CFLAGS="$MPG123_CFLAGS" - MPEG_LIBS="$MPG123_LIBS" - ], [ - enable_mpeg="no" - AS_ECHO([""]) - AC_MSG_WARN([[*** MPEG support disabled.]]) - AS_ECHO([""]) - ]) - ]) - ]) - -AC_DEFINE_UNQUOTED([HAVE_MPEG], [$HAVE_MPEG], [Will be set to 1 if lame, mpg123 mpeg support is available.]) - -dnl ==================================================================================== -dnl Check for libsqlite3 (only used in regtest). - -ac_cv_sqlite3=0 -AS_IF([test "x$enable_sqlite" != "xno"], [ - PKG_CHECK_MOD_VERSION([SQLITE3], [sqlite3 >= 3.2], [ac_cv_sqlite3=1], [ac_cv_sqlite3=0]) - ]) - -AC_DEFINE_UNQUOTED([HAVE_SQLITE3], [${ac_cv_sqlite3}], [Set to 1 if you have libsqlite3.]) -AM_CONDITIONAL([HAVE_SQLITE3], [test "x$ac_cv_sqlite3" = "x1"]) - -dnl ==================================================================================== -dnl Determine if the processor can do clipping on float to int conversions. - -AS_IF([test "x$enable_cpu_clip" != "xno"], [ - MN_C_CLIP_MODE - ], [ - AS_ECHO(["checking processor clipping capabilities... disabled"]) - ac_cv_c_clip_positive=0 - ac_cv_c_clip_negative=0 - ]) - -AC_DEFINE_UNQUOTED([CPU_CLIPS_POSITIVE], [${ac_cv_c_clip_positive}], - [Host processor clips on positive float to int conversion.]) -AC_DEFINE_UNQUOTED([CPU_CLIPS_NEGATIVE], [${ac_cv_c_clip_negative}], - [Host processor clips on negative float to int conversion.]) - -dnl ==================================================================================== -dnl Host OS specific stuff. - -OS_SPECIFIC_CFLAGS="" -OS_SPECIFIC_LINKS="" -os_is_win32=0 -os_is_openbsd=0 -use_windows_api=0 -AS_CASE([$host_os], - [darwin* | rhapsody*], [ - AS_IF([test "x$HAVE_XCODE_SELECT" = "xyes"], [ - developer_path=`xcode-select --print-path` - ], [ - developer_path="/Developer" - ]) - OS_SPECIFIC_LINKS="-framework CoreAudio -framework AudioToolbox -framework CoreFoundation"], - [mingw*], [ - os_is_win32=1 - use_windows_api=1 - OS_SPECIFIC_LINKS="-lwinmm"], - [openbsd*], [ - os_is_openbsd=1 - ]) - -AC_DEFINE_UNQUOTED([OS_IS_WIN32], [${os_is_win32}], [Set to 1 if compiling for Win32]) -AC_DEFINE_UNQUOTED([OS_IS_OPENBSD], [${os_is_openbsd}], [Set to 1 if compiling for OpenBSD]) -AC_DEFINE_UNQUOTED([USE_WINDOWS_API], [${use_windows_api}], [Set to 1 to use the native windows API]) -AM_CONDITIONAL(USE_WIN_VERSION_FILE, test ${use_windows_api} -eq 1) - -dnl ==================================================================================== -dnl Check for ALSA. - -AS_IF([test "x$enable_alsa" != "xno"], [ - PKG_CHECK_MODULES([ALSA], [alsa], [ - dnl actually test whether ALSA really works, in - dnl order to dodge wrong cross-compilation pickups - save_CFLAGS="${CFLAGS}" - save_LIBS="${LIBS}" - CFLAGS="${CFLAGS} ${ALSA_CFLAGS}" - LIBS="${LIBS} ${ALSA_LIBS}" - AC_CHECK_HEADERS([alsa/asoundlib.h]) - AS_IF([test "x$ac_cv_header_alsa_asoundlib_h" = "xyes"], [ - dnl ALSA definitely works - AC_DEFINE([HAVE_ALSA], [1], [Set to 1 if you have alsa]) - alsa_works="yes" - ], [ - dnl picked up wrong ALSA - alsa_works="no" - - dnl reset flags - ALSA_CFLAGS="" - ALSA_LIBS="" - ]) - CFLAGS="${save_CFLAGS}" - LIBS="${save_LIBS}" - ], [ - dnl could not find ALSA - alsa_works="no" - ]) - - AS_IF([test "x$alsa_works" = "xno"], [ - AS_IF([test "x$enable_alsa" = "xyes"], [ - dnl explicitly passed --enable-alsa, hence error out loud and clearly - AC_MSG_ERROR([You explicitly requested alsa support, but alsa could not be found!]) - ], [ - dnl did not explicitly pass --enable-alsa, relying on default automagic on - enable_alsa="no (auto)" - ]) - ]) - ]) - -dnl ==================================================================================== -dnl Check for OpenBSD's sndio. - -SNDIO_LIBS="" -HAVE_SNDIO_H=0 -AS_CASE([$host_os], - [openbsd*], [ - AC_CHECK_HEADERS(sndio.h) - AS_IF([test "x$ac_cv_header_sndio_h" = "xyes"], [ - SNDIO_LIBS="-lsndio" - HAVE_SNDIO_H=1 - ]) - ]) - -AC_DEFINE_UNQUOTED([HAVE_SNDIO_H], [${HAVE_SNDIO_H}], [Set to 1 if is available.]) - -dnl ==================================================================================== -dnl Test for sanity when cross-compiling. - -AS_IF([test "x$ac_cv_sizeof_short" != "x2"], [ - AC_MSG_WARN([[******************************************************************]]) - AC_MSG_WARN([[*** sizeof (short) != 2. ]]) - AC_MSG_WARN([[******************************************************************]]) - ]) - -AS_IF([test "x$ac_cv_sizeof_int" != "x4"], [ - AC_MSG_WARN([[******************************************************************]]) - AC_MSG_WARN([[*** sizeof (int) != 4 ]]) - AC_MSG_WARN([[******************************************************************]]) - ]) - -AS_IF([test "x$ac_cv_sizeof_float" != "x4"], [ - AC_MSG_WARN([[******************************************************************]]) - AC_MSG_WARN([[*** sizeof (float) != 4. ]]) - AC_MSG_WARN([[******************************************************************]]) - ]) - -AS_IF([test "x$ac_cv_sizeof_double" != "x8"], [ - AC_MSG_WARN([[******************************************************************]]) - AC_MSG_WARN([[*** sizeof (double) != 8. ]]) - AC_MSG_WARN([[******************************************************************]]) - ]) - -AS_IF([test "x$ac_cv_prog_HAVE_AUTOGEN" = "xno"], [ - AC_MSG_WARN([[Touching files in directory tests/.]]) - touch tests/*.c tests/*.h - ]) - -dnl ==================================================================================== -dnl Settings for the HTML documentation. - -AS_IF([test "x$enable_bow_docs" = "xyes"], [ - HTML_BGCOLOUR="white" - HTML_FGCOLOUR="black" - ], [ - HTML_BGCOLOUR="black" - HTML_FGCOLOUR="white" - ]) - -dnl ==================================================================================== -dnl Now use the information from the checking stage. - -win32_target_dll=0 -COMPILER_IS_GCC=0 - -AS_IF([test "x$enable_flags_setting" = "xyes"], [ - AX_APPEND_COMPILE_FLAGS([-O2 -pipe], [CFLAGS]) - - AC_LANG_PUSH([C++]) - AX_APPEND_COMPILE_FLAGS([-O2 -pipe], [CXXFLAGS]) - AC_LANG_POP([C++]) - - AS_CASE([${host_os}], - [darwin*], [ - ldflags_test="-Wl,-dead_strip_dylibs"], - [linux*], [ - ldflags_test="-Wl,-O1 -Wl,--as-needed -Wl,--no-undefined -Wl,--gc-sections"] - ) - AX_APPEND_LINK_FLAGS([${ldflags_test}], [LDFLAGS]) - ]) - -AS_IF([test "x$enable_werror" = "xyes"], [ - AX_APPEND_COMPILE_FLAGS([-Werror], [CFLAGS]) - - AC_LANG_PUSH([C++]) - AX_APPEND_COMPILE_FLAGS([-Werror], [CXXFLAGS]) - AC_LANG_POP([C++]) - ]) - -common_flags="-Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wundef -Wuninitialized -Winit-self" -common_cflags="${common_flags}" -dnl Clang doesn't know about -Wno-format-truncation -dnl and would spew tons of warnings otherwise. -AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [ - common_cflags+=" -Wno-format-truncation" - ]) -common_cxxflags="${common_flags}" -AS_IF([test "x$ax_cv_cxx_compiler_vendor" = "xgnu"], [ - common_cxxflags+=" -Wno-format-truncation" - ]) - -AX_APPEND_COMPILE_FLAGS([${common_cflags} -Wvla -Wbad-function-cast -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return], [CFLAGS]) - -AC_LANG_PUSH([C++]) -AX_APPEND_COMPILE_FLAGS([${common_cxxflags} -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo], [CXXFLAGS]) -AC_LANG_POP([C++]) - -AS_IF([test "x$enable_test_coverage" = "xyes"], [ - AX_APPEND_COMPILE_FLAGS([-coverage], [CFLAGS]) - ]) - -dnl some distributions (such as Gentoo) have _FORTIFY_SOURCE always -dnl enabled. We test for this situation in order to prevent polluting -dnl the console with messages of macro redefinitions. -AX_ADD_FORTIFY_SOURCE - -AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [ - dnl OS specific tweaks. - AS_CASE([$host_os], - [darwin* | rhapsody*], [ - dnl Disable -Wall, -pedantic and -Wshadow for Apple Darwin/Rhapsody. - dnl System headers on these systems are broken. - temp_CFLAGS=`echo $CFLAGS | $SED "s/-Wall -pedantic//" | $SED "s/-Wshadow//" | $SED "s/-Waggregate-return//"` - CFLAGS=$temp_CFLAGS - SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(top_srcdir)/src/Symbols.darwin"], - [mingw*], [ - SHLIB_VERSION_ARG="-Wc,-static-libgcc -Wl,\$(top_srcdir)/src/libsndfile-1.def" - win32_target_dll=1 - AS_IF([test "x$enable_shared" = "xno"], [ - win32_target_dll=0 - ]) - AX_APPEND_COMPILE_FLAGS([-mstackrealign], [CFLAGS]) - ], - [os2*], [ - SHLIB_VERSION_ARG="-Wl,-export-symbols \$(top_srcdir)/src/Symbols.os2" - ]) - - COMPILER_IS_GCC=1 - ]) - -AS_CASE([$host_os], [linux*|kfreebsd*-gnu*|gnu*], [SHLIB_VERSION_ARG="-Wl,--version-script=\$(top_srcdir)/src/Symbols.gnu-binutils"]) - -AC_DEFINE_UNQUOTED([WIN32_TARGET_DLL], [${win32_target_dll}], [Set to 1 if windows DLL is being built.]) -AC_DEFINE_UNQUOTED([COMPILER_IS_GCC], [${COMPILER_IS_GCC}], [Set to 1 if the compile is GNU GCC.]) - -CFLAGS="$CFLAGS $OS_SPECIFIC_CFLAGS" - -AS_IF([test "x$CFLAGS" = "x"], [ - AC_MSG_ERROR(["Error in configure script. CFLAGS has been screwed up."]) - ]) - -HOST_TRIPLET="${host_cpu}-${host_vendor}-${host_os}" - -AC_DEFINE_UNQUOTED([HOST_TRIPLET], [${HOST_TRIPLET}], [The host triplet of the compiled binary.]) - -AS_IF([test "$HOST_TRIPLET" = "x86_64-w64-mingw32"], [ - OS_SPECIFIC_LINKS=" -static-libgcc $OS_SPECIFIC_LINKS" - ]) - -WIN_RC_VERSION=`echo $PACKAGE_VERSION | $SED -e "s/pre.*//" -e "s/beta.*//" -e "s/\./,/g"` - - -AS_IF([test "x$enable_static" = "xno"], [ - SRC_BINDIR=src/.libs/ - TEST_BINDIR=tests/.libs/ - ], [ - SRC_BINDIR=src/ - TEST_BINDIR=tests/ - ]) - -dnl ------------------------------------------------------------------------------- - -AC_SUBST(HOST_TRIPLET) - -AC_SUBST(HTML_BGCOLOUR) -AC_SUBST(HTML_FGCOLOUR) - -AC_SUBST(SHLIB_VERSION_ARG) -AC_SUBST([SHARED_VERSION_INFO], [lt_current:lt_revision:lt_age]) -AC_SUBST([ABI_VERSION], [abi_version_major.abi_version_minor.abi_version_patch]) -AC_SUBST(CLEAN_VERSION) -AC_SUBST(VERSION_MAJOR) -AC_SUBST(GEN_TOOL) - -AC_SUBST(WIN_RC_VERSION) - -AC_SUBST(HAVE_EXTERNAL_XIPH_LIBS) -AC_SUBST(HAVE_MPEG) -AC_SUBST(OS_SPECIFIC_CFLAGS) -AC_SUBST(OS_SPECIFIC_LINKS) -AC_SUBST(SNDIO_LIBS) - -AC_SUBST(EXTERNAL_XIPH_CFLAGS) -AC_SUBST(EXTERNAL_XIPH_LIBS) -AC_SUBST(EXTERNAL_XIPH_REQUIRE) -AC_SUBST(EXTERNAL_MPEG_LIBS) -AC_SUBST(EXTERNAL_MPEG_REQUIRE) -AC_SUBST(MPG123_CFLAGS) -AC_SUBST(MPG123_LIBS) -AC_SUBST(MPEG_CFLAGS) -AC_SUBST(MPEG_LIBS) -AC_SUBST(SRC_BINDIR) -AC_SUBST(TEST_BINDIR) - -AC_CONFIG_FILES([ - Makefile Octave/Makefile - src/version-metadata.rc - tests/test_wrapper.sh tests/pedantic-header-test.sh - sndfile.pc - Scripts/build-test-tarball.mk - ]) -AC_OUTPUT - -dnl ==================================================================================== - -AS_IF([test -z "$PKG_CONFIG"], [ - AS_ECHO([" *****************************************************************"]) - AS_ECHO([" *** The pkg-config program is missing. ***"]) - AS_ECHO([" *** External FLAC/Ogg/Vorbis libs cannot be found without it. ***"]) - AS_ECHO([" *** http://pkg-config.freedesktop.org/wiki/ ***"]) - AS_ECHO([" *****************************************************************"]) - ]) - -AX_RECURSIVE_EVAL([$libdir], [full_absolute_libdir]) -AX_RECURSIVE_EVAL([$bindir], [full_absolute_bindir]) -AX_RECURSIVE_EVAL([$pkgconfigdir], [full_absolute_pkgconfigdir]) -AX_RECURSIVE_EVAL([$htmldir], [full_absolute_htmldir]) -AC_MSG_RESULT([ --=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-=- - - Configuration summary : - - libsndfile version : .................. ${VERSION} - - Host CPU : ............................ ${host_cpu} - Host Vendor : ......................... ${host_vendor} - Host OS : ............................. ${host_os} - - CFLAGS : .............................. ${CFLAGS} - CXXFLAGS : ............................ ${CXXFLAGS} - CPPFLAGS : ............................ ${CPPFLAGS} - LDFLAGS : ............................. ${LDFLAGS} - - Experimental code : ................... ${enable_experimental:-no} - Using ALSA in example programs : ...... ${enable_alsa:-no} - External FLAC/Ogg/Vorbis/Opus : ....... ${enable_external_libs:-no} - External MPEG Lame/MPG123 : ........... ${enable_mpeg:-no} - Building Octave interface : ........... ${OCTAVE_BUILD} - - Tools : - - C Compiler Vendor is : ................ ${ax_cv_c_compiler_vendor} (${ax_cv_c_compiler_version}) - CXX Compiler Vendor is : .............. ${ax_cv_cxx_compiler_vendor} (${ax_cv_cxx_compiler_version}) - - Sanitizer enabled : ................... ${enable_sanitizer:-no} - - Installation directories : - - Library directory : ................... ${full_absolute_libdir} - Program directory : ................... ${full_absolute_bindir} - Pkgconfig directory : ................. ${full_absolute_pkgconfigdir} - HTML docs directory : ................. ${full_absolute_htmldir} - -Compiling some other packages against libsndfile may require -the addition of '$full_absolute_pkgconfigdir' to the -PKG_CONFIG_PATH environment variable. -]) - -dnl Remove symlink created by Scripts/android-configure.sh. -rm -f gdbclient diff --git a/Engine/lib/libsndfile/docs/FAQ.md b/Engine/lib/libsndfile/docs/FAQ.md deleted file mode 100644 index e7c98e255..000000000 --- a/Engine/lib/libsndfile/docs/FAQ.md +++ /dev/null @@ -1,482 +0,0 @@ ---- -layout: default -title: libsndfile : Frequently Asked Questions. ---- - -# libsndfile : Frequently Asked Questions - -1. [Do you plan to support XYZ codec in libsndfile?](#Q001) -2. [In version 0 the SF\_INFO struct had a pcmbitwidth field but version 1 does not. Why?](#Q002) -3. [Compiling is really slow on MacOS X. Why?](#Q003) -4. [When trying to compile libsndfile on Solaris I get a "bad substitution" error during linking. What can I do to fix this?](#Q004) -5. [Why doesn't libsndfile do interleaving/de-interleaving?](#Q005) -6. [What's the best format for storing temporary files?](#Q006) -7. [On Linux/Unix/MacOS X, what's the best way of detecting the presence of libsndfile?](#Q007) -8. [I have libsndfile installed and now I want to use it. I just want a simple Makefile\! What do I do?](#Q008) -9. [How about adding the ability to write/read sound files to/from memory buffers?](#Q009) -10. [Reading a 16 bit PCM file as normalised floats and then writing them back changes some sample values. Why?](#Q010) -11. [I'm having problems with u-law encoded WAV files generated by libsndfile in Winamp. Why?](#Q011) -12. [I'm looking at sf\_read\*. What are items? What are frames?](#Q012) -13. [Why can't libsndfile open this Sound Designer II (SD2) file?](#Q013) -14. [I'd like to statically link libsndfile to my closed source application. Can I buy a license so that this is possible?](#Q014) -15. [My program is crashing during a call to a function in libsndfile. Is this a bug in libsndfile?](#Q015) -16. [Will you accept a fix for compiling libsndfile with compiler X?](#Q016) -17. [Can libsndfile read/write files from/to UNIX pipes?](#Q017) -18. [Is it possible to build a Universal Binary on Mac OS X?](#Q018) -19. [I have project files for Visual Studio / XCode / Whatever. Why don't you distribute them with libsndfile?](#Q019) -20. [Why doesn't libsndfile support MP3?](#Q020) -21. [How do I use libsndfile in a closed source or commercial program and comply with the license?](#Q021) -22. [What versions of windows does libsndfile work on?](#Q022) -23. [I'm cross compiling libsndfile for another platform. How can I run the test suite?](#Q023) - ------ - -## Q1 : Do you plan to support XYZ codec in libsndfile? {#Q001} - -If source code for XYZ codec is available under a suitable license (LGPL, BSD, -MIT etc) then yes, I'd like to add it. - -If suitable documentation is available on how to decode and encode the format -then maybe, depending on how much work is involved. - -If XYZ is some proprietary codec where no source code or documentation is -available then no. - -So if you want support for XYZ codec, first find existing source code or -documentation. If you can't find either then the answer is no. - -## Q2 : In version 0 the SF\_INFO struct had a pcmbitwidth field but version 1 does not. Why? {#Q002} - -This was dropped for a number of reasons: - -- pcmbitwidth makes little sense on compressed or floating point formats -- with the new API you really don't need to know it - -As documented [here](api.md#note-1) there is now a well defined behaviour which -ensures that no matter what the bit width of the source file, the scaling always -does something sensible. This makes it safe to read 8, 16, 24 and 32 bit PCM -files using `sf_read_short()` and always have the optimal behaviour. - -## Q3 : Compiling is really slow on MacOS X. Why? {#Q003} - -When you configure and compile libsndfile, it uses the /bin/sh shell for a -number of tasks (ie configure script and libtool). Older versions of OS X -(10.2?) shipped a really crappy Bourne shell as /bin/sh which resulted in -**really** slow compiles. Newer version of OS X ship GNU Bash as /bin/sh and -this answer doesn't apply in that case. - -To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to -/bin/sh.old and make a symlink from /bin/sh to the bash shell. Bash is designed -to behave as a Bourne shell when it is called as /bin/sh. - -When I did this on my iBook running MacOS X, compile times dropped from 13 -minutes to 3 minutes. - -## Q4 : When trying to compile libsndfile on Solaris I get a "bad substitution" error on linking. Why? {#Q004} - -It seems that the Solaris Bourne shell disagrees with GNU libtool. - -To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to -/bin/sh.old and make a symlink from /bin/sh to the bash shell. Bash is designed -to behave as a Bourne shell when it is called as /bin/sh. - -## Q5 : Why doesn't libsndfile do interleaving/de-interleaving? {#Q005} - -This problem is bigger than it may seem at first. - -For a stereo file, it is a pretty safe bet that a simple interleaving/ -de-interleaving could satisfy most users. However, for files with more than 2 -channels this is unlikely to be the case. If the user has a 4 channel file and -want to play that file on a stereo output sound card they either want the first -2 channels or they want some mixed combination of the 4 channels. - -When you add more channels, the combinations grow exponentially and it becomes -increasingly difficult to cover even a sensible subset of the possible -combinations. On top of that, coding any one style of interleaver/de-interleaver -is trivial, while coding one that can cover all combinations is far from -trivial. This means that this feature will not be added any time soon. - -## Q6 : What's the best format for storing temporary files? {#Q006} - -When you want to store temporary data there are a number of requirements: - -- A simple, easy to parse header. -- The format must provide the fastest possible read and write rates (ie avoid - conversions and encoding/decoding). -- The file format must be reasonably common and playable by most players. -- Able to store data in either endian-ness. - -The format which best meets these requirements is AU, which allows data to be -stored in any one of short, int, float and double (among others) formats. - -For instance, if an application uses float data internally, its temporary files -should use a format of (SF_ENDIAN_CPU | SF_FORMAT_AU | SF_FORMAT_FLOAT) which -will store big endian float data in big endian CPUs and little endian float data -on little endian CPUs. Reading and writing this format will not require any -conversions or byte swapping regardless of the host CPU. - -## Q7 : On Linux/Unix/MaxOS X, what's the best way of detecting the presence of libsndfile using autoconf? {#Q007} - -libsndfile uses the pkg-config (man pkg-config) method of registering itself -with the host system. The best way of detecting its presence is using something -like this in configure.ac (or configure.in): - - PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.2, ac_cv_sndfile=1, ac_cv_sndfile=0) - - AC_DEFINE_UNQUOTED([HAVE_SNDFILE],${ac_cv_sndfile}, - [Set to 1 if you have libsndfile.]) - - AC_SUBST(SNDFILE_CFLAGS) - AC_SUBST(SNDFILE_LIBS) - -This will automatically set the **SNDFILE_CFLAGS** and **SNDFILE_LIBS** -variables which can be used in Makefile.am like this: - - SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ - SNDFILE_LIBS = @SNDFILE_LIBS@ - -If you install libsndfile from source, you will probably need to set the -**PKG_CONFIG_PATH** environment variable as suggested at the end of the -libsndfile configure process. For instance on my system I get this: - - -=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=- - - Configuration summary : - - Version : ..................... 1.0.5 - Experimental code : ........... no - - Tools : - - Compiler is GCC : ............. yes - GCC major version : ........... 3 - - Installation directories : - - Library directory : ........... /usr/local/lib - Program directory : ........... /usr/local/bin - Pkgconfig directory : ......... /usr/local/lib/pkgconfig - - Compiling some other packages against libsndfile may require - the addition of "/usr/local/lib/pkgconfig" to the - PKG_CONFIG_PATH environment variable. - -## Q8 : I have libsndfile installed and now I want to use it. I just want a simple Makefile\! What do I do? {#Q008} - -The **pkg-config** program makes finding the correct compiler flag values and -library location far easier. During the installation of libsndfile, a file named -**sndfile.pc** is installed in the directory **${libdir}/pkgconfig** (ie if -libsndfile is installed in **/usr/local/lib**, **sndfile.pc** will be installed -in **/usr/local/lib/pkgconfig/**). - -In order for pkg-config to find sndfile.pc it may be necessary to point the -environment variable **PKG_CONFIG_PATH** in the right direction. - - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig - -Then, to compile a C file into an object file, the command would be: - - gcc `pkg-config --cflags sndfile` -c somefile.c - -and to link a number of objects into an executable that links against -libsndfile, the command would be: - - gcc `pkg-config --libs sndfile` obj1.o obj2.o -o program - -## Q9 : How about adding the ability to write/read sound files to/from memory buffers? {#Q009} - -This has been [added](api.md#open_virtual) for version 1.0.12. - -## Q10 : Reading a 16 bit PCM file as normalised floats and then writing them back changes some sample values. Why? {#Q010} - -This is caused by the fact that the conversion from 16 bit short to float is -done by dividing by 32768 (0x8000 in hexadecimal) while the conversion from -float to 16 bit short is done by multiplying by 32767 (0x7FFF in hex). So for -instance, a value in a 16 bit PCM file of 20000 gets read as a floating point -number of 0.6103515625 (20000.0 / 0x8000). Converting that back to a 16 bit -short results in a value of 19999.3896484375 (0.6103515625 \* 0x7FFF) which then -gets rounded down to 19999. - -You will notice that for this particular case, the error is 1 in 20000 or -0.005%. Interestingly, for values of less than 16369, dividing by 0x8000 -followed by multiplying by 0x7FFF and then rounding the result, gives back the -original value. It turns out that as long as the host operating system supplies -the 1999 ISO C Standard functions **lrintf** and **lrint** (or a replacement has -been supplied) then the maximum possible error is 1 in 16369 or about 0.006%. - -Regardless of the size of the error, the reason why this is done is rather -subtle. - -In a file containing 16 bit PCM samples, the values are restricted to the range -[-32768, 32767] while we want floating point values in the range [-1.0, 1.0]. -The only way to do this conversion is to do a floating point division by a value -of 0x8000. Converting the other way, the only way to ensure that floating point -values in the range [-1.0, 1.0] are within the valid range allowed by a 16 bit -short is to multiply by 0x7FFF. - -Some people would say that this is a severe short-coming of libsndfile. I would -counter that anybody who is constantly converting back and forth between 16 bit -shorts and normalised floats is going to suffer other losses in audio quality -that they should also be concerned about. - -Since this problem only occurs when converting between integer data on disk and -normalized floats in the application, it can be avoided by using something other -than normalized floats in the application. Alternatives to normalized floats are -the **short** and **int** data types (ie using sf_read_short or sf_read_int) or -using un-normalized floats (see -[SFC_SET_NORM_FLOAT](command.html#sfc_set_norm_float)). - -Another way to deal with this problem is to consider 16 bit short data as a -final destination format only, not as an intermediate storage format. All -intermediate data (ie which is going to be processed further) should be stored -in floating point format which is supported by all of the most common file -formats. If floating point files are considered too large (2 times the size of a -16 bit PCM file), it would also be possible to use 24 bit PCM as an intermediate -storage format (and which is also supported by most common file types). - -## Q11 : I'm having problems with u-law encoded WAV files generated by libsndfile in Winamp. Why? {#Q011} - -This is actually a Winamp problem. The official Microsoft spec suggests that the -'fmt ' chunk should be 18 bytes. Unfortunately at least one of Microsoft's own -applications (Sound Recorder on Win98 I believe) did not accept 18 bytes 'fmt ' -chunks. - -Michael Lee did some experimenting and found that: - -> I have checked that Windows Media Player 9, QuickTime Player 6.4, RealOne -> Player 2.0 and GoldWave 5.06 can all play u-law files with 16-byte or 18-byte -> 'fmt ' chunk. Only Winamp (2.91) and foobar2000 are unable to play u-law files -> with 16-byte 'fmt ' chunk. - -Even this is a very small sampling of all the players out there. For that reason -it is probably not a good idea to change this now because there is the risk of -breaking something that currently works. - -## Q12 : I'm looking at sf_read*. What are items? What are frames? {#Q012} - -An `item` is a single sample of the data type you are reading; ie a single -`short` value for `sf_read_short` or a single `float` for `sf_read_float`. - -For a sound file with only one channel, a frame is the same as a item (ie a -single sample) while for multi channel sound files, a single frame contains a -single item for each channel. - -Here are two simple, correct examples, both of which are assumed to be working -on a stereo file, first using items: - -```c -#define CHANNELS 2 -short data [CHANNELS * 100] ; -sf_count items_read = sf_read_short (file, data, 200) ; -assert (items_read == 200) ; -``` - -and now reading the exact same amount of data using frames: - -```c -#define CHANNELS 2 -short data [CHANNELS * 100] ; -sf_count frames_read = sf_readf_short (file, data, 100) ; -assert (frames_read == 100) ; -``` - -## Q13 : Why can't libsndfile open this Sound Designer II (SD2) file? {#Q013} - -This is somewhat complicated. First some background. - -SD2 files are native to the Apple Macintosh platform and use features of the Mac -filesystem (file resource forks) to store the file's sample rate, number of -channels, sample width and more. When you look at a file and its resource fork -on Mac OS X it looks like this: - - -rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2 - -rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 file.sd2/rsrc - -Notice how the file itself looks like a directory containing a single file named -**rsrc**. When libsndfile is compiled for MacOS X, it should open (for write and -read) SD2 file with resource forks like this without any problems. It will also -handle files with the resource fork in a separate file as described below. - -When SD2 files are moved to other platforms, the resource fork of the file can -sometimes be dropped altogether. All that remains is the raw audio data and no -information about the number of channels, sample rate or bit width which makes -it a little difficult for libsndfile to open the file. - -However, it is possible to safely move an SD2 file to a Linux or Windows -machine. For instance, when an SD2 file is copied from inside MacOS X to a -windows shared directory or a Samba share (ie Linux), MacOS X is clever enough -to store the resource fork of the file in a separate hidden file in the same -directory like this: - - -rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 ._file.sd2 - -rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2 - -Regardless of what platform it is running on, when libsndfile is asked to open a -file named **"foo"** and it can't recognize the file type from the data in the -file, it will attempt to open the resource fork and if that fails, it then tries -to open a file named **"._foo"** to see if the file has a valid resource fork. -This is the same regardless of whether the file is being opened for read or -write. - -In short, libsndfile should open SD2 files with a valid resource fork on all of -the platforms that libsndfile supports. If a file has lost its resource fork, -the only option is the open the file using the SF_FORMAT_RAW option and guessing -its sample rate, channel count and bit width. - -Occasionally, when SD2 files are moved to other systems, the file is -[BinHexed](http://www.macdisk.com/binhexen.php3) which wraps the resource fork -and the data fork together. For these files, it would be possible to write a -BinHex parser but there is not a lot to gain considering how rare these BinHexed -SD2 files are. - -## Q14 : I'd like to statically link libsndfile to my closed source application. Can I buy a license so that this is possible? {#Q014} - -Unfortunately no. libsndfile contains code written by other people who have -agreed that their code be used under the GNU LGPL but no more. Even if they were -to agree, there would be significant difficulties in dividing up the payments -fairly. - -The **only** way you can legally use libsndfile as a statically linked library -is if your application is released under the GNU GPL or LGPL. - -## Q15 : My program is crashing during a call to a function in libsndfile. Is this a bug in libsndfile? {#Q015} - -libsndfile is being used by large numbers of people all over the world without -any problems like this. That means that it is much more likely that your code -has a bug than libsndfile. However, it is still possible that there is a bug in -libsndfile. - -To figure out whether it is your code or libsndfile you should do the following: - -- Make sure you are compiling your code with warnings switched on and that you - fix as many warnings as possible. With the GNU compiler (gcc) I would - recommend at least **-W -Wall -Werror** which will force you to fix all - warnings before you can run the code. -- Try using a memory debugger. [Valgrind](http://valgrind.kde.org/) on x86 Linux - is excellent. [Purify](http://www.ibm.com/software/awdtools/purify/) also has - a good reputation. -- If the code is clean after the above two steps and you still get a crash in - libsndfile, then send me a small snippet of code (no more than 30-40 lines) - which includes the call to sf_open() and also shows how all variables passed - to/returned from sf_open() are defined. - -## Q16 : Will you accept a fix for compiling libsndfile with compiler X? {#Q016} - -If compiler X is a C++ compiler then no. C and C++ are different enough to make -writing code that compiles as valid C and valid C++ too difficult. I would -rather spend my time fixing bugs and adding features. - -If compiler X is a C compiler then I will do what I can as long as that does not -hamper the correctness, portability and maintainability of the existing code. It -should be noted however that libsndfile uses features specified by the 1999 ISO -C Standard. This can make compiling libsndfile with some older compilers -difficult. - -## Q17 : Can libsndfile read/write files from/to UNIX pipes? {#Q017} - -Yes, libsndfile can read files from pipes. Unfortunately, the write case is much -more complicated. - -File formats like AIFF and WAV have information at the start of the file (the -file header) which states the length of the file, the number of sample frames -etc. This information must be filled in correctly when the file header is -written, but this information is not reliably known until the file is closed. -This means that libsndfile cannot write AIFF, WAV and many other file types to a -pipe. - -However, there is at least one file format (AU) which is specifically designed -to be written to a pipe. Like AIFF and WAV, AU has a header with a sample frames -field, but it is specifically allowable to set that frames field to 0x7FFFFFFF -if the file length is not known when the header is written. The AU file format -can also hold data in many of the standard formats (ie SF_FORMAT_PCM_16, -SF_FORMAT_PCM_24, SF_FORMAT_FLOAT etc) as well as allowing data in both big and -little endian format. - -See also [FAQ Q6](#Q006). - -## Q18 : Is it possible to build a Universal Binary on Mac OS X? {#Q018} - -Yes, but you must do two separate configure/build/test runs; one on PowerPC and -one on Intel. It is then possible to merge the binaries into a single universal -binary using one of the programs in the Apple tool chain. - -It is **not** possible to build a working universal binary via a single -compile/build run on a single CPU. - -The problem is that the libsndfile build process detects features of the CPU its -being built for during the configure process and when building a universal -binary, configure is only run once and that data is then used for both CPUs. -That configure data will be wrong for one of those CPUs. You will still be able -to compile libsndfile, and the test suite will pass on the machine you compiled -it on. However, if you take the universal binary test suite programs compiled on -one CPU and run them on the other, the test suite will fail. - -Part of the problem is that the CPU endian-ness is detected at configure time. -Yes, I know the Apple compiler defines one of the macros \_\_LITTLE\_ENDIAN\_\_ -and \_\_BIG\_ENDIAN\_\_, but those macros are not part of the 1999 ISO C -Standard and they are not portable. - -Endian issues are not the only reason why the cross compiled binary will fail. -The configure script also detects other CPU specific idiosyncrasies to provide -more optimized code. - -Finally, the real show stopper problem with universal binaries is the problem -with the test suite. libsndfile contains a huge, comprehensive test suite. When -you compile a universal binary and run the test suite, you only test the native -compile. The cross compiled binary (the one with the much higher chance of -having problems) cannot be tested. - -Now, if you have read this far you're probably thinking there must be a way to -fix this and there probably is. The problem is that its a hell of a lot of work -and would require significant changes to the configure process, the internal -code and the test suite. In addition, these changes must not break compilation -on any of the platforms libsndfile is currently working on. - -## Q19 : I have project files for Visual Studio / XCode / Whatever. Why don't you distribute them with libsndfile? {#Q019} - -Use CMake project. - -## Q20 : Why doesn't libsndfile support MP3? {#Q020} - -~~In the past, MP3 was not supported because the technology behind MP3 was -patented. Those patents have now expired and there is an -[open ticket](https://github.com/libsndfile/libsndfile/issues/258) to implement -MP3 support.~~ - -**Update :** Starting from version 1.1.0 libsndfile supports MP3 format. - -## Q21 : How do I use libsndfile in a closed source or commercial program and comply with the license? {#Q021} - -Here is a checklist of things you need to do to make sure your use of libsndfile -in a closed source or commercial project complies with the license libsndfile is -released under, the GNU Lesser General Public License (LGPL): - -- Make sure you are linking to libsndfile as a shared library (Linux and Unix - systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OS X). If - you are using some other operating system that doesn't allow dynamically - linked libraries, you will not be able to use libsndfile unless you release - the source code to your program. -- In the licensing documentation for your program, add a statement that your - software depends on libsndfile and that libsndfile is released under the GNU - Lesser General Public License, either - [version 2.1](http://www.gnu.org/licenses/lgpl-2.1.txt) or optionally - [version 3](http://www.gnu.org/licenses/lgpl.txt). -- Include the text for both versions of the license, possibly as separate files - named libsndfile_lgpl_v2_1.txt and libsndfile_lgpl_v3.txt. - -## Q22 : What versions of Windows does libsndfile work on? {#Q022} - -New versions of libsndfile binary releases require Wiindows Vista. If you need -Windows XP support, you can build DLL from sources, we don't use specific WinXP -features. - -## Q23 : I'm cross compiling libsndfile for another platform. How can I run the test suite? {#Q023} - -Since version 1.0.21 the top level Makefile has an extra make target, -'test-tarball'. Building this target creates a tarball called called: - - ` libsndfile-testsuite-${host_triplet}-${version}.tar.gz` - -in the top level directory. This tarball can then be copied to the target -platform. Once untarred and test script `test_wrapper.sh` can be run from the -top level of the extracted tarball. diff --git a/Engine/lib/libsndfile/docs/_config.yml b/Engine/lib/libsndfile/docs/_config.yml deleted file mode 100644 index 4c626e0e2..000000000 --- a/Engine/lib/libsndfile/docs/_config.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -author: "The libsndfile team" -version: "1.2.2" - -markdown: kramdown -plugins: - - jekyll-default-layout ---- diff --git a/Engine/lib/libsndfile/docs/_includes/logo.html b/Engine/lib/libsndfile/docs/_includes/logo.html deleted file mode 100644 index f17a03431..000000000 --- a/Engine/lib/libsndfile/docs/_includes/logo.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Engine/lib/libsndfile/docs/_layouts/default.html b/Engine/lib/libsndfile/docs/_layouts/default.html deleted file mode 100644 index 76c2cb8bf..000000000 --- a/Engine/lib/libsndfile/docs/_layouts/default.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - {{ page.title }} - - - - - {{ content }} -
    -
    -

    The libsndfile home page is here.

    -

    The libsndfile version: {{ site.version }}.

    -
    - - diff --git a/Engine/lib/libsndfile/docs/_layouts/home.html b/Engine/lib/libsndfile/docs/_layouts/home.html deleted file mode 100644 index 6c8119d12..000000000 --- a/Engine/lib/libsndfile/docs/_layouts/home.html +++ /dev/null @@ -1,34 +0,0 @@ ---- -layout: default -keywords: WAV AIFF AU SVX PAF NIST W64 libsndfile sound audio dsp Linux -robots: nofollow -title: libsndfile home page ---- - - - -
    -
    - {{ content }} -
    -
    diff --git a/Engine/lib/libsndfile/docs/_layouts/page.html b/Engine/lib/libsndfile/docs/_layouts/page.html deleted file mode 100644 index 21c7d9b39..000000000 --- a/Engine/lib/libsndfile/docs/_layouts/page.html +++ /dev/null @@ -1,10 +0,0 @@ ---- -layout: default ---- - - -
    -
    - {{ content }} -
    -
    diff --git a/Engine/lib/libsndfile/docs/api.md b/Engine/lib/libsndfile/docs/api.md deleted file mode 100644 index e17f5ad9c..000000000 --- a/Engine/lib/libsndfile/docs/api.md +++ /dev/null @@ -1,744 +0,0 @@ ---- -layout: page -title: The libsndfile API ---- - -# libsndfile - -Libsndfile is a library designed to allow the reading and writing of many different sampled sound file formats (such as -MS Windows WAV and the Apple/SGI AIFF format) through one standard library interface. - -During read and write operations, formats are seamlessly converted between the format the application program has -requested or supplied and the file's data format. The application programmer can remain blissfully unaware of issues -such as file endian-ness and data format. See [Note 1](#note-1) and [Note 2](#note-2). - -Every effort is made to keep these documents up-to-date, error free and unambiguous. However, since maintaining the -documentation is the least fun part of working on libsndfile, these docs can and do fall behind the behaviour of the -library. If any errors, omissions or ambiguities are found, please notify me (erikd) at mega-nerd dot com. - -To supplement this reference documentation, there are simple example programs included in the source code tarball. The -test suite which is also part of the source code tarball is also a good place to look for the correct usage of the -library functions. - -**Finally, if you think there is some feature missing from libsndfile, check that it isn't already implemented (and -documented) [here](command.md).** - -## Synopsis - -```c -#include ; -#include ; -``` - -| Name | Description | -|:------------------------------------------------------------------------------------------------------------|:--------------------------------------- | -| [sf_open, sf_wchar_open](#open) | File open functions. | -| [sf_open_fd](#open_fd) | Open sound file using file descriptor. | -| [sf_open_virtual](#open_virtual) | Open sound file using virtual API. | -| [sf_format_check](#check) | Validate sound file info. | -| [sf_seek](#seek) | Seek position in sound file. | -| [sf_command](command.md) | Command interface. | -| [sf_error, sf_strerror, sf_error_number, sf_perror, sf_error_str](#error) | Error functions. | -| [sf_close](#close) | File close function. | -| [sf_write_sync](#write_sync) | Write sync function. | -| [sf_read_short, sf_read_int, sf_read_float, sf_read_double](#read) | File items read functions. | -| [sf_readf_short, sf_readf_int, sf_readf_float, sf_readf_double](#readf) | File frames read functions. | -| [sf_write_short, sf_write_int, sf_write_float, sf_write_double](#write) | File items write functions. | -| [sf_writef_short, sf_writef_int, sf_writef_float, sf_writef_double](#writef) | File frames write functions. | -| [sf_read_raw, sf_write_raw](#raw) | Raw read/write functions. | -| [sf_get_string, sf_set_string](#string) | Functions for reading and writing string data. | -| [sf_version_string](#version_string) | Retrieve library version string. | -| [sf_current_byterate](#current_byterate) | Retrieve current byterate. | -| [sf_set_chunk, sf_get_chunk_iterator, sf_next_chunk_iterator, sf_get_chunk_size, sf_get_chunk_data](#chunk) | RIFF chunks API. | - -SNDFILE* is an anonymous pointer to data which is private to the library. - -## File Open Function {#open} - -```c -SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; -``` - -The sf_open() function opens the sound file at the specified path. The filename is byte encoded, but may be utf-8 on -Linux, while on Mac OS X it will use the filesystem character set. On Windows, there is also a Windows specific -sf_wchar_open() that takes a UTF16_BE encoded filename. - -```c -SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ; -``` - -The SF_INFO structure is for passing data between the calling function and the library when opening a file for reading -or writing. It is defined in sndfile.h as follows: - -```c -typedef struct -{ sf_count_t frames ; /* Used to be called samples. */ - int samplerate ; - int channels ; - int format ; - int sections ; - int seekable ; - } SF_INFO ; -``` - -The mode parameter for this function can be any one of the following three values: - -SFM_READ -: read only mode - -SFM_WRITE -: write only mode - -SFM_RDWR -: read/write mode - -When opening a file for read, the **format** field should be set to zero before -calling **sf_open**(). The only exception to this is the case of RAW files where -the caller has to set the **samplerate**, **channels** and **format** fields to -valid values. All other fields of the structure are filled in by the library. - -**Note:** The libsndfile library will reject values ​​for field **channels** that -are greater than `1024`. These value ​​represent the maximum theoretical limit -and may be less for specific formats. - -When opening a file for write, the caller must fill in structure members -**samplerate**, **channels**, and **format**. - -The **format** field in the above **SF_INFO** structure is made up of the -bit-wise OR of a major format type (values between 0x10000 and 0x08000000), a -minor format type (with values less than 0x10000) and an optional endian-ness -value. The currently understood formats are listed in *sndfile.h* as follows and -also include bitmasks for separating major and minor file types. Not all -combinations of endian-ness and major and minor file types are valid. - -| Name | Value | Description | -|:-------------------------|:-----------|:-------------------------------------------| -| **Major formats.** | -| SF_FORMAT_WAV | 0x010000 | Microsoft WAV format (little endian). | -| SF_FORMAT_AIFF | 0x020000 | Apple/SGI AIFF format (big endian). | -| SF_FORMAT_AU | 0x030000 | Sun/NeXT AU format (big endian). | -| SF_FORMAT_RAW | 0x040000 | RAW PCM data. | -| SF_FORMAT_PAF | 0x050000 | Ensoniq PARIS file format. | -| SF_FORMAT_SVX | 0x060000 | Amiga IFF / SVX8 / SV16 format. | -| SF_FORMAT_NIST | 0x070000 | Sphere NIST format. | -| SF_FORMAT_VOC | 0x080000 | VOC files. | -| SF_FORMAT_IRCAM | 0x0A0000 | Berkeley/IRCAM/CARL | -| SF_FORMAT_W64 | 0x0B0000 | Sonic Foundry's 64 bit RIFF/WAV | -| SF_FORMAT_MAT4 | 0x0C0000 | Matlab (tm) V4.2 / GNU Octave 2.0 | -| SF_FORMAT_MAT5 | 0x0D0000 | Matlab (tm) V5.0 / GNU Octave 2.1 | -| SF_FORMAT_PVF | 0x0E0000 | Portable Voice Format | -| SF_FORMAT_XI | 0x0F0000 | Fasttracker 2 Extended Instrument | -| SF_FORMAT_HTK | 0x100000 | HMM Tool Kit format | -| SF_FORMAT_SDS | 0x110000 | Midi Sample Dump Standard | -| SF_FORMAT_AVR | 0x120000 | Audio Visual Research | -| SF_FORMAT_WAVEX | 0x130000 | MS WAVE with WAVEFORMATEX | -| SF_FORMAT_SD2 | 0x160000 | Sound Designer 2 | -| SF_FORMAT_FLAC | 0x170000 | FLAC lossless file format | -| SF_FORMAT_CAF | 0x180000 | Core Audio File format | -| SF_FORMAT_WVE | 0x190000 | Psion WVE format | -| SF_FORMAT_OGG | 0x200000 | Xiph OGG container | -| SF_FORMAT_MPC2K | 0x210000 | Akai MPC 2000 sampler | -| SF_FORMAT_RF64 | 0x220000 | RF64 WAV file | -| SF_FORMAT_MPEG | 0x230000 | MPEG-1/2 audio stream | -| **Subtypes.** | -| SF_FORMAT_PCM_S8 | 0x0001 | Signed 8 bit data | -| SF_FORMAT_PCM_16 | 0x0002 | Signed 16 bit data | -| SF_FORMAT_PCM_24 | 0x0003 | Signed 24 bit data | -| SF_FORMAT_PCM_32 | 0x0004 | Signed 32 bit data | -| SF_FORMAT_PCM_U8 | 0x0005 | Unsigned 8 bit data (WAV and RAW only) | -| SF_FORMAT_FLOAT | 0x0006 | 32 bit float data | -| SF_FORMAT_DOUBLE | 0x0007 | 64 bit float data | -| SF_FORMAT_ULAW | 0x0010 | U-Law encoded. | -| SF_FORMAT_ALAW | 0x0011 | A-Law encoded. | -| SF_FORMAT_IMA_ADPCM | 0x0012 | IMA ADPCM. | -| SF_FORMAT_MS_ADPCM | 0x0013 | Microsoft ADPCM. | -| SF_FORMAT_GSM610 | 0x0020 | GSM 6.10 encoding. | -| SF_FORMAT_VOX_ADPCM | 0x0021 | OKI / Dialogix ADPCM | -| SF_FORMAT_NMS_ADPCM_16 | 0x0022 | 16kbs NMS G721-variant encoding. | -| SF_FORMAT_NMS_ADPCM_24 | 0x0023 | 24kbs NMS G721-variant encoding. | -| SF_FORMAT_NMS_ADPCM_32 | 0x0024 | 32kbs NMS G721-variant encoding. | -| SF_FORMAT_G721_32 | 0x0030 | 32kbs G721 ADPCM encoding. | -| SF_FORMAT_G723_24 | 0x0031 | 24kbs G723 ADPCM encoding. | -| SF_FORMAT_G723_40 | 0x0032 | 40kbs G723 ADPCM encoding. | -| SF_FORMAT_DWVW_12 | 0x0040 | 12 bit Delta Width Variable Word encoding. | -| SF_FORMAT_DWVW_16 | 0x0041 | 16 bit Delta Width Variable Word encoding. | -| SF_FORMAT_DWVW_24 | 0x0042 | 24 bit Delta Width Variable Word encoding. | -| SF_FORMAT_DWVW_N | 0x0043 | N bit Delta Width Variable Word encoding. | -| SF_FORMAT_DPCM_8 | 0x0050 | 8 bit differential PCM (XI only) | -| SF_FORMAT_DPCM_16 | 0x0051 | 16 bit differential PCM (XI only) | -| SF_FORMAT_VORBIS | 0x0060 | Xiph Vorbis encoding. | -| SF_FORMAT_OPUS | 0x0064 | Xiph/Skype Opus encoding. | -| SF_FORMAT_ALAC_16 | 0x0070 | Apple Lossless Audio Codec (16 bit). | -| SF_FORMAT_ALAC_20 | 0x0071 | Apple Lossless Audio Codec (20 bit). | -| SF_FORMAT_ALAC_24 | 0x0072 | Apple Lossless Audio Codec (24 bit). | -| SF_FORMAT_ALAC_32 | 0x0073 | Apple Lossless Audio Codec (32 bit). | -| SF_FORMAT_MPEG_LAYER_I | 0x0080 | MPEG-1 Audio Layer I. | -| SF_FORMAT_MPEG_LAYER_II | 0x0081 | MPEG-1 Audio Layer II. | -| SF_FORMAT_MPEG_LAYER_III | 0x0082 | MPEG-2 Audio Layer III. | -| **Endian-ness options.** | -| SF_ENDIAN_FILE | 0x00000000 | Default file endian-ness. | -| SF_ENDIAN_LITTLE | 0x10000000 | Force little endian-ness. | -| SF_ENDIAN_BIG | 0x20000000 | Force big endian-ness. | -| SF_ENDIAN_CPU | 0x30000000 | Force CPU endian-ness. | -| SF_FORMAT_SUBMASK | 0x0000FFFF | | -| SF_FORMAT_TYPEMASK | 0x0FFF0000 | | -| SF_FORMAT_ENDMASK | 0x30000000 | | - -Every call to **sf_open**() should be matched with a call to -[**sf_close**()](#close) to free up memory allocated during the call to **sf_open**(). - -On success, the sf_open function returns a non-NULL pointer which should be passed as the first parameter to all -subsequent libsndfile calls dealing with that audio file. On fail, the sf_open function returns a NULL pointer. An -explanation of the error can obtained by passing NULL to [**sf_strerror**()](#error). - -### File Descriptor Open {#open_fd} - -```c -SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; -``` - -**Note:** On Microsoft Windows, this function does not work if the application -and the libsndfile DLL are linked to different versions of the Microsoft C -runtime DLL. - -The second open function takes a file descriptor of a file that has already been -opened. Care should be taken to ensure that the mode of the file represented by -the descriptor matches the mode argument. This function is useful in the -following circumstances: - -* Opening temporary files securely (ie use the **tmpfile**() to return a FILE* - pointer and then using fileno() to retrieve the file descriptor which is then - passed to libsndfile). -* Opening files with file names using OS specific character encodings and then - passing the file descriptor to **sf_open_fd**(). -* Opening sound files embedded within larger files. [More info](embedded_files.md). - -Every call to `sf_open_fd`() should be matched with a call to sf_close() to free -up memory allocated during the call to sf_open_fd(). - -When sf_close() is called, the file descriptor is only closed if the -**close_desc** parameter was TRUE when the sf_open_fd() function was called. - -On success, the sf_open_fd() function returns a non-NULL pointer which should be -passed as the first parameter to all subsequent libsndfile calls dealing with -that audio file. On fail, the sf_open_fd() function returns a NULL pointer. - -### Virtual File Open Function {#open_virtual} - -```c -SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; -``` - -Opens a soundfile from a virtual file I/O context which is provided by the -caller. This is usually used to interface libsndfile to write/read from memory -with a stream or buffer based system. Apart from the sfvirtual and the user_data -parameters this function behaves like [sf_open()](#open). - -```c - typedef struct - { sf_vio_get_filelen get_filelen ; - sf_vio_seek seek ; - sf_vio_read read ; - sf_vio_write write ; - sf_vio_tell tell ; - } SF_VIRTUAL_IO ; -``` - -Libsndfile calls the callbacks provided by the SF_VIRTUAL_IO structure when -opening, reading and writing to the virtual file context. The user_data pointer -is a user defined context which will be available in the callbacks. - -```c -typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ; -typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ; -typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ; -typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ; -typedef sf_count_t (*sf_vio_tell) (void *user_data) ; -``` - -#### sf_vio_get_filelen - -```c -typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ; -``` - -The virtual file context must return the length of the virtual file in bytes. - -#### sf_vio_seek - -```c -typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ; -``` - -The virtual file context must seek to offset using the seek mode provided by -whence which is one of SEEK_CUR, SEEK_SET, SEEK_END. - -The return value must contain the new offset in the file. - -#### sf_vio_read - -```c -typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ; -``` - -The virtual file context must copy ("read") "count" bytes into the buffer -provided by ptr and return the count of actually copied bytes. - -#### sf_vio_write - -```c -typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ; -``` - -The virtual file context must process "count" bytes stored in the buffer passed -with ptr and return the count of actually processed bytes. - -#### sf_vio_tell - -```c -typedef sf_count_t (*sf_vio_tell) (void *user_data) ; -``` - -Return the current position of the virtual file context. - -## Format Check Function {#chek} - -```c -int sf_format_check (const SF_INFO *info) ; -``` - -This function allows the caller to check if a set of parameters in the SF_INFO -struct is valid before calling [sf_open](#open) (SFM_WRITE). - -sf_format_check() returns TRUE if the parameters are valid and FALSE otherwise. - -## File Seek Functions - -```c -sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; -``` - -The file seek functions work much like lseek in unistd.h with the exception that -the non-audio data is ignored and the seek only moves within the audio data -section of the file. In addition, seeks are defined in number of (multichannel) -frames. Therefore, a seek in a stereo file from the current position forward -with an offset of 1 would skip forward by one sample of both channels. - -like lseek(), the whence parameter can be any one of the following three values: - -SEEK_SET -: The offset is set to the start of the audio data plus offset (multichannel) -frames. - -SEEK_CUR -: The offset is set to its current location plus offset (multichannel) frames. - -SEEK_END -: The offset is set to the end of the data plus offset (multichannel) frames. - -Internally, libsndfile keeps track of the read and write locations using -separate read and write pointers. If a file has been opened with a mode of -SFM_RDWR, bitwise OR-ing the standard whence values above with either SFM_READ -or SFM_WRITE allows the read and write pointers to be modified separately. -If the SEEK_* values are used on their own, the read and write pointers are -both modified. - -Note that the frames offset can be negative and in fact should be when SEEK_END -is used for the whence parameter. - -sf_seek will return the offset in (multichannel) frames from the start of the -audio data or -1 if an error occurred (ie an attempt is made to seek beyond the -start or end of the file). - -## Error Reporting Functions {#error} - -```c -int sf_error (SNDFILE *sndfile) ; -``` - -This function returns the current error number for the given SNDFILE. - -The error number may be one of the following: - -| Name | Value | -|:----------------------------|:------| -| SF_ERR_NO_ERROR | 0 | -| SF_ERR_UNRECOGNISED_FORMAT | 1 | -| SF_ERR_SYSTEM | 2 | -| SF_ERR_MALFORMED_FILE | 3 | -| SF_ERR_UNSUPPORTED_ENCODING | 4 | - -or any one of many other internal error values. -Applications should only test the return value against error values defined in -\; as the internal error values are subject to change at any time. -For errors not in the above list, the function sf_error_number() can be used to -convert it to an error string. - -```c -const char* sf_strerror (SNDFILE *sndfile) ; -const char* sf_error_number (int errnum) ; -``` - -The error functions sf_strerror () and sf_error_number () convert the library's -internal error enumerations into text strings. - -```c -int sf_perror (SNDFILE *sndfile) ; -int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; -``` - -The functions sf_perror() and sf_error_str() are deprecated and will be dropped -from the library at some later date. - -## File Close Function {#close} - -```c -int sf_close (SNDFILE *sndfile) ; -``` - -The close function closes the file, deallocates its internal buffers and returns -0 on success or an error value otherwise. - -## Write Sync Function {#write_sync} - -```c -void sf_write_sync (SNDFILE *sndfile) ; -``` - -If the file is opened SFM_WRITE or SFM_RDWR, call the operating system's -function to force the writing of all file cache buffers to disk. If the file is -opened SFM_READ no action is taken. - -## File Read Functions {#read} - -```c -sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; -sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; -sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; -sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; -``` - -{: #readf} -```c -sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; -sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; -sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; -sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; -``` - -The file read functions fill the array pointed to by ptr with the requested -number of items or frames. - -For the frames-count functions, the frames parameter specifies the number of -frames. A frame is just a block of samples, one for each channel. - -**Care must be taken to ensure that there is enough space in the array pointed -to by ptr, to take (frames \* channels) number of items (shorts, ints, floats or -doubles).** - -For the items-count functions, the items parameter must be an integer product -of the number of channels or an error will occur. Here, an item is just a -sample. - -Note: The only difference between the "items" and "frames" versions of each read -function is the units in which the object count is specified - calling -sf_readf_short() with a count argument of N, on a SNDFILE with C channels, is -the same as calling sf_read_short with a count argument of N\*C. The buffer -pointed to by "ptr" should be the same number of bytes in each case. - -Note: The data type used by the calling program and the data format of the file -do not need to be the same. For instance, it is possible to open a 16 bit PCM -encoded WAV file and read the data using sf_read_float(). The library seamlessly -converts between the two formats on-the-fly. See [Note 1](#note-1). - -The sf_read_XXXX and sf_readf_XXXX functions return the number of items or -frames read, respectively. Unless the end of the file was reached during the -read, the return value should equal the number of objects requested. Attempts to -read beyond the end of the file will not result in an error but will cause the -read functions to return less than the number of objects requested or 0 if -already at the end of the file. When the buffer is not is not completely filled, -unused buffer space is filled by zeroes. - -## File Write Functions {#write} - -```c -sf_count_t sf_write_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; -sf_count_t sf_write_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; -sf_count_t sf_write_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; -sf_count_t sf_write_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; -``` - -{: #writef} -```c -sf_count_t sf_writef_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; -sf_count_t sf_writef_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; -sf_count_t sf_writef_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; -sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; -``` - -The file write functions write the data in the array pointed to by ptr to the -file. - -For items-count functions, the items parameter specifies the size of the array -and must be an integer product of the number of channels or an error will occur. - -For the frames-count functions, the array is expected to be large enough to hold -a number of items equal to the product of frames and the number of channels. - -As with the read functions [above](#read), the only difference in the items and -frames version of each write function is the units in which the buffer size is -specified. Again, the data type used by the calling program and the data format -of the file do not need to be the same ([Note 1](#note-1)). - -The sf_write_XXXX and sf_writef_XXXX functions respectively return the number of -items or frames written (which should be the same as the items or frames -parameter). - -## Raw File Read and Write Functions {#raw} - -```c -sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; -sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; -``` - -**Note:** Unless you are writing an external decoder/encode that uses libsndfile -to handle the file headers, you should not be using these functions. - -The raw read and write functions read raw audio data from the audio file (not to -be confused with reading RAW header-less PCM files). The number of bytes read or -written must always be an integer multiple of the number of channels multiplied -by the number of bytes required to represent one sample from one channel. - -The raw read and write functions return the number of bytes read or written -(which should be the same as the bytes parameter). - -**Note : The result of using of both regular reads/writes and raw reads/writes -on compressed file formats other than SF_FORMAT_ALAW and SF_FORMAT_ULAW is -undefined.** - -See also : [SFC_RAW_NEEDS_ENDSWAP](command.md#sfc_raw_needs_endswap). - -## Functions for Reading and Writing String Data {#string} - -```c -const char* sf_get_string (SNDFILE *sndfile, int str_type) ; -int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ; -``` - -These functions allow strings to be set on files opened for write and to be -retrieved from files opened for read where supported by the given file type. The -**str_type** parameter can be any one of the following string types: - -| Name | Value | Description | -|:-------------------|:------|:--------------| -| SF_STR_TITLE | 0x01 | Title. | -| SF_STR_COPYRIGHT | 0x02 | Copyright. | -| SF_STR_SOFTWARE | 0x03 | Software. | -| SF_STR_ARTIST | 0x04 | Artist. | -| SF_STR_COMMENT | 0x05 | Comment. | -| SF_STR_DATE | 0x06 | Date. | -| SF_STR_ALBUM | 0x07 | Album. | -| SF_STR_LICENSE | 0x08 | License. | -| SF_STR_TRACKNUMBER | 0x09 | Track number. | -| SF_STR_GENRE | 0x10 | Genre. | - -The sf_get_string() function returns the specified string if it exists and a -NULL pointer otherwise. In addition to the string ids above, SF_STR_FIRST (== -SF_STR_TITLE) and SF_STR_LAST (always the same as the highest numbers string id) -are also available to allow iteration over all the available string ids. - -The sf_set_string() function sets the string data. It returns zero on success -and non-zero on error.The error code can be converted to a string using -sf_error_number(). - -Strings passed to and retrieved from these two functions are assumed to be -utf-8. However, while formats like Ogg/Vorbis and FLAC fully support utf-8, -others like WAV and AIFF officially only support ASCII. Writing utf-8 strings to -WAV and AIF files with libsndfile will work when read back with libsndfile, but -may not work with other programs. - -The suggested method of dealing with tags retrieved using sf_get_string() is to -assume they are utf-8. Similarly if you have a string in some exotic format like -utf-16, it should be encoded to utf-8 before being written using libsndfile. - -## Function for retrieving library version {#version_string} - -```c -const char *sf_version_string (void) ; -``` - -Return the library version string. - -## Function for retrieving current byterate {#current_byterate} - -```c -int sf_current_byterate (SNDFILE *sndfile) ; -``` - -Return the current byterate at this point in the file. The byte rate in this -case is the number of bytes per second of audio data. For instance, for a -stereo, 18 bit PCM encoded file with an 16kHz sample rate, the byte rate -would be 2 (stereo) \* 2 (two bytes per sample) * 16000 => 64000 bytes/sec. - -For some file formats the returned value will be accurate and exact, for some -it will be a close approximation, for some it will be the average bitrate for -the whole file and for some it will be a time varying value that was accurate -when the file was most recently read or written. - -To get the bitrate, multiple this value by 8. - -`sf_current_byterate` returns byte per second or -1 if byterate is -unknown. - -## Functions to get and set chunks from within a sound file - -These functions allow the getting and setting of chunks within a sound file (for -those formats which allow it). - -These functions fail safely. Specifically, they will not allow you to overwrite -existing chunks or add extra versions of format specific reserved chunks but -should allow you to retrieve any and all chunks (may not be implemented for all -chunks or all file formats). - -### sf_set_chunk - -```c -int sf_set_chunk (SNDFILE *sndfile, const SF_CHUNK_INFO *chunk_info) ; -``` - -Set the specified chunk info (must be done before any audio data is written to -the file). This will fail for format specific reserved chunks. The -`chunk_info->data` pointer must be valid until the file is closed. - -The `SF_CHUNK_INFO` struct is documented as follows: - -```c -struct SF_CHUNK_INFO -{ char id [64] ; /* The chunk identifier. */ - unsigned id_size ; /* The size of the chunk identifier. */ - unsigned datalen ; /* The size of that data. */ - void *data ; /* Pointer to the data. */ -} ; - typedef struct SF_CHUNK_INFO SF_CHUNK_INFO ; -``` - -`sf_set_chunk` returns `SF_ERR_NO_ERROR` on success or non-zero on failure. - -### sf_get_chunk_iterator - -```c -SF_CHUNK_ITERATOR * -sf_get_chunk_iterator (SNDFILE *sndfile, const SF_CHUNK_INFO *chunk_info) ; -``` - -Get an iterator for all chunks matching `chunk_info`. - -`SF_CHUNK_ITERATOR` is an opaque structure to an iterator over the all chunks of -a given id and defined as follows: - -```c -typedef struct SF_CHUNK_ITERATOR SF_CHUNK_ITERATOR ; -``` - -The iterator will point to the first chunk matching `chunk_info`. Chunks are -matching, if (`chunk_info->id`) matches the first (`chunk_info->id_size`) bytes -of a chunk found in the `SNDFILE*` handle. If `chunk_info` is `NULL`, an -iterator to all chunks in the `SNDFILE*` handle is returned. The values of -`chunk_info->datalen` and `chunk_info->data` are ignored. If no matching chunks -are found in the sndfile, `NULL` is returned. - -The returned iterator will stay valid until one of the following occurs: - -* The sndfile is closed. -* A new chunk is added using [`sf_set_chunk()`](#sf_set_chunk). -* Another chunk iterator function is called on the same `SNDFILE*` - handle that causes the iterator to be modified. - -The memory for the iterator belongs to the SNDFILE* handle and is freed when -[sf_close](#close) is called. - -### sf_next_chunk_iterator - -```c -sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) ; -``` - -Iterate through chunks by incrementing the iterator. - -Increments the iterator and returns a handle to the new one. After this call, -iterator will no longer be valid, and you must use the newly returned handle -from now on. The returned handle can be used to access the next chunk matching -the criteria as defined in [sf_get_chunk_iterator](#sf_get_chunk_iterator). -If iterator points to the last chunk, this will free all resources associated -with iterator and return `NULL`. The returned iterator will stay valid until -`sf_get_next_chunk_iterator` is called again, the sndfile is closed or a new -chunk us added. - -### sf_get_chunk_size - -```c -int -sf_get_chunk_size (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ; -``` - -Get the size of the specified chunk. - -If the specified chunk exists, the size will be returned in the `datalen` field -of the `SF_CHUNK_INFO` struct. Additionally, the id of the chunk will be copied -to the `id` field of the `SF_CHUNK_INFO` struct and it's `id_size` field will be -updated accordingly. - -If the chunk doesn't exist `chunk_info->datalen` will be zero, and the `id` and -`id_size` fields will be undefined. - -The function will return `SF_ERR_NO_ERROR` on success or non-zero on failure. - -### sf_get_chunk_data - -```c -int -sf_get_chunk_data (const SF_CHUNK_ITERATOR *it, SF_CHUNK_INFO *chunk_info) ; -``` - -Get the specified chunk data. - -If the specified chunk exists, up to `chunk_info->datalen` bytes of the chunk -data will be copied into the `chunk_info->data` buffer (allocated by the caller) -and the `chunk_info->datalen` field updated to reflect the size of the data. The -`id` and `id_size` field will be updated according to the retrieved chunk. If -the chunk doesn't exist `chunk_info->datalen` will be zero, and the `id` and -`id_size` fields will be undefined. - -The function will return `SF_ERR_NO_ERROR` on success or non-zero on failure. - -## Note 1 - -When converting between integer PCM formats of differing size (e.g. using -sf_read_int() to read a 16 bit PCM encoded WAV file) libsndfile obeys one simple -rule: - -Whenever integer data is moved from one sized container to another sized -container, the most significant bit in the source container will become the most -significant bit in the destination container. - -When converting between integer data and floating point data, different rules -apply. The default behaviour when reading floating point data (sf_read_float() -or sf_read_double ()) from a file with integer data is normalisation. Regardless -of whether data in the file is 8, 16, 24 or 32 bit wide, the data will be read -as floating point data in the range [-1.0, 1.0]. Similarly, data in the range -[-1.0, 1.0] will be written to an integer PCM file so that a data value of 1.0 -will be the largest allowable integer for the given bit width. This -normalisation can be turned on or off using the [sf_command](command.md) -interface. - -## Note 2 - -Reading a file containing floating point data (allowable with WAV, AIFF, AU and -other file formats) using integer read methods (sf_read_short() or -sf_read_int()) can produce unexpected results. For instance the data in the file -may have a maximum absolute value < 1.0 which would mean that all sample -values read from the file will be zero. In order to read these files correctly -using integer read methods, it is recommended that you use the -[sf_command](command.md) interface, a command of -[SFC_SET_SCALE_FLOAT_INT_READ](command.md#sfc_set_scale_float_int_read) and a -parameter of SF_TRUE to force correct scaling. diff --git a/Engine/lib/libsndfile/docs/bugs.md b/Engine/lib/libsndfile/docs/bugs.md deleted file mode 100644 index 9f2f00ce5..000000000 --- a/Engine/lib/libsndfile/docs/bugs.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -layout: page ---- - -# Reporting Bugs in libsndfile - -Before even attempting to report a bug in libsndfile please make sure you have -read the [Frequently Asked Questions](FAQ.md). If you are having a problem -writing code using libsndfile make sure you read the -[Application Programming Interface](api.md) documentation. - -That said, I am interested in finding and fixing all genuine bugs in libsndfile. -Bugs I want to fix include any of the following problems (and probably others): - -- Compilation problems on new platforms. -- Errors being detected during the `make check` process. -- Segmentation faults occurring inside libsndfile. -- libsndfile hanging when opening a file. -- Supported sound file types being incorrectly read or written. -- Omissions, errors or spelling mistakes in the documentation. - -When submitting a bug report you must include: - -- Your system (CPU and memory size should be enough). -- The operating system you are using. -- Whether you are using a package provided by your distribution or you compiled - it yourself. -- If you compiled it yourself, the compiler you are using. (Also make sure to - run `make check`.) -- A description of the problem. -- Information generated by the sndfile-info program (see next paragraph). -- If you are having problems with sndfile-play and ALSA on Linux, I will need - information about your kernel, ALSA version, compiler version, whether you - compiled the kernel/ALSA your self or installed from a package etc. - -If libsndfile compiles and installs correctly but has difficulty reading a -particular file or type of file you should run the **sndfile-info** program -(from the examples directory of the libsndfile distribution) on the file. See -[here](sndfile_info.md) for an example of the use of the **sndfile-info** -program. - -Please do not send me a sound file which fails to open under libsndfile unless -I specifically ask you to. The above information should usually suffice for most -problems. - -Once you have the above information you should submit a ticket on the libsndfile -[GitHub issue tracker](https://github.com/libsndfile/libsndfile/issues). diff --git a/Engine/lib/libsndfile/docs/command.md b/Engine/lib/libsndfile/docs/command.md deleted file mode 100644 index 53e01926c..000000000 --- a/Engine/lib/libsndfile/docs/command.md +++ /dev/null @@ -1,2016 +0,0 @@ ---- -layout: page -title: libsndfile : the sf_command function. ---- - -# sf_command - -```c -int sf_command (SNDFILE *sndfile, int cmd, void *data, int datasize) ; -``` - -This function allows the caller to retrieve information from or change aspects -of the library behaviour. Examples include retrieving a string containing the -library version or changing the scaling applied to floating point sample data -during read and write. Most of these operations are performed on a per-file -basis. - -The cmd parameter is an integer identifier which is defined in *sndfile.h*. All -of the valid command identifiers have names beginning with "SFC_". Data is -passed to and returned from the library by use of a void pointer. The library -will not read or write more than datasize bytes from the void pointer. For some -calls no data is required in which case data should be NULL and datasize may be -used for some other purpose. - -The available commands are as follows: - -| Name | Description | -|:------------------------------------------------------------------|:--------------------------------------------------------| -| [SFC_GET_LIB_VERSION](#sfc_get_lib_version) | Retrieve the version of the library as a string. | -| [SFC_GET_LOG_INFO](#sfc_get_log_info) | Retrieve the internal per-file operation log. | -| [SFC_GET_CURRENT_SF_INFO](#sfc_get_current_sf_info) | Retrieve `SF_INFO` struct of opened file. | -| [SFC_CALC_SIGNAL_MAX](#sfc_calc_signal_max) | Calculate the measured maximum signal value. | -| [SFC_CALC_NORM_SIGNAL_MAX](#sfc_calc_norm_signal_max) | Calculate the measured normalised maximum signal value. | -| [SFC_CALC_MAX_ALL_CHANNELS](#sfc_calc_max_all_channels) | Calculate the peak value for each channel. | -| [SFC_CALC_NORM_MAX_ALL_CHANNELS](#sfc_calc_norm_max_all_channels) | Calculate the normalised peak for each channel. | -| [SFC_GET_SIGNAL_MAX](#sfc_get_signal_max) | Retrieve the peak value for the file. | -| [SFC_GET_MAX_ALL_CHANNELS](#sfc_get_max_all_channels) | Retrieve the peak value for each channel. | -| [SFC_SET_NORM_FLOAT](#sfc_set_norm_float) | Set float normalisation behaviour. | -| [SFC_SET_NORM_DOUBLE](#sfc_set_norm_double) | Set double normalisation behaviour. | -| [SFC_GET_NORM_FLOAT](#sfc_get_norm_float) | Get float normalisation behaviour. | -| [SFC_GET_NORM_DOUBLE](#sfc_get_norm_double) | Get double normalisation behaviour. | -| [SFC_SET_SCALE_FLOAT_INT_READ](#sfc_set_scale_float_int_read) | Control scale factor on read. | -| [SFC_SET_SCALE_INT_FLOAT_WRITE](#sfc_set_scale_int_float_write) | Control scale factor on write. | -| [SFC_GET_SIMPLE_FORMAT_COUNT](#sfc_get_simple_format_count) | Get simple formats count. | -| [SFC_GET_SIMPLE_FORMAT](#sfc_get_simple_format) | Get information about a simple format. | -| [SFC_GET_FORMAT_INFO](#sfc_get_format_info) | Get information about a major or subtype format. | -| [SFC_GET_FORMAT_MAJOR_COUNT](#sfc_get_format_major_count) | Get the number of major formats. | -| [SFC_GET_FORMAT_MAJOR](#sfc_get_format_major) | Get information about a major format type. | -| [SFC_GET_FORMAT_SUBTYPE_COUNT](#sfc_get_format_subtype_count) | Get the number of subformats. | -| [SFC_GET_FORMAT_SUBTYPE](#sfc_get_format_subtype) | Get information about a subformat. | -| [SFC_SET_ADD_PEAK_CHUNK](#sfc_set_add_peak_chunk) | Control PEAK chunk write to WAV and AIFF. | -| [SFC_UPDATE_HEADER_NOW](#sfc_update_header_now) | Update the file header in write mode on demand. | -| [SFC_SET_UPDATE_HEADER_AUTO](#sfc_set_update_header_auto) | Update the file header on each write. | -| [SFC_FILE_TRUNCATE](#sfc_file_truncate) | Truncate a file open for write or for read/write. | -| [SFC_SET_RAW_START_OFFSET](#sfc_set_raw_start_offset) | Change the data start offset for raw files. | -| SFC_SET_DITHER_ON_WRITE | Not implemented. | -| SFC_SET_DITHER_ON_READ | Not implemented. | -| SFC_GET_DITHER_INFO_COUNT | Not implemented. | -| SFC_GET_DITHER_INFO | Not implemented. | -| [SFC_SET_CLIPPING](#sfc_set_clipping) | Control automatic clipping behaviour. | -| [SFC_GET_CLIPPING](#sfc_get_clipping) | Get current clipping setting. | -| [SFC_GET_EMBED_FILE_INFO](#sfc_get_embed_file_info) | Get information about embedded audio files. | -| [SFC_WAVEX_GET_AMBISONIC](#sfc_wavex_get_ambisonic) | Test a WAVEX file for Ambisonic format. | -| [SFC_WAVEX_SET_AMBISONIC](#sfc_wavex_set_ambisonic) | Modify a WAVEX header for Ambisonic format. | -| [SFC_SET_VBR_ENCODING_QUALITY](#sfc_set_vbr_encoding_quality) | Set the Variable Bit Rate encoding quality. | -| [SFC_SET_OGG_PAGE_LATENCY_MS](#sfc_set_ogg_page_latency_ms) | Set Ogg page latency for Opus file. | -| [SFC_GET_OGG_STREAM_SERIALNO](#sfc_get_ogg_stream_serialno) | Get Ogg stream serial number. | -| [SFC_SET_COMPRESSION_LEVEL](#sfc_set_compression_level) | Set the compression level. | -| [SFC_RAW_DATA_NEEDS_ENDSWAP](#sfc_raw_data_needs_endswap) | Determine if raw data needs endswapping. | -| [SFC_GET_BROADCAST_INFO](#sfc_get_broadcast_info) | Get the Broadcast Chunk info. | -| [SFC_SET_BROADCAST_INFO](#sfc_set_broadcast_info) | Set the Broadcast Chunk info. | -| [SFC_GET_CHANNEL_MAP_INFO](#sfc_get_channel_map_info) | Get the channel map info. | -| [SFC_SET_CHANNEL_MAP_INFO](#sfc_set_channel_map_info) | Set the channel map info. | -| [SFC_SET_CART_INFO](#sfc_set_cart_info) | Set the Cart Chunk info. | -| [SFC_GET_CART_INFO](#sfc_get_cart_info) | Get the Cart Chunk info. | -| [SFC_GET_LOOP_INFO](#sfc_get_loop_info) | Get loop info. | -| [SFC_GET_INSTRUMENT](#sfc_get_instrument) | Get instrument info. | -| [SFC_SET_INSTRUMENT](#sfc_set_instrument) | Set instrument info. | -| [SFC_GET_CUE_COUNT](#sfc_get_cue_count) | Get the cue marker count. | -| [SFC_GET_CUE](#sfc_get_cue) | Get cue marker info. | -| [SFC_SET_CUE](#sfc_set_cue) | Set cue marker info. | -| [SFC_RF64_AUTO_DOWNGRADE](#sfc_rf64_auto_downgrade) | Set auto downgrade from RF64 to WAV. | -| [SFC_GET_ORIGINAL_SAMPLERATE](#sfc_get_original_samplerate) | Get original samplerate metadata. | -| [SFC_SET_ORIGINAL_SAMPLERATE](#sfc_set_original_samplerate) | Set original samplerate metadata. | -| [SFC_GET_BITRATE_MODE](#sfc_get_bitrate_mode) | Get bitrate mode. | -| [SFC_SET_BITRATE_MODE](#sfc_set_bitrate_mode) | Set bitrate mode. | - ---- - -## SFC_GET_LIB_VERSION - -Retrieve the version of the library as a string. - -### Parameters - -sndfile -: Not used - -cmd -: SFC_GET_LIB_VERSION - -data -: A pointer to a char buffer - -datasize -: The size of the buffer - -### Examples - -```c -char buffer [128] ; -sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ; -``` - -### Return value - -This call will return the length of the retrieved version string. - -### Notes - -The string returned in the buffer passed to this function will not overflow the -buffer and will always be null terminated . - -## SFC_GET_LOG_INFO - -Retrieve the internal per-file operation log. - -This log buffer can often contain a good reason for why libsndfile failed to -open a particular file. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_LOG_INFO - -data -: A pointer to a char buffer - -datasize -: The size of the buffer - -Example: - -```c -char buffer [2048] ; -sf_command (sndfile, SFC_GET_LOG_INFO, buffer, sizeof (buffer)) ; -``` - -### Return value - -This call will return the length of the retrieved version string. - -### Notes - -The string returned in the buffer passed to this function will not overflow the -buffer and will always be null terminated. - -## SFC_GET_CURRENT_SF_INFO - -Retrieve `SF_INFO` struct of opened file. - -`SFC_GET_CURRENT_SF_INFO` command copies `SF_INFO` struct of `sndfile` object to -provided buffer. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_CURRENT_SF_INFO - -data -: A pointer to a valid SF_INFO* pointer - -datasize -: sizeof (SF_INFO) - -### Examples - -```c -SF_INFO sfinfo ; -sf_command (sndfile, SFC_GET_CURRENT_SF_INFO, sfinfo, sizeof (SF_INFO)) ; -``` - -### Return value - -Zero on success, non-zero otherwise. - -## SFC_CALC_SIGNAL_MAX - -Retrieve the measured maximum signal value. This involves reading through the -whole file which can be slow on large files. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_CALC_SIGNAL_MAX - -data -: A pointer to a double - -datasize -: sizeof (double) - -### Examples - -```c -double max_val ; -sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &max_val, sizeof (max_val)) ; -``` - -### Return value - -Zero on success, non-zero otherwise. - -## SFC_CALC_NORM_SIGNAL_MAX - -Retrieve the measured normalised maximum signal value. This involves reading -through the whole file which can be slow on large files. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_CALC_NORM_SIGNAL_MAX - -data -: A pointer to a double - -datasize -: sizeof (double) - -### Examples - -```c -double max_val ; -sf_command (sndfile, SFC_CALC_NORM_SIGNAL_MAX, &max_val, sizeof (max_val)) ; -``` - -### Return value - -Zero on success, non-zero otherwise. - -## SFC_CALC_MAX_ALL_CHANNELS - -Calculate the peak value (ie a single number) for each channel. This involves -reading through the whole file which can be slow on large files. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_CALC_MAX_ALL_CHANNELS - -data -: A pointer to a double - -datasize -: sizeof (double) * number_of_channels - -### Examples - -```c -double peaks [number_of_channels] ; -sf_command (sndfile, SFC_CALC_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ; -``` - -### Return value - -Zero if peaks have been calculated successfully and non-zero otherwise. - -## SFC_CALC_NORM_MAX_ALL_CHANNELS - -Calculate the normalised peak for each channel. This involves reading through -the whole file which can be slow on large files. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_CALC_NORM_MAX_ALL_CHANNELS - -data -: A pointer to a double - -datasize -: sizeof (double) * number_of_channels - -### Examples - -```c -double peaks [number_of_channels] ; -sf_command (sndfile, SFC_CALC_NORM_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ; -``` - -### Return value - -Zero if peaks have been calculated successfully and non-zero otherwise. - -## SFC_GET_SIGNAL_MAX - -Retrieve the peak value for the file as stored in the file header. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_SIGNAL_MAX - -data -: A pointer to a double - -datasize -: sizeof (double) - -### Examples - -```c -double max_peak ; -sf_command (sndfile, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ; -``` - -### Return value - -SF_TRUE if the file header contained the peak value. SF_FALSE -otherwise. - -## SFC_GET_MAX_ALL_CHANNELS - -Retrieve the peak value for the file as stored in the file header. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_SIGNAL_MAX - -data -: A pointer to an array of doubles - -datasize -: sizeof (double) * number_of_channels - -### Example - -```c -double peaks [number_of_channels] ; -sf_command (sndfile, SFC_GET_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ; -``` - -### Return value - -SF_TRUE if the file header contains per channel peak values for the file, -SF_FALSE otherwise. - -## SFC_SET_NORM_FLOAT - -This command only affects data read from or written to using the -floating point -functions: - -```c -size_t sf_read_float (SNDFILE *sndfile, float *ptr, size_t items) ; -size_t sf_readf_float (SNDFILE *sndfile, float *ptr, size_t frames) ; - -size_t sf_write_float (SNDFILE *sndfile, float *ptr, size_t items) ; -size_t sf_writef_float (SNDFILE *sndfile, float *ptr, size_t frames) ; -``` - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_NORM_FLOAT - -data -: NULL - -datasize -: SF_TRUE or SF_FALSE - -For read operations setting normalisation to SF_TRUE means that the data from -all subsequent reads will be be normalised to the range [-1.0, 1.0]. - -For write operations, setting normalisation to SF_TRUE means than all data -supplied to the float write functions should be in the range [-1.0, 1.0] and -will be scaled for the file format as necessary. - -For both cases, setting normalisation to SF_FALSE means that no scaling will -take place. - -### Examples - -```c -sf_command (sndfile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE) ; - -sf_command (sndfile, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; -``` - -### Return value - -Returns the previous float normalisation mode. - -## SFC_SET_NORM_DOUBLE - -This command only affects data read from or written to using the double -precision floating point -functions: - -```c -size_t sf_read_double (SNDFILE *sndfile, double *ptr, size_t items) ; -size_t sf_readf_double (SNDFILE *sndfile, double *ptr, size_t frames) ; - -size_t sf_write_double (SNDFILE *sndfile, double *ptr, size_t items) ; -size_t sf_writef_double (SNDFILE *sndfile, double *ptr, size_t frames) ; -``` - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_NORM_DOUBLE - -data -: NULL - -datasize -: SF_TRUE or SF_FALSE - -For read operations setting normalisation to SF_TRUE means that the data from -all subsequent reads will be be normalised to the range [-1.0, 1.0]. - -For write operations, setting normalisation to SF_TRUE means than all data -supplied to the double write functions should be in the range [-1.0, 1.0] and -will be scaled for the file format as necessary. - -For both cases, setting normalisation to SF_FALSE means that no scaling will -take place. - -### Examples - -```c -sf_command (sndfile, SFC_SET_NORM_DOUBLE, NULL, SF_TRUE) ; - -sf_command (sndfile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; -``` - -### Return value - -Returns the previous double normalisation mode. - -## SFC_GET_NORM_FLOAT - -Retrieve the current float normalisation mode. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_NORM_FLOAT - -data -: NULL - -datasize -: anything - -### Examples - -```c -normalisation = sf_command (sndfile, SFC_GET_NORM_FLOAT, NULL, 0) ; -``` - -### Return value - -Returns TRUE if normalisation is on and FALSE otherwise. - -## SFC_GET_NORM_DOUBLE - -Retrieve the current float normalisation mode. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_NORM_DOUBLE - -data -: NULL - -datasize -: anything - -Example: - -```c -normalisation = sf_command (sndfile, SFC_GET_NORM_DOUBLE, NULL, 0) ; -``` - -### Return value - -Returns TRUE if normalisation is on and FALSE otherwise. - -## SFC_SET_SCALE_FLOAT_INT_READ - -Set/clear the scale factor when integer (short/int) data is read from a file -containing floating point data. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd: -SFC_SET_SCALE_FLOAT_INT_READ - -data -: NULL - -datasize -: TRUE or FALSE - -Example: - -```c -sf_command (sndfile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ; -``` - -### Return value - -Returns the previous `SFC_SET_SCALE_FLOAT_INT_READ` setting for this file. - -## SFC_SET_SCALE_INT_FLOAT_WRITE - -Set/clear the scale factor when integer (short/int) data is written to a file as -floating point data. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_SCALE_INT_FLOAT_WRITE - -data -: NULL - -datasize -: TRUE or FALSE - -### Examples - -```c -sf_command (sndfile, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ; -``` - -### Return value - -Returns the previous `SFC_SET_SCALE_INT_FLOAT_WRITE` setting for this file. - -## SFC_GET_SIMPLE_FORMAT_COUNT - -Retrieve the number of simple formats supported by libsndfile. - -### Parameters - -sndfile -: Not used. - -cmd -: SFC_GET_SIMPLE_FORMAT_COUNT - -data -: a pointer to an int - -datasize -: sizeof (int) - -### Examples - -```c -int count ; -sf_command (sndfile, SFC_GET_SIMPLE_FORMAT_COUNT, &count, sizeof (int)) ; -``` - -### Return value - -`0`. - -## SFC_GET_SIMPLE_FORMAT - -Retrieve information about a simple format. - -### Parameters - -sndfile -: Not used. - -cmd -: SFC_GET_SIMPLE_FORMAT - -data -: a pointer to an SF_FORMAT_INFO struct - -datasize -: sizeof (SF_FORMAT_INFO) - -The SF_FORMAT_INFO struct is defined in *sndfile.h* as: - -```c -typedef struct -{ int format ; - const char *name ; - const char *extension ; -} SF_FORMAT_INFO ; -``` - -When `sf_command()` is called with `SF_GET_SIMPLE_FORMAT`, the value of the -format field should be the format number (ie 0 \<= format \<= count value -obtained using `SF_GET_SIMPLE_FORMAT_COUNT). - -### Examples - -```c -SF_FORMAT_INFO format_info ; -int k, count ; - -sf_command (sndfile, SFC_GET_SIMPLE_FORMAT_COUNT, &count, sizeof (int)) ; - -for (k = 0 ; k < count ; k++) -{ format_info.format = k ; - sf_command (sndfile, SFC_GET_SIMPLE_FORMAT, &format_info, sizeof (format_info)) ; - printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ; - } ; -``` - -### Return value - -0 on success and non-zero otherwise. - -The value of the format field of the `SF_FORMAT_INFO` struct will be a value -which can be placed in the format field of an `SF_INFO` struct when a file is to -be opened for write. The name field will contain a char\* pointer to the name of -the string, eg. "WAV (Microsoft 16 bit PCM)". The extension field will contain -the most commonly used file extension for that file type. - -## SFC_GET_FORMAT_INFO - -Retrieve information about a major or subtype format. - -### Parameters - -sndfile -: Not used. - -cmd -: SFC_GET_FORMAT_INFO - -data -: a pointer to an SF_FORMAT_INFO struct - -datasize -: sizeof (SF_FORMAT_INFO) - -The `SF_FORMAT_INFO` struct is defined in \ as: - -```c -typedef struct -{ int format ; - const char *name ; - const char *extension ; -} SF_FORMAT_INFO ; -``` - -When `sf_command()` is called with `SF_GET_FORMAT_INFO`, the format field is -examined and if (format & `SF_FORMAT_TYPEMASK`) is a valid format then the -struct is filled in with information about the given major type. If (format & -`SF_FORMAT_TYPEMASK`) is FALSE and (format & `SF_FORMAT_SUBMASK`) is a valid -subtype format then the struct is filled in with information about the given -subtype. - -### Examples - -```c -SF_FORMAT_INFO format_info ; - -format_info.format = SF_FORMAT_WAV ; -sf_command (sndfile, SFC_GET_FORMAT_INFO, &format_info, sizeof (format_info)) ; -printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ; - -format_info.format = SF_FORMAT_ULAW ; -sf_command (sndfile, SFC_GET_FORMAT_INFO, &format_info, sizeof (format_info)) ; -printf ("%08x %s\n", format_info.format, format_info.name) ; -``` - -### Return value - -0 on success and non-zero otherwise. - -## SFC_GET_FORMAT_MAJOR_COUNT - -Retrieve the number of major formats. - -### Parameters - -sndfile -: Not used. - -cmd -: SFC_GET_FORMAT_MAJOR_COUNT - -data -: a pointer to an int - -datasize -: sizeof (int) - -### Examples - -```c -int count ; -sf_command (sndfile, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ; -``` - -### Return value - -0. - -## SFC_GET_FORMAT_MAJOR - -Retrieve information about a major format type. - -### Parameters - -sndfile -: Not used. - -cmd -: SFC_GET_FORMAT_MAJOR - -data -: a pointer to an SF_FORMAT_INFO struct - -datasize -: sizeof (SF_FORMAT_INFO) - -### Examples - -```c -SF_FORMAT_INFO format_info ; -int k, count ; - -sf_command (sndfile, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ; - -for (k = 0 ; k < count ; k++) -{ format_info.format = k ; - sf_command (sndfile, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info)) ; - printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ; - } ; -``` - -For a more comprehensive example, see the program `list_formats.c` in the -`examples/` directory of the libsndfile source code distribution. - -### Return value - -0 on success and non-zero otherwise. - -The value of the format field will be one of the major format identifiers such -as `SF_FORMAT_WAV` or `SF_FORMAT`_AIFF. The name field will contain a char\* -pointer to the name of the string, eg. "WAV (Microsoft)". The extension field -will contain the most commonly used file extension for that file type. - -## SFC_GET_FORMAT_SUBTYPE_COUNT - -Retrieve the number of subformats. - -### Parameters - -sndfile -: Not used. - -cmd -: SFC_GET_FORMAT_SUBTYPE_COUNT - -data -: a pointer to an int - -datasize -: sizeof (int) - -### Examples - -```c -int count ; -sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ; -``` - -### Return value - -Returns zero. - -## SFC_GET_FORMAT_SUBTYPE - -Enumerate the subtypes (this function does not translate a subtype into a string -describing that subtype). A typical use case might be retrieving a string -description of all subtypes so that a dialog box can be filled in. - -### Parameters - -sndfile -: Not used. - -cmd -: SFC_GET_FORMAT_SUBTYPE - -data -: a pointer to an SF_FORMAT_INFO struct - -datasize -: sizeof (SF_FORMAT_INFO) - -### Examples - -Example 1: Retrieve all sybtypes supported by the WAV format. - -```c -SF_FORMAT_INFO format_info ; -int k, count ; - -sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ; - -for (k = 0 ; k < count ; k++) -{ format_info.format = k ; - sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)) ; - if (! sf_format_check (format_info.format | SF_FORMAT_WAV)) - continue ; - printf ("%08x %s\n", format_info.format, format_info.name) ; - } ; -``` - -Example 2: Print a string describing the `SF_FORMAT_PCM_16` subtype. - -```c -SF_FORMAT_INFO format_info ; -int k, count ; - -sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ; - -for (k = 0 ; k < count ; k++) -{ format_info.format = k ; - sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)) ; - if (format_info.format == SF_FORMAT_PCM_16) - { printf ("%08x %s\n", format_info.format, format_info.name) ; - break ; - } ; - } ; -``` - -For a more comprehensive example, see the program `list_formats.c` in the -`examples/` directory of the libsndfile source code distribution. - -### Return value - -0 on success and non-zero otherwise. - -The value of the format field will be one of the major format identifiers such -as `SF_FORMAT_WAV` or `SF_FORMAT_AIFF`. The name field will contain a char\* -pointer to the name of the string; for instance "WAV (Microsoft)" or "AIFF -(Apple/SGI)". The extension field will be a NULL pointer. - -## SFC_SET_ADD_PEAK_CHUNK - -By default, WAV and AIFF files which contain floating point data (subtype -`SF_FORMAT_FLOAT` or `SF_FORMAT_DOUBLE`) have a PEAK chunk. By using this -command, the addition of a PEAK chunk can be turned on or off. - -**Note**: This call must be made before any data is written to the file. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_ADD_PEAK_CHUNK - -data -: Not used (should be NULL) - -datasize -: TRUE or FALSE. - -### Examples - -```c -/* Turn on the PEAK chunk. */ -sf_command (sndfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ; - -/* Turn off the PEAK chunk. */ -sf_command (sndfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ; -``` - -### Return value - -Returns SF_TRUE if the peak chunk will be written after this call. Returns -SF_FALSE if the peak chunk will not be written after this call. - -## SFC_UPDATE_HEADER_NOW - -The header of an audio file is normally written by libsndfile when the file is -closed using [**sf_close()**](api.md#file-close-function). - -There are however situations where large files are being generated and it would -be nice to have valid data in the header before the file is complete. Using this -command will update the file header to reflect the amount of data written to the -file so far. Other programs opening the file for read (before any more data is -written) will then read a valid sound file header. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_UPDATE_HEADER_NOW - -data -: Not used (should be NULL) - -datasize -: Not used. - -### Examples - -```c -/* Update the header now. */ -sf_command (sndfile, SFC_UPDATE_HEADER_NOW, NULL, 0) ; -``` - -### Return value - -Returns zero. - -## SFC_SET_UPDATE_HEADER_AUTO - -Similar to `SFC_UPDATE_HEADER_NOW` but updates the header at the end of every -call to the [sf_write\*](api.md#write) functions. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_UPDATE_HEADER_AUTO - -data -: Not used (should be NULL) - -datasize -: `SF_TRUE` or `SF_FALSE` - -### Examples - -```c -/* Turn on auto header update. */ -sf_command (sndfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) ; - -/* Turn off auto header update. */ -sf_command (sndfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_FALSE) ; -``` - -### Return value - -TRUE if auto update header is now on; FALSE otherwise. - -## SFC_FILE_TRUNCATE - -Truncate a file that was opened for write or read/write. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_FILE_TRUNCATE - -data -: A pointer to an sf_count_t. - -datasize -: sizeof (sf_count_t) - -Truncate the file to the number of frames specified by the sf_count_t pointed to -by data. After this command, both the read and the write pointer will be at the -new end of the file. This command will fail (returning non-zero) if the -requested truncate position is beyond the end of the file. - -### Examples - -```c -/* Truncate the file to a length of 20 frames. */ -sf_count_t frames = 20 ; -sf_command (sndfile, SFC_FILE_TRUNCATE, &frames, sizeof (frames)) ; -``` - -### Return value - -Zero on success, non-zero otherwise. - -## SFC_SET_RAW_START_OFFSET - -Change the data start offset for files opened up as `SF_FORMAT_RAW`. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_RAW_START_OFFSET - -data -: A pointer to an sf_count_t. - -datasize -: sizeof (sf_count_t) - -For a file opened as format `SF_FORMAT_RAW`, set the data offset to the value -given by `data`. - -### Examples - -```c -/* Reset the data offset to 5 bytes from the start of the file. */ -sf_count_t offset = 5 ; -sf_command (sndfile, SFC_SET_RAW_START_OFFSET, &offset, sizeof (offset)) ; -``` - -### Return value - -Zero on success, non-zero otherwise. - -## SFC_SET_CLIPPING - -Turn on/off automatic clipping when doing floating point to integer conversion. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_CLIPPING - -data -: NULL - -datasize -: SF_TRUE or SF_FALSE. - -Turn on (datasize == SF_TRUE) or off (datasize == SF_FALSE) clipping. - -### Examples - -```c -sf_command (sndfile, SFC_SET_CLIPPING, NULL, SF_TRUE) ; -``` - -### Return value - -Clipping mode (SF_TRUE or SF_FALSE). - -## SFC_GET_CLIPPING - -Turn on/off automatic clipping when doing floating point to integer conversion. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_CLIPPING - -data -: NULL - -datasize -: 0 - -Retrieve the current cliiping setting. - -### Examples - -```c -sf_command (sndfile, SFC_GET_CLIPPING, NULL, 0) ; -``` - -### Return value - -Clipping mode (SF_TRUE or SF_FALSE). - -## SFC_GET_EMBED_FILE_INFO - -Get the file offset and file length of a file enbedded within another larger -file. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_EMBED_FILE_INFO - -data -: a pointer to an SF_EMBED_FILE_INFO struct - -datasize -: sizeof (SF_EMBED_FILE_INFO) - -The `SF_EMBED_FILE_INFO` struct is defined in *sndfile.h* as: - -```c -typedef struct -{ sf_count_t offset ; - sf_count_t length ; -} SF_EMBED_FILE_INFO ; -``` - -### Return value - -0 on success and non-zero otherwise. - -The value of the offset field of the `SF_EMBED_FILE_INFO` struct will be the -offsets in bytes from the start of the outer file to the start of the audio -file. The value of the offset field of the `SF_EMBED_FILE_INFO` struct will be -the length in bytes of the embedded file. - -## SFC_WAVEX_GET_AMBISONIC - -Test if the current file has the GUID of a WAVEX file for any of the Ambisonic -formats. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_WAVEX_GET_AMBISONIC - -data -: NULL - -datasize -: 0 - -The Ambisonic WAVEX formats are defined here: -. - -### Return value - -`SF_AMBISONIC_NONE(0x40)` or `SF_AMBISONIC_B_FORMAT(0x41)` or zero if the file -format does not support ambisonic formats. - -## SFC_WAVEX_SET_AMBISONIC - -Set the GUID of a new WAVEX file to indicate an Ambisonics format. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_WAVEX_SET_AMBISONIC - -data -: NULL - -datasize -: SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT - -Turn on (`SF_AMBISONIC_B_FORMAT(0x41)`) or off (`SF_AMBISONIC_NONE(0x40)`) -encoding. This command is currently only supported for files with -`SF_FORMAT_WAVEX` format. - -The Ambisonic WAVEX formats are defined here: - -. - -### Return value - -Return the ambisonic value that has just been set or zero if the -file format does not support ambisonic encoding. - -## SFC_SET_VBR_ENCODING_QUALITY - -Set the Variable Bit Rate encoding quality. The encoding quality value -should be between 0.0 (lowest quality) and 1.0 (highest quality). -Currently this command is only implemented for FLAC and Ogg/Vorbis files. -It has no effect on un-compressed file formats. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_VBR_ENCODING_QUALITY - -data -: A pointer to a double value - -datasize -: sizeof (double) - -The command must be sent before any audio data is written to the file. - -### Return value - -SF_TRUE if VBR encoding quality was set. SF_FALSE otherwise. - -## SFC_SET_OGG_PAGE_LATENCY_MS - -Set page latency for Ogg Opus file in milliseconds. The value should be between -50.0 and 1600.0. This command is only implemented for Ogg Opus files. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_OGG_PAGE_LATENCY_MS - -data -: A pointer to a double value - -datasize -: sizeof (double) - -### Return value - -0 on success and non-zero otherwise. - -## SFC_GET_OGG_STREAM_SERIALNO - -Get the Ogg stream serial number for files with the Ogg major format. Ogg -stream serail numbers are a randomly chosen 32-bit value, used for -differentiating logical Ogg streams. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_OGG_STREAM_SERIALNO - -data -: A pointer to a 32-bit int value - -datasize -: sizeof (int32_t) = 4 - -### Return value - -0 on success and non-zero otherwise. - -## SFC_SET_COMPRESSION_LEVEL - -Set the compression level. The compression level should be between 0.0 (minimum -compression level) and 1.0 (highest compression level). Currently this command is -only implemented for FLAC and Ogg/Vorbis files. It has no effect on -uncompressed file formats. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_COMPRESSION_LEVEL - -data -: A pointer to a double value - -datasize -: sizeof (double) - -The command must be sent before any audio data is written to the file. - -### Return value - -SF_TRUE if compression level was set. SF_FALSE otherwise. - -## SFC_RAW_DATA_NEEDS_ENDSWAP - -Determine if raw data read using [sf_read_raw()](api.md#raw) needs to be end -swapped on the host CPU. - -For instance, will return SF_TRUE on when reading WAV containing -`SF_FORMAT_PCM_16` data on a big endian machine and `SF_FALSE` on a -little endian machine. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_RAW_DATA_NEEDS_ENDSWAP - -data -: NULL - -datasize -: 0 - -### Return value - -`SF_TRUE` or `SF_FALSE`. - -## SFC_GET_BROADCAST_INFO - -Retrieve the Broadcast Extension Chunk from WAV (and related) files. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_BROADCAST_INFO - -data -: a pointer to an SF_BROADCAST_INFO struct - -datasize -: sizeof (SF_BROADCAST_INFO) - -The SF_BROADCAST_INFO struct is defined in *sndfile.h* as: - -```c -typedef struct -{ char description [256] ; - char originator [32] ; - char originator_reference [32] ; - char origination_date [10] ; - char origination_time [8] ; - unsigned int time_reference_low ; - unsigned int time_reference_high ; - short version ; - char umid [64] ; - char reserved [190] ; - unsigned int coding_history_size ; - char coding_history [256] ; -} SF_BROADCAST_INFO ; -``` - -### Return value - -`SF_TRUE` if the file contained a Broadcast Extension chunk or `SF_FALSE` -otherwise. - -## SFC_SET_BROADCAST_INFO - -Set the Broadcast Extension Chunk for WAV (and related) files. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_BROADCAST_INFO - -data -: a pointer to an SF_BROADCAST_INFO struct - -datasize -: sizeof (SF_BROADCAST_INFO) - -### Return value - -`SF_TRUE` if setting the Broadcast Extension chunk was successful and `SF_FALSE` -otherwise. - -## SFC_GET_CHANNEL_MAP_INFO - -Retrieve the channel map contained in an AIFF or CAF Channel Layout chunk. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_CHANNEL_MAP_INFO - -data -: a pointer to an array of int, the same size as the number of channels in the -file - -datasize -: number of channels * sizeof (int) - -Channel map positions are defined in an enum in *sndfile.h*: - -| Name | Value | Description | -|:-------------------------------------|:------|:------------------------------------------------------------------| -| SF_CHANNEL_MAP_INVALID | 0 | | -| SF_CHANNEL_MAP_MONO | 1 | | -| SF_CHANNEL_MAP_LEFT | 2 | Apple calls this 'Left' | -| SF_CHANNEL_MAP_RIGHT | 3 | Apple calls this 'Right' | -| SF_CHANNEL_MAP_CENTER | 4 | Apple calls this 'Center' | -| SF_CHANNEL_MAP_FRONT_LEFT | 5 | | -| SF_CHANNEL_MAP_FRONT_RIGHT | 6 | | -| SF_CHANNEL_MAP_FRONT_CENTER | 7 | | -| SF_CHANNEL_MAP_REAR_CENTER | 8 | Apple calls this 'Center Surround', Msft calls this 'Back Center' | -| SF_CHANNEL_MAP_REAR_LEFT | 9 | Apple calls this 'Left Surround', Msft calls this 'Back Left' | -| SF_CHANNEL_MAP_REAR_RIGHT | 10 | Apple calls this 'Right Surround', Msft calls this 'Back Right' | -| SF_CHANNEL_MAP_LFE | 11 | Apple calls this 'LFEScreen', Msft calls this 'Low Frequency' | -| SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER | 12 | Apple calls this 'Left Center' | -| SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER | 13 | Apple calls this 'Right Center' | -| SF_CHANNEL_MAP_SIDE_LEFT | 14 | Apple calls this 'Left Surround Direct' | -| SF_CHANNEL_MAP_SIDE_RIGHT | 15 | Apple calls this 'Right Surround Direct' | -| SF_CHANNEL_MAP_TOP_CENTER | 16 | Apple calls this 'Top Center Surround' | -| SF_CHANNEL_MAP_TOP_FRONT_LEFT | 17 | Apple calls this 'Vertical Height Left' | -| SF_CHANNEL_MAP_TOP_FRONT_RIGHT | 18 | Apple calls this 'Vertical Height Right' | -| SF_CHANNEL_MAP_TOP_FRONT_CENTER | 19 | Apple calls this 'Vertical Height Center' | -| SF_CHANNEL_MAP_TOP_REAR_LEFT | 20 | Apple and MS call this 'Top Back Left' | -| SF_CHANNEL_MAP_TOP_REAR_RIGHT | 21 | Apple and MS call this 'Top Back Right' | -| SF_CHANNEL_MAP_TOP_REAR_CENTER | 22 | Apple and MS call this 'Top Back Center' | -| SF_CHANNEL_MAP_AMBISONIC_B_W | 23 | | -| SF_CHANNEL_MAP_AMBISONIC_B_X | 24 | | -| SF_CHANNEL_MAP_AMBISONIC_B_Y | 25 | | -| SF_CHANNEL_MAP_AMBISONIC_B_Z | 26 | | -| SF_CHANNEL_MAP_MAX | 27 | | - -### Return value - -`SF_TRUE` if the file contained a Channel Layout chunk or `SF_FALSE` otherwise. - -## SFC_SET_CHANNEL_MAP_INFO - -Set the channel map contained in an AIFF or CAF Channel Layout chunk. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_CHANNEL_MAP_INFO - -data -: a pointer to an array of int, the same size as the number of channels in the -file - -datasize -: number of channels * sizeof (int) - -### Return value - -`SF_TRUE` if setting the Channel Layout chunk was successful and `SF_FALSE` -otherwise. - -## SFC_GET_CART_INFO - -Retrieve the Cart Chunk from WAV (and related) files. Based on AES46 standard -for CartChunk (see [CartChunk.org](http://www.cartchunk.org/) for more -information. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_CART_INFO - -data -: a pointer to an SF_CART_INFO struct - -datasize -: sizeof (SF_CART_INFO) - -The SF_CART_INFO struct is defined in *sndfile.h* as: - -```c -#define SF_CART_INFO_VAR(p_tag_text_size) \ - struct - { char version [4] ; - char title [64] ; - char artist [64] ; - char cut_id [64] ; - char client_id [64] ; - char category [64] ; - char classification [64] ; - char out_cue [64] ; - char start_date [10] ; - char start_time [8] ; - char end_date [10] ; - char end_time [8] ; - char producer_app_id [64] ; - char producer_app_version [64] ; - char user_def [64] ; - long level_reference ; - SF_CART_TIMER post_timers [8] ; - char reserved [276] ; - char url [1024] ; - unsigned int tag_text_size ; - char tag_text[p_tag_text_size] ; - } -``` - -### Return value - -`SF_TRUE` if the file contained a Cart chunk or `SF_FALSE` otherwise. - -## SFC_SET_CART_INFO - -Set the Cart Chunk for WAV (and related) files. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_CART_INFO - -data -: a pointer to an SF_CART_INFO struct - -datasize -: sizeof (SF_CART_INFO) - -### Return value - -SF_TRUE if setting the Cart chunk was successful and SF_FALSE otherwise. - -## SFC_GET_LOOP_INFO - -Retrieve loop information for file including time signature, length in beats and -original MIDI base note - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_LOOP_INFO - -data -: a pointer to an SF_LOOP_INFO struct - -datasize -: sizeof (SF_LOOP_INFO) - -The SF_LOOP_INFO struct is defined in *sndfile.h* as: - -```c -typedef struct -{ short time_sig_num ; /* any positive integer > 0 */ - short time_sig_den ; /* any positive power of 2 > 0 */ - int loop_mode ; /* see SF_LOOP enum */ - - int num_beats ; /* this is NOT the amount of quarter notes !!!*/ - /* a full bar of 4/4 is 4 beats */ - /* a full bar of 7/8 is 7 beats */ - - float bpm ; /* suggestion, as it can be calculated using other fields:*/ - /* file's length, file's sampleRate and our time_sig_den*/ - /* -> bpms are always the amount of _quarter notes_ per minute */ - - int root_key ; /* MIDI note, or -1 for None */ - int future [6] ; -} SF_LOOP_INFO ; -``` - -### Examples - -```c -SF_LOOP_INFO loop; -sf_command (sndfile, SFC_GET_LOOP_INFO, &loop, sizeof (loop)) ; -``` - -### Return value - -`SF_TRUE` if the file header contains loop information for the file, `SF_FALSE` -otherwise. - -## SFC_GET_INSTRUMENT - -Retrieve instrument information from file including MIDI base note, keyboard -mapping and looping information (start/stop and mode). - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_INSTRUMENT - -data -: a pointer to an SF_INSTRUMENT struct - -datasize -: sizeof (SF_INSTRUMENT) - -The `SF_INSTRUMENT` struct is defined in *sndfile.h* as: - -```c -typedef struct -{ int gain ; - char basenote, detune ; - char velocity_lo, velocity_hi ; - char key_lo, key_hi ; - int loop_count ; - - struct - { int mode ; - unsigned int start ; - unsigned int end ; - unsigned int count ; - } loops [16] ; /* make variable in a sensible way */ -} SF_INSTRUMENT ; -``` - -`mode` values are defined as: - -| Name | Value | Description | -|:--------------------|:------|:------------| -| SF_LOOP_NONE | 800 | | -| SF_LOOP_FORWARD | 801 | | -| SF_LOOP_BACKWARD | 802 | | -| SF_LOOP_ALTERNATING | 803 | | - -### Examples - -```c -SF_INSTRUMENT inst ; -sf_command (sndfile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) ; -``` - -### Return value - -`SF_TRUE` if the file header contains instrument information for the file, -`SF_FALSE` otherwise. - -## SFC_SET_INSTRUMENT - -Set the instrument information for the file. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_INSTRUMENT - -data -: a pointer to an SF_INSTRUMENT struct - -datasize -: sizeof (SF_INSTRUMENT) - -### Examples - -```c -SF_INSTRUMENT inst ; -sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ; -``` - -### Return value - -`SF_TRUE` if the file header contains instrument information for the file, -`SF_FALSE` otherwise. - -## SFC_GET_CUE_COUNT - -Retrieve the number of cue markers available for retrieval using the -[SFC_GET_CUE](#sfc_get_cue) command. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_CUE_COUNT - -data -: a pointer to a uint32_t - -datasize -: sizeof (uint32_t) - -### Examples - -```c -uint32_t cue_count ; -sf_command (sndfile, SFC_GET_CUE_COUNT, &cue_count, sizeof (cue_count)) ; -``` - -### Return value - -`SF_TRUE` if the file header contains cue marker information for the file, -`SF_FALSE` otherwise. - -## SFC_GET_CUE - -Retrieve cue marker information from file. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_CUE - -data -: a pointer to an SF_CUES struct - -datasize -: sizeof (SF_CUES) - -The SF_CUES struct is defined in *sndfile.h* as: - -```c -typedef struct -{ int cue_count ; - - struct - { int32_t indx ; - uint32_t position ; - int32_t fcc_chunk ; - int32_t chunk_start ; - int32_t block_start ; - uint32_t sample_offset ; - char name [256] ; - } cue_points [100] ; -} SF_CUES ; -``` - -There is also an SF_CUES_VAR \#define that allows reading/writing more than 100 -cue markers. - -### Examples - -```c -SF_CUES cues ; -sf_command (sndfile, SFC_GET_CUE, &cues, sizeof (cues)) ; -``` - -### Return value - -`SF_TRUE` if the file header contains cue marker information for the file, -`SF_FALSE` otherwise. - -## SFC_SET_CUE - -Set the cue marker information for the file. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_CUE - -data -: a pointer to an SF_CUES struct - -datasize -: sizeof (SF_CUES) - -### Examples - -```c -SF_CUES cues ; -sf_command (sndfile, SFC_SET_CUE, &cues, sizeof (cues)) ; -``` - -### Return value - -`SF_TRUE` if the file header contains cue marker information for the file, -`SF_FALSE` otherwise. - -## SFC_RF64_AUTO_DOWNGRADE - -Enable auto downgrade from RF64 to WAV. - -The EBU recommendation is that when writing RF64 files and the resulting file is -less than 4Gig in size, it should be downgraded to a WAV file (WAV files have a -maximum size of 4Gig). libsndfile doesn't follow the EBU recommendations -exactly, mainly because the test suite needs to be able test reading/writing -RF64 files without having to generate files larger than 4 gigabytes. - -Note: This command should be issued before the first bit of audio data has been -written to the file. Calling this command after audio data has been written will -return the current value of this setting, but will not allow it to be changed. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_RF64_AUTO_DOWNGRADE - -data -: NULL - -datasize -: SF_TRUE or SF_FALSE - -### Examples - -```c -/* Enable auto downgrade on file close. */ -sf_command (sndfile, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_TRUE) ; -``` - -### Return value - -Returns `SF_TRUE` if `SFC_RF64_AUTO_DOWNGRADE` is set and `SF_FALSE` otherwise. - -## SFC_GET_ORIGINAL_SAMPLERATE - -Get original samplerate metadata. - -The Opus audio codec stores audio data independent of samplerate, but only -supports encoding or decoding at 8000Hz, 12000Hz, 16000Hz, 24000Hz or 48000Hz. -Opus includes a header field to record the original source input samplerate, and -a samplerate converter may be used if needed. - -This command gets the original samplerate header field. It does not enable any -(non-existent) samplerate conversion, nor change the current decoder samplerate. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_ORIGINAL_SAMPLERATE - -data -: pointer to an integer - -datasize -: sizeof (int) - -### Examples - -```c -/* Get the original sample rate */ -int original_samplerate ; -sf_command (sndfile, SFC_GET_ORIGINAL_SAMPLERATE, &original_samplerate, sizeof (original_samplerate)) ; -``` - -### Return value - -Returns `SF_TRUE` on success, `SF_FALSE` otherwise. - -The passed integer is set to the value of the original samplerate. - -## SFC_SET_ORIGINAL_SAMPLERATE - -Set original samplerate metadata. - -The Opus audio codec stores audio data independent of samplerate, but only -supports encoding or decoding at 8000Hz, 12000Hz, 16000Hz, 24000Hz or 48000Hz. -Opus includes a header field to record the original source input samplerate, and -a samplerate converter may be used if needed. - -When writing an Opus file this command sets the original samplerate header field -to the provided value, which is then stored in the file. This has no effect on -the current encoder samplerate. - -When reading an Opus file this command overrides the original samplerate value -as read from the file. libsndfile uses this value to choose what samplerate to -decode at, rounding up to the nearest valid Opus samplerate. After a successful -call, the file samplerate and frames count may have changed. - -Note: This command should be issued before the first bit of audio data has been -read from or written to the file. - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_ORIGINAL_SAMPLERATE - -data -: pointer to an integer - -datasize -: sizeof (int) - -### Examples - -```c -/* Store the original sample rate as 44100 */ -int original_samplerate 44100; -sf_command (sndfile, SFC_SET_ORIGINAL_SAMPLERATE, &original_samplerate, sizeof (input_samplerate)) ; -``` - -### Return value - -Returns SF_TRUE on success, SF_FALSE otherwise. - -On write, can only succeed if no data has been written. On read, if successful, -[SFC_GET_CURRENT_SF_INFO](#sfc_get_current_sf_info) should be called to -determine the new frames count and samplerate - -## SFC_GET_BITRATE_MODE - -Get bitrate mode. - -The bitrate mode is one of: - -| Name | Value | Description | -|:-------------------------|:------|:------------------| -| SF_BITRATE_MODE_CONSTANT | 800 | Constant bitrate. | -| SF_BITRATE_MODE_AVERAGE | 801 | Average bitrate. | -| SF_BITRATE_MODE_VARIABLE | 802 | Variable bitrate. | - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_GET_BITRATE_MODE - -data -: NULL - -datasize -: anything - -### Return value - -Returns one of `SF_BITRATE_MODE_XXX` on success, `-1` otherwise. - -## SFC_SET_BITRATE_MODE - -Set bitrate mode. - -The bitrate mode is one of: - -| Name | Value | Description | -|:-------------------------|:------|:------------------| -| SF_BITRATE_MODE_CONSTANT | 800 | Constant bitrate. | -| SF_BITRATE_MODE_AVERAGE | 801 | Average bitrate. | -| SF_BITRATE_MODE_VARIABLE | 802 | Variable bitrate. | - -### Parameters - -sndfile -: A valid SNDFILE* pointer - -cmd -: SFC_SET_BITRATE_MODE - -data -: pointer to an integer - -datasize -: sizeof (int) - -### Return value - -Returns `SF_TRUE` on success, `SF_FALSE` otherwise. diff --git a/Engine/lib/libsndfile/docs/development.md b/Engine/lib/libsndfile/docs/development.md deleted file mode 100644 index 7d417ea6d..000000000 --- a/Engine/lib/libsndfile/docs/development.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -layout: page ---- - -# libsndfile Development - -libsndfile is being developed by a small community of users and hackers. People -interested in helping can raise an issue on Github. - -The main repository can be found on Github: - - - -and includes [instructions](https://github.com/libsndfile/libsndfile/blob/master/README.md) -on how to build libsndfile from the Git repo. - -If you are interested in how to add a new format to a libsndfile, you may find -this [FAQ](new_file_type_howto.md) helpful. diff --git a/Engine/lib/libsndfile/docs/donate.md b/Engine/lib/libsndfile/docs/donate.md deleted file mode 100644 index dd10769c5..000000000 --- a/Engine/lib/libsndfile/docs/donate.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -layout: page -title: libsndfile : donate. ---- - -{% include logo.html %} - -Dear libsndfile user, - -This library was developed on Linux for Linux. I am not a Windows user and -maintaining this library for Windows costs me significant amounts of time above -and beyond the time taken to make it work on Linux and Unix-like systems. - -I therefore ask Windows users of libsndfile to donate to ensure that -libsndfile's support for Windows continues. As long as donations continue to -flow in at a decentrate, I will continue to release precompiled Windows binaries -in sync with the Linux/Unix version. If donations are poor, support for windows -will fall behind. - -You are free to donate any amount you chose. As a guideline: - -* If you are simply a user of libsndfile that would like to ensure that the - development of libsndfile continues, a donation of $10US would be more than - adequate. -* If you are shareware author that distributes libsndfile with your app and - makes more than $1000 a year from your shareware, a one off donation of $50 - would be appropriate. -* If your company is a commercial software house that distributes one or more - products that ship with libsndfile, a donation of $100 every second or third - year would be appropriate. - -Donations can be made in Bitcoin to the Bitcoin address -**15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ** which can be verified by checking the -following GPG signature. - - -----BEGIN PGP SIGNED MESSAGE----- - Hash: SHA256 - - libsndfile Bitcoin address : 15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ - -----BEGIN PGP SIGNATURE----- - Version: GnuPG v1.4.12 (GNU/Linux) - - iQIcBAEBCAAGBQJSK7MUAAoJEEXYQ7zIiotIgXEP/R8hy65tlV7TiPw9bY9BklXS - /Vl8FU2RhDkBt61ZmxbfDTybyQ5Vce/3wWph15L4RvpoX1OyeintQFmwwuPjOGiq - eIz0nT9vDorG37Xdo5NZNBu9Tp1Od9MNtxFaAsRWFrDfvKEKljBHrcfM972cYrAp - DaFd0Ik+bHKom9iQXFB7TFd0w2V4uszVMQDUGqb/vRNeRURZS7ypeMNwc8tZyTKR - waEGMTa5sxxRjs7MqGRxSovnFT7JV3TNfdkBInUliIR/XvrudFR9J4Fiv+8Dk9P8 - WNjm6uFxvgIqiu1G9bjrwwr+DsBju93ljGNcZoayAKw5vwbX6KTcCbc31k9dP8Hf - p6YdmPlZVKZmva+P3nLSJBTlxNu24Jm+ha+ZM/svDXTaPFWC8l5FP17kK0Bj8wCq - N7pDz6RchEn10u+HdhfT1XiUjxj0zNXrr0GGj9apjl0RlT0O49eBttV0oXIdBRLi - nTEaOWITpCgu7ggw1kWXHIWEncuiaSuJy/iH8PgNepWVj/6PxQRMrTqG4ux2Snk8 - Ua4vO8YHLMZX/XvSUS7eMtgfM7AO6YjJ/ac9bQif9bh6LsYEVVklysMUin6ZRS7Z - Cms23FnqeQKtJOzdvqSJiV06lK6fP+tYdM4WSYn+AfL4IfYl2v48xXVU8XOOK9BH - bJPKMDcz1ZvfYtX5mSW1 - =WXGB - -----END PGP SIGNATURE----- - -Thanks and regards, -Erik de Castro Lopo -Main libsndfile author and maintainer diff --git a/Engine/lib/libsndfile/docs/embedded_files.md b/Engine/lib/libsndfile/docs/embedded_files.md deleted file mode 100644 index e55f2ede8..000000000 --- a/Engine/lib/libsndfile/docs/embedded_files.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: page ---- - -# Embedded Sound Files - -By using the open SNDFILE with a file descriptor function: - - SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; - -it is possible to open sound files embedded within larger files. There are -however a couple of caveats: - -* Read/Write mode (SFM_RDWR) is not supported. -* Writing of embedded files is only supported at the end of the file. -* Reading of embedded files is only supported at file offsets greater than zero. -* Not all file formats are supported (currently only WAV, AIFF and AU). - -The test program **multi_file_test.c** in the **tests/** directory of the source -code tarball shows how this functionality is used to read and write embedded -files. diff --git a/Engine/lib/libsndfile/docs/formats.md b/Engine/lib/libsndfile/docs/formats.md deleted file mode 100644 index 1d96737d0..000000000 --- a/Engine/lib/libsndfile/docs/formats.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -layout: page -title: libsndfile: Supported formats ---- - -# libsndfile : Supported formats - -The following table lists the file formats and encodings that libsndfile can -read and write. The file formats are arranged across the top and encodings along -the left edge. - -{:.formats-table} -| | Microsoft WAV | SGI / Apple AIFF / AIFC |Sun / DEC / NeXT AU / SND | Headerless RAW | Paris Audio File PAF | Commodore Amiga IFF / SVX | Sphere Nist WAV | IRCAM SF | Creative VOC | Soundforge W64 | GNU Octave 2.0 MAT4 | GNU Octave 2.1 MAT5 | Portable Voice Format PVF | Fasttracker 2 XI | HMM Tool Kit HTK | Apple CAF | Sound Designer II SD2 | Free Lossless Audio Codec FLAC | -|:-------------------|:-------------:|:-----------------------:|:------------------------:|:--------------:|:--------------------:|:-------------------------:|:---------------:|:--------:|:------------:|:--------------:|:-------------------:|:-------------------:|:-------------------------:|:----------------:|:----------------:|:---------:|:---------------------:|:------------------------------:| -| Unsigned 8 bit PCM | R/W | R/W | | R/W | | | | | R/W | R/W | | R/W | | | | | | | -| Signed 8 bit PCM | | R/W | R/W | R/W | R/W | R/W | R/W | | | | | | R/W | | | R/W | R/W | R/W | -| Signed 16 bit PCM | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | | R/W | R/W | R/W | R/W | -| Signed 24 bit PCM | R/W | R/W | R/W | R/W | R/W | | R/W | | | R/W | | | | | | R/W | R/W | R/W | -| Signed 32 bit PCM | R/W | R/W | R/W | R/W | | | R/W | R/W | | R/W | R/W | R/W | R/W | | | R/W | | | -| 32 bit float | R/W | R/W | R/W | R/W | | | | R/W | | R/W | R/W | R/W | | | | R/W | | | -| 64 bit double | R/W | R/W | R/W | R/W | | | | | | R/W | R/W | R/W | | | | R/W | | | -| u-law encoding | R/W | R/W | R/W | R/W | | | R/W | R/W | R/W | R/W | | | | | | R/W | | | -| A-law encoding | R/W | R/W | R/W | R/W | | | R/W | R/W | R/W | R/W | | | | | | R/W | | | -| IMA ADPCM | R/W | | | | | | | | | R/W | | | | | | | | | -| MS ADPCM | R/W | | | | | | | | | R/W | | | | | | | | | -| GSM 6.10 | R/W | R/W | | R/W | | | | | | R/W | | | | | | | | | -| G721 ADPCM 32kbps | R/W | | R/W | | | | | | | | | | | | | | | | -| G723 ADPCM 24kbps | | | R/W | | | | | | | | | | | | | | | | -| G723 ADPCM 40kbps | | | R/W | | | | | | | | | | | | | | | | -| 12 bit DWVW | | R/W | | R/W | | | | | | | | | | | | | | | -| 16 bit DWVW | | R/W | | R/W | | | | | | | | | | | | | | | -| 24 bit DWVW | | R/W | | R/W | | | | | | | | | | | | | | | -| Ok Dialogic ADPCM | | | | R/W | | | | | | | | | | | | | | | -| 8 bit DPCM | | | | | | | | | | | | | | R/W | | | | | -| 16 bit DPCM | | | | | | | | | | | | | | R/W | | | | | - -From version 1.0.18, libsndfile also reads and writes -[FLAC](https://xiph.org/flac/) and [Ogg/Vorbis](https://xiph.org/vorbis/). - -From version 1.0.29, libsndfile can read and write -[Ogg/Opus](https://opus-codec.org/). - -From version 1.1.0, libsndfile can read and write MP3. - -Some of the file formats I am also interested in adding are: - -- Kurzweil K2000 sampler files. -- Ogg Speex. - -Other file formats may also be added on request. - -If you are interested in how to add a new format to a libsndfile, you may find -this [FAQ](new_file_type_howto.md) helpful. diff --git a/Engine/lib/libsndfile/docs/index.md b/Engine/lib/libsndfile/docs/index.md deleted file mode 100644 index bc5890dbb..000000000 --- a/Engine/lib/libsndfile/docs/index.md +++ /dev/null @@ -1,322 +0,0 @@ ---- -layout: home -title: The libsndfile Home Page ---- - -Libsndfile is a C library for reading and writing files containing sampled sound -(such as MS Windows WAV and the Apple/SGI AIFF format) through one standard -library interface. It is released in source code format under the -[Gnu Lesser General Public License](http://www.gnu.org/copyleft/lesser.html). - -The library was written to compile and run on a Linux system but should compile -and run on just about any Unix (including MacOS X). -There are also pre-compiled binaries available for 32 and 64 bit windows. - -It was designed to handle both little-endian (such as WAV) and big-endian (such -as AIFF) data, and to compile and run correctly on little-endian (such as Intel -and DEC/Compaq Alpha) processor systems as well as big-endian processor systems -such as Motorola 68k, Power PC, MIPS and Sparc. Hopefully the design of the -library will also make it easy to extend for reading and writing new sound file -formats. - -It has been compiled and tested (at one time or another) on the following -systems: - -* Every platform supported by Debian GNU/Linux including x86_64-linux-gnu, - i486-linux-gnu, powerpc-linux-gnu, sparc-linux-gnu, alpha-linux-gnu, - mips-linux-gnu and armel-linux-gnu. -* powerpc-apple-darwin7.0 (Mac OS X 10.3) -* sparc-sun-solaris2.8 (using gcc) -* mips-sgi-irix5.3 (using gcc) -* QNX 6.0 -* i386-unknown-openbsd2.9 -* Microsoft Windows - -At the moment, each new release is being tested on i386 Linux, x86_64 Linux, -PowerPC Linux, Win32 and Win64. - -## Features - -libsndfile has the following main features : - -* Ability to read and write a large number of [file formats](formats.html). -* A simple, elegant and easy to use Applications Programming Interface. -* Usable on Unix, Win32, MacOS and others. -* On the fly format conversion, including endian-ness swapping, type conversion - and bitwidth scaling. -* Optional normalisation when reading floating point data from files containing - integer data. -* Ability to open files in read/write mode. -* The ability to write the file header without closing the file (only on files - open for write or read/write). -* Ability to query the library about all supported formats and retrieve text - strings describing each format. - -libsndfile has a comprehensive test suite so that each release is as bug free -as possible. -When new bugs are found, new tests are added to the test suite to ensure that -these bugs don't creep back into the code. -When new features are added, tests are added to the test suite to make sure that -these features continue to work correctly even when they are old features. - -## History - -My first attempt at reading and writing WAV files was in 1990 or so under -Windows 3.1. I started using Linux in early 1995 and contributed some code to -the [wavplay](http://www.vaxxine.com/ve3wwg/gnuwave.html) program. That -contributed code would eventually mutate into this library. As one of my -interests is Digital Signal Processing (DSP) I decided that as well as reading -data from an audio file in the native format (typically 16 bit short integers) -it would also be useful to be able to have the library do the conversion to -floating point numbers for DSP applications. It then dawned on me that whatever -file format (anything from 8 bit unsigned chars, to 32 bit floating point -numbers) the library should be able to convert the data to whatever format the -library user wishes to use it in. For example, in a sound playback program, the -library caller typically wants the sound data in 16 bit short integers to dump -into a sound card even though the data in the file may be 32 bit floating point -numbers (ie Microsoft's WAVE_FORMAT_IEEE_FLOAT format). Another example would be -someone doing speech recognition research who has recorded some speech as a 16 -bit WAV file but wants to process it as double precision floating point numbers. - -Here is the release history for libsndfile: - -* Version 0.0.8 (Feb 15 1999) First official release. -* Version 0.0.28 (Apr 26 2002) Final release of version 0 of libsndfile. -* Version 1.0.0rc1 (Jun 24 2002) Release candidate 1 of version 1 of libsndfile. -* Version 1.0.0rc6 (Aug 14 2002) MacOS 9 fixes. -* Version 1.0.0 (Aug 16 2002) First 1.0.X release. -* Version 1.0.1 (Sep 14 2002) Added MAT4 and MAT5 file formats. -* Version 1.0.2 (Nov 24 2002) Added VOX ADPCM format. -* Version 1.0.3 (Dec 09 2002) Fixes for Linux on ia64 CPUs. -* Version 1.0.4 (Feb 02 2003) New file formats and functionality. -* Version 1.0.5 (May 03 2003) One new file format and new functionality. -* Version 1.0.6 (Feb 08 2004) Large file fix for Linux/Solaris, new - functionality and Win32 improvements. -* Version 1.0.7 (Feb 24 2004) Fix build problems on MacOS X and fix ia64/MIPS - etc clip mode detection. -* Version 1.0.8 (Mar 14 2004) Minor bug fixes. -* Version 1.0.9 (Mar 30 2004) Add AVR format. Improve handling of some WAV - files. -* Version 1.0.10 (Jun 15 2004) Minor bug fixes. Fix support for Win32 MinGW - compiler. -* Version 1.0.11 (Nov 15 2004) Add SD2 file support, reading of loop data in WAV - and AIFF. Minor bug fixes. -* Version 1.0.12 (Sep 30 2005) Add FLAC and CAF file support, virtual I/O - interface. Minor bug fixes and cleanups. -* Version 1.0.13 (Jan 21 2006) Add read/write of instrument chunks. Minor bug - fixes. -* Version 1.0.14 (Feb 19 2006) Minor bug fixes. Start shipping windows - binary/source ZIP. -* Version 1.0.15 (Mar 16 2006) Minor bug fixes. -* Version 1.0.16 (Apr 30 2006) Add support for RIFX. Other minor feature - enhancements and bug fixes. -* Version 1.0.17 (Aug 31 2006) Add C++ wrapper sndfile.hh. Minor bug fixes and - cleanups. -* Version 1.0.18 (Feb 07 2009) Add Ogg/Vorbis support, remove captive - libraries, many new features and bug fixes. Generate Win32 and Win64 - pre-compiled binaries. -* Version 1.0.19 (Mar 02 2009) Fix for CVE-2009-0186. Huge number of minor fixes - as a result of static analysis. -* Version 1.0.20 (May 14 2009) Fix for potential heap overflow. -* Version 1.0.21 (December 13 2009) Bunch of minor bug fixes. -* Version 1.0.22 (October 04 2010) Bunch of minor bug fixes. -* Version 1.0.23 (October 10 2010) Minor bug fixes. -* Version 1.0.24 (March 23 2011) Minor bug fixes. -* Version 1.0.25 (July 13 2011) Fix for Secunia Advisory SA45125. Minor bug - fixes and improvements. -* Version 1.0.26 (November 22 2015) Fix for CVE-2014-9496, CVE-2014-9756 and - CVE-2015-7805. Add ALAC/CAF support. Minor bug fixes and improvements. -* Version 1.0.27 (June 19 2016) Fix a seek regression in 1.0.26. Add metadata - read/write for CAF and RF64. FIx PAF endian-ness issue. -* Version 1.0.28 (April 2 2017) Fix buffer overruns in FLAC and ID3 handling - code. Reduce default header memory requirements. Fix detection of Large File - Support for 32 bit systems. -* Version 1.0.29 (August 15 2020) Opus support, build system improvements and - bug fixes. -* Version 1.0.30 (September 19 2020) Bugfix release. Fix file descriptor leaks - in sf_open_fd () function. Fix critical CMake bug leading to broken ABI on - Linux platforms. Other numerous fixes to CMake build system, consider it - stable now. Fix some memory leaks. Fix handling of some SD2 files. Update - documentation. Integrate GitHub Actions for faster test builds and Oss-Fuzz - for fuzzing tests. Move sndfile.h.in from src/ to include/ directory. To avoid - problems, delete old generated sndfile.h from $(top_builddir)/src. -* Version 1.0.31 (January 24 2021) Bugfix release. Fix multiple memory leaks - reported by OSS-Fuzz. More SSE2-optimized functions for x86 and amd64. -* Version 1.1.0 (March 27 2022) Minor release, backward compatible with previous - releases. Added long-awaited MP3 support. Numerous improvements and bugfixes. -* Version 1.2.0 (December 25 2022) Various bugfixes, - removed artificial samplerate limit -* Version 1.2.1 (August 12 2023) Patch release, various bugfixes. -* Version 1.2.2 (August 13 2023) Patch release, various bugfixes. - -## Similar or Related Projects - -* [SoX](http://sox.sourceforge.net/) is a program for converting between sound - file formats. -* [Wavplay](http://www.hitsquad.com/smm/programs/WavPlay/) started out as a - minimal WAV file player under Linux and has mutated into Gnuwave, a - client/server application for more general multimedia and games sound - playback. -* [Audiofile](http://www.68k.org/~michael/audiofile/) (libaudiofile) is a - library similar to libsndfile but with a different programming interface. The - author Michael Pruett has set out to clone (and fix some bugs in) the - libaudiofile library which ships with SGI's IRIX OS. -* [sndlib.tar.gz](ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz) is - another library written by Bill Schottstaedt of CCRMA. - -## Licensing - -libsndfile is released under the terms of the GNU Lesser General Public License, -of which there are two versions; -[version 2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) -and -[version 3](http://www.gnu.org/copyleft/lesser.html). -To maximise the compatibility of libsndfile, the user may choose to use -libsndfile under either of the above two licenses. -You can also read a simple explanation of the ideas behind the GPL and the LGPL -[here](http://www.gnu.org/copyleft/lesser.html). - -You can use libsndfile with -[Free Software](http://www.gnu.org/), -[Open Source](http://www.opensource.org/), -proprietary, shareware or other closed source applications as long as libsndfile -is used as a dynamically loaded library and you abide by a small number of other -conditions (read the LGPL for more info). -With applications released under the GNU GPL you can also use libsndfile -statically linked to your application. - -I would like to see libsndfile used as widely as possible but I would prefer it -if you released software that uses libsndfile as -[Free Software](http://www.gnu.org/) -or -[Open Source](http://www.opensource.org/). -However, if you put in a great deal of effort building a significant application -which simply uses libsndfile for file I/O, then I have no problem with you -releasing that as closed source and charging as much money as you want for it as -long as you abide by [the license](http://www.gnu.org/copyleft/lesser.html). - -## Download - -Check latest version on -[GitHub Releases page](https://github.com/libsndfile/libsndfile/releases/). - -Binaries and source packages are signed by current releaser David Seifert aka -@SoapGentoo. You can verify signatures with his public GPG key: - -``` ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v2 - -mQINBFppABgBEAC42ZiNvV7BTIgR6TQy0YnF54fx3mVRP1u8Mq00UZa7reAsNKh7 -1H60j0W4s6+4pVVIKGfpVGxLwUdJe+KVCYw1Cd3YW6uMf5zZrC/ZWqnJiH/n6S6o -1l4INII2o6YbGBnzIWBPRo7PlOL+mvgKTLpBSJPnhD8XDGN5wRiV8rL2+6Dptg0F -nJt7oxECGF3OD3gk6HMel0o82CVkIqMtNaX1L/bhcdF7K0Rp2MXPZMmpn1izW5sI -asN1G9+w+Zwj7kMJzq1Aw3ac+rsX4SEYdvXjS2QhDHQUIr6LXri3D2WbcEqIZj2R -JVoVwblsrG11dYXFDBbgrq4NhgTBsxHYDlkr/qF2W+kbPC/nhSqTVZeCYvTBZbOQ -+RqyN/I0izukglnWmV1jGijFA8snyP8efx732hw/24zRYmtXOtnEITUpw8WOeZCq -6uiHaQ+eopnY2ojBg9BI7WZm0AFn58xxT9soMsyFOUFgXTqaWFZWlJ3fhZE8/0v8 -JEu/kPGE5aJReT3b34B+Bojkj74XR+h2u7iJJBHMTE8RwGoUOZHer/XsL9xlcdks -I+7TCjiq++ShaSSt2XsJmw2BhREohrjW/2KkwmvT3b44RMpKPB4WTH+++aqJQNeM -IqmswOMoZvzEZezInj7WVY/r0WEei1Y6wt1tBrJ/cFf1oQBM1UmphxcrfQARAQAB -tB9EYXZpZCBTZWlmZXJ0IDxzb2FwQGdlbnRvby5vcmc+iQJUBBMBCgA+BQsJCAcD -BRUKCQgLBRYCAwEAAh4BAheAAhsBFiEEMdlcq22A0mIkShdQpHYg6AHkfpUFAl/V -CvoFCQkuceIACgkQpHYg6AHkfpXYxA//aiJW1NwunpmzEc62id8lRMnoLHWVjISZ -b+xSlm+hk4LYq+ZbthJDzKcT86/3DJOSE1zQw9wLuCao9IW2UfFJQBtR+TAfbagG -0Yyk/kMcLoFJxnG1ywdJWypCAauuIhia52Z7PmmjsBbFwr6LygDwSQmZAyACMAs7 -TLQe+yERc2RNDsIEsquLSxxRF0Spk9gagWtKgrPc2XBjuNtQDwW7JgsOUoEeHyxC -29fRUjC3o/pG2I6iAZp17OROZI5yl4TSORrSBDGIi2sayxyxP0x+IPKtrCUcBGNx -wGp+56bP/V0hA6sgCPh/iwvqLoeibso6l/Kd4ltVAEQnHTd6fr8g+wLEUXfbJVTR -7aeFUoaFmWjSPlQrNr6HlxSLV/kRx9kVJp1Pn16vkfVBF7fG7iDLiqphwEeQg5ND -nmGeKAbRRNxFHyBHf0XRsaYiFZQckguO+71XSRtVx8/YP5nyNbtl9y1h/4JlT6Gy -t7hb5twYFQyQrKss83E/Bo1sRdHpj0ibtqb4ZbYANbh482E6yFhAkuo8YjVTJipI -1Ve8EBKnX3R+pDt147uyysNvtPVXML+sWpGSMVSm4NA8uT3F5nqxVwj+SeXy3Wq/ -CHQ2VBKGBC655G+wFD5C6O7cTx2MwH+2H8tzhWm+gFlI3MFKEXa/PC+YUC/diYcb -BrApavriTRa5Ag0EWmkAZgEQAPXMD3mZI+ChvBysXZWksC88/uSEwFeb3XkcRm7v -04GN7hcz+bfrmnUTB3tuE/ZQgv+u7ZjetvH1aEKieznn/GjnWoOBoJusOYvfAQeF -0mQVi118QiOZRCnEZpkz+RY9TiXVgrZJg+AGqHZ3Ol4GkInEV2NWgH37Xal+HkFl -rwI2U7mL0kZRG+LAVCQHKzqU0R0HE1XyJ4qf0awtG5Qi/TZvgXBdZPDXgr8i9Vlf -UUu10c2XnXM0Av/YAlZmBFjVYrSOUCFenqSVqL+s9sTCVdWlJrGjrr3Ja4uT3kl2 -rLva0AR4oSQoxt8adKohmFz0vzOkQtCoRzhrCwoo3JvNjKdSNoOP1nSsxlO5ji8r -ih5d+ajPgi580XyHLnrvG7vobR48qqscv1hizKuCgTacOTe6Db2Gqc8xF6v8HhJa -KwWJtmFllIfN/tIvZ6BbbgHQn0IGf4CYnWf0SksPZqpBmTRpD2jfBxcj2UEg+AR3 -LARjuyUVpFJScyu6ExQG+6O+ByLL31iWP5MgUrza1rIpriPa3NT3rZ3DG2pvQrS3 -ySsrPzH7VRX8L1ThSMSzjwF96aMsd14s7XzR4EzNuWwZDukfs0yavZk6l4o1M0mb -tbJi7hE4cz13KRHYvIkKMdZGYUnzRzZUDlsj2imakk3BR6GXnxZ1ST6062g+QxiL -AJFLABEBAAGJBHIEGAEKACYCGwIWIQQx2VyrbYDSYiRKF1CkdiDoAeR+lQUCX9UL -DQUJCS5xpwJAwXQgBBkBCgAdFiEEuNUxXaAAcsCoYIifzjbhFyAuOEIFAlppAGYA -CgkQzjbhFyAuOELmrQ/9H9wrWsWa21STZdxUmyU2sh9VXAWEHl1Ey0fVTznDM0Fl -zx5YSR/TmmnE36rpaz31Ttkx8SP914oV+mMgseecdya9Bf6uZL9Cv7V3KEsJBRL/ -ncrOWQBHP/Xy1X+mLD6A19xq7H4RihSLj0LeK2YVjrJzJ7wMf4mKXuBayQeAHImU -WRCRTbmK3umh2nB5V0iPd/XZEIiYtiTPe+7E/va6+0bBvOumF3a+Z0iui7eU4hFC -7Jk71D0dcg09SlIaNoMOrw7cMC3j2pMdKtsj8+0I6WBv14PhhqPAsnjdf7I/4NfK -L7Jav8T/gDS01uA2Jxm72d+wr+eSjOBXa6x8CEbTqfkjAGxsWENThCp6zDkaXSDd -JsV0va47vjzG8+wTDAvPy5IxIM/KZZdl4uWM+mF5K+q+eSTOHe7aLF2OdcussoBA -A18zm994dAkG1COX/qpxanxx2bv/2IvCGPg+x6JtAN8ji2kncWu3dWGQdE5XbVjc -fDwgsUPpp04G27Mr/x+HpEbgZ5SdA0dAqJktlNvCcHALhlblCWrsh/1QNjT/2iG8 -wsjcpEy/s4tWAuV4PTa4xvZ1JPS7Z7Eo5aBy9ZGOWG9SrHEiHnhkUsiswbHBOEjd -pBSkmNElDcv9fRUahVCTPfvWBATFDrQyMjJBSm+cV8c/iFQM7isVSu8W7E0eetsJ -EKR2IOgB5H6Vv9sP/1dxTvH0N0UoEoxIG/hnirEkbRpljdvqy4/uikYBKyQgSbo8 -VITTjea7gIhDztil9WZYt35jbOmoaGM2Z6TP2LEDOWgljYUNq9pl9Sc2GS8cNtEO -WxExzGOc1Flo730dX3A85Ks3+0WPXZjLDcRRcPVkFd5WLQQDV1YVYopWkuQBC+Br -4q3uv+sk+bw6gDa9+zFBbDuegdsYuTXrFHoxHz2GRv9Yb7ULCMgpFeNKDgtQq91u -RqewoTwQp9tlp91LH/hh7R0Q4DRgeFDkLnVRXwSKjVvCrT5cBgImGwtFTGS4egoy -MDKd/KKjZllp1ahRCln1XfmFQyQVMVvuF/JTtt31n6KwXwK2yxIlXB01xvRH+Ees -AWeRYWKWXydaAY/9Ve0/PLFlgsr/XUGvt0GoEKe7odD3nZgg6015+/8JTroKw19L -NZkhdfFMl11Zi0j5k3UbyzjYVpFSd8K2o0VoOG1LFsPp8tlRxNoVzpId0CX1au/p -y1H7Wy/39mzriRG3rw+mJAQbBjN09putCltXFXpOEWk08n/N3vufCVQUoSu/2Bqw -2HYj8VtToQp+O5dG3XxvDHINtInP1yr2Wcw2plna0KoXLwv/lZgDm3LN+eCWpG6d -N/xk25DTSqTHArUQIEkhcHYK6GnyxUcvoKtG88hXtqEPYXiK08FZYAUPTnDYuQIN -BFppAIkBEADDjvQZUs1NoqJpxkD2QDBudU1DBCaeI1D6CancMtb5FebPUxgFlDMd -CBGOun48dY5i87gDhT/qS3gP/Mv9rjKJmcG9JHfhpXdW73owxrcsQ96nxxVJNEVl -UHJw00z8C9eGWqr0SzSoE33K/PkzSkgtsaotF6+3uCerWulweulmGa5dpVfV0mbS -aVw8VmrhZ5NmCeodyy/lR85rPik5pb32NT6v7xBkgkfS0VYtPB2E5gW1pXX/jEOi -Mfq9idOEP9lxrNXV9j49Lr0JQCwAcrYbQ2+VPe6eacJEjzJ/6HiUqhPrYdnvydmb -hU+xmv2NjGp2UnDZDEhzQfwm6fMx+8Nx2uPzCnXQGoyRBwiC/KcdW0F1ZPKdSXqH -NKoOF62pLvIMSmfI3ZVOrTohArfr1kFEYVDv9Nl7oY+qg2rZEc2srOF74a9Z46bR -TDPsEQzE2UMCvu3+rofhSD7aRotlKeDCvbe2s0yE4Man457Xc3LXh8Gva8CzCOLE -2eMhNTsHIZk68WgXp3/uvE4Xy42myrk1AV8XXDdlWgx0Kc/I6tE59O5NVPSfuGvH -1a15KKx0F6euEnYDKKpQ5PDR6dSn61po0tfbt96m044G/xQFjrfhHei4jji9Ogd9 -vlXVAi2vn3+NCSHFP5l3igLByBHy9iLIdmz7yQuus/1nwRmxOHOf2QARAQABiQI8 -BBgBCgAmAhsMFiEEMdlcq22A0mIkShdQpHYg6AHkfpUFAl/VCxkFCQkucZAACgkQ -pHYg6AHkfpVPSRAAmheYkYJmtDbkzPBBnj5mbCIQN1/G5PI9eixc/TXWFOXtcjU1 -mJlJpSidHJyLRrx7r0c+N+s8vnY/JuUBsNoMJMER+Mv/CFW4iFi59V534SyAb2S0 -7NINJnFNkXBY62CDz9KsMuv/MdSv2yLhPH2Tfrm/eDRQesj1PanE4U1cgjWyJRc/ -IOlaRHvTasWDLgwbQi8ykt+4xUWzL/YKHzB+KyyzBK7vPBXqySX8ka4BOw7SDwG5 -lX2gtmhk4AGBwVChLXKflqVx1WXj4DPOt0kmOKVnKFyvUijK58M0A2FMgFMXDTIS -DRtoZPdx/rkODXxgS+W+27NcYAnxJiM0cQqizEnQh7PQ1KzgdChPejYXMKe9lwdn -ssMUxrBpbuAuagEf+pebNjD2eaNR4p8kfaDdGn53q55ysDvoyxKvnVQGSk1FAR9Q -s4N5a4f02U7dzlyEhEfIcuUlRCfnlpn4n725YIhHheDig5zKWoEZCkNIfiRcGzDl -8Drj+tlZiUR+gDkIoWSBaCkKbIQlc8qCYy6Hm7oZBaol6xKlUnTMK2rjK8fR4i8r -bVDWBAaWj3jcDHJ0Jg3fS/qBpeya/JXMp89TR8NK5Ys7PZpWbor+puXBYyXDAVx3 -rXQ7JBA5klHPxrgjso1S/LqwscKLENtrVjdjhryLBmPifrmofJRnrpiHIEa5Ag0E -WmkAswEQAL0hKwsRybQzkNGpJP+ElLSwFHd7XQhr+qIwLllpumWtnIK/DHmv8SpW -FqAYajmRTXipFcBHH25x2jIIliZidn0a9826l+sMzrFadMC6/W4pitP71TeqZzwn -pAuHs14YL7Wiy0aJQnfbCpRzPq3kYyOXmhmY7lPWO0WdUpR6W8wUbleK5XOVDDRx -aIC/M3hhDOxZOMzQ+pdn4BaOFQQ0ygsRkqOudbuc0R1giYRt1i6gMeT8gfzL9jlw -HcJ+aVnxdUQQ4uC47oKo/+lg7qh7LsiW79pQC1Bcdm8lhRmqtxe6ub60ecjax3XU -1ILIEfIFCv6M7LRUAwz0bqk35spgkJqrGGKkdeWEKAFHg2QWR2F0zy+HdlPLfKxO -uhaccpwc9EJtf744GS0SXa2AXr32j56n7CFcEjFcIQPBC6OJn6eA3hOVUYGZ7SrT -4fsmZiFAdGEkvLKFuNhju1Hj2EJQUY1pm4GSBco7BR8x+QqoYrt5clU3WxRMNfTR -0Rtuzsh4xskXNVMMgvKOahAtxENv2M2Cx6zJPVL5dmaysP7d6QRVeOQA5PwkcZ5Q -qK6JtDZj2jpaKQH4Za715kiIcdqMDSkwxa6avc0kARHvfFcBR4hwDm1GAlaKG7eH -8TOGGQIk8x2F3s4l8mTJVLWTP/uJYnkYBdqANYo5t1NIQLvwLFV3ABEBAAGJAjwE -GAEKACYCGyAWIQQx2VyrbYDSYiRKF1CkdiDoAeR+lQUCX9ULIwUJCS5xcAAKCRCk -diDoAeR+leekD/sF7aHH0W35ckWrXZlfSp0qHPWrBUaLBI9OAUHenRhgs4SbK0D4 -wqEiu0C5iDQojpXAeALQ8g/1pUsZ1yuFqYbGYWrHkA0Pm+P3tAGB4LMZ41YfvROP -uaiW/+IMJbWllgRtaDt8/NtCgs30WI9I+az5M29HcGfvEwEUykrBx3dE9T+1ui3O -capdd+GMvdAAsX5PyVkjWgZ7GrZeH8mG7UysYfT4qthxEtQfZ/u8ceSduKA46ugh -C2eafIDNvluqn7BU4oKxME61u6C8BN2yHLI6LV0Tr4z5H8joVbM4BSFMwLVGlsXf -HhB8kLiErN6bXolxsjARlmYiD9S9H2AcYidr6RYXf2EVFSpBG59xn1WTDN+DsHQf -7btNPEPl/OPxa3OQjG+xn8USddiP0N0B4xsyzMNCCKDgvXXcIhX55KG9eh3Tc98S -fEyhxu8ybZBIGmTJysPKxijfvSgQF+RPNTsz9lvXqkoK7RTgeYMschpjJEznCLbt -M6eTDb5z0G5uLXh6+dYxtDOlPogI5OHd+G51LwCjvrQ+AtIUCgafuemwA9mpFT2b -svb/qcxSVUb44bVaNHn1JHebX2YbokGtBOm1x2PI5fT8n6YIIYz3jKYOZAYdUT7x -6qURyNjOfG4aPJIATwuh4GSNuxUG40+yuT+XfQF24mu1esS1J3wzRloJ7w== -=K3x+ ------END PGP PUBLIC KEY BLOCK----- -``` - -## See Also - -* [sndfile-tools](https://github.com/libsndfile/sndfile-tools): a small -collection of programs which use libsndfile. diff --git a/Engine/lib/libsndfile/docs/libsndfile.css b/Engine/lib/libsndfile/docs/libsndfile.css deleted file mode 100644 index 3386bc3cb..000000000 --- a/Engine/lib/libsndfile/docs/libsndfile.css +++ /dev/null @@ -1,101 +0,0 @@ -body { - background : black ; - color : white ; - font-family : arial, helvetica, sans-serif ; - line-height: 1.5 ; - margin-left: 6%; - margin-right: 6%; -} -td { - font-family : arial, helvetica, sans-serif ; - background : black ; - color : white ; -} -center { - font-family : arial, helvetica, sans-serif ; -} -p { - font-family : arial, helvetica, sans-serif ; - text-align : left ; -} -.indent_block { - font-family : arial, helvetica, sans-serif ; - text-align : left ; -} -br { - font-family : arial, helvetica, sans-serif ; -} -form { - font-family : arial, helvetica, sans-serif ; -} -ul { - font-family : arial, helvetica, sans-serif ; - text-align : left ; -} -ol { - font-family : arial, helvetica, sans-serif ; - text-align : left ; -} -dl { - font-family : arial, helvetica, sans-serif ; - text-align : left ; -} -h1 { - font-size : xx-large ; - background : black ; - color : #5050FF ; - text-align : left ; -} -h2 { - font-size : x-large ; - background : black ; - color : #5050FF ; - text-align : left ; -} -h3 { - font-size : large ; - background : black ; - color : #5050FF ; - text-align : left ; -} -h4 { - font-size : medium ; - background : black ; - color : #5050FF ; - text-align : left ; -} -pre { - font-family : courier, monospace ; - font-size : medium ; -} -code, -kbd, -samp, -var { - font-family: "Courier New", monospace, serif; - font-size: 1em; -} -a:link { color : #9090FF ; } -a:visited { color : #5050FF ; } -a:active { color : #FF00FF ; } -a:hover { background-color : #202080 ; } - -table.formats-table { - text-align: center; - font-size: small; - border-collapse: collapse; -} - -table.formats-table, table.formats-table th, table.formats-table td { - border: 1px solid white; -} - -.image-logo { - display: block; - margin-left: auto; - margin-right: auto; -} - -nav { - text-align: center; -} diff --git a/Engine/lib/libsndfile/docs/libsndfile.jpg b/Engine/lib/libsndfile/docs/libsndfile.jpg deleted file mode 100644 index 7855b92d0..000000000 Binary files a/Engine/lib/libsndfile/docs/libsndfile.jpg and /dev/null differ diff --git a/Engine/lib/libsndfile/docs/linux_games_programming.txt b/Engine/lib/libsndfile/docs/linux_games_programming.txt deleted file mode 100644 index ca6a94f3b..000000000 --- a/Engine/lib/libsndfile/docs/linux_games_programming.txt +++ /dev/null @@ -1,434 +0,0 @@ -# Here are some some emails I exchanged with a guy trying to use -# libsndfile version 1 with code from the book "Linux Games Programming" -# by John Hall. The email addresses have been changed to foil the spam -# bots. - -Date: Tue, 20 Jul 2004 22:49:21 +0100 -From: Paul -To: erikd@fake-domain-name.com -Subject: Can you help with a problem? -Date: Tue, 20 Jul 2004 22:49:21 +0100 - -Hi, - -I'm trying to get the source examples in the "Programming Linux Games" -(NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile. - -While I can guess some of the newer versions of function calls and -enumerations, there are some which I cannot guess. - -Would you be able to translate them to the current version of -enumeration and function calls so that I can update the source? - -These are the three currently failing me: - - sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,SFM_READ, &sfinfo)) - SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW) - SF_INFO.pcmbitwidth (guess: no idea!) - -There are probably more. I'm happy to send you the source files for -sound calls, scan the pages or anything else. Failing that, is there -somewhere with the changes listed so I can try and fix the code for myself? - -Thanks - -TTFN - -Paul - -================================================================================ - -Date: Wed, 21 Jul 2004 17:38:08 +1000 -From: Erik de Castro Lopo -To: Paul -Subject: Re: Can you help with a problem? - -On Tue, 20 Jul 2004 22:49:21 +0100 -Paul wrote: - -> Hi, -> -> I'm trying to get the source examples in the "Programming Linux Games" -> (NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile. -> -> While I can guess some of the newer versions of function calls and -> enumerations, there are some which I cannot guess. -> -> Would you be able to translate them to the current version of -> enumeration and function calls so that I can update the source? -> -> These are the three currently failing me: -> -> sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename, -> SFM_READ, &sfinfo)) - -yes. - -> SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW) - -Actually this list: - - SF_FORMAT_PCM_U8 - SF_FORMAT_PCM_S8 - SF_FORMAT_PCM_16 - SF_FORMAT_PCM_24 - SF_FORMAT_PCM_32 - -> SF_INFO.pcmbitwidth (guess: no idea!) - -WIth the above change, pcmbitwidth becomes redundant. - -> There are probably more. I'm happy to send you the source files for -> sound calls, scan the pages or anything else. Failing that, is there -> somewhere with the changes listed so I can try and fix the code for -> myself? - -Version 1.0.0 came out some time ago, but I think this: - - http://www.mega-nerd.com/libsndfile/version-1.html - -lists most of the changes. You should also look at the API docs: - - http://www.mega-nerd.com/libsndfile/api.html - -HTH, -Erik --- -+-----------------------------------------------------------+ - Erik de Castro Lopo nospam@fake-domain-name.com -+-----------------------------------------------------------+ -"There is no reason why anyone would want a computer in their home" -Ken Olson, DEC, 1977 - -================================================================================ - -From: PFJ -To: Erik de Castro Lopo -Subject: Re: Can you help with a problem? -Date: Wed, 21 Jul 2004 09:07:39 +0100 - - -Hi Erik, - -Thanks for getting back to me. - -> > sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename, SFM_READ, &sfinfo)) -> -> yes. - -Yay! - -> > SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW) -> -> Actually this list: -> -> SF_FORMAT_PCM_U8 -> SF_FORMAT_PCM_S8 -> SF_FORMAT_PCM_16 -> SF_FORMAT_PCM_24 -> SF_FORMAT_PCM_32 - -I know, but the source code explicitly has SF_FORMAT_PCM which given the -code afterwards would equate to one of the above, but given that PCM -files can have a varied bitwidth the author probably wanted to cover all -bases. - -> Version 1.0.0 came out some time ago, but I think this: -> -> http://www.mega-nerd.com/libsndfile/version-1.html -> -> lists most of the changes. You should also look at the API docs: -> -> http://www.mega-nerd.com/libsndfile/api.html - -I'll download them and see what I can gleen. - -Thanks again for getting back to me - -TTFN - -Paul - -================================================================================ - -Date: Wed, 21 Jul 2004 18:20:29 +1000 -From: Erik de Castro Lopo -To: PFJ -Subject: Re: Can you help with a problem? - -On Wed, 21 Jul 2004 09:07:39 +0100 -PFJ wrote: - -> I know, but the source code explicitly has SF_FORMAT_PCM which given the -> code afterwards would equate to one of the above, but given that PCM -> files can have a varied bitwidth the author probably wanted to cover all -> bases. - -But surely the existing code does something like: - - sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM; - sfinfo.pcmbitwidth = 16; - -which can be directly translated to: - - sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; - -and the same for pcmbitwitdhs of 24 and 32. For pcmbitwidth of 8 -you need to know that WAV files use SF_FORMAT_PCM_U8 and AIFF -files use SF_FORMAT_PCM_S8. That's all there is to it. - -Erik --- -+-----------------------------------------------------------+ - Erik de Castro Lopo nospam@fake-domain-name.com -+-----------------------------------------------------------+ -"Python addresses true pseudocode's two major failings: that it -isn't standardized, and it isn't executable." -- Grant R. Griffin in comp.dsp - -================================================================================ - -Subject: Re: Can you help with a problem? -From: PFJ -To: Erik de Castro Lopo -Date: Wed, 21 Jul 2004 09:50:55 +0100 - -Hi Erik, - -> > I know, but the source code explicitly has SF_FORMAT_PCM which given the -> > code afterwards would equate to one of the above, but given that PCM -> > files can have a varied bitwidth the author probably wanted to cover all -> > bases. -> -> But surely the existing code does something like: -> -> sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM; -> sfinfo.pcmbitwidth = 16; - -If only! - -The actual code is this - -int LoadSoundFile(char *filename, sound_p sound) -{ - SNDFILE *file; - SF_INFO file_info; - short *buffer_short = NULL; - u_int8_t *buffer_8 = NULL; - int16_t *buffer_16 = NULL; - unsigned int i; - - /* Open the file and retrieve sample information. */ - file = sf_open_read(filename, &file_info); - // I've sorted this one already - PFJ - - /* Make sure the format is acceptable. */ - if ((file_info.format & 0x0F) != SF_FORMAT_PCM) { - printf("'%s' is not a PCM-based audio file.\n", filename); - sf_close(file); - return -1; - } - - if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) { - sound->format = AL_FORMAT_MONO8; - } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) { - sound->format = AL_FORMAT_STEREO8; - } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) { - sound->format = AL_FORMAT_MONO16; - } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) { - sound->format = AL_FORMAT_STEREO16; - } else { - printf("Unknown sample format in %s.\n", filename); - sf_close(file); - return -1; - } - - /* Allocate buffers. */ - buffer_short = (short *)malloc(file_info.samples * file_info.channels * sizeof (short)); - - buffer_8 = (u_int8_t *)malloc(file_info.samples * file_info.channels * file_info.pcmbitwidth / 8); - - buffer_16 = (int16_t *)buffer_8; - - if (buffer_short == NULL || buffer_8 == NULL) { - printf("Unable to allocate enough memory for '%s'.\n", filename); - goto error_cleanup; - } - - /* Read the entire sound file. */ - if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)-1) { - printf("Error while reading samples from '%s'.\n", filename); - goto error_cleanup; - } - - - - /* Fill in the sound data structure. */ - sound->freq = file_info.samplerate; - sound->size = file_info.samples * file_info.channels * file_info.pcmbitwidth / 8; - - /* Give our sound data to OpenAL. */ - alGenBuffers(1, &sound->name); - if (alGetError() != AL_NO_ERROR) { - printf("Error creating an AL buffer name for %s.\n", filename); - goto error_cleanup; - } - - alBufferData(sound->name, sound->format, buffer_8, sound->size,sound->freq); - if (alGetError() != AL_NO_ERROR) { - printf("Error sending buffer data to OpenAL for %s.\n", filename); - goto error_cleanup; - } - - /* Close the file and return success. */ - sf_close(file); - free(buffer_short); - free(buffer_8); - - return 0; - - error_cleanup: - if (file != NULL) fclose(file); - free(buffer_short); - free(buffer_8); - return -1; -} - -As you can see, the PCM material in the listing will not currently -compile and for the other sndfile material, it probably won't either. - -Any help would be appreciated. - -TTFN - -Paul - -================================================================================ - -From: Erik de Castro Lopo -To: PFJ -Subject: Re: Can you help with a problem? -Date: Wed, 21 Jul 2004 19:36:46 +1000 - -On Wed, 21 Jul 2004 09:50:55 +0100 -PFJ wrote: - -> Hi Erik, -> -> > > I know, but the source code explicitly has SF_FORMAT_PCM which given the -> > > code afterwards would equate to one of the above, but given that PCM -> > > files can have a varied bitwidth the author probably wanted to cover all -> > > bases. -> > -> > But surely the existing code does something like: -> > -> > sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM; -> > sfinfo.pcmbitwidth = 16; -> -> If only! - -No, really. - -Drop this completely: - -> /* Make sure the format is acceptable. */ -> if ((file_info.format & 0x0F) != SF_FORMAT_PCM) { -> printf("'%s' is not a PCM-based audio file.\n", filename); -> sf_close(file); -> return -1; -> } - -Replace this block: - -> if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) { -> sound->format = AL_FORMAT_MONO8; -> } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) { -> sound->format = AL_FORMAT_STEREO8; -> } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) { -> sound->format = AL_FORMAT_MONO16; -> } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) { -> sound->format = AL_FORMAT_STEREO16; -> } else { -> printf("Unknown sample format in %s.\n", filename); -> sf_close(file); -> return -1; -> } - -with: - - int pcmbitwidth = 0; - - if (file_info.format & SF_FORMAT_SUBMASK != SF_FORMAT_PCM_16) - { printf("'%s' is not a PCM-based audio file.\n", filename); - sf_close(file); - return -1; - } - - if (file_info.channels < 1 || file_info.channels > 2) - { printf("'%s' bad channel count.\n", filename); - sf_close(file); - return -1; - } - - switch (file_info.format & SF_FORMAT_SUBMASK + file_info.channels << 16) - { case (SF_FORMAT_PCM_U8 + 1 << 16): - sound->format = AL_FORMAT_MONO8; - pcmbitwidth = 8; - break; - case (SF_FORMAT_PCM_U8 + 2 << 16): - sound->format = AL_FORMAT_STEREO8; - pcmbitwidth = 8; - break; - case (SF_FORMAT_PCM_16 + 1 << 16): - sound->format = AL_FORMAT_MONO16; - pcmbitwidth = 16; - break; - case (SF_FORMAT_PCM_16 + 2 << 16): - sound->format = AL_FORMAT_STEREO16; - pcmbitwidth = 16; - break; - default: - printf("Unknown sample format in %s.\n", filename); - sf_close(file); - return -1; - } - -> /* Allocate buffers. */ -> buffer_short = (short *)malloc(file_info.samples * -> file_info.channels * -> sizeof (short)); -> -> buffer_8 = (u_int8_t *)malloc(file_info.samples * -> file_info.channels * -> file_info.pcmbitwidth / 8); - -Use pcmbitwidth as calculated above. - -> buffer_16 = (int16_t *)buffer_8; -> -> if (buffer_short == NULL || buffer_8 == NULL) { -> printf("Unable to allocate enough memory for '%s'.\n", filename); -> goto error_cleanup; -> } -> -> /* Read the entire sound file. */ -> if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)- 1) { - -Replace "(size_t) - 1" with " < 0". - -> As you can see, the PCM material in the listing will not currently -> compile and for the other sndfile material, it probably won't either. - -None of the changes above should have been very difficult to figure -out. - -Erik --- -+-----------------------------------------------------------+ - Erik de Castro Lopo nospam@fake-domain-name.com -+-----------------------------------------------------------+ -Microsoft is finally bringing all of its Windows operating system families -under one roof. It will combine all of the features of CE, stability and -support of ME and the speed of NT. -It will be called Windows CEMENT... - diff --git a/Engine/lib/libsndfile/docs/lists.md b/Engine/lib/libsndfile/docs/lists.md deleted file mode 100644 index 46b25473d..000000000 --- a/Engine/lib/libsndfile/docs/lists.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -layout: page -title: libsndfile Mailing Lists ---- - -# libsndfile Mailing Lists - -**Note**: These mailing lists are not maintained by the libsndfile team anymore. -Use [GitHub issues and pull requests instead](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests). - -There are three mailing lists for libsndfile: - - - **libsndfile-announce@mega-nerd.com**   - [Subscribe](mailto:libsndfile-announce-request@mega-nerd.com?subject=subscribe) - A list which will announce each new release of libsndfile. No one can - post to this list except the author. -- **libsndfile-devel@mega-nerd.com**   - [Subscribe](mailto:libsndfile-devel-request@mega-nerd.com?subject=subscribe) - A list for discussing bugs, porting issues and feature requests. - Posting is restricted to subscribers. -- **libsndfile-users@mega-nerd.com**   - [Subscribe](mailto:libsndfile-users-request@mega-nerd.com?subject=subscribe) - A list for discussing the use of libsndfile in other programs. - Posting is restricted to subscribers. - -The libsndfile-devel and libsndfile-users list will automatically receive a copy -of all emails to the libsndfile-announce list. diff --git a/Engine/lib/libsndfile/docs/new_file_type_howto.md b/Engine/lib/libsndfile/docs/new_file_type_howto.md deleted file mode 100644 index bb4220812..000000000 --- a/Engine/lib/libsndfile/docs/new_file_type_howto.md +++ /dev/null @@ -1,134 +0,0 @@ ---- -layout: page ---- - -# How to add new file format - - Original : Wed May 23 19:05:07 EST 2001 - Update 1 : Fri Jul 11 22:12:38 EST 2003 - -This document will attempt to explain as fully as possible how to add code to -libsndfile to allow the reading and writing of new file types. By new file -type I particularly mean a new header type rather than a new encoding method -for an existing file type. - -This HOWTO will take the form of a step by step guide. It will assume that you -have all required tools including : - -- gcc -- make (should really be the GNU version) -- autoconf -- automake -- libtool - -These should all be available on the GNU ftp site: . - -To help make these steps clearer let's suppose we are adding support for the -Whacky file format whose files contain 'W','A','C' and 'K' as the first four -bytes of the file format. Lets also assume that Whacky files contain PCM encoded -data. - -## Step 1 - -Create a new .c file in the src/ directory of the libsndfile source tree. The -file name should be reasonable descriptive so that is is obvious that files of -the new type are handled by this file. In this particular case the file might -be named 'whacky.c'. - -## Step 2 - -Add your new source code file to the build process. - -Edit the file src/Makefile.am and add the name of your file handler to the -FILESPECIFIC list of handlers. This list looks something like this: - - FILESPECIFIC = aiff.c au.c au_g72x.c nist.c paf.c raw.c samplitude.c \ - svx.c wav.c wav_float.c wav_gsm610.c wav_ima_adpcm.c \ - wav_ms_adpcm.c - -Then, run the script named 'reconf' in the libsndfile top level directory, -which will run autoconf and other associated tools. Finally run "./configure" -in the top level directory. You may want to use the "--disable-gcc-opt" option -to disable gcc optimisations and make debugging with gdb/ddd easier. - -## Step 3 - -Add a unique identifier for the new file type. - -Edit src/sndfile.h and find the enum containing the SF_FORMAT_XXX identifiers. -Since you will be adding a major file type you should add your identifier to the -top part of the list where the values are above 0x10000 in value. The easiest -way to do this is to find the largest value in the list, add 0x10000 to it and -make that your new identifier value. The identifier should be something like -SF_FORMAT_WACK. - -## Step 4 - -Add code to the file type recogniser function. - -Edit src/sndfile.c and find the function guess_file_type (). This function -reads the first 3 ints of the file and from that makes a guess at the file -type. In our case we would add: - - if (buffer [0] == MAKE_MARKER ('W','A','C','K')) - return SF_FORMAT_WACK ; - -The use of the MAKE_MARKER macro should be pretty obvious and it is defined at -the top of file should you need to have a look at it. - -## Step 5 - -Add a call to your open function from psf_open_file (). - -Edit src/sndfile.c and find the switch statement in psf_open_file (). It starts -like this: - - switch (filetype) - { case SF_FORMAT_WAV : - error = wav_open (psf) ; - break ; - - case SF_FORMAT_AIFF : - error = aiff_open (psf) ; - break ; - -Towards the bottom of this switch statement your should add one for the new file -type. Something like: - - case SF_FORMAT_WACK : - sf_errno = whacky_open (psf) ; - break ; - -## Step 6 - -Add prototypes for new open read and open write functions. - -Edit src/common.h, go to the bottom of the file and add something like - - int whacky_open (SF_PRIVATE *psf) ; - -## Step 7 - -Implement your open read function. The best way to do this is by coding -something much like one of the other file formats. The file src/au.c might be a -good place to start. - -In src/whacky.c you should now implement the function whacky_open() which -was prototyped in src/common.h. This function should return 0 on success and -a non-zero number on error. - -Error values are defined in src/common.h in a enum which starts at SFE_NO_ERROR. -When adding a new error value, you also need to add an error string to the -SndfileErrors array in src/sndfile.c. - -To parse the header of your new file type you should avoid using standard read/ -write/seek functions (and the fread/fwrite/fseek etc) and instead use -psf_binheader_readf () which is implemented and documented in src/common.h. - -During the parsing process, you should also print logging information to -libsndfile's internal log buffer using the psf_log_printf() function. - -At the end of the open read process, you should have set a number of fields in -the SF_PRIVATE structure pointed to by psf. - -**THIS FILE IS INCOMPLETE** diff --git a/Engine/lib/libsndfile/docs/octave.md b/Engine/lib/libsndfile/docs/octave.md deleted file mode 100644 index f619ca69c..000000000 --- a/Engine/lib/libsndfile/docs/octave.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -layout: page ---- - -# libsndfile and GNU Octave - -[GNU Octave](http://www.octave.org/) is a high-level interactive language for -numerical computations. There are currently two development streams, a stable -2.0.X series and a development 2.1.X series. Octave reads and writes data in -binary formats that were originally developed for -[MATLAB](http://www.mathworks.com/). Version 2.0.X of Octave uses binary data -files compatible with MATLAB version 4.2 while Octave 2.1.X uses binary data -files compatible with MATLAB version 5.0 as well as being able to read the older -MATLAB 4.2 format. - -From version 1.0.1 of libsndfile onwards, libsndfile has the ability of reading -and writing a small subset of the binary data files used by both versions of GNU -Octave. This gives people using GNU Octave for audio based work an easy method -of moving audio data between GNU Octave and other programs which use libsndfile. - -For instance it is now possible to do the following: - -* Load a WAV file into a sound file editor such as - [Sweep](http://www.metadecks.org/software/sweep/). -* Save it as a MAT4 file. -* Load the data into Octave for manipulation. -* Save the modified data. -* Reload it in Sweep. - -Another example would be using the MAT4 or MAT5 file formats as a format which -can be easily loaded into Octave for viewing/analyzing as well as a format which -can be played with command line players such as the one included with -libsndfile. - -## Details - -Octave, like most programming languages, uses variables to store data, and -Octave variables can contain both arrays and matrices. It is also able to store -one or more of these variables in a file. When reading Octave files, libsndfile -expects a file to contain two variables and their associated data. The first -variable should contain a variable holding the file sample rate while the second -variable contains the audio data. - -For example, to generate a sine wave and store it as a binary file which is -compatible with libsndfile, do the following: - - octave:1 > samplerate = 44100 ; - octave:2 > wavedata = sin ((0:1023)*2*pi/1024) ; - octave:3 > save sine.mat samplerate wavedata - -The process of reading and writing files compatible with libsndfile can be made -easier by use of two Octave script files: - - octave:4 > [data fs] = sndfile_load ("sine.mat") ; - octave:5 > sndfile_save ("sine2.mat", data, fs) ; - -In addition, libsndfile contains a command line program which which is able to -play the correct types of Octave files. Using this command line player -**sndfile-play** and a third Octave script file allows Octave data to be played -from within Octave on any of the platforms which **sndfile-play** supports (at -the moment: Linux, MacOS X, Solaris and Win32). - - octave:6 > sndfile_play (data, fs) ; - -These three Octave scripts are installed automatically in Octave's site script -directory when libsndfile is installed (except on Win32) ie when libsndfile is -being installed into /usr/local, the Octave scripts will be installed in -/usr/local/share/octave/site/m/. - -There are some other Octave scripts for audio to be found -[here](http://octave.sourceforge.net/audio/index.html). diff --git a/Engine/lib/libsndfile/docs/print.css b/Engine/lib/libsndfile/docs/print.css deleted file mode 100644 index deb5b13da..000000000 --- a/Engine/lib/libsndfile/docs/print.css +++ /dev/null @@ -1,14 +0,0 @@ -body { - background:white; - color:black; -} - -h1{ - background:white; - color:black; -} - -h2 { - background:white; - color:#666; -} diff --git a/Engine/lib/libsndfile/docs/sndfile_info.md b/Engine/lib/libsndfile/docs/sndfile_info.md deleted file mode 100644 index 78d3548d6..000000000 --- a/Engine/lib/libsndfile/docs/sndfile_info.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -layout: page -title: sndfile-info ---- - -Here is an example of the output from the **sndfile-info** program -distributed with libsndfile. - -This file was opened and parsed correctly but had been truncated so that -the values in the **FORM** and **SSND** chunks were incorrect. - -``` - erikd@hendrix > examples/sndfile-info truncated.aiff - truncated.aiff - size : 200000 - FORM : 307474 (should be 199992) - AIFF - COMM : 18 - Sample Rate : 16000 - Samples : 76857 - Channels : 2 - Sample Size : 16 - SSND : 307436 (should be 199946) - Offset : 0 - Block Size : 0 - - -------------------------------- - Sample Rate : 16000 - Frames : 76857 - Channels : 2 - Bit Width : 16 - Format : 0x00020001 - Sections : 1 - Seekable : TRUE - Signal Max : 32766 -``` diff --git a/Engine/lib/libsndfile/docs/tutorial.md b/Engine/lib/libsndfile/docs/tutorial.md deleted file mode 100644 index 848c17526..000000000 --- a/Engine/lib/libsndfile/docs/tutorial.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -layout: page ---- - -# libsndfile Tutorial - -**More coming soon.** - -For now, the best place to look for example code is the `examples/` directory of the source code distribution and the -libsndfile test suite which is located in the `tests/` directory of the source code distribution. diff --git a/Engine/lib/libsndfile/docs/win32.md b/Engine/lib/libsndfile/docs/win32.md deleted file mode 100644 index 6106517b1..000000000 --- a/Engine/lib/libsndfile/docs/win32.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -layout: page ---- - -# Building libsndfile on Win32 - -**Note : For pre-compiled binaries for windows, both for win32 and win64, see -the main web page.** - -There are currently two build systems; the official GNU autotool based one and -a more limited and experimental CMake based build system. - -libsndfile is written to be compiled by a compiler which supports large chunks -of the 1999 ISO C Standard (tested with GCC, Clang and Visual Studio 2015). - -It is recommended to use CMake and Visual Studio to build libsndfile on Windows -but you can try the [MinGW](http://www.mingw.org/) compiler suite with Autotools -or CMake buildsystem. diff --git a/Engine/lib/libsndfile/examples/generate.c b/Engine/lib/libsndfile/examples/generate.c deleted file mode 100644 index 9b59f4ade..000000000 --- a/Engine/lib/libsndfile/examples/generate.c +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Copyright (C) 2002-2011 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include - -#include - -#define BUFFER_LEN 4096 - -static void encode_file (const char *infilename, const char *outfilename, int filetype) ; - -int -main (int argc, char **argv) -{ - if (argc != 2) - { puts ("\nEncode a single input file into a number of different output ") ; - puts ("encodings. These output encodings can then be moved to another ") ; - puts ("OS for testing.\n") ; - puts (" Usage : generate \n") ; - exit (1) ; - } ; - - /* A couple of standard WAV files. Make sure Win32 plays these. */ - encode_file (argv [1], "pcmu8.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_U8) ; - encode_file (argv [1], "pcm16.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - encode_file (argv [1], "imaadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM) ; - encode_file (argv [1], "msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ; - encode_file (argv [1], "gsm610.wav" , SF_FORMAT_WAV | SF_FORMAT_GSM610) ; - - /* Soundforge W64. */ - encode_file (argv [1], "pcmu8.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_U8) ; - encode_file (argv [1], "pcm16.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_16) ; - encode_file (argv [1], "imaadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM) ; - encode_file (argv [1], "msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM) ; - encode_file (argv [1], "gsm610.w64" , SF_FORMAT_W64 | SF_FORMAT_GSM610) ; - - return 0 ; -} /* main */ - -/*============================================================================================ -** Helper functions and macros. -*/ - -#define PUT_DOTS(k) \ - { while (k--) \ - putchar ('.') ; \ - putchar (' ') ; \ - } - -/*======================================================================================== -*/ - -static void -encode_file (const char *infilename, const char *outfilename, int filetype) -{ static float buffer [BUFFER_LEN] ; - - SNDFILE *infile, *outfile ; - SF_INFO sfinfo ; - int k, readcount ; - - printf (" %s -> %s ", infilename, outfilename) ; - fflush (stdout) ; - - k = 16 - strlen (outfilename) ; - PUT_DOTS (k) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if (! (infile = sf_open (infilename, SFM_READ, &sfinfo))) - { printf ("Error : could not open file : %s\n", infilename) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } - - sfinfo.format = filetype ; - - if (! sf_format_check (&sfinfo)) - { sf_close (infile) ; - printf ("Invalid encoding\n") ; - return ; - } ; - - if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo))) - { printf ("Error : could not open file : %s\n", outfilename) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - while ((readcount = (int) sf_read_float (infile, buffer, BUFFER_LEN)) > 0) - sf_write_float (outfile, buffer, readcount) ; - - sf_close (infile) ; - sf_close (outfile) ; - - printf ("ok\n") ; - - return ; -} /* encode_file */ - diff --git a/Engine/lib/libsndfile/examples/generate.cs b/Engine/lib/libsndfile/examples/generate.cs deleted file mode 100644 index 1817856fa..000000000 --- a/Engine/lib/libsndfile/examples/generate.cs +++ /dev/null @@ -1,250 +0,0 @@ -/* (c) 2004 James Robson, http://www.arbingersys.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** **************************** -** -** How to use: -** - libsndfile.dll must have already been compiled and be in this -** application's search path -** -** - You must edit this file to point to the file you want to convert. Set -** the following line of code (found in the Main() function further below) -** to the name of a .WAV file that exists on your system. -** 186: string sfn = "input.wav"; -** -** - From a command prompt type -** csc generate.cs -** -** - Run the resulting executable 'generate.exe' -** -** -** Note: You will obviously need the csc compiler and the .NET runtime. I think -** these are freely available for download from Microsoft's website -** (part of the .NET SDK?). -*/ - - -using System; -using System.Runtime.InteropServices; -using sf_count_t = System.Int64; //alias; see SF_INFO struct - -#if PLATFORM_64 -using size_t = System.UInt64; -#else -using size_t = System.UInt32; -#endif - - -class lsndf_example { - - -//sound file formats - public enum lsndf_frmts { - SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian). */ - SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */ - SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */ - SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */ - SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */ - SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */ - SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */ - SF_FORMAT_VOC = 0x080000, /* VOC files. */ - SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */ - SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */ - SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */ - SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */ - SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */ - SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */ - SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */ - SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */ - - /* Subtypes from here on. */ - - SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */ - SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */ - SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */ - SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */ - - SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */ - - SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */ - SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */ - - SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */ - SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */ - SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */ - SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */ - - SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */ - SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */ - - SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */ - SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */ - SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */ - - SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */ - SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */ - SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */ - SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */ - - SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */ - SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */ - - - /* Endian-ness options. */ - - SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ - SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */ - SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */ - SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */ - - SF_FORMAT_SUBMASK = 0x0000FFFF, - SF_FORMAT_TYPEMASK = 0x0FFF0000, - SF_FORMAT_ENDMASK = 0x30000000 - } - - -//modes and other - public enum lsndf_tf - { /* True and false */ - SF_FALSE = 0, - SF_TRUE = 1, - - /* Modes for opening files. */ - SFM_READ = 0x10, - SFM_WRITE = 0x20, - SFM_RDWR = 0x30 - } - - -//important SF_INFO structure - [StructLayout(LayoutKind.Sequential)] - public struct SF_INFO - { - public sf_count_t frames ; // Used to be called samples. Changed to avoid confusion. - public int samplerate ; - public int channels ; - public int format ; - public int sections ; - public int seekable ; - }; - - -//function declarations -//Note: Not all functions have been prototyped here. Only the ones necessary to -// make this application work. The below code should give some clues as to -// how to add the rest since they have a lot of parameter and return type -// similarities. - [DllImport("libsndfile.dll")] - public static extern IntPtr sf_open ([MarshalAs(UnmanagedType.LPStr)] string path, int mode, ref SF_INFO sfinfo); - - [DllImport("libsndfile.dll")] - static extern int sf_error (IntPtr sndfile); - - [DllImport("libsndfile.dll")] - static extern IntPtr sf_strerror (IntPtr sndfile); - - [DllImport("libsndfile.dll")] - static extern int sf_format_check (ref SF_INFO info); - - [DllImport("libsndfile.dll")] - static extern sf_count_t sf_read_float (IntPtr sndfile, float[] ptr, sf_count_t items); - - [DllImport("libsndfile.dll")] - static extern sf_count_t sf_write_float (IntPtr sndfile, float[] ptr, sf_count_t items); - - [DllImport("libsndfile.dll")] - static extern int sf_close (IntPtr sndfile); - - - public const sf_count_t BUFFER_LEN = 4096; - - -//program entry - static void Main( ) { - - -//declarations - SF_INFO sfinfo = new SF_INFO(); - float[] buffer = new float[BUFFER_LEN]; - sf_count_t rcnt; - -//set the input file - string sfn = "input.wav"; //set to a file on YOUR system - //string sfn = "noexist.wav"; //test with non-existent file - -//set the output file - string ofn = "output.wav"; - -//read in sound file to convert - IntPtr infile = sf_open (sfn, (int)lsndf_tf.SFM_READ, ref sfinfo); - -//exit if error was thrown - if ( (int)infile == 0 ) { - Console.WriteLine("Error opening " + sfn); - Console.WriteLine("Error #" + sf_error(infile)); - return; - } - -//set the file type for the output file -//uncomment one and only one of the statements below to change the output -//file encoding. - //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_PCM_U8); - //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_PCM_16); - //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_MS_ADPCM); - sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_IMA_ADPCM); - //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_GSM610); - /* Soundforge W64. */ - //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_PCM_U8); - //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_PCM_16); - //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_MS_ADPCM); - //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_IMA_ADPCM); - //sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_GSM610); - - -//check that SF_INFO is valid - if ( sf_format_check(ref sfinfo) == 0 ) { - Console.WriteLine("sf_format_check failed. Invalid encoding"); - return; - } - -//open output file - IntPtr outfile = sf_open (ofn, (int)lsndf_tf.SFM_WRITE, ref sfinfo); - -//exit if error was thrown - if ( (int)outfile == 0 ) { - Console.WriteLine("Error opening " + ofn); - Console.WriteLine("Error #" + sf_error(outfile)); - return; - } - -//infile -> outfile - Console.Write(sfn + " -> " + ofn); - while ( (rcnt = sf_read_float (infile, buffer, BUFFER_LEN)) > 0) { - Console.Write("."); - sf_write_float (outfile, buffer, BUFFER_LEN); - } - Console.WriteLine("done."); - -//close up shop - sf_close(infile); - sf_close(outfile); - - - } //main() - - -} //class lsndf_example {} - diff --git a/Engine/lib/libsndfile/examples/list_formats.c b/Engine/lib/libsndfile/examples/list_formats.c deleted file mode 100644 index 348c81b07..000000000 --- a/Engine/lib/libsndfile/examples/list_formats.c +++ /dev/null @@ -1,76 +0,0 @@ -/* -** Copyright (C) 2001-2014 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include - -#include - -int -main (void) -{ SF_FORMAT_INFO info ; - SF_INFO sfinfo ; - int format, major_count, subtype_count, m, s ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - printf ("Version : %s\n\n", sf_version_string ()) ; - - sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ; - - sfinfo.channels = 1 ; - for (m = 0 ; m < major_count ; m++) - { info.format = m ; - sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ; - printf ("%s (extension \"%s\")\n", info.name, info.extension) ; - - format = info.format ; - - for (s = 0 ; s < subtype_count ; s++) - { info.format = s ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ; - - format = (format & SF_FORMAT_TYPEMASK) | info.format ; - - sfinfo.format = format ; - if (sf_format_check (&sfinfo)) - printf (" %s\n", info.name) ; - } ; - puts ("") ; - } ; - puts ("") ; - - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/examples/make_sine.c b/Engine/lib/libsndfile/examples/make_sine.c deleted file mode 100644 index b905b2af5..000000000 --- a/Engine/lib/libsndfile/examples/make_sine.c +++ /dev/null @@ -1,100 +0,0 @@ -/* -** Copyright (C) 1999-2012 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include - -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846264338 -#endif - -#define SAMPLE_RATE 44100 -#define SAMPLE_COUNT (SAMPLE_RATE * 4) /* 4 seconds */ -#define AMPLITUDE (1.0 * 0x7F000000) -#define LEFT_FREQ (344.0 / SAMPLE_RATE) -#define RIGHT_FREQ (466.0 / SAMPLE_RATE) - -int -main (void) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k ; - int *buffer ; - - if (! (buffer = malloc (2 * SAMPLE_COUNT * sizeof (int)))) - { printf ("Error : Malloc failed.\n") ; - return 1 ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = SAMPLE_COUNT ; - sfinfo.channels = 2 ; - sfinfo.format = (SF_FORMAT_WAV | SF_FORMAT_PCM_24) ; - - if (! (file = sf_open ("sine.wav", SFM_WRITE, &sfinfo))) - { printf ("Error : Not able to open output file.\n") ; - free (buffer) ; - return 1 ; - } ; - - if (sfinfo.channels == 1) - { for (k = 0 ; k < SAMPLE_COUNT ; k++) - buffer [k] = (int) (AMPLITUDE * sin (LEFT_FREQ * 2 * k * M_PI)) ; - } - else if (sfinfo.channels == 2) - { for (k = 0 ; k < SAMPLE_COUNT ; k++) - { buffer [2 * k] = (int) (AMPLITUDE * sin (LEFT_FREQ * 2 * k * M_PI)) ; - buffer [2 * k + 1] = (int) (AMPLITUDE * sin (RIGHT_FREQ * 2 * k * M_PI)) ; - } ; - } - else - { printf ("Error : make_sine can only generate mono or stereo files.\n") ; - sf_close (file) ; - free (buffer) ; - return 1 ; - } ; - - if (sf_write_int (file, buffer, sfinfo.channels * SAMPLE_COUNT) != - sfinfo.channels * SAMPLE_COUNT) - puts (sf_strerror (file)) ; - - sf_close (file) ; - free (buffer) ; - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/examples/sfprocess.c b/Engine/lib/libsndfile/examples/sfprocess.c deleted file mode 100644 index ce1bda8aa..000000000 --- a/Engine/lib/libsndfile/examples/sfprocess.c +++ /dev/null @@ -1,144 +0,0 @@ -/* -** Copyright (C) 2001-2013 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include - -/* Include this header file to use functions from libsndfile. */ -#include - -/* This will be the length of the buffer used to hold.frames while -** we process them. -*/ -#define BUFFER_LEN 1024 - -/* libsndfile can handle more than 6 channels but we'll restrict it to 6. */ -#define MAX_CHANNELS 6 - -/* Function prototype. */ -static void process_data (double *data, int count, int channels) ; - - -int -main (void) -{ /* This is a buffer of double precision floating point values - ** which will hold our data while we process it. - */ - static double data [BUFFER_LEN] ; - - /* A SNDFILE is very much like a FILE in the Standard C library. The - ** sf_open function return an SNDFILE* pointer when they sucessfully - ** open the specified file. - */ - SNDFILE *infile, *outfile ; - - /* A pointer to an SF_INFO struct is passed to sf_open. - ** On read, the library fills this struct with information about the file. - ** On write, the struct must be filled in before calling sf_open. - */ - SF_INFO sfinfo ; - int readcount ; - const char *infilename = "input.wav" ; - const char *outfilename = "output.wav" ; - - /* The SF_INFO struct must be initialized before using it. - */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Here's where we open the input file. We pass sf_open the file name and - ** a pointer to an SF_INFO struct. - ** On successful open, sf_open returns a SNDFILE* pointer which is used - ** for all subsequent operations on that file. - ** If an error occurs during sf_open, the function returns a NULL pointer. - ** - ** If you are trying to open a raw headerless file you will need to set the - ** format and channels fields of sfinfo before calling sf_open(). For - ** instance to open a raw 16 bit stereo PCM file you would need the following - ** two lines: - ** - ** sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 ; - ** sfinfo.channels = 2 ; - */ - if (! (infile = sf_open (infilename, SFM_READ, &sfinfo))) - { /* Open failed so print an error message. */ - printf ("Not able to open input file %s.\n", infilename) ; - /* Print the error message from libsndfile. */ - puts (sf_strerror (NULL)) ; - return 1 ; - } ; - - if (sfinfo.channels > MAX_CHANNELS) - { printf ("Not able to process more than %d channels\n", MAX_CHANNELS) ; - sf_close (infile) ; - return 1 ; - } ; - /* Open the output file. */ - if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo))) - { printf ("Not able to open output file %s.\n", outfilename) ; - puts (sf_strerror (NULL)) ; - sf_close (infile) ; - return 1 ; - } ; - - /* While there are.frames in the input file, read them, process - ** them and write them to the output file. - */ - while ((readcount = (int) sf_read_double (infile, data, BUFFER_LEN))) - { process_data (data, readcount, sfinfo.channels) ; - sf_write_double (outfile, data, readcount) ; - } ; - - /* Close input and output files. */ - sf_close (infile) ; - sf_close (outfile) ; - - return 0 ; -} /* main */ - -static void -process_data (double *data, int count, int channels) -{ double channel_gain [MAX_CHANNELS] = { 0.5, 0.8, 0.1, 0.4, 0.4, 0.9 } ; - int k, chan ; - - /* Process the data here. - ** If the soundfile contains more then 1 channel you need to take care of - ** the data interleaving youself. - ** Current we just apply a channel dependant gain. - */ - - for (chan = 0 ; chan < channels ; chan ++) - for (k = chan ; k < count ; k+= channels) - data [k] *= channel_gain [chan] ; - - return ; -} /* process_data */ - diff --git a/Engine/lib/libsndfile/examples/sndfile-loopify.c b/Engine/lib/libsndfile/examples/sndfile-loopify.c deleted file mode 100644 index 12b6b6bb6..000000000 --- a/Engine/lib/libsndfile/examples/sndfile-loopify.c +++ /dev/null @@ -1,175 +0,0 @@ -/* -** Copyright (C) 1999-2015 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -/* -** A quick/rough hack to add SF_INSTRUMENT data to a file. It compiles, but -** no guarantees beyond that. Happy to receive patches to fix/improve it. -** -** Code for this was stolen from programs/sndfile-convert.c and related code. -*/ - -#include -#include -#include -#include - -#include - -#define BUFFER_LEN (1 << 14) - -const char * program_name (const char * argv0) ; -static void sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ; -static void add_instrument_data (SNDFILE *outfile, const SF_INFO * in_info) ; - -static void -usage_exit (const char *progname) -{ - printf ("\nUsage : %s \n", progname) ; - puts ("") ; - exit (1) ; -} /* usage_exit */ - -int -main (int argc, char * argv []) -{ const char *progname, *infilename, *outfilename ; - SNDFILE *infile = NULL, *outfile = NULL ; - SF_INFO in_sfinfo, out_sfinfo ; - - progname = program_name (argv [0]) ; - - if (argc < 3 || argc > 5) - usage_exit (progname) ; - - infilename = argv [argc-2] ; - outfilename = argv [argc-1] ; - - if (strcmp (infilename, outfilename) == 0) - { printf ("Error : Input and output filenames are the same.\n\n") ; - usage_exit (progname) ; - } ; - - if (strlen (infilename) > 1 && infilename [0] == '-') - { printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ; - usage_exit (progname) ; - } ; - - if (outfilename [0] == '-') - { printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ; - usage_exit (progname) ; - } ; - - memset (&in_sfinfo, 0, sizeof (in_sfinfo)) ; - - if ((infile = sf_open (infilename, SFM_READ, &in_sfinfo)) == NULL) - { printf ("Not able to open input file %s.\n", infilename) ; - puts (sf_strerror (NULL)) ; - return 1 ; - } ; - - memcpy (&out_sfinfo, &in_sfinfo, sizeof (out_sfinfo)) ; - /* Open the output file. */ - if ((outfile = sf_open (outfilename, SFM_WRITE, &out_sfinfo)) == NULL) - { printf ("Not able to open output file %s : %s\n", outfilename, sf_strerror (NULL)) ; - sf_close (infile) ; - return 1 ; - } ; - - /* Add the loop data */ - add_instrument_data (outfile, &in_sfinfo) ; - - /* Copy the audio data */ - sfe_copy_data_int (outfile, infile, in_sfinfo.channels) ; - - sf_close (infile) ; - sf_close (outfile) ; - - return 0 ; -} /* main */ - -const char * -program_name (const char * argv0) -{ const char * tmp ; - - tmp = strrchr (argv0, '/') ; - argv0 = tmp ? tmp + 1 : argv0 ; - - /* Remove leading libtool name mangling. */ - if (strstr (argv0, "lt-") == argv0) - return argv0 + 3 ; - - return argv0 ; -} /* program_name */ - -static void -sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) -{ static int data [BUFFER_LEN] ; - int frames, readcount ; - - frames = BUFFER_LEN / channels ; - readcount = frames ; - - while (readcount > 0) - { readcount = (int) sf_readf_int (infile, data, frames) ; - sf_writef_int (outfile, data, readcount) ; - } ; - - return ; -} /* sfe_copy_data_int */ - -static void -add_instrument_data (SNDFILE *file, const SF_INFO *info) -{ SF_INSTRUMENT instr ; - - memset (&instr, 0, sizeof (instr)) ; - - instr.gain = 1 ; - instr.basenote = 0 ; - instr.detune = 0 ; - instr.velocity_lo = 0 ; - instr.velocity_hi = 0 ; - instr.key_lo = 0 ; - instr.key_hi = 0 ; - instr.loop_count = 1 ; - - instr.loops [0].mode = SF_LOOP_FORWARD ; - instr.loops [0].start = 0 ; - instr.loops [0].end = info->frames ; - instr.loops [0].count = 0 ; - - if (sf_command (file, SFC_SET_INSTRUMENT, &instr, sizeof (instr)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_INSTRUMENT) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - - return ; -} /* add_instrument_data */ - diff --git a/Engine/lib/libsndfile/examples/sndfile-to-text.c b/Engine/lib/libsndfile/examples/sndfile-to-text.c deleted file mode 100644 index 58ee06947..000000000 --- a/Engine/lib/libsndfile/examples/sndfile-to-text.c +++ /dev/null @@ -1,168 +0,0 @@ -/* -** Copyright (C) 2008-2016 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include -#include - -#include - -#define BLOCK_SIZE 4096 - -#ifdef DBL_DECIMAL_DIG - #define OP_DBL_Digs (DBL_DECIMAL_DIG) -#else - #ifdef DECIMAL_DIG - #define OP_DBL_Digs (DECIMAL_DIG) - #else - #define OP_DBL_Digs (DBL_DIG + 3) - #endif -#endif - -static void -print_usage (char *progname) -{ printf ("\nUsage : %s [--full-precision] \n", progname) ; - puts ("\n" - " Where the output file will contain a line for each frame\n" - " and a column for each channel.\n" - ) ; - -} /* print_usage */ - -static int -convert_to_text (SNDFILE * infile, FILE * outfile, int channels, int full_precision) -{ float *buf ; - sf_count_t frames ; - int k, m, readcount ; - - buf = malloc (BLOCK_SIZE * sizeof (float)) ; - if (buf == NULL) - { printf ("Error : Out of memory.\n\n") ; - return 1 ; - } ; - - frames = BLOCK_SIZE / channels ; - - while ((readcount = (int) sf_readf_float (infile, buf, frames)) > 0) - { for (k = 0 ; k < readcount ; k++) - { for (m = 0 ; m < channels ; m++) - if (full_precision) - fprintf (outfile, " %.*e", OP_DBL_Digs - 1, buf [k * channels + m]) ; - else - fprintf (outfile, " % 12.10f", buf [k * channels + m]) ; - fprintf (outfile, "\n") ; - } ; - } ; - - free (buf) ; - - return 0 ; -} /* convert_to_text */ - -int -main (int argc, char * argv []) -{ char *progname, *infilename, *outfilename ; - SNDFILE *infile = NULL ; - FILE *outfile = NULL ; - SF_INFO sfinfo ; - int full_precision = 0 ; - int ret = 1 ; - - progname = strrchr (argv [0], '/') ; - progname = progname ? progname + 1 : argv [0] ; - - switch (argc) - { case 4 : - if (!strcmp ("--full-precision", argv [3])) - { print_usage (progname) ; - goto cleanup ; - } ; - full_precision = 1 ; - argv++ ; - case 3 : - break ; - default: - print_usage (progname) ; - goto cleanup ; - } ; - - infilename = argv [1] ; - outfilename = argv [2] ; - - if (strcmp (infilename, outfilename) == 0) - { printf ("Error : Input and output filenames are the same.\n\n") ; - print_usage (progname) ; - goto cleanup ; - } ; - - if (infilename [0] == '-') - { printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ; - print_usage (progname) ; - goto cleanup ; - } ; - - if (outfilename [0] == '-') - { printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ; - print_usage (progname) ; - goto cleanup ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL) - { printf ("Not able to open input file %s.\n", infilename) ; - puts (sf_strerror (NULL)) ; - goto cleanup ; - } ; - - /* Open the output file. */ - if ((outfile = fopen (outfilename, "w")) == NULL) - { printf ("Not able to open output file %s : %s\n", outfilename, sf_strerror (NULL)) ; - goto cleanup ; - } ; - - fprintf (outfile, "# Converted from file %s.\n", infilename) ; - fprintf (outfile, "# Channels %d, Sample rate %d\n", sfinfo.channels, sfinfo.samplerate) ; - - ret = convert_to_text (infile, outfile, sfinfo.channels, full_precision) ; - -cleanup : - - sf_close (infile) ; - if (outfile != NULL) - fclose (outfile) ; - - return ret ; -} /* main */ - diff --git a/Engine/lib/libsndfile/examples/sndfilehandle.cc b/Engine/lib/libsndfile/examples/sndfilehandle.cc deleted file mode 100644 index c9a1931ae..000000000 --- a/Engine/lib/libsndfile/examples/sndfilehandle.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -** Copyright (C) 2007-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include - -#include - -#define BUFFER_LEN 1024 - -static void -create_file (const char * fname, int format) -{ static short buffer [BUFFER_LEN] ; - - SndfileHandle file ; - int channels = 2 ; - int srate = 48000 ; - - printf ("Creating file named '%s'\n", fname) ; - - file = SndfileHandle (fname, SFM_WRITE, format, channels, srate) ; - - memset (buffer, 0, sizeof (buffer)) ; - - file.write (buffer, BUFFER_LEN) ; - - puts ("") ; - /* - ** The SndfileHandle object will automatically close the file and - ** release all allocated memory when the object goes out of scope. - ** This is the Resource Acquisition Is Initailization idom. - ** See : http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization - */ -} /* create_file */ - -static void -read_file (const char * fname) -{ static short buffer [BUFFER_LEN] ; - - SndfileHandle file ; - - file = SndfileHandle (fname) ; - - printf ("Opened file '%s'\n", fname) ; - printf (" Sample rate : %d\n", file.samplerate ()) ; - printf (" Channels : %d\n", file.channels ()) ; - - file.read (buffer, BUFFER_LEN) ; - - puts ("") ; - - /* RAII takes care of destroying SndfileHandle object. */ -} /* read_file */ - -int -main (void) -{ const char * fname = "test.wav" ; - - puts ("\nSimple example showing usage of the C++ SndfileHandle object.\n") ; - - create_file (fname, SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - - read_file (fname) ; - - puts ("Done.\n") ; - return 0 ; -} /* main */ - - diff --git a/Engine/lib/libsndfile/include/sndfile.h b/Engine/lib/libsndfile/include/sndfile.h deleted file mode 100644 index ed992083a..000000000 --- a/Engine/lib/libsndfile/include/sndfile.h +++ /dev/null @@ -1,885 +0,0 @@ -/* -** Copyright (C) 1999-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** sndfile.h -- system-wide definitions -** -** API documentation is in the doc/ directory of the source code tarball -** and at http://libsndfile.github.io/libsndfile/api.html. -*/ - -#ifndef SNDFILE_H -#define SNDFILE_H - -/* This is the version 1.0.X header file. */ -#define SNDFILE_1 - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* The following file types can be read and written. -** A file type would consist of a major type (ie SF_FORMAT_WAV) bitwise -** ORed with a minor type (ie SF_FORMAT_PCM). SF_FORMAT_TYPEMASK and -** SF_FORMAT_SUBMASK can be used to separate the major and minor file -** types. -*/ - -enum -{ /* Major formats. */ - SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian default). */ - SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */ - SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */ - SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */ - SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */ - SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */ - SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */ - SF_FORMAT_VOC = 0x080000, /* VOC files. */ - SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */ - SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */ - SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */ - SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */ - SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */ - SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */ - SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */ - SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */ - SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */ - SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */ - SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */ - SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */ - SF_FORMAT_CAF = 0x180000, /* Core Audio File format */ - SF_FORMAT_WVE = 0x190000, /* Psion WVE format */ - SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */ - SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */ - SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */ - SF_FORMAT_MPEG = 0x230000, /* MPEG-1/2 audio stream */ - - /* Subtypes from here on. */ - - SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */ - SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */ - SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */ - SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */ - - SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */ - - SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */ - SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */ - - SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */ - SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */ - SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */ - SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */ - - SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */ - SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */ - - SF_FORMAT_NMS_ADPCM_16 = 0x0022, /* 16kbs NMS G721-variant encoding. */ - SF_FORMAT_NMS_ADPCM_24 = 0x0023, /* 24kbs NMS G721-variant encoding. */ - SF_FORMAT_NMS_ADPCM_32 = 0x0024, /* 32kbs NMS G721-variant encoding. */ - - SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */ - SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */ - SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */ - - SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */ - SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */ - SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */ - SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */ - - SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */ - SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */ - - SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */ - SF_FORMAT_OPUS = 0x0064, /* Xiph/Skype Opus encoding. */ - - SF_FORMAT_ALAC_16 = 0x0070, /* Apple Lossless Audio Codec (16 bit). */ - SF_FORMAT_ALAC_20 = 0x0071, /* Apple Lossless Audio Codec (20 bit). */ - SF_FORMAT_ALAC_24 = 0x0072, /* Apple Lossless Audio Codec (24 bit). */ - SF_FORMAT_ALAC_32 = 0x0073, /* Apple Lossless Audio Codec (32 bit). */ - - SF_FORMAT_MPEG_LAYER_I = 0x0080, /* MPEG-1 Audio Layer I */ - SF_FORMAT_MPEG_LAYER_II = 0x0081, /* MPEG-1 Audio Layer II */ - SF_FORMAT_MPEG_LAYER_III = 0x0082, /* MPEG-2 Audio Layer III */ - - /* Endian-ness options. */ - - SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ - SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */ - SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */ - SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */ - - SF_FORMAT_SUBMASK = 0x0000FFFF, - SF_FORMAT_TYPEMASK = 0x0FFF0000, - SF_FORMAT_ENDMASK = 0x30000000 -} ; - -/* -** The following are the valid command numbers for the sf_command() -** interface. The use of these commands is documented in the file -** command.html in the doc directory of the source code distribution. -*/ - -enum -{ SFC_GET_LIB_VERSION = 0x1000, - SFC_GET_LOG_INFO = 0x1001, - SFC_GET_CURRENT_SF_INFO = 0x1002, - - - SFC_GET_NORM_DOUBLE = 0x1010, - SFC_GET_NORM_FLOAT = 0x1011, - SFC_SET_NORM_DOUBLE = 0x1012, - SFC_SET_NORM_FLOAT = 0x1013, - SFC_SET_SCALE_FLOAT_INT_READ = 0x1014, - SFC_SET_SCALE_INT_FLOAT_WRITE = 0x1015, - - SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020, - SFC_GET_SIMPLE_FORMAT = 0x1021, - - SFC_GET_FORMAT_INFO = 0x1028, - - SFC_GET_FORMAT_MAJOR_COUNT = 0x1030, - SFC_GET_FORMAT_MAJOR = 0x1031, - SFC_GET_FORMAT_SUBTYPE_COUNT = 0x1032, - SFC_GET_FORMAT_SUBTYPE = 0x1033, - - SFC_CALC_SIGNAL_MAX = 0x1040, - SFC_CALC_NORM_SIGNAL_MAX = 0x1041, - SFC_CALC_MAX_ALL_CHANNELS = 0x1042, - SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043, - SFC_GET_SIGNAL_MAX = 0x1044, - SFC_GET_MAX_ALL_CHANNELS = 0x1045, - - SFC_SET_ADD_PEAK_CHUNK = 0x1050, - - SFC_UPDATE_HEADER_NOW = 0x1060, - SFC_SET_UPDATE_HEADER_AUTO = 0x1061, - - SFC_FILE_TRUNCATE = 0x1080, - - SFC_SET_RAW_START_OFFSET = 0x1090, - - /* Commands reserved for dithering, which is not implemented. */ - SFC_SET_DITHER_ON_WRITE = 0x10A0, - SFC_SET_DITHER_ON_READ = 0x10A1, - - SFC_GET_DITHER_INFO_COUNT = 0x10A2, - SFC_GET_DITHER_INFO = 0x10A3, - - SFC_GET_EMBED_FILE_INFO = 0x10B0, - - SFC_SET_CLIPPING = 0x10C0, - SFC_GET_CLIPPING = 0x10C1, - - SFC_GET_CUE_COUNT = 0x10CD, - SFC_GET_CUE = 0x10CE, - SFC_SET_CUE = 0x10CF, - - SFC_GET_INSTRUMENT = 0x10D0, - SFC_SET_INSTRUMENT = 0x10D1, - - SFC_GET_LOOP_INFO = 0x10E0, - - SFC_GET_BROADCAST_INFO = 0x10F0, - SFC_SET_BROADCAST_INFO = 0x10F1, - - SFC_GET_CHANNEL_MAP_INFO = 0x1100, - SFC_SET_CHANNEL_MAP_INFO = 0x1101, - - SFC_RAW_DATA_NEEDS_ENDSWAP = 0x1110, - - /* Support for Wavex Ambisonics Format */ - SFC_WAVEX_SET_AMBISONIC = 0x1200, - SFC_WAVEX_GET_AMBISONIC = 0x1201, - - /* - ** RF64 files can be set so that on-close, writable files that have less - ** than 4GB of data in them are converted to RIFF/WAV, as per EBU - ** recommendations. - */ - SFC_RF64_AUTO_DOWNGRADE = 0x1210, - - SFC_SET_VBR_ENCODING_QUALITY = 0x1300, - SFC_SET_COMPRESSION_LEVEL = 0x1301, - - /* Ogg format commands */ - SFC_SET_OGG_PAGE_LATENCY_MS = 0x1302, - SFC_SET_OGG_PAGE_LATENCY = 0x1303, - SFC_GET_OGG_STREAM_SERIALNO = 0x1306, - - SFC_GET_BITRATE_MODE = 0x1304, - SFC_SET_BITRATE_MODE = 0x1305, - - /* Cart Chunk support */ - SFC_SET_CART_INFO = 0x1400, - SFC_GET_CART_INFO = 0x1401, - - /* Opus files original samplerate metadata */ - SFC_SET_ORIGINAL_SAMPLERATE = 0x1500, - SFC_GET_ORIGINAL_SAMPLERATE = 0x1501, - - /* Following commands for testing only. */ - SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, - - /* - ** These SFC_SET_ADD_* values are deprecated and will disappear at some - ** time in the future. They are guaranteed to be here up to and - ** including version 1.0.8 to avoid breakage of existing software. - ** They currently do nothing and will continue to do nothing. - */ - SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051, - - SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, - SFC_SET_ADD_DITHER_ON_READ = 0x1071 -} ; - - -/* -** String types that can be set and read from files. Not all file types -** support this and even the file types which support one, may not support -** all string types. -*/ - -enum -{ SF_STR_TITLE = 0x01, - SF_STR_COPYRIGHT = 0x02, - SF_STR_SOFTWARE = 0x03, - SF_STR_ARTIST = 0x04, - SF_STR_COMMENT = 0x05, - SF_STR_DATE = 0x06, - SF_STR_ALBUM = 0x07, - SF_STR_LICENSE = 0x08, - SF_STR_TRACKNUMBER = 0x09, - SF_STR_GENRE = 0x10 -} ; - -/* -** Use the following as the start and end index when doing metadata -** transcoding. -*/ - -#define SF_STR_FIRST SF_STR_TITLE -#define SF_STR_LAST SF_STR_GENRE - -enum -{ /* True and false */ - SF_FALSE = 0, - SF_TRUE = 1, - - /* Modes for opening files. */ - SFM_READ = 0x10, - SFM_WRITE = 0x20, - SFM_RDWR = 0x30, - - SF_AMBISONIC_NONE = 0x40, - SF_AMBISONIC_B_FORMAT = 0x41 -} ; - -/* Public error values. These are guaranteed to remain unchanged for the duration -** of the library major version number. -** There are also a large number of private error numbers which are internal to -** the library which can change at any time. -*/ - -enum -{ SF_ERR_NO_ERROR = 0, - SF_ERR_UNRECOGNISED_FORMAT = 1, - SF_ERR_SYSTEM = 2, - SF_ERR_MALFORMED_FILE = 3, - SF_ERR_UNSUPPORTED_ENCODING = 4 -} ; - - -/* Channel map values (used with SFC_SET/GET_CHANNEL_MAP). -*/ - -enum -{ SF_CHANNEL_MAP_INVALID = 0, - SF_CHANNEL_MAP_MONO = 1, - SF_CHANNEL_MAP_LEFT, /* Apple calls this 'Left' */ - SF_CHANNEL_MAP_RIGHT, /* Apple calls this 'Right' */ - SF_CHANNEL_MAP_CENTER, /* Apple calls this 'Center' */ - SF_CHANNEL_MAP_FRONT_LEFT, - SF_CHANNEL_MAP_FRONT_RIGHT, - SF_CHANNEL_MAP_FRONT_CENTER, - SF_CHANNEL_MAP_REAR_CENTER, /* Apple calls this 'Center Surround', Msft calls this 'Back Center' */ - SF_CHANNEL_MAP_REAR_LEFT, /* Apple calls this 'Left Surround', Msft calls this 'Back Left' */ - SF_CHANNEL_MAP_REAR_RIGHT, /* Apple calls this 'Right Surround', Msft calls this 'Back Right' */ - SF_CHANNEL_MAP_LFE, /* Apple calls this 'LFEScreen', Msft calls this 'Low Frequency' */ - SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, /* Apple calls this 'Left Center' */ - SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, /* Apple calls this 'Right Center */ - SF_CHANNEL_MAP_SIDE_LEFT, /* Apple calls this 'Left Surround Direct' */ - SF_CHANNEL_MAP_SIDE_RIGHT, /* Apple calls this 'Right Surround Direct' */ - SF_CHANNEL_MAP_TOP_CENTER, /* Apple calls this 'Top Center Surround' */ - SF_CHANNEL_MAP_TOP_FRONT_LEFT, /* Apple calls this 'Vertical Height Left' */ - SF_CHANNEL_MAP_TOP_FRONT_RIGHT, /* Apple calls this 'Vertical Height Right' */ - SF_CHANNEL_MAP_TOP_FRONT_CENTER, /* Apple calls this 'Vertical Height Center' */ - SF_CHANNEL_MAP_TOP_REAR_LEFT, /* Apple and MS call this 'Top Back Left' */ - SF_CHANNEL_MAP_TOP_REAR_RIGHT, /* Apple and MS call this 'Top Back Right' */ - SF_CHANNEL_MAP_TOP_REAR_CENTER, /* Apple and MS call this 'Top Back Center' */ - - SF_CHANNEL_MAP_AMBISONIC_B_W, - SF_CHANNEL_MAP_AMBISONIC_B_X, - SF_CHANNEL_MAP_AMBISONIC_B_Y, - SF_CHANNEL_MAP_AMBISONIC_B_Z, - - SF_CHANNEL_MAP_MAX -} ; - -/* Bitrate mode values (for use with SFC_GET/SET_BITRATE_MODE) -*/ -enum -{ SF_BITRATE_MODE_CONSTANT = 0, - SF_BITRATE_MODE_AVERAGE, - SF_BITRATE_MODE_VARIABLE -} ; - - -/* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */ - -typedef struct sf_private_tag SNDFILE ; - -/* The following typedef is system specific and is defined when libsndfile is -** compiled. sf_count_t will be a 64 bit value when the underlying OS allows -** 64 bit file offsets. -** On windows, we need to allow the same header file to be compiler by both GCC -** and the Microsoft compiler. -*/ - -typedef int64_t sf_count_t ; -#ifndef SF_COUNT_MAX -#define SF_COUNT_MAX INT64_MAX -#endif - - -/* A pointer to a SF_INFO structure is passed to sf_open () and filled in. -** On write, the SF_INFO structure is filled in by the user and passed into -** sf_open (). -*/ - -struct SF_INFO -{ sf_count_t frames ; /* Used to be called samples. Changed to avoid confusion. */ - int samplerate ; - int channels ; - int format ; - int sections ; - int seekable ; -} ; - -typedef struct SF_INFO SF_INFO ; - -/* The SF_FORMAT_INFO struct is used to retrieve information about the sound -** file formats libsndfile supports using the sf_command () interface. -** -** Using this interface will allow applications to support new file formats -** and encoding types when libsndfile is upgraded, without requiring -** re-compilation of the application. -** -** Please consult the libsndfile documentation (particularly the information -** on the sf_command () interface) for examples of its use. -*/ - -typedef struct -{ int format ; - const char *name ; - const char *extension ; -} SF_FORMAT_INFO ; - -/* -** Enums and typedefs for adding dither on read and write. -** Reserved for future implementation. -*/ - -enum -{ SFD_DEFAULT_LEVEL = 0, - SFD_CUSTOM_LEVEL = 0x40000000, - - SFD_NO_DITHER = 500, - SFD_WHITE = 501, - SFD_TRIANGULAR_PDF = 502 -} ; - -typedef struct -{ int type ; - double level ; - const char *name ; -} SF_DITHER_INFO ; - -/* Struct used to retrieve information about a file embedded within a -** larger file. See SFC_GET_EMBED_FILE_INFO. -*/ - -typedef struct -{ sf_count_t offset ; - sf_count_t length ; -} SF_EMBED_FILE_INFO ; - -/* -** Struct used to retrieve cue marker information from a file -*/ - -typedef struct -{ int32_t indx ; - uint32_t position ; - int32_t fcc_chunk ; - int32_t chunk_start ; - int32_t block_start ; - uint32_t sample_offset ; - char name [256] ; -} SF_CUE_POINT ; - -#define SF_CUES_VAR(count) \ - struct \ - { uint32_t cue_count ; \ - SF_CUE_POINT cue_points [count] ; \ - } - -typedef SF_CUES_VAR (100) SF_CUES ; - -/* -** Structs used to retrieve music sample information from a file. -*/ - -enum -{ /* - ** The loop mode field in SF_INSTRUMENT will be one of the following. - */ - SF_LOOP_NONE = 800, - SF_LOOP_FORWARD, - SF_LOOP_BACKWARD, - SF_LOOP_ALTERNATING -} ; - -typedef struct -{ int gain ; - char basenote, detune ; - char velocity_lo, velocity_hi ; - char key_lo, key_hi ; - int loop_count ; - - struct - { int mode ; - uint32_t start ; - uint32_t end ; - uint32_t count ; - } loops [16] ; /* make variable in a sensible way */ -} SF_INSTRUMENT ; - - - -/* Struct used to retrieve loop information from a file.*/ -typedef struct -{ - short time_sig_num ; /* any positive integer > 0 */ - short time_sig_den ; /* any positive power of 2 > 0 */ - int loop_mode ; /* see SF_LOOP enum */ - - int num_beats ; /* this is NOT the amount of quarter notes !!!*/ - /* a full bar of 4/4 is 4 beats */ - /* a full bar of 7/8 is 7 beats */ - - float bpm ; /* suggestion, as it can be calculated using other fields:*/ - /* file's length, file's sampleRate and our time_sig_den*/ - /* -> bpms are always the amount of _quarter notes_ per minute */ - - int root_key ; /* MIDI note, or -1 for None */ - int future [6] ; -} SF_LOOP_INFO ; - - -/* Struct used to retrieve broadcast (EBU) information from a file. -** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE. -*/ -#define SF_BROADCAST_INFO_VAR(coding_hist_size) \ - struct \ - { char description [256] ; \ - char originator [32] ; \ - char originator_reference [32] ; \ - char origination_date [10] ; \ - char origination_time [8] ; \ - uint32_t time_reference_low ; \ - uint32_t time_reference_high ; \ - short version ; \ - char umid [64] ; \ - int16_t loudness_value ; \ - int16_t loudness_range ; \ - int16_t max_true_peak_level ; \ - int16_t max_momentary_loudness ; \ - int16_t max_shortterm_loudness ; \ - char reserved [180] ; \ - uint32_t coding_history_size ; \ - char coding_history [coding_hist_size] ; \ - } - -/* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */ -typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ; - -struct SF_CART_TIMER -{ char usage [4] ; - int32_t value ; -} ; - -typedef struct SF_CART_TIMER SF_CART_TIMER ; - -#define SF_CART_INFO_VAR(p_tag_text_size) \ - struct \ - { char version [4] ; \ - char title [64] ; \ - char artist [64] ; \ - char cut_id [64] ; \ - char client_id [64] ; \ - char category [64] ; \ - char classification [64] ; \ - char out_cue [64] ; \ - char start_date [10] ; \ - char start_time [8] ; \ - char end_date [10] ; \ - char end_time [8] ; \ - char producer_app_id [64] ; \ - char producer_app_version [64] ; \ - char user_def [64] ; \ - int32_t level_reference ; \ - SF_CART_TIMER post_timers [8] ; \ - char reserved [276] ; \ - char url [1024] ; \ - uint32_t tag_text_size ; \ - char tag_text [p_tag_text_size] ; \ - } - -typedef SF_CART_INFO_VAR (256) SF_CART_INFO ; - -/* Virtual I/O functionality. */ - -typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ; -typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ; -typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ; -typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ; -typedef sf_count_t (*sf_vio_tell) (void *user_data) ; - -struct SF_VIRTUAL_IO -{ sf_vio_get_filelen get_filelen ; - sf_vio_seek seek ; - sf_vio_read read ; - sf_vio_write write ; - sf_vio_tell tell ; -} ; - -typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; - - -/* Open the specified file for read, write or both. On error, this will -** return a NULL pointer. To find the error number, pass a NULL SNDFILE -** to sf_strerror (). -** All calls to sf_open() should be matched with a call to sf_close(). -*/ - -SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; - - -/* Use the existing file descriptor to create a SNDFILE object. If close_desc -** is TRUE, the file descriptor will be closed when sf_close() is called. If -** it is FALSE, the descriptor will not be closed. -** When passed a descriptor like this, the library will assume that the start -** of file header is at the current file offset. This allows sound files within -** larger container files to be read and/or written. -** On error, this will return a NULL pointer. To find the error number, pass a -** NULL SNDFILE to sf_strerror (). -** All calls to sf_open_fd() should be matched with a call to sf_close(). - -*/ - -SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; - -SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; - - -/* sf_error () returns a error number which can be translated to a text -** string using sf_error_number(). -*/ - -int sf_error (SNDFILE *sndfile) ; - - -/* sf_strerror () returns to the caller a pointer to the current error message for -** the given SNDFILE. -*/ - -const char* sf_strerror (SNDFILE *sndfile) ; - - -/* sf_error_number () allows the retrieval of the error string for each internal -** error number. -** -*/ - -const char* sf_error_number (int errnum) ; - - -/* The following two error functions are deprecated but they will remain in the -** library for the foreseeable future. The function sf_strerror() should be used -** in their place. -*/ - -int sf_perror (SNDFILE *sndfile) ; -int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; - - -/* Allow the caller to retrieve information from or change aspects of the -** library behaviour. -*/ - -int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ; - - -/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ - -int sf_format_check (const SF_INFO *info) ; - - -/* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses -** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as -** stdio.h function fseek (). -** An offset of zero with whence set to SEEK_SET will position the -** read / write pointer to the first data sample. -** On success sf_seek returns the current position in (multi-channel) -** samples from the start of the file. -** Please see the libsndfile documentation for moving the read pointer -** separately from the write pointer on files open in mode SFM_RDWR. -** On error all of these functions return -1. -*/ - -enum -{ SF_SEEK_SET = SEEK_SET, - SF_SEEK_CUR = SEEK_CUR, - SF_SEEK_END = SEEK_END -} ; - -sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; - - -/* Functions for retrieving and setting string data within sound files. -** Not all file types support this features; AIFF and WAV do. For both -** functions, the str_type parameter must be one of the SF_STR_* values -** defined above. -** On error, sf_set_string() returns non-zero while sf_get_string() -** returns NULL. -*/ - -int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ; - -const char* sf_get_string (SNDFILE *sndfile, int str_type) ; - - -/* Return the library version string. */ - -const char * sf_version_string (void) ; - -/* Return the current byterate at this point in the file. The byte rate in this -** case is the number of bytes per second of audio data. For instance, for a -** stereo, 18 bit PCM encoded file with an 16kHz sample rate, the byte rate -** would be 2 (stereo) * 2 (two bytes per sample) * 16000 => 64000 bytes/sec. -** For some file formats the returned value will be accurate and exact, for some -** it will be a close approximation, for some it will be the average bitrate for -** the whole file and for some it will be a time varying value that was accurate -** when the file was most recently read or written. -** To get the bitrate, multiple this value by 8. -** Returns -1 for unknown. -*/ -int sf_current_byterate (SNDFILE *sndfile) ; - -/* Functions for reading/writing the waveform data of a sound file. -*/ - -sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; -sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ; - - -/* Functions for reading and writing the data chunk in terms of frames. -** The number of items actually read/written = frames * number of channels. -** sf_xxxx_raw read/writes the raw data bytes from/to the file -** sf_xxxx_short passes data in the native short format -** sf_xxxx_int passes data in the native int format -** sf_xxxx_float passes data in the native float format -** sf_xxxx_double passes data in the native double format -** All of these read/write function return number of frames read/written. -*/ - -sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; -sf_count_t sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) ; - -sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; -sf_count_t sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) ; - -sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; -sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) ; - -sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; -sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ; - - -/* Functions for reading and writing the data chunk in terms of items. -** Otherwise similar to above. -** All of these read/write function return number of items read/written. -*/ - -sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; -sf_count_t sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t items) ; - -sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; -sf_count_t sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t items) ; - -sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; -sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) ; - -sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; -sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ; - - -/* Close the SNDFILE and clean up all memory allocations associated with this -** file. -** Returns 0 on success, or an error number. -*/ - -int sf_close (SNDFILE *sndfile) ; - - -/* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file -** to force the writing of data to disk. If the file is opened SFM_READ -** no action is taken. -*/ - -void sf_write_sync (SNDFILE *sndfile) ; - - - -/* The function sf_wchar_open() is Windows Only! -** Open a file passing in a Windows Unicode filename. Otherwise, this is -** the same as sf_open(). -*/ - -#ifdef _WIN32 -SNDFILE* sf_wchar_open (const wchar_t *wpath, int mode, SF_INFO *sfinfo) ; -#endif - - - - -/* Getting and setting of chunks from within a sound file. -** -** These functions allow the getting and setting of chunks within a sound file -** (for those formats which allow it). -** -** These functions fail safely. Specifically, they will not allow you to overwrite -** existing chunks or add extra versions of format specific reserved chunks but -** should allow you to retrieve any and all chunks (may not be implemented for -** all chunks or all file formats). -*/ - -struct SF_CHUNK_INFO -{ char id [64] ; /* The chunk identifier. */ - unsigned id_size ; /* The size of the chunk identifier. */ - unsigned datalen ; /* The size of that data. */ - void *data ; /* Pointer to the data. */ -} ; - -typedef struct SF_CHUNK_INFO SF_CHUNK_INFO ; - -/* Set the specified chunk info (must be done before any audio data is written -** to the file). This will fail for format specific reserved chunks. -** The chunk_info->data pointer must be valid until the file is closed. -** Returns SF_ERR_NO_ERROR on success or non-zero on failure. -*/ -int sf_set_chunk (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ; - -/* -** An opaque structure to an iterator over the all chunks of a given id -*/ -typedef struct SF_CHUNK_ITERATOR SF_CHUNK_ITERATOR ; - -/* Get an iterator for all chunks matching chunk_info. -** The iterator will point to the first chunk matching chunk_info. -** Chunks are matching, if (chunk_info->id) matches the first -** (chunk_info->id_size) bytes of a chunk found in the SNDFILE* handle. -** If chunk_info is NULL, an iterator to all chunks in the SNDFILE* handle -** is returned. -** The values of chunk_info->datalen and chunk_info->data are ignored. -** If no matching chunks are found in the sndfile, NULL is returned. -** The returned iterator will stay valid until one of the following occurs: -** a) The sndfile is closed. -** b) A new chunk is added using sf_set_chunk(). -** c) Another chunk iterator function is called on the same SNDFILE* handle -** that causes the iterator to be modified. -** The memory for the iterator belongs to the SNDFILE* handle and is freed when -** sf_close() is called. -*/ -SF_CHUNK_ITERATOR * -sf_get_chunk_iterator (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ; - -/* Iterate through chunks by incrementing the iterator. -** Increments the iterator and returns a handle to the new one. -** After this call, iterator will no longer be valid, and you must use the -** newly returned handle from now on. -** The returned handle can be used to access the next chunk matching -** the criteria as defined in sf_get_chunk_iterator(). -** If iterator points to the last chunk, this will free all resources -** associated with iterator and return NULL. -** The returned iterator will stay valid until sf_get_chunk_iterator_next -** is called again, the sndfile is closed or a new chunk us added. -*/ -SF_CHUNK_ITERATOR * -sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) ; - - -/* Get the size of the specified chunk. -** If the specified chunk exists, the size will be returned in the -** datalen field of the SF_CHUNK_INFO struct. -** Additionally, the id of the chunk will be copied to the id -** field of the SF_CHUNK_INFO struct and it's id_size field will -** be updated accordingly. -** If the chunk doesn't exist chunk_info->datalen will be zero, and the -** id and id_size fields will be undefined. -** The function will return SF_ERR_NO_ERROR on success or non-zero on -** failure. -*/ -int -sf_get_chunk_size (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ; - -/* Get the specified chunk data. -** If the specified chunk exists, up to chunk_info->datalen bytes of -** the chunk data will be copied into the chunk_info->data buffer -** (allocated by the caller) and the chunk_info->datalen field -** updated to reflect the size of the data. The id and id_size -** field will be updated according to the retrieved chunk -** If the chunk doesn't exist chunk_info->datalen will be zero, and the -** id and id_size fields will be undefined. -** The function will return SF_ERR_NO_ERROR on success or non-zero on -** failure. -*/ -int -sf_get_chunk_data (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ; - - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* SNDFILE_H */ diff --git a/Engine/lib/libsndfile/include/sndfile.hh b/Engine/lib/libsndfile/include/sndfile.hh deleted file mode 100644 index f8beb719e..000000000 --- a/Engine/lib/libsndfile/include/sndfile.hh +++ /dev/null @@ -1,484 +0,0 @@ -/* -** Copyright (C) 2005-2017 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -/* -** The above modified BSD style license (GPL and LGPL compatible) applies to -** this file. It does not apply to libsndfile itself which is released under -** the GNU LGPL or the libsndfile test suite which is released under the GNU -** GPL. -** This means that this header file can be used under this modified BSD style -** license, but the LGPL still holds for the libsndfile library itself. -*/ - -/* -** sndfile.hh -- A lightweight C++ wrapper for the libsndfile API. -** -** All the methods are inlines and all functionality is contained in this -** file. There is no separate implementation file. -** -** API documentation is in the doc/ directory of the source code tarball -** and at http://libsndfile.github.io/libsndfile/api.html. -** -** This file is intended to compile with C++98 and newer. -*/ - -#ifndef SNDFILE_HH -#define SNDFILE_HH - -#include - -#include -#include // for std::nothrow - -#if ((defined (_MSC_VER) && (_MSC_VER >= 1600)) || (__cplusplus >= 201100L)) -#define SF_NULL nullptr -#else -#define SF_NULL NULL -#endif - -class SndfileHandle -{ private : - struct SNDFILE_ref - { SNDFILE_ref (void) ; - ~SNDFILE_ref (void) ; - - SNDFILE *sf ; - SF_INFO sfinfo ; - int ref ; - } ; - - SNDFILE_ref *p ; - - public : - /* Default constructor */ - SndfileHandle (void) : p (SF_NULL) {} ; - SndfileHandle (const char *path, int mode = SFM_READ, - int format = 0, int channels = 0, int samplerate = 0) ; - SndfileHandle (std::string const & path, int mode = SFM_READ, - int format = 0, int channels = 0, int samplerate = 0) ; - SndfileHandle (int fd, bool close_desc, int mode = SFM_READ, - int format = 0, int channels = 0, int samplerate = 0) ; - SndfileHandle (SF_VIRTUAL_IO &sfvirtual, void *user_data, int mode = SFM_READ, - int format = 0, int channels = 0, int samplerate = 0) ; - -#ifdef _WIN32 - SndfileHandle (const wchar_t *wpath, int mode = SFM_READ, - int format = 0, int channels = 0, int samplerate = 0) ; -#endif - - ~SndfileHandle (void) ; - - SndfileHandle (const SndfileHandle &orig) ; - SndfileHandle & operator = (const SndfileHandle &rhs) ; - -#if (__cplusplus >= 201100L) - SndfileHandle (SndfileHandle &&orig) noexcept ; - SndfileHandle & operator = (SndfileHandle &&rhs) noexcept ; -#endif - - /* Mainly for debugging/testing. */ - int refCount (void) const { return (p == SF_NULL) ? 0 : p->ref ; } - - operator bool () const { return (p != SF_NULL) ; } - - bool operator == (const SndfileHandle &rhs) const { return (p == rhs.p) ; } - - sf_count_t frames (void) const { return p ? p->sfinfo.frames : 0 ; } - int format (void) const { return p ? p->sfinfo.format : 0 ; } - int channels (void) const { return p ? p->sfinfo.channels : 0 ; } - int samplerate (void) const { return p ? p->sfinfo.samplerate : 0 ; } - - int error (void) const ; - const char * strError (void) const ; - - int command (int cmd, void *data, int datasize) ; - - sf_count_t seek (sf_count_t frames, int whence) ; - - void writeSync (void) ; - - int setString (int str_type, const char* str) ; - - const char* getString (int str_type) const ; - - static int formatCheck (int format, int channels, int samplerate) ; - - sf_count_t read (short *ptr, sf_count_t items) ; - sf_count_t read (int *ptr, sf_count_t items) ; - sf_count_t read (float *ptr, sf_count_t items) ; - sf_count_t read (double *ptr, sf_count_t items) ; - - sf_count_t write (const short *ptr, sf_count_t items) ; - sf_count_t write (const int *ptr, sf_count_t items) ; - sf_count_t write (const float *ptr, sf_count_t items) ; - sf_count_t write (const double *ptr, sf_count_t items) ; - - sf_count_t readf (short *ptr, sf_count_t frames) ; - sf_count_t readf (int *ptr, sf_count_t frames) ; - sf_count_t readf (float *ptr, sf_count_t frames) ; - sf_count_t readf (double *ptr, sf_count_t frames) ; - - sf_count_t writef (const short *ptr, sf_count_t frames) ; - sf_count_t writef (const int *ptr, sf_count_t frames) ; - sf_count_t writef (const float *ptr, sf_count_t frames) ; - sf_count_t writef (const double *ptr, sf_count_t frames) ; - - sf_count_t readRaw (void *ptr, sf_count_t bytes) ; - sf_count_t writeRaw (const void *ptr, sf_count_t bytes) ; - - /**< Raw access to the handle. SndfileHandle keeps ownership. */ - SNDFILE * rawHandle (void) ; - - /**< Take ownership of handle, if reference count is 1. */ - SNDFILE * takeOwnership (void) ; -} ; - -/*============================================================================== -** Nothing but implementation below. -*/ - -inline -SndfileHandle::SNDFILE_ref::SNDFILE_ref (void) -: sf (SF_NULL), sfinfo (), ref (1) -{} - -inline -SndfileHandle::SNDFILE_ref::~SNDFILE_ref (void) -{ if (sf != SF_NULL) sf_close (sf) ; } - -inline -SndfileHandle::SndfileHandle (const char *path, int mode, int fmt, int chans, int srate) -: p (SF_NULL) -{ - p = new (std::nothrow) SNDFILE_ref () ; - - if (p != SF_NULL) - { p->ref = 1 ; - - p->sfinfo.frames = 0 ; - p->sfinfo.channels = chans ; - p->sfinfo.format = fmt ; - p->sfinfo.samplerate = srate ; - p->sfinfo.sections = 0 ; - p->sfinfo.seekable = 0 ; - - p->sf = sf_open (path, mode, &p->sfinfo) ; - } ; - - return ; -} /* SndfileHandle const char * constructor */ - -inline -SndfileHandle::SndfileHandle (std::string const & path, int mode, int fmt, int chans, int srate) -: p (SF_NULL) -{ - p = new (std::nothrow) SNDFILE_ref () ; - - if (p != SF_NULL) - { p->ref = 1 ; - - p->sfinfo.frames = 0 ; - p->sfinfo.channels = chans ; - p->sfinfo.format = fmt ; - p->sfinfo.samplerate = srate ; - p->sfinfo.sections = 0 ; - p->sfinfo.seekable = 0 ; - - p->sf = sf_open (path.c_str (), mode, &p->sfinfo) ; - } ; - - return ; -} /* SndfileHandle std::string constructor */ - -inline -SndfileHandle::SndfileHandle (int fd, bool close_desc, int mode, int fmt, int chans, int srate) -: p (SF_NULL) -{ - if (fd < 0) - return ; - - p = new (std::nothrow) SNDFILE_ref () ; - - if (p != SF_NULL) - { p->ref = 1 ; - - p->sfinfo.frames = 0 ; - p->sfinfo.channels = chans ; - p->sfinfo.format = fmt ; - p->sfinfo.samplerate = srate ; - p->sfinfo.sections = 0 ; - p->sfinfo.seekable = 0 ; - - p->sf = sf_open_fd (fd, mode, &p->sfinfo, close_desc) ; - } ; - - return ; -} /* SndfileHandle fd constructor */ - -inline -SndfileHandle::SndfileHandle (SF_VIRTUAL_IO &sfvirtual, void *user_data, int mode, int fmt, int chans, int srate) -: p (SF_NULL) -{ - p = new (std::nothrow) SNDFILE_ref () ; - - if (p != SF_NULL) - { p->ref = 1 ; - - p->sfinfo.frames = 0 ; - p->sfinfo.channels = chans ; - p->sfinfo.format = fmt ; - p->sfinfo.samplerate = srate ; - p->sfinfo.sections = 0 ; - p->sfinfo.seekable = 0 ; - - p->sf = sf_open_virtual (&sfvirtual, mode, &p->sfinfo, user_data) ; - } ; - - return ; -} /* SndfileHandle std::string constructor */ - -inline -SndfileHandle::~SndfileHandle (void) -{ if (p != SF_NULL && -- p->ref == 0) - delete p ; -} /* SndfileHandle destructor */ - - -inline -SndfileHandle::SndfileHandle (const SndfileHandle &orig) -: p (orig.p) -{ if (p != SF_NULL) - ++ p->ref ; -} /* SndfileHandle copy constructor */ - -inline SndfileHandle & -SndfileHandle::operator = (const SndfileHandle &rhs) -{ - if (&rhs == this) - return *this ; - if (p != SF_NULL && -- p->ref == 0) - delete p ; - - p = rhs.p ; - if (p != SF_NULL) - ++ p->ref ; - - return *this ; -} /* SndfileHandle copy assignment */ - -#if (__cplusplus >= 201100L) - -inline -SndfileHandle::SndfileHandle (SndfileHandle &&orig) noexcept -: p (orig.p) -{ - orig.p = SF_NULL ; -} /* SndfileHandle move constructor */ - -inline SndfileHandle & -SndfileHandle::operator = (SndfileHandle &&rhs) noexcept -{ - if (&rhs == this) - return *this ; - if (p != SF_NULL && -- p->ref == 0) - delete p ; - - p = rhs.p ; - rhs.p = SF_NULL ; - - return *this ; -} /* SndfileHandle move assignment */ - -#endif - -inline int -SndfileHandle::error (void) const -{ return sf_error (p->sf) ; } - -inline const char * -SndfileHandle::strError (void) const -{ return sf_strerror (p->sf) ; } - -inline int -SndfileHandle::command (int cmd, void *data, int datasize) -{ return sf_command (p->sf, cmd, data, datasize) ; } - -inline sf_count_t -SndfileHandle::seek (sf_count_t frame_count, int whence) -{ return sf_seek (p->sf, frame_count, whence) ; } - -inline void -SndfileHandle::writeSync (void) -{ sf_write_sync (p->sf) ; } - -inline int -SndfileHandle::setString (int str_type, const char* str) -{ return sf_set_string (p->sf, str_type, str) ; } - -inline const char* -SndfileHandle::getString (int str_type) const -{ return sf_get_string (p->sf, str_type) ; } - -inline int -SndfileHandle::formatCheck (int fmt, int chans, int srate) -{ - SF_INFO sfinfo ; - - sfinfo.frames = 0 ; - sfinfo.channels = chans ; - sfinfo.format = fmt ; - sfinfo.samplerate = srate ; - sfinfo.sections = 0 ; - sfinfo.seekable = 0 ; - - return sf_format_check (&sfinfo) ; -} - -/*---------------------------------------------------------------------*/ - -inline sf_count_t -SndfileHandle::read (short *ptr, sf_count_t items) -{ return sf_read_short (p->sf, ptr, items) ; } - -inline sf_count_t -SndfileHandle::read (int *ptr, sf_count_t items) -{ return sf_read_int (p->sf, ptr, items) ; } - -inline sf_count_t -SndfileHandle::read (float *ptr, sf_count_t items) -{ return sf_read_float (p->sf, ptr, items) ; } - -inline sf_count_t -SndfileHandle::read (double *ptr, sf_count_t items) -{ return sf_read_double (p->sf, ptr, items) ; } - -inline sf_count_t -SndfileHandle::write (const short *ptr, sf_count_t items) -{ return sf_write_short (p->sf, ptr, items) ; } - -inline sf_count_t -SndfileHandle::write (const int *ptr, sf_count_t items) -{ return sf_write_int (p->sf, ptr, items) ; } - -inline sf_count_t -SndfileHandle::write (const float *ptr, sf_count_t items) -{ return sf_write_float (p->sf, ptr, items) ; } - -inline sf_count_t -SndfileHandle::write (const double *ptr, sf_count_t items) -{ return sf_write_double (p->sf, ptr, items) ; } - -inline sf_count_t -SndfileHandle::readf (short *ptr, sf_count_t frame_count) -{ return sf_readf_short (p->sf, ptr, frame_count) ; } - -inline sf_count_t -SndfileHandle::readf (int *ptr, sf_count_t frame_count) -{ return sf_readf_int (p->sf, ptr, frame_count) ; } - -inline sf_count_t -SndfileHandle::readf (float *ptr, sf_count_t frame_count) -{ return sf_readf_float (p->sf, ptr, frame_count) ; } - -inline sf_count_t -SndfileHandle::readf (double *ptr, sf_count_t frame_count) -{ return sf_readf_double (p->sf, ptr, frame_count) ; } - -inline sf_count_t -SndfileHandle::writef (const short *ptr, sf_count_t frame_count) -{ return sf_writef_short (p->sf, ptr, frame_count) ; } - -inline sf_count_t -SndfileHandle::writef (const int *ptr, sf_count_t frame_count) -{ return sf_writef_int (p->sf, ptr, frame_count) ; } - -inline sf_count_t -SndfileHandle::writef (const float *ptr, sf_count_t frame_count) -{ return sf_writef_float (p->sf, ptr, frame_count) ; } - -inline sf_count_t -SndfileHandle::writef (const double *ptr, sf_count_t frame_count) -{ return sf_writef_double (p->sf, ptr, frame_count) ; } - -inline sf_count_t -SndfileHandle::readRaw (void *ptr, sf_count_t bytes) -{ return sf_read_raw (p->sf, ptr, bytes) ; } - -inline sf_count_t -SndfileHandle::writeRaw (const void *ptr, sf_count_t bytes) -{ return sf_write_raw (p->sf, ptr, bytes) ; } - -inline SNDFILE * -SndfileHandle::rawHandle (void) -{ return (p ? p->sf : SF_NULL) ; } - -inline SNDFILE * -SndfileHandle::takeOwnership (void) -{ - if (p == SF_NULL || (p->ref != 1)) - return SF_NULL ; - - SNDFILE * sf = p->sf ; - p->sf = SF_NULL ; - delete p ; - p = SF_NULL ; - return sf ; -} - -#ifdef _WIN32 - -inline -SndfileHandle::SndfileHandle (const wchar_t *wpath, int mode, int fmt, int chans, int srate) -: p (SF_NULL) -{ - p = new (std::nothrow) SNDFILE_ref () ; - - if (p != SF_NULL) - { p->ref = 1 ; - - p->sfinfo.frames = 0 ; - p->sfinfo.channels = chans ; - p->sfinfo.format = fmt ; - p->sfinfo.samplerate = srate ; - p->sfinfo.sections = 0 ; - p->sfinfo.seekable = 0 ; - - p->sf = sf_wchar_open (wpath, mode, &p->sfinfo) ; - } ; - - return ; -} /* SndfileHandle const wchar_t * constructor */ - -#endif - -#endif /* SNDFILE_HH */ - diff --git a/Engine/lib/libsndfile/m4/ax_add_fortify_source.m4 b/Engine/lib/libsndfile/m4/ax_add_fortify_source.m4 deleted file mode 100644 index 7e1531279..000000000 --- a/Engine/lib/libsndfile/m4/ax_add_fortify_source.m4 +++ /dev/null @@ -1,80 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_add_fortify_source.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_ADD_FORTIFY_SOURCE -# -# DESCRIPTION -# -# Check whether -D_FORTIFY_SOURCE=2 can be added to CPPFLAGS without macro -# redefinition warnings, other cpp warnings or linker. Some distributions -# (such as Gentoo Linux) enable _FORTIFY_SOURCE globally in their -# compilers, leading to unnecessary warnings in the form of -# -# :0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] -# : note: this is the location of the previous definition -# -# which is a problem if -Werror is enabled. This macro checks whether -# _FORTIFY_SOURCE is already defined, and if not, adds -D_FORTIFY_SOURCE=2 -# to CPPFLAGS. -# -# Newer mingw-w64 msys2 package comes with a bug in -# headers-git-7.0.0.5546.d200317d-1. It broke -D_FORTIFY_SOURCE support, -# and would need -lssp or -fstack-protector. See -# https://github.com/msys2/MINGW-packages/issues/5803. Try to actually -# link it. -# -# LICENSE -# -# Copyright (c) 2017 David Seifert -# Copyright (c) 2019 Reini Urban -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 4 - -AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[ - ac_save_cflags=$CFLAGS - ac_cwerror_flag=yes - AX_CHECK_COMPILE_FLAG([-Werror],[CFLAGS="$CFLAGS -Werror"]) - AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CPPFLAGS]) - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([], - [[ - #ifndef _FORTIFY_SOURCE - return 0; - #else - this_is_an_error; - #endif - ]] - )], - AC_LINK_IFELSE([ - AC_LANG_SOURCE([[ - #define _FORTIFY_SOURCE 2 - #include - int main() { - char *s = " "; - strcpy(s, "x"); - return strlen(s)-1; - } - ]] - )], - [ - AC_MSG_RESULT([yes]) - CFLAGS=$ac_save_cflags - CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2" - ], [ - AC_MSG_RESULT([no]) - CFLAGS=$ac_save_cflags - ], - ), - [ - AC_MSG_RESULT([no]) - CFLAGS=$ac_save_cflags - ]) -]) diff --git a/Engine/lib/libsndfile/m4/ax_append_compile_flags.m4 b/Engine/lib/libsndfile/m4/ax_append_compile_flags.m4 deleted file mode 100644 index 5b6f1af51..000000000 --- a/Engine/lib/libsndfile/m4/ax_append_compile_flags.m4 +++ /dev/null @@ -1,67 +0,0 @@ -# ============================================================================ -# https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html -# ============================================================================ -# -# SYNOPSIS -# -# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# For every FLAG1, FLAG2 it is checked whether the compiler works with the -# flag. If it does, the flag is added FLAGS-VARIABLE -# -# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. -# CFLAGS) is used. During the check the flag is always added to the -# current language's flags. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_COMPILE_IFELSE. -# -# NOTE: This macro depends on the AX_APPEND_FLAG and -# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with -# AX_APPEND_LINK_FLAGS. -# -# LICENSE -# -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 6 - -AC_DEFUN([AX_APPEND_COMPILE_FLAGS], -[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) -AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) -for flag in $1; do - AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4]) -done -])dnl AX_APPEND_COMPILE_FLAGS diff --git a/Engine/lib/libsndfile/m4/ax_append_flag.m4 b/Engine/lib/libsndfile/m4/ax_append_flag.m4 deleted file mode 100644 index e8c5312af..000000000 --- a/Engine/lib/libsndfile/m4/ax_append_flag.m4 +++ /dev/null @@ -1,71 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_append_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) -# -# DESCRIPTION -# -# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space -# added in between. -# -# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. -# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains -# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly -# FLAG. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 7 - -AC_DEFUN([AX_APPEND_FLAG], -[dnl -AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF -AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) -AS_VAR_SET_IF(FLAGS,[ - AS_CASE([" AS_VAR_GET(FLAGS) "], - [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], - [ - AS_VAR_APPEND(FLAGS,[" $1"]) - AC_RUN_LOG([: FLAGS="$FLAGS"]) - ]) - ], - [ - AS_VAR_SET(FLAGS,[$1]) - AC_RUN_LOG([: FLAGS="$FLAGS"]) - ]) -AS_VAR_POPDEF([FLAGS])dnl -])dnl AX_APPEND_FLAG diff --git a/Engine/lib/libsndfile/m4/ax_append_link_flags.m4 b/Engine/lib/libsndfile/m4/ax_append_link_flags.m4 deleted file mode 100644 index 6f7f17456..000000000 --- a/Engine/lib/libsndfile/m4/ax_append_link_flags.m4 +++ /dev/null @@ -1,65 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# For every FLAG1, FLAG2 it is checked whether the linker works with the -# flag. If it does, the flag is added FLAGS-VARIABLE -# -# If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is -# used. During the check the flag is always added to the linker's flags. -# -# If EXTRA-FLAGS is defined, it is added to the linker's default flags -# when the check is done. The check is thus made with the flags: "LDFLAGS -# EXTRA-FLAGS FLAG". This can for example be used to force the linker to -# issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_COMPILE_IFELSE. -# -# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG. -# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS. -# -# LICENSE -# -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 6 - -AC_DEFUN([AX_APPEND_LINK_FLAGS], -[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) -AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) -for flag in $1; do - AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4]) -done -])dnl AX_APPEND_LINK_FLAGS diff --git a/Engine/lib/libsndfile/m4/ax_check_compile_flag.m4 b/Engine/lib/libsndfile/m4/ax_check_compile_flag.m4 deleted file mode 100644 index dcabb92a1..000000000 --- a/Engine/lib/libsndfile/m4/ax_check_compile_flag.m4 +++ /dev/null @@ -1,74 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_COMPILE_IFELSE. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 5 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_VAR_IF(CACHEVAR,yes, - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS diff --git a/Engine/lib/libsndfile/m4/ax_check_link_flag.m4 b/Engine/lib/libsndfile/m4/ax_check_link_flag.m4 deleted file mode 100644 index 819409a20..000000000 --- a/Engine/lib/libsndfile/m4/ax_check_link_flag.m4 +++ /dev/null @@ -1,74 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the linker or gives an error. -# (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the linker's default flags -# when the check is done. The check is thus made with the flags: "LDFLAGS -# EXTRA-FLAGS FLAG". This can for example be used to force the linker to -# issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_LINK_IFELSE. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 5 - -AC_DEFUN([AX_CHECK_LINK_FLAG], -[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl -AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS $4 $1" - AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - LDFLAGS=$ax_check_save_flags]) -AS_VAR_IF(CACHEVAR,yes, - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_LINK_FLAGS diff --git a/Engine/lib/libsndfile/m4/ax_compiler_vendor.m4 b/Engine/lib/libsndfile/m4/ax_compiler_vendor.m4 deleted file mode 100644 index 4ca808955..000000000 --- a/Engine/lib/libsndfile/m4/ax_compiler_vendor.m4 +++ /dev/null @@ -1,87 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_COMPILER_VENDOR -# -# DESCRIPTION -# -# Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun, -# hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft, -# watcom, etc. The vendor is returned in the cache variable -# $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 16 - -AC_DEFUN([AX_COMPILER_VENDOR], -[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, - dnl Please add if possible support to ax_compiler_version.m4 - [# note: don't check for gcc first since some other compilers define __GNUC__ - vendors="intel: __ICC,__ECC,__INTEL_COMPILER - ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ - pathscale: __PATHCC__,__PATHSCALE__ - clang: __clang__ - cray: _CRAYC - fujitsu: __FUJITSU - gnu: __GNUC__ - sun: __SUNPRO_C,__SUNPRO_CC - hp: __HP_cc,__HP_aCC - dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER - borland: __BORLANDC__,__CODEGEARC__,__TURBOC__ - comeau: __COMO__ - kai: __KCC - lcc: __LCC__ - sgi: __sgi,sgi - microsoft: _MSC_VER - metrowerks: __MWERKS__ - watcom: __WATCOMC__ - portland: __PGI - tcc: __TINYC__ - unknown: UNKNOWN" - for ventest in $vendors; do - case $ventest in - *:) vendor=$ventest; continue ;; - *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; - esac - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ - #if !($vencpp) - thisisanerror; - #endif - ])], [break]) - done - ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` - ]) -]) diff --git a/Engine/lib/libsndfile/m4/ax_compiler_version.m4 b/Engine/lib/libsndfile/m4/ax_compiler_version.m4 deleted file mode 100644 index 8a8e28a98..000000000 --- a/Engine/lib/libsndfile/m4/ax_compiler_version.m4 +++ /dev/null @@ -1,492 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_compiler_version.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_COMPILER_VERSION -# -# DESCRIPTION -# -# This macro retrieves the compiler version and returns it in the cache -# variable $ax_cv_c_compiler_version for C and $ax_cv_cxx_compiler_version -# for C++. -# -# Version is returned as epoch:major.minor.patchversion -# -# Epoch is used in order to have an increasing version number in case of -# marketing change. -# -# Epoch use: * borland compiler use chronologically 0turboc for turboc -# era, -# -# 1borlanc BORLANDC++ before 5, 2cppbuilder for cppbuilder era, -# 3borlancpp for return of BORLANDC++ (after version 5.5), -# 4cppbuilder for cppbuilder with year version, -# and 5xe for XE era. -# -# An empty string is returned otherwise. -# -# LICENSE -# -# Copyright (c) 2014 Bastien ROUCARIES -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 9 - -# for intel -AC_DEFUN([_AX_COMPILER_VERSION_INTEL], - [ dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [__INTEL_COMPILER/100],, - AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [(__INTEL_COMPILER%100)/10],, - AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [(__INTEL_COMPILER%10)],, - AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# for IBM -AC_DEFUN([_AX_COMPILER_VERSION_IBM], - [ dnl - dnl check between z/OS C/C++ and XL C/C++ - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([], - [ - #if defined(__COMPILER_VER__) - choke me; - #endif - ])], - [ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [__xlC__/100],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [__xlC__%100],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__xlC_ver__/0x100],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, - [__xlC_ver__%0x100],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler build version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" - ], - [ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__xlC__%1000],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [(__xlC__/10000)%10],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [(__xlC__/100000)%10],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) -]) - -# for pathscale -AC_DEFUN([_AX_COMPILER_VERSION_PATHSCALE],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - __PATHCC__,, - AC_MSG_FAILURE([[[$0]] unknown pathscale major])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __PATHCC_MINOR__,, - AC_MSG_FAILURE([[[$0]] unknown pathscale minor])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__PATHCC_PATCHLEVEL__],, - AC_MSG_FAILURE([[[$0]] unknown pathscale patch level])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# for clang -AC_DEFUN([_AX_COMPILER_VERSION_CLANG],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - __clang_major__,, - AC_MSG_FAILURE([[[$0]] unknown clang major])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __clang_minor__,, - AC_MSG_FAILURE([[[$0]] unknown clang minor])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__clang_patchlevel__],,0) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# for crayc -AC_DEFUN([_AX_COMPILER_VERSION_CRAY],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - _RELEASE,, - AC_MSG_FAILURE([[[$0]] unknown crayc release])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - _RELEASE_MINOR,, - AC_MSG_FAILURE([[[$0]] unknown crayc minor])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" - ]) - -# for fujitsu -AC_DEFUN([_AX_COMPILER_VERSION_FUJITSU],[ - AC_COMPUTE_INT(ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, - __FCC_VERSION,, - AC_MSG_FAILURE([[[$0]]unknown fujitsu release])) - ]) - -# for GNU -AC_DEFUN([_AX_COMPILER_VERSION_GNU],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - __GNUC__,, - AC_MSG_FAILURE([[[$0]] unknown gcc major])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __GNUC_MINOR__,, - AC_MSG_FAILURE([[[$0]] unknown gcc minor])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__GNUC_PATCHLEVEL__],, - AC_MSG_FAILURE([[[$0]] unknown gcc patch level])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# For sun -AC_DEFUN([_AX_COMPILER_VERSION_SUN],[ - m4_define([_AX_COMPILER_VERSION_SUN_NUMBER], - [ - #if defined(__SUNPRO_CC) - __SUNPRO_CC - #else - __SUNPRO_C - #endif - ]) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59, - !!(_AX_COMPILER_VERSION_SUN_NUMBER < 0x1000),, - AC_MSG_FAILURE([[[$0]] unknown sun release version])) - AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59" = X1], - [dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, - AC_MSG_FAILURE([[[$0]] unknown sun patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - (_AX_COMPILER_VERSION_SUN_NUMBER / 0x10) % 0x10,, - AC_MSG_FAILURE([[[$0]] unknown sun minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100),, - AC_MSG_FAILURE([[[$0]] unknown sun major version])) - ], - [dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, - AC_MSG_FAILURE([[[$0]] unknown sun patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100) % 0x100,, - AC_MSG_FAILURE([[[$0]] unknown sun minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (_AX_COMPILER_VERSION_SUN_NUMBER / 0x1000),, - AC_MSG_FAILURE([[[$0]] unknown sun major version])) - ]) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" -]) - -AC_DEFUN([_AX_COMPILER_VERSION_HP],[ - m4_define([_AX_COMPILER_VERSION_HP_NUMBER], - [ - #if defined(__HP_cc) - __HP_cc - #else - __HP_aCC - #endif - ]) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121, - !!(_AX_COMPILER_VERSION_HP_NUMBER <= 1),, - AC_MSG_FAILURE([[[$0]] unknown hp release version])) - AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121" = X1], - [dnl By default output last version with this behavior. - dnl it is so old - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="01.21.00" - ], - [dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - (_AX_COMPILER_VERSION_HP_NUMBER % 100),, - AC_MSG_FAILURE([[[$0]] unknown hp release version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - ((_AX_COMPILER_VERSION_HP_NUMBER / 100)%100),, - AC_MSG_FAILURE([[[$0]] unknown hp minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - ((_AX_COMPILER_VERSION_HP_NUMBER / 10000)%100),, - AC_MSG_FAILURE([[[$0]] unknown hp major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) -]) - -AC_DEFUN([_AX_COMPILER_VERSION_DEC],[dnl - m4_define([_AX_COMPILER_VERSION_DEC_NUMBER], - [ - #if defined(__DECC_VER) - __DECC_VER - #else - __DECCXX_VER - #endif - ]) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - (_AX_COMPILER_VERSION_DEC_NUMBER % 10000),, - AC_MSG_FAILURE([[[$0]] unknown dec release version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - ((_AX_COMPILER_VERSION_DEC_NUMBER / 100000UL)%100),, - AC_MSG_FAILURE([[[$0]] unknown dec minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - ((_AX_COMPILER_VERSION_DEC_NUMBER / 10000000UL)%100),, - AC_MSG_FAILURE([[[$0]] unknown dec major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# borland -AC_DEFUN([_AX_COMPILER_VERSION_BORLAND],[dnl - m4_define([_AX_COMPILER_VERSION_TURBOC_NUMBER], - [ - #if defined(__TURBOC__) - __TURBOC__ - #else - choke me - #endif - ]) - m4_define([_AX_COMPILER_VERSION_BORLANDC_NUMBER], - [ - #if defined(__BORLANDC__) - __BORLANDC__ - #else - __CODEGEARC__ - #endif - ]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM(, - _AX_COMPILER_VERSION_TURBOC_NUMBER)], - [dnl TURBOC - AC_COMPUTE_INT( - _ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw, - _AX_COMPILER_VERSION_TURBOC_NUMBER,, - AC_MSG_FAILURE([[[$0]] unknown turboc version])) - AS_IF( - [test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -lt 661 || test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -gt 1023], - [dnl compute normal version - AC_COMPUTE_INT( - _ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - _AX_COMPILER_VERSION_TURBOC_NUMBER % 0x100,, - AC_MSG_FAILURE([[[$0]] unknown turboc minor version])) - AC_COMPUTE_INT( - _ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (_AX_COMPILER_VERSION_TURBOC_NUMBER/0x100)%0x100,, - AC_MSG_FAILURE([[[$0]] unknown turboc major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"], - [dnl special version - AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw], - [661],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.00"], - [662],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.01"], - [663],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:2.00"], - [ - AC_MSG_WARN([[[$0]] unknown turboc version between 0x295 and 0x400 please report bug]) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="" - ]) - ]) - ], - # borlandc - [ - AC_COMPUTE_INT( - _ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw, - _AX_COMPILER_VERSION_BORLANDC_NUMBER,, - AC_MSG_FAILURE([[[$0]] unknown borlandc version])) - AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw], - dnl BORLANDC++ before 5.5 - [512] ,[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:2.00"], - [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], - [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], - [1040],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.1"], - [1106],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:4.0"], - [1280],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.0"], - [1312],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.02"], - dnl C++ Builder era - [1328],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:3.0"], - [1344],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:4.0"], - dnl BORLANDC++ after 5.5 - [1360],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.5"], - [1361],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.51"], - [1378],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.6.4"], - dnl C++ Builder with year number - [1392],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2006"], - [1424],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2007"], - [1555],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2009"], - [1569],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2010"], - dnl XE version - [1584],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe"], - [1600],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:2"], - [1616],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:3"], - [1632],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:4"], - [ - AC_MSG_WARN([[[$0]] Unknown borlandc compiler version $_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw please report bug]) - ]) - ]) - ]) - -# COMO -AC_DEFUN([_AX_COMPILER_VERSION_COMEAU], - [ dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [__COMO_VERSION__%100],, - AC_MSG_FAILURE([[[$0]] unknown comeau compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [(__COMO_VERSION__/100)%10],, - AC_MSG_FAILURE([[[$0]] unknown comeau compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" - ]) - -# KAI -AC_DEFUN([_AX_COMPILER_VERSION_KAI],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__KCC_VERSION%100],, - AC_MSG_FAILURE([[[$0]] unknown kay compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [(__KCC_VERSION/100)%10],, - AC_MSG_FAILURE([[[$0]] unknown kay compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [(__KCC_VERSION/1000)%10],, - AC_MSG_FAILURE([[[$0]] unknown kay compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -dnl LCC -dnl LCC does not output version... - -# SGI -AC_DEFUN([_AX_COMPILER_VERSION_SGI],[ - m4_define([_AX_COMPILER_VERSION_SGI_NUMBER], - [ - #if defined(_COMPILER_VERSION) - _COMPILER_VERSION - #else - _SGI_COMPILER_VERSION - #endif - ]) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [_AX_COMPILER_VERSION_SGI_NUMBER%10],, - AC_MSG_FAILURE([[[$0]] unknown SGI compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [(_AX_COMPILER_VERSION_SGI_NUMBER/10)%10],, - AC_MSG_FAILURE([[[$0]] unknown SGI compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [(_AX_COMPILER_VERSION_SGI_NUMBER/100)%10],, - AC_MSG_FAILURE([[[$0]] unknown SGI compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# microsoft -AC_DEFUN([_AX_COMPILER_VERSION_MICROSOFT],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - _MSC_VER%100,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (_MSC_VER/100)%100,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler major version])) - dnl could be overridden - _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0 - _ax_[]_AC_LANG_ABBREV[]_compiler_version_build=0 - # special case for version 6 - AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X12"], - [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _MSC_FULL_VER%1000,, - _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0)]) - # for version 7 - AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X13"], - [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _MSC_FULL_VER%1000,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) - ]) - # for version > 8 - AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 14], - [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _MSC_FULL_VER%10000,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) - ]) - AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 15], - [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, - _MSC_BUILD,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler build version])) - ]) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" - ]) - -# for metrowerks -AC_DEFUN([_AX_COMPILER_VERSION_METROWERKS],[dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - __MWERKS__%0x100,, - AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - (__MWERKS__/0x100)%0x10,, - AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (__MWERKS__/0x1000)%0x10,, - AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# for watcom -AC_DEFUN([_AX_COMPILER_VERSION_WATCOM],[dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __WATCOMC__%100,, - AC_MSG_FAILURE([[[$0]] unknown watcom compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (__WATCOMC__/100)%100,, - AC_MSG_FAILURE([[[$0]] unknown watcom compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" - ]) - -# for PGI -AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - __PGIC__,, - AC_MSG_FAILURE([[[$0]] unknown pgi major])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __PGIC_MINOR__,, - AC_MSG_FAILURE([[[$0]] unknown pgi minor])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__PGIC_PATCHLEVEL__],, - AC_MSG_FAILURE([[[$0]] unknown pgi patch level])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# tcc -AC_DEFUN([_AX_COMPILER_VERSION_TCC],[ - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`] - ]) -# main entry point -AC_DEFUN([AX_COMPILER_VERSION],[dnl - AC_REQUIRE([AX_COMPILER_VENDOR]) - AC_REQUIRE([AC_PROG_SED]) - AC_CACHE_CHECK([for _AC_LANG compiler version], - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, - [ dnl - AS_CASE([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor], - [intel],[_AX_COMPILER_VERSION_INTEL], - [ibm],[_AX_COMPILER_VERSION_IBM], - [pathscale],[_AX_COMPILER_VERSION_PATHSCALE], - [clang],[_AX_COMPILER_VERSION_CLANG], - [cray],[_AX_COMPILER_VERSION_CRAY], - [fujitsu],[_AX_COMPILER_VERSION_FUJITSU], - [gnu],[_AX_COMPILER_VERSION_GNU], - [sun],[_AX_COMPILER_VERSION_SUN], - [hp],[_AX_COMPILER_VERSION_HP], - [dec],[_AX_COMPILER_VERSION_DEC], - [borland],[_AX_COMPILER_VERSION_BORLAND], - [comeau],[_AX_COMPILER_VERSION_COMEAU], - [kai],[_AX_COMPILER_VERSION_KAI], - [sgi],[_AX_COMPILER_VERSION_SGI], - [microsoft],[_AX_COMPILER_VERSION_MICROSOFT], - [metrowerks],[_AX_COMPILER_VERSION_METROWERKS], - [watcom],[_AX_COMPILER_VERSION_WATCOM], - [portland],[_AX_COMPILER_VERSION_PORTLAND], - [tcc],[_AX_COMPILER_VERSION_TCC], - [ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""]) - ]) -]) diff --git a/Engine/lib/libsndfile/m4/ax_recursive_eval.m4 b/Engine/lib/libsndfile/m4/ax_recursive_eval.m4 deleted file mode 100644 index 0625aca22..000000000 --- a/Engine/lib/libsndfile/m4/ax_recursive_eval.m4 +++ /dev/null @@ -1,56 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_recursive_eval.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_RECURSIVE_EVAL(VALUE, RESULT) -# -# DESCRIPTION -# -# Interpolate the VALUE in loop until it doesn't change, and set the -# result to $RESULT. WARNING: It's easy to get an infinite loop with some -# unsane input. -# -# LICENSE -# -# Copyright (c) 2008 Alexandre Duret-Lutz -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 1 - -AC_DEFUN([AX_RECURSIVE_EVAL], -[_lcl_receval="$1" -$2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix" - test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" - _lcl_receval_old='' - while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do - _lcl_receval_old="[$]_lcl_receval" - eval _lcl_receval="\"[$]_lcl_receval\"" - done - echo "[$]_lcl_receval")`]) diff --git a/Engine/lib/libsndfile/m4/ax_require_defined.m4 b/Engine/lib/libsndfile/m4/ax_require_defined.m4 deleted file mode 100644 index 17c3eab7d..000000000 --- a/Engine/lib/libsndfile/m4/ax_require_defined.m4 +++ /dev/null @@ -1,37 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_REQUIRE_DEFINED(MACRO) -# -# DESCRIPTION -# -# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have -# been defined and thus are available for use. This avoids random issues -# where a macro isn't expanded. Instead the configure script emits a -# non-fatal: -# -# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found -# -# It's like AC_REQUIRE except it doesn't expand the required macro. -# -# Here's an example: -# -# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) -# -# LICENSE -# -# Copyright (c) 2014 Mike Frysinger -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 2 - -AC_DEFUN([AX_REQUIRE_DEFINED], [dnl - m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) -])dnl AX_REQUIRE_DEFINED diff --git a/Engine/lib/libsndfile/m4/clip_mode.m4 b/Engine/lib/libsndfile/m4/clip_mode.m4 deleted file mode 100644 index 4556b937a..000000000 --- a/Engine/lib/libsndfile/m4/clip_mode.m4 +++ /dev/null @@ -1,124 +0,0 @@ -dnl @synopsis MN_C_CLIP_MODE -dnl -dnl Determine the clipping mode when converting float to int. -dnl @version 1.0 May 17 2003 -dnl @author Erik de Castro Lopo -dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright -dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is -dnl provided "as is" without express or implied warranty. - - - - - - - -dnl Find the clipping mode in the following way: -dnl 1) If we are not cross compiling test it. -dnl 2) IF we are cross compiling, assume that clipping isn't done correctly. - -AC_DEFUN([MN_C_CLIP_MODE], -[AC_CACHE_CHECK(processor clipping capabilities, - ac_cv_c_clip_type, - -# Initialize to unknown -ac_cv_c_clip_positive=unknown -ac_cv_c_clip_negative=unknown - - -if test $ac_cv_c_clip_positive = unknown ; then - AC_TRY_RUN( - [[ - #define _ISOC9X_SOURCE 1 - #define _ISOC99_SOURCE 1 - #define __USE_ISOC99 1 - #define __USE_ISOC9X 1 - #include - int main (void) - { double fval ; - int k, ival ; - - fval = 1.0 * 0x7FFFFFFF ; - for (k = 0 ; k < 100 ; k++) - { ival = (lrint (fval)) >> 24 ; - if (ival != 127) - return 1 ; - - fval *= 1.2499999 ; - } ; - - return 0 ; - } - ]], - ac_cv_c_clip_positive=yes, - ac_cv_c_clip_positive=no, - ac_cv_c_clip_positive=unknown - ) - - AC_TRY_RUN( - [[ - #define _ISOC9X_SOURCE 1 - #define _ISOC99_SOURCE 1 - #define __USE_ISOC99 1 - #define __USE_ISOC9X 1 - #include - int main (void) - { double fval ; - int k, ival ; - - fval = -8.0 * 0x10000000 ; - for (k = 0 ; k < 100 ; k++) - { ival = (lrint (fval)) >> 24 ; - if (ival != -128) - return 1 ; - - fval *= 1.2499999 ; - } ; - - return 0 ; - } - ]], - ac_cv_c_clip_negative=yes, - ac_cv_c_clip_negative=no, - ac_cv_c_clip_negative=unknown - ) - fi - -if test $ac_cv_c_clip_positive = yes ; then - ac_cv_c_clip_positive=1 -else - ac_cv_c_clip_positive=0 - fi - -if test $ac_cv_c_clip_negative = yes ; then - ac_cv_c_clip_negative=1 -else - ac_cv_c_clip_negative=0 - fi - -[[ -case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in - "00") - ac_cv_c_clip_type="none" - ;; - "10") - ac_cv_c_clip_type="positive" - ;; - "01") - ac_cv_c_clip_type="negative" - ;; - "11") - ac_cv_c_clip_type="both" - ;; - esac - ]] - -) -] - -)# MN_C_CLIP_MODE - - diff --git a/Engine/lib/libsndfile/m4/extra_pkg.m4 b/Engine/lib/libsndfile/m4/extra_pkg.m4 deleted file mode 100644 index 8a04c359f..000000000 --- a/Engine/lib/libsndfile/m4/extra_pkg.m4 +++ /dev/null @@ -1,105 +0,0 @@ -# extra_pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# -# Copyright (c) 2008-2012 Erik de Castro Lopo -# Copyright (c) 2004 Scott James Remnant . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# -------------------------------------------------------------- -# PKG_CHECK_MOD_VERSION(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# This is a very slight modification to the macro PKG_CHECK_MODULES that -# is in the original pkg.m4 file. It prints the versions in the checking -# message (erikd@mega-nerd.com). - -AC_DEFUN([PKG_CHECK_MOD_VERSION], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl -AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl - -pkg_failed=no -AC_MSG_CHECKING([for $2 ]) - -_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) -_PKG_CONFIG([$1][_LIBS], [libs], [$2]) - -pkg_link_saved_CFLAGS=$CFLAGS -pkg_link_saved_LIBS=$LIBS - -eval "pkg_CFLAGS=\${pkg_cv_[]$1[]_CFLAGS}" -eval "pkg_LIBS=\${pkg_cv_[]$1[]_LIBS}" - -CFLAGS="$CFLAGS $pkg_CFLAGS" -LIBS="$LIBS $pkg_LIBS" - -AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [puts ("")])], pkg_link=yes, pkg_link=no) - -CFLAGS=$pkg_link_saved_CFLAGS -LIBS=$pkg_link_saved_LIBS - -AS_IF([test x$pkg_link = xno], [ - AS_ECHO_N(["link failed ... "]) - pkg_failed=yes -]) - -m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS -and $1[]_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details.]) - -if test $pkg_failed = yes; then - _PKG_SHORT_ERRORS_SUPPORTED - if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` - fi - # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - - ifelse([$4], , [AC_MSG_ERROR(dnl -[Package requirements ($2) were not met: - -$$1_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -_PKG_TEXT -])], - [AC_MSG_RESULT([no]) - $4]) -elif test $pkg_failed = untried; then - ifelse([$4], , [AC_MSG_FAILURE(dnl -[The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -_PKG_TEXT - -To get pkg-config, see .])], - [$4]) -else - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS - AC_MSG_RESULT([yes]) - ifelse([$3], , :, [$3]) -fi[]dnl -])# PKG_CHECK_MOD_VERSION diff --git a/Engine/lib/libsndfile/m4/flexible_array.m4 b/Engine/lib/libsndfile/m4/flexible_array.m4 deleted file mode 100644 index 661da17b2..000000000 --- a/Engine/lib/libsndfile/m4/flexible_array.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl @synopsis MN_C99_FLEXIBLE_ARRAY -dnl -dnl Dose the compiler support the 1999 ISO C Standard "stuct hack". -dnl @version 1.1 Mar 15 2004 -dnl @author Erik de Castro Lopo -dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright -dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is -dnl provided "as is" without express or implied warranty. - -AC_DEFUN([MN_C99_FLEXIBLE_ARRAY], -[AC_CACHE_CHECK(C99 struct flexible array support, - ac_cv_c99_flexible_array, - -# Initialize to unknown -ac_cv_c99_flexible_array=no - -AC_TRY_LINK([[ - #include - typedef struct { - int k; - char buffer [] ; - } MY_STRUCT ; - ]], - [ MY_STRUCT *p = calloc (1, sizeof (MY_STRUCT) + 42); ], - ac_cv_c99_flexible_array=yes, - ac_cv_c99_flexible_array=no - ))] -) # MN_C99_FLEXIBLE_ARRAY - diff --git a/Engine/lib/libsndfile/m4/mkoctfile_version.m4 b/Engine/lib/libsndfile/m4/mkoctfile_version.m4 deleted file mode 100644 index 04a58e573..000000000 --- a/Engine/lib/libsndfile/m4/mkoctfile_version.m4 +++ /dev/null @@ -1,38 +0,0 @@ -dnl @synopsis OCTAVE_MKOCTFILE_VERSION -dnl -dnl Find the version of mkoctfile. -dnl @version 1.0 Aug 23 2007 -dnl @author Erik de Castro Lopo -dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright -dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is -dnl provided "as is" without express or implied warranty. -dnl - -AC_DEFUN([OCTAVE_MKOCTFILE_VERSION], -[ - - -AC_ARG_WITH(mkoctfile, - AS_HELP_STRING([--with-mkoctfile], [choose the mkoctfile version]), - [ with_mkoctfile=$withval ]) - -test -z "$with_mkoctfile" && with_mkoctfile=mkoctfile - -AC_CHECK_PROG(HAVE_MKOCTFILE,$with_mkoctfile,yes,no) - -if test "x$ac_cv_prog_HAVE_MKOCTFILE" = "xyes" ; then - MKOCTFILE=$with_mkoctfile - - AC_MSG_CHECKING([for version of $MKOCTFILE]) - MKOCTFILE_VERSION=`$with_mkoctfile --version 2>&1 | sed 's/mkoctfile, version //g'` - AC_MSG_RESULT($MKOCTFILE_VERSION) - fi - -AC_SUBST(MKOCTFILE) -AC_SUBST(MKOCTFILE_VERSION) - -])# OCTAVE_MKOCTFILE_VERSION - diff --git a/Engine/lib/libsndfile/m4/octave.m4 b/Engine/lib/libsndfile/m4/octave.m4 deleted file mode 100644 index fda043d05..000000000 --- a/Engine/lib/libsndfile/m4/octave.m4 +++ /dev/null @@ -1,143 +0,0 @@ -dnl Evaluate an expression in octave -dnl -dnl OCTAVE_EVAL(expr,var) -> var=expr -dnl -dnl Stolen from octave-forge - -AC_DEFUN([OCTAVE_EVAL], -[ -AC_MSG_CHECKING([for $1 in $OCTAVE]) -$2=`TERM=;$OCTAVE -qfH --eval "disp($1)"` -AC_MSG_RESULT($$2) -AC_SUBST($2) -]) # OCTAVE_EVAL - -dnl @synopsis AC_OCTAVE_VERSION -dnl -dnl Find the version of Octave. -dnl @version 1.0 Aug 23 2007 -dnl @author Erik de Castro Lopo -dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright -dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is -dnl provided "as is" without express or implied warranty. -dnl - -AC_DEFUN([AC_OCTAVE_VERSION], -[ - -AC_ARG_WITH(octave, - AS_HELP_STRING([--with-octave], [choose the octave version]), - [ with_octave=$withval ]) - -test -z "$with_octave" && with_octave=octave - -AC_CHECK_PROG(HAVE_OCTAVE,$with_octave,yes,no) - -if test "x$ac_cv_prog_HAVE_OCTAVE" = "xyes" ; then - OCTAVE=$with_octave - OCTAVE_EVAL(OCTAVE_VERSION,OCTAVE_VERSION) - fi - -AC_SUBST(OCTAVE) -AC_SUBST(OCTAVE_VERSION) - -])# AC_OCTAVE_VERSION - -dnl @synopsis AC_OCTAVE_CONFIG_VERSION -dnl -dnl Find the version of Octave. -dnl @version 1.0 Aug 23 2007 -dnl @author Erik de Castro Lopo -dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright -dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is -dnl provided "as is" without express or implied warranty. -dnl - -AC_DEFUN([AC_OCTAVE_CONFIG_VERSION], -[ - -AC_ARG_WITH(octave-config, - AS_HELP_STRING([--with-octave-config], [choose the octave-config version]), - [ with_octave_config=$withval ]) - -test -z "$with_octave_config" && with_octave_config=octave-config - -AC_CHECK_PROG(HAVE_OCTAVE_CONFIG,$with_octave_config,yes,no) - -if test "x$ac_cv_prog_HAVE_OCTAVE_CONFIG" = "xyes" ; then - OCTAVE_CONFIG=$with_octave_config - AC_MSG_CHECKING([for version of $OCTAVE_CONFIG]) - OCTAVE_CONFIG_VERSION=`$OCTAVE_CONFIG --version` - AC_MSG_RESULT($OCTAVE_CONFIG_VERSION) - fi - -AC_SUBST(OCTAVE_CONFIG) -AC_SUBST(OCTAVE_CONFIG_VERSION) - -])# AC_OCTAVE_CONFIG_VERSION - -dnl @synopsis AC_OCTAVE_BUILD -dnl -dnl Check programs and headers required for building octave plugins. -dnl @version 1.0 Aug 23 2007 -dnl @author Erik de Castro Lopo -dnl -dnl Permission to use, copy, modify, distribute, and sell this file for any -dnl purpose is hereby granted without fee, provided that the above copyright -dnl and this permission notice appear in all copies. No representations are -dnl made about the suitability of this software for any purpose. It is -dnl provided "as is" without express or implied warranty. - - -AC_DEFUN([AC_OCTAVE_BUILD], -[ - -dnl Default to no. -OCTAVE_BUILD=no - -AC_OCTAVE_VERSION -OCTAVE_MKOCTFILE_VERSION -AC_OCTAVE_CONFIG_VERSION - -prog_concat="$ac_cv_prog_HAVE_OCTAVE$ac_cv_prog_HAVE_OCTAVE_CONFIG$ac_cv_prog_HAVE_MKOCTFILE" - -if test "x$prog_concat" = "xyesyesyes" ; then - if test "x$OCTAVE_VERSION" != "x$MKOCTFILE_VERSION" ; then - AC_MSG_WARN([** Mismatch between versions of octave and mkoctfile. **]) - AC_MSG_WARN([** Octave libsndfile modules will not be built. **]) - elif test "x$OCTAVE_VERSION" != "x$OCTAVE_CONFIG_VERSION" ; then - AC_MSG_WARN([** Mismatch between versions of octave and octave-config. **]) - AC_MSG_WARN([** Octave libsndfile modules will not be built. **]) - else - case "$MKOCTFILE_VERSION" in - 2.*) - AC_MSG_WARN([Octave version 2.X is not supported.]) - ;; - 3.*) - OCTAVE_DEST_ODIR=`$OCTAVE_CONFIG --oct-site-dir | sed 's%^/usr%${prefix}%'` - OCTAVE_DEST_MDIR=`$OCTAVE_CONFIG --m-site-dir | sed 's%^/usr%${prefix}%'` - - OCTAVE_BUILD=yes - ;; - *) - AC_MSG_WARN([Octave version $MKOCTFILE_VERSION is not supported.]) - ;; - esac - fi - AC_MSG_RESULT([building octave libsndfile module... $OCTAVE_BUILD]) - fi - -AC_SUBST(OCTAVE_DEST_ODIR) -AC_SUBST(OCTAVE_DEST_MDIR) - -AC_SUBST(MKOCTFILE) - -AM_CONDITIONAL(BUILD_OCTAVE_MOD, test "x$OCTAVE_BUILD" = xyes) - -])# AC_OCTAVE_BUILD diff --git a/Engine/lib/libsndfile/make_lite.py b/Engine/lib/libsndfile/make_lite.py deleted file mode 100644 index eee69fc82..000000000 --- a/Engine/lib/libsndfile/make_lite.py +++ /dev/null @@ -1,491 +0,0 @@ -#!/usr/bin/python - -import commands, os, re, string, sys, time - -def count_enclosed_functions (source): - func_count = 0 - open_brace = 0 - close_brace = 0 - for ch in source: - if ch == '{': - open_brace += 1 - elif ch == '}': - close_brace += 1 - if open_brace == close_brace: - func_count += 1 - if open_brace < close_brace: - print "count_enclosed_functions : open_brace < close_brace" - return -1 - return func_count - -def find_function_prototype (source, proto_name): - proto_re = "(^[a-zA-Z_ \t]+\s+%s[^a-zA-Z0-9_]\s*\([^\)]+\)\s+;\n)" % (proto_name) - proto_result = re.search (proto_re, source, re.MULTILINE | re.DOTALL) - if not proto_result: - return None - proto_text = proto_result.groups ()[0] - return proto_text - -def find_function_definition (source, func_name): - func_re = "(\n[a-zA-Z_ \t]+\n%s[^a-zA-Z0-9_].* /\* %s \*/\n)" % (func_name, func_name) - func_result = re.search (func_re, source, re.MULTILINE | re.DOTALL) - if not func_result: - sys.exit (1) - return None - func_text = func_result.groups ()[0] - - # Now to check that we only have one enclosing function. - func_count = count_enclosed_functions (func_text) - if func_count != 1: - return None - return func_text - -def find_include (source, inc_name): - inc_re = "(^#include\s+[\<\"]%s[\"\>]\s*)" % inc_name - inc_result = re.search (inc_re, source, re.MULTILINE | re.DOTALL) - if not inc_result: - return None - inc_text = inc_result.groups ()[0] - return inc_text - -def find_assign_statement (source, var_name): - var_re = "(^\s+%s\s*=[^;]+;)" % var_name - var_result = re.search (var_re, source, re.MULTILINE | re.DOTALL) - if not var_result: - return None - assign_text = var_result.groups ()[0] - return assign_text - -#-------------------------------------------------------------------------------- - -def remove_include (source, inc_name): - inc_text = find_include (source, inc_name) - if not inc_text: - print "remove_include : include '%s' not found. Exiting." % inc_name - sys.exit (1) - - source = string.replace (source, inc_text, "") - return source - -def remove_assign (source, assign_name): - assign_text = find_assign (source, inc_name) - if not inc_text: - print "remove_include : include '%s' not found. Exiting." % inc_name - sys.exit (1) - - source = string.replace (source, inc_text, "") - return source - -def remove_prototype (source, proto_name): - proto_text = find_function_prototype (source, proto_name) - if not proto_text: - print "remove_prototype : prototype '%s' not found. Exiting." % proto_name - sys.exit (1) - - source = string.replace (source, proto_text, "") - return source - -def remove_function (source, func_name): - func_text = find_function_definition (source, func_name) - if not func_text: - print "remove_function : function '%s' not found. Exiting." % func_name - sys.exit (1) - - source = string.replace (source, func_text, "/* Function %s() removed here. */\n" % func_name) - return source - -def remove_all_assignments (source, var): - count = 0 - while 1: - assign_text = find_assign_statement (source, var) - if not assign_text: - if count != 0: - break - print "remove_all_assignments : variable '%s' not found. Exiting." % var - sys.exit (1) - - source = string.replace (source, assign_text, "") - count += 1 - return source - - - -#---------------------------------------------------------------- - -def remove_funcs_and_protos_from_file (filename, func_list): - source_code = open (filename, 'r').read () - - for func in func_list: - source_code = remove_prototype (source_code, func) ; - source_code = remove_function (source_code, func) ; - open (filename, 'w').write (source_code) - -def remove_funcs_from_file (filename, func_list): - source_code = open (filename, 'r').read () - - for func in func_list: - source_code = remove_function (source_code, func) ; - open (filename, 'w').write (source_code) - -def remove_protos_from_file (filename, func_list): - source_code = open (filename, 'r').read () - - for func in func_list: - source_code = remove_prototype (source_code, func) ; - open (filename, 'w').write (source_code) - -def remove_includes_from_file (filename, inc_list): - source_code = open (filename, 'r').read () - - for inc in inc_list: - source_code = remove_include (source_code, inc) ; - open (filename, 'w').write (source_code) - -def remove_all_assignments_from_file (filename, var_list): - source_code = open (filename, 'r').read () - - for var in var_list: - source_code = remove_all_assignments (source_code, var) ; - open (filename, 'w').write (source_code) - -def remove_comment_start_end (filename, start_comment, end_comment): - source_code = open (filename, 'r').read () - - while 1: - start_index = string.find (source_code, start_comment) - end_index = string.find (source_code, end_comment) - if start_index < 0 or end_index < start_index: - break - end_index += len (end_comment) - source_code = source_code [:start_index-1] + source_code [end_index:] ; - - open (filename, 'w').write (source_code) - -def remove_strings_from_file (filename, str_list): - file_text = open (filename, 'r').read () - for current_str in str_list: - file_text = string.replace (file_text, current_str, '') - open (filename, 'w').write (file_text) - -def string_replace_in_file (filename, from_str, to_str): - file_text = open (filename, 'r').read () - file_text = string.replace (file_text, from_str, to_str) - open (filename, 'w').write (file_text) - -def remove_regex_from_file (filename, regex_list): - file_text = open (filename, 'r').read () - for regex in regex_list: - file_text = re.sub (regex, '', file_text, re.MULTILINE | re.DOTALL) - open (filename, 'w').write (file_text) - -#========================================================================== - -def find_configure_version (filename): - # AM_INIT_AUTOMAKE(libsndfile,0.0.21pre6) - file = open (filename) - while 1: - line = file.readline () - if re.search ("AC_INIT", line): - x = re.sub ("[^\(]+\(", "", line) - x = re.sub ("\).*\n", "", x) - x = string.split (x, ",") - package = x [0] - version = x [1] - break - file.close () - # version = re.escape (version) - return package, version - -def fix_configure_ac_file (filename): - data = open (filename, 'r').read () - data = string.replace (data, "AM_INIT_AUTOMAKE(libsndfile,", "AM_INIT_AUTOMAKE(libsndfile_lite,", 1) - - file = open (filename, 'w') - file.write (data) - file.close () - - -def make_dist_file (package, version): - print "Making dist file." - tar_gz_file = "%s-%s.tar.gz" % (package, version) - if os.path.exists (tar_gz_file): - return - if os.system ("make dist"): - sys.exit (1) - return - -def delete_files (file_list): - for file_name in file_list: - os.remove (file_name) - -#======================================================================= - -source_dir = os.getcwd () - -conf_package, conf_version = find_configure_version ('configure.ac') - -package_version = "%s-%s" % (conf_package, conf_version) -lite_version = "%s_lite-%s" % (conf_package, conf_version) - -os.system ("rm -rf %s%s.tar.gz" % (source_dir, package_version)) - -os.system ("make dist") - -make_dist_file (conf_package, conf_version) - -os.chdir ("/tmp") - -print "Uncompressing .tar.gz file." -os.system ("rm -rf %s" % package_version) -if os.system ("tar zxf %s/%s.tar.gz" % (source_dir, package_version)): - sys.exit (1) - - -print "Renaming to libsndfile_lite." -os.system ("rm -rf %s" % lite_version) -os.rename (package_version, lite_version) - -print "Changing into libsndfile_lite directory." -os.chdir (lite_version) - -print "Removing un-neeed directories." -delete_dirs = [ 'src/G72x' ] - -for dir_name in delete_dirs: - os.system ("rm -rf %s" % dir_name) - -print "Removing un-needed files." -delete_files ([ 'src/ircam.c', 'src/nist.c', - 'src/ima_adpcm.c', 'src/ms_adpcm.c', 'src/au_g72x.c', - 'src/mat4.c', 'src/mat5.c', 'src/dwvw.c', 'src/paf.c', - 'src/ogg.c', 'src/pvf.c', 'src/xi.c', 'src/htk.c', - 'src/sd2.c', 'src/rx2.c', 'src/txw.c', 'src/wve.c', - 'src/dwd.c', 'src/svx.c', 'src/voc.c', 'src/vox_adpcm.c', - 'src/sds.c' - ]) - - -print "Hacking 'configure.ac' and 'src/Makefile.am'." -remove_strings_from_file ('configure.ac', [ 'src/G72x/Makefile' ]) -remove_strings_from_file ('src/Makefile.am', [ 'G72x/libg72x.la', 'G72x', - 'ircam.c', 'nist.c', 'ima_adpcm.c', 'ms_adpcm.c', 'au_g72x.c', 'mat4.c', - 'mat5.c', 'dwvw.c', 'paf.c', 'ogg.c', 'pvf.c', 'xi.c', 'htk.c', - 'sd2.c', 'rx2.c', 'txw.c', 'wve.c', 'dwd.c', 'svx.c', 'voc.c', - 'vox_adpcm.c', 'sds.c' - ]) - -#---------------------------------------------------------------------------- - -print "Hacking header files." - -remove_protos_from_file ('src/common.h', [ 'xi_open', 'sd2_open', 'ogg_open', - 'dwvw_init', 'paf_open', 'svx_open', 'nist_open', 'rx2_open', 'mat4_open', - 'voc_open', 'txw_open', 'dwd_open', 'htk_open', 'wve_open', 'mat5_open', - 'pvf_open', 'ircam_open', 'sds_open', - 'float32_init', 'double64_init', 'aiff_ima_init', 'vox_adpcm_init', - 'wav_w64_ima_init', 'wav_w64_msadpcm_init' - ]) - -remove_protos_from_file ('src/au.h', - [ 'au_g72x_reader_init', 'au_g72x_writer_init' ]) - -remove_protos_from_file ('src/wav_w64.h', [ 'msadpcm_write_adapt_coeffs' ]) - -#---------------------------------------------------------------------------- - -print "Hacking case statements." - -remove_comment_start_end ('src/sndfile.c', '/* Lite remove start */' , '/* Lite remove end */') -remove_comment_start_end ('src/aiff.c', '/* Lite remove start */' , '/* Lite remove end */') -remove_comment_start_end ('src/au.c', '/* Lite remove start */' , '/* Lite remove end */') -remove_comment_start_end ('src/raw.c', '/* Lite remove start */' , '/* Lite remove end */') -remove_comment_start_end ('src/w64.c', '/* Lite remove start */' , '/* Lite remove end */') -remove_comment_start_end ('src/wav.c', '/* Lite remove start */' , '/* Lite remove end */') -remove_comment_start_end ('src/double64.c', '/* Lite remove start */' , '/* Lite remove end */') -remove_comment_start_end ('src/float32.c', '/* Lite remove start */' , '/* Lite remove end */') - - -#---------------------------------------------------------------------------- - -print "Hacking src/pcm.c." -remove_funcs_from_file ('src/pcm.c', [ - 'f2sc_array', 'f2sc_clip_array', 'f2uc_array', 'f2uc_clip_array', - 'f2bes_array', 'f2bes_clip_array', 'f2les_array', 'f2les_clip_array', - 'f2let_array', 'f2let_clip_array', 'f2bet_array', 'f2bet_clip_array', - 'f2bei_array', 'f2bei_clip_array', 'f2lei_array', 'f2lei_clip_array', - 'd2sc_array', 'd2sc_clip_array', 'd2uc_array', 'd2uc_clip_array', - 'd2bes_array', 'd2bes_clip_array', 'd2les_array', 'd2les_clip_array', - 'd2let_array', 'd2let_clip_array', 'd2bet_array', 'd2bet_clip_array', - 'd2bei_array', 'd2bei_clip_array', 'd2lei_array', 'd2lei_clip_array', - ]) - -remove_funcs_and_protos_from_file ('src/pcm.c', [ - 'pcm_read_sc2f', 'pcm_read_uc2f', 'pcm_read_les2f', 'pcm_read_bes2f', - 'pcm_read_let2f', 'pcm_read_bet2f', 'pcm_read_lei2f', 'pcm_read_bei2f', - 'pcm_read_sc2d', 'pcm_read_uc2d', 'pcm_read_les2d', 'pcm_read_bes2d', - 'pcm_read_let2d', 'pcm_read_bet2d', 'pcm_read_lei2d', 'pcm_read_bei2d', - 'pcm_write_f2sc', 'pcm_write_f2uc', 'pcm_write_f2bes', 'pcm_write_f2les', - 'pcm_write_f2bet', 'pcm_write_f2let', 'pcm_write_f2bei', 'pcm_write_f2lei', - 'pcm_write_d2sc', 'pcm_write_d2uc', 'pcm_write_d2bes', 'pcm_write_d2les', - 'pcm_write_d2bet', 'pcm_write_d2let', 'pcm_write_d2bei', 'pcm_write_d2lei', - - 'sc2f_array', 'uc2f_array', 'bes2f_array', 'les2f_array', - 'bet2f_array', 'let2f_array', 'bei2f_array', 'lei2f_array', - 'sc2d_array', 'uc2d_array', 'bes2d_array', 'les2d_array', - 'bet2d_array', 'let2d_array', 'bei2d_array', 'lei2d_array' - ]) - -remove_includes_from_file ('src/pcm.c', [ 'float_cast.h' ]) -remove_all_assignments_from_file ('src/pcm.c', [ - 'psf-\>write_float', 'psf\-\>write_double', - 'psf-\>read_float', 'psf\-\>read_double' ]) - -#---------------------------------------------------------------------------- -print "Hacking src/ulaw.c." -remove_funcs_and_protos_from_file ('src/ulaw.c', [ - 'ulaw_read_ulaw2f', 'ulaw_read_ulaw2d', - 'ulaw_write_f2ulaw', 'ulaw_write_d2ulaw', - 'ulaw2f_array', 'ulaw2d_array', 'f2ulaw_array', 'd2ulaw_array' - ]) - -remove_includes_from_file ('src/ulaw.c', [ 'float_cast.h' ]) -remove_all_assignments_from_file ('src/ulaw.c', [ - 'psf-\>write_float', 'psf\-\>write_double', - 'psf-\>read_float', 'psf\-\>read_double' ]) - -#---------------------------------------------------------------------------- - -print "Hacking src/alaw.c." -remove_funcs_and_protos_from_file ('src/alaw.c', [ - 'alaw_read_alaw2f', 'alaw_read_alaw2d', - 'alaw_write_f2alaw', 'alaw_write_d2alaw', - 'alaw2f_array', 'alaw2d_array', 'f2alaw_array', 'd2alaw_array' - ]) - -remove_includes_from_file ('src/alaw.c', [ 'float_cast.h' ]) -remove_all_assignments_from_file ('src/alaw.c', [ - 'psf-\>write_float', 'psf\-\>write_double', - 'psf-\>read_float', 'psf\-\>read_double' ]) - -#---------------------------------------------------------------------------- - -print "Hacking src/gsm610.c." -remove_funcs_and_protos_from_file ('src/gsm610.c', [ - 'gsm610_read_f', 'gsm610_read_d', 'gsm610_write_f', 'gsm610_write_d' - ]) - -remove_includes_from_file ('src/gsm610.c', [ 'float_cast.h' ]) -remove_all_assignments_from_file ('src/gsm610.c', [ - 'psf-\>write_float', 'psf\-\>write_double', - 'psf-\>read_float', 'psf\-\>read_double' ]) - -#---------------------------------------------------------------------------- - -print "Hacking src/float32.c." - -# string_replace_in_file ('src/float32.c', '"float_cast.h"', '') -remove_funcs_from_file ('src/float32.c', [ 'float32_init' ]) - -remove_funcs_and_protos_from_file ('src/float32.c', [ - 'host_read_f2s', 'host_read_f2i', 'host_read_f', 'host_read_f2d', - 'host_write_s2f', 'host_write_i2f', 'host_write_f', 'host_write_d2f', - 'f2s_array', 'f2i_array', 'f2d_array', 's2f_array', 'i2f_array', 'd2f_array', - 'float32_peak_update', - 'replace_read_f2s', 'replace_read_f2i', 'replace_read_f', 'replace_read_f2d', - 'replace_write_s2f', 'replace_write_i2f', 'replace_write_f', 'replace_write_d2f', - 'bf2f_array', 'f2bf_array', - 'float32_get_capability', - ]) - -#---------------------------------------------------------------------------- - -print "Hacking src/double64.c." -remove_funcs_from_file ('src/double64.c', [ 'double64_init' ]) - -remove_funcs_and_protos_from_file ('src/double64.c', [ - 'host_read_d2s', 'host_read_d2i', 'host_read_d2f', 'host_read_d', - 'host_write_s2d', 'host_write_i2d', 'host_write_f2d', 'host_write_d', - 'd2s_array', 'd2i_array', 'd2f_array', - 's2d_array', 'i2d_array', 'f2d_array', - 'double64_peak_update', 'double64_get_capability', - 'replace_read_d2s', 'replace_read_d2i', 'replace_read_d2f', 'replace_read_d', - 'replace_write_s2d', 'replace_write_i2d', 'replace_write_f2d', 'replace_write_d', - 'd2bd_read', 'bd2d_write' - ]) - -#---------------------------------------------------------------------------- - -print "Hacking test programs." -delete_files ([ 'tests/dwvw_test.c', 'tests/floating_point_test.c', - 'tests/dft_cmp.c', 'tests/peak_chunk_test.c', - 'tests/scale_clip_test.tpl', 'tests/scale_clip_test.def' - ]) - -remove_comment_start_end ('tests/write_read_test.def', '/* Lite remove start */', '/* Lite remove end */') -remove_comment_start_end ('tests/write_read_test.tpl', '/* Lite remove start */', '/* Lite remove end */') - -remove_comment_start_end ('tests/Makefile.am', '# Lite remove start', '# Lite remove end') - -remove_strings_from_file ('tests/Makefile.am', [ - 'scale_clip_test.tpl', 'scale_clip_test.def', - '\n\t./dwvw_test', - '\n\t./floating_point_test', '\n\t./scale_clip_test', - '\n\t./peak_chunk_test aiff', '\n\t./peak_chunk_test wav', - '\n\t./command_test norm', '\n\t./command_test peak', - '\n\t./lossy_comp_test wav_ima', '\n\t./lossy_comp_test wav_msadpcm', - '\n\t./lossy_comp_test au_g721', '\n\t./lossy_comp_test au_g723', - '\n\t./lossy_comp_test vox_adpcm', - '\n\t./lossy_comp_test w64_ima', '\n\t./lossy_comp_test w64_msadpcm', - 'peak_chunk_test', 'dwvw_test', 'floating_point_test', 'scale_clip_test', - - 'paf-tests', 'svx-tests', 'nist-tests', 'ircam-tests', 'voc-tests', - 'mat4-tests', 'mat5-tests', 'pvf-tests', 'xi-tests', 'htk-tests', - 'sds-tests' - ]) - -remove_comment_start_end ('tests/pcm_test.c', '/* Lite remove start */', '/* Lite remove end */') -remove_funcs_and_protos_from_file ('tests/pcm_test.c', [ - 'pcm_test_float', 'pcm_test_double' - ]) - -remove_comment_start_end ('tests/lossy_comp_test.c', '/* Lite remove start */', '/* Lite remove end */') -remove_funcs_and_protos_from_file ('tests/lossy_comp_test.c', [ - 'lcomp_test_float', 'lcomp_test_double', 'sdlcomp_test_float', 'sdlcomp_test_double', - 'smoothed_diff_float', 'smoothed_diff_double' - ]) - -remove_comment_start_end ('tests/multi_file_test.c', '/* Lite remove start */', '/* Lite remove end */') - -remove_strings_from_file ('tests/stdio_test.c', [ - '"paf",', '"svx",', '"nist",', '"ircam",', '"voc",', '"mat4",', '"mat5",', '"pvf",' - ]) - -remove_comment_start_end ('tests/pipe_test.c', '/* Lite remove start */', '/* Lite remove end */') - -#---------------------------------------------------------------------------- - -print "Fixing configure.ac file." -fix_configure_ac_file ('configure.ac') - -print "Building and testing source." - # Try --disable-shared --disable-gcc-opt -if os.system ("./reconfigure.mk && ./configure --disable-shared --disable-gcc-opt && make check"): - os.system ('PS1="FIX > " bash --norc') - sys.exit (1) - -print "Making distcheck" -if os.system ("make distcheck"): - os.system ('PS1="FIX > " bash --norc') - sys.exit (1) - -print "Copying tarball" -if os.system ("cp %s.tar.gz %s" % (lite_version, source_dir)): - print "??? %s.tar.gz ???" % lite_version - os.system ('PS1="FIX > " bash --norc') - sys.exit (1) - -os.chdir (source_dir) - -os.system ("rm -rf /tmp/%s" % lite_version) - -print "Done." diff --git a/Engine/lib/libsndfile/man/sndfile-cmp.1 b/Engine/lib/libsndfile/man/sndfile-cmp.1 deleted file mode 100644 index 88aaafe7e..000000000 --- a/Engine/lib/libsndfile/man/sndfile-cmp.1 +++ /dev/null @@ -1,29 +0,0 @@ -.Dd November 2, 2014 -.Dt SNDFILE-CMP 1 -.Os -.Sh NAME -.Nm sndfile-cmp -.Nd compare two audio files -.Sh SYNOPSIS -.Nm sndfile-cmp -.Ar file1 -.Ar file2 -.Sh DESCRIPTION -.Nm -compares the audio data of two sound files. -For two files to compare as being the same, their channel counts, sample rate, -audio data lengths and actual audio data must match. -Other differences such as string metadata like song title, artist etc and their -presence or absence are ignored. -.Sh EXIT STATUS -.Bl -tag -width 1n -compact -.It 0 -The audio data is the same. -.It 1 -The audio data differs. -.El -.Sh SEE ALSO -.Lk http://libsndfile.github.io/libsndfile/ -.Sh AUTHORS -.An Conrad Parker Aq Mt conrad@metadecks.org -.An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com diff --git a/Engine/lib/libsndfile/man/sndfile-concat.1 b/Engine/lib/libsndfile/man/sndfile-concat.1 deleted file mode 100644 index 3ba34c74a..000000000 --- a/Engine/lib/libsndfile/man/sndfile-concat.1 +++ /dev/null @@ -1,28 +0,0 @@ -.Dd November 2, 2014 -.Dt SNDFILE-CONCAT 1 -.Os -.Sh NAME -.Nm sndfile-concat -.Nd concatenate audio data from two or more audio files -.Sh SYNOPSIS -.Nm sndfile-concat -.Ar infile1 -.Ar infile2 -.Ar ... -.Ar outfile -.Sh DESCRIPTION -.Nm -generates a new output file by concatenating the audio data -of two or more input files. The encoding of the output file -is the encoding used in -.Ar infile1 . -Audio data from the subsequent files are converted to this encoding. -The only restriction is that the files must have -the same number of channels. -The output file is overwritten if it already exists. -.Sh EXIT STATUS -.Ex -std -.Sh SEE ALSO -.Lk http://libsndfile.github.io/libsndfile/ -.Sh AUTHORS -.An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com diff --git a/Engine/lib/libsndfile/man/sndfile-convert.1 b/Engine/lib/libsndfile/man/sndfile-convert.1 deleted file mode 100644 index e7156eec1..000000000 --- a/Engine/lib/libsndfile/man/sndfile-convert.1 +++ /dev/null @@ -1,160 +0,0 @@ -.Dd November 2, 2014 -.Dt SNDFILE-CONVERT 1 -.Os -.Sh NAME -.Nm sndfile-convert -.Nd convert sound files from one format to another -.Sh SYNOPSIS -.Nm sndfile-convert -.Op Fl override-sample-rate Ns = Ns Ar rate -.Op Fl endian Ns = Ns Cm little | big | cpu -.Op Fl normalize -.Op Ar encoding -.Ar input -.Ar output -.Sh DESCRIPTION -.Nm -converts sound files from one audio format to another. -The output file is overwritten it it already exists. -.Ss Formats -The format of the output file is determined by the filename extension. -The following file formats are currently recognized: -.Pp -.Bl -tag -compact -width ircam -.It wav -WAV (Microsoft) -.It aif -AIFF (Apple/SGI) -.It au -AU (Sun/NeXT) -.It snd -AU (Sun/NeXT) -.It raw -RAW (header-less) -.It gsm -RAW (header-less) -.It vox -RAW (header-less) -.It paf -PAF (Ensoniq PARIS, big-endian) -.It fap -PAF (Ensoniq PARIS, little-endian) -.It svx -IFF (Amiga IFF/SVX8/SV16) -.It nist -SPHERE (NIST SPeech HEader Resources) -.It sph -SPHERE (NIST SPeech HEader Resources) -.It voc -VOC (Creative Labs) -.It ircam -SF (Berkeley/IRCAM/CARL) -.It sf -SF (Berkeley/IRCAM/CARL) -.It w64 -W64 (SoundFoundry WAVE 64) -.It mat -MAT4 (GNU Octave 2.0 / Matlab 4.2) -.It mat4 -MAT4 (GNU Octave 2.0 / Matlab 4.2) -.It mat5 -MAT5 (GNU Octave 2.1 / Matlab 5.0) -.It pvf -PVF (Portable Voice Format) -.It xi -XI (FastTracker 2) -.It htk -HTK (HMM Tool Kit) -.It sds -SDS (Midi Sample Dump Standard) -.It avr -AVR (Audio Visual Research) -.It wavex -WAVEX (MS WAVE with WAVEFORMATEX) -.It sd2 -SD2 (Sound Designer II) -.It flac -FLAC (FLAC Lossless Audio Codec) -.It caf -CAF (Apple Core Audio File) -.It wve -WVE (Psion Series 3) -.It prc -WVE (Psion Series 3) -.It ogg -OGG (OGG Container format) -.It oga -OGG (OGG Container format) -.It mpc -MPC (Akai MPC 2k) -.It rf64 -RF64 (RIFF 64) -.El -.Ss Options -The following options are recoginzed: -.Pp -.Bl -tag -compact -width "override-sample-rate=XXXXX" -.It Fl override-sample-rate Ns = Ns Ar rate -Make the input use sample rate of -.Ar rate -Hz. -.It Fl endian Ns = Ns Cm little -Make the output file use little endian data. -.It Fl endian Ns = Ns Cm big -Make the output file use big endian data. -.It Fl endian Ns = Ns Cm cpu -Make the output file use CPU endianness. -.It Fl normalize -Normalize the audio data in the output file. -.El -.Ss Encodings -The optional -.Ar encoding -parameter allows setting of the data encoding for the output file. -The following encodings are currently supported: -.Pp -.Bl -tag -compact -width ima-adpcmXX -.It Fl pcms8 -signed 8 bit pcm -.It Fl pcmu8 -unsigned 8 bit pcm -.It Fl pcm16 -16 bit pcm -.It Fl pcm24 -24 bit pcm -.It Fl pcm32 -32 bit pcm -.It Fl float32 -32 bit floating point -.It Fl ulaw -ULAW -.It Fl alaw -ALAW -.It Fl ima-adpcm -IMA ADPCM (WAV only) -.It Fl ms-adpcm -MS ADPCM (WAV only) -.It Fl gsm610 -GSM6.10 (WAV only) -.It Fl dwvw12 -12 bit DWVW (AIFF only) -.It Fl dwvw16 -16 bit DWVW (AIFF only) -.It Fl dwvw24 -24 bit DWVW (AIFF only) -.It Fl vorbis -Vorbis (OGG only) -.El -.Pp -If no encoding is specified for the output file, -.Nm -will try to use the encoding of the input file. -This will not always work as most container formats -(e.g. WAV, AIFF etc) only support a small subset of encodings -(e.g. 16 bit PCM, a-law, Vorbis etc). -.Sh EXIT STATUS -.Ex -std -.Sh SEE ALSO -.Lk http://libsndfile.github.io/libsndfile/ -.Sh AUTHORS -.An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com . diff --git a/Engine/lib/libsndfile/man/sndfile-info.1 b/Engine/lib/libsndfile/man/sndfile-info.1 deleted file mode 100644 index a8c3749ad..000000000 --- a/Engine/lib/libsndfile/man/sndfile-info.1 +++ /dev/null @@ -1,34 +0,0 @@ -.Dd November 2, 2014 -.Dt SNDFILE-INFO 1 -.Os -.Sh NAME -.Nm sndfile-info -.Nd display information about sound files -.Sh SYNOPSIS -.Nm sndfile-info -.Op Fl -broadcast -.Op Fl -cart -.Op Fl -channel-map -.Op Fl -instrument -.Ar -.Sh DESCRIPTION -.Nm -displays basic information about sound files -such as format, number of channels, samplerate, and length. -The following options are recognized: -.Pp -.Bl -tag -compact -width channelmapXXXX -.It Fl -broadcast -Display broadcast (BWF) info. -.It Fl -cart -Display the cart chunk of a WAV (or related) file. -.It Fl -channel-map -Display channel map. -.It Fl -instrument -Display instrument info: -a base note, gain, velocity, key, and loop points. -.El -.Sh SEE ALSO -.Lk http://libsndfile.github.io/libsndfile/ -.Sh AUTHORS -.An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com . diff --git a/Engine/lib/libsndfile/man/sndfile-interleave.1 b/Engine/lib/libsndfile/man/sndfile-interleave.1 deleted file mode 100644 index 0cf70764f..000000000 --- a/Engine/lib/libsndfile/man/sndfile-interleave.1 +++ /dev/null @@ -1,62 +0,0 @@ -.Dd November 2, 2014 -.Dt SNDFILE-INTERLEAVE 1 -.Os -.Sh NAME -.Nm sndfile-interleave , -.Nm sndfile-deinterleave -.Nd convert mono files into a multi-channel file and vice versa -.Sh SYNOPSIS -.Nm sndfile-interleave -.Ar input1 -.Ar input2 -.Ar ... -.Fl o Ar output -.Nm sndfile-deinterleave -.Ar file -.Sh DESCRIPTION -.Nm sndfile-interleave -creates a multi-channel file taking audio data -from two or more mono files as individual channels. -The format of the output file is determined by its filename suffix. -The audio parameters of the output file will be made so that -the format can accommodate each of the mono inputs; -for example, the samplerate will be the maximal samplerate -occurring in the inputs. -The output file will be overwritten if it already exists. -.Pp -.Nm sndfile-deinterleave -creates two or more mono files from a multi-channel audio file, -containing data from the individual channels. The names of the -resulting mono files are of the form -.Dq name_XY.suf -where -.Em name -and -.Em suf -are the basename and suffix of the original file. -If any file of such name already exists, it will be overwritten. -Apart from the number of channels, -the audio format of the resulting mono files -is the same as that of the original file. -.Sh EXIT STATUS -.Ex -std -.Sh EXAMPLES -Merge a mono OGG file and a mono FLAC file into a stereo WAV file: -.Bd -literal -offset indent -$ sndfile-interleave left.ogg right.flac -o stereo.wav -.Ed -.Pp -Split a multi-channel into individual mono files: -.Bd -literal -offset indent -$ sndfile-deinterleave multi.wav -Input file : multi -Output files : - multi_00.wav - multi_01.wav - multi_02.wav - multi_03.wav -.Ed -.Sh SEE ALSO -.Lk http://libsndfile.github.io/libsndfile/ -.Sh AUTHORS -.An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com diff --git a/Engine/lib/libsndfile/man/sndfile-metadata-get.1 b/Engine/lib/libsndfile/man/sndfile-metadata-get.1 deleted file mode 100644 index 61dfae787..000000000 --- a/Engine/lib/libsndfile/man/sndfile-metadata-get.1 +++ /dev/null @@ -1,116 +0,0 @@ -.Dd November 2, 2014 -.Dt SNDFILE-METADATA-GET 1 -.Os -.Sh NAME -.Nm sndfile-metadata-get , -.Nm sndfile-metadata-set -.Nd get or set metadata in a sound file -.Sh SYNOPSIS -.Nm sndfile-metadata-get -.Op Ar options -.Ar file -.Nm sndfile-metadata-set -.Op Ar options -.Ar file -.Nm sndfile-metadata-set -.Op Ar options -.Ar input -.Ar output -.Sh DESCRIPTION -.Nm sndfile-metadata-get -displays bext and string metadata stored in an audio file. -The following options specify what to print. -.Pp -.Bl -tag -width bext-descriptionXXXX -compact -.It Fl -all -all metadata -.It Fl -bext-description -description -.It Fl -bext-originator -originator info -.It Fl -bext-orig-ref -originator reference -.It Fl -bext-umid -Unique Material Identifier -.It Fl -bext-orig-date -origination date -.It Fl -bext-orig-time -origination time -.It Fl -bext-coding-hist -coding history -.It Fl -str-title -title -.It Fl -str-copyright -copyright -.It Fl -str-artist -artist -.It Fl -str-comment -comment -.It Fl -str-date -creation date -.It Fl -str-album -album -.It Fl -str-license -license -.El -.Pp -.Nm sndfile-metadata-set -sets bext and string metadata in an audio file if the format supports it. -If the file does not contain a BEXT chunk to be modified, -the second synopsis must be used, where another output file -capable of storing the metadata is created. -This file is overwritten if it already exists. -The following options take an argument specifying the metadata: -.Pp -.Bl -tag -width bext-coding-histXXXXXXX -compact -.It Fl -bext-description -description -.It Fl -bext-originator -originator -.It Fl -bext-orig-ref -originator reference -.It Fl -bext-umid -Unique Material Identifier -.It Fl -bext-orig-date -origination date -.It Fl -bext-orig-time -origination time -.It Fl -bext-coding-hist -coding history -.It Fl -bext-time-raf -time reference -.It Fl -str-comment -comment -.It Fl -str-title -title -.It Fl -str-copyright -copyright -.It Fl -str-artist -artist -.It Fl -str-date -date -.It Fl -str-album -album -.It Fl -str-license -license -.El -.Pp -The following options take no argument: -.Pp -.Bl -tag -width bext-coding-histXXXXXXX -compact -.It Fl -bext-auto-time-date -Set the BEXT time and date to current. -.It Fl -bext-auto-time -Set the BEXT time to current. -.It Fl -bext-auto-date -Set the BEXT date to current. -.It Fl -str-auto-date -Set the string date to current. -.El -.Sh EXIT STATUS -.Ex -std -.Sh SEE ALSO -.Lk http://libsndfile.github.io/libsndfile/ -.Lk http://tech.ebu.ch/docs/tech/tech3285.pdf -.Sh AUTHORS -.An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com diff --git a/Engine/lib/libsndfile/man/sndfile-play.1 b/Engine/lib/libsndfile/man/sndfile-play.1 deleted file mode 100644 index 4d570eafd..000000000 --- a/Engine/lib/libsndfile/man/sndfile-play.1 +++ /dev/null @@ -1,36 +0,0 @@ -.Dd September 10, 2021 -.Dt SNDFILE-PLAY 1 -.Os -.Sh NAME -.Nm sndfile-play -.Nd play a sound file -.Sh SYNOPSIS -.Nm sndfile-play -.Ar -.Sh DESCRIPTION -.Nm -plays one or more sound files on various operating systems using standard audio -output APIs. The following table summarizes which audio API is used where: -.Pp -.Bl -tag -width MacOSX10XXX -compact -.It Linux -ALSA or OSS -.It OpenBSD -sndio -.It FreeBSD -/dev/dsp (OSS) -.It NetBSD -/dev/audio -.It Solaris -/dev/audio -.It MacOSX 10.6 -CoreAudio -.It MacOSX 10.7 -AudioToolbox -.It Win32 -waveOut -.El -.Sh SEE ALSO -.Lk http://libsndfile.github.io/libsndfile/ -.Sh AUTHORS -.An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com diff --git a/Engine/lib/libsndfile/man/sndfile-salvage.1 b/Engine/lib/libsndfile/man/sndfile-salvage.1 deleted file mode 100644 index b2010f1b1..000000000 --- a/Engine/lib/libsndfile/man/sndfile-salvage.1 +++ /dev/null @@ -1,25 +0,0 @@ -.Dd November 2, 2014 -.Dt SNDFILE-SALVAGE 1 -.Os -.Sh NAME -.Nm sndfile-salvage -.Nd salvage audio data from WAV files longer than 4G -.Sh SYNOPSIS -.Nm sndfile-salvage -.Ar toolong.wav -.Ar fixed64.wav -.Sh DESCRIPTION -Audio files using the WAV file container are inherently limited to 4G of data -size fields in the WAV header being stored as unsigned 32bit integers. -Many applications have trouble with these WAV files -that are more the 4G in size. -.Nm -rewrites the WAV file into a W64 file with the same audio content. -This file is overwritten if it already exists. -.Sh EXIT STATUS -.Ex -std -.Sh SEE ALSO -.Lk http://libsndfile.github.io/libsndfile/ -.\".Lk http://en.wikipedia.org/wiki/RF64 -.Sh AUTHORS -.An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com diff --git a/Engine/lib/libsndfile/ossfuzz/ci_oss.sh b/Engine/lib/libsndfile/ossfuzz/ci_oss.sh deleted file mode 100644 index 408b00d29..000000000 --- a/Engine/lib/libsndfile/ossfuzz/ci_oss.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -set -ex - -PROJECT_NAME=libsndfile - -# Clone the oss-fuzz repository -git clone https://github.com/google/oss-fuzz.git /tmp/ossfuzz - -if [[ ! -d /tmp/ossfuzz/projects/${PROJECT_NAME} ]] -then - echo "Could not find the ${PROJECT_NAME} project in ossfuzz" - - # Exit with a success code while the libsndfile project is not expected to exist - # on oss-fuzz. - exit 0 -fi - -# Work out which branch to clone from, inside Docker -BRANCH=${GITHUB_REF} - -# Modify the oss-fuzz Dockerfile so that we're checking out the current reference on CI. -sed -i "s@RUN.*@RUN git config --global remote.origin.fetch '+refs/pull/*:refs/remotes/origin/pull/*' \&\& git clone https://github.com/libsndfile/libsndfile.git /src/libsndfile \&\& cd /src/libsndfile \&\& git checkout -b ${BRANCH}@" /tmp/ossfuzz/projects/${PROJECT_NAME}/Dockerfile - -# Try and build the fuzzers -pushd /tmp/ossfuzz -python3 infra/helper.py build_image --pull ${PROJECT_NAME} -python3 infra/helper.py build_fuzzers ${PROJECT_NAME} -python3 infra/helper.py check_build ${PROJECT_NAME} --engine libfuzzer --sanitizer address --architecture x86_64 -popd diff --git a/Engine/lib/libsndfile/ossfuzz/ossfuzz.sh b/Engine/lib/libsndfile/ossfuzz/ossfuzz.sh deleted file mode 100644 index 7b3666ffc..000000000 --- a/Engine/lib/libsndfile/ossfuzz/ossfuzz.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -eu - -# This script is called by the oss-fuzz main project when compiling the fuzz -# targets. This script is regression tested by ci_oss.sh. - -# Save off the current folder as the build root. -export BUILD_ROOT=$PWD - -echo "CC: ${CC:-}" -echo "CXX: ${CXX:-}" -echo "LIB_FUZZING_ENGINE: ${LIB_FUZZING_ENGINE:-}" -echo "CFLAGS: ${CFLAGS:-}" -echo "CXXFLAGS: ${CXXFLAGS:-}" -echo "OUT: ${OUT:-}" - -export MAKEFLAGS+="-j$(nproc)" - -# Install dependencies -apt-get -y install autoconf autogen automake libtool pkg-config python - -# For now, do not install the following libraries (as they won't be in the -# final image): -# libasound2-dev libflac-dev libogg-dev libopus-dev libvorbis-dev - -# Compile the fuzzer. -autoreconf -vif -./configure --disable-shared --enable-ossfuzzers -make V=1 - -# Copy the fuzzer to the output directory. -cp -v ossfuzz/sndfile_fuzzer $OUT/ -cp -v ossfuzz/sndfile_alt_fuzzer $OUT/ diff --git a/Engine/lib/libsndfile/ossfuzz/sndfile_alt_fuzzer.cc b/Engine/lib/libsndfile/ossfuzz/sndfile_alt_fuzzer.cc deleted file mode 100644 index e69fcdf30..000000000 --- a/Engine/lib/libsndfile/ossfuzz/sndfile_alt_fuzzer.cc +++ /dev/null @@ -1,79 +0,0 @@ -#include -#include -#include -#include -#include - -#include "sndfile_fuzz_header.h" - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ // One byte is needed for deciding which function to target. - if (size == 0) - return 0 ; - - const uint8_t decider = *data ; - data += 1 ; - size -= 1 ; - - SF_INFO sndfile_info ; - VIO_DATA vio_data ; - SF_VIRTUAL_IO vio ; - SNDFILE *sndfile = NULL ; - int err = sf_init_file(data, size, &sndfile, &vio_data, &vio, &sndfile_info) ; - if (err) - goto EXIT_LABEL ; - - // Just the right number of channels. Create some buffer space for reading. - switch (decider % 3) - { case 0 : - { - short* read_buffer = NULL ; - read_buffer = (short*)malloc(sizeof(short) * size); - if (read_buffer == NULL) - abort() ; - - while (sf_read_short(sndfile, read_buffer, size)) - { - // Do nothing with the data. - } - free(read_buffer) ; - } - break ; - case 1 : - { - int* read_buffer = NULL ; - read_buffer = (int*)malloc(sizeof(int) * size) ; - if (read_buffer == NULL) - abort() ; - - while (sf_read_int(sndfile, read_buffer, size)) - { - // Do nothing with the data. - } - free(read_buffer) ; - } - break ; - case 2 : - { - double* read_buffer = NULL ; - read_buffer = (double*)malloc(sizeof(double) * size) ; - if (read_buffer == NULL) - abort() ; - - while (sf_read_double(sndfile, read_buffer, size)) - { - // Do nothing with the data. - } - free(read_buffer) ; - } - break ; - default : - break ; - } ; - - EXIT_LABEL: - if (sndfile != NULL) - sf_close(sndfile); - - return 0 ; -} diff --git a/Engine/lib/libsndfile/ossfuzz/sndfile_fuzz_header.h b/Engine/lib/libsndfile/ossfuzz/sndfile_fuzz_header.h deleted file mode 100644 index 898aec441..000000000 --- a/Engine/lib/libsndfile/ossfuzz/sndfile_fuzz_header.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef SNDFILE_FUZZ_HEADER_H -#define SNDFILE_FUZZ_HEADER_H - -typedef struct -{ - sf_count_t offset ; - sf_count_t length ; - const unsigned char *data ; -} VIO_DATA ; - -static sf_count_t vfget_filelen (void *user_data) -{ VIO_DATA *vf = (VIO_DATA *)user_data ; - return vf->length ; -} - -static sf_count_t vfseek (sf_count_t offset, int whence, void *user_data) -{ - VIO_DATA *vf = (VIO_DATA *)user_data ; - sf_count_t new_offset ; - - switch (whence) - { case SEEK_SET : - new_offset = offset ; - break ; - - case SEEK_CUR : - new_offset = vf->offset + offset ; - break ; - - case SEEK_END : - new_offset = vf->length + offset ; - break ; - - default : - break ; - } - - /* Ensure you can't seek outside the data */ - if (new_offset > vf->length) - { /* Trying to seek past the end of the data */ - printf("vf overseek: new_offset(%" PRId64 ") > vf->length(%" PRId64 ");" - " whence(%d), vf->offset(%" PRId64 "), offset(%" PRId64 ")\n", - new_offset, vf->length, whence, vf->offset, offset) ; - new_offset = vf->length ; - } - else if (new_offset < 0) - { /* Trying to seek before the start of the data */ - printf("vf underseek: new_offset(%" PRId64 ") < 0; whence(%d), vf->offset" - "(%" PRId64 "), vf->length(%" PRId64 "), offset(%" PRId64 ")\n", - new_offset, whence, vf->offset, vf->length, offset) ; - new_offset = 0 ; - } - vf->offset = new_offset ; - - return vf->offset ; -} - -static sf_count_t vfread (void *ptr, sf_count_t count, void *user_data) -{ VIO_DATA *vf = (VIO_DATA *)user_data ; - - if (vf->offset + count > vf->length) - count = vf->length - vf->offset ; - - memcpy(ptr, vf->data + vf->offset, count) ; - vf->offset += count ; - - return count ; -} - -static sf_count_t vfwrite (const void *ptr, sf_count_t count, void *user_data) -{ - (void)ptr ; - (void)count ; - (void)user_data ; - - // Cannot write to this virtual file. - return 0; -} - -static sf_count_t vftell (void *user_data) -{ VIO_DATA *vf = (VIO_DATA *)user_data ; - - return vf->offset ; -} - -int sf_init_file(const uint8_t *data, - size_t size, - SNDFILE **sndfile, - VIO_DATA *vio_data, - SF_VIRTUAL_IO *vio, SF_INFO *sndfile_info) -{ float* read_buffer = NULL ; - - // Initialize the virtual IO structure. - vio->get_filelen = vfget_filelen ; - vio->seek = vfseek ; - vio->read = vfread ; - vio->write = vfwrite ; - vio->tell = vftell ; - - // Initialize the VIO user data. - vio_data->data = data ; - vio_data->length = size ; - vio_data->offset = 0 ; - - memset(sndfile_info, 0, sizeof(SF_INFO)) ; - - // Try and open the virtual file. - *sndfile = sf_open_virtual(vio, SFM_READ, sndfile_info, vio_data) ; - - if (sndfile_info->channels == 0) - return -1 ; - - if (sndfile_info->channels > 1024 * 1024) - return -1 ; - - return 0; -} - -#endif diff --git a/Engine/lib/libsndfile/ossfuzz/sndfile_fuzzer.cc b/Engine/lib/libsndfile/ossfuzz/sndfile_fuzzer.cc deleted file mode 100644 index 2a3d6934b..000000000 --- a/Engine/lib/libsndfile/ossfuzz/sndfile_fuzzer.cc +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "sndfile_fuzz_header.h" - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ VIO_DATA vio_data ; - SF_VIRTUAL_IO vio ; - SF_INFO sndfile_info ; - SNDFILE *sndfile = NULL ; - float* read_buffer = NULL ; - - int err = sf_init_file(data, size, &sndfile, &vio_data, &vio, &sndfile_info) ; - if (err) - goto EXIT_LABEL ; - - // Just the right number of channels. Create some buffer space for reading. - read_buffer = (float*)malloc(sizeof(float) * sndfile_info.channels); - if (read_buffer == NULL) - abort() ; - - while (sf_readf_float(sndfile, read_buffer, 1)) - { - // Do nothing with the data. - } - -EXIT_LABEL: - - if (sndfile != NULL) - sf_close(sndfile) ; - - free(read_buffer) ; - - return 0 ; -} diff --git a/Engine/lib/libsndfile/ossfuzz/standaloneengine.cc b/Engine/lib/libsndfile/ossfuzz/standaloneengine.cc deleted file mode 100644 index ab6408d94..000000000 --- a/Engine/lib/libsndfile/ossfuzz/standaloneengine.cc +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include - -#include "testinput.h" - -/** - * Main procedure for standalone fuzzing engine. - * - * Reads filenames from the argument array. For each filename, read the file - * into memory and then call the fuzzing interface with the data. - */ -int main(int argc, char **argv) -{ - int ii; - for(ii = 1; ii < argc; ii++) - { - FILE *infile; - printf("[%s] ", argv[ii]); - - /* Try and open the file. */ - infile = fopen(argv[ii], "rb"); - if(infile) - { - uint8_t *buffer = NULL; - size_t buffer_len; - - printf("Opened.. "); - - /* Get the length of the file. */ - fseek(infile, 0L, SEEK_END); - buffer_len = ftell(infile); - - /* Reset the file indicator to the beginning of the file. */ - fseek(infile, 0L, SEEK_SET); - - /* Allocate a buffer for the file contents. */ - buffer = (uint8_t *)calloc(buffer_len, sizeof(uint8_t)); - if(buffer) - { - size_t result; - - /* Read all the text from the file into the buffer. */ - result = fread(buffer, sizeof(uint8_t), buffer_len, infile); - - if (result == buffer_len) - { - printf("Read %zu bytes, fuzzing.. ", buffer_len); - /* Call the fuzzer with the data. */ - LLVMFuzzerTestOneInput(buffer, buffer_len); - - printf("complete !!"); - } - else - { - fprintf(stderr, - "Failed to read %zu bytes (result %zu)\n", - buffer_len, - result); - } - - /* Free the buffer as it's no longer needed. */ - free(buffer); - buffer = NULL; - } - else - { - fprintf(stderr, - "[%s] Failed to allocate %zu bytes \n", - argv[ii], - buffer_len); - } - - /* Close the file as it's no longer needed. */ - fclose(infile); - infile = NULL; - } - else - { - /* Failed to open the file. Maybe wrong name or wrong permissions? */ - fprintf(stderr, "[%s] Open failed. \n", argv[ii]); - } - - printf("\n"); - } -} diff --git a/Engine/lib/libsndfile/ossfuzz/testinput.h b/Engine/lib/libsndfile/ossfuzz/testinput.h deleted file mode 100644 index 6ab9b515e..000000000 --- a/Engine/lib/libsndfile/ossfuzz/testinput.h +++ /dev/null @@ -1,3 +0,0 @@ -#include - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); diff --git a/Engine/lib/libsndfile/programs/common.c b/Engine/lib/libsndfile/programs/common.c deleted file mode 100644 index 7ff0d41a7..000000000 --- a/Engine/lib/libsndfile/programs/common.c +++ /dev/null @@ -1,503 +0,0 @@ -/* -** Copyright (C) 1999-2019 Erik de Castro Lopo -** Copyright (C) 2008 George Blood Audio -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include -#include -#include - -#include - -#include "common.h" - -#define BUFFER_LEN 4096 - -#define MIN(x, y) ((x) < (y) ? (x) : (y)) - -int -sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels, int normalize) -{ static double data [BUFFER_LEN], max ; - sf_count_t frames, readcount, k ; - - frames = BUFFER_LEN / channels ; - readcount = frames ; - - sf_command (infile, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ; - if (!isnormal (max)) /* neither zero, subnormal, infinite, nor NaN */ - return 1 ; - - if (!normalize && max < 1.0) - { while (readcount > 0) - { readcount = sf_readf_double (infile, data, frames) ; - sf_writef_double (outfile, data, readcount) ; - } ; - } - else - { sf_command (infile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - - while (readcount > 0) - { readcount = sf_readf_double (infile, data, frames) ; - for (k = 0 ; k < readcount * channels ; k++) - { data [k] /= max ; - - if (!isfinite (data [k])) /* infinite or NaN */ - return 1 ; - } - sf_writef_double (outfile, data, readcount) ; - } ; - } ; - - return 0 ; -} /* sfe_copy_data_fp */ - -void -sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) -{ static int data [BUFFER_LEN] ; - int frames, readcount ; - - frames = BUFFER_LEN / channels ; - readcount = frames ; - - while (readcount > 0) - { readcount = (int) sf_readf_int (infile, data, frames) ; - sf_writef_int (outfile, data, readcount) ; - } ; - - return ; -} /* sfe_copy_data_int */ - -/*============================================================================== -*/ - -static int -merge_broadcast_info (SNDFILE * infile, SNDFILE * outfile, int format, const METADATA_INFO * info) -{ SF_BROADCAST_INFO_2K binfo ; - int infileminor ; - - memset (&binfo, 0, sizeof (binfo)) ; - - if ((SF_FORMAT_TYPEMASK & format) != SF_FORMAT_WAV) - { printf ("Error : This is not a WAV file and hence broadcast info cannot be added to it.\n\n") ; - return 1 ; - } ; - - infileminor = SF_FORMAT_SUBMASK & format ; - - switch (infileminor) - { case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - case SF_FORMAT_MPEG_LAYER_III : - break ; - - default : - printf ( - "Warning : The EBU Technical Recommendation R68-2000 states that the only\n" - " allowed encodings are Linear PCM and MPEG3. This file is not in\n" - " the right format.\n\n" - ) ; - break ; - } ; - - if (sf_command (infile, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0) - { if (infile == outfile) - { printf ( - "Error : Attempting in-place broadcast info update, but file does not\n" - " have a 'bext' chunk to modify. The solution is to specify both\n" - " input and output files on the command line.\n\n" - ) ; - return 1 ; - } ; - } ; - -#define REPLACE_IF_NEW(x) \ - if (info->x != NULL) \ - { memset (binfo.x, 0, sizeof (binfo.x)) ; \ - memcpy (binfo.x, info->x, MIN (strlen (info->x), sizeof (binfo.x))) ; \ - } ; - - REPLACE_IF_NEW (description) ; - REPLACE_IF_NEW (originator) ; - REPLACE_IF_NEW (originator_reference) ; - REPLACE_IF_NEW (origination_date) ; - REPLACE_IF_NEW (origination_time) ; - REPLACE_IF_NEW (umid) ; - - /* Special case loudness values */ -#define REPLACE_IF_NEW_INT(x) \ - if (info->x != NULL) \ - { binfo.x = round (atof (info->x) * 100.0) ; \ - } ; - - REPLACE_IF_NEW_INT (loudness_value) ; - REPLACE_IF_NEW_INT (loudness_range) ; - REPLACE_IF_NEW_INT (max_true_peak_level) ; - REPLACE_IF_NEW_INT (max_momentary_loudness) ; - REPLACE_IF_NEW_INT (max_shortterm_loudness) ; - - /* Special case for Time Ref. */ - if (info->time_ref != NULL) - { uint64_t ts = atoll (info->time_ref) ; - - binfo.time_reference_high = (ts >> 32) ; - binfo.time_reference_low = (ts & 0xffffffff) ; - } ; - - /* Special case for coding_history because we may want to append. */ - if (info->coding_history != NULL) - { if (info->coding_hist_append) - { int slen = (int) strlen (binfo.coding_history) ; - - while (slen > 1 && isspace (binfo.coding_history [slen - 1])) - slen -- ; - - memcpy (binfo.coding_history + slen, info->coding_history, sizeof (binfo.coding_history) - slen) ; - } - else - { size_t slen = MIN (strlen (info->coding_history), sizeof (binfo.coding_history)) ; - - memset (binfo.coding_history, 0, sizeof (binfo.coding_history)) ; - memcpy (binfo.coding_history, info->coding_history, slen) ; - binfo.coding_history_size = (uint32_t) slen ; - } ; - } ; - - if (sf_command (outfile, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0) - { printf ("Error : Setting of broadcast info chunks failed.\n\n") ; - return 1 ; - } ; - - return 0 ; -} /* merge_broadcast_info*/ - -static void -update_strings (SNDFILE * outfile, const METADATA_INFO * info) -{ - if (info->title != NULL) - sf_set_string (outfile, SF_STR_TITLE, info->title) ; - - if (info->copyright != NULL) - sf_set_string (outfile, SF_STR_COPYRIGHT, info->copyright) ; - - if (info->artist != NULL) - sf_set_string (outfile, SF_STR_ARTIST, info->artist) ; - - if (info->comment != NULL) - sf_set_string (outfile, SF_STR_COMMENT, info->comment) ; - - if (info->date != NULL) - sf_set_string (outfile, SF_STR_DATE, info->date) ; - - if (info->album != NULL) - sf_set_string (outfile, SF_STR_ALBUM, info->album) ; - - if (info->license != NULL) - sf_set_string (outfile, SF_STR_LICENSE, info->license) ; - -} /* update_strings */ - - - -void -sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * info) -{ SNDFILE *infile = NULL, *outfile = NULL ; - SF_INFO sfinfo ; - METADATA_INFO tmpinfo ; - int error_code = 0 ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - memset (&tmpinfo, 0, sizeof (tmpinfo)) ; - - if (filenames [1] == NULL) - infile = outfile = sf_open (filenames [0], SFM_RDWR, &sfinfo) ; - else - { infile = sf_open (filenames [0], SFM_READ, &sfinfo) ; - - /* Output must be WAV. */ - sfinfo.format = SF_FORMAT_WAV | (SF_FORMAT_SUBMASK & sfinfo.format) ; - outfile = sf_open (filenames [1], SFM_WRITE, &sfinfo) ; - } ; - - if (infile == NULL) - { printf ("Error : Not able to open input file '%s' : %s\n", filenames [0], sf_strerror (infile)) ; - error_code = 1 ; - goto cleanup_exit ; - } ; - - if (outfile == NULL) - { printf ("Error : Not able to open output file '%s' : %s\n", filenames [1], sf_strerror (outfile)) ; - error_code = 1 ; - goto cleanup_exit ; - } ; - - if (info->has_bext_fields && merge_broadcast_info (infile, outfile, sfinfo.format, info)) - { error_code = 1 ; - goto cleanup_exit ; - } ; - - if (infile != outfile) - { int infileminor = SF_FORMAT_SUBMASK & sfinfo.format ; - - /* If the input file is not the same as the output file, copy the data. */ - if ((infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT)) - { if (sfe_copy_data_fp (outfile, infile, sfinfo.channels, SF_FALSE) != 0) - { printf ("Error : Not able to decode input file '%s'\n", filenames [0]) ; - error_code = 1 ; - goto cleanup_exit ; - } ; - } - else - sfe_copy_data_int (outfile, infile, sfinfo.channels) ; - } ; - - update_strings (outfile, info) ; - -cleanup_exit : - - if (outfile != NULL && outfile != infile) - sf_close (outfile) ; - - if (infile != NULL) - sf_close (infile) ; - - if (error_code) - exit (error_code) ; - - return ; -} /* sfe_apply_metadata_changes */ - -/*============================================================================== -*/ - -typedef struct -{ const char *ext ; - int len ; - int format ; -} OUTPUT_FORMAT_MAP ; - -/* Map a file name extension to a container format. */ -static OUTPUT_FORMAT_MAP format_map [] = -{ - { "wav", 0, SF_FORMAT_WAV }, - { "aif", 3, SF_FORMAT_AIFF }, - { "au", 0, SF_FORMAT_AU }, - { "snd", 0, SF_FORMAT_AU }, - { "raw", 0, SF_FORMAT_RAW }, - { "gsm", 0, SF_FORMAT_RAW | SF_FORMAT_GSM610 }, - { "vox", 0, SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM }, - { "paf", 0, SF_FORMAT_PAF | SF_ENDIAN_BIG }, - { "fap", 0, SF_FORMAT_PAF | SF_ENDIAN_LITTLE }, - { "svx", 0, SF_FORMAT_SVX }, - { "nist", 0, SF_FORMAT_NIST }, - { "sph", 0, SF_FORMAT_NIST }, - { "voc", 0, SF_FORMAT_VOC }, - { "ircam", 0, SF_FORMAT_IRCAM }, - { "sf", 0, SF_FORMAT_IRCAM }, - { "w64", 0, SF_FORMAT_W64 }, - { "mat", 0, SF_FORMAT_MAT4 }, - { "mat4", 0, SF_FORMAT_MAT4 }, - { "mat5", 0, SF_FORMAT_MAT5 }, - { "pvf", 0, SF_FORMAT_PVF }, - { "xi", 0, SF_FORMAT_XI }, - { "htk", 0, SF_FORMAT_HTK }, - { "sds", 0, SF_FORMAT_SDS }, - { "avr", 0, SF_FORMAT_AVR }, - { "wavex", 0, SF_FORMAT_WAVEX }, - { "sd2", 0, SF_FORMAT_SD2 }, - { "flac", 0, SF_FORMAT_FLAC }, - { "caf", 0, SF_FORMAT_CAF }, - { "wve", 0, SF_FORMAT_WVE }, - { "prc", 0, SF_FORMAT_WVE }, - { "oga", 0, SF_FORMAT_OGG }, - { "ogg", 0, SF_FORMAT_OGG | SF_FORMAT_VORBIS }, - { "opus", 0, SF_FORMAT_OGG | SF_FORMAT_OPUS }, - { "mpc", 0, SF_FORMAT_MPC2K }, - { "rf64", 0, SF_FORMAT_RF64 }, - { "mp3", 0, SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III }, -} ; /* format_map */ - -int -sfe_file_type_of_ext (const char *str, int format) -{ char buffer [16], *cptr ; - int k ; - - format &= SF_FORMAT_SUBMASK ; - - if ((cptr = strrchr (str, '.')) == NULL) - return 0 ; - - strncpy (buffer, cptr + 1, 15) ; - buffer [15] = 0 ; - - for (k = 0 ; buffer [k] ; k++) - buffer [k] = tolower ((buffer [k])) ; - - for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++) - { if ((format_map [k].len > 0 && strncmp (buffer, format_map [k].ext, format_map [k].len) == 0) || - (strcmp (buffer, format_map [k].ext) == 0)) - { if (format_map [k].format & SF_FORMAT_SUBMASK) - return format_map [k].format ; - else - return format_map [k].format | format ; - } ; - } ; - - /* Default if all the above fails. */ - return (SF_FORMAT_WAV | SF_FORMAT_PCM_24) ; -} /* sfe_file_type_of_ext */ - -void -sfe_dump_format_map (void) -{ SF_FORMAT_INFO info ; - int k ; - - for (k = 0 ; k < ARRAY_LEN (format_map) ; k++) - { info.format = format_map [k].format ; - sf_command (NULL, SFC_GET_FORMAT_INFO, &info, sizeof (info)) ; - printf (" %-10s : %s", format_map [k].ext, info.name == NULL ? "????" : info.name) ; - if (format_map [k].format & SF_FORMAT_SUBMASK) - { info.format = format_map [k].format & SF_FORMAT_SUBMASK ; - sf_command (NULL, SFC_GET_FORMAT_INFO, &info, sizeof (info)) ; - printf (" %s", info.name == NULL ? "????" : info.name) ; - } ; - putchar ('\n') ; - - } ; - -} /* sfe_dump_format_map */ - -const char * -program_name (const char * argv0) -{ const char * tmp ; - - tmp = strrchr (argv0, '/') ; - argv0 = tmp ? tmp + 1 : argv0 ; - - /* Remove leading libtool name mangling. */ - if (strstr (argv0, "lt-") == argv0) - return argv0 + 3 ; - - return argv0 ; -} /* program_name */ - -const char * -sfe_endian_name (int format) -{ - switch (format & SF_FORMAT_ENDMASK) - { case SF_ENDIAN_FILE : return "file" ; - case SF_ENDIAN_LITTLE : return "little" ; - case SF_ENDIAN_BIG : return "big" ; - case SF_ENDIAN_CPU : return "cpu" ; - default : break ; - } ; - - return "unknown" ; -} /* sfe_endian_name */ - -const char * -sfe_container_name (int format) -{ - switch (format & SF_FORMAT_TYPEMASK) - { case SF_FORMAT_WAV : return "WAV" ; - case SF_FORMAT_AIFF : return "AIFF" ; - case SF_FORMAT_AU : return "AU" ; - case SF_FORMAT_RAW : return "RAW" ; - case SF_FORMAT_PAF : return "PAF" ; - case SF_FORMAT_SVX : return "SVX" ; - case SF_FORMAT_NIST : return "NIST" ; - case SF_FORMAT_VOC : return "VOC" ; - case SF_FORMAT_IRCAM : return "IRCAM" ; - case SF_FORMAT_W64 : return "W64" ; - case SF_FORMAT_MAT4 : return "MAT4" ; - case SF_FORMAT_MAT5 : return "MAT5" ; - case SF_FORMAT_PVF : return "PVF" ; - case SF_FORMAT_XI : return "XI" ; - case SF_FORMAT_HTK : return "HTK" ; - case SF_FORMAT_SDS : return "SDS" ; - case SF_FORMAT_AVR : return "AVR" ; - case SF_FORMAT_WAVEX : return "WAVEX" ; - case SF_FORMAT_SD2 : return "SD2" ; - case SF_FORMAT_FLAC : return "FLAC" ; - case SF_FORMAT_CAF : return "CAF" ; - case SF_FORMAT_WVE : return "WVE" ; - case SF_FORMAT_OGG : return "OGG" ; - case SF_FORMAT_MPC2K : return "MPC2K" ; - case SF_FORMAT_RF64 : return "RF64" ; - case SF_FORMAT_MPEG : return "MPEG" ; - default : break ; - } ; - - return "unknown" ; -} /* sfe_container_name */ - -const char * -sfe_codec_name (int format) -{ - switch (format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_PCM_S8 : return "signed 8 bit PCM" ; - case SF_FORMAT_PCM_16 : return "16 bit PCM" ; - case SF_FORMAT_PCM_24 : return "24 bit PCM" ; - case SF_FORMAT_PCM_32 : return "32 bit PCM" ; - case SF_FORMAT_PCM_U8 : return "unsigned 8 bit PCM" ; - case SF_FORMAT_FLOAT : return "32 bit float" ; - case SF_FORMAT_DOUBLE : return "64 bit double" ; - case SF_FORMAT_ULAW : return "u-law" ; - case SF_FORMAT_ALAW : return "a-law" ; - case SF_FORMAT_IMA_ADPCM : return "IMA ADPCM" ; - case SF_FORMAT_MS_ADPCM : return "MS ADPCM" ; - case SF_FORMAT_GSM610 : return "gsm610" ; - case SF_FORMAT_VOX_ADPCM : return "Vox ADPCM" ; - case SF_FORMAT_G721_32 : return "g721 32kbps" ; - case SF_FORMAT_G723_24 : return "g723 24kbps" ; - case SF_FORMAT_G723_40 : return "g723 40kbps" ; - case SF_FORMAT_DWVW_12 : return "12 bit DWVW" ; - case SF_FORMAT_DWVW_16 : return "16 bit DWVW" ; - case SF_FORMAT_DWVW_24 : return "14 bit DWVW" ; - case SF_FORMAT_DWVW_N : return "DWVW" ; - case SF_FORMAT_DPCM_8 : return "8 bit DPCM" ; - case SF_FORMAT_DPCM_16 : return "16 bit DPCM" ; - case SF_FORMAT_VORBIS : return "Vorbis" ; - case SF_FORMAT_ALAC_16 : return "16 bit ALAC" ; - case SF_FORMAT_ALAC_20 : return "20 bit ALAC" ; - case SF_FORMAT_ALAC_24 : return "24 bit ALAC" ; - case SF_FORMAT_ALAC_32 : return "32 bit ALAC" ; - case SF_FORMAT_OPUS : return "Opus" ; - case SF_FORMAT_MPEG_LAYER_I : return "MPEG layer 1" ; - case SF_FORMAT_MPEG_LAYER_II : return "MPEG layer 2" ; - case SF_FORMAT_MPEG_LAYER_III : return "MPEG layer 3" ; - default : break ; - } ; - return "unknown" ; -} /* sfe_codec_name */ diff --git a/Engine/lib/libsndfile/programs/common.h b/Engine/lib/libsndfile/programs/common.h deleted file mode 100644 index 5ed36dbb4..000000000 --- a/Engine/lib/libsndfile/programs/common.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -** Copyright (C) 1999-2013 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - - -#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof (x [0]))) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -typedef struct -{ const char * title ; - const char * copyright ; - const char * artist ; - const char * comment ; - const char * date ; - const char * album ; - const char * license ; - - - /* Stuff to go in the 'bext' chunk of WAV files. */ - int has_bext_fields ; - int coding_hist_append ; - - const char * description ; - const char * originator ; - const char * originator_reference ; - const char * origination_date ; - const char * origination_time ; - const char * umid ; - const char * loudness_value ; - const char * loudness_range ; - const char * max_true_peak_level ; - const char * max_momentary_loudness ; - const char * max_shortterm_loudness ; - const char * coding_history ; - const char * time_ref ; -} METADATA_INFO ; - -typedef SF_BROADCAST_INFO_VAR (2048) SF_BROADCAST_INFO_2K ; - -void sfe_apply_metadata_changes (const char * filenames [2], const METADATA_INFO * info) ; - -int sfe_copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels, int normalize) ; - -void sfe_copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ; - -int sfe_file_type_of_ext (const char *filename, int format) ; - -void sfe_dump_format_map (void) ; - -const char * program_name (const char * argv0) ; - -const char * sfe_endian_name (int format) ; -const char * sfe_container_name (int format) ; -const char * sfe_codec_name (int format) ; diff --git a/Engine/lib/libsndfile/programs/sndfile-cmp.c b/Engine/lib/libsndfile/programs/sndfile-cmp.c deleted file mode 100644 index 3dd992d1a..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-cmp.c +++ /dev/null @@ -1,155 +0,0 @@ -/* -** Copyright (C) 2008-2016 Erik de Castro Lopo -** Copyright (C) 2008 Conrad Parker -** -** 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 author nor the names of any 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. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include - -#include "common.h" - -/* Length of comparison data buffers in units of items */ -#define BUFLEN 65536 - -static const char * progname = NULL ; -static char * filename1 = NULL, * filename2 = NULL ; - -static int -comparison_error (const char * what, sf_count_t frame_offset) -{ char buffer [128] ; - - if (frame_offset >= 0) - snprintf (buffer, sizeof (buffer), " (at frame offset %" PRId64 ")", frame_offset) ; - else - buffer [0] = 0 ; - - printf ("%s: %s of files %s and %s differ%s.\n", progname, what, filename1, filename2, buffer) ; - return 1 ; -} /* comparison_error */ - -static int -compare (void) -{ - double buf1 [BUFLEN], buf2 [BUFLEN] ; - SF_INFO sfinfo1, sfinfo2 ; - SNDFILE * sf1 = NULL, * sf2 = NULL ; - sf_count_t items, i, nread1, nread2, offset = 0 ; - int retval = 0 ; - - memset (&sfinfo1, 0, sizeof (SF_INFO)) ; - sf1 = sf_open (filename1, SFM_READ, &sfinfo1) ; - if (sf1 == NULL) - { printf ("Error opening %s.\n", filename1) ; - retval = 1 ; - goto out ; - } ; - - memset (&sfinfo2, 0, sizeof (SF_INFO)) ; - sf2 = sf_open (filename2, SFM_READ, &sfinfo2) ; - if (sf2 == NULL) - { printf ("Error opening %s.\n", filename2) ; - retval = 1 ; - goto out ; - } ; - - if (sfinfo1.samplerate != sfinfo2.samplerate) - { retval = comparison_error ("Samplerates", -1) ; - goto out ; - } ; - - if (sfinfo1.channels != sfinfo2.channels) - { retval = comparison_error ("Number of channels", -1) ; - goto out ; - } ; - - /* Calculate the framecount that will fit in our data buffers */ - items = BUFLEN / sfinfo1.channels ; - - while ((nread1 = sf_readf_double (sf1, buf1, items)) > 0) - { nread2 = sf_readf_double (sf2, buf2, nread1) ; - if (nread2 != nread1) - { retval = comparison_error ("PCM data lengths", -1) ; - goto out ; - } ; - for (i = 0 ; i < nread1 * sfinfo1.channels ; i++) - { if (buf1 [i] != buf2 [i]) - { retval = comparison_error ("PCM data", offset + i / sfinfo1.channels) ; - goto out ; - } ; - } ; - offset += nread1 ; - } ; - - if ((nread2 = sf_readf_double (sf2, buf2, items)) != 0) - { retval = comparison_error ("PCM data lengths", -1) ; - goto out ; - } ; - -out : - sf_close (sf1) ; - sf_close (sf2) ; - - return retval ; -} /* compare */ - -static void -usage_exit (void) -{ - printf ("Usage : %s \n", progname) ; - printf (" Compare the PCM data of two sound files.\n\n") ; - printf ("Using %s.\n\n", sf_version_string ()) ; - exit (1) ; -} /* usage_exit */ - -int -main (int argc, char *argv []) -{ - progname = program_name (argv [0]) ; - - if (argc != 3) - usage_exit () ; - - filename1 = argv [argc - 2] ; - filename2 = argv [argc - 1] ; - - if (strcmp (filename1, filename2) == 0) - { printf ("Error : Input filenames are the same.\n\n") ; - usage_exit () ; - } ; - - return compare () ; -} /* main */ diff --git a/Engine/lib/libsndfile/programs/sndfile-concat.c b/Engine/lib/libsndfile/programs/sndfile-concat.c deleted file mode 100644 index 49380fd00..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-concat.c +++ /dev/null @@ -1,170 +0,0 @@ -/* -** Copyright (C) 1999-2014 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include - -#include - -#include "common.h" - -#define BUFFER_LEN (1 << 16) - - -static void concat_data_fp (SNDFILE *wfile, SNDFILE *rofile, int channels) ; -static void concat_data_int (SNDFILE *wfile, SNDFILE *rofile, int channels) ; - -static void -usage_exit (const char *progname) -{ - printf ("\nUsage : %s ... \n\n", progname) ; - puts ( - " Create a new output file containing the concatenated\n" - " audio data from froms ....\n" - "\n" - " The joined file will be encoded in the same format as the data\n" - " in infile1, with all the data in subsequent files automatically\n" - " converted to the correct encoding.\n" - "\n" - " The only restriction is that the two files must have the same\n" - " number of channels.\n" - ) ; - - exit (1) ; -} /* usage_exit */ - -int -main (int argc, char *argv []) -{ const char *progname, *outfilename ; - SNDFILE *outfile, **infiles ; - SF_INFO sfinfo_out, sfinfo_in ; - void (*func) (SNDFILE*, SNDFILE*, int) ; - int k ; - - progname = program_name (argv [0]) ; - - if (argc < 4) - usage_exit (progname) ; - - argv ++ ; - argc -- ; - - argc -- ; - outfilename = argv [argc] ; - - if ((infiles = calloc (argc, sizeof (SNDFILE*))) == NULL) - { printf ("\nError : Malloc failed.\n\n") ; - exit (1) ; - } ; - - memset (&sfinfo_in, 0, sizeof (sfinfo_in)) ; - - if ((infiles [0] = sf_open (argv [0], SFM_READ, &sfinfo_in)) == NULL) - { printf ("\nError : failed to open file '%s'.\n\n", argv [0]) ; - exit (1) ; - } ; - - sfinfo_out = sfinfo_in ; - - for (k = 1 ; k < argc ; k++) - { if ((infiles [k] = sf_open (argv [k], SFM_READ, &sfinfo_in)) == NULL) - { printf ("\nError : failed to open file '%s'.\n\n", argv [k]) ; - exit (1) ; - } ; - - if (sfinfo_in.channels != sfinfo_out.channels) - { printf ("\nError : File '%s' has %d channels (should have %d).\n\n", argv [k], sfinfo_in.channels, sfinfo_out.channels) ; - exit (1) ; - } ; - } ; - - if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo_out)) == NULL) - { printf ("\nError : Not able to open input file %s.\n", outfilename) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - if ((sfinfo_out.format & SF_FORMAT_SUBMASK) == SF_FORMAT_DOUBLE || - (sfinfo_out.format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT) - func = concat_data_fp ; - else - func = concat_data_int ; - - for (k = 0 ; k < argc ; k++) - { func (outfile, infiles [k], sfinfo_out.channels) ; - sf_close (infiles [k]) ; - } ; - - sf_close (outfile) ; - free (infiles) ; - - return 0 ; -} /* main */ - -static void -concat_data_fp (SNDFILE *wfile, SNDFILE *rofile, int channels) -{ static double data [BUFFER_LEN] ; - int frames, readcount ; - - frames = BUFFER_LEN / channels ; - readcount = frames ; - - sf_seek (wfile, 0, SEEK_END) ; - - while (readcount > 0) - { readcount = (int) sf_readf_double (rofile, data, frames) ; - sf_writef_double (wfile, data, readcount) ; - } ; - - return ; -} /* concat_data_fp */ - -static void -concat_data_int (SNDFILE *wfile, SNDFILE *rofile, int channels) -{ static int data [BUFFER_LEN] ; - int frames, readcount ; - - frames = BUFFER_LEN / channels ; - readcount = frames ; - - sf_seek (wfile, 0, SEEK_END) ; - - while (readcount > 0) - { readcount = (int) sf_readf_int (rofile, data, frames) ; - sf_writef_int (wfile, data, readcount) ; - } ; - - return ; -} /* concat_data_int */ - diff --git a/Engine/lib/libsndfile/programs/sndfile-convert.c b/Engine/lib/libsndfile/programs/sndfile-convert.c deleted file mode 100644 index b94686242..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-convert.c +++ /dev/null @@ -1,410 +0,0 @@ -/* -** Copyright (C) 1999-2019 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include - -#include - -#include "common.h" - - -typedef struct -{ char *infilename, *outfilename ; - SF_INFO infileinfo, outfileinfo ; -} OptionData ; - -static void copy_metadata (SNDFILE *outfile, SNDFILE *infile, int channels) ; - -static void -usage_exit (const char *progname) -{ - printf ("\nUsage : %s [options] [encoding] \n", progname) ; - puts ("\n" - " where [option] may be:\n\n" - " -override-sample-rate=X : force sample rate of input to X\n" - " -endian=little : force output file to little endian data\n" - " -endian=big : force output file to big endian data\n" - " -endian=cpu : force output file same endian-ness as the CPU\n" - " -normalize : normalize the data in the output file\n" - ) ; - - puts ( - " where [encoding] may be one of the following:\n\n" - " -pcms8 : signed 8 bit pcm\n" - " -pcmu8 : unsigned 8 bit pcm\n" - " -pcm16 : 16 bit pcm\n" - " -pcm24 : 24 bit pcm\n" - " -pcm32 : 32 bit pcm\n" - " -float32 : 32 bit floating point\n" - " -float64 : 64 bit floating point\n" - " -ulaw : ULAW\n" - " -alaw : ALAW\n" - " -alac16 : 16 bit ALAC (CAF only)\n" - " -alac20 : 20 bit ALAC (CAF only)\n" - " -alac24 : 24 bit ALAC (CAF only)\n" - " -alac32 : 32 bit ALAC (CAF only)\n" - " -ima-adpcm : IMA ADPCM (WAV only)\n" - " -ms-adpcm : MS ADPCM (WAV only)\n" - " -gsm610 : GSM6.10 (WAV only)\n" - " -dwvw12 : 12 bit DWVW (AIFF only)\n" - " -dwvw16 : 16 bit DWVW (AIFF only)\n" - " -dwvw24 : 24 bit DWVW (AIFF only)\n" - " -vorbis : Vorbis (OGG only)\n" - " -opus : Opus (OGG only)\n" - ) ; - - puts ( - " If no encoding is specified, the program will try to use the encoding\n" - " of the input file in the output file. This will not always work as\n" - " most container formats (eg WAV, AIFF etc) only support a small subset\n" - " of codec formats (eg 16 bit PCM, a-law, Vorbis etc).\n" - ) ; - - puts ( - " The format of the output file is determined by the file extension of the\n" - " output file name. The following extensions are currently understood:\n" - ) ; - - sfe_dump_format_map () ; - - puts ("") ; - exit (1) ; -} /* usage_exit */ - -static void -report_format_error_exit (const char * argv0, SF_INFO * sfinfo) -{ int old_format = sfinfo->format ; - int endian = sfinfo->format & SF_FORMAT_ENDMASK ; - int channels = sfinfo->channels ; - - sfinfo->format = old_format & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ; - - if (endian && sf_format_check (sfinfo)) - { printf ("Error : output file format does not support %s endian-ness.\n", sfe_endian_name (endian)) ; - exit (1) ; - } ; - - sfinfo->channels = 1 ; - if (sf_format_check (sfinfo)) - { printf ("Error : output file format does not support %d channels.\n", channels) ; - exit (1) ; - } ; - - printf ("\n" - "Error : output file format is invalid.\n" - "The '%s' container does not support '%s' codec data.\n" - "Run '%s --help' for clues.\n\n", - sfe_container_name (sfinfo->format), sfe_codec_name (sfinfo->format), program_name (argv0)) ; - exit (1) ; -} /* report_format_error_exit */ - -int -main (int argc, char * argv []) -{ const char *progname, *infilename, *outfilename ; - SNDFILE *infile = NULL, *outfile = NULL ; - SF_INFO sfinfo ; - int k, outfilemajor, outfileminor = 0, infileminor ; - int override_sample_rate = 0 ; /* assume no sample rate override. */ - int endian = SF_ENDIAN_FILE, normalize = SF_FALSE ; - - progname = program_name (argv [0]) ; - - if (argc < 3 || argc > 5) - usage_exit (progname) ; - - infilename = argv [argc-2] ; - outfilename = argv [argc-1] ; - - if (strcmp (infilename, outfilename) == 0) - { printf ("Error : Input and output filenames are the same.\n\n") ; - usage_exit (progname) ; - } ; - - if (strlen (infilename) > 1 && infilename [0] == '-') - { printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ; - usage_exit (progname) ; - } ; - - if (outfilename [0] == '-') - { printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ; - usage_exit (progname) ; - } ; - - for (k = 1 ; k < argc - 2 ; k++) - { if (! strcmp (argv [k], "-pcms8")) - { outfileminor = SF_FORMAT_PCM_S8 ; - continue ; - } ; - if (! strcmp (argv [k], "-pcmu8")) - { outfileminor = SF_FORMAT_PCM_U8 ; - continue ; - } ; - if (! strcmp (argv [k], "-pcm16")) - { outfileminor = SF_FORMAT_PCM_16 ; - continue ; - } ; - if (! strcmp (argv [k], "-pcm24")) - { outfileminor = SF_FORMAT_PCM_24 ; - continue ; - } ; - if (! strcmp (argv [k], "-pcm32")) - { outfileminor = SF_FORMAT_PCM_32 ; - continue ; - } ; - if (! strcmp (argv [k], "-float32")) - { outfileminor = SF_FORMAT_FLOAT ; - continue ; - } ; - if (! strcmp (argv [k], "-float64")) - { outfileminor = SF_FORMAT_DOUBLE ; - continue ; - } ; - if (! strcmp (argv [k], "-ulaw")) - { outfileminor = SF_FORMAT_ULAW ; - continue ; - } ; - if (! strcmp (argv [k], "-alaw")) - { outfileminor = SF_FORMAT_ALAW ; - continue ; - } ; - if (! strcmp (argv [k], "-alac16")) - { outfileminor = SF_FORMAT_ALAC_16 ; - continue ; - } ; - if (! strcmp (argv [k], "-alac20")) - { outfileminor = SF_FORMAT_ALAC_20 ; - continue ; - } ; - if (! strcmp (argv [k], "-alac24")) - { outfileminor = SF_FORMAT_ALAC_24 ; - continue ; - } ; - if (! strcmp (argv [k], "-alac32")) - { outfileminor = SF_FORMAT_ALAC_32 ; - continue ; - } ; - if (! strcmp (argv [k], "-ima-adpcm")) - { outfileminor = SF_FORMAT_IMA_ADPCM ; - continue ; - } ; - if (! strcmp (argv [k], "-ms-adpcm")) - { outfileminor = SF_FORMAT_MS_ADPCM ; - continue ; - } ; - if (! strcmp (argv [k], "-gsm610")) - { outfileminor = SF_FORMAT_GSM610 ; - continue ; - } ; - if (! strcmp (argv [k], "-dwvw12")) - { outfileminor = SF_FORMAT_DWVW_12 ; - continue ; - } ; - if (! strcmp (argv [k], "-dwvw16")) - { outfileminor = SF_FORMAT_DWVW_16 ; - continue ; - } ; - if (! strcmp (argv [k], "-dwvw24")) - { outfileminor = SF_FORMAT_DWVW_24 ; - continue ; - } ; - if (! strcmp (argv [k], "-vorbis")) - { outfileminor = SF_FORMAT_VORBIS ; - continue ; - } ; - if (! strcmp (argv [k], "-opus")) - { outfileminor = SF_FORMAT_OPUS ; - continue ; - } ; - - if (strstr (argv [k], "-override-sample-rate=") == argv [k]) - { const char *ptr ; - - ptr = argv [k] + strlen ("-override-sample-rate=") ; - override_sample_rate = atoi (ptr) ; - continue ; - } ; - - if (! strcmp (argv [k], "-endian=little")) - { endian = SF_ENDIAN_LITTLE ; - continue ; - } ; - - if (! strcmp (argv [k], "-endian=big")) - { endian = SF_ENDIAN_BIG ; - continue ; - } ; - - if (! strcmp (argv [k], "-endian=cpu")) - { endian = SF_ENDIAN_CPU ; - continue ; - } ; - - if (! strcmp (argv [k], "-endian=file")) - { endian = SF_ENDIAN_FILE ; - continue ; - } ; - - if (! strcmp (argv [k], "-normalize")) - { normalize = SF_TRUE ; - continue ; - } ; - - printf ("Error : Not able to decode argument '%s'.\n", argv [k]) ; - exit (1) ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL) - { printf ("Not able to open input file %s.\n", infilename) ; - puts (sf_strerror (NULL)) ; - return 1 ; - } ; - - /* Update sample rate if forced to something else. */ - if (override_sample_rate) - sfinfo.samplerate = override_sample_rate ; - - infileminor = sfinfo.format & SF_FORMAT_SUBMASK ; - - if ((sfinfo.format = sfe_file_type_of_ext (outfilename, sfinfo.format)) == 0) - { printf ("Error : Not able to determine output file type for %s.\n", outfilename) ; - return 1 ; - } ; - - outfilemajor = sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_ENDMASK) ; - - if (outfileminor == 0) - outfileminor = sfinfo.format & SF_FORMAT_SUBMASK ; - - if (outfileminor != 0) - sfinfo.format = outfilemajor | outfileminor ; - else - sfinfo.format = outfilemajor | (sfinfo.format & SF_FORMAT_SUBMASK) ; - - sfinfo.format |= endian ; - - if ((sfinfo.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_XI) - switch (sfinfo.format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_PCM_16 : - sfinfo.format = outfilemajor | SF_FORMAT_DPCM_16 ; - break ; - - case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_U8 : - sfinfo.format = outfilemajor | SF_FORMAT_DPCM_8 ; - break ; - } ; - - if (sf_format_check (&sfinfo) == 0) - { sf_close (infile) ; - report_format_error_exit (argv [0], &sfinfo) ; - } ; - - if ((sfinfo.format & SF_FORMAT_SUBMASK) == SF_FORMAT_GSM610 && sfinfo.samplerate != 8000) - { printf ( - "WARNING: GSM 6.10 data format only supports 8kHz sample rate. The converted\n" - "ouput file will contain the input data converted to the GSM 6.10 data format\n" - "but not re-sampled.\n" - ) ; - } ; - - /* Open the output file. */ - if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)) == NULL) - { printf ("Not able to open output file %s : %s\n", outfilename, sf_strerror (NULL)) ; - return 1 ; - } ; - - /* Copy the metadata */ - copy_metadata (outfile, infile, sfinfo.channels) ; - - if (normalize - || (outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT) - || (infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT) - || (infileminor == SF_FORMAT_OPUS) || (outfileminor == SF_FORMAT_OPUS) - || (infileminor == SF_FORMAT_VORBIS) || (outfileminor == SF_FORMAT_VORBIS) - || (infileminor == SF_FORMAT_MPEG_LAYER_I) - || (infileminor == SF_FORMAT_MPEG_LAYER_II) - || (infileminor == SF_FORMAT_MPEG_LAYER_III) || (outfileminor == SF_FORMAT_MPEG_LAYER_III)) - { if (sfe_copy_data_fp (outfile, infile, sfinfo.channels, normalize) != 0) - { printf ("Error : Not able to decode input file %s.\n", infilename) ; - return 1 ; - } ; - } - else - sfe_copy_data_int (outfile, infile, sfinfo.channels) ; - - sf_close (infile) ; - sf_close (outfile) ; - - return 0 ; -} /* main */ - -static void -copy_metadata (SNDFILE *outfile, SNDFILE *infile, int channels) -{ SF_INSTRUMENT inst ; - SF_CUES cues ; - SF_BROADCAST_INFO_2K binfo ; - const char *str ; - int k, chanmap [256] ; - - for (k = SF_STR_FIRST ; k <= SF_STR_LAST ; k++) - { str = sf_get_string (infile, k) ; - if (str != NULL) - sf_set_string (outfile, k, str) ; - } ; - - memset (&inst, 0, sizeof (inst)) ; - memset (&cues, 0, sizeof (cues)) ; - memset (&binfo, 0, sizeof (binfo)) ; - - if (channels < ARRAY_LEN (chanmap)) - { int size = channels * sizeof (chanmap [0]) ; - - if (sf_command (infile, SFC_GET_CHANNEL_MAP_INFO, chanmap, size) == SF_TRUE) - sf_command (outfile, SFC_SET_CHANNEL_MAP_INFO, chanmap, size) ; - } ; - - if (sf_command (infile, SFC_GET_CUE, &cues, sizeof (cues)) == SF_TRUE) - sf_command (outfile, SFC_SET_CUE, &cues, sizeof (cues)) ; - - if (sf_command (infile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE) - sf_command (outfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ; - - if (sf_command (infile, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == SF_TRUE) - sf_command (outfile, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) ; - -} /* copy_metadata */ - diff --git a/Engine/lib/libsndfile/programs/sndfile-deinterleave.c b/Engine/lib/libsndfile/programs/sndfile-deinterleave.c deleted file mode 100644 index 42d475099..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-deinterleave.c +++ /dev/null @@ -1,222 +0,0 @@ -/* -** Copyright (C) 2009-2017 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include - -#include "common.h" - -#define BUFFER_LEN 4096 -#define MAX_CHANNELS 16 - - -typedef struct -{ SNDFILE * infile ; - SNDFILE * outfile [MAX_CHANNELS] ; - - union - { double d [MAX_CHANNELS * BUFFER_LEN] ; - int i [MAX_CHANNELS * BUFFER_LEN] ; - } din ; - - union - { double d [BUFFER_LEN] ; - int i [BUFFER_LEN] ; - } dout ; - - int channels ; -} STATE ; - -static void usage_exit (void) ; - -static void deinterleave_int (STATE * state) ; -static void deinterleave_double (STATE * state) ; - -int -main (int argc, char **argv) -{ STATE *state = NULL ; - SF_INFO sfinfo ; - char pathname [512], ext [32], *cptr ; - int ch, double_split, ret = 1 ; - - if (argc != 2) - { if (argc != 1) - puts ("\nError : need a single input file.\n") ; - usage_exit () ; - goto cleanup ; - } ; - - state = calloc (1, sizeof (*state)) ; - if (!state) - { printf ("\nError : Out of memory.\n") ; - goto cleanup ; - } ; - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if ((state->infile = sf_open (argv [1], SFM_READ, &sfinfo)) == NULL) - { printf ("\nError : Not able to open input file '%s'\n%s\n", argv [1], sf_strerror (NULL)) ; - goto cleanup ; - } ; - - if (sfinfo.channels < 2) - { printf ("\nError : Input file '%s' only has one channel.\n", argv [1]) ; - goto cleanup ; - } ; - - if (sfinfo.channels > MAX_CHANNELS) - { printf ("\nError : Input file '%s' has too many (%d) channels. Limit is %d.\n", - argv [1], sfinfo.channels, MAX_CHANNELS) ; - goto cleanup ; - } ; - - - state->channels = sfinfo.channels ; - sfinfo.channels = 1 ; - - if (snprintf (pathname, sizeof (pathname), "%s", argv [1]) > (int) sizeof (pathname)) - { printf ("\nError : Length of provided filename '%s' exceeds MAX_PATH (%d).\n", argv [1], (int) sizeof (pathname)) ; - goto cleanup ; - } ; - - if ((cptr = strrchr (pathname, '.')) == NULL) - ext [0] = 0 ; - else - { snprintf (ext, sizeof (ext), "%s", cptr) ; - cptr [0] = 0 ; - } ; - - printf ("Input file : %s\n", pathname) ; - puts ("Output files :") ; - - for (ch = 0 ; ch < state->channels ; ch++) - { char filename [520] ; - size_t count ; - - count = snprintf (filename, sizeof (filename), "%s_%02d%s", pathname, ch, ext) ; - - if (count >= sizeof (filename)) - { printf ("File name truncated to %s\n", filename) ; - } ; - - if ((state->outfile [ch] = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { printf ("Not able to open output file '%s'\n%s\n", filename, sf_strerror (NULL)) ; - goto cleanup ; - } ; - - printf (" %s\n", filename) ; - } ; - - switch (sfinfo.format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - case SF_FORMAT_VORBIS : - double_split = 1 ; - break ; - - default : - double_split = 0 ; - break ; - } ; - - if (double_split) - deinterleave_double (state) ; - else - deinterleave_int (state) ; - - ret = 0 ; - -cleanup : - - if (state != NULL) - { sf_close (state->infile) ; - for (ch = 0 ; ch < MAX_CHANNELS ; ch++) - if (state->outfile [ch] != NULL) - sf_close (state->outfile [ch]) ; - } ; - - free (state) ; - - return ret ; -} /* main */ - -/*------------------------------------------------------------------------------ -*/ - -static void -usage_exit (void) -{ puts ("\nUsage : sndfile-deinterleave \n") ; - puts ( - "Split a mutli-channel file into a set of mono files.\n" - "\n" - "If the input file is named 'a.wav', the output files will be named\n" - "a_00.wav, a_01.wav and so on.\n" - ) ; - printf ("Using %s.\n\n", sf_version_string ()) ; -} /* usage_exit */ - -static void -deinterleave_int (STATE * state) -{ int read_len ; - int ch, k ; - - do - { read_len = (int) sf_readf_int (state->infile, state->din.i, BUFFER_LEN) ; - - for (ch = 0 ; ch < state->channels ; ch ++) - { for (k = 0 ; k < read_len ; k++) - state->dout.i [k] = state->din.i [k * state->channels + ch] ; - sf_write_int (state->outfile [ch], state->dout.i, read_len) ; - } ; - } - while (read_len > 0) ; - -} /* deinterleave_int */ - -static void -deinterleave_double (STATE * state) -{ int read_len ; - int ch, k ; - - do - { read_len = (int) sf_readf_double (state->infile, state->din.d, BUFFER_LEN) ; - - for (ch = 0 ; ch < state->channels ; ch ++) - { for (k = 0 ; k < read_len ; k++) - state->dout.d [k] = state->din.d [k * state->channels + ch] ; - sf_write_double (state->outfile [ch], state->dout.d, read_len) ; - } ; - } - while (read_len > 0) ; - -} /* deinterleave_double */ diff --git a/Engine/lib/libsndfile/programs/sndfile-info.c b/Engine/lib/libsndfile/programs/sndfile-info.c deleted file mode 100644 index ae4465496..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-info.c +++ /dev/null @@ -1,529 +0,0 @@ -/* -** Copyright (C) 1999-2019 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include -#include -#include - -#include - -#include "common.h" - -#define BUFFER_LEN (1 << 16) - -#if (defined (WIN32) || defined (_WIN32)) -#include -#endif - -static void usage_exit (const char *progname) ; - -static void info_dump (const char *filename) ; -static int instrument_dump (const char *filename) ; -static int broadcast_dump (const char *filename) ; -static int chanmap_dump (const char *filename) ; -static int cart_dump (const char *filename) ; -static void total_dump (void) ; - -static double total_seconds = 0.0 ; - -int -main (int argc, char *argv []) -{ int k ; - - if (argc < 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0) - usage_exit (program_name (argv [0])) ; - - if (strcmp (argv [1], "--instrument") == 0) - { int error = 0 ; - - for (k = 2 ; k < argc ; k++) - error += instrument_dump (argv [k]) ; - return error ; - } ; - - if (strcmp (argv [1], "--broadcast") == 0) - { int error = 0 ; - - for (k = 2 ; k < argc ; k++) - error += broadcast_dump (argv [k]) ; - return error ; - } ; - - if (strcmp (argv [1], "--channel-map") == 0) - { int error = 0 ; - - for (k = 2 ; k < argc ; k++) - error += chanmap_dump (argv [k]) ; - return error ; - } ; - - if (strcmp (argv [1], "--cart") == 0) - { int error = 0 ; - - for (k = 2 ; k < argc ; k++) - error += cart_dump (argv [k]) ; - return error ; - } ; - - for (k = 1 ; k < argc ; k++) - info_dump (argv [k]) ; - - if (argc > 2) - total_dump () ; - - return 0 ; -} /* main */ - -/*============================================================================== -** Print version and usage. -*/ - -static void -usage_exit (const char *progname) -{ printf ("Usage :\n %s ...\n", progname) ; - printf (" Prints out information about one or more sound files.\n\n") ; - printf (" %s --instrument \n", progname) ; - printf (" Prints out the instrument data for the given file.\n\n") ; - printf (" %s --broadcast \n", progname) ; - printf (" Prints out the broadcast WAV info for the given file.\n\n") ; - printf (" %s --channel-map \n", progname) ; - printf (" Prints out the channel map for the given file.\n\n") ; - printf (" %s --cart \n", progname) ; - printf (" Prints out the cart chunk WAV info for the given file.\n\n") ; - - printf ("Using %s.\n\n", sf_version_string ()) ; -#if (defined (_WIN32) || defined (WIN32)) - printf ("This is a Unix style command line application which\n" - "should be run in a MSDOS box or Command Shell window.\n\n") ; - printf ("Sleeping for 5 seconds before exiting.\n\n") ; - fflush (stdout) ; - - Sleep (5 * 1000) ; -#endif - exit (1) ; -} /* usage_exit */ - -/*============================================================================== -** Dumping of sndfile info. -*/ - -static double data [BUFFER_LEN] ; - -static double -calc_decibels (SF_INFO * sfinfo, double max) -{ double decibels ; - - switch (sfinfo->format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_S8 : - decibels = max / 0x80 ; - break ; - - case SF_FORMAT_PCM_16 : - decibels = max / 0x8000 ; - break ; - - case SF_FORMAT_PCM_24 : - decibels = max / 0x800000 ; - break ; - - case SF_FORMAT_PCM_32 : - decibels = max / 0x80000000 ; - break ; - - case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - case SF_FORMAT_VORBIS : - case SF_FORMAT_OPUS : - decibels = max / 1.0 ; - break ; - - default : - decibels = max / 0x8000 ; - break ; - } ; - - return 20.0 * log10 (decibels) ; -} /* calc_decibels */ - -static const char * -format_duration_str (double seconds) -{ static char str [128] ; - int hrs, min ; - double sec ; - - memset (str, 0, sizeof (str)) ; - - hrs = (int) (seconds / 3600.0) ; - min = (int) ((seconds - (hrs * 3600.0)) / 60.0) ; - sec = seconds - (hrs * 3600.0) - (min * 60.0) ; - - snprintf (str, sizeof (str) - 1, "%02d:%02d:%06.3f", hrs, min, sec) ; - - return str ; -} /* format_duration_str */ - -static const char * -generate_duration_str (SF_INFO *sfinfo) -{ - double seconds ; - - if (sfinfo->samplerate < 1) - return NULL ; - - if (sfinfo->frames / sfinfo->samplerate > 0x7FFFFFFF) - return "unknown" ; - - seconds = (1.0 * sfinfo->frames) / sfinfo->samplerate ; - - /* Accumulate the total of all known file durations */ - total_seconds += seconds ; - - return format_duration_str (seconds) ; -} /* generate_duration_str */ - -static void -info_dump (const char *filename) -{ static char strbuffer [BUFFER_LEN] ; - SNDFILE *file ; - SF_INFO sfinfo ; - double signal_max, decibels ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) - { printf ("Error : Not able to open input file %s.\n", filename) ; - fflush (stdout) ; - memset (data, 0, sizeof (data)) ; - sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ; - puts (strbuffer) ; - puts (sf_strerror (NULL)) ; - return ; - } ; - - printf ("========================================\n") ; - sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ; - puts (strbuffer) ; - printf ("----------------------------------------\n") ; - - printf ("Sample Rate : %d\n", sfinfo.samplerate) ; - - if (sfinfo.frames == SF_COUNT_MAX) - printf ("Frames : unknown\n") ; - else - printf ("Frames : %" PRId64 "\n", sfinfo.frames) ; - - printf ("Channels : %d\n", sfinfo.channels) ; - printf ("Format : 0x%08X\n", sfinfo.format) ; - printf ("Sections : %d\n", sfinfo.sections) ; - printf ("Seekable : %s\n", (sfinfo.seekable ? "TRUE" : "FALSE")) ; - printf ("Duration : %s\n", generate_duration_str (&sfinfo)) ; - - if (sfinfo.frames < 100 * 1024 * 1024) - { /* Do not use sf_signal_max because it doesn't work for non-seekable files . */ - sf_command (file, SFC_CALC_SIGNAL_MAX, &signal_max, sizeof (signal_max)) ; - decibels = calc_decibels (&sfinfo, signal_max) ; - printf ("Signal Max : %g (%4.2f dB)\n", signal_max, decibels) ; - } ; - putchar ('\n') ; - - sf_close (file) ; - -} /* info_dump */ - -/*============================================================================== -** Dumping of SF_INSTRUMENT data. -*/ - -static const char * -str_of_type (int mode) -{ switch (mode) - { case SF_LOOP_NONE : return "none" ; - case SF_LOOP_FORWARD : return "fwd " ; - case SF_LOOP_BACKWARD : return "back" ; - case SF_LOOP_ALTERNATING : return "alt " ; - default : break ; - } ; - - return "????" ; -} /* str_of_mode */ - -static int -instrument_dump (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo ; - SF_INSTRUMENT inst ; - int got_inst, k ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) - { printf ("Error : Not able to open input file %s.\n", filename) ; - fflush (stdout) ; - memset (data, 0, sizeof (data)) ; - puts (sf_strerror (NULL)) ; - return 1 ; - } ; - - got_inst = sf_command (file, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) ; - sf_close (file) ; - - if (got_inst == SF_FALSE) - { printf ("Error : File '%s' does not contain instrument data.\n\n", filename) ; - return 1 ; - } ; - - printf ("Instrument : %s\n\n", filename) ; - printf (" Gain : %d\n", inst.gain) ; - printf (" Base note : %d\n", inst.basenote) ; - printf (" Velocity : %d - %d\n", (int) inst.velocity_lo, (int) inst.velocity_hi) ; - printf (" Key : %d - %d\n", (int) inst.key_lo, (int) inst.key_hi) ; - printf (" Loop points : %d\n", inst.loop_count) ; - - for (k = 0 ; k < inst.loop_count ; k++) - printf (" %-2d Mode : %s Start : %6" PRIu32 " End : %6" PRIu32 - " Count : %6" PRIu32 "\n", k, str_of_type (inst.loops [k].mode), - inst.loops [k].start, inst.loops [k].end, inst.loops [k].count) ; - - putchar ('\n') ; - return 0 ; -} /* instrument_dump */ - -static int -broadcast_dump (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo ; - SF_BROADCAST_INFO_2K bext ; - double time_ref_sec ; - int got_bext ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) - { printf ("Error : Not able to open input file %s.\n", filename) ; - fflush (stdout) ; - memset (data, 0, sizeof (data)) ; - puts (sf_strerror (NULL)) ; - return 1 ; - } ; - - memset (&bext, 0, sizeof (SF_BROADCAST_INFO_2K)) ; - - got_bext = sf_command (file, SFC_GET_BROADCAST_INFO, &bext, sizeof (bext)) ; - sf_close (file) ; - - if (got_bext == SF_FALSE) - { printf ("Error : File '%s' does not contain broadcast information.\n\n", filename) ; - return 1 ; - } ; - - /* - ** From : http://www.ebu.ch/en/technical/publications/userguides/bwf_user_guide.php - ** - ** Time Reference: - ** This field is a count from midnight in samples to the first sample - ** of the audio sequence. - */ - - time_ref_sec = ((pow (2.0, 32) * bext.time_reference_high) + (1.0 * bext.time_reference_low)) / sfinfo.samplerate ; - - printf ("Description : %.*s\n", (int) sizeof (bext.description), bext.description) ; - printf ("Originator : %.*s\n", (int) sizeof (bext.originator), bext.originator) ; - printf ("Origination ref : %.*s\n", (int) sizeof (bext.originator_reference), bext.originator_reference) ; - printf ("Origination date : %.*s\n", (int) sizeof (bext.origination_date), bext.origination_date) ; - printf ("Origination time : %.*s\n", (int) sizeof (bext.origination_time), bext.origination_time) ; - - if (bext.time_reference_high == 0 && bext.time_reference_low == 0) - printf ("Time ref : 0\n") ; - else - printf ("Time ref : 0x%x%08x (%.6f seconds)\n", bext.time_reference_high, bext.time_reference_low, time_ref_sec) ; - - printf ("BWF version : %d\n", bext.version) ; - - if (bext.version >= 1) - printf ("UMID : %.*s\n", (int) sizeof (bext.umid), bext.umid) ; - - if (bext.version >= 2) - { /* 0x7fff shall be used to designate an unused value */ - /* valid range: -99.99 .. 99.99 */ - printf ("Loudness value : %6.2f LUFS\n", bext.loudness_value / 100.0) ; - /* valid range: 0.00 .. 99.99 */ - printf ("Loudness range : %6.2f LU\n", bext.loudness_range / 100.0) ; - /* valid range: -99.99 .. 99.99 */ - printf ("Max. true peak level : %6.2f dBTP\n", bext.max_true_peak_level / 100.0) ; - printf ("Max. momentary loudness : %6.2f LUFS\n", bext.max_momentary_loudness / 100.0) ; - printf ("Max. short term loudness : %6.2f LUFS\n", bext.max_shortterm_loudness / 100.0) ; - } ; - - printf ("Coding history : %.*s\n", bext.coding_history_size, bext.coding_history) ; - - return 0 ; -} /* broadcast_dump */ - -static int -chanmap_dump (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int * channel_map ; - int got_chanmap, k ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) - { printf ("Error : Not able to open input file %s.\n", filename) ; - fflush (stdout) ; - memset (data, 0, sizeof (data)) ; - puts (sf_strerror (NULL)) ; - return 1 ; - } ; - - if ((channel_map = calloc (sfinfo.channels, sizeof (int))) == NULL) - { printf ("Error : malloc failed.\n\n") ; - return 1 ; - } ; - - got_chanmap = sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map, sfinfo.channels * sizeof (int)) ; - sf_close (file) ; - - if (got_chanmap == SF_FALSE) - { printf ("Error : File '%s' does not contain channel map information.\n\n", filename) ; - free (channel_map) ; - return 1 ; - } ; - - printf ("File : %s\n\n", filename) ; - - puts (" Chan Position") ; - for (k = 0 ; k < sfinfo.channels ; k ++) - { const char * name ; - -#define CASE_NAME(x) case x : name = #x ; break ; - switch (channel_map [k]) - { CASE_NAME (SF_CHANNEL_MAP_INVALID) ; - CASE_NAME (SF_CHANNEL_MAP_MONO) ; - CASE_NAME (SF_CHANNEL_MAP_LEFT) ; - CASE_NAME (SF_CHANNEL_MAP_RIGHT) ; - CASE_NAME (SF_CHANNEL_MAP_CENTER) ; - CASE_NAME (SF_CHANNEL_MAP_FRONT_LEFT) ; - CASE_NAME (SF_CHANNEL_MAP_FRONT_RIGHT) ; - CASE_NAME (SF_CHANNEL_MAP_FRONT_CENTER) ; - CASE_NAME (SF_CHANNEL_MAP_REAR_CENTER) ; - CASE_NAME (SF_CHANNEL_MAP_REAR_LEFT) ; - CASE_NAME (SF_CHANNEL_MAP_REAR_RIGHT) ; - CASE_NAME (SF_CHANNEL_MAP_LFE) ; - CASE_NAME (SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER) ; - CASE_NAME (SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER) ; - CASE_NAME (SF_CHANNEL_MAP_SIDE_LEFT) ; - CASE_NAME (SF_CHANNEL_MAP_SIDE_RIGHT) ; - CASE_NAME (SF_CHANNEL_MAP_TOP_CENTER) ; - CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_LEFT) ; - CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_RIGHT) ; - CASE_NAME (SF_CHANNEL_MAP_TOP_FRONT_CENTER) ; - CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_LEFT) ; - CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_RIGHT) ; - CASE_NAME (SF_CHANNEL_MAP_TOP_REAR_CENTER) ; - CASE_NAME (SF_CHANNEL_MAP_MAX) ; - default : name = "default" ; - break ; - } ; - - printf (" %3d %s\n", k, name) ; - } ; - - putchar ('\n') ; - free (channel_map) ; - - return 0 ; -} /* chanmap_dump */ - -static int -cart_dump (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo ; - SF_CART_INFO_VAR (1024) cart ; - int got_cart, k ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - memset (&cart, 0, sizeof (cart)) ; - - if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) - { printf ("Error : Not able to open input file %s.\n", filename) ; - fflush (stdout) ; - memset (data, 0, sizeof (data)) ; - puts (sf_strerror (NULL)) ; - return 1 ; - } ; - - got_cart = sf_command (file, SFC_GET_CART_INFO, &cart, sizeof (cart)) ; - sf_close (file) ; - - if (got_cart == SF_FALSE) - { printf ("Error : File '%s' does not contain cart information.\n\n", filename) ; - return 1 ; - } ; - - printf ("Version : %.*s\n", (int) sizeof (cart.version), cart.version) ; - printf ("Title : %.*s\n", (int) sizeof (cart.title), cart.title) ; - printf ("Artist : %.*s\n", (int) sizeof (cart.artist), cart.artist) ; - printf ("Cut id : %.*s\n", (int) sizeof (cart.cut_id), cart.cut_id) ; - printf ("Category : %.*s\n", (int) sizeof (cart.category), cart.category) ; - printf ("Classification : %.*s\n", (int) sizeof (cart.classification), cart.classification) ; - printf ("Out cue : %.*s\n", (int) sizeof (cart.out_cue), cart.out_cue) ; - printf ("Start date : %.*s\n", (int) sizeof (cart.start_date), cart.start_date) ; - printf ("Start time : %.*s\n", (int) sizeof (cart.start_time), cart.start_time) ; - printf ("End date : %.*s\n", (int) sizeof (cart.end_date), cart.end_date) ; - printf ("End time : %.*s\n", (int) sizeof (cart.end_time), cart.end_time) ; - printf ("App id : %.*s\n", (int) sizeof (cart.producer_app_id), cart.producer_app_id) ; - printf ("App version : %.*s\n", (int) sizeof (cart.producer_app_version), cart.producer_app_version) ; - printf ("User defined : %.*s\n", (int) sizeof (cart.user_def), cart.user_def) ; - printf ("Level ref. : %d\n", cart.level_reference) ; - printf ("Post timers :\n") ; - - for (k = 0 ; k < ARRAY_LEN (cart.post_timers) ; k++) - if (cart.post_timers [k].usage [0]) - printf (" %d %.*s %d\n", k, (int) sizeof (cart.post_timers [k].usage), cart.post_timers [k].usage, cart.post_timers [k].value) ; - - printf ("Reserved : %.*s\n", (int) sizeof (cart.reserved), cart.reserved) ; - printf ("Url : %.*s\n", (int) sizeof (cart.url), cart.url) ; - printf ("Tag text : %.*s\n", cart.tag_text_size, cart.tag_text) ; - - return 0 ; -} /* cart_dump */ - -static void -total_dump (void) -{ printf ("========================================\n") ; - printf ("Total Duration : %s\n", format_duration_str (total_seconds)) ; -} /* total_dump */ diff --git a/Engine/lib/libsndfile/programs/sndfile-interleave.c b/Engine/lib/libsndfile/programs/sndfile-interleave.c deleted file mode 100644 index 2b44efb2c..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-interleave.c +++ /dev/null @@ -1,217 +0,0 @@ -/* -** Copyright (C) 2009-2015 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include -#include -#include -#include - -#include "common.h" - -#define BUFFER_LEN 4096 -#define MAX_INPUTS 16 - - -typedef struct -{ SNDFILE * infile [MAX_INPUTS] ; - SNDFILE * outfile ; - - union - { double d [BUFFER_LEN] ; - int i [BUFFER_LEN] ; - } din ; - - union - - { double d [MAX_INPUTS * BUFFER_LEN] ; - int i [MAX_INPUTS * BUFFER_LEN] ; - } dout ; - - int channels ; -} STATE ; - - -static void print_usage (void) ; -static void interleave_int (STATE * state) ; -static void interleave_double (STATE * state) ; - - -int -main (int argc, char **argv) -{ STATE *state = NULL ; - SF_INFO sfinfo ; - int k, double_merge = 0 ; - int ret = 1 ; - - if (argc < 5) - { if (argc > 1) - puts ("\nError : need at least 2 input files.") ; - print_usage () ; - goto cleanup ; - } ; - - if (strcmp (argv [argc - 2], "-o") != 0) - { puts ("\nError : second last command line parameter should be '-o'.\n") ; - print_usage () ; - goto cleanup ; - } ; - - if (argc - 3 > MAX_INPUTS) - { printf ("\nError : Cannot handle more than %d input channels.\n\n", MAX_INPUTS) ; - goto cleanup ; - } ; - - state = calloc (1, sizeof (STATE)) ; - if (state == NULL) - { puts ("\nError : out of memory.\n") ; - goto cleanup ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - for (k = 1 ; k < argc - 2 ; k++) - { - if ((state->infile [k - 1] = sf_open (argv [k], SFM_READ, &sfinfo)) == NULL) - { printf ("\nError : Not able to open input file '%s'\n%s\n", argv [k], sf_strerror (NULL)) ; - goto cleanup ; - } ; - - if (sfinfo.channels != 1) - { printf ("\bError : Input file '%s' should be mono (has %d channels).\n", argv [k], sfinfo.channels) ; - goto cleanup ; - } ; - - switch (sfinfo.format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - case SF_FORMAT_VORBIS : - double_merge = 1 ; - break ; - - default : - break ; - } ; - - state->channels ++ ; - } ; - - sfinfo.channels = state->channels ; - sfinfo.format = sfe_file_type_of_ext (argv [argc - 1], sfinfo.format) ; - - if ((state->outfile = sf_open (argv [argc - 1], SFM_WRITE, &sfinfo)) == NULL) - { printf ("Not able to open output file '%s'\n%s\n", argv [argc - 1], sf_strerror (NULL)) ; - goto cleanup ; - } ; - - if (double_merge) - interleave_double (state) ; - else - interleave_int (state) ; - - ret = 0 ; - -cleanup : - - if (state != NULL) - { for (k = 0 ; k < MAX_INPUTS ; k++) - if (state->infile [k] != NULL) - sf_close (state->infile [k]) ; - sf_close (state->outfile) ; - } - - free (state) ; - - return ret ; -} /* main */ - -/*------------------------------------------------------------------------------ -*/ - - -static void -print_usage (void) -{ puts ("\nUsage : sndfile-interleave ... -o \n") ; - puts ("Merge two or more mono files into a single multi-channel file.\n") ; - printf ("Using %s.\n\n", sf_version_string ()) ; -} /* print_usage */ - - -static void -interleave_int (STATE * state) -{ int max_read_len, read_len ; - int ch, k ; - - do - { max_read_len = 0 ; - - for (ch = 0 ; ch < state->channels ; ch ++) - { read_len = (int) sf_read_int (state->infile [ch], state->din.i, BUFFER_LEN) ; - if (read_len < BUFFER_LEN) - memset (state->din.i + read_len, 0, sizeof (state->din.i [0]) * (BUFFER_LEN - read_len)) ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - state->dout.i [k * state->channels + ch] = state->din.i [k] ; - - max_read_len = MAX (max_read_len, read_len) ; - } ; - - sf_writef_int (state->outfile, state->dout.i, max_read_len) ; - } - while (max_read_len > 0) ; - -} /* interleave_int */ - - -static void -interleave_double (STATE * state) -{ int max_read_len, read_len ; - int ch, k ; - - do - { max_read_len = 0 ; - - for (ch = 0 ; ch < state->channels ; ch ++) - { read_len = (int) sf_read_double (state->infile [ch], state->din.d, BUFFER_LEN) ; - if (read_len < BUFFER_LEN) - memset (state->din.d + read_len, 0, sizeof (state->din.d [0]) * (BUFFER_LEN - read_len)) ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - state->dout.d [k * state->channels + ch] = state->din.d [k] ; - - max_read_len = MAX (max_read_len, read_len) ; - } ; - - sf_writef_double (state->outfile, state->dout.d, max_read_len) ; - } - while (max_read_len > 0) ; - -} /* interleave_double */ diff --git a/Engine/lib/libsndfile/programs/sndfile-metadata-get.c b/Engine/lib/libsndfile/programs/sndfile-metadata-get.c deleted file mode 100644 index 9a0963803..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-metadata-get.c +++ /dev/null @@ -1,197 +0,0 @@ -/* -** Copyright (C) 2008-2014 Erik de Castro Lopo -** Copyright (C) 2008-2010 George Blood Audio -** -** 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 author nor the names of any 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. -*/ - -#include - -#include -#include -#include -#include -#include - -#include - -#include "common.h" - -#define BUFFER_LEN (1 << 16) - -static void usage_exit (const char *progname, int exit_code) ; -static void process_args (SNDFILE * file, const SF_BROADCAST_INFO_2K * binfo, int argc, char * argv []) ; - -int -main (int argc, char *argv []) -{ SNDFILE *file ; - SF_INFO sfinfo ; - SF_BROADCAST_INFO_2K binfo ; - const char *progname ; - const char * filename = NULL ; - int start ; - - /* Store the program name. */ - progname = program_name (argv [0]) ; - - /* Check if we've been asked for help. */ - if (argc < 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0) - usage_exit (progname, 0) ; - - if (argv [argc - 1][0] != '-') - { filename = argv [argc - 1] ; - start = 1 ; - } - else if (argv [1][0] != '-') - { filename = argv [1] ; - start = 2 ; - } - else - { printf ("Error : Either the first or the last command line parameter should be a filename.\n\n") ; - exit (1) ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) - { printf ("Error : Open of file '%s' failed : %s\n\n", filename, sf_strerror (file)) ; - exit (1) ; - } ; - - memset (&binfo, 0, sizeof (binfo)) ; - if (sf_command (file, SFC_GET_BROADCAST_INFO, &binfo, sizeof (binfo)) == 0) - memset (&binfo, 0, sizeof (binfo)) ; - - process_args (file, &binfo, argc - 2, argv + start) ; - - sf_close (file) ; - return 0 ; -} /* main */ - -/*============================================================================== -** Print version and usage. -*/ - -static void -usage_exit (const char *progname, int exit_code) -{ printf ("\nUsage :\n %s [options] \n\nOptions:\n", progname) ; - - puts ( - " --bext-description Print the 'bext' description.\n" - " --bext-originator Print the 'bext' originator info.\n" - " --bext-orig-ref Print the 'bext' origination reference.\n" - " --bext-umid Print the 'bext' UMID.\n" - " --bext-orig-date Print the 'bext' origination date.\n" - " --bext-orig-time Print the 'bext' origination time.\n" - " --bext-loudness-value Print the 'bext' loudness value.\n" - " --bext-loudness-range Print the 'bext' loudness range.\n" - " --bext-max-truepeak Print the 'bext' max. true peak level\n" - " --bext-max-momentary Print the 'bext' max. momentary loudness\n" - " --bext-max-shortterm Print the 'bext' max. short term loudness\n" - " --bext-coding-hist Print the 'bext' coding history.\n" - ) ; - - puts ( - " --str-title Print the title metadata.\n" - " --str-copyright Print the copyright metadata.\n" - " --str-artist Print the artist metadata.\n" - " --str-comment Print the comment metadata.\n" - " --str-date Print the creation date metadata.\n" - " --str-album Print the album metadata.\n" - " --str-license Print the license metadata.\n" - ) ; - - printf ("Using %s.\n\n", sf_version_string ()) ; - exit (exit_code) ; -} /* usage_exit */ - -static void -process_args (SNDFILE * file, const SF_BROADCAST_INFO_2K * binfo, int argc, char * argv []) -{ const char * str ; - int k, do_all = 0 ; - -#define HANDLE_BEXT_ARG(cmd, name, field) \ - if (do_all || strcmp (argv [k], cmd) == 0) \ - { printf ("%-22s : %.*s\n", name, (int) sizeof (binfo->field), binfo->field) ; \ - if (! do_all) \ - continue ; \ - } ; - -#define HANDLE_BEXT_ARG_INT(cmd, name, field) \ - if (do_all || strcmp (argv [k], cmd) == 0) \ - { printf ("%-22s : %6.2f\n", name, binfo->field / 100.0) ; \ - if (! do_all) \ - continue ; \ - } ; - -#define HANDLE_STR_ARG(cmd, name, id) \ - if (do_all || strcmp (argv [k], cmd) == 0) \ - { str = sf_get_string (file, id) ; \ - printf ("%-22s : %s\n", name, str ? str : "") ; \ - if (! do_all) continue ; \ - } ; - - if (argc == 0) - { do_all = 1 ; - argc = 1 ; - } ; - - for (k = 0 ; k < argc ; k++) - { if (do_all || strcmp (argv [k], "--all") == 0) - do_all = 1 ; - - HANDLE_BEXT_ARG ("--bext-description", "Description", description) ; - HANDLE_BEXT_ARG ("--bext-originator", "Originator", originator) ; - HANDLE_BEXT_ARG ("--bext-orig-ref", "Origination ref", originator_reference) ; - HANDLE_BEXT_ARG ("--bext-umid", "UMID", umid) ; - HANDLE_BEXT_ARG ("--bext-orig-date", "Origination date", origination_date) ; - HANDLE_BEXT_ARG ("--bext-orig-time", "Origination time", origination_time) ; - HANDLE_BEXT_ARG_INT ("--bext-loudness-value", "Loudness value", loudness_value) ; - HANDLE_BEXT_ARG_INT ("--bext-loudness-range", "Loudness range", loudness_range) ; - HANDLE_BEXT_ARG_INT ("--bext-max-truepeak", "Max. true peak level", max_true_peak_level) ; - HANDLE_BEXT_ARG_INT ("--bext-max-momentary", "Max. momentary level", max_momentary_loudness) ; - HANDLE_BEXT_ARG_INT ("--bext-max-shortterm", "Max. short term level", max_shortterm_loudness) ; - HANDLE_BEXT_ARG ("--bext-coding-hist", "Coding history", coding_history) ; - - HANDLE_STR_ARG ("--str-title", "Name", SF_STR_TITLE) ; - HANDLE_STR_ARG ("--str-copyright", "Copyright", SF_STR_COPYRIGHT) ; - HANDLE_STR_ARG ("--str-artist", "Artist", SF_STR_ARTIST) ; - HANDLE_STR_ARG ("--str-comment", "Comment", SF_STR_COMMENT) ; - HANDLE_STR_ARG ("--str-date", "Create date", SF_STR_DATE) ; - HANDLE_STR_ARG ("--str-album", "Album", SF_STR_ALBUM) ; - HANDLE_STR_ARG ("--str-license", "License", SF_STR_LICENSE) ; - - if (! do_all) - { printf ("Error : Don't know what to do with command line arg '%s'.\n\n", argv [k]) ; - exit (1) ; - } ; - break ; - } ; - - return ; -} /* process_args */ diff --git a/Engine/lib/libsndfile/programs/sndfile-metadata-set.c b/Engine/lib/libsndfile/programs/sndfile-metadata-set.c deleted file mode 100644 index 33c793998..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-metadata-set.c +++ /dev/null @@ -1,298 +0,0 @@ -/* -** Copyright (C) 2008-2016 Erik de Castro Lopo -** Copyright (C) 2008-2010 George Blood Audio -** -** 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 author nor the names of any 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. -*/ - -#include - -#include -#include -#include -#include -#include - -#include - -#include "common.h" - -#define BUFFER_LEN (1 << 16) - - -static void usage_exit (const char *progname, int exit_code) ; -static void missing_param (const char * option) ; -static void read_localtime (struct tm * timedata) ; -static int has_bext_fields_set (const METADATA_INFO * info) ; - -int -main (int argc, char *argv []) -{ METADATA_INFO info ; - struct tm timedata ; - const char *progname ; - const char * filenames [2] = { NULL, NULL } ; - char date [128], time [128] ; - int k ; - - /* Store the program name. */ - progname = program_name (argv [0]) ; - - /* Check if we've been asked for help. */ - if (argc < 3 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0) - usage_exit (progname, 0) ; - - /* Set all fields of the struct to zero bytes. */ - memset (&info, 0, sizeof (info)) ; - - /* Get the time in case we need it later. */ - read_localtime (&timedata) ; - - for (k = 1 ; k < argc ; k++) - { if (argv [k][0] != '-') - { if (filenames [0] == NULL) - filenames [0] = argv [k] ; - else if (filenames [1] == NULL) - filenames [1] = argv [k] ; - else - { printf ("Error : Already have two file names on the command line and then found '%s'.\n\n", argv [k]) ; - usage_exit (progname, 1) ; - } ; - continue ; - } ; - -#define HANDLE_BEXT_ARG(cmd, field) \ - if (strcmp (argv [k], cmd) == 0) \ - { k ++ ; \ - if (k == argc) missing_param (argv [k - 1]) ; \ - info.field = argv [k] ; \ - continue ; \ - } ; - - HANDLE_BEXT_ARG ("--bext-description", description) ; - HANDLE_BEXT_ARG ("--bext-originator", originator) ; - HANDLE_BEXT_ARG ("--bext-orig-ref", originator_reference) ; - HANDLE_BEXT_ARG ("--bext-umid", umid) ; - HANDLE_BEXT_ARG ("--bext-orig-date", origination_date) ; - HANDLE_BEXT_ARG ("--bext-orig-time", origination_time) ; - HANDLE_BEXT_ARG ("--bext-loudness-value", loudness_value) ; - HANDLE_BEXT_ARG ("--bext-loudness-range", loudness_range) ; - HANDLE_BEXT_ARG ("--bext-max-truepeak", max_true_peak_level) ; - HANDLE_BEXT_ARG ("--bext-max-momentary", max_momentary_loudness) ; - HANDLE_BEXT_ARG ("--bext-max-shortterm", max_shortterm_loudness) ; - HANDLE_BEXT_ARG ("--bext-coding-hist", coding_history) ; - HANDLE_BEXT_ARG ("--bext-time-ref", time_ref) ; - -#define HANDLE_STR_ARG(cmd, field) \ - if (strcmp (argv [k], cmd) == 0) \ - { k ++ ; \ - if (k == argc) missing_param (argv [k - 1]) ; \ - info.field = argv [k] ; \ - continue ; \ - } ; - - HANDLE_STR_ARG ("--str-comment", comment) ; - HANDLE_STR_ARG ("--str-title", title) ; - HANDLE_STR_ARG ("--str-copyright", copyright) ; - HANDLE_STR_ARG ("--str-artist", artist) ; - HANDLE_STR_ARG ("--str-date", date) ; - HANDLE_STR_ARG ("--str-album", album) ; - HANDLE_STR_ARG ("--str-license", license) ; - - /* Following options do not take an argument. */ - if (strcmp (argv [k], "--bext-auto-time-date") == 0) - { snprintf (time, sizeof (time), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ; - info.origination_time = time ; - - snprintf (date, sizeof (date), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ; - info.origination_date = date ; - continue ; - } ; - - if (strcmp (argv [k], "--bext-auto-time") == 0) - { snprintf (time, sizeof (time), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ; - info.origination_time = time ; - continue ; - } ; - - if (strcmp (argv [k], "--bext-auto-date") == 0) - { snprintf (date, sizeof (date), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ; - info.origination_date = strdup (date) ; - continue ; - } ; - - if (strcmp (argv [k], "--str-auto-date") == 0) - { snprintf (date, sizeof (date), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ; - - info.date = strdup (date) ; - continue ; - } ; - - printf ("Error : Don't know what to do with command line arg '%s'.\n\n", argv [k]) ; - usage_exit (progname, 1) ; - } ; - - /* Find out if any of the 'bext' fields are set. */ - info.has_bext_fields = has_bext_fields_set (&info) ; - - if (filenames [0] == NULL) - { printf ("Error : No input file specificed.\n\n") ; - exit (1) ; - } ; - - if (filenames [1] != NULL && strcmp (filenames [0], filenames [1]) == 0) - { printf ("Error : Input and output files are the same.\n\n") ; - exit (1) ; - } ; - - if (info.coding_history != NULL && filenames [1] == NULL) - { printf ("\n" - "Error : Trying to update coding history of an existing file which unfortunately\n" - " is not supported. Instead, create a new file using :\n" - "\n" - " %s --bext-coding-hist \"Coding history\" old_file.wav new_file.wav\n" - "\n", - progname) ; - exit (1) ; - } ; - - sfe_apply_metadata_changes (filenames, &info) ; - - return 0 ; -} /* main */ - -/*============================================================================== -** Print version and usage. -*/ - -static void -usage_exit (const char *progname, int exit_code) -{ printf ("\nUsage :\n\n" - " %s [options] \n" - " %s [options] \n" - "\n", - progname, progname) ; - - puts ( - "Where an option is made up of a pair of a field to set (one of\n" - "the 'bext' or metadata fields below) and a string. Fields are\n" - "as follows :\n" - ) ; - - puts ( - " --bext-description Set the 'bext' description.\n" - " --bext-originator Set the 'bext' originator.\n" - " --bext-orig-ref Set the 'bext' originator reference.\n" - " --bext-umid Set the 'bext' UMID.\n" - " --bext-orig-date Set the 'bext' origination date.\n" - " --bext-orig-time Set the 'bext' origination time.\n" - " --bext-loudness-value Set the 'bext' loudness value.\n" - " --bext-loudness-range Set the 'bext' loudness range.\n" - " --bext-max-truepeak Set the 'bext' max. true peak level\n" - " --bext-max-momentary Set the 'bext' max. momentary loudness\n" - " --bext-max-shortterm Set the 'bext' max. short term loudness\n" - " --bext-coding-hist Set the 'bext' coding history.\n" - " --bext-time-ref Set the 'bext' Time ref.\n" - "\n" - " --str-comment Set the metadata comment.\n" - " --str-title Set the metadata title.\n" - " --str-copyright Set the metadata copyright.\n" - " --str-artist Set the metadata artist.\n" - " --str-date Set the metadata date.\n" - " --str-album Set the metadata album.\n" - " --str-license Set the metadata license.\n" - ) ; - - puts ( - "There are also the following arguments which do not take a\n" - "parameter :\n\n" - " --bext-auto-time-date Set the 'bext' time and date to current time/date.\n" - " --bext-auto-time Set the 'bext' time to current time.\n" - " --bext-auto-date Set the 'bext' date to current date.\n" - " --str-auto-date Set the metadata date to current date.\n" - ) ; - - puts ( - "Most of the above operations can be done in-place on an existing\n" - "file. If any operation cannot be performed, the application will\n" - "exit with an appropriate error message.\n" - ) ; - - printf ("Using %s.\n\n", sf_version_string ()) ; - exit (exit_code) ; -} /* usage_exit */ - -static void -missing_param (const char * option) -{ - printf ("Error : Option '%s' needs a parameter but doesn't seem to have one.\n\n", option) ; - exit (1) ; -} /* missing_param */ - -/*============================================================================== -*/ - -static int -has_bext_fields_set (const METADATA_INFO * info) -{ - if (info->description || info->originator || info->originator_reference) - return 1 ; - - if (info->origination_date || info->origination_time || info->umid || info->coding_history || info->time_ref) - return 1 ; - - if (info->loudness_value || info->loudness_range || info->max_true_peak_level || info->max_momentary_loudness || info->max_shortterm_loudness) - return 1 ; - - return 0 ; -} /* has_bext_fields_set */ - -static void -read_localtime (struct tm * timedata) -{ time_t current ; - - time (¤t) ; - memset (timedata, 0, sizeof (struct tm)) ; - -#if defined (_WIN32) - /* If the re-entrant version is available, use it. */ - localtime_s (timedata, ¤t) ; -#elif defined (HAVE_LOCALTIME_R) - /* If the re-entrant version is available, use it. */ - localtime_r (¤t, timedata) ; -#elif defined (HAVE_LOCALTIME) - { - struct tm *tmptr ; - /* Otherwise use the standard one and copy the data to local storage. */ - if ((tmptr = localtime (¤t)) != NULL) - memcpy (timedata, tmptr, sizeof (struct tm)) ; - } -#endif - - return ; -} /* read_localtime */ diff --git a/Engine/lib/libsndfile/programs/sndfile-play.c b/Engine/lib/libsndfile/programs/sndfile-play.c deleted file mode 100644 index 48b95c133..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-play.c +++ /dev/null @@ -1,860 +0,0 @@ -/* -** Copyright (C) 1999-2018 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "common.h" - -#if HAVE_ALSA_ASOUNDLIB_H - #define ALSA_PCM_NEW_HW_PARAMS_API - #define ALSA_PCM_NEW_SW_PARAMS_API - #include - #include -#endif - -#if defined (__ANDROID__) - -#elif defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__) - #include - #include - #include - -#elif HAVE_SNDIO_H - #include - -#elif (defined (sun) && defined (unix)) || defined(__NetBSD__) - #include - #include - #include - -#elif (OS_IS_WIN32 == 1) - #include - #include - -#endif - -#define SIGNED_SIZEOF(x) ((int) sizeof (x)) -#define BUFFER_LEN (2048) - -/*------------------------------------------------------------------------------ -** Linux/OSS functions for playing a sound. -*/ - -#if HAVE_ALSA_ASOUNDLIB_H - -static snd_pcm_t * alsa_open (int channels, unsigned srate, int realtime) ; -static int alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels) ; - -static void -alsa_play (int argc, char *argv []) -{ static float buffer [BUFFER_LEN] ; - SNDFILE *sndfile ; - SF_INFO sfinfo ; - snd_pcm_t * alsa_dev ; - int k, readcount, subformat ; - - for (k = 1 ; k < argc ; k++) - { memset (&sfinfo, 0, sizeof (sfinfo)) ; - - printf ("Playing %s\n", argv [k]) ; - if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo))) - { puts (sf_strerror (NULL)) ; - continue ; - } ; - - if (sfinfo.channels < 1 || sfinfo.channels > 2) - { printf ("Error : channels = %d.\n", sfinfo.channels) ; - continue ; - } ; - - if ((alsa_dev = alsa_open (sfinfo.channels, (unsigned) sfinfo.samplerate, SF_FALSE)) == NULL) - continue ; - - subformat = sfinfo.format & SF_FORMAT_SUBMASK ; - - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - { double scale ; - int m ; - - sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ; - if (scale > 1.0) - scale = 1.0 / scale ; - else - scale = 1.0 ; - - while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN))) - { for (m = 0 ; m < readcount ; m++) - buffer [m] *= scale ; - alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ; - } ; - } - else - { while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN))) - alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ; - } ; - - snd_pcm_drain (alsa_dev) ; - snd_pcm_close (alsa_dev) ; - - sf_close (sndfile) ; - } ; - - return ; -} /* alsa_play */ - -static snd_pcm_t * -alsa_open (int channels, unsigned samplerate, int realtime) -{ const char * device = "default" ; - snd_pcm_t *alsa_dev = NULL ; - snd_pcm_hw_params_t *hw_params ; - snd_pcm_uframes_t buffer_size ; - snd_pcm_uframes_t alsa_period_size, alsa_buffer_frames ; - snd_pcm_sw_params_t *sw_params ; - - int err ; - - if (realtime) - { alsa_period_size = 256 ; - alsa_buffer_frames = 3 * alsa_period_size ; - } - else - { alsa_period_size = 1024 ; - alsa_buffer_frames = 4 * alsa_period_size ; - } ; - - if ((err = snd_pcm_open (&alsa_dev, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) - { fprintf (stderr, "cannot open audio device \"%s\" (%s)\n", device, snd_strerror (err)) ; - goto catch_error ; - } ; - - snd_pcm_nonblock (alsa_dev, 0) ; - - if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) - { fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_hw_params_any (alsa_dev, hw_params)) < 0) - { fprintf (stderr, "cannot initialize hardware parameter structure (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_hw_params_set_access (alsa_dev, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) - { fprintf (stderr, "cannot set access type (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_hw_params_set_format (alsa_dev, hw_params, SND_PCM_FORMAT_FLOAT)) < 0) - { fprintf (stderr, "cannot set sample format (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_hw_params_set_rate_near (alsa_dev, hw_params, &samplerate, 0)) < 0) - { fprintf (stderr, "cannot set sample rate (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_hw_params_set_channels (alsa_dev, hw_params, channels)) < 0) - { fprintf (stderr, "cannot set channel count (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_hw_params_set_buffer_size_near (alsa_dev, hw_params, &alsa_buffer_frames)) < 0) - { fprintf (stderr, "cannot set buffer size (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_hw_params_set_period_size_near (alsa_dev, hw_params, &alsa_period_size, 0)) < 0) - { fprintf (stderr, "cannot set period size (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_hw_params (alsa_dev, hw_params)) < 0) - { fprintf (stderr, "cannot set parameters (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - /* extra check: if we have only one period, this code won't work */ - snd_pcm_hw_params_get_period_size (hw_params, &alsa_period_size, 0) ; - snd_pcm_hw_params_get_buffer_size (hw_params, &buffer_size) ; - if (alsa_period_size == buffer_size) - { fprintf (stderr, "Can't use period equal to buffer size (%lu == %lu)", alsa_period_size, buffer_size) ; - goto catch_error ; - } ; - - snd_pcm_hw_params_free (hw_params) ; - - if ((err = snd_pcm_sw_params_malloc (&sw_params)) != 0) - { fprintf (stderr, "%s: snd_pcm_sw_params_malloc: %s", __func__, snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_sw_params_current (alsa_dev, sw_params)) != 0) - { fprintf (stderr, "%s: snd_pcm_sw_params_current: %s", __func__, snd_strerror (err)) ; - goto catch_error ; - } ; - - /* note: set start threshold to delay start until the ring buffer is full */ - snd_pcm_sw_params_current (alsa_dev, sw_params) ; - - if ((err = snd_pcm_sw_params_set_start_threshold (alsa_dev, sw_params, buffer_size)) < 0) - { fprintf (stderr, "cannot set start threshold (%s)\n", snd_strerror (err)) ; - goto catch_error ; - } ; - - if ((err = snd_pcm_sw_params (alsa_dev, sw_params)) != 0) - { fprintf (stderr, "%s: snd_pcm_sw_params: %s", __func__, snd_strerror (err)) ; - goto catch_error ; - } ; - - snd_pcm_sw_params_free (sw_params) ; - - snd_pcm_reset (alsa_dev) ; - -catch_error : - - if (err < 0 && alsa_dev != NULL) - { snd_pcm_close (alsa_dev) ; - return NULL ; - } ; - - return alsa_dev ; -} /* alsa_open */ - -static int -alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels) -{ static int epipe_count = 0 ; - - int total = 0 ; - int retval ; - - if (epipe_count > 0) - epipe_count -- ; - - while (total < frames) - { retval = snd_pcm_writei (alsa_dev, data + total * channels, frames - total) ; - - if (retval >= 0) - { total += retval ; - if (total == frames) - return total ; - - continue ; - } ; - - switch (retval) - { case -EAGAIN : - puts ("alsa_write_float: EAGAIN") ; - continue ; - break ; - - case -EPIPE : - if (epipe_count > 0) - { printf ("alsa_write_float: EPIPE %d\n", epipe_count) ; - if (epipe_count > 140) - return retval ; - } ; - epipe_count += 100 ; - -#if 0 - if (0) - { snd_pcm_status_t *status ; - - snd_pcm_status_alloca (&status) ; - if ((retval = snd_pcm_status (alsa_dev, status)) < 0) - fprintf (stderr, "alsa_out: xrun. can't determine length\n") ; - else if (snd_pcm_status_get_state (status) == SND_PCM_STATE_XRUN) - { struct timeval now, diff, tstamp ; - - gettimeofday (&now, 0) ; - snd_pcm_status_get_trigger_tstamp (status, &tstamp) ; - timersub (&now, &tstamp, &diff) ; - - fprintf (stderr, "alsa_write_float xrun: of at least %.3f msecs. resetting stream\n", - diff.tv_sec * 1000 + diff.tv_usec / 1000.0) ; - } - else - fprintf (stderr, "alsa_write_float: xrun. can't determine length\n") ; - } ; -#endif - - snd_pcm_prepare (alsa_dev) ; - break ; - - case -EBADFD : - fprintf (stderr, "alsa_write_float: Bad PCM state.n") ; - return 0 ; - break ; - -#if defined ESTRPIPE && ESTRPIPE != EPIPE - case -ESTRPIPE : - fprintf (stderr, "alsa_write_float: Suspend event.n") ; - return 0 ; - break ; -#endif - - case -EIO : - puts ("alsa_write_float: EIO") ; - return 0 ; - - default : - fprintf (stderr, "alsa_write_float: retval = %d\n", retval) ; - return 0 ; - break ; - } ; /* switch */ - } ; /* while */ - - return total ; -} /* alsa_write_float */ - -#endif /* HAVE_ALSA_ASOUNDLIB_H */ - -/*------------------------------------------------------------------------------ -** Linux/OSS functions for playing a sound. -*/ - -#if !defined (__ANDROID__) && (defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__)) - -static int opensoundsys_open_device (int channels, int srate) ; - -static int -opensoundsys_play (int argc, char *argv []) -{ static short buffer [BUFFER_LEN] ; - SNDFILE *sndfile ; - SF_INFO sfinfo ; - int k, audio_device, readcount, writecount, subformat ; - - for (k = 1 ; k < argc ; k++) - { memset (&sfinfo, 0, sizeof (sfinfo)) ; - - printf ("Playing %s\n", argv [k]) ; - if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo))) - { puts (sf_strerror (NULL)) ; - continue ; - } ; - - if (sfinfo.channels < 1 || sfinfo.channels > 2) - { printf ("Error : channels = %d.\n", sfinfo.channels) ; - continue ; - } ; - - audio_device = opensoundsys_open_device (sfinfo.channels, sfinfo.samplerate) ; - - subformat = sfinfo.format & SF_FORMAT_SUBMASK ; - - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - { static float float_buffer [BUFFER_LEN] ; - double scale ; - int m ; - - sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ; - if (scale < 1e-10) - scale = 1.0 ; - else - scale = 32700.0 / scale ; - - while ((readcount = sf_read_float (sndfile, float_buffer, BUFFER_LEN))) - { for (m = 0 ; m < readcount ; m++) - buffer [m] = scale * float_buffer [m] ; - writecount = write (audio_device, buffer, readcount * sizeof (short)) ; - } ; - } - else - { while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN))) - writecount = write (audio_device, buffer, readcount * sizeof (short)) ; - } ; - - if (ioctl (audio_device, SNDCTL_DSP_POST, 0) == -1) - perror ("ioctl (SNDCTL_DSP_POST) ") ; - - if (ioctl (audio_device, SNDCTL_DSP_SYNC, 0) == -1) - perror ("ioctl (SNDCTL_DSP_SYNC) ") ; - - close (audio_device) ; - - sf_close (sndfile) ; - } ; - - return writecount ; -} /* opensoundsys_play */ - -static int -opensoundsys_open_device (int channels, int srate) -{ int fd, stereo, fmt ; - - if ((fd = open ("/dev/dsp", O_WRONLY, 0)) == -1 && - (fd = open ("/dev/sound/dsp", O_WRONLY, 0)) == -1) - { perror ("opensoundsys_open_device : open ") ; - exit (1) ; - } ; - - stereo = 0 ; - if (ioctl (fd, SNDCTL_DSP_STEREO, &stereo) == -1) - { /* Fatal error */ - perror ("opensoundsys_open_device : stereo ") ; - exit (1) ; - } ; - - if (ioctl (fd, SNDCTL_DSP_RESET, 0)) - { perror ("opensoundsys_open_device : reset ") ; - exit (1) ; - } ; - - fmt = CPU_IS_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE ; - if (ioctl (fd, SNDCTL_DSP_SETFMT, &fmt) != 0) - { perror ("opensoundsys_open_device : set format ") ; - exit (1) ; - } ; - - if (ioctl (fd, SNDCTL_DSP_CHANNELS, &channels) != 0) - { perror ("opensoundsys_open_device : channels ") ; - exit (1) ; - } ; - - if (ioctl (fd, SNDCTL_DSP_SPEED, &srate) != 0) - { perror ("opensoundsys_open_device : sample rate ") ; - exit (1) ; - } ; - - if (ioctl (fd, SNDCTL_DSP_SYNC, 0) != 0) - { perror ("opensoundsys_open_device : sync ") ; - exit (1) ; - } ; - - return fd ; -} /* opensoundsys_open_device */ - -#endif /* __linux__ */ - -/*------------------------------------------------------------------------------ -** Mac OS X functions for playing a sound. -*/ - -/* MacOSX 10.8 use a new Audio API. Someone needs to write some code for it. */ - -/*------------------------------------------------------------------------------ -** Win32 functions for playing a sound. -** -** This API sucks. Its needlessly complicated and is *WAY* too loose with -** passing pointers around in integers and using char* pointers to -** point to data instead of short*. It plain sucks! -*/ - -#if (OS_IS_WIN32 == 1) - -#define WIN32_BUFFER_LEN (1 << 15) - -typedef struct -{ HWAVEOUT hwave ; - WAVEHDR whdr [2] ; - - CRITICAL_SECTION mutex ; /* to control access to BuffersInUSe */ - HANDLE Event ; /* signal that a buffer is free */ - - short buffer [WIN32_BUFFER_LEN / sizeof (short)] ; - int current, bufferlen ; - int BuffersInUse ; - - SNDFILE *sndfile ; - SF_INFO sfinfo ; - - sf_count_t remaining ; -} Win32_Audio_Data ; - - -static void -win32_play_data (Win32_Audio_Data *audio_data) -{ int thisread, readcount ; - - /* fill a buffer if there is more data and we can read it sucessfully */ - readcount = (audio_data->remaining > audio_data->bufferlen) ? audio_data->bufferlen : (int) audio_data->remaining ; - - short *lpData = (short *) (void *) audio_data->whdr [audio_data->current].lpData ; - thisread = (int) sf_read_short (audio_data->sndfile, lpData, readcount) ; - - audio_data->remaining -= thisread ; - - if (thisread > 0) - { /* Fix buffer length if this is only a partial block. */ - if (thisread < audio_data->bufferlen) - audio_data->whdr [audio_data->current].dwBufferLength = thisread * sizeof (short) ; - - /* Queue the WAVEHDR */ - waveOutWrite (audio_data->hwave, (LPWAVEHDR) &(audio_data->whdr [audio_data->current]), sizeof (WAVEHDR)) ; - - /* count another buffer in use */ - EnterCriticalSection (&audio_data->mutex) ; - audio_data->BuffersInUse ++ ; - LeaveCriticalSection (&audio_data->mutex) ; - - /* use the other buffer next time */ - audio_data->current = (audio_data->current + 1) % 2 ; - } ; - - return ; -} /* win32_play_data */ - -static void CALLBACK -win32_audio_out_callback (HWAVEOUT hwave, UINT msg, DWORD_PTR data, DWORD param1, DWORD param2) -{ Win32_Audio_Data *audio_data ; - - /* Prevent compiler warnings. */ - (void) hwave ; - (void) param1 ; - (void) param2 ; - - if (data == 0) - return ; - - /* - ** I consider this technique of passing a pointer via an integer as - ** fundamentally broken but thats the way microsoft has defined the - ** interface. - */ - audio_data = (Win32_Audio_Data*) data ; - - /* let main loop know a buffer is free */ - if (msg == MM_WOM_DONE) - { EnterCriticalSection (&audio_data->mutex) ; - audio_data->BuffersInUse -- ; - LeaveCriticalSection (&audio_data->mutex) ; - SetEvent (audio_data->Event) ; - } ; - - return ; -} /* win32_audio_out_callback */ - -static void -win32_play (int argc, char *argv []) -{ Win32_Audio_Data audio_data ; - - WAVEFORMATEX wf ; - int k, error ; - - audio_data.sndfile = NULL ; - audio_data.hwave = 0 ; - - for (k = 1 ; k < argc ; k++) - { printf ("Playing %s\n", argv [k]) ; - - if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo)))) - { puts (sf_strerror (NULL)) ; - continue ; - } ; - - audio_data.remaining = audio_data.sfinfo.frames * audio_data.sfinfo.channels ; - audio_data.current = 0 ; - - InitializeCriticalSection (&audio_data.mutex) ; - audio_data.Event = CreateEvent (0, FALSE, FALSE, 0) ; - - wf.nChannels = audio_data.sfinfo.channels ; - wf.wFormatTag = WAVE_FORMAT_PCM ; - wf.cbSize = 0 ; - wf.wBitsPerSample = 16 ; - - wf.nSamplesPerSec = audio_data.sfinfo.samplerate ; - - wf.nBlockAlign = audio_data.sfinfo.channels * sizeof (short) ; - - wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec ; - - error = waveOutOpen (&(audio_data.hwave), WAVE_MAPPER, &wf, (DWORD_PTR) win32_audio_out_callback, - (DWORD_PTR) &audio_data, CALLBACK_FUNCTION) ; - if (error) - { puts ("waveOutOpen failed.") ; - audio_data.hwave = 0 ; - continue ; - } ; - - audio_data.whdr [0].lpData = (char*) audio_data.buffer ; - audio_data.whdr [1].lpData = ((char*) audio_data.buffer) + sizeof (audio_data.buffer) / 2 ; - - audio_data.whdr [0].dwBufferLength = sizeof (audio_data.buffer) / 2 ; - audio_data.whdr [1].dwBufferLength = sizeof (audio_data.buffer) / 2 ; - - audio_data.whdr [0].dwFlags = 0 ; - audio_data.whdr [1].dwFlags = 0 ; - - /* length of each audio buffer in samples */ - audio_data.bufferlen = sizeof (audio_data.buffer) / 2 / sizeof (short) ; - - /* Prepare the WAVEHDRs */ - if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)))) - { printf ("waveOutPrepareHeader [0] failed : %08X\n", error) ; - waveOutClose (audio_data.hwave) ; - continue ; - } ; - - if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR)))) - { printf ("waveOutPrepareHeader [1] failed : %08X\n", error) ; - waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ; - waveOutClose (audio_data.hwave) ; - continue ; - } ; - - /* Fill up both buffers with audio data */ - audio_data.BuffersInUse = 0 ; - win32_play_data (&audio_data) ; - win32_play_data (&audio_data) ; - - /* loop until both buffers are released */ - while (audio_data.BuffersInUse > 0) - { - /* wait for buffer to be released */ - WaitForSingleObject (audio_data.Event, INFINITE) ; - - /* refill the buffer if there is more data to play */ - win32_play_data (&audio_data) ; - } ; - - waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ; - waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR)) ; - - waveOutClose (audio_data.hwave) ; - audio_data.hwave = 0 ; - - DeleteCriticalSection (&audio_data.mutex) ; - - sf_close (audio_data.sndfile) ; - } ; - -} /* win32_play */ - -#endif /* Win32 */ - -/*------------------------------------------------------------------------------ -** OpenBSD's sndio. -*/ - -#if HAVE_SNDIO_H - -static void -sndio_play (int argc, char *argv []) -{ struct sio_hdl *hdl ; - struct sio_par par ; - short buffer [BUFFER_LEN] ; - SNDFILE *sndfile ; - SF_INFO sfinfo ; - int k, readcount ; - - for (k = 1 ; k < argc ; k++) - { printf ("Playing %s\n", argv [k]) ; - if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo))) - { puts (sf_strerror (NULL)) ; - continue ; - } ; - - if (sfinfo.channels < 1 || sfinfo.channels > 2) - { printf ("Error : channels = %d.\n", sfinfo.channels) ; - continue ; - } ; - - if ((hdl = sio_open (NULL, SIO_PLAY, 0)) == NULL) - { fprintf (stderr, "open sndio device failed") ; - return ; - } ; - - sio_initpar (&par) ; - par.rate = sfinfo.samplerate ; - par.pchan = sfinfo.channels ; - par.bits = 16 ; - par.sig = 1 ; - par.le = SIO_LE_NATIVE ; - - if (! sio_setpar (hdl, &par) || ! sio_getpar (hdl, &par)) - { fprintf (stderr, "set sndio params failed") ; - return ; - } ; - - if (! sio_start (hdl)) - { fprintf (stderr, "sndio start failed") ; - return ; - } ; - - while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN))) - sio_write (hdl, buffer, readcount * sizeof (short)) ; - - sio_close (hdl) ; - } ; - - return ; -} /* sndio_play */ - -#endif /* sndio */ - -/*------------------------------------------------------------------------------ -** Solaris. -*/ - -#if (defined (sun) && defined (unix)) || defined(__NetBSD__) - -static void -solaris_play (int argc, char *argv []) -{ static short buffer [BUFFER_LEN] ; - audio_info_t audio_info ; - SNDFILE *sndfile ; - SF_INFO sfinfo ; - unsigned long delay_time ; - long k, start_count, output_count, write_count, read_count ; - int audio_fd, error, done ; - - for (k = 1 ; k < argc ; k++) - { printf ("Playing %s\n", argv [k]) ; - if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo))) - { puts (sf_strerror (NULL)) ; - continue ; - } ; - - if (sfinfo.channels < 1 || sfinfo.channels > 2) - { printf ("Error : channels = %d.\n", sfinfo.channels) ; - continue ; - } ; - - /* open the audio device - write only, non-blocking */ - if ((audio_fd = open ("/dev/audio", O_WRONLY | O_NONBLOCK)) < 0) - { perror ("open (/dev/audio) failed") ; - return ; - } ; - - /* Retrive standard values. */ - AUDIO_INITINFO (&audio_info) ; - - audio_info.play.sample_rate = sfinfo.samplerate ; - audio_info.play.channels = sfinfo.channels ; - audio_info.play.precision = 16 ; - audio_info.play.encoding = AUDIO_ENCODING_LINEAR ; - - if ((error = ioctl (audio_fd, AUDIO_SETINFO, &audio_info))) - { perror ("ioctl (AUDIO_SETINFO) failed") ; - return ; - } ; - - /* Delay time equal to 1/4 of a buffer in microseconds. */ - delay_time = (BUFFER_LEN * 1000000) / (audio_info.play.sample_rate * 4) ; - - done = 0 ; - while (! done) - { read_count = sf_read_short (sndfile, buffer, BUFFER_LEN) ; - if (read_count < BUFFER_LEN) - { memset (&(buffer [read_count]), 0, (BUFFER_LEN - read_count) * sizeof (short)) ; - /* Tell the main application to terminate. */ - done = SF_TRUE ; - } ; - - start_count = 0 ; - output_count = BUFFER_LEN * sizeof (short) ; - - while (output_count > 0) - { /* write as much data as possible */ - write_count = write (audio_fd, &(buffer [start_count]), output_count) ; - if (write_count > 0) - { output_count -= write_count ; - start_count += write_count ; - } - else - { /* Give the audio output time to catch up. */ - usleep (delay_time) ; - } ; - } ; /* while (outpur_count > 0) */ - } ; /* while (! done) */ - - close (audio_fd) ; - } ; - - return ; -} /* solaris_play */ - -#endif /* Solaris or NetBSD */ - -/*============================================================================== -** Main function. -*/ - -int -main (int argc, char *argv []) -{ - if (argc < 2) - { - printf ("\nUsage : %s \n\n", program_name (argv [0])) ; - printf ("Using %s.\n\n", sf_version_string ()) ; -#if (OS_IS_WIN32 == 1) - printf ("This is a Unix style command line application which\n" - "should be run in a MSDOS box or Command Shell window.\n\n") ; - printf ("Sleeping for 5 seconds before exiting.\n\n") ; - - Sleep (5 * 1000) ; -#endif - return 1 ; - } ; - -#if defined (__ANDROID__) - puts ("*** Playing sound not yet supported on Android.") ; - puts ("*** Please feel free to submit a patch.") ; - return 1 ; -#elif defined (__linux__) - #if HAVE_ALSA_ASOUNDLIB_H - if (access ("/proc/asound/cards", R_OK) == 0) - alsa_play (argc, argv) ; - else - #endif - opensoundsys_play (argc, argv) ; -#elif defined (__FreeBSD_kernel__) || defined (__FreeBSD__) || defined (__riscos__) - opensoundsys_play (argc, argv) ; -#elif HAVE_SNDIO_H - sndio_play (argc, argv) ; -#elif (defined (sun) && defined (unix)) || defined(__NetBSD__) - solaris_play (argc, argv) ; -#elif (OS_IS_WIN32 == 1) - win32_play (argc, argv) ; -#else - puts ("*** Playing sound not supported on this platform.") ; - puts ("*** Please feel free to submit a patch.") ; - return 1 ; -#endif - - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/programs/sndfile-salvage.c b/Engine/lib/libsndfile/programs/sndfile-salvage.c deleted file mode 100644 index 1a76dc3aa..000000000 --- a/Engine/lib/libsndfile/programs/sndfile-salvage.c +++ /dev/null @@ -1,302 +0,0 @@ -/* -** Copyright (C) 2010-2014 Erik de Castro Lopo -** -** 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 author nor the names of any 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. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif -#include -#include -#include - -#include - -#include "common.h" - -#define BUFFER_LEN (1 << 16) - -#define NOT(x) (! (x)) - -#ifndef _WIN32 -typedef off_t sf_off_t ; -#else -typedef long long sf_off_t ; -#endif - - -static void usage_exit (const char *progname) ; -static void salvage_file (const char * broken_wav, const char * fixed_w64) ; - -int -main (int argc, char *argv []) -{ - if (argc != 3) - usage_exit (program_name (argv [0])) ; - - salvage_file (argv [1], argv [2]) ; - - return 0 ; -} /* main */ - -/*============================================================================== -*/ - -static void lseek_or_die (int fd, sf_off_t offset, int whence) ; -static sf_off_t get_file_length (int fd, const char * name) ; -static sf_count_t find_data_offset (int fd, int format) ; -static void copy_data (int fd, SNDFILE * sndfile, int readsize) ; - - -static void -usage_exit (const char *progname) -{ printf ("Usage :\n\n %s \n\n", progname) ; - puts ("Salvages the audio data from WAV files which are more than 4G in length.\n") ; - printf ("Using %s.\n\n", sf_version_string ()) ; - exit (1) ; -} /* usage_exit */ - -static void -salvage_file (const char * broken_wav, const char * fixed_w64) -{ SNDFILE * sndfile ; - SF_INFO sfinfo ; - sf_count_t broken_len, data_offset ; - int fd, read_size ; - - if (strcmp (broken_wav, fixed_w64) == 0) - { printf ("Error : Input and output files must be different.\n\n") ; - exit (1) ; - } ; - - if ((fd = open (broken_wav, O_RDONLY)) < 0) - { printf ("Error : Not able to open file '%s' : %s\n", broken_wav, strerror (errno)) ; - exit (1) ; - } ; - - broken_len = get_file_length (fd, broken_wav) ; - if (broken_len <= 0xffffffff) - printf ("File is not greater than 4Gig but salvaging anyway.\n") ; - - /* Grab the format info from the broken file. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - if ((sndfile = sf_open (broken_wav, SFM_READ, &sfinfo)) == NULL) - { printf ("sf_open ('%s') failed : %s\n", broken_wav, sf_strerror (NULL)) ; - exit (1) ; - } ; - sf_close (sndfile) ; - - data_offset = find_data_offset (fd, sfinfo.format & SF_FORMAT_TYPEMASK) ; - - printf ("Offset to audio data : %" PRId64 "\n", data_offset) ; - - switch (sfinfo.format & SF_FORMAT_TYPEMASK) - { case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : - sfinfo.format = SF_FORMAT_W64 | (sfinfo.format & SF_FORMAT_SUBMASK) ; - break ; - - default : - printf ("Don't currently support this file type.\n") ; - exit (1) ; - } ; - - switch (sfinfo.format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_S8 : - read_size = 1 ; - break ; - - case SF_FORMAT_PCM_16 : - read_size = 2 ; - break ; - - case SF_FORMAT_PCM_24 : - read_size = 3 ; - break ; - - case SF_FORMAT_PCM_32 : - case SF_FORMAT_FLOAT : - read_size = 4 ; - break ; - - case SF_FORMAT_DOUBLE : - read_size = 8 ; - break ; - - default : - printf ("Sorry, don't currently support this file encoding type.\n") ; - exit (1) ; - } ; - - read_size *= sfinfo.channels ; - - if ((sndfile = sf_open (fixed_w64, SFM_WRITE, &sfinfo)) == NULL) - { printf ("sf_open ('%s') failed : %s\n", fixed_w64, sf_strerror (NULL)) ; - exit (1) ; - } ; - - lseek_or_die (fd, data_offset, SEEK_SET) ; - - copy_data (fd, sndfile, read_size) ; - - sf_close (sndfile) ; - - puts ("Done!") ; -} /* salvage_file */ - -/*------------------------------------------------------------------------------ -*/ - -static void -lseek_or_die (int fd, sf_off_t offset, int whence) -{ -#ifndef _WIN32 - if (lseek (fd, offset, whence) < 0) -#else - if (_lseeki64 (fd, offset, whence) < 0) -#endif - { printf ("lseek failed : %s\n", strerror (errno)) ; - exit (1) ; - } ; - - return ; -} /* lseek_or_die */ - - -static sf_off_t -get_file_length (int fd, const char * name) -{ -#ifndef _WIN32 - struct stat sbuf ; -#else - struct _stat64 sbuf ; -#endif - - if (sizeof (sbuf.st_size) != 8) - { puts ("Error : sizeof (sbuf.st_size) != 8. Was program compiled with\n" - " 64 bit file offsets?\n") ; - exit (1) ; - } ; - -#ifndef _WIN32 - if (fstat (fd, &sbuf) != 0) -#else - if (_fstat64 (fd, &sbuf) != 0) -#endif - { printf ("Error : fstat ('%s') failed : %s\n", name, strerror (errno)) ; - exit (1) ; - } ; - - return sbuf.st_size ; -} /* get_file_length */ - -static sf_count_t -find_data_offset (int fd, int format) -{ char buffer [8192], *cptr ; - const char * target = "XXXX" ; - sf_count_t offset = -1, extra ; - int rlen, slen ; - - switch (format) - { case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : - target = "data" ; - extra = 8 ; - break ; - - case SF_FORMAT_AIFF : - target = "SSND" ; - extra = 16 ; - break ; - - default : - puts ("Error : Sorry, don't handle this input file format.\n") ; - exit (1) ; - } ; - - slen = (int) strlen (target) ; - - lseek_or_die (fd, 0, SEEK_SET) ; - - printf ("Searching for '%s' maker.\n", target) ; - - if ((rlen = read (fd, buffer, sizeof (buffer))) < 0) - { printf ("Error : failed read : %s\n", strerror (errno)) ; - exit (1) ; - } ; - - cptr = memchr (buffer, target [0], rlen - slen) ; - if (cptr && memcmp (cptr, target, slen) == 0) - offset = cptr - buffer ; - else - { printf ("Error : Could not find data offset.\n") ; - exit (1) ; - } ; - - return offset + extra ; -} /* find_data_offset */ - -static void -copy_data (int fd, SNDFILE * sndfile, int readsize) -{ static char * buffer ; - sf_count_t readlen, count ; - int bufferlen, done = 0 ; - - bufferlen = readsize * 1024 ; - buffer = malloc (bufferlen) ; - - while (NOT (done) && (readlen = read (fd, buffer, bufferlen)) >= 0) - { if (readlen < bufferlen) - { readlen -= readlen % readsize ; - done = 1 ; - } ; - - if ((count = sf_write_raw (sndfile, buffer, readlen)) != readlen) - { printf ("Error : sf_write_raw returned %" PRId64 " : %s\n", count, sf_strerror (sndfile)) ; - return ; - } ; - } ; - - free (buffer) ; - - return ; -} /* copy_data */ - diff --git a/Engine/lib/libsndfile/programs/test-sndfile-metadata-set.py b/Engine/lib/libsndfile/programs/test-sndfile-metadata-set.py deleted file mode 100644 index 0006936ce..000000000 --- a/Engine/lib/libsndfile/programs/test-sndfile-metadata-set.py +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2008-2016 Erik de Castro Lopo -# -# 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 author nor the names of any 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. - -# Simple test script for the sndfile-metadata-set program. - -from __future__ import print_function - -try: - # py2 - import commands -except ImportError: - # py3 - import subprocess as commands - -import os, sys -import time, datetime - -class Programs: - def __init__ (self, needs_exe): - if needs_exe: - extension = ".exe" - else: - extension = "" - self.meta_set_prog = "./sndfile-metadata-set" + extension - self.meta_get_prog = "./sndfile-metadata-get" + extension - self.make_sine_prog = "../examples/make_sine" + extension - - def _run_command (self, should_fail, cmd): - status, output = commands.getstatusoutput (cmd) - if should_fail and not status: - print("\n\nError : command '%s' should have failed." % cmd) - print(output) - print() - sys.exit (1) - if not should_fail and status: - print("\n\nError : command '%s' should not have failed." % cmd) - print(output) - print() - sys.exit (1) - return output - - def meta_set (self, should_fail, args): - return self._run_command (should_fail, self.meta_set_prog + " " + args) - - def meta_get (self, should_fail, args): - return self._run_command (should_fail, self.meta_get_prog + " " + args) - - def make_sine (self): - return os.system (self.make_sine_prog) - - def check_executables (self): - for name in [ self.meta_set_prog, self.meta_get_prog, self.make_sine_prog ]: - if not (os.path.isfile (name)): - print("\n\nError : Can't find executable '%s'. Have you run make?" % name) - sys.exit (1) - - -def print_test_name (name): - print(" %-30s :" % name, end="") - -def assert_info (programs, filename, arg, value): - output = programs.meta_get (False, "%s %s" % (arg, filename)) - if output.find (value) < 0: - print("\n\nError : not able to find '%s'." % value) - print(output) - sys.exit (1) - return - - -def test_empty_fail (programs): - print_test_name ("Empty fail test") - output = programs.meta_set (True, "--bext-description Alpha sine.wav") - print("ok") - -def test_copy (programs): - print_test_name ("Copy test") - output = programs.meta_set (False, "--bext-description \"First Try\" sine.wav output.wav") - assert_info (programs, "output.wav", "--bext-description", "First Try") - print("ok") - -def test_update (programs, tests): - print_test_name ("Update test") - for arg, value in tests: - output = programs.meta_set (False, "%s \"%s\" output.wav" % (arg, value)) - assert_info (programs, "output.wav", arg, value) - print("ok") - -def test_post_mod (programs, tests): - print_test_name ("Post mod test") - for arg, value in tests: - assert_info (programs, "output.wav", arg, value) - print("ok") - -def test_auto_date (programs): - print_test_name ("Auto date test") - output = programs.meta_set (False, "--bext-auto-time-date sine.wav date-time.wav") - target = datetime.date.today ().__str__ () - assert_info (programs, "date-time.wav", "--bext-orig-date", target) - print("ok") - - -#------------------------------------------------------------------------------- - -def test_coding_history (programs): - print_test_name ("Coding history test") - output = programs.meta_set (False, "--bext-coding-hist \"alpha beta\" output.wav") - output = programs.meta_get (False, "--bext-coding-hist output.wav") - print("ok") - -#------------------------------------------------------------------------------- - -def test_rewrite (programs): - print_test_name ("Rewrite test") - output = programs.meta_set (False, "--bext-originator \"Really, really long string\" output.wav") - output = programs.meta_set (False, "--bext-originator \"Short\" output.wav") - output = programs.meta_get (False, "--bext-originator output.wav") - if output.find ("really long") > 0: - print("\n\nError : output '%s' should not contain 'really long'." % output) - sys.exit (1) - print("ok") - -#=============================================================================== - -test_dir = "programs" - -print("\nTesting WAV metadata manipulation:") - -if os.path.isdir (test_dir): - os.chdir (test_dir) - -if len (sys.argv) >= 1 and sys.argv [1].endswith ("mingw32"): - needs_exe = True -else: - needs_exe = False - -programs = Programs (needs_exe) - -programs.check_executables () - -programs.make_sine () -if not os.path.isfile ("sine.wav"): - print("\n\nError : Can't file file 'sine.wav'.") - sys.exit (1) - -test_empty_fail (programs) -test_copy (programs) - -tests = [ - ("--bext-description", "Alpha"), ("--bext-originator", "Beta"), ("--bext-orig-ref", "Charlie"), - ("--bext-umid", "Delta"), ("--bext-orig-date", "2001-10-01"), ("--bext-orig-time", "01:02:03"), - ("--str-title", "Echo"), ("--str-artist", "Fox trot") - ] - -test_auto_date (programs) -test_update (programs, tests) -test_post_mod (programs, tests) - -test_update (programs, [ ("--str-artist", "Fox") ]) - -# This never worked. -# test_coding_history () - -test_rewrite (programs) - - -print() - -sys.exit (0) - diff --git a/Engine/lib/libsndfile/regtest/Readme.txt b/Engine/lib/libsndfile/regtest/Readme.txt deleted file mode 100644 index bc038d642..000000000 --- a/Engine/lib/libsndfile/regtest/Readme.txt +++ /dev/null @@ -1,108 +0,0 @@ -sndfile-regtest -=============== - -The 'sndfile-regtest' program is a regression test-suite for libsndile. - -This program is intended to allow anyone who has an interest in the -reliability and correctness of libsndfile to do their own regression -testing. From the point of view of the libsndfile developers, this -program now allows for distributed regression testing of libsndfile -which will make libsndfile better. - - -How Does it Work ----------------- -Anyone who wishes to take part in the distributed regression testing of -libsndfile can download the regression test program and install it. - -Once installed the user can start collecting files and adding them to -their own personal database. Then, as new versions of libsndfile come -out, the user should test the new library version against their database -of files (instructions below). - -Any files which were successfully added to the database in the past but -now fail the check with the new library version represent a regression. -The user should then contact the libsndfile developers so that a copy -of the test file can be made available to the developers. - - -Requirements ------------- -The regression test program uses sqlite3 as the database engine. On -Debian, the required packages are : - - sqlite3 - libsqlite3-0 - libsqlite3-dev - -but similar packages should be available on any other Linux style -system. - -The regression test currently only compiles under Unix-like systems. -At some time in the future the regression test will distributed along -with the libsndfile source code distribution. - - -Organization of Files ---------------------- -The regession test program keeps its database file in the directory it -is run from. In addition, the database only contains information about -the files, not the files themselves. - -This means that database file should probably be kept in the same -directory (or a directory above) the test files. - - -Setting it Up for the First Time --------------------------------- -The sndfile-regtest program should be on your PATH. You can then cd into -the directory where you intend to keep you test files and -run the command: - - sndfile-regtest --create-db - -which creates a file named '.sndfile-regtest.db' in the current directory. - -Files can then be added to the database using the command: - - sndfile-regtest --add-file file1.wav - -The --add-file option allows more than one file to be added at a time -using: - - sndfile-regtest --add-file file1.wav file2.aif ..... - - -Checking Files --------------- -One or more files that have already been added to the database can be -checked using: - - sndfile-regtest --check-file file1.wav file2.aif ..... - -It is also possible to check all files in the database using: - - sndfile-regtest --check-all - - -Running a Regression Test -------------------------- -Once you have a collection of files and a database it is possible to test -new versions of libsndfile before you install them. If for instance you -have just compiled a new version of libsndfile in the directory -/usr/src/libsndfile-X.Y.Z, then you can use an existing sndfile-regtest -binary with the new libsndfile using something like: - - LD_PRELOAD=/usr/src/libsndfile-X.Y.Z/src/.libs/libsndfile.so.X.Y.Z \ - sndfile-regtest --check-all - - -Reporting Regressions ---------------------- -Any user who finds a file which was added to the regression database with -an earlier version of libsndfile and then fails the check with a later -version of the library should contact the author (erikd at mega dash nerd -dot com). If possible place the file on a web server and email the author -a link to it. - - diff --git a/Engine/lib/libsndfile/regtest/checksum.c b/Engine/lib/libsndfile/regtest/checksum.c deleted file mode 100644 index 5714144fd..000000000 --- a/Engine/lib/libsndfile/regtest/checksum.c +++ /dev/null @@ -1,117 +0,0 @@ -/* -** Copyright (C) 2005-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* -** A simple checksum for short, int and float data. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include - -#include "regtest.h" - -#define BIG_PRIME 999983 - -#define ARRAY_LEN(x) ((int) (sizeof (x)) / (sizeof ((x) [0]))) - -static int short_checksum (SNDFILE * file, int start) ; -static int int_checksum (SNDFILE * file, int start) ; -static int float_checksum (SNDFILE * file, int start) ; - -int -calc_checksum (SNDFILE * file, const SF_INFO * info) -{ int start ; - - /* Seed the checksum with data from the SF_INFO struct. */ - start = info->samplerate ; - start = start * BIG_PRIME + info->channels ; - start = start * BIG_PRIME + info->format ; - - switch (info->format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - return float_checksum (file, start) ; - - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - return int_checksum (file, start) ; - - default : - return short_checksum (file, start) ; - } ; - - return 0 ; -} /* calc_checksum */ - -/*------------------------------------------------------------------------------ -*/ - -static union -{ short s [1 << 16] ; - int i [1 << 15] ; - float f [1 << 15] ; -} data ; - -static int -short_checksum (SNDFILE * file, int start) -{ int k, count ; - - do - { count = (int) sf_read_short (file, data.s, ARRAY_LEN (data.s)) ; - for (k = 0 ; k < count ; k++) - start = start * BIG_PRIME + data.s [k] ; - } - while (count > 0) ; - - return start ; -} /* short_checksum */ - -static int -int_checksum (SNDFILE * file, int start) -{ int k, count ; - - do - { count = (int) sf_read_int (file, data.i, ARRAY_LEN (data.i)) ; - for (k = 0 ; k < count ; k++) - start = start * BIG_PRIME + data.i [k] ; - } - while (count > 0) ; - - return start ; -} /* int_checksum */ - -static int -float_checksum (SNDFILE * file, int start) -{ int k, count ; - - do - { count = (int) sf_read_float (file, data.f, ARRAY_LEN (data.f)) ; - for (k = 0 ; k < count ; k++) - start = start * BIG_PRIME + lrintf (2147483648.0f * data.f [k]) ; - } - while (count > 0) ; - - return start ; -} /* float_checksum */ - diff --git a/Engine/lib/libsndfile/regtest/database.c b/Engine/lib/libsndfile/regtest/database.c deleted file mode 100644 index 1f4c8d7bf..000000000 --- a/Engine/lib/libsndfile/regtest/database.c +++ /dev/null @@ -1,542 +0,0 @@ -/* -** Copyright (C) 2005-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "config.h" - -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif -#include -#include -#ifdef HAVE_DIRECT_H -#include -#endif -#include - -#include - -#include "regtest.h" - -#if HAVE_SQLITE3 - -#include -#include - -typedef struct -{ sqlite3 *sql ; - - int count ; - int ekey_max ; - - /* Filename and pathname for file. */ - char filename [256] ; - char pathname [512] ; - - /* Storage for createding SQL commands. Must be larger than logbuf below. */ - char cmdbuf [1 << 15] ; - - /* Storage for log buffer retrieved from SNDFILE* .*/ - char logbuf [1 << 14] ; - -} REGTEST_DB ; - -/* In checksum.c */ -int calc_checksum (SNDFILE * file, const SF_INFO * info) ; - -static void get_filename_pathname (REGTEST_DB * db, const char *filepath) ; -static void single_quote_replace (char * buf) ; - -static int get_ekey_from_filename (REGTEST_DB * db, const char *filepath) ; -static int get_filename_pathname_by_ekey (REGTEST_DB * db, int ekey) ; -static int check_file_by_ekey (REGTEST_DB * db, int ekey) ; - -static int count_callback (REGTEST_DB * db, int argc, char **argv, char **colname) ; -static int ekey_max_callback (REGTEST_DB * db, int argc, char **argv, char **colname) ; -static int callback (void *unused, int argc, char **argv, char **colname) ; -static const char *db_basename (const char *fname); - -/* Windows accepts both '\\' and '/' in paths */ -#ifdef _WIN32 - #define IS_SLASH(c) ((c) == '\\' || (c) == '/') - #define HAS_DRIVELETTER(path) (isalpha ((int)(path[0])) && path[1] == ':' && IS_SLASH(path[2])) -#else - #define IS_SLASH(c) ((c) == '/') - #define HAS_DRIVELETTER(path) 0 -#endif - -REG_DB * -db_open (const char * db_name) -{ REGTEST_DB * db ; - int err ; - - if ((db = malloc (sizeof (REGTEST_DB))) == NULL) - { perror ("malloc") ; - exit (1) ; - } ; - - if ((err = sqlite3_open (db_name, &(db->sql))) != 0) - { printf ("Can't open database: %s\n", sqlite3_errmsg (db->sql)) ; - sqlite3_close (db->sql) ; - free (db) ; - exit (1) ; - } ; - - return (REG_DB *) db ; -} /* db_open */ - -int -db_create (const char * db_name) -{ REGTEST_DB * db ; - const char *cmd ; - char * errmsg = NULL ; - int err ; - - db = (REGTEST_DB *) db_open (db_name) ; - - cmd = "create table sndfile (ekey INTEGER PRIMARY KEY," - "fname VARCHAR(1)," - "fpath VARCHAR(1)," - "srate INTEGER," - "frames VARCHAR(1)," - "channels INTEGER," - "format VARCHAR(1)," - "checksum VARCHAR(1)," - "logbuf VARCHAR(1)" - ");" ; - - err = sqlite3_exec (db->sql, cmd, callback, 0, &errmsg) ; - if (err != SQLITE_OK) - printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; - - sqlite3_close (db->sql) ; - free (db) ; - - return 0 ; -} /* db_create */ - -int -db_close (REG_DB * db_handle) -{ REGTEST_DB * db ; - - db = (REGTEST_DB *) db_handle ; - - sqlite3_close (db->sql) ; - free (db) ; - - return 0 ; -} /* db_close */ - -/*============================================================================== -*/ - -int -db_file_exists (REG_DB * db_handle, const char * filename) -{ REGTEST_DB * db ; - char * errmsg ; - int err ; - - db = (REGTEST_DB *) db_handle ; - - filename = db_basename (filename); - - snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select fname from sndfile where fname='%s'", filename) ; - - db->count = 0 ; - err = sqlite3_exec (db->sql, db->cmdbuf, (sqlite3_callback) count_callback, db, &errmsg) ; - if (err == 0 && db->count == 1) - return 1 ; - - return 0 ; -} /* db_file_exists */ - -int -db_add_file (REG_DB * db_handle, const char * filepath) -{ REGTEST_DB * db ; - SNDFILE * sndfile ; - SF_INFO info ; - char * errmsg ; - int err, checksum ; - - db = (REGTEST_DB *) db_handle ; - - get_filename_pathname (db, filepath) ; - - if (db_file_exists (db_handle, filepath)) - { printf (" %s : already in database\n", db->filename) ; - return 0 ; - } ; - - memset (&info, 0, sizeof (info)) ; - sndfile = sf_open (db->pathname, SFM_READ, &info) ; - sf_command (sndfile, SFC_GET_LOG_INFO, db->logbuf, sizeof (db->logbuf)) ; - checksum = (sndfile == NULL) ? 0 : calc_checksum (sndfile, &info) ; - sf_close (sndfile) ; - - if (sndfile == NULL) - { printf (" %s : could not open : %s, filepath: '%s'\n", db->filename, sf_strerror (NULL), filepath) ; - puts (db->logbuf) ; - return 1 ; - } ; - - single_quote_replace (db->logbuf) ; - - snprintf (db->cmdbuf, sizeof (db->cmdbuf), "insert into sndfile " - "(fname, fpath, srate, frames, channels, format, checksum, logbuf) values" - "('%s','%s',%d,'%ld', %d, '0x%08x', '0x%08x', '%s');", - db->filename, db->pathname, info.samplerate, (long) info.frames, info.channels, info.format, checksum, db->logbuf) ; - - if (strlen (db->cmdbuf) >= sizeof (db->cmdbuf) - 1) - { printf ("strlen (db->cmdbuf) too long.\n") ; - exit (1) ; - } ; - - err = sqlite3_exec (db->sql, db->cmdbuf, callback, 0, &errmsg) ; - if (err != SQLITE_OK) - { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; - puts (db->cmdbuf) ; - } ; - - return 0 ; -} /* db_add_file */ - -int -db_check_file (REG_DB * db_handle, const char * filepath) -{ REGTEST_DB * db ; - int ekey ; - - if (db_file_exists (db_handle, filepath) == 0) - { printf ("\nFile not in database.\n\n") ; - exit (0) ; - } ; - - db = (REGTEST_DB *) db_handle ; - - ekey = get_ekey_from_filename (db, filepath) ; - - return check_file_by_ekey (db, ekey) ; -} /* db_check_file */ - -/*============================================================================== -*/ - -int -db_check_all (REG_DB * db_handle) -{ REGTEST_DB * db ; - char * errmsg ; - int err, ekey ; - - db = (REGTEST_DB *) db_handle ; - - db->ekey_max = 0 ; - - snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select ekey from sndfile") ; - - err = sqlite3_exec (db->sql, db->cmdbuf, (sqlite3_callback) ekey_max_callback, db, &errmsg) ; - if (err != SQLITE_OK) - { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; - puts (db->cmdbuf) ; - } ; - - for (ekey = 1 ; ekey <= db->ekey_max ; ekey++) - if (get_filename_pathname_by_ekey (db, ekey) != 0) - check_file_by_ekey (db, ekey) ; - - return 0 ; -} /* db_check_all */ - - -int -db_list_all (REG_DB * db_handle) -{ - printf ("%s : %p\n", __func__, (void *) db_handle) ; - return 0 ; -} /* db_list_all */ - -int -db_del_entry (REG_DB * db_handle, const char * entry) -{ - printf ("%s : %p %s\n", __func__, (void *) db_handle, entry) ; - return 0 ; -} /* db_del_entry */ - -/*============================================================================== -*/ - -static int -get_ekey_from_filename (REGTEST_DB * db, const char *filepath) -{ char * errmsg, **result ; - int err, ekey = 0, rows, cols ; - - get_filename_pathname (db, filepath) ; - - snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select ekey from sndfile where fname='%s'", db->filename) ; - - err = sqlite3_get_table (db->sql, db->cmdbuf, &result, &rows, &cols, &errmsg) ; - if (err != SQLITE_OK) - { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; - puts (db->cmdbuf) ; - } ; - - if (cols != 1 || rows != 1) - { printf ("Bad juju!! rows = %d cols = %d\n", rows, cols) ; - exit (1) ; - } ; - - ekey = strtol (result [1], NULL, 10) ; - - sqlite3_free_table (result) ; - - return ekey ; -} /* get_ekey_from_filename */ - -static int -get_filename_pathname_by_ekey (REGTEST_DB * db, int ekey) -{ char *errmsg, **result ; - int err, rows, cols ; - - snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select fname,fpath from sndfile where ekey='%d'", ekey) ; - - err = sqlite3_get_table (db->sql, db->cmdbuf, &result, &rows, &cols, &errmsg) ; - if (err != SQLITE_OK) - { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; - puts (db->cmdbuf) ; - return 0 ; - } ; - - if (cols != 2 || rows != 1) - { printf ("\nError (%s %d) : rows = %d cols = %d\n", __func__, __LINE__, rows, cols) ; - exit (1) ; - } ; - - snprintf (db->filename, sizeof (db->filename), "%s", result [2]) ; - snprintf (db->pathname, sizeof (db->pathname), "%s", result [3]) ; - - sqlite3_free_table (result) ; - - return 1 ; -} /* get_filename_pathname_by_ekey */ - -static int -check_file_by_ekey (REGTEST_DB * db, int ekey) -{ SNDFILE * sndfile ; - SF_INFO info ; - char * errmsg, **result ; - int err, k, rows, cols, checksum ; - - printf (" %s : ", db->filename) ; - fflush (stdout) ; - - memset (&info, 0, sizeof (info)) ; - sndfile = sf_open (db->pathname, SFM_READ, &info) ; - sf_command (sndfile, SFC_GET_LOG_INFO, db->logbuf, sizeof (db->logbuf)) ; - checksum = (sndfile == NULL) ? 0 : calc_checksum (sndfile, &info) ; - sf_close (sndfile) ; - - if (sndfile == NULL) - { printf ("\n\nError : Could not open '%s' : %s\n", db->pathname, sf_strerror (NULL)) ; - puts (db->logbuf) ; - exit (1) ; - } ; - - single_quote_replace (db->logbuf) ; - - snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select fname,srate,frames,channels,format," - "checksum,logbuf from sndfile where ekey='%d'", ekey) ; - - err = sqlite3_get_table (db->sql, db->cmdbuf, &result, &rows, &cols, &errmsg) ; - if (err != SQLITE_OK) - { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; - puts (db->cmdbuf) ; - } ; - - for (k = 0 ; k < cols ; k++) - { if (strcmp (result [k], "fname") == 0) - { if (strcmp (result [k + cols], db->filename) == 0) - continue ; - printf ("\n\nError : fname doesn't match : %s != %s\n", result [k + cols], db->filename) ; - } ; - - if (strcmp (result [k], "srate") == 0) - { if (strtol (result [k + cols], NULL, 10) == info.samplerate) - continue ; - printf ("\n\nError : srate doesn't match : %s == %d\n", result [k + cols], info.samplerate) ; - } ; - - if (strcmp (result [k], "frames") == 0) - { if (strtoll (result [k + cols], NULL, 10) == info.frames) - continue ; - printf ("\n\nError : frames doesn't match : %s == %ld\n", result [k + cols], (long) info.frames) ; - } ; - - if (strcmp (result [k], "channels") == 0) - { if (strtol (result [k + cols], NULL, 10) == info.channels) - continue ; - printf ("\n\nError : channels doesn't match : %s == %d\n", result [k + cols], info.channels) ; - } ; - - if (strcmp (result [k], "format") == 0) - { if (strtol (result [k + cols], NULL, 16) == info.format) - continue ; - printf ("\n\nError : format doesn't match : %s == 0x%08x\n", result [k + cols], info.format) ; - } ; - - if (strcmp (result [k], "checksum") == 0) - { int db_val = (int) strtoll (result [k + cols], NULL, 16) ; - - if (db_val == checksum) - continue ; - printf ("\n\nError : checksum doesn't match : 0x%08x == 0x%08x\n", db_val, checksum) ; - } ; - - if (strcmp (result [k], "logbuf") == 0) - continue ; - - printf ("\nHere is the old logubuffer :\n\n%s\n\nand the new :\n\n%s\n\n", result [2 * cols - 1], db->logbuf) ; - exit (1) ; - } ; - - sqlite3_free_table (result) ; - - puts ("ok") ; - - return 0 ; -} /* check_file_by_ekey */ - -/*============================================================================== -*/ - -static void -get_filename_pathname (REGTEST_DB * db, const char *filepath) -{ - const char * basename = db_basename (filepath) ; - size_t slen ; - - /* Test for a relative path - */ - if (!IS_SLASH(filepath [0]) && !HAS_DRIVELETTER(filepath)) - { memset (db->pathname, 0, sizeof (db->pathname)) ; - if (getcwd (db->pathname, sizeof (db->pathname)) == NULL) - { perror ("\ngetcwd failed") ; - exit (1) ; - } ; - - slen = strlen (db->pathname) ; - /* a '/' is fine for Windows too */ - snprintf (db->pathname + slen, sizeof (db->pathname) - slen, "/%s", filepath) ; - } - else - snprintf (db->pathname, sizeof (db->pathname), "%s", filepath) ; - - snprintf (db->filename, sizeof (db->filename), "%s", basename) ; - - basename = db_basename (db->pathname) ; - if (basename == db->pathname) - { printf ("\nError : bad pathname %s\n", filepath) ; - exit (1) ; - } ; -} /* get filename_pathname */ - -static void -single_quote_replace (char * buf) -{ while ((buf = strchr (buf, '\'')) != 0) - buf [0] = '"' ; -} /* single_quote_replace */ - -static int -count_callback (REGTEST_DB * db, int argc, char **argv, char **colname) -{ db->count ++ ; - - (void) argc ; - (void) argv ; - (void) colname ; - return 0 ; -} /* count_callback */ - -static int -ekey_max_callback (REGTEST_DB * db, int argc, char **argv, char **unused) -{ int ekey ; - - (void) argc ; - (void) unused ; - - ekey = strtol (argv [0], NULL, 10) ; - if (ekey > db->ekey_max) - db->ekey_max = ekey ; - - return 0 ; -} /* ekey_max_callback */ - -static int -callback (void *unused, int argc, char **argv, char **colname) -{ int k ; - - (void) unused ; - - for (k = 0 ; k < argc ; k++) - printf ("%s = %s\n", colname [k], argv [k] ? argv [k] : "NULL") ; - - printf ("\n") ; - - return 0 ; -} /* callback */ - -/* - * Win32: Strip drive-letter and directory from a filename. - * non-Win32: Strip directory from a filename. - */ -static const char *db_basename (const char *fname) -{ - const char *base = fname; - -#if !defined(_WIN32) - const char *slash = strrchr (base, '/'); - - if (slash) - base = slash + 1 ; -#else - if (fname[0] && fname[1] == ':') { - fname += 2; - base = fname; - } - while (*fname) { - if (IS_SLASH(*fname)) - base = fname + 1; - fname++; - } -#endif - return base ; -} - -#else - -int dummy (void) ; - -int -dummy (void) -{ /* - ** Empty dummy fnction so tha compiler doesn't winge about an - ** empty file. - */ - return 0 ; -} /* dummy */ - -#endif diff --git a/Engine/lib/libsndfile/regtest/regtest.h b/Engine/lib/libsndfile/regtest/regtest.h deleted file mode 100644 index 567d97be2..000000000 --- a/Engine/lib/libsndfile/regtest/regtest.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -** Copyright (C) 2005-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -typedef struct REG_DB_tag REG_DB ; - -/* In database.c */ -REG_DB * db_open (const char * db_name) ; - -int db_create (const char * dbname) ; - -int db_close (REG_DB * db_handle) ; - -int db_file_exists (REG_DB * db_handle, const char * filename) ; -int db_add_file (REG_DB * db_handle, const char * filename) ; -int db_check_file (REG_DB * db_handle, const char * filename) ; - -int db_list_all (REG_DB * db_handle) ; -int db_check_all (REG_DB * db_handle) ; -int db_del_entry (REG_DB * db_handle, const char * entry) ; - -/* In checksum.c */ -int calc_checksum (SNDFILE * file, const SF_INFO * info) ; - diff --git a/Engine/lib/libsndfile/regtest/sndfile-regtest.c b/Engine/lib/libsndfile/regtest/sndfile-regtest.c deleted file mode 100644 index a28caa2d8..000000000 --- a/Engine/lib/libsndfile/regtest/sndfile-regtest.c +++ /dev/null @@ -1,121 +0,0 @@ -/* -** Copyright (C) 2005-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "config.h" - -#include -#include -#include - -#include - -#if HAVE_SQLITE3 - -#include "regtest.h" - -enum -{ OPT_ADD_FILE = 0x0100, - OPT_CREATE_DB = 0x0200, - OPT_DEL_ENTRY = 0x0400, - OPT_LIST_ALL = 0x0800, - OPT_TEST_ALL = 0x1000, - OPT_VERBOSE = 0x2000 -} ; - -static void print_libsndfile_version (void) ; - -int -main (int argc, char * argv []) -{ const char *db_name = "./.sndfile-regtest.db" ; - REG_DB *reg_db ; - int k, retval ; - - if (argc < 2) - { printf ("\nUsage message goes here.\n\n") ; - exit (0) ; - } ; - - if (argc == 2 && strcmp (argv [1], "--create-db") == 0) - return db_create (db_name) ; - - reg_db = db_open (db_name) ; - - if (argc == 2) - { if (strcmp (argv [1], "--list-all") == 0) - return db_list_all (reg_db) ; - - if (strcmp (argv [1], "--check-all") == 0) - { print_libsndfile_version () ; - retval = db_check_all (reg_db) ; - puts ("\nDone.\n") ; - return retval ; - } ; - } ; - - if (argc == 3 && strcmp (argv [1], "--del-entry") == 0) - { db_del_entry (reg_db, argv [2]) ; - db_close (reg_db) ; - return 0 ; - } ; - - if (strcmp (argv [1], "--check-file") == 0) - { print_libsndfile_version () ; - - for (k = 2 ; k < argc ; k++) - db_check_file (reg_db, argv [k]) ; - db_close (reg_db) ; - return 0 ; - } ; - - if (strcmp (argv [1], "--add-file") == 0) - { print_libsndfile_version () ; - - for (k = 2 ; k < argc ; k++) - db_add_file (reg_db, argv [k]) ; - db_close (reg_db) ; - return 0 ; - } ; - - printf ("\nError : unhandled command line args :") ; - for (k = 1 ; k < argc ; k++) - printf (" %s", argv [k]) ; - puts ("\n") ; - - return 1 ; -} /* main */ - -static void -print_libsndfile_version (void) -{ char version [64] ; - - sf_command (NULL, SFC_GET_LIB_VERSION, version, sizeof (version)) ; - printf ("\nsndfile-regtest : using %s\n\n", version) ; -} /* print_lib_version */ - -#else - -int -main (void) -{ - puts ("\nThis program was not compiled with libsqlite3 and hence doesn't work.\n") ; - - return 0 ; -} /* main */ - -#endif - diff --git a/Engine/lib/libsndfile/sndfile.pc.in b/Engine/lib/libsndfile/sndfile.pc.in deleted file mode 100644 index 6b8845373..000000000 --- a/Engine/lib/libsndfile/sndfile.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: sndfile -Description: A library for reading and writing audio files -Requires: -Requires.private: @EXTERNAL_XIPH_REQUIRE@ @EXTERNAL_MPEG_REQUIRE@ -Version: @VERSION@ -Libs: -L${libdir} -lsndfile -Libs.private: @EXTERNAL_MPEG_LIBS@ -Cflags: -I${includedir} diff --git a/Engine/lib/libsndfile/src/ALAC/ALACAudioTypes.h b/Engine/lib/libsndfile/src/ALAC/ALACAudioTypes.h deleted file mode 100644 index 52d3f44a0..000000000 --- a/Engine/lib/libsndfile/src/ALAC/ALACAudioTypes.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: ALACAudioTypes.h -*/ - -#ifndef ALACAUDIOTYPES_H -#define ALACAUDIOTYPES_H - -/* Force these Mac OS specific things to zero. */ -#define PRAGMA_STRUCT_ALIGN 0 -#define PRAGMA_STRUCT_PACKPUSH 0 -#define PRAGMA_STRUCT_PACK 0 -#define PRAGMA_ONCE 0 -#define PRAGMA_MARK 0 - - -#if PRAGMA_ONCE -#pragma once -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include "sfendian.h" - -#if CPU_IS_BIG_ENDIAN == 1 -#define TARGET_RT_BIG_ENDIAN 1 -#else -#define TARGET_RT_BIG_ENDIAN 0 -#endif - -#define kChannelAtomSize 12 - -enum -{ - kALAC_UnimplementedError = -4, - kALAC_FileNotFoundError = -43, - kALAC_ParamError = -50, - kALAC_MemFullError = -108, - fALAC_FrameLengthError = -666, - - /* Add for libsndfile */ - kALAC_BadBitWidth = -0x100000, - kALAC_IncompatibleVersion = -0x100001, - kALAC_BadSpecificConfigSize = -0x100002, - kALAC_ZeroChannelCount = -0x100003, - kALAC_NumSamplesTooBig = -0x100004, - kALAC_UnsupportedElement = -0x100005, -} ; - -enum -{ - kALACFormatAppleLossless = MAKE_MARKER ('a', 'l', 'a', 'c'), - kALACFormatLinearPCM = MAKE_MARKER ('l', 'p', 'c', 'm') -} ; - -enum -{ - kALACMaxChannels = 8, - kALACMaxEscapeHeaderBytes = 8, - kALACMaxSearches = 16, - kALACMaxCoefs = 16, - kALACDefaultFramesPerPacket = 4096 -} ; - -typedef uint32_t ALACChannelLayoutTag ; - -enum -{ - kALACFormatFlagIsFloat = (1 << 0), // 0x1 - kALACFormatFlagIsBigEndian = (1 << 1), // 0x2 - kALACFormatFlagIsSignedInteger = (1 << 2), // 0x4 - kALACFormatFlagIsPacked = (1 << 3), // 0x8 - kALACFormatFlagIsAlignedHigh = (1 << 4), // 0x10 -} ; - -enum -{ -#if TARGET_RT_BIG_ENDIAN - kALACFormatFlagsNativeEndian = kALACFormatFlagIsBigEndian -#else - kALACFormatFlagsNativeEndian = 0 -#endif -} ; - -// this is required to be an IEEE 64bit float -typedef double alac_float64_t ; - -// These are the Channel Layout Tags used in the Channel Layout Info portion of the ALAC magic cookie -enum -{ kALACChannelLayoutTag_Mono = (100 << 16) | 1, // C - kALACChannelLayoutTag_Stereo = (101 << 16) | 2, // L R - kALACChannelLayoutTag_MPEG_3_0_B = (113 << 16) | 3, // C L R - kALACChannelLayoutTag_MPEG_4_0_B = (116 << 16) | 4, // C L R Cs - kALACChannelLayoutTag_MPEG_5_0_D = (120 << 16) | 5, // C L R Ls Rs - kALACChannelLayoutTag_MPEG_5_1_D = (124 << 16) | 6, // C L R Ls Rs LFE - kALACChannelLayoutTag_AAC_6_1 = (142 << 16) | 7, // C L R Ls Rs Cs LFE - kALACChannelLayoutTag_MPEG_7_1_B = (127 << 16) | 8 // C Lc Rc L R Ls Rs LFE (doc: IS-13818-7 MPEG2-AAC) -} ; - -// ALAC currently only utilizes these channels layouts. There is a one for one correspondance between a -// given number of channels and one of these layout tags -static const ALACChannelLayoutTag ALACChannelLayoutTags [kALACMaxChannels] = -{ - kALACChannelLayoutTag_Mono, // C - kALACChannelLayoutTag_Stereo, // L R - kALACChannelLayoutTag_MPEG_3_0_B, // C L R - kALACChannelLayoutTag_MPEG_4_0_B, // C L R Cs - kALACChannelLayoutTag_MPEG_5_0_D, // C L R Ls Rs - kALACChannelLayoutTag_MPEG_5_1_D, // C L R Ls Rs LFE - kALACChannelLayoutTag_AAC_6_1, // C L R Ls Rs Cs LFE - kALACChannelLayoutTag_MPEG_7_1_B // C Lc Rc L R Ls Rs LFE (doc: IS-13818-7 MPEG2-AAC) -} ; - -// AudioChannelLayout from CoreAudioTypes.h. We never need the AudioChannelDescription so we remove it -struct ALACAudioChannelLayout -{ ALACChannelLayoutTag mChannelLayoutTag ; - uint32_t mChannelBitmap ; - uint32_t mNumberChannelDescriptions ; -} ; -typedef struct ALACAudioChannelLayout ALACAudioChannelLayout ; - -struct AudioFormatDescription -{ - alac_float64_t mSampleRate ; - uint32_t mFormatID ; - uint32_t mFormatFlags ; - uint32_t mBytesPerPacket ; - uint32_t mFramesPerPacket ; - uint32_t mBytesPerFrame ; - uint32_t mChannelsPerFrame ; - uint32_t mBitsPerChannel ; - uint32_t mReserved ; -} ; -typedef struct AudioFormatDescription AudioFormatDescription ; - -/* Lossless Definitions */ - -enum -{ - kALACCodecFormat = MAKE_MARKER ('a', 'l', 'a', 'c'), - kALACVersion = 0, - kALACCompatibleVersion = kALACVersion, - kALACDefaultFrameSize = 4096 -} ; - -// note: this struct is wrapped in an 'alac' atom in the sample description extension area -// note: in QT movies, it will be further wrapped in a 'wave' atom surrounded by 'frma' and 'term' atoms -typedef struct ALACSpecificConfig -{ - uint32_t frameLength ; - uint8_t compatibleVersion ; - uint8_t bitDepth ; // max 32 - uint8_t pb ; // 0 <= pb <= 255 - uint8_t mb ; - uint8_t kb ; - uint8_t numChannels ; - uint16_t maxRun ; - uint32_t maxFrameBytes ; - uint32_t avgBitRate ; - uint32_t sampleRate ; - -} ALACSpecificConfig ; - - -// The AudioChannelLayout atom type is not exposed yet so define it here -enum -{ - AudioChannelLayoutAID = MAKE_MARKER ('c', 'h', 'a', 'n') -} ; - -#if PRAGMA_STRUCT_ALIGN - #pragma options align = reset -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack (pop) -#elif PRAGMA_STRUCT_PACK - #pragma pack () -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ALACAUDIOTYPES_H */ diff --git a/Engine/lib/libsndfile/src/ALAC/ALACBitUtilities.c b/Engine/lib/libsndfile/src/ALAC/ALACBitUtilities.c deleted file mode 100644 index d861be4f1..000000000 --- a/Engine/lib/libsndfile/src/ALAC/ALACBitUtilities.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/*============================================================================= - File: ALACBitUtilities.c - - $NoKeywords: $ -=============================================================================*/ - -#include -#include "ALACBitUtilities.h" - -#define PRAGMA_MARK 0 - -// BitBufferInit -// -void BitBufferInit (BitBuffer * bits, uint8_t * buffer, uint32_t byteSize) -{ - bits->cur = buffer ; - bits->end = bits->cur + byteSize ; - bits->bitIndex = 0 ; - bits->byteSize = byteSize ; -} - -// BitBufferRead -// -uint32_t BitBufferRead (BitBuffer * bits, uint8_t numBits) -{ - uint32_t returnBits ; - - //Assert (numBits <= 16) ; - - returnBits = ((uint32_t) bits->cur [0] << 16) | ((uint32_t) bits->cur [1] << 8) | ((uint32_t) bits->cur [2]) ; - returnBits = returnBits << bits->bitIndex ; - returnBits &= 0x00FFFFFF ; - - bits->bitIndex += numBits ; - - returnBits = returnBits >> (24 - numBits) ; - - bits->cur += (bits->bitIndex >> 3) ; - bits->bitIndex &= 7 ; - - //Assert (bits->cur <= bits->end) ; - - return returnBits ; -} - -// BitBufferReadSmall -// -// Reads up to 8 bits -uint8_t BitBufferReadSmall (BitBuffer * bits, uint8_t numBits) -{ - uint16_t returnBits ; - - //Assert (numBits <= 8) ; - - returnBits = (bits->cur [0] << 8) | bits->cur [1] ; - returnBits = returnBits << bits->bitIndex ; - - bits->bitIndex += numBits ; - - returnBits = returnBits >> (16 - numBits) ; - - bits->cur += (bits->bitIndex >> 3) ; - bits->bitIndex &= 7 ; - - //Assert (bits->cur <= bits->end) ; - - return (uint8_t) returnBits ; -} - -// BitBufferReadOne -// -// Reads one byte -uint8_t BitBufferReadOne (BitBuffer * bits) -{ - uint8_t returnBits ; - - returnBits = (bits->cur [0] >> (7 - bits->bitIndex)) & 1 ; - - bits->bitIndex++ ; - - bits->cur += (bits->bitIndex >> 3) ; - bits->bitIndex &= 7 ; - - //Assert (bits->cur <= bits->end) ; - - return returnBits ; -} - -// BitBufferPeek -// -uint32_t BitBufferPeek (BitBuffer * bits, uint8_t numBits) -{ - return ((((((uint32_t) bits->cur [0] << 16) | ((uint32_t) bits->cur [1] << 8) | - ((uint32_t) bits->cur [2])) << bits->bitIndex) & 0x00FFFFFF) >> (24 - numBits)) ; -} - -// BitBufferPeekOne -// -uint32_t BitBufferPeekOne (BitBuffer * bits) -{ - return ((bits->cur [0] >> (7 - bits->bitIndex)) & 1) ; -} - -// BitBufferUnpackBERSize -// -uint32_t BitBufferUnpackBERSize (BitBuffer * bits) -{ - uint32_t size ; - uint8_t tmp ; - - for (size = 0, tmp = 0x80u ; tmp &= 0x80u ; size = (size << 7u) | (tmp & 0x7fu)) - tmp = (uint8_t) BitBufferReadSmall (bits, 8) ; - - return size ; -} - -// BitBufferGetPosition -// -uint32_t BitBufferGetPosition (BitBuffer * bits) -{ - uint8_t * begin ; - - begin = bits->end - bits->byteSize ; - - return ((uint32_t) (bits->cur - begin) * 8) + bits->bitIndex ; -} - -// BitBufferByteAlign -// -void BitBufferByteAlign (BitBuffer * bits, int32_t addZeros) -{ - // align bit buffer to next byte boundary, writing zeros if requested - if (bits->bitIndex == 0) - return ; - - if (addZeros) - BitBufferWrite (bits, 0, 8 - bits->bitIndex) ; - else - BitBufferAdvance (bits, 8 - bits->bitIndex) ; -} - -// BitBufferAdvance -// -void BitBufferAdvance (BitBuffer * bits, uint32_t numBits) -{ - if (numBits) - { - bits->bitIndex += numBits ; - bits->cur += (bits->bitIndex >> 3) ; - bits->bitIndex &= 7 ; - } -} - -// BitBufferRewind -// -void BitBufferRewind (BitBuffer * bits, uint32_t numBits) -{ - uint32_t numBytes ; - - if (numBits == 0) - return ; - - if (bits->bitIndex >= numBits) - { - bits->bitIndex -= numBits ; - return ; - } - - numBits -= bits->bitIndex ; - bits->bitIndex = 0 ; - - numBytes = numBits / 8 ; - numBits = numBits % 8 ; - - bits->cur -= numBytes ; - - if (numBits > 0) - { - bits->bitIndex = 8 - numBits ; - bits->cur-- ; - } - - if (bits->cur < (bits->end - bits->byteSize)) - { - //DebugCMsg ("BitBufferRewind: Rewound too far.") ; - - bits->cur = (bits->end - bits->byteSize) ; - bits->bitIndex = 0 ; - } -} - -// BitBufferWrite -// -void BitBufferWrite (BitBuffer * bits, uint32_t bitValues, uint32_t numBits) -{ - uint32_t invBitIndex ; - - RequireAction (bits != NULL, return ;) ; - RequireActionSilent (numBits > 0, return ;) ; - - invBitIndex = 8 - bits->bitIndex ; - - while (numBits > 0) - { - uint32_t tmp ; - uint8_t shift ; - uint8_t mask ; - uint32_t curNum ; - - curNum = MIN (invBitIndex, numBits) ; - - tmp = bitValues >> (numBits - curNum) ; - - shift = (uint8_t) (invBitIndex - curNum) ; - mask = 0xffu >> (8 - curNum) ; // must be done in two steps to avoid compiler sequencing ambiguity - mask <<= shift ; - - bits->cur [0] = (bits->cur [0] & ~mask) | (((uint8_t) tmp << shift) & mask) ; - numBits -= curNum ; - - // increment to next byte if need be - invBitIndex -= curNum ; - if (invBitIndex == 0) - { - invBitIndex = 8 ; - bits->cur++ ; - } - } - - bits->bitIndex = 8 - invBitIndex ; -} - -void BitBufferReset (BitBuffer * bits) -//void BitBufferInit (BitBuffer * bits, uint8_t * buffer, uint32_t byteSize) -{ - bits->cur = bits->end - bits->byteSize ; - bits->bitIndex = 0 ; -} - -#if PRAGMA_MARK -#pragma mark - -#endif diff --git a/Engine/lib/libsndfile/src/ALAC/ALACBitUtilities.h b/Engine/lib/libsndfile/src/ALAC/ALACBitUtilities.h deleted file mode 100644 index 97080cdfe..000000000 --- a/Engine/lib/libsndfile/src/ALAC/ALACBitUtilities.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/*============================================================================= - File: ALACBitUtilities.h - - $NoKeywords: $ -=============================================================================*/ - -#ifndef __ALACBITUTILITIES_H -#define __ALACBITUTILITIES_H - -#include - -#ifndef MIN -#define MIN(x, y) ((x) < (y) ? (x) : (y)) -#endif // MIN -#ifndef MAX -#define MAX(x, y) ((x) > (y) ? (x) : (y)) -#endif // MAX - -#define RequireAction(condition, action) if (! (condition)) { action } -#define RequireActionSilent(condition, action) if (! (condition)) { action } -#define RequireNoErr(condition, action) if (condition) { action } - -enum -{ - ALAC_noErr = 0 -} ; - - -typedef enum -{ ID_SCE = 0, /* Single Channel Element */ - ID_CPE = 1, /* Channel Pair Element */ - ID_CCE = 2, /* Coupling Channel Element */ - ID_LFE = 3, /* LFE Channel Element */ - ID_DSE = 4, /* not yet supported */ - ID_PCE = 5, - ID_FIL = 6, - ID_END = 7 -} ELEMENT_TYPE ; - -// types -typedef struct BitBuffer -{ - uint8_t * cur ; - uint8_t * end ; - uint32_t bitIndex ; - uint32_t byteSize ; - -} BitBuffer ; - -/* - BitBuffer routines - - these routines take a fixed size buffer and read/write to it - - bounds checking must be done by the client -*/ -void BitBufferInit (BitBuffer * bits, uint8_t * buffer, uint32_t byteSize) ; -uint32_t BitBufferRead (BitBuffer * bits, uint8_t numBits) ; // note: cannot read more than 16 bits at a time -uint8_t BitBufferReadSmall (BitBuffer * bits, uint8_t numBits) ; -uint8_t BitBufferReadOne (BitBuffer * bits) ; -uint32_t BitBufferPeek (BitBuffer * bits, uint8_t numBits) ; // note: cannot read more than 16 bits at a time -uint32_t BitBufferPeekOne (BitBuffer * bits) ; -uint32_t BitBufferUnpackBERSize (BitBuffer * bits) ; -uint32_t BitBufferGetPosition (BitBuffer * bits) ; -void BitBufferByteAlign (BitBuffer * bits, int32_t addZeros) ; -void BitBufferAdvance (BitBuffer * bits, uint32_t numBits) ; -void BitBufferRewind (BitBuffer * bits, uint32_t numBits) ; -void BitBufferWrite (BitBuffer * bits, uint32_t value, uint32_t numBits) ; -void BitBufferReset (BitBuffer * bits) ; - -#endif /* __BITUTILITIES_H */ diff --git a/Engine/lib/libsndfile/src/ALAC/ALACDecoder.h b/Engine/lib/libsndfile/src/ALAC/ALACDecoder.h deleted file mode 100644 index 8eb7531f8..000000000 --- a/Engine/lib/libsndfile/src/ALAC/ALACDecoder.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: ALACDecoder.h -*/ - -#ifndef _ALACDECODER_H -#define _ALACDECODER_H - -#include - -#include "ALACAudioTypes.h" - -struct BitBuffer ; - -class ALACDecoder -{ - public: - ALACDecoder () ; - ~ALACDecoder () ; - - int32_t Init (void * inMagicCookie, uint32_t inMagicCookieSize) ; - int32_t Decode (struct BitBuffer * bits, uint8_t * sampleBuffer, uint32_t numSamples, uint32_t numChannels, uint32_t * outNumSamples) ; - - public: - // decoding parameters (public for use in the analyzer) - ALACSpecificConfig mConfig ; - - protected: - int32_t FillElement (struct BitBuffer * bits) ; - int32_t DataStreamElement (struct BitBuffer * bits) ; - - uint16_t mActiveElements ; - - // decoding buffers - int32_t * mMixBufferU ; - int32_t * mMixBufferV ; - int32_t * mPredictor ; - uint16_t * mShiftBuffer ; // note: this points to mPredictor's memory but different - // variable for clarity and type difference -} ; - -#endif /* _ALACDECODER_H */ diff --git a/Engine/lib/libsndfile/src/ALAC/ALACEncoder.h b/Engine/lib/libsndfile/src/ALAC/ALACEncoder.h deleted file mode 100644 index eb5b79ee3..000000000 --- a/Engine/lib/libsndfile/src/ALAC/ALACEncoder.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: ALACEncoder.h -*/ - -#pragma once - -#include - -#include "ALACAudioTypes.h" - - -struct BitBuffer ; - -class ALACEncoder -{ - public : - ALACEncoder () ; - virtual ~ALACEncoder () ; - - virtual int32_t Encode (AudioFormatDescription theInputFormat, AudioFormatDescription theOutputFormat, - unsigned char * theReadBuffer, unsigned char * theWriteBuffer, int32_t * ioNumBytes) ; - virtual int32_t Finish () ; - - void SetFastMode (bool fast) { mFastMode = fast ; } ; - - // this must be called *before* InitializeEncoder () - void SetFrameSize (uint32_t frameSize) { mFrameSize = frameSize ; } ; - - void GetConfig (ALACSpecificConfig & config) ; - uint32_t GetMagicCookieSize (uint32_t inNumChannels) ; - void GetMagicCookie (void * config, uint32_t * ioSize) ; - - virtual int32_t InitializeEncoder (AudioFormatDescription theOutputFormat) ; - - protected : - virtual void GetSourceFormat (const AudioFormatDescription * source, AudioFormatDescription * output) ; - - int32_t EncodeStereo (struct BitBuffer * bitstream, void * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) ; - int32_t EncodeStereoFast (struct BitBuffer * bitstream, void * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) ; - int32_t EncodeStereoEscape (struct BitBuffer * bitstream, void * input, uint32_t stride, uint32_t numSamples) ; - int32_t EncodeMono (struct BitBuffer * bitstream, void * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) ; - - - // ALAC encoder parameters - int16_t mBitDepth ; - bool mFastMode ; - - // encoding state - int16_t mLastMixRes [kALACMaxChannels] ; - - // encoding buffers - int32_t * mMixBufferU ; - int32_t * mMixBufferV ; - int32_t * mPredictorU ; - int32_t * mPredictorV ; - uint16_t * mShiftBufferUV ; - - uint8_t * mWorkBuffer ; - - // per-channel coefficients buffers - int16_t mCoefsU [kALACMaxChannels][kALACMaxSearches][kALACMaxCoefs] ; - int16_t mCoefsV [kALACMaxChannels][kALACMaxSearches][kALACMaxCoefs] ; - - // encoding statistics - uint32_t mTotalBytesGenerated ; - uint32_t mAvgBitRate ; - uint32_t mMaxFrameBytes ; - uint32_t mFrameSize ; - uint32_t mMaxOutputBytes ; - uint32_t mNumChannels ; - uint32_t mOutputSampleRate ; -} ; diff --git a/Engine/lib/libsndfile/src/ALAC/EndianPortable.h b/Engine/lib/libsndfile/src/ALAC/EndianPortable.h deleted file mode 100644 index aa1f449b4..000000000 --- a/Engine/lib/libsndfile/src/ALAC/EndianPortable.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. -** Copyright (C) 2013-2014 Erik de Castro Lopo - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -// -// EndianPortable.h -// -// Copyright 2011 Apple Inc. All rights reserved. -// - -#ifndef _EndianPortable_h -#define _EndianPortable_h - -#include - -#define Swap16NtoB(x) H2BE_16 (x) -#define Swap16BtoN(x) BE2H_16 (x) - -#define Swap32NtoB(x) H2BE_32 (x) -#define Swap32BtoN(x) BE2H_32 (x) - -#endif diff --git a/Engine/lib/libsndfile/src/ALAC/LICENSE b/Engine/lib/libsndfile/src/ALAC/LICENSE deleted file mode 100644 index 7d8595490..000000000 --- a/Engine/lib/libsndfile/src/ALAC/LICENSE +++ /dev/null @@ -1,170 +0,0 @@ -Apache License - -Version 2.0, January 2004 - -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the -copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other -entities that control, are controlled by, or are under common control -with that entity. For the purposes of this definition, "control" means -(i) the power, direct or indirect, to cause the direction or management -of such entity, whether by contract or otherwise, or (ii) ownership -of fifty percent (50%) or more of the outstanding shares, or (iii) -beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, -including but not limited to software source code, documentation source, -and configuration files. - -"Object" form shall mean any form resulting from mechanical -transformation or translation of a Source form, including but not -limited to compiled object code, generated documentation, and -conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object -form, made available under the License, as indicated by a copyright -notice that is included in or attached to the work (an example is -provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object -form, that is based on (or derived from) the Work and for which the -editorial revisions, annotations, elaborations, or other modifications -represent, as a whole, an original work of authorship. For the purposes -of this License, Derivative Works shall not include works that remain -separable from, or merely link (or bind by name) to the interfaces of, -the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original -version of the Work and any modifications or additions to that Work or -Derivative Works thereof, that is intentionally submitted to Licensor -for inclusion in the Work by the copyright owner or by an individual -or Legal Entity authorized to submit on behalf of the copyright owner. -For the purposes of this definition, "submitted" means any form of -electronic, verbal, or written communication sent to the Licensor -or its representatives, including but not limited to communication -on electronic mailing lists, source code control systems, and issue -tracking systems that are managed by, or on behalf of, the Licensor -for the purpose of discussing and improving the Work, but excluding -communication that is conspicuously marked or otherwise designated in -writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity -on behalf of whom a Contribution has been received by Licensor and -subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions -of this License, each Contributor hereby grants to You a perpetual, -worldwide, non-exclusive, no-charge, royalty-free, irrevocable -copyright license to reproduce, prepare Derivative Works of, publicly -display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of -this License, each Contributor hereby grants to You a perpetual, -worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except -as stated in this section) patent license to make, have made, use, -offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such -Contributor that are necessarily infringed by their Contribution(s) -alone or by combination of their Contribution(s) with the Work to which -such Contribution(s) was submitted. If You institute patent litigation -against any entity (including a cross-claim or counterclaim in a -lawsuit) alleging that the Work or a Contribution incorporated within -the Work constitutes direct or contributory patent infringement, then -any patent licenses granted to You under this License for that Work -shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the -Work or Derivative Works thereof in any medium, with or without -modifications, and in Source or Object form, provided that You meet the -following conditions: - -You must give any other recipients of the Work or Derivative Works a -copy of this License; and - -You must cause any modified files to carry prominent notices stating -that You changed the files; and - -You must retain, in the Source form of any Derivative Works that You -distribute, all copyright, patent, trademark, and attribution notices -from the Source form of the Work, excluding those notices that do not -pertain to any part of the Derivative Works; and - -If the Work includes a "NOTICE" text file as part of its distribution, -then any Derivative Works that You distribute must include a readable -copy of the attribution notices contained within such NOTICE file, -excluding those notices that do not pertain to any part of the -Derivative Works, in at least one of the following places: within a -NOTICE text file distributed as part of the Derivative Works; within -the Source form or documentation, if provided along with the Derivative -Works; or, within a display generated by the Derivative Works, if and -wherever such third-party notices normally appear. The contents of the -NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative -Works that You distribute, alongside or as an addendum to the NOTICE -text from the Work, provided that such additional attribution notices -cannot be construed as modifying the License. You may add Your own -copyright statement to Your modifications and may provide additional -or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as -a whole, provided Your use, reproduction, and distribution of the Work -otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, -any Contribution intentionally submitted for inclusion in the Work by -You to the Licensor shall be under the terms and conditions of this -License, without any additional terms or conditions. Notwithstanding -the above, nothing herein shall supersede or modify the terms of any -separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. This License does not grant permission to use the trade -names, trademarks, service marks, or product names of the Licensor, -except as required for reasonable and customary use in describing the -origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed -to in writing, Licensor provides the Work (and each Contributor -provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied, including, without -limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, -MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your -exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, -whether in tort (including negligence), contract, or otherwise, unless -required by applicable law (such as deliberate and grossly negligent -acts) or agreed to in writing, shall any Contributor be liable to You -for damages, including any direct, indirect, special, incidental, or -consequential damages of any character arising as a result of this -License or out of the use or inability to use the Work (including but -not limited to damages for loss of goodwill, work stoppage, computer -failure or malfunction, or any and all other commercial damages or -losses), even if such Contributor has been advised of the possibility of -such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the -Work or Derivative Works thereof, You may choose to offer, and charge a -fee for, acceptance of support, warranty, indemnity, or other liability -obligations and/or rights consistent with this License. However, in -accepting such obligations, You may act only on Your own behalf and -on Your sole responsibility, not on behalf of any other Contributor, -and only if You agree to indemnify, defend, and hold each Contributor -harmless for any liability incurred by, or claims asserted against, such -Contributor by reason of your accepting any such warranty or additional -liability. diff --git a/Engine/lib/libsndfile/src/ALAC/ag_dec.c b/Engine/lib/libsndfile/src/ALAC/ag_dec.c deleted file mode 100644 index 37671d240..000000000 --- a/Engine/lib/libsndfile/src/ALAC/ag_dec.c +++ /dev/null @@ -1,358 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: ag_dec.c - - Contains: Adaptive Golomb decode routines. - - Copyright: (c) 2001-2011 Apple, Inc. -*/ - -#include -#include -#include -#include - -#include "aglib.h" -#include "ALACBitUtilities.h" -#include "ALACAudioTypes.h" - -#define CODE_TO_LONG_MAXBITS 32 -#define N_MAX_MEAN_CLAMP 0xffff -#define N_MEAN_CLAMP_VAL 0xffff -#define REPORT_VAL 40 - -#if __GNUC__ -#define ALWAYS_INLINE __attribute__ ((always_inline)) -#elif defined _MSC_VER -#define ALWAYS_INLINE __forceinline -#else -#define ALWAYS_INLINE -#endif - -/* And on the subject of the CodeWarrior x86 compiler and inlining, I reworked a lot of this - to help the compiler out. In many cases this required manual inlining or a macro. Sorry - if it is ugly but the performance gains are well worth it. - - WSK 5/19/04 -*/ - -void set_standard_ag_params (AGParamRecPtr params, uint32_t fullwidth, uint32_t sectorwidth) -{ - /* Use - fullwidth = sectorwidth = numOfSamples, for analog 1-dimensional type-short data, - but use - fullwidth = full image width, sectorwidth = sector (patch) width - for such as image (2-dim.) data. - */ - set_ag_params (params, MB0, PB0, KB0, fullwidth, sectorwidth, MAX_RUN_DEFAULT) ; -} - -void set_ag_params (AGParamRecPtr params, uint32_t m, uint32_t p, uint32_t k, uint32_t f, uint32_t s, uint32_t maxrun) -{ - params->mb = params->mb0 = m ; - params->pb = p ; - params->kb = k ; - params->wb = (1u << params->kb) - 1 ; - params->qb = QB-params->pb ; - params->fw = f ; - params->sw = s ; - params->maxrun = maxrun ; -} - -#if PRAGMA_MARK -#pragma mark - -#endif - - -// note: implementing this with some kind of "count leading zeros" assembly is a big performance win -static inline int32_t lead (int32_t m) -{ - long j ; - unsigned long c = (1ul << 31) ; - - for (j = 0 ; j < 32 ; j++) - { - if ((c & m) != 0) - break ; - c >>= 1 ; - } - return j ; -} - -#define arithmin(a, b) ((a) < (b) ? (a) : (b)) - -static inline int32_t ALWAYS_INLINE lg3a (int32_t x) -{ - int32_t result ; - - x += 3 ; - result = lead (x) ; - - return 31 - result ; -} - -static inline uint32_t ALWAYS_INLINE read32bit (uint8_t * buffer) -{ - // embedded CPUs typically can't read unaligned 32-bit words so just read the bytes - uint32_t value ; - - value = ((uint32_t) buffer [0] << 24) | ((uint32_t) buffer [1] << 16) | - ((uint32_t) buffer [2] << 8) | (uint32_t) buffer [3] ; - return value ; - -} - -#if PRAGMA_MARK -#pragma mark - -#endif - -#define get_next_fromlong(inlong, suff) ((inlong) >> (32 - (suff))) - - -static inline uint32_t ALWAYS_INLINE -getstreambits (uint8_t *in, int32_t bitoffset, int32_t numbits) -{ - uint32_t load1, load2 ; - uint32_t byteoffset = bitoffset / 8 ; - uint32_t result ; - - //Assert (numbits <= 32) ; - - load1 = read32bit (in + byteoffset) ; - - if ((numbits + (bitoffset & 0x7)) > 32) - { - int32_t load2shift ; - - result = load1 << (bitoffset & 0x7) ; - load2 = (uint32_t) in [byteoffset + 4] ; - load2shift = (8 - (numbits + (bitoffset & 0x7) - 32)) ; - load2 >>= load2shift ; - result >>= (32 - numbits) ; - result |= load2 ; - } - else - { - result = load1 >> (32 - numbits - (bitoffset & 7)) ; - } - - // a shift of >= "the number of bits in the type of the value being shifted" results in undefined - // behavior so don't try to shift by 32 - if (numbits != (sizeof (result) * 8)) - result &= ~ (0xfffffffful << numbits) ; - - return result ; -} - - -static inline int32_t dyn_get (unsigned char *in, uint32_t *bitPos, uint32_t m, uint32_t k) -{ - uint32_t tempbits = *bitPos ; - uint32_t result ; - uint32_t pre = 0, v ; - uint32_t streamlong ; - - streamlong = read32bit (in + (tempbits >> 3)) ; - streamlong <<= (tempbits & 7) ; - - /* find the number of bits in the prefix */ - { - uint32_t notI = ~streamlong ; - pre = lead (notI) ; - } - - if (pre >= MAX_PREFIX_16) - { - pre = MAX_PREFIX_16 ; - tempbits += pre ; - streamlong <<= pre ; - result = get_next_fromlong (streamlong, MAX_DATATYPE_BITS_16) ; - tempbits += MAX_DATATYPE_BITS_16 ; - - } - else - { - // all of the bits must fit within the long we have loaded - //Assert (pre+1+k <= 32) ; - - tempbits += pre ; - tempbits += 1 ; - streamlong <<= pre + 1 ; - v = get_next_fromlong (streamlong, k) ; - tempbits += k ; - - result = pre*m + v-1 ; - - if (v < 2) - { - result -= (v-1) ; - tempbits -= 1 ; - } - } - - *bitPos = tempbits ; - return result ; -} - - -static inline int32_t dyn_get_32bit (uint8_t * in, uint32_t * bitPos, int32_t m, int32_t k, int32_t maxbits) -{ - uint32_t tempbits = *bitPos ; - uint32_t v ; - uint32_t streamlong ; - uint32_t result ; - - streamlong = read32bit (in + (tempbits >> 3)) ; - streamlong <<= (tempbits & 7) ; - - /* find the number of bits in the prefix */ - { - uint32_t notI = ~streamlong ; - result = lead (notI) ; - } - - if (result >= MAX_PREFIX_32) - { - result = getstreambits (in, tempbits+MAX_PREFIX_32, maxbits) ; - tempbits += MAX_PREFIX_32 + maxbits ; - } - else - { - /* all of the bits must fit within the long we have loaded*/ - //Assert (k<=14) ; - //Assert (result= 2) - { - result += (v-1) ; - tempbits += 1 ; - } - } - } - - *bitPos = tempbits ; - - return result ; -} - -int32_t dyn_decomp (AGParamRecPtr params, BitBuffer * bitstream, int32_t * pc, int32_t numSamples, int32_t maxSize, uint32_t * outNumBits) -{ - uint8_t *in ; - int32_t *outPtr = pc ; - uint32_t bitPos, startPos, maxPos ; - uint32_t j, m, k, n, c, mz ; - int32_t del, zmode ; - uint32_t mb ; - uint32_t pb_local = params->pb ; - uint32_t kb_local = params->kb ; - uint32_t wb_local = params->wb ; - int32_t status ; - - RequireAction ((bitstream != NULL) && (pc != NULL) && (outNumBits != NULL), return kALAC_ParamError ;) ; - *outNumBits = 0 ; - - in = bitstream->cur ; - startPos = bitstream->bitIndex ; - maxPos = bitstream->byteSize * 8 ; - bitPos = startPos ; - - mb = params->mb0 ; - zmode = 0 ; - - c = 0 ; - status = ALAC_noErr ; - - while (c < (uint32_t) numSamples) - { - // bail if we've run off the end of the buffer - RequireAction (bitPos < maxPos, status = kALAC_ParamError ; goto Exit ;) ; - - m = (mb) >> QBSHIFT ; - k = lg3a (m) ; - - k = arithmin (k, kb_local) ; - m = (1 << k) - 1 ; - - n = dyn_get_32bit (in, &bitPos, m, k, maxSize) ; - - // least significant bit is sign bit - { - uint32_t ndecode = n + zmode ; - int32_t multiplier = - (int) (ndecode & 1) ; - - multiplier |= 1 ; - del = ((ndecode+1) >> 1) * (multiplier) ; - } - - *outPtr++ = del ; - - c++ ; - - mb = pb_local * (n + zmode) + mb - ((pb_local * mb) >> QBSHIFT) ; - - // update mean tracking - if (n > N_MAX_MEAN_CLAMP) - mb = N_MEAN_CLAMP_VAL ; - - zmode = 0 ; - - if (((mb << MMULSHIFT) < QB) && (c < (uint32_t) numSamples)) - { - zmode = 1 ; - k = lead (mb) - BITOFF + ((mb + MOFF) >> MDENSHIFT) ; - mz = ((1 << k) - 1) & wb_local ; - - n = dyn_get (in, &bitPos, mz, k) ; - - RequireAction (c+n <= (uint32_t) numSamples, status = kALAC_ParamError ; goto Exit ;) ; - - for (j = 0 ; j < n ; j++) - { - *outPtr++ = 0 ; - ++c ; - } - - if (n >= 65535) - zmode = 0 ; - - mb = 0 ; - } - } - -Exit: - *outNumBits = (bitPos - startPos) ; - BitBufferAdvance (bitstream, *outNumBits) ; - RequireAction (bitstream->cur <= bitstream->end, status = kALAC_ParamError ;) ; - - return status ; -} diff --git a/Engine/lib/libsndfile/src/ALAC/ag_enc.c b/Engine/lib/libsndfile/src/ALAC/ag_enc.c deleted file mode 100644 index 4737b96e3..000000000 --- a/Engine/lib/libsndfile/src/ALAC/ag_enc.c +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * Copyright (C) 2013-2014 Erik de Castro Lopo - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: ag_enc.c - - Contains: Adaptive Golomb encode routines. - - Copyright: (c) 2001-2011 Apple, Inc. -*/ - -#include "aglib.h" -#include "ALACBitUtilities.h" -#include "EndianPortable.h" -#include "ALACAudioTypes.h" - -#include -#include -#include -#include - -#define CODE_TO_LONG_MAXBITS 32 -#define N_MAX_MEAN_CLAMP 0xffff -#define N_MEAN_CLAMP_VAL 0xffff -#define REPORT_VAL 40 - -#if __GNUC__ -#define ALWAYS_INLINE __attribute__ ((always_inline)) -#elif defined _MSC_VER -#define ALWAYS_INLINE __forceinline -#else -#define ALWAYS_INLINE -#endif - - -/* And on the subject of the CodeWarrior x86 compiler and inlining, I reworked a lot of this - to help the compiler out. In many cases this required manual inlining or a macro. Sorry - if it is ugly but the performance gains are well worth it. - - WSK 5/19/04 -*/ - -// note: implementing this with some kind of "count leading zeros" assembly is a big performance win -static inline int32_t lead (int32_t m) -{ - long j ; - unsigned long c = (1ul << 31) ; - - for (j = 0 ; j < 32 ; j++) - { - if ((c & m) != 0) - break ; - c >>= 1 ; - } - return j ; -} - -#define arithmin (a, b) ((a) < (b) ? (a) : (b)) - -static inline int32_t ALWAYS_INLINE lg3a (int32_t x) -{ - int32_t result ; - - x += 3 ; - result = lead (x) ; - - return 31 - result ; -} - -static inline int32_t ALWAYS_INLINE abs_func (int32_t a) -{ - // note: the CW PPC intrinsic __abs () turns into these instructions so no need to try and use it - int32_t isneg = a >> 31 ; - int32_t xorval = a ^ isneg ; - int32_t result = xorval-isneg ; - - return result ; -} - -#if PRAGMA_MARK -#pragma mark - -#endif - -static inline int32_t dyn_code (int32_t m, int32_t k, int32_t n, uint32_t *outNumBits) -{ - uint32_t divx, mod, de ; - uint32_t numBits ; - uint32_t value ; - - // Assert (n >= 0) ; - - divx = n / m ; - - if (divx >= MAX_PREFIX_16) - { - numBits = MAX_PREFIX_16 + MAX_DATATYPE_BITS_16 ; - value = (((1 << MAX_PREFIX_16) - 1) << MAX_DATATYPE_BITS_16) + n ; - } - else - { - mod = n%m ; - de = (mod == 0) ; - numBits = divx + k + 1 - de ; - value = (((1 << divx) - 1) << (numBits - divx)) + mod + 1 - de ; - - // if coding this way is bigger than doing escape, then do escape - if (numBits > MAX_PREFIX_16 + MAX_DATATYPE_BITS_16) - { - numBits = MAX_PREFIX_16 + MAX_DATATYPE_BITS_16 ; - value = (((1 << MAX_PREFIX_16) - 1) << MAX_DATATYPE_BITS_16) + n ; - } - } - - *outNumBits = numBits ; - - return (int32_t) value ; -} - - -static inline int32_t dyn_code_32bit (int32_t maxbits, uint32_t m, uint32_t k, uint32_t n, uint32_t *outNumBits, uint32_t *outValue, uint32_t *overflow, uint32_t *overflowbits) -{ - uint32_t divx, mod, de ; - uint32_t numBits ; - uint32_t value ; - int32_t didOverflow = 0 ; - - divx = n / m ; - - if (divx < MAX_PREFIX_32) - { - mod = n - (m * divx) ; - - de = (mod == 0) ; - numBits = divx + k + 1 - de ; - value = (((1 << divx) - 1) << (numBits - divx)) + mod + 1 - de ; - if (numBits > 25) - goto codeasescape ; - } - else - { -codeasescape: - numBits = MAX_PREFIX_32 ; - value = (((1 << MAX_PREFIX_32) - 1)) ; - *overflow = n ; - *overflowbits = maxbits ; - didOverflow = 1 ; - } - - *outNumBits = numBits ; - *outValue = value ; - - return didOverflow ; -} - - -static inline void ALWAYS_INLINE dyn_jam_noDeref (unsigned char *out, uint32_t bitPos, uint32_t numBits, uint32_t value) -{ - uint32_t mask ; - uint32_t curr ; - uint32_t shift ; - - //Assert (numBits <= 32) ; - - curr = psf_get_be32 (out, bitPos >> 3) ; - - shift = 32 - (bitPos & 7) - numBits ; - - mask = ~0u >> (32 - numBits) ; // mask must be created in two steps to avoid compiler sequencing ambiguity - mask <<= shift ; - - value = (value << shift) & mask ; - value |= curr & ~mask ; - - psf_put_be32 (out, bitPos >> 3, value) ; -} - - -static inline void ALWAYS_INLINE dyn_jam_noDeref_large (unsigned char *out, uint32_t bitPos, uint32_t numBits, uint32_t value) -{ - uint32_t w ; - uint32_t curr ; - uint32_t mask ; - int32_t shiftvalue = (32 - (bitPos & 7) - numBits) ; - - //Assert (numBits <= 32) ; - - curr = psf_get_be32 (out, bitPos >> 3) ; - - if (shiftvalue < 0) - { - uint8_t tailbyte ; - uint8_t *tailptr ; - - w = value >> -shiftvalue ; - mask = ~0u >> -shiftvalue ; - w |= (curr & ~mask) ; - - tailptr = out + (bitPos >> 3) + 4 ; - tailbyte = (value << ((8+shiftvalue))) & 0xff ; - *tailptr = (uint8_t) tailbyte ; - } - else - { - mask = ~0u >> (32 - numBits) ; - mask <<= shiftvalue ; // mask must be created in two steps to avoid compiler sequencing ambiguity - - w = (value << shiftvalue) & mask ; - w |= curr & ~mask ; - } - - psf_put_be32 (out, bitPos >> 3, w) ; -} - - -int32_t dyn_comp (AGParamRecPtr params, int32_t * pc, BitBuffer * bitstream, int32_t numSamples, int32_t bitSize, uint32_t * outNumBits) -{ - unsigned char * out ; - uint32_t bitPos, startPos ; - uint32_t m, k, n, c, mz, nz ; - uint32_t numBits ; - uint32_t value ; - int32_t del, zmode ; - uint32_t overflow, overflowbits ; - int32_t status ; - - // shadow the variables in params so there's not the dereferencing overhead - uint32_t mb, pb, kb, wb ; - int32_t rowPos = 0 ; - int32_t rowSize = params->sw ; - int32_t rowJump = (params->fw) - rowSize ; - int32_t * inPtr = pc ; - - *outNumBits = 0 ; - RequireAction ((bitSize >= 1) && (bitSize <= 32), return kALAC_ParamError ;) ; - - out = bitstream->cur ; - startPos = bitstream->bitIndex ; - bitPos = startPos ; - - mb = params->mb = params->mb0 ; - pb = params->pb ; - kb = params->kb ; - wb = params->wb ; - zmode = 0 ; - - c = 0 ; - status = ALAC_noErr ; - - while (c < (uint32_t) numSamples) - { - m = mb >> QBSHIFT ; - k = lg3a (m) ; - if (k > kb) - { - k = kb ; - } - m = (1 << k) - 1 ; - - del = *inPtr++ ; - rowPos++ ; - - n = (abs_func (del) << 1) - ((del >> 31) & 1) - zmode ; - //Assert (32-lead (n) <= bitSize) ; - - if (dyn_code_32bit (bitSize, m, k, n, &numBits, &value, &overflow, &overflowbits)) - { - dyn_jam_noDeref (out, bitPos, numBits, value) ; - bitPos += numBits ; - dyn_jam_noDeref_large (out, bitPos, overflowbits, overflow) ; - bitPos += overflowbits ; - } - else - { - dyn_jam_noDeref (out, bitPos, numBits, value) ; - bitPos += numBits ; - } - - c++ ; - if (rowPos >= rowSize) - { - rowPos = 0 ; - inPtr += rowJump ; - } - - mb = pb * (n + zmode) + mb - ((pb * mb) >> QBSHIFT) ; - - // update mean tracking if it's overflowed - if (n > N_MAX_MEAN_CLAMP) - mb = N_MEAN_CLAMP_VAL ; - - zmode = 0 ; - - RequireAction (c <= (uint32_t) numSamples, status = kALAC_ParamError ; goto Exit ;) ; - - if (((mb << MMULSHIFT) < QB) && (c < (uint32_t) numSamples)) - { - zmode = 1 ; - nz = 0 ; - - while (c < (uint32_t) numSamples && *inPtr == 0) - { - /* Take care of wrap-around globals. */ - ++inPtr ; - ++nz ; - ++c ; - if (++rowPos >= rowSize) - { - rowPos = 0 ; - inPtr += rowJump ; - } - - if (nz >= 65535) - { - zmode = 0 ; - break ; - } - } - - k = lead (mb) - BITOFF + ((mb + MOFF) >> MDENSHIFT) ; - mz = ((1 << k) - 1) & wb ; - - value = dyn_code (mz, k, nz, &numBits) ; - dyn_jam_noDeref (out, bitPos, numBits, value) ; - bitPos += numBits ; - - mb = 0 ; - } - } - - *outNumBits = (bitPos - startPos) ; - BitBufferAdvance (bitstream, *outNumBits) ; - -Exit: - return status ; -} diff --git a/Engine/lib/libsndfile/src/ALAC/aglib.h b/Engine/lib/libsndfile/src/ALAC/aglib.h deleted file mode 100644 index 825c4bdfd..000000000 --- a/Engine/lib/libsndfile/src/ALAC/aglib.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: aglib.h - - Copyright: (C) 2001-2011 Apple, Inc. -*/ - -#ifndef AGLIB_H -#define AGLIB_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define QBSHIFT 9 -#define QB (1 << QBSHIFT) -#define PB0 40 -#define MB0 10 -#define KB0 14 -#define MAX_RUN_DEFAULT 255 - -#define MMULSHIFT 2 -#define MDENSHIFT (QBSHIFT - MMULSHIFT - 1) -#define MOFF ((1 << (MDENSHIFT - 2))) - -#define BITOFF 24 - -/* Max. prefix of 1's. */ -#define MAX_PREFIX_16 9 -#define MAX_PREFIX_TOLONG_16 15 -#define MAX_PREFIX_32 9 - -/* Max. bits in 16-bit data type */ -#define MAX_DATATYPE_BITS_16 16 - -typedef struct AGParamRec -{ - uint32_t mb, mb0, pb, kb, wb, qb ; - uint32_t fw, sw ; - - uint32_t maxrun ; - - // fw = 1, sw = 1 ; - -} AGParamRec, *AGParamRecPtr ; - -struct BitBuffer ; - -void set_standard_ag_params (AGParamRecPtr params, uint32_t fullwidth, uint32_t sectorwidth) ; -void set_ag_params (AGParamRecPtr params, uint32_t m, uint32_t p, uint32_t k, uint32_t f, uint32_t s, uint32_t maxrun) ; - -int32_t dyn_comp (AGParamRecPtr params, int32_t * pc, struct BitBuffer * bitstream, int32_t numSamples, int32_t bitSize, uint32_t * outNumBits) ; -int32_t dyn_decomp (AGParamRecPtr params, struct BitBuffer * bitstream, int32_t * pc, int32_t numSamples, int32_t maxSize, uint32_t * outNumBits) ; - - -#ifdef __cplusplus -} -#endif - -#endif //#ifndef AGLIB_H diff --git a/Engine/lib/libsndfile/src/ALAC/alac_codec.h b/Engine/lib/libsndfile/src/ALAC/alac_codec.h deleted file mode 100644 index e762b279a..000000000 --- a/Engine/lib/libsndfile/src/ALAC/alac_codec.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * Copyright (C) 2012-2014 Erik de Castro Lopo - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: alac_codec.h -*/ - -#ifndef ALAC_CODEC_H -#define ALAC_CODEC_H - -#include - -#include "ALACAudioTypes.h" - -#define ALAC_FRAME_LENGTH 4096 - -struct BitBuffer ; - -typedef struct alac_decoder_s -{ - // decoding parameters (public for use in the analyzer) - ALACSpecificConfig mConfig ; - - uint16_t mActiveElements ; - - // decoding buffers - int32_t mMixBufferU [ALAC_FRAME_LENGTH] ; - int32_t mMixBufferV [ALAC_FRAME_LENGTH] ; - union - { - int32_t mPredictor [ALAC_FRAME_LENGTH] ; - uint16_t mShiftBuffer [ALAC_FRAME_LENGTH] ; - } u ; - uint32_t mNumChannels ; -} ALAC_DECODER ; - -typedef struct alac_encoder_s -{ - // ALAC encoder parameters - int16_t mBitDepth ; - - // encoding state - int16_t mLastMixRes [kALACMaxChannels] ; - - int32_t mFastMode ; - - // encoding buffers - int32_t mMixBufferU [ALAC_FRAME_LENGTH] ; - int32_t mMixBufferV [ALAC_FRAME_LENGTH] ; - int32_t mPredictorU [ALAC_FRAME_LENGTH] ; - int32_t mPredictorV [ALAC_FRAME_LENGTH] ; - uint16_t mShiftBufferUV [2 * ALAC_FRAME_LENGTH] ; - uint8_t mWorkBuffer [4 * ALAC_FRAME_LENGTH] ; - - // per-channel coefficients buffers - int16_t mCoefsU [kALACMaxChannels][kALACMaxSearches][kALACMaxCoefs] ; - int16_t mCoefsV [kALACMaxChannels][kALACMaxSearches][kALACMaxCoefs] ; - - // encoding statistics - uint32_t mTotalBytesGenerated ; - uint32_t mAvgBitRate ; - uint32_t mMaxFrameBytes ; - uint32_t mFrameSize ; - uint32_t mMaxOutputBytes ; - uint32_t mNumChannels ; - uint32_t mOutputSampleRate ; -} ALAC_ENCODER ; - - -int32_t alac_decoder_init (ALAC_DECODER *p, void * inMagicCookie, uint32_t inMagicCookieSize) ; -int32_t alac_encoder_init (ALAC_ENCODER *p, uint32_t samplerate, uint32_t channels, uint32_t format_flags, uint32_t frameSize) ; - -int32_t alac_decode (ALAC_DECODER *, struct BitBuffer * bits, int32_t * sampleBuffer, - uint32_t numSamples, uint32_t * outNumSamples) ; - -int32_t alac_encode (ALAC_ENCODER *p, uint32_t numSamples, - const int32_t * theReadBuffer, unsigned char * theWriteBuffer, - uint32_t * ioNumBytes) ; - -void alac_set_fastmode (ALAC_ENCODER * p, int32_t fast) ; - -uint32_t alac_get_magic_cookie_size (uint32_t inNumChannels) ; -void alac_get_magic_cookie (ALAC_ENCODER *p, void * config, uint32_t * ioSize) ; -void alac_get_source_format (ALAC_ENCODER *p, const AudioFormatDescription * source, AudioFormatDescription * output) ; - -#endif diff --git a/Engine/lib/libsndfile/src/ALAC/alac_decoder.c b/Engine/lib/libsndfile/src/ALAC/alac_decoder.c deleted file mode 100644 index 46d333060..000000000 --- a/Engine/lib/libsndfile/src/ALAC/alac_decoder.c +++ /dev/null @@ -1,652 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * Copyright (C) 2012-2015 Erik de Castro Lopo - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: ALACDecoder.cpp -*/ - -#include -#include -#include -#include - -#include "alac_codec.h" - -#include "dplib.h" -#include "aglib.h" -#include "matrixlib.h" -#include "shift.h" - -#include "ALACBitUtilities.h" -#include "EndianPortable.h" - -typedef enum -{ false = 0, - true = 1 -} bool ; - -// constants/data -const uint32_t kMaxBitDepth = 32 ; // max allowed bit depth is 32 - - -// prototypes -static int32_t alac_fill_element (struct BitBuffer * bits) ; -static int32_t alac_data_stream_element (struct BitBuffer * bits) ; - -static void Zero32 (int32_t * buffer, uint32_t numItems, uint32_t stride) ; - - -/* - Init () - - initialize the decoder with the given configuration -*/ -int32_t -alac_decoder_init (ALAC_DECODER *p, void * inMagicCookie, uint32_t inMagicCookieSize) -{ - int32_t status = ALAC_noErr ; - ALACSpecificConfig theConfig ; - uint8_t * theActualCookie = (uint8_t *) inMagicCookie ; - uint32_t theCookieBytesRemaining = inMagicCookieSize ; - - // For historical reasons the decoder needs to be resilient to magic cookies vended by older encoders. - // As specified in the ALACMagicCookieDescription.txt document, there may be additional data encapsulating - // the ALACSpecificConfig. This would consist of format ('frma') and 'alac' atoms which precede the - // ALACSpecificConfig. - // See ALACMagicCookieDescription.txt for additional documentation concerning the 'magic cookie' - - // skip format ('frma') atom if present - if (theActualCookie [4] == 'f' && theActualCookie [5] == 'r' && theActualCookie [6] == 'm' && theActualCookie [7] == 'a') - { - theActualCookie += 12 ; - theCookieBytesRemaining -= 12 ; - } - - // skip 'alac' atom header if present - if (theActualCookie [4] == 'a' && theActualCookie [5] == 'l' && theActualCookie [6] == 'a' && theActualCookie [7] == 'c') - { - theActualCookie += 12 ; - theCookieBytesRemaining -= 12 ; - } - - // read the ALACSpecificConfig - if (theCookieBytesRemaining >= sizeof (ALACSpecificConfig)) - { - theConfig.frameLength = psf_get_be32 (theActualCookie, offsetof (ALACSpecificConfig, frameLength)) ; - - if (theConfig.frameLength > ALAC_FRAME_LENGTH) - return fALAC_FrameLengthError ; - - theConfig.compatibleVersion = theActualCookie [offsetof (ALACSpecificConfig, compatibleVersion)] ; - theConfig.bitDepth = theActualCookie [offsetof (ALACSpecificConfig, bitDepth)] ; - theConfig.pb = theActualCookie [offsetof (ALACSpecificConfig, pb)] ; - theConfig.mb = theActualCookie [offsetof (ALACSpecificConfig, mb)] ; - theConfig.kb = theActualCookie [offsetof (ALACSpecificConfig, kb)] ; - theConfig.numChannels = theActualCookie [offsetof (ALACSpecificConfig, numChannels)] ; - theConfig.maxRun = psf_get_be16 (theActualCookie, offsetof (ALACSpecificConfig, maxRun)) ; - theConfig.maxFrameBytes = psf_get_be32 (theActualCookie, offsetof (ALACSpecificConfig, maxFrameBytes)) ; - theConfig.avgBitRate = psf_get_be32 (theActualCookie, offsetof (ALACSpecificConfig, avgBitRate)) ; - theConfig.sampleRate = psf_get_be32 (theActualCookie, offsetof (ALACSpecificConfig, sampleRate)) ; - - p->mConfig = theConfig ; - p->mNumChannels = theConfig.numChannels ; - - RequireAction (p->mConfig.compatibleVersion <= kALACVersion, return kALAC_IncompatibleVersion ;) ; - RequireAction ((p->mConfig.bitDepth >= 8 && p->mConfig.bitDepth <= 32), return kALAC_BadBitWidth ;) ; - RequireAction ((p->mMixBufferU != NULL) && (p->mMixBufferV != NULL) && (p->u.mPredictor != NULL), - status = kALAC_MemFullError ; goto Exit ;) ; - } - else - { - status = kALAC_BadSpecificConfigSize ; - } - - // skip to Channel Layout Info - // theActualCookie += sizeof (ALACSpecificConfig) ; - - // Currently, the Channel Layout Info portion of the magic cookie (as defined in the - // ALACMagicCookieDescription.txt document) is unused by the decoder. - -Exit: - return status ; -} - -/* - Decode () - - the decoded samples are interleaved into the output buffer in the order they arrive in - the bitstream -*/ -int32_t -alac_decode (ALAC_DECODER *p, struct BitBuffer * bits, int32_t * sampleBuffer, uint32_t numSamples, uint32_t * outNumSamples) -{ - BitBuffer shiftBits ; - uint32_t bits1, bits2 ; - uint8_t tag ; - uint8_t elementInstanceTag ; - AGParamRec agParams ; - uint32_t channelIndex ; - int16_t coefsU [32] ; // max possible size is 32 although NUMCOEPAIRS is the current limit - int16_t coefsV [32] ; - uint8_t numU, numV ; - uint8_t mixBits ; - int8_t mixRes ; - uint16_t unusedHeader ; - uint8_t escapeFlag ; - uint32_t chanBits ; - uint8_t bytesShifted ; - uint32_t shift ; - uint8_t modeU, modeV ; - uint32_t denShiftU, denShiftV ; - uint16_t pbFactorU, pbFactorV ; - uint16_t pb ; - int32_t * out32 ; - uint8_t headerByte ; - uint8_t partialFrame ; - uint32_t extraBits ; - int32_t val ; - uint32_t i, j ; - int32_t status ; - uint32_t numChannels = p->mNumChannels ; - - RequireAction ((bits != NULL) && (sampleBuffer != NULL) && (outNumSamples != NULL), return kALAC_ParamError ;) ; - RequireAction (p->mNumChannels > 0, return kALAC_ZeroChannelCount ;) ; - - p->mActiveElements = 0 ; - channelIndex = 0 ; - - status = ALAC_noErr ; - *outNumSamples = numSamples ; - - while (status == ALAC_noErr) - { - // bail if we ran off the end of the buffer - RequireAction (bits->cur < bits->end, status = kALAC_ParamError ; goto Exit ;) ; - - // copy global decode params for this element - pb = p->mConfig.pb ; - - // read element tag - tag = BitBufferReadSmall (bits, 3) ; - switch (tag) - { - case ID_SCE: - case ID_LFE: - { - // mono/LFE channel - elementInstanceTag = BitBufferReadSmall (bits, 4) ; - p->mActiveElements |= (1u << elementInstanceTag) ; - - // read the 12 unused header bits - unusedHeader = (uint16_t) BitBufferRead (bits, 12) ; - RequireAction (unusedHeader == 0, status = kALAC_ParamError ; goto Exit ;) ; - - // read the 1-bit "partial frame" flag, 2-bit "shift-off" flag & 1-bit "escape" flag - headerByte = (uint8_t) BitBufferRead (bits, 4) ; - - partialFrame = headerByte >> 3 ; - - bytesShifted = (headerByte >> 1) & 0x3u ; - RequireAction (bytesShifted != 3, status = kALAC_ParamError ; goto Exit ;) ; - - shift = bytesShifted * 8 ; - - escapeFlag = headerByte & 0x1 ; - - chanBits = p->mConfig.bitDepth - (bytesShifted * 8) ; - - // check for partial frame to override requested numSamples - if (partialFrame != 0) - { - numSamples = BitBufferRead (bits, 16) << 16 ; - numSamples |= BitBufferRead (bits, 16) ; - - RequireAction (numSamples < kALACDefaultFramesPerPacket, return kALAC_NumSamplesTooBig ;) ; - } - - if (escapeFlag == 0) - { - // compressed frame, read rest of parameters - mixBits = (uint8_t) BitBufferRead (bits, 8) ; - mixRes = (int8_t) BitBufferRead (bits, 8) ; - //Assert ((mixBits == 0) && (mixRes == 0)) ; // no mixing for mono - - headerByte = (uint8_t) BitBufferRead (bits, 8) ; - modeU = headerByte >> 4 ; - denShiftU = headerByte & 0xfu ; - - headerByte = (uint8_t) BitBufferRead (bits, 8) ; - pbFactorU = headerByte >> 5 ; - numU = headerByte & 0x1fu ; - - for (i = 0 ; i < numU ; i++) - coefsU [i] = (int16_t) BitBufferRead (bits, 16) ; - - // if shift active, skip the shift buffer but remember where it starts - if (bytesShifted != 0) - { - shiftBits = *bits ; - BitBufferAdvance (bits, (bytesShifted * 8) * numSamples) ; - } - - // decompress - set_ag_params (&agParams, p->mConfig.mb, (pb * pbFactorU) / 4, p->mConfig.kb, numSamples, numSamples, p->mConfig.maxRun) ; - status = dyn_decomp (&agParams, bits, p->u.mPredictor, numSamples, chanBits, &bits1) ; - RequireNoErr (status, goto Exit ;) ; - - if (modeU == 0) - { - unpc_block (p->u.mPredictor, p->mMixBufferU, numSamples, &coefsU [0], numU, chanBits, denShiftU) ; - } - else - { - // the special "numActive == 31" mode can be done in-place - unpc_block (p->u.mPredictor, p->u.mPredictor, numSamples, NULL, 31, chanBits, 0) ; - unpc_block (p->u.mPredictor, p->mMixBufferU, numSamples, &coefsU [0], numU, chanBits, denShiftU) ; - } - } - else - { - //Assert (bytesShifted == 0) ; - - // uncompressed frame, copy data into the mix buffer to use common output code - shift = 32 - chanBits ; - if (chanBits <= 16) - { - for (i = 0 ; i < numSamples ; i++) - { - val = (int32_t) BitBufferRead (bits, (uint8_t) chanBits) ; - val = (val << shift) >> shift ; - p->mMixBufferU [i] = val ; - } - } - else - { - // BitBufferRead () can't read more than 16 bits at a time so break up the reads - extraBits = chanBits - 16 ; - for (i = 0 ; i < numSamples ; i++) - { - val = (int32_t) BitBufferRead (bits, 16) ; - val = arith_shift_left (val, 16) >> shift ; - p->mMixBufferU [i] = val | BitBufferRead (bits, (uint8_t) extraBits) ; - } - } - - mixBits = mixRes = 0 ; - bits1 = chanBits * numSamples ; - bytesShifted = 0 ; - } - - // now read the shifted values into the shift buffer - if (bytesShifted != 0) - { - shift = bytesShifted * 8 ; - //Assert (shift <= 16) ; - - for (i = 0 ; i < numSamples ; i++) - p->u.mShiftBuffer [i] = (uint16_t) BitBufferRead (&shiftBits, (uint8_t) shift) ; - } - - // convert 32-bit integers into output buffer - switch (p->mConfig.bitDepth) - { - case 16: - out32 = sampleBuffer + channelIndex ; - for (i = 0, j = 0 ; i < numSamples ; i++, j += numChannels) - out32 [j] = arith_shift_left (p->mMixBufferU [i], 16) ; - break ; - case 20: - out32 = sampleBuffer + channelIndex ; - copyPredictorTo20 (p->mMixBufferU, out32, numChannels, numSamples) ; - break ; - case 24: - out32 = sampleBuffer + channelIndex ; - if (bytesShifted != 0) - copyPredictorTo24Shift (p->mMixBufferU, p->u.mShiftBuffer, out32, numChannels, numSamples, bytesShifted) ; - else - copyPredictorTo24 (p->mMixBufferU, out32, numChannels, numSamples) ; - break ; - case 32: - out32 = sampleBuffer + channelIndex ; - if (bytesShifted != 0) - copyPredictorTo32Shift (p->mMixBufferU, p->u.mShiftBuffer, out32, numChannels, numSamples, bytesShifted) ; - else - copyPredictorTo32 (p->mMixBufferU, out32, numChannels, numSamples) ; - break ; - } - - channelIndex += 1 ; - *outNumSamples = numSamples ; - break ; - } - - case ID_CPE: - { - // if decoding this pair would take us over the max channels limit, bail - if ((channelIndex + 2) > numChannels) - goto NoMoreChannels ; - - // stereo channel pair - elementInstanceTag = BitBufferReadSmall (bits, 4) ; - p->mActiveElements |= (1u << elementInstanceTag) ; - - // read the 12 unused header bits - unusedHeader = (uint16_t) BitBufferRead (bits, 12) ; - RequireAction (unusedHeader == 0, status = kALAC_ParamError ; goto Exit ;) ; - - // read the 1-bit "partial frame" flag, 2-bit "shift-off" flag & 1-bit "escape" flag - headerByte = (uint8_t) BitBufferRead (bits, 4) ; - - partialFrame = headerByte >> 3 ; - - bytesShifted = (headerByte >> 1) & 0x3u ; - RequireAction (bytesShifted != 3, status = kALAC_ParamError ; goto Exit ;) ; - - shift = bytesShifted * 8 ; - - escapeFlag = headerByte & 0x1 ; - - chanBits = p->mConfig.bitDepth - (bytesShifted * 8) + 1 ; - - // check for partial frame length to override requested numSamples - if (partialFrame != 0) - { - numSamples = BitBufferRead (bits, 16) << 16 ; - numSamples |= BitBufferRead (bits, 16) ; - - RequireAction (numSamples < kALACDefaultFramesPerPacket, return kALAC_NumSamplesTooBig ;) ; - } - - if (escapeFlag == 0) - { - // compressed frame, read rest of parameters - mixBits = (uint8_t) BitBufferRead (bits, 8) ; - mixRes = (int8_t) BitBufferRead (bits, 8) ; - - headerByte = (uint8_t) BitBufferRead (bits, 8) ; - modeU = headerByte >> 4 ; - denShiftU = headerByte & 0xfu ; - - headerByte = (uint8_t) BitBufferRead (bits, 8) ; - pbFactorU = headerByte >> 5 ; - numU = headerByte & 0x1fu ; - for (i = 0 ; i < numU ; i++) - coefsU [i] = (int16_t) BitBufferRead (bits, 16) ; - - headerByte = (uint8_t) BitBufferRead (bits, 8) ; - modeV = headerByte >> 4 ; - denShiftV = headerByte & 0xfu ; - - headerByte = (uint8_t) BitBufferRead (bits, 8) ; - pbFactorV = headerByte >> 5 ; - numV = headerByte & 0x1fu ; - for (i = 0 ; i < numV ; i++) - coefsV [i] = (int16_t) BitBufferRead (bits, 16) ; - - // if shift active, skip the interleaved shifted values but remember where they start - if (bytesShifted != 0) - { - shiftBits = *bits ; - BitBufferAdvance (bits, (bytesShifted * 8) * 2 * numSamples) ; - } - - // decompress and run predictor for "left" channel - set_ag_params (&agParams, p->mConfig.mb, (pb * pbFactorU) / 4, p->mConfig.kb, numSamples, numSamples, p->mConfig.maxRun) ; - status = dyn_decomp (&agParams, bits, p->u.mPredictor, numSamples, chanBits, &bits1) ; - RequireNoErr (status, goto Exit ;) ; - - if (modeU == 0) - { - unpc_block (p->u.mPredictor, p->mMixBufferU, numSamples, &coefsU [0], numU, chanBits, denShiftU) ; - } - else - { - // the special "numActive == 31" mode can be done in-place - unpc_block (p->u.mPredictor, p->u.mPredictor, numSamples, NULL, 31, chanBits, 0) ; - unpc_block (p->u.mPredictor, p->mMixBufferU, numSamples, &coefsU [0], numU, chanBits, denShiftU) ; - } - - // decompress and run predictor for "right" channel - set_ag_params (&agParams, p->mConfig.mb, (pb * pbFactorV) / 4, p->mConfig.kb, numSamples, numSamples, p->mConfig.maxRun) ; - status = dyn_decomp (&agParams, bits, p->u.mPredictor, numSamples, chanBits, &bits2) ; - RequireNoErr (status, goto Exit ;) ; - - if (modeV == 0) - { - unpc_block (p->u.mPredictor, p->mMixBufferV, numSamples, &coefsV [0], numV, chanBits, denShiftV) ; - } - else - { - // the special "numActive == 31" mode can be done in-place - unpc_block (p->u.mPredictor, p->u.mPredictor, numSamples, NULL, 31, chanBits, 0) ; - unpc_block (p->u.mPredictor, p->mMixBufferV, numSamples, &coefsV [0], numV, chanBits, denShiftV) ; - } - } - else - { - //Assert (bytesShifted == 0) ; - - // uncompressed frame, copy data into the mix buffers to use common output code - chanBits = p->mConfig.bitDepth ; - shift = 32 - chanBits ; - if (chanBits <= 16) - { - for (i = 0 ; i < numSamples ; i++) - { - val = (int32_t) BitBufferRead (bits, (uint8_t) chanBits) ; - val = (val << shift) >> shift ; - p->mMixBufferU [i] = val ; - - val = (int32_t) BitBufferRead (bits, (uint8_t) chanBits) ; - val = (val << shift) >> shift ; - p->mMixBufferV [i] = val ; - } - } - else - { - // BitBufferRead () can't read more than 16 bits at a time so break up the reads - extraBits = chanBits - 16 ; - for (i = 0 ; i < numSamples ; i++) - { - val = (int32_t) BitBufferRead (bits, 16) ; - val = (((uint32_t) val) << 16) >> shift ; - p->mMixBufferU [i] = val | BitBufferRead (bits, (uint8_t) extraBits) ; - - val = (int32_t) BitBufferRead (bits, 16) ; - val = ((uint32_t) val) >> shift ; - p->mMixBufferV [i] = val | BitBufferRead (bits, (uint8_t) extraBits) ; - } - } - - bits1 = chanBits * numSamples ; - bits2 = chanBits * numSamples ; - mixBits = mixRes = 0 ; - bytesShifted = 0 ; - } - - // now read the shifted values into the shift buffer - if (bytesShifted != 0) - { - shift = bytesShifted * 8 ; - //Assert (shift <= 16) ; - - for (i = 0 ; i < (numSamples * 2) ; i += 2) - { - p->u.mShiftBuffer [i + 0] = (uint16_t) BitBufferRead (&shiftBits, (uint8_t) shift) ; - p->u.mShiftBuffer [i + 1] = (uint16_t) BitBufferRead (&shiftBits, (uint8_t) shift) ; - } - } - - // un-mix the data and convert to output format - // - note that mixRes = 0 means just interleave so we use that path for uncompressed frames - switch (p->mConfig.bitDepth) - { - case 16: - out32 = sampleBuffer + channelIndex ; - unmix16 (p->mMixBufferU, p->mMixBufferV, out32, numChannels, numSamples, mixBits, mixRes) ; - break ; - case 20: - out32 = sampleBuffer + channelIndex ; - unmix20 (p->mMixBufferU, p->mMixBufferV, out32, numChannels, numSamples, mixBits, mixRes) ; - break ; - case 24: - out32 = sampleBuffer + channelIndex ; - unmix24 (p->mMixBufferU, p->mMixBufferV, out32, numChannels, numSamples, - mixBits, mixRes, p->u.mShiftBuffer, bytesShifted) ; - break ; - case 32: - out32 = sampleBuffer + channelIndex ; - unmix32 (p->mMixBufferU, p->mMixBufferV, out32, numChannels, numSamples, - mixBits, mixRes, p->u.mShiftBuffer, bytesShifted) ; - break ; - } - - channelIndex += 2 ; - *outNumSamples = numSamples ; - break ; - } - - case ID_CCE: - case ID_PCE: - { - // unsupported element, bail - //AssertNoErr (tag) ; - status = kALAC_UnsupportedElement ; - break ; - } - - case ID_DSE: - { - // data stream element -- parse but ignore - status = alac_data_stream_element (bits) ; - break ; - } - - case ID_FIL: - { - // fill element -- parse but ignore - status = alac_fill_element (bits) ; - break ; - } - - case ID_END: - { - // frame end, all done so byte align the frame and check for overruns - BitBufferByteAlign (bits, false) ; - //Assert (bits->cur == bits->end) ; - goto Exit ; - } - } - -#if 1 // ! DEBUG - // if we've decoded all of our channels, bail (but not in debug b/c we want to know if we're seeing bad bits) - // - this also protects us if the config does not match the bitstream or crap data bits follow the audio bits - if (channelIndex >= numChannels) - break ; -#endif - } - -NoMoreChannels: - - // if we get here and haven't decoded all of the requested channels, fill the remaining channels with zeros - for ( ; channelIndex < numChannels ; channelIndex++) - { - int32_t * fill32 = sampleBuffer + channelIndex ; - Zero32 (fill32, numSamples, numChannels) ; - } - -Exit: - return status ; -} - -#if PRAGMA_MARK -#pragma mark - -#endif - -/* - FillElement () - - they're just filler so we don't need 'em -*/ -static int32_t -alac_fill_element (struct BitBuffer * bits) -{ - int16_t count ; - - // 4-bit count or (4-bit + 8-bit count) if 4-bit count == 15 - // - plus this weird -1 thing I still don't fully understand - count = BitBufferReadSmall (bits, 4) ; - if (count == 15) - count += (int16_t) BitBufferReadSmall (bits, 8) - 1 ; - - BitBufferAdvance (bits, count * 8) ; - - RequireAction (bits->cur <= bits->end, return kALAC_ParamError ;) ; - - return ALAC_noErr ; -} - -/* - DataStreamElement () - - we don't care about data stream elements so just skip them -*/ -static int32_t -alac_data_stream_element (struct BitBuffer * bits) -{ - int32_t data_byte_align_flag ; - uint16_t count ; - - // the tag associates this data stream element with a given audio element - - /* element_instance_tag = */ BitBufferReadSmall (bits, 4) ; - - data_byte_align_flag = BitBufferReadOne (bits) ; - - // 8-bit count or (8-bit + 8-bit count) if 8-bit count == 255 - count = BitBufferReadSmall (bits, 8) ; - if (count == 255) - count += BitBufferReadSmall (bits, 8) ; - - // the align flag means the bitstream should be byte-aligned before reading the following data bytes - if (data_byte_align_flag) - BitBufferByteAlign (bits, false) ; - - // skip the data bytes - BitBufferAdvance (bits, count * 8) ; - - RequireAction (bits->cur <= bits->end, return kALAC_ParamError ;) ; - - return ALAC_noErr ; -} - -/* - ZeroN () - - helper routines to clear out output channel buffers when decoding fewer channels than requested -*/ -static void Zero32 (int32_t * buffer, uint32_t numItems, uint32_t stride) -{ - if (stride == 1) - { - memset (buffer, 0, numItems * sizeof (int32_t)) ; - } - else - { - for (uint32_t indx = 0 ; indx < (numItems * stride) ; indx += stride) - buffer [indx] = 0 ; - } -} diff --git a/Engine/lib/libsndfile/src/ALAC/alac_decoder.h b/Engine/lib/libsndfile/src/ALAC/alac_decoder.h deleted file mode 100644 index 8a4359226..000000000 --- a/Engine/lib/libsndfile/src/ALAC/alac_decoder.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: alac_decoder.h -*/ - -#ifndef ALAC_DECODER_H -#define ALAC_DECODER_H - -#include - -#include "ALACAudioTypes.h" - -typedef enum -{ - false = 0, - ALAC_TRUE = 1 -} bool ; - -struct BitBuffer ; - -typedef struct alac_decoder -{ - // decoding parameters (public for use in the analyzer) - ALACSpecificConfig mConfig ; - - uint16_t mActiveElements ; - - // decoding buffers - int32_t * mMixBufferU ; - int32_t * mMixBufferV ; - int32_t * mPredictor ; - uint16_t * mShiftBuffer ; // note: this points to mPredictor's memory but different - // variable for clarity and type difference -} alac_decoder ; - -alac_decoder * alac_decoder_new (void) ; -void alac_decoder_delete (alac_decoder *) ; - -int32_t alac_init (alac_decoder *p, void * inMagicCookie, uint32_t inMagicCookieSize) ; -int32_t alac_decode (alac_decoder *, struct BitBuffer * bits, uint8_t * sampleBuffer, uint32_t numSamples, uint32_t numChannels, uint32_t * outNumSamples) ; - -#endif /* ALAC_DECODER_H */ diff --git a/Engine/lib/libsndfile/src/ALAC/alac_encoder.c b/Engine/lib/libsndfile/src/ALAC/alac_encoder.c deleted file mode 100644 index 599399afe..000000000 --- a/Engine/lib/libsndfile/src/ALAC/alac_encoder.c +++ /dev/null @@ -1,1333 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * Copyright (C) 2012-2015 Erik de Castro Lopo - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: ALACEncoder.cpp -*/ - -// build stuff -#define VERBOSE_DEBUG 0 -#define DebugMsg printf - -// headers -#include -#include -#include - -#include "sfendian.h" - -#include "alac_codec.h" - -#include "aglib.h" -#include "dplib.h" -#include "matrixlib.h" - -#include "ALACBitUtilities.h" -#include "ALACAudioTypes.h" -#include "EndianPortable.h" - -typedef enum -{ - false = 0, - true = 1 -} bool ; - -static void GetConfig (ALAC_ENCODER *p, ALACSpecificConfig * config) ; - -static int32_t EncodeStereo (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) ; -static int32_t EncodeStereoFast (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) ; -static int32_t EncodeStereoEscape (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * input, uint32_t stride, uint32_t numSamples) ; -static int32_t EncodeMono (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * input, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) ; - - - -// Note: in C you can't typecast to a 2-dimensional array pointer but that's what we need when -// picking which coefs to use so we declare this typedef b/c we *can* typecast to this type -typedef int16_t (*SearchCoefs) [kALACMaxCoefs] ; - -// defines/constants -const uint32_t kALACEncoderMagic = MAKE_MARKER ('d', 'p', 'g', 'e') ; -const uint32_t kMaxSampleSize = 32 ; // max allowed bit width is 32 -const uint32_t kDefaultMixBits = 2 ; -const uint32_t kDefaultMixRes = 0 ; -const uint32_t kMaxRes = 4 ; -const uint32_t kDefaultNumUV = 8 ; -const uint32_t kMinUV = 4 ; -const uint32_t kMaxUV = 8 ; - -// static functions -#if VERBOSE_DEBUG -static void AddFiller (BitBuffer * bits, int32_t numBytes) ; -#endif - - -/* - Map Format: 3-bit field per channel which is the same as the "element tag" that should be placed - at the beginning of the frame for that channel. Indicates whether SCE, CPE, or LFE. - Each particular field is accessed via the current channel indx. Note that the channel - indx increments by two for channel pairs. - - For example: - - C L R 3-channel input = (ID_CPE << 3) | (ID_SCE) - indx 0 value = (map & (0x7ul << (0 * 3))) >> (0 * 3) - indx 1 value = (map & (0x7ul << (1 * 3))) >> (1 * 3) - - C L R Ls Rs LFE 5.1-channel input = (ID_LFE << 15) | (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE) - indx 0 value = (map & (0x7ul << (0 * 3))) >> (0 * 3) - indx 1 value = (map & (0x7ul << (1 * 3))) >> (1 * 3) - indx 3 value = (map & (0x7ul << (3 * 3))) >> (3 * 3) - indx 5 value = (map & (0x7ul << (5 * 3))) >> (5 * 3) - indx 7 value = (map & (0x7ul << (7 * 3))) >> (7 * 3) -*/ -static const uint32_t sChannelMaps [kALACMaxChannels] = -{ - ID_SCE, - ID_CPE, - (ID_CPE << 3) | (ID_SCE), - (ID_SCE << 9) | (ID_CPE << 3) | (ID_SCE), - (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE), - (ID_SCE << 15) | (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE), - (ID_SCE << 18) | (ID_SCE << 15) | (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE), - (ID_SCE << 21) | (ID_CPE << 15) | (ID_CPE << 9) | (ID_CPE << 3) | (ID_SCE) -} ; - -#if PRAGMA_MARK -#pragma mark - -#endif - -void -alac_set_fastmode (ALAC_ENCODER * p, int32_t fast) -{ - p->mFastMode = fast ; -} - - -/* - HEADER SPECIFICATION - - For every segment we adopt the following header: - - 1 byte reserved (always 0) - 1 byte flags (see below) - [4 byte frame length] (optional, see below) - ---Next, the per-segment ALAC parameters--- - 1 byte mixBits (middle-side parameter) - 1 byte mixRes (middle-side parameter, interpreted as signed char) - - 1 byte shiftU (4 bits modeU, 4 bits denShiftU) - 1 byte filterU (3 bits pbFactorU, 5 bits numU) - (numU) shorts (signed DP coefficients for V channel) - ---Next, 2nd-channel ALAC parameters in case of stereo mode--- - 1 byte shiftV (4 bits modeV, 4 bits denShiftV) - 1 byte filterV (3 bits pbFactorV, 5 bits numV) - (numV) shorts (signed DP coefficients for V channel) - ---After this come the shift-off bytes for (>= 24)-bit data (n-byte shift) if indicated--- - ---Then comes the AG-compressor bitstream--- - - - FLAGS - ----- - - The presence of certain flag bits changes the header format such that the parameters might - not even be sent. The currently defined flags format is: - - 0000psse - - where 0 = reserved, must be 0 - p = 1-bit field "partial frame" flag indicating 32-bit frame length follows this byte - ss = 2-bit field indicating "number of shift-off bytes ignored by compression" - e = 1-bit field indicating "escape" - - The "partial frame" flag means that the following segment is not equal to the frame length specified - in the out-of-band decoder configuration. This allows the decoder to deal with end-of-file partial - segments without incurring the 32-bit overhead for each segment. - - The "shift-off" field indicates the number of bytes at the bottom of the word that were passed through - uncompressed. The reason for this is that the entropy inherent in the LS bytes of >= 24-bit words - quite often means that the frame would have to be "escaped" b/c the compressed size would be >= the - uncompressed size. However, by shifting the input values down and running the remaining bits through - the normal compression algorithm, a net win can be achieved. If this field is non-zero, it means that - the shifted-off bytes follow after the parameter section of the header and before the compressed - bitstream. Note that doing this also allows us to use matrixing on 32-bit inputs after one or more - bytes are shifted off the bottom which helps the eventual compression ratio. For stereo channels, - the shifted off bytes are interleaved. - - The "escape" flag means that this segment was not compressed b/c the compressed size would be - >= uncompressed size. In that case, the audio data was passed through uncompressed after the header. - The other header parameter bytes will not be sent. - - - PARAMETERS - ---------- - - If the segment is not a partial or escape segment, the total header size (in bytes) is given exactly by: - - 4 + (2 + 2 * numU) (mono mode) - 4 + (2 + 2 * numV) + (2 + 2 * numV) (stereo mode) - - where the ALAC filter-lengths numU, numV are bounded by a - constant (in the current source, numU, numV <= NUMCOEPAIRS), and - this forces an absolute upper bound on header size. - - Each segment-decode process loads up these bytes from the front of the - local stream, in the above order, then follows with the entropy-encoded - bits for the given segment. - - To generalize middle-side, there are various mixing modes including middle-side, each lossless, - as embodied in the mix () and unmix () functions. These functions exploit a generalized middle-side - transformation: - - u := [(rL + (m-r)R)/m] ; - v := L - R ; - - where [ ] denotes integer floor. The (lossless) inverse is - - L = u + v - [rV/m] ; - R = L - v ; - - In the segment header, m and r are encoded in mixBits and mixRes. - Classical "middle-side" is obtained with m = 2, r = 1, but now - we have more generalized mixes. - - NOTES - ----- - The relevance of the ALAC coefficients is explained in detail - in patent documents. -*/ - -/* - EncodeStereo () - - encode a channel pair -*/ -static int32_t -EncodeStereo (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * inputBuffer, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) -{ - BitBuffer workBits ; - BitBuffer startBits = *bitstream ; // squirrel away copy of current state in case we need to go back and do an escape packet - AGParamRec agParams ; - uint32_t bits1, bits2 ; - uint32_t dilate ; - int32_t mixBits, mixRes, maxRes ; - uint32_t minBits, minBits1, minBits2 ; - uint32_t numU, numV ; - uint32_t mode ; - uint32_t pbFactor ; - uint32_t chanBits ; - uint8_t bytesShifted ; - SearchCoefs coefsU ; - SearchCoefs coefsV ; - uint32_t indx ; - uint8_t partialFrame ; - uint32_t escapeBits ; - bool doEscape ; - int32_t status = ALAC_noErr ; - int32_t bestRes ; - - // make sure we handle this bit-depth before we get going - RequireAction ((p->mBitDepth == 16) || (p->mBitDepth == 20) || (p->mBitDepth == 24) || (p->mBitDepth == 32), return kALAC_ParamError ;) ; - - // reload coefs pointers for this channel pair - // - note that, while you might think they should be re-initialized per block, retaining state across blocks - // actually results in better overall compression - // - strangely, re-using the same coefs for the different passes of the "mixRes" search loop instead of using - // different coefs for the different passes of "mixRes" results in even better compression - coefsU = (SearchCoefs) p->mCoefsU [channelIndex] ; - coefsV = (SearchCoefs) p->mCoefsV [channelIndex] ; - - // matrix encoding adds an extra bit but 32-bit inputs cannot be matrixed b/c 33 is too many - // so enable 16-bit "shift off" and encode in 17-bit mode - // - in addition, 24-bit mode really improves with one byte shifted off - if (p->mBitDepth == 32) - bytesShifted = 2 ; - else if (p->mBitDepth >= 24) - bytesShifted = 1 ; - else - bytesShifted = 0 ; - - chanBits = p->mBitDepth - (bytesShifted * 8) + 1 ; - - // flag whether or not this is a partial frame - partialFrame = (numSamples == p->mFrameSize) ? 0 : 1 ; - - // brute-force encode optimization loop - // - run over variations of the encoding params to find the best choice - mixBits = kDefaultMixBits ; - maxRes = kMaxRes ; - numU = numV = kDefaultNumUV ; - mode = 0 ; - pbFactor = 4 ; - dilate = 8 ; - - minBits = minBits1 = minBits2 = 1ul << 31 ; - - bestRes = p->mLastMixRes [channelIndex] ; - - for (mixRes = 0 ; mixRes <= maxRes ; mixRes++) - { - // mix the stereo inputs - switch (p->mBitDepth) - { - case 16: - mix16 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples / dilate, mixBits, mixRes) ; - break ; - case 20: - mix20 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples / dilate, mixBits, mixRes) ; - break ; - case 24: - // includes extraction of shifted-off bytes - mix24 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples / dilate, - mixBits, mixRes, p->mShiftBufferUV, bytesShifted) ; - break ; - case 32: - // includes extraction of shifted-off bytes - mix32 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples / dilate, - mixBits, mixRes, p->mShiftBufferUV, bytesShifted) ; - break ; - } - - BitBufferInit (&workBits, p->mWorkBuffer, p->mMaxOutputBytes) ; - - // run the dynamic predictors - pc_block (p->mMixBufferU, p->mPredictorU, numSamples / dilate, coefsU [numU - 1], numU, chanBits, DENSHIFT_DEFAULT) ; - pc_block (p->mMixBufferV, p->mPredictorV, numSamples / dilate, coefsV [numV - 1], numV, chanBits, DENSHIFT_DEFAULT) ; - - // run the lossless compressor on each channel - set_ag_params (&agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples / dilate, numSamples / dilate, MAX_RUN_DEFAULT) ; - status = dyn_comp (&agParams, p->mPredictorU, &workBits, numSamples / dilate, chanBits, &bits1) ; - RequireNoErr (status, goto Exit ;) ; - - set_ag_params (&agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples / dilate, numSamples / dilate, MAX_RUN_DEFAULT) ; - status = dyn_comp (&agParams, p->mPredictorV, &workBits, numSamples / dilate, chanBits, &bits2) ; - RequireNoErr (status, goto Exit ;) ; - - // look for best match - if ((bits1 + bits2) < minBits1) - { - minBits1 = bits1 + bits2 ; - bestRes = mixRes ; - } - } - - p->mLastMixRes [channelIndex] = (int16_t) bestRes ; - - // mix the stereo inputs with the current best mixRes - mixRes = p->mLastMixRes [channelIndex] ; - switch (p->mBitDepth) - { - case 16: - mix16 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, mixBits, mixRes) ; - break ; - case 20: - mix20 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, mixBits, mixRes) ; - break ; - case 24: - // also extracts the shifted off bytes into the shift buffers - mix24 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, - mixBits, mixRes, p->mShiftBufferUV, bytesShifted) ; - break ; - case 32: - // also extracts the shifted off bytes into the shift buffers - mix32 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, - mixBits, mixRes, p->mShiftBufferUV, bytesShifted) ; - break ; - } - - // now it's time for the predictor coefficient search loop - numU = numV = kMinUV ; - minBits1 = minBits2 = 1ul << 31 ; - - for (uint32_t numUV = kMinUV ; numUV <= kMaxUV ; numUV += 4) - { - BitBufferInit (&workBits, p->mWorkBuffer, p->mMaxOutputBytes) ; - - dilate = 32 ; - - // run the predictor over the same data multiple times to help it converge - for (uint32_t converge = 0 ; converge < 8 ; converge++) - { - pc_block (p->mMixBufferU, p->mPredictorU, numSamples / dilate, coefsU [numUV-1], numUV, chanBits, DENSHIFT_DEFAULT) ; - pc_block (p->mMixBufferV, p->mPredictorV, numSamples / dilate, coefsV [numUV-1], numUV, chanBits, DENSHIFT_DEFAULT) ; - } - - dilate = 8 ; - - set_ag_params (&agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples / dilate, numSamples / dilate, MAX_RUN_DEFAULT) ; - status = dyn_comp (&agParams, p->mPredictorU, &workBits, numSamples / dilate, chanBits, &bits1) ; - - if ((bits1 * dilate + 16 * numUV) < minBits1) - { - minBits1 = bits1 * dilate + 16 * numUV ; - numU = numUV ; - } - - set_ag_params (&agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples / dilate, numSamples / dilate, MAX_RUN_DEFAULT) ; - status = dyn_comp (&agParams, p->mPredictorV, &workBits, numSamples / dilate, chanBits, &bits2) ; - - if ((bits2 * dilate + 16 * numUV) < minBits2) - { - minBits2 = bits2 * dilate + 16 * numUV ; - numV = numUV ; - } - } - - // test for escape hatch if best calculated compressed size turns out to be more than the input size - minBits = minBits1 + minBits2 + (8 /* mixRes/maxRes/etc. */ * 8) + ((partialFrame == true) ? 32 : 0) ; - if (bytesShifted != 0) - minBits += (numSamples * (bytesShifted * 8) * 2) ; - - escapeBits = (numSamples * p->mBitDepth * 2) + ((partialFrame == true) ? 32 : 0) + (2 * 8) ; /* 2 common header bytes */ - - doEscape = (minBits >= escapeBits) ? true : false ; - - if (doEscape == false) - { - // write bitstream header and coefs - BitBufferWrite (bitstream, 0, 12) ; - BitBufferWrite (bitstream, (partialFrame << 3) | (bytesShifted << 1), 4) ; - if (partialFrame) - BitBufferWrite (bitstream, numSamples, 32) ; - BitBufferWrite (bitstream, mixBits, 8) ; - BitBufferWrite (bitstream, mixRes, 8) ; - - //Assert ((mode < 16) && (DENSHIFT_DEFAULT < 16)) ; - //Assert ((pbFactor < 8) && (numU < 32)) ; - //Assert ((pbFactor < 8) && (numV < 32)) ; - - BitBufferWrite (bitstream, (mode << 4) | DENSHIFT_DEFAULT, 8) ; - BitBufferWrite (bitstream, (pbFactor << 5) | numU, 8) ; - for (indx = 0 ; indx < numU ; indx++) - BitBufferWrite (bitstream, coefsU [numU - 1][indx], 16) ; - - BitBufferWrite (bitstream, (mode << 4) | DENSHIFT_DEFAULT, 8) ; - BitBufferWrite (bitstream, (pbFactor << 5) | numV, 8) ; - for (indx = 0 ; indx < numV ; indx++) - BitBufferWrite (bitstream, coefsV [numV - 1][indx], 16) ; - - // if shift active, write the interleaved shift buffers - if (bytesShifted != 0) - { - uint32_t bitShift = bytesShifted * 8 ; - - //Assert (bitShift <= 16) ; - - for (indx = 0 ; indx < (numSamples * 2) ; indx += 2) - { - uint32_t shiftedVal ; - - shiftedVal = ((uint32_t) p->mShiftBufferUV [indx + 0] << bitShift) | (uint32_t) p->mShiftBufferUV [indx + 1] ; - BitBufferWrite (bitstream, shiftedVal, bitShift * 2) ; - } - } - - // run the dynamic predictor and lossless compression for the "left" channel - // - note: to avoid allocating more buffers, we're mixing and matching between the available buffers instead - // of only using "U" buffers for the U-channel and "V" buffers for the V-channel - if (mode == 0) - { - pc_block (p->mMixBufferU, p->mPredictorU, numSamples, coefsU [numU - 1], numU, chanBits, DENSHIFT_DEFAULT) ; - } - else - { - pc_block (p->mMixBufferU, p->mPredictorV, numSamples, coefsU [numU - 1], numU, chanBits, DENSHIFT_DEFAULT) ; - pc_block (p->mPredictorV, p->mPredictorU, numSamples, NULL, 31, chanBits, 0) ; - } - - set_ag_params (&agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples, numSamples, MAX_RUN_DEFAULT) ; - status = dyn_comp (&agParams, p->mPredictorU, bitstream, numSamples, chanBits, &bits1) ; - RequireNoErr (status, goto Exit ;) ; - - // run the dynamic predictor and lossless compression for the "right" channel - if (mode == 0) - { - pc_block (p->mMixBufferV, p->mPredictorV, numSamples, coefsV [numV - 1], numV, chanBits, DENSHIFT_DEFAULT) ; - } - else - { - pc_block (p->mMixBufferV, p->mPredictorU, numSamples, coefsV [numV - 1], numV, chanBits, DENSHIFT_DEFAULT) ; - pc_block (p->mPredictorU, p->mPredictorV, numSamples, NULL, 31, chanBits, 0) ; - } - - set_ag_params (&agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples, numSamples, MAX_RUN_DEFAULT) ; - status = dyn_comp (&agParams, p->mPredictorV, bitstream, numSamples, chanBits, &bits2) ; - RequireNoErr (status, goto Exit ;) ; - - /* if we happened to create a compressed packet that was actually bigger than an escape packet would be, - chuck it and do an escape packet - */ - minBits = BitBufferGetPosition (bitstream) - BitBufferGetPosition (&startBits) ; - if (minBits >= escapeBits) - { - *bitstream = startBits ; // reset bitstream state - doEscape = true ; - printf ("compressed frame too big: %u vs. %u \n", minBits, escapeBits) ; - } - } - - if (doEscape == true) - { - /* escape */ - status = EncodeStereoEscape (p, bitstream, inputBuffer, stride, numSamples) ; - -#if VERBOSE_DEBUG - DebugMsg ("escape!: %u vs %u\n", minBits, escapeBits) ; -#endif - } - -Exit: - return status ; -} - -/* - EncodeStereoFast () - - encode a channel pair without the search loop for maximum possible speed -*/ -static int32_t -EncodeStereoFast (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * inputBuffer, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) -{ - BitBuffer startBits = *bitstream ; // squirrel away current bit position in case we decide to use escape hatch - AGParamRec agParams ; - uint32_t bits1, bits2 ; - int32_t mixBits, mixRes ; - uint32_t minBits, minBits1, minBits2 ; - uint32_t numU, numV ; - uint32_t mode ; - uint32_t pbFactor ; - uint32_t chanBits ; - uint8_t bytesShifted ; - SearchCoefs coefsU ; - SearchCoefs coefsV ; - uint32_t indx ; - uint8_t partialFrame ; - uint32_t escapeBits ; - bool doEscape ; - int32_t status ; - - // make sure we handle this bit-depth before we get going - RequireAction ((p->mBitDepth == 16) || (p->mBitDepth == 20) || (p->mBitDepth == 24) || (p->mBitDepth == 32), return kALAC_ParamError ;) ; - - // reload coefs pointers for this channel pair - // - note that, while you might think they should be re-initialized per block, retaining state across blocks - // actually results in better overall compression - // - strangely, re-using the same coefs for the different passes of the "mixRes" search loop instead of using - // different coefs for the different passes of "mixRes" results in even better compression - coefsU = (SearchCoefs) p->mCoefsU [channelIndex] ; - coefsV = (SearchCoefs) p->mCoefsV [channelIndex] ; - - // matrix encoding adds an extra bit but 32-bit inputs cannot be matrixed b/c 33 is too many - // so enable 16-bit "shift off" and encode in 17-bit mode - // - in addition, 24-bit mode really improves with one byte shifted off - if (p->mBitDepth == 32) - bytesShifted = 2 ; - else if (p->mBitDepth >= 24) - bytesShifted = 1 ; - else - bytesShifted = 0 ; - - chanBits = p->mBitDepth - (bytesShifted * 8) + 1 ; - - // flag whether or not this is a partial frame - partialFrame = (numSamples == p->mFrameSize) ? 0 : 1 ; - - // set up default encoding parameters for "fast" mode - mixBits = kDefaultMixBits ; - mixRes = kDefaultMixRes ; - numU = numV = kDefaultNumUV ; - mode = 0 ; - pbFactor = 4 ; - - minBits = minBits1 = minBits2 = 1ul << 31 ; - - // mix the stereo inputs with default mixBits/mixRes - switch (p->mBitDepth) - { - case 16: - mix16 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, mixBits, mixRes) ; - break ; - case 20: - mix20 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, mixBits, mixRes) ; - break ; - case 24: - // also extracts the shifted off bytes into the shift buffers - mix24 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, - mixBits, mixRes, p->mShiftBufferUV, bytesShifted) ; - break ; - case 32: - // also extracts the shifted off bytes into the shift buffers - mix32 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, - mixBits, mixRes, p->mShiftBufferUV, bytesShifted) ; - break ; - } - - /* speculatively write the bitstream assuming the compressed version will be smaller */ - - // write bitstream header and coefs - BitBufferWrite (bitstream, 0, 12) ; - BitBufferWrite (bitstream, (partialFrame << 3) | (bytesShifted << 1), 4) ; - if (partialFrame) - BitBufferWrite (bitstream, numSamples, 32) ; - BitBufferWrite (bitstream, mixBits, 8) ; - BitBufferWrite (bitstream, mixRes, 8) ; - - //Assert ((mode < 16) && (DENSHIFT_DEFAULT < 16)) ; - //Assert ((pbFactor < 8) && (numU < 32)) ; - //Assert ((pbFactor < 8) && (numV < 32)) ; - - BitBufferWrite (bitstream, (mode << 4) | DENSHIFT_DEFAULT, 8) ; - BitBufferWrite (bitstream, (pbFactor << 5) | numU, 8) ; - for (indx = 0 ; indx < numU ; indx++) - BitBufferWrite (bitstream, coefsU [numU - 1][indx], 16) ; - - BitBufferWrite (bitstream, (mode << 4) | DENSHIFT_DEFAULT, 8) ; - BitBufferWrite (bitstream, (pbFactor << 5) | numV, 8) ; - for (indx = 0 ; indx < numV ; indx++) - BitBufferWrite (bitstream, coefsV [numV - 1][indx], 16) ; - - // if shift active, write the interleaved shift buffers - if (bytesShifted != 0) - { - uint32_t bitShift = bytesShifted * 8 ; - - //Assert (bitShift <= 16) ; - - for (indx = 0 ; indx < (numSamples * 2) ; indx += 2) - { - uint32_t shiftedVal ; - - shiftedVal = ((uint32_t) p->mShiftBufferUV [indx + 0] << bitShift) | (uint32_t) p->mShiftBufferUV [indx + 1] ; - BitBufferWrite (bitstream, shiftedVal, bitShift * 2) ; - } - } - - // run the dynamic predictor and lossless compression for the "left" channel - // - note: we always use mode 0 in the "fast" path so we don't need the code for mode != 0 - pc_block (p->mMixBufferU, p->mPredictorU, numSamples, coefsU [numU - 1], numU, chanBits, DENSHIFT_DEFAULT) ; - - set_ag_params (&agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples, numSamples, MAX_RUN_DEFAULT) ; - status = dyn_comp (&agParams, p->mPredictorU, bitstream, numSamples, chanBits, &bits1) ; - RequireNoErr (status, goto Exit ;) ; - - // run the dynamic predictor and lossless compression for the "right" channel - pc_block (p->mMixBufferV, p->mPredictorV, numSamples, coefsV [numV - 1], numV, chanBits, DENSHIFT_DEFAULT) ; - - set_ag_params (&agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples, numSamples, MAX_RUN_DEFAULT) ; - status = dyn_comp (&agParams, p->mPredictorV, bitstream, numSamples, chanBits, &bits2) ; - RequireNoErr (status, goto Exit ;) ; - - // do bit requirement calculations - minBits1 = bits1 + (numU * sizeof (int16_t) * 8) ; - minBits2 = bits2 + (numV * sizeof (int16_t) * 8) ; - - // test for escape hatch if best calculated compressed size turns out to be more than the input size - minBits = minBits1 + minBits2 + (8 /* mixRes/maxRes/etc. */ * 8) + ((partialFrame == true) ? 32 : 0) ; - if (bytesShifted != 0) - minBits += (numSamples * (bytesShifted * 8) * 2) ; - - escapeBits = (numSamples * p->mBitDepth * 2) + ((partialFrame == true) ? 32 : 0) + (2 * 8) ; /* 2 common header bytes */ - - doEscape = (minBits >= escapeBits) ? true : false ; - - if (doEscape == false) - { - /* if we happened to create a compressed packet that was actually bigger than an escape packet would be, - chuck it and do an escape packet - */ - minBits = BitBufferGetPosition (bitstream) - BitBufferGetPosition (&startBits) ; - if (minBits >= escapeBits) - { - doEscape = true ; - printf ("compressed frame too big: %u vs. %u\n", minBits, escapeBits) ; - } - - } - - if (doEscape == true) - { - /* escape */ - - // reset bitstream position since we speculatively wrote the compressed version - *bitstream = startBits ; - - // write escape frame - status = EncodeStereoEscape (p, bitstream, inputBuffer, stride, numSamples) ; - -#if VERBOSE_DEBUG - DebugMsg ("escape!: %u vs %u\n", minBits, (numSamples * p->mBitDepth * 2)) ; -#endif - } - -Exit: - return status ; -} - -/* - EncodeStereoEscape () - - encode stereo escape frame -*/ -static int32_t -EncodeStereoEscape (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * inputBuffer, uint32_t stride, uint32_t numSamples) -{ - uint8_t partialFrame ; - uint32_t indx ; - - // flag whether or not this is a partial frame - partialFrame = (numSamples == p->mFrameSize) ? 0 : 1 ; - - // write bitstream header - BitBufferWrite (bitstream, 0, 12) ; - BitBufferWrite (bitstream, (partialFrame << 3) | 1, 4) ; // LSB = 1 means "frame not compressed" - if (partialFrame) - BitBufferWrite (bitstream, numSamples, 32) ; - - // just copy the input data to the output buffer - switch (p->mBitDepth) - { - case 16: - for (indx = 0 ; indx < (numSamples * stride) ; indx += stride) - { - BitBufferWrite (bitstream, inputBuffer [indx + 0] >> 16, 16) ; - BitBufferWrite (bitstream, inputBuffer [indx + 1] >> 16, 16) ; - } - break ; - case 20: - for (indx = 0 ; indx < (numSamples * stride) ; indx += stride) - { - BitBufferWrite (bitstream, inputBuffer [indx + 0] >> 12, 16) ; - BitBufferWrite (bitstream, inputBuffer [indx + 1] >> 12, 16) ; - } - break ; - case 24: - // mix24 () with mixres param = 0 means de-interleave so use it to simplify things - mix24 (inputBuffer, stride, p->mMixBufferU, p->mMixBufferV, numSamples, 0, 0, p->mShiftBufferUV, 0) ; - for (indx = 0 ; indx < numSamples ; indx++) - { - BitBufferWrite (bitstream, p->mMixBufferU [indx] >> 8, 24) ; - BitBufferWrite (bitstream, p->mMixBufferV [indx] >> 8, 24) ; - } - break ; - case 32: - for (indx = 0 ; indx < (numSamples * stride) ; indx += stride) - { - BitBufferWrite (bitstream, inputBuffer [indx + 0], 32) ; - BitBufferWrite (bitstream, inputBuffer [indx + 1], 32) ; - } - break ; - } - - return ALAC_noErr ; -} - -/* - EncodeMono () - - encode a mono input buffer -*/ -static int32_t -EncodeMono (ALAC_ENCODER *p, struct BitBuffer * bitstream, const int32_t * inputBuffer, uint32_t stride, uint32_t channelIndex, uint32_t numSamples) -{ - BitBuffer startBits = *bitstream ; // squirrel away copy of current state in case we need to go back and do an escape packet - AGParamRec agParams ; - uint32_t bits1 ; - uint32_t numU ; - SearchCoefs coefsU ; - uint32_t dilate ; - uint32_t minBits, bestU ; - uint32_t minU, maxU ; - uint32_t indx, indx2 ; - uint8_t bytesShifted ; - uint32_t shift ; - uint32_t mask ; - uint32_t chanBits ; - uint8_t pbFactor ; - uint8_t partialFrame ; - uint32_t escapeBits ; - bool doEscape ; - int32_t status = ALAC_noErr ; - - - // make sure we handle this bit-depth before we get going - RequireAction ((p->mBitDepth == 16) || (p->mBitDepth == 20) || (p->mBitDepth == 24) || (p->mBitDepth == 32), return kALAC_ParamError ;) ; - - // reload coefs array from previous frame - coefsU = (SearchCoefs) p->mCoefsU [channelIndex] ; - - // pick bit depth for actual encoding - // - we lop off the lower byte (s) for 24-/32-bit encodings - if (p->mBitDepth == 32) - bytesShifted = 2 ; - else if (p->mBitDepth >= 24) - bytesShifted = 1 ; - else - bytesShifted = 0 ; - - shift = bytesShifted * 8 ; - mask = (1ul << shift) - 1 ; - chanBits = p->mBitDepth - (bytesShifted * 8) ; - - // flag whether or not this is a partial frame - partialFrame = (numSamples == p->mFrameSize) ? 0 : 1 ; - - // convert N-bit data to 32-bit for predictor - switch (p->mBitDepth) - { - case 16: - // convert 16-bit data to 32-bit for predictor - for (indx = 0, indx2 = 0 ; indx < numSamples ; indx++, indx2 += stride) - p->mMixBufferU [indx] = inputBuffer [indx2] >> 16 ; - break ; - - case 20: - // convert 20-bit data to 32-bit for predictor - for (indx = 0, indx2 = 0 ; indx < numSamples ; indx++, indx2 += stride) - p->mMixBufferU [indx] = inputBuffer [indx2] >> 12 ; - break ; - case 24: - // convert 24-bit data to 32-bit for the predictor and extract the shifted off byte (s) - for (indx = 0, indx2 = 0 ; indx < numSamples ; indx++, indx2 += stride) - { - p->mMixBufferU [indx] = inputBuffer [indx2] >> 8 ; - p->mShiftBufferUV [indx] = (uint16_t) (p->mMixBufferU [indx] & mask) ; - p->mMixBufferU [indx] >>= shift ; - } - - break ; - case 32: - // just copy the 32-bit input data for the predictor and extract the shifted off byte (s) - for (indx = 0, indx2 = 0 ; indx < numSamples ; indx++, indx2 += stride) - { - p->mShiftBufferUV [indx] = (uint16_t) (inputBuffer [indx2] & mask) ; - p->mMixBufferU [indx] = inputBuffer [indx2] >> shift ; - } - break ; - } - - // brute-force encode optimization loop (implied "encode depth" of 0 if comparing to cmd line tool) - // - run over variations of the encoding params to find the best choice - minU = 4 ; - maxU = 8 ; - minBits = 1ul << 31 ; - pbFactor = 4 ; - - bestU = minU ; - - for (numU = minU ; numU <= maxU ; numU += 4) - { - BitBuffer workBits ; - uint32_t numBits ; - - BitBufferInit (&workBits, p->mWorkBuffer, p->mMaxOutputBytes) ; - - dilate = 32 ; - for (uint32_t converge = 0 ; converge < 7 ; converge++) - pc_block (p->mMixBufferU, p->mPredictorU, numSamples / dilate, coefsU [numU - 1], numU, chanBits, DENSHIFT_DEFAULT) ; - - dilate = 8 ; - pc_block (p->mMixBufferU, p->mPredictorU, numSamples / dilate, coefsU [numU - 1], numU, chanBits, DENSHIFT_DEFAULT) ; - - set_ag_params (&agParams, MB0, (pbFactor * PB0) / 4, KB0, numSamples / dilate, numSamples / dilate, MAX_RUN_DEFAULT) ; - status = dyn_comp (&agParams, p->mPredictorU, &workBits, numSamples / dilate, chanBits, &bits1) ; - RequireNoErr (status, goto Exit ;) ; - - numBits = (dilate * bits1) + (16 * numU) ; - if (numBits < minBits) - { - bestU = numU ; - minBits = numBits ; - } - } - - // test for escape hatch if best calculated compressed size turns out to be more than the input size - // - first, add bits for the header bytes mixRes/maxRes/shiftU/filterU - minBits += (4 /* mixRes/maxRes/etc. */ * 8) + ((partialFrame == true) ? 32 : 0) ; - if (bytesShifted != 0) - minBits += (numSamples * (bytesShifted * 8)) ; - - escapeBits = (numSamples * p->mBitDepth) + ((partialFrame == true) ? 32 : 0) + (2 * 8) ; /* 2 common header bytes */ - - doEscape = (minBits >= escapeBits) ? true : false ; - - if (doEscape == false) - { - // write bitstream header - BitBufferWrite (bitstream, 0, 12) ; - BitBufferWrite (bitstream, (partialFrame << 3) | (bytesShifted << 1), 4) ; - if (partialFrame) - BitBufferWrite (bitstream, numSamples, 32) ; - BitBufferWrite (bitstream, 0, 16) ; // mixBits = mixRes = 0 - - // write the params and predictor coefs - numU = bestU ; - BitBufferWrite (bitstream, (0 << 4) | DENSHIFT_DEFAULT, 8) ; // modeU = 0 - BitBufferWrite (bitstream, (pbFactor << 5) | numU, 8) ; - for (indx = 0 ; indx < numU ; indx++) - BitBufferWrite (bitstream, coefsU [numU-1][indx], 16) ; - - // if shift active, write the interleaved shift buffers - if (bytesShifted != 0) - { - for (indx = 0 ; indx < numSamples ; indx++) - BitBufferWrite (bitstream, p->mShiftBufferUV [indx], shift) ; - } - - // run the dynamic predictor with the best result - pc_block (p->mMixBufferU, p->mPredictorU, numSamples, coefsU [numU-1], numU, chanBits, DENSHIFT_DEFAULT) ; - - // do lossless compression - set_standard_ag_params (&agParams, numSamples, numSamples) ; - status = dyn_comp (&agParams, p->mPredictorU, bitstream, numSamples, chanBits, &bits1) ; - //AssertNoErr (status) ; - - - /* if we happened to create a compressed packet that was actually bigger than an escape packet would be, - chuck it and do an escape packet - */ - minBits = BitBufferGetPosition (bitstream) - BitBufferGetPosition (&startBits) ; - if (minBits >= escapeBits) - { - *bitstream = startBits ; // reset bitstream state - doEscape = true ; - printf ("compressed frame too big: %u vs. %u\n", minBits, escapeBits) ; - } - } - - if (doEscape == true) - { - // write bitstream header and coefs - BitBufferWrite (bitstream, 0, 12) ; - BitBufferWrite (bitstream, (partialFrame << 3) | 1, 4) ; // LSB = 1 means "frame not compressed" - if (partialFrame) - BitBufferWrite (bitstream, numSamples, 32) ; - - // just copy the input data to the output buffer - switch (p->mBitDepth) - { - case 16: - for (indx = 0 ; indx < (numSamples * stride) ; indx += stride) - BitBufferWrite (bitstream, inputBuffer [indx] >> 16, 16) ; - break ; - case 20: - // convert 20-bit data to 32-bit for simplicity - for (indx = 0 ; indx < (numSamples * stride) ; indx += stride) - BitBufferWrite (bitstream, inputBuffer [indx] >> 12, 20) ; - break ; - case 24: - // convert 24-bit data to 32-bit for simplicity - for (indx = 0, indx2 = 0 ; indx < numSamples ; indx++, indx2 += stride) - { - p->mMixBufferU [indx] = inputBuffer [indx2] >> 8 ; - BitBufferWrite (bitstream, p->mMixBufferU [indx], 24) ; - } - break ; - case 32: - for (indx = 0 ; indx < (numSamples * stride) ; indx += stride) - BitBufferWrite (bitstream, inputBuffer [indx], 32) ; - break ; - } -#if VERBOSE_DEBUG - DebugMsg ("escape!: %u vs %u\n", minBits, (numSamples * p->mBitDepth)) ; -#endif - } - -Exit: - return status ; -} - -#if PRAGMA_MARK -#pragma mark - -#endif - -/* - Encode () - - encode the next block of samples -*/ -int32_t -alac_encode (ALAC_ENCODER *p, uint32_t numSamples, - const int32_t * theReadBuffer, unsigned char * theWriteBuffer, uint32_t * ioNumBytes) -{ - uint32_t outputSize ; - BitBuffer bitstream ; - int32_t status ; - uint32_t numChannels = p->mNumChannels ; - - // make sure we handle this bit-depth before we get going - RequireAction ((p->mBitDepth == 16) || (p->mBitDepth == 20) || (p->mBitDepth == 24) || (p->mBitDepth == 32), return kALAC_ParamError ;) ; - - // create a bit buffer structure pointing to our output buffer - BitBufferInit (&bitstream, theWriteBuffer, p->mMaxOutputBytes) ; - - if (numChannels == 2) - { - // add 3-bit frame start tag ID_CPE = channel pair & 4-bit element instance tag = 0 - BitBufferWrite (&bitstream, ID_CPE, 3) ; - BitBufferWrite (&bitstream, 0, 4) ; - - // encode stereo input buffer - if (p->mFastMode == false) - status = EncodeStereo (p, &bitstream, theReadBuffer, 2, 0, numSamples) ; - else - status = EncodeStereoFast (p, &bitstream, theReadBuffer, 2, 0, numSamples) ; - RequireNoErr (status, goto Exit ;) ; - } - else if (numChannels == 1) - { - // add 3-bit frame start tag ID_SCE = mono channel & 4-bit element instance tag = 0 - BitBufferWrite (&bitstream, ID_SCE, 3) ; - BitBufferWrite (&bitstream, 0, 4) ; - - // encode mono input buffer - status = EncodeMono (p, &bitstream, theReadBuffer, 1, 0, numSamples) ; - RequireNoErr (status, goto Exit ;) ; - } - else - { - const int32_t * inputBuffer ; - uint32_t tag ; - uint32_t channelIndex ; - uint8_t stereoElementTag ; - uint8_t monoElementTag ; - uint8_t lfeElementTag ; - - inputBuffer = theReadBuffer ; - - stereoElementTag = 0 ; - monoElementTag = 0 ; - lfeElementTag = 0 ; - - for (channelIndex = 0 ; channelIndex < numChannels ;) - { - tag = (sChannelMaps [numChannels - 1] & (0x7ul << (channelIndex * 3))) >> (channelIndex * 3) ; - - BitBufferWrite (&bitstream, tag, 3) ; - switch (tag) - { - case ID_SCE: - // mono - BitBufferWrite (&bitstream, monoElementTag, 4) ; - - status = EncodeMono (p, &bitstream, inputBuffer, numChannels, channelIndex, numSamples) ; - - inputBuffer += 1 ; - channelIndex++ ; - monoElementTag++ ; - break ; - - case ID_CPE: - // stereo - BitBufferWrite (&bitstream, stereoElementTag, 4) ; - - status = EncodeStereo (p, &bitstream, inputBuffer, numChannels, channelIndex, numSamples) ; - - inputBuffer += 2 ; - channelIndex += 2 ; - stereoElementTag++ ; - break ; - - case ID_LFE: - // LFE channel (subwoofer) - BitBufferWrite (&bitstream, lfeElementTag, 4) ; - - status = EncodeMono (p, &bitstream, inputBuffer, numChannels, channelIndex, numSamples) ; - - inputBuffer += 1 ; - channelIndex++ ; - lfeElementTag++ ; - break ; - - default: - printf ("That ain't right! (%u)\n", tag) ; - status = kALAC_ParamError ; - goto Exit ; - } - - RequireNoErr (status, goto Exit ;) ; - } - } - -#if VERBOSE_DEBUG -{ - // if there is room left in the output buffer, add some random fill data to test decoder - int32_t bitsLeft ; - int32_t bytesLeft ; - - bitsLeft = BitBufferGetPosition (&bitstream) - 3 ; // - 3 for ID_END tag - bytesLeft = bitstream.byteSize - ((bitsLeft + 7) / 8) ; - - if ((bytesLeft > 20) && ((bytesLeft & 0x4u) != 0)) - AddFiller (&bitstream, bytesLeft) ; -} -#endif - - // add 3-bit frame end tag: ID_END - BitBufferWrite (&bitstream, ID_END, 3) ; - - // byte-align the output data - BitBufferByteAlign (&bitstream, true) ; - - outputSize = BitBufferGetPosition (&bitstream) / 8 ; - //Assert (outputSize <= mMaxOutputBytes) ; - - - // all good, let iTunes know what happened and remember the total number of input sample frames - *ioNumBytes = outputSize ; - //mEncodedFrames += encodeMsg->numInputSamples ; - - // gather encoding stats - p->mTotalBytesGenerated += outputSize ; - p->mMaxFrameBytes = MAX (p->mMaxFrameBytes, outputSize) ; - - status = ALAC_noErr ; - -Exit: - return status ; -} - - -#if PRAGMA_MARK -#pragma mark - -#endif - -/* - GetConfig () -*/ -void -GetConfig (ALAC_ENCODER *p, ALACSpecificConfig * config) -{ - config->frameLength = Swap32NtoB (p->mFrameSize) ; - config->compatibleVersion = (uint8_t) kALACCompatibleVersion ; - config->bitDepth = (uint8_t) p->mBitDepth ; - config->pb = (uint8_t) PB0 ; - config->kb = (uint8_t) KB0 ; - config->mb = (uint8_t) MB0 ; - config->numChannels = (uint8_t) p->mNumChannels ; - config->maxRun = Swap16NtoB ((uint16_t) MAX_RUN_DEFAULT) ; - config->maxFrameBytes = Swap32NtoB (p->mMaxFrameBytes) ; - config->avgBitRate = Swap32NtoB (p->mAvgBitRate) ; - config->sampleRate = Swap32NtoB (p->mOutputSampleRate) ; -} - -uint32_t -alac_get_magic_cookie_size (uint32_t inNumChannels) -{ - if (inNumChannels > 2) - { - return sizeof (ALACSpecificConfig) + kChannelAtomSize + sizeof (ALACAudioChannelLayout) ; - } - else - { - return sizeof (ALACSpecificConfig) ; - } -} - -void -alac_get_magic_cookie (ALAC_ENCODER *p, void * outCookie, uint32_t * ioSize) -{ - ALACSpecificConfig theConfig = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ; - ALACAudioChannelLayout theChannelLayout = { 0, 0, 0 } ; - uint8_t theChannelAtom [kChannelAtomSize] = { 0, 0, 0, 0, 'c', 'h', 'a', 'n', 0, 0, 0, 0 } ; - uint32_t theCookieSize = sizeof (ALACSpecificConfig) ; - uint8_t * theCookiePointer = (uint8_t *) outCookie ; - - GetConfig (p, &theConfig) ; - if (theConfig.numChannels > 2) - { - theChannelLayout.mChannelLayoutTag = Swap32NtoB (ALACChannelLayoutTags [theConfig.numChannels - 1]) ; - theCookieSize += (sizeof (ALACAudioChannelLayout) + kChannelAtomSize) ; - } - if (*ioSize >= theCookieSize) - { - memcpy (theCookiePointer, &theConfig, sizeof (ALACSpecificConfig)) ; - theChannelAtom [3] = (sizeof (ALACAudioChannelLayout) + kChannelAtomSize) ; - if (theConfig.numChannels > 2) - { - theCookiePointer += sizeof (ALACSpecificConfig) ; - memcpy (theCookiePointer, theChannelAtom, kChannelAtomSize) ; - theCookiePointer += kChannelAtomSize ; - memcpy (theCookiePointer, &theChannelLayout, sizeof (ALACAudioChannelLayout)) ; - } - *ioSize = theCookieSize ; - } - else - { - *ioSize = 0 ; // no incomplete cookies - } -} - -/* - alac_encoder_init () - - initialize the encoder component with the current config -*/ -int32_t -alac_encoder_init (ALAC_ENCODER *p, uint32_t samplerate, uint32_t channels, uint32_t format_flags, uint32_t frameSize) -{ - int32_t status ; - - p->mFrameSize = (frameSize > 0 && frameSize <= ALAC_FRAME_LENGTH) ? frameSize : ALAC_FRAME_LENGTH ; - - p->mOutputSampleRate = samplerate ; - p->mNumChannels = channels ; - switch (format_flags) - { - case 1: - p->mBitDepth = 16 ; - break ; - case 2: - p->mBitDepth = 20 ; - break ; - case 3: - p->mBitDepth = 24 ; - break ; - case 4: - p->mBitDepth = 32 ; - break ; - default: - break ; - } - - // set up default encoding parameters and state - // - note: mFrameSize is set in the constructor or via alac_set_frame_size () which must be called before this routine - for (uint32_t indx = 0 ; indx < kALACMaxChannels ; indx++) - p->mLastMixRes [indx] = kDefaultMixRes ; - - // the maximum output frame size can be no bigger than (samplesPerBlock * numChannels * ((10 + sampleSize)/8) + 1) - // but note that this can be bigger than the input size! - // - since we don't yet know what our input format will be, use our max allowed sample size in the calculation - p->mMaxOutputBytes = p->mFrameSize * p->mNumChannels * ((10 + kMaxSampleSize) / 8) + 1 ; - - status = ALAC_noErr ; - - // initialize coefs arrays once b/c retaining state across blocks actually improves the encode ratio - for (int32_t channel = 0 ; channel < (int32_t) p->mNumChannels ; channel++) - { - for (int32_t search = 0 ; search < kALACMaxSearches ; search++) - { - init_coefs (p->mCoefsU [channel][search], DENSHIFT_DEFAULT, kALACMaxCoefs) ; - init_coefs (p->mCoefsV [channel][search], DENSHIFT_DEFAULT, kALACMaxCoefs) ; - } - } - - return status ; -} - -/* - alac_get_source_format () - - given the input format, return one of our supported formats -*/ -void -alac_get_source_format (ALAC_ENCODER *p, const AudioFormatDescription * source, AudioFormatDescription * output) -{ - (void) output ; - // default is 16-bit native endian - // - note: for float input we assume that's coming from one of our decoders (mp3, aac) so it only makes sense - // to encode to 16-bit since the source was lossy in the first place - // - note: if not a supported bit depth, find the closest supported bit depth to the input one - if ((source->mFormatID != kALACFormatLinearPCM) || ((source->mFormatFlags & kALACFormatFlagIsFloat) != 0) || (source->mBitsPerChannel <= 16)) - p->mBitDepth = 16 ; - else if (source->mBitsPerChannel <= 20) - p->mBitDepth = 20 ; - else if (source->mBitsPerChannel <= 24) - p->mBitDepth = 24 ; - else - p->mBitDepth = 32 ; - - // we support 16/20/24/32-bit integer data at any sample rate and our target number of channels - // and sample rate were specified when we were configured - /* - MakeUncompressedAudioFormat (mNumChannels, (float) mOutputSampleRate, mBitDepth, kAudioFormatFlagsNativeIntegerPacked, output) ; - */ -} - - - -#if VERBOSE_DEBUG - -#if PRAGMA_MARK -#pragma mark - -#endif - -/* - AddFiller () - - add fill and data stream elements to the bitstream to test the decoder -*/ -static void AddFiller (BitBuffer * bits, int32_t numBytes) -{ - uint8_t tag ; - int32_t indx ; - - // out of lameness, subtract 6 bytes to deal with header + alignment as required for fill/data elements - numBytes -= 6 ; - if (numBytes <= 0) - return ; - - // randomly pick Fill or Data Stream Element based on numBytes requested - tag = (numBytes & 0x8) ? ID_FIL : ID_DSE ; - - BitBufferWrite (bits, tag, 3) ; - if (tag == ID_FIL) - { - // can't write more than 269 bytes in a fill element - numBytes = (numBytes > 269) ? 269 : numBytes ; - - // fill element = 4-bit size unless >= 15 then 4-bit size + 8-bit extension size - if (numBytes >= 15) - { - uint16_t extensionSize ; - - BitBufferWrite (bits, 15, 4) ; - - // 8-bit extension count field is "extra + 1" which is weird but I didn't define the syntax - // - otherwise, there's no way to represent 15 - // - for example, to really mean 15 bytes you must encode extensionSize = 1 - // - why it's not like data stream elements I have no idea - extensionSize = (numBytes - 15) + 1 ; - //Assert (extensionSize <= 255) ; - BitBufferWrite (bits, extensionSize, 8) ; - } - else - BitBufferWrite (bits, numBytes, 4) ; - - BitBufferWrite (bits, 0x10, 8) ; // extension_type = FILL_DATA = b0001 or'ed with fill_nibble = b0000 - for (indx = 0 ; indx < (numBytes - 1) ; indx++) - BitBufferWrite (bits, 0xa5, 8) ; // fill_byte = b10100101 = 0xa5 - } - else - { - // can't write more than 510 bytes in a data stream element - numBytes = (numBytes > 510) ? 510 : numBytes ; - - BitBufferWrite (bits, 0, 4) ; // element instance tag - BitBufferWrite (bits, 1, 1) ; // byte-align flag = true - - // data stream element = 8-bit size unless >= 255 then 8-bit size + 8-bit size - if (numBytes >= 255) - { - BitBufferWrite (bits, 255, 8) ; - BitBufferWrite (bits, numBytes - 255, 8) ; - } - else - BitBufferWrite (bits, numBytes, 8) ; - - BitBufferByteAlign (bits, true) ; // byte-align with zeros - - for (indx = 0 ; indx < numBytes ; indx++) - BitBufferWrite (bits, 0x5a, 8) ; - } -} - -#endif /* VERBOSE_DEBUG */ diff --git a/Engine/lib/libsndfile/src/ALAC/dp_dec.c b/Engine/lib/libsndfile/src/ALAC/dp_dec.c deleted file mode 100644 index 0d1c10d53..000000000 --- a/Engine/lib/libsndfile/src/ALAC/dp_dec.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: dp_dec.c - - Contains: Dynamic Predictor decode routines - - Copyright: (c) 2001-2011 Apple, Inc. -*/ - - -#include - -#include "dplib.h" -#include "shift.h" - -#if __GNUC__ -#define ALWAYS_INLINE __attribute__ ((always_inline)) -#elif defined _MSC_VER -#define ALWAYS_INLINE __forceinline -#else -#define ALWAYS_INLINE -#endif - -#define LOOP_ALIGN - -static inline int32_t ALWAYS_INLINE -sign_of_int (int32_t i) -{ - int32_t negishift ; - - negishift = ((uint32_t) - i) >> 31 ; - return negishift | (i >> 31) ; -} - -void -unpc_block (const int32_t * pc1, int32_t * out, int32_t num, int16_t * coefs, int32_t numactive, uint32_t chanbits, uint32_t denshift) -{ - register int16_t a0, a1, a2, a3 ; - register int32_t b0, b1, b2, b3 ; - int32_t j, k, lim ; - int32_t sum1, sg, sgn, top, dd ; - int32_t * pout ; - int32_t del, del0 ; - uint32_t chanshift = 32 - chanbits ; - int32_t denhalf = 1 << (denshift - 1) ; - - out [0] = pc1 [0] ; - if (numactive == 0) - { - // just copy if numactive == 0 (but don't bother if in/out pointers the same) - if ((num > 1) && (pc1 != out)) - memcpy (&out [1], &pc1 [1], (num - 1) * sizeof (int32_t)) ; - return ; - } - if (numactive == 31) - { - // short-circuit if numactive == 31 - int32_t prev ; - - /* this code is written such that the in/out buffers can be the same - to conserve buffer space on embedded devices like the iPod - - (original code) - for (j = 1 ; j < num ; j++) - del = pc1 [j] + out [j-1] ; - out [j] = (del << chanshift) >> chanshift ; - */ - prev = out [0] ; - for (j = 1 ; j < num ; j++) - { - del = pc1 [j] + prev ; - prev = (del << chanshift) >> chanshift ; - out [j] = prev ; - } - return ; - } - - for (j = 1 ; j <= numactive ; j++) - { - del = pc1 [j] + out [j-1] ; - out [j] = arith_shift_left (del, chanshift) >> chanshift ; - } - - lim = numactive + 1 ; - - if (numactive == 4) - { - // optimization for numactive == 4 - register int16_t ia0, ia1, ia2, ia3 ; - register int32_t ib0, ib1, ib2, ib3 ; - - ia0 = coefs [0] ; - ia1 = coefs [1] ; - ia2 = coefs [2] ; - ia3 = coefs [3] ; - - for (j = lim ; j < num ; j++) - { - LOOP_ALIGN - - top = out [j - lim] ; - pout = out + j - 1 ; - - ib0 = top - pout [0] ; - ib1 = top - pout [-1] ; - ib2 = top - pout [-2] ; - ib3 = top - pout [-3] ; - - sum1 = (denhalf - ia0 * ib0 - ia1 * ib1 - ia2 * ib2 - ia3 * ib3) >> denshift ; - - del = pc1 [j] ; - del0 = del ; - sg = sign_of_int (del) ; - del += top + sum1 ; - - out [j] = arith_shift_left (del, chanshift) >> chanshift ; - - if (sg > 0) - { - sgn = sign_of_int (ib3) ; - ia3 -= sgn ; - del0 -= (4 - 3) * ((sgn * ib3) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (ib2) ; - ia2 -= sgn ; - del0 -= (4 - 2) * ((sgn * ib2) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (ib1) ; - ia1 -= sgn ; - del0 -= (4 - 1) * ((sgn * ib1) >> denshift) ; - if (del0 <= 0) - continue ; - - ia0 -= sign_of_int (ib0) ; - } - else if (sg < 0) - { - // note: to avoid unnecessary negations, we flip the value of "sgn" - sgn = -sign_of_int (ib3) ; - ia3 -= sgn ; - del0 -= (4 - 3) * ((sgn * ib3) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (ib2) ; - ia2 -= sgn ; - del0 -= (4 - 2) * ((sgn * ib2) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (ib1) ; - ia1 -= sgn ; - del0 -= (4 - 1) * ((sgn * ib1) >> denshift) ; - if (del0 >= 0) - continue ; - - ia0 += sign_of_int (ib0) ; - } - } - - coefs [0] = ia0 ; - coefs [1] = ia1 ; - coefs [2] = ia2 ; - coefs [3] = ia3 ; - } - else if (numactive == 8) - { - register int16_t a4, a5, a6, a7 ; - register int32_t b4, b5, b6, b7 ; - - // optimization for numactive == 8 - a0 = coefs [0] ; - a1 = coefs [1] ; - a2 = coefs [2] ; - a3 = coefs [3] ; - a4 = coefs [4] ; - a5 = coefs [5] ; - a6 = coefs [6] ; - a7 = coefs [7] ; - - for (j = lim ; j < num ; j++) - { - LOOP_ALIGN - - top = out [j - lim] ; - pout = out + j - 1 ; - - b0 = top - (*pout--) ; - b1 = top - (*pout--) ; - b2 = top - (*pout--) ; - b3 = top - (*pout--) ; - b4 = top - (*pout--) ; - b5 = top - (*pout--) ; - b6 = top - (*pout--) ; - b7 = top - (*pout) ; - pout += 8 ; - - sum1 = (denhalf - a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3 - - a4 * b4 - a5 * b5 - a6 * b6 - a7 * b7) >> denshift ; - - del = pc1 [j] ; - del0 = del ; - sg = sign_of_int (del) ; - del += top + sum1 ; - - out [j] = arith_shift_left (del, chanshift) >> chanshift ; - - if (sg > 0) - { - sgn = sign_of_int (b7) ; - a7 -= sgn ; - del0 -= 1 * ((sgn * b7) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b6) ; - a6 -= sgn ; - del0 -= 2 * ((sgn * b6) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b5) ; - a5 -= sgn ; - del0 -= 3 * ((sgn * b5) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b4) ; - a4 -= sgn ; - del0 -= 4 * ((sgn * b4) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b3) ; - a3 -= sgn ; - del0 -= 5 * ((sgn * b3) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b2) ; - a2 -= sgn ; - del0 -= 6 * ((sgn * b2) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b1) ; - a1 -= sgn ; - del0 -= 7 * ((sgn * b1) >> denshift) ; - if (del0 <= 0) - continue ; - - a0 -= sign_of_int (b0) ; - } - else if (sg < 0) - { - // note: to avoid unnecessary negations, we flip the value of "sgn" - sgn = -sign_of_int (b7) ; - a7 -= sgn ; - del0 -= 1 * ((sgn * b7) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b6) ; - a6 -= sgn ; - del0 -= 2 * ((sgn * b6) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b5) ; - a5 -= sgn ; - del0 -= 3 * ((sgn * b5) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b4) ; - a4 -= sgn ; - del0 -= 4 * ((sgn * b4) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b3) ; - a3 -= sgn ; - del0 -= 5 * ((sgn * b3) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b2) ; - a2 -= sgn ; - del0 -= 6 * ((sgn * b2) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b1) ; - a1 -= sgn ; - del0 -= 7 * ((sgn * b1) >> denshift) ; - if (del0 >= 0) - continue ; - - a0 += sign_of_int (b0) ; - } - } - - coefs [0] = a0 ; - coefs [1] = a1 ; - coefs [2] = a2 ; - coefs [3] = a3 ; - coefs [4] = a4 ; - coefs [5] = a5 ; - coefs [6] = a6 ; - coefs [7] = a7 ; - } - else - { - // general case - for (j = lim ; j < num ; j++) - { - LOOP_ALIGN - - sum1 = 0 ; - pout = out + j - 1 ; - top = out [j-lim] ; - - for (k = 0 ; k < numactive ; k++) - sum1 += coefs [k] * (pout [-k] - top) ; - - del = pc1 [j] ; - del0 = del ; - sg = sign_of_int (del) ; - del += top + ((sum1 + denhalf) >> denshift) ; - out [j] = (del << chanshift) >> chanshift ; - - if (sg > 0) - { - for (k = (numactive - 1) ; k >= 0 ; k--) - { - dd = top - pout [-k] ; - sgn = sign_of_int (dd) ; - coefs [k] -= sgn ; - del0 -= (numactive - k) * ((sgn * dd) >> denshift) ; - if (del0 <= 0) - break ; - } - } - else if (sg < 0) - { - for (k = (numactive - 1) ; k >= 0 ; k--) - { - dd = top - pout [-k] ; - sgn = sign_of_int (dd) ; - coefs [k] += sgn ; - del0 -= (numactive - k) * ((-sgn * dd) >> denshift) ; - if (del0 >= 0) - break ; - } - } - } - } -} diff --git a/Engine/lib/libsndfile/src/ALAC/dp_enc.c b/Engine/lib/libsndfile/src/ALAC/dp_enc.c deleted file mode 100644 index 01db8d401..000000000 --- a/Engine/lib/libsndfile/src/ALAC/dp_enc.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: dp_enc.c - - Contains: Dynamic Predictor encode routines - - Copyright: (c) 2001-2011 Apple, Inc. -*/ - -#include - -#include "dplib.h" -#include "shift.h" - -#if __GNUC__ -#define ALWAYS_INLINE __attribute__ ((always_inline)) -#elif defined _MSC_VER -#define ALWAYS_INLINE __forceinline -#else -#define ALWAYS_INLINE -#endif - -#define LOOP_ALIGN - -void -init_coefs (int16_t * coefs, uint32_t denshift, int32_t numPairs) -{ - int32_t k ; - int32_t den = 1 << denshift ; - - coefs [0] = (AINIT * den) >> 4 ; - coefs [1] = (BINIT * den) >> 4 ; - coefs [2] = (CINIT * den) >> 4 ; - for (k = 3 ; k < numPairs ; k++) - coefs [k] = 0 ; -} - -void -copy_coefs (const int16_t * srcCoefs, int16_t * dstCoefs, int32_t numPairs) -{ - int32_t k ; - - for (k = 0 ; k < numPairs ; k++) - dstCoefs [k] = srcCoefs [k] ; -} - -static inline int32_t ALWAYS_INLINE sign_of_int (int32_t i) -{ - int32_t negishift ; - - negishift = ((uint32_t) - i) >> 31 ; - return negishift | (i >> 31) ; -} - -void -pc_block (int32_t * in, int32_t * pc1, int32_t num, int16_t * coefs, int32_t numactive, uint32_t chanbits, uint32_t denshift) -{ - register int16_t a0, a1, a2, a3 ; - register int32_t b0, b1, b2, b3 ; - int32_t j, k, lim ; - int32_t * pin ; - int32_t sum1, dd ; - int32_t sg, sgn ; - int32_t top ; - int32_t del, del0 ; - uint32_t chanshift = 32 - chanbits ; - int32_t denhalf = 1 << (denshift - 1) ; - - pc1 [0] = in [0] ; - if (numactive == 0) - { - // just copy if numactive == 0 (but don't bother if in/out pointers the same) - if ((num > 1) && (in != pc1)) - memcpy (&pc1 [1], &in [1], (num - 1) * sizeof (int32_t)) ; - return ; - } - if (numactive == 31) - { - // short-circuit if numactive == 31 - for (j = 1 ; j < num ; j++) - { - del = in [j] - in [j-1] ; - pc1 [j] = (del << chanshift) >> chanshift ; - } - return ; - } - - for (j = 1 ; j <= numactive ; j++) - { - del = in [j] - in [j-1] ; - pc1 [j] = arith_shift_left (del, chanshift) >> chanshift ; - } - - lim = numactive + 1 ; - - if (numactive == 4) - { - // optimization for numactive == 4 - a0 = coefs [0] ; - a1 = coefs [1] ; - a2 = coefs [2] ; - a3 = coefs [3] ; - - for (j = lim ; j < num ; j++) - { - LOOP_ALIGN - - top = in [j - lim] ; - pin = in + j - 1 ; - - b0 = top - pin [0] ; - b1 = top - pin [-1] ; - b2 = top - pin [-2] ; - b3 = top - pin [-3] ; - - sum1 = (denhalf - a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3) >> denshift ; - - del = in [j] - top - sum1 ; - del = arith_shift_left (del, chanshift) >> chanshift ; - pc1 [j] = del ; - del0 = del ; - - sg = sign_of_int (del) ; - if (sg > 0) - { - sgn = sign_of_int (b3) ; - a3 -= sgn ; - del0 -= (4 - 3) * ((sgn * b3) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b2) ; - a2 -= sgn ; - del0 -= (4 - 2) * ((sgn * b2) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b1) ; - a1 -= sgn ; - del0 -= (4 - 1) * ((sgn * b1) >> denshift) ; - if (del0 <= 0) - continue ; - - a0 -= sign_of_int (b0) ; - } - else if (sg < 0) - { - // note: to avoid unnecessary negations, we flip the value of "sgn" - sgn = -sign_of_int (b3) ; - a3 -= sgn ; - del0 -= (4 - 3) * ((sgn * b3) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b2) ; - a2 -= sgn ; - del0 -= (4 - 2) * ((sgn * b2) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b1) ; - a1 -= sgn ; - del0 -= (4 - 1) * ((sgn * b1) >> denshift) ; - if (del0 >= 0) - continue ; - - a0 += sign_of_int (b0) ; - } - } - - coefs [0] = a0 ; - coefs [1] = a1 ; - coefs [2] = a2 ; - coefs [3] = a3 ; - } - else if (numactive == 8) - { - // optimization for numactive == 8 - register int16_t a4, a5, a6, a7 ; - register int32_t b4, b5, b6, b7 ; - - a0 = coefs [0] ; - a1 = coefs [1] ; - a2 = coefs [2] ; - a3 = coefs [3] ; - a4 = coefs [4] ; - a5 = coefs [5] ; - a6 = coefs [6] ; - a7 = coefs [7] ; - - for (j = lim ; j < num ; j++) - { - LOOP_ALIGN - - top = in [j - lim] ; - pin = in + j - 1 ; - - b0 = top - (*pin--) ; - b1 = top - (*pin--) ; - b2 = top - (*pin--) ; - b3 = top - (*pin--) ; - b4 = top - (*pin--) ; - b5 = top - (*pin--) ; - b6 = top - (*pin--) ; - b7 = top - (*pin) ; - pin += 8 ; - - sum1 = (denhalf - a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3 - - a4 * b4 - a5 * b5 - a6 * b6 - a7 * b7) >> denshift ; - - del = in [j] - top - sum1 ; - del = arith_shift_left (del, chanshift) >> chanshift ; - pc1 [j] = del ; - del0 = del ; - - sg = sign_of_int (del) ; - if (sg > 0) - { - sgn = sign_of_int (b7) ; - a7 -= sgn ; - del0 -= 1 * ((sgn * b7) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b6) ; - a6 -= sgn ; - del0 -= 2 * ((sgn * b6) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b5) ; - a5 -= sgn ; - del0 -= 3 * ((sgn * b5) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b4) ; - a4 -= sgn ; - del0 -= 4 * ((sgn * b4) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b3) ; - a3 -= sgn ; - del0 -= 5 * ((sgn * b3) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b2) ; - a2 -= sgn ; - del0 -= 6 * ((sgn * b2) >> denshift) ; - if (del0 <= 0) - continue ; - - sgn = sign_of_int (b1) ; - a1 -= sgn ; - del0 -= 7 * ((sgn * b1) >> denshift) ; - if (del0 <= 0) - continue ; - - a0 -= sign_of_int (b0) ; - } - else if (sg < 0) - { - // note: to avoid unnecessary negations, we flip the value of "sgn" - sgn = -sign_of_int (b7) ; - a7 -= sgn ; - del0 -= 1 * ((sgn * b7) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b6) ; - a6 -= sgn ; - del0 -= 2 * ((sgn * b6) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b5) ; - a5 -= sgn ; - del0 -= 3 * ((sgn * b5) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b4) ; - a4 -= sgn ; - del0 -= 4 * ((sgn * b4) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b3) ; - a3 -= sgn ; - del0 -= 5 * ((sgn * b3) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b2) ; - a2 -= sgn ; - del0 -= 6 * ((sgn * b2) >> denshift) ; - if (del0 >= 0) - continue ; - - sgn = -sign_of_int (b1) ; - a1 -= sgn ; - del0 -= 7 * ((sgn * b1) >> denshift) ; - if (del0 >= 0) - continue ; - - a0 += sign_of_int (b0) ; - } - } - - coefs [0] = a0 ; - coefs [1] = a1 ; - coefs [2] = a2 ; - coefs [3] = a3 ; - coefs [4] = a4 ; - coefs [5] = a5 ; - coefs [6] = a6 ; - coefs [7] = a7 ; - } - else - { -//pc_block_general: - // general case - for (j = lim ; j < num ; j++) - { - LOOP_ALIGN - - top = in [j - lim] ; - pin = in + j - 1 ; - - sum1 = 0 ; - for (k = 0 ; k < numactive ; k++) - sum1 -= coefs [k] * (top - pin [-k]) ; - - del = in [j] - top - ((sum1 + denhalf) >> denshift) ; - del = (del << chanshift) >> chanshift ; - pc1 [j] = del ; - del0 = del ; - - sg = sign_of_int (del) ; - if (sg > 0) - { - for (k = (numactive - 1) ; k >= 0 ; k--) - { - dd = top - pin [-k] ; - sgn = sign_of_int (dd) ; - coefs [k] -= sgn ; - del0 -= (numactive - k) * ((sgn * dd) >> denshift) ; - if (del0 <= 0) - break ; - } - } - else if (sg < 0) - { - for (k = (numactive - 1) ; k >= 0 ; k--) - { - dd = top - pin [-k] ; - sgn = sign_of_int (dd) ; - coefs [k] += sgn ; - del0 -= (numactive - k) * ((-sgn * dd) >> denshift) ; - if (del0 >= 0) - break ; - } - } - } - } -} diff --git a/Engine/lib/libsndfile/src/ALAC/dplib.h b/Engine/lib/libsndfile/src/ALAC/dplib.h deleted file mode 100644 index 43ae721d5..000000000 --- a/Engine/lib/libsndfile/src/ALAC/dplib.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: dplib.h - - Contains: Dynamic Predictor routines - - Copyright: Copyright (C) 2001-2011 Apple, Inc. -*/ - -#ifndef __DPLIB_H__ -#define __DPLIB_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// defines - -#define DENSHIFT_MAX 15 -#define DENSHIFT_DEFAULT 9 -#define AINIT 38 -#define BINIT (-29) -#define CINIT (-2) -#define NUMCOEPAIRS 16 - -// prototypes - -void init_coefs (int16_t * coefs, uint32_t denshift, int32_t numPairs) ; -void copy_coefs (const int16_t * srcCoefs, int16_t * dstCoefs, int32_t numPairs) ; - -// NOTE: these routines read at least "numactive" samples so the i/o buffers must be at least that big - -void pc_block (int32_t * in, int32_t * pc, int32_t num, int16_t * coefs, int32_t numactive, uint32_t chanbits, uint32_t denshift) ; -void unpc_block (const int32_t * pc, int32_t * out, int32_t num, int16_t * coefs, int32_t numactive, uint32_t chanbits, uint32_t denshift) ; - -#ifdef __cplusplus -} -#endif - -#endif /* __DPLIB_H__ */ diff --git a/Engine/lib/libsndfile/src/ALAC/matrix_dec.c b/Engine/lib/libsndfile/src/ALAC/matrix_dec.c deleted file mode 100644 index 6d0b40153..000000000 --- a/Engine/lib/libsndfile/src/ALAC/matrix_dec.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * Copyright (C) 2012-2014 Erik de Castro Lopo - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: matrix_dec.c - - Contains: ALAC mixing/matrixing decode routines. - - Copyright: (c) 2004-2011 Apple, Inc. -*/ - -#include "matrixlib.h" -#include "ALACAudioTypes.h" -#include "shift.h" - -// up to 24-bit "offset" macros for the individual bytes of a 20/24-bit word -#if TARGET_RT_BIG_ENDIAN - #define LBYTE 2 - #define MBYTE 1 - #define HBYTE 0 -#else - #define LBYTE 0 - #define MBYTE 1 - #define HBYTE 2 -#endif - -/* - There is no plain middle-side option ; instead there are various mixing - modes including middle-side, each lossless, as embodied in the mix () - and unmix () functions. These functions exploit a generalized middle-side - transformation: - - u := [(rL + (m-r)R)/m] ; - v := L - R ; - - where [ ] denotes integer floor. The (lossless) inverse is - - L = u + v - [rV/m] ; - R = L - v ; -*/ - -// 16-bit routines - -void -unmix16 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres) -{ - int32_t j ; - - if (mixres != 0) - { - /* matrixed stereo */ - for (j = 0 ; j < numSamples ; j++) - { - int32_t l, r ; - - l = u [j] + v [j] - ((mixres * v [j]) >> mixbits) ; - r = l - v [j] ; - - out [0] = arith_shift_left (l, 16) ; - out [1] = arith_shift_left (r, 16) ; - out += stride ; - } - } - else - { - /* Conventional separated stereo. */ - for (j = 0 ; j < numSamples ; j++) - { - out [0] = u [j] << 16 ; - out [1] = v [j] << 16 ; - out += stride ; - } - } -} - -// 20-bit routines -// - the 20 bits of data are left-justified in 3 bytes of storage but right-aligned for input/output predictor buffers - -void -unmix20 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres) -{ - int32_t j ; - - if (mixres != 0) - { - /* matrixed stereo */ - for (j = 0 ; j < numSamples ; j++) - { - int32_t l, r ; - - l = u [j] + v [j] - ((mixres * v [j]) >> mixbits) ; - r = l - v [j] ; - - out [0] = arith_shift_left (l, 12) ; - out [1] = arith_shift_left (r, 12) ; - out += stride ; - } - } - else - { - /* Conventional separated stereo. */ - for (j = 0 ; j < numSamples ; j++) - { - out [0] = arith_shift_left (u [j], 12) ; - out [1] = arith_shift_left (v [j], 12) ; - out += stride ; - } - } -} - -// 24-bit routines -// - the 24 bits of data are right-justified in the input/output predictor buffers - -void -unmix24 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, - int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) -{ - int32_t shift = bytesShifted * 8 ; - int32_t l, r ; - int32_t j, k ; - - if (mixres != 0) - { - /* matrixed stereo */ - if (bytesShifted != 0) - { - for (j = 0, k = 0 ; j < numSamples ; j++, k += 2) - { - l = u [j] + v [j] - ((mixres * v [j]) >> mixbits) ; - r = l - v [j] ; - - l = arith_shift_left (l, shift) | (uint32_t) shiftUV [k + 0] ; - r = arith_shift_left (r, shift) | (uint32_t) shiftUV [k + 1] ; - - out [0] = arith_shift_left (l, 8) ; - out [1] = arith_shift_left (r, 8) ; - out += stride ; - } - } - else - { - for (j = 0 ; j < numSamples ; j++) - { - l = u [j] + v [j] - ((mixres * v [j]) >> mixbits) ; - r = l - v [j] ; - - out [0] = l << 8 ; - out [1] = r << 8 ; - out += stride ; - } - } - } - else - { - /* Conventional separated stereo. */ - if (bytesShifted != 0) - { - for (j = 0, k = 0 ; j < numSamples ; j++, k += 2) - { - l = u [j] ; - r = v [j] ; - - l = (l << shift) | (uint32_t) shiftUV [k + 0] ; - r = (r << shift) | (uint32_t) shiftUV [k + 1] ; - - out [0] = l << 8 ; - out [1] = r << 8 ; - out += stride ; - } - } - else - { - for (j = 0 ; j < numSamples ; j++) - { - out [0] = u [j] << 8 ; - out [1] = v [j] << 8 ; - out += stride ; - } - } - } -} - -// 32-bit routines -// - note that these really expect the internal data width to be < 32 but the arrays are 32-bit -// - otherwise, the calculations might overflow into the 33rd bit and be lost -// - therefore, these routines deal with the specified "unused lower" bytes in the "shift" buffers - -void -unmix32 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, - int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) -{ - int32_t shift = bytesShifted * 8 ; - int32_t l, r ; - int32_t j, k ; - - if (mixres != 0) - { - //Assert (bytesShifted != 0) ; - - /* matrixed stereo with shift */ - for (j = 0, k = 0 ; j < numSamples ; j++, k += 2) - { - int32_t lt, rt ; - - lt = u [j] ; - rt = v [j] ; - - l = lt + rt - ((mixres * rt) >> mixbits) ; - r = l - rt ; - - out [0] = arith_shift_left (l, shift) | (uint32_t) shiftUV [k + 0] ; - out [1] = arith_shift_left (r, shift) | (uint32_t) shiftUV [k + 1] ; - out += stride ; - } - } - else - { - if (bytesShifted == 0) - { - /* interleaving w/o shift */ - for (j = 0 ; j < numSamples ; j++) - { - out [0] = u [j] ; - out [1] = v [j] ; - out += stride ; - } - } - else - { - /* interleaving with shift */ - for (j = 0, k = 0 ; j < numSamples ; j++, k += 2) - { - out [0] = (u [j] << shift) | (uint32_t) shiftUV [k + 0] ; - out [1] = (v [j] << shift) | (uint32_t) shiftUV [k + 1] ; - out += stride ; - } - } - } -} - -// 20/24-bit <-> 32-bit helper routines (not really matrixing but convenient to put here) - -void -copyPredictorTo24 (const int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples) -{ - int32_t j ; - - for (j = 0 ; j < numSamples ; j++) - { - out [0] = in [j] << 8 ; - out += stride ; - } -} - -void -copyPredictorTo24Shift (const int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted) -{ - int32_t shiftVal = bytesShifted * 8 ; - int32_t j ; - - //Assert (bytesShifted != 0) ; - - for (j = 0 ; j < numSamples ; j++) - { - int32_t val = in [j] ; - - val = arith_shift_left (val, shiftVal) | (uint32_t) shift [j] ; - out [0] = arith_shift_left (val, 8) ; - out += stride ; - } -} - -void -copyPredictorTo20 (const int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples) -{ - int32_t j ; - - // 32-bit predictor values are right-aligned but 20-bit output values should be left-aligned - // in the 24-bit output buffer - for (j = 0 ; j < numSamples ; j++) - { - out [0] = arith_shift_left (in [j], 12) ; - out += stride ; - } -} - -void -copyPredictorTo32 (const int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples) -{ - int32_t i, j ; - - // this is only a subroutine to abstract the "iPod can only output 16-bit data" problem - for (i = 0, j = 0 ; i < numSamples ; i++, j += stride) - out [j] = arith_shift_left (in [i], 8) ; -} - -void -copyPredictorTo32Shift (const int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted) -{ - int32_t * op = out ; - uint32_t shiftVal = bytesShifted * 8 ; - int32_t j ; - - //Assert (bytesShifted != 0) ; - - // this is only a subroutine to abstract the "iPod can only output 16-bit data" problem - for (j = 0 ; j < numSamples ; j++) - { - op [0] = arith_shift_left (in [j], shiftVal) | (uint32_t) shift [j] ; - op += stride ; - } -} diff --git a/Engine/lib/libsndfile/src/ALAC/matrix_enc.c b/Engine/lib/libsndfile/src/ALAC/matrix_enc.c deleted file mode 100644 index b50f83b78..000000000 --- a/Engine/lib/libsndfile/src/ALAC/matrix_enc.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * Copyright (C) 2012-2014 Erik de Castro Lopo - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: matrix_enc.c - - Contains: ALAC mixing/matrixing encode routines. - - Copyright: (c) 2004-2011 Apple, Inc. -*/ - -#include "matrixlib.h" -#include "ALACAudioTypes.h" - -/* - There is no plain middle-side option ; instead there are various mixing - modes including middle-side, each lossless, as embodied in the mix () - and unmix () functions. These functions exploit a generalized middle-side - transformation: - - u := [(rL + (m-r)R)/m] ; - v := L - R ; - - where [ ] denotes integer floor. The (lossless) inverse is - - L = u + v - [rV/m] ; - R = L - v ; -*/ - -// 16-bit routines - -void -mix16 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres) -{ - int32_t j ; - - if (mixres != 0) - { - int32_t mod = 1 << mixbits ; - int32_t m2 ; - - /* matrixed stereo */ - m2 = mod - mixres ; - for (j = 0 ; j < numSamples ; j++) - { - int32_t l, r ; - - l = in [0] >> 16 ; - r = in [1] >> 16 ; - in += stride ; - u [j] = (mixres * l + m2 * r) >> mixbits ; - v [j] = l - r ; - } - } - else - { - /* Conventional separated stereo. */ - for (j = 0 ; j < numSamples ; j++) - { - u [j] = in [0] >> 16 ; - v [j] = in [1] >> 16 ; - in += stride ; - } - } -} - -// 20-bit routines -// - the 20 bits of data are left-justified in 3 bytes of storage but right-aligned for input/output predictor buffers - -void -mix20 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres) -{ - int32_t l, r ; - int32_t j ; - - if (mixres != 0) - { - /* matrixed stereo */ - int32_t mod = 1 << mixbits ; - int32_t m2 = mod - mixres ; - - for (j = 0 ; j < numSamples ; j++) - { - l = in [0] >> 12 ; - r = in [1] >> 12 ; - in += stride ; - - u [j] = (mixres * l + m2 * r) >> mixbits ; - v [j] = l - r ; - } - } - else - { - /* Conventional separated stereo. */ - for (j = 0 ; j < numSamples ; j++) - { - u [j] = in [0] >> 12 ; - v [j] = in [1] >> 12 ; - in += stride ; - } - } -} - -// 24-bit routines -// - the 24 bits of data are right-justified in the input/output predictor buffers - -void -mix24 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, - int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) -{ - int32_t l, r ; - int32_t shift = bytesShifted * 8 ; - uint32_t mask = (1ul << shift) - 1 ; - int32_t j, k ; - - if (mixres != 0) - { - /* matrixed stereo */ - int32_t mod = 1 << mixbits ; - int32_t m2 = mod - mixres ; - - if (bytesShifted != 0) - { - for (j = 0, k = 0 ; j < numSamples ; j++, k += 2) - { - l = in [0] >> 8 ; - r = in [1] >> 8 ; - in += stride ; - - shiftUV [k + 0] = (uint16_t) (l & mask) ; - shiftUV [k + 1] = (uint16_t) (r & mask) ; - - l >>= shift ; - r >>= shift ; - - u [j] = (mixres * l + m2 * r) >> mixbits ; - v [j] = l - r ; - } - } - else - { - for (j = 0 ; j < numSamples ; j++) - { - l = in [0] >> 8 ; - r = in [1] >> 8 ; - in += stride ; - - u [j] = (mixres * l + m2 * r) >> mixbits ; - v [j] = l - r ; - } - } - } - else - { - /* Conventional separated stereo. */ - if (bytesShifted != 0) - { - for (j = 0, k = 0 ; j < numSamples ; j++, k += 2) - { - l = in [0] >> 8 ; - r = in [1] >> 8 ; - in += stride ; - - shiftUV [k + 0] = (uint16_t) (l & mask) ; - shiftUV [k + 1] = (uint16_t) (r & mask) ; - - l >>= shift ; - r >>= shift ; - - u [j] = l ; - v [j] = r ; - } - } - else - { - for (j = 0 ; j < numSamples ; j++) - { - l = in [0] >> 8 ; - r = in [1] >> 8 ; - in += stride ; - } - } - } -} - -// 32-bit routines -// - note that these really expect the internal data width to be < 32 but the arrays are 32-bit -// - otherwise, the calculations might overflow into the 33rd bit and be lost -// - therefore, these routines deal with the specified "unused lower" bytes in the "shift" buffers - -void -mix32 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, - int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) -{ - int32_t shift = bytesShifted * 8 ; - uint32_t mask = (1ul << shift) - 1 ; - int32_t l, r ; - int32_t j, k ; - - if (mixres != 0) - { - int32_t mod = 1 << mixbits ; - int32_t m2 ; - - //Assert (bytesShifted != 0) ; - - /* matrixed stereo with shift */ - m2 = mod - mixres ; - for (j = 0, k = 0 ; j < numSamples ; j++, k += 2) - { - l = in [0] ; - r = in [1] ; - in += stride ; - - shiftUV [k + 0] = (uint16_t) (l & mask) ; - shiftUV [k + 1] = (uint16_t) (r & mask) ; - - l >>= shift ; - r >>= shift ; - - u [j] = (mixres * l + m2 * r) >> mixbits ; - v [j] = l - r ; - } - } - else - { - if (bytesShifted == 0) - { - /* de-interleaving w/o shift */ - for (j = 0 ; j < numSamples ; j++) - { - u [j] = in [0] ; - v [j] = in [1] ; - in += stride ; - } - } - else - { - /* de-interleaving with shift */ - for (j = 0, k = 0 ; j < numSamples ; j++, k += 2) - { - l = in [0] ; - r = in [1] ; - in += stride ; - - shiftUV [k + 0] = (uint16_t) (l & mask) ; - shiftUV [k + 1] = (uint16_t) (r & mask) ; - - l >>= shift ; - r >>= shift ; - - u [j] = l ; - v [j] = r ; - } - } - } -} diff --git a/Engine/lib/libsndfile/src/ALAC/matrixlib.h b/Engine/lib/libsndfile/src/ALAC/matrixlib.h deleted file mode 100644 index d9be5feca..000000000 --- a/Engine/lib/libsndfile/src/ALAC/matrixlib.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011 Apple Inc. All rights reserved. - * Copyright (C) 2012-2014 Erik de Castro Lopo - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License") ; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - File: matrixlib.h - - Contains: ALAC mixing/matrixing routines to/from 32-bit predictor buffers. - - Copyright: Copyright (C) 2004 to 2011 Apple, Inc. -*/ - -#ifndef __MATRIXLIB_H -#define __MATRIXLIB_H - -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// 16-bit routines -void mix16 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres) ; -void unmix16 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres) ; - -// 20-bit routines -void mix20 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres) ; -void unmix20 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres) ; - -// 24-bit routines -// - 24-bit data sometimes compresses better by shifting off the bottom byte so these routines deal with -// the specified "unused lower bytes" in the combined "shift" buffer -void mix24 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, - int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) ; -void unmix24 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, - int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) ; - -// 32-bit routines -// - note that these really expect the internal data width to be < 32-bit but the arrays are 32-bit -// - otherwise, the calculations might overflow into the 33rd bit and be lost -// - therefore, these routines deal with the specified "unused lower" bytes in the combined "shift" buffer -void mix32 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, - int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) ; -void unmix32 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, - int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) ; - -// 20/24/32-bit <-> 32-bit helper routines (not really matrixing but convenient to put here) -void copy20ToPredictor (const int32_t * in, uint32_t stride, int32_t * out, int32_t numSamples) ; -void copy24ToPredictor (const int32_t * in, uint32_t stride, int32_t * out, int32_t numSamples) ; - -void copyPredictorTo24 (const int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples) ; -void copyPredictorTo24Shift (const int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted) ; -void copyPredictorTo20 (const int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples) ; - -void copyPredictorTo32 (const int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples) ; -void copyPredictorTo32Shift (const int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted) ; - -#ifdef __cplusplus -} -#endif - -#endif /* __MATRIXLIB_H */ diff --git a/Engine/lib/libsndfile/src/ALAC/shift.h b/Engine/lib/libsndfile/src/ALAC/shift.h deleted file mode 100644 index bce404d24..000000000 --- a/Engine/lib/libsndfile/src/ALAC/shift.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -** Copyright (C) 2014 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if __GNUC__ -#define ALWAYS_INLINE __attribute__ ((always_inline)) -#elif defined _MSC_VER -#define ALWAYS_INLINE __forceinline -#else -#define ALWAYS_INLINE -#endif - - -static inline int32_t ALWAYS_INLINE -arith_shift_left (int32_t x, int shift) -{ return (int32_t) (((uint32_t) x) << shift) ; -} /* arith_shift_left */ diff --git a/Engine/lib/libsndfile/src/G72x/ChangeLog b/Engine/lib/libsndfile/src/G72x/ChangeLog deleted file mode 100644 index aa108dff7..000000000 --- a/Engine/lib/libsndfile/src/G72x/ChangeLog +++ /dev/null @@ -1,50 +0,0 @@ -2001-06-05 Erik de Castro Lopo - - * g72x.c - Added {} in function update () to prevent 'ambiguous else' warning messages. - -2000-07-14 Erik de Castro Lopo - - * g72x.c - Modified g72x_init_state () to fit in with the new structure of the code. - Implemented g72x_encode_block () and g72x_decode_block (). - -2000-07-12 Erik de Castro Lopo - - * g72x.h - Moved nearly all definitions and function prototypes from this file have been - moved to private.h. - Added an enum defining the 4 different G72x ADPCM codecs. - Added new function prototypes to define a cleaner interface to the encoder - and decoder. This new interface also allows samples to be processed in blocks - rather than on a sample by sample basis like the original code. - - * private.h - Added prototypes moved from g72x.h. - Changed struct g72x_state to a typedef struct { .. } G72x_PRIVATE. - Added fields to G72x_PRIVATE required for working on blocks of samples. - -2000-06-07 Erik de Castro Lopo - - * g72x.c - Fixed all compiler warnings. - Removed functions tandem_adjust() which is not required by libsndfile. - - * g721.c - Fixed all compiler warnings. - Removed functions tandem_adjust_alaw() and tandem_adjust_ulaw () which are not - required by libsndfile. - Removed second parameter to g721_encoder () which is not required. - - * g72x.h - Removed in_coding and out_coding parameters from all functions. These allowed - g72x encoding/decoding to/from A-law or u-law and are not required by libsndfile. - Removed unneeded defines for A-law, u-law and linear encoding. - - * g723_16.c - Removed second parameter (in_coding) for g723_16_encoder(). - Removed second parameter (out_coding) for g723_16_decoder(). - - * private.h - New file containing prototypes and tyepdefs private to G72x code. - diff --git a/Engine/lib/libsndfile/src/G72x/README b/Engine/lib/libsndfile/src/G72x/README deleted file mode 100644 index e69de29bb..000000000 diff --git a/Engine/lib/libsndfile/src/G72x/README.original b/Engine/lib/libsndfile/src/G72x/README.original deleted file mode 100644 index 23b0e7dd5..000000000 --- a/Engine/lib/libsndfile/src/G72x/README.original +++ /dev/null @@ -1,94 +0,0 @@ -The files in this directory comprise ANSI-C language reference implementations -of the CCITT (International Telegraph and Telephone Consultative Committee) -G.711, G.721 and G.723 voice compressions. They have been tested on Sun -SPARCstations and passed 82 out of 84 test vectors published by CCITT -(Dec. 20, 1988) for G.721 and G.723. [The two remaining test vectors, -which the G.721 decoder implementation for u-law samples did not pass, -may be in error because they are identical to two other vectors for G.723_40.] - -This source code is released by Sun Microsystems, Inc. to the public domain. -Please give your acknowledgement in product literature if this code is used -in your product implementation. - -Sun Microsystems supports some CCITT audio formats in Solaris 2.0 system -software. However, Sun's implementations have been optimized for higher -performance on SPARCstations. - - -The source files for CCITT conversion routines in this directory are: - - g72x.h header file for g721.c, g723_24.c and g723_40.c - g711.c CCITT G.711 u-law and A-law compression - g72x.c common denominator of G.721 and G.723 ADPCM codes - g721.c CCITT G.721 32Kbps ADPCM coder (with g72x.c) - g723_24.c CCITT G.723 24Kbps ADPCM coder (with g72x.c) - g723_40.c CCITT G.723 40Kbps ADPCM coder (with g72x.c) - - -Simple conversions between u-law, A-law, and 16-bit linear PCM are invoked -as follows: - - unsigned char ucode, acode; - short pcm_val; - - ucode = linear2ulaw(pcm_val); - ucode = alaw2ulaw(acode); - - acode = linear2alaw(pcm_val); - acode = ulaw2alaw(ucode); - - pcm_val = ulaw2linear(ucode); - pcm_val = alaw2linear(acode); - - -The other CCITT compression routines are invoked as follows: - - #include "g72x.h" - - struct g72x_state state; - int sample, code; - - g72x_init_state(&state); - code = {g721,g723_24,g723_40}_encoder(sample, coding, &state); - sample = {g721,g723_24,g723_40}_decoder(code, coding, &state); - -where - coding = AUDIO_ENCODING_ULAW for 8-bit u-law samples - AUDIO_ENCODING_ALAW for 8-bit A-law samples - AUDIO_ENCODING_LINEAR for 16-bit linear PCM samples - - - -This directory also includes the following sample programs: - - encode.c CCITT ADPCM encoder - decode.c CCITT ADPCM decoder - Makefile makefile for the sample programs - - -The sample programs contain examples of how to call the various compression -routines and pack/unpack the bits. The sample programs read byte streams from -stdin and write to stdout. The input/output data is raw data (no file header -or other identifying information is embedded). The sample programs are -invoked as follows: - - encode [-3|4|5] [-a|u|l] outfile - decode [-3|4|5] [-a|u|l] outfile -where: - -3 encode to (decode from) G.723 24kbps (3-bit) data - -4 encode to (decode from) G.721 32kbps (4-bit) data [the default] - -5 encode to (decode from) G.723 40kbps (5-bit) data - -a encode from (decode to) A-law data - -u encode from (decode to) u-law data [the default] - -l encode from (decode to) 16-bit linear data - -Examples: - # Read 16-bit linear and output G.721 - encode -4 -l g721file - - # Read 40Kbps G.723 and output A-law - decode -5 -a alawfile - - # Compress and then decompress u-law data using 24Kbps G.723 - encode -3 ulawout - diff --git a/Engine/lib/libsndfile/src/G72x/g721.c b/Engine/lib/libsndfile/src/G72x/g721.c deleted file mode 100644 index 826d42c49..000000000 --- a/Engine/lib/libsndfile/src/G72x/g721.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * g721.c - * - * Description: - * - * g721_encoder (), g721_decoder () - * - * These routines comprise an implementation of the CCITT G.721 ADPCM - * coding algorithm. Essentially, this implementation is identical to - * the bit level description except for a few deviations which - * take advantage of work station attributes, such as hardware 2's - * complement arithmetic and large memory. Specifically, certain time - * consuming operations such as multiplications are replaced - * with lookup tables and software 2's complement operations are - * replaced with hardware 2's complement. - * - * The deviation from the bit level specification (lookup tables) - * preserves the bit level performance specifications. - * - * As outlined in the G.721 Recommendation, the algorithm is broken - * down into modules. Each section of code below is preceded by - * the name of the module which it is implementing. - * - */ - -#include "g72x.h" -#include "g72x_priv.h" - -static short qtab_721 [7] = { -124, 80, 178, 246, 300, 349, 400 } ; -/* - * Maps G.721 code word to reconstructed scale factor normalized log - * magnitude values. - */ -static short _dqlntab [16] = { -2048, 4, 135, 213, 273, 323, 373, 425, - 425, 373, 323, 273, 213, 135, 4, -2048 } ; - -/* Maps G.721 code word to log of scale factor multiplier. */ -static short _witab [16] = { -12, 18, 41, 64, 112, 198, 355, 1122, - 1122, 355, 198, 112, 64, 41, 18, -12 } ; -/* - * Maps G.721 code words to a set of values whose long and short - * term averages are computed and then compared to give an indication - * how stationary (steady state) the signal is. - */ -static short _fitab [16] = { 0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00, - 0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0 } ; - -/* - * g721_encoder () - * - * Encodes the input vale of linear PCM, A-law or u-law data sl and returns - * the resulting code. -1 is returned for unknown input coding value. - */ -int -g721_encoder ( - int sl, - G72x_STATE *state_ptr) -{ - short sezi, se, sez ; /* ACCUM */ - short d ; /* SUBTA */ - short sr ; /* ADDB */ - short y ; /* MIX */ - short dqsez ; /* ADDC */ - short dq, i ; - - /* linearize input sample to 14-bit PCM */ - sl >>= 2 ; /* 14-bit dynamic range */ - - sezi = predictor_zero (state_ptr) ; - sez = sezi >> 1 ; - se = (sezi + predictor_pole (state_ptr)) >> 1 ; /* estimated signal */ - - d = sl - se ; /* estimation difference */ - - /* quantize the prediction difference */ - y = step_size (state_ptr) ; /* quantizer step size */ - i = quantize (d, y, qtab_721, 7) ; /* i = ADPCM code */ - - dq = reconstruct (i & 8, _dqlntab [i], y) ; /* quantized est diff */ - - sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq ; /* reconst. signal */ - - dqsez = sr + sez - se ; /* pole prediction diff. */ - - update (4, y, arith_shift_left (_witab [i], 5), _fitab [i], dq, sr, dqsez, state_ptr) ; - - return i ; -} - -/* - * g721_decoder () - * - * Description: - * - * Decodes a 4-bit code of G.721 encoded data of i and - * returns the resulting linear PCM, A-law or u-law value. - * return -1 for unknown out_coding value. - */ -int -g721_decoder ( - int i, - G72x_STATE *state_ptr) -{ - short sezi, sei, sez, se ; /* ACCUM */ - short y ; /* MIX */ - short sr ; /* ADDB */ - short dq ; - short dqsez ; - - i &= 0x0f ; /* mask to get proper bits */ - sezi = predictor_zero (state_ptr) ; - sez = sezi >> 1 ; - sei = sezi + predictor_pole (state_ptr) ; - se = sei >> 1 ; /* se = estimated signal */ - - y = step_size (state_ptr) ; /* dynamic quantizer step size */ - - dq = reconstruct (i & 0x08, _dqlntab [i], y) ; /* quantized diff. */ - - sr = (dq < 0) ? (se - (dq & 0x3FFF)) : se + dq ; /* reconst. signal */ - - dqsez = sr - se + sez ; /* pole prediction diff. */ - - update (4, y, arith_shift_left (_witab [i], 5), _fitab [i], dq, sr, dqsez, state_ptr) ; - - /* sr was 14-bit dynamic range */ - return arith_shift_left (sr, 2) ; -} - diff --git a/Engine/lib/libsndfile/src/G72x/g723_16.c b/Engine/lib/libsndfile/src/G72x/g723_16.c deleted file mode 100644 index c377e6319..000000000 --- a/Engine/lib/libsndfile/src/G72x/g723_16.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* 16kbps version created, used 24kbps code and changing as little as possible. - * G.726 specs are available from ITU's gopher or WWW site (http://www.itu.ch) - * If any errors are found, please contact me at mrand@tamu.edu - * -Marc Randolph - */ - -/* - * g723_16.c - * - * Description: - * - * g723_16_encoder (), g723_16_decoder () - * - * These routines comprise an implementation of the CCITT G.726 16 Kbps - * ADPCM coding algorithm. Essentially, this implementation is identical to - * the bit level description except for a few deviations which take advantage - * of workstation attributes, such as hardware 2's complement arithmetic. - * - */ - -#include "g72x.h" -#include "g72x_priv.h" - -/* - * Maps G.723_16 code word to reconstructed scale factor normalized log - * magnitude values. Comes from Table 11/G.726 - */ -static short _dqlntab [4] = { 116, 365, 365, 116 } ; - -/* Maps G.723_16 code word to log of scale factor multiplier. - * - * _witab [4] is actually {-22 , 439, 439, -22}, but FILTD wants it - * as WI << 5 (multiplied by 32), so we'll do that here - */ -static short _witab [4] = { -704, 14048, 14048, -704 } ; - -/* - * Maps G.723_16 code words to a set of values whose long and short - * term averages are computed and then compared to give an indication - * how stationary (steady state) the signal is. - */ - -/* Comes from FUNCTF */ -static short _fitab [4] = { 0, 0xE00, 0xE00, 0 } ; - -/* Comes from quantizer decision level tables (Table 7/G.726) - */ -static short qtab_723_16 [1] = { 261 } ; - - -/* - * g723_16_encoder () - * - * Encodes a linear PCM, A-law or u-law input sample and returns its 2-bit code. - * Returns -1 if invalid input coding value. - */ -int -g723_16_encoder ( - int sl, - G72x_STATE *state_ptr) -{ - short sei, sezi, se, sez ; /* ACCUM */ - short d ; /* SUBTA */ - short y ; /* MIX */ - short sr ; /* ADDB */ - short dqsez ; /* ADDC */ - short dq, i ; - - /* linearize input sample to 14-bit PCM */ - sl >>= 2 ; /* sl of 14-bit dynamic range */ - - sezi = predictor_zero (state_ptr) ; - sez = sezi >> 1 ; - sei = sezi + predictor_pole (state_ptr) ; - se = sei >> 1 ; /* se = estimated signal */ - - d = sl - se ; /* d = estimation diff. */ - - /* quantize prediction difference d */ - y = step_size (state_ptr) ; /* quantizer step size */ - i = quantize (d, y, qtab_723_16, 1) ; /* i = ADPCM code */ - - /* Since quantize () only produces a three level output - * (1, 2, or 3), we must create the fourth one on our own - */ - if (i == 3) /* i code for the zero region */ - if ((d & 0x8000) == 0) /* If d > 0, i=3 isn't right... */ - i = 0 ; - - dq = reconstruct (i & 2, _dqlntab [i], y) ; /* quantized diff. */ - - sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq ; /* reconstructed signal */ - - dqsez = sr + sez - se ; /* pole prediction diff. */ - - update (2, y, _witab [i], _fitab [i], dq, sr, dqsez, state_ptr) ; - - return i ; -} - -/* - * g723_16_decoder () - * - * Decodes a 2-bit CCITT G.723_16 ADPCM code and returns - * the resulting 16-bit linear PCM, A-law or u-law sample value. - * -1 is returned if the output coding is unknown. - */ -int -g723_16_decoder ( - int i, - G72x_STATE *state_ptr) -{ - short sezi, sei, sez, se ; /* ACCUM */ - short y ; /* MIX */ - short sr ; /* ADDB */ - short dq ; - short dqsez ; - - i &= 0x03 ; /* mask to get proper bits */ - sezi = predictor_zero (state_ptr) ; - sez = sezi >> 1 ; - sei = sezi + predictor_pole (state_ptr) ; - se = sei >> 1 ; /* se = estimated signal */ - - y = step_size (state_ptr) ; /* adaptive quantizer step size */ - dq = reconstruct (i & 0x02, _dqlntab [i], y) ; /* unquantize pred diff */ - - sr = (dq < 0) ? (se - (dq & 0x3FFF)) : (se + dq) ; /* reconst. signal */ - - dqsez = sr - se + sez ; /* pole prediction diff. */ - - update (2, y, _witab [i], _fitab [i], dq, sr, dqsez, state_ptr) ; - - /* sr was of 14-bit dynamic range */ - return (sr << 2) ; -} - diff --git a/Engine/lib/libsndfile/src/G72x/g723_24.c b/Engine/lib/libsndfile/src/G72x/g723_24.c deleted file mode 100644 index 9cc2f6d50..000000000 --- a/Engine/lib/libsndfile/src/G72x/g723_24.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * g723_24.c - * - * Description: - * - * g723_24_encoder (), g723_24_decoder () - * - * These routines comprise an implementation of the CCITT G.723 24 Kbps - * ADPCM coding algorithm. Essentially, this implementation is identical to - * the bit level description except for a few deviations which take advantage - * of workstation attributes, such as hardware 2's complement arithmetic. - * - */ - -#include "g72x.h" -#include "g72x_priv.h" - -/* - * Maps G.723_24 code word to reconstructed scale factor normalized log - * magnitude values. - */ -static short _dqlntab [8] = { -2048, 135, 273, 373, 373, 273, 135, -2048 } ; - -/* Maps G.723_24 code word to log of scale factor multiplier. */ -static short _witab [8] = { -128, 960, 4384, 18624, 18624, 4384, 960, -128 } ; - -/* - * Maps G.723_24 code words to a set of values whose long and short - * term averages are computed and then compared to give an indication - * how stationary (steady state) the signal is. - */ -static short _fitab [8] = { 0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0 } ; - -static short qtab_723_24 [3] = { 8, 218, 331 } ; - -/* - * g723_24_encoder () - * - * Encodes a linear PCM, A-law or u-law input sample and returns its 3-bit code. - * Returns -1 if invalid input coding value. - */ -int -g723_24_encoder ( - int sl, - G72x_STATE *state_ptr) -{ - short sei, sezi, se, sez ; /* ACCUM */ - short d ; /* SUBTA */ - short y ; /* MIX */ - short sr ; /* ADDB */ - short dqsez ; /* ADDC */ - short dq, i ; - - /* linearize input sample to 14-bit PCM */ - sl >>= 2 ; /* sl of 14-bit dynamic range */ - - sezi = predictor_zero (state_ptr) ; - sez = sezi >> 1 ; - sei = sezi + predictor_pole (state_ptr) ; - se = sei >> 1 ; /* se = estimated signal */ - - d = sl - se ; /* d = estimation diff. */ - - /* quantize prediction difference d */ - y = step_size (state_ptr) ; /* quantizer step size */ - i = quantize (d, y, qtab_723_24, 3) ; /* i = ADPCM code */ - dq = reconstruct (i & 4, _dqlntab [i], y) ; /* quantized diff. */ - - sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq ; /* reconstructed signal */ - - dqsez = sr + sez - se ; /* pole prediction diff. */ - - update (3, y, _witab [i], _fitab [i], dq, sr, dqsez, state_ptr) ; - - return i ; -} - -/* - * g723_24_decoder () - * - * Decodes a 3-bit CCITT G.723_24 ADPCM code and returns - * the resulting 16-bit linear PCM, A-law or u-law sample value. - * -1 is returned if the output coding is unknown. - */ -int -g723_24_decoder ( - int i, - G72x_STATE *state_ptr) -{ - short sezi, sei, sez, se ; /* ACCUM */ - short y ; /* MIX */ - short sr ; /* ADDB */ - short dq ; - short dqsez ; - - i &= 0x07 ; /* mask to get proper bits */ - sezi = predictor_zero (state_ptr) ; - sez = sezi >> 1 ; - sei = sezi + predictor_pole (state_ptr) ; - se = sei >> 1 ; /* se = estimated signal */ - - y = step_size (state_ptr) ; /* adaptive quantizer step size */ - dq = reconstruct (i & 0x04, _dqlntab [i], y) ; /* unquantize pred diff */ - - sr = (dq < 0) ? (se - (dq & 0x3FFF)) : (se + dq) ; /* reconst. signal */ - - dqsez = sr - se + sez ; /* pole prediction diff. */ - - update (3, y, _witab [i], _fitab [i], dq, sr, dqsez, state_ptr) ; - - return arith_shift_left (sr, 2) ; /* sr was of 14-bit dynamic range */ -} - diff --git a/Engine/lib/libsndfile/src/G72x/g723_40.c b/Engine/lib/libsndfile/src/G72x/g723_40.c deleted file mode 100644 index f7f8f7427..000000000 --- a/Engine/lib/libsndfile/src/G72x/g723_40.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * g723_40.c - * - * Description: - * - * g723_40_encoder (), g723_40_decoder () - * - * These routines comprise an implementation of the CCITT G.723 40Kbps - * ADPCM coding algorithm. Essentially, this implementation is identical to - * the bit level description except for a few deviations which - * take advantage of workstation attributes, such as hardware 2's - * complement arithmetic. - * - * The deviation from the bit level specification (lookup tables), - * preserves the bit level performance specifications. - * - * As outlined in the G.723 Recommendation, the algorithm is broken - * down into modules. Each section of code below is preceded by - * the name of the module which it is implementing. - * - */ - -#include "g72x.h" -#include "g72x_priv.h" - -/* - * Maps G.723_40 code word to ructeconstructed scale factor normalized log - * magnitude values. - */ -static short _dqlntab [32] = { -2048, -66, 28, 104, 169, 224, 274, 318, - 358, 395, 429, 459, 488, 514, 539, 566, - 566, 539, 514, 488, 459, 429, 395, 358, - 318, 274, 224, 169, 104, 28, -66, -2048 } ; - -/* Maps G.723_40 code word to log of scale factor multiplier. */ -static short _witab [32] = { 448, 448, 768, 1248, 1280, 1312, 1856, 3200, - 4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272, - 22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512, - 3200, 1856, 1312, 1280, 1248, 768, 448, 448 } ; - -/* - * Maps G.723_40 code words to a set of values whose long and short - * term averages are computed and then compared to give an indication - * how stationary (steady state) the signal is. - */ -static short _fitab [32] = { 0, 0, 0, 0, 0, 0x200, 0x200, 0x200, - 0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00, - 0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200, - 0x200, 0x200, 0x200, 0, 0, 0, 0, 0 } ; - -static short qtab_723_40 [15] = { -122, -16, 68, 139, 198, 250, 298, 339, - 378, 413, 445, 475, 502, 528, 553 } ; - -/* - * g723_40_encoder () - * - * Encodes a 16-bit linear PCM, A-law or u-law input sample and retuens - * the resulting 5-bit CCITT G.723 40Kbps code. - * Returns -1 if the input coding value is invalid. - */ -int g723_40_encoder (int sl, G72x_STATE *state_ptr) -{ - short sei, sezi, se, sez ; /* ACCUM */ - short d ; /* SUBTA */ - short y ; /* MIX */ - short sr ; /* ADDB */ - short dqsez ; /* ADDC */ - short dq, i ; - - /* linearize input sample to 14-bit PCM */ - sl >>= 2 ; /* sl of 14-bit dynamic range */ - - sezi = predictor_zero (state_ptr) ; - sez = sezi >> 1 ; - sei = sezi + predictor_pole (state_ptr) ; - se = sei >> 1 ; /* se = estimated signal */ - - d = sl - se ; /* d = estimation difference */ - - /* quantize prediction difference */ - y = step_size (state_ptr) ; /* adaptive quantizer step size */ - i = quantize (d, y, qtab_723_40, 15) ; /* i = ADPCM code */ - - dq = reconstruct (i & 0x10, _dqlntab [i], y) ; /* quantized diff */ - - sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq ; /* reconstructed signal */ - - dqsez = sr + sez - se ; /* dqsez = pole prediction diff. */ - - update (5, y, _witab [i], _fitab [i], dq, sr, dqsez, state_ptr) ; - - return i ; -} - -/* - * g723_40_decoder () - * - * Decodes a 5-bit CCITT G.723 40Kbps code and returns - * the resulting 16-bit linear PCM, A-law or u-law sample value. - * -1 is returned if the output coding is unknown. - */ -int g723_40_decoder (int i, G72x_STATE *state_ptr) -{ - short sezi, sei, sez, se ; /* ACCUM */ - short y ; /* MIX */ - short sr ; /* ADDB */ - short dq ; - short dqsez ; - - i &= 0x1f ; /* mask to get proper bits */ - sezi = predictor_zero (state_ptr) ; - sez = sezi >> 1 ; - sei = sezi + predictor_pole (state_ptr) ; - se = sei >> 1 ; /* se = estimated signal */ - - y = step_size (state_ptr) ; /* adaptive quantizer step size */ - dq = reconstruct (i & 0x10, _dqlntab [i], y) ; /* estimation diff. */ - - sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq) ; /* reconst. signal */ - - dqsez = sr - se + sez ; /* pole prediction diff. */ - - update (5, y, _witab [i], _fitab [i], dq, sr, dqsez, state_ptr) ; - - return arith_shift_left (sr, 2) ; /* sr was of 14-bit dynamic range */ -} - diff --git a/Engine/lib/libsndfile/src/G72x/g72x.c b/Engine/lib/libsndfile/src/G72x/g72x.c deleted file mode 100644 index 2d6469cf1..000000000 --- a/Engine/lib/libsndfile/src/G72x/g72x.c +++ /dev/null @@ -1,645 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * g72x.c - * - * Common routines for G.721 and G.723 conversions. - */ - -#include -#include -#include - -#include "g72x.h" -#include "g72x_priv.h" - -static G72x_STATE * g72x_state_new (void) ; -static int unpack_bytes (int bits, int blocksize, const unsigned char * block, short * samples) ; -static int pack_bytes (int bits, const short * samples, unsigned char * block) ; - -static -short power2 [15] = -{ 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, - 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000 -} ; - -/* - * quan () - * - * quantizes the input val against the table of size short integers. - * It returns i if table [i - 1] <= val < table [i]. - * - * Using linear search for simple coding. - */ -static -int quan (int val, short *table, int size) -{ - int i ; - - for (i = 0 ; i < size ; i++) - if (val < *table++) - break ; - return i ; -} - -/* - * fmult () - * - * returns the integer product of the 14-bit integer "an" and - * "floating point" representation (4-bit exponent, 6-bit mantessa) "srn". - */ -static -int fmult (int an, int srn) -{ - short anmag, anexp, anmant ; - short wanexp, wanmant ; - short retval ; - - anmag = (an > 0) ? an : ((-an) & 0x1FFF) ; - anexp = quan (anmag, power2, 15) - 6 ; - anmant = (anmag == 0) ? 32 : - (anexp >= 0) ? anmag >> anexp : anmag << -anexp ; - wanexp = anexp + ((srn >> 6) & 0xF) - 13 ; - - /* - ** The original was : - ** wanmant = (anmant * (srn & 0x3F) + 0x30) >> 4 ; - ** but could see no valid reason for the + 0x30. - ** Removed it and it improved the SNR of the codec. - */ - - wanmant = (anmant * (srn & 0x3F)) >> 4 ; - - retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) : (wanmant >> -wanexp) ; - - return (((an ^ srn) < 0) ? -retval : retval) ; -} - -static G72x_STATE * g72x_state_new (void) -{ return calloc (1, sizeof (G72x_STATE)) ; -} - -/* - * private_init_state () - * - * This routine initializes and/or resets the G72x_PRIVATE structure - * pointed to by 'state_ptr'. - * All the initial state values are specified in the CCITT G.721 document. - */ -void private_init_state (G72x_STATE *state_ptr) -{ - int cnta ; - - state_ptr->yl = 34816 ; - state_ptr->yu = 544 ; - state_ptr->dms = 0 ; - state_ptr->dml = 0 ; - state_ptr->ap = 0 ; - for (cnta = 0 ; cnta < 2 ; cnta++) - { state_ptr->a [cnta] = 0 ; - state_ptr->pk [cnta] = 0 ; - state_ptr->sr [cnta] = 32 ; - } - for (cnta = 0 ; cnta < 6 ; cnta++) - { state_ptr->b [cnta] = 0 ; - state_ptr->dq [cnta] = 32 ; - } - state_ptr->td = 0 ; -} /* private_init_state */ - -struct g72x_state * g72x_reader_init (int codec, int *blocksize, int *samplesperblock) -{ G72x_STATE *pstate ; - - if ((pstate = g72x_state_new ()) == NULL) - return NULL ; - - private_init_state (pstate) ; - - pstate->encoder = NULL ; - - switch (codec) - { case G723_16_BITS_PER_SAMPLE : /* 2 bits per sample. */ - pstate->decoder = g723_16_decoder ; - *blocksize = G723_16_BYTES_PER_BLOCK ; - *samplesperblock = G723_16_SAMPLES_PER_BLOCK ; - pstate->codec_bits = 2 ; - pstate->blocksize = G723_16_BYTES_PER_BLOCK ; - pstate->samplesperblock = G723_16_SAMPLES_PER_BLOCK ; - break ; - - case G723_24_BITS_PER_SAMPLE : /* 3 bits per sample. */ - pstate->decoder = g723_24_decoder ; - *blocksize = G723_24_BYTES_PER_BLOCK ; - *samplesperblock = G723_24_SAMPLES_PER_BLOCK ; - pstate->codec_bits = 3 ; - pstate->blocksize = G723_24_BYTES_PER_BLOCK ; - pstate->samplesperblock = G723_24_SAMPLES_PER_BLOCK ; - break ; - - case G721_32_BITS_PER_SAMPLE : /* 4 bits per sample. */ - pstate->decoder = g721_decoder ; - *blocksize = G721_32_BYTES_PER_BLOCK ; - *samplesperblock = G721_32_SAMPLES_PER_BLOCK ; - pstate->codec_bits = 4 ; - pstate->blocksize = G721_32_BYTES_PER_BLOCK ; - pstate->samplesperblock = G721_32_SAMPLES_PER_BLOCK ; - break ; - - case G721_40_BITS_PER_SAMPLE : /* 5 bits per sample. */ - pstate->decoder = g723_40_decoder ; - *blocksize = G721_40_BYTES_PER_BLOCK ; - *samplesperblock = G721_40_SAMPLES_PER_BLOCK ; - pstate->codec_bits = 5 ; - pstate->blocksize = G721_40_BYTES_PER_BLOCK ; - pstate->samplesperblock = G721_40_SAMPLES_PER_BLOCK ; - break ; - - default : - free (pstate) ; - return NULL ; - } ; - - return pstate ; -} /* g72x_reader_init */ - -struct g72x_state * g72x_writer_init (int codec, int *blocksize, int *samplesperblock) -{ G72x_STATE *pstate ; - - if ((pstate = g72x_state_new ()) == NULL) - return NULL ; - - private_init_state (pstate) ; - pstate->decoder = NULL ; - - switch (codec) - { case G723_16_BITS_PER_SAMPLE : /* 2 bits per sample. */ - pstate->encoder = g723_16_encoder ; - *blocksize = G723_16_BYTES_PER_BLOCK ; - *samplesperblock = G723_16_SAMPLES_PER_BLOCK ; - pstate->codec_bits = 2 ; - pstate->blocksize = G723_16_BYTES_PER_BLOCK ; - pstate->samplesperblock = G723_16_SAMPLES_PER_BLOCK ; - break ; - - case G723_24_BITS_PER_SAMPLE : /* 3 bits per sample. */ - pstate->encoder = g723_24_encoder ; - *blocksize = G723_24_BYTES_PER_BLOCK ; - *samplesperblock = G723_24_SAMPLES_PER_BLOCK ; - pstate->codec_bits = 3 ; - pstate->blocksize = G723_24_BYTES_PER_BLOCK ; - pstate->samplesperblock = G723_24_SAMPLES_PER_BLOCK ; - break ; - - case G721_32_BITS_PER_SAMPLE : /* 4 bits per sample. */ - pstate->encoder = g721_encoder ; - *blocksize = G721_32_BYTES_PER_BLOCK ; - *samplesperblock = G721_32_SAMPLES_PER_BLOCK ; - pstate->codec_bits = 4 ; - pstate->blocksize = G721_32_BYTES_PER_BLOCK ; - pstate->samplesperblock = G721_32_SAMPLES_PER_BLOCK ; - break ; - - case G721_40_BITS_PER_SAMPLE : /* 5 bits per sample. */ - pstate->encoder = g723_40_encoder ; - *blocksize = G721_40_BYTES_PER_BLOCK ; - *samplesperblock = G721_40_SAMPLES_PER_BLOCK ; - pstate->codec_bits = 5 ; - pstate->blocksize = G721_40_BYTES_PER_BLOCK ; - pstate->samplesperblock = G721_40_SAMPLES_PER_BLOCK ; - break ; - - default : - free (pstate) ; - return NULL ; - } ; - - return pstate ; -} /* g72x_writer_init */ - -int g72x_decode_block (G72x_STATE *pstate, const unsigned char *block, short *samples) -{ int k, count ; - - count = unpack_bytes (pstate->codec_bits, pstate->blocksize, block, samples) ; - - for (k = 0 ; k < count ; k++) - samples [k] = pstate->decoder (samples [k], pstate) ; - - return 0 ; -} /* g72x_decode_block */ - -int g72x_encode_block (G72x_STATE *pstate, short *samples, unsigned char *block) -{ int k, count ; - - for (k = 0 ; k < pstate->samplesperblock ; k++) - samples [k] = pstate->encoder (samples [k], pstate) ; - - count = pack_bytes (pstate->codec_bits, samples, block) ; - - return count ; -} /* g72x_encode_block */ - -/* - * predictor_zero () - * - * computes the estimated signal from 6-zero predictor. - * - */ -int predictor_zero (G72x_STATE *state_ptr) -{ - int i ; - int sezi ; - - sezi = fmult (state_ptr->b [0] >> 2, state_ptr->dq [0]) ; - for (i = 1 ; i < 6 ; i++) /* ACCUM */ - sezi += fmult (state_ptr->b [i] >> 2, state_ptr->dq [i]) ; - return sezi ; -} -/* - * predictor_pole () - * - * computes the estimated signal from 2-pole predictor. - * - */ -int predictor_pole (G72x_STATE *state_ptr) -{ - return (fmult (state_ptr->a [1] >> 2, state_ptr->sr [1]) + - fmult (state_ptr->a [0] >> 2, state_ptr->sr [0])) ; -} -/* - * step_size () - * - * computes the quantization step size of the adaptive quantizer. - * - */ -int step_size (G72x_STATE *state_ptr) -{ - int y ; - int dif ; - int al ; - - if (state_ptr->ap >= 256) - return (state_ptr->yu) ; - else { - y = state_ptr->yl >> 6 ; - dif = state_ptr->yu - y ; - al = state_ptr->ap >> 2 ; - if (dif > 0) - y += (dif * al) >> 6 ; - else if (dif < 0) - y += (dif * al + 0x3F) >> 6 ; - return y ; - } -} - -/* - * quantize () - * - * Given a raw sample, 'd', of the difference signal and a - * quantization step size scale factor, 'y', this routine returns the - * ADPCM codeword to which that sample gets quantized. The step - * size scale factor division operation is done in the log base 2 domain - * as a subtraction. - */ -int quantize ( - int d, /* Raw difference signal sample */ - int y, /* Step size multiplier */ - short *table, /* quantization table */ - int size) /* table size of short integers */ -{ - short dqm ; /* Magnitude of 'd' */ - short expon ; /* Integer part of base 2 log of 'd' */ - short mant ; /* Fractional part of base 2 log */ - short dl ; /* Log of magnitude of 'd' */ - short dln ; /* Step size scale factor normalized log */ - int i ; - - /* - * LOG - * - * Compute base 2 log of 'd', and store in 'dl'. - */ - dqm = abs (d) ; - expon = quan (dqm >> 1, power2, 15) ; - mant = ((dqm << 7) >> expon) & 0x7F ; /* Fractional portion. */ - dl = (expon << 7) + mant ; - - /* - * SUBTB - * - * "Divide" by step size multiplier. - */ - dln = dl - (y >> 2) ; - - /* - * QUAN - * - * Obtain codword i for 'd'. - */ - i = quan (dln, table, size) ; - if (d < 0) /* take 1's complement of i */ - return ((size << 1) + 1 - i) ; - else if (i == 0) /* take 1's complement of 0 */ - return ((size << 1) + 1) ; /* new in 1988 */ - - return i ; -} -/* - * reconstruct () - * - * Returns reconstructed difference signal 'dq' obtained from - * codeword 'i' and quantization step size scale factor 'y'. - * Multiplication is performed in log base 2 domain as addition. - */ -int -reconstruct ( - int sign, /* 0 for non-negative value */ - int dqln, /* G.72x codeword */ - int y) /* Step size multiplier */ -{ - short dql ; /* Log of 'dq' magnitude */ - short dex ; /* Integer part of log */ - short dqt ; - short dq ; /* Reconstructed difference signal sample */ - - dql = dqln + (y >> 2) ; /* ADDA */ - - if (dql < 0) - return ((sign) ? -0x8000 : 0) ; - else /* ANTILOG */ - { dex = (dql >> 7) & 15 ; - dqt = 128 + (dql & 127) ; - dq = (dqt << 7) >> (14 - dex) ; - return ((sign) ? (dq - 0x8000) : dq) ; - } -} - - -/* - * update () - * - * updates the state variables for each output code - */ -void -update ( - int code_size, /* distinguish 723_40 with others */ - int y, /* quantizer step size */ - int wi, /* scale factor multiplier */ - int fi, /* for long/short term energies */ - int dq, /* quantized prediction difference */ - int sr, /* reconstructed signal */ - int dqsez, /* difference from 2-pole predictor */ - G72x_STATE *state_ptr) /* coder state pointer */ -{ - int cnt ; - short mag, expon ; /* Adaptive predictor, FLOAT A */ - short a2p = 0 ; /* LIMC */ - short a1ul ; /* UPA1 */ - short pks1 ; /* UPA2 */ - short fa1 ; - char tr ; /* tone/transition detector */ - short ylint, thr2, dqthr ; - short ylfrac, thr1 ; - short pk0 ; - - pk0 = (dqsez < 0) ? 1 : 0 ; /* needed in updating predictor poles */ - - mag = dq & 0x7FFF ; /* prediction difference magnitude */ - /* TRANS */ - ylint = state_ptr->yl >> 15 ; /* exponent part of yl */ - ylfrac = (state_ptr->yl >> 10) & 0x1F ; /* fractional part of yl */ - thr1 = (32 + ylfrac) << ylint ; /* threshold */ - thr2 = (ylint > 9) ? 31 << 10 : thr1 ; /* limit thr2 to 31 << 10 */ - dqthr = (thr2 + (thr2 >> 1)) >> 1 ; /* dqthr = 0.75 * thr2 */ - if (state_ptr->td == 0) /* signal supposed voice */ - tr = 0 ; - else if (mag <= dqthr) /* supposed data, but small mag */ - tr = 0 ; /* treated as voice */ - else /* signal is data (modem) */ - tr = 1 ; - - /* - * Quantizer scale factor adaptation. - */ - - /* FUNCTW & FILTD & DELAY */ - /* update non-steady state step size multiplier */ - state_ptr->yu = y + ((wi - y) >> 5) ; - - /* LIMB */ - if (state_ptr->yu < 544) /* 544 <= yu <= 5120 */ - state_ptr->yu = 544 ; - else if (state_ptr->yu > 5120) - state_ptr->yu = 5120 ; - - /* FILTE & DELAY */ - /* update steady state step size multiplier */ - state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6) ; - - /* - * Adaptive predictor coefficients. - */ - if (tr == 1) { /* reset a's and b's for modem signal */ - state_ptr->a [0] = 0 ; - state_ptr->a [1] = 0 ; - state_ptr->b [0] = 0 ; - state_ptr->b [1] = 0 ; - state_ptr->b [2] = 0 ; - state_ptr->b [3] = 0 ; - state_ptr->b [4] = 0 ; - state_ptr->b [5] = 0 ; - } - else /* update a's and b's */ - { pks1 = pk0 ^ state_ptr->pk [0] ; /* UPA2 */ - - /* update predictor pole a [1] */ - a2p = state_ptr->a [1] - (state_ptr->a [1] >> 7) ; - if (dqsez != 0) - { fa1 = (pks1) ? state_ptr->a [0] : -state_ptr->a [0] ; - if (fa1 < -8191) /* a2p = function of fa1 */ - a2p -= 0x100 ; - else if (fa1 > 8191) - a2p += 0xFF ; - else - a2p += fa1 >> 5 ; - - if (pk0 ^ state_ptr->pk [1]) - { /* LIMC */ - if (a2p <= -12160) - a2p = -12288 ; - else if (a2p >= 12416) - a2p = 12288 ; - else - a2p -= 0x80 ; - } - else if (a2p <= -12416) - a2p = -12288 ; - else if (a2p >= 12160) - a2p = 12288 ; - else - a2p += 0x80 ; - } - - /* TRIGB & DELAY */ - state_ptr->a [1] = a2p ; - - /* UPA1 */ - /* update predictor pole a [0] */ - state_ptr->a [0] -= state_ptr->a [0] >> 8 ; - if (dqsez != 0) - { if (pks1 == 0) - state_ptr->a [0] += 192 ; - else - state_ptr->a [0] -= 192 ; - } ; - - /* LIMD */ - a1ul = 15360 - a2p ; - if (state_ptr->a [0] < -a1ul) - state_ptr->a [0] = -a1ul ; - else if (state_ptr->a [0] > a1ul) - state_ptr->a [0] = a1ul ; - - /* UPB : update predictor zeros b [6] */ - for (cnt = 0 ; cnt < 6 ; cnt++) - { if (code_size == 5) /* for 40Kbps G.723 */ - state_ptr->b [cnt] -= state_ptr->b [cnt] >> 9 ; - else /* for G.721 and 24Kbps G.723 */ - state_ptr->b [cnt] -= state_ptr->b [cnt] >> 8 ; - if (dq & 0x7FFF) /* XOR */ - { if ((dq ^ state_ptr->dq [cnt]) >= 0) - state_ptr->b [cnt] += 128 ; - else - state_ptr->b [cnt] -= 128 ; - } - } - } - - for (cnt = 5 ; cnt > 0 ; cnt--) - state_ptr->dq [cnt] = state_ptr->dq [cnt - 1] ; - /* FLOAT A : convert dq [0] to 4-bit exp, 6-bit mantissa f.p. */ - if (mag == 0) - state_ptr->dq [0] = (dq >= 0) ? 0x20 : 0xFC20 ; - else - { expon = quan (mag, power2, 15) ; - state_ptr->dq [0] = (dq >= 0) ? - (expon << 6) + ((mag << 6) >> expon) : - (expon << 6) + ((mag << 6) >> expon) - 0x400 ; - } - - state_ptr->sr [1] = state_ptr->sr [0] ; - /* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */ - if (sr == 0) - state_ptr->sr [0] = 0x20 ; - else if (sr > 0) - { expon = quan (sr, power2, 15) ; - state_ptr->sr [0] = (expon << 6) + ((sr << 6) >> expon) ; - } - else if (sr > -32768) - { mag = -sr ; - expon = quan (mag, power2, 15) ; - state_ptr->sr [0] = (expon << 6) + ((mag << 6) >> expon) - 0x400 ; - } - else - state_ptr->sr [0] = (short) 0xFC20 ; - - /* DELAY A */ - state_ptr->pk [1] = state_ptr->pk [0] ; - state_ptr->pk [0] = pk0 ; - - /* TONE */ - if (tr == 1) /* this sample has been treated as data */ - state_ptr->td = 0 ; /* next one will be treated as voice */ - else if (a2p < -11776) /* small sample-to-sample correlation */ - state_ptr->td = 1 ; /* signal may be data */ - else /* signal is voice */ - state_ptr->td = 0 ; - - /* - * Adaptation speed control. - */ - state_ptr->dms += (fi - state_ptr->dms) >> 5 ; /* FILTA */ - state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7) ; /* FILTB */ - - if (tr == 1) - state_ptr->ap = 256 ; - else if (y < 1536) /* SUBTC */ - state_ptr->ap += (0x200 - state_ptr->ap) >> 4 ; - else if (state_ptr->td == 1) - state_ptr->ap += (0x200 - state_ptr->ap) >> 4 ; - else if (abs ((state_ptr->dms << 2) - state_ptr->dml) >= (state_ptr->dml >> 3)) - state_ptr->ap += (0x200 - state_ptr->ap) >> 4 ; - else - state_ptr->ap += (-state_ptr->ap) >> 4 ; - - return ; -} /* update */ - -/*------------------------------------------------------------------------------ -*/ - -static int -unpack_bytes (int bits, int blocksize, const unsigned char * block, short * samples) -{ unsigned int in_buffer = 0 ; - unsigned char in_byte ; - int k, in_bits = 0, bindex = 0 ; - - for (k = 0 ; bindex <= blocksize && k < G72x_BLOCK_SIZE ; k++) - { if (in_bits < bits) - { in_byte = block [bindex++] ; - - in_buffer |= (in_byte << in_bits) ; - in_bits += 8 ; - } - samples [k] = in_buffer & ((1 << bits) - 1) ; - in_buffer >>= bits ; - in_bits -= bits ; - } ; - - return k ; -} /* unpack_bytes */ - -static int -pack_bytes (int bits, const short * samples, unsigned char * block) -{ - unsigned int out_buffer = 0 ; - int k, bindex = 0, out_bits = 0 ; - unsigned char out_byte ; - - for (k = 0 ; k < G72x_BLOCK_SIZE ; k++) - { out_buffer |= (samples [k] << out_bits) ; - out_bits += bits ; - if (out_bits >= 8) - { out_byte = out_buffer & 0xFF ; - out_bits -= 8 ; - out_buffer >>= 8 ; - block [bindex++] = out_byte ; - } - } ; - - return bindex ; -} /* pack_bytes */ - diff --git a/Engine/lib/libsndfile/src/G72x/g72x.h b/Engine/lib/libsndfile/src/G72x/g72x.h deleted file mode 100644 index d7631e6d8..000000000 --- a/Engine/lib/libsndfile/src/G72x/g72x.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -** Copyright (C) 1999-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** This file is not the same as the original file from Sun Microsystems. Nearly -** all the original definitions and function prototypes that were in the file -** of this name have been moved to g72x_priv.h. -*/ - -#ifndef G72X_HEADER_FILE -#define G72X_HEADER_FILE - -/* -** Number of samples per block to process. -** Must be a common multiple of possible bits per sample : 2, 3, 4, 5 and 8. -*/ -#define G72x_BLOCK_SIZE (3 * 5 * 8) - -/* -** Identifiers for the differing kinds of G72x ADPCM codecs. -** The identifiers also define the number of encoded bits per sample. -*/ - -enum -{ G723_16_BITS_PER_SAMPLE = 2, - G723_24_BITS_PER_SAMPLE = 3, - G723_40_BITS_PER_SAMPLE = 5, - - G721_32_BITS_PER_SAMPLE = 4, - G721_40_BITS_PER_SAMPLE = 5, - - G723_16_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, - G723_24_SAMPLES_PER_BLOCK = G723_24_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_24_BITS_PER_SAMPLE), - G723_40_SAMPLES_PER_BLOCK = G723_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_40_BITS_PER_SAMPLE), - - G721_32_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, - G721_40_SAMPLES_PER_BLOCK = G721_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G721_40_BITS_PER_SAMPLE), - - G723_16_BYTES_PER_BLOCK = (G723_16_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, - G723_24_BYTES_PER_BLOCK = (G723_24_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, - G723_40_BYTES_PER_BLOCK = (G723_40_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, - - G721_32_BYTES_PER_BLOCK = (G721_32_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, - G721_40_BYTES_PER_BLOCK = (G721_40_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8 -} ; - -/* Forward declaration of of g72x_state. */ - -struct g72x_state ; - -/* External function definitions. */ - -struct g72x_state * g72x_reader_init (int codec, int *blocksize, int *samplesperblock) ; -struct g72x_state * g72x_writer_init (int codec, int *blocksize, int *samplesperblock) ; -/* -** Initialize the ADPCM state table for the given codec. -** Return 0 on success, 1 on fail. -*/ - -int g72x_decode_block (struct g72x_state *pstate, const unsigned char *block, short *samples) ; -/* -** The caller fills data->block with data->bytes bytes before calling the -** function. The value data->bytes must be an integer multiple of -** data->blocksize and be <= data->max_bytes. -** When it returns, the caller can read out data->samples samples. -*/ - -int g72x_encode_block (struct g72x_state *pstate, short *samples, unsigned char *block) ; -/* -** The caller fills state->samples some integer multiple data->samples_per_block -** (up to G72x_BLOCK_SIZE) samples before calling the function. -** When it returns, the caller can read out bytes encoded bytes. -*/ - -#endif /* !G72X_HEADER_FILE */ - diff --git a/Engine/lib/libsndfile/src/G72x/g72x_priv.h b/Engine/lib/libsndfile/src/G72x/g72x_priv.h deleted file mode 100644 index 6a194ec3f..000000000 --- a/Engine/lib/libsndfile/src/G72x/g72x_priv.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This source code is a product of Sun Microsystems, Inc. and is provided - * for unrestricted use. Users may copy or modify this source code without - * charge. - * - * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING - * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun source code is provided with no support and without any obligation on - * the part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#ifndef G72X_PRIVATE_H -#define G72X_PRIVATE_H - -#ifdef __cplusplus -#error "This code is not designed to be compiled with a C++ compiler." -#endif - -/* -** The following is the definition of the state structure used by the -** G.721/G.723 encoder and decoder to preserve their internal state -** between successive calls. The meanings of the majority of the state -** structure fields are explained in detail in the CCITT Recommendation -** G.721. The field names are essentially identical to variable names -** in the bit level description of the coding algorithm included in this -** Recommendation. -*/ - -struct g72x_state -{ long yl ; /* Locked or steady state step size multiplier. */ - short yu ; /* Unlocked or non-steady state step size multiplier. */ - short dms ; /* Short term energy estimate. */ - short dml ; /* Long term energy estimate. */ - short ap ; /* Linear weighting coefficient of 'yl' and 'yu'. */ - - short a [2] ; /* Coefficients of pole portion of prediction filter. */ - short b [6] ; /* Coefficients of zero portion of prediction filter. */ - short pk [2] ; /* - ** Signs of previous two samples of a partially - ** reconstructed signal. - **/ - short dq [6] ; /* - ** Previous 6 samples of the quantized difference - ** signal represented in an internal floating point - ** format. - **/ - short sr [2] ; /* - ** Previous 2 samples of the quantized difference - ** signal represented in an internal floating point - ** format. - */ - char td ; /* delayed tone detect, new in 1988 version */ - - /* The following struct members were added for libsndfile. The original - ** code worked by calling a set of functions on a sample by sample basis - ** which is slow on architectures like Intel x86. For libsndfile, this - ** was changed so that the encoding and decoding routines could work on - ** a block of samples at a time to reduce the function call overhead. - */ - int (*encoder) (int, struct g72x_state* state) ; - int (*decoder) (int, struct g72x_state* state) ; - - int codec_bits, blocksize, samplesperblock ; -} ; - -typedef struct g72x_state G72x_STATE ; - -int predictor_zero (G72x_STATE *state_ptr) ; - -int predictor_pole (G72x_STATE *state_ptr) ; - -int step_size (G72x_STATE *state_ptr) ; - -int quantize (int d, int y, short *table, int size) ; - -int reconstruct (int sign, int dqln, int y) ; - -void update (int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, G72x_STATE *state_ptr) ; - -int g721_encoder (int sample, G72x_STATE *state_ptr) ; -int g721_decoder (int code, G72x_STATE *state_ptr) ; - -int g723_16_encoder (int sample, G72x_STATE *state_ptr) ; -int g723_16_decoder (int code, G72x_STATE *state_ptr) ; - -int g723_24_encoder (int sample, G72x_STATE *state_ptr) ; -int g723_24_decoder (int code, G72x_STATE *state_ptr) ; - -int g723_40_encoder (int sample, G72x_STATE *state_ptr) ; -int g723_40_decoder (int code, G72x_STATE *state_ptr) ; - -void private_init_state (G72x_STATE *state_ptr) ; - -#if __GNUC__ -#define ALWAYS_INLINE __attribute__ ((always_inline)) -#elif defined _MSC_VER -#define ALWAYS_INLINE __forceinline -#else -#define ALWAYS_INLINE -#endif - -static inline int ALWAYS_INLINE -arith_shift_left (int x, int shift) -{ return (int) (((unsigned int) x) << shift) ; -} /* arith_shift_left */ - -static inline int ALWAYS_INLINE -arith_shift_right (int x, int shift) -{ if (x >= 0) - return x << shift ; - return ~ ((~x) << shift) ; -} /* arith_shift_right */ - -#endif /* G72X_PRIVATE_H */ diff --git a/Engine/lib/libsndfile/src/G72x/g72x_test.c b/Engine/lib/libsndfile/src/G72x/g72x_test.c deleted file mode 100644 index e8a976773..000000000 --- a/Engine/lib/libsndfile/src/G72x/g72x_test.c +++ /dev/null @@ -1,220 +0,0 @@ -/* -** Copyright (C) 1999-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif -#include -#include -#include - -#include "g72x.h" -#include "g72x_priv.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846264338 -#endif - -#define BUFFER_SIZE (1 << 14) -#define SAMPLE_RATE 11025 - - -static void g721_test (void) ; -static void g723_test (double margin) ; - -static void gen_signal_double (double *data, double scale, int datalen) ; -static int error_function (double data, double orig, double margin) ; - -static int oct_save_short (short *a, short *b, int len) ; - -int -main (int argc, char *argv []) -{ int bDoAll = 0 ; - int nTests = 0 ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" g721 - test G721 encoder and decoder\n") ; - printf (" g723 - test G721 encoder and decoder\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - bDoAll = !strcmp (argv [1], "all") ; - - if (bDoAll || ! strcmp (argv [1], "g721")) - { g721_test () ; - nTests++ ; - } ; - - if (bDoAll || ! strcmp (argv [1], "g723")) - { g723_test (0.53) ; - nTests++ ; - } ; - - if (nTests == 0) - { printf ("Mono : ************************************\n") ; - printf ("Mono : * No '%s' test defined.\n", argv [1]) ; - printf ("Mono : ************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - -static void -g721_test (void) -{ - return ; -} /* g721_test */ - -static void -g723_test (double margin) -{ static double orig_buffer [BUFFER_SIZE] ; - static short orig [BUFFER_SIZE] ; - static short data [BUFFER_SIZE] ; - - G72x_STATE encoder_state, decoder_state ; - - long k ; - int code, position, max_err ; - - private_init_state (&encoder_state) ; - encoder_state.encoder = g723_24_encoder ; - encoder_state.codec_bits = 3 ; - - private_init_state (&decoder_state) ; - decoder_state.decoder = g723_24_decoder ; - decoder_state.codec_bits = 3 ; - - memset (data, 0, BUFFER_SIZE * sizeof (short)) ; - memset (orig, 0, BUFFER_SIZE * sizeof (short)) ; - - printf (" g723_test : ") ; - fflush (stdout) ; - - gen_signal_double (orig_buffer, 32000.0, BUFFER_SIZE) ; - for (k = 0 ; k < BUFFER_SIZE ; k++) - orig [k] = (short) orig_buffer [k] ; - - /* Write and read data here. */ - position = 0 ; - max_err = 0 ; - for (k = 0 ; k < BUFFER_SIZE ; k++) - { code = encoder_state.encoder (orig [k], &encoder_state) ; - data [k] = decoder_state.decoder (code, &decoder_state) ; - if (abs (orig [k] - data [k]) > max_err) - { position = k ; - max_err = abs (orig [k] - data [k]) ; - } ; - } ; - - printf ("\n\nMax error of %d at postion %d.\n", max_err, position) ; - - for (k = 0 ; k < BUFFER_SIZE ; k++) - { if (error_function (data [k], orig [k], margin)) - { printf ("Line %d: Incorrect sample A (#%ld : %d should be %d).\n", __LINE__, k, data [k], orig [k]) ; - oct_save_short (orig, data, BUFFER_SIZE) ; - exit (1) ; - } ; - } ; - - - printf ("ok\n") ; - - return ; -} /* g723_test */ - - -#define SIGNAL_MAXVAL 30000.0 -#define DECAY_COUNT 1000 - -static void -gen_signal_double (double *gendata, double scale, int gendatalen) -{ int k, ramplen ; - double amp = 0.0 ; - - ramplen = DECAY_COUNT ; - - for (k = 0 ; k < gendatalen ; k++) - { if (k <= ramplen) - amp = scale * k / ((double) ramplen) ; - else if (k > gendatalen - ramplen) - amp = scale * (gendatalen - k) / ((double) ramplen) ; - - gendata [k] = amp * (0.4 * sin (33.3 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE)) - + 0.3 * cos (201.1 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))) ; - } ; - - return ; -} /* gen_signal_double */ - -static int -error_function (double data, double orig, double margin) -{ double error ; - - if (fabs (orig) <= 500.0) - error = fabs (fabs (data) - fabs (orig)) / 2000.0 ; - else if (fabs (orig) <= 1000.0) - error = fabs (data - orig) / 3000.0 ; - else - error = fabs (data - orig) / fabs (orig) ; - - if (error > margin) - { printf ("\n\n*******************\nError : %f\n", error) ; - return 1 ; - } ; - return 0 ; -} /* error_function */ - -static int -oct_save_short (short *a, short *b, int len) -{ FILE *file ; - int k ; - - if (! (file = fopen ("error.dat", "w"))) - return 1 ; - - fprintf (file, "# Not created by Octave\n") ; - - fprintf (file, "# name: a\n") ; - fprintf (file, "# type: matrix\n") ; - fprintf (file, "# rows: %d\n", len) ; - fprintf (file, "# columns: 1\n") ; - - for (k = 0 ; k < len ; k++) - fprintf (file, "% d\n", a [k]) ; - - fprintf (file, "# name: b\n") ; - fprintf (file, "# type: matrix\n") ; - fprintf (file, "# rows: %d\n", len) ; - fprintf (file, "# columns: 1\n") ; - - for (k = 0 ; k < len ; k++) - fprintf (file, "% d\n", b [k]) ; - - fclose (file) ; - return 0 ; -} /* oct_save_short */ - diff --git a/Engine/lib/libsndfile/src/GSM610/COPYRIGHT b/Engine/lib/libsndfile/src/GSM610/COPYRIGHT deleted file mode 100644 index eba0e523b..000000000 --- a/Engine/lib/libsndfile/src/GSM610/COPYRIGHT +++ /dev/null @@ -1,16 +0,0 @@ -Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, -Technische Universitaet Berlin - -Any use of this software is permitted provided that this notice is not -removed and that neither the authors nor the Technische Universitaet Berlin -are deemed to have made any representations as to the suitability of this -software for any purpose nor are held responsible for any defects of -this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - -As a matter of courtesy, the authors request to be informed about uses -this software has found, about bugs in this software, and about any -improvements that may be of general interest. - -Berlin, 28.11.1994 -Jutta Degener -Carsten Bormann diff --git a/Engine/lib/libsndfile/src/GSM610/ChangeLog b/Engine/lib/libsndfile/src/GSM610/ChangeLog deleted file mode 100644 index 24f524882..000000000 --- a/Engine/lib/libsndfile/src/GSM610/ChangeLog +++ /dev/null @@ -1,56 +0,0 @@ -2004-05-12 Erik de Castro Lopo - - * gsm610_priv.h - Replace ugly macros with inline functions. - - * *.c - Remove temporary variables used by macros and other minor fixes required by - above change. - -2003-06-02 Erik de Castro Lopo - - * rpe.c - Renamed variables "exp" to "expon" to avoid shadowed parameter warnigns. - -2002-06-08 Erik de Castro Lopo - - * long_term.c - Changes tp removed compiler warnings about shadowed parameters. - -2002-06-08 Erik de Castro Lopo - - * private.h - Made declarations of gsm_A, gsm_B, gsm_MIC etc extern. This fixed a compile - problem on MacOSX. - -2002-05-10 Erik de Castro Lopo - - * *.[ch] - Removed all pre-ANSI prototype kludges. Removed proto.h and unproto.h. - Started work on making GSM 6.10 files seekable. Currently they are not. - - * code.c private.h - Function Gsm_Coder () used a statically defined array. This was obviously - not re-entrant so moved it to struct gsm_state. - -2001-09-16 Erik de Castro Lopo - - * code.c - Added #includes for string.h and stdlib.h. - -2000-10-27 Erik de Castro Lopo - - * config.h - Removed some commented out #defines (ie //*efine) which were causing problems on - the Sun cc compiler. - -2000-02-29 Erik de Castro Lopo - - * private.h - Added #defines to emulate normal compile time options. - -2000-02-28 Erik de Castro Lopo - - * everthing - Created this directory and copied files from libgsm. - http://kbs.cs.tu-berlin.de/~jutta/toast.html diff --git a/Engine/lib/libsndfile/src/GSM610/README b/Engine/lib/libsndfile/src/GSM610/README deleted file mode 100644 index b57132b05..000000000 --- a/Engine/lib/libsndfile/src/GSM610/README +++ /dev/null @@ -1,36 +0,0 @@ -GSM 06.10 13 kbit/s RPE/LTP speech codec ----------------------------------------- - -All the file in this directory were written by Jutta Degener -and Carsten Borman for The Communications and Operating Systems -Research Group (KBS) at the Technische Universitaet Berlin. - -Their work was released under the following license which is -assumed to be compatible with The GNU Lesser General Public License. - ----------------------------------------------------------------------------- - -Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, -Technische Universitaet Berlin - -Any use of this software is permitted provided that this notice is not -removed and that neither the authors nor the Technische Universitaet Berlin -are deemed to have made any representations as to the suitability of this -software for any purpose nor are held responsible for any defects of -this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - -As a matter of courtesy, the authors request to be informed about uses -this software has found, about bugs in this software, and about any -improvements that may be of general interest. - -Berlin, 28.11.1994 -Jutta Degener (jutta@cs.tu-berlin.de) -Carsten Bormann (cabo@cs.tu-berlin.de) - ----------------------------------------------------------------------------- - -Jutta Degener and Carsten Bormann's work can be found on their homepage -at: - - http://kbs.cs.tu-berlin.de/~jutta/toast.html - diff --git a/Engine/lib/libsndfile/src/GSM610/add.c b/Engine/lib/libsndfile/src/GSM610/add.c deleted file mode 100644 index c943eec7b..000000000 --- a/Engine/lib/libsndfile/src/GSM610/add.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* - * See private.h for the more commonly used macro versions. - */ - -#include -#include - -#include "gsm610_priv.h" - -#define saturate(x) \ - ((x) < MIN_WORD ? MIN_WORD : (x) > MAX_WORD ? MAX_WORD: (x)) - -int16_t gsm_add (int16_t a, int16_t b) -{ - int32_t sum = (int32_t) a + (int32_t) b ; - return saturate (sum) ; -} - -int16_t gsm_sub (int16_t a, int16_t b) -{ - int32_t diff = (int32_t) a - (int32_t) b ; - return saturate (diff) ; -} - -int16_t gsm_mult (int16_t a, int16_t b) -{ - if (a == MIN_WORD && b == MIN_WORD) - return MAX_WORD ; - - return SASR_L ((int32_t) a * (int32_t) b, 15) ; -} - -int16_t gsm_mult_r (int16_t a, int16_t b) -{ - if (b == MIN_WORD && a == MIN_WORD) - return MAX_WORD ; - else - { int32_t prod = (int32_t) a * (int32_t) b + 16384 ; - prod >>= 15 ; - return prod & 0xFFFF ; - } -} - -int16_t gsm_abs (int16_t a) -{ - return a < 0 ? (a == MIN_WORD ? MAX_WORD : -a) : a ; -} - -int32_t gsm_L_mult (int16_t a, int16_t b) -{ - assert (a != MIN_WORD || b != MIN_WORD) ; - return ((int32_t) a * (int32_t) b) << 1 ; -} - -int32_t gsm_L_add (int32_t a, int32_t b) -{ - if (a < 0) - { if (b >= 0) - return a + b ; - else - { uint32_t A = (uint32_t) - (a + 1) + (uint32_t) - (b + 1) ; - return A >= MAX_LONGWORD ? MIN_LONGWORD : - (int32_t) A - 2 ; - } - } - else if (b <= 0) - return a + b ; - else - { uint32_t A = (uint32_t) a + (uint32_t) b ; - return A > MAX_LONGWORD ? MAX_LONGWORD : A ; - } -} - -int32_t gsm_L_sub (int32_t a, int32_t b) -{ - if (a >= 0) - { if (b >= 0) - return a - b ; - else - { /* a>=0, b<0 */ - uint32_t A = (uint32_t) a + - (b + 1) ; - return A >= MAX_LONGWORD ? MAX_LONGWORD : (A + 1) ; - } - } - else if (b <= 0) - return a - b ; - else - { /* a<0, b>0 */ - uint32_t A = (uint32_t) - (a + 1) + b ; - return A >= MAX_LONGWORD ? MIN_LONGWORD : - (int32_t) A - 1 ; - } -} - -static unsigned char const bitoff [256] = { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -} ; - -int16_t gsm_norm (int32_t a) -/* - * the number of left shifts needed to normalize the 32 bit - * variable L_var1 for positive values on the interval - * - * with minimum of - * minimum of 1073741824 (01000000000000000000000000000000) and - * maximum of 2147483647 (01111111111111111111111111111111) - * - * - * and for negative values on the interval with - * minimum of -2147483648 (-10000000000000000000000000000000) and - * maximum of -1073741824 (-1000000000000000000000000000000). - * - * in order to normalize the result, the following - * operation must be done: L_norm_var1 = L_var1 << norm (L_var1) ; - * - * (That's 'ffs', only from the left, not the right..) - */ -{ - assert (a != 0) ; - - if (a < 0) - { if (a <= -1073741824) return 0 ; - a = ~a ; - } - - return a & 0xffff0000 - ? (a & 0xff000000 - ? -1 + bitoff [0xFF & (a >> 24)] - : 7 + bitoff [0xFF & (a >> 16)]) - : (a & 0xff00 - ? 15 + bitoff [0xFF & (a >> 8)] - : 23 + bitoff [0xFF & a]) ; -} - -int32_t gsm_L_asl (int32_t a, int n) -{ - if (n >= 32) return 0 ; - if (n <= -32) return - (a < 0) ; - if (n < 0) return gsm_L_asr (a, -n) ; - return a << n ; -} - -int16_t gsm_asr (int16_t a, int n) -{ - if (n >= 16) return - (a < 0) ; - if (n <= -16) return 0 ; - if (n < 0) return a << -n ; - - return SASR_W (a, (int16_t) n) ; -} - -int16_t gsm_asl (int16_t a, int n) -{ - if (n >= 16) return 0 ; - if (n <= -16) return - (a < 0) ; - if (n < 0) return gsm_asr (a, -n) ; - return a << n ; -} - -int32_t gsm_L_asr (int32_t a, int n) -{ - if (n >= 32) return - (a < 0) ; - if (n <= -32) return 0 ; - if (n < 0) return a << -n ; - - return SASR_L (a, (int16_t) n) ; -} - -/* -** int16_t gsm_asr (int16_t a, int n) -** { -** if (n >= 16) return - (a < 0) ; -** if (n <= -16) return 0 ; -** if (n < 0) return a << -n ; -** -** # ifdef SASR_W -** return a >> n ; -** # else -** if (a >= 0) return a >> n ; -** else return - (int16_t) (- (uint16_t)a >> n) ; -** # endif -** } -** -*/ -/* - * (From p. 46, end of section 4.2.5) - * - * NOTE: The following lines gives [sic] one correct implementation - * of the div (num, denum) arithmetic operation. Compute div - * which is the integer division of num by denum: with denum - * >= num > 0 - */ - -int16_t gsm_div (int16_t num, int16_t denum) -{ - int32_t L_num = num ; - int32_t L_denum = denum ; - int16_t div = 0 ; - int k = 15 ; - - /* The parameter num sometimes becomes zero. - * Although this is explicitly guarded against in 4.2.5, - * we assume that the result should then be zero as well. - */ - - /* assert (num != 0) ; */ - - assert (num >= 0 && denum >= num) ; - if (num == 0) - return 0 ; - - while (k--) - { div <<= 1 ; - L_num <<= 1 ; - - if (L_num >= L_denum) - { L_num -= L_denum ; - div++ ; - } - } - - return div ; -} - diff --git a/Engine/lib/libsndfile/src/GSM610/code.c b/Engine/lib/libsndfile/src/GSM610/code.c deleted file mode 100644 index 991913bda..000000000 --- a/Engine/lib/libsndfile/src/GSM610/code.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - - -#include -#include - -#include "gsm610_priv.h" - -/* - * 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER - */ - -void Gsm_Coder ( - - struct gsm_state * State, - - int16_t * s, /* [0..159] samples IN */ - -/* - * The RPE-LTD coder works on a frame by frame basis. The length of - * the frame is equal to 160 samples. Some computations are done - * once per frame to produce at the output of the coder the - * LARc [1..8] parameters which are the coded LAR coefficients and - * also to realize the inverse filtering operation for the entire - * frame (160 samples of signal d [0..159]). These parts produce at - * the output of the coder: - */ - - int16_t * LARc, /* [0..7] LAR coefficients OUT */ - -/* - * Procedure 4.2.11 to 4.2.18 are to be executed four times per - * frame. That means once for each sub-segment RPE-LTP analysis of - * 40 samples. These parts produce at the output of the coder: - */ - - int16_t *Nc, /* [0..3] LTP lag OUT */ - int16_t *bc, /* [0..3] coded LTP gain OUT */ - int16_t *Mc, /* [0..3] RPE grid selection OUT */ - int16_t *xmaxc, /* [0..3] Coded maximum amplitude OUT */ - int16_t *xMc /* [13*4] normalized RPE samples OUT */ -) -{ - int k ; - int16_t *dp = State->dp0 + 120 ; /* [-120...-1] */ - int16_t *dpp = dp ; /* [0...39] */ - - int16_t so [160] ; - - Gsm_Preprocess (State, s, so) ; - Gsm_LPC_Analysis (State, so, LARc) ; - Gsm_Short_Term_Analysis_Filter (State, LARc, so) ; - - for (k = 0 ; k <= 3 ; k++, xMc += 13) - { Gsm_Long_Term_Predictor (State, - so+k*40, /* d [0..39] IN */ - dp, /* dp [-120..-1] IN */ - State->e + 5, /* e [0..39] OUT */ - dpp, /* dpp [0..39] OUT */ - Nc++, - bc++) ; - - Gsm_RPE_Encoding (/*-S,-*/ - State->e + 5, /* e ][0..39][IN/OUT */ - xmaxc++, Mc++, xMc) ; - /* - * Gsm_Update_of_reconstructed_short_time_residual_signal - * (dpp, State->e + 5, dp) ; - */ - - { - register int i ; - for (i = 0 ; i <= 39 ; i++) - dp [i] = GSM_ADD (State->e [5 + i], dpp [i]) ; - } - dp += 40 ; - dpp += 40 ; - - } - memcpy ((char *) State->dp0, (char *) (State->dp0 + 160), - 120 * sizeof (*State->dp0)) ; -} - diff --git a/Engine/lib/libsndfile/src/GSM610/config.h b/Engine/lib/libsndfile/src/GSM610/config.h deleted file mode 100644 index f3eeb82e8..000000000 --- a/Engine/lib/libsndfile/src/GSM610/config.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#ifndef CONFIG_H -#define CONFIG_H - -#define HAS_STDLIB_H 1 /* /usr/include/stdlib.h */ -#define HAS_FCNTL_H 1 /* /usr/include/fcntl.h */ - -#define HAS_FSTAT 1 /* fstat syscall */ -#define HAS_FCHMOD 1 /* fchmod syscall */ -#define HAS_CHMOD 1 /* chmod syscall */ -#define HAS_FCHOWN 1 /* fchown syscall */ -#define HAS_CHOWN 1 /* chown syscall */ - -#define HAS_STRING_H 1 /* /usr/include/string.h */ - -#define HAS_UNISTD_H 1 /* /usr/include/unistd.h */ -#define HAS_UTIME 1 /* POSIX utime(path, times) */ -#define HAS_UTIME_H 1 /* UTIME header file */ - -#endif /* CONFIG_H */ - diff --git a/Engine/lib/libsndfile/src/GSM610/decode.c b/Engine/lib/libsndfile/src/GSM610/decode.c deleted file mode 100644 index 2a0712f09..000000000 --- a/Engine/lib/libsndfile/src/GSM610/decode.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include - -#include "gsm610_priv.h" - -/* - * 4.3 FIXED POINT IMPLEMENTATION OF THE RPE-LTP DECODER - */ - -static void Postprocessing ( - struct gsm_state * S, - register int16_t * s) -{ - register int k ; - register int16_t msr = S->msr ; - register int16_t tmp ; - - for (k = 160 ; k-- ; s++) - { tmp = GSM_MULT_R (msr, 28180) ; - msr = GSM_ADD (*s, tmp) ; /* Deemphasis */ - *s = GSM_ADD (msr, msr) & 0xFFF8 ; /* Truncation & Upscaling */ - } - S->msr = msr ; -} - -void Gsm_Decoder ( - struct gsm_state * S, - - int16_t * LARcr, /* [0..7] IN */ - - int16_t * Ncr, /* [0..3] IN */ - int16_t * bcr, /* [0..3] IN */ - int16_t * Mcr, /* [0..3] IN */ - int16_t * xmaxcr, /* [0..3] IN */ - int16_t * xMcr, /* [0..13*4] IN */ - - int16_t * s) /* [0..159] OUT */ -{ - int j, k ; - int16_t erp [40], wt [160] ; - int16_t *drp = S->dp0 + 120 ; - - for (j = 0 ; j <= 3 ; j++, xmaxcr++, bcr++, Ncr++, Mcr++, xMcr += 13) - { Gsm_RPE_Decoding (/*-S,-*/ *xmaxcr, *Mcr, xMcr, erp) ; - Gsm_Long_Term_Synthesis_Filtering (S, *Ncr, *bcr, erp, drp) ; - - for (k = 0 ; k <= 39 ; k++) wt [j * 40 + k] = drp [k] ; - } - - Gsm_Short_Term_Synthesis_Filter (S, LARcr, wt, s) ; - Postprocessing (S, s) ; -} - diff --git a/Engine/lib/libsndfile/src/GSM610/gsm.h b/Engine/lib/libsndfile/src/GSM610/gsm.h deleted file mode 100644 index 6506a6581..000000000 --- a/Engine/lib/libsndfile/src/GSM610/gsm.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#ifndef GSM_H -#define GSM_H - -#include /* for FILE * */ - -/* - * Interface - */ - -typedef struct gsm_state * gsm ; -typedef short gsm_signal ; /* signed 16 bit */ -typedef unsigned char gsm_byte ; -typedef gsm_byte gsm_frame [33] ; /* 33 * 8 bits */ - -#define GSM_MAGIC 0xD /* 13 kbit/s RPE-LTP */ - -#define GSM_PATCHLEVEL 10 -#define GSM_MINOR 0 -#define GSM_MAJOR 1 - -#define GSM_OPT_VERBOSE 1 -#define GSM_OPT_FAST 2 -#define GSM_OPT_LTP_CUT 3 -#define GSM_OPT_WAV49 4 -#define GSM_OPT_FRAME_INDEX 5 -#define GSM_OPT_FRAME_CHAIN 6 - -gsm gsm_create (void) ; - -/* Added for libsndfile : May 6, 2002 */ -void gsm_init (gsm) ; - -void gsm_destroy (gsm) ; - -int gsm_print (FILE *, gsm, gsm_byte *) ; -int gsm_option (gsm, int, int *) ; - -void gsm_encode (gsm, gsm_signal *, gsm_byte *) ; -int gsm_decode (gsm, gsm_byte *, gsm_signal *) ; - -int gsm_explode (gsm, gsm_byte *, gsm_signal *) ; -void gsm_implode (gsm, gsm_signal *, gsm_byte *) ; - -#endif /* GSM_H */ - - diff --git a/Engine/lib/libsndfile/src/GSM610/gsm610_priv.h b/Engine/lib/libsndfile/src/GSM610/gsm610_priv.h deleted file mode 100644 index 7ffaddc1d..000000000 --- a/Engine/lib/libsndfile/src/GSM610/gsm610_priv.h +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#ifndef PRIVATE_H -#define PRIVATE_H - -#include - -/* Added by Erik de Castro Lopo */ -#define USE_FLOAT_MUL -#define FAST -#define WAV49 - -#ifdef __cplusplus -#error "This code is not designed to be compiled with a C++ compiler." -#endif -/* Added by Erik de Castro Lopo */ - -struct gsm_state -{ int16_t dp0 [280] ; - - int16_t z1 ; /* preprocessing.c, Offset_com. */ - int32_t L_z2 ; /* Offset_com. */ - int mp ; /* Preemphasis */ - - int16_t u [8] ; /* short_term_aly_filter.c */ - int16_t LARpp [2][8] ; /* */ - int16_t j ; /* */ - - int16_t ltp_cut ; /* long_term.c, LTP crosscorr. */ - int16_t nrp ; /* 40 */ /* long_term.c, synthesis */ - int16_t v [9] ; /* short_term.c, synthesis */ - int16_t msr ; /* decoder.c, Postprocessing */ - - char verbose ; /* only used if !NDEBUG */ - char fast ; /* only used if FAST */ - - char wav_fmt ; /* only used if WAV49 defined */ - unsigned char frame_index ; /* odd/even chaining */ - unsigned char frame_chain ; /* half-byte to carry forward */ - - /* Moved here from code.c where it was defined as static */ - int16_t e [50] ; -} ; - -typedef struct gsm_state GSM_STATE ; - -#define MIN_WORD (-32767 - 1) -#define MAX_WORD 32767 - -#define MIN_LONGWORD (-2147483647 - 1) -#define MAX_LONGWORD 2147483647 - -/* Signed arithmetic shift right. */ -static inline int16_t -SASR_W (int16_t x, int16_t by) -{ if (x >= 0) - return x >> by ; - return ~ ((~x) >> by) ; -} /* SASR_W */ - -static inline int32_t -SASR_L (int32_t x, int16_t by) -{ if (x >= 0) - return x >> by ; - return ~ ((~x) >> by) ; -} /* SASR_L */ - -/* Signed arithmetic shift left. */ -static inline int16_t -SASL_W (int16_t x, int16_t by) -{ if (x >= 0) - return x << by ; - return - ((-x) << by) ; -} /* SASR_W */ - -static inline int32_t -SASL_L (int32_t x, int16_t by) -{ if (x >= 0) - return x << by ; - return - ((-x) << by) ; -} /* SASR_L */ - -/* - * Prototypes from add.c - */ -int16_t gsm_mult (int16_t a, int16_t b) ; -int32_t gsm_L_mult (int16_t a, int16_t b) ; -int16_t gsm_mult_r (int16_t a, int16_t b) ; - -int16_t gsm_div (int16_t num, int16_t denum) ; - -int16_t gsm_add (int16_t a, int16_t b) ; -int32_t gsm_L_add (int32_t a, int32_t b) ; - -int16_t gsm_sub (int16_t a, int16_t b) ; -int32_t gsm_L_sub (int32_t a, int32_t b) ; - -int16_t gsm_abs (int16_t a) ; - -int16_t gsm_norm (int32_t a) ; - -int32_t gsm_L_asl (int32_t a, int n) ; -int16_t gsm_asl (int16_t a, int n) ; - -int32_t gsm_L_asr (int32_t a, int n) ; -int16_t gsm_asr (int16_t a, int n) ; - -/* - * Inlined functions from add.h - */ - -static inline int32_t -GSM_MULT_R (int16_t a, int16_t b) -{ return (((int32_t) (a)) * ((int32_t) (b)) + 16384) >> 15 ; -} /* GSM_MULT_R */ - -static inline int32_t -GSM_MULT (int16_t a, int16_t b) -{ return (((int32_t) (a)) * ((int32_t) (b))) >> 15 ; -} /* GSM_MULT */ - -static inline int32_t -GSM_L_MULT (int16_t a, int16_t b) -{ return ((int32_t) (a)) * ((int32_t) (b)) << 1 ; -} /* GSM_L_MULT */ - -static inline int32_t -GSM_L_ADD (int32_t a, int32_t b) -{ uint32_t utmp ; - - if (a < 0 && b < 0) - { utmp = (uint32_t) - ((a) + 1) + (uint32_t) - ((b) + 1) ; - return (utmp >= (uint32_t) MAX_LONGWORD) ? MIN_LONGWORD : - (int32_t) utmp - 2 ; - } ; - - if (a > 0 && b > 0) - { utmp = (uint32_t) a + (uint32_t) b ; - return (utmp >= (uint32_t) MAX_LONGWORD) ? MAX_LONGWORD : utmp ; - } ; - - return a + b ; -} /* GSM_L_ADD */ - -static inline int32_t -GSM_ADD (int16_t a, int16_t b) -{ int32_t ltmp ; - - ltmp = ((int32_t) a) + ((int32_t) b) ; - - if (ltmp >= MAX_WORD) - return MAX_WORD ; - if (ltmp <= MIN_WORD) - return MIN_WORD ; - - return ltmp ; -} /* GSM_ADD */ - -static inline int32_t -GSM_SUB (int16_t a, int16_t b) -{ int32_t ltmp ; - - ltmp = ((int32_t) a) - ((int32_t) b) ; - - if (ltmp >= MAX_WORD) - ltmp = MAX_WORD ; - else if (ltmp <= MIN_WORD) - ltmp = MIN_WORD ; - - return ltmp ; -} /* GSM_SUB */ - -static inline int16_t -GSM_ABS (int16_t a) -{ - if (a > 0) - return a ; - if (a == MIN_WORD) - return MAX_WORD ; - return -a ; -} /* GSM_ADD */ - - -/* - * More prototypes from implementations.. - */ -void Gsm_Coder ( - struct gsm_state * S, - int16_t * s, /* [0..159] samples IN */ - int16_t * LARc, /* [0..7] LAR coefficients OUT */ - int16_t * Nc, /* [0..3] LTP lag OUT */ - int16_t * bc, /* [0..3] coded LTP gain OUT */ - int16_t * Mc, /* [0..3] RPE grid selection OUT */ - int16_t * xmaxc, /* [0..3] Coded maximum amplitude OUT */ - int16_t * xMc) ; /* [13*4] normalized RPE samples OUT */ - -void Gsm_Long_Term_Predictor ( /* 4x for 160 samples */ - struct gsm_state * S, - int16_t * d, /* [0..39] residual signal IN */ - int16_t * dp, /* [-120..-1] d' IN */ - int16_t * e, /* [0..40] OUT */ - int16_t * dpp, /* [0..40] OUT */ - int16_t * Nc, /* correlation lag OUT */ - int16_t * bc) ; /* gain factor OUT */ - -void Gsm_LPC_Analysis ( - struct gsm_state * S, - int16_t * s, /* 0..159 signals IN/OUT */ - int16_t * LARc) ; /* 0..7 LARc's OUT */ - -void Gsm_Preprocess ( - struct gsm_state * S, - int16_t * s, int16_t * so) ; - -void Gsm_Encoding ( - struct gsm_state * S, - int16_t * e, - int16_t * ep, - int16_t * xmaxc, - int16_t * Mc, - int16_t * xMc) ; - -void Gsm_Short_Term_Analysis_Filter ( - struct gsm_state * S, - int16_t * LARc, /* coded log area ratio [0..7] IN */ - int16_t * d) ; /* st res. signal [0..159] IN/OUT */ - -void Gsm_Decoder ( - struct gsm_state * S, - int16_t * LARcr, /* [0..7] IN */ - int16_t * Ncr, /* [0..3] IN */ - int16_t * bcr, /* [0..3] IN */ - int16_t * Mcr, /* [0..3] IN */ - int16_t * xmaxcr, /* [0..3] IN */ - int16_t * xMcr, /* [0..13*4] IN */ - int16_t * s) ; /* [0..159] OUT */ - -void Gsm_Decoding ( - struct gsm_state * S, - int16_t xmaxcr, - int16_t Mcr, - int16_t * xMcr, /* [0..12] IN */ - int16_t * erp) ; /* [0..39] OUT */ - -void Gsm_Long_Term_Synthesis_Filtering ( - struct gsm_state* S, - int16_t Ncr, - int16_t bcr, - int16_t * erp, /* [0..39] IN */ - int16_t * drp) ; /* [-120..-1] IN, [0..40] OUT */ - -void Gsm_RPE_Decoding ( - /*-struct gsm_state *S,-*/ - int16_t xmaxcr, - int16_t Mcr, - int16_t * xMcr, /* [0..12], 3 bits IN */ - int16_t * erp) ; /* [0..39] OUT */ - -void Gsm_RPE_Encoding ( - /*-struct gsm_state * S,-*/ - int16_t * e, /* -5..-1][0..39][40..44 IN/OUT */ - int16_t * xmaxc, /* OUT */ - int16_t * Mc, /* OUT */ - int16_t * xMc) ; /* [0..12] OUT */ - -void Gsm_Short_Term_Synthesis_Filter ( - struct gsm_state * S, - int16_t * LARcr, /* log area ratios [0..7] IN */ - int16_t * drp, /* received d [0...39] IN */ - int16_t * s) ; /* signal s [0..159] OUT */ - -void Gsm_Update_of_reconstructed_short_time_residual_signal ( - int16_t * dpp, /* [0...39] IN */ - int16_t * ep, /* [0...39] IN */ - int16_t * dp) ; /* [-120...-1] IN/OUT */ - -/* - * Tables from table.c - */ -#ifndef GSM_TABLE_C - -extern int16_t gsm_A [8], gsm_B [8], gsm_MIC [8], gsm_MAC [8] ; -extern int16_t gsm_INVA [8] ; -extern int16_t gsm_DLB [4], gsm_QLB [4] ; -extern int16_t gsm_H [11] ; -extern int16_t gsm_NRFAC [8] ; -extern int16_t gsm_FAC [8] ; - -#endif /* GSM_TABLE_C */ - - -#if __GNUC__ -#define ALWAYS_INLINE __attribute__ ((always_inline)) -#elif defined _MSC_VER -#define ALWAYS_INLINE __forceinline -#else -#define ALWAYS_INLINE -#endif - - -static inline int32_t ALWAYS_INLINE -arith_shift_left (int32_t x, int shift) -{ return (int32_t) (((uint32_t) x) << shift) ; -} /* arith_shift_left */ - -static inline int32_t ALWAYS_INLINE -arith_shift_right (int32_t x, int shift) -{ if (x >= 0) - return x << shift ; - return ~ ((~x) << shift) ; -} /* arith_shift_right */ - - -/* - * Debugging - */ -#ifdef NDEBUG - -# define gsm_debug_int16_ts(a, b, c, d) /* nil */ -# define gsm_debug_int32_ts(a, b, c, d) /* nil */ -# define gsm_debug_int16_t(a, b) /* nil */ -# define gsm_debug_int32_t(a, b) /* nil */ - -#else /* !NDEBUG => DEBUG */ - - void gsm_debug_int16_ts (char * name, int, int, int16_t *) ; - void gsm_debug_int32_ts (char * name, int, int, int32_t *) ; - void gsm_debug_int32_t (char * name, int32_t) ; - void gsm_debug_int16_t (char * name, int16_t) ; - -#endif /* !NDEBUG */ - -#endif /* PRIVATE_H */ - diff --git a/Engine/lib/libsndfile/src/GSM610/gsm_create.c b/Engine/lib/libsndfile/src/GSM610/gsm_create.c deleted file mode 100644 index 05425dd7a..000000000 --- a/Engine/lib/libsndfile/src/GSM610/gsm_create.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include "config.h" - -#include -#include -#include - - - -#include "gsm.h" -#include "gsm610_priv.h" - -gsm gsm_create (void) -{ - gsm r ; - - r = malloc (sizeof (struct gsm_state)) ; - if (!r) return r ; - - memset ((char *) r, 0, sizeof (struct gsm_state)) ; - r->nrp = 40 ; - - return r ; -} - -/* Added for libsndfile : May 6, 2002. Not sure if it works. */ -void gsm_init (gsm state) -{ - memset (state, 0, sizeof (struct gsm_state)) ; - state->nrp = 40 ; -} - diff --git a/Engine/lib/libsndfile/src/GSM610/gsm_decode.c b/Engine/lib/libsndfile/src/GSM610/gsm_decode.c deleted file mode 100644 index 04411be3f..000000000 --- a/Engine/lib/libsndfile/src/GSM610/gsm_decode.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include "gsm610_priv.h" - -#include "gsm.h" - -int gsm_decode (gsm s, gsm_byte * c, gsm_signal * target) -{ - int16_t LARc [8], Nc [4], Mc [4], bc [4], xmaxc [4], xmc [13 * 4] ; - -#ifdef WAV49 - if (s->wav_fmt) - { uint16_t sr = 0 ; - - s->frame_index = !s->frame_index ; - if (s->frame_index) - { sr = *c++ ; - LARc [0] = sr & 0x3f ; sr >>= 6 ; - sr |= (uint16_t) *c++ << 2 ; - LARc [1] = sr & 0x3f ; sr >>= 6 ; - sr |= (uint16_t) *c++ << 4 ; - LARc [2] = sr & 0x1f ; sr >>= 5 ; - LARc [3] = sr & 0x1f ; sr >>= 5 ; - sr |= (uint16_t) *c++ << 2 ; - LARc [4] = sr & 0xf ; sr >>= 4 ; - LARc [5] = sr & 0xf ; sr >>= 4 ; - sr |= (uint16_t) *c++ << 2 ; /* 5 */ - LARc [6] = sr & 0x7 ; sr >>= 3 ; - LARc [7] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 4 ; - Nc [0] = sr & 0x7f ; sr >>= 7 ; - bc [0] = sr & 0x3 ; sr >>= 2 ; - Mc [0] = sr & 0x3 ; sr >>= 2 ; - sr |= (uint16_t) *c++ << 1 ; - xmaxc [0] = sr & 0x3f ; sr >>= 6 ; - xmc [0] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - xmc [1] = sr & 0x7 ; sr >>= 3 ; - xmc [2] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [3] = sr & 0x7 ; sr >>= 3 ; - xmc [4] = sr & 0x7 ; sr >>= 3 ; - xmc [5] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; /* 10 */ - xmc [6] = sr & 0x7 ; sr >>= 3 ; - xmc [7] = sr & 0x7 ; sr >>= 3 ; - xmc [8] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - xmc [9] = sr & 0x7 ; sr >>= 3 ; - xmc [10] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [11] = sr & 0x7 ; sr >>= 3 ; - xmc [12] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 4 ; - Nc [1] = sr & 0x7f ; sr >>= 7 ; - bc [1] = sr & 0x3 ; sr >>= 2 ; - Mc [1] = sr & 0x3 ; sr >>= 2 ; - sr |= (uint16_t) *c++ << 1 ; - xmaxc [1] = sr & 0x3f ; sr >>= 6 ; - xmc [13] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; /* 15 */ - xmc [14] = sr & 0x7 ; sr >>= 3 ; - xmc [15] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [16] = sr & 0x7 ; sr >>= 3 ; - xmc [17] = sr & 0x7 ; sr >>= 3 ; - xmc [18] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; - xmc [19] = sr & 0x7 ; sr >>= 3 ; - xmc [20] = sr & 0x7 ; sr >>= 3 ; - xmc [21] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - xmc [22] = sr & 0x7 ; sr >>= 3 ; - xmc [23] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [24] = sr & 0x7 ; sr >>= 3 ; - xmc [25] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 4 ; /* 20 */ - Nc [2] = sr & 0x7f ; sr >>= 7 ; - bc [2] = sr & 0x3 ; sr >>= 2 ; - Mc [2] = sr & 0x3 ; sr >>= 2 ; - sr |= (uint16_t) *c++ << 1 ; - xmaxc [2] = sr & 0x3f ; sr >>= 6 ; - xmc [26] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - xmc [27] = sr & 0x7 ; sr >>= 3 ; - xmc [28] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [29] = sr & 0x7 ; sr >>= 3 ; - xmc [30] = sr & 0x7 ; sr >>= 3 ; - xmc [31] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; - xmc [32] = sr & 0x7 ; sr >>= 3 ; - xmc [33] = sr & 0x7 ; sr >>= 3 ; - xmc [34] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; /* 25 */ - xmc [35] = sr & 0x7 ; sr >>= 3 ; - xmc [36] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [37] = sr & 0x7 ; sr >>= 3 ; - xmc [38] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 4 ; - Nc [3] = sr & 0x7f ; sr >>= 7 ; - bc [3] = sr & 0x3 ; sr >>= 2 ; - Mc [3] = sr & 0x3 ; sr >>= 2 ; - sr |= (uint16_t) *c++ << 1 ; - xmaxc [3] = sr & 0x3f ; sr >>= 6 ; - xmc [39] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - xmc [40] = sr & 0x7 ; sr >>= 3 ; - xmc [41] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; /* 30 */ - xmc [42] = sr & 0x7 ; sr >>= 3 ; - xmc [43] = sr & 0x7 ; sr >>= 3 ; - xmc [44] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; - xmc [45] = sr & 0x7 ; sr >>= 3 ; - xmc [46] = sr & 0x7 ; sr >>= 3 ; - xmc [47] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - xmc [48] = sr & 0x7 ; sr >>= 3 ; - xmc [49] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [50] = sr & 0x7 ; sr >>= 3 ; - xmc [51] = sr & 0x7 ; sr >>= 3 ; - - s->frame_chain = sr & 0xf ; - } - else { - sr = s->frame_chain ; - sr |= (uint16_t) *c++ << 4 ; /* 1 */ - LARc [0] = sr & 0x3f ; sr >>= 6 ; - LARc [1] = sr & 0x3f ; sr >>= 6 ; - sr = *c++ ; - LARc [2] = sr & 0x1f ; sr >>= 5 ; - sr |= (uint16_t) *c++ << 3 ; - LARc [3] = sr & 0x1f ; sr >>= 5 ; - LARc [4] = sr & 0xf ; sr >>= 4 ; - sr |= (uint16_t) *c++ << 2 ; - LARc [5] = sr & 0xf ; sr >>= 4 ; - LARc [6] = sr & 0x7 ; sr >>= 3 ; - LARc [7] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; /* 5 */ - Nc [0] = sr & 0x7f ; sr >>= 7 ; - sr |= (uint16_t) *c++ << 1 ; - bc [0] = sr & 0x3 ; sr >>= 2 ; - Mc [0] = sr & 0x3 ; sr >>= 2 ; - sr |= (uint16_t) *c++ << 5 ; - xmaxc [0] = sr & 0x3f ; sr >>= 6 ; - xmc [0] = sr & 0x7 ; sr >>= 3 ; - xmc [1] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; - xmc [2] = sr & 0x7 ; sr >>= 3 ; - xmc [3] = sr & 0x7 ; sr >>= 3 ; - xmc [4] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - xmc [5] = sr & 0x7 ; sr >>= 3 ; - xmc [6] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; /* 10 */ - xmc [7] = sr & 0x7 ; sr >>= 3 ; - xmc [8] = sr & 0x7 ; sr >>= 3 ; - xmc [9] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; - xmc [10] = sr & 0x7 ; sr >>= 3 ; - xmc [11] = sr & 0x7 ; sr >>= 3 ; - xmc [12] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - Nc [1] = sr & 0x7f ; sr >>= 7 ; - sr |= (uint16_t) *c++ << 1 ; - bc [1] = sr & 0x3 ; sr >>= 2 ; - Mc [1] = sr & 0x3 ; sr >>= 2 ; - sr |= (uint16_t) *c++ << 5 ; - xmaxc [1] = sr & 0x3f ; sr >>= 6 ; - xmc [13] = sr & 0x7 ; sr >>= 3 ; - xmc [14] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; /* 15 */ - xmc [15] = sr & 0x7 ; sr >>= 3 ; - xmc [16] = sr & 0x7 ; sr >>= 3 ; - xmc [17] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - xmc [18] = sr & 0x7 ; sr >>= 3 ; - xmc [19] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [20] = sr & 0x7 ; sr >>= 3 ; - xmc [21] = sr & 0x7 ; sr >>= 3 ; - xmc [22] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; - xmc [23] = sr & 0x7 ; sr >>= 3 ; - xmc [24] = sr & 0x7 ; sr >>= 3 ; - xmc [25] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - Nc [2] = sr & 0x7f ; sr >>= 7 ; - sr |= (uint16_t) *c++ << 1 ; /* 20 */ - bc [2] = sr & 0x3 ; sr >>= 2 ; - Mc [2] = sr & 0x3 ; sr >>= 2 ; - sr |= (uint16_t) *c++ << 5 ; - xmaxc [2] = sr & 0x3f ; sr >>= 6 ; - xmc [26] = sr & 0x7 ; sr >>= 3 ; - xmc [27] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; - xmc [28] = sr & 0x7 ; sr >>= 3 ; - xmc [29] = sr & 0x7 ; sr >>= 3 ; - xmc [30] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - xmc [31] = sr & 0x7 ; sr >>= 3 ; - xmc [32] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [33] = sr & 0x7 ; sr >>= 3 ; - xmc [34] = sr & 0x7 ; sr >>= 3 ; - xmc [35] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; /* 25 */ - xmc [36] = sr & 0x7 ; sr >>= 3 ; - xmc [37] = sr & 0x7 ; sr >>= 3 ; - xmc [38] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; - Nc [3] = sr & 0x7f ; sr >>= 7 ; - sr |= (uint16_t) *c++ << 1 ; - bc [3] = sr & 0x3 ; sr >>= 2 ; - Mc [3] = sr & 0x3 ; sr >>= 2 ; - sr |= (uint16_t) *c++ << 5 ; - xmaxc [3] = sr & 0x3f ; sr >>= 6 ; - xmc [39] = sr & 0x7 ; sr >>= 3 ; - xmc [40] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; - xmc [41] = sr & 0x7 ; sr >>= 3 ; - xmc [42] = sr & 0x7 ; sr >>= 3 ; - xmc [43] = sr & 0x7 ; sr >>= 3 ; - sr = *c++ ; /* 30 */ - xmc [44] = sr & 0x7 ; sr >>= 3 ; - xmc [45] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 2 ; - xmc [46] = sr & 0x7 ; sr >>= 3 ; - xmc [47] = sr & 0x7 ; sr >>= 3 ; - xmc [48] = sr & 0x7 ; sr >>= 3 ; - sr |= (uint16_t) *c++ << 1 ; - xmc [49] = sr & 0x7 ; sr >>= 3 ; - xmc [50] = sr & 0x7 ; sr >>= 3 ; - xmc [51] = sr & 0x7 ; sr >>= 3 ; - } - } - else -#endif - { - /* GSM_MAGIC = (*c >> 4) & 0xF ; */ - - if (((*c >> 4) & 0x0F) != GSM_MAGIC) return -1 ; - - LARc [0] = (*c++ & 0xF) << 2 ; /* 1 */ - LARc [0] |= (*c >> 6) & 0x3 ; - LARc [1] = *c++ & 0x3F ; - LARc [2] = (*c >> 3) & 0x1F ; - LARc [3] = (*c++ & 0x7) << 2 ; - LARc [3] |= (*c >> 6) & 0x3 ; - LARc [4] = (*c >> 2) & 0xF ; - LARc [5] = (*c++ & 0x3) << 2 ; - LARc [5] |= (*c >> 6) & 0x3 ; - LARc [6] = (*c >> 3) & 0x7 ; - LARc [7] = *c++ & 0x7 ; - Nc [0] = (*c >> 1) & 0x7F ; - bc [0] = (*c++ & 0x1) << 1 ; - bc [0] |= (*c >> 7) & 0x1 ; - Mc [0] = (*c >> 5) & 0x3 ; - xmaxc [0] = (*c++ & 0x1F) << 1 ; - xmaxc [0] |= (*c >> 7) & 0x1 ; - xmc [0] = (*c >> 4) & 0x7 ; - xmc [1] = (*c >> 1) & 0x7 ; - xmc [2] = (*c++ & 0x1) << 2 ; - xmc [2] |= (*c >> 6) & 0x3 ; - xmc [3] = (*c >> 3) & 0x7 ; - xmc [4] = *c++ & 0x7 ; - xmc [5] = (*c >> 5) & 0x7 ; - xmc [6] = (*c >> 2) & 0x7 ; - xmc [7] = (*c++ & 0x3) << 1 ; /* 10 */ - xmc [7] |= (*c >> 7) & 0x1 ; - xmc [8] = (*c >> 4) & 0x7 ; - xmc [9] = (*c >> 1) & 0x7 ; - xmc [10] = (*c++ & 0x1) << 2 ; - xmc [10] |= (*c >> 6) & 0x3 ; - xmc [11] = (*c >> 3) & 0x7 ; - xmc [12] = *c++ & 0x7 ; - Nc [1] = (*c >> 1) & 0x7F ; - bc [1] = (*c++ & 0x1) << 1 ; - bc [1] |= (*c >> 7) & 0x1 ; - Mc [1] = (*c >> 5) & 0x3 ; - xmaxc [1] = (*c++ & 0x1F) << 1 ; - xmaxc [1] |= (*c >> 7) & 0x1 ; - xmc [13] = (*c >> 4) & 0x7 ; - xmc [14] = (*c >> 1) & 0x7 ; - xmc [15] = (*c++ & 0x1) << 2 ; - xmc [15] |= (*c >> 6) & 0x3 ; - xmc [16] = (*c >> 3) & 0x7 ; - xmc [17] = *c++ & 0x7 ; - xmc [18] = (*c >> 5) & 0x7 ; - xmc [19] = (*c >> 2) & 0x7 ; - xmc [20] = (*c++ & 0x3) << 1 ; - xmc [20] |= (*c >> 7) & 0x1 ; - xmc [21] = (*c >> 4) & 0x7 ; - xmc [22] = (*c >> 1) & 0x7 ; - xmc [23] = (*c++ & 0x1) << 2 ; - xmc [23] |= (*c >> 6) & 0x3 ; - xmc [24] = (*c >> 3) & 0x7 ; - xmc [25] = *c++ & 0x7 ; - Nc [2] = (*c >> 1) & 0x7F ; - bc [2] = (*c++ & 0x1) << 1 ; /* 20 */ - bc [2] |= (*c >> 7) & 0x1 ; - Mc [2] = (*c >> 5) & 0x3 ; - xmaxc [2] = (*c++ & 0x1F) << 1 ; - xmaxc [2] |= (*c >> 7) & 0x1 ; - xmc [26] = (*c >> 4) & 0x7 ; - xmc [27] = (*c >> 1) & 0x7 ; - xmc [28] = (*c++ & 0x1) << 2 ; - xmc [28] |= (*c >> 6) & 0x3 ; - xmc [29] = (*c >> 3) & 0x7 ; - xmc [30] = *c++ & 0x7 ; - xmc [31] = (*c >> 5) & 0x7 ; - xmc [32] = (*c >> 2) & 0x7 ; - xmc [33] = (*c++ & 0x3) << 1 ; - xmc [33] |= (*c >> 7) & 0x1 ; - xmc [34] = (*c >> 4) & 0x7 ; - xmc [35] = (*c >> 1) & 0x7 ; - xmc [36] = (*c++ & 0x1) << 2 ; - xmc [36] |= (*c >> 6) & 0x3 ; - xmc [37] = (*c >> 3) & 0x7 ; - xmc [38] = *c++ & 0x7 ; - Nc [3] = (*c >> 1) & 0x7F ; - bc [3] = (*c++ & 0x1) << 1 ; - bc [3] |= (*c >> 7) & 0x1 ; - Mc [3] = (*c >> 5) & 0x3 ; - xmaxc [3] = (*c++ & 0x1F) << 1 ; - xmaxc [3] |= (*c >> 7) & 0x1 ; - xmc [39] = (*c >> 4) & 0x7 ; - xmc [40] = (*c >> 1) & 0x7 ; - xmc [41] = (*c++ & 0x1) << 2 ; - xmc [41] |= (*c >> 6) & 0x3 ; - xmc [42] = (*c >> 3) & 0x7 ; - xmc [43] = *c++ & 0x7 ; /* 30 */ - xmc [44] = (*c >> 5) & 0x7 ; - xmc [45] = (*c >> 2) & 0x7 ; - xmc [46] = (*c++ & 0x3) << 1 ; - xmc [46] |= (*c >> 7) & 0x1 ; - xmc [47] = (*c >> 4) & 0x7 ; - xmc [48] = (*c >> 1) & 0x7 ; - xmc [49] = (*c++ & 0x1) << 2 ; - xmc [49] |= (*c >> 6) & 0x3 ; - xmc [50] = (*c >> 3) & 0x7 ; - xmc [51] = *c & 0x7 ; /* 33 */ - } - - Gsm_Decoder (s, LARc, Nc, bc, Mc, xmaxc, xmc, target) ; - - return 0 ; -} - diff --git a/Engine/lib/libsndfile/src/GSM610/gsm_destroy.c b/Engine/lib/libsndfile/src/GSM610/gsm_destroy.c deleted file mode 100644 index 03bf7c350..000000000 --- a/Engine/lib/libsndfile/src/GSM610/gsm_destroy.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include "gsm.h" -#include "config.h" - -#ifdef HAS_STDLIB_H -# include -#else -# ifdef HAS_MALLOC_H -# include -# else - extern void free () ; -# endif -#endif - -void gsm_destroy (gsm S) -{ - if (S) - free ((char *) S) ; -} - diff --git a/Engine/lib/libsndfile/src/GSM610/gsm_encode.c b/Engine/lib/libsndfile/src/GSM610/gsm_encode.c deleted file mode 100644 index 5fd535150..000000000 --- a/Engine/lib/libsndfile/src/GSM610/gsm_encode.c +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include "gsm610_priv.h" -#include "gsm.h" - -void gsm_encode (gsm s, gsm_signal * source, gsm_byte * c) -{ - int16_t LARc [8], Nc [4], Mc [4], bc [4], xmaxc [4], xmc [13 * 4] ; - - Gsm_Coder (s, source, LARc, Nc, bc, Mc, xmaxc, xmc) ; - - - /* variable size - - GSM_MAGIC 4 - - LARc [0] 6 - LARc [1] 6 - LARc [2] 5 - LARc [3] 5 - LARc [4] 4 - LARc [5] 4 - LARc [6] 3 - LARc [7] 3 - - Nc [0] 7 - bc [0] 2 - Mc [0] 2 - xmaxc [0] 6 - xmc [0] 3 - xmc [1] 3 - xmc [2] 3 - xmc [3] 3 - xmc [4] 3 - xmc [5] 3 - xmc [6] 3 - xmc [7] 3 - xmc [8] 3 - xmc [9] 3 - xmc [10] 3 - xmc [11] 3 - xmc [12] 3 - - Nc [1] 7 - bc [1] 2 - Mc [1] 2 - xmaxc [1] 6 - xmc [13] 3 - xmc [14] 3 - xmc [15] 3 - xmc [16] 3 - xmc [17] 3 - xmc [18] 3 - xmc [19] 3 - xmc [20] 3 - xmc [21] 3 - xmc [22] 3 - xmc [23] 3 - xmc [24] 3 - xmc [25] 3 - - Nc [2] 7 - bc [2] 2 - Mc [2] 2 - xmaxc [2] 6 - xmc [26] 3 - xmc [27] 3 - xmc [28] 3 - xmc [29] 3 - xmc [30] 3 - xmc [31] 3 - xmc [32] 3 - xmc [33] 3 - xmc [34] 3 - xmc [35] 3 - xmc [36] 3 - xmc [37] 3 - xmc [38] 3 - - Nc [3] 7 - bc [3] 2 - Mc [3] 2 - xmaxc [3] 6 - xmc [39] 3 - xmc [40] 3 - xmc [41] 3 - xmc [42] 3 - xmc [43] 3 - xmc [44] 3 - xmc [45] 3 - xmc [46] 3 - xmc [47] 3 - xmc [48] 3 - xmc [49] 3 - xmc [50] 3 - xmc [51] 3 - */ - -#ifdef WAV49 - - if (s->wav_fmt) - { s->frame_index = !s->frame_index ; - if (s->frame_index) - { uint16_t sr ; - - sr = 0 ; - sr = sr >> 6 | LARc [0] << 10 ; - sr = sr >> 6 | LARc [1] << 10 ; - *c++ = sr >> 4 ; - sr = sr >> 5 | LARc [2] << 11 ; - *c++ = sr >> 7 ; - sr = sr >> 5 | LARc [3] << 11 ; - sr = sr >> 4 | LARc [4] << 12 ; - *c++ = sr >> 6 ; - sr = sr >> 4 | LARc [5] << 12 ; - sr = sr >> 3 | LARc [6] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | LARc [7] << 13 ; - sr = sr >> 7 | Nc [0] << 9 ; - *c++ = sr >> 5 ; - sr = sr >> 2 | bc [0] << 14 ; - sr = sr >> 2 | Mc [0] << 14 ; - sr = sr >> 6 | xmaxc [0] << 10 ; - *c++ = sr >> 3 ; - sr = sr >> 3 | xmc [0] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [1] << 13 ; - sr = sr >> 3 | xmc [2] << 13 ; - sr = sr >> 3 | xmc [3] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [4] << 13 ; - sr = sr >> 3 | xmc [5] << 13 ; - sr = sr >> 3 | xmc [6] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [7] << 13 ; - sr = sr >> 3 | xmc [8] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [9] << 13 ; - sr = sr >> 3 | xmc [10] << 13 ; - sr = sr >> 3 | xmc [11] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [12] << 13 ; - sr = sr >> 7 | Nc [1] << 9 ; - *c++ = sr >> 5 ; - sr = sr >> 2 | bc [1] << 14 ; - sr = sr >> 2 | Mc [1] << 14 ; - sr = sr >> 6 | xmaxc [1] << 10 ; - *c++ = sr >> 3 ; - sr = sr >> 3 | xmc [13] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [14] << 13 ; - sr = sr >> 3 | xmc [15] << 13 ; - sr = sr >> 3 | xmc [16] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [17] << 13 ; - sr = sr >> 3 | xmc [18] << 13 ; - sr = sr >> 3 | xmc [19] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [20] << 13 ; - sr = sr >> 3 | xmc [21] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [22] << 13 ; - sr = sr >> 3 | xmc [23] << 13 ; - sr = sr >> 3 | xmc [24] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [25] << 13 ; - sr = sr >> 7 | Nc [2] << 9 ; - *c++ = sr >> 5 ; - sr = sr >> 2 | bc [2] << 14 ; - sr = sr >> 2 | Mc [2] << 14 ; - sr = sr >> 6 | xmaxc [2] << 10 ; - *c++ = sr >> 3 ; - sr = sr >> 3 | xmc [26] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [27] << 13 ; - sr = sr >> 3 | xmc [28] << 13 ; - sr = sr >> 3 | xmc [29] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [30] << 13 ; - sr = sr >> 3 | xmc [31] << 13 ; - sr = sr >> 3 | xmc [32] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [33] << 13 ; - sr = sr >> 3 | xmc [34] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [35] << 13 ; - sr = sr >> 3 | xmc [36] << 13 ; - sr = sr >> 3 | xmc [37] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [38] << 13 ; - sr = sr >> 7 | Nc [3] << 9 ; - *c++ = sr >> 5 ; - sr = sr >> 2 | bc [3] << 14 ; - sr = sr >> 2 | Mc [3] << 14 ; - sr = sr >> 6 | xmaxc [3] << 10 ; - *c++ = sr >> 3 ; - sr = sr >> 3 | xmc [39] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [40] << 13 ; - sr = sr >> 3 | xmc [41] << 13 ; - sr = sr >> 3 | xmc [42] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [43] << 13 ; - sr = sr >> 3 | xmc [44] << 13 ; - sr = sr >> 3 | xmc [45] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [46] << 13 ; - sr = sr >> 3 | xmc [47] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [48] << 13 ; - sr = sr >> 3 | xmc [49] << 13 ; - sr = sr >> 3 | xmc [50] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [51] << 13 ; - sr = sr >> 4 ; - *c = sr >> 8 ; - s->frame_chain = *c ; - } - else { - uint16_t sr ; - - sr = 0 ; - sr = sr >> 4 | s->frame_chain << 12 ; - sr = sr >> 6 | LARc [0] << 10 ; - *c++ = sr >> 6 ; - sr = sr >> 6 | LARc [1] << 10 ; - *c++ = sr >> 8 ; - sr = sr >> 5 | LARc [2] << 11 ; - sr = sr >> 5 | LARc [3] << 11 ; - *c++ = sr >> 6 ; - sr = sr >> 4 | LARc [4] << 12 ; - sr = sr >> 4 | LARc [5] << 12 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | LARc [6] << 13 ; - sr = sr >> 3 | LARc [7] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 7 | Nc [0] << 9 ; - sr = sr >> 2 | bc [0] << 14 ; - *c++ = sr >> 7 ; - sr = sr >> 2 | Mc [0] << 14 ; - sr = sr >> 6 | xmaxc [0] << 10 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [0] << 13 ; - sr = sr >> 3 | xmc [1] << 13 ; - sr = sr >> 3 | xmc [2] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [3] << 13 ; - sr = sr >> 3 | xmc [4] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [5] << 13 ; - sr = sr >> 3 | xmc [6] << 13 ; - sr = sr >> 3 | xmc [7] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [8] << 13 ; - sr = sr >> 3 | xmc [9] << 13 ; - sr = sr >> 3 | xmc [10] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [11] << 13 ; - sr = sr >> 3 | xmc [12] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 7 | Nc [1] << 9 ; - sr = sr >> 2 | bc [1] << 14 ; - *c++ = sr >> 7 ; - sr = sr >> 2 | Mc [1] << 14 ; - sr = sr >> 6 | xmaxc [1] << 10 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [13] << 13 ; - sr = sr >> 3 | xmc [14] << 13 ; - sr = sr >> 3 | xmc [15] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [16] << 13 ; - sr = sr >> 3 | xmc [17] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [18] << 13 ; - sr = sr >> 3 | xmc [19] << 13 ; - sr = sr >> 3 | xmc [20] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [21] << 13 ; - sr = sr >> 3 | xmc [22] << 13 ; - sr = sr >> 3 | xmc [23] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [24] << 13 ; - sr = sr >> 3 | xmc [25] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 7 | Nc [2] << 9 ; - sr = sr >> 2 | bc [2] << 14 ; - *c++ = sr >> 7 ; - sr = sr >> 2 | Mc [2] << 14 ; - sr = sr >> 6 | xmaxc [2] << 10 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [26] << 13 ; - sr = sr >> 3 | xmc [27] << 13 ; - sr = sr >> 3 | xmc [28] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [29] << 13 ; - sr = sr >> 3 | xmc [30] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [31] << 13 ; - sr = sr >> 3 | xmc [32] << 13 ; - sr = sr >> 3 | xmc [33] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [34] << 13 ; - sr = sr >> 3 | xmc [35] << 13 ; - sr = sr >> 3 | xmc [36] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [37] << 13 ; - sr = sr >> 3 | xmc [38] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 7 | Nc [3] << 9 ; - sr = sr >> 2 | bc [3] << 14 ; - *c++ = sr >> 7 ; - sr = sr >> 2 | Mc [3] << 14 ; - sr = sr >> 6 | xmaxc [3] << 10 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [39] << 13 ; - sr = sr >> 3 | xmc [40] << 13 ; - sr = sr >> 3 | xmc [41] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [42] << 13 ; - sr = sr >> 3 | xmc [43] << 13 ; - *c++ = sr >> 8 ; - sr = sr >> 3 | xmc [44] << 13 ; - sr = sr >> 3 | xmc [45] << 13 ; - sr = sr >> 3 | xmc [46] << 13 ; - *c++ = sr >> 7 ; - sr = sr >> 3 | xmc [47] << 13 ; - sr = sr >> 3 | xmc [48] << 13 ; - sr = sr >> 3 | xmc [49] << 13 ; - *c++ = sr >> 6 ; - sr = sr >> 3 | xmc [50] << 13 ; - sr = sr >> 3 | xmc [51] << 13 ; - *c++ = sr >> 8 ; - } - } - - else - -#endif /* WAV49 */ - { - - *c++ = ((GSM_MAGIC & 0xF) << 4) /* 1 */ - | ((LARc [0] >> 2) & 0xF) ; - *c++ = ((LARc [0] & 0x3) << 6) - | (LARc [1] & 0x3F) ; - *c++ = ((LARc [2] & 0x1F) << 3) - | ((LARc [3] >> 2) & 0x7) ; - *c++ = ((LARc [3] & 0x3) << 6) - | ((LARc [4] & 0xF) << 2) - | ((LARc [5] >> 2) & 0x3) ; - *c++ = ((LARc [5] & 0x3) << 6) - | ((LARc [6] & 0x7) << 3) - | (LARc [7] & 0x7) ; - *c++ = ((Nc [0] & 0x7F) << 1) - | ((bc [0] >> 1) & 0x1) ; - *c++ = ((bc [0] & 0x1) << 7) - | ((Mc [0] & 0x3) << 5) - | ((xmaxc [0] >> 1) & 0x1F) ; - *c++ = ((xmaxc [0] & 0x1) << 7) - | ((xmc [0] & 0x7) << 4) - | ((xmc [1] & 0x7) << 1) - | ((xmc [2] >> 2) & 0x1) ; - *c++ = ((xmc [2] & 0x3) << 6) - | ((xmc [3] & 0x7) << 3) - | (xmc [4] & 0x7) ; - *c++ = ((xmc [5] & 0x7) << 5) /* 10 */ - | ((xmc [6] & 0x7) << 2) - | ((xmc [7] >> 1) & 0x3) ; - *c++ = ((xmc [7] & 0x1) << 7) - | ((xmc [8] & 0x7) << 4) - | ((xmc [9] & 0x7) << 1) - | ((xmc [10] >> 2) & 0x1) ; - *c++ = ((xmc [10] & 0x3) << 6) - | ((xmc [11] & 0x7) << 3) - | (xmc [12] & 0x7) ; - *c++ = ((Nc [1] & 0x7F) << 1) - | ((bc [1] >> 1) & 0x1) ; - *c++ = ((bc [1] & 0x1) << 7) - | ((Mc [1] & 0x3) << 5) - | ((xmaxc [1] >> 1) & 0x1F) ; - *c++ = ((xmaxc [1] & 0x1) << 7) - | ((xmc [13] & 0x7) << 4) - | ((xmc [14] & 0x7) << 1) - | ((xmc [15] >> 2) & 0x1) ; - *c++ = ((xmc [15] & 0x3) << 6) - | ((xmc [16] & 0x7) << 3) - | (xmc [17] & 0x7) ; - *c++ = ((xmc [18] & 0x7) << 5) - | ((xmc [19] & 0x7) << 2) - | ((xmc [20] >> 1) & 0x3) ; - *c++ = ((xmc [20] & 0x1) << 7) - | ((xmc [21] & 0x7) << 4) - | ((xmc [22] & 0x7) << 1) - | ((xmc [23] >> 2) & 0x1) ; - *c++ = ((xmc [23] & 0x3) << 6) - | ((xmc [24] & 0x7) << 3) - | (xmc [25] & 0x7) ; - *c++ = ((Nc [2] & 0x7F) << 1) /* 20 */ - | ((bc [2] >> 1) & 0x1) ; - *c++ = ((bc [2] & 0x1) << 7) - | ((Mc [2] & 0x3) << 5) - | ((xmaxc [2] >> 1) & 0x1F) ; - *c++ = ((xmaxc [2] & 0x1) << 7) - | ((xmc [26] & 0x7) << 4) - | ((xmc [27] & 0x7) << 1) - | ((xmc [28] >> 2) & 0x1) ; - *c++ = ((xmc [28] & 0x3) << 6) - | ((xmc [29] & 0x7) << 3) - | (xmc [30] & 0x7) ; - *c++ = ((xmc [31] & 0x7) << 5) - | ((xmc [32] & 0x7) << 2) - | ((xmc [33] >> 1) & 0x3) ; - *c++ = ((xmc [33] & 0x1) << 7) - | ((xmc [34] & 0x7) << 4) - | ((xmc [35] & 0x7) << 1) - | ((xmc [36] >> 2) & 0x1) ; - *c++ = ((xmc [36] & 0x3) << 6) - | ((xmc [37] & 0x7) << 3) - | (xmc [38] & 0x7) ; - *c++ = ((Nc [3] & 0x7F) << 1) - | ((bc [3] >> 1) & 0x1) ; - *c++ = ((bc [3] & 0x1) << 7) - | ((Mc [3] & 0x3) << 5) - | ((xmaxc [3] >> 1) & 0x1F) ; - *c++ = ((xmaxc [3] & 0x1) << 7) - | ((xmc [39] & 0x7) << 4) - | ((xmc [40] & 0x7) << 1) - | ((xmc [41] >> 2) & 0x1) ; - *c++ = ((xmc [41] & 0x3) << 6) /* 30 */ - | ((xmc [42] & 0x7) << 3) - | (xmc [43] & 0x7) ; - *c++ = ((xmc [44] & 0x7) << 5) - | ((xmc [45] & 0x7) << 2) - | ((xmc [46] >> 1) & 0x3) ; - *c++ = ((xmc [46] & 0x1) << 7) - | ((xmc [47] & 0x7) << 4) - | ((xmc [48] & 0x7) << 1) - | ((xmc [49] >> 2) & 0x1) ; - *c++ = ((xmc [49] & 0x3) << 6) - | ((xmc [50] & 0x7) << 3) - | (xmc [51] & 0x7) ; - - } -} - diff --git a/Engine/lib/libsndfile/src/GSM610/gsm_option.c b/Engine/lib/libsndfile/src/GSM610/gsm_option.c deleted file mode 100644 index 208768338..000000000 --- a/Engine/lib/libsndfile/src/GSM610/gsm_option.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include "gsm610_priv.h" - -#include "gsm.h" - -int gsm_option (gsm r, int opt, int * val) -{ - int result = -1 ; - - switch (opt) { - case GSM_OPT_LTP_CUT: -#ifdef LTP_CUT - result = r->ltp_cut ; - if (val) r->ltp_cut = *val ; -#endif - break ; - - case GSM_OPT_VERBOSE: -#ifndef NDEBUG - result = r->verbose ; - if (val) r->verbose = *val ; -#endif - break ; - - case GSM_OPT_FAST: - -#if defined (FAST) && defined (USE_FLOAT_MUL) - result = r->fast ; - if (val) r->fast = !!*val ; -#endif - break ; - - case GSM_OPT_FRAME_CHAIN: - -#ifdef WAV49 - result = r->frame_chain ; - if (val) r->frame_chain = *val ; -#endif - break ; - - case GSM_OPT_FRAME_INDEX: - -#ifdef WAV49 - result = r->frame_index ; - if (val) r->frame_index = *val ; -#endif - break ; - - case GSM_OPT_WAV49: - -#ifdef WAV49 - result = r->wav_fmt ; - if (val) r->wav_fmt = !!*val ; -#endif - break ; - - default: - break ; - } - return result ; -} diff --git a/Engine/lib/libsndfile/src/GSM610/long_term.c b/Engine/lib/libsndfile/src/GSM610/long_term.c deleted file mode 100644 index 3276a464c..000000000 --- a/Engine/lib/libsndfile/src/GSM610/long_term.c +++ /dev/null @@ -1,932 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include -#include - -#include "gsm610_priv.h" - -/* - * 4.2.11 .. 4.2.12 LONG TERM PREDICTOR (LTP) SECTION - */ - - -/* - * This module computes the LTP gain (bc) and the LTP lag (Nc) - * for the long term analysis filter. This is done by calculating a - * maximum of the cross-correlation function between the current - * sub-segment short term residual signal d [0..39] (output of - * the short term analysis filter ; for simplification the index - * of this array begins at 0 and ends at 39 for each sub-segment of the - * RPE-LTP analysis) and the previous reconstructed short term - * residual signal dp [-120 .. -1]. A dynamic scaling must be - * performed to avoid overflow. - */ - - /* The next procedure exists in six versions. First two integer - * version (if USE_FLOAT_MUL is not defined) ; then four floating - * point versions, twice with proper scaling (USE_FLOAT_MUL defined), - * once without (USE_FLOAT_MUL and FAST defined, and fast run-time - * option used). Every pair has first a Cut version (see the -C - * option to toast or the LTP_CUT option to gsm_option ()), then the - * uncut one. (For a detailed explanation of why this is altogether - * a bad idea, see Henry Spencer and Geoff Collyer, ``#ifdef Considered - * Harmful''.) - */ - -#ifndef USE_FLOAT_MUL - -#ifdef LTP_CUT - -static void Cut_Calculation_of_the_LTP_parameters ( - - struct gsm_state * st, - - register int16_t * d, /* [0..39] IN */ - register int16_t * dp, /* [-120..-1] IN */ - int16_t * bc_out, /* OUT */ - int16_t * Nc_out /* OUT */) -{ - register int k, lambda ; - int16_t Nc, bc ; - int16_t wt [40] ; - - int32_t L_result ; - int32_t L_max, L_power ; - int16_t R, S, dmax, scal, best_k ; - int16_t ltp_cut ; - - register int16_t temp, wt_k ; - - /* Search of the optimum scaling of d [0..39]. */ - dmax = 0 ; - for (k = 0 ; k <= 39 ; k++) - { temp = d [k] ; - temp = GSM_ABS (temp) ; - if (temp > dmax) - { dmax = temp ; - best_k = k ; - } - } - temp = 0 ; - if (dmax == 0) - scal = 0 ; - else - { assert (dmax > 0) ; - temp = gsm_norm ((int32_t) dmax << 16) ; - } - if (temp > 6) scal = 0 ; - else scal = 6 - temp ; - assert (scal >= 0) ; - - /* Search for the maximum cross-correlation and coding of the LTP lag - */ - L_max = 0 ; - Nc = 40 ; /* index for the maximum cross-correlation */ - wt_k = SASR_W (d [best_k], scal) ; - - for (lambda = 40 ; lambda <= 120 ; lambda++) - { L_result = (int32_t) wt_k * dp [best_k - lambda] ; - if (L_result > L_max) - { Nc = lambda ; - L_max = L_result ; - } - } - *Nc_out = Nc ; - L_max <<= 1 ; - - /* Rescaling of L_max - */ - assert (scal <= 100 && scal >= -100) ; - L_max = L_max >> (6 - scal) ; /* sub (6, scal) */ - - assert (Nc <= 120 && Nc >= 40) ; - - /* Compute the power of the reconstructed short term residual - * signal dp [..] - */ - L_power = 0 ; - for (k = 0 ; k <= 39 ; k++) - { register int32_t L_temp ; - - L_temp = SASR_W (dp [k - Nc], 3) ; - L_power += L_temp * L_temp ; - } - L_power <<= 1 ; /* from L_MULT */ - - /* Normalization of L_max and L_power */ - - if (L_max <= 0) - { *bc_out = 0 ; - return ; - } - if (L_max >= L_power) - { *bc_out = 3 ; - return ; - } - - temp = gsm_norm (L_power) ; - - R = SASR (L_max << temp, 16) ; - S = SASR (L_power << temp, 16) ; - - /* Coding of the LTP gain - */ - - /* Table 4.3a must be used to obtain the level DLB [i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - for (bc = 0 ; bc <= 2 ; bc++) if (R <= gsm_mult (S, gsm_DLB [bc])) break ; - *bc_out = bc ; -} - -#endif /* LTP_CUT */ - -static void Calculation_of_the_LTP_parameters ( - register int16_t * d, /* [0..39] IN */ - register int16_t * dp, /* [-120..-1] IN */ - int16_t * bc_out, /* OUT */ - int16_t * Nc_out /* OUT */) -{ - register int k, lambda ; - int16_t Nc, bc ; - int16_t wt [40] ; - - int32_t L_max, L_power ; - int16_t R, S, dmax, scal ; - register int16_t temp ; - - /* Search of the optimum scaling of d [0..39]. - */ - dmax = 0 ; - - for (k = 0 ; k <= 39 ; k++) - { temp = d [k] ; - temp = GSM_ABS (temp) ; - if (temp > dmax) dmax = temp ; - } - - temp = 0 ; - if (dmax == 0) - scal = 0 ; - else - { assert (dmax > 0) ; - temp = gsm_norm ((int32_t) dmax << 16) ; - } - - if (temp > 6) scal = 0 ; - else scal = 6 - temp ; - - assert (scal >= 0) ; - - /* Initialization of a working array wt - */ - - for (k = 0 ; k <= 39 ; k++) wt [k] = SASR_W (d [k], scal) ; - - /* Search for the maximum cross-correlation and coding of the LTP lag */ - L_max = 0 ; - Nc = 40 ; /* index for the maximum cross-correlation */ - - for (lambda = 40 ; lambda <= 120 ; lambda++) - { - -# undef STEP -# define STEP(k) (int32_t) wt [k] * dp [k - lambda] - - register int32_t L_result ; - - L_result = STEP (0) ; L_result += STEP (1) ; - L_result += STEP (2) ; L_result += STEP (3) ; - L_result += STEP (4) ; L_result += STEP (5) ; - L_result += STEP (6) ; L_result += STEP (7) ; - L_result += STEP (8) ; L_result += STEP (9) ; - L_result += STEP (10) ; L_result += STEP (11) ; - L_result += STEP (12) ; L_result += STEP (13) ; - L_result += STEP (14) ; L_result += STEP (15) ; - L_result += STEP (16) ; L_result += STEP (17) ; - L_result += STEP (18) ; L_result += STEP (19) ; - L_result += STEP (20) ; L_result += STEP (21) ; - L_result += STEP (22) ; L_result += STEP (23) ; - L_result += STEP (24) ; L_result += STEP (25) ; - L_result += STEP (26) ; L_result += STEP (27) ; - L_result += STEP (28) ; L_result += STEP (29) ; - L_result += STEP (30) ; L_result += STEP (31) ; - L_result += STEP (32) ; L_result += STEP (33) ; - L_result += STEP (34) ; L_result += STEP (35) ; - L_result += STEP (36) ; L_result += STEP (37) ; - L_result += STEP (38) ; L_result += STEP (39) ; - - if (L_result > L_max) - { Nc = lambda ; - L_max = L_result ; - } - } - - *Nc_out = Nc ; - - L_max <<= 1 ; - - /* Rescaling of L_max - */ - assert (scal <= 100 && scal >= -100) ; - L_max = L_max >> (6 - scal) ; /* sub (6, scal) */ - - assert (Nc <= 120 && Nc >= 40) ; - - /* Compute the power of the reconstructed short term residual - * signal dp [..] - */ - L_power = 0 ; - for (k = 0 ; k <= 39 ; k++) - { register int32_t L_temp ; - - L_temp = SASR_W (dp [k - Nc], 3) ; - L_power += L_temp * L_temp ; - } - L_power <<= 1 ; /* from L_MULT */ - - /* Normalization of L_max and L_power - */ - - if (L_max <= 0) - { *bc_out = 0 ; - return ; - } - if (L_max >= L_power) - { *bc_out = 3 ; - return ; - } - - temp = gsm_norm (L_power) ; - - R = SASR_L (L_max << temp, 16) ; - S = SASR_L (L_power << temp, 16) ; - - /* Coding of the LTP gain - */ - - /* Table 4.3a must be used to obtain the level DLB [i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - for (bc = 0 ; bc <= 2 ; bc++) if (R <= gsm_mult (S, gsm_DLB [bc])) break ; - *bc_out = bc ; -} - -#else /* USE_FLOAT_MUL */ - -#ifdef LTP_CUT - -static void Cut_Calculation_of_the_LTP_parameters ( - struct gsm_state * st, /* IN */ - register int16_t * d, /* [0..39] IN */ - register int16_t * dp, /* [-120..-1] IN */ - int16_t * bc_out, /* OUT */ - int16_t * Nc_out /* OUT */) -{ - register int k, lambda ; - int16_t Nc, bc ; - int16_t ltp_cut ; - - float wt_float [40] ; - float dp_float_base [120], * dp_float = dp_float_base + 120 ; - - int32_t L_max, L_power ; - int16_t R, S, dmax, scal ; - register int16_t temp ; - - /* Search of the optimum scaling of d [0..39]. - */ - dmax = 0 ; - - for (k = 0 ; k <= 39 ; k++) - { temp = d [k] ; - temp = GSM_ABS (temp) ; - if (temp > dmax) dmax = temp ; - } - - temp = 0 ; - if (dmax == 0) scal = 0 ; - else - { assert (dmax > 0) ; - temp = gsm_norm ((int32_t) dmax << 16) ; - } - - if (temp > 6) scal = 0 ; - else scal = 6 - temp ; - - assert (scal >= 0) ; - ltp_cut = (int32_t) SASR_W (dmax, scal) * st->ltp_cut / 100 ; - - /* Initialization of a working array wt */ - - for (k = 0 ; k < 40 ; k++) - { register int16_t w = SASR_W (d [k], scal) ; - if (w < 0 ? w > -ltp_cut : w < ltp_cut) - wt_float [k] = 0.0 ; - else - wt_float [k] = w ; - } - for (k = -120 ; k < 0 ; k++) dp_float [k] = dp [k] ; - - /* Search for the maximum cross-correlation and coding of the LTP lag - */ - L_max = 0 ; - Nc = 40 ; /* index for the maximum cross-correlation */ - - for (lambda = 40 ; lambda <= 120 ; lambda += 9) - { /* Calculate L_result for l = lambda .. lambda + 9. */ - register float *lp = dp_float - lambda ; - - register float W ; - register float a = lp [-8], b = lp [-7], c = lp [-6], - d = lp [-5], e = lp [-4], f = lp [-3], - g = lp [-2], h = lp [-1] ; - register float E ; - register float S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0, - S5 = 0, S6 = 0, S7 = 0, S8 = 0 ; - -# undef STEP -# define STEP(K, a, b, c, d, e, f, g, h) \ - if ((W = wt_float [K]) != 0.0) { \ - E = W * a ; S8 += E ; \ - E = W * b ; S7 += E ; \ - E = W * c ; S6 += E ; \ - E = W * d ; S5 += E ; \ - E = W * e ; S4 += E ; \ - E = W * f ; S3 += E ; \ - E = W * g ; S2 += E ; \ - E = W * h ; S1 += E ; \ - a = lp [K] ; \ - E = W * a ; S0 += E ; } else (a = lp [K]) - -# define STEP_A(K) STEP (K, a, b, c, d, e, f, g, h) -# define STEP_B(K) STEP (K, b, c, d, e, f, g, h, a) -# define STEP_C(K) STEP (K, c, d, e, f, g, h, a, b) -# define STEP_D(K) STEP (K, d, e, f, g, h, a, b, c) -# define STEP_E(K) STEP (K, e, f, g, h, a, b, c, d) -# define STEP_F(K) STEP (K, f, g, h, a, b, c, d, e) -# define STEP_G(K) STEP (K, g, h, a, b, c, d, e, f) -# define STEP_H(K) STEP (K, h, a, b, c, d, e, f, g) - - STEP_A (0) ; STEP_B (1) ; STEP_C (2) ; STEP_D (3) ; - STEP_E (4) ; STEP_F (5) ; STEP_G (6) ; STEP_H (7) ; - - STEP_A (8) ; STEP_B (9) ; STEP_C (10) ; STEP_D (11) ; - STEP_E (12) ; STEP_F (13) ; STEP_G (14) ; STEP_H (15) ; - - STEP_A (16) ; STEP_B (17) ; STEP_C (18) ; STEP_D (19) ; - STEP_E (20) ; STEP_F (21) ; STEP_G (22) ; STEP_H (23) ; - - STEP_A (24) ; STEP_B (25) ; STEP_C (26) ; STEP_D (27) ; - STEP_E (28) ; STEP_F (29) ; STEP_G (30) ; STEP_H (31) ; - - STEP_A (32) ; STEP_B (33) ; STEP_C (34) ; STEP_D (35) ; - STEP_E (36) ; STEP_F (37) ; STEP_G (38) ; STEP_H (39) ; - -# undef STEP_A -# undef STEP_B -# undef STEP_C -# undef STEP_D -# undef STEP_E -# undef STEP_F -# undef STEP_G -# undef STEP_H - - if (S0 > L_max) { L_max = S0 ; Nc = lambda ; } - if (S1 > L_max) { L_max = S1 ; Nc = lambda + 1 ; } - if (S2 > L_max) { L_max = S2 ; Nc = lambda + 2 ; } - if (S3 > L_max) { L_max = S3 ; Nc = lambda + 3 ; } - if (S4 > L_max) { L_max = S4 ; Nc = lambda + 4 ; } - if (S5 > L_max) { L_max = S5 ; Nc = lambda + 5 ; } - if (S6 > L_max) { L_max = S6 ; Nc = lambda + 6 ; } - if (S7 > L_max) { L_max = S7 ; Nc = lambda + 7 ; } - if (S8 > L_max) { L_max = S8 ; Nc = lambda + 8 ; } - - } - *Nc_out = Nc ; - - L_max <<= 1 ; - - /* Rescaling of L_max - */ - assert (scal <= 100 && scal >= -100) ; - L_max = L_max >> (6 - scal) ; /* sub (6, scal) */ - - assert (Nc <= 120 && Nc >= 40) ; - - /* Compute the power of the reconstructed short term residual - * signal dp [..] - */ - L_power = 0 ; - for (k = 0 ; k <= 39 ; k++) - { register int32_t L_temp ; - - L_temp = SASR_W (dp [k - Nc], 3) ; - L_power += L_temp * L_temp ; - } - L_power <<= 1 ; /* from L_MULT */ - - /* Normalization of L_max and L_power - */ - - if (L_max <= 0) - { *bc_out = 0 ; - return ; - } - if (L_max >= L_power) - { *bc_out = 3 ; - return ; - } - - temp = gsm_norm (L_power) ; - - R = SASR (L_max << temp, 16) ; - S = SASR (L_power << temp, 16) ; - - /* Coding of the LTP gain - */ - - /* Table 4.3a must be used to obtain the level DLB [i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - for (bc = 0 ; bc <= 2 ; bc++) if (R <= gsm_mult (S, gsm_DLB [bc])) break ; - *bc_out = bc ; -} - -#endif /* LTP_CUT */ - -static void Calculation_of_the_LTP_parameters ( - register int16_t * din, /* [0..39] IN */ - register int16_t * dp, /* [-120..-1] IN */ - int16_t * bc_out, /* OUT */ - int16_t * Nc_out /* OUT */) -{ - register int k, lambda ; - int16_t Nc, bc ; - - float wt_float [40] ; - float dp_float_base [120], * dp_float = dp_float_base + 120 ; - - int32_t L_max, L_power ; - int16_t R, S, dmax, scal ; - register int16_t temp ; - - /* Search of the optimum scaling of d [0..39]. - */ - dmax = 0 ; - - for (k = 0 ; k <= 39 ; k++) - { temp = din [k] ; - temp = GSM_ABS (temp) ; - if (temp > dmax) dmax = temp ; - } - - temp = 0 ; - if (dmax == 0) scal = 0 ; - else - { assert (dmax > 0) ; - temp = gsm_norm ((int32_t) dmax << 16) ; - } - - if (temp > 6) scal = 0 ; - else scal = 6 - temp ; - - assert (scal >= 0) ; - - /* Initialization of a working array wt */ - - for (k = 0 ; k < 40 ; k++) wt_float [k] = SASR_W (din [k], scal) ; - for (k = -120 ; k < 0 ; k++) dp_float [k] = dp [k] ; - - /* Search for the maximum cross-correlation and coding of the LTP lag - */ - L_max = 0 ; - Nc = 40 ; /* index for the maximum cross-correlation */ - - for (lambda = 40 ; lambda <= 120 ; lambda += 9) - { /* Calculate L_result for l = lambda .. lambda + 9. */ - register float *lp = dp_float - lambda ; - - register float W ; - register float a = lp [-8], b = lp [-7], c = lp [-6], - d = lp [-5], e = lp [-4], f = lp [-3], - g = lp [-2], h = lp [-1] ; - register float E ; - register float S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0, - S5 = 0, S6 = 0, S7 = 0, S8 = 0 ; - -# undef STEP -# define STEP(K, a, b, c, d, e, f, g, h) \ - W = wt_float [K] ; \ - E = W * a ; S8 += E ; \ - E = W * b ; S7 += E ; \ - E = W * c ; S6 += E ; \ - E = W * d ; S5 += E ; \ - E = W * e ; S4 += E ; \ - E = W * f ; S3 += E ; \ - E = W * g ; S2 += E ; \ - E = W * h ; S1 += E ; \ - a = lp [K] ; \ - E = W * a ; S0 += E - -# define STEP_A(K) STEP (K, a, b, c, d, e, f, g, h) -# define STEP_B(K) STEP (K, b, c, d, e, f, g, h, a) -# define STEP_C(K) STEP (K, c, d, e, f, g, h, a, b) -# define STEP_D(K) STEP (K, d, e, f, g, h, a, b, c) -# define STEP_E(K) STEP (K, e, f, g, h, a, b, c, d) -# define STEP_F(K) STEP (K, f, g, h, a, b, c, d, e) -# define STEP_G(K) STEP (K, g, h, a, b, c, d, e, f) -# define STEP_H(K) STEP (K, h, a, b, c, d, e, f, g) - - STEP_A (0) ; STEP_B (1) ; STEP_C (2) ; STEP_D (3) ; - STEP_E (4) ; STEP_F (5) ; STEP_G (6) ; STEP_H (7) ; - - STEP_A (8) ; STEP_B (9) ; STEP_C (10) ; STEP_D (11) ; - STEP_E (12) ; STEP_F (13) ; STEP_G (14) ; STEP_H (15) ; - - STEP_A (16) ; STEP_B (17) ; STEP_C (18) ; STEP_D (19) ; - STEP_E (20) ; STEP_F (21) ; STEP_G (22) ; STEP_H (23) ; - - STEP_A (24) ; STEP_B (25) ; STEP_C (26) ; STEP_D (27) ; - STEP_E (28) ; STEP_F (29) ; STEP_G (30) ; STEP_H (31) ; - - STEP_A (32) ; STEP_B (33) ; STEP_C (34) ; STEP_D (35) ; - STEP_E (36) ; STEP_F (37) ; STEP_G (38) ; STEP_H (39) ; - -# undef STEP_A -# undef STEP_B -# undef STEP_C -# undef STEP_D -# undef STEP_E -# undef STEP_F -# undef STEP_G -# undef STEP_H - - if (S0 > L_max) { L_max = S0 ; Nc = lambda ; } - if (S1 > L_max) { L_max = S1 ; Nc = lambda + 1 ; } - if (S2 > L_max) { L_max = S2 ; Nc = lambda + 2 ; } - if (S3 > L_max) { L_max = S3 ; Nc = lambda + 3 ; } - if (S4 > L_max) { L_max = S4 ; Nc = lambda + 4 ; } - if (S5 > L_max) { L_max = S5 ; Nc = lambda + 5 ; } - if (S6 > L_max) { L_max = S6 ; Nc = lambda + 6 ; } - if (S7 > L_max) { L_max = S7 ; Nc = lambda + 7 ; } - if (S8 > L_max) { L_max = S8 ; Nc = lambda + 8 ; } - } - *Nc_out = Nc ; - - L_max <<= 1 ; - - /* Rescaling of L_max - */ - assert (scal <= 100 && scal >= -100) ; - L_max = L_max >> (6 - scal) ; /* sub (6, scal) */ - - assert (Nc <= 120 && Nc >= 40) ; - - /* Compute the power of the reconstructed short term residual - * signal dp [..] - */ - L_power = 0 ; - for (k = 0 ; k <= 39 ; k++) - { register int32_t L_temp ; - - L_temp = SASR_W (dp [k - Nc], 3) ; - L_power += L_temp * L_temp ; - } - L_power <<= 1 ; /* from L_MULT */ - - /* Normalization of L_max and L_power - */ - - if (L_max <= 0) - { *bc_out = 0 ; - return ; - } - if (L_max >= L_power) - { *bc_out = 3 ; - return ; - } - - temp = gsm_norm (L_power) ; - - R = SASR_L (L_max << temp, 16) ; - S = SASR_L (L_power << temp, 16) ; - - /* Coding of the LTP gain - */ - - /* Table 4.3a must be used to obtain the level DLB [i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - for (bc = 0 ; bc <= 2 ; bc++) if (R <= gsm_mult (S, gsm_DLB [bc])) break ; - *bc_out = bc ; -} - -#ifdef FAST -#ifdef LTP_CUT - -static void Cut_Fast_Calculation_of_the_LTP_parameters ( - struct gsm_state * st, /* IN */ - register int16_t * d, /* [0..39] IN */ - register int16_t * dp, /* [-120..-1] IN */ - int16_t * bc_out, /* OUT */ - int16_t * Nc_out /* OUT */) -{ - register int k, lambda ; - register float wt_float ; - int16_t Nc, bc ; - int16_t wt_max, best_k, ltp_cut ; - - float dp_float_base [120], * dp_float = dp_float_base + 120 ; - - register float L_result, L_max, L_power ; - - wt_max = 0 ; - - for (k = 0 ; k < 40 ; ++k) - { if (d [k] > wt_max) wt_max = d [best_k = k] ; - else if (-d [k] > wt_max) wt_max = -d [best_k = k] ; - } - - assert (wt_max >= 0) ; - wt_float = (float) wt_max ; - - for (k = -120 ; k < 0 ; ++k) dp_float [k] = (float) dp [k] ; - - /* Search for the maximum cross-correlation and coding of the LTP lag */ - L_max = 0 ; - Nc = 40 ; /* index for the maximum cross-correlation */ - - for (lambda = 40 ; lambda <= 120 ; lambda++) - { L_result = wt_float * dp_float [best_k - lambda] ; - if (L_result > L_max) - { Nc = lambda ; - L_max = L_result ; - } - } - - *Nc_out = Nc ; - if (L_max <= 0.) - { *bc_out = 0 ; - return ; - } - - /* Compute the power of the reconstructed short term residual - * signal dp [..] - */ - dp_float -= Nc ; - L_power = 0 ; - for (k = 0 ; k < 40 ; ++k) - { register float f = dp_float [k] ; - L_power += f * f ; - } - - if (L_max >= L_power) - { *bc_out = 3 ; - return ; - } - - /* Coding of the LTP gain - * Table 4.3a must be used to obtain the level DLB [i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - lambda = L_max / L_power * 32768.0 ; - for (bc = 0 ; bc <= 2 ; ++bc) if (lambda <= gsm_DLB [bc]) break ; - *bc_out = bc ; -} - -#endif /* LTP_CUT */ - -static void Fast_Calculation_of_the_LTP_parameters ( - register int16_t * din, /* [0..39] IN */ - register int16_t * dp, /* [-120..-1] IN */ - int16_t * bc_out, /* OUT */ - int16_t * Nc_out /* OUT */) -{ - register int k, lambda ; - int16_t Nc, bc ; - - float wt_float [40] ; - float dp_float_base [120], * dp_float = dp_float_base + 120 ; - - register float L_max, L_power ; - - for (k = 0 ; k < 40 ; ++k) wt_float [k] = (float) din [k] ; - for (k = -120 ; k < 0 ; ++k) dp_float [k] = (float) dp [k] ; - - /* Search for the maximum cross-correlation and coding of the LTP lag */ - L_max = 0 ; - Nc = 40 ; /* index for the maximum cross-correlation */ - - for (lambda = 40 ; lambda <= 120 ; lambda += 9) - { /* Calculate L_result for l = lambda .. lambda + 9. */ - register float *lp = dp_float - lambda ; - - register float W ; - register float a = lp [-8], b = lp [-7], c = lp [-6], - d = lp [-5], e = lp [-4], f = lp [-3], - g = lp [-2], h = lp [-1] ; - register float E ; - register float S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0, - S5 = 0, S6 = 0, S7 = 0, S8 = 0 ; - -# undef STEP -# define STEP(K, a, b, c, d, e, f, g, h) \ - W = wt_float [K] ; \ - E = W * a ; S8 += E ; \ - E = W * b ; S7 += E ; \ - E = W * c ; S6 += E ; \ - E = W * d ; S5 += E ; \ - E = W * e ; S4 += E ; \ - E = W * f ; S3 += E ; \ - E = W * g ; S2 += E ; \ - E = W * h ; S1 += E ; \ - a = lp [K] ; \ - E = W * a ; S0 += E - -# define STEP_A(K) STEP (K, a, b, c, d, e, f, g, h) -# define STEP_B(K) STEP (K, b, c, d, e, f, g, h, a) -# define STEP_C(K) STEP (K, c, d, e, f, g, h, a, b) -# define STEP_D(K) STEP (K, d, e, f, g, h, a, b, c) -# define STEP_E(K) STEP (K, e, f, g, h, a, b, c, d) -# define STEP_F(K) STEP (K, f, g, h, a, b, c, d, e) -# define STEP_G(K) STEP (K, g, h, a, b, c, d, e, f) -# define STEP_H(K) STEP (K, h, a, b, c, d, e, f, g) - - STEP_A (0) ; STEP_B (1) ; STEP_C (2) ; STEP_D (3) ; - STEP_E (4) ; STEP_F (5) ; STEP_G (6) ; STEP_H (7) ; - - STEP_A (8) ; STEP_B (9) ; STEP_C (10) ; STEP_D (11) ; - STEP_E (12) ; STEP_F (13) ; STEP_G (14) ; STEP_H (15) ; - - STEP_A (16) ; STEP_B (17) ; STEP_C (18) ; STEP_D (19) ; - STEP_E (20) ; STEP_F (21) ; STEP_G (22) ; STEP_H (23) ; - - STEP_A (24) ; STEP_B (25) ; STEP_C (26) ; STEP_D (27) ; - STEP_E (28) ; STEP_F (29) ; STEP_G (30) ; STEP_H (31) ; - - STEP_A (32) ; STEP_B (33) ; STEP_C (34) ; STEP_D (35) ; - STEP_E (36) ; STEP_F (37) ; STEP_G (38) ; STEP_H (39) ; - - if (S0 > L_max) { L_max = S0 ; Nc = lambda ; } - if (S1 > L_max) { L_max = S1 ; Nc = lambda + 1 ; } - if (S2 > L_max) { L_max = S2 ; Nc = lambda + 2 ; } - if (S3 > L_max) { L_max = S3 ; Nc = lambda + 3 ; } - if (S4 > L_max) { L_max = S4 ; Nc = lambda + 4 ; } - if (S5 > L_max) { L_max = S5 ; Nc = lambda + 5 ; } - if (S6 > L_max) { L_max = S6 ; Nc = lambda + 6 ; } - if (S7 > L_max) { L_max = S7 ; Nc = lambda + 7 ; } - if (S8 > L_max) { L_max = S8 ; Nc = lambda + 8 ; } - } - *Nc_out = Nc ; - - if (L_max <= 0.0) - { *bc_out = 0 ; - return ; - } - - /* Compute the power of the reconstructed short term residual - * signal dp [..] - */ - dp_float -= Nc ; - L_power = 0 ; - for (k = 0 ; k < 40 ; ++k) - { register float f = dp_float [k] ; - L_power += f * f ; - } - - if (L_max >= L_power) - { *bc_out = 3 ; - return ; - } - - /* Coding of the LTP gain - * Table 4.3a must be used to obtain the level DLB [i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - lambda = L_max / L_power * 32768.0 ; - for (bc = 0 ; bc <= 2 ; ++bc) if (lambda <= gsm_DLB [bc]) break ; - *bc_out = bc ; -} - -#endif /* FAST */ -#endif /* USE_FLOAT_MUL */ - - -/* 4.2.12 */ - -static void Long_term_analysis_filtering ( - int16_t bc, /* IN */ - int16_t Nc, /* IN */ - register int16_t * dp, /* previous d [-120..-1] IN */ - register int16_t * d, /* d [0..39] IN */ - register int16_t * dpp, /* estimate [0..39] OUT */ - register int16_t * e /* long term res. signal [0..39] OUT */) -/* - * In this part, we have to decode the bc parameter to compute - * the samples of the estimate dpp [0..39]. The decoding of bc needs the - * use of table 4.3b. The long term residual signal e [0..39] - * is then calculated to be fed to the RPE encoding section. - */ -{ - register int k ; - -# undef STEP -# define STEP(BP) \ - for (k = 0 ; k <= 39 ; k++) \ - { dpp [k] = GSM_MULT_R (BP, dp [k - Nc]) ; \ - e [k] = GSM_SUB (d [k], dpp [k]) ; \ - } - - switch (bc) - { case 0: STEP (3277) ; break ; - case 1: STEP (11469) ; break ; - case 2: STEP (21299) ; break ; - case 3: STEP (32767) ; break ; - } -} - -void Gsm_Long_Term_Predictor ( /* 4x for 160 samples */ - - struct gsm_state * S, - - int16_t * d, /* [0..39] residual signal IN */ - int16_t * dp, /* [-120..-1] d' IN */ - - int16_t * e, /* [0..39] OUT */ - int16_t * dpp, /* [0..39] OUT */ - int16_t * Nc, /* correlation lag OUT */ - int16_t * bc /* gain factor OUT */) -{ - assert (d) ; assert (dp) ; assert (e) ; - assert (dpp) ; assert (Nc) ; assert (bc) ; - -#if defined (FAST) && defined (USE_FLOAT_MUL) - if (S->fast) -#if defined (LTP_CUT) - if (S->ltp_cut) - Cut_Fast_Calculation_of_the_LTP_parameters (S, - d, dp, bc, Nc) ; - else -#endif /* LTP_CUT */ - Fast_Calculation_of_the_LTP_parameters (d, dp, bc, Nc) ; - else -#endif /* FAST & USE_FLOAT_MUL */ -#ifdef LTP_CUT - if (S->ltp_cut) - Cut_Calculation_of_the_LTP_parameters (S, d, dp, bc, Nc) ; - else -#endif - Calculation_of_the_LTP_parameters (d, dp, bc, Nc) ; - - Long_term_analysis_filtering (*bc, *Nc, dp, d, dpp, e) ; -} - -/* 4.3.2 */ -void Gsm_Long_Term_Synthesis_Filtering ( - struct gsm_state * S, - - int16_t Ncr, - int16_t bcr, - register int16_t * erp, /* [0..39] IN */ - register int16_t * drp /* [-120..-1] IN, [-120..40] OUT */) -/* - * This procedure uses the bcr and Ncr parameter to realize the - * long term synthesis filtering. The decoding of bcr needs - * table 4.3b. - */ -{ - register int k ; - int16_t brp, drpp, Nr ; - - /* Check the limits of Nr. - */ - Nr = Ncr < 40 || Ncr > 120 ? S->nrp : Ncr ; - S->nrp = Nr ; - assert (Nr >= 40 && Nr <= 120) ; - - /* Decoding of the LTP gain bcr - */ - brp = gsm_QLB [bcr] ; - - /* Computation of the reconstructed short term residual - * signal drp [0..39] - */ - assert (brp != MIN_WORD) ; - - for (k = 0 ; k <= 39 ; k++) - { drpp = GSM_MULT_R (brp, drp [k - Nr]) ; - drp [k] = GSM_ADD (erp [k], drpp) ; - } - - /* - * Update of the reconstructed short term residual signal - * drp [-1..-120] - */ - - for (k = 0 ; k <= 119 ; k++) drp [-120 + k] = drp [-80 + k] ; -} diff --git a/Engine/lib/libsndfile/src/GSM610/lpc.c b/Engine/lib/libsndfile/src/GSM610/lpc.c deleted file mode 100644 index 922421e15..000000000 --- a/Engine/lib/libsndfile/src/GSM610/lpc.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include -#include -#include - -#include "gsm610_priv.h" - -/* - * 4.2.4 .. 4.2.7 LPC ANALYSIS SECTION - */ - -/* 4.2.4 */ - - -static void Autocorrelation ( - int16_t * s, /* [0..159] IN/OUT */ - int32_t * L_ACF) /* [0..8] OUT */ -/* - * The goal is to compute the array L_ACF [k]. The signal s [i] must - * be scaled in order to avoid an overflow situation. - */ -{ - register int k, i ; - - int16_t temp, smax, scalauto ; - -#ifdef USE_FLOAT_MUL - float float_s [160] ; -#endif - - /* Dynamic scaling of the array s [0..159] */ - - /* Search for the maximum. */ - smax = 0 ; - for (k = 0 ; k <= 159 ; k++) - { temp = GSM_ABS (s [k]) ; - if (temp > smax) smax = temp ; - } - - /* Computation of the scaling factor. - */ - if (smax == 0) - scalauto = 0 ; - else - { assert (smax > 0) ; - scalauto = 4 - gsm_norm ((int32_t) smax << 16) ; /* sub (4,..) */ - } - - /* Scaling of the array s [0...159] - */ - - if (scalauto > 0) - { - -# ifdef USE_FLOAT_MUL -# define SCALE(n) \ - case n: for (k = 0 ; k <= 159 ; k++) \ - float_s [k] = (float) \ - (s [k] = GSM_MULT_R (s [k], 16384 >> (n-1))) ;\ - break ; -# else -# define SCALE(n) \ - case n: for (k = 0 ; k <= 159 ; k++) \ - s [k] = GSM_MULT_R (s [k], 16384 >> (n-1)) ;\ - break ; -# endif /* USE_FLOAT_MUL */ - - switch (scalauto) { - SCALE (1) - SCALE (2) - SCALE (3) - SCALE (4) - } -# undef SCALE - } -# ifdef USE_FLOAT_MUL - else for (k = 0 ; k <= 159 ; k++) float_s [k] = (float) s [k] ; -# endif - - /* Compute the L_ACF [..]. - */ - { -# ifdef USE_FLOAT_MUL - register float *sp = float_s ; - register float sl = *sp ; - -# define STEP(k) L_ACF [k] += (int32_t) (sl * sp [- (k)]) ; -# else - int16_t *sp = s ; - int16_t sl = *sp ; - -# define STEP(k) L_ACF [k] += ((int32_t) sl * sp [- (k)]) ; -# endif - -# define NEXTI sl = *++sp - - - for (k = 9 ; k-- ; L_ACF [k] = 0) ; - - STEP (0) ; - NEXTI ; - STEP (0) ; STEP (1) ; - NEXTI ; - STEP (0) ; STEP (1) ; STEP (2) ; - NEXTI ; - STEP (0) ; STEP (1) ; STEP (2) ; STEP (3) ; - NEXTI ; - STEP (0) ; STEP (1) ; STEP (2) ; STEP (3) ; STEP (4) ; - NEXTI ; - STEP (0) ; STEP (1) ; STEP (2) ; STEP (3) ; STEP (4) ; STEP (5) ; - NEXTI ; - STEP (0) ; STEP (1) ; STEP (2) ; STEP (3) ; STEP (4) ; STEP (5) ; STEP (6) ; - NEXTI ; - STEP (0) ; STEP (1) ; STEP (2) ; STEP (3) ; STEP (4) ; STEP (5) ; STEP (6) ; STEP (7) ; - - for (i = 8 ; i <= 159 ; i++) - { NEXTI ; - - STEP (0) ; - STEP (1) ; STEP (2) ; STEP (3) ; STEP (4) ; - STEP (5) ; STEP (6) ; STEP (7) ; STEP (8) ; - } - - for (k = 9 ; k-- ; ) - L_ACF [k] = SASL_L (L_ACF [k], 1) ; - - } - /* Rescaling of the array s [0..159] - */ - if (scalauto > 0) - { assert (scalauto <= 4) ; - for (k = 160 ; k-- ; s++) - *s = SASL_W (*s, scalauto) ; - } -} - -#if defined (USE_FLOAT_MUL) && defined (FAST) - -static void Fast_Autocorrelation ( - int16_t * s, /* [0..159] IN/OUT */ - int32_t * L_ACF) /* [0..8] OUT */ -{ - register int k, i ; - float f_L_ACF [9] ; - float scale ; - - float s_f [160] ; - register float *sf = s_f ; - - for (i = 0 ; i < 160 ; ++i) sf [i] = s [i] ; - for (k = 0 ; k <= 8 ; k++) - { register float L_temp2 = 0 ; - register float *sfl = sf - k ; - for (i = k ; i < 160 ; ++i) L_temp2 += sf [i] * sfl [i] ; - f_L_ACF [k] = L_temp2 ; - } - scale = 2147483648.0f / f_L_ACF [0] ; - - for (k = 0 ; k <= 8 ; k++) - L_ACF [k] = f_L_ACF [k] * scale ; -} -#endif /* defined (USE_FLOAT_MUL) && defined (FAST) */ - -/* 4.2.5 */ - -static void Reflection_coefficients ( - int32_t * L_ACF, /* 0...8 IN */ - register int16_t * r /* 0...7 OUT */ -) -{ - register int i, m, n ; - register int16_t temp ; - int16_t ACF [9] ; /* 0..8 */ - int16_t P [9] ; /* 0..8 */ - int16_t K [9] ; /* 2..8 */ - - /* Schur recursion with 16 bits arithmetic. - */ - - if (L_ACF [0] == 0) - { memset (r, 0, 8 * sizeof (r [0])) ; - return ; - } - - assert (L_ACF [0] != 0) ; - temp = gsm_norm (L_ACF [0]) ; - - assert (temp >= 0 && temp < 32) ; - - /* ? overflow ? */ - for (i = 0 ; i <= 8 ; i++) ACF [i] = SASR_L (SASL_L (L_ACF [i], temp), 16) ; - - /* Initialize array P [..] and K [..] for the recursion. - */ - - for (i = 1 ; i <= 7 ; i++) K [i] = ACF [i] ; - for (i = 0 ; i <= 8 ; i++) P [i] = ACF [i] ; - - /* Compute reflection coefficients - */ - for (n = 1 ; n <= 8 ; n++, r++) - { temp = P [1] ; - temp = GSM_ABS (temp) ; - if (P [0] < temp) - { for (i = n ; i <= 8 ; i++) *r++ = 0 ; - return ; - } - - *r = gsm_div (temp, P [0]) ; - - assert (*r >= 0) ; - if (P [1] > 0) *r = -*r ; /* r [n] = sub (0, r [n]) */ - assert (*r != MIN_WORD) ; - if (n == 8) return ; - - /* Schur recursion - */ - temp = GSM_MULT_R (P [1], *r) ; - P [0] = GSM_ADD (P [0], temp) ; - - for (m = 1 ; m <= 8 - n ; m++) - { temp = GSM_MULT_R (K [m], *r) ; - P [m] = GSM_ADD (P [m + 1], temp) ; - - temp = GSM_MULT_R (P [m + 1], *r) ; - K [m] = GSM_ADD (K [m], temp) ; - } - } -} - -/* 4.2.6 */ - -static void Transformation_to_Log_Area_Ratios ( - register int16_t * r /* 0..7 IN/OUT */ -) -/* - * The following scaling for r [..] and LAR [..] has been used: - * - * r [..] = integer (real_r [..]*32768.) ; -1 <= real_r < 1. - * LAR [..] = integer (real_LAR [..] * 16384) ; - * with -1.625 <= real_LAR <= 1.625 - */ -{ - register int16_t temp ; - register int i ; - - - /* Computation of the LAR [0..7] from the r [0..7] - */ - for (i = 1 ; i <= 8 ; i++, r++) - { temp = *r ; - temp = GSM_ABS (temp) ; - assert (temp >= 0) ; - - if (temp < 22118) - { temp >>= 1 ; - } - else if (temp < 31130) - { assert (temp >= 11059) ; - temp -= 11059 ; - } - else - { assert (temp >= 26112) ; - temp -= 26112 ; - temp <<= 2 ; - } - - *r = *r < 0 ? -temp : temp ; - assert (*r != MIN_WORD) ; - } -} - -/* 4.2.7 */ - -static void Quantization_and_coding ( - register int16_t * LAR /* [0..7] IN/OUT */ -) -{ - register int16_t temp ; - - /* This procedure needs four tables ; the following equations - * give the optimum scaling for the constants: - * - * A [0..7] = integer (real_A [0..7] * 1024) - * B [0..7] = integer (real_B [0..7] * 512) - * MAC [0..7] = maximum of the LARc [0..7] - * MIC [0..7] = minimum of the LARc [0..7] - */ - -# undef STEP -# define STEP(A, B, MAC, MIC) \ - temp = GSM_MULT (A, *LAR) ; \ - temp = GSM_ADD (temp, B) ; \ - temp = GSM_ADD (temp, 256) ; \ - temp = SASR_W (temp, 9) ; \ - *LAR = temp > MAC ? MAC - MIC : (temp < MIC ? 0 : temp - MIC) ; \ - LAR++ ; - - STEP (20480, 0, 31, -32) ; - STEP (20480, 0, 31, -32) ; - STEP (20480, 2048, 15, -16) ; - STEP (20480, -2560, 15, -16) ; - - STEP (13964, 94, 7, -8) ; - STEP (15360, -1792, 7, -8) ; - STEP (8534, -341, 3, -4) ; - STEP (9036, -1144, 3, -4) ; - -# undef STEP -} - -void Gsm_LPC_Analysis ( - struct gsm_state *S, - int16_t * s, /* 0..159 signals IN/OUT */ - int16_t *LARc) /* 0..7 LARc's OUT */ -{ - int32_t L_ACF [9] ; - -#if defined (USE_FLOAT_MUL) && defined (FAST) - if (S->fast) - Fast_Autocorrelation (s, L_ACF) ; - else -#endif - Autocorrelation (s, L_ACF ) ; - Reflection_coefficients (L_ACF, LARc ) ; - Transformation_to_Log_Area_Ratios (LARc) ; - Quantization_and_coding (LARc) ; -} diff --git a/Engine/lib/libsndfile/src/GSM610/preprocess.c b/Engine/lib/libsndfile/src/GSM610/preprocess.c deleted file mode 100644 index 82f4fe296..000000000 --- a/Engine/lib/libsndfile/src/GSM610/preprocess.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include -#include - -#include "gsm610_priv.h" - -/* 4.2.0 .. 4.2.3 PREPROCESSING SECTION - * - * After A-law to linear conversion (or directly from the - * Ato D converter) the following scaling is assumed for - * input to the RPE-LTP algorithm: - * - * in: 0.1.....................12 - * S.v.v.v.v.v.v.v.v.v.v.v.v.*.*.* - * - * Where S is the sign bit, v a valid bit, and * a "don't care" bit. - * The original signal is called sop[..] - * - * out: 0.1................... 12 - * S.S.v.v.v.v.v.v.v.v.v.v.v.v.0.0 - */ - - -void Gsm_Preprocess ( - struct gsm_state * S, - int16_t * s, - int16_t * so) /* [0..159] IN/OUT */ -{ - - int16_t z1 = S->z1 ; - int32_t L_z2 = S->L_z2 ; - int16_t mp = S->mp ; - - int16_t s1 ; - int32_t L_s2 ; - - int32_t L_temp ; - - int16_t msp, lsp ; - int16_t SO ; - - register int k = 160 ; - - while (k--) - { - - /* 4.2.1 Downscaling of the input signal */ - SO = arith_shift_left (SASR_W (*s, 3), 2) ; - s++ ; - - assert (SO >= -0x4000) ; /* downscaled by */ - assert (SO <= 0x3FFC) ; /* previous routine. */ - - - /* 4.2.2 Offset compensation - * - * This part implements a high-pass filter and requires extended - * arithmetic precision for the recursive part of this filter. - * The input of this procedure is the array so[0...159] and the - * output the array sof[ 0...159 ]. - */ - - /* Compute the non-recursive part */ - - s1 = SO - z1 ; /* s1 = gsm_sub (*so, z1) ; */ - z1 = SO ; - - assert (s1 != MIN_WORD) ; - - /* Compute the recursive part */ - L_s2 = s1 ; - L_s2 = arith_shift_left (L_s2, 15) ; - - /* Execution of a 31 bv 16 bits multiplication */ - - msp = SASR_L (L_z2, 15) ; - lsp = L_z2 - arith_shift_left ((int32_t) msp, 15) ; /* gsm_L_sub (L_z2,(msp<<15)) ; */ - - L_s2 += GSM_MULT_R (lsp, 32735) ; - L_temp = (int32_t) msp * 32735 ; /* GSM_L_MULT (msp,32735) >> 1 ;*/ - L_z2 = GSM_L_ADD (L_temp, L_s2) ; - - /* Compute sof[k] with rounding */ - L_temp = GSM_L_ADD (L_z2, 16384) ; - - /* 4.2.3 Preemphasis */ - - msp = GSM_MULT_R (mp, -28180) ; - mp = SASR_L (L_temp, 15) ; - *so++ = GSM_ADD (mp, msp) ; - } - - S->z1 = z1 ; - S->L_z2 = L_z2 ; - S->mp = mp ; -} diff --git a/Engine/lib/libsndfile/src/GSM610/rpe.c b/Engine/lib/libsndfile/src/GSM610/rpe.c deleted file mode 100644 index d9e90f29c..000000000 --- a/Engine/lib/libsndfile/src/GSM610/rpe.c +++ /dev/null @@ -1,460 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include -#include - -#include "gsm610_priv.h" - -/* 4.2.13 .. 4.2.17 RPE ENCODING SECTION - */ - -/* 4.2.13 */ - -static void Weighting_filter ( - register int16_t * e, /* signal [-5..0.39.44] IN */ - int16_t * x /* signal [0..39] OUT */ -) -/* - * The coefficients of the weighting filter are stored in a table - * (see table 4.4). The following scaling is used: - * - * H[0..10] = integer(real_H [0..10] * 8192) ; - */ -{ - /* int16_t wt [50] ; */ - - register int32_t L_result ; - register int k /* , i */ ; - - /* Initialization of a temporary working array wt[0...49] - */ - - /* for (k = 0 ; k <= 4 ; k++) wt[k] = 0 ; - * for (k = 5 ; k <= 44 ; k++) wt[k] = *e++; - * for (k = 45 ; k <= 49 ; k++) wt[k] = 0 ; - * - * (e[-5..-1] and e[40..44] are allocated by the caller, - * are initially zero and are not written anywhere.) - */ - e -= 5 ; - - /* Compute the signal x[0..39] - */ - for (k = 0 ; k <= 39 ; k++) - { L_result = 8192 >> 1 ; - - /* for (i = 0 ; i <= 10 ; i++) { - * L_temp = GSM_L_MULT(wt[k+i], gsm_H[i]) ; - * L_result = GSM_L_ADD(L_result, L_temp) ; - * } - */ - -#undef STEP -#define STEP(i, H) (e [k + i] * (int32_t) H) - - /* Every one of these multiplications is done twice -- - * but I don't see an elegant way to optimize this. - * Do you? - */ - -#ifdef STUPID_COMPILER - L_result += STEP (0, -134) ; - L_result += STEP (1, -374) ; - /* + STEP (2, 0) */ - L_result += STEP (3, 2054) ; - L_result += STEP (4, 5741) ; - L_result += STEP (5, 8192) ; - L_result += STEP (6, 5741) ; - L_result += STEP (7, 2054) ; - /* + STEP (8, 0) */ - L_result += STEP (9, -374) ; - L_result += STEP (10, -134) ; -#else - L_result += STEP (0, -134) - + STEP (1, -374) - /* + STEP (2, 0) */ - + STEP (3, 2054) - + STEP (4, 5741) - + STEP (5, 8192) - + STEP (6, 5741) - + STEP (7, 2054) - /* + STEP (8, 0) */ - + STEP (9, -374) - + STEP (10, -134) ; -#endif - - /* L_result = GSM_L_ADD(L_result, L_result) ; (* scaling(x2) *) - * L_result = GSM_L_ADD(L_result, L_result) ; (* scaling(x4) *) - * - * x[k] = SASR(L_result, 16) ; - */ - - /* 2 adds vs. >>16 => 14, minus one shift to compensate for - * those we lost when replacing L_MULT by '*'. - */ - - L_result = SASR_L (L_result, 13) ; - x [k] = (L_result < MIN_WORD ? MIN_WORD - : (L_result > MAX_WORD ? MAX_WORD : L_result)) ; - } -} - -/* 4.2.14 */ - -static void RPE_grid_selection ( - int16_t * x, /* [0..39] IN */ - int16_t * xM, /* [0..12] OUT */ - int16_t * Mc_out /* OUT */ -) -/* - * The signal x[0..39] is used to select the RPE grid which is - * represented by Mc. - */ -{ - register int i ; - register int32_t L_result, L_temp ; - int32_t EM ; /* xxx should be L_EM? */ - int16_t Mc ; - - int32_t L_common_0_3 ; - - EM = 0 ; - Mc = 0 ; - - /* for (m = 0 ; m <= 3 ; m++) { - * L_result = 0 ; - * - * - * for (i = 0 ; i <= 12 ; i++) { - * - * temp1 = SASR_W (x[m + 3*i], 2) ; - * - * assert (temp1 != MIN_WORD) ; - * - * L_temp = GSM_L_MULT(temp1, temp1) ; - * L_result = GSM_L_ADD(L_temp, L_result) ; - * } - * - * if (L_result > EM) { - * Mc = m ; - * EM = L_result ; - * } - * } - */ - -#undef STEP -#define STEP(m, i) L_temp = SASR_W (x [m + 3 * i], 2) ; \ - L_result += L_temp * L_temp ; - - /* common part of 0 and 3 */ - - L_result = 0 ; - STEP (0, 1) ; STEP (0, 2) ; STEP (0, 3) ; STEP (0, 4) ; - STEP (0, 5) ; STEP (0, 6) ; STEP (0, 7) ; STEP (0, 8) ; - STEP (0, 9) ; STEP (0, 10) ; STEP (0, 11) ; STEP (0, 12) ; - L_common_0_3 = L_result ; - - /* i = 0 */ - - STEP (0, 0) ; - L_result <<= 1 ; /* implicit in L_MULT */ - EM = L_result ; - - /* i = 1 */ - - L_result = 0 ; - STEP (1, 0) ; - STEP (1, 1) ; STEP (1, 2) ; STEP (1, 3) ; STEP (1, 4) ; - STEP (1, 5) ; STEP (1, 6) ; STEP (1, 7) ; STEP (1, 8) ; - STEP (1, 9) ; STEP (1, 10) ; STEP (1, 11) ; STEP (1, 12) ; - L_result <<= 1 ; - if (L_result > EM) - { Mc = 1 ; - EM = L_result ; - } - - /* i = 2 */ - - L_result = 0 ; - STEP (2, 0) ; - STEP (2, 1) ; STEP (2, 2) ; STEP (2, 3) ; STEP (2, 4) ; - STEP (2, 5) ; STEP (2, 6) ; STEP (2, 7) ; STEP (2, 8) ; - STEP (2, 9) ; STEP (2, 10) ; STEP (2, 11) ; STEP (2, 12) ; - L_result <<= 1 ; - if (L_result > EM) - { Mc = 2 ; - EM = L_result ; - } - - /* i = 3 */ - - L_result = L_common_0_3 ; - STEP (3, 12) ; - L_result <<= 1 ; - if (L_result > EM) - { Mc = 3 ; - EM = L_result ; - } - - /* Down-sampling by a factor 3 to get the selected xM [0..12] - * RPE sequence. - */ - for (i = 0 ; i <= 12 ; i ++) xM [i] = x [Mc + 3 * i] ; - *Mc_out = Mc ; -} - -/* 4.12.15 */ - -static void APCM_quantization_xmaxc_to_exp_mant ( - int16_t xmaxc, /* IN */ - int16_t * expon_out, /* OUT */ - int16_t * mant_out) /* OUT */ -{ - int16_t expon, mant ; - - /* Compute expononent and mantissa of the decoded version of xmaxc - */ - - expon = 0 ; - if (xmaxc > 15) expon = SASR_W (xmaxc, 3) - 1 ; - mant = xmaxc - (expon << 3) ; - - if (mant == 0) - { expon = -4 ; - mant = 7 ; - } - else - { while (mant <= 7) - { mant = mant << 1 | 1 ; - expon-- ; - } - mant -= 8 ; - } - - assert (expon >= -4 && expon <= 6) ; - assert (mant >= 0 && mant <= 7) ; - - *expon_out = expon ; - *mant_out = mant ; -} - -static void APCM_quantization ( - int16_t * xM, /* [0..12] IN */ - int16_t * xMc, /* [0..12] OUT */ - int16_t * mant_out, /* OUT */ - int16_t * expon_out, /* OUT */ - int16_t * xmaxc_out /* OUT */ -) -{ - int i, itest ; - - int16_t xmax, xmaxc, temp, temp1, temp2 ; - int16_t expon, mant ; - - - /* Find the maximum absolute value xmax of xM [0..12]. - */ - - xmax = 0 ; - for (i = 0 ; i <= 12 ; i++) - { temp = xM [i] ; - temp = GSM_ABS (temp) ; - if (temp > xmax) xmax = temp ; - } - - /* Qantizing and coding of xmax to get xmaxc. - */ - - expon = 0 ; - temp = SASR_W (xmax, 9) ; - itest = 0 ; - - for (i = 0 ; i <= 5 ; i++) - { itest |= (temp <= 0) ; - temp = SASR_W (temp, 1) ; - - assert (expon <= 5) ; - if (itest == 0) expon++ ; /* expon = add (expon, 1) */ - } - - assert (expon <= 6 && expon >= 0) ; - temp = expon + 5 ; - - assert (temp <= 11 && temp >= 0) ; - xmaxc = gsm_add (SASR_W (xmax, temp), (int16_t) (expon << 3)) ; - - /* Quantizing and coding of the xM [0..12] RPE sequence - * to get the xMc [0..12] - */ - - APCM_quantization_xmaxc_to_exp_mant (xmaxc, &expon, &mant) ; - - /* This computation uses the fact that the decoded version of xmaxc - * can be calculated by using the expononent and the mantissa part of - * xmaxc (logarithmic table). - * So, this method avoids any division and uses only a scaling - * of the RPE samples by a function of the expononent. A direct - * multiplication by the inverse of the mantissa (NRFAC[0..7] - * found in table 4.5) gives the 3 bit coded version xMc [0..12] - * of the RPE samples. - */ - - - /* Direct computation of xMc [0..12] using table 4.5 - */ - - assert (expon <= 4096 && expon >= -4096) ; - assert (mant >= 0 && mant <= 7) ; - - temp1 = 6 - expon ; /* normalization by the expononent */ - temp2 = gsm_NRFAC [mant] ; /* inverse mantissa */ - - for (i = 0 ; i <= 12 ; i++) - { assert (temp1 >= 0 && temp1 < 16) ; - - temp = arith_shift_left (xM [i], temp1) ; - temp = GSM_MULT (temp, temp2) ; - temp = SASR_W (temp, 12) ; - xMc [i] = temp + 4 ; /* see note below */ - } - - /* NOTE: This equation is used to make all the xMc [i] positive. - */ - - *mant_out = mant ; - *expon_out = expon ; - *xmaxc_out = xmaxc ; -} - -/* 4.2.16 */ - -static void APCM_inverse_quantization ( - register int16_t * xMc, /* [0..12] IN */ - int16_t mant, - int16_t expon, - register int16_t * xMp) /* [0..12] OUT */ -/* - * This part is for decoding the RPE sequence of coded xMc [0..12] - * samples to obtain the xMp[0..12] array. Table 4.6 is used to get - * the mantissa of xmaxc (FAC[0..7]). - */ -{ - int i ; - int16_t temp, temp1, temp2, temp3 ; - - assert (mant >= 0 && mant <= 7) ; - - temp1 = gsm_FAC [mant] ; /* see 4.2-15 for mant */ - temp2 = gsm_sub (6, expon) ; /* see 4.2-15 for exp */ - temp3 = gsm_asl (1, gsm_sub (temp2, 1)) ; - - for (i = 13 ; i-- ;) - { assert (*xMc <= 7 && *xMc >= 0) ; /* 3 bit unsigned */ - - /* temp = gsm_sub (*xMc++ << 1, 7) ; */ - temp = (*xMc++ << 1) - 7 ; /* restore sign */ - assert (temp <= 7 && temp >= -7) ; /* 4 bit signed */ - - temp = arith_shift_left (temp, 12) ; /* 16 bit signed */ - temp = GSM_MULT_R (temp1, temp) ; - temp = GSM_ADD (temp, temp3) ; - *xMp++ = gsm_asr (temp, temp2) ; - } -} - -/* 4.2.17 */ - -static void RPE_grid_positioning ( - int16_t Mc, /* grid position IN */ - register int16_t * xMp, /* [0..12] IN */ - register int16_t * ep /* [0..39] OUT */ -) -/* - * This procedure computes the reconstructed long term residual signal - * ep[0..39] for the LTP analysis filter. The inputs are the Mc - * which is the grid position selection and the xMp[0..12] decoded - * RPE samples which are upsampled by a factor of 3 by inserting zero - * values. - */ -{ - int i = 13 ; - - assert (0 <= Mc && Mc <= 3) ; - - switch (Mc) - { case 3: *ep++ = 0 ; - /* Falls through. */ - case 2: do - { *ep++ = 0 ; - /* Falls through. */ - case 1: *ep++ = 0 ; - /* Falls through. */ - case 0: *ep++ = *xMp++ ; - } while (--i) ; - } - while (++Mc < 4) *ep++ = 0 ; -} - -/* 4.2.18 */ - -/* This procedure adds the reconstructed long term residual signal - * ep[0..39] to the estimated signal dpp[0..39] from the long term - * analysis filter to compute the reconstructed short term residual - * signal dp[-40..-1] ; also the reconstructed short term residual - * array dp[-120..-41] is updated. - */ - -#if 0 /* Has been inlined in code.c */ -void Gsm_Update_of_reconstructed_short_time_residual_signal ( - int16_t * dpp, /* [0...39] IN */ - int16_t * ep, /* [0...39] IN */ - int16_t * dp) /* [-120...-1] IN/OUT */ -{ - int k ; - - for (k = 0 ; k <= 79 ; k++) - dp [-120 + k] = dp [-80 + k] ; - - for (k = 0 ; k <= 39 ; k++) - dp [-40 + k] = gsm_add (ep [k], dpp [k]) ; -} -#endif /* Has been inlined in code.c */ - -void Gsm_RPE_Encoding ( - int16_t * e, /* -5..-1][0..39][40..44 IN/OUT */ - int16_t * xmaxc, /* OUT */ - int16_t * Mc, /* OUT */ - int16_t * xMc) /* [0..12] OUT */ -{ - int16_t x [40] ; - int16_t xM [13], xMp [13] ; - int16_t mant, expon ; - - Weighting_filter (e, x) ; - RPE_grid_selection (x, xM, Mc) ; - - APCM_quantization (xM, xMc, &mant, &expon, xmaxc) ; - APCM_inverse_quantization (xMc, mant, expon, xMp) ; - - RPE_grid_positioning (*Mc, xMp, e) ; - -} - -void Gsm_RPE_Decoding ( - int16_t xmaxcr, - int16_t Mcr, - int16_t * xMcr, /* [0..12], 3 bits IN */ - int16_t * erp /* [0..39] OUT */ -) -{ - int16_t expon, mant ; - int16_t xMp [13] ; - - APCM_quantization_xmaxc_to_exp_mant (xmaxcr, &expon, &mant) ; - APCM_inverse_quantization (xMcr, mant, expon, xMp) ; - RPE_grid_positioning (Mcr, xMp, erp) ; -} diff --git a/Engine/lib/libsndfile/src/GSM610/short_term.c b/Engine/lib/libsndfile/src/GSM610/short_term.c deleted file mode 100644 index e8cdac3b8..000000000 --- a/Engine/lib/libsndfile/src/GSM610/short_term.c +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -#include -#include - -#include "gsm610_priv.h" - -/* - * SHORT TERM ANALYSIS FILTERING SECTION - */ - -/* 4.2.8 */ - -static void Decoding_of_the_coded_Log_Area_Ratios ( - int16_t * LARc, /* coded log area ratio [0..7] IN */ - int16_t * LARpp) /* out: decoded .. */ -{ - register int16_t temp1 ; - - /* This procedure requires for efficient implementation - * two tables. - * - * INVA[1..8] = integer((32768 * 8) / real_A[1..8]) - * MIC[1..8] = minimum value of the LARc[1..8] - */ - - /* Compute the LARpp[1..8] - */ - - /* for (i = 1; i <= 8; i++, B++, MIC++, INVA++, LARc++, LARpp++) { - * - * temp1 = GSM_ADD (*LARc, *MIC) << 10; - * temp2 = *B << 1; - * temp1 = GSM_SUB(temp1, temp2) ; - * - * assert(*INVA != MIN_WORD) ; - * - * temp1 = GSM_MULT_R (*INVA, temp1) ; - * *LARpp = GSM_ADD (temp1, temp1) ; - * } - */ - -#undef STEP -#define STEP(B, MIC, INVA) \ - temp1 = arith_shift_left (GSM_ADD (*LARc++, MIC), 10) ; \ - temp1 = GSM_SUB (temp1, B * 2) ; \ - temp1 = GSM_MULT_R (INVA, temp1) ; \ - *LARpp++ = GSM_ADD (temp1, temp1) ; - - STEP (0, -32, 13107) ; - STEP (0, -32, 13107) ; - STEP (2048, -16, 13107) ; - STEP (-2560, -16, 13107) ; - - STEP (94, -8, 19223) ; - STEP (-1792, -8, 17476) ; - STEP (-341, -4, 31454) ; - STEP (-1144, -4, 29708) ; - - /* NOTE: the addition of *MIC is used to restore - * the sign of *LARc. - */ -} - -/* 4.2.9 */ -/* Computation of the quantized reflection coefficients - */ - -/* 4.2.9.1 Interpolation of the LARpp[1..8] to get the LARp[1..8] - */ - -/* - * Within each frame of 160 analyzed speech samples the short term - * analysis and synthesis filters operate with four different sets of - * coefficients, derived from the previous set of decoded LARs(LARpp(j-1)) - * and the actual set of decoded LARs (LARpp(j)) - * - * (Initial value: LARpp(j-1)[1..8] = 0.) - */ - -static void Coefficients_0_12 ( - register int16_t * LARpp_j_1, - register int16_t * LARpp_j, - register int16_t * LARp) -{ - register int i ; - - for (i = 1 ; i <= 8 ; i++, LARp++, LARpp_j_1++, LARpp_j++) - { *LARp = GSM_ADD (SASR_W (*LARpp_j_1, 2), SASR_W (*LARpp_j, 2)) ; - *LARp = GSM_ADD (*LARp, SASR_W (*LARpp_j_1, 1)) ; - } -} - -static void Coefficients_13_26 ( - register int16_t * LARpp_j_1, - register int16_t * LARpp_j, - register int16_t * LARp) -{ - register int i ; - for (i = 1 ; i <= 8 ; i++, LARpp_j_1++, LARpp_j++, LARp++) - *LARp = GSM_ADD (SASR_W (*LARpp_j_1, 1), SASR_W (*LARpp_j, 1)) ; -} - -static void Coefficients_27_39 ( - register int16_t * LARpp_j_1, - register int16_t * LARpp_j, - register int16_t * LARp) -{ - register int i ; - - for (i = 1 ; i <= 8 ; i++, LARpp_j_1++, LARpp_j++, LARp++) - { *LARp = GSM_ADD (SASR_W (*LARpp_j_1, 2), SASR_W (*LARpp_j, 2)) ; - *LARp = GSM_ADD (*LARp, SASR_W (*LARpp_j, 1)) ; - } -} - - -static void Coefficients_40_159 ( - register int16_t * LARpp_j, - register int16_t * LARp) -{ - register int i ; - - for (i = 1 ; i <= 8 ; i++, LARp++, LARpp_j++) - *LARp = *LARpp_j ; -} - -/* 4.2.9.2 */ - -static void LARp_to_rp ( - register int16_t * LARp) /* [0..7] IN/OUT */ -/* - * The input of this procedure is the interpolated LARp[0..7] array. - * The reflection coefficients, rp[i], are used in the analysis - * filter and in the synthesis filter. - */ -{ - register int i ; - register int16_t temp ; - - for (i = 1 ; i <= 8 ; i++, LARp++) - { /* temp = GSM_ABS(*LARp) ; - * - * if (temp < 11059) temp <<= 1; - * else if (temp < 20070) temp += 11059; - * else temp = GSM_ADD (temp >> 2, 26112) ; - * - * *LARp = *LARp < 0 ? -temp : temp; - */ - - if (*LARp < 0) - { temp = *LARp == MIN_WORD ? MAX_WORD : - (*LARp) ; - *LARp = - ((temp < 11059) ? temp << 1 - : ((temp < 20070) ? temp + 11059 - : GSM_ADD ((int16_t) (temp >> 2), (int16_t) 26112))) ; - } - else - { temp = *LARp ; - *LARp = (temp < 11059) ? temp << 1 - : ((temp < 20070) ? temp + 11059 - : GSM_ADD ((int16_t) (temp >> 2), (int16_t) 26112)) ; - } - } -} - - -/* 4.2.10 */ -static void Short_term_analysis_filtering ( - struct gsm_state * S, - register int16_t * rp, /* [0..7] IN */ - register int k_n, /* k_end - k_start */ - register int16_t * s /* [0..n-1] IN/OUT */ -) -/* - * This procedure computes the short term residual signal d[..] to be fed - * to the RPE-LTP loop from the s[..] signal and from the local rp[..] - * array (quantized reflection coefficients). As the call of this - * procedure can be done in many ways (see the interpolation of the LAR - * coefficient), it is assumed that the computation begins with index - * k_start (for arrays d[..] and s[..]) and stops with index k_end - * (k_start and k_end are defined in 4.2.9.1). This procedure also - * needs to keep the array u [0..7] in memory for each call. - */ -{ - register int16_t * u = S->u ; - register int i ; - register int16_t di, zzz, ui, sav, rpi ; - - for ( ; k_n-- ; s++) - { di = sav = *s ; - - for (i = 0 ; i < 8 ; i++) - { /* YYY */ - ui = u [i] ; - rpi = rp [i] ; - u [i] = sav ; - - zzz = GSM_MULT_R (rpi, di) ; - sav = GSM_ADD (ui, zzz) ; - - zzz = GSM_MULT_R (rpi, ui) ; - di = GSM_ADD (di, zzz) ; - } - - *s = di ; - } -} - -#if defined (USE_FLOAT_MUL) && defined (FAST) - -static void Fast_Short_term_analysis_filtering ( - struct gsm_state * S, - register int16_t * rp, /* [0..7] IN */ - register int k_n, /* k_end - k_start */ - register int16_t * s /* [0..n-1] IN/OUT */ -) -{ - register int16_t * u = S->u ; - register int i ; - - float uf [8], rpf [8] ; - - register float scalef = 3.0517578125e-5 ; - register float sav, di, temp ; - - for (i = 0 ; i < 8 ; ++i) - { uf [i] = u [i] ; - rpf [i] = rp [i] * scalef ; - } - for ( ; k_n-- ; s++) - { sav = di = *s ; - for (i = 0 ; i < 8 ; i++) - { register float rpfi = rpf [i] ; - register float ufi = uf [i] ; - - uf [i] = sav ; - temp = rpfi * di + ufi ; - di += rpfi * ufi ; - sav = temp ; - } - *s = di ; - } - for (i = 0 ; i < 8 ; i++) u [i] = uf [i] ; -} -#endif /* ! (defined (USE_FLOAT_MUL) && defined (FAST)) */ - -static void Short_term_synthesis_filtering ( - struct gsm_state * S, - register int16_t * rrp, /* [0..7] IN */ - register int k, /* k_end - k_start */ - register int16_t * wt, /* [0..k-1] IN */ - register int16_t * sr /* [0..k-1] OUT */ -) -{ - register int16_t * v = S->v ; - register int i ; - register int16_t sri, tmp1, tmp2 ; - - while (k--) - { sri = *wt++ ; - for (i = 8 ; i-- ; ) - { /* sri = GSM_SUB(sri, gsm_mult_r(rrp[i], v [i])) ; - */ - tmp1 = rrp [i] ; - tmp2 = v [i] ; - tmp2 = (tmp1 == MIN_WORD && tmp2 == MIN_WORD - ? MAX_WORD - : 0x0FFFF & (((int32_t) tmp1 * (int32_t) tmp2 - + 16384) >> 15)) ; - - sri = GSM_SUB (sri, tmp2) ; - - /* v [i+1] = GSM_ADD (v [i], gsm_mult_r(rrp[i], sri)) ; - */ - tmp1 = (tmp1 == MIN_WORD && sri == MIN_WORD - ? MAX_WORD - : 0x0FFFF & (((int32_t) tmp1 * (int32_t) sri - + 16384) >> 15)) ; - - v [i + 1] = GSM_ADD (v [i], tmp1) ; - } - *sr++ = v [0] = sri ; - } -} - - -#if defined (FAST) && defined (USE_FLOAT_MUL) - -static void Fast_Short_term_synthesis_filtering ( - struct gsm_state * S, - register int16_t * rrp, /* [0..7] IN */ - register int k, /* k_end - k_start */ - register int16_t * wt, /* [0..k-1] IN */ - register int16_t * sr /* [0..k-1] OUT */ -) -{ - register int16_t * v = S->v ; - register int i ; - - float va [9], rrpa [8] ; - register float scalef = 3.0517578125e-5, temp ; - - for (i = 0 ; i < 8 ; ++i) - { va [i] = v [i] ; - rrpa [i] = (float) rrp [i] * scalef ; - } - while (k--) { - register float sri = *wt++ ; - for (i = 8 ; i-- ; ) - { sri -= rrpa [i] * va [i] ; - if (sri < -32768.0) sri = -32768.0 ; - else if (sri > 32767.0) sri = 32767.0 ; - - temp = va [i] + rrpa [i] * sri ; - if (temp < -32768.0) temp = -32768.0 ; - else if (temp > 32767.0) temp = 32767.0 ; - va [i+1] = temp ; - } - *sr++ = va [0] = sri ; - } - for (i = 0 ; i < 9 ; ++i) v [i] = va [i] ; -} - -#endif /* defined(FAST) && defined(USE_FLOAT_MUL) */ - -void Gsm_Short_Term_Analysis_Filter ( - struct gsm_state * S, - - int16_t * LARc, /* coded log area ratio [0..7] IN */ - int16_t * s /* signal [0..159] IN/OUT */ -) -{ - int16_t * LARpp_j = S->LARpp [S->j] ; - int16_t * LARpp_j_1 = S->LARpp [S->j ^= 1] ; - - int16_t LARp [8] ; - -#undef FILTER -#if defined (FAST) && defined (USE_FLOAT_MUL) -# define FILTER (* (S->fast \ - ? Fast_Short_term_analysis_filtering \ - : Short_term_analysis_filtering)) - -#else -# define FILTER Short_term_analysis_filtering -#endif - - Decoding_of_the_coded_Log_Area_Ratios (LARc, LARpp_j) ; - - Coefficients_0_12 (LARpp_j_1, LARpp_j, LARp) ; - LARp_to_rp (LARp) ; - FILTER (S, LARp, 13, s) ; - - Coefficients_13_26 (LARpp_j_1, LARpp_j, LARp) ; - LARp_to_rp (LARp) ; - FILTER (S, LARp, 14, s + 13) ; - - Coefficients_27_39 (LARpp_j_1, LARpp_j, LARp) ; - LARp_to_rp (LARp) ; - FILTER (S, LARp, 13, s + 27) ; - - Coefficients_40_159 (LARpp_j, LARp) ; - LARp_to_rp (LARp) ; - FILTER (S, LARp, 120, s + 40) ; -} - -void Gsm_Short_Term_Synthesis_Filter ( - struct gsm_state * S, - - int16_t * LARcr, /* received log area ratios [0..7] IN */ - int16_t * wt, /* received d [0..159] IN */ - - int16_t * s /* signal s [0..159] OUT */ -) -{ - int16_t * LARpp_j = S->LARpp [S->j] ; - int16_t * LARpp_j_1 = S->LARpp [S->j ^= 1] ; - - int16_t LARp [8] ; - -#undef FILTER -#if defined (FAST) && defined (USE_FLOAT_MUL) - -# define FILTER (* (S->fast \ - ? Fast_Short_term_synthesis_filtering \ - : Short_term_synthesis_filtering)) -#else -# define FILTER Short_term_synthesis_filtering -#endif - - Decoding_of_the_coded_Log_Area_Ratios (LARcr, LARpp_j) ; - - Coefficients_0_12 (LARpp_j_1, LARpp_j, LARp) ; - LARp_to_rp (LARp) ; - FILTER (S, LARp, 13, wt, s) ; - - Coefficients_13_26 (LARpp_j_1, LARpp_j, LARp) ; - LARp_to_rp (LARp) ; - FILTER (S, LARp, 14, wt + 13, s + 13) ; - - Coefficients_27_39 (LARpp_j_1, LARpp_j, LARp) ; - LARp_to_rp (LARp) ; - FILTER (S, LARp, 13, wt + 27, s + 27) ; - - Coefficients_40_159 (LARpp_j, LARp) ; - LARp_to_rp (LARp) ; - FILTER (S, LARp, 120, wt + 40, s + 40) ; -} diff --git a/Engine/lib/libsndfile/src/GSM610/table.c b/Engine/lib/libsndfile/src/GSM610/table.c deleted file mode 100644 index 30590aff3..000000000 --- a/Engine/lib/libsndfile/src/GSM610/table.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* Most of these tables are inlined at their point of use. - */ - -/* 4.4 TABLES USED IN THE FIXED POINT IMPLEMENTATION OF THE RPE-LTP - * CODER AND DECODER - * - * (Most of them inlined, so watch out.) - */ - -#define GSM_TABLE_C -#include "gsm610_priv.h" - -/* Table 4.1 Quantization of the Log.-Area Ratios - */ -/* i 1 2 3 4 5 6 7 8 */ -int16_t gsm_A [8] = { 20480, 20480, 20480, 20480, 13964, 15360, 8534, 9036 } ; -int16_t gsm_B [8] = { 0, 0, 2048, -2560, 94, -1792, -341, -1144 } ; -int16_t gsm_MIC [8] = { -32, -32, -16, -16, -8, -8, -4, -4 } ; -int16_t gsm_MAC [8] = { 31, 31, 15, 15, 7, 7, 3, 3 } ; - - -/* Table 4.2 Tabulation of 1/A[1..8] - */ -int16_t gsm_INVA [8] = { 13107, 13107, 13107, 13107, 19223, 17476, 31454, 29708 } ; - - -/* Table 4.3a Decision level of the LTP gain quantizer - */ -/* bc 0 1 2 3 */ -int16_t gsm_DLB [4] = { 6554, 16384, 26214, 32767 } ; - - -/* Table 4.3b Quantization levels of the LTP gain quantizer - */ -/* bc 0 1 2 3 */ -int16_t gsm_QLB [4] = { 3277, 11469, 21299, 32767 } ; - - -/* Table 4.4 Coefficients of the weighting filter - */ -/* i 0 1 2 3 4 5 6 7 8 9 10 */ -int16_t gsm_H [11] = { -134, -374, 0, 2054, 5741, 8192, 5741, 2054, 0, -374, -134 } ; - - -/* Table 4.5 Normalized inverse mantissa used to compute xM/xmax - */ -/* i 0 1 2 3 4 5 6 7 */ -int16_t gsm_NRFAC [8] = { 29128, 26215, 23832, 21846, 20165, 18725, 17476, 16384 } ; - - -/* Table 4.6 Normalized direct mantissa used to compute xM/xmax - */ -/* i 0 1 2 3 4 5 6 7 */ -int16_t gsm_FAC [8] = { 18431, 20479, 22527, 24575, 26623, 28671, 30719, 32767 } ; diff --git a/Engine/lib/libsndfile/src/aiff.c b/Engine/lib/libsndfile/src/aiff.c deleted file mode 100644 index a2bda8f4f..000000000 --- a/Engine/lib/libsndfile/src/aiff.c +++ /dev/null @@ -1,1851 +0,0 @@ -/* -** Copyright (C) 1999-2018 Erik de Castro Lopo -** Copyright (C) 2005 David Viens -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "chanmap.h" - -/*------------------------------------------------------------------------------ - * Macros to handle big/little endian issues. - */ - -#define FORM_MARKER (MAKE_MARKER ('F', 'O', 'R', 'M')) -#define AIFF_MARKER (MAKE_MARKER ('A', 'I', 'F', 'F')) -#define AIFC_MARKER (MAKE_MARKER ('A', 'I', 'F', 'C')) -#define COMM_MARKER (MAKE_MARKER ('C', 'O', 'M', 'M')) -#define SSND_MARKER (MAKE_MARKER ('S', 'S', 'N', 'D')) -#define MARK_MARKER (MAKE_MARKER ('M', 'A', 'R', 'K')) -#define INST_MARKER (MAKE_MARKER ('I', 'N', 'S', 'T')) -#define APPL_MARKER (MAKE_MARKER ('A', 'P', 'P', 'L')) -#define CHAN_MARKER (MAKE_MARKER ('C', 'H', 'A', 'N')) - -#define c_MARKER (MAKE_MARKER ('(', 'c', ')', ' ')) -#define NAME_MARKER (MAKE_MARKER ('N', 'A', 'M', 'E')) -#define AUTH_MARKER (MAKE_MARKER ('A', 'U', 'T', 'H')) -#define ANNO_MARKER (MAKE_MARKER ('A', 'N', 'N', 'O')) -#define COMT_MARKER (MAKE_MARKER ('C', 'O', 'M', 'T')) -#define FVER_MARKER (MAKE_MARKER ('F', 'V', 'E', 'R')) -#define SFX_MARKER (MAKE_MARKER ('S', 'F', 'X', '!')) - -#define PEAK_MARKER (MAKE_MARKER ('P', 'E', 'A', 'K')) -#define basc_MARKER (MAKE_MARKER ('b', 'a', 's', 'c')) - -/* Supported AIFC encodings.*/ -#define NONE_MARKER (MAKE_MARKER ('N', 'O', 'N', 'E')) -#define sowt_MARKER (MAKE_MARKER ('s', 'o', 'w', 't')) -#define twos_MARKER (MAKE_MARKER ('t', 'w', 'o', 's')) -#define raw_MARKER (MAKE_MARKER ('r', 'a', 'w', ' ')) -#define in24_MARKER (MAKE_MARKER ('i', 'n', '2', '4')) -#define ni24_MARKER (MAKE_MARKER ('4', '2', 'n', '1')) -#define in32_MARKER (MAKE_MARKER ('i', 'n', '3', '2')) -#define ni32_MARKER (MAKE_MARKER ('2', '3', 'n', 'i')) - -#define fl32_MARKER (MAKE_MARKER ('f', 'l', '3', '2')) -#define FL32_MARKER (MAKE_MARKER ('F', 'L', '3', '2')) -#define fl64_MARKER (MAKE_MARKER ('f', 'l', '6', '4')) -#define FL64_MARKER (MAKE_MARKER ('F', 'L', '6', '4')) - -#define ulaw_MARKER (MAKE_MARKER ('u', 'l', 'a', 'w')) -#define ULAW_MARKER (MAKE_MARKER ('U', 'L', 'A', 'W')) -#define alaw_MARKER (MAKE_MARKER ('a', 'l', 'a', 'w')) -#define ALAW_MARKER (MAKE_MARKER ('A', 'L', 'A', 'W')) - -#define DWVW_MARKER (MAKE_MARKER ('D', 'W', 'V', 'W')) -#define GSM_MARKER (MAKE_MARKER ('G', 'S', 'M', ' ')) -#define ima4_MARKER (MAKE_MARKER ('i', 'm', 'a', '4')) - -/* -** This value is officially assigned to Mega Nerd Pty Ltd by Apple -** Corportation as the Application marker for libsndfile. -** -** See : http://developer.apple.com/faq/datatype.html -*/ -#define m3ga_MARKER (MAKE_MARKER ('m', '3', 'g', 'a')) - -/* Unsupported AIFC encodings.*/ - -#define MAC3_MARKER (MAKE_MARKER ('M', 'A', 'C', '3')) -#define MAC6_MARKER (MAKE_MARKER ('M', 'A', 'C', '6')) -#define ADP4_MARKER (MAKE_MARKER ('A', 'D', 'P', '4')) - -/* Predfined chunk sizes. */ -#define SIZEOF_AIFF_COMM 18 -#define SIZEOF_AIFC_COMM_MIN 22 -#define SIZEOF_AIFC_COMM 24 -#define SIZEOF_SSND_CHUNK 8 -#define SIZEOF_INST_CHUNK 20 - -/* Is it constant? */ - -/* AIFC/IMA4 defines. */ -#define AIFC_IMA4_BLOCK_LEN 34 -#define AIFC_IMA4_SAMPLES_PER_BLOCK 64 - -#define AIFF_PEAK_CHUNK_SIZE(ch) (2 * sizeof (int) + ch * (sizeof (float) + sizeof (int))) - -/*------------------------------------------------------------------------------ - * Typedefs for file chunks. - */ - -enum -{ HAVE_FORM = 0x01, - HAVE_AIFF = 0x02, - HAVE_AIFC = 0x04, - HAVE_FVER = 0x08, - HAVE_COMM = 0x10, - HAVE_SSND = 0x20 -} ; - -typedef struct -{ uint32_t size ; - int16_t numChannels ; - uint32_t numSampleFrames ; - int16_t sampleSize ; - uint8_t sampleRate [10] ; - uint32_t encoding ; - char zero_bytes [2] ; -} COMM_CHUNK ; - -typedef struct -{ uint32_t offset ; - uint32_t blocksize ; -} SSND_CHUNK ; - -typedef struct -{ int16_t playMode ; - uint16_t beginLoop ; - uint16_t endLoop ; -} INST_LOOP ; - -typedef struct -{ int8_t baseNote ; /* all notes are MIDI note numbers */ - int8_t detune ; /* cents off, only -50 to +50 are significant */ - int8_t lowNote ; - int8_t highNote ; - int8_t lowVelocity ; /* 1 to 127 */ - int8_t highVelocity ; /* 1 to 127 */ - int16_t gain ; /* in dB, 0 is normal */ - INST_LOOP sustain_loop ; - INST_LOOP release_loop ; -} INST_CHUNK ; - - -enum -{ basc_SCALE_MINOR = 1, - basc_SCALE_MAJOR, - basc_SCALE_NEITHER, - basc_SCALE_BOTH -} ; - -enum -{ basc_TYPE_LOOP = 0, - basc_TYPE_ONE_SHOT -} ; - - -typedef struct -{ uint32_t version ; - uint32_t numBeats ; - uint16_t rootNote ; - uint16_t scaleType ; - uint16_t sigNumerator ; - uint16_t sigDenominator ; - uint16_t loopType ; -} basc_CHUNK ; - -typedef struct -{ uint16_t markerID ; - uint32_t position ; -} MARK_ID_POS ; - -typedef struct -{ sf_count_t comm_offset ; - sf_count_t ssnd_offset ; - - int32_t chanmap_tag ; - - MARK_ID_POS *markstr ; -} AIFF_PRIVATE ; - -/*------------------------------------------------------------------------------ - * Private static functions. - */ - -static int aiff_close (SF_PRIVATE *psf) ; - -static int tenbytefloat2int (uint8_t *bytes) ; -static void uint2tenbytefloat (uint32_t num, uint8_t *bytes) ; - -static int aiff_read_comm_chunk (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) ; - -static int aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) ; - -static int aiff_write_header (SF_PRIVATE *psf, int calc_length) ; -static int aiff_write_tailer (SF_PRIVATE *psf) ; -static void aiff_write_strings (SF_PRIVATE *psf, int location) ; - -static int aiff_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; - -static const char *get_loop_mode_str (int16_t mode) ; - -static int16_t get_loop_mode (int16_t mode) ; - -static int aiff_read_basc_chunk (SF_PRIVATE * psf, int) ; - -static int aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword) ; - -static uint32_t marker_to_position (const MARK_ID_POS *m, uint16_t n, int marksize) ; - -static int aiff_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) ; -static SF_CHUNK_ITERATOR * aiff_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) ; -static int aiff_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; -static int aiff_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -aiff_open (SF_PRIVATE *psf) -{ COMM_CHUNK comm_fmt ; - int error = 0, subformat ; - - memset (&comm_fmt, 0, sizeof (comm_fmt)) ; - - subformat = SF_CODEC (psf->sf.format) ; - - if ((psf->container_data = calloc (1, sizeof (AIFF_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - - psf->container_close = aiff_close ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = aiff_read_header (psf, &comm_fmt))) - return error ; - - psf->next_chunk_iterator = aiff_next_chunk_iterator ; - psf->get_chunk_size = aiff_get_chunk_size ; - psf->get_chunk_data = aiff_get_chunk_data ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (psf->is_pipe) - return SFE_NO_PIPE_WRITE ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AIFF) - return SFE_BAD_OPEN_FORMAT ; - - if (psf->file.mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)) - { if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL) - return SFE_MALLOC_FAILED ; - psf->peak_info->peak_loc = SF_PEAK_START ; - } ; - - if (psf->file.mode != SFM_RDWR || psf->filelength < 40) - { psf->filelength = 0 ; - psf->datalength = 0 ; - psf->dataoffset = 0 ; - psf->sf.frames = 0 ; - } ; - - psf->strings.flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ; - - if ((error = aiff_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = aiff_write_header ; - psf->set_chunk = aiff_set_chunk ; - } ; - - psf->command = aiff_command ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_U8 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_PCM_S8 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_ULAW : - error = ulaw_init (psf) ; - break ; - - case SF_FORMAT_ALAW : - error = alaw_init (psf) ; - break ; - - /* Lite remove start */ - case SF_FORMAT_FLOAT : - error = float32_init (psf) ; - break ; - - case SF_FORMAT_DOUBLE : - error = double64_init (psf) ; - break ; - - case SF_FORMAT_DWVW_12 : - if (psf->sf.frames > comm_fmt.numSampleFrames) - psf->sf.frames = comm_fmt.numSampleFrames ; - break ; - - case SF_FORMAT_DWVW_16 : - error = dwvw_init (psf, 16) ; - if (psf->sf.frames > comm_fmt.numSampleFrames) - psf->sf.frames = comm_fmt.numSampleFrames ; - break ; - - case SF_FORMAT_DWVW_24 : - error = dwvw_init (psf, 24) ; - if (psf->sf.frames > comm_fmt.numSampleFrames) - psf->sf.frames = comm_fmt.numSampleFrames ; - break ; - - case SF_FORMAT_DWVW_N : - if (psf->file.mode != SFM_READ) - { error = SFE_DWVW_BAD_BITWIDTH ; - break ; - } ; - if (comm_fmt.sampleSize >= 8 && comm_fmt.sampleSize < 24) - { error = dwvw_init (psf, comm_fmt.sampleSize) ; - if (psf->sf.frames > comm_fmt.numSampleFrames) - psf->sf.frames = comm_fmt.numSampleFrames ; - break ; - } ; - psf_log_printf (psf, "AIFC/DWVW : Bad bitwidth %d\n", comm_fmt.sampleSize) ; - error = SFE_DWVW_BAD_BITWIDTH ; - break ; - - case SF_FORMAT_IMA_ADPCM : - /* - ** IMA ADPCM encoded AIFF files always have a block length - ** of 34 which decodes to 64 samples. - */ - error = aiff_ima_init (psf, AIFC_IMA4_BLOCK_LEN, AIFC_IMA4_SAMPLES_PER_BLOCK) ; - break ; - /* Lite remove end */ - - case SF_FORMAT_GSM610 : - error = gsm610_init (psf) ; - if (psf->sf.frames > comm_fmt.numSampleFrames) - psf->sf.frames = comm_fmt.numSampleFrames ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - if (psf->file.mode != SFM_WRITE && psf->sf.frames - comm_fmt.numSampleFrames != 0) - { psf_log_printf (psf, - "*** Frame count read from 'COMM' chunk (%u) not equal to frame count\n" - "*** calculated from length of 'SSND' chunk (%u).\n", - comm_fmt.numSampleFrames, (uint32_t) psf->sf.frames) ; - } ; - - return error ; -} /* aiff_open */ - -/*========================================================================================== -** Private functions. -*/ - -/* This function ought to check size */ -static uint32_t -marker_to_position (const MARK_ID_POS *m, uint16_t n, int marksize) -{ int i ; - - for (i = 0 ; i < marksize ; i++) - if (m [i].markerID == n) - return m [i].position ; - return 0 ; -} /* marker_to_position */ - -static int -aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) -{ SSND_CHUNK ssnd_fmt ; - AIFF_PRIVATE *paiff ; - BUF_UNION ubuf ; - uint32_t chunk_size = 0, FORMsize, SSNDsize, bytesread, mark_count = 0 ; - int k, found_chunk = 0, done = 0, error = 0 ; - char *cptr ; - int instr_found = 0, mark_found = 0 ; - - if (psf->filelength > 0xFFFFFFFFLL) - psf_log_printf (psf, "Warning : filelength > 0xffffffff. This is bad!!!!\n") ; - - if ((paiff = psf->container_data) == NULL) - return SFE_INTERNAL ; - - paiff->comm_offset = 0 ; - paiff->ssnd_offset = 0 ; - - /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "p", 0) ; - - memset (comm_fmt, 0, sizeof (COMM_CHUNK)) ; - - /* Until recently AIF* file were all BIG endian. */ - psf->endian = SF_ENDIAN_BIG ; - - /* AIFF files can apparently have their chunks in any order. However, they - ** must have a FORM chunk. Approach here is to read all the chunks one by - ** one and then check for the mandatory chunks at the end. - */ - while (! done) - { unsigned marker ; - size_t jump = chunk_size & 1 ; - - marker = chunk_size = 0 ; - psf_binheader_readf (psf, "Ejm4", jump, &marker, &chunk_size) ; - if (marker == 0) - { sf_count_t pos = psf_ftell (psf) ; - psf_log_printf (psf, "Have 0 marker at position %D (0x%x).\n", pos, pos) ; - break ; - } ; - - if (psf->file.mode == SFM_RDWR && (found_chunk & HAVE_SSND)) - return SFE_AIFF_RW_SSND_NOT_LAST ; - - psf_store_read_chunk_u32 (&psf->rchunks, marker, psf_ftell (psf), chunk_size) ; - - switch (marker) - { case FORM_MARKER : - if (found_chunk) - return SFE_AIFF_NO_FORM ; - - FORMsize = chunk_size ; - - found_chunk |= HAVE_FORM ; - psf_binheader_readf (psf, "m", &marker) ; - switch (marker) - { case AIFC_MARKER : - case AIFF_MARKER : - found_chunk |= (marker == AIFC_MARKER) ? (HAVE_AIFC | HAVE_AIFF) : HAVE_AIFF ; - break ; - default : - break ; - } ; - - if (psf->fileoffset > 0 && psf->filelength > FORMsize + 8) - { /* Set file length. */ - psf->filelength = FORMsize + 8 ; - psf_log_printf (psf, "FORM : %u\n %M\n", FORMsize, marker) ; - } - else if (FORMsize != psf->filelength - 2 * SIGNED_SIZEOF (chunk_size)) - { chunk_size = psf->filelength - 2 * sizeof (chunk_size) ; - psf_log_printf (psf, "FORM : %u (should be %u)\n %M\n", FORMsize, chunk_size, marker) ; - FORMsize = chunk_size ; - } - else - psf_log_printf (psf, "FORM : %u\n %M\n", FORMsize, marker) ; - /* Set this to 0, so we don't jump a byte when parsing the next marker. */ - chunk_size = 0 ; - break ; - - - case COMM_MARKER : - paiff->comm_offset = psf_ftell (psf) - 8 ; - chunk_size += chunk_size & 1 ; - comm_fmt->size = chunk_size ; - if ((error = aiff_read_comm_chunk (psf, comm_fmt)) != 0) - return error ; - - found_chunk |= HAVE_COMM ; - break ; - - case PEAK_MARKER : - /* Must have COMM chunk before PEAK chunk. */ - if ((found_chunk & (HAVE_FORM | HAVE_AIFF | HAVE_COMM)) != (HAVE_FORM | HAVE_AIFF | HAVE_COMM)) - return SFE_AIFF_PEAK_B4_COMM ; - - psf_log_printf (psf, "%M : %d\n", marker, chunk_size) ; - if (chunk_size != AIFF_PEAK_CHUNK_SIZE (psf->sf.channels)) - { psf_binheader_readf (psf, "j", chunk_size) ; - psf_log_printf (psf, "*** File PEAK chunk too big.\n") ; - return SFE_WAV_BAD_PEAK ; - } ; - - if (psf->peak_info) - { psf_log_printf (psf, "*** Found existing peak info, using last one.\n") ; - free (psf->peak_info) ; - psf->peak_info = NULL ; - } ; - if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL) - return SFE_MALLOC_FAILED ; - - /* Read in rest of PEAK chunk. */ - psf_binheader_readf (psf, "E44", &(psf->peak_info->version), &(psf->peak_info->timestamp)) ; - - if (psf->peak_info->version != 1) - psf_log_printf (psf, " version : %d *** (should be version 1)\n", psf->peak_info->version) ; - else - psf_log_printf (psf, " version : %d\n", psf->peak_info->version) ; - - psf_log_printf (psf, " time stamp : %d\n", psf->peak_info->timestamp) ; - psf_log_printf (psf, " Ch Position Value\n") ; - - cptr = ubuf.cbuf ; - for (k = 0 ; k < psf->sf.channels ; k++) - { float value ; - uint32_t position ; - - psf_binheader_readf (psf, "Ef4", &value, &position) ; - psf->peak_info->peaks [k].value = value ; - psf->peak_info->peaks [k].position = position ; - - snprintf (cptr, sizeof (ubuf.scbuf), " %2d %-12" PRId64 " %g\n", - k, psf->peak_info->peaks [k].position, psf->peak_info->peaks [k].value) ; - cptr [sizeof (ubuf.scbuf) - 1] = 0 ; - psf_log_printf (psf, "%s", cptr) ; - } ; - - psf->peak_info->peak_loc = ((found_chunk & HAVE_SSND) == 0) ? SF_PEAK_START : SF_PEAK_END ; - break ; - - case SSND_MARKER : - if ((found_chunk & HAVE_AIFC) && (found_chunk & HAVE_FVER) == 0) - psf_log_printf (psf, "*** Valid AIFC files should have an FVER chunk.\n") ; - - paiff->ssnd_offset = psf_ftell (psf) - 8 ; - SSNDsize = chunk_size ; - psf_binheader_readf (psf, "E44", &(ssnd_fmt.offset), &(ssnd_fmt.blocksize)) ; - - psf->datalength = SSNDsize - sizeof (ssnd_fmt) ; - psf->dataoffset = psf_ftell (psf) ; - - if (psf->datalength > psf->filelength - psf->dataoffset || psf->datalength < 0) - { psf_log_printf (psf, " SSND : %u (should be %D)\n", SSNDsize, psf->filelength - psf->dataoffset + sizeof (SSND_CHUNK)) ; - psf->datalength = psf->filelength - psf->dataoffset ; - } - else - psf_log_printf (psf, " SSND : %u\n", SSNDsize) ; - - if (ssnd_fmt.offset == 0 || psf->dataoffset + ssnd_fmt.offset == ssnd_fmt.blocksize) - { psf_log_printf (psf, " Offset : %u\n", ssnd_fmt.offset) ; - psf_log_printf (psf, " Block Size : %u\n", ssnd_fmt.blocksize) ; - - psf->dataoffset += ssnd_fmt.offset ; - psf->datalength -= ssnd_fmt.offset ; - } - else - { psf_log_printf (psf, " Offset : %u\n", ssnd_fmt.offset) ; - psf_log_printf (psf, " Block Size : %u ???\n", ssnd_fmt.blocksize) ; - psf->dataoffset += ssnd_fmt.offset ; - psf->datalength -= ssnd_fmt.offset ; - } ; - - /* Only set dataend if there really is data at the end. */ - if (psf->datalength + psf->dataoffset < psf->filelength) - psf->dataend = psf->datalength + psf->dataoffset ; - - found_chunk |= HAVE_SSND ; - - if (! psf->sf.seekable) - break ; - - /* Seek to end of SSND chunk. */ - psf_fseek (psf, psf->dataoffset + psf->datalength, SEEK_SET) ; - break ; - - case c_MARKER : - if (chunk_size == 0) - break ; - if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf)) - { psf_log_printf (psf, " %M : %d (too big)\n", marker, chunk_size) ; - return SFE_INTERNAL ; - } ; - - cptr = ubuf.cbuf ; - psf_binheader_readf (psf, "b", cptr, chunk_size + (chunk_size & 1)) ; - cptr [chunk_size] = 0 ; - - psf_sanitize_string (cptr, chunk_size) ; - - psf_log_printf (psf, " %M : %s\n", marker, cptr) ; - psf_store_string (psf, SF_STR_COPYRIGHT, cptr) ; - chunk_size += chunk_size & 1 ; - break ; - - case AUTH_MARKER : - if (chunk_size == 0) - break ; - if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf) - 1) - { psf_log_printf (psf, " %M : %d (too big)\n", marker, chunk_size) ; - return SFE_INTERNAL ; - } ; - - cptr = ubuf.cbuf ; - psf_binheader_readf (psf, "b", cptr, chunk_size + (chunk_size & 1)) ; - cptr [chunk_size] = 0 ; - psf_log_printf (psf, " %M : %s\n", marker, cptr) ; - psf_store_string (psf, SF_STR_ARTIST, cptr) ; - chunk_size += chunk_size & 1 ; - break ; - - case COMT_MARKER : - { uint16_t count, id, len ; - uint32_t timestamp, bytes ; - - if (chunk_size == 0) - break ; - bytes = chunk_size ; - bytes -= psf_binheader_readf (psf, "E2", &count) ; - psf_log_printf (psf, " %M : %d\n count : %d\n", marker, chunk_size, count) ; - - for (k = 0 ; k < count ; k++) - { bytes -= psf_binheader_readf (psf, "E422", ×tamp, &id, &len) ; - psf_log_printf (psf, " time : 0x%x\n marker : %x\n length : %d\n", timestamp, id, len) ; - - if (len + 1 > SIGNED_SIZEOF (ubuf.scbuf)) - { psf_log_printf (psf, "\nError : string length (%d) too big.\n", len) ; - return SFE_INTERNAL ; - } ; - - cptr = ubuf.cbuf ; - bytes -= psf_binheader_readf (psf, "b", cptr, len) ; - cptr [len] = 0 ; - psf_log_printf (psf, " string : %s\n", cptr) ; - } ; - - if (bytes > 0) - psf_binheader_readf (psf, "j", bytes) ; - } ; - break ; - - case APPL_MARKER : - { unsigned appl_marker ; - - if (chunk_size == 0) - break ; - if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf) - 1) - { psf_log_printf (psf, " %M : %u (too big, skipping)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size + (chunk_size & 1)) ; - break ; - } ; - - if (chunk_size < 4) - { psf_log_printf (psf, " %M : %d (too small, skipping)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size + (chunk_size & 1)) ; - break ; - } ; - - cptr = ubuf.cbuf ; - psf_binheader_readf (psf, "mb", &appl_marker, cptr, chunk_size + (chunk_size & 1) - 4) ; - cptr [chunk_size] = 0 ; - - for (k = 0 ; k < (int) chunk_size ; k++) - if (! psf_isprint (cptr [k])) - { cptr [k] = 0 ; - break ; - } ; - - psf_log_printf (psf, " %M : %d\n AppSig : %M\n Name : %s\n", marker, chunk_size, appl_marker, cptr) ; - psf_store_string (psf, SF_STR_SOFTWARE, cptr) ; - chunk_size += chunk_size & 1 ; - } ; - break ; - - case NAME_MARKER : - if (chunk_size == 0) - break ; - if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf) - 2) - { psf_log_printf (psf, " %M : %d (too big)\n", marker, chunk_size) ; - return SFE_INTERNAL ; - } ; - - cptr = ubuf.cbuf ; - psf_binheader_readf (psf, "b", cptr, chunk_size + (chunk_size & 1)) ; - cptr [chunk_size] = 0 ; - psf_log_printf (psf, " %M : %s\n", marker, cptr) ; - psf_store_string (psf, SF_STR_TITLE, cptr) ; - chunk_size += chunk_size & 1 ; - break ; - - case ANNO_MARKER : - if (chunk_size == 0) - break ; - if (chunk_size >= SIGNED_SIZEOF (ubuf.scbuf) - 2) - { psf_log_printf (psf, " %M : %d (too big)\n", marker, chunk_size) ; - return SFE_INTERNAL ; - } ; - - cptr = ubuf.cbuf ; - psf_binheader_readf (psf, "b", cptr, chunk_size + (chunk_size & 1)) ; - cptr [chunk_size] = 0 ; - psf_log_printf (psf, " %M : %s\n", marker, cptr) ; - psf_store_string (psf, SF_STR_COMMENT, cptr) ; - chunk_size += chunk_size & 1 ; - break ; - - case INST_MARKER : - if (chunk_size != SIZEOF_INST_CHUNK) - { psf_log_printf (psf, " %M : %d (should be %d)\n", marker, chunk_size, SIZEOF_INST_CHUNK) ; - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - } ; - psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; - { uint8_t bytes [6] ; - int16_t gain ; - - if (psf->instrument == NULL && (psf->instrument = psf_instrument_alloc ()) == NULL) - return SFE_MALLOC_FAILED ; - - psf_binheader_readf (psf, "b", bytes, 6) ; - psf_log_printf (psf, " Base Note : %u\n Detune : %u\n" - " Low Note : %u\n High Note : %u\n" - " Low Vel. : %u\n High Vel. : %u\n", - bytes [0], bytes [1], bytes [2], bytes [3], bytes [4], bytes [5]) ; - psf->instrument->basenote = bytes [0] ; - psf->instrument->detune = bytes [1] ; - psf->instrument->key_lo = bytes [2] ; - psf->instrument->key_hi = bytes [3] ; - psf->instrument->velocity_lo = bytes [4] ; - psf->instrument->velocity_hi = bytes [5] ; - psf_binheader_readf (psf, "E2", &gain) ; - psf->instrument->gain = gain ; - psf_log_printf (psf, " Gain (dB) : %d\n", gain) ; - } ; - { int16_t mode ; /* 0 - no loop, 1 - forward looping, 2 - backward looping */ - const char *loop_mode ; - uint16_t begin, end ; - - psf_binheader_readf (psf, "E222", &mode, &begin, &end) ; - loop_mode = get_loop_mode_str (mode) ; - mode = get_loop_mode (mode) ; - if (mode == SF_LOOP_NONE) - { psf->instrument->loop_count = 0 ; - psf->instrument->loops [0].mode = SF_LOOP_NONE ; - } - else - { psf->instrument->loop_count = 1 ; - psf->instrument->loops [0].mode = SF_LOOP_FORWARD ; - psf->instrument->loops [0].start = begin ; - psf->instrument->loops [0].end = end ; - psf->instrument->loops [0].count = 0 ; - } ; - psf_log_printf (psf, " Sustain\n mode : %d => %s\n begin : %u\n end : %u\n", - mode, loop_mode, begin, end) ; - psf_binheader_readf (psf, "E222", &mode, &begin, &end) ; - loop_mode = get_loop_mode_str (mode) ; - mode = get_loop_mode (mode) ; - if (mode == SF_LOOP_NONE) - psf->instrument->loops [1].mode = SF_LOOP_NONE ; - else - { psf->instrument->loop_count += 1 ; - psf->instrument->loops [1].mode = SF_LOOP_FORWARD ; - psf->instrument->loops [1].start = begin ; - psf->instrument->loops [1].end = end ; - psf->instrument->loops [1].count = 0 ; - } ; - psf_log_printf (psf, " Release\n mode : %d => %s\n begin : %u\n end : %u\n", - mode, loop_mode, begin, end) ; - } ; - instr_found++ ; - break ; - - case basc_MARKER : - psf_log_printf (psf, " basc : %u\n", chunk_size) ; - - if ((error = aiff_read_basc_chunk (psf, chunk_size))) - return error ; - break ; - - case MARK_MARKER : - psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; - { uint16_t mark_id, n = 0 ; - uint32_t position ; - - bytesread = psf_binheader_readf (psf, "E2", &n) ; - mark_count = n ; - psf_log_printf (psf, " Count : %u\n", mark_count) ; - if (paiff->markstr != NULL) - { psf_log_printf (psf, "*** Second MARK chunk found. Throwing away the first.\n") ; - free (paiff->markstr) ; - } ; - paiff->markstr = calloc (mark_count, sizeof (MARK_ID_POS)) ; - if (paiff->markstr == NULL) - return SFE_MALLOC_FAILED ; - - if (mark_count > 2500) /* 2500 is close to the largest number of cues possible because of block sizes */ - { psf_log_printf (psf, " More than 2500 markers, skipping!\n") ; - psf_binheader_readf (psf, "j", chunk_size - bytesread) ; - break ; - } ; - - if (psf->cues) - { free (psf->cues) ; - psf->cues = NULL ; - } ; - if ((psf->cues = psf_cues_alloc (mark_count)) == NULL) - return SFE_MALLOC_FAILED ; - - for (n = 0 ; n < mark_count && bytesread < chunk_size ; n++) - { uint32_t pstr_len ; - uint8_t ch ; - - bytesread += psf_binheader_readf (psf, "E241", &mark_id, &position, &ch) ; - psf_log_printf (psf, " Mark ID : %u\n Position : %u\n", mark_id, position) ; - - psf->cues->cue_points [n].indx = mark_id ; - psf->cues->cue_points [n].position = 0 ; - psf->cues->cue_points [n].fcc_chunk = MAKE_MARKER ('d', 'a', 't', 'a') ; /* always data */ - psf->cues->cue_points [n].chunk_start = 0 ; - psf->cues->cue_points [n].block_start = 0 ; - psf->cues->cue_points [n].sample_offset = position ; - - pstr_len = (ch & 1) ? ch : ch + 1 ; - - if (pstr_len < sizeof (ubuf.scbuf) - 1) - { bytesread += psf_binheader_readf (psf, "b", ubuf.scbuf, pstr_len) ; - ubuf.scbuf [pstr_len] = 0 ; - } - else - { uint32_t read_len = pstr_len - (sizeof (ubuf.scbuf) - 1) ; - bytesread += psf_binheader_readf (psf, "bj", ubuf.scbuf, read_len, pstr_len - read_len) ; - ubuf.scbuf [sizeof (ubuf.scbuf) - 1] = 0 ; - } - - psf_log_printf (psf, " Name : %s\n", ubuf.scbuf) ; - - psf_strlcpy (psf->cues->cue_points [n].name, sizeof (psf->cues->cue_points [n].name), ubuf.cbuf) ; - - paiff->markstr [n].markerID = mark_id ; - paiff->markstr [n].position = position ; - /* - ** TODO if ubuf.scbuf is equal to - ** either Beg_loop, Beg loop or beg loop and spam - ** if (psf->instrument == NULL && (psf->instrument = psf_instrument_alloc ()) == NULL) - ** return SFE_MALLOC_FAILED ; - */ - } ; - } ; - mark_found++ ; - psf_binheader_readf (psf, "j", chunk_size - bytesread) ; - break ; - - case FVER_MARKER : - found_chunk |= HAVE_FVER ; - /* Falls through. */ - - case SFX_MARKER : - psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - - case NONE_MARKER : - /* Fix for broken AIFC files with incorrect COMM chunk length. */ - chunk_size = (chunk_size >> 24) - 3 ; - psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", make_size_t (chunk_size)) ; - break ; - - case CHAN_MARKER : - if (chunk_size < 12) - { psf_log_printf (psf, " %M : %d (should be >= 12)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - } - - psf_log_printf (psf, " %M : %d\n", marker, chunk_size) ; - - if ((error = aiff_read_chanmap (psf, chunk_size))) - return error ; - break ; - - default : - if (chunk_size >= 0xffff0000) - { done = SF_TRUE ; - psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D with length %u. Exiting parser.\n", marker, psf_ftell (psf) - 8, chunk_size) ; - break ; - } ; - - if (psf_isprint ((marker >> 24) & 0xFF) && psf_isprint ((marker >> 16) & 0xFF) - && psf_isprint ((marker >> 8) & 0xFF) && psf_isprint (marker & 0xFF)) - { psf_log_printf (psf, " %M : %u (unknown marker)\n", marker, chunk_size) ; - - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - } ; - - if (psf_ftell (psf) & 0x03) - { psf_log_printf (psf, " Unknown chunk marker at position %D. Resynching.\n", psf_ftell (psf) - 8) ; - psf_binheader_readf (psf, "j", -3) ; - break ; - } ; - psf_log_printf (psf, "*** Unknown chunk marker %X at position %D. Exiting parser.\n", marker, psf_ftell (psf)) ; - done = SF_TRUE ; - break ; - } ; /* switch (marker) */ - - if (chunk_size >= psf->filelength) - { psf_log_printf (psf, "*** Chunk size %u > file length %D. Exiting parser.\n", chunk_size, psf->filelength) ; - break ; - } ; - - if ((! psf->sf.seekable) && (found_chunk & HAVE_SSND)) - break ; - - if (psf_ftell (psf) >= psf->filelength - (2 * SIGNED_SIZEOF (int32_t))) - break ; - } ; /* while (1) */ - - if (instr_found && mark_found) - { int ji, str_index ; - /* Next loop will convert markers to loop positions for internal handling */ - for (ji = 0 ; ji < psf->instrument->loop_count ; ji ++) - { if (ji < ARRAY_LEN (psf->instrument->loops)) - { psf->instrument->loops [ji].start = marker_to_position (paiff->markstr, psf->instrument->loops [ji].start, mark_count) ; - psf->instrument->loops [ji].end = marker_to_position (paiff->markstr, psf->instrument->loops [ji].end, mark_count) ; - psf->instrument->loops [ji].mode = SF_LOOP_FORWARD ; - } ; - } ; - - /* The markers that correspond to loop positions can now be removed from cues struct */ - if (psf->cues->cue_count > (uint32_t) (psf->instrument->loop_count * 2)) - { uint32_t j ; - - for (j = 0 ; j < psf->cues->cue_count - (uint32_t) (psf->instrument->loop_count * 2) ; j ++) - { /* This simply copies the information in cues above loop positions and writes it at current count instead */ - psf->cues->cue_points [j].indx = psf->cues->cue_points [j + psf->instrument->loop_count * 2].indx ; - psf->cues->cue_points [j].position = psf->cues->cue_points [j + psf->instrument->loop_count * 2].position ; - psf->cues->cue_points [j].fcc_chunk = psf->cues->cue_points [j + psf->instrument->loop_count * 2].fcc_chunk ; - psf->cues->cue_points [j].chunk_start = psf->cues->cue_points [j + psf->instrument->loop_count * 2].chunk_start ; - psf->cues->cue_points [j].block_start = psf->cues->cue_points [j + psf->instrument->loop_count * 2].block_start ; - psf->cues->cue_points [j].sample_offset = psf->cues->cue_points [j + psf->instrument->loop_count * 2].sample_offset ; - for (str_index = 0 ; str_index < 256 ; str_index++) - psf->cues->cue_points [j].name [str_index] = psf->cues->cue_points [j + psf->instrument->loop_count * 2].name [str_index] ; - } ; - psf->cues->cue_count -= psf->instrument->loop_count * 2 ; - } else - { /* All the cues were in fact loop positions so we can actually remove the cues altogether */ - free (psf->cues) ; - psf->cues = NULL ; - } - } ; - - if (psf->sf.channels < 1) - return SFE_CHANNEL_COUNT_ZERO ; - - if (psf->sf.channels > SF_MAX_CHANNELS) - return SFE_CHANNEL_COUNT ; - - if (! (found_chunk & HAVE_FORM)) - return SFE_AIFF_NO_FORM ; - - if (! (found_chunk & HAVE_AIFF)) - return SFE_AIFF_COMM_NO_FORM ; - - if (! (found_chunk & HAVE_COMM)) - return SFE_AIFF_SSND_NO_COMM ; - - if (! psf->dataoffset) - return SFE_AIFF_NO_DATA ; - - return 0 ; -} /* aiff_read_header */ - -static int -aiff_close (SF_PRIVATE *psf) -{ AIFF_PRIVATE *paiff = psf->container_data ; - - if (paiff != NULL && paiff->markstr != NULL) - { free (paiff->markstr) ; - paiff->markstr = NULL ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { aiff_write_tailer (psf) ; - aiff_write_header (psf, SF_TRUE) ; - } ; - - return 0 ; -} /* aiff_close */ - -static int -aiff_read_comm_chunk (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) -{ BUF_UNION ubuf ; - int subformat, samplerate ; - - ubuf.scbuf [0] = 0 ; - - /* The COMM chunk has an int aligned to an odd word boundary. Some - ** processors are not able to deal with this (ie bus fault) so we have - ** to take special care. - */ - - psf_binheader_readf (psf, "E242b", &(comm_fmt->numChannels), &(comm_fmt->numSampleFrames), - &(comm_fmt->sampleSize), &(comm_fmt->sampleRate), SIGNED_SIZEOF (comm_fmt->sampleRate)) ; - - if (comm_fmt->size > 0x10000 && (comm_fmt->size & 0xffff) == 0) - { psf_log_printf (psf, " COMM : %d (0x%x) *** should be ", comm_fmt->size, comm_fmt->size) ; - comm_fmt->size = ENDSWAP_32 (comm_fmt->size) ; - psf_log_printf (psf, "%d (0x%x)\n", comm_fmt->size, comm_fmt->size) ; - } - else - psf_log_printf (psf, " COMM : %d\n", comm_fmt->size) ; - - if (comm_fmt->size == SIZEOF_AIFF_COMM) - comm_fmt->encoding = NONE_MARKER ; - else if (comm_fmt->size == SIZEOF_AIFC_COMM_MIN) - psf_binheader_readf (psf, "Em", &(comm_fmt->encoding)) ; - else if (comm_fmt->size >= SIZEOF_AIFC_COMM) - { uint8_t encoding_len ; - unsigned read_len ; - - psf_binheader_readf (psf, "Em1", &(comm_fmt->encoding), &encoding_len) ; - - comm_fmt->size = SF_MIN (sizeof (ubuf.scbuf), make_size_t (comm_fmt->size)) ; - memset (ubuf.scbuf, 0, comm_fmt->size) ; - read_len = comm_fmt->size - SIZEOF_AIFC_COMM + 1 ; - psf_binheader_readf (psf, "b", ubuf.scbuf, read_len) ; - ubuf.scbuf [read_len + 1] = 0 ; - } ; - - samplerate = tenbytefloat2int (comm_fmt->sampleRate) ; - - psf_log_printf (psf, " Sample Rate : %d\n", samplerate) ; - psf_log_printf (psf, " Frames : %u%s\n", comm_fmt->numSampleFrames, (comm_fmt->numSampleFrames == 0 && psf->filelength > 104) ? " (Should not be 0)" : "") ; - - if (comm_fmt->numChannels < 1 || comm_fmt->numChannels > SF_MAX_CHANNELS) - { psf_log_printf (psf, " Channels : %d (should be >= 1 and < %d)\n", comm_fmt->numChannels, SF_MAX_CHANNELS) ; - return SFE_CHANNEL_COUNT_BAD ; - } ; - - psf_log_printf (psf, " Channels : %d\n", comm_fmt->numChannels) ; - - /* Found some broken 'fl32' files with comm.samplesize == 16. Fix it here. */ - if ((comm_fmt->encoding == fl32_MARKER || comm_fmt->encoding == FL32_MARKER) && comm_fmt->sampleSize != 32) - { psf_log_printf (psf, " Sample Size : %d (should be 32)\n", comm_fmt->sampleSize) ; - comm_fmt->sampleSize = 32 ; - } - else if ((comm_fmt->encoding == fl64_MARKER || comm_fmt->encoding == FL64_MARKER) && comm_fmt->sampleSize != 64) - { psf_log_printf (psf, " Sample Size : %d (should be 64)\n", comm_fmt->sampleSize) ; - comm_fmt->sampleSize = 64 ; - } - else - psf_log_printf (psf, " Sample Size : %d\n", comm_fmt->sampleSize) ; - - - if ((psf->sf.channels != comm_fmt->numChannels) && psf->peak_info) - { psf_log_printf (psf, " *** channel count changed, discarding existing PEAK chunk\n") ; - free (psf->peak_info) ; - psf->peak_info = NULL ; - } ; - - subformat = s_bitwidth_to_subformat (comm_fmt->sampleSize) ; - - psf->sf.samplerate = samplerate ; - psf->sf.frames = comm_fmt->numSampleFrames ; - psf->sf.channels = comm_fmt->numChannels ; - psf->bytewidth = BITWIDTH2BYTES (comm_fmt->sampleSize) ; - - psf->endian = SF_ENDIAN_BIG ; - - switch (comm_fmt->encoding) - { case NONE_MARKER : - psf->sf.format = (SF_FORMAT_AIFF | subformat) ; - break ; - - case twos_MARKER : - case in24_MARKER : - case in32_MARKER : - psf->sf.format = (SF_ENDIAN_BIG | SF_FORMAT_AIFF | subformat) ; - break ; - - case sowt_MARKER : - case ni24_MARKER : - case ni32_MARKER : - psf->endian = SF_ENDIAN_LITTLE ; - psf->sf.format = (SF_ENDIAN_LITTLE | SF_FORMAT_AIFF | subformat) ; - break ; - - case fl32_MARKER : - case FL32_MARKER : - psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_FLOAT) ; - break ; - - case ulaw_MARKER : - case ULAW_MARKER : - psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_ULAW) ; - break ; - - case alaw_MARKER : - case ALAW_MARKER : - psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_ALAW) ; - break ; - - case fl64_MARKER : - case FL64_MARKER : - psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_DOUBLE) ; - break ; - - case raw_MARKER : - psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_PCM_U8) ; - break ; - - case DWVW_MARKER : - psf->sf.format = SF_FORMAT_AIFF ; - switch (comm_fmt->sampleSize) - { case 12 : - psf->sf.format |= SF_FORMAT_DWVW_12 ; - break ; - case 16 : - psf->sf.format |= SF_FORMAT_DWVW_16 ; - break ; - case 24 : - psf->sf.format |= SF_FORMAT_DWVW_24 ; - break ; - - default : - psf->sf.format |= SF_FORMAT_DWVW_N ; - break ; - } ; - break ; - - case GSM_MARKER : - psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_GSM610) ; - break ; - - - case ima4_MARKER : - psf->endian = SF_ENDIAN_BIG ; - psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_IMA_ADPCM) ; - break ; - - default : - psf_log_printf (psf, "AIFC : Unimplemented format : %M\n", comm_fmt->encoding) ; - return SFE_UNIMPLEMENTED ; - } ; - - if (! ubuf.scbuf [0]) - psf_log_printf (psf, " Encoding : %M\n", comm_fmt->encoding) ; - else - psf_log_printf (psf, " Encoding : %M => %s\n", comm_fmt->encoding, ubuf.scbuf) ; - - return 0 ; -} /* aiff_read_comm_chunk */ - - -/*========================================================================================== -*/ - -static int -aiff_rewrite_header (SF_PRIVATE *psf) -{ AIFF_PRIVATE *paiff = psf->container_data ; - - /* Assuming here that the header has already been written and just - ** needs to be corrected for new data length. That means that we - ** only change the length fields of the FORM and SSND chunks ; - ** everything else can be skipped over. - */ - int k, ch, comm_size, comm_frames ; - sf_count_t header_len ; - - /* Calculate the header length rather than use dataoffset, as AIFF files - ** can have additional padding offset bytes which aren't usefully a part of - ** the header. - */ - header_len = paiff->ssnd_offset + 8 + SIZEOF_SSND_CHUNK ; - if (psf->header.len < header_len || header_len > psf->dataoffset) - return SFE_INTERNAL ; - psf_fseek (psf, 0, SEEK_SET) ; - psf_fread (psf->header.ptr, header_len, 1, psf) ; - - psf->header.indx = 0 ; - - /* FORM chunk. */ - psf_binheader_writef (psf, "Etm8", BHWm (FORM_MARKER), BHW8 (psf->filelength - 8)) ; - - /* COMM chunk. */ - if ((k = psf_find_read_chunk_m32 (&psf->rchunks, COMM_MARKER)) >= 0) - { psf->header.indx = psf->rchunks.chunks [k].offset - 8 ; - comm_frames = psf->sf.frames ; - comm_size = psf->rchunks.chunks [k].len ; - psf_binheader_writef (psf, "Em42t4", BHWm (COMM_MARKER), BHW4 (comm_size), BHW2 (psf->sf.channels), BHW4 (comm_frames)) ; - } ; - - /* PEAK chunk. */ - if ((k = psf_find_read_chunk_m32 (&psf->rchunks, PEAK_MARKER)) >= 0) - { psf->header.indx = psf->rchunks.chunks [k].offset - 8 ; - psf_binheader_writef (psf, "Em4", BHWm (PEAK_MARKER), BHW4 (AIFF_PEAK_CHUNK_SIZE (psf->sf.channels))) ; - psf_binheader_writef (psf, "E44", BHW4 (1), BHW4 (time (NULL))) ; - for (ch = 0 ; ch < psf->sf.channels ; ch++) - psf_binheader_writef (psf, "Eft8", BHWf ((float) psf->peak_info->peaks [ch].value), BHW8 (psf->peak_info->peaks [ch].position)) ; - } ; - - - /* SSND chunk. */ - if ((k = psf_find_read_chunk_m32 (&psf->rchunks, SSND_MARKER)) >= 0) - { psf->header.indx = psf->rchunks.chunks [k].offset - 8 ; - psf_binheader_writef (psf, "Etm8", BHWm (SSND_MARKER), BHW8 (psf->datalength + SIZEOF_SSND_CHUNK)) ; - } ; - - /* Header mangling complete so write it out. */ - psf_fseek (psf, 0, SEEK_SET) ; - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - return 0 ; -} /* aiff_rewrite_header */ - -static int -aiff_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t current ; - AIFF_PRIVATE *paiff ; - uint8_t comm_sample_rate [10], comm_zero_bytes [2] = { 0, 0 } ; - uint32_t comm_type, comm_size, comm_encoding, comm_frames = 0, uk ; - int ret, k, endian, has_data = SF_FALSE ; - int16_t bit_width ; - - if ((paiff = psf->container_data) == NULL) - return SFE_INTERNAL ; - - current = psf_ftell (psf) ; - - if (current > psf->dataoffset) - has_data = SF_TRUE ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - if (psf->bytewidth > 0) - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - if (psf->file.mode == SFM_RDWR && psf->dataoffset > 0 && psf->rchunks.count > 0) - { if ((ret = aiff_rewrite_header (psf)) != 0) - return ret ; - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - return 0 ; - } ; - - endian = SF_ENDIAN (psf->sf.format) ; - if (CPU_IS_LITTLE_ENDIAN && endian == SF_ENDIAN_CPU) - endian = SF_ENDIAN_LITTLE ; - - /* Standard value here. */ - bit_width = psf->bytewidth * 8 ; - comm_frames = (psf->sf.frames > 0xFFFFFFFF) ? 0xFFFFFFFF : psf->sf.frames ; - - switch (SF_CODEC (psf->sf.format) | endian) - { case SF_FORMAT_PCM_S8 | SF_ENDIAN_BIG : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = twos_MARKER ; - break ; - - case SF_FORMAT_PCM_S8 | SF_ENDIAN_LITTLE : - psf->endian = SF_ENDIAN_LITTLE ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = sowt_MARKER ; - break ; - - case SF_FORMAT_PCM_16 | SF_ENDIAN_BIG : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = twos_MARKER ; - break ; - - case SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE : - psf->endian = SF_ENDIAN_LITTLE ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = sowt_MARKER ; - break ; - - case SF_FORMAT_PCM_24 | SF_ENDIAN_BIG : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = in24_MARKER ; - break ; - - case SF_FORMAT_PCM_24 | SF_ENDIAN_LITTLE : - psf->endian = SF_ENDIAN_LITTLE ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = ni24_MARKER ; - break ; - - case SF_FORMAT_PCM_32 | SF_ENDIAN_BIG : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = in32_MARKER ; - break ; - - case SF_FORMAT_PCM_32 | SF_ENDIAN_LITTLE : - psf->endian = SF_ENDIAN_LITTLE ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = ni32_MARKER ; - break ; - - case SF_FORMAT_PCM_S8 : /* SF_ENDIAN_FILE */ - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFF_MARKER ; - comm_size = SIZEOF_AIFF_COMM ; - comm_encoding = 0 ; - break ; - - case SF_FORMAT_FLOAT : /* Big endian floating point. */ - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = FL32_MARKER ; /* Use 'FL32' because its easier to read. */ - break ; - - case SF_FORMAT_DOUBLE : /* Big endian double precision floating point. */ - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = FL64_MARKER ; /* Use 'FL64' because its easier to read. */ - break ; - - case SF_FORMAT_ULAW : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = ulaw_MARKER ; - break ; - - case SF_FORMAT_ALAW : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = alaw_MARKER ; - break ; - - case SF_FORMAT_PCM_U8 : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = raw_MARKER ; - break ; - - case SF_FORMAT_DWVW_12 : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = DWVW_MARKER ; - - /* Override standard value here.*/ - bit_width = 12 ; - break ; - - case SF_FORMAT_DWVW_16 : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = DWVW_MARKER ; - - /* Override standard value here.*/ - bit_width = 16 ; - break ; - - case SF_FORMAT_DWVW_24 : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = DWVW_MARKER ; - - /* Override standard value here.*/ - bit_width = 24 ; - break ; - - case SF_FORMAT_GSM610 : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = GSM_MARKER ; - - /* Override standard value here.*/ - bit_width = 16 ; - break ; - - case SF_FORMAT_IMA_ADPCM : - psf->endian = SF_ENDIAN_BIG ; - comm_type = AIFC_MARKER ; - comm_size = SIZEOF_AIFC_COMM ; - comm_encoding = ima4_MARKER ; - - /* Override standard value here.*/ - bit_width = 16 ; - comm_frames = psf->sf.frames / AIFC_IMA4_SAMPLES_PER_BLOCK ; - break ; - - default : return SFE_BAD_OPEN_FORMAT ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - psf_binheader_writef (psf, "Etm8", BHWm (FORM_MARKER), BHW8 (psf->filelength - 8)) ; - - /* Write AIFF/AIFC marker and COM chunk. */ - if (comm_type == AIFC_MARKER) - /* AIFC must have an FVER chunk. */ - psf_binheader_writef (psf, "Emm44", BHWm (comm_type), BHWm (FVER_MARKER), BHW4 (4), BHW4 (0xA2805140)) ; - else - psf_binheader_writef (psf, "Em", BHWm (comm_type)) ; - - paiff->comm_offset = psf->header.indx - 8 ; - - memset (comm_sample_rate, 0, sizeof (comm_sample_rate)) ; - uint2tenbytefloat (psf->sf.samplerate, comm_sample_rate) ; - - psf_binheader_writef (psf, "Em42t42", BHWm (COMM_MARKER), BHW4 (comm_size), BHW2 (psf->sf.channels), BHW4 (comm_frames), BHW2 (bit_width)) ; - psf_binheader_writef (psf, "b", BHWv (comm_sample_rate), BHWz (sizeof (comm_sample_rate))) ; - - /* AIFC chunks have some extra data. */ - if (comm_type == AIFC_MARKER) - psf_binheader_writef (psf, "mb", BHWm (comm_encoding), BHWv (comm_zero_bytes), BHWz (sizeof (comm_zero_bytes))) ; - - if (psf->channel_map && paiff->chanmap_tag) - psf_binheader_writef (psf, "Em4444", BHWm (CHAN_MARKER), BHW4 (12), BHW4 (paiff->chanmap_tag), BHW4 (0), BHW4 (0)) ; - - /* Check if there's a INST chunk to write */ - if (psf->instrument != NULL && psf->cues != NULL) - { /* Huge chunk of code removed here because it had egregious errors that were - ** not detected by either the compiler or the tests. It was found when updating - ** the way psf_binheader_writef works. - */ - } - else if (psf->instrument == NULL && psf->cues != NULL) - { /* There are cues but no loops */ - uint32_t idx ; - int totalStringLength = 0, stringLength ; - - /* Here we count how many bytes will the pascal strings need */ - for (idx = 0 ; idx < psf->cues->cue_count ; idx++) - { stringLength = strlen (psf->cues->cue_points [idx].name) + 1 ; /* We'll count the first byte also of every pascal string */ - totalStringLength += stringLength + (stringLength % 2 == 0 ? 0 : 1) ; - } ; - - psf_binheader_writef (psf, "Em42", - BHWm (MARK_MARKER), BHW4 (2 + psf->cues->cue_count * (2 + 4) + totalStringLength), BHW2 (psf->cues->cue_count)) ; - - for (idx = 0 ; idx < psf->cues->cue_count ; idx++) - psf_binheader_writef (psf, "E24p", BHW2 (psf->cues->cue_points [idx].indx), BHW4 (psf->cues->cue_points [idx].sample_offset), BHWp (psf->cues->cue_points [idx].name)) ; - } ; - - if (psf->strings.flags & SF_STR_LOCATE_START) - aiff_write_strings (psf, SF_STR_LOCATE_START) ; - - if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_START) - { psf_binheader_writef (psf, "Em4", BHWm (PEAK_MARKER), BHW4 (AIFF_PEAK_CHUNK_SIZE (psf->sf.channels))) ; - psf_binheader_writef (psf, "E44", BHW4 (1), BHW4 (time (NULL))) ; - for (k = 0 ; k < psf->sf.channels ; k++) - psf_binheader_writef (psf, "Eft8", BHWf ((float) psf->peak_info->peaks [k].value), BHW8 (psf->peak_info->peaks [k].position)) ; - } ; - - /* Write custom headers. */ - for (uk = 0 ; uk < psf->wchunks.used ; uk++) - psf_binheader_writef (psf, "Em4b", BHWm (psf->wchunks.chunks [uk].mark32), BHW4 (psf->wchunks.chunks [uk].len), BHWv (psf->wchunks.chunks [uk].data), BHWz (psf->wchunks.chunks [uk].len)) ; - - /* Write SSND chunk. */ - paiff->ssnd_offset = psf->header.indx ; - psf_binheader_writef (psf, "Etm844", BHWm (SSND_MARKER), BHW8 (psf->datalength + SIZEOF_SSND_CHUNK), BHW4 (0), BHW4 (0)) ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - if (has_data && psf->dataoffset != psf->header.indx) - return psf->error = SFE_INTERNAL ; - - psf->dataoffset = psf->header.indx ; - - if (! has_data) - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - else if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* aiff_write_header */ - -static int -aiff_write_tailer (SF_PRIVATE *psf) -{ int k ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - psf->dataend = psf_fseek (psf, 0, SEEK_END) ; - - /* Make sure tailer data starts at even byte offset. Pad if necessary. */ - if (psf->dataend % 2 == 1) - { psf_fwrite (psf->header.ptr, 1, 1, psf) ; - psf->dataend ++ ; - } ; - - if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_END) - { psf_binheader_writef (psf, "Em4", BHWm (PEAK_MARKER), BHW4 (AIFF_PEAK_CHUNK_SIZE (psf->sf.channels))) ; - psf_binheader_writef (psf, "E44", BHW4 (1), BHW4 (time (NULL))) ; - for (k = 0 ; k < psf->sf.channels ; k++) - psf_binheader_writef (psf, "Eft8", BHWf ((float) psf->peak_info->peaks [k].value), BHW8 (psf->peak_info->peaks [k].position)) ; - } ; - - if (psf->strings.flags & SF_STR_LOCATE_END) - aiff_write_strings (psf, SF_STR_LOCATE_END) ; - - /* Write the tailer. */ - if (psf->header.indx > 0) - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - return 0 ; -} /* aiff_write_tailer */ - -static void -aiff_write_strings (SF_PRIVATE *psf, int location) -{ int k, slen ; - - for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { if (psf->strings.data [k].type == 0) - break ; - - if (psf->strings.data [k].flags != location) - continue ; - - switch (psf->strings.data [k].type) - { case SF_STR_SOFTWARE : - slen = strlen (psf->strings.storage + psf->strings.data [k].offset) ; - psf_binheader_writef (psf, "Em4mb", BHWm (APPL_MARKER), BHW4 (slen + 4), BHWm (m3ga_MARKER), BHWv (psf->strings.storage + psf->strings.data [k].offset), BHWz (slen + (slen & 1))) ; - break ; - - case SF_STR_TITLE : - psf_binheader_writef (psf, "EmS", BHWm (NAME_MARKER), BHWS (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_COPYRIGHT : - psf_binheader_writef (psf, "EmS", BHWm (c_MARKER), BHWS (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_ARTIST : - psf_binheader_writef (psf, "EmS", BHWm (AUTH_MARKER), BHWS (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_COMMENT : - psf_binheader_writef (psf, "EmS", BHWm (ANNO_MARKER), BHWS (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - /* - case SF_STR_DATE : - psf_binheader_writef (psf, "Ems", BHWm (ICRD_MARKER), BHWs (psf->strings.data [k].str)) ; - break ; - */ - } ; - } ; - - return ; -} /* aiff_write_strings */ - -static int -aiff_command (SF_PRIVATE * psf, int command, void * UNUSED (data), int UNUSED (datasize)) -{ AIFF_PRIVATE *paiff ; - - if ((paiff = psf->container_data) == NULL) - return SFE_INTERNAL ; - - switch (command) - { case SFC_SET_CHANNEL_MAP_INFO : - paiff->chanmap_tag = aiff_caf_find_channel_layout_tag (psf->channel_map, psf->sf.channels) ; - return (paiff->chanmap_tag != 0) ; - - default : - break ; - } ; - - return 0 ; -} /* aiff_command */ - -static const char* -get_loop_mode_str (int16_t mode) -{ switch (mode) - { case 0 : return "none" ; - case 1 : return "forward" ; - case 2 : return "backward" ; - } ; - - return "*** unknown" ; -} /* get_loop_mode_str */ - -static int16_t -get_loop_mode (int16_t mode) -{ switch (mode) - { case 0 : return SF_LOOP_NONE ; - case 1 : return SF_LOOP_FORWARD ; - case 2 : return SF_LOOP_BACKWARD ; - } ; - - return SF_LOOP_NONE ; -} /* get_loop_mode */ - -/*========================================================================================== -** Rough hack at converting from 80 bit IEEE float in AIFF header to an int and -** back again. It assumes that all sample rates are between 1 and 800MHz, which -** should be OK as other sound file formats use a 32 bit integer to store sample -** rate. -** There is another (probably better) version in the source code to the SoX but it -** has a copyright which probably prevents it from being allowable as GPL/LGPL. -*/ - -static int -tenbytefloat2int (uint8_t *bytes) -{ int val = 3 ; - - if (bytes [0] & 0x80) /* Negative number. */ - return 0 ; - - if (bytes [0] <= 0x3F) /* Less than 1. */ - return 1 ; - - if (bytes [0] > 0x40) /* Way too big. */ - return 0x4000000 ; - - if (bytes [0] == 0x40 && bytes [1] > 0x1C) /* Too big. */ - return 800000000 ; - - /* Ok, can handle it. */ - - val = (bytes [2] << 23) | (bytes [3] << 15) | (bytes [4] << 7) | (bytes [5] >> 1) ; - - val >>= (29 - bytes [1]) ; - - return val ; -} /* tenbytefloat2int */ - -static void -uint2tenbytefloat (uint32_t num, uint8_t *bytes) -{ uint32_t mask = 0x40000000 ; - int count ; - - if (num <= 1) - { bytes [0] = 0x3F ; - bytes [1] = 0xFF ; - bytes [2] = 0x80 ; - return ; - } ; - - bytes [0] = 0x40 ; - - if (num >= mask) - { bytes [1] = 0x1D ; - return ; - } ; - - for (count = 0 ; count < 32 ; count ++) - { if (num & mask) - break ; - mask >>= 1 ; - } ; - - num = count < 31 ? num << (count + 1) : 0 ; - bytes [1] = 29 - count ; - bytes [2] = (num >> 24) & 0xFF ; - bytes [3] = (num >> 16) & 0xFF ; - bytes [4] = (num >> 8) & 0xFF ; - bytes [5] = num & 0xFF ; - -} /* uint2tenbytefloat */ - -static int -aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize) -{ const char * type_str ; - basc_CHUNK bc ; - int count ; - - count = psf_binheader_readf (psf, "E442", &bc.version, &bc.numBeats, &bc.rootNote) ; - count += psf_binheader_readf (psf, "E222", &bc.scaleType, &bc.sigNumerator, &bc.sigDenominator) ; - count += psf_binheader_readf (psf, "E2j", &bc.loopType, datasize - sizeof (bc)) ; - - psf_log_printf (psf, " Version ? : %u\n Num Beats : %u\n Root Note : 0x%x\n", - bc.version, bc.numBeats, bc.rootNote) ; - - switch (bc.scaleType) - { case basc_SCALE_MINOR : - type_str = "MINOR" ; - break ; - case basc_SCALE_MAJOR : - type_str = "MAJOR" ; - break ; - case basc_SCALE_NEITHER : - type_str = "NEITHER" ; - break ; - case basc_SCALE_BOTH : - type_str = "BOTH" ; - break ; - default : - type_str = "!!WRONG!!" ; - break ; - } ; - - psf_log_printf (psf, " ScaleType : 0x%x (%s)\n", bc.scaleType, type_str) ; - psf_log_printf (psf, " Time Sig : %d/%d\n", bc.sigNumerator, bc.sigDenominator) ; - - switch (bc.loopType) - { case basc_TYPE_ONE_SHOT : - type_str = "One Shot" ; - break ; - case basc_TYPE_LOOP : - type_str = "Loop" ; - break ; - default: - type_str = "!!WRONG!!" ; - break ; - } ; - - psf_log_printf (psf, " Loop Type : 0x%x (%s)\n", bc.loopType, type_str) ; - - if (psf->loop_info) - { psf_log_printf (psf, " Found existing loop info, using last one.\n") ; - free (psf->loop_info) ; - psf->loop_info = NULL ; - } ; - if ((psf->loop_info = calloc (1, sizeof (SF_LOOP_INFO))) == NULL) - return SFE_MALLOC_FAILED ; - - psf->loop_info->time_sig_num = bc.sigNumerator ; - psf->loop_info->time_sig_den = bc.sigDenominator ; - psf->loop_info->loop_mode = (bc.loopType == basc_TYPE_ONE_SHOT) ? SF_LOOP_NONE : SF_LOOP_FORWARD ; - psf->loop_info->num_beats = bc.numBeats ; - - /* Can always be recalculated from other known fields. */ - psf->loop_info->bpm = (1.0 / psf->sf.frames) * psf->sf.samplerate - * ((bc.numBeats * 4.0) / bc.sigDenominator) * 60.0 ; - psf->loop_info->root_key = bc.rootNote ; - - if (count < datasize) - psf_binheader_readf (psf, "j", datasize - count) ; - - return 0 ; -} /* aiff_read_basc_chunk */ - - -static int -aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword) -{ const AIFF_CAF_CHANNEL_MAP * map_info ; - unsigned channel_bitmap, channel_decriptions, bytesread ; - int layout_tag ; - - bytesread = psf_binheader_readf (psf, "444", &layout_tag, &channel_bitmap, &channel_decriptions) ; - - if ((map_info = aiff_caf_of_channel_layout_tag (layout_tag)) == NULL) - return 0 ; - - psf_log_printf (psf, " Tag : %x\n", layout_tag) ; - if (map_info) - psf_log_printf (psf, " Layout : %s\n", map_info->name) ; - - if (bytesread < dword) - psf_binheader_readf (psf, "j", dword - bytesread) ; - - if (map_info->channel_map != NULL) - { size_t chanmap_size = SF_MIN (psf->sf.channels, layout_tag & 0xffff) * sizeof (psf->channel_map [0]) ; - - free (psf->channel_map) ; - - if ((psf->channel_map = malloc (chanmap_size)) == NULL) - return SFE_MALLOC_FAILED ; - - memcpy (psf->channel_map, map_info->channel_map, chanmap_size) ; - } ; - - return 0 ; -} /* aiff_read_chanmap */ - -/*============================================================================== -*/ - -static int -aiff_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) -{ return psf_save_write_chunk (&psf->wchunks, chunk_info) ; -} /* aiff_set_chunk */ - -static SF_CHUNK_ITERATOR * -aiff_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) -{ return psf_next_chunk_iterator (&psf->rchunks, iterator) ; -} /* aiff_next_chunk_iterator */ - -static int -aiff_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ int indx ; - - if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) - return SFE_UNKNOWN_CHUNK ; - - chunk_info->datalen = psf->rchunks.chunks [indx].len ; - - return SFE_NO_ERROR ; -} /* aiff_get_chunk_size */ - -static int -aiff_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ sf_count_t pos ; - int indx ; - - if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) - return SFE_UNKNOWN_CHUNK ; - - if (chunk_info->data == NULL) - return SFE_BAD_CHUNK_DATA_PTR ; - - chunk_info->id_size = psf->rchunks.chunks [indx].id_size ; - memcpy (chunk_info->id, psf->rchunks.chunks [indx].id, sizeof (chunk_info->id) / sizeof (*chunk_info->id)) ; - - pos = psf_ftell (psf) ; - psf_fseek (psf, psf->rchunks.chunks [indx].offset, SEEK_SET) ; - psf_fread (chunk_info->data, SF_MIN (chunk_info->datalen, psf->rchunks.chunks [indx].len), 1, psf) ; - psf_fseek (psf, pos, SEEK_SET) ; - - return SFE_NO_ERROR ; -} /* aiff_get_chunk_data */ diff --git a/Engine/lib/libsndfile/src/alac.c b/Engine/lib/libsndfile/src/alac.c deleted file mode 100644 index a6668f367..000000000 --- a/Engine/lib/libsndfile/src/alac.c +++ /dev/null @@ -1,999 +0,0 @@ -/* -** Copyright (C) 2011-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "ALAC/alac_codec.h" -#include "ALAC/ALACBitUtilities.h" - -#define ALAC_MAX_FRAME_SIZE 8192 -#define ALAC_BYTE_BUFFER_SIZE 0x20000 -#define ALAC_MAX_CHANNEL_COUNT 8 // Same as kALACMaxChannels in /ALACAudioTypes.h - -typedef struct -{ uint32_t current, count, allocated ; - uint32_t packet_size [] ; -} PAKT_INFO ; - -typedef struct -{ sf_count_t input_data_pos ; - - PAKT_INFO * pakt_info ; - - int channels, final_write_block ; - - uint32_t frames_this_block, partial_block_frames, frames_per_block ; - uint32_t bits_per_sample, kuki_size ; - - - /* Can't have a decoder and an encoder at the same time so stick - ** them in a union. - */ - union - { ALAC_DECODER decoder ; - ALAC_ENCODER encoder ; - } u ; - - char enctmpname [512] ; - FILE *enctmp ; - - uint8_t byte_buffer [ALAC_MAX_CHANNEL_COUNT * ALAC_BYTE_BUFFER_SIZE] ; - - int buffer [] ; - -} ALAC_PRIVATE ; - -/*============================================================================================ -*/ - -static int alac_reader_init (SF_PRIVATE *psf, const ALAC_DECODER_INFO * info) ; -static int alac_writer_init (SF_PRIVATE *psf) ; - -static sf_count_t alac_reader_calc_frames (SF_PRIVATE *psf, ALAC_PRIVATE *plac) ; - -static sf_count_t alac_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t alac_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t alac_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t alac_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t alac_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t alac_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t alac_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t alac_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static sf_count_t alac_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; - -static int alac_close (SF_PRIVATE *psf) ; -static int alac_byterate (SF_PRIVATE *psf) ; - -static int alac_decode_block (SF_PRIVATE *psf, ALAC_PRIVATE *plac) ; -static int alac_encode_block (ALAC_PRIVATE *plac) ; - -static uint32_t alac_kuki_read (SF_PRIVATE * psf, uint32_t kuki_offset, uint8_t * kuki, size_t kuki_maxlen) ; - -static PAKT_INFO * alac_pakt_alloc (uint32_t initial_count) ; -static PAKT_INFO * alac_pakt_read_decode (SF_PRIVATE * psf, uint32_t pakt_offset) ; -static PAKT_INFO * alac_pakt_append (PAKT_INFO * info, uint32_t value) ; -static uint8_t * alac_pakt_encode (const SF_PRIVATE *psf, uint32_t * pakt_size) ; -static sf_count_t alac_pakt_block_offset (const PAKT_INFO *info, uint32_t block) ; - -static const char * alac_error_string (int error) ; - -/*============================================================================================ -** ALAC Reader initialisation function. -*/ - -int -alac_init (SF_PRIVATE *psf, const ALAC_DECODER_INFO * info) -{ int error ; - - if ((psf->codec_data = calloc (1, sizeof (ALAC_PRIVATE) + psf->sf.channels * sizeof (int) * ALAC_MAX_FRAME_SIZE)) == NULL) - return SFE_MALLOC_FAILED ; - - psf->codec_close = alac_close ; - - switch (psf->file.mode) - { case SFM_RDWR : - return SFE_BAD_MODE_RW ; - - case SFM_READ : - if ((error = alac_reader_init (psf, info))) - return error ; - break ; - - case SFM_WRITE : - if ((error = alac_writer_init (psf))) - return error ; - break ; - - default : - psf_log_printf (psf, "%s : Bad psf->file.mode.\n", __func__) ; - return SFE_INTERNAL ; - } ; - - psf->byterate = alac_byterate ; - - return 0 ; -} /* aiff_alac_init */ - -void -alac_get_desc_chunk_items (int subformat, uint32_t *fmt_flags, uint32_t *frames_per_packet) -{ switch (subformat) - { case SF_FORMAT_ALAC_16 : - *fmt_flags = 1 ; - break ; - case SF_FORMAT_ALAC_20 : - *fmt_flags = 2 ; - break ; - case SF_FORMAT_ALAC_24 : - *fmt_flags = 3 ; - break ; - case SF_FORMAT_ALAC_32 : - *fmt_flags = 4 ; - break ; - default : - break ; - } ; - *frames_per_packet = ALAC_FRAME_LENGTH ; -} /* alac_get_desc_chunk_items */ - -static int -alac_close (SF_PRIVATE *psf) -{ ALAC_PRIVATE *plac ; - BUF_UNION ubuf ; - - plac = psf->codec_data ; - - if (psf->file.mode == SFM_WRITE) - { ALAC_ENCODER *penc = &plac->u.encoder ; - SF_CHUNK_INFO chunk_info ; - sf_count_t readcount ; - uint8_t kuki_data [1024] ; - uint32_t pakt_size = 0, saved_partial_block_frames ; - - plac->final_write_block = 1 ; - saved_partial_block_frames = plac->partial_block_frames ; - - /* If a block has been partially assembled, write it out as the final block. */ - if (plac->partial_block_frames && plac->partial_block_frames < plac->frames_per_block) - alac_encode_block (plac) ; - - plac->partial_block_frames = saved_partial_block_frames ; - - alac_get_magic_cookie (penc, kuki_data, &plac->kuki_size) ; - - memset (&chunk_info, 0, sizeof (chunk_info)) ; - chunk_info.id_size = snprintf (chunk_info.id, sizeof (chunk_info.id), "kuki") ; - chunk_info.data = kuki_data ; - chunk_info.datalen = plac->kuki_size ; - psf_save_write_chunk (&psf->wchunks, &chunk_info) ; - - memset (&chunk_info, 0, sizeof (chunk_info)) ; - chunk_info.id_size = snprintf (chunk_info.id, sizeof (chunk_info.id), "pakt") ; - chunk_info.data = alac_pakt_encode (psf, &pakt_size) ; - chunk_info.datalen = pakt_size ; - psf_save_write_chunk (&psf->wchunks, &chunk_info) ; - - free (chunk_info.data) ; - chunk_info.data = NULL ; - - psf->write_header (psf, 1) ; - - if (plac->enctmp != NULL) - { fseek (plac->enctmp, 0, SEEK_SET) ; - - while ((readcount = fread (ubuf.ucbuf, 1, sizeof (ubuf.ucbuf), plac->enctmp)) > 0) - psf_fwrite (ubuf.ucbuf, 1, readcount, psf) ; - fclose (plac->enctmp) ; - remove (plac->enctmpname) ; - } ; - } ; - - if (plac->pakt_info) - free (plac->pakt_info) ; - plac->pakt_info = NULL ; - - return 0 ; -} /* alac_close */ - -static int -alac_byterate (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_READ) - return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; - - return -1 ; -} /* alac_byterate */ - -/*============================================================================================ -** ALAC initialisation Functions. -*/ - -static int -alac_reader_init (SF_PRIVATE *psf, const ALAC_DECODER_INFO * info) -{ ALAC_PRIVATE *plac ; - uint32_t kuki_size ; - int error ; - union { uint8_t kuki [512] ; uint32_t alignment ; } u ; - - if (info == NULL) - { psf_log_printf (psf, "%s : ALAC_DECODER_INFO is NULL.\n", __func__) ; - return SFE_INTERNAL ; - } ; - - if (info->frames_per_packet > ALAC_FRAME_LENGTH) - { psf_log_printf (psf, "*** Error : frames_per_packet (%u) is too big. ***\n", info->frames_per_packet) ; - return SFE_INTERNAL ; - } ; - - plac = psf->codec_data ; - - plac->channels = psf->sf.channels ; - plac->frames_per_block = info->frames_per_packet ; - plac->bits_per_sample = info->bits_per_sample ; - - if (plac->pakt_info != NULL) - free (plac->pakt_info) ; - plac->pakt_info = alac_pakt_read_decode (psf, info->pakt_offset) ; - - if (plac->pakt_info == NULL) - { psf_log_printf (psf, "%s : alac_pkt_read() returns NULL.\n", __func__) ; - return SFE_INTERNAL ; - } ; - - /* Read in the ALAC cookie data and pass it to the init function. */ - kuki_size = alac_kuki_read (psf, info->kuki_offset, u.kuki, sizeof (u.kuki)) ; - - if ((error = alac_decoder_init (&plac->u.decoder, u.kuki, kuki_size)) != ALAC_noErr) - { psf_log_printf (psf, "*** alac_decoder_init() returned %s. ***\n", alac_error_string (error)) ; - return SFE_INTERNAL ; - } ; - - - if (plac->u.decoder.mNumChannels != (unsigned) psf->sf.channels) - { psf_log_printf (psf, "*** Initialized decoder has %u channels, but it should be %d. ***\n", plac->u.decoder.mNumChannels, psf->sf.channels) ; - return SFE_INTERNAL ; - } ; - - switch (info->bits_per_sample) - { case 16 : - case 20 : - case 24 : - case 32 : - psf->read_short = alac_read_s ; - psf->read_int = alac_read_i ; - psf->read_float = alac_read_f ; - psf->read_double = alac_read_d ; - break ; - - default : - printf ("%s : info->bits_per_sample %u\n", __func__, info->bits_per_sample) ; - return SFE_UNSUPPORTED_ENCODING ; - } ; - - psf->codec_close = alac_close ; - psf->seek = alac_seek ; - - psf->sf.frames = alac_reader_calc_frames (psf, plac) ; - alac_seek (psf, SFM_READ, 0) ; - - return 0 ; -} /* alac_reader_init */ - -static int -alac_writer_init (SF_PRIVATE *psf) -{ ALAC_PRIVATE *plac ; - uint32_t alac_format_flags = 0 ; - - plac = psf->codec_data ; - - if (psf->file.mode != SFM_WRITE) - return SFE_BAD_MODE_RW ; - - plac->channels = psf->sf.channels ; - plac->kuki_size = alac_get_magic_cookie_size (psf->sf.channels) ; - - psf->write_short = alac_write_s ; - psf->write_int = alac_write_i ; - psf->write_float = alac_write_f ; - psf->write_double = alac_write_d ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_ALAC_16 : - alac_format_flags = 1 ; - plac->bits_per_sample = 16 ; - break ; - - case SF_FORMAT_ALAC_20 : - alac_format_flags = 2 ; - plac->bits_per_sample = 20 ; - break ; - - case SF_FORMAT_ALAC_24 : - alac_format_flags = 3 ; - plac->bits_per_sample = 24 ; - break ; - - case SF_FORMAT_ALAC_32 : - alac_format_flags = 4 ; - plac->bits_per_sample = 32 ; - break ; - - default : - psf_log_printf (psf, "%s : Can't figure out bits per sample.\n", __func__) ; - return SFE_UNIMPLEMENTED ; - } ; - - plac->frames_per_block = ALAC_FRAME_LENGTH ; - - plac->pakt_info = alac_pakt_alloc (2000) ; - - if ((plac->enctmp = psf_open_tmpfile (plac->enctmpname, sizeof (plac->enctmpname))) == NULL) - { psf_log_printf (psf, "Error : Failed to open temp file '%s' : \n", plac->enctmpname, strerror (errno)) ; - return SFE_ALAC_FAIL_TMPFILE ; - } ; - - alac_encoder_init (&plac->u.encoder, psf->sf.samplerate, psf->sf.channels, alac_format_flags, ALAC_FRAME_LENGTH) ; - - return 0 ; -} /* alac_writer_init */ - -/*============================================================================================ -** ALAC block decoder and encoder. -*/ - -static inline uint32_t -alac_reader_next_packet_size (PAKT_INFO * info) -{ if (info->current >= info->count) - return 0 ; - return info->packet_size [info->current++] ; -} /* alac_reader_next_packet_size */ - -static sf_count_t -alac_reader_calc_frames (SF_PRIVATE *psf, ALAC_PRIVATE *plac) -{ sf_count_t frames = 0 ; - uint32_t current_pos = 1, blocks = 0 ; - - plac->pakt_info->current = 0 ; - - while (current_pos < psf->filelength && current_pos > 0) - { current_pos = alac_reader_next_packet_size (plac->pakt_info) ; - blocks = current_pos > 0 ? blocks + 1 : blocks ; - } ; - - if (blocks == 0) - return 0 ; - - /* Only count full blocks. */ - frames = plac->frames_per_block * (blocks - 1) ; - - alac_seek (psf, SFM_READ, frames) ; - alac_decode_block (psf, plac) ; - frames += plac->frames_this_block ; - - plac->pakt_info->current = 0 ; - - return frames ; -} /* alac_reader_calc_frames */ - -static int -alac_decode_block (SF_PRIVATE *psf, ALAC_PRIVATE *plac) -{ ALAC_DECODER *pdec = &plac->u.decoder ; - uint32_t packet_size ; - BitBuffer bit_buffer ; - - packet_size = alac_reader_next_packet_size (plac->pakt_info) ; - if (packet_size == 0) - { if (plac->pakt_info->current < plac->pakt_info->count) - psf_log_printf (psf, "packet_size is 0 (%d of %d)\n", plac->pakt_info->current, plac->pakt_info->count) ; - return 0 ; - } ; - - psf_fseek (psf, plac->input_data_pos, SEEK_SET) ; - - if (packet_size > sizeof (plac->byte_buffer)) - { psf_log_printf (psf, "%s : bad packet_size (%u)\n", __func__, packet_size) ; - return 0 ; - } ; - - if ((packet_size != psf_fread (plac->byte_buffer, 1, packet_size, psf))) - return 0 ; - - BitBufferInit (&bit_buffer, plac->byte_buffer, packet_size) ; - - plac->input_data_pos += packet_size ; - plac->frames_this_block = 0 ; - alac_decode (pdec, &bit_buffer, plac->buffer, plac->frames_per_block, &plac->frames_this_block) ; - - plac->partial_block_frames = 0 ; - - return 1 ; -} /* alac_decode_block */ - - -static int -alac_encode_block (ALAC_PRIVATE *plac) -{ ALAC_ENCODER *penc = &plac->u.encoder ; - uint32_t num_bytes = 0 ; - - alac_encode (penc, plac->partial_block_frames, plac->buffer, plac->byte_buffer, &num_bytes) ; - - if (fwrite (plac->byte_buffer, 1, num_bytes, plac->enctmp) != num_bytes) - return 0 ; - if ((plac->pakt_info = alac_pakt_append (plac->pakt_info, num_bytes)) == NULL) - return 0 ; - - plac->partial_block_frames = 0 ; - - return 1 ; -} /* alac_encode_block */ - -/*============================================================================================ -** ALAC read functions. -*/ - -static sf_count_t -alac_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ ALAC_PRIVATE *plac ; - int *iptr ; - int k, readcount ; - sf_count_t total = 0 ; - - if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) - return 0 ; - - while (len > 0) - { if (plac->partial_block_frames >= plac->frames_this_block && alac_decode_block (psf, plac) == 0) - break ; - - readcount = (plac->frames_this_block - plac->partial_block_frames) * plac->channels ; - readcount = readcount > len ? (int) len : readcount ; - - iptr = plac->buffer + plac->partial_block_frames * plac->channels ; - - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = iptr [k] >> 16 ; - - plac->partial_block_frames += readcount / plac->channels ; - total += readcount ; - len -= readcount ; - } ; - - return total ; -} /* alac_read_s */ - -static sf_count_t -alac_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ ALAC_PRIVATE *plac ; - int *iptr ; - int k, readcount ; - sf_count_t total = 0 ; - - if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) - return 0 ; - - while (len > 0) - { if (plac->partial_block_frames >= plac->frames_this_block && alac_decode_block (psf, plac) == 0) - break ; - - readcount = (plac->frames_this_block - plac->partial_block_frames) * plac->channels ; - readcount = readcount > len ? (int) len : readcount ; - - iptr = plac->buffer + plac->partial_block_frames * plac->channels ; - - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = iptr [k] ; - - plac->partial_block_frames += readcount / plac->channels ; - total += readcount ; - len -= readcount ; - } ; - - return total ; -} /* alac_read_i */ - -static sf_count_t -alac_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ ALAC_PRIVATE *plac ; - int *iptr ; - int k, readcount ; - sf_count_t total = 0 ; - float normfact ; - - if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; - - while (len > 0) - { if (plac->partial_block_frames >= plac->frames_this_block && alac_decode_block (psf, plac) == 0) - break ; - - readcount = (plac->frames_this_block - plac->partial_block_frames) * plac->channels ; - readcount = readcount > len ? (int) len : readcount ; - - iptr = plac->buffer + plac->partial_block_frames * plac->channels ; - - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * iptr [k] ; - - plac->partial_block_frames += readcount / plac->channels ; - total += readcount ; - len -= readcount ; - } ; - - return total ; -} /* alac_read_f */ - -static sf_count_t -alac_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ ALAC_PRIVATE *plac ; - int *iptr ; - int k, readcount ; - sf_count_t total = 0 ; - double normfact ; - - if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; - - while (len > 0) - { if (plac->partial_block_frames >= plac->frames_this_block && alac_decode_block (psf, plac) == 0) - break ; - - readcount = (plac->frames_this_block - plac->partial_block_frames) * plac->channels ; - readcount = readcount > len ? (int) len : readcount ; - - iptr = plac->buffer + plac->partial_block_frames * plac->channels ; - - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * iptr [k] ; - - plac->partial_block_frames += readcount / plac->channels ; - total += readcount ; - len -= readcount ; - } ; - - return total ; -} /* alac_read_d */ - -/*============================================================================================ -*/ - -static sf_count_t -alac_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ ALAC_PRIVATE *plac ; - int newblock, newsample ; - - if (! psf->codec_data) - return 0 ; - plac = (ALAC_PRIVATE*) psf->codec_data ; - - if (psf->datalength < 0 || psf->dataoffset < 0) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (offset == 0) - { psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - plac->frames_this_block = 0 ; - plac->input_data_pos = psf->dataoffset ; - plac->pakt_info->current = 0 ; - return 0 ; - } ; - - if (offset < 0 || offset > plac->pakt_info->count * plac->frames_per_block) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - newblock = offset / plac->frames_per_block ; - newsample = offset % plac->frames_per_block ; - - if (mode == SFM_READ) - { plac->input_data_pos = psf->dataoffset + alac_pakt_block_offset (plac->pakt_info, newblock) ; - - plac->pakt_info->current = newblock ; - alac_decode_block (psf, plac) ; - plac->partial_block_frames = newsample ; - } - else - { /* What to do about write??? */ - psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - return newblock * plac->frames_per_block + newsample ; -} /* alac_seek */ - -/*========================================================================================== -** ALAC Write Functions. -*/ - -static sf_count_t -alac_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ ALAC_PRIVATE *plac ; - int *iptr ; - int k, writecount ; - sf_count_t total = 0 ; - - if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) - return 0 ; - - while (len > 0) - { writecount = (plac->frames_per_block - plac->partial_block_frames) * plac->channels ; - writecount = (writecount == 0 || writecount > len) ? (int) len : writecount ; - - iptr = plac->buffer + plac->partial_block_frames * plac->channels ; - - for (k = 0 ; k < writecount ; k++) - iptr [k] = arith_shift_left (ptr [k], 16) ; - - plac->partial_block_frames += writecount / plac->channels ; - total += writecount ; - len -= writecount ; - ptr += writecount ; - - if (plac->partial_block_frames >= plac->frames_per_block) - alac_encode_block (plac) ; - } ; - - return total ; -} /* alac_write_s */ - -static sf_count_t -alac_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ ALAC_PRIVATE *plac ; - int *iptr ; - int k, writecount ; - sf_count_t total = 0 ; - - if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) - return 0 ; - - while (len > 0) - { writecount = (plac->frames_per_block - plac->partial_block_frames) * plac->channels ; - writecount = (writecount == 0 || writecount > len) ? (int) len : writecount ; - - iptr = plac->buffer + plac->partial_block_frames * plac->channels ; - - for (k = 0 ; k < writecount ; k++) - iptr [k] = ptr [k] ; - - plac->partial_block_frames += writecount / plac->channels ; - total += writecount ; - len -= writecount ; - ptr += writecount ; - - if (plac->partial_block_frames >= plac->frames_per_block) - alac_encode_block (plac) ; - } ; - - return total ; -} /* alac_write_i */ - -static sf_count_t -alac_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ ALAC_PRIVATE *plac ; - void (*convert) (const float *, int *t, int, int) ; - int *iptr ; - int writecount ; - sf_count_t total = 0 ; - - if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) - return 0 ; - - convert = (psf->add_clipping) ? psf_f2i_clip_array : psf_f2i_array ; - - while (len > 0) - { writecount = (plac->frames_per_block - plac->partial_block_frames) * plac->channels ; - writecount = (writecount == 0 || writecount > len) ? (int) len : writecount ; - - iptr = plac->buffer + plac->partial_block_frames * plac->channels ; - - convert (ptr, iptr, writecount, psf->norm_float) ; - - plac->partial_block_frames += writecount / plac->channels ; - total += writecount ; - len -= writecount ; - ptr += writecount ; - - if (plac->partial_block_frames >= plac->frames_per_block) - alac_encode_block (plac) ; - } ; - - return total ; -} /* alac_write_f */ - -static sf_count_t -alac_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ ALAC_PRIVATE *plac ; - void (*convert) (const double *, int *t, int, int) ; - int *iptr ; - int writecount ; - sf_count_t total = 0 ; - - if ((plac = (ALAC_PRIVATE*) psf->codec_data) == NULL) - return 0 ; - - convert = (psf->add_clipping) ? psf_d2i_clip_array : psf_d2i_array ; - - while (len > 0) - { writecount = (plac->frames_per_block - plac->partial_block_frames) * plac->channels ; - writecount = (writecount == 0 || writecount > len) ? (int) len : writecount ; - - iptr = plac->buffer + plac->partial_block_frames * plac->channels ; - - convert (ptr, iptr, writecount, psf->norm_float) ; - - plac->partial_block_frames += writecount / plac->channels ; - total += writecount ; - len -= writecount ; - ptr += writecount ; - - if (plac->partial_block_frames >= plac->frames_per_block) - alac_encode_block (plac) ; - } ; - - return total ; -} /* alac_write_d */ - -/*============================================================================== -** PAKT_INFO handling. -*/ - -static PAKT_INFO * -alac_pakt_alloc (uint32_t initial_count) -{ PAKT_INFO * info ; - - if ((info = calloc (1, sizeof (PAKT_INFO) + initial_count * sizeof (info->packet_size [0]))) == NULL) - return NULL ; - - info->allocated = initial_count ; - info->current = 0 ; - info->count = 0 ; - - return info ; -} /* alac_pakt_alloc */ - -static PAKT_INFO * -alac_pakt_append (PAKT_INFO * info, uint32_t value) -{ - if (info->count >= info->allocated) - { PAKT_INFO * temp ; - uint32_t newcount = info->allocated + info->allocated / 2 ; - - if ((temp = realloc (info, sizeof (PAKT_INFO) + newcount * sizeof (info->packet_size [0]))) == NULL) - return NULL ; - - info = temp ; - info->allocated = newcount ; - } ; - - info->packet_size [info->count++] = value ; - return info ; -} /* alac_pakt_append */ - -static PAKT_INFO * -alac_pakt_read_decode (SF_PRIVATE * psf, uint32_t UNUSED (pakt_offset)) -{ SF_CHUNK_INFO chunk_info ; - PAKT_INFO * info = NULL ; - uint8_t *pakt_data = NULL ; - uint32_t bcount, value = 1, pakt_size ; - SF_CHUNK_ITERATOR * chunk_iterator ; - - - memset (&chunk_info, 0, sizeof (chunk_info)) ; - snprintf (chunk_info.id, sizeof (chunk_info.id), "pakt") ; - chunk_info.id_size = 4 ; - - if ((chunk_iterator = psf_get_chunk_iterator (psf, chunk_info.id)) == NULL) - { psf_log_printf (psf, "%s : no chunk iterator found\n", __func__) ; - free (chunk_info.data) ; - chunk_info.data = NULL ; - return NULL ; - } ; - - psf->get_chunk_size (psf, chunk_iterator, &chunk_info) ; - - pakt_size = chunk_info.datalen ; - chunk_info.data = pakt_data = malloc (pakt_size + 5) ; - if (!chunk_info.data) - return NULL ; - - if ((bcount = psf->get_chunk_data (psf, chunk_iterator, &chunk_info)) != SF_ERR_NO_ERROR) - { while (chunk_iterator) - chunk_iterator = psf->next_chunk_iterator (psf, chunk_iterator) ; - free (chunk_info.data) ; - chunk_info.data = NULL ; - return NULL ; - } ; - - while (chunk_iterator) - chunk_iterator = psf->next_chunk_iterator (psf, chunk_iterator) ; - - info = alac_pakt_alloc (pakt_size / 4) ; - - /* Start at 24 bytes in, skipping over the 'pakt' chunks header. */ - for (bcount = 24 ; bcount < pakt_size && value != 0 ; ) - { uint8_t byte ; - int32_t count = 0 ; - - value = 0 ; - do - { byte = pakt_data [bcount + count] ; - value = (value << 7) + (byte & 0x7F) ; - - count ++ ; - if (count > 5 || bcount + count > pakt_size) - { printf ("%s %d : Ooops! count %" PRIi32 " bcount %" PRIu32 "\n", __func__, __LINE__, count, bcount) ; - value = 0 ; - break ; - } ; - } - while (byte & 0x80) ; - - bcount += count ; - - if ((info = alac_pakt_append (info, value)) == NULL) - goto FreeExit ; - } ; - - free (pakt_data) ; - - return info ; - -FreeExit : - free (pakt_data) ; - free (info) ; - return NULL ; -} /* alac_pakt_read_decode */ - -static uint8_t * -alac_pakt_encode (const SF_PRIVATE *psf, uint32_t * pakt_size_out) -{ const ALAC_PRIVATE *plac ; - const PAKT_INFO *info ; - uint8_t *data ; - uint32_t k, allocated, pakt_size ; - - plac = psf->codec_data ; - info = plac->pakt_info ; - - allocated = 100 + 2 * info->count ; - if ((data = calloc (1, allocated)) == NULL) - return NULL ; - - psf_put_be64 (data, 0, info->count) ; - psf_put_be64 (data, 8, psf->sf.frames) ; - psf_put_be32 (data, 20, kALACDefaultFramesPerPacket - plac->partial_block_frames) ; - - /* Real 'pakt' data starts after 24 byte header. */ - pakt_size = 24 ; - - for (k = 0 ; k < info->count ; k++) - { int32_t value = info->packet_size [k] ; - - if ((value & 0x7f) == value) - { data [pakt_size++] = value ; - continue ; - } ; - - if ((value & 0x3fff) == value) - { data [pakt_size++] = (value >> 7) | 0x80 ; - data [pakt_size++] = value & 0x7f ; - continue ; - } ; - - if ((value & 0x1fffff) == value) - { data [pakt_size++] = (value >> 14) | 0x80 ; - data [pakt_size++] = ((value >> 7) & 0x7f) | 0x80 ; - data [pakt_size++] = value & 0x7f ; - continue ; - } ; - - if ((value & 0x0fffffff) == value) - { data [pakt_size++] = (value >> 21) | 0x80 ; - data [pakt_size++] = ((value >> 14) & 0x7f) | 0x80 ; - data [pakt_size++] = ((value >> 7) & 0x7f) | 0x80 ; - data [pakt_size++] = value & 0x7f ; - continue ; - } ; - - *pakt_size_out = 0 ; - free (data) ; - return NULL ; - } ; - - *pakt_size_out = pakt_size ; - return data ; -} /* alac_pakt_encode */ - -static sf_count_t -alac_pakt_block_offset (const PAKT_INFO *info, uint32_t block) -{ sf_count_t offset = 0 ; - uint32_t k ; - - for (k = 0 ; k < block ; k++) - offset += info->packet_size [k] ; - - return offset ; -} /* alac_pakt_block_offset */ - -static uint32_t -alac_kuki_read (SF_PRIVATE * psf, uint32_t kuki_offset, uint8_t * kuki, size_t kuki_maxlen) -{ uint32_t marker ; - uint64_t kuki_size ; - - if (psf_fseek (psf, kuki_offset, SEEK_SET) != kuki_offset) - return 0 ; - - psf_fread (&marker, 1, sizeof (marker), psf) ; - if (marker != MAKE_MARKER ('k', 'u', 'k', 'i')) - return 0 ; - - psf_fread (&kuki_size, 1, sizeof (kuki_size), psf) ; - kuki_size = BE2H_64 (kuki_size) ; - - if (kuki_size == 0 || kuki_size > kuki_maxlen) - { psf_log_printf (psf, "%s : Bad size (%D) of 'kuki' chunk.\n", __func__, kuki_size) ; - return 0 ; - } ; - - psf_fread (kuki, 1, kuki_size, psf) ; - - return kuki_size ; -} /* alac_kuki_read */ - -#define CASE_NAME(x) case x : return #x ; break ; - -static const char * -alac_error_string (int error) -{ static char errstr [128] ; - switch (error) - { CASE_NAME (kALAC_UnimplementedError) ; - CASE_NAME (kALAC_FileNotFoundError) ; - CASE_NAME (kALAC_ParamError) ; - CASE_NAME (kALAC_MemFullError) ; - CASE_NAME (fALAC_FrameLengthError) ; - - /* Added for libsndfile */ - CASE_NAME (kALAC_BadBitWidth) ; - CASE_NAME (kALAC_IncompatibleVersion) ; - CASE_NAME (kALAC_BadSpecificConfigSize) ; - CASE_NAME (kALAC_ZeroChannelCount) ; - CASE_NAME (kALAC_NumSamplesTooBig) ; - CASE_NAME (kALAC_UnsupportedElement) ; - default : - break ; - } ; - - snprintf (errstr, sizeof (errstr), "Unknown error %d", error) ; - return errstr ; -} /* alac_error_string */ - diff --git a/Engine/lib/libsndfile/src/alaw.c b/Engine/lib/libsndfile/src/alaw.c deleted file mode 100644 index 4be642e59..000000000 --- a/Engine/lib/libsndfile/src/alaw.c +++ /dev/null @@ -1,553 +0,0 @@ -/* -** Copyright (C) 1999-2013 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#include "sndfile.h" -#include "common.h" - -static sf_count_t alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t alaw_write_s2alaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t alaw_write_i2alaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t alaw_write_f2alaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t alaw_write_d2alaw (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static void alaw2s_array (unsigned char *buffer, int count, short *ptr) ; -static void alaw2i_array (unsigned char *buffer, int count, int *ptr) ; -static void alaw2f_array (unsigned char *buffer, int count, float *ptr, float normfact) ; -static void alaw2d_array (unsigned char *buffer, int count, double *ptr, double normfact) ; - -static void s2alaw_array (const short *buffer, int count, unsigned char *ptr) ; -static void i2alaw_array (const int *buffer, int count, unsigned char *ptr) ; -static void f2alaw_array (const float *buffer, int count, unsigned char *ptr, float normfact) ; -static void d2alaw_array (const double *buffer, int count, unsigned char *ptr, double normfact) ; - - -int -alaw_init (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) - { psf->read_short = alaw_read_alaw2s ; - psf->read_int = alaw_read_alaw2i ; - psf->read_float = alaw_read_alaw2f ; - psf->read_double = alaw_read_alaw2d ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { psf->write_short = alaw_write_s2alaw ; - psf->write_int = alaw_write_i2alaw ; - psf->write_float = alaw_write_f2alaw ; - psf->write_double = alaw_write_d2alaw ; - } ; - - psf->bytewidth = 1 ; - psf->blockwidth = psf->sf.channels ; - - if (psf->filelength > psf->dataoffset) - psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset : psf->filelength - psf->dataoffset ; - else - psf->datalength = 0 ; - - psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ; - - return 0 ; -} /* alaw_init */ - -/*============================================================================== - * Private static functions and data. - */ - -static -short alaw_decode [256] = -{ -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, - -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, - -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368, - -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392, - -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944, - -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136, - -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472, - -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568, - -344, -328, -376, -360, -280, -264, -312, -296, - -472, -456, -504, -488, -408, -392, -440, -424, - -88, -72, -120, -104, -24, -8, -56, -40, - -216, -200, -248, -232, -152, -136, -184, -168, - -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184, - -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696, - -688, -656, -752, -720, -560, -528, -624, -592, - -944, -912, -1008, -976, -816, -784, -880, -848, - 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736, - 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784, - 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368, - 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392, - 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944, - 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136, - 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472, - 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568, - 344, 328, 376, 360, 280, 264, 312, 296, - 472, 456, 504, 488, 408, 392, 440, 424, - 88, 72, 120, 104, 24, 8, 56, 40, - 216, 200, 248, 232, 152, 136, 184, 168, - 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184, - 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696, - 688, 656, 752, 720, 560, 528, 624, 592, - 944, 912, 1008, 976, 816, 784, 880, 848 -} ; /* alaw_decode */ - -static -unsigned char alaw_encode [2048 + 1] = -{ 0xd5, 0xd4, 0xd7, 0xd6, 0xd1, 0xd0, 0xd3, 0xd2, 0xdd, 0xdc, 0xdf, 0xde, - 0xd9, 0xd8, 0xdb, 0xda, 0xc5, 0xc4, 0xc7, 0xc6, 0xc1, 0xc0, 0xc3, 0xc2, - 0xcd, 0xcc, 0xcf, 0xce, 0xc9, 0xc8, 0xcb, 0xca, 0xf5, 0xf5, 0xf4, 0xf4, - 0xf7, 0xf7, 0xf6, 0xf6, 0xf1, 0xf1, 0xf0, 0xf0, 0xf3, 0xf3, 0xf2, 0xf2, - 0xfd, 0xfd, 0xfc, 0xfc, 0xff, 0xff, 0xfe, 0xfe, 0xf9, 0xf9, 0xf8, 0xf8, - 0xfb, 0xfb, 0xfa, 0xfa, 0xe5, 0xe5, 0xe5, 0xe5, 0xe4, 0xe4, 0xe4, 0xe4, - 0xe7, 0xe7, 0xe7, 0xe7, 0xe6, 0xe6, 0xe6, 0xe6, 0xe1, 0xe1, 0xe1, 0xe1, - 0xe0, 0xe0, 0xe0, 0xe0, 0xe3, 0xe3, 0xe3, 0xe3, 0xe2, 0xe2, 0xe2, 0xe2, - 0xed, 0xed, 0xed, 0xed, 0xec, 0xec, 0xec, 0xec, 0xef, 0xef, 0xef, 0xef, - 0xee, 0xee, 0xee, 0xee, 0xe9, 0xe9, 0xe9, 0xe9, 0xe8, 0xe8, 0xe8, 0xe8, - 0xeb, 0xeb, 0xeb, 0xeb, 0xea, 0xea, 0xea, 0xea, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0xb5, 0xb5, 0xb5, 0xb5, - 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, - 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, - 0xb5, 0xb5, 0xb5, 0xb5, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, - 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, - 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, - 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, - 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, - 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb6, 0xb6, 0xb6, 0xb6, - 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, - 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, - 0xb6, 0xb6, 0xb6, 0xb6, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, - 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, - 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, - 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, - 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, - 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb3, 0xb3, 0xb3, 0xb3, - 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, - 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, - 0xb3, 0xb3, 0xb3, 0xb3, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, - 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, - 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, - 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, - 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, - 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbc, 0xbc, 0xbc, 0xbc, - 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, - 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, - 0xbc, 0xbc, 0xbc, 0xbc, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, - 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, - 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, - 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, - 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, - 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xb9, 0xb9, 0xb9, 0xb9, - 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, - 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, - 0xb9, 0xb9, 0xb9, 0xb9, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, - 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, - 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xba, 0xba, 0xba, 0xba, - 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, - 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, - 0xba, 0xba, 0xba, 0xba, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa -} ; /* alaw_encode */ - -static inline void -alaw2s_array (unsigned char *buffer, int count, short *ptr) -{ for (int i = 0 ; i < count ; i++) - ptr [i] = alaw_decode [(int) buffer [i]] ; -} /* alaw2s_array */ - -static inline void -alaw2i_array (unsigned char *buffer, int count, int *ptr) -{ for (int i = 0 ; i < count ; i++) - ptr [i] = ((uint32_t) alaw_decode [(int) buffer [i]]) << 16 ; -} /* alaw2i_array */ - -static inline void -alaw2f_array (unsigned char *buffer, int count, float *ptr, float normfact) -{ for (int i = 0 ; i < count ; i++) - ptr [i] = normfact * alaw_decode [(int) buffer [i]] ; -} /* alaw2f_array */ - -static inline void -alaw2d_array (unsigned char *buffer, int count, double *ptr, double normfact) -{ for (int i = 0 ; i < count ; i++) - ptr [i] = normfact * alaw_decode [(int) buffer [i]] ; -} /* alaw2d_array */ - -static inline void -s2alaw_array (const short *ptr, int count, unsigned char *buffer) -{ for (int i = 0 ; i < count ; i++) - { if (ptr [i] >= 0) - buffer [i] = alaw_encode [ptr [i] / 16] ; - else - buffer [i] = 0x7F & alaw_encode [ptr [i] / -16] ; - } ; -} /* s2alaw_array */ - -static inline void -i2alaw_array (const int *ptr, int count, unsigned char *buffer) -{ for (int i = 0 ; i < count ; i++) - { if (ptr [i] == INT_MIN) - buffer [i] = alaw_encode [INT_MAX >> (16 + 4)] ; - else if (ptr [i] >= 0) - buffer [i] = alaw_encode [ptr [i] >> (16 + 4)] ; - else - buffer [i] = 0x7F & alaw_encode [- ptr [i] >> (16 + 4)] ; - } ; -} /* i2alaw_array */ - -static inline void -f2alaw_array (const float *ptr, int count, unsigned char *buffer, float normfact) -{ for (int i = 0 ; i < count ; i++) - { if (ptr [i] >= 0) - buffer [i] = alaw_encode [psf_lrintf (normfact * ptr [i])] ; - else - buffer [i] = 0x7F & alaw_encode [- psf_lrintf (normfact * ptr [i])] ; - } ; -} /* f2alaw_array */ - -static inline void -d2alaw_array (const double *ptr, int count, unsigned char *buffer, double normfact) -{ for (int i = 0 ; i < count ; i++) - { if (!isfinite (ptr [i])) - buffer [i] = 0 ; - else if (ptr [i] >= 0) - buffer [i] = alaw_encode [psf_lrint (normfact * ptr [i])] ; - else - buffer [i] = 0x7F & alaw_encode [- psf_lrint (normfact * ptr [i])] ; - } ; -} /* d2alaw_array */ - -/*============================================================================== -*/ - -static sf_count_t -alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; - alaw2s_array (ubuf.ucbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* alaw_read_alaw2s */ - -static sf_count_t -alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; - alaw2i_array (ubuf.ucbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* alaw_read_alaw2i */ - -static sf_count_t -alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; - alaw2f_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* alaw_read_alaw2f */ - -static sf_count_t -alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double) ? 1.0 / ((double) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; - alaw2d_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* alaw_read_alaw2d */ - -/*============================================================================================= -*/ - -static sf_count_t -alaw_write_s2alaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2alaw_array (ptr + total, bufferlen, ubuf.ucbuf) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* alaw_write_s2alaw */ - -static sf_count_t -alaw_write_i2alaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2alaw_array (ptr + total, bufferlen, ubuf.ucbuf) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* alaw_write_i2alaw */ - -static sf_count_t -alaw_write_f2alaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - float normfact ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) / 16.0 : 1.0 / 16 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - f2alaw_array (ptr + total, bufferlen, ubuf.ucbuf, normfact) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* alaw_write_f2alaw */ - -static sf_count_t -alaw_write_d2alaw (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double) ? (1.0 * 0x7FFF) / 16.0 : 1.0 / 16.0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - d2alaw_array (ptr + total, bufferlen, ubuf.ucbuf, normfact) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* alaw_write_d2alaw */ - diff --git a/Engine/lib/libsndfile/src/au.c b/Engine/lib/libsndfile/src/au.c deleted file mode 100644 index 62bd691d6..000000000 --- a/Engine/lib/libsndfile/src/au.c +++ /dev/null @@ -1,454 +0,0 @@ -/* -** Copyright (C) 1999-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -#define DOTSND_MARKER (MAKE_MARKER ('.', 's', 'n', 'd')) -#define DNSDOT_MARKER (MAKE_MARKER ('d', 'n', 's', '.')) - -#define AU_DATA_OFFSET 24 - -/*------------------------------------------------------------------------------ -** Known AU file encoding types. -*/ - -enum -{ AU_ENCODING_ULAW_8 = 1, /* 8-bit u-law samples */ - AU_ENCODING_PCM_8 = 2, /* 8-bit linear samples */ - AU_ENCODING_PCM_16 = 3, /* 16-bit linear samples */ - AU_ENCODING_PCM_24 = 4, /* 24-bit linear samples */ - AU_ENCODING_PCM_32 = 5, /* 32-bit linear samples */ - - AU_ENCODING_FLOAT = 6, /* floating-point samples */ - AU_ENCODING_DOUBLE = 7, /* double-precision float samples */ - AU_ENCODING_INDIRECT = 8, /* fragmented sampled data */ - AU_ENCODING_NESTED = 9, /* ? */ - AU_ENCODING_DSP_CORE = 10, /* DSP program */ - AU_ENCODING_DSP_DATA_8 = 11, /* 8-bit fixed-point samples */ - AU_ENCODING_DSP_DATA_16 = 12, /* 16-bit fixed-point samples */ - AU_ENCODING_DSP_DATA_24 = 13, /* 24-bit fixed-point samples */ - AU_ENCODING_DSP_DATA_32 = 14, /* 32-bit fixed-point samples */ - - AU_ENCODING_DISPLAY = 16, /* non-audio display data */ - AU_ENCODING_MULAW_SQUELCH = 17, /* ? */ - AU_ENCODING_EMPHASIZED = 18, /* 16-bit linear with emphasis */ - AU_ENCODING_NEXT = 19, /* 16-bit linear with compression (NEXT) */ - AU_ENCODING_COMPRESSED_EMPHASIZED = 20, /* A combination of the two above */ - AU_ENCODING_DSP_COMMANDS = 21, /* Music Kit DSP commands */ - AU_ENCODING_DSP_COMMANDS_SAMPLES = 22, /* ? */ - - AU_ENCODING_ADPCM_G721_32 = 23, /* G721 32 kbs ADPCM - 4 bits per sample. */ - AU_ENCODING_ADPCM_G722 = 24, /* G722 64 kbs ADPCM */ - AU_ENCODING_ADPCM_G723_24 = 25, /* G723 24 kbs ADPCM - 3 bits per sample. */ - AU_ENCODING_ADPCM_G723_40 = 26, /* G723 40 kbs ADPCM - 5 bits per sample. */ - - AU_ENCODING_ALAW_8 = 27 -} ; - -/*------------------------------------------------------------------------------ -** Typedefs. -*/ - -typedef struct -{ int dataoffset ; - int datasize ; - int encoding ; - int samplerate ; - int channels ; -} AU_FMT ; - - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int au_close (SF_PRIVATE *psf) ; - -static int au_format_to_encoding (int format) ; - -static int au_write_header (SF_PRIVATE *psf, int calc_length) ; -static int au_read_header (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -au_open (SF_PRIVATE *psf) -{ int subformat ; - int error = 0 ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = au_read_header (psf))) - return error ; - } ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AU) - return SFE_BAD_OPEN_FORMAT ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { psf->endian = SF_ENDIAN (psf->sf.format) ; - if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU) - psf->endian = SF_ENDIAN_LITTLE ; - else if (psf->endian != SF_ENDIAN_LITTLE) - psf->endian = SF_ENDIAN_BIG ; - - if (au_write_header (psf, SF_FALSE)) - return psf->error ; - - psf->write_header = au_write_header ; - } ; - - psf->container_close = au_close ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - switch (subformat) - { case SF_FORMAT_ULAW : /* 8-bit Ulaw encoding. */ - ulaw_init (psf) ; - break ; - - case SF_FORMAT_PCM_S8 : /* 8-bit linear PCM. */ - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_PCM_16 : /* 16-bit linear PCM. */ - case SF_FORMAT_PCM_24 : /* 24-bit linear PCM */ - case SF_FORMAT_PCM_32 : /* 32-bit linear PCM. */ - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_ALAW : /* 8-bit Alaw encoding. */ - alaw_init (psf) ; - break ; - - /* Lite remove start */ - case SF_FORMAT_FLOAT : /* 32-bit floats. */ - error = float32_init (psf) ; - break ; - - case SF_FORMAT_DOUBLE : /* 64-bit double precision floats. */ - error = double64_init (psf) ; - break ; - - case SF_FORMAT_G721_32 : - error = g72x_init (psf) ; - psf->sf.seekable = SF_FALSE ; - break ; - - case SF_FORMAT_G723_24 : - error = g72x_init (psf) ; - psf->sf.seekable = SF_FALSE ; - break ; - - case SF_FORMAT_G723_40 : - error = g72x_init (psf) ; - psf->sf.seekable = SF_FALSE ; - break ; - /* Lite remove end */ - - default : break ; - } ; - - return error ; -} /* au_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -au_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - au_write_header (psf, SF_TRUE) ; - - return 0 ; -} /* au_close */ - -static int -au_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t current ; - int encoding, datalength ; - - if (psf->pipeoffset > 0) - return 0 ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - } ; - - encoding = au_format_to_encoding (SF_CODEC (psf->sf.format)) ; - if (! encoding) - return (psf->error = SFE_BAD_OPEN_FORMAT) ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - /* - ** Only attempt to seek if we are not writng to a pipe. If we are - ** writing to a pipe we shouldn't be here anyway. - */ - if (psf->is_pipe == SF_FALSE) - psf_fseek (psf, 0, SEEK_SET) ; - - /* - ** AU format files allow a datalength value of -1 if the datalength - ** is not know at the time the header is written. - ** Also use this value of -1 if the datalength > 2 gigabytes. - */ - if (psf->datalength < 0 || psf->datalength > 0x7FFFFFFF) - datalength = -1 ; - else - datalength = (int) (psf->datalength & 0x7FFFFFFF) ; - - if (psf->endian == SF_ENDIAN_BIG) - { psf_binheader_writef (psf, "Em4", BHWm (DOTSND_MARKER), BHW4 (AU_DATA_OFFSET)) ; - psf_binheader_writef (psf, "E4444", BHW4 (datalength), BHW4 (encoding), BHW4 (psf->sf.samplerate), BHW4 (psf->sf.channels)) ; - } - else if (psf->endian == SF_ENDIAN_LITTLE) - { psf_binheader_writef (psf, "em4", BHWm (DNSDOT_MARKER), BHW4 (AU_DATA_OFFSET)) ; - psf_binheader_writef (psf, "e4444", BHW4 (datalength), BHW4 (encoding), BHW4 (psf->sf.samplerate), BHW4 (psf->sf.channels)) ; - } - else - return (psf->error = SFE_BAD_OPEN_FORMAT) ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* au_write_header */ - -static int -au_format_to_encoding (int format) -{ - switch (format) - { case SF_FORMAT_PCM_S8 : return AU_ENCODING_PCM_8 ; - case SF_FORMAT_PCM_16 : return AU_ENCODING_PCM_16 ; - case SF_FORMAT_PCM_24 : return AU_ENCODING_PCM_24 ; - case SF_FORMAT_PCM_32 : return AU_ENCODING_PCM_32 ; - - case SF_FORMAT_FLOAT : return AU_ENCODING_FLOAT ; - case SF_FORMAT_DOUBLE : return AU_ENCODING_DOUBLE ; - - case SF_FORMAT_ULAW : return AU_ENCODING_ULAW_8 ; - case SF_FORMAT_ALAW : return AU_ENCODING_ALAW_8 ; - - case SF_FORMAT_G721_32 : return AU_ENCODING_ADPCM_G721_32 ; - case SF_FORMAT_G723_24 : return AU_ENCODING_ADPCM_G723_24 ; - case SF_FORMAT_G723_40 : return AU_ENCODING_ADPCM_G723_40 ; - - default : break ; - } ; - return 0 ; -} /* au_format_to_encoding */ - -static int -au_read_header (SF_PRIVATE *psf) -{ AU_FMT au_fmt ; - int marker, dword ; - - memset (&au_fmt, 0, sizeof (au_fmt)) ; - psf_binheader_readf (psf, "pm", 0, &marker) ; - psf_log_printf (psf, "%M\n", marker) ; - - if (marker == DOTSND_MARKER) - { psf->endian = SF_ENDIAN_BIG ; - - psf_binheader_readf (psf, "E44444", &(au_fmt.dataoffset), &(au_fmt.datasize), - &(au_fmt.encoding), &(au_fmt.samplerate), &(au_fmt.channels)) ; - } - else if (marker == DNSDOT_MARKER) - { psf->endian = SF_ENDIAN_LITTLE ; - psf_binheader_readf (psf, "e44444", &(au_fmt.dataoffset), &(au_fmt.datasize), - &(au_fmt.encoding), &(au_fmt.samplerate), &(au_fmt.channels)) ; - } - else - return SFE_AU_NO_DOTSND ; - - psf_log_printf (psf, " Data Offset : %d\n", au_fmt.dataoffset) ; - - if (psf->fileoffset > 0 && au_fmt.datasize == -1) - { psf_log_printf (psf, " Data Size : -1\n") ; - return SFE_AU_EMBED_BAD_LEN ; - } ; - - if (psf->fileoffset > 0) - { psf->filelength = au_fmt.dataoffset + au_fmt.datasize ; - psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ; - } - else if (au_fmt.datasize == -1 || au_fmt.dataoffset + au_fmt.datasize == psf->filelength) - psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ; - else if (au_fmt.dataoffset + au_fmt.datasize < psf->filelength) - { psf->filelength = au_fmt.dataoffset + au_fmt.datasize ; - psf_log_printf (psf, " Data Size : %d\n", au_fmt.datasize) ; - } - else - { dword = psf->filelength - au_fmt.dataoffset ; - psf_log_printf (psf, " Data Size : %d (should be %d)\n", au_fmt.datasize, dword) ; - au_fmt.datasize = dword ; - } ; - - psf->dataoffset = au_fmt.dataoffset ; - psf->datalength = psf->filelength - psf->dataoffset ; - - if (psf_ftell (psf) < psf->dataoffset) - psf_binheader_readf (psf, "j", psf->dataoffset - psf_ftell (psf)) ; - - psf->sf.samplerate = au_fmt.samplerate ; - psf->sf.channels = au_fmt.channels ; - - /* Only fill in type major. */ - if (psf->endian == SF_ENDIAN_BIG) - psf->sf.format = SF_FORMAT_AU ; - else if (psf->endian == SF_ENDIAN_LITTLE) - psf->sf.format = SF_ENDIAN_LITTLE | SF_FORMAT_AU ; - - psf_log_printf (psf, " Encoding : %d => ", au_fmt.encoding) ; - - psf->sf.format = SF_ENDIAN (psf->sf.format) ; - - switch (au_fmt.encoding) - { case AU_ENCODING_ULAW_8 : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_ULAW ; - psf->bytewidth = 1 ; /* Before decoding */ - psf_log_printf (psf, "8-bit ISDN u-law\n") ; - break ; - - case AU_ENCODING_PCM_8 : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_PCM_S8 ; - psf->bytewidth = 1 ; - psf_log_printf (psf, "8-bit linear PCM\n") ; - break ; - - case AU_ENCODING_PCM_16 : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_PCM_16 ; - psf->bytewidth = 2 ; - psf_log_printf (psf, "16-bit linear PCM\n") ; - break ; - - case AU_ENCODING_PCM_24 : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_PCM_24 ; - psf->bytewidth = 3 ; - psf_log_printf (psf, "24-bit linear PCM\n") ; - break ; - - case AU_ENCODING_PCM_32 : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_PCM_32 ; - psf->bytewidth = 4 ; - psf_log_printf (psf, "32-bit linear PCM\n") ; - break ; - - case AU_ENCODING_FLOAT : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_FLOAT ; - psf->bytewidth = 4 ; - psf_log_printf (psf, "32-bit float\n") ; - break ; - - case AU_ENCODING_DOUBLE : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_DOUBLE ; - psf->bytewidth = 8 ; - psf_log_printf (psf, "64-bit double precision float\n") ; - break ; - - case AU_ENCODING_ALAW_8 : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_ALAW ; - psf->bytewidth = 1 ; /* Before decoding */ - psf_log_printf (psf, "8-bit ISDN A-law\n") ; - break ; - - case AU_ENCODING_ADPCM_G721_32 : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_G721_32 ; - psf->bytewidth = 0 ; - psf_log_printf (psf, "G721 32kbs ADPCM\n") ; - break ; - - case AU_ENCODING_ADPCM_G723_24 : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_G723_24 ; - psf->bytewidth = 0 ; - psf_log_printf (psf, "G723 24kbs ADPCM\n") ; - break ; - - case AU_ENCODING_ADPCM_G723_40 : - psf->sf.format |= SF_FORMAT_AU | SF_FORMAT_G723_40 ; - psf->bytewidth = 0 ; - psf_log_printf (psf, "G723 40kbs ADPCM\n") ; - break ; - - case AU_ENCODING_ADPCM_G722 : - psf_log_printf (psf, "G722 64 kbs ADPCM (unsupported)\n") ; - break ; - - case AU_ENCODING_NEXT : - psf_log_printf (psf, "Weird NeXT encoding format (unsupported)\n") ; - break ; - - default : - psf_log_printf (psf, "Unknown!!\n") ; - break ; - } ; - - psf_log_printf (psf, " Sample Rate : %d\n", au_fmt.samplerate) ; - if (au_fmt.channels < 1) - { psf_log_printf (psf, " Channels : %d **** should be >= 1\n", au_fmt.channels) ; - return SFE_CHANNEL_COUNT_ZERO ; - } - else if (au_fmt.channels > SF_MAX_CHANNELS) - { psf_log_printf (psf, " Channels : %d **** should be <= %d\n", au_fmt.channels, SF_MAX_CHANNELS) ; - return SFE_CHANNEL_COUNT ; - } ; - - psf_log_printf (psf, " Channels : %d\n", au_fmt.channels) ; - - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - if (! psf->sf.frames && psf->blockwidth) - psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - - return 0 ; -} /* au_read_header */ - diff --git a/Engine/lib/libsndfile/src/audio_detect.c b/Engine/lib/libsndfile/src/audio_detect.c deleted file mode 100644 index b2671e8d8..000000000 --- a/Engine/lib/libsndfile/src/audio_detect.c +++ /dev/null @@ -1,107 +0,0 @@ -/* -** Copyright (C) 1999-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#include "sfconfig.h" - -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include -#include - -#include "common.h" - -typedef struct -{ int le_float ; - int be_float ; - int le_int_24_32 ; - int be_int_24_32 ; -} VOTE ; - - -static void vote_for_format (VOTE * vote, const unsigned char * data, int datalen) ; - -int -audio_detect (SF_PRIVATE * psf, AUDIO_DETECT *ad, const unsigned char * data, int datalen) -{ VOTE vote ; - - if (psf == NULL) - return 0 ; - - if (ad == NULL || datalen < 256) - return 0 ; - - vote_for_format (&vote, data, datalen) ; - - psf_log_printf (psf, "audio_detect :\n" - " le_float : %d\n" - " be_float : %d\n" - " le_int_24_32 : %d\n" - " be_int_24_32 : %d\n", - vote.le_float, vote.be_float, vote.le_int_24_32, vote.be_int_24_32) ; - - if (0) puts (psf->parselog.buf) ; - - if (ad->endianness == SF_ENDIAN_LITTLE && vote.le_float > (3 * datalen) / 4) - { /* Almost certainly 32 bit floats. */ - return SF_FORMAT_FLOAT ; - } ; - - if (ad->endianness == SF_ENDIAN_LITTLE && vote.le_int_24_32 > (3 * datalen) / 4) - { /* Almost certainly 24 bit data stored in 32 bit ints. */ - return SF_FORMAT_PCM_32 ; - } ; - - return 0 ; -} /* data_detect */ - -static void -vote_for_format (VOTE * vote, const unsigned char * data, int datalen) -{ - int k ; - - memset (vote, 0, sizeof (VOTE)) ; - - datalen -= datalen % 4 ; - - for (k = 0 ; k < datalen ; k ++) - { if ((k % 4) == 0) - { if (data [k] == 0 && data [k + 1] != 0) - vote->le_int_24_32 += 4 ; - - if (data [2] != 0 && data [3] == 0) - vote->le_int_24_32 += 4 ; - - if (data [0] != 0 && data [3] > 0x43 && data [3] < 0x4B) - vote->le_float += 4 ; - - if (data [3] != 0 && data [0] > 0x43 && data [0] < 0x4B) - vote->be_float += 4 ; - } ; - } ; - - return ; -} /* vote_for_format */ - diff --git a/Engine/lib/libsndfile/src/avr.c b/Engine/lib/libsndfile/src/avr.c deleted file mode 100644 index 6c78ff69b..000000000 --- a/Engine/lib/libsndfile/src/avr.c +++ /dev/null @@ -1,244 +0,0 @@ -/* -** Copyright (C) 2004-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#define TWOBIT_MARKER (MAKE_MARKER ('2', 'B', 'I', 'T')) -#define AVR_HDR_SIZE 128 - -/* -** From: hyc@hanauma.Jpl.Nasa.Gov (Howard Chu) -** -** A lot of PD software exists to play Mac .snd files on the ST. One other -** format that seems pretty popular (used by a number of commercial packages) -** is the AVR format (from Audio Visual Research). This format has a 128 byte -** header that looks like this (its actually packed, but thats not portable): -*/ - -typedef struct -{ int marker ; /* 2BIT */ - char name [8] ; /* null-padded sample name */ - short mono ; /* 0 = mono, 0xffff = stereo */ - short rez ; /* 8 = 8 bit, 16 = 16 bit */ - short sign ; /* 0 = unsigned, 0xffff = signed */ - - short loop ; /* 0 = no loop, 0xffff = looping sample */ - short midi ; /* 0xffff = no MIDI note assigned, */ - /* 0xffXX = single key note assignment */ - /* 0xLLHH = key split, low/hi note */ - int srate ; /* sample frequency in hertz */ - int frames ; /* sample length in bytes or words (see rez) */ - int lbeg ; /* offset to start of loop in bytes or words. */ - /* set to zero if unused */ - int lend ; /* offset to end of loop in bytes or words. */ - /* set to sample length if unused */ - short res1 ; /* Reserved, MIDI keyboard split */ - short res2 ; /* Reserved, sample compression */ - short res3 ; /* Reserved */ - char ext [20] ; /* Additional filename space, used if (name[7] != 0) */ - char user [64] ; /* User defined. Typically ASCII message */ -} AVR_HEADER ; - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int avr_close (SF_PRIVATE *psf) ; - -static int avr_read_header (SF_PRIVATE *psf) ; -static int avr_write_header (SF_PRIVATE *psf, int calc_length) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -avr_open (SF_PRIVATE *psf) -{ int error = 0 ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = avr_read_header (psf))) - return error ; - } ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_AVR) - return SFE_BAD_OPEN_FORMAT ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { psf->endian = SF_ENDIAN_BIG ; - - if (avr_write_header (psf, SF_FALSE)) - return psf->error ; - - psf->write_header = avr_write_header ; - } ; - - psf->container_close = avr_close ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - error = pcm_init (psf) ; - - return error ; -} /* avr_open */ - -static int -avr_read_header (SF_PRIVATE *psf) -{ AVR_HEADER hdr ; - - memset (&hdr, 0, sizeof (hdr)) ; - - psf_binheader_readf (psf, "pmb", 0, &hdr.marker, &hdr.name, sizeof (hdr.name)) ; - psf_log_printf (psf, "%M\n", hdr.marker) ; - - if (hdr.marker != TWOBIT_MARKER) - return SFE_AVR_NOT_AVR ; - - psf_log_printf (psf, " Name : %s\n", hdr.name) ; - - psf_binheader_readf (psf, "E22222", &hdr.mono, &hdr.rez, &hdr.sign, &hdr.loop, &hdr.midi) ; - - psf->sf.channels = (hdr.mono & 1) + 1 ; - - psf_log_printf (psf, " Channels : %d\n Bit width : %d\n Signed : %s\n", - (hdr.mono & 1) + 1, hdr.rez, hdr.sign ? "yes" : "no") ; - - switch (arith_shift_left (hdr.rez, 16) + (hdr.sign & 1)) - { case ((8 << 16) + 0) : - psf->sf.format = SF_FORMAT_AVR | SF_FORMAT_PCM_U8 ; - psf->bytewidth = 1 ; - break ; - - case ((8 << 16) + 1) : - psf->sf.format = SF_FORMAT_AVR | SF_FORMAT_PCM_S8 ; - psf->bytewidth = 1 ; - break ; - - case ((16 << 16) + 1) : - psf->sf.format = SF_FORMAT_AVR | SF_FORMAT_PCM_16 ; - psf->bytewidth = 2 ; - break ; - - default : - psf_log_printf (psf, "Error : bad rez/sign combination.\n") ; - return SFE_AVR_BAD_REZ_SIGN ; - } ; - - psf_binheader_readf (psf, "E4444", &hdr.srate, &hdr.frames, &hdr.lbeg, &hdr.lend) ; - - psf->sf.frames = hdr.frames ; - psf->sf.samplerate = hdr.srate ; - - psf_log_printf (psf, " Frames : %D\n", psf->sf.frames) ; - psf_log_printf (psf, " Sample rate : %d\n", psf->sf.samplerate) ; - - psf_binheader_readf (psf, "E222", &hdr.res1, &hdr.res2, &hdr.res3) ; - psf_binheader_readf (psf, "bb", hdr.ext, sizeof (hdr.ext), hdr.user, sizeof (hdr.user)) ; - - psf_log_printf (psf, " Ext : %s\n User : %s\n", hdr.ext, hdr.user) ; - - psf->endian = SF_ENDIAN_BIG ; - - psf->dataoffset = AVR_HDR_SIZE ; - psf->datalength = hdr.frames * (hdr.rez / 8) ; - - if (psf->fileoffset > 0) - psf->filelength = AVR_HDR_SIZE + psf->datalength ; - - if (psf_ftell (psf) != psf->dataoffset) - psf_binheader_readf (psf, "j", psf->dataoffset - psf_ftell (psf)) ; - - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - if (psf->sf.frames == 0 && psf->blockwidth) - psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - - return 0 ; -} /* avr_read_header */ - -static int -avr_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t current ; - int sign ; - - if (psf->pipeoffset > 0) - return 0 ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - /* - ** Only attempt to seek if we are not writng to a pipe. If we are - ** writing to a pipe we shouldn't be here anyway. - */ - if (psf->is_pipe == SF_FALSE) - psf_fseek (psf, 0, SEEK_SET) ; - - psf_binheader_writef (psf, "Emz22", BHWm (TWOBIT_MARKER), BHWz (8), - BHW2 (psf->sf.channels == 2 ? 0xFFFF : 0), BHW2 (psf->bytewidth * 8)) ; - - sign = ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_U8) ? 0 : 0xFFFF ; - - psf_binheader_writef (psf, "E222", BHW2 (sign), BHW2 (0), BHW2 (0xFFFF)) ; - psf_binheader_writef (psf, "E4444", BHW4 (psf->sf.samplerate), BHW4 (psf->sf.frames), BHW4 (0), BHW4 (0)) ; - - psf_binheader_writef (psf, "E222zz", BHW2 (0), BHW2 (0), BHW2 (0), BHWz (20), BHWz (64)) ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* avr_write_header */ - -static int -avr_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - avr_write_header (psf, SF_TRUE) ; - - return 0 ; -} /* avr_close */ - diff --git a/Engine/lib/libsndfile/src/binheader_writef_check.py b/Engine/lib/libsndfile/src/binheader_writef_check.py deleted file mode 100644 index 09ebc92e0..000000000 --- a/Engine/lib/libsndfile/src/binheader_writef_check.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/python - -# Copyright (C) 2006-2017 Erik de Castro Lopo -# -# 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 author nor the names of any 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. - - -# This parses C code using regexes (yes, thats horrible) and makes sure -# that calling conventions to the function psf_binheader_writef are -# correct. - - - -import re, string, sys - -_whitespace_re = re.compile ("\s+", re.MULTILINE) - -def find_binheader_writefs (data): - lst = re.findall ('psf_binheader_writef\s*\(\s*[a-zA-Z_]+\s*,\s*\"[^;]+;', data, re.MULTILINE) - return [_whitespace_re.sub (" ", x) for x in lst] - -def find_format_string (s): - fmt = re.search ('"([^"]+)"', s) - if not fmt: - print ("Bad format in :\n\n\t%s\n\n" % s) - sys.exit (1) - fmt = fmt.groups () - if len (fmt) != 1: - print ("Bad format in :\n\n\t%s\n\n" % s) - sys.exit (1) - return _whitespace_re.sub ("", fmt [0]) - -def get_param_list (data): - dlist = re.search ("\((.+)\)\s*;", data) - dlist = dlist.groups ()[0] - dlist = dlist.split(",") - dlist = [x.strip() for x in dlist] - return dlist [2:] - -def handle_file (fname): - errors = 0 - data = open (fname, "r").read () - - # return errors - - writefs = find_binheader_writefs (data) - for item in writefs: - fmt = find_format_string (item) - params = get_param_list (item) - param_index = 0 - - # print item - - for ch in fmt: - if ch in 'Eet ': - continue - - if ch == 'b': - if params [param_index][:4] == "BHWv" and params [param_index + 1][:4] == "BHWz": - param_index += 2 - continue - - if "BHW" + ch == params [param_index][:4]: - param_index += 1 - continue - - if errors == 0: sys.stdout.write ("\n") - print ("\n%s: error for format specifier '%c' (index %d) in:\n %s\n" % (fname, ch, param_index, item)) - errors += 1 - # Break out of 'for ch in fmt' loop - break - - return errors - -#=============================================================================== - -if len (sys.argv) > 1: - sys.stdout.write ("\n binheader_writef_check : ") - sys.stdout.flush () - errors = 0 - for fname in sys.argv [1:]: - errors += handle_file (fname) - if errors > 0: - print ("\nErrors : %d\n" % errors) - sys.exit (1) - -print ("ok\n") - diff --git a/Engine/lib/libsndfile/src/broadcast.c b/Engine/lib/libsndfile/src/broadcast.c deleted file mode 100644 index aad5f880d..000000000 --- a/Engine/lib/libsndfile/src/broadcast.c +++ /dev/null @@ -1,190 +0,0 @@ -/* -** Copyright (C) 2006-2016 Erik de Castro Lopo -** Copyright (C) 2006 Paul Davis -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "common.h" - - -static int gen_coding_history (char * added_history, int added_history_max, const SF_INFO * psfinfo) ; - -static inline size_t -bc_min_size (const SF_BROADCAST_INFO* info) -{ if (info == NULL) - return 0 ; - - return offsetof (SF_BROADCAST_INFO, coding_history) + info->coding_history_size ; -} /* bc_min_size */ - -SF_BROADCAST_INFO_16K* -broadcast_var_alloc (void) -{ return calloc (1, sizeof (SF_BROADCAST_INFO_16K)) ; -} /* broadcast_var_alloc */ - -int -broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datasize) -{ size_t len ; - - if (info == NULL) - return SF_FALSE ; - - if (bc_min_size (info) > datasize) - { psf->error = SFE_BAD_BROADCAST_INFO_SIZE ; - return SF_FALSE ; - } ; - - if (datasize >= sizeof (SF_BROADCAST_INFO_16K)) - { psf->error = SFE_BAD_BROADCAST_INFO_TOO_BIG ; - return SF_FALSE ; - } ; - - if (psf->broadcast_16k == NULL) - { if ((psf->broadcast_16k = broadcast_var_alloc ()) == NULL) - { psf->error = SFE_MALLOC_FAILED ; - return SF_FALSE ; - } ; - } ; - - /* Only copy the first part of the struct. */ - memcpy (psf->broadcast_16k, info, offsetof (SF_BROADCAST_INFO, coding_history)) ; - - psf_strlcpy_crlf (psf->broadcast_16k->coding_history, info->coding_history, sizeof (psf->broadcast_16k->coding_history), datasize - offsetof (SF_BROADCAST_INFO, coding_history)) ; - len = strlen (psf->broadcast_16k->coding_history) ; - - if (len > 0 && psf->broadcast_16k->coding_history [len - 1] != '\n') - psf_strlcat (psf->broadcast_16k->coding_history, sizeof (psf->broadcast_16k->coding_history), "\r\n") ; - - if (psf->file.mode == SFM_WRITE) - { char added_history [256] ; - - gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ; - psf_strlcat (psf->broadcast_16k->coding_history, sizeof (psf->broadcast_16k->coding_history), added_history) ; - } ; - - /* Force coding_history_size to be even. */ - len = strlen (psf->broadcast_16k->coding_history) ; - len += (len & 1) ? 1 : 0 ; - psf->broadcast_16k->coding_history_size = (uint32_t) len ; - - /* Currently writing this version. */ - psf->broadcast_16k->version = 2 ; - - return SF_TRUE ; -} /* broadcast_var_set */ - - -int -broadcast_var_get (SF_PRIVATE *psf, SF_BROADCAST_INFO * data, size_t datasize) -{ size_t size ; - - if (psf->broadcast_16k == NULL) - return SF_FALSE ; - - size = SF_MIN (datasize, bc_min_size ((const SF_BROADCAST_INFO *) psf->broadcast_16k)) ; - - memcpy (data, psf->broadcast_16k, size) ; - - return SF_TRUE ; -} /* broadcast_var_get */ - -/*------------------------------------------------------------------------------ -*/ - -static int -gen_coding_history (char * added_history, int added_history_max, const SF_INFO * psfinfo) -{ char chnstr [16] ; - int count, width ; - - /* - ** From : http://www.sr.se/utveckling/tu/bwf/docs/codhist2.htm - ** - ** Parameter Variable string Unit - ** ========================================================================================== - ** Coding Algorithm A= - ** Sampling frequency F=<11000,22050,24000,32000,44100,48000> [Hz] - ** Bit-rate B= - ** Word Length W=<8, 12, 14, 16, 18, 20, 22, 24> [bits] - ** Mode M= - ** Text, free string T= - */ - - switch (psfinfo->channels) - { case 0 : - return SF_FALSE ; - - case 1 : - psf_strlcpy (chnstr, sizeof (chnstr), "mono") ; - break ; - - case 2 : - psf_strlcpy (chnstr, sizeof (chnstr), "stereo") ; - break ; - - default : - snprintf (chnstr, sizeof (chnstr), "%dchn", psfinfo->channels) ; - break ; - } ; - - switch (SF_CODEC (psfinfo->format)) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_S8 : - width = 8 ; - break ; - case SF_FORMAT_PCM_16 : - width = 16 ; - break ; - case SF_FORMAT_PCM_24 : - width = 24 ; - break ; - case SF_FORMAT_PCM_32 : - width = 32 ; - break ; - case SF_FORMAT_FLOAT : - width = 24 ; /* Bits in the mantissa + 1 */ - break ; - case SF_FORMAT_DOUBLE : - width = 53 ; /* Bits in the mantissa + 1 */ - break ; - case SF_FORMAT_ULAW : - case SF_FORMAT_ALAW : - width = 12 ; - break ; - default : - width = 42 ; - break ; - } ; - - count = snprintf (added_history, added_history_max, - "A=PCM,F=%d,W=%d,M=%s,T=%s-%s\r\n", - psfinfo->samplerate, width, chnstr, PACKAGE_NAME, PACKAGE_VERSION) ; - - if (count >= added_history_max) - return 0 ; - - return count ; -} /* gen_coding_history */ diff --git a/Engine/lib/libsndfile/src/caf.c b/Engine/lib/libsndfile/src/caf.c deleted file mode 100644 index a886bf562..000000000 --- a/Engine/lib/libsndfile/src/caf.c +++ /dev/null @@ -1,1034 +0,0 @@ -/* -** Copyright (C) 2005-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "chanmap.h" - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -#define aac_MARKER MAKE_MARKER ('a', 'a', 'c', ' ') -#define alac_MARKER MAKE_MARKER ('a', 'l', 'a', 'c') -#define alaw_MARKER MAKE_MARKER ('a', 'l', 'a', 'w') -#define caff_MARKER MAKE_MARKER ('c', 'a', 'f', 'f') -#define chan_MARKER MAKE_MARKER ('c', 'h', 'a', 'n') -#define data_MARKER MAKE_MARKER ('d', 'a', 't', 'a') -#define desc_MARKER MAKE_MARKER ('d', 'e', 's', 'c') -#define edct_MARKER MAKE_MARKER ('e', 'd', 'c', 't') -#define free_MARKER MAKE_MARKER ('f', 'r', 'e', 'e') -#define ima4_MARKER MAKE_MARKER ('i', 'm', 'a', '4') -#define info_MARKER MAKE_MARKER ('i', 'n', 'f', 'o') -#define inst_MARKER MAKE_MARKER ('i', 'n', 's', 't') -#define kuki_MARKER MAKE_MARKER ('k', 'u', 'k', 'i') -#define lpcm_MARKER MAKE_MARKER ('l', 'p', 'c', 'm') -#define mark_MARKER MAKE_MARKER ('m', 'a', 'r', 'k') -#define midi_MARKER MAKE_MARKER ('m', 'i', 'd', 'i') -#define mp1_MARKER MAKE_MARKER ('.', 'm', 'p', '1') -#define mp2_MARKER MAKE_MARKER ('.', 'm', 'p', '2') -#define mp3_MARKER MAKE_MARKER ('.', 'm', 'p', '3') -#define ovvw_MARKER MAKE_MARKER ('o', 'v', 'v', 'w') -#define pakt_MARKER MAKE_MARKER ('p', 'a', 'k', 't') -#define peak_MARKER MAKE_MARKER ('p', 'e', 'a', 'k') -#define regn_MARKER MAKE_MARKER ('r', 'e', 'g', 'n') -#define strg_MARKER MAKE_MARKER ('s', 't', 'r', 'g') -#define umid_MARKER MAKE_MARKER ('u', 'm', 'i', 'd') -#define uuid_MARKER MAKE_MARKER ('u', 'u', 'i', 'd') -#define ulaw_MARKER MAKE_MARKER ('u', 'l', 'a', 'w') -#define MAC3_MARKER MAKE_MARKER ('M', 'A', 'C', '3') -#define MAC6_MARKER MAKE_MARKER ('M', 'A', 'C', '6') - -#define CAF_PEAK_CHUNK_SIZE(ch) ((int) (sizeof (int) + ch * (sizeof (float) + 8))) - -/*------------------------------------------------------------------------------ -** Typedefs. -*/ - -typedef struct -{ uint8_t srate [8] ; - uint32_t fmt_id ; - uint32_t fmt_flags ; - uint32_t pkt_bytes ; - uint32_t frames_per_packet ; - uint32_t channels_per_frame ; - uint32_t bits_per_chan ; -} DESC_CHUNK ; - -typedef struct -{ int chanmap_tag ; - - ALAC_DECODER_INFO alac ; -} CAF_PRIVATE ; - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int caf_close (SF_PRIVATE *psf) ; -static int caf_read_header (SF_PRIVATE *psf) ; -static int caf_write_header (SF_PRIVATE *psf, int calc_length) ; -static int caf_write_tailer (SF_PRIVATE *psf) ; -static int caf_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; -static int caf_read_chanmap (SF_PRIVATE * psf, sf_count_t chunk_size) ; -static int caf_read_strings (SF_PRIVATE * psf, sf_count_t chunk_size) ; -static void caf_write_strings (SF_PRIVATE * psf, int location) ; - - -static int caf_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) ; -static SF_CHUNK_ITERATOR * caf_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) ; -static int caf_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; -static int caf_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -caf_open (SF_PRIVATE *psf) -{ CAF_PRIVATE * pcaf ; - int subformat, format, error = 0 ; - - if ((psf->container_data = calloc (1, sizeof (CAF_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - - pcaf = psf->container_data ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = caf_read_header (psf))) - return error ; - - psf->next_chunk_iterator = caf_next_chunk_iterator ; - psf->get_chunk_size = caf_get_chunk_size ; - psf->get_chunk_data = caf_get_chunk_data ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (psf->is_pipe) - return SFE_NO_PIPE_WRITE ; - - format = SF_CONTAINER (psf->sf.format) ; - if (format != SF_FORMAT_CAF) - return SFE_BAD_OPEN_FORMAT ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - if (psf->file.mode != SFM_RDWR || psf->filelength < 44) - { psf->filelength = 0 ; - psf->datalength = 0 ; - psf->dataoffset = 0 ; - psf->sf.frames = 0 ; - } ; - - psf->strings.flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ; - - /* - ** By default, add the peak chunk to floating point files. Default behaviour - ** can be switched off using sf_command (SFC_SET_PEAK_CHUNK, SF_FALSE). - */ - if (psf->file.mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)) - { if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL) - return SFE_MALLOC_FAILED ; - psf->peak_info->peak_loc = SF_PEAK_START ; - } ; - - if ((error = caf_write_header (psf, SF_FALSE)) != 0) - return error ; - - psf->write_header = caf_write_header ; - psf->set_chunk = caf_set_chunk ; - } ; - - psf->container_close = caf_close ; - psf->command = caf_command ; - - switch (subformat) - { case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_ULAW : - error = ulaw_init (psf) ; - break ; - - case SF_FORMAT_ALAW : - error = alaw_init (psf) ; - break ; - - /* Lite remove start */ - case SF_FORMAT_FLOAT : - error = float32_init (psf) ; - break ; - - case SF_FORMAT_DOUBLE : - error = double64_init (psf) ; - break ; - - case SF_FORMAT_ALAC_16 : - case SF_FORMAT_ALAC_20 : - case SF_FORMAT_ALAC_24 : - case SF_FORMAT_ALAC_32 : - if (psf->file.mode == SFM_READ) - /* Only pass the ALAC_DECODER_INFO in read mode. */ - error = alac_init (psf, &pcaf->alac) ; - else - error = alac_init (psf, NULL) ; - break ; - - /* Lite remove end */ - - default : - return SFE_UNSUPPORTED_ENCODING ; - } ; - - return error ; -} /* caf_open */ - -static int -caf_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { caf_write_tailer (psf) ; - caf_write_header (psf, SF_TRUE) ; - } ; - - return 0 ; -} /* caf_close */ - -static int -caf_command (SF_PRIVATE * psf, int command, void * UNUSED (data), int UNUSED (datasize)) -{ CAF_PRIVATE *pcaf ; - - if ((pcaf = psf->container_data) == NULL) - return SFE_INTERNAL ; - - switch (command) - { case SFC_SET_CHANNEL_MAP_INFO : - pcaf->chanmap_tag = aiff_caf_find_channel_layout_tag (psf->channel_map, psf->sf.channels) ; - return (pcaf->chanmap_tag != 0) ; - - default : - break ; - } ; - - return 0 ; -} /* caf_command */ - -/*------------------------------------------------------------------------------ -*/ - -static int -decode_desc_chunk (SF_PRIVATE *psf, const DESC_CHUNK *desc) -{ int format = SF_FORMAT_CAF ; - - psf->sf.channels = desc->channels_per_frame ; - - if (desc->fmt_id == alac_MARKER) - { CAF_PRIVATE *pcaf ; - - if ((pcaf = psf->container_data) != NULL) - { switch (desc->fmt_flags) - { case 1 : - pcaf->alac.bits_per_sample = 16 ; - format |= SF_FORMAT_ALAC_16 ; - break ; - case 2 : - pcaf->alac.bits_per_sample = 20 ; - format |= SF_FORMAT_ALAC_20 ; - break ; - case 3 : - pcaf->alac.bits_per_sample = 24 ; - format |= SF_FORMAT_ALAC_24 ; - break ; - case 4 : - pcaf->alac.bits_per_sample = 32 ; - format |= SF_FORMAT_ALAC_32 ; - break ; - default : - psf_log_printf (psf, "Bad ALAC format flag value of %d\n", desc->fmt_flags) ; - } ; - - pcaf->alac.frames_per_packet = desc->frames_per_packet ; - } ; - - return format ; - } ; - - format |= psf->endian == SF_ENDIAN_LITTLE ? SF_ENDIAN_LITTLE : 0 ; - - if (desc->fmt_id == lpcm_MARKER && desc->fmt_flags & 1) - { /* Floating point data. */ - if (desc->bits_per_chan == 32 && desc->pkt_bytes == 4 * desc->channels_per_frame) - { psf->bytewidth = 4 ; - return format | SF_FORMAT_FLOAT ; - } ; - if (desc->bits_per_chan == 64 && desc->pkt_bytes == 8 * desc->channels_per_frame) - { psf->bytewidth = 8 ; - return format | SF_FORMAT_DOUBLE ; - } ; - } ; - - if (desc->fmt_id == lpcm_MARKER && (desc->fmt_flags & 1) == 0) - { /* Integer data. */ - if (desc->bits_per_chan == 32 && desc->pkt_bytes == 4 * desc->channels_per_frame) - { psf->bytewidth = 4 ; - return format | SF_FORMAT_PCM_32 ; - } ; - if (desc->bits_per_chan == 24 && desc->pkt_bytes == 3 * desc->channels_per_frame) - { psf->bytewidth = 3 ; - return format | SF_FORMAT_PCM_24 ; - } ; - if (desc->bits_per_chan == 16 && desc->pkt_bytes == 2 * desc->channels_per_frame) - { psf->bytewidth = 2 ; - return format | SF_FORMAT_PCM_16 ; - } ; - if (desc->bits_per_chan == 8 && desc->pkt_bytes == 1 * desc->channels_per_frame) - { psf->bytewidth = 1 ; - return format | SF_FORMAT_PCM_S8 ; - } ; - } ; - - if (desc->fmt_id == alaw_MARKER && desc->bits_per_chan == 8) - { psf->bytewidth = 1 ; - return format | SF_FORMAT_ALAW ; - } ; - - if (desc->fmt_id == ulaw_MARKER && desc->bits_per_chan == 8) - { psf->bytewidth = 1 ; - return format | SF_FORMAT_ULAW ; - } ; - - psf_log_printf (psf, "**** Unknown format identifier.\n") ; - - return 0 ; -} /* decode_desc_chunk */ - -static int -caf_read_header (SF_PRIVATE *psf) -{ CAF_PRIVATE *pcaf ; - BUF_UNION ubuf ; - DESC_CHUNK desc ; - sf_count_t chunk_size ; - double srate ; - short version, flags ; - int marker, k, have_data = 0, error ; - - if ((pcaf = psf->container_data) == NULL) - return SFE_INTERNAL ; - - memset (&desc, 0, sizeof (desc)) ; - - /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "pmE2E2", 0, &marker, &version, &flags) ; - psf_log_printf (psf, "%M\n Version : %d\n Flags : %x\n", marker, version, flags) ; - if (marker != caff_MARKER) - return SFE_CAF_NOT_CAF ; - - psf_binheader_readf (psf, "mE8b", &marker, &chunk_size, ubuf.ucbuf, 8) ; - srate = double64_be_read (ubuf.ucbuf) ; - snprintf (ubuf.cbuf, sizeof (ubuf.cbuf), "%5.3f", srate) ; - psf_log_printf (psf, "%M : %D\n Sample rate : %s\n", marker, chunk_size, ubuf.cbuf) ; - if (marker != desc_MARKER) - return SFE_CAF_NO_DESC ; - - if (chunk_size < SIGNED_SIZEOF (DESC_CHUNK)) - { psf_log_printf (psf, "**** Chunk size too small. Should be > 32 bytes.\n") ; - return SFE_MALFORMED_FILE ; - } ; - - psf->sf.samplerate = psf_lrint (srate) ; - - psf_binheader_readf (psf, "mE44444", &desc.fmt_id, &desc.fmt_flags, &desc.pkt_bytes, &desc.frames_per_packet, - &desc.channels_per_frame, &desc.bits_per_chan) ; - psf_log_printf (psf, " Format id : %M\n Format flags : %x\n Bytes / packet : %u\n" - " Frames / packet : %u\n Channels / frame : %u\n Bits / channel : %u\n", - desc.fmt_id, desc.fmt_flags, desc.pkt_bytes, desc.frames_per_packet, desc.channels_per_frame, desc.bits_per_chan) ; - - if (desc.channels_per_frame > SF_MAX_CHANNELS) - { psf_log_printf (psf, "**** Bad channels per frame value %u.\n", desc.channels_per_frame) ; - return SFE_MALFORMED_FILE ; - } ; - - if (chunk_size > SIGNED_SIZEOF (DESC_CHUNK)) - psf_binheader_readf (psf, "j", (int) (chunk_size - sizeof (DESC_CHUNK))) ; - - psf->sf.channels = desc.channels_per_frame ; - - while (1) - { marker = 0 ; - chunk_size = 0 ; - - psf_binheader_readf (psf, "mE8", &marker, &chunk_size) ; - if (marker == 0) - { sf_count_t pos = psf_ftell (psf) ; - psf_log_printf (psf, "Have 0 marker at position %D (0x%x).\n", pos, pos) ; - break ; - } ; - if (chunk_size < 0) - { psf_log_printf (psf, "%M : %D *** Should be >= 0 ***\n", marker, chunk_size) ; - break ; - } ; - if (chunk_size > psf->filelength) - break ; - - psf_store_read_chunk_u32 (&psf->rchunks, marker, psf_ftell (psf), chunk_size) ; - - switch (marker) - { case peak_MARKER : - psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; - if (chunk_size != CAF_PEAK_CHUNK_SIZE (psf->sf.channels)) - { psf_binheader_readf (psf, "j", (size_t) chunk_size) ; - psf_log_printf (psf, "*** File PEAK chunk %D should be %d.\n", chunk_size, CAF_PEAK_CHUNK_SIZE (psf->sf.channels)) ; - return SFE_CAF_BAD_PEAK ; - } ; - - if (psf->peak_info) - { psf_log_printf (psf, "*** Found existing peak info, using last one.\n") ; - free (psf->peak_info) ; - psf->peak_info = NULL ; - } ; - if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL) - return SFE_MALLOC_FAILED ; - - /* read in rest of PEAK chunk. */ - psf_binheader_readf (psf, "E4", & (psf->peak_info->edit_number)) ; - psf_log_printf (psf, " edit count : %d\n", psf->peak_info->edit_number) ; - - psf_log_printf (psf, " Ch Position Value\n") ; - for (k = 0 ; k < psf->sf.channels ; k++) - { sf_count_t position ; - float value ; - - psf_binheader_readf (psf, "Ef8", &value, &position) ; - psf->peak_info->peaks [k].value = value ; - psf->peak_info->peaks [k].position = position ; - - snprintf (ubuf.cbuf, sizeof (ubuf.cbuf), " %2d %-12" PRId64 " %g\n", k, position, value) ; - psf_log_printf (psf, ubuf.cbuf) ; - } ; - - psf->peak_info->peak_loc = SF_PEAK_START ; - break ; - - case chan_MARKER : - if (chunk_size < 12) - { psf_log_printf (psf, "%M : %D (should be >= 12)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", (size_t) chunk_size) ; - break ; - } - - psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; - - if ((error = caf_read_chanmap (psf, chunk_size))) - return error ; - break ; - - case free_MARKER : - psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", (size_t) chunk_size) ; - break ; - - case data_MARKER : - psf_binheader_readf (psf, "E4", &k) ; - if (chunk_size == -1) - { psf_log_printf (psf, "%M : -1\n") ; - chunk_size = psf->filelength - psf->header.indx ; - } - else if (psf->filelength > 0 && chunk_size > psf->filelength - psf->header.indx + 10) - { psf_log_printf (psf, "%M : %D (should be %D)\n", marker, chunk_size, psf->filelength - psf->header.indx - 8) ; - psf->datalength = psf->filelength - psf->header.indx - 8 ; - } - else - { psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; - /* Subtract the 4 bytes of the 'edit' field above. */ - psf->datalength = chunk_size - 4 ; - } ; - - psf_log_printf (psf, " edit : %u\n", k) ; - - psf->dataoffset = psf->header.indx ; - if (psf->datalength + psf->dataoffset < psf->filelength) - psf->dataend = psf->datalength + psf->dataoffset ; - - psf_binheader_readf (psf, "j", (size_t) psf->datalength) ; - have_data = 1 ; - break ; - - case kuki_MARKER : - psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; - pcaf->alac.kuki_offset = psf_ftell (psf) - 12 ; - psf_binheader_readf (psf, "j", (size_t) chunk_size) ; - break ; - - case pakt_MARKER : - if (chunk_size < 24) - { psf_log_printf (psf, "%M : %D (should be > 24)\n", marker, chunk_size) ; - return SFE_MALFORMED_FILE ; - } - else if (chunk_size > psf->filelength - psf->header.indx) - { psf_log_printf (psf, "%M : %D (should be < %D)\n", marker, chunk_size, psf->filelength - psf->header.indx) ; - return SFE_MALFORMED_FILE ; - } - else - psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; - - psf_binheader_readf (psf, "E8844", &pcaf->alac.packets, &pcaf->alac.valid_frames, - &pcaf->alac.priming_frames, &pcaf->alac.remainder_frames) ; - - psf_log_printf (psf, - " Packets : %D\n" - " Valid frames : %D\n" - " Priming frames : %d\n" - " Remainder frames : %d\n", - pcaf->alac.packets, pcaf->alac.valid_frames, pcaf->alac.priming_frames, - pcaf->alac.remainder_frames - ) ; - - if (pcaf->alac.packets == 0 && pcaf->alac.valid_frames == 0 - && pcaf->alac.priming_frames == 0 && pcaf->alac.remainder_frames == 0) - psf_log_printf (psf, "*** 'pakt' chunk header is all zero.\n") ; - - pcaf->alac.pakt_offset = psf_ftell (psf) - 12 ; - psf_binheader_readf (psf, "j", (size_t) chunk_size - 24) ; - break ; - - case info_MARKER : - if (chunk_size < 4) - { psf_log_printf (psf, "%M : %D (should be > 4)\n", marker, chunk_size) ; - return SFE_MALFORMED_FILE ; - } - else if (chunk_size > psf->filelength - psf->header.indx) - { psf_log_printf (psf, "%M : %D (should be < %D)\n", marker, chunk_size, psf->filelength - psf->header.indx) ; - return SFE_MALFORMED_FILE ; - } ; - psf_log_printf (psf, "%M : %D\n", marker, chunk_size) ; - if (chunk_size > 4) - caf_read_strings (psf, chunk_size - 4) ; - break ; - - default : - psf_log_printf (psf, "%M : %D (skipped)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", (size_t) chunk_size) ; - break ; - } ; - - if (marker != data_MARKER && chunk_size >= 0xffffff00) - break ; - - if (! psf->sf.seekable && have_data) - break ; - - if (psf_ftell (psf) >= psf->filelength - SIGNED_SIZEOF (chunk_size)) - { psf_log_printf (psf, "End\n") ; - break ; - } ; - } ; - - if (have_data == 0) - { psf_log_printf (psf, "**** Error, could not find 'data' chunk.\n") ; - return SFE_MALFORMED_FILE ; - } ; - - psf->endian = (desc.fmt_flags & 2) ? SF_ENDIAN_LITTLE : SF_ENDIAN_BIG ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - if ((psf->sf.format = decode_desc_chunk (psf, &desc)) == 0) - return SFE_UNSUPPORTED_ENCODING ; - - if (psf->bytewidth > 0) - psf->sf.frames = psf->datalength / psf->bytewidth ; - - return 0 ; -} /* caf_read_header */ - -/*------------------------------------------------------------------------------ -*/ - -static int -caf_write_header (SF_PRIVATE *psf, int calc_length) -{ BUF_UNION ubuf ; - CAF_PRIVATE *pcaf ; - DESC_CHUNK desc ; - sf_count_t current ; - uint32_t uk ; - int subformat, append_free_block = SF_TRUE ; - - if ((pcaf = psf->container_data) == NULL) - return SFE_INTERNAL ; - - memset (&desc, 0, sizeof (desc)) ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - if (psf->bytewidth > 0) - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - /* 'caff' marker, version and flags. */ - psf_binheader_writef (psf, "Em22", BHWm (caff_MARKER), BHW2 (1), BHW2 (0)) ; - - /* 'desc' marker and chunk size. */ - psf_binheader_writef (psf, "Em8", BHWm (desc_MARKER), BHW8 ((sf_count_t) (sizeof (DESC_CHUNK)))) ; - - double64_be_write (1.0 * psf->sf.samplerate, ubuf.ucbuf) ; - psf_binheader_writef (psf, "b", BHWv (ubuf.ucbuf), BHWz (8)) ; - - subformat = SF_CODEC (psf->sf.format) ; - - psf->endian = SF_ENDIAN (psf->sf.format) ; - - if (CPU_IS_BIG_ENDIAN && (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU)) - psf->endian = SF_ENDIAN_BIG ; - else if (CPU_IS_LITTLE_ENDIAN && (psf->endian == SF_ENDIAN_LITTLE || psf->endian == SF_ENDIAN_CPU)) - psf->endian = SF_ENDIAN_LITTLE ; - - if (psf->endian == SF_ENDIAN_LITTLE) - desc.fmt_flags = 2 ; - else - psf->endian = SF_ENDIAN_BIG ; - - /* initial section (same for all, it appears) */ - switch (subformat) - { case SF_FORMAT_PCM_S8 : - desc.fmt_id = lpcm_MARKER ; - psf->bytewidth = 1 ; - desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.frames_per_packet = 1 ; - desc.channels_per_frame = psf->sf.channels ; - desc.bits_per_chan = 8 ; - break ; - - case SF_FORMAT_PCM_16 : - desc.fmt_id = lpcm_MARKER ; - psf->bytewidth = 2 ; - desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.frames_per_packet = 1 ; - desc.channels_per_frame = psf->sf.channels ; - desc.bits_per_chan = 16 ; - break ; - - case SF_FORMAT_PCM_24 : - psf->bytewidth = 3 ; - desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.frames_per_packet = 1 ; - desc.channels_per_frame = psf->sf.channels ; - desc.bits_per_chan = 24 ; - desc.fmt_id = lpcm_MARKER ; - break ; - - case SF_FORMAT_PCM_32 : - desc.fmt_id = lpcm_MARKER ; - psf->bytewidth = 4 ; - desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.frames_per_packet = 1 ; - desc.channels_per_frame = psf->sf.channels ; - desc.bits_per_chan = 32 ; - break ; - - case SF_FORMAT_FLOAT : - desc.fmt_id = lpcm_MARKER ; - desc.fmt_flags |= 1 ; - psf->bytewidth = 4 ; - desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.frames_per_packet = 1 ; - desc.channels_per_frame = psf->sf.channels ; - desc.bits_per_chan = 32 ; - break ; - - case SF_FORMAT_DOUBLE : - desc.fmt_id = lpcm_MARKER ; - desc.fmt_flags |= 1 ; - psf->bytewidth = 8 ; - desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.frames_per_packet = 1 ; - desc.channels_per_frame = psf->sf.channels ; - desc.bits_per_chan = 64 ; - break ; - - case SF_FORMAT_ALAW : - desc.fmt_id = alaw_MARKER ; - psf->bytewidth = 1 ; - desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.frames_per_packet = 1 ; - desc.channels_per_frame = psf->sf.channels ; - desc.bits_per_chan = 8 ; - break ; - - case SF_FORMAT_ULAW : - desc.fmt_id = ulaw_MARKER ; - psf->bytewidth = 1 ; - desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.frames_per_packet = 1 ; - desc.channels_per_frame = psf->sf.channels ; - desc.bits_per_chan = 8 ; - break ; - - case SF_FORMAT_ALAC_16 : - case SF_FORMAT_ALAC_20 : - case SF_FORMAT_ALAC_24 : - case SF_FORMAT_ALAC_32 : - desc.fmt_id = alac_MARKER ; - desc.pkt_bytes = psf->bytewidth * psf->sf.channels ; - desc.channels_per_frame = psf->sf.channels ; - alac_get_desc_chunk_items (subformat, &desc.fmt_flags, &desc.frames_per_packet) ; - append_free_block = SF_FALSE ; - break ; - - default : - return SFE_UNIMPLEMENTED ; - } ; - - psf_binheader_writef (psf, "mE44444", BHWm (desc.fmt_id), BHW4 (desc.fmt_flags), BHW4 (desc.pkt_bytes), BHW4 (desc.frames_per_packet), BHW4 (desc.channels_per_frame), BHW4 (desc.bits_per_chan)) ; - - caf_write_strings (psf, SF_STR_LOCATE_START) ; - - if (psf->peak_info != NULL) - { int k ; - psf_binheader_writef (psf, "Em84", BHWm (peak_MARKER), BHW8 ((sf_count_t) CAF_PEAK_CHUNK_SIZE (psf->sf.channels)), BHW4 (psf->peak_info->edit_number)) ; - for (k = 0 ; k < psf->sf.channels ; k++) - psf_binheader_writef (psf, "Ef8", BHWf ((float) psf->peak_info->peaks [k].value), BHW8 (psf->peak_info->peaks [k].position)) ; - } ; - - if (psf->channel_map && pcaf->chanmap_tag) - psf_binheader_writef (psf, "Em8444", BHWm (chan_MARKER), BHW8 ((sf_count_t) 12), BHW4 (pcaf->chanmap_tag), BHW4 (0), BHW4 (0)) ; - - /* Write custom headers. */ - for (uk = 0 ; uk < psf->wchunks.used ; uk++) - psf_binheader_writef (psf, "m44b", BHWm ((int) psf->wchunks.chunks [uk].mark32), BHW4 (0), BHW4 (psf->wchunks.chunks [uk].len), BHWv (psf->wchunks.chunks [uk].data), BHWz (psf->wchunks.chunks [uk].len)) ; - - if (append_free_block) - { /* Add free chunk so that the actual audio data starts at a multiple 0x1000. */ - sf_count_t free_len = 0x1000 - psf->header.indx - 16 - 12 ; - while (free_len < 0) - free_len += 0x1000 ; - psf_binheader_writef (psf, "Em8z", BHWm (free_MARKER), BHW8 (free_len), BHWz (free_len)) ; - } ; - - psf_binheader_writef (psf, "Em84", BHWm (data_MARKER), BHW8 (psf->datalength + 4), BHW4 (0)) ; - - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - if (current < psf->dataoffset) - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - else if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* caf_write_header */ - -static int -caf_write_tailer (SF_PRIVATE *psf) -{ - /* Reset the current header buffer length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - if (psf->bytewidth > 0 && psf->sf.seekable == SF_TRUE) - { psf->datalength = psf->sf.frames * psf->bytewidth * psf->sf.channels ; - psf->dataend = psf->dataoffset + psf->datalength ; - } ; - - if (psf->dataend > 0) - psf_fseek (psf, psf->dataend, SEEK_SET) ; - else - psf->dataend = psf_fseek (psf, 0, SEEK_END) ; - - if (psf->dataend & 1) - psf_binheader_writef (psf, "z", BHWz (1)) ; - - if (psf->strings.flags & SF_STR_LOCATE_END) - caf_write_strings (psf, SF_STR_LOCATE_END) ; - - /* Write the tailer. */ - if (psf->header.indx > 0) - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - return 0 ; -} /* caf_write_tailer */ - -static int -caf_read_chanmap (SF_PRIVATE * psf, sf_count_t chunk_size) -{ const AIFF_CAF_CHANNEL_MAP * map_info ; - unsigned channel_bitmap, channel_decriptions, bytesread ; - int layout_tag ; - - bytesread = psf_binheader_readf (psf, "E444", &layout_tag, &channel_bitmap, &channel_decriptions) ; - - map_info = aiff_caf_of_channel_layout_tag (layout_tag) ; - - psf_log_printf (psf, " Tag : %x\n", layout_tag) ; - if (map_info) - psf_log_printf (psf, " Layout : %s\n", map_info->name) ; - - if (bytesread < chunk_size) - psf_binheader_readf (psf, "j", chunk_size - bytesread) ; - - if (map_info && map_info->channel_map != NULL) - { size_t chanmap_size = SF_MIN (psf->sf.channels, layout_tag & 0xff) * sizeof (psf->channel_map [0]) ; - - free (psf->channel_map) ; - - if ((psf->channel_map = malloc (chanmap_size)) == NULL) - return SFE_MALLOC_FAILED ; - - memcpy (psf->channel_map, map_info->channel_map, chanmap_size) ; - } ; - - return 0 ; -} /* caf_read_chanmap */ - - -static uint32_t -string_hash32 (const char * str) -{ uint32_t hash = 0x87654321 ; - - while (str [0]) - { hash = hash * 333 + str [0] ; - str ++ ; - } ; - - return hash ; -} /* string_hash32 */ - -static int -caf_read_strings (SF_PRIVATE * psf, sf_count_t chunk_size) -{ char *buf ; - char *key, *value ; - uint32_t count, hash ; - - if ((buf = malloc (chunk_size + 1)) == NULL) - return (psf->error = SFE_MALLOC_FAILED) ; - - psf_binheader_readf (psf, "E4b", &count, buf, (size_t) chunk_size) ; - psf_log_printf (psf, " count: %u\n", count) ; - - /* Force terminate `buf` to make sure. */ - buf [chunk_size] = 0 ; - - for (key = buf ; key < buf + chunk_size ; ) - { value = key + strlen (key) + 1 ; - if (value > buf + chunk_size) - break ; - psf_log_printf (psf, " %-12s : %s\n", key, value) ; - - hash = string_hash32 (key) ; - switch (hash) - { case 0xC4861943 : /* 'title' */ - psf_store_string (psf, SF_STR_TITLE, value) ; - break ; - case 0xAD47A394 : /* 'software' */ - psf_store_string (psf, SF_STR_SOFTWARE, value) ; - break ; - case 0x5D178E2A : /* 'copyright' */ - psf_store_string (psf, SF_STR_COPYRIGHT, value) ; - break ; - case 0x60E4D0C8 : /* 'artist' */ - psf_store_string (psf, SF_STR_ARTIST, value) ; - break ; - case 0x83B5D16A : /* 'genre' */ - psf_store_string (psf, SF_STR_GENRE, value) ; - break ; - case 0x15E5FC88 : /* 'comment' */ - case 0x7C297D5B : /* 'comments' */ - psf_store_string (psf, SF_STR_COMMENT, value) ; - break ; - case 0x24A7C347 : /* 'tracknumber' */ - psf_store_string (psf, SF_STR_TRACKNUMBER, value) ; - break ; - case 0x50A31EB7 : /* 'date' */ - psf_store_string (psf, SF_STR_DATE, value) ; - break ; - case 0x6583545A : /* 'album' */ - psf_store_string (psf, SF_STR_ALBUM, value) ; - break ; - case 0xE7C64B6C : /* 'license' */ - psf_store_string (psf, SF_STR_LICENSE, value) ; - break ; - default : - psf_log_printf (psf, " Unhandled hash 0x%x : /* '%s' */\n", hash, key) ; - break ; - } ; - - key = value + strlen (value) + 1 ; - } ; - - free (buf) ; - - return 0 ; -} /* caf_read_strings */ - -struct put_buffer -{ uint32_t index ; - char s [16 * 1024] ; -} ; - -static uint32_t -put_key_value (struct put_buffer * buf, const char * key, const char * value) -{ uint32_t written ; - - if (buf->index + strlen (key) + strlen (value) + 2 > sizeof (buf->s)) - return 0 ; - - written = snprintf (buf->s + buf->index, sizeof (buf->s) - buf->index, "%s%c%s%c", key, 0, value, 0) ; - - if (buf->index + written >= sizeof (buf->s)) - return 0 ; - - buf->index += written ; - return 1 ; -} /* put_key_value */ - -static void -caf_write_strings (SF_PRIVATE * psf, int location) -{ struct put_buffer buf ; - const char * cptr ; - uint32_t k, string_count = 0 ; - - memset (&buf, 0, sizeof (buf)) ; - - for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { if (psf->strings.data [k].type == 0) - break ; - - if (psf->strings.data [k].flags != location) - continue ; - - if ((cptr = psf_get_string (psf, psf->strings.data [k].type)) == NULL) - continue ; - - switch (psf->strings.data [k].type) - { case SF_STR_TITLE : - string_count += put_key_value (&buf, "title", cptr) ; - break ; - case SF_STR_COPYRIGHT : - string_count += put_key_value (&buf, "copyright", cptr) ; - break ; - case SF_STR_SOFTWARE : - string_count += put_key_value (&buf, "software", cptr) ; - break ; - case SF_STR_ARTIST : - string_count += put_key_value (&buf, "artist", cptr) ; - break ; - case SF_STR_COMMENT : - string_count += put_key_value (&buf, "comment", cptr) ; - break ; - case SF_STR_DATE : - string_count += put_key_value (&buf, "date", cptr) ; - break ; - case SF_STR_ALBUM : - string_count += put_key_value (&buf, "album", cptr) ; - break ; - case SF_STR_LICENSE : - string_count += put_key_value (&buf, "license", cptr) ; - break ; - case SF_STR_TRACKNUMBER : - string_count += put_key_value (&buf, "tracknumber", cptr) ; - break ; - case SF_STR_GENRE : - string_count += put_key_value (&buf, "genre", cptr) ; - break ; - - default : - break ; - } ; - } ; - - if (string_count == 0 || buf.index == 0) - return ; - - psf_binheader_writef (psf, "Em84b", BHWm (info_MARKER), BHW8 (buf.index + 4), BHW4 (string_count), BHWv (buf.s), BHWz (buf.index)) ; -} /* caf_write_strings */ - -/*============================================================================== -*/ - -static int -caf_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) -{ return psf_save_write_chunk (&psf->wchunks, chunk_info) ; -} /* caf_set_chunk */ - -static SF_CHUNK_ITERATOR * -caf_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) -{ return psf_next_chunk_iterator (&psf->rchunks, iterator) ; -} /* caf_next_chunk_iterator */ - -static int -caf_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ int indx ; - - if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) - return SFE_UNKNOWN_CHUNK ; - - chunk_info->datalen = psf->rchunks.chunks [indx].len ; - - return SFE_NO_ERROR ; -} /* caf_get_chunk_size */ - -static int -caf_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ int indx ; - sf_count_t pos ; - - if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) - return SFE_UNKNOWN_CHUNK ; - - if (chunk_info->data == NULL) - return SFE_BAD_CHUNK_DATA_PTR ; - - chunk_info->id_size = psf->rchunks.chunks [indx].id_size ; - memcpy (chunk_info->id, psf->rchunks.chunks [indx].id, sizeof (chunk_info->id) / sizeof (*chunk_info->id)) ; - - pos = psf_ftell (psf) ; - psf_fseek (psf, psf->rchunks.chunks [indx].offset, SEEK_SET) ; - psf_fread (chunk_info->data, SF_MIN (chunk_info->datalen, psf->rchunks.chunks [indx].len), 1, psf) ; - psf_fseek (psf, pos, SEEK_SET) ; - - return SFE_NO_ERROR ; -} /* caf_get_chunk_data */ diff --git a/Engine/lib/libsndfile/src/cart.c b/Engine/lib/libsndfile/src/cart.c deleted file mode 100644 index 8b00eab16..000000000 --- a/Engine/lib/libsndfile/src/cart.c +++ /dev/null @@ -1,101 +0,0 @@ -/* -** Copyright (C) 2012 Chris Roberts -** Copyright (C) 2006-2013 Erik de Castro Lopo -** Copyright (C) 2006 Paul Davis -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include "common.h" - - - -static inline size_t -cart_min_size (const SF_CART_INFO* info) -{ if (info == NULL) - return 0 ; - - return offsetof (SF_CART_INFO, tag_text) + info->tag_text_size ; -} /* cart_min_size */ - -SF_CART_INFO_16K* -cart_var_alloc (void) -{ SF_CART_INFO_16K* thing ; - thing = malloc (sizeof (SF_CART_INFO_16K)) ; - return thing ; -} /* cart_var_alloc */ - -int -cart_var_set (SF_PRIVATE *psf, const SF_CART_INFO * info, size_t datasize) -{ size_t len ; - - if (info == NULL) - return SF_FALSE ; - - if (cart_min_size (info) > datasize) - { psf->error = SFE_BAD_CART_INFO_SIZE ; - return SF_FALSE ; - } ; - - if (datasize >= sizeof (SF_CART_INFO_16K)) - { psf->error = SFE_BAD_CART_INFO_TOO_BIG ; - return SF_FALSE ; - } ; - - if (psf->cart_16k == NULL) - { if ((psf->cart_16k = cart_var_alloc ()) == NULL) - { psf->error = SFE_MALLOC_FAILED ; - return SF_FALSE ; - } ; - } ; - - memcpy (psf->cart_16k, info, offsetof (SF_CART_INFO, tag_text)) ; - psf_strlcpy_crlf (psf->cart_16k->tag_text, info->tag_text, sizeof (psf->cart_16k->tag_text), datasize - offsetof (SF_CART_INFO, tag_text)) ; - - len = strlen (psf->cart_16k->tag_text) ; - - if (len > 0 && psf->cart_16k->tag_text [len - 1] != '\n') - psf_strlcat (psf->cart_16k->tag_text, sizeof (psf->cart_16k->tag_text), "\r\n") ; - - /* Force tag_text_size to be even. */ - len = strlen (psf->cart_16k->tag_text) ; - len += (len & 1) ? 1 : 2 ; - - psf->cart_16k->tag_text_size = (uint32_t) len ; - - return SF_TRUE ; -} /* cart_var_set */ - - -int -cart_var_get (SF_PRIVATE *psf, SF_CART_INFO * data, size_t datasize) -{ size_t size ; - if (psf->cart_16k == NULL) - return SF_FALSE ; - - size = SF_MIN (datasize, cart_min_size ((const SF_CART_INFO *) psf->cart_16k)) ; - - memcpy (data, psf->cart_16k, size) ; - - return SF_TRUE ; -} /* cart_var_get */ - - diff --git a/Engine/lib/libsndfile/src/chanmap.c b/Engine/lib/libsndfile/src/chanmap.c deleted file mode 100644 index c06702ca0..000000000 --- a/Engine/lib/libsndfile/src/chanmap.c +++ /dev/null @@ -1,262 +0,0 @@ -/* -** Copyright (C) 2009-2014 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** Mostly from "Apple Core Audio Format Specification 1.0": -** -** http://developer.apple.com/documentation/MusicAudio/Reference/CAFSpec/CAFSpec.pdf -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "sndfile.h" -#include "common.h" -#include "chanmap.h" - - -static const AIFF_CAF_CHANNEL_MAP zero_chan [] = -{ { (0 << 16) | 0, NULL, "Use channel descriptions." }, - { (1 << 16) | 0, NULL, "Use channel bitmap." } -} ; /* zero_chan */ - - -static const int one_chan_mono [1] = { SF_CHANNEL_MAP_MONO } ; - -static const AIFF_CAF_CHANNEL_MAP one_chan [] = -{ { (100 << 16) | 1, one_chan_mono, "mono" } -} ; /* one_chan */ - - -static const int two_channel_stereo [2] = { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT } ; - -static const AIFF_CAF_CHANNEL_MAP two_chan [] = -{ { (101 << 16) | 2, two_channel_stereo, "stereo (L, R)" }, - { (102 << 16) | 2, two_channel_stereo, "stereo headphones (L, R)" }, -#if 0 - { (103 << 16) | 2, NULL, "matrix stereo (Lt, Rt)" }, - { (104 << 16) | 2, NULL, "2 channels (mid, side)" }, - { (105 << 16) | 2, NULL, "coincident mic pair" }, - { (106 << 16) | 2, NULL, "binaural stereo (L, R)" - } -#endif -} ; /* two_chan */ - - -static const int three_channel_mpeg_30a [3] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER } ; -static const int three_channel_mpeg_30b [3] = - { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT } ; -static const int three_channel_itu_21 [3] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_CENTER } ; -static const int three_channel_dvd_4 [3] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_LFE } ; - -static const AIFF_CAF_CHANNEL_MAP three_chan [] = -{ { (113 << 16) | 3, three_channel_mpeg_30a, "MPEG 3 0 A (L, R, C)" }, - { (114 << 16) | 3, three_channel_mpeg_30b, "MPEG 3 0 B (C, L, R)" }, - { (131 << 16) | 3, three_channel_itu_21, "ITU 2.1 (L, R, Cs)" }, - { (133 << 16) | 3, three_channel_dvd_4, "DVD 4 (L, R, LFE)" } -} ; /* three_chan */ - - -static const int four_channel_ambisonc_b [4] = - { SF_CHANNEL_MAP_AMBISONIC_B_W, SF_CHANNEL_MAP_AMBISONIC_B_X, SF_CHANNEL_MAP_AMBISONIC_B_Y, SF_CHANNEL_MAP_AMBISONIC_B_Z } ; -static const int four_channel_quad [4] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; -static const int four_channel_mpeg_40a [4] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_REAR_CENTER } ; -static const int four_channel_mpeg_40b [4] = - { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_CENTER } ; -static const int four_channel_itu_23 [4] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; -static const int four_channel_dvd_5 [4] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_CENTER } ; -static const int four_channel_dvd_10 [4] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE } ; - -static const AIFF_CAF_CHANNEL_MAP four_chan [] = -{ { (107 << 16) | 4, four_channel_ambisonc_b, "ambisonic B (W, X, Y, Z)" }, - { (108 << 16) | 4, four_channel_quad, "quad (Lfront, Rfront, Lrear, Rrear)" }, - { (115 << 16) | 4, four_channel_mpeg_40a, "MPEG 4.0 A (L, R, C, Cs)" }, - { (116 << 16) | 4, four_channel_mpeg_40b, "MPEG 4.0 B (C, L, R, Cs)" }, - { (132 << 16) | 4, four_channel_itu_23, "ITU 2.3 (L, R, Ls, Rs)" }, - { (134 << 16) | 4, four_channel_dvd_5, "DVD 5 (L, R, LFE, Cs)" }, - { (136 << 16) | 4, four_channel_dvd_10, "DVD 10 (L, R, C, LFE)" } -} ; /* four_chan */ - - -static const int five_channel_pentagonal [5] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_CENTER } ; -static const int five_channel_mpeg_50_a [5] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; -static const int five_channel_mpeg_50_b [5] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_CENTER } ; -static const int five_channel_mpeg_50_c [5] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; -static const int five_channel_mpeg_50_d [5] = - { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; -static const int five_channel_dvd_6 [5] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; -static const int five_channel_dvd_11 [5] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_CENTER } ; -static const int five_channel_dvd_18 [5] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_LFE } ; - -static const AIFF_CAF_CHANNEL_MAP five_chan [] = -{ { (109 << 16) | 5, five_channel_pentagonal, "pentagonal (L, R, Lrear, Rrear, C)" }, - { (117 << 16) | 5, five_channel_mpeg_50_a, "MPEG 5.0 A (L, R, C, Ls, Rs)" }, - { (118 << 16) | 5, five_channel_mpeg_50_b, "MPEG 5.0 B (L, R, Ls, Rs, C)" }, - { (119 << 16) | 5, five_channel_mpeg_50_c, "MPEG 5.0 C (L, C, R, Ls, Rs,)" }, - { (120 << 16) | 5, five_channel_mpeg_50_d, "MPEG 5.0 D (C, L, R, Ls, Rs)" }, - { (135 << 16) | 5, five_channel_dvd_6, "DVD 6 (L, R, LFE, Ls, Rs)" }, - { (137 << 16) | 5, five_channel_dvd_11, "DVD 11 (L, R, C, LFE, Cs)" }, - { (138 << 16) | 5, five_channel_dvd_18, "DVD 18 (L, R, Ls, Rs, LFE)" } -} ; /* five_chan */ - - -static const int six_channel_mpeg_51_a [6] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT } ; -static const int six_channel_mpeg_51_b [6] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE } ; -static const int six_channel_mpeg_51_c [6] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_LFE } ; -static const int six_channel_mpeg_51_d [6] = - { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_LFE } ; -static const int six_channel_audio_unit_60 [6] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_REAR_CENTER } ; -static const int six_channel_aac_60 [6] = - { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_REAR_CENTER } ; - -static const AIFF_CAF_CHANNEL_MAP six_chan [] = -{ { (110 << 16) | 6, NULL, "hexagonal (L, R, Lr, Rr, C, Rear)" }, - { (121 << 16) | 6, six_channel_mpeg_51_a, "MPEG 5.1 A (L, R, C, LFE, Ls, Rs)" }, - { (122 << 16) | 6, six_channel_mpeg_51_b, "MPEG 5.1 B (L, R, Ls, Rs, C, LFE)" }, - { (123 << 16) | 6, six_channel_mpeg_51_c, "MPEG 5.1 C (L, C, R, Ls, Rs, LFE)" }, - { (124 << 16) | 6, six_channel_mpeg_51_d, "MPEG 5.1 D (C, L, R, Ls, Rs, LFE)" }, - { (139 << 16) | 6, six_channel_audio_unit_60, "AudioUnit 6.0 (L, R, Ls, Rs, C, Cs)" }, - { (141 << 16) | 6, six_channel_aac_60, "AAC 6.0 (C, L, R, Ls, Rs, Cs)" } -} ; /* six_chan */ - - -static const int six_channel_mpeg_61a [7] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LFE, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_REAR_CENTER } ; -static const int six_channel_aac_61 [7] = - { SF_CHANNEL_MAP_CENTER, SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT, SF_CHANNEL_MAP_REAR_CENTER, SF_CHANNEL_MAP_LFE } ; - -static const AIFF_CAF_CHANNEL_MAP seven_chan [] = -{ { (125 << 16) | 7, six_channel_mpeg_61a, "MPEG 6.1 A (L, R, C, LFE, Ls, Rs, Cs)" }, - { (140 << 16) | 7, NULL, "AudioUnit 7.0 (L, R, Ls, Rs, C, Rls, Rrs)" }, - { (142 << 16) | 7, six_channel_aac_61, "AAC 6.1 (C, L, R, Ls, Rs, Cs, Lfe)" }, - { (143 << 16) | 7, NULL, "AAC 7.0 (C, L, R, Ls, Rs, Rls, Rrs,)" } -} ; /* seven_chan */ - - -static const AIFF_CAF_CHANNEL_MAP eight_chan [] = -{ { (111 << 16) | 8, NULL, - // front left, front right, rear left, rear right, - // front center, rear center, side left, side right - "octagonal (Lf, Rf, Lr, Rr, Cf, Cr, Ls, Rs)" - }, - { (112 << 16) | 8, NULL, - // left, right, rear left, rear right - // top left, top right, top rear left, top rear right - "cube (L, R, Lrear, Rrear, Ltop, Rtop, Ltoprear, Rtoprear)" - }, - { (126 << 16) | 8, NULL, "MPEG 7.1 A (L, R, C, LFE, Ls, Rs, Lc, Rc)" }, - { (127 << 16) | 8, NULL, "MPEG 7.1 B (C, Lc, Rc, L, R, Ls, Rs, LFE)" }, - { (128 << 16) | 8, NULL, "MPEG 7.1 C (L, R, C, LFE, Ls, R, Rls, Rrs)" }, - { (129 << 16) | 8, NULL, "Emagic Default 7.1 (L, R, Ls, Rs, C, LFE, Lc, Rc)" }, - { (130 << 16) | 8, NULL, - // (ITU_5_1 plus a matrix encoded stereo mix) - "SMPTE DTV (L, R, C, LFE, Ls, Rs, Lt, Rt)" - }, - { (144 << 16) | 8, NULL, "AAC octagonal (C, L, R, Ls, Rs, Rls, Rrs, Cs)" } -} ; /* eight_chan */ - - - -#if 0 - -TMH_10_2_std = (145 << 16) | 16, -// L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2 - -TMH_10_2_full = (146 << 16) | 21, -// TMH_10_2_std plus: Lc Rc HI VI Haptic - -#endif - - -typedef struct -{ const AIFF_CAF_CHANNEL_MAP * map ; - int len ; -} MAP_MAP ; - -static const MAP_MAP map [] = -{ { zero_chan, ARRAY_LEN (zero_chan) }, - { one_chan, ARRAY_LEN (one_chan) }, - { two_chan, ARRAY_LEN (two_chan) }, - { three_chan, ARRAY_LEN (three_chan) }, - { four_chan, ARRAY_LEN (four_chan) }, - { five_chan, ARRAY_LEN (five_chan) }, - { six_chan, ARRAY_LEN (six_chan) }, - { seven_chan, ARRAY_LEN (seven_chan) }, - { eight_chan, ARRAY_LEN (eight_chan) } -} ; /* map */ - - -int -aiff_caf_find_channel_layout_tag (const int *chan_map, int channels) -{ const AIFF_CAF_CHANNEL_MAP * curr_map ; - unsigned k, len ; - - if (channels < 1 || channels >= ARRAY_LEN (map)) - return 0 ; - - curr_map = map [channels].map ; - len = map [channels].len ; - - for (k = 0 ; k < len ; k++) - if (curr_map [k].channel_map != NULL) - if (memcmp (chan_map, curr_map [k].channel_map, channels * sizeof (chan_map [0])) == 0) - return curr_map [k].channel_layout_tag ; - - return 0 ; -} /* aiff_caf_find_channel_layout_tag */ - -const AIFF_CAF_CHANNEL_MAP * -aiff_caf_of_channel_layout_tag (int tag) -{ const AIFF_CAF_CHANNEL_MAP * curr_map ; - unsigned k, len ; - int channels = tag & 0xffff ; - - if (channels < 0 || channels >= ARRAY_LEN (map)) - return NULL ; - - curr_map = map [channels].map ; - len = map [channels].len ; - - for (k = 0 ; k < len ; k++) - if (curr_map [k].channel_layout_tag == tag) - return curr_map + k ; - - return NULL ; -} /* aiff_caf_of_channel_layout_tag */ diff --git a/Engine/lib/libsndfile/src/chanmap.h b/Engine/lib/libsndfile/src/chanmap.h deleted file mode 100644 index 8af409dba..000000000 --- a/Engine/lib/libsndfile/src/chanmap.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -** Copyright (C) 2009-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -typedef struct -{ /* The tag in the AIFF or CAF file. */ - int channel_layout_tag ; - - /* The equivalent array of SF_CHANNEL_MAP_* entries. */ - const int * channel_map ; - - const char * name ; -} AIFF_CAF_CHANNEL_MAP ; - - -int aiff_caf_find_channel_layout_tag (const int *chan_map, int channels) ; - -const AIFF_CAF_CHANNEL_MAP * aiff_caf_of_channel_layout_tag (int tag) ; diff --git a/Engine/lib/libsndfile/src/chunk.c b/Engine/lib/libsndfile/src/chunk.c deleted file mode 100644 index 9b181fc74..000000000 --- a/Engine/lib/libsndfile/src/chunk.c +++ /dev/null @@ -1,266 +0,0 @@ -/* -** Copyright (C) 2008-2016 Erik de Castro Lopo -** Copyright (C) 2012 IOhannes m zmoelnig, IEM -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -static int64_t -hash_of_str (const char * str) -{ int64_t marker = 0 ; - int k ; - - for (k = 0 ; str [k] ; k++) - marker = marker * 0x7f + ((const uint8_t *) str) [k] ; - - return marker ; -} /* hash_of_str */ - -SF_CHUNK_ITERATOR * -psf_get_chunk_iterator (SF_PRIVATE * psf, const char * marker_str) -{ const READ_CHUNKS * pchk = &psf->rchunks ; - int idx ; - - if (marker_str) - idx = psf_find_read_chunk_str (pchk, marker_str) ; - else - idx = pchk->used > 0 ? 0 : -1 ; - - if (idx < 0) - return NULL ; - - if (psf->iterator == NULL) - { psf->iterator = calloc (1, sizeof (SF_CHUNK_ITERATOR)) ; - if (psf->iterator == NULL) - return NULL ; - } ; - - psf->iterator->sndfile = (SNDFILE *) psf ; - - if (marker_str) - { int64_t hash ; - size_t marker_len ; - union - { uint32_t marker ; - char str [5] ; - } u ; - - snprintf (u.str, sizeof (u.str), "%s", marker_str) ; - - marker_len = strlen (marker_str) ; - if (marker_len > 64) - marker_len = 64 ; - - hash = marker_len > 4 ? hash_of_str (marker_str) : u.marker ; - - memcpy (psf->iterator->id, marker_str, marker_len) ; - psf->iterator->id_size = (unsigned) marker_len ; - psf->iterator->hash = hash ; - } - - psf->iterator->current = idx ; - - return psf->iterator ; -} /* psf_get_chunk_iterator */ - -SF_CHUNK_ITERATOR * -psf_next_chunk_iterator (const READ_CHUNKS * pchk , SF_CHUNK_ITERATOR * iterator) -{ uint64_t hash = iterator->hash ; - uint32_t k ; - - iterator->current++ ; - - if (hash) - { for (k = iterator->current ; k < pchk->used ; k++) - if (pchk->chunks [k].hash == hash) - { iterator->current = k ; - return iterator ; - } - } - else if (iterator->current < pchk->used) - return iterator ; - - /* No match, clear iterator and return NULL */ - memset (iterator, 0, sizeof (*iterator)) ; - return NULL ; -} /* psf_next_chunk_iterator */ - -static int -psf_store_read_chunk (READ_CHUNKS * pchk, const READ_CHUNK * rchunk) -{ if (pchk->count == 0) - { pchk->used = 0 ; - pchk->count = 20 ; - pchk->chunks = calloc (pchk->count, sizeof (READ_CHUNK)) ; - if (!pchk->chunks) - { return SFE_MALLOC_FAILED ; - } ; - } - else if (pchk->used > pchk->count) - return SFE_INTERNAL ; - else if (pchk->used == pchk->count) - { READ_CHUNK * old_ptr = pchk->chunks ; - int new_count = 3 * (pchk->count + 1) / 2 ; - - READ_CHUNK * new_chunks = realloc (old_ptr, new_count * sizeof (READ_CHUNK)) ; - if (new_chunks == NULL) - { - return SFE_MALLOC_FAILED ; - } else { - pchk->chunks = new_chunks; - } ; - pchk->count = new_count ; - } ; - - pchk->chunks [pchk->used] = *rchunk ; - - pchk->used ++ ; - - return SFE_NO_ERROR ; -} /* psf_store_read_chunk */ - -int -psf_store_read_chunk_u32 (READ_CHUNKS * pchk, uint32_t marker, sf_count_t offset, uint32_t len) -{ READ_CHUNK rchunk ; - - memset (&rchunk, 0, sizeof (rchunk)) ; - - rchunk.hash = marker ; - rchunk.mark32 = marker ; - rchunk.offset = offset ; - rchunk.len = len ; - - rchunk.id_size = 4 ; - memcpy (rchunk.id, &marker, rchunk.id_size) ; - - return psf_store_read_chunk (pchk, &rchunk) ; -} /* psf_store_read_chunk_u32 */ - -int -psf_find_read_chunk_str (const READ_CHUNKS * pchk, const char * marker_str) -{ uint64_t hash ; - uint32_t k ; - union - { uint32_t marker ; - char str [5] ; - } u ; - - snprintf (u.str, sizeof (u.str), "%s", marker_str) ; - - hash = strlen (marker_str) > 4 ? hash_of_str (marker_str) : u.marker ; - - for (k = 0 ; k < pchk->used ; k++) - if (pchk->chunks [k].hash == hash) - return k ; - - return -1 ; -} /* psf_find_read_chunk_str */ - -int -psf_find_read_chunk_m32 (const READ_CHUNKS * pchk, uint32_t marker) -{ uint32_t k ; - - for (k = 0 ; k < pchk->used ; k++) - if (pchk->chunks [k].mark32 == marker) - return k ; - - return -1 ; -} /* psf_find_read_chunk_m32 */ -int -psf_find_read_chunk_iterator (const READ_CHUNKS * pchk, const SF_CHUNK_ITERATOR * marker) -{ if (marker->current < pchk->used) - return marker->current ; - - return -1 ; -} /* psf_find_read_chunk_iterator */ - -int -psf_store_read_chunk_str (READ_CHUNKS * pchk, const char * marker_str, sf_count_t offset, uint32_t len) -{ READ_CHUNK rchunk ; - union - { uint32_t marker ; - char str [5] ; - } u ; - size_t marker_len ; - - memset (&rchunk, 0, sizeof (rchunk)) ; - snprintf (u.str, sizeof (u.str), "%s", marker_str) ; - - marker_len = strlen (marker_str) ; - - rchunk.hash = marker_len > 4 ? hash_of_str (marker_str) : u.marker ; - rchunk.mark32 = u.marker ; - rchunk.offset = offset ; - rchunk.len = len ; - - rchunk.id_size = marker_len > 64 ? 64 : (unsigned) marker_len ; - memcpy (rchunk.id, marker_str, rchunk.id_size) ; - - return psf_store_read_chunk (pchk, &rchunk) ; -} /* psf_store_read_chunk_str */ - -int -psf_save_write_chunk (WRITE_CHUNKS * pchk, const SF_CHUNK_INFO * chunk_info) -{ union - { uint32_t marker ; - char str [5] ; - /* Update snprintf() format string below when changing this */ - } u ; - uint32_t len ; - - if (pchk->count == 0) - { pchk->used = 0 ; - pchk->count = 20 ; - pchk->chunks = calloc (pchk->count, sizeof (WRITE_CHUNK)) ; - if (!pchk->chunks) - { return SFE_MALLOC_FAILED ; - } ; - } - else if (pchk->used >= pchk->count) - { WRITE_CHUNK * old_ptr = pchk->chunks ; - int new_count = 3 * (pchk->count + 1) / 2 ; - - WRITE_CHUNK * new_chunks = realloc (old_ptr, new_count * sizeof (WRITE_CHUNK)) ; - if (new_chunks == NULL) - { - return SFE_MALLOC_FAILED ; - } else { - pchk->chunks = new_chunks; - } ; - } ; - - len = chunk_info->datalen ; - while (len & 3) len ++ ; - - snprintf (u.str, sizeof (u.str), "%.4s", chunk_info->id) ; - - pchk->chunks [pchk->used].hash = strlen (chunk_info->id) > 4 ? hash_of_str (chunk_info->id) : u.marker ; - pchk->chunks [pchk->used].mark32 = u.marker ; - pchk->chunks [pchk->used].len = len ; - pchk->chunks [pchk->used].data = psf_memdup (chunk_info->data, chunk_info->datalen) ; - - pchk->used ++ ; - - return SFE_NO_ERROR ; -} /* psf_save_write_chunk */ - diff --git a/Engine/lib/libsndfile/src/command.c b/Engine/lib/libsndfile/src/command.c deleted file mode 100644 index d4837dab6..000000000 --- a/Engine/lib/libsndfile/src/command.c +++ /dev/null @@ -1,415 +0,0 @@ -/* -** Copyright (C) 2001-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "sndfile.h" -#include "common.h" - -static SF_FORMAT_INFO const simple_formats [] = -{ - { SF_FORMAT_AIFF | SF_FORMAT_PCM_16, - "AIFF (Apple/SGI 16 bit PCM)", "aiff" - }, - - { SF_FORMAT_AIFF | SF_FORMAT_FLOAT, - "AIFF (Apple/SGI 32 bit float)", "aifc" - }, - - { SF_FORMAT_AIFF | SF_FORMAT_PCM_S8, - "AIFF (Apple/SGI 8 bit PCM)", "aiff" - }, - - { SF_FORMAT_AU | SF_FORMAT_PCM_16, - "AU (Sun/Next 16 bit PCM)", "au" - }, - - { SF_FORMAT_AU | SF_FORMAT_ULAW, - "AU (Sun/Next 8-bit u-law)", "au" - }, - - { SF_FORMAT_CAF | SF_FORMAT_ALAC_16, - "CAF (Apple 16 bit ALAC)", "caf" - }, - - { SF_FORMAT_CAF | SF_FORMAT_PCM_16, - "CAF (Apple 16 bit PCM)", "caf" - }, - -#if HAVE_EXTERNAL_XIPH_LIBS - { SF_FORMAT_FLAC | SF_FORMAT_PCM_16, - "FLAC 16 bit", "flac" - }, -#endif - -#if HAVE_MPEG - { SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III, - "MPEG Layer 3", "mp3" - }, -#endif - - { SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, - "OKI Dialogic VOX ADPCM", "vox" - }, - -#if HAVE_EXTERNAL_XIPH_LIBS - { SF_FORMAT_OGG | SF_FORMAT_OPUS, - "Ogg Opus (Xiph Foundation)", "opus" - }, - - { SF_FORMAT_OGG | SF_FORMAT_VORBIS, - "Ogg Vorbis (Xiph Foundation)", "ogg" - }, -#endif - - { SF_FORMAT_WAV | SF_FORMAT_PCM_16, - "WAV (Microsoft 16 bit PCM)", "wav" - }, - - { SF_FORMAT_WAV | SF_FORMAT_FLOAT, - "WAV (Microsoft 32 bit float)", "wav" - }, - - { SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, - "WAV (Microsoft 4 bit IMA ADPCM)", "wav" - }, - - { SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, - "WAV (Microsoft 4 bit MS ADPCM)", "wav" - }, - - { SF_FORMAT_WAV | SF_FORMAT_PCM_U8, - "WAV (Microsoft 8 bit PCM)", "wav" - }, - -} ; /* simple_formats */ - -int -psf_get_format_simple_count (void) -{ return (sizeof (simple_formats) / sizeof (SF_FORMAT_INFO)) ; -} /* psf_get_format_simple_count */ - -int -psf_get_format_simple (SF_FORMAT_INFO *data) -{ int indx ; - - if (data->format < 0 || data->format >= (SIGNED_SIZEOF (simple_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO))) - return SFE_BAD_COMMAND_PARAM ; - - indx = data->format ; - memcpy (data, &(simple_formats [indx]), SIGNED_SIZEOF (SF_FORMAT_INFO)) ; - - return 0 ; -} /* psf_get_format_simple */ - -/*============================================================================ -** Major format info. -*/ - -static SF_FORMAT_INFO const major_formats [] = -{ - { SF_FORMAT_AIFF, "AIFF (Apple/SGI)", "aiff" }, - { SF_FORMAT_AU, "AU (Sun/NeXT)", "au" }, - { SF_FORMAT_AVR, "AVR (Audio Visual Research)", "avr" }, - { SF_FORMAT_CAF, "CAF (Apple Core Audio File)", "caf" }, -#if HAVE_EXTERNAL_XIPH_LIBS - { SF_FORMAT_FLAC, "FLAC (Free Lossless Audio Codec)", "flac" }, -#endif - { SF_FORMAT_HTK, "HTK (HMM Tool Kit)", "htk" }, - { SF_FORMAT_SVX, "IFF (Amiga IFF/SVX8/SV16)", "iff" }, - { SF_FORMAT_MAT4, "MAT4 (GNU Octave 2.0 / Matlab 4.2)", "mat" }, - { SF_FORMAT_MAT5, "MAT5 (GNU Octave 2.1 / Matlab 5.0)", "mat" }, - { SF_FORMAT_MPC2K, "MPC (Akai MPC 2k)", "mpc" }, -#if HAVE_MPEG - { SF_FORMAT_MPEG, "MPEG-1/2 Audio", "m1a" }, -#endif -#if HAVE_EXTERNAL_XIPH_LIBS - { SF_FORMAT_OGG, "OGG (OGG Container format)", "oga" }, -#endif - { SF_FORMAT_PAF, "PAF (Ensoniq PARIS)", "paf" }, - { SF_FORMAT_PVF, "PVF (Portable Voice Format)", "pvf" }, - { SF_FORMAT_RAW, "RAW (header-less)", "raw" }, - { SF_FORMAT_RF64, "RF64 (RIFF 64)", "rf64" }, - { SF_FORMAT_SD2, "SD2 (Sound Designer II)", "sd2" }, - { SF_FORMAT_SDS, "SDS (Midi Sample Dump Standard)", "sds" }, - { SF_FORMAT_IRCAM, "SF (Berkeley/IRCAM/CARL)", "sf" }, - { SF_FORMAT_VOC, "VOC (Creative Labs)", "voc" }, - { SF_FORMAT_W64, "W64 (SoundFoundry WAVE 64)", "w64" }, - { SF_FORMAT_WAV, "WAV (Microsoft)", "wav" }, - { SF_FORMAT_NIST, "WAV (NIST Sphere)", "wav" }, - { SF_FORMAT_WAVEX, "WAVEX (Microsoft)", "wav" }, - { SF_FORMAT_WVE, "WVE (Psion Series 3)", "wve" }, - { SF_FORMAT_XI, "XI (FastTracker 2)", "xi" }, - -} ; /* major_formats */ - -int -psf_get_format_major_count (void) -{ return (sizeof (major_formats) / sizeof (SF_FORMAT_INFO)) ; -} /* psf_get_format_major_count */ - -int -psf_get_format_major (SF_FORMAT_INFO *data) -{ int indx ; - - if (data->format < 0 || data->format >= (SIGNED_SIZEOF (major_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO))) - return SFE_BAD_COMMAND_PARAM ; - - indx = data->format ; - memcpy (data, &(major_formats [indx]), SIGNED_SIZEOF (SF_FORMAT_INFO)) ; - - return 0 ; -} /* psf_get_format_major */ - -/*============================================================================ -** Subtype format info. -*/ - -static SF_FORMAT_INFO subtype_formats [] = -{ - { SF_FORMAT_PCM_S8, "Signed 8 bit PCM", NULL }, - { SF_FORMAT_PCM_16, "Signed 16 bit PCM", NULL }, - { SF_FORMAT_PCM_24, "Signed 24 bit PCM", NULL }, - { SF_FORMAT_PCM_32, "Signed 32 bit PCM", NULL }, - - { SF_FORMAT_PCM_U8, "Unsigned 8 bit PCM", NULL }, - - { SF_FORMAT_FLOAT, "32 bit float", NULL }, - { SF_FORMAT_DOUBLE, "64 bit float", NULL }, - - { SF_FORMAT_ULAW, "U-Law", NULL }, - { SF_FORMAT_ALAW, "A-Law", NULL }, - { SF_FORMAT_IMA_ADPCM, "IMA ADPCM", NULL }, - { SF_FORMAT_MS_ADPCM, "Microsoft ADPCM", NULL }, - - { SF_FORMAT_GSM610, "GSM 6.10", NULL }, - - { SF_FORMAT_G721_32, "32kbs G721 ADPCM", NULL }, - { SF_FORMAT_G723_24, "24kbs G723 ADPCM", NULL }, - { SF_FORMAT_G723_40, "40kbs G723 ADPCM", NULL }, - - { SF_FORMAT_DWVW_12, "12 bit DWVW", NULL }, - { SF_FORMAT_DWVW_16, "16 bit DWVW", NULL }, - { SF_FORMAT_DWVW_24, "24 bit DWVW", NULL }, - { SF_FORMAT_VOX_ADPCM, "VOX ADPCM", "vox" }, - - { SF_FORMAT_NMS_ADPCM_16, "16kbs NMS ADPCM", NULL }, - { SF_FORMAT_NMS_ADPCM_24, "24kbs NMS ADPCM", NULL }, - { SF_FORMAT_NMS_ADPCM_32, "32kbs NMS ADPCM", NULL }, - - { SF_FORMAT_DPCM_16, "16 bit DPCM", NULL }, - { SF_FORMAT_DPCM_8, "8 bit DPCM", NULL }, - -#if HAVE_EXTERNAL_XIPH_LIBS - { SF_FORMAT_VORBIS, "Vorbis", NULL }, - { SF_FORMAT_OPUS, "Opus", NULL }, -#endif - -#if HAVE_MPEG - { SF_FORMAT_MPEG_LAYER_I, "MPEG Layer I", "mp1" }, - { SF_FORMAT_MPEG_LAYER_II, "MPEG Layer II", "mp2" }, - { SF_FORMAT_MPEG_LAYER_III, "MPEG Layer III", "mp3" }, -#endif - - { SF_FORMAT_ALAC_16, "16 bit ALAC", NULL }, - { SF_FORMAT_ALAC_20, "20 bit ALAC", NULL }, - { SF_FORMAT_ALAC_24, "24 bit ALAC", NULL }, - { SF_FORMAT_ALAC_32, "32 bit ALAC", NULL }, -} ; /* subtype_formats */ - -int -psf_get_format_subtype_count (void) -{ return (sizeof (subtype_formats) / sizeof (SF_FORMAT_INFO)) ; -} /* psf_get_format_subtype_count */ - -int -psf_get_format_subtype (SF_FORMAT_INFO *data) -{ int indx ; - - if (data->format < 0 || data->format >= (SIGNED_SIZEOF (subtype_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO))) - { data->format = 0 ; - return SFE_BAD_COMMAND_PARAM ; - } ; - - indx = data->format ; - memcpy (data, &(subtype_formats [indx]), sizeof (SF_FORMAT_INFO)) ; - - return 0 ; -} /* psf_get_format_subtype */ - -/*============================================================================== -*/ - -int -psf_get_format_info (SF_FORMAT_INFO *data) -{ int k, format ; - - if (SF_CONTAINER (data->format)) - { format = SF_CONTAINER (data->format) ; - - for (k = 0 ; k < (SIGNED_SIZEOF (major_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO)) ; k++) - { if (format == major_formats [k].format) - { memcpy (data, &(major_formats [k]), sizeof (SF_FORMAT_INFO)) ; - return 0 ; - } ; - } ; - } - else if (SF_CODEC (data->format)) - { format = SF_CODEC (data->format) ; - - for (k = 0 ; k < (SIGNED_SIZEOF (subtype_formats) / SIGNED_SIZEOF (SF_FORMAT_INFO)) ; k++) - { if (format == subtype_formats [k].format) - { memcpy (data, &(subtype_formats [k]), sizeof (SF_FORMAT_INFO)) ; - return 0 ; - } ; - } ; - } ; - - memset (data, 0, sizeof (SF_FORMAT_INFO)) ; - - return SFE_BAD_COMMAND_PARAM ; -} /* psf_get_format_info */ - -/*============================================================================== -*/ - -double -psf_calc_signal_max (SF_PRIVATE *psf, int normalize) -{ BUF_UNION ubuf ; - sf_count_t position ; - double max_val, temp, *data ; - int k, len, readcount, save_state ; - - /* If the file is not seekable, there is nothing we can do. */ - if (! psf->sf.seekable) - { psf->error = SFE_NOT_SEEKABLE ; - return 0.0 ; - } ; - - if (! psf->read_double) - { psf->error = SFE_UNIMPLEMENTED ; - return 0.0 ; - } ; - - save_state = sf_command ((SNDFILE*) psf, SFC_GET_NORM_DOUBLE, NULL, 0) ; - sf_command ((SNDFILE*) psf, SFC_SET_NORM_DOUBLE, NULL, normalize) ; - - /* Brute force. Read the whole file and find the biggest sample. */ - /* Get current position in file */ - position = sf_seek ((SNDFILE*) psf, 0, SEEK_CUR) ; - /* Go to start of file. */ - sf_seek ((SNDFILE*) psf, 0, SEEK_SET) ; - - data = ubuf.dbuf ; - /* Make sure len is an integer multiple of the channel count. */ - len = ARRAY_LEN (ubuf.dbuf) - (ARRAY_LEN (ubuf.dbuf) % psf->sf.channels) ; - - for (readcount = 1, max_val = 0.0 ; readcount > 0 ; /* nothing */) - { readcount = (int) sf_read_double ((SNDFILE*) psf, data, len) ; - for (k = 0 ; k < readcount ; k++) - { temp = fabs (data [k]) ; - max_val = temp > max_val ? temp : max_val ; - } ; - } ; - - /* Return to SNDFILE to original state. */ - sf_seek ((SNDFILE*) psf, position, SEEK_SET) ; - sf_command ((SNDFILE*) psf, SFC_SET_NORM_DOUBLE, NULL, save_state) ; - - return max_val ; -} /* psf_calc_signal_max */ - -int -psf_calc_max_all_channels (SF_PRIVATE *psf, double *peaks, int normalize) -{ BUF_UNION ubuf ; - sf_count_t position ; - double temp, *data ; - int k, len, readcount, save_state ; - int chan ; - - /* If the file is not seekable, there is nothing we can do. */ - if (! psf->sf.seekable) - return (psf->error = SFE_NOT_SEEKABLE) ; - - if (! psf->read_double) - return (psf->error = SFE_UNIMPLEMENTED) ; - - save_state = sf_command ((SNDFILE*) psf, SFC_GET_NORM_DOUBLE, NULL, 0) ; - sf_command ((SNDFILE*) psf, SFC_SET_NORM_DOUBLE, NULL, normalize) ; - - memset (peaks, 0, sizeof (double) * psf->sf.channels) ; - - /* Brute force. Read the whole file and find the biggest sample for each channel. */ - position = sf_seek ((SNDFILE*) psf, 0, SEEK_CUR) ; /* Get current position in file */ - sf_seek ((SNDFILE*) psf, 0, SEEK_SET) ; /* Go to start of file. */ - - len = ARRAY_LEN (ubuf.dbuf) - (ARRAY_LEN (ubuf.dbuf) % psf->sf.channels) ; - - data = ubuf.dbuf ; - - chan = 0 ; - readcount = len ; - while (readcount > 0) - { readcount = (int) sf_read_double ((SNDFILE*) psf, data, len) ; - for (k = 0 ; k < readcount ; k++) - { temp = fabs (data [k]) ; - peaks [chan] = temp > peaks [chan] ? temp : peaks [chan] ; - chan = (chan + 1) % psf->sf.channels ; - } ; - } ; - - sf_seek ((SNDFILE*) psf, position, SEEK_SET) ; /* Return to original position. */ - - sf_command ((SNDFILE*) psf, SFC_SET_NORM_DOUBLE, NULL, save_state) ; - - return 0 ; -} /* psf_calc_max_all_channels */ - -int -psf_get_signal_max (SF_PRIVATE *psf, double *peak) -{ int k ; - - if (psf->peak_info == NULL) - return SF_FALSE ; - - peak [0] = psf->peak_info->peaks [0].value ; - - for (k = 1 ; k < psf->sf.channels ; k++) - peak [0] = SF_MAX (peak [0], psf->peak_info->peaks [k].value) ; - - return SF_TRUE ; -} /* psf_get_signal_max */ - -int -psf_get_max_all_channels (SF_PRIVATE *psf, double *peaks) -{ int k ; - - if (psf->peak_info == NULL) - return SF_FALSE ; - - for (k = 0 ; k < psf->sf.channels ; k++) - peaks [k] = psf->peak_info->peaks [k].value ; - - return SF_TRUE ; -} /* psf_get_max_all_channels */ - - diff --git a/Engine/lib/libsndfile/src/common.c b/Engine/lib/libsndfile/src/common.c deleted file mode 100644 index 1c3d951db..000000000 --- a/Engine/lib/libsndfile/src/common.c +++ /dev/null @@ -1,1845 +0,0 @@ -/* -** Copyright (C) 1999-2019 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include - -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif -#include -#include -#include -#if HAVE_SYS_TIME_H -#include -#endif -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#define INITIAL_HEADER_SIZE 256 - -/* Allocate and initialize the SF_PRIVATE struct. */ -SF_PRIVATE * -psf_allocate (void) -{ SF_PRIVATE * psf ; - - if ((psf = calloc (1, sizeof (SF_PRIVATE))) == NULL) - return NULL ; - - if ((psf->header.ptr = calloc (1, INITIAL_HEADER_SIZE)) == NULL) - { free (psf) ; - return NULL ; - } ; - psf->header.len = INITIAL_HEADER_SIZE ; - - return psf ; -} /* psf_allocate */ - -static int -psf_bump_header_allocation (SF_PRIVATE * psf, sf_count_t needed) -{ - sf_count_t newlen, smallest = INITIAL_HEADER_SIZE ; - void * ptr ; - - newlen = (needed > psf->header.len) ? 2 * SF_MAX (needed, smallest) : 2 * psf->header.len ; - - if (newlen > 100 * 1024) - { psf_log_printf (psf, "Request for header allocation of %D denied.\n", newlen) ; - return 1 ; - } - - if ((ptr = realloc (psf->header.ptr, newlen)) == NULL) - { psf_log_printf (psf, "realloc (%p, %D) failed\n", psf->header.ptr, newlen) ; - psf->error = SFE_MALLOC_FAILED ; - return 1 ; - } ; - - /* Always zero-out new header memory to avoid un-initializer memory accesses. */ - if (newlen > psf->header.len) - memset ((char *) ptr + psf->header.len, 0, newlen - psf->header.len) ; - - psf->header.ptr = ptr ; - psf->header.len = newlen ; - return 0 ; -} /* psf_bump_header_allocation */ - -/*----------------------------------------------------------------------------------------------- -** psf_log_printf allows libsndfile internal functions to print to an internal parselog which -** can later be displayed. -** The format specifiers are as for printf but without the field width and other modifiers. -** Printing is performed to the parselog char array of the SF_PRIVATE struct. -** Printing is done in such a way as to guarantee that the log never overflows the end of the -** parselog array. -*/ - -static inline void -log_putchar (SF_PRIVATE *psf, char ch) -{ if (psf->parselog.indx < SIGNED_SIZEOF (psf->parselog.buf) - 1) - { psf->parselog.buf [psf->parselog.indx++] = ch ; - psf->parselog.buf [psf->parselog.indx] = 0 ; - } ; - return ; -} /* log_putchar */ - -void -psf_log_printf (SF_PRIVATE *psf, const char *format, ...) -{ va_list ap ; - uint32_t u, tens ; - int d, shift, width, width_specifier, left_align, slen, precision ; - char c, *strptr, istr [5], lead_char, sign_char ; - - va_start (ap, format) ; - - while ((c = *format++)) - { if (c != '%') - { log_putchar (psf, c) ; - continue ; - } ; - - if (format [0] == '%') /* Handle %% */ - { log_putchar (psf, '%') ; - format ++ ; - continue ; - } ; - - sign_char = 0 ; - left_align = SF_FALSE ; - while (1) - { switch (format [0]) - { case ' ' : - case '+' : - sign_char = format [0] ; - format ++ ; - continue ; - - case '-' : - left_align = SF_TRUE ; - format ++ ; - continue ; - - default : break ; - } ; - - break ; - } ; - - if (format [0] == 0) - break ; - - lead_char = ' ' ; - if (format [0] == '0') - lead_char = '0' ; - - width_specifier = 0 ; - while ((c = *format++) && isdigit (c)) - width_specifier = width_specifier * 10 + (c - '0') ; - - precision = 0 ; - if (c == '.') - { while ((c = *format++) && isdigit (c)) - precision = precision * 10 + (c - '0') ; - } ; - - switch (c) - { case 0 : /* NULL character. */ - va_end (ap) ; - return ; - - case 's': /* string */ - strptr = va_arg (ap, char *) ; - if (strptr == NULL) - break ; - if (precision > 0) - slen = strnlen (strptr, precision) ; - else - slen = strlen (strptr) ; - width_specifier = width_specifier >= slen ? width_specifier - slen : 0 ; - if (left_align == SF_FALSE) - while (width_specifier -- > 0) - log_putchar (psf, ' ') ; - while (slen--) - log_putchar (psf, *strptr++) ; - while (width_specifier -- > 0) - log_putchar (psf, ' ') ; - break ; - - case 'd': /* int */ - d = va_arg (ap, int) ; - - if (d < 0) - { sign_char = '-' ; - if (lead_char != '0' && left_align == SF_FALSE) - width_specifier -- ; - - u = - ((unsigned) d) ; - } - else - { u = (unsigned) d ; - } - - tens = 1 ; - width = 1 ; - while (u / tens >= 10) - { tens *= 10 ; - width ++ ; - } ; - - width_specifier -= width ; - - if (sign_char == ' ') - { log_putchar (psf, ' ') ; - width_specifier -- ; - } ; - - if (left_align == SF_FALSE && lead_char != '0') - { if (sign_char == '+') - width_specifier -- ; - - while (width_specifier -- > 0) - log_putchar (psf, lead_char) ; - } ; - - if (sign_char == '+' || sign_char == '-') - { log_putchar (psf, sign_char) ; - width_specifier -- ; - } ; - - if (left_align == SF_FALSE) - while (width_specifier -- > 0) - log_putchar (psf, lead_char) ; - - while (tens > 0) - { log_putchar (psf, '0' + u / tens) ; - u %= tens ; - tens /= 10 ; - } ; - - while (width_specifier -- > 0) - log_putchar (psf, lead_char) ; - break ; - - case 'D': /* sf_count_t */ - { sf_count_t D ; - uint64_t U, Tens ; - - D = va_arg (ap, sf_count_t) ; - - if (D == 0) - { while (-- width_specifier > 0) - log_putchar (psf, lead_char) ; - log_putchar (psf, '0') ; - break ; - } - else - { if (D < 0) - { log_putchar (psf, '-') ; - U = - ((uint64_t) D) ; - } - else - { U = (uint64_t) D ; - } - } - - Tens = 1 ; - width = 1 ; - while (U / Tens >= 10) - { Tens *= 10 ; - width ++ ; - } ; - - while (width_specifier > width) - { log_putchar (psf, lead_char) ; - width_specifier-- ; - } ; - - while (Tens > 0) - { log_putchar (psf, '0' + U / Tens) ; - U %= Tens ; - Tens /= 10 ; - } ; - } ; - break ; - - case 'u': /* unsigned int */ - u = va_arg (ap, unsigned int) ; - - tens = 1 ; - width = 1 ; - while (u / tens >= 10) - { tens *= 10 ; - width ++ ; - } ; - - width_specifier -= width ; - - if (sign_char == ' ') - { log_putchar (psf, ' ') ; - width_specifier -- ; - } ; - - if (left_align == SF_FALSE && lead_char != '0') - { if (sign_char == '+') - width_specifier -- ; - - while (width_specifier -- > 0) - log_putchar (psf, lead_char) ; - } ; - - if (sign_char == '+' || sign_char == '-') - { log_putchar (psf, sign_char) ; - width_specifier -- ; - } ; - - if (left_align == SF_FALSE) - while (width_specifier -- > 0) - log_putchar (psf, lead_char) ; - - while (tens > 0) - { log_putchar (psf, '0' + u / tens) ; - u %= tens ; - tens /= 10 ; - } ; - - while (width_specifier -- > 0) - log_putchar (psf, lead_char) ; - break ; - - case 'c': /* char */ - c = va_arg (ap, int) & 0xFF ; - log_putchar (psf, c) ; - break ; - - case 'x': /* hex */ - case 'X': /* hex */ - d = va_arg (ap, int) ; - - if (d == 0) - { while (--width_specifier > 0) - log_putchar (psf, lead_char) ; - log_putchar (psf, '0') ; - break ; - } ; - shift = 28 ; - width = (width_specifier < 8) ? 8 : width_specifier ; - while (! ((((uint32_t) 0xF) << shift) & d)) - { shift -= 4 ; - width -- ; - } ; - - while (width > 0 && width_specifier > width) - { log_putchar (psf, lead_char) ; - width_specifier-- ; - } ; - - while (shift >= 0) - { c = (d >> shift) & 0xF ; - log_putchar (psf, (c > 9) ? c + 'A' - 10 : c + '0') ; - shift -= 4 ; - } ; - break ; - - case 'M': /* int2str */ - d = va_arg (ap, int) ; - if (CPU_IS_LITTLE_ENDIAN) - { istr [0] = d & 0xFF ; - istr [1] = (d >> 8) & 0xFF ; - istr [2] = (d >> 16) & 0xFF ; - istr [3] = (d >> 24) & 0xFF ; - } - else - { istr [3] = d & 0xFF ; - istr [2] = (d >> 8) & 0xFF ; - istr [1] = (d >> 16) & 0xFF ; - istr [0] = (d >> 24) & 0xFF ; - } ; - istr [4] = 0 ; - strptr = istr ; - while (*strptr) - { c = *strptr++ ; - log_putchar (psf, psf_isprint (c) ? c : '.') ; - } ; - break ; - - default : - log_putchar (psf, '*') ; - log_putchar (psf, c) ; - log_putchar (psf, '*') ; - break ; - } /* switch */ - } /* while */ - - va_end (ap) ; - return ; -} /* psf_log_printf */ - -/*----------------------------------------------------------------------------------------------- -** ASCII header printf functions. -** Some formats (ie NIST) use ascii text in their headers. -** Format specifiers are the same as the standard printf specifiers (uses vsnprintf). -** If this generates a compile error on any system, the author should be notified -** so an alternative vsnprintf can be provided. -*/ - -void -psf_asciiheader_printf (SF_PRIVATE *psf, const char *format, ...) -{ va_list argptr ; - int maxlen ; - char *start ; - - if (! format) - return ; - - maxlen = strlen ((char*) psf->header.ptr) ; - start = ((char*) psf->header.ptr) + maxlen ; - maxlen = psf->header.len - maxlen ; - - va_start (argptr, format) ; - vsnprintf (start, maxlen, format, argptr) ; - va_end (argptr) ; - - /* Make sure the string is properly terminated. */ - start [maxlen - 1] = 0 ; - - psf->header.indx = strlen ((char*) psf->header.ptr) ; - - return ; -} /* psf_asciiheader_printf */ - -/*----------------------------------------------------------------------------------------------- -** Binary header writing functions. Returns number of bytes written. -** -** Format specifiers for psf_binheader_writef are as follows -** m - marker - four bytes - no endian manipulation -** -** e - all following numerical values will be little endian -** E - all following numerical values will be big endian -** -** t - all following O types will be truncated to 4 bytes -** T - switch off truncation of all following O types -** -** 1 - single byte value -** 2 - two byte value -** 3 - three byte value -** 4 - four byte value -** 8 - eight byte value (sometimes written as 4 bytes) -** -** s - string preceded by a four byte length -** S - string including null terminator -** p - a Pascal string -** -** f - floating point data -** d - double precision floating point data -** h - 16 binary bytes value -** -** b - binary data (see below) -** z - zero bytes (ses below) -** j - jump forwards or backwards -** -** To write a word followed by an int (both little endian) use: -** psf_binheader_writef ("e24", wordval, longval) ; -** -** To write binary data use: -** psf_binheader_writef ("b", &bindata, sizeof (bindata)) ; -** -** To write N zero bytes use: -** NOTE: due to platform issues (ie x86-64) you should cast the -** argument to size_t or ensure the variable type is size_t. -** psf_binheader_writef ("z", N) ; -*/ - -/* These macros may seem a bit messy but do prevent problems with processors which -** seg. fault when asked to write an int or short to a non-int/short aligned address. -*/ - -static inline void -header_put_byte (SF_PRIVATE *psf, char x) -{ psf->header.ptr [psf->header.indx++] = x ; -} /* header_put_byte */ - -#if (CPU_IS_BIG_ENDIAN == 1) -static inline void -header_put_marker (SF_PRIVATE *psf, int x) -{ psf->header.ptr [psf->header.indx++] = (x >> 24) ; - psf->header.ptr [psf->header.indx++] = (x >> 16) ; - psf->header.ptr [psf->header.indx++] = (x >> 8) ; - psf->header.ptr [psf->header.indx++] = x ; -} /* header_put_marker */ - -#elif (CPU_IS_LITTLE_ENDIAN == 1) -static inline void -header_put_marker (SF_PRIVATE *psf, int x) -{ psf->header.ptr [psf->header.indx++] = x ; - psf->header.ptr [psf->header.indx++] = (x >> 8) ; - psf->header.ptr [psf->header.indx++] = (x >> 16) ; - psf->header.ptr [psf->header.indx++] = (x >> 24) ; -} /* header_put_marker */ - -#else -# error "Cannot determine endian-ness of processor." -#endif - - -static inline void -header_put_be_short (SF_PRIVATE *psf, int x) -{ psf->header.ptr [psf->header.indx++] = (x >> 8) ; - psf->header.ptr [psf->header.indx++] = x ; -} /* header_put_be_short */ - -static inline void -header_put_le_short (SF_PRIVATE *psf, int x) -{ psf->header.ptr [psf->header.indx++] = x ; - psf->header.ptr [psf->header.indx++] = (x >> 8) ; -} /* header_put_le_short */ - -static inline void -header_put_be_3byte (SF_PRIVATE *psf, int x) -{ psf->header.ptr [psf->header.indx++] = (x >> 16) ; - psf->header.ptr [psf->header.indx++] = (x >> 8) ; - psf->header.ptr [psf->header.indx++] = x ; -} /* header_put_be_3byte */ - -static inline void -header_put_le_3byte (SF_PRIVATE *psf, int x) -{ psf->header.ptr [psf->header.indx++] = x ; - psf->header.ptr [psf->header.indx++] = (x >> 8) ; - psf->header.ptr [psf->header.indx++] = (x >> 16) ; -} /* header_put_le_3byte */ - -static inline void -header_put_be_int (SF_PRIVATE *psf, int x) -{ psf->header.ptr [psf->header.indx++] = (x >> 24) ; - psf->header.ptr [psf->header.indx++] = (x >> 16) ; - psf->header.ptr [psf->header.indx++] = (x >> 8) ; - psf->header.ptr [psf->header.indx++] = x ; -} /* header_put_be_int */ - -static inline void -header_put_le_int (SF_PRIVATE *psf, int x) -{ psf->header.ptr [psf->header.indx++] = x ; - psf->header.ptr [psf->header.indx++] = (x >> 8) ; - psf->header.ptr [psf->header.indx++] = (x >> 16) ; - psf->header.ptr [psf->header.indx++] = (x >> 24) ; -} /* header_put_le_int */ - -static inline void -header_put_be_8byte (SF_PRIVATE *psf, sf_count_t x) -{ psf->header.ptr [psf->header.indx++] = (x >> 56) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 48) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 40) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 32) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 24) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 16) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 8) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) x ; -} /* header_put_be_8byte */ - -static inline void -header_put_le_8byte (SF_PRIVATE *psf, sf_count_t x) -{ psf->header.ptr [psf->header.indx++] = (unsigned char) x ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 8) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 16) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 24) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 32) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 40) ; - psf->header.ptr [psf->header.indx++] = (unsigned char) (x >> 48) ; - psf->header.ptr [psf->header.indx++] = (x >> 56) ; -} /* header_put_le_8byte */ - -int -psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...) -{ va_list argptr ; - sf_count_t countdata ; - unsigned long longdata ; - unsigned int data ; - float floatdata ; - double doubledata ; - void *bindata ; - size_t size ; - char c, *strptr ; - int count = 0, trunc_8to4 = SF_FALSE ; - - if (! format) - return psf_ftell (psf) ; - - va_start (argptr, format) ; - - while ((c = *format++)) - { - if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16)) - break ; - - switch (c) - { case ' ' : /* Do nothing. Just used to space out format string. */ - break ; - - case 'e' : /* All conversions are now from LE to host. */ - psf->rwf_endian = SF_ENDIAN_LITTLE ; - break ; - - case 'E' : /* All conversions are now from BE to host. */ - psf->rwf_endian = SF_ENDIAN_BIG ; - break ; - - case 't' : /* All 8 byte values now get written as 4 bytes. */ - trunc_8to4 = SF_TRUE ; - break ; - - case 'T' : /* All 8 byte values now get written as 8 bytes. */ - trunc_8to4 = SF_FALSE ; - break ; - - case 'm' : - data = va_arg (argptr, unsigned int) ; - header_put_marker (psf, data) ; - count += 4 ; - break ; - - case '1' : - data = va_arg (argptr, unsigned int) ; - header_put_byte (psf, data) ; - count += 1 ; - break ; - - case '2' : - data = va_arg (argptr, unsigned int) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - { header_put_be_short (psf, data) ; - } - else - { header_put_le_short (psf, data) ; - } ; - count += 2 ; - break ; - - case '3' : /* tribyte */ - data = va_arg (argptr, unsigned int) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - { header_put_be_3byte (psf, data) ; - } - else - { header_put_le_3byte (psf, data) ; - } ; - count += 3 ; - break ; - - case '4' : - data = va_arg (argptr, unsigned int) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - { header_put_be_int (psf, data) ; - } - else - { header_put_le_int (psf, data) ; - } ; - count += 4 ; - break ; - - case '8' : - countdata = va_arg (argptr, sf_count_t) ; - if (psf->rwf_endian == SF_ENDIAN_BIG && trunc_8to4 == SF_FALSE) - { header_put_be_8byte (psf, countdata) ; - count += 8 ; - } - else if (psf->rwf_endian == SF_ENDIAN_LITTLE && trunc_8to4 == SF_FALSE) - { header_put_le_8byte (psf, countdata) ; - count += 8 ; - } - else if (psf->rwf_endian == SF_ENDIAN_BIG && trunc_8to4 == SF_TRUE) - { longdata = countdata & 0xFFFFFFFF ; - header_put_be_int (psf, longdata) ; - count += 4 ; - } - else if (psf->rwf_endian == SF_ENDIAN_LITTLE && trunc_8to4 == SF_TRUE) - { longdata = countdata & 0xFFFFFFFF ; - header_put_le_int (psf, longdata) ; - count += 4 ; - } - break ; - - case 'f' : - /* Floats are passed as doubles. Is this always true? */ - floatdata = (float) va_arg (argptr, double) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - float32_be_write (floatdata, psf->header.ptr + psf->header.indx) ; - else - float32_le_write (floatdata, psf->header.ptr + psf->header.indx) ; - psf->header.indx += 4 ; - count += 4 ; - break ; - - case 'd' : - doubledata = va_arg (argptr, double) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - double64_be_write (doubledata, psf->header.ptr + psf->header.indx) ; - else - double64_le_write (doubledata, psf->header.ptr + psf->header.indx) ; - psf->header.indx += 8 ; - count += 8 ; - break ; - - case 's' : - /* Write a C string (guaranteed to have a zero terminator). */ - strptr = va_arg (argptr, char *) ; - size = strlen (strptr) + 1 ; - - if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1))) - break ; - - if (psf->rwf_endian == SF_ENDIAN_BIG) - header_put_be_int (psf, size + (size & 1)) ; - else - header_put_le_int (psf, size + (size & 1)) ; - memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ; - size += (size & 1) ; - psf->header.indx += size ; - psf->header.ptr [psf->header.indx - 1] = 0 ; - count += 4 + size ; - break ; - - case 'S' : - /* - ** Write an AIFF style string (no zero terminator but possibly - ** an extra pad byte if the string length is odd). - */ - strptr = va_arg (argptr, char *) ; - size = strlen (strptr) ; - if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1))) - break ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - header_put_be_int (psf, size) ; - else - header_put_le_int (psf, size) ; - memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + (size & 1)) ; - size += (size & 1) ; - psf->header.indx += size ; - count += 4 + size ; - break ; - - case 'p' : - /* Write a PASCAL string (as used by AIFF files). - */ - strptr = va_arg (argptr, char *) ; - size = strlen (strptr) ; - size = (size & 1) ? size : size + 1 ; - size = (size > 254) ? 254 : size ; - - if (psf->header.indx + 1 + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, 1 + size)) - break ; - - header_put_byte (psf, size) ; - memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ; - psf->header.indx += size ; - count += 1 + size ; - break ; - - case 'b' : - bindata = va_arg (argptr, void *) ; - size = va_arg (argptr, size_t) ; - - if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size)) - break ; - - memcpy (&(psf->header.ptr [psf->header.indx]), bindata, size) ; - psf->header.indx += size ; - count += size ; - break ; - - case 'z' : - size = va_arg (argptr, size_t) ; - - if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size)) - break ; - - count += size ; - while (size) - { psf->header.ptr [psf->header.indx] = 0 ; - psf->header.indx ++ ; - size -- ; - } ; - break ; - - case 'h' : - bindata = va_arg (argptr, void *) ; - memcpy (&(psf->header.ptr [psf->header.indx]), bindata, 16) ; - psf->header.indx += 16 ; - count += 16 ; - break ; - - case 'j' : /* Jump forwards/backwards by specified amount. */ - size = va_arg (argptr, size_t) ; - - if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size)) - break ; - - psf->header.indx += size ; - count += size ; - break ; - - case 'o' : /* Jump to specified offset. */ - size = va_arg (argptr, size_t) ; - - if ((sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, size)) - break ; - - psf->header.indx = size ; - break ; - - default : - psf_log_printf (psf, "*** Invalid format specifier `%c'\n", c) ; - psf->error = SFE_INTERNAL ; - break ; - } ; - } ; - - va_end (argptr) ; - return count ; -} /* psf_binheader_writef */ - -/*----------------------------------------------------------------------------------------------- -** Binary header reading functions. Returns number of bytes read. -** -** Format specifiers are the same as for header write function above with the following -** additions: -** -** p - jump a given number of position from start of file. -** -** If format is NULL, psf_binheader_readf returns the current offset. -*/ - -#if (CPU_IS_BIG_ENDIAN == 1) -#define GET_MARKER(ptr) ( (((uint32_t) (ptr) [0]) << 24) | ((ptr) [1] << 16) | \ - ((ptr) [2] << 8) | ((ptr) [3])) - -#elif (CPU_IS_LITTLE_ENDIAN == 1) -#define GET_MARKER(ptr) ( ((ptr) [0]) | ((ptr) [1] << 8) | \ - ((ptr) [2] << 16) | (((uint32_t) (ptr) [3]) << 24)) - -#else -# error "Cannot determine endian-ness of processor." -#endif - -#define GET_LE_SHORT(ptr) (((ptr) [1] << 8) | ((ptr) [0])) -#define GET_BE_SHORT(ptr) (((ptr) [0] << 8) | ((ptr) [1])) - -#define GET_LE_3BYTE(ptr) ( ((ptr) [2] << 16) | ((ptr) [1] << 8) | ((ptr) [0])) -#define GET_BE_3BYTE(ptr) ( ((ptr) [0] << 16) | ((ptr) [1] << 8) | ((ptr) [2])) - -#define GET_LE_INT(ptr) ( ((ptr) [3] << 24) | ((ptr) [2] << 16) | \ - ((ptr) [1] << 8) | ((ptr) [0])) - -#define GET_BE_INT(ptr) ( ((ptr) [0] << 24) | ((ptr) [1] << 16) | \ - ((ptr) [2] << 8) | ((ptr) [3])) - -#define GET_LE_8BYTE(ptr) ( (((sf_count_t) (ptr) [7]) << 56) | (((sf_count_t) (ptr) [6]) << 48) | \ - (((sf_count_t) (ptr) [5]) << 40) | (((sf_count_t) (ptr) [4]) << 32) | \ - (((sf_count_t) (ptr) [3]) << 24) | (((sf_count_t) (ptr) [2]) << 16) | \ - (((sf_count_t) (ptr) [1]) << 8) | ((ptr) [0])) - -#define GET_BE_8BYTE(ptr) ( (((sf_count_t) (ptr) [0]) << 56) | (((sf_count_t) (ptr) [1]) << 48) | \ - (((sf_count_t) (ptr) [2]) << 40) | (((sf_count_t) (ptr) [3]) << 32) | \ - (((sf_count_t) (ptr) [4]) << 24) | (((sf_count_t) (ptr) [5]) << 16) | \ - (((sf_count_t) (ptr) [6]) << 8) | ((ptr) [7])) - - - -static int -header_read (SF_PRIVATE *psf, void *ptr, int bytes) -{ int count = 0 ; - - if (psf->header.indx + bytes >= psf->header.len && psf_bump_header_allocation (psf, bytes)) - return count ; - - if (psf->header.indx + bytes > psf->header.end) - { count = psf_fread (psf->header.ptr + psf->header.end, 1, bytes - (psf->header.end - psf->header.indx), psf) ; - if (count != bytes - (int) (psf->header.end - psf->header.indx)) - { psf_log_printf (psf, "Error : psf_fread returned short count.\n") ; - return count ; - } ; - psf->header.end += count ; - } ; - - memcpy (ptr, psf->header.ptr + psf->header.indx, bytes) ; - psf->header.indx += bytes ; - - return bytes ; -} /* header_read */ - -static void -header_seek (SF_PRIVATE *psf, sf_count_t position, int whence) -{ - switch (whence) - { case SEEK_SET : - if (psf->header.indx + position >= psf->header.len) - psf_bump_header_allocation (psf, position) ; - if (position > psf->header.len) - { /* Too much header to cache so just seek instead. */ - psf->header.indx = psf->header.end = 0 ; - psf_fseek (psf, position, whence) ; - return ; - } ; - if (position > psf->header.end) - psf->header.end += psf_fread (psf->header.ptr + psf->header.end, 1, position - psf->header.end, psf) ; - psf->header.indx = position ; - break ; - - case SEEK_CUR : - if (psf->header.indx + position >= psf->header.len) - psf_bump_header_allocation (psf, position) ; - - if (psf->header.indx + position < 0) - break ; - - if (psf->header.indx >= psf->header.len) - { psf_fseek (psf, position, whence) ; - return ; - } ; - - if (psf->header.indx + position <= psf->header.end) - { psf->header.indx += position ; - break ; - } ; - - if (psf->header.indx + position > psf->header.len) - { /* Need to jump this without caching it. */ - position -= (psf->header.end - psf->header.indx) ; - psf->header.indx = psf->header.end ; - if (psf->is_pipe) - { - /* seeking is not supported on pipe input, so we read instead */ - size_t skip = position ; - while (skip) - { char junk [16 * 1024] ; - size_t to_skip = SF_MIN (skip, sizeof (junk)) ; - psf_fread (junk, 1, to_skip, psf) ; - skip -= to_skip ; - } - } - else - { psf_fseek (psf, position, SEEK_CUR) ; - } - break ; - } ; - - psf->header.end += psf_fread (psf->header.ptr + psf->header.end, 1, position - (psf->header.end - psf->header.indx), psf) ; - psf->header.indx = psf->header.end ; - break ; - - case SEEK_END : - default : - psf_log_printf (psf, "Bad whence param in header_seek().\n") ; - break ; - } ; - - return ; -} /* header_seek */ - -static int -header_gets (SF_PRIVATE *psf, char *ptr, int bufsize) -{ int k ; - - if (psf->header.indx + bufsize >= psf->header.len && psf_bump_header_allocation (psf, bufsize)) - return 0 ; - - for (k = 0 ; k < bufsize - 1 ; k++) - { if (psf->header.indx < psf->header.end) - { ptr [k] = psf->header.ptr [psf->header.indx] ; - psf->header.indx ++ ; - } - else - { psf->header.end += psf_fread (psf->header.ptr + psf->header.end, 1, 1, psf) ; - ptr [k] = psf->header.ptr [psf->header.indx] ; - psf->header.indx = psf->header.end ; - } ; - - if (ptr [k] == '\n') - break ; - } ; - - ptr [k] = 0 ; - - return k ; -} /* header_gets */ - -int -psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...) -{ va_list argptr ; - sf_count_t *countptr, countdata ; - unsigned char *ucptr, sixteen_bytes [16] = { 0 } ; - unsigned int *intptr, intdata ; - unsigned short *shortptr ; - char *charptr ; - float *floatptr ; - double *doubleptr ; - char c ; - int byte_count = 0, count = 0 ; - - if (! format) - return psf_ftell (psf) ; - - va_start (argptr, format) ; - - while ((c = *format++)) - { - if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16)) - break ; - - switch (c) - { case 'e' : /* All conversions are now from LE to host. */ - psf->rwf_endian = SF_ENDIAN_LITTLE ; - break ; - - case 'E' : /* All conversions are now from BE to host. */ - psf->rwf_endian = SF_ENDIAN_BIG ; - break ; - - case 'm' : /* 4 byte marker value eg 'RIFF' */ - intptr = va_arg (argptr, unsigned int*) ; - *intptr = 0 ; - ucptr = (unsigned char*) intptr ; - byte_count += header_read (psf, ucptr, sizeof (int)) ; - *intptr = GET_MARKER (ucptr) ; - break ; - - case 'h' : - intptr = va_arg (argptr, unsigned int*) ; - *intptr = 0 ; - ucptr = (unsigned char*) intptr ; - byte_count += header_read (psf, sixteen_bytes, sizeof (sixteen_bytes)) ; - { int k ; - intdata = 0 ; - for (k = 0 ; k < 16 ; k++) - intdata ^= sixteen_bytes [k] << k ; - } - *intptr = intdata ; - break ; - - case '1' : - charptr = va_arg (argptr, char*) ; - *charptr = 0 ; - byte_count += header_read (psf, charptr, sizeof (char)) ; - break ; - - case '2' : /* 2 byte value with the current endian-ness */ - shortptr = va_arg (argptr, unsigned short*) ; - *shortptr = 0 ; - ucptr = (unsigned char*) shortptr ; - byte_count += header_read (psf, ucptr, sizeof (short)) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - *shortptr = GET_BE_SHORT (ucptr) ; - else - *shortptr = GET_LE_SHORT (ucptr) ; - break ; - - case '3' : /* 3 byte value with the current endian-ness */ - intptr = va_arg (argptr, unsigned int*) ; - *intptr = 0 ; - byte_count += header_read (psf, sixteen_bytes, 3) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - *intptr = GET_BE_3BYTE (sixteen_bytes) ; - else - *intptr = GET_LE_3BYTE (sixteen_bytes) ; - break ; - - case '4' : /* 4 byte value with the current endian-ness */ - intptr = va_arg (argptr, unsigned int*) ; - *intptr = 0 ; - ucptr = (unsigned char*) intptr ; - byte_count += header_read (psf, ucptr, sizeof (int)) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - *intptr = psf_get_be32 (ucptr, 0) ; - else - *intptr = psf_get_le32 (ucptr, 0) ; - break ; - - case '8' : /* 8 byte value with the current endian-ness */ - countptr = va_arg (argptr, sf_count_t *) ; - *countptr = 0 ; - byte_count += header_read (psf, sixteen_bytes, 8) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - countdata = psf_get_be64 (sixteen_bytes, 0) ; - else - countdata = psf_get_le64 (sixteen_bytes, 0) ; - *countptr = countdata ; - break ; - - case 'f' : /* Float conversion */ - floatptr = va_arg (argptr, float *) ; - *floatptr = 0.0 ; - byte_count += header_read (psf, floatptr, sizeof (float)) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - *floatptr = float32_be_read ((unsigned char*) floatptr) ; - else - *floatptr = float32_le_read ((unsigned char*) floatptr) ; - break ; - - case 'd' : /* double conversion */ - doubleptr = va_arg (argptr, double *) ; - *doubleptr = 0.0 ; - byte_count += header_read (psf, doubleptr, sizeof (double)) ; - if (psf->rwf_endian == SF_ENDIAN_BIG) - *doubleptr = double64_be_read ((unsigned char*) doubleptr) ; - else - *doubleptr = double64_le_read ((unsigned char*) doubleptr) ; - break ; - - case 's' : - psf_log_printf (psf, "Format conversion 's' not implemented yet.\n") ; - /* - strptr = va_arg (argptr, char *) ; - size = strlen (strptr) + 1 ; - size += (size & 1) ; - longdata = H2LE_32 (size) ; - get_int (psf, longdata) ; - memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ; - psf->header.indx += size ; - */ - break ; - - case 'b' : /* Raw bytes */ - charptr = va_arg (argptr, char*) ; - count = va_arg (argptr, size_t) ; - memset (charptr, 0, count) ; - byte_count += header_read (psf, charptr, count) ; - break ; - - case 'G' : - charptr = va_arg (argptr, char*) ; - count = va_arg (argptr, size_t) ; - memset (charptr, 0, count) ; - - if (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count)) - break ; - - byte_count += header_gets (psf, charptr, count) ; - break ; - - case 'z' : - psf_log_printf (psf, "Format conversion 'z' not implemented yet.\n") ; - /* - size = va_arg (argptr, size_t) ; - while (size) - { psf->header.ptr [psf->header.indx] = 0 ; - psf->header.indx ++ ; - size -- ; - } ; - */ - break ; - - case 'p' : /* Seek to position from start. */ - count = va_arg (argptr, size_t) ; - header_seek (psf, count, SEEK_SET) ; - byte_count = count ; - break ; - - case 'j' : /* Seek to position from current position. */ - count = va_arg (argptr, size_t) ; - header_seek (psf, count, SEEK_CUR) ; - byte_count += count ; - break ; - - case '!' : /* Clear buffer, forcing re-read. */ - psf->header.end = psf->header.indx = 0 ; - break ; - - default : - psf_log_printf (psf, "*** Invalid format specifier `%c'\n", c) ; - psf->error = SFE_INTERNAL ; - break ; - } ; - } ; - - va_end (argptr) ; - - return byte_count ; -} /* psf_binheader_readf */ - -/*----------------------------------------------------------------------------------------------- -*/ - -sf_count_t -psf_default_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t samples_from_start) -{ sf_count_t position, retval ; - - if (! (psf->blockwidth && psf->dataoffset >= 0)) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (! psf->sf.seekable) - { psf->error = SFE_NOT_SEEKABLE ; - return PSF_SEEK_ERROR ; - } ; - - position = psf->dataoffset + psf->blockwidth * samples_from_start ; - - if ((retval = psf_fseek (psf, position, SEEK_SET)) != position) - { psf->error = SFE_SEEK_FAILED ; - return PSF_SEEK_ERROR ; - } ; - - return samples_from_start ; -} /* psf_default_seek */ - -/*----------------------------------------------------------------------------------------------- -*/ - -void -psf_hexdump (const void *ptr, int len) -{ const char *data ; - char ascii [17] ; - int k, m ; - - if ((data = ptr) == NULL) - return ; - if (len <= 0) - return ; - - puts ("") ; - for (k = 0 ; k < len ; k += 16) - { memset (ascii, ' ', sizeof (ascii)) ; - - printf ("%08X: ", k) ; - for (m = 0 ; m < 16 && k + m < len ; m++) - { printf (m == 8 ? " %02X " : "%02X ", data [k + m] & 0xFF) ; - ascii [m] = psf_isprint (data [k + m]) ? data [k + m] : '.' ; - } ; - - if (m <= 8) printf (" ") ; - for ( ; m < 16 ; m++) printf (" ") ; - - ascii [16] = 0 ; - printf (" %s\n", ascii) ; - } ; - - puts ("") ; -} /* psf_hexdump */ - -void -psf_log_SF_INFO (SF_PRIVATE *psf) -{ psf_log_printf (psf, "---------------------------------\n") ; - - psf_log_printf (psf, " Sample rate : %d\n", psf->sf.samplerate) ; - if (psf->sf.frames == SF_COUNT_MAX) - psf_log_printf (psf, " Frames : unknown\n") ; - else - psf_log_printf (psf, " Frames : %D\n", psf->sf.frames) ; - psf_log_printf (psf, " Channels : %d\n", psf->sf.channels) ; - - psf_log_printf (psf, " Format : 0x%X\n", psf->sf.format) ; - psf_log_printf (psf, " Sections : %d\n", psf->sf.sections) ; - psf_log_printf (psf, " Seekable : %s\n", psf->sf.seekable ? "TRUE" : "FALSE") ; - - psf_log_printf (psf, "---------------------------------\n") ; -} /* psf_dump_SFINFO */ - -/*======================================================================================== -*/ - -int -psf_isprint (int ch) -{ return (ch >= ' ' && ch <= '~') ; -} /* psf_isprint */ - -void -psf_strlcat (char *dest, size_t n, const char *src) -{ strncat (dest, src, n - strlen (dest) - 1) ; - dest [n - 1] = 0 ; -} /* psf_strlcat */ - -void -psf_strlcpy (char *dest, size_t n, const char *src) -{ strncpy (dest, src, n - 1) ; - dest [n - 1] = 0 ; -} /* psf_strlcpy */ - -/*======================================================================================== -*/ - -void * -psf_memdup (const void *src, size_t n) -{ if (src == NULL) - return NULL ; - - void * mem = calloc (1, n & 3 ? n + 4 - (n & 3) : n) ; - if (mem != NULL) - memcpy (mem, src, n) ; - return mem ; -} /* psf_memdup */ - -void* -psf_memset (void *s, int c, sf_count_t len) -{ char *ptr ; - int setcount ; - - ptr = (char *) s ; - - while (len > 0) - { setcount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - memset (ptr, c, setcount) ; - - ptr += setcount ; - len -= setcount ; - } ; - - return s ; -} /* psf_memset */ - - -/* -** Clang refuses to do sizeof (SF_CUES_VAR (cue_count)) so we have to manually -** bodgy something up instead. -*/ - -#ifdef _MSC_VER -typedef SF_CUES_VAR (0) SF_CUES_0 ; -#else -typedef SF_CUES_VAR () SF_CUES_0 ; -#endif - -/* calculate size of SF_CUES struct given number of cues */ -#define SF_CUES_VAR_SIZE(count) (sizeof (SF_CUES_0) + count * sizeof (SF_CUE_POINT)) - -/* calculate number of cues in SF_CUES struct given data size */ -#define SF_CUES_COUNT(datasize) (((datasize) - sizeof (uint32_t)) / sizeof (SF_CUE_POINT)) - -SF_CUES * -psf_cues_alloc (uint32_t cue_count) -{ SF_CUES *pcues = calloc (1, SF_CUES_VAR_SIZE (cue_count)) ; - if (pcues) - { pcues->cue_count = cue_count ; - } ; - return pcues ; -} /* psf_cues_alloc */ - -SF_CUES * -psf_cues_dup (const void * ptr, size_t datasize) -{ const SF_CUES *pcues = ptr ; - SF_CUES *pnew = NULL ; - - if (pcues->cue_count <= SF_CUES_COUNT (datasize)) - { /* check that passed-in datasize is consistent with cue_count in passed-in SF_CUES struct */ - pnew = psf_cues_alloc (pcues->cue_count) ; - memcpy (pnew, pcues, SF_CUES_VAR_SIZE (pcues->cue_count)) ; - } - - return pnew ; -} /* psf_cues_dup */ - -void -psf_get_cues (SF_PRIVATE * psf, void * data, size_t datasize) -{ - if (psf->cues) - { uint32_t cue_count = SF_CUES_COUNT (datasize) ; - - cue_count = SF_MIN (cue_count, psf->cues->cue_count) ; - memcpy (data, psf->cues, SF_CUES_VAR_SIZE (cue_count)) ; - ((SF_CUES*) data)->cue_count = cue_count ; - } ; - - return ; -} /* psf_get_cues */ - - -SF_INSTRUMENT * -psf_instrument_alloc (void) -{ SF_INSTRUMENT *instr ; - - instr = calloc (1, sizeof (SF_INSTRUMENT)) ; - - if (instr == NULL) - return NULL ; - - /* Set non-zero default values. */ - instr->basenote = -1 ; - instr->velocity_lo = -1 ; - instr->velocity_hi = -1 ; - instr->key_lo = -1 ; - instr->key_hi = -1 ; - - return instr ; -} /* psf_instrument_alloc */ - -void -psf_sanitize_string (char * cptr, int len) -{ - do - { - len -- ; - cptr [len] = psf_isprint (cptr [len]) ? cptr [len] : '.' ; - } - while (len > 0) ; -} /* psf_sanitize_string */ - -void -psf_get_date_str (char *str, int maxlen) -{ time_t current ; - struct tm timedata, *tmptr ; - - time (¤t) ; - -#if defined (HAVE_GMTIME_R) - /* If the re-entrant version is available, use it. */ - tmptr = gmtime_r (¤t, &timedata) ; -#elif defined (HAVE_GMTIME) - /* Otherwise use the standard one and copy the data to local storage. */ - tmptr = gmtime (¤t) ; - memcpy (&timedata, tmptr, sizeof (timedata)) ; -#else - tmptr = NULL ; -#endif - - if (tmptr) - snprintf (str, maxlen, "%4d-%02d-%02d %02d:%02d:%02d UTC", - 1900 + timedata.tm_year, timedata.tm_mon, timedata.tm_mday, - timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ; - else - snprintf (str, maxlen, "Unknown date") ; - - return ; -} /* psf_get_date_str */ - -int -subformat_to_bytewidth (int format) -{ - switch (format) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_S8 : - return 1 ; - case SF_FORMAT_PCM_16 : - return 2 ; - case SF_FORMAT_PCM_24 : - return 3 ; - case SF_FORMAT_PCM_32 : - case SF_FORMAT_FLOAT : - return 4 ; - case SF_FORMAT_DOUBLE : - return 8 ; - } ; - - return 0 ; -} /* subformat_to_bytewidth */ - -int -s_bitwidth_to_subformat (int bits) -{ static int array [] = - { SF_FORMAT_PCM_S8, SF_FORMAT_PCM_16, SF_FORMAT_PCM_24, SF_FORMAT_PCM_32 - } ; - - if (bits < 8 || bits > 32) - return 0 ; - - return array [((bits + 7) / 8) - 1] ; -} /* bitwidth_to_subformat */ - -int -u_bitwidth_to_subformat (int bits) -{ static int array [] = - { SF_FORMAT_PCM_U8, SF_FORMAT_PCM_16, SF_FORMAT_PCM_24, SF_FORMAT_PCM_32 - } ; - - if (bits < 8 || bits > 32) - return 0 ; - - return array [((bits + 7) / 8) - 1] ; -} /* bitwidth_to_subformat */ - -/* -** psf_rand_int32 : Not crypto quality, but more than adequate for things -** like stream serial numbers in Ogg files or the unique_id field of the -** SF_PRIVATE struct. -*/ - -int32_t -psf_rand_int32 (void) -{ static uint64_t value = 0 ; - int k, count ; - - if (value == 0) - { -#if HAVE_GETTIMEOFDAY - struct timeval tv ; - gettimeofday (&tv, NULL) ; - value = tv.tv_sec + tv.tv_usec ; -#else - value = time (NULL) ; -#endif - } ; - - count = 4 + (value & 7) ; - for (k = 0 ; k < count ; k++) - value = (11117 * value + 211231) & 0x7fffffff ; - - return (int32_t) value ; -} /* psf_rand_int32 */ - -void -append_snprintf (char * dest, size_t maxlen, const char * fmt, ...) -{ size_t len = strlen (dest) ; - - if (len < maxlen) - { va_list ap ; - - va_start (ap, fmt) ; - vsnprintf (dest + len, maxlen - len, fmt, ap) ; - va_end (ap) ; - } ; - - return ; -} /* append_snprintf */ - - -void -psf_strlcpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax) -{ /* Must be minus 2 so it can still expand a single trailing '\n' or '\r'. */ - char * destend = dest + destmax - 2 ; - const char * srcend = src + srcmax ; - - while (dest < destend && src < srcend) - { if ((src [0] == '\r' && src [1] == '\n') || (src [0] == '\n' && src [1] == '\r')) - { *dest++ = '\r' ; - *dest++ = '\n' ; - src += 2 ; - continue ; - } ; - - if (src [0] == '\r') - { *dest++ = '\r' ; - *dest++ = '\n' ; - src += 1 ; - continue ; - } ; - - if (src [0] == '\n') - { *dest++ = '\r' ; - *dest++ = '\n' ; - src += 1 ; - continue ; - } ; - - *dest++ = *src++ ; - } ; - - /* Make sure dest is terminated. */ - *dest = 0 ; -} /* psf_strlcpy_crlf */ - -sf_count_t -psf_decode_frame_count (SF_PRIVATE *psf) -{ sf_count_t count, readlen, total = 0 ; - BUF_UNION ubuf ; - - /* If we're reading from a pipe or the file is too long, just return SF_COUNT_MAX. */ - if (psf_is_pipe (psf) || psf->datalength > 0x1000000) - return SF_COUNT_MAX ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - readlen = ARRAY_LEN (ubuf.ibuf) / psf->sf.channels ; - readlen *= psf->sf.channels ; - - while ((count = psf->read_int (psf, ubuf.ibuf, readlen)) > 0) - total += count ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - return total / psf->sf.channels ; -} /* psf_decode_frame_count */ - -/*============================================================================== -*/ - -#define CASE_NAME(x) case x : return #x ; break ; - -const char * -str_of_major_format (int format) -{ switch (SF_CONTAINER (format)) - { CASE_NAME (SF_FORMAT_WAV) ; - CASE_NAME (SF_FORMAT_AIFF) ; - CASE_NAME (SF_FORMAT_AU) ; - CASE_NAME (SF_FORMAT_RAW) ; - CASE_NAME (SF_FORMAT_PAF) ; - CASE_NAME (SF_FORMAT_SVX) ; - CASE_NAME (SF_FORMAT_NIST) ; - CASE_NAME (SF_FORMAT_VOC) ; - CASE_NAME (SF_FORMAT_IRCAM) ; - CASE_NAME (SF_FORMAT_W64) ; - CASE_NAME (SF_FORMAT_MAT4) ; - CASE_NAME (SF_FORMAT_MAT5) ; - CASE_NAME (SF_FORMAT_PVF) ; - CASE_NAME (SF_FORMAT_XI) ; - CASE_NAME (SF_FORMAT_HTK) ; - CASE_NAME (SF_FORMAT_SDS) ; - CASE_NAME (SF_FORMAT_AVR) ; - CASE_NAME (SF_FORMAT_WAVEX) ; - CASE_NAME (SF_FORMAT_SD2) ; - CASE_NAME (SF_FORMAT_FLAC) ; - CASE_NAME (SF_FORMAT_CAF) ; - CASE_NAME (SF_FORMAT_WVE) ; - CASE_NAME (SF_FORMAT_OGG) ; - CASE_NAME (SF_FORMAT_MPEG) ; - default : - break ; - } ; - - return "BAD_MAJOR_FORMAT" ; -} /* str_of_major_format */ - -const char * -str_of_minor_format (int format) -{ switch (SF_CODEC (format)) - { CASE_NAME (SF_FORMAT_PCM_S8) ; - CASE_NAME (SF_FORMAT_PCM_16) ; - CASE_NAME (SF_FORMAT_PCM_24) ; - CASE_NAME (SF_FORMAT_PCM_32) ; - CASE_NAME (SF_FORMAT_PCM_U8) ; - CASE_NAME (SF_FORMAT_FLOAT) ; - CASE_NAME (SF_FORMAT_DOUBLE) ; - CASE_NAME (SF_FORMAT_ULAW) ; - CASE_NAME (SF_FORMAT_ALAW) ; - CASE_NAME (SF_FORMAT_IMA_ADPCM) ; - CASE_NAME (SF_FORMAT_MS_ADPCM) ; - CASE_NAME (SF_FORMAT_GSM610) ; - CASE_NAME (SF_FORMAT_VOX_ADPCM) ; - CASE_NAME (SF_FORMAT_NMS_ADPCM_16) ; - CASE_NAME (SF_FORMAT_NMS_ADPCM_24) ; - CASE_NAME (SF_FORMAT_NMS_ADPCM_32) ; - CASE_NAME (SF_FORMAT_G721_32) ; - CASE_NAME (SF_FORMAT_G723_24) ; - CASE_NAME (SF_FORMAT_G723_40) ; - CASE_NAME (SF_FORMAT_DWVW_12) ; - CASE_NAME (SF_FORMAT_DWVW_16) ; - CASE_NAME (SF_FORMAT_DWVW_24) ; - CASE_NAME (SF_FORMAT_DWVW_N) ; - CASE_NAME (SF_FORMAT_DPCM_8) ; - CASE_NAME (SF_FORMAT_DPCM_16) ; - CASE_NAME (SF_FORMAT_VORBIS) ; - CASE_NAME (SF_FORMAT_MPEG_LAYER_I) ; - CASE_NAME (SF_FORMAT_MPEG_LAYER_II) ; - CASE_NAME (SF_FORMAT_MPEG_LAYER_III) ; - default : - break ; - } ; - - return "BAD_MINOR_FORMAT" ; -} /* str_of_minor_format */ - -const char * -str_of_open_mode (int mode) -{ switch (mode) - { CASE_NAME (SFM_READ) ; - CASE_NAME (SFM_WRITE) ; - CASE_NAME (SFM_RDWR) ; - - default : - break ; - } ; - - return "BAD_MODE" ; -} /* str_of_open_mode */ - -const char * -str_of_endianness (int end) -{ switch (end) - { CASE_NAME (SF_ENDIAN_BIG) ; - CASE_NAME (SF_ENDIAN_LITTLE) ; - CASE_NAME (SF_ENDIAN_CPU) ; - default : - break ; - } ; - - /* Zero length string for SF_ENDIAN_FILE. */ - return "" ; -} /* str_of_endianness */ - -/*============================================================================== -*/ - -void -psf_f2s_array (const float *src, short *dest, int count, int normalize) -{ float normfact ; - - normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrintf (src [i] * normfact) ; - - return ; -} /* psf_f2s_array */ - -void -psf_f2s_clip_array (const float *src, short *dest, int count, int normalize) -{ float normfact, scaled_value ; - - normfact = normalize ? (1.0 * 0x8000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFF)) - { dest [i] = 0x7FFF ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x1000)) - { dest [i] = -0x7FFF - 1 ; - continue ; - } ; - - dest [i] = psf_lrintf (scaled_value) ; - } ; - - return ; -} /* psf_f2s_clip_array */ - -void -psf_d2s_array (const double *src, short *dest, int count, int normalize) -{ double normfact ; - - normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrint (src [i] * normfact) ; - - return ; -} /* psf_f2s_array */ - -void -psf_d2s_clip_array (const double *src, short *dest, int count, int normalize) -{ double normfact, scaled_value ; - - normfact = normalize ? (1.0 * 0x8000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFF)) - { dest [i] = 0x7FFF ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x1000)) - { dest [i] = -0x7FFF - 1 ; - continue ; - } ; - - dest [i] = psf_lrint (scaled_value) ; - } ; - - return ; -} /* psf_d2s_clip_array */ - - -void -psf_f2i_array (const float *src, int *dest, int count, int normalize) -{ float normfact ; - - normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ; - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrintf (src [i] * normfact) ; - - return ; -} /* psf_f2i_array */ - -void -psf_f2i_clip_array (const float *src, int *dest, int count, int normalize) -{ float normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i] = 0x7FFFFFFF ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i] = 0x80000000 ; - continue ; - } ; -#endif - - dest [i] = psf_lrintf (scaled_value) ; - } ; - - return ; -} /* psf_f2i_clip_array */ - -void -psf_d2i_array (const double *src, int *dest, int count, int normalize) -{ double normfact ; - - normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ; - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrint (src [i] * normfact) ; - - return ; -} /* psf_f2i_array */ - -void -psf_d2i_clip_array (const double *src, int *dest, int count, int normalize) -{ double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i] = 0x7FFFFFFF ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i] = 0x80000000 ; - continue ; - } ; -#endif - - dest [i] = psf_lrint (scaled_value) ; - } ; - - return ; -} /* psf_d2i_clip_array */ - -FILE * -psf_open_tmpfile (char * fname, size_t fnamelen) -{ const char * tmpdir ; - FILE * file ; - - if (OS_IS_WIN32) - tmpdir = getenv ("TEMP") ; - else - { tmpdir = getenv ("TMPDIR") ; - tmpdir = tmpdir == NULL ? "/tmp" : tmpdir ; - } ; - - if (tmpdir && access (tmpdir, R_OK | W_OK | X_OK) == 0) - { snprintf (fname, fnamelen, "%s/%x%x-alac.tmp", tmpdir, psf_rand_int32 (), psf_rand_int32 ()) ; - if ((file = fopen (fname, "wb+")) != NULL) - return file ; - } ; - - snprintf (fname, fnamelen, "%x%x-alac.tmp", psf_rand_int32 (), psf_rand_int32 ()) ; - if ((file = fopen (fname, "wb+")) != NULL) - return file ; - - memset (fname, 0, fnamelen) ; - return NULL ; -} /* psf_open_tmpfile */ diff --git a/Engine/lib/libsndfile/src/common.h b/Engine/lib/libsndfile/src/common.h deleted file mode 100644 index d92eabde9..000000000 --- a/Engine/lib/libsndfile/src/common.h +++ /dev/null @@ -1,1096 +0,0 @@ -/* -** Copyright (C) 1999-2018 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SNDFILE_COMMON_H -#define SNDFILE_COMMON_H - -#include "sfconfig.h" - -#include -#include -#if HAVE_STDBOOL_H -#include -#endif - -#if HAVE_INTTYPES_H -#include -#elif HAVE_STDINT_H -#include -#endif -#if HAVE_SYS_TYPES_H -#include -#endif - -#ifndef SNDFILE_H -#include "sndfile.h" -#endif - -#include - -#ifdef USE_SSE2 -# ifdef _MSC_VER -# include -# else -# include -# endif -#endif - -#ifdef __cplusplus -#error "This code is not designed to be compiled with a C++ compiler." -#endif - - - -/* -** Inspiration : http://sourcefrog.net/weblog/software/languages/C/unused.html -*/ -#ifdef UNUSED -#elif defined (__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__ ((unused)) -#elif defined (__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -#ifdef __GNUC__ -# define WARN_UNUSED __attribute__ ((warn_unused_result)) -#else -# define WARN_UNUSED -#endif - -#define SF_BUFFER_LEN (8192) -#define SF_FILENAME_LEN (1024) -#define SF_SYSERR_LEN (256) -#define SF_MAX_STRINGS (32) -#define SF_PARSELOG_LEN (2048) - -#define PSF_SEEK_ERROR ((sf_count_t) -1) - -#define BITWIDTH2BYTES(x) (((x) + 7) / 8) - -/* For some reason sizeof returns an unsigned value which causes -** a warning when that value is added or subtracted from a signed -** value. Use SIGNED_SIZEOF instead. -*/ -#define SIGNED_SIZEOF(x) ((int) sizeof (x)) - -#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0]))) - -#define SF_MAX(a, b) ((a) > (b) ? (a) : (b)) -#define SF_MIN(a, b) ((a) < (b) ? (a) : (b)) - - -#define COMPILE_TIME_ASSERT(e) (sizeof (struct { int : - !! (e) ; })) - - -#define SF_MAX_CHANNELS 1024 - -/* -* Macros for spliting the format file of SF_INFO into container type, -** codec type and endian-ness. -*/ -#define SF_CONTAINER(x) ((x) & SF_FORMAT_TYPEMASK) -#define SF_CODEC(x) ((x) & SF_FORMAT_SUBMASK) -#define SF_ENDIAN(x) ((x) & SF_FORMAT_ENDMASK) - -/* -** Binheader cast macros. -*/ - -#define BHW1(x) ((uint8_t) (x)) -#define BHW2(x) ((uint16_t) (x)) -#define BHW3(x) ((uint32_t) (x)) -#define BHW4(x) ((uint32_t) (x)) -#define BHW8(x) ((uint64_t) (x)) - -#define BHWm(x) ((uint32_t) (x)) -#define BHWS(x) ((char *) (x)) - -#define BHWf(x) ((double) (x)) -#define BHWd(x) ((double) (x)) - -#define BHWh(x) ((void *) (x)) -#define BHWj(x) ((size_t) (x)) -#define BHWp(x) ((char *) (x)) -#define BHWo(x) ((size_t) (x)) -#define BHWs(x) ((char *) (x)) -#define BHWv(x) ((const void *) (x)) -#define BHWz(x) ((size_t) (x)) - -/*------------------------------------------------------------------------------ -*/ - -enum -{ /* PEAK chunk location. */ - SF_PEAK_START = 42, - SF_PEAK_END = 43, - - /* PEAK chunk location. */ - SF_SCALE_MAX = 52, - SF_SCALE_MIN = 53, - - /* str_flags values. */ - SF_STR_ALLOW_START = 0x0100, - SF_STR_ALLOW_END = 0x0200, - - /* Location of strings. */ - SF_STR_LOCATE_START = 0x0400, - SF_STR_LOCATE_END = 0x0800, - - SFD_TYPEMASK = 0x0FFFFFFF -} ; - -#define SFM_MASK (SFM_READ | SFM_WRITE | SFM_RDWR) -#define SFM_UNMASK (~SFM_MASK) - -/*--------------------------------------------------------------------------------------- -** Formats that may be supported at some time in the future. -** When support is finalised, these values move to src/sndfile.h. -*/ - -enum -{ /* Work in progress. */ - SF_FORMAT_SPEEX = 0x5000000, - SF_FORMAT_OGGFLAC = 0x5000001, - - /* Formats supported read only. */ - SF_FORMAT_TXW = 0x4030000, /* Yamaha TX16 sampler file */ - SF_FORMAT_DWD = 0x4040000, /* DiamondWare Digirized */ - - /* Following are detected but not supported. */ - SF_FORMAT_REX = 0x40A0000, /* Propellorheads Rex/Rcy */ - SF_FORMAT_REX2 = 0x40D0000, /* Propellorheads Rex2 */ - SF_FORMAT_KRZ = 0x40E0000, /* Kurzweil sampler file */ - SF_FORMAT_WMA = 0x4100000, /* Windows Media Audio. */ - SF_FORMAT_SHN = 0x4110000, /* Shorten. */ - - /* Unsupported encodings. */ - SF_FORMAT_SVX_FIB = 0x1020, /* SVX Fibonacci Delta encoding. */ - SF_FORMAT_SVX_EXP = 0x1021, /* SVX Exponential Delta encoding. */ - - SF_FORMAT_PCM_N = 0x1030 -} ; - -/*--------------------------------------------------------------------------------------- -*/ - -typedef struct -{ unsigned kuki_offset ; - unsigned pakt_offset ; - - unsigned bits_per_sample ; - unsigned frames_per_packet ; - - int64_t packets ; - int64_t valid_frames ; - int32_t priming_frames ; - int32_t remainder_frames ; -} ALAC_DECODER_INFO ; - -/*--------------------------------------------------------------------------------------- -** PEAK_CHUNK - This chunk type is common to both AIFF and WAVE files although their -** endian encodings are different. -*/ - -typedef struct -{ double value ; /* signed value of peak */ - sf_count_t position ; /* the sample frame for the peak */ -} PEAK_POS ; - -typedef struct -{ /* libsndfile internal : write a PEAK chunk at the start or end of the file? */ - int peak_loc ; - - /* WAV/AIFF */ - unsigned int version ; /* version of the PEAK chunk */ - unsigned int timestamp ; /* secs since 1/1/1970 */ - - /* CAF */ - unsigned int edit_number ; - - /* the per channel peak info */ - PEAK_POS peaks [] ; -} PEAK_INFO ; - -static inline PEAK_INFO * -peak_info_calloc (int channels) -{ return calloc (1, sizeof (PEAK_INFO) + channels * sizeof (PEAK_POS)) ; -} /* peak_info_calloc */ - -typedef struct -{ int type ; - int flags ; - size_t offset ; -} STR_DATA ; - -typedef struct -{ uint64_t hash ; - char id [64] ; - unsigned id_size ; - uint32_t mark32 ; - sf_count_t offset ; - uint32_t len ; -} READ_CHUNK ; - -typedef struct -{ uint64_t hash ; - uint32_t mark32 ; - uint32_t len ; - void *data ; -} WRITE_CHUNK ; - -typedef struct -{ uint32_t count ; - uint32_t used ; - READ_CHUNK *chunks ; -} READ_CHUNKS ; -typedef struct -{ uint32_t count ; - uint32_t used ; - WRITE_CHUNK *chunks ; -} WRITE_CHUNKS ; - -struct SF_CHUNK_ITERATOR -{ uint32_t current ; - int64_t hash ; - char id [64] ; - unsigned id_size ; - SNDFILE *sndfile ; -} ; - -static inline size_t -make_size_t (int x) -{ return (size_t) x ; -} /* make_size_t */ - -typedef SF_BROADCAST_INFO_VAR (16 * 1024) SF_BROADCAST_INFO_16K ; - -typedef SF_CART_INFO_VAR (16 * 1024) SF_CART_INFO_16K ; - -typedef struct -{ sf_count_t offset ; - sf_count_t len ; - unsigned minor_version ; -} ID3V2_HEADER_INFO ; - -#if SIZEOF_WCHAR_T == 2 -typedef wchar_t sfwchar_t ; -#else -typedef int16_t sfwchar_t ; -#endif - - -void *psf_memdup (const void *src, size_t n) ; - -/* -** This version of isprint specifically ignores any locale info. Its used for -** determining which characters can be printed in things like hexdumps. -*/ -int psf_isprint (int ch) ; - -/*======================================================================================= -** SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the -** sf_open_XXXX functions. The caller however has no knowledge of the struct's -** contents. -*/ - -typedef struct -{ - char path [SF_FILENAME_LEN] ; - char dir [SF_FILENAME_LEN] ; - char name [SF_FILENAME_LEN / 4] ; - -#if USE_WINDOWS_API - /* - ** These fields can only be used in src/file_io.c. - ** They are basically the same as a windows file HANDLE. - */ - void *handle, *hsaved ; -#else - /* These fields can only be used in src/file_io.c. */ - int filedes, savedes ; -#endif - - int do_not_close_descriptor ; - int mode ; /* Open mode : SFM_READ, SFM_WRITE or SFM_RDWR. */ -} PSF_FILE ; - - - -typedef union -{ double dbuf [SF_BUFFER_LEN / sizeof (double)] ; -#if (defined (SIZEOF_INT64_T) && (SIZEOF_INT64_T == 8)) - int64_t lbuf [SF_BUFFER_LEN / sizeof (int64_t)] ; -#else - long lbuf [SF_BUFFER_LEN / sizeof (double)] ; -#endif - float fbuf [SF_BUFFER_LEN / sizeof (float)] ; - int ibuf [SF_BUFFER_LEN / sizeof (int)] ; - short sbuf [SF_BUFFER_LEN / sizeof (short)] ; - char cbuf [SF_BUFFER_LEN / sizeof (char)] ; - signed char scbuf [SF_BUFFER_LEN / sizeof (signed char)] ; - unsigned char ucbuf [SF_BUFFER_LEN / sizeof (signed char)] ; -} BUF_UNION ; - - - -typedef struct sf_private_tag -{ - PSF_FILE file, rsrc ; - - char syserr [SF_SYSERR_LEN] ; - - /* parselog and indx should only be changed within the logging functions - ** of common.c - */ - struct - { char buf [SF_PARSELOG_LEN] ; - int indx ; - } parselog ; - - - struct - { unsigned char * ptr ; - sf_count_t indx, end, len ; - } header ; - - int rwf_endian ; /* Header endian-ness flag. */ - - /* Storage and housekeeping data for adding/reading strings from - ** sound files. - */ - struct - { STR_DATA data [SF_MAX_STRINGS] ; - char *storage ; - size_t storage_len ; - size_t storage_used ; - uint32_t flags ; - } strings ; - - /* Guard value. If this changes the buffers above have overflowed. */ - int Magick ; - - unsigned unique_id ; - - int error ; - - int endian ; /* File endianness : SF_ENDIAN_LITTLE or SF_ENDIAN_BIG. */ - int data_endswap ; /* Need to endswap data? */ - - /* - ** Maximum float value for calculating the multiplier for - ** float/double to short/int conversions. - */ - int float_int_mult ; - float float_max ; - - int scale_int_float ; - - /* Vairables for handling pipes. */ - int is_pipe ; /* True if file is a pipe. */ - sf_count_t pipeoffset ; /* Number of bytes read from a pipe. */ - - /* True if clipping must be performed on float->int conversions. */ - int add_clipping ; - - SF_INFO sf ; - - int have_written ; /* Has a single write been done to the file? */ - PEAK_INFO *peak_info ; - - /* Cue Marker Info */ - SF_CUES *cues ; - - /* Loop Info */ - SF_LOOP_INFO *loop_info ; - SF_INSTRUMENT *instrument ; - - /* Broadcast (EBU) Info */ - SF_BROADCAST_INFO_16K *broadcast_16k ; - - /* Cart (AES46) Info */ - SF_CART_INFO_16K *cart_16k ; - - /* Channel map data (if present) : an array of ints. */ - int *channel_map ; - - sf_count_t filelength ; /* Overall length of (embedded) file. */ - sf_count_t fileoffset ; /* Offset in number of bytes from beginning of file. */ - - sf_count_t rsrclength ; /* Length of the resource fork (if it exists). */ - - sf_count_t dataoffset ; /* Offset in number of bytes from beginning of file. */ - sf_count_t datalength ; /* Length in bytes of the audio data. */ - sf_count_t dataend ; /* Offset to file tailer. */ - - int blockwidth ; /* Size in bytes of one set of interleaved samples. */ - int bytewidth ; /* Size in bytes of one sample (one channel). */ - - void *dither ; - void *interleave ; - - int last_op ; /* Last operation; either SFM_READ or SFM_WRITE */ - sf_count_t read_current ; - sf_count_t write_current ; - - void *container_data ; /* This is a pointer to dynamically allocated file - ** container format specific data. - */ - - void *codec_data ; /* This is a pointer to dynamically allocated file - ** codec format specific data. - */ - - SF_DITHER_INFO write_dither ; - SF_DITHER_INFO read_dither ; - - int norm_double ; - int norm_float ; - - int auto_header ; - - int ieee_replace ; - - /* A set of file specific function pointers */ - sf_count_t (*read_short) (struct sf_private_tag*, short *ptr, sf_count_t len) ; - sf_count_t (*read_int) (struct sf_private_tag*, int *ptr, sf_count_t len) ; - sf_count_t (*read_float) (struct sf_private_tag*, float *ptr, sf_count_t len) ; - sf_count_t (*read_double) (struct sf_private_tag*, double *ptr, sf_count_t len) ; - - sf_count_t (*write_short) (struct sf_private_tag*, const short *ptr, sf_count_t len) ; - sf_count_t (*write_int) (struct sf_private_tag*, const int *ptr, sf_count_t len) ; - sf_count_t (*write_float) (struct sf_private_tag*, const float *ptr, sf_count_t len) ; - sf_count_t (*write_double) (struct sf_private_tag*, const double *ptr, sf_count_t len) ; - - sf_count_t (*seek) (struct sf_private_tag*, int mode, sf_count_t samples_from_start) ; - int (*write_header) (struct sf_private_tag*, int calc_length) ; - int (*command) (struct sf_private_tag*, int command, void *data, int datasize) ; - int (*byterate) (struct sf_private_tag*) ; - - /* - ** Separate close functions for the codec and the container. - ** The codec close function is always called first. - */ - int (*codec_close) (struct sf_private_tag*) ; - int (*container_close) (struct sf_private_tag*) ; - - char *format_desc ; - - /* Virtual I/O functions. */ - int virtual_io ; - SF_VIRTUAL_IO vio ; - void *vio_user_data ; - - /* Chunk get/set. */ - SF_CHUNK_ITERATOR *iterator ; - - READ_CHUNKS rchunks ; - WRITE_CHUNKS wchunks ; - - int (*set_chunk) (struct sf_private_tag*, const SF_CHUNK_INFO * chunk_info) ; - SF_CHUNK_ITERATOR * (*next_chunk_iterator) (struct sf_private_tag*, SF_CHUNK_ITERATOR * iterator) ; - int (*get_chunk_size) (struct sf_private_tag*, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; - int (*get_chunk_data) (struct sf_private_tag*, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; - - int cpu_flags ; - - ID3V2_HEADER_INFO id3_header ; -} SF_PRIVATE ; - - - -enum -{ SFE_NO_ERROR = SF_ERR_NO_ERROR, - SFE_BAD_OPEN_FORMAT = SF_ERR_UNRECOGNISED_FORMAT, - SFE_SYSTEM = SF_ERR_SYSTEM, - SFE_MALFORMED_FILE = SF_ERR_MALFORMED_FILE, - SFE_UNSUPPORTED_ENCODING = SF_ERR_UNSUPPORTED_ENCODING, - - SFE_ZERO_MAJOR_FORMAT, - SFE_ZERO_MINOR_FORMAT, - SFE_BAD_FILE, - SFE_BAD_FILE_READ, - SFE_OPEN_FAILED, - SFE_BAD_SNDFILE_PTR, - SFE_BAD_SF_INFO_PTR, - SFE_BAD_SF_INCOMPLETE, - SFE_BAD_FILE_PTR, - SFE_BAD_INT_PTR, - SFE_BAD_STAT_SIZE, - SFE_NO_TEMP_DIR, - SFE_MALLOC_FAILED, - SFE_UNIMPLEMENTED, - SFE_BAD_READ_ALIGN, - SFE_BAD_WRITE_ALIGN, - SFE_NOT_READMODE, - SFE_NOT_WRITEMODE, - SFE_BAD_MODE_RW, - SFE_BAD_SF_INFO, - SFE_BAD_OFFSET, - SFE_NO_EMBED_SUPPORT, - SFE_NO_EMBEDDED_RDWR, - SFE_NO_PIPE_WRITE, - - SFE_INTERNAL, - SFE_BAD_COMMAND_PARAM, - SFE_BAD_ENDIAN, - SFE_CHANNEL_COUNT_ZERO, - SFE_CHANNEL_COUNT, - SFE_CHANNEL_COUNT_BAD, - - SFE_BAD_VIRTUAL_IO, - - SFE_INTERLEAVE_MODE, - SFE_INTERLEAVE_SEEK, - SFE_INTERLEAVE_READ, - - SFE_BAD_SEEK, - SFE_NOT_SEEKABLE, - SFE_AMBIGUOUS_SEEK, - SFE_WRONG_SEEK, - SFE_SEEK_FAILED, - - SFE_BAD_OPEN_MODE, - SFE_OPEN_PIPE_RDWR, - SFE_RDWR_POSITION, - SFE_RDWR_BAD_HEADER, - SFE_CMD_HAS_DATA, - SFE_BAD_BROADCAST_INFO_SIZE, - SFE_BAD_BROADCAST_INFO_TOO_BIG, - SFE_BAD_CART_INFO_SIZE, - SFE_BAD_CART_INFO_TOO_BIG, - - SFE_STR_NO_SUPPORT, - SFE_STR_NOT_WRITE, - SFE_STR_MAX_DATA, - SFE_STR_MAX_COUNT, - SFE_STR_BAD_TYPE, - SFE_STR_NO_ADD_END, - SFE_STR_BAD_STRING, - SFE_STR_WEIRD, - - SFE_WAV_NO_RIFF, - SFE_WAV_NO_WAVE, - SFE_WAV_NO_FMT, - SFE_WAV_BAD_FMT, - SFE_WAV_FMT_SHORT, - SFE_WAV_BAD_FACT, - SFE_WAV_BAD_PEAK, - SFE_WAV_PEAK_B4_FMT, - SFE_WAV_BAD_FORMAT, - SFE_WAV_BAD_BLOCKALIGN, - SFE_WAV_NO_DATA, - SFE_WAV_BAD_LIST, - SFE_WAV_ADPCM_NOT4BIT, - SFE_WAV_ADPCM_CHANNELS, - SFE_WAV_ADPCM_SAMPLES, - SFE_WAV_GSM610_FORMAT, - SFE_WAV_UNKNOWN_CHUNK, - SFE_WAV_WVPK_DATA, - SFE_WAV_NMS_FORMAT, - - SFE_AIFF_NO_FORM, - SFE_AIFF_AIFF_NO_FORM, - SFE_AIFF_COMM_NO_FORM, - SFE_AIFF_SSND_NO_COMM, - SFE_AIFF_UNKNOWN_CHUNK, - SFE_AIFF_COMM_CHUNK_SIZE, - SFE_AIFF_BAD_COMM_CHUNK, - SFE_AIFF_PEAK_B4_COMM, - SFE_AIFF_BAD_PEAK, - SFE_AIFF_NO_SSND, - SFE_AIFF_NO_DATA, - SFE_AIFF_RW_SSND_NOT_LAST, - - SFE_AU_UNKNOWN_FORMAT, - SFE_AU_NO_DOTSND, - SFE_AU_EMBED_BAD_LEN, - - SFE_RAW_READ_BAD_SPEC, - SFE_RAW_BAD_BITWIDTH, - SFE_RAW_BAD_FORMAT, - - SFE_PAF_NO_MARKER, - SFE_PAF_VERSION, - SFE_PAF_UNKNOWN_FORMAT, - SFE_PAF_SHORT_HEADER, - SFE_PAF_BAD_CHANNELS, - - SFE_SVX_NO_FORM, - SFE_SVX_NO_BODY, - SFE_SVX_NO_DATA, - SFE_SVX_BAD_COMP, - SFE_SVX_BAD_NAME_LENGTH, - - SFE_NIST_BAD_HEADER, - SFE_NIST_CRLF_CONVERISON, - SFE_NIST_BAD_ENCODING, - - SFE_VOC_NO_CREATIVE, - SFE_VOC_BAD_FORMAT, - SFE_VOC_BAD_VERSION, - SFE_VOC_BAD_MARKER, - SFE_VOC_BAD_SECTIONS, - SFE_VOC_MULTI_SAMPLERATE, - SFE_VOC_MULTI_SECTION, - SFE_VOC_MULTI_PARAM, - SFE_VOC_SECTION_COUNT, - SFE_VOC_NO_PIPE, - - SFE_IRCAM_NO_MARKER, - SFE_IRCAM_BAD_CHANNELS, - SFE_IRCAM_UNKNOWN_FORMAT, - - SFE_W64_64_BIT, - SFE_W64_NO_RIFF, - SFE_W64_NO_WAVE, - SFE_W64_NO_DATA, - SFE_W64_ADPCM_NOT4BIT, - SFE_W64_ADPCM_CHANNELS, - SFE_W64_GSM610_FORMAT, - - SFE_MAT4_BAD_NAME, - SFE_MAT4_NO_SAMPLERATE, - - SFE_MAT5_BAD_ENDIAN, - SFE_MAT5_NO_BLOCK, - SFE_MAT5_SAMPLE_RATE, - - SFE_PVF_NO_PVF1, - SFE_PVF_BAD_HEADER, - SFE_PVF_BAD_BITWIDTH, - - SFE_DWVW_BAD_BITWIDTH, - SFE_G72X_NOT_MONO, - SFE_NMS_ADPCM_NOT_MONO, - - SFE_XI_BAD_HEADER, - SFE_XI_EXCESS_SAMPLES, - SFE_XI_NO_PIPE, - - SFE_HTK_NO_PIPE, - - SFE_SDS_NOT_SDS, - SFE_SDS_BAD_BIT_WIDTH, - - SFE_SD2_FD_DISALLOWED, - SFE_SD2_BAD_DATA_OFFSET, - SFE_SD2_BAD_MAP_OFFSET, - SFE_SD2_BAD_DATA_LENGTH, - SFE_SD2_BAD_MAP_LENGTH, - SFE_SD2_BAD_RSRC, - SFE_SD2_BAD_SAMPLE_SIZE, - - SFE_FLAC_BAD_HEADER, - SFE_FLAC_NEW_DECODER, - SFE_FLAC_INIT_DECODER, - SFE_FLAC_LOST_SYNC, - SFE_FLAC_BAD_SAMPLE_RATE, - SFE_FLAC_CHANNEL_COUNT_CHANGED, - SFE_FLAC_UNKOWN_ERROR, - - SFE_WVE_NOT_WVE, - SFE_WVE_NO_PIPE, - - SFE_VORBIS_ENCODER_BUG, - - SFE_RF64_NOT_RF64, - SFE_RF64_PEAK_B4_FMT, - SFE_RF64_NO_DATA, - - SFE_BAD_CHUNK_PTR, - SFE_UNKNOWN_CHUNK, - SFE_BAD_CHUNK_FORMAT, - SFE_BAD_CHUNK_MARKER, - SFE_BAD_CHUNK_DATA_PTR, - SFE_ALAC_FAIL_TMPFILE, - SFE_FILENAME_TOO_LONG, - SFE_NEGATIVE_RW_LEN, - - SFE_OPUS_BAD_SAMPLERATE, - - SFE_CAF_NOT_CAF, - SFE_CAF_NO_DESC, - SFE_CAF_BAD_PEAK, - - SFE_AVR_NOT_AVR, - SFE_AVR_BAD_REZ_SIGN, - - SFE_MPC_NO_MARKER, - - SFE_MPEG_BAD_SAMPLERATE, - - SFE_MAX_ERROR /* This must be last in list. */ -} ; - -/* Allocate and initialize the SF_PRIVATE struct. */ -SF_PRIVATE * psf_allocate (void) ; - -int subformat_to_bytewidth (int format) ; -int s_bitwidth_to_subformat (int bits) ; -int u_bitwidth_to_subformat (int bits) ; - -/* Functions for reading and writing floats and doubles on processors -** with non-IEEE floats/doubles. -*/ -float float32_be_read (const unsigned char *cptr) ; -float float32_le_read (const unsigned char *cptr) ; -void float32_be_write (float in, unsigned char *out) ; -void float32_le_write (float in, unsigned char *out) ; - -double double64_be_read (const unsigned char *cptr) ; -double double64_le_read (const unsigned char *cptr) ; -void double64_be_write (double in, unsigned char *out) ; -void double64_le_write (double in, unsigned char *out) ; - -/* Functions for writing to the internal logging buffer. */ - -void psf_log_printf (SF_PRIVATE *psf, const char *format, ...) ; -void psf_log_SF_INFO (SF_PRIVATE *psf) ; - -int32_t psf_rand_int32 (void) ; - -void append_snprintf (char * dest, size_t maxlen, const char * fmt, ...) ; -void psf_strlcpy_crlf (char *dest, const char *src, size_t destmax, size_t srcmax) ; - -sf_count_t psf_decode_frame_count (SF_PRIVATE *psf) ; - -/* Functions used when writing file headers. */ - -int psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...) ; -void psf_asciiheader_printf (SF_PRIVATE *psf, const char *format, ...) ; - -/* Functions used when reading file headers. */ - -int psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...) ; - -/* Functions used in the write function for updating the peak chunk. */ - -void peak_update_short (SF_PRIVATE *psf, short *ptr, size_t items) ; -void peak_update_int (SF_PRIVATE *psf, int *ptr, size_t items) ; -void peak_update_double (SF_PRIVATE *psf, double *ptr, size_t items) ; - -/* Functions defined in command.c. */ - -int psf_get_format_simple_count (void) ; -int psf_get_format_simple (SF_FORMAT_INFO *data) ; - -int psf_get_format_info (SF_FORMAT_INFO *data) ; - -int psf_get_format_major_count (void) ; -int psf_get_format_major (SF_FORMAT_INFO *data) ; - -int psf_get_format_subtype_count (void) ; -int psf_get_format_subtype (SF_FORMAT_INFO *data) ; - -void psf_generate_format_desc (SF_PRIVATE *psf) ; - -double psf_calc_signal_max (SF_PRIVATE *psf, int normalize) ; -int psf_calc_max_all_channels (SF_PRIVATE *psf, double *peaks, int normalize) ; - -int psf_get_signal_max (SF_PRIVATE *psf, double *peak) ; -int psf_get_max_all_channels (SF_PRIVATE *psf, double *peaks) ; - -/* Functions in strings.c. */ - -const char* psf_get_string (SF_PRIVATE *psf, int str_type) ; -int psf_set_string (SF_PRIVATE *psf, int str_type, const char *str) ; -int psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) ; -int psf_location_string_count (const SF_PRIVATE * psf, int location) ; - -/* Default seek function. Use for PCM and float encoded data. */ -sf_count_t psf_default_seek (SF_PRIVATE *psf, int mode, sf_count_t samples_from_start) ; - -int macos_guess_file_type (SF_PRIVATE *psf, const char *filename) ; - -/*------------------------------------------------------------------------------------ -** File I/O functions which will allow access to large files (> 2 Gig) on -** some 32 bit OSes. Implementation in file_io.c. -*/ - -int psf_fopen (SF_PRIVATE *psf) ; -int psf_set_stdio (SF_PRIVATE *psf) ; -int psf_file_valid (SF_PRIVATE *psf) ; -void psf_set_file (SF_PRIVATE *psf, int fd) ; -void psf_init_files (SF_PRIVATE *psf) ; -void psf_use_rsrc (SF_PRIVATE *psf, int on_off) ; - -SNDFILE * psf_open_file (SF_PRIVATE *psf, SF_INFO *sfinfo) ; - -sf_count_t psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) ; -sf_count_t psf_fread (void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ; -sf_count_t psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ; -sf_count_t psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf) ; -sf_count_t psf_ftell (SF_PRIVATE *psf) ; -sf_count_t psf_get_filelen (SF_PRIVATE *psf) ; - -void psf_fsync (SF_PRIVATE *psf) ; - -int psf_is_pipe (SF_PRIVATE *psf) ; - -int psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) ; -int psf_fclose (SF_PRIVATE *psf) ; - -/* Open and close the resource fork of a file. */ -int psf_open_rsrc (SF_PRIVATE *psf) ; -int psf_close_rsrc (SF_PRIVATE *psf) ; - -int psf_copy_filename (SF_PRIVATE *psf, const char *path) ; - -/* -void psf_fclearerr (SF_PRIVATE *psf) ; -int psf_ferror (SF_PRIVATE *psf) ; -*/ - -/*------------------------------------------------------------------------------------ -** Functions for reading and writing different file formats. -*/ - -int aiff_open (SF_PRIVATE *psf) ; -int au_open (SF_PRIVATE *psf) ; -int avr_open (SF_PRIVATE *psf) ; -int htk_open (SF_PRIVATE *psf) ; -int ircam_open (SF_PRIVATE *psf) ; -int mat4_open (SF_PRIVATE *psf) ; -int mat5_open (SF_PRIVATE *psf) ; -int nist_open (SF_PRIVATE *psf) ; -int paf_open (SF_PRIVATE *psf) ; -int pvf_open (SF_PRIVATE *psf) ; -int raw_open (SF_PRIVATE *psf) ; -int sd2_open (SF_PRIVATE *psf) ; -int sds_open (SF_PRIVATE *psf) ; -int svx_open (SF_PRIVATE *psf) ; -int voc_open (SF_PRIVATE *psf) ; -int w64_open (SF_PRIVATE *psf) ; -int wav_open (SF_PRIVATE *psf) ; -int xi_open (SF_PRIVATE *psf) ; -int flac_open (SF_PRIVATE *psf) ; -int caf_open (SF_PRIVATE *psf) ; -int mpc2k_open (SF_PRIVATE *psf) ; -int rf64_open (SF_PRIVATE *psf) ; - -int ogg_vorbis_open (SF_PRIVATE *psf) ; -int ogg_speex_open (SF_PRIVATE *psf) ; -int ogg_pcm_open (SF_PRIVATE *psf) ; -int ogg_opus_open (SF_PRIVATE *psf) ; -int ogg_open (SF_PRIVATE *psf) ; - -int mpeg_open (SF_PRIVATE *psf) ; - -/* In progress. Do not currently work. */ - -int rx2_open (SF_PRIVATE *psf) ; -int txw_open (SF_PRIVATE *psf) ; -int wve_open (SF_PRIVATE *psf) ; -int dwd_open (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------------ -** Init functions for a number of common data encodings. -*/ - -int pcm_init (SF_PRIVATE *psf) ; -int ulaw_init (SF_PRIVATE *psf) ; -int alaw_init (SF_PRIVATE *psf) ; -int float32_init (SF_PRIVATE *psf) ; -int double64_init (SF_PRIVATE *psf) ; -int dwvw_init (SF_PRIVATE *psf, int bitwidth) ; -int gsm610_init (SF_PRIVATE *psf) ; -int nms_adpcm_init (SF_PRIVATE *psf) ; -int vox_adpcm_init (SF_PRIVATE *psf) ; -int flac_init (SF_PRIVATE *psf) ; -int g72x_init (SF_PRIVATE * psf) ; -int alac_init (SF_PRIVATE *psf, const ALAC_DECODER_INFO * info) ; -int mpeg_init (SF_PRIVATE *psf, int bitrate_mode, int write_metadata) ; - -int dither_init (SF_PRIVATE *psf, int mode) ; - -int wavlike_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) ; -int wavlike_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) ; - -int aiff_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) ; - -int interleave_init (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------------ -** Chunk logging functions. -*/ - -SF_CHUNK_ITERATOR * psf_get_chunk_iterator (SF_PRIVATE * psf, const char * marker_str) ; -SF_CHUNK_ITERATOR * psf_next_chunk_iterator (const READ_CHUNKS * pchk , SF_CHUNK_ITERATOR *iterator) ; -int psf_store_read_chunk_u32 (READ_CHUNKS * pchk, uint32_t marker, sf_count_t offset, uint32_t len) ; -int psf_store_read_chunk_str (READ_CHUNKS * pchk, const char * marker, sf_count_t offset, uint32_t len) ; -int psf_save_write_chunk (WRITE_CHUNKS * pchk, const SF_CHUNK_INFO * chunk_info) ; -int psf_find_read_chunk_str (const READ_CHUNKS * pchk, const char * marker) ; -int psf_find_read_chunk_m32 (const READ_CHUNKS * pchk, uint32_t marker) ; -int psf_find_read_chunk_iterator (const READ_CHUNKS * pchk, const SF_CHUNK_ITERATOR * marker) ; - -int psf_find_write_chunk (WRITE_CHUNKS * pchk, const char * marker) ; - -/*------------------------------------------------------------------------------------ -** Functions that work like OpenBSD's strlcpy/strlcat to replace strncpy/strncat. -** -** See : http://www.gratisoft.us/todd/papers/strlcpy.html -** -** These functions are available on *BSD, but are not avaialble everywhere so we -** implement them here. -** -** The argument order has been changed to that of strncpy/strncat to cause -** compiler errors if code is carelessly converted from one to the other. -*/ - -void psf_strlcat (char *dest, size_t n, const char *src) ; -void psf_strlcpy (char *dest, size_t n, const char *src) ; - -/*------------------------------------------------------------------------------------ -** SIMD optimized math functions. -*/ - -static inline int psf_lrintf (float x) -{ - #ifdef USE_SSE2 - return _mm_cvtss_si32 (_mm_load_ss (&x)) ; - #else - return lrintf (x) ; - #endif -} /* psf_lrintf */ - -static inline int psf_lrint (double x) -{ - #ifdef USE_SSE2 - return _mm_cvtsd_si32 (_mm_load_sd (&x)) ; - #else - return lrint (x) ; - #endif -} /* psf_lrintf */ - -/*------------------------------------------------------------------------------------ -** Other helper functions. -*/ - -void *psf_memset (void *s, int c, sf_count_t n) ; - -SF_CUES * psf_cues_dup (const void * ptr, size_t datasize) ; -SF_CUES * psf_cues_alloc (uint32_t cue_count) ; -void psf_get_cues (SF_PRIVATE * psf, void * data, size_t datasize) ; - -SF_INSTRUMENT * psf_instrument_alloc (void) ; - -void psf_sanitize_string (char * cptr, int len) ; - -/* Generate the current date as a string. */ -void psf_get_date_str (char *str, int maxlen) ; - -SF_BROADCAST_INFO_16K * broadcast_var_alloc (void) ; -int broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * data, size_t datasize) ; -int broadcast_var_get (SF_PRIVATE *psf, SF_BROADCAST_INFO * data, size_t datasize) ; - - -SF_CART_INFO_16K * cart_var_alloc (void) ; -int cart_var_set (SF_PRIVATE *psf, const SF_CART_INFO * date, size_t datasize) ; -int cart_var_get (SF_PRIVATE *psf, SF_CART_INFO * data, size_t datasize) ; - -typedef struct -{ int channels ; - int endianness ; -} AUDIO_DETECT ; - -int audio_detect (SF_PRIVATE * psf, AUDIO_DETECT *ad, const unsigned char * data, int datalen) ; -int id3_skip (SF_PRIVATE * psf) ; -const char *id3_lookup_v1_genre (int number) ; - -void alac_get_desc_chunk_items (int subformat, uint32_t *fmt_flags, uint32_t *frames_per_packet) ; - -FILE * psf_open_tmpfile (char * fname, size_t fnamelen) ; - -/*------------------------------------------------------------------------------------ -** Helper/debug functions. -*/ - -void psf_hexdump (const void *ptr, int len) ; - -const char * str_of_major_format (int format) ; -const char * str_of_minor_format (int format) ; -const char * str_of_open_mode (int mode) ; -const char * str_of_endianness (int end) ; - -/*------------------------------------------------------------------------------------ -** Extra commands for sf_command(). Not for public use yet. -*/ - -enum -{ SFC_TEST_AIFF_ADD_INST_CHUNK = 0x2000, - SFC_TEST_WAV_ADD_INFO_CHUNK = 0x2010 -} ; - -/* -** Maybe, one day, make these functions or something like them, public. -** -** Buffer to buffer dithering. Pointer in and out are allowed to point -** to the same buffer for in-place dithering. -*/ - -#if 0 -int sf_dither_short (const SF_DITHER_INFO *dither, const short *in, short *out, int count) ; -int sf_dither_int (const SF_DITHER_INFO *dither, const int *in, int *out, int count) ; -int sf_dither_float (const SF_DITHER_INFO *dither, const float *in, float *out, int count) ; -int sf_dither_double (const SF_DITHER_INFO *dither, const double *in, double *out, int count) ; -#endif - -/*------------------------------------------------------------------------------------ -** Data conversion functions. -*/ - -void psf_f2s_array (const float *src, short *dest, int count, int normalize) ; -void psf_f2s_clip_array (const float *src, short *dest, int count, int normalize) ; - -void psf_d2s_array (const double *src, short *dest, int count, int normalize) ; -void psf_d2s_clip_array (const double *src, short *dest, int count, int normalize) ; - -void psf_f2i_array (const float *src, int *dest, int count, int normalize) ; -void psf_f2i_clip_array (const float *src, int *dest, int count, int normalize) ; - -void psf_d2i_array (const double *src, int *dest, int count, int normalize) ; -void psf_d2i_clip_array (const double *src, int *dest, int count, int normalize) ; - - -/*------------------------------------------------------------------------------------ -** Left and right shift on int. According to the C standard, the left and right -** shift operations applied to a negative integer results in undefined behavior. -** These twp functions work around that. -*/ - -#if __GNUC__ -#define ALWAYS_INLINE __attribute__ ((always_inline)) -#else -#define ALWAYS_INLINE -#endif - -static inline int32_t ALWAYS_INLINE -arith_shift_left (int32_t x, int shift) -{ return (int32_t) (((uint32_t) x) << shift) ; -} /* arith_shift_left */ - -static inline int32_t ALWAYS_INLINE -arith_shift_right (int32_t x, int shift) -{ if (x >= 0) - return x >> shift ; - return ~ ((~x) >> shift) ; -} /* arith_shift_right */ - -#endif /* SNDFILE_COMMON_H */ diff --git a/Engine/lib/libsndfile/src/config.h.cmake b/Engine/lib/libsndfile/src/config.h.cmake deleted file mode 100644 index e8d81453d..000000000 --- a/Engine/lib/libsndfile/src/config.h.cmake +++ /dev/null @@ -1,315 +0,0 @@ -/* Set to 1 if the compile is GNU GCC. */ -#cmakedefine01 COMPILER_IS_GCC - -/* Target processor clips on negative float to int conversion. */ -#cmakedefine01 CPU_CLIPS_NEGATIVE - -/* Target processor clips on positive float to int conversion. */ -#cmakedefine01 CPU_CLIPS_POSITIVE - -/* Target processor is big endian. */ -#cmakedefine01 CPU_IS_BIG_ENDIAN - -/* Target processor is little endian. */ -#cmakedefine01 CPU_IS_LITTLE_ENDIAN - -/* Set to 1 to enable experimental code. */ -#cmakedefine01 ENABLE_EXPERIMENTAL_CODE - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_ALSA_ASOUNDLIB_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_BYTESWAP_H - -/* Define to 1 if you have the `calloc' function. */ -#cmakedefine01 HAVE_CALLOC - -/* Define to 1 if you have the `ceil' function. */ -#cmakedefine01 HAVE_CEIL - -/* Set to 1 if S_IRGRP is defined. */ -#cmakedefine01 HAVE_DECL_S_IRGRP - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DIRECT_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_ENDIAN_H - -/* Will be set to 1 if flac, ogg and vorbis are available. */ -#cmakedefine01 HAVE_EXTERNAL_XIPH_LIBS - -/* Will be set to 1 if lame and mpg123 are available. */ -#cmakedefine01 HAVE_MPEG - -/* Define to 1 if you have the `floor' function. */ -#cmakedefine01 HAVE_FLOOR - -/* Define to 1 if you have the `fmod' function. */ -#cmakedefine01 HAVE_FMOD - -/* Define to 1 if you have the `free' function. */ -#cmakedefine01 HAVE_FREE - -/* Define to 1 if you have the `fstat' function. */ -#cmakedefine01 HAVE_FSTAT - -/* Define to 1 if you have the `fstat64' function. */ -#cmakedefine01 HAVE_FSTAT64 - -/* Define to 1 if you have the `fsync' function. */ -#cmakedefine01 HAVE_FSYNC - -/* Define to 1 if you have the `ftruncate' function. */ -#cmakedefine01 HAVE_FTRUNCATE - -/* Define to 1 if you have the `getpagesize' function. */ -#cmakedefine01 HAVE_GETPAGESIZE - -/* Define to 1 if you have the `gettimeofday' function. */ -#cmakedefine01 HAVE_GETTIMEOFDAY - -/* Define if you have the `gmtime' function. */ -#cmakedefine HAVE_GMTIME - -/* Define if you have the `gmtime_r' function. */ -#cmakedefine HAVE_GMTIME_R - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_IO_H - -/* Define to 1 if you have the `m' library (-lm). */ -#cmakedefine01 HAVE_LIBM - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_LOCALE_H - -/* Define if you have the `localtime' function. */ -#cmakedefine HAVE_LOCALTIME - -/* Define if you have the `localtime_r' function. */ -#cmakedefine HAVE_LOCALTIME_R - -/* Define if you have C99's lrint function. */ -#cmakedefine01 HAVE_LRINT - -/* Define if you have C99's lrintf function. */ -#cmakedefine01 HAVE_LRINTF - -/* Define to 1 if you have the `lround' function. */ -#cmakedefine01 HAVE_LROUND - -/* Define to 1 if you have the `lseek' function. */ -#cmakedefine01 HAVE_LSEEK - -/* Define to 1 if you have the `lseek64' function. */ -#cmakedefine01 HAVE_LSEEK64 - -/* Define to 1 if you have the `malloc' function. */ -#cmakedefine01 HAVE_MALLOC - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_MEMORY_H - -/* Define to 1 if you have the `mmap' function. */ -#cmakedefine01 HAVE_MMAP - -/* Define to 1 if you have the `open' function. */ -#cmakedefine01 HAVE_OPEN - -/* Define to 1 if you have the `pipe' function. */ -#cmakedefine01 HAVE_PIPE - -/* Define to 1 if you have the `read' function. */ -#cmakedefine01 HAVE_READ - -/* Define to 1 if you have the `realloc' function. */ -#cmakedefine01 HAVE_REALLOC - -/* Define to 1 if you have the `setlocale' function. */ -#cmakedefine01 HAVE_SETLOCALE - -/* Set to 1 if is available. */ -#cmakedefine01 HAVE_SNDIO_H - -/* Define to 1 if you have the `snprintf' function. */ -#cmakedefine01 HAVE_SNPRINTF - -/* Set to 1 if you have libsqlite3. */ -#cmakedefine01 HAVE_SQLITE3 - -/* Define to 1 if the system has the type `ssize_t'. */ -#cmakedefine01 HAVE_SSIZE_T - -#if (HAVE_SSIZE_T == 0) -#define ssize_t intptr_t -#endif - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_SYS_TYPES_H - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#cmakedefine01 HAVE_SYS_WAIT_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_UNISTD_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_IMMINTRIN_H - -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_STDBOOL_H - -/* Define to 1 if you have the `vsnprintf' function. */ -#cmakedefine01 HAVE_VSNPRINTF - -/* Define to 1 if you have the `waitpid' function. */ -#cmakedefine01 HAVE_WAITPID - -/* Define to 1 if you have the `write' function. */ -#cmakedefine01 HAVE_WRITE - -/* The darwin version, no-zero is valid */ -#cmakedefine01 OSX_DARWIN_VERSION - -/* Set to 1 if compiling for OpenBSD */ -#cmakedefine01 OS_IS_OPENBSD - -/* Set to 1 if compiling for Win32 */ -#cmakedefine01 OS_IS_WIN32 - -/* Set to 1 if SSE2 is enabled */ -#cmakedefine USE_SSE2 - -/* Name of package */ -#define PACKAGE "@PACKAGE_NAME@" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "@PACKAGE_NAME@" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "@PACKAGE_NAME@ @CPACK_PACKAGE_VERSION_FULL@" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "@PACKAGE_NAME@" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "@PACKAGE_URL@" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "@CPACK_PACKAGE_VERSION_FULL@" - -/* The size of `double', as computed by sizeof. */ -@SIZEOF_DOUBLE_CODE@ - -/* The size of `float', as computed by sizeof. */ -@SIZEOF_FLOAT_CODE@ - -/* The size of `int', as computed by sizeof. */ -@SIZEOF_INT_CODE@ - -/* The size of `int64_t', as computed by sizeof. */ -@SIZEOF_INT64_T_CODE@ - -/* The size of `loff_t', as computed by sizeof. */ -@SIZEOF_LOFF_T_CODE@ - -/* The size of `long', as computed by sizeof. */ -@SIZEOF_LONG_CODE@ - -/* The size of `long long', as computed by sizeof. */ -@SIZEOF_LONG_LONG_CODE@ - -/* The size of `off64_t', as computed by sizeof. */ -@SIZEOF_OFF64_T_CODE@ - -/* The size of `off_t', as computed by sizeof. */ -@SIZEOF_OFF_T_CODE@ - -/* The size of `short', as computed by sizeof. */ -@SIZEOF_SHORT_CODE@ - -/* The size of `size_t', as computed by sizeof. */ -@SIZEOF_SIZE_T_CODE@ - -/* The size of `ssize_t', as computed by sizeof. */ -@SIZEOF_SSIZE_T_CODE@ - -/* The size of `void*', as computed by sizeof. */ -@SIZEOF_VOIDP_CODE@ - -/* The size of `wchar_t', as computed by sizeof. */ -@SIZEOF_WCHAR_T_CODE@ - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif - - -/* Set to 1 to use the native windows API */ -#cmakedefine01 USE_WINDOWS_API - -/* Version number of package */ -#define VERSION "@PROJECT_VERSION@" - -/* Set to 1 if windows DLL is being built. */ -#cmakedefine01 WIN32_TARGET_DLL - -/* Target processor is big endian. */ -#cmakedefine01 WORDS_BIGENDIAN - -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - -/* Define to 1 if on MINIX. */ -#cmakedefine01 _MINIX - -/* Define as `__inline' or '__inline__' if that's what the C compiler calls it, or to nothing if it is not supported. */ -@INLINE_CODE@ diff --git a/Engine/lib/libsndfile/src/create_symbols_file.py b/Engine/lib/libsndfile/src/create_symbols_file.py deleted file mode 100644 index c0debce1d..000000000 --- a/Engine/lib/libsndfile/src/create_symbols_file.py +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/python - -# Copyright (C) 2003-2017 Erik de Castro Lopo -# -# 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 author nor the names of any 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. - -import re, sys - -#---------------------------------------------------------------- -# These are all of the public functions exported from libsndfile. -# -# Its important not to change the order they are listed in or -# the ordinal values in the second column. - -ALL_SYMBOLS = ( - ( "sf_command", 1 ), - ( "sf_open", 2 ), - ( "sf_close", 3 ), - ( "sf_seek", 4 ), - ( "sf_error", 7 ), - ( "sf_perror", 8 ), - ( "sf_error_str", 9 ), - ( "sf_error_number", 10 ), - ( "sf_format_check", 11 ), - ( "sf_read_raw", 16 ), - ( "sf_readf_short", 17 ), - ( "sf_readf_int", 18 ), - ( "sf_readf_float", 19 ), - ( "sf_readf_double", 20 ), - ( "sf_read_short", 21 ), - ( "sf_read_int", 22 ), - ( "sf_read_float", 23 ), - ( "sf_read_double", 24 ), - ( "sf_write_raw", 32 ), - ( "sf_writef_short", 33 ), - ( "sf_writef_int", 34 ), - ( "sf_writef_float", 35 ), - ( "sf_writef_double", 36 ), - ( "sf_write_short", 37 ), - ( "sf_write_int", 38 ), - ( "sf_write_float", 39 ), - ( "sf_write_double", 40 ), - ( "sf_strerror", 50 ), - ( "sf_get_string", 60 ), - ( "sf_set_string", 61 ), - ( "sf_version_string", 68 ), - ( "sf_open_fd", 70 ), - ( "sf_wchar_open", 71 ), - ( "sf_open_virtual", 80 ), - ( "sf_write_sync", 90 ), - ( "sf_set_chunk", 100 ), - ( "sf_get_chunk_size", 101 ), - ( "sf_get_chunk_data", 102 ), - ( "sf_get_chunk_iterator", 103 ), - ( "sf_next_chunk_iterator", 104 ), - ( "sf_current_byterate", 110 ) - ) - -#------------------------------------------------------------------------------- - -def linux_symbols (progname, version): - print ("# Auto-generated by %s\n" %progname) - print ("libsndfile.so.%s" % version) - print ("{") - print (" global:") - for name, ordinal in ALL_SYMBOLS: - if name == "sf_wchar_open": - continue - print (" %s ;" % name) - print (" local:") - print (" * ;") - print ("} ;") - sys.stdout.write ("\n") - return - -def darwin_symbols (progname, version): - print ("# Auto-generated by %s\n" %progname) - for name, ordinal in ALL_SYMBOLS: - if name == "sf_wchar_open": - continue - print ("_%s" % name) - sys.stdout.write ("\n") - return - -def win32_symbols (progname, version, name): - print ("; Auto-generated by %s\n" %progname) - print ("EXPORTS\n") - for name, ordinal in ALL_SYMBOLS: - print ("%-20s @%s" % (name, ordinal)) - sys.stdout.write ("\n") - return - -def os2_symbols (progname, version, name): - print ("; Auto-generated by %s\n" %progname) - print ("LIBRARY %s%s" % (name, re.sub (r"\..*", "", version))) - print ("INITINSTANCE TERMINSTANCE") - print ("CODE PRELOAD MOVEABLE DISCARDABLE") - print ("DATA PRELOAD MOVEABLE MULTIPLE NONSHARED") - print ("EXPORTS\n") - for name, ordinal in ALL_SYMBOLS: - if name == "sf_wchar_open": - continue - print ("_%-20s @%s" % (name, ordinal)) - sys.stdout.write ("\n") - return - -def plain_symbols (progname, version, name): - for name, ordinal in ALL_SYMBOLS: - print (name) - -def no_symbols (os_name): - sys.stdout.write ("\n") - print ("No known way of restricting exported symbols on '%s'." % os_name) - print ("If you know a way, please contact the author.") - sys.stdout.write ("\n") - return - -#------------------------------------------------------------------------------- - -progname = re.sub (".*[\\/]", "", sys.argv [0]) - -if len (sys.argv) != 3: - sys.stdout.write ("\n") - print ("Usage : %s ." % progname) - sys.stdout.write ("\n") - print (" Currently supported values for target OS are:") - print (" linux") - print (" darwin (ie MacOSX)") - print (" win32 (ie wintendo)") - print (" cygwin (Cygwin on wintendo)") - print (" os2 (OS/2)") - print (" plain (plain list of symbols)") - sys.stdout.write ("\n") - sys.exit (1) - -os_name = sys.argv [1] -version = re.sub (r"\.[a-z0-9]+$", "", sys.argv [2]) - -if os_name == "linux" or os_name == "gnu" or os_name == "binutils": - linux_symbols (progname, version) -elif os_name == "darwin": - darwin_symbols (progname, version) -elif os_name == "win32": - win32_symbols (progname, version, "libsndfile") -elif os_name == "cygwin": - win32_symbols (progname, version, "cygsndfile") -elif os_name == "os2": - os2_symbols (progname, version, "sndfile") -elif os_name == "static": - plain_symbols (progname, version, "") -else: - no_symbols (os_name) - -sys.exit (0) - diff --git a/Engine/lib/libsndfile/src/dither.c b/Engine/lib/libsndfile/src/dither.c deleted file mode 100644 index b0ef7311a..000000000 --- a/Engine/lib/libsndfile/src/dither.c +++ /dev/null @@ -1,534 +0,0 @@ -/* -** Copyright (C) 2003-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*============================================================================ -** Rule number 1 is to only apply dither when going from a larger bitwidth -** to a smaller bitwidth. This can happen on both read and write. -** -** Need to apply dither on all conversions marked X below. -** -** Dither on write: -** -** Input -** | short int float double -** --------+----------------------------------------------- -** O 8 bit | X X X X -** u 16 bit | none X X X -** t 24 bit | none X X X -** p 32 bit | none none X X -** u float | none none none none -** t double | none none none none -** -** Dither on read: -** -** Input -** O | 8 bit 16 bit 24 bit 32 bit float double -** u --------+------------------------------------------------- -** t short | none none X X X X -** p int | none none none X X X -** u float | none none none none none none -** t double | none none none none none none -*/ - -#define SFE_DITHER_BAD_PTR 666 -#define SFE_DITHER_BAD_TYPE 667 - -typedef struct -{ int read_short_dither_bits, read_int_dither_bits ; - int write_short_dither_bits, write_int_dither_bits ; - double read_float_dither_scale, read_double_dither_bits ; - double write_float_dither_scale, write_double_dither_bits ; - - sf_count_t (*read_short) (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; - sf_count_t (*read_int) (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; - sf_count_t (*read_float) (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; - sf_count_t (*read_double) (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - - sf_count_t (*write_short) (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; - sf_count_t (*write_int) (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; - sf_count_t (*write_float) (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; - sf_count_t (*write_double) (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - - double buffer [SF_BUFFER_LEN / sizeof (double)] ; -} DITHER_DATA ; - -static sf_count_t dither_read_short (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t dither_read_int (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; - -static sf_count_t dither_write_short (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t dither_write_int (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t dither_write_float (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t dither_write_double (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -int -dither_init (SF_PRIVATE *psf, int mode) -{ DITHER_DATA *pdither ; - - pdither = psf->dither ; /* This may be NULL. */ - - /* Turn off dither on read. */ - if (mode == SFM_READ && psf->read_dither.type == SFD_NO_DITHER) - { if (pdither == NULL) - return 0 ; /* Dither is already off, so just return. */ - - if (pdither->read_short) - psf->read_short = pdither->read_short ; - if (pdither->read_int) - psf->read_int = pdither->read_int ; - if (pdither->read_float) - psf->read_float = pdither->read_float ; - if (pdither->read_double) - psf->read_double = pdither->read_double ; - return 0 ; - } ; - - /* Turn off dither on write. */ - if (mode == SFM_WRITE && psf->write_dither.type == SFD_NO_DITHER) - { if (pdither == NULL) - return 0 ; /* Dither is already off, so just return. */ - - if (pdither->write_short) - psf->write_short = pdither->write_short ; - if (pdither->write_int) - psf->write_int = pdither->write_int ; - if (pdither->write_float) - psf->write_float = pdither->write_float ; - if (pdither->write_double) - psf->write_double = pdither->write_double ; - return 0 ; - } ; - - /* Turn on dither on read if asked. */ - if (mode == SFM_READ && psf->read_dither.type != 0) - { if (pdither == NULL) - pdither = psf->dither = calloc (1, sizeof (DITHER_DATA)) ; - if (pdither == NULL) - return SFE_MALLOC_FAILED ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_DOUBLE : - case SF_FORMAT_FLOAT : - pdither->read_int = psf->read_int ; - psf->read_int = dither_read_int ; - break ; - - case SF_FORMAT_PCM_32 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_U8 : - pdither->read_short = psf->read_short ; - psf->read_short = dither_read_short ; - break ; - - default : break ; - } ; - } ; - - /* Turn on dither on write if asked. */ - if (mode == SFM_WRITE && psf->write_dither.type != 0) - { if (pdither == NULL) - pdither = psf->dither = calloc (1, sizeof (DITHER_DATA)) ; - if (pdither == NULL) - return SFE_MALLOC_FAILED ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_DOUBLE : - case SF_FORMAT_FLOAT : - pdither->write_int = psf->write_int ; - psf->write_int = dither_write_int ; - break ; - - case SF_FORMAT_PCM_32 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_U8 : - break ; - - default : break ; - } ; - - pdither->write_short = psf->write_short ; - psf->write_short = dither_write_short ; - - pdither->write_int = psf->write_int ; - psf->write_int = dither_write_int ; - - pdither->write_float = psf->write_float ; - psf->write_float = dither_write_float ; - - pdither->write_double = psf->write_double ; - psf->write_double = dither_write_double ; - } ; - - return 0 ; -} /* dither_init */ - -/*============================================================================== -*/ - -static void dither_short (const short *in, short *out, int frames, int channels) ; -static void dither_int (const int *in, int *out, int frames, int channels) ; - -static void dither_float (const float *in, float *out, int frames, int channels) ; -static void dither_double (const double *in, double *out, int frames, int channels) ; - -static sf_count_t -dither_read_short (SF_PRIVATE * UNUSED (psf), short * UNUSED (ptr), sf_count_t len) -{ - return len ; -} /* dither_read_short */ - -static sf_count_t -dither_read_int (SF_PRIVATE * UNUSED (psf), int * UNUSED (ptr), sf_count_t len) -{ - return len ; -} /* dither_read_int */ - -/*------------------------------------------------------------------------------ -*/ - -static sf_count_t -dither_write_short (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ DITHER_DATA *pdither ; - int bufferlen, writecount, thiswrite ; - sf_count_t total = 0 ; - - if ((pdither = psf->dither) == NULL) - { psf->error = SFE_DITHER_BAD_PTR ; - return 0 ; - } ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_U8 : - case SF_FORMAT_DPCM_8 : - break ; - - default : - return pdither->write_short (psf, ptr, len) ; - } ; - - bufferlen = sizeof (pdither->buffer) / (sizeof (short)) ; - - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - writecount /= psf->sf.channels ; - writecount *= psf->sf.channels ; - - dither_short (ptr, (short*) pdither->buffer, writecount / psf->sf.channels, psf->sf.channels) ; - - thiswrite = (int) pdither->write_short (psf, (short*) pdither->buffer, writecount) ; - total += thiswrite ; - len -= thiswrite ; - if (thiswrite < writecount) - break ; - } ; - - return total ; -} /* dither_write_short */ - -static sf_count_t -dither_write_int (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ DITHER_DATA *pdither ; - int bufferlen, writecount, thiswrite ; - sf_count_t total = 0 ; - - if ((pdither = psf->dither) == NULL) - { psf->error = SFE_DITHER_BAD_PTR ; - return 0 ; - } ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - break ; - - case SF_FORMAT_DPCM_8 : - case SF_FORMAT_DPCM_16 : - break ; - - default : - return pdither->write_int (psf, ptr, len) ; - } ; - - - bufferlen = sizeof (pdither->buffer) / (sizeof (int)) ; - - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - writecount /= psf->sf.channels ; - writecount *= psf->sf.channels ; - - dither_int (ptr, (int*) pdither->buffer, writecount / psf->sf.channels, psf->sf.channels) ; - - thiswrite = (int) pdither->write_int (psf, (int*) pdither->buffer, writecount) ; - total += thiswrite ; - len -= thiswrite ; - if (thiswrite < writecount) - break ; - } ; - - return total ; -} /* dither_write_int */ - -static sf_count_t -dither_write_float (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ DITHER_DATA *pdither ; - int bufferlen, writecount, thiswrite ; - sf_count_t total = 0 ; - - if ((pdither = psf->dither) == NULL) - { psf->error = SFE_DITHER_BAD_PTR ; - return 0 ; - } ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - break ; - - case SF_FORMAT_DPCM_8 : - case SF_FORMAT_DPCM_16 : - break ; - - default : - return pdither->write_float (psf, ptr, len) ; - } ; - - bufferlen = sizeof (pdither->buffer) / (sizeof (float)) ; - - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - writecount /= psf->sf.channels ; - writecount *= psf->sf.channels ; - - dither_float (ptr, (float*) pdither->buffer, writecount / psf->sf.channels, psf->sf.channels) ; - - thiswrite = (int) pdither->write_float (psf, (float*) pdither->buffer, writecount) ; - total += thiswrite ; - len -= thiswrite ; - if (thiswrite < writecount) - break ; - } ; - - return total ; -} /* dither_write_float */ - -static sf_count_t -dither_write_double (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ DITHER_DATA *pdither ; - int bufferlen, writecount, thiswrite ; - sf_count_t total = 0 ; - - if ((pdither = psf->dither) == NULL) - { psf->error = SFE_DITHER_BAD_PTR ; - return 0 ; - } ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - break ; - - case SF_FORMAT_DPCM_8 : - case SF_FORMAT_DPCM_16 : - break ; - - default : - return pdither->write_double (psf, ptr, len) ; - } ; - - - bufferlen = sizeof (pdither->buffer) / sizeof (double) ; - - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - writecount /= psf->sf.channels ; - writecount *= psf->sf.channels ; - - dither_double (ptr, (double*) pdither->buffer, writecount / psf->sf.channels, psf->sf.channels) ; - - thiswrite = (int) pdither->write_double (psf, (double*) pdither->buffer, writecount) ; - total += thiswrite ; - len -= thiswrite ; - if (thiswrite < writecount) - break ; - } ; - - return total ; -} /* dither_write_double */ - -/*============================================================================== -*/ - -static void -dither_short (const short *in, short *out, int frames, int channels) -{ int ch, k ; - - for (ch = 0 ; ch < channels ; ch++) - for (k = ch ; k < channels * frames ; k += channels) - out [k] = in [k] ; - -} /* dither_short */ - -static void -dither_int (const int *in, int *out, int frames, int channels) -{ int ch, k ; - - for (ch = 0 ; ch < channels ; ch++) - for (k = ch ; k < channels * frames ; k += channels) - out [k] = in [k] ; - -} /* dither_int */ - -static void -dither_float (const float *in, float *out, int frames, int channels) -{ int ch, k ; - - for (ch = 0 ; ch < channels ; ch++) - for (k = ch ; k < channels * frames ; k += channels) - out [k] = in [k] ; - -} /* dither_float */ - -static void -dither_double (const double *in, double *out, int frames, int channels) -{ int ch, k ; - - for (ch = 0 ; ch < channels ; ch++) - for (k = ch ; k < channels * frames ; k += channels) - out [k] = in [k] ; - -} /* dither_double */ - -/*============================================================================== -*/ -#if 0 - -/* -** Not made public because this (maybe) requires storage of state information. -** -** Also maybe need separate state info for each channel!!!! -*/ - -int -DO_NOT_USE_sf_dither_short (const SF_DITHER_INFO *dither, const short *in, short *out, int frames, int channels) -{ int ch, k ; - - if (! dither) - return SFE_DITHER_BAD_PTR ; - - switch (dither->type & SFD_TYPEMASK) - { case SFD_WHITE : - case SFD_TRIANGULAR_PDF : - for (ch = 0 ; ch < channels ; ch++) - for (k = ch ; k < channels * frames ; k += channels) - out [k] = in [k] ; - break ; - - default : - return SFE_DITHER_BAD_TYPE ; - } ; - - return 0 ; -} /* DO_NOT_USE_sf_dither_short */ - -int -DO_NOT_USE_sf_dither_int (const SF_DITHER_INFO *dither, const int *in, int *out, int frames, int channels) -{ int ch, k ; - - if (! dither) - return SFE_DITHER_BAD_PTR ; - - switch (dither->type & SFD_TYPEMASK) - { case SFD_WHITE : - case SFD_TRIANGULAR_PDF : - for (ch = 0 ; ch < channels ; ch++) - for (k = ch ; k < channels * frames ; k += channels) - out [k] = in [k] ; - break ; - - default : - return SFE_DITHER_BAD_TYPE ; - } ; - - return 0 ; -} /* DO_NOT_USE_sf_dither_int */ - -int -DO_NOT_USE_sf_dither_float (const SF_DITHER_INFO *dither, const float *in, float *out, int frames, int channels) -{ int ch, k ; - - if (! dither) - return SFE_DITHER_BAD_PTR ; - - switch (dither->type & SFD_TYPEMASK) - { case SFD_WHITE : - case SFD_TRIANGULAR_PDF : - for (ch = 0 ; ch < channels ; ch++) - for (k = ch ; k < channels * frames ; k += channels) - out [k] = in [k] ; - break ; - - default : - return SFE_DITHER_BAD_TYPE ; - } ; - - return 0 ; -} /* DO_NOT_USE_sf_dither_float */ - -int -DO_NOT_USE_sf_dither_double (const SF_DITHER_INFO *dither, const double *in, double *out, int frames, int channels) -{ int ch, k ; - - if (! dither) - return SFE_DITHER_BAD_PTR ; - - switch (dither->type & SFD_TYPEMASK) - { case SFD_WHITE : - case SFD_TRIANGULAR_PDF : - for (ch = 0 ; ch < channels ; ch++) - for (k = ch ; k < channels * frames ; k += channels) - out [k] = in [k] ; - break ; - - default : - return SFE_DITHER_BAD_TYPE ; - } ; - - return 0 ; -} /* DO_NOT_USE_sf_dither_double */ - -#endif - diff --git a/Engine/lib/libsndfile/src/double64.c b/Engine/lib/libsndfile/src/double64.c deleted file mode 100644 index 0c79cd58f..000000000 --- a/Engine/lib/libsndfile/src/double64.c +++ /dev/null @@ -1,1063 +0,0 @@ -/* -** Copyright (C) 1999-2015 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if CPU_IS_LITTLE_ENDIAN - #define DOUBLE64_READ double64_le_read - #define DOUBLE64_WRITE double64_le_write -#elif CPU_IS_BIG_ENDIAN - #define DOUBLE64_READ double64_be_read - #define DOUBLE64_WRITE double64_be_write -#endif - -/* A 32 number which will not overflow when multiplied by sizeof (double). */ -#define SENSIBLE_LEN (0x8000000) - -/*-------------------------------------------------------------------------------------------- -** Processor floating point capabilities. double64_get_capability () returns one of the -** latter three values. -*/ - -enum -{ DOUBLE_UNKNOWN = 0x00, - DOUBLE_CAN_RW_LE = 0x23, - DOUBLE_CAN_RW_BE = 0x34, - DOUBLE_BROKEN_LE = 0x45, - DOUBLE_BROKEN_BE = 0x56 -} ; - -/*-------------------------------------------------------------------------------------------- -** Prototypes for private functions. -*/ - -static sf_count_t host_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t host_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t host_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t host_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t host_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t host_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t host_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static void double64_peak_update (SF_PRIVATE *psf, const double *buffer, int count, sf_count_t indx) ; - -static int double64_get_capability (SF_PRIVATE *psf) ; - -static sf_count_t replace_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t replace_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t replace_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t replace_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t replace_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t replace_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t replace_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t replace_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static void d2bd_read (double *buffer, int count) ; -static void bd2d_write (double *buffer, int count) ; - -/*-------------------------------------------------------------------------------------------- -** Exported functions. -*/ - -int -double64_init (SF_PRIVATE *psf) -{ static int double64_caps ; - - if (psf->sf.channels < 1 || psf->sf.channels > SF_MAX_CHANNELS) - { psf_log_printf (psf, "double64_init : internal error : channels = %d\n", psf->sf.channels) ; - return SFE_INTERNAL ; - } ; - - double64_caps = double64_get_capability (psf) ; - - psf->blockwidth = sizeof (double) * psf->sf.channels ; - - if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) - { switch (psf->endian + double64_caps) - { case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_BE) : - psf->data_endswap = SF_FALSE ; - psf->read_short = host_read_d2s ; - psf->read_int = host_read_d2i ; - psf->read_float = host_read_d2f ; - psf->read_double = host_read_d ; - break ; - - case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_LE) : - psf->data_endswap = SF_FALSE ; - psf->read_short = host_read_d2s ; - psf->read_int = host_read_d2i ; - psf->read_float = host_read_d2f ; - psf->read_double = host_read_d ; - break ; - - case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_LE) : - psf->data_endswap = SF_TRUE ; - psf->read_short = host_read_d2s ; - psf->read_int = host_read_d2i ; - psf->read_float = host_read_d2f ; - psf->read_double = host_read_d ; - break ; - - case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_BE) : - psf->data_endswap = SF_TRUE ; - psf->read_short = host_read_d2s ; - psf->read_int = host_read_d2i ; - psf->read_float = host_read_d2f ; - psf->read_double = host_read_d ; - break ; - - /* When the CPU is not IEEE compatible. */ - case (SF_ENDIAN_BIG + DOUBLE_BROKEN_BE) : - psf->data_endswap = SF_FALSE ; - psf->read_short = replace_read_d2s ; - psf->read_int = replace_read_d2i ; - psf->read_float = replace_read_d2f ; - psf->read_double = replace_read_d ; - break ; - - case (SF_ENDIAN_LITTLE + DOUBLE_BROKEN_LE) : - psf->data_endswap = SF_FALSE ; - psf->read_short = replace_read_d2s ; - psf->read_int = replace_read_d2i ; - psf->read_float = replace_read_d2f ; - psf->read_double = replace_read_d ; - break ; - - case (SF_ENDIAN_BIG + DOUBLE_BROKEN_LE) : - psf->data_endswap = SF_TRUE ; - psf->read_short = replace_read_d2s ; - psf->read_int = replace_read_d2i ; - psf->read_float = replace_read_d2f ; - psf->read_double = replace_read_d ; - break ; - - case (SF_ENDIAN_LITTLE + DOUBLE_BROKEN_BE) : - psf->data_endswap = SF_TRUE ; - psf->read_short = replace_read_d2s ; - psf->read_int = replace_read_d2i ; - psf->read_float = replace_read_d2f ; - psf->read_double = replace_read_d ; - break ; - - default : break ; - } ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { switch (psf->endian + double64_caps) - { case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_LE) : - psf->data_endswap = SF_FALSE ; - psf->write_short = host_write_s2d ; - psf->write_int = host_write_i2d ; - psf->write_float = host_write_f2d ; - psf->write_double = host_write_d ; - break ; - - case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_BE) : - psf->data_endswap = SF_FALSE ; - psf->write_short = host_write_s2d ; - psf->write_int = host_write_i2d ; - psf->write_float = host_write_f2d ; - psf->write_double = host_write_d ; - break ; - - case (SF_ENDIAN_BIG + DOUBLE_CAN_RW_LE) : - psf->data_endswap = SF_TRUE ; - psf->write_short = host_write_s2d ; - psf->write_int = host_write_i2d ; - psf->write_float = host_write_f2d ; - psf->write_double = host_write_d ; - break ; - - case (SF_ENDIAN_LITTLE + DOUBLE_CAN_RW_BE) : - psf->data_endswap = SF_TRUE ; - psf->write_short = host_write_s2d ; - psf->write_int = host_write_i2d ; - psf->write_float = host_write_f2d ; - psf->write_double = host_write_d ; - break ; - - /* When the CPU is not IEEE compatible. */ - case (SF_ENDIAN_LITTLE + DOUBLE_BROKEN_LE) : - psf->data_endswap = SF_FALSE ; - psf->write_short = replace_write_s2d ; - psf->write_int = replace_write_i2d ; - psf->write_float = replace_write_f2d ; - psf->write_double = replace_write_d ; - break ; - - case (SF_ENDIAN_BIG + DOUBLE_BROKEN_BE) : - psf->data_endswap = SF_FALSE ; - psf->write_short = replace_write_s2d ; - psf->write_int = replace_write_i2d ; - psf->write_float = replace_write_f2d ; - psf->write_double = replace_write_d ; - break ; - - case (SF_ENDIAN_BIG + DOUBLE_BROKEN_LE) : - psf->data_endswap = SF_TRUE ; - psf->write_short = replace_write_s2d ; - psf->write_int = replace_write_i2d ; - psf->write_float = replace_write_f2d ; - psf->write_double = replace_write_d ; - break ; - - case (SF_ENDIAN_LITTLE + DOUBLE_BROKEN_BE) : - psf->data_endswap = SF_TRUE ; - psf->write_short = replace_write_s2d ; - psf->write_int = replace_write_i2d ; - psf->write_float = replace_write_f2d ; - psf->write_double = replace_write_d ; - break ; - - default : break ; - } ; - } ; - - if (psf->filelength > psf->dataoffset) - { psf->datalength = (psf->dataend > 0) ? psf->dataend - psf->dataoffset : - psf->filelength - psf->dataoffset ; - } - else - psf->datalength = 0 ; - - psf->sf.frames = psf->datalength / psf->blockwidth ; - - return 0 ; -} /* double64_init */ - -/*---------------------------------------------------------------------------- -** From : http://www.hpcf.cam.ac.uk/fp_formats.html -** -** 64 bit double precision layout (big endian) -** Sign bit 0 -** Exponent bits 1-11 -** Mantissa bits 12-63 -** Exponent Offset 1023 -** -** double single -** -** +INF 7FF0000000000000 7F800000 -** -INF FFF0000000000000 FF800000 -** NaN 7FF0000000000001 7F800001 -** to to -** 7FFFFFFFFFFFFFFF 7FFFFFFF -** and and -** FFF0000000000001 FF800001 -** to to -** FFFFFFFFFFFFFFFF FFFFFFFF -** +OVER 7FEFFFFFFFFFFFFF 7F7FFFFF -** -OVER FFEFFFFFFFFFFFFF FF7FFFFF -** +UNDER 0010000000000000 00800000 -** -UNDER 8010000000000000 80800000 -*/ - -double -double64_be_read (const unsigned char *cptr) -{ int exponent, negative, upper, lower ; - double dvalue ; - - negative = (cptr [0] & 0x80) ? 1 : 0 ; - exponent = ((cptr [0] & 0x7F) << 4) | ((cptr [1] >> 4) & 0xF) ; - - /* Might not have a 64 bit long, so load the mantissa into a double. */ - upper = (((cptr [1] & 0xF) << 24) | (cptr [2] << 16) | (cptr [3] << 8) | cptr [4]) ; - lower = (cptr [5] << 16) | (cptr [6] << 8) | cptr [7] ; - - if (exponent == 0 && upper == 0 && lower == 0) - return 0.0 ; - - dvalue = upper + lower / ((double) 0x1000000) ; - dvalue += 0x10000000 ; - - exponent = exponent - 0x3FF ; - - dvalue = dvalue / ((double) 0x10000000) ; - - if (negative) - dvalue *= -1 ; - - if (exponent > 0) - dvalue *= pow (2.0, exponent) ; - else if (exponent < 0) - dvalue /= pow (2.0, abs (exponent)) ; - - return dvalue ; -} /* double64_be_read */ - -double -double64_le_read (const unsigned char *cptr) -{ int exponent, negative, upper, lower ; - double dvalue ; - - negative = (cptr [7] & 0x80) ? 1 : 0 ; - exponent = ((cptr [7] & 0x7F) << 4) | ((cptr [6] >> 4) & 0xF) ; - - /* Might not have a 64 bit long, so load the mantissa into a double. */ - upper = ((cptr [6] & 0xF) << 24) | (cptr [5] << 16) | (cptr [4] << 8) | cptr [3] ; - lower = (cptr [2] << 16) | (cptr [1] << 8) | cptr [0] ; - - if (exponent == 0 && upper == 0 && lower == 0) - return 0.0 ; - - dvalue = upper + lower / ((double) 0x1000000) ; - dvalue += 0x10000000 ; - - exponent = exponent - 0x3FF ; - - dvalue = dvalue / ((double) 0x10000000) ; - - if (negative) - dvalue *= -1 ; - - if (exponent > 0) - dvalue *= pow (2.0, exponent) ; - else if (exponent < 0) - dvalue /= pow (2.0, abs (exponent)) ; - - return dvalue ; -} /* double64_le_read */ - -void -double64_be_write (double in, unsigned char *out) -{ int exponent, mantissa ; - - memset (out, 0, sizeof (double)) ; - - if (fabs (in) < 1e-30) - return ; - - if (in < 0.0) - { in *= -1.0 ; - out [0] |= 0x80 ; - } ; - - in = frexp (in, &exponent) ; - - exponent += 1022 ; - - out [0] |= (exponent >> 4) & 0x7F ; - out [1] |= (exponent << 4) & 0xF0 ; - - in *= 0x20000000 ; - mantissa = psf_lrint (floor (in)) ; - - out [1] |= (mantissa >> 24) & 0xF ; - out [2] = (mantissa >> 16) & 0xFF ; - out [3] = (mantissa >> 8) & 0xFF ; - out [4] = mantissa & 0xFF ; - - in = fmod (in, 1.0) ; - in *= 0x1000000 ; - mantissa = psf_lrint (floor (in)) ; - - out [5] = (mantissa >> 16) & 0xFF ; - out [6] = (mantissa >> 8) & 0xFF ; - out [7] = mantissa & 0xFF ; - - return ; -} /* double64_be_write */ - -void -double64_le_write (double in, unsigned char *out) -{ int exponent, mantissa ; - - memset (out, 0, sizeof (double)) ; - - if (fabs (in) < 1e-30) - return ; - - if (in < 0.0) - { in *= -1.0 ; - out [7] |= 0x80 ; - } ; - - in = frexp (in, &exponent) ; - - exponent += 1022 ; - - out [7] |= (exponent >> 4) & 0x7F ; - out [6] |= (exponent << 4) & 0xF0 ; - - in *= 0x20000000 ; - mantissa = psf_lrint (floor (in)) ; - - out [6] |= (mantissa >> 24) & 0xF ; - out [5] = (mantissa >> 16) & 0xFF ; - out [4] = (mantissa >> 8) & 0xFF ; - out [3] = mantissa & 0xFF ; - - in = fmod (in, 1.0) ; - in *= 0x1000000 ; - mantissa = psf_lrint (floor (in)) ; - - out [2] = (mantissa >> 16) & 0xFF ; - out [1] = (mantissa >> 8) & 0xFF ; - out [0] = mantissa & 0xFF ; - - return ; -} /* double64_le_write */ - -/*============================================================================================== -** Private functions. -*/ - -static void -double64_peak_update (SF_PRIVATE *psf, const double *buffer, int count, sf_count_t indx) -{ int chan ; - int k, position ; - float fmaxval ; - - for (chan = 0 ; chan < psf->sf.channels ; chan++) - { fmaxval = fabs (buffer [chan]) ; - position = 0 ; - for (k = chan ; k < count ; k += psf->sf.channels) - if (fmaxval < fabs (buffer [k])) - { fmaxval = fabs (buffer [k]) ; - position = k ; - } ; - - if (fmaxval > psf->peak_info->peaks [chan].value) - { psf->peak_info->peaks [chan].value = fmaxval ; - psf->peak_info->peaks [chan].position = psf->write_current + indx + (position / psf->sf.channels) ; - } ; - } ; - - return ; -} /* double64_peak_update */ - -static int -double64_get_capability (SF_PRIVATE *psf) -{ union - { double d ; - unsigned char c [8] ; - } data ; - - data.d = 1.234567890123456789 ; /* Some abitrary value. */ - - if (! psf->ieee_replace) - { /* If this test is true ints and floats are compatible and little endian. */ - if (data.c [0] == 0xfb && data.c [1] == 0x59 && data.c [2] == 0x8c && data.c [3] == 0x42 && - data.c [4] == 0xca && data.c [5] == 0xc0 && data.c [6] == 0xf3 && data.c [7] == 0x3f) - return DOUBLE_CAN_RW_LE ; - - /* If this test is true ints and floats are compatible and big endian. */ - if (data.c [0] == 0x3f && data.c [1] == 0xf3 && data.c [2] == 0xc0 && data.c [3] == 0xca && - data.c [4] == 0x42 && data.c [5] == 0x8c && data.c [6] == 0x59 && data.c [7] == 0xfb) - return DOUBLE_CAN_RW_BE ; - } ; - - /* Doubles are broken. Don't expect reading or writing to be fast. */ - psf_log_printf (psf, "Using IEEE replacement code for double.\n") ; - - return (CPU_IS_LITTLE_ENDIAN) ? DOUBLE_BROKEN_LE : DOUBLE_BROKEN_BE ; -} /* double64_get_capability */ - -/*======================================================================================= -*/ - -static void -d2s_array (const double *src, int count, short *dest, double scale) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = psf_lrint (scale * src [i]) ; - } ; -} /* d2s_array */ - -static void -d2s_clip_array (const double *src, int count, short *dest, double scale) -{ for (int i = 0 ; i < count ; i++) - { double tmp = scale * src [i] ; - - if (tmp > 32767.0) - dest [i] = SHRT_MAX ; - else if (tmp < -32768.0) - dest [i] = SHRT_MIN ; - else - dest [i] = psf_lrint (tmp) ; - } ; -} /* d2s_clip_array */ - -static void -d2i_array (const double *src, int count, int *dest, double scale) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = psf_lrint (scale * src [i]) ; - } ; -} /* d2i_array */ - -static void -d2i_clip_array (const double *src, int count, int *dest, double scale) -{ for (int i = 0 ; i < count ; i++) - { float tmp = scale * src [i] ; - - if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX)) - dest [i] = INT_MAX ; - else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX)) - dest [i] = INT_MIN ; - else - dest [i] = psf_lrint (tmp) ; - } ; -} /* d2i_clip_array */ - -static inline void -d2f_array (const double *src, int count, float *dest) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = src [i] ; - } ; -} /* d2f_array */ - -static inline void -s2d_array (const short *src, double *dest, int count, double scale) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = scale * src [i] ; - } ; -} /* s2d_array */ - -static inline void -i2d_array (const int *src, double *dest, int count, double scale) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = scale * src [i] ; - } ; -} /* i2d_array */ - -static inline void -f2d_array (const float *src, double *dest, int count) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = src [i] ; - } ; -} /* f2d_array */ - -/*---------------------------------------------------------------------------------------------- -*/ - -static sf_count_t -host_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, int, short *, double) ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double scale ; - - convert = (psf->add_clipping) ? d2s_clip_array : d2s_array ; - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, readcount) ; - - convert (ubuf.dbuf, readcount, ptr + total, scale) ; - total += readcount ; - len -= readcount ; - if (readcount < bufferlen) - break ; - } ; - - return total ; -} /* host_read_d2s */ - -static sf_count_t -host_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, int, int *, double) ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double scale ; - - convert = (psf->add_clipping) ? d2i_clip_array : d2i_array ; - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - scale = (psf->float_int_mult == 0) ? 1.0 : 2147483648.0f / psf->float_max ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - convert (ubuf.dbuf, readcount, ptr + total, scale) ; - total += readcount ; - len -= readcount ; - if (readcount < bufferlen) - break ; - } ; - - return total ; -} /* host_read_d2i */ - -static sf_count_t -host_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, readcount) ; - - d2f_array (ubuf.dbuf, readcount, ptr + total) ; - total += readcount ; - len -= readcount ; - if (readcount < bufferlen) - break ; - } ; - - return total ; -} /* host_read_d2f */ - -static sf_count_t -host_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ int bufferlen ; - sf_count_t readcount, total = 0 ; - - readcount = psf_fread (ptr, sizeof (double), len, psf) ; - - if (psf->data_endswap != SF_TRUE) - return readcount ; - - /* If the read length was sensible, endswap output in one go. */ - if (readcount < SENSIBLE_LEN) - { endswap_double_array (ptr, readcount) ; - return readcount ; - } ; - - bufferlen = SENSIBLE_LEN ; - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - - endswap_double_array (ptr + total, bufferlen) ; - - total += bufferlen ; - len -= bufferlen ; - } ; - - return total ; -} /* host_read_d */ - -static sf_count_t -host_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - double scale ; - - scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ; - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - - s2d_array (ptr + total, ubuf.dbuf, bufferlen, scale) ; - - if (psf->peak_info) - double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* host_write_s2d */ - -static sf_count_t -host_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - double scale ; - - scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ; - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2d_array (ptr + total, ubuf.dbuf, bufferlen, scale) ; - - if (psf->peak_info) - double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* host_write_i2d */ - -static sf_count_t -host_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - f2d_array (ptr + total, ubuf.dbuf, bufferlen) ; - - if (psf->peak_info) - double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* host_write_f2d */ - -static sf_count_t -host_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - if (psf->peak_info) - double64_peak_update (psf, ptr, len, 0) ; - - if (psf->data_endswap != SF_TRUE) - return psf_fwrite (ptr, sizeof (double), len, psf) ; - - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - - endswap_double_copy (ubuf.dbuf, ptr + total, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* host_write_d */ - -/*======================================================================================= -*/ - -static sf_count_t -replace_read_d2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double scale ; - - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - d2bd_read (ubuf.dbuf, bufferlen) ; - - d2s_array (ubuf.dbuf, readcount, ptr + total, scale) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* replace_read_d2s */ - -static sf_count_t -replace_read_d2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double scale ; - - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - scale = (psf->float_int_mult == 0) ? 1.0 : 2147483648.0f / psf->float_max ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - d2bd_read (ubuf.dbuf, bufferlen) ; - - d2i_array (ubuf.dbuf, readcount, ptr + total, scale) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* replace_read_d2i */ - -static sf_count_t -replace_read_d2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - d2bd_read (ubuf.dbuf, bufferlen) ; - - memcpy (ptr + total, ubuf.dbuf, bufferlen * sizeof (double)) ; - - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* replace_read_d2f */ - -static sf_count_t -replace_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - /* FIXME : This is probably nowhere near optimal. */ - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, readcount) ; - - d2bd_read (ubuf.dbuf, readcount) ; - - memcpy (ptr + total, ubuf.dbuf, readcount * sizeof (double)) ; - - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* replace_read_d */ - -static sf_count_t -replace_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - double scale ; - - scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ; - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2d_array (ptr + total, ubuf.dbuf, bufferlen, scale) ; - - if (psf->peak_info) - double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; - - bd2d_write (ubuf.dbuf, bufferlen) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* replace_write_s2d */ - -static sf_count_t -replace_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - double scale ; - - scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ; - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2d_array (ptr + total, ubuf.dbuf, bufferlen, scale) ; - - if (psf->peak_info) - double64_peak_update (psf, ubuf.dbuf, bufferlen, total / psf->sf.channels) ; - - bd2d_write (ubuf.dbuf, bufferlen) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* replace_write_i2d */ - -static sf_count_t -replace_write_f2d (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - f2d_array (ptr + total, ubuf.dbuf, bufferlen) ; - - bd2d_write (ubuf.dbuf, bufferlen) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* replace_write_f2d */ - -static sf_count_t -replace_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - /* FIXME : This is probably nowhere near optimal. */ - if (psf->peak_info) - double64_peak_update (psf, ptr, len, 0) ; - - bufferlen = ARRAY_LEN (ubuf.dbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - - memcpy (ubuf.dbuf, ptr + total, bufferlen * sizeof (double)) ; - - bd2d_write (ubuf.dbuf, bufferlen) ; - - if (psf->data_endswap == SF_TRUE) - endswap_double_array (ubuf.dbuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.dbuf, sizeof (double), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* replace_write_d */ - -/*---------------------------------------------------------------------------------------------- -*/ - -static void -d2bd_read (double *buffer, int count) -{ for (int i = 0 ; i < count ; i++) - { buffer [i] = DOUBLE64_READ ((unsigned char *) &buffer [i]) ; - } ; -} /* d2bd_read */ - -static void -bd2d_write (double *buffer, int count) -{ for (int i = 0 ; i < count ; i++) - { DOUBLE64_WRITE (buffer [i], (unsigned char*) &buffer [i]) ; - } ; -} /* bd2d_write */ - diff --git a/Engine/lib/libsndfile/src/dwd.c b/Engine/lib/libsndfile/src/dwd.c deleted file mode 100644 index a15750d4f..000000000 --- a/Engine/lib/libsndfile/src/dwd.c +++ /dev/null @@ -1,201 +0,0 @@ -/* -** Copyright (C) 2002-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if (ENABLE_EXPERIMENTAL_CODE == 0) - -int -dwd_open (SF_PRIVATE *psf) -{ if (psf) - return SFE_UNIMPLEMENTED ; - return 0 ; -} /* dwd_open */ - -#else - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -#define SFE_DWD_NO_DWD 1666 -#define SFE_DWD_BAND_BIT_WIDTH 1667 -#define SFE_DWD_COMPRESSION 1668 - -#define DWD_IDENTIFIER "DiamondWare Digitized\n\0\x1a" -#define DWD_IDENTIFIER_LEN 24 - -#define DWD_HEADER_LEN 57 - -/*------------------------------------------------------------------------------ -** Typedefs. -*/ - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int dwd_read_header (SF_PRIVATE *psf) ; - -static int dwd_close (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -dwd_open (SF_PRIVATE *psf) -{ int error = 0 ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = dwd_read_header (psf))) - return error ; - } ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_DWD) - return SFE_BAD_OPEN_FORMAT ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { - /*-psf->endian = SF_ENDIAN (psf->sf.format) ; - if (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU) - psf->endian = SF_ENDIAN_LITTLE ; - else if (psf->endian != SF_ENDIAN_LITTLE) - psf->endian = SF_ENDIAN_BIG ; - - if (! (encoding = dwd_write_header (psf, SF_FALSE))) - return psf->error ; - - psf->write_header = dwd_write_header ; - -*/ - } ; - - psf->container_close = dwd_close ; - - /*-psf->blockwidth = psf->bytewidth * psf->sf.channels ;-*/ - - return error ; -} /* dwd_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -dwd_close (SF_PRIVATE * UNUSED (psf)) -{ - return 0 ; -} /* dwd_close */ - -/* This struct contains all the fields of interest om the DWD header, but does not -** do so in the same order and layout as the actual file, header. -** No assumptions are made about the packing of this struct. -*/ -typedef struct -{ uint8_t major, minor, compression, channels, bitwidth ; - uint16_t srate, maxval ; - uint32_t id, datalen, frames, offset ; -} DWD_HEADER ; - -static int -dwd_read_header (SF_PRIVATE *psf) -{ BUF_UNION ubuf ; - DWD_HEADER dwdh ; - - memset (ubuf.cbuf, 0, sizeof (ubuf.cbuf)) ; - /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "pb", 0, ubuf.cbuf, DWD_IDENTIFIER_LEN) ; - - if (memcmp (ubuf.cbuf, DWD_IDENTIFIER, DWD_IDENTIFIER_LEN) != 0) - return SFE_DWD_NO_DWD ; - - psf_log_printf (psf, "Read only : DiamondWare Digitized (.dwd)\n", ubuf.cbuf) ; - - psf_binheader_readf (psf, "11", &dwdh.major, &dwdh.minor) ; - psf_binheader_readf (psf, "e4j1", &dwdh.id, 1, &dwdh.compression) ; - psf_binheader_readf (psf, "e211", &dwdh.srate, &dwdh.channels, &dwdh.bitwidth) ; - psf_binheader_readf (psf, "e24", &dwdh.maxval, &dwdh.datalen) ; - psf_binheader_readf (psf, "e44", &dwdh.frames, &dwdh.offset) ; - - psf_log_printf (psf, " Version Major : %d\n Version Minor : %d\n Unique ID : %08X\n", - dwdh.major, dwdh.minor, dwdh.id) ; - psf_log_printf (psf, " Compression : %d => ", dwdh.compression) ; - - if (dwdh.compression != 0) - { psf_log_printf (psf, "Unsupported compression\n") ; - return SFE_DWD_COMPRESSION ; - } - else - psf_log_printf (psf, "None\n") ; - - psf_log_printf (psf, " Sample Rate : %d\n Channels : %d\n" - " Bit Width : %d\n", - dwdh.srate, dwdh.channels, dwdh.bitwidth) ; - - switch (dwdh.bitwidth) - { case 8 : - psf->sf.format = SF_FORMAT_DWD | SF_FORMAT_PCM_S8 ; - psf->bytewidth = 1 ; - break ; - - case 16 : - psf->sf.format = SF_FORMAT_DWD | SF_FORMAT_PCM_16 ; - psf->bytewidth = 2 ; - break ; - - default : - psf_log_printf (psf, "*** Bad bit width %d\n", dwdh.bitwidth) ; - return SFE_DWD_BAND_BIT_WIDTH ; - } ; - - if (psf->filelength != dwdh.offset + dwdh.datalen) - { psf_log_printf (psf, " Data Length : %d (should be %D)\n", dwdh.datalen, psf->filelength - dwdh.offset) ; - dwdh.datalen = (uint32_t) (psf->filelength - dwdh.offset) ; - } - else - psf_log_printf (psf, " Data Length : %d\n", dwdh.datalen) ; - - psf_log_printf (psf, " Max Value : %d\n", dwdh.maxval) ; - psf_log_printf (psf, " Frames : %d\n", dwdh.frames) ; - psf_log_printf (psf, " Data Offset : %d\n", dwdh.offset) ; - - psf->datalength = dwdh.datalen ; - psf->dataoffset = dwdh.offset ; - - psf->endian = SF_ENDIAN_LITTLE ; - - psf->sf.samplerate = dwdh.srate ; - psf->sf.channels = dwdh.channels ; - psf->sf.sections = 1 ; - - return pcm_init (psf) ; -} /* dwd_read_header */ - -/*------------------------------------------------------------------------------ -*/ - -#endif - diff --git a/Engine/lib/libsndfile/src/dwvw.c b/Engine/lib/libsndfile/src/dwvw.c deleted file mode 100644 index a015fceb0..000000000 --- a/Engine/lib/libsndfile/src/dwvw.c +++ /dev/null @@ -1,674 +0,0 @@ -/* -** Copyright (C) 2002-2014 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/*=========================================================================== -** Delta Word Variable Width -** -** This decoder and encoder were implemented using information found in this -** document : http://home.swbell.net/rubywand/R011SNDFMTS.TXT -** -** According to the document, the algorithm "was invented 1991 by Magnus -** Lidstrom and is copyright 1993 by NuEdge Development". -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -typedef struct -{ int bit_width, dwm_maxsize, max_delta, span ; - int samplecount ; - int bit_count, bits, last_delta_width, last_sample ; - struct - { int index, end ; - unsigned char buffer [256] ; - } b ; -} DWVW_PRIVATE ; - -/*============================================================================================ -*/ - -static sf_count_t dwvw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t dwvw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t dwvw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t dwvw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t dwvw_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t dwvw_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t dwvw_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static sf_count_t dwvw_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; -static int dwvw_close (SF_PRIVATE *psf) ; -static int dwvw_byterate (SF_PRIVATE *psf) ; - -static int dwvw_decode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int *ptr, int len) ; -static int dwvw_decode_load_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int bit_count) ; - -static int dwvw_encode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, const int *ptr, int len) ; -static void dwvw_encode_store_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int data, int new_bits) ; -static void dwvw_read_reset (DWVW_PRIVATE *pdwvw) ; - -/*============================================================================================ -** DWVW initialisation function. -*/ - -int -dwvw_init (SF_PRIVATE *psf, int bitwidth) -{ DWVW_PRIVATE *pdwvw ; - - if (psf->codec_data != NULL) - { psf_log_printf (psf, "*** psf->codec_data is not NULL.\n") ; - return SFE_INTERNAL ; - } ; - - if (bitwidth > 24) - return SFE_DWVW_BAD_BITWIDTH ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if ((pdwvw = calloc (1, sizeof (DWVW_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - - psf->codec_data = (void*) pdwvw ; - pdwvw->bit_width = bitwidth ; - dwvw_read_reset (pdwvw) ; - - if (psf->file.mode == SFM_READ) - { psf->read_short = dwvw_read_s ; - psf->read_int = dwvw_read_i ; - psf->read_float = dwvw_read_f ; - psf->read_double = dwvw_read_d ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->write_short = dwvw_write_s ; - psf->write_int = dwvw_write_i ; - psf->write_float = dwvw_write_f ; - psf->write_double = dwvw_write_d ; - } ; - - psf->codec_close = dwvw_close ; - psf->seek = dwvw_seek ; - psf->byterate = dwvw_byterate ; - - if (psf->file.mode == SFM_READ) - { psf->sf.frames = psf_decode_frame_count (psf) ; - dwvw_read_reset (pdwvw) ; - } ; - - return 0 ; -} /* dwvw_init */ - -/*-------------------------------------------------------------------------------------------- -*/ - -static int -dwvw_close (SF_PRIVATE *psf) -{ DWVW_PRIVATE *pdwvw ; - - if (psf->codec_data == NULL) - return 0 ; - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - if (psf->file.mode == SFM_WRITE) - { static int last_values [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ; - - /* Write 8 zero samples to fully flush output. */ - dwvw_encode_data (psf, pdwvw, last_values, 12) ; - - /* Write the last buffer worth of data to disk. */ - psf_fwrite (pdwvw->b.buffer, 1, pdwvw->b.index, psf) ; - - if (psf->write_header) - psf->write_header (psf, SF_TRUE) ; - } ; - - return 0 ; -} /* dwvw_close */ - -static sf_count_t -dwvw_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) -{ DWVW_PRIVATE *pdwvw ; - - if (! psf->codec_data) - { psf->error = SFE_INTERNAL ; - return PSF_SEEK_ERROR ; - } ; - - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - if (offset == 0) - { psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - dwvw_read_reset (pdwvw) ; - return 0 ; - } ; - - psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; -} /* dwvw_seek */ - -static int -dwvw_byterate (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_READ) - return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; - - return -1 ; -} /* dwvw_byterate */ - -/*============================================================================== -*/ - -static sf_count_t -dwvw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ DWVW_PRIVATE *pdwvw ; - BUF_UNION ubuf ; - int *iptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = dwvw_decode_data (psf, pdwvw, iptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = iptr [k] >> 16 ; - - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* dwvw_read_s */ - -static sf_count_t -dwvw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ DWVW_PRIVATE *pdwvw ; - int readcount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - while (len > 0) - { readcount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = dwvw_decode_data (psf, pdwvw, ptr, readcount) ; - - total += count ; - len -= count ; - - if (count != readcount) - break ; - } ; - - return total ; -} /* dwvw_read_i */ - -static sf_count_t -dwvw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ DWVW_PRIVATE *pdwvw ; - BUF_UNION ubuf ; - int *iptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (! psf->codec_data) - return 0 ; - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = dwvw_decode_data (psf, pdwvw, iptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (float) (iptr [k]) ; - - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* dwvw_read_f */ - -static sf_count_t -dwvw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ DWVW_PRIVATE *pdwvw ; - BUF_UNION ubuf ; - int *iptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - if (! psf->codec_data) - return 0 ; - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = dwvw_decode_data (psf, pdwvw, iptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (double) (iptr [k]) ; - - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* dwvw_read_d */ - -static int -dwvw_decode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int *ptr, int len) -{ int count ; - int delta_width_modifier, delta_width, delta_negative, delta, sample ; - - /* Restore state from last decode call. */ - delta_width = pdwvw->last_delta_width ; - sample = pdwvw->last_sample ; - - for (count = 0 ; count < len ; count++) - { /* If bit_count parameter is zero get the delta_width_modifier. */ - delta_width_modifier = dwvw_decode_load_bits (psf, pdwvw, -1) ; - - /* Check for end of input bit stream. Break loop if end. */ - if (delta_width_modifier < 0 || (pdwvw->b.end == 0 && count == 0)) - break ; - - if (delta_width_modifier && dwvw_decode_load_bits (psf, pdwvw, 1)) - delta_width_modifier = - delta_width_modifier ; - - /* Calculate the current word width. */ - delta_width = (delta_width + delta_width_modifier + pdwvw->bit_width) % pdwvw->bit_width ; - - /* Load the delta. */ - delta = 0 ; - if (delta_width) - { delta = dwvw_decode_load_bits (psf, pdwvw, delta_width - 1) | (1 << (delta_width - 1)) ; - delta_negative = dwvw_decode_load_bits (psf, pdwvw, 1) ; - if (delta == pdwvw->max_delta - 1) - delta += dwvw_decode_load_bits (psf, pdwvw, 1) ; - if (delta_negative) - delta = -delta ; - } ; - - /* Calculate the sample */ - sample += delta ; - - if (sample >= pdwvw->max_delta) - sample -= pdwvw->span ; - else if (sample < - pdwvw->max_delta) - sample += pdwvw->span ; - - /* Store the sample justifying to the most significant bit. */ - ptr [count] = arith_shift_left (sample, 32 - pdwvw->bit_width) ; - - if (pdwvw->b.end == 0 && pdwvw->bit_count == 0) - break ; - } ; - - pdwvw->last_delta_width = delta_width ; - pdwvw->last_sample = sample ; - - pdwvw->samplecount += count ; - - return count ; -} /* dwvw_decode_data */ - -static int -dwvw_decode_load_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int bit_count) -{ int output = 0, get_dwm = SF_FALSE ; - - /* - ** Depending on the value of parameter bit_count, either get the - ** required number of bits (ie bit_count > 0) or the - ** delta_width_modifier (otherwise). - */ - - if (bit_count < 0) - { get_dwm = SF_TRUE ; - /* modify bit_count to ensure we have enought bits for finding dwm. */ - bit_count = pdwvw->dwm_maxsize ; - } ; - - /* Load bits in bit reseviour. */ - while (pdwvw->bit_count < bit_count) - { if (pdwvw->b.index >= pdwvw->b.end) - { pdwvw->b.end = (int) psf_fread (pdwvw->b.buffer, 1, sizeof (pdwvw->b.buffer), psf) ; - pdwvw->b.index = 0 ; - } ; - - /* Check for end of input stream. */ - if (bit_count < 8 && pdwvw->b.end == 0) - return -1 ; - - pdwvw->bits = arith_shift_left (pdwvw->bits, 8) ; - - if (pdwvw->b.index < pdwvw->b.end) - { pdwvw->bits |= pdwvw->b.buffer [pdwvw->b.index] ; - pdwvw->b.index ++ ; - } ; - pdwvw->bit_count += 8 ; - } ; - - /* If asked to get bits do so. */ - if (! get_dwm) - { output = (pdwvw->bits >> (pdwvw->bit_count - bit_count)) & ((1 << bit_count) - 1) ; - pdwvw->bit_count -= bit_count ; - return output ; - } ; - - /* Otherwise must have been asked to get delta_width_modifier. */ - while (output < (pdwvw->dwm_maxsize)) - { pdwvw->bit_count -= 1 ; - if (pdwvw->bits & (1 << pdwvw->bit_count)) - break ; - output += 1 ; - } ; - - return output ; -} /* dwvw_decode_load_bits */ - -static void -dwvw_read_reset (DWVW_PRIVATE *pdwvw) -{ int bitwidth = pdwvw->bit_width ; - - memset (pdwvw, 0, sizeof (DWVW_PRIVATE)) ; - - pdwvw->bit_width = bitwidth ; - pdwvw->dwm_maxsize = bitwidth / 2 ; - pdwvw->max_delta = 1 << (bitwidth - 1) ; - pdwvw->span = 1 << bitwidth ; -} /* dwvw_read_reset */ - -static void -dwvw_encode_store_bits (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, int data, int new_bits) -{ int byte ; - - /* Shift the bits into the resevoir. */ - pdwvw->bits = arith_shift_left (pdwvw->bits, new_bits) | (data & (arith_shift_left (1, new_bits) - 1)) ; - pdwvw->bit_count += new_bits ; - - /* Transfer bit to buffer. */ - while (pdwvw->bit_count >= 8) - { byte = pdwvw->bits >> (pdwvw->bit_count - 8) ; - pdwvw->bit_count -= 8 ; - pdwvw->b.buffer [pdwvw->b.index] = byte & 0xFF ; - pdwvw->b.index ++ ; - } ; - - if (pdwvw->b.index > SIGNED_SIZEOF (pdwvw->b.buffer) - 4) - { psf_fwrite (pdwvw->b.buffer, 1, pdwvw->b.index, psf) ; - pdwvw->b.index = 0 ; - } ; - - return ; -} /* dwvw_encode_store_bits */ - -#if 0 -/* Debigging routine. */ -static void -dump_bits (DWVW_PRIVATE *pdwvw) -{ int k, mask ; - - for (k = 0 ; k < 10 && k < pdwvw->b.index ; k++) - { mask = 0x80 ; - while (mask) - { putchar (mask & pdwvw->b.buffer [k] ? '1' : '0') ; - mask >>= 1 ; - } ; - putchar (' ') ; - } - - for (k = pdwvw->bit_count - 1 ; k >= 0 ; k --) - putchar (pdwvw->bits & (1 << k) ? '1' : '0') ; - - putchar ('\n') ; -} /* dump_bits */ -#endif - -#define HIGHEST_BIT(x, count) \ - { int y = x ; \ - (count) = 0 ; \ - while (y) \ - { (count) ++ ; \ - y >>= 1 ; \ - } ; \ - } ; - -static int -dwvw_encode_data (SF_PRIVATE *psf, DWVW_PRIVATE *pdwvw, const int *ptr, int len) -{ int count ; - int delta_width_modifier, delta, delta_negative, delta_width, extra_bit ; - - for (count = 0 ; count < len ; count++) - { delta = (ptr [count] >> (32 - pdwvw->bit_width)) - pdwvw->last_sample ; - - /* Calculate extra_bit if needed. */ - extra_bit = -1 ; - delta_negative = 0 ; - if (delta < -pdwvw->max_delta) - delta = pdwvw->max_delta + (delta % pdwvw->max_delta) ; - else if (delta == -pdwvw->max_delta) - { extra_bit = 1 ; - delta_negative = 1 ; - delta = pdwvw->max_delta - 1 ; - } - else if (delta > pdwvw->max_delta) - { delta_negative = 1 ; - delta = pdwvw->span - delta ; - delta = abs (delta) ; - } - else if (delta == pdwvw->max_delta) - { extra_bit = 1 ; - delta = pdwvw->max_delta - 1 ; - } - else if (delta < 0) - { delta_negative = 1 ; - delta = abs (delta) ; - } ; - - if (delta == pdwvw->max_delta - 1 && extra_bit == -1) - extra_bit = 0 ; - - /* Find width in bits of delta */ - HIGHEST_BIT (delta, delta_width) ; - - /* Calculate the delta_width_modifier */ - delta_width_modifier = (delta_width - pdwvw->last_delta_width) % pdwvw->bit_width ; - if (delta_width_modifier > pdwvw->dwm_maxsize) - delta_width_modifier -= pdwvw->bit_width ; - if (delta_width_modifier < -pdwvw->dwm_maxsize) - delta_width_modifier += pdwvw->bit_width ; - - /* Write delta_width_modifier zeros, followed by terminating '1'. */ - dwvw_encode_store_bits (psf, pdwvw, 0, abs (delta_width_modifier)) ; - if (abs (delta_width_modifier) != pdwvw->dwm_maxsize) - dwvw_encode_store_bits (psf, pdwvw, 1, 1) ; - - /* Write delta_width_modifier sign. */ - if (delta_width_modifier < 0) - dwvw_encode_store_bits (psf, pdwvw, 1, 1) ; - if (delta_width_modifier > 0) - dwvw_encode_store_bits (psf, pdwvw, 0, 1) ; - - /* Write delta and delta sign bit. */ - if (delta_width) - { dwvw_encode_store_bits (psf, pdwvw, delta, abs (delta_width) - 1) ; - dwvw_encode_store_bits (psf, pdwvw, (delta_negative ? 1 : 0), 1) ; - } ; - - /* Write extra bit!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ - if (extra_bit >= 0) - dwvw_encode_store_bits (psf, pdwvw, extra_bit, 1) ; - - pdwvw->last_sample = ptr [count] >> (32 - pdwvw->bit_width) ; - pdwvw->last_delta_width = delta_width ; - } ; - - pdwvw->samplecount += count ; - - return count ; -} /* dwvw_encode_data */ - -static sf_count_t -dwvw_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ DWVW_PRIVATE *pdwvw ; - BUF_UNION ubuf ; - int *iptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - iptr [k] = arith_shift_left (ptr [total + k], 16) ; - count = dwvw_encode_data (psf, pdwvw, iptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* dwvw_write_s */ - -static sf_count_t -dwvw_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ DWVW_PRIVATE *pdwvw ; - int writecount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - while (len > 0) - { writecount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = dwvw_encode_data (psf, pdwvw, ptr, writecount) ; - - total += count ; - len -= count ; - - if (count != writecount) - break ; - } ; - - return total ; -} /* dwvw_write_i */ - -static sf_count_t -dwvw_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ DWVW_PRIVATE *pdwvw ; - BUF_UNION ubuf ; - int *iptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (! psf->codec_data) - return 0 ; - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : 1.0 ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - iptr [k] = psf_lrintf (normfact * ptr [total + k]) ; - count = dwvw_encode_data (psf, pdwvw, iptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* dwvw_write_f */ - -static sf_count_t -dwvw_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ DWVW_PRIVATE *pdwvw ; - BUF_UNION ubuf ; - int *iptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - if (! psf->codec_data) - return 0 ; - pdwvw = (DWVW_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : 1.0 ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - iptr [k] = psf_lrint (normfact * ptr [total + k]) ; - count = dwvw_encode_data (psf, pdwvw, iptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* dwvw_write_d */ - diff --git a/Engine/lib/libsndfile/src/file_io.c b/Engine/lib/libsndfile/src/file_io.c deleted file mode 100644 index b7f7ed77f..000000000 --- a/Engine/lib/libsndfile/src/file_io.c +++ /dev/null @@ -1,1206 +0,0 @@ -/* -** Copyright (C) 2002-2014 Erik de Castro Lopo -** Copyright (C) 2003 Ross Bencina -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** The file is split into three sections as follows: -** - The top section (USE_WINDOWS_API == 0) for Linux, Unix and MacOSX -** systems (including Cygwin). -** - The middle section (USE_WINDOWS_API == 1) for microsoft windows -** (including MinGW) using the native windows API. -** - A legacy windows section which attempted to work around grevious -** bugs in microsoft's POSIX implementation. -*/ - -/* -** The header file sfconfig.h MUST be included before the others to ensure -** that large file support is enabled correctly on Unix systems. -*/ - -#include "sfconfig.h" - -#if USE_WINDOWS_API - -/* Don't include rarely used headers, speed up build */ -#define WIN32_LEAN_AND_MEAN - -#include -#endif - -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include -#endif - -#if (HAVE_DECL_S_IRGRP == 0) -#include -#endif - -#include -#include -#include -#include - -#include "sndfile.h" -#include "common.h" - -#define SENSIBLE_SIZE (0x40000000) - -/* -** Neat solution to the Win32/OS2 binary file flage requirement. -** If O_BINARY isn't already defined by the inclusion of the system -** headers, set it to zero. -*/ -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -static void psf_log_syserr (SF_PRIVATE *psf, int error) ; - -int -psf_copy_filename (SF_PRIVATE *psf, const char *path) -{ const char *ccptr ; - char *cptr ; - - if (strlen (path) > 1 && strlen (path) - 1 >= sizeof (psf->file.path)) - { psf->error = SFE_FILENAME_TOO_LONG ; - return psf->error ; - } ; - - snprintf (psf->file.path, sizeof (psf->file.path), "%s", path) ; - if ((ccptr = strrchr (path, '/')) || (ccptr = strrchr (path, '\\'))) - ccptr ++ ; - else - ccptr = path ; - - snprintf (psf->file.name, sizeof (psf->file.name), "%s", ccptr) ; - - /* Now grab the directory. */ - snprintf (psf->file.dir, sizeof (psf->file.dir), "%s", path) ; - if ((cptr = strrchr (psf->file.dir, '/')) || (cptr = strrchr (psf->file.dir, '\\'))) - cptr [1] = 0 ; - else - psf->file.dir [0] = 0 ; - - return 0 ; -} /* psf_copy_filename */ - -#if (USE_WINDOWS_API == 0) - -/*------------------------------------------------------------------------------ -** Win32 stuff at the bottom of the file. Unix and other sensible OSes here. -*/ - -static int psf_close_fd (int fd) ; -static int psf_open_fd (PSF_FILE * pfile) ; -static sf_count_t psf_get_filelen_fd (int fd) ; - -int -psf_fopen (SF_PRIVATE *psf) -{ - psf->error = 0 ; - psf->file.filedes = psf_open_fd (&psf->file) ; - - if (psf->file.filedes == - SFE_BAD_OPEN_MODE) - { psf->error = SFE_BAD_OPEN_MODE ; - psf->file.filedes = -1 ; - return psf->error ; - } ; - - if (psf->file.filedes == -1) - psf_log_syserr (psf, errno) ; - - return psf->error ; -} /* psf_fopen */ - -int -psf_fclose (SF_PRIVATE *psf) -{ int retval ; - - if (psf->virtual_io) - return 0 ; - - if (psf->file.do_not_close_descriptor) - { psf->file.filedes = -1 ; - return 0 ; - } ; - - if ((retval = psf_close_fd (psf->file.filedes)) == -1) - psf_log_syserr (psf, errno) ; - - psf->file.filedes = -1 ; - - return retval ; -} /* psf_fclose */ - -int -psf_open_rsrc (SF_PRIVATE *psf) -{ size_t count ; - - if (psf->rsrc.filedes > 0) - return 0 ; - - /* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */ - count = snprintf (psf->rsrc.path, sizeof (psf->rsrc.path), "%s/..namedfork/rsrc", psf->file.path) ; - psf->error = SFE_NO_ERROR ; - if (count < sizeof (psf->rsrc.path)) - { if ((psf->rsrc.filedes = psf_open_fd (&psf->rsrc)) >= 0) - { psf->rsrclength = psf_get_filelen_fd (psf->rsrc.filedes) ; - if (psf->rsrclength > 0 || (psf->rsrc.mode & SFM_WRITE)) - return SFE_NO_ERROR ; - psf_close_fd (psf->rsrc.filedes) ; - psf->rsrc.filedes = -1 ; - } ; - - if (psf->rsrc.filedes == - SFE_BAD_OPEN_MODE) - { psf->error = SFE_BAD_OPEN_MODE ; - return psf->error ; - } ; - } ; - - /* - ** Now try for a resource fork stored as a separate file in the same - ** directory, but preceded with a dot underscore. - */ - count = snprintf (psf->rsrc.path, sizeof (psf->rsrc.path), "%s._%s", psf->file.dir, psf->file.name) ; - psf->error = SFE_NO_ERROR ; - if (count < sizeof (psf->rsrc.path) && (psf->rsrc.filedes = psf_open_fd (&psf->rsrc)) >= 0) - { psf->rsrclength = psf_get_filelen_fd (psf->rsrc.filedes) ; - return SFE_NO_ERROR ; - } ; - - /* - ** Now try for a resource fork stored in a separate file in the - ** .AppleDouble/ directory. - */ - count = snprintf (psf->rsrc.path, sizeof (psf->rsrc.path), "%s.AppleDouble/%s", psf->file.dir, psf->file.name) ; - psf->error = SFE_NO_ERROR ; - if (count < sizeof (psf->rsrc.path)) - { if ((psf->rsrc.filedes = psf_open_fd (&psf->rsrc)) >= 0) - { psf->rsrclength = psf_get_filelen_fd (psf->rsrc.filedes) ; - return SFE_NO_ERROR ; - } ; - - /* No resource file found. */ - if (psf->rsrc.filedes == -1) - psf_log_syserr (psf, errno) ; - } - else - { psf->error = SFE_OPEN_FAILED ; - } ; - - psf->rsrc.filedes = -1 ; - - return psf->error ; -} /* psf_open_rsrc */ - -sf_count_t -psf_get_filelen (SF_PRIVATE *psf) -{ sf_count_t filelen ; - - if (psf->virtual_io) - return psf->vio.get_filelen (psf->vio_user_data) ; - - filelen = psf_get_filelen_fd (psf->file.filedes) ; - - if (filelen == -1) - { psf_log_syserr (psf, errno) ; - return (sf_count_t) -1 ; - } ; - - if (filelen == -SFE_BAD_STAT_SIZE) - { psf->error = SFE_BAD_STAT_SIZE ; - return (sf_count_t) -1 ; - } ; - - switch (psf->file.mode) - { case SFM_WRITE : - filelen = filelen - psf->fileoffset ; - break ; - - case SFM_READ : - if (psf->fileoffset > 0 && psf->filelength > 0) - filelen = psf->filelength ; - break ; - - case SFM_RDWR : - /* - ** Cannot open embedded files SFM_RDWR so we don't need to - ** subtract psf->fileoffset. We already have the answer we - ** need. - */ - break ; - - default : - /* Shouldn't be here, so return error. */ - filelen = -1 ; - } ; - - return filelen ; -} /* psf_get_filelen */ - -int -psf_close_rsrc (SF_PRIVATE *psf) -{ psf_close_fd (psf->rsrc.filedes) ; - psf->rsrc.filedes = -1 ; - return 0 ; -} /* psf_close_rsrc */ - -int -psf_set_stdio (SF_PRIVATE *psf) -{ int error = 0 ; - - switch (psf->file.mode) - { case SFM_RDWR : - error = SFE_OPEN_PIPE_RDWR ; - break ; - - case SFM_READ : - psf->file.filedes = 0 ; - break ; - - case SFM_WRITE : - psf->file.filedes = 1 ; - break ; - - default : - error = SFE_BAD_OPEN_MODE ; - break ; - } ; - psf->filelength = 0 ; - - return error ; -} /* psf_set_stdio */ - -void -psf_set_file (SF_PRIVATE *psf, int fd) -{ psf->file.filedes = fd ; -} /* psf_set_file */ - -int -psf_file_valid (SF_PRIVATE *psf) -{ return (psf->file.filedes >= 0) ? SF_TRUE : SF_FALSE ; -} /* psf_set_file */ - -sf_count_t -psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) -{ sf_count_t absolute_position ; - - if (psf->virtual_io) - return psf->vio.seek (offset, whence, psf->vio_user_data) ; - - /* When decoding from pipes sometimes see seeks to the pipeoffset, which appears to mean do nothing. */ - if (psf->is_pipe) - { if (whence != SEEK_SET || offset != psf->pipeoffset) - psf_log_printf (psf, "psf_fseek : pipe seek to value other than pipeoffset\n") ; - return offset ; - } - - switch (whence) - { case SEEK_SET : - offset += psf->fileoffset ; - break ; - - case SEEK_END : - break ; - - case SEEK_CUR : - break ; - - default : - /* We really should not be here. */ - psf_log_printf (psf, "psf_fseek : whence is %d *****.\n", whence) ; - return 0 ; - } ; - - absolute_position = lseek (psf->file.filedes, offset, whence) ; - - if (absolute_position < 0) - psf_log_syserr (psf, errno) ; - - return absolute_position - psf->fileoffset ; -} /* psf_fseek */ - -sf_count_t -psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) -{ sf_count_t total = 0 ; - ssize_t count ; - - if (psf->virtual_io) - return psf->vio.read (ptr, bytes*items, psf->vio_user_data) / bytes ; - - items *= bytes ; - - /* Do this check after the multiplication above. */ - if (items <= 0) - return 0 ; - - while (items > 0) - { /* Break the read down to a sensible size. */ - count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ; - - count = read (psf->file.filedes, ((char*) ptr) + total, (size_t) count) ; - - if (count == -1) - { if (errno == EINTR) - continue ; - - psf_log_syserr (psf, errno) ; - break ; - } ; - - if (count == 0) - break ; - - total += count ; - items -= count ; - } ; - - if (psf->is_pipe) - psf->pipeoffset += total ; - - return total / bytes ; -} /* psf_fread */ - -sf_count_t -psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) -{ sf_count_t total = 0 ; - ssize_t count ; - - if (bytes == 0 || items == 0) - return 0 ; - - if (psf->virtual_io) - return psf->vio.write (ptr, bytes*items, psf->vio_user_data) / bytes ; - - items *= bytes ; - - /* Do this check after the multiplication above. */ - if (items <= 0) - return 0 ; - - while (items > 0) - { /* Break the writes down to a sensible size. */ - count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : items ; - - count = write (psf->file.filedes, ((const char*) ptr) + total, count) ; - - if (count == -1) - { if (errno == EINTR) - continue ; - - psf_log_syserr (psf, errno) ; - break ; - } ; - - if (count == 0) - break ; - - total += count ; - items -= count ; - } ; - - if (psf->is_pipe) - psf->pipeoffset += total ; - - return total / bytes ; -} /* psf_fwrite */ - -sf_count_t -psf_ftell (SF_PRIVATE *psf) -{ sf_count_t pos ; - - if (psf->virtual_io) - return psf->vio.tell (psf->vio_user_data) ; - - if (psf->is_pipe) - return psf->pipeoffset ; - - pos = lseek (psf->file.filedes, 0, SEEK_CUR) ; - - if (pos == ((sf_count_t) -1)) - { psf_log_syserr (psf, errno) ; - return -1 ; - } ; - - return pos - psf->fileoffset ; -} /* psf_ftell */ - -static int -psf_close_fd (int fd) -{ int retval ; - - if (fd < 0) - return 0 ; - - while ((retval = close (fd)) == -1 && errno == EINTR) - /* Do nothing. */ ; - - return retval ; -} /* psf_close_fd */ - -sf_count_t -psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf) -{ sf_count_t k = 0 ; - sf_count_t count ; - - while (k < bufsize - 1) - { count = read (psf->file.filedes, &(buffer [k]), 1) ; - - if (count == -1) - { if (errno == EINTR) - continue ; - - psf_log_syserr (psf, errno) ; - break ; - } ; - - if (count == 0 || buffer [k++] == '\n') - break ; - } ; - - buffer [k] = 0 ; - - return k ; -} /* psf_fgets */ - -int -psf_is_pipe (SF_PRIVATE *psf) -{ struct stat statbuf ; - - if (psf->virtual_io) - return SF_FALSE ; - - if (fstat (psf->file.filedes, &statbuf) == -1) - { psf_log_syserr (psf, errno) ; - /* Default to maximum safety. */ - return SF_TRUE ; - } ; - - if (S_ISFIFO (statbuf.st_mode) || S_ISSOCK (statbuf.st_mode)) - return SF_TRUE ; - - return SF_FALSE ; -} /* psf_is_pipe */ - -static sf_count_t -psf_get_filelen_fd (int fd) -{ -#if (SIZEOF_OFF_T == 4 && HAVE_FSTAT64) - struct stat64 statbuf ; - - if (fstat64 (fd, &statbuf) == -1) - return (sf_count_t) -1 ; - - return statbuf.st_size ; -#else - struct stat statbuf ; - - if (fstat (fd, &statbuf) == -1) - return (sf_count_t) -1 ; - - return statbuf.st_size ; -#endif -} /* psf_get_filelen_fd */ - -int -psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) -{ int retval ; - - /* Returns 0 on success, non-zero on failure. */ - if (len < 0) - return -1 ; - - if ((sizeof (off_t) < sizeof (sf_count_t)) && len > 0x7FFFFFFF) - return -1 ; - - retval = ftruncate (psf->file.filedes, len) ; - - if (retval == -1) - psf_log_syserr (psf, errno) ; - - return retval ; -} /* psf_ftruncate */ - -void -psf_init_files (SF_PRIVATE *psf) -{ psf->file.filedes = -1 ; - psf->rsrc.filedes = -1 ; - psf->file.savedes = -1 ; -} /* psf_init_files */ - -void -psf_use_rsrc (SF_PRIVATE *psf, int on_off) -{ - if (on_off) - { if (psf->file.filedes != psf->rsrc.filedes) - { psf->file.savedes = psf->file.filedes ; - psf->file.filedes = psf->rsrc.filedes ; - } ; - } - else if (psf->file.filedes == psf->rsrc.filedes) - psf->file.filedes = psf->file.savedes ; - - return ; -} /* psf_use_rsrc */ - -static int -psf_open_fd (PSF_FILE * pfile) -{ int fd, oflag, mode ; - - /* - ** Sanity check. If everything is OK, this test and the printfs will - ** be optimised out. This is meant to catch the problems caused by - ** "sfconfig.h" being included after . - */ - if (sizeof (sf_count_t) != 8) - { puts ("\n\n*** Fatal error : sizeof (sf_count_t) != 8") ; - puts ("*** This means that libsndfile was not configured correctly.\n") ; - exit (1) ; - } ; - - switch (pfile->mode) - { case SFM_READ : - oflag = O_RDONLY | O_BINARY ; - mode = 0 ; - break ; - - case SFM_WRITE : - oflag = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY ; - mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH ; - break ; - - case SFM_RDWR : - oflag = O_RDWR | O_CREAT | O_BINARY ; - mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH ; - break ; - - default : - return - SFE_BAD_OPEN_MODE ; - break ; - } ; - - if (mode == 0) - fd = open (pfile->path, oflag) ; - else - fd = open (pfile->path, oflag, mode) ; - - return fd ; -} /* psf_open_fd */ - -static void -psf_log_syserr (SF_PRIVATE *psf, int error) -{ - /* Only log an error if no error has been set yet. */ - if (psf->error == 0) - { psf->error = SFE_SYSTEM ; - snprintf (psf->syserr, sizeof (psf->syserr), "System error : %s.", strerror (error)) ; - } ; - - return ; -} /* psf_log_syserr */ - -void -psf_fsync (SF_PRIVATE *psf) -{ -#if HAVE_FSYNC - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - fsync (psf->file.filedes) ; -#else - psf = NULL ; -#endif -} /* psf_fsync */ - -#else - -/* Win32 file i/o functions implemented using native Win32 API */ - -#ifndef WINAPI_PARTITION_SYSTEM -#define WINAPI_PARTITION_SYSTEM 0 -#endif - -static int psf_close_handle (HANDLE handle) ; -static HANDLE psf_open_handle (PSF_FILE * pfile) ; -static sf_count_t psf_get_filelen_handle (HANDLE handle) ; - -/* USE_WINDOWS_API */ int -psf_fopen (SF_PRIVATE *psf) -{ - psf->error = 0 ; - psf->file.handle = psf_open_handle (&psf->file) ; - - if (psf->file.handle == INVALID_HANDLE_VALUE) - psf_log_syserr (psf, GetLastError ()) ; - - return psf->error ; -} /* psf_fopen */ - -/* USE_WINDOWS_API */ int -psf_fclose (SF_PRIVATE *psf) -{ int retval ; - - if (psf->virtual_io) - return 0 ; - - if (psf->file.do_not_close_descriptor) - { psf->file.handle = INVALID_HANDLE_VALUE ; - return 0 ; - } ; - - if ((retval = psf_close_handle (psf->file.handle)) == -1) - psf_log_syserr (psf, GetLastError ()) ; - - psf->file.handle = INVALID_HANDLE_VALUE ; - - return retval ; -} /* psf_fclose */ - -/* USE_WINDOWS_API */ int -psf_open_rsrc (SF_PRIVATE *psf) -{ - if (psf->rsrc.handle != INVALID_HANDLE_VALUE) - return 0 ; - - /* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */ - snprintf (psf->rsrc.path, sizeof (psf->rsrc.path), "%s/rsrc", psf->file.path) ; - psf->error = SFE_NO_ERROR ; - if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != INVALID_HANDLE_VALUE) - { psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ; - return SFE_NO_ERROR ; - } ; - - /* - ** Now try for a resource fork stored as a separate file in the same - ** directory, but preceded with a dot underscore. - */ - snprintf (psf->rsrc.path, sizeof (psf->rsrc.path), "%s._%s", psf->file.dir, psf->file.name) ; - psf->error = SFE_NO_ERROR ; - if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != INVALID_HANDLE_VALUE) - { psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ; - return SFE_NO_ERROR ; - } ; - - /* - ** Now try for a resource fork stored in a separate file in the - ** .AppleDouble/ directory. - */ - snprintf (psf->rsrc.path, sizeof (psf->rsrc.path), "%s.AppleDouble/%s", psf->file.dir, psf->file.name) ; - psf->error = SFE_NO_ERROR ; - if ((psf->rsrc.handle = psf_open_handle (&psf->rsrc)) != INVALID_HANDLE_VALUE) - { psf->rsrclength = psf_get_filelen_handle (psf->rsrc.handle) ; - return SFE_NO_ERROR ; - } ; - - /* No resource file found. */ - if (psf->rsrc.handle == INVALID_HANDLE_VALUE) - psf_log_syserr (psf, GetLastError ()) ; - - return psf->error ; -} /* psf_open_rsrc */ - -/* USE_WINDOWS_API */ sf_count_t -psf_get_filelen (SF_PRIVATE *psf) -{ sf_count_t filelen ; - - if (psf->virtual_io) - return psf->vio.get_filelen (psf->vio_user_data) ; - - filelen = psf_get_filelen_handle (psf->file.handle) ; - - if (filelen == -1) - { psf_log_syserr (psf, errno) ; - return (sf_count_t) -1 ; - } ; - - if (filelen == -SFE_BAD_STAT_SIZE) - { psf->error = SFE_BAD_STAT_SIZE ; - return (sf_count_t) -1 ; - } ; - - switch (psf->file.mode) - { case SFM_WRITE : - filelen = filelen - psf->fileoffset ; - break ; - - case SFM_READ : - if (psf->fileoffset > 0 && psf->filelength > 0) - filelen = psf->filelength ; - break ; - - case SFM_RDWR : - /* - ** Cannot open embedded files SFM_RDWR so we don't need to - ** subtract psf->fileoffset. We already have the answer we - ** need. - */ - break ; - - default : - /* Shouldn't be here, so return error. */ - filelen = -1 ; - } ; - - return filelen ; -} /* psf_get_filelen */ - -/* USE_WINDOWS_API */ void -psf_init_files (SF_PRIVATE *psf) -{ psf->file.handle = INVALID_HANDLE_VALUE ; - psf->rsrc.handle = INVALID_HANDLE_VALUE ; - psf->file.hsaved = INVALID_HANDLE_VALUE ; -} /* psf_init_files */ - -/* USE_WINDOWS_API */ void -psf_use_rsrc (SF_PRIVATE *psf, int on_off) -{ - if (on_off) - { if (psf->file.handle != psf->rsrc.handle) - { psf->file.hsaved = psf->file.handle ; - psf->file.handle = psf->rsrc.handle ; - } ; - } - else if (psf->file.handle == psf->rsrc.handle) - psf->file.handle = psf->file.hsaved ; - - return ; -} /* psf_use_rsrc */ - -/* USE_WINDOWS_API */ static HANDLE -psf_open_handle (PSF_FILE * pfile) -{ DWORD dwDesiredAccess ; - DWORD dwShareMode ; - DWORD dwCreationDistribution ; - HANDLE handle ; - LPWSTR pwszPath = NULL ; - - switch (pfile->mode) - { case SFM_READ : - dwDesiredAccess = GENERIC_READ ; - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE ; - dwCreationDistribution = OPEN_EXISTING ; - break ; - - case SFM_WRITE : - dwDesiredAccess = GENERIC_WRITE ; - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE ; - dwCreationDistribution = CREATE_ALWAYS ; - break ; - - case SFM_RDWR : - dwDesiredAccess = GENERIC_READ | GENERIC_WRITE ; - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE ; - dwCreationDistribution = OPEN_ALWAYS ; - break ; - - default : - return INVALID_HANDLE_VALUE ; - } ; - - int nResult = MultiByteToWideChar (CP_UTF8, 0, pfile->path, -1, NULL, 0) ; - pwszPath = malloc (nResult * sizeof (WCHAR)) ; - if (!pwszPath) - return INVALID_HANDLE_VALUE ; - - int nResult2 = MultiByteToWideChar (CP_UTF8, 0, pfile->path, -1, pwszPath, nResult) ; - if (nResult != nResult2) - { free (pwszPath) ; - return INVALID_HANDLE_VALUE ; - } ; - -#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) - CREATEFILE2_EXTENDED_PARAMETERS cfParams = { 0 } ; - cfParams.dwSize = sizeof (CREATEFILE2_EXTENDED_PARAMETERS) ; - cfParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL ; - - handle = CreateFile2 (pwszPath, dwDesiredAccess, dwShareMode, dwCreationDistribution, &cfParams) ; -#else - handle = CreateFileW ( - pwszPath, /* pointer to name of the file */ - dwDesiredAccess, /* access (read-write) mode */ - dwShareMode, /* share mode */ - 0, /* pointer to security attributes */ - dwCreationDistribution, /* how to create */ - FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */ - NULL /* handle to file with attributes to copy */ - ) ; -#endif - free (pwszPath) ; - - return handle ; -} /* psf_open_handle */ - -/* USE_WINDOWS_API */ static void -psf_log_syserr (SF_PRIVATE *psf, int error) -{ LPVOID lpMsgBuf ; - - /* Only log an error if no error has been set yet. */ - if (psf->error == 0) - { psf->error = SFE_SYSTEM ; - - FormatMessage ( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - error, - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &lpMsgBuf, - 0, - NULL - ) ; - - snprintf (psf->syserr, sizeof (psf->syserr), "System error : %s", (char*) lpMsgBuf) ; - LocalFree (lpMsgBuf) ; - } ; - - return ; -} /* psf_log_syserr */ - - -/* USE_WINDOWS_API */ int -psf_close_rsrc (SF_PRIVATE *psf) -{ psf_close_handle (psf->rsrc.handle) ; - psf->rsrc.handle = INVALID_HANDLE_VALUE ; - return 0 ; -} /* psf_close_rsrc */ - - -/* USE_WINDOWS_API */ int -psf_set_stdio (SF_PRIVATE *psf) -{ HANDLE handle = INVALID_HANDLE_VALUE ; - int error = 0 ; - - switch (psf->file.mode) - { case SFM_RDWR : - error = SFE_OPEN_PIPE_RDWR ; - break ; - - case SFM_READ : - handle = GetStdHandle (STD_INPUT_HANDLE) ; - psf->file.do_not_close_descriptor = 1 ; - break ; - - case SFM_WRITE : - handle = GetStdHandle (STD_OUTPUT_HANDLE) ; - psf->file.do_not_close_descriptor = 1 ; - break ; - - default : - error = SFE_BAD_OPEN_MODE ; - break ; - } ; - - psf->file.handle = handle ; - psf->filelength = 0 ; - - return error ; -} /* psf_set_stdio */ - -/* USE_WINDOWS_API */ void -psf_set_file (SF_PRIVATE *psf, int fd) -{ HANDLE handle ; - intptr_t osfhandle ; - - osfhandle = _get_osfhandle (fd) ; - handle = (HANDLE) osfhandle ; - - psf->file.handle = handle ; -} /* psf_set_file */ - -/* USE_WINDOWS_API */ int -psf_file_valid (SF_PRIVATE *psf) -{ if (psf->file.handle == INVALID_HANDLE_VALUE) - return SF_FALSE ; - return SF_TRUE ; -} /* psf_set_file */ - -/* USE_WINDOWS_API */ sf_count_t -psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) -{ sf_count_t new_position ; - LARGE_INTEGER liDistanceToMove, liNewFilePointer ; - DWORD dwMoveMethod ; - BOOL fResult ; - DWORD dwError ; - - if (psf->virtual_io) - return psf->vio.seek (offset, whence, psf->vio_user_data) ; - - switch (whence) - { case SEEK_SET : - offset += psf->fileoffset ; - dwMoveMethod = FILE_BEGIN ; - break ; - - case SEEK_END : - dwMoveMethod = FILE_END ; - break ; - - default : - dwMoveMethod = FILE_CURRENT ; - break ; - } ; - - liDistanceToMove.QuadPart = offset ; - - fResult = SetFilePointerEx (psf->file.handle, liDistanceToMove, &liNewFilePointer, dwMoveMethod) ; - - if (fResult == FALSE) - dwError = GetLastError () ; - else - dwError = NO_ERROR ; - - if (dwError != NO_ERROR) - { psf_log_syserr (psf, dwError) ; - return -1 ; - } ; - - new_position = liNewFilePointer.QuadPart - psf->fileoffset ; - - return new_position ; -} /* psf_fseek */ - -/* USE_WINDOWS_API */ sf_count_t -psf_fread (void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) -{ sf_count_t total = 0 ; - ssize_t count ; - DWORD dwNumberOfBytesRead ; - - if (psf->virtual_io) - return psf->vio.read (ptr, bytes*items, psf->vio_user_data) / bytes ; - - items *= bytes ; - - /* Do this check after the multiplication above. */ - if (items <= 0) - return 0 ; - - while (items > 0) - { /* Break the writes down to a sensible size. */ - count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ; - - if (ReadFile (psf->file.handle, ((char*) ptr) + total, count, &dwNumberOfBytesRead, 0) == 0) - { psf_log_syserr (psf, GetLastError ()) ; - break ; - } - else - count = dwNumberOfBytesRead ; - - if (count == 0) - break ; - - total += count ; - items -= count ; - } ; - - if (psf->is_pipe) - psf->pipeoffset += total ; - - return total / bytes ; -} /* psf_fread */ - -/* USE_WINDOWS_API */ sf_count_t -psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf) -{ sf_count_t total = 0 ; - ssize_t count ; - DWORD dwNumberOfBytesWritten ; - - if (psf->virtual_io) - return psf->vio.write (ptr, bytes * items, psf->vio_user_data) / bytes ; - - items *= bytes ; - - /* Do this check after the multiplication above. */ - if (items <= 0) - return 0 ; - - while (items > 0) - { /* Break the writes down to a sensible size. */ - count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : (ssize_t) items ; - - if (WriteFile (psf->file.handle, ((const char*) ptr) + total, count, &dwNumberOfBytesWritten, 0) == 0) - { psf_log_syserr (psf, GetLastError ()) ; - break ; - } - else - count = dwNumberOfBytesWritten ; - - if (count == 0) - break ; - - total += count ; - items -= count ; - } ; - - if (psf->is_pipe) - psf->pipeoffset += total ; - - return total / bytes ; -} /* psf_fwrite */ - -/* USE_WINDOWS_API */ sf_count_t -psf_ftell (SF_PRIVATE *psf) -{ sf_count_t pos ; - LARGE_INTEGER liDistanceToMove, liNewFilePointer ; - BOOL fResult ; - DWORD dwError ; - - if (psf->virtual_io) - return psf->vio.tell (psf->vio_user_data) ; - - if (psf->is_pipe) - return psf->pipeoffset ; - - liDistanceToMove.QuadPart = 0 ; - - fResult = SetFilePointerEx (psf->file.handle, liDistanceToMove, &liNewFilePointer, FILE_CURRENT) ; - - if (fResult == FALSE) - dwError = GetLastError () ; - else - dwError = NO_ERROR ; - - if (dwError != NO_ERROR) - { psf_log_syserr (psf, dwError) ; - return -1 ; - } ; - - pos = liNewFilePointer.QuadPart ; - - return pos - psf->fileoffset ; -} /* psf_ftell */ - -/* USE_WINDOWS_API */ static int -psf_close_handle (HANDLE handle) -{ if (handle == INVALID_HANDLE_VALUE) - return 0 ; - - if (CloseHandle (handle) == 0) - return -1 ; - - return 0 ; -} /* psf_close_handle */ - -/* USE_WINDOWS_API */ sf_count_t -psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf) -{ sf_count_t k = 0 ; - sf_count_t count ; - DWORD dwNumberOfBytesRead ; - - while (k < bufsize - 1) - { if (ReadFile (psf->file.handle, &(buffer [k]), 1, &dwNumberOfBytesRead, 0) == 0) - { psf_log_syserr (psf, GetLastError ()) ; - break ; - } - else - { count = dwNumberOfBytesRead ; - /* note that we only check for '\n' not other line endings such as CRLF */ - if (count == 0 || buffer [k++] == '\n') - break ; - } ; - } ; - - buffer [k] = 0 ; - - return k ; -} /* psf_fgets */ - -/* USE_WINDOWS_API */ int -psf_is_pipe (SF_PRIVATE *psf) -{ - if (psf->virtual_io) - return SF_FALSE ; - - if (GetFileType (psf->file.handle) == FILE_TYPE_DISK) - return SF_FALSE ; - - /* Default to maximum safety. */ - return SF_TRUE ; -} /* psf_is_pipe */ - -/* USE_WINDOWS_API */ sf_count_t -psf_get_filelen_handle (HANDLE handle) -{ sf_count_t filelen ; - LARGE_INTEGER liFileSize ; - BOOL fResult ; - DWORD dwError = NO_ERROR ; - - fResult = GetFileSizeEx (handle, &liFileSize) ; - - if (fResult == FALSE) - dwError = GetLastError () ; - - if (dwError != NO_ERROR) - return (sf_count_t) -1 ; - - filelen = liFileSize.QuadPart ; - - return filelen ; -} /* psf_get_filelen_handle */ - -/* USE_WINDOWS_API */ void -psf_fsync (SF_PRIVATE *psf) -{ FlushFileBuffers (psf->file.handle) ; -} /* psf_fsync */ - - -/* USE_WINDOWS_API */ int -psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) -{ int retval = 0 ; - LARGE_INTEGER liDistanceToMove ; - BOOL fResult ; - DWORD dwError = NO_ERROR ; - - /* This implementation trashes the current file position. - ** should it save and restore it? what if the current position is past - ** the new end of file? - */ - - /* Returns 0 on success, non-zero on failure. */ - if (len < 0) - return 1 ; - - liDistanceToMove.QuadPart = (sf_count_t) len ; - - fResult = SetFilePointerEx (psf->file.handle, liDistanceToMove, NULL, FILE_BEGIN) ; - - if (fResult == FALSE) - dwError = GetLastError () ; - - if (dwError != NO_ERROR) - { retval = -1 ; - psf_log_syserr (psf, dwError) ; - } - else - { /* Note: when SetEndOfFile is used to extend a file, the contents of the - ** new portion of the file is undefined. This is unlike chsize(), - ** which guarantees that the new portion of the file will be zeroed. - ** Not sure if this is important or not. - */ - if (SetEndOfFile (psf->file.handle) == 0) - { retval = -1 ; - psf_log_syserr (psf, GetLastError ()) ; - } ; - } ; - - return retval ; -} /* psf_ftruncate */ - -#endif - diff --git a/Engine/lib/libsndfile/src/flac.c b/Engine/lib/libsndfile/src/flac.c deleted file mode 100644 index 073ce553d..000000000 --- a/Engine/lib/libsndfile/src/flac.c +++ /dev/null @@ -1,1463 +0,0 @@ -/* -** Copyright (C) 2004-2017 Erik de Castro Lopo -** Copyright (C) 2004 Tobias Gehrig -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "common.h" - -#if HAVE_EXTERNAL_XIPH_LIBS - -#include -#include -#include - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -#define FLAC_DEFAULT_COMPRESSION_LEVEL 5 - -#define ENC_BUFFER_SIZE 8192 - -/* -** READ_LOOP_MAX_LEN is the maximum 'len' that will be passed to -** flac_read_loop(). This is somewhat arbitrary, but must be less -** than (UINT_MAX - FLAC__MAX_CHANNELS * FLAC__MAX_BLOCK_SIZE) to -** avoid overflows, and must also be a multiple of the number of -** channels (which is between 1 and 8.) -*/ -#define READ_LOOP_MAX_LEN (0x10000 * 3 * 5 * 7) - -typedef enum -{ PFLAC_PCM_SHORT = 50, - PFLAC_PCM_INT = 51, - PFLAC_PCM_FLOAT = 52, - PFLAC_PCM_DOUBLE = 53 -} PFLAC_PCM ; - -typedef struct -{ - FLAC__StreamDecoder *fsd ; - FLAC__StreamEncoder *fse ; - - PFLAC_PCM pcmtype ; - void* ptr ; - unsigned pos, len, remain ; - - FLAC__StreamMetadata *metadata ; - - const int32_t * const * wbuffer ; - int32_t * rbuffer [FLAC__MAX_CHANNELS] ; - - int32_t* encbuffer ; - unsigned bufferpos ; - - const FLAC__Frame *frame ; - - unsigned compression ; - -} FLAC_PRIVATE ; - -typedef struct -{ const char *tag ; - int type ; -} FLAC_TAG ; - -static sf_count_t flac_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; -static int flac_byterate (SF_PRIVATE *psf) ; -static int flac_close (SF_PRIVATE *psf) ; - -static int flac_enc_init (SF_PRIVATE *psf) ; -static int flac_read_header (SF_PRIVATE *psf) ; - -static sf_count_t flac_read_flac2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t flac_read_flac2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t flac_read_flac2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t flac_read_flac2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t flac_write_s2flac (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t flac_write_i2flac (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t flac_write_f2flac (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t flac_write_d2flac (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static void f2flac8_array (const float *src, int32_t *dest, int count, int normalize) ; -static void f2flac16_array (const float *src, int32_t *dest, int count, int normalize) ; -static void f2flac24_array (const float *src, int32_t *dest, int count, int normalize) ; -static void f2flac8_clip_array (const float *src, int32_t *dest, int count, int normalize) ; -static void f2flac16_clip_array (const float *src, int32_t *dest, int count, int normalize) ; -static void f2flac24_clip_array (const float *src, int32_t *dest, int count, int normalize) ; -static void d2flac8_array (const double *src, int32_t *dest, int count, int normalize) ; -static void d2flac16_array (const double *src, int32_t *dest, int count, int normalize) ; -static void d2flac24_array (const double *src, int32_t *dest, int count, int normalize) ; -static void d2flac8_clip_array (const double *src, int32_t *dest, int count, int normalize) ; -static void d2flac16_clip_array (const double *src, int32_t *dest, int count, int normalize) ; -static void d2flac24_clip_array (const double *src, int32_t *dest, int count, int normalize) ; - -static int flac_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; - -/* Decoder Callbacks */ -static FLAC__StreamDecoderReadStatus sf_flac_read_callback (const FLAC__StreamDecoder *decoder, FLAC__byte buffer [], size_t *bytes, void *client_data) ; -static FLAC__StreamDecoderSeekStatus sf_flac_seek_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) ; -static FLAC__StreamDecoderTellStatus sf_flac_tell_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ; -static FLAC__StreamDecoderLengthStatus sf_flac_length_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) ; -static FLAC__bool sf_flac_eof_callback (const FLAC__StreamDecoder *decoder, void *client_data) ; -static FLAC__StreamDecoderWriteStatus sf_flac_write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const int32_t * const buffer [], void *client_data) ; -static void sf_flac_meta_callback (const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) ; -static void sf_flac_error_callback (const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) ; - -/* Encoder Callbacks */ -static FLAC__StreamEncoderSeekStatus sf_flac_enc_seek_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) ; -static FLAC__StreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ; -static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__StreamEncoder *encoder, const FLAC__byte buffer [], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) ; - -static void -s2flac8_array (const short *src, int32_t *dest, int count) -{ for (int i = 0 ; i < count ; i++) - dest [i] = src [i] >> 8 ; -} /* s2flac8_array */ - -static void -s2flac16_array (const short *src, int32_t *dest, int count) -{ for (int i = 0 ; i < count ; i++) - dest [i] = src [i] ; -} /* s2flac16_array */ - -static void -s2flac24_array (const short *src, int32_t *dest, int count) -{ for (int i = 0 ; i < count ; i++) - dest [i] = src [i] << 8 ; -} /* s2flac24_array */ - -static void -i2flac8_array (const int *src, int32_t *dest, int count) -{ for (int i = 0 ; i < count ; i++) - dest [i] = src [i] >> 24 ; -} /* i2flac8_array */ - -static void -i2flac16_array (const int *src, int32_t *dest, int count) -{ - for (int i = 0 ; i < count ; i++) - dest [i] = src [i] >> 16 ; -} /* i2flac16_array */ - -static void -i2flac24_array (const int *src, int32_t *dest, int count) -{ for (int i = 0 ; i < count ; i++) - dest [i] = src [i] >> 8 ; -} /* i2flac24_array */ - -static sf_count_t -flac_buffer_copy (SF_PRIVATE *psf) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - const FLAC__Frame *frame = pflac->frame ; - const int32_t* const *buffer = pflac->wbuffer ; - unsigned i = 0, j, offset, channels, len ; - - if (psf->sf.channels != (int) frame->header.channels) - { psf_log_printf (psf, "Error: FLAC frame changed from %d to %d channels\n" - "Nothing to do but to error out.\n" , - psf->sf.channels, frame->header.channels) ; - psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ; - return 0 ; - } ; - - /* - ** frame->header.blocksize is variable and we're using a constant blocksize - ** of FLAC__MAX_BLOCK_SIZE. - ** Check our assumptions here. - */ - if (frame->header.blocksize > FLAC__MAX_BLOCK_SIZE) - { psf_log_printf (psf, "Ooops : frame->header.blocksize (%d) > FLAC__MAX_BLOCK_SIZE (%d)\n", __func__, __LINE__, frame->header.blocksize, FLAC__MAX_BLOCK_SIZE) ; - psf->error = SFE_INTERNAL ; - return 0 ; - } ; - - if (frame->header.channels > FLAC__MAX_CHANNELS) - psf_log_printf (psf, "Ooops : frame->header.channels (%d) > FLAC__MAX_BLOCK_SIZE (%d)\n", __func__, __LINE__, frame->header.channels, FLAC__MAX_CHANNELS) ; - - channels = SF_MIN (frame->header.channels, FLAC__MAX_CHANNELS) ; - - if (pflac->ptr == NULL) - { /* - ** This pointer is reset to NULL each time the current frame has been - ** decoded. Somehow its used during encoding and decoding. - */ - for (i = 0 ; i < channels ; i++) - { - if (pflac->rbuffer [i] == NULL) - pflac->rbuffer [i] = calloc (FLAC__MAX_BLOCK_SIZE, sizeof (int32_t)) ; - - memcpy (pflac->rbuffer [i], buffer [i], frame->header.blocksize * sizeof (int32_t)) ; - } ; - pflac->wbuffer = (const int32_t* const*) pflac->rbuffer ; - - return 0 ; - } ; - - len = SF_MIN (pflac->len, frame->header.blocksize) ; - - if (pflac->remain % channels != 0) - { psf_log_printf (psf, "Error: pflac->remain %u channels %u\n", pflac->remain, channels) ; - return 0 ; - } ; - - switch (pflac->pcmtype) - { case PFLAC_PCM_SHORT : - { short *retpcm = (short*) pflac->ptr ; - int shift = 16 - frame->header.bits_per_sample ; - if (shift < 0) - { shift = abs (shift) ; - for (i = 0 ; i < len && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * channels ; - - if (pflac->bufferpos >= frame->header.blocksize) - break ; - - if (offset + channels > pflac->len) - break ; - - for (j = 0 ; j < channels ; j++) - retpcm [offset + j] = buffer [j][pflac->bufferpos] >> shift ; - pflac->remain -= channels ; - pflac->bufferpos ++ ; - } - } - else - { for (i = 0 ; i < len && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * channels ; - - if (pflac->bufferpos >= frame->header.blocksize) - break ; - - if (offset + channels > pflac->len) - break ; - - for (j = 0 ; j < channels ; j++) - retpcm [offset + j] = ((uint16_t) buffer [j][pflac->bufferpos]) << shift ; - - pflac->remain -= channels ; - pflac->bufferpos ++ ; - } ; - } ; - } ; - break ; - - case PFLAC_PCM_INT : - { int *retpcm = (int*) pflac->ptr ; - int shift = 32 - frame->header.bits_per_sample ; - for (i = 0 ; i < len && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * channels ; - - if (pflac->bufferpos >= frame->header.blocksize) - break ; - - if (offset + channels > pflac->len) - break ; - - for (j = 0 ; j < channels ; j++) - retpcm [offset + j] = ((uint32_t) buffer [j][pflac->bufferpos]) << shift ; - pflac->remain -= channels ; - pflac->bufferpos++ ; - } ; - } ; - break ; - - case PFLAC_PCM_FLOAT : - { float *retpcm = (float*) pflac->ptr ; - float norm = (psf->norm_float == SF_TRUE) ? 1.0 / (1 << (frame->header.bits_per_sample - 1)) : 1.0 ; - - for (i = 0 ; i < len && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * channels ; - - if (pflac->bufferpos >= frame->header.blocksize) - break ; - - if (offset + channels > pflac->len) - break ; - - for (j = 0 ; j < channels ; j++) - retpcm [offset + j] = buffer [j][pflac->bufferpos] * norm ; - pflac->remain -= channels ; - pflac->bufferpos++ ; - } ; - } ; - break ; - - case PFLAC_PCM_DOUBLE : - { double *retpcm = (double*) pflac->ptr ; - double norm = (psf->norm_double == SF_TRUE) ? 1.0 / (1 << (frame->header.bits_per_sample - 1)) : 1.0 ; - - for (i = 0 ; i < len && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * channels ; - - if (pflac->bufferpos >= frame->header.blocksize) - break ; - - if (offset + channels > pflac->len) - break ; - - for (j = 0 ; j < channels ; j++) - retpcm [offset + j] = buffer [j][pflac->bufferpos] * norm ; - pflac->remain -= channels ; - pflac->bufferpos++ ; - } ; - } ; - break ; - - default : - return 0 ; - } ; - - offset = i * channels ; - pflac->pos += i * channels ; - - return offset ; -} /* flac_buffer_copy */ - - -static FLAC__StreamDecoderReadStatus -sf_flac_read_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__byte buffer [], size_t *bytes, void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - - *bytes = psf_fread (buffer, 1, *bytes, psf) ; - if (*bytes > 0 && psf->error == 0) - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE ; - - return FLAC__STREAM_DECODER_READ_STATUS_ABORT ; -} /* sf_flac_read_callback */ - -static FLAC__StreamDecoderSeekStatus -sf_flac_seek_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 absolute_byte_offset, void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - - psf_fseek (psf, absolute_byte_offset, SEEK_SET) ; - if (psf->error) - return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR ; - - return FLAC__STREAM_DECODER_SEEK_STATUS_OK ; -} /* sf_flac_seek_callback */ - -static FLAC__StreamDecoderTellStatus -sf_flac_tell_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 *absolute_byte_offset, void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - - *absolute_byte_offset = psf_ftell (psf) ; - if (psf->error) - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR ; - - return FLAC__STREAM_DECODER_TELL_STATUS_OK ; -} /* sf_flac_tell_callback */ - -static FLAC__StreamDecoderLengthStatus -sf_flac_length_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__uint64 *stream_length, void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - - if ((*stream_length = psf->filelength) == 0) - return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR ; - - return FLAC__STREAM_DECODER_LENGTH_STATUS_OK ; -} /* sf_flac_length_callback */ - -static FLAC__bool -sf_flac_eof_callback (const FLAC__StreamDecoder *UNUSED (decoder), void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - - if (psf_ftell (psf) == psf->filelength) - return SF_TRUE ; - - return SF_FALSE ; -} /* sf_flac_eof_callback */ - -static FLAC__StreamDecoderWriteStatus -sf_flac_write_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const int32_t * const buffer [], void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - - pflac->frame = frame ; - pflac->bufferpos = 0 ; - - pflac->wbuffer = buffer ; - - flac_buffer_copy (psf) ; - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE ; -} /* sf_flac_write_callback */ - -static void -sf_flac_meta_get_vorbiscomments (SF_PRIVATE *psf, const FLAC__StreamMetadata *metadata) -{ static FLAC_TAG tags [] = - { { "title", SF_STR_TITLE }, - { "copyright", SF_STR_COPYRIGHT }, - { "software", SF_STR_SOFTWARE }, - { "artist", SF_STR_ARTIST }, - { "comment", SF_STR_COMMENT }, - { "date", SF_STR_DATE }, - { "album", SF_STR_ALBUM }, - { "license", SF_STR_LICENSE }, - { "tracknumber", SF_STR_TRACKNUMBER }, - { "genre", SF_STR_GENRE } - } ; - - const char *value, *cptr ; - int k, tag_num ; - - for (k = 0 ; k < ARRAY_LEN (tags) ; k++) - { tag_num = FLAC__metadata_object_vorbiscomment_find_entry_from (metadata, 0, tags [k].tag) ; - - if (tag_num < 0) - continue ; - - value = (const char*) metadata->data.vorbis_comment.comments [tag_num].entry ; - if ((cptr = strchr (value, '=')) != NULL) - value = cptr + 1 ; - - psf_log_printf (psf, " %-12s : %s\n", tags [k].tag, value) ; - psf_store_string (psf, tags [k].type, value) ; - } ; - - return ; -} /* sf_flac_meta_get_vorbiscomments */ - -static void -sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__StreamMetadata *metadata, void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - int bitwidth = 0 ; - - switch (metadata->type) - { case FLAC__METADATA_TYPE_STREAMINFO : - if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels) - { psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n" - "Nothing to do but to error out.\n" , - psf->sf.channels, metadata->data.stream_info.channels) ; - psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ; - return ; - } ; - - if (psf->sf.channels > 0 && psf->sf.samplerate != (int) metadata->data.stream_info.sample_rate) - { psf_log_printf (psf, "Warning: FLAC stream changed sample rates from %d to %d.\n" - "Carrying on as if nothing happened.", - psf->sf.samplerate, metadata->data.stream_info.sample_rate) ; - } ; - psf->sf.channels = metadata->data.stream_info.channels ; - psf->sf.samplerate = metadata->data.stream_info.sample_rate ; - psf->sf.frames = metadata->data.stream_info.total_samples ; - - psf_log_printf (psf, "FLAC Stream Metadata\n Channels : %d\n Sample rate : %d\n", psf->sf.channels, psf->sf.samplerate) ; - - if (psf->sf.frames == 0) - { psf_log_printf (psf, " Frames : 0 (bumping to SF_COUNT_MAX)\n") ; - psf->sf.frames = SF_COUNT_MAX ; - } - else - psf_log_printf (psf, " Frames : %D\n", psf->sf.frames) ; - - switch (metadata->data.stream_info.bits_per_sample) - { case 8 : - psf->sf.format |= SF_FORMAT_PCM_S8 ; - bitwidth = 8 ; - break ; - case 16 : - psf->sf.format |= SF_FORMAT_PCM_16 ; - bitwidth = 16 ; - break ; - case 24 : - psf->sf.format |= SF_FORMAT_PCM_24 ; - bitwidth = 24 ; - break ; - default : - psf_log_printf (psf, "sf_flac_meta_callback : bits_per_sample %d not yet implemented.\n", metadata->data.stream_info.bits_per_sample) ; - break ; - } ; - - if (bitwidth > 0) - psf_log_printf (psf, " Bit width : %d\n", bitwidth) ; - break ; - - case FLAC__METADATA_TYPE_VORBIS_COMMENT : - psf_log_printf (psf, "Vorbis Comment Metadata\n") ; - sf_flac_meta_get_vorbiscomments (psf, metadata) ; - break ; - - case FLAC__METADATA_TYPE_PADDING : - psf_log_printf (psf, "Padding Metadata\n") ; - break ; - - case FLAC__METADATA_TYPE_APPLICATION : - psf_log_printf (psf, "Application Metadata\n") ; - break ; - - case FLAC__METADATA_TYPE_SEEKTABLE : - psf_log_printf (psf, "Seektable Metadata\n") ; - break ; - - case FLAC__METADATA_TYPE_CUESHEET : - psf_log_printf (psf, "Cuesheet Metadata\n") ; - break ; - - case FLAC__METADATA_TYPE_PICTURE : - psf_log_printf (psf, "Picture Metadata\n") ; - break ; - - case FLAC__METADATA_TYPE_UNDEFINED : - psf_log_printf (psf, "Undefined Metadata\n") ; - break ; - - default : - psf_log_printf (psf, "sf_flac_meta_callback : metadata-type %d not yet implemented.\n", metadata->type) ; - break ; - } ; - - return ; -} /* sf_flac_meta_callback */ - -static void -sf_flac_error_callback (const FLAC__StreamDecoder * UNUSED (decoder), FLAC__StreamDecoderErrorStatus status, void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - - psf_log_printf (psf, "ERROR : %s\n", FLAC__StreamDecoderErrorStatusString [status]) ; - - switch (status) - { case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC : - psf->error = SFE_FLAC_LOST_SYNC ; - break ; - case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER : - psf->error = SFE_FLAC_BAD_HEADER ; - break ; - default : - psf->error = SFE_FLAC_UNKOWN_ERROR ; - break ; - } ; - - return ; -} /* sf_flac_error_callback */ - -static FLAC__StreamEncoderSeekStatus -sf_flac_enc_seek_callback (const FLAC__StreamEncoder * UNUSED (encoder), FLAC__uint64 absolute_byte_offset, void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - - psf_fseek (psf, absolute_byte_offset, SEEK_SET) ; - if (psf->error) - return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR ; - - return FLAC__STREAM_ENCODER_SEEK_STATUS_OK ; -} /* sf_flac_enc_seek_callback */ - -static FLAC__StreamEncoderTellStatus -sf_flac_enc_tell_callback (const FLAC__StreamEncoder *UNUSED (encoder), FLAC__uint64 *absolute_byte_offset, void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - - *absolute_byte_offset = psf_ftell (psf) ; - if (psf->error) - return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR ; - - return FLAC__STREAM_ENCODER_TELL_STATUS_OK ; -} /* sf_flac_enc_tell_callback */ - -static FLAC__StreamEncoderWriteStatus -sf_flac_enc_write_callback (const FLAC__StreamEncoder * UNUSED (encoder), const FLAC__byte buffer [], size_t bytes, unsigned UNUSED (samples), unsigned UNUSED (current_frame), void *client_data) -{ SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - - if (psf_fwrite (buffer, 1, bytes, psf) == (sf_count_t) bytes && psf->error == 0) - return FLAC__STREAM_ENCODER_WRITE_STATUS_OK ; - - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR ; -} /* sf_flac_enc_write_callback */ - -static void -flac_write_strings (SF_PRIVATE *psf, FLAC_PRIVATE* pflac) -{ FLAC__StreamMetadata_VorbisComment_Entry entry ; - int k, string_count = 0 ; - - for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { if (psf->strings.data [k].type != 0) - string_count ++ ; - } ; - - if (string_count == 0) - return ; - - if (pflac->metadata == NULL && (pflac->metadata = FLAC__metadata_object_new (FLAC__METADATA_TYPE_VORBIS_COMMENT)) == NULL) - { psf_log_printf (psf, "FLAC__metadata_object_new returned NULL\n") ; - return ; - } ; - - for (k = 0 ; k < SF_MAX_STRINGS && psf->strings.data [k].type != 0 ; k++) - { const char * key, * value ; - - switch (psf->strings.data [k].type) - { case SF_STR_SOFTWARE : - key = "software" ; - break ; - case SF_STR_TITLE : - key = "title" ; - break ; - case SF_STR_COPYRIGHT : - key = "copyright" ; - break ; - case SF_STR_ARTIST : - key = "artist" ; - break ; - case SF_STR_COMMENT : - key = "comment" ; - break ; - case SF_STR_DATE : - key = "date" ; - break ; - case SF_STR_ALBUM : - key = "album" ; - break ; - case SF_STR_LICENSE : - key = "license" ; - break ; - case SF_STR_TRACKNUMBER : - key = "tracknumber" ; - break ; - case SF_STR_GENRE : - key = "genre" ; - break ; - default : - continue ; - } ; - - value = psf->strings.storage + psf->strings.data [k].offset ; - - FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair (&entry, key, value) ; - FLAC__metadata_object_vorbiscomment_append_comment (pflac->metadata, entry, /* copy */ SF_FALSE) ; - } ; - - if (! FLAC__stream_encoder_set_metadata (pflac->fse, &pflac->metadata, 1)) - { printf ("%s %d : fail\n", __func__, __LINE__) ; - return ; - } ; - - return ; -} /* flac_write_strings */ - -static int -flac_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - int err ; - - flac_write_strings (psf, pflac) ; - - if ((err = FLAC__stream_encoder_init_stream (pflac->fse, sf_flac_enc_write_callback, sf_flac_enc_seek_callback, sf_flac_enc_tell_callback, NULL, psf)) != FLAC__STREAM_DECODER_INIT_STATUS_OK) - { psf_log_printf (psf, "Error : FLAC encoder init returned error : %s\n", FLAC__StreamEncoderInitStatusString [err]) ; - return SFE_FLAC_INIT_DECODER ; - } ; - - if (psf->error == 0) - psf->dataoffset = psf_ftell (psf) ; - pflac->encbuffer = calloc (ENC_BUFFER_SIZE, sizeof (int32_t)) ; - - /* can only call init_stream once */ - psf->write_header = NULL ; - - return psf->error ; -} /* flac_write_header */ - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -flac_open (SF_PRIVATE *psf) -{ int subformat ; - int error = 0 ; - - FLAC_PRIVATE* pflac = calloc (1, sizeof (FLAC_PRIVATE)) ; - psf->codec_data = pflac ; - - /* Set the default value here. Over-ridden later if necessary. */ - pflac->compression = FLAC_DEFAULT_COMPRESSION_LEVEL ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode == SFM_READ) - { if ((error = flac_read_header (psf))) - return error ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE) - { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_FLAC) - return SFE_BAD_OPEN_FORMAT ; - - psf->endian = SF_ENDIAN_BIG ; - psf->sf.seekable = 0 ; - - psf->strings.flags = SF_STR_ALLOW_START ; - - if ((error = flac_enc_init (psf))) - return error ; - - /* In an ideal world we would write the header at this point. Unfortunately - ** that would prevent string metadata being added so we have to hold off. - */ - - psf->write_header = flac_write_header ; - } ; - - psf->datalength = psf->filelength ; - psf->dataoffset = 0 ; - - psf->container_close = flac_close ; - psf->seek = flac_seek ; - psf->byterate = flac_byterate ; - - psf->command = flac_command ; - - switch (subformat) - { case SF_FORMAT_PCM_S8 : /* 8-bit FLAC. */ - case SF_FORMAT_PCM_16 : /* 16-bit FLAC. */ - case SF_FORMAT_PCM_24 : /* 24-bit FLAC. */ - error = flac_init (psf) ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - return error ; -} /* flac_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -flac_close (SF_PRIVATE *psf) -{ FLAC_PRIVATE* pflac ; - int k ; - - if ((pflac = (FLAC_PRIVATE*) psf->codec_data) == NULL) - return 0 ; - - if (pflac->metadata != NULL) - FLAC__metadata_object_delete (pflac->metadata) ; - - if (psf->file.mode == SFM_WRITE) - { FLAC__stream_encoder_finish (pflac->fse) ; - FLAC__stream_encoder_delete (pflac->fse) ; - free (pflac->encbuffer) ; - } ; - - if (psf->file.mode == SFM_READ) - { FLAC__stream_decoder_finish (pflac->fsd) ; - FLAC__stream_decoder_delete (pflac->fsd) ; - } ; - - for (k = 0 ; k < ARRAY_LEN (pflac->rbuffer) ; k++) - free (pflac->rbuffer [k]) ; - - free (pflac) ; - psf->codec_data = NULL ; - - return 0 ; -} /* flac_close */ - -static int -flac_enc_init (SF_PRIVATE *psf) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - unsigned bps ; - - /* To cite the flac FAQ at - ** http://flac.sourceforge.net/faq.html#general__samples - ** "FLAC supports linear sample rates from 1Hz - 655350Hz in 1Hz - ** increments." - */ - if (psf->sf.samplerate < 1 || psf->sf.samplerate > 655350) - { psf_log_printf (psf, "flac sample rate out of range.\n", psf->sf.samplerate) ; - return SFE_FLAC_BAD_SAMPLE_RATE ; - } ; - - psf_fseek (psf, 0, SEEK_SET) ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - bps = 8 ; - break ; - case SF_FORMAT_PCM_16 : - bps = 16 ; - break ; - case SF_FORMAT_PCM_24 : - bps = 24 ; - break ; - - default : - bps = 0 ; - break ; - } ; - - if (pflac->fse) - FLAC__stream_encoder_delete (pflac->fse) ; - if ((pflac->fse = FLAC__stream_encoder_new ()) == NULL) - return SFE_FLAC_NEW_DECODER ; - - if (! FLAC__stream_encoder_set_channels (pflac->fse, psf->sf.channels)) - { psf_log_printf (psf, "FLAC__stream_encoder_set_channels (%d) return false.\n", psf->sf.channels) ; - return SFE_FLAC_INIT_DECODER ; - } ; - - if (! FLAC__stream_encoder_set_sample_rate (pflac->fse, psf->sf.samplerate)) - { psf_log_printf (psf, "FLAC__stream_encoder_set_sample_rate (%d) returned false.\n", psf->sf.samplerate) ; - return SFE_FLAC_BAD_SAMPLE_RATE ; - } ; - - if (! FLAC__stream_encoder_set_bits_per_sample (pflac->fse, bps)) - { psf_log_printf (psf, "FLAC__stream_encoder_set_bits_per_sample (%d) return false.\n", bps) ; - return SFE_FLAC_INIT_DECODER ; - } ; - - if (! FLAC__stream_encoder_set_compression_level (pflac->fse, pflac->compression)) - { psf_log_printf (psf, "FLAC__stream_encoder_set_compression_level (%d) return false.\n", pflac->compression) ; - return SFE_FLAC_INIT_DECODER ; - } ; - - return 0 ; -} /* flac_enc_init */ - -static int -flac_read_header (SF_PRIVATE *psf) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - - psf_fseek (psf, 0, SEEK_SET) ; - if (pflac->fsd) - FLAC__stream_decoder_delete (pflac->fsd) ; - if ((pflac->fsd = FLAC__stream_decoder_new ()) == NULL) - return SFE_FLAC_NEW_DECODER ; - - FLAC__stream_decoder_set_metadata_respond_all (pflac->fsd) ; - - if (FLAC__stream_decoder_init_stream (pflac->fsd, sf_flac_read_callback, sf_flac_seek_callback, sf_flac_tell_callback, sf_flac_length_callback, sf_flac_eof_callback, sf_flac_write_callback, sf_flac_meta_callback, sf_flac_error_callback, psf) != FLAC__STREAM_DECODER_INIT_STATUS_OK) - return SFE_FLAC_INIT_DECODER ; - - FLAC__stream_decoder_process_until_end_of_metadata (pflac->fsd) ; - - psf_log_printf (psf, "End\n") ; - - if (psf->error != 0) - FLAC__stream_decoder_delete (pflac->fsd) ; - else - { FLAC__uint64 position ; - - FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ; - psf->dataoffset = position ; - } ; - - return psf->error ; -} /* flac_read_header */ - -static int -flac_command (SF_PRIVATE * psf, int command, void * data, int datasize) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - double quality ; - - switch (command) - { case SFC_SET_COMPRESSION_LEVEL : - if (data == NULL || datasize != sizeof (double)) - return SF_FALSE ; - - if (psf->have_written) - return SF_FALSE ; - - /* FLAC compression level is in the range [0, 8] while libsndfile takes - ** values in the range [0.0, 1.0]. Massage the libsndfile value here. - */ - quality = (*((double *) data)) * 8.0 ; - /* Clip range. */ - pflac->compression = psf_lrint (SF_MAX (0.0, SF_MIN (8.0, quality))) ; - - psf_log_printf (psf, "%s : Setting SFC_SET_COMPRESSION_LEVEL to %u.\n", __func__, pflac->compression) ; - - if (flac_enc_init (psf)) - return SF_FALSE ; - - return SF_TRUE ; - - default : - return SF_FALSE ; - } ; - - return SF_FALSE ; -} /* flac_command */ - -int -flac_init (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode == SFM_READ) - { psf->read_short = flac_read_flac2s ; - psf->read_int = flac_read_flac2i ; - psf->read_float = flac_read_flac2f ; - psf->read_double = flac_read_flac2d ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->write_short = flac_write_s2flac ; - psf->write_int = flac_write_i2flac ; - psf->write_float = flac_write_f2flac ; - psf->write_double = flac_write_d2flac ; - } ; - - if (psf->filelength > psf->dataoffset) - psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset : psf->filelength - psf->dataoffset ; - else - psf->datalength = 0 ; - - return 0 ; -} /* flac_init */ - -static unsigned -flac_read_loop (SF_PRIVATE *psf, unsigned len) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - FLAC__StreamDecoderState state ; - - pflac->pos = 0 ; - pflac->len = len ; - pflac->remain = len ; - - state = FLAC__stream_decoder_get_state (pflac->fsd) ; - if (state > FLAC__STREAM_DECODER_END_OF_STREAM) - { psf_log_printf (psf, "FLAC__stream_decoder_get_state returned %s\n", FLAC__StreamDecoderStateString [state]) ; - /* Current frame is busted, so NULL the pointer. */ - pflac->frame = NULL ; - } ; - - /* First copy data that has already been decoded and buffered. */ - if (pflac->frame != NULL && pflac->bufferpos < pflac->frame->header.blocksize) - flac_buffer_copy (psf) ; - - /* Decode some more. */ - while (pflac->pos < pflac->len) - { if (FLAC__stream_decoder_process_single (pflac->fsd) == 0) - { psf_log_printf (psf, "FLAC__stream_decoder_process_single returned false\n") ; - /* Current frame is busted, so NULL the pointer. */ - pflac->frame = NULL ; - break ; - } ; - state = FLAC__stream_decoder_get_state (pflac->fsd) ; - if (state >= FLAC__STREAM_DECODER_END_OF_STREAM) - { psf_log_printf (psf, "FLAC__stream_decoder_get_state returned %s\n", FLAC__StreamDecoderStateString [state]) ; - /* Current frame is busted, so NULL the pointer. */ - pflac->frame = NULL ; - break ; - } ; - } ; - - pflac->ptr = NULL ; - - return pflac->pos ; -} /* flac_read_loop */ - -static sf_count_t -flac_read_flac2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0, current ; - unsigned readlen ; - - pflac->pcmtype = PFLAC_PCM_SHORT ; - - while (total < len) - { pflac->ptr = ptr + total ; - readlen = (len - total > READ_LOOP_MAX_LEN) ? READ_LOOP_MAX_LEN : (unsigned) (len - total) ; - current = flac_read_loop (psf, readlen) ; - if (current == 0) - break ; - total += current ; - } ; - - return total ; -} /* flac_read_flac2s */ - -static sf_count_t -flac_read_flac2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0, current ; - unsigned readlen ; - - pflac->pcmtype = PFLAC_PCM_INT ; - - while (total < len) - { pflac->ptr = ptr + total ; - readlen = (len - total > READ_LOOP_MAX_LEN) ? READ_LOOP_MAX_LEN : (unsigned) (len - total) ; - current = flac_read_loop (psf, readlen) ; - if (current == 0) - break ; - total += current ; - } ; - - return total ; -} /* flac_read_flac2i */ - -static sf_count_t -flac_read_flac2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0, current ; - unsigned readlen ; - - pflac->pcmtype = PFLAC_PCM_FLOAT ; - - while (total < len) - { pflac->ptr = ptr + total ; - readlen = (len - total > READ_LOOP_MAX_LEN) ? READ_LOOP_MAX_LEN : (unsigned) (len - total) ; - current = flac_read_loop (psf, readlen) ; - if (current == 0) - break ; - total += current ; - } ; - - return total ; -} /* flac_read_flac2f */ - -static sf_count_t -flac_read_flac2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0, current ; - unsigned readlen ; - - pflac->pcmtype = PFLAC_PCM_DOUBLE ; - - while (total < len) - { pflac->ptr = ptr + total ; - readlen = (len - total > READ_LOOP_MAX_LEN) ? READ_LOOP_MAX_LEN : (unsigned) (len - total) ; - - current = flac_read_loop (psf, readlen) ; - if (current == 0) - break ; - total += current ; - } ; - - return total ; -} /* flac_read_flac2d */ - -static sf_count_t -flac_write_s2flac (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - void (*convert) (const short *, int32_t *, int) ; - int bufferlen, writecount, thiswrite ; - sf_count_t total = 0 ; - int32_t* buffer = pflac->encbuffer ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - convert = s2flac8_array ; - break ; - case SF_FORMAT_PCM_16 : - convert = s2flac16_array ; - break ; - case SF_FORMAT_PCM_24 : - convert = s2flac24_array ; - break ; - default : - return -1 ; - } ; - - bufferlen = ENC_BUFFER_SIZE / (sizeof (int32_t) * psf->sf.channels) ; - bufferlen *= psf->sf.channels ; - - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - convert (ptr + total, buffer, writecount) ; - if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels)) - thiswrite = writecount ; - else - break ; - total += thiswrite ; - if (thiswrite < writecount) - break ; - - len -= thiswrite ; - } ; - - return total ; -} /* flac_write_s2flac */ - -static sf_count_t -flac_write_i2flac (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - void (*convert) (const int *, int32_t *, int) ; - int bufferlen, writecount, thiswrite ; - sf_count_t total = 0 ; - int32_t* buffer = pflac->encbuffer ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - convert = i2flac8_array ; - break ; - case SF_FORMAT_PCM_16 : - convert = i2flac16_array ; - break ; - case SF_FORMAT_PCM_24 : - convert = i2flac24_array ; - break ; - default : - return -1 ; - } ; - - bufferlen = ENC_BUFFER_SIZE / (sizeof (int32_t) * psf->sf.channels) ; - bufferlen *= psf->sf.channels ; - - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - convert (ptr + total, buffer, writecount) ; - if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels)) - thiswrite = writecount ; - else - break ; - total += thiswrite ; - if (thiswrite < writecount) - break ; - - len -= thiswrite ; - } ; - - return total ; -} /* flac_write_i2flac */ - -static sf_count_t -flac_write_f2flac (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - void (*convert) (const float *, int32_t *, int, int) ; - int bufferlen, writecount, thiswrite ; - sf_count_t total = 0 ; - int32_t* buffer = pflac->encbuffer ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - convert = (psf->add_clipping) ? f2flac8_clip_array : f2flac8_array ; - break ; - case SF_FORMAT_PCM_16 : - convert = (psf->add_clipping) ? f2flac16_clip_array : f2flac16_array ; - break ; - case SF_FORMAT_PCM_24 : - convert = (psf->add_clipping) ? f2flac24_clip_array : f2flac24_array ; - break ; - default : - return -1 ; - } ; - - bufferlen = ENC_BUFFER_SIZE / (sizeof (int32_t) * psf->sf.channels) ; - bufferlen *= psf->sf.channels ; - - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - convert (ptr + total, buffer, writecount, psf->norm_float) ; - if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels)) - thiswrite = writecount ; - else - break ; - total += thiswrite ; - if (thiswrite < writecount) - break ; - - len -= thiswrite ; - } ; - - return total ; -} /* flac_write_f2flac */ - -static void -f2flac8_clip_array (const float *src, int32_t *dest, int count, int normalize) -{ float normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7F)) - { dest [i] = 0x7F ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10)) - { dest [i] = -0x80 ; - continue ; - } ; - dest [i] = psf_lrintf (scaled_value) ; - } ; - - return ; -} /* f2flac8_clip_array */ - -static void -f2flac16_clip_array (const float *src, int32_t *dest, int count, int normalize) -{ float normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x1000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFF)) - { dest [i] = 0x7FFF ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x1000)) - { dest [i] = -0x8000 ; - continue ; - } ; - dest [i] = psf_lrintf (scaled_value) ; - } ; -} /* f2flac16_clip_array */ - -static void -f2flac24_clip_array (const float *src, int32_t *dest, int count, int normalize) -{ float normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x100000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFF)) - { dest [i] = 0x7FFFFF ; - continue ; - } ; - - if (scaled_value <= (-8.0 * 0x100000)) - { dest [i] = -0x800000 ; - continue ; - } - dest [i] = psf_lrintf (scaled_value) ; - } ; - - return ; -} /* f2flac24_clip_array */ - -static void -f2flac8_array (const float *src, int32_t *dest, int count, int normalize) -{ float normfact = normalize ? (1.0 * 0x7F) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrintf (src [i] * normfact) ; -} /* f2flac8_array */ - -static void -f2flac16_array (const float *src, int32_t *dest, int count, int normalize) -{ float normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrintf (src [i] * normfact) ; -} /* f2flac16_array */ - -static void -f2flac24_array (const float *src, int32_t *dest, int count, int normalize) -{ float normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrintf (src [i] * normfact) ; -} /* f2flac24_array */ - -static sf_count_t -flac_write_d2flac (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - void (*convert) (const double *, int32_t *, int, int) ; - int bufferlen, writecount, thiswrite ; - sf_count_t total = 0 ; - int32_t* buffer = pflac->encbuffer ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - convert = (psf->add_clipping) ? d2flac8_clip_array : d2flac8_array ; - break ; - case SF_FORMAT_PCM_16 : - convert = (psf->add_clipping) ? d2flac16_clip_array : d2flac16_array ; - break ; - case SF_FORMAT_PCM_24 : - convert = (psf->add_clipping) ? d2flac24_clip_array : d2flac24_array ; - break ; - default : - return -1 ; - } ; - - bufferlen = ENC_BUFFER_SIZE / (sizeof (int32_t) * psf->sf.channels) ; - bufferlen *= psf->sf.channels ; - - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - convert (ptr + total, buffer, writecount, psf->norm_double) ; - if (FLAC__stream_encoder_process_interleaved (pflac->fse, buffer, writecount / psf->sf.channels)) - thiswrite = writecount ; - else - break ; - total += thiswrite ; - if (thiswrite < writecount) - break ; - - len -= thiswrite ; - } ; - - return total ; -} /* flac_write_d2flac */ - -static void -d2flac8_clip_array (const double *src, int32_t *dest, int count, int normalize) -{ double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7F)) - { dest [i] = 0x7F ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10)) - { dest [i] = -0x80 ; - continue ; - } ; - dest [i] = psf_lrint (scaled_value) ; - } ; - - return ; -} /* d2flac8_clip_array */ - -static void -d2flac16_clip_array (const double *src, int32_t *dest, int count, int normalize) -{ double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x1000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFF)) - { dest [i] = 0x7FFF ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x1000)) - { dest [i] = -0x8000 ; - continue ; - } ; - dest [i] = psf_lrint (scaled_value) ; - } ; - - return ; -} /* d2flac16_clip_array */ - -static void -d2flac24_clip_array (const double *src, int32_t *dest, int count, int normalize) -{ double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x100000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFF)) - { dest [i] = 0x7FFFFF ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x100000)) - { dest [i] = -0x800000 ; - continue ; - } ; - dest [i] = psf_lrint (scaled_value) ; - } ; - - return ; -} /* d2flac24_clip_array */ - -static void -d2flac8_array (const double *src, int32_t *dest, int count, int normalize) -{ double normfact = normalize ? (1.0 * 0x7F) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrint (src [i] * normfact) ; -} /* d2flac8_array */ - -static void -d2flac16_array (const double *src, int32_t *dest, int count, int normalize) -{ double normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrint (src [i] * normfact) ; -} /* d2flac16_array */ - -static void -d2flac24_array (const double *src, int32_t *dest, int count, int normalize) -{ double normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - dest [i] = psf_lrint (src [i] * normfact) ; -} /* d2flac24_array */ - -static sf_count_t -flac_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) -{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - - if (pflac == NULL) - return 0 ; - - if (psf->dataoffset < 0) - { psf->error = SFE_BAD_SEEK ; - return ((sf_count_t) -1) ; - } ; - - pflac->frame = NULL ; - - if (psf->file.mode == SFM_READ) - { if (FLAC__stream_decoder_seek_absolute (pflac->fsd, offset)) - return offset ; - - if (offset == psf->sf.frames) - { /* - ** If we've been asked to seek to the very end of the file, libFLAC - ** will return an error. However, we know the length of the file so - ** instead of returning an error, we can return the offset. - */ - return offset ; - } ; - - psf->error = SFE_BAD_SEEK ; - return ((sf_count_t) -1) ; - } ; - - /* Seeking in write mode not yet supported. */ - psf->error = SFE_BAD_SEEK ; - - return ((sf_count_t) -1) ; -} /* flac_seek */ - -static int -flac_byterate (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_READ) - return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; - - return -1 ; -} /* flac_byterate */ - - -#else /* HAVE_EXTERNAL_XIPH_LIBS */ - -int -flac_open (SF_PRIVATE *psf) -{ - psf_log_printf (psf, "This version of libsndfile was compiled without FLAC support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* flac_open */ - -#endif diff --git a/Engine/lib/libsndfile/src/float32.c b/Engine/lib/libsndfile/src/float32.c deleted file mode 100644 index 431e39bb3..000000000 --- a/Engine/lib/libsndfile/src/float32.c +++ /dev/null @@ -1,1017 +0,0 @@ -/* -** Copyright (C) 1999-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if CPU_IS_LITTLE_ENDIAN - #define FLOAT32_READ float32_le_read - #define FLOAT32_WRITE float32_le_write -#elif CPU_IS_BIG_ENDIAN - #define FLOAT32_READ float32_be_read - #define FLOAT32_WRITE float32_be_write -#endif - -/*-------------------------------------------------------------------------------------------- -** Processor floating point capabilities. float32_get_capability () returns one of the -** latter four values. -*/ - -enum -{ FLOAT_UNKNOWN = 0x00, - FLOAT_CAN_RW_LE = 0x12, - FLOAT_CAN_RW_BE = 0x23, - FLOAT_BROKEN_LE = 0x34, - FLOAT_BROKEN_BE = 0x45 -} ; - -/*-------------------------------------------------------------------------------------------- -** Prototypes for private functions. -*/ - -static sf_count_t host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static void float32_peak_update (SF_PRIVATE *psf, const float *buffer, int count, sf_count_t indx) ; - -static sf_count_t replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t replace_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t replace_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static void bf2f_array (float *buffer, int count) ; -static void f2bf_array (float *buffer, int count) ; - -static int float32_get_capability (SF_PRIVATE *psf) ; - -/*-------------------------------------------------------------------------------------------- -** Exported functions. -*/ - -int -float32_init (SF_PRIVATE *psf) -{ static int float_caps ; - - if (psf->sf.channels < 1) - { psf_log_printf (psf, "float32_init : internal error : channels = %d\n", psf->sf.channels) ; - return SFE_INTERNAL ; - } ; - - float_caps = float32_get_capability (psf) ; - - psf->blockwidth = sizeof (float) * psf->sf.channels ; - - if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) - { switch (psf->endian + float_caps) - { case (SF_ENDIAN_BIG + FLOAT_CAN_RW_BE) : - psf->data_endswap = SF_FALSE ; - psf->read_short = host_read_f2s ; - psf->read_int = host_read_f2i ; - psf->read_float = host_read_f ; - psf->read_double = host_read_f2d ; - break ; - - case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_LE) : - psf->data_endswap = SF_FALSE ; - psf->read_short = host_read_f2s ; - psf->read_int = host_read_f2i ; - psf->read_float = host_read_f ; - psf->read_double = host_read_f2d ; - break ; - - case (SF_ENDIAN_BIG + FLOAT_CAN_RW_LE) : - psf->data_endswap = SF_TRUE ; - psf->read_short = host_read_f2s ; - psf->read_int = host_read_f2i ; - psf->read_float = host_read_f ; - psf->read_double = host_read_f2d ; - break ; - - case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_BE) : - psf->data_endswap = SF_TRUE ; - psf->read_short = host_read_f2s ; - psf->read_int = host_read_f2i ; - psf->read_float = host_read_f ; - psf->read_double = host_read_f2d ; - break ; - - /* When the CPU is not IEEE compatible. */ - case (SF_ENDIAN_BIG + FLOAT_BROKEN_LE) : - psf->data_endswap = SF_TRUE ; - psf->read_short = replace_read_f2s ; - psf->read_int = replace_read_f2i ; - psf->read_float = replace_read_f ; - psf->read_double = replace_read_f2d ; - break ; - - case (SF_ENDIAN_LITTLE + FLOAT_BROKEN_LE) : - psf->data_endswap = SF_FALSE ; - psf->read_short = replace_read_f2s ; - psf->read_int = replace_read_f2i ; - psf->read_float = replace_read_f ; - psf->read_double = replace_read_f2d ; - break ; - - case (SF_ENDIAN_BIG + FLOAT_BROKEN_BE) : - psf->data_endswap = SF_FALSE ; - psf->read_short = replace_read_f2s ; - psf->read_int = replace_read_f2i ; - psf->read_float = replace_read_f ; - psf->read_double = replace_read_f2d ; - break ; - - case (SF_ENDIAN_LITTLE + FLOAT_BROKEN_BE) : - psf->data_endswap = SF_TRUE ; - psf->read_short = replace_read_f2s ; - psf->read_int = replace_read_f2i ; - psf->read_float = replace_read_f ; - psf->read_double = replace_read_f2d ; - break ; - - default : break ; - } ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { switch (psf->endian + float_caps) - { case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_LE) : - psf->data_endswap = SF_FALSE ; - psf->write_short = host_write_s2f ; - psf->write_int = host_write_i2f ; - psf->write_float = host_write_f ; - psf->write_double = host_write_d2f ; - break ; - - case (SF_ENDIAN_BIG + FLOAT_CAN_RW_BE) : - psf->data_endswap = SF_FALSE ; - psf->write_short = host_write_s2f ; - psf->write_int = host_write_i2f ; - psf->write_float = host_write_f ; - psf->write_double = host_write_d2f ; - break ; - - case (SF_ENDIAN_BIG + FLOAT_CAN_RW_LE) : - psf->data_endswap = SF_TRUE ; - psf->write_short = host_write_s2f ; - psf->write_int = host_write_i2f ; - psf->write_float = host_write_f ; - psf->write_double = host_write_d2f ; - break ; - - case (SF_ENDIAN_LITTLE + FLOAT_CAN_RW_BE) : - psf->data_endswap = SF_TRUE ; - psf->write_short = host_write_s2f ; - psf->write_int = host_write_i2f ; - psf->write_float = host_write_f ; - psf->write_double = host_write_d2f ; - break ; - - /* When the CPU is not IEEE compatible. */ - case (SF_ENDIAN_BIG + FLOAT_BROKEN_LE) : - psf->data_endswap = SF_TRUE ; - psf->write_short = replace_write_s2f ; - psf->write_int = replace_write_i2f ; - psf->write_float = replace_write_f ; - psf->write_double = replace_write_d2f ; - break ; - - case (SF_ENDIAN_LITTLE + FLOAT_BROKEN_LE) : - psf->data_endswap = SF_FALSE ; - psf->write_short = replace_write_s2f ; - psf->write_int = replace_write_i2f ; - psf->write_float = replace_write_f ; - psf->write_double = replace_write_d2f ; - break ; - - case (SF_ENDIAN_BIG + FLOAT_BROKEN_BE) : - psf->data_endswap = SF_FALSE ; - psf->write_short = replace_write_s2f ; - psf->write_int = replace_write_i2f ; - psf->write_float = replace_write_f ; - psf->write_double = replace_write_d2f ; - break ; - - case (SF_ENDIAN_LITTLE + FLOAT_BROKEN_BE) : - psf->data_endswap = SF_TRUE ; - psf->write_short = replace_write_s2f ; - psf->write_int = replace_write_i2f ; - psf->write_float = replace_write_f ; - psf->write_double = replace_write_d2f ; - break ; - - default : break ; - } ; - } ; - - if (psf->filelength > psf->dataoffset) - { psf->datalength = (psf->dataend > 0) ? psf->dataend - psf->dataoffset : - psf->filelength - psf->dataoffset ; - } - else - psf->datalength = 0 ; - - psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ; - - return 0 ; -} /* float32_init */ - -float -float32_be_read (const unsigned char *cptr) -{ int exponent, mantissa, negative ; - float fvalue ; - - negative = cptr [0] & 0x80 ; - exponent = ((cptr [0] & 0x7F) << 1) | ((cptr [1] & 0x80) ? 1 : 0) ; - mantissa = ((cptr [1] & 0x7F) << 16) | (cptr [2] << 8) | (cptr [3]) ; - - if (! (exponent || mantissa)) - return 0.0 ; - - mantissa |= 0x800000 ; - exponent = exponent ? exponent - 127 : 0 ; - - fvalue = mantissa ? ((float) mantissa) / ((float) 0x800000) : 0.0 ; - - if (negative) - fvalue *= -1 ; - - if (exponent > 0) - fvalue *= pow (2.0, exponent) ; - else if (exponent < 0) - fvalue /= pow (2.0, abs (exponent)) ; - - return fvalue ; -} /* float32_be_read */ - -float -float32_le_read (const unsigned char *cptr) -{ int exponent, mantissa, negative ; - float fvalue ; - - negative = cptr [3] & 0x80 ; - exponent = ((cptr [3] & 0x7F) << 1) | ((cptr [2] & 0x80) ? 1 : 0) ; - mantissa = ((cptr [2] & 0x7F) << 16) | (cptr [1] << 8) | (cptr [0]) ; - - if (! (exponent || mantissa)) - return 0.0 ; - - mantissa |= 0x800000 ; - exponent = exponent ? exponent - 127 : 0 ; - - fvalue = mantissa ? ((float) mantissa) / ((float) 0x800000) : 0.0 ; - - if (negative) - fvalue *= -1 ; - - if (exponent > 0) - fvalue *= pow (2.0, exponent) ; - else if (exponent < 0) - fvalue /= pow (2.0, abs (exponent)) ; - - return fvalue ; -} /* float32_le_read */ - -void -float32_le_write (float in, unsigned char *out) -{ int exponent, mantissa, negative = 0 ; - - memset (out, 0, sizeof (int)) ; - - if (fabs (in) < 1e-30) - return ; - - if (in < 0.0) - { in *= -1.0 ; - negative = 1 ; - } ; - - in = frexp (in, &exponent) ; - - exponent += 126 ; - - in *= (float) 0x1000000 ; - mantissa = (((int) in) & 0x7FFFFF) ; - - if (negative) - out [3] |= 0x80 ; - - if (exponent & 0x01) - out [2] |= 0x80 ; - - out [0] = mantissa & 0xFF ; - out [1] = (mantissa >> 8) & 0xFF ; - out [2] |= (mantissa >> 16) & 0x7F ; - out [3] |= (exponent >> 1) & 0x7F ; - - return ; -} /* float32_le_write */ - -void -float32_be_write (float in, unsigned char *out) -{ int exponent, mantissa, negative = 0 ; - - memset (out, 0, sizeof (int)) ; - - if (fabs (in) < 1e-30) - return ; - - if (in < 0.0) - { in *= -1.0 ; - negative = 1 ; - } ; - - in = frexp (in, &exponent) ; - - exponent += 126 ; - - in *= (float) 0x1000000 ; - mantissa = (((int) in) & 0x7FFFFF) ; - - if (negative) - out [0] |= 0x80 ; - - if (exponent & 0x01) - out [1] |= 0x80 ; - - out [3] = mantissa & 0xFF ; - out [2] = (mantissa >> 8) & 0xFF ; - out [1] |= (mantissa >> 16) & 0x7F ; - out [0] |= (exponent >> 1) & 0x7F ; - - return ; -} /* float32_be_write */ - -/*============================================================================================== -** Private functions. -*/ - -static void -float32_peak_update (SF_PRIVATE *psf, const float *buffer, int count, sf_count_t indx) -{ int chan ; - int k, position ; - float fmaxval ; - - for (chan = 0 ; chan < psf->sf.channels ; chan++) - { fmaxval = fabs (buffer [chan]) ; - position = 0 ; - for (k = chan ; k < count ; k += psf->sf.channels) - if (fmaxval < fabs (buffer [k])) - { fmaxval = fabs (buffer [k]) ; - position = k ; - } ; - - if (fmaxval > psf->peak_info->peaks [chan].value) - { psf->peak_info->peaks [chan].value = fmaxval ; - psf->peak_info->peaks [chan].position = psf->write_current + indx + (position / psf->sf.channels) ; - } ; - } ; - - return ; -} /* float32_peak_update */ - -static int -float32_get_capability (SF_PRIVATE *psf) -{ union - { float f ; - int i ; - unsigned char c [4] ; - } data ; - - data.f = (float) 1.23456789 ; /* Some abitrary value. */ - - if (! psf->ieee_replace) - { /* If this test is true ints and floats are compatible and little endian. */ - if (data.c [0] == 0x52 && data.c [1] == 0x06 && data.c [2] == 0x9e && data.c [3] == 0x3f) - return FLOAT_CAN_RW_LE ; - - /* If this test is true ints and floats are compatible and big endian. */ - if (data.c [3] == 0x52 && data.c [2] == 0x06 && data.c [1] == 0x9e && data.c [0] == 0x3f) - return FLOAT_CAN_RW_BE ; - } ; - - /* Floats are broken. Don't expect reading or writing to be fast. */ - psf_log_printf (psf, "Using IEEE replacement code for float.\n") ; - - return (CPU_IS_LITTLE_ENDIAN) ? FLOAT_BROKEN_LE : FLOAT_BROKEN_BE ; -} /* float32_get_capability */ - -/*======================================================================================= -*/ - -static void -f2s_array (const float *src, int count, short *dest, float scale) -{ - for (int i = 0 ; i < count ; i++) - { dest [i] = psf_lrintf (scale * src [i]) ; - } ; -} /* f2s_array */ - -static void -f2s_clip_array (const float *src, int count, short *dest, float scale) -{ for (int i = 0 ; i < count ; i++) - { float tmp = scale * src [i] ; - - if (tmp > 32767.0) - dest [i] = SHRT_MAX ; - else if (tmp < -32768.0) - dest [i] = SHRT_MIN ; - else - dest [i] = psf_lrintf (tmp) ; - } ; -} /* f2s_clip_array */ - -static inline void -f2i_array (const float *src, int count, int *dest, float scale) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = psf_lrintf (scale * src [i]) ; - } ; -} /* f2i_array */ - -static inline void -f2i_clip_array (const float *src, int count, int *dest, float scale) -{ for (int i = 0 ; i < count ; i++) - { float tmp = scale * src [i] ; - - if (CPU_CLIPS_POSITIVE == 0 && tmp > (1.0 * INT_MAX)) - dest [i] = INT_MAX ; - else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX)) - dest [i] = INT_MIN ; - else - dest [i] = psf_lrintf (tmp) ; - } ; -} /* f2i_clip_array */ - -static inline void -f2d_array (const float *src, int count, double *dest) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = src [i] ; - } ; -} /* f2d_array */ - -static inline void -s2f_array (const short *src, float *dest, int count, float scale) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = scale * src [i] ; - } ; -} /* s2f_array */ - -static inline void -i2f_array (const int *src, float *dest, int count, float scale) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = scale * src [i] ; - } ; -} /* i2f_array */ - -static inline void -d2f_array (const double *src, float *dest, int count) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = src [i] ; - } ; -} /* d2f_array */ - -/*---------------------------------------------------------------------------------------------- -*/ - -static sf_count_t -host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, int, short *, float) ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float scale ; - - convert = (psf->add_clipping) ? f2s_clip_array : f2s_array ; - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - -/* Fix me : Need lef2s_array */ - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, readcount) ; - - convert (ubuf.fbuf, readcount, ptr + total, scale) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* host_read_f2s */ - -static sf_count_t -host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, int, int *, float) ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float scale ; - - convert = (psf->add_clipping) ? f2i_clip_array : f2i_array ; - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - scale = (psf->float_int_mult == 0) ? 1.0 : 2147483648.0f / psf->float_max ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - convert (ubuf.fbuf, readcount, ptr + total, scale) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* host_read_f2i */ - -static sf_count_t -host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - if (psf->data_endswap != SF_TRUE) - return psf_fread (ptr, sizeof (float), len, psf) ; - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - - endswap_int_copy ((int*) (ptr + total), ubuf.ibuf, readcount) ; - - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* host_read_f */ - -static sf_count_t -host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - -/* Fix me : Need lef2d_array */ - f2d_array (ubuf.fbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* host_read_f2d */ - -static sf_count_t -host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - float scale ; - -/* Erik */ - scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ; - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2f_array (ptr + total, ubuf.fbuf, bufferlen, scale) ; - - if (psf->peak_info) - float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* host_write_s2f */ - -static sf_count_t -host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - float scale ; - - scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ; - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2f_array (ptr + total, ubuf.fbuf, bufferlen, scale) ; - - if (psf->peak_info) - float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float) , bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* host_write_i2f */ - -static sf_count_t -host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - if (psf->peak_info) - float32_peak_update (psf, ptr, len, 0) ; - - if (psf->data_endswap != SF_TRUE) - return psf_fwrite (ptr, sizeof (float), len, psf) ; - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - - endswap_int_copy (ubuf.ibuf, (const int*) (ptr + total), bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* host_write_f */ - -static sf_count_t -host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - - d2f_array (ptr + total, ubuf.fbuf, bufferlen) ; - - if (psf->peak_info) - float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* host_write_d2f */ - -/*======================================================================================= -*/ - -static sf_count_t -replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float scale ; - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - bf2f_array (ubuf.fbuf, bufferlen) ; - - f2s_array (ubuf.fbuf, readcount, ptr + total, scale) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* replace_read_f2s */ - -static sf_count_t -replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float scale ; - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - scale = (psf->float_int_mult == 0) ? 1.0 : 2147483648.0f / psf->float_max ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - bf2f_array (ubuf.fbuf, bufferlen) ; - - f2i_array (ubuf.fbuf, readcount, ptr + total, scale) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* replace_read_f2i */ - -static sf_count_t -replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - /* FIX THIS */ - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - bf2f_array (ubuf.fbuf, bufferlen) ; - - memcpy (ptr + total, ubuf.fbuf, bufferlen * sizeof (float)) ; - - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* replace_read_f */ - -static sf_count_t -replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - bf2f_array (ubuf.fbuf, bufferlen) ; - - f2d_array (ubuf.fbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* replace_read_f2d */ - -static sf_count_t -replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - float scale ; - - scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ; - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2f_array (ptr + total, ubuf.fbuf, bufferlen, scale) ; - - if (psf->peak_info) - float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; - - f2bf_array (ubuf.fbuf, bufferlen) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* replace_write_s2f */ - -static sf_count_t -replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - float scale ; - - scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ; - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2f_array (ptr + total, ubuf.fbuf, bufferlen, scale) ; - - if (psf->peak_info) - float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; - - f2bf_array (ubuf.fbuf, bufferlen) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* replace_write_i2f */ - -static sf_count_t -replace_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - /* FIX THIS */ - if (psf->peak_info) - float32_peak_update (psf, ptr, len, 0) ; - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - - memcpy (ubuf.fbuf, ptr + total, bufferlen * sizeof (float)) ; - - f2bf_array (ubuf.fbuf, bufferlen) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float) , bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* replace_write_f */ - -static sf_count_t -replace_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.fbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - d2f_array (ptr + total, ubuf.fbuf, bufferlen) ; - - if (psf->peak_info) - float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ; - - f2bf_array (ubuf.fbuf, bufferlen) ; - - if (psf->data_endswap == SF_TRUE) - endswap_int_array (ubuf.ibuf, bufferlen) ; - - writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* replace_write_d2f */ - -/*---------------------------------------------------------------------------------------------- -*/ - -static void -bf2f_array (float *buffer, int count) -{ for (int i = 0 ; i < count ; i++) - { buffer [i] = FLOAT32_READ ((unsigned char *) &buffer [i]) ; - } ; -} /* bf2f_array */ - -static void -f2bf_array (float *buffer, int count) -{ for (int i = 0 ; i < count ; i++) - { FLOAT32_WRITE (buffer [i], (unsigned char*) &buffer [i]) ; - } ; -} /* f2bf_array */ - diff --git a/Engine/lib/libsndfile/src/g72x.c b/Engine/lib/libsndfile/src/g72x.c deleted file mode 100644 index 62e400513..000000000 --- a/Engine/lib/libsndfile/src/g72x.c +++ /dev/null @@ -1,608 +0,0 @@ -/* -** Copyright (C) 1999-2014 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "G72x/g72x.h" - -/* This struct is private to the G72x code. */ -struct g72x_state ; -typedef struct g72x_state G72x_STATE ; - -typedef struct -{ /* Private data. Don't mess with it. */ - struct g72x_state * private ; - - /* Public data. Read only. */ - int blocksize, samplesperblock, bytesperblock ; - - /* Public data. Read and write. */ - int blocks_total, block_curr, sample_curr ; - unsigned char block [G72x_BLOCK_SIZE] ; - short samples [G72x_BLOCK_SIZE] ; -} G72x_PRIVATE ; - -static int psf_g72x_decode_block (SF_PRIVATE *psf, G72x_PRIVATE *pg72x) ; -static int psf_g72x_encode_block (SF_PRIVATE *psf, G72x_PRIVATE *pg72x) ; - -static sf_count_t g72x_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t g72x_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t g72x_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t g72x_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t g72x_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t g72x_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t g72x_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t g72x_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static sf_count_t g72x_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; - -static int g72x_close (SF_PRIVATE *psf) ; - - -/*============================================================================================ -** WAV G721 Reader initialisation function. -*/ - -int -g72x_init (SF_PRIVATE * psf) -{ G72x_PRIVATE *pg72x ; - int bitspersample, bytesperblock, codec ; - - if (psf->codec_data != NULL) - { psf_log_printf (psf, "*** psf->codec_data is not NULL.\n") ; - return SFE_INTERNAL ; - } ; - - psf->sf.seekable = SF_FALSE ; - - if (psf->sf.channels != 1) - return SFE_G72X_NOT_MONO ; - - if ((pg72x = calloc (1, sizeof (G72x_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - - psf->codec_data = (void*) pg72x ; - - pg72x->block_curr = 0 ; - pg72x->sample_curr = 0 ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_G721_32 : - codec = G721_32_BITS_PER_SAMPLE ; - bytesperblock = G721_32_BYTES_PER_BLOCK ; - bitspersample = G721_32_BITS_PER_SAMPLE ; - break ; - - case SF_FORMAT_G723_24: - codec = G723_24_BITS_PER_SAMPLE ; - bytesperblock = G723_24_BYTES_PER_BLOCK ; - bitspersample = G723_24_BITS_PER_SAMPLE ; - break ; - - case SF_FORMAT_G723_40: - codec = G723_40_BITS_PER_SAMPLE ; - bytesperblock = G723_40_BYTES_PER_BLOCK ; - bitspersample = G723_40_BITS_PER_SAMPLE ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - psf->filelength = psf_get_filelen (psf) ; - if (psf->filelength < psf->dataoffset) - psf->filelength = psf->dataoffset ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend > 0) - psf->datalength -= psf->filelength - psf->dataend ; - - if (psf->file.mode == SFM_READ) - { pg72x->private = g72x_reader_init (codec, &(pg72x->blocksize), &(pg72x->samplesperblock)) ; - if (pg72x->private == NULL) - return SFE_MALLOC_FAILED ; - - pg72x->bytesperblock = bytesperblock ; - - psf->read_short = g72x_read_s ; - psf->read_int = g72x_read_i ; - psf->read_float = g72x_read_f ; - psf->read_double = g72x_read_d ; - - psf->seek = g72x_seek ; - - if (psf->datalength % pg72x->blocksize) - { psf_log_printf (psf, "*** Odd psf->datalength (%D) should be a multiple of %d\n", psf->datalength, pg72x->blocksize) ; - pg72x->blocks_total = (psf->datalength / pg72x->blocksize) + 1 ; - } - else - pg72x->blocks_total = psf->datalength / pg72x->blocksize ; - - psf->sf.frames = (sf_count_t) pg72x->blocks_total * pg72x->samplesperblock ; - - psf_g72x_decode_block (psf, pg72x) ; - } - else if (psf->file.mode == SFM_WRITE) - { pg72x->private = g72x_writer_init (codec, &(pg72x->blocksize), &(pg72x->samplesperblock)) ; - if (pg72x->private == NULL) - return SFE_MALLOC_FAILED ; - - pg72x->bytesperblock = bytesperblock ; - - psf->write_short = g72x_write_s ; - psf->write_int = g72x_write_i ; - psf->write_float = g72x_write_f ; - psf->write_double = g72x_write_d ; - - if (psf->datalength % pg72x->blocksize) - pg72x->blocks_total = (psf->datalength / pg72x->blocksize) + 1 ; - else - pg72x->blocks_total = psf->datalength / pg72x->blocksize ; - - if (psf->datalength > 0) - psf->sf.frames = (8 * psf->datalength) / bitspersample ; - - if ((psf->sf.frames * bitspersample) / 8 != psf->datalength) - psf_log_printf (psf, "*** Warning : weird psf->datalength.\n") ; - } ; - - psf->codec_close = g72x_close ; - - return 0 ; -} /* g72x_init */ - -/*============================================================================================ -** G721 Read Functions. -*/ - -static int -psf_g72x_decode_block (SF_PRIVATE *psf, G72x_PRIVATE *pg72x) -{ int k ; - - pg72x->block_curr ++ ; - pg72x->sample_curr = 0 ; - - if (pg72x->block_curr > pg72x->blocks_total) - { memset (pg72x->samples, 0, G72x_BLOCK_SIZE * sizeof (short)) ; - return 1 ; - } ; - - if ((k = psf_fread (pg72x->block, 1, pg72x->bytesperblock, psf)) != pg72x->bytesperblock) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pg72x->bytesperblock) ; - - pg72x->blocksize = k ; - g72x_decode_block (pg72x->private, pg72x->block, pg72x->samples) ; - - return 1 ; -} /* psf_g72x_decode_block */ - -static int -g72x_read_block (SF_PRIVATE *psf, G72x_PRIVATE *pg72x, short *ptr, int len) -{ int count, total = 0, indx = 0 ; - - while (indx < len) - { if (pg72x->block_curr > pg72x->blocks_total) - { memset (&(ptr [indx]), 0, (len - indx) * sizeof (short)) ; - return total ; - } ; - - if (pg72x->sample_curr >= pg72x->samplesperblock) - psf_g72x_decode_block (psf, pg72x) ; - - count = pg72x->samplesperblock - pg72x->sample_curr ; - count = (len - indx > count) ? count : len - indx ; - - memcpy (&(ptr [indx]), &(pg72x->samples [pg72x->sample_curr]), count * sizeof (short)) ; - indx += count ; - pg72x->sample_curr += count ; - total = indx ; - } ; - - return total ; -} /* g72x_read_block */ - -static sf_count_t -g72x_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ G72x_PRIVATE *pg72x ; - int readcount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pg72x = (G72x_PRIVATE*) psf->codec_data ; - - while (len > 0) - { readcount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = g72x_read_block (psf, pg72x, ptr, readcount) ; - - total += count ; - len -= count ; - - if (count != readcount) - break ; - } ; - - return total ; -} /* g72x_read_s */ - -static sf_count_t -g72x_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - G72x_PRIVATE *pg72x ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pg72x = (G72x_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = g72x_read_block (psf, pg72x, sptr, readcount) ; - - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = arith_shift_left (sptr [k], 16) ; - - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* g72x_read_i */ - -static sf_count_t -g72x_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - G72x_PRIVATE *pg72x ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pg72x = (G72x_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = g72x_read_block (psf, pg72x, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * sptr [k] ; - - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* g72x_read_f */ - -static sf_count_t -g72x_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - G72x_PRIVATE *pg72x ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pg72x = (G72x_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = g72x_read_block (psf, pg72x, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (double) (sptr [k]) ; - - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* g72x_read_d */ - -static sf_count_t -g72x_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t UNUSED (offset)) -{ - psf_log_printf (psf, "seek unsupported\n") ; - - /* No simple solution. To do properly, would need to seek - ** to start of file and decode everything up to seek position. - ** Maybe implement SEEK_SET to 0 only? - */ - return 0 ; - -/* -** G72x_PRIVATE *pg72x ; -** int newblock, newsample, sample_curr ; -** -** if (psf->codec_data == NULL) -** return 0 ; -** pg72x = (G72x_PRIVATE*) psf->codec_data ; -** -** if (! (psf->datalength && psf->dataoffset)) -** { psf->error = SFE_BAD_SEEK ; -** return PSF_SEEK_ERROR ; -** } ; -** -** sample_curr = (8 * psf->datalength) / G721_32_BITS_PER_SAMPLE ; -** -** switch (whence) -** { case SEEK_SET : -** if (offset < 0 || offset > sample_curr) -** { psf->error = SFE_BAD_SEEK ; -** return PSF_SEEK_ERROR ; -** } ; -** newblock = offset / pg72x->samplesperblock ; -** newsample = offset % pg72x->samplesperblock ; -** break ; -** -** case SEEK_CUR : -** if (psf->current + offset < 0 || psf->current + offset > sample_curr) -** { psf->error = SFE_BAD_SEEK ; -** return PSF_SEEK_ERROR ; -** } ; -** newblock = (8 * (psf->current + offset)) / pg72x->samplesperblock ; -** newsample = (8 * (psf->current + offset)) % pg72x->samplesperblock ; -** break ; -** -** case SEEK_END : -** if (offset > 0 || sample_curr + offset < 0) -** { psf->error = SFE_BAD_SEEK ; -** return PSF_SEEK_ERROR ; -** } ; -** newblock = (sample_curr + offset) / pg72x->samplesperblock ; -** newsample = (sample_curr + offset) % pg72x->samplesperblock ; -** break ; -** -** default : -** psf->error = SFE_BAD_SEEK ; -** return PSF_SEEK_ERROR ; -** } ; -** -** if (psf->file.mode == SFM_READ) -** { psf_fseek (psf, psf->dataoffset + newblock * pg72x->blocksize, SEEK_SET) ; -** pg72x->block_curr = newblock ; -** psf_g72x_decode_block (psf, pg72x) ; -** pg72x->sample_curr = newsample ; -** } -** else -** { /+* What to do about write??? *+/ -** psf->error = SFE_BAD_SEEK ; -** return PSF_SEEK_ERROR ; -** } ; -** -** psf->current = newblock * pg72x->samplesperblock + newsample ; -** return psf->current ; -** -*/ -} /* g72x_seek */ - -/*========================================================================================== -** G72x Write Functions. -*/ - -static int -psf_g72x_encode_block (SF_PRIVATE *psf, G72x_PRIVATE *pg72x) -{ int k ; - - /* Encode the samples. */ - g72x_encode_block (pg72x->private, pg72x->samples, pg72x->block) ; - - /* Write the block to disk. */ - if ((k = psf_fwrite (pg72x->block, 1, pg72x->blocksize, psf)) != pg72x->blocksize) - psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pg72x->blocksize) ; - - pg72x->sample_curr = 0 ; - pg72x->block_curr ++ ; - - /* Set samples to zero for next block. */ - memset (pg72x->samples, 0, G72x_BLOCK_SIZE * sizeof (short)) ; - - return 1 ; -} /* psf_g72x_encode_block */ - -static int -g72x_write_block (SF_PRIVATE *psf, G72x_PRIVATE *pg72x, const short *ptr, int len) -{ int count, total = 0, indx = 0 ; - - while (indx < len) - { count = pg72x->samplesperblock - pg72x->sample_curr ; - - if (count > len - indx) - count = len - indx ; - - memcpy (&(pg72x->samples [pg72x->sample_curr]), &(ptr [indx]), count * sizeof (short)) ; - indx += count ; - pg72x->sample_curr += count ; - total = indx ; - - if (pg72x->sample_curr >= pg72x->samplesperblock) - psf_g72x_encode_block (psf, pg72x) ; - } ; - - return total ; -} /* g72x_write_block */ - -static sf_count_t -g72x_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ G72x_PRIVATE *pg72x ; - int writecount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pg72x = (G72x_PRIVATE*) psf->codec_data ; - - while (len > 0) - { writecount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = g72x_write_block (psf, pg72x, ptr, writecount) ; - - total += count ; - len -= count ; - if (count != writecount) - break ; - } ; - - return total ; -} /* g72x_write_s */ - -static sf_count_t -g72x_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - G72x_PRIVATE *pg72x ; - short *sptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pg72x = (G72x_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = ptr [total + k] >> 16 ; - count = g72x_write_block (psf, pg72x, sptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - return total ; -} /* g72x_write_i */ - -static sf_count_t -g72x_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - G72x_PRIVATE *pg72x ; - short *sptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pg72x = (G72x_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrintf (normfact * ptr [total + k]) ; - count = g72x_write_block (psf, pg72x, sptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* g72x_write_f */ - -static sf_count_t -g72x_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - G72x_PRIVATE *pg72x ; - short *sptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pg72x = (G72x_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrint (normfact * ptr [total + k]) ; - count = g72x_write_block (psf, pg72x, sptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* g72x_write_d */ - -static int -g72x_close (SF_PRIVATE *psf) -{ G72x_PRIVATE *pg72x ; - - pg72x = (G72x_PRIVATE*) psf->codec_data ; - - if (psf->file.mode == SFM_WRITE) - { /* If a block has been partially assembled, write it out - ** as the final block. - */ - - if (pg72x->sample_curr && pg72x->sample_curr < G72x_BLOCK_SIZE) - psf_g72x_encode_block (psf, pg72x) ; - - if (psf->write_header) - psf->write_header (psf, SF_FALSE) ; - } ; - - /* Only free the pointer allocated by g72x_(reader|writer)_init. */ - free (pg72x->private) ; - - return 0 ; -} /* g72x_close */ - diff --git a/Engine/lib/libsndfile/src/gsm610.c b/Engine/lib/libsndfile/src/gsm610.c deleted file mode 100644 index 933f03f0a..000000000 --- a/Engine/lib/libsndfile/src/gsm610.c +++ /dev/null @@ -1,629 +0,0 @@ -/* -** Copyright (C) 1999-2019 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "wavlike.h" -#include "GSM610/gsm.h" - -#define GSM610_BLOCKSIZE 33 -#define GSM610_SAMPLES 160 - -typedef struct gsm610_tag -{ int blocks ; - int blockcount, samplecount ; - int samplesperblock, blocksize ; - - int (*decode_block) (SF_PRIVATE *psf, struct gsm610_tag *pgsm610) ; - int (*encode_block) (SF_PRIVATE *psf, struct gsm610_tag *pgsm610) ; - - short samples [WAVLIKE_GSM610_SAMPLES] ; - unsigned char block [WAVLIKE_GSM610_BLOCKSIZE] ; - - /* Damn I hate typedef-ed pointers; yes, gsm is a pointer type. */ - gsm gsm_data ; -} GSM610_PRIVATE ; - -static sf_count_t gsm610_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t gsm610_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t gsm610_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t gsm610_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t gsm610_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t gsm610_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t gsm610_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t gsm610_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static int gsm610_read_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len) ; -static int gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, const short *ptr, int len) ; - -static int gsm610_decode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) ; -static int gsm610_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) ; - -static int gsm610_wav_decode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) ; -static int gsm610_wav_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) ; - -static sf_count_t gsm610_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; - -static int gsm610_close (SF_PRIVATE *psf) ; - -/*============================================================================================ -** WAV GSM610 initialisation function. -*/ - -int -gsm610_init (SF_PRIVATE *psf) -{ GSM610_PRIVATE *pgsm610 ; - int true_flag = 1 ; - - if (psf->codec_data != NULL) - { psf_log_printf (psf, "*** psf->codec_data is not NULL.\n") ; - return SFE_INTERNAL ; - } ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - psf->sf.seekable = SF_FALSE ; - - if ((pgsm610 = calloc (1, sizeof (GSM610_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - - psf->codec_data = pgsm610 ; - - memset (pgsm610, 0, sizeof (GSM610_PRIVATE)) ; - -/*============================================================ - -Need separate gsm_data structs for encode and decode. - -============================================================*/ - - if ((pgsm610->gsm_data = gsm_create ()) == NULL) - return SFE_MALLOC_FAILED ; - - switch (SF_CONTAINER (psf->sf.format)) - { case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : - case SF_FORMAT_W64 : - gsm_option (pgsm610->gsm_data, GSM_OPT_WAV49, &true_flag) ; - - pgsm610->encode_block = gsm610_wav_encode_block ; - pgsm610->decode_block = gsm610_wav_decode_block ; - - pgsm610->samplesperblock = WAVLIKE_GSM610_SAMPLES ; - pgsm610->blocksize = WAVLIKE_GSM610_BLOCKSIZE ; - break ; - - case SF_FORMAT_AIFF : - case SF_FORMAT_RAW : - pgsm610->encode_block = gsm610_encode_block ; - pgsm610->decode_block = gsm610_decode_block ; - - pgsm610->samplesperblock = GSM610_SAMPLES ; - pgsm610->blocksize = GSM610_BLOCKSIZE ; - break ; - - default : - return SFE_INTERNAL ; - break ; - } ; - - if (psf->file.mode == SFM_READ) - { if (psf->datalength % pgsm610->blocksize == 0) - pgsm610->blocks = psf->datalength / pgsm610->blocksize ; - else if (psf->datalength % pgsm610->blocksize == 1 && pgsm610->blocksize == GSM610_BLOCKSIZE) - { /* - ** Weird AIFF specific case. - ** AIFF chunks must be at an even offset from the start of file and - ** GSM610_BLOCKSIZE is odd which can result in an odd length SSND - ** chunk. The SSND chunk then gets padded on write which means that - ** when it is read the datalength is too big by 1. - */ - pgsm610->blocks = psf->datalength / pgsm610->blocksize ; - } - else - { psf_log_printf (psf, "*** Warning : data chunk seems to be truncated.\n") ; - pgsm610->blocks = psf->datalength / pgsm610->blocksize + 1 ; - } ; - - psf->sf.frames = (sf_count_t) pgsm610->samplesperblock * pgsm610->blocks ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - pgsm610->decode_block (psf, pgsm610) ; /* Read first block. */ - - psf->read_short = gsm610_read_s ; - psf->read_int = gsm610_read_i ; - psf->read_float = gsm610_read_f ; - psf->read_double = gsm610_read_d ; - } ; - - if (psf->file.mode == SFM_WRITE) - { pgsm610->blockcount = 0 ; - pgsm610->samplecount = 0 ; - - psf->write_short = gsm610_write_s ; - psf->write_int = gsm610_write_i ; - psf->write_float = gsm610_write_f ; - psf->write_double = gsm610_write_d ; - } ; - - psf->codec_close = gsm610_close ; - - psf->seek = gsm610_seek ; - - psf->filelength = psf_get_filelen (psf) ; - psf->datalength = psf->filelength - psf->dataoffset ; - - return 0 ; -} /* gsm610_init */ - -/*============================================================================================ -** GSM 6.10 Read Functions. -*/ - -static int -gsm610_wav_decode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) -{ int k ; - - pgsm610->blockcount ++ ; - pgsm610->samplecount = 0 ; - - if (pgsm610->blockcount > pgsm610->blocks) - { memset (pgsm610->samples, 0, sizeof (pgsm610->samples)) ; - return 1 ; - } ; - - if ((k = (int) psf_fread (pgsm610->block, 1, WAVLIKE_GSM610_BLOCKSIZE, psf)) != WAVLIKE_GSM610_BLOCKSIZE) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, WAVLIKE_GSM610_BLOCKSIZE) ; - - if (gsm_decode (pgsm610->gsm_data, pgsm610->block, pgsm610->samples) < 0) - { psf_log_printf (psf, "Error from WAV gsm_decode() on frame : %d\n", pgsm610->blockcount) ; - return 0 ; - } ; - - if (gsm_decode (pgsm610->gsm_data, pgsm610->block + (WAVLIKE_GSM610_BLOCKSIZE + 1) / 2, pgsm610->samples + WAVLIKE_GSM610_SAMPLES / 2) < 0) - { psf_log_printf (psf, "Error from WAV gsm_decode() on frame : %d.5\n", pgsm610->blockcount) ; - return 0 ; - } ; - - return 1 ; -} /* gsm610_wav_decode_block */ - -static int -gsm610_decode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) -{ int k ; - - pgsm610->blockcount ++ ; - pgsm610->samplecount = 0 ; - - if (pgsm610->blockcount > pgsm610->blocks) - { memset (pgsm610->samples, 0, sizeof (pgsm610->samples)) ; - return 1 ; - } ; - - if ((k = (int) psf_fread (pgsm610->block, 1, GSM610_BLOCKSIZE, psf)) != GSM610_BLOCKSIZE) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, GSM610_BLOCKSIZE) ; - - if (gsm_decode (pgsm610->gsm_data, pgsm610->block, pgsm610->samples) < 0) - { psf_log_printf (psf, "Error from standard gsm_decode() on frame : %d\n", pgsm610->blockcount) ; - return 0 ; - } ; - - return 1 ; -} /* gsm610_decode_block */ - -static int -gsm610_read_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len) -{ int count, total = 0, indx = 0 ; - - while (indx < len) - { if (pgsm610->blockcount >= pgsm610->blocks && pgsm610->samplecount >= pgsm610->samplesperblock) - { memset (ptr + indx, 0, (len - indx) * sizeof (short)) ; - return total ; - } ; - - if (pgsm610->samplecount >= pgsm610->samplesperblock) - pgsm610->decode_block (psf, pgsm610) ; - - count = pgsm610->samplesperblock - pgsm610->samplecount ; - count = (len - indx > count) ? count : len - indx ; - - memcpy (&(ptr [indx]), &(pgsm610->samples [pgsm610->samplecount]), count * sizeof (short)) ; - indx += count ; - pgsm610->samplecount += count ; - total = indx ; - } ; - - return total ; -} /* gsm610_read_block */ - -static sf_count_t -gsm610_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ GSM610_PRIVATE *pgsm610 ; - int readcount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - while (len > 0) - { readcount = (len > 0x10000000) ? 0x1000000 : (int) len ; - - count = gsm610_read_block (psf, pgsm610, ptr, readcount) ; - - total += count ; - len -= count ; - - if (count != readcount) - break ; - } ; - - return total ; -} /* gsm610_read_s */ - -static sf_count_t -gsm610_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ GSM610_PRIVATE *pgsm610 ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = gsm610_read_block (psf, pgsm610, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = arith_shift_left (sptr [k], 16) ; - - total += count ; - len -= readcount ; - } ; - return total ; -} /* gsm610_read_i */ - -static sf_count_t -gsm610_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ GSM610_PRIVATE *pgsm610 ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = gsm610_read_block (psf, pgsm610, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * sptr [k] ; - - total += count ; - len -= readcount ; - } ; - return total ; -} /* gsm610_read_f */ - -static sf_count_t -gsm610_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ GSM610_PRIVATE *pgsm610 ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - - if (psf->codec_data == NULL) - return 0 ; - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = gsm610_read_block (psf, pgsm610, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * sptr [k] ; - - total += count ; - len -= readcount ; - } ; - return total ; -} /* gsm610_read_d */ - -static sf_count_t -gsm610_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) -{ GSM610_PRIVATE *pgsm610 ; - int newblock, newsample ; - - if (psf->codec_data == NULL) - return 0 ; - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - if (psf->dataoffset < 0) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (offset == 0) - { int true_flag = 1 ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - pgsm610->blockcount = 0 ; - - gsm_init (pgsm610->gsm_data) ; - if ((SF_CONTAINER (psf->sf.format)) == SF_FORMAT_WAV || - (SF_CONTAINER (psf->sf.format)) == SF_FORMAT_W64) - gsm_option (pgsm610->gsm_data, GSM_OPT_WAV49, &true_flag) ; - - pgsm610->decode_block (psf, pgsm610) ; - pgsm610->samplecount = 0 ; - return 0 ; - } ; - - if (offset < 0 || offset > pgsm610->blocks * pgsm610->samplesperblock) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - newblock = offset / pgsm610->samplesperblock ; - newsample = offset % pgsm610->samplesperblock ; - - if (psf->file.mode == SFM_READ) - { if (psf->read_current != newblock * pgsm610->samplesperblock + newsample) - { psf_fseek (psf, psf->dataoffset + newblock * pgsm610->samplesperblock, SEEK_SET) ; - pgsm610->blockcount = newblock ; - pgsm610->decode_block (psf, pgsm610) ; - pgsm610->samplecount = newsample ; - } ; - - return newblock * pgsm610->samplesperblock + newsample ; - } ; - - /* What to do about write??? */ - psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; -} /* gsm610_seek */ - -/*========================================================================================== -** GSM 6.10 Write Functions. -*/ - -static int -gsm610_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) -{ int k ; - - /* Encode the samples. */ - gsm_encode (pgsm610->gsm_data, pgsm610->samples, pgsm610->block) ; - - /* Write the block to disk. */ - if ((k = (int) psf_fwrite (pgsm610->block, 1, GSM610_BLOCKSIZE, psf)) != GSM610_BLOCKSIZE) - psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, GSM610_BLOCKSIZE) ; - - pgsm610->samplecount = 0 ; - pgsm610->blockcount ++ ; - - /* Set samples to zero for next block. */ - memset (pgsm610->samples, 0, sizeof (pgsm610->samples)) ; - - return 1 ; -} /* gsm610_encode_block */ - -static int -gsm610_wav_encode_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) -{ int k ; - - /* Encode the samples. */ - gsm_encode (pgsm610->gsm_data, pgsm610->samples, pgsm610->block) ; - gsm_encode (pgsm610->gsm_data, pgsm610->samples+WAVLIKE_GSM610_SAMPLES / 2, pgsm610->block+WAVLIKE_GSM610_BLOCKSIZE / 2) ; - - /* Write the block to disk. */ - if ((k = (int) psf_fwrite (pgsm610->block, 1, WAVLIKE_GSM610_BLOCKSIZE, psf)) != WAVLIKE_GSM610_BLOCKSIZE) - psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, WAVLIKE_GSM610_BLOCKSIZE) ; - - pgsm610->samplecount = 0 ; - pgsm610->blockcount ++ ; - - /* Set samples to zero for next block. */ - memset (pgsm610->samples, 0, sizeof (pgsm610->samples)) ; - - return 1 ; -} /* gsm610_wav_encode_block */ - -static int -gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, const short *ptr, int len) -{ int count, total = 0, indx = 0 ; - - while (indx < len) - { count = pgsm610->samplesperblock - pgsm610->samplecount ; - - if (count > len - indx) - count = len - indx ; - - memcpy (&(pgsm610->samples [pgsm610->samplecount]), &(ptr [indx]), count * sizeof (short)) ; - indx += count ; - pgsm610->samplecount += count ; - total = indx ; - - if (pgsm610->samplecount >= pgsm610->samplesperblock) - pgsm610->encode_block (psf, pgsm610) ; - } ; - - return total ; -} /* gsm610_write_block */ - -static sf_count_t -gsm610_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ GSM610_PRIVATE *pgsm610 ; - int writecount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - while (len > 0) - { writecount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = gsm610_write_block (psf, pgsm610, ptr, writecount) ; - - total += count ; - len -= count ; - - if (count != writecount) - break ; - } ; - - return total ; -} /* gsm610_write_s */ - -static sf_count_t -gsm610_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ GSM610_PRIVATE *pgsm610 ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = ptr [total + k] >> 16 ; - count = gsm610_write_block (psf, pgsm610, sptr, writecount) ; - - total += count ; - len -= writecount ; - } ; - return total ; -} /* gsm610_write_i */ - -static sf_count_t -gsm610_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ GSM610_PRIVATE *pgsm610 ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrintf (normfact * ptr [total + k]) ; - count = gsm610_write_block (psf, pgsm610, sptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - return total ; -} /* gsm610_write_f */ - -static sf_count_t -gsm610_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ GSM610_PRIVATE *pgsm610 ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrint (normfact * ptr [total + k]) ; - count = gsm610_write_block (psf, pgsm610, sptr, writecount) ; - - total += count ; - len -= writecount ; - } ; - return total ; -} /* gsm610_write_d */ - -static int -gsm610_close (SF_PRIVATE *psf) -{ GSM610_PRIVATE *pgsm610 ; - - if (psf->codec_data == NULL) - return 0 ; - - pgsm610 = (GSM610_PRIVATE*) psf->codec_data ; - - if (psf->file.mode == SFM_WRITE) - { /* If a block has been partially assembled, write it out - ** as the final block. - */ - - if (pgsm610->samplecount && pgsm610->samplecount < pgsm610->samplesperblock) - pgsm610->encode_block (psf, pgsm610) ; - } ; - - if (pgsm610->gsm_data) - gsm_destroy (pgsm610->gsm_data) ; - - return 0 ; -} /* gsm610_close */ - diff --git a/Engine/lib/libsndfile/src/htk.c b/Engine/lib/libsndfile/src/htk.c deleted file mode 100644 index 1041a8481..000000000 --- a/Engine/lib/libsndfile/src/htk.c +++ /dev/null @@ -1,226 +0,0 @@ -/* -** Copyright (C) 2002-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -#define SFE_HTK_BAD_FILE_LEN 1666 -#define SFE_HTK_NOT_WAVEFORM 1667 - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int htk_close (SF_PRIVATE *psf) ; - -static int htk_write_header (SF_PRIVATE *psf, int calc_length) ; -static int htk_read_header (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -htk_open (SF_PRIVATE *psf) -{ int subformat ; - int error = 0 ; - - if (psf->is_pipe) - return SFE_HTK_NO_PIPE ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = htk_read_header (psf))) - return error ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_HTK) - return SFE_BAD_OPEN_FORMAT ; - - psf->endian = SF_ENDIAN_BIG ; - - if (htk_write_header (psf, SF_FALSE)) - return psf->error ; - - psf->write_header = htk_write_header ; - } ; - - psf->container_close = htk_close ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - switch (subformat) - { case SF_FORMAT_PCM_16 : /* 16-bit linear PCM. */ - error = pcm_init (psf) ; - break ; - - default : break ; - } ; - - return error ; -} /* htk_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -htk_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - htk_write_header (psf, SF_TRUE) ; - - return 0 ; -} /* htk_close */ - -static int -htk_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t current ; - int sample_count, sample_period ; - - current = psf_ftell (psf) ; - - if (calc_length) - psf->filelength = psf_get_filelen (psf) ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - if (psf->filelength > 12) - sample_count = (psf->filelength - 12) / 2 ; - else - sample_count = 0 ; - - sample_period = 10000000 / psf->sf.samplerate ; - - psf_binheader_writef (psf, "E444", BHW4 (sample_count), BHW4 (sample_period), BHW4 (0x20000)) ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* htk_write_header */ - -/* -** Found the following info in a comment block within Bill Schottstaedt's -** sndlib library. -** -** HTK format files consist of a contiguous sequence of samples preceded by a -** header. Each sample is a vector of either 2-byte integers or 4-byte floats. -** 2-byte integers are used for compressed forms as described below and for -** vector quantised data as described later in section 5.11. HTK format data -** files can also be used to store speech waveforms as described in section 5.8. -** -** The HTK file format header is 12 bytes long and contains the following data -** nSamples -- number of samples in file (4-byte integer) -** sampPeriod -- sample period in 100ns units (4-byte integer) -** sampSize -- number of bytes per sample (2-byte integer) -** parmKind -- a code indicating the sample kind (2-byte integer) -** -** The parameter kind consists of a 6 bit code representing the basic -** parameter kind plus additional bits for each of the possible qualifiers. -** The basic parameter kind codes are -** -** 0 WAVEFORM sampled waveform -** 1 LPC linear prediction filter coefficients -** 2 LPREFC linear prediction reflection coefficients -** 3 LPCEPSTRA LPC cepstral coefficients -** 4 LPDELCEP LPC cepstra plus delta coefficients -** 5 IREFC LPC reflection coef in 16 bit integer format -** 6 MFCC mel-frequency cepstral coefficients -** 7 FBANK log mel-filter bank channel outputs -** 8 MELSPEC linear mel-filter bank channel outputs -** 9 USER user defined sample kind -** 10 DISCRETE vector quantised data -** -** and the bit-encoding for the qualifiers (in octal) is -** _E 000100 has energy -** _N 000200 absolute energy suppressed -** _D 000400 has delta coefficients -** _A 001000 has acceleration coefficients -** _C 002000 is compressed -** _Z 004000 has zero mean static coef. -** _K 010000 has CRC checksum -** _O 020000 has 0'th cepstral coef. -*/ - -static int -htk_read_header (SF_PRIVATE *psf) -{ int sample_count, sample_period, marker ; - - psf_binheader_readf (psf, "pE444", 0, &sample_count, &sample_period, &marker) ; - - if (2 * sample_count + 12 != psf->filelength) - return SFE_HTK_BAD_FILE_LEN ; - - if (marker != 0x20000) - return SFE_HTK_NOT_WAVEFORM ; - - psf->sf.channels = 1 ; - - if (sample_period > 0) - { psf->sf.samplerate = 10000000 / sample_period ; - psf_log_printf (psf, "HTK Waveform file\n Sample Count : %d\n Sample Period : %d => %d Hz\n", - sample_count, sample_period, psf->sf.samplerate) ; - } - else - { psf->sf.samplerate = 16000 ; - psf_log_printf (psf, "HTK Waveform file\n Sample Count : %d\n Sample Period : %d (should be > 0) => Guessed sample rate %d Hz\n", - sample_count, sample_period, psf->sf.samplerate) ; - } ; - - psf->sf.format = SF_FORMAT_HTK | SF_FORMAT_PCM_16 ; - psf->bytewidth = 2 ; - - /* HTK always has a 12 byte header. */ - psf->dataoffset = 12 ; - psf->endian = SF_ENDIAN_BIG ; - - psf->datalength = psf->filelength - psf->dataoffset ; - - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - if (! psf->sf.frames && psf->blockwidth) - psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - - return 0 ; -} /* htk_read_header */ - diff --git a/Engine/lib/libsndfile/src/id3.c b/Engine/lib/libsndfile/src/id3.c deleted file mode 100644 index 1516ee316..000000000 --- a/Engine/lib/libsndfile/src/id3.c +++ /dev/null @@ -1,132 +0,0 @@ -/* -** Copyright (C) 2010-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "id3.h" - -#if HAVE_MPEG -#include - -struct id3v1_genre_handler_userdata -{ int number ; - const char *ret ; -} ; - -static void -id3v1_genre_handler (int number, const char *description, void *userdata) -{ struct id3v1_genre_handler_userdata *data = (struct id3v1_genre_handler_userdata *) userdata ; - if (data->number == number) - data->ret = description ; -} - -const char * -id3_lookup_v1_genre (int number) -{ struct id3v1_genre_handler_userdata data ; - - data.number = number ; - data.ret = NULL ; - id3tag_genre_list (id3v1_genre_handler, &data) ; - - return data.ret ; -} - -#else /* HAVE_MPEG */ - -const char * -id3_lookup_v1_genre (int UNUSED (number)) -{ return NULL ; - } - -#endif - -int -id3_skip (SF_PRIVATE * psf) -{ unsigned char buf [10] ; - int offset ; - - memset (buf, 0, sizeof (buf)) ; - psf_binheader_readf (psf, "pb", 0, buf, 10) ; - - if (buf [0] == 'I' && buf [1] == 'D' && buf [2] == '3') - { psf->id3_header.minor_version = buf [3] ; - offset = buf [6] & 0x7f ; - offset = (offset << 7) | (buf [7] & 0x7f) ; - offset = (offset << 7) | (buf [8] & 0x7f) ; - offset = (offset << 7) | (buf [9] & 0x7f) ; - - /* - ** ID3 count field is how many bytes of ID3v2 header FOLLOW the ten - ** bytes of header magic and offset, NOT the total ID3v2 header len. - */ - psf->id3_header.len = offset + 10 ; - psf->id3_header.offset = psf->fileoffset ; - - psf_log_printf (psf, " ID3v2.%d header length : %d\n----------------------------------------\n", - psf->id3_header.minor_version, psf->id3_header.len) ; - - /* Never want to jump backwards in a file. */ - if (offset < 0) - return 0 ; - - /* Position ourselves at the new file offset. */ - if (psf->fileoffset + psf->id3_header.len < psf->filelength) - { psf_binheader_readf (psf, "p!", psf->id3_header.len) ; - psf->fileoffset += psf->id3_header.len ; - return 1 ; - } ; - } ; - - return 0 ; -} /* id3_skip */ - -const char * -id3_process_v2_genre (const char *genre) -{ int num = 0 ; - char c ; - const char *ptr ; - - if (!genre) - return NULL ; - - /* - ** Genre may require more processing. - ** - ** It is allowed to have numeric references to the genre table from ID3v1. - ** We'll just convert the simple case here, strings of the format "(nnn)". - */ - ptr = genre ; - if (ptr [0] == '(' && (c = *++ ptr) && isdigit (c)) - { num = c - '0' ; - while ((c == *++ ptr) && isdigit (c)) - num = num * 10 + (c - '0') ; - if (c == ')' && (c = *++ ptr) == '\0' && num < 256) - if ((ptr = id3_lookup_v1_genre (num))) - return ptr ; - } ; - - return genre ; -} /* id3_process_v2_genre */ diff --git a/Engine/lib/libsndfile/src/id3.h b/Engine/lib/libsndfile/src/id3.h deleted file mode 100644 index 4f54c4fca..000000000 --- a/Engine/lib/libsndfile/src/id3.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -** Copyright (C) 2008-2019 Erik de Castro Lopo -** Copyright (C) 2019 Arthur Taylor -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SF_SRC_ID3_H -#define SF_SRC_ID3_H - -int id3_skip (SF_PRIVATE * psf) ; - -const char *id3_lookup_v1_genre (int number) ; - -const char *id3_process_v2_genre (const char *genre) ; - -#endif /* SF_SRC_ID3_H */ diff --git a/Engine/lib/libsndfile/src/ima_adpcm.c b/Engine/lib/libsndfile/src/ima_adpcm.c deleted file mode 100644 index bc61f4e5a..000000000 --- a/Engine/lib/libsndfile/src/ima_adpcm.c +++ /dev/null @@ -1,1008 +0,0 @@ -/* -** Copyright (C) 1999-2020 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -typedef struct IMA_ADPCM_PRIVATE_tag -{ int (*decode_block) (SF_PRIVATE *psf, struct IMA_ADPCM_PRIVATE_tag *pima) ; - int (*encode_block) (SF_PRIVATE *psf, struct IMA_ADPCM_PRIVATE_tag *pima) ; - - int channels, blocksize, samplesperblock, blocks ; - int blockcount, samplecount ; - int previous [2] ; - int stepindx [2] ; - unsigned char *block ; - short *samples ; - short data [] ; /* ISO C99 struct flexible array. */ -} IMA_ADPCM_PRIVATE ; - -/*============================================================================================ -** Predefined IMA ADPCM data. -*/ - -static int ima_indx_adjust [16] = -{ -1, -1, -1, -1, /* +0 - +3, decrease the step size */ - +2, +4, +6, +8, /* +4 - +7, increase the step size */ - -1, -1, -1, -1, /* -0 - -3, decrease the step size */ - +2, +4, +6, +8, /* -4 - -7, increase the step size */ -} ; - -static int ima_step_size [89] = -{ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, - 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, - 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, - 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, - 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, - 32767 -} ; - -static int ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) ; -static int ima_writer_init (SF_PRIVATE *psf, int blockalign) ; - -static int ima_read_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len) ; -static int ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, const short *ptr, int len) ; - -static sf_count_t ima_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t ima_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t ima_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t ima_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t ima_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t ima_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t ima_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t ima_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static sf_count_t aiff_ima_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; -static sf_count_t wavlike_ima_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; - -static int ima_close (SF_PRIVATE *psf) ; - -static int wavlike_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ; -static int wavlike_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ; - -/*-static int aiff_ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) ;-*/ -static int aiff_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ; -static int aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ; - - -static inline int -clamp_ima_step_index (int indx) -{ if (indx < 0) - return 0 ; - if (indx >= ARRAY_LEN (ima_step_size)) - return ARRAY_LEN (ima_step_size) - 1 ; - - return indx ; -} /* clamp_ima_step_index */ - -/*============================================================================================ -** IMA ADPCM Reader initialisation function. -*/ - -int -wavlike_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) -{ int error ; - - if (psf->codec_data != NULL) - { psf_log_printf (psf, "*** psf->codec_data is not NULL.\n") ; - return SFE_INTERNAL ; - } ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode == SFM_READ) - if ((error = ima_reader_init (psf, blockalign, samplesperblock))) - return error ; - - if (psf->file.mode == SFM_WRITE) - if ((error = ima_writer_init (psf, blockalign))) - return error ; - - psf->codec_close = ima_close ; - psf->seek = wavlike_ima_seek ; - - return 0 ; -} /* wavlike_ima_init */ - -int -aiff_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) -{ int error ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode == SFM_READ) - if ((error = ima_reader_init (psf, blockalign, samplesperblock))) - return error ; - - if (psf->file.mode == SFM_WRITE) - if ((error = ima_writer_init (psf, blockalign))) - return error ; - - psf->codec_close = ima_close ; - psf->seek = aiff_ima_seek ; - - return 0 ; -} /* aiff_ima_init */ - -static int -ima_close (SF_PRIVATE *psf) -{ IMA_ADPCM_PRIVATE *pima ; - - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - if (psf->file.mode == SFM_WRITE) - { /* If a block has been partially assembled, write it out - ** as the final block. - */ - if (pima->samplecount && pima->samplecount < pima->samplesperblock) - pima->encode_block (psf, pima) ; - - psf->sf.frames = pima->samplesperblock * pima->blockcount / psf->sf.channels ; - } ; - - return 0 ; -} /* ima_close */ - -/*============================================================================================ -** IMA ADPCM Read Functions. -*/ - -static int -ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) -{ IMA_ADPCM_PRIVATE *pima ; - int pimasize, count ; - - if (psf->file.mode != SFM_READ) - return SFE_BAD_MODE_RW ; - - /* - ** Allocate enough space for 1 more than a multiple of 8 samples - ** to avoid having to branch when pulling apart the nibbles. - */ - count = ((samplesperblock - 2) | 7) + 2 ; - pimasize = sizeof (IMA_ADPCM_PRIVATE) + psf->sf.channels * (blockalign + samplesperblock + sizeof(short) * count) ; - - if (! (pima = calloc (1, pimasize))) - return SFE_MALLOC_FAILED ; - - psf->codec_data = (void*) pima ; - - pima->samples = pima->data ; - pima->block = (unsigned char*) (pima->data + samplesperblock * psf->sf.channels) ; - - pima->channels = psf->sf.channels ; - pima->blocksize = blockalign ; - pima->samplesperblock = samplesperblock ; - - psf->filelength = psf_get_filelen (psf) ; - psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset : - psf->filelength - psf->dataoffset ; - - if (pima->blocksize <= 0) - { psf_log_printf (psf, "*** Error : pima->blocksize should be > 0.\n") ; - return SFE_INTERNAL ; - } ; - - if (pima->samplesperblock <= 0) - { psf_log_printf (psf, "*** Error : pima->samplesperblock should be > 0.\n") ; - return SFE_INTERNAL ; - } ; - - if (psf->datalength % pima->blocksize) - pima->blocks = psf->datalength / pima->blocksize + 1 ; - else - pima->blocks = psf->datalength / pima->blocksize ; - - switch (SF_CONTAINER (psf->sf.format)) - { case SF_FORMAT_WAV : - case SF_FORMAT_W64 : - count = 2 * (pima->blocksize - 4 * pima->channels) / pima->channels + 1 ; - - if (pima->samplesperblock != count) - { psf_log_printf (psf, "*** Error : samplesperblock should be %d.\n", count) ; - return SFE_INTERNAL ; - } ; - - pima->decode_block = wavlike_ima_decode_block ; - - psf->sf.frames = pima->samplesperblock * pima->blocks ; - break ; - - case SF_FORMAT_AIFF : - psf_log_printf (psf, "still need to check block count\n") ; - pima->decode_block = aiff_ima_decode_block ; - psf->sf.frames = pima->samplesperblock * pima->blocks / pima->channels ; - break ; - - default : - psf_log_printf (psf, "ima_reader_init: bad psf->sf.format\n") ; - return SFE_INTERNAL ; - } ; - - pima->decode_block (psf, pima) ; /* Read first block. */ - - psf->read_short = ima_read_s ; - psf->read_int = ima_read_i ; - psf->read_float = ima_read_f ; - psf->read_double = ima_read_d ; - - return 0 ; -} /* ima_reader_init */ - -static int -aiff_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) -{ unsigned char *blockdata ; - int chan, k, diff, bytecode, predictor ; - short step, stepindx, *sampledata ; - -static int count = 0 ; -count ++ ; - - pima->blockcount += pima->channels ; - pima->samplecount = 0 ; - - if (pima->blockcount > pima->blocks) - { memset (pima->samples, 0, pima->samplesperblock * pima->channels * sizeof (short)) ; - return 1 ; - } ; - - if ((k = (int) psf_fread (pima->block, 1, pima->blocksize * pima->channels, psf)) != pima->blocksize * pima->channels) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pima->blocksize) ; - - /* Read and check the block header. */ - for (chan = 0 ; chan < pima->channels ; chan++) - { blockdata = pima->block + chan * 34 ; - sampledata = pima->samples + chan ; - - /* Sign-extend from 16 bits to 32. */ - predictor = (int) ((short) ((blockdata [0] << 8) | (blockdata [1] & 0x80))) ; - - stepindx = blockdata [1] & 0x7F ; - stepindx = clamp_ima_step_index (stepindx) ; - - /* - ** Pull apart the packed 4 bit samples and store them in their - ** correct sample positions. - */ - for (k = 0 ; k < pima->blocksize - 2 ; k++) - { bytecode = blockdata [k + 2] ; - sampledata [pima->channels * (2 * k + 0)] = bytecode & 0xF ; - sampledata [pima->channels * (2 * k + 1)] = (bytecode >> 4) & 0xF ; - } ; - - /* Decode the encoded 4 bit samples. */ - for (k = 0 ; k < pima->samplesperblock ; k ++) - { step = ima_step_size [stepindx] ; - - bytecode = pima->samples [pima->channels * k + chan] ; - - stepindx += ima_indx_adjust [bytecode] ; - stepindx = clamp_ima_step_index (stepindx) ; - - diff = step >> 3 ; - if (bytecode & 1) diff += step >> 2 ; - if (bytecode & 2) diff += step >> 1 ; - if (bytecode & 4) diff += step ; - if (bytecode & 8) diff = -diff ; - - predictor += diff ; - if (predictor < -32768) - predictor = -32768 ; - else if (predictor > 32767) - predictor = 32767 ; - - pima->samples [pima->channels * k + chan] = predictor ; - } ; - } ; - - return 1 ; -} /* aiff_ima_decode_block */ - -static int -aiff_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) -{ int chan, k, step, diff, vpdiff, blockindx, indx ; - short bytecode, mask ; - - k = 0 ; - for (chan = 0 ; chan < pima->channels ; chan ++) - { blockindx = chan * pima->blocksize ; - /* Encode the block header. */ - pima->block [blockindx++] = (pima->previous [chan] >> 8) & 0xFF ; - pima->block [blockindx++] = (pima->previous [chan] & 0x80) + (pima->stepindx [chan] & 0x7F) ; - - /* Encode the samples as 4 bit. */ - for (indx = chan ; indx < pima->samplesperblock * pima->channels ; indx += pima->channels) - { diff = pima->samples [indx] - pima->previous [chan] ; - - bytecode = 0 ; - step = ima_step_size [pima->stepindx [chan]] ; - vpdiff = step >> 3 ; - if (diff < 0) - { bytecode = 8 ; - diff = -diff ; - } ; - mask = 4 ; - while (mask) - { if (diff >= step) - { bytecode |= mask ; - diff -= step ; - vpdiff += step ; - } ; - step >>= 1 ; - mask >>= 1 ; - } ; - - if (bytecode & 8) - vpdiff = -vpdiff ; - pima->previous [chan] += vpdiff ; - - if (pima->previous [chan] > 32767) - pima->previous [chan] = 32767 ; - else if (pima->previous [chan] < -32768) - pima->previous [chan] = -32768 ; - - pima->stepindx [chan] += ima_indx_adjust [bytecode] ; - - pima->stepindx [chan] = clamp_ima_step_index (pima->stepindx [chan]) ; - pima->block [blockindx] = (bytecode << (4 * k)) | pima->block [blockindx] ; - blockindx += k ; - k = 1 - k ; - } ; - } ; - - /* Write the block to disk. */ - if ((k = (int) psf_fwrite (pima->block, 1, pima->channels * pima->blocksize, psf)) != pima->channels * pima->blocksize) - psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pima->channels * pima->blocksize) ; - - memset (pima->block, 0, pima->channels * pima->blocksize) ; - pima->samplecount = 0 ; - pima->blockcount ++ ; - - return 1 ; -} /* aiff_ima_encode_block */ - -static int -wavlike_ima_decode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) -{ int chan, k, predictor, blockindx, indx, indxstart, diff ; - short step, bytecode, stepindx [2] = { 0 }; - - pima->blockcount ++ ; - pima->samplecount = 0 ; - - if (pima->blockcount > pima->blocks) - { memset (pima->samples, 0, pima->samplesperblock * pima->channels * sizeof (short)) ; - return 1 ; - } ; - - if ((k = (int) psf_fread (pima->block, 1, pima->blocksize, psf)) != pima->blocksize) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pima->blocksize) ; - - /* Read and check the block header. */ - - for (chan = 0 ; chan < pima->channels ; chan++) - { predictor = pima->block [chan*4] | (pima->block [chan*4+1] << 8) ; - if (predictor & 0x8000) - predictor -= 0x10000 ; - - stepindx [chan] = pima->block [chan*4+2] ; - stepindx [chan] = clamp_ima_step_index (stepindx [chan]) ; - - - if (pima->block [chan*4+3] != 0) - psf_log_printf (psf, "IMA ADPCM synchronisation error.\n") ; - - pima->samples [chan] = predictor ; - } ; - - /* - ** Pull apart the packed 4 bit samples and store them in their - ** correct sample positions. - */ - - blockindx = 4 * pima->channels ; - - indxstart = pima->channels ; - while (blockindx < pima->blocksize) - { for (chan = 0 ; chan < pima->channels ; chan++) - { indx = indxstart + chan ; - for (k = 0 ; k < 4 ; k++) - { bytecode = pima->block [blockindx++] ; - pima->samples [indx] = bytecode & 0x0F ; - indx += pima->channels ; - pima->samples [indx] = (bytecode >> 4) & 0x0F ; - indx += pima->channels ; - } ; - } ; - indxstart += 8 * pima->channels ; - } ; - - /* Decode the encoded 4 bit samples. */ - - for (k = pima->channels ; k < (pima->samplesperblock * pima->channels) ; k ++) - { chan = (pima->channels > 1) ? (k % 2) : 0 ; - - bytecode = pima->samples [k] & 0xF ; - - step = ima_step_size [stepindx [chan]] ; - predictor = pima->samples [k - pima->channels] ; - - diff = step >> 3 ; - if (bytecode & 1) - diff += step >> 2 ; - if (bytecode & 2) - diff += step >> 1 ; - if (bytecode & 4) - diff += step ; - if (bytecode & 8) - diff = -diff ; - - predictor += diff ; - - if (predictor > 32767) - predictor = 32767 ; - else if (predictor < -32768) - predictor = -32768 ; - - stepindx [chan] += ima_indx_adjust [bytecode] ; - stepindx [chan] = clamp_ima_step_index (stepindx [chan]) ; - - pima->samples [k] = predictor ; - } ; - - return 1 ; -} /* wavlike_ima_decode_block */ - -static int -wavlike_ima_encode_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) -{ int chan, k, step, diff, vpdiff, blockindx, indx, indxstart ; - short bytecode, mask ; - - /* Encode the block header. */ - for (chan = 0 ; chan < pima->channels ; chan++) - { pima->block [chan*4] = pima->samples [chan] & 0xFF ; - pima->block [chan*4+1] = (pima->samples [chan] >> 8) & 0xFF ; - - pima->block [chan*4+2] = pima->stepindx [chan] ; - pima->block [chan*4+3] = 0 ; - - pima->previous [chan] = pima->samples [chan] ; - } ; - - /* Encode the samples as 4 bit. */ - - for (k = pima->channels ; k < (pima->samplesperblock * pima->channels) ; k ++) - { chan = (pima->channels > 1) ? (k % 2) : 0 ; - - diff = pima->samples [k] - pima->previous [chan] ; - - bytecode = 0 ; - step = ima_step_size [pima->stepindx [chan]] ; - vpdiff = step >> 3 ; - if (diff < 0) - { bytecode = 8 ; - diff = -diff ; - } ; - mask = 4 ; - while (mask) - { if (diff >= step) - { bytecode |= mask ; - diff -= step ; - vpdiff += step ; - } ; - step >>= 1 ; - mask >>= 1 ; - } ; - - if (bytecode & 8) - pima->previous [chan] -= vpdiff ; - else - pima->previous [chan] += vpdiff ; - - if (pima->previous [chan] > 32767) - pima->previous [chan] = 32767 ; - else if (pima->previous [chan] < -32768) - pima->previous [chan] = -32768 ; - - pima->stepindx [chan] += ima_indx_adjust [bytecode] ; - pima->stepindx [chan] = clamp_ima_step_index (pima->stepindx [chan]) ; - - pima->samples [k] = bytecode ; - } ; - - /* Pack the 4 bit encoded samples. */ - - blockindx = 4 * pima->channels ; - - indxstart = pima->channels ; - while (blockindx < pima->blocksize) - { for (chan = 0 ; chan < pima->channels ; chan++) - { indx = indxstart + chan ; - for (k = 0 ; k < 4 ; k++) - { pima->block [blockindx] = pima->samples [indx] & 0x0F ; - indx += pima->channels ; - pima->block [blockindx] |= (pima->samples [indx] << 4) & 0xF0 ; - indx += pima->channels ; - blockindx ++ ; - } ; - } ; - indxstart += 8 * pima->channels ; - } ; - - /* Write the block to disk. */ - - if ((k = (int) psf_fwrite (pima->block, 1, pima->blocksize, psf)) != pima->blocksize) - psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pima->blocksize) ; - - memset (pima->samples, 0, pima->samplesperblock * sizeof (short)) ; - pima->samplecount = 0 ; - pima->blockcount ++ ; - - return 1 ; -} /* wavlike_ima_encode_block */ - -static int -ima_read_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len) -{ int count, total = 0, indx = 0 ; - - while (indx < len) - { if (pima->blockcount >= pima->blocks && pima->samplecount >= pima->samplesperblock) - { memset (&(ptr [indx]), 0, (size_t) ((len - indx) * sizeof (short))) ; - return total ; - } ; - - if (pima->samplecount >= pima->samplesperblock) - pima->decode_block (psf, pima) ; - - count = (pima->samplesperblock - pima->samplecount) * pima->channels ; - count = (len - indx > count) ? count : len - indx ; - - memcpy (&(ptr [indx]), &(pima->samples [pima->samplecount * pima->channels]), count * sizeof (short)) ; - indx += count ; - pima->samplecount += count / pima->channels ; - total = indx ; - } ; - - return total ; -} /* ima_read_block */ - -static sf_count_t -ima_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ IMA_ADPCM_PRIVATE *pima ; - int readcount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - while (len > 0) - { readcount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = ima_read_block (psf, pima, ptr, readcount) ; - - total += count ; - len -= count ; - if (count != readcount) - break ; - } ; - - return total ; -} /* ima_read_s */ - -static sf_count_t -ima_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ IMA_ADPCM_PRIVATE *pima ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = ima_read_block (psf, pima, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = arith_shift_left (sptr [k], 16) ; - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* ima_read_i */ - -static sf_count_t -ima_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ IMA_ADPCM_PRIVATE *pima ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - float normfact ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = ima_read_block (psf, pima, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (float) (sptr [k]) ; - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* ima_read_f */ - -static sf_count_t -ima_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ IMA_ADPCM_PRIVATE *pima ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - double normfact ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = ima_read_block (psf, pima, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (double) (sptr [k]) ; - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* ima_read_d */ - -static sf_count_t -aiff_ima_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ IMA_ADPCM_PRIVATE *pima ; - int newblock, newsample, newblockaiff ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - if (psf->datalength < 0 || psf->dataoffset < 0) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (offset == 0) - { psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - pima->blockcount = 0 ; - pima->decode_block (psf, pima) ; - pima->samplecount = 0 ; - return 0 ; - } ; - - if (offset < 0 || offset > pima->blocks * pima->samplesperblock) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - newblock = offset / pima->samplesperblock ; - newsample = offset % pima->samplesperblock ; - newblockaiff = newblock * psf->sf.channels ; - - if (mode == SFM_READ) - { psf_fseek (psf, psf->dataoffset + newblockaiff * pima->blocksize, SEEK_SET) ; - pima->blockcount = newblockaiff ; - pima->decode_block (psf, pima) ; - pima->samplecount = newsample ; - } - else - { /* What to do about write??? */ - psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - return newblock * pima->samplesperblock + newsample ; -} /* aiff_ima_seek */ - -static sf_count_t -wavlike_ima_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ IMA_ADPCM_PRIVATE *pima ; - int newblock, newsample ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - if (psf->datalength < 0 || psf->dataoffset < 0) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (offset == 0) - { psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - pima->blockcount = 0 ; - if (!pima->decode_block) - return PSF_SEEK_ERROR ; - - pima->decode_block (psf, pima) ; - pima->samplecount = 0 ; - return 0 ; - } ; - - if (offset < 0 || offset > pima->blocks * pima->samplesperblock) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - newblock = offset / pima->samplesperblock ; - newsample = offset % pima->samplesperblock ; - - if (mode == SFM_READ) - { psf_fseek (psf, psf->dataoffset + newblock * pima->blocksize, SEEK_SET) ; - pima->blockcount = newblock ; - pima->decode_block (psf, pima) ; - pima->samplecount = newsample ; - } - else - { /* What to do about write??? */ - psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - return newblock * pima->samplesperblock + newsample ; -} /* wavlike_ima_seek */ - -/*========================================================================================== -** IMA ADPCM Write Functions. -*/ - -static int -ima_writer_init (SF_PRIVATE *psf, int blockalign) -{ IMA_ADPCM_PRIVATE *pima ; - int samplesperblock ; - unsigned int pimasize ; - - if (psf->file.mode != SFM_WRITE) - return SFE_BAD_MODE_RW ; - - switch (SF_CONTAINER (psf->sf.format)) - { case SF_FORMAT_WAV : - case SF_FORMAT_W64 : - samplesperblock = 2 * (blockalign - 4 * psf->sf.channels) / psf->sf.channels + 1 ; - break ; - - case SF_FORMAT_AIFF : - samplesperblock = 2 * ((blockalign - 2) * psf->sf.channels) / psf->sf.channels ; - break ; - - default : - psf_log_printf (psf, "ima_reader_init: bad psf->sf.format\n") ; - return SFE_INTERNAL ; - } ; - - pimasize = sizeof (IMA_ADPCM_PRIVATE) + blockalign + 3 * psf->sf.channels * samplesperblock ; - - if ((pima = calloc (1, pimasize)) == NULL) - return SFE_MALLOC_FAILED ; - - psf->codec_data = (void*) pima ; - - pima->channels = psf->sf.channels ; - pima->blocksize = blockalign ; - pima->samplesperblock = samplesperblock ; - - pima->block = (unsigned char*) pima->data ; - pima->samples = (short*) (pima->data + blockalign) ; - - pima->samplecount = 0 ; - - switch (SF_CONTAINER (psf->sf.format)) - { case SF_FORMAT_WAV : - case SF_FORMAT_W64 : - pima->encode_block = wavlike_ima_encode_block ; - break ; - - case SF_FORMAT_AIFF : - pima->encode_block = aiff_ima_encode_block ; - break ; - - default : - psf_log_printf (psf, "ima_reader_init: bad psf->sf.format\n") ; - return SFE_INTERNAL ; - } ; - - psf->write_short = ima_write_s ; - psf->write_int = ima_write_i ; - psf->write_float = ima_write_f ; - psf->write_double = ima_write_d ; - - return 0 ; -} /* ima_writer_init */ - -/*========================================================================================== -*/ - -static int -ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, const short *ptr, int len) -{ int count, total = 0, indx = 0 ; - - while (indx < len) - { count = (pima->samplesperblock - pima->samplecount) * pima->channels ; - - if (count > len - indx) - count = len - indx ; - - memcpy (&(pima->samples [pima->samplecount * pima->channels]), &(ptr [total]), count * sizeof (short)) ; - indx += count ; - pima->samplecount += count / pima->channels ; - total = indx ; - - if (pima->samplecount >= pima->samplesperblock) - pima->encode_block (psf, pima) ; - } ; - - return total ; -} /* ima_write_block */ - -static sf_count_t -ima_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ IMA_ADPCM_PRIVATE *pima ; - int writecount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - while (len) - { writecount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = ima_write_block (psf, pima, ptr, writecount) ; - - total += count ; - len -= count ; - if (count != writecount) - break ; - } ; - - return total ; -} /* ima_write_s */ - -static sf_count_t -ima_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ IMA_ADPCM_PRIVATE *pima ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = ptr [total + k] >> 16 ; - count = ima_write_block (psf, pima, sptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* ima_write_i */ - -static sf_count_t -ima_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ IMA_ADPCM_PRIVATE *pima ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - float normfact ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrintf (normfact * ptr [total + k]) ; - count = ima_write_block (psf, pima, sptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* ima_write_f */ - -static sf_count_t -ima_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ IMA_ADPCM_PRIVATE *pima ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - double normfact ; - - if (! psf->codec_data) - return 0 ; - pima = (IMA_ADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrint (normfact * ptr [total + k]) ; - count = ima_write_block (psf, pima, sptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* ima_write_d */ - diff --git a/Engine/lib/libsndfile/src/ima_oki_adpcm.c b/Engine/lib/libsndfile/src/ima_oki_adpcm.c deleted file mode 100644 index 253216009..000000000 --- a/Engine/lib/libsndfile/src/ima_oki_adpcm.c +++ /dev/null @@ -1,297 +0,0 @@ -/* -** Copyright (C) 2007-2014 Erik de Castro Lopo -** Copyright (c) 2007 -** -** This library is free software; you can redistribute it and/or modify it -** under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2 of the License, or (at -** your option) any later version. -** -** This library is distributed in the hope that it will be useful, but -** WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser -** General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this library. If not, write to the Free Software Foundation, -** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA. -*/ - -/* ADPCM: IMA, OKI <==> 16-bit PCM. */ - -#include "sfconfig.h" - -#include - -/* Set up for libsndfile environment: */ -#include "common.h" - -#include "ima_oki_adpcm.h" - -#define MIN_SAMPLE -0x8000 -#define MAX_SAMPLE 0x7fff - -static int const ima_steps [] = /* ~16-bit precision */ -{ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, - 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, - 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, - 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, - 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, - 32767 -} ; - -static int const oki_steps [] = /* ~12-bit precision */ -{ 256, 272, 304, 336, 368, 400, 448, 496, 544, 592, 656, 720, 800, 880, 960, - 1056, 1168, 1280, 1408, 1552, 1712, 1888, 2080, 2288, 2512, 2768, 3040, 3344, - 3680, 4048, 4464, 4912, 5392, 5936, 6528, 7184, 7904, 8704, 9568, 10528, - 11584, 12736, 14016, 15408, 16960, 18656, 20512, 22576, 24832 -} ; - -static int const step_changes [] = { -1, -1, -1, -1, 2, 4, 6, 8 } ; - -void -ima_oki_adpcm_init (IMA_OKI_ADPCM * state, IMA_OKI_ADPCM_TYPE type) -{ - memset (state, 0, sizeof (*state)) ; - - if (type == IMA_OKI_ADPCM_TYPE_IMA) - { state->max_step_index = ARRAY_LEN (ima_steps) - 1 ; - state->steps = ima_steps ; - state->mask = (~0) ; - } - else - { state->max_step_index = ARRAY_LEN (oki_steps) - 1 ; - state->steps = oki_steps ; - state->mask = arith_shift_left (~0, 4) ; - } ; - -} /* ima_oki_adpcm_init */ - - -int -adpcm_decode (IMA_OKI_ADPCM * state, int code) -{ int s ; - - s = ((code & 7) << 1) | 1 ; - s = ((state->steps [state->step_index] * s) >> 3) & state->mask ; - - if (code & 8) - s = -s ; - s += state->last_output ; - - if (s < MIN_SAMPLE || s > MAX_SAMPLE) - { int grace ; - - grace = (state->steps [state->step_index] >> 3) & state->mask ; - - if (s < MIN_SAMPLE - grace || s > MAX_SAMPLE + grace) - state->errors ++ ; - - s = s < MIN_SAMPLE ? MIN_SAMPLE : MAX_SAMPLE ; - } ; - - state->step_index += step_changes [code & 7] ; - state->step_index = SF_MIN (SF_MAX (state->step_index, 0), state->max_step_index) ; - state->last_output = s ; - - return s ; -} /* adpcm_decode */ - -int -adpcm_encode (IMA_OKI_ADPCM * state, int sample) -{ int delta, sign = 0, code ; - - delta = sample - state->last_output ; - - if (delta < 0) - { sign = 8 ; - delta = -delta ; - } ; - - code = 4 * delta / state->steps [state->step_index] ; - code = sign | SF_MIN (code, 7) ; - adpcm_decode (state, code) ; /* Update encoder state */ - - return code ; -} /* adpcm_encode */ - - -void -ima_oki_adpcm_decode_block (IMA_OKI_ADPCM * state) -{ unsigned char code ; - int k ; - - for (k = 0 ; k < state->code_count ; k++) - { code = state->codes [k] ; - state->pcm [2 * k] = adpcm_decode (state, code >> 4) ; - state->pcm [2 * k + 1] = adpcm_decode (state, code) ; - } ; - - state->pcm_count = 2 * k ; -} /* ima_oki_adpcm_decode_block */ - - -void -ima_oki_adpcm_encode_block (IMA_OKI_ADPCM * state) -{ unsigned char code ; - int k ; - - /* - ** The codec expects an even number of input samples. - ** - ** Samples should always be passed in even length blocks. If the last block to - ** be encoded is odd length, extend that block by one zero valued sample. - */ - if (state->pcm_count % 2 == 1) - state->pcm [state->pcm_count ++] = 0 ; - - for (k = 0 ; k < state->pcm_count / 2 ; k++) - { code = adpcm_encode (state, state->pcm [2 * k]) << 4 ; - code |= adpcm_encode (state, state->pcm [2 * k + 1]) ; - state->codes [k] = code ; - } ; - - state->code_count = k ; -} /* ima_oki_adpcm_encode_block */ - - -#ifdef TEST - -static const unsigned char test_codes [] = -{ 0x08, 0x08, 0x04, 0x7f, 0x72, 0xf7, 0x9f, 0x7c, 0xd7, 0xbc, 0x7a, 0xa7, 0xb8, - 0x4b, 0x0b, 0x38, 0xf6, 0x9d, 0x7a, 0xd7, 0xbc, 0x7a, 0xd7, 0xa8, 0x6c, 0x81, - 0x98, 0xe4, 0x0e, 0x7a, 0xd7, 0x9e, 0x7b, 0xc7, 0xab, 0x7a, 0x85, 0xc0, 0xb3, - 0x8f, 0x58, 0xd7, 0xad, 0x7a, 0xd7, 0xad, 0x7a, 0x87, 0xd0, 0x2b, 0x0e, 0x48, - 0xd7, 0xad, 0x78, 0xf7, 0xbc, 0x7a, 0xb7, 0xa8, 0x4b, 0x88, 0x18, 0xd5, 0x8d, - 0x6a, 0xa4, 0x98, 0x08, 0x00, 0x80, 0x88, -} ; - -static const short test_pcm [] = -{ 32, 0, 32, 0, 32, 320, 880, -336, 2304, 4192, -992, 10128, 5360, -16352, - 30208, 2272, -31872, 14688, -7040, -32432, 14128, -1392, -15488, 22960, - 1232, -1584, 21488, -240, 2576, -15360, 960, -1152, -30032, 10320, 1008, - -30032, 16528, 1008, -30032, 16528, -5200, -30592, 15968, 448, -30592, - 15968, 448, -2368, 30960, 3024, -80, 8384, 704, -1616, -29168, -1232, 1872, - -32768, 13792, -1728, -32768, 13792, 4480, -32192, 14368, -7360, -32752, - 13808, -1712, -21456, 16992, 1472, -1344, 26848, -1088, 2016, -17728, 208, - -2112, -32768, 1376, -1728, -32768, 13792, -1728, -32768, 13792, -1728, - -32768, 13792, -1728, -32768, 13792, -1728, -4544, 32767, -1377, 1727, - 15823, -2113, 207, -27345, 591, -2513, -32768, 13792, -1728, -32768, 13792, - 10688, -31632, 14928, -6800, -32192, 14368, -1152, -20896, 17552, 2032, - -784, 22288, 560, -2256, -4816, 2176, 64, -21120, 9920, 6816, -24224, 16128, - 608, -13488, 9584, 272, -2544, 16, -2304, -192, 1728, -16, 1568, 128, -1184, -} ; - - -static void -test_oki_adpcm (void) -{ - IMA_OKI_ADPCM adpcm ; - unsigned char code ; - int i, j ; - - printf (" Testing encoder : ") ; - fflush (stdout) ; - - ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ; - for (i = 0 ; i < ARRAY_LEN (test_codes) ; i++) - for (j = 0, code = test_codes [i] ; j < 2 ; j++, code <<= 4) - if (adpcm_decode (&adpcm, code >> 4) != test_pcm [2 * i + j]) - { printf ("\n\nFail at i = %d, j = %d.\n\n", i, j) ; - exit (1) ; - } ; - - puts ("ok") ; - - printf (" Testing decoder : ") ; - fflush (stdout) ; - - ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ; - for (i = 0 ; i < ARRAY_LEN (test_pcm) ; i += j) - { code = adpcm_encode (&adpcm, test_pcm [i]) ; - code = (code << 4) | adpcm_encode (&adpcm, test_pcm [i + 1]) ; - if (code != test_codes [i / 2]) - { printf ("\n\nFail at i = %d, %d should be %d\n\n", i, code, test_codes [i / 2]) ; - exit (1) ; - } ; - } ; - - puts ("ok") ; -} /* test_oki_adpcm */ - -static void -test_oki_adpcm_block (void) -{ - IMA_OKI_ADPCM adpcm ; - int k ; - - if (ARRAY_LEN (adpcm.pcm) < ARRAY_LEN (test_pcm)) - { printf ("\n\nLine %d : ARRAY_LEN (adpcm->pcm) > ARRAY_LEN (test_pcm) (%d > %d).\n\n", __LINE__, ARRAY_LEN (adpcm.pcm), ARRAY_LEN (test_pcm)) ; - exit (1) ; - } ; - - if (ARRAY_LEN (adpcm.codes) < ARRAY_LEN (test_codes)) - { printf ("\n\nLine %d : ARRAY_LEN (adcodes->codes) > ARRAY_LEN (test_codes).n", __LINE__) ; - exit (1) ; - } ; - - printf (" Testing block encoder : ") ; - fflush (stdout) ; - - ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ; - - memcpy (adpcm.pcm, test_pcm, sizeof (adpcm.pcm [0]) * ARRAY_LEN (test_pcm)) ; - adpcm.pcm_count = ARRAY_LEN (test_pcm) ; - adpcm.code_count = 13 ; - - ima_oki_adpcm_encode_block (&adpcm) ; - - if (adpcm.code_count * 2 != ARRAY_LEN (test_pcm)) - { printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.code_count * 2, ARRAY_LEN (test_pcm)) ; - exit (1) ; - } ; - - for (k = 0 ; k < ARRAY_LEN (test_codes) ; k++) - if (adpcm.codes [k] != test_codes [k]) - { printf ("\n\nLine %d : Fail at k = %d, %d should be %d\n\n", __LINE__, k, adpcm.codes [k], test_codes [k]) ; - exit (1) ; - } ; - - puts ("ok") ; - - printf (" Testing block decoder : ") ; - fflush (stdout) ; - - ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ; - - memcpy (adpcm.codes, test_codes, sizeof (adpcm.codes [0]) * ARRAY_LEN (test_codes)) ; - adpcm.code_count = ARRAY_LEN (test_codes) ; - adpcm.pcm_count = 13 ; - - ima_oki_adpcm_decode_block (&adpcm) ; - - if (adpcm.pcm_count != 2 * ARRAY_LEN (test_codes)) - { printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.pcm_count, 2 * ARRAY_LEN (test_codes)) ; - exit (1) ; - } ; - - for (k = 0 ; k < ARRAY_LEN (test_pcm) ; k++) - if (adpcm.pcm [k] != test_pcm [k]) - { printf ("\n\nLine %d : Fail at i = %d, %d should be %d.\n\n", __LINE__, k, adpcm.pcm [k], test_pcm [k]) ; - exit (1) ; - } ; - - puts ("ok") ; -} /* test_oki_adpcm_block */ - -int -main (void) -{ - test_oki_adpcm () ; - test_oki_adpcm_block () ; - - return 0 ; -} /* main */ - -#endif diff --git a/Engine/lib/libsndfile/src/ima_oki_adpcm.h b/Engine/lib/libsndfile/src/ima_oki_adpcm.h deleted file mode 100644 index 86241e7a2..000000000 --- a/Engine/lib/libsndfile/src/ima_oki_adpcm.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -** Copyright (C) 2007-2011 Erik de Castro Lopo -** Copyright (c) 2007 -** -** This library is free software; you can redistribute it and/or modify it -** under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2 of the License, or (at -** your option) any later version. -** -** This library is distributed in the hope that it will be useful, but -** WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser -** General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this library. If not, write to the Free Software Foundation, -** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA. -*/ - -/* ADPCM: IMA, OKI <==> 16-bit PCM. */ - - -#define IMA_OKI_ADPCM_CODE_LEN 256 -#define IMA_OKI_ADPCM_PCM_LEN (IMA_OKI_ADPCM_CODE_LEN *2) - -typedef struct -{ - /* private: */ - int mask ; - int last_output ; - int step_index ; - int max_step_index ; - int const * steps ; - - /* public: */ - int errors ; - int code_count, pcm_count ; - - unsigned char codes [IMA_OKI_ADPCM_CODE_LEN] ; - short pcm [IMA_OKI_ADPCM_PCM_LEN] ; -} IMA_OKI_ADPCM ; - -typedef enum -{ IMA_OKI_ADPCM_TYPE_IMA, - IMA_OKI_ADPCM_TYPE_OKI -} IMA_OKI_ADPCM_TYPE ; - -void ima_oki_adpcm_init (IMA_OKI_ADPCM * state, IMA_OKI_ADPCM_TYPE type) ; - -int adpcm_decode (IMA_OKI_ADPCM * state, int /* 0..15 */ code) ; -int adpcm_encode (IMA_OKI_ADPCM * state, int /* -32768..32767 */ sample) ; - -void ima_oki_adpcm_decode_block (IMA_OKI_ADPCM * state) ; -void ima_oki_adpcm_encode_block (IMA_OKI_ADPCM * state) ; diff --git a/Engine/lib/libsndfile/src/interleave.c b/Engine/lib/libsndfile/src/interleave.c deleted file mode 100644 index 5f799444c..000000000 --- a/Engine/lib/libsndfile/src/interleave.c +++ /dev/null @@ -1,299 +0,0 @@ -/* -** Copyright (C) 2002-2013 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfendian.h" - -#include - -#include "sndfile.h" -#include "common.h" - -#define INTERLEAVE_CHANNELS 6 - -typedef struct -{ double buffer [SF_BUFFER_LEN / sizeof (double)] ; - - sf_count_t channel_len ; - - sf_count_t (*read_short) (SF_PRIVATE*, short *ptr, sf_count_t len) ; - sf_count_t (*read_int) (SF_PRIVATE*, int *ptr, sf_count_t len) ; - sf_count_t (*read_float) (SF_PRIVATE*, float *ptr, sf_count_t len) ; - sf_count_t (*read_double) (SF_PRIVATE*, double *ptr, sf_count_t len) ; - -} INTERLEAVE_DATA ; - - - -static sf_count_t interleave_read_short (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t interleave_read_int (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t interleave_read_float (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t interleave_read_double (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t interleave_seek (SF_PRIVATE*, int mode, sf_count_t samples_from_start) ; - - - - -int -interleave_init (SF_PRIVATE *psf) -{ INTERLEAVE_DATA *pdata ; - - if (psf->file.mode != SFM_READ) - return SFE_INTERLEAVE_MODE ; - - if (psf->interleave) - { psf_log_printf (psf, "*** Weird, already have interleave.\n") ; - return 666 ; - } ; - - /* Free this in sf_close() function. */ - if (! (pdata = malloc (sizeof (INTERLEAVE_DATA)))) - return SFE_MALLOC_FAILED ; - -puts ("interleave_init") ; - - psf->interleave = pdata ; - - /* Save the existing methods. */ - pdata->read_short = psf->read_short ; - pdata->read_int = psf->read_int ; - pdata->read_float = psf->read_float ; - pdata->read_double = psf->read_double ; - - pdata->channel_len = psf->sf.frames * psf->bytewidth ; - - /* Insert our new methods. */ - psf->read_short = interleave_read_short ; - psf->read_int = interleave_read_int ; - psf->read_float = interleave_read_float ; - psf->read_double = interleave_read_double ; - - psf->seek = interleave_seek ; - - return 0 ; -} /* pcm_interleave_init */ - -/*------------------------------------------------------------------------------ -*/ - -static sf_count_t -interleave_read_short (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ INTERLEAVE_DATA *pdata ; - sf_count_t offset, templen ; - int chan, count, k ; - short *inptr, *outptr ; - - if (! (pdata = psf->interleave)) - return 0 ; - - inptr = (short*) pdata->buffer ; - - for (chan = 0 ; chan < psf->sf.channels ; chan++) - { outptr = ptr + chan ; - - offset = psf->dataoffset + chan * psf->bytewidth * psf->read_current ; - - if (psf_fseek (psf, offset, SEEK_SET) != offset) - { psf->error = SFE_INTERLEAVE_SEEK ; - return 0 ; - } ; - - templen = len / psf->sf.channels ; - - while (templen > 0) - { if (templen > SIGNED_SIZEOF (pdata->buffer) / SIGNED_SIZEOF (short)) - count = SIGNED_SIZEOF (pdata->buffer) / SIGNED_SIZEOF (short) ; - else - count = (int) templen ; - - if (pdata->read_short (psf, inptr, count) != count) - { psf->error = SFE_INTERLEAVE_READ ; - return 0 ; - } ; - - for (k = 0 ; k < count ; k++) - { *outptr = inptr [k] ; - outptr += psf->sf.channels ; - } ; - - templen -= count ; - } ; - } ; - - return len ; -} /* interleave_read_short */ - -static sf_count_t -interleave_read_int (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ INTERLEAVE_DATA *pdata ; - sf_count_t offset, templen ; - int chan, count, k ; - int *inptr, *outptr ; - - if (! (pdata = psf->interleave)) - return 0 ; - - inptr = (int*) pdata->buffer ; - - for (chan = 0 ; chan < psf->sf.channels ; chan++) - { outptr = ptr + chan ; - - offset = psf->dataoffset + chan * psf->bytewidth * psf->read_current ; - - if (psf_fseek (psf, offset, SEEK_SET) != offset) - { psf->error = SFE_INTERLEAVE_SEEK ; - return 0 ; - } ; - - templen = len / psf->sf.channels ; - - while (templen > 0) - { if (templen > SIGNED_SIZEOF (pdata->buffer) / SIGNED_SIZEOF (int)) - count = SIGNED_SIZEOF (pdata->buffer) / SIGNED_SIZEOF (int) ; - else - count = (int) templen ; - - if (pdata->read_int (psf, inptr, count) != count) - { psf->error = SFE_INTERLEAVE_READ ; - return 0 ; - } ; - - for (k = 0 ; k < count ; k++) - { *outptr = inptr [k] ; - outptr += psf->sf.channels ; - } ; - - templen -= count ; - } ; - } ; - - return len ; -} /* interleave_read_int */ - -static sf_count_t -interleave_read_float (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ INTERLEAVE_DATA *pdata ; - sf_count_t offset, templen ; - int chan, count, k ; - float *inptr, *outptr ; - - if (! (pdata = psf->interleave)) - return 0 ; - - inptr = (float*) pdata->buffer ; - - for (chan = 0 ; chan < psf->sf.channels ; chan++) - { outptr = ptr + chan ; - - offset = psf->dataoffset + pdata->channel_len * chan + psf->read_current * psf->bytewidth ; - -/*-printf ("chan : %d read_current : %6lld offset : %6lld\n", chan, psf->read_current, offset) ;-*/ - - if (psf_fseek (psf, offset, SEEK_SET) != offset) - { psf->error = SFE_INTERLEAVE_SEEK ; -/*-puts ("interleave_seek error") ; exit (1) ;-*/ - return 0 ; - } ; - - templen = len / psf->sf.channels ; - - while (templen > 0) - { if (templen > SIGNED_SIZEOF (pdata->buffer) / SIGNED_SIZEOF (float)) - count = SIGNED_SIZEOF (pdata->buffer) / SIGNED_SIZEOF (float) ; - else - count = (int) templen ; - - if (pdata->read_float (psf, inptr, count) != count) - { psf->error = SFE_INTERLEAVE_READ ; -/*-puts ("interleave_read error") ; exit (1) ;-*/ - return 0 ; - } ; - - for (k = 0 ; k < count ; k++) - { *outptr = inptr [k] ; - outptr += psf->sf.channels ; - } ; - - templen -= count ; - } ; - } ; - - return len ; -} /* interleave_read_float */ - -static sf_count_t -interleave_read_double (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ INTERLEAVE_DATA *pdata ; - sf_count_t offset, templen ; - int chan, count, k ; - double *inptr, *outptr ; - - if (! (pdata = psf->interleave)) - return 0 ; - - inptr = (double*) pdata->buffer ; - - for (chan = 0 ; chan < psf->sf.channels ; chan++) - { outptr = ptr + chan ; - - offset = psf->dataoffset + chan * psf->bytewidth * psf->read_current ; - - if (psf_fseek (psf, offset, SEEK_SET) != offset) - { psf->error = SFE_INTERLEAVE_SEEK ; - return 0 ; - } ; - - templen = len / psf->sf.channels ; - - while (templen > 0) - { if (templen > SIGNED_SIZEOF (pdata->buffer) / SIGNED_SIZEOF (double)) - count = SIGNED_SIZEOF (pdata->buffer) / SIGNED_SIZEOF (double) ; - else - count = (int) templen ; - - if (pdata->read_double (psf, inptr, count) != count) - { psf->error = SFE_INTERLEAVE_READ ; - return 0 ; - } ; - - for (k = 0 ; k < count ; k++) - { *outptr = inptr [k] ; - outptr += psf->sf.channels ; - } ; - - templen -= count ; - } ; - } ; - - return len ; -} /* interleave_read_double */ - -/*------------------------------------------------------------------------------ -*/ - -static sf_count_t -interleave_seek (SF_PRIVATE * UNUSED (psf), int UNUSED (mode), sf_count_t samples_from_start) -{ - /* - ** Do nothing here. This is a place holder to prevent the default - ** seek function from being called. - */ - - return samples_from_start ; -} /* interleave_seek */ - diff --git a/Engine/lib/libsndfile/src/ircam.c b/Engine/lib/libsndfile/src/ircam.c deleted file mode 100644 index 8e7cdba81..000000000 --- a/Engine/lib/libsndfile/src/ircam.c +++ /dev/null @@ -1,323 +0,0 @@ -/* -** Copyright (C) 2001-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -/* The IRCAM magic number is weird in that one byte in the number can have -** values of 0x1, 0x2, 0x03 or 0x04. Hence the need for a marker and a mask. -*/ - -#define IRCAM_BE_MASK (MAKE_MARKER (0xFF, 0xFF, 0x00, 0xFF)) -#define IRCAM_BE_MARKER (MAKE_MARKER (0x64, 0xA3, 0x00, 0x00)) - -#define IRCAM_LE_MASK (MAKE_MARKER (0xFF, 0x00, 0xFF, 0xFF)) -#define IRCAM_LE_MARKER (MAKE_MARKER (0x00, 0x00, 0xA3, 0x64)) - -#define IRCAM_02B_MARKER (MAKE_MARKER (0x64, 0xA3, 0x02, 0x00)) -#define IRCAM_03L_MARKER (MAKE_MARKER (0x64, 0xA3, 0x03, 0x00)) - -#define IRCAM_DATA_OFFSET (1024) - -/*------------------------------------------------------------------------------ -** Typedefs. -*/ - -enum -{ IRCAM_PCM_16 = 0x00002, - IRCAM_FLOAT = 0x00004, - IRCAM_ALAW = 0x10001, - IRCAM_ULAW = 0x20001, - IRCAM_PCM_32 = 0x40004 -} ; - - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int ircam_close (SF_PRIVATE *psf) ; -static int ircam_write_header (SF_PRIVATE *psf, int calc_length) ; -static int ircam_read_header (SF_PRIVATE *psf) ; - -static int get_encoding (int subformat) ; - -static const char* get_encoding_str (int encoding) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -ircam_open (SF_PRIVATE *psf) -{ int subformat ; - int error = SFE_NO_ERROR ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = ircam_read_header (psf))) - return error ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_IRCAM) - return SFE_BAD_OPEN_FORMAT ; - - psf->endian = SF_ENDIAN (psf->sf.format) ; - if (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU) - psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ; - - psf->dataoffset = IRCAM_DATA_OFFSET ; - - if ((error = ircam_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = ircam_write_header ; - } ; - - psf->container_close = ircam_close ; - - switch (subformat) - { case SF_FORMAT_ULAW : /* 8-bit Ulaw encoding. */ - error = ulaw_init (psf) ; - break ; - - case SF_FORMAT_ALAW : /* 8-bit Alaw encoding. */ - error = alaw_init (psf) ; - break ; - - case SF_FORMAT_PCM_16 : /* 16-bit linear PCM. */ - case SF_FORMAT_PCM_32 : /* 32-bit linear PCM. */ - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_FLOAT : /* 32-bit linear PCM. */ - error = float32_init (psf) ; - break ; - - default : break ; - } ; - - return error ; -} /* ircam_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -ircam_read_header (SF_PRIVATE *psf) -{ unsigned int marker, encoding ; - float samplerate ; - int error = SFE_NO_ERROR ; - - psf_binheader_readf (psf, "epmf44", 0, &marker, &samplerate, &(psf->sf.channels), &encoding) ; - - if (((marker & IRCAM_BE_MASK) != IRCAM_BE_MARKER) && ((marker & IRCAM_LE_MASK) != IRCAM_LE_MARKER)) - { psf_log_printf (psf, "marker: 0x%X\n", marker) ; - return SFE_IRCAM_NO_MARKER ; - } ; - - psf->endian = SF_ENDIAN_LITTLE ; - - if (psf->sf.channels > SF_MAX_CHANNELS) - { psf_binheader_readf (psf, "Epmf44", 0, &marker, &samplerate, &(psf->sf.channels), &encoding) ; - - /* Sanity checking for endian-ness detection. */ - if (psf->sf.channels > SF_MAX_CHANNELS) - { psf_log_printf (psf, "marker: 0x%X\n", marker) ; - return SFE_IRCAM_BAD_CHANNELS ; - } ; - - psf->endian = SF_ENDIAN_BIG ; - } ; - - psf_log_printf (psf, "marker: 0x%X\n", marker) ; - - psf->sf.samplerate = (int) samplerate ; - - psf_log_printf (psf, " Sample Rate : %d\n" - " Channels : %d\n" - " Encoding : %X => %s\n", - psf->sf.samplerate, psf->sf.channels, encoding, get_encoding_str (encoding)) ; - - switch (encoding) - { case IRCAM_PCM_16 : - psf->bytewidth = 2 ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_16 ; - break ; - - case IRCAM_PCM_32 : - psf->bytewidth = 4 ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_32 ; - break ; - - case IRCAM_FLOAT : - psf->bytewidth = 4 ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_FLOAT ; - break ; - - case IRCAM_ALAW : - psf->bytewidth = 1 ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ALAW ; - break ; - - case IRCAM_ULAW : - psf->bytewidth = 1 ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_ULAW ; - break ; - - default : - error = SFE_IRCAM_UNKNOWN_FORMAT ; - break ; - } ; - - if (psf->endian == SF_ENDIAN_BIG) - psf->sf.format |= SF_ENDIAN_BIG ; - else - psf->sf.format |= SF_ENDIAN_LITTLE ; - - if (error) - return error ; - - psf->dataoffset = IRCAM_DATA_OFFSET ; - psf->datalength = psf->filelength - psf->dataoffset ; - - if (psf->sf.frames == 0 && psf->blockwidth) - psf->sf.frames = psf->datalength / psf->blockwidth ; - - psf_log_printf (psf, " Samples : %d\n", psf->sf.frames) ; - - psf_binheader_readf (psf, "p", IRCAM_DATA_OFFSET) ; - - return 0 ; -} /* ircam_read_header */ - -static int -ircam_close (SF_PRIVATE *psf) -{ - psf_log_printf (psf, "close\n") ; - - return 0 ; -} /* ircam_close */ - -static int -ircam_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ int encoding ; - float samplerate ; - sf_count_t current ; - - if (psf->pipeoffset > 0) - return 0 ; - - current = psf_ftell (psf) ; - - /* This also sets psf->endian. */ - encoding = get_encoding (SF_CODEC (psf->sf.format)) ; - - if (encoding == 0) - return SFE_BAD_OPEN_FORMAT ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - if (psf->is_pipe == SF_FALSE) - psf_fseek (psf, 0, SEEK_SET) ; - - samplerate = psf->sf.samplerate ; - - switch (psf->endian) - { case SF_ENDIAN_BIG : - psf_binheader_writef (psf, "Emf", BHWm (IRCAM_02B_MARKER), BHWf (samplerate)) ; - psf_binheader_writef (psf, "E44", BHW4 (psf->sf.channels), BHW4 (encoding)) ; - break ; - - case SF_ENDIAN_LITTLE : - psf_binheader_writef (psf, "emf", BHWm (IRCAM_03L_MARKER), BHWf (samplerate)) ; - psf_binheader_writef (psf, "e44", BHW4 (psf->sf.channels), BHW4 (encoding)) ; - break ; - - default : return SFE_BAD_OPEN_FORMAT ; - } ; - - psf_binheader_writef (psf, "z", BHWz ((size_t) (IRCAM_DATA_OFFSET - psf->header.indx))) ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* ircam_write_header */ - -static int -get_encoding (int subformat) -{ switch (subformat) - { case SF_FORMAT_PCM_16 : return IRCAM_PCM_16 ; - case SF_FORMAT_PCM_32 : return IRCAM_PCM_32 ; - - case SF_FORMAT_FLOAT : return IRCAM_FLOAT ; - - case SF_FORMAT_ULAW : return IRCAM_ULAW ; - case SF_FORMAT_ALAW : return IRCAM_ALAW ; - - default : break ; - } ; - - return 0 ; -} /* get_encoding */ - -static const char* -get_encoding_str (int encoding) -{ switch (encoding) - { case IRCAM_PCM_16 : return "16 bit PCM" ; - case IRCAM_FLOAT : return "32 bit float" ; - case IRCAM_ALAW : return "A law" ; - case IRCAM_ULAW : return "u law" ; - case IRCAM_PCM_32 : return "32 bit PCM" ; - } ; - return "Unknown encoding" ; -} /* get_encoding_str */ - diff --git a/Engine/lib/libsndfile/src/macos.c b/Engine/lib/libsndfile/src/macos.c deleted file mode 100644 index 5f6c53191..000000000 --- a/Engine/lib/libsndfile/src/macos.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Copyright (C) 2003-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#define STR_MARKER MAKE_MARKER ('S', 'T', 'R', ' ') - -int -macos_guess_file_type (SF_PRIVATE * psf, const char *filename) -{ static char rsrc_name [1024] ; - struct stat statbuf ; - - snprintf (rsrc_name, sizeof (rsrc_name), "%s/rsrc", filename) ; - - /* If there is no resource fork, just return. */ - if (stat (rsrc_name, &statbuf) != 0) - { psf_log_printf (psf, "No resource fork.\n") ; - return 0 ; - } ; - - if (statbuf.st_size == 0) - { psf_log_printf (psf, "Have zero size resource fork.\n") ; - return 0 ; - } ; - - return 0 ; -} /* macos_guess_file_type */ - diff --git a/Engine/lib/libsndfile/src/make-static-lib-hidden-privates.sh b/Engine/lib/libsndfile/src/make-static-lib-hidden-privates.sh deleted file mode 100644 index 5bfd485d2..000000000 --- a/Engine/lib/libsndfile/src/make-static-lib-hidden-privates.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -e - -# This script takes a static library and removes all non-public symbols. -# Ie, it makes a static lib whose symbols are far less likely to clash with -# the symbols of another shared or static library. - -grep sf_ Symbols.gnu-binutils | sed -e "s/[ ;]//g" > Symbols.static - -ld -r --whole-archive .libs/libsndfile.a -o libsndfile_a.o - -objcopy --keep-global-symbols=Symbols.static libsndfile_a.o libsndfile.o - -rm -f libsndfile.a -ar cru libsndfile.a libsndfile.o diff --git a/Engine/lib/libsndfile/src/mat4.c b/Engine/lib/libsndfile/src/mat4.c deleted file mode 100644 index 0b1b414b4..000000000 --- a/Engine/lib/libsndfile/src/mat4.c +++ /dev/null @@ -1,391 +0,0 @@ -/* -** Copyright (C) 2002-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -** Information on how to decode and encode this file was obtained in a PDF -** file which I found on http://www.wotsit.org/. -** Also did a lot of testing with GNU Octave but do not have access to -** Matlab (tm) and so could not test it there. -*/ - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -#define MAT4_BE_DOUBLE (MAKE_MARKER (0, 0, 0x03, 0xE8)) -#define MAT4_LE_DOUBLE (MAKE_MARKER (0, 0, 0, 0)) - -#define MAT4_BE_FLOAT (MAKE_MARKER (0, 0, 0x03, 0xF2)) -#define MAT4_LE_FLOAT (MAKE_MARKER (0x0A, 0, 0, 0)) - -#define MAT4_BE_PCM_32 (MAKE_MARKER (0, 0, 0x03, 0xFC)) -#define MAT4_LE_PCM_32 (MAKE_MARKER (0x14, 0, 0, 0)) - -#define MAT4_BE_PCM_16 (MAKE_MARKER (0, 0, 0x04, 0x06)) -#define MAT4_LE_PCM_16 (MAKE_MARKER (0x1E, 0, 0, 0)) - -/* Can't see any reason to ever implement this. */ -#define MAT4_BE_PCM_U8 (MAKE_MARKER (0, 0, 0x04, 0x1A)) -#define MAT4_LE_PCM_U8 (MAKE_MARKER (0x32, 0, 0, 0)) - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int mat4_close (SF_PRIVATE *psf) ; - -static int mat4_format_to_encoding (int format, int endian) ; - -static int mat4_write_header (SF_PRIVATE *psf, int calc_length) ; -static int mat4_read_header (SF_PRIVATE *psf) ; - -static const char * mat4_marker_to_str (int marker) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -mat4_open (SF_PRIVATE *psf) -{ int subformat, error = 0 ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = mat4_read_header (psf))) - return error ; - } ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MAT4) - return SFE_BAD_OPEN_FORMAT ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (psf->is_pipe) - return SFE_NO_PIPE_WRITE ; - - psf->endian = SF_ENDIAN (psf->sf.format) ; - if (CPU_IS_LITTLE_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0)) - psf->endian = SF_ENDIAN_LITTLE ; - else if (CPU_IS_BIG_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0)) - psf->endian = SF_ENDIAN_BIG ; - - if ((error = mat4_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = mat4_write_header ; - } ; - - psf->container_close = mat4_close ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - switch (subformat) - { case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_32 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_FLOAT : - error = float32_init (psf) ; - break ; - - case SF_FORMAT_DOUBLE : - error = double64_init (psf) ; - break ; - - default : break ; - } ; - - return error ; -} /* mat4_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -mat4_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - mat4_write_header (psf, SF_TRUE) ; - - return 0 ; -} /* mat4_close */ - -/*------------------------------------------------------------------------------ -*/ - -static int -mat4_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t current ; - int encoding ; - double samplerate ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - encoding = mat4_format_to_encoding (SF_CODEC (psf->sf.format), psf->endian) ; - - if (encoding == -1) - return SFE_BAD_OPEN_FORMAT ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - /* Need sample rate as a double for writing to the header. */ - samplerate = psf->sf.samplerate ; - - if (psf->endian == SF_ENDIAN_BIG) - { psf_binheader_writef (psf, "Em444", BHWm (MAT4_BE_DOUBLE), BHW4 (1), BHW4 (1), BHW4 (0)) ; - psf_binheader_writef (psf, "E4bd", BHW4 (11), BHWv ("samplerate"), BHWz (11), BHWd (samplerate)) ; - psf_binheader_writef (psf, "tEm484", BHWm (encoding), BHW4 (psf->sf.channels), BHW8 (psf->sf.frames), BHW4 (0)) ; - psf_binheader_writef (psf, "E4b", BHW4 (9), BHWv ("wavedata"), BHWz (9)) ; - } - else if (psf->endian == SF_ENDIAN_LITTLE) - { psf_binheader_writef (psf, "em444", BHWm (MAT4_LE_DOUBLE), BHW4 (1), BHW4 (1), BHW4 (0)) ; - psf_binheader_writef (psf, "e4bd", BHW4 (11), BHWv ("samplerate"), BHWz (11), BHWd (samplerate)) ; - psf_binheader_writef (psf, "tem484", BHWm (encoding), BHW4 (psf->sf.channels), BHW8 (psf->sf.frames), BHW4 (0)) ; - psf_binheader_writef (psf, "e4b", BHW4 (9), BHWv ("wavedata"), BHWz (9)) ; - } - else - return SFE_BAD_OPEN_FORMAT ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* mat4_write_header */ - -static int -mat4_read_header (SF_PRIVATE *psf) -{ char buffer [256] ; - uint32_t marker, namesize ; - int rows, cols, imag ; - double value ; - const char *marker_str ; - char name [64] ; - - psf_binheader_readf (psf, "pm", 0, &marker) ; - - /* MAT4 file must start with a double for the samplerate. */ - if (marker == MAT4_BE_DOUBLE) - { psf->endian = psf->rwf_endian = SF_ENDIAN_BIG ; - marker_str = "big endian double" ; - } - else if (marker == MAT4_LE_DOUBLE) - { psf->endian = psf->rwf_endian = SF_ENDIAN_LITTLE ; - marker_str = "little endian double" ; - } - else - return SFE_UNIMPLEMENTED ; - - psf_log_printf (psf, "GNU Octave 2.0 / MATLAB v4.2 format\nMarker : %s\n", marker_str) ; - - psf_binheader_readf (psf, "444", &rows, &cols, &imag) ; - - psf_log_printf (psf, " Rows : %d\n Cols : %d\n Imag : %s\n", rows, cols, imag ? "True" : "False") ; - - psf_binheader_readf (psf, "4", &namesize) ; - - if (namesize >= SIGNED_SIZEOF (name)) - return SFE_MAT4_BAD_NAME ; - - psf_binheader_readf (psf, "b", name, namesize) ; - name [namesize] = 0 ; - - psf_log_printf (psf, " Name : %s\n", name) ; - - psf_binheader_readf (psf, "d", &value) ; - - snprintf (buffer, sizeof (buffer), " Value : %f\n", value) ; - psf_log_printf (psf, buffer) ; - - if ((rows != 1) || (cols != 1)) - return SFE_MAT4_NO_SAMPLERATE ; - - psf->sf.samplerate = psf_lrint (value) ; - - /* Now write out the audio data. */ - - psf_binheader_readf (psf, "m", &marker) ; - - psf_log_printf (psf, "Marker : %s\n", mat4_marker_to_str (marker)) ; - - psf_binheader_readf (psf, "444", &rows, &cols, &imag) ; - - psf_log_printf (psf, " Rows : %d\n Cols : %d\n Imag : %s\n", rows, cols, imag ? "True" : "False") ; - - psf_binheader_readf (psf, "4", &namesize) ; - - if (namesize >= SIGNED_SIZEOF (name)) - return SFE_MAT4_BAD_NAME ; - - psf_binheader_readf (psf, "b", name, namesize) ; - name [namesize] = 0 ; - - psf_log_printf (psf, " Name : %s\n", name) ; - - psf->dataoffset = psf_ftell (psf) ; - - if (rows == 0) - { psf_log_printf (psf, "*** Error : zero channel count.\n") ; - return SFE_CHANNEL_COUNT_ZERO ; - } - else if (rows > SF_MAX_CHANNELS) - { psf_log_printf (psf, "*** Error : channel count %d > SF_MAX_CHANNELS.\n", rows) ; - return SFE_CHANNEL_COUNT ; - } ; - - psf->sf.channels = rows ; - psf->sf.frames = cols ; - - psf->sf.format = psf->endian | SF_FORMAT_MAT4 ; - switch (marker) - { case MAT4_BE_DOUBLE : - case MAT4_LE_DOUBLE : - psf->sf.format |= SF_FORMAT_DOUBLE ; - psf->bytewidth = 8 ; - break ; - - case MAT4_BE_FLOAT : - case MAT4_LE_FLOAT : - psf->sf.format |= SF_FORMAT_FLOAT ; - psf->bytewidth = 4 ; - break ; - - case MAT4_BE_PCM_32 : - case MAT4_LE_PCM_32 : - psf->sf.format |= SF_FORMAT_PCM_32 ; - psf->bytewidth = 4 ; - break ; - - case MAT4_BE_PCM_16 : - case MAT4_LE_PCM_16 : - psf->sf.format |= SF_FORMAT_PCM_16 ; - psf->bytewidth = 2 ; - break ; - - default : - psf_log_printf (psf, "*** Error : Bad marker %08X\n", marker) ; - return SFE_UNIMPLEMENTED ; - } ; - - if ((psf->filelength - psf->dataoffset) < psf->sf.channels * psf->sf.frames * psf->bytewidth) - { psf_log_printf (psf, "*** File seems to be truncated. %D <--> %D\n", - psf->filelength - psf->dataoffset, psf->sf.channels * psf->sf.frames * psf->bytewidth) ; - } - else if ((psf->filelength - psf->dataoffset) > psf->sf.channels * psf->sf.frames * psf->bytewidth) - psf->dataend = psf->dataoffset + rows * cols * psf->bytewidth ; - - psf->datalength = psf->filelength - psf->dataoffset - psf->dataend ; - - psf->sf.sections = 1 ; - - return 0 ; -} /* mat4_read_header */ - -static int -mat4_format_to_encoding (int format, int endian) -{ - switch (format | endian) - { case (SF_FORMAT_PCM_16 | SF_ENDIAN_BIG) : - return MAT4_BE_PCM_16 ; - - case (SF_FORMAT_PCM_16 | SF_ENDIAN_LITTLE) : - return MAT4_LE_PCM_16 ; - - case (SF_FORMAT_PCM_32 | SF_ENDIAN_BIG) : - return MAT4_BE_PCM_32 ; - - case (SF_FORMAT_PCM_32 | SF_ENDIAN_LITTLE) : - return MAT4_LE_PCM_32 ; - - case (SF_FORMAT_FLOAT | SF_ENDIAN_BIG) : - return MAT4_BE_FLOAT ; - - case (SF_FORMAT_FLOAT | SF_ENDIAN_LITTLE) : - return MAT4_LE_FLOAT ; - - case (SF_FORMAT_DOUBLE | SF_ENDIAN_BIG) : - return MAT4_BE_DOUBLE ; - - case (SF_FORMAT_DOUBLE | SF_ENDIAN_LITTLE) : - return MAT4_LE_DOUBLE ; - - default : break ; - } ; - - return -1 ; -} /* mat4_format_to_encoding */ - -static const char * -mat4_marker_to_str (int marker) -{ static char str [32] ; - - switch (marker) - { - case MAT4_BE_PCM_16 : return "big endian 16 bit PCM" ; - case MAT4_LE_PCM_16 : return "little endian 16 bit PCM" ; - - case MAT4_BE_PCM_32 : return "big endian 32 bit PCM" ; - case MAT4_LE_PCM_32 : return "little endian 32 bit PCM" ; - - - case MAT4_BE_FLOAT : return "big endian float" ; - case MAT4_LE_FLOAT : return "big endian float" ; - - case MAT4_BE_DOUBLE : return "big endian double" ; - case MAT4_LE_DOUBLE : return "little endian double" ; - } ; - - /* This is a little unsafe but is really only for debugging. */ - str [sizeof (str) - 1] = 0 ; - snprintf (str, sizeof (str) - 1, "%08X", marker) ; - return str ; -} /* mat4_marker_to_str */ - diff --git a/Engine/lib/libsndfile/src/mat5.c b/Engine/lib/libsndfile/src/mat5.c deleted file mode 100644 index da5a6eca0..000000000 --- a/Engine/lib/libsndfile/src/mat5.c +++ /dev/null @@ -1,509 +0,0 @@ -/* -** Copyright (C) 2002-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -** Information on how to decode and encode this file was obtained in a PDF -** file which I found on http://www.wotsit.org/. -** Also did a lot of testing with GNU Octave but do not have access to -** Matlab (tm) and so could not test it there. -*/ - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -#define MATL_MARKER (MAKE_MARKER ('M', 'A', 'T', 'L')) - -#define IM_MARKER (('I' << 8) + 'M') -#define MI_MARKER (('M' << 8) + 'I') - -/*------------------------------------------------------------------------------ -** Enums and typedefs. -*/ - -enum -{ MAT5_TYPE_SCHAR = 0x1, - MAT5_TYPE_UCHAR = 0x2, - MAT5_TYPE_INT16 = 0x3, - MAT5_TYPE_UINT16 = 0x4, - MAT5_TYPE_INT32 = 0x5, - MAT5_TYPE_UINT32 = 0x6, - MAT5_TYPE_FLOAT = 0x7, - MAT5_TYPE_DOUBLE = 0x9, - MAT5_TYPE_ARRAY = 0xE, - - MAT5_TYPE_COMP_USHORT = 0x00020004, - MAT5_TYPE_COMP_UINT = 0x00040006 -} ; - -typedef struct -{ sf_count_t size ; - int rows, cols ; - char name [32] ; -} MAT5_MATRIX ; - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int mat5_close (SF_PRIVATE *psf) ; - -static int mat5_write_header (SF_PRIVATE *psf, int calc_length) ; -static int mat5_read_header (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -mat5_open (SF_PRIVATE *psf) -{ int subformat, error = 0 ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = mat5_read_header (psf))) - return error ; - } ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MAT5) - return SFE_BAD_OPEN_FORMAT ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (psf->is_pipe) - return SFE_NO_PIPE_WRITE ; - - psf->endian = SF_ENDIAN (psf->sf.format) ; - if (CPU_IS_LITTLE_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0)) - psf->endian = SF_ENDIAN_LITTLE ; - else if (CPU_IS_BIG_ENDIAN && (psf->endian == SF_ENDIAN_CPU || psf->endian == 0)) - psf->endian = SF_ENDIAN_BIG ; - - if ((error = mat5_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = mat5_write_header ; - } ; - - psf->container_close = mat5_close ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_32 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_FLOAT : - error = float32_init (psf) ; - break ; - - case SF_FORMAT_DOUBLE : - error = double64_init (psf) ; - break ; - - default : break ; - } ; - - return error ; -} /* mat5_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -mat5_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - mat5_write_header (psf, SF_TRUE) ; - - return 0 ; -} /* mat5_close */ - -/*------------------------------------------------------------------------------ -*/ - -static int -mat5_write_header (SF_PRIVATE *psf, int calc_length) -{ static const char *filename = "MATLAB 5.0 MAT-file, written by " PACKAGE_NAME "-" PACKAGE_VERSION ", " ; - static const char *sr_name = "samplerate\0\0\0\0\0\0\0\0\0\0\0" ; - static const char *wd_name = "wavedata\0" ; - char buffer [256] ; - sf_count_t current, datasize ; - int encoding ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf_fseek (psf, 0, SEEK_END) ; - psf->filelength = psf_ftell (psf) ; - psf_fseek (psf, 0, SEEK_SET) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_U8 : - encoding = MAT5_TYPE_UCHAR ; - break ; - - case SF_FORMAT_PCM_16 : - encoding = MAT5_TYPE_INT16 ; - break ; - - case SF_FORMAT_PCM_32 : - encoding = MAT5_TYPE_INT32 ; - break ; - - case SF_FORMAT_FLOAT : - encoding = MAT5_TYPE_FLOAT ; - break ; - - case SF_FORMAT_DOUBLE : - encoding = MAT5_TYPE_DOUBLE ; - break ; - - default : - return SFE_BAD_OPEN_FORMAT ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - psf_get_date_str (buffer, sizeof (buffer)) ; - psf_binheader_writef (psf, "bb", BHWv (filename), BHWz (strlen (filename)), BHWv (buffer), BHWz (strlen (buffer) + 1)) ; - - memset (buffer, ' ', 124 - psf->header.indx) ; - psf_binheader_writef (psf, "b", BHWv (buffer), BHWz (124 - psf->header.indx)) ; - - psf->rwf_endian = psf->endian ; - - if (psf->rwf_endian == SF_ENDIAN_BIG) - psf_binheader_writef (psf, "2b", BHW2 (0x0100), BHWv ("MI"), BHWz (2)) ; - else - psf_binheader_writef (psf, "2b", BHW2 (0x0100), BHWv ("IM"), BHWz (2)) ; - - psf_binheader_writef (psf, "444444", BHW4 (MAT5_TYPE_ARRAY), BHW4 (64), BHW4 (MAT5_TYPE_UINT32), BHW4 (8), BHW4 (6), BHW4 (0)) ; - psf_binheader_writef (psf, "4444", BHW4 (MAT5_TYPE_INT32), BHW4 (8), BHW4 (1), BHW4 (1)) ; - psf_binheader_writef (psf, "44b", BHW4 (MAT5_TYPE_SCHAR), BHW4 (strlen (sr_name)), BHWv (sr_name), BHWz (16)) ; - - if (psf->sf.samplerate > 0xFFFF) - psf_binheader_writef (psf, "44", BHW4 (MAT5_TYPE_COMP_UINT), BHW4 (psf->sf.samplerate)) ; - else - { unsigned short samplerate = psf->sf.samplerate ; - - psf_binheader_writef (psf, "422", BHW4 (MAT5_TYPE_COMP_USHORT), BHW2 (samplerate), BHW2 (0)) ; - } ; - - datasize = psf->sf.frames * psf->sf.channels * psf->bytewidth ; - - psf_binheader_writef (psf, "t484444", BHW4 (MAT5_TYPE_ARRAY), BHW8 (datasize + 64), BHW4 (MAT5_TYPE_UINT32), BHW4 (8), BHW4 (6), BHW4 (0)) ; - psf_binheader_writef (psf, "t4448", BHW4 (MAT5_TYPE_INT32), BHW4 (8), BHW4 (psf->sf.channels), BHW8 (psf->sf.frames)) ; - psf_binheader_writef (psf, "44b", BHW4 (MAT5_TYPE_SCHAR), BHW4 (strlen (wd_name)), BHWv (wd_name), BHWz (strlen (wd_name))) ; - - datasize = psf->sf.frames * psf->sf.channels * psf->bytewidth ; - if (datasize > 0x7FFFFFFF) - datasize = 0x7FFFFFFF ; - - psf_binheader_writef (psf, "t48", BHW4 (encoding), BHW8 (datasize)) ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* mat5_write_header */ - -static int -mat5_read_header (SF_PRIVATE *psf) -{ char buffer [256], name [32] ; - short version, endian ; - int type, flags1, flags2, rows, cols ; - unsigned size ; - int have_samplerate = 1 ; - - psf_binheader_readf (psf, "pb", 0, buffer, 124) ; - - buffer [125] = 0 ; - - if (strlen (buffer) >= 124) - return SFE_UNIMPLEMENTED ; - - if (strstr (buffer, "MATLAB 5.0 MAT-file") == buffer) - psf_log_printf (psf, "%s\n", buffer) ; - - - psf_binheader_readf (psf, "E22", &version, &endian) ; - - if (endian == MI_MARKER) - { psf->endian = psf->rwf_endian = SF_ENDIAN_BIG ; - if (CPU_IS_LITTLE_ENDIAN) version = ENDSWAP_16 (version) ; - } - else if (endian == IM_MARKER) - { psf->endian = psf->rwf_endian = SF_ENDIAN_LITTLE ; - if (CPU_IS_BIG_ENDIAN) version = ENDSWAP_16 (version) ; - } - else - return SFE_MAT5_BAD_ENDIAN ; - - if ((CPU_IS_LITTLE_ENDIAN && endian == IM_MARKER) || - (CPU_IS_BIG_ENDIAN && endian == MI_MARKER)) - version = ENDSWAP_16 (version) ; - - psf_log_printf (psf, "Version : 0x%04X\n", version) ; - psf_log_printf (psf, "Endian : 0x%04X => %s\n", endian, - (psf->endian == SF_ENDIAN_LITTLE) ? "Little" : "Big") ; - - /*========================================================*/ - psf_binheader_readf (psf, "44", &type, &size) ; - psf_log_printf (psf, "Block\n Type : %X Size : %d\n", type, size) ; - - if (type != MAT5_TYPE_ARRAY) - return SFE_MAT5_NO_BLOCK ; - - psf_binheader_readf (psf, "44", &type, &size) ; - psf_log_printf (psf, " Type : %X Size : %d\n", type, size) ; - - if (type != MAT5_TYPE_UINT32) - return SFE_MAT5_NO_BLOCK ; - - psf_binheader_readf (psf, "44", &flags1, &flags2) ; - psf_log_printf (psf, " Flg1 : %X Flg2 : %d\n", flags1, flags2) ; - - psf_binheader_readf (psf, "44", &type, &size) ; - psf_log_printf (psf, " Type : %X Size : %d\n", type, size) ; - - if (type != MAT5_TYPE_INT32) - return SFE_MAT5_NO_BLOCK ; - - psf_binheader_readf (psf, "44", &rows, &cols) ; - psf_log_printf (psf, " Rows : %d Cols : %d\n", rows, cols) ; - - if (rows != 1 || cols != 1) - { if (psf->sf.samplerate == 0) - psf->sf.samplerate = 44100 ; - have_samplerate = 0 ; - } - psf_binheader_readf (psf, "4", &type) ; - - if (type == MAT5_TYPE_SCHAR) - { psf_binheader_readf (psf, "4", &size) ; - psf_log_printf (psf, " Type : %X Size : %d\n", type, size) ; - if (size > SIGNED_SIZEOF (name) - 1) - { psf_log_printf (psf, "Error : Bad name length.\n") ; - return SFE_MAT5_NO_BLOCK ; - } ; - - psf_binheader_readf (psf, "bj", name, size, (8 - (size % 8)) % 8) ; - name [size] = 0 ; - } - else if ((type & 0xFFFF) == MAT5_TYPE_SCHAR) - { size = type >> 16 ; - if (size > 4) - { psf_log_printf (psf, "Error : Bad name length.\n") ; - return SFE_MAT5_NO_BLOCK ; - } ; - - psf_log_printf (psf, " Type : %X\n", type) ; - psf_binheader_readf (psf, "4", &name) ; - name [size] = 0 ; - } - else - return SFE_MAT5_NO_BLOCK ; - - psf_log_printf (psf, " Name : %s\n", name) ; - - /*-----------------------------------------*/ - - psf_binheader_readf (psf, "44", &type, &size) ; - - if (!have_samplerate) - goto skip_samplerate ; - - switch (type) - { case MAT5_TYPE_DOUBLE : - { double samplerate ; - - psf_binheader_readf (psf, "d", &samplerate) ; - snprintf (name, sizeof (name), "%f\n", samplerate) ; - psf_log_printf (psf, " Val : %s\n", name) ; - - psf->sf.samplerate = psf_lrint (samplerate) ; - } ; - break ; - - case MAT5_TYPE_COMP_USHORT : - { unsigned short samplerate ; - - psf_binheader_readf (psf, "j2j", -4, &samplerate, 2) ; - psf_log_printf (psf, " Val : %u\n", samplerate) ; - psf->sf.samplerate = samplerate ; - } - break ; - - case MAT5_TYPE_COMP_UINT : - psf_log_printf (psf, " Val : %u\n", size) ; - psf->sf.samplerate = size ; - break ; - - default : - psf_log_printf (psf, " Type : %X Size : %d ***\n", type, size) ; - return SFE_MAT5_SAMPLE_RATE ; - } ; - - /*-----------------------------------------*/ - - - psf_binheader_readf (psf, "44", &type, &size) ; - psf_log_printf (psf, " Type : %X Size : %d\n", type, size) ; - - if (type != MAT5_TYPE_ARRAY) - return SFE_MAT5_NO_BLOCK ; - - psf_binheader_readf (psf, "44", &type, &size) ; - psf_log_printf (psf, " Type : %X Size : %d\n", type, size) ; - - if (type != MAT5_TYPE_UINT32) - return SFE_MAT5_NO_BLOCK ; - - psf_binheader_readf (psf, "44", &flags1, &flags2) ; - psf_log_printf (psf, " Flg1 : %X Flg2 : %d\n", flags1, flags2) ; - - psf_binheader_readf (psf, "44", &type, &size) ; - psf_log_printf (psf, " Type : %X Size : %d\n", type, size) ; - - if (type != MAT5_TYPE_INT32) - return SFE_MAT5_NO_BLOCK ; - - psf_binheader_readf (psf, "44", &rows, &cols) ; - psf_log_printf (psf, " Rows : %X Cols : %d\n", rows, cols) ; - - psf_binheader_readf (psf, "4", &type) ; - - if (type == MAT5_TYPE_SCHAR) - { psf_binheader_readf (psf, "4", &size) ; - psf_log_printf (psf, " Type : %X Size : %d\n", type, size) ; - if (size > SIGNED_SIZEOF (name) - 1) - { psf_log_printf (psf, "Error : Bad name length.\n") ; - return SFE_MAT5_NO_BLOCK ; - } ; - - psf_binheader_readf (psf, "bj", name, size, (8 - (size % 8)) % 8) ; - name [size] = 0 ; - } - else if ((type & 0xFFFF) == MAT5_TYPE_SCHAR) - { size = type >> 16 ; - if (size > 4) - { psf_log_printf (psf, "Error : Bad name length.\n") ; - return SFE_MAT5_NO_BLOCK ; - } ; - - psf_log_printf (psf, " Type : %X\n", type) ; - psf_binheader_readf (psf, "4", &name) ; - name [size] = 0 ; - } - else - return SFE_MAT5_NO_BLOCK ; - - psf_log_printf (psf, " Name : %s\n", name) ; - - psf_binheader_readf (psf, "44", &type, &size) ; - psf_log_printf (psf, " Type : %X Size : %d\n", type, size) ; - -skip_samplerate : - /*++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - if (rows == 0 && cols == 0) - { psf_log_printf (psf, "*** Error : zero channel count.\n") ; - return SFE_CHANNEL_COUNT_ZERO ; - } ; - - psf->sf.channels = rows ; - psf->sf.frames = cols ; - - psf->sf.format = psf->endian | SF_FORMAT_MAT5 ; - - switch (type) - { case MAT5_TYPE_DOUBLE : - psf_log_printf (psf, "Data type : double\n") ; - psf->sf.format |= SF_FORMAT_DOUBLE ; - psf->bytewidth = 8 ; - break ; - - case MAT5_TYPE_FLOAT : - psf_log_printf (psf, "Data type : float\n") ; - psf->sf.format |= SF_FORMAT_FLOAT ; - psf->bytewidth = 4 ; - break ; - - case MAT5_TYPE_INT32 : - psf_log_printf (psf, "Data type : 32 bit PCM\n") ; - psf->sf.format |= SF_FORMAT_PCM_32 ; - psf->bytewidth = 4 ; - break ; - - case MAT5_TYPE_INT16 : - psf_log_printf (psf, "Data type : 16 bit PCM\n") ; - psf->sf.format |= SF_FORMAT_PCM_16 ; - psf->bytewidth = 2 ; - break ; - - case MAT5_TYPE_UCHAR : - psf_log_printf (psf, "Data type : unsigned 8 bit PCM\n") ; - psf->sf.format |= SF_FORMAT_PCM_U8 ; - psf->bytewidth = 1 ; - break ; - - default : - psf_log_printf (psf, "*** Error : Bad marker %08X\n", type) ; - return SFE_UNIMPLEMENTED ; - } ; - - psf->dataoffset = psf_ftell (psf) ; - psf->datalength = psf->filelength - psf->dataoffset ; - - return 0 ; -} /* mat5_read_header */ - diff --git a/Engine/lib/libsndfile/src/mpc2k.c b/Engine/lib/libsndfile/src/mpc2k.c deleted file mode 100644 index 733f1f4bc..000000000 --- a/Engine/lib/libsndfile/src/mpc2k.c +++ /dev/null @@ -1,202 +0,0 @@ -/* -** Copyright (C) 2008-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/* -** Info from Olivier Tristan -** -** HEADER -** 2 magic bytes: 1 and 4. -** 17 char for the name of the sample. -** 3 bytes: level, tune and channels (0 for channels is mono while 1 is stereo) -** 4 uint32: sampleStart, loopEnd, sampleFrames and loopLength -** 1 byte: loopMode (0 no loop, 1 forward looping) -** 1 byte: number of beat in loop -** 1 uint16: sampleRate -** -** DATA -** Data are always non compressed 16 bits interleaved -*/ - -#define HEADER_LENGTH 42 /* Sum of above data fields. */ -#define HEADER_NAME_LEN 17 /* Length of name string. */ - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int mpc2k_close (SF_PRIVATE *psf) ; - -static int mpc2k_write_header (SF_PRIVATE *psf, int calc_length) ; -static int mpc2k_read_header (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -mpc2k_open (SF_PRIVATE *psf) -{ int error = 0 ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = mpc2k_read_header (psf))) - return error ; - } ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_MPC2K) - return SFE_BAD_OPEN_FORMAT ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (mpc2k_write_header (psf, SF_FALSE)) - return psf->error ; - - psf->write_header = mpc2k_write_header ; - } ; - - psf->container_close = mpc2k_close ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - error = pcm_init (psf) ; - - return error ; -} /* mpc2k_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -mpc2k_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - mpc2k_write_header (psf, SF_TRUE) ; - - return 0 ; -} /* mpc2k_close */ - -static int -mpc2k_write_header (SF_PRIVATE *psf, int calc_length) -{ char sample_name [HEADER_NAME_LEN + 1] ; - sf_count_t current ; - - if (psf->pipeoffset > 0) - return 0 ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->dataoffset = HEADER_LENGTH ; - psf->datalength = psf->filelength - psf->dataoffset ; - - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - /* - ** Only attempt to seek if we are not writng to a pipe. If we are - ** writing to a pipe we shouldn't be here anyway. - */ - if (psf->is_pipe == SF_FALSE) - psf_fseek (psf, 0, SEEK_SET) ; - - snprintf (sample_name, sizeof (sample_name), "%-*.*s", HEADER_NAME_LEN, HEADER_NAME_LEN, psf->file.name) ; - - psf_binheader_writef (psf, "e11b", BHW1 (1), BHW1 (4), BHWv (sample_name), BHWz (HEADER_NAME_LEN)) ; - psf_binheader_writef (psf, "e111", BHW1 (100), BHW1 (0), BHW1 ((psf->sf.channels - 1) & 1)) ; - psf_binheader_writef (psf, "et4888", BHW4 (0), BHW8 (psf->sf.frames), BHW8 (psf->sf.frames), BHW8 (psf->sf.frames)) ; - psf_binheader_writef (psf, "e112", BHW1 (0), BHW1 (1), BHW2 ((uint16_t) psf->sf.samplerate)) ; - - /* Always 16 bit little endian data. */ - psf->bytewidth = 2 ; - psf->endian = SF_ENDIAN_LITTLE ; - - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* mpc2k_write_header */ - -static int -mpc2k_read_header (SF_PRIVATE *psf) -{ char sample_name [HEADER_NAME_LEN + 1] ; - unsigned char bytes [4] ; - uint32_t sample_start, loop_end, sample_frames, loop_length ; - uint16_t sample_rate ; - - psf_binheader_readf (psf, "pebb", 0, bytes, 2, sample_name, make_size_t (HEADER_NAME_LEN)) ; - - if (bytes [0] != 1 || bytes [1] != 4) - return SFE_MPC_NO_MARKER ; - - sample_name [HEADER_NAME_LEN] = 0 ; - - psf_log_printf (psf, "MPC2000\n Name : %s\n", sample_name) ; - - psf_binheader_readf (psf, "eb4444", bytes, 3, &sample_start, &loop_end, &sample_frames, &loop_length) ; - - psf->sf.channels = bytes [2] ? 2 : 1 ; - - psf_log_printf (psf, " Level : %d\n Tune : %d\n Stereo : %s\n", bytes [0], bytes [1], bytes [2] ? "Yes" : "No") ; - - psf_log_printf (psf, " Sample start : %d\n Loop end : %d\n Frames : %d\n Length : %d\n", sample_start, loop_end, sample_frames, loop_length) ; - - psf_binheader_readf (psf, "eb2", bytes, 2, &sample_rate) ; - - psf_log_printf (psf, " Loop mode : %s\n Beats : %d\n Sample rate : %d\nEnd\n", bytes [0] ? "None" : "Fwd", bytes [1], sample_rate) ; - - psf->sf.samplerate = sample_rate ; - - psf->sf.format = SF_FORMAT_MPC2K | SF_FORMAT_PCM_16 ; - - psf->dataoffset = psf_ftell (psf) ; - - /* Always 16 bit little endian data. */ - psf->bytewidth = 2 ; - psf->endian = SF_ENDIAN_LITTLE ; - - psf->datalength = psf->filelength - psf->dataoffset ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - psf->sf.frames = psf->datalength / psf->blockwidth ; - - psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - - return 0 ; -} /* mpc2k_read_header */ - diff --git a/Engine/lib/libsndfile/src/mpeg.c b/Engine/lib/libsndfile/src/mpeg.c deleted file mode 100644 index 44db0adfb..000000000 --- a/Engine/lib/libsndfile/src/mpeg.c +++ /dev/null @@ -1,165 +0,0 @@ -/* -** Copyright (C) 2019 Erik de Castro Lopo -** Copyright (C) 2021 Arthur Taylor -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include "sndfile.h" -#include "common.h" - -#if HAVE_MPEG - -#include "mpeg.h" - -static int mpeg_write_header (SF_PRIVATE *psf, int calc_length) ; -static int mpeg_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; - -/*------------------------------------------------------------------------------ - * Private functions - */ - -static int -mpeg_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ - if (psf->have_written) - return 0 ; - - return mpeg_l3_encoder_write_id3tag (psf) ; -} - -static int -mpeg_command (SF_PRIVATE *psf, int command, void *data, int datasize) -{ int bitrate_mode ; - - switch (command) - { case SFC_SET_COMPRESSION_LEVEL : - if (data == NULL || datasize != sizeof (double)) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - if (psf->file.mode != SFM_WRITE) - { psf->error = SFE_NOT_WRITEMODE ; - return SF_FALSE ; - } ; - return mpeg_l3_encoder_set_quality (psf, *(double *) data) ; - - case SFC_SET_BITRATE_MODE : - if (psf->file.mode != SFM_WRITE) - { psf->error = SFE_NOT_WRITEMODE ; - return SF_FALSE ; - } ; - if (data == NULL || datasize != sizeof (int)) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - bitrate_mode = *(int *) data ; - return mpeg_l3_encoder_set_bitrate_mode (psf, bitrate_mode) ; - - case SFC_GET_BITRATE_MODE : - if (psf->file.mode == SFM_READ) - return mpeg_decoder_get_bitrate_mode (psf) ; - else - return mpeg_l3_encoder_get_bitrate_mode (psf) ; - - default : - return SF_FALSE ; - } ; - - return SF_FALSE ; -} /* mpeg_command */ - -/*------------------------------------------------------------------------------ - * Public functions - */ - -int -mpeg_init (SF_PRIVATE *psf, int bitrate_mode, int write_metadata) -{ int error ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode == SFM_WRITE) - { switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_MPEG_LAYER_III : - if ((error = mpeg_l3_encoder_init (psf, write_metadata))) - return error ; - mpeg_l3_encoder_set_bitrate_mode (psf, bitrate_mode) ; - if (write_metadata) - { /* ID3 support */ - psf->strings.flags = SF_STR_ALLOW_START ; - psf->write_header = mpeg_write_header ; - } ; - break ; - - case SF_FORMAT_MPEG_LAYER_I : - case SF_FORMAT_MPEG_LAYER_II : - psf_log_printf (psf, "MPEG Layer I and II encoding is not yet supported.\n") ; - return SFE_UNIMPLEMENTED ; - - default: - psf_log_printf (psf, "%s: bad psf->sf.format 0x%x.\n", __func__, psf->sf.format) ; - return SFE_INTERNAL ; - } ; - } ; - - if (psf->file.mode == SFM_READ) - { if ((error = mpeg_decoder_init (psf))) - return error ; - } ; - - return 0 ; -} /* mpeg_init */ - -int -mpeg_open (SF_PRIVATE *psf) -{ int error ; - - /* Choose variable bitrate mode by default for standalone files.*/ - if ((error = mpeg_init (psf, SF_BITRATE_MODE_VARIABLE, SF_TRUE))) - return error ; - - psf->dataoffset = 0 ; - psf->command = mpeg_command ; - - if (psf->filelength != SF_COUNT_MAX) - psf->datalength = psf->filelength - psf->dataoffset ; - else - psf->datalength = SF_COUNT_MAX ; - - - return 0 ; -} /* mpeg_open */ - -#else /* HAVE_MPEG */ - -int -mpeg_init (SF_PRIVATE *psf, int UNUSED (bitrate_mode) , int UNUSED (write_metadata)) -{ - psf_log_printf (psf, "This version of libsndfile was compiled without MPEG support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* mpeg_init */ - -int -mpeg_open (SF_PRIVATE *psf) -{ - psf_log_printf (psf, "This version of libsndfile was compiled without MP3 support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* mpeg_open */ - -#endif diff --git a/Engine/lib/libsndfile/src/mpeg.h b/Engine/lib/libsndfile/src/mpeg.h deleted file mode 100644 index f335745f7..000000000 --- a/Engine/lib/libsndfile/src/mpeg.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Copyright (C) 2019 Erik de Castro Lopo -** Copyright (C) 2019 Arthur Taylor -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SNDFILE_MPEG_H -#define SNDFILE_MPEG_H - -#include "common.h" - -int mpeg_decoder_init (SF_PRIVATE *psf) ; - -/* -** Get the file bitrate mode, returning one of the SF_BITRATE_MODE_ enum -** values. Purely informative, 'Frankenstein' files and VBR files without an -** Xing/LAME/Info header may not be detected properly. -*/ -int mpeg_decoder_get_bitrate_mode (SF_PRIVATE *psf) ; - - -/* -** Initialize an encoder instance for writing. If parameter info_tag is -** SF_TRUE, a Xing/LAME/Info header is written at the beginning of the file, -** (unless the file cannot seek.) -*/ -int mpeg_l3_encoder_init (SF_PRIVATE *psf, int info_tag) ; - - -/* -** Write an ID3v2 header from the sndfile string metadata. Must be called -** before any audio data is written. Writing an ID3v2 header will also cause -** a ID3v1 trailer to be written on close automatically. -*/ -int mpeg_l3_encoder_write_id3tag (SF_PRIVATE *psf) ; - -/* -** Set the encoder quality setting. Argument to compression should be identical -** to that for SFC_SET_COMPRESSION_LEVEL; It should be in the range [0-1], -** with 0 being highest quality, least compression, and 1 being the opposite. -** Returns SF_TRUE on success, SF_FALSE otherwise. -*/ -int mpeg_l3_encoder_set_quality (SF_PRIVATE *psf, double compression) ; - -/* -** Set the encoder bitrate mode. Can only be called before any data has been -** written. Argument mode should be one of the SF_BITRATE_MODE_ enum values. -** Returns SF_TRUE on success, SF_FALSE otherwise. The SF_BITRATE_MODE_FILE -** enum value should not be passed here but rather intercepted at the container -** level and translated according to the container. -*/ -int mpeg_l3_encoder_set_bitrate_mode (SF_PRIVATE *psf, int mode) ; - -/* -** Get the encoder bitrate mode in use. Returns a SF_BITRATE_MODE_ enum value. -** Will not return SF_BITRATE_MODE_FILE. -*/ -int mpeg_l3_encoder_get_bitrate_mode (SF_PRIVATE *psf) ; - - -#endif /* SNDFILE_MPEG_H */ diff --git a/Engine/lib/libsndfile/src/mpeg_decode.c b/Engine/lib/libsndfile/src/mpeg_decode.c deleted file mode 100644 index aaf12bf9c..000000000 --- a/Engine/lib/libsndfile/src/mpeg_decode.c +++ /dev/null @@ -1,644 +0,0 @@ -/* -** Copyright (C) 2019 - 2021 Arthur Taylor -** Copyright (C) 2019 Erik de Castro Lopo -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include - -#include "sndfile.h" -#include "common.h" -#include "mpeg.h" - -#if HAVE_MPEG - -#include "sfendian.h" -#include "id3.h" - -#include - -typedef struct -{ mpg123_handle *pmh ; - size_t header_remaining ; -} MPEG_DEC_PRIVATE ; - -static int mpeg_dec_close (SF_PRIVATE *psf) ; -static sf_count_t mpeg_dec_seek (SF_PRIVATE *psf, int whence, sf_count_t count) ; - -static ssize_t mpeg_dec_io_read (void *priv, void *buffer, size_t nbytes) ; -static off_t mpeg_dec_io_lseek (void *priv, off_t offset, int whence) ; - -static ssize_t -mpeg_dec_io_read (void *priv, void *buffer, size_t nbytes) -{ SF_PRIVATE *psf = (SF_PRIVATE *) priv ; - MPEG_DEC_PRIVATE *pmp3d = (MPEG_DEC_PRIVATE *) psf->codec_data ; - - if (pmp3d->header_remaining) - { if (pmp3d->header_remaining < nbytes) - nbytes = pmp3d->header_remaining ; - psf_binheader_readf (psf, "b", buffer, nbytes) ; - pmp3d->header_remaining -= nbytes ; - return nbytes ; - } ; - - return psf_fread (buffer, 1, nbytes, psf) ; -} /* mpeg_dec_io_read */ - -static off_t -mpeg_dec_io_lseek (void *priv, off_t offset, int whence) -{ SF_PRIVATE *psf = (SF_PRIVATE *) priv ; - - return psf_fseek (psf, offset, whence) ; -} /* mpeg_dec_io_lseek */ - -static int -mpeg_dec_close (SF_PRIVATE *psf) -{ MPEG_DEC_PRIVATE *pmp3d = (MPEG_DEC_PRIVATE *) psf->codec_data ; - - if (pmp3d) - { if (pmp3d->pmh) - { mpg123_close (pmp3d->pmh) ; - mpg123_delete (pmp3d->pmh) ; - pmp3d->pmh = NULL ; - } - free (psf->codec_data) ; - psf->codec_data = NULL ; - } ; - - return 0 ; -} /* mpeg_dec_close */ - -static sf_count_t -mpeg_dec_decode (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ MPEG_DEC_PRIVATE *pmp3d = (MPEG_DEC_PRIVATE *) psf->codec_data ; - size_t done ; - int error ; - - error = mpg123_read (pmp3d->pmh, (unsigned char *) ptr, len * sizeof (float), &done) ; - - if (error == MPG123_OK || error == MPG123_DONE) - return done / sizeof (float) ; - - if (error == MPG123_NEW_FORMAT) - { psf->error = SFE_MALFORMED_FILE ; - return -1 ; - } ; - - psf->error = SFE_INTERNAL ; - return -1 ; -} /* mpeg_dec_decode */ - -static sf_count_t -mpeg_dec_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - sf_count_t total, readlen ; - void (*convert) (const float *, short *, int, int) ; - const sf_count_t buflen = ARRAY_LEN (ubuf.fbuf) ; - - convert = (psf->add_clipping) ? psf_f2s_clip_array : psf_f2s_array ; - for (total = 0 ; total < len ; total += readlen) - { readlen = mpeg_dec_decode (psf, ubuf.fbuf, SF_MIN (buflen, len - total)) ; - if (readlen <= 0) - break ; - - convert (ubuf.fbuf, ptr + total, readlen, SF_TRUE) ; - } ; - - return total ; -} /*mpeg_dec_read_s */ - -static sf_count_t -mpeg_dec_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - sf_count_t total, readlen ; - void (*convert) (const float *, int *, int, int) ; - const sf_count_t buflen = ARRAY_LEN (ubuf.fbuf) ; - - convert = (psf->add_clipping) ? psf_f2i_clip_array : psf_f2i_array ; - for (total = 0 ; total < len ; total += readlen) - { readlen = mpeg_dec_decode (psf, ubuf.fbuf, SF_MIN (buflen, len - total)) ; - if (readlen <= 0) - break ; - - convert (ubuf.fbuf, ptr + total, readlen, SF_TRUE) ; - } ; - - return total ; -} /* mpeg_dec_read_i */ - -static sf_count_t -mpeg_dec_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ sf_count_t readlen ; - - readlen = mpeg_dec_decode (psf, ptr, len) ; - if (readlen <= 0) - return 0 ; - - if (psf->norm_float == SF_FALSE) - for (int i = 0 ; i < readlen ; i++) - { ptr [i] *= (1.0f * 0x8000) ; - } ; - - return readlen ; -} /* mpeg_dec_read_f */ - -static inline void -f2d_array (const float *src, int count, double *dest, double normfact) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = src [i] * normfact ; - } -} /* f2d_array */ - -static sf_count_t -mpeg_dec_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - sf_count_t total, readlen ; - double normfact ; - const sf_count_t buflen = ARRAY_LEN (ubuf.fbuf) ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 : (1.0 * 0x8000) ; - - for (total = 0 ; total < len ; total += readlen) - { readlen = mpeg_dec_decode (psf, ubuf.fbuf, SF_MIN (buflen, len - total)) ; - if (readlen <= 0) - break ; - - f2d_array (ubuf.fbuf, readlen, ptr + total, normfact) ; - } ; - - return total ; -} /* mpeg_dec_read_d */ - -static sf_count_t -mpeg_dec_seek (SF_PRIVATE *psf, int mode, sf_count_t count) -{ MPEG_DEC_PRIVATE *pmp3d = (MPEG_DEC_PRIVATE *) psf->codec_data ; - off_t ret ; - - if (mode != SFM_READ || psf->file.mode != SFM_READ) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - ret = mpg123_seek (pmp3d->pmh, count, SEEK_SET) ; - - if (ret < 0) - return PSF_SEEK_ERROR ; - - return (sf_count_t) ret ; -} /* mpeg_dec_seek */ - -static int -mpeg_dec_fill_sfinfo (SF_PRIVATE* psf, mpg123_handle *mh, SF_INFO *info) -{ int error ; - int channels ; - int encoding ; - long rate ; - off_t length ; - - error = mpg123_getformat (mh, &rate, &channels, &encoding) ; - if (error != MPG123_OK) - return error ; - - info->samplerate = rate ; - info->channels = channels ; - - length = mpg123_length (mh) ; - if (length <= 0 && !psf->is_pipe) - { if ((error = mpg123_scan (mh)) != MPG123_OK) - return error ; - length = mpg123_length (mh) ; - } - - if (length >= 0) - { info->frames = length ; - info->seekable = SF_TRUE ; - } - else - { info->frames = SF_COUNT_MAX ; - info->seekable = SF_FALSE ; - } - - /* Force 32-bit float samples. */ - if (encoding != MPG123_ENC_FLOAT_32) - { error = mpg123_format (mh, rate, channels, MPG123_ENC_FLOAT_32) ; - } ; - - return error ; -} /* mpeg_dec_fill_sfinfo */ - -static void -mpeg_dec_print_frameinfo (SF_PRIVATE *psf, const struct mpg123_frameinfo *fi) -{ psf_log_printf (psf, "MPEG-1/2 Audio\n----------------------------------------\n") ; - psf_log_printf (psf, " MPEG version : %s\n", - fi->version == MPG123_1_0 ? "MPEG 1.0" : - fi->version == MPG123_2_0 ? "MPEG 2.0" : - fi->version == MPG123_2_5 ? "MPEG 2.5" : "???") ; - psf_log_printf (psf, " layer : %d\n", fi->layer) ; - psf_log_printf (psf, " rate : %d\n", fi->rate) ; - psf_log_printf (psf, " mode : %s\n", - fi->mode == MPG123_M_STEREO ? "stereo" : - fi->mode == MPG123_M_JOINT ? "joint stereo" : - fi->mode == MPG123_M_DUAL ? "dual channel" : - fi->mode == MPG123_M_MONO ? "mono" : "???") ; - psf_log_printf (psf, " mode ext : %d\n", fi->mode_ext) ; - psf_log_printf (psf, " framesize : %d\n", fi->framesize) ; - psf_log_printf (psf, " crc : %d\n", !! (fi->flags & MPG123_CRC)) ; - psf_log_printf (psf, " copyright flag : %d\n", !! (fi->flags & MPG123_COPYRIGHT)) ; - psf_log_printf (psf, " private flag : %d\n", !! (fi->flags & MPG123_PRIVATE)) ; - psf_log_printf (psf, " original flag : %d\n", !! (fi->flags & MPG123_ORIGINAL)) ; - psf_log_printf (psf, " emphasis : %d\n", fi->emphasis) ; - psf_log_printf (psf, " bitrate mode : ") ; - switch (fi->vbr) - { case MPG123_CBR : - psf_log_printf (psf, "constant\n") ; - psf_log_printf (psf, " bitrate : %d kbps\n", fi->bitrate) ; - break ; - case MPG123_VBR : - psf_log_printf (psf, "variable\n") ; - break ; - - case MPG123_ABR : - psf_log_printf (psf, "average\n") ; - psf_log_printf (psf, " ABR target : %d\n", fi->abr_rate) ; - break ; - - default : - psf_log_printf (psf, "(%d) ???\n", fi->vbr) ; - break ; - } ; -} /* mpeg_dec_print_frameinfo */ - -/* - * Like strlcpy, except the size argument is the maximum size of the input, - * always null terminates the output string. Thus, up to size + 1 bytes may be - * written. - * - * Returns the length of the copied string. - */ -static int -strcpy_inbounded (char *dest, size_t size, const char *src) -{ char *c = memccpy (dest, src, '\0', size) ; - if (!c) - c = dest + size ; - *c = '\0' ; - return c - dest ; -} /* strcpy_inbounded */ - -static void -mpeg_decoder_read_strings_id3v1 (SF_PRIVATE *psf, mpg123_id3v1 *tags) -{ const char *genre ; - char buf [31] ; - - psf_log_printf (psf, "ID3v1 Tags\n") ; - - if (strcpy_inbounded (buf, ARRAY_LEN (tags->title), tags->title)) - { psf_log_printf (psf, " Title : %s\n", buf) ; - psf_store_string (psf, SF_STR_TITLE, buf) ; - } ; - - if (strcpy_inbounded (buf, ARRAY_LEN (tags->artist), tags->artist)) - { psf_log_printf (psf, " Artist : %s\n", buf) ; - psf_store_string (psf, SF_STR_ARTIST, buf) ; - } ; - - if (strcpy_inbounded (buf, ARRAY_LEN (tags->album), tags->album)) - { psf_log_printf (psf, " Album : %s\n", buf) ; - psf_store_string (psf, SF_STR_ALBUM, buf) ; - } ; - - if (strcpy_inbounded (buf, ARRAY_LEN (tags->year), tags->year)) - { psf_log_printf (psf, " Year : %s\n", buf) ; - psf_store_string (psf, SF_STR_DATE, buf) ; - } ; - - if (strcpy_inbounded (buf, ARRAY_LEN (tags->comment), tags->comment)) - { psf_log_printf (psf, " Comment : %s\n", buf) ; - psf_store_string (psf, SF_STR_COMMENT, buf) ; - } ; - - /* ID3v1.1 Tracknumber */ - if (tags->comment [28] == '\0' && tags->comment [29] != '\0') - { snprintf (buf, ARRAY_LEN (buf), "%hhu", (unsigned char) tags->comment [29]) ; - psf_log_printf (psf, " Tracknumber : %s\n", buf) ; - psf_store_string (psf, SF_STR_TRACKNUMBER, buf) ; - } ; - - if ((genre = id3_lookup_v1_genre (tags->genre)) != NULL) - { psf_log_printf (psf, " Genre : %s\n", genre) ; - psf_store_string (psf, SF_STR_GENRE, genre) ; - } ; -} /* mpeg_decoder_read_strings_id3v1 */ - -static void -mpeg_decoder_read_strings_id3v2 (SF_PRIVATE *psf, mpg123_id3v2 *tags) -{ mpg123_text *text_frame ; - size_t i ; - uint32_t marker ; - const char *title = NULL ; - const char *copyright = NULL ; - const char *software = NULL ; - const char *artist = NULL ; - const char *comment = NULL ; - const char *date = NULL ; - const char *album = NULL ; - const char *license = NULL ; - const char *tracknumber = NULL ; - const char *genre = NULL ; - const char *tlen = NULL ; - - psf_log_printf (psf, "ID3v2 Tags\n") ; - - // Read the parsed text tags - for (i = 0 ; i < tags->texts ; i++) - { text_frame = &tags->text [i] ; - psf_log_printf (psf, " %.4s : %s\n", text_frame->id, text_frame->text.p) ; - - // Thankfully mpg123 translates v2.2 3-byte frames to v2.3 4-byte for us. - marker = MAKE_MARKER (text_frame->id [0], text_frame->id [1], - text_frame->id [2], text_frame->id [3]) ; - - /* Use our own map of frame types to metadata for text frames */ - switch (marker) - { case MAKE_MARKER ('T', 'I', 'T', '2') : - title = text_frame->text.p ; - break ; - - case MAKE_MARKER ('T', 'C', 'O', 'P') : - copyright = text_frame->text.p ; - break ; - - case MAKE_MARKER ('T', 'E', 'N', 'C') : - case MAKE_MARKER ('T', 'S', 'S', 'E') : - software = text_frame->text.p ; - break ; - - case MAKE_MARKER ('T', 'P', 'E', '1') : - artist = text_frame->text.p ; - break ; - - case MAKE_MARKER ('T', 'A', 'L', 'B') : - album = text_frame->text.p ; - break ; - - case MAKE_MARKER ('T', 'R', 'C', 'K') : - tracknumber = text_frame->text.p ; - break ; - - case MAKE_MARKER ('T', 'Y', 'E', 'R') : - case MAKE_MARKER ('T', 'D', 'R', 'C') : - /* TODO (maybe) - case MAKE_MARKER ('T', 'D', 'A', 'T') : - case MAKE_MARKER ('T', 'I', 'M', 'E') : - case MAKE_MARKER ('T', 'D', 'R', 'A') : - */ - date = text_frame->text.p ; - break ; - - case MAKE_MARKER ('T', 'O', 'W', 'N') : - tracknumber = text_frame->text.p ; - break ; - - case MAKE_MARKER ('T', 'C', 'O', 'N') : - genre = text_frame->text.p ; - break ; - - case MAKE_MARKER ('T', 'L', 'E', 'N') : - tlen = text_frame->text.p ; - break ; - } ; - } ; - - /* Use mpg123's handling of comment headers, but print all the comment headers anyways. */ - if (tags->comment) - comment = tags->comment->p ; - for (i = 0 ; i < tags->comments ; i++) - { text_frame = &tags->comment_list [i] ; - psf_log_printf (psf, " %.4s : (%s)[%s] %s\n", text_frame->id, - text_frame->description. p, text_frame->lang, text_frame->text.p) ; - } ; - - /* Print extra headers */ - for (i = 0 ; i < tags->extras ; i++) - { text_frame = &tags->extra [i] ; - psf_log_printf (psf, " %.4s : (%s) %s\n", text_frame->id, - text_frame->description.p, text_frame->text.p) ; - } ; - - if (title != NULL) - psf_store_string (psf, SF_STR_TITLE, title) ; - if (copyright != NULL) - psf_store_string (psf, SF_STR_COPYRIGHT, copyright) ; - if (software != NULL) - psf_store_string (psf, SF_STR_SOFTWARE, software) ; - if (artist != NULL) - psf_store_string (psf, SF_STR_ARTIST, artist) ; - if (comment != NULL) - psf_store_string (psf, SF_STR_COMMENT, comment) ; - if (date != NULL) - psf_store_string (psf, SF_STR_DATE, date) ; - if (album != NULL) - psf_store_string (psf, SF_STR_ALBUM, album) ; - if (license != NULL) - psf_store_string (psf, SF_STR_LICENSE, license) ; - if (tracknumber != NULL) - psf_store_string (psf, SF_STR_TRACKNUMBER, tracknumber) ; - if (genre != NULL) - psf_store_string (psf, SF_STR_GENRE, id3_process_v2_genre (genre)) ; - if (tlen != NULL) - { /* If non-seekable, set framecount? Can we trust it? */ - } ; -} /* mpeg_decoder_read_strings_id3v2 */ - -static void -mpeg_decoder_read_strings (SF_PRIVATE *psf) -{ MPEG_DEC_PRIVATE *pmp3d = (MPEG_DEC_PRIVATE *) psf->codec_data ; - mpg123_id3v1 *v1_tags ; - mpg123_id3v2 *v2_tags ; - - if (mpg123_id3 (pmp3d->pmh, &v1_tags, &v2_tags) != MPG123_OK) - return ; - - if (v1_tags != NULL) - mpeg_decoder_read_strings_id3v1 (psf, v1_tags) ; - - if (v2_tags != NULL) - mpeg_decoder_read_strings_id3v2 (psf, v2_tags) ; -} /* mpeg_decoder_read_strings */ - -static int -mpeg_dec_byterate (SF_PRIVATE *psf) -{ MPEG_DEC_PRIVATE *pmp3d = (MPEG_DEC_PRIVATE *) psf->codec_data ; - struct mpg123_frameinfo fi ; - - if (mpg123_info (pmp3d->pmh, &fi) == MPG123_OK) - return (fi.bitrate + 7) / 8 ; - - return -1 ; - -} /* mpeg_dec_byterate */ - -/*============================================================================== -** exported functions -*/ - -int -mpeg_decoder_init (SF_PRIVATE *psf) -{ MPEG_DEC_PRIVATE *pmp3d ; - struct mpg123_frameinfo fi ; - int error ; - - if (! (psf->file.mode & SFM_READ)) - return SFE_INTERNAL ; - - /* - ** *** FIXME - Threading issues *** - ** - ** mpg123_init() is a global call that should only be called once, and - ** should be paried with mpg123_exit() when done. libsndfile does not - ** provide for these requirements. - ** - ** Currently this is a moot issue as mpg123_init() non-conditionally writes - ** static areas with calculated data, and mpg123_exit() is a NOP, but this - ** could change in a future version of it! - ** - ** From mpg123.h: - ** > This should be called once in a non-parallel context. It is not explicitly - ** > thread-safe, but repeated/concurrent calls still _should_ be safe as static - ** > tables are filled with the same values anyway. - ** - ** Note that calling mpg123_init() after it has already completed is a NOP. - ** - ** Update 2021-07-04 - ** mpg123 upstream has confirmed that mpg132_init() will become a NOP in future, - ** so this is moot. - */ - if (mpg123_init () != MPG123_OK) - return SFE_INTERNAL ; - - psf->codec_data = pmp3d = calloc (1, sizeof (MPEG_DEC_PRIVATE)) ; - if (!psf->codec_data) - return SFE_MALLOC_FAILED ; - - pmp3d->pmh = mpg123_new (NULL, &error) ; - if (!pmp3d->pmh) - { psf_log_printf (psf, "Could not obtain a mpg123 handle: %s\n", mpg123_plain_strerror (error)) ; - return SFE_INTERNAL ; - } ; - - psf->codec_close = mpeg_dec_close ; - - mpg123_replace_reader_handle (pmp3d->pmh, - mpeg_dec_io_read, mpeg_dec_io_lseek, NULL) ; - - mpg123_param (pmp3d->pmh, MPG123_REMOVE_FLAGS, MPG123_AUTO_RESAMPLE, 1.0) ; - mpg123_param (pmp3d->pmh, MPG123_ADD_FLAGS, MPG123_FORCE_FLOAT | MPG123_GAPLESS, 1.0) ; -#if MPG123_API_VERSION >= 45 - mpg123_param (pmp3d->pmh, MPG123_ADD_FLAGS, MPG123_NO_FRANKENSTEIN, 1.0) ; -#endif - - /* - ** Need to pass the first MPEG frame to libmpg123, but that frame was read - ** into psf->binheader in order that we could identify the stream. - */ - if (psf->is_pipe) - { /* - ** Can't seek, so setup our libmpg123 io callbacks to read the binheader - ** buffer first. - */ - psf_binheader_readf (psf, "p", psf->dataoffset) ; - pmp3d->header_remaining = psf_binheader_readf (psf, NULL) - psf->dataoffset ; - - /* Tell libmpg123 we can't seek the file. */ - mpg123_param (pmp3d->pmh, MPG123_ADD_FLAGS, MPG123_NO_PEEK_END, 1.0) ; - } - else - { /* - ** libmpg123 can parse the ID3v2 header. Undo the embedded file offset if the - ** enclosing file data is the ID3v2 header. - */ - if (psf->id3_header.len > 0 && psf->id3_header.len + psf->id3_header.offset == psf->fileoffset) - psf->fileoffset = psf->id3_header.offset ; - - psf_fseek (psf, 0, SEEK_SET) ; - } ; - - error = mpg123_open_handle (pmp3d->pmh, psf) ; - if (error != MPG123_OK) - { psf_log_printf (psf, "mpg123 could not open the file: %s\n", mpg123_plain_strerror (error)) ; - return SFE_BAD_FILE ; - } ; - - if (mpeg_dec_fill_sfinfo (psf, pmp3d->pmh, &psf->sf) != MPG123_OK) - { psf_log_printf (psf, "Cannot get MPEG decoder configuration: %s\n", mpg123_plain_strerror (error)) ; - return SFE_BAD_FILE ; - } ; - - error = mpg123_info (pmp3d->pmh, &fi) ; - if (error != MPG123_OK) - { psf_log_printf (psf, "Cannot get MPEG frame info: %s\n", mpg123_plain_strerror (error)) ; - return SFE_INTERNAL ; - } - - switch (fi.layer) - { case 1 : psf->sf.format |= SF_FORMAT_MPEG_LAYER_I ; break ; - case 2 : psf->sf.format |= SF_FORMAT_MPEG_LAYER_II ; break ; - case 3 : psf->sf.format |= SF_FORMAT_MPEG_LAYER_III ; break ; - default : - return SFE_BAD_FILE ; - } ; - mpeg_dec_print_frameinfo (psf, &fi) ; - - psf->read_short = mpeg_dec_read_s ; - psf->read_int = mpeg_dec_read_i ; - psf->read_float = mpeg_dec_read_f ; - psf->read_double = mpeg_dec_read_d ; - psf->seek = mpeg_dec_seek ; - psf->byterate = mpeg_dec_byterate ; - - mpeg_decoder_read_strings (psf) ; - - return 0 ; -} /* mpeg_decoder_init */ - -int -mpeg_decoder_get_bitrate_mode (SF_PRIVATE *psf) -{ MPEG_DEC_PRIVATE *pmp3d = (MPEG_DEC_PRIVATE *) psf->codec_data ; - struct mpg123_frameinfo fi ; - - if (mpg123_info (pmp3d->pmh, &fi) == MPG123_OK) - { - switch (fi.vbr) - { case MPG123_CBR : return SF_BITRATE_MODE_CONSTANT ; - case MPG123_ABR : return SF_BITRATE_MODE_AVERAGE ; - case MPG123_VBR : return SF_BITRATE_MODE_VARIABLE ; - default : break ; - } ; - } ; - - psf_log_printf (psf, "Cannot determine MPEG bitrate mode.\n") ; - return -1 ; -} /* mpeg_decoder_get_bitrate_mode */ - -#else /* HAVE_MPEG */ - -int mpeg_decoder_init (SF_PRIVATE *psf) -{ psf_log_printf (psf, "This version of libsndfile was compiled without MPEG decode support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* mpeg_decoder_init */ - -#endif /* HAVE_MPEG */ diff --git a/Engine/lib/libsndfile/src/mpeg_l3_encode.c b/Engine/lib/libsndfile/src/mpeg_l3_encode.c deleted file mode 100644 index 97324f792..000000000 --- a/Engine/lib/libsndfile/src/mpeg_l3_encode.c +++ /dev/null @@ -1,784 +0,0 @@ -/* -** Copyright (C) 2020 Arthur Taylor -** Copyright (C) 2019 Erik de Castro Lopo -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" -#include "sndfile.h" -#include "common.h" -#include "mpeg.h" - - -#if HAVE_MPEG - -#include - -/* - * RANT RANT RANT - * - * Lame has 11 functions for inputing sample data of various types and - * configurations, but due to bad definitions, or missing combinations, they - * aren't really of much help to us. - * - */ - -typedef struct -{ lame_t lamef ; - unsigned char *block ; - size_t block_len ; - int frame_samples ; - double compression ; - int initialized ; -} MPEG_L3_ENC_PRIVATE ; - - -/*----------------------------------------------------------------------------------------------- -** Private function prototypes. -*/ - -static int mpeg_l3_encoder_close (SF_PRIVATE *psf) ; -static int mpeg_l3_encoder_construct (SF_PRIVATE *psf) ; -static int mpeg_l3_encoder_byterate (SF_PRIVATE *psf) ; - -static sf_count_t mpeg_l3_encode_write_short_stereo (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t mpeg_l3_encode_write_int_stereo (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t mpeg_l3_encode_write_float_stereo (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t mpeg_l3_encode_write_double_stereo (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t mpeg_l3_encode_write_short_mono (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t mpeg_l3_encode_write_int_mono (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t mpeg_l3_encode_write_float_mono (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t mpeg_l3_encode_write_double_mono (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -/*----------------------------------------------------------------------------------------------- -** Exported functions. -*/ - -int -mpeg_l3_encoder_init (SF_PRIVATE *psf, int info_tag) -{ MPEG_L3_ENC_PRIVATE* pmpeg = NULL ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode != SFM_WRITE) - return SFE_INTERNAL ; - - psf->codec_data = pmpeg = calloc (1, sizeof (MPEG_L3_ENC_PRIVATE)) ; - if (!pmpeg) - return SFE_MALLOC_FAILED ; - - if (psf->sf.channels < 1 || psf->sf.channels > 2) - return SFE_BAD_OPEN_FORMAT ; - - if (! (pmpeg->lamef = lame_init ())) - return SFE_MALLOC_FAILED ; - - pmpeg->compression = -1.0 ; /* Unset */ - - lame_set_in_samplerate (pmpeg->lamef, psf->sf.samplerate) ; - lame_set_num_channels (pmpeg->lamef, psf->sf.channels) ; - if (lame_set_out_samplerate (pmpeg->lamef, psf->sf.samplerate) < 0) - return SFE_MPEG_BAD_SAMPLERATE ; - - lame_set_write_id3tag_automatic (pmpeg->lamef, 0) ; - - if (!info_tag || psf->is_pipe) - { /* Can't seek back, so force disable Xing/Lame/Info header. */ - lame_set_bWriteVbrTag (pmpeg->lamef, 0) ; - } ; - - if (psf->sf.channels == 2) - { psf->write_short = mpeg_l3_encode_write_short_stereo ; - psf->write_int = mpeg_l3_encode_write_int_stereo ; - psf->write_float = mpeg_l3_encode_write_float_stereo ; - psf->write_double = mpeg_l3_encode_write_double_stereo ; - } - else - { psf->write_short = mpeg_l3_encode_write_short_mono ; - psf->write_int = mpeg_l3_encode_write_int_mono ; - psf->write_float = mpeg_l3_encode_write_float_mono ; - psf->write_double = mpeg_l3_encode_write_double_mono ; - } - - psf->sf.seekable = 0 ; - psf->codec_close = mpeg_l3_encoder_close ; - psf->byterate = mpeg_l3_encoder_byterate ; - psf->datalength = 0 ; - - return 0 ; -} /* mpeg_l3_encoder_init */ - -int -mpeg_l3_encoder_write_id3tag (SF_PRIVATE *psf) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE *) psf->codec_data ; - unsigned char *id3v2_buffer ; - int i, id3v2_size ; - - if (psf->have_written) - return 0 ; - - if ((i = mpeg_l3_encoder_construct (psf))) - return i ; - - if (psf_fseek (psf, 0, SEEK_SET) != 0) - return SFE_NOT_SEEKABLE ; - - /* Safe to call multiple times. */ - id3tag_init (pmpeg->lamef) ; - - for (i = 0 ; i < SF_MAX_STRINGS ; i++) - { switch (psf->strings.data [i].type) - { case SF_STR_TITLE : - id3tag_set_title (pmpeg->lamef, psf->strings.storage + psf->strings.data [i].offset) ; - break ; - - case SF_STR_ARTIST : - id3tag_set_artist (pmpeg->lamef, psf->strings.storage + psf->strings.data [i].offset) ; - break ; - - case SF_STR_ALBUM : - id3tag_set_album (pmpeg->lamef, psf->strings.storage + psf->strings.data [i].offset) ; - break ; - - case SF_STR_DATE : - id3tag_set_year (pmpeg->lamef, psf->strings.storage + psf->strings.data [i].offset) ; - break ; - - case SF_STR_COMMENT : - id3tag_set_comment (pmpeg->lamef, psf->strings.storage + psf->strings.data [i].offset) ; - break ; - - case SF_STR_GENRE : - id3tag_set_genre (pmpeg->lamef, psf->strings.storage + psf->strings.data [i].offset) ; - break ; - - case SF_STR_TRACKNUMBER : - id3tag_set_track (pmpeg->lamef, psf->strings.storage + psf->strings.data [i].offset) ; - break ; - - default: - break ; - } ; - } ; - - /* The header in this case is the ID3v2 tag header. */ - id3v2_size = lame_get_id3v2_tag (pmpeg->lamef, 0, 0) ; - if (id3v2_size > 0) - { psf_log_printf (psf, "Writing ID3v2 header.\n") ; - if (! (id3v2_buffer = malloc (id3v2_size))) - return SFE_MALLOC_FAILED ; - lame_get_id3v2_tag (pmpeg->lamef, id3v2_buffer, id3v2_size) ; - psf_fwrite (id3v2_buffer, 1, id3v2_size, psf) ; - psf->dataoffset = id3v2_size ; - free (id3v2_buffer) ; - } ; - - return 0 ; -} - -int -mpeg_l3_encoder_set_quality (SF_PRIVATE *psf, double compression) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE *) psf->codec_data ; - int bitrate_mode ; - int bitrate ; - int ret ; - - if (compression < 0.0 || compression > 1.0) - return SF_FALSE ; - - /* - ** Save the compression setting, as we may have to re-interpret it if - ** the bitrate mode changes. - */ - pmpeg->compression = compression ; - - bitrate_mode = mpeg_l3_encoder_get_bitrate_mode (psf) ; - if (bitrate_mode == SF_BITRATE_MODE_VARIABLE) - { ret = lame_set_VBR_quality (pmpeg->lamef, compression * 10.0) ; - } - else - { /* Choose a bitrate. */ - if (psf->sf.samplerate >= 32000) - { /* MPEG-1.0, bitrates are [32,320] kbps */ - bitrate = (320.0 - (compression * (320.0 - 32.0))) ; - } - else if (psf->sf.samplerate >= 16000) - { /* MPEG-2.0, bitrates are [8,160] */ - bitrate = (160.0 - (compression * (160.0 - 8.0))) ; - } - else - { /* MPEG-2.5, bitrates are [8,64] */ - bitrate = (64.0 - (compression * (64.0 - 8.0))) ; - } - - if (bitrate_mode == SF_BITRATE_MODE_AVERAGE) - ret = lame_set_VBR_mean_bitrate_kbps (pmpeg->lamef, bitrate) ; - else - ret = lame_set_brate (pmpeg->lamef, bitrate) ; - } ; - - if (ret == LAME_OKAY) - return SF_TRUE ; - - psf_log_printf (psf, "Failed to set lame encoder quality.\n") ; - return SF_FALSE ; -} /* mpeg_l3_encoder_set_quality */ - -int -mpeg_l3_encoder_set_bitrate_mode (SF_PRIVATE *psf, int mode) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE *) psf->codec_data ; - enum vbr_mode_e vbr_mode ; - - if (pmpeg->initialized) - { psf->error = SFE_CMD_HAS_DATA ; - return SF_FALSE ; - } ; - - switch (mode) - { case SF_BITRATE_MODE_CONSTANT : vbr_mode = vbr_off ; break ; - case SF_BITRATE_MODE_AVERAGE : vbr_mode = vbr_abr ; break ; - case SF_BITRATE_MODE_VARIABLE : vbr_mode = vbr_default ; break ; - default : - psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - - if (lame_set_VBR (pmpeg->lamef, vbr_mode) == LAME_OKAY) - { /* Re-evaluate the compression setting. */ - return mpeg_l3_encoder_set_quality (psf, pmpeg->compression) ; - } ; - - psf_log_printf (psf, "Failed to set LAME vbr mode to %d.\n", vbr_mode) ; - return SF_FALSE ; -} /* mpeg_l3_encoder_set_bitrate_mode */ - -int -mpeg_l3_encoder_get_bitrate_mode (SF_PRIVATE *psf) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE *) psf->codec_data ; - enum vbr_mode_e vbr_mode ; - - vbr_mode = lame_get_VBR (pmpeg->lamef) ; - - if (vbr_mode == vbr_off) - return SF_BITRATE_MODE_CONSTANT ; - if (vbr_mode == vbr_abr) - return SF_BITRATE_MODE_AVERAGE ; - if (vbr_mode == vbr_default || vbr_mode < vbr_max_indicator) - return SF_BITRATE_MODE_VARIABLE ; - - /* Something is wrong. */ - psf->error = SFE_INTERNAL ; - return -1 ; -} /* mpeg_l3_encoder_get_bitrate_mode */ - - -/*----------------------------------------------------------------------------------------------- -** Private functions. -*/ - -static int -mpeg_l3_encoder_close (SF_PRIVATE *psf) -{ MPEG_L3_ENC_PRIVATE* pmpeg = (MPEG_L3_ENC_PRIVATE *) psf->codec_data ; - int ret, len ; - sf_count_t pos ; - unsigned char *buffer ; - - /* Magic number 7200 comes from a comment in lame.h */ - len = 7200 ; - if (! (buffer = malloc (len))) - return SFE_MALLOC_FAILED ; - ret = lame_encode_flush (pmpeg->lamef, buffer, len) ; - if (ret > 0) - psf_fwrite (buffer, 1, ret, psf) ; - - /* - ** Write an IDv1 trailer. The whole tag structure is always 128 bytes, so is - ** guaranteed to fit in the buffer allocated above. - */ - ret = lame_get_id3v1_tag (pmpeg->lamef, buffer, len) ; - if (ret > 0) - { psf_log_printf (psf, " Writing ID3v1 trailer.\n") ; - psf_fwrite (buffer, 1, ret, psf) ; - } ; - - /* - ** If possible, seek back and write the LAME/XING/Info headers. This - ** contains information about the whole file and a seek table, and can - ** only be written after encoding. - ** - ** If enabled, Lame wrote an empty header at the beginning of the data - ** that we now fill in. - */ - ret = lame_get_lametag_frame (pmpeg->lamef, 0, 0) ; - if (ret > 0) - { if (ret > len) - { len = ret ; - free (buffer) ; - if (! (buffer = malloc (len))) - return SFE_MALLOC_FAILED ; - } ; - psf_log_printf (psf, " Writing LAME info header at offset %d, %d bytes.\n", - psf->dataoffset, len) ; - lame_get_lametag_frame (pmpeg->lamef, buffer, len) ; - pos = psf_ftell (psf) ; - if (psf_fseek (psf, psf->dataoffset, SEEK_SET) == psf->dataoffset) - { psf_fwrite (buffer, 1, ret, psf) ; - psf_fseek (psf, pos, SEEK_SET) ; - } ; - } ; - free (buffer) ; - - free (pmpeg->block) ; - pmpeg->block = NULL ; - - if (pmpeg->lamef) - { lame_close (pmpeg->lamef) ; - pmpeg->lamef = NULL ; - } ; - - return 0 ; -} /* mpeg_l3_encoder_close */ - -static void -mpeg_l3_encoder_log_config (SF_PRIVATE *psf, lame_t lamef) -{ const char *version ; - const char *chn_mode ; - - switch (lame_get_version (lamef)) - { case 0 : version = "2" ; break ; - case 1 : version = "1" ; break ; - case 2 : version = "2.5" ; break ; - default : version = "unknown!?" ; break ; - } ; - switch (lame_get_mode (lamef)) - { case STEREO : chn_mode = "stereo" ; break ; - case JOINT_STEREO : chn_mode = "joint-stereo" ; break ; - case MONO : chn_mode = "mono" ; break ; - default : chn_mode = "unknown!?" ; break ; - } ; - psf_log_printf (psf, " MPEG Version : %s\n", version) ; - psf_log_printf (psf, " Block samples : %d\n", lame_get_framesize (lamef)) ; - psf_log_printf (psf, " Channel mode : %s\n", chn_mode) ; - psf_log_printf (psf, " Samplerate : %d\n", lame_get_out_samplerate (lamef)) ; - psf_log_printf (psf, " Encoder mode : ") ; - switch (lame_get_VBR (lamef)) - { case vbr_off : - psf_log_printf (psf, "CBR\n") ; - psf_log_printf (psf, " Bitrate : %d kbps\n", lame_get_brate (lamef)) ; - break ; - case vbr_abr : - psf_log_printf (psf, "ABR\n") ; - psf_log_printf (psf, " Mean Bitrate : %d kbps\n", lame_get_VBR_mean_bitrate_kbps (lamef)) ; - break ; - - case vbr_mt : - case vbr_default : - psf_log_printf (psf, "VBR\n") ; - psf_log_printf (psf, " Quality : %d\n", lame_get_VBR_q (lamef)) ; - break ; - - default: - psf_log_printf (psf, "Unknown!? (%d)\n", lame_get_VBR (lamef)) ; - break ; - } ; - - psf_log_printf (psf, " Encoder delay : %d\n", lame_get_encoder_delay (lamef)) ; - psf_log_printf (psf, " Write INFO header : %d\n", lame_get_bWriteVbrTag (lamef)) ; -} /* mpeg_l3_encoder_log_config */ - -static int -mpeg_l3_encoder_construct (SF_PRIVATE *psf) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE *) psf->codec_data ; - int frame_samples_per_channel ; - - if (pmpeg->initialized == SF_FALSE) - { if (lame_init_params (pmpeg->lamef) < 0) - { psf_log_printf (psf, "Failed to initialize lame encoder!\n") ; - return SFE_INTERNAL ; - } ; - - psf_log_printf (psf, "Initialized LAME encoder.\n") ; - mpeg_l3_encoder_log_config (psf, pmpeg->lamef) ; - - frame_samples_per_channel = lame_get_framesize (pmpeg->lamef) ; - - /* - * Suggested output buffer size in bytes from lame.h comment is - * 1.25 * samples + 7200 - */ - pmpeg->block_len = (frame_samples_per_channel * 4) / 3 + 7200 ; - pmpeg->frame_samples = frame_samples_per_channel * psf->sf.channels ; - - pmpeg->block = malloc (pmpeg->block_len) ; - if (!pmpeg->block) - return SFE_MALLOC_FAILED ; - - pmpeg->initialized = SF_TRUE ; - } ; - - return 0 ; -} /* mpeg_l3_encoder_construct */ - -static int -mpeg_l3_encoder_byterate (SF_PRIVATE *psf) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE *) psf->codec_data ; - int bitrate_mode ; - int byterate ; - float calculated_byterate ; - - bitrate_mode = mpeg_l3_encoder_get_bitrate_mode (psf) ; - byterate = (lame_get_brate (pmpeg->lamef) + 7) / 8 ; - - if (bitrate_mode == SF_BITRATE_MODE_VARIABLE) - { /* - ** For VBR, lame_get_brate returns the minimum bitrate, so calculate the - ** average byterate so far. - */ - calculated_byterate = psf_ftell (psf) - psf->dataoffset ; - calculated_byterate /= (float) psf->write_current ; - calculated_byterate *= (float) psf->sf.samplerate ; - - return SF_MIN (byterate, (int) calculated_byterate) ; - } - - return byterate ; -} /* mpeg_l3_encoder_byterate */ - -static sf_count_t -mpeg_l3_encode_write_short_mono (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0 ; - int nbytes, writecount, writen ; - - if ((psf->error = mpeg_l3_encoder_construct (psf))) - return 0 ; - - while (len) - { writecount = SF_MIN (len, (sf_count_t) pmpeg->frame_samples) ; - - nbytes = lame_encode_buffer (pmpeg->lamef, ptr + total, NULL, writecount, pmpeg->block, pmpeg->block_len) ; - if (nbytes < 0) - { psf_log_printf (psf, "lame_encode_buffer returned %d\n", nbytes) ; - break ; - } ; - - if (nbytes) - { writen = psf_fwrite (pmpeg->block, 1, nbytes, psf) ; - if (writen != nbytes) - { psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", writen, nbytes) ; - } ; - } ; - - total += writecount ; - len -= writecount ; - } ; - - return total ; -} - - -static sf_count_t -mpeg_l3_encode_write_short_stereo (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0 ; - int nbytes, writecount, writen ; - - if ((psf->error = mpeg_l3_encoder_construct (psf))) - return 0 ; - - const sf_count_t max_samples = SF_MIN (ARRAY_LEN (ubuf.sbuf), pmpeg->frame_samples) ; - while (len) - { writecount = SF_MIN (len, max_samples) ; - /* - * An oversight, but lame_encode_buffer_interleaved() lacks a const. - * As such, need another memcpy to not cause a warning. - */ - memcpy (ubuf.sbuf, ptr + total, writecount) ; - nbytes = lame_encode_buffer_interleaved (pmpeg->lamef, ubuf.sbuf, writecount / 2, pmpeg->block, pmpeg->block_len) ; - if (nbytes < 0) - { psf_log_printf (psf, "lame_encode_buffer returned %d\n", nbytes) ; - break ; - } ; - - if (nbytes) - { writen = psf_fwrite (pmpeg->block, 1, nbytes, psf) ; - if (writen != nbytes) - { psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", writen, nbytes) ; - } ; - } ; - - total += writecount ; - len -= writecount ; - } ; - - return total ; -} - - -static sf_count_t -mpeg_l3_encode_write_int_mono (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0 ; - int nbytes, writecount, writen ; - - if ((psf->error = mpeg_l3_encoder_construct (psf))) - return 0 ; - - while (len) - { writecount = SF_MIN (len, (sf_count_t) pmpeg->frame_samples) ; - - nbytes = lame_encode_buffer_int (pmpeg->lamef, ptr + total, NULL, writecount, pmpeg->block, pmpeg->block_len) ; - if (nbytes < 0) - { psf_log_printf (psf, "lame_encode_buffer returned %d\n", nbytes) ; - break ; - } ; - - if (nbytes) - { writen = psf_fwrite (pmpeg->block, 1, nbytes, psf) ; - if (writen != nbytes) - { psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", writen, nbytes) ; - } ; - } ; - - total += writecount ; - len -= writecount ; - } ; - - return total ; -} - - -static sf_count_t -mpeg_l3_encode_write_int_stereo (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0 ; - int nbytes, writecount, writen ; - - if ((psf->error = mpeg_l3_encoder_construct (psf))) - return 0 ; - - while (len) - { writecount = SF_MIN (len, (sf_count_t) pmpeg->frame_samples) ; - - nbytes = lame_encode_buffer_interleaved_int (pmpeg->lamef, ptr + total, writecount / 2, pmpeg->block, pmpeg->block_len) ; - if (nbytes < 0) - { psf_log_printf (psf, "lame_encode_buffer returned %d\n", nbytes) ; - break ; - } ; - - if (nbytes) - { writen = psf_fwrite (pmpeg->block, 1, nbytes, psf) ; - if (writen != nbytes) - { psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", writen, nbytes) ; - } ; - } ; - - total += writecount ; - len -= writecount ; - } ; - - return total ; -} - - -static sf_count_t -mpeg_l3_encode_write_float_mono (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0 ; - int nbytes, writecount, writen ; - - if ((psf->error = mpeg_l3_encoder_construct (psf))) - return 0 ; - - while (len) - { writecount = SF_MIN (len, (sf_count_t) pmpeg->frame_samples) ; - - if (psf->norm_float) - nbytes = lame_encode_buffer_ieee_float (pmpeg->lamef, ptr + total, NULL, writecount, pmpeg->block, pmpeg->block_len) ; - else - nbytes = lame_encode_buffer_float (pmpeg->lamef, ptr + total, NULL, writecount, pmpeg->block, pmpeg->block_len) ; - if (nbytes < 0) - { psf_log_printf (psf, "lame_encode_buffer returned %d\n", nbytes) ; - break ; - } ; - - if (nbytes) - { writen = psf_fwrite (pmpeg->block, 1, nbytes, psf) ; - if (writen != nbytes) - { psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", writen, nbytes) ; - } ; - } ; - - total += writecount ; - len -= writecount ; - } ; - - return total ; -} - - -static inline void -normalize_float (float *dest, const float *src, sf_count_t count, float norm_fact) -{ while (--count >= 0) - { dest [count] = src [count] * norm_fact ; - } ; -} - - -static sf_count_t -mpeg_l3_encode_write_float_stereo (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0 ; - int nbytes, writecount, writen ; - - if ((psf->error = mpeg_l3_encoder_construct (psf))) - return 0 ; - - const sf_count_t max_samples = SF_MIN (ARRAY_LEN (ubuf.fbuf), pmpeg->frame_samples) ; - while (len) - { writecount = SF_MIN (len, max_samples) ; - - if (psf->norm_float) - nbytes = lame_encode_buffer_interleaved_ieee_float (pmpeg->lamef, ptr + total, writecount / 2, pmpeg->block, pmpeg->block_len) ; - else - { /* Lame lacks a non-normalized interleaved float write. Bummer. */ - normalize_float (ubuf.fbuf, ptr + total, writecount, 1.0 / (float) 0x8000) ; - nbytes = lame_encode_buffer_interleaved_ieee_float (pmpeg->lamef, ubuf.fbuf, writecount / 2, pmpeg->block, pmpeg->block_len) ; - } - - if (nbytes < 0) - { psf_log_printf (psf, "lame_encode_buffer returned %d\n", nbytes) ; - break ; - } ; - - if (nbytes) - { writen = psf_fwrite (pmpeg->block, 1, nbytes, psf) ; - if (writen != nbytes) - { psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", writen, nbytes) ; - } ; - } ; - - total += writecount ; - len -= writecount ; - } ; - - return total ; -} - - -static inline void -normalize_double (double *dest, const double *src, sf_count_t count, double norm_fact) -{ while (--count >= 0) - { dest [count] = src [count] * norm_fact ; - } ; -} - - -static sf_count_t -mpeg_l3_encode_write_double_mono (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0 ; - int nbytes, writecount, writen ; - - if ((psf->error = mpeg_l3_encoder_construct (psf))) - return 0 ; - - const sf_count_t max_samples = SF_MIN (ARRAY_LEN (ubuf.dbuf), pmpeg->frame_samples) ; - while (len) - { writecount = SF_MIN (len, max_samples) ; - - if (psf->norm_double) - nbytes = lame_encode_buffer_ieee_double (pmpeg->lamef, ptr + total, NULL, writecount, pmpeg->block, pmpeg->block_len) ; - else - { /* Lame lacks non-normalized double writing */ - normalize_double (ubuf.dbuf, ptr + total, writecount, 1.0 / (double) 0x8000) ; - nbytes = lame_encode_buffer_ieee_double (pmpeg->lamef, ubuf.dbuf, NULL, writecount, pmpeg->block, pmpeg->block_len) ; - } - - if (nbytes < 0) - { psf_log_printf (psf, "lame_encode_buffer returned %d\n", nbytes) ; - break ; - } ; - - if (nbytes) - { writen = psf_fwrite (pmpeg->block, 1, nbytes, psf) ; - if (writen != nbytes) - { psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", writen, nbytes) ; - } ; - } ; - - total += writecount ; - len -= writecount ; - } ; - - return total ; -} - - -static sf_count_t -mpeg_l3_encode_write_double_stereo (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - MPEG_L3_ENC_PRIVATE *pmpeg = (MPEG_L3_ENC_PRIVATE*) psf->codec_data ; - sf_count_t total = 0 ; - int nbytes, writecount, writen ; - - if ((psf->error = mpeg_l3_encoder_construct (psf))) - return 0 ; - - const sf_count_t max_samples = SF_MIN (ARRAY_LEN (ubuf.dbuf), pmpeg->frame_samples) ; - while (len) - { writecount = SF_MIN (len, max_samples) ; - - if (psf->norm_double) - nbytes = lame_encode_buffer_interleaved_ieee_double (pmpeg->lamef, ptr + total, writecount / 2, pmpeg->block, pmpeg->block_len) ; - else - { /* Lame lacks interleaved non-normalized double writing */ - normalize_double (ubuf.dbuf, ptr + total, writecount, 1.0 / (double) 0x8000) ; - nbytes = lame_encode_buffer_interleaved_ieee_double (pmpeg->lamef, ubuf.dbuf, writecount / 2, pmpeg->block, pmpeg->block_len) ; - } - - if (nbytes < 0) - { psf_log_printf (psf, "lame_encode_buffer returned %d\n", nbytes) ; - break ; - } ; - - if (nbytes) - { writen = psf_fwrite (pmpeg->block, 1, nbytes, psf) ; - if (writen != nbytes) - { psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", writen, nbytes) ; - } ; - } ; - - total += writecount ; - len -= writecount ; - } ; - - return total ; -} - -#else /* HAVE_MPEG */ - -int -mpeg_l3_encoder_init (SF_PRIVATE *psf, int UNUSED (vbr)) -{ psf_log_printf (psf, "This version of libsndfile was compiled without MPEG Layer 3 encoding support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* mpeg_l3_encoder_init */ - -#endif diff --git a/Engine/lib/libsndfile/src/ms_adpcm.c b/Engine/lib/libsndfile/src/ms_adpcm.c deleted file mode 100644 index 0e05181ab..000000000 --- a/Engine/lib/libsndfile/src/ms_adpcm.c +++ /dev/null @@ -1,857 +0,0 @@ -/* -** Copyright (C) 1999-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "wavlike.h" - - -typedef struct -{ int channels, blocksize, samplesperblock, blocks, dataremaining ; - int blockcount ; - int sync_error ; - sf_count_t samplecount ; - short *samples ; - unsigned char *block ; - short dummydata [] ; /* ISO C99 struct flexible array. */ -} MSADPCM_PRIVATE ; - -/*============================================================================================ -** MS ADPCM static data and functions. -*/ - -static int AdaptationTable [] = -{ 230, 230, 230, 230, 307, 409, 512, 614, - 768, 614, 512, 409, 307, 230, 230, 230 -} ; - -/* TODO : The first 7 coef's are are always hardcode and must - appear in the actual WAVE file. They should be read in - in case a sound program added extras to the list. */ - -static int AdaptCoeff1 [WAVLIKE_MSADPCM_ADAPT_COEFF_COUNT] = -{ 256, 512, 0, 192, 240, 460, 392 -} ; - -static int AdaptCoeff2 [WAVLIKE_MSADPCM_ADAPT_COEFF_COUNT] = -{ 0, -256, 0, 64, 0, -208, -232 -} ; - -/*============================================================================================ -** MS ADPCM Block Layout. -** ====================== -** Block is usually 256, 512 or 1024 bytes depending on sample rate. -** For a mono file, the block is laid out as follows: -** byte purpose -** 0 block predictor [0..6] -** 1,2 initial idelta (positive) -** 3,4 sample 1 -** 5,6 sample 0 -** 7..n packed bytecodes -** -** For a stereo file, the block is laid out as follows: -** byte purpose -** 0 block predictor [0..6] for left channel -** 1 block predictor [0..6] for right channel -** 2,3 initial idelta (positive) for left channel -** 4,5 initial idelta (positive) for right channel -** 6,7 sample 1 for left channel -** 8,9 sample 1 for right channel -** 10,11 sample 0 for left channel -** 12,13 sample 0 for right channel -** 14..n packed bytecodes -*/ - -/*============================================================================================ -** Static functions. -*/ - -static int msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) ; -static sf_count_t msadpcm_read_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, short *ptr, int len) ; - -static int msadpcm_encode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) ; -static sf_count_t msadpcm_write_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, const short *ptr, int len) ; - -static sf_count_t msadpcm_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t msadpcm_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t msadpcm_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t msadpcm_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t msadpcm_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t msadpcm_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t msadpcm_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t msadpcm_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static sf_count_t msadpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; -static int msadpcm_close (SF_PRIVATE *psf) ; - -static void choose_predictor (unsigned int channels, short *data, int *bpred, int *idelta) ; - -/*============================================================================================ -** MS ADPCM Read Functions. -*/ - -int -wavlike_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) -{ MSADPCM_PRIVATE *pms ; - unsigned int pmssize ; - int count ; - - if (psf->codec_data != NULL) - { psf_log_printf (psf, "*** psf->codec_data is not NULL.\n") ; - return SFE_INTERNAL ; - } ; - - if (psf->file.mode == SFM_WRITE) - samplesperblock = 2 + 2 * (blockalign - 7 * psf->sf.channels) / psf->sf.channels ; - - /* There's 7 samples per channel in the preamble of each block */ - if (samplesperblock < 7 * psf->sf.channels) - { psf_log_printf (psf, "*** Error samplesperblock (%d) should be >= %d.\n", samplesperblock, 7 * psf->sf.channels) ; - return SFE_INTERNAL ; - } ; - - if (2 * blockalign < samplesperblock * psf->sf.channels) - { psf_log_printf (psf, "*** Error blockalign (%d) should be >= %d.\n", blockalign, samplesperblock * psf->sf.channels / 2) ; - return SFE_INTERNAL ; - } ; - - pmssize = sizeof (MSADPCM_PRIVATE) + blockalign + 3 * psf->sf.channels * samplesperblock ; - - if (! (psf->codec_data = calloc (1, pmssize))) - return SFE_MALLOC_FAILED ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - pms->sync_error = 0 ; - pms->samples = pms->dummydata ; - pms->block = (unsigned char*) (pms->dummydata + psf->sf.channels * samplesperblock) ; - - pms->channels = psf->sf.channels ; - pms->blocksize = blockalign ; - pms->samplesperblock = samplesperblock ; - - if (pms->blocksize <= 0) - { psf_log_printf (psf, "*** Error : pms->blocksize should be > 0.\n") ; - return SFE_INTERNAL ; - } ; - - if (psf->file.mode == SFM_READ) - { pms->dataremaining = psf->datalength ; - - if (psf->datalength % pms->blocksize) - pms->blocks = psf->datalength / pms->blocksize + 1 ; - else - pms->blocks = psf->datalength / pms->blocksize ; - - count = 2 * (pms->blocksize - 6 * pms->channels) / pms->channels ; - if (pms->samplesperblock != count) - { psf_log_printf (psf, "*** Error : samplesperblock should be %d.\n", count) ; - return SFE_INTERNAL ; - } ; - - psf->sf.frames = (psf->datalength / pms->blocksize) * pms->samplesperblock ; - - msadpcm_decode_block (psf, pms) ; - - psf->read_short = msadpcm_read_s ; - psf->read_int = msadpcm_read_i ; - psf->read_float = msadpcm_read_f ; - psf->read_double = msadpcm_read_d ; - } ; - - if (psf->file.mode == SFM_WRITE) - { pms->samples = pms->dummydata ; - - pms->samplecount = 0 ; - - psf->write_short = msadpcm_write_s ; - psf->write_int = msadpcm_write_i ; - psf->write_float = msadpcm_write_f ; - psf->write_double = msadpcm_write_d ; - } ; - - psf->codec_close = msadpcm_close ; - psf->seek = msadpcm_seek ; - - return 0 ; -} /* wavlike_msadpcm_init */ - - -static inline short -msadpcm_get_bpred (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, unsigned char value) -{ if (value >= WAVLIKE_MSADPCM_ADAPT_COEFF_COUNT) - { if (pms->sync_error == 0) - { pms->sync_error = 1 ; - psf_log_printf (psf, "MS ADPCM synchronisation error (%u should be < %u).\n", value, WAVLIKE_MSADPCM_ADAPT_COEFF_COUNT) ; - } ; - return 0 ; - } ; - return value ; -} /* msadpcm_get_bpred */ - - -static int -msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) -{ int chan, k, blockindx, sampleindx ; - short bytecode, bpred [2], chan_idelta [2] ; - - int predict ; - int current ; - int idelta ; - - pms->blockcount ++ ; - pms->samplecount = 0 ; - - if (pms->blockcount > pms->blocks) - { memset (pms->samples, 0, pms->samplesperblock * pms->channels) ; - return 1 ; - } ; - - if ((k = (int) psf_fread (pms->block, 1, pms->blocksize, psf)) != pms->blocksize) - { psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pms->blocksize) ; - if (k <= 0) - return 1 ; - } ; - - /* Read and check the block header. */ - - if (pms->channels == 1) - { bpred [0] = msadpcm_get_bpred (psf, pms, pms->block [0]) ; - - chan_idelta [0] = pms->block [1] | (pms->block [2] << 8) ; - chan_idelta [1] = 0 ; - - pms->samples [1] = pms->block [3] | (pms->block [4] << 8) ; - pms->samples [0] = pms->block [5] | (pms->block [6] << 8) ; - blockindx = 7 ; - } - else - { bpred [0] = msadpcm_get_bpred (psf, pms, pms->block [0]) ; - bpred [1] = msadpcm_get_bpred (psf, pms, pms->block [1]) ; - - chan_idelta [0] = pms->block [2] | (pms->block [3] << 8) ; - chan_idelta [1] = pms->block [4] | (pms->block [5] << 8) ; - - pms->samples [2] = pms->block [6] | (pms->block [7] << 8) ; - pms->samples [3] = pms->block [8] | (pms->block [9] << 8) ; - - pms->samples [0] = pms->block [10] | (pms->block [11] << 8) ; - pms->samples [1] = pms->block [12] | (pms->block [13] << 8) ; - - blockindx = 14 ; - } ; - - /*-------------------------------------------------------- - This was left over from a time when calculations were done - as ints rather than shorts. Keep this around as a reminder - in case I ever find a file which decodes incorrectly. - - if (chan_idelta [0] & 0x8000) - chan_idelta [0] -= 0x10000 ; - if (chan_idelta [1] & 0x8000) - chan_idelta [1] -= 0x10000 ; - --------------------------------------------------------*/ - - /* Pull apart the packed 4 bit samples and store them in their - ** correct sample positions. - */ - - sampleindx = 2 * pms->channels ; - while (blockindx < pms->blocksize) - { bytecode = pms->block [blockindx++] ; - pms->samples [sampleindx++] = (bytecode >> 4) & 0x0F ; - pms->samples [sampleindx++] = bytecode & 0x0F ; - } ; - - /* Decode the encoded 4 bit samples. */ - - for (k = 2 * pms->channels ; k < (pms->samplesperblock * pms->channels) ; k ++) - { chan = (pms->channels > 1) ? (k % 2) : 0 ; - - bytecode = pms->samples [k] & 0xF ; - - /* Compute next Adaptive Scale Factor (ASF) */ - idelta = chan_idelta [chan] ; - chan_idelta [chan] = (AdaptationTable [bytecode] * idelta) >> 8 ; /* => / 256 => FIXED_POINT_ADAPTATION_BASE == 256 */ - if (chan_idelta [chan] < 16) - chan_idelta [chan] = 16 ; - if (bytecode & 0x8) - bytecode -= 0x10 ; - - predict = ((pms->samples [k - pms->channels] * AdaptCoeff1 [bpred [chan]]) - + (pms->samples [k - 2 * pms->channels] * AdaptCoeff2 [bpred [chan]])) >> 8 ; /* => / 256 => FIXED_POINT_COEFF_BASE == 256 */ - current = (bytecode * idelta) + predict ; - - if (current > 32767) - current = 32767 ; - else if (current < -32768) - current = -32768 ; - - pms->samples [k] = current ; - } ; - - return 0 ; -} /* msadpcm_decode_block */ - -static sf_count_t -msadpcm_read_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, short *ptr, int len) -{ int count, total = 0, indx = 0 ; - - while (indx < len) - { if (pms->blockcount >= pms->blocks && pms->samplecount >= pms->samplesperblock) - { memset (&(ptr [indx]), 0, (size_t) ((len - indx) * sizeof (short))) ; - return total ; - } ; - - if (pms->samplecount >= pms->samplesperblock) - if (msadpcm_decode_block (psf, pms) != 0) - return total ; - - count = (pms->samplesperblock - pms->samplecount) * pms->channels ; - count = (len - indx > count) ? count : len - indx ; - - memcpy (&(ptr [indx]), &(pms->samples [pms->samplecount * pms->channels]), count * sizeof (short)) ; - indx += count ; - pms->samplecount += count / pms->channels ; - total = indx ; - } ; - - return total ; -} /* msadpcm_read_block */ - -static sf_count_t -msadpcm_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ MSADPCM_PRIVATE *pms ; - int readcount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - while (len > 0) - { readcount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - if ((count = (int) msadpcm_read_block (psf, pms, ptr, readcount)) <= 0) - return -1 ; - - total += count ; - len -= count ; - if (count != readcount) - break ; - } ; - - return total ; -} /* msadpcm_read_s */ - -static sf_count_t -msadpcm_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ MSADPCM_PRIVATE *pms ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - - if ((count = (int) msadpcm_read_block (psf, pms, sptr, readcount)) <= 0) - return -1 ; - - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = arith_shift_left (sptr [k], 16) ; - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - return total ; -} /* msadpcm_read_i */ - -static sf_count_t -msadpcm_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ MSADPCM_PRIVATE *pms ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (! psf->codec_data) - return 0 ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - - if ((count = (int) msadpcm_read_block (psf, pms, sptr, readcount)) <= 0) - return -1 ; - - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (float) (sptr [k]) ; - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - return total ; -} /* msadpcm_read_f */ - -static sf_count_t -msadpcm_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ MSADPCM_PRIVATE *pms ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - if (! psf->codec_data) - return 0 ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - - if ((count = (int) msadpcm_read_block (psf, pms, sptr, readcount)) <= 0) - return -1 ; - - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (double) (sptr [k]) ; - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* msadpcm_read_d */ - -static sf_count_t -msadpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ MSADPCM_PRIVATE *pms ; - int newblock, newsample ; - - if (! psf->codec_data) - return 0 ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - if (psf->datalength < 0 || psf->dataoffset < 0) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (offset == 0) - { psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - pms->blockcount = 0 ; - msadpcm_decode_block (psf, pms) ; - pms->samplecount = 0 ; - return 0 ; - } ; - - if (offset < 0 || offset > pms->blocks * pms->samplesperblock) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - newblock = offset / pms->samplesperblock ; - newsample = offset % pms->samplesperblock ; - - if (mode == SFM_READ) - { psf_fseek (psf, psf->dataoffset + newblock * pms->blocksize, SEEK_SET) ; - pms->blockcount = newblock ; - msadpcm_decode_block (psf, pms) ; - pms->samplecount = newsample ; - } - else - { /* What to do about write??? */ - psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - return newblock * pms->samplesperblock + newsample ; -} /* msadpcm_seek */ - -/*========================================================================================== -** MS ADPCM Write Functions. -*/ - -void -wavlike_msadpcm_write_adapt_coeffs (SF_PRIVATE *psf) -{ int k ; - - for (k = 0 ; k < WAVLIKE_MSADPCM_ADAPT_COEFF_COUNT ; k++) - psf_binheader_writef (psf, "22", BHW2 (AdaptCoeff1 [k]), BHW2 (AdaptCoeff2 [k])) ; -} /* wavlike_msadpcm_write_adapt_coeffs */ - -/*========================================================================================== -*/ - -static int -msadpcm_encode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) -{ unsigned int blockindx ; - unsigned char byte ; - int chan, k, predict, bpred [2] = { 0 }, idelta [2] = { 0 }, - errordelta, newsamp ; - - choose_predictor (pms->channels, pms->samples, bpred, idelta) ; - - /* Write the block header. */ - - if (pms->channels == 1) - { pms->block [0] = bpred [0] ; - pms->block [1] = idelta [0] & 0xFF ; - pms->block [2] = idelta [0] >> 8 ; - pms->block [3] = pms->samples [1] & 0xFF ; - pms->block [4] = pms->samples [1] >> 8 ; - pms->block [5] = pms->samples [0] & 0xFF ; - pms->block [6] = pms->samples [0] >> 8 ; - - blockindx = 7 ; - byte = 0 ; - - /* Encode the samples as 4 bit. */ - - for (k = 2 ; k < pms->samplesperblock ; k++) - { predict = (pms->samples [k-1] * AdaptCoeff1 [bpred [0]] + pms->samples [k-2] * AdaptCoeff2 [bpred [0]]) >> 8 ; - errordelta = (pms->samples [k] - predict) / idelta [0] ; - if (errordelta < -8) - errordelta = -8 ; - else if (errordelta > 7) - errordelta = 7 ; - newsamp = predict + (idelta [0] * errordelta) ; - if (newsamp > 32767) - newsamp = 32767 ; - else if (newsamp < -32768) - newsamp = -32768 ; - if (errordelta < 0) - errordelta += 0x10 ; - - byte = (byte << 4) | (errordelta & 0xF) ; - if (k % 2) - { pms->block [blockindx++] = byte ; - byte = 0 ; - } ; - - idelta [0] = (idelta [0] * AdaptationTable [errordelta]) >> 8 ; - if (idelta [0] < 16) - idelta [0] = 16 ; - pms->samples [k] = newsamp ; - } ; - } - else - { /* Stereo file. */ - pms->block [0] = bpred [0] ; - pms->block [1] = bpred [1] ; - - pms->block [2] = idelta [0] & 0xFF ; - pms->block [3] = idelta [0] >> 8 ; - pms->block [4] = idelta [1] & 0xFF ; - pms->block [5] = idelta [1] >> 8 ; - - pms->block [6] = pms->samples [2] & 0xFF ; - pms->block [7] = pms->samples [2] >> 8 ; - pms->block [8] = pms->samples [3] & 0xFF ; - pms->block [9] = pms->samples [3] >> 8 ; - - pms->block [10] = pms->samples [0] & 0xFF ; - pms->block [11] = pms->samples [0] >> 8 ; - pms->block [12] = pms->samples [1] & 0xFF ; - pms->block [13] = pms->samples [1] >> 8 ; - - blockindx = 14 ; - byte = 0 ; - chan = 1 ; - - for (k = 4 ; k < 2 * pms->samplesperblock ; k++) - { chan = k & 1 ; - - predict = (pms->samples [k-2] * AdaptCoeff1 [bpred [chan]] + pms->samples [k-4] * AdaptCoeff2 [bpred [chan]]) >> 8 ; - errordelta = (pms->samples [k] - predict) / idelta [chan] ; - - - if (errordelta < -8) - errordelta = -8 ; - else if (errordelta > 7) - errordelta = 7 ; - newsamp = predict + (idelta [chan] * errordelta) ; - if (newsamp > 32767) - newsamp = 32767 ; - else if (newsamp < -32768) - newsamp = -32768 ; - if (errordelta < 0) - errordelta += 0x10 ; - - byte = (byte << 4) | (errordelta & 0xF) ; - - if (chan) - { pms->block [blockindx++] = byte ; - byte = 0 ; - } ; - - idelta [chan] = (idelta [chan] * AdaptationTable [errordelta]) >> 8 ; - if (idelta [chan] < 16) - idelta [chan] = 16 ; - pms->samples [k] = newsamp ; - } ; - } ; - - /* Write the block to disk. */ - - if ((k = (int) psf_fwrite (pms->block, 1, pms->blocksize, psf)) != pms->blocksize) - psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pms->blocksize) ; - - memset (pms->samples, 0, pms->samplesperblock * sizeof (short)) ; - - pms->blockcount ++ ; - pms->samplecount = 0 ; - - return 1 ; -} /* msadpcm_encode_block */ - -static sf_count_t -msadpcm_write_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, const short *ptr, int len) -{ int count, total = 0, indx = 0 ; - - while (indx < len) - { count = (pms->samplesperblock - pms->samplecount) * pms->channels ; - - if (count > len - indx) - count = len - indx ; - - memcpy (&(pms->samples [pms->samplecount * pms->channels]), &(ptr [total]), count * sizeof (short)) ; - indx += count ; - pms->samplecount += count / pms->channels ; - total = indx ; - - if (pms->samplecount >= pms->samplesperblock) - msadpcm_encode_block (psf, pms) ; - } ; - - return total ; -} /* msadpcm_write_block */ - -static sf_count_t -msadpcm_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ MSADPCM_PRIVATE *pms ; - int writecount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - while (len > 0) - { writecount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = (int) msadpcm_write_block (psf, pms, ptr, writecount) ; - - total += count ; - len -= count ; - if (count != writecount) - break ; - } ; - - return total ; -} /* msadpcm_write_s */ - -static sf_count_t -msadpcm_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ MSADPCM_PRIVATE *pms ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = ptr [total + k] >> 16 ; - count = (int) msadpcm_write_block (psf, pms, sptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - return total ; -} /* msadpcm_write_i */ - -static sf_count_t -msadpcm_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ MSADPCM_PRIVATE *pms ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - float normfact ; - - if (! psf->codec_data) - return 0 ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrintf (normfact * ptr [total + k]) ; - count = (int) msadpcm_write_block (psf, pms, sptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - return total ; -} /* msadpcm_write_f */ - -static sf_count_t -msadpcm_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ MSADPCM_PRIVATE *pms ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - if (! psf->codec_data) - return 0 ; - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrint (normfact * ptr [total + k]) ; - count = (int) msadpcm_write_block (psf, pms, sptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - return total ; -} /* msadpcm_write_d */ - -/*======================================================================================== -*/ - -static int -msadpcm_close (SF_PRIVATE *psf) -{ MSADPCM_PRIVATE *pms ; - - pms = (MSADPCM_PRIVATE*) psf->codec_data ; - - if (psf->file.mode == SFM_WRITE) - { /* Now we know static int for certain the length of the file we can - ** re-write the header. - */ - - if (pms->samplecount && pms->samplecount < pms->samplesperblock) - msadpcm_encode_block (psf, pms) ; - } ; - - return 0 ; -} /* msadpcm_close */ - -/*======================================================================================== -** Static functions. -*/ - -/*---------------------------------------------------------------------------------------- -** Choosing the block predictor. -** Each block requires a predictor and an idelta for each channel. -** The predictor is in the range [0..6] which is an indx into the two AdaptCoeff tables. -** The predictor is chosen by trying all of the possible predictors on a small set of -** samples at the beginning of the block. The predictor with the smallest average -** abs (idelta) is chosen as the best predictor for this block. -** The value of idelta is chosen to to give a 4 bit code value of +/- 4 (approx. half the -** max. code value). If the average abs (idelta) is zero, the sixth predictor is chosen. -** If the value of idelta is less then 16 it is set to 16. -** -** Microsoft uses an IDELTA_COUNT (number of sample pairs used to choose best predictor) -** value of 3. The best possible results would be obtained by using all the samples to -** choose the predictor. -*/ - -#define IDELTA_COUNT 3 - -static void -choose_predictor (unsigned int channels, short *data, int *block_pred, int *idelta) -{ unsigned int chan, k, bpred, idelta_sum, best_bpred, best_idelta ; - - for (chan = 0 ; chan < channels ; chan++) - { best_bpred = best_idelta = 0 ; - - for (bpred = 0 ; bpred < 7 ; bpred++) - { idelta_sum = 0 ; - for (k = 2 ; k < 2 + IDELTA_COUNT ; k++) - idelta_sum += abs (data [k * channels] - ((data [(k - 1) * channels] * AdaptCoeff1 [bpred] + data [(k - 2) * channels] * AdaptCoeff2 [bpred]) >> 8)) ; - idelta_sum /= (4 * IDELTA_COUNT) ; - - if (bpred == 0 || idelta_sum < best_idelta) - { best_bpred = bpred ; - best_idelta = idelta_sum ; - } ; - - if (! idelta_sum) - { best_bpred = bpred ; - best_idelta = 16 ; - break ; - } ; - - } ; /* for bpred ... */ - if (best_idelta < 16) - best_idelta = 16 ; - - block_pred [chan] = best_bpred ; - idelta [chan] = best_idelta ; - } ; - - return ; -} /* choose_predictor */ - diff --git a/Engine/lib/libsndfile/src/new.c b/Engine/lib/libsndfile/src/new.c deleted file mode 100644 index 23f3087f1..000000000 --- a/Engine/lib/libsndfile/src/new.c +++ /dev/null @@ -1,116 +0,0 @@ -/* -** Copyright (C) 2002-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if (ENABLE_EXPERIMENTAL_CODE == 0) - -int -new_open (SF_PRIVATE *psf) -{ if (psf) - return SFE_UNIMPLEMENTED ; - return (psf && 0) ; -} /* new_open */ - -#else - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -/*------------------------------------------------------------------------------ -** Typedefs. -*/ - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int new_read_header (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -new_open (SF_PRIVATE *psf) -{ int subformat, error = 0 ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - return SFE_UNIMPLEMENTED ; - - if ((error = new_read_header (psf))) - return error ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_WVE) - return SFE_BAD_OPEN_FORMAT ; - - subformat = SF_CODEC (psf->sf.format) ; - - return error ; -} /* new_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -new_read_header (SF_PRIVATE *psf) -{ int marker ; - - /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "pm", 0, &marker) ; - if (marker != ALAW_MARKER) - return SFE_WVE_NOT_WVE ; - - psf_binheader_readf (psf, "m", &marker) ; - if (marker != SOUN_MARKER) - return SFE_WVE_NOT_WVE ; - - psf_binheader_readf (psf, "m", &marker) ; - if (marker != DFIL_MARKER) - return SFE_WVE_NOT_WVE ; - - psf_log_printf (psf, "Read only : Psion Alaw\n" - " Sample Rate : 8000\n" - " Channels : 1\n" - " Encoding : A-law\n") ; - - psf->dataoffset = 0x20 ; - psf->datalength = psf->filelength - psf->dataoffset ; - - psf->sf.format = SF_FORMAT_WVE | SF_FORMAT_ALAW ; - psf->sf.samplerate = 8000 ; - psf->sf.frames = psf->datalength ; - psf->sf.channels = 1 ; - - return alaw_init (psf) ; -} /* new_read_header */ - -/*------------------------------------------------------------------------------ -*/ - -#endif diff --git a/Engine/lib/libsndfile/src/nist.c b/Engine/lib/libsndfile/src/nist.c deleted file mode 100644 index 657c4d41f..000000000 --- a/Engine/lib/libsndfile/src/nist.c +++ /dev/null @@ -1,372 +0,0 @@ -/* -** Copyright (C) 1999-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** Some of the information used to read NIST files was gleaned from -** reading the code of Bill Schottstaedt's sndlib library -** ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz -** However, no code from that package was used. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -*/ - -#define NIST_HEADER_LENGTH 1024 - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int nist_close (SF_PRIVATE *psf) ; -static int nist_write_header (SF_PRIVATE *psf, int calc_length) ; -static int nist_read_header (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -*/ - -int -nist_open (SF_PRIVATE *psf) -{ int error ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = nist_read_header (psf))) - return error ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (psf->is_pipe) - return SFE_NO_PIPE_WRITE ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_NIST) - return SFE_BAD_OPEN_FORMAT ; - - psf->endian = SF_ENDIAN (psf->sf.format) ; - if (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU) - psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - psf->sf.frames = 0 ; - - if ((error = nist_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = nist_write_header ; - } ; - - psf->container_close = nist_close ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_ULAW : - error = ulaw_init (psf) ; - break ; - - case SF_FORMAT_ALAW : - error = alaw_init (psf) ; - break ; - - default : error = SFE_UNIMPLEMENTED ; - break ; - } ; - - return error ; -} /* nist_open */ - -/*------------------------------------------------------------------------------ -*/ - -static char bad_header [] = -{ 'N', 'I', 'S', 'T', '_', '1', 'A', 0x0d, 0x0a, - ' ', ' ', ' ', '1', '0', '2', '4', 0x0d, 0x0a, - 0 -} ; - - static int -nist_read_header (SF_PRIVATE *psf) -{ char psf_header [NIST_HEADER_LENGTH + 2] ; - int bitwidth = 0, count, encoding ; - unsigned bytes = 0 ; - char str [64], *cptr ; - long samples ; - - /* Go to start of file and read in the whole header. */ - psf_binheader_readf (psf, "pb", 0, psf_header, NIST_HEADER_LENGTH) ; - - /* Header is a string, so make sure it is null terminated. */ - psf_header [NIST_HEADER_LENGTH] = 0 ; - - /* Now trim the header after the end marker. */ - if ((cptr = strstr (psf_header, "end_head"))) - { cptr += strlen ("end_head") + 1 ; - cptr [0] = 0 ; - } ; - - if (strstr (psf_header, bad_header) == psf_header) - return SFE_NIST_CRLF_CONVERISON ; - - /* Make sure its a NIST file. */ - if (strstr (psf_header, "NIST_1A\n") != psf_header) - { psf_log_printf (psf, "Not a NIST file.\n") ; - return SFE_NIST_BAD_HEADER ; - } ; - - if (sscanf (psf_header, "NIST_1A\n%d\n", &count) == 1) - psf->dataoffset = count ; - else - { psf_log_printf (psf, "*** Suspicious header length.\n") ; - psf->dataoffset = NIST_HEADER_LENGTH ; - } ; - - /* Determine sample encoding, start by assuming PCM. */ - encoding = SF_FORMAT_PCM_U8 ; - if ((cptr = strstr (psf_header, "sample_coding -s"))) - { sscanf (cptr, "sample_coding -s%d %63s", &count, str) ; - - if (strcmp (str, "pcm") == 0) - { /* Correct this later when we find out the bitwidth. */ - encoding = SF_FORMAT_PCM_U8 ; - } - else if (strcmp (str, "alaw") == 0) - encoding = SF_FORMAT_ALAW ; - else if ((strcmp (str, "ulaw") == 0) || (strcmp (str, "mu-law") == 0)) - encoding = SF_FORMAT_ULAW ; - else - { psf_log_printf (psf, "*** Unknown encoding : %s\n", str) ; - encoding = 0 ; - } ; - } ; - - if ((cptr = strstr (psf_header, "channel_count -i ")) != NULL) - sscanf (cptr, "channel_count -i %d", &(psf->sf.channels)) ; - - if ((cptr = strstr (psf_header, "sample_rate -i ")) != NULL) - sscanf (cptr, "sample_rate -i %d", &(psf->sf.samplerate)) ; - - if ((cptr = strstr (psf_header, "sample_count -i ")) != NULL) - { sscanf (cptr, "sample_count -i %ld", &samples) ; - psf->sf.frames = samples ; - } ; - - if ((cptr = strstr (psf_header, "sample_n_bytes -i ")) != NULL) - sscanf (cptr, "sample_n_bytes -i %d", &(psf->bytewidth)) ; - - /* Default endian-ness (for 8 bit, u-law, A-law. */ - psf->endian = (CPU_IS_BIG_ENDIAN) ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ; - - /* This is where we figure out endian-ness. */ - if ((cptr = strstr (psf_header, "sample_byte_format -s")) - && sscanf (cptr, "sample_byte_format -s%u %8s", &bytes, str) == 2) - { - if (bytes != strlen (str)) - psf_log_printf (psf, "Weird sample_byte_format : strlen '%s' != %d\n", str, bytes) ; - - if (bytes > 1) - { if (psf->bytewidth == 0) - psf->bytewidth = bytes ; - else if (psf->bytewidth - bytes != 0) - { psf_log_printf (psf, "psf->bytewidth (%d) != bytes (%d)\n", psf->bytewidth, bytes) ; - return SFE_NIST_BAD_ENCODING ; - } ; - - if (strcmp (str, "01") == 0) - psf->endian = SF_ENDIAN_LITTLE ; - else if (strcmp (str, "10") == 0) - psf->endian = SF_ENDIAN_BIG ; - else - { psf_log_printf (psf, "Weird endian-ness : %s\n", str) ; - return SFE_NIST_BAD_ENCODING ; - } ; - } ; - - psf->sf.format |= psf->endian ; - } ; - - if ((cptr = strstr (psf_header, "sample_sig_bits -i "))) - sscanf (cptr, "sample_sig_bits -i %d", &bitwidth) ; - - if (strstr (psf_header, "channels_interleaved -s5 FALSE")) - { psf_log_printf (psf, "Non-interleaved data unsupported.\n", str) ; - return SFE_NIST_BAD_ENCODING ; - } ; - - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - psf->datalength = psf->filelength - psf->dataoffset ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - if (encoding == SF_FORMAT_PCM_U8) - { switch (psf->bytewidth) - { case 1 : - psf->sf.format |= SF_FORMAT_PCM_S8 ; - break ; - - case 2 : - psf->sf.format |= SF_FORMAT_PCM_16 ; - break ; - - case 3 : - psf->sf.format |= SF_FORMAT_PCM_24 ; - break ; - - case 4 : - psf->sf.format |= SF_FORMAT_PCM_32 ; - break ; - - default : break ; - } ; - } - else if (encoding != 0) - psf->sf.format |= encoding ; - else - return SFE_UNIMPLEMENTED ; - - /* Sanitize psf->sf.format. */ - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_ULAW : - case SF_FORMAT_ALAW : - case SF_FORMAT_PCM_U8 : - /* Blank out endian bits. */ - psf->sf.format = SF_FORMAT_NIST | SF_CODEC (psf->sf.format) ; - break ; - - default : - break ; - } ; - - return 0 ; -} /* nist_read_header */ - -static int -nist_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - nist_write_header (psf, SF_TRUE) ; - - return 0 ; -} /* nist_close */ - -/*========================================================================= -*/ - -static int -nist_write_header (SF_PRIVATE *psf, int calc_length) -{ const char *end_str ; - long samples ; - sf_count_t current ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - if (psf->bytewidth > 0) - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - if (psf->endian == SF_ENDIAN_BIG) - end_str = "10" ; - else if (psf->endian == SF_ENDIAN_LITTLE) - end_str = "01" ; - else - end_str = "error" ; - - /* Clear the whole header. */ - memset (psf->header.ptr, 0, psf->header.len) ; - psf->header.indx = 0 ; - - psf_fseek (psf, 0, SEEK_SET) ; - - psf_asciiheader_printf (psf, "NIST_1A\n 1024\n") ; - psf_asciiheader_printf (psf, "channel_count -i %d\n", psf->sf.channels) ; - psf_asciiheader_printf (psf, "sample_rate -i %d\n", psf->sf.samplerate) ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - psf_asciiheader_printf (psf, "sample_coding -s3 pcm\n") ; - psf_asciiheader_printf (psf, "sample_n_bytes -i 1\n" - "sample_sig_bits -i 8\n") ; - break ; - - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - psf_asciiheader_printf (psf, "sample_n_bytes -i %d\n", psf->bytewidth) ; - psf_asciiheader_printf (psf, "sample_sig_bits -i %d\n", psf->bytewidth * 8) ; - psf_asciiheader_printf (psf, "sample_coding -s3 pcm\n" - "sample_byte_format -s%d %s\n", psf->bytewidth, end_str) ; - break ; - - case SF_FORMAT_ALAW : - psf_asciiheader_printf (psf, "sample_coding -s4 alaw\n") ; - psf_asciiheader_printf (psf, "sample_n_bytes -s1 1\n") ; - break ; - - case SF_FORMAT_ULAW : - psf_asciiheader_printf (psf, "sample_coding -s4 ulaw\n") ; - psf_asciiheader_printf (psf, "sample_n_bytes -s1 1\n") ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - psf->dataoffset = NIST_HEADER_LENGTH ; - - /* Fix this */ - samples = psf->sf.frames ; - psf_asciiheader_printf (psf, "sample_count -i %ld\n", samples) ; - psf_asciiheader_printf (psf, "end_head\n") ; - - /* Zero fill to dataoffset. */ - psf_binheader_writef (psf, "z", BHWz ((size_t) (NIST_HEADER_LENGTH - psf->header.indx))) ; - - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* nist_write_header */ - diff --git a/Engine/lib/libsndfile/src/nms_adpcm.c b/Engine/lib/libsndfile/src/nms_adpcm.c deleted file mode 100644 index 96d6ad268..000000000 --- a/Engine/lib/libsndfile/src/nms_adpcm.c +++ /dev/null @@ -1,1156 +0,0 @@ -/* -** Copyright (C) 1999-2014 Erik de Castro Lopo -** Copyright (C) 2017 Arthur Taylor -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** This is a Natural MicroSystems ADPCM encoder/decoder. It converts 14 bit linear -** PCM to and from either a 2, 3, or 4 bit ADPCM. NMS-ADPCM does not have appeared -** to have ever been publicly documented, and appears to have debuted in the early -** 90s in the Natural Access suite of PC-based telephony products. Raw NMS ADPCM -** files usually have a .vce extension, although this does not encode what bitrate -** is used. -** -** NMS-ADPCM is an 'optimised variation' of the ITU G.726 ADPCM scheme. The dominant -** variation is that it removes the tone (modem) operation mode, and it's associated -** voice/modem transition detection. This simplifies the computation of the step -** size multiplier, as all operations on it remain in a log domain. -*/ - -#include "sfconfig.h" - -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - - -#define NMS_SAMPLES_PER_BLOCK 160 -#define NMS_BLOCK_SHORTS_32 41 -#define NMS_BLOCK_SHORTS_24 31 -#define NMS_BLOCK_SHORTS_16 21 - -/* Variable names from ITU G.726 spec */ -struct nms_adpcm_state -{ /* Log of the step size multiplier. Operated on by codewords. */ - int yl ; - - /* Quantizer step size multiplier. Generated from yl. */ - int y ; - - /* Coefficents of the pole predictor */ - int a [2] ; - - /* Coefficents of the zero predictor */ - int b [6] ; - - /* Previous quantized deltas (multiplied by 2^14) */ - int d_q [7] ; - - /* d_q [x] + s_ez [x], used by the pole-predictor for signs only. */ - int p [3] ; - - /* Previous reconstructed signal values. */ - int s_r [2] ; - - /* Zero predictor components of the signal estimate. */ - int s_ez ; - - /* Signal estimate, (including s_ez). */ - int s_e ; - - /* The most recent codeword (enc:generated, dec:inputted) */ - int Ik ; - - int parity ; - - /* - ** Offset into code tables for the bitrate. - ** 2-bit words: +0 - ** 3-bit words: +8 - ** 4-bit words: +16 - */ - int t_off ; -} ; - -enum nms_enc_type -{ NMS16, - NMS24, - NMS32 -} ; - -typedef struct -{ struct nms_adpcm_state state ; - - /* The encoding type */ - enum nms_enc_type type ; - - int shortsperblock ; - int blocks_total ; - int block_curr, sample_curr ; - - unsigned short block [NMS_BLOCK_SHORTS_32] ; - short samples [NMS_SAMPLES_PER_BLOCK] ; -} NMS_ADPCM_PRIVATE ; - -/* Pre-computed exponential interval used in the antilog approximation. */ -static unsigned int table_expn [] = -{ 0x4000, 0x4167, 0x42d5, 0x444c, 0x45cb, 0x4752, 0x48e2, 0x4a7a, - 0x4c1b, 0x4dc7, 0x4f7a, 0x5138, 0x52ff, 0x54d1, 0x56ac, 0x5892, - 0x5a82, 0x5c7e, 0x5e84, 0x6096, 0x62b4, 0x64dd, 0x6712, 0x6954, - 0x6ba2, 0x6dfe, 0x7066, 0x72dc, 0x7560, 0x77f2, 0x7a93, 0x7d42, -} ; - -/* Table mapping codewords to scale factor deltas. */ -static int table_scale_factor_step [] = -{ 0x0, 0x0, 0x0, 0x0, 0x4b0, 0x0, 0x0, 0x0, /* 2-bit */ - -0x3c, 0x0, 0x90, 0x0, 0x2ee, 0x0, 0x898, 0x0, /* 3-bit */ - -0x30, 0x12, 0x6b, 0xc8, 0x188, 0x2e0, 0x551, 0x1150, /* 4-bit */ -} ; - -/* Table mapping codewords to quantized delta interval steps. */ -static unsigned int table_step [] = -{ 0x73F, 0, 0, 0, 0x1829, 0, 0, 0, /* 2-bit */ - 0x3EB, 0, 0xC18, 0, 0x1581, 0, 0x226E, 0, /* 3-bit */ - 0x20C, 0x635, 0xA83, 0xF12, 0x1418, 0x19E3, 0x211A, 0x2BBA, /* 4-bit */ -} ; - -/* Binary search lookup table for quantizing using table_step. */ -static int table_step_search [] = -{ 0, 0x1F6D, 0, -0x1F6D, 0, 0, 0, 0, /* 2-bit */ - 0x1008, 0x1192, 0, -0x219A, 0x1656, -0x1656, 0, 0, /* 3-bit */ - 0x872, 0x1277, -0x8E6, -0x232B, 0xD06, -0x17D7, -0x11D3, 0, /* 4-bit */ -} ; - - -/*============================================================================================ -** Static functions. -*/ - -static void nms_adpcm_update (struct nms_adpcm_state *s) ; -static void nms_adpcm_codec_init (struct nms_adpcm_state *s, enum nms_enc_type type) ; - -static int16_t nms_adpcm_reconstruct_sample (struct nms_adpcm_state *s, uint8_t I) ; -static uint8_t nms_adpcm_encode_sample (struct nms_adpcm_state *s, int16_t sl) ; -static int16_t nms_adpcm_decode_sample (struct nms_adpcm_state *s, uint8_t code) ; - -static void nms_adpcm_block_pack_16 (const int16_t codewords [], uint16_t block [], int16_t rms) ; -static void nms_adpcm_block_pack_24 (const int16_t codewords [], uint16_t block [], int16_t rms) ; -static void nms_adpcm_block_pack_32 (const int16_t codewords [], uint16_t block [], int16_t rms) ; - -static void nms_adpcm_block_unpack_16 (const uint16_t block [], int16_t codewords [], int16_t *rms) ; -static void nms_adpcm_block_unpack_24 (const uint16_t block [], int16_t codewords [], int16_t *rms) ; -static void nms_adpcm_block_unpack_32 (const uint16_t block [], int16_t codewords [], int16_t *rms) ; - -static int nms_adpcm_decode_block (SF_PRIVATE *psf, NMS_ADPCM_PRIVATE *pnms, uint16_t block [], int16_t samples []) ; -static int nms_adpcm_encode_block (SF_PRIVATE *psf, NMS_ADPCM_PRIVATE *pnms, int16_t samples [], uint16_t block []) ; - -static sf_count_t nms_adpcm_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t nms_adpcm_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t nms_adpcm_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t nms_adpcm_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t nms_adpcm_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t nms_adpcm_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t nms_adpcm_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t nms_adpcm_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static int nms_adpcm_close (SF_PRIVATE *psf) ; -static sf_count_t nms_adpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; - -/* -** An exponential function (antilog) approximation. -** -** Maps [1,20480] to [1,1024] in an exponential relationship. This is -** approximately ret = b^exp where b = e^(ln(1024)/ln(20480)) ~= 1.0003385 -*/ -static inline int -nms_adpcm_antilog (int exp) -{ int ret ; - - ret = 0x1000 ; - ret += (((exp & 0x3f) * 0x166b) >> 12) ; - ret *= table_expn [(exp & 0x7c0) >> 6] ; - ret >>= (26 - (exp >> 11)) ; - - return ret ; -} /* nms_adpcm_antilog */ - -static void -nms_adpcm_update (struct nms_adpcm_state *s) -{ /* Variable names from ITU G.726 spec */ - int a1ul ; - int fa1 ; - int i ; - - /* Decay and Modify the scale factor in the log domain based on the codeword. */ - s->yl = ((s->yl *0xf8) >> 8) + table_scale_factor_step [s->t_off + (s->Ik & 7)] ; - if (s->yl < 2171) - s->yl = 2171 ; - else if (s->yl > 20480) - s->yl = 20480 ; - s->y = nms_adpcm_antilog (s->yl) ; - - /* Update the zero predictor coefficents. */ - for (i = 0 ; i < 6 ; i++) - { s->b [i] = (s->b [i] * 0xff) >> 8 ; - if ((s->d_q [0] ^ s->d_q [i + 1]) >= 0) - s->b [i] += 128 ; - else - s->b [i] -= 128 ; - } - - /* Update the pole predictor coefficents. */ - fa1 = s->a [0] >> 5 ; - if (fa1 < -256) - fa1 = -256 ; - else if (fa1 > 256) - fa1 = 256 ; - - s->a [0] = (0xff * s->a [0]) >> 8 ; - if (s->p [0] != 0 && s->p [1] != 0 && ((s->p [0] ^ s->p [1]) < 0)) - s->a [0] -= 192 ; - else - { s->a [0] += 192 ; - fa1 = -fa1 ; - } - - s->a [1] = fa1 + ((0xfe * s->a [1]) >> 8) ; - if (s->p [0] != 0 && s->p [2] != 0 && ((s->p [0] ^ s->p [2]) < 0)) - s->a [1] -= 128 ; - else - s->a [1] += 128 ; - - /* Stability constraints. */ - if (s->a [1] < -12288) - s->a [1] = -12288 ; - else if (s->a [1] > 12288) - s->a [1] = 12288 ; - a1ul = 15360 - s->a [1] ; - if (s->a [0] >= a1ul) - s->a [0] = a1ul ; - else - { a1ul = -a1ul ; - if (s->a [0] < a1ul) - s->a [0] = a1ul ; - } ; - - /* Compute the zero predictor estimate. Rotate past deltas too. */ - s->s_ez = 0 ; - for (i = 5 ; i >= 0 ; i--) - { s->s_ez += s->d_q [i] * s->b [i] ; - s->d_q [i + 1] = s->d_q [i] ; - } ; - - /* Compute the signal estimate. */ - s->s_e = s->a [0] * s->s_r [0] + s->a [1] * s->s_r [1] + s->s_ez ; - - /* Return to scale */ - s->s_ez >>= 14 ; - s->s_e >>= 14 ; - - /* Rotate members to prepare for next iteration. */ - s->s_r [1] = s->s_r [0] ; - s->p [2] = s->p [1] ; - s->p [1] = s->p [0] ; -} /* nms_adpcm_update */ - - -static int16_t -nms_adpcm_reconstruct_sample (struct nms_adpcm_state *s, uint8_t I) -{ /* Variable names from ITU G.726 spec */ - int dqx ; - - /* - ** The ordering of the 12-bit right-shift is a precision loss. It agrees - ** with the output of a 16-bit NMSVCE.DLL, but disagrees with the output - ** of a CG6565 board. - */ - - /* Look up the delta, scale and sign it. */ - dqx = table_step [s->t_off + (I & 7)] * s->y ; - if (I & 8) - dqx = -dqx ; - - /* Take from delta scale to actual scale. */ - dqx >>= 12 ; - - /* Set variables used as input for the next predictor update. */ - s->d_q [0] = dqx ; - s->s_r [0] = s->s_e + dqx ; - s->Ik = I & 0xf ; - s->p [0] = s->s_ez + dqx ; - - return s->s_r [0] ; -} /* nms_adpcm_reconstruct_sample */ - -static void -nms_adpcm_codec_init (struct nms_adpcm_state *s, enum nms_enc_type type) -{ memset (s, 0, sizeof (struct nms_adpcm_state)) ; - s->t_off = (type == NMS32) ? 16 : (type == NMS24) ? 8 : 0 ; -} /* nms_adpcm_codec_init */ - -/* -** nms_adpcm_encode_sample() -** -** Encode a linear 16-bit pcm sample into a 2,3, or 4 bit NMS-ADPCM codeword -** using and updating the predictor state. -*/ -static uint8_t -nms_adpcm_encode_sample (struct nms_adpcm_state *s, int16_t sl) -{ /* Variable names from ITU G.726 spec */ - int d ; - uint8_t I ; - - /* Down scale the sample from 16 => ~14 bits. */ - sl = (sl * 0x1fdf) / 0x7fff ; - - /* Compute estimate, and delta from actual value */ - nms_adpcm_update (s) ; - d = sl - s->s_e ; - - /* - ** Vary the input signal. Not sure why. It agrees with NMSVCE.DLL and - ** a CG6565 board. - */ - if (s->parity ^= 1) - d -= 2 ; - - /* Encode the delta signed-ness (Codeword bit 4) */ - if (d < 0) - { d = -d ; - I = 8 ; - } - else - I = 0 ; - - /* Increase magnitude to be in the range of the delta steps */ - d <<= 13 ; - - /* Quantize the delta using a binary search. */ - d += table_step_search [s->t_off + 3] * s->y ; - /* Codeword bit 3 */ - if (d >= 0) - { d += table_step_search [s->t_off + 5] * s->y ; - /* Codeword bit 2 */ - if (d >= 0) - { d += table_step_search [s->t_off + 6] * s->y ; - /* Codeword bit 1 */ - if (d >= 0) - I |= 7 ; - else - I |= 6 ; - } - else - { d += table_step_search [s->t_off + 4] * s->y ; - /* Codeword bit 1 */ - if (d >= 0) - I |= 5 ; - else - I |= 4 ; - } ; - } - else { - d += table_step_search [s->t_off + 1] * s->y ; - /* Codeword bit 2 */ - if (d >= 0) - { d += table_step_search [s->t_off + 2] * s->y ; - /* Codeword bit 1 */ - if (d >= 0) - I |= 3 ; - else - I |= 2 ; - } - else { - d += table_step_search [s->t_off + 0] * s->y ; - /* Codeword bit 1 */ - if (d >= 0) - I |= 1 ; - else - I |= 0 ; - } ; - } ; - /* What's left in d is actually our quantizer noise. */ - - /* Reduce the codeword size for the bitrate accordingly. */ - if (s->t_off == 8) - I &= 0xe ; - else if (s->t_off == 0) - I &= 0xc ; - - /* Call reconstruct for side effects preparing for the next update. */ - nms_adpcm_reconstruct_sample (s, I) ; - - return I ; -} /* nms_adpcm_encode_sample */ - -/* -** nms_adpcm_decode_sample() -** -** Given a 2,3 or 4-bit NMS-ADPCM codeword, decode the next 16-bit linear PCM -** sample using and updating the predictor state. -*/ -static int16_t -nms_adpcm_decode_sample (struct nms_adpcm_state *s, uint8_t I) -{ int sl ; - - nms_adpcm_update (s) ; - sl = nms_adpcm_reconstruct_sample (s, I) ; - - /* Clamp to [-0x1fdf, 0x1fdf] (just under 14 bits resolution) */ - if (sl < -0x1fdf) - sl = -0x1fdf ; - else if (sl > 0x1fdf) - sl = 0x1fdf ; - - /* Expand from 14 to 16 bits */ - sl = (sl * 0x7fff) / 0x1fdf ; - - return (int16_t) sl ; -} /* nms_adpcm_decode_sample */ - -/** -** NMS ADPCM Codeword packing scheme. -** -** The serialized form of NMS-ADPCM operates on blocks of 160 mono samples -** (20ms at 8000Hz.) Blocks are 42, 62 and 82 bytes in size for the 2, 3, and -** 4 bit codeword sizes respectively. The data is treated as an array of -** little-endian 2-byte shorts, and the data is packed into the first 20, 30 -** or 40 shorts. The last short represents the block's root-mean-square -** average. This is apparently an optimization so that energy/silence -** detection processes can avoid decoding a block. -** -** All codewords are nibbles, with the least significant bits dropped as -** required for the 3 and 2 bit codeword sizes. -** -** Nibbles are packed into shorts in order of most significant to least. The -** 4-bit scheme is trivial. The three bit scheme reconstructs a fourth sample -** from the leftover bits of the proceeding three samples. The 2-bit scheme -** uses a two-pass, left two bit shift. -*/ - -/* -** Reads 21 shorts from block, unpacks 160 codewords of 2-bits each, writing -** each to its sequential array index of codewords. If rms is non-null, the -** read block rms is copied to its location. -*/ -static void -nms_adpcm_block_unpack_16 (const uint16_t block [], int16_t codewords [], int16_t *rms) -{ int k ; - uint16_t w = 0 ; - - for (k = 0 ; k < NMS_SAMPLES_PER_BLOCK ; ) - { /* - ** k % 8 == [0-3]: Top 2-bits of a nibble - ** k % 8 == [4-7]: Bottom 2-bits of a nibble - */ - if ((k & 4) == 0) - w = *(block++) ; - else - w <<= 2 ; - codewords [k++] = (w >> 12) & 0xc ; - codewords [k++] = (w >> 8) & 0xc ; - codewords [k++] = (w >> 4) & 0xc ; - codewords [k++] = w & 0xc ; - } ; - - /* - ** Every block ends with a short representing a RMS-approximation for the - ** block. - **/ - if (rms) - *rms = *block ; -} /* nms_adpcm_unpack_16 */ - -/* -** Reads 31 shorts from block, unpacks 160 codewords of 3-bits each, writing -** each to its sequential array index of codewords. If rms is non-null, the -** read block rms is copied to its location. -*/ -static void -nms_adpcm_block_unpack_24 (const uint16_t block [], int16_t codewords [], int16_t *rms) -{ int k ; - uint16_t w = 0, residual = 0 ; - - for (k = 0 ; k < NMS_SAMPLES_PER_BLOCK ; ) - { /* - ** k % 16 == [0, 11]: Unpack new nibble, build residual - ** k % 16 == [12, 15]: Unpack residual - */ - if ((k & 12) != 12) - { w = *(block++) ; - residual = (residual << 1) | (w & 0x1111) ; - } - else - { w = residual << 1 ; - residual = 0 ; - } ; - codewords [k++] = (w >> 12) & 0xe ; - codewords [k++] = (w >> 8) & 0xe ; - codewords [k++] = (w >> 4) & 0xe ; - codewords [k++] = w & 0xe ; - } ; - - /* - ** Every block ends with a short representing a RMS-approximation for the - ** block. - **/ - if (rms) - *rms = *block ; -} /* nms_adpcm_unpack_24 */ - -/* -** Reads 41 shorts from block, unpacks 160 codewords of 4-bits each, writing -** each to its sequential array index of codewords. If rms is non-null, the -** read block rms is copied to its location. -*/ -static void -nms_adpcm_block_unpack_32 (const uint16_t block [], int16_t codewords [], int16_t *rms) -{ int k ; - uint16_t w = 0 ; - - for (k = 0 ; k < NMS_SAMPLES_PER_BLOCK ; ) - { w = *(block++) ; - codewords [k++] = (w >> 12) & 0xf ; - codewords [k++] = (w >> 8) & 0xf ; - codewords [k++] = (w >> 4) & 0xf ; - codewords [k++] = w & 0xf ; - } ; - /* - ** Every block ends with a short representing a RMS-approximation for the - ** block. - **/ - if (rms) - *rms = *block ; -} /* nms_adpcm_unpack_32 */ - -/* -** Reads 160 indicies of codewords for one 2-bit codeword each, packing them -** into 20 shorts of block, and writes the short rms for a total of 42 bytes. -*/ -static void -nms_adpcm_block_pack_16 (const int16_t codewords [], uint16_t block [], int16_t rms) -{ int k ; - uint16_t w ; - - for (k = 0 ; k < NMS_SAMPLES_PER_BLOCK ; ) - { w = codewords [k++] << 12 ; - w |= codewords [k++] << 8 ; - w |= codewords [k++] << 4 ; - w |= codewords [k++] ; - w |= codewords [k++] << 10 ; - w |= codewords [k++] << 6 ; - w |= codewords [k++] << 2 ; - w |= codewords [k++] >> 2 ; - - *(block++) = w ; - } ; - - /* Every block ends with a short representing the blocks RMS */ - *block = rms ; -} /* nms_adpcm_pack_16 */ - -/* -** Reads 160 indicies of codewords for one 3-bit codeword each, packing them -** into 30 shorts of block, and writes the short rms for a total of 62 bytes. -*/ -static void -nms_adpcm_block_pack_24 (const int16_t codewords [], uint16_t block [], int16_t rms) -{ int k ; - uint16_t w [3] ; - uint16_t residual ; - - for (k = 0 ; k < NMS_SAMPLES_PER_BLOCK ; ) - { w [0] = codewords [k++] << 12 ; - w [0] |= codewords [k++] << 8 ; - w [0] |= codewords [k++] << 4 ; - w [0] |= codewords [k++] ; - - w [1] = codewords [k++] << 12 ; - w [1] |= codewords [k++] << 8 ; - w [1] |= codewords [k++] << 4 ; - w [1] |= codewords [k++] ; - - w [2] = codewords [k++] << 12 ; - w [2] |= codewords [k++] << 8 ; - w [2] |= codewords [k++] << 4 ; - w [2] |= codewords [k++] ; - - residual = codewords [k++] << 12 ; - residual |= codewords [k++] << 8 ; - residual |= codewords [k++] << 4 ; - residual |= codewords [k++] ; - - residual >>= 1 ; - w [2] |= (residual & 0x1111) ; - residual >>= 1 ; - w [1] |= (residual & 0x1111) ; - residual >>= 1 ; - w [0] |= (residual & 0x1111) ; - - *(block++) = w [0] ; - *(block++) = w [1] ; - *(block++) = w [2] ; - } ; - - /* Every block ends with a short representing the blocks RMS */ - *block = rms ; -} /* nms_adpcm_pack_24 */ - -/* -** Reads 160 indicies of codewords for one 4-bit codeword each, packing them -** into 40 shorts of block, and writes the short rms for a total of 82 bytes. -*/ -static void -nms_adpcm_block_pack_32 (const int16_t codewords [], uint16_t block [], int16_t rms) -{ int k ; - uint16_t w ; - - for (k = 0 ; k < NMS_SAMPLES_PER_BLOCK ; ) - { w = codewords [k++] << 12 ; - w |= codewords [k++] << 8 ; - w |= codewords [k++] << 4 ; - w |= codewords [k++] ; - - *(block++) = w ; - } ; - - /* Every block ends with a short representing the blocks RMS */ - *block = rms ; -} /*nms_adpcm_block_pack_32 */ - -static int -nms_adpcm_decode_block (SF_PRIVATE *psf, NMS_ADPCM_PRIVATE *pnms, uint16_t block [], int16_t samples []) -{ int k ; - - switch (pnms->type) - { case NMS16 : - nms_adpcm_block_unpack_16 (block, samples, NULL) ; - break ; - case NMS24 : - nms_adpcm_block_unpack_24 (block, samples, NULL) ; - break ; - case NMS32 : - nms_adpcm_block_unpack_32 (block, samples, NULL) ; - break ; - - default : - psf_log_printf (psf, "*** Error : Unhandled NMS ADPCM type %d.\n", pnms->type) ; - return 0 ; - } ; - - for (k = 0 ; k < NMS_SAMPLES_PER_BLOCK ; k++) - samples [k] = nms_adpcm_decode_sample (&pnms->state, samples [k]) ; - - return NMS_SAMPLES_PER_BLOCK ; -} /* nms_adpcm_decode_block */ - -static int -nms_adpcm_encode_block (SF_PRIVATE *psf, NMS_ADPCM_PRIVATE *pnms, int16_t samples [], uint16_t block []) -{ int k ; - unsigned int rms = 0 ; - - /* - ** The rms we write is a complete lie. Considering that the various - ** other implementations I've tested don't completely agree, that this data - ** is usually ignored, and except for some weird offloading of "energy - ** detection", so long as we don't write zeros for non-zero data, I don't - ** think it really matters. - */ - - for (k = 0 ; k < NMS_SAMPLES_PER_BLOCK ; k++) - { rms += (samples [k] * samples [k]) >> 2 ; - samples [k] = nms_adpcm_encode_sample (&pnms->state, samples [k]) ; - } ; - - rms <<= 12 ; - switch (pnms->type) - { case NMS16 : - nms_adpcm_block_pack_16 (samples, block, rms) ; - break ; - case NMS24 : - nms_adpcm_block_pack_24 (samples, block, rms) ; - break ; - case NMS32 : - nms_adpcm_block_pack_32 (samples, block, rms) ; - break ; - - default : - psf_log_printf (psf, "*** Error : Unhandled NMS ADPCM type %d.\n", pnms->type) ; - return 0 ; - } ; - - return NMS_SAMPLES_PER_BLOCK ; -} /* nms_adpcm_encode_block */ - -static int -psf_nms_adpcm_decode_block (SF_PRIVATE *psf, NMS_ADPCM_PRIVATE *pnms) -{ int k ; - - if ((k = (int) psf_fread (pnms->block, sizeof (short), pnms->shortsperblock, psf)) != pnms->shortsperblock) - { psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pnms->shortsperblock) ; - memset (pnms->block + (k * sizeof (short)), 0, (pnms->shortsperblock - k) * sizeof (short)) ; - } ; - - if (CPU_IS_BIG_ENDIAN) - endswap_short_array ((signed short *) pnms->block, pnms->shortsperblock) ; - - nms_adpcm_decode_block (psf, pnms, pnms->block, pnms->samples) ; - - return 1 ; -} /* nms_adpcm_decode_block */ - -static int -nms_adpcm_read_block (SF_PRIVATE *psf, NMS_ADPCM_PRIVATE *pnms, short *ptr, int len) -{ int count, indx = 0 ; - - while (indx < len) - { if (pnms->sample_curr >= NMS_SAMPLES_PER_BLOCK) - { pnms->block_curr ++ ; - pnms->sample_curr = 0 ; - } ; - - if (pnms->block_curr > pnms->blocks_total) - { memset (&(ptr [indx]), 0, (len - indx) * sizeof (short)) ; - return indx ; - } ; - - if (pnms->sample_curr == 0) - psf_nms_adpcm_decode_block (psf, pnms) ; - - count = NMS_SAMPLES_PER_BLOCK - pnms->sample_curr ; - if (len - indx < count) - count = len - indx ; - - memcpy (&(ptr [indx]), &(pnms->samples [pnms->sample_curr]), count * sizeof (short)) ; - indx += count ; - pnms->sample_curr += count ; - } ; - - return indx ; -} /* nms_adpcm_read_block */ - -static sf_count_t -nms_adpcm_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ NMS_ADPCM_PRIVATE *pnms ; - int readcount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pnms = (NMS_ADPCM_PRIVATE*) psf->codec_data ; - - while (len > 0) - { readcount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = nms_adpcm_read_block (psf, pnms, ptr, readcount) ; - - total += count ; - len -= count ; - - if (count != readcount) - break ; - } ; - - return total ; -} /* nms_adpcm_read_s */ - -static sf_count_t -nms_adpcm_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - NMS_ADPCM_PRIVATE *pnms ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pnms = (NMS_ADPCM_PRIVATE *) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = nms_adpcm_read_block (psf, pnms, sptr, readcount) ; - - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = arith_shift_left (sptr [k], 16) ; - - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* nms_adpcm_read_i */ - -static sf_count_t -nms_adpcm_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - NMS_ADPCM_PRIVATE *pnms ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pnms = (NMS_ADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = nms_adpcm_read_block (psf, pnms, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * sptr [k] ; - - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* nms_adpcm_read_f */ - -static sf_count_t -nms_adpcm_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - NMS_ADPCM_PRIVATE *pnms ; - short *sptr ; - int k, bufferlen, readcount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pnms = (NMS_ADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = nms_adpcm_read_block (psf, pnms, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (double) (sptr [k]) ; - - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* nms_adpcm_read_d */ - -static int -psf_nms_adpcm_encode_block (SF_PRIVATE *psf, NMS_ADPCM_PRIVATE *pnms) -{ int k ; - - /* Encode the samples. */ - nms_adpcm_encode_block (psf, pnms, pnms->samples, pnms->block) ; - - if (CPU_IS_BIG_ENDIAN) - endswap_short_array ((signed short *) pnms->block, pnms->shortsperblock) ; - - /* Write the block to disk. */ - if ((k = (int) psf_fwrite (pnms->block, sizeof (short), pnms->shortsperblock, psf)) != pnms->shortsperblock) - psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pnms->shortsperblock) ; - - pnms->sample_curr = 0 ; - pnms->block_curr ++ ; - - return 1 ; -} /* psf_nms_adpcm_encode_block */ - -static int -nms_adpcm_write_block (SF_PRIVATE *psf, NMS_ADPCM_PRIVATE *pnms, const short *ptr, int len) -{ int count, total = 0, indx = 0 ; - - while (indx < len) - { count = NMS_SAMPLES_PER_BLOCK - pnms->sample_curr ; - - if (count > len - indx) - count = len - indx ; - - memcpy (&(pnms->samples [pnms->sample_curr]), &(ptr [indx]), count * sizeof (short)) ; - indx += count ; - pnms->sample_curr += count ; - total = indx ; - - if (pnms->sample_curr >= NMS_SAMPLES_PER_BLOCK) - psf_nms_adpcm_encode_block (psf, pnms) ; - } ; - - return total ; -} /* nms_adpcm_write_block */ - -static sf_count_t -nms_adpcm_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ NMS_ADPCM_PRIVATE *pnms ; - int writecount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pnms = (NMS_ADPCM_PRIVATE*) psf->codec_data ; - - while (len > 0) - { writecount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = nms_adpcm_write_block (psf, pnms, ptr, writecount) ; - - total += count ; - len -= count ; - if (count != writecount) - break ; - } ; - - return total ; -} /* nms_adpcm_write_s */ - -static sf_count_t -nms_adpcm_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - NMS_ADPCM_PRIVATE *pnms ; - short *sptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - pnms = (NMS_ADPCM_PRIVATE*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = ptr [total + k] >> 16 ; - count = nms_adpcm_write_block (psf, pnms, sptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - return total ; -} /* nms_adpcm_write_i */ - -static sf_count_t -nms_adpcm_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - NMS_ADPCM_PRIVATE *pnms ; - short *sptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pnms = (NMS_ADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrintf (normfact * ptr [total + k]) ; - count = nms_adpcm_write_block (psf, pnms, sptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* nms_adpcm_write_f */ - -static sf_count_t -nms_adpcm_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - NMS_ADPCM_PRIVATE *pnms ; - short *sptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->codec_data == NULL) - return 0 ; - pnms = (NMS_ADPCM_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = SF_BUFFER_LEN / sizeof (short) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrint (normfact * ptr [total + k]) ; - count = nms_adpcm_write_block (psf, pnms, sptr, writecount) ; - - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* nms_adpcm_write_d */ - -int -nms_adpcm_init (SF_PRIVATE *psf) -{ NMS_ADPCM_PRIVATE *pnms ; - - if (psf->codec_data != NULL) - { psf_log_printf (psf, "*** psf->codec_data is not NULL.\n") ; - return SFE_INTERNAL ; - } ; - - psf->sf.seekable = SF_FALSE ; - - if (psf->sf.channels != 1) - return SFE_NMS_ADPCM_NOT_MONO ; - - if ((pnms = calloc (1, sizeof (NMS_ADPCM_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - - psf->codec_data = (void*) pnms ; - - pnms->block_curr = 0 ; - pnms->sample_curr = 0 ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_NMS_ADPCM_16 : - pnms->type = NMS16 ; - pnms->shortsperblock = NMS_BLOCK_SHORTS_16 ; - break ; - case SF_FORMAT_NMS_ADPCM_24 : - pnms->type = NMS24 ; - pnms->shortsperblock = NMS_BLOCK_SHORTS_24 ; - break ; - case SF_FORMAT_NMS_ADPCM_32 : - pnms->type = NMS32 ; - pnms->shortsperblock = NMS_BLOCK_SHORTS_32 ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - nms_adpcm_codec_init (&pnms->state, pnms->type) ; - - psf->filelength = psf_get_filelen (psf) ; - if (psf->filelength < psf->dataoffset) - psf->filelength = psf->dataoffset ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend > 0) - psf->datalength -= psf->filelength - psf->dataend ; - - if (psf->file.mode == SFM_READ) - { psf->read_short = nms_adpcm_read_s ; - psf->read_int = nms_adpcm_read_i ; - psf->read_float = nms_adpcm_read_f ; - psf->read_double = nms_adpcm_read_d ; - } - else if (psf->file.mode == SFM_WRITE) - { psf->write_short = nms_adpcm_write_s ; - psf->write_int = nms_adpcm_write_i ; - psf->write_float = nms_adpcm_write_f ; - psf->write_double = nms_adpcm_write_d ; - } ; - - if (psf->datalength % (pnms->shortsperblock * sizeof (short))) - { psf_log_printf (psf, "*** Odd psf->datalength (%D) should be a multiple of %d\n", - psf->datalength, pnms->shortsperblock * sizeof (short)) ; - pnms->blocks_total = (psf->datalength / (pnms->shortsperblock * sizeof (short))) + 1 ; - } - else - pnms->blocks_total = psf->datalength / (pnms->shortsperblock * sizeof (short)) ; - - psf->sf.frames = pnms->blocks_total * NMS_SAMPLES_PER_BLOCK ; - psf->codec_close = nms_adpcm_close ; - psf->seek = nms_adpcm_seek ; - - return 0 ; -} /* nms_adpcm_init */ - -static int -nms_adpcm_close (SF_PRIVATE *psf) -{ NMS_ADPCM_PRIVATE *pnms ; - - pnms = (NMS_ADPCM_PRIVATE*) psf->codec_data ; - - /* - ** If a block has been partially assembled, write it out as the final - ** block. - */ - if (psf->file.mode == SFM_WRITE) - { if (pnms->sample_curr && pnms->sample_curr < NMS_SAMPLES_PER_BLOCK) - { memset (pnms->samples + pnms->sample_curr, 0, (NMS_SAMPLES_PER_BLOCK - pnms->sample_curr) * sizeof (short)) ; - psf_nms_adpcm_encode_block (psf, pnms) ; - } - - if (psf->write_header) - psf->write_header (psf, SF_FALSE) ; - } - - return 0 ; -} /* nms_adpcm_close */ - -static sf_count_t -nms_adpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ NMS_ADPCM_PRIVATE *pnms ; - - pnms = (NMS_ADPCM_PRIVATE *) psf->codec_data ; - - /* - ** NMS ADPCM is symmetric, so transitioning from reading and writing is - ** possible, but unimplemented, as it would require syncing partial blocks. - */ - if (mode != psf->file.mode) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - /* - ** NMS ADPCM cannot be seek'ed, as codec state depends on previous samples, - ** so only a seek to 0 is supported. - */ - if (offset != 0) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (psf_fseek (psf, psf->dataoffset, SEEK_SET) == PSF_SEEK_ERROR) - return PSF_SEEK_ERROR ; - - nms_adpcm_codec_init (&pnms->state, pnms->type) ; - pnms->block_curr = 0 ; - pnms->sample_curr = 0 ; - return 0 ; -} /* nms_adpcm_seek */ - diff --git a/Engine/lib/libsndfile/src/ogg.c b/Engine/lib/libsndfile/src/ogg.c deleted file mode 100644 index 8cd4379dd..000000000 --- a/Engine/lib/libsndfile/src/ogg.c +++ /dev/null @@ -1,921 +0,0 @@ -/* -** Copyright (C) 2002-2019 Erik de Castro Lopo -** Copyright (C) 2007 John ffitch -** Copyright (C) 2018 Arthur Taylor -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** This file contains code based on OpusFile and Opus-Tools, both by -** Xiph.Org. COPYING from each is identical and is as follows: -** -** Copyright (c) 1994-2013 Xiph.Org Foundation and contributors -** -** 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 the Xiph.Org Foundation nor the names of its -** 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 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. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if HAVE_EXTERNAL_XIPH_LIBS - -#include - -#include "ogg.h" - -#define OGG_SYNC_READ_SIZE (2048) -#define OGG_PAGE_SIZE_MAX (65307) -#define OGG_CHUNK_SIZE (65536) -#define OGG_CHUNK_SIZE_MAX (1024*1024) - -/* - * The Ogg container may seem overly complicated, particularly when used for a - * on-disk audio file format. This is probably because Ogg is designed with - * streaming rather than storage as a priority, and can handle multiple codec - * payloads multiplexed together, then possibly chained on top of that. - * Ogg achieves its goals well, but it does lend to a bit of a learning curve, - * with many internal structures to push data around in compared to most sound - * file formats which only have a header and raw data. - * - * See - * - [https://xiph.org/ogg/doc/oggstream.html] - * - [https://xiph.org/ogg/doc/framing.html] - * - * libogg Memory Management - * =========================================================================== - * - * libOgg's memory management is documented in code, not in headers or external - * documentation. What follows is not an attempt to completely document it, but - * an explanation of the basics. - * - * libOgg has two data structures which allocate and manage data buffers: The - * ogg_sync_state structure and the ogg_stream_state structure. The remaining - * structures of ogg_page and ogg_packet are views into the buffers managed by - * the previous structures. - * - * ogg_sync_state is used for reading purposes. It takes a physical bitstream - * and searches for, validates, and returns complete Ogg Pages. The - * ogg_sync_state buffers the returned page data, holding at most one - * complete page at a time. A returned Ogg page remains valid until any - * operation other than ogg_sync_check() is called. - * - * ogg_stream_state is used for both reading and writing. For reading, the - * contents of an ogg_page is copied into the stream state. This data is - * buffered to be split or joined as necessary into complete ogg_packets. If, - * after copying an ogg_page into an ogg_stream_state, packets are available to - * be read, then all of those packets remain in memory and valid until either - * the ogg_stream_state is reset, destroyed, or a new ogg_page is read into it. - * As the maximum number of packets an Ogg Page may contain is 255, at most 255 - * packets may be available from an ogg_stream_state at one time. - * - * For writing, the life cycle of a buffer pointed to by a ogg_packet is the - * responsibility of the caller. Packets written into an ogg_stream_state are - * buffered until a complete page is ready for writing. Pages for writing out - * remain in the ogg_stream_state's buffer and valid until either the - * ogg_stream_state is reset, cleared, destroyed. Writing another packet into - * the ogg_stream_state might also invalidate such pages, but writing in - * packets when a page is ready to be written out is a caller bug anyways. - */ - -/*----------------------------------------------------------------------------------------------- -** Private function prototypes. -*/ - -static int ogg_close (SF_PRIVATE *psf) ; -static int ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE * odata) ; -static int ogg_page_classify (SF_PRIVATE * psf, const ogg_page * og) ; -static uint64_t ogg_page_search_do_rescale (uint64_t x, uint64_t from, uint64_t to) ; -static void ogg_page_search_continued_data (OGG_PRIVATE *odata, ogg_page *page) ; - -/*----------------------------------------------------------------------------------------------- -** Exported functions. -*/ - -int -ogg_read_first_page (SF_PRIVATE *psf, OGG_PRIVATE *odata) -{ int ret ; - char *buffer ; - - /* - ** The ogg standard requires that the first pages of a physical ogg - ** bitstream be only the first pages of each logical bitstream. These - ** pages MUST have the Beginning-Of-Stream bit set, and must contain - ** only the stream's relevant header. Currently we only load the first - ** page and check that it contains a codec we support as supporting - ** multiplexed streams (video+audio(en)+audio(fs)+subtitles, etc) is - ** beyond the scope of this library. - */ - - ret = ogg_sync_fseek (psf, psf->header.indx, SEEK_SET) ; - if (ret < 0) - return SFE_NOT_SEEKABLE ; - - buffer = ogg_sync_buffer (&odata->osync, psf->header.indx) ; - if (buffer == NULL) - return SFE_MALLOC_FAILED ; - memcpy (buffer, psf->header.ptr, psf->header.indx) ; - ogg_sync_wrote (&odata->osync, psf->header.indx) ; - - ret = ogg_sync_next_page (psf, &odata->opage, SF_MAX ((sf_count_t) 0, 4096 - psf->header.indx), NULL) ; - - /* Have we simply run out of data? If so, we're done. */ - if (ret == 0) - return 0 ; - if (ret < 0) - return psf->error ; - - if (!ogg_page_bos (&odata->opage)) - { /* - ** Error case. Either must not be an Ogg bitstream, or is in the - ** middle of a bitstream (live capture), or in the middle of a - ** bitstream and no complete page was in the buffer. - */ - psf_log_printf (psf, "Input does not appear to be the start of an Ogg bitstream.\n") ; - return SFE_MALFORMED_FILE ; - } ; - - /* - ** Get the serial number and set up the rest of decode. - ** Serialno first ; use it to set up a logical stream. - */ - ogg_stream_reset_serialno (&odata->ostream, ogg_page_serialno (&odata->opage)) ; - - if (ogg_stream_pagein (&odata->ostream, &odata->opage) < 0) - { /* Error ; stream version mismatch perhaps. */ - psf_log_printf (psf, "Error reading first page of Ogg bitstream data\n") ; - return SFE_MALFORMED_FILE ; - } ; - - if (ogg_stream_packetout (&odata->ostream, &odata->opacket) != 1) - { /* No page? */ - psf_log_printf (psf, "Error reading initial header page packet.\n") ; - return SFE_MALFORMED_FILE ; - } ; - - return 0 ; -} /* ogg_read_first_page */ - -int -ogg_write_page (SF_PRIVATE *psf, ogg_page *page) -{ int bytes ; - - bytes = psf_fwrite (page->header, 1, page->header_len, psf) ; - bytes += psf_fwrite (page->body, 1, page->body_len, psf) ; - - return bytes == page->header_len + page->body_len ; -} /* ogg_write_page */ - -sf_count_t -ogg_sync_ftell (SF_PRIVATE *psf) -{ OGG_PRIVATE* odata = (OGG_PRIVATE *) psf->container_data ; - sf_count_t position ; - - position = psf_ftell (psf) ; - if (position >= 0) - { /* success */ - if (position < odata->osync.fill) - { /* Really, this should be an assert. */ - psf->error = SFE_INTERNAL ; - return -1 ; - } - position += (sf_count_t) (odata->osync.returned - odata->osync.fill) ; - } - - return position ; -} /* ogg_sync_ftell */ - -sf_count_t -ogg_sync_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) -{ OGG_PRIVATE* odata = (OGG_PRIVATE *) psf->container_data ; - sf_count_t ret ; - - ret = psf_fseek (psf, offset, whence) ; - if (ret >= 0) - { /* success */ - odata->eos = 0 ; - ogg_sync_reset (&odata->osync) ; - } - - return ret ; -} /* ogg_sync_fseek */ - -int -ogg_sync_next_page (SF_PRIVATE * psf, ogg_page *og, sf_count_t readmax, sf_count_t *offset) -{ OGG_PRIVATE* odata = (OGG_PRIVATE *) psf->container_data ; - sf_count_t position, nb_read, read_ret ; - unsigned char *buffer ; - int synced ; - int report_hole = 0 ; - - for (position = 0 ; readmax <= 0 || readmax > position ; ) - { synced = ogg_sync_pageseek (&odata->osync, og) ; - if (synced < 0) - { /* - ** Skipped -synced bytes before finding the start of a page. - ** If seeking, we have just landed in the middle of a page. - ** Otherwise, warn about junk in the bitstream. - ** Page might not yet be ready, hence the continue. - */ - if (!offset) - report_hole = 1 ; - position -= synced ; - continue ; - } ; - - if (report_hole) - { psf_log_printf (psf, "Ogg : Skipped %d bytes looking for the next page. Corrupted bitstream?!\n", position) ; - report_hole = 0 ; - } ; - - if (synced > 0) - { /* Have a page */ - if (offset) - *offset += position ; - return og->header_len + og->body_len ; - } ; - - /* - ** Else readmax == 0, Out of data. Try to read more in without - ** invalidating our boundary (readmax) constraint. - */ - if (readmax == 0) - return 0 ; - if (readmax > 0) - nb_read = SF_MIN ((sf_count_t) OGG_SYNC_READ_SIZE, readmax - position) ; - else - nb_read = OGG_SYNC_READ_SIZE ; - buffer = (unsigned char *) ogg_sync_buffer (&odata->osync, nb_read) ; - if (buffer == NULL) - { psf->error = SFE_MALLOC_FAILED ; - return -1 ; - } - read_ret = psf_fread (buffer, 1, nb_read, psf) ; - if (read_ret == 0) - return psf->error ? -1 : 0 ; - ogg_sync_wrote (&odata->osync, read_ret) ; - } ; - return 0 ; -} /* ogg_sync_next_page */ - -int -ogg_stream_next_page (SF_PRIVATE *psf, OGG_PRIVATE *odata) -{ int nn ; - - if (odata->eos) - return 0 ; - - for ( ; ; ) - { nn = ogg_sync_next_page (psf, &odata->opage, -1, NULL) ; - if (nn == 0) - { psf_log_printf (psf, "Ogg : File ended unexpectedly without an End-Of-Stream flag set.\n") ; - odata->eos = 1 ; - } - if (nn <= 0) - return nn ; - - if (ogg_page_serialno (&odata->opage) == odata->ostream.serialno) - break ; - } ; - - if (ogg_page_eos (&odata->opage)) - odata->eos = 1 ; - - if (ogg_stream_pagein (&odata->ostream, &odata->opage) < 0) - { psf->error = SFE_INTERNAL ; - return -1 ; - } - - return 1 ; -} /* ogg_stream_next_page */ - -int -ogg_stream_unpack_page (SF_PRIVATE *psf, OGG_PRIVATE *odata) -{ int nn ; - int i ; - int found_hole = 0 ; - ogg_packet *ppkt = odata->pkt ; - - odata->pkt_indx = 0 ; - nn = ogg_stream_packetout (&odata->ostream, ppkt) ; - if (nn == 0) - { /* - ** Steam is out of packets. Read in more pages until there is one, or - ** the stream ends, or an error occurs. - */ - for ( ; nn == 0 ; nn = ogg_stream_packetout (&odata->ostream, ppkt)) - { nn = ogg_stream_next_page (psf, odata) ; - if (nn <= 0) - { odata->pkt_len = 0 ; - return nn ; - } - } - /* - ** In the case of the for loop exiting because - ** ogg_stream_packetout() == -1, fall-through. - */ - } - - if (nn == -1) - { /* - ** libOgg found a hole. That is, the next packet found was out of - ** sequence. As such, "flush" the hole marker by removing the invalid - ** packet, as the valid packets are queued behind it. - */ - psf_log_printf (psf, "Ogg : Warning, libogg reports a hole at %d bytes.\n", ogg_sync_ftell (psf)) ; - nn = ogg_stream_packetout (&odata->ostream, ppkt) ; - found_hole = 1 ; - } - - /* - ** Unpack all the packets on the page. It is undocumented (like much of - ** libOgg behavior) but all packets from a page read into the stream are - ** guarenteed to remain valid in memory until a new page is read into the - ** stream. - */ - for (i = 1 ; ; i++) - { /* Not an off-by-one, there are 255 not 256 packets max. */ - if (i == 255) - { if (ogg_stream_packetpeek (&odata->ostream, NULL) == 1) - { psf->error = SFE_INTERNAL ; - return -1 ; - } - break ; - } - if (ogg_stream_packetout (&odata->ostream, ++ ppkt) != 1) - break ; - } - odata->pkt_len = i ; - - /* 1 = ok, 2 = ok, and found a hole. */ - return 1 + found_hole ; -} /* ogg_stream_unpack_page */ - -sf_count_t -ogg_sync_last_page_before (SF_PRIVATE *psf, OGG_PRIVATE *odata, uint64_t *gp_out, sf_count_t offset, int32_t serialno) -{ sf_count_t begin, end, original_end, chunk_size, ret ; - sf_count_t position = 0 ; - uint64_t gp = -1 ; - int left_link ; - - /* Based on code from Xiph.org's Opusfile */ - - original_end = end = begin = offset ; - offset = -1 ; - chunk_size = OGG_CHUNK_SIZE ; - do - { begin = SF_MAX (begin - chunk_size, (sf_count_t) 0) ; - position = ogg_sync_fseek (psf, begin, SEEK_SET) ; - if (position < 0) - return position ; - left_link = 0 ; - while (position < end) - { ret = ogg_sync_next_page (psf, &odata->opage, end - position, &position) ; - if (ret < 0) - return -1 ; - else if (ret == 0) - { // Hit EOF before EOS - break ; - } - if (ogg_page_serialno (&odata->opage) == serialno) - { uint64_t page_gp = ogg_page_granulepos (&odata->opage) ; - if (page_gp != (uint64_t) -1) - { offset = position ; - gp = page_gp ; - } - } - else - left_link = 1 ; - position += ret ; - } - - if ((left_link || !begin) && offset < 0) - { psf->error = SFE_MALFORMED_FILE ; - return -1 ; - } - - chunk_size = SF_MIN (2 * chunk_size, (sf_count_t) OGG_CHUNK_SIZE_MAX) ; - end = SF_MIN (begin + OGG_PAGE_SIZE_MAX - 1, original_end) ; - } - while (offset < 0) ; - - *gp_out = gp ; - return offset ; -} /* ogg_sync_last_page_before */ - -int -ogg_stream_seek_page_search (SF_PRIVATE *psf, OGG_PRIVATE *odata, - uint64_t target_gp, uint64_t pcm_start, uint64_t pcm_end, uint64_t *best_gp, - sf_count_t begin, sf_count_t end, uint64_t gp_rate) -{ ogg_page page ; - uint64_t gp ; - sf_count_t d0, d1, d2 ; - sf_count_t best ; - sf_count_t best_start ; - sf_count_t boundary ; - sf_count_t next_boundary ; - sf_count_t page_offset = -1 ; - sf_count_t seek_pos = -1 ; - sf_count_t bisect ; - sf_count_t chunk_size ; - int buffering = SF_FALSE ; - int force_bisect = SF_FALSE ; - int ret ; - int has_packets ; - - *best_gp = pcm_start ; - best = best_start = begin ; - boundary = end ; - - ogg_stream_reset_serialno (&odata->ostream, odata->ostream.serialno) ; - - /* - ** This code is based on op_pcm_seek_page() from Opusfile, which is in turn - ** based on "new search algorithm by Nicholas Vinen" from libvorbisfile. - */ - - d2 = d1 = d0 = end - begin ; - while (begin < end) - { /* - ** Figure out if and where to try and seek in the file. - */ - if (end - begin < OGG_CHUNK_SIZE) - bisect = begin ; - else - { /* Update the interval size history */ - d0 = d1 >> 1 ; - d1 = d2 >> 1 ; - d2 = (end - begin) >> 1 ; - if (force_bisect == SF_TRUE) - bisect = begin + ((end - begin) >> 1) ; - else - { /* Take a decent guess. */ - bisect = begin + ogg_page_search_do_rescale (target_gp - pcm_start, pcm_end - pcm_start, end - begin) ; - } - if (bisect - OGG_CHUNK_SIZE < begin) - bisect = begin ; - else - bisect -= OGG_CHUNK_SIZE ; - force_bisect = SF_FALSE ; - } - - /* - ** Avoid an actual fseek if we can (common for final iterations.) - */ - if (seek_pos != bisect) - { if (buffering == SF_TRUE) - ogg_stream_reset (&odata->ostream) ; - buffering = SF_FALSE ; - page_offset = -1 ; - seek_pos = ogg_sync_fseek (psf, bisect, SEEK_SET) ; - if (seek_pos < 0) - return seek_pos ; - } - - chunk_size = OGG_CHUNK_SIZE ; - next_boundary = boundary ; - - /* - ** Scan forward, figure out where we landed. - ** The ideal case is we see a page that ends before our target followed - ** by a page that ends after our target. - ** If we are too far before or after, breaking out will bisect what we - ** have found so far. - */ - while (begin < end) - { ret = ogg_sync_next_page (psf, &page, boundary - seek_pos, &seek_pos) ; - if (ret <= 0) - return ret ; - page_offset = seek_pos ; - if (ret == 0) - { /* - ** There are no more pages in this interval from our stream - ** with a granulepos less than our target. - */ - if (bisect <= begin + 1) - { /* Scanned the whole interval, so we are done. */ - end = begin ; - } - else - { /* - ** Otherwise, back up one chunk. First discard any data - ** from a continued packet. - */ - if (buffering) - ogg_stream_reset (&odata->ostream) ; - buffering = SF_FALSE ; - bisect = SF_MAX (bisect - chunk_size, begin) ; - seek_pos = ogg_sync_fseek (psf, bisect, SEEK_SET) ; - if (seek_pos < 0) - return seek_pos ; - /* Bump up the chunk size. */ - chunk_size = SF_MIN (2 * chunk_size, (sf_count_t) OGG_CHUNK_SIZE_MAX) ; - /* - ** If we did find a page from another stream or without a - ** timestamp, don't read past it. - */ - boundary = next_boundary ; - } - continue ; - } - - /* Found a page. Advance seek_pos past it */ - seek_pos += page.header_len + page.body_len ; - /* - ** Save the offset of the first page we found after the seek, - ** regardless of the stream it came from or whether or not it has a - ** timestamp. - */ - next_boundary = SF_MIN (page_offset, next_boundary) ; - - /* If not from our stream, continue. */ - if (odata->ostream.serialno != ogg_page_serialno (&page)) - continue ; - - /* - ** The Ogg spec says that a page with a granule pos of -1 must not - ** contain and packets which complete, but the lack of biconditional - ** wording means that /technically/ a packet which does not complete - ** any packets can have a granule pos other than -1. To make matters - ** worse, older versions of libogg did just that. - */ - has_packets = ogg_page_packets (&page) > 0 ; - gp = has_packets ? ogg_page_granulepos (&page) : -1 ; - if (gp == (uint64_t) -1) - { if (buffering == SF_TRUE) - { if (!has_packets) - ogg_stream_pagein (&odata->ostream, &page) ; - else - { /* - ** If packets did end on this page, but we still didn't - ** have a valid granule position (in violation of the - ** spec!), stop buffering continued packet data. - ** Otherwise we might continue past the packet we - ** actually wanted. - */ - ogg_stream_reset (&odata->ostream) ; - buffering = SF_FALSE ; - } - } - continue ; - } - - if (gp < target_gp) - { /* - ** We found a page that ends before our target. Advance to - ** the raw offset of the next page. - */ - begin = seek_pos ; - if (pcm_start > gp || pcm_end < gp) - break ; - /* Save the byte offset of after this page. */ - best = best_start = begin ; - if (buffering) - ogg_stream_reset (&odata->ostream) ; - /* Check to see if the last packet continues. */ - if (ogg_page_continues (&page)) - { ogg_page_search_continued_data (odata, &page) ; - /* - ** If we have a continued packet, remember the offset of - ** this page's start, so that if we do wind up having to - ** seek back here later, we can prime the stream with the - ** continued packet data. With no continued packet, we - ** remember the end of the page. - */ - best_start = page_offset ; - /* - ** Then force buffering on, so that if a packet starts (but - ** does not end) on the next page, we still avoid the extra - ** seek back. - */ - buffering = SF_TRUE ; - } ; - *best_gp = pcm_start = gp ; - if (target_gp - gp > gp_rate) - { /* Out by over a second. Try another bisection. */ - break ; - } - /* Otherwise, keep scanning forward (do NOT use begin+1). */ - bisect = begin ; - } - else - { /* - ** Found a page that ends after our target. If we had just - ** scanned the whole interval before we found it, we're good. - */ - if (bisect <= begin + 1) - end = begin ; - else - { end = bisect ; - /* - ** In later iterations, don't read past the first page we - ** found. - */ - boundary = next_boundary ; - /* - ** If we're not making much progress shrinking the interval - ** size, start forcing straight bisection to limit the - ** worst case. - */ - force_bisect = end - begin > d0 * 2 ? SF_TRUE : SF_FALSE ; - /* - ** Don't let pcm_end get out of range! That could happen - ** with an invalid timestamp. - */ - if (pcm_end > gp && pcm_start <= gp) - pcm_end = gp ; - } - break ; - } - } - } - - /* - ** If we are buffering, the page we want is currently buffered in the - ** Ogg stream structure, or in the Ogg page which has not been submitted. - ** If not, we need to seek back and load it again. - */ - if (buffering == SF_FALSE) - { if (best_start != page_offset) - { page_offset = -1 ; - seek_pos = ogg_sync_fseek (psf, best_start, SEEK_SET) ; - if (seek_pos < 0) - return seek_pos ; - } - if (best_start < best) - { if (page_offset < 0) - { ret = ogg_sync_next_page (psf, &page, -1, &seek_pos) ; - if (seek_pos != best_start) - return -1 ; - } - ogg_page_search_continued_data (odata, &page) ; - page_offset = -1 ; - } - } ; - - if (page_offset >= 0) - ogg_stream_pagein (&odata->ostream, &page) ; - - return 0 ; -} /* ogg_stream_seek_page_search */ - -int -ogg_open (SF_PRIVATE *psf) -{ OGG_PRIVATE* odata = calloc (1, sizeof (OGG_PRIVATE)) ; - sf_count_t pos = psf_ftell (psf) ; - int error = 0 ; - - psf->container_data = odata ; - psf->container_close = ogg_close ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode == SFM_READ) - if ((error = ogg_stream_classify (psf, odata)) != 0) - return error ; - - if (SF_ENDIAN (psf->sf.format) != 0) - return SFE_BAD_ENDIAN ; - - switch (psf->sf.format) - { case SF_FORMAT_OGG | SF_FORMAT_VORBIS : - return ogg_vorbis_open (psf) ; - - case SF_FORMAT_OGGFLAC : - /* Reset everything to an initial state. */ - ogg_sync_clear (&odata->osync) ; - ogg_stream_clear (&odata->ostream) ; - psf_fseek (psf, pos, SEEK_SET) ; - free (psf->container_data) ; - psf->container_data = NULL ; - psf->container_close = NULL ; - return flac_open (psf) ; - - case SF_FORMAT_OGG | SF_FORMAT_OPUS : - return ogg_opus_open (psf) ; - -#if ENABLE_EXPERIMENTAL_CODE - case SF_FORMAT_OGG | SF_FORMAT_SPEEX : - return ogg_speex_open (psf) ; - - case SF_FORMAT_OGG | SF_FORMAT_PCM_16 : - case SF_FORMAT_OGG | SF_FORMAT_PCM_24 : - return ogg_pcm_open (psf) ; -#endif - - default : - break ; - } ; - - psf_log_printf (psf, "%s : bad psf->sf.format 0x%x.\n", __func__, psf->sf.format) ; - return SFE_INTERNAL ; -} /* ogg_open */ - -/*============================================================================== -** Private functions. -*/ - -static int -ogg_close (SF_PRIVATE *psf) -{ OGG_PRIVATE* odata = psf->container_data ; - - ogg_sync_clear (&odata->osync) ; - ogg_stream_clear (&odata->ostream) ; - - return 0 ; -} /* ogg_close */ - -static int -ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE* odata) -{ int error ; - - /* Call this here so it only gets called once, so no memory is leaked. */ - ogg_sync_init (&odata->osync) ; - ogg_stream_init (&odata->ostream, 0) ; - - /* Load the first page in the physical bitstream. */ - if ((error = ogg_read_first_page (psf, odata)) != 0) - return error ; - - odata->codec = ogg_page_classify (psf, &odata->opage) ; - - switch (odata->codec) - { case OGG_VORBIS : - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - return 0 ; - - case OGG_FLAC : - case OGG_FLAC0 : - psf->sf.format = SF_FORMAT_OGGFLAC ; - return 0 ; - - case OGG_SPEEX : - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_SPEEX ; - return 0 ; - - case OGG_OPUS : - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_OPUS ; - return 0 ; - - case OGG_PCM : - psf_log_printf (psf, "Detected Ogg/PCM data. This is not supported yet.\n") ; - return SFE_UNIMPLEMENTED ; - - default : - break ; - } ; - - psf_log_printf (psf, "This Ogg bitstream contains some uknown data type.\n") ; - return SFE_UNIMPLEMENTED ; -} /* ogg_stream_classify */ - -/*============================================================================== -*/ - -static struct -{ const char *str, *name ; - int len, codec ; -} codec_lookup [] = -{ { "Annodex", "Annodex", 8, OGG_ANNODEX }, - { "AnxData", "AnxData", 7, OGG_ANXDATA }, - { "\177FLAC", "Flac1", 5, OGG_FLAC }, - { "fLaC", "Flac0", 4, OGG_FLAC0 }, - { "PCM ", "PCM", 8, OGG_PCM }, - { "Speex", "Speex", 5, OGG_SPEEX }, - { "\001vorbis", "Vorbis", 7, OGG_VORBIS }, - { "OpusHead", "Opus", 8, OGG_OPUS }, -} ; - -static int -ogg_page_classify (SF_PRIVATE * psf, const ogg_page * og) -{ int k, len ; - - for (k = 0 ; k < ARRAY_LEN (codec_lookup) ; k++) - { if (codec_lookup [k].len > og->body_len) - continue ; - - if (memcmp (og->body, codec_lookup [k].str, codec_lookup [k].len) == 0) - { psf_log_printf (psf, "Ogg stream data : %s\n", codec_lookup [k].name) ; - psf_log_printf (psf, "Stream serialno : %u\n", (uint32_t) ogg_page_serialno (og)) ; - return codec_lookup [k].codec ; - } ; - } ; - - len = og->body_len < 8 ? og->body_len : 8 ; - - psf_log_printf (psf, "Ogg_stream data : '") ; - for (k = 0 ; k < len ; k++) - psf_log_printf (psf, "%c", isprint (og->body [k]) ? og->body [k] : '.') ; - psf_log_printf (psf, "' ") ; - for (k = 0 ; k < len ; k++) - psf_log_printf (psf, " %02x", og->body [k] & 0xff) ; - psf_log_printf (psf, "\n") ; - - return 0 ; -} /* ogg_page_classify */ - -/* -** Scale x from the range [0, from] to the range [0, to] -*/ -static uint64_t -ogg_page_search_do_rescale (uint64_t x, uint64_t from, uint64_t to) -{ uint64_t frac ; - uint64_t ret ; - int i ; - - /* I should have paid more attention in CSc 349A: Numerical Analysis */ - if (x >= from) - return to ; - if (x == 0) - return 0 ; - frac = 0 ; - for (i = 0 ; i < 63 ; i++) - { frac <<= 1 ; - if (x >= from >> 1) - { x -= from - x ; - frac |= 1 ; - } - else - x <<= 1 ; - } - ret = 0 ; - for (i = 0 ; i < 63 ; i++) - { if (frac & 1) - ret = (ret & to & 1) + (ret >> 1) + (to >> 1) ; - else - ret >>= 1 ; - frac >>= 1 ; - } - return ret ; -} /* ogg_page_search_do_rescale */ - -static void -ogg_page_search_continued_data (OGG_PRIVATE *odata, ogg_page *page) -{ ogg_stream_pagein (&odata->ostream, page) ; - while (ogg_stream_packetout (&odata->ostream, &odata->opacket)) ; -} /* ogg_page_search_continued_data */ - -#else /* HAVE_EXTERNAL_XIPH_LIBS */ - -int -ogg_open (SF_PRIVATE *psf) -{ - psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Vorbis support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* ogg_open */ - -#endif diff --git a/Engine/lib/libsndfile/src/ogg.h b/Engine/lib/libsndfile/src/ogg.h deleted file mode 100644 index 8b2927a90..000000000 --- a/Engine/lib/libsndfile/src/ogg.h +++ /dev/null @@ -1,169 +0,0 @@ -/* -** Copyright (C) 2008-2011 Erik de Castro Lopo -** Copyright (C) 2018 Arthur Taylor -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SF_SRC_OGG_H -#define SF_SRC_OGG_H - -enum -{ OGG_ANNODEX = 300, - OGG_ANXDATA, - OGG_FLAC, - OGG_FLAC0, - OGG_PCM, - OGG_SPEEX, - OGG_VORBIS, - OGG_OPUS, -} ; - -typedef struct -{ /* Sync and verify incoming physical bitstream */ - ogg_sync_state osync ; - /* Take physical pages, weld into a logical stream of packets */ - ogg_stream_state ostream ; - /* One Ogg bitstream page. Codec packets are inside */ - ogg_page opage ; - /* One raw packet of data for decode */ - ogg_packet opacket ; - - /* Unpacked packets. 255 is max there can ever be in one page. */ - ogg_packet pkt [255] ; - /* How many packets */ - int pkt_len ; - /* Current packet */ - int pkt_indx ; - - int eos ; - int codec ; -} OGG_PRIVATE ; - - -#define readint(buf, base) (((buf [base + 3] << 24) & 0xff000000) | \ - ((buf [base + 2] <<16) & 0xff0000) | \ - ((buf [base + 1] << 8) & 0xff00) | \ - (buf [base] & 0xff)) -/*----------------------------------------------------------------------------------------------- -** Inline functions. -*/ - -/* -** LibOgg documentation is noted as being bad by it's author. -** Add some useful utility inline functions for introspecting Ogg pages. -*/ - -/* ogg_page_segments returns how many segments are in this page. */ -static inline int -ogg_page_segments (ogg_page *pg) -{ return (int) (pg->header [26]) ; } - -/* ogg_page_continues returns true if this page ends in a continued packet. */ -static inline int -ogg_page_continues (ogg_page *pg) -{ return pg->header [27 + pg->header [26] - 1] == 255 ; -} - -/*----------------------------------------------------------------------------------------------- -** Exported functions. -*/ - -/* -** ogg_read_first_page loads the first Ogg page found in the file, and sets the -** OGG_PRIVATE serialno to match the logical stream of the page. Data is read -** without seeking backwards, loading any data present from psf->header into -** the ogg_sync state first, so that this function works with pipes. -*/ -int ogg_read_first_page (SF_PRIVATE *, OGG_PRIVATE *) ; - -/* -** Write the whole Ogg page out. Convenience function as the ogg_page struct -** splits header and body data into separate buffers. -*/ -int ogg_write_page (SF_PRIVATE *, ogg_page *) ; - -/* -** Wrapper around psf_ftell() that returns the current offset in the file after -** the most recent page that has been returned by ogg_sync_pageout(). -*/ -sf_count_t ogg_sync_ftell (SF_PRIVATE *) ; - -/* -** Wrapper around psf_fseek() that on success resets the ogg_sync_state struct -** so that it doesn't get corrupted. -*/ -sf_count_t ogg_sync_fseek (SF_PRIVATE *, sf_count_t offset, int whence) ; - -/* -** Get the next page from the physical bitstream, reading in data as necessary. -** Pays no attention to Ogg BOS/EOS markers or stream serial numbers. -** The page is buffered in the ogg_sync_state struct, (replacing any other -** buffered there) and also returned in *og. readmax sets a boundary for how -** many bytes more may be read from the file, use already buffered only, or -** unlimited reading in the case of a positive, zero or negative argument -** respectively. If a pointer to a sf_count_t is passed in offset, then it will -** be incremented by how many bytes were skipped to find the next page header. -** (Useful for seeking, normally zero.) Returns the page size in bytes on -** success, 0 on out-of-data (be it end of file or readmax reached) and -1 on -** error with psf->error set appropriately. -*/ -int ogg_sync_next_page (SF_PRIVATE * psf, ogg_page *og, sf_count_t readmax, sf_count_t *offset) ; - -/* -** Load the last page of a stream before the provided file offset. Searches the -** physical bitstream, and selects a page of the passed serialno. The page -** found is loaded in the sync buffer and exposed in odata->opage, and not -** loaded into the ogg_stream_state. If found, the granulepos is returned in -** *gp_out. Returns the file offset *before* the last page on success, or -1 on -** error, setting psf->error as appropriate. -*/ -sf_count_t ogg_sync_last_page_before (SF_PRIVATE *psf, OGG_PRIVATE *odata, uint64_t *gp_out, sf_count_t offset, int32_t serialno) ; - -/* -** Load the next page from the virtual bitstream, reading data as necessary. -** Reads in pages from the physical bitstream, skipping pages until one of the -** virtual bitstream of interest is found, and then feeds it into the -** ogg_stream_state of odata->ostream, where it is buffered. Heeds EOS markers. -** Returns 1 on success, 0 on end of stream, and -1 on fatal error. -*/ -int ogg_stream_next_page (SF_PRIVATE * psf, OGG_PRIVATE *odata) ; - -/* -** Loads the next page using ogg_stream_next_page() and unpacks all packets -** into the array odata->pkt, updating odata->pkt_len and setting -** odata->pkt_indx to 0. Returns 1 if okay, 2 if okay but a hole was found -** in the bitstream, 0 if on end of stream, and -1 on fatal error. -*/ -int ogg_stream_unpack_page (SF_PRIVATE *psf, OGG_PRIVATE *odata) ; - -/* -** Seek within the Ogg virtual bitstream for a page containing target_gp. -** Preforms a bisection search. If not found exactly, the best result is -** returned in *best_gp. Found page is loaded into the virtual bitstream, -** ready for unpacking. Arguments pcm_start and pcm_end are the highest and -** lowest granule positions of the file. begin and end are the file offset -** range to search. gp_rate is an information hint so granule positions can -** be correlated to playback time, so the search can figure out how close it -** is, should be granule positions per second. -*/ -int ogg_stream_seek_page_search (SF_PRIVATE *psf, OGG_PRIVATE *odata, - uint64_t target_gp, - uint64_t pcm_start, uint64_t pcm_end, - uint64_t *best_gp, - sf_count_t begin, sf_count_t end, - uint64_t gp_rate) ; - -#endif /* SF_SRC_OGG_H */ diff --git a/Engine/lib/libsndfile/src/ogg_opus.c b/Engine/lib/libsndfile/src/ogg_opus.c deleted file mode 100644 index f5857df97..000000000 --- a/Engine/lib/libsndfile/src/ogg_opus.c +++ /dev/null @@ -1,1823 +0,0 @@ -/* -** Copyright (C) 2013-2020 Erik de Castro Lopo -** Copyright (C) 2018 Arthur Taylor -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** This file contains code based on OpusFile and Opus-Tools, both by -** Xiph.Org. COPYING from each is identical and is as follows: -** -** Copyright (c) 1994-2013 Xiph.Org Foundation and contributors -** -** 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 the Xiph.Org Foundation nor the names of its -** 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 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. -*/ - -/* -** TODO: -** - Channel mapping modification / reporting -** - connect psf->channel_map and Opus channel mapping somehow? -** - Gain parameters and their mappings -*/ - -/* -** Opus Sample, Frame, and Samples/Channel Terminology -** -** libsndfile refers to one PCM value as a 'sample,' and a group of samples of -** the same sample time, one for each channel, as a 'frame.' This differs from -** Opus, which has no corresponding name for sample, and refers to a group of -** PCM values, one per channel (aka libsndfile frames) as 'samples.' -** Further, Opus has an object called a 'frame' that is made up of multiple -** Opus-samples. -** All this means that one has to be careful with what is meant by each term. -** In an attempt to avoid ambiguity, this file adopts the following terms: -** - Samples shall refer to discrete PCM values, regardless of any channel -** considerations. This is the same as what libsndfile calls samples. -** - Samples/channel shall refer to groups of samples, one for each channel. -** This is what Opus calles samples, and what libsndfile calles frames. It -** has the advantage that its name is also the formula to calculate it. -** -** -** Opus vs OggOpus -** -** In this file a distinction is made between Opus and OggOpus. Opus refers to -** the codec alone, support for which is by libopus. OggOpus refers to an Opus -** payload encapsulated in an Ogg stream. This is also know as an "Opus file." -** The OggOpus spec includes information on header and granule position -** interpretation, which is outside of the scope of the Opus spec. As such, an -** attempt here is made to refer to either Opus or OggOpus depending on which -** spec is being referenced. See https://wiki.xiph.org/OggOpus -** -** -** Opus Sample Rates -** -** Opus only supports a fixed number of sample rates: 48kHz, 24kHz, 16kHz, -** 12kHz, 8kHz. Audio may be decoded or encoded at any of these rates, -** independent of the rate it was encoded at or to be decoded at respectively. -** Other sample rates must be converted to one of these rates. -** -** As 44.1kHz (CD sample rate) and 22.5kHz are popular sample rates, and to -** support any other sample rate there may be, the Opus header includes a field -** to save the input (original) sample rate before converting it to a supported -** one. Implementations are recommended by the Opus spec to do a sample rate -** conversion at encode, but decode at 48kHz if outputting to hardware, or do -** the reverse sample rate conversion if outputting to file. -** -** Heretofore libsndfile does not contain a sample rate converter, so doing the -** sample rate conversion is not supported. Instead audio must be provided by -** the user at a supported rate. However, the input sample rate field can be -** set and retrieved by the user using sf_command(). At decode we choose to -** decode at the lowest valid rate that is greater than or equal to the input -** sample rate. -** -** -** OggOpus Granule Positions -** -** Ogg streams include a strictly increasing granule position value. The -** interpretation of this value is dependent on the payload type. For Opus -** streams the granule position is the count of samples in the stream when -** encoding/decoding at 48kHz. Note that the actual position of the output -** sample relative to the granule position is offset by the preskip amount. -** That is, if a packet ends with a granule position of x, the last sample -** output when decoding is actually sample (x - preskip). -** -** Further, to allow for clipping off of the front of a stream without -** rewriting all following granule positions, an Opus stream granule position -** may be offset by a constant amount. This amount is evident by comparing the -** granule position of the first page of an Opus stream on which an audio -** packet completes is greater than the sum of the samples of all audio -** packets completed on the page. Only the first such page is allows to have an -** 'excessive' granule position, and only if it is not also the last page of -** the stream (e_o_s bit is not set.) -** -** The granule position is an unsigned 64-bit integer, with the special value -** of UINT64_MAX/-1 being treated as invalid. However, as not all platforms -** support unsigned 64-bit integers, libOgg uses signed 64-bit integers for the -** granule position. -** -** Remembering that signed integer overflow/underflow is explicitly undefined -** in C, and as we already assume support for unsigned 64-bit integers, the -** easiest way to deal with this problem is to modify granule positions as -** unsigned integers. -*/ - - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if HAVE_EXTERNAL_XIPH_LIBS - -#include -#include -#include - -#include "ogg.h" -#include "ogg_vcomment.h" - -#define OGG_OPUS_COMMENT_PAD (512) /* Same as oggenc default */ - -/* -** When encoding, we can choose the size of the Opus frames. -** Valid values are 2.5, 5, 10, 20, 40, and 60 milliseconds. -** -** Frames smaller than 10ms can't use CELT (MDCT) mode. -** Frames larger than 20ms "are only interesting at fairly low bitrates." -** -** We choose the suggested default of 20ms for high-fidelity audio, however, -** maybe this could be user-selected, or triggered by bitrate command. -** default for non-realtime of 20ms. While longer packets reduce the overhead -** data somewhat, it also decreases the quality. -*/ -#define OGG_OPUS_ENCODE_PACKET_LEN(samplerate) ((20 * (samplerate)) / 1000) - -/* -** The pre-roll is how long it takes for the decoder to converge. It converges -** pretty quickly, to within -40db within 80ms. However, this also depends on -** the signal. From experimentation, use the conservative pre-roll amount of -** 660ms after which the output is 32-bit-exact with high probability. -*/ -#define OGG_OPUS_PREROLL (660 * 48) /* 660 milliseconds (33 packets of 20ms) */ - -typedef struct -{ uint8_t version ; - - /* Number of channels, 1...255 */ - uint8_t channels ; - - /* Encoder latency, the amount to skip before valid data comes out. */ - uint16_t preskip ; - - /* The sample rate of a the encoded source, as it may have been converted. */ - int32_t input_samplerate ; - - /* 'baked-in' gain to apply, dB S7.8 format. Should be zero when possible. */ - int16_t gain ; - - /* Channel mapping type. See OggOpus spec */ - uint8_t channel_mapping ; - - /* The rest is only used if channel_mapping != 0 */ - /* How many streams are there? */ - uint8_t nb_streams ; - - /* How man of those streams are coupled? (aka stereo) */ - uint8_t nb_coupled ; - - /* Mapping of opus streams to output channels */ - uint8_t stream_map [255] ; -} OpusHeader ; - -typedef struct -{ uint32_t serialno ; - OpusHeader header ; - - /* Encode: Granule position after the previous packet. - * Decode: Granule position after the current packet */ - uint64_t pkt_pos ; - - /* Encode: Granule position at the end of the previous page. - * Decode: Granule position at the end of the current page. */ - uint64_t pg_pos ; - - /* integer coefficient of (current sample rate) / 48000Hz */ - int sr_factor ; - - /* Current position in buffer expressed as samples/channel */ - int loc ; - - /* Current data fill (decode) or target (encode) of buffer expressed in samples/channel */ - int len ; - - /* Size of the buffer storage, in sizeof (float) * channels */ - int buffersize ; - - /* Samples, either decoded from a packet, or assembling for encode. */ - float *buffer ; - - union { - /* decode only members */ - struct { - OpusMSDecoder *state ; - uint64_t gp_start ; - uint64_t gp_end ; - sf_count_t last_offset ; - } decode ; - - /* encode only members */ - struct { - OpusMSEncoder *state ; - - /* How many Ogg page segments are in Ogg page currently being assembled. */ - int last_segments ; - - int bitrate ; - unsigned long latency ; - - /* Least significant bit of the source (aka bitwidth) */ - int lsb ; - int lsb_last ; - } encode ; - } u ; -} OPUS_PRIVATE ; - -/*----------------------------------------------------------------------------------------------- -** Private function prototypes. -*/ - -static int ogg_opus_close (SF_PRIVATE *psf) ; -static void opus_print_header (SF_PRIVATE *psf, OpusHeader *h) ; -static int opus_read_header_packet (SF_PRIVATE *psf, OpusHeader *h, ogg_packet *opacket) ; -static int ogg_opus_read_header (SF_PRIVATE * psf) ; -static int ogg_opus_setup_decoder (SF_PRIVATE *psf, int input_samplerate) ; - -static int ogg_opus_setup_encoder (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) ; -static int ogg_opus_write_header (SF_PRIVATE * psf, int calc_length) ; -static void ogg_opus_flush (SF_PRIVATE *psf) ; -static int ogg_opus_unpack_next_page (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) ; -static int ogg_opus_calculate_page_duration (OGG_PRIVATE *odata) ; -static int ogg_opus_read_refill (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) ; -static int ogg_opus_write_out (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) ; - -static sf_count_t ogg_opus_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t ogg_opus_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t ogg_opus_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t ogg_opus_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t ogg_opus_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t ogg_opus_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t ogg_opus_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t ogg_opus_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static sf_count_t ogg_opus_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; -static sf_count_t ogg_opus_null_read (SF_PRIVATE *psf, sf_count_t offset) ; -static sf_count_t ogg_opus_page_seek_manual (SF_PRIVATE *psf, uint64_t target_gp) ; -static int ogg_opus_page_seek_search (SF_PRIVATE *psf, uint64_t target_gp) ; - -static int ogg_opus_analyze_file (SF_PRIVATE *psf) ; -static int ogg_opus_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; -static int ogg_opus_byterate (SF_PRIVATE *psf) ; - -/*----------------------------------------------------------------------------------------------- -*/ - -static vorbiscomment_ident opustags_ident = { "OpusTags", 8 } ; - -/*----------------------------------------------------------------------------------------------- -** Exported functions. -*/ - -int -ogg_opus_open (SF_PRIVATE *psf) -{ OGG_PRIVATE* odata = psf->container_data ; - OPUS_PRIVATE* oopus = calloc (1, sizeof (OPUS_PRIVATE)) ; - int error = 0 ; - - if (odata == NULL) - { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ; - free (oopus) ; - return SFE_INTERNAL ; - } ; - - psf->codec_data = oopus ; - if (oopus == NULL) - return SFE_MALLOC_FAILED ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - psf_log_printf (psf, "Opus library version: %s\n", opus_get_version_string ()) ; - - psf->codec_close = ogg_opus_close ; - if (psf->file.mode == SFM_READ) - { if ((error = ogg_opus_read_header (psf))) - return error ; - if ((error = ogg_opus_analyze_file (psf))) - return error ; - - psf->read_short = ogg_opus_read_s ; - psf->read_int = ogg_opus_read_i ; - psf->read_float = ogg_opus_read_f ; - psf->read_double = ogg_opus_read_d ; - } ; - - if (psf->file.mode == SFM_WRITE) - { if ((error = ogg_opus_setup_encoder (psf, odata, oopus))) - return error ; - - psf->write_header = ogg_opus_write_header ; - psf->write_short = ogg_opus_write_s ; - psf->write_int = ogg_opus_write_i ; - psf->write_float = ogg_opus_write_f ; - psf->write_double = ogg_opus_write_d ; - - psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */ - psf->strings.flags = SF_STR_ALLOW_START ; - psf->datalength = 0 ; - psf->dataoffset = 0 ; /* will be updated */ - } ; - - psf->seek = ogg_opus_seek ; - psf->command = ogg_opus_command ; - psf->byterate = ogg_opus_byterate ; - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_OPUS ; - - return error ; -} /* ogg_opus_open */ - -/*============================================================================== -** Private functions. -*/ - -static int -ogg_opus_close (SF_PRIVATE *psf) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - - if (!oopus) - return 0 ; - - if (psf->file.mode == SFM_WRITE) - { if (psf->have_written) - ogg_opus_flush (psf) ; - else { - /* Write a header... it is expected. */ - ogg_opus_write_header (psf, 0) ; - } ; - ogg_packet_clear (&odata->opacket) ; - if (oopus->u.encode.state) - { opus_multistream_encoder_destroy (oopus->u.encode.state) ; - oopus->u.encode.state = NULL ; - } ; - } - else if (psf->file.mode == SFM_READ) - { if (oopus->u.decode.state) - { opus_multistream_decoder_destroy (oopus->u.decode.state) ; - oopus->u.decode.state = NULL ; - } ; - } ; - - psf->codec_data = NULL ; - if (oopus->buffer) - free (oopus->buffer) ; - free (oopus) ; - - return 0 ; -} /* ogg_opus_close */ - -static void -opus_print_header (SF_PRIVATE *psf, OpusHeader *h) -{ psf_log_printf (psf, "Opus Header Metadata\n") ; - psf_log_printf (psf, " OggOpus version : %d\n", (int) h->version) ; - psf_log_printf (psf, " Channels : %d\n", (int) h->channels) ; - psf_log_printf (psf, " Preskip : %d samples @48kHz\n", (int) h->preskip) ; - psf_log_printf (psf, " Input Samplerate : %d Hz\n", (int) h->input_samplerate) ; - psf_log_printf (psf, " Gain : %d.%d\n", (int) arith_shift_right (h->gain & 0xF0, 8), h->gain & 0x0F) ; - psf_log_printf (psf, " Channel Mapping : ") ; - switch (h->channel_mapping) - { case 0 : psf_log_printf (psf, "0 (mono or stereo)\n") ; break ; - case 1 : psf_log_printf (psf, "1 (surround, AC3 channel order)\n") ; break ; - case 255 : psf_log_printf (psf, "255 (no channel order)\n") ; break ; - default : psf_log_printf (psf, "%d (unknown or unsupported)\n", (int) h->channel_mapping) ; break ; - } ; - - if (h->channel_mapping > 0) - { int i ; - psf_log_printf (psf, " streams total : %d\n", (int) h->nb_streams) ; - psf_log_printf (psf, " streams coupled : %d\n", (int) h->nb_coupled) ; - psf_log_printf (psf, " stream mapping : [") ; - for (i = 0 ; i < h->channels - 1 ; i++) - psf_log_printf (psf, "%d,", (int) (h->stream_map [i])) ; - psf_log_printf (psf, "%d]\n", (int) (h->stream_map [i])) ; - } ; -} /* opus_print_header */ - -static int -opus_read_header_packet (SF_PRIVATE *psf, OpusHeader *h, ogg_packet *opacket) -{ int count, i ; - - /* - ** Opus headers are 19 bytes, in the case of type 0 channel mapping, - ** or 19 + 2 + (1 * channel count) bytes for other channel mappings, to a - ** maximum of 276 (255 channels). - */ - - if (opacket->bytes < 19 || opacket->bytes > 276) - return SFE_MALFORMED_FILE ; - - if (memcmp (opacket->packet, "OpusHead", 8) != 0) - return SFE_MALFORMED_FILE ; - - /* - ** Copy the header page into the binheader so we can use binheader - ** functions to safely unpack it. - */ - count = psf_binheader_writef (psf, "ob", BHWo (0), BHWv (opacket->packet), BHWz (opacket->bytes)) ; - psf->header.end = count ; - - count = psf_binheader_readf (psf, "ep1", 8, &h->version) ; - if (! (h->version == 1 || h->version == 0)) - { psf_log_printf (psf, "Opus : Unknown / unsupported embedding scheme version: %d.\n", (int) h->version) ; - return SFE_UNIMPLEMENTED ; - } ; - - count += psf_binheader_readf (psf, "e12421", &h->channels, &h->preskip, - &h->input_samplerate, &h->gain, &h->channel_mapping) ; - - if (h->channel_mapping == 0) - { if (h->channels > 2) - return SFE_MALFORMED_FILE ; - - /* - ** Setup the stream mapping, so we can use the multistream decoder, - ** rather than have to deal with two decoder pointer types - */ - h->nb_streams = 1 ; - h->nb_coupled = h->channels - 1 ; - h->stream_map [0] = 0 ; - h->stream_map [1] = 1 ; - } - else - { if (opacket->bytes < 19 + 2 + h->channels) - return SFE_MALFORMED_FILE ; - - if (h->channel_mapping == 1 && h->channels > 8) - return SFE_MALFORMED_FILE ; - - count += psf_binheader_readf (psf, "11", &h->nb_streams, &h->nb_coupled) ; - - if (h->nb_streams < 1 || - h->nb_coupled > h->nb_streams || - h->nb_coupled + h->nb_streams > 255) - return SFE_MALFORMED_FILE ; - - for (i = 0 ; i < h->channels ; i++) - { count += psf_binheader_readf (psf, "1", &(h->stream_map [i])) ; - if (h->stream_map [i] > h->nb_streams + h->nb_coupled && h->stream_map [i] != 255) - return SFE_MALFORMED_FILE ; - } ; - } ; - - if (count != opacket->bytes) - { /* OggOpus spec mandates that this is a hard error. */ - psf_log_printf (psf, "Opus : Error, extra data in Ogg Opus header.\n") ; - return SFE_MALFORMED_FILE ; - } ; - - opus_print_header (psf, h) ; - - return 0 ; -} /* ogg_opus_read_header_packet */ - -static int -ogg_opus_read_header (SF_PRIVATE *psf) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - int error ; - - /* - ** First page is already loaded by the ogg container code when it - ** classified the stream, no need to re-load it now. - */ - - if (ogg_page_packets (&odata->opage) != 1 || !ogg_page_bos (&odata->opage)) - return SFE_MALFORMED_FILE ; - - oopus->serialno = ogg_page_serialno (&odata->opage) ; - if ((error = opus_read_header_packet (psf, &oopus->header, &odata->opacket))) - return error ; - - /* - ** The comment header MUST be next. It is one packet, that packet MUST begin - ** on the second page of the stream, but it MAY span multiple pages. - */ - - while (ogg_stream_packetout (&odata->ostream, &odata->opacket) != 1) - { if (ogg_stream_next_page (psf, odata) != 1) - { /* out of data... technically that's malformed. */ - return psf->error ? psf->error : SFE_MALFORMED_FILE ; - } ; - } ; - - if ((error = vorbiscomment_read_tags (psf, &odata->opacket, &opustags_ident))) - return error ; - - return ogg_opus_setup_decoder (psf, oopus->header.input_samplerate) ; -} /* ogg_opus_read_header */ - -static int -ogg_opus_setup_decoder (SF_PRIVATE *psf, int input_samplerate) -{ OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - OpusMSDecoder *decoder ; - int sr_factor ; - int error ; - - /* - ** Decide what sample rate to decode at. We choose the lowest valid rate - ** that is greater or equal to the original rate. - ** - ** Opus documentation recommends always decoding at 48000Hz if the file is - ** being decoded for playback, since most hardware will resample it back to - ** 48000Hz anyways. We don't know if that's true, maybe the user is - ** decoding for editing or transcoding purposes. - */ - if (input_samplerate > 24000) - sr_factor = 1 ; - else if (input_samplerate > 16000) - sr_factor = 2 ; - else if (input_samplerate > 12000) - sr_factor = 3 ; - else if (input_samplerate > 8000) - sr_factor = 4 ; - else - sr_factor = 6 ; - - decoder = opus_multistream_decoder_create ( - 48000 / sr_factor, - oopus->header.channels, - oopus->header.nb_streams, - oopus->header.nb_coupled, - oopus->header.stream_map, - &error) ; - - if (error != OPUS_OK) - { psf_log_printf (psf, "Opus : Failed to create multistream decoder: %s\n", - opus_strerror (error)) ; - return SFE_INTERNAL ; - } - - /* - ** Replace the decoder, if one was already initialized (see - ** SFC_GET_ORIGINAL_SAMPLERATE) - */ - if (oopus->u.decode.state) - opus_multistream_decoder_destroy (oopus->u.decode.state) ; - oopus->u.decode.state = decoder ; - - oopus->sr_factor = sr_factor ; - psf->sf.samplerate = 48000 / sr_factor ; - psf->sf.channels = oopus->header.channels ; - oopus->loc = oopus->len = 0 ; - - /* - ** The Opus decoder can do our gain for us. The OggOpus header contains a - ** gain field. This field, unlike various gain-related tags, is intended to - ** be a perminent baked-in gain applied before any user-configurable gain - ** (eg replay-gain.) This is so the gain of track can be set without having - ** to re-encode. - ** - ** Both the header.gain field and the parameter are in the Q7.8 format. - ** - ** TODO: Make this configurable? Include other gain sources too? - */ - opus_multistream_decoder_ctl (oopus->u.decode.state, OPUS_SET_GAIN (oopus->header.gain)) ; - - /* - ** Opus packets can vary in length, with the legal values being 2.5, 5, 10, - ** 20, 40 or 60ms. The recommended default for non-realtime is 20ms. As - ** such, allocate a buffer of that size now, we'll realloc later if a - ** larger one is needed. - ** - ** buffersize is expressed in samples/channel, as that is what opus_decode - ** expects. - */ - if (oopus->buffer) - { free (oopus->buffer) ; - oopus->buffer = NULL ; - } ; - oopus->buffersize = 20 * psf->sf.samplerate / 1000 ; - oopus->buffer = malloc (sizeof (float) * psf->sf.channels * oopus->buffersize) ; - if (oopus->buffer == NULL) - return SFE_MALLOC_FAILED ; - - return 0 ; -} /* ogg_opus_setup_decoder */ - -static int -ogg_opus_setup_encoder (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) -{ int error ; - int lookahead ; - int nb_streams ; - int nb_coupled ; - - /* default page latency value (1000ms) */ - oopus->u.encode.latency = 1000 * 48 ; - - switch (psf->sf.samplerate) - { case 8000 : - case 12000 : - case 16000 : - case 24000 : - case 48000 : - oopus->sr_factor = 48000 / psf->sf.samplerate ; - break ; - default : - return SFE_OPUS_BAD_SAMPLERATE ; - } ; - - if (psf->sf.channels <= 2) - { oopus->header.channel_mapping = 0 ; - nb_streams = 1 ; - nb_coupled = psf->sf.channels - 1 ; - oopus->header.stream_map [0] = 0 ; - oopus->header.stream_map [1] = 1 ; - - oopus->u.encode.state = opus_multistream_encoder_create ( - psf->sf.samplerate, - psf->sf.channels, - nb_streams, - nb_coupled, - oopus->header.stream_map, - OPUS_APPLICATION_AUDIO, - &error) ; - } - else - { if (psf->sf.channels <= 8) - { /* Use Vorbis/AC3 channel mappings for surround. */ - oopus->header.channel_mapping = 1 ; - } - else - { /* There is no channel mapping, just audio, in parallel, good luck */ - oopus->header.channel_mapping = 255 ; - } - - oopus->u.encode.state = opus_multistream_surround_encoder_create ( - psf->sf.samplerate, - psf->sf.channels, - oopus->header.channel_mapping, - &nb_streams, - &nb_coupled, - oopus->header.stream_map, - OPUS_APPLICATION_AUDIO, - &error) ; - - } - - if (error != OPUS_OK) - { psf_log_printf (psf, "Opus : Error, opus_multistream_encoder_create returned %s\n", opus_strerror (error)) ; - return SFE_BAD_OPEN_FORMAT ; - } ; - oopus->header.nb_streams = nb_streams ; - oopus->header.nb_coupled = nb_coupled ; - - opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_GET_BITRATE (&oopus->u.encode.bitrate)) ; - psf_log_printf (psf, "Encoding at target bitrate of %dbps\n", oopus->u.encode.bitrate) ; - - /* TODO: Make configurable? */ - error = opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_SET_COMPLEXITY (10)) ; - if (error != OPUS_OK) - { /* Non-fatal */ - psf_log_printf (psf, "Opus : OPUS_SET_COMPLEXITY returned: %s\n", opus_strerror (error)) ; - } - - /* - ** Get the encoder delay. This can vary depending on implementation and - ** encoder configuration. - ** GOTCHA: This returns the preskip at the encoder samplerate, not the - ** granulepos rate of 48000Hz needed for header.preskip. - */ - error = opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_GET_LOOKAHEAD (&lookahead)) ; - if (error != OPUS_OK) - { psf_log_printf (psf, "Opus : OPUS_GET_LOOKAHEAD returned: %s\n", opus_strerror (error)) ; - return SFE_BAD_OPEN_FORMAT ; - } ; - oopus->header.preskip = lookahead * oopus->sr_factor ; - - oopus->len = OGG_OPUS_ENCODE_PACKET_LEN (psf->sf.samplerate) ; - oopus->buffer = malloc (sizeof (float) * psf->sf.channels * oopus->len) ; - if (oopus->buffer == NULL) - return SFE_MALLOC_FAILED ; - - /* - ** Set up the resident ogg packet structure, ready for writing into. - ** 1275 * 3 + 7 bytes of packet per stream is from opusenc from opus-tools - */ - ogg_packet_clear (&odata->opacket) ; - oopus->buffersize = (1275 * 3 + 7) * oopus->header.nb_streams ; - odata->opacket.packet = malloc (oopus->buffersize) ; - odata->opacket.packetno = 2 ; - if (odata->opacket.packet == NULL) - return SFE_MALLOC_FAILED ; - - oopus->serialno = psf_rand_int32 () ; - ogg_stream_init (&odata->ostream, oopus->serialno) ; - - return 0 ; -} /* ogg_opus_setup_encoder */ - -static int -ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - int nn ; - ogg_packet op ; - - oopus->header.version = 1 ; - oopus->header.channels = psf->sf.channels ; - - /* FIXME: Allow the user to set this ?! */ - oopus->header.gain = 0 ; - - if (psf->dataoffset > 0) - { if (psf->have_written) - { /* - ** Might be possible to deal with this, but it's difficult as we - ** have to take Ogg Page header sizes in to account, not just - ** packet sizes. - */ - return SFE_UNIMPLEMENTED ; - } - if (psf_is_pipe (psf)) - return SFE_NOT_SEEKABLE ; - if (psf_fseek (psf, 0, SEEK_SET) < 0) - return SFE_SEEK_FAILED ; - ogg_stream_reset_serialno (&odata->ostream, oopus->serialno) ; - psf->dataoffset = 0 ; - } - else - opus_print_header (psf, &oopus->header) ; - - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - /* Opus Header Marker */ - psf_binheader_writef (psf, "eb", BHWv ("OpusHead"), BHWz (8)) ; - - /* Ogg Embedding scheme version, Channel Count, Preskip Samples */ - psf_binheader_writef (psf, "e112", BHW1 (oopus->header.version), BHW1 (psf->sf.channels), BHW2 (oopus->header.preskip)) ; - - /* - ** If an original samplerate has not been set by the user command - ** SFC_SET_ORIGINAL_SAMPLERATE, write the current samplerate. - */ - if (oopus->header.input_samplerate) - psf_binheader_writef (psf, "e4", BHW4 (oopus->header.input_samplerate)) ; - else - psf_binheader_writef (psf, "e4", BHW4 (psf->sf.samplerate)) ; - - /* Input Sample Rate, Gain (S7.8 format), Channel Mapping Type */ - psf_binheader_writef (psf, "e21", BHW2 (oopus->header.gain), BHW1 (oopus->header.channel_mapping)) ; - - /* Channel mappings, required if not using type 0 (mono/stereo) */ - if (oopus->header.channel_mapping > 0) - { psf_binheader_writef (psf, "11", BHW1 (oopus->header.nb_streams), BHW1 (oopus->header.nb_coupled)) ; - for (nn = 0 ; nn < oopus->header.channels ; nn++) - psf_binheader_writef (psf, "1", BHW1 (oopus->header.stream_map [nn])) ; - } ; - - op.packet = psf->header.ptr ; - op.bytes = psf->header.indx ; - op.b_o_s = 1 ; - op.e_o_s = 0 ; - op.granulepos = 0 ; - op.packetno = 1 ; - - /* The first page MUST only contain the header, so flush it out now */ - ogg_stream_packetin (&odata->ostream, &op) ; - for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; ) - { if (! (nn = ogg_write_page (psf, &odata->opage))) - { psf_log_printf (psf, "Opus : Failed to write header!\n") ; - if (psf->error) - return psf->error ; - return SFE_INTERNAL ; - } ; - psf->dataoffset += nn ; - } - - /* - ** Metadata Tags (manditory) - ** - ** All tags must be in one packet, which may span pages, and these pages - ** must not contain any other packets, so flush. The vendor string should - ** be the libopus library version, as it is doing the actual encoding. We - ** put the libsndfile identifier in the ENCODER tag. - ** - ** See: https://wiki.xiph.org/VorbisComment#ENCODER - */ - vorbiscomment_write_tags (psf, &op, &opustags_ident, opus_get_version_string (), - (OGG_OPUS_COMMENT_PAD)) ; - op.packetno = 2 ; - ogg_stream_packetin (&odata->ostream, &op) ; - for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; ) - { if (! (nn = ogg_write_page (psf, &odata->opage))) - { psf_log_printf (psf, "Opus : Failed to write comments!\n") ; - if (psf->error) - return psf->error ; - return SFE_INTERNAL ; - } ; - psf->dataoffset += nn ; - } - - return 0 ; -} /* ogg_opus_write_header */ - -static void -ogg_opus_flush (SF_PRIVATE *psf) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - uint64_t last_granulepos ; - int nbytes ; - int len ; - int last_packet ; - - /* - ** Need to flush both samples waiting for a complete packet and samples - ** currently 'inside' the encoder because of its latency. In the case of - ** the latter, we need to encode an equivalent amount of silence to push - ** them out. - ** - ** Note that the last packet's granule position might be less than the - ** total number of samples completed in it. This is how Ogg embedded Opus - ** encodes the amount of appended padding to truncate for gapless playback. - */ - - last_granulepos = oopus->pkt_pos + (oopus->sr_factor * oopus->loc) + oopus->header.preskip ; - last_packet = SF_FALSE ; - memset (&(oopus->buffer [oopus->loc * psf->sf.channels]), 0, sizeof (float) * psf->sf.channels * (oopus->len - oopus->loc)) ; - - for (last_packet = SF_FALSE ; last_packet == SF_FALSE ; ) - { oopus->pkt_pos += oopus->len * oopus->sr_factor ; - if (oopus->pkt_pos >= last_granulepos) - { last_packet = SF_TRUE ; - /* - ** Try to shorten the last packet to the smallest valid packet size - ** to minimize padding samples. - */ - len = (oopus->len * oopus->sr_factor) - (oopus->pkt_pos - last_granulepos) ; - if (len <= 120) /* 2.5 ms */ - len = 120 / oopus->sr_factor ; - else if (len <= 240) /* 5 ms */ - len = 240 / oopus->sr_factor ; - else if (len <= 480) /* 10 ms */ - len = 480 / oopus->sr_factor ; - else - len = oopus->len ; - } - else - len = oopus->len ; - - nbytes = opus_multistream_encode_float (oopus->u.encode.state, oopus->buffer, - len, odata->opacket.packet, oopus->buffersize) ; - - if (nbytes < 0) - { psf_log_printf (psf, "Opus : opus_multistream_encode_float returned: %s\n", opus_strerror (nbytes)) ; - break ; - } - - odata->opacket.bytes = nbytes ; - odata->opacket.packetno++ ; - if (last_packet) - { odata->opacket.granulepos = (ogg_int64_t) last_granulepos ; - odata->opacket.e_o_s = 1 ; - } - else - odata->opacket.granulepos = (ogg_int64_t) oopus->pkt_pos ; - - ogg_stream_packetin (&odata->ostream, &odata->opacket) ; - while (ogg_stream_pageout (&odata->ostream, &odata->opage)) - ogg_write_page (psf, &odata->opage) ; - } ; - - while (ogg_stream_flush (&odata->ostream, &odata->opage)) - ogg_write_page (psf, &odata->opage) ; -} /* ogg_opus_flush */ - -static int -ogg_opus_calculate_page_duration (OGG_PRIVATE *odata) -{ int i, samples, duration ; - ogg_packet *ppkt ; - - duration = 0 ; - for (i = 0 , ppkt = odata->pkt ; i < odata->pkt_len ; i++, ppkt++) - { /* Use 48kHz to get the sample count for use with granule positions. */ - samples = opus_packet_get_nb_samples (ppkt->packet, ppkt->bytes, 48000) ; - if (samples > 0) - duration += samples ; - } ; - return duration ; -} /* ogg_opus_calculate_page_duration */ - -static int -ogg_opus_unpack_next_page (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) -{ int nn ; - - nn = ogg_stream_unpack_page (psf, odata) ; - - if (nn == 1) - { oopus->pkt_pos = oopus->pg_pos ; - oopus->pg_pos = odata->pkt [odata->pkt_len - 1].granulepos ; - } - else if (nn == 2) - { uint64_t gp, last_page ; - - /* Found a hole. Need to recalculated pkt_pos from pg_pos */ - last_page = oopus->pg_pos ; - oopus->pg_pos = odata->pkt [odata->pkt_len - 1].granulepos ; - gp = ogg_opus_calculate_page_duration (odata) ; - oopus->pkt_pos = oopus->pg_pos - gp ; - psf_log_printf (psf, "Opus : Hole found appears to be of length %D samples.\n", - (oopus->pkt_pos - last_page) / (uint64_t) oopus->sr_factor) ; - /* - ** Could save the hole size here, and have ogg_opus_read_refill() - ** do packet loss concealment until the hole is gone, but libopus does - ** PLC by generating white-noise for the duration of the hole. That is - ** the correct thing for use in telephony, but it isn't generally - ** appropriate here. It actually sounds better with no PLC, as the - ** lapped nature of full-width Opus means the two edges of the hole - ** will be blended together. - */ - return 1 ; - } - - return nn ; -} /* ogg_opus_unpack_next_page */ - -static int -ogg_opus_read_refill (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) -{ uint64_t pkt_granulepos ; - int nn, nsamp ; - ogg_packet *ppkt ; - - if (odata->pkt_indx == odata->pkt_len) - { nn = ogg_opus_unpack_next_page (psf, odata, oopus) ; - if (nn <= 0) - return nn ; - } - - if (odata->pkt_indx == odata->pkt_len) - return 0 ; - - ppkt = odata->pkt + odata->pkt_indx ; - nsamp = opus_multistream_decode_float (oopus->u.decode.state, - ppkt->packet, ppkt->bytes, oopus->buffer, oopus->buffersize, 0) ; - - if (nsamp == OPUS_BUFFER_TOO_SMALL) - { nsamp = opus_packet_get_nb_samples (ppkt->packet, ppkt->bytes, psf->sf.samplerate) ; - psf_log_printf (psf, "Growing decode buffer to hold %d samples from %d\n", - nsamp, oopus->buffersize) ; - if (nsamp > 5760) - { psf_log_printf (psf, "Packet is larger than maximum allowable of 120ms!? Skipping.\n") ; - return 0 ; - } ; - oopus->buffersize = nsamp ; - - free (oopus->buffer) ; - oopus->buffer = NULL ; - oopus->buffer = malloc (sizeof (float) * oopus->buffersize * psf->sf.channels) ; - if (oopus->buffer == NULL) - { psf->error = SFE_MALLOC_FAILED ; - oopus->buffersize = 0 ; - return -1 ; - } ; - - nsamp = opus_multistream_decode_float (oopus->u.decode.state, - ppkt->packet, ppkt->bytes, oopus->buffer, oopus->buffersize, 0) ; - } ; - odata->pkt_indx ++ ; - - if (nsamp < 0) - { psf_log_printf (psf, "Opus : opus_multistream_decode returned: %s\n", - opus_strerror (nsamp)) ; - psf->error = SFE_INTERNAL ; - return nsamp ; - } ; - - /* - ** Check for if this decoded packet is the last of the stream, in - ** which case a page granule position which is shorter than the - ** sample count of all packets in the page indicates that the last - ** samples are padding and should be dropped. - */ - pkt_granulepos = oopus->pkt_pos + (nsamp * oopus->sr_factor) ; - if (pkt_granulepos <= oopus->pg_pos) - { oopus->len = nsamp ; - } - else - { if (ogg_page_eos (&odata->opage)) - { /* - ** Possible for pg_pos < pkt_pos if there is a trailing - ** packet. It's not supposed to happen, but could. - */ - oopus->len = SF_MAX ((int) (oopus->pg_pos - oopus->pkt_pos) / oopus->sr_factor, 0) ; - } - else - { /* - ** From https://wiki.xiph.org/OggOpus#Granule_Position - ** A decoder MUST reject as invalid any stream where the granule - ** position is smaller than the number of samples contained in - ** packets that complete on the first page with a completed - ** packet, unless that page has the 'end of stream' flag set. It - ** MAY defer this action until it decodes the last packet - ** completed on that page. - */ - psf_log_printf (psf, "Opus : Mid-stream page's granule position %D is less than total samples of %D\n", oopus->pg_pos, pkt_granulepos) ; - psf->error = SFE_MALFORMED_FILE ; - return -1 ; - } ; - } ; - - if (oopus->len > oopus->buffersize) - { free (oopus->buffer) ; - oopus->buffersize = oopus->len ; - oopus->buffer = malloc (sizeof (float) * oopus->buffersize * psf->sf.channels) ; - if (oopus->buffer == NULL) - { psf->error = SFE_MALLOC_FAILED ; - oopus->buffersize = 0 ; - return -1 ; - } ; - } ; - - /* - ** Check for if this decoded packet contains samples from before the pre- - ** skip point, indicating that these samples are padding to get the decoder - ** to converge and should be dropped. - */ - if (oopus->pkt_pos < (unsigned) oopus->header.preskip) - oopus->loc = SF_MIN ((oopus->header.preskip - (int) oopus->pkt_pos) / oopus->sr_factor, oopus->len) ; - else - oopus->loc = 0 ; - - oopus->pkt_pos = pkt_granulepos ; - - return nsamp ; -} /* ogg_opus_read_refill */ - -static int -ogg_opus_write_out (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) -{ int nbytes ; - - if (oopus->u.encode.lsb != oopus->u.encode.lsb_last) - opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_SET_LSB_DEPTH (oopus->u.encode.lsb)) ; - - nbytes = opus_multistream_encode_float (oopus->u.encode.state, - oopus->buffer, oopus->len, - odata->opacket.packet, oopus->buffersize) ; - - if (nbytes < 0) - { psf_log_printf (psf, "Opus : Error, opus_multistream_encode_float returned: %s\n", opus_strerror (nbytes)) ; - psf->error = SFE_INTERNAL ; - return nbytes ; - } ; - - oopus->u.encode.last_segments += (nbytes + 255) / 255 ; - oopus->pkt_pos += oopus->len * oopus->sr_factor ; - odata->opacket.bytes = nbytes ; - odata->opacket.granulepos = oopus->pkt_pos ; - odata->opacket.packetno++ ; - - /* - ** Decide whether to flush the Ogg page *before* adding the new packet to - ** it. Check both for if there is more than 1 second of audio (our default - ** Ogg page latency, this latency can be modified using sf_command()) - ** or if adding the packet would cause a continued page, - ** in which case we might as well make a new page anyways. - */ - for ( ; ; ) - { if (oopus->pkt_pos - oopus->pg_pos >= oopus->u.encode.latency || oopus->u.encode.last_segments >= 255) - nbytes = ogg_stream_flush_fill (&odata->ostream, &odata->opage, 255 * 255) ; - else - nbytes = ogg_stream_pageout_fill (&odata->ostream, &odata->opage, 255 * 255) ; - if (nbytes > 0) - { oopus->u.encode.last_segments -= ogg_page_segments (&odata->opage) ; - oopus->pg_pos = oopus->pkt_pos ; - ogg_write_page (psf, &odata->opage) ; - } - else - break ; - } ; - - ogg_stream_packetin (&odata->ostream, &odata->opacket) ; - oopus->loc = 0 ; - oopus->u.encode.lsb_last = oopus->u.encode.lsb ; - oopus->u.encode.lsb = 0 ; - - return 1 ; -} /* ogg_opus_write_out */ - -static sf_count_t -ogg_opus_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t total = 0 ; - sf_count_t readlen, i ; - float *iptr ; - - while (total < len) - { if (oopus->loc == oopus->len) - { if (ogg_opus_read_refill (psf, odata, oopus) <= 0) - return total ; - } ; - - readlen = SF_MIN (len - total, (sf_count_t) (oopus->len - oopus->loc) * psf->sf.channels) ; - if (readlen > 0) - { iptr = oopus->buffer + oopus->loc * psf->sf.channels ; - i = total ; - total += readlen ; - - if (psf->float_int_mult) - { float inverse = 1.0 / psf->float_max ; - for ( ; i < total ; i++) - { ptr [i] = psf_lrintf (((*(iptr++)) * inverse) * 32767.0f) ; - } ; - } - else - { for ( ; i < total ; i++) - { ptr [i] = psf_lrintf ((*(iptr++)) * 32767.0f) ; - } ; - } ; - oopus->loc += (readlen / psf->sf.channels) ; - } ; - } ; - return total ; -} /* ogg_opus_read_s */ - -static sf_count_t -ogg_opus_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t total = 0 ; - sf_count_t readlen, i ; - float *iptr ; - - while (total < len) - { if (oopus->loc == oopus->len) - { if (ogg_opus_read_refill (psf, odata, oopus) <= 0) - return total ; - } ; - - readlen = SF_MIN (len - total, (sf_count_t) (oopus->len - oopus->loc) * psf->sf.channels) ; - if (readlen > 0) - { iptr = oopus->buffer + oopus->loc * psf->sf.channels ; - i = total ; - total += readlen ; - - if (psf->float_int_mult) - { float inverse = 1.0 / psf->float_max ; - for ( ; i < total ; i++) - { ptr [i] = psf_lrintf (((*(iptr++)) * inverse) * 2147483647.0f) ; - } - } - else - { for ( ; i < total ; i++) - { ptr [i] = psf_lrintf ((*(iptr++)) * 2147483647.0f) ; - } - } ; - oopus->loc += (readlen / psf->sf.channels) ; - } ; - } ; - return total ; -} /* ogg_opus_read_i */ - -static sf_count_t -ogg_opus_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t total = 0 ; - sf_count_t readlen ; - - while (total < len) - { if (oopus->loc == oopus->len) - { if (ogg_opus_read_refill (psf, odata, oopus) <= 0) - return total ; - } ; - - readlen = SF_MIN (len - total, (sf_count_t) (oopus->len - oopus->loc) * psf->sf.channels) ; - if (readlen > 0) - { memcpy (&(ptr [total]), &(oopus->buffer [oopus->loc * psf->sf.channels]), sizeof (float) * readlen) ; - total += readlen ; - oopus->loc += (readlen / psf->sf.channels) ; - } ; - } ; - return total ; -} /* ogg_opus_read_f */ - -static sf_count_t -ogg_opus_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t total = 0 ; - sf_count_t readlen, i ; - float *fptr ; - - while (total < len) - { if (oopus->loc >= oopus->len) - { if (ogg_opus_read_refill (psf, odata, oopus) <= 0) - return total ; - } ; - - readlen = SF_MIN (len - total, (sf_count_t) (oopus->len - oopus->loc) * psf->sf.channels) ; - - if (readlen > 0) - { fptr = oopus->buffer + oopus->loc * psf->sf.channels ; - i = total ; - total += readlen ; - for ( ; i < total ; i++) - { ptr [i] = *fptr++ ; - } ; - oopus->loc += readlen / psf->sf.channels ; - } ; - } ; - return total ; -} /* ogg_opus_read_d */ - -static sf_count_t -ogg_opus_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t total, i ; - int writelen ; - float *optr ; - - if (oopus->u.encode.lsb < 16) - oopus->u.encode.lsb = 16 ; - - for (total = 0 ; total < len ; ) - { if (oopus->loc >= oopus->len) - { /* Need to encode the buffer */ - if (ogg_opus_write_out (psf, odata, oopus) <= 0) - return total ; - } ; - - writelen = SF_MIN (len - total, (sf_count_t) (oopus->len - oopus->loc) * psf->sf.channels) ; - if (writelen) - { optr = oopus->buffer + oopus->loc * psf->sf.channels ; - i = total ; - total += writelen ; - for ( ; i < total ; i++) - { *optr++ = (float) (ptr [i]) / 32767.0f ; - } - oopus->loc += (writelen / psf->sf.channels) ; - } ; - } ; - return total ; -} /* ogg_opus_write_s */ - -static sf_count_t -ogg_opus_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t total, i ; - int writelen ; - float *optr ; - - if (oopus->u.encode.lsb < 24) - oopus->u.encode.lsb = 24 ; - - for (total = 0 ; total < len ; ) - { if (oopus->loc >= oopus->len) - { /* Need to encode the buffer */ - if (ogg_opus_write_out (psf, odata, oopus) <= 0) - return total ; - } ; - - writelen = SF_MIN (len - total, (sf_count_t) (oopus->len - oopus->loc) * psf->sf.channels) ; - if (writelen) - { optr = oopus->buffer + oopus->loc * psf->sf.channels ; - i = total ; - total += writelen ; - for ( ; i < total ; i++) - { *optr++ = (float) (ptr [i]) / 2147483647.0f ; - } ; - oopus->loc += (writelen / psf->sf.channels) ; - } ; - } ; - return total ; -} /* ogg_opus_write_i */ - -static sf_count_t -ogg_opus_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t total ; - int writelen ; - - if (oopus->u.encode.lsb < 24) - oopus->u.encode.lsb = 24 ; - - for (total = 0 ; total < len ; ) - { if (oopus->loc >= oopus->len) - { /* Need to encode the buffer */ - if (ogg_opus_write_out (psf, odata, oopus) <= 0) - return total ; - } ; - - writelen = SF_MIN (len - total, (sf_count_t) (oopus->len - oopus->loc) * psf->sf.channels) ; - if (writelen) - { memcpy (&(oopus->buffer [oopus->loc * psf->sf.channels]), &(ptr [total]), sizeof (float) * writelen) ; - total += writelen ; - oopus->loc += (writelen / psf->sf.channels) ; - } ; - } ; - return total ; -} /* ogg_opus_write_f */ - -static sf_count_t -ogg_opus_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t total, i ; - int writelen ; - float *optr ; - - if (oopus->u.encode.lsb < 24) - oopus->u.encode.lsb = 24 ; - - for (total = 0 ; total < len ; ) - { if (oopus->loc >= oopus->len) - { /* Need to encode the buffer */ - if (ogg_opus_write_out (psf, odata, oopus) <= 0) - return total ; - } ; - - writelen = SF_MIN (len - total, (sf_count_t) (oopus->len - oopus->loc) * psf->sf.channels) ; - if (writelen) - { optr = oopus->buffer + oopus->loc * psf->sf.channels ; - i = total ; - total += writelen ; - for ( ; i < total ; i++) - { *optr++ = (float) (ptr [i]) ; - } ; - oopus->loc += (writelen / psf->sf.channels) ; - } ; - } ; - return total ; -} /* ogg_opus_write_d */ - -static int -ogg_opus_analyze_file (SF_PRIVATE *psf) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - uint64_t gp ; - sf_count_t saved_offset, last_page ; - int error ; - - psf->sf.sections = 1 ; - psf->sf.frames = SF_COUNT_MAX ; - oopus->u.decode.gp_end = (uint64_t) -1 ; - oopus->u.decode.last_offset = SF_COUNT_MAX ; - - psf->dataoffset = ogg_sync_ftell (psf) ; - if (psf->filelength != SF_COUNT_MAX) - psf->datalength = psf->filelength - psf->dataoffset ; - else - psf->datalength = SF_COUNT_MAX ; - - /* - ** Calculate the start granule position offset - ** - ** OggOpus streams are allowed to start with a granule position other than - ** zero. This allows for cutting the beginning off of streams without - ** having to modify all following granule positions, or for recording/ - ** joining a live stream in the middle. To figure out the offset, we need - ** to sum up how many samples are in all the packets that complete in the - ** page and subtract it from the page granule position. - ** - ** If this is the last page of the steam (EOS set), this is not possible, - ** as the granule position may be /less/ than the number of samples, to - ** indicate how many samples are end-padding. In this case the granule - ** position offset of the file must be 0, as otherwise it is considered - ** malformed. - */ - error = ogg_opus_unpack_next_page (psf, odata, oopus) ; - if (error < 0 && psf->error) - return psf->error ; - - gp = ogg_opus_calculate_page_duration (odata) ; - if (gp <= 0) - { psf_log_printf (psf, "Opus : Page duration of zero!\n") ; - return SFE_MALFORMED_FILE ; - } ; - - if (!ogg_page_eos (&odata->opage)) - { if (gp > oopus->pg_pos) - { psf_log_printf (psf, "Opus : First data page's granule position is less than total number of samples on the page!\n") ; - return SFE_MALFORMED_FILE ; - } - oopus->pkt_pos = oopus->pg_pos - gp ; - } - else if (gp < oopus->pg_pos) - { psf_log_printf (psf, "Opus : First data page is also the last, and granule position has an (ambigious) offset.\n") ; - return SFE_MALFORMED_FILE ; - } ; - oopus->u.decode.gp_start = oopus->pkt_pos ; - - if (!psf->sf.seekable) - return 0 ; - - /* - ** Find the last page and fetch the last granule position. - ** First, save were we are now. - */ - saved_offset = ogg_sync_ftell (psf) ; - - /* This uses the sync page buffer, the stream page buffer is untouched. */ - last_page = ogg_sync_last_page_before (psf, odata, &oopus->u.decode.gp_end, psf->filelength, oopus->serialno) ; - if (last_page > 0) - { if (!ogg_page_eos (&odata->opage)) - psf_log_printf (psf, "Ogg : Last page lacks an end-of-stream bit.\n") ; - if (last_page + odata->opage.header_len + odata->opage.body_len < psf->filelength) - psf_log_printf (psf, "Ogg : Junk after the last page.\n") ; - oopus->u.decode.last_offset = last_page ; - - if (oopus->u.decode.gp_end != (uint64_t) -1) - { psf->sf.frames = (oopus->u.decode.gp_end - oopus->u.decode.gp_start - - oopus->header.preskip) / oopus->sr_factor ; - } ; - } ; - - - psf_log_printf (psf, " Granule pos offset : %D\n", oopus->u.decode.gp_start) ; - if (oopus->u.decode.gp_end != (uint64_t) -1) - psf_log_printf (psf, " Last Granule pos : %D\n", oopus->u.decode.gp_end) ; - - /* Go back to where we left off. */ - ogg_sync_fseek (psf, saved_offset, SEEK_SET) ; - return 0 ; -} /* ogg_opus_analyze_file */ - -/* -** ogg_opus_null_read -** -** Decode samples, doing nothing with them, until the desired granule position -** is reached. -*/ -static sf_count_t -ogg_opus_null_read (SF_PRIVATE *psf, sf_count_t offset) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t total ; - - total = (oopus->pkt_pos / oopus->sr_factor) - (oopus->len - oopus->loc) ; - for ( ; total < offset ; ) - { sf_count_t readlen = SF_MIN ((int) (offset - total), (oopus->len - oopus->loc)) ; - if (readlen > 0) - { total += readlen ; - oopus->loc += readlen ; - } ; - if (oopus->loc == oopus->len) - { if (ogg_opus_read_refill (psf, odata, oopus) <= 0) - return total ; - /* - ** Ignore pre-skip skipping. The preskip was accounted for in the - ** arugment to offset, so we need to count it. - */ - oopus->loc = 0 ; - } ; - } ; - return total ; -} /* ogg_opus_null_read */ - -/* -** ogg_opus_page_seek_search -** -** Search within the file for the page with the highest granule position at or -** before our target. -*/ -static int -ogg_opus_page_seek_search (SF_PRIVATE *psf, uint64_t target_gp) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - uint64_t pcm_start ; - uint64_t pcm_end ; - uint64_t best_gp ; - sf_count_t begin ; - sf_count_t end ; - sf_count_t old_pos ; - int ret ; - - best_gp = pcm_start = oopus->u.decode.gp_start ; - pcm_end = oopus->u.decode.gp_end ; - begin = psf->dataoffset ; - end = oopus->u.decode.last_offset ; - - /* Search the Ogg stream for such a page */ - old_pos = ogg_sync_ftell (psf) ; - ret = ogg_stream_seek_page_search (psf, odata, target_gp, pcm_start, pcm_end, &best_gp, begin, end, 48000) ; - if (ret != 0) - { ogg_sync_fseek (psf, old_pos, SEEK_SET) ; - return ret ; - } ; - - /* Load the page that contains our pre-roll target */ - oopus->loc = 0 ; - oopus->len = 0 ; - if ((ret = ogg_opus_unpack_next_page (psf, odata, oopus)) != 1) - return ret ; - oopus->pkt_pos = best_gp ; - - /* Reset the decoder (gain settings survive the reset) */ - opus_multistream_decoder_ctl (oopus->u.decode.state, OPUS_RESET_STATE) ; - - return 0 ; -} /* ogg_opus_page_seek_search */ - -/* -** ogg_opus_page_seek_manual -** -** Seek to the beginning of the Ogg stream and read pages until we find one with -** a granule position at or before our target. -*/ -static sf_count_t -ogg_opus_page_seek_manual (SF_PRIVATE *psf, uint64_t target_gp) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - sf_count_t pos ; - int nn ; - - if (oopus->pg_pos > target_gp) - { ogg_stream_reset (&odata->ostream) ; - pos = ogg_sync_fseek (psf, psf->dataoffset, SEEK_SET) ; - if (pos < 0) - return pos ; - oopus->pg_pos = oopus->u.decode.gp_start ; - opus_multistream_decoder_ctl (oopus->u.decode.state, OPUS_RESET_STATE) ; - } ; - - while (oopus->pg_pos < target_gp) - { nn = ogg_opus_unpack_next_page (psf, odata, oopus) ; - if (nn <= 0) - return nn ; - } ; - - return 1 ; -} /* ogg_opus_page_seek_manual */ - -static sf_count_t -ogg_opus_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - uint64_t target_gp, current_gp ; - int ret ; - - /* Only support seeking in read mode. */ - if (mode != SFM_READ || psf->file.mode != SFM_READ) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - /* Figure out the current position granule pos. Use the start of the - * current buffer, to avoid backwards seeking if the target is on the page - * but before the current locaiton. */ - oopus->loc = 0 ; - current_gp = oopus->pkt_pos - (uint64_t) (oopus->len * oopus->sr_factor) ; - - /* Calculate the target granule pos. This includes the decoder delay and - * the file granule position offset. */ - target_gp = offset * oopus->sr_factor ; - target_gp += oopus->u.decode.gp_start ; - target_gp += oopus->header.preskip ; - - /* Check if we need to do a page seek. */ - if (target_gp < current_gp || target_gp - current_gp > OGG_OPUS_PREROLL) - { uint64_t preroll_gp ; - - /* For a page seek, use an earlier target granule pos, giving the - * decoder samples to converge before the actual target. */ - if (target_gp >= OGG_OPUS_PREROLL + oopus->u.decode.gp_start + (uint64_t) oopus->header.preskip) - { preroll_gp = target_gp - OGG_OPUS_PREROLL ; - } - else - { preroll_gp = oopus->u.decode.gp_start + (uint64_t) oopus->header.preskip ; - } ; - - if (oopus->u.decode.gp_end == (uint64_t) -1) - { /* - ** Don't know the end of the file. Could be a chained file we don't yet - ** support. Oh well, just do it manually. - */ - ogg_opus_page_seek_manual (psf, preroll_gp) ; - } - else - { ret = ogg_opus_page_seek_search (psf, preroll_gp) ; - if (ret < 0) - { /* - ** Page seek failed, what to do? Could be bad data. We can - ** either fall-back to manual seeking or bail. Manaul seeking - ** from the beginning has the advantage of finding where the - ** file goes bad. - */ - ret = ogg_opus_page_seek_manual (psf, preroll_gp) ; - if (ret < 0) - { /* - ** If were here, and there is no error, we can be pretty - ** sure that it's the file that is to blame. - */ - if (!psf->error) - psf->error = SFE_MALFORMED_FILE ; - return ret ; - } ; - } ; - } ; - - /* - ** Skip over packets on the found page that are before our pre-roll - ** target to avoid unnecessary decoding, and make decoder convergence - ** independent of page boundaries for more visible errors. - */ - for ( ; odata->pkt_indx != odata->pkt_len ; ) - { ogg_packet *ppkt = &odata->pkt [odata->pkt_indx] ; - int nsamp = opus_packet_get_nb_samples (ppkt->packet, ppkt->bytes, 48000) ; - if (oopus->pkt_pos + nsamp < preroll_gp) - { oopus->pkt_pos += nsamp ; - odata->pkt_indx++ ; - } - else - break ; - } ; - } ; - - /* - ** We've seeked or skipped through pages until just before our target, - ** now decode until we hit it. - */ - offset = ogg_opus_null_read (psf, target_gp / oopus->sr_factor) ; - return offset - ((oopus->header.preskip + oopus->u.decode.gp_start) / oopus->sr_factor) ; - -} /* ogg_opus_seek */ - -static int -ogg_opus_command (SF_PRIVATE *psf, int command, void *data, int datasize) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - double quality ; - double latency ; - int error ; - - switch (command) - { case SFC_SET_CHANNEL_MAP_INFO : - /* TODO: figure this out */ - break ; - - case SFC_SET_OGG_PAGE_LATENCY : - /* - ** Argument: double, range 50 to 1600. - ** Average length of OGG page in ms. - ** This length drive the flush of pages. - */ - if (data == NULL || datasize != SIGNED_SIZEOF (double)) - return SFE_BAD_COMMAND_PARAM ; - - latency = *((double *) data) ; - if (latency < 50) - latency = 50 ; - - if (latency > 1600) - latency = 1600 ; - - oopus->u.encode.latency = ((unsigned long) latency) * 48 ; - break ; - - case SFC_SET_COMPRESSION_LEVEL : - /* - ** Argument: double, range 0.0 (lest compressed, best quality) to - ** 1.0 (most compressed, worst quality) - */ - if (data == NULL || datasize != SIGNED_SIZEOF (double)) - return SFE_BAD_COMMAND_PARAM ; - - /* Usable bitrate range is [6, 256] kbps per channel. */ - quality = *((double *) data) ; - oopus->u.encode.bitrate = (int) (((1.0 - quality) * (250000.0)) + 6000.0) * psf->sf.channels ; - if (opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_SET_BITRATE (oopus->u.encode.bitrate)) == OPUS_OK) - { psf_log_printf (psf, "User changed encoding target bitrate to %dbps\n", oopus->u.encode.bitrate) ; - return SF_TRUE ; - } - psf_log_printf (psf, "Failed to set user encoding target bitrate of %dbps\n", oopus->u.encode.bitrate) ; - return SF_FALSE ; - break ; - - case SFC_SET_ORIGINAL_SAMPLERATE : - if (data == NULL || datasize != SIGNED_SIZEOF (int)) - return SFE_BAD_COMMAND_PARAM ; - /* - ** Only allow changing the input samplerate if at the beginning - ** of the stream, because while it might be possible to change - ** samplerate mid-decode, or to re-write the header for encode, - ** ain't nobody got time to implement and test that. - */ - if (psf->file.mode == SFM_WRITE) - { if (psf->have_written) - return SF_FALSE ; - oopus->header.input_samplerate = *((int *) data) ; - } - else { - if (oopus->pkt_pos > oopus->u.decode.gp_start || oopus->loc > 0) - return SF_FALSE ; - if ((error = ogg_opus_setup_decoder (psf, *((int *) data)))) - return error ; - odata->pkt_indx = 0 ; - /* Adjust file frames count. */ - if (oopus->u.decode.gp_end != (uint64_t) -1) - psf->sf.frames = (oopus->u.decode.gp_end - oopus->u.decode.gp_start - - oopus->header.preskip) / oopus->sr_factor ; - } ; - return SF_TRUE ; - - case SFC_GET_ORIGINAL_SAMPLERATE : - if (data == NULL || datasize != SIGNED_SIZEOF (int)) - return SFE_BAD_COMMAND_PARAM ; - *((int *) data) = oopus->header.input_samplerate ; - return SF_TRUE ; - - case SFC_GET_OGG_STREAM_SERIALNO : - if (data == NULL || datasize != sizeof (int32_t)) - return SF_FALSE ; - - *((int32_t *) data) = odata->ostream.serialno ; - return SF_TRUE ; - - default : - break ; - } - - return SF_FALSE ; -} /* ogg_opus_command */ - -static int -ogg_opus_byterate (SF_PRIVATE *psf) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - OPUS_PRIVATE *oopus = (OPUS_PRIVATE *) psf->codec_data ; - - if (psf->file.mode == SFM_READ) - { if (odata->pkt_indx == odata->pkt_len) - { if (ogg_opus_unpack_next_page (psf, odata, oopus) < 0) - return -1 ; - } ; - - if (odata->pkt_indx < odata->pkt_len) - { ogg_packet *ppkt = &odata->pkt [odata->pkt_indx] ; - return (ppkt->bytes * 8000) / opus_packet_get_nb_samples (ppkt->packet, ppkt->bytes, 8000) ; - } ; - - if (psf->datalength != SF_COUNT_MAX) - return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; - } ; - - if (psf->file.mode == SFM_WRITE && oopus->u.encode.state != NULL) - return (oopus->u.encode.bitrate + 7) / 8 ; - - return -1 ; -} /* ogg_opus_byterate */ - -#else /* HAVE_EXTERNAL_XIPH_LIBS */ - -int -ogg_opus_open (SF_PRIVATE *psf) -{ - psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Opus support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* ogg_opus_open */ - -#endif diff --git a/Engine/lib/libsndfile/src/ogg_pcm.c b/Engine/lib/libsndfile/src/ogg_pcm.c deleted file mode 100644 index f105214b7..000000000 --- a/Engine/lib/libsndfile/src/ogg_pcm.c +++ /dev/null @@ -1,167 +0,0 @@ -/* -** Copyright (C) 2008-2016 Erik de Castro Lopo -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if (ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_XIPH_LIBS) - -#include - -#include "ogg.h" - -typedef struct -{ int32_t serialno ; - - - void * state ; -} OPCM_PRIVATE ; - -static int opcm_read_header (SF_PRIVATE * psf) ; -static int opcm_close (SF_PRIVATE *psf) ; - -int -ogg_pcm_open (SF_PRIVATE *psf) -{ OGG_PRIVATE* odata = psf->container_data ; - OPCM_PRIVATE* opcm = calloc (1, sizeof (OPCM_PRIVATE)) ; - int error = 0 ; - - if (odata == NULL) - { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ; - free (opcm) ; - return SFE_INTERNAL ; - } ; - - psf->codec_data = opcm ; - if (opcm == NULL) - return SFE_MALLOC_FAILED ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode == SFM_READ) - { /* Call this here so it only gets called once, so no memory is leaked. */ - ogg_sync_init (&odata->osync) ; - - if ((error = opcm_read_header (psf))) - return error ; - -#if 0 - psf->read_short = opcm_read_s ; - psf->read_int = opcm_read_i ; - psf->read_float = opcm_read_f ; - psf->read_double = opcm_read_d ; - psf->sf.frames = opcm_length (psf) ; -#endif - } ; - - psf->codec_close = opcm_close ; - - if (psf->file.mode == SFM_WRITE) - { -#if 0 - /* Set the default opcm quality here. */ - vdata->quality = 0.4 ; - - psf->write_header = opcm_write_header ; - psf->write_short = opcm_write_s ; - psf->write_int = opcm_write_i ; - psf->write_float = opcm_write_f ; - psf->write_double = opcm_write_d ; -#endif - - psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */ - psf->strings.flags = SF_STR_ALLOW_START ; - } ; - - psf->bytewidth = 1 ; - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - -#if 0 - psf->seek = opcm_seek ; - psf->command = opcm_command ; -#endif - - /* FIXME, FIXME, FIXME : Hack these here for now and correct later. */ - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_SPEEX ; - psf->sf.sections = 1 ; - - psf->datalength = 1 ; - psf->dataoffset = 0 ; - /* End FIXME. */ - - return error ; -} /* ogg_pcm_open */ - -static int -opcm_read_header (SF_PRIVATE * UNUSED (psf)) -{ - return 0 ; -} /* opcm_read_header */ - -static int -opcm_close (SF_PRIVATE * UNUSED (psf)) -{ - - - return 0 ; -} /* opcm_close */ - - - -/* -encoded_speex_frames = (frames_per_packet * Packets) - = 1 * 272 - = 272 - -audio_samples = encoded_speex_frames * frame_size - = 272 * 640 - = 174080 - -duration = audio_samples / rate - = 174080 / 44100 - = 3.947 -*/ - -#else /* ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_XIPH_LIBS */ - -int -ogg_pcm_open (SF_PRIVATE *psf) -{ - psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Speex support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* ogg_pcm_open */ - -#endif diff --git a/Engine/lib/libsndfile/src/ogg_speex.c b/Engine/lib/libsndfile/src/ogg_speex.c deleted file mode 100644 index 546cf35d7..000000000 --- a/Engine/lib/libsndfile/src/ogg_speex.c +++ /dev/null @@ -1,428 +0,0 @@ -/* -** Copyright (C) 2008-2016 Erik de Castro Lopo -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if (ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_XIPH_LIBS) - -#include - -#include -#include -#include -#include - -#include "ogg.h" - -#define OGG_SPX_READ_SIZE 200 - -typedef struct -{ SpeexBits bits ; - - int32_t serialno ; - - int frame_size, granule_frame_size, nframes ; - int force_mode ; - - SpeexStereoState stereo ; - SpeexHeader header ; - - void * state ; -} SPX_PRIVATE ; - -static int spx_read_header (SF_PRIVATE * psf) ; -static int spx_close (SF_PRIVATE *psf) ; -static void *spx_header_read (SF_PRIVATE * psf, ogg_packet *op, spx_int32_t enh_enabled, int force_mode) ; -static void spx_print_comments (const char *comments, int length) ; - -int -ogg_speex_open (SF_PRIVATE *psf) -{ OGG_PRIVATE* odata = psf->container_data ; - SPX_PRIVATE* spx = calloc (1, sizeof (SPX_PRIVATE)) ; - int error = 0 ; - - if (odata == NULL) - { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ; - free (spx) ; - return SFE_INTERNAL ; - } ; - - psf->codec_data = spx ; - if (spx == NULL) - return SFE_MALLOC_FAILED ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode == SFM_READ) - { /* Call this here so it only gets called once, so no memory is leaked. */ - ogg_sync_init (&odata->osync) ; - - if ((error = spx_read_header (psf))) - return error ; - -#if 0 - psf->read_short = spx_read_s ; - psf->read_int = spx_read_i ; - psf->read_float = spx_read_f ; - psf->read_double = spx_read_d ; - psf->sf.frames = spx_length (psf) ; -#endif - } ; - - psf->codec_close = spx_close ; - - if (psf->file.mode == SFM_WRITE) - { -#if 0 - /* Set the default spx quality here. */ - vdata->quality = 0.4 ; - - psf->write_header = spx_write_header ; - psf->write_short = spx_write_s ; - psf->write_int = spx_write_i ; - psf->write_float = spx_write_f ; - psf->write_double = spx_write_d ; -#endif - - psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */ - psf->strings.flags = SF_STR_ALLOW_START ; - } ; - - psf->bytewidth = 1 ; - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - -#if 0 - psf->seek = spx_seek ; - psf->command = spx_command ; -#endif - - /* FIXME, FIXME, FIXME : Hack these here for now and correct later. */ - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_SPEEX ; - psf->sf.sections = 1 ; - - psf->datalength = 1 ; - psf->dataoffset = 0 ; - /* End FIXME. */ - - return error ; -} /* ogg_speex_open */ - -#define le_short (x) (x) - -static int -spx_read_header (SF_PRIVATE * psf) -{ static SpeexStereoState STEREO_INIT = SPEEX_STEREO_STATE_INIT ; - - OGG_PRIVATE* odata = psf->container_data ; - SPX_PRIVATE* spx = psf->codec_data ; - - ogg_int64_t page_granule = 0 ; - int stream_init = 0 ; - int page_nb_packets = 0 ; - int packet_count = 0 ; - int enh_enabled = 1 ; - int force_mode = -1 ; - char * data ; - int nb_read ; - int lookahead ; - -printf ("%s %d\n", __func__, __LINE__) ; - - psf_log_printf (psf, "Speex header\n") ; - odata->eos = 0 ; - - /* Reset ogg stuff which has already been used in src/ogg.c. */ - ogg_stream_reset (&odata->ostream) ; - ogg_sync_reset (&odata->osync) ; - - /* Seek to start of stream. */ - psf_fseek (psf, 0, SEEK_SET) ; - - /* Initialize. */ - ogg_sync_init (&odata->osync) ; - speex_bits_init (&spx->bits) ; - - /* Set defaults. */ - psf->sf.channels = -1 ; - psf->sf.samplerate = 0 ; - spx->stereo = STEREO_INIT ; - - /* Get a pointer to the ogg buffer and read data into it. */ - data = ogg_sync_buffer (&odata->osync, OGG_SPX_READ_SIZE) ; - nb_read = psf_fread (data, 1, OGG_SPX_READ_SIZE, psf) ; - ogg_sync_wrote (&odata->osync, nb_read) ; - - /* Now we chew on Ogg packets. */ - while (ogg_sync_pageout (&odata->osync, &odata->opage) == 1) - { if (stream_init == 0) - { ogg_stream_init (&odata->ostream, ogg_page_serialno (&odata->opage)) ; - stream_init = 1 ; - } ; - - if (ogg_page_serialno (&odata->opage) != odata->ostream.serialno) - { /* so all streams are read. */ - ogg_stream_reset_serialno (&odata->ostream, ogg_page_serialno (&odata->opage)) ; - } ; - - /*Add page to the bitstream*/ - ogg_stream_pagein (&odata->ostream, &odata->opage) ; - page_granule = ogg_page_granulepos (&odata->opage) ; - page_nb_packets = ogg_page_packets (&odata->opage) ; - - /*Extract all available packets*/ - while (odata->eos == 0 && ogg_stream_packetout (&odata->ostream, &odata->opacket) == 1) - { if (odata->opacket.bytes >= 8 && memcmp (odata->opacket.packet, "Speex ", 8) == 0) - { spx->serialno = odata->ostream.serialno ; - } ; - - if (spx->serialno == -1 || odata->ostream.serialno != spx->serialno) - break ; - - if (packet_count == 0) - { spx->state = spx_header_read (psf, &odata->opacket, enh_enabled, force_mode) ; - if (! spx->state) - break ; - - speex_decoder_ctl (spx->state, SPEEX_GET_LOOKAHEAD, &lookahead) ; - if (spx->nframes == 0) - spx->nframes = 1 ; - } - else if (packet_count == 1) - { spx_print_comments ((const char*) odata->opacket.packet, odata->opacket.bytes) ; - } - else if (packet_count < 2 + spx->header.extra_headers) - { /* Ignore extra headers */ - } - packet_count ++ ; - } ; - } ; - - psf_log_printf (psf, "End\n") ; - - psf_log_printf (psf, "packet_count %d\n", packet_count) ; - psf_log_printf (psf, "page_nb_packets %d\n", page_nb_packets) ; - psf_log_printf (psf, "page_granule %lld\n", page_granule) ; - - return 0 ; -} /* spx_read_header */ - -static int -spx_close (SF_PRIVATE *psf) -{ SPX_PRIVATE* spx = psf->codec_data ; - - if (spx->state) - speex_decoder_destroy (spx->state) ; - - if (spx) - speex_bits_destroy (&spx->bits) ; - - return 0 ; -} /* spx_close */ - - - -static void * -spx_header_read (SF_PRIVATE * psf, ogg_packet *op, spx_int32_t enh_enabled, int force_mode) -{ SPX_PRIVATE* spx = psf->codec_data ; - void *st ; - const SpeexMode *mode ; - SpeexHeader *tmp_header ; - int modeID ; - SpeexCallback callback ; - - tmp_header = speex_packet_to_header ((char*) op->packet, op->bytes) ; - if (tmp_header == NULL) - { psf_log_printf (psf, "Cannot read Speex header\n") ; - return NULL ; - } ; - - memcpy (&spx->header, tmp_header, sizeof (spx->header)) ; - free (tmp_header) ; - tmp_header = NULL ; - - if (spx->header.mode >= SPEEX_NB_MODES || spx->header.mode < 0) - { psf_log_printf (psf, "Mode number %d does not (yet/any longer) exist in this version\n", spx->header.mode) ; - return NULL ; - } ; - - modeID = spx->header.mode ; - if (force_mode != -1) - modeID = force_mode ; - - mode = speex_lib_get_mode (modeID) ; - - if (spx->header.speex_version_id > 1) - { psf_log_printf (psf, "This file was encoded with Speex bit-stream version %d, which I don't know how to decode\n", spx->header.speex_version_id) ; - return NULL ; - } ; - - if (mode->bitstream_version < spx->header.mode_bitstream_version) - { psf_log_printf (psf, "The file was encoded with a newer version of Speex. You need to upgrade in order to play it.\n") ; - return NULL ; - } ; - - if (mode->bitstream_version > spx->header.mode_bitstream_version) - { psf_log_printf (psf, "The file was encoded with an older version of Speex. You would need to downgrade the version in order to play it.\n") ; - return NULL ; - } ; - - st = speex_decoder_init (mode) ; - if (!st) - { psf_log_printf (psf, "Decoder initialization failed.\n") ; - return NULL ; - } ; - - speex_decoder_ctl (st, SPEEX_SET_ENH, &enh_enabled) ; - speex_decoder_ctl (st, SPEEX_GET_FRAME_SIZE, &spx->frame_size) ; - spx->granule_frame_size = spx->frame_size ; - - if (!psf->sf.samplerate) - psf->sf.samplerate = spx->header.rate ; - /* Adjust rate if --force-* options are used */ - if (force_mode != -1) - { if (spx->header.mode < force_mode) - { psf->sf.samplerate <<= (force_mode - spx->header.mode) ; - spx->granule_frame_size >>= (force_mode - spx->header.mode) ; - } ; - if (spx->header.mode > force_mode) - { psf->sf.samplerate >>= (spx->header.mode - force_mode) ; - spx->granule_frame_size <<= (spx->header.mode - force_mode) ; - } ; - } ; - - speex_decoder_ctl (st, SPEEX_SET_SAMPLING_RATE, &psf->sf.samplerate) ; - - spx->nframes = spx->header.frames_per_packet ; - - if (psf->sf.channels == -1) - psf->sf.channels = spx->header.nb_channels ; - - if (! (psf->sf.channels == 1)) - { psf->sf.channels = 2 ; - callback.callback_id = SPEEX_INBAND_STEREO ; - callback.func = speex_std_stereo_request_handler ; - callback.data = &spx->stereo ; - speex_decoder_ctl (st, SPEEX_SET_HANDLER, &callback) ; - } ; - - spx->header.speex_version [sizeof (spx->header.speex_version) - 1] = 0 ; - - psf_log_printf (psf, " Encoder ver : %s\n Frames/packet : %d\n", - spx->header.speex_version, spx->header.frames_per_packet) ; - - if (spx->header.bitrate > 0) - psf_log_printf (psf, " Bit rate : %d\n", spx->header.bitrate) ; - - psf_log_printf (psf, " Sample rate : %d\n Mode : %s\n VBR : %s\n Channels : %d\n", - psf->sf.samplerate, mode->modeName, (spx->header.vbr ? "yes" : "no"), psf->sf.channels) ; - - psf_log_printf (psf, " Extra headers : %d\n", spx->header.extra_headers) ; - - return st ; -} /* spx_header_read */ - - -static void -spx_print_comments (const char *c, int length) -{ - const char *end ; - int len, i, nb_fields ; - -printf ("%s %d\n", __func__, __LINE__) ; - if (length < 8) - { fprintf (stderr, "Invalid/corrupted comments\n") ; - return ; - } - end = c + length ; - len = readint (c, 0) ; - c += 4 ; - if (len < 0 || c + len > end) - { fprintf (stderr, "Invalid/corrupted comments\n") ; - return ; - } - (void) fwrite (c, 1, len, stderr) ; - c += len ; - fprintf (stderr, "\n") ; - if (c + 4 > end) - { fprintf (stderr, "Invalid/corrupted comments\n") ; - return ; - } - nb_fields = readint (c, 0) ; - c += 4 ; - for (i = 0 ; i < nb_fields ; i++) - { if (c + 4 > end) - { fprintf (stderr, "Invalid/corrupted comments\n") ; - return ; - } ; - len = readint (c, 0) ; - c += 4 ; - if (len < 0 || c + len > end) - { fprintf (stderr, "Invalid/corrupted comments\n") ; - return ; - } - (void) fwrite (c, 1, len, stderr) ; - c += len ; - fprintf (stderr, "\n") ; - } ; - return ; -} /* spx_print_comments */ - - -/* -encoded_speex_frames = (frames_per_packet * Packets) - = 1 * 272 - = 272 - -audio_samples = encoded_speex_frames * frame_size - = 272 * 640 - = 174080 - -duration = audio_samples / rate - = 174080 / 44100 - = 3.947 -*/ - -#else /* ENABLE_EXPERIMENTAL_CODE && HAVE_EXTERNAL_XIPH_LIBS */ - -int -ogg_speex_open (SF_PRIVATE *psf) -{ - psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Speex support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* ogg_speex_open */ - -#endif diff --git a/Engine/lib/libsndfile/src/ogg_vcomment.c b/Engine/lib/libsndfile/src/ogg_vcomment.c deleted file mode 100644 index 252ed61d0..000000000 --- a/Engine/lib/libsndfile/src/ogg_vcomment.c +++ /dev/null @@ -1,277 +0,0 @@ -/* -** Copyright (C) 2008-2019 Erik de Castro Lopo -** Copyright (C) 2018 Arthur Taylor -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if HAVE_EXTERNAL_XIPH_LIBS - -#include - -#include "ogg_vcomment.h" - -typedef struct -{ int id ; - const char *name ; -} STR_PAIR ; - -/* See https://xiph.org/vorbis/doc/v-comment.html */ -static STR_PAIR vorbiscomment_mapping [] = -{ { SF_STR_TITLE, "TITLE" }, - { SF_STR_COPYRIGHT, "COPYRIGHT", }, - { SF_STR_SOFTWARE, "ENCODER", }, - { SF_STR_ARTIST, "ARTIST" }, - { SF_STR_COMMENT, "COMMENT" }, - { SF_STR_DATE, "DATE", }, - { SF_STR_ALBUM, "ALBUM" }, - { SF_STR_LICENSE, "LICENSE", }, - { SF_STR_TRACKNUMBER, "TRACKNUMBER", }, - { SF_STR_GENRE, "GENRE", }, - { 0, NULL, }, -} ; - -/*----------------------------------------------------------------------------------------------- -** Private function prototypes. -*/ - -static int vorbiscomment_lookup_id (const char *name) ; -static const char * vorbiscomment_lookup_name (int id) ; - -static inline size_t read_32bit_size_t (const unsigned char * ptr) -{ /* Read a 32 bit positive value from the provided pointer. */ - return LE2H_32_PTR (ptr) & 0x7fffffff ; -} /* read_32bit_size_t */ - -/*----------------------------------------------------------------------------------------------- -** Exported functions. -*/ - -int -vorbiscomment_read_tags (SF_PRIVATE *psf, ogg_packet *packet, vorbiscomment_ident *ident) -{ unsigned char *p, *ep ; - char *tag, *c ; - size_t tag_size, tag_len = 0 ; - unsigned int ntags, i = 0 ; - int id, ret = 0 ; - - /* - ** The smallest possible header is the ident string length plus two 4-byte - ** integers, (vender string length, tags count.) - */ - if (packet->bytes < (ident ? ident->length : 0) + 4 + 4) - return SFE_MALFORMED_FILE ; - - /* Our working pointer. */ - p = packet->packet ; - /* Our end pointer for bound checking. */ - ep = p + packet->bytes ; - - if (ident) - { if (memcmp (p, ident->ident, ident->length) != 0) - { psf_log_printf (psf, "Expected comment packet identifier missing.\n") ; - return SFE_MALFORMED_FILE ; - } ; - p += ident->length ; - } ; - - tag_size = 1024 ; - tag = malloc (tag_size) ; - /* Unlikely */ - if (!tag) - return SFE_MALLOC_FAILED ; - - psf_log_printf (psf, "VorbisComment Metadata\n") ; - - /* - ** Vendor tag, manditory, no field name. - */ - tag_len = read_32bit_size_t (p) ; - p += 4 ; - if (tag_len > 0) - { /* Bound checking. 4 bytes for remaining manditory fields. */ - if (p + tag_len + 4 > ep) - { ret = SFE_MALFORMED_FILE ; - goto free_tag_out ; - } ; - if (tag_len > tag_size - 1) - { free (tag) ; - tag_size = tag_len + 1 ; - tag = malloc (tag_size) ; - /* Unlikely */ - if (!tag) - return SFE_MALLOC_FAILED ; - } ; - memcpy (tag, p, tag_len) ; p += tag_len ; - tag [tag_len] = '\0' ; - psf_log_printf (psf, " Vendor: %s\n", tag) ; - } ; - - /* - ** List of tags of the form NAME=value - ** Allowable characters for NAME are the same as shell variable names. - */ - ntags = read_32bit_size_t (p) ; - p += 4 ; - for (i = 0 ; i < ntags ; i++) - { if (p + 4 > ep) - { ret = SFE_MALFORMED_FILE ; - goto free_tag_out ; - } ; - tag_len = read_32bit_size_t (p) ; - p += 4 ; - if (p + tag_len > ep) - { ret = SFE_MALFORMED_FILE ; - goto free_tag_out ; - } ; - if (tag_len > tag_size - 1) - { free (tag) ; - tag_size = tag_len + 1 ; - tag = malloc (tag_size) ; - /* Unlikely */ - if (!tag) - return SFE_MALLOC_FAILED ; - } ; - memcpy (tag, p, tag_len) ; p += tag_len ; - tag [tag_len] = '\0' ; - psf_log_printf (psf, " %s\n", tag) ; - for (c = tag ; *c ; c++) - { if (*c == '=') - break ; - *c = toupper (*c) ; - } ; - if (!c) - { psf_log_printf (psf, "Malformed Vorbis comment, no '=' found.\n") ; - continue ; - } ; - *c = '\0' ; - if ((id = vorbiscomment_lookup_id (tag)) != 0) - psf_store_string (psf, id, c + 1) ; - } ; - -free_tag_out: - if (tag != NULL) - free (tag) ; - return ret ; -} /* vorbiscomment_read_tags */ - -int -vorbiscomment_write_tags (SF_PRIVATE *psf, ogg_packet *packet, vorbiscomment_ident *ident, const char *vendor, int targetsize) -{ int i, ntags ; - int tags_start ; - const char *tag_name ; - int tag_name_len, tag_body_len ; - - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - /* Packet identifier */ - if (ident) - psf_binheader_writef (psf, "eb", BHWv (ident->ident), BHWz (ident->length)) ; - - /* Manditory Vendor Tag */ - tag_name_len = vendor ? strlen (vendor) : 0 ; - psf_binheader_writef (psf, "e4b", BHW4 (tag_name_len), BHWv (vendor), BHWz (tag_name_len)) ; - - /* Tags Count. Skip for now, write after. */ - tags_start = psf->header.indx ; - psf_binheader_writef (psf, "j", BHWj (4)) ; - - ntags = 0 ; - /* Write each tag */ - for (i = 0 ; i < SF_MAX_STRINGS ; i++) - { if (psf->strings.data [i].type == 0) - continue ; - - tag_name = vorbiscomment_lookup_name (psf->strings.data [i].type) ; - if (tag_name == NULL) - continue ; - - tag_name_len = strlen (tag_name) ; - tag_body_len = strlen (psf->strings.storage + psf->strings.data [i].offset) ; - if (targetsize > 0 && tag_name_len + tag_body_len + psf->header.indx > targetsize) - { /* If we are out of space, stop now. */ - return SFE_STR_MAX_DATA ; - } - psf_binheader_writef (psf, "e4b1b", - BHW4 (tag_name_len + 1 + tag_body_len), - BHWv (tag_name), BHWz (tag_name_len), - BHW1 ('='), - BHWv (psf->strings.storage + psf->strings.data [i].offset), BHWz (tag_body_len)) ; - ntags++ ; - } ; - - if (targetsize < 0) - { /* - ** Padding. - ** - ** Pad to a minimum of -targetsize, but make sure length % 255 - ** = 254 so that we get the most out of the ogg segment lacing. - */ - psf_binheader_writef (psf, "z", BHWz ((psf->header.indx + -targetsize + 255) / 255 * 255 - 1)) ; - } - else if (targetsize > 0) - psf_binheader_writef (psf, "z", BHWz (targetsize - psf->header.indx)) ; - - packet->packet = psf->header.ptr ; - packet->bytes = psf->header.indx ; - packet->b_o_s = 0 ; - packet->e_o_s = 0 ; - - /* Seek back and write the tag count. */ - psf_binheader_writef (psf, "eo4", BHWo (tags_start), BHW4 (ntags)) ; - - return 0 ; -} /* vorbiscomment_write_tags */ - -/*============================================================================== -** Private functions. -*/ - -static int -vorbiscomment_lookup_id (const char * name) -{ STR_PAIR *p ; - - for (p = vorbiscomment_mapping ; p->id ; p++) - { if (!strcmp (name, p->name)) - return p->id ; - } ; - - return 0 ; -} /* vorbiscomment_lookup_id */ - -static const char * -vorbiscomment_lookup_name (int id) -{ STR_PAIR *p ; - - for (p = vorbiscomment_mapping ; p->id ; p++) - { if (p->id == id) - return p->name ; - } ; - - return NULL ; -} /* vorbiscomment_lookup_name */ - -#endif /* HAVE_EXTERNAL_XIPH_LIBS */ diff --git a/Engine/lib/libsndfile/src/ogg_vcomment.h b/Engine/lib/libsndfile/src/ogg_vcomment.h deleted file mode 100644 index c25d900f6..000000000 --- a/Engine/lib/libsndfile/src/ogg_vcomment.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -** Copyright (C) 2008-2018 Erik de Castro Lopo -** Copyright (C) 2018 Arthur Taylor -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SF_SRC_OGG_VCOMMENT_H -#define SF_SRC_OGG_VCOMMENT_H - -/* -** Voriscomment identifier. Some Ogg stream embedding schemes require it. -*/ -typedef struct -{ const char *ident ; - int length ; -} vorbiscomment_ident ; - -/* -** Read all vorbiscomment tags from *packet. Tags which match ones used -** by libsndfile strings are loaded into *psf. Ogg streams which require an -** identifier for the tags packet should pass it in *ident. -*/ -int vorbiscomment_read_tags (SF_PRIVATE *psf, ogg_packet *packet, vorbiscomment_ident *ident) ; - -/* -** Write metadata strings stored in *psf to *packet. The packet is optionally -** prefixed with *ident. The always-present vendor field should be the library -** used for encoding the audio data. -*/ -int vorbiscomment_write_tags (SF_PRIVATE *psf, ogg_packet *packet, vorbiscomment_ident *ident, const char *vendor, int targetsize) ; - -#endif /* SF_SRC_OGG_VCOMMENT_H */ diff --git a/Engine/lib/libsndfile/src/ogg_vorbis.c b/Engine/lib/libsndfile/src/ogg_vorbis.c deleted file mode 100644 index f9428ed1f..000000000 --- a/Engine/lib/libsndfile/src/ogg_vorbis.c +++ /dev/null @@ -1,1057 +0,0 @@ -/* -** Copyright (C) 2018-2021 Arthur Taylor -** Copyright (C) 2002-2016 Erik de Castro Lopo -** Copyright (C) 2002-2005 Michael Smith -** Copyright (C) 2007 John ffitch -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation ; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** Much of this code is based on the examples in libvorbis from the -** XIPHOPHORUS Company http://www.xiph.org/ which has a BSD-style Licence -** Copyright (c) 2002, Xiph.org Foundation -** -** 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 the Xiph.org Foundation nor the names of its -** 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 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. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if HAVE_EXTERNAL_XIPH_LIBS - -#include -#include -#include - -#include "ogg.h" - -/* How many seconds in the future to not bother bisection searching for. */ -#define VORBIS_SEEK_THRESHOLD 2 - -typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ; - -static int vorbis_read_header (SF_PRIVATE *psf) ; -static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ; -static int vorbis_close (SF_PRIVATE *psf) ; -static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; -static int vorbis_byterate (SF_PRIVATE *psf) ; -static int vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out) ; -static int vorbis_skip (SF_PRIVATE *psf, uint64_t target_gp) ; -static int vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) ; -static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; -static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; -static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ; -static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ; - -typedef struct -{ int id ; - const char *name ; -} STR_PAIRS ; - - -/* See https://xiph.org/vorbis/doc/v-comment.html */ -static STR_PAIRS vorbis_metatypes [] = -{ { SF_STR_TITLE, "Title" }, - { SF_STR_COPYRIGHT, "Copyright" }, - { SF_STR_SOFTWARE, "Software" }, - { SF_STR_ARTIST, "Artist" }, - { SF_STR_COMMENT, "Comment" }, - { SF_STR_DATE, "Date" }, - { SF_STR_ALBUM, "Album" }, - { SF_STR_LICENSE, "License" }, - { SF_STR_TRACKNUMBER, "Tracknumber" }, - { SF_STR_GENRE, "Genre" }, -} ; - -typedef struct -{ /* Current granule position. */ - uint64_t gp ; - /* Struct that stores all the static vorbis bitstream settings */ - vorbis_info vinfo ; - /* Struct that stores all the bitstream user comments */ - vorbis_comment vcomment ; - /* Central working state for the packet->PCM decoder */ - vorbis_dsp_state vdsp ; - /* Local working space for packet->PCM decode */ - vorbis_block vblock ; - /* Encoding quality in range [0.0, 1.0]. */ - double quality ; - /* Offset of the first samples' granule position. */ - uint64_t pcm_start ; - /* Last valid samples' granule position. */ - uint64_t pcm_end ; - /* File offset of the start of the last page. */ - sf_count_t last_page ; -} VORBIS_PRIVATE ; - -static int -vorbis_read_header (SF_PRIVATE *psf) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int printed_metadata_msg = 0 ; - int i, nn ; - sf_count_t last_page ; - sf_count_t saved_offset ; - - /* - ** The first page of the Ogg stream we are told to try and open as Vorbis - ** has already been loaded into odata->ostream by ogg_open(). - ** - ** Extract the initial header from the first page and verify that the - ** Ogg bitstream is in fact Vorbis data. - */ - - vorbis_info_init (&vdata->vinfo) ; - vorbis_comment_init (&vdata->vcomment) ; - - if (!odata->opacket.b_o_s) - { psf_log_printf (psf, "Vorbis: First packet does not have a beginning-of-stream bit.\n") ; - return SFE_MALFORMED_FILE ; - } - - if (ogg_stream_packetpeek (&odata->ostream, NULL)) - { psf_log_printf (psf, "Vorbis: First page contains extraneous packets!\n") ; - return SFE_MALFORMED_FILE ; - } - - if (vorbis_synthesis_headerin (&vdata->vinfo, &vdata->vcomment, &odata->opacket) < 0) - { /* Error case ; not a vorbis header. */ - psf_log_printf (psf, "Found Vorbis in stream header, but vorbis_synthesis_headerin failed.\n") ; - return SFE_MALFORMED_FILE ; - } ; - - /* - ** At this point, we're sure we're Vorbis. We've set up the logical (Ogg) - ** bitstream decoder. Get the comment and codebook headers and set up the - ** Vorbis decoder. - ** - ** The next two packets in order are the comment and codebook headers. - ** They're likely large and may span multiple pages. Thus we read - ** and submit data until we get our two packets, watching that no - ** pages are missing. If a page is missing, error out ; losing a - ** header page is the only place where missing data is fatal. - */ - - i = 0 ; /* Count of number of packets read */ - while (i < 2) - { nn = ogg_stream_packetout (&odata->ostream, &odata->opacket) ; - - if (nn == 0) - { nn = ogg_stream_next_page (psf, odata) ; - if (nn == 0) - { psf_log_printf (psf, "End of file before finding all Vorbis headers!\n") ; - return SFE_MALFORMED_FILE ; - } ; - if (nn == -1) - { psf_log_printf (psf, "Error reading file while finding Vorbis headers!\n") ; - return psf->error ; - } ; - continue ; - } - - if (nn < 0) - { /* A hole while reading headers. This could be bad. */ - psf_log_printf (psf, "Corrupt secondary header. Exiting.\n") ; - return SFE_MALFORMED_FILE ; - } ; - - vorbis_synthesis_headerin (&vdata->vinfo, &vdata->vcomment, &odata->opacket) ; - i++ ; - } ; - - /* Check for extraneous packets in the last headers page. */ - while (ogg_stream_packetout (&odata->ostream, &odata->opacket) == 1) - { i++ ; - } - if (i > 2) - psf_log_printf (psf, "Vorbis: stream has extraneous header packets.\n") ; - - psf_log_printf (psf, "Bitstream is %d channel, %D Hz\n", vdata->vinfo.channels, vdata->vinfo.rate) ; - psf_log_printf (psf, "Encoded by : %s\n", vdata->vcomment.vendor) ; - - /* Save the offset of the first payload page */ - psf->dataoffset = ogg_sync_ftell (psf) ; - - /* - ** Calculate the granule position offset. The first page with a payload - ** packet shouldn't end in a continued packet. The difference between the - ** page's granule position and the sum of frames on the page tells us the - ** granule position offset. - ** See https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-132000A.2 - */ - ogg_stream_unpack_page (psf, odata) ; - vorbis_calculate_granulepos (psf, &vdata->pcm_start) ; - vdata->gp = vdata->pcm_start ; - - /* - ** Find the end of the stream, save it. Only works if the file is seekable. - */ - vdata->pcm_end = (uint64_t) -1 ; - psf->datalength = psf->filelength ; - if (!psf->is_pipe) - { saved_offset = ogg_sync_ftell (psf) ; - last_page = ogg_sync_last_page_before (psf, odata, &vdata->pcm_end, psf->filelength, odata->ostream.serialno) ; - if (last_page > 0) - { if (!ogg_page_eos (&odata->opage)) - psf_log_printf (psf, "Ogg: Last page lacks an end-of-stream bit.\n") ; - psf->datalength = last_page + odata->opage.header_len + odata->opage.body_len - psf->dataoffset ; - if (psf->datalength + psf->dataoffset < psf->filelength) - psf_log_printf (psf, "Ogg: Junk after the last page.\n") ; - vdata->last_page = last_page ; - } ; - - ogg_sync_fseek (psf, saved_offset, SEEK_SET) ; - } - - psf_log_printf (psf, "PCM offset : %D\n", vdata->pcm_start) ; - if (vdata->pcm_end != (uint64_t) -1) - psf_log_printf (psf, "PCM end : %D\n", vdata->pcm_end) ; - else - psf_log_printf (psf, "PCM end : unknown\n") ; - - /* Throw the comments plus a few lines about the bitstream we're decoding. */ - for (i = 0 ; i < ARRAY_LEN (vorbis_metatypes) ; i++) - { char *dd ; - - dd = vorbis_comment_query (&vdata->vcomment, vorbis_metatypes [i].name, 0) ; - if (dd == NULL) - continue ; - - if (printed_metadata_msg == 0) - { psf_log_printf (psf, "Metadata :\n") ; - printed_metadata_msg = 1 ; - } ; - - psf_store_string (psf, vorbis_metatypes [i].id, dd) ; - psf_log_printf (psf, " %-10s : %s\n", vorbis_metatypes [i].name, dd) ; - } ; - psf_log_printf (psf, "End\n") ; - - psf->sf.samplerate = vdata->vinfo.rate ; - psf->sf.channels = vdata->vinfo.channels ; - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - psf->sf.frames = (vdata->pcm_end != (uint64_t) -1) ? vdata->pcm_end - vdata->pcm_start : SF_COUNT_MAX ; - - /* OK, got and parsed all three headers. Initialize the Vorbis - ** packet->PCM decoder. - ** Central decode state. */ - vorbis_synthesis_init (&vdata->vdsp, &vdata->vinfo) ; - - /* Local state for most of the decode so multiple block decodes can - ** proceed in parallel. We could init multiple vorbis_block structures - ** for vdsp here. */ - vorbis_block_init (&vdata->vdsp, &vdata->vblock) ; - - return 0 ; -} /* vorbis_read_header */ - -static int -vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int k, ret ; - - vorbis_info_init (&vdata->vinfo) ; - - /* The style of encoding should be selectable here, VBR quality mode. */ - ret = vorbis_encode_init_vbr (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, vdata->quality) ; - -#if 0 - ret = vorbis_encode_init (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, -1, 128000, -1) ; /* average bitrate mode */ - ret = ( vorbis_encode_setup_managed (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, -1, 128000, -1) - || vorbis_encode_ctl (&vdata->vinfo, OV_ECTL_RATEMANAGE_AVG, NULL) - || vorbis_encode_setup_init (&vdata->vinfo) - ) ; -#endif - if (ret) - return SFE_BAD_OPEN_FORMAT ; - - vdata->gp = 0 ; - - /* add a comment */ - vorbis_comment_init (&vdata->vcomment) ; - - vorbis_comment_add_tag (&vdata->vcomment, "ENCODER", "libsndfile") ; - for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { const char * name ; - - if (psf->strings.data [k].type == 0) - break ; - - switch (psf->strings.data [k].type) - { case SF_STR_TITLE : name = "TITLE" ; break ; - case SF_STR_COPYRIGHT : name = "COPYRIGHT" ; break ; - case SF_STR_SOFTWARE : name = "SOFTWARE" ; break ; - case SF_STR_ARTIST : name = "ARTIST" ; break ; - case SF_STR_COMMENT : name = "COMMENT" ; break ; - case SF_STR_DATE : name = "DATE" ; break ; - case SF_STR_ALBUM : name = "ALBUM" ; break ; - case SF_STR_LICENSE : name = "LICENSE" ; break ; - case SF_STR_TRACKNUMBER : name = "Tracknumber" ; break ; - case SF_STR_GENRE : name = "Genre" ; break ; - - default : continue ; - } ; - - vorbis_comment_add_tag (&vdata->vcomment, name, psf->strings.storage + psf->strings.data [k].offset) ; - } ; - - /* set up the analysis state and auxiliary encoding storage */ - vorbis_analysis_init (&vdata->vdsp, &vdata->vinfo) ; - vorbis_block_init (&vdata->vdsp, &vdata->vblock) ; - - /* - ** Set up our packet->stream encoder. - ** Pick a random serial number ; that way we can more likely build - ** chained streams just by concatenation. - */ - - ogg_stream_init (&odata->ostream, psf_rand_int32 ()) ; - - /* Vorbis streams begin with three headers ; the initial header (with - most of the codec setup parameters) which is mandated by the Ogg - bitstream spec. The second header holds any comment fields. The - third header holds the bitstream codebook. We merely need to - make the headers, then pass them to libvorbis one at a time ; - libvorbis handles the additional Ogg bitstream constraints */ - - { ogg_packet header ; - ogg_packet header_comm ; - ogg_packet header_code ; - int result ; - - vorbis_analysis_headerout (&vdata->vdsp, &vdata->vcomment, &header, &header_comm, &header_code) ; - ogg_stream_packetin (&odata->ostream, &header) ; /* automatically placed in its own page */ - ogg_stream_packetin (&odata->ostream, &header_comm) ; - ogg_stream_packetin (&odata->ostream, &header_code) ; - - /* This ensures the actual - * audio data will start on a new page, as per spec - */ - while ((result = ogg_stream_flush (&odata->ostream, &odata->opage)) != 0) - { ogg_write_page (psf, &odata->opage) ; - } ; - } - - return 0 ; -} /* vorbis_write_header */ - -static int -vorbis_close (SF_PRIVATE *psf) -{ OGG_PRIVATE* odata = psf->container_data ; - VORBIS_PRIVATE *vdata = psf->codec_data ; - - if (odata == NULL || vdata == NULL) - return 0 ; - - /* Clean up this logical bitstream ; before exit we shuld see if we're - ** followed by another [chained]. */ - - if (psf->file.mode == SFM_WRITE) - { - if (psf->write_current <= 0) - vorbis_write_header (psf, 0) ; - - vorbis_analysis_wrote (&vdata->vdsp, 0) ; - while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1) - { - - /* analysis, assume we want to use bitrate management */ - vorbis_analysis (&vdata->vblock, NULL) ; - vorbis_bitrate_addblock (&vdata->vblock) ; - - while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) - { /* weld the packet into the bitstream */ - ogg_stream_packetin (&odata->ostream, &odata->opacket) ; - - /* write out pages (if any) */ - while (!odata->eos) - { int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ; - if (result == 0) break ; - ogg_write_page (psf, &odata->opage) ; - - /* this could be set above, but for illustrative purposes, I do - it here (to show that vorbis does know where the stream ends) */ - - if (ogg_page_eos (&odata->opage)) odata->eos = 1 ; - } - } - } - } - - /* ogg_page and ogg_packet structs always point to storage in - libvorbis. They are never freed or manipulated directly */ - - vorbis_block_clear (&vdata->vblock) ; - vorbis_dsp_clear (&vdata->vdsp) ; - vorbis_comment_clear (&vdata->vcomment) ; - vorbis_info_clear (&vdata->vinfo) ; - - return 0 ; -} /* vorbis_close */ - -int -ogg_vorbis_open (SF_PRIVATE *psf) -{ OGG_PRIVATE* odata = psf->container_data ; - VORBIS_PRIVATE* vdata ; - int error = 0 ; - - if (odata == NULL) - { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ; - return SFE_INTERNAL ; - } ; - - vdata = calloc (1, sizeof (VORBIS_PRIVATE)) ; - psf->codec_data = vdata ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - psf_log_printf (psf, "Vorbis library version : %s\n", vorbis_version_string ()) ; - - if (psf->file.mode == SFM_READ) - { if ((error = vorbis_read_header (psf))) - return error ; - - psf->read_short = vorbis_read_s ; - psf->read_int = vorbis_read_i ; - psf->read_float = vorbis_read_f ; - psf->read_double = vorbis_read_d ; - } ; - - psf->codec_close = vorbis_close ; - if (psf->file.mode == SFM_WRITE) - { - /* Set the default vorbis quality here. */ - vdata->quality = 0.4 ; - - psf->write_header = vorbis_write_header ; - psf->write_short = vorbis_write_s ; - psf->write_int = vorbis_write_i ; - psf->write_float = vorbis_write_f ; - psf->write_double = vorbis_write_d ; - - psf->sf.frames = 0 ; - psf->datalength = 0 ; - psf->filelength = 0 ; - psf->dataoffset = 0 ; - psf->strings.flags = SF_STR_ALLOW_START ; - } ; - - psf->seek = vorbis_seek ; - psf->command = vorbis_command ; - psf->byterate = vorbis_byterate ; - psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - psf->sf.sections = 1 ; - - return error ; -} /* ogg_vorbis_open */ - -static int -vorbis_command (SF_PRIVATE *psf, int command, void * data, int datasize) -{ OGG_PRIVATE* odata = psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - - switch (command) - { case SFC_SET_COMPRESSION_LEVEL : - if (data == NULL || datasize != sizeof (double)) - return SF_FALSE ; - - if (psf->have_written) - return SF_FALSE ; - - vdata->quality = 1.0 - *((double *) data) ; - - /* Clip range. */ - vdata->quality = SF_MAX (0.0, SF_MIN (1.0, vdata->quality)) ; - - psf_log_printf (psf, "%s : Setting SFC_SET_VBR_ENCODING_QUALITY to %f.\n", __func__, vdata->quality) ; - return SF_TRUE ; - - case SFC_GET_OGG_STREAM_SERIALNO : - if (data == NULL || datasize != sizeof (int32_t)) - return SF_FALSE ; - - *((int32_t *) data) = odata->ostream.serialno ; - return SF_TRUE ; - - default : - return SF_FALSE ; - } ; - - return SF_FALSE ; -} /* vorbis_command */ - -static int -vorbis_rnull (SF_PRIVATE *UNUSED (psf), int samples, void *UNUSED (vptr), int UNUSED (off) , int channels, float **UNUSED (pcm)) -{ - return samples * channels ; -} /* vorbis_rnull */ - -static int -vorbis_rshort (SF_PRIVATE *psf, int samples, void *vptr, int off, int channels, float **pcm) -{ - short *ptr = (short*) vptr + off ; - int i = 0, j, n ; - if (psf->float_int_mult) - { - float inverse = 1.0 / psf->float_max ; - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = psf_lrintf ((pcm [n][j] * inverse) * 32767.0f) ; - } - else - { - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = psf_lrintf (pcm [n][j] * 32767.0f) ; - } - return i ; -} /* vorbis_rshort */ - -static int -vorbis_rint (SF_PRIVATE *psf, int samples, void *vptr, int off, int channels, float **pcm) -{ - int *ptr = (int*) vptr + off ; - int i = 0, j, n ; - - if (psf->float_int_mult) - { - float inverse = 1.0 / psf->float_max ; - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = psf_lrintf ((pcm [n][j] * inverse) * 2147483647.0f) ; - } - else - { - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = psf_lrintf (pcm [n][j] * 2147483647.0f) ; - } - return i ; -} /* vorbis_rint */ - -static int -vorbis_rfloat (SF_PRIVATE *UNUSED (psf), int samples, void *vptr, int off, int channels, float **pcm) -{ - float *ptr = (float*) vptr + off ; - int i = 0, j, n ; - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = pcm [n][j] ; - return i ; -} /* vorbis_rfloat */ - -static int -vorbis_rdouble (SF_PRIVATE *UNUSED (psf), int samples, void *vptr, int off, int channels, float **pcm) -{ - double *ptr = (double*) vptr + off ; - int i = 0, j, n ; - for (j = 0 ; j < samples ; j++) - for (n = 0 ; n < channels ; n++) - ptr [i++] = pcm [n][j] ; - return i ; -} /* vorbis_rdouble */ - - -static sf_count_t -vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) -{ VORBIS_PRIVATE *vdata = psf->codec_data ; - OGG_PRIVATE *odata = psf->container_data ; - int len, samples, i = 0 , nn ; - float **pcm ; - - len = lens / psf->sf.channels ; - - while (len > 0) - { /* - ** pcm is a multichannel float vector. In stereo, for - ** example, pcm [0] is left, and pcm [1] is right. samples is - ** the size of each channel. Convert the float values - ** (-1.<=range<=1.) to whatever PCM format and write it out. - */ - while ((samples = vorbis_synthesis_pcmout (&vdata->vdsp, &pcm)) > 0) - { if (samples > len) samples = len ; - i += transfn (psf, samples, ptr, i, psf->sf.channels, pcm) ; - len -= samples ; - /* tell libvorbis how many samples we actually consumed */ - vorbis_synthesis_read (&vdata->vdsp, samples) ; - vdata->gp += samples ; - if (len == 0) - return i ; - } ; - - /* Out of samples, load the next packet. */ - if (odata->pkt_indx == odata->pkt_len) - { /* Page out of packets, load and unpack the next page. */ - nn = ogg_stream_unpack_page (psf, odata) ; - if (nn <= 0) - return i ; - if (nn == 2) - { /* Ran over a hole. gp is now out of date, need to recalculate. */ - vorbis_synthesis_restart (&vdata->vdsp) ; - vorbis_calculate_granulepos (psf, &vdata->gp) ; - } - } ; - - /* Decode the packet */ - if (vorbis_synthesis (&vdata->vblock, &(odata->pkt [odata->pkt_indx])) == 0) /* test for success! */ - vorbis_synthesis_blockin (&vdata->vdsp, &vdata->vblock) ; - odata->pkt_indx++ ; - } ; - - return i ; -} /* vorbis_read_sample */ - -static sf_count_t -vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t lens) -{ return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rshort) ; -} /* vorbis_read_s */ - -static sf_count_t -vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t lens) -{ return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rint) ; -} /* vorbis_read_i */ - -static sf_count_t -vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t lens) -{ return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rfloat) ; -} /* vorbis_read_f */ - -static sf_count_t -vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens) -{ return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rdouble) ; -} /* vorbis_read_d */ - -/*============================================================================== -*/ - -static void -vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames) -{ - vorbis_analysis_wrote (&vdata->vdsp, in_frames) ; - - /* - ** Vorbis does some data preanalysis, then divvies up blocks for - ** more involved (potentially parallel) processing. Get a single - ** block for encoding now. - */ - while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1) - { - /* analysis, assume we want to use bitrate management */ - vorbis_analysis (&vdata->vblock, NULL) ; - vorbis_bitrate_addblock (&vdata->vblock) ; - - while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) - { - /* weld the packet into the bitstream */ - ogg_stream_packetin (&odata->ostream, &odata->opacket) ; - - /* write out pages (if any) */ - while (!odata->eos) - { int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ; - if (result == 0) - break ; - ogg_write_page (psf, &odata->opage) ; - - /* This could be set above, but for illustrative purposes, I do - ** it here (to show that vorbis does know where the stream ends) */ - if (ogg_page_eos (&odata->opage)) - odata->eos = 1 ; - } ; - } ; - } ; - - vdata->gp += in_frames ; -} /* vorbis_write_data */ - - -static sf_count_t -vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens) -{ - int i, m, j = 0 ; - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int in_frames = lens / psf->sf.channels ; - float **buffer = vorbis_analysis_buffer (&vdata->vdsp, in_frames) ; - for (i = 0 ; i < in_frames ; i++) - for (m = 0 ; m < psf->sf.channels ; m++) - buffer [m][i] = (float) (ptr [j++]) / 32767.0f ; - - vorbis_write_samples (psf, odata, vdata, in_frames) ; - - return lens ; -} /* vorbis_write_s */ - -static sf_count_t -vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens) -{ int i, m, j = 0 ; - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int in_frames = lens / psf->sf.channels ; - float **buffer = vorbis_analysis_buffer (&vdata->vdsp, in_frames) ; - for (i = 0 ; i < in_frames ; i++) - for (m = 0 ; m < psf->sf.channels ; m++) - buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ; - - vorbis_write_samples (psf, odata, vdata, in_frames) ; - - return lens ; -} /* vorbis_write_i */ - -static sf_count_t -vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens) -{ int i, m, j = 0 ; - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int in_frames = lens / psf->sf.channels ; - float **buffer = vorbis_analysis_buffer (&vdata->vdsp, in_frames) ; - for (i = 0 ; i < in_frames ; i++) - for (m = 0 ; m < psf->sf.channels ; m++) - buffer [m][i] = ptr [j++] ; - - vorbis_write_samples (psf, odata, vdata, in_frames) ; - - return lens ; -} /* vorbis_write_f */ - -static sf_count_t -vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens) -{ int i, m, j = 0 ; - OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - int in_frames = lens / psf->sf.channels ; - float **buffer = vorbis_analysis_buffer (&vdata->vdsp, in_frames) ; - for (i = 0 ; i < in_frames ; i++) - for (m = 0 ; m < psf->sf.channels ; m++) - buffer [m][i] = (float) ptr [j++] ; - - vorbis_write_samples (psf, odata, vdata, in_frames) ; - - return lens ; -} /* vorbis_write_d */ - -static int -vorbis_skip (SF_PRIVATE *psf, uint64_t target) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - ogg_packet *pkt ; - int thisblock, lastblock, nn ; - const int blocksize = vorbis_info_blocksize (&vdata->vinfo, 1) ; - - /* Read out any samples that may be in the decoder from a seek without a - ** search. */ - thisblock = vorbis_synthesis_pcmout (&vdata->vdsp, NULL) ; - if (thisblock > 0) - { if ((uint64_t) thisblock + vdata->gp >= target) - thisblock = SF_MIN (thisblock, (int) (target - vdata->gp)) ; - - vorbis_synthesis_read (&vdata->vdsp, thisblock) ; - vdata->gp += thisblock ; - if (vdata->gp == target) - return 0 ; - } ; - - /* Read through packets that are before our target */ - lastblock = 0 ; - for ( ; vdata->gp < target ; ) - { /* Ensure there are unpacked packets. */ - if (odata->pkt_indx == odata->pkt_len) - { /* Page out of packets, load and unpack the next page. */ - nn = ogg_stream_unpack_page (psf, odata) ; - if (nn < 0) - return nn ; - if (nn == 0) - break ; - if (nn == 2) - { /* Ran over a hole. gp is now out of date, need to recalculate. */ - vorbis_synthesis_restart (&vdata->vdsp) ; - vorbis_calculate_granulepos (psf, &vdata->gp) ; - if (target < vdata->gp) - { /* Our target is inside the hole :-( */ - return 0 ; - } ; - } ; - } ; - - pkt = &odata->pkt [odata->pkt_indx] ; - thisblock = vorbis_packet_blocksize (&vdata->vinfo, pkt) ; - if (thisblock < 0) - { /* Not an audio packet */ - odata->pkt_indx++ ; - continue ; - } ; - - if (lastblock) - { vdata->gp += ((lastblock + thisblock) / 4) ; - } ; - - /* Check to see if the block contains our target */ - if (vdata->gp + ((thisblock + blocksize) / 4) >= target) - break ; - - /* Block is before the target. Track for state, but don't decode. */ - odata->pkt_indx++ ; - vorbis_synthesis_trackonly (&vdata->vblock, pkt) ; - vorbis_synthesis_blockin (&vdata->vdsp, &vdata->vblock) ; - lastblock = thisblock ; - } ; - - /* We are at the correct block, but still need to consume samples to reach - ** our target. */ - vorbis_read_sample (psf, (void *) NULL, (target - vdata->gp) * psf->sf.channels, vorbis_rnull) ; - - return 0 ; -} /* vorbis_skip */ - -static int -vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - uint64_t best_gp, search_target_gp ; - int ret ; - - /* Can't bisect a file we don't know the end of (cannot seek). */ - if (vdata->pcm_end == (uint64_t) -1) - return 0 ; - - /* If the target is for the near future, don't bother bisecting, just skip - ** to it. */ - if (target_gp >= vdata->gp && - target_gp - vdata->gp < ((unsigned) (VORBIS_SEEK_THRESHOLD) * psf->sf.samplerate)) - return 0 ; - - /* Search for a position a half large-block before our target. As Vorbis is - ** lapped, every sample position come from two blocks, the "left" half of - ** one block and the "right" half of the previous block. The granule - ** position of an Ogg page of a Vorbis stream is the sample offset of the - ** last finished sample in the stream that can be decoded from a page. A - ** page also contains another half-block of samples waiting to be lapped - ** with the first half-block of samples from the next page. - ** - ** Searching for a sample one half of a large block before our target - ** guarantees we always load a page containing the previous half block - ** required to decode the target. Downside is we can't use best_gp - ** parameter of the page seek function. */ - search_target_gp = vorbis_info_blocksize (&vdata->vinfo, 1) / 2 ; - search_target_gp = search_target_gp < target_gp ? target_gp - search_target_gp : 0 ; - - ret = ogg_stream_seek_page_search (psf, odata, search_target_gp, vdata->pcm_start, - vdata->pcm_end, &best_gp, psf->dataoffset, vdata->last_page, vdata->vinfo.rate) ; - if (ret < 0) - return ret ; - - ret = ogg_stream_unpack_page (psf, odata) ; - if (ret > 0) - { /* Reset the decoder, recalculate position */ - vorbis_synthesis_restart (&vdata->vdsp) ; - ret = vorbis_calculate_granulepos (psf, &vdata->gp) ; - } ; - - return ret ; -} /* vorbis_seek_trysearch */ - -static sf_count_t -vorbis_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - uint64_t target_gp ; - int ret ; - - if (odata == NULL || vdata == NULL) - return 0 ; - - if (offset < 0) - { psf->error = SFE_BAD_SEEK ; - return ((sf_count_t) -1) ; - } ; - - if (psf->file.mode == SFM_READ) - { target_gp = (uint64_t) offset + vdata->pcm_start ; - - ret = vorbis_seek_trysearch (psf, target_gp) ; - - if (ret < 0 || vdata->gp > target_gp) - { /* Search failed (bad data?), reset to the beginning of the stream. */ - psf_log_printf (psf, "Vorbis: Seek search failed. Reading through stream from start.\n") ; - ogg_stream_reset_serialno (&odata->ostream, odata->ostream.serialno) ; - odata->pkt_len = 0 ; - odata->pkt_indx = 0 ; - ogg_sync_fseek (psf, psf->dataoffset, SEEK_SET) ; - vdata->gp = vdata->pcm_start ; - vorbis_synthesis_restart (&vdata->vdsp) ; - } ; - - vorbis_skip (psf, target_gp) ; - - return vdata->gp - vdata->pcm_start ; - } ; - - psf->error = SFE_BAD_SEEK ; - return ((sf_count_t) -1) ; -} /* vorbis_seek */ - -static int -vorbis_byterate (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_READ) - return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; - - return -1 ; -} /* vorbis_byterate */ - -static int -vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out) -{ OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - ogg_packet *pkt ; - uint64_t last_gp ; - int thisblock, lastblock, i ; - unsigned duration ; - - /* Calculate the granule position when dropped into the middle of a stream - ** with an un-primed decoder. - ** - ** Normally the last unpacked packet contains the granule position of the - ** last completed sample from decoding all the blocks in the page's - ** packets. By calculating how many samples we can decode from the blocks - ** in the page's packets and subtracting it from the final packet's granule - ** position we get the position of the first sample to be output from the - ** decoder after it primes. That is, the current granule position. - ** - ** However, there is an ambiguity if this is the last page of a stream. The - ** last page of a stream may have a granule position of fewer samples than - ** the page actually contains. The excess samples are padding leftovers - ** for and exact sample length file. */ - - if (odata->pkt_len > 0) - { /* Calculate how many samples can be decoded from blocks in this page, - ** accounting for the fact that blocks are 1/2 lapped. */ - lastblock = -1 ; - duration = 0 ; - pkt = odata->pkt ; - for (i = 0 ; i < odata->pkt_len ; i++) - { thisblock = vorbis_packet_blocksize (&vdata->vinfo, &pkt [i]) ; - if (thisblock >= 0) - { if (lastblock != -1) - duration += (lastblock + thisblock) >> 2 ; - lastblock = thisblock ; - } ; - } ; - - pkt = &odata->pkt [odata->pkt_len - 1] ; - last_gp = pkt->granulepos ; - if (last_gp == (uint64_t) -1) - { psf_log_printf (psf, "Vorbis: Ogg page has no granule position, cannot calculate sample position!\n") ; - psf->error = SFE_MALFORMED_FILE ; - return -1 ; - } ; - - if (pkt->e_o_s) - { if (last_gp <= duration) - { /* Corner case: One page stream. Ogg/Vorbis spec dictates the - ** granule position offset MUST be zero, hence this first (and - ** only) page must start at 0. */ - *gp_out = 0 ; - return 1 ; - } ; - - /* Otherwise, we cannot know where we are without looking at the - ** blocks of the previous page. (The granule position of the - ** previous page is not enough, we need the block sizes.) - ** - ** We avoid this case by never allowing a bisection search to seek - ** beyond the second-to-last page, so the last page is always - ** approached with a known location and never dropped into. - ** - ** The only way we should be able to end up here is if there was a - ** hole in stream just before the last page, in which case all bets - ** are off anyways. */ - psf_log_printf (psf, "Vorbis: Cannot calculate ambiguous last page duration. Sample count may be wrong.\n") ; - } ; - - if (last_gp < duration) - { psf_log_printf (psf, "Vorbis: Granule position is nonsensical! (Missing end-of-stream marker?)\n") ; - psf->error = SFE_MALFORMED_FILE ; - return -1 ; - } ; - - *gp_out = last_gp - duration ; - return 1 ; - } ; - - return 0 ; -} /* vorbis_calculate_granulepos */ - -#else /* HAVE_EXTERNAL_XIPH_LIBS */ - -int -ogg_vorbis_open (SF_PRIVATE *psf) -{ - psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Vorbis support.\n") ; - return SFE_UNIMPLEMENTED ; -} /* ogg_vorbis_open */ - -#endif diff --git a/Engine/lib/libsndfile/src/paf.c b/Engine/lib/libsndfile/src/paf.c deleted file mode 100644 index 871931c6c..000000000 --- a/Engine/lib/libsndfile/src/paf.c +++ /dev/null @@ -1,818 +0,0 @@ -/* -** Copyright (C) 1999-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -#define FAP_MARKER (MAKE_MARKER ('f', 'a', 'p', ' ')) -#define PAF_MARKER (MAKE_MARKER (' ', 'p', 'a', 'f')) - -/*------------------------------------------------------------------------------ -** Other defines. -*/ - -#define PAF_HEADER_LENGTH 2048 - -#define PAF24_SAMPLES_PER_BLOCK 10 -#define PAF24_BLOCK_SIZE 32 - -/*------------------------------------------------------------------------------ -** Typedefs. -*/ - -typedef struct -{ int version ; - int endianness ; - int samplerate ; - int format ; - int channels ; - int source ; -} PAF_FMT ; - -typedef struct -{ int max_blocks, channels, blocksize ; - int read_block, write_block, read_count, write_count ; - sf_count_t sample_count ; - int *samples ; - int *block ; - int data [] ; /* ISO C99 struct flexible array. */ -} PAF24_PRIVATE ; - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int paf24_init (SF_PRIVATE *psf) ; - -static int paf_read_header (SF_PRIVATE *psf) ; -static int paf_write_header (SF_PRIVATE *psf, int calc_length) ; - -static sf_count_t paf24_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t paf24_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t paf24_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t paf24_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t paf24_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t paf24_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t paf24_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t paf24_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static sf_count_t paf24_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; - -enum -{ PAF_PCM_16 = 0, - PAF_PCM_24 = 1, - PAF_PCM_S8 = 2 -} ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -paf_open (SF_PRIVATE *psf) -{ int subformat, error, endian ; - - psf->dataoffset = PAF_HEADER_LENGTH ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = paf_read_header (psf))) - return error ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PAF) - return SFE_BAD_OPEN_FORMAT ; - - endian = SF_ENDIAN (psf->sf.format) ; - - /* PAF is by default big endian. */ - psf->endian = SF_ENDIAN_BIG ; - - if (endian == SF_ENDIAN_LITTLE || (CPU_IS_LITTLE_ENDIAN && (endian == SF_ENDIAN_CPU))) - psf->endian = SF_ENDIAN_LITTLE ; - - if ((error = paf_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = paf_write_header ; - } ; - - switch (subformat) - { case SF_FORMAT_PCM_S8 : - psf->bytewidth = 1 ; - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_PCM_16 : - psf->bytewidth = 2 ; - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_PCM_24 : - /* No bytewidth because of whacky 24 bit encoding. */ - error = paf24_init (psf) ; - break ; - - default : return SFE_PAF_UNKNOWN_FORMAT ; - } ; - - return error ; -} /* paf_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -paf_read_header (SF_PRIVATE *psf) -{ PAF_FMT paf_fmt ; - int marker ; - - if (psf->filelength < PAF_HEADER_LENGTH) - return SFE_PAF_SHORT_HEADER ; - - memset (&paf_fmt, 0, sizeof (paf_fmt)) ; - psf_binheader_readf (psf, "pm", 0, &marker) ; - - psf_log_printf (psf, "Signature : '%M'\n", marker) ; - - if (marker == PAF_MARKER) - { psf_binheader_readf (psf, "E444444", &(paf_fmt.version), &(paf_fmt.endianness), - &(paf_fmt.samplerate), &(paf_fmt.format), &(paf_fmt.channels), &(paf_fmt.source)) ; - } - else if (marker == FAP_MARKER) - { psf_binheader_readf (psf, "e444444", &(paf_fmt.version), &(paf_fmt.endianness), - &(paf_fmt.samplerate), &(paf_fmt.format), &(paf_fmt.channels), &(paf_fmt.source)) ; - } - else - return SFE_PAF_NO_MARKER ; - - psf_log_printf (psf, "Version : %d\n", paf_fmt.version) ; - - if (paf_fmt.version != 0) - { psf_log_printf (psf, "*** Bad version number. should be zero.\n") ; - return SFE_PAF_VERSION ; - } ; - - psf_log_printf (psf, "Sample Rate : %d\n", paf_fmt.samplerate) ; - psf_log_printf (psf, "Channels : %d\n", paf_fmt.channels) ; - - psf_log_printf (psf, "Endianness : %d => ", paf_fmt.endianness) ; - if (paf_fmt.endianness) - { psf_log_printf (psf, "Little\n", paf_fmt.endianness) ; - psf->endian = SF_ENDIAN_LITTLE ; - } - else - { psf_log_printf (psf, "Big\n", paf_fmt.endianness) ; - psf->endian = SF_ENDIAN_BIG ; - } ; - - if (paf_fmt.channels < 1 || paf_fmt.channels > SF_MAX_CHANNELS) - return SFE_PAF_BAD_CHANNELS ; - - psf->datalength = psf->filelength - psf->dataoffset ; - - psf_binheader_readf (psf, "p", (int) psf->dataoffset) ; - - psf->sf.samplerate = paf_fmt.samplerate ; - psf->sf.channels = paf_fmt.channels ; - - /* Only fill in type major. */ - psf->sf.format = SF_FORMAT_PAF ; - - psf_log_printf (psf, "Format : %d => ", paf_fmt.format) ; - - /* PAF is by default big endian. */ - psf->sf.format |= paf_fmt.endianness ? SF_ENDIAN_LITTLE : SF_ENDIAN_BIG ; - - switch (paf_fmt.format) - { case PAF_PCM_S8 : - psf_log_printf (psf, "8 bit linear PCM\n") ; - psf->bytewidth = 1 ; - - psf->sf.format |= SF_FORMAT_PCM_S8 ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - psf->sf.frames = psf->datalength / psf->blockwidth ; - break ; - - case PAF_PCM_16 : - psf_log_printf (psf, "16 bit linear PCM\n") ; - psf->bytewidth = 2 ; - - psf->sf.format |= SF_FORMAT_PCM_16 ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - psf->sf.frames = psf->datalength / psf->blockwidth ; - break ; - - case PAF_PCM_24 : - psf_log_printf (psf, "24 bit linear PCM\n") ; - psf->bytewidth = 3 ; - - psf->sf.format |= SF_FORMAT_PCM_24 ; - - psf->blockwidth = 0 ; - psf->sf.frames = PAF24_SAMPLES_PER_BLOCK * psf->datalength / - (PAF24_BLOCK_SIZE * psf->sf.channels) ; - break ; - - default : psf_log_printf (psf, "Unknown\n") ; - return SFE_PAF_UNKNOWN_FORMAT ; - break ; - } ; - - psf_log_printf (psf, "Source : %d => ", paf_fmt.source) ; - - switch (paf_fmt.source) - { case 1 : psf_log_printf (psf, "Analog Recording\n") ; - break ; - case 2 : psf_log_printf (psf, "Digital Transfer\n") ; - break ; - case 3 : psf_log_printf (psf, "Multi-track Mixdown\n") ; - break ; - case 5 : psf_log_printf (psf, "Audio Resulting From DSP Processing\n") ; - break ; - default : psf_log_printf (psf, "Unknown\n") ; - break ; - } ; - - return 0 ; -} /* paf_read_header */ - -static int -paf_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ int paf_format ; - - /* PAF header already written so no need to re-write. */ - if (psf_ftell (psf) >= PAF_HEADER_LENGTH) - return 0 ; - - psf->dataoffset = PAF_HEADER_LENGTH ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - paf_format = PAF_PCM_S8 ; - break ; - - case SF_FORMAT_PCM_16 : - paf_format = PAF_PCM_16 ; - break ; - - case SF_FORMAT_PCM_24 : - paf_format = PAF_PCM_24 ; - break ; - - default : return SFE_PAF_UNKNOWN_FORMAT ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - if (psf->endian == SF_ENDIAN_BIG) - { /* Marker, version, endianness, samplerate */ - psf_binheader_writef (psf, "Em444", BHWm (PAF_MARKER), BHW4 (0), BHW4 (0), BHW4 (psf->sf.samplerate)) ; - /* format, channels, source */ - psf_binheader_writef (psf, "E444", BHW4 (paf_format), BHW4 (psf->sf.channels), BHW4 (0)) ; - } - else if (psf->endian == SF_ENDIAN_LITTLE) - { /* Marker, version, endianness, samplerate */ - psf_binheader_writef (psf, "em444", BHWm (FAP_MARKER), BHW4 (0), BHW4 (1), BHW4 (psf->sf.samplerate)) ; - /* format, channels, source */ - psf_binheader_writef (psf, "e444", BHW4 (paf_format), BHW4 (psf->sf.channels), BHW4 (0)) ; - } ; - - /* Zero fill to dataoffset. */ - psf_binheader_writef (psf, "z", BHWz ((size_t) (psf->dataoffset - psf->header.indx))) ; - - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - return psf->error ; -} /* paf_write_header */ - -/*=============================================================================== -** 24 bit PAF files have a really weird encoding. -** For a mono file, 10 samples (each being 3 bytes) are packed into a 32 byte -** block. The 8 ints in this 32 byte block are then endian swapped (as ints) -** if necessary before being written to disk. -** For a stereo file, blocks of 10 samples from the same channel are encoded -** into 32 bytes as for the mono case. The 32 byte blocks are then interleaved -** on disk. -** Reading has to reverse the above process :-). -** Weird!!! -** -** The code below attempts to gain efficiency while maintaining readability. -*/ - -static int paf24_read_block (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24) ; -static int paf24_write_block (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24) ; -static int paf24_close (SF_PRIVATE *psf) ; - - -static int -paf24_init (SF_PRIVATE *psf) -{ PAF24_PRIVATE *ppaf24 ; - int paf24size ; - - paf24size = sizeof (PAF24_PRIVATE) + psf->sf.channels * - (PAF24_BLOCK_SIZE + PAF24_SAMPLES_PER_BLOCK * sizeof (int)) ; - - /* - ** Not exatly sure why this needs to be here but the tests - ** fail without it. - */ - psf->last_op = 0 ; - - if (! (psf->codec_data = calloc (1, paf24size))) - return SFE_MALLOC_FAILED ; - - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - ppaf24->channels = psf->sf.channels ; - ppaf24->samples = ppaf24->data ; - ppaf24->block = ppaf24->data + PAF24_SAMPLES_PER_BLOCK * ppaf24->channels ; - - ppaf24->blocksize = PAF24_BLOCK_SIZE * ppaf24->channels ; - - if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) - { paf24_read_block (psf, ppaf24) ; /* Read first block. */ - - psf->read_short = paf24_read_s ; - psf->read_int = paf24_read_i ; - psf->read_float = paf24_read_f ; - psf->read_double = paf24_read_d ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { psf->write_short = paf24_write_s ; - psf->write_int = paf24_write_i ; - psf->write_float = paf24_write_f ; - psf->write_double = paf24_write_d ; - } ; - - psf->seek = paf24_seek ; - psf->container_close = paf24_close ; - - psf->filelength = psf_get_filelen (psf) ; - psf->datalength = psf->filelength - psf->dataoffset ; - - if (psf->datalength % PAF24_BLOCK_SIZE) - { if (psf->file.mode == SFM_READ) - psf_log_printf (psf, "*** Warning : file seems to be truncated.\n") ; - ppaf24->max_blocks = psf->datalength / ppaf24->blocksize + 1 ; - } - else - ppaf24->max_blocks = psf->datalength / ppaf24->blocksize ; - - ppaf24->read_block = 0 ; - if (psf->file.mode == SFM_RDWR) - ppaf24->write_block = ppaf24->max_blocks ; - else - ppaf24->write_block = 0 ; - - psf->sf.frames = PAF24_SAMPLES_PER_BLOCK * ppaf24->max_blocks ; - ppaf24->sample_count = psf->sf.frames ; - - return 0 ; -} /* paf24_init */ - -static sf_count_t -paf24_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ PAF24_PRIVATE *ppaf24 ; - int newblock, newsample ; - - if (psf->codec_data == NULL) - { psf->error = SFE_INTERNAL ; - return PSF_SEEK_ERROR ; - } ; - - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - if (mode == SFM_READ && ppaf24->write_count > 0) - paf24_write_block (psf, ppaf24) ; - - newblock = offset / PAF24_SAMPLES_PER_BLOCK ; - newsample = offset % PAF24_SAMPLES_PER_BLOCK ; - - switch (mode) - { case SFM_READ : - if (psf->last_op == SFM_WRITE && ppaf24->write_count) - paf24_write_block (psf, ppaf24) ; - - psf_fseek (psf, psf->dataoffset + newblock * ppaf24->blocksize, SEEK_SET) ; - ppaf24->read_block = newblock ; - paf24_read_block (psf, ppaf24) ; - ppaf24->read_count = newsample ; - break ; - - case SFM_WRITE : - if (offset > ppaf24->sample_count) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (psf->last_op == SFM_WRITE && ppaf24->write_count) - paf24_write_block (psf, ppaf24) ; - - psf_fseek (psf, psf->dataoffset + newblock * ppaf24->blocksize, SEEK_SET) ; - ppaf24->write_block = newblock ; - paf24_read_block (psf, ppaf24) ; - ppaf24->write_count = newsample ; - break ; - - default : - psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - return newblock * PAF24_SAMPLES_PER_BLOCK + newsample ; -} /* paf24_seek */ - -static int -paf24_close (SF_PRIVATE *psf) -{ PAF24_PRIVATE *ppaf24 ; - - if (psf->codec_data == NULL) - return 0 ; - - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (ppaf24->write_count > 0) - paf24_write_block (psf, ppaf24) ; - } ; - - return 0 ; -} /* paf24_close */ - -/*--------------------------------------------------------------------------- -*/ -static int -paf24_read_block (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24) -{ int k, channel ; - unsigned char *cptr ; - - ppaf24->read_block ++ ; - ppaf24->read_count = 0 ; - - if (ppaf24->read_block * PAF24_SAMPLES_PER_BLOCK > ppaf24->sample_count) - { memset (ppaf24->samples, 0, PAF24_SAMPLES_PER_BLOCK * ppaf24->channels) ; - return 1 ; - } ; - - /* Read the block. */ - if ((k = (int) psf_fread (ppaf24->block, 1, ppaf24->blocksize, psf)) != ppaf24->blocksize) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, ppaf24->blocksize) ; - - /* Do endian swapping if necessary. */ - if ((CPU_IS_BIG_ENDIAN && psf->endian == SF_ENDIAN_LITTLE) || (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_BIG)) - endswap_int_array (ppaf24->block, 8 * ppaf24->channels) ; - - /* Unpack block. */ - for (k = 0 ; k < PAF24_SAMPLES_PER_BLOCK * ppaf24->channels ; k++) - { channel = k % ppaf24->channels ; - cptr = ((unsigned char *) ppaf24->block) + PAF24_BLOCK_SIZE * channel + 3 * (k / ppaf24->channels) ; - ppaf24->samples [k] = (cptr [0] << 8) | (cptr [1] << 16) | (((unsigned) cptr [2]) << 24) ; - } ; - - return 1 ; -} /* paf24_read_block */ - -static int -paf24_read (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, int *ptr, int len) -{ int count, total = 0 ; - - while (total < len) - { if (ppaf24->read_block * PAF24_SAMPLES_PER_BLOCK >= ppaf24->sample_count) - { memset (&(ptr [total]), 0, (len - total) * sizeof (int)) ; - return total ; - } ; - - if (ppaf24->read_count >= PAF24_SAMPLES_PER_BLOCK) - paf24_read_block (psf, ppaf24) ; - - count = (PAF24_SAMPLES_PER_BLOCK - ppaf24->read_count) * ppaf24->channels ; - count = (len - total > count) ? count : len - total ; - - memcpy (&(ptr [total]), &(ppaf24->samples [ppaf24->read_count * ppaf24->channels]), count * sizeof (int)) ; - total += count ; - ppaf24->read_count += count / ppaf24->channels ; - } ; - - return total ; -} /* paf24_read */ - -static sf_count_t -paf24_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - PAF24_PRIVATE *ppaf24 ; - int *iptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = paf24_read (psf, ppaf24, iptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = iptr [k] >> 16 ; - total += count ; - len -= readcount ; - } ; - return total ; -} /* paf24_read_s */ - -static sf_count_t -paf24_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ PAF24_PRIVATE *ppaf24 ; - int total ; - - if (psf->codec_data == NULL) - return 0 ; - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - total = paf24_read (psf, ppaf24, ptr, len) ; - - return total ; -} /* paf24_read_i */ - -static sf_count_t -paf24_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - PAF24_PRIVATE *ppaf24 ; - int *iptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 / 0x80000000) : (1.0 / 0x100) ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = paf24_read (psf, ppaf24, iptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * iptr [k] ; - total += count ; - len -= readcount ; - } ; - return total ; -} /* paf24_read_f */ - -static sf_count_t -paf24_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - PAF24_PRIVATE *ppaf24 ; - int *iptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->codec_data == NULL) - return 0 ; - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 / 0x80000000) : (1.0 / 0x100) ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = paf24_read (psf, ppaf24, iptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * iptr [k] ; - total += count ; - len -= readcount ; - } ; - return total ; -} /* paf24_read_d */ - -/*--------------------------------------------------------------------------- -*/ - -static int -paf24_write_block (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24) -{ int k, nextsample, channel ; - unsigned char *cptr ; - - /* First pack block. */ - - if (CPU_IS_LITTLE_ENDIAN) - { for (k = 0 ; k < PAF24_SAMPLES_PER_BLOCK * ppaf24->channels ; k++) - { channel = k % ppaf24->channels ; - cptr = ((unsigned char *) ppaf24->block) + PAF24_BLOCK_SIZE * channel + 3 * (k / ppaf24->channels) ; - nextsample = ppaf24->samples [k] >> 8 ; - cptr [0] = nextsample ; - cptr [1] = nextsample >> 8 ; - cptr [2] = nextsample >> 16 ; - } ; - - /* Do endian swapping if necessary. */ - if (psf->endian == SF_ENDIAN_BIG) - endswap_int_array (ppaf24->block, 8 * ppaf24->channels) ; - } - else if (CPU_IS_BIG_ENDIAN) - { /* This is correct. */ - for (k = 0 ; k < PAF24_SAMPLES_PER_BLOCK * ppaf24->channels ; k++) - { channel = k % ppaf24->channels ; - cptr = ((unsigned char *) ppaf24->block) + PAF24_BLOCK_SIZE * channel + 3 * (k / ppaf24->channels) ; - nextsample = ppaf24->samples [k] >> 8 ; - cptr [0] = nextsample ; - cptr [1] = nextsample >> 8 ; - cptr [2] = nextsample >> 16 ; - } ; - if (psf->endian == SF_ENDIAN_LITTLE) - endswap_int_array (ppaf24->block, 8 * ppaf24->channels) ; - } ; - - /* Write block to disk. */ - if ((k = (int) psf_fwrite (ppaf24->block, 1, ppaf24->blocksize, psf)) != ppaf24->blocksize) - psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, ppaf24->blocksize) ; - - if (ppaf24->sample_count < ppaf24->write_block * PAF24_SAMPLES_PER_BLOCK + ppaf24->write_count) - ppaf24->sample_count = ppaf24->write_block * PAF24_SAMPLES_PER_BLOCK + ppaf24->write_count ; - - if (ppaf24->write_count == PAF24_SAMPLES_PER_BLOCK) - { ppaf24->write_block ++ ; - ppaf24->write_count = 0 ; - } ; - - return 1 ; -} /* paf24_write_block */ - -static int -paf24_write (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, const int *ptr, int len) -{ int count, total = 0 ; - - while (total < len) - { count = (PAF24_SAMPLES_PER_BLOCK - ppaf24->write_count) * ppaf24->channels ; - - if (count > len - total) - count = len - total ; - - memcpy (&(ppaf24->samples [ppaf24->write_count * ppaf24->channels]), &(ptr [total]), count * sizeof (int)) ; - total += count ; - ppaf24->write_count += count / ppaf24->channels ; - - if (ppaf24->write_count >= PAF24_SAMPLES_PER_BLOCK) - paf24_write_block (psf, ppaf24) ; - } ; - - return total ; -} /* paf24_write */ - -static sf_count_t -paf24_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - PAF24_PRIVATE *ppaf24 ; - int *iptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - iptr [k] = ptr [total + k] << 16 ; - count = paf24_write (psf, ppaf24, iptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - return total ; -} /* paf24_write_s */ - -static sf_count_t -paf24_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ PAF24_PRIVATE *ppaf24 ; - int writecount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - while (len > 0) - { writecount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = paf24_write (psf, ppaf24, ptr, writecount) ; - - total += count ; - len -= count ; - if (count != writecount) - break ; - } ; - - return total ; -} /* paf24_write_i */ - -static sf_count_t -paf24_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - PAF24_PRIVATE *ppaf24 ; - int *iptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : (1.0 / 0x100) ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - iptr [k] = psf_lrintf (normfact * ptr [total + k]) ; - count = paf24_write (psf, ppaf24, iptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* paf24_write_f */ - -static sf_count_t -paf24_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - PAF24_PRIVATE *ppaf24 ; - int *iptr ; - int k, bufferlen, writecount = 0, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->codec_data == NULL) - return 0 ; - ppaf24 = (PAF24_PRIVATE*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFFFFFF) : (1.0 / 0x100) ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - iptr [k] = psf_lrint (normfact * ptr [total+k]) ; - count = paf24_write (psf, ppaf24, iptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* paf24_write_d */ - diff --git a/Engine/lib/libsndfile/src/pcm.c b/Engine/lib/libsndfile/src/pcm.c deleted file mode 100644 index d7dc82c4f..000000000 --- a/Engine/lib/libsndfile/src/pcm.c +++ /dev/null @@ -1,2918 +0,0 @@ -/* -** Copyright (C) 1999-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/* Need to be able to handle 3 byte (24 bit) integers. So defined a -** type and use SIZEOF_TRIBYTE instead of (tribyte). -*/ - -typedef struct tribyte -{ uint8_t bytes [3] ; - } tribyte ; - -#define SIZEOF_TRIBYTE 3 - -static sf_count_t pcm_read_sc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t pcm_read_uc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bes2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t pcm_read_les2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bet2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t pcm_read_let2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bei2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t pcm_read_lei2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; - -static sf_count_t pcm_read_sc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t pcm_read_uc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bes2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t pcm_read_les2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bet2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t pcm_read_let2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bei2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t pcm_read_lei2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; - -static sf_count_t pcm_read_sc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t pcm_read_uc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bes2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t pcm_read_les2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bet2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t pcm_read_let2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bei2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t pcm_read_lei2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; - -static sf_count_t pcm_read_sc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; -static sf_count_t pcm_read_uc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bes2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; -static sf_count_t pcm_read_les2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bet2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; -static sf_count_t pcm_read_let2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; -static sf_count_t pcm_read_bei2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; -static sf_count_t pcm_read_lei2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t pcm_write_s2sc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t pcm_write_s2uc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t pcm_write_s2bes (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t pcm_write_s2les (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t pcm_write_s2bet (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t pcm_write_s2let (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t pcm_write_s2bei (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t pcm_write_s2lei (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; - -static sf_count_t pcm_write_i2sc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t pcm_write_i2uc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t pcm_write_i2bes (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t pcm_write_i2les (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t pcm_write_i2bet (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t pcm_write_i2let (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t pcm_write_i2bei (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t pcm_write_i2lei (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; - -static sf_count_t pcm_write_f2sc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t pcm_write_f2uc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t pcm_write_f2bes (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t pcm_write_f2les (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t pcm_write_f2bet (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t pcm_write_f2let (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t pcm_write_f2bei (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t pcm_write_f2lei (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; - -static sf_count_t pcm_write_d2sc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t pcm_write_d2uc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t pcm_write_d2bes (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t pcm_write_d2les (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t pcm_write_d2bet (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t pcm_write_d2let (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t pcm_write_d2bei (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static sf_count_t pcm_write_d2lei (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -/*----------------------------------------------------------------------------------------------- -*/ - -enum -{ /* Char type for 8 bit files. */ - SF_CHARS_SIGNED = 200, - SF_CHARS_UNSIGNED = 201 -} ; - -/*----------------------------------------------------------------------------------------------- -*/ - -int -pcm_init (SF_PRIVATE *psf) -{ int chars = 0 ; - - if (psf->bytewidth == 0 || psf->sf.channels == 0) - { psf_log_printf (psf, "pcm_init : internal error : bytewitdh = %d, channels = %d\n", psf->bytewidth, psf->sf.channels) ; - return SFE_INTERNAL ; - } ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_S8) - chars = SF_CHARS_SIGNED ; - else if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_U8) - chars = SF_CHARS_UNSIGNED ; - -#if CPU_IS_BIG_ENDIAN - psf->data_endswap = (psf->endian == SF_ENDIAN_BIG) ? SF_FALSE : SF_TRUE ; -#else - psf->data_endswap = (psf->endian == SF_ENDIAN_LITTLE) ? SF_FALSE : SF_TRUE ; -#endif - - if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) - { switch (psf->bytewidth * 0x10000 + psf->endian + chars) - { case (0x10000 + SF_ENDIAN_BIG + SF_CHARS_SIGNED) : - case (0x10000 + SF_ENDIAN_LITTLE + SF_CHARS_SIGNED) : - psf->read_short = pcm_read_sc2s ; - psf->read_int = pcm_read_sc2i ; - psf->read_float = pcm_read_sc2f ; - psf->read_double = pcm_read_sc2d ; - break ; - case (0x10000 + SF_ENDIAN_BIG + SF_CHARS_UNSIGNED) : - case (0x10000 + SF_ENDIAN_LITTLE + SF_CHARS_UNSIGNED) : - psf->read_short = pcm_read_uc2s ; - psf->read_int = pcm_read_uc2i ; - psf->read_float = pcm_read_uc2f ; - psf->read_double = pcm_read_uc2d ; - break ; - - case (2 * 0x10000 + SF_ENDIAN_BIG) : - psf->read_short = pcm_read_bes2s ; - psf->read_int = pcm_read_bes2i ; - psf->read_float = pcm_read_bes2f ; - psf->read_double = pcm_read_bes2d ; - break ; - case (3 * 0x10000 + SF_ENDIAN_BIG) : - psf->read_short = pcm_read_bet2s ; - psf->read_int = pcm_read_bet2i ; - psf->read_float = pcm_read_bet2f ; - psf->read_double = pcm_read_bet2d ; - break ; - case (4 * 0x10000 + SF_ENDIAN_BIG) : - - psf->read_short = pcm_read_bei2s ; - psf->read_int = pcm_read_bei2i ; - psf->read_float = pcm_read_bei2f ; - psf->read_double = pcm_read_bei2d ; - break ; - - case (2 * 0x10000 + SF_ENDIAN_LITTLE) : - psf->read_short = pcm_read_les2s ; - psf->read_int = pcm_read_les2i ; - psf->read_float = pcm_read_les2f ; - psf->read_double = pcm_read_les2d ; - break ; - case (3 * 0x10000 + SF_ENDIAN_LITTLE) : - psf->read_short = pcm_read_let2s ; - psf->read_int = pcm_read_let2i ; - psf->read_float = pcm_read_let2f ; - psf->read_double = pcm_read_let2d ; - break ; - case (4 * 0x10000 + SF_ENDIAN_LITTLE) : - psf->read_short = pcm_read_lei2s ; - psf->read_int = pcm_read_lei2i ; - psf->read_float = pcm_read_lei2f ; - psf->read_double = pcm_read_lei2d ; - break ; - default : - psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\nbytewidth %d endian %d\n", psf->bytewidth, psf->endian) ; - return SFE_UNIMPLEMENTED ; - } ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { switch (psf->bytewidth * 0x10000 + psf->endian + chars) - { case (0x10000 + SF_ENDIAN_BIG + SF_CHARS_SIGNED) : - case (0x10000 + SF_ENDIAN_LITTLE + SF_CHARS_SIGNED) : - psf->write_short = pcm_write_s2sc ; - psf->write_int = pcm_write_i2sc ; - psf->write_float = pcm_write_f2sc ; - psf->write_double = pcm_write_d2sc ; - break ; - case (0x10000 + SF_ENDIAN_BIG + SF_CHARS_UNSIGNED) : - case (0x10000 + SF_ENDIAN_LITTLE + SF_CHARS_UNSIGNED) : - psf->write_short = pcm_write_s2uc ; - psf->write_int = pcm_write_i2uc ; - psf->write_float = pcm_write_f2uc ; - psf->write_double = pcm_write_d2uc ; - break ; - - case (2 * 0x10000 + SF_ENDIAN_BIG) : - psf->write_short = pcm_write_s2bes ; - psf->write_int = pcm_write_i2bes ; - psf->write_float = pcm_write_f2bes ; - psf->write_double = pcm_write_d2bes ; - break ; - - case (3 * 0x10000 + SF_ENDIAN_BIG) : - psf->write_short = pcm_write_s2bet ; - psf->write_int = pcm_write_i2bet ; - psf->write_float = pcm_write_f2bet ; - psf->write_double = pcm_write_d2bet ; - break ; - - case (4 * 0x10000 + SF_ENDIAN_BIG) : - psf->write_short = pcm_write_s2bei ; - psf->write_int = pcm_write_i2bei ; - psf->write_float = pcm_write_f2bei ; - psf->write_double = pcm_write_d2bei ; - break ; - - case (2 * 0x10000 + SF_ENDIAN_LITTLE) : - psf->write_short = pcm_write_s2les ; - psf->write_int = pcm_write_i2les ; - psf->write_float = pcm_write_f2les ; - psf->write_double = pcm_write_d2les ; - break ; - - case (3 * 0x10000 + SF_ENDIAN_LITTLE) : - psf->write_short = pcm_write_s2let ; - psf->write_int = pcm_write_i2let ; - psf->write_float = pcm_write_f2let ; - psf->write_double = pcm_write_d2let ; - break ; - - case (4 * 0x10000 + SF_ENDIAN_LITTLE) : - psf->write_short = pcm_write_s2lei ; - psf->write_int = pcm_write_i2lei ; - psf->write_float = pcm_write_f2lei ; - psf->write_double = pcm_write_d2lei ; - break ; - - default : - psf_log_printf (psf, "pcm.c returning SFE_UNIMPLEMENTED\nbytewidth %d endian %d\n", psf->bytewidth, psf->endian) ; - return SFE_UNIMPLEMENTED ; - } ; - - } ; - - if (psf->filelength > psf->dataoffset) - { psf->datalength = (psf->dataend > 0) ? psf->dataend - psf->dataoffset : - psf->filelength - psf->dataoffset ; - } - else - psf->datalength = 0 ; - - psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ; - - return 0 ; -} /* pcm_init */ - -/*============================================================================== -*/ - -static inline void -sc2s_array (const signed char *src, int count, short *dest) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = ((uint16_t) src [i]) << 8 ; - } ; -} /* sc2s_array */ - -static inline void -uc2s_array (const unsigned char *src, int count, short *dest) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = (((uint32_t) src [i]) - 0x80) << 8 ; - } ; -} /* uc2s_array */ - -static inline void -let2s_array (const tribyte *src, int count, short *dest) -{ for (int i = 0 ; i < count ; i++) - dest [i] = LET2H_16_PTR (src [i].bytes) ; -} /* let2s_array */ - -static inline void -bet2s_array (const tribyte *src, int count, short *dest) -{ for (int i = 0 ; i < count ; i++) - dest [i] = BET2H_16_PTR (src [i].bytes) ; -} /* bet2s_array */ - -static inline void -lei2s_array (const int *src, int count, short *dest) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = LE2H_32 (src [i]) ; - dest [i] = value >> 16 ; - } ; -} /* lei2s_array */ - -static inline void -bei2s_array (const int *src, int count, short *dest) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = BE2H_32 (src [i]) ; - dest [i] = value >> 16 ; - } ; -} /* bei2s_array */ - -/*-------------------------------------------------------------------------- -*/ - -static inline void -sc2i_array (const signed char *src, int count, int *dest) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = arith_shift_left ((int) src [i], 24) ; - } ; -} /* sc2i_array */ - -static inline void -uc2i_array (const unsigned char *src, int count, int *dest) -{ for (int i = 0 ; i < count ; i++) - { dest [i] = arith_shift_left (((int) src [i]) - 128, 24) ; - } ; -} /* uc2i_array */ - -static inline void -bes2i_array (const short *src, int count, int *dest) -{ short value ; - - for (int i = 0 ; i < count ; i++) - { value = BE2H_16 (src [i]) ; - dest [i] = arith_shift_left (value, 16) ; - } ; -} /* bes2i_array */ - -static inline void -les2i_array (const short *src, int count, int *dest) -{ short value ; - - for (int i = 0 ; i < count ; i++) - { value = LE2H_16 (src [i]) ; - dest [i] = arith_shift_left (value, 16) ; - } ; -} /* les2i_array */ - -static inline void -bet2i_array (const tribyte *src, int count, int *dest) -{ for (int i = 0 ; i < count ; i++) - dest [i] = psf_get_be24 (src [i].bytes, 0) ; -} /* bet2i_array */ - -static inline void -let2i_array (const tribyte *src, int count, int *dest) -{ for (int i = 0 ; i < count ; i++) - dest [i] = psf_get_le24 (src [i].bytes, 0) ; -} /* let2i_array */ - -/*-------------------------------------------------------------------------- -*/ - -static inline void -sc2f_array (const signed char *src, int count, float *dest, float normfact) -{ for (int i = 0 ; i < count ; i++) - dest [i] = ((float) src [i]) * normfact ; -} /* sc2f_array */ - -static inline void -uc2f_array (const unsigned char *src, int count, float *dest, float normfact) -{ for (int i = 0 ; i < count ; i++) - dest [i] = (((int) src [i]) - 128) * normfact ; -} /* uc2f_array */ - -static inline void -les2f_array (const short *src, int count, float *dest, float normfact) -{ short value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] ; - value = LE2H_16 (value) ; - dest [i] = ((float) value) * normfact ; - } ; -} /* les2f_array */ - -static inline void -bes2f_array (const short *src, int count, float *dest, float normfact) -{ short value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] ; - value = BE2H_16 (value) ; - dest [i] = ((float) value) * normfact ; - } ; -} /* bes2f_array */ - -static inline void -let2f_array (const tribyte *src, int count, float *dest, float normfact) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = psf_get_le24 (src [i].bytes, 0) ; - dest [i] = ((float) value) * normfact ; - } ; -} /* let2f_array */ - -static inline void -bet2f_array (const tribyte *src, int count, float *dest, float normfact) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = psf_get_be24 (src [i].bytes, 0) ; - dest [i] = ((float) value) * normfact ; - } ; -} /* bet2f_array */ - -static inline void -lei2f_array (const int *src, int count, float *dest, float normfact) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] ; - value = LE2H_32 (value) ; - dest [i] = ((float) value) * normfact ; - } ; -} /* lei2f_array */ - -static inline void -bei2f_array (const int *src, int count, float *dest, float normfact) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] ; - value = BE2H_32 (value) ; - dest [i] = ((float) value) * normfact ; - } ; -} /* bei2f_array */ - -/*-------------------------------------------------------------------------- -*/ - -static inline void -sc2d_array (const signed char *src, int count, double *dest, double normfact) -{ for (int i = 0 ; i < count ; i++) - dest [i] = ((double) src [i]) * normfact ; -} /* sc2d_array */ - -static inline void -uc2d_array (const unsigned char *src, int count, double *dest, double normfact) -{ for (int i = 0 ; i < count ; i++) - dest [i] = (((int) src [i]) - 128) * normfact ; -} /* uc2d_array */ - -static inline void -les2d_array (const short *src, int count, double *dest, double normfact) -{ short value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] ; - value = LE2H_16 (value) ; - dest [i] = ((double) value) * normfact ; - } ; -} /* les2d_array */ - -static inline void -bes2d_array (const short *src, int count, double *dest, double normfact) -{ short value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] ; - value = BE2H_16 (value) ; - dest [i] = ((double) value) * normfact ; - } ; -} /* bes2d_array */ - -static inline void -let2d_array (const tribyte *src, int count, double *dest, double normfact) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = psf_get_le24 (src [i].bytes, 0) ; - dest [i] = ((double) value) * normfact ; - } ; -} /* let2d_array */ - -static inline void -bet2d_array (const tribyte *src, int count, double *dest, double normfact) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = psf_get_be24 (src [i].bytes, 0) ; - dest [i] = ((double) value) * normfact ; - } ; -} /* bet2d_array */ - -static inline void -lei2d_array (const int *src, int count, double *dest, double normfact) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] ; - value = LE2H_32 (value) ; - dest [i] = ((double) value) * normfact ; - } ; -} /* lei2d_array */ - -static inline void -bei2d_array (const int *src, int count, double *dest, double normfact) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] ; - value = BE2H_32 (value) ; - dest [i] = ((double) value) * normfact ; - } ; -} /* bei2d_array */ - -/*-------------------------------------------------------------------------- -*/ - -static inline void -s2sc_array (const short *src, signed char *dest, int count) -{ for (int i = 0 ; i < count ; i++) - dest [i] = src [i] >> 8 ; -} /* s2sc_array */ - -static inline void -s2uc_array (const short *src, unsigned char *dest, int count) -{ for (int i = 0 ; i < count ; i++) - dest [i] = (src [i] >> 8) + 0x80 ; -} /* s2uc_array */ - -static inline void -s2let_array (const short *src, tribyte *dest, int count) -{ for (int i = 0 ; i < count ; i++) - { dest [i].bytes [0] = 0 ; - dest [i].bytes [1] = src [i] ; - dest [i].bytes [2] = src [i] >> 8 ; - } ; -} /* s2let_array */ - -static inline void -s2bet_array (const short *src, tribyte *dest, int count) -{ for (int i = 0 ; i < count ; i++) - { dest [i].bytes [2] = 0 ; - dest [i].bytes [1] = src [i] ; - dest [i].bytes [0] = src [i] >> 8 ; - } ; -} /* s2bet_array */ - -static inline void -s2lei_array (const short *src, int *dest, int count) -{ unsigned char *ucptr ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - ucptr [0] = 0 ; - ucptr [1] = 0 ; - ucptr [2] = src [i] ; - ucptr [3] = src [i] >> 8 ; - } ; -} /* s2lei_array */ - -static inline void -s2bei_array (const short *src, int *dest, int count) -{ unsigned char *ucptr ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - ucptr [0] = src [i] >> 8 ; - ucptr [1] = src [i] ; - ucptr [2] = 0 ; - ucptr [3] = 0 ; - } ; -} /* s2bei_array */ - -/*-------------------------------------------------------------------------- -*/ - -static inline void -i2sc_array (const int *src, signed char *dest, int count) -{ for (int i = 0 ; i < count ; i++) - dest [i] = (src [i] >> 24) ; -} /* i2sc_array */ - -static inline void -i2uc_array (const int *src, unsigned char *dest, int count) -{ for (int i = 0 ; i < count ; i++) - dest [i] = ((src [i] >> 24) + 128) ; -} /* i2uc_array */ - -static inline void -i2bes_array (const int *src, short *dest, int count) -{ unsigned char *ucptr ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - ucptr [0] = src [i] >> 24 ; - ucptr [1] = src [i] >> 16 ; - } ; -} /* i2bes_array */ - -static inline void -i2les_array (const int *src, short *dest, int count) -{ unsigned char *ucptr ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - ucptr [0] = src [i] >> 16 ; - ucptr [1] = src [i] >> 24 ; - } ; -} /* i2les_array */ - -static inline void -i2let_array (const int *src, tribyte *dest, int count) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] >> 8 ; - dest [i].bytes [0] = value ; - dest [i].bytes [1] = value >> 8 ; - dest [i].bytes [2] = value >> 16 ; - } ; -} /* i2let_array */ - -static inline void -i2bet_array (const int *src, tribyte *dest, int count) -{ int value ; - - for (int i = 0 ; i < count ; i++) - { value = src [i] >> 8 ; - dest [i].bytes [2] = value ; - dest [i].bytes [1] = value >> 8 ; - dest [i].bytes [0] = value >> 16 ; - } ; -} /* i2bet_array */ - -/*=============================================================================================== -*/ - -static sf_count_t -pcm_read_sc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.scbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - sc2s_array (ubuf.scbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_sc2s */ - -static sf_count_t -pcm_read_uc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - uc2s_array (ubuf.ucbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_uc2s */ - -static sf_count_t -pcm_read_bes2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int total ; - - total = (int) psf_fread (ptr, sizeof (short), len, psf) ; -#if CPU_IS_LITTLE_ENDIAN - endswap_short_array (ptr, len) ; -#endif - - return total ; -} /* pcm_read_bes2s */ - -static sf_count_t -pcm_read_les2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ int total ; - - total = psf_fread (ptr, sizeof (short), len, psf) ; -#if CPU_IS_BIG_ENDIAN - endswap_short_array (ptr, len) ; -#endif - - return total ; -} /* pcm_read_les2s */ - -static sf_count_t -pcm_read_bet2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - bet2s_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bet2s */ - -static sf_count_t -pcm_read_let2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - let2s_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_let2s */ - -static sf_count_t -pcm_read_bei2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - bei2s_array (ubuf.ibuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bei2s */ - -static sf_count_t -pcm_read_lei2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - lei2s_array (ubuf.ibuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_lei2s */ - -/*----------------------------------------------------------------------------------------------- -*/ - -static sf_count_t -pcm_read_sc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.scbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - sc2i_array (ubuf.scbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_sc2i */ - -static sf_count_t -pcm_read_uc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - uc2i_array (ubuf.ucbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_uc2i */ - -static sf_count_t -pcm_read_bes2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - bes2i_array (ubuf.sbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bes2i */ - -static sf_count_t -pcm_read_les2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - les2i_array (ubuf.sbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_les2i */ - -static sf_count_t -pcm_read_bet2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - bet2i_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bet2i */ - -static sf_count_t -pcm_read_let2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - let2i_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_let2i */ - -static sf_count_t -pcm_read_bei2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int total ; - - total = psf_fread (ptr, sizeof (int), len, psf) ; -#if CPU_IS_LITTLE_ENDIAN - endswap_int_array (ptr, len) ; -#endif - - return total ; -} /* pcm_read_bei2i */ - -static sf_count_t -pcm_read_lei2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ int total ; - - total = psf_fread (ptr, sizeof (int), len, psf) ; -#if CPU_IS_BIG_ENDIAN - endswap_int_array (ptr, len) ; -#endif - - return total ; -} /* pcm_read_lei2i */ - -/*----------------------------------------------------------------------------------------------- -*/ - -static sf_count_t -pcm_read_sc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.scbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - sc2f_array (ubuf.scbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_sc2f */ - -static sf_count_t -pcm_read_uc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - uc2f_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_uc2f */ - -static sf_count_t -pcm_read_bes2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - bes2f_array (ubuf.sbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bes2f */ - -static sf_count_t -pcm_read_les2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - les2f_array (ubuf.sbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_les2f */ - -static sf_count_t -pcm_read_bet2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - /* Special normfactor because tribyte value is read into an int. */ - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 / 256.0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - bet2f_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bet2f */ - -static sf_count_t -pcm_read_let2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - /* Special normfactor because tribyte value is read into an int. */ - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 / 256.0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - let2f_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_let2f */ - -static sf_count_t -pcm_read_bei2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - bei2f_array (ubuf.ibuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bei2f */ - -static sf_count_t -pcm_read_lei2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - lei2f_array (ubuf.ibuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_lei2f */ - -/*----------------------------------------------------------------------------------------------- -*/ - -static sf_count_t -pcm_read_sc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.scbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - sc2d_array (ubuf.scbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_sc2d */ - -static sf_count_t -pcm_read_uc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - uc2d_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_uc2d */ - -static sf_count_t -pcm_read_bes2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - bes2d_array (ubuf.sbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bes2d */ - -static sf_count_t -pcm_read_les2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - les2d_array (ubuf.sbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_les2d */ - -static sf_count_t -pcm_read_bet2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 / 256.0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - bet2d_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bet2d */ - -static sf_count_t -pcm_read_let2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - /* Special normfactor because tribyte value is read into an int. */ - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 / 256.0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - let2d_array ((tribyte*) (ubuf.ucbuf), readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_let2d */ - -static sf_count_t -pcm_read_bei2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - bei2d_array (ubuf.ibuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_bei2d */ - -static sf_count_t -pcm_read_lei2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80000000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - lei2d_array (ubuf.ibuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* pcm_read_lei2d */ - -/*=============================================================================================== -**----------------------------------------------------------------------------------------------- -**=============================================================================================== -*/ - -static sf_count_t -pcm_write_s2sc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.scbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2sc_array (ptr + total, ubuf.scbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_s2sc */ - -static sf_count_t -pcm_write_s2uc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2uc_array (ptr + total, ubuf.ucbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_s2uc */ - -static sf_count_t -pcm_write_s2bes (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ -#if CPU_IS_BIG_ENDIAN - return psf_fwrite (ptr, sizeof (short), len, psf) ; -#else - BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - endswap_short_copy (ubuf.sbuf, ptr + total, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -#endif -} /* pcm_write_s2bes */ - -static sf_count_t -pcm_write_s2les (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ -#if CPU_IS_LITTLE_ENDIAN - return psf_fwrite (ptr, sizeof (short), len, psf) ; -#else - BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - endswap_short_copy (ubuf.sbuf, ptr + total, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -#endif -} /* pcm_write_s2les */ - -static sf_count_t -pcm_write_s2bet (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2bet_array (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_s2bet */ - -static sf_count_t -pcm_write_s2let (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2let_array (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_s2let */ - -static sf_count_t -pcm_write_s2bei (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2bei_array (ptr + total, ubuf.ibuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_s2bei */ - -static sf_count_t -pcm_write_s2lei (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2lei_array (ptr + total, ubuf.ibuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_s2lei */ - -/*----------------------------------------------------------------------------------------------- -*/ - -static sf_count_t -pcm_write_i2sc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.scbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2sc_array (ptr + total, ubuf.scbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_i2sc */ - -static sf_count_t -pcm_write_i2uc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2uc_array (ptr + total, ubuf.ucbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, sizeof (signed char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_i2uc */ - -static sf_count_t -pcm_write_i2bes (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2bes_array (ptr + total, ubuf.sbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_i2bes */ - -static sf_count_t -pcm_write_i2les (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2les_array (ptr + total, ubuf.sbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_i2les */ - -static sf_count_t -pcm_write_i2bet (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2bet_array (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_i2bet */ - -static sf_count_t -pcm_write_i2let (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2let_array (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_i2les */ - -static sf_count_t -pcm_write_i2bei (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ -#if CPU_IS_BIG_ENDIAN - return psf_fwrite (ptr, sizeof (int), len, psf) ; -#else - BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - endswap_int_copy (ubuf.ibuf, ptr + total, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -#endif -} /* pcm_write_i2bei */ - -static sf_count_t -pcm_write_i2lei (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ -#if CPU_IS_LITTLE_ENDIAN - return psf_fwrite (ptr, sizeof (int), len, psf) ; -#else - BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - endswap_int_copy (ubuf.ibuf, ptr + total, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -#endif -} /* pcm_write_i2lei */ - -/*------------------------------------------------------------------------------ -**============================================================================== -**------------------------------------------------------------------------------ -*/ - -static void -f2sc_array (const float *src, signed char *dest, int count, int normalize) -{ float normfact ; - - normfact = normalize ? (1.0 * 0x7F) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { dest [i] = psf_lrintf (src [i] * normfact) ; - } ; -} /* f2sc_array */ - -static void -f2sc_clip_array (const float *src, signed char *dest, int count, int normalize) -{ float normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i] = 127 ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i] = -128 ; - continue ; - } ; - - dest [i] = psf_lrintf (scaled_value) >> 24 ; - } ; -} /* f2sc_clip_array */ - -static sf_count_t -pcm_write_f2sc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, signed char *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? f2sc_clip_array : f2sc_array ; - bufferlen = ARRAY_LEN (ubuf.scbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.scbuf, bufferlen, psf->norm_float) ; - writecount = (int) psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_f2sc */ - -/*============================================================================== -*/ - -static void -f2uc_array (const float *src, unsigned char *dest, int count, int normalize) -{ float normfact ; - - normfact = normalize ? (1.0 * 0x7F) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { dest [i] = psf_lrintf (src [i] * normfact) + 128 ; - } ; -} /* f2uc_array */ - -static void -f2uc_clip_array (const float *src, unsigned char *dest, int count, int normalize) -{ float normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i] = 0xFF ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i] = 0 ; - continue ; - } ; - - dest [i] = (psf_lrintf (scaled_value) >> 24) + 128 ; - } ; -} /* f2uc_clip_array */ - -static sf_count_t -pcm_write_f2uc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, unsigned char *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? f2uc_clip_array : f2uc_array ; - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.ucbuf, bufferlen, psf->norm_float) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_f2uc */ - -/*============================================================================== -*/ - -static void -f2bes_array (const float *src, short *dest, int count, int normalize) -{ unsigned char *ucptr ; - float normfact ; - short value ; - - normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - value = psf_lrintf (src [i] * normfact) ; - ucptr [1] = value ; - ucptr [0] = value >> 8 ; - } ; -} /* f2bes_array */ - -static void -f2bes_clip_array (const float *src, short *dest, int count, int normalize) -{ unsigned char *ucptr ; - float normfact, scaled_value ; - int value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { ucptr [1] = 0xFF ; - ucptr [0] = 0x7F ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10000000)) - { ucptr [1] = 0x00 ; - ucptr [0] = 0x80 ; - continue ; - } ; - - value = psf_lrintf (scaled_value) ; - ucptr [1] = value >> 16 ; - ucptr [0] = value >> 24 ; - } ; -} /* f2bes_clip_array */ - -static sf_count_t -pcm_write_f2bes (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, short *t, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? f2bes_clip_array : f2bes_array ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.sbuf, bufferlen, psf->norm_float) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_f2bes */ - -/*============================================================================== -*/ - -static void -f2les_array (const float *src, short *dest, int count, int normalize) -{ unsigned char *ucptr ; - float normfact ; - int value ; - - normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - value = psf_lrintf (src [i] * normfact) ; - ucptr [0] = value ; - ucptr [1] = value >> 8 ; - } ; -} /* f2les_array */ - -static void -f2les_clip_array (const float *src, short *dest, int count, int normalize) -{ unsigned char *ucptr ; - float normfact, scaled_value ; - int value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { ucptr [0] = 0xFF ; - ucptr [1] = 0x7F ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10000000)) - { ucptr [0] = 0x00 ; - ucptr [1] = 0x80 ; - continue ; - } ; - - value = psf_lrintf (scaled_value) ; - ucptr [0] = value >> 16 ; - ucptr [1] = value >> 24 ; - } ; -} /* f2les_clip_array */ - -static sf_count_t -pcm_write_f2les (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, short *t, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? f2les_clip_array : f2les_array ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.sbuf, bufferlen, psf->norm_float) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_f2les */ - -/*============================================================================== -*/ - -static void -f2let_array (const float *src, tribyte *dest, int count, int normalize) -{ float normfact ; - int value ; - - normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { value = psf_lrintf (src [i] * normfact) ; - dest [i].bytes [0] = value ; - dest [i].bytes [1] = value >> 8 ; - dest [i].bytes [2] = value >> 16 ; - } ; -} /* f2let_array */ - -static void -f2let_clip_array (const float *src, tribyte *dest, int count, int normalize) -{ float normfact, scaled_value ; - int value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i].bytes [0] = 0xFF ; - dest [i].bytes [1] = 0xFF ; - dest [i].bytes [2] = 0x7F ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i].bytes [0] = 0x00 ; - dest [i].bytes [1] = 0x00 ; - dest [i].bytes [2] = 0x80 ; - continue ; - } ; -#endif - - value = psf_lrintf (scaled_value) ; - dest [i].bytes [0] = value >> 8 ; - dest [i].bytes [1] = value >> 16 ; - dest [i].bytes [2] = value >> 24 ; - } ; -} /* f2let_clip_array */ - -static sf_count_t -pcm_write_f2let (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, tribyte *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? f2let_clip_array : f2let_array ; - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen, psf->norm_float) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_f2let */ - -/*============================================================================== -*/ - -static void -f2bet_array (const float *src, tribyte *dest, int count, int normalize) -{ float normfact ; - int value ; - - normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { value = psf_lrintf (src [i] * normfact) ; - dest [i].bytes [0] = value >> 16 ; - dest [i].bytes [1] = value >> 8 ; - dest [i].bytes [2] = value ; - } ; -} /* f2bet_array */ - -static void -f2bet_clip_array (const float *src, tribyte *dest, int count, int normalize) -{ float normfact, scaled_value ; - int value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i].bytes [0] = 0x7F ; - dest [i].bytes [1] = 0xFF ; - dest [i].bytes [2] = 0xFF ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i].bytes [0] = 0x80 ; - dest [i].bytes [1] = 0x00 ; - dest [i].bytes [2] = 0x00 ; - continue ; - } ; -#endif - - value = psf_lrint (scaled_value) ; - dest [i].bytes [0] = value >> 24 ; - dest [i].bytes [1] = value >> 16 ; - dest [i].bytes [2] = value >> 8 ; - } ; -} /* f2bet_clip_array */ - -static sf_count_t -pcm_write_f2bet (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, tribyte *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? f2bet_clip_array : f2bet_array ; - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen, psf->norm_float) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_f2bet */ - -/*============================================================================== -*/ - -static void -f2bei_array (const float *src, int *dest, int count, int normalize) -{ unsigned char *ucptr ; - float normfact ; - int value ; - - normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - value = psf_lrintf (src [i] * normfact) ; - ucptr [0] = value >> 24 ; - ucptr [1] = value >> 16 ; - ucptr [2] = value >> 8 ; - ucptr [3] = value ; - } ; -} /* f2bei_array */ - -static void -f2bei_clip_array (const float *src, int *dest, int count, int normalize) -{ unsigned char *ucptr ; - float normfact, scaled_value ; - int value ; - - normfact = normalize ? (8.0 * 0x10000000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= 1.0 * 0x7FFFFFFF) - { ucptr [0] = 0x7F ; - ucptr [1] = 0xFF ; - ucptr [2] = 0xFF ; - ucptr [3] = 0xFF ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { ucptr [0] = 0x80 ; - ucptr [1] = 0x00 ; - ucptr [2] = 0x00 ; - ucptr [3] = 0x00 ; - continue ; - } ; -#endif - - value = psf_lrintf (scaled_value) ; - ucptr [0] = value >> 24 ; - ucptr [1] = value >> 16 ; - ucptr [2] = value >> 8 ; - ucptr [3] = value ; - } ; -} /* f2bei_clip_array */ - -static sf_count_t -pcm_write_f2bei (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, int *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? f2bei_clip_array : f2bei_array ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.ibuf, bufferlen, psf->norm_float) ; - writecount = (int) psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_f2bei */ - -/*============================================================================== -*/ - -static void -f2lei_array (const float *src, int *dest, int count, int normalize) -{ unsigned char *ucptr ; - float normfact ; - int value ; - - normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - value = psf_lrintf (src [i] * normfact) ; - ucptr [0] = value ; - ucptr [1] = value >> 8 ; - ucptr [2] = value >> 16 ; - ucptr [3] = value >> 24 ; - } ; -} /* f2lei_array */ - -static void -f2lei_clip_array (const float *src, int *dest, int count, int normalize) -{ unsigned char *ucptr ; - float normfact, scaled_value ; - int value ; - - normfact = normalize ? (8.0 * 0x10000000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { ucptr [0] = 0xFF ; - ucptr [1] = 0xFF ; - ucptr [2] = 0xFF ; - ucptr [3] = 0x7F ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { ucptr [0] = 0x00 ; - ucptr [1] = 0x00 ; - ucptr [2] = 0x00 ; - ucptr [3] = 0x80 ; - continue ; - } ; -#endif - - value = psf_lrintf (scaled_value) ; - ucptr [0] = value ; - ucptr [1] = value >> 8 ; - ucptr [2] = value >> 16 ; - ucptr [3] = value >> 24 ; - } ; -} /* f2lei_clip_array */ - -static sf_count_t -pcm_write_f2lei (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const float *, int *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? f2lei_clip_array : f2lei_array ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.ibuf, bufferlen, psf->norm_float) ; - writecount = (int) psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_f2lei */ - -/*============================================================================== -*/ - -static void -d2sc_array (const double *src, signed char *dest, int count, int normalize) -{ double normfact ; - - normfact = normalize ? (1.0 * 0x7F) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { dest [i] = psf_lrint (src [i] * normfact) ; - } ; -} /* d2sc_array */ - -static void -d2sc_clip_array (const double *src, signed char *dest, int count, int normalize) -{ double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i] = 127 ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i] = -128 ; - continue ; - } ; - - dest [i] = psf_lrintf (scaled_value) >> 24 ; - } ; -} /* d2sc_clip_array */ - -static sf_count_t -pcm_write_d2sc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, signed char *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? d2sc_clip_array : d2sc_array ; - bufferlen = ARRAY_LEN (ubuf.scbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.scbuf, bufferlen, psf->norm_double) ; - writecount = (int) psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_d2sc */ - -/*============================================================================== -*/ - -static void -d2uc_array (const double *src, unsigned char *dest, int count, int normalize) -{ double normfact ; - - normfact = normalize ? (1.0 * 0x7F) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { dest [i] = psf_lrint (src [i] * normfact) + 128 ; - } ; -} /* d2uc_array */ - -static void -d2uc_clip_array (const double *src, unsigned char *dest, int count, int normalize) -{ double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i] = 255 ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i] = 0 ; - continue ; - } ; - - dest [i] = (psf_lrint (src [i] * normfact) >> 24) + 128 ; - } ; -} /* d2uc_clip_array */ - -static sf_count_t -pcm_write_d2uc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, unsigned char *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? d2uc_clip_array : d2uc_array ; - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.ucbuf, bufferlen, psf->norm_double) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, sizeof (unsigned char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_d2uc */ - -/*============================================================================== -*/ - -static void -d2bes_array (const double *src, short *dest, int count, int normalize) -{ unsigned char *ucptr ; - short value ; - double normfact ; - - normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - value = psf_lrint (src [i] * normfact) ; - ucptr [1] = value ; - ucptr [0] = value >> 8 ; - } ; -} /* d2bes_array */ - -static void -d2bes_clip_array (const double *src, short *dest, int count, int normalize) -{ unsigned char *ucptr ; - double normfact, scaled_value ; - int value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { ucptr [1] = 0xFF ; - ucptr [0] = 0x7F ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10000000)) - { ucptr [1] = 0x00 ; - ucptr [0] = 0x80 ; - continue ; - } ; - - value = psf_lrint (scaled_value) ; - ucptr [1] = value >> 16 ; - ucptr [0] = value >> 24 ; - } ; -} /* d2bes_clip_array */ - -static sf_count_t -pcm_write_d2bes (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, short *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? d2bes_clip_array : d2bes_array ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.sbuf, bufferlen, psf->norm_double) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_d2bes */ - -/*============================================================================== -*/ - -static void -d2les_array (const double *src, short *dest, int count, int normalize) -{ unsigned char *ucptr ; - short value ; - double normfact ; - - normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - value = psf_lrint (src [i] * normfact) ; - ucptr [0] = value ; - ucptr [1] = value >> 8 ; - } ; -} /* d2les_array */ - -static void -d2les_clip_array (const double *src, short *dest, int count, int normalize) -{ unsigned char *ucptr ; - int value ; - double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - scaled_value = src [i] * normfact ; - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { ucptr [0] = 0xFF ; - ucptr [1] = 0x7F ; - continue ; - } ; - if (scaled_value <= (-8.0 * 0x10000000)) - { ucptr [0] = 0x00 ; - ucptr [1] = 0x80 ; - continue ; - } ; - - value = psf_lrint (scaled_value) ; - ucptr [0] = value >> 16 ; - ucptr [1] = value >> 24 ; - } ; -} /* d2les_clip_array */ - -static sf_count_t -pcm_write_d2les (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, short *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? d2les_clip_array : d2les_array ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.sbuf, bufferlen, psf->norm_double) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_d2les */ - -/*============================================================================== -*/ - -static void -d2let_array (const double *src, tribyte *dest, int count, int normalize) -{ int value ; - double normfact ; - - normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { value = psf_lrint (src [i] * normfact) ; - dest [i].bytes [0] = value ; - dest [i].bytes [1] = value >> 8 ; - dest [i].bytes [2] = value >> 16 ; - } ; -} /* d2let_array */ - -static void -d2let_clip_array (const double *src, tribyte *dest, int count, int normalize) -{ int value ; - double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i].bytes [0] = 0xFF ; - dest [i].bytes [1] = 0xFF ; - dest [i].bytes [2] = 0x7F ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i].bytes [0] = 0x00 ; - dest [i].bytes [1] = 0x00 ; - dest [i].bytes [2] = 0x80 ; - continue ; - } ; -#endif - - value = psf_lrint (scaled_value) ; - dest [i].bytes [0] = value >> 8 ; - dest [i].bytes [1] = value >> 16 ; - dest [i].bytes [2] = value >> 24 ; - } ; -} /* d2let_clip_array */ - -static sf_count_t -pcm_write_d2let (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, tribyte *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? d2let_clip_array : d2let_array ; - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen, psf->norm_double) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_d2let */ - -/*============================================================================== -*/ - -static void -d2bet_array (const double *src, tribyte *dest, int count, int normalize) -{ int value ; - double normfact ; - - normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { value = psf_lrint (src [i] * normfact) ; - dest [i].bytes [2] = value ; - dest [i].bytes [1] = value >> 8 ; - dest [i].bytes [0] = value >> 16 ; - } ; -} /* d2bet_array */ - -static void -d2bet_clip_array (const double *src, tribyte *dest, int count, int normalize) -{ int value ; - double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ; - - for (int i = 0 ; i < count ; i++) - { scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { dest [i].bytes [2] = 0xFF ; - dest [i].bytes [1] = 0xFF ; - dest [i].bytes [0] = 0x7F ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { dest [i].bytes [2] = 0x00 ; - dest [i].bytes [1] = 0x00 ; - dest [i].bytes [0] = 0x80 ; - continue ; - } ; -#endif - - value = psf_lrint (scaled_value) ; - dest [i].bytes [2] = value >> 8 ; - dest [i].bytes [1] = value >> 16 ; - dest [i].bytes [0] = value >> 24 ; - } ; -} /* d2bet_clip_array */ - -static sf_count_t -pcm_write_d2bet (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, tribyte *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? d2bet_clip_array : d2bet_array ; - bufferlen = sizeof (ubuf.ucbuf) / SIZEOF_TRIBYTE ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, (tribyte*) (ubuf.ucbuf), bufferlen, psf->norm_double) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_d2bet */ - -/*============================================================================== -*/ - -static void -d2bei_array (const double *src, int *dest, int count, int normalize) -{ unsigned char *ucptr ; - int value ; - double normfact ; - - normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - value = psf_lrint (src [i] * normfact) ; - ucptr [0] = value >> 24 ; - ucptr [1] = value >> 16 ; - ucptr [2] = value >> 8 ; - ucptr [3] = value ; - } ; -} /* d2bei_array */ - -static void -d2bei_clip_array (const double *src, int *dest, int count, int normalize) -{ unsigned char *ucptr ; - int value ; - double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { ucptr [3] = 0xFF ; - ucptr [2] = 0xFF ; - ucptr [1] = 0xFF ; - ucptr [0] = 0x7F ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { ucptr [3] = 0x00 ; - ucptr [2] = 0x00 ; - ucptr [1] = 0x00 ; - ucptr [0] = 0x80 ; - continue ; - } ; -#endif - - value = psf_lrint (scaled_value) ; - ucptr [0] = value >> 24 ; - ucptr [1] = value >> 16 ; - ucptr [2] = value >> 8 ; - ucptr [3] = value ; - } ; -} /* d2bei_clip_array */ - -static sf_count_t -pcm_write_d2bei (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, int *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? d2bei_clip_array : d2bei_array ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.ibuf, bufferlen, psf->norm_double) ; - writecount = (int) psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_d2bei */ - -/*============================================================================== -*/ - -static void -d2lei_array (const double *src, int *dest, int count, int normalize) -{ unsigned char *ucptr ; - int value ; - double normfact ; - - normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - value = psf_lrint (src [i] * normfact) ; - ucptr [0] = value ; - ucptr [1] = value >> 8 ; - ucptr [2] = value >> 16 ; - ucptr [3] = value >> 24 ; - } ; -} /* d2lei_array */ - -static void -d2lei_clip_array (const double *src, int *dest, int count, int normalize) -{ unsigned char *ucptr ; - int value ; - double normfact, scaled_value ; - - normfact = normalize ? (8.0 * 0x10000000) : 1.0 ; - - for (int i = 0 ; i < count ; i++) - { ucptr = (unsigned char*) &dest [i] ; - scaled_value = src [i] * normfact ; -#if CPU_CLIPS_POSITIVE == 0 - if (scaled_value >= (1.0 * 0x7FFFFFFF)) - { ucptr [0] = 0xFF ; - ucptr [1] = 0xFF ; - ucptr [2] = 0xFF ; - ucptr [3] = 0x7F ; - continue ; - } ; -#endif -#if CPU_CLIPS_NEGATIVE == 0 - if (scaled_value <= (-8.0 * 0x10000000)) - { ucptr [0] = 0x00 ; - ucptr [1] = 0x00 ; - ucptr [2] = 0x00 ; - ucptr [3] = 0x80 ; - continue ; - } ; -#endif - - value = psf_lrint (scaled_value) ; - ucptr [0] = value ; - ucptr [1] = value >> 8 ; - ucptr [2] = value >> 16 ; - ucptr [3] = value >> 24 ; - } ; -} /* d2lei_clip_array */ - -static sf_count_t -pcm_write_d2lei (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - void (*convert) (const double *, int *, int, int) ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - convert = (psf->add_clipping) ? d2lei_clip_array : d2lei_array ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - convert (ptr + total, ubuf.ibuf, bufferlen, psf->norm_double) ; - writecount = (int) psf_fwrite (ubuf.ibuf, sizeof (int), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* pcm_write_d2lei */ - diff --git a/Engine/lib/libsndfile/src/pvf.c b/Engine/lib/libsndfile/src/pvf.c deleted file mode 100644 index 714f5b380..000000000 --- a/Engine/lib/libsndfile/src/pvf.c +++ /dev/null @@ -1,188 +0,0 @@ -/* -** Copyright (C) 2002-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ - -#define PVF1_MARKER (MAKE_MARKER ('P', 'V', 'F', '1')) - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int pvf_close (SF_PRIVATE *psf) ; - -static int pvf_write_header (SF_PRIVATE *psf, int calc_length) ; -static int pvf_read_header (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -pvf_open (SF_PRIVATE *psf) -{ int subformat ; - int error = 0 ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = pvf_read_header (psf))) - return error ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_PVF) - return SFE_BAD_OPEN_FORMAT ; - - psf->endian = SF_ENDIAN_BIG ; - - if (pvf_write_header (psf, SF_FALSE)) - return psf->error ; - - psf->write_header = pvf_write_header ; - } ; - - psf->container_close = pvf_close ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - switch (subformat) - { case SF_FORMAT_PCM_S8 : /* 8-bit linear PCM. */ - case SF_FORMAT_PCM_16 : /* 16-bit linear PCM. */ - case SF_FORMAT_PCM_32 : /* 32-bit linear PCM. */ - error = pcm_init (psf) ; - break ; - - default : break ; - } ; - - return error ; -} /* pvf_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -pvf_close (SF_PRIVATE * UNUSED (psf)) -{ - return 0 ; -} /* pvf_close */ - -static int -pvf_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ sf_count_t current ; - - if (psf->pipeoffset > 0) - return 0 ; - - current = psf_ftell (psf) ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - if (psf->is_pipe == SF_FALSE) - psf_fseek (psf, 0, SEEK_SET) ; - - snprintf ((char*) psf->header.ptr, psf->header.len, "PVF1\n%d %d %d\n", - psf->sf.channels, psf->sf.samplerate, psf->bytewidth * 8) ; - - psf->header.indx = strlen ((char*) psf->header.ptr) ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* pvf_write_header */ - -static int -pvf_read_header (SF_PRIVATE *psf) -{ char buffer [32] ; - int marker, channels, samplerate, bitwidth ; - - psf_binheader_readf (psf, "pmj", 0, &marker, 1) ; - psf_log_printf (psf, "%M\n", marker) ; - - if (marker != PVF1_MARKER) - return SFE_PVF_NO_PVF1 ; - - /* Grab characters up until a newline which is replaced by an EOS. */ - psf_binheader_readf (psf, "G", buffer, sizeof (buffer)) ; - - if (sscanf (buffer, "%d %d %d", &channels, &samplerate, &bitwidth) != 3) - return SFE_PVF_BAD_HEADER ; - - psf_log_printf (psf, " Channels : %d\n Sample rate : %d\n Bit width : %d\n", - channels, samplerate, bitwidth) ; - - psf->sf.channels = channels ; - psf->sf.samplerate = samplerate ; - - switch (bitwidth) - { case 8 : - psf->sf.format = SF_FORMAT_PVF | SF_FORMAT_PCM_S8 ; - psf->bytewidth = 1 ; - break ; - - case 16 : - psf->sf.format = SF_FORMAT_PVF | SF_FORMAT_PCM_16 ; - psf->bytewidth = 2 ; - break ; - case 32 : - psf->sf.format = SF_FORMAT_PVF | SF_FORMAT_PCM_32 ; - psf->bytewidth = 4 ; - break ; - - default : - return SFE_PVF_BAD_BITWIDTH ; - } ; - - psf->dataoffset = psf_ftell (psf) ; - psf_log_printf (psf, " Data Offset : %D\n", psf->dataoffset) ; - - psf->endian = SF_ENDIAN_BIG ; - - psf->datalength = psf->filelength - psf->dataoffset ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - if (! psf->sf.frames && psf->blockwidth) - psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - - return 0 ; -} /* pvf_read_header */ diff --git a/Engine/lib/libsndfile/src/raw.c b/Engine/lib/libsndfile/src/raw.c deleted file mode 100644 index c8fcbfde2..000000000 --- a/Engine/lib/libsndfile/src/raw.c +++ /dev/null @@ -1,111 +0,0 @@ -/* -** Copyright (C) 1999-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include - -#include "sndfile.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -raw_open (SF_PRIVATE *psf) -{ int subformat, error = SFE_NO_ERROR ; - - subformat = SF_CODEC (psf->sf.format) ; - - psf->endian = SF_ENDIAN (psf->sf.format) ; - - if (CPU_IS_BIG_ENDIAN && (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU)) - psf->endian = SF_ENDIAN_BIG ; - else if (CPU_IS_LITTLE_ENDIAN && (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU)) - psf->endian = SF_ENDIAN_LITTLE ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - psf->dataoffset = 0 ; - psf->datalength = psf->filelength ; - - switch (subformat) - { case SF_FORMAT_PCM_S8 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_PCM_U8 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_ULAW : - error = ulaw_init (psf) ; - break ; - - case SF_FORMAT_ALAW : - error = alaw_init (psf) ; - break ; - - case SF_FORMAT_GSM610 : - error = gsm610_init (psf) ; - break ; - - /* Lite remove start */ - - case SF_FORMAT_NMS_ADPCM_16 : - case SF_FORMAT_NMS_ADPCM_24 : - case SF_FORMAT_NMS_ADPCM_32 : - error = nms_adpcm_init (psf) ; - break ; - - case SF_FORMAT_FLOAT : - error = float32_init (psf) ; - break ; - - case SF_FORMAT_DOUBLE : - error = double64_init (psf) ; - break ; - - case SF_FORMAT_DWVW_12 : - error = dwvw_init (psf, 12) ; - break ; - - case SF_FORMAT_DWVW_16 : - error = dwvw_init (psf, 16) ; - break ; - - case SF_FORMAT_DWVW_24 : - error = dwvw_init (psf, 24) ; - break ; - - case SF_FORMAT_VOX_ADPCM : - error = vox_adpcm_init (psf) ; - break ; - /* Lite remove end */ - - default : return SFE_BAD_OPEN_FORMAT ; - } ; - - return error ; -} /* raw_open */ diff --git a/Engine/lib/libsndfile/src/rf64.c b/Engine/lib/libsndfile/src/rf64.c deleted file mode 100644 index 123db445a..000000000 --- a/Engine/lib/libsndfile/src/rf64.c +++ /dev/null @@ -1,894 +0,0 @@ -/* -** Copyright (C) 2008-2018 Erik de Castro Lopo -** Copyright (C) 2009 Uli Franke -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** This format documented at: -** http://www.sr.se/utveckling/tu/bwf/prog/RF_64v1_4.pdf -** -** But this may be a better reference: -** http://www.ebu.ch/CMSimages/en/tec_doc_t3306-2007_tcm6-42570.pdf -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "wavlike.h" - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues. -*/ -#define RF64_MARKER MAKE_MARKER ('R', 'F', '6', '4') -#define RIFF_MARKER MAKE_MARKER ('R', 'I', 'F', 'F') -#define JUNK_MARKER MAKE_MARKER ('J', 'U', 'N', 'K') -#define FFFF_MARKER MAKE_MARKER (0xff, 0xff, 0xff, 0xff) -#define WAVE_MARKER MAKE_MARKER ('W', 'A', 'V', 'E') -#define ds64_MARKER MAKE_MARKER ('d', 's', '6', '4') -#define fmt_MARKER MAKE_MARKER ('f', 'm', 't', ' ') -#define fact_MARKER MAKE_MARKER ('f', 'a', 'c', 't') -#define data_MARKER MAKE_MARKER ('d', 'a', 't', 'a') - -#define bext_MARKER MAKE_MARKER ('b', 'e', 'x', 't') -#define cart_MARKER MAKE_MARKER ('c', 'a', 'r', 't') -#define OggS_MARKER MAKE_MARKER ('O', 'g', 'g', 'S') -#define wvpk_MARKER MAKE_MARKER ('w', 'v', 'p', 'k') -#define LIST_MARKER MAKE_MARKER ('L', 'I', 'S', 'T') - -/* -** The file size limit in bytes below which we can, if requested, write this -** file as a RIFF/WAVE file. -*/ - -#define RIFF_DOWNGRADE_BYTES ((sf_count_t) 0xffffffff) - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) ; -static int rf64_write_header (SF_PRIVATE *psf, int calc_length) ; -static int rf64_write_tailer (SF_PRIVATE *psf) ; -static int rf64_close (SF_PRIVATE *psf) ; -static int rf64_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize) ; - -static int rf64_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) ; -static SF_CHUNK_ITERATOR * rf64_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) ; -static int rf64_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; -static int rf64_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -rf64_open (SF_PRIVATE *psf) -{ WAVLIKE_PRIVATE *wpriv ; - int subformat, error = 0 ; - int blockalign, framesperblock ; - - if ((wpriv = calloc (1, sizeof (WAVLIKE_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - psf->container_data = wpriv ; - wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ; - - /* All RF64 files are little endian. */ - psf->endian = SF_ENDIAN_LITTLE ; - - psf->strings.flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = rf64_read_header (psf, &blockalign, &framesperblock)) != 0) - return error ; - - psf->next_chunk_iterator = rf64_next_chunk_iterator ; - psf->get_chunk_size = rf64_get_chunk_size ; - psf->get_chunk_data = rf64_get_chunk_data ; - } ; - - if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RF64) - return SFE_BAD_OPEN_FORMAT ; - - subformat = psf->sf.format & SF_FORMAT_SUBMASK ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (psf->is_pipe) - return SFE_NO_PIPE_WRITE ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - if ((error = rf64_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = rf64_write_header ; - psf->set_chunk = rf64_set_chunk ; - } ; - - psf->container_close = rf64_close ; - psf->command = rf64_command ; - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_ULAW : - error = ulaw_init (psf) ; - break ; - - case SF_FORMAT_ALAW : - error = alaw_init (psf) ; - break ; - - /* Lite remove start */ - case SF_FORMAT_FLOAT : - error = float32_init (psf) ; - break ; - - case SF_FORMAT_DOUBLE : - error = double64_init (psf) ; - break ; - - /* Lite remove end */ - - default : return SFE_UNIMPLEMENTED ; - } ; - - return error ; -} /* rf64_open */ - -/*------------------------------------------------------------------------------ -*/ -enum -{ HAVE_ds64 = 0x01, - HAVE_fmt = 0x02, - HAVE_bext = 0x04, - HAVE_data = 0x08, - HAVE_cart = 0x10, - HAVE_PEAK = 0x20, - HAVE_other = 0x40 -} ; - -#define HAVE_CHUNK(CHUNK) ((parsestage & CHUNK) != 0) - -static int -rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) -{ WAVLIKE_PRIVATE *wpriv ; - WAV_FMT *wav_fmt ; - sf_count_t riff_size = 0, frame_count = 0, ds64_datalength = 0 ; - uint32_t marks [2], marker, chunk_size, parsestage = 0 ; - int error, done = 0, format = 0 ; - - if ((wpriv = psf->container_data) == NULL) - return SFE_INTERNAL ; - wav_fmt = &wpriv->wav_fmt ; - - /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "pmmm", 0, &marker, marks, marks + 1) ; - if (marker != RF64_MARKER || marks [1] != WAVE_MARKER) - return SFE_RF64_NOT_RF64 ; - - if (marks [0] == FFFF_MARKER) - psf_log_printf (psf, "%M\n %M\n", RF64_MARKER, WAVE_MARKER) ; - else - psf_log_printf (psf, "%M : 0x%x (should be 0xFFFFFFFF)\n %M\n", RF64_MARKER, WAVE_MARKER) ; - - while (!done) - { - marker = chunk_size = 0 ; - psf_binheader_readf (psf, "em4", &marker, &chunk_size) ; - - if (marker == 0) - { sf_count_t pos = psf_ftell (psf) ; - psf_log_printf (psf, "Have 0 marker at position %D (0x%x).\n", pos, pos) ; - break ; - } ; - - psf_store_read_chunk_u32 (&psf->rchunks, marker, psf_ftell (psf), chunk_size) ; - - switch (marker) - { case ds64_MARKER : - if (parsestage & HAVE_ds64) - { psf_log_printf (psf, "*** Second 'ds64' chunk?\n") ; - break ; - } ; - - { unsigned int table_len, bytesread ; - - /* Read ds64 sizes (3 8-byte words). */ - bytesread = psf_binheader_readf (psf, "888", &riff_size, &ds64_datalength, &frame_count) ; - - /* Read table length. */ - bytesread += psf_binheader_readf (psf, "4", &table_len) ; - /* Skip table for now. (this was "table_len + 4", why?) */ - bytesread += psf_binheader_readf (psf, "j", table_len) ; - - if (chunk_size == bytesread) - psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; - else if (chunk_size >= bytesread + 4) - { unsigned int next ; - psf_binheader_readf (psf, "m", &next) ; - if (next == fmt_MARKER) - { psf_log_printf (psf, "%M : %u (should be %u)\n", marker, chunk_size, bytesread) ; - psf_binheader_readf (psf, "j", -4) ; - } - else - { psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size - bytesread - 4) ; - } ; - } ; - - if (psf->filelength != riff_size + 8) - psf_log_printf (psf, " Riff size : %D (should be %D)\n", riff_size, psf->filelength - 8) ; - else - psf_log_printf (psf, " Riff size : %D\n", riff_size) ; - - psf_log_printf (psf, " Data size : %D\n", ds64_datalength) ; - - psf_log_printf (psf, " Frames : %D\n", frame_count) ; - psf_log_printf (psf, " Table length : %u\n", table_len) ; - - } ; - parsestage |= HAVE_ds64 ; - break ; - - case fmt_MARKER: - psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; - if ((error = wavlike_read_fmt_chunk (psf, chunk_size)) != 0) - return error ; - format = wav_fmt->format ; - parsestage |= HAVE_fmt ; - break ; - - case bext_MARKER : - if ((error = wavlike_read_bext_chunk (psf, chunk_size)) != 0) - return error ; - parsestage |= HAVE_bext ; - break ; - - case cart_MARKER : - if ((error = wavlike_read_cart_chunk (psf, chunk_size)) != 0) - return error ; - parsestage |= HAVE_cart ; - break ; - - case INFO_MARKER : - case LIST_MARKER : - if ((error = wavlike_subchunk_parse (psf, marker, chunk_size)) != 0) - return error ; - parsestage |= HAVE_other ; - break ; - - case PEAK_MARKER : - if ((parsestage & (HAVE_ds64 | HAVE_fmt)) != (HAVE_ds64 | HAVE_fmt)) - return SFE_RF64_PEAK_B4_FMT ; - - parsestage |= HAVE_PEAK ; - - psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; - if ((error = wavlike_read_peak_chunk (psf, chunk_size)) != 0) - return error ; - psf->peak_info->peak_loc = ((parsestage & HAVE_data) == 0) ? SF_PEAK_START : SF_PEAK_END ; - break ; - - case data_MARKER : - /* see wav for more sophisticated parsing -> implement state machine with parsestage */ - - if (HAVE_CHUNK (HAVE_ds64)) - { if (chunk_size == 0xffffffff) - psf_log_printf (psf, "%M : 0x%x\n", marker, chunk_size) ; - else - psf_log_printf (psf, "%M : 0x%x (should be 0xffffffff\n", marker, chunk_size) ; - psf->datalength = ds64_datalength ; - } - else - { if (chunk_size == 0xffffffff) - { psf_log_printf (psf, "%M : 0x%x\n", marker, chunk_size) ; - psf_log_printf (psf, " *** Data length not specified no 'ds64' chunk.\n") ; - } - else - { psf_log_printf (psf, "%M : 0x%x\n**** Weird, RF64 file without a 'ds64' chunk and no valid 'data' size.\n", marker, chunk_size) ; - psf->datalength = chunk_size ; - } ; - } ; - - psf->dataoffset = psf_ftell (psf) ; - - if (psf->dataoffset > 0) - { if (chunk_size == 0 && riff_size == 8 && psf->filelength > 44) - { psf_log_printf (psf, " *** Looks like a WAV file which wasn't closed properly. Fixing it.\n") ; - psf->datalength = psf->filelength - psf->dataoffset ; - } ; - - /* Only set dataend if there really is data at the end. */ - if (psf->datalength + psf->dataoffset < psf->filelength) - psf->dataend = psf->datalength + psf->dataoffset ; - - if (!psf->sf.seekable || psf->dataoffset < 0) - break ; - - /* Seek past data and continue reading header. */ - psf_fseek (psf, psf->datalength, SEEK_CUR) ; - - if (psf_ftell (psf) != psf->datalength + psf->dataoffset) - psf_log_printf (psf, " *** psf_fseek past end error ***\n") ; - } ; - break ; - - case JUNK_MARKER : - case PAD_MARKER : - psf_log_printf (psf, "%M : %d\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - - default : - if (chunk_size >= 0xffff0000) - { psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D with length %u. Exiting parser.\n", marker, psf_ftell (psf) - 8, chunk_size) ; - done = SF_TRUE ; - break ; - } ; - - if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF) - && isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF)) - { psf_log_printf (psf, "*** %M : %d (unknown marker)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - } ; - if (psf_ftell (psf) & 0x03) - { psf_log_printf (psf, " Unknown chunk marker at position 0x%x. Resynching.\n", chunk_size - 4) ; - psf_binheader_readf (psf, "j", -3) ; - break ; - } ; - psf_log_printf (psf, "*** Unknown chunk marker (0x%X) at position 0x%X. Exiting parser.\n", marker, psf_ftell (psf) - 4) ; - done = SF_TRUE ; - break ; - } ; /* switch (marker) */ - - /* The 'data' chunk, a chunk size of 0xffffffff means that the 'data' chunk size - ** is actually given by the ds64_datalength field. - */ - if (marker != data_MARKER && chunk_size >= psf->filelength) - { psf_log_printf (psf, "*** Chunk size %u > file length %D. Exiting parser.\n", chunk_size, psf->filelength) ; - break ; - } ; - - if (psf_ftell (psf) >= psf->filelength - SIGNED_SIZEOF (marker)) - { psf_log_printf (psf, "End\n") ; - break ; - } ; - } ; - - if (psf->dataoffset <= 0) - return SFE_RF64_NO_DATA ; - - if (psf->sf.channels < 1) - return SFE_CHANNEL_COUNT_ZERO ; - - if (psf->sf.channels > SF_MAX_CHANNELS) - return SFE_CHANNEL_COUNT ; - - /* WAVs can be little or big endian */ - psf->endian = psf->rwf_endian ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - if (psf->is_pipe == 0) - { /* - ** Check for 'wvpk' at the start of the DATA section. Not able to - ** handle this. - */ - psf_binheader_readf (psf, "4", &marker) ; - if (marker == wvpk_MARKER || marker == OggS_MARKER) - return SFE_WAV_WVPK_DATA ; - } ; - - /* Seek to start of DATA section. */ - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - if (psf->blockwidth) - { if (psf->filelength - psf->dataoffset < psf->datalength) - psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - else - psf->sf.frames = psf->datalength / psf->blockwidth ; - } ; - - if (frame_count != psf->sf.frames) - psf_log_printf (psf, "*** Calculated frame count %d does not match value from 'ds64' chunk of %d.\n", psf->sf.frames, frame_count) ; - - switch (format) - { - case WAVE_FORMAT_EXTENSIBLE : - - /* with WAVE_FORMAT_EXTENSIBLE the psf->sf.format field is already set. We just have to set the major to rf64 */ - psf->sf.format = (psf->sf.format & ~SF_FORMAT_TYPEMASK) | SF_FORMAT_RF64 ; - - if (psf->sf.format == (SF_FORMAT_WAVEX | SF_FORMAT_MS_ADPCM)) - { *blockalign = wav_fmt->msadpcm.blockalign ; - *framesperblock = wav_fmt->msadpcm.samplesperblock ; - } ; - break ; - - case WAVE_FORMAT_PCM : - psf->sf.format = SF_FORMAT_RF64 | u_bitwidth_to_subformat (psf->bytewidth * 8) ; - break ; - - case WAVE_FORMAT_MULAW : - case IBM_FORMAT_MULAW : - psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_ULAW) ; - break ; - - case WAVE_FORMAT_ALAW : - case IBM_FORMAT_ALAW : - psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_ALAW) ; - break ; - - case WAVE_FORMAT_MS_ADPCM : - psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_MS_ADPCM) ; - *blockalign = wav_fmt->msadpcm.blockalign ; - *framesperblock = wav_fmt->msadpcm.samplesperblock ; - break ; - - case WAVE_FORMAT_IMA_ADPCM : - psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_IMA_ADPCM) ; - *blockalign = wav_fmt->ima.blockalign ; - *framesperblock = wav_fmt->ima.samplesperblock ; - break ; - - case WAVE_FORMAT_GSM610 : - psf->sf.format = (SF_FORMAT_RF64 | SF_FORMAT_GSM610) ; - break ; - - case WAVE_FORMAT_IEEE_FLOAT : - psf->sf.format = SF_FORMAT_RF64 ; - psf->sf.format |= (psf->bytewidth == 8) ? SF_FORMAT_DOUBLE : SF_FORMAT_FLOAT ; - break ; - - case WAVE_FORMAT_G721_ADPCM : - psf->sf.format = SF_FORMAT_RF64 | SF_FORMAT_G721_32 ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - if (wpriv->fmt_is_broken) - wavlike_analyze (psf) ; - - /* Only set the format endian-ness if its non-standard big-endian. */ - if (psf->endian == SF_ENDIAN_BIG) - psf->sf.format |= SF_ENDIAN_BIG ; - - return 0 ; -} /* rf64_read_header */ - -/* known WAVEFORMATEXTENSIBLE GUIDS */ -static const EXT_SUBFORMAT MSGUID_SUBTYPE_PCM = -{ 0x00000001, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -#if 0 -static const EXT_SUBFORMAT MSGUID_SUBTYPE_MS_ADPCM = -{ 0x00000002, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; -#endif - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_IEEE_FLOAT = -{ 0x00000003, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_ALAW = -{ 0x00000006, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_MULAW = -{ 0x00000007, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -/* -** the next two are from -** http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html -*/ -static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM = -{ 0x00000001, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT = -{ 0x00000003, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 } -} ; - - -static int -rf64_write_fmt_chunk (SF_PRIVATE *psf) -{ WAVLIKE_PRIVATE *wpriv ; - int subformat, fmt_size ; - - if ((wpriv = psf->container_data) == NULL) - return SFE_INTERNAL ; - - subformat = psf->sf.format & SF_FORMAT_SUBMASK ; - - /* initial section (same for all, it appears) */ - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - case SF_FORMAT_ULAW : - case SF_FORMAT_ALAW : - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 + 4 + 4 + 2 + 2 + 8 ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "4224", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_EXTENSIBLE), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "22", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (psf->bytewidth * 8)) ; - - /* cbSize 22 is sizeof (WAVEFORMATEXTENSIBLE) - sizeof (WAVEFORMATEX) */ - psf_binheader_writef (psf, "2", BHW2 (22)) ; - - /* wValidBitsPerSample, for our use same as bitwidth as we use it fully */ - psf_binheader_writef (psf, "2", BHW2 (psf->bytewidth * 8)) ; - - /* For an Ambisonic file set the channel mask to zero. - ** Otherwise use a default based on the channel count. - */ - if (wpriv->wavex_ambisonic != SF_AMBISONIC_NONE) - psf_binheader_writef (psf, "4", BHW4 (0)) ; - else if (wpriv->wavex_channelmask != 0) - psf_binheader_writef (psf, "4", BHW4 (wpriv->wavex_channelmask)) ; - else - { /* - ** Ok some liberty is taken here to use the most commonly used channel masks - ** instead of "no mapping". If you really want to use "no mapping" for 8 channels and less - ** please don't use wavex. (otherwise we'll have to create a new SF_COMMAND) - */ - switch (psf->sf.channels) - { case 1 : /* center channel mono */ - psf_binheader_writef (psf, "4", BHW4 (0x4)) ; - break ; - - case 2 : /* front left and right */ - psf_binheader_writef (psf, "4", BHW4 (0x1 | 0x2)) ; - break ; - - case 4 : /* Quad */ - psf_binheader_writef (psf, "4", BHW4 (0x1 | 0x2 | 0x10 | 0x20)) ; - break ; - - case 6 : /* 5.1 */ - psf_binheader_writef (psf, "4", BHW4 (0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20)) ; - break ; - - case 8 : /* 7.1 */ - psf_binheader_writef (psf, "4", BHW4 (0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x80)) ; - break ; - - default : /* 0 when in doubt , use direct out, ie NO mapping*/ - psf_binheader_writef (psf, "4", BHW4 (0x0)) ; - break ; - } ; - } ; - break ; - - case SF_FORMAT_MS_ADPCM : /* Todo, GUID exists might have different header as per wav_write_header */ - default : - return SFE_UNIMPLEMENTED ; - } ; - - /* GUID section, different for each */ - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - wavlike_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ? - &MSGUID_SUBTYPE_PCM : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM) ; - break ; - - case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - wavlike_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ? - &MSGUID_SUBTYPE_IEEE_FLOAT : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT) ; - break ; - - case SF_FORMAT_ULAW : - wavlike_write_guid (psf, &MSGUID_SUBTYPE_MULAW) ; - break ; - - case SF_FORMAT_ALAW : - wavlike_write_guid (psf, &MSGUID_SUBTYPE_ALAW) ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - return 0 ; -} /* rf64_write_fmt_chunk */ - - -static int -rf64_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t current, pad_size ; - int error = 0, has_data = SF_FALSE, add_fact_chunk = 0 ; - WAVLIKE_PRIVATE *wpriv ; - - if ((wpriv = psf->container_data) == NULL) - return SFE_INTERNAL ; - - current = psf_ftell (psf) ; - - if (psf->dataoffset > 0 && current > psf->dataoffset) - has_data = SF_TRUE ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - psf->datalength = psf->filelength - psf->dataoffset ; - - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - if (psf->bytewidth > 0) - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - if (wpriv->rf64_downgrade && psf->filelength < RIFF_DOWNGRADE_BYTES) - { psf_binheader_writef (psf, "etm8m", BHWm (RIFF_MARKER), BHW8 ((psf->filelength < 8) ? 8 : psf->filelength - 8), BHWm (WAVE_MARKER)) ; - psf_binheader_writef (psf, "m4z", BHWm (JUNK_MARKER), BHW4 (24), BHWz (24)) ; - add_fact_chunk = 1 ; - } - else - { psf_binheader_writef (psf, "em4m", BHWm (RF64_MARKER), BHW4 (0xffffffff), BHWm (WAVE_MARKER)) ; - /* Currently no table. */ - psf_binheader_writef (psf, "m48884", BHWm (ds64_MARKER), BHW4 (28), BHW8 (psf->filelength - 8), BHW8 (psf->datalength), BHW8 (psf->sf.frames), BHW4 (0)) ; - } ; - - /* WAVE and 'fmt ' markers. */ - psf_binheader_writef (psf, "m", BHWm (fmt_MARKER)) ; - - /* Write the 'fmt ' chunk. */ - switch (psf->sf.format & SF_FORMAT_TYPEMASK) - { case SF_FORMAT_WAV : - psf_log_printf (psf, "ooops SF_FORMAT_WAV\n") ; - return SFE_UNIMPLEMENTED ; - break ; - - case SF_FORMAT_WAVEX : - case SF_FORMAT_RF64 : - if ((error = rf64_write_fmt_chunk (psf)) != 0) - return error ; - if (add_fact_chunk) - psf_binheader_writef (psf, "tm48", BHWm (fact_MARKER), BHW4 (4), BHW8 (psf->sf.frames)) ; - break ; - - default : - return SFE_UNIMPLEMENTED ; - } ; - - if (psf->broadcast_16k != NULL) - wavlike_write_bext_chunk (psf) ; - - if (psf->cart_16k != NULL) - wavlike_write_cart_chunk (psf) ; - - /* The LIST/INFO chunk. */ - if (psf->strings.flags & SF_STR_LOCATE_START) - wavlike_write_strings (psf, SF_STR_LOCATE_START) ; - - if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_START) - wavlike_write_peak_chunk (psf) ; - - /* Write custom headers. */ - if (psf->wchunks.used > 0) - wavlike_write_custom_chunks (psf) ; - -#if 0 - if (psf->instrument != NULL) - { int tmp ; - double dtune = (double) (0x40000000) / 25.0 ; - - psf_binheader_writef (psf, "m4", BHWm (smpl_MARKER), BHW4 (9 * 4 + psf->instrument->loop_count * 6 * 4)) ; - psf_binheader_writef (psf, "44", BHW4 (0), BHW4 (0)) ; /* Manufacturer zero is everyone */ - tmp = (int) (1.0e9 / psf->sf.samplerate) ; /* Sample period in nano seconds */ - psf_binheader_writef (psf, "44", BHW4 (tmp), BHW4 (psf->instrument->basenote)) ; - tmp = (unsigned int) (psf->instrument->detune * dtune + 0.5) ; - psf_binheader_writef (psf, "4", BHW4 (tmp)) ; - psf_binheader_writef (psf, "44", BHW4 (0), BHW4 (0)) ; /* SMTPE format */ - psf_binheader_writef (psf, "44", BHW4 (psf->instrument->loop_count), BHW4 (0)) ; - - for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++) - { int type ; - - type = psf->instrument->loops [tmp].mode ; - type = (type == SF_LOOP_FORWARD ? 0 : type == SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ; - - psf_binheader_writef (psf, "44", BHW4 (tmp), BHW4 (type)) ; - psf_binheader_writef (psf, "44", BHW4 (psf->instrument->loops [tmp].start), BHW4 (psf->instrument->loops [tmp].end)) ; - psf_binheader_writef (psf, "44", BHW4 (0), BHW4 (psf->instrument->loops [tmp].count)) ; - } ; - } ; - -#endif - - /* Padding may be needed if string data sizes change. */ - pad_size = psf->dataoffset - 16 - psf->header.indx ; - if (pad_size >= 0) - psf_binheader_writef (psf, "m4z", BHWm (PAD_MARKER), BHW4 ((unsigned int) pad_size), BHWz (pad_size)) ; - - if (wpriv->rf64_downgrade && (psf->filelength < RIFF_DOWNGRADE_BYTES)) - psf_binheader_writef (psf, "tm8", BHWm (data_MARKER), BHW8 (psf->datalength)) ; - else - psf_binheader_writef (psf, "m4", BHWm (data_MARKER), BHW4 (0xffffffff)) ; - - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - if (psf->error) - return psf->error ; - - if (has_data && psf->dataoffset != psf->header.indx) - { psf_log_printf (psf, "Oooops : has_data && psf->dataoffset != psf->header.indx\n") ; - return psf->error = SFE_INTERNAL ; - } ; - - psf->dataoffset = psf->header.indx ; - - if (!has_data) - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - else if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* rf64_write_header */ - -static int -rf64_write_tailer (SF_PRIVATE *psf) -{ - /* Reset the current header buffer length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - if (psf->bytewidth > 0 && psf->sf.seekable == SF_TRUE) - { psf->datalength = psf->sf.frames * psf->bytewidth * psf->sf.channels ; - psf->dataend = psf->dataoffset + psf->datalength ; - } ; - - if (psf->dataend > 0) - psf_fseek (psf, psf->dataend, SEEK_SET) ; - else - psf->dataend = psf_fseek (psf, 0, SEEK_END) ; - - if (psf->dataend & 1) - psf_binheader_writef (psf, "z", BHWz (1)) ; - - if (psf->strings.flags & SF_STR_LOCATE_END) - wavlike_write_strings (psf, SF_STR_LOCATE_END) ; - - /* Write the tailer. */ - if (psf->header.indx > 0) - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - return 0 ; -} /* rf64_write_tailer */ - -static int -rf64_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { rf64_write_tailer (psf) ; - rf64_write_header (psf, SF_TRUE) ; - } ; - - return 0 ; -} /* rf64_close */ - -static int -rf64_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize) -{ WAVLIKE_PRIVATE *wpriv ; - - if ((wpriv = psf->container_data) == NULL) - return SFE_INTERNAL ; - - switch (command) - { case SFC_WAVEX_SET_AMBISONIC : - if ((SF_CONTAINER (psf->sf.format)) == SF_FORMAT_WAVEX) - { if (datasize == SF_AMBISONIC_NONE) - wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ; - else if (datasize == SF_AMBISONIC_B_FORMAT) - wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ; - else - return 0 ; - } ; - return wpriv->wavex_ambisonic ; - - case SFC_WAVEX_GET_AMBISONIC : - return wpriv->wavex_ambisonic ; - - case SFC_SET_CHANNEL_MAP_INFO : - wpriv->wavex_channelmask = wavlike_gen_channel_mask (psf->channel_map, psf->sf.channels) ; - return (wpriv->wavex_channelmask != 0) ; - - case SFC_RF64_AUTO_DOWNGRADE : - if (psf->have_written == 0) - wpriv->rf64_downgrade = datasize ? SF_TRUE : SF_FALSE ; - return wpriv->rf64_downgrade ; - - default : - break ; - } ; - - return 0 ; -} /* rf64_command */ - -static int -rf64_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) -{ return psf_save_write_chunk (&psf->wchunks, chunk_info) ; -} /* rf64_set_chunk */ - -static SF_CHUNK_ITERATOR * -rf64_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) -{ return psf_next_chunk_iterator (&psf->rchunks, iterator) ; -} /* rf64_next_chunk_iterator */ - -static int -rf64_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ int indx ; - - if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) - return SFE_UNKNOWN_CHUNK ; - - chunk_info->datalen = psf->rchunks.chunks [indx].len ; - - return SFE_NO_ERROR ; -} /* rf64_get_chunk_size */ - -static int -rf64_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ int indx ; - sf_count_t pos ; - - if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) - return SFE_UNKNOWN_CHUNK ; - - if (chunk_info->data == NULL) - return SFE_BAD_CHUNK_DATA_PTR ; - - chunk_info->id_size = psf->rchunks.chunks [indx].id_size ; - memcpy (chunk_info->id, psf->rchunks.chunks [indx].id, sizeof (chunk_info->id) / sizeof (*chunk_info->id)) ; - - pos = psf_ftell (psf) ; - psf_fseek (psf, psf->rchunks.chunks [indx].offset, SEEK_SET) ; - psf_fread (chunk_info->data, SF_MIN (chunk_info->datalen, psf->rchunks.chunks [indx].len), 1, psf) ; - psf_fseek (psf, pos, SEEK_SET) ; - - return SFE_NO_ERROR ; -} /* rf64_get_chunk_data */ diff --git a/Engine/lib/libsndfile/src/rx2.c b/Engine/lib/libsndfile/src/rx2.c deleted file mode 100644 index 0a730480e..000000000 --- a/Engine/lib/libsndfile/src/rx2.c +++ /dev/null @@ -1,318 +0,0 @@ -/* -** Copyright (C) 2001-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if (ENABLE_EXPERIMENTAL_CODE == 0) - -int -rx2_open (SF_PRIVATE *psf) -{ if (psf) - return SFE_UNIMPLEMENTED ; - return 0 ; -} /* rx2_open */ - -#else - -/*------------------------------------------------------------------------------ - * Macros to handle big/little endian issues. -*/ - -#define CAT_MARKER (MAKE_MARKER ('C', 'A', 'T', ' ')) -#define GLOB_MARKER (MAKE_MARKER ('G', 'L', 'O', 'B')) - -#define RECY_MARKER (MAKE_MARKER ('R', 'E', 'C', 'Y')) - -#define SLCL_MARKER (MAKE_MARKER ('S', 'L', 'C', 'L')) -#define SLCE_MARKER (MAKE_MARKER ('S', 'L', 'C', 'E')) - -#define DEVL_MARKER (MAKE_MARKER ('D', 'E', 'V', 'L')) -#define TRSH_MARKER (MAKE_MARKER ('T', 'R', 'S', 'H')) - -#define EQ_MARKER (MAKE_MARKER ('E', 'Q', ' ', ' ')) -#define COMP_MARKER (MAKE_MARKER ('C', 'O', 'M', 'P')) - -#define SINF_MARKER (MAKE_MARKER ('S', 'I', 'N', 'F')) -#define SDAT_MARKER (MAKE_MARKER ('S', 'D', 'A', 'T')) - -/*------------------------------------------------------------------------------ - * Typedefs for file chunks. -*/ - - -/*------------------------------------------------------------------------------ - * Private static functions. -*/ -static int rx2_close (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public functions. -*/ - -int -rx2_open (SF_PRIVATE *psf) -{ static const char *marker_type [4] = - { "Original Enabled", "Enabled Hidden", - "Additional/PencilTool", "Disabled" - } ; - - BUF_UNION ubuf ; - int error, marker, length, glob_offset, slce_count, frames ; - int sdat_length = 0, slce_total = 0 ; - int n_channels ; - - - /* So far only doing read. */ - - psf_binheader_readf (psf, "Epm4", 0, &marker, &length) ; - - if (marker != CAT_MARKER) - { psf_log_printf (psf, "length : %d\n", length) ; - return -1000 ; - } ; - - if (length != psf->filelength - 8) - psf_log_printf (psf, "%M : %d (should be %d)\n", marker, length, psf->filelength - 8) ; - else - psf_log_printf (psf, "%M : %d\n", marker, length) ; - - /* 'REX2' marker */ - psf_binheader_readf (psf, "m", &marker) ; - psf_log_printf (psf, "%M", marker) ; - - /* 'HEAD' marker */ - psf_binheader_readf (psf, "m", &marker) ; - psf_log_printf (psf, "%M\n", marker) ; - - /* Grab 'GLOB' offset. */ - psf_binheader_readf (psf, "E4", &glob_offset) ; - glob_offset += 0x14 ; /* Add the current file offset. */ - - /* Jump to offset 0x30 */ - psf_binheader_readf (psf, "p", 0x30) ; - - /* Get name length */ - length = 0 ; - psf_binheader_readf (psf, "1", &length) ; - if (length >= SIGNED_SIZEOF (ubuf.cbuf)) - { psf_log_printf (psf, " Text : %d *** Error : Too sf_count_t!\n") ; - return -1001 ; - } - - memset (ubuf.cbuf, 0, sizeof (ubuf.cbuf)) ; - psf_binheader_readf (psf, "b", ubuf.cbuf, length) ; - psf_log_printf (psf, " Text : \"%s\"\n", ubuf.cbuf) ; - - /* Jump to GLOB offset position. */ - if (glob_offset & 1) - glob_offset ++ ; - - psf_binheader_readf (psf, "p", glob_offset) ; - - slce_count = 0 ; - /* GLOB */ - while (1) - { psf_binheader_readf (psf, "m", &marker) ; - - if (marker != SLCE_MARKER && slce_count > 0) - { psf_log_printf (psf, " SLCE count : %d\n", slce_count) ; - slce_count = 0 ; - } - switch (marker) - { case GLOB_MARKER: - psf_binheader_readf (psf, "E4", &length) ; - psf_log_printf (psf, " %M : %d\n", marker, length) ; - psf_binheader_readf (psf, "j", length) ; - break ; - - case RECY_MARKER: - psf_binheader_readf (psf, "E4", &length) ; - psf_log_printf (psf, " %M : %d\n", marker, length) ; - psf_binheader_readf (psf, "j", (length+1) & 0xFFFFFFFE) ; /* ?????? */ - break ; - - case CAT_MARKER: - psf_binheader_readf (psf, "E4", &length) ; - psf_log_printf (psf, " %M : %d\n", marker, length) ; - /*-psf_binheader_readf (psf, "j", length) ;-*/ - break ; - - case DEVL_MARKER: - psf_binheader_readf (psf, "mE4", &marker, &length) ; - psf_log_printf (psf, " DEVL%M : %d\n", marker, length) ; - if (length & 1) - length ++ ; - psf_binheader_readf (psf, "j", length) ; - break ; - - case EQ_MARKER: - case COMP_MARKER: - psf_binheader_readf (psf, "E4", &length) ; - psf_log_printf (psf, " %M : %d\n", marker, length) ; - /* This is weird!!!! why make this (length - 1) */ - if (length & 1) - length ++ ; - psf_binheader_readf (psf, "j", length) ; - break ; - - case SLCL_MARKER: - psf_log_printf (psf, " %M\n (Offset, Next Offset, Type)\n", marker) ; - slce_count = 0 ; - break ; - - case SLCE_MARKER: - { int len [4], indx ; - - psf_binheader_readf (psf, "E4444", &len [0], &len [1], &len [2], &len [3]) ; - - indx = ((len [3] & 0x0000FFFF) >> 8) & 3 ; - - if (len [2] == 1) - { if (indx != 1) - indx = 3 ; /* 2 cases, where next slice offset = 1 -> disabled & enabled/hidden */ - - psf_log_printf (psf, " %M : (%6d, ?: 0x%X, %s)\n", marker, len [1], (len [3] & 0xFFFF0000) >> 16, marker_type [indx]) ; - } - else - { slce_total += len [2] ; - - psf_log_printf (psf, " %M : (%6d, SLCE_next_ofs:%d, ?: 0x%X, %s)\n", marker, len [1], len [2], (len [3] & 0xFFFF0000) >> 16, marker_type [indx]) ; - } ; - - slce_count ++ ; - } ; - break ; - - case SINF_MARKER: - psf_binheader_readf (psf, "E4", &length) ; - psf_log_printf (psf, " %M : %d\n", marker, length) ; - - psf_binheader_readf (psf, "E2", &n_channels) ; - n_channels = (n_channels & 0x0000FF00) >> 8 ; - psf_log_printf (psf, " Channels : %d\n", n_channels) ; - - psf_binheader_readf (psf, "E44", &psf->sf.samplerate, &frames) ; - psf->sf.frames = frames ; - psf_log_printf (psf, " Sample Rate : %d\n", psf->sf.samplerate) ; - psf_log_printf (psf, " Frames : %D\n", psf->sf.frames) ; - - psf_binheader_readf (psf, "E4", &length) ; - psf_log_printf (psf, " ??????????? : %d\n", length) ; - - psf_binheader_readf (psf, "E4", &length) ; - psf_log_printf (psf, " ??????????? : %d\n", length) ; - break ; - - case SDAT_MARKER: - psf_binheader_readf (psf, "E4", &length) ; - - sdat_length = length ; - - /* Get the current offset. */ - psf->dataoffset = psf_binheader_readf (psf, NULL) ; - - if (psf->dataoffset + length != psf->filelength) - psf_log_printf (psf, " %M : %d (should be %d)\n", marker, length, psf->dataoffset + psf->filelength) ; - else - psf_log_printf (psf, " %M : %d\n", marker, length) ; - break ; - - default : - psf_log_printf (psf, "Unknown marker : 0x%X %M", marker, marker) ; - return -1003 ; - break ; - } ; - - /* SDAT always last marker in file. */ - if (marker == SDAT_MARKER) - break ; - } ; - - puts (psf->parselog.buf) ; - puts ("-----------------------------------") ; - - printf ("SDAT length : %d\n", sdat_length) ; - printf ("SLCE count : %d\n", slce_count) ; - - /* Hack for zero slice count. */ - if (slce_count == 0 && slce_total == 1) - slce_total = frames ; - - printf ("SLCE samples : %d\n", slce_total) ; - - /* Two bytes per sample. */ - printf ("Comp Ratio : %f:1\n", (2.0 * slce_total * n_channels) / sdat_length) ; - - puts (" ") ; - - psf->parselog.buf [0] = 0 ; - - /* OK, have the header although not too sure what it all means. */ - - psf->endian = SF_ENDIAN_BIG ; - - psf->datalength = psf->filelength - psf->dataoffset ; - - if (psf_fseek (psf, psf->dataoffset, SEEK_SET)) - return SFE_BAD_SEEK ; - - psf->sf.format = (SF_FORMAT_REX2 | SF_FORMAT_DWVW_12) ; - - psf->sf.channels = 1 ; - psf->bytewidth = 2 ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - if ((error = dwvw_init (psf, 16))) - return error ; - - psf->container_close = rx2_close ; - - if (! psf->sf.frames && psf->blockwidth) - psf->sf.frames = psf->datalength / psf->blockwidth ; - - /* All done. */ - - return 0 ; -} /* rx2_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -rx2_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE) - { /* Now we know for certain the length of the file we can re-write - ** correct values for the FORM, 8SVX and BODY chunks. - */ - - } ; - - return 0 ; -} /* rx2_close */ - -#endif diff --git a/Engine/lib/libsndfile/src/sd2.c b/Engine/lib/libsndfile/src/sd2.c deleted file mode 100644 index f5ef9de20..000000000 --- a/Engine/lib/libsndfile/src/sd2.c +++ /dev/null @@ -1,619 +0,0 @@ -/* -** Copyright (C) 2001-2020 Erik de Castro Lopo -** Copyright (C) 2004 Paavo Jumppanen -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** The sd2 support implemented in this file was partially sponsored -** (financially) by Paavo Jumppanen. -*/ - -/* -** Documentation on the Mac resource fork was obtained here : -** http://developer.apple.com/documentation/mac/MoreToolbox/MoreToolbox-99.html -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ - * Markers. -*/ - -#define Sd2f_MARKER MAKE_MARKER ('S', 'd', '2', 'f') -#define Sd2a_MARKER MAKE_MARKER ('S', 'd', '2', 'a') -#define ALCH_MARKER MAKE_MARKER ('A', 'L', 'C', 'H') -#define lsf1_MARKER MAKE_MARKER ('l', 's', 'f', '1') - -#define STR_MARKER MAKE_MARKER ('S', 'T', 'R', ' ') -#define sdML_MARKER MAKE_MARKER ('s', 'd', 'M', 'L') - -enum -{ RSRC_STR = 111, - RSRC_BIN -} ; - -typedef struct -{ unsigned char * rsrc_data ; - int rsrc_len ; - int need_to_free_rsrc_data ; - - int data_offset, data_length ; - int map_offset, map_length ; - - int type_count, type_offset ; - int item_offset ; - - int str_index, str_count ; - - int string_offset ; - - /* All the above just to get these three. */ - int sample_size, sample_rate, channels ; -} SD2_RSRC ; - -typedef struct -{ int type ; - int id ; - char name [32] ; - char value [32] ; - int value_len ; -} STR_RSRC ; - -/*------------------------------------------------------------------------------ - * Private static functions. -*/ - -static int sd2_close (SF_PRIVATE *psf) ; - -static int sd2_parse_rsrc_fork (SF_PRIVATE *psf) ; -static int parse_str_rsrc (SF_PRIVATE *psf, SD2_RSRC * rsrc) ; - -static int sd2_write_rsrc_fork (SF_PRIVATE *psf, int calc_length) ; - -/*------------------------------------------------------------------------------ -** Public functions. -*/ - -int -sd2_open (SF_PRIVATE *psf) -{ int subformat, error = 0, valid ; - - /* SD2 is always big endian. */ - psf->endian = SF_ENDIAN_BIG ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->rsrclength > 0)) - { psf_use_rsrc (psf, SF_TRUE) ; - valid = psf_file_valid (psf) ; - psf_use_rsrc (psf, SF_FALSE) ; - if (! valid) - { psf_log_printf (psf, "sd2_open : psf->rsrc.filedes < 0\n") ; - return SFE_SD2_BAD_RSRC ; - } ; - - error = sd2_parse_rsrc_fork (psf) ; - - if (error) - goto error_cleanup ; - } ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SD2) - { error = SFE_BAD_OPEN_FORMAT ; - goto error_cleanup ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - psf->dataoffset = 0 ; - - /* Only open and write the resource in RDWR mode is its current length is zero. */ - if (psf->file.mode == SFM_WRITE || (psf->file.mode == SFM_RDWR && psf->rsrclength == 0)) - { psf->rsrc.mode = psf->file.mode ; - psf_open_rsrc (psf) ; - - error = sd2_write_rsrc_fork (psf, SF_FALSE) ; - - if (error) - goto error_cleanup ; - - /* Not needed. */ - psf->write_header = NULL ; - } ; - - psf->container_close = sd2_close ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - switch (subformat) - { case SF_FORMAT_PCM_S8 : /* 8-bit linear PCM. */ - case SF_FORMAT_PCM_16 : /* 16-bit linear PCM. */ - case SF_FORMAT_PCM_24 : /* 24-bit linear PCM */ - case SF_FORMAT_PCM_32 : /* 32-bit linear PCM */ - error = pcm_init (psf) ; - break ; - - default : - error = SFE_UNIMPLEMENTED ; - break ; - } ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - -error_cleanup: - - /* Close the resource fork regardless. We won't need it again. */ - psf_close_rsrc (psf) ; - - return error ; -} /* sd2_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -sd2_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE) - { /* Now we know for certain the audio_length of the file we can re-write - ** correct values for the FORM, 8SVX and BODY chunks. - */ - - } ; - - return 0 ; -} /* sd2_close */ - -/*------------------------------------------------------------------------------ -*/ - -static int -sd2_write_rsrc_fork (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ SD2_RSRC rsrc ; - STR_RSRC str_rsrc [] = - { { RSRC_STR, 1000, "_sample-size", "", 0 }, - { RSRC_STR, 1001, "_sample-rate", "", 0 }, - { RSRC_STR, 1002, "_channels", "", 0 }, - { RSRC_BIN, 1000, "_Markers", "", 8 } - } ; - - int k, str_offset, data_offset, next_str ; - - psf_use_rsrc (psf, SF_TRUE) ; - - memset (&rsrc, 0, sizeof (rsrc)) ; - - rsrc.sample_rate = psf->sf.samplerate ; - rsrc.sample_size = psf->bytewidth ; - rsrc.channels = psf->sf.channels ; - - rsrc.rsrc_data = psf->header.ptr ; - rsrc.rsrc_len = psf->header.len ; - memset (rsrc.rsrc_data, 0xea, rsrc.rsrc_len) ; - - snprintf (str_rsrc [0].value, sizeof (str_rsrc [0].value), "_%d", rsrc.sample_size) ; - snprintf (str_rsrc [1].value, sizeof (str_rsrc [1].value), "_%d.000000", rsrc.sample_rate) ; - snprintf (str_rsrc [2].value, sizeof (str_rsrc [2].value), "_%d", rsrc.channels) ; - - for (k = 0 ; k < ARRAY_LEN (str_rsrc) ; k++) - { if (str_rsrc [k].value_len == 0) - { str_rsrc [k].value_len = strlen (str_rsrc [k].value) ; - str_rsrc [k].value [0] = str_rsrc [k].value_len - 1 ; - } ; - - /* Turn name string into a pascal string. */ - str_rsrc [k].name [0] = strlen (str_rsrc [k].name) - 1 ; - } ; - - rsrc.data_offset = 0x100 ; - - /* - ** Calculate data length : - ** length of strings, plus the length of the sdML chunk. - */ - rsrc.data_length = 0 ; - for (k = 0 ; k < ARRAY_LEN (str_rsrc) ; k++) - rsrc.data_length += str_rsrc [k].value_len + 4 ; - - rsrc.map_offset = rsrc.data_offset + rsrc.data_length ; - - /* Very start of resource fork. */ - psf_binheader_writef (psf, "E444", BHW4 (rsrc.data_offset), BHW4 (rsrc.map_offset), BHW4 (rsrc.data_length)) ; - - psf_binheader_writef (psf, "Eop", BHWo (0x30), BHWp (psf->file.name)) ; - psf_binheader_writef (psf, "Eo2mm", BHWo (0x50), BHW2 (0), BHWm (Sd2f_MARKER), BHWm (lsf1_MARKER)) ; - - /* Very start of resource map. */ - psf_binheader_writef (psf, "E4444", BHW4 (rsrc.map_offset), BHW4 (rsrc.data_offset), BHW4 (rsrc.map_offset), BHW4 (rsrc.data_length)) ; - - /* These I don't currently understand. */ - if (1) - { psf_binheader_writef (psf, "Eo1422", BHWo (rsrc.map_offset + 16), BHW1 (1), BHW4 (0x12345678), BHW2 (0xabcd), BHW2 (0)) ; - } ; - - /* Resource type offset. */ - rsrc.type_offset = rsrc.map_offset + 30 ; - psf_binheader_writef (psf, "Eo2", BHWo (rsrc.map_offset + 24), BHW2 (rsrc.type_offset - rsrc.map_offset - 2)) ; - - /* Type index max. */ - rsrc.type_count = 2 ; - psf_binheader_writef (psf, "Eo2", BHWo (rsrc.map_offset + 28), BHW2 (rsrc.type_count - 1)) ; - - rsrc.item_offset = rsrc.type_offset + rsrc.type_count * 8 ; - - rsrc.str_count = ARRAY_LEN (str_rsrc) ; - rsrc.string_offset = rsrc.item_offset + (rsrc.str_count + 1) * 12 - rsrc.map_offset ; - psf_binheader_writef (psf, "Eo2", BHWo (rsrc.map_offset + 26), BHW2 (rsrc.string_offset)) ; - - /* Write 'STR ' resource type. */ - rsrc.str_count = 3 ; - psf_binheader_writef (psf, "Eom22", BHWo (rsrc.type_offset), BHWm (STR_MARKER), BHW2 (rsrc.str_count - 1), BHW2 (0x12)) ; - - /* Write 'sdML' resource type. */ - psf_binheader_writef (psf, "Em22", BHWm (sdML_MARKER), BHW2 (0), BHW2 (0x36)) ; - - str_offset = rsrc.map_offset + rsrc.string_offset ; - next_str = 0 ; - data_offset = rsrc.data_offset ; - for (k = 0 ; k < ARRAY_LEN (str_rsrc) ; k++) - { psf_binheader_writef (psf, "Eop", BHWo (str_offset), BHWp (str_rsrc [k].name)) ; - psf_binheader_writef (psf, "Eo22", BHWo (rsrc.item_offset + k * 12), BHW2 (str_rsrc [k].id), BHW2 (next_str)) ; - - str_offset += strlen (str_rsrc [k].name) ; - next_str += strlen (str_rsrc [k].name) ; - - psf_binheader_writef (psf, "Eo4", BHWo (rsrc.item_offset + k * 12 + 4), BHW4 (data_offset - rsrc.data_offset)) ; - psf_binheader_writef (psf, "Eo4", BHWo (data_offset), BHW4 (str_rsrc [k].value_len)) ; - - psf_binheader_writef (psf, "Eob", BHWo (data_offset + 4), BHWv (str_rsrc [k].value), BHWz (str_rsrc [k].value_len)) ; - data_offset += 4 + str_rsrc [k].value_len ; - } ; - - /* Finally, calculate and set map length. */ - rsrc.map_length = str_offset - rsrc.map_offset ; - psf_binheader_writef (psf, "Eo4o4", BHWo (12), BHW4 (rsrc.map_length), - BHWo (rsrc.map_offset + 12), BHW4 (rsrc.map_length)) ; - - psf->header.indx = rsrc.map_offset + rsrc.map_length ; - - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - psf_use_rsrc (psf, SF_FALSE) ; - - if (psf->error) - return psf->error ; - - return 0 ; -} /* sd2_write_rsrc_fork */ - -/*------------------------------------------------------------------------------ -*/ - -static inline int -read_rsrc_char (const SD2_RSRC *prsrc, int offset) -{ const unsigned char * data = prsrc->rsrc_data ; - if (offset < 0 || offset >= prsrc->rsrc_len) - return 0 ; - return data [offset] ; -} /* read_rsrc_char */ - -static inline int -read_rsrc_short (const SD2_RSRC *prsrc, int offset) -{ const unsigned char * data = prsrc->rsrc_data ; - if (offset < 0 || offset + 1 >= prsrc->rsrc_len) - return 0 ; - return (data [offset] << 8) + data [offset + 1] ; -} /* read_rsrc_short */ - -static inline int -read_rsrc_int (const SD2_RSRC *prsrc, int offset) -{ const unsigned char * data = prsrc->rsrc_data ; - if (offset < 0 || offset + 3 >= prsrc->rsrc_len) - return 0 ; - return (((uint32_t) data [offset]) << 24) + (data [offset + 1] << 16) + (data [offset + 2] << 8) + data [offset + 3] ; -} /* read_rsrc_int */ - -static inline int -read_rsrc_marker (const SD2_RSRC *prsrc, int offset) -{ const unsigned char * data = prsrc->rsrc_data ; - - if (offset < 0 || offset + 3 >= prsrc->rsrc_len) - return 0 ; - - if (CPU_IS_BIG_ENDIAN) - return (((uint32_t) data [offset]) << 24) + (data [offset + 1] << 16) + (data [offset + 2] << 8) + data [offset + 3] ; - if (CPU_IS_LITTLE_ENDIAN) - return data [offset] + (data [offset + 1] << 8) + (data [offset + 2] << 16) + (((uint32_t) data [offset + 3]) << 24) ; - - return 0 ; -} /* read_rsrc_marker */ - -static void -read_rsrc_str (const SD2_RSRC *prsrc, int offset, char * buffer, int buffer_len) -{ const unsigned char * data = prsrc->rsrc_data ; - int k ; - - memset (buffer, 0, buffer_len) ; - - if (offset < 0 || offset + buffer_len >= prsrc->rsrc_len) - return ; - - for (k = 0 ; k < buffer_len - 1 ; k++) - { if (psf_isprint (data [offset + k]) == 0) - return ; - buffer [k] = data [offset + k] ; - } ; - return ; -} /* read_rsrc_str */ - -static int -sd2_parse_rsrc_fork (SF_PRIVATE *psf) -{ SD2_RSRC rsrc ; - int k, marker, error = 0 ; - - psf_use_rsrc (psf, SF_TRUE) ; - - memset (&rsrc, 0, sizeof (rsrc)) ; - - rsrc.rsrc_len = psf_get_filelen (psf) ; - psf_log_printf (psf, "Resource length : %d (0x%04X)\n", rsrc.rsrc_len, rsrc.rsrc_len) ; - - if (rsrc.rsrc_len > psf->header.len) - { rsrc.rsrc_data = calloc (1, rsrc.rsrc_len) ; - rsrc.need_to_free_rsrc_data = SF_TRUE ; - } - else - { - rsrc.rsrc_data = psf->header.ptr ; - // rsrc.rsrc_len > psf->header.len ; - rsrc.need_to_free_rsrc_data = SF_FALSE ; - } ; - - /* Read in the whole lot. */ - psf_fread (rsrc.rsrc_data, rsrc.rsrc_len, 1, psf) ; - - /* Reset the header storage because we have changed to the rsrcdes. */ - psf->header.indx = psf->header.end = rsrc.rsrc_len ; - - rsrc.data_offset = read_rsrc_int (&rsrc, 0) ; - rsrc.map_offset = read_rsrc_int (&rsrc, 4) ; - rsrc.data_length = read_rsrc_int (&rsrc, 8) ; - rsrc.map_length = read_rsrc_int (&rsrc, 12) ; - - if (rsrc.data_offset == 0x51607 && rsrc.map_offset == 0x20000) - { psf_log_printf (psf, "Trying offset of 0x52 bytes.\n") ; - rsrc.data_offset = read_rsrc_int (&rsrc, 0x52 + 0) + 0x52 ; - rsrc.map_offset = read_rsrc_int (&rsrc, 0x52 + 4) + 0x52 ; - rsrc.data_length = read_rsrc_int (&rsrc, 0x52 + 8) ; - rsrc.map_length = read_rsrc_int (&rsrc, 0x52 + 12) ; - } ; - - psf_log_printf (psf, " data offset : 0x%04X\n map offset : 0x%04X\n" - " data length : 0x%04X\n map length : 0x%04X\n", - rsrc.data_offset, rsrc.map_offset, rsrc.data_length, rsrc.map_length) ; - - if (rsrc.data_offset > rsrc.rsrc_len) - { psf_log_printf (psf, "Error : rsrc.data_offset (%d, 0x%x) > len\n", rsrc.data_offset, rsrc.data_offset) ; - error = SFE_SD2_BAD_DATA_OFFSET ; - goto parse_rsrc_fork_cleanup ; - } ; - - if (rsrc.map_offset > rsrc.rsrc_len) - { psf_log_printf (psf, "Error : rsrc.map_offset > len\n") ; - error = SFE_SD2_BAD_MAP_OFFSET ; - goto parse_rsrc_fork_cleanup ; - } ; - - if (rsrc.data_length > rsrc.rsrc_len) - { psf_log_printf (psf, "Error : rsrc.data_length > len\n") ; - error = SFE_SD2_BAD_DATA_LENGTH ; - goto parse_rsrc_fork_cleanup ; - } ; - - if (rsrc.map_length > rsrc.rsrc_len) - { psf_log_printf (psf, "Error : rsrc.map_length > len\n") ; - error = SFE_SD2_BAD_MAP_LENGTH ; - goto parse_rsrc_fork_cleanup ; - } ; - - if (rsrc.data_offset + rsrc.data_length != rsrc.map_offset || rsrc.map_offset + rsrc.map_length != rsrc.rsrc_len) - { psf_log_printf (psf, "Error : This does not look like a MacOSX resource fork.\n") ; - error = SFE_SD2_BAD_RSRC ; - goto parse_rsrc_fork_cleanup ; - } ; - - if (rsrc.map_offset + 28 >= rsrc.rsrc_len) - { psf_log_printf (psf, "Bad map offset (%d + 28 > %d).\n", rsrc.map_offset, rsrc.rsrc_len) ; - error = SFE_SD2_BAD_RSRC ; - goto parse_rsrc_fork_cleanup ; - } ; - - rsrc.string_offset = rsrc.map_offset + read_rsrc_short (&rsrc, rsrc.map_offset + 26) ; - if (rsrc.string_offset > rsrc.rsrc_len) - { psf_log_printf (psf, "Bad string offset (%d).\n", rsrc.string_offset) ; - error = SFE_SD2_BAD_RSRC ; - goto parse_rsrc_fork_cleanup ; - } ; - - rsrc.type_offset = rsrc.map_offset + 30 ; - - if (rsrc.map_offset + 28 > rsrc.rsrc_len) - { psf_log_printf (psf, "Bad map offset.\n") ; - goto parse_rsrc_fork_cleanup ; - } ; - - rsrc.type_count = read_rsrc_short (&rsrc, rsrc.map_offset + 28) + 1 ; - if (rsrc.type_count < 1) - { psf_log_printf (psf, "Bad type count.\n") ; - error = SFE_SD2_BAD_RSRC ; - goto parse_rsrc_fork_cleanup ; - } ; - - rsrc.item_offset = rsrc.type_offset + rsrc.type_count * 8 ; - if (rsrc.item_offset < 0 || rsrc.item_offset > rsrc.rsrc_len) - { psf_log_printf (psf, "Bad item offset (%d).\n", rsrc.item_offset) ; - error = SFE_SD2_BAD_RSRC ; - goto parse_rsrc_fork_cleanup ; - } ; - - rsrc.str_index = -1 ; - for (k = 0 ; k < rsrc.type_count ; k ++) - { if (rsrc.type_offset + k * 8 > rsrc.rsrc_len) - { psf_log_printf (psf, "Bad rsrc marker.\n") ; - goto parse_rsrc_fork_cleanup ; - } ; - - marker = read_rsrc_marker (&rsrc, rsrc.type_offset + k * 8) ; - - if (marker == STR_MARKER) - { rsrc.str_index = k ; - rsrc.str_count = read_rsrc_short (&rsrc, rsrc.type_offset + k * 8 + 4) + 1 ; - error = parse_str_rsrc (psf, &rsrc) ; - goto parse_rsrc_fork_cleanup ; - } ; - } ; - - psf_log_printf (psf, "No 'STR ' resource.\n") ; - error = SFE_SD2_BAD_RSRC ; - -parse_rsrc_fork_cleanup : - - psf_use_rsrc (psf, SF_FALSE) ; - - if (rsrc.need_to_free_rsrc_data) - free (rsrc.rsrc_data) ; - - return error ; -} /* sd2_parse_rsrc_fork */ - -static int -parse_str_rsrc (SF_PRIVATE *psf, SD2_RSRC * rsrc) -{ char name [32], value [32] ; - int k, str_offset, rsrc_id, data_offset = 0, data_len = 0 ; - - psf_log_printf (psf, "Finding parameters :\n") ; - - str_offset = rsrc->string_offset ; - psf_log_printf (psf, " Offset RsrcId dlen slen Value\n") ; - - - for (k = 0 ; data_offset + data_len < rsrc->rsrc_len ; k++) - { int slen ; - - slen = read_rsrc_char (rsrc, str_offset) ; - read_rsrc_str (rsrc, str_offset + 1, name, SF_MIN (SIGNED_SIZEOF (name), slen + 1)) ; - str_offset += slen + 1 ; - - // work-around for GitHub issue #340 - int id_offset = rsrc->item_offset + k * 12 ; - if (id_offset < 0 || id_offset + 1 >= rsrc->rsrc_len) - { psf_log_printf (psf, "Exiting parser on id_offset of %d.\n", id_offset) ; - break ; - } - rsrc_id = read_rsrc_short (rsrc, id_offset) ; - - data_offset = rsrc->data_offset + read_rsrc_int (rsrc, rsrc->item_offset + k * 12 + 4) ; - if (data_offset < 0 || data_offset > rsrc->rsrc_len) - { psf_log_printf (psf, "Exiting parser on data offset of %d.\n", data_offset) ; - break ; - } ; - - data_len = read_rsrc_int (rsrc, data_offset) ; - if (data_len < 0 || data_len > rsrc->rsrc_len) - { psf_log_printf (psf, "Exiting parser on data length of %d.\n", data_len) ; - break ; - } ; - - slen = read_rsrc_char (rsrc, data_offset + 4) ; - read_rsrc_str (rsrc, data_offset + 5, value, SF_MIN (SIGNED_SIZEOF (value), slen + 1)) ; - - psf_log_printf (psf, " 0x%04x %4d %4d %3d '%s'\n", data_offset, rsrc_id, data_len, slen, value) ; - - if (strstr (value, "Photoshop")) - { psf_log_printf (psf, "Exiting parser on Photoshop data.\n", data_offset) ; - break ; - } ; - - if (rsrc_id == 1000 && rsrc->sample_size == 0) - rsrc->sample_size = strtol (value, NULL, 10) ; - else if (rsrc_id == 1001 && rsrc->sample_rate == 0) - rsrc->sample_rate = strtol (value, NULL, 10) ; - else if (rsrc_id == 1002 && rsrc->channels == 0) - rsrc->channels = strtol (value, NULL, 10) ; - } ; - - psf_log_printf (psf, "Found Parameters :\n") ; - psf_log_printf (psf, " sample-size : %d\n", rsrc->sample_size) ; - psf_log_printf (psf, " sample-rate : %d\n", rsrc->sample_rate) ; - psf_log_printf (psf, " channels : %d\n", rsrc->channels) ; - - if (rsrc->sample_rate <= 4 && rsrc->sample_size > 4) - { int temp ; - - psf_log_printf (psf, "Geez!! Looks like sample rate and sample size got switched.\nCorrecting this screw up.\n") ; - temp = rsrc->sample_rate ; - rsrc->sample_rate = rsrc->sample_size ; - rsrc->sample_size = temp ; - } ; - - if (rsrc->sample_rate < 0) - { psf_log_printf (psf, "Bad sample rate (%d)\n", rsrc->sample_rate) ; - return SFE_SD2_BAD_RSRC ; - } ; - - if (rsrc->channels < 0) - { psf_log_printf (psf, "Bad channel count (%d)\n", rsrc->channels) ; - return SFE_SD2_BAD_RSRC ; - } ; - - psf->sf.samplerate = rsrc->sample_rate ; - psf->sf.channels = rsrc->channels ; - psf->bytewidth = rsrc->sample_size ; - - switch (rsrc->sample_size) - { case 1 : - psf->sf.format = SF_FORMAT_SD2 | SF_FORMAT_PCM_S8 ; - break ; - - case 2 : - psf->sf.format = SF_FORMAT_SD2 | SF_FORMAT_PCM_16 ; - break ; - - case 3 : - psf->sf.format = SF_FORMAT_SD2 | SF_FORMAT_PCM_24 ; - break ; - - case 4 : - psf->sf.format = SF_FORMAT_SD2 | SF_FORMAT_PCM_32 ; - break ; - - default : - psf_log_printf (psf, "Bad sample size (%d)\n", rsrc->sample_size) ; - return SFE_SD2_BAD_SAMPLE_SIZE ; - } ; - - psf_log_printf (psf, "ok\n") ; - - return 0 ; -} /* parse_str_rsrc */ - diff --git a/Engine/lib/libsndfile/src/sds.c b/Engine/lib/libsndfile/src/sds.c deleted file mode 100644 index 6bc761716..000000000 --- a/Engine/lib/libsndfile/src/sds.c +++ /dev/null @@ -1,1022 +0,0 @@ -/* -** Copyright (C) 2002-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -*/ - -#define SDS_DATA_OFFSET 0x15 -#define SDS_BLOCK_SIZE 127 - -#define SDS_AUDIO_BYTES_PER_BLOCK 120 - -#define SDS_3BYTE_TO_INT_DECODE(x) (((x) & 0x7F) | (((x) & 0x7F00) >> 1) | (((x) & 0x7F0000) >> 2)) -#define SDS_INT_TO_3BYTE_ENCODE(x) (((x) & 0x7F) | (((x) << 1) & 0x7F00) | (((x) << 2) & 0x7F0000)) - -/*------------------------------------------------------------------------------ -** Typedefs. -*/ - -typedef struct tag_SDS_PRIVATE -{ int bitwidth, frames ; - int samplesperblock, total_blocks ; - - int (*reader) (SF_PRIVATE *psf, struct tag_SDS_PRIVATE *psds) ; - int (*writer) (SF_PRIVATE *psf, struct tag_SDS_PRIVATE *psds) ; - - int read_block, read_count ; - unsigned char read_data [SDS_BLOCK_SIZE] ; - int read_samples [SDS_BLOCK_SIZE / 2] ; /* Maximum samples per block */ - - int write_block, write_count ; - int total_written ; - unsigned char write_data [SDS_BLOCK_SIZE] ; - int write_samples [SDS_BLOCK_SIZE / 2] ; /* Maximum samples per block */ -} SDS_PRIVATE ; - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int sds_close (SF_PRIVATE *psf) ; - -static int sds_write_header (SF_PRIVATE *psf, int calc_length) ; -static int sds_read_header (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; - -static int sds_init (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; - -static sf_count_t sds_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t sds_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t sds_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t sds_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t sds_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t sds_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t sds_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t sds_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static sf_count_t sds_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; -static int sds_byterate (SF_PRIVATE * psf) ; - -static int sds_2byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; -static int sds_3byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; -static int sds_4byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; - -static int sds_read (SF_PRIVATE *psf, SDS_PRIVATE *psds, int *iptr, int readcount) ; - -static int sds_2byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; -static int sds_3byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; -static int sds_4byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) ; - -static int sds_write (SF_PRIVATE *psf, SDS_PRIVATE *psds, const int *iptr, int writecount) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -sds_open (SF_PRIVATE *psf) -{ SDS_PRIVATE *psds ; - int error = 0 ; - - /* Hmmmm, need this here to pass update_header_test. */ - psf->sf.frames = 0 ; - - if (! (psds = calloc (1, sizeof (SDS_PRIVATE)))) - return SFE_MALLOC_FAILED ; - psf->codec_data = psds ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = sds_read_header (psf, psds))) - return error ; - } ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SDS) - return SFE_BAD_OPEN_FORMAT ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (sds_write_header (psf, SF_FALSE)) - return psf->error ; - - psf->write_header = sds_write_header ; - - psf_fseek (psf, SDS_DATA_OFFSET, SEEK_SET) ; - } ; - - if ((error = sds_init (psf, psds)) != 0) - return error ; - - psf->container_close = sds_close ; - psf->seek = sds_seek ; - psf->byterate = sds_byterate ; - - psf->blockwidth = 0 ; - - return error ; -} /* sds_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -sds_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { SDS_PRIVATE *psds ; - - if ((psds = (SDS_PRIVATE *) psf->codec_data) == NULL) - { psf_log_printf (psf, "*** Bad psf->codec_data ptr.\n") ; - return SFE_INTERNAL ; - } ; - - if (psds->write_count > 0) - { memset (&(psds->write_data [psds->write_count]), 0, (psds->samplesperblock - psds->write_count) * sizeof (int)) ; - psds->writer (psf, psds) ; - } ; - - sds_write_header (psf, SF_TRUE) ; - } ; - - return 0 ; -} /* sds_close */ - -static int -sds_init (SF_PRIVATE *psf, SDS_PRIVATE *psds) -{ - if (psds->bitwidth < 8 || psds->bitwidth > 28) - return (psf->error = SFE_SDS_BAD_BIT_WIDTH) ; - - if (psds->bitwidth < 14) - { psds->reader = sds_2byte_read ; - psds->writer = sds_2byte_write ; - psds->samplesperblock = SDS_AUDIO_BYTES_PER_BLOCK / 2 ; - } - else if (psds->bitwidth < 21) - { psds->reader = sds_3byte_read ; - psds->writer = sds_3byte_write ; - psds->samplesperblock = SDS_AUDIO_BYTES_PER_BLOCK / 3 ; - } - else - { psds->reader = sds_4byte_read ; - psds->writer = sds_4byte_write ; - psds->samplesperblock = SDS_AUDIO_BYTES_PER_BLOCK / 4 ; - } ; - - if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) - { psf->read_short = sds_read_s ; - psf->read_int = sds_read_i ; - psf->read_float = sds_read_f ; - psf->read_double = sds_read_d ; - - /* Read first block. */ - psds->reader (psf, psds) ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { psf->write_short = sds_write_s ; - psf->write_int = sds_write_i ; - psf->write_float = sds_write_f ; - psf->write_double = sds_write_d ; - } ; - - return 0 ; -} /* sds_init */ - -static int -sds_read_header (SF_PRIVATE *psf, SDS_PRIVATE *psds) -{ unsigned char channel, bitwidth, loop_type, byte ; - unsigned short sample_no, marker ; - unsigned int samp_period, data_length, sustain_loop_start, sustain_loop_end ; - int bytesread, blockcount ; - - /* Set position to start of file to begin reading header. */ - bytesread = psf_binheader_readf (psf, "pE211", 0, &marker, &channel, &byte) ; - - if (marker != 0xF07E || byte != 0x01) - return SFE_SDS_NOT_SDS ; - - bytesread += psf_binheader_readf (psf, "e2", &sample_no) ; - sample_no = SDS_3BYTE_TO_INT_DECODE (sample_no) ; - - psf_log_printf (psf, "Midi Sample Dump Standard (.sds)\nF07E\n" - " Midi Channel : %d\n Sample Number : %d\n", - channel, sample_no) ; - - bytesread += psf_binheader_readf (psf, "e13", &bitwidth, &samp_period) ; - - samp_period = SDS_3BYTE_TO_INT_DECODE (samp_period) ; - - psds->bitwidth = bitwidth ; - - if (psds->bitwidth > 1) - psf_log_printf (psf, " Bit Width : %d\n", psds->bitwidth) ; - else - { psf_log_printf (psf, " Bit Width : %d (should be > 1)\n", psds->bitwidth) ; - return SFE_SDS_BAD_BIT_WIDTH ; - } ; - - if (samp_period > 0) - { psf->sf.samplerate = 1000000000 / samp_period ; - - psf_log_printf (psf, " Sample Period : %d\n" - " Sample Rate : %d\n", - samp_period, psf->sf.samplerate) ; - } - else - { psf->sf.samplerate = 16000 ; - - psf_log_printf (psf, " Sample Period : %d (should be > 0)\n" - " Sample Rate : %d (guessed)\n", - samp_period, psf->sf.samplerate) ; - } ; - - bytesread += psf_binheader_readf (psf, "e3331", &data_length, &sustain_loop_start, &sustain_loop_end, &loop_type) ; - - data_length = SDS_3BYTE_TO_INT_DECODE (data_length) ; - - psf->sf.frames = psds->frames = data_length ; - - sustain_loop_start = SDS_3BYTE_TO_INT_DECODE (sustain_loop_start) ; - sustain_loop_end = SDS_3BYTE_TO_INT_DECODE (sustain_loop_end) ; - - psf_log_printf (psf, " Sustain Loop\n" - " Start : %d\n" - " End : %d\n" - " Loop Type : %d\n", - sustain_loop_start, sustain_loop_end, loop_type) ; - - psf->dataoffset = SDS_DATA_OFFSET ; - psf->datalength = psf->filelength - psf->dataoffset ; - - bytesread += psf_binheader_readf (psf, "1", &byte) ; - if (byte != 0xF7) - psf_log_printf (psf, "bad end : %X\n", byte & 0xFF) ; - - for (blockcount = 0 ; bytesread < psf->filelength ; blockcount++) - { - bytesread += (int) psf_fread (&marker, 1, 2, psf) ; - - if (marker == 0) - break ; - - psf_fseek (psf, SDS_BLOCK_SIZE - 2, SEEK_CUR) ; - bytesread += SDS_BLOCK_SIZE - 2 ; - } ; - - psf_log_printf (psf, "\nBlocks : %d\n", blockcount) ; - psds->total_blocks = blockcount ; - - psds->samplesperblock = SDS_AUDIO_BYTES_PER_BLOCK / ((psds->bitwidth + 6) / 7) ; - psf_log_printf (psf, "Samples/Block : %d\n", psds->samplesperblock) ; - - psf_log_printf (psf, "Frames : %d\n", blockcount * psds->samplesperblock) ; - - /* Always Mono */ - psf->sf.channels = 1 ; - psf->sf.sections = 1 ; - - /* - ** Lie to the user about PCM bit width. Always round up to - ** the next multiple of 8. - */ - switch ((psds->bitwidth + 7) / 8) - { case 1 : - psf->sf.format = SF_FORMAT_SDS | SF_FORMAT_PCM_S8 ; - break ; - - case 2 : - psf->sf.format = SF_FORMAT_SDS | SF_FORMAT_PCM_16 ; - break ; - - case 3 : - psf->sf.format = SF_FORMAT_SDS | SF_FORMAT_PCM_24 ; - break ; - - case 4 : - psf->sf.format = SF_FORMAT_SDS | SF_FORMAT_PCM_32 ; - break ; - - default : - psf_log_printf (psf, "*** Weird byte width (%d)\n", (psds->bitwidth + 7) / 8) ; - return SFE_SDS_BAD_BIT_WIDTH ; - } ; - - psf_fseek (psf, SDS_DATA_OFFSET, SEEK_SET) ; - - return 0 ; -} /* sds_read_header */ - -static int -sds_write_header (SF_PRIVATE *psf, int calc_length) -{ SDS_PRIVATE *psds ; - sf_count_t current ; - int samp_period, data_length, sustain_loop_start, sustain_loop_end ; - unsigned char loop_type = 0 ; - - if ((psds = (SDS_PRIVATE *) psf->codec_data) == NULL) - { psf_log_printf (psf, "*** Bad psf->codec_data ptr.\n") ; - return SFE_INTERNAL ; - } ; - - if (psf->pipeoffset > 0) - return 0 ; - - current = psf_ftell (psf) ; - - if (calc_length) - psf->sf.frames = psds->total_written ; - - if (psds->write_count > 0) - { int current_count = psds->write_count ; - int current_block = psds->write_block ; - - psds->writer (psf, psds) ; - - psf_fseek (psf, -1 * SDS_BLOCK_SIZE, SEEK_CUR) ; - - psds->write_count = current_count ; - psds->write_block = current_block ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - if (psf->is_pipe == SF_FALSE) - psf_fseek (psf, 0, SEEK_SET) ; - - psf_binheader_writef (psf, "E211", BHW2 (0xF07E), BHW1 (0), BHW1 (1)) ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - psds->bitwidth = 8 ; - break ; - case SF_FORMAT_PCM_16 : - psds->bitwidth = 16 ; - break ; - case SF_FORMAT_PCM_24 : - psds->bitwidth = 24 ; - break ; - default: - return SFE_SDS_BAD_BIT_WIDTH ; - } ; - - samp_period = SDS_INT_TO_3BYTE_ENCODE (1000000000 / psf->sf.samplerate) ; - - psf_binheader_writef (psf, "e213", BHW2 (0), BHW1 (psds->bitwidth), BHW3 (samp_period)) ; - - data_length = SDS_INT_TO_3BYTE_ENCODE (psds->total_written) ; - sustain_loop_start = SDS_INT_TO_3BYTE_ENCODE (0) ; - sustain_loop_end = SDS_INT_TO_3BYTE_ENCODE (0) ; - - psf_binheader_writef (psf, "e33311", BHW3 (data_length), BHW3 (sustain_loop_start), BHW3 (sustain_loop_end), BHW1 (loop_type), BHW1 (0xF7)) ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - psf->datalength = psds->write_block * SDS_BLOCK_SIZE ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* sds_write_header */ - - -/*------------------------------------------------------------------------------ -*/ - -static int -sds_2byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) -{ unsigned char *ucptr, checksum ; - unsigned int sample ; - int k ; - - psds->read_block ++ ; - psds->read_count = 0 ; - - if (psds->read_block * psds->samplesperblock > psds->frames) - { memset (psds->read_samples, 0, psds->samplesperblock * sizeof (int)) ; - return 1 ; - } ; - - if ((k = (int) psf_fread (psds->read_data, 1, SDS_BLOCK_SIZE, psf)) != SDS_BLOCK_SIZE) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, SDS_BLOCK_SIZE) ; - - if (psds->read_data [0] != 0xF0) - { printf ("Error A : %02X\n", psds->read_data [0] & 0xFF) ; - } ; - - checksum = psds->read_data [1] ; - if (checksum != 0x7E) - { printf ("Error 1 : %02X\n", checksum & 0xFF) ; - } - - for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) - checksum ^= psds->read_data [k] ; - - checksum &= 0x7F ; - - if (checksum != psds->read_data [SDS_BLOCK_SIZE - 2]) - { psf_log_printf (psf, "Block %d : checksum is %02X should be %02X\n", psds->read_data [4], checksum, psds->read_data [SDS_BLOCK_SIZE - 2]) ; - } ; - - ucptr = psds->read_data + 5 ; - for (k = 0 ; k < 120 ; k += 2) - { sample = arith_shift_left (ucptr [k], 25) + arith_shift_left (ucptr [k + 1], 18) ; - psds->read_samples [k / 2] = (int) (sample - 0x80000000) ; - } ; - - return 1 ; -} /* sds_2byte_read */ - -static int -sds_3byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) -{ unsigned char *ucptr, checksum ; - unsigned int sample ; - int k ; - - psds->read_block ++ ; - psds->read_count = 0 ; - - if (psds->read_block * psds->samplesperblock > psds->frames) - { memset (psds->read_samples, 0, psds->samplesperblock * sizeof (int)) ; - return 1 ; - } ; - - if ((k = (int) psf_fread (psds->read_data, 1, SDS_BLOCK_SIZE, psf)) != SDS_BLOCK_SIZE) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, SDS_BLOCK_SIZE) ; - - if (psds->read_data [0] != 0xF0) - { printf ("Error A : %02X\n", psds->read_data [0] & 0xFF) ; - } ; - - checksum = psds->read_data [1] ; - if (checksum != 0x7E) - { printf ("Error 1 : %02X\n", checksum & 0xFF) ; - } - - for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) - checksum ^= psds->read_data [k] ; - - checksum &= 0x7F ; - - if (checksum != psds->read_data [SDS_BLOCK_SIZE - 2]) - { psf_log_printf (psf, "Block %d : checksum is %02X should be %02X\n", psds->read_data [4], checksum, psds->read_data [SDS_BLOCK_SIZE - 2]) ; - } ; - - ucptr = psds->read_data + 5 ; - for (k = 0 ; k < 120 ; k += 3) - { sample = (((uint32_t) ucptr [k]) << 25) + (ucptr [k + 1] << 18) + (ucptr [k + 2] << 11) ; - psds->read_samples [k / 3] = (int) (sample - 0x80000000) ; - } ; - - return 1 ; -} /* sds_3byte_read */ - -static int -sds_4byte_read (SF_PRIVATE *psf, SDS_PRIVATE *psds) -{ unsigned char *ucptr, checksum ; - uint32_t sample ; - int k ; - - psds->read_block ++ ; - psds->read_count = 0 ; - - if (psds->read_block * psds->samplesperblock > psds->frames) - { memset (psds->read_samples, 0, psds->samplesperblock * sizeof (int)) ; - return 1 ; - } ; - - if ((k = (int) psf_fread (psds->read_data, 1, SDS_BLOCK_SIZE, psf)) != SDS_BLOCK_SIZE) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, SDS_BLOCK_SIZE) ; - - if (psds->read_data [0] != 0xF0) - { printf ("Error A : %02X\n", psds->read_data [0] & 0xFF) ; - } ; - - checksum = psds->read_data [1] ; - if (checksum != 0x7E) - { printf ("Error 1 : %02X\n", checksum & 0xFF) ; - } - - for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) - checksum ^= psds->read_data [k] ; - - checksum &= 0x7F ; - - if (checksum != psds->read_data [SDS_BLOCK_SIZE - 2]) - { psf_log_printf (psf, "Block %d : checksum is %02X should be %02X\n", psds->read_data [4], checksum, psds->read_data [SDS_BLOCK_SIZE - 2]) ; - } ; - - ucptr = psds->read_data + 5 ; - for (k = 0 ; k < 120 ; k += 4) - { sample = (((uint32_t) ucptr [k]) << 25) + (ucptr [k + 1] << 18) + (ucptr [k + 2] << 11) + (ucptr [k + 3] << 4) ; - psds->read_samples [k / 4] = (int) (sample - 0x80000000) ; - } ; - - return 1 ; -} /* sds_4byte_read */ - - -static sf_count_t -sds_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - SDS_PRIVATE *psds ; - int *iptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - psds = (SDS_PRIVATE*) psf->codec_data ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = sds_read (psf, psds, iptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = iptr [k] >> 16 ; - total += count ; - len -= readcount ; - } ; - - return total ; -} /* sds_read_s */ - -static sf_count_t -sds_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ SDS_PRIVATE *psds ; - int total ; - - if (psf->codec_data == NULL) - return 0 ; - psds = (SDS_PRIVATE*) psf->codec_data ; - - total = sds_read (psf, psds, ptr, len) ; - - return total ; -} /* sds_read_i */ - -static sf_count_t -sds_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - SDS_PRIVATE *psds ; - int *iptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - psds = (SDS_PRIVATE*) psf->codec_data ; - - if (psf->norm_float == SF_TRUE) - normfact = 1.0 / 0x80000000 ; - else - normfact = 1.0 / (1 << psds->bitwidth) ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = sds_read (psf, psds, iptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * iptr [k] ; - total += count ; - len -= readcount ; - } ; - - return total ; -} /* sds_read_f */ - -static sf_count_t -sds_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - SDS_PRIVATE *psds ; - int *iptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->codec_data == NULL) - return 0 ; - psds = (SDS_PRIVATE*) psf->codec_data ; - - if (psf->norm_double == SF_TRUE) - normfact = 1.0 / 0x80000000 ; - else - normfact = 1.0 / (1 << psds->bitwidth) ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = sds_read (psf, psds, iptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * iptr [k] ; - total += count ; - len -= readcount ; - } ; - - return total ; -} /* sds_read_d */ - -static int -sds_read (SF_PRIVATE *psf, SDS_PRIVATE *psds, int *ptr, int len) -{ int count, total = 0 ; - - while (total < len) - { if (psds->read_block * psds->samplesperblock >= psds->frames) - { memset (&(ptr [total]), 0, (len - total) * sizeof (int)) ; - return total ; - } ; - - if (psds->read_count >= psds->samplesperblock) - psds->reader (psf, psds) ; - - count = (psds->samplesperblock - psds->read_count) ; - count = (len - total > count) ? count : len - total ; - - memcpy (&(ptr [total]), &(psds->read_samples [psds->read_count]), count * sizeof (int)) ; - total += count ; - psds->read_count += count ; - } ; - - return total ; -} /* sds_read */ - -/*============================================================================== -*/ - -static sf_count_t -sds_seek (SF_PRIVATE *psf, int mode, sf_count_t seek_from_start) -{ SDS_PRIVATE *psds ; - sf_count_t file_offset ; - int newblock, newsample ; - - if ((psds = psf->codec_data) == NULL) - { psf->error = SFE_INTERNAL ; - return PSF_SEEK_ERROR ; - } ; - - if (psf->datalength < 0 || psf->dataoffset < 0) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (seek_from_start < 0 || seek_from_start > psf->sf.frames) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (mode == SFM_READ && psds->write_count > 0) - psds->writer (psf, psds) ; - - newblock = seek_from_start / psds->samplesperblock ; - newsample = seek_from_start % psds->samplesperblock ; - - switch (mode) - { case SFM_READ : - if (newblock > psds->total_blocks) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - file_offset = psf->dataoffset + newblock * SDS_BLOCK_SIZE ; - - if (psf_fseek (psf, file_offset, SEEK_SET) != file_offset) - { psf->error = SFE_SEEK_FAILED ; - return PSF_SEEK_ERROR ; - } ; - - psds->read_block = newblock ; - psds->reader (psf, psds) ; - psds->read_count = newsample ; - break ; - - case SFM_WRITE : - if (newblock > psds->total_blocks) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - file_offset = psf->dataoffset + newblock * SDS_BLOCK_SIZE ; - - if (psf_fseek (psf, file_offset, SEEK_SET) != file_offset) - { psf->error = SFE_SEEK_FAILED ; - return PSF_SEEK_ERROR ; - } ; - - psds->write_block = newblock ; - psds->reader (psf, psds) ; - psds->write_count = newsample ; - break ; - - default : - psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - break ; - } ; - - return seek_from_start ; -} /* sds_seek */ - -static int -sds_byterate (SF_PRIVATE * psf) -{ - if (psf->file.mode == SFM_READ) - return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ; - - return -1 ; -} /* sds_byterate */ - -/*============================================================================== -*/ - -static int -sds_2byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) -{ unsigned char *ucptr, checksum ; - unsigned int sample ; - int k ; - - psds->write_data [0] = 0xF0 ; - psds->write_data [1] = 0x7E ; - psds->write_data [2] = 0 ; /* Channel number */ - psds->write_data [3] = 2 ; - psds->write_data [4] = psds->write_block & 0x7F ; /* Packet number */ - - ucptr = psds->write_data + 5 ; - for (k = 0 ; k < 120 ; k += 2) - { sample = psds->write_samples [k / 2] ; - sample += 0x80000000 ; - ucptr [k] = (sample >> 25) & 0x7F ; - ucptr [k + 1] = (sample >> 18) & 0x7F ; - } ; - - checksum = psds->write_data [1] ; - for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) - checksum ^= psds->write_data [k] ; - checksum &= 0x7F ; - - psds->write_data [SDS_BLOCK_SIZE - 2] = checksum ; - psds->write_data [SDS_BLOCK_SIZE - 1] = 0xF7 ; - - if ((k = (int) psf_fwrite (psds->write_data, 1, SDS_BLOCK_SIZE, psf)) != SDS_BLOCK_SIZE) - psf_log_printf (psf, "*** Warning : psf_fwrite (%d != %d).\n", k, SDS_BLOCK_SIZE) ; - - psds->write_block ++ ; - psds->write_count = 0 ; - - if (psds->write_block > psds->total_blocks) - psds->total_blocks = psds->write_block ; - psds->frames = psds->total_blocks * psds->samplesperblock ; - - return 1 ; -} /* sds_2byte_write */ - -static int -sds_3byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) -{ unsigned char *ucptr, checksum ; - unsigned int sample ; - int k ; - - psds->write_data [0] = 0xF0 ; - psds->write_data [1] = 0x7E ; - psds->write_data [2] = 0 ; /* Channel number */ - psds->write_data [3] = 2 ; - psds->write_data [4] = psds->write_block & 0x7F ; /* Packet number */ - - ucptr = psds->write_data + 5 ; - for (k = 0 ; k < 120 ; k += 3) - { sample = psds->write_samples [k / 3] ; - sample += 0x80000000 ; - ucptr [k] = (sample >> 25) & 0x7F ; - ucptr [k + 1] = (sample >> 18) & 0x7F ; - ucptr [k + 2] = (sample >> 11) & 0x7F ; - } ; - - checksum = psds->write_data [1] ; - for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) - checksum ^= psds->write_data [k] ; - checksum &= 0x7F ; - - psds->write_data [SDS_BLOCK_SIZE - 2] = checksum ; - psds->write_data [SDS_BLOCK_SIZE - 1] = 0xF7 ; - - if ((k = (int) psf_fwrite (psds->write_data, 1, SDS_BLOCK_SIZE, psf)) != SDS_BLOCK_SIZE) - psf_log_printf (psf, "*** Warning : psf_fwrite (%d != %d).\n", k, SDS_BLOCK_SIZE) ; - - psds->write_block ++ ; - psds->write_count = 0 ; - - if (psds->write_block > psds->total_blocks) - psds->total_blocks = psds->write_block ; - psds->frames = psds->total_blocks * psds->samplesperblock ; - - return 1 ; -} /* sds_3byte_write */ - -static int -sds_4byte_write (SF_PRIVATE *psf, SDS_PRIVATE *psds) -{ unsigned char *ucptr, checksum ; - unsigned int sample ; - int k ; - - psds->write_data [0] = 0xF0 ; - psds->write_data [1] = 0x7E ; - psds->write_data [2] = 0 ; /* Channel number */ - psds->write_data [3] = 2 ; - psds->write_data [4] = psds->write_block & 0x7F ; /* Packet number */ - - ucptr = psds->write_data + 5 ; - for (k = 0 ; k < 120 ; k += 4) - { sample = psds->write_samples [k / 4] ; - sample += 0x80000000 ; - ucptr [k] = (sample >> 25) & 0x7F ; - ucptr [k + 1] = (sample >> 18) & 0x7F ; - ucptr [k + 2] = (sample >> 11) & 0x7F ; - ucptr [k + 3] = (sample >> 4) & 0x7F ; - } ; - - checksum = psds->write_data [1] ; - for (k = 2 ; k <= SDS_BLOCK_SIZE - 3 ; k ++) - checksum ^= psds->write_data [k] ; - checksum &= 0x7F ; - - psds->write_data [SDS_BLOCK_SIZE - 2] = checksum ; - psds->write_data [SDS_BLOCK_SIZE - 1] = 0xF7 ; - - if ((k = (int) psf_fwrite (psds->write_data, 1, SDS_BLOCK_SIZE, psf)) != SDS_BLOCK_SIZE) - psf_log_printf (psf, "*** Warning : psf_fwrite (%d != %d).\n", k, SDS_BLOCK_SIZE) ; - - psds->write_block ++ ; - psds->write_count = 0 ; - - if (psds->write_block > psds->total_blocks) - psds->total_blocks = psds->write_block ; - psds->frames = psds->total_blocks * psds->samplesperblock ; - - return 1 ; -} /* sds_4byte_write */ - -static sf_count_t -sds_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - SDS_PRIVATE *psds ; - int *iptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - - if (psf->codec_data == NULL) - return 0 ; - psds = (SDS_PRIVATE*) psf->codec_data ; - psds->total_written += len ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - iptr [k] = arith_shift_left (ptr [total + k], 16) ; - count = sds_write (psf, psds, iptr, writecount) ; - total += count ; - len -= writecount ; - } ; - - return total ; -} /* sds_write_s */ - -static sf_count_t -sds_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ SDS_PRIVATE *psds ; - int total ; - - if (psf->codec_data == NULL) - return 0 ; - psds = (SDS_PRIVATE*) psf->codec_data ; - psds->total_written += len ; - - total = sds_write (psf, psds, ptr, len) ; - - return total ; -} /* sds_write_i */ - -static sf_count_t -sds_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - SDS_PRIVATE *psds ; - int *iptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->codec_data == NULL) - return 0 ; - psds = (SDS_PRIVATE*) psf->codec_data ; - psds->total_written += len ; - - if (psf->norm_float == SF_TRUE) - normfact = 1.0 * 0x80000000 ; - else - normfact = 1.0 * (1 << psds->bitwidth) ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - iptr [k] = normfact * ptr [total + k] ; - count = sds_write (psf, psds, iptr, writecount) ; - total += count ; - len -= writecount ; - } ; - - return total ; -} /* sds_write_f */ - -static sf_count_t -sds_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - SDS_PRIVATE *psds ; - int *iptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->codec_data == NULL) - return 0 ; - psds = (SDS_PRIVATE*) psf->codec_data ; - psds->total_written += len ; - - if (psf->norm_double == SF_TRUE) - normfact = 1.0 * 0x80000000 ; - else - normfact = 1.0 * (1 << psds->bitwidth) ; - - iptr = ubuf.ibuf ; - bufferlen = ARRAY_LEN (ubuf.ibuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - iptr [k] = normfact * ptr [total + k] ; - count = sds_write (psf, psds, iptr, writecount) ; - total += count ; - len -= writecount ; - } ; - - return total ; -} /* sds_write_d */ - -static int -sds_write (SF_PRIVATE *psf, SDS_PRIVATE *psds, const int *ptr, int len) -{ int count, total = 0 ; - - while (total < len) - { count = psds->samplesperblock - psds->write_count ; - if (count > len - total) - count = len - total ; - - memcpy (&(psds->write_samples [psds->write_count]), &(ptr [total]), count * sizeof (int)) ; - total += count ; - psds->write_count += count ; - - if (psds->write_count >= psds->samplesperblock) - psds->writer (psf, psds) ; - } ; - - return total ; -} /* sds_write */ - diff --git a/Engine/lib/libsndfile/src/sf_unistd.h b/Engine/lib/libsndfile/src/sf_unistd.h deleted file mode 100644 index 698eff21c..000000000 --- a/Engine/lib/libsndfile/src/sf_unistd.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Copyright (C) 2002-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* Microsoft declares some 'unistd.h' functions in 'io.h'. */ - -#include -#ifdef HAVE_IO_H -#include -#endif - -/* Some defines that microsoft 'forgot' to implement. */ - -#ifndef R_OK -#define R_OK 4 /* Test for read permission. */ -#endif - -#ifndef W_OK -#define W_OK 2 /* Test for write permission. */ -#endif - -#ifndef X_OK -#ifdef _WIN32 -#define X_OK 0 -#else -#define X_OK 1 /* execute permission - unsupported in windows*/ -#endif -#endif - -#ifndef F_OK -#define F_OK 0 /* Test for existence. */ -#endif - -#ifndef S_IRWXU -#define S_IRWXU 0000700 /* rwx, owner */ -#endif - -#ifndef S_IRUSR -#define S_IRUSR 0000400 /* read permission, owner */ -#endif - -#ifndef S_IWUSR -#define S_IWUSR 0000200 /* write permission, owner */ -#endif - -#ifndef S_IXUSR -#define S_IXUSR 0000100 /* execute/search permission, owner */ -#endif - -/* Windows (except MinGW) doesn't have group permissions so set all these to zero. */ -#ifndef S_IRWXG -#define S_IRWXG 0 /* rwx, group */ -#endif - -#ifndef S_IRGRP -#define S_IRGRP 0 /* read permission, group */ -#endif - -#ifndef S_IWGRP -#define S_IWGRP 0 /* write permission, grougroup */ -#endif - -#ifndef S_IXGRP -#define S_IXGRP 0 /* execute/search permission, group */ -#endif - -/* Windows (except MinGW) doesn't have others permissions so set all these to zero. */ -#ifndef S_IRWXO -#define S_IRWXO 0 /* rwx, other */ -#endif - -#ifndef S_IROTH -#define S_IROTH 0 /* read permission, other */ -#endif - -#ifndef S_IWOTH -#define S_IWOTH 0 /* write permission, other */ -#endif - -#ifndef S_IXOTH -#define S_IXOTH 0 /* execute/search permission, other */ -#endif - -#ifndef S_ISFIFO -#define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO) -#endif - -#ifndef S_ISREG -#define S_ISREG(mode) (((mode) & _S_IFREG) == _S_IFREG) -#endif - -/* -** Don't know if these are still needed. -** -** #define _IFMT _S_IFMT -** #define _IFREG _S_IFREG -*/ - diff --git a/Engine/lib/libsndfile/src/sfconfig.h b/Engine/lib/libsndfile/src/sfconfig.h deleted file mode 100644 index de2e56d62..000000000 --- a/Engine/lib/libsndfile/src/sfconfig.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Copyright (C) 2005-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** Autoconf leaves many config parameters undefined. -** Here we change then from being undefined to defining them to 0. -** This allows things like: -** -** #if HAVE_CONFIG_PARAM -** -** and -** -** if (HAVE_CONFIG_PARAM) -** do_something () ; -*/ - -#ifndef SFCONFIG_H -#define SFCONFIG_H - -/* Include the Autoconf generated file. */ -#include "config.h" - -/* Now fiddle the values. */ - -#ifndef HAVE_ALSA_ASOUNDLIB_H -#define HAVE_ALSA_ASOUNDLIB_H 0 -#endif - -#ifndef HAVE_BYTESWAP_H -#define HAVE_BYTESWAP_H 0 -#endif - -#ifndef HAVE_DECL_S_IRGRP -#define HAVE_DECL_S_IRGRP 0 -#endif - -#ifndef HAVE_ENDIAN_H -#define HAVE_ENDIAN_H 0 -#endif - -#ifndef HAVE_FSTAT64 -#define HAVE_FSTAT64 0 -#endif - -#ifndef HAVE_FSYNC -#define HAVE_FSYNC 0 -#endif - -#ifndef HAVE_LOCALE_H -#define HAVE_LOCALE_H 0 -#endif - -#ifndef HAVE_LRINT -#define HAVE_LRINT 0 -#endif - -#ifndef HAVE_LRINTF -#define HAVE_LRINTF 0 -#endif - -#ifndef HAVE_MMAP -#define HAVE_MMAP 0 -#endif - -#ifndef HAVE_SETLOCALE -#define HAVE_SETLOCALE 0 -#endif - -#ifndef HAVE_SQLITE3 -#define HAVE_SQLITE3 0 -#endif - -#ifndef HAVE_STDINT_H -#define HAVE_STDINT_H 0 -#endif - -#ifndef HAVE_SYS_WAIT_H -#define HAVE_SYS_WAIT_H 0 -#endif - -#ifndef HAVE_SYS_TIME_H -#define HAVE_SYS_TIME_H 0 -#endif - -#ifndef HAVE_UNISTD_H -#define HAVE_UNISTD_H 0 -#endif - -#ifndef HAVE_PIPE -#define HAVE_PIPE 0 -#endif - -#ifndef HAVE_WAITPID -#define HAVE_WAITPID 0 -#endif - -#ifndef HAVE_X86INTRIN_H -#define HAVE_X86INTRIN_H 0 -#endif - -#if (defined __x86_64__) || (defined _M_X64) -#define CPU_IS_X86_64 1 /* Define both for x86_64 */ -#define CPU_IS_X86 1 -#elif defined (__i486__) || defined (__i586__) || defined (__i686__) || defined (_M_IX86) -#define CPU_IS_X86 1 -#define CPU_IS_X86_64 0 -#else -#define CPU_IS_X86 0 -#define CPU_IS_X86_64 0 -#endif - -#if (defined (__SSE2__) || defined (_M_AMD64) || (defined (_M_IX86_FP) && (_M_IX86_FP >= 2)) && HAVE_IMMINTRIN_H) -#define USE_SSE2 -#endif - -#endif diff --git a/Engine/lib/libsndfile/src/sfendian.h b/Engine/lib/libsndfile/src/sfendian.h deleted file mode 100644 index ab02742b2..000000000 --- a/Engine/lib/libsndfile/src/sfendian.h +++ /dev/null @@ -1,360 +0,0 @@ -/* -** Copyright (C) 1999-2018 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SFENDIAN_INCLUDED -#define SFENDIAN_INCLUDED - -#include "sfconfig.h" - -#include -#include - -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - -#if HAVE_BYTESWAP_H /* Linux, any CPU */ -#include - -#define ENDSWAP_16(x) (bswap_16 (x)) -#define ENDSWAP_32(x) (bswap_32 (x)) -#define ENDSWAP_64(x) (bswap_64 (x)) - -#elif __has_builtin(__builtin_bswap16) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64) - -#define ENDSWAP_16(x) ((int16_t) __builtin_bswap16 ((uint16_t) x)) -#define ENDSWAP_32(x) ((int32_t) __builtin_bswap32 ((uint32_t) x)) -#define ENDSWAP_64(x) ((int64_t) __builtin_bswap64 ((uint64_t) x)) - -#elif COMPILER_IS_GCC - -#if CPU_IS_X86 - -static inline int16_t -ENDSWAP_16X (int16_t x) -{ int16_t y ; - __asm__ ("rorw $8, %w0" : "=r" (y) : "0" (x) : "cc") ; - return y ; -} /* ENDSWAP_16 */ - -static inline int32_t -ENDSWAP_32X (int32_t x) -{ int32_t y ; - __asm__ ("bswap %0" : "=r" (y) : "0" (x)) ; - return y ; -} /* ENDSWAP_32 */ - -#define ENDSWAP_16 ENDSWAP_16X -#define ENDSWAP_32 ENDSWAP_32X - -#endif - -#if CPU_IS_X86_64 - -static inline int64_t -ENDSWAP_64X (int64_t x) -{ int64_t y ; - __asm__ ("bswap %q0" : "=r" (y) : "0" (x)) ; - return y ; -} /* ENDSWAP_64X */ - -#define ENDSWAP_64 ENDSWAP_64X - -#endif - -#elif defined _MSC_VER -#include - -#define ENDSWAP_16(x) (_byteswap_ushort (x)) -#define ENDSWAP_32(x) (_byteswap_ulong (x)) -#define ENDSWAP_64(x) (_byteswap_uint64 (x)) - -#endif - -#ifndef ENDSWAP_16 -#define ENDSWAP_16(x) ((((x) >> 8) & 0xFF) + (((x) & 0xFF) << 8)) -#endif - -#ifndef ENDSWAP_32 -#define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) + (((x) >> 8) & 0xFF00) + (((x) & 0xFF00) << 8) + (((x) & 0xFF) << 24)) -#endif - -#ifndef ENDSWAP_64 -static inline uint64_t -ENDSWAP_64 (uint64_t x) -{ union - { uint32_t parts [2] ; - uint64_t whole ; - } u ; - uint32_t temp ; - - u.whole = x ; - temp = u.parts [0] ; - u.parts [0] = ENDSWAP_32 (u.parts [1]) ; - u.parts [1] = ENDSWAP_32 (temp) ; - return u.whole ; -} -#endif - -/* -** Many file types (ie WAV, AIFF) use sets of four consecutive bytes as a -** marker indicating different sections of the file. -** The following MAKE_MARKER macro allows th creation of integer constants -** for these markers. -*/ - -#if (CPU_IS_LITTLE_ENDIAN == 1) - #define MAKE_MARKER(a, b, c, d) ((uint32_t) ((a) | ((b) << 8) | ((c) << 16) | (((uint32_t) (d)) << 24))) -#elif (CPU_IS_BIG_ENDIAN == 1) - #define MAKE_MARKER(a, b, c, d) ((uint32_t) ((((uint32_t) (a)) << 24) | ((b) << 16) | ((c) << 8) | (d))) -#else - #error "Target CPU endian-ness unknown. May need to hand edit src/sfconfig.h" -#endif - -/* -** Macros to handle reading of data of a specific endian-ness into host endian -** shorts and ints. The single input is an unsigned char* pointer to the start -** of the object. There are two versions of each macro as we need to deal with -** both big and little endian CPUs. -*/ - -#if (CPU_IS_LITTLE_ENDIAN == 1) - #define LE2H_16(x) (x) - #define LE2H_32(x) (x) - - #define BE2H_16(x) ENDSWAP_16 (x) - #define BE2H_32(x) ENDSWAP_32 (x) - #define BE2H_64(x) ENDSWAP_64 (x) - - #define H2BE_16(x) ENDSWAP_16 (x) - #define H2BE_32(x) ENDSWAP_32 (x) - - #define H2LE_16(x) (x) - #define H2LE_32(x) (x) - -#elif (CPU_IS_BIG_ENDIAN == 1) - #define LE2H_16(x) ENDSWAP_16 (x) - #define LE2H_32(x) ENDSWAP_32 (x) - - #define BE2H_16(x) (x) - #define BE2H_32(x) (x) - #define BE2H_64(x) (x) - - #define H2BE_16(x) (x) - #define H2BE_32(x) (x) - - #define H2LE_16(x) ENDSWAP_16 (x) - #define H2LE_32(x) ENDSWAP_32 (x) - -#else - #error "Target CPU endian-ness unknown. May need to hand edit src/sfconfig.h" -#endif - -#define LE2H_32_PTR(x) (((x) [0]) + ((x) [1] << 8) + ((x) [2] << 16) + ((x) [3] << 24)) - -#define LET2H_16_PTR(x) ((x) [1] + ((x) [2] << 8)) -#define LET2H_32_PTR(x) (((x) [0] << 8) + ((x) [1] << 16) + ((x) [2] << 24)) - -#define BET2H_16_PTR(x) (((x) [0] << 8) + (x) [1]) -#define BET2H_32_PTR(x) (((x) [0] << 24) + ((x) [1] << 16) + ((x) [2] << 8)) - -static inline void -psf_put_be64 (uint8_t *ptr, int offset, int64_t value) -{ - ptr [offset] = (uint8_t) (value >> 56) ; - ptr [offset + 1] = (uint8_t) (value >> 48) ; - ptr [offset + 2] = (uint8_t) (value >> 40) ; - ptr [offset + 3] = (uint8_t) (value >> 32) ; - ptr [offset + 4] = (uint8_t) (value >> 24) ; - ptr [offset + 5] = (uint8_t) (value >> 16) ; - ptr [offset + 6] = (uint8_t) (value >> 8) ; - ptr [offset + 7] = (uint8_t) value ; -} /* psf_put_be64 */ - -static inline void -psf_put_be32 (uint8_t *ptr, int offset, int32_t value) -{ - ptr [offset] = (uint8_t) (value >> 24) ; - ptr [offset + 1] = (uint8_t) (value >> 16) ; - ptr [offset + 2] = (uint8_t) (value >> 8) ; - ptr [offset + 3] = (uint8_t) value ; -} /* psf_put_be32 */ - -static inline void -psf_put_be16 (uint8_t *ptr, int offset, int16_t value) -{ - ptr [offset] = (uint8_t) (value >> 8) ; - ptr [offset + 1] = (uint8_t) value ; -} /* psf_put_be16 */ - -static inline int64_t -psf_get_be64 (const uint8_t *ptr, int offset) -{ int64_t value ; - - value = (int64_t) ((uint64_t) ptr [offset] << 24) ; - value += (int64_t) ((uint64_t) ptr [offset + 1] << 16) ; - value += (int64_t) ((uint64_t) ptr [offset + 2] << 8) ; - value += ptr [offset + 3] ; - - value = (int64_t) (((uint64_t) value) << 32) ; - - value += (int64_t) ((uint64_t) ptr [offset + 4] << 24) ; - value += (int64_t) ((uint64_t) ptr [offset + 5] << 16) ; - value += (int64_t) ((uint64_t) ptr [offset + 6] << 8) ; - value += ptr [offset + 7] ; - return value ; -} /* psf_get_be64 */ - -static inline int64_t -psf_get_le64 (const uint8_t *ptr, int offset) -{ int64_t value = (int64_t) ((uint64_t) ptr [offset + 7] << 24) ; - value += (int64_t) ((uint64_t) ptr [offset + 6] << 16) ; - value += (int64_t) ((uint64_t) ptr [offset + 5] << 8) ; - value += ptr [offset + 4] ; - - value = (int64_t) (((uint64_t) value) << 32) ; - - value += (int64_t) ((uint64_t) ptr [offset + 3] << 24) ; - value += (int64_t) ((uint64_t) ptr [offset + 2] << 16) ; - value += (int64_t) ((uint64_t) ptr [offset + 1] << 8) ; - value += ptr [offset] ; - return value ; -} /* psf_get_le64 */ - -static inline int32_t -psf_get_be32 (const uint8_t *ptr, int offset) -{ int32_t value = ((uint32_t) ptr [offset]) << 24 ; - value += ptr [offset + 1] << 16 ; - value += ptr [offset + 2] << 8 ; - value += ptr [offset + 3] ; - return value ; -} /* psf_get_be32 */ - -static inline int32_t -psf_get_le32 (const uint8_t *ptr, int offset) -{ int32_t value = ((uint32_t) ptr [offset + 3]) << 24 ; - value += ptr [offset + 2] << 16 ; - value += ptr [offset + 1] << 8 ; - value += ptr [offset] ; - return value ; -} /* psf_get_le32 */ - -static inline int32_t -psf_get_be24 (const uint8_t *ptr, int offset) -{ int32_t value = ((uint32_t) ptr [offset]) << 24 ; - value += ptr [offset + 1] << 16 ; - value += ptr [offset + 2] << 8 ; - return value ; -} /* psf_get_be24 */ - -static inline int32_t -psf_get_le24 (const uint8_t *ptr, int offset) -{ int32_t value = ((uint32_t) ptr [offset + 2]) << 24 ; - value += ptr [offset + 1] << 16 ; - value += ptr [offset] << 8 ; - return value ; -} /* psf_get_le24 */ - -static inline int16_t -psf_get_be16 (const uint8_t *ptr, int offset) -{ return (int16_t) (ptr [offset] << 8) + ptr [offset + 1] ; -} /* psf_get_be16 */ - -/*----------------------------------------------------------------------------------------------- -** Generic functions for performing endian swapping on integer arrays. -*/ - -static inline void -endswap_short_array (short *ptr, int len) -{ - for (int i = 0 ; i < len ; i++) - { short temp = ptr [i] ; - ptr [i] = ENDSWAP_16 (temp) ; - } ; -} /* endswap_short_array */ - -static inline void -endswap_short_copy (short *dest, const short *src, int len) -{ - for (int i = 0 ; i < len ; i++) - { dest [i] = ENDSWAP_16 (src [i]) ; - } ; -} /* endswap_short_copy */ - -static inline void -endswap_int_array (int *ptr, int len) -{ - for (int i = 0 ; i < len ; i++) - { int temp = ptr [i] ; - ptr [i] = ENDSWAP_32 (temp) ; - } ; -} /* endswap_int_array */ - -static inline void -endswap_int_copy (int *dest, const int *src, int len) -{ - for (int i = 0 ; i < len ; i++) - { dest [i] = ENDSWAP_32 (src [i]) ; - } ; -} /* endswap_int_copy */ - -/*======================================================================================== -*/ - -static inline void -endswap_int64_t_array (int64_t *ptr, int len) -{ - for (int i = 0 ; i < len ; i++) - { int64_t value = ptr [i] ; - ptr [i] = ENDSWAP_64 (value) ; - } ; -} /* endswap_int64_t_array */ - -static inline void -endswap_int64_t_copy (int64_t *dest, const int64_t *src, int len) -{ - for (int i = 0 ; i < len ; i++) - { int64_t value = src [i] ; - dest [i] = ENDSWAP_64 (value) ; - } ; -} /* endswap_int64_t_copy */ - -/* A couple of wrapper functions. */ - -static inline void -endswap_float_array (float *ptr, int len) -{ endswap_int_array ((int *) ptr, len) ; -} /* endswap_float_array */ - -static inline void -endswap_double_array (double *ptr, int len) -{ endswap_int64_t_array ((int64_t *) ptr, len) ; -} /* endswap_double_array */ - -static inline void -endswap_float_copy (float *dest, const float *src, int len) -{ endswap_int_copy ((int *) dest, (const int *) src, len) ; -} /* endswap_float_copy */ - -static inline void -endswap_double_copy (double *dest, const double *src, int len) -{ endswap_int64_t_copy ((int64_t *) dest, (const int64_t *) src, len) ; -} /* endswap_double_copy */ - -#endif /* SFENDIAN_INCLUDED */ - diff --git a/Engine/lib/libsndfile/src/sndfile.c b/Engine/lib/libsndfile/src/sndfile.c deleted file mode 100644 index 9a6c62275..000000000 --- a/Engine/lib/libsndfile/src/sndfile.c +++ /dev/null @@ -1,3450 +0,0 @@ -/* -** Copyright (C) 1999-2018 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if HAVE_UNISTD_H -#include -#elif defined _WIN32 -#include -#endif - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#endif - -#define SNDFILE_MAGICK 0x1234C0DE - -#ifdef __APPLE__ - /* - ** Detect if a compile for a universal binary is being attempted and barf if it is. - ** See the URL below for the rationale. - */ - #ifdef __BIG_ENDIAN__ - #if (CPU_IS_LITTLE_ENDIAN == 1) - #error "Universal binary compile detected. See http://libsndfile.github.io/libsndfile/FAQ.html#Q018" - #endif - #endif - - #ifdef __LITTLE_ENDIAN__ - #if (CPU_IS_BIG_ENDIAN == 1) - #error "Universal binary compile detected. See http://libsndfile.github.io/libsndfile/FAQ.html#Q018" - #endif - #endif -#endif - - -typedef struct -{ int error ; - const char *str ; -} ErrorStruct ; - -static -ErrorStruct SndfileErrors [] = -{ - /* Public error values and their associated strings. */ - { SF_ERR_NO_ERROR , "No Error." }, - { SF_ERR_UNRECOGNISED_FORMAT , "Format not recognised." }, - { SF_ERR_SYSTEM , "System error." /* Often replaced. */ }, - { SF_ERR_MALFORMED_FILE , "Supported file format but file is malformed." }, - { SF_ERR_UNSUPPORTED_ENCODING , "Supported file format but unsupported encoding." }, - - /* Private error values and their associated strings. */ - { SFE_ZERO_MAJOR_FORMAT , "Error : major format is 0." }, - { SFE_ZERO_MINOR_FORMAT , "Error : minor format is 0." }, - { SFE_BAD_FILE , "File does not exist or is not a regular file (possibly a pipe?)." }, - { SFE_BAD_FILE_READ , "File exists but no data could be read." }, - { SFE_OPEN_FAILED , "Could not open file." }, - { SFE_BAD_SNDFILE_PTR , "Not a valid SNDFILE* pointer." }, - { SFE_BAD_SF_INFO_PTR , "NULL SF_INFO pointer passed to libsndfile." }, - { SFE_BAD_SF_INCOMPLETE , "SF_PRIVATE struct incomplete and end of header parsing." }, - { SFE_BAD_FILE_PTR , "Bad FILE pointer." }, - { SFE_BAD_INT_PTR , "Internal error, Bad pointer." }, - { SFE_BAD_STAT_SIZE , "Error : software was misconfigured at compile time (sizeof statbuf.st_size)." }, - { SFE_NO_TEMP_DIR , "Error : Could not file temp dir." }, - - { SFE_MALLOC_FAILED , "Internal malloc () failed." }, - { SFE_UNIMPLEMENTED , "File contains data in an unimplemented format." }, - { SFE_BAD_READ_ALIGN , "Attempt to read a non-integer number of channels." }, - { SFE_BAD_WRITE_ALIGN , "Attempt to write a non-integer number of channels." }, - { SFE_NOT_READMODE , "Read attempted on file currently open for write." }, - { SFE_NOT_WRITEMODE , "Write attempted on file currently open for read." }, - { SFE_BAD_MODE_RW , "Error : This file format does not support read/write mode." }, - { SFE_BAD_SF_INFO , "Internal error : SF_INFO struct incomplete." }, - { SFE_BAD_OFFSET , "Error : supplied offset beyond end of file." }, - { SFE_NO_EMBED_SUPPORT , "Error : embedding not supported for this file format." }, - { SFE_NO_EMBEDDED_RDWR , "Error : cannot open embedded file read/write." }, - { SFE_NO_PIPE_WRITE , "Error : this file format does not support pipe write." }, - { SFE_BAD_VIRTUAL_IO , "Error : bad pointer on SF_VIRTUAL_IO struct." }, - { SFE_BAD_BROADCAST_INFO_SIZE - , "Error : bad coding_history_size in SF_BROADCAST_INFO struct." }, - { SFE_BAD_BROADCAST_INFO_TOO_BIG - , "Error : SF_BROADCAST_INFO struct too large." }, - { SFE_BAD_CART_INFO_SIZE , "Error: SF_CART_INFO struct too large." }, - { SFE_BAD_CART_INFO_TOO_BIG , "Error: bad tag_text_size in SF_CART_INFO struct." }, - { SFE_INTERLEAVE_MODE , "Attempt to write to file with non-interleaved data." }, - { SFE_INTERLEAVE_SEEK , "Bad karma in seek during interleave read operation." }, - { SFE_INTERLEAVE_READ , "Bad karma in read during interleave read operation." }, - - { SFE_INTERNAL , "Unspecified internal error." }, - { SFE_BAD_COMMAND_PARAM , "Bad parameter passed to function sf_command." }, - { SFE_BAD_ENDIAN , "Bad endian-ness. Try default endian-ness" }, - { SFE_CHANNEL_COUNT_ZERO , "Channel count is zero." }, - { SFE_CHANNEL_COUNT , "Too many channels specified." }, - { SFE_CHANNEL_COUNT_BAD , "Bad channel count." }, - - { SFE_BAD_SEEK , "Internal psf_fseek() failed." }, - { SFE_NOT_SEEKABLE , "Seek attempted on unseekable file type." }, - { SFE_AMBIGUOUS_SEEK , "Error : combination of file open mode and seek command is ambiguous." }, - { SFE_WRONG_SEEK , "Error : invalid seek parameters." }, - { SFE_SEEK_FAILED , "Error : parameters OK, but psf_seek() failed." }, - - { SFE_BAD_OPEN_MODE , "Error : bad mode parameter for file open." }, - { SFE_OPEN_PIPE_RDWR , "Error : attempt to open a pipe in read/write mode." }, - { SFE_RDWR_POSITION , "Error on RDWR position (cryptic)." }, - { SFE_RDWR_BAD_HEADER , "Error : Cannot open file in read/write mode due to string data in header." }, - { SFE_CMD_HAS_DATA , "Error : Command fails because file already has audio data." }, - - { SFE_STR_NO_SUPPORT , "Error : File type does not support string data." }, - { SFE_STR_NOT_WRITE , "Error : Trying to set a string when file is not in write mode." }, - { SFE_STR_MAX_DATA , "Error : Maximum string data storage reached." }, - { SFE_STR_MAX_COUNT , "Error : Maximum string data count reached." }, - { SFE_STR_BAD_TYPE , "Error : Bad string data type." }, - { SFE_STR_NO_ADD_END , "Error : file type does not support strings added at end of file." }, - { SFE_STR_BAD_STRING , "Error : bad string." }, - { SFE_STR_WEIRD , "Error : Weird string error." }, - - { SFE_WAV_NO_RIFF , "Error in WAV file. No 'RIFF' chunk marker." }, - { SFE_WAV_NO_WAVE , "Error in WAV file. No 'WAVE' chunk marker." }, - { SFE_WAV_NO_FMT , "Error in WAV/W64/RF64 file. No 'fmt ' chunk marker." }, - { SFE_WAV_BAD_FMT , "Error in WAV/W64/RF64 file. Malformed 'fmt ' chunk." }, - { SFE_WAV_FMT_SHORT , "Error in WAV/W64/RF64 file. Short 'fmt ' chunk." }, - - { SFE_WAV_BAD_FACT , "Error in WAV file. 'fact' chunk out of place." }, - { SFE_WAV_BAD_PEAK , "Error in WAV file. Bad 'PEAK' chunk." }, - { SFE_WAV_PEAK_B4_FMT , "Error in WAV file. 'PEAK' chunk found before 'fmt ' chunk." }, - - { SFE_WAV_BAD_FORMAT , "Error in WAV file. Errors in 'fmt ' chunk." }, - { SFE_WAV_BAD_BLOCKALIGN , "Error in WAV file. Block alignment in 'fmt ' chunk is incorrect." }, - { SFE_WAV_NO_DATA , "Error in WAV file. No 'data' chunk marker." }, - { SFE_WAV_BAD_LIST , "Error in WAV file. Malformed LIST chunk." }, - { SFE_WAV_UNKNOWN_CHUNK , "Error in WAV file. File contains an unknown chunk marker." }, - { SFE_WAV_WVPK_DATA , "Error in WAV file. Data is in WAVPACK format." }, - - { SFE_WAV_ADPCM_NOT4BIT , "Error in ADPCM WAV file. Invalid bit width." }, - { SFE_WAV_ADPCM_CHANNELS , "Error in ADPCM WAV file. Invalid number of channels." }, - { SFE_WAV_ADPCM_SAMPLES , "Error in ADPCM WAV file. Invalid number of samples per block." }, - { SFE_WAV_GSM610_FORMAT , "Error in GSM610 WAV file. Invalid format chunk." }, - { SFE_WAV_NMS_FORMAT , "Error in NMS ADPCM WAV file. Invalid format chunk." }, - - { SFE_AIFF_NO_FORM , "Error in AIFF file, bad 'FORM' marker." }, - { SFE_AIFF_AIFF_NO_FORM , "Error in AIFF file, 'AIFF' marker without 'FORM'." }, - { SFE_AIFF_COMM_NO_FORM , "Error in AIFF file, 'COMM' marker without 'FORM'." }, - { SFE_AIFF_SSND_NO_COMM , "Error in AIFF file, 'SSND' marker without 'COMM'." }, - { SFE_AIFF_UNKNOWN_CHUNK , "Error in AIFF file, unknown chunk." }, - { SFE_AIFF_COMM_CHUNK_SIZE, "Error in AIFF file, bad 'COMM' chunk size." }, - { SFE_AIFF_BAD_COMM_CHUNK , "Error in AIFF file, bad 'COMM' chunk." }, - { SFE_AIFF_PEAK_B4_COMM , "Error in AIFF file. 'PEAK' chunk found before 'COMM' chunk." }, - { SFE_AIFF_BAD_PEAK , "Error in AIFF file. Bad 'PEAK' chunk." }, - { SFE_AIFF_NO_SSND , "Error in AIFF file, bad 'SSND' chunk." }, - { SFE_AIFF_NO_DATA , "Error in AIFF file, no sound data." }, - { SFE_AIFF_RW_SSND_NOT_LAST, "Error in AIFF file, RDWR only possible if SSND chunk at end of file." }, - - { SFE_AU_UNKNOWN_FORMAT , "Error in AU file, unknown format." }, - { SFE_AU_NO_DOTSND , "Error in AU file, missing '.snd' or 'dns.' marker." }, - { SFE_AU_EMBED_BAD_LEN , "Embedded AU file with unknown length." }, - - { SFE_RAW_READ_BAD_SPEC , "Error while opening RAW file for read. Must specify format and channels.\n" - "Possibly trying to open unsupported format." }, - { SFE_RAW_BAD_BITWIDTH , "Error. RAW file bitwidth must be a multiple of 8." }, - { SFE_RAW_BAD_FORMAT , "Error. Bad format field in SF_INFO struct when opening a RAW file for read." }, - - { SFE_PAF_NO_MARKER , "Error in PAF file, no marker." }, - { SFE_PAF_VERSION , "Error in PAF file, bad version." }, - { SFE_PAF_UNKNOWN_FORMAT , "Error in PAF file, unknown format." }, - { SFE_PAF_SHORT_HEADER , "Error in PAF file. File shorter than minimal header." }, - { SFE_PAF_BAD_CHANNELS , "Error in PAF file. Bad channel count." }, - - { SFE_SVX_NO_FORM , "Error in 8SVX / 16SV file, no 'FORM' marker." }, - { SFE_SVX_NO_BODY , "Error in 8SVX / 16SV file, no 'BODY' marker." }, - { SFE_SVX_NO_DATA , "Error in 8SVX / 16SV file, no sound data." }, - { SFE_SVX_BAD_COMP , "Error in 8SVX / 16SV file, unsupported compression format." }, - { SFE_SVX_BAD_NAME_LENGTH , "Error in 8SVX / 16SV file, NAME chunk too long." }, - - { SFE_NIST_BAD_HEADER , "Error in NIST file, bad header." }, - { SFE_NIST_CRLF_CONVERISON, "Error : NIST file damaged by Windows CR -> CRLF conversion process." }, - { SFE_NIST_BAD_ENCODING , "Error in NIST file, unsupported compression format." }, - - { SFE_VOC_NO_CREATIVE , "Error in VOC file, no 'Creative Voice File' marker." }, - { SFE_VOC_BAD_FORMAT , "Error in VOC file, bad format." }, - { SFE_VOC_BAD_VERSION , "Error in VOC file, bad version number." }, - { SFE_VOC_BAD_MARKER , "Error in VOC file, bad marker in file." }, - { SFE_VOC_BAD_SECTIONS , "Error in VOC file, incompatible VOC sections." }, - { SFE_VOC_MULTI_SAMPLERATE, "Error in VOC file, more than one sample rate defined." }, - { SFE_VOC_MULTI_SECTION , "Unimplemented VOC file feature, file contains multiple sound sections." }, - { SFE_VOC_MULTI_PARAM , "Error in VOC file, file contains multiple bit or channel widths." }, - { SFE_VOC_SECTION_COUNT , "Error in VOC file, too many sections." }, - { SFE_VOC_NO_PIPE , "Error : not able to operate on VOC files over a pipe." }, - - { SFE_IRCAM_NO_MARKER , "Error in IRCAM file, bad IRCAM marker." }, - { SFE_IRCAM_BAD_CHANNELS , "Error in IRCAM file, bad channel count." }, - { SFE_IRCAM_UNKNOWN_FORMAT, "Error in IRCAM file, unknown encoding format." }, - - { SFE_W64_64_BIT , "Error in W64 file, file contains 64 bit offset." }, - { SFE_W64_NO_RIFF , "Error in W64 file. No 'riff' chunk marker." }, - { SFE_W64_NO_WAVE , "Error in W64 file. No 'wave' chunk marker." }, - { SFE_W64_NO_DATA , "Error in W64 file. No 'data' chunk marker." }, - { SFE_W64_ADPCM_NOT4BIT , "Error in ADPCM W64 file. Invalid bit width." }, - { SFE_W64_ADPCM_CHANNELS , "Error in ADPCM W64 file. Invalid number of channels." }, - { SFE_W64_GSM610_FORMAT , "Error in GSM610 W64 file. Invalid format chunk." }, - - { SFE_MAT4_BAD_NAME , "Error in MAT4 file. No variable name." }, - { SFE_MAT4_NO_SAMPLERATE , "Error in MAT4 file. No sample rate." }, - - { SFE_MAT5_BAD_ENDIAN , "Error in MAT5 file. Not able to determine endian-ness." }, - { SFE_MAT5_NO_BLOCK , "Error in MAT5 file. Bad block structure." }, - { SFE_MAT5_SAMPLE_RATE , "Error in MAT5 file. Not able to determine sample rate." }, - - { SFE_PVF_NO_PVF1 , "Error in PVF file. No PVF1 marker." }, - { SFE_PVF_BAD_HEADER , "Error in PVF file. Bad header." }, - { SFE_PVF_BAD_BITWIDTH , "Error in PVF file. Bad bit width." }, - - { SFE_XI_BAD_HEADER , "Error in XI file. Bad header." }, - { SFE_XI_EXCESS_SAMPLES , "Error in XI file. Excess samples in file." }, - { SFE_XI_NO_PIPE , "Error : not able to operate on XI files over a pipe." }, - - { SFE_HTK_NO_PIPE , "Error : not able to operate on HTK files over a pipe." }, - - { SFE_SDS_NOT_SDS , "Error : not an SDS file." }, - { SFE_SDS_BAD_BIT_WIDTH , "Error : bad bit width for SDS file." }, - - { SFE_SD2_FD_DISALLOWED , "Error : cannot open SD2 file without a file name." }, - { SFE_SD2_BAD_DATA_OFFSET , "Error : bad data offset." }, - { SFE_SD2_BAD_MAP_OFFSET , "Error : bad map offset." }, - { SFE_SD2_BAD_DATA_LENGTH , "Error : bad data length." }, - { SFE_SD2_BAD_MAP_LENGTH , "Error : bad map length." }, - { SFE_SD2_BAD_RSRC , "Error : bad resource fork." }, - { SFE_SD2_BAD_SAMPLE_SIZE , "Error : bad sample size." }, - - { SFE_FLAC_BAD_HEADER , "Error : bad flac header." }, - { SFE_FLAC_NEW_DECODER , "Error : problem while creating flac decoder." }, - { SFE_FLAC_INIT_DECODER , "Error : problem with initialization of the flac decoder." }, - { SFE_FLAC_LOST_SYNC , "Error : flac decoder lost sync." }, - { SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." }, - { SFE_FLAC_CHANNEL_COUNT_CHANGED, "Error : flac channel changed mid stream." }, - { SFE_FLAC_UNKOWN_ERROR , "Error : unknown error in flac decoder." }, - - { SFE_WVE_NOT_WVE , "Error : not a WVE file." }, - { SFE_WVE_NO_PIPE , "Error : not able to operate on WVE files over a pipe." }, - - { SFE_DWVW_BAD_BITWIDTH , "Error : Bad bit width for DWVW encoding. Must be 12, 16 or 24." }, - { SFE_G72X_NOT_MONO , "Error : G72x encoding does not support more than 1 channel." }, - { SFE_NMS_ADPCM_NOT_MONO , "Error : NMS ADPCM encoding does not support more than 1 channel." }, - - { SFE_VORBIS_ENCODER_BUG , "Error : Sample rate chosen is known to trigger a Vorbis encoder bug on this CPU." }, - - { SFE_RF64_NOT_RF64 , "Error : Not an RF64 file." }, - { SFE_RF64_PEAK_B4_FMT , "Error in RF64 file. 'PEAK' chunk found before 'fmt ' chunk." }, - { SFE_RF64_NO_DATA , "Error in RF64 file. No 'data' chunk marker." }, - - { SFE_ALAC_FAIL_TMPFILE , "Error : Failed to open tmp file for ALAC encoding." }, - - { SFE_BAD_CHUNK_PTR , "Error : Bad SF_CHUNK_INFO pointer." }, - { SFE_UNKNOWN_CHUNK , "Error : Unknown chunk marker." }, - { SFE_BAD_CHUNK_FORMAT , "Error : Reading/writing chunks from this file format is not supported." }, - { SFE_BAD_CHUNK_MARKER , "Error : Bad chunk marker." }, - { SFE_BAD_CHUNK_DATA_PTR , "Error : Bad data pointer in SF_CHUNK_INFO struct." }, - { SFE_FILENAME_TOO_LONG , "Error : Supplied filename too long." }, - { SFE_NEGATIVE_RW_LEN , "Error : Length parameter passed to read/write is negative." }, - - { SFE_OPUS_BAD_SAMPLERATE , "Error : Opus only supports sample rates of 8000, 12000, 16000, 24000, and 48000." }, - - { SFE_MPEG_BAD_SAMPLERATE , "Error : MPEG-1/2/2.5 only supports sample rates of 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, and 48000." }, - - { SFE_CAF_NOT_CAF , "Error : Not a CAF file." }, - { SFE_CAF_NO_DESC , "Error : No 'desc' marker in CAF file." }, - { SFE_CAF_BAD_PEAK , "Error : Bad 'PEAK' chunk in CAF file." }, - - { SFE_AVR_NOT_AVR , "Error : Not an AVR file." }, - { SFE_AVR_BAD_REZ_SIGN , "Error : Bad rez/sign combination." }, - - { SFE_MPC_NO_MARKER , "Error : No marker in MPC2K file." }, - - { SFE_MAX_ERROR , "Maximum error number." }, - { SFE_MAX_ERROR + 1 , NULL } -} ; - -/*------------------------------------------------------------------------------ -*/ - -static int format_from_extension (SF_PRIVATE *psf) ; -static int guess_file_type (SF_PRIVATE *psf) ; -static int validate_sfinfo (SF_INFO *sfinfo) ; -static int validate_psf (SF_PRIVATE *psf) ; -static void save_header_info (SF_PRIVATE *psf) ; -static int psf_close (SF_PRIVATE *psf) ; - -static int try_resource_fork (SF_PRIVATE * psf) ; - -/*------------------------------------------------------------------------------ -** Private (static) variables. -*/ - -int sf_errno = 0 ; -static char sf_parselog [SF_BUFFER_LEN] = { 0 } ; -static char sf_syserr [SF_SYSERR_LEN] = { 0 } ; - -/*------------------------------------------------------------------------------ -*/ - -#define VALIDATE_SNDFILE_AND_ASSIGN_PSF(a, b, c) \ - { if ((a) == NULL) \ - { sf_errno = SFE_BAD_SNDFILE_PTR ; \ - return 0 ; \ - } ; \ - (b) = (SF_PRIVATE*) (a) ; \ - if ((b)->virtual_io == SF_FALSE && \ - psf_file_valid (b) == 0) \ - { (b)->error = SFE_BAD_FILE_PTR ; \ - return 0 ; \ - } ; \ - if ((b)->Magick != SNDFILE_MAGICK) \ - { (b)->error = SFE_BAD_SNDFILE_PTR ; \ - return 0 ; \ - } ; \ - if (c) (b)->error = 0 ; \ - } - -/*------------------------------------------------------------------------------ -** Public functions. -*/ - -SNDFILE* -sf_open (const char *path, int mode, SF_INFO *sfinfo) -{ SF_PRIVATE *psf ; - const char *utf8path_ptr ; -#ifdef _WIN32 - LPWSTR wpath ; - int nResult ; - int wpath_len ; - char utf8path [SF_FILENAME_LEN] ; - DWORD dwError ; -#endif - - /* Ultimate sanity check. */ - assert (sizeof (sf_count_t) == 8) ; - - if ((psf = psf_allocate ()) == NULL) - { sf_errno = SFE_MALLOC_FAILED ; - return NULL ; - } ; - - psf_init_files (psf) ; - - psf_log_printf (psf, "File : %s\n", path) ; - -#ifdef _WIN32 - nResult = MultiByteToWideChar (CP_ACP, 0, path, -1, NULL, 0) ; - if (nResult == 0) - { sf_errno = SF_ERR_UNSUPPORTED_ENCODING ; - psf_close (psf) ; - return NULL ; - } ; - - wpath_len = nResult ; - wpath = malloc (wpath_len * sizeof (WCHAR)) ; - if (!wpath) - { sf_errno = SFE_MALLOC_FAILED ; - psf_close (psf) ; - return NULL ; - } ; - - nResult = MultiByteToWideChar (CP_ACP, 0, path, -1, wpath, wpath_len) ; - if (nResult == 0) - { sf_errno = SF_ERR_UNSUPPORTED_ENCODING ; - free (wpath) ; - psf_close (psf) ; - return NULL ; - } ; - - nResult = WideCharToMultiByte (CP_UTF8, 0, wpath, wpath_len, NULL, 0, NULL, - NULL) ; - if (nResult == 0) - { sf_errno = SF_ERR_UNSUPPORTED_ENCODING ; - free (wpath) ; - psf_close (psf) ; - return NULL ; - } ; - - nResult = WideCharToMultiByte (CP_UTF8, 0, wpath, wpath_len, utf8path, - SF_FILENAME_LEN, NULL, NULL) ; - - free (wpath) ; - - if (nResult == 0) - { dwError = GetLastError () ; - if (dwError == ERROR_INSUFFICIENT_BUFFER) - sf_errno = SFE_FILENAME_TOO_LONG ; - else - sf_errno = SF_ERR_UNSUPPORTED_ENCODING ; - psf_close (psf) ; - return NULL ; - } ; - - utf8path_ptr = utf8path ; -#else - utf8path_ptr = path ; -#endif - - if (psf_copy_filename (psf, utf8path_ptr) != 0) - { sf_errno = psf->error ; - psf_close (psf) ; - return NULL ; - } ; - - psf->file.mode = mode ; - if (strcmp (path, "-") == 0) - psf->error = psf_set_stdio (psf) ; - else - psf->error = psf_fopen (psf) ; - - return psf_open_file (psf, sfinfo) ; -} /* sf_open */ - -SNDFILE* -sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) -{ SF_PRIVATE *psf ; - - if ((SF_CONTAINER (sfinfo->format)) == SF_FORMAT_SD2) - { sf_errno = SFE_SD2_FD_DISALLOWED ; - if (close_desc) - close (fd) ; - - return NULL ; - } ; - - if ((psf = psf_allocate ()) == NULL) - { sf_errno = SFE_MALLOC_FAILED ; - if (close_desc) - close (fd) ; - - return NULL ; - } ; - - psf_init_files (psf) ; - psf_copy_filename (psf, "") ; - - psf->file.mode = mode ; - psf->file.do_not_close_descriptor = !close_desc; - psf_set_file (psf, fd) ; - psf->is_pipe = psf_is_pipe (psf) ; - psf->fileoffset = psf_ftell (psf) ; - - return psf_open_file (psf, sfinfo) ; -} /* sf_open_fd */ - -SNDFILE* -sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) -{ SF_PRIVATE *psf ; - - /* Make sure we have a valid set ot virtual pointers. */ - if (sfvirtual->get_filelen == NULL) - { sf_errno = SFE_BAD_VIRTUAL_IO ; - snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_get_filelen in SF_VIRTUAL_IO struct.\n") ; - return NULL ; - } ; - - if ((sfvirtual->seek == NULL || sfvirtual->tell == NULL) && sfinfo->seekable) - { sf_errno = SFE_BAD_VIRTUAL_IO ; - snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_seek / vio_tell in SF_VIRTUAL_IO struct.\n") ; - return NULL ; - } ; - - if ((mode == SFM_READ || mode == SFM_RDWR) && sfvirtual->read == NULL) - { sf_errno = SFE_BAD_VIRTUAL_IO ; - snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_read in SF_VIRTUAL_IO struct.\n") ; - return NULL ; - } ; - - if ((mode == SFM_WRITE || mode == SFM_RDWR) && sfvirtual->write == NULL) - { sf_errno = SFE_BAD_VIRTUAL_IO ; - snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_write in SF_VIRTUAL_IO struct.\n") ; - return NULL ; - } ; - - if ((psf = psf_allocate ()) == NULL) - { sf_errno = SFE_MALLOC_FAILED ; - return NULL ; - } ; - - psf_init_files (psf) ; - - psf->virtual_io = SF_TRUE ; - psf->vio = *sfvirtual ; - psf->vio_user_data = user_data ; - - psf->file.mode = mode ; - - return psf_open_file (psf, sfinfo) ; -} /* sf_open_virtual */ - -int -sf_close (SNDFILE *sndfile) -{ SF_PRIVATE *psf ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - return psf_close (psf) ; -} /* sf_close */ - -void -sf_write_sync (SNDFILE *sndfile) -{ SF_PRIVATE *psf ; - - if ((psf = (SF_PRIVATE *) sndfile) == NULL) - return ; - - psf_fsync (psf) ; - - return ; -} /* sf_write_sync */ - -/*============================================================================== -*/ - -const char* -sf_error_number (int errnum) -{ static const char *bad_errnum = - "No error defined for this error number. This is a bug in libsndfile." ; - int k ; - - if (errnum == SFE_MAX_ERROR) - return SndfileErrors [0].str ; - - if (errnum < 0 || errnum > SFE_MAX_ERROR) - { /* This really shouldn't happen in release versions. */ - printf ("Not a valid error number (%d).\n", errnum) ; - return bad_errnum ; - } ; - - for (k = 0 ; SndfileErrors [k].str ; k++) - if (errnum == SndfileErrors [k].error) - return SndfileErrors [k].str ; - - return bad_errnum ; -} /* sf_error_number */ - -const char* -sf_strerror (SNDFILE *sndfile) -{ SF_PRIVATE *psf = NULL ; - int errnum ; - - if (sndfile == NULL) - { errnum = sf_errno ; - if (errnum == SFE_SYSTEM && sf_syserr [0]) - return sf_syserr ; - } - else - { psf = (SF_PRIVATE *) sndfile ; - - if (psf->Magick != SNDFILE_MAGICK) - return "sf_strerror : Bad magic number." ; - - errnum = psf->error ; - - if (errnum == SFE_SYSTEM && psf->syserr [0]) - return psf->syserr ; - } ; - - return sf_error_number (errnum) ; -} /* sf_strerror */ - -/*------------------------------------------------------------------------------ -*/ - -int -sf_error (SNDFILE *sndfile) -{ SF_PRIVATE *psf ; - - if (sndfile == NULL) - return sf_errno ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 0) ; - - if (psf->error) - return psf->error ; - - return 0 ; -} /* sf_error */ - -/*------------------------------------------------------------------------------ -*/ - -int -sf_perror (SNDFILE *sndfile) -{ SF_PRIVATE *psf ; - int errnum ; - - if (sndfile == NULL) - { errnum = sf_errno ; - } - else - { VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 0) ; - errnum = psf->error ; - } ; - - fprintf (stderr, "%s\n", sf_error_number (errnum)) ; - return SFE_NO_ERROR ; -} /* sf_perror */ - - -/*------------------------------------------------------------------------------ -*/ - -int -sf_error_str (SNDFILE *sndfile, char *str, size_t maxlen) -{ SF_PRIVATE *psf ; - int errnum ; - - if (str == NULL) - return SFE_INTERNAL ; - - if (sndfile == NULL) - errnum = sf_errno ; - else - { VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 0) ; - errnum = psf->error ; - } ; - - snprintf (str, maxlen, "%s", sf_error_number (errnum)) ; - - return SFE_NO_ERROR ; -} /* sf_error_str */ - -/*============================================================================== -*/ - -int -sf_format_check (const SF_INFO *info) -{ int subformat, endian ; - - subformat = SF_CODEC (info->format) ; - endian = SF_ENDIAN (info->format) ; - - /* This is the place where each file format can check if the supplied - ** SF_INFO struct is valid. - ** Return 0 on failure, 1 ons success. - */ - - if (info->channels < 1 || info->channels > SF_MAX_CHANNELS) - return 0 ; - - if (info->samplerate < 0) - return 0 ; - - switch (SF_CONTAINER (info->format)) - { case SF_FORMAT_WAV : - /* WAV now allows both endian, RIFF or RIFX (little or big respectively) */ - if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if ((subformat == SF_FORMAT_IMA_ADPCM || subformat == SF_FORMAT_MS_ADPCM) && info->channels <= 2) - return 1 ; - if (subformat == SF_FORMAT_GSM610 && info->channels == 1) - return 1 ; - if (subformat == SF_FORMAT_G721_32 && info->channels == 1) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - if ((subformat == SF_FORMAT_NMS_ADPCM_16 || subformat == SF_FORMAT_NMS_ADPCM_24 || - subformat == SF_FORMAT_NMS_ADPCM_32) && info->channels == 1) - return 1 ; - if (subformat == SF_FORMAT_MPEG_LAYER_III && info->channels <= 2) - return 1 ; - break ; - - case SF_FORMAT_WAVEX : - if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - break ; - - case SF_FORMAT_AIFF : - /* AIFF does allow both endian-nesses for PCM data.*/ - if (subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - /* For other encodings reject any endian-ness setting. */ - if (endian != 0) - return 0 ; - if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_S8) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) - return 1 ; - if ((subformat == SF_FORMAT_DWVW_12 || subformat == SF_FORMAT_DWVW_16 || - subformat == SF_FORMAT_DWVW_24) && info-> channels == 1) - return 1 ; - if (subformat == SF_FORMAT_GSM610 && info->channels == 1) - return 1 ; - if (subformat == SF_FORMAT_IMA_ADPCM && (info->channels == 1 || info->channels == 2)) - return 1 ; - break ; - - case SF_FORMAT_AU : - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - if (subformat == SF_FORMAT_G721_32 && info->channels == 1) - return 1 ; - if (subformat == SF_FORMAT_G723_24 && info->channels == 1) - return 1 ; - if (subformat == SF_FORMAT_G723_40 && info->channels == 1) - return 1 ; - break ; - - case SF_FORMAT_CAF : - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) - return 1 ; - if (subformat == SF_FORMAT_ALAC_16 || subformat == SF_FORMAT_ALAC_20) - return 1 ; - if (subformat == SF_FORMAT_ALAC_24 || subformat == SF_FORMAT_ALAC_32) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - break ; - - case SF_FORMAT_RAW : - if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - if (subformat == SF_FORMAT_ALAW || subformat == SF_FORMAT_ULAW) - return 1 ; - if ((subformat == SF_FORMAT_DWVW_12 || subformat == SF_FORMAT_DWVW_16 || - subformat == SF_FORMAT_DWVW_24) && info-> channels == 1) - return 1 ; - if (subformat == SF_FORMAT_GSM610 && info->channels == 1) - return 1 ; - if (subformat == SF_FORMAT_VOX_ADPCM && info->channels == 1) - return 1 ; - if ((subformat == SF_FORMAT_NMS_ADPCM_16 || subformat == SF_FORMAT_NMS_ADPCM_24 || - subformat == SF_FORMAT_NMS_ADPCM_32) && info->channels == 1) - return 1 ; - break ; - - case SF_FORMAT_PAF : - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24) - return 1 ; - break ; - - case SF_FORMAT_SVX : - /* SVX only supports writing mono SVX files. */ - if (info->channels > 1) - return 0 ; - /* Always big endian. */ - if (endian == SF_ENDIAN_LITTLE || endian == SF_ENDIAN_CPU) - return 0 ; - - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - break ; - - case SF_FORMAT_NIST : - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) - return 1 ; - break ; - - case SF_FORMAT_IRCAM : - if (info->channels > 256) - return 0 ; - if (subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW || subformat == SF_FORMAT_FLOAT) - return 1 ; - break ; - - case SF_FORMAT_VOC : - if (info->channels > 2) - return 0 ; - /* VOC is strictly little endian. */ - if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) - return 1 ; - break ; - - case SF_FORMAT_W64 : - /* W64 is strictly little endian. */ - if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if ((subformat == SF_FORMAT_IMA_ADPCM || subformat == SF_FORMAT_MS_ADPCM) && info->channels <= 2) - return 1 ; - if (subformat == SF_FORMAT_GSM610 && info->channels == 1) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - break ; - - case SF_FORMAT_MAT4 : - if (subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - break ; - - case SF_FORMAT_MAT5 : - if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - break ; - - case SF_FORMAT_PVF : - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_32) - return 1 ; - break ; - - case SF_FORMAT_XI : - if (info->channels != 1) - return 0 ; - if (subformat == SF_FORMAT_DPCM_8 || subformat == SF_FORMAT_DPCM_16) - return 1 ; - break ; - - case SF_FORMAT_HTK : - if (info->channels != 1) - return 0 ; - /* HTK is strictly big endian. */ - if (endian == SF_ENDIAN_LITTLE || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_PCM_16) - return 1 ; - break ; - - case SF_FORMAT_SDS : - if (info->channels != 1) - return 0 ; - /* SDS is strictly big endian. */ - if (endian == SF_ENDIAN_LITTLE || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24) - return 1 ; - break ; - - case SF_FORMAT_AVR : - if (info->channels > 2) - return 0 ; - /* SDS is strictly big endian. */ - if (endian == SF_ENDIAN_LITTLE || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - break ; - - case SF_FORMAT_FLAC : - /* FLAC can't do more than 8 channels. */ - if (info->channels > 8) - return 0 ; - if (endian != SF_ENDIAN_FILE) - return 0 ; - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24) - return 1 ; - break ; - - case SF_FORMAT_SD2 : - /* SD2 is strictly big endian. */ - if (endian == SF_ENDIAN_LITTLE || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_16 || subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - break ; - - case SF_FORMAT_WVE : - if (info->channels > 1) - return 0 ; - /* WVE is strictly big endian. */ - if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_ALAW) - return 1 ; - break ; - - case SF_FORMAT_OGG : - if (endian != SF_ENDIAN_FILE) - return 0 ; - if (subformat == SF_FORMAT_VORBIS) - return 1 ; - if (subformat == SF_FORMAT_OPUS) - return 1 ; - break ; - - case SF_FORMAT_MPC2K : - if (info->channels > 2) - return 0 ; - /* MPC2000 is strictly little endian. */ - if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_PCM_16) - return 1 ; - break ; - - case SF_FORMAT_RF64 : - if (endian == SF_ENDIAN_BIG || endian == SF_ENDIAN_CPU) - return 0 ; - if (subformat == SF_FORMAT_PCM_U8 || subformat == SF_FORMAT_PCM_16) - return 1 ; - if (subformat == SF_FORMAT_PCM_24 || subformat == SF_FORMAT_PCM_32) - return 1 ; - if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW) - return 1 ; - if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE) - return 1 ; - break ; - - case SF_FORMAT_MPEG : - if (info->channels > 2) - return 0 ; - if (endian != SF_ENDIAN_FILE) - return 0 ; - if (subformat == SF_FORMAT_MPEG_LAYER_I || subformat == SF_FORMAT_MPEG_LAYER_II || subformat == SF_FORMAT_MPEG_LAYER_III) - return 1 ; - break ; - default : break ; - } ; - - return 0 ; -} /* sf_format_check */ - -/*------------------------------------------------------------------------------ -*/ - -const char * -sf_version_string (void) -{ -#if ENABLE_EXPERIMENTAL_CODE - return PACKAGE_NAME "-" PACKAGE_VERSION "-exp" ; -#else - return PACKAGE_NAME "-" PACKAGE_VERSION ; -#endif -} - - -/*------------------------------------------------------------------------------ -*/ - -int -sf_command (SNDFILE *sndfile, int command, void *data, int datasize) -{ SF_PRIVATE *psf = (SF_PRIVATE *) sndfile ; - double quality ; - double latency ; - int old_value ; - - /* This set of commands do not need the sndfile parameter. */ - switch (command) - { case SFC_GET_LIB_VERSION : - if (data == NULL) - { if (psf) - psf->error = SFE_BAD_COMMAND_PARAM ; - return 0 ; - } ; - snprintf (data, datasize, "%s", sf_version_string ()) ; - return strlen (data) ; - - case SFC_GET_SIMPLE_FORMAT_COUNT : - if (data == NULL || datasize != SIGNED_SIZEOF (int)) - return (sf_errno = SFE_BAD_COMMAND_PARAM) ; - *((int*) data) = psf_get_format_simple_count () ; - return 0 ; - - case SFC_GET_SIMPLE_FORMAT : - if (data == NULL || datasize != SIGNED_SIZEOF (SF_FORMAT_INFO)) - return (sf_errno = SFE_BAD_COMMAND_PARAM) ; - return psf_get_format_simple (data) ; - - case SFC_GET_FORMAT_MAJOR_COUNT : - if (data == NULL || datasize != SIGNED_SIZEOF (int)) - return (sf_errno = SFE_BAD_COMMAND_PARAM) ; - *((int*) data) = psf_get_format_major_count () ; - return 0 ; - - case SFC_GET_FORMAT_MAJOR : - if (data == NULL || datasize != SIGNED_SIZEOF (SF_FORMAT_INFO)) - return (sf_errno = SFE_BAD_COMMAND_PARAM) ; - return psf_get_format_major (data) ; - - case SFC_GET_FORMAT_SUBTYPE_COUNT : - if (data == NULL || datasize != SIGNED_SIZEOF (int)) - return (sf_errno = SFE_BAD_COMMAND_PARAM) ; - *((int*) data) = psf_get_format_subtype_count () ; - return 0 ; - - case SFC_GET_FORMAT_SUBTYPE : - if (data == NULL || datasize != SIGNED_SIZEOF (SF_FORMAT_INFO)) - return (sf_errno = SFE_BAD_COMMAND_PARAM) ; - return psf_get_format_subtype (data) ; - - case SFC_GET_FORMAT_INFO : - if (data == NULL || datasize != SIGNED_SIZEOF (SF_FORMAT_INFO)) - return (sf_errno = SFE_BAD_COMMAND_PARAM) ; - return psf_get_format_info (data) ; - } ; - - if (sndfile == NULL && command == SFC_GET_LOG_INFO) - { if (data == NULL) - return (sf_errno = SFE_BAD_COMMAND_PARAM) ; - snprintf (data, datasize, "%s", sf_parselog) ; - return strlen (data) ; - } ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - switch (command) - { case SFC_SET_NORM_FLOAT : - old_value = psf->norm_float ; - psf->norm_float = (datasize) ? SF_TRUE : SF_FALSE ; - return old_value ; - - case SFC_GET_CURRENT_SF_INFO : - if (data == NULL || datasize != SIGNED_SIZEOF (SF_INFO)) - return (sf_errno = SFE_BAD_COMMAND_PARAM) ; - memcpy (data, &psf->sf, sizeof (SF_INFO)) ; - break ; - - case SFC_SET_NORM_DOUBLE : - old_value = psf->norm_double ; - psf->norm_double = (datasize) ? SF_TRUE : SF_FALSE ; - return old_value ; - - case SFC_GET_NORM_FLOAT : - return psf->norm_float ; - - case SFC_GET_NORM_DOUBLE : - return psf->norm_double ; - - case SFC_SET_SCALE_FLOAT_INT_READ : - old_value = psf->float_int_mult ; - - psf->float_int_mult = (datasize != 0) ? SF_TRUE : SF_FALSE ; - if (psf->float_int_mult && psf->float_max < 0.0) - /* Scale to prevent wrap-around distortion. */ - psf->float_max = (32768.0 / 32767.0) * psf_calc_signal_max (psf, SF_FALSE) ; - return old_value ; - - case SFC_SET_SCALE_INT_FLOAT_WRITE : - old_value = psf->scale_int_float ; - psf->scale_int_float = (datasize != 0) ? SF_TRUE : SF_FALSE ; - return old_value ; - - case SFC_SET_ADD_PEAK_CHUNK : - { int format = SF_CONTAINER (psf->sf.format) ; - - /* Only WAV and AIFF support the PEAK chunk. */ - switch (format) - { case SF_FORMAT_AIFF : - case SF_FORMAT_CAF : - case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : - case SF_FORMAT_RF64 : - break ; - - default : - return SF_FALSE ; - } ; - - format = SF_CODEC (psf->sf.format) ; - - /* Only files containg the following data types support the PEAK chunk. */ - if (format != SF_FORMAT_FLOAT && format != SF_FORMAT_DOUBLE) - return SF_FALSE ; - - } ; - /* Can only do this is in SFM_WRITE mode. */ - if (psf->file.mode != SFM_WRITE && psf->file.mode != SFM_RDWR) - return SF_FALSE ; - /* If data has already been written this must fail. */ - if (psf->have_written) - { psf->error = SFE_CMD_HAS_DATA ; - return SF_FALSE ; - } ; - /* Everything seems OK, so set psf->has_peak and re-write header. */ - if (datasize == SF_FALSE && psf->peak_info != NULL) - { free (psf->peak_info) ; - psf->peak_info = NULL ; - } - else if (psf->peak_info == NULL) - { psf->peak_info = peak_info_calloc (psf->sf.channels) ; - if (psf->peak_info != NULL) - psf->peak_info->peak_loc = SF_PEAK_START ; - } ; - - if (psf->write_header) - psf->write_header (psf, SF_TRUE) ; - return datasize ; - - case SFC_SET_ADD_HEADER_PAD_CHUNK : - return SF_FALSE ; - - case SFC_GET_LOG_INFO : - if (data == NULL) - return SFE_BAD_COMMAND_PARAM ; - snprintf (data, datasize, "%s", psf->parselog.buf) ; - return strlen (data) ; - - case SFC_CALC_SIGNAL_MAX : - if (data == NULL || datasize != sizeof (double)) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - *((double*) data) = psf_calc_signal_max (psf, SF_FALSE) ; - break ; - - case SFC_CALC_NORM_SIGNAL_MAX : - if (data == NULL || datasize != sizeof (double)) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - *((double*) data) = psf_calc_signal_max (psf, SF_TRUE) ; - break ; - - case SFC_CALC_MAX_ALL_CHANNELS : - if (data == NULL || datasize != SIGNED_SIZEOF (double) * psf->sf.channels) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - return psf_calc_max_all_channels (psf, (double*) data, SF_FALSE) ; - - case SFC_CALC_NORM_MAX_ALL_CHANNELS : - if (data == NULL || datasize != SIGNED_SIZEOF (double) * psf->sf.channels) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - return psf_calc_max_all_channels (psf, (double*) data, SF_TRUE) ; - - case SFC_GET_SIGNAL_MAX : - if (data == NULL || datasize != sizeof (double)) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - return psf_get_signal_max (psf, (double *) data) ; - - case SFC_GET_MAX_ALL_CHANNELS : - if (data == NULL || datasize != SIGNED_SIZEOF (double) * psf->sf.channels) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - return psf_get_max_all_channels (psf, (double*) data) ; - - case SFC_UPDATE_HEADER_NOW : - if (psf->write_header) - psf->write_header (psf, SF_TRUE) ; - break ; - - case SFC_SET_UPDATE_HEADER_AUTO : - psf->auto_header = datasize ? SF_TRUE : SF_FALSE ; - return psf->auto_header ; - break ; - - case SFC_SET_ADD_DITHER_ON_WRITE : - case SFC_SET_ADD_DITHER_ON_READ : - /* - ** FIXME ! - ** These are obsolete. Just return. - ** Remove some time after version 1.0.8. - */ - break ; - - case SFC_SET_DITHER_ON_WRITE : - if (data == NULL || datasize != SIGNED_SIZEOF (SF_DITHER_INFO)) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - memcpy (&psf->write_dither, data, sizeof (psf->write_dither)) ; - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - dither_init (psf, SFM_WRITE) ; - break ; - - case SFC_SET_DITHER_ON_READ : - if (data == NULL || datasize != SIGNED_SIZEOF (SF_DITHER_INFO)) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - memcpy (&psf->read_dither, data, sizeof (psf->read_dither)) ; - if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) - dither_init (psf, SFM_READ) ; - break ; - - case SFC_FILE_TRUNCATE : - if (psf->file.mode != SFM_WRITE && psf->file.mode != SFM_RDWR) - return SF_TRUE ; - if (datasize != sizeof (sf_count_t)) - return SF_TRUE ; - if (data == NULL || datasize != sizeof (sf_count_t)) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } - else - { sf_count_t position ; - - position = *((sf_count_t*) data) ; - - if (sf_seek (sndfile, position, SEEK_SET) != position) - return SF_TRUE ; - - psf->sf.frames = position ; - - position = psf_fseek (psf, 0, SEEK_CUR) ; - - return psf_ftruncate (psf, position) ; - } ; - break ; - - case SFC_SET_RAW_START_OFFSET : - if (data == NULL || datasize != sizeof (sf_count_t)) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_RAW) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - - psf->dataoffset = *((sf_count_t*) data) ; - sf_seek (sndfile, 0, SEEK_CUR) ; - break ; - - case SFC_GET_EMBED_FILE_INFO : - if (data == NULL || datasize != sizeof (SF_EMBED_FILE_INFO)) - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - - ((SF_EMBED_FILE_INFO*) data)->offset = psf->fileoffset ; - ((SF_EMBED_FILE_INFO*) data)->length = psf->filelength ; - break ; - - /* Lite remove start */ - case SFC_TEST_IEEE_FLOAT_REPLACE : - psf->ieee_replace = (datasize) ? SF_TRUE : SF_FALSE ; - if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_FLOAT) - float32_init (psf) ; - else if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_DOUBLE) - double64_init (psf) ; - else - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - break ; - /* Lite remove end */ - - case SFC_SET_CLIPPING : - psf->add_clipping = (datasize) ? SF_TRUE : SF_FALSE ; - return psf->add_clipping ; - - case SFC_GET_CLIPPING : - return psf->add_clipping ; - - case SFC_GET_LOOP_INFO : - if (datasize != sizeof (SF_LOOP_INFO) || data == NULL) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - if (psf->loop_info == NULL) - return SF_FALSE ; - memcpy (data, psf->loop_info, sizeof (SF_LOOP_INFO)) ; - return SF_TRUE ; - - case SFC_SET_BROADCAST_INFO : - { int format = SF_CONTAINER (psf->sf.format) ; - - /* Only WAV and RF64 supports the BEXT (Broadcast) chunk. */ - if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX && format != SF_FORMAT_RF64) - return SF_FALSE ; - } ; - - /* Only makes sense in SFM_WRITE or SFM_RDWR mode. */ - if ((psf->file.mode != SFM_WRITE) && (psf->file.mode != SFM_RDWR)) - return SF_FALSE ; - /* If data has already been written this must fail. */ - if (psf->broadcast_16k == NULL && psf->have_written) - { psf->error = SFE_CMD_HAS_DATA ; - return SF_FALSE ; - } ; - - if (!broadcast_var_set (psf, data, datasize)) - return SF_FALSE ; - - if (psf->write_header) - psf->write_header (psf, SF_TRUE) ; - return SF_TRUE ; - - case SFC_GET_BROADCAST_INFO : - if (data == NULL) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - return broadcast_var_get (psf, data, datasize) ; - - case SFC_SET_CART_INFO : - { int format = SF_CONTAINER (psf->sf.format) ; - /* Only WAV and RF64 support cart chunk format */ - if (format != SF_FORMAT_WAV && format != SF_FORMAT_RF64) - return SF_FALSE ; - } ; - - /* Only makes sense in SFM_WRITE or SFM_RDWR mode */ - if ((psf->file.mode != SFM_WRITE) && (psf->file.mode != SFM_RDWR)) - return SF_FALSE ; - /* If data has already been written this must fail. */ - if (psf->cart_16k == NULL && psf->have_written) - { psf->error = SFE_CMD_HAS_DATA ; - return SF_FALSE ; - } ; - if (!cart_var_set (psf, data, datasize)) - return SF_FALSE ; - if (psf->write_header) - psf->write_header (psf, SF_TRUE) ; - return SF_TRUE ; - - case SFC_GET_CART_INFO : - if (data == NULL) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - return cart_var_get (psf, data, datasize) ; - - case SFC_GET_CUE_COUNT : - if (datasize != sizeof (uint32_t) || data == NULL) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - if (psf->cues != NULL) - { *((uint32_t *) data) = psf->cues->cue_count ; - return SF_TRUE ; - } ; - return SF_FALSE ; - - case SFC_GET_CUE : - if (datasize < (int) sizeof (uint32_t) || data == NULL) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - if (psf->cues == NULL) - return SF_FALSE ; - psf_get_cues (psf, data, datasize) ; - return SF_TRUE ; - - case SFC_SET_CUE : - if (psf->have_written) - { psf->error = SFE_CMD_HAS_DATA ; - return SF_FALSE ; - } ; - if (datasize < (int) sizeof (uint32_t) || data == NULL) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - if (psf->cues == NULL && (psf->cues = psf_cues_dup (data, datasize)) == NULL) - { psf->error = SFE_MALLOC_FAILED ; - return SF_FALSE ; - } ; - return SF_TRUE ; - - case SFC_GET_INSTRUMENT : - if (datasize != sizeof (SF_INSTRUMENT) || data == NULL) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - if (psf->instrument == NULL) - return SF_FALSE ; - memcpy (data, psf->instrument, sizeof (SF_INSTRUMENT)) ; - return SF_TRUE ; - - case SFC_SET_INSTRUMENT : - /* If data has already been written this must fail. */ - if (psf->have_written) - { psf->error = SFE_CMD_HAS_DATA ; - return SF_FALSE ; - } ; - if (datasize != sizeof (SF_INSTRUMENT) || data == NULL) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - - if (psf->instrument == NULL && (psf->instrument = psf_instrument_alloc ()) == NULL) - { psf->error = SFE_MALLOC_FAILED ; - return SF_FALSE ; - } ; - memcpy (psf->instrument, data, sizeof (SF_INSTRUMENT)) ; - return SF_TRUE ; - - case SFC_RAW_DATA_NEEDS_ENDSWAP : - return psf->data_endswap ; - - case SFC_GET_CHANNEL_MAP_INFO : - if (psf->channel_map == NULL) - return SF_FALSE ; - - if (data == NULL || datasize != SIGNED_SIZEOF (psf->channel_map [0]) * psf->sf.channels) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - - memcpy (data, psf->channel_map, datasize) ; - return SF_TRUE ; - - case SFC_SET_CHANNEL_MAP_INFO : - if (psf->have_written) - { psf->error = SFE_CMD_HAS_DATA ; - return SF_FALSE ; - } ; - if (data == NULL || datasize != SIGNED_SIZEOF (psf->channel_map [0]) * psf->sf.channels) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - - { int *iptr ; - - for (iptr = data ; iptr < (int*) data + psf->sf.channels ; iptr++) - { if (*iptr <= SF_CHANNEL_MAP_INVALID || *iptr >= SF_CHANNEL_MAP_MAX) - { psf->error = SFE_BAD_COMMAND_PARAM ; - return SF_FALSE ; - } ; - } ; - } ; - - free (psf->channel_map) ; - if ((psf->channel_map = malloc (datasize)) == NULL) - { psf->error = SFE_MALLOC_FAILED ; - return SF_FALSE ; - } ; - - memcpy (psf->channel_map, data, datasize) ; - - /* - ** Pass the command down to the container's command handler. - ** Don't pass user data, use validated psf->channel_map data instead. - */ - if (psf->command) - return psf->command (psf, command, NULL, 0) ; - return SF_FALSE ; - - case SFC_SET_VBR_ENCODING_QUALITY : - if (data == NULL || datasize != sizeof (double)) - return SF_FALSE ; - - quality = *((double *) data) ; - quality = 1.0 - SF_MAX (0.0, SF_MIN (1.0, quality)) ; - return sf_command (sndfile, SFC_SET_COMPRESSION_LEVEL, &quality, sizeof (quality)) ; - - case SFC_SET_OGG_PAGE_LATENCY_MS : - if (data == NULL || datasize != sizeof (double)) - return SF_FALSE ; - - latency = *((double *) data) ; - return sf_command (sndfile, SFC_SET_OGG_PAGE_LATENCY, &latency, sizeof (latency)) ; - - default : - /* Must be a file specific command. Pass it on. */ - if (psf->command) - return psf->command (psf, command, data, datasize) ; - - psf_log_printf (psf, "*** sf_command : cmd = 0x%X\n", command) ; - return (psf->error = SFE_BAD_COMMAND_PARAM) ; - } ; - - return 0 ; -} /* sf_command */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence) -{ SF_PRIVATE *psf ; - sf_count_t seek_from_start = 0, retval ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (! psf->sf.seekable) - { psf->error = SFE_NOT_SEEKABLE ; - return PSF_SEEK_ERROR ; - } ; - - /* If the whence parameter has a mode ORed in, check to see that - ** it makes sense. - */ - if (((whence & SFM_MASK) == SFM_WRITE && psf->file.mode == SFM_READ) || - ((whence & SFM_MASK) == SFM_READ && psf->file.mode == SFM_WRITE)) - { psf->error = SFE_WRONG_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - /* Convert all SEEK_CUR and SEEK_END into seek_from_start to be - ** used with SEEK_SET. - */ - switch (whence) - { /* The SEEK_SET behaviour is independant of mode. */ - case SEEK_SET : - case SEEK_SET | SFM_READ : - case SEEK_SET | SFM_WRITE : - case SEEK_SET | SFM_RDWR : - seek_from_start = offset ; - break ; - - /* The SEEK_CUR is a little more tricky. */ - case SEEK_CUR : - if (offset == 0) - { if (psf->file.mode == SFM_READ) - return psf->read_current ; - if (psf->file.mode == SFM_WRITE) - return psf->write_current ; - } ; - if (psf->file.mode == SFM_READ) - seek_from_start = psf->read_current + offset ; - else if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - seek_from_start = psf->write_current + offset ; - else - psf->error = SFE_AMBIGUOUS_SEEK ; - break ; - - case SEEK_CUR | SFM_READ : - if (offset == 0) - return psf->read_current ; - seek_from_start = psf->read_current + offset ; - break ; - - case SEEK_CUR | SFM_WRITE : - if (offset == 0) - return psf->write_current ; - seek_from_start = psf->write_current + offset ; - break ; - - /* The SEEK_END */ - case SEEK_END : - case SEEK_END | SFM_READ : - case SEEK_END | SFM_WRITE : - seek_from_start = psf->sf.frames + offset ; - break ; - - default : - psf->error = SFE_BAD_SEEK ; - break ; - } ; - - if (psf->error) - return PSF_SEEK_ERROR ; - - if (psf->file.mode == SFM_RDWR || psf->file.mode == SFM_WRITE) - { if (seek_from_start < 0) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - } - else if (seek_from_start < 0 || seek_from_start > psf->sf.frames) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (psf->seek) - { int new_mode = (whence & SFM_MASK) ? (whence & SFM_MASK) : psf->file.mode ; - - retval = psf->seek (psf, new_mode, seek_from_start) ; - - switch (new_mode) - { case SFM_READ : - psf->read_current = retval ; - break ; - case SFM_WRITE : - psf->write_current = retval ; - break ; - case SFM_RDWR : - psf->read_current = retval ; - psf->write_current = retval ; - new_mode = SFM_READ ; - break ; - } ; - - psf->last_op = new_mode ; - - return retval ; - } ; - - psf->error = SFE_AMBIGUOUS_SEEK ; - return PSF_SEEK_ERROR ; -} /* sf_seek */ - -/*------------------------------------------------------------------------------ -*/ - -const char* -sf_get_string (SNDFILE *sndfile, int str_type) -{ SF_PRIVATE *psf ; - - if ((psf = (SF_PRIVATE*) sndfile) == NULL) - return NULL ; - if (psf->Magick != SNDFILE_MAGICK) - return NULL ; - - return psf_get_string (psf, str_type) ; -} /* sf_get_string */ - -int -sf_set_string (SNDFILE *sndfile, int str_type, const char* str) -{ SF_PRIVATE *psf ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - return psf_set_string (psf, str_type, str) ; -} /* sf_get_string */ - -/*------------------------------------------------------------------------------ -*/ - -int -sf_current_byterate (SNDFILE *sndfile) -{ SF_PRIVATE *psf ; - - if ((psf = (SF_PRIVATE*) sndfile) == NULL) - return -1 ; - if (psf->Magick != SNDFILE_MAGICK) - return -1 ; - - /* This should cover all PCM and floating point formats. */ - if (psf->bytewidth) - return psf->sf.samplerate * psf->sf.channels * psf->bytewidth ; - - if (psf->byterate) - return psf->byterate (psf) ; - - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_IMA_ADPCM : - case SF_FORMAT_MS_ADPCM : - case SF_FORMAT_VOX_ADPCM : - return (psf->sf.samplerate * psf->sf.channels) / 2 ; - - case SF_FORMAT_GSM610 : - return (psf->sf.samplerate * psf->sf.channels * 13000) / 8000 ; - - case SF_FORMAT_NMS_ADPCM_16: - return psf->sf.samplerate / 4 + 10 ; - - case SF_FORMAT_NMS_ADPCM_24: - return psf->sf.samplerate * 3 / 8 + 10 ; - - case SF_FORMAT_NMS_ADPCM_32: - return psf->sf.samplerate / 2 + 10 ; - - case SF_FORMAT_G721_32 : /* 32kbs G721 ADPCM encoding. */ - return (psf->sf.samplerate * psf->sf.channels) / 2 ; - - case SF_FORMAT_G723_24 : /* 24kbs G723 ADPCM encoding. */ - return (psf->sf.samplerate * psf->sf.channels * 3) / 8 ; - - case SF_FORMAT_G723_40 : /* 40kbs G723 ADPCM encoding. */ - return (psf->sf.samplerate * psf->sf.channels * 5) / 8 ; - - default : - break ; - } ; - - return -1 ; -} /* sf_current_byterate */ - -/*============================================================================== -*/ - -sf_count_t -sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) -{ SF_PRIVATE *psf ; - sf_count_t count, extra ; - int bytewidth, blockwidth ; - - if (bytes == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - bytewidth = (psf->bytewidth > 0) ? psf->bytewidth : 1 ; - blockwidth = (psf->blockwidth > 0) ? psf->blockwidth : 1 ; - - if (psf->file.mode == SFM_WRITE) - { psf->error = SFE_NOT_READMODE ; - return 0 ; - } ; - - if (bytes < 0 || psf->read_current >= psf->sf.frames) - { psf_memset (ptr, 0, bytes) ; - return 0 ; - } ; - - if (bytes % (psf->sf.channels * bytewidth)) - { psf->error = SFE_BAD_READ_ALIGN ; - return 0 ; - } ; - - if (psf->last_op != SFM_READ) - if (psf->seek (psf, SFM_READ, psf->read_current) < 0) - return 0 ; - - count = psf_fread (ptr, 1, bytes, psf) ; - - if (psf->read_current + count / blockwidth <= psf->sf.frames) - psf->read_current += count / blockwidth ; - else - { count = (psf->sf.frames - psf->read_current) * blockwidth ; - extra = bytes - count ; - psf_memset (((char *) ptr) + count, 0, extra) ; - psf->read_current = psf->sf.frames ; - } ; - - psf->last_op = SFM_READ ; - - return count ; -} /* sf_read_raw */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t len) -{ SF_PRIVATE *psf ; - sf_count_t count, extra ; - - if (len == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (len <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->error = SFE_NOT_READMODE ; - return 0 ; - } ; - - if (len % psf->sf.channels) - { psf->error = SFE_BAD_READ_ALIGN ; - return 0 ; - } ; - - if (psf->read_current >= psf->sf.frames) - { psf_memset (ptr, 0, len * sizeof (short)) ; - return 0 ; /* End of file. */ - } ; - - if (psf->read_short == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_READ) - if (psf->seek (psf, SFM_READ, psf->read_current) < 0) - return 0 ; - - count = psf->read_short (psf, ptr, len) ; - - if (psf->read_current + count / psf->sf.channels <= psf->sf.frames) - psf->read_current += count / psf->sf.channels ; - else - { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ; - extra = len - count ; - psf_memset (ptr + count, 0, extra * sizeof (short)) ; - psf->read_current = psf->sf.frames ; - } ; - - psf->last_op = SFM_READ ; - - return count ; -} /* sf_read_short */ - -sf_count_t -sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) -{ SF_PRIVATE *psf ; - sf_count_t count, extra ; - - if (frames == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (frames <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->error = SFE_NOT_READMODE ; - return 0 ; - } ; - - if (psf->read_current >= psf->sf.frames) - { psf_memset (ptr, 0, frames * psf->sf.channels * sizeof (short)) ; - return 0 ; /* End of file. */ - } ; - - if (psf->read_short == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_READ) - if (psf->seek (psf, SFM_READ, psf->read_current) < 0) - return 0 ; - - count = psf->read_short (psf, ptr, frames * psf->sf.channels) ; - - if (psf->read_current + count / psf->sf.channels <= psf->sf.frames) - psf->read_current += count / psf->sf.channels ; - else - { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ; - extra = frames * psf->sf.channels - count ; - psf_memset (ptr + count, 0, extra * sizeof (short)) ; - psf->read_current = psf->sf.frames ; - } ; - - psf->last_op = SFM_READ ; - - return count / psf->sf.channels ; -} /* sf_readf_short */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t len) -{ SF_PRIVATE *psf ; - sf_count_t count, extra ; - - if (len == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (len <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->error = SFE_NOT_READMODE ; - return 0 ; - } ; - - if (len % psf->sf.channels) - { psf->error = SFE_BAD_READ_ALIGN ; - return 0 ; - } ; - - if (psf->read_current >= psf->sf.frames) - { psf_memset (ptr, 0, len * sizeof (int)) ; - return 0 ; - } ; - - if (psf->read_int == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_READ) - if (psf->seek (psf, SFM_READ, psf->read_current) < 0) - return 0 ; - - count = psf->read_int (psf, ptr, len) ; - - if (psf->read_current + count / psf->sf.channels <= psf->sf.frames) - psf->read_current += count / psf->sf.channels ; - else - { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ; - extra = len - count ; - psf_memset (ptr + count, 0, extra * sizeof (int)) ; - psf->read_current = psf->sf.frames ; - } ; - - psf->last_op = SFM_READ ; - - return count ; -} /* sf_read_int */ - -sf_count_t -sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) -{ SF_PRIVATE *psf ; - sf_count_t count, extra ; - - if (frames == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (frames <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->error = SFE_NOT_READMODE ; - return 0 ; - } ; - - if (psf->read_current >= psf->sf.frames) - { psf_memset (ptr, 0, frames * psf->sf.channels * sizeof (int)) ; - return 0 ; - } ; - - if (psf->read_int == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_READ) - if (psf->seek (psf, SFM_READ, psf->read_current) < 0) - return 0 ; - - count = psf->read_int (psf, ptr, frames * psf->sf.channels) ; - - if (psf->read_current + count / psf->sf.channels <= psf->sf.frames) - psf->read_current += count / psf->sf.channels ; - else - { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ; - extra = frames * psf->sf.channels - count ; - psf_memset (ptr + count, 0, extra * sizeof (int)) ; - psf->read_current = psf->sf.frames ; - } ; - - psf->last_op = SFM_READ ; - - return count / psf->sf.channels ; -} /* sf_readf_int */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t len) -{ SF_PRIVATE *psf ; - sf_count_t count, extra ; - - if (len == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (len <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->error = SFE_NOT_READMODE ; - return 0 ; - } ; - - if (len % psf->sf.channels) - { psf->error = SFE_BAD_READ_ALIGN ; - return 0 ; - } ; - - if (psf->read_current >= psf->sf.frames) - { psf_memset (ptr, 0, len * sizeof (float)) ; - return 0 ; - } ; - - if (psf->read_float == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_READ) - if (psf->seek (psf, SFM_READ, psf->read_current) < 0) - return 0 ; - - count = psf->read_float (psf, ptr, len) ; - - if (psf->read_current + count / psf->sf.channels <= psf->sf.frames) - psf->read_current += count / psf->sf.channels ; - else - { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ; - extra = len - count ; - psf_memset (ptr + count, 0, extra * sizeof (float)) ; - psf->read_current = psf->sf.frames ; - } ; - - psf->last_op = SFM_READ ; - - return count ; -} /* sf_read_float */ - -sf_count_t -sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) -{ SF_PRIVATE *psf ; - sf_count_t count, extra ; - - if (frames == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (frames <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->error = SFE_NOT_READMODE ; - return 0 ; - } ; - - if (psf->read_current >= psf->sf.frames) - { psf_memset (ptr, 0, frames * psf->sf.channels * sizeof (float)) ; - return 0 ; - } ; - - if (psf->read_float == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_READ) - if (psf->seek (psf, SFM_READ, psf->read_current) < 0) - return 0 ; - - count = psf->read_float (psf, ptr, frames * psf->sf.channels) ; - - if (psf->read_current + count / psf->sf.channels <= psf->sf.frames) - psf->read_current += count / psf->sf.channels ; - else - { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ; - extra = frames * psf->sf.channels - count ; - psf_memset (ptr + count, 0, extra * sizeof (float)) ; - psf->read_current = psf->sf.frames ; - } ; - - psf->last_op = SFM_READ ; - - return count / psf->sf.channels ; -} /* sf_readf_float */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t len) -{ SF_PRIVATE *psf ; - sf_count_t count, extra ; - - if (len == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (len <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->error = SFE_NOT_READMODE ; - return 0 ; - } ; - - if (len % psf->sf.channels) - { psf->error = SFE_BAD_READ_ALIGN ; - return 0 ; - } ; - - if (psf->read_current >= psf->sf.frames) - { psf_memset (ptr, 0, len * sizeof (double)) ; - return 0 ; - } ; - - if (psf->read_double == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_READ) - if (psf->seek (psf, SFM_READ, psf->read_current) < 0) - return 0 ; - - count = psf->read_double (psf, ptr, len) ; - - if (psf->read_current + count / psf->sf.channels <= psf->sf.frames) - psf->read_current += count / psf->sf.channels ; - else - { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ; - extra = len - count ; - psf_memset (ptr + count, 0, extra * sizeof (double)) ; - psf->read_current = psf->sf.frames ; - } ; - - psf->last_op = SFM_READ ; - - return count ; -} /* sf_read_double */ - -sf_count_t -sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) -{ SF_PRIVATE *psf ; - sf_count_t count, extra ; - - if (frames == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (frames <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_WRITE) - { psf->error = SFE_NOT_READMODE ; - return 0 ; - } ; - - if (psf->read_current >= psf->sf.frames) - { psf_memset (ptr, 0, frames * psf->sf.channels * sizeof (double)) ; - return 0 ; - } ; - - if (psf->read_double == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_READ) - if (psf->seek (psf, SFM_READ, psf->read_current) < 0) - return 0 ; - - count = psf->read_double (psf, ptr, frames * psf->sf.channels) ; - - if (psf->read_current + count / psf->sf.channels <= psf->sf.frames) - psf->read_current += count / psf->sf.channels ; - else - { count = (psf->sf.frames - psf->read_current) * psf->sf.channels ; - extra = frames * psf->sf.channels - count ; - psf_memset (ptr + count, 0, extra * sizeof (double)) ; - psf->read_current = psf->sf.frames ; - } ; - - psf->last_op = SFM_READ ; - - return count / psf->sf.channels ; -} /* sf_readf_double */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t len) -{ SF_PRIVATE *psf ; - sf_count_t count ; - int bytewidth, blockwidth ; - - if (len == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (len <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - bytewidth = (psf->bytewidth > 0) ? psf->bytewidth : 1 ; - blockwidth = (psf->blockwidth > 0) ? psf->blockwidth : 1 ; - - if (psf->file.mode == SFM_READ) - { psf->error = SFE_NOT_WRITEMODE ; - return 0 ; - } ; - - if (len % (psf->sf.channels * bytewidth)) - { psf->error = SFE_BAD_WRITE_ALIGN ; - return 0 ; - } ; - - if (psf->last_op != SFM_WRITE) - if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) - return 0 ; - - if (psf->have_written == SF_FALSE && psf->write_header != NULL) - { if ((psf->error = psf->write_header (psf, SF_FALSE))) - return 0 ; - } ; - psf->have_written = SF_TRUE ; - - count = psf_fwrite (ptr, 1, len, psf) ; - - psf->write_current += count / blockwidth ; - - psf->last_op = SFM_WRITE ; - - if (psf->write_current > psf->sf.frames) - { psf->sf.frames = psf->write_current ; - psf->dataend = 0 ; - } ; - - if (psf->auto_header && psf->write_header != NULL) - psf->write_header (psf, SF_TRUE) ; - - return count ; -} /* sf_write_raw */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t len) -{ SF_PRIVATE *psf ; - sf_count_t count ; - - if (len == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (len <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_READ) - { psf->error = SFE_NOT_WRITEMODE ; - return 0 ; - } ; - - if (len % psf->sf.channels) - { psf->error = SFE_BAD_WRITE_ALIGN ; - return 0 ; - } ; - - if (psf->write_short == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_WRITE) - if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) - return 0 ; - - if (psf->have_written == SF_FALSE && psf->write_header != NULL) - { if ((psf->error = psf->write_header (psf, SF_FALSE))) - return 0 ; - } ; - psf->have_written = SF_TRUE ; - - count = psf->write_short (psf, ptr, len) ; - - psf->write_current += count / psf->sf.channels ; - - psf->last_op = SFM_WRITE ; - - if (psf->write_current > psf->sf.frames) - { psf->sf.frames = psf->write_current ; - psf->dataend = 0 ; - } ; - - if (psf->auto_header && psf->write_header != NULL) - psf->write_header (psf, SF_TRUE) ; - - return count ; -} /* sf_write_short */ - -sf_count_t -sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) -{ SF_PRIVATE *psf ; - sf_count_t count ; - - if (frames == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (frames <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_READ) - { psf->error = SFE_NOT_WRITEMODE ; - return 0 ; - } ; - - if (psf->write_short == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_WRITE) - if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) - return 0 ; - - if (psf->have_written == SF_FALSE && psf->write_header != NULL) - { if ((psf->error = psf->write_header (psf, SF_FALSE))) - return 0 ; - } ; - psf->have_written = SF_TRUE ; - - count = psf->write_short (psf, ptr, frames * psf->sf.channels) ; - - psf->write_current += count / psf->sf.channels ; - - psf->last_op = SFM_WRITE ; - - if (psf->write_current > psf->sf.frames) - { psf->sf.frames = psf->write_current ; - psf->dataend = 0 ; - } ; - - if (psf->auto_header && psf->write_header != NULL) - psf->write_header (psf, SF_TRUE) ; - - return count / psf->sf.channels ; -} /* sf_writef_short */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t len) -{ SF_PRIVATE *psf ; - sf_count_t count ; - - if (len == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (len <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_READ) - { psf->error = SFE_NOT_WRITEMODE ; - return 0 ; - } ; - - if (len % psf->sf.channels) - { psf->error = SFE_BAD_WRITE_ALIGN ; - return 0 ; - } ; - - if (psf->write_int == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_WRITE) - if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) - return 0 ; - - if (psf->have_written == SF_FALSE && psf->write_header != NULL) - { if ((psf->error = psf->write_header (psf, SF_FALSE))) - return 0 ; - } ; - psf->have_written = SF_TRUE ; - - count = psf->write_int (psf, ptr, len) ; - - psf->write_current += count / psf->sf.channels ; - - psf->last_op = SFM_WRITE ; - - if (psf->write_current > psf->sf.frames) - { psf->sf.frames = psf->write_current ; - psf->dataend = 0 ; - } ; - - if (psf->auto_header && psf->write_header != NULL) - psf->write_header (psf, SF_TRUE) ; - - return count ; -} /* sf_write_int */ - -sf_count_t -sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) -{ SF_PRIVATE *psf ; - sf_count_t count ; - - if (frames == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (frames <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_READ) - { psf->error = SFE_NOT_WRITEMODE ; - return 0 ; - } ; - - if (psf->write_int == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_WRITE) - if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) - return 0 ; - - if (psf->have_written == SF_FALSE && psf->write_header != NULL) - { if ((psf->error = psf->write_header (psf, SF_FALSE))) - return 0 ; - } ; - psf->have_written = SF_TRUE ; - - count = psf->write_int (psf, ptr, frames * psf->sf.channels) ; - - psf->write_current += count / psf->sf.channels ; - - psf->last_op = SFM_WRITE ; - - if (psf->write_current > psf->sf.frames) - { psf->sf.frames = psf->write_current ; - psf->dataend = 0 ; - } ; - - if (psf->auto_header && psf->write_header != NULL) - psf->write_header (psf, SF_TRUE) ; - - return count / psf->sf.channels ; -} /* sf_writef_int */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t len) -{ SF_PRIVATE *psf ; - sf_count_t count ; - - if (len == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (len <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_READ) - { psf->error = SFE_NOT_WRITEMODE ; - return 0 ; - } ; - - if (len % psf->sf.channels) - { psf->error = SFE_BAD_WRITE_ALIGN ; - return 0 ; - } ; - - if (psf->write_float == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_WRITE) - if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) - return 0 ; - - if (psf->have_written == SF_FALSE && psf->write_header != NULL) - { if ((psf->error = psf->write_header (psf, SF_FALSE))) - return 0 ; - } ; - psf->have_written = SF_TRUE ; - - count = psf->write_float (psf, ptr, len) ; - - psf->write_current += count / psf->sf.channels ; - - psf->last_op = SFM_WRITE ; - - if (psf->write_current > psf->sf.frames) - { psf->sf.frames = psf->write_current ; - psf->dataend = 0 ; - } ; - - if (psf->auto_header && psf->write_header != NULL) - psf->write_header (psf, SF_TRUE) ; - - return count ; -} /* sf_write_float */ - -sf_count_t -sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) -{ SF_PRIVATE *psf ; - sf_count_t count ; - - if (frames == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (frames <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_READ) - { psf->error = SFE_NOT_WRITEMODE ; - return 0 ; - } ; - - if (psf->write_float == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_WRITE) - if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) - return 0 ; - - if (psf->have_written == SF_FALSE && psf->write_header != NULL) - { if ((psf->error = psf->write_header (psf, SF_FALSE))) - return 0 ; - } ; - psf->have_written = SF_TRUE ; - - count = psf->write_float (psf, ptr, frames * psf->sf.channels) ; - - psf->write_current += count / psf->sf.channels ; - - psf->last_op = SFM_WRITE ; - - if (psf->write_current > psf->sf.frames) - { psf->sf.frames = psf->write_current ; - psf->dataend = 0 ; - } ; - - if (psf->auto_header && psf->write_header != NULL) - psf->write_header (psf, SF_TRUE) ; - - return count / psf->sf.channels ; -} /* sf_writef_float */ - -/*------------------------------------------------------------------------------ -*/ - -sf_count_t -sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t len) -{ SF_PRIVATE *psf ; - sf_count_t count ; - - if (len == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (len <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_READ) - { psf->error = SFE_NOT_WRITEMODE ; - return 0 ; - } ; - - if (len % psf->sf.channels) - { psf->error = SFE_BAD_WRITE_ALIGN ; - return 0 ; - } ; - - if (psf->write_double == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_WRITE) - if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) - return 0 ; - - if (psf->have_written == SF_FALSE && psf->write_header != NULL) - { if ((psf->error = psf->write_header (psf, SF_FALSE))) - return 0 ; - } ; - psf->have_written = SF_TRUE ; - - count = psf->write_double (psf, ptr, len) ; - - psf->write_current += count / psf->sf.channels ; - - psf->last_op = SFM_WRITE ; - - if (psf->write_current > psf->sf.frames) - { psf->sf.frames = psf->write_current ; - psf->dataend = 0 ; - } ; - - if (psf->auto_header && psf->write_header != NULL) - psf->write_header (psf, SF_TRUE) ; - - return count ; -} /* sf_write_double */ - -sf_count_t -sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) -{ SF_PRIVATE *psf ; - sf_count_t count ; - - if (frames == 0) - return 0 ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (frames <= 0) - { psf->error = SFE_NEGATIVE_RW_LEN ; - return 0 ; - } ; - - if (psf->file.mode == SFM_READ) - { psf->error = SFE_NOT_WRITEMODE ; - return 0 ; - } ; - - if (psf->write_double == NULL || psf->seek == NULL) - { psf->error = SFE_UNIMPLEMENTED ; - return 0 ; - } ; - - if (psf->last_op != SFM_WRITE) - if (psf->seek (psf, SFM_WRITE, psf->write_current) < 0) - return 0 ; - - if (psf->have_written == SF_FALSE && psf->write_header != NULL) - { if ((psf->error = psf->write_header (psf, SF_FALSE))) - return 0 ; - } ; - psf->have_written = SF_TRUE ; - - count = psf->write_double (psf, ptr, frames * psf->sf.channels) ; - - psf->write_current += count / psf->sf.channels ; - - psf->last_op = SFM_WRITE ; - - if (psf->write_current > psf->sf.frames) - { psf->sf.frames = psf->write_current ; - psf->dataend = 0 ; - } ; - - if (psf->auto_header && psf->write_header != NULL) - psf->write_header (psf, SF_TRUE) ; - - return count / psf->sf.channels ; -} /* sf_writef_double */ - -/*========================================================================= -** Private functions. -*/ - -static int -try_resource_fork (SF_PRIVATE * psf) -{ int old_error = psf->error ; - - /* Set READ mode now, to see if resource fork exists. */ - psf->rsrc.mode = SFM_READ ; - if (psf_open_rsrc (psf) != 0) - { psf->error = old_error ; - return 0 ; - } ; - - /* More checking here. */ - psf_log_printf (psf, "Resource fork : %s\n", psf->rsrc.path) ; - - return SF_FORMAT_SD2 ; -} /* try_resource_fork */ - -static int -format_from_extension (SF_PRIVATE *psf) -{ char *cptr ; - char buffer [16] ; - int format = 0 ; - - if ((cptr = strrchr (psf->file.name, '.')) == NULL) - return 0 ; - - cptr ++ ; - if (strlen (cptr) > sizeof (buffer) - 1) - return 0 ; - - psf_strlcpy (buffer, sizeof (buffer), cptr) ; - buffer [sizeof (buffer) - 1] = 0 ; - - /* Convert everything in the buffer to lower case. */ - cptr = buffer ; - while (*cptr) - { *cptr = tolower (*cptr) ; - cptr ++ ; - } ; - - cptr = buffer ; - - if (strcmp (cptr, "au") == 0) - { psf->sf.channels = 1 ; - psf->sf.samplerate = 8000 ; - format = SF_FORMAT_RAW | SF_FORMAT_ULAW ; - } - else if (strcmp (cptr, "snd") == 0) - { psf->sf.channels = 1 ; - psf->sf.samplerate = 8000 ; - format = SF_FORMAT_RAW | SF_FORMAT_ULAW ; - } - - else if (strcmp (cptr, "vox") == 0 || strcmp (cptr, "vox8") == 0) - { psf->sf.channels = 1 ; - psf->sf.samplerate = 8000 ; - format = SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ; - } - else if (strcmp (cptr, "vox6") == 0) - { psf->sf.channels = 1 ; - psf->sf.samplerate = 6000 ; - format = SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ; - } - else if (strcmp (cptr, "gsm") == 0) - { psf->sf.channels = 1 ; - psf->sf.samplerate = 8000 ; - format = SF_FORMAT_RAW | SF_FORMAT_GSM610 ; - } - else if (strcmp (cptr, "mp3") == 0) - { /* - * MPEG streams are quite tollerate of crap. If we couldn't identify a - * MP3 stream, but it has a .mp3 extension, let libmpg123 have a try. - */ - format = SF_FORMAT_MPEG ; - } - - /* For RAW files, make sure the dataoffset if set correctly. */ - if ((SF_CONTAINER (format)) == SF_FORMAT_RAW) - psf->dataoffset = 0 ; - - return format ; -} /* format_from_extension */ - -static int -identify_mpeg (uint32_t marker) -{ if ((marker & MAKE_MARKER (0xFF, 0xE0, 0, 0)) == MAKE_MARKER (0xFF, 0xE0, 0, 0) && /* Frame sync */ - (marker & MAKE_MARKER (0, 0x18, 0, 0)) != MAKE_MARKER (0, 0x08, 0, 0) && /* Valid MPEG version */ - (marker & MAKE_MARKER (0, 0x06, 0, 0)) != MAKE_MARKER (0, 0, 0, 0) && /* Valid layer description */ - (marker & MAKE_MARKER (0, 0, 0xF0, 0)) != MAKE_MARKER (0, 0, 0xF0, 0) && /* Valid bitrate */ - (marker & MAKE_MARKER (0, 0, 0x0C, 0)) != MAKE_MARKER (0, 0, 0x0C, 0)) /* Valid samplerate */ - return SF_FORMAT_MPEG ; - return 0 ; -} /* identify_mpeg */ - -static int -guess_file_type (SF_PRIVATE *psf) -{ uint32_t buffer [3], format ; - -retry: - if (psf_binheader_readf (psf, "b", &buffer, SIGNED_SIZEOF (buffer)) != SIGNED_SIZEOF (buffer)) - { psf->error = SFE_BAD_FILE_READ ; - return 0 ; - } ; - - if ((buffer [0] == MAKE_MARKER ('R', 'I', 'F', 'F') || buffer [0] == MAKE_MARKER ('R', 'I', 'F', 'X')) - && buffer [2] == MAKE_MARKER ('W', 'A', 'V', 'E')) - return SF_FORMAT_WAV ; - - if (buffer [0] == MAKE_MARKER ('F', 'O', 'R', 'M')) - { if (buffer [2] == MAKE_MARKER ('A', 'I', 'F', 'F') || buffer [2] == MAKE_MARKER ('A', 'I', 'F', 'C')) - return SF_FORMAT_AIFF ; - if (buffer [2] == MAKE_MARKER ('8', 'S', 'V', 'X') || buffer [2] == MAKE_MARKER ('1', '6', 'S', 'V')) - return SF_FORMAT_SVX ; - return 0 ; - } ; - - if (buffer [0] == MAKE_MARKER ('.', 's', 'n', 'd') || buffer [0] == MAKE_MARKER ('d', 'n', 's', '.')) - return SF_FORMAT_AU ; - - if ((buffer [0] == MAKE_MARKER ('f', 'a', 'p', ' ') || buffer [0] == MAKE_MARKER (' ', 'p', 'a', 'f'))) - return SF_FORMAT_PAF ; - - if (buffer [0] == MAKE_MARKER ('N', 'I', 'S', 'T')) - return SF_FORMAT_NIST ; - - if (buffer [0] == MAKE_MARKER ('C', 'r', 'e', 'a') && buffer [1] == MAKE_MARKER ('t', 'i', 'v', 'e')) - return SF_FORMAT_VOC ; - - if ((buffer [0] & MAKE_MARKER (0xFF, 0xFF, 0xF8, 0xFF)) == MAKE_MARKER (0x64, 0xA3, 0x00, 0x00) || - (buffer [0] & MAKE_MARKER (0xFF, 0xF8, 0xFF, 0xFF)) == MAKE_MARKER (0x00, 0x00, 0xA3, 0x64)) - return SF_FORMAT_IRCAM ; - - if (buffer [0] == MAKE_MARKER ('r', 'i', 'f', 'f')) - return SF_FORMAT_W64 ; - - if (buffer [0] == MAKE_MARKER (0, 0, 0x03, 0xE8) && buffer [1] == MAKE_MARKER (0, 0, 0, 1) && - buffer [2] == MAKE_MARKER (0, 0, 0, 1)) - return SF_FORMAT_MAT4 ; - - if (buffer [0] == MAKE_MARKER (0, 0, 0, 0) && buffer [1] == MAKE_MARKER (1, 0, 0, 0) && - buffer [2] == MAKE_MARKER (1, 0, 0, 0)) - return SF_FORMAT_MAT4 ; - - if (buffer [0] == MAKE_MARKER ('M', 'A', 'T', 'L') && buffer [1] == MAKE_MARKER ('A', 'B', ' ', '5')) - return SF_FORMAT_MAT5 ; - - if (buffer [0] == MAKE_MARKER ('P', 'V', 'F', '1')) - return SF_FORMAT_PVF ; - - if (buffer [0] == MAKE_MARKER ('E', 'x', 't', 'e') && buffer [1] == MAKE_MARKER ('n', 'd', 'e', 'd') && - buffer [2] == MAKE_MARKER (' ', 'I', 'n', 's')) - return SF_FORMAT_XI ; - - if (buffer [0] == MAKE_MARKER ('c', 'a', 'f', 'f') && buffer [2] == MAKE_MARKER ('d', 'e', 's', 'c')) - return SF_FORMAT_CAF ; - - if (buffer [0] == MAKE_MARKER ('O', 'g', 'g', 'S')) - return SF_FORMAT_OGG ; - - if (buffer [0] == MAKE_MARKER ('A', 'L', 'a', 'w') && buffer [1] == MAKE_MARKER ('S', 'o', 'u', 'n') - && buffer [2] == MAKE_MARKER ('d', 'F', 'i', 'l')) - return SF_FORMAT_WVE ; - - if (buffer [0] == MAKE_MARKER ('D', 'i', 'a', 'm') && buffer [1] == MAKE_MARKER ('o', 'n', 'd', 'W') - && buffer [2] == MAKE_MARKER ('a', 'r', 'e', ' ')) - return SF_FORMAT_DWD ; - - if (buffer [0] == MAKE_MARKER ('L', 'M', '8', '9') || buffer [0] == MAKE_MARKER ('5', '3', 0, 0)) - return SF_FORMAT_TXW ; - - if ((buffer [0] & MAKE_MARKER (0xFF, 0xFF, 0x80, 0xFF)) == MAKE_MARKER (0xF0, 0x7E, 0, 0x01)) - return SF_FORMAT_SDS ; - - if ((buffer [0] & MAKE_MARKER (0xFF, 0xFF, 0, 0)) == MAKE_MARKER (1, 4, 0, 0)) - return SF_FORMAT_MPC2K ; - - if (buffer [0] == MAKE_MARKER ('C', 'A', 'T', ' ') && buffer [2] == MAKE_MARKER ('R', 'E', 'X', '2')) - return SF_FORMAT_REX2 ; - - if (buffer [0] == MAKE_MARKER (0x30, 0x26, 0xB2, 0x75) && buffer [1] == MAKE_MARKER (0x8E, 0x66, 0xCF, 0x11)) - return 0 /*-SF_FORMAT_WMA-*/ ; - - /* HMM (Hidden Markov Model) Tool Kit. */ - if (buffer [2] == MAKE_MARKER (0, 2, 0, 0) && 2 * ((int64_t) BE2H_32 (buffer [0])) + 12 == psf->filelength) - return SF_FORMAT_HTK ; - - if (buffer [0] == MAKE_MARKER ('f', 'L', 'a', 'C')) - return SF_FORMAT_FLAC ; - - if (buffer [0] == MAKE_MARKER ('2', 'B', 'I', 'T')) - return SF_FORMAT_AVR ; - - if (buffer [0] == MAKE_MARKER ('R', 'F', '6', '4') && buffer [2] == MAKE_MARKER ('W', 'A', 'V', 'E')) - return SF_FORMAT_RF64 ; - - if (buffer [0] == MAKE_MARKER ('I', 'D', '3', 2) || buffer [0] == MAKE_MARKER ('I', 'D', '3', 3) - || buffer [0] == MAKE_MARKER ('I', 'D', '3', 4)) - { psf_log_printf (psf, "Found 'ID3' marker.\n") ; - if (id3_skip (psf)) - goto retry ; - return 0 ; - } ; - - /* ID3v2 tags + MPEG */ - if (psf->id3_header.len > 0 && (format = identify_mpeg (buffer [0])) != 0) - return format ; - - /* Turtle Beach SMP 16-bit */ - if (buffer [0] == MAKE_MARKER ('S', 'O', 'U', 'N') && buffer [1] == MAKE_MARKER ('D', ' ', 'S', 'A')) - return 0 ; - - /* Yamaha sampler format. */ - if (buffer [0] == MAKE_MARKER ('S', 'Y', '8', '0') || buffer [0] == MAKE_MARKER ('S', 'Y', '8', '5')) - return 0 ; - - if (buffer [0] == MAKE_MARKER ('a', 'j', 'k', 'g')) - return 0 /*-SF_FORMAT_SHN-*/ ; - - /* This must be (almost) the last one. */ - if (psf->filelength > 0 && (format = try_resource_fork (psf)) != 0) - return format ; - - /* MPEG with no ID3v2 tags. Only have the MPEG sync header for - * identification and it is quite brief, and prone to false positives. - * Check for this last, even after resource forks. */ - if (psf->id3_header.len == 0 && (format = identify_mpeg (buffer [0])) != 0) - return format ; - - return 0 ; -} /* guess_file_type */ - - -static int -validate_sfinfo (SF_INFO *sfinfo) -{ if (sfinfo->samplerate < 1) - return 0 ; - if (sfinfo->frames < 0) - return 0 ; - if ((sfinfo->channels < 1) || (sfinfo->channels > SF_MAX_CHANNELS)) - return 0 ; - if ((SF_CONTAINER (sfinfo->format)) == 0) - return 0 ; - if ((SF_CODEC (sfinfo->format)) == 0) - return 0 ; - if (sfinfo->sections < 1) - return 0 ; - return 1 ; -} /* validate_sfinfo */ - -static int -validate_psf (SF_PRIVATE *psf) -{ - if (psf->datalength < 0) - { psf_log_printf (psf, "Invalid SF_PRIVATE field : datalength == %D.\n", psf->datalength) ; - return 0 ; - } ; - if (psf->dataoffset < 0) - { psf_log_printf (psf, "Invalid SF_PRIVATE field : dataoffset == %D.\n", psf->dataoffset) ; - return 0 ; - } ; - if (psf->blockwidth && psf->blockwidth != psf->sf.channels * psf->bytewidth) - { psf_log_printf (psf, "Invalid SF_PRIVATE field : channels * bytewidth == %d.\n", - psf->sf.channels * psf->bytewidth) ; - return 0 ; - } ; - return 1 ; -} /* validate_psf */ - -static void -save_header_info (SF_PRIVATE *psf) -{ snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog.buf) ; -} /* save_header_info */ - -/*============================================================================== -*/ - -static int -psf_close (SF_PRIVATE *psf) -{ uint32_t k ; - int error = 0 ; - - if (psf->codec_close) - { error = psf->codec_close (psf) ; - /* To prevent it being called in psf->container_close(). */ - psf->codec_close = NULL ; - } ; - - if (psf->container_close) - error = psf->container_close (psf) ; - - error = psf_fclose (psf) ; - psf_close_rsrc (psf) ; - - /* For an ISO C compliant implementation it is ok to free a NULL pointer. */ - free (psf->header.ptr) ; - free (psf->container_data) ; - free (psf->codec_data) ; - free (psf->interleave) ; - free (psf->dither) ; - free (psf->peak_info) ; - free (psf->broadcast_16k) ; - free (psf->loop_info) ; - free (psf->instrument) ; - free (psf->cues) ; - free (psf->channel_map) ; - free (psf->format_desc) ; - free (psf->strings.storage) ; - - if (psf->wchunks.chunks) - for (k = 0 ; k < psf->wchunks.used ; k++) - free (psf->wchunks.chunks [k].data) ; - free (psf->rchunks.chunks) ; - free (psf->wchunks.chunks) ; - free (psf->iterator) ; - free (psf->cart_16k) ; - - free (psf) ; - - return error ; -} /* psf_close */ - -SNDFILE * -psf_open_file (SF_PRIVATE *psf, SF_INFO *sfinfo) -{ int error, format ; - - sf_errno = error = 0 ; - sf_parselog [0] = 0 ; - - if (psf->error) - { error = psf->error ; - goto error_exit ; - } ; - - if (psf->file.mode != SFM_READ && psf->file.mode != SFM_WRITE && psf->file.mode != SFM_RDWR) - { error = SFE_BAD_OPEN_MODE ; - goto error_exit ; - } ; - - if (sfinfo == NULL) - { error = SFE_BAD_SF_INFO_PTR ; - goto error_exit ; - } ; - - if (psf->file.mode == SFM_READ) - { if ((SF_CONTAINER (sfinfo->format)) == SF_FORMAT_RAW) - { if (sf_format_check (sfinfo) == 0) - { error = SFE_RAW_BAD_FORMAT ; - goto error_exit ; - } ; - } - else - memset (sfinfo, 0, sizeof (SF_INFO)) ; - } ; - - memcpy (&psf->sf, sfinfo, sizeof (SF_INFO)) ; - - psf->Magick = SNDFILE_MAGICK ; - psf->norm_float = SF_TRUE ; - psf->norm_double = SF_TRUE ; - psf->dataoffset = -1 ; - psf->datalength = -1 ; - psf->read_current = -1 ; - psf->write_current = -1 ; - psf->auto_header = SF_FALSE ; - psf->rwf_endian = SF_ENDIAN_LITTLE ; - psf->seek = psf_default_seek ; - psf->float_int_mult = 0 ; - psf->float_max = -1.0 ; - - /* An attempt at a per SF_PRIVATE unique id. */ - psf->unique_id = psf_rand_int32 () ; - - psf->sf.sections = 1 ; - - psf->is_pipe = psf_is_pipe (psf) ; - - if (psf->is_pipe) - { psf->sf.seekable = SF_FALSE ; - psf->filelength = SF_COUNT_MAX ; - } - else - { psf->sf.seekable = SF_TRUE ; - - /* File is open, so get the length. */ - psf->filelength = psf_get_filelen (psf) ; - } ; - - if (psf->fileoffset > 0) - { switch (psf->file.mode) - { case SFM_READ : - if (psf->filelength < 44) - { psf_log_printf (psf, "Short filelength: %D (fileoffset: %D)\n", psf->filelength, psf->fileoffset) ; - error = SFE_BAD_OFFSET ; - goto error_exit ; - } ; - break ; - - case SFM_WRITE : - psf->fileoffset = 0 ; - psf_fseek (psf, 0, SEEK_END) ; - psf->fileoffset = psf_ftell (psf) ; - break ; - - case SFM_RDWR : - error = SFE_NO_EMBEDDED_RDWR ; - goto error_exit ; - } ; - - psf_log_printf (psf, "Embedded file offset : %D\n", psf->fileoffset) ; - } ; - - if (psf->filelength == SF_COUNT_MAX) - psf_log_printf (psf, "Length : unknown\n") ; - else - psf_log_printf (psf, "Length : %D\n", psf->filelength) ; - - if (psf->file.mode == SFM_WRITE || (psf->file.mode == SFM_RDWR && psf->filelength == 0)) - { /* If the file is being opened for write or RDWR and the file is currently - ** empty, then the SF_INFO struct must contain valid data. - */ - if ((SF_CONTAINER (psf->sf.format)) == 0) - { error = SFE_ZERO_MAJOR_FORMAT ; - goto error_exit ; - } ; - if ((SF_CODEC (psf->sf.format)) == 0) - { error = SFE_ZERO_MINOR_FORMAT ; - goto error_exit ; - } ; - - if (sf_format_check (&psf->sf) == 0) - { error = SFE_BAD_OPEN_FORMAT ; - goto error_exit ; - } ; - } - else if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_RAW) - { /* If type RAW has not been specified then need to figure out file type. */ - psf->sf.format = guess_file_type (psf) ; - - if (psf->sf.format == 0) - psf->sf.format = format_from_extension (psf) ; - } ; - - /* Prevent unnecessary seeks */ - psf->last_op = psf->file.mode ; - - /* Set bytewidth if known. */ - switch (SF_CODEC (psf->sf.format)) - { case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_U8 : - case SF_FORMAT_ULAW : - case SF_FORMAT_ALAW : - case SF_FORMAT_DPCM_8 : - psf->bytewidth = 1 ; - break ; - - case SF_FORMAT_PCM_16 : - case SF_FORMAT_DPCM_16 : - psf->bytewidth = 2 ; - break ; - - case SF_FORMAT_PCM_24 : - psf->bytewidth = 3 ; - break ; - - case SF_FORMAT_PCM_32 : - case SF_FORMAT_FLOAT : - psf->bytewidth = 4 ; - break ; - - case SF_FORMAT_DOUBLE : - psf->bytewidth = 8 ; - break ; - } ; - - /* Call the initialisation function for the relevant file type. */ - switch (SF_CONTAINER (psf->sf.format)) - { case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : - error = wav_open (psf) ; - break ; - - case SF_FORMAT_AIFF : - error = aiff_open (psf) ; - break ; - - case SF_FORMAT_AU : - error = au_open (psf) ; - break ; - - case SF_FORMAT_RAW : - error = raw_open (psf) ; - break ; - - case SF_FORMAT_W64 : - error = w64_open (psf) ; - break ; - - case SF_FORMAT_RF64 : - error = rf64_open (psf) ; - break ; - - /* Lite remove start */ - case SF_FORMAT_PAF : - error = paf_open (psf) ; - break ; - - case SF_FORMAT_SVX : - error = svx_open (psf) ; - break ; - - case SF_FORMAT_NIST : - error = nist_open (psf) ; - break ; - - case SF_FORMAT_IRCAM : - error = ircam_open (psf) ; - break ; - - case SF_FORMAT_VOC : - error = voc_open (psf) ; - break ; - - case SF_FORMAT_SDS : - error = sds_open (psf) ; - break ; - - case SF_FORMAT_OGG : - error = ogg_open (psf) ; - break ; - - case SF_FORMAT_TXW : - error = txw_open (psf) ; - break ; - - case SF_FORMAT_WVE : - error = wve_open (psf) ; - break ; - - case SF_FORMAT_DWD : - error = dwd_open (psf) ; - break ; - - case SF_FORMAT_MAT4 : - error = mat4_open (psf) ; - break ; - - case SF_FORMAT_MAT5 : - error = mat5_open (psf) ; - break ; - - case SF_FORMAT_PVF : - error = pvf_open (psf) ; - break ; - - case SF_FORMAT_XI : - error = xi_open (psf) ; - break ; - - case SF_FORMAT_HTK : - error = htk_open (psf) ; - break ; - - case SF_FORMAT_SD2 : - error = sd2_open (psf) ; - break ; - - case SF_FORMAT_REX2 : - error = rx2_open (psf) ; - break ; - - case SF_FORMAT_AVR : - error = avr_open (psf) ; - break ; - - case SF_FORMAT_FLAC : - error = flac_open (psf) ; - break ; - - case SF_FORMAT_CAF : - error = caf_open (psf) ; - break ; - - case SF_FORMAT_MPC2K : - error = mpc2k_open (psf) ; - break ; - - case SF_FORMAT_MPEG : - error = mpeg_open (psf) ; - break ; - - /* Lite remove end */ - - default : - error = SF_ERR_UNRECOGNISED_FORMAT ; - } ; - - if (error) - goto error_exit ; - - /* For now, check whether embedding is supported. */ - format = SF_CONTAINER (psf->sf.format) ; - if (psf->fileoffset > 0) - { switch (format) - { case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : - case SF_FORMAT_AIFF : - case SF_FORMAT_AU : - /* Actual embedded files. */ - break ; - - case SF_FORMAT_MPEG : - case SF_FORMAT_FLAC : - /* Flac with an ID3v2 header? */ - break ; - - default : - error = SFE_NO_EMBED_SUPPORT ; - goto error_exit ; - } ; - } ; - - if (psf->fileoffset > 0) - psf_log_printf (psf, "Embedded file length : %D\n", psf->filelength) ; - - if (psf->file.mode == SFM_RDWR && sf_format_check (&psf->sf) == 0) - { error = SFE_BAD_MODE_RW ; - goto error_exit ; - } ; - - if (validate_sfinfo (&psf->sf) == 0) - { psf_log_SF_INFO (psf) ; - save_header_info (psf) ; - error = SFE_BAD_SF_INFO ; - goto error_exit ; - } ; - - if (validate_psf (psf) == 0) - { save_header_info (psf) ; - error = SFE_INTERNAL ; - goto error_exit ; - } ; - - psf->read_current = 0 ; - psf->write_current = 0 ; - if (psf->file.mode == SFM_RDWR) - { psf->write_current = psf->sf.frames ; - psf->have_written = psf->sf.frames > 0 ? SF_TRUE : SF_FALSE ; - } ; - - memcpy (sfinfo, &psf->sf, sizeof (SF_INFO)) ; - - if (psf->file.mode == SFM_WRITE) - { /* Zero out these fields. */ - sfinfo->frames = 0 ; - sfinfo->sections = 0 ; - sfinfo->seekable = 0 ; - } ; - - return (SNDFILE *) psf ; - -error_exit : - sf_errno = error ; - - if (error == SFE_SYSTEM) - snprintf (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ; - snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog.buf) ; - - switch (error) - { case SF_ERR_SYSTEM : - case SF_ERR_UNSUPPORTED_ENCODING : - case SFE_UNIMPLEMENTED : - break ; - - case SFE_RAW_BAD_FORMAT : - break ; - - default : - if (psf->file.mode == SFM_READ) - { psf_log_printf (psf, "Parse error : %s\n", sf_error_number (error)) ; - error = SF_ERR_MALFORMED_FILE ; - } ; - } ; - - psf_close (psf) ; - return NULL ; -} /* psf_open_file */ - -/*============================================================================== -** Chunk getting and setting. -** This works for AIFF, CAF, RF64 and WAV. -** It doesn't work for W64 because W64 uses weird GUID style chunk markers. -*/ - -int -sf_set_chunk (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) -{ SF_PRIVATE *psf ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (chunk_info == NULL || chunk_info->data == NULL) - return SFE_BAD_CHUNK_PTR ; - - if (psf->set_chunk) - return psf->set_chunk (psf, chunk_info) ; - - return SFE_BAD_CHUNK_FORMAT ; -} /* sf_set_chunk */ - -SF_CHUNK_ITERATOR * -sf_get_chunk_iterator (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) -{ SF_PRIVATE *psf ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (chunk_info) - return psf_get_chunk_iterator (psf, chunk_info->id) ; - - return psf_get_chunk_iterator (psf, NULL) ; -} /* sf_get_chunk_iterator */ - -SF_CHUNK_ITERATOR * -sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) -{ SF_PRIVATE *psf ; - SNDFILE *sndfile = iterator ? iterator->sndfile : NULL ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (psf->next_chunk_iterator) - return psf->next_chunk_iterator (psf, iterator) ; - - return NULL ; -} /* sf_get_chunk_iterator_next */ - -int -sf_get_chunk_size (const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ SF_PRIVATE *psf ; - SNDFILE *sndfile = iterator ? iterator->sndfile : NULL ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (chunk_info == NULL) - return SFE_BAD_CHUNK_PTR ; - - if (psf->get_chunk_size) - return psf->get_chunk_size (psf, iterator, chunk_info) ; - - return SFE_BAD_CHUNK_FORMAT ; -} /* sf_get_chunk_size */ - -int -sf_get_chunk_data (const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ SF_PRIVATE *psf ; - SNDFILE *sndfile = iterator ? iterator->sndfile : NULL ; - - VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ; - - if (chunk_info == NULL || chunk_info->data == NULL) - return SFE_BAD_CHUNK_PTR ; - - if (psf->get_chunk_data) - return psf->get_chunk_data (psf, iterator, chunk_info) ; - - return SFE_BAD_CHUNK_FORMAT ; -} /* sf_get_chunk_data */ diff --git a/Engine/lib/libsndfile/src/strings.c b/Engine/lib/libsndfile/src/strings.c deleted file mode 100644 index 3dfe5de8b..000000000 --- a/Engine/lib/libsndfile/src/strings.c +++ /dev/null @@ -1,190 +0,0 @@ -/* -** Copyright (C) 2001-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "sndfile.h" -#include "common.h" - -#define STRINGS_DEBUG 0 - -int -psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) -{ char new_str [128] ; - size_t str_len ; - int k, str_flags ; - - if (str == NULL) - return SFE_STR_BAD_STRING ; - - str_len = strlen (str) ; - - /* A few extra checks for write mode. */ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if ((psf->strings.flags & SF_STR_ALLOW_START) == 0) - return SFE_STR_NO_SUPPORT ; - if (psf->have_written && (psf->strings.flags & SF_STR_ALLOW_END) == 0) - return SFE_STR_NO_SUPPORT ; - /* Only allow zero length strings for software. */ - if (str_type != SF_STR_SOFTWARE && str_len == 0) - return SFE_STR_BAD_STRING ; - } ; - - /* Find the next free slot in table. */ - for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { /* If we find a matching entry clear it. */ - if (psf->strings.data [k].type == str_type) - psf->strings.data [k].type = -1 ; - - if (psf->strings.data [k].type == 0) - break ; - } ; - - /* Determine flags */ - str_flags = SF_STR_LOCATE_START ; - if (psf->file.mode == SFM_RDWR || psf->have_written) - { if ((psf->strings.flags & SF_STR_ALLOW_END) == 0) - return SFE_STR_NO_ADD_END ; - str_flags = SF_STR_LOCATE_END ; - } ; - - /* More sanity checking. */ - if (k >= SF_MAX_STRINGS) - return SFE_STR_MAX_COUNT ; - - if (k == 0 && psf->strings.storage_used != 0) - { psf_log_printf (psf, "SFE_STR_WEIRD : k == 0 && psf->strings.storage_used != 0\n") ; - return SFE_STR_WEIRD ; - } ; - - if (k != 0 && psf->strings.storage_used == 0) - { psf_log_printf (psf, "SFE_STR_WEIRD : k != 0 && psf->strings.storage_used == 0\n") ; - return SFE_STR_WEIRD ; - } ; - - /* Special case for the first string. */ - if (k == 0) - psf->strings.storage_used = 0 ; - - switch (str_type) - { case SF_STR_SOFTWARE : - /* In write mode, want to append libsndfile-version to string. */ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (strstr (str, PACKAGE_NAME) == NULL) - { /* - ** If the supplied string does not already contain a - ** libsndfile-X.Y.Z component, then add it. - */ - if (strlen (str) == 0) - snprintf (new_str, sizeof (new_str), "%s-%s", PACKAGE_NAME, PACKAGE_VERSION) ; - else - snprintf (new_str, sizeof (new_str), "%s (%s-%s)", str, PACKAGE_NAME, PACKAGE_VERSION) ; - } - else - snprintf (new_str, sizeof (new_str), "%s", str) ; - - str = new_str ; - } ; - break ; - - case SF_STR_TITLE : - case SF_STR_COPYRIGHT : - case SF_STR_ARTIST : - case SF_STR_COMMENT : - case SF_STR_DATE : - case SF_STR_ALBUM : - case SF_STR_LICENSE : - case SF_STR_TRACKNUMBER : - case SF_STR_GENRE : - break ; - - default : - psf_log_printf (psf, "%s : SFE_STR_BAD_TYPE\n", __func__) ; - return SFE_STR_BAD_TYPE ; - } ; - - /* Plus one to catch string terminator. */ - str_len = strlen (str) + 1 ; - - if (psf->strings.storage_used + str_len + 1 > psf->strings.storage_len) - { char * temp = psf->strings.storage ; - size_t newlen = 2 * psf->strings.storage_len + str_len + 1 ; - - newlen = newlen < 256 ? 256 : newlen ; - - char * new_storage = realloc(temp, newlen); - if (new_storage == NULL) - { - return SFE_MALLOC_FAILED ; - } else { - psf->strings.storage = new_storage; - } ; - - psf->strings.storage_len = newlen ; - } ; - - psf->strings.data [k].type = str_type ; - psf->strings.data [k].offset = psf->strings.storage_used ; - psf->strings.data [k].flags = str_flags ; - - memcpy (psf->strings.storage + psf->strings.storage_used, str, str_len) ; - psf->strings.storage_used += str_len ; - - psf->strings.flags |= str_flags ; - -#if STRINGS_DEBUG - printf ("storage_used : %zd / %zd\n", psf->strings.storage_used, psf->strings.storage_len) ; - psf_hexdump (psf->strings.storage, psf->strings.storage_used) ; -#endif - - return 0 ; -} /* psf_store_string */ - -int -psf_set_string (SF_PRIVATE *psf, int str_type, const char *str) -{ if (psf->file.mode == SFM_READ) - return SFE_STR_NOT_WRITE ; - - return psf_store_string (psf, str_type, str) ; -} /* psf_set_string */ - -const char* -psf_get_string (SF_PRIVATE *psf, int str_type) -{ int k ; - - for (k = 0 ; k < SF_MAX_STRINGS ; k++) - if (str_type == psf->strings.data [k].type) - return psf->strings.storage + psf->strings.data [k].offset ; - - return NULL ; -} /* psf_get_string */ - -int -psf_location_string_count (const SF_PRIVATE * psf, int location) -{ int k, count = 0 ; - - for (k = 0 ; k < SF_MAX_STRINGS ; k++) - if (psf->strings.data [k].type > 0 && psf->strings.data [k].flags & location) - count ++ ; - - return count ; -} /* psf_location_string_count */ diff --git a/Engine/lib/libsndfile/src/svx.c b/Engine/lib/libsndfile/src/svx.c deleted file mode 100644 index 342b00629..000000000 --- a/Engine/lib/libsndfile/src/svx.c +++ /dev/null @@ -1,402 +0,0 @@ -/* -** Copyright (C) 1999-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - - -/*------------------------------------------------------------------------------ - * Macros to handle big/little endian issues. -*/ - -#define FORM_MARKER (MAKE_MARKER ('F', 'O', 'R', 'M')) -#define SVX8_MARKER (MAKE_MARKER ('8', 'S', 'V', 'X')) -#define SV16_MARKER (MAKE_MARKER ('1', '6', 'S', 'V')) -#define VHDR_MARKER (MAKE_MARKER ('V', 'H', 'D', 'R')) -#define BODY_MARKER (MAKE_MARKER ('B', 'O', 'D', 'Y')) - -#define ATAK_MARKER (MAKE_MARKER ('A', 'T', 'A', 'K')) -#define RLSE_MARKER (MAKE_MARKER ('R', 'L', 'S', 'E')) - -#define c_MARKER (MAKE_MARKER ('(', 'c', ')', ' ')) -#define NAME_MARKER (MAKE_MARKER ('N', 'A', 'M', 'E')) -#define AUTH_MARKER (MAKE_MARKER ('A', 'U', 'T', 'H')) -#define ANNO_MARKER (MAKE_MARKER ('A', 'N', 'N', 'O')) -#define CHAN_MARKER (MAKE_MARKER ('C', 'H', 'A', 'N')) - -/*------------------------------------------------------------------------------ - * Typedefs for file chunks. -*/ - -typedef struct -{ unsigned int oneShotHiSamples, repeatHiSamples, samplesPerHiCycle ; - unsigned short samplesPerSec ; - unsigned char octave, compression ; - unsigned int volume ; -} VHDR_CHUNK ; - -enum { - HAVE_FORM = 0x01, - - HAVE_SVX = 0x02, - HAVE_VHDR = 0x04, - HAVE_BODY = 0x08 -} ; - -/*------------------------------------------------------------------------------ - * Private static functions. -*/ - -static int svx_close (SF_PRIVATE *psf) ; -static int svx_write_header (SF_PRIVATE *psf, int calc_length) ; -static int svx_read_header (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -svx_open (SF_PRIVATE *psf) -{ int error ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = svx_read_header (psf))) - return error ; - - psf->endian = SF_ENDIAN_BIG ; /* All SVX files are big endian. */ - - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - if (psf->blockwidth) - psf->sf.frames = psf->datalength / psf->blockwidth ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (psf->is_pipe) - return SFE_NO_PIPE_WRITE ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_SVX) - return SFE_BAD_OPEN_FORMAT ; - - psf->endian = SF_ENDIAN (psf->sf.format) ; - - if (psf->endian == SF_ENDIAN_LITTLE || (CPU_IS_LITTLE_ENDIAN && psf->endian == SF_ENDIAN_CPU)) - return SFE_BAD_ENDIAN ; - - psf->endian = SF_ENDIAN_BIG ; /* All SVX files are big endian. */ - - error = svx_write_header (psf, SF_FALSE) ; - if (error) - return error ; - - psf->write_header = svx_write_header ; - } ; - - psf->container_close = svx_close ; - - if ((error = pcm_init (psf))) - return error ; - - return 0 ; -} /* svx_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -svx_read_header (SF_PRIVATE *psf) -{ VHDR_CHUNK vhdr ; - uint32_t chunk_size, marker ; - int filetype = 0, parsestage = 0, done = 0 ; - int bytecount = 0, channels ; - - if (psf->filelength > 0xFFFFFFFFLL) - psf_log_printf (psf, "Warning : filelength > 0xffffffff. This is bad!!!!\n") ; - - memset (&vhdr, 0, sizeof (vhdr)) ; - psf_binheader_readf (psf, "p", 0) ; - - /* Set default number of channels. Modify later if necessary */ - psf->sf.channels = 1 ; - - psf->sf.format = SF_FORMAT_SVX ; - - while (! done) - { psf_binheader_readf (psf, "Em4", &marker, &chunk_size) ; - - switch (marker) - { case FORM_MARKER : - if (parsestage) - return SFE_SVX_NO_FORM ; - - if (chunk_size != psf->filelength - 2 * sizeof (chunk_size)) - psf_log_printf (psf, "FORM : %u (should be %u)\n", chunk_size, (uint32_t) psf->filelength - 2 * sizeof (chunk_size)) ; - else - psf_log_printf (psf, "FORM : %u\n", chunk_size) ; - parsestage |= HAVE_FORM ; - - psf_binheader_readf (psf, "m", &marker) ; - - filetype = marker ; - psf_log_printf (psf, " %M\n", marker) ; - parsestage |= HAVE_SVX ; - break ; - - case VHDR_MARKER : - if (! (parsestage & (HAVE_FORM | HAVE_SVX))) - return SFE_SVX_NO_FORM ; - - psf_log_printf (psf, " VHDR : %d\n", chunk_size) ; - - psf_binheader_readf (psf, "E4442114", &(vhdr.oneShotHiSamples), &(vhdr.repeatHiSamples), - &(vhdr.samplesPerHiCycle), &(vhdr.samplesPerSec), &(vhdr.octave), &(vhdr.compression), - &(vhdr.volume)) ; - - psf_log_printf (psf, " OneShotHiSamples : %d\n", vhdr.oneShotHiSamples) ; - psf_log_printf (psf, " RepeatHiSamples : %d\n", vhdr.repeatHiSamples) ; - psf_log_printf (psf, " samplesPerHiCycle : %d\n", vhdr.samplesPerHiCycle) ; - psf_log_printf (psf, " Sample Rate : %d\n", vhdr.samplesPerSec) ; - psf_log_printf (psf, " Octave : %d\n", vhdr.octave) ; - - psf_log_printf (psf, " Compression : %d => ", vhdr.compression) ; - - switch (vhdr.compression) - { case 0 : psf_log_printf (psf, "None.\n") ; - break ; - case 1 : psf_log_printf (psf, "Fibonacci delta\n") ; - break ; - case 2 : psf_log_printf (psf, "Exponential delta\n") ; - break ; - } ; - - psf_log_printf (psf, " Volume : %d\n", vhdr.volume) ; - - psf->sf.samplerate = vhdr.samplesPerSec ; - - if (filetype == SVX8_MARKER) - { psf->sf.format |= SF_FORMAT_PCM_S8 ; - psf->bytewidth = 1 ; - } - else if (filetype == SV16_MARKER) - { psf->sf.format |= SF_FORMAT_PCM_16 ; - psf->bytewidth = 2 ; - } ; - - parsestage |= HAVE_VHDR ; - break ; - - case BODY_MARKER : - if (! (parsestage & HAVE_VHDR)) - return SFE_SVX_NO_BODY ; - - psf->datalength = chunk_size ; - - psf->dataoffset = psf_ftell (psf) ; - if (psf->dataoffset < 0) - return SFE_SVX_NO_BODY ; - - if (psf->datalength > psf->filelength - psf->dataoffset) - { psf_log_printf (psf, " BODY : %D (should be %D)\n", psf->datalength, psf->filelength - psf->dataoffset) ; - psf->datalength = psf->filelength - psf->dataoffset ; - } - else - psf_log_printf (psf, " BODY : %D\n", psf->datalength) ; - - parsestage |= HAVE_BODY ; - - if (! psf->sf.seekable) - break ; - - psf_fseek (psf, psf->datalength, SEEK_CUR) ; - break ; - - case NAME_MARKER : - if (! (parsestage & HAVE_SVX)) - return SFE_SVX_NO_FORM ; - - psf_log_printf (psf, " %M : %u\n", marker, chunk_size) ; - - if (strlen (psf->file.name) != chunk_size) - { if (chunk_size > sizeof (psf->file.name) - 1) - return SFE_SVX_BAD_NAME_LENGTH ; - - psf_binheader_readf (psf, "b", psf->file.name, chunk_size) ; - psf->file.name [chunk_size] = 0 ; - } - else - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - - case ANNO_MARKER : - if (! (parsestage & HAVE_SVX)) - return SFE_SVX_NO_FORM ; - - psf_log_printf (psf, " %M : %u\n", marker, chunk_size) ; - - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - - case CHAN_MARKER : - if (! (parsestage & HAVE_SVX)) - return SFE_SVX_NO_FORM ; - - psf_log_printf (psf, " %M : %u\n", marker, chunk_size) ; - - bytecount += psf_binheader_readf (psf, "E4", &channels) ; - - if (channels == 2 || channels == 4) - psf_log_printf (psf, " Channels : %d => mono\n", channels) ; - else if (channels == 6) - { psf->sf.channels = 2 ; - psf_log_printf (psf, " Channels : %d => stereo\n", channels) ; - } - else - psf_log_printf (psf, " Channels : %d *** assuming mono\n", channels) ; - - psf_binheader_readf (psf, "j", chunk_size - bytecount) ; - break ; - - - case AUTH_MARKER : - case c_MARKER : - if (! (parsestage & HAVE_SVX)) - return SFE_SVX_NO_FORM ; - - psf_log_printf (psf, " %M : %u\n", marker, chunk_size) ; - - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - - default : - if (chunk_size >= 0xffff0000) - { done = SF_TRUE ; - psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D with length %u. Exiting parser.\n", marker, psf_ftell (psf) - 8, chunk_size) ; - break ; - } ; - - if (psf_isprint ((marker >> 24) & 0xFF) && psf_isprint ((marker >> 16) & 0xFF) - && psf_isprint ((marker >> 8) & 0xFF) && psf_isprint (marker & 0xFF)) - { psf_log_printf (psf, "%M : %u (unknown marker)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - } ; - if ((chunk_size = psf_ftell (psf)) & 0x03) - { psf_log_printf (psf, " Unknown chunk marker at position %d. Resynching.\n", chunk_size - 4) ; - - chunk_size = chunk_size & 3 ; - psf_binheader_readf (psf, "j", 4 - chunk_size) ; - break ; - } ; - psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D. Exiting parser.\n", marker, psf_ftell (psf) - 8) ; - done = SF_TRUE ; - } ; /* switch (marker) */ - - if (! psf->sf.seekable && (parsestage & HAVE_BODY)) - break ; - - if (psf_ftell (psf) >= psf->filelength - SIGNED_SIZEOF (chunk_size)) - break ; - } ; /* while (1) */ - - if (vhdr.compression) - return SFE_SVX_BAD_COMP ; - - if (psf->dataoffset <= 0) - return SFE_SVX_NO_DATA ; - - return 0 ; -} /* svx_read_header */ - -static int -svx_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - svx_write_header (psf, SF_TRUE) ; - - return 0 ; -} /* svx_close */ - -static int -svx_write_header (SF_PRIVATE *psf, int calc_length) -{ static char annotation [] = "libsndfile by Erik de Castro Lopo\0\0\0" ; - sf_count_t current ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - /* FORM marker and FORM size. */ - psf_binheader_writef (psf, "Etm8", BHWm (FORM_MARKER), BHW8 ((psf->filelength < 8) ? - psf->filelength * 0 : psf->filelength - 8)) ; - - psf_binheader_writef (psf, "m", BHWm ((psf->bytewidth == 1) ? SVX8_MARKER : SV16_MARKER)) ; - - /* VHDR chunk. */ - psf_binheader_writef (psf, "Em4", BHWm (VHDR_MARKER), BHW4 (sizeof (VHDR_CHUNK))) ; - /* VHDR : oneShotHiSamples, repeatHiSamples, samplesPerHiCycle */ - psf_binheader_writef (psf, "E444", BHW4 (psf->sf.frames), BHW4 (0), BHW4 (0)) ; - /* VHDR : samplesPerSec, octave, compression */ - psf_binheader_writef (psf, "E211", BHW2 (psf->sf.samplerate), BHW1 (1), BHW1 (0)) ; - /* VHDR : volume */ - psf_binheader_writef (psf, "E4", BHW4 ((psf->bytewidth == 1) ? 0xFF : 0xFFFF)) ; - - if (psf->sf.channels == 2) - psf_binheader_writef (psf, "Em44", BHWm (CHAN_MARKER), BHW4 (4), BHW4 (6)) ; - - /* Filename and annotation strings. */ - psf_binheader_writef (psf, "Emsms", BHWm (NAME_MARKER), BHWs (psf->file.name), BHWm (ANNO_MARKER), BHWs (annotation)) ; - - /* BODY marker and size. */ - psf_binheader_writef (psf, "Etm8", BHWm (BODY_MARKER), BHW8 ((psf->datalength < 0) ? - psf->datalength * 0 : psf->datalength)) ; - - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* svx_write_header */ - diff --git a/Engine/lib/libsndfile/src/test_audio_detect.c b/Engine/lib/libsndfile/src/test_audio_detect.c deleted file mode 100644 index 20926df03..000000000 --- a/Engine/lib/libsndfile/src/test_audio_detect.c +++ /dev/null @@ -1,113 +0,0 @@ -/* -** Copyright (C) 2007-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include -#include - -#include "common.h" -#include "sfendian.h" - -#include "test_main.h" - -static unsigned char float_le_mono [] = -{ 0x36, 0x86, 0x21, 0x44, 0xB5, 0xB4, 0x49, 0x44, 0xA2, 0xC0, 0x71, 0x44, 0x7B, 0xD1, 0x8C, 0x44, - 0x54, 0xAA, 0xA0, 0x44, 0x60, 0x67, 0xB4, 0x44, 0x22, 0x05, 0xC8, 0x44, 0x29, 0x80, 0xDB, 0x44, - 0x04, 0xD5, 0xEE, 0x44, 0x27, 0x00, 0x01, 0x45, 0x50, 0x7F, 0x0A, 0x45, 0x53, 0xE6, 0x13, 0x45, - 0x85, 0x33, 0x1D, 0x45, 0x43, 0x65, 0x26, 0x45, 0xEC, 0x79, 0x2F, 0x45, 0xE3, 0x6F, 0x38, 0x45, - 0x98, 0x45, 0x41, 0x45, 0x77, 0xF9, 0x49, 0x45, 0xF6, 0x89, 0x52, 0x45, 0x8F, 0xF5, 0x5A, 0x45, - 0xC9, 0x3A, 0x63, 0x45, 0x28, 0x58, 0x6B, 0x45, 0x3C, 0x4C, 0x73, 0x45, 0x9F, 0x15, 0x7B, 0x45, - 0x75, 0x59, 0x81, 0x45, 0x64, 0x11, 0x85, 0x45, 0xF1, 0xB1, 0x88, 0x45, 0x78, 0x3A, 0x8C, 0x45, - 0x58, 0xAA, 0x8F, 0x45, 0xF2, 0x00, 0x93, 0x45, 0xB2, 0x3D, 0x96, 0x45, 0x01, 0x60, 0x99, 0x45, - 0x50, 0x67, 0x9C, 0x45, 0x15, 0x53, 0x9F, 0x45, 0xCC, 0x22, 0xA2, 0x45, 0xF0, 0xD5, 0xA4, 0x45, - 0x07, 0x6C, 0xA7, 0x45, 0x9C, 0xE4, 0xA9, 0x45, 0x3D, 0x3F, 0xAC, 0x45, 0x7A, 0x7B, 0xAE, 0x45, - 0xF2, 0x98, 0xB0, 0x45, 0x3C, 0x97, 0xB2, 0x45, 0x02, 0x76, 0xB4, 0x45, 0xEC, 0x34, 0xB6, 0x45, - 0xA8, 0xD3, 0xB7, 0x45, 0xEB, 0x51, 0xB9, 0x45, 0x6F, 0xAF, 0xBA, 0x45, 0xF5, 0xEB, 0xBB, 0x45, - 0x41, 0x07, 0xBD, 0x45, 0x21, 0x01, 0xBE, 0x45, 0x64, 0xD9, 0xBE, 0x45, 0xE3, 0x8F, 0xBF, 0x45, - 0x7E, 0x24, 0xC0, 0x45, 0x15, 0x97, 0xC0, 0x45, 0x92, 0xE7, 0xC0, 0x45, 0xE8, 0x15, 0xC1, 0x45, - 0x7E, 0x24, 0xC0, 0x45, 0x15, 0x97, 0xC0, 0x45, 0x92, 0xE7, 0xC0, 0x45, 0xE8, 0x15, 0xC1, 0x45, - 0x7E, 0x24, 0xC0, 0x45, 0x15, 0x97, 0xC0, 0x45, 0x92, 0xE7, 0xC0, 0x45, 0xE8, 0x15, 0xC1, 0x45, -} ; - -static unsigned char int24_32_le_stereo [] = -{ - 0x00, 0xE7, 0xFB, 0xFF, 0x00, 0x7C, 0xFD, 0xFF, 0x00, 0xA2, 0xFC, 0xFF, 0x00, 0x2B, 0xFC, 0xFF, - 0x00, 0xF3, 0xFD, 0xFF, 0x00, 0x19, 0xFB, 0xFF, 0x00, 0xA5, 0xFE, 0xFF, 0x00, 0x8D, 0xFA, 0xFF, - 0x00, 0x91, 0xFF, 0xFF, 0x00, 0xB5, 0xFA, 0xFF, 0x00, 0x91, 0x00, 0x00, 0x00, 0x5E, 0xFB, 0xFF, - 0x00, 0xD9, 0x01, 0x00, 0x00, 0x82, 0xFB, 0xFF, 0x00, 0xDF, 0x03, 0x00, 0x00, 0x44, 0xFC, 0xFF, - 0x00, 0x1C, 0x05, 0x00, 0x00, 0x77, 0xFC, 0xFF, 0x00, 0x8D, 0x06, 0x00, 0x00, 0x4F, 0xFC, 0xFF, - 0x00, 0x84, 0x07, 0x00, 0x00, 0x74, 0xFC, 0xFF, 0x00, 0x98, 0x08, 0x00, 0x00, 0x33, 0xFD, 0xFF, - 0x00, 0xB9, 0x09, 0x00, 0x00, 0x48, 0xFF, 0xFF, 0x00, 0xD1, 0x0A, 0x00, 0x00, 0x10, 0x02, 0x00, - 0x00, 0x28, 0x0C, 0x00, 0x00, 0xA2, 0x05, 0x00, 0x00, 0xA7, 0x0C, 0x00, 0x00, 0x45, 0x08, 0x00, - 0x00, 0x44, 0x0D, 0x00, 0x00, 0x1A, 0x0A, 0x00, 0x00, 0x65, 0x0D, 0x00, 0x00, 0x51, 0x0B, 0x00, - 0x00, 0x8B, 0x0D, 0x00, 0x00, 0x18, 0x0B, 0x00, 0x00, 0x37, 0x0E, 0x00, 0x00, 0x24, 0x0B, 0x00, - 0x00, 0x00, 0x0F, 0x00, 0x00, 0xDD, 0x0A, 0x00, 0x00, 0x83, 0x10, 0x00, 0x00, 0x31, 0x0A, 0x00, - 0x00, 0x07, 0x12, 0x00, 0x00, 0xC0, 0x08, 0x00, 0x00, 0xF7, 0x12, 0x00, 0x00, 0x47, 0x06, 0x00, - 0x00, 0xDD, 0x12, 0x00, 0x00, 0x6A, 0x03, 0x00, 0x00, 0xD5, 0x11, 0x00, 0x00, 0x99, 0x00, 0x00, - 0x00, 0x01, 0x10, 0x00, 0x00, 0xC5, 0xFE, 0xFF, 0x00, 0xF4, 0x0D, 0x00, 0x00, 0x97, 0xFD, 0xFF, - 0x00, 0x62, 0x0B, 0x00, 0x00, 0x75, 0xFC, 0xFF, 0x00, 0xE9, 0x08, 0x00, 0x00, 0xC0, 0xFB, 0xFF, - 0x00, 0x80, 0x06, 0x00, 0x00, 0x3C, 0xFB, 0xFF, 0x00, 0xDA, 0x03, 0x00, 0x00, 0xE4, 0xFA, 0xFF, - 0x00, 0xEB, 0x01, 0x00, 0x00, 0x21, 0xFB, 0xFF, 0x00, 0x20, 0x00, 0x00, 0x00, 0xE7, 0xFB, 0xFF, -} ; - - -void -test_audio_detect (void) -{ - SF_PRIVATE psf ; - AUDIO_DETECT ad ; - int errors = 0 ; - - print_test_name ("Testing audio detect") ; - - memset (&psf, 0, sizeof (psf)) ; - - ad.endianness = SF_ENDIAN_LITTLE ; - ad.channels = 1 ; - if (audio_detect (&psf, &ad, float_le_mono, sizeof (float_le_mono)) != SF_FORMAT_FLOAT) - { puts (" float_le_mono") ; - errors ++ ; - } ; - - ad.endianness = SF_ENDIAN_LITTLE ; - ad.channels = 2 ; - if (audio_detect (&psf, &ad, int24_32_le_stereo, sizeof (int24_32_le_stereo)) != SF_FORMAT_PCM_32) - { if (errors == 0) puts ("\nFailed tests :\n") ; - puts (" int24_32_le_stereo") ; - errors ++ ; - } ; - - if (errors != 0) - { printf ("\n Errors : %d\n\n", errors) ; - exit (1) ; - } ; - - puts ("ok") ; - - return ; -} /* test_audio_detect */ diff --git a/Engine/lib/libsndfile/src/test_binheader_writef.c b/Engine/lib/libsndfile/src/test_binheader_writef.c deleted file mode 100644 index 8b1f9c1ea..000000000 --- a/Engine/lib/libsndfile/src/test_binheader_writef.c +++ /dev/null @@ -1,61 +0,0 @@ -/* -** Copyright (C) 2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#include "common.h" - -#include "test_main.h" - -void -test_binheader_writef (void) -{ char buffer [18] ; - SF_PRIVATE sf_private, *psf ; - int k, errors = 0 ; - - print_test_name ("Testing binheader_writef") ; - - memset (&sf_private, 0, sizeof (sf_private)) ; - - psf = &sf_private ; - for (k = 0 ; errors == 0 && k < 10 ; k++) - { psf_strlcpy (buffer, sizeof (buffer), "abcdefghijklmnop") ; - buffer [k] = 0 ; - - psf_binheader_writef (psf, "Ep", BHWp (buffer)) ; - - if ((psf->header.indx & 1) != 0) - errors = 1 ; - } ; - - free (psf->header.ptr) ; - - if (errors) - { puts ("\nExiting due to errors.\n") ; - exit (1) ; - } ; - - puts ("ok") ; -} /* test_log_printf */ - diff --git a/Engine/lib/libsndfile/src/test_broadcast_var.c b/Engine/lib/libsndfile/src/test_broadcast_var.c deleted file mode 100644 index 5ae81fb18..000000000 --- a/Engine/lib/libsndfile/src/test_broadcast_var.c +++ /dev/null @@ -1,123 +0,0 @@ -/* -** Copyright (C) 2010-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "common.h" - -#include "test_main.h" - -#define BCAST_MAX 512 - -typedef SF_BROADCAST_INFO_VAR (BCAST_MAX) SF_BROADCAST_INFO_512 ; - -static void -fill_coding_history (SF_BROADCAST_INFO_512 * bi) -{ static const char *lines [] = - { "Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit.", - "Donec dignissim erat\nvehicula libero condimentum\ndictum porta augue faucibus.", - "Maecenas nec turpis\nsit amet quam\nfaucibus adipiscing.", - "Mauris aliquam,\nlectus interdum\ntincidunt luctus.", - "\n\n\n\n\n\n\n\n\n\n\n\n", - "In auctor lorem\nvel est euismod\ncondimentum.", - "\n\n\n\n\n\n\n\n\n\n\n\n", - "Ut vitae magna\nid dui placerat vehicula\nin id lectus.", - "\n\n\n\n\n\n\n\n\n\n\n\n", - "Sed lacus leo,\nmolestie et luctus ac,\ntincidunt sit amet nisi.", - "\n\n\n\n\n\n\n\n\n\n\n\n", - "Sed ligula neque,\ngravida semper vulputate laoreet,\ngravida eu tellus.", - "Donec dolor dolor,\nscelerisque in consequat ornare,\ntempor nec nisl." - } ; - int k ; - - bi->coding_history [0] = 0 ; - - for (k = 0 ; strlen (bi->coding_history) < bi->coding_history_size - 1 ; k ++) - append_snprintf (bi->coding_history, bi->coding_history_size, "%s\n", lines [k % ARRAY_LEN (lines)]) ; - - return ; -} /* fill_coding_listory */ - -static void -test_broadcast_var_set (void) -{ SF_PRIVATE sf_private, *psf ; - int k ; - - psf = &sf_private ; - memset (psf, 0, sizeof (sf_private)) ; - - print_test_name ("Testing broadcast_var_set ") ; - - for (k = 64 ; k < BCAST_MAX ; k++) - { - SF_BROADCAST_INFO_512 bi ; - - memset (&bi, 0, sizeof (bi)) ; - - bi.coding_history_size = k ; - fill_coding_history (&bi) ; - bi.coding_history_size -- ; - - broadcast_var_set (psf, (SF_BROADCAST_INFO*) &bi, sizeof (bi)) ; - } ; - - if (psf->broadcast_16k != NULL) - free (psf->broadcast_16k) ; - - puts ("ok") ; -} /* test_broadcast_var_set */ - -static void -test_broadcast_var_zero (void) -{ SF_PRIVATE sf_private, *psf ; -#ifdef _MSC_VER - SF_BROADCAST_INFO_VAR (0) bi ; -#else - SF_BROADCAST_INFO_VAR () bi ; -#endif - - psf = &sf_private ; - memset (psf, 0, sizeof (sf_private)) ; - psf->file.mode = SFM_RDWR ; - - print_test_name ("Testing broadcast_var_zero ") ; - - memset (&bi, 0, sizeof (bi)) ; - - broadcast_var_set (psf, (SF_BROADCAST_INFO*) &bi, sizeof (bi)) ; - - if (psf->broadcast_16k->coding_history_size != 0) - { printf ("\n\nLine %d: coding_history_size %d should be zero.\n\n", __LINE__, psf->broadcast_16k->coding_history_size) ; - exit (1) ; - } ; - - if (psf->broadcast_16k != NULL) - free (psf->broadcast_16k) ; - - puts ("ok") ; -} /* test_broadcast_var_zero */ - -void -test_broadcast_var (void) -{ test_broadcast_var_set () ; - test_broadcast_var_zero () ; -} /* test_broadcast_var */ diff --git a/Engine/lib/libsndfile/src/test_cart_var.c b/Engine/lib/libsndfile/src/test_cart_var.c deleted file mode 100644 index 532a75587..000000000 --- a/Engine/lib/libsndfile/src/test_cart_var.c +++ /dev/null @@ -1,91 +0,0 @@ -/* -** Copyright (C) 2010-2013 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "common.h" - -#include "test_main.h" - -#define CART_MAX 512 - -typedef SF_CART_INFO_VAR (CART_MAX) SF_CART_INFO_512 ; - -static void -fill_tag_text (SF_CART_INFO_512 * ci) -{ static const char *lines [] = - { "Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit.", - "Donec dignissim erat\nvehicula libero condimentum\ndictum porta augue faucibus.", - "Maecenas nec turpis\nsit amet quam\nfaucibus adipiscing.", - "Mauris aliquam,\nlectus interdum\ntincidunt luctus.", - "\n\n\n\n\n\n\n\n\n\n\n\n", - "In auctor lorem\nvel est euismod\ncondimentum.", - "\n\n\n\n\n\n\n\n\n\n\n\n", - "Ut vitae magna\nid dui placerat vehicula\nin id lectus.", - "\n\n\n\n\n\n\n\n\n\n\n\n", - "Sed lacus leo,\nmolestie et luctus ac,\ntincidunt sit amet nisi.", - "\n\n\n\n\n\n\n\n\n\n\n\n", - "Sed ligula neque,\ngravida semper vulputate laoreet,\ngravida eu tellus.", - "Donec dolor dolor,\nscelerisque in consequat ornare,\ntempor nec nisl." - } ; - int k ; - - ci->tag_text [0] = 0 ; - - for (k = 0 ; strlen (ci->tag_text) < ci->tag_text_size - 1 ; k ++) - append_snprintf (ci->tag_text, ci->tag_text_size, "%s\n", lines [k % ARRAY_LEN (lines)]) ; - - return ; -} /* fill_tag_text */ - -void -test_cart_var (void) -{ SF_PRIVATE sf_private, *psf ; - SF_CART_TIMER timer ; - int k ; - - psf = &sf_private ; - memset (psf, 0, sizeof (sf_private)) ; - - print_test_name ("Testing cart_var_set ") ; - - for (k = 64 ; k < CART_MAX ; k++) - { - SF_CART_INFO_512 ci ; - - memset (&ci, 0, sizeof (ci)) ; - - memset (&timer, 0, sizeof (timer)) ; - memcpy (ci.post_timers, &timer, sizeof (timer)) ; - - ci.tag_text_size = k ; - fill_tag_text (&ci) ; - ci.tag_text_size -- ; - - cart_var_set (psf, (SF_CART_INFO*) &ci, sizeof (ci)) ; - } ; - - if (psf->cart_16k != NULL) - free (psf->cart_16k) ; - - puts ("ok") ; -} /* test_cart_var */ diff --git a/Engine/lib/libsndfile/src/test_conversions.c b/Engine/lib/libsndfile/src/test_conversions.c deleted file mode 100644 index f717fa58a..000000000 --- a/Engine/lib/libsndfile/src/test_conversions.c +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Copyright (C) 2006-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#include "common.h" -#include "test_main.h" - - -/* -** This is a bit rough, but it is the nicest way to do it. -*/ - -#define cmp_test(line, ival, tval, str) \ - if (ival != tval) \ - { printf (str, line, ival, tval) ; \ - exit (1) ; \ - } ; - -static void -conversion_test (char endian) -{ - SF_PRIVATE sf_private, *psf ; - const char * filename = "conversion.bin" ; - int64_t i64 = 0x0123456789ABCDEFLL, t64 = 0 ; - char format_str [16] ; - char test_name [64] ; - char i8 = 12, t8 = 0 ; - short i16 = 0x123, t16 = 0 ; - int i24 = 0x23456, t24 = 0 ; - int i32 = 0x0a0b0c0d, t32 = 0 ; - int bytes ; - - snprintf (format_str, sizeof (format_str), "%c12348", endian) ; - - snprintf (test_name, sizeof (test_name), "Testing %s conversions", endian == 'e' ? "little endian" : "big endian") ; - print_test_name (test_name) ; - - psf = &sf_private ; - memset (psf, 0, sizeof (sf_private)) ; - - psf->file.mode = SFM_WRITE ; - snprintf (psf->file.path, sizeof (psf->file.path), "%s", filename) ; - - if (psf_fopen (psf) != 0) - { printf ("\n\nError : failed to open file '%s' for write.\n\n", filename) ; - exit (1) ; - } ; - - psf_binheader_writef (psf, format_str, i8, i16, i24, i32, i64) ; - psf_fwrite (psf->header.ptr, 1, psf->header.indx, psf) ; - free (psf->header.ptr) ; - psf_fclose (psf) ; - - memset (psf, 0, sizeof (sf_private)) ; - - psf->file.mode = SFM_READ ; - snprintf (psf->file.path, sizeof (psf->file.path), "%s", filename) ; - - if (psf_fopen (psf) != 0) - { printf ("\n\nError : failed to open file '%s' for read.\n\n", filename) ; - exit (1) ; - } ; - - bytes = psf_binheader_readf (psf, format_str, &t8, &t16, &t24, &t32, &t64) ; - free (psf->header.ptr) ; - psf_fclose (psf) ; - - if (bytes != 18) - { printf ("\n\nLine %d : read %d bytes.\n\n", __LINE__, bytes) ; - exit (1) ; - } ; - - cmp_test (__LINE__, i8, t8, "\n\nLine %d : 8 bit int failed %d -> %d.\n\n") ; - cmp_test (__LINE__, i16, t16, "\n\nLine %d : 16 bit int failed 0x%x -> 0x%x.\n\n") ; - cmp_test (__LINE__, i24, t24, "\n\nLine %d : 24 bit int failed 0x%x -> 0x%x.\n\n") ; - cmp_test (__LINE__, i32, t32, "\n\nLine %d : 32 bit int failed 0x%x -> 0x%x.\n\n") ; - cmp_test (__LINE__, i64, t64, "\n\nLine %d : 64 bit int failed 0x%" PRIx64 "x -> 0x%" PRIx64 "x.\n\n") ; - - remove (filename) ; - puts ("ok") ; -} /* conversion_test */ - -void -test_conversions (void) -{ - conversion_test ('E') ; - conversion_test ('e') ; -} /* test_conversion */ - diff --git a/Engine/lib/libsndfile/src/test_endswap.def b/Engine/lib/libsndfile/src/test_endswap.def deleted file mode 100644 index 1d6ab1f0d..000000000 --- a/Engine/lib/libsndfile/src/test_endswap.def +++ /dev/null @@ -1,40 +0,0 @@ -autogen definitions test_endswap.tpl; - -int_type = { - name = short ; - value = '0x3210' ; - format = FMT_SHORT ; - } ; - -int_type = { - name = int ; - value = '0x76543210' ; - format = FMT_INT ; - } ; - -int_type = { - name = int64_t ; - value = '0x0807050540302010LL' ; - format = FMT_INT64 ; - } ; - -int_size = { - name = 16 ; - typename = int16_t ; - value = '0x4142' ; - strval = "AB" ; - } ; - -int_size = { - name = 32 ; - typename = int32_t ; - value = '0x30313233' ; - strval = "0123" ; - } ; - -int_size = { - name = 64 ; - typename = int64_t ; - value = '0x3031323334353637' ; - strval = "01234567" ; - } ; diff --git a/Engine/lib/libsndfile/src/test_endswap.tpl b/Engine/lib/libsndfile/src/test_endswap.tpl deleted file mode 100644 index 348a6be60..000000000 --- a/Engine/lib/libsndfile/src/test_endswap.tpl +++ /dev/null @@ -1,153 +0,0 @@ -[+ AutoGen5 template c +] -/* -** Copyright (C) 2002-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include "common.h" -#include "sfendian.h" - -#include "test_main.h" - -#define FMT_SHORT "0x%04x\n" -#define FMT_INT "0x%08x\n" -#define FMT_INT64 "0x%016" PRIx64 "\n" - -/*============================================================================== -** Test functions. -*/ - -[+ FOR int_type +] -static void -dump_[+ (get "name") +]_array (const char * name, [+ (get "name") +] * data, int datalen) -{ int k ; - - printf ("%-6s : ", name) ; - for (k = 0 ; k < datalen ; k++) - printf ([+ (get "format") +], data [k]) ; - putchar ('\n') ; -} /* dump_[+ (get "name") +]_array */ - -static void -test_endswap_[+ (get "name") +] (void) -{ [+ (get "name") +] orig [4], first [4], second [4] ; - int64_t k ; - - printf (" %-40s : ", "test_endswap_[+ (get "name") +]") ; - fflush (stdout) ; - - for (k = 0 ; k < ARRAY_LEN (orig) ; k++) - orig [k] = [+ (get "value") +] + k ; - - endswap_[+ (get "name") +]_copy (first, orig, ARRAY_LEN (first)) ; - endswap_[+ (get "name") +]_copy (second, first, ARRAY_LEN (second)) ; - - if (memcmp (orig, first, sizeof (orig)) == 0) - { printf ("\n\nLine %d : test 1 : these two array should not be the same:\n\n", __LINE__) ; - dump_[+ (get "name") +]_array ("orig", orig, ARRAY_LEN (orig)) ; - dump_[+ (get "name") +]_array ("first", first, ARRAY_LEN (first)) ; - exit (1) ; - } ; - - if (memcmp (orig, second, sizeof (orig)) != 0) - { printf ("\n\nLine %d : test 2 : these two array should be the same:\n\n", __LINE__) ; - dump_[+ (get "name") +]_array ("orig", orig, ARRAY_LEN (orig)) ; - dump_[+ (get "name") +]_array ("second", second, ARRAY_LEN (second)) ; - exit (1) ; - } ; - - endswap_[+ (get "name") +]_array (first, ARRAY_LEN (first)) ; - - if (memcmp (orig, first, sizeof (orig)) != 0) - { printf ("\n\nLine %d : test 3 : these two array should be the same:\n\n", __LINE__) ; - dump_[+ (get "name") +]_array ("orig", orig, ARRAY_LEN (orig)) ; - dump_[+ (get "name") +]_array ("first", first, ARRAY_LEN (first)) ; - exit (1) ; - } ; - - endswap_[+ (get "name") +]_copy (first, orig, ARRAY_LEN (first)) ; - endswap_[+ (get "name") +]_copy (first, first, ARRAY_LEN (first)) ; - - if (memcmp (orig, first, sizeof (orig)) != 0) - { printf ("\n\nLine %d : test 4 : these two array should be the same:\n\n", __LINE__) ; - dump_[+ (get "name") +]_array ("orig", orig, ARRAY_LEN (orig)) ; - dump_[+ (get "name") +]_array ("first", first, ARRAY_LEN (first)) ; - exit (1) ; - } ; - - puts ("ok") ; -} /* test_endswap_[+ (get "name") +] */ -[+ ENDFOR int_type -+] - -[+ FOR int_size +] -static void -test_psf_put_be[+ (get "name") +] (void) -{ const char *test = "[+ (get "strval") +]" ; - uint8_t array [32] ; - int k ; - - printf (" %-40s : ", __func__) ; - fflush (stdout) ; - - for (k = 0 ; k < 10 ; k++) - { memset (array, 0, sizeof (array)) ; - - psf_put_be[+ (get "name") +] (array, k, [+ (get "value") +]) ; - if (memcmp (array + k, test, sizeof ([+ (get "typename") +])) != 0) - { printf ("\n\nLine %d : Put failed at index %d.\n", __LINE__, k) ; - exit (1) ; - } ; - if (psf_get_be[+ (get "name") +] (array, k) != [+ (get "value") +]) - { printf ("\n\nLine %d : Get failed at index %d.\n", __LINE__, k) ; - exit (1) ; - } ; - } ; - - puts ("ok") ; -} /* test_psf_put_be[+ (get "name") +] */ -[+ ENDFOR int_size -+] - -void -test_endswap (void) -{ -[+ FOR int_type -+] test_endswap_[+ (get "name") +] () ; -[+ ENDFOR int_type -+] - -[+ FOR int_size -+] test_psf_put_be[+ (get "name") +] () ; -[+ ENDFOR int_size -+] - -} /* test_endswap */ - diff --git a/Engine/lib/libsndfile/src/test_file_io.c b/Engine/lib/libsndfile/src/test_file_io.c deleted file mode 100644 index 1e5b0f568..000000000 --- a/Engine/lib/libsndfile/src/test_file_io.c +++ /dev/null @@ -1,492 +0,0 @@ -/* -** Copyright (C) 2002-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include -#include -#include - -#include "common.h" - -#include "test_main.h" - -static void make_data (int *data, int len, int seed) ; - -static void file_open_test (const char *filename) ; -static void file_read_write_test (const char *filename) ; -static void file_truncate_test (const char *filename) ; - -static void test_open_or_die (SF_PRIVATE *psf, int linenum) ; -static void test_close_or_die (SF_PRIVATE *psf, int linenum) ; - -static void test_write_or_die (SF_PRIVATE *psf, void *data, sf_count_t bytes, sf_count_t items, sf_count_t new_position, int linenum) ; -static void test_read_or_die (SF_PRIVATE *psf, void *data, sf_count_t bytes, sf_count_t items, sf_count_t new_position, int linenum) ; -static void test_equal_or_die (int *array1, int *array2, int len, int linenum) ; -static void test_seek_or_die (SF_PRIVATE *psf, sf_count_t offset, int whence, sf_count_t new_position, int linenum) ; -static void test_tell_or_die (SF_PRIVATE *psf, sf_count_t expected_position, int linenum) ; - - - -/*============================================================================== -** Actual test functions. -*/ - -static void -file_open_test (const char *filename) -{ SF_PRIVATE sf_data, *psf ; - int error ; - - print_test_name ("Testing file open") ; - - memset (&sf_data, 0, sizeof (sf_data)) ; - psf = &sf_data ; - - /* Ensure that the file doesn't already exist. */ - if (unlink (filename) != 0 && errno != ENOENT) - { printf ("\n\nLine %d: unlink failed (%d) : %s\n\n", __LINE__, errno, strerror (errno)) ; - exit (1) ; - } ; - - psf->file.mode = SFM_READ ; - snprintf (psf->file.path, sizeof (psf->file.path), "%s", filename) ; - - /* Test that open for read fails if the file doesn't exist. */ - error = psf_fopen (psf) ; - if (error == 0) - { printf ("\n\nLine %d: psf_fopen() should have failed.\n\n", __LINE__) ; - exit (1) ; - } ; - - /* Reset error to zero. */ - psf->error = SFE_NO_ERROR ; - - /* Test file open in write mode. */ - psf->file.mode = SFM_WRITE ; - test_open_or_die (psf, __LINE__) ; - - test_close_or_die (psf, __LINE__) ; - - unlink (psf->file.path) ; - - /* Test file open in read/write mode for a non-existant file. */ - psf->file.mode = SFM_RDWR ; - test_open_or_die (psf, __LINE__) ; - - test_close_or_die (psf, __LINE__) ; - - /* Test file open in read/write mode for an existing file. */ - psf->file.mode = SFM_RDWR ; - test_open_or_die (psf, __LINE__) ; - - test_close_or_die (psf, __LINE__) ; - - unlink (psf->file.path) ; - puts ("ok") ; -} /* file_open_test */ - -static void -file_read_write_test (const char *filename) -{ static int data_out [512] ; - static int data_in [512] ; - - SF_PRIVATE sf_data, *psf ; - sf_count_t retval ; - - /* - ** Open a new file and write two blocks of data to the file. After each - ** write, test that psf_get_filelen() returns the new length. - */ - - print_test_name ("Testing file write") ; - - memset (&sf_data, 0, sizeof (sf_data)) ; - psf = &sf_data ; - snprintf (psf->file.path, sizeof (psf->file.path), "%s", filename) ; - - /* Test file open in write mode. */ - psf->file.mode = SFM_WRITE ; - test_open_or_die (psf, __LINE__) ; - - make_data (data_out, ARRAY_LEN (data_out), 1) ; - test_write_or_die (psf, data_out, sizeof (data_out [0]), ARRAY_LEN (data_out), sizeof (data_out), __LINE__) ; - - if ((retval = psf_get_filelen (psf)) != sizeof (data_out)) - { printf ("\n\nLine %d: file length after write is not correct (%" PRId64 " should be %zd).\n\n", __LINE__, retval, sizeof (data_out)) ; - if (retval == 0) - printf ("An fsync() may be necessary before fstat() in psf_get_filelen().\n\n") ; - exit (1) ; - } ; - - make_data (data_out, ARRAY_LEN (data_out), 2) ; - test_write_or_die (psf, data_out, ARRAY_LEN (data_out), sizeof (data_out [0]), 2 * sizeof (data_out), __LINE__) ; - - if ((retval = psf_get_filelen (psf)) != 2 * sizeof (data_out)) - { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %zd)\n\n", __LINE__, retval, 2 * sizeof (data_out)) ; - exit (1) ; - } ; - - test_close_or_die (psf, __LINE__) ; - puts ("ok") ; - - /* - ** Now open the file in read mode, check the file length and check - ** that the data is correct. - */ - - print_test_name ("Testing file read") ; - - /* Test file open in write mode. */ - psf->file.mode = SFM_READ ; - test_open_or_die (psf, __LINE__) ; - - make_data (data_out, ARRAY_LEN (data_out), 1) ; - test_read_or_die (psf, data_in, 1, sizeof (data_in), sizeof (data_in), __LINE__) ; - test_equal_or_die (data_out, data_in, ARRAY_LEN (data_out), __LINE__) ; - - make_data (data_out, ARRAY_LEN (data_out), 2) ; - test_read_or_die (psf, data_in, sizeof (data_in [0]), ARRAY_LEN (data_in), 2 * sizeof (data_in), __LINE__) ; - test_equal_or_die (data_out, data_in, ARRAY_LEN (data_out), __LINE__) ; - - test_close_or_die (psf, __LINE__) ; - - puts ("ok") ; - - /* - ** Open the file in read/write mode, seek around a bit and then seek to - ** the end of the file and write another block of data (3rd block). Then - ** go back and check that all three blocks are correct. - */ - - print_test_name ("Testing file seek") ; - - /* Test file open in read/write mode. */ - psf->file.mode = SFM_RDWR ; - test_open_or_die (psf, __LINE__) ; - - test_seek_or_die (psf, 0, SEEK_SET, 0, __LINE__) ; - test_seek_or_die (psf, 0, SEEK_END, 2 * SIGNED_SIZEOF (data_out), __LINE__) ; - test_seek_or_die (psf, -1 * SIGNED_SIZEOF (data_out), SEEK_CUR, (sf_count_t) sizeof (data_out), __LINE__) ; - - test_seek_or_die (psf, SIGNED_SIZEOF (data_out), SEEK_CUR, 2 * SIGNED_SIZEOF (data_out), __LINE__) ; - make_data (data_out, ARRAY_LEN (data_out), 3) ; - test_write_or_die (psf, data_out, sizeof (data_out [0]), ARRAY_LEN (data_out), 3 * sizeof (data_out), __LINE__) ; - - test_seek_or_die (psf, 0, SEEK_SET, 0, __LINE__) ; - make_data (data_out, ARRAY_LEN (data_out), 1) ; - test_read_or_die (psf, data_in, 1, sizeof (data_in), sizeof (data_in), __LINE__) ; - test_equal_or_die (data_out, data_in, ARRAY_LEN (data_out), __LINE__) ; - - test_seek_or_die (psf, 2 * SIGNED_SIZEOF (data_out), SEEK_SET, 2 * SIGNED_SIZEOF (data_out), __LINE__) ; - make_data (data_out, ARRAY_LEN (data_out), 3) ; - test_read_or_die (psf, data_in, 1, sizeof (data_in), 3 * sizeof (data_in), __LINE__) ; - test_equal_or_die (data_out, data_in, ARRAY_LEN (data_out), __LINE__) ; - - test_seek_or_die (psf, SIGNED_SIZEOF (data_out), SEEK_SET, SIGNED_SIZEOF (data_out), __LINE__) ; - make_data (data_out, ARRAY_LEN (data_out), 2) ; - test_read_or_die (psf, data_in, 1, sizeof (data_in), 2 * sizeof (data_in), __LINE__) ; - test_equal_or_die (data_out, data_in, ARRAY_LEN (data_out), __LINE__) ; - - test_close_or_die (psf, __LINE__) ; - puts ("ok") ; - - /* - ** Now test operations with a non-zero psf->fileoffset field. This field - ** sets an artificial file start positions so that a seek to the start of - ** the file will actually be a seek to the value given by psf->fileoffset. - */ - - print_test_name ("Testing file offset") ; - - /* Test file open in read/write mode. */ - psf->file.mode = SFM_RDWR ; - psf->fileoffset = sizeof (data_out [0]) * ARRAY_LEN (data_out) ; - test_open_or_die (psf, __LINE__) ; - - if ((retval = psf_get_filelen (psf)) != 3 * sizeof (data_out)) - { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %zd)\n\n", __LINE__, retval, 3 * sizeof (data_out)) ; - exit (1) ; - } ; - - test_seek_or_die (psf, SIGNED_SIZEOF (data_out), SEEK_SET, SIGNED_SIZEOF (data_out), __LINE__) ; - make_data (data_out, ARRAY_LEN (data_out), 5) ; - test_write_or_die (psf, data_out, sizeof (data_out [0]), ARRAY_LEN (data_out), 2 * sizeof (data_out), __LINE__) ; - test_close_or_die (psf, __LINE__) ; - - /* final test with psf->fileoffset == 0. */ - - psf->file.mode = SFM_RDWR ; - psf->fileoffset = 0 ; - test_open_or_die (psf, __LINE__) ; - - if ((retval = psf_get_filelen (psf)) != 3 * sizeof (data_out)) - { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %zd)\n\n", __LINE__, retval, 3 * sizeof (data_out)) ; - exit (1) ; - } ; - - make_data (data_out, ARRAY_LEN (data_out), 1) ; - test_read_or_die (psf, data_in, 1, sizeof (data_in), sizeof (data_in), __LINE__) ; - test_equal_or_die (data_out, data_in, ARRAY_LEN (data_out), __LINE__) ; - - make_data (data_out, ARRAY_LEN (data_out), 2) ; - test_read_or_die (psf, data_in, 1, sizeof (data_in), 2 * sizeof (data_in), __LINE__) ; - test_equal_or_die (data_out, data_in, ARRAY_LEN (data_out), __LINE__) ; - - make_data (data_out, ARRAY_LEN (data_out), 5) ; - test_read_or_die (psf, data_in, 1, sizeof (data_in), 3 * sizeof (data_in), __LINE__) ; - test_equal_or_die (data_out, data_in, ARRAY_LEN (data_out), __LINE__) ; - - test_close_or_die (psf, __LINE__) ; - - puts ("ok") ; -} /* file_read_write_test */ - -static void -file_truncate_test (const char *filename) -{ SF_PRIVATE sf_data, *psf ; - unsigned char buffer [256] ; - int k ; - - /* - ** Open a new file and write two blocks of data to the file. After each - ** write, test that psf_get_filelen() returns the new length. - */ - - print_test_name ("Testing file truncate") ; - - memset (&sf_data, 0, sizeof (sf_data)) ; - memset (buffer, 0xEE, sizeof (buffer)) ; - - psf = &sf_data ; - snprintf (psf->file.path, sizeof (psf->file.path), "%s", filename) ; - - /* - ** Open the file write mode, write 0xEE data and then extend the file - ** using truncate (the extended data should be 0x00). - */ - psf->file.mode = SFM_WRITE ; - test_open_or_die (psf, __LINE__) ; - test_write_or_die (psf, buffer, sizeof (buffer) / 2, 1, sizeof (buffer) / 2, __LINE__) ; - psf_ftruncate (psf, sizeof (buffer)) ; - test_close_or_die (psf, __LINE__) ; - - /* Open the file in read mode and check the data. */ - psf->file.mode = SFM_READ ; - test_open_or_die (psf, __LINE__) ; - test_read_or_die (psf, buffer, sizeof (buffer), 1, sizeof (buffer), __LINE__) ; - test_close_or_die (psf, __LINE__) ; - - for (k = 0 ; k < SIGNED_SIZEOF (buffer) / 2 ; k++) - if (buffer [k] != 0xEE) - { printf ("\n\nLine %d : buffer [%d] = %hhu (should be 0xEE)\n\n", __LINE__, k, buffer [k]) ; - exit (1) ; - } ; - - for (k = SIGNED_SIZEOF (buffer) / 2 ; k < SIGNED_SIZEOF (buffer) ; k++) - if (buffer [k] != 0) - { printf ("\n\nLine %d : buffer [%d] = %hhu (should be 0)\n\n", __LINE__, k, buffer [k]) ; - exit (1) ; - } ; - - /* Open the file in read/write and shorten the file using truncate. */ - psf->file.mode = SFM_RDWR ; - test_open_or_die (psf, __LINE__) ; - psf_ftruncate (psf, sizeof (buffer) / 4) ; - test_close_or_die (psf, __LINE__) ; - - /* Check the file length. */ - psf->file.mode = SFM_READ ; - test_open_or_die (psf, __LINE__) ; - test_seek_or_die (psf, 0, SEEK_END, SIGNED_SIZEOF (buffer) / 4, __LINE__) ; - test_close_or_die (psf, __LINE__) ; - - puts ("ok") ; -} /* file_truncate_test */ - -static void -file_seek_with_offset_test (const char *filename) -{ SF_PRIVATE sf_data, *psf ; - sf_count_t real_end ; - const size_t fileoffset = 64 ; - - print_test_name ("Testing seek with offset") ; - - /* Open the file created by the previous test for reading. */ - memset (&sf_data, 0, sizeof (sf_data)) ; - psf = &sf_data ; - psf->file.mode = SFM_READ ; - snprintf (psf->file.path, sizeof (psf->file.path), "%s", filename) ; - test_open_or_die (psf, __LINE__) ; - - /* Gather basic info before setting offset. */ - real_end = psf_fseek (psf, 0, SEEK_END) ; - test_tell_or_die (psf, real_end, __LINE__) ; - - /* Set the fileoffset (usually in a real system this is due to an id3 tag). */ - psf->fileoffset = fileoffset ; - - /* Check tell respects offset. */ - test_tell_or_die (psf, real_end - fileoffset, __LINE__) ; - - /* Check seeking works as expected. */ - test_seek_or_die (psf, 0, SEEK_SET, 0, __LINE__) ; - test_seek_or_die (psf, 0, SEEK_CUR, 0, __LINE__) ; - test_seek_or_die (psf, 0, SEEK_CUR, 0, __LINE__) ; - test_seek_or_die (psf, 0, SEEK_END, real_end - fileoffset, __LINE__) ; - - test_close_or_die (psf, __LINE__) ; - - puts ("ok") ; -} /* file_seek_with_offset_test */ - -/*============================================================================== -** Testing helper functions. -*/ - -static void -test_open_or_die (SF_PRIVATE *psf, int linenum) -{ int error ; - - /* Test that open for read fails if the file doesn't exist. */ - error = psf_fopen (psf) ; - if (error) - { printf ("\n\nLine %d: psf_fopen() failed : %s\n\n", linenum, strerror (errno)) ; - exit (1) ; - } ; - -} /* test_open_or_die */ - -static void -test_close_or_die (SF_PRIVATE *psf, int linenum) -{ - psf_fclose (psf) ; - if (psf_file_valid (psf)) - { printf ("\n\nLine %d: psf->file.filedes should not be valid.\n\n", linenum) ; - exit (1) ; - } ; - -} /* test_close_or_die */ - -static void -test_write_or_die (SF_PRIVATE *psf, void *data, sf_count_t bytes, sf_count_t items, sf_count_t new_position, int linenum) -{ sf_count_t retval ; - - retval = psf_fwrite (data, bytes, items, psf) ; - if (retval != items) - { printf ("\n\nLine %d: psf_write() returned %" PRId64 " (should be %" PRId64 ")\n\n", linenum, retval, items) ; - exit (1) ; - } ; - - if ((retval = psf_ftell (psf)) != new_position) - { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %" PRId64 ")\n\n", linenum, retval, new_position) ; - exit (1) ; - } ; - - return ; -} /* test_write_or_die */ - -static void -test_read_or_die (SF_PRIVATE *psf, void *data, sf_count_t bytes, sf_count_t items, sf_count_t new_position, int linenum) -{ sf_count_t retval ; - - retval = psf_fread (data, bytes, items, psf) ; - if (retval != items) - { printf ("\n\nLine %d: psf_write() returned %" PRId64 " (should be %" PRId64 ")\n\n", linenum, retval, items) ; - exit (1) ; - } ; - - if ((retval = psf_ftell (psf)) != new_position) - { printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %" PRId64 ")\n\n", linenum, retval, new_position) ; - exit (1) ; - } ; - - return ; -} /* test_write_or_die */ - -static void -test_seek_or_die (SF_PRIVATE *psf, sf_count_t offset, int whence, sf_count_t new_position, int linenum) -{ sf_count_t retval ; - - retval = psf_fseek (psf, offset, whence) ; - - if (retval != new_position) - { printf ("\n\nLine %d: psf_fseek() failed. New position is %" PRId64 " (should be %" PRId64 ").\n\n", - linenum, retval, new_position) ; - exit (1) ; - } ; - -} /* test_seek_or_die */ - -static void -test_tell_or_die (SF_PRIVATE *psf, sf_count_t expected_position, int linenum) -{ - sf_count_t retval ; - - retval = psf_ftell (psf) ; - - if (retval != expected_position) - { printf ("\n\nLine %d: psf_ftell() failed. Position reported as %" PRId64 " (should be %" PRId64 ").\n\n", - linenum, retval, expected_position) ; - exit (1) ; - } ; -} - -static void -test_equal_or_die (int *array1, int *array2, int len, int linenum) -{ int k ; - - for (k = 0 ; k < len ; k++) - if (array1 [k] != array2 [k]) - printf ("\n\nLine %d: error at index %d (%d != %d).\n\n", - linenum, k, array1 [k], array2 [k]) ; - - return ; -} /* test_equal_or_die */ - -static void -make_data (int *data, int len, int seed) -{ int k ; - - srand (seed * 3333333 + 14756123) ; - - for (k = 0 ; k < len ; k++) - data [k] = rand () ; - -} /* make_data */ - -void -test_file_io (void) -{ const char *filename = "file_io.dat" ; - - file_open_test (filename) ; - file_read_write_test (filename) ; - file_seek_with_offset_test (filename) ; - file_truncate_test (filename) ; - - unlink (filename) ; -} /* main */ - diff --git a/Engine/lib/libsndfile/src/test_float.c b/Engine/lib/libsndfile/src/test_float.c deleted file mode 100644 index 07879896e..000000000 --- a/Engine/lib/libsndfile/src/test_float.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -** Copyright (C) 2006-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#include "common.h" -#include "test_main.h" - -void -test_float_convert (void) -{ static float data [] = - { 0.0, 1.0, -1.0, 1.0 * M_PI, -1.0 * M_PI, - 1e9, -1e9, 1e-9, -1e-9, 1e-10, -1e-10, - 1e-19, -1e-19, 1e19, -1e19, 1e-20, -1e-20, - } ; - - int k ; - - print_test_name (__func__) ; - - for (k = 0 ; k < ARRAY_LEN (data) ; k++) - { unsigned char bytes [4] ; - float test ; - - float32_le_write (data [k], bytes) ; - test = float32_le_read (bytes) ; - - if (fabs (data [k] - test) > 1e-20) - { printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ; - exit (1) ; - } ; - - float32_be_write (data [k], bytes) ; - test = float32_be_read (bytes) ; - - if (fabs (data [k] - test) > 1e-20) - { printf ("\n\nLine %d : Test %d, big endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ; - exit (1) ; - } ; - - } ; - - puts ("ok") ; -} /* test_float_convert */ - -void -test_double_convert (void) -{ static double data [] = - { 0.0, 1.0, -1.0, 1.0 * M_PI, -1.0 * M_PI, - 1e9, -1e9, 1e-9, -1e-9, 1e-10, -1e-10, - 1e-19, -1e-19, 1e19, -1e19, 1e-20, -1e-20, - } ; - - int k ; - - print_test_name (__func__) ; - - for (k = 0 ; k < ARRAY_LEN (data) ; k++) - { unsigned char bytes [8] ; - double test ; - - double64_le_write (data [k], bytes) ; - test = double64_le_read (bytes) ; - - if (fabs (data [k] - test) > 1e-20) - { printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ; - exit (1) ; - } ; - - double64_be_write (data [k], bytes) ; - test = double64_be_read (bytes) ; - - if (fabs (data [k] - test) > 1e-20) - { printf ("\n\nLine %d : Test %d, big endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ; - exit (1) ; - } ; - - } ; - - puts ("ok") ; -} /* test_double_convert */ - diff --git a/Engine/lib/libsndfile/src/test_ima_oki_adpcm.c b/Engine/lib/libsndfile/src/test_ima_oki_adpcm.c deleted file mode 100644 index 6c937d117..000000000 --- a/Engine/lib/libsndfile/src/test_ima_oki_adpcm.c +++ /dev/null @@ -1,157 +0,0 @@ -/* -** Copyright (C) 2007-2011 Erik de Castro Lopo -** Copyright (c) 2007 -** -** This library is free software; you can redistribute it and/or modify it -** under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2 of the License, or (at -** your option) any later version. -** -** This library is distributed in the hope that it will be useful, but -** WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser -** General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this library. If not, write to the Free Software Foundation, -** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA. -*/ - -#include "sfconfig.h" - -#include - -#include "test_main.h" - -#include "ima_oki_adpcm.c" - -static const unsigned char test_codes [] = -{ 0x08, 0x08, 0x04, 0x7f, 0x72, 0xf7, 0x9f, 0x7c, 0xd7, 0xbc, 0x7a, 0xa7, 0xb8, - 0x4b, 0x0b, 0x38, 0xf6, 0x9d, 0x7a, 0xd7, 0xbc, 0x7a, 0xd7, 0xa8, 0x6c, 0x81, - 0x98, 0xe4, 0x0e, 0x7a, 0xd7, 0x9e, 0x7b, 0xc7, 0xab, 0x7a, 0x85, 0xc0, 0xb3, - 0x8f, 0x58, 0xd7, 0xad, 0x7a, 0xd7, 0xad, 0x7a, 0x87, 0xd0, 0x2b, 0x0e, 0x48, - 0xd7, 0xad, 0x78, 0xf7, 0xbc, 0x7a, 0xb7, 0xa8, 0x4b, 0x88, 0x18, 0xd5, 0x8d, - 0x6a, 0xa4, 0x98, 0x08, 0x00, 0x80, 0x88, -} ; - -static const short test_pcm [] = -{ 32, 0, 32, 0, 32, 320, 880, -336, 2304, 4192, -992, 10128, 5360, -16352, - 30208, 2272, -31872, 14688, -7040, -32432, 14128, -1392, -15488, 22960, - 1232, -1584, 21488, -240, 2576, -15360, 960, -1152, -30032, 10320, 1008, - -30032, 16528, 1008, -30032, 16528, -5200, -30592, 15968, 448, -30592, - 15968, 448, -2368, 30960, 3024, -80, 8384, 704, -1616, -29168, -1232, 1872, - -32768, 13792, -1728, -32768, 13792, 4480, -32192, 14368, -7360, -32752, - 13808, -1712, -21456, 16992, 1472, -1344, 26848, -1088, 2016, -17728, 208, - -2112, -32768, 1376, -1728, -32768, 13792, -1728, -32768, 13792, -1728, - -32768, 13792, -1728, -32768, 13792, -1728, -4544, 32767, -1377, 1727, - 15823, -2113, 207, -27345, 591, -2513, -32768, 13792, -1728, -32768, 13792, - 10688, -31632, 14928, -6800, -32192, 14368, -1152, -20896, 17552, 2032, - -784, 22288, 560, -2256, -4816, 2176, 64, -21120, 9920, 6816, -24224, 16128, - 608, -13488, 9584, 272, -2544, 16, -2304, -192, 1728, -16, 1568, 128, -1184, -} ; - - -static void -test_oki_adpcm (void) -{ - IMA_OKI_ADPCM adpcm ; - unsigned char code ; - int i, j ; - - print_test_name ("Testing ima/oki encoder") ; - - ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ; - for (i = 0 ; i < ARRAY_LEN (test_codes) ; i++) - for (j = 0, code = test_codes [i] ; j < 2 ; j++, code <<= 4) - if (adpcm_decode (&adpcm, code >> 4) != test_pcm [2 * i + j]) - { printf ("\n\nFail at i = %d, j = %d.\n\n", i, j) ; - exit (1) ; - } ; - - puts ("ok") ; - - print_test_name ("Testing ima/oki decoder") ; - - ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ; - for (i = 0 ; i < ARRAY_LEN (test_pcm) - 1 ; i += 2) - { code = adpcm_encode (&adpcm, test_pcm [i]) ; - code = (code << 4) | adpcm_encode (&adpcm, test_pcm [i + 1]) ; - if (code != test_codes [i / 2]) - { printf ("\n\nFail at i = %d, %d should be %d\n\n", i, code, test_codes [i / 2]) ; - exit (1) ; - } ; - } ; - - puts ("ok") ; -} /* test_oki_adpcm */ - -static void -test_oki_adpcm_block (void) -{ - IMA_OKI_ADPCM adpcm ; - int k ; - - if (ARRAY_LEN (adpcm.pcm) < ARRAY_LEN (test_pcm)) - { printf ("\n\nLine %d : ARRAY_LEN (adpcm->pcm) > ARRAY_LEN (test_pcm) (%d > %d).\n\n", __LINE__, ARRAY_LEN (adpcm.pcm), ARRAY_LEN (test_pcm)) ; - exit (1) ; - } ; - - if (ARRAY_LEN (adpcm.codes) < ARRAY_LEN (test_codes)) - { printf ("\n\nLine %d : ARRAY_LEN (adcodes->codes) > ARRAY_LEN (test_codes).n", __LINE__) ; - exit (1) ; - } ; - - print_test_name ("Testing ima/oki block encoder") ; - - ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ; - - memcpy (adpcm.pcm, test_pcm, sizeof (adpcm.pcm [0]) * ARRAY_LEN (test_pcm)) ; - adpcm.pcm_count = ARRAY_LEN (test_pcm) ; - adpcm.code_count = 13 ; - - ima_oki_adpcm_encode_block (&adpcm) ; - - if (adpcm.code_count * 2 != ARRAY_LEN (test_pcm)) - { printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.code_count * 2, ARRAY_LEN (test_pcm)) ; - exit (1) ; - } ; - - for (k = 0 ; k < ARRAY_LEN (test_codes) ; k++) - if (adpcm.codes [k] != test_codes [k]) - { printf ("\n\nLine %d : Fail at k = %d, %d should be %d\n\n", __LINE__, k, adpcm.codes [k], test_codes [k]) ; - exit (1) ; - } ; - - puts ("ok") ; - - print_test_name ("Testing ima/oki block decoder") ; - - ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ; - - memcpy (adpcm.codes, test_codes, sizeof (adpcm.codes [0]) * ARRAY_LEN (test_codes)) ; - adpcm.code_count = ARRAY_LEN (test_codes) ; - adpcm.pcm_count = 13 ; - - ima_oki_adpcm_decode_block (&adpcm) ; - - if (adpcm.pcm_count != 2 * ARRAY_LEN (test_codes)) - { printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.pcm_count, 2 * ARRAY_LEN (test_codes)) ; - exit (1) ; - } ; - - for (k = 0 ; k < ARRAY_LEN (test_pcm) ; k++) - if (adpcm.pcm [k] != test_pcm [k]) - { printf ("\n\nLine %d : Fail at i = %d, %d should be %d.\n\n", __LINE__, k, adpcm.pcm [k], test_pcm [k]) ; - exit (1) ; - } ; - - puts ("ok") ; -} /* test_oki_adpcm_block */ - -void -test_ima_oki_adpcm (void) -{ - test_oki_adpcm () ; - test_oki_adpcm_block () ; -} /* main */ - diff --git a/Engine/lib/libsndfile/src/test_log_printf.c b/Engine/lib/libsndfile/src/test_log_printf.c deleted file mode 100644 index ada623779..000000000 --- a/Engine/lib/libsndfile/src/test_log_printf.c +++ /dev/null @@ -1,125 +0,0 @@ -/* -** Copyright (C) 2003-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#include "common.h" - -#include "test_main.h" - -#define CMP_0_ARGS(line, err, fmt) \ - { psf->parselog.indx = 0 ; \ - snprintf (buffer, sizeof (buffer), (fmt)) ; \ - psf_log_printf (psf, (fmt)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ - } - -#define CMP_2_ARGS(line, err, fmt, a) \ - { psf->parselog.indx = 0 ; \ - snprintf (buffer, sizeof (buffer), (fmt), (a), (a)) ; \ - psf_log_printf (psf, (fmt), (a), (a)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ - } - -#define CMP_4_ARGS(line, err, fmt, a) \ - { psf->parselog.indx = 0 ; \ - snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a)) ; \ - psf_log_printf (psf, (fmt), (a), (a), (a), (a)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ - } - -#define CMP_5_ARGS(line, err, fmt, a) \ - { psf->parselog.indx = 0 ; \ - snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a)) ; \ - psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ - } - -#define CMP_6_ARGS(line, err, fmt, a) \ - { psf->parselog.indx = 0 ; \ - snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a), (a)) ; \ - psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a), (a)) ; \ - err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \ - } - -static int -compare_strings_or_die (int linenum, const char *fmt, const char* s1, const char* s2) -{ int errors = 0 ; -/*-puts (s1) ;puts (s2) ;-*/ - - if (strcmp (s1, s2) != 0) - { printf ("\n\nLine %d: string compare mismatch:\n\t", linenum) ; - printf ("\"%s\"\n", fmt) ; - printf ("\t\"%s\"\n\t\"%s\"\n", s1, s2) ; - errors ++ ; - } ; - - return errors ; -} /* compare_strings_or_die */ - -void -test_log_printf (void) -{ static char buffer [2048] ; - SF_PRIVATE sf_private, *psf ; - int k, errors = 0 ; - int int_values [] = { 0, 1, 12, 123, 1234, 123456, -1, -12, -123, -1234, -123456 } ; - - print_test_name ("Testing psf_log_printf") ; - - psf = &sf_private ; - memset (psf, 0, sizeof (sf_private)) ; - - CMP_0_ARGS (__LINE__, errors, " ->%%<- ") ; - - /* Test printing of ints. */ - for (k = 0 ; k < ARRAY_LEN (int_values) ; k++) - CMP_6_ARGS (__LINE__, errors, "int A : %d, % d, %4d, % 4d, %04d, % 04d", int_values [k]) ; - - for (k = 0 ; k < ARRAY_LEN (int_values) ; k++) - CMP_5_ARGS (__LINE__, errors, "int B : %+d, %+4d, %+04d, %-d, %-4d", int_values [k]) ; - - for (k = 0 ; k < ARRAY_LEN (int_values) ; k++) - CMP_2_ARGS (__LINE__, errors, "int C : %- d, %- 4d", int_values [k]) ; - - /* Test printing of unsigned ints. */ - for (k = 0 ; k < ARRAY_LEN (int_values) ; k++) - CMP_4_ARGS (__LINE__, errors, "D : %u, %4u, %04u, %0u", int_values [k]) ; - - /* Test printing of hex ints. */ - for (k = 0 ; k < ARRAY_LEN (int_values) ; k++) - CMP_4_ARGS (__LINE__, errors, "E : %X, %4X, %04X, %0X", int_values [k]) ; - - /* Test printing of strings. */ - CMP_4_ARGS (__LINE__, errors, "B %s, %3s, %8s, %-8s", "str") ; - - CMP_4_ARGS (__LINE__, errors, "B %.2s, %.8s, %-8.8s, %-4.2s", "str") ; - - if (errors) - { puts ("\nExiting due to errors.\n") ; - exit (1) ; - } ; - - puts ("ok") ; -} /* test_log_printf */ - diff --git a/Engine/lib/libsndfile/src/test_main.c b/Engine/lib/libsndfile/src/test_main.c deleted file mode 100644 index f5a501d55..000000000 --- a/Engine/lib/libsndfile/src/test_main.c +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Copyright (C) 2008-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#if defined (HAVE_SYS_TYPES_H) && (HAVE_SYS_TYPES_H == 1) -#include -#endif -#include -#include -#include - -#include "test_main.h" - -static void -test_file_offsets_are_64_bit (void) -{ - print_test_name ("File offsets are 64 bit") ; - - // The Windows specific code path uses the 64 bit file I/O APIs. - if (! USE_WINDOWS_API && sizeof (off_t) != 8) - { printf ("\n\nError : sizeof (off_t) is %zd (should be 8).\n\n", sizeof (off_t)) ; - exit (1) ; - } ; - - puts ("ok") ; -} /* test_file_offsets_are_64_bit */ - -int -main (void) -{ - test_file_offsets_are_64_bit () ; - test_conversions () ; - test_endswap () ; - test_float_convert () ; - test_double_convert () ; - - test_log_printf () ; - test_binheader_writef () ; - test_file_io () ; - - test_audio_detect () ; - test_ima_oki_adpcm () ; - - test_psf_strlcpy_crlf () ; - test_broadcast_var () ; - test_cart_var () ; - - test_nms_adpcm () ; - - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/src/test_main.h b/Engine/lib/libsndfile/src/test_main.h deleted file mode 100644 index d08fb2e09..000000000 --- a/Engine/lib/libsndfile/src/test_main.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -** Copyright (C) 2008-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -static inline void -print_test_name (const char * name) -{ printf (" %-40s : ", name) ; - fflush (stdout) ; -} /* print_test_name */ - - - -void test_conversions (void) ; -void test_endswap (void) ; -void test_log_printf (void) ; -void test_binheader_writef (void) ; -void test_file_io (void) ; - -void test_float_convert (void) ; -void test_double_convert (void) ; - -void test_audio_detect (void) ; -void test_ima_oki_adpcm (void) ; - -void test_psf_strlcpy_crlf (void) ; -void test_broadcast_var (void) ; - -void test_cart_var (void) ; - -void test_nms_adpcm (void) ; diff --git a/Engine/lib/libsndfile/src/test_nms_adpcm.c b/Engine/lib/libsndfile/src/test_nms_adpcm.c deleted file mode 100644 index 8558a046d..000000000 --- a/Engine/lib/libsndfile/src/test_nms_adpcm.c +++ /dev/null @@ -1,400 +0,0 @@ -/* -** Copyright (C) 2007-2018 Erik de Castro Lopo -** Copyright (C) 2017-2018 Arthur Taylor -** -** This library is free software; you can redistribute it and/or modify it -** under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2 of the License, or (at -** your option) any later version. -** -** This library is distributed in the hope that it will be useful, but -** WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser -** General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this library. If not, write to the Free Software Foundation, -** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA. -*/ - -#include "sfconfig.h" - -#include - -#include "test_main.h" - -#include "nms_adpcm.c" - -static const short pcm_data_src [] = -{ 505, 743, 805, 409, 101, -552, -709, -679, - -624, -1174, -1050, 32, -401, -769, -679, 47, - -3273, -4425, -2158, -176, 824, 1057, 1245, 805, - 2414, 3282, 1739, -624, -1197, -1663, -913, 603, - 549, -614, 707, 3314, 2864, 1127, -294, -919, - -1251, -147, 30, -750, -131, 1394, 2197, 1829, - 1387, 417, 391, 533, 581, 179, -210, -210, - -884, -937, -1373, -1338, -1811, -2727, -2536, -1552, - -651, -3556, -7713, -9083, -6182, 1070, 4983, 5341, - 4596, 4682, 6488, 5197, 2401, -2702, -5261, -4036, - -1995, 463, 1056, 2436, 3238, 4395, 4478, 1130, - -2383, -4349, -4547, -3631, -1396, 1029, 2589, 3948, - 4966, 4312, 2362, 492, -1289, -2259, -1659, -597, - 239, 1433, 2353, 2512, 1763, 610, -291, -640, - 7, 132, 432, 438, -1070, -1202, -1071, -1841, - -462, 225, -4465, -11313, -10492, -4522, -2096, -7013, - -11770, -2546, 7687, 12765, 12014, 5324, 1645, 1191, - 3800, -187, -6689, -7778, -4631, 2487, 7352, 7928, - 4317, 2424, 3784, 2301, -1713, -6668, -8345, -6453, - -2303, 2269, 3232, 4114, 5054, 5054, 3768, 1060, - -1793, -3302, -2059, -86, 1153, 1690, 2869, 3841, - 3551, 1919, -197, -1391, -847, 128, 746, 1111, - 431, 559, 1086, 138, -1539, -2758, -1886, 1351, - 2407, -1883, -8356, -10999, -9917, -7329, -4295, -3209, - -11616, -15352, 1032, 12603, 13233, 9059, 4019, 1858, - 3368, 7454, -56, -8600, -7278, -818, 5478, 7039, - 5630, 1186, 1634, 5422, 2518, -3182, -8271, -7889, - -4399, -129, 3205, 2933, 3661, 5886, 6543, 3798, - 374, -2722, -3378, -1804, -24, 385, 1663, 3595, - 4749, 3865, 1402, -851, -1932, -1394, -725, -219, - 290, 658, 1074, 1638, 536, 204, -340, 408, - 1835, 1261, -2872, -4840, -5978, -8177, -7644, -6554, - -8093, -6174, -7796, -17019, -12355, 1280, 12576, 11868, - 10710, 8578, 5605, 9675, 7123, -977, -8770, -6740, - -1327, 2905, 6386, 5026, 3809, 5137, 6392, 2463, - -4924, -8830, -9572, -6122, -1608, 1677, 3379, 5660, - 8236, 7225, 4470, 295, -2628, -3572, -2107, -666, - 951, 3101, 5049, 4759, 2367, -140, -2078, -2471, - -2332, -1547, -798, 410, 1825, 3329, 3092, 352, - -3310, -3307, -1229, -415, 532, 2091, 465, -1430 -} ; - -/* pcm_data encoded as 16kbs from a known reference */ -static const unsigned short test_codes_16 [] = -{ 0x5777, 0xfff0, 0xdcd0, 0x672d, 0x1826, 0xc11c, 0x0822, 0xffee, - 0x3ddc, 0x6372, 0x0116, 0xc8d8, 0x6780, 0x8624, 0x3323, 0x33ef, - 0xd865, 0x4cd8, 0x3372, 0x1096, 0x0049, 0xa911, 0x1288, 0xa74d, - 0x3fee, 0xcc45, 0x52de, 0x6a72, 0x9118, 0xe291, 0x60a2, 0x3164, - 0x73fe, 0xeddf, 0x57b5, 0x185a, 0xe889, 0x460e, 0x2646, 0x8d87, - 0xe5ba, 0x004c -} ; - -/* pcm_data encoded as 24kbs from a known reference */ -static const unsigned short test_codes_24 [] = -{ 0x7776, 0x2fec, 0xceb0, 0xffd0, 0x3241, 0x650a, 0x0a26, 0x61ba, - 0xa10b, 0x3912, 0x39a8, 0xebfa, 0x1fff, 0x8552, 0x2342, 0x0204, - 0x454b, 0xccbb, 0x4318, 0xaa00, 0x1642, 0x3031, 0xfc8f, 0x38ff, - 0xf604, 0x4924, 0x2ddb, 0x0469, 0xbcaa, 0x83b6, 0x0049, 0x8828, - 0x2266, 0x3801, 0x873d, 0xcb86, 0x0eff, 0xef64, 0xd402, 0x44fa, - 0x2867, 0xd1d0, 0xa109, 0x2a11, 0x8a64, 0x4018, 0x1357, 0xd5a5, - 0x4bfc, 0xcbfe, 0x070a, 0x6307, 0x1858, 0x624b, 0xf9a9, 0x783b, - 0x0880, 0x1652, 0xc893, 0x641c, 0xf30d, 0x004c -} ; - -/* pcm_data encoded as 32kbs from a known reference */ -static const unsigned short test_codes_32 [] = -{ 0x7772, 0x0cdc, 0xbec2, 0xacb2, 0xff90, 0x1220, 0x551c, 0xcc84, - 0x2c47, 0x30aa, 0xa10b, 0x0663, 0x2812, 0x28a9, 0xf9ba, 0xceb9, - 0x1fec, 0x9553, 0x2361, 0x9ed8, 0x8314, 0x564b, 0xddba, 0x1346, - 0x6308, 0xab00, 0x0721, 0x2908, 0x3820, 0xf89c, 0x38ff, 0xa2bf, - 0xc535, 0x2933, 0x5de9, 0x8633, 0x8569, 0xbeca, 0x1186, 0x5528, - 0xd000, 0xaa21, 0x0473, 0x2800, 0x1112, 0xa64d, 0xdc17, 0x8eeb, - 0xccac, 0xfe74, 0xc501, 0x63f9, 0x2040, 0x3a73, 0xc9b9, 0x9188, - 0x7318, 0x0a81, 0x9a65, 0x5188, 0x00ba, 0x2256, 0xd5b6, 0x4bfa, - 0xbeac, 0xe8fe, 0x343b, 0x7117, 0x9ca4, 0x915a, 0x563d, 0xcad0, - 0xa837, 0x302a, 0x1a2a, 0x3561, 0x98a9, 0xb9b5, 0x578a, 0xc48b, - 0x25f0, 0x1000 -} ; - - -/* test_codes_16 decoded by a known reference */ -const short pcm_data_out16 [] = -{ 12, 16, 24, 36, 52, -68, -104, -156, - -224, -309, -433, 12, -449, -618, -851, 32, - -871, -1176, -1586, 60, 1172, 634, 1566, 983, - 1995, 2586, 1718, -1152, -815, -2313, -1610, 1261, - 1056, -253, 522, 1799, 2506, 1518, 72, -329, - -1510, -76, 337, -1144, 68, 1369, 2200, 1337, - 1016, 60, 405, 461, 433, 389, -36, -164, - -550, -871, -1212, -1626, -2136, -2791, -2064, -1642, - -485, -1566, -2538, -3445, -4481, 650, 4381, 3799, - 5807, 4742, 6674, 5590, 2072, -2228, -5650, -4983, - -1698, 441, 1333, 3064, 2855, 3815, 5108, 2156, - -2228, -3321, -5028, -4405, -1550, 771, 3232, 3273, - 4008, 5008, 2024, 859, -654, -2746, -1694, -136, - 68, 1409, 1759, 2453, 2016, 522, -514, -445, - 0, 305, 493, 518, -232, -1076, -1116, -1321, - -506, 365, -140, -1132, -2076, -2895, -2357, -2477, - -3325, -2859, 666, 4449, 7164, 6244, 1847, 1365, - 3827, -779, -7682, -8951, -3811, 1718, 6566, 7120, - 4674, 1959, 1819, 2032, -1104, -5220, -8518, -7626, - -2385, 2714, 3510, 3871, 4831, 4024, 4156, 1590, - -1694, -3437, -2393, 96, 959, 1847, 2775, 3638, - 3072, 1734, -204, -1730, -718, -92, 453, 807, - 220, 514, 1349, -40, -1285, -2477, -1566, 1273, - 2586, 546, -2887, -5534, -6883, -7461, -5281, -2224, - -2361, -5104, -48, 9228, 12140, 9048, 3614, 1927, - 4618, 6004, -148, -9871, -5582, -489, 6835, 6746, - 6839, 2851, 3028, 4566, 1461, -2028, -6883, -7642, - -5321, -610, 3385, 3461, 3088, 3389, 4570, 4321, - -389, -2630, -3369, -1706, -136, 220, 1594, 3024, - 4622, 4232, 1265, -943, -2273, -1638, -726, -232, - 365, 538, 995, 1530, 289, 453, -68, 12, - 1184, 1562, 92, -2558, -4859, -6277, -7096, -5461, - -4811, -6020, -8851, -12594, -11501, -943, 12927, 10449, - 8935, 10389, 5662, 5755, 9108, 1827, -10224, -7807, - -148, 3429, 7722, 5212, 4734, 3847, 5570, 3433, - -3931, -8244, -8461, -5397, -1710, 1919, 3787, 4558, - 5040, 5722, 4811, -441, -3140, -4180, -2397, -493, - 1309, 3064, 4116, 5040, 2759, -730, -2445, -2847, - -2080, -1682, -1124, 706, 2032, 3325, 3248, 425, - -3586, -2987, -1397, -188, 144, 1506, 4, -2028 -} ; - -/* test_codes_24 decoded by a known reference */ -static const short pcm_data_out24 [] = -{ 16, 32, 68, 140, 116, -232, -510, -650, - -771, -1329, -1052, -152, -317, -907, -710, -104, - -1144, -2132, -2598, -301, 662, 827, 1469, 702, - 2401, 2987, 1574, -244, -1481, -1365, -903, 738, - 369, -469, 473, 1630, 3124, 1542, -582, -1172, - -1381, -317, 4, -610, -40, 1236, 1843, 1493, - 1349, 417, 389, 630, 686, 188, -228, -168, - -742, -795, -1530, -1473, -1903, -3008, -2907, -1317, - -445, -2309, -4919, -8939, -5867, 1204, 5293, 5337, - 4871, 4562, 5602, 5104, 2485, -2337, -5594, -4240, - -1694, 867, 1281, 2622, 3638, 4228, 4654, 1405, - -1947, -4112, -4184, -3582, -1570, 1325, 2538, 4036, - 5144, 4630, 2718, 518, -1373, -2397, -1642, -453, - 349, 1566, 2558, 2493, 1927, 662, -365, -610, - -136, 188, 453, 437, -385, -1281, -1196, -1534, - -369, 265, -899, -3445, -7176, -4538, -2726, -5650, - -13152, -1694, 7040, 11489, 12224, 5971, 1971, 1779, - 3457, -373, -6040, -7714, -5008, 2594, 7658, 8156, - 4461, 2333, 4369, 2867, -1919, -7180, -8465, -6409, - -2618, 2152, 3120, 4208, 5570, 5558, 4120, 690, - -2088, -3345, -1975, -208, 1180, 1738, 2144, 3289, - 3686, 1819, -417, -1534, -875, 88, 678, 967, - 437, 558, 951, 20, -1638, -2558, -1967, 558, - 2289, 465, -4449, -11080, -8931, -6248, -4208, -3337, - -6493, -14550, -5068, 12305, 13261, 9742, 4261, 1851, - 3016, 6971, 441, -9554, -7096, -975, 5188, 6658, - 5409, 1341, 855, 6164, 1726, -2381, -7991, -7212, - -4799, -433, 3236, 3273, 3253, 4445, 6706, 3329, - 582, -2602, -3028, -1614, -152, 196, 1598, 3638, - 5144, 4016, 1586, -1004, -2016, -1401, -682, -128, - 273, 614, 963, 1614, 425, 269, -449, 277, - 1746, 1240, -1510, -4598, -6397, -8008, -7602, -7152, - -7393, -6738, -8606, -15385, -13385, 1192, 12212, 11152, - 9967, 8622, 5240, 6939, 7369, -2216, -9602, -7425, - -999, 3228, 6329, 4702, 4305, 4550, 6216, 3072, - -4983, -9313, -9437, -5586, -1987, 2088, 3184, 4662, - 8244, 6598, 4606, -277, -2718, -3188, -2321, -437, - 835, 2855, 4638, 4943, 2116, -393, -2269, -2502, - -2445, -1630, -646, 469, 1927, 3188, 2943, 502, - -3148, -3100, -1144, -642, 658, 1843, 449, -1445 -} ; - -/* test_codes_32 decoded by a known reference */ -static const short pcm_data_out32 [] = -{ 20, 96, 417, 433, 140, -506, -742, -714, - -598, -1092, -1044, 56, -445, -702, -622, 76, - -1116, -4293, -2429, -433, 606, 1196, 1357, 650, - 2465, 3040, 1730, -682, -1381, -1759, -867, 518, - 614, -698, 751, 2172, 3216, 1369, -562, -1076, - -1293, -116, -12, -803, -176, 1297, 2228, 1759, - 1257, 425, 453, 614, 622, 188, -212, -220, - -975, -951, -1441, -1309, -1698, -2578, -2405, -1650, - -590, -2293, -7052, -8506, -5907, 1100, 5192, 5305, - 4244, 4425, 6779, 5313, 2152, -2654, -5598, -3803, - -2176, 301, 1080, 2281, 3361, 4485, 4690, 1269, - -2253, -4477, -4562, -3598, -1345, 1108, 2638, 3783, - 4819, 4401, 2357, 409, -1180, -2204, -1730, -662, - 168, 1566, 2550, 2333, 1879, 485, -293, -690, - -28, 176, 445, 413, -767, -1088, -1204, -1847, - -481, 261, -1321, -8714, -10646, -4265, -1979, -7100, - -11678, -1911, 7449, 13333, 11991, 5244, 1935, 1072, - 3638, -4, -6377, -7650, -4819, 2674, 7148, 8036, - 4325, 2433, 3855, 2204, -1638, -6361, -8192, -6634, - -2184, 2144, 3357, 4164, 4783, 5168, 3835, 1100, - -1670, -3224, -2140, -144, 1120, 1755, 2530, 3626, - 3678, 1771, -281, -1289, -875, 48, 755, 1112, - 449, 546, 1140, 232, -1530, -2783, -1871, 1128, - 2216, -1899, -8606, -11333, -10140, -7546, -4357, -2979, - -6044, -14851, -3726, 13136, 13477, 9534, 3871, 1489, - 3526, 7012, 80, -8188, -7140, -1120, 5783, 7060, - 5823, 1337, 1108, 5566, 2345, -3373, -8140, -7919, - -4566, 76, 3060, 2795, 3385, 5907, 6558, 3638, - 257, -2630, -3401, -1807, -116, 349, 1610, 3417, - 4750, 3967, 1489, -907, -1923, -1385, -666, -265, - 253, 682, 1084, 1586, 538, 184, -381, 433, - 1875, 1289, -1574, -4538, -6168, -8196, -7887, -6750, - -7526, -6060, -8148, -16036, -12546, 895, 12991, 12060, - 10827, 8931, 5321, 8646, 7654, -473, -8582, -6614, - -1321, 2803, 6542, 5184, 3847, 4943, 6397, 2148, - -4999, -8799, -9614, -5931, -1574, 1546, 3493, 5397, - 7879, 6919, 4610, 160, -2538, -3582, -2052, -578, - 1060, 2987, 4843, 4791, 2421, -116, -1987, -2518, - -2333, -1534, -855, 365, 1779, 3389, 3080, 477, - -3281, -3120, -1188, -265, 638, 2224, 333, -1377 -} ; - - -static void -test_nms_adpcm_32 (void) -{ - struct nms_adpcm_state nms ; - int16_t *buffer ; - unsigned char code ; - int i, j, sl ; - - buffer = (int16_t *) malloc (sizeof (int16_t) * NMS_SAMPLES_PER_BLOCK) ; - - print_test_name ("Testing nms adpcm 32kbs encoder") ; - - nms_adpcm_codec_init (&nms, NMS32) ; - for (i = 0 ; i * NMS_BLOCK_SHORTS_32 < ARRAY_LEN (test_codes_32) ; i ++) - { /* Unpack the reference */ - nms_adpcm_block_unpack_32 (&(test_codes_32 [i * NMS_BLOCK_SHORTS_32]), buffer, NULL) ; - for (j = 0 ; j < NMS_SAMPLES_PER_BLOCK ; j++) - { sl = pcm_data_src [i * NMS_SAMPLES_PER_BLOCK + j] ; - code = nms_adpcm_encode_sample (&nms, sl) ; - if (code != buffer [j]) - { printf ("\n\nFail at sample %d (block %d, sample %d). Expected 0x%x got 0x%x\n\n", - i * NMS_SAMPLES_PER_BLOCK + j, i, j, buffer [j], code) ; - exit (1) ; - } - } - } - - puts ("ok") ; - - print_test_name ("Testing nms adpcm 32kbs decoder") ; - - nms_adpcm_codec_init (&nms, NMS32) ; - for (i = 0 ; i * NMS_BLOCK_SHORTS_32 < ARRAY_LEN (test_codes_32) ; i ++) - { /* Unpack the code */ - nms_adpcm_block_unpack_32 (&(test_codes_32 [i * NMS_BLOCK_SHORTS_32]), buffer, NULL) ; - for (j = 0 ; j < NMS_SAMPLES_PER_BLOCK ; j++) - { sl = nms_adpcm_decode_sample (&nms, buffer [j]) ; - if (sl != pcm_data_out32 [i * NMS_SAMPLES_PER_BLOCK + j]) - { printf ("\n\nFail at sample %d (block %d, sample %d). Expected %d got %d\n\n", - i * NMS_SAMPLES_PER_BLOCK + j, i, j, pcm_data_out32 [i * NMS_SAMPLES_PER_BLOCK + j], sl) ; - exit (1) ; - } - } - } - - puts ("ok") ; - - free (buffer) ; -} - - -static void -test_nms_adpcm_24 (void) -{ - struct nms_adpcm_state nms ; - int16_t *buffer ; - unsigned char code ; - int i, j, sl ; - - buffer = (int16_t *) malloc (sizeof (int16_t) * NMS_SAMPLES_PER_BLOCK) ; - - - print_test_name ("Testing nms adpcm 24kbs encoder") ; - - nms_adpcm_codec_init (&nms, NMS24) ; - for (i = 0 ; i * NMS_BLOCK_SHORTS_24 < ARRAY_LEN (test_codes_24) ; i ++) - { /* Unpack the reference */ - nms_adpcm_block_unpack_24 (&test_codes_24 [i * NMS_BLOCK_SHORTS_24], buffer, NULL) ; - for (j = 0 ; j < NMS_SAMPLES_PER_BLOCK ; j++) - { sl = pcm_data_src [i * NMS_SAMPLES_PER_BLOCK + j] ; - code = nms_adpcm_encode_sample (&nms, sl) ; - if (code != buffer [j]) - { printf ("\n\nFail at sample %d (block %d, sample %d). Expected 0x%x got 0x%x\n\n", - i * NMS_SAMPLES_PER_BLOCK + j, i, j, buffer [j], code) ; - exit (1) ; - } - } - } - - puts ("ok") ; - - - print_test_name ("Testing nms adpcm 24kbs decoder") ; - - nms_adpcm_codec_init (&nms, NMS24) ; - for (i = 0 ; i * NMS_BLOCK_SHORTS_24 < ARRAY_LEN (test_codes_24) ; i ++) - { /* Unpack the code */ - nms_adpcm_block_unpack_24 (&test_codes_24 [i * NMS_BLOCK_SHORTS_24], buffer, NULL) ; - for (j = 0 ; j < NMS_SAMPLES_PER_BLOCK ; j++) - { sl = nms_adpcm_decode_sample (&nms, buffer [j]) ; - if (sl != pcm_data_out24 [i * NMS_SAMPLES_PER_BLOCK + j]) - { printf ("\n\nFail at sample %d (block %d, sample %d). Expected %d got %d\n\n", - i * NMS_SAMPLES_PER_BLOCK + j, i, j, pcm_data_out24 [i * NMS_SAMPLES_PER_BLOCK + j], sl) ; - exit (1) ; - } - } - } - - puts ("ok") ; - - free (buffer) ; -} /* test_nms_adpcm_24 */ - -static void -test_nms_adpcm_16 (void) -{ struct nms_adpcm_state nms ; - int16_t *buffer ; - unsigned char code ; - int i, j, sl ; - - buffer = (int16_t *) malloc (sizeof (int16_t) * NMS_SAMPLES_PER_BLOCK) ; - - print_test_name ("Testing nms adpcm 16kbs encoder") ; - - nms_adpcm_codec_init (&nms, NMS16) ; - for (i = 0 ; i * NMS_BLOCK_SHORTS_16 < ARRAY_LEN (test_codes_16) ; i ++) - { /* Unpack the reference */ - nms_adpcm_block_unpack_16 (&test_codes_16 [i * NMS_BLOCK_SHORTS_16], buffer, NULL) ; - for (j = 0 ; j < NMS_SAMPLES_PER_BLOCK ; j++) - { sl = pcm_data_src [i * NMS_SAMPLES_PER_BLOCK + j] ; - code = nms_adpcm_encode_sample (&nms, sl) ; - if (code != buffer [j]) - { printf ("\n\nFail at sample %d (block %d, sample %d). Expected 0x%x got 0x%x\n\n", - i * NMS_SAMPLES_PER_BLOCK + j, i, j, buffer [j], code) ; - exit (1) ; - } - } - } - - puts ("ok") ; - - print_test_name ("Testing nms adpcm 16kbs decoder") ; - - nms_adpcm_codec_init (&nms, NMS16) ; - for (i = 0 ; i * NMS_BLOCK_SHORTS_16 < ARRAY_LEN (test_codes_16) ; i ++) - { /* Unpack the code */ - nms_adpcm_block_unpack_16 (&test_codes_16 [i * NMS_BLOCK_SHORTS_16], buffer, NULL) ; - for (j = 0 ; j < NMS_SAMPLES_PER_BLOCK ; j++) - { sl = nms_adpcm_decode_sample (&nms, buffer [j]) ; - if (sl != pcm_data_out16 [i * NMS_SAMPLES_PER_BLOCK + j]) - { printf ("\n\nFail at sample %d (block %d, sample %d). Expected %d got %d\n\n", - i * NMS_SAMPLES_PER_BLOCK + j, i, j, pcm_data_out16 [i * NMS_SAMPLES_PER_BLOCK + j], sl) ; - exit (1) ; - } - } - } - - puts ("ok") ; - - free (buffer) ; -} /* test_nms_adpcm_16 */ - -void -test_nms_adpcm (void) -{ test_nms_adpcm_32 () ; - test_nms_adpcm_24 () ; - test_nms_adpcm_16 () ; -} /* main */ - diff --git a/Engine/lib/libsndfile/src/test_strncpy_crlf.c b/Engine/lib/libsndfile/src/test_strncpy_crlf.c deleted file mode 100644 index f21addc30..000000000 --- a/Engine/lib/libsndfile/src/test_strncpy_crlf.c +++ /dev/null @@ -1,59 +0,0 @@ -/* -** Copyright (C) 2010-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#include "common.h" - -#include "test_main.h" - -void -test_psf_strlcpy_crlf (void) -{ const char *src = "a\nb\nc\n" ; - char *dest ; - int dest_len ; - - print_test_name ("Testing psf_strlcpy_crlf") ; - - for (dest_len = 3 ; dest_len < 30 ; dest_len++) - { dest = calloc (1, dest_len + 1) ; - if (dest == NULL) - { printf ("\n\nLine %d: calloc failed!\n\n", __LINE__) ; - exit (1) ; - } ; - - /* This value needs to be a in the [0, 127] range to avoid tripping up - ** compiles like Sun Studio 12.* - */ - dest [dest_len] = '\x5a' ; - - psf_strlcpy_crlf (dest, src, dest_len, sizeof (*src)) ; - - if (dest [dest_len] != '\x5a') - { printf ("\n\nLine %d: buffer overrun for dest_len == %d\n\n", __LINE__, dest_len) ; - exit (1) ; - } ; - - free (dest) ; - } ; - - puts ("ok") ; -} /* test_psf_strlcpy_crlf */ diff --git a/Engine/lib/libsndfile/src/txw.c b/Engine/lib/libsndfile/src/txw.c deleted file mode 100644 index 16525dfe2..000000000 --- a/Engine/lib/libsndfile/src/txw.c +++ /dev/null @@ -1,377 +0,0 @@ -/* -** Copyright (C) 2002-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/*=========================================================================== -** Yamaha TX16 Sampler Files. -** -** This header parser was written using information from the SoX source code -** and trial and error experimentation. The code here however is all original. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#if (ENABLE_EXPERIMENTAL_CODE == 0) - -int -txw_open (SF_PRIVATE *psf) -{ if (psf) - return SFE_UNIMPLEMENTED ; - return 0 ; -} /* txw_open */ - -#else - -/*------------------------------------------------------------------------------ -** Markers. -*/ - -#define TXW_DATA_OFFSET 32 - -#define TXW_LOOPED 0x49 -#define TXW_NO_LOOP 0xC9 - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int txw_read_header (SF_PRIVATE *psf) ; - -static sf_count_t txw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t txw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t txw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t txw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t txw_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; - -/*------------------------------------------------------------------------------ -** Public functions. -*/ - -/* - * ftp://ftp.t0.or.at/pub/sound/tx16w/samples.yamaha - * ftp://ftp.t0.or.at/pub/sound/tx16w/faq/tx16w.tec - * http://www.t0.or.at/~mpakesch/tx16w/ - * - * from tx16w.c sox 12.15: (7-Oct-98) (Mark Lakata and Leigh Smith) - * char filetype[6] "LM8953" - * nulls[10], - * dummy_aeg[6] - * format 0x49 = looped, 0xC9 = non-looped - * sample_rate 1 = 33 kHz, 2 = 50 kHz, 3 = 16 kHz - * atc_length[3] if sample rate 0, [2]&0xfe = 6: 33kHz, 0x10:50, 0xf6: 16, - * depending on [5] but to heck with it - * rpt_length[3] (these are for looped samples, attack and loop lengths) - * unused[2] - */ - -typedef struct -{ unsigned char format, srate, sr2, sr3 ; - unsigned short srhash ; - unsigned int attacklen, repeatlen ; -} TXW_HEADER ; - -#define ERROR_666 666 - -int -txw_open (SF_PRIVATE *psf) -{ int error ; - - if (psf->file.mode != SFM_READ) - return SFE_UNIMPLEMENTED ; - - if ((error = txw_read_header (psf))) - return error ; - - if (psf_fseek (psf, psf->dataoffset, SEEK_SET) != psf->dataoffset) - return SFE_BAD_SEEK ; - - psf->read_short = txw_read_s ; - psf->read_int = txw_read_i ; - psf->read_float = txw_read_f ; - psf->read_double = txw_read_d ; - - psf->seek = txw_seek ; - - return 0 ; -} /* txw_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -txw_read_header (SF_PRIVATE *psf) -{ BUF_UNION ubuf ; - TXW_HEADER txwh ; - const char *strptr ; - - memset (&txwh, 0, sizeof (txwh)) ; - memset (ubuf.cbuf, 0, sizeof (ubuf.cbuf)) ; - psf_binheader_readf (psf, "pb", 0, ubuf.cbuf, 16) ; - - if (memcmp (ubuf.cbuf, "LM8953\0\0\0\0\0\0\0\0\0\0", 16) != 0) - return ERROR_666 ; - - psf_log_printf (psf, "Read only : Yamaha TX-16 Sampler (.txw)\nLM8953\n") ; - - /* Jump 6 bytes (dummp_aeg), read format, read sample rate. */ - psf_binheader_readf (psf, "j11", 6, &txwh.format, &txwh.srate) ; - - /* 8 bytes (atc_length[3], rpt_length[3], unused[2]). */ - psf_binheader_readf (psf, "e33j", &txwh.attacklen, &txwh.repeatlen, 2) ; - txwh.sr2 = (txwh.attacklen >> 16) & 0xFE ; - txwh.sr3 = (txwh.repeatlen >> 16) & 0xFE ; - txwh.attacklen &= 0x1FFFF ; - txwh.repeatlen &= 0x1FFFF ; - - switch (txwh.format) - { case TXW_LOOPED : - strptr = "looped" ; - break ; - - case TXW_NO_LOOP : - strptr = "non-looped" ; - break ; - - default : - psf_log_printf (psf, " Format : 0x%02x => ?????\n", txwh.format) ; - return ERROR_666 ; - } ; - - psf_log_printf (psf, " Format : 0x%02X => %s\n", txwh.format, strptr) ; - - strptr = NULL ; - - switch (txwh.srate) - { case 1 : - psf->sf.samplerate = 33333 ; - break ; - - case 2 : - psf->sf.samplerate = 50000 ; - break ; - - case 3 : - psf->sf.samplerate = 16667 ; - break ; - - default : - /* This is ugly and braindead. */ - txwh.srhash = ((txwh.sr2 & 0xFE) << 8) | (txwh.sr3 & 0xFE) ; - switch (txwh.srhash) - { case ((0x6 << 8) | 0x52) : - psf->sf.samplerate = 33333 ; - break ; - - case ((0x10 << 8) | 0x52) : - psf->sf.samplerate = 50000 ; - break ; - - case ((0xF6 << 8) | 0x52) : - psf->sf.samplerate = 166667 ; - break ; - - default : - strptr = " Sample Rate : Unknown : forcing to 33333\n" ; - psf->sf.samplerate = 33333 ; - break ; - } ; - } ; - - - if (strptr) - psf_log_printf (psf, strptr) ; - else if (txwh.srhash) - psf_log_printf (psf, " Sample Rate : %d (0x%X) => %d\n", txwh.srate, txwh.srhash, psf->sf.samplerate) ; - else - psf_log_printf (psf, " Sample Rate : %d => %d\n", txwh.srate, psf->sf.samplerate) ; - - if (txwh.format == TXW_LOOPED) - { psf_log_printf (psf, " Attack Len : %d\n", txwh.attacklen) ; - psf_log_printf (psf, " Repeat Len : %d\n", txwh.repeatlen) ; - } ; - - psf->dataoffset = TXW_DATA_OFFSET ; - psf->datalength = psf->filelength - TXW_DATA_OFFSET ; - psf->sf.frames = 2 * psf->datalength / 3 ; - - - if (psf->datalength % 3 == 1) - psf_log_printf (psf, "*** File seems to be truncated, %d extra bytes.\n", - (int) (psf->datalength % 3)) ; - - if (txwh.attacklen + txwh.repeatlen > psf->sf.frames) - psf_log_printf (psf, "*** File has been truncated.\n") ; - - psf->sf.format = SF_FORMAT_TXW | SF_FORMAT_PCM_16 ; - psf->sf.channels = 1 ; - psf->sf.sections = 1 ; - psf->sf.seekable = SF_TRUE ; - - return 0 ; -} /* txw_read_header */ - -static sf_count_t -txw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - unsigned char *ucptr ; - short sample ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.cbuf) / 3 ; - bufferlen -= (bufferlen & 1) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : len ; - count = psf_fread (ubuf.cbuf, 3, readcount, psf) ; - - ucptr = ubuf.ucbuf ; - for (k = 0 ; k < readcount ; k += 2) - { sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ; - ptr [total + k] = sample ; - sample = (ucptr [2] << 8) | ((ucptr [1] & 0xF) << 4) ; - ptr [total + k + 1] = sample ; - ucptr += 3 ; - } ; - - total += count ; - len -= readcount ; - } ; - - return total ; -} /* txw_read_s */ - -static sf_count_t -txw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - unsigned char *ucptr ; - short sample ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - - bufferlen = sizeof (ubuf.cbuf) / 3 ; - bufferlen -= (bufferlen & 1) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : len ; - count = psf_fread (ubuf.cbuf, 3, readcount, psf) ; - - ucptr = ubuf.ucbuf ; - for (k = 0 ; k < readcount ; k += 2) - { sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ; - ptr [total + k] = sample << 16 ; - sample = (ucptr [2] << 8) | ((ucptr [1] & 0xF) << 4) ; - ptr [total + k + 1] = sample << 16 ; - ucptr += 3 ; - } ; - - total += count ; - len -= readcount ; - } ; - - return total ; -} /* txw_read_i */ - -static sf_count_t -txw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - unsigned char *ucptr ; - short sample ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - float normfact ; - - if (psf->norm_float == SF_TRUE) - normfact = 1.0 / 0x8000 ; - else - normfact = 1.0 / 0x10 ; - - bufferlen = sizeof (ubuf.cbuf) / 3 ; - bufferlen -= (bufferlen & 1) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : len ; - count = psf_fread (ubuf.cbuf, 3, readcount, psf) ; - - ucptr = ubuf.ucbuf ; - for (k = 0 ; k < readcount ; k += 2) - { sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ; - ptr [total + k] = normfact * sample ; - sample = (ucptr [2] << 8) | ((ucptr [1] & 0xF) << 4) ; - ptr [total + k + 1] = normfact * sample ; - ucptr += 3 ; - } ; - - total += count ; - len -= readcount ; - } ; - - return total ; -} /* txw_read_f */ - -static sf_count_t -txw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - unsigned char *ucptr ; - short sample ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - double normfact ; - - if (psf->norm_double == SF_TRUE) - normfact = 1.0 / 0x8000 ; - else - normfact = 1.0 / 0x10 ; - - bufferlen = sizeof (ubuf.cbuf) / 3 ; - bufferlen -= (bufferlen & 1) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : len ; - count = psf_fread (ubuf.cbuf, 3, readcount, psf) ; - - ucptr = ubuf.ucbuf ; - for (k = 0 ; k < readcount ; k += 2) - { sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ; - ptr [total + k] = normfact * sample ; - sample = (ucptr [2] << 8) | ((ucptr [1] & 0xF) << 4) ; - ptr [total + k + 1] = normfact * sample ; - ucptr += 3 ; - } ; - - total += count ; - len -= readcount ; - } ; - - return total ; -} /* txw_read_d */ - -static sf_count_t -txw_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ if (psf && mode) - return offset ; - - return 0 ; -} /* txw_seek */ - -#endif diff --git a/Engine/lib/libsndfile/src/ulaw.c b/Engine/lib/libsndfile/src/ulaw.c deleted file mode 100644 index ed2f8ff05..000000000 --- a/Engine/lib/libsndfile/src/ulaw.c +++ /dev/null @@ -1,1056 +0,0 @@ -/* -** Copyright (C) 1999-2013 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#include "sndfile.h" -#include "common.h" - -static sf_count_t ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t ulaw_read_ulaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t ulaw_read_ulaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t ulaw_write_s2ulaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t ulaw_write_i2ulaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t ulaw_write_f2ulaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t ulaw_write_d2ulaw (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -int -ulaw_init (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) - { psf->read_short = ulaw_read_ulaw2s ; - psf->read_int = ulaw_read_ulaw2i ; - psf->read_float = ulaw_read_ulaw2f ; - psf->read_double = ulaw_read_ulaw2d ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { psf->write_short = ulaw_write_s2ulaw ; - psf->write_int = ulaw_write_i2ulaw ; - psf->write_float = ulaw_write_f2ulaw ; - psf->write_double = ulaw_write_d2ulaw ; - } ; - - psf->bytewidth = 1 ; - psf->blockwidth = psf->sf.channels ; - - if (psf->filelength > psf->dataoffset) - psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset : - psf->filelength - psf->dataoffset ; - else - psf->datalength = 0 ; - - psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ; - - return 0 ; -} /* ulaw_init */ - -/*============================================================================== -*/ - -static short ulaw_decode [256] = -{ -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956, - -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764, - -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412, - -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316, - -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140, - -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, - -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004, - -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, - -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436, - -1372, -1308, -1244, -1180, -1116, -1052, -988, -924, - -876, -844, -812, -780, -748, -716, -684, -652, - -620, -588, -556, -524, -492, -460, -428, -396, - -372, -356, -340, -324, -308, -292, -276, -260, - -244, -228, -212, -196, -180, -164, -148, -132, - -120, -112, -104, -96, -88, -80, -72, -64, - -56, -48, -40, -32, -24, -16, -8, 0, - - 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, - 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, - 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, - 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, - 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140, - 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, - 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004, - 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, - 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436, - 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, - 876, 844, 812, 780, 748, 716, 684, 652, - 620, 588, 556, 524, 492, 460, 428, 396, - 372, 356, 340, 324, 308, 292, 276, 260, - 244, 228, 212, 196, 180, 164, 148, 132, - 120, 112, 104, 96, 88, 80, 72, 64, - 56, 48, 40, 32, 24, 16, 8, 0 -} ; - -static -unsigned char ulaw_encode [8193] = -{ 0xff, 0xfe, 0xfe, 0xfd, 0xfd, 0xfc, 0xfc, 0xfb, 0xfb, 0xfa, 0xfa, 0xf9, - 0xf9, 0xf8, 0xf8, 0xf7, 0xf7, 0xf6, 0xf6, 0xf5, 0xf5, 0xf4, 0xf4, 0xf3, - 0xf3, 0xf2, 0xf2, 0xf1, 0xf1, 0xf0, 0xf0, 0xef, 0xef, 0xef, 0xef, 0xee, - 0xee, 0xee, 0xee, 0xed, 0xed, 0xed, 0xed, 0xec, 0xec, 0xec, 0xec, 0xeb, - 0xeb, 0xeb, 0xeb, 0xea, 0xea, 0xea, 0xea, 0xe9, 0xe9, 0xe9, 0xe9, 0xe8, - 0xe8, 0xe8, 0xe8, 0xe7, 0xe7, 0xe7, 0xe7, 0xe6, 0xe6, 0xe6, 0xe6, 0xe5, - 0xe5, 0xe5, 0xe5, 0xe4, 0xe4, 0xe4, 0xe4, 0xe3, 0xe3, 0xe3, 0xe3, 0xe2, - 0xe2, 0xe2, 0xe2, 0xe1, 0xe1, 0xe1, 0xe1, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, - 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xdf, 0xde, 0xde, 0xde, 0xde, 0xde, - 0xde, 0xde, 0xde, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdc, - 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, - 0xdb, 0xdb, 0xdb, 0xda, 0xda, 0xda, 0xda, 0xda, 0xda, 0xda, 0xda, 0xd9, - 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd9, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, - 0xd8, 0xd8, 0xd8, 0xd7, 0xd7, 0xd7, 0xd7, 0xd7, 0xd7, 0xd7, 0xd7, 0xd6, - 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd5, 0xd5, 0xd5, 0xd5, 0xd5, - 0xd5, 0xd5, 0xd5, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd3, - 0xd3, 0xd3, 0xd3, 0xd3, 0xd3, 0xd3, 0xd3, 0xd2, 0xd2, 0xd2, 0xd2, 0xd2, - 0xd2, 0xd2, 0xd2, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd0, - 0xd0, 0xd0, 0xd0, 0xd0, 0xd0, 0xd0, 0xd0, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, - 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xce, - 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, - 0xce, 0xce, 0xce, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, - 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcb, - 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, - 0xcb, 0xcb, 0xcb, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, - 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, - 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc8, - 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, - 0xc8, 0xc8, 0xc8, 0xc7, 0xc7, 0xc7, 0xc7, 0xc7, 0xc7, 0xc7, 0xc7, 0xc7, - 0xc7, 0xc7, 0xc7, 0xc7, 0xc7, 0xc7, 0xc7, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc5, - 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, 0xc5, - 0xc5, 0xc5, 0xc5, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, - 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, - 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc2, - 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, - 0xc2, 0xc2, 0xc2, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, - 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, - 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xbf, - 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, - 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, - 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, - 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, - 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, - 0xbe, 0xbe, 0xbe, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, - 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, - 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbc, - 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, - 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, - 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, - 0xbb, 0xbb, 0xbb, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, - 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, - 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xb9, - 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, - 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, - 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, - 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, - 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, 0xb8, - 0xb8, 0xb8, 0xb8, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, - 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, - 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb7, 0xb6, - 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, - 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, - 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, - 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, - 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, - 0xb5, 0xb5, 0xb5, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, - 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, - 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb3, - 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, - 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, - 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, - 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, - 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, - 0xb2, 0xb2, 0xb2, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, - 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, - 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb0, - 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, - 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, - 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xae, 0xae, 0xae, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xab, 0xab, 0xab, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa8, 0xa8, 0xa8, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa5, 0xa5, 0xa5, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 -} ; - -static inline void -ulaw2s_array (unsigned char *buffer, int count, short *ptr) -{ for (int i = 0 ; i < count ; i++) - ptr [i] = ulaw_decode [(int) buffer [i]] ; -} /* ulaw2s_array */ - -static inline void -ulaw2i_array (unsigned char *buffer, int count, int *ptr) -{ for (int i = 0 ; i < count ; i++) - ptr [i] = ((uint32_t) ulaw_decode [buffer [i]]) << 16 ; -} /* ulaw2i_array */ - -static inline void -ulaw2f_array (unsigned char *buffer, int count, float *ptr, float normfact) -{ for (int i = 0 ; i < count ; i++) - ptr [i] = normfact * ulaw_decode [(int) buffer [i]] ; -} /* ulaw2f_array */ - -static inline void -ulaw2d_array (const unsigned char *buffer, int count, double *ptr, double normfact) -{ for (int i = 0 ; i < count ; i++) - ptr [i] = normfact * ulaw_decode [(int) buffer [i]] ; -} /* ulaw2d_array */ - -static inline void -s2ulaw_array (const short *ptr, int count, unsigned char *buffer) -{ for (int i = 0 ; i < count ; i++) - { if (ptr [i] >= 0) - buffer [i] = ulaw_encode [ptr [i] / 4] ; - else - buffer [i] = 0x7F & ulaw_encode [ptr [i] / -4] ; - } ; -} /* s2ulaw_array */ - -static inline void -i2ulaw_array (const int *ptr, int count, unsigned char *buffer) -{ for (int i = 0 ; i < count ; i++) - { if (ptr [i] == INT_MIN) - buffer [i] = ulaw_encode [INT_MAX >> (16 + 2)] ; - else if (ptr [i] >= 0) - buffer [i] = ulaw_encode [ptr [i] >> (16 + 2)] ; - else - buffer [i] = 0x7F & ulaw_encode [-ptr [i] >> (16 + 2)] ; - } ; -} /* i2ulaw_array */ - -static inline void -f2ulaw_array (const float *ptr, int count, unsigned char *buffer, float normfact) -{ for (int i = 0 ; i < count ; i++) - { if (ptr [i] >= 0) - buffer [i] = ulaw_encode [psf_lrintf (normfact * ptr [i])] ; - else - buffer [i] = 0x7F & ulaw_encode [- psf_lrintf (normfact * ptr [i])] ; - } ; -} /* f2ulaw_array */ - -static inline void -d2ulaw_array (const double *ptr, int count, unsigned char *buffer, double normfact) -{ for (int i = 0 ; i < count ; i++) - { if (!isfinite (ptr [i])) - buffer [i] = 0 ; - else if (ptr [i] >= 0) - buffer [i] = ulaw_encode [psf_lrint (normfact * ptr [i])] ; - else - buffer [i] = 0x7F & ulaw_encode [- psf_lrint (normfact * ptr [i])] ; - } ; -} /* d2ulaw_array */ - -/*============================================================================== -*/ - -static sf_count_t -ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; - ulaw2s_array (ubuf.ucbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* ulaw_read_ulaw2s */ - -static sf_count_t -ulaw_read_ulaw2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; - ulaw2i_array (ubuf.ucbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* ulaw_read_ulaw2i */ - -static sf_count_t -ulaw_read_ulaw2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; - ulaw2f_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* ulaw_read_ulaw2f */ - -static sf_count_t -ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - normfact = (psf->norm_double) ? 1.0 / ((double) 0x8000) : 1.0 ; - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.ucbuf, 1, bufferlen, psf) ; - ulaw2d_array (ubuf.ucbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* ulaw_read_ulaw2d */ - -/*============================================================================================= -*/ - -static sf_count_t -ulaw_write_s2ulaw (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2ulaw_array (ptr + total, bufferlen, ubuf.ucbuf) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* ulaw_write_s2ulaw */ - -static sf_count_t -ulaw_write_i2ulaw (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2ulaw_array (ptr + total, bufferlen, ubuf.ucbuf) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* ulaw_write_i2ulaw */ - -static sf_count_t -ulaw_write_f2ulaw (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - float normfact ; - - /* Factor in a divide by 4. */ - normfact = (psf->norm_float == SF_TRUE) ? (0.25 * 0x7FFF) : 0.25 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - f2ulaw_array (ptr + total, bufferlen, ubuf.ucbuf, normfact) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* ulaw_write_f2ulaw */ - -static sf_count_t -ulaw_write_d2ulaw (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - double normfact ; - - /* Factor in a divide by 4. */ - normfact = (psf->norm_double) ? (0.25 * 0x7FFF) : 0.25 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - d2ulaw_array (ptr + total, bufferlen, ubuf.ucbuf, normfact) ; - writecount = (int) psf_fwrite (ubuf.ucbuf, 1, bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* ulaw_write_d2ulaw */ - diff --git a/Engine/lib/libsndfile/src/version-metadata.rc.in b/Engine/lib/libsndfile/src/version-metadata.rc.in deleted file mode 100644 index a672e4bbe..000000000 --- a/Engine/lib/libsndfile/src/version-metadata.rc.in +++ /dev/null @@ -1,31 +0,0 @@ -#include - -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS -1 VERSIONINFO - FILEVERSION @WIN_RC_VERSION@,0 - PRODUCTVERSION @WIN_RC_VERSION@,0 - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT2_UNKNOWN - FILEFLAGSMASK 0x00000000 - FILEFLAGS 0x00000000 -{ - BLOCK "StringFileInfo" - { - BLOCK "040904e4" - { - VALUE "FileDescription", "A library for reading and writing audio files." - VALUE "FileVersion", "@CLEAN_VERSION@.0\0" - VALUE "Full Version", "@PACKAGE_VERSION@" - VALUE "InternalName", "libsndfile" - VALUE "LegalCopyright", "Copyright (C) 1999-2012, Licensed LGPL" - VALUE "ProductName", "libsndfile-1 DLL" - VALUE "ProductVersion", "@CLEAN_VERSION@.0\0" - VALUE "Language", "Language Neutral" - } - } - BLOCK "VarFileInfo" - { - VALUE "Translation", 0x0409, 0x04E4 - } -} diff --git a/Engine/lib/libsndfile/src/voc.c b/Engine/lib/libsndfile/src/voc.c deleted file mode 100644 index 380d3a3f1..000000000 --- a/Engine/lib/libsndfile/src/voc.c +++ /dev/null @@ -1,883 +0,0 @@ -/* -** Copyright (C) 2001-2018 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* RANT: -** The VOC file format is the most brain damaged format I have yet had to deal -** with. No one programmer could have bee stupid enough to put this together. -** Instead it looks like a series of manic, dyslexic assembly language programmers -** hacked it to fit their needs. -** Utterly woeful. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - - -/*------------------------------------------------------------------------------ - * Typedefs for file chunks. -*/ - -#define VOC_MAX_SECTIONS 200 - -enum -{ VOC_TERMINATOR = 0, - VOC_SOUND_DATA = 1, - VOC_SOUND_CONTINUE = 2, - VOC_SILENCE = 3, - VOC_MARKER = 4, - VOC_ASCII = 5, - VOC_REPEAT = 6, - VOC_END_REPEAT = 7, - VOC_EXTENDED = 8, - VOC_EXTENDED_II = 9 -} ; - -typedef struct -{ int samples ; - int offset ; /* Offset of zero => silence. */ -} SND_DATA_BLOCKS ; - -typedef struct -{ unsigned int sections, section_types ; - int samplerate, channels, bitwidth ; - SND_DATA_BLOCKS blocks [VOC_MAX_SECTIONS] ; -} VOC_DATA ; - -/*------------------------------------------------------------------------------ - * Private static functions. -*/ - -static int voc_close (SF_PRIVATE *psf) ; -static int voc_write_header (SF_PRIVATE *psf, int calc_length) ; -static int voc_read_header (SF_PRIVATE *psf) ; - -static const char* voc_encoding2str (int encoding) ; - -#if 0 - -/* These functions would be required for files with more than one VOC_SOUND_DATA -** segment. Not sure whether to bother implementing this. -*/ - -static int voc_multi_init (SF_PRIVATE *psf, VOC_DATA *pvoc) ; - -static int voc_multi_read_uc2s (SF_PRIVATE *psf, short *ptr, int len) ; -static int voc_multi_read_les2s (SF_PRIVATE *psf, short *ptr, int len) ; - -static int voc_multi_read_uc2i (SF_PRIVATE *psf, int *ptr, int len) ; -static int voc_multi_read_les2i (SF_PRIVATE *psf, int *ptr, int len) ; - -static int voc_multi_read_uc2f (SF_PRIVATE *psf, float *ptr, int len) ; -static int voc_multi_read_les2f (SF_PRIVATE *psf, float *ptr, int len) ; - -static int voc_multi_read_uc2d (SF_PRIVATE *psf, double *ptr, int len) ; -static int voc_multi_read_les2d (SF_PRIVATE *psf, double *ptr, int len) ; -#endif - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -voc_open (SF_PRIVATE *psf) -{ int subformat, error = 0 ; - - if (psf->is_pipe) - return SFE_VOC_NO_PIPE ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = voc_read_header (psf))) - return error ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_VOC) - return SFE_BAD_OPEN_FORMAT ; - - psf->endian = SF_ENDIAN_LITTLE ; - - if ((error = voc_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = voc_write_header ; - } ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - psf->container_close = voc_close ; - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_ALAW : - error = alaw_init (psf) ; - break ; - - case SF_FORMAT_ULAW : - error = ulaw_init (psf) ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - return error ; -} /* voc_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -voc_read_header (SF_PRIVATE *psf) -{ VOC_DATA *pvoc ; - char creative [20] ; - unsigned char block_type, rate_byte ; - short version, checksum, encoding, dataoffset ; - int offset ; - - /* Set position to start of file to begin reading header. */ - offset = psf_binheader_readf (psf, "pb", 0, creative, SIGNED_SIZEOF (creative)) ; - - if (creative [sizeof (creative) - 1] != 0x1A) - return SFE_VOC_NO_CREATIVE ; - - /* Terminate the string. */ - creative [sizeof (creative) - 1] = 0 ; - - if (strcmp ("Creative Voice File", creative)) - return SFE_VOC_NO_CREATIVE ; - - psf_log_printf (psf, "%s\n", creative) ; - - offset += psf_binheader_readf (psf, "e222", &dataoffset, &version, &checksum) ; - - psf->dataoffset = dataoffset ; - - psf_log_printf (psf, "dataoffset : %d\n" - "version : 0x%X\n" - "checksum : 0x%X\n", psf->dataoffset, version, checksum) ; - - if (version != 0x010A && version != 0x0114) - return SFE_VOC_BAD_VERSION ; - - if (! (psf->codec_data = malloc (sizeof (VOC_DATA)))) - return SFE_MALLOC_FAILED ; - - pvoc = (VOC_DATA*) psf->codec_data ; - - memset (pvoc, 0, sizeof (VOC_DATA)) ; - - /* Set the default encoding now. */ - psf->sf.format = SF_FORMAT_VOC ; /* Major format */ - encoding = SF_FORMAT_PCM_U8 ; /* Minor format */ - psf->endian = SF_ENDIAN_LITTLE ; - - while (1) - { char header [256] ; - unsigned size ; - short count ; - - block_type = 0 ; - offset += psf_binheader_readf (psf, "1", &block_type) ; - - switch (block_type) - { case VOC_ASCII : - offset += psf_binheader_readf (psf, "e3", &size) ; - - psf_log_printf (psf, " ASCII : %d\n", size) ; - - if (size < sizeof (header) - 1) - { offset += psf_binheader_readf (psf, "b", header, size) ; - header [size] = 0 ; - psf_log_printf (psf, " text : %s\n", header) ; - continue ; - } - - offset += psf_binheader_readf (psf, "j", size) ; - continue ; - - case VOC_REPEAT : - offset += psf_binheader_readf (psf, "e32", &size, &count) ; - psf_log_printf (psf, " Repeat : %d\n", count) ; - continue ; - - case VOC_SOUND_DATA : - case VOC_EXTENDED : - case VOC_EXTENDED_II : - break ; - - default : psf_log_printf (psf, "*** Weird block marker (%d)\n", block_type) ; - } ; - - break ; - } ; - - if (block_type == VOC_SOUND_DATA) - { unsigned char compression ; - int size ; - - offset += psf_binheader_readf (psf, "e311", &size, &rate_byte, &compression) ; - - psf->sf.samplerate = 1000000 / (256 - (rate_byte & 0xFF)) ; - - psf_log_printf (psf, " Sound Data : %d\n sr : %d => %dHz\n comp : %d\n", - size, rate_byte, psf->sf.samplerate, compression) ; - - if (offset + size - 1 > psf->filelength) - { psf_log_printf (psf, "Seems to be a truncated file.\n") ; - psf_log_printf (psf, "offset: %d size: %d sum: %d filelength: %D\n", offset, size, offset + size, psf->filelength) ; - return SFE_VOC_BAD_SECTIONS ; - } - else if (psf->filelength - offset - size > 4) - { psf_log_printf (psf, "Seems to be a multi-segment file (#1).\n") ; - psf_log_printf (psf, "offset: %d size: %d sum: %d filelength: %D\n", offset, size, offset + size, psf->filelength) ; - return SFE_VOC_BAD_SECTIONS ; - } ; - - psf->dataoffset = offset ; - psf->dataend = psf->filelength - 1 ; - - psf->sf.channels = 1 ; - psf->bytewidth = 1 ; - - psf->sf.format = SF_FORMAT_VOC | SF_FORMAT_PCM_U8 ; - - return 0 ; - } ; - - if (block_type == VOC_EXTENDED) - { unsigned char pack, stereo, compression ; - unsigned short rate_short ; - int size ; - - offset += psf_binheader_readf (psf, "e3211", &size, &rate_short, &pack, &stereo) ; - - psf_log_printf (psf, " Extended : %d\n", size) ; - if (size == 4) - psf_log_printf (psf, " size : 4\n") ; - else - psf_log_printf (psf, " size : %d (should be 4)\n", size) ; - - psf_log_printf (psf, " pack : %d\n" - " stereo : %s\n", pack, (stereo ? "yes" : "no")) ; - - if (stereo) - { psf->sf.channels = 2 ; - psf->sf.samplerate = 128000000 / (65536 - rate_short) ; - } - else - { psf->sf.channels = 1 ; - psf->sf.samplerate = 256000000 / (65536 - rate_short) ; - } ; - - psf_log_printf (psf, " sr : %d => %dHz\n", (rate_short & 0xFFFF), psf->sf.samplerate) ; - - offset += psf_binheader_readf (psf, "1", &block_type) ; - - if (block_type != VOC_SOUND_DATA) - { psf_log_printf (psf, "*** Expecting VOC_SOUND_DATA section.\n") ; - return SFE_VOC_BAD_FORMAT ; - } ; - - offset += psf_binheader_readf (psf, "e311", &size, &rate_byte, &compression) ; - - psf_log_printf (psf, " Sound Data : %d\n" - " sr : %d\n" - " comp : %d\n", size, rate_byte, compression) ; - - - if (offset + size - 1 > psf->filelength) - { psf_log_printf (psf, "Seems to be a truncated file.\n") ; - psf_log_printf (psf, "offset: %d size: %d sum: %d filelength: %D\n", offset, size, offset + size, psf->filelength) ; - return SFE_VOC_BAD_SECTIONS ; - } - else if (offset + size - 1 < psf->filelength) - { psf_log_printf (psf, "Seems to be a multi-segment file (#2).\n") ; - psf_log_printf (psf, "offset: %d size: %d sum: %d filelength: %D\n", offset, size, offset + size, psf->filelength) ; - return SFE_VOC_BAD_SECTIONS ; - } ; - - psf->dataoffset = offset ; - psf->dataend = psf->filelength - 1 ; - - psf->bytewidth = 1 ; - - psf->sf.format = SF_FORMAT_VOC | SF_FORMAT_PCM_U8 ; - - return 0 ; - } - - if (block_type == VOC_EXTENDED_II) - { unsigned char bitwidth, channels ; - int size, fourbytes ; - - offset += psf_binheader_readf (psf, "e341124", &size, &psf->sf.samplerate, - &bitwidth, &channels, &encoding, &fourbytes) ; - - if (size * 2 == psf->filelength - 39) - { int temp_size = psf->filelength - 31 ; - - psf_log_printf (psf, " Extended II : %d (SoX bug: should be %d)\n", size, temp_size) ; - size = temp_size ; - } - else - psf_log_printf (psf, " Extended II : %d\n", size) ; - - psf_log_printf (psf, " sample rate : %d\n" - " bit width : %d\n" - " channels : %d\n", psf->sf.samplerate, bitwidth, channels) ; - - if (bitwidth == 16 && encoding == 0) - { encoding = 4 ; - psf_log_printf (psf, " encoding : 0 (SoX bug: should be 4 for 16 bit signed PCM)\n") ; - } - else - psf_log_printf (psf, " encoding : %d => %s\n", encoding, voc_encoding2str (encoding)) ; - - - psf_log_printf (psf, " fourbytes : %X\n", fourbytes) ; - - psf->sf.channels = channels ; - - psf->dataoffset = offset ; - psf->dataend = psf->filelength - 1 ; - - if (size + 31 == psf->filelength + 1) - { /* Hack for reading files produced using - ** sf_command (SFC_UPDATE_HEADER_NOW). - */ - psf_log_printf (psf, "Missing zero byte at end of file.\n") ; - size = psf->filelength - 30 ; - psf->dataend = 0 ; - } - else if (size + 31 > psf->filelength) - { psf_log_printf (psf, "Seems to be a truncated file.\n") ; - size = psf->filelength - 31 ; - } - else if (size + 31 < psf->filelength) - psf_log_printf (psf, "Seems to be a multi-segment file (#3).\n") ; - - switch (encoding) - { case 0 : - psf->sf.format = SF_FORMAT_VOC | SF_FORMAT_PCM_U8 ; - psf->bytewidth = 1 ; - break ; - - case 4 : - psf->sf.format = SF_FORMAT_VOC | SF_FORMAT_PCM_16 ; - psf->bytewidth = 2 ; - break ; - - case 6 : - psf->sf.format = SF_FORMAT_VOC | SF_FORMAT_ALAW ; - psf->bytewidth = 1 ; - break ; - - case 7 : - psf->sf.format = SF_FORMAT_VOC | SF_FORMAT_ULAW ; - psf->bytewidth = 1 ; - break ; - - default : /* Unknown */ - return SFE_VOC_BAD_FORMAT ; - break ; - } ; - - } ; - - return 0 ; -} /* voc_read_header */ - -/*==================================================================================== -*/ - -static int -voc_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t current ; - int rate_const, subformat ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - /* VOC marker and 0x1A byte. */ - psf_binheader_writef (psf, "eb1", BHWv ("Creative Voice File"), BHWz (19), BHW1 (0x1A)) ; - - /* Data offset, version and other. */ - psf_binheader_writef (psf, "e222", BHW2 (26), BHW2 (0x0114), BHW2 (0x111F)) ; - - /* Use same logic as SOX. - ** If the file is mono 8 bit data, use VOC_SOUND_DATA. - ** If the file is mono 16 bit data, use VOC_EXTENED. - ** Otherwise use VOC_EXTENED_2. - */ - - if (subformat == SF_FORMAT_PCM_U8 && psf->sf.channels == 1) - { /* samplerate = 1000000 / (256 - rate_const) ; */ - rate_const = 256 - 1000000 / psf->sf.samplerate ; - - /* First type marker, length, rate_const and compression */ - psf_binheader_writef (psf, "e1311", BHW1 (VOC_SOUND_DATA), BHW3 ((int) (psf->datalength + 1)), BHW1 (rate_const), BHW1 (0)) ; - } - else if (subformat == SF_FORMAT_PCM_U8 && psf->sf.channels == 2) - { /* sample_rate = 128000000 / (65536 - rate_short) ; */ - rate_const = 65536 - 128000000 / psf->sf.samplerate ; - - /* First write the VOC_EXTENDED section - ** marker, length, rate_const and compression - */ - psf_binheader_writef (psf, "e13211", BHW1 (VOC_EXTENDED), BHW3 (4), BHW2 (rate_const), BHW1 (0), BHW1 (1)) ; - - /* samplerate = 1000000 / (256 - rate_const) ; */ - rate_const = 256 - 1000000 / psf->sf.samplerate ; - - /* Now write the VOC_SOUND_DATA section - ** marker, length, rate_const and compression - */ - psf_binheader_writef (psf, "e1311", BHW1 (VOC_SOUND_DATA), BHW3 ((int) (psf->datalength + 1)), BHW1 (rate_const), BHW1 (0)) ; - } - else - { int length ; - - if (psf->sf.channels < 1 || psf->sf.channels > 2) - return SFE_CHANNEL_COUNT ; - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - psf->bytewidth = 1 ; - length = psf->sf.frames * psf->sf.channels * psf->bytewidth + 12 ; - /* Marker, length, sample rate, bitwidth, stereo flag, encoding and fourt zero bytes. */ - psf_binheader_writef (psf, "e1341124", BHW1 (VOC_EXTENDED_II), BHW3 (length), BHW4 (psf->sf.samplerate), BHW1 (16), BHW1 (psf->sf.channels), BHW2 (4), BHW4 (0)) ; - break ; - - case SF_FORMAT_PCM_16 : - psf->bytewidth = 2 ; - length = psf->sf.frames * psf->sf.channels * psf->bytewidth + 12 ; - /* Marker, length, sample rate, bitwidth, stereo flag, encoding and fourt zero bytes. */ - psf_binheader_writef (psf, "e1341124", BHW1 (VOC_EXTENDED_II), BHW3 (length), BHW4 (psf->sf.samplerate), BHW1 (16), BHW1 (psf->sf.channels), BHW2 (4), BHW4 (0)) ; - break ; - - case SF_FORMAT_ALAW : - psf->bytewidth = 1 ; - length = psf->sf.frames * psf->sf.channels * psf->bytewidth + 12 ; - psf_binheader_writef (psf, "e1341124", BHW1 (VOC_EXTENDED_II), BHW3 (length), BHW4 (psf->sf.samplerate), BHW1 (8), BHW1 (psf->sf.channels), BHW2 (6), BHW4 (0)) ; - break ; - - case SF_FORMAT_ULAW : - psf->bytewidth = 1 ; - length = psf->sf.frames * psf->sf.channels * psf->bytewidth + 12 ; - psf_binheader_writef (psf, "e1341124", BHW1 (VOC_EXTENDED_II), BHW3 (length), BHW4 (psf->sf.samplerate), BHW1 (8), BHW1 (psf->sf.channels), BHW2 (7), BHW4 (0)) ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - } ; - - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* voc_write_header */ - -static int -voc_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { /* Now we know for certain the length of the file we can re-write - ** correct values for the FORM, 8SVX and BODY chunks. - */ - unsigned char byte = VOC_TERMINATOR ; - - - psf_fseek (psf, 0, SEEK_END) ; - - /* Write terminator */ - psf_fwrite (&byte, 1, 1, psf) ; - - voc_write_header (psf, SF_TRUE) ; - } ; - - return 0 ; -} /* voc_close */ - -static const char* -voc_encoding2str (int encoding) -{ - switch (encoding) - { case 0 : return "8 bit unsigned PCM" ; - case 4 : return "16 bit signed PCM" ; - case 6 : return "A-law" ; - case 7 : return "u-law" ; - default : break ; - } - return "*** Unknown ***" ; -} /* voc_encoding2str */ - -/*==================================================================================== -*/ - -#if 0 -static int -voc_multi_init (SF_PRIVATE *psf, VOC_DATA *pvoc) -{ - psf->sf.frames = 0 ; - - if (pvoc->bitwidth == 8) - { psf->read_short = voc_multi_read_uc2s ; - psf->read_int = voc_multi_read_uc2i ; - psf->read_float = voc_multi_read_uc2f ; - psf->read_double = voc_multi_read_uc2d ; - return 0 ; - } ; - - if (pvoc->bitwidth == 16) - { psf->read_short = voc_multi_read_les2s ; - psf->read_int = voc_multi_read_les2i ; - psf->read_float = voc_multi_read_les2f ; - psf->read_double = voc_multi_read_les2d ; - return 0 ; - } ; - - psf_log_printf (psf, "Error : bitwith != 8 && bitwidth != 16.\n") ; - - return SFE_UNIMPLEMENTED ; -} /* voc_multi_read_int */ - -/*------------------------------------------------------------------------------------ -*/ - -static int -voc_multi_read_uc2s (SF_PRIVATE *psf, short *ptr, int len) -{ - - return 0 ; -} /* voc_multi_read_uc2s */ - -static int -voc_multi_read_les2s (SF_PRIVATE *psf, short *ptr, int len) -{ - - return 0 ; -} /* voc_multi_read_les2s */ - - -static int -voc_multi_read_uc2i (SF_PRIVATE *psf, int *ptr, int len) -{ - - return 0 ; -} /* voc_multi_read_uc2i */ - -static int -voc_multi_read_les2i (SF_PRIVATE *psf, int *ptr, int len) -{ - - return 0 ; -} /* voc_multi_read_les2i */ - - -static int -voc_multi_read_uc2f (SF_PRIVATE *psf, float *ptr, int len) -{ - - return 0 ; -} /* voc_multi_read_uc2f */ - -static int -voc_multi_read_les2f (SF_PRIVATE *psf, float *ptr, int len) -{ - - return 0 ; -} /* voc_multi_read_les2f */ - - -static int -voc_multi_read_uc2d (SF_PRIVATE *psf, double *ptr, int len) -{ - - return 0 ; -} /* voc_multi_read_uc2d */ - -static int -voc_multi_read_les2d (SF_PRIVATE *psf, double *ptr, int len) -{ - - return 0 ; -} /* voc_multi_read_les2d */ - -#endif - -/*------------------------------------------------------------------------------------ - -Creative Voice (VOC) file format --------------------------------- - -~From: galt@dsd.es.com - -(byte numbers are hex!) - - HEADER (bytes 00-19) - Series of DATA BLOCKS (bytes 1A+) [Must end w/ Terminator Block] - -- --------------------------------------------------------------- - -HEADER: -======= - byte # Description - ------ ------------------------------------------ - 00-12 "Creative Voice File" - 13 1A (eof to abort printing of file) - 14-15 Offset of first datablock in .voc file (std 1A 00 - in Intel Notation) - 16-17 Version number (minor,major) (VOC-HDR puts 0A 01) - 18-19 1's Comp of Ver. # + 1234h (VOC-HDR puts 29 11) - -- --------------------------------------------------------------- - -DATA BLOCK: -=========== - - Data Block: TYPE(1-byte), SIZE(3-bytes), INFO(0+ bytes) - NOTE: Terminator Block is an exception -- it has only the TYPE byte. - - TYPE Description Size (3-byte int) Info - ---- ----------- ----------------- ----------------------- - 00 Terminator (NONE) (NONE) - 01 Sound data 2+length of data * - 02 Sound continue length of data Voice Data - 03 Silence 3 ** - 04 Marker 2 Marker# (2 bytes) - 05 ASCII length of string null terminated string - 06 Repeat 2 Count# (2 bytes) - 07 End repeat 0 (NONE) - 08 Extended 4 *** - - *Sound Info Format: - --------------------- - 00 Sample Rate - 01 Compression Type - 02+ Voice Data - - **Silence Info Format: - ---------------------------- - 00-01 Length of silence - 1 - 02 Sample Rate - - - ***Extended Info Format: - --------------------- - 00-01 Time Constant: Mono: 65536 - (256000000/sample_rate) - Stereo: 65536 - (25600000/(2*sample_rate)) - 02 Pack - 03 Mode: 0 = mono - 1 = stereo - - - Marker# -- Driver keeps the most recent marker in a status byte - Count# -- Number of repetitions + 1 - Count# may be 1 to FFFE for 0 - FFFD repetitions - or FFFF for endless repetitions - Sample Rate -- SR byte = 256-(1000000/sample_rate) - Length of silence -- in units of sampling cycle - Compression Type -- of voice data - 8-bits = 0 - 4-bits = 1 - 2.6-bits = 2 - 2-bits = 3 - Multi DAC = 3+(# of channels) [interesting-- - this isn't in the developer's manual] - - ---------------------------------------------------------------------------------- -Addendum submitted by Votis Kokavessis: - -After some experimenting with .VOC files I found out that there is a Data Block -Type 9, which is not covered in the VOC.TXT file. Here is what I was able to discover -about this block type: - - -TYPE: 09 -SIZE: 12 + length of data -INFO: 12 (twelve) bytes - -INFO STRUCTURE: - -Bytes 0-1: (Word) Sample Rate (e.g. 44100) -Bytes 2-3: zero (could be that bytes 0-3 are a DWord for Sample Rate) -Byte 4: Sample Size in bits (e.g. 16) -Byte 5: Number of channels (e.g. 1 for mono, 2 for stereo) -Byte 6: Unknown (equal to 4 in all files I examined) -Bytes 7-11: zero - - --------------------------------------------------------------------------------------*/ - -/*===================================================================================== -**===================================================================================== -**===================================================================================== -**===================================================================================== -*/ - -/*------------------------------------------------------------------------ -The following is taken from the Audio File Formats FAQ dated 2-Jan-1995 -and submitted by Guido van Rossum . --------------------------------------------------------------------------- -Creative Voice (VOC) file format --------------------------------- - -From: galt@dsd.es.com - -(byte numbers are hex!) - - HEADER (bytes 00-19) - Series of DATA BLOCKS (bytes 1A+) [Must end w/ Terminator Block] - -- --------------------------------------------------------------- - -HEADER: -------- - byte # Description - ------ ------------------------------------------ - 00-12 "Creative Voice File" - 13 1A (eof to abort printing of file) - 14-15 Offset of first datablock in .voc file (std 1A 00 - in Intel Notation) - 16-17 Version number (minor,major) (VOC-HDR puts 0A 01) - 18-19 2's Comp of Ver. # + 1234h (VOC-HDR puts 29 11) - -- --------------------------------------------------------------- - -DATA BLOCK: ------------ - - Data Block: TYPE(1-byte), SIZE(3-bytes), INFO(0+ bytes) - NOTE: Terminator Block is an exception -- it has only the TYPE byte. - - TYPE Description Size (3-byte int) Info - ---- ----------- ----------------- ----------------------- - 00 Terminator (NONE) (NONE) - 01 Sound data 2+length of data * - 02 Sound continue length of data Voice Data - 03 Silence 3 ** - 04 Marker 2 Marker# (2 bytes) - 05 ASCII length of string null terminated string - 06 Repeat 2 Count# (2 bytes) - 07 End repeat 0 (NONE) - 08 Extended 4 *** - - *Sound Info Format: **Silence Info Format: - --------------------- ---------------------------- - 00 Sample Rate 00-01 Length of silence - 1 - 01 Compression Type 02 Sample Rate - 02+ Voice Data - - ***Extended Info Format: - --------------------- - 00-01 Time Constant: Mono: 65536 - (256000000/sample_rate) - Stereo: 65536 - (25600000/(2*sample_rate)) - 02 Pack - 03 Mode: 0 = mono - 1 = stereo - - - Marker# -- Driver keeps the most recent marker in a status byte - Count# -- Number of repetitions + 1 - Count# may be 1 to FFFE for 0 - FFFD repetitions - or FFFF for endless repetitions - Sample Rate -- SR byte = 256-(1000000/sample_rate) - Length of silence -- in units of sampling cycle - Compression Type -- of voice data - 8-bits = 0 - 4-bits = 1 - 2.6-bits = 2 - 2-bits = 3 - Multi DAC = 3+(# of channels) [interesting-- - this isn't in the developer's manual] - -Detailed description of new data blocks (VOC files version 1.20 and above): - - (Source is fax from Barry Boone at Creative Labs, 405/742-6622) - -BLOCK 8 - digitized sound attribute extension, must preceed block 1. - Used to define stereo, 8 bit audio - BYTE bBlockID; // = 8 - BYTE nBlockLen[3]; // 3 byte length - WORD wTimeConstant; // time constant = same as block 1 - BYTE bPackMethod; // same as in block 1 - BYTE bVoiceMode; // 0-mono, 1-stereo - - Data is stored left, right - -BLOCK 9 - data block that supersedes blocks 1 and 8. - Used for stereo, 16 bit. - - BYTE bBlockID; // = 9 - BYTE nBlockLen[3]; // length 12 plus length of sound - DWORD dwSamplesPerSec; // samples per second, not time const. - BYTE bBitsPerSample; // e.g., 8 or 16 - BYTE bChannels; // 1 for mono, 2 for stereo - WORD wFormat; // see below - BYTE reserved[4]; // pad to make block w/o data - // have a size of 16 bytes - - Valid values of wFormat are: - - 0x0000 8-bit unsigned PCM - 0x0001 Creative 8-bit to 4-bit ADPCM - 0x0002 Creative 8-bit to 3-bit ADPCM - 0x0003 Creative 8-bit to 2-bit ADPCM - 0x0004 16-bit signed PCM - 0x0006 CCITT a-Law - 0x0007 CCITT u-Law - 0x02000 Creative 16-bit to 4-bit ADPCM - - Data is stored left, right - -------------------------------------------------------------------------*/ diff --git a/Engine/lib/libsndfile/src/vox_adpcm.c b/Engine/lib/libsndfile/src/vox_adpcm.c deleted file mode 100644 index e206675c0..000000000 --- a/Engine/lib/libsndfile/src/vox_adpcm.c +++ /dev/null @@ -1,400 +0,0 @@ -/* -** Copyright (C) 2002-2014 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** This is the OKI / Dialogic ADPCM encoder/decoder. It converts from -** 12 bit linear sample data to a 4 bit ADPCM. -*/ - -/* - * Note: some early Dialogic hardware does not always reset the ADPCM encoder - * at the start of each vox file. This can result in clipping and/or DC offset - * problems when it comes to decoding the audio. Whilst little can be done - * about the clipping, a DC offset can be removed by passing the decoded audio - * through a high-pass filter at e.g. 10Hz. - */ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "ima_oki_adpcm.h" - - -static sf_count_t vox_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t vox_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t vox_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t vox_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t vox_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t vox_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t vox_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t vox_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static int vox_read_block (SF_PRIVATE *psf, IMA_OKI_ADPCM *pvox, short *ptr, int len) ; - -/*------------------------------------------------------------------------------ -*/ - -static int -codec_close (SF_PRIVATE * psf) -{ - IMA_OKI_ADPCM * p = (IMA_OKI_ADPCM *) psf->codec_data ; - - if (p->errors) - psf_log_printf (psf, "*** Warning : ADPCM state errors: %d\n", p->errors) ; - return p->errors ; -} /* code_close */ - -int -vox_adpcm_init (SF_PRIVATE *psf) -{ IMA_OKI_ADPCM *pvox = NULL ; - - if (psf->file.mode == SFM_RDWR) - return SFE_BAD_MODE_RW ; - - if (psf->file.mode == SFM_WRITE && psf->sf.channels != 1) - return SFE_CHANNEL_COUNT ; - - if ((pvox = malloc (sizeof (IMA_OKI_ADPCM))) == NULL) - return SFE_MALLOC_FAILED ; - - psf->codec_data = (void*) pvox ; - memset (pvox, 0, sizeof (IMA_OKI_ADPCM)) ; - - if (psf->file.mode == SFM_WRITE) - { psf->write_short = vox_write_s ; - psf->write_int = vox_write_i ; - psf->write_float = vox_write_f ; - psf->write_double = vox_write_d ; - } - else - { psf_log_printf (psf, "Header-less OKI Dialogic ADPCM encoded file.\n") ; - psf_log_printf (psf, "Setting up for 8kHz, mono, Vox ADPCM.\n") ; - - psf->read_short = vox_read_s ; - psf->read_int = vox_read_i ; - psf->read_float = vox_read_f ; - psf->read_double = vox_read_d ; - } ; - - /* Standard sample rate chennels etc. */ - if (psf->sf.samplerate < 1) - psf->sf.samplerate = 8000 ; - psf->sf.channels = 1 ; - - psf->sf.frames = psf->filelength * 2 ; - - psf->sf.seekable = SF_FALSE ; - psf->codec_close = codec_close ; - - /* Seek back to start of data. */ - if (psf_fseek (psf, 0 , SEEK_SET) == -1) - return SFE_BAD_SEEK ; - - ima_oki_adpcm_init (pvox, IMA_OKI_ADPCM_TYPE_OKI) ; - - return 0 ; -} /* vox_adpcm_init */ - -/*============================================================================== -*/ - -static int -vox_read_block (SF_PRIVATE *psf, IMA_OKI_ADPCM *pvox, short *ptr, int len) -{ int indx = 0, k ; - - while (indx < len) - { pvox->code_count = (len - indx > IMA_OKI_ADPCM_PCM_LEN) ? IMA_OKI_ADPCM_CODE_LEN : (len - indx + 1) / 2 ; - - if ((k = (int) psf_fread (pvox->codes, 1, pvox->code_count, psf)) != pvox->code_count) - { if (psf_ftell (psf) != psf->filelength) - psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pvox->code_count) ; - if (k == 0) - break ; - } ; - - pvox->code_count = k ; - - ima_oki_adpcm_decode_block (pvox) ; - - memcpy (&(ptr [indx]), pvox->pcm, pvox->pcm_count * sizeof (short)) ; - indx += pvox->pcm_count ; - } ; - - return indx ; -} /* vox_read_block */ - - -static sf_count_t -vox_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ IMA_OKI_ADPCM *pvox ; - int readcount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - - while (len > 0) - { readcount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = vox_read_block (psf, pvox, ptr, readcount) ; - - total += count ; - len -= count ; - if (count != readcount) - break ; - } ; - - return total ; -} /* vox_read_s */ - -static sf_count_t -vox_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ IMA_OKI_ADPCM *pvox ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = vox_read_block (psf, pvox, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = arith_shift_left (sptr [k], 16) ; - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* vox_read_i */ - -static sf_count_t -vox_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ IMA_OKI_ADPCM *pvox ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - float normfact ; - - if (! psf->codec_data) - return 0 ; - pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = vox_read_block (psf, pvox, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (float) (sptr [k]) ; - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* vox_read_f */ - -static sf_count_t -vox_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ IMA_OKI_ADPCM *pvox ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, readcount, count ; - sf_count_t total = 0 ; - double normfact ; - - if (! psf->codec_data) - return 0 ; - pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { readcount = (len >= bufferlen) ? bufferlen : (int) len ; - count = vox_read_block (psf, pvox, sptr, readcount) ; - for (k = 0 ; k < readcount ; k++) - ptr [total + k] = normfact * (double) (sptr [k]) ; - total += count ; - len -= readcount ; - if (count != readcount) - break ; - } ; - - return total ; -} /* vox_read_d */ - -/*------------------------------------------------------------------------------ -*/ - -static int -vox_write_block (SF_PRIVATE *psf, IMA_OKI_ADPCM *pvox, const short *ptr, int len) -{ int indx = 0, k ; - - while (indx < len) - { pvox->pcm_count = (len - indx > IMA_OKI_ADPCM_PCM_LEN) ? IMA_OKI_ADPCM_PCM_LEN : len - indx ; - - memcpy (pvox->pcm, &(ptr [indx]), pvox->pcm_count * sizeof (short)) ; - - ima_oki_adpcm_encode_block (pvox) ; - - if ((k = (int) psf_fwrite (pvox->codes, 1, pvox->code_count, psf)) != pvox->code_count) - psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pvox->code_count) ; - - indx += pvox->pcm_count ; - } ; - - return indx ; -} /* vox_write_block */ - -static sf_count_t -vox_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ IMA_OKI_ADPCM *pvox ; - int writecount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - - while (len) - { writecount = (len > 0x10000000) ? 0x10000000 : (int) len ; - - count = vox_write_block (psf, pvox, ptr, writecount) ; - - total += count ; - len -= count ; - if (count != writecount) - break ; - } ; - - return total ; -} /* vox_write_s */ - -static sf_count_t -vox_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ IMA_OKI_ADPCM *pvox ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - - if (! psf->codec_data) - return 0 ; - pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = ptr [total + k] >> 16 ; - count = vox_write_block (psf, pvox, sptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* vox_write_i */ - -static sf_count_t -vox_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ IMA_OKI_ADPCM *pvox ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - float normfact ; - - if (! psf->codec_data) - return 0 ; - pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrintf (normfact * ptr [total + k]) ; - count = vox_write_block (psf, pvox, sptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* vox_write_f */ - -static sf_count_t -vox_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ IMA_OKI_ADPCM *pvox ; - BUF_UNION ubuf ; - short *sptr ; - int k, bufferlen, writecount, count ; - sf_count_t total = 0 ; - double normfact ; - - if (! psf->codec_data) - return 0 ; - pvox = (IMA_OKI_ADPCM*) psf->codec_data ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - sptr = ubuf.sbuf ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (len > 0) - { writecount = (len >= bufferlen) ? bufferlen : (int) len ; - for (k = 0 ; k < writecount ; k++) - sptr [k] = psf_lrint (normfact * ptr [total + k]) ; - count = vox_write_block (psf, pvox, sptr, writecount) ; - total += count ; - len -= writecount ; - if (count != writecount) - break ; - } ; - - return total ; -} /* vox_write_d */ - diff --git a/Engine/lib/libsndfile/src/w64.c b/Engine/lib/libsndfile/src/w64.c deleted file mode 100644 index 14346cd26..000000000 --- a/Engine/lib/libsndfile/src/w64.c +++ /dev/null @@ -1,640 +0,0 @@ -/* -** Copyright (C) 1999-2018 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "wavlike.h" - -/*------------------------------------------------------------------------------ -** W64 files use 16 byte markers as opposed to the four byte marker of -** WAV files. -** For comparison purposes, an integer is required, so make an integer -** hash for the 16 bytes using MAKE_HASH16 macro, but also create a 16 -** byte array containing the complete 16 bytes required when writing the -** header. -*/ - -#define MAKE_HASH16(x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf) \ - ( (x0) ^ ((x1) << 1) ^ ((x2) << 2) ^ ((x3) << 3) ^ \ - ((x4) << 4) ^ ((x5) << 5) ^ ((x6) << 6) ^ ((x7) << 7) ^ \ - ((x8) << 8) ^ ((x9) << 9) ^ ((xa) << 10) ^ ((xb) << 11) ^ \ - ((xc) << 12) ^ ((xd) << 13) ^ ((xe) << 14) ^ ((xf) << 15) ) - -#define MAKE_MARKER16(name, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf) \ - static unsigned char name [16] = { (x0), (x1), (x2), (x3), (x4), (x5), \ - (x6), (x7), (x8), (x9), (xa), (xb), (xc), (xd), (xe), (xf) } - -#define riff_HASH16 MAKE_HASH16 ('r', 'i', 'f', 'f', 0x2E, 0x91, 0xCF, 0x11, \ - 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00) - -#define wave_HASH16 MAKE_HASH16 ('w', 'a', 'v', 'e', 0xF3, 0xAC, 0xD3, 0x11, \ - 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) - -#define fmt_HASH16 MAKE_HASH16 ('f', 'm', 't', ' ', 0xF3, 0xAC, 0xD3, 0x11, \ - 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) - -#define fact_HASH16 MAKE_HASH16 ('f', 'a', 'c', 't', 0xF3, 0xAC, 0xD3, 0x11, \ - 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) - -#define data_HASH16 MAKE_HASH16 ('d', 'a', 't', 'a', 0xF3, 0xAC, 0xD3, 0x11, \ - 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) - -#define ACID_HASH16 MAKE_HASH16 (0x6D, 0x07, 0x1C, 0xEA, 0xA3, 0xEF, 0x78, 0x4C, \ - 0x90, 0x57, 0x7F, 0x79, 0xEE, 0x25, 0x2A, 0xAE) - -#define levl_HASH16 MAKE_HASH16 (0x6c, 0x65, 0x76, 0x6c, 0xf3, 0xac, 0xd3, 0x11, \ - 0xd1, 0x8c, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) - -#define list_HASH16 MAKE_HASH16 (0x6C, 0x69, 0x73, 0x74, 0x2F, 0x91, 0xCF, 0x11, \ - 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00) - -#define junk_HASH16 MAKE_HASH16 (0x6A, 0x75, 0x6E, 0x6b, 0xF3, 0xAC, 0xD3, 0x11, \ - 0x8C, 0xD1, 0x00, 0xC0, 0x4f, 0x8E, 0xDB, 0x8A) - -#define bext_HASH16 MAKE_HASH16 (0x62, 0x65, 0x78, 0x74, 0xf3, 0xac, 0xd3, 0xaa, \ - 0xd1, 0x8c, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) - -#define MARKER_HASH16 MAKE_HASH16 (0x56, 0x62, 0xf7, 0xab, 0x2d, 0x39, 0xd2, 0x11, \ - 0x86, 0xc7, 0x00, 0xc0, 0x4f, 0x8e, 0xdb, 0x8a) - -#define SUMLIST_HASH16 MAKE_HASH16 (0xBC, 0x94, 0x5F, 0x92, 0x5A, 0x52, 0xD2, 0x11, \ - 0x86, 0xDC, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) - - -MAKE_MARKER16 (riff_MARKER16, 'r', 'i', 'f', 'f', 0x2E, 0x91, 0xCF, 0x11, - 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00) ; - - -MAKE_MARKER16 (wave_MARKER16, 'w', 'a', 'v', 'e', 0xF3, 0xAC, 0xD3, 0x11, - 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) ; - -MAKE_MARKER16 (fmt_MARKER16, 'f', 'm', 't', ' ', 0xF3, 0xAC, 0xD3, 0x11, - 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) ; - -MAKE_MARKER16 (fact_MARKER16, 'f', 'a', 'c', 't', 0xF3, 0xAC, 0xD3, 0x11, - 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) ; - -MAKE_MARKER16 (data_MARKER16, 'd', 'a', 't', 'a', 0xF3, 0xAC, 0xD3, 0x11, - 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A) ; - -enum -{ HAVE_riff = 0x01, - HAVE_wave = 0x02, - HAVE_fmt = 0x04, - HAVE_fact = 0x08, - HAVE_data = 0x20 -} ; - -/*------------------------------------------------------------------------------ - * Private static functions. - */ - -static int w64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) ; -static int w64_write_header (SF_PRIVATE *psf, int calc_length) ; -static int w64_close (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -w64_open (SF_PRIVATE *psf) -{ WAVLIKE_PRIVATE * wpriv ; - int subformat, error, blockalign = 0, framesperblock = 0 ; - - if ((wpriv = calloc (1, sizeof (WAVLIKE_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - psf->container_data = wpriv ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR &&psf->filelength > 0)) - { if ((error = w64_read_header (psf, &blockalign, &framesperblock))) - return error ; - } ; - - if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_W64) - return SFE_BAD_OPEN_FORMAT ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (psf->is_pipe) - return SFE_NO_PIPE_WRITE ; - - psf->endian = SF_ENDIAN_LITTLE ; /* All W64 files are little endian. */ - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - if (subformat == SF_FORMAT_IMA_ADPCM || subformat == SF_FORMAT_MS_ADPCM) - { blockalign = wavlike_srate2blocksize (psf->sf.samplerate * psf->sf.channels) ; - framesperblock = -1 ; - - /* - ** At this point we don't know the file length so set it stupidly high, but not - ** so high that it triggers undefined behaviour whan something is added to it. - */ - psf->filelength = SF_COUNT_MAX - 10000 ; - psf->datalength = psf->filelength ; - if (psf->sf.frames <= 0) - psf->sf.frames = (psf->blockwidth) ? psf->filelength / psf->blockwidth : psf->filelength ; - } ; - - if ((error = w64_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = w64_write_header ; - } ; - - psf->container_close = w64_close ; - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_ULAW : - error = ulaw_init (psf) ; - break ; - - case SF_FORMAT_ALAW : - error = alaw_init (psf) ; - break ; - - /* Lite remove start */ - case SF_FORMAT_FLOAT : - error = float32_init (psf) ; - break ; - - case SF_FORMAT_DOUBLE : - error = double64_init (psf) ; - break ; - - case SF_FORMAT_IMA_ADPCM : - error = wavlike_ima_init (psf, blockalign, framesperblock) ; - break ; - - case SF_FORMAT_MS_ADPCM : - error = wavlike_msadpcm_init (psf, blockalign, framesperblock) ; - break ; - /* Lite remove end */ - - case SF_FORMAT_GSM610 : - error = gsm610_init (psf) ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - return error ; -} /* w64_open */ - -/*========================================================================= -** Private functions. -*/ - -static int -w64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) -{ WAVLIKE_PRIVATE *wpriv ; - WAV_FMT *wav_fmt ; - int dword = 0, marker, format = 0 ; - sf_count_t chunk_size, bytesread = 0 ; - int parsestage = 0, error, done = 0 ; - - if ((wpriv = psf->container_data) == NULL) - return SFE_INTERNAL ; - wav_fmt = &wpriv->wav_fmt ; - - /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "p", 0) ; - - while (! done) - { /* Each new chunk must start on an 8 byte boundary, so jump if needed. */ - if (psf->header.indx & 0x7) - psf_binheader_readf (psf, "j", 8 - (psf->header.indx & 0x7)) ; - - /* Generate hash of 16 byte marker. */ - marker = 0 ; - chunk_size = 0 ; - - bytesread = psf_binheader_readf (psf, "eh8", &marker, &chunk_size) ; - if (bytesread == 0) - break ; - switch (marker) - { case riff_HASH16 : - if (parsestage) - return SFE_W64_NO_RIFF ; - - if (psf->filelength != chunk_size) - psf_log_printf (psf, "riff : %D (should be %D)\n", chunk_size, psf->filelength) ; - else - psf_log_printf (psf, "riff : %D\n", chunk_size) ; - - parsestage |= HAVE_riff ; - - bytesread += psf_binheader_readf (psf, "h", &marker) ; - if (marker == wave_HASH16) - { if ((parsestage & HAVE_riff) != HAVE_riff) - return SFE_W64_NO_WAVE ; - psf_log_printf (psf, "wave\n") ; - parsestage |= HAVE_wave ; - } ; - chunk_size = 0 ; - break ; - - case ACID_HASH16: - psf_log_printf (psf, "Looks like an ACID file. Exiting.\n") ; - return SFE_UNIMPLEMENTED ; - - case fmt_HASH16 : - if ((parsestage & (HAVE_riff | HAVE_wave)) != (HAVE_riff | HAVE_wave)) - return SFE_WAV_NO_FMT ; - - psf_log_printf (psf, " fmt : %D\n", chunk_size) ; - - /* size of 16 byte marker and 8 byte chunk_size value. */ - chunk_size -= 24 ; - - if ((error = wavlike_read_fmt_chunk (psf, (int) chunk_size))) - return error ; - - if (chunk_size % 8) - psf_binheader_readf (psf, "j", 8 - (chunk_size % 8)) ; - - format = wav_fmt->format ; - parsestage |= HAVE_fmt ; - chunk_size = 0 ; - break ; - - case fact_HASH16: - { sf_count_t frames ; - - psf_binheader_readf (psf, "e8", &frames) ; - psf_log_printf (psf, "fact : %D\n frames : %D\n", - chunk_size, frames) ; - } ; - chunk_size = 0 ; - break ; - - - case data_HASH16 : - if ((parsestage & (HAVE_riff | HAVE_wave | HAVE_fmt)) != (HAVE_riff | HAVE_wave | HAVE_fmt)) - return SFE_W64_NO_DATA ; - - psf->dataoffset = psf_ftell (psf) ; - psf->datalength = SF_MIN (chunk_size - 24, psf->filelength - psf->dataoffset) ; - - if (chunk_size % 8) - chunk_size += 8 - (chunk_size % 8) ; - - psf_log_printf (psf, "data : %D\n", chunk_size) ; - - parsestage |= HAVE_data ; - - if (! psf->sf.seekable) - break ; - - /* Seek past data and continue reading header. */ - psf_fseek (psf, chunk_size, SEEK_CUR) ; - chunk_size = 0 ; - break ; - - case levl_HASH16 : - psf_log_printf (psf, "levl : %D\n", chunk_size) ; - break ; - - case list_HASH16 : - psf_log_printf (psf, "list : %D\n", chunk_size) ; - break ; - - case junk_HASH16 : - psf_log_printf (psf, "junk : %D\n", chunk_size) ; - break ; - - case bext_HASH16 : - psf_log_printf (psf, "bext : %D\n", chunk_size) ; - break ; - - case MARKER_HASH16 : - psf_log_printf (psf, "marker : %D\n", chunk_size) ; - break ; - - case SUMLIST_HASH16 : - psf_log_printf (psf, "summary list : %D\n", chunk_size) ; - break ; - - default : - psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D with length %D. Skipping and continuing.\n", marker, psf_ftell (psf) - 8, chunk_size) ; - break ; - } ; /* switch (dword) */ - - if (chunk_size >= psf->filelength) - { psf_log_printf (psf, "*** Chunk size %u > file length %D. Exiting parser.\n", chunk_size, psf->filelength) ; - break ; - } ; - - if (psf->sf.seekable == 0 && (parsestage & HAVE_data)) - break ; - - if (psf_ftell (psf) >= (psf->filelength - (2 * SIGNED_SIZEOF (dword)))) - break ; - - if (chunk_size > 0 && chunk_size < 0xffff0000) - { dword = chunk_size ; - psf_binheader_readf (psf, "j", dword - 24) ; - } ; - } ; /* while (1) */ - - if (psf->dataoffset <= 0) - return SFE_W64_NO_DATA ; - - if (psf->sf.channels < 1) - return SFE_CHANNEL_COUNT_ZERO ; - - if (psf->sf.channels > SF_MAX_CHANNELS) - return SFE_CHANNEL_COUNT ; - - psf->endian = SF_ENDIAN_LITTLE ; /* All W64 files are little endian. */ - - if (psf_ftell (psf) != psf->dataoffset) - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - if (psf->blockwidth) - { if (psf->filelength - psf->dataoffset < psf->datalength) - psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - else - psf->sf.frames = psf->datalength / psf->blockwidth ; - } ; - - switch (format) - { case WAVE_FORMAT_PCM : - case WAVE_FORMAT_EXTENSIBLE : - /* extensible might be FLOAT, MULAW, etc as well! */ - psf->sf.format = SF_FORMAT_W64 | u_bitwidth_to_subformat (psf->bytewidth * 8) ; - break ; - - case WAVE_FORMAT_MULAW : - psf->sf.format = (SF_FORMAT_W64 | SF_FORMAT_ULAW) ; - break ; - - case WAVE_FORMAT_ALAW : - psf->sf.format = (SF_FORMAT_W64 | SF_FORMAT_ALAW) ; - break ; - - case WAVE_FORMAT_MS_ADPCM : - psf->sf.format = (SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM) ; - *blockalign = wav_fmt->msadpcm.blockalign ; - *framesperblock = wav_fmt->msadpcm.samplesperblock ; - break ; - - case WAVE_FORMAT_IMA_ADPCM : - psf->sf.format = (SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM) ; - *blockalign = wav_fmt->ima.blockalign ; - *framesperblock = wav_fmt->ima.samplesperblock ; - break ; - - case WAVE_FORMAT_GSM610 : - psf->sf.format = (SF_FORMAT_W64 | SF_FORMAT_GSM610) ; - break ; - - case WAVE_FORMAT_IEEE_FLOAT : - psf->sf.format = SF_FORMAT_W64 ; - psf->sf.format |= (psf->bytewidth == 8) ? SF_FORMAT_DOUBLE : SF_FORMAT_FLOAT ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - return 0 ; -} /* w64_read_header */ - -static int -w64_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t fmt_size, current ; - size_t fmt_pad = 0 ; - int subformat, add_fact_chunk = SF_FALSE ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - if (psf->bytewidth) - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - /* riff marker, length, wave and 'fmt ' markers. */ - psf_binheader_writef (psf, "eh8hh", BHWh (riff_MARKER16), BHW8 (psf->filelength), BHWh (wave_MARKER16), BHWh (fmt_MARKER16)) ; - - subformat = SF_CODEC (psf->sf.format) ; - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - fmt_size = 24 + 2 + 2 + 4 + 4 + 2 + 2 ; - fmt_pad = (size_t) ((fmt_size & 0x7) ? 8 - (fmt_size & 0x7) : 0) ; - fmt_size += fmt_pad ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "e8224", BHW8 (fmt_size), BHW2 (WAVE_FORMAT_PCM), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "e4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "e22", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (psf->bytewidth * 8)) ; - break ; - - case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - fmt_size = 24 + 2 + 2 + 4 + 4 + 2 + 2 ; - fmt_pad = (size_t) ((fmt_size & 0x7) ? 8 - (fmt_size & 0x7) : 0) ; - fmt_size += fmt_pad ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "e8224", BHW8 (fmt_size), BHW2 (WAVE_FORMAT_IEEE_FLOAT), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "e4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "e22", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (psf->bytewidth * 8)) ; - - add_fact_chunk = SF_TRUE ; - break ; - - case SF_FORMAT_ULAW : - fmt_size = 24 + 2 + 2 + 4 + 4 + 2 + 2 ; - fmt_pad = (size_t) ((fmt_size & 0x7) ? 8 - (fmt_size & 0x7) : 0) ; - fmt_size += fmt_pad ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "e8224", BHW8 (fmt_size), BHW2 (WAVE_FORMAT_MULAW), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "e4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "e22", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (8)) ; - - add_fact_chunk = SF_TRUE ; - break ; - - case SF_FORMAT_ALAW : - fmt_size = 24 + 2 + 2 + 4 + 4 + 2 + 2 ; - fmt_pad = (size_t) ((fmt_size & 0x7) ? 8 - (fmt_size & 0x7) : 0) ; - fmt_size += fmt_pad ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "e8224", BHW8 (fmt_size), BHW2 (WAVE_FORMAT_ALAW), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "e4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "e22", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (8)) ; - - add_fact_chunk = SF_TRUE ; - break ; - - /* Lite remove start */ - case SF_FORMAT_IMA_ADPCM : - { int blockalign, framesperblock, bytespersec ; - - blockalign = wavlike_srate2blocksize (psf->sf.samplerate * psf->sf.channels) ; - framesperblock = 2 * (blockalign - 4 * psf->sf.channels) / psf->sf.channels + 1 ; - bytespersec = (psf->sf.samplerate * blockalign) / framesperblock ; - - /* fmt chunk. */ - fmt_size = 24 + 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 ; - fmt_pad = (size_t) ((fmt_size & 0x7) ? 8 - (fmt_size & 0x7) : 0) ; - fmt_size += fmt_pad ; - - /* fmt : size, WAV format type, channels. */ - psf_binheader_writef (psf, "e822", BHW8 (fmt_size), BHW2 (WAVE_FORMAT_IMA_ADPCM), BHW2 (psf->sf.channels)) ; - - /* fmt : samplerate, bytespersec. */ - psf_binheader_writef (psf, "e44", BHW4 (psf->sf.samplerate), BHW4 (bytespersec)) ; - - /* fmt : blockalign, bitwidth, extrabytes, framesperblock. */ - psf_binheader_writef (psf, "e2222", BHW2 (blockalign), BHW2 (4), BHW2 (2), BHW2 (framesperblock)) ; - } ; - - add_fact_chunk = SF_TRUE ; - break ; - - case SF_FORMAT_MS_ADPCM : - { int blockalign, framesperblock, bytespersec, extrabytes ; - - blockalign = wavlike_srate2blocksize (psf->sf.samplerate * psf->sf.channels) ; - framesperblock = 2 + 2 * (blockalign - 7 * psf->sf.channels) / psf->sf.channels ; - bytespersec = (psf->sf.samplerate * blockalign) / framesperblock ; - - /* fmt chunk. */ - extrabytes = 2 + 2 + WAVLIKE_MSADPCM_ADAPT_COEFF_COUNT * (2 + 2) ; - fmt_size = 24 + 2 + 2 + 4 + 4 + 2 + 2 + 2 + extrabytes ; - fmt_pad = (size_t) ((fmt_size & 0x7) ? 8 - (fmt_size & 0x7) : 0) ; - fmt_size += fmt_pad ; - - /* fmt : size, W64 format type, channels. */ - psf_binheader_writef (psf, "e822", BHW8 (fmt_size), BHW2 (WAVE_FORMAT_MS_ADPCM), BHW2 (psf->sf.channels)) ; - - /* fmt : samplerate, bytespersec. */ - psf_binheader_writef (psf, "e44", BHW4 (psf->sf.samplerate), BHW4 (bytespersec)) ; - - /* fmt : blockalign, bitwidth, extrabytes, framesperblock. */ - psf_binheader_writef (psf, "e22222", BHW2 (blockalign), BHW2 (4), BHW2 (extrabytes), BHW2 (framesperblock), BHW2 (7)) ; - - wavlike_msadpcm_write_adapt_coeffs (psf) ; - } ; - - add_fact_chunk = SF_TRUE ; - break ; - /* Lite remove end */ - - case SF_FORMAT_GSM610 : - { int bytespersec ; - - bytespersec = (psf->sf.samplerate * WAVLIKE_GSM610_BLOCKSIZE) / WAVLIKE_GSM610_SAMPLES ; - - /* fmt chunk. */ - fmt_size = 24 + 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 ; - fmt_pad = (size_t) ((fmt_size & 0x7) ? 8 - (fmt_size & 0x7) : 0) ; - fmt_size += fmt_pad ; - - /* fmt : size, WAV format type, channels. */ - psf_binheader_writef (psf, "e822", BHW8 (fmt_size), BHW2 (WAVE_FORMAT_GSM610), BHW2 (psf->sf.channels)) ; - - /* fmt : samplerate, bytespersec. */ - psf_binheader_writef (psf, "e44", BHW4 (psf->sf.samplerate), BHW4 (bytespersec)) ; - - /* fmt : blockalign, bitwidth, extrabytes, framesperblock. */ - psf_binheader_writef (psf, "e2222", BHW2 (WAVLIKE_GSM610_BLOCKSIZE), BHW2 (0), BHW2 (2), BHW2 (WAVLIKE_GSM610_SAMPLES)) ; - } ; - - add_fact_chunk = SF_TRUE ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - /* Pad to 8 bytes with zeros. */ - if (fmt_pad > 0) - psf_binheader_writef (psf, "z", BHWz (fmt_pad)) ; - - if (add_fact_chunk) - psf_binheader_writef (psf, "eh88", BHWh (fact_MARKER16), BHW8 ((sf_count_t) (16 + 8 + 8)), BHW8 (psf->sf.frames)) ; - - psf_binheader_writef (psf, "eh8", BHWh (data_MARKER16), BHW8 (psf->datalength + 24)) ; - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* w64_write_header */ - -static int -w64_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - w64_write_header (psf, SF_TRUE) ; - - return 0 ; -} /* w64_close */ - diff --git a/Engine/lib/libsndfile/src/wav.c b/Engine/lib/libsndfile/src/wav.c deleted file mode 100644 index b87068695..000000000 --- a/Engine/lib/libsndfile/src/wav.c +++ /dev/null @@ -1,1653 +0,0 @@ -/* -** Copyright (C) 1999-2019 Erik de Castro Lopo -** Copyright (C) 2004-2005 David Viens -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "wavlike.h" - -/*------------------------------------------------------------------------------ - * Macros to handle big/little endian issues. - */ - -#define RIFF_MARKER (MAKE_MARKER ('R', 'I', 'F', 'F')) -#define RIFX_MARKER (MAKE_MARKER ('R', 'I', 'F', 'X')) -#define WAVE_MARKER (MAKE_MARKER ('W', 'A', 'V', 'E')) -#define fmt_MARKER (MAKE_MARKER ('f', 'm', 't', ' ')) -#define fact_MARKER (MAKE_MARKER ('f', 'a', 'c', 't')) - -#define cue_MARKER (MAKE_MARKER ('c', 'u', 'e', ' ')) -#define slnt_MARKER (MAKE_MARKER ('s', 'l', 'n', 't')) -#define wavl_MARKER (MAKE_MARKER ('w', 'a', 'v', 'l')) -#define plst_MARKER (MAKE_MARKER ('p', 'l', 's', 't')) -#define smpl_MARKER (MAKE_MARKER ('s', 'm', 'p', 'l')) -#define iXML_MARKER (MAKE_MARKER ('i', 'X', 'M', 'L')) -#define levl_MARKER (MAKE_MARKER ('l', 'e', 'v', 'l')) -#define MEXT_MARKER (MAKE_MARKER ('M', 'E', 'X', 'T')) -#define acid_MARKER (MAKE_MARKER ('a', 'c', 'i', 'd')) -#define strc_MARKER (MAKE_MARKER ('s', 't', 'r', 'c')) -#define afsp_MARKER (MAKE_MARKER ('a', 'f', 's', 'p')) -#define clm_MARKER (MAKE_MARKER ('c', 'l', 'm', ' ')) -#define elmo_MARKER (MAKE_MARKER ('e', 'l', 'm', 'o')) -#define FLLR_MARKER (MAKE_MARKER ('F', 'L', 'L', 'R')) - -#define minf_MARKER (MAKE_MARKER ('m', 'i', 'n', 'f')) -#define elm1_MARKER (MAKE_MARKER ('e', 'l', 'm', '1')) -#define regn_MARKER (MAKE_MARKER ('r', 'e', 'g', 'n')) -#define ovwf_MARKER (MAKE_MARKER ('o', 'v', 'w', 'f')) -#define umid_MARKER (MAKE_MARKER ('u', 'm', 'i', 'd')) -#define SyLp_MARKER (MAKE_MARKER ('S', 'y', 'L', 'p')) -#define Cr8r_MARKER (MAKE_MARKER ('C', 'r', '8', 'r')) -#define JUNK_MARKER (MAKE_MARKER ('J', 'U', 'N', 'K')) -#define PMX_MARKER (MAKE_MARKER ('_', 'P', 'M', 'X')) -#define inst_MARKER (MAKE_MARKER ('i', 'n', 's', 't')) -#define AFAn_MARKER (MAKE_MARKER ('A', 'F', 'A', 'n')) - - -/* Weird WAVPACK marker which can show up at the start of the DATA section. */ -#define wvpk_MARKER (MAKE_MARKER ('w', 'v', 'p', 'k')) -#define OggS_MARKER (MAKE_MARKER ('O', 'g', 'g', 'S')) - -/* ID3v1 trailer which can show up at the end and erronerously look like a chunk. */ -#define TAG__MARKER (MAKE_MARKER ('T', 'A', 'G', 0)) -#define TAG__MARKER_MASK (MAKE_MARKER (0xff, 0xff, 0xff, 0)) - -#define WAVLIKE_PEAK_CHUNK_SIZE(ch) (2 * sizeof (int) + ch * (sizeof (float) + sizeof (int))) - - -enum -{ HAVE_RIFF = 1 << 0, - HAVE_WAVE = 1 << 1, - HAVE_fmt = 1 << 2, - HAVE_fact = 1 << 3, - HAVE_PEAK = 1 << 4, - HAVE_data = 1 << 5, - HAVE_other = 1 << 6 -} ; - - -/* known WAVEFORMATEXTENSIBLE GUIDS */ -static const EXT_SUBFORMAT MSGUID_SUBTYPE_PCM = -{ 0x00000001, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -#if 0 -static const EXT_SUBFORMAT MSGUID_SUBTYPE_MS_ADPCM = -{ 0x00000002, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; -#endif - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_IEEE_FLOAT = -{ 0x00000003, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_ALAW = -{ 0x00000006, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_MULAW = -{ 0x00000007, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -/* -** the next two are from -** http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html -*/ -static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM = -{ 0x00000001, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT = -{ 0x00000003, 0x0721, 0x11d3, { 0x86, 0x44, 0xC8, 0xC1, 0xCA, 0x00, 0x00, 0x00 } -} ; - - -#if 0 -/* maybe interesting one day to read the following through sf_read_raw */ -/* http://www.bath.ac.uk/~masrwd/pvocex/pvocex.html */ -static const EXT_SUBFORMAT MSGUID_SUBTYPE_PVOCEX = -{ 0x8312B9C2, 0x2E6E, 0x11d4, { 0xA8, 0x24, 0xDE, 0x5B, 0x96, 0xC3, 0xAB, 0x21 } -} ; -#endif - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) ; -static int wav_write_header (SF_PRIVATE *psf, int calc_length) ; - -static int wav_write_tailer (SF_PRIVATE *psf) ; -static int wav_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; -static int wav_close (SF_PRIVATE *psf) ; - -static int wav_read_smpl_chunk (SF_PRIVATE *psf, uint32_t chunklen) ; -static int wav_read_acid_chunk (SF_PRIVATE *psf, uint32_t chunklen) ; - -static int wav_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) ; -static SF_CHUNK_ITERATOR * wav_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) ; -static int wav_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; -static int wav_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -wav_open (SF_PRIVATE *psf) -{ WAVLIKE_PRIVATE * wpriv ; - int format, subformat, error, blockalign = 0, framesperblock = 0 ; - - if ((wpriv = calloc (1, sizeof (WAVLIKE_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - psf->container_data = wpriv ; - - wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ; - psf->strings.flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = wav_read_header (psf, &blockalign, &framesperblock))) - return error ; - - psf->next_chunk_iterator = wav_next_chunk_iterator ; - psf->get_chunk_size = wav_get_chunk_size ; - psf->get_chunk_data = wav_get_chunk_data ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if (psf->is_pipe) - return SFE_NO_PIPE_WRITE ; - - wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ; - - format = SF_CONTAINER (psf->sf.format) ; - if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX) - return SFE_BAD_OPEN_FORMAT ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - /* RIFF WAVs are little-endian, RIFX WAVs are big-endian, default to little */ - psf->endian = SF_ENDIAN (psf->sf.format) ; - if (CPU_IS_BIG_ENDIAN && psf->endian == SF_ENDIAN_CPU) - psf->endian = SF_ENDIAN_BIG ; - else if (psf->endian != SF_ENDIAN_BIG) - psf->endian = SF_ENDIAN_LITTLE ; - - if (psf->file.mode != SFM_RDWR || psf->filelength < 44) - { psf->filelength = 0 ; - psf->datalength = 0 ; - psf->dataoffset = 0 ; - psf->sf.frames = 0 ; - } ; - -#if (ENABLE_EXPERIMENTAL_CODE == 0) - /* For now, don't support writing MPEGLAYER3 WAVs, as we can't guarentee that - ** such a file written by libsndfile would have the same length when opened again. - */ - if (subformat == SF_FORMAT_MPEG_LAYER_III) - return SFE_UNSUPPORTED_ENCODING ; -#endif - - if (subformat == SF_FORMAT_IMA_ADPCM || subformat == SF_FORMAT_MS_ADPCM) - { blockalign = wavlike_srate2blocksize (psf->sf.samplerate * psf->sf.channels) ; - framesperblock = -1 ; /* Corrected later. */ - } ; - - /* By default, add the peak chunk to floating point files. Default behaviour - ** can be switched off using sf_command (SFC_SET_PEAK_CHUNK, SF_FALSE). - */ - if (psf->file.mode == SFM_WRITE && (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)) - { if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL) - return SFE_MALLOC_FAILED ; - psf->peak_info->peak_loc = SF_PEAK_START ; - } ; - - psf->write_header = wav_write_header ; - psf->set_chunk = wav_set_chunk ; - } ; - - psf->container_close = wav_close ; - psf->command = wav_command ; - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - error = pcm_init (psf) ; - break ; - - case SF_FORMAT_ULAW : - error = ulaw_init (psf) ; - break ; - - case SF_FORMAT_ALAW : - error = alaw_init (psf) ; - break ; - - /* Lite remove start */ - case SF_FORMAT_FLOAT : - error = float32_init (psf) ; - break ; - - case SF_FORMAT_DOUBLE : - error = double64_init (psf) ; - break ; - - case SF_FORMAT_IMA_ADPCM : - error = wavlike_ima_init (psf, blockalign, framesperblock) ; - break ; - - case SF_FORMAT_MS_ADPCM : - error = wavlike_msadpcm_init (psf, blockalign, framesperblock) ; - break ; - - case SF_FORMAT_G721_32 : - error = g72x_init (psf) ; - break ; - - case SF_FORMAT_NMS_ADPCM_16 : - case SF_FORMAT_NMS_ADPCM_24 : - case SF_FORMAT_NMS_ADPCM_32 : - error = nms_adpcm_init (psf) ; - break ; - - /* Lite remove end */ - - case SF_FORMAT_GSM610 : - error = gsm610_init (psf) ; - break ; - - case SF_FORMAT_MPEG_LAYER_III : - error = mpeg_init (psf, SF_BITRATE_MODE_CONSTANT, SF_FALSE) ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - if (psf->file.mode == SFM_WRITE || (psf->file.mode == SFM_RDWR && psf->filelength == 0)) - return psf->write_header (psf, SF_FALSE) ; - - return error ; -} /* wav_open */ - -/*========================================================================= -** Private functions. -*/ - -static int -wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock) -{ WAVLIKE_PRIVATE *wpriv ; - WAV_FMT *wav_fmt ; - FACT_CHUNK fact_chunk ; - uint32_t marker, chunk_size = 0, RIFFsize = 0, done = 0 ; - int parsestage = 0, error, format = 0 ; - - if (psf->is_pipe == 0 && psf->filelength > 0xFFFFFFFFLL) - psf_log_printf (psf, "Warning : filelength > 0xffffffff. This is bad!!!!\n") ; - - if ((wpriv = psf->container_data) == NULL) - return SFE_INTERNAL ; - wav_fmt = &wpriv->wav_fmt ; - - /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "pmj", 0, &marker, -4) ; - psf->header.indx = 0 ; - - /* RIFX signifies big-endian format for all header and data to prevent - ** lots of code copying here, we'll set the psf->rwf_endian flag once here, - ** and never specify endian-ness for all other header ops/ - */ - psf->rwf_endian = (marker == RIFF_MARKER) ? SF_ENDIAN_LITTLE : SF_ENDIAN_BIG ; - - while (! done) - { size_t jump = chunk_size & 1 ; - - marker = chunk_size = 0 ; - psf_binheader_readf (psf, "jm4", jump, &marker, &chunk_size) ; - if (marker == 0) - { sf_count_t pos = psf_ftell (psf) ; - psf_log_printf (psf, "Have 0 marker at position %D (0x%x).\n", pos, pos) ; - break ; - } ; - - psf_store_read_chunk_u32 (&psf->rchunks, marker, psf_ftell (psf), chunk_size) ; - - switch (marker) - { case RIFF_MARKER : - case RIFX_MARKER : - if (parsestage) - return SFE_WAV_NO_RIFF ; - - parsestage |= HAVE_RIFF ; - - RIFFsize = chunk_size ; - - if (psf->fileoffset > 0 && psf->filelength > RIFFsize + 8) - { /* Set file length. */ - psf->filelength = RIFFsize + 8 ; - if (marker == RIFF_MARKER) - psf_log_printf (psf, "RIFF : %u\n", RIFFsize) ; - else - psf_log_printf (psf, "RIFX : %u\n", RIFFsize) ; - } - else if (psf->filelength < RIFFsize + 2 * SIGNED_SIZEOF (marker)) - { if (marker == RIFF_MARKER) - psf_log_printf (psf, "RIFF : %u (should be %D)\n", RIFFsize, psf->filelength - 2 * SIGNED_SIZEOF (marker)) ; - else - psf_log_printf (psf, "RIFX : %u (should be %D)\n", RIFFsize, psf->filelength - 2 * SIGNED_SIZEOF (marker)) ; - - RIFFsize = psf->filelength - 2 * SIGNED_SIZEOF (RIFFsize) ; - } - else - { if (marker == RIFF_MARKER) - psf_log_printf (psf, "RIFF : %u\n", RIFFsize) ; - else - psf_log_printf (psf, "RIFX : %u\n", RIFFsize) ; - } ; - - psf_binheader_readf (psf, "m", &marker) ; - if (marker != WAVE_MARKER) - return SFE_WAV_NO_WAVE ; - parsestage |= HAVE_WAVE ; - psf_log_printf (psf, "WAVE\n") ; - chunk_size = 0 ; - break ; - - case fmt_MARKER : - if ((parsestage & (HAVE_RIFF | HAVE_WAVE)) != (HAVE_RIFF | HAVE_WAVE)) - return SFE_WAV_NO_FMT ; - - /* If this file has a SECOND fmt chunk, I don't want to know about it. */ - if (parsestage & HAVE_fmt) - break ; - - parsestage |= HAVE_fmt ; - - psf_log_printf (psf, "fmt : %d\n", chunk_size) ; - - if ((error = wavlike_read_fmt_chunk (psf, chunk_size))) - return error ; - - format = wav_fmt->format ; - break ; - - case data_MARKER : - if ((parsestage & (HAVE_RIFF | HAVE_WAVE | HAVE_fmt)) != (HAVE_RIFF | HAVE_WAVE | HAVE_fmt)) - return SFE_WAV_NO_DATA ; - - if (psf->file.mode == SFM_RDWR && (parsestage & HAVE_other) != 0) - return SFE_RDWR_BAD_HEADER ; - - parsestage |= HAVE_data ; - - psf->datalength = chunk_size ; - if (psf->datalength & 1) - psf_log_printf (psf, "*** 'data' chunk should be an even number of bytes in length.\n") ; - - psf->dataoffset = psf_ftell (psf) ; - - if (psf->dataoffset > 0) - { if (chunk_size == 0 && RIFFsize == 8 && psf->filelength > 44) - { psf_log_printf (psf, "*** Looks like a WAV file which wasn't closed properly. Fixing it.\n") ; - psf->datalength = psf->filelength - psf->dataoffset ; - } ; - - if (psf->datalength > psf->filelength - psf->dataoffset) - { psf_log_printf (psf, "data : %D (should be %D)\n", psf->datalength, psf->filelength - psf->dataoffset) ; - psf->datalength = psf->filelength - psf->dataoffset ; - } - else - psf_log_printf (psf, "data : %D\n", psf->datalength) ; - - /* Only set dataend if there really is data at the end. */ - if (psf->datalength + psf->dataoffset < psf->filelength) - psf->dataend = psf->datalength + psf->dataoffset ; - - psf->datalength += chunk_size & 1 ; - chunk_size = 0 ; - } ; - - if (! psf->sf.seekable || psf->dataoffset < 0) - break ; - - /* Seek past data and continue reading header. */ - psf_fseek (psf, psf->datalength, SEEK_CUR) ; - - if (psf_ftell (psf) != psf->datalength + psf->dataoffset) - psf_log_printf (psf, "*** psf_fseek past end error ***\n") ; - break ; - - case fact_MARKER : - if ((parsestage & (HAVE_RIFF | HAVE_WAVE)) != (HAVE_RIFF | HAVE_WAVE)) - return SFE_WAV_BAD_FACT ; - - parsestage |= HAVE_fact ; - - if ((parsestage & HAVE_fmt) != HAVE_fmt) - psf_log_printf (psf, "*** Should have 'fmt ' chunk before 'fact'\n") ; - - psf_binheader_readf (psf, "4", & (fact_chunk.frames)) ; - - if (chunk_size > SIGNED_SIZEOF (fact_chunk)) - psf_binheader_readf (psf, "j", (int) (chunk_size - SIGNED_SIZEOF (fact_chunk))) ; - - if (chunk_size) - psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; - else - psf_log_printf (psf, "%M : %u (should not be zero)\n", marker, chunk_size) ; - - psf_log_printf (psf, " frames : %d\n", fact_chunk.frames) ; - break ; - - case PEAK_MARKER : - if ((parsestage & (HAVE_RIFF | HAVE_WAVE | HAVE_fmt)) != (HAVE_RIFF | HAVE_WAVE | HAVE_fmt)) - return SFE_WAV_PEAK_B4_FMT ; - - parsestage |= HAVE_PEAK ; - - psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; - if ((error = wavlike_read_peak_chunk (psf, chunk_size)) != 0) - return error ; - psf->peak_info->peak_loc = ((parsestage & HAVE_data) == 0) ? SF_PEAK_START : SF_PEAK_END ; - break ; - - case cue_MARKER : - parsestage |= HAVE_other ; - - { uint32_t thisread, bytesread, cue_count, position, offset ; - int id, chunk_id, chunk_start, block_start, cue_index ; - - bytesread = psf_binheader_readf (psf, "4", &cue_count) ; - psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; - - if (cue_count > 2500) /* 2500 is close to the largest number of cues possible because of block sizes */ - { psf_log_printf (psf, " Count : %u (skipping)\n", cue_count) ; - psf_binheader_readf (psf, "j", chunk_size - bytesread) ; - break ; - } ; - - psf_log_printf (psf, " Count : %d\n", cue_count) ; - - if (psf->cues) - { free (psf->cues) ; - psf->cues = NULL ; - } ; - - if ((psf->cues = psf_cues_alloc (cue_count)) == NULL) - return SFE_MALLOC_FAILED ; - - cue_index = 0 ; - - while (cue_count) - { - if ((thisread = psf_binheader_readf (psf, "e44m444", &id, &position, &chunk_id, &chunk_start, &block_start, &offset)) == 0) - break ; - bytesread += thisread ; - - if (cue_index < 10) /* avoid swamping log buffer with cues */ - psf_log_printf (psf, " Cue ID : %2d" - " Pos : %5u Chunk : %M" - " Chk Start : %d Blk Start : %d" - " Offset : %5d\n", - id, position, chunk_id, chunk_start, block_start, offset) ; - else if (cue_index == 10) - psf_log_printf (psf, " (Skipping)\n") ; - - psf->cues->cue_points [cue_index].indx = id ; - psf->cues->cue_points [cue_index].position = position ; - psf->cues->cue_points [cue_index].fcc_chunk = chunk_id ; - psf->cues->cue_points [cue_index].chunk_start = chunk_start ; - psf->cues->cue_points [cue_index].block_start = block_start ; - psf->cues->cue_points [cue_index].sample_offset = offset ; - psf->cues->cue_points [cue_index].name [0] = '\0' ; - cue_count -- ; - cue_index ++ ; - } ; - - if (bytesread != chunk_size) - { psf_log_printf (psf, "**** Chunk size weirdness (%d != %d)\n", chunk_size, bytesread) ; - psf_binheader_readf (psf, "j", chunk_size - bytesread) ; - } ; - } ; - break ; - - case smpl_MARKER : - parsestage |= HAVE_other ; - - psf_log_printf (psf, "smpl : %u\n", chunk_size) ; - - if ((error = wav_read_smpl_chunk (psf, chunk_size))) - return error ; - break ; - - case acid_MARKER : - parsestage |= HAVE_other ; - - psf_log_printf (psf, "acid : %u\n", chunk_size) ; - - if ((error = wav_read_acid_chunk (psf, chunk_size))) - return error ; - break ; - - case INFO_MARKER : - case LIST_MARKER : - parsestage |= HAVE_other ; - - if ((error = wavlike_subchunk_parse (psf, marker, chunk_size)) != 0) - return error ; - break ; - - case bext_MARKER : - /* - The 'bext' chunk can actually be updated, so don't need to set this. - parsestage |= HAVE_other ; - */ - if ((error = wavlike_read_bext_chunk (psf, chunk_size))) - return error ; - break ; - - case PAD_MARKER : - /* - We can eat into a 'PAD ' chunk if we need to. - parsestage |= HAVE_other ; - */ - psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - - case cart_MARKER: - if ((error = wavlike_read_cart_chunk (psf, chunk_size))) - return error ; - break ; - - case iXML_MARKER : /* See http://en.wikipedia.org/wiki/IXML */ - case strc_MARKER : /* Multiple of 32 bytes. */ - case afsp_MARKER : - case clm_MARKER : - case elmo_MARKER : - case levl_MARKER : - case plst_MARKER : - case minf_MARKER : - case elm1_MARKER : - case regn_MARKER : - case ovwf_MARKER : - case inst_MARKER : - case AFAn_MARKER : - case umid_MARKER : - case SyLp_MARKER : - case Cr8r_MARKER : - case JUNK_MARKER : - case PMX_MARKER : - case DISP_MARKER : - case MEXT_MARKER : - case FLLR_MARKER : - psf_log_printf (psf, "%M : %u\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - - default : - if (chunk_size >= 0xffff0000) - { done = SF_TRUE ; - psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D with length %u. Exiting parser.\n", marker, psf_ftell (psf) - 8, chunk_size) ; - break ; - } ; - - if ((marker & TAG__MARKER_MASK) == TAG__MARKER && - psf_ftell (psf) - 8 + 128 == psf->filelength) - { psf_log_printf (psf, "*** Hit ID3v1 trailer. Exiting parser.\n") ; - chunk_size = 128 ; - done = SF_TRUE ; - parsestage |= HAVE_other ; - break ; - } ; - - if (psf_isprint ((marker >> 24) & 0xFF) && psf_isprint ((marker >> 16) & 0xFF) - && psf_isprint ((marker >> 8) & 0xFF) && psf_isprint (marker & 0xFF)) - { psf_log_printf (psf, "*** %M : %u (unknown marker)\n", marker, chunk_size) ; - psf_binheader_readf (psf, "j", chunk_size) ; - break ; - } ; - if (psf_ftell (psf) & 0x03) - { psf_log_printf (psf, " Unknown chunk marker at position %D. Resynching.\n", psf_ftell (psf) - 8) ; - psf_binheader_readf (psf, "j", -3) ; - /* File is too messed up so we prevent editing in RDWR mode here. */ - parsestage |= HAVE_other ; - break ; - } ; - psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D. Exiting parser.\n", marker, psf_ftell (psf) - 8) ; - done = SF_TRUE ; - break ; - } ; /* switch (marker) */ - - if (chunk_size >= psf->filelength) - { psf_log_printf (psf, "*** Chunk size %u > file length %D. Exiting parser.\n", chunk_size, psf->filelength) ; - break ; - } ; - - if (! psf->sf.seekable && (parsestage & HAVE_data)) - break ; - - if (psf_ftell (psf) >= psf->filelength - SIGNED_SIZEOF (chunk_size)) - { psf_log_printf (psf, "End\n") ; - break ; - } ; - } ; /* while (1) */ - - if (psf->dataoffset <= 0) - return SFE_WAV_NO_DATA ; - - if (psf->sf.channels < 1) - return SFE_CHANNEL_COUNT_ZERO ; - - if (psf->sf.channels > SF_MAX_CHANNELS) - return SFE_CHANNEL_COUNT ; - - if (format != WAVE_FORMAT_PCM && (parsestage & HAVE_fact) == 0) - psf_log_printf (psf, "**** All non-PCM format files should have a 'fact' chunk.\n") ; - - /* WAVs can be little or big endian */ - psf->endian = psf->rwf_endian ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - if (psf->is_pipe == 0) - { /* - ** Check for 'wvpk' at the start of the DATA section. Not able to - ** handle this. - */ - psf_binheader_readf (psf, "4", &marker) ; - if (marker == wvpk_MARKER || marker == OggS_MARKER) - return SFE_WAV_WVPK_DATA ; - } ; - - /* Seek to start of DATA section. */ - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - if (psf->blockwidth) - { if (psf->filelength - psf->dataoffset < psf->datalength) - psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - else - psf->sf.frames = psf->datalength / psf->blockwidth ; - } ; - - switch (format) - { case WAVE_FORMAT_EXTENSIBLE : - if (psf->sf.format == (SF_FORMAT_WAVEX | SF_FORMAT_MS_ADPCM)) - { *blockalign = wav_fmt->msadpcm.blockalign ; - *framesperblock = wav_fmt->msadpcm.samplesperblock ; - } ; - break ; - - case WAVE_FORMAT_NMS_VBXADPCM : - switch (wav_fmt->min.bitwidth) - { case 2 : - psf->sf.format = SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_16 ; - break ; - case 3 : - psf->sf.format = SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_24 ; - break ; - case 4 : - psf->sf.format = SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_32 ; - break ; - - default : - return SFE_UNIMPLEMENTED ; - } - break ; - - case WAVE_FORMAT_PCM : - psf->sf.format = SF_FORMAT_WAV | u_bitwidth_to_subformat (psf->bytewidth * 8) ; - break ; - - case WAVE_FORMAT_MULAW : - case IBM_FORMAT_MULAW : - psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_ULAW) ; - break ; - - case WAVE_FORMAT_ALAW : - case IBM_FORMAT_ALAW : - psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_ALAW) ; - break ; - - case WAVE_FORMAT_MS_ADPCM : - psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM) ; - *blockalign = wav_fmt->msadpcm.blockalign ; - *framesperblock = wav_fmt->msadpcm.samplesperblock ; - break ; - - case WAVE_FORMAT_IMA_ADPCM : - psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ; - *blockalign = wav_fmt->ima.blockalign ; - *framesperblock = wav_fmt->ima.samplesperblock ; - break ; - - case WAVE_FORMAT_GSM610 : - psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_GSM610) ; - break ; - - case WAVE_FORMAT_IEEE_FLOAT : - psf->sf.format = SF_FORMAT_WAV ; - psf->sf.format |= (psf->bytewidth == 8) ? SF_FORMAT_DOUBLE : SF_FORMAT_FLOAT ; - break ; - - case WAVE_FORMAT_G721_ADPCM : - psf->sf.format = SF_FORMAT_WAV | SF_FORMAT_G721_32 ; - break ; - - case WAVE_FORMAT_MPEGLAYER3 : - psf->sf.format = SF_FORMAT_WAV | SF_FORMAT_MPEG_LAYER_III ; - if (parsestage & HAVE_fact) - psf->sf.frames = fact_chunk.frames ; - break ; - - default : return SFE_UNIMPLEMENTED ; - } ; - - if (wpriv->fmt_is_broken) - wavlike_analyze (psf) ; - - /* Only set the format endian-ness if its non-standard big-endian. */ - if (psf->endian == SF_ENDIAN_BIG) - psf->sf.format |= SF_ENDIAN_BIG ; - - return 0 ; -} /* wav_read_header */ - -static int -wav_write_fmt_chunk (SF_PRIVATE *psf) -{ int subformat, fmt_size, add_fact_chunk = 0 ; - - subformat = SF_CODEC (psf->sf.format) ; - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "4224", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_PCM), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "22", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (psf->bytewidth * 8)) ; - break ; - - case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "4224", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_IEEE_FLOAT), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "22", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (psf->bytewidth * 8)) ; - - add_fact_chunk = SF_TRUE ; - break ; - - case SF_FORMAT_ULAW : - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "4224", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_MULAW), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth, extrabytes */ - psf_binheader_writef (psf, "222", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (8), BHW2 (0)) ; - - add_fact_chunk = SF_TRUE ; - break ; - - case SF_FORMAT_ALAW : - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "4224", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_ALAW), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth, extrabytes */ - psf_binheader_writef (psf, "222", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (8), BHW2 (0)) ; - - add_fact_chunk = SF_TRUE ; - break ; - - /* Lite remove start */ - case SF_FORMAT_IMA_ADPCM : - { int blockalign, framesperblock, bytespersec ; - - blockalign = wavlike_srate2blocksize (psf->sf.samplerate * psf->sf.channels) ; - framesperblock = 2 * (blockalign - 4 * psf->sf.channels) / psf->sf.channels + 1 ; - bytespersec = (psf->sf.samplerate * blockalign) / framesperblock ; - - /* fmt chunk. */ - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 ; - - /* fmt : size, WAV format type, channels, samplerate, bytespersec */ - psf_binheader_writef (psf, "42244", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_IMA_ADPCM), - BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate), BHW4 (bytespersec)) ; - - /* fmt : blockalign, bitwidth, extrabytes, framesperblock. */ - psf_binheader_writef (psf, "2222", BHW2 (blockalign), BHW2 (4), BHW2 (2), BHW2 (framesperblock)) ; - } ; - - add_fact_chunk = SF_TRUE ; - break ; - - case SF_FORMAT_MS_ADPCM : - { int blockalign, framesperblock, bytespersec, extrabytes ; - - blockalign = wavlike_srate2blocksize (psf->sf.samplerate * psf->sf.channels) ; - framesperblock = 2 + 2 * (blockalign - 7 * psf->sf.channels) / psf->sf.channels ; - bytespersec = (psf->sf.samplerate * blockalign) / framesperblock ; - - /* fmt chunk. */ - extrabytes = 2 + 2 + WAVLIKE_MSADPCM_ADAPT_COEFF_COUNT * (2 + 2) ; - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + extrabytes ; - - /* fmt : size, WAV format type, channels. */ - psf_binheader_writef (psf, "422", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_MS_ADPCM), BHW2 (psf->sf.channels)) ; - - /* fmt : samplerate, bytespersec. */ - psf_binheader_writef (psf, "44", BHW4 (psf->sf.samplerate), BHW4 (bytespersec)) ; - - /* fmt : blockalign, bitwidth, extrabytes, framesperblock. */ - psf_binheader_writef (psf, "22222", BHW2 (blockalign), BHW2 (4), BHW2 (extrabytes), BHW2 (framesperblock), BHW2 (7)) ; - - wavlike_msadpcm_write_adapt_coeffs (psf) ; - } ; - - add_fact_chunk = SF_TRUE ; - break ; - - - case SF_FORMAT_G721_32 : - /* fmt chunk. */ - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 ; - - /* fmt : size, WAV format type, channels, samplerate, bytespersec */ - psf_binheader_writef (psf, "42244", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_G721_ADPCM), - BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate), BHW4 (psf->sf.samplerate * psf->sf.channels / 2)) ; - - /* fmt : blockalign, bitwidth, extrabytes, auxblocksize. */ - psf_binheader_writef (psf, "2222", BHW2 (64), BHW2 (4), BHW2 (2), BHW2 (0)) ; - - add_fact_chunk = SF_TRUE ; - break ; - - case SF_FORMAT_NMS_ADPCM_16 : - case SF_FORMAT_NMS_ADPCM_24 : - case SF_FORMAT_NMS_ADPCM_32 : - { int bytespersec, blockalign, bitwidth ; - - bitwidth = subformat == SF_FORMAT_NMS_ADPCM_16 ? 2 : subformat == SF_FORMAT_NMS_ADPCM_24 ? 3 : 4 ; - blockalign = 20 * bitwidth + 2 ; - bytespersec = psf->sf.samplerate * blockalign / 160 ; - - /* fmt chunk. */ - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "4224", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_NMS_VBXADPCM), - BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec, blockalign, bitwidth */ - psf_binheader_writef (psf, "422", BHW4 (bytespersec), BHW2 (blockalign), BHW2 (bitwidth)) ; - - add_fact_chunk = SF_TRUE ; - break ; - } - - /* Lite remove end */ - - case SF_FORMAT_GSM610 : - { int blockalign, framesperblock, bytespersec ; - - blockalign = WAVLIKE_GSM610_BLOCKSIZE ; - framesperblock = WAVLIKE_GSM610_SAMPLES ; - bytespersec = (psf->sf.samplerate * blockalign) / framesperblock ; - - /* fmt chunk. */ - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 ; - - /* fmt : size, WAV format type, channels. */ - psf_binheader_writef (psf, "422", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_GSM610), BHW2 (psf->sf.channels)) ; - - /* fmt : samplerate, bytespersec. */ - psf_binheader_writef (psf, "44", BHW4 (psf->sf.samplerate), BHW4 (bytespersec)) ; - - /* fmt : blockalign, bitwidth, extrabytes, framesperblock. */ - psf_binheader_writef (psf, "2222", BHW2 (blockalign), BHW2 (0), BHW2 (2), BHW2 (framesperblock)) ; - } ; - - add_fact_chunk = SF_TRUE ; - break ; - -#if (ENABLE_EXPERIMENTAL_CODE == 0) - case SF_FORMAT_MPEG_LAYER_III : - { int bytespersec, blockalign, flags, blocksize, samplesperblock, codecdelay ; - - /* Intended to be set as the average sample rate. - ** TODO: Maybe re-write this on close with final average - ** byterate? */ - bytespersec = psf->byterate (psf) ; - - /* Average block size. Info only I think. */ - blocksize = (1152 * bytespersec) / psf->sf.samplerate ; - - /* Can be set to block size IFF the block size is - ** constant, set to 1 otherwise. Constant sized - ** MPEG block streams are uncommon (CBR @ 32kHz and - ** 48kHz only. Meh. */ - blockalign = 1 ; - - /* TODO: Only flags defined are padding-type. I /think/ - ** Lame does ISO style padding by default, which has a - ** flag value of 0. - */ - flags = 0 ; - - /* Should only vary per MPEG 1.0/2.0 vs '2.5'. - ** TODO: Move this out to MPEG specific place? */ - samplesperblock = psf->sf.samplerate >= 32000 ? 1152 : 576 ; - - /* Set as 0 if unknown. - ** TODO: Plumb this cleanly from Lame. - */ - codecdelay = 0 ; - - /* fmt chunk. */ - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 + 4 + 2 + 2 + 2 ; - - /* fmt : size, WAV format type, channels. */ - psf_binheader_writef (psf, "422", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_MPEGLAYER3), BHW2 (psf->sf.channels)) ; - - /* fmt : samplerate, bytespersec. */ - psf_binheader_writef (psf, "44", BHW4 (psf->sf.samplerate), BHW4 (bytespersec)) ; - - /* fmt : blockalign, bitwidth, extrabytes, id. */ - psf_binheader_writef (psf, "2222", BHW2 (blockalign), BHW2 (0), BHW2 (12), BHW2 (1)) ; - - /* fmt : flags, blocksize, samplesperblock, codecdelay */ - psf_binheader_writef (psf, "4222", BHW4 (flags), BHW2 (blocksize), BHW2 (samplesperblock), BHW2 (codecdelay)) ; - } ; - - add_fact_chunk = SF_TRUE ; - break ; -#endif - - default : return SFE_UNIMPLEMENTED ; - } ; - - if (add_fact_chunk) - psf_binheader_writef (psf, "tm48", BHWm (fact_MARKER), BHW4 (4), BHW8 (psf->sf.frames)) ; - - return 0 ; -} /* wav_write_fmt_chunk */ - -static int -wavex_write_fmt_chunk (SF_PRIVATE *psf) -{ WAVLIKE_PRIVATE *wpriv ; - int subformat, fmt_size ; - - if ((wpriv = psf->container_data) == NULL) - return SFE_INTERNAL ; - - subformat = SF_CODEC (psf->sf.format) ; - - /* initial section (same for all, it appears) */ - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - case SF_FORMAT_ULAW : - case SF_FORMAT_ALAW : - fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 + 4 + 4 + 2 + 2 + 8 ; - - /* fmt : format, channels, samplerate */ - psf_binheader_writef (psf, "4224", BHW4 (fmt_size), BHW2 (WAVE_FORMAT_EXTENSIBLE), BHW2 (psf->sf.channels), BHW4 (psf->sf.samplerate)) ; - /* fmt : bytespersec */ - psf_binheader_writef (psf, "4", BHW4 (psf->sf.samplerate * psf->bytewidth * psf->sf.channels)) ; - /* fmt : blockalign, bitwidth */ - psf_binheader_writef (psf, "22", BHW2 (psf->bytewidth * psf->sf.channels), BHW2 (psf->bytewidth * 8)) ; - - /* cbSize 22 is sizeof (WAVEFORMATEXTENSIBLE) - sizeof (WAVEFORMATEX) */ - psf_binheader_writef (psf, "2", BHW2 (22)) ; - - /* wValidBitsPerSample, for our use same as bitwidth as we use it fully */ - psf_binheader_writef (psf, "2", BHW2 (psf->bytewidth * 8)) ; - - /* For an Ambisonic file set the channel mask to zero. - ** Otherwise use a default based on the channel count. - */ - if (wpriv->wavex_ambisonic != SF_AMBISONIC_NONE) - psf_binheader_writef (psf, "4", BHW4 (0)) ; - else if (wpriv->wavex_channelmask != 0) - psf_binheader_writef (psf, "4", BHW4 (wpriv->wavex_channelmask)) ; - else - { /* - ** Ok some liberty is taken here to use the most commonly used channel masks - ** instead of "no mapping". If you really want to use "no mapping" for 8 channels and less - ** please don't use wavex. (otherwise we'll have to create a new SF_COMMAND) - */ - switch (psf->sf.channels) - { case 1 : /* center channel mono */ - psf_binheader_writef (psf, "4", BHW4 (0x4)) ; - break ; - - case 2 : /* front left and right */ - psf_binheader_writef (psf, "4", BHW4 (0x1 | 0x2)) ; - break ; - - case 4 : /* Quad */ - psf_binheader_writef (psf, "4", BHW4 (0x1 | 0x2 | 0x10 | 0x20)) ; - break ; - - case 6 : /* 5.1 */ - psf_binheader_writef (psf, "4", BHW4 (0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20)) ; - break ; - - case 8 : /* 7.1 */ - psf_binheader_writef (psf, "4", BHW4 (0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x80)) ; - break ; - - default : /* 0 when in doubt , use direct out, ie NO mapping*/ - psf_binheader_writef (psf, "4", BHW4 (0x0)) ; - break ; - } ; - } ; - break ; - - case SF_FORMAT_MS_ADPCM : /* Todo, GUID exists might have different header as per wav_write_header */ - default : - return SFE_UNIMPLEMENTED ; - } ; - - /* GUID section, different for each */ - - switch (subformat) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - wavlike_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ? - &MSGUID_SUBTYPE_PCM : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM) ; - break ; - - case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - wavlike_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ? - &MSGUID_SUBTYPE_IEEE_FLOAT : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT) ; - break ; - - case SF_FORMAT_ULAW : - wavlike_write_guid (psf, &MSGUID_SUBTYPE_MULAW) ; - break ; - - case SF_FORMAT_ALAW : - wavlike_write_guid (psf, &MSGUID_SUBTYPE_ALAW) ; - break ; - -#if 0 - /* This is dead code due to return in previous switch statement. */ - case SF_FORMAT_MS_ADPCM : /* todo, GUID exists */ - wavlike_write_guid (psf, &MSGUID_SUBTYPE_MS_ADPCM) ; - break ; - return SFE_UNIMPLEMENTED ; -#endif - - default : return SFE_UNIMPLEMENTED ; - } ; - - psf_binheader_writef (psf, "tm48", BHWm (fact_MARKER), BHW4 (4), BHW8 (psf->sf.frames)) ; - - return 0 ; -} /* wavex_write_fmt_chunk */ - - -static int -wav_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t current ; - int error, has_data = SF_FALSE ; - - current = psf_ftell (psf) ; - - if (current > psf->dataoffset) - has_data = SF_TRUE ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - else if (psf->bytewidth > 0 && psf->sf.seekable == SF_TRUE) - psf->datalength = psf->sf.frames * psf->bytewidth * psf->sf.channels ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - /* - ** RIFX signifies big-endian format for all header and data. - ** To prevent lots of code copying here, we'll set the psf->rwf_endian flag - ** once here, and never specify endian-ness for all other header operations. - */ - - /* RIFF/RIFX marker, length, WAVE and 'fmt ' markers. */ - - if (psf->endian == SF_ENDIAN_LITTLE) - psf_binheader_writef (psf, "etm8", BHWm (RIFF_MARKER), BHW8 ((psf->filelength < 8) ? 8 : SF_MIN(psf->filelength - 8, UINT32_MAX))) ; - else - psf_binheader_writef (psf, "Etm8", BHWm (RIFX_MARKER), BHW8 ((psf->filelength < 8) ? 8 : SF_MIN(psf->filelength - 8, UINT32_MAX))) ; - - /* WAVE and 'fmt ' markers. */ - psf_binheader_writef (psf, "mm", BHWm (WAVE_MARKER), BHWm (fmt_MARKER)) ; - - /* Write the 'fmt ' chunk. */ - switch (SF_CONTAINER (psf->sf.format)) - { case SF_FORMAT_WAV : - if ((error = wav_write_fmt_chunk (psf)) != 0) - return error ; - break ; - - case SF_FORMAT_WAVEX : - if ((error = wavex_write_fmt_chunk (psf)) != 0) - return error ; - break ; - - default : - return SFE_UNIMPLEMENTED ; - } ; - - /* The LIST/INFO chunk. */ - if (psf->strings.flags & SF_STR_LOCATE_START) - wavlike_write_strings (psf, SF_STR_LOCATE_START) ; - - if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_START) - wavlike_write_peak_chunk (psf) ; - - if (psf->broadcast_16k != NULL) - wavlike_write_bext_chunk (psf) ; - - if (psf->cart_16k != NULL) - wavlike_write_cart_chunk (psf) ; - - if (psf->cues != NULL) - { uint32_t k ; - - psf_binheader_writef (psf, "em44", BHWm (cue_MARKER), BHW4 (4 + psf->cues->cue_count * 6 * 4), BHW4 (psf->cues->cue_count)) ; - - for (k = 0 ; k < psf->cues->cue_count ; k++) - psf_binheader_writef (psf, "e44m444", BHW4 (psf->cues->cue_points [k].indx), BHW4 (psf->cues->cue_points [k].position), - BHWm (psf->cues->cue_points [k].fcc_chunk), BHW4 (psf->cues->cue_points [k].chunk_start), - BHW4 (psf->cues->cue_points [k].block_start), BHW4 (psf->cues->cue_points [k].sample_offset)) ; - } ; - - if (psf->instrument != NULL) - { int tmp ; - double dtune = (double) (0x40000000) / 25.0 ; - - psf_binheader_writef (psf, "m4", BHWm (smpl_MARKER), BHW4 (9 * 4 + psf->instrument->loop_count * 6 * 4)) ; - psf_binheader_writef (psf, "44", BHW4 (0), BHW4 (0)) ; /* Manufacturer zero is everyone */ - tmp = (int) (1.0e9 / psf->sf.samplerate) ; /* Sample period in nano seconds */ - psf_binheader_writef (psf, "44", BHW4 (tmp), BHW4 (psf->instrument->basenote)) ; - tmp = (uint32_t) (psf->instrument->detune * dtune + 0.5) ; - psf_binheader_writef (psf, "4", BHW4 (tmp)) ; - psf_binheader_writef (psf, "44", BHW4 (0), BHW4 (0)) ; /* SMTPE format */ - psf_binheader_writef (psf, "44", BHW4 (psf->instrument->loop_count), BHW4 (0)) ; - - /* Make sure we don't read past the loops array end. */ - if (psf->instrument->loop_count > ARRAY_LEN (psf->instrument->loops)) - psf->instrument->loop_count = ARRAY_LEN (psf->instrument->loops) ; - - for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++) - { int type ; - - type = psf->instrument->loops [tmp].mode ; - type = (type == SF_LOOP_FORWARD ? 0 : type == SF_LOOP_BACKWARD ? 2 : type == SF_LOOP_ALTERNATING ? 1 : 32) ; - - psf_binheader_writef (psf, "44", BHW4 (tmp), BHW4 (type)) ; - psf_binheader_writef (psf, "44", BHW4 (psf->instrument->loops [tmp].start), BHW4 (psf->instrument->loops [tmp].end - 1)) ; - psf_binheader_writef (psf, "44", BHW4 (0), BHW4 (psf->instrument->loops [tmp].count)) ; - } ; - } ; - - /* Write custom headers. */ - if (psf->wchunks.used > 0) - wavlike_write_custom_chunks (psf) ; - - if (psf->header.indx + 16 < psf->dataoffset) - { /* Add PAD data if necessary. */ - size_t k = psf->dataoffset - (psf->header.indx + 16) ; - psf_binheader_writef (psf, "m4z", BHWm (PAD_MARKER), BHW4 (k), BHWz (k)) ; - } ; - - psf_binheader_writef (psf, "tm8", BHWm (data_MARKER), BHW8 (SF_MIN(psf->datalength, UINT32_MAX))) ; - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - if (psf->error) - return psf->error ; - - if (has_data && psf->dataoffset != psf->header.indx) - { psf_log_printf (psf, "Oooops : has_data && psf->dataoffset != psf->header.indx\n") ; - return psf->error = SFE_INTERNAL ; - } ; - - psf->dataoffset = psf->header.indx ; - - if (! has_data) - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - else if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* wav_write_header */ - - -static int -wav_write_tailer (SF_PRIVATE *psf) -{ - /* Reset the current header buffer length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - - if (psf->bytewidth > 0 && psf->sf.seekable == SF_TRUE) - { psf->datalength = psf->sf.frames * psf->bytewidth * psf->sf.channels ; - psf->dataend = psf->dataoffset + psf->datalength ; - } ; - - if (psf->dataend > 0) - psf_fseek (psf, psf->dataend, SEEK_SET) ; - else - psf->dataend = psf_fseek (psf, 0, SEEK_END) ; - - if (psf->dataend & 1) - psf_binheader_writef (psf, "z", BHWz (1)) ; - - /* Add a PEAK chunk if requested. */ - if (psf->peak_info != NULL && psf->peak_info->peak_loc == SF_PEAK_END) - wavlike_write_peak_chunk (psf) ; - - if (psf->strings.flags & SF_STR_LOCATE_END) - wavlike_write_strings (psf, SF_STR_LOCATE_END) ; - - /* Write the tailer. */ - if (psf->header.indx > 0) - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - return 0 ; -} /* wav_write_tailer */ - -static int -wav_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { wav_write_tailer (psf) ; - - if (psf->file.mode == SFM_RDWR) - { sf_count_t current = psf_ftell (psf) ; - - /* - ** If the mode is RDWR and the current position is less than the - ** filelength, truncate the file. - */ - - if (current < psf->filelength) - { psf_ftruncate (psf, current) ; - psf->filelength = current ; - } ; - } ; - - psf->write_header (psf, SF_TRUE) ; - } ; - - return 0 ; -} /* wav_close */ - -static int -wav_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize) -{ WAVLIKE_PRIVATE *wpriv ; - - if ((wpriv = psf->container_data) == NULL) - return SFE_INTERNAL ; - - switch (command) - { case SFC_WAVEX_SET_AMBISONIC : - if ((SF_CONTAINER (psf->sf.format)) == SF_FORMAT_WAVEX) - { if (datasize == SF_AMBISONIC_NONE) - wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ; - else if (datasize == SF_AMBISONIC_B_FORMAT) - wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ; - else - return 0 ; - } ; - return wpriv->wavex_ambisonic ; - - case SFC_WAVEX_GET_AMBISONIC : - return wpriv->wavex_ambisonic ; - - case SFC_SET_CHANNEL_MAP_INFO : - wpriv->wavex_channelmask = wavlike_gen_channel_mask (psf->channel_map, psf->sf.channels) ; - return (wpriv->wavex_channelmask != 0) ; - - default : - break ; - } ; - - return 0 ; -} /* wav_command */ - -static int -wav_read_smpl_chunk (SF_PRIVATE *psf, uint32_t chunklen) -{ char buffer [512] ; - uint32_t thisread, bytesread = 0, dword, sampler_data, loop_count, actually_loop_count = 0 ; - uint32_t note, pitch, start, end, type = -1, count ; - int j, k ; - - chunklen += (chunklen & 1) ; - - bytesread += psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, " Manufacturer : %X\n", dword) ; - - bytesread += psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, " Product : %u\n", dword) ; - - bytesread += psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, " Period : %u nsec\n", dword) ; - - bytesread += psf_binheader_readf (psf, "4", ¬e) ; - psf_log_printf (psf, " Midi Note : %u\n", note) ; - - bytesread += psf_binheader_readf (psf, "4", &pitch) ; - if (pitch != 0) - { snprintf (buffer, sizeof (buffer), "%f", - (1.0 * 0x80000000) / ((uint32_t) pitch)) ; - psf_log_printf (psf, " Pitch Fract. : %s\n", buffer) ; - } - else - psf_log_printf (psf, " Pitch Fract. : 0\n") ; - - bytesread += psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, " SMPTE Format : %u\n", dword) ; - - bytesread += psf_binheader_readf (psf, "4", &dword) ; - snprintf (buffer, sizeof (buffer), "%02"PRIu32 ":%02"PRIu32 ":%02"PRIu32 - " %02"PRIu32 "", (dword >> 24) & 0x7F, (dword >> 16) & 0x7F, - (dword >> 8) & 0x7F, dword & 0x7F) ; - psf_log_printf (psf, " SMPTE Offset : %s\n", buffer) ; - - bytesread += psf_binheader_readf (psf, "4", &loop_count) ; - psf_log_printf (psf, " Loop Count : %u\n", loop_count) ; - - if (loop_count == 0 && chunklen == bytesread) - return 0 ; - - /* Sampler Data holds the number of data bytes after the CUE chunks which - ** is not actually CUE data. Display value after CUE data. - */ - bytesread += psf_binheader_readf (psf, "4", &sampler_data) ; - - if (psf->instrument) - { psf_log_printf (psf, " Found more than one SMPL chunk, using last one.\n") ; - free (psf->instrument) ; - psf->instrument = NULL ; - } ; - if ((psf->instrument = psf_instrument_alloc ()) == NULL) - return SFE_MALLOC_FAILED ; - - psf->instrument->loop_count = loop_count ; - - for (j = 0 ; loop_count > 0 && chunklen - bytesread >= 24 ; j ++) - { if ((thisread = psf_binheader_readf (psf, "4", &dword)) == 0) - break ; - bytesread += thisread ; - psf_log_printf (psf, " Cue ID : %2u", dword) ; - - bytesread += psf_binheader_readf (psf, "4", &type) ; - psf_log_printf (psf, " Type : %2u", type) ; - - bytesread += psf_binheader_readf (psf, "4", &start) ; - psf_log_printf (psf, " Start : %5u", start) ; - - bytesread += psf_binheader_readf (psf, "4", &end) ; - psf_log_printf (psf, " End : %5u", end) ; - - bytesread += psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, " Fraction : %5u", dword) ; - - bytesread += psf_binheader_readf (psf, "4", &count) ; - psf_log_printf (psf, " Count : %5u\n", count) ; - - if (j < ARRAY_LEN (psf->instrument->loops)) - { psf->instrument->loops [j].start = start ; - psf->instrument->loops [j].end = end + 1 ; - psf->instrument->loops [j].count = count ; - - switch (type) - { case 0 : - psf->instrument->loops [j].mode = SF_LOOP_FORWARD ; - break ; - case 1 : - psf->instrument->loops [j].mode = SF_LOOP_ALTERNATING ; - break ; - case 2 : - psf->instrument->loops [j].mode = SF_LOOP_BACKWARD ; - break ; - default: - psf->instrument->loops [j].mode = SF_LOOP_NONE ; - break ; - } ; - } ; - actually_loop_count ++ ; - } ; - - if (actually_loop_count > ARRAY_LEN (psf->instrument->loops)) - { - psf_log_printf (psf, "*** Warning, actual Loop Points count exceeds %u, changing Loop Count from %u to %u\n", ARRAY_LEN (psf->instrument->loops), loop_count, ARRAY_LEN (psf->instrument->loops)) ; - psf->instrument->loop_count = ARRAY_LEN (psf->instrument->loops) ; - } - else if (loop_count != actually_loop_count) - { psf_log_printf (psf, "*** Warning, actual Loop Points count != Loop Count, changing Loop Count from %u to %u\n", loop_count, actually_loop_count) ; - psf->instrument->loop_count = actually_loop_count ; - } ; - - if (chunklen - bytesread == 0) - { if (sampler_data != 0) - psf_log_printf (psf, " Sampler Data : %u (should be 0)\n", sampler_data) ; - else - psf_log_printf (psf, " Sampler Data : %u\n", sampler_data) ; - } - else - { if (sampler_data != chunklen - bytesread) - { psf_log_printf (psf, " Sampler Data : %u (should have been %u)\n", sampler_data, chunklen - bytesread) ; - sampler_data = chunklen - bytesread ; - } - else - psf_log_printf (psf, " Sampler Data : %u\n", sampler_data) ; - - psf_log_printf (psf, " ") ; - for (k = 0 ; k < (int) sampler_data ; k++) - { char ch ; - - if (k > 0 && (k % 20) == 0) - psf_log_printf (psf, "\n ") ; - - if ((thisread = psf_binheader_readf (psf, "1", &ch)) == 0) - break ; - bytesread += thisread ; - psf_log_printf (psf, "%02X ", ch & 0xFF) ; - } ; - - psf_log_printf (psf, "\n") ; - } ; - - psf->instrument->basenote = note ; - psf->instrument->detune = (int8_t) (pitch / (0x40000000 / 25.0) + 0.5) ; - psf->instrument->gain = 1 ; - psf->instrument->velocity_lo = psf->instrument->key_lo = 0 ; - psf->instrument->velocity_hi = psf->instrument->key_hi = 127 ; - - return 0 ; -} /* wav_read_smpl_chunk */ - -/* -** The acid chunk goes a little something like this: -** -** 4 bytes 'acid' -** 4 bytes (int) length of chunk starting at next byte -** -** 4 bytes (int) type of file: -** this appears to be a bit mask,however some combinations -** are probably impossible and/or qualified as "errors" -** -** 0x01 On: One Shot Off: Loop -** 0x02 On: Root note is Set Off: No root -** 0x04 On: Stretch is On, Off: Strech is OFF -** 0x08 On: Disk Based Off: Ram based -** 0x10 On: ?????????? Off: ????????? (Acidizer puts that ON) -** -** 2 bytes (short) root note -** if type 0x10 is OFF : [C,C#,(...),B] -> [0x30 to 0x3B] -** if type 0x10 is ON : [C,C#,(...),B] -> [0x3C to 0x47] -** (both types fit on same MIDI pitch albeit different octaves, so who cares) -** -** 2 bytes (short) ??? always set to 0x8000 -** 4 bytes (float) ??? seems to be always 0 -** 4 bytes (int) number of beats -** 2 bytes (short) meter denominator //always 4 in SF/ACID -** 2 bytes (short) meter numerator //always 4 in SF/ACID -** //are we sure about the order?? usually its num/denom -** 4 bytes (float) tempo -** -*/ - -static int -wav_read_acid_chunk (SF_PRIVATE *psf, uint32_t chunklen) -{ char buffer [512] ; - uint32_t bytesread = 0 ; - int beats, flags ; - short rootnote, q1, meter_denom, meter_numer ; - float q2, tempo ; - - chunklen += (chunklen & 1) ; - - bytesread += psf_binheader_readf (psf, "422f", &flags, &rootnote, &q1, &q2) ; - - snprintf (buffer, sizeof (buffer), "%f", q2) ; - - psf_log_printf (psf, " Flags : 0x%04x (%s,%s,%s,%s,%s)\n", flags, - (flags & 0x01) ? "OneShot" : "Loop", - (flags & 0x02) ? "RootNoteValid" : "RootNoteInvalid", - (flags & 0x04) ? "StretchOn" : "StretchOff", - (flags & 0x08) ? "DiskBased" : "RAMBased", - (flags & 0x10) ? "??On" : "??Off") ; - - psf_log_printf (psf, " Root note : 0x%x\n ???? : 0x%04x\n ???? : %s\n", - rootnote, q1, buffer) ; - - bytesread += psf_binheader_readf (psf, "422f", &beats, &meter_denom, &meter_numer, &tempo) ; - snprintf (buffer, sizeof (buffer), "%f", tempo) ; - psf_log_printf (psf, " Beats : %d\n Meter : %d/%d\n Tempo : %s\n", - beats, meter_numer, meter_denom, buffer) ; - - psf_binheader_readf (psf, "j", chunklen - bytesread) ; - - if (psf->loop_info) - { psf_log_printf (psf, " Found existing loop info, using last one.\n") ; - free (psf->loop_info) ; - psf->loop_info = NULL ; - } ; - if ((psf->loop_info = calloc (1, sizeof (SF_LOOP_INFO))) == NULL) - return SFE_MALLOC_FAILED ; - - psf->loop_info->time_sig_num = meter_numer ; - psf->loop_info->time_sig_den = meter_denom ; - psf->loop_info->loop_mode = (flags & 0x01) ? SF_LOOP_NONE : SF_LOOP_FORWARD ; - psf->loop_info->num_beats = beats ; - psf->loop_info->bpm = tempo ; - psf->loop_info->root_key = (flags & 0x02) ? rootnote : -1 ; - - return 0 ; -} /* wav_read_acid_chunk */ - -/*============================================================================== -*/ - -static int -wav_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info) -{ return psf_save_write_chunk (&psf->wchunks, chunk_info) ; -} /* wav_set_chunk */ - -static SF_CHUNK_ITERATOR * -wav_next_chunk_iterator (SF_PRIVATE *psf, SF_CHUNK_ITERATOR * iterator) -{ return psf_next_chunk_iterator (&psf->rchunks, iterator) ; -} /* wav_next_chunk_iterator */ - -static int -wav_get_chunk_size (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ int indx ; - - if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) - return SFE_UNKNOWN_CHUNK ; - - chunk_info->datalen = psf->rchunks.chunks [indx].len ; - - return SFE_NO_ERROR ; -} /* wav_get_chunk_size */ - -static int -wav_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) -{ int indx ; - sf_count_t pos ; - - if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0) - return SFE_UNKNOWN_CHUNK ; - - if (chunk_info->data == NULL) - return SFE_BAD_CHUNK_DATA_PTR ; - - chunk_info->id_size = psf->rchunks.chunks [indx].id_size ; - memcpy (chunk_info->id, psf->rchunks.chunks [indx].id, sizeof (chunk_info->id) / sizeof (*chunk_info->id)) ; - - pos = psf_ftell (psf) ; - psf_fseek (psf, psf->rchunks.chunks [indx].offset, SEEK_SET) ; - psf_fread (chunk_info->data, SF_MIN (chunk_info->datalen, psf->rchunks.chunks [indx].len), 1, psf) ; - psf_fseek (psf, pos, SEEK_SET) ; - - return SFE_NO_ERROR ; -} /* wav_get_chunk_data */ diff --git a/Engine/lib/libsndfile/src/wavlike.c b/Engine/lib/libsndfile/src/wavlike.c deleted file mode 100644 index 7acdc80e7..000000000 --- a/Engine/lib/libsndfile/src/wavlike.c +++ /dev/null @@ -1,1371 +0,0 @@ -/* -** Copyright (C) 1999-2020 Erik de Castro Lopo -** Copyright (C) 2004-2005 David Viens -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" -#include "wavlike.h" - - -#define WAV_BEXT_MIN_CHUNK_SIZE 602 -#define WAV_BEXT_MAX_CHUNK_SIZE (10 * 1024) - -#define WAV_CART_MIN_CHUNK_SIZE 2048 -#define WAV_CART_MAX_CHUNK_SIZE 0xffffffff - - -static int exif_subchunk_parse (SF_PRIVATE *psf, uint32_t length) ; - - -/* Known WAVEFORMATEXTENSIBLE GUIDS. */ -static const EXT_SUBFORMAT MSGUID_SUBTYPE_PCM = -{ 0x00000001, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_MS_ADPCM = -{ 0x00000002, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_IEEE_FLOAT = -{ 0x00000003, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_ALAW = -{ 0x00000006, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_MULAW = -{ 0x00000007, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } -} ; - -/* -** the next two are from -** http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html -*/ - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM = -{ 0x00000001, 0x0721, 0x11d3, { 0x86, 0x44, 0xc8, 0xc1, 0xca, 0x00, 0x00, 0x00 } -} ; - -static const EXT_SUBFORMAT MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT = -{ 0x00000003, 0x0721, 0x11d3, { 0x86, 0x44, 0xc8, 0xc1, 0xca, 0x00, 0x00, 0x00 } -} ; - - -#if 0 -/* maybe interesting one day to read the following through sf_read_raw */ -/* http://www.bath.ac.uk/~masrwd/pvocex/pvocex.html */ -static const EXT_SUBFORMAT MSGUID_SUBTYPE_PVOCEX = -{ 0x8312b9c2, 0x2e6e, 0x11d4, { 0xa8, 0x24, 0xde, 0x5b, 0x96, 0xc3, 0xab, 0x21 } -} ; -#endif - -/* This stores which bit in dwChannelMask maps to which channel */ -static const struct chanmap_s -{ int id ; - const char * name ; -} channel_mask_bits [] = -{ /* WAVEFORMATEXTENSIBLE doesn't distuingish FRONT_LEFT from LEFT */ - { SF_CHANNEL_MAP_LEFT, "L" }, - { SF_CHANNEL_MAP_RIGHT, "R" }, - { SF_CHANNEL_MAP_CENTER, "C" }, - { SF_CHANNEL_MAP_LFE, "LFE" }, - { SF_CHANNEL_MAP_REAR_LEFT, "Ls" }, - { SF_CHANNEL_MAP_REAR_RIGHT, "Rs" }, - { SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, "Lc" }, - { SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, "Rc" }, - { SF_CHANNEL_MAP_REAR_CENTER, "Cs" }, - { SF_CHANNEL_MAP_SIDE_LEFT, "Sl" }, - { SF_CHANNEL_MAP_SIDE_RIGHT, "Sr" }, - { SF_CHANNEL_MAP_TOP_CENTER, "Tc" }, - { SF_CHANNEL_MAP_TOP_FRONT_LEFT, "Tfl" }, - { SF_CHANNEL_MAP_TOP_FRONT_CENTER, "Tfc" }, - { SF_CHANNEL_MAP_TOP_FRONT_RIGHT, "Tfr" }, - { SF_CHANNEL_MAP_TOP_REAR_LEFT, "Trl" }, - { SF_CHANNEL_MAP_TOP_REAR_CENTER, "Trc" }, - { SF_CHANNEL_MAP_TOP_REAR_RIGHT, "Trr" }, -} ; - -/*------------------------------------------------------------------------------ - * Private static functions. - */ - -static int -wavex_guid_equal (const EXT_SUBFORMAT * first, const EXT_SUBFORMAT * second) -{ return !memcmp (first, second, sizeof (EXT_SUBFORMAT)) ; -} /* wavex_guid_equal */ - - - -int -wavlike_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) -{ WAVLIKE_PRIVATE * wpriv ; - WAV_FMT *wav_fmt ; - int bytesread, k, bytespersec = 0 ; - - if ((wpriv = psf->container_data) == NULL) - return SFE_INTERNAL ; - wav_fmt = &wpriv->wav_fmt ; - - memset (wav_fmt, 0, sizeof (WAV_FMT)) ; - - if (fmtsize < 16) - return SFE_WAV_FMT_SHORT ; - - /* assume psf->rwf_endian is already properly set */ - - /* Read the minimal WAV file header here. */ - bytesread = psf_binheader_readf (psf, "224422", - &(wav_fmt->format), &(wav_fmt->min.channels), - &(wav_fmt->min.samplerate), &(wav_fmt->min.bytespersec), - &(wav_fmt->min.blockalign), &(wav_fmt->min.bitwidth)) ; - - psf_log_printf (psf, " Format : 0x%X => %s\n", wav_fmt->format, wavlike_format_str (wav_fmt->format)) ; - psf_log_printf (psf, " Channels : %d\n", wav_fmt->min.channels) ; - psf_log_printf (psf, " Sample Rate : %d\n", wav_fmt->min.samplerate) ; - - if (wav_fmt->format == WAVE_FORMAT_PCM && wav_fmt->min.blockalign == 0 - && wav_fmt->min.bitwidth > 0 && wav_fmt->min.channels > 0) - { wav_fmt->min.blockalign = wav_fmt->min.bitwidth / 8 + (wav_fmt->min.bitwidth % 8 > 0 ? 1 : 0) ; - wav_fmt->min.blockalign *= wav_fmt->min.channels ; - psf_log_printf (psf, " Block Align : 0 (should be %d)\n", wav_fmt->min.blockalign) ; - } - else - psf_log_printf (psf, " Block Align : %d\n", wav_fmt->min.blockalign) ; - - if (wav_fmt->format == WAVE_FORMAT_PCM && wav_fmt->min.bitwidth == 24 && - wav_fmt->min.blockalign == 4 * wav_fmt->min.channels) - { psf_log_printf (psf, " Bit Width : 24\n") ; - - psf_log_printf (psf, "\n" - " Ambiguous information in 'fmt ' chunk. Possibile file types:\n" - " 0) Invalid IEEE float file generated by Syntrillium's Cooledit!\n" - " 1) File generated by ALSA's arecord containing 24 bit samples in 32 bit containers.\n" - " 2) 24 bit file with incorrect Block Align value.\n" - "\n") ; - - wpriv->fmt_is_broken = 1 ; - } - else if (wav_fmt->min.bitwidth == 0) - { switch (wav_fmt->format) - { case WAVE_FORMAT_GSM610 : - case WAVE_FORMAT_IPP_ITU_G_723_1 : - case WAVE_FORMAT_MPEGLAYER3 : - psf_log_printf (psf, " Bit Width : %d\n", wav_fmt->min.bitwidth) ; - break ; - default : - psf_log_printf (psf, " Bit Width : %d (should not be 0)\n", wav_fmt->min.bitwidth) ; - } - } - else - { switch (wav_fmt->format) - { case WAVE_FORMAT_GSM610 : - case WAVE_FORMAT_IPP_ITU_G_723_1 : - case WAVE_FORMAT_MPEGLAYER3 : - psf_log_printf (psf, " Bit Width : %d (should be 0)\n", wav_fmt->min.bitwidth) ; - break ; - default : - psf_log_printf (psf, " Bit Width : %d\n", wav_fmt->min.bitwidth) ; - } - } ; - - psf->sf.samplerate = wav_fmt->min.samplerate ; - psf->sf.frames = 0 ; /* Correct this when reading data chunk. */ - psf->sf.channels = wav_fmt->min.channels ; - - switch (wav_fmt->format) - { case WAVE_FORMAT_PCM : - case WAVE_FORMAT_IEEE_FLOAT : - bytespersec = wav_fmt->min.samplerate * wav_fmt->min.blockalign ; - if (wav_fmt->min.bytespersec != (unsigned) bytespersec) - psf_log_printf (psf, " Bytes/sec : %d (should be %d)\n", wav_fmt->min.bytespersec, bytespersec) ; - else - psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->min.bytespersec) ; - - psf->bytewidth = BITWIDTH2BYTES (wav_fmt->min.bitwidth) ; - break ; - - case WAVE_FORMAT_ALAW : - case WAVE_FORMAT_MULAW : - if (wav_fmt->min.bytespersec != wav_fmt->min.samplerate * wav_fmt->min.blockalign) - psf_log_printf (psf, " Bytes/sec : %d (should be %d)\n", wav_fmt->min.bytespersec, wav_fmt->min.samplerate * wav_fmt->min.blockalign) ; - else - psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->min.bytespersec) ; - - psf->bytewidth = 1 ; - if (fmtsize >= 18) - { bytesread += psf_binheader_readf (psf, "2", &(wav_fmt->size20.extrabytes)) ; - psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->size20.extrabytes) ; - } ; - break ; - - case WAVE_FORMAT_IMA_ADPCM : - if (wav_fmt->min.bitwidth != 4) - return SFE_WAV_ADPCM_NOT4BIT ; - if (wav_fmt->min.channels < 1 || wav_fmt->min.channels > 2) - return SFE_WAV_ADPCM_CHANNELS ; - - bytesread += psf_binheader_readf (psf, "22", &(wav_fmt->ima.extrabytes), &(wav_fmt->ima.samplesperblock)) ; - psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->ima.extrabytes) ; - if (wav_fmt->ima.samplesperblock < 1) - { psf_log_printf (psf, " Samples/Block : %d (should be > 0)\n", wav_fmt->ima.samplesperblock) ; - return SFE_WAV_ADPCM_SAMPLES ; - } - else - psf_log_printf (psf, " Samples/Block : %d\n", wav_fmt->ima.samplesperblock) ; - - bytespersec = (wav_fmt->ima.samplerate * wav_fmt->ima.blockalign) / wav_fmt->ima.samplesperblock ; - if (wav_fmt->ima.bytespersec != (unsigned) bytespersec) - psf_log_printf (psf, " Bytes/sec : %d (should be %d)\n", wav_fmt->ima.bytespersec, bytespersec) ; - else - psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->ima.bytespersec) ; - - break ; - - case WAVE_FORMAT_MS_ADPCM : - if (wav_fmt->msadpcm.bitwidth != 4) - return SFE_WAV_ADPCM_NOT4BIT ; - if (wav_fmt->msadpcm.channels < 1 || wav_fmt->msadpcm.channels > 2) - return SFE_WAV_ADPCM_CHANNELS ; - - bytesread += psf_binheader_readf (psf, "222", &(wav_fmt->msadpcm.extrabytes), - &(wav_fmt->msadpcm.samplesperblock), &(wav_fmt->msadpcm.numcoeffs)) ; - - psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->msadpcm.extrabytes) ; - if (wav_fmt->ima.samplesperblock < 1) - { psf_log_printf (psf, " Samples/Block : %d (should be > 0)\n", wav_fmt->ima.samplesperblock) ; - return SFE_WAV_ADPCM_SAMPLES ; - } - else - psf_log_printf (psf, " Samples/Block : %d\n", wav_fmt->ima.samplesperblock) ; - - bytespersec = (wav_fmt->min.samplerate * wav_fmt->min.blockalign) / wav_fmt->msadpcm.samplesperblock ; - if (wav_fmt->min.bytespersec == (unsigned) bytespersec) - psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->min.bytespersec) ; - else if (wav_fmt->min.bytespersec == (wav_fmt->min.samplerate / wav_fmt->msadpcm.samplesperblock) * wav_fmt->min.blockalign) - psf_log_printf (psf, " Bytes/sec : %d (should be %d (MS BUG!))\n", wav_fmt->min.bytespersec, bytespersec) ; - else - psf_log_printf (psf, " Bytes/sec : %d (should be %d)\n", wav_fmt->min.bytespersec, bytespersec) ; - - if (wav_fmt->msadpcm.numcoeffs > ARRAY_LEN (wav_fmt->msadpcm.coeffs)) - { psf_log_printf (psf, " No. of Coeffs : %d (should be <= %d)\n", wav_fmt->msadpcm.numcoeffs, ARRAY_LEN (wav_fmt->msadpcm.coeffs)) ; - wav_fmt->msadpcm.numcoeffs = ARRAY_LEN (wav_fmt->msadpcm.coeffs) ; - } - else - psf_log_printf (psf, " No. of Coeffs : %d\n", wav_fmt->msadpcm.numcoeffs) ; - - psf_log_printf (psf, " Index Coeffs1 Coeffs2\n") ; - for (k = 0 ; k < wav_fmt->msadpcm.numcoeffs ; k++) - { char buffer [128] ; - - bytesread += - psf_binheader_readf (psf, "22", &(wav_fmt->msadpcm.coeffs [k].coeff1), &(wav_fmt->msadpcm.coeffs [k].coeff2)) ; - snprintf (buffer, sizeof (buffer), " %2d %7d %7d\n", k, wav_fmt->msadpcm.coeffs [k].coeff1, wav_fmt->msadpcm.coeffs [k].coeff2) ; - psf_log_printf (psf, buffer) ; - } ; - break ; - - case WAVE_FORMAT_GSM610 : - if (wav_fmt->gsm610.channels != 1 || wav_fmt->gsm610.blockalign != 65) - return SFE_WAV_GSM610_FORMAT ; - - bytesread += - psf_binheader_readf (psf, "22", &(wav_fmt->gsm610.extrabytes), &(wav_fmt->gsm610.samplesperblock)) ; - - if (wav_fmt->gsm610.samplesperblock != 320) - return SFE_WAV_GSM610_FORMAT ; - - bytespersec = (wav_fmt->gsm610.samplerate * wav_fmt->gsm610.blockalign) / wav_fmt->gsm610.samplesperblock ; - if (wav_fmt->gsm610.bytespersec != (unsigned) bytespersec) - psf_log_printf (psf, " Bytes/sec : %d (should be %d)\n", wav_fmt->gsm610.bytespersec, bytespersec) ; - else - psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->gsm610.bytespersec) ; - - psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->gsm610.extrabytes) ; - psf_log_printf (psf, " Samples/Block : %d\n", wav_fmt->gsm610.samplesperblock) ; - break ; - - case WAVE_FORMAT_MPEGLAYER3 : - bytesread += psf_binheader_readf (psf, "24222", &(wav_fmt->mpeg3.extrabytes), - &(wav_fmt->mpeg3.id), &(wav_fmt->mpeg3.flags), &(wav_fmt->mpeg3.blocksize), - &(wav_fmt->mpeg3.samplesperblock), &(wav_fmt->mpeg3.codecdelay)) ; - - psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->mpeg3.bytespersec) ; - psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->mpeg3.extrabytes) ; - if (wav_fmt->mpeg3.id != 1) - psf_log_printf (psf, " ID : %d (unknown, should be 1)\n", wav_fmt->mpeg3.id) ; - else - psf_log_printf (psf, " ID : MPEGLAYER3_ID_MPEG\n") ; - psf_log_printf (psf, " Flags : 0x%08x\n", wav_fmt->mpeg3.flags) ; - psf_log_printf (psf, " Block Size : %d\n", wav_fmt->mpeg3.blocksize) ; - psf_log_printf (psf, " Samples/Block : %d\n", wav_fmt->mpeg3.samplesperblock) ; - psf_log_printf (psf, " Codec Delay : %d samples\n", wav_fmt->mpeg3.codecdelay) ; - break ; - - case WAVE_FORMAT_EXTENSIBLE : - if (wav_fmt->ext.bytespersec != wav_fmt->ext.samplerate * wav_fmt->ext.blockalign) - psf_log_printf (psf, " Bytes/sec : %d (should be %d)\n", wav_fmt->ext.bytespersec, wav_fmt->ext.samplerate * wav_fmt->ext.blockalign) ; - else - psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->ext.bytespersec) ; - - bytesread += - psf_binheader_readf (psf, "224", &(wav_fmt->ext.extrabytes), &(wav_fmt->ext.validbits), - &(wav_fmt->ext.channelmask)) ; - - psf_log_printf (psf, " Valid Bits : %d\n", wav_fmt->ext.validbits) ; - - if (wav_fmt->ext.channelmask == 0) - psf_log_printf (psf, " Channel Mask : 0x0 (should not be zero)\n") ; - else - { char buffer [512] ; - unsigned bit ; - - wpriv->wavex_channelmask = wav_fmt->ext.channelmask ; - - /* It's probably wise to ignore the channel mask if it is all zero */ - free (psf->channel_map) ; - - if ((psf->channel_map = calloc (psf->sf.channels, sizeof (psf->channel_map [0]))) == NULL) - return SFE_MALLOC_FAILED ; - - /* Terminate the buffer we're going to append_snprintf into. */ - buffer [0] = 0 ; - - for (bit = k = 0 ; bit < ARRAY_LEN (channel_mask_bits) && k < psf->sf.channels ; bit++) - { - if (wav_fmt->ext.channelmask & (1 << bit)) - { if (k > psf->sf.channels) - { psf_log_printf (psf, "*** More channel map bits than there are channels.\n") ; - break ; - } ; - - psf->channel_map [k++] = channel_mask_bits [bit].id ; - append_snprintf (buffer, sizeof (buffer), "%s, ", channel_mask_bits [bit].name) ; - } ; - } ; - - /* Remove trailing ", ". */ - bit = strlen (buffer) ; - if (bit >= 2) - { buffer [--bit] = 0 ; - buffer [--bit] = 0 ; - } ; - - if (k != psf->sf.channels) - { psf_log_printf (psf, " Channel Mask : 0x%X\n", wav_fmt->ext.channelmask) ; - psf_log_printf (psf, "*** Less channel map bits than there are channels.\n") ; - } - else - psf_log_printf (psf, " Channel Mask : 0x%X (%s)\n", wav_fmt->ext.channelmask, buffer) ; - } ; - - bytesread += psf_binheader_readf (psf, "422", &(wav_fmt->ext.esf.esf_field1), &(wav_fmt->ext.esf.esf_field2), &(wav_fmt->ext.esf.esf_field3)) ; - - /* compare the esf_fields with each known GUID? and print? */ - psf_log_printf (psf, " Subformat\n") ; - psf_log_printf (psf, " esf_field1 : 0x%X\n", wav_fmt->ext.esf.esf_field1) ; - psf_log_printf (psf, " esf_field2 : 0x%X\n", wav_fmt->ext.esf.esf_field2) ; - psf_log_printf (psf, " esf_field3 : 0x%X\n", wav_fmt->ext.esf.esf_field3) ; - psf_log_printf (psf, " esf_field4 : ") ; - for (k = 0 ; k < 8 ; k++) - { bytesread += psf_binheader_readf (psf, "1", &(wav_fmt->ext.esf.esf_field4 [k])) ; - psf_log_printf (psf, "0x%X ", wav_fmt->ext.esf.esf_field4 [k] & 0xFF) ; - } ; - psf_log_printf (psf, "\n") ; - psf->bytewidth = BITWIDTH2BYTES (wav_fmt->ext.bitwidth) ; - - /* Compare GUIDs for known ones. */ - if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_PCM)) - { psf->sf.format = SF_FORMAT_WAVEX | u_bitwidth_to_subformat (psf->bytewidth * 8) ; - psf_log_printf (psf, " format : pcm\n") ; - } - else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_MS_ADPCM)) - { psf->sf.format = (SF_FORMAT_WAVEX | SF_FORMAT_MS_ADPCM) ; - psf_log_printf (psf, " format : ms adpcm\n") ; - } - else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_IEEE_FLOAT)) - { psf->sf.format = SF_FORMAT_WAVEX | ((psf->bytewidth == 8) ? SF_FORMAT_DOUBLE : SF_FORMAT_FLOAT) ; - psf_log_printf (psf, " format : IEEE float\n") ; - } - else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_ALAW)) - { psf->sf.format = (SF_FORMAT_WAVEX | SF_FORMAT_ALAW) ; - psf_log_printf (psf, " format : A-law\n") ; - } - else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_MULAW)) - { psf->sf.format = (SF_FORMAT_WAVEX | SF_FORMAT_ULAW) ; - psf_log_printf (psf, " format : u-law\n") ; - } - else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM)) - { psf->sf.format = SF_FORMAT_WAVEX | u_bitwidth_to_subformat (psf->bytewidth * 8) ; - psf_log_printf (psf, " format : pcm (Ambisonic B)\n") ; - wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ; - } - else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT)) - { psf->sf.format = SF_FORMAT_WAVEX | ((psf->bytewidth == 8) ? SF_FORMAT_DOUBLE : SF_FORMAT_FLOAT) ; - psf_log_printf (psf, " format : IEEE float (Ambisonic B)\n") ; - wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ; - } - else - return SFE_UNIMPLEMENTED ; - - break ; - - case WAVE_FORMAT_G721_ADPCM : - psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->g72x.bytespersec) ; - if (fmtsize >= 20) - { bytesread += psf_binheader_readf (psf, "22", &(wav_fmt->g72x.extrabytes), &(wav_fmt->g72x.auxblocksize)) ; - if (wav_fmt->g72x.extrabytes == 0) - psf_log_printf (psf, " Extra Bytes : %d (should be 2)\n", wav_fmt->g72x.extrabytes) ; - else - psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->g72x.extrabytes) ; - psf_log_printf (psf, " Aux Blk Size : %d\n", wav_fmt->g72x.auxblocksize) ; - } - else if (fmtsize == 18) - { bytesread += psf_binheader_readf (psf, "2", &(wav_fmt->g72x.extrabytes)) ; - psf_log_printf (psf, " Extra Bytes : %d%s\n", wav_fmt->g72x.extrabytes, wav_fmt->g72x.extrabytes != 0 ? " (should be 0)" : "") ; - } - else - psf_log_printf (psf, "*** 'fmt ' chunk should be bigger than this!\n") ; - break ; - - case WAVE_FORMAT_NMS_VBXADPCM : - if (wav_fmt->min.channels != 1 || wav_fmt->min.bitwidth < 2 || wav_fmt->min.bitwidth * 20 + 2 != wav_fmt->min.blockalign) - return SFE_WAV_NMS_FORMAT ; - - bytespersec = (wav_fmt->min.samplerate * wav_fmt->min.blockalign) / 160 ; - if (wav_fmt->min.bytespersec == (unsigned) bytespersec) - psf_log_printf (psf, " Bytes/sec : %d\n", wav_fmt->min.bytespersec) ; - else - psf_log_printf (psf, " Bytes/sec : %d (should be %d)\n", wav_fmt->min.bytespersec, bytespersec) ; - if (fmtsize >= 18) - { bytesread += psf_binheader_readf (psf, "2", &(wav_fmt->size20.extrabytes)) ; - psf_log_printf (psf, " Extra Bytes : %d\n", wav_fmt->size20.extrabytes) ; - } ; - break ; - - default : - psf_log_printf (psf, "*** No 'fmt ' chunk dumper for this format!\n") ; - return SFE_WAV_BAD_FMT ; - } ; - - if (bytesread > fmtsize) - { psf_log_printf (psf, "*** wavlike_read_fmt_chunk (bytesread > fmtsize)\n") ; - return SFE_WAV_BAD_FMT ; - } - else - psf_binheader_readf (psf, "j", fmtsize - bytesread) ; - - psf->blockwidth = wav_fmt->min.channels * psf->bytewidth ; - - return 0 ; -} /* wavlike_read_fmt_chunk */ - -void -wavlike_write_guid (SF_PRIVATE *psf, const EXT_SUBFORMAT * subformat) -{ - psf_binheader_writef (psf, "422b", BHW4 (subformat->esf_field1), - BHW2 (subformat->esf_field2), BHW2 (subformat->esf_field3), - BHWv (subformat->esf_field4), BHWz (8)) ; -} /* wavlike_write_guid */ - - -int -wavlike_gen_channel_mask (const int *chan_map, int channels) -{ int chan, mask = 0, bit = -1, last_bit = -1 ; - - if (chan_map == NULL) - return 0 ; - - for (chan = 0 ; chan < channels ; chan ++) - { int k ; - - for (k = bit + 1 ; k < ARRAY_LEN (channel_mask_bits) ; k++) - if (chan_map [chan] == channel_mask_bits [k].id) - { bit = k ; - break ; - } ; - - /* Check for bad sequence. */ - if (bit <= last_bit) - return 0 ; - - mask += 1 << bit ; - last_bit = bit ; - } ; - - return mask ; -} /* wavlike_gen_channel_mask */ - -void -wavlike_analyze (SF_PRIVATE *psf) -{ unsigned char buffer [4096] ; - AUDIO_DETECT ad ; - int format = 0 ; - - if (psf->is_pipe) - { psf_log_printf (psf, "*** Error : Reading from a pipe. Can't analyze data section to figure out real data format.\n\n") ; - return ; - } ; - - psf_log_printf (psf, "---------------------------------------------------\n" - "Format is known to be broken. Using detection code.\n") ; - - /* Code goes here. */ - ad.endianness = SF_ENDIAN_LITTLE ; - ad.channels = psf->sf.channels ; - - psf_fseek (psf, 3 * 4 * 50, SEEK_SET) ; - - while (psf_fread (buffer, 1, sizeof (buffer), psf) == sizeof (buffer)) - { format = audio_detect (psf, &ad, buffer, sizeof (buffer)) ; - if (format != 0) - break ; - } ; - - /* Seek to start of DATA section. */ - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - if (format == 0) - { psf_log_printf (psf, "wavlike_analyze : detection failed.\n") ; - return ; - } ; - - switch (format) - { case SF_FORMAT_PCM_32 : - case SF_FORMAT_FLOAT : - psf_log_printf (psf, "wavlike_analyze : found format : 0x%X\n", format) ; - psf->sf.format = (psf->sf.format & ~SF_FORMAT_SUBMASK) + format ; - psf->bytewidth = 4 ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - break ; - - case SF_FORMAT_PCM_24 : - psf_log_printf (psf, "wavlike_analyze : found format : 0x%X\n", format) ; - psf->sf.format = (psf->sf.format & ~SF_FORMAT_SUBMASK) + format ; - psf->bytewidth = 3 ; - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - break ; - - default : - psf_log_printf (psf, "wavlike_analyze : unhandled format : 0x%X\n", format) ; - break ; - } ; - - return ; -} /* wavlike_analyze */ - -/*============================================================================== -*/ - -typedef struct -{ int ID ; - const char *name ; -} WAV_FORMAT_DESC ; - -#define STR(x) #x -#define FORMAT_TYPE(x) { x, STR (x) } - -static WAV_FORMAT_DESC wave_descs [] = -{ FORMAT_TYPE (WAVE_FORMAT_PCM), - FORMAT_TYPE (WAVE_FORMAT_MS_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_IEEE_FLOAT), - FORMAT_TYPE (WAVE_FORMAT_VSELP), - FORMAT_TYPE (WAVE_FORMAT_IBM_CVSD), - FORMAT_TYPE (WAVE_FORMAT_ALAW), - FORMAT_TYPE (WAVE_FORMAT_MULAW), - FORMAT_TYPE (WAVE_FORMAT_OKI_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_IMA_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_MEDIASPACE_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_SIERRA_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_G723_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_DIGISTD), - FORMAT_TYPE (WAVE_FORMAT_DIGIFIX), - FORMAT_TYPE (WAVE_FORMAT_DIALOGIC_OKI_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_MEDIAVISION_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_CU_CODEC), - FORMAT_TYPE (WAVE_FORMAT_YAMAHA_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_SONARC), - FORMAT_TYPE (WAVE_FORMAT_DSPGROUP_TRUESPEECH), - FORMAT_TYPE (WAVE_FORMAT_ECHOSC1), - FORMAT_TYPE (WAVE_FORMAT_AUDIOFILE_AF36), - FORMAT_TYPE (WAVE_FORMAT_APTX), - FORMAT_TYPE (WAVE_FORMAT_AUDIOFILE_AF10), - FORMAT_TYPE (WAVE_FORMAT_PROSODY_1612), - FORMAT_TYPE (WAVE_FORMAT_LRC), - FORMAT_TYPE (WAVE_FORMAT_DOLBY_AC2), - FORMAT_TYPE (WAVE_FORMAT_GSM610), - FORMAT_TYPE (WAVE_FORMAT_MSNAUDIO), - FORMAT_TYPE (WAVE_FORMAT_ANTEX_ADPCME), - FORMAT_TYPE (WAVE_FORMAT_CONTROL_RES_VQLPC), - FORMAT_TYPE (WAVE_FORMAT_DIGIREAL), - FORMAT_TYPE (WAVE_FORMAT_DIGIADPCM), - FORMAT_TYPE (WAVE_FORMAT_CONTROL_RES_CR10), - FORMAT_TYPE (WAVE_FORMAT_NMS_VBXADPCM), - FORMAT_TYPE (WAVE_FORMAT_ROLAND_RDAC), - FORMAT_TYPE (WAVE_FORMAT_ECHOSC3), - FORMAT_TYPE (WAVE_FORMAT_ROCKWELL_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_ROCKWELL_DIGITALK), - FORMAT_TYPE (WAVE_FORMAT_XEBEC), - FORMAT_TYPE (WAVE_FORMAT_G721_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_G728_CELP), - FORMAT_TYPE (WAVE_FORMAT_MSG723), - FORMAT_TYPE (WAVE_FORMAT_MPEG), - FORMAT_TYPE (WAVE_FORMAT_RT24), - FORMAT_TYPE (WAVE_FORMAT_PAC), - FORMAT_TYPE (WAVE_FORMAT_MPEGLAYER3), - FORMAT_TYPE (WAVE_FORMAT_LUCENT_G723), - FORMAT_TYPE (WAVE_FORMAT_CIRRUS), - FORMAT_TYPE (WAVE_FORMAT_ESPCM), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE), - FORMAT_TYPE (WAVE_FORMAT_CANOPUS_ATRAC), - FORMAT_TYPE (WAVE_FORMAT_G726_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_G722_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_DSAT), - FORMAT_TYPE (WAVE_FORMAT_DSAT_DISPLAY), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_BYTE_ALIGNED), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_AC8), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_AC10), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_AC16), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_AC20), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_RT24), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_RT29), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_RT29HW), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_VR12), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_VR18), - FORMAT_TYPE (WAVE_FORMAT_VOXWARE_TQ40), - FORMAT_TYPE (WAVE_FORMAT_SOFTSOUND), - FORMAT_TYPE (WAVE_FORMAT_VOXARE_TQ60), - FORMAT_TYPE (WAVE_FORMAT_MSRT24), - FORMAT_TYPE (WAVE_FORMAT_G729A), - FORMAT_TYPE (WAVE_FORMAT_MVI_MV12), - FORMAT_TYPE (WAVE_FORMAT_DF_G726), - FORMAT_TYPE (WAVE_FORMAT_DF_GSM610), - FORMAT_TYPE (WAVE_FORMAT_ONLIVE), - FORMAT_TYPE (WAVE_FORMAT_SBC24), - FORMAT_TYPE (WAVE_FORMAT_DOLBY_AC3_SPDIF), - FORMAT_TYPE (WAVE_FORMAT_ZYXEL_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_PHILIPS_LPCBB), - FORMAT_TYPE (WAVE_FORMAT_PACKED), - FORMAT_TYPE (WAVE_FORMAT_RHETOREX_ADPCM), - FORMAT_TYPE (IBM_FORMAT_MULAW), - FORMAT_TYPE (IBM_FORMAT_ALAW), - FORMAT_TYPE (IBM_FORMAT_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_VIVO_G723), - FORMAT_TYPE (WAVE_FORMAT_VIVO_SIREN), - FORMAT_TYPE (WAVE_FORMAT_DIGITAL_G723), - FORMAT_TYPE (WAVE_FORMAT_CREATIVE_ADPCM), - FORMAT_TYPE (WAVE_FORMAT_CREATIVE_FASTSPEECH8), - FORMAT_TYPE (WAVE_FORMAT_CREATIVE_FASTSPEECH10), - FORMAT_TYPE (WAVE_FORMAT_QUARTERDECK), - FORMAT_TYPE (WAVE_FORMAT_FM_TOWNS_SND), - FORMAT_TYPE (WAVE_FORMAT_BZV_DIGITAL), - FORMAT_TYPE (WAVE_FORMAT_VME_VMPCM), - FORMAT_TYPE (WAVE_FORMAT_OLIGSM), - FORMAT_TYPE (WAVE_FORMAT_OLIADPCM), - FORMAT_TYPE (WAVE_FORMAT_OLICELP), - FORMAT_TYPE (WAVE_FORMAT_OLISBC), - FORMAT_TYPE (WAVE_FORMAT_OLIOPR), - FORMAT_TYPE (WAVE_FORMAT_LH_CODEC), - FORMAT_TYPE (WAVE_FORMAT_NORRIS), - FORMAT_TYPE (WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS), - FORMAT_TYPE (WAVE_FORMAT_DVM), - FORMAT_TYPE (WAVE_FORMAT_INTERWAV_VSC112), - FORMAT_TYPE (WAVE_FORMAT_IPP_ITU_G_723_1), - FORMAT_TYPE (WAVE_FORMAT_EXTENSIBLE), -} ; - -char const* -wavlike_format_str (int k) -{ int lower, upper, mid ; - - lower = -1 ; - upper = sizeof (wave_descs) / sizeof (WAV_FORMAT_DESC) ; - - /* binary search */ - if ((wave_descs [0].ID <= k) && (k <= wave_descs [upper - 1].ID)) - { - while (lower + 1 < upper) - { mid = (upper + lower) / 2 ; - - if (k == wave_descs [mid].ID) - return wave_descs [mid].name ; - if (k < wave_descs [mid].ID) - upper = mid ; - else - lower = mid ; - } ; - } ; - - return "Unknown format" ; -} /* wavlike_format_str */ - -int -wavlike_srate2blocksize (int srate_chan_product) -{ if (srate_chan_product < 12000) - return 256 ; - if (srate_chan_product < 23000) - return 512 ; - if (srate_chan_product < 44000) - return 1024 ; - return 2048 ; -} /* srate2blocksize */ - -int -wavlike_read_bext_chunk (SF_PRIVATE *psf, uint32_t chunksize) -{ - SF_BROADCAST_INFO_16K * b ; - uint32_t bytes = 0 ; - - if (chunksize < WAV_BEXT_MIN_CHUNK_SIZE) - { psf_log_printf (psf, "bext : %u (should be >= %d)\n", chunksize, WAV_BEXT_MIN_CHUNK_SIZE) ; - psf_binheader_readf (psf, "j", chunksize) ; - return 0 ; - } ; - - if (chunksize > WAV_BEXT_MAX_CHUNK_SIZE) - { psf_log_printf (psf, "bext : %u (should be < %d)\n", chunksize, WAV_BEXT_MAX_CHUNK_SIZE) ; - psf_binheader_readf (psf, "j", chunksize) ; - return 0 ; - } ; - - if (chunksize >= sizeof (SF_BROADCAST_INFO_16K)) - { psf_log_printf (psf, "bext : %u too big to be handled\n", chunksize) ; - psf_binheader_readf (psf, "j", chunksize) ; - return 0 ; - } ; - - psf_log_printf (psf, "bext : %u\n", chunksize) ; - - if (!psf->broadcast_16k) - { psf->broadcast_16k = broadcast_var_alloc () ; - if (!psf->broadcast_16k) - { psf->error = SFE_MALLOC_FAILED ; - return psf->error ; - } - } - else - { psf_log_printf (psf, "bext : found more than one bext chunk, using last one.\n") ; - memset (psf->broadcast_16k, 0, sizeof (SF_BROADCAST_INFO_16K)) ; - } - - b = psf->broadcast_16k ; - - bytes += psf_binheader_readf (psf, "b", b->description, sizeof (b->description)) ; - bytes += psf_binheader_readf (psf, "b", b->originator, sizeof (b->originator)) ; - bytes += psf_binheader_readf (psf, "b", b->originator_reference, sizeof (b->originator_reference)) ; - bytes += psf_binheader_readf (psf, "b", b->origination_date, sizeof (b->origination_date)) ; - bytes += psf_binheader_readf (psf, "b", b->origination_time, sizeof (b->origination_time)) ; - bytes += psf_binheader_readf (psf, "442", &b->time_reference_low, &b->time_reference_high, &b->version) ; - bytes += psf_binheader_readf (psf, "b", &b->umid, sizeof (b->umid)) ; - bytes += psf_binheader_readf (psf, "22", &b->loudness_value, &b->loudness_range) ; - bytes += psf_binheader_readf (psf, "222", &b->max_true_peak_level, &b->max_momentary_loudness, &b->max_shortterm_loudness) ; - bytes += psf_binheader_readf (psf, "j", 180) ; - - if (chunksize > WAV_BEXT_MIN_CHUNK_SIZE) - { /* File has coding history data. */ - - b->coding_history_size = chunksize - WAV_BEXT_MIN_CHUNK_SIZE ; - - /* We do not parse the coding history */ - bytes += psf_binheader_readf (psf, "b", BHWv (b->coding_history), BHWz (b->coding_history_size)) ; - } ; - - if (bytes < chunksize) - psf_binheader_readf (psf, "j", BHWj (chunksize - bytes)) ; - - return 0 ; -} /* wavlike_read_bext_chunk */ - -int -wavlike_write_bext_chunk (SF_PRIVATE *psf) -{ SF_BROADCAST_INFO_16K *b ; - - if (psf->broadcast_16k == NULL) - return -1 ; - - b = psf->broadcast_16k ; - - psf_binheader_writef (psf, "m4", BHWm (bext_MARKER), BHW4 (WAV_BEXT_MIN_CHUNK_SIZE + b->coding_history_size)) ; - - /* - ** Note that it is very important that the field widths of the SF_BROADCAST_INFO - ** struct match those of the bext chunk fields. - */ - - psf_binheader_writef (psf, "b", BHWv (b->description), BHWz (sizeof (b->description))) ; - psf_binheader_writef (psf, "b", BHWv (b->originator), BHWz (sizeof (b->originator))) ; - psf_binheader_writef (psf, "b", BHWv (b->originator_reference), BHWz (sizeof (b->originator_reference))) ; - psf_binheader_writef (psf, "b", BHWv (b->origination_date), BHWz (sizeof (b->origination_date))) ; - psf_binheader_writef (psf, "b", BHWv (b->origination_time), BHWz (sizeof (b->origination_time))) ; - psf_binheader_writef (psf, "442", BHW4 (b->time_reference_low), BHW4 (b->time_reference_high), BHW2 (b->version)) ; - psf_binheader_writef (psf, "b", BHWv (b->umid), BHWz (sizeof (b->umid))) ; - psf_binheader_writef (psf, "22", BHW2 (b->loudness_value), BHW2 (b->loudness_range)) ; - psf_binheader_writef (psf, "222", BHW2 (b->max_true_peak_level), BHW2 (b->max_momentary_loudness), BHW2 (b->max_shortterm_loudness)) ; - psf_binheader_writef (psf, "z", BHWz (180)) ; - - if (b->coding_history_size > 0) - psf_binheader_writef (psf, "b", BHWv (b->coding_history), BHWz (b->coding_history_size)) ; - - return 0 ; -} /* wavlike_write_bext_chunk */ - -int -wavlike_read_cart_chunk (SF_PRIVATE *psf, uint32_t chunksize) -{ SF_CART_INFO_16K *c ; - uint32_t bytes = 0 ; - int k ; - - if (chunksize < WAV_CART_MIN_CHUNK_SIZE) - { psf_log_printf (psf, "cart : %u (should be >= %d)\n", chunksize, WAV_CART_MIN_CHUNK_SIZE) ; - psf_binheader_readf (psf, "j", chunksize) ; - return 0 ; - } ; - if (chunksize > WAV_CART_MAX_CHUNK_SIZE) - { psf_log_printf (psf, "cart : %u (should be < %d)\n", chunksize, WAV_CART_MAX_CHUNK_SIZE) ; - psf_binheader_readf (psf, "j", chunksize) ; - return 0 ; - } ; - - /* - ** SF_CART_INFO_16K has an extra field 'tag_text_size' that isn't part - ** of the chunk, so don't include it in the size check. - */ - if (chunksize >= sizeof (SF_CART_INFO_16K) - 4) - { psf_log_printf (psf, "cart : %u too big to be handled\n", chunksize) ; - psf_binheader_readf (psf, "j", chunksize) ; - return 0 ; - } ; - - psf_log_printf (psf, "cart : %u\n", chunksize) ; - - if (psf->cart_16k) - { psf_log_printf (psf, " Found more than one cart chunk, using last one.\n") ; - free (psf->cart_16k) ; - psf->cart_16k = NULL ; - } ; - - if ((psf->cart_16k = cart_var_alloc ()) == NULL) - { psf->error = SFE_MALLOC_FAILED ; - return psf->error ; - } ; - - c = psf->cart_16k ; - bytes += psf_binheader_readf (psf, "b", c->version, sizeof (c->version)) ; - bytes += psf_binheader_readf (psf, "b", c->title, sizeof (c->title)) ; - bytes += psf_binheader_readf (psf, "b", c->artist, sizeof (c->artist)) ; - bytes += psf_binheader_readf (psf, "b", c->cut_id, sizeof (c->cut_id)) ; - bytes += psf_binheader_readf (psf, "b", c->client_id, sizeof (c->client_id)) ; - bytes += psf_binheader_readf (psf, "b", c->category, sizeof (c->category)) ; - bytes += psf_binheader_readf (psf, "b", c->classification, sizeof (c->classification)) ; - bytes += psf_binheader_readf (psf, "b", c->out_cue, sizeof (c->out_cue)) ; - bytes += psf_binheader_readf (psf, "b", c->start_date, sizeof (c->start_date)) ; - bytes += psf_binheader_readf (psf, "b", c->start_time, sizeof (c->start_time)) ; - bytes += psf_binheader_readf (psf, "b", c->end_date, sizeof (c->end_date)) ; - bytes += psf_binheader_readf (psf, "b", c->end_time, sizeof (c->end_time)) ; - bytes += psf_binheader_readf (psf, "b", c->producer_app_id, sizeof (c->producer_app_id)) ; - bytes += psf_binheader_readf (psf, "b", c->producer_app_version, sizeof (c->producer_app_version)) ; - bytes += psf_binheader_readf (psf, "b", c->user_def, sizeof (c->user_def)) ; - bytes += psf_binheader_readf (psf, "e4", &c->level_reference, sizeof (c->level_reference)) ; - - for (k = 0 ; k < ARRAY_LEN (c->post_timers) ; k++) - bytes += psf_binheader_readf (psf, "b4", &c->post_timers [k].usage, make_size_t (4), &c->post_timers [k].value) ; - - bytes += psf_binheader_readf (psf, "b", c->reserved, sizeof (c->reserved)) ; - bytes += psf_binheader_readf (psf, "b", c->url, sizeof (c->url)) ; - - if (chunksize > WAV_CART_MIN_CHUNK_SIZE) - { /* File has tag text. */ - c->tag_text_size = chunksize - WAV_CART_MIN_CHUNK_SIZE ; - bytes += psf_binheader_readf (psf, "b", c->tag_text, make_size_t (c->tag_text_size)) ; - } ; - - if (bytes < chunksize) - psf_log_printf (psf, " %d trailing bytes in cart chunk.\n", chunksize - bytes) ; - - return 0 ; -} /* wavlike_read_cart_chunk */ - -int -wavlike_write_cart_chunk (SF_PRIVATE *psf) -{ SF_CART_INFO_16K *c ; - int k ; - - if (psf->cart_16k == NULL) - return -1 ; - - c = psf->cart_16k ; - psf_binheader_writef (psf, "m4", BHWm (cart_MARKER), BHW4 (WAV_CART_MIN_CHUNK_SIZE + c->tag_text_size)) ; - /* - ** Note that it is very important that the field widths of the SF_CART_INFO - ** struct match those of the cart chunk fields. - */ - psf_binheader_writef (psf, "b", BHWv (c->version), BHWz (sizeof (c->version))) ; - psf_binheader_writef (psf, "b", BHWv (c->title), BHWz (sizeof (c->title))) ; - psf_binheader_writef (psf, "b", BHWv (c->artist), BHWz (sizeof (c->artist))) ; - psf_binheader_writef (psf, "b", BHWv (c->cut_id), BHWz (sizeof (c->cut_id))) ; - psf_binheader_writef (psf, "b", BHWv (c->client_id), BHWz (sizeof (c->client_id))) ; - psf_binheader_writef (psf, "b", BHWv (c->category), BHWz (sizeof (c->category))) ; - psf_binheader_writef (psf, "b", BHWv (c->classification), BHWz (sizeof (c->classification))) ; - psf_binheader_writef (psf, "b", BHWv (c->out_cue), BHWz (sizeof (c->out_cue))) ; - psf_binheader_writef (psf, "b", BHWv (c->start_date), BHWz (sizeof (c->start_date))) ; - psf_binheader_writef (psf, "b", BHWv (c->start_time), BHWz (sizeof (c->start_time))) ; - psf_binheader_writef (psf, "b", BHWv (c->end_date), BHWz (sizeof (c->end_date))) ; - psf_binheader_writef (psf, "b", BHWv (c->end_time), BHWz (sizeof (c->end_time))) ; - psf_binheader_writef (psf, "b", BHWv (c->producer_app_id), BHWz (sizeof (c->producer_app_id))) ; - psf_binheader_writef (psf, "b", BHWv (c->producer_app_version), BHWz (sizeof (c->producer_app_version))) ; - psf_binheader_writef (psf, "b", BHWv (c->user_def), BHWz (sizeof (c->user_def))) ; - psf_binheader_writef (psf, "e4", BHW4 (c->level_reference)) ; - - for (k = 0 ; k < ARRAY_LEN (c->post_timers) ; k++) - psf_binheader_writef (psf, "b4", BHWv (c->post_timers [k].usage), BHWz (4), BHW4 (c->post_timers [k].value)) ; - - psf_binheader_writef (psf, "z", BHWz (sizeof (c->reserved))) ; // just write zeros, we don't have any other use for it - psf_binheader_writef (psf, "b", BHWv (c->url), BHWz (sizeof (c->url))) ; - - if (c->tag_text_size > 0) - psf_binheader_writef (psf, "b", BHWv (c->tag_text), BHWz (c->tag_text_size)) ; - - return 0 ; -} /* wavlike_write_cart_chunk */ - -int -wavlike_subchunk_parse (SF_PRIVATE *psf, int chunk, uint32_t chunk_length) -{ sf_count_t current_pos ; - char buffer [2048] ; - uint32_t chunk_size, bytesread = 0 ; - - current_pos = psf_fseek (psf, 0, SEEK_CUR) ; - - if (chunk_length <= 8) - { /* This case is for broken files generated by PEAK. */ - psf_log_printf (psf, "%M : %u (weird length)\n", chunk, chunk_length) ; - psf_binheader_readf (psf, "mj", &chunk, chunk_length - 4) ; - psf_log_printf (psf, " %M\n", chunk) ; - return 0 ; - } ; - - if (current_pos + chunk_length > psf->filelength) - { psf_log_printf (psf, "%M : %u (should be %d)\n", chunk, chunk_length, (int) (psf->filelength - current_pos)) ; - chunk_length = psf->filelength - current_pos ; - } - else - psf_log_printf (psf, "%M : %u\n", chunk, chunk_length) ; - - while (bytesread < chunk_length) - { uint32_t thisread ; - - if ((thisread = psf_binheader_readf (psf, "m", &chunk)) == 0) - break ; - bytesread += thisread ; - - switch (chunk) - { case adtl_MARKER : - case INFO_MARKER : - /* These markers don't contain anything, not even a chunk length. */ - psf_log_printf (psf, " %M\n", chunk) ; - continue ; - - case exif_MARKER : - psf_log_printf (psf, " %M\n", chunk) ; - if (chunk_length > bytesread) - bytesread += exif_subchunk_parse (psf, chunk_length - bytesread) ; - continue ; - - case data_MARKER : - psf_log_printf (psf, " %M inside a LIST block??? Backing out.\n", chunk) ; - /* Jump back four bytes and return to caller. */ - psf_binheader_readf (psf, "j", -4) ; - return 0 ; - - case 0 : - /* - ** Four zero bytes where a marker was expected. Assume this means - ** the rest of the chunk is garbage. - */ - psf_log_printf (psf, " *** Found weird-ass zero marker. Jumping to end of chunk.\n") ; - goto cleanup_subchunk_parse ; - - default : - break ; - } ; - - switch (chunk) - { case ISFT_MARKER : - case ICOP_MARKER : - case IARL_MARKER : - case IART_MARKER : - case ICMT_MARKER : - case ICRD_MARKER : - case IENG_MARKER : - case IGNR_MARKER : - case INAM_MARKER : - case IPRD_MARKER : - case ISBJ_MARKER : - case ISRC_MARKER : - case IAUT_MARKER : - case ITRK_MARKER : - bytesread += psf_binheader_readf (psf, "4", &chunk_size) ; - chunk_size += (chunk_size & 1) ; - if (chunk_size >= SIGNED_SIZEOF (buffer) || bytesread + chunk_size > chunk_length) - { psf_log_printf (psf, " *** %M : %u (too big)\n", chunk, chunk_size) ; - goto cleanup_subchunk_parse ; - } ; - - bytesread += psf_binheader_readf (psf, "b", buffer, chunk_size) ; - buffer [chunk_size] = 0 ; - psf_log_printf (psf, " %M : %s\n", chunk, buffer) ; - break ; - - case labl_MARKER : - { int mark_id ; - - bytesread += psf_binheader_readf (psf, "44", &chunk_size, &mark_id) ; - chunk_size -= 4 ; - chunk_size += (chunk_size & 1) ; - if (chunk_size < 1 || chunk_size >= SIGNED_SIZEOF (buffer) || bytesread + chunk_size > chunk_length) - { psf_log_printf (psf, " *** %M : %u (too big)\n", chunk, chunk_size) ; - goto cleanup_subchunk_parse ; - } ; - - bytesread += psf_binheader_readf (psf, "b", buffer, chunk_size) ; - buffer [chunk_size] = 0 ; - - if (mark_id < 10) /* avoid swamping log buffer with labels */ - psf_log_printf (psf, " %M : %u : %s\n", chunk, mark_id, buffer) ; - else if (mark_id == 10) - psf_log_printf (psf, " (Skipping)\n") ; - - if (psf->cues) - { unsigned int i = 0 ; - - /* find id to store label */ - while (i < psf->cues->cue_count && psf->cues->cue_points [i].indx != mark_id) - i++ ; - - if (i < psf->cues->cue_count) - memcpy (psf->cues->cue_points [i].name, buffer, sizeof (psf->cues->cue_points [i].name)) ; - } ; - } ; - break ; - - case DISP_MARKER : - case ltxt_MARKER : - case note_MARKER : - bytesread += psf_binheader_readf (psf, "4", &chunk_size) ; - chunk_size += (chunk_size & 1) ; - if (chunk_size >= SIGNED_SIZEOF (buffer) || bytesread + chunk_size > chunk_length) - { psf_log_printf (psf, " *** %M : %u (too big)\n", chunk, chunk_size) ; - goto cleanup_subchunk_parse ; - } ; - - psf_log_printf (psf, " %M : %u\n", chunk, chunk_size) ; - goto cleanup_subchunk_parse ; - - default : - bytesread += psf_binheader_readf (psf, "4", &chunk_size) ; - chunk_size += (chunk_size & 1) ; - if (bytesread + chunk_size > chunk_length) - { psf_log_printf (psf, " *** %M : %u (too big)\n", chunk, chunk_size) ; - goto cleanup_subchunk_parse ; - } - else - { psf_log_printf (psf, " %M : %u\n", chunk, chunk_size) ; - bytesread += psf_binheader_readf (psf, "j", chunk_size) ; - } ; - break ; - } ; - - switch (chunk) - { case ISFT_MARKER : - psf_store_string (psf, SF_STR_SOFTWARE, buffer) ; - break ; - case ICOP_MARKER : - psf_store_string (psf, SF_STR_COPYRIGHT, buffer) ; - break ; - case INAM_MARKER : - psf_store_string (psf, SF_STR_TITLE, buffer) ; - break ; - case IART_MARKER : - psf_store_string (psf, SF_STR_ARTIST, buffer) ; - break ; - case ICMT_MARKER : - psf_store_string (psf, SF_STR_COMMENT, buffer) ; - break ; - case ICRD_MARKER : - psf_store_string (psf, SF_STR_DATE, buffer) ; - break ; - case IGNR_MARKER : - psf_store_string (psf, SF_STR_GENRE, buffer) ; - break ; - case IPRD_MARKER : - psf_store_string (psf, SF_STR_ALBUM, buffer) ; - break ; - case ITRK_MARKER : - psf_store_string (psf, SF_STR_TRACKNUMBER, buffer) ; - break ; - } ; - } ; - -cleanup_subchunk_parse : - - if (chunk_length > bytesread) - bytesread += psf_binheader_readf (psf, "j", chunk_length - bytesread) ; - - return 0 ; -} /* wavlike_subchunk_parse */ - -void -wavlike_write_strings (SF_PRIVATE *psf, int location) -{ int k, prev_head_index, saved_head_index ; - - if (psf_location_string_count (psf, location) == 0) - return ; - - prev_head_index = psf->header.indx + 4 ; - - psf_binheader_writef (psf, "m4m", BHWm (LIST_MARKER), BHW4 (0xBADBAD), BHWm (INFO_MARKER)) ; - - for (k = 0 ; k < SF_MAX_STRINGS ; k++) - { if (psf->strings.data [k].type == 0) - break ; - if (psf->strings.data [k].type < 0 || psf->strings.data [k].flags != location) - continue ; - - switch (psf->strings.data [k].type) - { case SF_STR_SOFTWARE : - psf_binheader_writef (psf, "ms", BHWm (ISFT_MARKER), BHWs (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_TITLE : - psf_binheader_writef (psf, "ms", BHWm (INAM_MARKER), BHWs (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_COPYRIGHT : - psf_binheader_writef (psf, "ms", BHWm (ICOP_MARKER), BHWs (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_ARTIST : - psf_binheader_writef (psf, "ms", BHWm (IART_MARKER), BHWs (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_COMMENT : - psf_binheader_writef (psf, "ms", BHWm (ICMT_MARKER), BHWs (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_DATE : - psf_binheader_writef (psf, "ms", BHWm (ICRD_MARKER), BHWs (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_GENRE : - psf_binheader_writef (psf, "ms", BHWm (IGNR_MARKER), BHWs (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_ALBUM : - psf_binheader_writef (psf, "ms", BHWm (IPRD_MARKER), BHWs (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - case SF_STR_TRACKNUMBER : - psf_binheader_writef (psf, "ms", BHWm (ITRK_MARKER), BHWs (psf->strings.storage + psf->strings.data [k].offset)) ; - break ; - - default : - break ; - } ; - } ; - - saved_head_index = psf->header.indx ; - psf->header.indx = prev_head_index ; - psf_binheader_writef (psf, "4", BHW4 (saved_head_index - prev_head_index - 4)) ; - psf->header.indx = saved_head_index ; - -} /* wavlike_write_strings */ - -int -wavlike_read_peak_chunk (SF_PRIVATE * psf, size_t chunk_size) -{ char buffer [256] ; - uint32_t uk ; - - if (chunk_size != WAVLIKE_PEAK_CHUNK_SIZE (psf->sf.channels)) - { psf_binheader_readf (psf, "j", chunk_size) ; - psf_log_printf (psf, "*** File PEAK chunk size doesn't fit with number of channels (%d).\n", psf->sf.channels) ; - return SFE_WAV_BAD_PEAK ; - } ; - - if (psf->peak_info) - { psf_log_printf (psf, "*** Found existing peak info, using last one.\n") ; - free (psf->peak_info) ; - psf->peak_info = NULL ; - } ; - if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL) - return SFE_MALLOC_FAILED ; - - /* read in rest of PEAK chunk. */ - psf_binheader_readf (psf, "44", & (psf->peak_info->version), & (psf->peak_info->timestamp)) ; - - if (psf->peak_info->version != 1) - psf_log_printf (psf, " version : %d *** (should be version 1)\n", psf->peak_info->version) ; - else - psf_log_printf (psf, " version : %d\n", psf->peak_info->version) ; - - psf_log_printf (psf, " time stamp : %d\n", psf->peak_info->timestamp) ; - psf_log_printf (psf, " Ch Position Value\n") ; - - for (uk = 0 ; uk < (uint32_t) psf->sf.channels ; uk++) - { float value ; - uint32_t position ; - - psf_binheader_readf (psf, "f4", &value, &position) ; - psf->peak_info->peaks [uk].value = value ; - psf->peak_info->peaks [uk].position = position ; - - snprintf (buffer, sizeof (buffer), " %2d %-12" PRId64 " %g\n", - uk, psf->peak_info->peaks [uk].position, psf->peak_info->peaks [uk].value) ; - buffer [sizeof (buffer) - 1] = 0 ; - psf_log_printf (psf, "%s", buffer) ; - } ; - - return 0 ; -} /* wavlike_read_peak_chunk */ - -void -wavlike_write_peak_chunk (SF_PRIVATE * psf) -{ int k ; - - if (psf->peak_info == NULL) - return ; - - psf_binheader_writef (psf, "m4", BHWm (PEAK_MARKER), BHW4 (WAVLIKE_PEAK_CHUNK_SIZE (psf->sf.channels))) ; - psf_binheader_writef (psf, "44", BHW4 (1), BHW4 (time (NULL))) ; - for (k = 0 ; k < psf->sf.channels ; k++) - psf_binheader_writef (psf, "ft8", BHWf (psf->peak_info->peaks [k].value), BHW8 (psf->peak_info->peaks [k].position)) ; -} /* wavlike_write_peak_chunk */ - -/*============================================================================== -*/ - -static int -exif_fill_and_sink (SF_PRIVATE *psf, char* buf, size_t bufsz, size_t toread) -{ - size_t bytesread = 0 ; - - buf [0] = 0 ; - bufsz -= 1 ; - if (toread < bufsz) - bufsz = toread ; - bytesread = psf_binheader_readf (psf, "b", buf, bufsz) ; - buf [bufsz] = 0 ; - - if (bytesread == bufsz && toread > bufsz) - bytesread += psf_binheader_readf (psf, "j", toread - bufsz) ; - - return bytesread ; -} /* exif_fill_and_sink */ - -/* -** Exif specification for audio files, at JEITA CP-3451 Exif 2.2 section 5 -** (Exif Audio File Specification) http://www.exif.org/Exif2-2.PDF -*/ -static int -exif_subchunk_parse (SF_PRIVATE *psf, uint32_t length) -{ uint32_t marker, dword = 0, vmajor = -1, vminor = -1, bytesread = 0 ; - char buf [4096] ; - int thisread ; - - while (bytesread < length) - { - if ((thisread = psf_binheader_readf (psf, "m", &marker)) == 0) - break ; - bytesread += thisread ; - - switch (marker) - { - case 0 : /* camera padding? */ - break ; - - case ever_MARKER : - bytesread += psf_binheader_readf (psf, "j4", 4, &dword) ; - vmajor = 10 * (((dword >> 24) & 0xff) - '0') + (((dword >> 16) & 0xff) - '0') ; - vminor = 10 * (((dword >> 8) & 0xff) - '0') + ((dword & 0xff) - '0') ; - psf_log_printf (psf, " EXIF Version : %u.%02u\n", vmajor, vminor) ; - break ; - - case olym_MARKER : - bytesread += psf_binheader_readf (psf, "4", &dword) ; - psf_log_printf (psf, "%M : %u\n", marker, dword) ; - if (dword > length || bytesread + dword > length) - break ; - dword += (dword & 1) ; - bytesread += psf_binheader_readf (psf, "j", dword) ; - break ; - - case emnt_MARKER : /* design information: null-terminated string */ - case emdl_MARKER : /* model name ; null-terminated string */ - case ecor_MARKER : /* manufacturer: null-terminated string */ - case etim_MARKER : /* creation time: null-terminated string in the format "hour:minute:second.subsecond" */ - case erel_MARKER : /* relation info: null-terminated string (filename) */ - case eucm_MARKER : /* user comment: 4-byte size follows, then possibly unicode data */ - bytesread += psf_binheader_readf (psf, "4", &dword) ; - bytesread += sizeof (dword) ; - dword += (dword & 1) ; - - if (dword >= sizeof (buf)) - { psf_log_printf (psf, "*** Marker '%M' is too big %u\n\n", marker, dword) ; - return bytesread ; - } ; - - bytesread += exif_fill_and_sink (psf, buf, sizeof (buf), dword) ; - - /* BAD - don't know what's going on here -- maybe a bug in the camera */ - /* field should be NULL-terminated but there's no room for it with the reported number */ - /* example output: emdl : 8 (EX-Z1050) */ - if (marker == emdl_MARKER && dword == strlen (buf) /* should be >= strlen+1*/) - { psf_log_printf (psf, " *** field size too small for string (sinking 2 bytes)\n") ; - bytesread += psf_binheader_readf (psf, "j", 2) ; - } ; - - psf_log_printf (psf, " %M : %u (%s)\n", marker, dword, buf) ; - if (dword > length) - return bytesread ; - break ; - - default : - psf_log_printf (psf, " *** %M (%u): -- ignored --\n", marker, marker) ; - break ; - } ; - } ; - - return bytesread ; -} /* exif_subchunk_parse */ - -void -wavlike_write_custom_chunks (SF_PRIVATE * psf) -{ uint32_t k ; - - for (k = 0 ; k < psf->wchunks.used ; k++) - psf_binheader_writef (psf, "m4b", BHWm (psf->wchunks.chunks [k].mark32), BHW4 (psf->wchunks.chunks [k].len), - BHWv (psf->wchunks.chunks [k].data), BHWz (psf->wchunks.chunks [k].len)) ; - -} /* wavlike_write_custom_chunks */ diff --git a/Engine/lib/libsndfile/src/wavlike.h b/Engine/lib/libsndfile/src/wavlike.h deleted file mode 100644 index 686287d8a..000000000 --- a/Engine/lib/libsndfile/src/wavlike.h +++ /dev/null @@ -1,374 +0,0 @@ -/* -** Copyright (C) 1999-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* This file contains definitions commong to WAV and W64 files. */ - - -#ifndef WAVLIKE_H_INCLUDED -#define WAVLIKE_H_INCLUDED - -/*------------------------------------------------------------------------------ -** Chunk markers. -*/ - -#define adtl_MARKER MAKE_MARKER ('a', 'd', 't', 'l') -#define bext_MARKER MAKE_MARKER ('b', 'e', 'x', 't') -#define cart_MARKER MAKE_MARKER ('c', 'a', 'r', 't') -#define data_MARKER MAKE_MARKER ('d', 'a', 't', 'a') -#define labl_MARKER MAKE_MARKER ('l', 'a', 'b', 'l') -#define ltxt_MARKER MAKE_MARKER ('l', 't', 'x', 't') -#define note_MARKER MAKE_MARKER ('n', 'o', 't', 'e') -#define DISP_MARKER MAKE_MARKER ('D', 'I', 'S', 'P') -#define INFO_MARKER MAKE_MARKER ('I', 'N', 'F', 'O') -#define LIST_MARKER MAKE_MARKER ('L', 'I', 'S', 'T') -#define PAD_MARKER MAKE_MARKER ('P', 'A', 'D', ' ') -#define PEAK_MARKER MAKE_MARKER ('P', 'E', 'A', 'K') - -#define ISFT_MARKER MAKE_MARKER ('I', 'S', 'F', 'T') -#define ICRD_MARKER MAKE_MARKER ('I', 'C', 'R', 'D') -#define ICOP_MARKER MAKE_MARKER ('I', 'C', 'O', 'P') -#define IARL_MARKER MAKE_MARKER ('I', 'A', 'R', 'L') -#define IART_MARKER MAKE_MARKER ('I', 'A', 'R', 'T') -#define INAM_MARKER MAKE_MARKER ('I', 'N', 'A', 'M') -#define IENG_MARKER MAKE_MARKER ('I', 'E', 'N', 'G') -#define IGNR_MARKER MAKE_MARKER ('I', 'G', 'N', 'R') -#define ICOP_MARKER MAKE_MARKER ('I', 'C', 'O', 'P') -#define IPRD_MARKER MAKE_MARKER ('I', 'P', 'R', 'D') -#define ISRC_MARKER MAKE_MARKER ('I', 'S', 'R', 'C') -#define ISBJ_MARKER MAKE_MARKER ('I', 'S', 'B', 'J') -#define ICMT_MARKER MAKE_MARKER ('I', 'C', 'M', 'T') -#define IAUT_MARKER MAKE_MARKER ('I', 'A', 'U', 'T') -#define ITRK_MARKER MAKE_MARKER ('I', 'T', 'R', 'K') - -#define exif_MARKER MAKE_MARKER ('e', 'x', 'i', 'f') -#define ever_MARKER MAKE_MARKER ('e', 'v', 'e', 'r') -#define etim_MARKER MAKE_MARKER ('e', 't', 'i', 'm') -#define ecor_MARKER MAKE_MARKER ('e', 'c', 'o', 'r') -#define emdl_MARKER MAKE_MARKER ('e', 'm', 'd', 'l') -#define emnt_MARKER MAKE_MARKER ('e', 'm', 'n', 't') -#define erel_MARKER MAKE_MARKER ('e', 'r', 'e', 'l') -#define eucm_MARKER MAKE_MARKER ('e', 'u', 'c', 'm') -#define olym_MARKER MAKE_MARKER ('o', 'l', 'y', 'm') - -/*------------------------------------------------------------------------------ -** List of known WAV format tags -*/ - -enum -{ - /* keep sorted for wavlike_format_str() */ - WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Corporation */ - WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM format */ - WAVE_FORMAT_MS_ADPCM = 0x0002, /* Microsoft ADPCM */ - WAVE_FORMAT_IEEE_FLOAT = 0x0003, /* Micrososft 32 bit float format */ - WAVE_FORMAT_VSELP = 0x0004, /* Compaq Computer Corporation */ - WAVE_FORMAT_IBM_CVSD = 0x0005, /* IBM Corporation */ - WAVE_FORMAT_ALAW = 0x0006, /* Microsoft Corporation */ - WAVE_FORMAT_MULAW = 0x0007, /* Microsoft Corporation */ - WAVE_FORMAT_OKI_ADPCM = 0x0010, /* OKI */ - WAVE_FORMAT_IMA_ADPCM = 0x0011, /* Intel Corporation */ - WAVE_FORMAT_MEDIASPACE_ADPCM = 0x0012, /* Videologic */ - WAVE_FORMAT_SIERRA_ADPCM = 0x0013, /* Sierra Semiconductor Corp */ - WAVE_FORMAT_G723_ADPCM = 0x0014, /* Antex Electronics Corporation */ - WAVE_FORMAT_DIGISTD = 0x0015, /* DSP Solutions, Inc. */ - WAVE_FORMAT_DIGIFIX = 0x0016, /* DSP Solutions, Inc. */ - WAVE_FORMAT_DIALOGIC_OKI_ADPCM = 0x0017, /* Dialogic Corporation */ - WAVE_FORMAT_MEDIAVISION_ADPCM = 0x0018, /* Media Vision, Inc. */ - WAVE_FORMAT_CU_CODEC = 0x0019, /* Hewlett-Packard Company */ - WAVE_FORMAT_YAMAHA_ADPCM = 0x0020, /* Yamaha Corporation of America */ - WAVE_FORMAT_SONARC = 0x0021, /* Speech Compression */ - WAVE_FORMAT_DSPGROUP_TRUESPEECH = 0x0022, /* DSP Group, Inc */ - WAVE_FORMAT_ECHOSC1 = 0x0023, /* Echo Speech Corporation */ - WAVE_FORMAT_AUDIOFILE_AF36 = 0x0024, /* Audiofile, Inc. */ - WAVE_FORMAT_APTX = 0x0025, /* Audio Processing Technology */ - WAVE_FORMAT_AUDIOFILE_AF10 = 0x0026, /* Audiofile, Inc. */ - WAVE_FORMAT_PROSODY_1612 = 0x0027, /* Aculab plc */ - WAVE_FORMAT_LRC = 0x0028, /* Merging Technologies S.A. */ - WAVE_FORMAT_DOLBY_AC2 = 0x0030, /* Dolby Laboratories */ - WAVE_FORMAT_GSM610 = 0x0031, /* Microsoft Corporation */ - WAVE_FORMAT_MSNAUDIO = 0x0032, /* Microsoft Corporation */ - WAVE_FORMAT_ANTEX_ADPCME = 0x0033, /* Antex Electronics Corporation */ - WAVE_FORMAT_CONTROL_RES_VQLPC = 0x0034, /* Control Resources Limited */ - WAVE_FORMAT_DIGIREAL = 0x0035, /* DSP Solutions, Inc. */ - WAVE_FORMAT_DIGIADPCM = 0x0036, /* DSP Solutions, Inc. */ - WAVE_FORMAT_CONTROL_RES_CR10 = 0x0037, /* Control Resources Limited */ - WAVE_FORMAT_NMS_VBXADPCM = 0x0038, /* Natural MicroSystems */ - WAVE_FORMAT_ROLAND_RDAC = 0x0039, /* Roland */ - WAVE_FORMAT_ECHOSC3 = 0x003A, /* Echo Speech Corporation */ - WAVE_FORMAT_ROCKWELL_ADPCM = 0x003B, /* Rockwell International */ - WAVE_FORMAT_ROCKWELL_DIGITALK = 0x003C, /* Rockwell International */ - WAVE_FORMAT_XEBEC = 0x003D, /* Xebec Multimedia Solutions Limited */ - WAVE_FORMAT_G721_ADPCM = 0x0040, /* Antex Electronics Corporation */ - WAVE_FORMAT_G728_CELP = 0x0041, /* Antex Electronics Corporation */ - WAVE_FORMAT_MSG723 = 0x0042, /* Microsoft Corporation */ - WAVE_FORMAT_MPEG = 0x0050, /* Microsoft Corporation */ - WAVE_FORMAT_RT24 = 0x0052, /* InSoft Inc. */ - WAVE_FORMAT_PAC = 0x0053, /* InSoft Inc. */ - WAVE_FORMAT_MPEGLAYER3 = 0x0055, /* MPEG 3 Layer 1 */ - WAVE_FORMAT_LUCENT_G723 = 0x0059, /* Lucent Technologies */ - WAVE_FORMAT_CIRRUS = 0x0060, /* Cirrus Logic */ - WAVE_FORMAT_ESPCM = 0x0061, /* ESS Technology */ - WAVE_FORMAT_VOXWARE = 0x0062, /* Voxware Inc */ - WAVE_FORMAT_CANOPUS_ATRAC = 0x0063, /* Canopus, Co., Ltd. */ - WAVE_FORMAT_G726_ADPCM = 0x0064, /* APICOM */ - WAVE_FORMAT_G722_ADPCM = 0x0065, /* APICOM */ - WAVE_FORMAT_DSAT = 0x0066, /* Microsoft Corporation */ - WAVE_FORMAT_DSAT_DISPLAY = 0x0067, /* Microsoft Corporation */ - WAVE_FORMAT_VOXWARE_BYTE_ALIGNED = 0x0069, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_AC8 = 0x0070, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_AC10 = 0x0071, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_AC16 = 0x0072, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_AC20 = 0x0073, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_RT24 = 0x0074, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_RT29 = 0x0075, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_RT29HW = 0x0076, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_VR12 = 0x0077, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_VR18 = 0x0078, /* Voxware Inc. */ - WAVE_FORMAT_VOXWARE_TQ40 = 0x0079, /* Voxware Inc. */ - WAVE_FORMAT_SOFTSOUND = 0x0080, /* Softsound, Ltd. */ - WAVE_FORMAT_VOXARE_TQ60 = 0x0081, /* Voxware Inc. */ - WAVE_FORMAT_MSRT24 = 0x0082, /* Microsoft Corporation */ - WAVE_FORMAT_G729A = 0x0083, /* AT&T Laboratories */ - WAVE_FORMAT_MVI_MV12 = 0x0084, /* Motion Pixels */ - WAVE_FORMAT_DF_G726 = 0x0085, /* DataFusion Systems (Pty) (Ltd) */ - WAVE_FORMAT_DF_GSM610 = 0x0086, /* DataFusion Systems (Pty) (Ltd) */ - /* removed because duplicate */ - /* WAVE_FORMAT_ISIAUDIO = 0x0088, */ /* Iterated Systems, Inc. */ - WAVE_FORMAT_ONLIVE = 0x0089, /* OnLive! Technologies, Inc. */ - WAVE_FORMAT_SBC24 = 0x0091, /* Siemens Business Communications Systems */ - WAVE_FORMAT_DOLBY_AC3_SPDIF = 0x0092, /* Sonic Foundry */ - WAVE_FORMAT_ZYXEL_ADPCM = 0x0097, /* ZyXEL Communications, Inc. */ - WAVE_FORMAT_PHILIPS_LPCBB = 0x0098, /* Philips Speech Processing */ - WAVE_FORMAT_PACKED = 0x0099, /* Studer Professional Audio AG */ - WAVE_FORMAT_RHETOREX_ADPCM = 0x0100, /* Rhetorex, Inc. */ - - /* removed because of the following */ - /* WAVE_FORMAT_IRAT = 0x0101,*/ /* BeCubed Software Inc. */ - - /* these three are unofficial */ - IBM_FORMAT_MULAW = 0x0101, /* IBM mu-law format */ - IBM_FORMAT_ALAW = 0x0102, /* IBM a-law format */ - IBM_FORMAT_ADPCM = 0x0103, /* IBM AVC Adaptive Differential PCM format */ - - WAVE_FORMAT_VIVO_G723 = 0x0111, /* Vivo Software */ - WAVE_FORMAT_VIVO_SIREN = 0x0112, /* Vivo Software */ - WAVE_FORMAT_DIGITAL_G723 = 0x0123, /* Digital Equipment Corporation */ - WAVE_FORMAT_CREATIVE_ADPCM = 0x0200, /* Creative Labs, Inc */ - WAVE_FORMAT_CREATIVE_FASTSPEECH8 = 0x0202, /* Creative Labs, Inc */ - WAVE_FORMAT_CREATIVE_FASTSPEECH10 = 0x0203, /* Creative Labs, Inc */ - WAVE_FORMAT_QUARTERDECK = 0x0220, /* Quarterdeck Corporation */ - WAVE_FORMAT_FM_TOWNS_SND = 0x0300, /* Fujitsu Corporation */ - WAVE_FORMAT_BZV_DIGITAL = 0x0400, /* Brooktree Corporation */ - WAVE_FORMAT_VME_VMPCM = 0x0680, /* AT&T Labs, Inc. */ - WAVE_FORMAT_OLIGSM = 0x1000, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_OLIADPCM = 0x1001, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_OLICELP = 0x1002, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_OLISBC = 0x1003, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_OLIOPR = 0x1004, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_LH_CODEC = 0x1100, /* Lernout & Hauspie */ - WAVE_FORMAT_NORRIS = 0x1400, /* Norris Communications, Inc. */ - /* removed because duplicate */ - /* WAVE_FORMAT_ISIAUDIO = 0x1401, */ /* AT&T Labs, Inc. */ - WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS = 0x1500, /* AT&T Labs, Inc. */ - WAVE_FORMAT_DVM = 0x2000, /* FAST Multimedia AG */ - WAVE_FORMAT_INTERWAV_VSC112 = 0x7150, /* ????? */ - - WAVE_FORMAT_IPP_ITU_G_723_1 = 0x7230, /* Intel Performance Primitives g723 codec. */ - - WAVE_FORMAT_EXTENSIBLE = 0xFFFE -} ; - -typedef struct -{ unsigned short format ; - unsigned short channels ; - unsigned int samplerate ; - unsigned int bytespersec ; - unsigned short blockalign ; - unsigned short bitwidth ; -} MIN_WAV_FMT ; - -typedef struct -{ unsigned short format ; - unsigned short channels ; - unsigned int samplerate ; - unsigned int bytespersec ; - unsigned short blockalign ; - unsigned short bitwidth ; - unsigned short extrabytes ; - unsigned short dummy ; -} WAV_FMT_SIZE20 ; - -typedef struct -{ unsigned short format ; - unsigned short channels ; - unsigned int samplerate ; - unsigned int bytespersec ; - unsigned short blockalign ; - unsigned short bitwidth ; - unsigned short extrabytes ; - unsigned short samplesperblock ; - unsigned short numcoeffs ; - struct - { short coeff1 ; - short coeff2 ; - } coeffs [7] ; -} MS_ADPCM_WAV_FMT ; - -typedef struct -{ unsigned short format ; - unsigned short channels ; - unsigned int samplerate ; - unsigned int bytespersec ; - unsigned short blockalign ; - unsigned short bitwidth ; - unsigned short extrabytes ; - unsigned short samplesperblock ; -} IMA_ADPCM_WAV_FMT ; - -typedef struct -{ unsigned short format ; - unsigned short channels ; - unsigned int samplerate ; - unsigned int bytespersec ; - unsigned short blockalign ; - unsigned short bitwidth ; - unsigned short extrabytes ; - unsigned short auxblocksize ; -} G72x_ADPCM_WAV_FMT ; - - -typedef struct -{ unsigned short format ; - unsigned short channels ; - unsigned int samplerate ; - unsigned int bytespersec ; - unsigned short blockalign ; - unsigned short bitwidth ; - unsigned short extrabytes ; - unsigned short samplesperblock ; -} GSM610_WAV_FMT ; - -typedef struct -{ unsigned short format ; - unsigned short channels ; - unsigned int samplerate ; - unsigned int bytespersec ; - unsigned short blockalign ; - unsigned short bitwidth ; - unsigned short extrabytes ; - unsigned short id ; - unsigned int flags ; - unsigned short blocksize ; - unsigned short samplesperblock ; - unsigned short codecdelay ; -} MPEGLAYER3_WAV_FMT ; - -typedef struct -{ unsigned int esf_field1 ; - unsigned short esf_field2 ; - unsigned short esf_field3 ; - unsigned char esf_field4 [8] ; -} EXT_SUBFORMAT ; - -typedef struct -{ unsigned short format ; - unsigned short channels ; - unsigned int samplerate ; - unsigned int bytespersec ; - unsigned short blockalign ; - unsigned short bitwidth ; - unsigned short extrabytes ; - unsigned short validbits ; - unsigned int channelmask ; - EXT_SUBFORMAT esf ; -} EXTENSIBLE_WAV_FMT ; - -typedef union -{ unsigned short format ; - MIN_WAV_FMT min ; - IMA_ADPCM_WAV_FMT ima ; - MS_ADPCM_WAV_FMT msadpcm ; - G72x_ADPCM_WAV_FMT g72x ; - EXTENSIBLE_WAV_FMT ext ; - GSM610_WAV_FMT gsm610 ; - MPEGLAYER3_WAV_FMT mpeg3 ; - WAV_FMT_SIZE20 size20 ; - char padding [512] ; -} WAV_FMT ; - -typedef struct -{ int frames ; -} FACT_CHUNK ; - -typedef struct -{ /* For ambisonic commands */ - int wavex_ambisonic ; - unsigned wavex_channelmask ; - - /* Set to true when 'fmt ' chunk is ambiguous.*/ - int fmt_is_broken ; - WAV_FMT wav_fmt ; - - /* - ** Set to true when RF64 should be converted back to RIFF when writing the - ** header. - */ - int rf64_downgrade ; -} WAVLIKE_PRIVATE ; - -#define WAVLIKE_GSM610_BLOCKSIZE 65 -#define WAVLIKE_GSM610_SAMPLES 320 - -#define WAVLIKE_PEAK_CHUNK_SIZE(ch) (2 * sizeof (int) + ch * (sizeof (float) + sizeof (int))) - -/*------------------------------------------------------------------------------------ -** Functions defined in wav_ms_adpcm.c -*/ - -#define WAVLIKE_MSADPCM_ADAPT_COEFF_COUNT 7 - -void wavlike_msadpcm_write_adapt_coeffs (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------------ -** Functions defined in wavlike.c -*/ - -char const* wavlike_format_str (int k) ; - -int wavlike_srate2blocksize (int srate_chan_product) ; -int wavlike_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize) ; -void wavlike_write_guid (SF_PRIVATE *psf, const EXT_SUBFORMAT * subformat) ; -void wavlike_analyze (SF_PRIVATE *psf) ; -int wavlike_gen_channel_mask (const int *chan_map, int channels) ; - -int wavlike_read_bext_chunk (SF_PRIVATE *psf, uint32_t chunksize) ; -int wavlike_write_bext_chunk (SF_PRIVATE *psf) ; - -int wavlike_read_cart_chunk (SF_PRIVATE *psf, uint32_t chunksize) ; -int wavlike_write_cart_chunk (SF_PRIVATE *psf) ; - -int wavlike_subchunk_parse (SF_PRIVATE *psf, int chunk, uint32_t length) ; -void wavlike_write_strings (SF_PRIVATE *psf, int location) ; - -int wavlike_read_peak_chunk (SF_PRIVATE * psf, size_t chunk_size) ; -void wavlike_write_peak_chunk (SF_PRIVATE * psf) ; - -void wavlike_write_custom_chunks (SF_PRIVATE * psf) ; - -#endif - diff --git a/Engine/lib/libsndfile/src/windows.c b/Engine/lib/libsndfile/src/windows.c deleted file mode 100644 index c11ed9b4b..000000000 --- a/Engine/lib/libsndfile/src/windows.c +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Copyright (C) 2009-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** This needs to be a separate file so that we don't have to include -** elsewhere (too many symbol clashes). -*/ - - -#include "sfconfig.h" - -#if OS_IS_WIN32 -#include - -#include "sndfile.h" -#include "common.h" - -extern int sf_errno ; - -SNDFILE* -sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) -{ SF_PRIVATE *psf ; - char utf8name [SF_BUFFER_LEN] ; - DWORD dwError ; - - if ((psf = psf_allocate ()) == NULL) - { sf_errno = SFE_MALLOC_FAILED ; - return NULL ; - } ; - - psf_init_files (psf) ; - - if (WideCharToMultiByte (CP_UTF8, 0, wpath, -1, utf8name, sizeof (utf8name), NULL, NULL) == 0) - { dwError = GetLastError () ; - if (dwError == ERROR_INSUFFICIENT_BUFFER) - sf_errno = SFE_FILENAME_TOO_LONG ; - else - sf_errno = SF_ERR_UNSUPPORTED_ENCODING ; - - sf_close (psf) ; - - return NULL ; - } ; - - psf_log_printf (psf, "File : '%s' (utf-8 converted from ucs-2)\n", utf8name) ; - - psf_copy_filename (psf, utf8name) ; - psf->file.mode = mode ; - - psf->error = psf_fopen (psf) ; - - return psf_open_file (psf, sfinfo) ; -} /* sf_wchar_open */ - -#endif diff --git a/Engine/lib/libsndfile/src/wve.c b/Engine/lib/libsndfile/src/wve.c deleted file mode 100644 index 4b9fc8aa7..000000000 --- a/Engine/lib/libsndfile/src/wve.c +++ /dev/null @@ -1,209 +0,0 @@ -/* -** Copyright (C) 2002-2017 Erik de Castro Lopo -** Copyright (C) 2007 Reuben Thomas -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -/*------------------------------------------------------------------------------ -** Macros to handle big/little endian issues, and other magic numbers. -*/ - -#define ALAW_MARKER MAKE_MARKER ('A', 'L', 'a', 'w') -#define SOUN_MARKER MAKE_MARKER ('S', 'o', 'u', 'n') -#define DFIL_MARKER MAKE_MARKER ('d', 'F', 'i', 'l') -#define ESSN_MARKER MAKE_MARKER ('e', '*', '*', '\0') -#define PSION_VERSION ((unsigned short) 3856) -#define PSION_DATAOFFSET 0x20 - -/*------------------------------------------------------------------------------ -** Private static functions. -*/ - -static int wve_read_header (SF_PRIVATE *psf) ; -static int wve_write_header (SF_PRIVATE *psf, int calc_length) ; -static int wve_close (SF_PRIVATE *psf) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -wve_open (SF_PRIVATE *psf) -{ int error = 0 ; - - if (psf->is_pipe) - return SFE_WVE_NO_PIPE ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = wve_read_header (psf))) - return error ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_WVE) - return SFE_BAD_OPEN_FORMAT ; - - psf->endian = SF_ENDIAN_BIG ; - - if ((error = wve_write_header (psf, SF_FALSE))) - return error ; - - psf->write_header = wve_write_header ; - } ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - psf->container_close = wve_close ; - - error = alaw_init (psf) ; - - return error ; -} /* wve_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -wve_read_header (SF_PRIVATE *psf) -{ int marker ; - unsigned short version, padding, repeats, trash ; - unsigned datalength ; - - /* Set position to start of file to begin reading header. */ - psf_binheader_readf (psf, "pm", 0, &marker) ; - if (marker != ALAW_MARKER) - { psf_log_printf (psf, "Could not find '%M'\n", ALAW_MARKER) ; - return SFE_WVE_NOT_WVE ; - } ; - - psf_binheader_readf (psf, "m", &marker) ; - if (marker != SOUN_MARKER) - { psf_log_printf (psf, "Could not find '%M'\n", SOUN_MARKER) ; - return SFE_WVE_NOT_WVE ; - } ; - - psf_binheader_readf (psf, "m", &marker) ; - if (marker != DFIL_MARKER) - { psf_log_printf (psf, "Could not find '%M'\n", DFIL_MARKER) ; - return SFE_WVE_NOT_WVE ; - } ; - - psf_binheader_readf (psf, "m", &marker) ; - if (marker != ESSN_MARKER) - { psf_log_printf (psf, "Could not find '%M'\n", ESSN_MARKER) ; - return SFE_WVE_NOT_WVE ; - } ; - - psf_binheader_readf (psf, "E2", &version) ; - - psf_log_printf (psf, "Psion Palmtop Alaw (.wve)\n" - " Sample Rate : 8000\n" - " Channels : 1\n" - " Encoding : A-law\n") ; - - if (version != PSION_VERSION) - psf_log_printf (psf, "Psion version %d should be %d\n", version, PSION_VERSION) ; - - psf_binheader_readf (psf, "E4", &datalength) ; - psf->dataoffset = PSION_DATAOFFSET ; - if (datalength != psf->filelength - psf->dataoffset) - { psf->datalength = psf->filelength - psf->dataoffset ; - psf_log_printf (psf, "Data length %d should be %D\n", datalength, psf->datalength) ; - } - else - psf->datalength = datalength ; - - psf_binheader_readf (psf, "E22222", &padding, &repeats, &trash, &trash, &trash) ; - - psf->sf.format = SF_FORMAT_WVE | SF_FORMAT_ALAW ; - psf->sf.samplerate = 8000 ; - psf->sf.frames = psf->datalength ; - psf->sf.channels = 1 ; - - return SFE_NO_ERROR ; -} /* wve_read_header */ - -/*------------------------------------------------------------------------------ -*/ - -static int -wve_write_header (SF_PRIVATE *psf, int calc_length) -{ sf_count_t current ; - unsigned datalen ; - - current = psf_ftell (psf) ; - - if (calc_length) - { psf->filelength = psf_get_filelen (psf) ; - - psf->datalength = psf->filelength - psf->dataoffset ; - if (psf->dataend) - psf->datalength -= psf->filelength - psf->dataend ; - - psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ; - } ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - /* Write header. */ - datalen = psf->datalength ; - psf_binheader_writef (psf, "Emmmm", BHWm (ALAW_MARKER), BHWm (SOUN_MARKER), BHWm (DFIL_MARKER), BHWm (ESSN_MARKER)) ; - psf_binheader_writef (psf, "E2422222", BHW2 (PSION_VERSION), BHW4 (datalen), BHW2 (0), BHW2 (0), BHW2 (0), BHW2 (0), BHW2 (0)) ; - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->sf.channels != 1) - return SFE_CHANNEL_COUNT ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* wve_write_header */ - -/*------------------------------------------------------------------------------ -*/ - -static int -wve_close (SF_PRIVATE *psf) -{ - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { /* Now we know for certain the length of the file we can re-write - ** the header. - */ - wve_write_header (psf, SF_TRUE) ; - } ; - - return 0 ; -} /* wve_close */ diff --git a/Engine/lib/libsndfile/src/xi.c b/Engine/lib/libsndfile/src/xi.c deleted file mode 100644 index e8169471e..000000000 --- a/Engine/lib/libsndfile/src/xi.c +++ /dev/null @@ -1,1223 +0,0 @@ -/* -** Copyright (C) 2003-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#include "sndfile.h" -#include "sfendian.h" -#include "common.h" - -#define MAX_XI_SAMPLES 16 - -/*------------------------------------------------------------------------------ -** Private static functions and tyepdefs. -*/ - -typedef struct -{ /* Warning, this filename is NOT nul terminated. */ - char filename [22] ; - char software [20] ; - char sample_name [22] ; - - int loop_begin, loop_end ; - int sample_flags ; - - /* Data for encoder and decoder. */ - short last_16 ; -} XI_PRIVATE ; - -static int xi_close (SF_PRIVATE *psf) ; -static int xi_write_header (SF_PRIVATE *psf, int calc_length) ; -static int xi_read_header (SF_PRIVATE *psf) ; -static int dpcm_init (SF_PRIVATE *psf) ; - - -static sf_count_t dpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; - -/*------------------------------------------------------------------------------ -** Public function. -*/ - -int -xi_open (SF_PRIVATE *psf) -{ XI_PRIVATE *pxi ; - int subformat, error = 0 ; - - if (psf->is_pipe) - return SFE_XI_NO_PIPE ; - - if (psf->codec_data) - pxi = psf->codec_data ; - else if ((pxi = calloc (1, sizeof (XI_PRIVATE))) == NULL) - return SFE_MALLOC_FAILED ; - - psf->codec_data = pxi ; - - if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0)) - { if ((error = xi_read_header (psf))) - return error ; - } ; - - subformat = SF_CODEC (psf->sf.format) ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { if ((SF_CONTAINER (psf->sf.format)) != SF_FORMAT_XI) - return SFE_BAD_OPEN_FORMAT ; - - psf->endian = SF_ENDIAN_LITTLE ; - psf->sf.channels = 1 ; /* Always mono */ - psf->sf.samplerate = 44100 ; /* Always */ - - /* Set up default instrument and software name. */ - memcpy (pxi->filename, "Default Name ", sizeof (pxi->filename)) ; - memcpy (pxi->software, PACKAGE_NAME "-" PACKAGE_VERSION " ", sizeof (pxi->software)) ; - - memset (pxi->sample_name, 0, sizeof (pxi->sample_name)) ; - snprintf (pxi->sample_name, sizeof (pxi->sample_name), "%s", "Sample #1") ; - - pxi->sample_flags = (subformat == SF_FORMAT_DPCM_16) ? 16 : 0 ; - - if (xi_write_header (psf, SF_FALSE)) - return psf->error ; - - psf->write_header = xi_write_header ; - } ; - - psf->container_close = xi_close ; - psf->seek = dpcm_seek ; - - psf->sf.seekable = SF_FALSE ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - switch (subformat) - { case SF_FORMAT_DPCM_8 : /* 8-bit differential PCM. */ - case SF_FORMAT_DPCM_16 : /* 16-bit differential PCM. */ - error = dpcm_init (psf) ; - break ; - - default : break ; - } ; - - return error ; -} /* xi_open */ - -/*------------------------------------------------------------------------------ -*/ - -static int -xi_close (SF_PRIVATE * UNUSED (psf)) -{ - return 0 ; -} /* xi_close */ - -/*============================================================================== -*/ - -static sf_count_t dpcm_read_dsc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t dpcm_read_dsc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t dpcm_read_dsc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t dpcm_read_dsc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t dpcm_write_s2dsc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t dpcm_write_i2dsc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t dpcm_write_f2dsc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t dpcm_write_d2dsc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static sf_count_t dpcm_read_dles2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; -static sf_count_t dpcm_read_dles2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; -static sf_count_t dpcm_read_dles2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; -static sf_count_t dpcm_read_dles2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; - -static sf_count_t dpcm_write_s2dles (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; -static sf_count_t dpcm_write_i2dles (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; -static sf_count_t dpcm_write_f2dles (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; -static sf_count_t dpcm_write_d2dles (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; - -static int -dpcm_init (SF_PRIVATE *psf) -{ if (psf->bytewidth == 0 || psf->sf.channels == 0) - return SFE_INTERNAL ; - - psf->blockwidth = psf->bytewidth * psf->sf.channels ; - - if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR) - { switch (psf->bytewidth) - { case 1 : - psf->read_short = dpcm_read_dsc2s ; - psf->read_int = dpcm_read_dsc2i ; - psf->read_float = dpcm_read_dsc2f ; - psf->read_double = dpcm_read_dsc2d ; - break ; - case 2 : - psf->read_short = dpcm_read_dles2s ; - psf->read_int = dpcm_read_dles2i ; - psf->read_float = dpcm_read_dles2f ; - psf->read_double = dpcm_read_dles2d ; - break ; - default : - psf_log_printf (psf, "dpcm_init() returning SFE_UNIMPLEMENTED\n") ; - return SFE_UNIMPLEMENTED ; - } ; - } ; - - if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR) - { switch (psf->bytewidth) - { case 1 : - psf->write_short = dpcm_write_s2dsc ; - psf->write_int = dpcm_write_i2dsc ; - psf->write_float = dpcm_write_f2dsc ; - psf->write_double = dpcm_write_d2dsc ; - break ; - case 2 : - psf->write_short = dpcm_write_s2dles ; - psf->write_int = dpcm_write_i2dles ; - psf->write_float = dpcm_write_f2dles ; - psf->write_double = dpcm_write_d2dles ; - break ; - default : - psf_log_printf (psf, "dpcm_init() returning SFE_UNIMPLEMENTED\n") ; - return SFE_UNIMPLEMENTED ; - } ; - } ; - - psf->filelength = psf_get_filelen (psf) ; - psf->datalength = (psf->dataend) ? psf->dataend - psf->dataoffset : - psf->filelength - psf->dataoffset ; - psf->sf.frames = psf->datalength / psf->blockwidth ; - - return 0 ; -} /* dpcm_init */ - -/*============================================================================== -*/ - -static sf_count_t -dpcm_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int total, bufferlen, len ; - - if ((pxi = psf->codec_data) == NULL) - return SFE_INTERNAL ; - - if (psf->datalength < 0 || psf->dataoffset < 0) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (offset == 0) - { psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - pxi->last_16 = 0 ; - return 0 ; - } ; - - if (offset < 0 || offset > psf->sf.frames) - { psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - if (mode != SFM_READ) - { /* What to do about write??? */ - psf->error = SFE_BAD_SEEK ; - return PSF_SEEK_ERROR ; - } ; - - psf_fseek (psf, psf->dataoffset, SEEK_SET) ; - - if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_DPCM_16) - { total = offset ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (total > 0) - { len = (total > bufferlen) ? bufferlen : total ; - total -= (int) dpcm_read_dles2s (psf, ubuf.sbuf, len) ; - } ; - } - else - { total = offset ; - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - while (total > 0) - { len = (total > bufferlen) ? bufferlen : total ; - total -= (int) dpcm_read_dsc2s (psf, ubuf.sbuf, len) ; - } ; - } ; - - return offset ; -} /* dpcm_seek */ - - -static int -xi_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) -{ XI_PRIVATE *pxi ; - sf_count_t current ; - const char *string ; - - if ((pxi = psf->codec_data) == NULL) - return SFE_INTERNAL ; - - current = psf_ftell (psf) ; - - /* Reset the current header length to zero. */ - psf->header.ptr [0] = 0 ; - psf->header.indx = 0 ; - psf_fseek (psf, 0, SEEK_SET) ; - - string = "Extended Instrument: " ; - psf_binheader_writef (psf, "b", BHWv (string), BHWz (strlen (string))) ; - psf_binheader_writef (psf, "b1", BHWv (pxi->filename), BHWz (sizeof (pxi->filename)), BHW1 (0x1A)) ; - - /* Write software version and two byte XI version. */ - psf_binheader_writef (psf, "eb2", BHWv (pxi->software), BHWz (sizeof (pxi->software)), BHW2 ((1 << 8) + 2)) ; - - /* - ** Jump note numbers (96), volume envelope (48), pan envelope (48), - ** volume points (1), pan points (1) - */ - psf_binheader_writef (psf, "z", BHWz ((size_t) (96 + 48 + 48 + 1 + 1))) ; - - /* Jump volume loop (3 bytes), pan loop (3), envelope flags (3), vibrato (3) - ** fade out (2), 22 unknown bytes, and then write sample_count (2 bytes). - */ - psf_binheader_writef (psf, "ez2z2", BHWz ((size_t) (4 * 3)), BHW2 (0x1234), BHWz (22), BHW2 (1)) ; - - pxi->loop_begin = 0 ; - pxi->loop_end = 0 ; - - psf_binheader_writef (psf, "et844", BHW8 (psf->sf.frames), BHW4 (pxi->loop_begin), BHW4 (pxi->loop_end)) ; - - /* volume, fine tune, flags, pan, note, namelen */ - psf_binheader_writef (psf, "111111", BHW1 (128), BHW1 (0), BHW1 (pxi->sample_flags), BHW1 (128), BHW1 (0), BHW1 (strlen (pxi->sample_name))) ; - - psf_binheader_writef (psf, "b", BHWv (pxi->sample_name), BHWz (sizeof (pxi->sample_name))) ; - - /* Header construction complete so write it out. */ - psf_fwrite (psf->header.ptr, psf->header.indx, 1, psf) ; - - if (psf->error) - return psf->error ; - - psf->dataoffset = psf->header.indx ; - - if (current > 0) - psf_fseek (psf, current, SEEK_SET) ; - - return psf->error ; -} /* xi_write_header */ - -static int -xi_read_header (SF_PRIVATE *psf) -{ char buffer [64], name [32] ; - short version, fade_out, sample_count ; - int k, loop_begin, loop_end ; - int sample_sizes [MAX_XI_SAMPLES] ; - - psf_binheader_readf (psf, "pb", 0, buffer, 21) ; - - memset (sample_sizes, 0, sizeof (sample_sizes)) ; - - buffer [20] = 0 ; - if (strcmp (buffer, "Extended Instrument:") != 0) - return SFE_XI_BAD_HEADER ; - - memset (buffer, 0, sizeof (buffer)) ; - psf_binheader_readf (psf, "b", buffer, 23) ; - - if (buffer [22] != 0x1A) - return SFE_XI_BAD_HEADER ; - - buffer [22] = 0 ; - for (k = 21 ; k >= 0 && buffer [k] == ' ' ; k --) - buffer [k] = 0 ; - - psf_log_printf (psf, "Extended Instrument : %s\n", buffer) ; - psf_store_string (psf, SF_STR_TITLE, buffer) ; - - psf_binheader_readf (psf, "be2", buffer, 20, &version) ; - buffer [19] = 0 ; - for (k = 18 ; k >= 0 && buffer [k] == ' ' ; k --) - buffer [k] = 0 ; - - psf_log_printf (psf, "Software : %s\nVersion : %d.%02d\n", buffer, version / 256, version % 256) ; - psf_store_string (psf, SF_STR_SOFTWARE, buffer) ; - - /* Jump note numbers (96), volume envelope (48), pan envelope (48), - ** volume points (1), pan points (1) - */ - psf_binheader_readf (psf, "j", 96 + 48 + 48 + 1 + 1) ; - - psf_binheader_readf (psf, "b", buffer, 12) ; - psf_log_printf (psf, "Volume Loop\n sustain : %u\n begin : %u\n end : %u\n", - buffer [0], buffer [1], buffer [2]) ; - psf_log_printf (psf, "Pan Loop\n sustain : %u\n begin : %u\n end : %u\n", - buffer [3], buffer [4], buffer [5]) ; - psf_log_printf (psf, "Envelope Flags\n volume : 0x%X\n pan : 0x%X\n", - buffer [6] & 0xFF, buffer [7] & 0xFF) ; - - psf_log_printf (psf, "Vibrato\n type : %u\n sweep : %u\n depth : %u\n rate : %u\n", - buffer [8], buffer [9], buffer [10], buffer [11]) ; - - /* - ** Read fade_out then jump reserved (2 bytes) and ???? (20 bytes) and - ** sample_count. - */ - psf_binheader_readf (psf, "e2j2", &fade_out, 2 + 20, &sample_count) ; - psf_log_printf (psf, "Fade out : %d\n", fade_out) ; - - /* XI file can contain up to 16 samples. */ - if (sample_count > MAX_XI_SAMPLES) - return SFE_XI_EXCESS_SAMPLES ; - - if (psf->instrument == NULL && (psf->instrument = psf_instrument_alloc ()) == NULL) - return SFE_MALLOC_FAILED ; - - psf->instrument->basenote = 0 ; - /* Log all data for each sample. */ - for (k = 0 ; k < sample_count ; k++) - { psf_binheader_readf (psf, "e444", &(sample_sizes [k]), &loop_begin, &loop_end) ; - - /* Read 5 know bytes, 1 unknown byte and 22 name bytes. */ - psf_binheader_readf (psf, "bb", buffer, 6, name, 22) ; - name [21] = 0 ; - - psf_log_printf (psf, "Sample #%d\n name : %s\n", k + 1, name) ; - - psf_log_printf (psf, " size : %d\n", sample_sizes [k]) ; - - psf_log_printf (psf, " loop\n begin : %d\n end : %d\n", loop_begin, loop_end) ; - - psf_log_printf (psf, " volume : %u\n f. tune : %d\n flags : 0x%02X ", - buffer [0] & 0xFF, buffer [1] & 0xFF, buffer [2] & 0xFF) ; - - psf_log_printf (psf, " (") ; - if (buffer [2] & 1) - psf_log_printf (psf, " Loop") ; - if (buffer [2] & 2) - psf_log_printf (psf, " PingPong") ; - psf_log_printf (psf, (buffer [2] & 16) ? " 16bit" : " 8bit") ; - psf_log_printf (psf, " )\n") ; - - psf_log_printf (psf, " pan : %u\n note : %d\n namelen : %d\n", - buffer [3] & 0xFF, buffer [4], buffer [5]) ; - - psf->instrument->basenote = buffer [4] ; - if (buffer [2] & 1) - { psf->instrument->loop_count = 1 ; - psf->instrument->loops [0].mode = (buffer [2] & 2) ? SF_LOOP_ALTERNATING : SF_LOOP_FORWARD ; - psf->instrument->loops [0].start = loop_begin ; - psf->instrument->loops [0].end = loop_end ; - } ; - - if (k != 0) - continue ; - - if (buffer [2] & 16) - { psf->sf.format = SF_FORMAT_XI | SF_FORMAT_DPCM_16 ; - psf->bytewidth = 2 ; - } - else - { psf->sf.format = SF_FORMAT_XI | SF_FORMAT_DPCM_8 ; - psf->bytewidth = 1 ; - } ; - } ; - - while (sample_count > 1 && sample_sizes [sample_count - 1] == 0) - sample_count -- ; - - /* Currently, we can only handle 1 sample per file. */ - - if (sample_count > 2) - { psf_log_printf (psf, "*** Sample count is less than 16 but more than 1.\n") ; - psf_log_printf (psf, " sample count : %d sample_sizes [%d] : %d\n", - sample_count, sample_count - 1, sample_sizes [sample_count - 1]) ; - return SFE_XI_EXCESS_SAMPLES ; - } ; - - psf->datalength = sample_sizes [0] ; - - psf->dataoffset = psf_ftell (psf) ; - if (psf->dataoffset < 0) - { psf_log_printf (psf, "*** Bad Data Offset : %D\n", psf->dataoffset) ; - return SFE_BAD_OFFSET ; - } ; - psf_log_printf (psf, "Data Offset : %D\n", psf->dataoffset) ; - - if (psf->dataoffset + psf->datalength > psf->filelength) - { psf_log_printf (psf, "*** File seems to be truncated. Should be at least %D bytes long.\n", - psf->dataoffset + sample_sizes [0]) ; - psf->datalength = psf->filelength - psf->dataoffset ; - } ; - - if (psf_fseek (psf, psf->dataoffset, SEEK_SET) != psf->dataoffset) - return SFE_BAD_SEEK ; - - psf->endian = SF_ENDIAN_LITTLE ; - psf->sf.channels = 1 ; /* Always mono */ - psf->sf.samplerate = 44100 ; /* Always */ - - psf->blockwidth = psf->sf.channels * psf->bytewidth ; - - if (! psf->sf.frames && psf->blockwidth) - psf->sf.frames = (psf->filelength - psf->dataoffset) / psf->blockwidth ; - - psf->instrument->gain = 1 ; - psf->instrument->velocity_lo = psf->instrument->key_lo = 0 ; - psf->instrument->velocity_hi = psf->instrument->key_hi = 127 ; - - return 0 ; -} /* xi_read_header */ - -/*============================================================================== -*/ - -static void dsc2s_array (XI_PRIVATE *pxi, signed char *src, int count, short *dest) ; -static void dsc2i_array (XI_PRIVATE *pxi, signed char *src, int count, int *dest) ; -static void dsc2f_array (XI_PRIVATE *pxi, signed char *src, int count, float *dest, float normfact) ; -static void dsc2d_array (XI_PRIVATE *pxi, signed char *src, int count, double *dest, double normfact) ; - -static void dles2s_array (XI_PRIVATE *pxi, short *src, int count, short *dest) ; -static void dles2i_array (XI_PRIVATE *pxi, short *src, int count, int *dest) ; -static void dles2f_array (XI_PRIVATE *pxi, short *src, int count, float *dest, float normfact) ; -static void dles2d_array (XI_PRIVATE *pxi, short *src, int count, double *dest, double normfact) ; - -static sf_count_t -dpcm_read_dsc2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - dsc2s_array (pxi, ubuf.scbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* dpcm_read_dsc2s */ - -static sf_count_t -dpcm_read_dsc2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - dsc2i_array (pxi, ubuf.scbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* dpcm_read_dsc2i */ - -static sf_count_t -dpcm_read_dsc2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - dsc2f_array (pxi, ubuf.scbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* dpcm_read_dsc2f */ - -static sf_count_t -dpcm_read_dsc2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x80) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - dsc2d_array (pxi, ubuf.scbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* dpcm_read_dsc2d */ - -/*------------------------------------------------------------------------------ -*/ - -static sf_count_t -dpcm_read_dles2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - dles2s_array (pxi, ubuf.sbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* dpcm_read_dles2s */ - -static sf_count_t -dpcm_read_dles2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - dles2i_array (pxi, ubuf.sbuf, readcount, ptr + total) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* dpcm_read_dles2i */ - -static sf_count_t -dpcm_read_dles2f (SF_PRIVATE *psf, float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - float normfact ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - dles2f_array (pxi, ubuf.sbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* dpcm_read_dles2f */ - -static sf_count_t -dpcm_read_dles2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, readcount ; - sf_count_t total = 0 ; - double normfact ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - readcount = (int) psf_fread (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - dles2d_array (pxi, ubuf.sbuf, readcount, ptr + total, normfact) ; - total += readcount ; - if (readcount < bufferlen) - break ; - len -= readcount ; - } ; - - return total ; -} /* dpcm_read_dles2d */ - -/*============================================================================== -*/ - -static void s2dsc_array (XI_PRIVATE *pxi, const short *src, signed char *dest, int count) ; -static void i2dsc_array (XI_PRIVATE *pxi, const int *src, signed char *dest, int count) ; -static void f2dsc_array (XI_PRIVATE *pxi, const float *src, signed char *dest, int count, float normfact) ; -static void d2dsc_array (XI_PRIVATE *pxi, const double *src, signed char *dest, int count, double normfact) ; - -static void s2dles_array (XI_PRIVATE *pxi, const short *src, short *dest, int count) ; -static void i2dles_array (XI_PRIVATE *pxi, const int *src, short *dest, int count) ; -static void f2dles_array (XI_PRIVATE *pxi, const float *src, short *dest, int count, float normfact) ; -static void d2dles_array (XI_PRIVATE *pxi, const double *src, short *dest, int count, double normfact) ; - - -static sf_count_t -dpcm_write_s2dsc (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2dsc_array (pxi, ptr + total, ubuf.scbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* dpcm_write_s2dsc */ - -static sf_count_t -dpcm_write_i2dsc (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2dsc_array (pxi, ptr + total, ubuf.scbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* dpcm_write_i2dsc */ - -static sf_count_t -dpcm_write_f2dsc (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - float normfact ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7F) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - f2dsc_array (pxi, ptr + total, ubuf.scbuf, bufferlen, normfact) ; - writecount = (int) psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* dpcm_write_f2dsc */ - -static sf_count_t -dpcm_write_d2dsc (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - double normfact ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7F) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.ucbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - d2dsc_array (pxi, ptr + total, ubuf.scbuf, bufferlen, normfact) ; - writecount = (int) psf_fwrite (ubuf.scbuf, sizeof (signed char), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* dpcm_write_d2dsc */ - - -static sf_count_t -dpcm_write_s2dles (SF_PRIVATE *psf, const short *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - s2dles_array (pxi, ptr + total, ubuf.sbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* dpcm_write_s2dles */ - -static sf_count_t -dpcm_write_i2dles (SF_PRIVATE *psf, const int *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - i2dles_array (pxi, ptr + total, ubuf.sbuf, bufferlen) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* dpcm_write_i2dles */ - -static sf_count_t -dpcm_write_f2dles (SF_PRIVATE *psf, const float *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - float normfact ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - f2dles_array (pxi, ptr + total, ubuf.sbuf, bufferlen, normfact) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* dpcm_write_f2dles */ - -static sf_count_t -dpcm_write_d2dles (SF_PRIVATE *psf, const double *ptr, sf_count_t len) -{ BUF_UNION ubuf ; - XI_PRIVATE *pxi ; - int bufferlen, writecount ; - sf_count_t total = 0 ; - double normfact ; - - if ((pxi = psf->codec_data) == NULL) - return 0 ; - - normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x7FFF) : 1.0 ; - - bufferlen = ARRAY_LEN (ubuf.sbuf) ; - - while (len > 0) - { if (len < bufferlen) - bufferlen = (int) len ; - d2dles_array (pxi, ptr + total, ubuf.sbuf, bufferlen, normfact) ; - writecount = (int) psf_fwrite (ubuf.sbuf, sizeof (short), bufferlen, psf) ; - total += writecount ; - if (writecount < bufferlen) - break ; - len -= writecount ; - } ; - - return total ; -} /* dpcm_write_d2dles */ - - -/*============================================================================== -*/ - -static void -dsc2s_array (XI_PRIVATE *pxi, signed char *src, int count, short *dest) -{ signed char last_val ; - int k ; - - last_val = pxi->last_16 >> 8 ; - - for (k = 0 ; k < count ; k++) - { last_val += src [k] ; - dest [k] = arith_shift_left (last_val, 8) ; - } ; - - pxi->last_16 = arith_shift_left (last_val, 8) ; -} /* dsc2s_array */ - -static void -dsc2i_array (XI_PRIVATE *pxi, signed char *src, int count, int *dest) -{ signed char last_val ; - int k ; - - last_val = pxi->last_16 >> 8 ; - - for (k = 0 ; k < count ; k++) - { last_val += src [k] ; - dest [k] = arith_shift_left (last_val, 24) ; - } ; - - pxi->last_16 = arith_shift_left (last_val, 8) ; -} /* dsc2i_array */ - -static void -dsc2f_array (XI_PRIVATE *pxi, signed char *src, int count, float *dest, float normfact) -{ signed char last_val ; - int k ; - - last_val = pxi->last_16 >> 8 ; - - for (k = 0 ; k < count ; k++) - { last_val += src [k] ; - dest [k] = last_val * normfact ; - } ; - - pxi->last_16 = arith_shift_left (last_val, 8) ; -} /* dsc2f_array */ - -static void -dsc2d_array (XI_PRIVATE *pxi, signed char *src, int count, double *dest, double normfact) -{ signed char last_val ; - int k ; - - last_val = pxi->last_16 >> 8 ; - - for (k = 0 ; k < count ; k++) - { last_val += src [k] ; - dest [k] = last_val * normfact ; - } ; - - pxi->last_16 = arith_shift_left (last_val, 8) ; -} /* dsc2d_array */ - -/*------------------------------------------------------------------------------ -*/ - -static void -s2dsc_array (XI_PRIVATE *pxi, const short *src, signed char *dest, int count) -{ signed char last_val, current ; - int k ; - - last_val = pxi->last_16 >> 8 ; - - for (k = 0 ; k < count ; k++) - { current = src [k] >> 8 ; - dest [k] = current - last_val ; - last_val = current ; - } ; - - pxi->last_16 = arith_shift_left (last_val, 8) ; -} /* s2dsc_array */ - -static void -i2dsc_array (XI_PRIVATE *pxi, const int *src, signed char *dest, int count) -{ signed char last_val, current ; - int k ; - - last_val = pxi->last_16 >> 8 ; - - for (k = 0 ; k < count ; k++) - { current = src [k] >> 24 ; - dest [k] = current - last_val ; - last_val = current ; - } ; - - pxi->last_16 = arith_shift_left (last_val, 8) ; -} /* i2dsc_array */ - -static void -f2dsc_array (XI_PRIVATE *pxi, const float *src, signed char *dest, int count, float normfact) -{ signed char last_val, current ; - int k ; - - last_val = pxi->last_16 >> 8 ; - - for (k = 0 ; k < count ; k++) - { current = psf_lrintf (src [k] * normfact) ; - dest [k] = current - last_val ; - last_val = current ; - } ; - - pxi->last_16 = arith_shift_left (last_val, 8) ; -} /* f2dsc_array */ - -static void -d2dsc_array (XI_PRIVATE *pxi, const double *src, signed char *dest, int count, double normfact) -{ signed char last_val, current ; - int k ; - - last_val = pxi->last_16 >> 8 ; - - for (k = 0 ; k < count ; k++) - { current = psf_lrint (src [k] * normfact) ; - dest [k] = current - last_val ; - last_val = current ; - } ; - - pxi->last_16 = arith_shift_left (last_val, 8) ; -} /* d2dsc_array */ - -/*============================================================================== -*/ - -static void -dles2s_array (XI_PRIVATE *pxi, short *src, int count, short *dest) -{ short last_val ; - int k ; - - last_val = pxi->last_16 ; - - for (k = 0 ; k < count ; k++) - { last_val += LE2H_16 (src [k]) ; - dest [k] = last_val ; - } ; - - pxi->last_16 = last_val ; -} /* dles2s_array */ - -static void -dles2i_array (XI_PRIVATE *pxi, short *src, int count, int *dest) -{ short last_val ; - int k ; - - last_val = pxi->last_16 ; - - for (k = 0 ; k < count ; k++) - { last_val += LE2H_16 (src [k]) ; - dest [k] = arith_shift_left (last_val, 16) ; - } ; - - pxi->last_16 = last_val ; -} /* dles2i_array */ - -static void -dles2f_array (XI_PRIVATE *pxi, short *src, int count, float *dest, float normfact) -{ short last_val ; - int k ; - - last_val = pxi->last_16 ; - - for (k = 0 ; k < count ; k++) - { last_val += LE2H_16 (src [k]) ; - dest [k] = last_val * normfact ; - } ; - - pxi->last_16 = last_val ; -} /* dles2f_array */ - -static void -dles2d_array (XI_PRIVATE *pxi, short *src, int count, double *dest, double normfact) -{ short last_val ; - int k ; - - last_val = pxi->last_16 ; - - for (k = 0 ; k < count ; k++) - { last_val += LE2H_16 (src [k]) ; - dest [k] = last_val * normfact ; - } ; - - pxi->last_16 = last_val ; -} /* dles2d_array */ - -/*------------------------------------------------------------------------------ -*/ - -static void -s2dles_array (XI_PRIVATE *pxi, const short *src, short *dest, int count) -{ short diff, last_val ; - int k ; - - last_val = pxi->last_16 ; - - for (k = 0 ; k < count ; k++) - { diff = src [k] - last_val ; - dest [k] = LE2H_16 (diff) ; - last_val = src [k] ; - } ; - - pxi->last_16 = last_val ; -} /* s2dles_array */ - -static void -i2dles_array (XI_PRIVATE *pxi, const int *src, short *dest, int count) -{ short diff, last_val ; - int k ; - - last_val = pxi->last_16 ; - - for (k = 0 ; k < count ; k++) - { diff = (src [k] >> 16) - last_val ; - dest [k] = LE2H_16 (diff) ; - last_val = src [k] >> 16 ; - } ; - - pxi->last_16 = last_val ; -} /* i2dles_array */ - -static void -f2dles_array (XI_PRIVATE *pxi, const float *src, short *dest, int count, float normfact) -{ short diff, last_val, current ; - int k ; - - last_val = pxi->last_16 ; - - for (k = 0 ; k < count ; k++) - { current = psf_lrintf (src [k] * normfact) ; - diff = current - last_val ; - dest [k] = LE2H_16 (diff) ; - last_val = current ; - } ; - - pxi->last_16 = last_val ; -} /* f2dles_array */ - -static void -d2dles_array (XI_PRIVATE *pxi, const double *src, short *dest, int count, double normfact) -{ short diff, last_val, current ; - int k ; - - last_val = pxi->last_16 ; - - for (k = 0 ; k < count ; k++) - { current = psf_lrint (src [k] * normfact) ; - diff = current - last_val ; - dest [k] = LE2H_16 (diff) ; - last_val = current ; - } ; - - pxi->last_16 = last_val ; -} /* d2dles_array */ diff --git a/Engine/lib/libsndfile/tests/aiff_rw_test.c b/Engine/lib/libsndfile/tests/aiff_rw_test.c deleted file mode 100644 index 54eec4ba9..000000000 --- a/Engine/lib/libsndfile/tests/aiff_rw_test.c +++ /dev/null @@ -1,169 +0,0 @@ -/* -** Copyright (C) 2003-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif -#include -#include - - -#include - -#include "utils.h" - - -static unsigned char aifc_data [] = -{ 'F' , 'O' , 'R' , 'M' , - 0x00, 0x00, 0x01, 0xE8, /* FORM length */ - - 'A' , 'I' , 'F' , 'C' , - 0x43, 0x4F, 0x4D, 0x4D, /* COMM */ - 0x00, 0x00, 0x00, 0x26, /* COMM length */ - 0x00, 0x01, 0x00, 0x00, 0x00, 0xAE, 0x00, 0x10, 0x40, 0x0D, 0xAC, 0x44, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x4F, 0x4E, 0x45, 0x0D, 'N' , - 'o' , 't' , ' ' , 'c' , 'o' , 'm' , 'p' , 'r' , 'e' , 's' , 's' , 'e' , - 'd' , 0x00, - - 'F' , 'V' , 'E' , 'R' , 0x00, 0x00, 0x00, 0x04, 0xA2, 0x80, 0x51, 0x40, - - /* A 'MARK' chunk. */ - 'M' , 'A' , 'R' , 'K' , 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 'A' , - 0x00, 0x02, 0x00, 0x00, 0x11, 0x3A, 0x02, 'B' , 'C' , 0x00, - 0x00, 0x03, 0x00, 0x00, 0x22, 0x74, 0x03, 'D' , 'E' , 'F', - 0x00, 0x04, 0x00, 0x00, 0x33, 0xAE, 0x04, 'G' , 'H' , 'I', 'J' , 0x00, - 0x00, 0x05, 0x00, 0x00, 0x44, 0xE8, 0x05, 'K' , 'L' , 'M', 'N' , 'O' , - - 'S' , 'S' , 'N' , 'D' , - 0x00, 0x00, 0x01, 0x64, /* SSND length */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xE0, 0xFF, 0xDB, 0xFF, 0xD0, 0xFF, 0xD5, 0xFF, 0xD6, 0xFF, 0xD0, - 0xFF, 0xBF, 0xFF, 0xBE, 0xFF, 0xB9, 0xFF, 0xC8, 0xFF, 0xBF, 0xFF, 0xD5, - 0xFF, 0xC3, 0xFF, 0xBF, 0xFF, 0xB3, 0xFF, 0xBE, 0xFF, 0xB4, 0xFF, 0xAD, - 0xFF, 0xAC, 0xFF, 0xAF, 0xFF, 0xB9, 0xFF, 0xB3, 0xFF, 0xA4, 0xFF, 0xA5, - 0xFF, 0x93, 0xFF, 0x95, 0xFF, 0x97, 0xFF, 0x98, 0xFF, 0x99, 0xFF, 0x9E, - 0xFF, 0x90, 0xFF, 0x80, 0xFF, 0x81, 0xFF, 0x7C, 0xFF, 0x80, 0xFF, 0x7C, - 0xFF, 0x72, 0xFF, 0x72, 0xFF, 0x6C, 0xFF, 0x75, 0xFF, 0x6E, 0xFF, 0x6F, - 0xFF, 0x66, 0xFF, 0x62, 0xFF, 0x5C, 0xFF, 0x64, 0xFF, 0x50, 0xFF, 0x56, - 0xFF, 0x56, 0xFF, 0x4A, 0xFF, 0x4A, 0xFF, 0x49, 0xFF, 0x44, 0xFF, 0x49, - 0xFF, 0x3B, 0xFF, 0x3F, 0xFF, 0x48, 0xFF, 0x46, 0xFF, 0x42, 0xFF, 0x49, - 0xFF, 0x43, 0xFF, 0x36, 0xFF, 0x40, 0xFF, 0x35, 0xFF, 0x3F, 0xFF, 0x36, - 0xFF, 0x37, 0xFF, 0x2E, 0xFF, 0x23, 0xFF, 0x23, 0xFF, 0x21, 0xFF, 0x1F, - 0xFF, 0x25, 0xFF, 0x2C, 0xFF, 0x1E, 0xFF, 0x22, 0xFF, 0x24, 0xFF, 0x2B, - 0xFF, 0x35, 0xFF, 0x27, 0xFF, 0x2E, 0xFF, 0x21, 0xFF, 0x18, 0xFF, 0x21, - 0xFF, 0x20, 0xFF, 0x0F, 0xFF, 0x21, 0xFF, 0x1A, 0xFF, 0x10, 0xFF, 0x09, - 0xFF, 0x1E, 0xFF, 0x19, 0xFF, 0x21, 0xFF, 0x13, 0xFF, 0x1B, 0xFF, 0x18, - 0xFF, 0x21, 0xFF, 0x0F, 0xFF, 0x1A, 0xFF, 0x16, 0xFF, 0x21, 0xFF, 0x1B, - 0xFF, 0x1B, 0xFF, 0x23, 0xFF, 0x1A, 0xFF, 0x21, 0xFF, 0x26, 0xFF, 0x23, - 0xFF, 0x26, 0xFF, 0x27, 0xFF, 0x30, 0xFF, 0x27, 0xFF, 0x2F, 0xFF, 0x28, - 0xFF, 0x2C, 0xFF, 0x27, 0xFF, 0x33, 0xFF, 0x29, 0xFF, 0x33, 0xFF, 0x3A, - 0xFF, 0x42, 0xFF, 0x3B, 0xFF, 0x4D, 0xFF, 0x4B, 0xFF, 0x4D, 0xFF, 0x4A, - 0xFF, 0x67, 0xFF, 0x77, 0xFF, 0x73, 0xFF, 0x7B, 0xFF, 0xDE, 0xFF, 0xAD, - 0x00, 0x4A, 0x00, 0x63, 0xEC, 0x8C, 0x03, 0xBB, 0x0E, 0xE4, 0x08, 0xF2, - 0x00, 0x70, 0xE3, 0xD1, 0xE5, 0xE4, 0x01, 0x6E, 0x0A, 0x67, 0x1C, 0x74, - 0xF8, 0x8E, 0x10, 0x7B, 0xEA, 0x3C, 0x09, 0x87, 0x1B, 0x24, 0xEF, 0x05, - 0x17, 0x76, 0x0D, 0x5B, 0x02, 0x43, 0xF5, 0xEF, 0x0C, 0x1D, 0xF7, 0x61, - 0x05, 0x95, 0x0B, 0xC2, 0xF1, 0x69, 0x1A, 0xA1, 0xEC, 0x75, 0xF4, 0x11, - 0x13, 0x4F, 0x13, 0x71, 0xFA, 0x33, 0xEC, 0x32, 0xC8, 0xCF, 0x05, 0xB0, - 0x0B, 0x61, 0x33, 0x19, 0xCE, 0x37, 0xEF, 0xD4, 0x21, 0x9D, 0xFA, 0xAE, -} ; - -static void rw_test (const char *filename) ; - -int -main (void) -{ const char *filename = "rw.aifc" ; - - print_test_name ("aiff_rw_test", filename) ; - - dump_data_to_file (filename, aifc_data, sizeof (aifc_data)) ; - - rw_test (filename) ; - - unlink (filename) ; - - puts ("ok") ; - return 0 ; -} /* main */ - -/*============================================================================== -*/ - -static void -rw_test (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo_rd, sfinfo_rw ; - - memset (&sfinfo_rd, 0, sizeof (sfinfo_rd)) ; - memset (&sfinfo_rw, 0, sizeof (sfinfo_rw)) ; - - /* Open the file in read only mode and fill in the SF_INFO struct. */ - if ((file = sf_open (filename, SFM_READ, &sfinfo_rd)) == NULL) - { printf ("\n\nLine %d : sf_open SFM_READ failed : %s\n\n", __LINE__, sf_strerror (NULL)) ; - exit (1) ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - /* Now open read/write and close the file. */ - if ((file = sf_open (filename, SFM_RDWR, &sfinfo_rw)) == NULL) - { printf ("\n\nLine %d : sf_open SFM_RDWR failed : %s\n\n", __LINE__, sf_strerror (NULL)) ; - exit (1) ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - /* Open again as read only again and fill in a new SF_INFO struct. */ - memset (&sfinfo_rw, 0, sizeof (sfinfo_rw)) ; - if ((file = sf_open (filename, SFM_READ, &sfinfo_rw)) == NULL) - { printf ("\n\nLine %d : sf_open SFM_RDWR failed : %s\n\n", __LINE__, sf_strerror (NULL)) ; - exit (1) ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - /* Now compare the two. */ - if (sfinfo_rd.format != sfinfo_rw.format) - { printf ("\n\nLine %d : format mismatch (0x%08X != 0x%08X).\n\n", __LINE__, - sfinfo_rd.format, sfinfo_rw.format) ; - exit (1) ; - } ; - - if (sfinfo_rd.channels != sfinfo_rw.channels) - { printf ("\n\nLine %d : channel count mismatch (%d != %d).\n\n", __LINE__, - sfinfo_rd.channels, sfinfo_rw.channels) ; - exit (1) ; - } ; - - if (sfinfo_rd.frames != sfinfo_rw.frames) - { printf ("\n\nLine %d : frame count mismatch (rd %" PRId64 " != rw %" PRId64 ").\n\n", __LINE__, - sfinfo_rd.frames, sfinfo_rw.frames) ; - exit (1) ; - } ; - - return ; -} /* rw_test */ - diff --git a/Engine/lib/libsndfile/tests/alaw_test.c b/Engine/lib/libsndfile/tests/alaw_test.c deleted file mode 100644 index 01b3dc4f5..000000000 --- a/Engine/lib/libsndfile/tests/alaw_test.c +++ /dev/null @@ -1,238 +0,0 @@ -/* -** Copyright (C) 1999-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_SIZE (65536) - -static unsigned char alaw_encode (int sample) ; -static int alaw_decode (unsigned int alawbyte) ; - -static short short_buffer [BUFFER_SIZE] ; -static unsigned char alaw_buffer [BUFFER_SIZE] ; - -int -main (void) -{ SNDFILE *file ; - SF_INFO sfinfo ; - const char *filename ; - int k ; - - print_test_name ("alaw_test", "encoder") ; - - filename = "alaw_test.raw" ; - - sf_info_setup (&sfinfo, SF_FORMAT_RAW | SF_FORMAT_ALAW, 44100, 1) ; - - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { printf ("sf_open_write failed with error : ") ; - fflush (stdout) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - /* Generate a file containing all possible 16 bit sample values - ** and write it to disk as alaw encoded.frames. - */ - - for (k = 0 ; k < 0x10000 ; k++) - short_buffer [k] = k & 0xFFFF ; - - sf_write_short (file, short_buffer, BUFFER_SIZE) ; - sf_close (file) ; - - /* Now open that file and compare the alaw encoded sample values - ** with what they should be. - */ - - if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) - { printf ("sf_open_write failed with error : ") ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - if (sf_read_raw (file, alaw_buffer, BUFFER_SIZE) != BUFFER_SIZE) - { printf ("sf_read_raw : ") ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - for (k = 0 ; k < 0x10000 ; k++) - if (alaw_encode (short_buffer [k]) != alaw_buffer [k]) - { printf ("Encoder error : sample #%d (0x%02X should be 0x%02X)\n", k, alaw_buffer [k], alaw_encode (short_buffer [k])) ; - exit (1) ; - } ; - - sf_close (file) ; - - puts ("ok") ; - - print_test_name ("alaw_test", "decoder") ; - /* Now generate a file containing all possible 8 bit encoded - ** sample values and write it to disk as alaw encoded.frames. - */ - - if (! (file = sf_open (filename, SFM_WRITE, &sfinfo))) - { printf ("sf_open_write failed with error : ") ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - for (k = 0 ; k < 256 ; k++) - alaw_buffer [k] = k & 0xFF ; - - sf_write_raw (file, alaw_buffer, 256) ; - sf_close (file) ; - - /* Now open that file and compare the alaw decoded sample values - ** with what they should be. - */ - - if (! (file = sf_open (filename, SFM_READ, &sfinfo))) - { printf ("sf_open_write failed with error : ") ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - if (sf_read_short (file, short_buffer, 256) != 256) - { printf ("sf_read_short : ") ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - - for (k = 0 ; k < 256 ; k++) - if (short_buffer [k] != alaw_decode (alaw_buffer [k])) - { printf ("Decoder error : sample #%d (0x%02X should be 0x%02X)\n", k, short_buffer [k], alaw_decode (alaw_buffer [k])) ; - exit (1) ; - } ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; - - return 0 ; -} /* main */ - - -/*================================================================================= -** The following routines came from the sox-12.15 (Sound eXcahcnge) distribution. -** -** This code is not compiled into libsndfile. It is only used to test the -** libsndfile lookup tables for correctness. -** -** I have included the original authors comments. -*/ - -/* -** A-law routines by Graeme W. Gill. -** Date: 93/5/7 -** -** References: -** 1) CCITT Recommendation G.711 -** -*/ - -#define ACLIP 31744 - -static -unsigned char alaw_encode (int sample) -{ static int exp_lut [128] = - { 1, 1, 2, 2, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, - 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, - 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7 - } ; - - int sign, exponent, mantissa ; - unsigned char Alawbyte ; - - /* Get the sample into sign-magnitude. */ - sign = ((~sample) >> 8) & 0x80 ; /* set aside the sign */ - if (sign == 0) - sample = -sample ; /* get magnitude */ - if (sample > ACLIP) - sample = ACLIP ; /* clip the magnitude */ - - /* Convert from 16 bit linear to ulaw. */ - if (sample >= 256) - { exponent = exp_lut [(sample >> 8) & 0x7F] ; - mantissa = (sample >> (exponent + 3)) & 0x0F ; - Alawbyte = ((exponent << 4) | mantissa) ; - } - else - Alawbyte = (sample >> 4) ; - - Alawbyte ^= (sign ^ 0x55) ; - - return Alawbyte ; -} /* alaw_encode */ - -static -int alaw_decode (unsigned int Alawbyte) -{ static int exp_lut [8] = { 0, 264, 528, 1056, 2112, 4224, 8448, 16896 } ; - int sign, exponent, mantissa, sample ; - - Alawbyte ^= 0x55 ; - sign = (Alawbyte & 0x80) ; - Alawbyte &= 0x7f ; /* get magnitude */ - if (Alawbyte >= 16) - { exponent = (Alawbyte >> 4) & 0x07 ; - mantissa = Alawbyte & 0x0F ; - sample = exp_lut [exponent] + (mantissa << (exponent + 3)) ; - } - else - sample = (Alawbyte << 4) + 8 ; - if (sign == 0) - sample = -sample ; - - return sample ; -} /* alaw_decode */ - diff --git a/Engine/lib/libsndfile/tests/benchmark-0.0.28 b/Engine/lib/libsndfile/tests/benchmark-0.0.28 deleted file mode 100644 index 2d2b06f9b..000000000 --- a/Engine/lib/libsndfile/tests/benchmark-0.0.28 +++ /dev/null @@ -1,40 +0,0 @@ -erikd@coltrane > tests/benchmark -Benchmarking libsndfile-0.0.28 ------------------------------- -Each test takes a little over 5 seconds. - - Raw write PCM_16 : 30660117 samples per sec - Raw read PCM_16 : 62788982 samples per sec - -Native endian I/O : - Write short to PCM_16 : 83.37% of raw write - Read short from PCM_16 : 83.17% of raw read - Write int to PCM_24 : 30.78% of raw write - Read int from PCM_24 : 32.96% of raw read - Write int to PCM_32 : 42.05% of raw write - Read int from PCM_32 : 41.11% of raw read - Write float to PCM_16 : 17.75% of raw write - Read float from PCM_16 : 43.27% of raw read - Write float to PCM_24 : 15.30% of raw write - Read float from PCM_24 : 28.09% of raw read - Write float to PCM_32 : 14.55% of raw write - Read float from PCM_32 : 34.65% of raw read - Write float to FLOAT : 28.98% of raw write - Read float from FLOAT : 56.71% of raw read - -Endian swapped I/O : - Write short to PCM_16 : 43.39% of raw write - Read short from PCM_16 : 49.12% of raw read - Write int to PCM_24 : 29.65% of raw write - Read int from PCM_24 : 33.66% of raw read - Write int to PCM_32 : 19.62% of raw write - Read int from PCM_32 : 21.97% of raw read - Write float to PCM_16 : 17.63% of raw write - Read float from PCM_16 : 31.43% of raw read - Write float to PCM_24 : 14.91% of raw write - Read float from PCM_24 : 27.99% of raw read - Write float to PCM_32 : 13.69% of raw write - Read float from PCM_32 : 22.23% of raw read - Write float to FLOAT : 19.25% of raw write - Read float from FLOAT : 25.66% of raw read - diff --git a/Engine/lib/libsndfile/tests/benchmark-1.0.0 b/Engine/lib/libsndfile/tests/benchmark-1.0.0 deleted file mode 100644 index 292283641..000000000 --- a/Engine/lib/libsndfile/tests/benchmark-1.0.0 +++ /dev/null @@ -1,35 +0,0 @@ -Benchmarking libsndfile-1.0.0 ------------------------------ -Each test takes a little over 5 seconds. - - Raw write PCM_16 : 31084269 samples per sec - Raw read PCM_16 : 63597065 samples per sec - -Native endian I/O : - Write short to PCM_16 : 83.19% of raw write - Read short from PCM_16 : 82.93% of raw read - Write int to PCM_24 : 31.12% of raw write - Read int from PCM_24 : 37.90% of raw read - Write float to PCM_16 : 37.00% of raw write - Read float from PCM_16 : 45.53% of raw read - Write float to PCM_24 : 29.08% of raw write - Read float from PCM_24 : 28.48% of raw read - Write float to PCM_32 : 22.08% of raw write - Read float from PCM_32 : 31.21% of raw read - Write float to FLOAT : 28.70% of raw write - Read float from FLOAT : 56.32% of raw read - -Endian swapped I/O : - Write short to PCM_16 : 22.08% of raw write - Read short from PCM_16 : 23.20% of raw read - Write int to PCM_24 : 30.96% of raw write - Read int from PCM_24 : 37.76% of raw read - Write float to PCM_16 : 35.82% of raw write - Read float from PCM_16 : 22.61% of raw read - Write float to PCM_24 : 27.70% of raw write - Read float from PCM_24 : 28.37% of raw read - Write float to PCM_32 : 20.77% of raw write - Read float from PCM_32 : 23.46% of raw read - Write float to FLOAT : 15.03% of raw write - Read float from FLOAT : 15.43% of raw read - diff --git a/Engine/lib/libsndfile/tests/benchmark-1.0.0rc2 b/Engine/lib/libsndfile/tests/benchmark-1.0.0rc2 deleted file mode 100644 index 770224672..000000000 --- a/Engine/lib/libsndfile/tests/benchmark-1.0.0rc2 +++ /dev/null @@ -1,31 +0,0 @@ -Benchmarking libsndfile-1.0.0rc2 --------------------------------- -Each test takes a little over 5 seconds. - - Raw write PCM_16 : 31638069 samples per sec - Raw read PCM_16 : 62788982 samples per sec - -Native endian I/O : - Write short to PCM_16 : 82.37% of raw write - Read short from PCM_16 : 82.17% of raw read - Write int to PCM_24 : 30.80% of raw write - Read int from PCM_24 : 37.95% of raw read - Write float to PCM_16 : 36.22% of raw write - Read float from PCM_16 : 23.32% of raw read - Write float to PCM_24 : 28.41% of raw write - Read float from PCM_24 : 28.41% of raw read - Write float to FLOAT : 28.41% of raw write - Read float from FLOAT : 57.50% of raw read - -Endian swapped I/O : - Write short to PCM_16 : 21.73% of raw write - Read short from PCM_16 : 23.37% of raw read - Write int to PCM_24 : 31.02% of raw write - Read int from PCM_24 : 38.24% of raw read - Write float to PCM_16 : 35.51% of raw write - Read float from PCM_16 : 19.16% of raw read - Write float to PCM_24 : 27.37% of raw write - Read float from PCM_24 : 28.74% of raw read - Write float to FLOAT : 15.11% of raw write - Read float from FLOAT : 15.60% of raw read - diff --git a/Engine/lib/libsndfile/tests/benchmark-1.0.18pre16-hendrix b/Engine/lib/libsndfile/tests/benchmark-1.0.18pre16-hendrix deleted file mode 100644 index 951bc56d2..000000000 --- a/Engine/lib/libsndfile/tests/benchmark-1.0.18pre16-hendrix +++ /dev/null @@ -1,38 +0,0 @@ -Benchmarking libsndfile-1.0.18pre15 ------------------------------------ -Each test takes a little over 5 seconds. - - Raw write PCM_16 : 103189885 samples per sec - Raw read PCM_16 : 660854036 samples per sec - -Native endian I/O : - Write short to PCM_16 : 95.08% of raw write - Read short from PCM_16 : 96.39% of raw read - Write int to PCM_24 : 54.55% of raw write - Read int from PCM_24 : 28.50% of raw read - Write int to PCM_32 : 46.97% of raw write - Read int from PCM_32 : 39.98% of raw read - Write float to PCM_16 : 60.85% of raw write - Read float from PCM_16 : 27.79% of raw read - Write float to PCM_24 : 46.23% of raw write - Read float from PCM_24 : 22.62% of raw read - Write float to PCM_32 : 35.38% of raw write - Read float from PCM_32 : 24.18% of raw read - Write float to FLOAT : 47.73% of raw write - Read float from FLOAT : 40.62% of raw read - -Endian swapped I/O : - Write short to PCM_16 : 79.98% of raw write - Read short from PCM_16 : 49.27% of raw read - Write int to PCM_24 : 53.80% of raw write - Read int from PCM_24 : 28.50% of raw read - Write int to PCM_32 : 41.68% of raw write - Read int from PCM_32 : 25.89% of raw read - Write float to PCM_16 : 61.03% of raw write - Read float from PCM_16 : 27.74% of raw read - Write float to PCM_24 : 45.10% of raw write - Read float from PCM_24 : 22.43% of raw read - Write float to PCM_32 : 35.24% of raw write - Read float from PCM_32 : 22.37% of raw read - Write float to FLOAT : 42.01% of raw write - Read float from FLOAT : 28.98% of raw read diff --git a/Engine/lib/libsndfile/tests/benchmark-1.0.18pre16-mingus b/Engine/lib/libsndfile/tests/benchmark-1.0.18pre16-mingus deleted file mode 100644 index fa0584e14..000000000 --- a/Engine/lib/libsndfile/tests/benchmark-1.0.18pre16-mingus +++ /dev/null @@ -1,38 +0,0 @@ -Benchmarking libsndfile-1.0.18pre15 ------------------------------------ -Each test takes a little over 5 seconds. - - Raw write PCM_16 : 178237074 samples per sec - Raw read PCM_16 : 368885269 samples per sec - -Native endian I/O : - Write short to PCM_16 : 98.84% of raw write - Read short from PCM_16 : 147.10% of raw read - Write int to PCM_24 : 33.74% of raw write - Read int from PCM_24 : 30.82% of raw read - Write int to PCM_32 : 48.34% of raw write - Read int from PCM_32 : 62.43% of raw read - Write float to PCM_16 : 41.86% of raw write - Read float from PCM_16 : 36.73% of raw read - Write float to PCM_24 : 28.38% of raw write - Read float from PCM_24 : 19.50% of raw read - Write float to PCM_32 : 23.68% of raw write - Read float from PCM_32 : 28.76% of raw read - Write float to FLOAT : 47.21% of raw write - Read float from FLOAT : 60.85% of raw read - -Endian swapped I/O : - Write short to PCM_16 : 54.94% of raw write - Read short from PCM_16 : 59.03% of raw read - Write int to PCM_24 : 33.40% of raw write - Read int from PCM_24 : 31.98% of raw read - Write int to PCM_32 : 30.89% of raw write - Read int from PCM_32 : 33.68% of raw read - Write float to PCM_16 : 41.61% of raw write - Read float from PCM_16 : 26.76% of raw read - Write float to PCM_24 : 25.75% of raw write - Read float from PCM_24 : 19.84% of raw read - Write float to PCM_32 : 21.29% of raw write - Read float from PCM_32 : 21.78% of raw read - Write float to FLOAT : 30.82% of raw write - Read float from FLOAT : 35.04% of raw read diff --git a/Engine/lib/libsndfile/tests/benchmark-1.0.6pre10-coltrane b/Engine/lib/libsndfile/tests/benchmark-1.0.6pre10-coltrane deleted file mode 100644 index 12f71a8a7..000000000 --- a/Engine/lib/libsndfile/tests/benchmark-1.0.6pre10-coltrane +++ /dev/null @@ -1,39 +0,0 @@ -Benchmarking libsndfile-1.0.6pre10 ----------------------------------- -Each test takes a little over 5 seconds. - - Raw write PCM_16 : 28845961 samples per sec - Raw read PCM_16 : 63471874 samples per sec - -Native endian I/O : - Write short to PCM_16 : 86.21% of raw write - Read short from PCM_16 : 82.60% of raw read - Write int to PCM_24 : 34.89% of raw write - Read int from PCM_24 : 37.26% of raw read - Write int to PCM_32 : 43.36% of raw write - Read int from PCM_32 : 41.30% of raw read - Write float to PCM_16 : 43.02% of raw write - Read float from PCM_16 : 43.99% of raw read - Write float to PCM_24 : 32.72% of raw write - Read float from PCM_24 : 28.21% of raw read - Write float to PCM_32 : 25.92% of raw write - Read float from PCM_32 : 30.98% of raw read - Write float to FLOAT : 46.65% of raw write - Read float from FLOAT : 56.66% of raw read - -Endian swapped I/O : - Write short to PCM_16 : 54.53% of raw write - Read short from PCM_16 : 56.32% of raw read - Write int to PCM_24 : 35.28% of raw write - Read int from PCM_24 : 37.33% of raw read - Write int to PCM_32 : 26.21% of raw write - Read int from PCM_32 : 23.51% of raw read - Write float to PCM_16 : 41.39% of raw write - Read float from PCM_16 : 23.56% of raw read - Write float to PCM_24 : 30.86% of raw write - Read float from PCM_24 : 28.27% of raw read - Write float to PCM_32 : 23.83% of raw write - Read float from PCM_32 : 20.54% of raw read - Write float to FLOAT : 27.26% of raw write - Read float from FLOAT : 29.04% of raw read - diff --git a/Engine/lib/libsndfile/tests/benchmark-1.0.6pre10-miles b/Engine/lib/libsndfile/tests/benchmark-1.0.6pre10-miles deleted file mode 100644 index fffdb8463..000000000 --- a/Engine/lib/libsndfile/tests/benchmark-1.0.6pre10-miles +++ /dev/null @@ -1,39 +0,0 @@ -Benchmarking libsndfile-1.0.6pre10 ----------------------------------- -Each test takes a little over 5 seconds. - - Raw write PCM_16 : 40092612 samples per sec - Raw read PCM_16 : 42382563 samples per sec - -Native endian I/O : - Write short to PCM_16 : 61.90% of raw write - Read short from PCM_16 : 100.20% of raw read - Write int to PCM_24 : 28.69% of raw write - Read int from PCM_24 : 33.62% of raw read - Write int to PCM_32 : 31.14% of raw write - Read int from PCM_32 : 51.04% of raw read - Write float to PCM_16 : 25.57% of raw write - Read float from PCM_16 : 28.17% of raw read - Write float to PCM_24 : 23.59% of raw write - Read float from PCM_24 : 24.14% of raw read - Write float to PCM_32 : 18.00% of raw write - Read float from PCM_32 : 22.59% of raw read - Write float to FLOAT : 31.32% of raw write - Read float from FLOAT : 51.54% of raw read - -Endian swapped I/O : - Write short to PCM_16 : 42.81% of raw write - Read short from PCM_16 : 54.58% of raw read - Write int to PCM_24 : 29.28% of raw write - Read int from PCM_24 : 33.43% of raw read - Write int to PCM_32 : 22.21% of raw write - Read int from PCM_32 : 27.24% of raw read - Write float to PCM_16 : 25.76% of raw write - Read float from PCM_16 : 26.84% of raw read - Write float to PCM_24 : 23.71% of raw write - Read float from PCM_24 : 24.10% of raw read - Write float to PCM_32 : 18.47% of raw write - Read float from PCM_32 : 21.45% of raw read - Write float to FLOAT : 22.46% of raw write - Read float from FLOAT : 29.72% of raw read - diff --git a/Engine/lib/libsndfile/tests/benchmark-latest-coltrane b/Engine/lib/libsndfile/tests/benchmark-latest-coltrane deleted file mode 100644 index 97ce29a8a..000000000 --- a/Engine/lib/libsndfile/tests/benchmark-latest-coltrane +++ /dev/null @@ -1,75 +0,0 @@ -erikd@coltrane > cat tests/benchmark-0.0.28 -Benchmarking libsndfile-0.0.28 ------------------------------- -Each test takes a little over 5 seconds. - - Raw write PCM_16 : 31022959 samples per sec - Raw read PCM_16 : 63471874 samples per sec - -Native endian I/O : - Write short to PCM_16 : 83.19% of raw write - Read short from PCM_16 : 82.28% of raw read - Write int to PCM_24 : 30.81% of raw write - Read int from PCM_24 : 32.92% of raw read - Write float to PCM_16 : 17.70% of raw write - Read float from PCM_16 : 43.64% of raw read - Write float to PCM_24 : 15.09% of raw write - Read float from PCM_24 : 27.79% of raw read - Write float to PCM_32 : 14.32% of raw write - Read float from PCM_32 : 34.42% of raw read - Write float to FLOAT : 28.64% of raw write - Read float from FLOAT : 56.77% of raw read - -Endian swapped I/O : - Write short to PCM_16 : 44.04% of raw write - Read short from PCM_16 : 49.46% of raw read - Write int to PCM_24 : 28.92% of raw write - Read int from PCM_24 : 33.10% of raw read - Write float to PCM_16 : 17.30% of raw write - Read float from PCM_16 : 31.46% of raw read - Write float to PCM_24 : 14.62% of raw write - Read float from PCM_24 : 27.64% of raw read - Write float to PCM_32 : 13.65% of raw write - Read float from PCM_32 : 22.41% of raw read - Write float to FLOAT : 19.13% of raw write - Read float from FLOAT : 26.21% of raw read - -erikd@coltrane > tests/benchmark -Benchmarking libsndfile-1.0.0 ------------------------------ -Each test takes a little over 5 seconds. - - Raw write PCM_16 : 29884416 samples per sec - Raw read PCM_16 : 63347175 samples per sec - -Native endian I/O : - Write short to PCM_16 : 88.24% of raw write - Read short from PCM_16 : 82.76% of raw read - Write int to PCM_24 : 34.95% of raw write - Read int from PCM_24 : 37.17% of raw read - Write int to PCM_32 : 43.86% of raw write - Read int from PCM_32 : 41.22% of raw read - Write float to PCM_16 : 42.07% of raw write - Read float from PCM_16 : 44.25% of raw read - Write float to PCM_24 : 32.43% of raw write - Read float from PCM_24 : 28.93% of raw read - Write float to PCM_32 : 25.60% of raw write - Read float from PCM_32 : 31.10% of raw read - Write float to FLOAT : 45.55% of raw write - Read float from FLOAT : 57.41% of raw read - -Endian swapped I/O : - Write short to PCM_16 : 43.46% of raw write - Read short from PCM_16 : 43.99% of raw read - Write int to PCM_24 : 35.09% of raw write - Read int from PCM_24 : 37.34% of raw read - Write int to PCM_32 : 24.05% of raw write - Read int from PCM_32 : 19.74% of raw read - Write float to PCM_16 : 40.25% of raw write - Read float from PCM_16 : 32.15% of raw read - Write float to PCM_24 : 31.02% of raw write - Read float from PCM_24 : 28.82% of raw read - Write float to PCM_32 : 23.54% of raw write - Read float from PCM_32 : 23.65% of raw read - Write float to FLOAT : 24.87% of raw write - Read float from FLOAT : 20.28% of raw read diff --git a/Engine/lib/libsndfile/tests/benchmark.def b/Engine/lib/libsndfile/tests/benchmark.def deleted file mode 100644 index 382bf3b1a..000000000 --- a/Engine/lib/libsndfile/tests/benchmark.def +++ /dev/null @@ -1,17 +0,0 @@ -autogen definitions benchmark.tpl; - -data_type = { - type_name = short ; - multiplier = "32700.0" ; - }; - -data_type = { - type_name = int ; - multiplier = "32700.0 * (1 << 16)" ; - }; - -data_type = { - type_name = float ; - multiplier = "1.0" ; - }; - diff --git a/Engine/lib/libsndfile/tests/benchmark.tpl b/Engine/lib/libsndfile/tests/benchmark.tpl deleted file mode 100644 index 14b22e2e2..000000000 --- a/Engine/lib/libsndfile/tests/benchmark.tpl +++ /dev/null @@ -1,360 +0,0 @@ -[+ AutoGen5 template c +] -/* -** Copyright (C) 2002-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#if HAVE_UNISTD_H -#include -#endif - -#if (HAVE_DECL_S_IRGRP == 0) -#include -#endif - -#include -#include -#include -#include -#include - -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846264338 -#endif - -/* -** Neat solution to the Win32/OS2 binary file flage requirement. -** If O_BINARY isn't already defined by the inclusion of the system -** headers, set it to zero. -*/ -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -#define WRITE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC | O_BINARY) -#define READ_FLAGS (O_RDONLY | O_BINARY) - -#if (defined (WIN32) || defined (_WIN32) || defined (__OS2__)) - #define WRITE_PERMS 0777 -#else - #define WRITE_PERMS (S_IRUSR | S_IWUSR | S_IRGRP) -#endif - -#define BUFFER_SIZE (1 << 18) -#define BLOCK_COUNT (30) -#define TEST_DURATION (5) /* 5 Seconds. */ - -typedef struct -{ double write_rate ; - double read_rate ; -} PERF_STATS ; - -static void *data = NULL ; - -static void calc_raw_performance (PERF_STATS *stats) ; - -[+ FOR data_type -+]static void calc_[+ (get "type_name") +]_performance (int format, double read_rate, double write_rate) ; -[+ ENDFOR data_type -+] - -static int cpu_is_big_endian (void) ; - -static const char* get_subtype_str (int subtype) ; - -int -main (int argc, char *argv []) -{ PERF_STATS stats ; - char buffer [256] = "Benchmarking " ; - int format_major ; - - if (! (data = malloc (BUFFER_SIZE * sizeof (double)))) - { perror ("Error : malloc failed") ; - exit (1) ; - } ; - - sf_command (NULL, SFC_GET_LIB_VERSION, buffer + strlen (buffer), sizeof (buffer) - strlen (buffer)) ; - - puts (buffer) ; - memset (buffer, '-', strlen (buffer)) ; - puts (buffer) ; - printf ("Each test takes a little over %d seconds.\n\n", TEST_DURATION) ; - - calc_raw_performance (&stats) ; - - if (argc < 2 || strcmp ("--native-only", argv [1]) == 0) - { puts ("\nNative endian I/O :") ; - format_major = cpu_is_big_endian () ? SF_FORMAT_AIFF : SF_FORMAT_WAV ; - - calc_short_performance (format_major | SF_FORMAT_PCM_16, stats.read_rate, stats.write_rate) ; - calc_int_performance (format_major | SF_FORMAT_PCM_24, stats.read_rate, stats.write_rate) ; - calc_int_performance (format_major | SF_FORMAT_PCM_32, stats.read_rate, stats.write_rate) ; - calc_float_performance (format_major | SF_FORMAT_PCM_16, stats.read_rate, stats.write_rate) ; - calc_float_performance (format_major | SF_FORMAT_PCM_24, stats.read_rate, stats.write_rate) ; - calc_float_performance (format_major | SF_FORMAT_PCM_32, stats.read_rate, stats.write_rate) ; - calc_float_performance (format_major | SF_FORMAT_FLOAT , stats.read_rate, stats.write_rate) ; - } ; - - if (argc < 2 || strcmp ("--swap-only", argv [1]) == 0) - { puts ("\nEndian swapped I/O :") ; - format_major = cpu_is_big_endian () ? SF_FORMAT_WAV : SF_FORMAT_AIFF ; - - calc_short_performance (format_major | SF_FORMAT_PCM_16, stats.read_rate, stats.write_rate) ; - calc_int_performance (format_major | SF_FORMAT_PCM_24, stats.read_rate, stats.write_rate) ; - calc_int_performance (format_major | SF_FORMAT_PCM_32, stats.read_rate, stats.write_rate) ; - calc_float_performance (format_major | SF_FORMAT_PCM_16, stats.read_rate, stats.write_rate) ; - calc_float_performance (format_major | SF_FORMAT_PCM_24, stats.read_rate, stats.write_rate) ; - calc_float_performance (format_major | SF_FORMAT_PCM_32, stats.read_rate, stats.write_rate) ; - calc_float_performance (format_major | SF_FORMAT_FLOAT , stats.read_rate, stats.write_rate) ; - } ; - - puts ("") ; - - free (data) ; - - return 0 ; -} /* main */ - -/*============================================================================== -*/ - -static void -calc_raw_performance (PERF_STATS *stats) -{ clock_t start_clock, clock_time ; - int fd, k, byte_count, retval, op_count ; - const char *filename ; - - filename = "benchmark.dat" ; - - byte_count = BUFFER_SIZE * sizeof (short) ; - - /* Collect write stats */ - printf (" Raw write PCM_16 : ") ; - fflush (stdout) ; - - clock_time = 0 ; - op_count = 0 ; - start_clock = clock () ; - - while (clock_time < (CLOCKS_PER_SEC * TEST_DURATION)) - { if ((fd = open (filename, WRITE_FLAGS, WRITE_PERMS)) < 0) - { printf ("Error : not able to open file : %s\n", filename) ; - perror ("") ; - exit (1) ; - } ; - - for (k = 0 ; k < BLOCK_COUNT ; k++) - { if ((retval = write (fd, data, byte_count)) != byte_count) - { printf ("Error : write returned %d (should have been %d)\n", retval, byte_count) ; - exit (1) ; - } ; - } ; - - close (fd) ; - - clock_time = clock () - start_clock ; - op_count ++ ; - } ; - - stats->write_rate = (1.0 * BUFFER_SIZE) * BLOCK_COUNT * op_count ; - stats->write_rate *= (1.0 * CLOCKS_PER_SEC) / clock_time ; - printf ("%10.0f samples per sec\n", stats->write_rate) ; - - /* Collect read stats */ - printf (" Raw read PCM_16 : ") ; - fflush (stdout) ; - - clock_time = 0 ; - op_count = 0 ; - start_clock = clock () ; - - while (clock_time < (CLOCKS_PER_SEC * TEST_DURATION)) - { if ((fd = open (filename, READ_FLAGS)) < 0) - { printf ("Error : not able to open file : %s\n", filename) ; - perror ("") ; - exit (1) ; - } ; - - for (k = 0 ; k < BLOCK_COUNT ; k++) - { if ((retval = read (fd, data, byte_count)) != byte_count) - { printf ("Error : write returned %d (should have been %d)\n", retval, byte_count) ; - exit (1) ; - } ; - } ; - - close (fd) ; - - clock_time = clock () - start_clock ; - op_count ++ ; - } ; - - stats->read_rate = (1.0 * BUFFER_SIZE) * BLOCK_COUNT * op_count ; - stats->read_rate *= (1.0 * CLOCKS_PER_SEC) / clock_time ; - printf ("%10.0f samples per sec\n", stats->read_rate) ; - - unlink (filename) ; -} /* calc_raw_performance */ - -/*------------------------------------------------------------------------------ -*/ - -[+ FOR data_type -+]static void -calc_[+ (get "type_name") +]_performance (int format, double read_rate, double write_rate) -{ SNDFILE *file ; - SF_INFO sfinfo ; - clock_t start_clock, clock_time ; - double performance ; - int k, item_count, retval, op_count ; - const char* subtype ; - [+ (get "type_name") +] *[+ (get "type_name") +]_data ; - const char *filename ; - - filename = "benchmark.dat" ; - subtype = get_subtype_str (format & SF_FORMAT_SUBMASK) ; - - [+ (get "type_name") +]_data = data ; - item_count = BUFFER_SIZE ; - for (k = 0 ; k < item_count ; k++) - [+ (get "type_name") +]_data [k] = [+ (get "multiplier") +] * sin (2 * M_PI * k / 32000.0) ; - - /* Collect write stats */ - printf (" Write %-5s to %s : ", "[+ (get "type_name") +]", subtype) ; - fflush (stdout) ; - - sfinfo.channels = 1 ; - sfinfo.format = format ; - sfinfo.frames = 1 ; - sfinfo.samplerate = 32000 ; - - clock_time = 0 ; - op_count = 0 ; - start_clock = clock () ; - - while (clock_time < (CLOCKS_PER_SEC * TEST_DURATION)) - { if (! (file = sf_open (filename, SFM_WRITE, &sfinfo))) - { printf ("Error : not able to open file : %s\n", filename) ; - perror ("") ; - exit (1) ; - } ; - - /* Turn off the addition of a PEAK chunk. */ - sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ; - - for (k = 0 ; k < BLOCK_COUNT ; k++) - { if ((retval = sf_write_[+ (get "type_name") +] (file, [+ (get "type_name") +]_data, item_count)) != item_count) - { printf ("Error : sf_write_short returned %d (should have been %d)\n", retval, item_count) ; - exit (1) ; - } ; - } ; - - sf_close (file) ; - - clock_time = clock () - start_clock ; - op_count ++ ; - } ; - - performance = (1.0 * BUFFER_SIZE) * BLOCK_COUNT * op_count ; - performance *= (1.0 * CLOCKS_PER_SEC) / clock_time ; - printf ("%6.2f%% of raw write\n", 100.0 * performance / write_rate) ; - - /* Collect read stats */ - printf (" Read %-5s from %s : ", "[+ (get "type_name") +]", subtype) ; - fflush (stdout) ; - - clock_time = 0 ; - op_count = 0 ; - start_clock = clock () ; - - while (clock_time < (CLOCKS_PER_SEC * TEST_DURATION)) - { if (! (file = sf_open (filename, SFM_READ, &sfinfo))) - { printf ("Error : not able to open file : %s\n", filename) ; - perror ("") ; - exit (1) ; - } ; - - for (k = 0 ; k < BLOCK_COUNT ; k++) - { if ((retval = sf_read_[+ (get "type_name") +] (file, [+ (get "type_name") +]_data, item_count)) != item_count) - { printf ("Error : write returned %d (should have been %d)\n", retval, item_count) ; - exit (1) ; - } ; - } ; - - sf_close (file) ; - - clock_time = clock () - start_clock ; - op_count ++ ; - } ; - - performance = (1.0 * item_count) * BLOCK_COUNT * op_count ; - performance *= (1.0 * CLOCKS_PER_SEC) / clock_time ; - printf ("%6.2f%% of raw read\n", 100.0 * performance / read_rate) ; - - unlink (filename) ; - -} /* calc_[+ (get "type_name") +]_performance */ -[+ ENDFOR data_type -+] - -/*============================================================================== -*/ - -static int -cpu_is_big_endian (void) -{ unsigned char *cptr ; - int endtest ; - - endtest = 0x12345678 ; - - cptr = (unsigned char*) (&endtest) ; - - if (cptr [0] == 0x12 && cptr [1] == 0x34 && cptr [3] == 0x78) - return SF_TRUE ; - - return SF_FALSE ; -} /* cpu_is_big_endian */ - -static const char* -get_subtype_str (int subtype) -{ switch (subtype) - { case SF_FORMAT_PCM_16 : - return "PCM_16" ; - - case SF_FORMAT_PCM_24 : - return "PCM_24" ; - - case SF_FORMAT_PCM_32 : - return "PCM_32" ; - - case SF_FORMAT_FLOAT : - return "FLOAT " ; - - case SF_FORMAT_DOUBLE : - return "DOUBLE" ; - - default : break ; - } ; - - return "UNKNOWN" ; -} /* get_subtype_str */ - diff --git a/Engine/lib/libsndfile/tests/channel_test.c b/Engine/lib/libsndfile/tests/channel_test.c deleted file mode 100644 index a69cd32db..000000000 --- a/Engine/lib/libsndfile/tests/channel_test.c +++ /dev/null @@ -1,138 +0,0 @@ -/* -** Copyright (C) 2001-2015 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include - -#include "utils.h" - -#define BUFFER_LEN (1 << 10) -#define LOG_BUFFER_SIZE 1024 - -static void channel_test (void) ; -static double max_diff (const float *a, const float *b, unsigned int len, unsigned int * position) ; - -int -main (void) // int argc, char *argv []) -{ channel_test () ; - return 0 ; -} /* main */ - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -channel_test (void) -{ static float float_data [1024] ; - static float read_float [1024] ; - static int read_int [1024] ; - static short read_short [1024] ; - unsigned int ch, k, position = 0 ; - - gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 0.9) ; - - for (ch = 1 ; ch <= 8 ; ch++) - { SNDFILE *file ; - SF_INFO wsfinfo, rsfinfo ; - sf_count_t wframes = ARRAY_LEN (float_data) / ch ; - double maxdiff ; - char filename [256] ; - - snprintf (filename, sizeof (filename), "chan_%d.wav", ch) ; - print_test_name (__func__, filename) ; - - sf_info_setup (&wsfinfo, SF_FORMAT_WAV | SF_FORMAT_FLOAT, 48000, ch) ; - sf_info_clear (&rsfinfo) ; - - /* Write the test file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &wsfinfo, SF_FALSE, __LINE__) ; - test_writef_float_or_die (file, 0, float_data, wframes, __LINE__) ; - sf_close (file) ; - - /* Read it as float and test. */ - file = test_open_file_or_die (filename, SFM_READ, &rsfinfo, SF_FALSE, __LINE__) ; - exit_if_true (rsfinfo.frames == 0, - "\n\nLine %d : Frames in file %" PRId64 ".\n\n", __LINE__, rsfinfo.frames) ; - exit_if_true (wframes != rsfinfo.frames, - "\n\nLine %d : Wrote %" PRId64 ", read %" PRId64 " frames.\n\n", __LINE__, wframes, rsfinfo.frames) ; - - sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ; - - test_readf_float_or_die (file, 0, read_float, rsfinfo.frames, __LINE__) ; - compare_float_or_die (float_data, read_float, ch * rsfinfo.frames, __LINE__) ; - - /* Read it as short and test. */ - test_seek_or_die (file, 0, SEEK_SET, 0, ch, __LINE__) ; - test_readf_short_or_die (file, 0, read_short, rsfinfo.frames, __LINE__) ; - - for (k = 0 ; k < ARRAY_LEN (read_float) ; k++) - read_float [k] = read_short [k] * (0.9 / 0x8000) ; - - maxdiff = max_diff (float_data, read_float, ch * rsfinfo.frames, &position) ; - exit_if_true (maxdiff > 0.5, "\n\nLine %d : Max diff is %f at index %u\n\n", __LINE__, maxdiff, position) ; - - /* Read it as int and test. */ - test_seek_or_die (file, 0, SEEK_SET, 0, ch, __LINE__) ; - test_readf_int_or_die (file, 0, read_int, rsfinfo.frames, __LINE__) ; - - for (k = 0 ; k < ARRAY_LEN (read_float) ; k++) - read_float [k] = read_int [k] * (0.9 / 0x80000000) ; - - maxdiff = max_diff (float_data, read_float, ch * rsfinfo.frames, &position) ; - exit_if_true (maxdiff > 0.5, "\n\nLine %d : Max diff is %f at index %u\n\n", __LINE__, maxdiff, position) ; - - sf_close (file) ; - unlink (filename) ; - printf ("ok\n") ; - } ; - - return ; -} /* channel_test */ - -static double -max_diff (const float *a, const float *b, unsigned int len, unsigned int * position) -{ double mdiff = 0.0, diff ; - unsigned int k ; - - for (k = 0 ; k < len ; k++) - { diff = fabs (a [k] - b [k]) ; - if (diff > mdiff) - { mdiff = diff ; - *position = k ; - } ; - } ; - - return mdiff ; -} /* max_diff */ diff --git a/Engine/lib/libsndfile/tests/checksum_test.c b/Engine/lib/libsndfile/tests/checksum_test.c deleted file mode 100644 index 4b37b3d37..000000000 --- a/Engine/lib/libsndfile/tests/checksum_test.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -** Copyright (C) 2008-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include - -#include "utils.h" - -#define SAMPLE_RATE 8000 - -typedef struct -{ int enc_fmt ; - - const char * enc_name ; - const char * dec_name ; - - uint64_t enc_cksum ; - uint64_t dec_cksum ; -} CHECKSUM ; - -static CHECKSUM -checksum_orig [] = -{ - { SF_FORMAT_RAW | SF_FORMAT_ULAW, - "checksum.ulaw", "cksum_ulaw.pcm16", - 0xbd99d34ccbe2fLL, 0xda82168ed82e9LL - }, - { SF_FORMAT_RAW | SF_FORMAT_ALAW, - "checksum.alaw", "cksum_alaw.pcm16", - 0x0004afddc0fcf4bdLL, 0x2e7320230b88LL - }, - { SF_FORMAT_RAW | SF_FORMAT_GSM610, - "checksum.gsm", "cksum_gsm.pcm16", - 0xa06a3faaaf684LL, 0x2d7ff668efeb9LL - }, - { SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, - "checksum.vox", "cksum_vox.pcm16", - 0x7c9d7afdb96a1LL, 0xe540df74a4b14LL - }, -} ; - -static void checksum_test (const CHECKSUM * cksum) ; - -static float orig [1 << 14] ; -static short data [1 << 14] ; - -int -main (void) -{ unsigned k ; - - gen_windowed_sine_float (orig, ARRAY_LEN (orig), 0.9) ; - - for (k = 0 ; k < ARRAY_LEN (checksum_orig) ; k++) - checksum_test (&checksum_orig [k]) ; - - return 0 ; -} /* main */ - -/*============================================================================== -*/ - -static void -checksum_test (const CHECKSUM * cksum) -{ SNDFILE * file ; - SF_INFO info ; - - print_test_name (__func__, cksum->enc_name) ; - - memset (&info, 0, sizeof (info)) ; - info.format = cksum->enc_fmt ; - info.channels = 1 ; - info.samplerate = SAMPLE_RATE ; - - file = test_open_file_or_die (cksum->enc_name, SFM_WRITE, &info, 0, __LINE__) ; - test_write_float_or_die (file, 0, orig, ARRAY_LEN (orig), __LINE__) ; - sf_close (file) ; - - check_file_hash_or_die (cksum->enc_name, cksum->enc_cksum, __LINE__) ; - puts ("ok") ; - - /*------------------------------------------------------------------------*/ - - print_test_name (__func__, cksum->dec_name) ; - - info.format = cksum->enc_fmt ; - info.channels = 1 ; - info.samplerate = SAMPLE_RATE ; - - file = test_open_file_or_die (cksum->enc_name, SFM_READ, &info, 0, __LINE__) ; - test_read_short_or_die (file, 0, data, ARRAY_LEN (data), __LINE__) ; - sf_close (file) ; - - info.format = SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16 ; - info.channels = 1 ; - info.samplerate = SAMPLE_RATE ; - - file = test_open_file_or_die (cksum->dec_name, SFM_WRITE, &info, 0, __LINE__) ; - test_write_short_or_die (file, 0, data, ARRAY_LEN (data), __LINE__) ; - sf_close (file) ; - - check_file_hash_or_die (cksum->dec_name, cksum->dec_cksum, __LINE__) ; - - remove (cksum->enc_name) ; - remove (cksum->dec_name) ; - - puts ("ok") ; -} /* checksum_test */ - diff --git a/Engine/lib/libsndfile/tests/chunk_test.c b/Engine/lib/libsndfile/tests/chunk_test.c deleted file mode 100644 index 0e358e811..000000000 --- a/Engine/lib/libsndfile/tests/chunk_test.c +++ /dev/null @@ -1,446 +0,0 @@ -/* -** Copyright (C) 2003-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "sfendian.h" -#include "utils.h" - -#define BUFFER_LEN (1 << 10) -#define LOG_BUFFER_SIZE 1024 - -static void chunk_test (const char *filename, int format) ; -static void wav_subchunk_test (unsigned int chunk_size) ; -static void large_free_test (const char *filename, int format, unsigned int chunk_size) ; - -int -main (int argc, char *argv []) -{ int do_all = 0 ; - int test_count = 0, k ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" wav - test adding chunks to WAV files\n") ; - printf (" aiff - test adding chunks to AIFF files\n") ; - printf (" caf - test adding chunks to CAF files\n") ; - printf (" rf64 - test adding chunks to RF64 files\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "wav")) - { chunk_test ("chunks_pcm16.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - chunk_test ("chunks_pcm16.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - chunk_test ("chunks_pcm16.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ; - - for (k = 100 ; k < 10000 ; k *= 4) - wav_subchunk_test (k) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { chunk_test ("chunks_pcm16.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "caf")) - { chunk_test ("chunks_pcm16.caf", SF_FORMAT_CAF | SF_FORMAT_PCM_16) ; - chunk_test ("chunks_alac.caf", SF_FORMAT_CAF | SF_FORMAT_ALAC_16) ; - large_free_test ("large_free.caf", SF_FORMAT_CAF | SF_FORMAT_PCM_16, 100) ; - large_free_test ("large_free.caf", SF_FORMAT_CAF | SF_FORMAT_PCM_16, 20000) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "rf64")) - { chunk_test ("chunks_pcm16.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; - test_count++ ; - } ; - - if (test_count == 0) - { printf ("Mono : ************************************\n") ; - printf ("Mono : * No '%s' test defined.\n", argv [1]) ; - printf ("Mono : ************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -chunk_test_helper (const char *filename, int format, const char * testdata) -{ SNDFILE *file ; - SF_INFO sfinfo ; - SF_CHUNK_INFO chunk_info ; - SF_CHUNK_ITERATOR * iterator ; - uint32_t length_before ; - int err, allow_fd ; - - switch (format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_ALAC_16 : - allow_fd = SF_FALSE ; - break ; - default : - allow_fd = SF_TRUE ; - break ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - sfinfo.format = format ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; - - /* Set up the chunk to write. */ - memset (&chunk_info, 0, sizeof (chunk_info)) ; - snprintf (chunk_info.id, sizeof (chunk_info.id), "Test") ; - chunk_info.id_size = 4 ; - chunk_info.data = strdup (testdata) ; - chunk_info.datalen = (unsigned int) strlen (chunk_info.data) ; - - length_before = chunk_info.datalen ; - - err = sf_set_chunk (file, &chunk_info) ; - exit_if_true ( - err != SF_ERR_NO_ERROR, - "\n\nLine %d : sf_set_chunk returned for testdata '%s' : %s\n\n", __LINE__, testdata, sf_error_number (err) - ) ; - - memset (chunk_info.data, 0, chunk_info.datalen) ; - free (chunk_info.data) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, allow_fd, __LINE__) ; - - memset (&chunk_info, 0, sizeof (chunk_info)) ; - snprintf (chunk_info.id, sizeof (chunk_info.id), "Test") ; - chunk_info.id_size = 4 ; - - iterator = sf_get_chunk_iterator (file, &chunk_info) ; - err = sf_get_chunk_size (iterator, &chunk_info) ; - exit_if_true ( - err != SF_ERR_NO_ERROR, - "\n\nLine %d : sf_get_chunk_size returned for testdata '%s' : %s\n\n", __LINE__, testdata, sf_error_number (err) - ) ; - - exit_if_true ( - length_before > chunk_info.datalen || chunk_info.datalen - length_before > 4, - "\n\nLine %d : testdata '%s' : Bad chunk length %u (previous length %u)\n\n", __LINE__, testdata, chunk_info.datalen, length_before - ) ; - - chunk_info.data = malloc (chunk_info.datalen) ; - err = sf_get_chunk_data (iterator, &chunk_info) ; - exit_if_true ( - err != SF_ERR_NO_ERROR, - "\n\nLine %d : sf_get_chunk_size returned for testdata '%s' : %s\n\n", __LINE__, testdata, sf_error_number (err) - ) ; - - exit_if_true ( - memcmp (testdata, chunk_info.data, length_before), - "\n\nLine %d : Data compare failed.\n %s\n %s\n\n", __LINE__, testdata, (char*) chunk_info.data - ) ; - - free (chunk_info.data) ; - - sf_close (file) ; - unlink (filename) ; -} /* chunk_test_helper */ - -static void -multichunk_test_helper (const char *filename, int format, const char * testdata [], size_t testdata_len) -{ SNDFILE *file ; - SF_INFO sfinfo ; - SF_CHUNK_INFO chunk_info ; - SF_CHUNK_ITERATOR * iterator ; - uint32_t length_before [16] ; - int err, allow_fd ; - size_t i ; - - - exit_if_true ( - ARRAY_LEN (length_before) < testdata_len, - "\n\nLine %d : Bad array length.\n\n", __LINE__ - ) ; - - - sfinfo.samplerate = 44100 ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - sfinfo.format = format ; - - switch (format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_ALAC_16 : - allow_fd = SF_FALSE ; - break ; - default : - allow_fd = SF_TRUE ; - break ; - } ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; - - /* Set up the chunk to write. */ - for (i = 0 ; i < testdata_len ; i++) - { memset (&chunk_info, 0, sizeof (chunk_info)) ; - snprintf (chunk_info.id, sizeof (chunk_info.id), "Test") ; - chunk_info.id_size = 4 ; - - chunk_info.data = strdup (testdata [i]) ; - chunk_info.datalen = (unsigned int) strlen (chunk_info.data) ; - - length_before [i] = chunk_info.datalen ; - - err = sf_set_chunk (file, &chunk_info) ; - exit_if_true ( - err != SF_ERR_NO_ERROR, - "\n\nLine %d : sf_set_chunk returned for testdata[%d] '%s' : %s\n\n", __LINE__, (int) i, testdata [i], sf_error_number (err) - ) ; - - memset (chunk_info.data, 0, chunk_info.datalen) ; - free (chunk_info.data) ; - } - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, allow_fd, __LINE__) ; - - memset (&chunk_info, 0, sizeof (chunk_info)) ; - snprintf (chunk_info.id, sizeof (chunk_info.id), "Test") ; - chunk_info.id_size = 4 ; - - iterator = sf_get_chunk_iterator (file, &chunk_info) ; - - i = 0 ; - while (iterator) - { memset (&chunk_info, 0, sizeof (chunk_info)) ; - err = sf_get_chunk_size (iterator, &chunk_info) ; - exit_if_true ( - i > testdata_len, - "\n\nLine %d : iterated to chunk #%d, but only %d chunks have been written\n\n", __LINE__, (int) i, (int) testdata_len - ) ; - - exit_if_true ( - err != SF_ERR_NO_ERROR, - "\n\nLine %d : sf_get_chunk_size returned for testdata[%d] '%s' : %s\n\n", __LINE__, (int) i, testdata [i], sf_error_number (err) - ) ; - - exit_if_true ( - length_before [i] > chunk_info.datalen || chunk_info.datalen - length_before [i] > 4, - "\n\nLine %d : testdata[%d] '%s' : Bad chunk length %u (previous length %u)\n\n", __LINE__, (int) i, testdata [i], chunk_info.datalen, length_before [i] - ) ; - - chunk_info.data = malloc (chunk_info.datalen) ; - err = sf_get_chunk_data (iterator, &chunk_info) ; - exit_if_true ( - err != SF_ERR_NO_ERROR, - "\n\nLine %d : sf_get_chunk_size returned for testdata[%d] '%s' : %s\n\n", __LINE__, (int) i, testdata [i], sf_error_number (err) - ) ; - - exit_if_true ( - 4 != chunk_info.id_size, - "\n\nLine %d : testdata[%d] : Bad ID length %u (previous length %u)\n\n", __LINE__, (int) i, chunk_info.id_size, 4 - ) ; - exit_if_true ( - memcmp ("Test", chunk_info.id, 4), - "\n\nLine %d : ID compare failed at %d.\n %s\n %s\n\n", __LINE__, (int) i, "Test", (char*) chunk_info.id - ) ; - - exit_if_true ( - memcmp (testdata [i], chunk_info.data, length_before [i]), - "\n\nLine %d : Data compare failed at %d.\n %s\n %s\n\n", __LINE__, (int) i, testdata [i], (char*) chunk_info.data - ) ; - - free (chunk_info.data) ; - iterator = sf_next_chunk_iterator (iterator) ; - i++ ; - } - - sf_close (file) ; - unlink (filename) ; -} /* multichunk_test_helper */ - - -static void -chunk_test (const char *filename, int format) -{ const char* testdata [] = - { "There can be only one.", "", "A", "AB", "ABC", "ABCD", "ABCDE" } ; - uint32_t k ; - - print_test_name (__func__, filename) ; - - for (k = 0 ; k < ARRAY_LEN (testdata) ; k++) - chunk_test_helper (filename, format, testdata [k]) ; - - multichunk_test_helper (filename, format, testdata, ARRAY_LEN (testdata)) ; - - puts ("ok") ; -} /* chunk_test */ - - -static void -wav_subchunk_test (unsigned int chunk_size) -{ SNDFILE * file ; - SF_INFO sfinfo ; - SF_CHUNK_INFO chunk_info ; - char filename [256] ; - char chunk_data [10240] ; - short audio [16] ; - int err, value ; - - snprintf (filename, sizeof (filename), "subchunk_%04u.wav", chunk_size) ; - print_test_name (__func__, filename) ; - - exit_if_true (sizeof (chunk_data) < chunk_size, "\n\nLine %d : sizeof (data) < chunk_size\n\n", __LINE__) ; - - memset (chunk_data, 53, sizeof (chunk_data)) ; - chunk_data [chunk_size] = 0 ; - - /* Fill in the chunk data. */ - value = MAKE_MARKER ('a', 'd', 't', 'l') ; - memcpy (chunk_data, &value, sizeof (value)) ; - value = MAKE_MARKER ('n', 'o', 't', 'e') ; - memcpy (chunk_data + 4, &value, sizeof (value)) ; - value = H2LE_32 (chunk_size - 12) ; - memcpy (chunk_data + 8, &value, sizeof (value)) ; - - sfinfo.samplerate = 44100 ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - /* Set up the chunk to write. */ - memset (&chunk_info, 0, sizeof (chunk_info)) ; - snprintf (chunk_info.id, sizeof (chunk_info.id), "LIST") ; - chunk_info.id_size = 4 ; - chunk_info.data = chunk_data ; - chunk_info.datalen = (unsigned int) chunk_size ; - - err = sf_set_chunk (file, &chunk_info) ; - exit_if_true ( - err != SF_ERR_NO_ERROR, - "\n\nLine %d : sf_set_chunk returned for testdata : %s\n\n", __LINE__, sf_error_number (err) - ) ; - - memset (chunk_info.data, 0, chunk_info.datalen) ; - - /* Add some audio data. */ - memset (audio, 0, sizeof (audio)) ; - sf_write_short (file, audio, ARRAY_LEN (audio)) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true ( - sfinfo.frames != ARRAY_LEN (audio), - "\n\nLine %d : Incorrect sample count (%d should be %d)\n", __LINE__, (int) sfinfo.frames, (int) ARRAY_LEN (audio) - ) ; - - if (chunk_size < 512) - check_log_buffer_or_die (file, __LINE__) ; - - sf_close (file) ; - - unlink (filename) ; - puts ("ok") ; -} /* wav_subchunk_test */ - -static void -large_free_test (const char *filename, int format, unsigned int chunk_size) -{ SNDFILE * file ; - SF_INFO sfinfo ; - SF_CHUNK_INFO chunk_info ; - char chunk_data [20002] ; - short audio [16] ; - int err ; - - print_test_name (__func__, filename) ; - - exit_if_true (sizeof (chunk_data) <= chunk_size, "\n\nLine %d : sizeof (data) < chunk_size\n\n", __LINE__) ; - - memset (chunk_data, 53, sizeof (chunk_data)) ; - chunk_data [chunk_size] = 0 ; - - sfinfo.samplerate = 44100 ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - sfinfo.format = format ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - /* Set up the chunk to write. */ - memset (&chunk_info, 0, sizeof (chunk_info)) ; - snprintf (chunk_info.id, sizeof (chunk_info.id), "free") ; - chunk_info.id_size = 4 ; - chunk_info.data = chunk_data ; - chunk_info.datalen = chunk_size ; - - err = sf_set_chunk (file, &chunk_info) ; - exit_if_true ( - err != SF_ERR_NO_ERROR, - "\n\nLine %d : sf_set_chunk returned for testdata : %s\n\n", __LINE__, sf_error_number (err) - ) ; - - memset (chunk_info.data, 0, chunk_info.datalen) ; - - /* Add some audio data. */ - memset (audio, 0, sizeof (audio)) ; - sf_write_short (file, audio, ARRAY_LEN (audio)) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true ( - sfinfo.frames != ARRAY_LEN (audio), - "\n\nLine %d : Incorrect sample count (%d should be %d)\n", __LINE__, (int) sfinfo.frames, (int) ARRAY_LEN (audio) - ) ; - - if (chunk_size < 512) - check_log_buffer_or_die (file, __LINE__) ; - - sf_close (file) ; - - unlink (filename) ; - puts ("ok") ; -} /* large_free_test */ diff --git a/Engine/lib/libsndfile/tests/command_test.c b/Engine/lib/libsndfile/tests/command_test.c deleted file mode 100644 index 86cbcfb39..000000000 --- a/Engine/lib/libsndfile/tests/command_test.c +++ /dev/null @@ -1,1806 +0,0 @@ -/* -** Copyright (C) 2001-2019 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include - -#include "sfendian.h" -#include "utils.h" - -#define BUFFER_LEN (1 << 10) -#define LOG_BUFFER_SIZE 1024 -#define data_MARKER MAKE_MARKER ('d', 'a', 't', 'a') - -static void float_norm_test (const char *filename) ; -static void double_norm_test (const char *filename) ; -static void format_tests (void) ; -static void calc_peak_test (int filetype, const char *filename, int channels) ; -static void truncate_test (const char *filename, int filetype) ; -static void instrument_test (const char *filename, int filetype) ; -static void cue_test (const char *filename, int filetype) ; -static void cue_test_var (const char *filename, int filetype, int count) ; -static void channel_map_test (const char *filename, int filetype) ; -static void current_sf_info_test (const char *filename) ; -static void raw_needs_endswap_test (const char *filename, int filetype) ; - -static void broadcast_test (const char *filename, int filetype) ; -static void broadcast_rdwr_test (const char *filename, int filetype) ; -static void broadcast_coding_history_test (const char *filename) ; -static void broadcast_coding_history_size (const char *filename) ; - -/* Cart Chunk tests */ -static void cart_test (const char *filename, int filetype) ; -static void cart_rdwr_test (const char *filename, int filetype) ; - -/* Force the start of this buffer to be double aligned. Sparc-solaris will -** choke if its not. -*/ - -static int int_data [BUFFER_LEN] ; -static float float_data [BUFFER_LEN] ; -static double double_data [BUFFER_LEN] ; - -int -main (int argc, char *argv []) -{ int do_all = 0 ; - int test_count = 0 ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" ver - test sf_command (SFC_GETLIB_VERSION)\n") ; - printf (" norm - test floating point normalisation\n") ; - printf (" format - test format string commands\n") ; - printf (" peak - test peak calculation\n") ; - printf (" trunc - test file truncation\n") ; - printf (" inst - test set/get of SF_INSTRUMENT.\n") ; - printf (" cue - test set/get of SF_CUES.\n") ; - printf (" chanmap - test set/get of channel map data..\n") ; - printf (" bext - test set/get of SF_BROADCAST_INFO.\n") ; - printf (" bextch - test set/get of SF_BROADCAST_INFO coding_history.\n") ; - printf (" cart - test set/get of SF_CART_INFO.\n") ; - printf (" rawend - test SFC_RAW_NEEDS_ENDSWAP.\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || strcmp (argv [1], "ver") == 0) - { char buffer [128] ; - - print_test_name ("version_test", "(none)") ; - buffer [0] = 0 ; - sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ; - if (strlen (buffer) < 1) - { printf ("Line %d: could not retrieve lib version.\n", __LINE__) ; - exit (1) ; - } ; - puts ("ok") ; - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "norm") == 0) - { /* Preliminary float/double normalisation tests. More testing - ** is done in the program 'floating_point_test'. - */ - float_norm_test ("cmd_float.wav") ; - double_norm_test ("cmd_double.wav") ; - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "peak") == 0) - { calc_peak_test (SF_ENDIAN_BIG | SF_FORMAT_RAW, "be-peak.raw", 1) ; - calc_peak_test (SF_ENDIAN_LITTLE | SF_FORMAT_RAW, "le-peak.raw", 1) ; - calc_peak_test (SF_ENDIAN_BIG | SF_FORMAT_RAW, "be-peak.raw", 7) ; - calc_peak_test (SF_ENDIAN_LITTLE | SF_FORMAT_RAW, "le-peak.raw", 7) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "format")) - { format_tests () ; - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "trunc") == 0) - { truncate_test ("truncate.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_32) ; - truncate_test ("truncate.au" , SF_FORMAT_AU | SF_FORMAT_PCM_16) ; - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "inst") == 0) - { instrument_test ("instrument.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - /*-instrument_test ("instrument.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_24) ;-*/ - /*-instrument_test ("instrument.xi", SF_FORMAT_XI | SF_FORMAT_DPCM_16) ;-*/ - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "cue") == 0) - { /* 2500 is close to the largest number of cues possible because of block sizes (enforced in aiff.c, wav.c) */ - int cuecounts [] = { 0, 1, 10, 100, 101, 1000, 1001, 2500 } ; - unsigned int i ; - - cue_test ("cue.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - cue_test ("cue.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_24) ; - - for (i = 0 ; i < ARRAY_LEN (cuecounts) ; i++) - { cue_test_var ("cue.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16, cuecounts [i]) ; - cue_test_var ("cue.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_24, cuecounts [i]) ; - } ; - - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "current_sf_info") == 0) - { current_sf_info_test ("current.wav") ; - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "bext") == 0) - { broadcast_test ("broadcast.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - broadcast_rdwr_test ("broadcast.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - - broadcast_test ("broadcast.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ; - broadcast_rdwr_test ("broadcast.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ; - - broadcast_test ("broadcast.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; - broadcast_rdwr_test ("broadcast.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "cart") == 0) - { cart_test ("cart.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - cart_rdwr_test ("cart.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - cart_test ("cart.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; - cart_rdwr_test ("cart.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "bextch") == 0) - { broadcast_coding_history_test ("coding_history.wav") ; - broadcast_coding_history_size ("coding_hist_size.wav") ; - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "chanmap") == 0) - { channel_map_test ("chanmap.wavex", SF_FORMAT_WAVEX | SF_FORMAT_PCM_16) ; - channel_map_test ("chanmap.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; - channel_map_test ("chanmap.aifc" , SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ; - channel_map_test ("chanmap.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_16) ; - test_count ++ ; - } ; - - if (do_all || strcmp (argv [1], "rawend") == 0) - { raw_needs_endswap_test ("raw_end.wav", SF_FORMAT_WAV) ; - raw_needs_endswap_test ("raw_end.wavex", SF_FORMAT_WAVEX) ; - raw_needs_endswap_test ("raw_end.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ; - raw_needs_endswap_test ("raw_end.aiff", SF_FORMAT_AIFF) ; - raw_needs_endswap_test ("raw_end.aiff_le", SF_ENDIAN_LITTLE | SF_FORMAT_AIFF) ; - test_count ++ ; - } ; - - if (test_count == 0) - { printf ("Mono : ************************************\n") ; - printf ("Mono : * No '%s' test defined.\n", argv [1]) ; - printf ("Mono : ************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -float_norm_test (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo ; - unsigned int k ; - - print_test_name ("float_norm_test", filename) ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = (SF_FORMAT_RAW | SF_FORMAT_PCM_16) ; - sfinfo.channels = 1 ; - sfinfo.frames = BUFFER_LEN ; - - /* Create float_data with all values being less than 1.0. */ - for (k = 0 ; k < BUFFER_LEN / 2 ; k++) - float_data [k] = (k + 5) / (2.0f * BUFFER_LEN) ; - for (k = BUFFER_LEN / 2 ; k < BUFFER_LEN ; k++) - float_data [k] = (float) (k + 5) ; - - if (! (file = sf_open (filename, SFM_WRITE, &sfinfo))) - { printf ("Line %d: sf_open_write failed with error : ", __LINE__) ; - fflush (stdout) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - /* Normalisation is on by default so no need to do anything here. */ - - if ((k = (unsigned int) sf_write_float (file, float_data, BUFFER_LEN / 2)) != BUFFER_LEN / 2) - { printf ("Line %d: sf_write_float failed with short write (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - /* Turn normalisation off. */ - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - - if ((k = (unsigned int) sf_write_float (file, float_data + BUFFER_LEN / 2, BUFFER_LEN / 2)) != BUFFER_LEN / 2) - { printf ("Line %d: sf_write_float failed with short write (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - sf_close (file) ; - - /* sfinfo struct should still contain correct data. */ - if (! (file = sf_open (filename, SFM_READ, &sfinfo))) - { printf ("Line %d: sf_open_read failed with error : ", __LINE__) ; - fflush (stdout) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - if (sfinfo.format != (SF_FORMAT_RAW | SF_FORMAT_PCM_16)) - { printf ("Line %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, (SF_FORMAT_RAW | SF_FORMAT_PCM_16), sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != BUFFER_LEN) - { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_LEN, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("Line %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - /* Read float_data and check that it is normalised (ie default). */ - if ((k = (unsigned int) sf_read_float (file, float_data, BUFFER_LEN)) != BUFFER_LEN) - { printf ("\n\nLine %d: sf_read_float failed with short read (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - if (float_data [k] >= 1.0) - { printf ("\n\nLine %d: float_data [%d] == %f which is greater than 1.0\n", __LINE__, k, float_data [k]) ; - exit (1) ; - } ; - - /* Seek to start of file, turn normalisation off, read float_data and check again. */ - sf_seek (file, 0, SEEK_SET) ; - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - - if ((k = (unsigned int) sf_read_float (file, float_data, BUFFER_LEN)) != BUFFER_LEN) - { printf ("\n\nLine %d: sf_read_float failed with short read (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - if (float_data [k] < 1.0) - { printf ("\n\nLine %d: float_data [%d] == %f which is less than 1.0\n", __LINE__, k, float_data [k]) ; - exit (1) ; - } ; - - /* Seek to start of file, turn normalisation on, read float_data and do final check. */ - sf_seek (file, 0, SEEK_SET) ; - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_TRUE) ; - - if ((k = (unsigned int) sf_read_float (file, float_data, BUFFER_LEN)) != BUFFER_LEN) - { printf ("\n\nLine %d: sf_read_float failed with short read (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - if (float_data [k] > 1.0) - { printf ("\n\nLine %d: float_data [%d] == %f which is greater than 1.0\n", __LINE__, k, float_data [k]) ; - exit (1) ; - } ; - - - sf_close (file) ; - - unlink (filename) ; - - printf ("ok\n") ; -} /* float_norm_test */ - -static void -double_norm_test (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo ; - unsigned int k ; - - print_test_name ("double_norm_test", filename) ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = (SF_FORMAT_RAW | SF_FORMAT_PCM_16) ; - sfinfo.channels = 1 ; - sfinfo.frames = BUFFER_LEN ; - - /* Create double_data with all values being less than 1.0. */ - for (k = 0 ; k < BUFFER_LEN / 2 ; k++) - double_data [k] = (k + 5) / (2.0 * BUFFER_LEN) ; - for (k = BUFFER_LEN / 2 ; k < BUFFER_LEN ; k++) - double_data [k] = (k + 5) ; - - if (! (file = sf_open (filename, SFM_WRITE, &sfinfo))) - { printf ("Line %d: sf_open_write failed with error : ", __LINE__) ; - fflush (stdout) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - /* Normailsation is on by default so no need to do anything here. */ - /*-sf_command (file, "set-norm-double", "true", 0) ;-*/ - - if ((k = (unsigned int) sf_write_double (file, double_data, BUFFER_LEN / 2)) != BUFFER_LEN / 2) - { printf ("Line %d: sf_write_double failed with short write (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - /* Turn normalisation off. */ - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - - if ((k = (unsigned int) sf_write_double (file, double_data + BUFFER_LEN / 2, BUFFER_LEN / 2)) != BUFFER_LEN / 2) - { printf ("Line %d: sf_write_double failed with short write (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - sf_close (file) ; - - if (! (file = sf_open (filename, SFM_READ, &sfinfo))) - { printf ("Line %d: sf_open_read failed with error : ", __LINE__) ; - fflush (stdout) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - if (sfinfo.format != (SF_FORMAT_RAW | SF_FORMAT_PCM_16)) - { printf ("Line %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, (SF_FORMAT_RAW | SF_FORMAT_PCM_16), sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != BUFFER_LEN) - { printf ("\n\nLine %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_LEN, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("Line %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - /* Read double_data and check that it is normalised (ie default). */ - if ((k = (unsigned int) sf_read_double (file, double_data, BUFFER_LEN)) != BUFFER_LEN) - { printf ("\n\nLine %d: sf_read_double failed with short read (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - if (double_data [k] >= 1.0) - { printf ("\n\nLine %d: double_data [%d] == %f which is greater than 1.0\n", __LINE__, k, double_data [k]) ; - exit (1) ; - } ; - - /* Seek to start of file, turn normalisation off, read double_data and check again. */ - sf_seek (file, 0, SEEK_SET) ; - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - - if ((k = (unsigned int) sf_read_double (file, double_data, BUFFER_LEN)) != BUFFER_LEN) - { printf ("\n\nLine %d: sf_read_double failed with short read (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - if (double_data [k] < 1.0) - { printf ("\n\nLine %d: double_data [%d] == %f which is less than 1.0\n", __LINE__, k, double_data [k]) ; - exit (1) ; - } ; - - /* Seek to start of file, turn normalisation on, read double_data and do final check. */ - sf_seek (file, 0, SEEK_SET) ; - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_TRUE) ; - - if ((k = (unsigned int) sf_read_double (file, double_data, BUFFER_LEN)) != BUFFER_LEN) - { printf ("\n\nLine %d: sf_read_double failed with short read (%d ->%d)\n", __LINE__, BUFFER_LEN, k) ; - exit (1) ; - } ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - if (double_data [k] > 1.0) - { printf ("\n\nLine %d: double_data [%d] == %f which is greater than 1.0\n", __LINE__, k, double_data [k]) ; - exit (1) ; - } ; - - - sf_close (file) ; - - unlink (filename) ; - - printf ("ok\n") ; -} /* double_norm_test */ - -static void -format_tests (void) -{ SF_FORMAT_INFO format_info ; - SF_INFO sfinfo ; - const char *last_name ; - int k, count ; - - print_test_name ("format_tests", "(null)") ; - - /* Clear out SF_INFO struct and set channels > 0. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.channels = 1 ; - - /* First test simple formats. */ - - sf_command (NULL, SFC_GET_SIMPLE_FORMAT_COUNT, &count, sizeof (int)) ; - - if (count < 0 || count > 30) - { printf ("Line %d: Weird count.\n", __LINE__) ; - exit (1) ; - } ; - - format_info.format = 0 ; - sf_command (NULL, SFC_GET_SIMPLE_FORMAT, &format_info, sizeof (format_info)) ; - - last_name = format_info.name ; - for (k = 1 ; k < count ; k ++) - { format_info.format = k ; - sf_command (NULL, SFC_GET_SIMPLE_FORMAT, &format_info, sizeof (format_info)) ; - if (strcmp (last_name, format_info.name) >= 0) - { printf ("\n\nLine %d: format names out of sequence `%s' < `%s'.\n", __LINE__, last_name, format_info.name) ; - exit (1) ; - } ; - sfinfo.format = format_info.format ; - - if (! sf_format_check (&sfinfo)) - { printf ("\n\nLine %d: sf_format_check failed.\n", __LINE__) ; - printf (" Name : %s\n", format_info.name) ; - printf (" Format : 0x%X\n", sfinfo.format) ; - printf (" Channels : 0x%X\n", sfinfo.channels) ; - printf (" Sample Rate : 0x%X\n", sfinfo.samplerate) ; - exit (1) ; - } ; - last_name = format_info.name ; - } ; - format_info.format = 666 ; - sf_command (NULL, SFC_GET_SIMPLE_FORMAT, &format_info, sizeof (format_info)) ; - - /* Now test major formats. */ - sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ; - - if (count < 0 || count > 30) - { printf ("Line %d: Weird count.\n", __LINE__) ; - exit (1) ; - } ; - - format_info.format = 0 ; - sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info)) ; - - last_name = format_info.name ; - for (k = 1 ; k < count ; k ++) - { format_info.format = k ; - sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info)) ; - if (strcmp (last_name, format_info.name) >= 0) - { printf ("\n\nLine %d: format names out of sequence (%d) `%s' < `%s'.\n", __LINE__, k, last_name, format_info.name) ; - exit (1) ; - } ; - - last_name = format_info.name ; - } ; - format_info.format = 666 ; - sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info)) ; - - /* Now test subtype formats. */ - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ; - - if (count < 0 || count > 33) - { printf ("Line %d: Weird count.\n", __LINE__) ; - exit (1) ; - } ; - - format_info.format = 0 ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)) ; - - last_name = format_info.name ; - for (k = 1 ; k < count ; k ++) - { format_info.format = k ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)) ; - } ; - format_info.format = 666 ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)) ; - - - printf ("ok\n") ; -} /* format_tests */ - -static void -calc_peak_test (int filetype, const char *filename, int channels) -{ SNDFILE *file ; - SF_INFO sfinfo ; - char label [128] ; - int k, format ; - sf_count_t buffer_len, frame_count ; - double peak ; - - snprintf (label, sizeof (label), "calc_peak_test (%d channels)", channels) ; - print_test_name (label, filename) ; - - format = filetype | SF_FORMAT_PCM_16 ; - - buffer_len = BUFFER_LEN - (BUFFER_LEN % channels) ; - frame_count = buffer_len / channels ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = format ; - sfinfo.channels = channels ; - sfinfo.frames = frame_count ; - - /* Create double_data with max value of 0.5. */ - for (k = 0 ; k < buffer_len ; k++) - double_data [k] = (k + 1) / (2.0 * buffer_len) ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - test_writef_double_or_die (file, 0, double_data, frame_count, __LINE__) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sfinfo.format != format) - { printf ("Line %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, format, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != frame_count) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%" PRId64 " => %" PRId64 ")\n", __LINE__, frame_count, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Line %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - sf_command (file, SFC_CALC_SIGNAL_MAX, &peak, sizeof (peak)) ; - if (fabs (peak - (1 << 14)) > 1.0) - { printf ("Line %d : Peak value should be %d (is %f).\n", __LINE__, (1 << 14), peak) ; - exit (1) ; - } ; - - sf_command (file, SFC_CALC_NORM_SIGNAL_MAX, &peak, sizeof (peak)) ; - if (fabs (peak - 0.5) > 4e-5) - { printf ("Line %d : Peak value should be %f (is %f).\n", __LINE__, 0.5, peak) ; - exit (1) ; - } ; - - sf_close (file) ; - - format = (filetype | SF_FORMAT_FLOAT) ; - sfinfo.samplerate = 44100 ; - sfinfo.format = format ; - sfinfo.channels = channels ; - sfinfo.frames = frame_count ; - - /* Create double_data with max value of 0.5. */ - for (k = 0 ; k < buffer_len ; k++) - double_data [k] = (k + 1) / (2.0 * buffer_len) ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - test_writef_double_or_die (file, 0, double_data, frame_count, __LINE__) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sfinfo.format != format) - { printf ("Line %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, format, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != frame_count) - { printf ("\n\nLine %d: Incorrect number of.frames in file. (%" PRId64 " => %" PRId64 ")\n", __LINE__, frame_count, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Line %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - sf_command (file, SFC_CALC_SIGNAL_MAX, &peak, sizeof (peak)) ; - if (fabs (peak - 0.5) > 1e-5) - { printf ("Line %d : Peak value should be %f (is %f).\n", __LINE__, 0.5, peak) ; - exit (1) ; - } ; - - sf_command (file, SFC_CALC_NORM_SIGNAL_MAX, &peak, sizeof (peak)) ; - if (fabs (peak - 0.5) > 1e-5) - { printf ("Line %d : Peak value should be %f (is %f).\n", __LINE__, 0.5, peak) ; - exit (1) ; - } ; - - sf_close (file) ; - - unlink (filename) ; - - printf ("ok\n") ; -} /* calc_peak_test */ - -static void -truncate_test (const char *filename, int filetype) -{ SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t len ; - - print_test_name ("truncate_test", filename) ; - - sfinfo.samplerate = 11025 ; - sfinfo.format = filetype ; - sfinfo.channels = 2 ; - - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; - - test_write_int_or_die (file, 0, int_data, BUFFER_LEN, __LINE__) ; - - len = 100 ; - if (sf_command (file, SFC_FILE_TRUNCATE, &len, sizeof (len))) - { printf ("Line %d: sf_command (SFC_FILE_TRUNCATE) returned error.\n", __LINE__) ; - exit (1) ; - } ; - - test_seek_or_die (file, 0, SEEK_CUR, len, 2, __LINE__) ; - test_seek_or_die (file, 0, SEEK_END, len, 2, __LINE__) ; - - sf_close (file) ; - - unlink (filename) ; - puts ("ok") ; -} /* truncate_test */ - -/*------------------------------------------------------------------------------ -*/ - -static void -instrumet_rw_test (const char *filename) -{ SNDFILE *sndfile ; - SF_INFO sfinfo ; - SF_INSTRUMENT inst ; - memset (&sfinfo, 0, sizeof (SF_INFO)) ; - - sndfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; - - if (sf_command (sndfile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE) - { inst.basenote = 22 ; - - if (sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE) - printf ("Sucess: [%s] updated\n", filename) ; - else - printf ("Error: SFC_SET_INSTRUMENT on [%s] [%s]\n", filename, sf_strerror (sndfile)) ; - } - else - printf ("Error: SFC_GET_INSTRUMENT on [%s] [%s]\n", filename, sf_strerror (sndfile)) ; - - - if (sf_command (sndfile, SFC_UPDATE_HEADER_NOW, NULL, 0) != 0) - printf ("Error: SFC_UPDATE_HEADER_NOW on [%s] [%s]\n", filename, sf_strerror (sndfile)) ; - - sf_write_sync (sndfile) ; - sf_close (sndfile) ; - - return ; -} /* instrumet_rw_test */ - -static void -instrument_test (const char *filename, int filetype) -{ static SF_INSTRUMENT write_inst = - { 2, /* gain */ - 3, /* detune */ - 4, /* basenote */ - 5, 6, /* key low and high */ - 7, 8, /* velocity low and high */ - 2, /* loop_count */ - { { 801, 2, 3, 0 }, - { 801, 3, 4, 0 }, - } - } ; - SF_INSTRUMENT read_inst ; - SNDFILE *file ; - SF_INFO sfinfo ; - - print_test_name ("instrument_test", filename) ; - - sfinfo.samplerate = 11025 ; - sfinfo.format = filetype ; - sfinfo.channels = 1 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_SET_INSTRUMENT, &write_inst, sizeof (write_inst)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_INSTRUMENT) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (&read_inst, 0, sizeof (read_inst)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_GET_INSTRUMENT, &read_inst, sizeof (read_inst)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_GET_INSTRUMENT) failed.\n\n", __LINE__) ; - exit (1) ; - return ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - if ((filetype & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV) - { /* - ** For all the fields that WAV doesn't support, modify the - ** write_inst struct to hold the default value that the WAV - ** module should hold. - */ - write_inst.key_lo = write_inst.velocity_lo = 0 ; - write_inst.key_hi = write_inst.velocity_hi = 127 ; - write_inst.gain = 1 ; - } ; - - if ((filetype & SF_FORMAT_TYPEMASK) == SF_FORMAT_XI) - { /* - ** For all the fields that XI doesn't support, modify the - ** write_inst struct to hold the default value that the XI - ** module should hold. - */ - write_inst.basenote = 0 ; - write_inst.detune = 0 ; - write_inst.key_lo = write_inst.velocity_lo = 0 ; - write_inst.key_hi = write_inst.velocity_hi = 127 ; - write_inst.gain = 1 ; - } ; - - if (memcmp (&write_inst, &read_inst, sizeof (write_inst)) != 0) - { printf ("\n\nLine %d : instrument comparison failed.\n\n", __LINE__) ; - printf ("W Base Note : %u\n" - " Detune : %u\n" - " Low Note : %u\tHigh Note : %u\n" - " Low Vel. : %u\tHigh Vel. : %u\n" - " Gain : %d\tCount : %d\n" - " mode : %d\n" - " start : %d\tend : %d\tcount :%d\n" - " mode : %d\n" - " start : %d\tend : %d\tcount :%d\n\n", - write_inst.basenote, - write_inst.detune, - write_inst.key_lo, write_inst.key_hi, - write_inst.velocity_lo, write_inst.velocity_hi, - write_inst.gain, write_inst.loop_count, - write_inst.loops [0].mode, write_inst.loops [0].start, - write_inst.loops [0].end, write_inst.loops [0].count, - write_inst.loops [1].mode, write_inst.loops [1].start, - write_inst.loops [1].end, write_inst.loops [1].count) ; - printf ("R Base Note : %u\n" - " Detune : %u\n" - " Low Note : %u\tHigh Note : %u\n" - " Low Vel. : %u\tHigh Vel. : %u\n" - " Gain : %d\tCount : %d\n" - " mode : %d\n" - " start : %d\tend : %d\tcount :%d\n" - " mode : %d\n" - " start : %d\tend : %d\tcount :%d\n\n", - read_inst.basenote, - read_inst.detune, - read_inst.key_lo, read_inst.key_hi, - read_inst.velocity_lo, read_inst.velocity_hi, - read_inst.gain, read_inst.loop_count, - read_inst.loops [0].mode, read_inst.loops [0].start, - read_inst.loops [0].end, read_inst.loops [0].count, - read_inst.loops [1].mode, read_inst.loops [1].start, - read_inst.loops [1].end, read_inst.loops [1].count) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_XI) - exit (1) ; - } ; - - if (0) instrumet_rw_test (filename) ; - - unlink (filename) ; - puts ("ok") ; -} /* instrument_test */ - -static void -print_cue (SF_CUES *cue, int i) -{ - printf (" indx[%d] : %d\n" - " position : %u\n" - " fcc_chunk : %x\n" - " chunk_start : %d\n" - " block_start : %d\n" - " sample_offset : %u\n" - " name : %s\n", - i, - cue->cue_points [i].indx, - cue->cue_points [i].position, - cue->cue_points [i].fcc_chunk, - cue->cue_points [i].chunk_start, - cue->cue_points [i].block_start, - cue->cue_points [i].sample_offset, - cue->cue_points [i].name) ; -} - -static int -cue_compare (SF_CUES *write_cue, SF_CUES *read_cue, size_t cue_size, int line) -{ - if (memcmp (write_cue, read_cue, cue_size) != 0) - { - printf ("\n\nLine %d : cue comparison failed.\n\n", line) ; - printf ("W Cue count : %d\n", write_cue->cue_count) ; - if (write_cue->cue_count > 0) - print_cue (write_cue, 0) ; - if (write_cue->cue_count > 2) /* print last if at least 2 */ - print_cue (write_cue, write_cue->cue_count - 1) ; - - printf ("R Cue count : %d\n", read_cue->cue_count) ; - if (read_cue->cue_count > 0) - print_cue (read_cue, 0) ; - if (read_cue->cue_count > 2) /* print last if at least 2 */ - print_cue (read_cue, read_cue->cue_count - 1) ; - - return SF_FALSE ; - } ; - - return SF_TRUE ; -} /* cue_compare */ - -static void -cue_rw_test (const char *filename) -{ SNDFILE *sndfile ; - SF_INFO sfinfo ; - SF_CUES cues ; - memset (&sfinfo, 0, sizeof (SF_INFO)) ; - - sndfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; - - exit_if_true ( - sf_command (sndfile, SFC_GET_CUE_COUNT, &cues.cue_count, sizeof (cues.cue_count)) != SF_TRUE, - "\nLine %d: SFC_GET_CUE_COUNT command failed.\n\n", __LINE__ - ) ; - - exit_if_true ( - cues.cue_count != 3, - "\nLine %d: Expected cue_count (%u) to be 3.\n\n", __LINE__, cues.cue_count - ) ; - - if (sf_command (sndfile, SFC_GET_CUE, &cues, sizeof (cues)) == SF_TRUE) - { cues.cue_points [1].sample_offset = 3 ; - - if (sf_command (sndfile, SFC_SET_CUE, &cues, sizeof (cues)) == SF_TRUE) - printf ("Sucess: [%s] updated\n", filename) ; - else - printf ("Error: SFC_SET_CUE on [%s] [%s]\n", filename, sf_strerror (sndfile)) ; - } - else - printf ("Error: SFC_GET_CUE on [%s] [%s]\n", filename, sf_strerror (sndfile)) ; - - - if (sf_command (sndfile, SFC_UPDATE_HEADER_NOW, NULL, 0) != 0) - printf ("Error: SFC_UPDATE_HEADER_NOW on [%s] [%s]\n", filename, sf_strerror (sndfile)) ; - - sf_write_sync (sndfile) ; - sf_close (sndfile) ; - - return ; -} /* cue_rw_test */ - -static void -cue_test (const char *filename, int filetype) -{ SF_CUES write_cue ; - SF_CUES read_cue ; - SNDFILE *file ; - SF_INFO sfinfo ; - - if (filetype == (SF_FORMAT_WAV | SF_FORMAT_PCM_16)) - { write_cue = (SF_CUES) - { 2, /* cue_count */ - { { 1, 0, data_MARKER, 0, 0, 1, "" }, - { 2, 0, data_MARKER, 0, 0, 2, "" }, - } - } ; - } - else - { write_cue = (SF_CUES) - { 2, /* cue_count */ - { { 1, 0, data_MARKER, 0, 0, 1, "Cue1" }, - { 2, 0, data_MARKER, 0, 0, 2, "Cue2" }, - } - } ; - } - - print_test_name ("cue_test", filename) ; - - sfinfo.samplerate = 11025 ; - sfinfo.format = filetype ; - sfinfo.channels = 1 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_SET_CUE, &write_cue, sizeof (write_cue)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_CUE) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (&read_cue, 0, sizeof (read_cue)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_GET_CUE, &read_cue, sizeof (read_cue)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_GET_CUE) failed.\n\n", __LINE__) ; - exit (1) ; - return ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - if (cue_compare (&write_cue, &read_cue, sizeof (write_cue), __LINE__) == SF_FALSE) - exit (1) ; - - if (0) cue_rw_test (filename) ; - - unlink (filename) ; - puts ("ok") ; -} /* cue_test */ - -/* calculate size of SF_CUES struct given number of cues */ -#define SF_CUES_SIZE(count) (sizeof (uint32_t) + sizeof (SF_CUE_POINT) * (count)) - -static void -cue_test_var (const char *filename, int filetype, int count) -{ size_t cues_size = SF_CUES_SIZE (count) ; - SF_CUES *write_cue = calloc (1, cues_size) ; - SF_CUES *read_cue = calloc (1, cues_size) ; - SNDFILE *file ; - SF_INFO sfinfo ; - char name [40] ; - int i ; - - snprintf (name, sizeof (name), "cue_test_var %d", count) ; - print_test_name (name, filename) ; - - if (write_cue == NULL || read_cue == NULL) - { printf ("ok (can't alloc)\n") ; - return ; - } ; - - write_cue->cue_count = count ; - for (i = 0 ; i < count ; i++) - { write_cue->cue_points [i] = (SF_CUE_POINT) { i, 0, data_MARKER, 0, 0, i, "" } ; - if (filetype == (SF_FORMAT_AIFF | SF_FORMAT_PCM_24)) - snprintf (write_cue->cue_points [i].name, sizeof (write_cue->cue_points [i].name), "Cue%03d", i) ; - } ; - - sfinfo.samplerate = 11025 ; - sfinfo.format = filetype ; - sfinfo.channels = 1 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_SET_CUE, write_cue, (int) cues_size) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_CUE) failed with %d cues, datasize %zu --> error: %s\n\n", __LINE__, count, cues_size, sf_strerror (file)) ; - exit (1) ; - } ; - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (read_cue, 0, cues_size) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sf_command (file, SFC_GET_CUE, read_cue, (int) cues_size) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_GET_CUE) failed with %d cues, datasize %zu --> error: %s\n\n", __LINE__, count, cues_size, sf_strerror (file)) ; - exit (1) ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - if (cue_compare (write_cue, read_cue, cues_size, __LINE__) == SF_FALSE) - { printf ("\n\nLine %d : cue_compare failed.\n\n", __LINE__) ; - exit (1) ; - } ; - - free (write_cue) ; - free (read_cue) ; - unlink (filename) ; - puts ("ok") ; -} /* cue_test_var */ - -static void -current_sf_info_test (const char *filename) -{ SNDFILE *outfile, *infile ; - SF_INFO outinfo, ininfo ; - - print_test_name ("current_sf_info_test", filename) ; - - outinfo.samplerate = 44100 ; - outinfo.format = (SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - outinfo.channels = 1 ; - outinfo.frames = 0 ; - - outfile = test_open_file_or_die (filename, SFM_WRITE, &outinfo, SF_TRUE, __LINE__) ; - sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, 0) ; - - exit_if_true (outinfo.frames != 0, - "\n\nLine %d : Initial sfinfo.frames is not zero.\n\n", __LINE__ - ) ; - - test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_command (outfile, SFC_GET_CURRENT_SF_INFO, &outinfo, sizeof (outinfo)) ; - - exit_if_true (outinfo.frames != BUFFER_LEN, - "\n\nLine %d : Initial sfinfo.frames (%" PRId64 ") should be %d.\n\n", __LINE__, - outinfo.frames, BUFFER_LEN - ) ; - - /* Read file making sure no channel map exists. */ - memset (&ininfo, 0, sizeof (ininfo)) ; - infile = test_open_file_or_die (filename, SFM_READ, &ininfo, SF_TRUE, __LINE__) ; - - test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ; - - sf_command (infile, SFC_GET_CURRENT_SF_INFO, &ininfo, sizeof (ininfo)) ; - - exit_if_true (ininfo.frames != BUFFER_LEN, - "\n\nLine %d : Initial sfinfo.frames (%" PRId64 ") should be %d.\n\n", __LINE__, - ininfo.frames, BUFFER_LEN - ) ; - - sf_close (outfile) ; - sf_close (infile) ; - - unlink (filename) ; - puts ("ok") ; -} /* current_sf_info_test */ - -static void -broadcast_test (const char *filename, int filetype) -{ static SF_BROADCAST_INFO bc_write, bc_read ; - SNDFILE *file ; - SF_INFO sfinfo ; - int errors = 0 ; - - print_test_name ("broadcast_test", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 11025 ; - sfinfo.format = filetype ; - sfinfo.channels = 1 ; - - memset (&bc_write, 0, sizeof (bc_write)) ; - - snprintf (bc_write.description, sizeof (bc_write.description), "Test description") ; - snprintf (bc_write.originator, sizeof (bc_write.originator), "Test originator") ; - snprintf (bc_write.originator_reference, sizeof (bc_write.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ; - snprintf (bc_write.origination_date, sizeof (bc_write.origination_date), "%d/%02d/%02d", 2006, 3, 30) ; - snprintf (bc_write.origination_time, sizeof (bc_write.origination_time), "%02d:%02d:%02d", 20, 27, 0) ; - snprintf (bc_write.umid, sizeof (bc_write.umid), "Some umid") ; - bc_write.coding_history_size = 0 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (&bc_read, 0, sizeof (bc_read)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_GET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - return ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - if (bc_read.version != 2) - { printf ("\n\nLine %d : Read bad version number %d.\n\n", __LINE__, bc_read.version) ; - exit (1) ; - return ; - } ; - - bc_read.version = bc_write.version = 0 ; - - if (memcmp (bc_write.description, bc_read.description, sizeof (bc_write.description)) != 0) - { printf ("\n\nLine %d : description mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, bc_write.description, bc_read.description) ; - errors ++ ; - } ; - - if (memcmp (bc_write.originator, bc_read.originator, sizeof (bc_write.originator)) != 0) - { printf ("\n\nLine %d : originator mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, bc_write.originator, bc_read.originator) ; - errors ++ ; - } ; - - if (memcmp (bc_write.originator_reference, bc_read.originator_reference, sizeof (bc_write.originator_reference)) != 0) - { printf ("\n\nLine %d : originator_reference mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, bc_write.originator_reference, bc_read.originator_reference) ; - errors ++ ; - } ; - - if (memcmp (bc_write.origination_date, bc_read.origination_date, sizeof (bc_write.origination_date)) != 0) - { printf ("\n\nLine %d : origination_date mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, bc_write.origination_date, bc_read.origination_date) ; - errors ++ ; - } ; - - if (memcmp (bc_write.origination_time, bc_read.origination_time, sizeof (bc_write.origination_time)) != 0) - { printf ("\n\nLine %d : origination_time mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, bc_write.origination_time, bc_read.origination_time) ; - errors ++ ; - } ; - - if (memcmp (bc_write.umid, bc_read.umid, sizeof (bc_write.umid)) != 0) - { printf ("\n\nLine %d : umid mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, bc_write.umid, bc_read.umid) ; - errors ++ ; - } ; - - if (errors) - exit (1) ; - - unlink (filename) ; - puts ("ok") ; -} /* broadcast_test */ - -static void -broadcast_rdwr_test (const char *filename, int filetype) -{ SF_BROADCAST_INFO binfo ; - SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t frames ; - - print_test_name (__func__, filename) ; - - create_short_sndfile (filename, filetype, 2) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - memset (&binfo, 0, sizeof (binfo)) ; - - snprintf (binfo.description, sizeof (binfo.description), "Test description") ; - snprintf (binfo.originator, sizeof (binfo.originator), "Test originator") ; - snprintf (binfo.originator_reference, sizeof (binfo.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ; - snprintf (binfo.origination_date, sizeof (binfo.origination_date), "%d/%02d/%02d", 2006, 3, 30) ; - snprintf (binfo.origination_time, sizeof (binfo.origination_time), "%02d:%02d:%02d", 20, 27, 0) ; - snprintf (binfo.umid, sizeof (binfo.umid), "Some umid") ; - binfo.coding_history_size = 0 ; - - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; - frames = sfinfo.frames ; - if (sf_command (file, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) != SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) should have failed but didn't.\n\n", __LINE__) ; - exit (1) ; - } ; - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_close (file) ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; - - unlink (filename) ; - puts ("ok") ; -} /* broadcast_rdwr_test */ - -static void -check_coding_history_newlines (const char *filename) -{ static SF_BROADCAST_INFO bc_write, bc_read ; - SNDFILE *file ; - SF_INFO sfinfo ; - unsigned k ; - - sfinfo.samplerate = 22050 ; - sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; - sfinfo.channels = 1 ; - - memset (&bc_write, 0, sizeof (bc_write)) ; - - snprintf (bc_write.description, sizeof (bc_write.description), "Test description") ; - snprintf (bc_write.originator, sizeof (bc_write.originator), "Test originator") ; - snprintf (bc_write.originator_reference, sizeof (bc_write.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ; - snprintf (bc_write.origination_date, sizeof (bc_write.origination_date), "%d/%02d/%02d", 2006, 3, 30) ; - snprintf (bc_write.origination_time, sizeof (bc_write.origination_time), "%02d:%02d:%02d", 20, 27, 0) ; - snprintf (bc_write.umid, sizeof (bc_write.umid), "Some umid") ; - bc_write.coding_history_size = snprintf (bc_write.coding_history, sizeof (bc_write.coding_history), "This has\nUnix\nand\rMac OS9\rline endings.\nLast line") ; ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (&bc_read, 0, sizeof (bc_read)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - if (bc_read.coding_history_size == 0) - { printf ("\n\nLine %d : missing coding history.\n\n", __LINE__) ; - exit (1) ; - } ; - - if (strstr (bc_read.coding_history, "Last line") == NULL) - { printf ("\n\nLine %d : coding history truncated.\n\n", __LINE__) ; - exit (1) ; - } ; - - for (k = 1 ; k < bc_read.coding_history_size ; k++) - { if (bc_read.coding_history [k] == '\n' && bc_read.coding_history [k - 1] != '\r') - { printf ("\n\nLine %d : '\\n' without '\\r' before.\n\n", __LINE__) ; - exit (1) ; - } ; - - if (bc_read.coding_history [k] == '\r' && bc_read.coding_history [k + 1] != '\n') - { printf ("\n\nLine %d : '\\r' without '\\n' after.\n\n", __LINE__) ; - exit (1) ; - } ; - - if (bc_read.coding_history [k] == 0 && k < bc_read.coding_history_size - 1) - { printf ("\n\nLine %d : '\\0' within coding history at index %d of %d.\n\n", __LINE__, k, bc_read.coding_history_size) ; - exit (1) ; - } ; - } ; - - return ; -} /* check_coding_history_newlines */ - -static void -broadcast_coding_history_test (const char *filename) -{ static SF_BROADCAST_INFO bc_write, bc_read ; - SNDFILE *file ; - SF_INFO sfinfo ; - const char *default_history = "A=PCM,F=22050,W=16,M=mono" ; - const char *supplied_history = - "A=PCM,F=44100,W=24,M=mono,T=other\r\n" - "A=PCM,F=22050,W=16,M=mono,T=yet_another\r\n" ; - - print_test_name ("broadcast_coding_history_test", filename) ; - - sfinfo.samplerate = 22050 ; - sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; - sfinfo.channels = 1 ; - - memset (&bc_write, 0, sizeof (bc_write)) ; - - snprintf (bc_write.description, sizeof (bc_write.description), "Test description") ; - snprintf (bc_write.originator, sizeof (bc_write.originator), "Test originator") ; - snprintf (bc_write.originator_reference, sizeof (bc_write.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ; - snprintf (bc_write.origination_date, sizeof (bc_write.origination_date), "%d/%02d/%02d", 2006, 3, 30) ; - snprintf (bc_write.origination_time, sizeof (bc_write.origination_time), "%02d:%02d:%02d", 20, 27, 0) ; - snprintf (bc_write.umid, sizeof (bc_write.umid), "Some umid") ; - /* Coding history will be filled in by the library. */ - bc_write.coding_history_size = 0 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (&bc_read, 0, sizeof (bc_read)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - if (bc_read.coding_history_size == 0) - { printf ("\n\nLine %d : missing coding history.\n\n", __LINE__) ; - exit (1) ; - } ; - - if (bc_read.coding_history_size < strlen (default_history) || memcmp (bc_read.coding_history, default_history, strlen (default_history)) != 0) - { printf ("\n\n" - "Line %d : unexpected coding history '%.*s',\n" - " should be '%s'\n\n", __LINE__, bc_read.coding_history_size, bc_read.coding_history, default_history) ; - exit (1) ; - } ; - - bc_write.coding_history_size = (uint32_t) strlen (supplied_history) ; - bc_write.coding_history_size = snprintf (bc_write.coding_history, sizeof (bc_write.coding_history), "%s", supplied_history) ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (&bc_read, 0, sizeof (bc_read)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - if (strstr (bc_read.coding_history, supplied_history) != bc_read.coding_history) - { printf ("\n\nLine %d : unexpected coding history :\n" - "----------------------------------------------------\n%s" - "----------------------------------------------------\n" - "should be this :\n" - "----------------------------------------------------\n%s" - "----------------------------------------------------\n" - "with one more line at the end.\n\n", - __LINE__, bc_read.coding_history, supplied_history) ; - exit (1) ; - } ; - - check_coding_history_newlines (filename) ; - - unlink (filename) ; - puts ("ok") ; -} /* broadcast_coding_history_test */ - -/*============================================================================== -*/ - -static void -broadcast_coding_history_size (const char *filename) -{ /* SF_BROADCAST_INFO struct with coding_history field of 1024 bytes. */ - static SF_BROADCAST_INFO_VAR (1024) bc_write ; - static SF_BROADCAST_INFO_VAR (1024) bc_read ; - SNDFILE *file ; - SF_INFO sfinfo ; - int k ; - - print_test_name (__func__, filename) ; - - sfinfo.samplerate = 22050 ; - sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; - sfinfo.channels = 1 ; - - memset (&bc_write, 0, sizeof (bc_write)) ; - - snprintf (bc_write.description, sizeof (bc_write.description), "Test description") ; - snprintf (bc_write.originator, sizeof (bc_write.originator), "Test originator") ; - snprintf (bc_write.originator_reference, sizeof (bc_write.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ; - snprintf (bc_write.origination_date, sizeof (bc_write.origination_date), "%d/%02d/%02d", 2006, 3, 30) ; - snprintf (bc_write.origination_time, sizeof (bc_write.origination_time), "%02d:%02d:%02d", 20, 27, 0) ; - snprintf (bc_write.umid, sizeof (bc_write.umid), "Some umid") ; - bc_write.coding_history_size = 0 ; - - for (k = 0 ; bc_write.coding_history_size < 512 ; k++) - { snprintf (bc_write.coding_history + bc_write.coding_history_size, - sizeof (bc_write.coding_history) - bc_write.coding_history_size, "line %4d\n", k) ; - bc_write.coding_history_size = (uint32_t) strlen (bc_write.coding_history) ; - } ; - - exit_if_true (bc_write.coding_history_size < 512, - "\n\nLine %d : bc_write.coding_history_size (%d) should be > 512.\n\n", __LINE__, bc_write.coding_history_size) ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (&bc_read, 0, sizeof (bc_read)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_GET_BROADCAST_INFO, &bc_read, sizeof (bc_read)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_BROADCAST_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - exit_if_true (bc_read.coding_history_size < 512, - "\n\nLine %d : unexpected coding history size %d (should be > 512).\n\n", __LINE__, bc_read.coding_history_size) ; - - exit_if_true (strstr (bc_read.coding_history, "libsndfile") == NULL, - "\n\nLine %d : coding history incomplete (should contain 'libsndfile').\n\n", __LINE__) ; - - unlink (filename) ; - puts ("ok") ; -} /* broadcast_coding_history_size */ - -/*============================================================================== -*/ -static void -cart_test (const char *filename, int filetype) -{ static SF_CART_INFO ca_write, ca_read ; - SNDFILE *file ; - SF_INFO sfinfo ; - int errors = 0 ; - - print_test_name ("cart_test", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 11025 ; - sfinfo.format = filetype ; - sfinfo.channels = 1 ; - memset (&ca_write, 0, sizeof (ca_write)) ; - - // example test data - snprintf (ca_write.artist, sizeof (ca_write.artist), "Test artist") ; - snprintf (ca_write.version, sizeof (ca_write.version), "Test version") ; - snprintf (ca_write.cut_id, sizeof (ca_write.cut_id), "Test cut ID") ; - snprintf (ca_write.client_id, sizeof (ca_write.client_id), "Test client ID") ; - snprintf (ca_write.category, sizeof (ca_write.category), "Test category") ; - snprintf (ca_write.classification, sizeof (ca_write.classification), "Test classification") ; - snprintf (ca_write.out_cue, sizeof (ca_write.out_cue), "Test out cue") ; - snprintf (ca_write.start_date, sizeof (ca_write.start_date), "%d/%02d/%02d", 2006, 3, 30) ; - snprintf (ca_write.start_time, sizeof (ca_write.start_time), "%02d:%02d:%02d", 20, 27, 0) ; - snprintf (ca_write.end_date, sizeof (ca_write.end_date), "%d/%02d/%02d", 2006, 3, 30) ; - snprintf (ca_write.end_time, sizeof (ca_write.end_time), "%02d:%02d:%02d", 20, 27, 0) ; - snprintf (ca_write.producer_app_id, sizeof (ca_write.producer_app_id), "Test producer app id") ; - snprintf (ca_write.producer_app_version, sizeof (ca_write.producer_app_version), "Test producer app version") ; - snprintf (ca_write.user_def, sizeof (ca_write.user_def), "test user def test test") ; - ca_write.level_reference = 42 ; - snprintf (ca_write.url, sizeof (ca_write.url), "http://www.test.com/test_url") ; - snprintf (ca_write.tag_text, sizeof (ca_write.tag_text), "tag text test! \r\n") ; // must be terminated \r\n to be valid - ca_write.tag_text_size = (uint32_t) strlen (ca_write.tag_text) ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_SET_CART_INFO, &ca_write, sizeof (ca_write)) == SF_FALSE) - exit (1) ; - - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (&ca_read, 0, sizeof (ca_read)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - if (sf_command (file, SFC_GET_CART_INFO, &ca_read, sizeof (ca_read)) == SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_GET_CART_INFO) failed.\n\n", __LINE__) ; - exit (1) ; - return ; - } ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - - if (memcmp (ca_write.artist, ca_read.artist, sizeof (ca_write.artist)) != 0) - { printf ("\n\nLine %d : artist mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.artist, ca_read.artist) ; - errors ++ ; - } ; - - if (memcmp (ca_write.version, ca_read.version, sizeof (ca_write.version)) != 0) - { printf ("\n\nLine %d : version mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.version, ca_read.version) ; - errors ++ ; - } ; - - if (memcmp (ca_write.title, ca_read.title, sizeof (ca_write.title)) != 0) - { printf ("\n\nLine %d : title mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.title, ca_read.title) ; - errors ++ ; - } ; - - if (memcmp (ca_write.cut_id, ca_read.cut_id, sizeof (ca_write.cut_id)) != 0) - { printf ("\n\nLine %d : cut_id mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.cut_id, ca_read.cut_id) ; - errors ++ ; - } ; - - if (memcmp (ca_write.client_id, ca_read.client_id, sizeof (ca_write.client_id)) != 0) - { printf ("\n\nLine %d : client_id mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.client_id, ca_read.client_id) ; - errors ++ ; - } ; - - if (memcmp (ca_write.category, ca_read.category, sizeof (ca_write.category)) != 0) - { printf ("\n\nLine %d : category mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.category, ca_read.category) ; - errors ++ ; - } ; - - if (memcmp (ca_write.out_cue, ca_read.out_cue, sizeof (ca_write.out_cue)) != 0) - { printf ("\n\nLine %d : out_cue mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.out_cue, ca_read.out_cue) ; - errors ++ ; - } ; - - if (memcmp (ca_write.start_date, ca_read.start_date, sizeof (ca_write.start_date)) != 0) - { printf ("\n\nLine %d : start_date mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.start_date, ca_read.start_date) ; - errors ++ ; - } ; - - - if (memcmp (ca_write.start_time, ca_read.start_time, sizeof (ca_write.start_time)) != 0) - { printf ("\n\nLine %d : start_time mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.start_time, ca_read.start_time) ; - errors ++ ; - } ; - - - if (memcmp (ca_write.end_date, ca_read.end_date, sizeof (ca_write.end_date)) != 0) - { printf ("\n\nLine %d : end_date mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.end_date, ca_read.end_date) ; - errors ++ ; - } ; - - - if (memcmp (ca_write.end_time, ca_read.end_time, sizeof (ca_write.end_time)) != 0) - { printf ("\n\nLine %d : end_time mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.end_time, ca_read.end_time) ; - errors ++ ; - } ; - - - if (memcmp (ca_write.producer_app_id, ca_read.producer_app_id, sizeof (ca_write.producer_app_id)) != 0) - { printf ("\n\nLine %d : producer_app_id mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.producer_app_id, ca_read.producer_app_id) ; - errors ++ ; - } ; - - - if (memcmp (ca_write.producer_app_version, ca_read.producer_app_version, sizeof (ca_write.producer_app_version)) != 0) - { printf ("\n\nLine %d : producer_app_version mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.producer_app_version, ca_read.producer_app_version) ; - errors ++ ; - } ; - - - if (memcmp (ca_write.user_def, ca_read.user_def, sizeof (ca_write.user_def)) != 0) - { printf ("\n\nLine %d : user_def mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.user_def, ca_read.user_def) ; - errors ++ ; - } ; - - - if (ca_write.level_reference != ca_read.level_reference) - { printf ("\n\nLine %d : level_reference mismatch :\n\twrite : '%d'\n\tread : '%d'\n\n", __LINE__, ca_write.level_reference, ca_read.level_reference) ; - errors ++ ; - } ; - - // TODO: make this more helpful - if (memcmp (ca_write.post_timers, ca_read.post_timers, sizeof (ca_write.post_timers)) != 0) - { printf ("\n\nLine %d : post_timers mismatch :\n'\n\n", __LINE__) ; - errors ++ ; - } ; - - if (memcmp (ca_write.url, ca_read.url, sizeof (ca_write.url)) != 0) - { printf ("\n\nLine %d : url mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.url, ca_read.url) ; - errors ++ ; - } ; - - - if (memcmp (ca_write.tag_text, ca_read.tag_text, (size_t) (ca_read.tag_text_size)) != 0) - { printf ("\n\nLine %d : tag_text mismatch :\n\twrite : '%s'\n\tread : '%s'\n\n", __LINE__, ca_write.tag_text, ca_read.tag_text) ; - errors ++ ; - } ; - - - if (errors) - exit (1) ; - - unlink (filename) ; - puts ("ok") ; -} /* cart_test */ - -static void -cart_rdwr_test (const char *filename, int filetype) -{ SF_CART_INFO cinfo ; - SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t frames ; - - print_test_name (__func__, filename) ; - - create_short_sndfile (filename, filetype, 2) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - memset (&cinfo, 0, sizeof (cinfo)) ; - - snprintf (cinfo.artist, sizeof (cinfo.artist), "Test artist") ; - snprintf (cinfo.version, sizeof (cinfo.version), "Test version") ; - snprintf (cinfo.cut_id, sizeof (cinfo.cut_id), "Test cut ID") ; - snprintf (cinfo.client_id, sizeof (cinfo.client_id), "Test client ID") ; - snprintf (cinfo.category, sizeof (cinfo.category), "Test category") ; - snprintf (cinfo.classification, sizeof (cinfo.classification), "Test classification") ; - snprintf (cinfo.out_cue, sizeof (cinfo.out_cue), "Test out cue") ; - snprintf (cinfo.start_date, sizeof (cinfo.start_date), "%d/%02d/%02d", 2006, 3, 30) ; - snprintf (cinfo.start_time, sizeof (cinfo.start_time), "%02d:%02d:%02d", 20, 27, 0) ; - snprintf (cinfo.end_date, sizeof (cinfo.end_date), "%d/%02d/%02d", 2006, 3, 30) ; - snprintf (cinfo.end_time, sizeof (cinfo.end_time), "%02d:%02d:%02d", 20, 27, 0) ; - snprintf (cinfo.producer_app_id, sizeof (cinfo.producer_app_id), "Test producer app id") ; - snprintf (cinfo.producer_app_version, sizeof (cinfo.producer_app_version), "Test producer app version") ; - snprintf (cinfo.user_def, sizeof (cinfo.user_def), "test user def test test") ; - cinfo.level_reference = 42 ; - snprintf (cinfo.url, sizeof (cinfo.url), "http://www.test.com/test_url") ; - snprintf (cinfo.tag_text, sizeof (cinfo.tag_text), "tag text test!\r\n") ; - cinfo.tag_text_size = (uint32_t) strlen (cinfo.tag_text) ; - - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; - frames = sfinfo.frames ; - if (sf_command (file, SFC_SET_CART_INFO, &cinfo, sizeof (cinfo)) != SF_FALSE) - { printf ("\n\nLine %d : sf_command (SFC_SET_CART_INFO) should have failed but didn't.\n\n", __LINE__) ; - exit (1) ; - } ; - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_close (file) ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; - - unlink (filename) ; - puts ("ok") ; -} /* cart_rdwr_test */ - -/*============================================================================== -*/ - -static void -channel_map_test (const char *filename, int filetype) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int channel_map_read [4], channel_map_write [4] = - { SF_CHANNEL_MAP_LEFT, SF_CHANNEL_MAP_RIGHT, SF_CHANNEL_MAP_LFE, - SF_CHANNEL_MAP_REAR_CENTER - } ; - - print_test_name ("channel_map_test", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 11025 ; - sfinfo.format = filetype ; - sfinfo.channels = ARRAY_LEN (channel_map_read) ; - - switch (filetype & SF_FORMAT_TYPEMASK) - { /* WAVEX and RF64 have a default channel map, even if you don't specify one. */ - case SF_FORMAT_WAVEX : - case SF_FORMAT_RF64 : - /* Write file without channel map. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - /* Read file making default channel map exists. */ - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - exit_if_true ( - sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map_read, sizeof (channel_map_read)) == SF_FALSE, - "\n\nLine %d : sf_command (SFC_GET_CHANNEL_MAP_INFO) should not have failed.\n\n", __LINE__ - ) ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - break ; - - default : - break ; - } ; - - /* Write file with a channel map. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - exit_if_true ( - sf_command (file, SFC_SET_CHANNEL_MAP_INFO, channel_map_write, sizeof (channel_map_write)) == SF_FALSE, - "\n\nLine %d : sf_command (SFC_SET_CHANNEL_MAP_INFO) failed.\n\n", __LINE__ - ) ; - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - /* Read file making sure no channel map exists. */ - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - exit_if_true ( - sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map_read, sizeof (channel_map_read)) != SF_TRUE, - "\n\nLine %d : sf_command (SFC_GET_CHANNEL_MAP_INFO) failed.\n\n", __LINE__ - ) ; - check_log_buffer_or_die (file, __LINE__) ; - sf_close (file) ; - - exit_if_true ( - memcmp (channel_map_read, channel_map_write, sizeof (channel_map_read)) != 0, - "\n\nLine %d : Channel map read does not match channel map written.\n\n", __LINE__ - ) ; - - unlink (filename) ; - puts ("ok") ; -} /* channel_map_test */ - -static void -raw_needs_endswap_test (const char *filename, int filetype) -{ static int subtypes [] = - { SF_FORMAT_FLOAT, SF_FORMAT_DOUBLE, - SF_FORMAT_PCM_16, SF_FORMAT_PCM_24, SF_FORMAT_PCM_32 - } ; - SNDFILE *file ; - SF_INFO sfinfo ; - unsigned k ; - int needs_endswap ; - - print_test_name (__func__, filename) ; - - for (k = 0 ; k < ARRAY_LEN (subtypes) ; k++) - { - if (filetype == (SF_ENDIAN_LITTLE | SF_FORMAT_AIFF)) - switch (subtypes [k]) - { /* Little endian AIFF does not AFAIK support fl32 and fl64. */ - case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - continue ; - default : - break ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 11025 ; - sfinfo.format = filetype | subtypes [k] ; - sfinfo.channels = 1 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - needs_endswap = sf_command (file, SFC_RAW_DATA_NEEDS_ENDSWAP, NULL, 0) ; - - switch (filetype) - { case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : - case SF_FORMAT_AIFF | SF_ENDIAN_LITTLE : - exit_if_true (needs_endswap != CPU_IS_BIG_ENDIAN, - "\n\nLine %d : SFC_RAW_DATA_NEEDS_ENDSWAP failed for (%d | %d).\n\n", __LINE__, filetype, k) ; - break ; - - case SF_FORMAT_AIFF : - case SF_FORMAT_WAV | SF_ENDIAN_BIG : - exit_if_true (needs_endswap != CPU_IS_LITTLE_ENDIAN, - "\n\nLine %d : SFC_RAW_DATA_NEEDS_ENDSWAP failed for (%d | %d).\n\n", __LINE__, filetype, k) ; - break ; - - default : - printf ("\n\nLine %d : bad format value %d.\n\n", __LINE__, filetype) ; - exit (1) ; - break ; - } ; - - sf_close (file) ; - } ; - - unlink (filename) ; - puts ("ok") ; -} /* raw_needs_endswap_test */ diff --git a/Engine/lib/libsndfile/tests/compression_size_test.c b/Engine/lib/libsndfile/tests/compression_size_test.c deleted file mode 100644 index b7dae300b..000000000 --- a/Engine/lib/libsndfile/tests/compression_size_test.c +++ /dev/null @@ -1,234 +0,0 @@ -/* -** Copyright (C) 2007-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include - -#include "utils.h" -#include "dft_cmp.h" - -#define SAMPLE_RATE 16000 -#define DATA_LENGTH (SAMPLE_RATE) - -static const char CMP_TEST_PREFIX[] = "cmp" ; - -static float data_out [DATA_LENGTH] ; - -static inline float -max_float (float a, float b) -{ return a > b ? a : b ; -} /* max_float */ - -static void -vorbis_test (void) -{ static float float_data [DFT_DATA_LENGTH] ; - const char * filename = "vorbis_test.oga" ; - SNDFILE * file ; - SF_INFO sfinfo ; - float max_abs = 0.0 ; - unsigned k ; - - get_unique_test_name (&filename, CMP_TEST_PREFIX) ; - - print_test_name ("vorbis_test", filename) ; - - /* Generate float data. */ - gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 1.0) ; - - /* Set up output file type. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - - /* The Vorbis encoder has a bug on PowerPC and X86-64 with sample rates - ** <= 22050. Increasing the sample rate to 32000 avoids triggering it. - ** See https://trac.xiph.org/ticket/1229 - */ - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { const char * errstr ; - - errstr = sf_strerror (NULL) ; - if (strstr (errstr, "Sample rate chosen is known to trigger a Vorbis") == NULL) - { printf ("Line %d: sf_open (SFM_WRITE) failed : %s\n", __LINE__, errstr) ; - dump_log_buffer (NULL) ; - exit (1) ; - } ; - - printf ("\n Sample rate -> 32kHz ") ; - sfinfo.samplerate = 32000 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - } ; - - test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ; - sf_close (file) ; - - memset (float_data, 0, sizeof (float_data)) ; - - /* Read the file back in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ; - sf_close (file) ; - - for (k = 0 ; k < ARRAY_LEN (float_data) ; k ++) - max_abs = max_float (max_abs, fabsf (float_data [k])) ; - - exit_if_true (max_abs > 1.023, - "\n\nLine %d : max_abs %f should be < 1.023.\n\n", __LINE__, max_abs) ; - - puts ("ok") ; - unlink (filename) ; -} /* vorbis_test */ - -static void -compression_size_test (int format, const char * filename) -{ /* - ** Encode two files, one at quality 0.3 and one at quality 0.5 and then - ** make sure that the quality 0.3 files is the smaller of the two. - */ - char q3_fname [64] ; - char q6_fname [64] ; - char test_name [64] ; - - SNDFILE *q3_file, *q6_file ; - SF_INFO sfinfo ; - int q3_size, q6_size ; - double quality ; - int k ; - - get_unique_test_name (&filename, CMP_TEST_PREFIX) ; - - snprintf (q3_fname, sizeof (q3_fname), "q3_%s", filename) ; - snprintf (q6_fname, sizeof (q6_fname), "q6_%s", filename) ; - - snprintf (test_name, sizeof (test_name), "q[36]_%s", filename) ; - print_test_name (__func__, test_name) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = format ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - q3_file = test_open_file_or_die (q3_fname, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - q6_file = test_open_file_or_die (q6_fname, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - - quality = 0.3 ; - sf_command (q3_file, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof (quality)) ; - quality = 0.6 ; - sf_command (q6_file, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof (quality)) ; - - for (k = 0 ; k < 5 ; k++) - { gen_lowpass_signal_float (data_out, ARRAY_LEN (data_out)) ; - test_write_float_or_die (q3_file, 0, data_out, ARRAY_LEN (data_out), __LINE__) ; - test_write_float_or_die (q6_file, 0, data_out, ARRAY_LEN (data_out), __LINE__) ; - } ; - - sf_close (q3_file) ; - sf_close (q6_file) ; - - q3_size = (int) file_length (q3_fname) ; - q6_size = (int) file_length (q6_fname) ; - - exit_if_true (q3_size >= q6_size, - "\n\nLine %d : q3 size (%d) >= q6 size (%d)\n\n", __LINE__, q3_size, q6_size) ; - - puts ("ok") ; - unlink (q3_fname) ; - unlink (q6_fname) ; -} /* compression_size_test */ - - - -int -main (int argc, char *argv []) -{ int all_tests = 0, tests = 0 ; - - if (argc != 2) - { printf ( - "Usage : %s \n" - " Where is one of:\n" - " vorbis - test Ogg/Vorbis\n" - " flac - test FLAC\n" - " opus - test Opus\n" - " mpeg - test mpeg\n" - " all - perform all tests\n", - argv [0]) ; - exit (0) ; - } ; - - if (strcmp (argv [1], "all") == 0) - all_tests = 1 ; - - if (all_tests || strcmp (argv [1], "vorbis") == 0) - { if (HAVE_EXTERNAL_XIPH_LIBS) - { vorbis_test () ; - compression_size_test (SF_FORMAT_OGG | SF_FORMAT_VORBIS, "vorbis.oga") ; - tests ++ ; - } - else - puts (" No Ogg Vorbis tests because support was not compiled in.") ; - } ; - - if (all_tests || strcmp (argv [1], "flac") == 0) - { if (HAVE_EXTERNAL_XIPH_LIBS) - { compression_size_test (SF_FORMAT_FLAC | SF_FORMAT_PCM_16, "pcm16.flac") ; - tests ++ ; - } - else - puts (" No FLAC tests because support was not compiled in.") ; - } ; - - if (all_tests || strcmp (argv [1], "opus") == 0) - { if (HAVE_EXTERNAL_XIPH_LIBS) - { compression_size_test (SF_FORMAT_OGG | SF_FORMAT_OPUS, "opus.opus") ; - tests ++ ; - } - else - puts (" No Opus tests because support was not compiled in.") ; - } ; - - if (all_tests || strcmp (argv [1], "mpeg") == 0) - { if (HAVE_MPEG) - { compression_size_test (SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III, "mpeg.mp3") ; - tests ++ ; - } - else - puts (" No MPEG tests because support was not compiled in.") ; - } ; - - return 0 ; -} /* main */ diff --git a/Engine/lib/libsndfile/tests/cpp_test.cc b/Engine/lib/libsndfile/tests/cpp_test.cc deleted file mode 100644 index e05a73709..000000000 --- a/Engine/lib/libsndfile/tests/cpp_test.cc +++ /dev/null @@ -1,315 +0,0 @@ -/* -** Copyright (C) 2006-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include - -#include "utils.h" - -static short sbuffer [100] ; -static int ibuffer [100] ; -static float fbuffer [100] ; -static double dbuffer [100] ; - -static void -ceeplusplus_wchar_test (void) -{ -#if 0 - LPCWSTR filename = L"wchar_test.wav" ; - - print_test_name (__func__, "ceeplusplus_wchar_test.wav") ; - - /* Use this scope to make sure the created file is closed. */ - { - SndfileHandle file (filename, SFM_WRITE, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 44100) ; - - if (file.refCount () != 1) - { printf ("\n\n%s %d : Error : Reference count (%d) should be 1.\n\n", __func__, __LINE__, file.refCount ()) ; - exit (1) ; - } ; - - /* This should check that the file did in fact get created with a - ** wchar_t * filename. - */ - exit_if_true ( - GetFileAttributesW (filename) == INVALID_FILE_ATTRIBUTES, - "\n\nLine %d : GetFileAttributes failed.\n\n", __LINE__ - ) ; - } - - /* Use this because the file was created with CreateFileW. */ - DeleteFileW (filename) ; - - puts ("ok") ; -#endif -} /* ceeplusplus_wchar_test */ - - - -static void -create_file (const char * filename, int format) -{ SndfileHandle file ; - - if (file.refCount () != 0) - { printf ("\n\n%s %d : Error : Reference count (%d) should be zero.\n\n", __func__, __LINE__, file.refCount ()) ; - exit (1) ; - } ; - - file = SndfileHandle (filename, SFM_WRITE, format, 2, 48000) ; - - if (file.refCount () != 1) - { printf ("\n\n%s %d : Error : Reference count (%d) should be 1.\n\n", __func__, __LINE__, file.refCount ()) ; - exit (1) ; - } ; - - file.setString (SF_STR_TITLE, filename) ; - - /* Item write. */ - file.write (sbuffer, ARRAY_LEN (sbuffer)) ; - file.write (ibuffer, ARRAY_LEN (ibuffer)) ; - file.write (fbuffer, ARRAY_LEN (fbuffer)) ; - file.write (dbuffer, ARRAY_LEN (dbuffer)) ; - - /* Frame write. */ - file.writef (sbuffer, ARRAY_LEN (sbuffer) / file.channels ()) ; - file.writef (ibuffer, ARRAY_LEN (ibuffer) / file.channels ()) ; - file.writef (fbuffer, ARRAY_LEN (fbuffer) / file.channels ()) ; - file.writef (dbuffer, ARRAY_LEN (dbuffer) / file.channels ()) ; - - /* RAII takes care of the SndfileHandle. */ -} /* create_file */ - -static void -check_title (const SndfileHandle & file, const char * filename) -{ const char *title = NULL ; - - title = file.getString (SF_STR_TITLE) ; - - if (title == NULL) - { printf ("\n\n%s %d : Error : No title for %s.\n\n", __func__, __LINE__, filename) ; - exit (1) ; - } ; - - if (strcmp (filename, title) != 0) - { printf ("\n\n%s %d : Error : title '%s' should be '%s'\n\n", __func__, __LINE__, title, filename) ; - exit (1) ; - } ; - - return ; -} /* check_title */ - -static void -read_file (const char * filename, int format) -{ SndfileHandle file ; - sf_count_t count ; - - if (file) - { printf ("\n\n%s %d : Error : should not be here.\n\n", __func__, __LINE__) ; - exit (1) ; - } ; - - file = SndfileHandle (filename) ; - - if (1) - { SndfileHandle file2 = file ; - - if (file.refCount () != 2 || file2.refCount () != 2) - { printf ("\n\n%s %d : Error : Reference count (%d) should be two.\n\n", __func__, __LINE__, file.refCount ()) ; - exit (1) ; - } ; - } ; - - if (file.refCount () != 1) - { printf ("\n\n%s %d : Error : Reference count (%d) should be one.\n\n", __func__, __LINE__, file.refCount ()) ; - exit (1) ; - } ; - - if (! file) - { printf ("\n\n%s %d : Error : should not be here.\n\n", __func__, __LINE__) ; - exit (1) ; - } ; - - if (file.format () != format) - { printf ("\n\n%s %d : Error : format 0x%08x should be 0x%08x.\n\n", __func__, __LINE__, file.format (), format) ; - exit (1) ; - } ; - - if (file.channels () != 2) - { printf ("\n\n%s %d : Error : channels %d should be 2.\n\n", __func__, __LINE__, file.channels ()) ; - exit (1) ; - } ; - - if (file.frames () != ARRAY_LEN (sbuffer) * 4) - { printf ("\n\n%s %d : Error : frames %ld should be %lu.\n\n", __func__, __LINE__, - (long) file.frames (), (long) ARRAY_LEN (sbuffer) * 4 / 2) ; - exit (1) ; - } ; - - switch (format & SF_FORMAT_TYPEMASK) - { case SF_FORMAT_AU : - break ; - - default : - check_title (file, filename) ; - break ; - } ; - - /* Item read. */ - file.read (sbuffer, ARRAY_LEN (sbuffer)) ; - file.read (ibuffer, ARRAY_LEN (ibuffer)) ; - file.read (fbuffer, ARRAY_LEN (fbuffer)) ; - file.read (dbuffer, ARRAY_LEN (dbuffer)) ; - - /* Frame read. */ - file.readf (sbuffer, ARRAY_LEN (sbuffer) / file.channels ()) ; - file.readf (ibuffer, ARRAY_LEN (ibuffer) / file.channels ()) ; - file.readf (fbuffer, ARRAY_LEN (fbuffer) / file.channels ()) ; - file.readf (dbuffer, ARRAY_LEN (dbuffer) / file.channels ()) ; - - count = file.seek (file.frames () - 10, SEEK_SET) ; - if (count != file.frames () - 10) - { printf ("\n\n%s %d : Error : offset (%ld) should be %ld\n\n", __func__, __LINE__, - (long) count, (long) (file.frames () - 10)) ; - exit (1) ; - } ; - - count = file.read (sbuffer, ARRAY_LEN (sbuffer)) ; - if (count != 10 * file.channels ()) - { printf ("\n\n%s %d : Error : count (%ld) should be %ld\n\n", __func__, __LINE__, - (long) count, (long) (10 * file.channels ())) ; - exit (1) ; - } ; - - /* RAII takes care of the SndfileHandle. */ -} /* read_file */ - -static void -ceeplusplus_test (const char *filename, int format) -{ - print_test_name ("ceeplusplus_test", filename) ; - - create_file (filename, format) ; - read_file (filename, format) ; - - remove (filename) ; - puts ("ok") ; -} /* ceeplusplus_test */ - -static void -ceeplusplus_extra_test (void) -{ SndfileHandle file ; - const char * filename = "bad_file_name.wav" ; - int error ; - - print_test_name ("ceeplusplus_extra_test", filename) ; - - file = SndfileHandle (filename) ; - - error = file.error () ; - if (error == 0) - { printf ("\n\n%s %d : error should not be zero.\n\n", __func__, __LINE__) ; - exit (1) ; - } ; - - if (file.strError () == NULL) - { printf ("\n\n%s %d : strError should not return NULL.\n\n", __func__, __LINE__) ; - exit (1) ; - } ; - - if (file.seek (0, SEEK_SET) != 0) - { printf ("\n\n%s %d : bad seek ().\n\n", __func__, __LINE__) ; - exit (1) ; - } ; - - puts ("ok") ; -} /* ceeplusplus_extra_test */ - - -static void -ceeplusplus_rawhandle_test (const char *filename) -{ - SNDFILE* handle ; - { - SndfileHandle file (filename) ; - handle = file.rawHandle () ; - sf_read_float (handle, fbuffer, ARRAY_LEN (fbuffer)) ; - } -} /* ceeplusplus_rawhandle_test */ - -static void -ceeplusplus_takeOwnership_test (const char *filename) -{ - SNDFILE* handle ; - { - SndfileHandle file (filename) ; - handle = file.takeOwnership () ; - } - - if (sf_read_float (handle, fbuffer, ARRAY_LEN (fbuffer)) <= 0) - { printf ("\n\n%s %d : error when taking ownership of handle.\n\n", __func__, __LINE__) ; - exit (1) ; - } - - if (sf_close (handle) != 0) - { printf ("\n\n%s %d : cannot close file.\n\n", __func__, __LINE__) ; - exit (1) ; - } - - SndfileHandle file (filename) ; - SndfileHandle file2 (file) ; - - if (file2.takeOwnership ()) - { printf ("\n\n%s %d : taking ownership of shared handle is not allowed.\n\n", __func__, __LINE__) ; - exit (1) ; - } -} /* ceeplusplus_takeOwnership_test */ - -static void -ceeplusplus_handle_test (const char *filename, int format) -{ - print_test_name ("ceeplusplus_handle_test", filename) ; - - create_file (filename, format) ; - - if (0) ceeplusplus_rawhandle_test (filename) ; - ceeplusplus_takeOwnership_test (filename) ; - - remove (filename) ; - puts ("ok") ; -} /* ceeplusplus_test */ - -int -main (void) -{ - ceeplusplus_test ("cpp_test.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - ceeplusplus_test ("cpp_test.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_S8) ; - ceeplusplus_test ("cpp_test.au", SF_FORMAT_AU | SF_FORMAT_FLOAT) ; - - ceeplusplus_extra_test () ; - ceeplusplus_handle_test ("cpp_test.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - - ceeplusplus_wchar_test () ; - - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/tests/cue_test.c b/Engine/lib/libsndfile/tests/cue_test.c deleted file mode 100644 index d2fdae4bb..000000000 --- a/Engine/lib/libsndfile/tests/cue_test.c +++ /dev/null @@ -1,135 +0,0 @@ - -#include "sfconfig.h" - -#include -#include -#include -#include - - -static void * -get_cues (const char *filename, double *sr) -{ - SNDFILE *file; - SF_INFO sfinfo; - - unsigned int err, size; - uint32_t count = 0; - SF_CUES_VAR(0) *info; - - if ((file = sf_open(filename, SFM_READ, &sfinfo)) == NULL) - { - printf("can't open file '%s'\n", filename); - exit(1); - } - - printf("\n---- get cues of file '%s'\n", filename); - - if ((err = sf_command(file, SFC_GET_CUE_COUNT, &count, sizeof(uint32_t))) == SF_FALSE) - { - if (sf_error(file)) - { - printf("can't get cue info size for file '%s' (arg size %lu), err %s\n", - filename, sizeof(uint32_t), sf_strerror(file)); - exit(2); - } - else - printf("no cue info for file '%s'\n", filename); - return NULL; - } - - size = sizeof(*info) + count * sizeof(SF_CUE_POINT); - printf("number of cues %d size %d\n", count, size); - - if (!(info = malloc(size))) - return NULL; - - if (sf_command(file, SFC_GET_CUE, info, size) == SF_FALSE) - { - printf("can't get cue info of size %d for file '%s' error %s\n", - size, filename, sf_strerror(file)); - exit(3); - } - - *sr = sfinfo.samplerate; - sf_close(file); - - return info; -} - - -static void -test_cues (const char *filename) -{ - unsigned int i; - double sr; - SF_CUES_VAR(0) *info = get_cues(filename, &sr); - - if (info == NULL) - exit(1); - - for (i = 0; i < info->cue_count; i++) - { - int pos = info->cue_points[i].position; - double t = (double) pos / sr; - double expected = i < 8 ? (double) i / 3. : 10. / 3.; - double error = (double) fabs(t - expected); - - printf("cue %02d: markerID %02d position %6d offset %6d (time %.3f expected %.3f diff %f) label '%s'\n", - i, info->cue_points[i].indx, pos, info->cue_points[i].sample_offset, t, expected, error, info->cue_points[i].name); - - if (error > 0.025) - exit(4); - } - - free(info); -} - -static void -print_cues (const char *filename) -{ - unsigned int i; - double sr; - SF_CUES_VAR(0) *info = get_cues(filename, &sr); - - if (info == NULL) - exit(1); - - for (i = 0; i < info->cue_count; i++) - { - int pos = info->cue_points[i].position; - int indx = info->cue_points[i].indx; - int cstart = info->cue_points[i].chunk_start; - int bstart = info->cue_points[i].block_start; - int offset = info->cue_points[i].sample_offset; - const char *name = info->cue_points[i].name; - double t = (double) pos / sr; - - if (cstart != 0 || bstart != 0) - printf("cue %02d time %7.3f: markerID %02d position %8d chunk_start %d block_start %d offset %8d label '%s'\n", - i, t, indx, pos, offset, cstart, bstart, name); - else - printf("cue %02d time %7.3f: markerID %02d position %8d offset %8d label '%s'\n", - i, t, indx, pos, offset, name); - } - - free(info); -} - - -int -main (int argc, char **argv) -{ - int i; - - if (argc > 1) - for (i = 1; i < argc; i++) - print_cues(argv[i]); - else - { - test_cues("clickpluck24.wav"); - test_cues("clickpluck.wav"); - test_cues("clickpluck.aiff"); - } - return 0; -} diff --git a/Engine/lib/libsndfile/tests/dft_cmp.c b/Engine/lib/libsndfile/tests/dft_cmp.c deleted file mode 100644 index 03bd4646d..000000000 --- a/Engine/lib/libsndfile/tests/dft_cmp.c +++ /dev/null @@ -1,151 +0,0 @@ -/* -** Copyright (C) 2002-2015 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include "dft_cmp.h" -#include "utils.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846264338 -#endif - -#define DFT_SPEC_LENGTH (DFT_DATA_LENGTH / 2) - -static void dft_magnitude (const double *data, double *spectrum) ; -static double calc_max_spectral_difference (const double *spec1, const double *spec2) ; - -/*-------------------------------------------------------------------------------- -** Public functions. -*/ - -double -dft_cmp_float (int linenum, const float *in_data, const float *test_data, int len, double target_snr, int allow_exit) -{ static double orig [DFT_DATA_LENGTH] ; - static double test [DFT_DATA_LENGTH] ; - unsigned k ; - - if (len != DFT_DATA_LENGTH) - { printf ("Error (line %d) : dft_cmp_float : Bad input array length.\n", linenum) ; - return 1 ; - } ; - - for (k = 0 ; k < ARRAY_LEN (orig) ; k++) - { test [k] = test_data [k] ; - orig [k] = in_data [k] ; - } ; - - return dft_cmp_double (linenum, orig, test, len, target_snr, allow_exit) ; -} /* dft_cmp_float */ - -double -dft_cmp_double (int linenum, const double *orig, const double *test, int len, double target_snr, int allow_exit) -{ static double orig_spec [DFT_SPEC_LENGTH] ; - static double test_spec [DFT_SPEC_LENGTH] ; - double snr ; - - if (! orig || ! test) - { printf ("Error (line %d) : dft_cmp_double : Bad input arrays.\n", linenum) ; - return 1 ; - } ; - - if (len != DFT_DATA_LENGTH) - { printf ("Error (line %d) : dft_cmp_double : Bad input array length.\n", linenum) ; - return 1 ; - } ; - - dft_magnitude (orig, orig_spec) ; - dft_magnitude (test, test_spec) ; - - snr = calc_max_spectral_difference (orig_spec, test_spec) ; - - if (snr > target_snr) - { printf ("\n\nLine %d: Actual SNR (% 4.1f) > target SNR (% 4.1f).\n\n", linenum, snr, target_snr) ; - oct_save_double (orig, test, len) ; - if (allow_exit) - exit (1) ; - } ; - - if (snr < -500.0) - snr = -500.0 ; - - return snr ; -} /* dft_cmp_double */ - -/*-------------------------------------------------------------------------------- -** Quick dirty calculation of magnitude spectrum for real valued data using -** Discrete Fourier Transform. Since the data is real, the DFT is only -** calculated for positive frequencies. -*/ - -static void -dft_magnitude (const double *data, double *spectrum) -{ static double cos_angle [DFT_DATA_LENGTH] = { 0.0 } ; - static double sin_angle [DFT_DATA_LENGTH] ; - - double real_part, imag_part ; - int k, n ; - - /* If sine and cosine tables haven't been initialised, do so. */ - if (cos_angle [0] == 0.0) - for (n = 0 ; n < DFT_DATA_LENGTH ; n++) - { cos_angle [n] = cos (2.0 * M_PI * n / DFT_DATA_LENGTH) ; - sin_angle [n] = -1.0 * sin (2.0 * M_PI * n / DFT_DATA_LENGTH) ; - } ; - - /* DFT proper. Since the data is real, only generate a half spectrum. */ - for (k = 1 ; k < DFT_SPEC_LENGTH ; k++) - { real_part = 0.0 ; - imag_part = 0.0 ; - - for (n = 0 ; n < DFT_DATA_LENGTH ; n++) - { real_part += data [n] * cos_angle [(k * n) % DFT_DATA_LENGTH] ; - imag_part += data [n] * sin_angle [(k * n) % DFT_DATA_LENGTH] ; - } ; - - spectrum [k] = sqrt (real_part * real_part + imag_part * imag_part) ; - } ; - - spectrum [DFT_SPEC_LENGTH - 1] = 0.0 ; - - spectrum [0] = spectrum [1] = spectrum [2] = 0.0 ; - - return ; -} /* dft_magnitude */ - -static double -calc_max_spectral_difference (const double *orig, const double *test) -{ double orig_max = 0.0, max_diff = 0.0 ; - int k ; - - for (k = 0 ; k < DFT_SPEC_LENGTH ; k++) - { if (orig_max < orig [k]) - orig_max = orig [k] ; - if (max_diff < fabs (orig [k] - test [k])) - max_diff = fabs (orig [k] - test [k]) ; - } ; - - if (max_diff < 1e-25) - return -500.0 ; - - return 20.0 * log10 (max_diff / orig_max) ; -} /* calc_max_spectral_difference */ diff --git a/Engine/lib/libsndfile/tests/dft_cmp.h b/Engine/lib/libsndfile/tests/dft_cmp.h deleted file mode 100644 index faa5fe0a6..000000000 --- a/Engine/lib/libsndfile/tests/dft_cmp.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -** Copyright (C) 2002-2015 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#define DFT_DATA_LENGTH (8192) - -double dft_cmp_float (int linenum, const float *orig, const float *test, int len, double tolerance, int allow_exit) ; - -double dft_cmp_double (int linenum, const double *orig, const double *test, int len, double tolerance, int allow_exit) ; - diff --git a/Engine/lib/libsndfile/tests/dither_test.c b/Engine/lib/libsndfile/tests/dither_test.c deleted file mode 100644 index c0928440c..000000000 --- a/Engine/lib/libsndfile/tests/dither_test.c +++ /dev/null @@ -1,184 +0,0 @@ -/* -** Copyright (C) 2003-2013 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#include "sfconfig.h" -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif -#include -#include - -#include - -#include "utils.h" - -#define BUFFER_LEN (1 << 16) -#define LOG_BUFFER_SIZE 1024 - -static void dither_test (const char *filename, int filetype) ; - -/* Force the start of this buffer to be double aligned. Sparc-solaris will -** choke if its not. -*/ -static short data_out [BUFFER_LEN] ; - -int -main (int argc, char *argv []) -{ int do_all = 0 ; - int test_count = 0 ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" wav - test WAV file peak chunk\n") ; - printf (" aiff - test AIFF file PEAK chunk\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "wav")) - { dither_test ("dither.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { dither_test ("dither.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "au")) - { dither_test ("dither.au", SF_FORMAT_AU | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "svx")) - { dither_test ("dither.svx", SF_FORMAT_SVX | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "nist")) - { dither_test ("dither.nist", SF_FORMAT_NIST | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "paf")) - { dither_test ("dither.paf", SF_FORMAT_PAF | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "ircam")) - { dither_test ("dither.ircam", SF_FORMAT_IRCAM | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "voc")) - { dither_test ("dither.voc", SF_FORMAT_VOC | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "w64")) - { dither_test ("dither.w64", SF_FORMAT_W64 | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat4")) - { dither_test ("dither.mat4", SF_FORMAT_MAT4 | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat5")) - { dither_test ("dither.mat5", SF_FORMAT_MAT5 | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "pvf")) - { dither_test ("dither.pvf", SF_FORMAT_PVF | SF_FORMAT_PCM_S8) ; - test_count++ ; - } ; - - if (test_count == 0) - { printf ("Mono : ************************************\n") ; - printf ("Mono : * No '%s' test defined.\n", argv [1]) ; - printf ("Mono : ************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -dither_test (const char *filename, int filetype) -{ SNDFILE *file ; - SF_INFO sfinfo ; - SF_DITHER_INFO dither ; - - print_test_name ("dither_test", filename) ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = filetype ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - /* Check for old version of the dither API. */ - if (sf_command (file, SFC_SET_DITHER_ON_WRITE, NULL, SF_TRUE) == 0) - { printf ("\n\nLine %d: Should have an error here but don't.\n\n", __LINE__) ; - exit (1) ; - } ; - - memset (&dither, 0, sizeof (dither)) ; - dither.type = SFD_WHITE ; - dither.level = 0 ; - - if (sf_command (file, SFC_SET_DITHER_ON_WRITE, &dither, sizeof (dither)) != 0) - { printf ("\n\nLine %d: sf_command (SFC_SET_DITHER_ON_WRITE) returned error : %s\n\n", - __LINE__, sf_strerror (file)) ; - exit (1) ; - } ; - - /* Write data to file. */ - test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sfinfo.frames != BUFFER_LEN) - { printf ("\n\nLine %d: Bad frame count %d (should be %d)\n\n", __LINE__, (int) sfinfo.frames, BUFFER_LEN) ; - } ; - - sf_close (file) ; - /*-unlink (filename) ;-*/ - - puts ("ok") ; -} /* dither_test */ - diff --git a/Engine/lib/libsndfile/tests/dwvw_test.c b/Engine/lib/libsndfile/tests/dwvw_test.c deleted file mode 100644 index 0c92f874d..000000000 --- a/Engine/lib/libsndfile/tests/dwvw_test.c +++ /dev/null @@ -1,111 +0,0 @@ -/* -** Copyright (C) 2002-2014 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_SIZE (10000) - -#ifndef M_PI -#define M_PI 3.14159265358979323846264338 -#endif - -static void dwvw_test (const char *filename, int format, int bit_width) ; - -int -main (void) -{ - dwvw_test ("dwvw12.raw", SF_FORMAT_RAW | SF_FORMAT_DWVW_12, 12) ; - dwvw_test ("dwvw16.raw", SF_FORMAT_RAW | SF_FORMAT_DWVW_16, 16) ; - dwvw_test ("dwvw24.raw", SF_FORMAT_RAW | SF_FORMAT_DWVW_24, 24) ; - - return 0 ; -} /* main */ - -static void -dwvw_test (const char *filename, int format, int bit_width) -{ static int write_buf [BUFFER_SIZE] ; - static int read_buf [BUFFER_SIZE] ; - - SNDFILE *file ; - SF_INFO sfinfo ; - double value ; - int k, bit_mask ; - - srand (123456) ; - - /* Only want to grab the top bit_width bits. */ - bit_mask = arith_shift_left (-1, 32 - bit_width) ; - - print_test_name ("dwvw_test", filename) ; - - sf_info_setup (&sfinfo, format, 44100, 1) ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - /* Generate random.frames. */ - for (k = 0 ; k < BUFFER_SIZE / 2 ; k++) - { value = 0x7FFFFFFF * sin (123.0 / sfinfo.samplerate * 2 * k * M_PI) ; - write_buf [k] = bit_mask & lrint (value) ; - } ; - - for ( ; k < BUFFER_SIZE ; k++) - write_buf [k] = bit_mask & (arith_shift_left (rand (), 11) ^ (rand () >> 11)) ; - - sf_write_int (file, write_buf, BUFFER_SIZE) ; - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if ((k = (int) sf_read_int (file, read_buf, BUFFER_SIZE)) != BUFFER_SIZE) - { printf ("Error (line %d) : Only read %d/%d.frames.\n", __LINE__, k, BUFFER_SIZE) ; - exit (1) ; - } - - for (k = 0 ; k < BUFFER_SIZE ; k++) - { if (read_buf [k] != write_buf [k]) - { printf ("Error (line %d) : %d != %d at position %d/%d\n", __LINE__, - write_buf [k] >> (32 - bit_width), read_buf [k] >> (32 - bit_width), - k, BUFFER_SIZE) ; - oct_save_int (write_buf, read_buf, BUFFER_SIZE) ; - exit (1) ; - } ; - } ; - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; - - return ; -} /* dwvw_test */ - diff --git a/Engine/lib/libsndfile/tests/error_test.c b/Engine/lib/libsndfile/tests/error_test.c deleted file mode 100644 index 9cdabf4ea..000000000 --- a/Engine/lib/libsndfile/tests/error_test.c +++ /dev/null @@ -1,314 +0,0 @@ -/* -** Copyright (C) 1999-2018 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_SIZE (1 << 15) -#define SHORT_BUFFER (256) - -static void -error_number_test (void) -{ const char *noerror, *errstr ; - int k ; - - print_test_name ("error_number_test", "") ; - - noerror = sf_error_number (0) ; - - for (k = 1 ; k < 300 ; k++) - { errstr = sf_error_number (k) ; - - /* Test for termination condition. */ - if (errstr == noerror) - break ; - - /* Test for error. */ - if (strstr (errstr, "This is a bug in libsndfile.")) - { printf ("\n\nError : error number %d : %s\n\n\n", k, errstr) ; - exit (1) ; - } ; - } ; - - - puts ("ok") ; - return ; -} /* error_number_test */ - -static void -error_value_test (void) -{ static unsigned char aiff_data [0x1b0] = - { 'F' , 'O' , 'R' , 'M' , - 0x00, 0x00, 0x01, 0xA8, /* FORM length */ - - 'A' , 'I' , 'F' , 'C' , - } ; - - const char *filename = "error.aiff" ; - SNDFILE *file ; - SF_INFO sfinfo ; - int error_num ; - - print_test_name ("error_value_test", filename) ; - - dump_data_to_file (filename, aiff_data, sizeof (aiff_data)) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = sf_open (filename, SFM_READ, &sfinfo) ; - if (file != NULL) - { printf ("\n\nLine %d : Should not have been able to open this file.\n\n", __LINE__) ; - exit (1) ; - } ; - - if ((error_num = sf_error (NULL)) <= 1 || error_num > 300) - { printf ("\n\nLine %d : Should not have had an error number of %d.\n\n", __LINE__, error_num) ; - exit (1) ; - } ; - - remove (filename) ; - puts ("ok") ; - return ; -} /* error_value_test */ - -static void -no_file_test (const char * filename) -{ SNDFILE *sndfile ; - SF_INFO sfinfo ; - - print_test_name (__func__, filename) ; - - unlink (filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sndfile = sf_open (filename, SFM_READ, &sfinfo) ; - - exit_if_true (sndfile != NULL, "\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ; - - unlink (filename) ; - puts ("ok") ; -} /* no_file_test */ - -static void -zero_length_test (const char *filename) -{ SNDFILE *sndfile ; - SF_INFO sfinfo ; - FILE *file ; - - print_test_name (__func__, filename) ; - - /* Create a zero length file. */ - file = fopen (filename, "w") ; - exit_if_true (file == NULL, "\n\nLine %d : fopen ('%s') failed.\n", __LINE__, filename) ; - fclose (file) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sndfile = sf_open (filename, SFM_READ, &sfinfo) ; - - exit_if_true (sndfile != NULL, "\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ; - - exit_if_true (0 && sf_error (NULL) != SF_ERR_UNRECOGNISED_FORMAT, - "\n\nLine %3d : Error : %s\n should be : %s\n", __LINE__, - sf_strerror (NULL), sf_error_number (SF_ERR_UNRECOGNISED_FORMAT)) ; - - unlink (filename) ; - puts ("ok") ; -} /* zero_length_test */ - -static void -bad_wav_test (const char * filename) -{ SNDFILE *sndfile ; - SF_INFO sfinfo ; - - FILE *file ; - const char data [] = "RIFF WAVEfmt " ; - - print_test_name (__func__, filename) ; - - if ((file = fopen (filename, "w")) == NULL) - { printf ("\n\nLine %d : fopen returned NULL.\n", __LINE__) ; - exit (1) ; - } ; - - exit_if_true (fwrite (data, sizeof (data), 1, file) != 1, "\n\nLine %d : fwrite failed.\n", __LINE__) ; - fclose (file) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sndfile = sf_open (filename, SFM_READ, &sfinfo) ; - - if (sndfile) - { printf ("\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ; - exit (1) ; - } ; - - unlink (filename) ; - puts ("ok") ; -} /* bad_wav_test */ - -static void -wav_list_recover_test (const char * filename) -{ SNDFILE *sndfile ; - SF_INFO sfinfo ; - - FILE *file ; - const char data [] = - "RIFF" "J\000\000\000" - "WAVE" "fmt " "\020\000\000\000" "\001\000\001\000D\254\000\000\210X\001\000\002\000\020\000" - "LIST" "\014\000\000\000" "test" "\010\000\000\000" "1234" /* test is 4 bytes short inside LIST container */ - "data" "\004\000\000\000" "abcd" ; - - print_test_name (__func__, filename) ; - - if ((file = fopen (filename, "w")) == NULL) - { printf ("\n\nLine %d : fopen returned NULL.\n", __LINE__) ; - exit (1) ; - } ; - - exit_if_true (fwrite (data, sizeof (data) - 1, 1, file) != 1, "\n\nLine %d : fwrite failed.\n", __LINE__) ; - fclose (file) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sndfile = sf_open (filename, SFM_READ, &sfinfo) ; - - if (!sndfile) - { printf ("\n\nLine %d : expected recovery from bogus LIST content.\n", __LINE__) ; - exit (1) ; - } ; - - if (sfinfo.frames != 2) - { printf ("\n\nLine %d : Should have read data chunk with 2 stereo frames, got %ld.\n\n", __LINE__, (long)sfinfo.frames) ; - exit (1) ; - } ; - - unlink (filename) ; - puts ("ok") ; -} /* wav_list_recover_test */ - -static void -error_close_test (void) -{ static short buffer [SHORT_BUFFER] ; - const char *filename = "error_close.wav" ; - SNDFILE *sndfile ; - SF_INFO sfinfo ; - FILE *file ; - - print_test_name (__func__, filename) ; - - /* Open a FILE* from which we will extract a file descriptor. */ - if ((file = fopen (filename, "w")) == NULL) - { printf ("\n\nLine %d : fopen returned NULL.\n", __LINE__) ; - exit (1) ; - } ; - - /* Set parameters for writing the file. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.channels = 1 ; - sfinfo.samplerate = 44100 ; - sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; - - sndfile = sf_open_fd (fileno (file), SFM_WRITE, &sfinfo, SF_TRUE) ; - if (sndfile == NULL) - { printf ("\n\nLine %d : sf_open_fd failed : %s\n", __LINE__, sf_strerror (NULL)) ; - exit (1) ; - } ; - - test_write_short_or_die (sndfile, 0, buffer, ARRAY_LEN (buffer), __LINE__) ; - - /* Now close the fd associated with file before calling sf_close. */ - fclose (file) ; - - if (sf_close (sndfile) == 0) - { - printf ("\n\nLine %d : sf_close should not have returned zero.\n", __LINE__) ; -#if OS_IS_WIN32 - printf ("\nHowever, this is a known bug on windows platform so we'll ignore it.\n\n") ; -#else - exit (1) ; -#endif - } ; - - unlink (filename) ; - puts ("ok") ; -} /* error_close_test */ - -static void -unrecognised_test (void) -{ const char *filename = "unrecognised.bin" ; - SNDFILE *sndfile ; - SF_INFO sfinfo ; - FILE *file ; - int k ; - - print_test_name (__func__, filename) ; - - file = fopen (filename, "wb") ; - exit_if_true (file == NULL, - "\n\nLine %d : fopen ('%s') failed : %s\n", __LINE__, filename, strerror (errno) - ) ; - fputs ("Unrecognised file", file) ; - fclose (file) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sndfile = sf_open (filename, SFM_READ, &sfinfo) ; - - exit_if_true (sndfile != NULL, - "\n\nLine %d : SNDFILE* pointer (%p) should be NULL.\n", __LINE__, (void *) sndfile - ) ; - - k = sf_error (sndfile) ; - exit_if_true (k != SF_ERR_UNRECOGNISED_FORMAT, - "\n\nLine %d : error (%d) should have been SF_ERR_UNRECOGNISED_FORMAT (%d).\n", - __LINE__, k, SF_ERR_UNRECOGNISED_FORMAT - ) ; - - unlink (filename) ; - puts ("ok") ; -} /* unrecognised_test */ - -int -main (void) -{ - error_number_test () ; - error_value_test () ; - - error_close_test () ; - - no_file_test ("no_file.wav") ; - zero_length_test ("zero_length.wav") ; - bad_wav_test ("bad_wav.wav") ; - wav_list_recover_test ("list_recover.wav") ; - - unrecognised_test () ; - - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/tests/external_libs_test.c b/Engine/lib/libsndfile/tests/external_libs_test.c deleted file mode 100644 index 0c6fcf8e4..000000000 --- a/Engine/lib/libsndfile/tests/external_libs_test.c +++ /dev/null @@ -1,204 +0,0 @@ -/* -** Copyright (C) 2008-2017 Erik de Castro Lopo -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation ; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -static void major_format_test (void) ; -static void subtype_format_test (void) ; -static void simple_format_test (void) ; -static void flac_subset_test (void) ; - -int -main (void) -{ - major_format_test () ; - subtype_format_test () ; - simple_format_test () ; - - if (HAVE_EXTERNAL_XIPH_LIBS) - flac_subset_test () ; - - return 0 ; -} /* main */ - -static void -major_format_test (void) -{ SF_FORMAT_INFO info ; - int have_ogg = 0, have_flac = 0 ; - int m, major_count ; - - print_test_name (__func__, NULL) ; - - sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ; - - for (m = 0 ; m < major_count ; m++) - { info.format = m ; - sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ; - - have_flac = info.format == SF_FORMAT_FLAC ? 1 : have_flac ; - have_ogg = info.format == SF_FORMAT_OGG ? 1 : have_ogg ; - } ; - - if (HAVE_EXTERNAL_XIPH_LIBS) - { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ; - exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ; - } - else - { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ; - exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ; - } ; - - puts ("ok") ; -} /* major_format_test */ - -static void -subtype_format_test (void) -{ SF_FORMAT_INFO info ; - int have_vorbis = 0 , have_opus = 0 ; - int s, subtype_count ; - - print_test_name (__func__, NULL) ; - - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ; - - for (s = 0 ; s < subtype_count ; s++) - { info.format = s ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ; - - have_vorbis = info.format == SF_FORMAT_VORBIS ? 1 : have_vorbis ; - have_opus = info.format == SF_FORMAT_OPUS ? 1 : have_opus ; - } ; - - if (HAVE_EXTERNAL_XIPH_LIBS) - { exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ; - exit_if_true (have_opus == 0, "\n\nLine %d : Ogg/Opus should be available.\n\n", __LINE__) ; - } - else - { exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ; - exit_if_true (have_opus, "\n\nLine %d : Ogg/Opus should not be available.\n\n", __LINE__) ; - } ; - - puts ("ok") ; -} /* subtype_format_test */ - -static void -simple_format_test (void) -{ SF_FORMAT_INFO info ; - int have_flac = 0, have_ogg = 0, have_vorbis = 0, have_opus = 0 ; - int s, simple_count ; - - print_test_name (__func__, NULL) ; - - sf_command (NULL, SFC_GET_SIMPLE_FORMAT_COUNT, &simple_count, sizeof (int)) ; - - for (s = 0 ; s < simple_count ; s++) - { info.format = s ; - sf_command (NULL, SFC_GET_SIMPLE_FORMAT, &info, sizeof (info)) ; - - switch (info.format & SF_FORMAT_TYPEMASK) - { case SF_FORMAT_FLAC : - have_flac = 1 ; - break ; - - case SF_FORMAT_OGG : - have_ogg = 1 ; - break ; - - default : - break ; - } ; - - switch (info.format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_VORBIS : - have_vorbis = 1 ; - break ; - - case SF_FORMAT_OPUS : - have_opus = 1 ; - break ; - - default : - break ; - } ; - - } ; - - if (HAVE_EXTERNAL_XIPH_LIBS) - { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ; - exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ; - exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ; - exit_if_true (have_opus == 0, "\n\nLine %d : Ogg/Opus should be available.\n\n", __LINE__) ; - } - else - { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ; - exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ; - exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ; - exit_if_true (have_opus, "\n\nLine %d : Ogg/Opus should not be available.\n\n", __LINE__) ; - } ; - - puts ("ok") ; -} /* simple_format_test */ - -static void -flac_subset_test (void) -{ float whatever [256] ; - SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t rc ; - int samplerate ; - const char *filename = "subset_test.flac" ; - - /* For some formats (like FLAC) the headers are written *just* before the - ** first bit of audio data. This test makes sure errors in that process - ** are caught. - */ - - print_test_name (__func__, NULL) ; - - for (samplerate = 65536 ; samplerate < 655350 ; samplerate *= 4) - { sfinfo.samplerate = samplerate ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - sfinfo.format = SF_FORMAT_FLAC | SF_FORMAT_PCM_16 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - rc = sf_write_float (file, whatever, ARRAY_LEN (whatever)) ; - unlink (filename) ; - exit_if_true (rc != 0, "\n\nLine %d : return code (%d) should be 0.\n\n", __LINE__, (int) rc) ; - - sf_close (file) ; - } ; - - puts ("ok") ; -} /* flac_subset_test */ - diff --git a/Engine/lib/libsndfile/tests/fix_this.c b/Engine/lib/libsndfile/tests/fix_this.c deleted file mode 100644 index 5c697ea81..000000000 --- a/Engine/lib/libsndfile/tests/fix_this.c +++ /dev/null @@ -1,334 +0,0 @@ -/* -** Copyright (C) 1999-2014 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif -#include -#include - -#include - -#include "utils.h" - -#define BUFFER_SIZE (1 << 14) -#define SAMPLE_RATE (11025) - -#ifndef M_PI -#define M_PI 3.14159265358979323846264338 -#endif - -static void lcomp_test_int (const char *str, const char *filename, int filetype, double margin) ; - -static int error_function (double data, double orig, double margin) ; -static int decay_response (int k) ; - -static void gen_signal_double (double *data, double scale, int datalen) ; - -/* Force the start of these buffers to be double aligned. Sparc-solaris will -** choke if they are not. -*/ - -typedef union -{ double d [BUFFER_SIZE + 1] ; - int i [BUFFER_SIZE + 1] ; -} BUFFER ; - -static BUFFER data_buffer ; -static BUFFER orig_buffer ; - -int -main (void) -{ const char *filename = "test.au" ; - - lcomp_test_int ("au_g721", filename, SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G721_32, 0.06) ; - - return 0 ; -} /* main */ - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -lcomp_test_int (const char *str, const char *filename, int filetype, double margin) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, m, *orig, *data ; - sf_count_t datalen, seekpos ; - int64_t sum_abs ; - double scale ; - - printf ("\nThis is program is not part of the libsndfile test suite.\n\n") ; - - printf (" lcomp_test_int : %s ... ", str) ; - fflush (stdout) ; - - datalen = BUFFER_SIZE ; - - scale = 1.0 * 0x10000 ; - - data = data_buffer.i ; - orig = orig_buffer.i ; - - gen_signal_double (orig_buffer.d, 32000.0 * scale, datalen) ; - for (k = 0 ; k < datalen ; k++) - orig [k] = orig_buffer.d [k] ; - - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - if (! (file = sf_open (filename, SFM_WRITE, &sfinfo))) - { printf ("sf_open_write failed with error : ") ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - if ((k = sf_writef_int (file, orig, datalen)) != datalen) - { printf ("sf_writef_int failed with short write (%" PRId64 " => %d).\n", datalen, k) ; - exit (1) ; - } ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (int)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if (! (file = sf_open (filename, SFM_READ, &sfinfo))) - { printf ("sf_open_read failed with error : ") ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - if ((sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)) != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) - { printf ("Line %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen) - { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + datalen / 2)) - { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - if ((k = sf_readf_int (file, data, datalen)) != datalen) - { printf ("Line %d: short read (%d should be %" PRId64 ").\n", __LINE__, k, datalen) ; - exit (1) ; - } ; - - sum_abs = 0 ; - for (k = 0 ; k < datalen ; k++) - { if (error_function (data [k] / scale, orig [k] / scale, margin)) - { printf ("Line %d: Incorrect sample (#%d : %f should be %f).\n", __LINE__, k, data [k] / scale, orig [k] / scale) ; - oct_save_int (orig, data, datalen) ; - exit (1) ; - } ; - sum_abs += abs (data [k]) ; - } ; - - if (sum_abs < 1.0) - { printf ("Line %d: Signal is all zeros.\n", __LINE__) ; - exit (1) ; - } ; - - if ((k = sf_readf_int (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("Line %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, sfinfo.frames - datalen, k) ; - exit (1) ; - } ; - - /* This check is only for block based encoders which must append silence - ** to the end of a file so as to fill out a block. - */ - if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM) - for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (ABS (data [k] / scale) > decay_response (k)) - { printf ("Line %d : Incorrect sample B (#%d : abs (%d) should be < %d).\n", __LINE__, k, data [k], decay_response (k)) ; - exit (1) ; - } ; - - if (! sfinfo.seekable) - { printf ("ok\n") ; - return ; - } ; - - /* Now test sf_seek function. */ - - if ((k = sf_seek (file, 0, SEEK_SET)) != 0) - { printf ("Line %d: Seek to start of file failed (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (m = 0 ; m < 3 ; m++) - { int n ; - - if ((k = sf_readf_int (file, data, 11)) != 11) - { printf ("Line %d: Incorrect read length (11 => %d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (k = 0 ; k < 11 ; k++) - if (error_function (data [k] / scale, orig [k + m * 11] / scale, margin)) - { printf ("Line %d: Incorrect sample (m = %d) (#%d : %d => %d).\n", __LINE__, m, k + m * 11, orig [k + m * 11], data [k]) ; - for (n = 0 ; n < 1 ; n++) - printf ("%d ", data [n]) ; - printf ("\n") ; - exit (1) ; - } ; - } ; - - seekpos = BUFFER_SIZE / 10 ; - - /* Check seek from start of file. */ - if ((k = sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %" PRId64 " failed (%d).\n", seekpos, k) ; - exit (1) ; - } ; - - if ((k = sf_readf_int (file, data, 1)) != 1) - { printf ("Line %d: sf_readf_int (file, data, 1) returned %d.\n", __LINE__, k) ; - exit (1) ; - } ; - - if (error_function ((double) data [0], (double) orig [seekpos], margin)) - { printf ("Line %d: sf_seek (SEEK_SET) followed by sf_readf_int failed (%d, %d).\n", __LINE__, orig [1], data [0]) ; - exit (1) ; - } ; - - if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("Line %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %" PRId64 ")\n", __LINE__, k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ; - k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; - sf_readf_int (file, data, 1) ; - if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos) - { printf ("Line %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %" PRId64 ").\n", __LINE__, data [0], orig [seekpos], k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ; - /* Check seek backward from current position. */ - k = sf_seek (file, -20, SEEK_CUR) ; - sf_readf_int (file, data, 1) ; - if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos) - { printf ("sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %" PRId64 ").\n", data [0], orig [seekpos], k, seekpos) ; - exit (1) ; - } ; - - /* Check that read past end of file returns number of items. */ - sf_seek (file, (int) sfinfo.frames, SEEK_SET) ; - - if ((k = sf_readf_int (file, data, datalen)) != 0) - { printf ("Line %d: Return value from sf_readf_int past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - /* Check seek backward from end. */ - if ((k = sf_seek (file, 5 - (int) sfinfo.frames, SEEK_END)) != 5) - { printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ; - exit (1) ; - } ; - - sf_readf_int (file, data, 1) ; - if (error_function (data [0] / scale, orig [5] / scale, margin)) - { printf ("Line %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%d should be %d).\n", __LINE__, data [0], orig [5]) ; - exit (1) ; - } ; - - sf_close (file) ; - - printf ("ok\n") ; -} /* lcomp_test_int */ - -/*======================================================================================== -** Auxiliary functions -*/ - -#define SIGNAL_MAXVAL 30000.0 -#define DECAY_COUNT 800 - -static int -decay_response (int k) -{ if (k < 1) - return (int) (1.2 * SIGNAL_MAXVAL) ; - if (k > DECAY_COUNT) - return 0 ; - return (int) (1.2 * SIGNAL_MAXVAL * (DECAY_COUNT - k) / (1.0 * DECAY_COUNT)) ; -} /* decay_response */ - -static void -gen_signal_double (double *data, double scale, int datalen) -{ int k, ramplen ; - double amp = 0.0 ; - - ramplen = datalen / 18 ; - - for (k = 0 ; k < datalen ; k++) - { if (k <= ramplen) - amp = scale * k / ((double) ramplen) ; - else if (k > datalen - ramplen) - amp = scale * (datalen - k) / ((double) ramplen) ; - - data [k] = amp * (0.4 * sin (33.3 * 2.0 * M_PI * ((double) (k + 1)) / ((double) SAMPLE_RATE)) - + 0.3 * cos (201.1 * 2.0 * M_PI * ((double) (k + 1)) / ((double) SAMPLE_RATE))) ; - } ; - - return ; -} /* gen_signal_double */ - -static int -error_function (double data, double orig, double margin) -{ double error ; - - if (fabs (orig) <= 500.0) - error = fabs (fabs (data) - fabs (orig)) / 2000.0 ; - else if (fabs (orig) <= 1000.0) - error = fabs (data - orig) / 3000.0 ; - else - error = fabs (data - orig) / fabs (orig) ; - - if (error > margin) - { printf ("\n\n*******************\nError : %f\n", error) ; - return 1 ; - } ; - return 0 ; -} /* error_function */ - diff --git a/Engine/lib/libsndfile/tests/floating_point_test.def b/Engine/lib/libsndfile/tests/floating_point_test.def deleted file mode 100644 index e368ddf45..000000000 --- a/Engine/lib/libsndfile/tests/floating_point_test.def +++ /dev/null @@ -1,32 +0,0 @@ -autogen definitions floating_point_test.tpl; - -endian_type = { - end_name = little ; - end_type = SF_ENDIAN_LITTLE ; - } ; - -endian_type = { - end_name = big ; - end_type = SF_ENDIAN_BIG ; - } ; - -float_type = { - float_name = float ; - minor_type = SF_FORMAT_FLOAT ; - } ; - -float_type = { - float_name = double ; - minor_type = SF_FORMAT_DOUBLE ; - } ; - -int_type = { - int_name = short ; - int_max = "0x7FFF" ; - } ; - -int_type = { - int_name = int ; - int_max = "0x7FFFFFFF" ; - } ; - diff --git a/Engine/lib/libsndfile/tests/floating_point_test.tpl b/Engine/lib/libsndfile/tests/floating_point_test.tpl deleted file mode 100644 index 9651391cc..000000000 --- a/Engine/lib/libsndfile/tests/floating_point_test.tpl +++ /dev/null @@ -1,380 +0,0 @@ -[+ AutoGen5 template c +] -/* -** Copyright (C) 1999-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "dft_cmp.h" -#include "utils.h" - -#define SAMPLE_RATE 16000 - -static const char FPT_TEST_PREFIX[] = "fpt" ; - -static void float_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr) ; -static void double_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr) ; - -[+ FOR float_type +][+ FOR int_type +][+ FOR endian_type -+]static void [+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test (const char * filename, int replace_float) ; -[+ ENDFOR endian_type +][+ ENDFOR int_type +][+ ENDFOR float_type -+] - -static double double_data [DFT_DATA_LENGTH] ; -static double double_test [DFT_DATA_LENGTH] ; - -static float float_data [DFT_DATA_LENGTH] ; -static float float_test [DFT_DATA_LENGTH] ; - -static double double_data [DFT_DATA_LENGTH] ; -static short short_data [DFT_DATA_LENGTH] ; -static int int_data [DFT_DATA_LENGTH] ; - -int -main (int argc, char *argv []) -{ int allow_exit = 1 ; - - if (argc == 2 && ! strstr (argv [1], "no-exit")) - allow_exit = 0 ; - -#if (HAVE_LRINTF == 0) - puts ("*** Cannot run this test on this platform because it lacks lrintf().") ; - exit (0) ; -#endif - - /* Float tests. */ - float_scaled_test ("float.raw", allow_exit, SF_FALSE, SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, - OS_IS_OPENBSD ? -98.0 : -163.0) ; - - /* Test both signed and unsigned 8 bit files. */ - float_scaled_test ("pcm_s8.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_S8, -39.0) ; - float_scaled_test ("pcm_u8.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_U8, -39.0) ; - - float_scaled_test ("pcm_16.raw", allow_exit, SF_FALSE, SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, -87.0) ; - float_scaled_test ("pcm_24.raw", allow_exit, SF_FALSE, SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, -138.0) ; - float_scaled_test ("pcm_32.raw", allow_exit, SF_FALSE, SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, -163.0) ; - - float_scaled_test ("ulaw.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_ULAW, -50.0) ; - float_scaled_test ("alaw.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_ALAW, -49.0) ; - - float_scaled_test ("ima_adpcm.wav", allow_exit, SF_FALSE, SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, -47.0) ; - float_scaled_test ("ms_adpcm.wav" , allow_exit, SF_FALSE, SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, -40.0) ; - float_scaled_test ("gsm610.raw" , allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_GSM610, -33.0) ; - - float_scaled_test ("g721_32.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G721_32, -32.3) ; - float_scaled_test ("g723_24.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G723_24, -32.3) ; - float_scaled_test ("g723_40.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G723_40, -40.0) ; - - /* PAF files do not use the same encoding method for 24 bit PCM data as other file - ** formats so we need to explicitly test it here. - */ - float_scaled_test ("le_paf_24.paf", allow_exit, SF_FALSE, SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_24, -149.0) ; - float_scaled_test ("be_paf_24.paf", allow_exit, SF_FALSE, SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_24, -149.0) ; - - float_scaled_test ("dwvw_12.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_12, -64.0) ; - float_scaled_test ("dwvw_16.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_16, -92.0) ; - float_scaled_test ("dwvw_24.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_24, -151.0) ; - - float_scaled_test ("adpcm.vox", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, -40.0) ; - - float_scaled_test ("dpcm_16.xi", allow_exit, SF_FALSE, SF_FORMAT_XI | SF_FORMAT_DPCM_16, -90.0) ; - float_scaled_test ("dpcm_8.xi" , allow_exit, SF_FALSE, SF_FORMAT_XI | SF_FORMAT_DPCM_8 , -41.0) ; - - float_scaled_test ("pcm_s8.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_S8, -89.0) ; - float_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -132.0) ; - float_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -170.0) ; - - float_scaled_test ("alac_16.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_16, -90.0) ; - float_scaled_test ("alac_32.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_32, -76.0) ; - float_scaled_test ("alac_24.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_24, -153.0) ; - float_scaled_test ("alac_20.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_20, -125.0) ; - -#if HAVE_EXTERNAL_XIPH_LIBS - float_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ; - float_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ; - float_scaled_test ("flac_24.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_24, -138.0) ; - - float_scaled_test ("vorbis.oga", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_VORBIS, -31.0) ; - - float_scaled_test ("opus.opus", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_OPUS, -32.0) ; -#endif - -#if HAVE_MPEG - float_scaled_test ("mpeg.mp3", allow_exit, SF_FALSE, SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III, -52.0) ; -#endif - - float_scaled_test ("replace_float.raw", allow_exit, SF_TRUE, SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, -163.0) ; - - /*============================================================================== - ** Double tests. - */ - - double_scaled_test ("double.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -201.0) ; - - /* Test both signed (AIFF) and unsigned (WAV) 8 bit files. */ - double_scaled_test ("pcm_s8.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_S8, -39.0) ; - double_scaled_test ("pcm_u8.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_U8, -39.0) ; - - double_scaled_test ("pcm_16.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_16, -87.0) ; - double_scaled_test ("pcm_24.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_24, -135.0) ; - double_scaled_test ("pcm_32.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_32, -184.0) ; - - double_scaled_test ("ulaw.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_ULAW, -50.0) ; - double_scaled_test ("alaw.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_ALAW, -49.0) ; - - double_scaled_test ("ima_adpcm.wav", allow_exit, SF_FALSE, SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, -47.0) ; - double_scaled_test ("ms_adpcm.wav" , allow_exit, SF_FALSE, SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, -40.0) ; - double_scaled_test ("gsm610.raw" , allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_GSM610, -33.0) ; - - double_scaled_test ("g721_32.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G721_32, -32.3) ; - double_scaled_test ("g723_24.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G723_24, -32.3) ; - double_scaled_test ("g723_40.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G723_40, -40.0) ; - - /* 24 bit PCM PAF files tested here. */ - double_scaled_test ("be_paf_24.paf", allow_exit, SF_FALSE, SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_24, -151.0) ; - double_scaled_test ("le_paf_24.paf", allow_exit, SF_FALSE, SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_24, -151.0) ; - - double_scaled_test ("dwvw_12.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_12, -64.0) ; - double_scaled_test ("dwvw_16.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_16, -92.0) ; - double_scaled_test ("dwvw_24.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_24, -151.0) ; - - double_scaled_test ("adpcm.vox" , allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, -40.0) ; - - double_scaled_test ("dpcm_16.xi", allow_exit, SF_FALSE, SF_FORMAT_XI | SF_FORMAT_DPCM_16, -90.0) ; - double_scaled_test ("dpcm_8.xi" , allow_exit, SF_FALSE, SF_FORMAT_XI | SF_FORMAT_DPCM_8 , -41.0) ; - - double_scaled_test ("pcm_s8.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_S8, -89.0) ; - double_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -132.0) ; - double_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -180.0) ; - - double_scaled_test ("alac_16.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_16, -90.0) ; - double_scaled_test ("alac_20.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_20, -125.0) ; - double_scaled_test ("alac_24.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_24, -153.0) ; - double_scaled_test ("alac_32.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_32, -186.0) ; - -#if HAVE_EXTERNAL_XIPH_LIBS - double_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ; - double_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ; - double_scaled_test ("flac_24.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_24, -138.0) ; - - double_scaled_test ("vorbis.oga", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_VORBIS, -29.0) ; - double_scaled_test ("opus.opus", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_OPUS, -32.0) ; -#endif - -#if HAVE_MPEG - double_scaled_test ("mpeg.mp3", allow_exit, SF_FALSE, SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III, -52.0) ; -#endif - - double_scaled_test ("replace_double.raw", allow_exit, SF_TRUE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -201.0) ; - - putchar ('\n') ; - /* Float int tests. */ -[+ FOR float_type +][+ FOR int_type +][+ FOR endian_type +] -[+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test ("[+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +].au", SF_FALSE) ; -[+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test ("[+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_replace.au", SF_TRUE) ; -[+ ENDFOR endian_type +][+ ENDFOR int_type +][+ ENDFOR float_type +] - - return 0 ; -} /* main */ - -/*============================================================================================ - * Here are the test functions. - */ - -static void -float_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr) -{ SNDFILE *file ; - SF_INFO sfinfo ; - double snr ; - int byterate ; - - get_unique_test_name (&filename, FPT_TEST_PREFIX) ; - print_test_name ("float_scaled_test", filename) ; - - gen_windowed_sine_float (float_data, DFT_DATA_LENGTH, 0.9999) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = DFT_DATA_LENGTH ; - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - - test_write_float_or_die (file, 0, float_data, DFT_DATA_LENGTH, __LINE__) ; - - sf_close (file) ; - - memset (float_test, 0, sizeof (float_test)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - - exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit_if_true (sfinfo.frames < DFT_DATA_LENGTH, "\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; - exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_float_or_die (file, 0, float_test, DFT_DATA_LENGTH, __LINE__) ; - - byterate = sf_current_byterate (file) ; - exit_if_true (byterate <= 0, "\n\nLine %d: byterate is zero.\n", __LINE__) ; - - sf_close (file) ; - - snr = dft_cmp_float (__LINE__, float_data, float_test, DFT_DATA_LENGTH, target_snr, allow_exit) ; - - exit_if_true (snr > target_snr, "% 6.1fdB SNR\n\n Error : should be better than % 6.1fdB\n\n", snr, target_snr) ; - - printf ("% 6.1fdB SNR ... ok\n", snr) ; - - unlink (filename) ; - - return ; -} /* float_scaled_test */ - -static void -double_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr) -{ SNDFILE *file ; - SF_INFO sfinfo ; - double snr ; - int byterate ; - - get_unique_test_name (&filename, FPT_TEST_PREFIX) ; - print_test_name ("double_scaled_test", filename) ; - - gen_windowed_sine_double (double_data, DFT_DATA_LENGTH, 0.9999) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = DFT_DATA_LENGTH ; - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - - test_write_double_or_die (file, 0, double_data, DFT_DATA_LENGTH, __LINE__) ; - - sf_close (file) ; - - memset (double_test, 0, sizeof (double_test)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - - exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit_if_true (sfinfo.frames < DFT_DATA_LENGTH, "\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; - exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_double_or_die (file, 0, double_test, DFT_DATA_LENGTH, __LINE__) ; - - byterate = sf_current_byterate (file) ; - exit_if_true (byterate <= 0, "\n\nLine %d: byterate is zero.\n", __LINE__) ; - - sf_close (file) ; - - snr = dft_cmp_double (__LINE__, double_data, double_test, DFT_DATA_LENGTH, target_snr, allow_exit) ; - - exit_if_true (snr > target_snr, "% 6.1fdB SNR\n\n Error : should be better than % 6.1fdB\n\n", snr, target_snr) ; - - printf ("% 6.1fdB SNR ... ok\n", snr) ; - - unlink (filename) ; - - return ; -} /* double_scaled_test */ - -/*============================================================================== -*/ - -[+ FOR float_type +][+ FOR int_type +][+ FOR endian_type -+] -static void -[+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test (const char * filename, int replace_float) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int max ; - unsigned k ; - - get_unique_test_name (&filename, FPT_TEST_PREFIX) ; - print_test_name ("[+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test", filename) ; - - gen_windowed_sine_[+ (get "float_name") +] ([+ (get "float_name") +]_data, ARRAY_LEN ([+ (get "float_name") +]_data), 0.9999) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = ARRAY_LEN ([+ (get "int_name") +]_data) ; - sfinfo.channels = 1 ; - sfinfo.format = [+ (get "end_type") +] | SF_FORMAT_AU | [+ (get "minor_type") +] ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - test_write_[+ (get "float_name") +]_or_die (file, 0, [+ (get "float_name") +]_data, ARRAY_LEN ([+ (get "float_name") +]_data), __LINE__) ; - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - - if (sfinfo.frames != ARRAY_LEN ([+ (get "float_name") +]_data)) - { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ; - - test_read_[+ (get "int_name") +]_or_die (file, 0, [+ (get "int_name") +]_data, ARRAY_LEN ([+ (get "int_name") +]_data), __LINE__) ; - sf_close (file) ; - - max = 0 ; - for (k = 0 ; k < ARRAY_LEN ([+ (get "int_name") +]_data) ; k++) - if (abs ([+ (get "int_name") +]_data [k]) > max) - max = abs ([+ (get "int_name") +]_data [k]) ; - - if (1.0 * abs (max - [+ (get "int_max") +]) / [+ (get "int_max") +] > 0.01) - { printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, [+ (get "int_max") +]) ; - exit (1) ; - } ; - - unlink (filename) ; - puts ("ok") ; -} /* [+ (get "float_name") +]_[+ (get "int_name") +]_[+ (get "end_name") +]_test */ -[+ ENDFOR endian_type +][+ ENDFOR int_type +][+ ENDFOR float_type +] - diff --git a/Engine/lib/libsndfile/tests/format_check_test.c b/Engine/lib/libsndfile/tests/format_check_test.c deleted file mode 100644 index 2e76679a4..000000000 --- a/Engine/lib/libsndfile/tests/format_check_test.c +++ /dev/null @@ -1,166 +0,0 @@ -/* -** Copyright (C) 2011-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include "sndfile.h" -#include "utils.h" - -static void format_error_test (void) ; -static void format_combo_test (void) ; - -int -main (void) -{ - format_error_test () ; - format_combo_test () ; - - return 0 ; -} /* main */ - -/*============================================================================== -*/ - -static void -format_error_test (void) -{ const char *filename = "format-error.wav" ; - SNDFILE *file ; - SF_INFO info ; - - print_test_name (__func__, NULL) ; - - memset (&info, 0, sizeof (info)) ; - info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; - info.channels = 1 ; - info.samplerate = 44100 ; - - info.format = SF_FORMAT_WAV ; - file = sf_open (filename, SFM_WRITE, &info) ; - exit_if_true (file != NULL, "\n\nLine %d : Format should not be valid.\n\n", __LINE__) ; - exit_if_true ( - strstr (sf_strerror (NULL), "minor format") == NULL, - "\n\nLine %d : Error string should reference bad 'minor format'.\n\n", __LINE__ - ) ; - - info.format = SF_FORMAT_PCM_16 ; - file = sf_open (filename, SFM_WRITE, &info) ; - exit_if_true (file != NULL, "\n\nLine %d : Format should not be valid.\n\n", __LINE__) ; - exit_if_true ( - strstr (sf_strerror (NULL), "major format") == NULL, - "\n\nLine %d : Error string should reference bad 'major format'.\n\n", __LINE__ - ) ; - - unlink (filename) ; - puts ("ok") ; -} /* format_error_test */ - -static void -format_combo_test (void) -{ int container_max, codec_max, cont, codec ; - - print_test_name (__func__, NULL) ; - - sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &container_max, sizeof (container_max)) ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &codec_max, sizeof (codec_max)) ; - - for (cont = 0 ; cont < container_max + 10 ; cont ++) - { SF_FORMAT_INFO major_fmt_info ; - - memset (&major_fmt_info, 0, sizeof (major_fmt_info)) ; - major_fmt_info.format = cont ; - (void) sf_command (NULL, SFC_GET_FORMAT_MAJOR, &major_fmt_info, sizeof (major_fmt_info)) ; - - for (codec = 0 ; codec < codec_max + 10 ; codec ++) - { SF_FORMAT_INFO subtype_fmt_info ; - SNDFILE * sndfile ; - SF_INFO info ; - char filename [128] ; - int subtype_is_valid, check_is_valid ; - - memset (&info, 0, sizeof (info)) ; - memset (&subtype_fmt_info, 0, sizeof (subtype_fmt_info)) ; - subtype_fmt_info.format = codec ; - subtype_is_valid = sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &subtype_fmt_info, sizeof (subtype_fmt_info)) == 0 ; - - /* Opus only works with a fixed set of sample rates. */ - if (subtype_fmt_info.format == SF_FORMAT_OPUS) - sf_info_setup (&info, major_fmt_info.format | subtype_fmt_info.format, 24000, 1) ; - else - sf_info_setup (&info, major_fmt_info.format | subtype_fmt_info.format, 22050, 1) ; - - check_is_valid = sf_format_check (&info) ; - - exit_if_true ( - NOT (subtype_is_valid) && check_is_valid, - "\n\nLine %d : Subtype is not valid but checks ok.\n", - __LINE__ - ) ; - - /* Only have decode, not encode support for MPEG Layer I and II */ - if (subtype_fmt_info.format == SF_FORMAT_MPEG_LAYER_I || - subtype_fmt_info.format == SF_FORMAT_MPEG_LAYER_II) - continue ; - - /* MPEG Layer III in WAV is decode only currently */ - if (subtype_fmt_info.format == SF_FORMAT_MPEG_LAYER_III && - major_fmt_info.format == SF_FORMAT_WAV) - continue ; - - snprintf (filename, sizeof (filename), "format-check.%s", major_fmt_info.extension) ; - - sndfile = sf_open (filename, SFM_WRITE, &info) ; - - sf_close (sndfile) ; - unlink (filename) ; - - if (major_fmt_info.extension != NULL && strcmp (major_fmt_info.extension, "sd2") == 0) - { snprintf (filename, sizeof (filename), "._format-check.%s", major_fmt_info.extension) ; - unlink (filename) ; - } ; - - exit_if_true ( - sndfile && NOT (check_is_valid), - "\n\nError : Format was not valid but file opened correctly.\n" - " Container : %s\n" - " Codec : %s\n\n", - major_fmt_info.name, subtype_fmt_info.name - ) ; - - exit_if_true ( - NOT (sndfile) && check_is_valid, - "\n\nError : Format was valid but file failed to open.\n" - " Container : %s\n" - " Codec : %s\n\n", - major_fmt_info.name, subtype_fmt_info.name - ) ; - } ; - } ; - - puts ("ok") ; -} /* format_combo_test */ - diff --git a/Engine/lib/libsndfile/tests/generate.c b/Engine/lib/libsndfile/tests/generate.c deleted file mode 100644 index b49b2718b..000000000 --- a/Engine/lib/libsndfile/tests/generate.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -** Copyright (C) 2007-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include - -#include "utils.h" -#include "generate.h" - -#define SF_MAX(x, y) ((x) > (y) ? (x) : (y)) - -static float crappy_snare (float *output, int len, int offset, float gain, float maxabs) ; - -void -generate_file (const char * filename, int format, int len) -{ float * output ; - float maxabs = 0.0 ; - - output = calloc (len, sizeof (float)) ; - - maxabs = crappy_snare (output, len, 0, 0.95f, maxabs) ; - maxabs = crappy_snare (output, len, len / 4, 0.85f, maxabs) ; - maxabs = crappy_snare (output, len, 2 * len / 4, 0.85f, maxabs) ; - crappy_snare (output, len, 3 * len / 4, 0.85f, maxabs) ; - - write_mono_file (filename, format, 44100, output, len) ; - - free (output) ; -} /* generate_file */ - -static inline float -rand_float (void) -{ return rand () / (0.5f * (float) RAND_MAX) - 1.0f ; -} /* rand_float */ - -static float -crappy_snare (float *output, int len, int offset, float gain, float maxabs) -{ int k ; - float env = 0.0f ; - - for (k = offset ; k < len && env < gain ; k++) - { env += 0.03f ; - output [k] += env * rand_float () ; - maxabs = SF_MAX (maxabs, fabsf (output [k])) ; - } ; - - for ( ; k < len && env > 1e-8 ; k++) - { env *= 0.995f ; - output [k] += env * rand_float () ; - maxabs = SF_MAX (maxabs, fabsf (output [k])) ; - } ; - - return maxabs ; -} /* crappy_snare */ diff --git a/Engine/lib/libsndfile/tests/generate.h b/Engine/lib/libsndfile/tests/generate.h deleted file mode 100644 index 709ea6119..000000000 --- a/Engine/lib/libsndfile/tests/generate.h +++ /dev/null @@ -1,19 +0,0 @@ -/* -** Copyright (C) 2007-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -void generate_file (const char * filename, int format, int len) ; diff --git a/Engine/lib/libsndfile/tests/header_test.def b/Engine/lib/libsndfile/tests/header_test.def deleted file mode 100644 index 959703ef0..000000000 --- a/Engine/lib/libsndfile/tests/header_test.def +++ /dev/null @@ -1,22 +0,0 @@ -autogen definitions header_test.tpl; - -data_type = { - name = "short" ; - format = "SF_FORMAT_PCM_16" ; - } ; - -data_type = { - name = "int" ; - format = "SF_FORMAT_PCM_32" ; - } ; - -data_type = { - name = "float" ; - format = "SF_FORMAT_FLOAT" ; - } ; - -data_type = { - name = "double" ; - format = "SF_FORMAT_DOUBLE" ; - } ; - diff --git a/Engine/lib/libsndfile/tests/header_test.tpl b/Engine/lib/libsndfile/tests/header_test.tpl deleted file mode 100644 index b02fbef86..000000000 --- a/Engine/lib/libsndfile/tests/header_test.tpl +++ /dev/null @@ -1,583 +0,0 @@ -[+ AutoGen5 template c +] -/* -** Copyright (C) 2001-2017 Erik de Castro Lopo -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation ; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#include - -#if HAVE_UNISTD_H -#include -#endif - -#if (HAVE_DECL_S_IRGRP == 0) -#include -#endif - -#if (defined (WIN32) || defined (_WIN32)) -#include -#include -#endif - -#include - -#include "utils.h" - -#define BUFFER_LEN (1 << 10) -#define LOG_BUFFER_SIZE 1024 - -static void update_header_test (const char *filename, int typemajor) ; -static void update_header_before_write_test (const char *filename, int typemajor) ; - -[+ FOR data_type -+]static void update_seek_[+ (get "name") +]_test (const char *filename, int filetype) ; -[+ ENDFOR data_type -+] - -static void extra_header_test (const char *filename, int filetype) ; - -static void header_shrink_test (const char *filename, int filetype) ; - -/* Force the start of this buffer to be double aligned. Sparc-solaris will -** choke if its not. -*/ -static int data_out [BUFFER_LEN] ; -static int data_in [BUFFER_LEN] ; - -int -main (int argc, char *argv []) -{ int do_all = 0 ; - int test_count = 0 ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" wav - test WAV file peak chunk\n") ; - printf (" aiff - test AIFF file PEAK chunk\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all= !strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "wav")) - { update_header_test ("header.wav", SF_FORMAT_WAV) ; - update_seek_short_test ("header_short.wav", SF_FORMAT_WAV) ; - update_seek_int_test ("header_int.wav", SF_FORMAT_WAV) ; - update_seek_float_test ("header_float.wav", SF_FORMAT_WAV) ; - update_seek_double_test ("header_double.wav", SF_FORMAT_WAV) ; - header_shrink_test ("header_shrink.wav", SF_FORMAT_WAV) ; - extra_header_test ("extra.wav", SF_FORMAT_WAV) ; - - update_header_test ("header.wavex", SF_FORMAT_WAVEX) ; - update_seek_short_test ("header_short.wavex", SF_FORMAT_WAVEX) ; - update_seek_int_test ("header_int.wavex", SF_FORMAT_WAVEX) ; - update_seek_float_test ("header_float.wavex", SF_FORMAT_WAVEX) ; - update_seek_double_test ("header_double.wavex", SF_FORMAT_WAVEX) ; - header_shrink_test ("header_shrink.wavex", SF_FORMAT_WAVEX) ; - extra_header_test ("extra.wavex", SF_FORMAT_WAVEX) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { update_header_test ("header.aiff", SF_FORMAT_AIFF) ; - update_seek_short_test ("header_short.aiff", SF_FORMAT_AIFF) ; - update_seek_int_test ("header_int.aiff", SF_FORMAT_AIFF) ; - update_seek_float_test ("header_float.aiff", SF_FORMAT_AIFF) ; - update_seek_double_test ("header_double.aiff", SF_FORMAT_AIFF) ; - header_shrink_test ("header_shrink.aiff", SF_FORMAT_AIFF) ; - extra_header_test ("extra.aiff", SF_FORMAT_AIFF) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "au")) - { update_header_test ("header.au", SF_FORMAT_AU) ; - update_seek_short_test ("header_short.au", SF_FORMAT_AU) ; - update_seek_int_test ("header_int.au", SF_FORMAT_AU) ; - update_seek_float_test ("header_float.au", SF_FORMAT_AU) ; - update_seek_double_test ("header_double.au", SF_FORMAT_AU) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "caf")) - { update_header_test ("header.caf", SF_FORMAT_CAF) ; - update_seek_short_test ("header_short.caf", SF_FORMAT_CAF) ; - update_seek_int_test ("header_int.caf", SF_FORMAT_CAF) ; - update_seek_float_test ("header_float.caf", SF_FORMAT_CAF) ; - update_seek_double_test ("header_double.caf", SF_FORMAT_CAF) ; - /* extra_header_test ("extra.caf", SF_FORMAT_CAF) ; */ - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "nist")) - { update_header_test ("header.nist", SF_FORMAT_NIST) ; - update_seek_short_test ("header_short.nist", SF_FORMAT_NIST) ; - update_seek_int_test ("header_int.nist", SF_FORMAT_NIST) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "paf")) - { update_header_test ("header.paf", SF_FORMAT_PAF) ; - update_seek_short_test ("header_short.paf", SF_FORMAT_PAF) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "ircam")) - { update_header_test ("header.ircam", SF_FORMAT_IRCAM) ; - update_seek_short_test ("header_short.ircam", SF_FORMAT_IRCAM) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "w64")) - { update_header_test ("header.w64", SF_FORMAT_W64) ; - update_seek_short_test ("header_short.w64", SF_FORMAT_W64) ; - update_seek_int_test ("header_int.w64", SF_FORMAT_W64) ; - update_seek_float_test ("header_float.w64", SF_FORMAT_W64) ; - update_seek_double_test ("header_double.w64", SF_FORMAT_W64) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "rf64")) - { update_header_test ("header.rf64", SF_FORMAT_RF64) ; - update_seek_short_test ("header_short.rf64", SF_FORMAT_RF64) ; - update_seek_int_test ("header_int.rf64", SF_FORMAT_RF64) ; - update_seek_float_test ("header_float.rf64", SF_FORMAT_RF64) ; - update_seek_double_test ("header_double.rf64", SF_FORMAT_RF64) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat4")) - { update_header_test ("header.mat4", SF_FORMAT_MAT4) ; - update_seek_short_test ("header_short.mat4", SF_FORMAT_MAT4) ; - update_seek_int_test ("header_int.mat4", SF_FORMAT_MAT4) ; - update_seek_float_test ("header_float.mat4", SF_FORMAT_MAT4) ; - update_seek_double_test ("header_double.mat4", SF_FORMAT_MAT4) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat5")) - { update_header_test ("header.mat5", SF_FORMAT_MAT5) ; - update_seek_short_test ("header_short.mat5", SF_FORMAT_MAT5) ; - update_seek_int_test ("header_int.mat5", SF_FORMAT_MAT5) ; - update_seek_float_test ("header_float.mat5", SF_FORMAT_MAT5) ; - update_seek_double_test ("header_double.mat5", SF_FORMAT_MAT5) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "pvf")) - { update_header_test ("header.pvf", SF_FORMAT_PVF) ; - update_seek_short_test ("header_short.pvf", SF_FORMAT_PVF) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "avr")) - { update_header_test ("header.avr", SF_FORMAT_AVR) ; - update_seek_short_test ("header_short.avr", SF_FORMAT_AVR) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "htk")) - { update_header_test ("header.htk", SF_FORMAT_HTK) ; - update_seek_short_test ("header_short.htk", SF_FORMAT_HTK) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "svx")) - { update_header_test ("header.svx", SF_FORMAT_SVX) ; - update_seek_short_test ("header_short.svx", SF_FORMAT_SVX) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "voc")) - { update_header_test ("header.voc", SF_FORMAT_VOC) ; - /*-update_seek_short_test ("header_short.voc", SF_FORMAT_VOC) ;-*/ - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "sds")) - { update_header_test ("header.sds", SF_FORMAT_SDS) ; - /*-update_seek_short_test ("header_short.sds", SF_FORMAT_SDS) ;-*/ - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mpc2k")) - { update_header_test ("header.mpc", SF_FORMAT_MPC2K) ; - update_seek_short_test ("header_short.mpc", SF_FORMAT_MPC2K) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "flac")) - { if (HAVE_EXTERNAL_XIPH_LIBS) - update_header_before_write_test ("header.flac", SF_FORMAT_FLAC) ; - else - puts (" No FLAC tests because FLAC support was not compiled in.") ; - test_count++ ; - } ; - - if (test_count == 0) - { printf ("Mono : ************************************\n") ; - printf ("Mono : * No '%s' test defined.\n", argv [1]) ; - printf ("Mono : ************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -update_header_sub (const char *filename, int typemajor, int write_mode) -{ SNDFILE *outfile, *infile ; - SF_INFO sfinfo ; - int k ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ; - sfinfo.channels = 1 ; - - outfile = test_open_file_or_die (filename, write_mode, &sfinfo, SF_TRUE, __LINE__) ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - data_out [k] = k + 1 ; - test_write_int_or_die (outfile, 0, data_out, BUFFER_LEN, __LINE__) ; - - if (typemajor != SF_FORMAT_HTK) - { /* The HTK header is not correct when the file is first written. */ - infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_close (infile) ; - } ; - - sf_command (outfile, SFC_UPDATE_HEADER_NOW, NULL, 0) ; - - /* - ** Open file and check log buffer for an error. If header update failed - ** the the log buffer will contain errors. - */ - infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - check_log_buffer_or_die (infile, __LINE__) ; - - if (sfinfo.frames < BUFFER_LEN || sfinfo.frames > BUFFER_LEN + 50) - { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, BUFFER_LEN) ; - dump_log_buffer (infile) ; - exit (1) ; - } ; - - test_read_int_or_die (infile, 0, data_in, BUFFER_LEN, __LINE__) ; - for (k = 0 ; k < BUFFER_LEN ; k++) - if (data_out [k] != k + 1) - printf ("Error : line %d\n", __LINE__) ; - - sf_close (infile) ; - - /* Set auto update on. */ - sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) ; - - /* Write more data_out. */ - for (k = 0 ; k < BUFFER_LEN ; k++) - data_out [k] = k + 2 ; - test_write_int_or_die (outfile, 0, data_out, BUFFER_LEN, __LINE__) ; - - /* Open file again and make sure no errors in log buffer. */ - infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - check_log_buffer_or_die (infile, __LINE__) ; - - if (sfinfo.frames < 2 * BUFFER_LEN || sfinfo.frames > 2 * BUFFER_LEN + 50) - { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, 2 * BUFFER_LEN) ; - dump_log_buffer (infile) ; - exit (1) ; - } ; - - sf_close (infile) ; - - sf_close (outfile) ; - - unlink (filename) ; -} /* update_header_sub */ - -static void -update_header_test (const char *filename, int typemajor) -{ - print_test_name ("update_header_test", filename) ; - - update_header_sub (filename, typemajor, SFM_WRITE) ; - update_header_sub (filename, typemajor, SFM_RDWR) ; - - unlink (filename) ; - puts ("ok") ; -} /* update_header_test */ - -static void -update_header_before_write_test (const char *filename, int typemajor) -{ - SNDFILE *outfile ; - SF_INFO sfinfo ; - int k ; - - print_test_name ("update_header_before_write", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ; - sfinfo.channels = 1 ; - - outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - /* FLAC can only write the header once; if the first call to sf_write() will - ** also attempt to write the header, it fails. FLAC-specific regression - */ - sf_command (outfile, SFC_UPDATE_HEADER_NOW, NULL, 0) ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - data_out [k] = k + 1 ; - test_write_int_or_die (outfile, 0, data_out, BUFFER_LEN, __LINE__) ; - - sf_close (outfile) ; - unlink (filename) ; - puts ("ok") ; -} /* update_header_before_write_test */ - -/*============================================================================== -*/ - -[+ FOR data_type -+]static void -update_seek_[+ (get "name") +]_test (const char *filename, int filetype) -{ SNDFILE *outfile, *infile ; - SF_INFO sfinfo ; - sf_count_t frames ; - [+ (get "name") +] buffer [8] ; - int k ; - - print_test_name ("update_seek_[+ (get "name") +]_test", filename) ; - - memset (buffer, 0, sizeof (buffer)) ; - - /* Create sound outfile with no data. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.format = filetype | [+ (get "format") +] ; - sfinfo.samplerate = 48000 ; - sfinfo.channels = 2 ; - - if (sf_format_check (&sfinfo) == SF_FALSE) - sfinfo.channels = 1 ; - - outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_close (outfile) ; - - /* Open again for read/write. */ - outfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; - - /* - ** In auto header update mode, seeking to the end of the file with - ** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END - ** will seek to 0 anyway - */ - if (sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) == 0) - { printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ; - exit (1) ; - } ; - - /* Now write some frames. */ - frames = ARRAY_LEN (buffer) / sfinfo.channels ; - - for (k = 0 ; k < 6 ; k++) - { test_seek_or_die (outfile, k * frames, SEEK_SET, k * frames, sfinfo.channels, __LINE__) ; - test_seek_or_die (outfile, 0, SEEK_END, k * frames, sfinfo.channels, __LINE__) ; - - /* Open file again and make sure no errors in log buffer. */ - infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - check_log_buffer_or_die (infile, __LINE__) ; - sf_close (infile) ; - - if (sfinfo.frames != k * frames) - { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %" PRId64 ")\n", __LINE__, sfinfo.frames, k + frames) ; - dump_log_buffer (infile) ; - exit (1) ; - } ; - - if ((k & 1) == 0) - test_write_[+ (get "name") +]_or_die (outfile, k, buffer, sfinfo.channels * frames, __LINE__) ; - else - test_writef_[+ (get "name") +]_or_die (outfile, k, buffer, frames, __LINE__) ; - } ; - - sf_close (outfile) ; - unlink (filename) ; - - puts ("ok") ; - return ; -} /* update_seek_[+ (get "name") +]_test */ - -[+ ENDFOR data_type -+] - -static void -header_shrink_test (const char *filename, int filetype) -{ SNDFILE *outfile, *infile ; - SF_INFO sfinfo ; - sf_count_t frames ; - float buffer [8], bufferin [8] ; - - print_test_name ("header_shrink_test", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.format = filetype | SF_FORMAT_FLOAT ; - sfinfo.channels = 1 ; - - memset (buffer, 0xA0, sizeof (buffer)) ; - - /* Now write some frames. */ - frames = ARRAY_LEN (buffer) / sfinfo.channels ; - - /* Test the file with extra header data. */ - outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - - sf_command (outfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ; - sf_command (outfile, SFC_UPDATE_HEADER_NOW, NULL, SF_FALSE) ; - sf_command (outfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ; - - test_writef_float_or_die (outfile, 0, buffer, frames, __LINE__) ; - sf_close (outfile) ; - - /* Open again for read. */ - infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_readf_float_or_die (infile, 0, bufferin, frames, __LINE__) ; - sf_close (infile) ; - - compare_float_or_die (buffer, bufferin, frames, __LINE__) ; - - unlink (filename) ; - puts ("ok") ; - return ; -} /* header_shrink_test */ - - -static void -extra_header_test (const char *filename, int filetype) -{ SNDFILE *outfile, *infile ; - SF_INFO sfinfo ; - sf_count_t frames ; - short buffer [8] ; - int k = 0 ; - - print_test_name ("extra_header_test", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.format = (filetype | SF_FORMAT_PCM_16) ; - sfinfo.channels = 1 ; - - memset (buffer, 0xA0, sizeof (buffer)) ; - - /* Now write some frames. */ - frames = ARRAY_LEN (buffer) / sfinfo.channels ; - - /* Test the file with extra header data. */ - outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, [+ (tpl-file-line "%2$d") +]) ; - sf_set_string (outfile, SF_STR_TITLE, filename) ; - test_writef_short_or_die (outfile, k, buffer, frames, [+ (tpl-file-line "%2$d") +]) ; - sf_set_string (outfile, SF_STR_COPYRIGHT, "(c) 1980 Erik") ; - sf_close (outfile) ; - -#if 1 - /* - ** Erik de Castro Lopo May 23 2004. - ** - ** This file has extra string data in the header and therefore cannot - ** currently be opened in SFM_RDWR mode. This is fixable, but its in - ** a part of the code I don't want to fiddle with until the Ogg/Vorbis - ** integration is done. - */ - - if ((infile = sf_open (filename, SFM_RDWR, &sfinfo)) != NULL) - { printf ("\n\nError : should not be able to open this file in SFM_RDWR.\n\n") ; - exit (1) ; - } ; - - unlink (filename) ; - puts ("ok") ; - return ; -#else - - hexdump_file (filename, 0, 100000) ; - - /* Open again for read/write. */ - outfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, [+ (tpl-file-line "%2$d") +]) ; - - /* - ** In auto header update mode, seeking to the end of the file with - ** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END - ** will seek to 0 anyway - */ - if (sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) == 0) - { printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ; - exit (1) ; - } ; - - /* Now write some frames. */ - frames = ARRAY_LEN (buffer) / sfinfo.channels ; - - for (k = 1 ; k < 6 ; k++) - { - printf ("\n*** pass %d\n", k) ; - memset (buffer, 0xA0 + k, sizeof (buffer)) ; - - - test_seek_or_die (outfile, k * frames, SEEK_SET, k * frames, sfinfo.channels, [+ (tpl-file-line "%2$d") +]) ; - test_seek_or_die (outfile, 0, SEEK_END, k * frames, sfinfo.channels, [+ (tpl-file-line "%2$d") +]) ; - - /* Open file again and make sure no errors in log buffer. */ - if (0) - { infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, [+ (tpl-file-line "%2$d") +]) ; - check_log_buffer_or_die (infile, [+ (tpl-file-line "%2$d") +]) ; - sf_close (infile) ; - } ; - - if (sfinfo.frames != k * frames) - { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %" PRId64 ")\n", [+ (tpl-file-line "%2$d") +], sfinfo.frames, k + frames) ; - dump_log_buffer (infile) ; - exit (1) ; - } ; - - if ((k & 1) == 0) - test_write_short_or_die (outfile, k, buffer, sfinfo.channels * frames, [+ (tpl-file-line "%2$d") +]) ; - else - test_writef_short_or_die (outfile, k, buffer, frames, [+ (tpl-file-line "%2$d") +]) ; - hexdump_file (filename, 0, 100000) ; - } ; - - sf_close (outfile) ; - unlink (filename) ; - - puts ("ok") ; - return ; -#endif -} /* extra_header_test */ diff --git a/Engine/lib/libsndfile/tests/headerless_test.c b/Engine/lib/libsndfile/tests/headerless_test.c deleted file mode 100644 index 86aa6db9a..000000000 --- a/Engine/lib/libsndfile/tests/headerless_test.c +++ /dev/null @@ -1,187 +0,0 @@ -/* -** Copyright (C) 1999-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_SIZE (2000) - -static void old_test (void) ; -static void headerless_test (const char * filename, int format, int expected) ; - -int -main (void) -{ - old_test () ; - - headerless_test ("headerless.vox", SF_FORMAT_VOX_ADPCM, SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM) ; - headerless_test ("headerless.gsm", SF_FORMAT_GSM610, SF_FORMAT_RAW | SF_FORMAT_GSM610) ; - - headerless_test ("headerless.snd", SF_FORMAT_ULAW, SF_FORMAT_RAW | SF_FORMAT_ULAW) ; - headerless_test ("headerless.au" , SF_FORMAT_ULAW, SF_FORMAT_RAW | SF_FORMAT_ULAW) ; - - return 0 ; -} /* main */ - -static void -headerless_test (const char * filename, int format, int expected) -{ static short buffer [BUFFER_SIZE] ; - SNDFILE *file ; - SF_INFO sfinfo ; - int k ; - - format &= SF_FORMAT_SUBMASK ; - - print_test_name (__func__, filename) ; - - for (k = 0 ; k < BUFFER_SIZE ; k++) - buffer [k] = k ; - - sfinfo.samplerate = 8000 ; - sfinfo.frames = 0 ; - sfinfo.channels = 1 ; - sfinfo.format = SF_FORMAT_RAW | format ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - if ((k = (int) sf_write_short (file, buffer, BUFFER_SIZE)) != BUFFER_SIZE) - { printf ("Line %d: sf_write_short failed with short write (%d => %d).\n", __LINE__, BUFFER_SIZE, k) ; - fflush (stdout) ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - sf_close (file) ; - - memset (buffer, 0, sizeof (buffer)) ; - - /* We should be able to detect these so clear sfinfo. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sfinfo.format != expected) - { printf ("Line %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, expected, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < BUFFER_SIZE) - { printf ("Line %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("Line %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - sf_close (file) ; - - printf ("ok\n") ; - unlink (filename) ; -} /* headerless_test */ - -static void -old_test (void) -{ static short buffer [BUFFER_SIZE] ; - SNDFILE *file ; - SF_INFO sfinfo ; - int k, filetype ; - const char *filename = "headerless.wav" ; - - print_test_name (__func__, "") ; - - for (k = 0 ; k < BUFFER_SIZE ; k++) - buffer [k] = k ; - - filetype = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; - - sfinfo.samplerate = 32000 ; - sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - if ((k = (int) sf_write_short (file, buffer, BUFFER_SIZE)) != BUFFER_SIZE) - { printf ("Line %d: sf_write_short failed with short write (%d => %d).\n", __LINE__, BUFFER_SIZE, k) ; - fflush (stdout) ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - sf_close (file) ; - - memset (buffer, 0, sizeof (buffer)) ; - - /* Read as RAW but get the bit width and endian-ness correct. */ - sfinfo.format = filetype = SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16 ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("Line %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < BUFFER_SIZE) - { printf ("Line %d: Incorrect number of.frames in file. (%d => %" PRId64 ")\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("Line %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - if ((k = (int) sf_read_short (file, buffer, BUFFER_SIZE)) != BUFFER_SIZE) - { printf ("Line %d: short read (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (k = 0 ; k < BUFFER_SIZE - 22 ; k++) - if (buffer [k + 22] != k) - { printf ("Line %d: Incorrect sample (#%d : 0x%x => 0x%x).\n", __LINE__, k, k, buffer [k]) ; - exit (1) ; - } ; - - sf_close (file) ; - - printf ("ok\n") ; - unlink (filename) ; -} /* old_test */ - diff --git a/Engine/lib/libsndfile/tests/largefile_test.c b/Engine/lib/libsndfile/tests/largefile_test.c deleted file mode 100644 index 4c97c90b2..000000000 --- a/Engine/lib/libsndfile/tests/largefile_test.c +++ /dev/null @@ -1,85 +0,0 @@ -/* -** Copyright (C) 2006-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_LEN (1024 * 1024) -#define BUFFER_COUNT (768) - -static void largefile_test (int filetype, const char * filename) ; - -int -main (void) -{ - largefile_test (SF_FORMAT_WAV, "largefile.wav") ; - largefile_test (SF_FORMAT_AIFF, "largefile.aiff") ; - - return 0 ; -} /* main */ - -static void -largefile_test (int filetype, const char * filename) -{ static float data [BUFFER_LEN] ; - SNDFILE *file ; - SF_INFO sfinfo ; - int k ; - - print_test_name ("largefile_test", filename) ; - - sfinfo.samplerate = 44100 ; - sfinfo.channels = 2 ; - sfinfo.frames = 0 ; - sfinfo.format = (filetype | SF_FORMAT_PCM_32) ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - for (k = 0 ; k < BUFFER_COUNT ; k++) - test_write_float_or_die (file, k, data, BUFFER_LEN, __LINE__) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if ((sfinfo.frames * sfinfo.channels) / BUFFER_LEN != BUFFER_COUNT) - { printf ("\n\nLine %d : bad frame count.\n", __LINE__) ; - exit (1) ; - } ; - - sf_close (file) ; - - unlink (filename) ; - puts ("ok") ; - - - return ; -} /* largefile_test */ - diff --git a/Engine/lib/libsndfile/tests/locale_test.c b/Engine/lib/libsndfile/tests/locale_test.c deleted file mode 100644 index 932c72efb..000000000 --- a/Engine/lib/libsndfile/tests/locale_test.c +++ /dev/null @@ -1,168 +0,0 @@ -/* -** Copyright (C) 2005-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#if HAVE_LOCALE_H -#include -#endif - -#if OS_IS_WIN32 -#include -#endif - -#include "sndfile.h" -#include "utils.h" - -static void utf8_test (void) ; -static void wchar_test (void) ; - -int -main (void) -{ - utf8_test () ; - wchar_test () ; - - return 0 ; -} /* main */ - -/*============================================================================== -*/ - -static void -wchar_test (void) -{ -#if OS_IS_WIN32 - SNDFILE * file ; - SF_INFO info ; - LPCWSTR filename = L"test.wav" ; - - print_test_name (__func__, "test.wav") ; - - info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ; - info.channels = 1 ; - info.samplerate = 44100 ; - - file = sf_wchar_open (filename, SFM_WRITE, &info) ; - exit_if_true (file == NULL, "\n\nLine %d : sf_wchar_open failed : %s\n\n", __LINE__, sf_strerror (NULL)) ; - sf_close (file) ; - - /* This should check that the file did in fact get created with a - ** wchar_t * filename. - */ - exit_if_true ( - GetFileAttributesW (filename) == INVALID_FILE_ATTRIBUTES, - "\n\nLine %d : GetFileAttributes failed.\n\n", __LINE__ - ) ; - - /* Use this because the file was created with CreateFileW. */ - DeleteFileW (filename) ; - - puts ("ok") ; -#endif -} /* wchar_test */ - -/*============================================================================== -*/ - -typedef struct -{ const char *locale ; - int utf8 ; - const char *filename ; - int width ; -} LOCALE_DATA ; - -static void locale_test (const LOCALE_DATA * locdata) ; - -static void -utf8_test (void) -{ LOCALE_DATA ldata [] = - { { "de_DE", 1, "F\303\274\303\237e.au", 7 }, - { "en_AU", 1, "kangaroo.au", 11 }, - { "POSIX", 0, "posix.au", 8 }, - { "pt_PT", 1, "concei\303\247\303\243o.au", 12 }, - -#if OS_IS_WIN32 == 0 - { "ja_JP", 1, "\343\201\212\343\201\257\343\202\210\343\201\206\343\201\224\343\201\226\343\201\204\343\201\276\343\201\231.au", 21 }, -#endif - - { "vi_VN", 1, "qu\341\273\221c ng\341\273\257.au", 11 }, - { NULL, 0, NULL, 0 } - } ; - int k ; - - for (k = 0 ; ldata [k].locale != NULL ; k++) - locale_test (ldata + k) ; -} /* utf8_test */ - - -static void -locale_test (const LOCALE_DATA * ldata) -{ -#if (HAVE_LOCALE_H == 0 || HAVE_SETLOCALE == 0) - locname = filename = NULL ; - width = 0 ; - return ; -#else - const short wdata [] = { 1, 2, 3, 4, 5, 6, 7, 8 } ; - short rdata [ARRAY_LEN (wdata)] ; - const char *old_locale ; - char utf8_locname [32] ; - SNDFILE *file ; - SF_INFO sfinfo ; - - snprintf (utf8_locname, sizeof (utf8_locname), "%s%s", ldata->locale, ldata->utf8 ? ".UTF-8" : "") ; - - /* Change the locale saving the old one. */ - if ((old_locale = setlocale (LC_CTYPE, utf8_locname)) == NULL) - return ; - - printf (" locale_test %-8s : %s %*c ", ldata->locale, ldata->filename, 24 - ldata->width, ' ') ; - fflush (stdout) ; - - sfinfo.format = SF_FORMAT_AU | SF_FORMAT_PCM_16 ; - sfinfo.channels = 1 ; - sfinfo.samplerate = 44100 ; - - file = test_open_file_or_die (ldata->filename, SFM_WRITE, &sfinfo, 0, __LINE__) ; - test_write_short_or_die (file, 0, wdata, ARRAY_LEN (wdata), __LINE__) ; - sf_close (file) ; - - file = test_open_file_or_die (ldata->filename, SFM_READ, &sfinfo, 0, __LINE__) ; - test_read_short_or_die (file, 0, rdata, ARRAY_LEN (rdata), __LINE__) ; - sf_close (file) ; - - unlink (ldata->filename) ; - - /* Restore old locale. */ - setlocale (LC_CTYPE, old_locale) ; - - puts ("ok") ; -#endif -} /* locale_test */ - diff --git a/Engine/lib/libsndfile/tests/long_read_write_test.c b/Engine/lib/libsndfile/tests/long_read_write_test.c deleted file mode 100644 index 0629caef1..000000000 --- a/Engine/lib/libsndfile/tests/long_read_write_test.c +++ /dev/null @@ -1,272 +0,0 @@ -/* -** Copyright (C) 2015-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "dft_cmp.h" -#include "utils.h" - -#define BUFFER_LENGTH 10000 -#define SAMPLE_RATE 44010 - -static void short_lrw_test (const char *filename, int filetype, const short * output, int out_len) ; -static void int_lrw_test (const char *filename, int filetype, const int * output, int out_len) ; -static void float_lrw_test (const char *filename, int filetype, const float * output, int out_len) ; -static void double_lrw_test (const char *filename, int filetype, const double * output, int out_len) ; - - -static short short_data [BUFFER_LENGTH] ; -static int int_data [BUFFER_LENGTH] ; -static float float_data [BUFFER_LENGTH] ; -static double double_data [BUFFER_LENGTH] ; - -int -main (int argc, char *argv []) -{ int do_all ; - size_t k ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" alac - test CAF/ALAC file functions\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - for (k = 0 ; k < ARRAY_LEN (short_data) ; k++) - { int value = k / 32 ; - int_data [k] = (value & 1 ? -1 : 1) * value ; - short_data [k] = int_data [k] ; - float_data [k] = int_data [k] / 32000.0f ; - double_data [k] = int_data [k] / 32000.0 ; - } - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || strcmp (argv [1], "alac") == 0) - { short_lrw_test ("alac.caf", SF_FORMAT_CAF | SF_FORMAT_ALAC_16, short_data, ARRAY_LEN (short_data)) ; - int_lrw_test ("alac.caf", SF_FORMAT_CAF | SF_FORMAT_ALAC_32, int_data, ARRAY_LEN (int_data)) ; - float_lrw_test ("alac.caf", SF_FORMAT_CAF | SF_FORMAT_ALAC_32, float_data, ARRAY_LEN (float_data)) ; - double_lrw_test ("alac.caf", SF_FORMAT_CAF | SF_FORMAT_ALAC_32, double_data, ARRAY_LEN (double_data)) ; - } ; - - return 0 ; -} /* main */ - -/*============================================================================================ - * Here are the test functions. - */ - -static void -short_lrw_test (const char *filename, int filetype, const short * output, int out_len) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k ; - short input [BUFFER_LENGTH] ; - - print_test_name ("short_lrw_test", filename) ; - - exit_if_true (BUFFER_LENGTH > out_len, "\n\nLine %d: Bad array length.\n", __LINE__) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = out_len ; - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - test_write_short_or_die (file, 0, output, out_len, __LINE__) ; - - sf_close (file) ; - - memset (input, 0, sizeof (input)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit_if_true (sfinfo.frames < out_len, "\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; - exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_short_or_die (file, 0, input, out_len, __LINE__) ; - - sf_close (file) ; - - for (k = 0 ; k < out_len ; k++) - exit_if_true (input [k] != output [k], - "\n\nLine: %d: Error on input %d, expected %d, got %d\n", __LINE__, k, output [k], input [k]) ; - - puts ("ok") ; - unlink (filename) ; - - return ; -} /* short_lrw_test */ - -static void -int_lrw_test (const char *filename, int filetype, const int * output, int out_len) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k ; - int input [BUFFER_LENGTH] ; - - print_test_name ("int_lrw_test", filename) ; - - exit_if_true (BUFFER_LENGTH > out_len, "\n\nLine %d: Bad array length.\n", __LINE__) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = out_len ; - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - test_write_int_or_die (file, 0, output, out_len, __LINE__) ; - - sf_close (file) ; - - memset (input, 0, sizeof (input)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit_if_true (sfinfo.frames < out_len, "\n\nLine %d: Incorrect number of frames in file (too int). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; - exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_int_or_die (file, 0, input, out_len, __LINE__) ; - - sf_close (file) ; - - for (k = 0 ; k < out_len ; k++) - exit_if_true (input [k] != output [k], - "\n\nLine: %d: Error on input %d, expected %d, got %d\n", __LINE__, k, output [k], input [k]) ; - - puts ("ok") ; - unlink (filename) ; - - return ; -} /* int_lrw_test */ - -static void -float_lrw_test (const char *filename, int filetype, const float * output, int out_len) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k ; - float input [BUFFER_LENGTH] ; - - print_test_name ("float_lrw_test", filename) ; - - exit_if_true (BUFFER_LENGTH > out_len, "\n\nLine %d: Bad array length.\n", __LINE__) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = out_len ; - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - test_write_float_or_die (file, 0, output, out_len, __LINE__) ; - - sf_close (file) ; - - memset (input, 0, sizeof (input)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit_if_true (sfinfo.frames < out_len, "\n\nLine %d: Incorrect number of frames in file (too float). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; - exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_float_or_die (file, 0, input, out_len, __LINE__) ; - - sf_close (file) ; - - for (k = 0 ; k < out_len ; k++) - exit_if_true (fabs (input [k] - output [k]) > 0.00001, - "\n\nLine: %d: Error on input %d, expected %f, got %f\n", __LINE__, k, output [k], input [k]) ; - - puts ("ok") ; - unlink (filename) ; - - return ; -} /* float_lrw_test */ - -static void -double_lrw_test (const char *filename, int filetype, const double * output, int out_len) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k ; - double input [BUFFER_LENGTH] ; - - print_test_name ("double_lrw_test", filename) ; - - exit_if_true (BUFFER_LENGTH > out_len, "\n\nLine %d: Bad array length.\n", __LINE__) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = out_len ; - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - test_write_double_or_die (file, 0, output, out_len, __LINE__) ; - - sf_close (file) ; - - memset (input, 0, sizeof (input)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit_if_true (sfinfo.frames < out_len, "\n\nLine %d: Incorrect number of frames in file (too double). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ; - exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_double_or_die (file, 0, input, out_len, __LINE__) ; - - sf_close (file) ; - - for (k = 0 ; k < out_len ; k++) - exit_if_true (fabs (input [k] - output [k]) > 0.00001, - "\n\nLine: %d: Error on input %d, expected %f, got %f\n", __LINE__, k, output [k], input [k]) ; - - puts ("ok") ; - unlink (filename) ; - - return ; -} /* double_lrw_test */ - diff --git a/Engine/lib/libsndfile/tests/lossy_comp_test.c b/Engine/lib/libsndfile/tests/lossy_comp_test.c deleted file mode 100644 index 928032135..000000000 --- a/Engine/lib/libsndfile/tests/lossy_comp_test.c +++ /dev/null @@ -1,2634 +0,0 @@ -/* -** Copyright (C) 1999-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_SIZE (1 << 14) -#define SAMPLE_RATE 11025 - -#ifndef M_PI -#define M_PI 3.14159265358979323846264338 -#endif - -#define LCT_MAX(x, y) ((x) > (y) ? (x) : (y)) - -static const char LCT_TEST_PREFIX[] = "lct" ; - -static void lcomp_test_short (const char *filename, int filetype, int chan, double margin) ; -static void lcomp_test_int (const char *filename, int filetype, int chan, double margin) ; -static void lcomp_test_float (const char *filename, int filetype, int chan, double margin) ; -static void lcomp_test_double (const char *filename, int filetype, int chan, double margin) ; - -static void sdlcomp_test_short (const char *filename, int filetype, int chan, double margin) ; -static void sdlcomp_test_int (const char *filename, int filetype, int chan, double margin) ; -static void sdlcomp_test_float (const char *filename, int filetype, int chan, double margin) ; -static void sdlcomp_test_double (const char *filename, int filetype, int chan, double margin) ; - -static void read_raw_test (const char *filename, int filetype, int chan) ; - -static int error_function (double data, double orig, double margin) ; -static int decay_response (int k) ; - -static void gen_signal_double (double *data, double scale, int channels, int datalen) ; - -static void smoothed_diff_short (short *data, unsigned int datalen) ; -static void smoothed_diff_int (int *data, unsigned int datalen) ; -static void smoothed_diff_float (float *data, unsigned int datalen) ; -static void smoothed_diff_double (double *data, unsigned int datalen) ; - -static void check_comment (SNDFILE * file, int format, int lineno) ; - -static int is_lossy (int filetype) ; - -static int check_opus_version (SNDFILE *file) ; - -/* -** Force the start of these buffers to be double aligned. Sparc-solaris will -** choke if they are not. -*/ -typedef union -{ double d [BUFFER_SIZE + 1] ; - float f [BUFFER_SIZE + 1] ; - int i [BUFFER_SIZE + 1] ; - short s [BUFFER_SIZE + 1] ; - char c [BUFFER_SIZE + 1] ; -} BUFFER ; - -static BUFFER data_buffer ; -static BUFFER orig_buffer ; -static BUFFER smooth_buffer ; - -static const char *long_comment = - "This is really quite a long comment. It is designed to be long enough " - "to screw up the encoders and decoders if the file container format does " - "not handle things correctly. If everything is working correctly, the " - "decoder will only decode the actual audio data, and not this string at " - "the end of the file." ; - -int -main (int argc, char *argv []) -{ int do_all = 0 ; - int test_count = 0 ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" wav_ima - test IMA ADPCM WAV file functions\n") ; - printf (" wav_msadpcm - test MS ADPCM WAV file functions\n") ; - printf (" wav_gsm610 - test GSM 6.10 WAV file functions\n") ; - printf (" wav_ulaw - test u-law WAV file functions\n") ; - printf (" wav_alaw - test A-law WAV file functions\n") ; - printf (" wve - test Psion WVE file functions\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || strcmp (argv [1], "wav_pcm") == 0) - { /* This is just a sanity test for PCM encoding. */ - lcomp_test_short ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 1e-50) ; - lcomp_test_int ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_32, 2, 1e-50) ; - lcomp_test_short ("pcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 1e-50) ; - lcomp_test_int ("pcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_32, 2, 1e-50) ; - /* Lite remove start */ - lcomp_test_float ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_FLOAT, 2, 1e-50) ; - lcomp_test_double ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_DOUBLE, 2, 1e-50) ; - /* Lite remove end */ - - read_raw_test ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8, 2) ; - test_count++ ; - } ; - - /* For all the rest, if the file format supports more than 1 channel, use stereo. */ - /* Lite remove start */ - if (do_all || strcmp (argv [1], "wav_ima") == 0) - { lcomp_test_short ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_int ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.65) ; - lcomp_test_float ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_double ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - - lcomp_test_short ("ima.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_int ("ima.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_float ("ima.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_double ("ima.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - - sdlcomp_test_short ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - sdlcomp_test_int ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - sdlcomp_test_float ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - sdlcomp_test_double ("ima.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "wav_msadpcm") == 0) - { lcomp_test_short ("msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - lcomp_test_int ("msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - lcomp_test_float ("msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - lcomp_test_double ("msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - - lcomp_test_short ("msadpcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - lcomp_test_int ("msadpcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - lcomp_test_float ("msadpcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - lcomp_test_double ("msadpcm.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - - sdlcomp_test_short ("msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - sdlcomp_test_int ("msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - sdlcomp_test_float ("msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - sdlcomp_test_double ("msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "wav_g721") == 0) - { printf ("**** Fix this later : error bound should be 0.06 ****\n") ; - lcomp_test_short ("g721.wav", SF_FORMAT_WAV | SF_FORMAT_G721_32, 1, 0.7) ; - lcomp_test_int ("g721.wav", SF_FORMAT_WAV | SF_FORMAT_G721_32, 1, 0.7) ; - - lcomp_test_short ("g721.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_G721_32, 1, 0.7) ; - lcomp_test_int ("g721.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_G721_32, 1, 0.7) ; - - test_count++ ; - } ; - /* Lite remove end */ - - if (do_all || strcmp (argv [1], "wav_ulaw") == 0) - { lcomp_test_short ("ulaw.wav", SF_FORMAT_WAV | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.wav", SF_FORMAT_WAV | SF_FORMAT_ULAW, 2, 0.04) ; - - lcomp_test_short ("ulaw.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_ULAW, 2, 0.04) ; - - /* Lite remove start */ - lcomp_test_float ("ulaw.wav", SF_FORMAT_WAV | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_double ("ulaw.wav", SF_FORMAT_WAV | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove end */ - - read_raw_test ("ulaw.wav", SF_FORMAT_WAV | SF_FORMAT_ULAW, 2) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "wav_alaw") == 0) - { lcomp_test_short ("alaw.wav", SF_FORMAT_WAV | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_int ("alaw.wav", SF_FORMAT_WAV | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("alaw.wav", SF_FORMAT_WAV | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_double ("alaw.wav", SF_FORMAT_WAV | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove end */ - - read_raw_test ("alaw.wav", SF_FORMAT_WAV | SF_FORMAT_ALAW, 2) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "wav_gsm610") == 0) - { /* Don't do lcomp_test_XXX as the errors are too big. */ - sdlcomp_test_short ("gsm610.wav", SF_FORMAT_WAV | SF_FORMAT_GSM610, 1, 0.24) ; - sdlcomp_test_int ("gsm610.wav", SF_FORMAT_WAV | SF_FORMAT_GSM610, 1, 0.24) ; - - sdlcomp_test_short ("gsm610.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_GSM610, 1, 0.24) ; - sdlcomp_test_int ("gsm610.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_GSM610, 1, 0.24) ; - - /* Lite remove start */ - sdlcomp_test_float ("gsm610.wav", SF_FORMAT_WAV | SF_FORMAT_GSM610, 1, 0.24) ; - sdlcomp_test_double ("gsm610.wav", SF_FORMAT_WAV | SF_FORMAT_GSM610, 1, 0.24) ; - /* Lite remove end */ - test_count++ ; - } ; - - /* Lite remove start */ - if (do_all || strcmp (argv [1], "wav_nmsadpcm") == 0) - { lcomp_test_short ("nms_16.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_16, 1, 0.37) ; - lcomp_test_int ("nms_16.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_16, 1, 0.31) ; - lcomp_test_float ("nms_16.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_16, 1, 0.34) ; - lcomp_test_double ("nms_16.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_16, 1, 0.34) ; - - lcomp_test_short ("nms_24.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_24, 1, 0.15) ; - lcomp_test_int ("nms_24.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_24, 1, 0.10) ; - lcomp_test_float ("nms_24.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_24, 1, 0.14) ; - lcomp_test_double ("nms_24.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_24, 1, 0.14) ; - - lcomp_test_short ("nms_32.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_32, 1, 0.036) ; - lcomp_test_int ("nms_32.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_32, 1, 0.045) ; - lcomp_test_float ("nms_32.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_32, 1, 0.035) ; - lcomp_test_double ("nms_32.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_32, 1, 0.035) ; - - sdlcomp_test_short ("nms_16.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_16, 1, 0.16) ; - sdlcomp_test_int ("nms_16.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_16, 1, 0.16) ; - sdlcomp_test_float ("nms_16.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_16, 1, 0.16) ; - sdlcomp_test_double ("nms_16.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_16, 1, 0.16) ; - - sdlcomp_test_short ("nms_24.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_24, 1, 0.06) ; - sdlcomp_test_int ("nms_24.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_24, 1, 0.06) ; - sdlcomp_test_float ("nms_24.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_24, 1, 0.06) ; - sdlcomp_test_double ("nms_24.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_24, 1, 0.06) ; - - sdlcomp_test_short ("nms_32.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_32, 1, 0.017) ; - sdlcomp_test_int ("nms_32.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_32, 1, 0.018) ; - sdlcomp_test_float ("nms_32.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_32, 1, 0.018) ; - sdlcomp_test_double ("nms_32.wav", SF_FORMAT_WAV | SF_FORMAT_NMS_ADPCM_32, 1, 0.018) ; - - test_count++ ; - } ; - /* Lite remove end */ - - if (do_all || strcmp (argv [1], "aiff_ulaw") == 0) - { lcomp_test_short ("ulaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("ulaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_double ("ulaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove end */ - - read_raw_test ("ulaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ULAW, 2) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "aiff_alaw") == 0) - { lcomp_test_short ("alaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_int ("alaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("alaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_double ("alaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove end */ - - read_raw_test ("alaw.aiff", SF_FORMAT_AIFF | SF_FORMAT_ALAW, 2) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "aiff_gsm610") == 0) - { /* Don't do lcomp_test_XXX as the errors are too big. */ - sdlcomp_test_short ("gsm610.aiff", SF_FORMAT_AIFF | SF_FORMAT_GSM610, 1, 0.24) ; - sdlcomp_test_int ("gsm610.aiff", SF_FORMAT_AIFF | SF_FORMAT_GSM610, 1, 0.24) ; - /* Lite remove start */ - sdlcomp_test_float ("gsm610.aiff", SF_FORMAT_AIFF | SF_FORMAT_GSM610, 1, 0.24) ; - sdlcomp_test_double ("gsm610.aiff", SF_FORMAT_AIFF | SF_FORMAT_GSM610, 1, 0.24) ; - /* Lite remove end */ - test_count++ ; - } ; - - if (strcmp (argv [1], "aiff_ima") == 0) - { lcomp_test_short ("ima.aiff", SF_FORMAT_AIFF | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_int ("ima.aiff", SF_FORMAT_AIFF | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - /* Lite remove start */ - lcomp_test_float ("ima.aiff", SF_FORMAT_AIFF | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_double ("ima.aiff", SF_FORMAT_AIFF | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - /* Lite remove end */ - } ; - - if (do_all || strcmp (argv [1], "au_ulaw") == 0) - { lcomp_test_short ("ulaw.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("ulaw.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_double ("ulaw.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove end */ - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "au_alaw") == 0) - { lcomp_test_short ("alaw.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_int ("alaw.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("alaw.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_double ("alaw.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove end */ - test_count++ ; - } ; - - /* Lite remove start */ - if (do_all || strcmp (argv [1], "au_g721") == 0) - { printf ("**** Fix this later : error bound should be 0.06 ****\n") ; - lcomp_test_short ("g721.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G721_32, 1, 0.7) ; - lcomp_test_int ("g721.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G721_32, 1, 0.7) ; - lcomp_test_float ("g721.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G721_32, 1, 0.7) ; - lcomp_test_double ("g721.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G721_32, 1, 0.7) ; - -/*- sdlcomp_test_short ("g721.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G721_32, 1, 0.07) ; - sdlcomp_test_int ("g721.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G721_32, 1, 0.07) ; - sdlcomp_test_float ("g721.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G721_32, 1, 0.07) ; - sdlcomp_test_double ("g721.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G721_32, 1, 0.12) ; --*/ - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "au_g723") == 0) - { printf ("**** Fix this later : error bound should be 0.16 ****\n") ; - lcomp_test_short ("g723_24.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.7) ; - lcomp_test_int ("g723_24.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.7) ; - lcomp_test_float ("g723_24.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.7) ; - lcomp_test_double ("g723_24.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.7) ; - - lcomp_test_short ("g723_40.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.85) ; - lcomp_test_int ("g723_40.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.84) ; - lcomp_test_float ("g723_40.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.86) ; - lcomp_test_double ("g723_40.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_40, 1, 0.86) ; - -/*- sdlcomp_test_short ("g723.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.15) ; - sdlcomp_test_int ("g723.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.15) ; - sdlcomp_test_float ("g723.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.15) ; - sdlcomp_test_double ("g723.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_G723_24, 1, 0.15) ; --*/ - test_count++ ; - } ; - /* Lite remove end */ - - if (do_all || strcmp (argv [1], "caf_ulaw") == 0) - { lcomp_test_short ("ulaw.caf", SF_FORMAT_CAF | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.caf", SF_FORMAT_CAF | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("ulaw.caf", SF_FORMAT_CAF | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_double ("ulaw.caf", SF_FORMAT_CAF | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove end */ - - read_raw_test ("ulaw.caf", SF_FORMAT_CAF | SF_FORMAT_ULAW, 2) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "caf_alaw") == 0) - { lcomp_test_short ("alaw.caf", SF_FORMAT_CAF | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_int ("alaw.caf", SF_FORMAT_CAF | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("alaw.caf", SF_FORMAT_CAF | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_double ("alaw.caf", SF_FORMAT_CAF | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove end */ - - read_raw_test ("alaw.caf", SF_FORMAT_CAF | SF_FORMAT_ALAW, 2) ; - test_count++ ; - } ; - - - if (do_all || strcmp (argv [1], "raw_ulaw") == 0) - { lcomp_test_short ("ulaw.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("ulaw.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_double ("ulaw.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove end */ - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "raw_alaw") == 0) - { lcomp_test_short ("alaw.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_int ("alaw.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("alaw.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_double ("alaw.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove end */ - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "raw_gsm610") == 0) - { /* Don't do lcomp_test_XXX as the errors are too big. */ - sdlcomp_test_short ("raw.gsm", SF_FORMAT_RAW | SF_FORMAT_GSM610, 1, 0.24) ; - sdlcomp_test_int ("raw.gsm", SF_FORMAT_RAW | SF_FORMAT_GSM610, 1, 0.24) ; - sdlcomp_test_float ("raw.gsm", SF_FORMAT_RAW | SF_FORMAT_GSM610, 1, 0.24) ; - sdlcomp_test_double ("raw.gsm", SF_FORMAT_RAW | SF_FORMAT_GSM610, 1, 0.24) ; - test_count++ ; - } ; - - /* Lite remove start */ - if (do_all || strcmp (argv [1], "raw_nmsadpcm") == 0) - { lcomp_test_short ("raw.vce16", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_16, 1, 0.37) ; - lcomp_test_int ("raw.vce16", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_16, 1, 0.31) ; - lcomp_test_float ("raw.vce16", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_16, 1, 0.34) ; - lcomp_test_double ("raw.vce16", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_16, 1, 0.34) ; - - lcomp_test_short ("raw.vce24", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_24, 1, 0.15) ; - lcomp_test_int ("raw.vce24", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_24, 1, 0.10) ; - lcomp_test_float ("raw.vce24", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_24, 1, 0.14) ; - lcomp_test_double ("raw.vce24", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_24, 1, 0.14) ; - - lcomp_test_short ("raw.vce32", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_32, 1, 0.036) ; - lcomp_test_int ("raw.vce32", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_32, 1, 0.045) ; - lcomp_test_float ("raw.vce32", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_32, 1, 0.035) ; - lcomp_test_double ("raw.vce32", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_32, 1, 0.035) ; - - sdlcomp_test_short ("raw.vce16", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_16, 1, 0.16) ; - sdlcomp_test_int ("raw.vce16", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_16, 1, 0.16) ; - sdlcomp_test_float ("raw.vce16", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_16, 1, 0.16) ; - sdlcomp_test_double ("raw.vce16", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_16, 1, 0.16) ; - - sdlcomp_test_short ("raw.vce24", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_24, 1, 0.06) ; - sdlcomp_test_int ("raw.vce24", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_24, 1, 0.06) ; - sdlcomp_test_float ("raw.vce24", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_24, 1, 0.06) ; - sdlcomp_test_double ("raw.vce24", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_24, 1, 0.06) ; - - sdlcomp_test_short ("raw.vce32", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_32, 1, 0.017) ; - sdlcomp_test_int ("raw.vce32", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_32, 1, 0.018) ; - sdlcomp_test_float ("raw.vce32", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_32, 1, 0.018) ; - sdlcomp_test_double ("raw.vce32", SF_FORMAT_RAW | SF_FORMAT_NMS_ADPCM_32, 1, 0.018) ; - - test_count++ ; - } ; - /* Lite remove end */ - - if (do_all || strcmp (argv [1], "ogg_vorbis") == 0) - { if (HAVE_EXTERNAL_XIPH_LIBS) - { /* Don't do lcomp_test_XXX as the errors are too big. */ - sdlcomp_test_short ("vorbis.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS, 1, 0.30) ; - sdlcomp_test_int ("vorbis.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS, 1, 0.30) ; - sdlcomp_test_float ("vorbis.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS, 1, 0.30) ; - sdlcomp_test_double ("vorbis.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS, 1, 0.30) ; - } - else - puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ; - - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "ogg_opus") == 0) - { if (HAVE_EXTERNAL_XIPH_LIBS) - { /* Don't do lcomp_test_XXX as the errors are too big. */ - sdlcomp_test_short ("opus.opus", SF_FORMAT_OGG | SF_FORMAT_OPUS, 1, 0.57) ; - sdlcomp_test_int ("opus.opus", SF_FORMAT_OGG | SF_FORMAT_OPUS, 1, 0.54) ; - sdlcomp_test_float ("opus.opus", SF_FORMAT_OGG | SF_FORMAT_OPUS, 1, 0.55) ; - sdlcomp_test_double ("opus.opus", SF_FORMAT_OGG | SF_FORMAT_OPUS, 1, 0.55) ; - } - else - puts (" No Ogg/Opus tests because Ogg/Opus support was not compiled in.") ; - - test_count++ ; - } ; - - /* Lite remove start */ - if (do_all || strcmp (argv [1], "ircam_ulaw") == 0) - { lcomp_test_short ("ulaw.ircam", SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.ircam", SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_float ("ulaw.ircam", SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_double ("ulaw.ircam", SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_ULAW, 2, 0.04) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "ircam_alaw") == 0) - { lcomp_test_short ("alaw.ircam", SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_int ("alaw.ircam", SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_float ("alaw.ircam", SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_double ("alaw.ircam", SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_ALAW, 2, 0.04) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "nist_ulaw") == 0) - { lcomp_test_short ("ulaw.nist", SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.nist", SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_float ("ulaw.nist", SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_double ("ulaw.nist", SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_ULAW, 2, 0.04) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "nist_alaw") == 0) - { lcomp_test_short ("alaw.nist", SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_int ("alaw.nist", SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_float ("alaw.nist", SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_double ("alaw.nist", SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_ALAW, 2, 0.04) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "voc_ulaw") == 0) - { lcomp_test_short ("ulaw.voc", SF_FORMAT_VOC | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.voc", SF_FORMAT_VOC | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_float ("ulaw.voc", SF_FORMAT_VOC | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_double ("ulaw.voc", SF_FORMAT_VOC | SF_FORMAT_ULAW, 2, 0.04) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "voc_alaw") == 0) - { lcomp_test_short ("alaw.voc", SF_FORMAT_VOC | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_int ("alaw.voc", SF_FORMAT_VOC | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_float ("alaw.voc", SF_FORMAT_VOC | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_double ("alaw.voc", SF_FORMAT_VOC | SF_FORMAT_ALAW, 2, 0.04) ; - test_count++ ; - } ; - /* Lite remove end */ - - if (do_all || strcmp (argv [1], "w64_ulaw") == 0) - { lcomp_test_short ("ulaw.w64", SF_FORMAT_W64 | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_int ("ulaw.w64", SF_FORMAT_W64 | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("ulaw.w64", SF_FORMAT_W64 | SF_FORMAT_ULAW, 2, 0.04) ; - lcomp_test_double ("ulaw.w64", SF_FORMAT_W64 | SF_FORMAT_ULAW, 2, 0.04) ; - /* Lite remove end */ - - read_raw_test ("ulaw.w64", SF_FORMAT_W64 | SF_FORMAT_ULAW, 2) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "w64_alaw") == 0) - { lcomp_test_short ("alaw.w64", SF_FORMAT_W64 | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_int ("alaw.w64", SF_FORMAT_W64 | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("alaw.w64", SF_FORMAT_W64 | SF_FORMAT_ALAW, 2, 0.04) ; - lcomp_test_double ("alaw.w64", SF_FORMAT_W64 | SF_FORMAT_ALAW, 2, 0.04) ; - /* Lite remove end */ - - read_raw_test ("alaw.w64", SF_FORMAT_W64 | SF_FORMAT_ALAW, 2) ; - test_count++ ; - } ; - - /* Lite remove start */ - if (do_all || strcmp (argv [1], "w64_ima") == 0) - { lcomp_test_short ("ima.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_int ("ima.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_float ("ima.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - lcomp_test_double ("ima.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - - sdlcomp_test_short ("ima.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - sdlcomp_test_int ("ima.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - sdlcomp_test_float ("ima.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - sdlcomp_test_double ("ima.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM, 2, 0.18) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "w64_msadpcm") == 0) - { lcomp_test_short ("msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - lcomp_test_int ("msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - lcomp_test_float ("msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - lcomp_test_double ("msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - - sdlcomp_test_short ("msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - sdlcomp_test_int ("msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - sdlcomp_test_float ("msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - sdlcomp_test_double ("msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM, 2, 0.36) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "wve") == 0) - { lcomp_test_short ("psion.wve", SF_FORMAT_WVE | SF_FORMAT_ALAW, 1, 0.04) ; - lcomp_test_int ("psion.wve", SF_FORMAT_WVE | SF_FORMAT_ALAW, 1, 0.04) ; - /* Lite remove start */ - lcomp_test_float ("psion.wve", SF_FORMAT_WVE | SF_FORMAT_ALAW, 1, 0.04) ; - lcomp_test_double ("psion.wve", SF_FORMAT_WVE | SF_FORMAT_ALAW, 1, 0.04) ; - /* Lite remove end */ - test_count++ ; - } ; - - /* Lite remove end */ - - if (do_all || strcmp (argv [1], "w64_gsm610") == 0) - { /* Don't do lcomp_test_XXX as the errors are too big. */ - sdlcomp_test_short ("gsm610.w64", SF_FORMAT_W64 | SF_FORMAT_GSM610, 1, 0.2) ; - sdlcomp_test_int ("gsm610.w64", SF_FORMAT_W64 | SF_FORMAT_GSM610, 1, 0.2) ; - /* Lite remove start */ - sdlcomp_test_float ("gsm610.w64", SF_FORMAT_W64 | SF_FORMAT_GSM610, 1, 0.2) ; - sdlcomp_test_double ("gsm610.w64", SF_FORMAT_W64 | SF_FORMAT_GSM610, 1, 0.2) ; - /* Lite remove end */ - test_count++ ; - } ; - - /* Lite remove start */ - if (do_all || strcmp (argv [1], "vox_adpcm") == 0) - { lcomp_test_short ("adpcm.vox", SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, 1, 0.17) ; - lcomp_test_int ("adpcm.vox", SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, 1, 0.17) ; - lcomp_test_float ("adpcm.vox", SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, 1, 0.17) ; - lcomp_test_double ("adpcm.vox", SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, 1, 0.17) ; - - sdlcomp_test_short ("adpcm.vox", SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, 1, 0.072) ; - sdlcomp_test_int ("adpcm.vox", SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, 1, 0.072) ; - sdlcomp_test_float ("adpcm.vox", SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, 1, 0.072) ; - sdlcomp_test_double ("adpcm.vox", SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, 1, 0.072) ; - test_count++ ; - } ; - - if (do_all || strcmp (argv [1], "xi_dpcm") == 0) - { lcomp_test_short ("8bit.xi", SF_FORMAT_XI | SF_FORMAT_DPCM_8, 1, 0.25) ; - lcomp_test_int ("8bit.xi", SF_FORMAT_XI | SF_FORMAT_DPCM_8, 1, 0.25) ; - - lcomp_test_short ("16bit.xi", SF_FORMAT_XI | SF_FORMAT_DPCM_16, 1, 0.002) ; - lcomp_test_int ("16bit.xi", SF_FORMAT_XI | SF_FORMAT_DPCM_16, 1, 0.002) ; - lcomp_test_float ("16bit.xi", SF_FORMAT_XI | SF_FORMAT_DPCM_16, 1, 0.002) ; - lcomp_test_double ("16bit.xi", SF_FORMAT_XI | SF_FORMAT_DPCM_16, 1, 0.002) ; - test_count++ ; - } ; - /* Lite remove end */ - - if (test_count == 0) - { printf ("************************************\n") ; - printf ("* No '%s' test defined.\n", argv [1]) ; - printf ("************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -lcomp_test_short (const char *filename, int filetype, int channels, double margin) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, m, seekpos, half_max_abs ; - sf_count_t datalen ; - short *orig, *data ; - - get_unique_test_name (&filename, LCT_TEST_PREFIX) ; - print_test_name ("lcomp_test_short", filename) ; - - datalen = BUFFER_SIZE / channels ; - - data = data_buffer.s ; - orig = orig_buffer.s ; - - gen_signal_double (orig_buffer.d, 32000.0, channels, (int) datalen) ; - for (k = 0 ; k < channels * datalen ; k++) - orig [k] = (short) (orig_buffer.d [k]) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = channels ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_writef_short_or_die (file, 0, orig, datalen, __LINE__) ; - sf_set_string (file, SF_STR_COMMENT, long_comment) ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (short)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - if ((sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)) != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen / channels) - { printf ("Too few frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + datalen / 20)) - { printf ("Too many frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - check_comment (file, filetype, __LINE__) ; - - test_readf_short_or_die (file, 0, data, datalen, __LINE__) ; - - half_max_abs = 0 ; - for (k = 0 ; k < datalen ; k++) - { if (error_function (data [k], orig [k], margin)) - { printf ("\n\nLine %d: Incorrect sample A (#%d : %d should be %d).\n", __LINE__, k, data [k], orig [k]) ; - oct_save_short (orig, data, (int) datalen) ; - exit (1) ; - } ; - half_max_abs = LCT_MAX (half_max_abs, abs (data [k] / 2)) ; - } ; - - if (half_max_abs < 1.0) - { printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ; - exit (1) ; - } ; - - if ((k = (int) sf_readf_short (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, - channels * sfinfo.frames - datalen, k) ; - exit (1) ; - } ; - - /* This check is only for block based encoders which must append silence - ** to the end of a file so as to fill out a block. - */ - for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (abs (data [channels * k]) > decay_response (channels * k)) - { printf ("\n\nLine %d : Incorrect sample B (#%d : abs (%d) should be < %d).\n", __LINE__, channels * k, data [channels * k], decay_response (channels * k)) ; - exit (1) ; - } ; - - if (! sfinfo.seekable) - { sf_close (file) ; - unlink (filename) ; - printf ("ok\n") ; - return ; - } ; - - /* Now test sf_seek function. */ - - if ((k = (int) sf_seek (file, 0, SEEK_SET)) != 0) - { printf ("\n\nLine %d: Seek to start of file failed (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (m = 0 ; m < 3 ; m++) - { test_readf_short_or_die (file, m, data, 11, __LINE__) ; - - for (k = 0 ; k < channels * 11 ; k++) - if (error_function (1.0 * data [k], 1.0 * orig [k + channels * m * 11], margin)) - { printf ("\n\nLine %d: Incorrect sample (m = %d) (#%d : %d => %d).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ; - for (m = 0 ; m < channels ; m++) - printf ("%d ", data [m]) ; - printf ("\n") ; - exit (1) ; - } ; - } ; - - seekpos = BUFFER_SIZE / 10 ; - - /* Check seek from start of file. */ - if ((k = (int) sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ; - exit (1) ; - } ; - - test_readf_short_or_die (file, 0, data, 1, __LINE__) ; - - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin)) - { printf ("\n\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_short failed (%d, %d).\n", __LINE__, orig [1], data [0]) ; - exit (1) ; - } ; - - if ((k = (int) sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ; - k = (int) sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; - test_readf_short_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\n\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_short failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ; - oct_save_short (orig, data, (int) datalen) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) - 20 ; - /* Check seek backward from current position. */ - k = (int) sf_seek (file, -20, SEEK_CUR) ; - test_readf_short_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_short failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ; - exit (1) ; - } ; - - /* Check that read past end of file returns number of items. */ - sf_seek (file, sfinfo.frames, SEEK_SET) ; - - if ((k = (int) sf_readf_short (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_readf_short past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - /* Check seek backward from end. */ - if ((k = (int) sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5) - { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ; - exit (1) ; - } ; - - test_readf_short_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [5 * channels], margin)) - { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%d should be %d).\n", __LINE__, data [0], orig [5 * channels]) ; - exit (1) ; - } ; - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* lcomp_test_short */ - -/*-------------------------------------------------------------------------------------------- -*/ - -static void -lcomp_test_int (const char *filename, int filetype, int channels, double margin) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, m, half_max_abs ; - sf_count_t datalen, seekpos ; - double scale, max_val ; - int *orig, *data ; - - get_unique_test_name (&filename, LCT_TEST_PREFIX) ; - print_test_name ("lcomp_test_int", filename) ; - - datalen = BUFFER_SIZE / channels ; - - if (is_lossy (filetype)) - { scale = 1.0 * 0x10000 ; - max_val = 32000.0 * scale ; - } - else - { scale = 1.0 ; - max_val = 0x7fffffff * scale ; - } ; - - data = data_buffer.i ; - orig = orig_buffer.i ; - - gen_signal_double (orig_buffer.d, max_val, channels, (int) datalen) ; - - for (k = 0 ; k < channels * datalen ; k++) - orig [k] = lrint (orig_buffer.d [k]) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = channels ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_writef_int_or_die (file, 0, orig, datalen, __LINE__) ; - sf_set_string (file, SF_STR_COMMENT, long_comment) ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (int)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - if ((sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)) != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + datalen / 20)) - { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - check_comment (file, filetype, __LINE__) ; - - test_readf_int_or_die (file, 0, data, datalen, __LINE__) ; - - half_max_abs = 0 ; - for (k = 0 ; k < datalen ; k++) - { if (error_function (data [k] / scale, orig [k] / scale, margin)) - { printf ("\nLine %d: Incorrect sample (#%d : %f should be %f).\n", __LINE__, k, data [k] / scale, orig [k] / scale) ; - oct_save_int (orig, data, (int) datalen) ; - exit (1) ; - } ; - half_max_abs = LCT_MAX (half_max_abs, abs (data [k] / 2)) ; - } ; - - if (half_max_abs < 1.0) - { printf ("\n\nLine %d: Signal is all zeros (%d, 0x%X).\n", __LINE__, half_max_abs, half_max_abs) ; - exit (1) ; - } ; - - if ((k = (int) sf_readf_int (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, - channels * sfinfo.frames - datalen, k) ; - exit (1) ; - } ; - - /* This check is only for block based encoders which must append silence - ** to the end of a file so as to fill out a block. - */ - if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM) - for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (ABS (data [channels * k] / scale) > decay_response (channels * k)) - { printf ("\n\nLine %d : Incorrect sample B (#%d : abs (%d) should be < %d).\n", __LINE__, channels * k, data [channels * k], decay_response (channels * k)) ; - exit (1) ; - } ; - - if (! sfinfo.seekable) - { sf_close (file) ; - unlink (filename) ; - printf ("ok\n") ; - return ; - } ; - - /* Now test sf_seek function. */ - - if ((k = (int) sf_seek (file, 0, SEEK_SET)) != 0) - { printf ("\n\nLine %d: Seek to start of file failed (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (m = 0 ; m < 3 ; m++) - { test_readf_int_or_die (file, m, data, 11, __LINE__) ; - - for (k = 0 ; k < channels * 11 ; k++) - if (error_function (data [k] / scale, orig [k + channels * m * 11] / scale, margin)) - { printf ("\nLine %d: Incorrect sample (m = %d) (#%d : %d => %d).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ; - for (m = 0 ; m < channels ; m++) - printf ("%d ", data [m]) ; - printf ("\n") ; - exit (1) ; - } ; - } ; - - seekpos = BUFFER_SIZE / 10 ; - - /* Check seek from start of file. */ - if ((k = (int) sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %" PRId64 " failed (%d).\n", seekpos, k) ; - exit (1) ; - } ; - - test_readf_int_or_die (file, 0, data, 1, __LINE__) ; - - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin)) - { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_int failed (%d, %d).\n", __LINE__, orig [1], data [0]) ; - exit (1) ; - } ; - - if ((k = (int) sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %" PRId64 ")\n", __LINE__, k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ; - k = (int) sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; - test_readf_int_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %" PRId64 ").\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ; - /* Check seek backward from current position. */ - k = (int) sf_seek (file, -20, SEEK_CUR) ; - test_readf_int_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %" PRId64 ").\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ; - exit (1) ; - } ; - - /* Check that read past end of file returns number of items. */ - sf_seek (file, sfinfo.frames, SEEK_SET) ; - - if ((k = (int) sf_readf_int (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_readf_int past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - /* Check seek backward from end. */ - if ((k = (int) sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5) - { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ; - exit (1) ; - } ; - - test_readf_int_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (data [0] / scale, orig [5 * channels] / scale, margin)) - { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%d should be %d).\n", __LINE__, data [0], orig [5]) ; - exit (1) ; - } ; - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* lcomp_test_int */ - -/*-------------------------------------------------------------------------------------------- -*/ - -static void -lcomp_test_float (const char *filename, int filetype, int channels, double margin) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, m, seekpos ; - sf_count_t datalen ; - float *orig, *data ; - double half_max_abs ; - - get_unique_test_name (&filename, LCT_TEST_PREFIX) ; - print_test_name ("lcomp_test_float", filename) ; - - datalen = BUFFER_SIZE / channels ; - - data = data_buffer.f ; - orig = orig_buffer.f ; - - gen_signal_double (orig_buffer.d, 32000.0, channels, (int) datalen) ; - for (k = 0 ; k < channels * datalen ; k++) - orig [k] = (float) orig_buffer.d [k] ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = channels ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - test_writef_float_or_die (file, 0, orig, datalen, __LINE__) ; - sf_set_string (file, SF_STR_COMMENT, long_comment) ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (float)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - if ((sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)) != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + datalen / 20)) - { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_comment (file, filetype, __LINE__) ; - - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - - check_log_buffer_or_die (file, __LINE__) ; - - check_comment (file, filetype, __LINE__) ; - - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - - test_readf_float_or_die (file, 0, data, datalen, __LINE__) ; - - half_max_abs = 0.0 ; - for (k = 0 ; k < datalen ; k++) - { if (error_function (data [k], orig [k], margin)) - { printf ("\nLine %d: Incorrect sample A (#%d : %f should be %f).\n", __LINE__, k, data [k], orig [k]) ; - oct_save_float (orig, data, (int) datalen) ; - exit (1) ; - } ; - half_max_abs = LCT_MAX (half_max_abs, fabs (0.5 * data [k])) ; - } ; - - if (half_max_abs < 1.0) - { printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ; - exit (1) ; - } ; - - if ((k = (int) sf_readf_float (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, - channels * sfinfo.frames - datalen, k) ; - exit (1) ; - } ; - - /* This check is only for block based encoders which must append silence - ** to the end of a file so as to fill out a block. - */ - if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM) - for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (ABS (data [channels * k]) > decay_response (channels * k)) - { printf ("\n\nLine %d : Incorrect sample B (#%d : abs (%f) should be < %d).\n", __LINE__, channels * k, data [channels * k], decay_response (channels * k)) ; - exit (1) ; - } ; - - if (! sfinfo.seekable) - { sf_close (file) ; - unlink (filename) ; - printf ("ok\n") ; - return ; - } ; - - /* Now test sf_seek function. */ - - if ((k = (int) sf_seek (file, 0, SEEK_SET)) != 0) - { printf ("\n\nLine %d: Seek to start of file failed (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (m = 0 ; m < 3 ; m++) - { test_readf_float_or_die (file, 0, data, 11, __LINE__) ; - - for (k = 0 ; k < channels * 11 ; k++) - if (error_function (data [k], orig [k + channels * m * 11], margin)) - { printf ("\nLine %d: Incorrect sample (m = %d) (#%d : %f => %f).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ; - for (m = 0 ; m < channels ; m++) - printf ("%f ", data [m]) ; - printf ("\n") ; - exit (1) ; - } ; - } ; - - seekpos = BUFFER_SIZE / 10 ; - - /* Check seek from start of file. */ - if ((k = (int) sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ; - exit (1) ; - } ; - - test_readf_float_or_die (file, 0, data, 1, __LINE__) ; - - if (error_function (data [0], orig [seekpos * channels], margin)) - { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_float failed (%f, %f).\n", __LINE__, orig [1], data [0]) ; - exit (1) ; - } ; - - if ((k = (int) sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ; - k = (int) sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; - test_readf_float_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_float failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) - 20 ; - /* Check seek backward from current position. */ - k = (int) sf_seek (file, -20, SEEK_CUR) ; - test_readf_float_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_float failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ; - exit (1) ; - } ; - - /* Check that read past end of file returns number of items. */ - sf_seek (file, sfinfo.frames, SEEK_SET) ; - - if ((k = (int) sf_readf_float (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_readf_float past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - /* Check seek backward from end. */ - if ((k = (int) sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5) - { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ; - exit (1) ; - } ; - - test_readf_float_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (data [0], orig [5 * channels], margin)) - { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%f should be %f).\n", __LINE__, data [0], orig [5 * channels]) ; - exit (1) ; - } ; - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* lcomp_test_float */ - -/*-------------------------------------------------------------------------------------------- -*/ - -static void -lcomp_test_double (const char *filename, int filetype, int channels, double margin) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, m, seekpos ; - sf_count_t datalen ; - double *orig, *data ; - double half_max_abs ; - - get_unique_test_name (&filename, LCT_TEST_PREFIX) ; - print_test_name ("lcomp_test_double", filename) ; - - datalen = BUFFER_SIZE / channels ; - - data = data_buffer.d ; - orig = orig_buffer.d ; - - gen_signal_double (orig_buffer.d, 32000.0, channels, (int) datalen) ; - for (k = 0 ; k < channels * datalen ; k++) - orig [k] = orig_buffer.d [k] ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = channels ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - test_writef_double_or_die (file, 0, orig, datalen, __LINE__) ; - sf_set_string (file, SF_STR_COMMENT, long_comment) ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (double)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - if ((sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)) != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + datalen / 20)) - { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_comment (file, filetype, __LINE__) ; - - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - - check_log_buffer_or_die (file, __LINE__) ; - - check_comment (file, filetype, __LINE__) ; - - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - - test_readf_double_or_die (file, 0, data, datalen, __LINE__) ; - - half_max_abs = 0.0 ; - for (k = 0 ; k < datalen ; k++) - { if (error_function (data [k], orig [k], margin)) - { printf ("\nLine %d: Incorrect sample A (#%d : %f should be %f).\n", __LINE__, k, data [k], orig [k]) ; - oct_save_double (orig, data, (int) datalen) ; - exit (1) ; - } ; - half_max_abs = LCT_MAX (half_max_abs, ABS (0.5 * data [k])) ; - } ; - - if (half_max_abs < 1.0) - { printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ; - exit (1) ; - } ; - - if ((k = (int) sf_readf_double (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%" PRId64 " should be %d).\n", __LINE__, - channels * sfinfo.frames - datalen, k) ; - exit (1) ; - } ; - - /* This check is only for block based encoders which must append silence - ** to the end of a file so as to fill out a block. - */ - if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM) - for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (ABS (data [channels * k]) > decay_response (channels * k)) - { printf ("\n\nLine %d : Incorrect sample B (#%d : abs (%f) should be < %d).\n", __LINE__, channels * k, data [channels * k], decay_response (channels * k)) ; - exit (1) ; - } ; - - if (! sfinfo.seekable) - { sf_close (file) ; - unlink (filename) ; - printf ("ok\n") ; - return ; - } ; - - /* Now test sf_seek function. */ - - if ((k = (int) sf_seek (file, 0, SEEK_SET)) != 0) - { printf ("\n\nLine %d: Seek to start of file failed (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (m = 0 ; m < 3 ; m++) - { test_readf_double_or_die (file, m, data, 11, __LINE__) ; - - for (k = 0 ; k < channels * 11 ; k++) - if (error_function (data [k], orig [k + channels * m * 11], margin)) - { printf ("\nLine %d: Incorrect sample (m = %d) (#%d : %f => %f).\n", __LINE__, m, k + channels * m * 11, orig [k + channels * m * 11], data [k]) ; - for (m = 0 ; m < channels ; m++) - printf ("%f ", data [m]) ; - printf ("\n") ; - exit (1) ; - } ; - } ; - - seekpos = BUFFER_SIZE / 10 ; - - /* Check seek from start of file. */ - if ((k = (int) sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ; - exit (1) ; - } ; - - test_readf_double_or_die (file, 0, data, 1, __LINE__) ; - - if (error_function (data [0], orig [seekpos * channels], margin)) - { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_double failed (%f, %f).\n", __LINE__, orig [1], data [0]) ; - exit (1) ; - } ; - - if ((k = (int) sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ; - k = (int) sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; - test_readf_double_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_double failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) - 20 ; - /* Check seek backward from current position. */ - k = (int) sf_seek (file, -20, SEEK_CUR) ; - test_readf_double_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (data [0], orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_double failed (%f, %f) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ; - exit (1) ; - } ; - - /* Check that read past end of file returns number of items. */ - sf_seek (file, sfinfo.frames, SEEK_SET) ; - - if ((k = (int) sf_readf_double (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_readf_double past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - /* Check seek backward from end. */ - if ((k = (int) sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5) - { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ; - exit (1) ; - } ; - - test_readf_double_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (data [0], orig [5 * channels], margin)) - { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_short failed (%f should be %f).\n", __LINE__, data [0], orig [5 * channels]) ; - exit (1) ; - } ; - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* lcomp_test_double */ - -/*======================================================================================== -** Smoothed differential loss compression tests. -*/ - -static void -sdlcomp_test_short (const char *filename, int filetype, int channels, double margin) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, m, seekpos, half_max_abs ; - sf_count_t datalen ; - short *orig, *data, *smooth ; - -channels = 1 ; - - get_unique_test_name (&filename, LCT_TEST_PREFIX) ; - print_test_name ("sdlcomp_test_short", filename) ; - - datalen = BUFFER_SIZE ; - - orig = orig_buffer.s ; - data = data_buffer.s ; - smooth = smooth_buffer.s ; - - gen_signal_double (orig_buffer.d, 32000.0, channels, (int) datalen) ; - for (k = 0 ; k < datalen ; k++) - orig [k] = (short) lrint (orig_buffer.d [k]) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = channels ; - sfinfo.format = filetype ; - - /* The Vorbis encoder has a bug on PowerPC and X86-64 with sample rates - ** <= 22050. Increasing the sample rate to 32000 avoids triggering it. - ** See https://trac.xiph.org/ticket/1229 - ** - ** Opus only supports discrete sample rates. Choose supported 12000. - */ - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { const char * errstr ; - - errstr = sf_strerror (NULL) ; - if (strstr (errstr, "Sample rate chosen is known to trigger a Vorbis") != NULL) - { printf ("\n Sample rate -> 32kHz ") ; - sfinfo.samplerate = 32000 ; - } - else if (strstr (errstr, "Opus only supports sample rates of") != NULL) - { printf ("\n Sample rate -> 12kHz ") ; - sfinfo.samplerate = 12000 ; - } - else - { printf ("Line %d: sf_open_fd (SFM_WRITE) failed : %s\n", __LINE__, errstr) ; - dump_log_buffer (NULL) ; - exit (1) ; - } ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - } ; - - if ((filetype & SF_FORMAT_SUBMASK) == SF_FORMAT_OPUS && !check_opus_version (file)) - { sf_close (file) ; - unlink (filename) ; - return ; - } ; - - test_write_short_or_die (file, 0, orig, datalen, __LINE__) ; - sf_set_string (file, SF_STR_COMMENT, long_comment) ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (short)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_comment (file, filetype, __LINE__) ; - - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_readf_short_or_die (file, 0, data, datalen, __LINE__) ; - - memcpy (smooth, orig, datalen * sizeof (short)) ; - smoothed_diff_short (data, (unsigned int) datalen) ; - smoothed_diff_short (smooth, (unsigned int) datalen) ; - - half_max_abs = 0 ; - for (k = 0 ; k < datalen ; k++) - { if (error_function (1.0 * data [k], 1.0 * smooth [k], margin)) - { printf ("\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, data [k], smooth [k]) ; - oct_save_short (orig, smooth, (int) datalen) ; - exit (1) ; - } ; - half_max_abs = (int) (LCT_MAX (half_max_abs, ABS (0.5 * data [k]))) ; - } ; - - if (half_max_abs < 1) - { printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ; - exit (1) ; - } ; - - if ((k = (int) sf_read_short (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%d should be %" PRId64 ").\n", __LINE__, k, sfinfo.frames - datalen) ; - exit (1) ; - } ; - - if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610) - for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (ABS (data [k]) > decay_response (k)) - { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, data [k], decay_response (k)) ; - exit (1) ; - } ; - - /* Now test sf_seek function. */ - if (sfinfo.seekable) - { if ((k = (int) sf_seek (file, 0, SEEK_SET)) != 0) - { printf ("\n\nLine %d: Seek to start of file failed (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (m = 0 ; m < 3 ; m++) - { test_readf_short_or_die (file, m, data, datalen / 7, __LINE__) ; - - smoothed_diff_short (data, (unsigned int) (datalen / 7)) ; - memcpy (smooth, orig + m * datalen / 7, datalen / 7 * sizeof (short)) ; - smoothed_diff_short (smooth, (unsigned int) (datalen / 7)) ; - - for (k = 0 ; k < datalen / 7 ; k++) - if (error_function (1.0 * data [k], 1.0 * smooth [k], margin)) - { printf ("\nLine %d: Incorrect sample C (#%d (%" PRId64 ") : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), smooth [k], data [k]) ; - for (m = 0 ; m < 10 ; m++) - printf ("%d ", data [k]) ; - printf ("\n") ; - exit (1) ; - } ; - } ; /* for (m = 0 ; m < 3 ; m++) */ - - seekpos = BUFFER_SIZE / 10 ; - - /* Check seek from start of file. */ - if ((k = (int) sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ; - exit (1) ; - } ; - test_readf_short_or_die (file, 0, data, 1, __LINE__) ; - - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin)) - { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_read_short failed (%d, %d).\n", __LINE__, orig [1], data [0]) ; - exit (1) ; - } ; - - if ((k = (int) sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ; - k = (int) sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; - test_readf_short_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) - 20 ; - /* Check seek backward from current position. */ - k = (int) sf_seek (file, -20, SEEK_CUR) ; - test_readf_short_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ; - exit (1) ; - } ; - - /* Check that read past end of file returns number of items. */ - sf_seek (file, sfinfo.frames, SEEK_SET) ; - - if ((k = (int) sf_read_short (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_read_short past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - /* Check seek backward from end. */ - - if ((k = (int) sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5) - { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ; - exit (1) ; - } ; - - test_read_short_or_die (file, 0, data, channels, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [5 * channels], margin)) - { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_read_short failed (%d should be %d).\n", __LINE__, data [0], orig [5 * channels]) ; - exit (1) ; - } ; - } /* if (sfinfo.seekable) */ - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* sdlcomp_test_short */ - -static void -sdlcomp_test_int (const char *filename, int filetype, int channels, double margin) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, m, seekpos, half_max_abs ; - sf_count_t datalen ; - int *orig, *data, *smooth ; - double scale ; - -channels = 1 ; - - get_unique_test_name (&filename, LCT_TEST_PREFIX) ; - print_test_name ("sdlcomp_test_int", filename) ; - - datalen = BUFFER_SIZE ; - scale = 1.0 * 0x10000 ; - - orig = orig_buffer.i ; - data = data_buffer.i ; - smooth = smooth_buffer.i ; - - gen_signal_double (orig_buffer.d, 32000.0 * scale, channels, (int) datalen) ; - for (k = 0 ; k < datalen ; k++) - orig [k] = lrint (orig_buffer.d [k]) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = channels ; - sfinfo.format = filetype ; - - /* The Vorbis encoder has a bug on PowerPC and X86-64 with sample rates - ** <= 22050. Increasing the sample rate to 32000 avoids triggering it. - ** See https://trac.xiph.org/ticket/1229 - ** - ** Opus only supports discrete sample rates. Choose supported 12000. - */ - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { const char * errstr ; - - errstr = sf_strerror (NULL) ; - if (strstr (errstr, "Sample rate chosen is known to trigger a Vorbis") != NULL) - { printf ("\n Sample rate -> 32kHz ") ; - sfinfo.samplerate = 32000 ; - } - else if (strstr (errstr, "Opus only supports sample rates of") != NULL) - { printf ("\n Sample rate -> 12kHz ") ; - sfinfo.samplerate = 12000 ; - } - else - { printf ("Line %d: sf_open_fd (SFM_WRITE) failed : %s\n", __LINE__, errstr) ; - dump_log_buffer (NULL) ; - exit (1) ; - } ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - } ; - - if ((filetype & SF_FORMAT_SUBMASK) == SF_FORMAT_OPUS && !check_opus_version (file)) - { sf_close (file) ; - unlink (filename) ; - return ; - } ; - - test_writef_int_or_die (file, 0, orig, datalen, __LINE__) ; - sf_set_string (file, SF_STR_COMMENT, long_comment) ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (int)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("Returned format incorrect (0x%08X => 0x%08X).\n", filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_readf_int_or_die (file, 0, data, datalen, __LINE__) ; - - memcpy (smooth, orig, datalen * sizeof (int)) ; - smoothed_diff_int (data, (unsigned int) datalen) ; - smoothed_diff_int (smooth, (unsigned int) datalen) ; - - half_max_abs = abs (data [0] >> 16) ; - for (k = 1 ; k < datalen ; k++) - { if (error_function (data [k] / scale, smooth [k] / scale, margin)) - { printf ("\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, data [k], smooth [k]) ; - oct_save_int (orig, smooth, (int) datalen) ; - exit (1) ; - } ; - half_max_abs = LCT_MAX (half_max_abs, abs (data [k] / 2)) ; - } ; - - if (half_max_abs < 1) - { printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ; - exit (1) ; - } ; - - if ((k = (int) sf_readf_int (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%d should be %" PRId64 ").\n", __LINE__, k, sfinfo.frames - datalen) ; - exit (1) ; - } ; - - if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_IMA_ADPCM && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610 && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_G721_32 && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_G723_24 && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_NMS_ADPCM_16 && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_NMS_ADPCM_24 && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_NMS_ADPCM_32) - for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (abs (data [k]) > decay_response (k)) - { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, data [k], decay_response (k)) ; - exit (1) ; - } ; - - /* Now test sf_seek function. */ - if (sfinfo.seekable) - { if ((k = (int) sf_seek (file, 0, SEEK_SET)) != 0) - { printf ("\n\nLine %d: Seek to start of file failed (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (m = 0 ; m < 3 ; m++) - { test_readf_int_or_die (file, m, data, datalen / 7, __LINE__) ; - - smoothed_diff_int (data, (unsigned int) (datalen / 7)) ; - memcpy (smooth, orig + m * datalen / 7, datalen / 7 * sizeof (int)) ; - smoothed_diff_int (smooth, (unsigned int) (datalen / 7)) ; - - for (k = 0 ; k < datalen / 7 ; k++) - if (error_function (data [k] / scale, smooth [k] / scale, margin)) - { printf ("\nLine %d: Incorrect sample (#%d (%" PRId64 ") : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), smooth [k], data [k]) ; - for (m = 0 ; m < 10 ; m++) - printf ("%d ", data [k]) ; - printf ("\n") ; - exit (1) ; - } ; - } ; /* for (m = 0 ; m < 3 ; m++) */ - - seekpos = BUFFER_SIZE / 10 ; - - /* Check seek from start of file. */ - if ((k = (int) sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ; - exit (1) ; - } ; - test_readf_int_or_die (file, 0, data, 1, __LINE__) ; - - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin)) - { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_readf_int failed (%d, %d).\n", __LINE__, orig [1], data [0]) ; - exit (1) ; - } ; - - if ((k = (int) sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ; - k = (int) sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; - test_readf_int_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) - 20 ; - /* Check seek backward from current position. */ - k = (int) sf_seek (file, -20, SEEK_CUR) ; - test_readf_int_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (1.0 * data [0], 1.0 * orig [seekpos * channels], margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_readf_int failed (%d, %d) (%d, %d).\n", __LINE__, data [0], orig [seekpos * channels], k, seekpos) ; - exit (1) ; - } ; - - /* Check that read past end of file returns number of items. */ - sf_seek (file, sfinfo.frames, SEEK_SET) ; - - if ((k = (int) sf_readf_int (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_readf_int past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - /* Check seek backward from end. */ - - if ((k = (int) sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5) - { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ; - exit (1) ; - } ; - - test_readf_int_or_die (file, 0, data, 1, __LINE__) ; - if (error_function (data [0] / scale, orig [5] / scale, margin)) - { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_readf_int failed (%d should be %d).\n", __LINE__, data [0], orig [5]) ; - exit (1) ; - } ; - } /* if (sfinfo.seekable) */ - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* sdlcomp_test_int */ - -static void -sdlcomp_test_float (const char *filename, int filetype, int channels, double margin) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, m, seekpos ; - sf_count_t datalen ; - float *orig, *data, *smooth ; - double half_max_abs , scale ; - -channels = 1 ; - - get_unique_test_name (&filename, LCT_TEST_PREFIX) ; - print_test_name ("sdlcomp_test_float", filename) ; - - switch ((filetype & SF_FORMAT_SUBMASK)) - { case SF_FORMAT_VORBIS : - /* Vorbis starts to loose fidelity with floating point values outside - ** the range of approximately [-2000.0, 2000.0] (Determined - ** experimentally, not know if it is a limitation of Vorbis or - ** libvorbis.) - */ - scale = 16.0 ; /* 32000/16 = 2000 */ - break ; - - case SF_FORMAT_OPUS : - /* The Opus spec says that non-normalized floating point value - ** support (extended dynamic range in its terms) is optional and - ** cannot be relied upon. - */ - scale = 32000.0 ; /* 32000/32000 = 1 */ - break ; - - default : - scale = 1.0 ; - break ; - } ; - - datalen = BUFFER_SIZE ; - - orig = orig_buffer.f ; - data = data_buffer.f ; - smooth = smooth_buffer.f ; - - gen_signal_double (orig_buffer.d, 32000.0 / scale, channels, (int) datalen) ; - for (k = 0 ; k < datalen ; k++) - orig [k] = (float) orig_buffer.d [k] ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = channels ; - sfinfo.format = filetype ; - - - /* The Vorbis encoder has a bug on PowerPC and X86-64 with sample rates - ** <= 22050. Increasing the sample rate to 32000 avoids triggering it. - ** See https://trac.xiph.org/ticket/1229 - ** - ** Opus only supports discrete sample rates. Choose supported 12000. - */ - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { const char * errstr ; - - errstr = sf_strerror (NULL) ; - if (strstr (errstr, "Sample rate chosen is known to trigger a Vorbis") != NULL) - { printf ("\n Sample rate -> 32kHz ") ; - sfinfo.samplerate = 32000 ; - } - else if (strstr (errstr, "Opus only supports sample rates of") != NULL) - { printf ("\n Sample rate -> 12kHz ") ; - sfinfo.samplerate = 12000 ; - } - else - { printf ("Line %d: sf_open_fd (SFM_WRITE) failed : %s\n", __LINE__, errstr) ; - dump_log_buffer (NULL) ; - exit (1) ; - } ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - } ; - - if ((filetype & SF_FORMAT_SUBMASK) == SF_FORMAT_OPUS && !check_opus_version (file)) - { sf_close (file) ; - unlink (filename) ; - return ; - } ; - - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - test_write_float_or_die (file, 0, orig, datalen, __LINE__) ; - sf_set_string (file, SF_STR_COMMENT, long_comment) ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (float)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - if ((sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)) != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_comment (file, filetype, __LINE__) ; - - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_float_or_die (file, 0, data, datalen, __LINE__) ; - - memcpy (smooth, orig, datalen * sizeof (float)) ; - smoothed_diff_float (data, (unsigned int) datalen) ; - smoothed_diff_float (smooth, (unsigned int) datalen) ; - - half_max_abs = fabs (data [0]) ; - for (k = 1 ; k < datalen ; k++) - { if (error_function (data [k] * scale, smooth [k] * scale, margin)) - { printf ("\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, (int) (data [k] * scale), (int) (smooth [k] * scale)) ; - oct_save_float (orig, smooth, (int) datalen) ; - exit (1) ; - } ; - half_max_abs = LCT_MAX (half_max_abs, ABS (0.5 * data [k] * scale)) ; - } ; - - if (half_max_abs <= 0.0) - { printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ; - printf ("half_max_abs : % 10.6f\n", half_max_abs) ; - exit (1) ; - } ; - - if ((k = (int) sf_read_float (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%d should be %" PRId64 ").\n", __LINE__, k, sfinfo.frames - datalen) ; - exit (1) ; - } ; - - if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610) - for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (ABS (data [k]) > decay_response (k)) - { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, (int) data [k], (int) decay_response (k)) ; - exit (1) ; - } ; - - /* Now test sf_seek function. */ - if (sfinfo.seekable) - { if ((k = (int) sf_seek (file, 0, SEEK_SET)) != 0) - { printf ("\n\nLine %d: Seek to start of file failed (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (m = 0 ; m < 3 ; m++) - { test_read_float_or_die (file, 0, data, datalen / 7, __LINE__) ; - - smoothed_diff_float (data, (unsigned int) (datalen / 7)) ; - memcpy (smooth, orig + m * datalen / 7, datalen / 7 * sizeof (float)) ; - smoothed_diff_float (smooth, (unsigned int) (datalen / 7)) ; - - for (k = 0 ; k < datalen / 7 ; k++) - if (error_function (data [k] * scale, smooth [k] * scale, margin)) - { printf ("\nLine %d: Incorrect sample C (#%d (%" PRId64 ") : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), (int) (smooth [k] * scale), (int) (data [k] * scale)) ; - for (m = 0 ; m < 10 ; m++) - printf ("%d ", (int) data [k]) ; - printf ("\n") ; - exit (1) ; - } ; - } ; /* for (m = 0 ; m < 3 ; m++) */ - - seekpos = BUFFER_SIZE / 10 ; - - /* Check seek from start of file. */ - if ((k = (int) sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ; - exit (1) ; - } ; - test_read_float_or_die (file, 0, data, channels, __LINE__) ; - - if (error_function (data [0] * scale, orig [seekpos * channels] * scale, margin)) - { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_read_float failed (%d, %d).\n", __LINE__, (int) (orig [1] * scale), (int) (data [0] * scale)) ; - exit (1) ; - } ; - - if ((k = (int) sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ; - k = (int) sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; - test_read_float_or_die (file, 0, data, channels, __LINE__) ; - if (error_function (data [0] * scale, orig [seekpos * channels] * scale, margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_read_float failed (%d, %d) (%d, %d).\n", __LINE__, (int) (data [0] * scale), (int) (orig [seekpos * channels] * scale), k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) - 20 ; - /* Check seek backward from current position. */ - k = (int) sf_seek (file, -20, SEEK_CUR) ; - test_read_float_or_die (file, 0, data, channels, __LINE__) ; - if (error_function (data [0] * scale, orig [seekpos * channels] * scale, margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_read_float failed (%d, %d) (%d, %d).\n", __LINE__, (int) (data [0] * scale), (int) (orig [seekpos * channels] * scale), k, seekpos) ; - exit (1) ; - } ; - - /* Check that read past end of file returns number of items. */ - sf_seek (file, sfinfo.frames, SEEK_SET) ; - - if ((k = (int) sf_read_float (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_read_float past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - /* Check seek backward from end. */ - - if ((k = (int) sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5) - { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ; - exit (1) ; - } ; - - test_read_float_or_die (file, 0, data, channels, __LINE__) ; - if (error_function (data [0] * scale, orig [5 * channels] * scale, margin)) - { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_read_float failed (%f should be %f).\n", __LINE__, data [0] * scale, orig [5 * channels] * scale) ; - exit (1) ; - } ; - } /* if (sfinfo.seekable) */ - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* sdlcomp_test_float */ - -static void -sdlcomp_test_double (const char *filename, int filetype, int channels, double margin) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, m, seekpos ; - sf_count_t datalen ; - double *orig, *data, *smooth, half_max_abs, scale ; - -channels = 1 ; - - get_unique_test_name (&filename, LCT_TEST_PREFIX) ; - print_test_name ("sdlcomp_test_double", filename) ; - - switch ((filetype & SF_FORMAT_SUBMASK)) - { case SF_FORMAT_VORBIS : - /* Vorbis starts to loose fidelity with floating point values outside - ** the range of approximately [-2000.0, 2000.0] (Determined - ** experimentally, not know if it is a limitation of Vorbis or - ** libvorbis.) - */ - scale = 16.0 ; /* 32000/16 = 2000 */ - break ; - - case SF_FORMAT_OPUS : - /* The Opus spec says that non-normalized floating point value - ** support (extended dynamic range in its terms) is optional and - ** cannot be relied upon. - */ - scale = 32000.0 ; /* 32000/32000 = 1 */ - break ; - - default : - scale = 1.0 ; - break ; - } ; - - datalen = BUFFER_SIZE ; - - orig = orig_buffer.d ; - data = data_buffer.d ; - smooth = smooth_buffer.d ; - - gen_signal_double (orig_buffer.d, 32000.0 / scale, channels, (int) datalen) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = channels ; - sfinfo.format = filetype ; - - /* The Vorbis encoder has a bug on PowerPC and X86-64 with sample rates - ** <= 22050. Increasing the sample rate to 32000 avoids triggering it. - ** See https://trac.xiph.org/ticket/1229 - ** - ** Opus only supports discrete sample rates. Choose supported 12000. - */ - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { const char * errstr ; - - errstr = sf_strerror (NULL) ; - if (strstr (errstr, "Sample rate chosen is known to trigger a Vorbis") != NULL) - { printf ("\n Sample rate -> 32kHz ") ; - sfinfo.samplerate = 32000 ; - } - else if (strstr (errstr, "Opus only supports sample rates of") != NULL) - { printf ("\n Sample rate -> 12kHz ") ; - sfinfo.samplerate = 12000 ; - } - else - { printf ("Line %d: sf_open_fd (SFM_WRITE) failed : %s\n", __LINE__, errstr) ; - dump_log_buffer (NULL) ; - exit (1) ; - } ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - } ; - - if ((filetype & SF_FORMAT_SUBMASK) == SF_FORMAT_OPUS && !check_opus_version (file)) - { sf_close (file) ; - unlink (filename) ; - return ; - } ; - - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - test_write_double_or_die (file, 0, orig, datalen, __LINE__) ; - sf_set_string (file, SF_STR_COMMENT, long_comment) ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (double)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("Returned format incorrect (0x%08X => 0x%08X).\n", filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_comment (file, filetype, __LINE__) ; - - check_comment (file, filetype, __LINE__) ; - - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_double_or_die (file, 0, data, datalen, __LINE__) ; - - memcpy (smooth, orig, datalen * sizeof (double)) ; - smoothed_diff_double (data, (unsigned int) datalen) ; - smoothed_diff_double (smooth, (unsigned int) datalen) ; - - half_max_abs = 0.0 ; - for (k = 0 ; k < datalen ; k++) - { if (error_function (data [k] * scale, smooth [k] * scale, margin)) - { printf ("\n\nLine %d: Incorrect sample (#%d : %d should be %d).\n", __LINE__, k, (int) (data [k] * scale), (int) (smooth [k] * scale)) ; - oct_save_double (orig, smooth, (int) datalen) ; - exit (1) ; - } ; - half_max_abs = LCT_MAX (half_max_abs, 0.5 * fabs (data [k] * scale)) ; - } ; - - if (half_max_abs < 1.0) - { printf ("\n\nLine %d: Signal is all zeros.\n", __LINE__) ; - exit (1) ; - } ; - - if ((k = (int) sf_read_double (file, data, datalen)) != sfinfo.frames - datalen) - { printf ("\n\nLine %d: Incorrect read length (%d should be %" PRId64 ").\n", __LINE__, k, sfinfo.frames - datalen) ; - exit (1) ; - } ; - - if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM && - (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610) - for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (ABS (data [k]) > decay_response (k)) - { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, (int) data [k], (int) decay_response (k)) ; - exit (1) ; - } ; - - /* Now test sf_seek function. */ - if (sfinfo.seekable) - { if ((k = (int) sf_seek (file, 0, SEEK_SET)) != 0) - { printf ("\n\nLine %d: Seek to start of file failed (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - for (m = 0 ; m < 3 ; m++) - { test_read_double_or_die (file, m, data, datalen / 7, __LINE__) ; - - smoothed_diff_double (data, (unsigned int) (datalen / 7)) ; - memcpy (smooth, orig + m * datalen / 7, datalen / 7 * sizeof (double)) ; - smoothed_diff_double (smooth, (unsigned int) (datalen / 7)) ; - - for (k = 0 ; k < datalen / 7 ; k++) - if (error_function (data [k] * scale, smooth [k] * scale, margin)) - { printf ("\nLine %d: Incorrect sample C (#%d (%" PRId64 ") : %d => %d).\n", __LINE__, k, k + m * (datalen / 7), (int) (smooth [k] * scale), (int) (data [k] * scale)) ; - for (m = 0 ; m < 10 ; m++) - printf ("%d ", (int) data [k]) ; - printf ("\n") ; - exit (1) ; - } ; - } ; /* for (m = 0 ; m < 3 ; m++) */ - - seekpos = BUFFER_SIZE / 10 ; - - /* Check seek from start of file. */ - if ((k = (int) sf_seek (file, seekpos, SEEK_SET)) != seekpos) - { printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ; - exit (1) ; - } ; - test_read_double_or_die (file, 0, data, channels, __LINE__) ; - - if (error_function (data [0] * scale, orig [seekpos * channels] * scale, margin)) - { printf ("\nLine %d: sf_seek (SEEK_SET) followed by sf_read_double failed (%d, %d).\n", __LINE__, (int) (orig [1] * scale), (int) (data [0] * scale)) ; - exit (1) ; - } ; - - if ((k = (int) sf_seek (file, 0, SEEK_CUR)) != seekpos + 1) - { printf ("\n\nLine %d: sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", __LINE__, k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ; - k = (int) sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ; - test_read_double_or_die (file, 0, data, channels, __LINE__) ; - if (error_function (data [0] * scale, orig [seekpos * channels] * scale, margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (forwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", __LINE__, (int) (data [0] * scale), (int) (orig [seekpos * channels] * scale), k, seekpos + 1) ; - exit (1) ; - } ; - - seekpos = (int) sf_seek (file, 0, SEEK_CUR) - 20 ; - /* Check seek backward from current position. */ - k = (int) sf_seek (file, -20, SEEK_CUR) ; - test_read_double_or_die (file, 0, data, channels, __LINE__) ; - if (error_function (data [0] * scale, orig [seekpos * channels] * scale, margin) || k != seekpos) - { printf ("\nLine %d: sf_seek (backwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", __LINE__, (int) (data [0] * scale), (int) (orig [seekpos * channels] * scale), k, seekpos) ; - exit (1) ; - } ; - - /* Check that read past end of file returns number of items. */ - sf_seek (file, sfinfo.frames, SEEK_SET) ; - - if ((k = (int) sf_read_double (file, data, datalen)) != 0) - { printf ("\n\nLine %d: Return value from sf_read_double past end of file incorrect (%d).\n", __LINE__, k) ; - exit (1) ; - } ; - - /* Check seek backward from end. */ - - if ((k = (int) sf_seek (file, 5 - sfinfo.frames, SEEK_END)) != 5) - { printf ("\n\nLine %d: sf_seek (SEEK_END) returned %d instead of %d.\n", __LINE__, k, 5) ; - exit (1) ; - } ; - - test_read_double_or_die (file, 0, data, channels, __LINE__) ; - if (error_function (data [0] * scale, orig [5 * channels] * scale, margin)) - { printf ("\nLine %d: sf_seek (SEEK_END) followed by sf_read_double failed (%f should be %f).\n", __LINE__, data [0] * scale, orig [5 * channels] * scale) ; - exit (1) ; - } ; - } /* if (sfinfo.seekable) */ - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* sdlcomp_test_double */ - -static void -read_raw_test (const char *filename, int filetype, int channels) -{ SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t count, datalen ; - short *orig, *data ; - int k ; - - get_unique_test_name (&filename, LCT_TEST_PREFIX) ; - print_test_name ("read_raw_test", filename) ; - - datalen = ARRAY_LEN (orig_buffer.s) / 2 ; - - orig = orig_buffer.s ; - data = data_buffer.s ; - - gen_signal_double (orig_buffer.d, 32000.0, channels, (int) datalen) ; - for (k = 0 ; k < datalen ; k++) - orig [k] = (short) lrint (orig_buffer.d [k]) ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = 123456789 ; /* Ridiculous value. */ - sfinfo.channels = channels ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_short_or_die (file, 0, orig, datalen, __LINE__) ; - sf_set_string (file, SF_STR_COMMENT, long_comment) ; - sf_close (file) ; - - memset (data, 0, datalen * sizeof (double)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("Returned format incorrect (0x%08X => 0x%08X).\n", filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < datalen / channels) - { printf ("Too few.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", datalen, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.frames > (datalen + 400)) - { printf ("Too many.frames in file. (%" PRId64 " should be a little more than %" PRId64 ")\n", sfinfo.frames, datalen) ; - exit (1) ; - } ; - - if (sfinfo.channels != channels) - { printf ("Incorrect number of channels in file.\n") ; - exit (1) ; - } ; - - check_comment (file, filetype, __LINE__) ; - - count = sf_read_raw (file, orig_buffer.c, datalen + 5 * channels) ; - if (count != sfinfo.channels * sfinfo.frames) - { printf ("\nLine %d : sf_read_raw returned %" PRId64 " should be %" PRId64 "\n", __LINE__, count, sfinfo.channels * sfinfo.frames) ; - exit (1) ; - } ; - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* read_raw_test */ - -/*======================================================================================== -** Auxiliary functions -*/ - -#define SIGNAL_MAXVAL 30000.0 -#define DECAY_COUNT 1000 - -static int -decay_response (int k) -{ if (k < 1) - return (int) (1.2 * SIGNAL_MAXVAL) ; - if (k > DECAY_COUNT) - return 0 ; - return (int) (1.2 * SIGNAL_MAXVAL * (DECAY_COUNT - k) / (1.0 * DECAY_COUNT)) ; -} /* decay_response */ - -static void -gen_signal_double (double *data, double scale, int channels, int datalen) -{ int k, ramplen ; - double amp = 0.0 ; - - ramplen = DECAY_COUNT ; - - if (channels == 1) - { for (k = 0 ; k < datalen ; k++) - { if (k <= ramplen) - amp = scale * k / ((double) ramplen) ; - else if (k > datalen - ramplen) - amp = scale * (datalen - k) / ((double) ramplen) ; - -/*-printf ("%3d : %g\n", k, amp) ;-*/ - - data [k] = amp * (0.4 * sin (33.3 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE)) - + 0.3 * cos (201.1 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))) ; - } ; - } - else - { for (k = 0 ; k < datalen ; k ++) - { if (k <= ramplen) - amp = scale * k / ((double) ramplen) ; - else if (k > datalen - ramplen) - amp = scale * (datalen - k) / ((double) ramplen) ; - - data [2 * k] = amp * (0.4 * sin (33.3 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE)) - + 0.3 * cos (201.1 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))) ; - data [2 * k + 1] = amp * (0.4 * sin (55.5 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE)) - + 0.3 * cos (201.1 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))) ; - } ; - } ; - - return ; -} /* gen_signal_double */ - -static int -error_function (double data, double orig, double margin) -{ double error ; - - if (fabs (orig) <= 500.0) - error = fabs (fabs (data) - fabs (orig)) / 2000.0 ; - else if (fabs (orig) <= 1000.0) - error = fabs (data - orig) / 3000.0 ; - else - error = fabs (data - orig) / fabs (orig) ; - - if (error > margin) - { printf ("\n\nerror_function (data = %f, orig = %f, margin = %f) -> %f\n", data, orig, margin, error) ; - return 1 ; - } ; - return 0 ; -} /* error_function */ - -static void -smoothed_diff_short (short *data, unsigned int datalen) -{ unsigned int k ; - double memory = 0.0 ; - - /* Calculate the smoothed sample-to-sample difference. */ - for (k = 0 ; k < datalen - 1 ; k++) - { memory = 0.7 * memory + (1 - 0.7) * (double) (data [k+1] - data [k]) ; - data [k] = (short) memory ; - } ; - data [datalen-1] = data [datalen-2] ; - -} /* smoothed_diff_short */ - -static void -smoothed_diff_int (int *data, unsigned int datalen) -{ unsigned int k ; - double memory = 0.0 ; - - /* Calculate the smoothed sample-to-sample difference. */ - for (k = 0 ; k < datalen - 1 ; k++) - { memory = 0.7 * memory + (1 - 0.7) * (double) (data [k+1] - data [k]) ; - data [k] = (int) memory ; - } ; - data [datalen-1] = data [datalen-2] ; - -} /* smoothed_diff_int */ - -static void -smoothed_diff_float (float *data, unsigned int datalen) -{ unsigned int k ; - float memory = 0.0 ; - - /* Calculate the smoothed sample-to-sample difference. */ - for (k = 0 ; k < datalen - 1 ; k++) - { memory = (float) (0.7 * memory + (1 - 0.7) * (data [k+1] - data [k])) ; - data [k] = memory ; - } ; - data [datalen-1] = data [datalen-2] ; - -} /* smoothed_diff_float */ - -static void -smoothed_diff_double (double *data, unsigned int datalen) -{ unsigned int k ; - double memory = 0.0 ; - - /* Calculate the smoothed sample-to-sample difference. */ - for (k = 0 ; k < datalen - 1 ; k++) - { memory = 0.7 * memory + (1 - 0.7) * (data [k+1] - data [k]) ; - data [k] = memory ; - } ; - data [datalen-1] = data [datalen-2] ; - -} /* smoothed_diff_double */ - -static void -check_comment (SNDFILE * file, int format, int lineno) -{ const char *comment ; - - switch (format & SF_FORMAT_TYPEMASK) - { case SF_FORMAT_AIFF : - case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : - break ; - default : - return ; - } ; - - comment = sf_get_string (file, SF_STR_COMMENT) ; - if (comment == NULL) - { printf ("\n\nLine %d : File does not contain a comment string.\n\n", lineno) ; - exit (1) ; - } ; - - if (strcmp (comment, long_comment) != 0) - { printf ("\n\nLine %d : File comment does not match comment written.\n\n", lineno) ; - exit (1) ; - } ; - - return ; -} /* check_comment */ - -static int -is_lossy (int filetype) -{ - switch (SF_FORMAT_SUBMASK & filetype) - { case SF_FORMAT_PCM_U8 : - case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_16 : - case SF_FORMAT_PCM_24 : - case SF_FORMAT_PCM_32 : - case SF_FORMAT_FLOAT : - case SF_FORMAT_DOUBLE : - return 0 ; - - default : - break ; - } ; - - return 1 ; -} /* is_lossy */ - - -static int -check_opus_version (SNDFILE *file) -{ char log_buf [256] ; - char *str, *p ; - const char *str_libopus = "Opus library version: " ; - int ver_major, ver_minor ; - - sf_command (file, SFC_GET_LOG_INFO, log_buf, sizeof (log_buf)) ; - str = strstr (log_buf, str_libopus) ; - if (str) - { str += strlen (str_libopus) ; - if ((p = strchr (str, '\n'))) - *p = '\0' ; - if (sscanf (str, "libopus %d.%d", &ver_major, &ver_minor) == 2) - { /* Reject versions prior to 1.3 */ - if (ver_major > 1 || (ver_major == 1 && ver_minor >= 3)) - { /* - ** Make sure that the libopus in use is not fixed-point, as it - ** sacrifices accuracy. libopus API documentation explicitly - ** allows checking for this suffix to determine if it is. - */ - if (!strstr (str, "-fixed")) - return 1 ; - } ; - } ; - } ; - - printf ("skipping (%s)\n", str ? str : "unknown libopus version") ; - return 0 ; -} /* check_opus_version */ diff --git a/Engine/lib/libsndfile/tests/misc_test.c b/Engine/lib/libsndfile/tests/misc_test.c deleted file mode 100644 index 31e93d185..000000000 --- a/Engine/lib/libsndfile/tests/misc_test.c +++ /dev/null @@ -1,533 +0,0 @@ -/* -** Copyright (C) 2001-2017 Erik de Castro Lopo -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation ; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#include -#include - -#if HAVE_UNISTD_H -#include -#endif - -#if (HAVE_DECL_S_IRGRP == 0) -#include -#endif - -#if (defined (WIN32) || defined (_WIN32)) -#include -#include -#endif - -#include - -#include "utils.h" - -#define BUFFER_LEN (1 << 10) -#define LOG_BUFFER_SIZE 1024 - -static void zero_data_test (const char *filename, int format) ; -static void filesystem_full_test (int format) ; -static void permission_test (const char *filename, int typemajor) ; -static void wavex_amb_test (const char *filename) ; -static void rf64_downgrade_test (const char *filename) ; -static void rf64_long_file_downgrade_test (const char *filename) ; - -int -main (int argc, char *argv []) -{ int do_all = 0 ; - int test_count = 0 ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" wav - test WAV file peak chunk\n") ; - printf (" aiff - test AIFF file PEAK chunk\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "wav")) - { zero_data_test ("zerolen.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - permission_test ("readonly.wav", SF_FORMAT_WAV) ; - wavex_amb_test ("ambisonic.wav") ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { zero_data_test ("zerolen.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ; - permission_test ("readonly.aiff", SF_FORMAT_AIFF) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "au")) - { zero_data_test ("zerolen.au", SF_FORMAT_AU | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_AU | SF_FORMAT_PCM_16) ; - permission_test ("readonly.au", SF_FORMAT_AU) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "caf")) - { zero_data_test ("zerolen.caf", SF_FORMAT_CAF | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_CAF | SF_FORMAT_PCM_16) ; - permission_test ("readonly.caf", SF_FORMAT_CAF) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "svx")) - { zero_data_test ("zerolen.svx", SF_FORMAT_SVX | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_SVX | SF_FORMAT_PCM_16) ; - permission_test ("readonly.svx", SF_FORMAT_SVX) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "nist")) - { zero_data_test ("zerolen.nist", SF_FORMAT_NIST | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_NIST | SF_FORMAT_PCM_16) ; - permission_test ("readonly.nist", SF_FORMAT_NIST) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "paf")) - { zero_data_test ("zerolen.paf", SF_FORMAT_PAF | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_PAF | SF_FORMAT_PCM_16) ; - permission_test ("readonly.paf", SF_FORMAT_PAF) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "ircam")) - { zero_data_test ("zerolen.ircam", SF_FORMAT_IRCAM | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_IRCAM | SF_FORMAT_PCM_16) ; - permission_test ("readonly.ircam", SF_FORMAT_IRCAM) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "voc")) - { zero_data_test ("zerolen.voc", SF_FORMAT_VOC | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_VOC | SF_FORMAT_PCM_16) ; - permission_test ("readonly.voc", SF_FORMAT_VOC) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "w64")) - { zero_data_test ("zerolen.w64", SF_FORMAT_W64 | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_W64 | SF_FORMAT_PCM_16) ; - permission_test ("readonly.w64", SF_FORMAT_W64) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "rf64")) - { zero_data_test ("zerolen.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; - permission_test ("readonly.rf64", SF_FORMAT_RF64) ; - rf64_downgrade_test ("downgrade.wav") ; - /* Disable this by default, because it needs to write 4 gigabytes of data. */ - if (SF_FALSE) - rf64_long_file_downgrade_test ("no-downgrade.rf64") ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat4")) - { zero_data_test ("zerolen.mat4", SF_FORMAT_MAT4 | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_MAT4 | SF_FORMAT_PCM_16) ; - permission_test ("readonly.mat4", SF_FORMAT_MAT4) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat5")) - { zero_data_test ("zerolen.mat5", SF_FORMAT_MAT5 | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_MAT5 | SF_FORMAT_PCM_16) ; - permission_test ("readonly.mat5", SF_FORMAT_MAT5) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "pvf")) - { zero_data_test ("zerolen.pvf", SF_FORMAT_PVF | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_PVF | SF_FORMAT_PCM_16) ; - permission_test ("readonly.pvf", SF_FORMAT_PVF) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "htk")) - { zero_data_test ("zerolen.htk", SF_FORMAT_HTK | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_HTK | SF_FORMAT_PCM_16) ; - permission_test ("readonly.htk", SF_FORMAT_HTK) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "avr")) - { zero_data_test ("zerolen.avr", SF_FORMAT_AVR | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_AVR | SF_FORMAT_PCM_16) ; - permission_test ("readonly.avr", SF_FORMAT_AVR) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "sds")) - { zero_data_test ("zerolen.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_SDS | SF_FORMAT_PCM_16) ; - permission_test ("readonly.sds", SF_FORMAT_SDS) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mpc2k")) - { zero_data_test ("zerolen.mpc", SF_FORMAT_MPC2K | SF_FORMAT_PCM_16) ; - filesystem_full_test (SF_FORMAT_MPC2K | SF_FORMAT_PCM_16) ; - permission_test ("readonly.mpc", SF_FORMAT_MPC2K) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "ogg")) - { zero_data_test ("zerolen.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS) ; - /*-filesystem_full_test (SF_FORMAT_OGG | SF_FORMAT_VORBIS) ;-*/ - permission_test ("readonly.oga", SF_FORMAT_OGG) ; - test_count++ ; - } ; - - if (test_count == 0) - { printf ("Mono : ************************************\n") ; - printf ("Mono : * No '%s' test defined.\n", argv [1]) ; - printf ("Mono : ************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -zero_data_test (const char *filename, int format) -{ SNDFILE *file ; - SF_INFO sfinfo ; - - switch (format & SF_FORMAT_TYPEMASK) - { case SF_FORMAT_OGG : - if (HAVE_EXTERNAL_XIPH_LIBS == 0) - return ; - break ; - default : - break ; - } ; - - print_test_name ("zero_data_test", filename) ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = format ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - sf_close (file) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - sf_close (file) ; - - unlink (filename) ; - puts ("ok") ; -} /* zero_data_test */ - -static void -filesystem_full_test (int format) -{ -#if (defined (WIN32) || defined (_WIN32)) - (void) format ; - /* Can't run this test on Win32 so return. */ - return ; -#else - SNDFILE *file ; - SF_INFO sfinfo ; - struct stat buf ; - - const char *filename = "/dev/full", *errorstr ; - - /* Make sure errno is zero before doing anything else. */ - errno = 0 ; - - print_test_name ("filesystem_full_test", filename) ; - - if (stat (filename, &buf) != 0) - { puts ("/dev/full missing") ; - return ; - } ; - - if (S_ISCHR (buf.st_mode) == 0 && S_ISBLK (buf.st_mode) == 0) - { puts ("/dev/full is not a device file") ; - return ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = format ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) != NULL) - { printf ("\n\nLine %d : Error, file should not have openned.\n", __LINE__ - 1) ; - exit (1) ; - } ; - - errorstr = sf_strerror (file) ; - - if (strstr (errorstr, " space ") == NULL || strstr (errorstr, "device") == NULL) - { printf ("\n\nLine %d : Error bad error string : %s.\n", __LINE__ - 1, errorstr) ; - exit (1) ; - } ; - - puts ("ok") ; -#endif -} /* filesystem_full_test */ - -static void -permission_test (const char *filename, int typemajor) -{ -#if (OS_IS_WIN32) - /* Avoid compiler warnings. */ - (void) filename ; - (void) typemajor ; - - /* Can't run this test on Win32 so return. */ - return ; -#else - - FILE *textfile ; - SNDFILE *file ; - SF_INFO sfinfo ; - const char *errorstr ; - - /* Make sure errno is zero before doing anything else. */ - errno = 0 ; - - if (getuid () == 0) - { /* If running as root bypass this test. - ** Root is allowed to open a readonly file for write. - */ - return ; - } ; - - print_test_name ("permission_test", filename) ; - - if (access (filename, F_OK) == 0) - { chmod (filename, S_IWUSR) ; - unlink (filename) ; - } ; - - if ((textfile = fopen (filename, "w")) == NULL) - { printf ("\n\nLine %d : not able to open text file for write.\n", __LINE__) ; - exit (1) ; - } ; - - fprintf (textfile, "This is a read only file.\n") ; - fclose (textfile) ; - - if (chmod (filename, S_IRUSR | S_IRGRP)) - { printf ("\n\nLine %d : chmod failed", __LINE__) ; - fflush (stdout) ; - perror ("") ; - exit (1) ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) != NULL) - { printf ("\n\nLine %d : Error, file should not have opened.\n", __LINE__ - 1) ; - exit (1) ; - } ; - - errorstr = sf_strerror (file) ; - - if (strstr (errorstr, "ermission denied") == NULL) - { printf ("\n\nLine %d : Error bad error string : %s.\n", __LINE__ - 1, errorstr) ; - exit (1) ; - } ; - - if (chmod (filename, S_IWUSR | S_IWGRP)) - { printf ("\n\nLine %d : chmod failed", __LINE__) ; - fflush (stdout) ; - perror ("") ; - exit (1) ; - } ; - - unlink (filename) ; - - puts ("ok") ; - -#endif -} /* permission_test */ - -static void -wavex_amb_test (const char *filename) -{ static short buffer [800] ; - SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t frames ; - - print_test_name (__func__, filename) ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = SF_FORMAT_WAVEX | SF_FORMAT_PCM_16 ; - sfinfo.channels = 4 ; - - frames = ARRAY_LEN (buffer) / sfinfo.channels ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_WAVEX_SET_AMBISONIC, NULL, SF_AMBISONIC_B_FORMAT) ; - test_writef_short_or_die (file, 0, buffer, frames, __LINE__) ; - sf_close (file) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true ( - sf_command (file, SFC_WAVEX_GET_AMBISONIC, NULL, 0) != SF_AMBISONIC_B_FORMAT, - "\n\nLine %d : Error, this file should be in Ambisonic B format.\n", __LINE__ - ) ; - - sf_close (file) ; - - unlink (filename) ; - puts ("ok") ; -} /* wavex_amb_test */ - -static void -rf64_downgrade_test (const char *filename) -{ static short output [BUFFER_LEN] ; - static short input [BUFFER_LEN] ; - - SNDFILE *file ; - SF_INFO sfinfo ; - unsigned k ; - - print_test_name (__func__, filename) ; - - sf_info_clear (&sfinfo) ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = ARRAY_LEN (output) ; - sfinfo.channels = 1 ; - sfinfo.format = SF_FORMAT_RF64 | SF_FORMAT_PCM_16 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_FALSE) != SF_FALSE, "\n\nLine %d: sf_command failed.\n", __LINE__) ; - exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_TRUE) != SF_TRUE, "\n\nLine %d: sf_command failed.\n", __LINE__) ; - - test_write_short_or_die (file, 0, output, ARRAY_LEN (output), __LINE__) ; - - exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_FALSE) != SF_TRUE, "\n\nLine %d: sf_command failed.\n", __LINE__) ; - exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_TRUE) != SF_TRUE, "\n\nLine %d: sf_command failed.\n", __LINE__) ; - - sf_close (file) ; - - memset (input, 0, sizeof (input)) ; - sf_info_clear (&sfinfo) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true (sfinfo.format != (SF_FORMAT_WAVEX | SF_FORMAT_PCM_16), "\n\nLine %d: RF64 to WAV downgrade failed.\n", __LINE__) ; - exit_if_true (sfinfo.frames != ARRAY_LEN (output), "\n\nLine %d: Incorrect number of frames in file (too short). (%d should be %d)\n", __LINE__, (int) sfinfo.frames, (int) ARRAY_LEN (output)) ; - exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_short_or_die (file, 0, input, ARRAY_LEN (input), __LINE__) ; - - sf_close (file) ; - - for (k = 0 ; k < ARRAY_LEN (input) ; k++) - exit_if_true (input [k] != output [k], - "\n\nLine: %d: Error on input %d, expected %d, got %d\n", __LINE__, k, output [k], input [k]) ; - - puts ("ok") ; - unlink (filename) ; - - return ; -} /* rf64_downgrade_test */ - -static void -rf64_long_file_downgrade_test (const char *filename) -{ static int output [BUFFER_LEN] ; - static int input [1] = { 0 } ; - - SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t output_frames = 0 ; - - print_test_name (__func__, filename) ; - - sf_info_clear (&sfinfo) ; - - memset (output, 0, sizeof (output)) ; - output [0] = 0x1020304 ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = ARRAY_LEN (output) ; - sfinfo.channels = 1 ; - sfinfo.format = SF_FORMAT_RF64 | SF_FORMAT_PCM_32 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_TRUE) != SF_TRUE, "\n\nLine %d: sf_command failed.\n", __LINE__) ; - - while (output_frames * sizeof (output [0]) < 0x100000000) - { test_write_int_or_die (file, 0, output, ARRAY_LEN (output), __LINE__) ; - output_frames += ARRAY_LEN (output) ; - } ; - - sf_close (file) ; - - sf_info_clear (&sfinfo) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - exit_if_true (sfinfo.format != (SF_FORMAT_RF64 | SF_FORMAT_PCM_32), "\n\nLine %d: RF64 to WAV downgrade should have failed.\n", __LINE__) ; - exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - exit_if_true (sfinfo.frames != output_frames, "\n\nLine %d: Incorrect number of frames in file (%d should be %d).\n", __LINE__, (int) sfinfo.frames, (int) output_frames) ; - - /* Check that the first sample read is the same as the first written. */ - test_read_int_or_die (file, 0, input, ARRAY_LEN (input), __LINE__) ; - exit_if_true (input [0] != output [0], "\n\nLine %d: Bad first sample (0x%08x).\n", __LINE__, input [0]) ; - - check_log_buffer_or_die (file, __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - unlink (filename) ; - - return ; -} /* rf64_long_file_downgrade_test */ diff --git a/Engine/lib/libsndfile/tests/mpeg_test.c b/Engine/lib/libsndfile/tests/mpeg_test.c deleted file mode 100644 index fe7f53d16..000000000 --- a/Engine/lib/libsndfile/tests/mpeg_test.c +++ /dev/null @@ -1,348 +0,0 @@ -/* -** Copyright (C) 2007-2019 Erik de Castro Lopo -** Copyright (C) 2019 John ffitch -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include - -#include "utils.h" - -#define SAMPLE_RATE 44100 -#define DATA_LENGTH (SAMPLE_RATE / 8) - -typedef union -{ double d [DATA_LENGTH] ; - float f [DATA_LENGTH] ; - int i [DATA_LENGTH] ; - short s [DATA_LENGTH] ; -} BUFFER ; - -static BUFFER data_out ; -static BUFFER data_in ; - -static void -mpeg_short_test (void) -{ const char * filename = "mpeg_short.mp3" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - short seek_data [10] ; - unsigned k ; - - print_test_name ("mpeg_short_test", filename) ; - - /* Generate float data. */ - gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7F00) ; - - /* Convert to shorteger. */ - for (k = 0 ; k < ARRAY_LEN (data_out.s) ; k++) - data_out.s [k] = lrintf (data_out.f [k]) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_short_or_die (file, 0, data_out.s, ARRAY_LEN (data_out.s), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_short_or_die (file, 0, data_in.s, ARRAY_LEN (data_in.s), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("mpeg_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_short_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_short_or_die (seek_data, data_in.s + 10, ARRAY_LEN (seek_data), __LINE__) ; - - /* Test seek to end of file. */ - test_seek_or_die (file, 0, SEEK_END, sfinfo.frames, sfinfo.channels, __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* mpeg_short_test */ - -static void -mpeg_int_test (void) -{ const char * filename = "mpeg_int.mp3" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - int seek_data [10] ; - unsigned k ; - - print_test_name ("mpeg_int_test", filename) ; - - /* Generate float data. */ - gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7FFF0000) ; - - /* Convert to integer. */ - for (k = 0 ; k < ARRAY_LEN (data_out.i) ; k++) - data_out.i [k] = lrintf (data_out.f [k]) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_int_or_die (file, 0, data_out.i, ARRAY_LEN (data_out.i), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_int_or_die (file, 0, data_in.i, ARRAY_LEN (data_in.i), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("mpeg_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_int_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_int_or_die (seek_data, data_in.i + 10, ARRAY_LEN (seek_data), __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* mpeg_int_test */ - -static void -mpeg_float_test (void) -{ const char * filename = "mpeg_float.mp3" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - float seek_data [10] ; - - print_test_name ("mpeg_float_test", filename) ; - - gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 0.95) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_float_or_die (file, 0, data_out.f, ARRAY_LEN (data_out.f), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_float_or_die (file, 0, data_in.f, ARRAY_LEN (data_in.f), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("mpeg_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_float_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_float_or_die (seek_data, data_in.f + 10, ARRAY_LEN (seek_data), __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* mpeg_float_test */ - -static void -mpeg_double_test (void) -{ const char * filename = "mpeg_double.mp3" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - double seek_data [10] ; - - print_test_name ("mpeg_double_test", filename) ; - - gen_windowed_sine_double (data_out.d, ARRAY_LEN (data_out.d), 0.95) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_double_or_die (file, 0, data_out.d, ARRAY_LEN (data_out.d), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_double_or_die (file, 0, data_in.d, ARRAY_LEN (data_in.d), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("mpeg_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_double_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_double_or_die (seek_data, data_in.d + 10, ARRAY_LEN (seek_data), __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* mpeg_double_test */ - - -static void -mpeg_stereo_seek_test (const char * filename, int format) -{ static float data [SAMPLE_RATE] ; - static float stereo_out [SAMPLE_RATE * 2] ; - - SNDFILE * file ; - SF_INFO sfinfo ; - sf_count_t pos ; - unsigned k ; - - print_test_name (__func__, filename) ; - - gen_windowed_sine_float (data, ARRAY_LEN (data), 0.95) ; - for (k = 0 ; k < ARRAY_LEN (data) ; k++) - { stereo_out [2 * k] = data [k] ; - stereo_out [2 * k + 1] = data [ARRAY_LEN (data) - k - 1] ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = format ; - sfinfo.channels = 2 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ; - sf_close (file) ; - - /* Open file in again for reading. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - /* Read in the whole file. */ - test_read_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ; - - /* Now hammer seeking code. */ - test_seek_or_die (file, 234, SEEK_SET, 234, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (234 * sfinfo.channels), 10, __LINE__) ; - - test_seek_or_die (file, 442, SEEK_SET, 442, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (442 * sfinfo.channels), 10, __LINE__) ; - - test_seek_or_die (file, 12, SEEK_CUR, 442 + 10 + 12, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + ((442 + 10 + 12) * sfinfo.channels), 10, __LINE__) ; - - test_seek_or_die (file, 12, SEEK_CUR, 442 + 20 + 24, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + ((442 + 20 + 24) * sfinfo.channels), 10, __LINE__) ; - - pos = 500 - sfinfo.frames ; - test_seek_or_die (file, pos, SEEK_END, 500, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (500 * sfinfo.channels), 10, __LINE__) ; - - pos = 10 - sfinfo.frames ; - test_seek_or_die (file, pos, SEEK_END, 10, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (10 * sfinfo.channels), 10, __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - unlink (filename) ; -} /* mpeg_stereo_seek_test */ - - -int -main (void) -{ - if (HAVE_MPEG) - { mpeg_short_test () ; - mpeg_int_test () ; - mpeg_float_test () ; - mpeg_double_test () ; - - mpeg_stereo_seek_test ("mpeg_seek.mp3", SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III) ; - } - else - puts (" No MPEG tests because mpg123/lame support was not compiled in.") ; - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/tests/multi_file_test.c b/Engine/lib/libsndfile/tests/multi_file_test.c deleted file mode 100644 index 690697316..000000000 --- a/Engine/lib/libsndfile/tests/multi_file_test.c +++ /dev/null @@ -1,238 +0,0 @@ -/* -** Copyright (C) 1999-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#endif - -#if (HAVE_DECL_S_IRGRP == 0) -#include -#endif - -#include -#include -#include - -#include - -#include "utils.h" - -#define DATA_LENGTH (512) - -static void write_file_at_end (int fd, int filetype, int channels, int file_num) ; - -static void multi_file_test (const char *filename, int *formats, int format_count) ; - -static short data [DATA_LENGTH] ; - -static int wav_formats [] = -{ SF_FORMAT_WAV | SF_FORMAT_PCM_16, - SF_FORMAT_WAV | SF_FORMAT_PCM_24, - SF_FORMAT_WAV | SF_FORMAT_ULAW, - SF_FORMAT_WAV | SF_FORMAT_ALAW, - /* Lite remove start */ - SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, - SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, - /* Lite remove end */ - /*-SF_FORMAT_WAV | SF_FORMAT_GSM610 Doesn't work yet. -*/ -} ; - -static int aiff_formats [] = -{ SF_FORMAT_AIFF | SF_FORMAT_PCM_16, - SF_FORMAT_AIFF | SF_FORMAT_PCM_24, - SF_FORMAT_AIFF | SF_FORMAT_ULAW, - SF_FORMAT_AIFF | SF_FORMAT_ALAW -} ; - -static int au_formats [] = -{ SF_FORMAT_AU | SF_FORMAT_PCM_16, - SF_FORMAT_AU | SF_FORMAT_PCM_24, - SF_FORMAT_AU | SF_FORMAT_ULAW, - SF_FORMAT_AU | SF_FORMAT_ALAW -} ; - -static int verbose = SF_FALSE ; - -int -main (int argc, char **argv) -{ int do_all = 0 ; - int test_count = 0 ; - - if (argc == 3 && strcmp (argv [2], "-v") == 0) - { verbose = SF_TRUE ; - argc -- ; - } ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" wav - test WAV file functions (little endian)\n") ; - printf (" aiff - test AIFF file functions (big endian)\n") ; - printf (" au - test AU file functions\n") ; -#if 0 - printf (" svx - test 8SVX/16SV file functions\n") ; - printf (" nist - test NIST Sphere file functions\n") ; - printf (" ircam - test IRCAM file functions\n") ; - printf (" voc - Create Voice file functions\n") ; - printf (" w64 - Sonic Foundry's W64 file functions\n") ; -#endif - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all = !strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "wav")) - { multi_file_test ("multi_wav.dat", wav_formats, ARRAY_LEN (wav_formats)) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { multi_file_test ("multi_aiff.dat", aiff_formats, ARRAY_LEN (aiff_formats)) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "au")) - { multi_file_test ("multi_au.dat", au_formats, ARRAY_LEN (au_formats)) ; - test_count++ ; - } ; - - return 0 ; -} /* main */ - -/*====================================================================================== -*/ - -static void -multi_file_test (const char *filename, int *formats, int format_count) -{ SNDFILE *sndfile ; - SF_INFO sfinfo ; - SF_EMBED_FILE_INFO embed_info ; - sf_count_t filelen ; - int fd, k, file_count = 0 ; - - print_test_name ("multi_file_test", filename) ; - - unlink (filename) ; - - if ((fd = open (filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0) - { printf ("\n\nLine %d: open failed : %s\n", __LINE__, strerror (errno)) ; - exit (1) ; - } ; - - k = write (fd, "1234", 4) ; - - for (k = 0 ; k < format_count ; k++) - write_file_at_end (fd, formats [k], 2, k) ; - - filelen = file_length_fd (fd) ; - - embed_info.offset = 4 ; - embed_info.length = 0 ; - - - for (file_count = 1 ; embed_info.offset + embed_info.length < filelen ; file_count ++) - { - if (verbose) - { puts ("\n------------------------------------") ; - printf ("This offset : %" PRId64 "\n", embed_info.offset + embed_info.length) ; - } ; - - if (lseek (fd, (long) (embed_info.offset + embed_info.length), SEEK_SET) < 0) - { printf ("\n\nLine %d: lseek failed : %s\n", __LINE__, strerror (errno)) ; - exit (1) ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - if ((sndfile = sf_open_fd (fd, SFM_READ, &sfinfo, SF_FALSE)) == NULL) - { printf ("\n\nLine %d: sf_open_fd failed\n", __LINE__) ; - printf ("Embedded file number : %d offset : %" PRId64 "\n", file_count, embed_info.offset) ; - puts (sf_strerror (sndfile)) ; - dump_log_buffer (sndfile) ; - exit (1) ; - } ; - - sf_command (sndfile, SFC_GET_EMBED_FILE_INFO, &embed_info, sizeof (embed_info)) ; - - sf_close (sndfile) ; - - if (verbose) - printf ("\nNext offset : %" PRId64 "\nNext length : %" PRId64 "\n", embed_info.offset, embed_info.length) ; - } ; - - file_count -- ; - - if (file_count != format_count) - { printf ("\n\nLine %d: file count (%d) not equal to %d.\n\n", __LINE__, file_count, format_count) ; - printf ("Embedded file number : %d\n", file_count) ; - exit (1) ; - } ; - - close (fd) ; - unlink (filename) ; - printf ("ok\n") ; - - return ; -} /* multi_file_test */ - -/*====================================================================================== -*/ - -static void -write_file_at_end (int fd, int filetype, int channels, int file_num) -{ SNDFILE *sndfile ; - SF_INFO sfinfo ; - - int frames, k ; - - lseek (fd, 0, SEEK_END) ; - - for (k = 0 ; k < DATA_LENGTH ; k++) - data [k] = k ; - - frames = DATA_LENGTH / channels ; - - sfinfo.format = filetype ; - sfinfo.channels = channels ; - sfinfo.samplerate = 44100 ; - - if ((sndfile = sf_open_fd (fd, SFM_WRITE, &sfinfo, SF_FALSE)) == NULL) - { printf ("\n\nLine %d: sf_open_fd failed\n", __LINE__) ; - printf ("Embedded file number : %d\n", file_num) ; - puts (sf_strerror (sndfile)) ; - dump_log_buffer (sndfile) ; - exit (1) ; - } ; - - if (sf_writef_short (sndfile, data, frames) != frames) - { printf ("\n\nLine %d: short write\n", __LINE__) ; - printf ("Embedded file number : %d\n", file_num) ; - exit (1) ; - } ; - - sf_close (sndfile) ; -} /* write_file_at_end */ - diff --git a/Engine/lib/libsndfile/tests/ogg_opus_test.c b/Engine/lib/libsndfile/tests/ogg_opus_test.c deleted file mode 100644 index a850908c2..000000000 --- a/Engine/lib/libsndfile/tests/ogg_opus_test.c +++ /dev/null @@ -1,424 +0,0 @@ -/* -** Copyright (C) 2007-2018 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include -#include -#include - -#include "utils.h" - -#define SAMPLE_RATE 48000 -#define DATA_LENGTH (SAMPLE_RATE / 8) - -typedef union -{ double d [DATA_LENGTH] ; - float f [DATA_LENGTH] ; - int i [DATA_LENGTH] ; - short s [DATA_LENGTH] ; -} BUFFER ; - -static BUFFER data_out ; -static BUFFER data_in ; - -static void -ogg_opus_short_test (void) -{ const char * filename = "ogg_opus_short.opus" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - short seek_data [10] ; - unsigned k ; - - print_test_name ("ogg_opus_short_test", filename) ; - - /* Generate float data. */ - gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7F00) ; - - /* Convert to short. */ - for (k = 0 ; k < ARRAY_LEN (data_out.s) ; k++) - data_out.s [k] = (short) lrintf (data_out.f [k]) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_OPUS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_short_or_die (file, 0, data_out.s, ARRAY_LEN (data_out.s), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_short_or_die (file, 0, data_in.s, ARRAY_LEN (data_in.s), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("ogg_opus_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_short_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_short_or_die (seek_data, data_in.s + 10, ARRAY_LEN (seek_data), __LINE__) ; - - /* Test seek to end of file. */ - test_seek_or_die (file, 0, SEEK_END, sfinfo.frames, sfinfo.channels, __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* ogg_opus_short_test */ - -static void -ogg_opus_int_test (void) -{ const char * filename = "ogg_opus_int.opus" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - int seek_data [10] ; - unsigned k ; - - print_test_name ("ogg_opus_int_test", filename) ; - - /* Generate float data. */ - gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7FFF0000) ; - - /* Convert to integer. */ - for (k = 0 ; k < ARRAY_LEN (data_out.i) ; k++) - data_out.i [k] = lrintf (data_out.f [k]) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_OPUS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_int_or_die (file, 0, data_out.i, ARRAY_LEN (data_out.i), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_int_or_die (file, 0, data_in.i, ARRAY_LEN (data_in.i), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("ogg_opus_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_int_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_int_or_die (seek_data, data_in.i + 10, ARRAY_LEN (seek_data), __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* ogg_opus_int_test */ - -static void -ogg_opus_float_test (void) -{ const char * filename = "ogg_opus_float.opus" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - float seek_data [10] ; - - print_test_name ("ogg_opus_float_test", filename) ; - - gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 0.95) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_OPUS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_float_or_die (file, 0, data_out.f, ARRAY_LEN (data_out.f), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_float_or_die (file, 0, data_in.f, ARRAY_LEN (data_in.f), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("ogg_opus_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_float_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_float_or_die (seek_data, data_in.f + 10, ARRAY_LEN (seek_data), __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* ogg_opus_float_test */ - -static void -ogg_opus_double_test (void) -{ const char * filename = "ogg_opus_double.opus" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - double seek_data [10] ; - - print_test_name ("ogg_opus_double_test", filename) ; - - gen_windowed_sine_double (data_out.d, ARRAY_LEN (data_out.d), 0.95) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_OPUS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_double_or_die (file, 0, data_out.d, ARRAY_LEN (data_out.d), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_double_or_die (file, 0, data_in.d, ARRAY_LEN (data_in.d), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("ogg_opus_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_double_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_double_or_die (seek_data, data_in.d + 10, ARRAY_LEN (seek_data), __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* ogg_opus_double_test */ - - -static void -ogg_opus_stereo_seek_test (const char * filename, int format) -{ static float data [SAMPLE_RATE] ; - static float stereo_out [SAMPLE_RATE * 2] ; - - SNDFILE * file ; - SF_INFO sfinfo ; - sf_count_t pos ; - unsigned k ; - - print_test_name (__func__, filename) ; - - gen_windowed_sine_float (data, ARRAY_LEN (data), 0.95) ; - for (k = 0 ; k < ARRAY_LEN (data) ; k++) - { stereo_out [2 * k] = data [k] ; - stereo_out [2 * k + 1] = data [ARRAY_LEN (data) - k - 1] ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = format ; - sfinfo.channels = 2 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ; - sf_close (file) ; - - /* Open file in again for reading. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - /* Read in the whole file. */ - test_read_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ; - - /* Now hammer seeking code. */ - test_seek_or_die (file, 234, SEEK_SET, 234, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (234 * sfinfo.channels), 10, __LINE__) ; - - test_seek_or_die (file, 442, SEEK_SET, 442, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (442 * sfinfo.channels), 10, __LINE__) ; - - test_seek_or_die (file, 12, SEEK_CUR, 442 + 10 + 12, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + ((442 + 10 + 12) * sfinfo.channels), 10, __LINE__) ; - - test_seek_or_die (file, 12, SEEK_CUR, 442 + 20 + 24, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + ((442 + 20 + 24) * sfinfo.channels), 10, __LINE__) ; - - pos = 500 - sfinfo.frames ; - test_seek_or_die (file, pos, SEEK_END, 500, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (500 * sfinfo.channels), 10, __LINE__) ; - - pos = 10 - sfinfo.frames ; - test_seek_or_die (file, pos, SEEK_END, 10, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (10 * sfinfo.channels), 10, __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - unlink (filename) ; -} /* ogg_opus_stereo_seek_test */ - - -static void -ogg_opus_original_samplerate_test (void) -{ const char * filename = "ogg_opus_original_samplerate.opus" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - int original_samplerate = 54321 ; - sf_count_t frames ; - - print_test_name ("ogg_opus_original_samplerate_test", filename) ; - - gen_windowed_sine_double (data_out.d, ARRAY_LEN (data_out.d), 0.95) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_OPUS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - if (sf_command (file, SFC_SET_ORIGINAL_SAMPLERATE, &original_samplerate, sizeof (original_samplerate)) != SF_TRUE) - { printf ("\nCommand SFC_SET_ORIGINAL_SAMPLERATE failed!\n") ; - exit (1) ; - } ; - test_write_double_or_die (file, 0, data_out.d, ARRAY_LEN (data_out.d), __LINE__) ; - if (sf_command (file, SFC_SET_ORIGINAL_SAMPLERATE, &original_samplerate, sizeof (original_samplerate)) != SF_FALSE) - { printf ("\nCommand SFC_SET_ORIGINAL_SAMPLERATE succeeded when it should have failed!") ; - exit (1) ; - } ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - original_samplerate = 0 ; - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - if (sf_command (file, SFC_GET_ORIGINAL_SAMPLERATE, &original_samplerate, sizeof (original_samplerate)) != SF_TRUE - || original_samplerate != 54321) - { printf ("\nCommand SFC_GET_ORIGINAL_SAMPLERATE failed!\n") ; - exit (1) ; - } ; - test_read_double_or_die (file, 0, data_in.d, 8, __LINE__) ; - if (sf_command (file, SFC_SET_ORIGINAL_SAMPLERATE, &original_samplerate, sizeof (original_samplerate)) == SF_TRUE) - { printf ("\nCommand SFC_SET_ORIGINAL_SAMPLERATE succeeded when it should have failed!\n") ; - exit (1) ; - } ; - sf_close (file) ; - - /* Test changing the decoder. */ - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - frames = sfinfo.frames ; - original_samplerate = 16000 ; - if (sf_command (file, SFC_SET_ORIGINAL_SAMPLERATE, &original_samplerate, sizeof (original_samplerate)) != SF_TRUE) - { printf ("\nCommand SFC_SET_ORIGINAL_SAMPLERATE failed!\n") ; - exit (1) ; - } ; - if (sf_command (file, SFC_GET_CURRENT_SF_INFO, &sfinfo, sizeof (sfinfo))) - { printf ("\nCommand SFC_GET_CURRENT_SF_INFO failed!\n") ; - exit (1) ; - } ; - if (frames / (48000 / 16000) != sfinfo.frames) - { printf ("\nIncorrect frame count! (%" PRId64 " vs %" PRId64")\n", frames / (48000 / 16000), sfinfo.frames) ; - exit (1) ; - } ; - test_read_double_or_die (file, 0, data_out.d, sfinfo.frames, __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* ogg_opus_original_samplerate_test */ - - -int -main (void) -{ - if (HAVE_EXTERNAL_XIPH_LIBS) - { ogg_opus_short_test () ; - ogg_opus_int_test () ; - ogg_opus_float_test () ; - ogg_opus_double_test () ; - - ogg_opus_stereo_seek_test ("ogg_opus_seek.opus", SF_FORMAT_OGG | SF_FORMAT_OPUS) ; - ogg_opus_original_samplerate_test () ; - } - else - puts (" No Ogg/Opus tests because Ogg/Opus support was not compiled in.") ; - - return 0 ; -} /* main */ diff --git a/Engine/lib/libsndfile/tests/ogg_test.c b/Engine/lib/libsndfile/tests/ogg_test.c deleted file mode 100644 index dcc5ed196..000000000 --- a/Engine/lib/libsndfile/tests/ogg_test.c +++ /dev/null @@ -1,348 +0,0 @@ -/* -** Copyright (C) 2007-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include - -#include "utils.h" - -#define SAMPLE_RATE 44100 -#define DATA_LENGTH (SAMPLE_RATE / 8) - -typedef union -{ double d [DATA_LENGTH] ; - float f [DATA_LENGTH] ; - int i [DATA_LENGTH] ; - short s [DATA_LENGTH] ; -} BUFFER ; - -static BUFFER data_out ; -static BUFFER data_in ; - -static void -ogg_short_test (void) -{ const char * filename = "vorbis_short.oga" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - short seek_data [10] ; - unsigned k ; - - print_test_name ("ogg_short_test", filename) ; - - /* Generate float data. */ - gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7F00) ; - - /* Convert to shorteger. */ - for (k = 0 ; k < ARRAY_LEN (data_out.s) ; k++) - data_out.s [k] = (short) lrintf (data_out.f [k]) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_short_or_die (file, 0, data_out.s, ARRAY_LEN (data_out.s), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_short_or_die (file, 0, data_in.s, ARRAY_LEN (data_in.s), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("ogg_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_short_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_short_or_die (seek_data, data_in.s + 10, ARRAY_LEN (seek_data), __LINE__) ; - - /* Test seek to end of file. */ - test_seek_or_die (file, 0, SEEK_END, sfinfo.frames, sfinfo.channels, __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* ogg_short_test */ - -static void -ogg_int_test (void) -{ const char * filename = "vorbis_int.oga" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - int seek_data [10] ; - unsigned k ; - - print_test_name ("ogg_int_test", filename) ; - - /* Generate float data. */ - gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7FFF0000) ; - - /* Convert to integer. */ - for (k = 0 ; k < ARRAY_LEN (data_out.i) ; k++) - data_out.i [k] = lrintf (data_out.f [k]) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_int_or_die (file, 0, data_out.i, ARRAY_LEN (data_out.i), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_int_or_die (file, 0, data_in.i, ARRAY_LEN (data_in.i), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("ogg_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_int_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_int_or_die (seek_data, data_in.i + 10, ARRAY_LEN (seek_data), __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* ogg_int_test */ - -static void -ogg_float_test (void) -{ const char * filename = "vorbis_float.oga" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - float seek_data [10] ; - - print_test_name ("ogg_float_test", filename) ; - - gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 0.95) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_float_or_die (file, 0, data_out.f, ARRAY_LEN (data_out.f), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_float_or_die (file, 0, data_in.f, ARRAY_LEN (data_in.f), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("ogg_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_float_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_float_or_die (seek_data, data_in.f + 10, ARRAY_LEN (seek_data), __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* ogg_float_test */ - -static void -ogg_double_test (void) -{ const char * filename = "vorbis_double.oga" ; - - SNDFILE * file ; - SF_INFO sfinfo ; - double seek_data [10] ; - - print_test_name ("ogg_double_test", filename) ; - - gen_windowed_sine_double (data_out.d, ARRAY_LEN (data_out.d), 0.95) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ; - sfinfo.channels = 1 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_double_or_die (file, 0, data_out.d, ARRAY_LEN (data_out.d), __LINE__) ; - sf_close (file) ; - - /* Read the file in again. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - test_read_double_or_die (file, 0, data_in.d, ARRAY_LEN (data_in.d), __LINE__) ; - sf_close (file) ; - - puts ("ok") ; - - /* Test seeking. */ - print_test_name ("ogg_seek_test", filename) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - test_read_double_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; - compare_double_or_die (seek_data, data_in.d + 10, ARRAY_LEN (seek_data), __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; -} /* ogg_double_test */ - - -static void -ogg_stereo_seek_test (const char * filename, int format) -{ static float data [SAMPLE_RATE] ; - static float stereo_out [SAMPLE_RATE * 2] ; - - SNDFILE * file ; - SF_INFO sfinfo ; - sf_count_t pos ; - unsigned k ; - - print_test_name (__func__, filename) ; - - gen_windowed_sine_float (data, ARRAY_LEN (data), 0.95) ; - for (k = 0 ; k < ARRAY_LEN (data) ; k++) - { stereo_out [2 * k] = data [k] ; - stereo_out [2 * k + 1] = data [ARRAY_LEN (data) - k - 1] ; - } ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - /* Set up output file type. */ - sfinfo.format = format ; - sfinfo.channels = 2 ; - sfinfo.samplerate = SAMPLE_RATE ; - - /* Write the output file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - test_write_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ; - sf_close (file) ; - - /* Open file in again for reading. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - /* Read in the whole file. */ - test_read_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ; - - /* Now hammer seeking code. */ - test_seek_or_die (file, 234, SEEK_SET, 234, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (234 * sfinfo.channels), 10, __LINE__) ; - - test_seek_or_die (file, 442, SEEK_SET, 442, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (442 * sfinfo.channels), 10, __LINE__) ; - - test_seek_or_die (file, 12, SEEK_CUR, 442 + 10 + 12, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + ((442 + 10 + 12) * sfinfo.channels), 10, __LINE__) ; - - test_seek_or_die (file, 12, SEEK_CUR, 442 + 20 + 24, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + ((442 + 20 + 24) * sfinfo.channels), 10, __LINE__) ; - - pos = 500 - sfinfo.frames ; - test_seek_or_die (file, pos, SEEK_END, 500, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (500 * sfinfo.channels), 10, __LINE__) ; - - pos = 10 - sfinfo.frames ; - test_seek_or_die (file, pos, SEEK_END, 10, sfinfo.channels, __LINE__) ; - test_readf_float_or_die (file, 0, data, 10, __LINE__) ; - compare_float_or_die (data, stereo_out + (10 * sfinfo.channels), 10, __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; - unlink (filename) ; -} /* ogg_stereo_seek_test */ - - -int -main (void) -{ - if (HAVE_EXTERNAL_XIPH_LIBS) - { ogg_short_test () ; - ogg_int_test () ; - ogg_float_test () ; - ogg_double_test () ; - - /*-ogg_stereo_seek_test ("pcm.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;-*/ - ogg_stereo_seek_test ("vorbis_seek.ogg", SF_FORMAT_OGG | SF_FORMAT_VORBIS) ; - } - else - puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ; - - return 0 ; -} /* main */ diff --git a/Engine/lib/libsndfile/tests/pcm_test.def b/Engine/lib/libsndfile/tests/pcm_test.def deleted file mode 100644 index 2cc91b5f3..000000000 --- a/Engine/lib/libsndfile/tests/pcm_test.def +++ /dev/null @@ -1,34 +0,0 @@ -autogen definitions pcm_test.tpl; - -data_type = { - name = "bits_8" ; - item_count = 127 ; - short_func = "arith_shift_left (k * ((k % 2) ? 1 : -1), 8)" ; - int_func = "arith_shift_left (k * ((k % 2) ? 1 : -1), 24)" ; - float_func = "(k * ((k % 2) ? 1 : -1))" ; - } ; - -data_type = { - name = "bits_16" ; - item_count = 1024 ; - short_func = "(k * ((k % 2) ? 3 : -3))" ; - int_func = "arith_shift_left (k * ((k % 2) ? 3 : -3), 16)" ; - float_func = "(k * ((k % 2) ? 3 : -3))" ; - } ; - -data_type = { - name = "bits_24" ; - item_count = 1024 ; - short_func = "(k * ((k % 2) ? 3 : -3))" ; - int_func = "arith_shift_left (k * ((k % 2) ? 3333 : -3333), 8)" ; - float_func = "(k * ((k % 2) ? 3333 : -3333))" ; - } ; - -data_type = { - name = "bits_32" ; - item_count = 1024 ; - short_func = "(k * ((k % 2) ? 3 : -3))" ; - int_func = "(k * ((k % 2) ? 333333 : -333333))" ; - float_func = "(k * ((k % 2) ? 333333 : -333333))" ; - } ; - diff --git a/Engine/lib/libsndfile/tests/pcm_test.tpl b/Engine/lib/libsndfile/tests/pcm_test.tpl deleted file mode 100644 index 11226fb98..000000000 --- a/Engine/lib/libsndfile/tests/pcm_test.tpl +++ /dev/null @@ -1,919 +0,0 @@ -[+ AutoGen5 template c +] -/* -** Copyright (C) 1999-2013 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_SIZE (1 << 12) - -static void lrintf_test (void) ; - -[+ FOR data_type -+]static void pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash) ; -[+ ENDFOR data_type -+] -static void pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_float) ; -static void pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_float) ; - -typedef union -{ double d [BUFFER_SIZE + 1] ; - float f [BUFFER_SIZE + 1] ; - int i [BUFFER_SIZE + 1] ; - short s [BUFFER_SIZE + 1] ; -} BUFFER ; - -/* Data written to the file. */ -static BUFFER data_out ; - -/* Data read back from the file. */ -static BUFFER data_in ; - -int -main (void) -{ - lrintf_test () ; - - pcm_test_bits_8 ("pcm-s8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_S8, 0xa335091249dbfLL) ; - pcm_test_bits_8 ("pcm-u8.raw", SF_FORMAT_RAW | SF_FORMAT_PCM_U8, 0x48c433d695f3fLL) ; - - pcm_test_bits_16 ("le-pcm16.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0xb956c881ebf08LL) ; - pcm_test_bits_16 ("be-pcm16.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, 0x2f840c55750f8LL) ; - - pcm_test_bits_24 ("le-pcm24.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0xb6a759ab496f8LL) ; - pcm_test_bits_24 ("be-pcm24.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_24, 0xf3eaf9c30b6f8LL) ; - - pcm_test_bits_32 ("le-pcm32.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0xaece1c1c17f08LL) ; - pcm_test_bits_32 ("be-pcm32.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, 0x9ddf142d0b0f8LL) ; - - /* Lite remove start */ - pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xad04f7554267aLL, SF_FALSE) ; - pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xde3e248fa9186LL, SF_FALSE) ; - - pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0x2726f958f669cLL, SF_FALSE) ; - pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0x3583f8ee51164LL, SF_FALSE) ; - - pcm_test_float ("le-float.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xad04f7554267aLL, SF_TRUE) ; - pcm_test_float ("be-float.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT, 0xde3e248fa9186LL, SF_TRUE) ; - - pcm_test_double ("le-double.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0x2726f958f669cLL, SF_TRUE) ; - pcm_test_double ("be-double.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, 0x3583f8ee51164LL, SF_TRUE) ; - /* Lite remove end */ - - return 0 ; -} /* main */ - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -lrintf_test (void) -{ int k, items ; - float *float_data ; - int *int_data ; - - print_test_name ("lrintf_test", "") ; - - items = 1024 ; - - float_data = data_out.f ; - int_data = data_in.i ; - - for (k = 0 ; k < items ; k++) - float_data [k] = (k * ((k % 2) ? 333333.0 : -333333.0)) ; - - for (k = 0 ; k < items ; k++) - int_data [k] = lrintf (float_data [k]) ; - - for (k = 0 ; k < items ; k++) - if (fabs (int_data [k] - float_data [k]) > 1.0) - { printf ("\n\nLine %d: float : Incorrect sample (#%d : %f => %d).\n", __LINE__, k, float_data [k], int_data [k]) ; - exit (1) ; - } ; - - printf ("ok\n") ; -} /* lrintf_test */ - -[+ FOR data_type -+]static void -pcm_test_[+ (get "name") +] (const char *filename, int filetype, uint64_t hash) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, items, zero_count ; - short *short_out, *short_in ; - int *int_out, *int_in ; - /* Lite remove start */ - float *float_out, *float_in ; - double *double_out, *double_in ; - /* Lite remove end */ - - print_test_name ("pcm_test_[+ (get "name") +]", filename) ; - - items = [+ (get "item_count") +] ; - - short_out = data_out.s ; - short_in = data_in.s ; - - zero_count = 0 ; - for (k = 0 ; k < items ; k++) - { short_out [k] = [+ (get "short_func") +] ; - zero_count = short_out [k] ? zero_count : zero_count + 1 ; - } ; - - if (zero_count > items / 4) - { printf ("\n\nLine %d: too many zeros.\n", __LINE__) ; - exit (1) ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - test_write_short_or_die (file, 0, short_out, items, __LINE__) ; - - sf_close (file) ; - - memset (short_in, 0, items * sizeof (short)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != items) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %" PRId64 ")\n", __LINE__, items, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_short_or_die (file, 0, short_in, items, __LINE__) ; - - for (k = 0 ; k < items ; k++) - if (short_out [k] != short_in [k]) - { printf ("\n\nLine %d: Incorrect sample (#%d : 0x%x => 0x%x).\n", __LINE__, k, short_out [k], short_in [k]) ; - exit (1) ; - } ; - - sf_close (file) ; - - /* Finally, check the file hash. */ - check_file_hash_or_die (filename, hash, __LINE__) ; - - /*-------------------------------------------------------------------------- - ** Test sf_read/write_int () - */ - zero_count = 0 ; - - int_out = data_out.i ; - int_in = data_in.i ; - for (k = 0 ; k < items ; k++) - { int_out [k] = [+ (get "int_func") +] ; - zero_count = int_out [k] ? zero_count : zero_count + 1 ; - } ; - - if (zero_count > items / 4) - { printf ("\n\nLine %d: too many zeros.\n", __LINE__) ; - exit (1) ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - test_write_int_or_die (file, 0, int_out, items, __LINE__) ; - - sf_close (file) ; - - memset (int_in, 0, items * sizeof (int)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != items) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %" PRId64 ")\n", __LINE__, items, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_int_or_die (file, 0, int_in, items, __LINE__) ; - - for (k = 0 ; k < items ; k++) - if (int_out [k] != int_in [k]) - { printf ("\n\nLine %d: int : Incorrect sample (#%d : 0x%x => 0x%x).\n", __LINE__, k, int_out [k], int_in [k]) ; - exit (1) ; - } ; - - sf_close (file) ; - - /* Lite remove start */ - /*-------------------------------------------------------------------------- - ** Test sf_read/write_float () - */ - zero_count = 0 ; - - float_out = data_out.f ; - float_in = data_in.f ; - for (k = 0 ; k < items ; k++) - { float_out [k] = [+ (get "float_func") +] ; - zero_count = (fabs (float_out [k]) > 1e-10) ? zero_count : zero_count + 1 ; - } ; - - if (zero_count > items / 4) - { printf ("\n\nLine %d: too many zeros (%d/%d).\n", __LINE__, zero_count, items) ; - exit (1) ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - - test_write_float_or_die (file, 0, float_out, items, __LINE__) ; - - sf_close (file) ; - - memset (float_in, 0, items * sizeof (float)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != items) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %" PRId64 ")\n", __LINE__, items, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - sf_command (file, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ; - - test_read_float_or_die (file, 0, float_in, items, __LINE__) ; - - for (k = 0 ; k < items ; k++) - if (fabs (float_out [k] - float_in [k]) > 1e-10) - { printf ("\n\nLine %d: float : Incorrect sample (#%d : %f => %f).\n", __LINE__, k, (double) float_out [k], (double) float_in [k]) ; - exit (1) ; - } ; - - sf_close (file) ; - - /*-------------------------------------------------------------------------- - ** Test sf_read/write_double () - */ - zero_count = 0 ; - - double_out = data_out.d ; - double_in = data_in.d ; - for (k = 0 ; k < items ; k++) - { double_out [k] = [+ (get "float_func") +] ; - zero_count = (fabs (double_out [k]) > 1e-10) ? zero_count : zero_count + 1 ; - } ; - - if (zero_count > items / 4) - { printf ("\n\nLine %d: too many zeros (%d/%d).\n", __LINE__, zero_count, items) ; - exit (1) ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - - test_write_double_or_die (file, 0, double_out, items, __LINE__) ; - - sf_close (file) ; - - memset (double_in, 0, items * sizeof (double)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != items) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %" PRId64 ")\n", __LINE__, items, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ; - - test_read_double_or_die (file, 0, double_in, items, __LINE__) ; - - for (k = 0 ; k < items ; k++) - if (fabs (double_out [k] - double_in [k]) > 1e-10) - { printf ("\n\nLine %d: double : Incorrect sample (#%d : %f => %f).\n", __LINE__, k, double_out [k], double_in [k]) ; - exit (1) ; - } ; - - sf_close (file) ; - /* Lite remove end */ - unlink (filename) ; - - puts ("ok") ; -} /* pcm_test_[+ (get "name") +] */ - -[+ ENDFOR data_type -+] - -/*============================================================================== -*/ - -static void -pcm_test_float (const char *filename, int filetype, uint64_t hash, int replace_float) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, items, frames ; - int sign ; - double *data, error ; - - print_test_name (replace_float ? "pcm_test_float (replace)" : "pcm_test_float", filename) ; - - items = BUFFER_SIZE ; - - data = data_out.d ; - for (sign = 1, k = 0 ; k < items ; k++) - { data [k] = ((double) (k * sign)) / 100.0 ; - sign = (sign > 0) ? -1 : 1 ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = items ; - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - if (replace_float && string_in_log_buffer (file, "Using IEEE replacement") == 0) - { printf ("\n\nLine %d : Float replacement code not working.\n\n", __LINE__) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - test_write_double_or_die (file, 0, data, items, __LINE__) ; - - sf_close (file) ; - - check_file_hash_or_die (filename, hash, __LINE__) ; - - memset (data, 0, items * sizeof (double)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - if (replace_float && string_in_log_buffer (file, "Using IEEE replacement") == 0) - { printf ("\n\nLine %d : Float replacement code not working.\n\n", __LINE__) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - if (sfinfo.format != filetype) - { printf ("\n\nError (%s:%d) Mono : Returned format incorrect (0x%08X => 0x%08X).\n", __FILE__, __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != items) - { printf ("\n\nError (%s:%d) Mono : Incorrect number of frames in file. (%d => %" PRId64 ")\n", __FILE__, __LINE__, items, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nError (%s:%d) Mono : Incorrect number of channels in file.\n", __FILE__, __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_double_or_die (file, 0, data, items, __LINE__) ; - - for (sign = -1, k = 0 ; k < items ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to end of file. */ - test_seek_or_die (file, 0, SEEK_END, sfinfo.frames, sfinfo.channels, __LINE__) ; - - /* Seek to start of file. */ - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data, 4, __LINE__) ; - for (k = 0 ; k < 4 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from start of file. */ - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data + 10, 4, __LINE__) ; - for (k = 10 ; k < 14 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from current position. */ - test_seek_or_die (file, 6, SEEK_CUR, 20, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data + 20, 4, __LINE__) ; - for (k = 20 ; k < 24 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from end of file. */ - test_seek_or_die (file, -1 * (sfinfo.frames - 10), SEEK_END, 10, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data + 10, 4, __LINE__) ; - for (k = 10 ; k < 14 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - sf_close (file) ; - - /* Now test Stereo. */ - - if ((filetype & SF_FORMAT_TYPEMASK) == SF_FORMAT_SVX) /* SVX is mono only */ - { printf ("ok\n") ; - return ; - } ; - - items = BUFFER_SIZE ; - - data = data_out.d ; - for (sign = -1, k = 0 ; k < items ; k++) - data [k] = ((double) k) / 100.0 * (sign *= -1) ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = items ; - sfinfo.channels = 2 ; - sfinfo.format = filetype ; - - frames = items / sfinfo.channels ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - if (replace_float && string_in_log_buffer (file, "Using IEEE replacement") == 0) - { printf ("\n\nLine %d : Float replacement code not working.\n\n", __LINE__) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - test_writef_double_or_die (file, 0, data, frames, __LINE__) ; - - sf_close (file) ; - - check_file_hash_or_die (filename, hash, __LINE__) ; - - memset (data, 0, items * sizeof (double)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - if (replace_float && string_in_log_buffer (file, "Using IEEE replacement") == 0) - { printf ("\n\nLine %d : Float replacement code not working.\n\n", __LINE__) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - if (sfinfo.format != filetype) - { printf ("\n\nError (%s:%d) Stereo : Returned format incorrect (0x%08X => 0x%08X).\n", __FILE__, __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != frames) - { printf ("\n\nError (%s:%d) Stereo : Incorrect number of frames in file. (%d => %" PRId64 ")\n", __FILE__, __LINE__, frames, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 2) - { printf ("\n\nError (%s:%d) Stereo : Incorrect number of channels in file.\n", __FILE__, __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_readf_double_or_die (file, 0, data, frames, __LINE__) ; - for (sign = -1, k = 0 ; k < items ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to start of file. */ - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - test_readf_double_or_die (file, 0, data, 4, __LINE__) ; - for (k = 0 ; k < 4 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from start of file. */ - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - - test_readf_double_or_die (file, 0, data + 20, 2, __LINE__) ; - for (k = 20 ; k < 24 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from current position. */ - test_seek_or_die (file, 8, SEEK_CUR, 20, sfinfo.channels, __LINE__) ; - - test_readf_double_or_die (file, 0, data + 40, 2, __LINE__) ; - for (k = 40 ; k < 44 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from end of file. */ - test_seek_or_die (file, -1 * (sfinfo.frames - 10), SEEK_END, 10, sfinfo.channels, __LINE__) ; - - test_readf_double_or_die (file, 0, data + 20, 2, __LINE__) ; - for (k = 20 ; k < 24 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - sf_close (file) ; - - printf ("ok\n") ; - unlink (filename) ; -} /* pcm_test_float */ - -static void -pcm_test_double (const char *filename, int filetype, uint64_t hash, int replace_float) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, items, frames ; - int sign ; - double *data, error ; - - /* This is the best test routine. Other should be brought up to this standard. */ - - print_test_name (replace_float ? "pcm_test_double (replace)" : "pcm_test_double", filename) ; - - items = BUFFER_SIZE ; - - data = data_out.d ; - for (sign = 1, k = 0 ; k < items ; k++) - { data [k] = ((double) (k * sign)) / 100.0 ; - sign = (sign > 0) ? -1 : 1 ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = items ; - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - if (replace_float && string_in_log_buffer (file, "Using IEEE replacement") == 0) - { printf ("\n\nLine %d : Float replacement code not working.\n\n", __LINE__) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - test_write_double_or_die (file, 0, data, items, __LINE__) ; - - sf_close (file) ; - - check_file_hash_or_die (filename, hash, __LINE__) ; - - memset (data, 0, items * sizeof (double)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - if (replace_float && string_in_log_buffer (file, "Using IEEE replacement") == 0) - { printf ("\n\nLine %d : Float replacement code not working.\n\n", __LINE__) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - if (sfinfo.format != filetype) - { printf ("\n\nError (%s:%d) Mono : Returned format incorrect (0x%08X => 0x%08X).\n", __FILE__, __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != items) - { printf ("\n\nError (%s:%d) Mono : Incorrect number of frames in file. (%d => %" PRId64 ")\n", __FILE__, __LINE__, items, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nError (%s:%d) Mono : Incorrect number of channels in file.\n", __FILE__, __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_double_or_die (file, 0, data, items, __LINE__) ; - - for (sign = -1, k = 0 ; k < items ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to start of file. */ - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data, 4, __LINE__) ; - for (k = 0 ; k < 4 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from start of file. */ - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data + 10, 4, __LINE__) ; - - test_seek_or_die (file, 0, SEEK_CUR, 14, sfinfo.channels, __LINE__) ; - - for (k = 10 ; k < 14 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from current position. */ - test_seek_or_die (file, 6, SEEK_CUR, 20, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data + 20, 4, __LINE__) ; - for (k = 20 ; k < 24 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from end of file. */ - test_seek_or_die (file, -1 * (sfinfo.frames - 10), SEEK_END, 10, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data + 10, 4, __LINE__) ; - for (k = 10 ; k < 14 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Mono : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - sf_close (file) ; - - /* Now test Stereo. */ - - if ((filetype & SF_FORMAT_TYPEMASK) == SF_FORMAT_SVX) /* SVX is mono only */ - { printf ("ok\n") ; - return ; - } ; - - items = BUFFER_SIZE ; - - data = data_out.d ; - for (sign = -1, k = 0 ; k < items ; k++) - data [k] = ((double) k) / 100.0 * (sign *= -1) ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = items ; - sfinfo.channels = 2 ; - sfinfo.format = filetype ; - - frames = items / sfinfo.channels ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - if (replace_float && string_in_log_buffer (file, "Using IEEE replacement") == 0) - { printf ("\n\nLine %d : Float replacement code not working.\n\n", __LINE__) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - test_writef_double_or_die (file, 0, data, frames, __LINE__) ; - - sf_close (file) ; - - check_file_hash_or_die (filename, hash, __LINE__) ; - - memset (data, 0, items * sizeof (double)) ; - - if ((filetype & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ; - if (replace_float && string_in_log_buffer (file, "Using IEEE replacement") == 0) - { printf ("\n\nLine %d : Float replacement code not working.\n\n", __LINE__) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - if (sfinfo.format != filetype) - { printf ("\n\nError (%s:%d) Stereo : Returned format incorrect (0x%08X => 0x%08X).\n", __FILE__, __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != frames) - { printf ("\n\nError (%s:%d) Stereo : Incorrect number of frames in file. (%d => %" PRId64 ")\n", __FILE__, __LINE__, frames, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 2) - { printf ("\n\nError (%s:%d) Stereo : Incorrect number of channels in file.\n", __FILE__, __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_readf_double_or_die (file, 0, data, frames, __LINE__) ; - - for (sign = -1, k = 0 ; k < items ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to start of file. */ - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data, 4, __LINE__) ; - for (k = 0 ; k < 4 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from start of file. */ - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - - test_read_double_or_die (file, 0, data + 10, 4, __LINE__) ; - for (k = 20 ; k < 24 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from current position. */ - test_seek_or_die (file, 8, SEEK_CUR, 20, sfinfo.channels, __LINE__) ; - - test_readf_double_or_die (file, 0, data + 40, 4, __LINE__) ; - for (k = 40 ; k < 44 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - /* Seek to offset from end of file. */ - test_seek_or_die (file, -1 * (sfinfo.frames -10), SEEK_END, 10, sfinfo.channels, __LINE__) ; - - test_readf_double_or_die (file, 0, data + 20, 4, __LINE__) ; - for (k = 20 ; k < 24 ; k++) - { error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ; - if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5) - { printf ("\n\nError (%s:%d) Stereo : Incorrect sample (#%d : %f => %f).\n", __FILE__, __LINE__, k, ((double) k) / 100.0, data [k]) ; - exit (1) ; - } ; - } ; - - sf_close (file) ; - - printf ("ok\n") ; - unlink (filename) ; -} /* pcm_test_double */ - -/*============================================================================== -*/ diff --git a/Engine/lib/libsndfile/tests/peak_chunk_test.c b/Engine/lib/libsndfile/tests/peak_chunk_test.c deleted file mode 100644 index 3e1aa3d30..000000000 --- a/Engine/lib/libsndfile/tests/peak_chunk_test.c +++ /dev/null @@ -1,371 +0,0 @@ -/* -** Copyright (C) 2001-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_LEN (1 << 15) -#define LOG_BUFFER_SIZE 1024 - - -static void test_float_peak (const char *filename, int filetype) ; -static void read_write_peak_test (const char *filename, int filetype) ; - -static void check_logged_peaks (char *buffer) ; - -/* Force the start of this buffer to be double aligned. Sparc-solaris will -** choke if its not. -*/ -static double data [BUFFER_LEN] ; -static char log_buffer [LOG_BUFFER_SIZE] ; - -int -main (int argc, char *argv []) -{ int do_all = 0 ; - int test_count = 0 ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" aiff - test AIFF file PEAK chunk\n") ; - printf (" caf - test CAF file PEAK chunk\n") ; - printf (" wav - test WAV file peak chunk\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "wav")) - { test_float_peak ("peak_float.wav", SF_FORMAT_WAV | SF_FORMAT_FLOAT) ; - test_float_peak ("peak_float.wavex", SF_FORMAT_WAVEX | SF_FORMAT_FLOAT) ; - test_float_peak ("peak_float.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_FLOAT) ; - - read_write_peak_test ("rw_peak.wav", SF_FORMAT_WAV | SF_FORMAT_FLOAT) ; - read_write_peak_test ("rw_peak.wavex", SF_FORMAT_WAVEX | SF_FORMAT_FLOAT) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { test_float_peak ("peak_float.aiff", SF_FORMAT_AIFF | SF_FORMAT_FLOAT) ; - - read_write_peak_test ("rw_peak.aiff", SF_FORMAT_AIFF | SF_FORMAT_FLOAT) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "caf")) - { test_float_peak ("peak_float.caf", SF_FORMAT_CAF | SF_FORMAT_FLOAT) ; - - read_write_peak_test ("rw_peak.caf", SF_FORMAT_CAF | SF_FORMAT_FLOAT) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "rf64")) - { test_float_peak ("peak_float.rf64", SF_FORMAT_RF64 | SF_FORMAT_FLOAT) ; - - read_write_peak_test ("rw_peak.rf64", SF_FORMAT_RF64 | SF_FORMAT_FLOAT) ; - test_count++ ; - } ; - - if (test_count == 0) - { printf ("Mono : ************************************\n") ; - printf ("Mono : * No '%s' test defined.\n", argv [1]) ; - printf ("Mono : ************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -test_float_peak (const char *filename, int filetype) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, frames, count ; - - print_test_name ("test_float_peak", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.format = filetype ; - sfinfo.channels = 4 ; - sfinfo.frames = 0 ; - - frames = BUFFER_LEN / sfinfo.channels ; - - /* Create some random data with a peak value of 0.66. */ - for (k = 0 ; k < BUFFER_LEN ; k++) - data [k] = (rand () % 2000) / 3000.0 ; - - /* Insert some larger peaks a know locations. */ - data [4 * (frames / 8) + 0] = (frames / 8) * 0.01 ; /* First channel */ - data [4 * (frames / 6) + 1] = (frames / 6) * 0.01 ; /* Second channel */ - data [4 * (frames / 4) + 2] = (frames / 4) * 0.01 ; /* Third channel */ - data [4 * (frames / 2) + 3] = (frames / 2) * 0.01 ; /* Fourth channel */ - - /* Write a file with PEAK chunks. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, 0, __LINE__) ; - - /* Try to confuse the header writer by adding a removing the PEAK chunk. */ - sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ; - sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ; - sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ; - - /* Write the data in four passed. The data is designed so that peaks will - ** be written in the different calls to sf_write_double (). - */ - for (count = 0 ; count < 4 ; count ++) - test_write_double_or_die (file, 0, data + count * BUFFER_LEN / 4, BUFFER_LEN / 4, BUFFER_LEN / 4) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, 0, __LINE__) ; - - if (sfinfo.format != filetype) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != frames) - { printf ("\n\nLine %d: Incorrect number of frames in file. (%d => %ld)\n", __LINE__, frames, (long) sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 4) - { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - /* Check these two commands. */ - if (sf_command (file, SFC_GET_SIGNAL_MAX, data, sizeof (double)) == SF_FALSE) - { printf ("\n\nLine %d: Command should have returned SF_TRUE.\n", __LINE__) ; - exit (1) ; - } ; - - if (fabs (data [0] - (frames / 2) * 0.01) > 0.01) - { printf ("\n\nLine %d: Bad peak value (%f should be %f) for command SFC_GET_SIGNAL_MAX.\n", __LINE__, data [0], (frames / 2) * 0.01) ; - exit (1) ; - } ; - - if (sf_command (file, SFC_GET_MAX_ALL_CHANNELS, data, sizeof (double) * sfinfo.channels) == SF_FALSE) - { printf ("\n\nLine %d: Command should have returned SF_TRUE.\n", __LINE__) ; - exit (1) ; - } ; - - if (fabs (data [3] - (frames / 2) * 0.01) > 0.01) - { printf ("\n\nLine %d: Bad peak value (%f should be %f) for command SFC_GET_MAX_ALL_CHANNELS.\n", __LINE__, data [0], (frames / 2) * 0.01) ; - exit (1) ; - } ; - - /* Get the log buffer data. */ - log_buffer [0] = 0 ; - sf_command (file, SFC_GET_LOG_INFO, log_buffer, LOG_BUFFER_SIZE) ; - - if (strlen (log_buffer) == 0) - { printf ("\n\nLine %d: Empty log buffer,\n", __LINE__) ; - exit (1) ; - } ; - - check_logged_peaks (log_buffer) ; - - sf_close (file) ; - - /* Write a file ***without*** PEAK chunks. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, 0, __LINE__) ; - - /* Try to confuse the header writer by adding a removing the PEAK chunk. */ - sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ; - sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ; - sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ; - - /* Write the data in four passed. The data is designed so that peaks will - ** be written in the different calls to sf_write_double (). - */ - for (count = 0 ; count < 4 ; count ++) - test_write_double_or_die (file, 0, data + count * BUFFER_LEN / 4, BUFFER_LEN / 4, BUFFER_LEN / 4) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, 0, __LINE__) ; - - /* Check these two commands. */ - if (sf_command (file, SFC_GET_SIGNAL_MAX, data, sizeof (double))) - { printf ("\n\nLine %d: Command should have returned SF_FALSE.\n", __LINE__) ; - exit (1) ; - } ; - - if (sf_command (file, SFC_GET_MAX_ALL_CHANNELS, data, sizeof (double) * sfinfo.channels)) - { printf ("\n\nLine %d: Command should have returned SF_FALSE.\n", __LINE__) ; - exit (1) ; - } ; - - /* Get the log buffer data. */ - log_buffer [0] = 0 ; - sf_command (file, SFC_GET_LOG_INFO, log_buffer, LOG_BUFFER_SIZE) ; - - if (strlen (log_buffer) == 0) - { printf ("\n\nLine %d: Empty log buffer,\n", __LINE__) ; - exit (1) ; - } ; - - if (strstr (log_buffer, "PEAK :") != NULL) - { printf ("\n\nLine %d: Should not have a PEAK chunk in this file.\n\n", __LINE__) ; - puts (log_buffer) ; - exit (1) ; - } ; - - sf_close (file) ; - - unlink (filename) ; - printf ("ok\n") ; -} /* test_float_peak */ - -static void -check_logged_peaks (char *buffer) -{ char *cptr ; - int k, chan, channel_count, position ; - float value ; - - if (strstr (buffer, "should") || strstr (buffer, "*")) - { printf ("\n\nLine %d: Something wrong in buffer. Dumping.\n", __LINE__) ; - puts (buffer) ; - exit (1) ; - } ; - - channel_count = 0 ; - cptr = strstr (buffer, "Channels") ; - if (cptr && sscanf (cptr, "Channels : %d", &k) == 1) - channel_count = k ; - else if (cptr && sscanf (cptr, "Channels / frame : %d", &k) == 1) - channel_count = k ; - else - { printf ("\n\nLine %d: Couldn't find channel count.\n", __LINE__) ; - exit (1) ; - } ; - - if (channel_count != 4) - { printf ("\n\nLine %d: Wrong channel count (4 ->%d).\n", __LINE__, channel_count) ; - exit (1) ; - } ; - - if (! (cptr = strstr (buffer, "Ch Position Value"))) - { printf ("\n\nLine %d: Can't find PEAK data.\n", __LINE__) ; - exit (1) ; - } ; - - for (k = 0 ; k < channel_count ; k++) - { if (! (cptr = strchr (cptr, '\n'))) - { printf ("\n\nLine %d: Got lost.\n", __LINE__) ; - exit (1) ; - } ; - if (sscanf (cptr, "%d %d %f", &chan, &position, &value) != 3) - { printf ("\n\nLine %d: sscanf failed.\n", __LINE__) ; - exit (1) ; - } ; - if (position == 0) - { printf ("\n\nLine %d: peak position for channel %d should not be at offset 0.\n", __LINE__, chan) ; - printf ("%s", buffer) ; - exit (1) ; - } ; - if (chan != k || fabs ((position) * 0.01 - value) > 1e-6) - { printf ("\n\nLine %d: Error : peak value incorrect!\n", __LINE__) ; - printf ("%s", buffer) ; - printf ("\n\nLine %d: %d %f %f\n", __LINE__, chan, position * 0.01, value) ; - exit (1) ; - } ; - cptr ++ ; /* Move past current newline. */ - } ; - -} /* check_logged_peaks */ - -static void -read_write_peak_test (const char *filename, int filetype) -{ SNDFILE *file ; - SF_INFO sfinfo ; - - double small_data [10], max_peak = 0.0 ; - unsigned k ; - - print_test_name (__func__, filename) ; - - for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++) - small_data [k] = 0.1 ; - - sfinfo.samplerate = 44100 ; - sfinfo.channels = 2 ; - sfinfo.format = filetype ; - sfinfo.frames = 0 ; - - /* Open the file, add peak chunk and write samples with value 0.1. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - - sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ; - - test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ; - - sf_close (file) ; - - /* Open the fiel RDWR, write sample valied 1.25. */ - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; - - for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++) - small_data [k] = 1.0 ; - - test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ; - - sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ; - - sf_close (file) ; - - exit_if_true (max_peak < 0.1, "\n\nLine %d : max peak (%5.3f) should not be 0.1.\n\n", __LINE__, max_peak) ; - - /* Open the file and test the values written to the PEAK chunk. */ - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - exit_if_true (sfinfo.channels * sfinfo.frames != 2 * ARRAY_LEN (small_data), - "Line %d : frame count is %" PRId64 ", should be %zd\n", __LINE__, sfinfo.frames, 2 * ARRAY_LEN (small_data)) ; - - sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (double)) ; - - sf_close (file) ; - - exit_if_true (max_peak < 1.0, "\n\nLine %d : max peak (%5.3f) should be 1.0.\n\n", __LINE__, max_peak) ; - - unlink (filename) ; - puts ("ok") ; -} /* read_write_peak_test */ - diff --git a/Engine/lib/libsndfile/tests/pedantic-header-test.sh.in b/Engine/lib/libsndfile/tests/pedantic-header-test.sh.in deleted file mode 100644 index 561628dcf..000000000 --- a/Engine/lib/libsndfile/tests/pedantic-header-test.sh.in +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2010-2017 Erik de Castro Lopo -# -# 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 author nor the names of any 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. - - -if test ! -f @top_srcdir@/tests/sfversion.c ; then - exit 0 - fi - -echo -n " Pedantic header test : " - -# Only do this if the compiler is GCC. -if test -n "@GCC_MAJOR_VERSION@" ; then - - CC=`echo "@CC@" | sed "s/.*shave cc //"` - # Compile with -Werror and -pedantic. - $CC -std=c99 -Werror -pedantic -I@top_srcdir@/src -I@abs_top_builddir@/src -I@top_srcdir@/include -c @top_srcdir@/tests/sfversion.c -o /dev/null - - # Check compiler return status. - if test $? -ne 0 ; then - echo - exit 1 - fi - - echo "ok" -else - echo "n/a" - fi - -exit 0 diff --git a/Engine/lib/libsndfile/tests/pipe_test.def b/Engine/lib/libsndfile/tests/pipe_test.def deleted file mode 100644 index 6469cca1e..000000000 --- a/Engine/lib/libsndfile/tests/pipe_test.def +++ /dev/null @@ -1,14 +0,0 @@ -autogen definitions pipe_test.tpl; - -data_type = { - type_name = short ; - }; - -data_type = { - type_name = float ; - }; - -data_type = { - type_name = double ; - }; - diff --git a/Engine/lib/libsndfile/tests/pipe_test.tpl b/Engine/lib/libsndfile/tests/pipe_test.tpl deleted file mode 100644 index 9bb30cc79..000000000 --- a/Engine/lib/libsndfile/tests/pipe_test.tpl +++ /dev/null @@ -1,362 +0,0 @@ -[+ AutoGen5 template c +] -/* -** Copyright (C) 2001-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/*========================================================================== -** This is a test program which tests reading from and writing to pipes. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#if (OS_IS_WIN32 || defined __OS2__ || HAVE_PIPE == 0 || HAVE_WAITPID == 0) - -int -main (void) -{ - puts (" pipe_test : this test doesn't work on this OS.") ; - return 0 ; -} /* main */ - -#else - -#if HAVE_UNISTD_H -#include -#endif - -#include -#include -#include -#include - -#include - -#include "utils.h" - -typedef struct -{ int format ; - const char *ext ; -} FILETYPE ; - -static void useek_pipe_rw_test (int filetype, const char *ext) ; -static void pipe_read_test (int filetype, const char *ext) ; -static void pipe_write_test (const char *ext) ; -static void pipe_test_others (FILETYPE*, FILETYPE*) ; - -static FILETYPE read_write_types [] = -{ { SF_FORMAT_RAW , "raw" }, - { SF_FORMAT_AU , "au" }, - /* Lite remove start */ - { SF_FORMAT_PAF , "paf" }, - { SF_FORMAT_IRCAM , "ircam" }, - { SF_FORMAT_PVF , "pvf" }, - /* Lite remove end */ - { 0 , NULL } -} ; - -static FILETYPE read_only_types [] = -{ { SF_FORMAT_RAW , "raw" }, - { SF_FORMAT_AU , "au" }, - { SF_FORMAT_AIFF , "aiff" }, - { SF_FORMAT_WAV , "wav" }, - { SF_FORMAT_W64 , "w64" }, - /* Lite remove start */ - { SF_FORMAT_PAF , "paf" }, - { SF_FORMAT_NIST , "nist" }, - { SF_FORMAT_IRCAM , "ircam" }, - { SF_FORMAT_MAT4 , "mat4" }, - { SF_FORMAT_MAT5 , "mat5" }, - { SF_FORMAT_SVX , "svx" }, - { SF_FORMAT_PVF , "pvf" }, - /* Lite remove end */ - { 0 , NULL } -} ; - -int -main (void) -{ int k ; - - for (k = 0 ; read_only_types [k].format ; k++) - pipe_read_test (read_only_types [k].format, read_only_types [k].ext) ; - - for (k = 0 ; read_write_types [k].format ; k++) - pipe_write_test (read_write_types [k].ext) ; - - for (k = 0 ; read_write_types [k].format ; k++) - useek_pipe_rw_test (read_write_types [k].format, read_write_types [k].ext) ; - - if (0) - pipe_test_others (read_write_types, read_only_types) ; - - return 0 ; -} /* main */ - -/*============================================================================== -*/ - -static void -pipe_read_test (int filetype, const char *ext) -{ static short data [PIPE_TEST_LEN] ; - static char buffer [256] ; - static char filename [256] ; - - SNDFILE *outfile ; - SF_INFO sfinfo ; - int k, retval ; - - snprintf (filename, sizeof (filename), "pipe_in.%s", ext) ; - print_test_name ("pipe_read_test", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.format = filetype | SF_FORMAT_PCM_16 ; - sfinfo.channels = 1 ; - sfinfo.samplerate = 44100 ; - - for (k = 0 ; k < PIPE_TEST_LEN ; k++) - data [k] = PIPE_INDEX (k) ; - - outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - test_writef_short_or_die (outfile, 0, data, PIPE_TEST_LEN, __LINE__) ; - sf_close (outfile) ; - - snprintf (buffer, sizeof (buffer), "cat %s | ./tests/stdin_test %s ", filename, ext) ; - if ((retval = system (buffer)) != 0) - { retval = WEXITSTATUS (retval) ; - printf ("\n\n Line %d : pipe test returned error for file type \"%s\".\n\n", __LINE__, ext) ; - exit (retval) ; - } ; - - unlink (filename) ; - puts ("ok") ; - - return ; -} /* pipe_read_test */ - -static void -pipe_write_test (const char *ext) -{ static char buffer [256] ; - - int retval ; - - print_test_name ("pipe_write_test", ext) ; - - snprintf (buffer, sizeof (buffer), "./tests/stdout_test %s | ./tests/stdin_test %s ", ext, ext) ; - if ((retval = system (buffer))) - { retval = WEXITSTATUS (retval) ; - printf ("\n\n Line %d : pipe test returned error file type \"%s\".\n\n", __LINE__, ext) ; - exit (retval) ; - } ; - - puts ("ok") ; - - return ; -} /* pipe_write_test */ - -/*============================================================================== -*/ - -[+ FOR data_type +] -static void -useek_pipe_rw_[+ (get "type_name") +] (const char * ext, SF_INFO * psfinfo_write, SF_INFO * psfinfo_read) -{ static [+ (get "type_name") +] buffer [PIPE_TEST_LEN] ; - static [+ (get "type_name") +] data [PIPE_TEST_LEN] ; - SNDFILE *outfile ; - SNDFILE *infile_piped ; - - int k, status = 0 ; - int pipefd [2] ; - pid_t pida ; - - for (k = 0 ; k < PIPE_TEST_LEN ; k++) - data [k] = PIPE_INDEX (k) ; - - /* - ** Create the pipe. - */ - exit_if_true (pipe (pipefd) != 0, "\n\n%s %d : pipe failed : %s\n", __func__, __LINE__, strerror (errno)) ; - - /* - ** Attach the write end of the pipe to be written to. - */ - if ((outfile = sf_open_fd (pipefd [1], SFM_WRITE, psfinfo_write, SF_TRUE)) == NULL) - { printf ("\n\n%s %d : unable to create unseekable pipe for write type \"%s\".\n", __func__, __LINE__, ext) ; - printf ("\t%s\n\n", sf_strerror (outfile)) ; - exit (1) ; - } ; - - if (sf_error (outfile) != SF_ERR_NO_ERROR) - { printf ("\n\n%s %d : unable to open unseekable pipe for write type \"%s\".\n\n", __func__, __LINE__, ext) ; - exit (1) ; - } ; - - /* - ** Attach the read end of the pipe to be read from. - */ - if ((infile_piped = sf_open_fd (pipefd [0], SFM_READ, psfinfo_read, SF_TRUE)) == NULL) - { printf ("\n\n%s %d : unable to create unseekable pipe for read type. \"%s\".\n\n", __func__, __LINE__, ext) ; - exit (1) ; - } ; - - if (sf_error (infile_piped) != SF_ERR_NO_ERROR) - { printf ("\n\n%s %d : unable to open unseekable pipe for read type \"%s\".\n\n", __func__, __LINE__, ext) ; - exit (1) ; - } ; - - /* Fork a child process that will write directly into the pipe. */ - if ((pida = fork ()) == 0) /* child process */ - { test_writef_[+ (get "type_name") +]_or_die (outfile, 0, data, PIPE_TEST_LEN, __LINE__) ; - exit (0) ; - } ; - - /* In the parent process, read from the pipe and compare what is read - ** to what is written, if they match everything went as planned. - */ - test_readf_[+ (get "type_name") +]_or_die (infile_piped, 0, buffer, PIPE_TEST_LEN, __LINE__) ; - if (memcmp (buffer, data, sizeof (buffer)) != 0) - { printf ("\n\n%s %d : unseekable pipe test failed for file type \"%s\".\n\n", __func__, __LINE__, ext) ; - exit (1) ; - } ; - - /* Wait for the child process to return. */ - waitpid (pida, &status, 0) ; - status = WEXITSTATUS (status) ; - sf_close (outfile) ; - sf_close (infile_piped) ; - - if (status != 0) - { printf ("\n\n%s %d : status of child process is %d for file type %s.\n\n", __func__, __LINE__, status, ext) ; - exit (1) ; - } ; - - return ; -} /* useek_pipe_rw_[+ (get "type_name") +] */ - -[+ ENDFOR data_type +] - - -static void -useek_pipe_rw_test (int filetype, const char *ext) -{ SF_INFO sfinfo_write ; - SF_INFO sfinfo_read ; - - print_test_name ("useek_pipe_rw_test", ext) ; - - /* - ** Setup the INFO structures for the filetype we will be - ** working with. - */ - sfinfo_write.format = filetype | SF_FORMAT_PCM_16 ; - sfinfo_write.channels = 1 ; - sfinfo_write.samplerate = 44100 ; - - - sfinfo_read.format = 0 ; - if (filetype == SF_FORMAT_RAW) - { sfinfo_read.format = filetype | SF_FORMAT_PCM_16 ; - sfinfo_read.channels = 1 ; - sfinfo_read.samplerate = 44100 ; - } ; - - useek_pipe_rw_short (ext, &sfinfo_write, &sfinfo_read) ; - - sfinfo_read.format = sfinfo_write.format = filetype | SF_FORMAT_FLOAT ; - if (sf_format_check (&sfinfo_read) != 0) - useek_pipe_rw_float (ext, &sfinfo_write, &sfinfo_read) ; - - sfinfo_read.format = sfinfo_write.format = filetype | SF_FORMAT_DOUBLE ; - if (sf_format_check (&sfinfo_read) != 0) - useek_pipe_rw_double (ext, &sfinfo_write, &sfinfo_read) ; - - puts ("ok") ; - return ; -} /* useek_pipe_rw_test */ - - - -static void -pipe_test_others (FILETYPE* list1, FILETYPE* list2) -{ SF_FORMAT_INFO info ; - int k, m, major_count, in_list ; - - print_test_name ("pipe_test_others", "") ; - - sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ; - - for (k = 0 ; k < major_count ; k++) - { info.format = k ; - - sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ; - - in_list = SF_FALSE ; - for (m = 0 ; list1 [m].format ; m++) - if (info.format == list1 [m].format) - in_list = SF_TRUE ; - - for (m = 0 ; list2 [m].format ; m++) - if (info.format == list2 [m].format) - in_list = SF_TRUE ; - - if (in_list) - continue ; - - printf ("%s %x\n", info.name, info.format) ; - - if (1) - { static short data [PIPE_TEST_LEN] ; - static char buffer [256] ; - static const char *filename = "pipe_in.dat" ; - - SNDFILE *outfile ; - SF_INFO sfinfo ; - int retval ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.format = info.format | SF_FORMAT_PCM_16 ; - sfinfo.channels = 1 ; - sfinfo.samplerate = 44100 ; - - outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - test_writef_short_or_die (outfile, 0, data, PIPE_TEST_LEN, __LINE__) ; - sf_close (outfile) ; - - snprintf (buffer, sizeof (buffer), "cat %s | ./tests/stdin_test %s %d ", filename, info.extension, PIPE_TEST_LEN) ; - if ((retval = system (buffer)) == 0) - { retval = WEXITSTATUS (retval) ; - printf ("\n\n Line %d : pipe test should have returned error file type \"%s\" but didn't.\n\n", __LINE__, info.name) ; - exit (1) ; - } ; - - unlink (filename) ; - } ; - } ; - - - puts ("ok") ; - - return ; -} /* pipe_test_others */ - - -/*============================================================================== -*/ - -#endif - diff --git a/Engine/lib/libsndfile/tests/raw_test.c b/Engine/lib/libsndfile/tests/raw_test.c deleted file mode 100644 index be0f94dcf..000000000 --- a/Engine/lib/libsndfile/tests/raw_test.c +++ /dev/null @@ -1,189 +0,0 @@ -/* -** Copyright (C) 2002-2014 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_LEN (1 << 10) -#define LOG_BUFFER_SIZE 1024 - -static void raw_offset_test (const char *filename, int typeminor) ; -static void bad_raw_test (void) ; - -/* Force the start of this buffer to be double aligned. Sparc-solaris will -** choke if its not. -*/ -static short data [BUFFER_LEN] ; - -int -main (void) -{ - raw_offset_test ("offset.raw", SF_FORMAT_PCM_16) ; - bad_raw_test () ; - - return 0 ; -} /* main */ - -/*============================================================================================ -** Here are the test functions. -*/ - -static void -raw_offset_test (const char *filename, int typeminor) -{ SNDFILE *sndfile ; - SF_INFO sfinfo ; - sf_count_t start ; - int k ; - - print_test_name ("raw_offset_test", filename) ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = SF_FORMAT_RAW | typeminor ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - - sndfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; - - start = 0 ; - sf_command (sndfile, SFC_FILE_TRUNCATE, &start, sizeof (start)) ; - - for (k = 0 ; k < BUFFER_LEN ; k++) - data [k] = k ; - test_write_short_or_die (sndfile, 0, data, BUFFER_LEN, __LINE__) ; - - sf_close (sndfile) ; - - sndfile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - check_log_buffer_or_die (sndfile, __LINE__) ; - - if (ABS (BUFFER_LEN - sfinfo.frames) > 1) - { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, BUFFER_LEN) ; - dump_log_buffer (sndfile) ; - exit (1) ; - } ; - - memset (data, 0 , sizeof (data)) ; - test_read_short_or_die (sndfile, 0, data, BUFFER_LEN, __LINE__) ; - for (k = 0 ; k < BUFFER_LEN ; k++) - if (data [k] != k) - printf ("Error : line %d\n", __LINE__) ; - - /* Set dataoffset to 2 bytes from beginning of file. */ - start = 2 ; - sf_command (sndfile, SFC_SET_RAW_START_OFFSET, &start, sizeof (start)) ; - - /* Seek to new start */ - test_seek_or_die (sndfile, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - memset (data, 0 , sizeof (data)) ; - test_read_short_or_die (sndfile, 0, data, BUFFER_LEN - 1, __LINE__) ; - for (k = 0 ; k < BUFFER_LEN - 1 ; k++) - if (data [k] != k + 1) - { printf ("Error : line %d\n", __LINE__) ; - exit (1) ; - } ; - - /* Set dataoffset to 4 bytes from beginning of file. */ - start = 4 ; - sf_command (sndfile, SFC_SET_RAW_START_OFFSET, &start, sizeof (start)) ; - - /* Seek to new start */ - test_seek_or_die (sndfile, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - memset (data, 0 , sizeof (data)) ; - test_read_short_or_die (sndfile, 0, data, BUFFER_LEN - 2, __LINE__) ; - for (k = 0 ; k < BUFFER_LEN - 2 ; k++) - if (data [k] != k + 2) - { printf ("Error : line %d\n", __LINE__) ; - exit (1) ; - } ; - - /* Set dataoffset back to 0 bytes from beginning of file. */ - start = 0 ; - sf_command (sndfile, SFC_SET_RAW_START_OFFSET, &start, sizeof (start)) ; - - /* Seek to new start */ - test_seek_or_die (sndfile, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - memset (data, 0 , sizeof (data)) ; - test_read_short_or_die (sndfile, 0, data, BUFFER_LEN, __LINE__) ; - for (k = 0 ; k < BUFFER_LEN ; k++) - if (data [k] != k) - { printf ("Error : line %d\n", __LINE__) ; - exit (1) ; - } ; - - sf_close (sndfile) ; - unlink (filename) ; - - puts ("ok") ; -} /* raw_offset_test */ - -static void -bad_raw_test (void) -{ FILE *textfile ; - SNDFILE *file ; - SF_INFO sfinfo ; - const char *errorstr, *filename = "bad.raw" ; - - print_test_name ("bad_raw_test", filename) ; - - if ((textfile = fopen (filename, "w")) == NULL) - { printf ("\n\nLine %d : not able to open text file for write.\n", __LINE__) ; - exit (1) ; - } ; - - fprintf (textfile, "This is not a valid file.\n") ; - fclose (textfile) ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = SF_FORMAT_RAW | 0xABCD ; - sfinfo.channels = 1 ; - - if ((file = sf_open (filename, SFM_READ, &sfinfo)) != NULL) - { printf ("\n\nLine %d : Error, file should not have opened.\n", __LINE__ - 1) ; - exit (1) ; - } ; - - errorstr = sf_strerror (file) ; - - if (strstr (errorstr, "Bad format field in SF_INFO struct") == NULL) - { printf ("\n\nLine %d : Error bad error string : %s.\n", __LINE__ - 1, errorstr) ; - exit (1) ; - } ; - - unlink (filename) ; - - puts ("ok") ; -} /* bad_raw_test */ - diff --git a/Engine/lib/libsndfile/tests/rdwr_test.def b/Engine/lib/libsndfile/tests/rdwr_test.def deleted file mode 100644 index 43c108981..000000000 --- a/Engine/lib/libsndfile/tests/rdwr_test.def +++ /dev/null @@ -1,32 +0,0 @@ -autogen definitions rdwr_test.tpl; - -data_type = { - name = "short" ; - type = "short" ; - format = "SF_FORMAT_PCM_16" ; - } ; - -data_type = { - name = "int" ; - type = "int" ; - format = "SF_FORMAT_PCM_32" ; - } ; - -data_type = { - name = "float" ; - type = "float" ; - format = "SF_FORMAT_FLOAT" ; - } ; - -data_type = { - name = "double" ; - type = "double" ; - format = "SF_FORMAT_DOUBLE" ; - } ; - -data_type = { - name = "raw" ; - type = "unsigned char" ; - format = "SF_FORMAT_PCM_U8" ; - } ; - diff --git a/Engine/lib/libsndfile/tests/rdwr_test.tpl b/Engine/lib/libsndfile/tests/rdwr_test.tpl deleted file mode 100644 index 8cfdd3687..000000000 --- a/Engine/lib/libsndfile/tests/rdwr_test.tpl +++ /dev/null @@ -1,105 +0,0 @@ -[+ AutoGen5 template c +] -/* -** Copyright (C) 2010-2012 Erik de Castro Lopo -** -** This program is free software ; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation ; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY ; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program ; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#include -#include - -#if HAVE_UNISTD_H -#include -#endif - -#if (HAVE_DECL_S_IRGRP == 0) -#include -#endif - -#if (defined (WIN32) || defined (_WIN32)) -#include -#include -#endif - -#include - -#include "utils.h" - -[+ FOR data_type -+]static void rdwr_[+ (get "name") +]_test (const char *filename) ; -[+ ENDFOR data_type -+] - -int -main (void) -{ - rdwr_short_test ("rdwr_short.wav") ; - rdwr_int_test ("rdwr_int.wav") ; - rdwr_float_test ("rdwr_float.wav") ; - rdwr_double_test ("rdwr_double.wav") ; - rdwr_raw_test ("rdwr_raw.wav") ; - - return 0 ; -} /* main */ - - -/*============================================================================================ -** Here are the test functions. -*/ - -[+ FOR data_type -+]static void -rdwr_[+ (get "name") +]_test (const char *filename) -{ SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t frames ; - [+ (get "type") +] buffer [160] ; - - print_test_name ("rdwr_[+ (get "name") +]_test", filename) ; - - memset (buffer, 0, sizeof (buffer)) ; - - /* Create sound file with no data. */ - sfinfo.format = SF_FORMAT_WAV | [+ (get "format") +] ; - sfinfo.samplerate = 16000 ; - sfinfo.channels = 1 ; - - unlink (filename) ; - - frames = ARRAY_LEN (buffer) ; - - /* Open again for read/write. */ - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; - - test_write_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ; - - test_read_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ; - - sf_close (file) ; - unlink (filename) ; - - puts ("ok") ; - return ; -} /* rdwr_[+ (get "name") +]_test */ - -[+ ENDFOR data_type -+] - diff --git a/Engine/lib/libsndfile/tests/scale_clip_test.def b/Engine/lib/libsndfile/tests/scale_clip_test.def deleted file mode 100644 index 9974f116d..000000000 --- a/Engine/lib/libsndfile/tests/scale_clip_test.def +++ /dev/null @@ -1,56 +0,0 @@ -autogen definitions scale_clip_test.tpl; - -float_type = { - float_type_name = "float" ; - float_short_name = "flt" ; - float_upper_name = "FLOAT" ; - float_to_int = "lrintf" ; - } ; - -float_type = { - float_type_name = "double" ; - float_short_name = "dbl" ; - float_upper_name = "DOUBLE" ; - float_to_int = "lrint" ; - } ; - - - -int_type = { - int_type_name = "short" ; - int_short_name = "s" ; - int_max_value = "0x7FFFF" ; - } ; - -int_type = { - int_type_name = "int" ; - int_short_name = "i" ; - int_max_value = "0x7FFFFFFF" ; - } ; - - - -data_type = { - name = "16" ; - bit_count = 16 ; - error_val = "1.0 / 0x8000" ; - } ; - -data_type = { - name = "24" ; - bit_count = 24 ; - error_val = "1.0 / 0x800000" ; - } ; - -data_type = { - name = "32" ; - bit_count = 32 ; - error_val = "1.0 / 0x80000000" ; - } ; - -data_type = { - name = "08" ; - bit_count = 8 ; - error_val = "1.0 / 0x80" ; - } ; - diff --git a/Engine/lib/libsndfile/tests/scale_clip_test.tpl b/Engine/lib/libsndfile/tests/scale_clip_test.tpl deleted file mode 100644 index ad59ce16d..000000000 --- a/Engine/lib/libsndfile/tests/scale_clip_test.tpl +++ /dev/null @@ -1,440 +0,0 @@ -[+ AutoGen5 template c +] -/* -** Copyright (C) 1999-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846264338 -#endif - -#define HALF_BUFFER_SIZE (1 << 12) -#define BUFFER_SIZE (2 * HALF_BUFFER_SIZE) - -#define SINE_AMP 1.1 -#define MAX_ERROR 0.0202 - -[+ FOR float_type +] -[+ FOR data_type -+]static void [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval) ; -[+ ENDFOR data_type -+][+ ENDFOR float_type +] - -[+ FOR float_type +] -[+ FOR int_type -+]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype) ; -[+ ENDFOR int_type -+][+ ENDFOR float_type +] - -[+ FOR int_type +] -[+ FOR float_type -+]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype) ; -[+ ENDFOR float_type -+][+ ENDFOR int_type +] - -typedef union -{ double dbl [BUFFER_SIZE] ; - float flt [BUFFER_SIZE] ; - int i [BUFFER_SIZE] ; - short s [BUFFER_SIZE] ; -} BUFFER ; - -/* Data buffer. */ -static BUFFER buffer_out ; -static BUFFER buffer_in ; - -int -main (void) -{ - flt_scale_clip_test_08 ("scale_clip_s8.au", SF_FORMAT_AU | SF_FORMAT_PCM_S8, 1.0 * 0x80) ; - flt_scale_clip_test_08 ("scale_clip_u8.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8, 1.0 * 0x80) ; - - dbl_scale_clip_test_08 ("scale_clip_s8.au", SF_FORMAT_AU | SF_FORMAT_PCM_S8, 1.0 * 0x80) ; - dbl_scale_clip_test_08 ("scale_clip_u8.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8, 1.0 * 0x80) ; - - /* - ** Now use SF_FORMAT_AU where possible because it allows both - ** big and little endian files. - */ - - flt_scale_clip_test_16 ("scale_clip_be16.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ; - flt_scale_clip_test_16 ("scale_clip_le16.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ; - flt_scale_clip_test_24 ("scale_clip_be24.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ; - flt_scale_clip_test_24 ("scale_clip_le24.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ; - flt_scale_clip_test_32 ("scale_clip_be32.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ; - flt_scale_clip_test_32 ("scale_clip_le32.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ; - - dbl_scale_clip_test_16 ("scale_clip_be16.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ; - dbl_scale_clip_test_16 ("scale_clip_le16.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ; - dbl_scale_clip_test_24 ("scale_clip_be24.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ; - dbl_scale_clip_test_24 ("scale_clip_le24.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ; - dbl_scale_clip_test_32 ("scale_clip_be32.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ; - dbl_scale_clip_test_32 ("scale_clip_le32.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ; - - flt_short_clip_read_test ("flt_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ; - flt_int_clip_read_test ("flt_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ; - dbl_short_clip_read_test ("dbl_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ; - dbl_int_clip_read_test ("dbl_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ; - - short_flt_scale_write_test ("short_flt.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ; - int_flt_scale_write_test ("int_flt.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ; - short_dbl_scale_write_test ("short_dbl.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ; - int_dbl_scale_write_test ("int_dbl.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ; - - return 0 ; -} /* main */ - -/*============================================================================================ -** Here are the test functions. -*/ - -[+ FOR float_type +] -[+ FOR data_type -+]static void -[+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k ; - [+ (get "float_type_name") +] *data_out, *data_in ; - double diff, clip_max_diff ; - - print_test_name ("[+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +]", filename) ; - - data_out = buffer_out.[+ (get "float_short_name") +] ; - data_in = buffer_in.[+ (get "float_short_name") +] ; - - for (k = 0 ; k < HALF_BUFFER_SIZE ; k++) - { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ; - data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ; - } ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - /* - ** Write two versions of the data: - ** normalized and clipped - ** un-normalized and clipped. - */ - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ; - test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out, HALF_BUFFER_SIZE, __LINE__) ; - sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ; - test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ; - sf_close (file) ; - - memset (&buffer_in, 0, sizeof (buffer_in)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ; - - if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != BUFFER_SIZE) - { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, HALF_BUFFER_SIZE, __LINE__) ; - sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ; - test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ; - sf_close (file) ; - - /* Check normalized version. */ - clip_max_diff = 0.0 ; - for (k = 0 ; k < HALF_BUFFER_SIZE ; k++) - { if (fabs (data_in [k]) > 1.0) - { printf ("\n\nLine %d: Input sample %d/%d (%f) has not been clipped.\n\n", __LINE__, k, BUFFER_SIZE, data_in [k]) ; - exit (1) ; - } ; - - if (data_out [k] * data_in [k] < 0.0) - { printf ("\n\nLine %d: Data wrap around at index %d/%d.\n\n", __LINE__, k, BUFFER_SIZE) ; - exit (1) ; - } ; - - if (fabs (data_out [k]) > 1.0) - continue ; - - diff = fabs (data_out [k] - data_in [k]) ; - if (diff > clip_max_diff) - clip_max_diff = diff ; - } ; - - if (clip_max_diff < 1e-20) - { printf ("\n\nLine %d: Clipping difference (%e) too small (normalized).\n\n", __LINE__, clip_max_diff) ; - exit (1) ; - } ; - - if (clip_max_diff > [+ (get "error_val") +]) - { printf ("\n\nLine %d: Clipping difference (%e) too large (normalized).\n\n", __LINE__, clip_max_diff) ; - exit (1) ; - } ; - - /* Check the un-normalized data. */ - clip_max_diff = 0.0 ; - for (k = HALF_BUFFER_SIZE ; k < BUFFER_SIZE ; k++) - { if (fabs (data_in [k]) > maxval) - { printf ("\n\nLine %d: Input sample %d/%d (%f) has not been clipped.\n\n", __LINE__, k, BUFFER_SIZE, data_in [k]) ; - exit (1) ; - } ; - - if (data_out [k] * data_in [k] < 0.0) - { printf ("\n\nLine %d: Data wrap around at index %d/%d.\n\n", __LINE__, k, BUFFER_SIZE) ; - exit (1) ; - } ; - - if (fabs (data_out [k]) > maxval) - continue ; - - diff = fabs (data_out [k] - data_in [k]) ; - if (diff > clip_max_diff) - clip_max_diff = diff ; - } ; - - if (clip_max_diff < 1e-20) - { printf ("\n\nLine %d: Clipping difference (%e) too small (un-normalized).\n\n", __LINE__, clip_max_diff) ; - exit (1) ; - } ; - - if (clip_max_diff > 1.0) - { printf ("\n\nLine %d: Clipping difference (%e) too large (un-normalised).\n\n", __LINE__, clip_max_diff) ; - exit (1) ; - } ; - - printf ("ok\n") ; - unlink (filename) ; -} /* [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] */ - -[+ ENDFOR data_type -+] -[+ ENDFOR float_type +] - -/*============================================================================== -*/ - -[+ FOR float_type +] -[+ FOR int_type -+]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype) -{ SNDFILE *file ; - SF_INFO sfinfo ; - [+ (get "float_type_name") +] *data_out ; - [+ (get "int_type_name") +] *data_in, max_value ; - int k ; - - print_test_name ("[+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test", filename) ; - - data_out = buffer_out.[+ (get "float_short_name") +] ; - data_in = buffer_in.[+ (get "int_short_name") +] ; - - for (k = 0 ; k < BUFFER_SIZE ; k++) - data_out [k] = 0.995 * sin (4 * M_PI * k / BUFFER_SIZE) ; - data_out [BUFFER_SIZE / 8] = 1.0 ; - data_out [3 * BUFFER_SIZE / 8] = -1.000000001 ; - data_out [5 * BUFFER_SIZE / 8] = 1.0 ; - data_out [7 * BUFFER_SIZE / 8] = -1.000000001 ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - /* Save unclipped data to the file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ; - sf_close (file) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ; - - sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ; - - if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != BUFFER_SIZE) - { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ; - test_read_[+ (get "int_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ; - /*-sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ;-*/ - sf_close (file) ; - - /* Check the first half. */ - max_value = 0 ; - for (k = 0 ; k < sfinfo.frames ; k++) - { /* Check if data_out has different sign from data_in. */ - if ((data_out [k] < 0.0 && data_in [k] > 0) || (data_out [k] > 0.0 && data_in [k] < 0)) - { printf ("\n\nLine %d: Data wrap around at index %d/%d (%f -> %d).\n\n", __LINE__, k, BUFFER_SIZE, data_out [k], data_in [k]) ; - exit (1) ; - } ; - max_value = (max_value > abs (data_in [k])) ? max_value : abs (data_in [k]) ; - } ; - - unlink (filename) ; - puts ("ok") ; -} /* [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test */ -[+ ENDFOR int_type -+][+ ENDFOR float_type +] - -/*============================================================================== -*/ - -[+ FOR int_type +] -[+ FOR float_type -+]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype) -{ SNDFILE *file ; - SF_INFO sfinfo ; - [+ (get "int_type_name") +] *data_out ; - [+ (get "float_type_name") +] *data_in, max_value ; - int k ; - - print_test_name ("[+ (get "int_type_name") +]_[+ (get "float_short_name") +]_clip_write_test", filename) ; - - data_out = buffer_out.[+ (get "int_short_name") +] ; - data_in = buffer_in.[+ (get "float_short_name") +] ; - - for (k = 0 ; k < BUFFER_SIZE ; k++) - data_out [k] = [+ (get "float_to_int") +] ([+ (get "int_max_value") +] * 0.995 * sin (4 * M_PI * k / BUFFER_SIZE)) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = filetype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ; - sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ; - test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ; - sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_FALSE) ; - test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ; - sf_close (file) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ; - - if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) - { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames != 3 * BUFFER_SIZE) - { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, 3 * BUFFER_SIZE, sfinfo.frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - /* Check the first section. */ - test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ; - - max_value = 0.0 ; - for (k = 0 ; k < BUFFER_SIZE ; k++) - max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ; - - if (max_value < 1000.0) - { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ; - exit (1) ; - } ; - - /* Check the second section. */ - test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ; - - max_value = 0.0 ; - for (k = 0 ; k < BUFFER_SIZE ; k++) - max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ; - - if (max_value > 1.0) - { printf ("\n\nLine %d: Max value (%f) > 1.0.\n\n", __LINE__, max_value) ; - exit (1) ; - } ; - - /* Check the third section. */ - test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ; - - max_value = 0.0 ; - for (k = 0 ; k < BUFFER_SIZE ; k++) - max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ; - - if (max_value < 1000.0) - { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ; - exit (1) ; - } ; - - sf_close (file) ; - - unlink (filename) ; - puts ("ok") ; -} /* [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test */ -[+ ENDFOR float_type -+][+ ENDFOR int_type +] - - diff --git a/Engine/lib/libsndfile/tests/sftest.c b/Engine/lib/libsndfile/tests/sftest.c deleted file mode 100644 index 497265c92..000000000 --- a/Engine/lib/libsndfile/tests/sftest.c +++ /dev/null @@ -1,67 +0,0 @@ -/* -** Copyright (C) 1999-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#define BUFFER_SIZE (1024) - - -static short buffer [BUFFER_SIZE] ; - -int -main (int argc, char *argv []) -{ SNDFILE *file ; - SF_INFO sfinfo ; - int k, count, max = 0, total = 0 ; - - if (argc < 2) - { printf ("Expecting input file name.\n") ; - return 0 ; - } ; - - if (! (file = sf_open (argv [1], SFM_READ, &sfinfo))) - { printf ("sf_open_read failed with error : ") ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - while ((count = sf_read_short (file, buffer, BUFFER_SIZE))) - { for (k = 0 ; k < count ; k++) - if (abs (buffer [k]) > max) - max = abs (buffer [k]) ; - total += count ; - } ; - - printf ("Total : %d\n", total) ; - printf ("Maximun value : %d\n", max) ; - - sf_close (file) ; - - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/tests/sfversion.c b/Engine/lib/libsndfile/tests/sfversion.c deleted file mode 100644 index 6caa77ae2..000000000 --- a/Engine/lib/libsndfile/tests/sfversion.c +++ /dev/null @@ -1,48 +0,0 @@ -/* -** Copyright (C) 1999-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#include - -#define BUFFER_SIZE (256) - - -int -main (void) -{ static char strbuffer [BUFFER_SIZE] ; - const char * ver ; - - sf_command (NULL, SFC_GET_LIB_VERSION, strbuffer, sizeof (strbuffer)) ; - ver = sf_version_string () ; - - if (strcmp (ver, strbuffer) != 0) - { printf ("Version mismatch : '%s' != '%s'\n\n", ver, strbuffer) ; - exit (1) ; - } ; - - printf ("%s", strbuffer) ; - - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/tests/stdin_test.c b/Engine/lib/libsndfile/tests/stdin_test.c deleted file mode 100644 index 1a9c67b85..000000000 --- a/Engine/lib/libsndfile/tests/stdin_test.c +++ /dev/null @@ -1,206 +0,0 @@ -/* -** Copyright (C) 2001-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_LEN (1 << 16) - -static void stdin_test (int typemajor, int count) ; - -int -main (int argc, char *argv []) -{ int do_all = 0, test_count = 0 ; - - if (BUFFER_LEN < PIPE_TEST_LEN) - { fprintf (stderr, "Error : BUFFER_LEN < PIPE_TEST_LEN.\n\n") ; - exit (1) ; - } ; - - if (argc != 2) - { fprintf (stderr, "This program cannot be run by itself. It needs\n") ; - fprintf (stderr, "to be run from the stdio_test program.\n") ; - exit (1) ; - } ; - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "raw")) - { stdin_test (SF_FORMAT_RAW, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "wav")) - { stdin_test (SF_FORMAT_WAV, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { stdin_test (SF_FORMAT_AIFF, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "au")) - { stdin_test (SF_FORMAT_AU, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "paf")) - { stdin_test (SF_FORMAT_PAF, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "svx")) - { stdin_test (SF_FORMAT_SVX, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "nist")) - { stdin_test (SF_FORMAT_NIST, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "ircam")) - { stdin_test (SF_FORMAT_IRCAM, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "voc")) - { stdin_test (SF_FORMAT_VOC, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "w64")) - { stdin_test (SF_FORMAT_W64, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat4")) - { stdin_test (SF_FORMAT_MAT4, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat5")) - { stdin_test (SF_FORMAT_MAT5, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "pvf")) - { stdin_test (SF_FORMAT_PVF, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "htk")) - { stdin_test (SF_FORMAT_HTK, PIPE_TEST_LEN) ; - test_count++ ; - } ; - - if (test_count == 0) - { fprintf (stderr, "\n*****************************************\n") ; - fprintf (stderr, "* stdin_test : No '%s' test defined.\n", argv [1]) ; - fprintf (stderr, "*****************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - -static void -stdin_test (int typemajor, int count) -{ static short data [BUFFER_LEN] ; - - SNDFILE *file ; - SF_INFO sfinfo ; - int k, total, err ; - - if (typemajor == SF_FORMAT_RAW) - { sfinfo.samplerate = 44100 ; - sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - } - else - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - if ((file = sf_open_fd (fileno (stdin), SFM_READ, &sfinfo, SF_TRUE)) == NULL) - { fprintf (stderr, "sf_open_fd failed with error : ") ; - puts (sf_strerror (NULL)) ; - dump_log_buffer (NULL) ; - exit (1) ; - } ; - - err = sf_error (file) ; - if (err != SF_ERR_NO_ERROR) - { printf ("Line %d : unexpected error : %s\n", __LINE__, sf_error_number (err)) ; - exit (1) ; - } ; - - if ((sfinfo.format & SF_FORMAT_TYPEMASK) != typemajor) - { fprintf (stderr, "\n\nError : File type doesn't match.\n") ; - exit (1) ; - } ; - - if (sfinfo.samplerate != 44100) - { fprintf (stderr, "\n\nError : Sample rate (%d) should be 44100\n", sfinfo.samplerate) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { fprintf (stderr, "\n\nError : Channels (%d) should be 1\n", sfinfo.channels) ; - exit (1) ; - } ; - - if (sfinfo.frames < count) - { fprintf (stderr, "\n\nError : Sample count (%ld) should be %d\n", (long) sfinfo.frames, count) ; - exit (1) ; - } ; - - total = 0 ; - while ((k = (int) sf_read_short (file, data + total, BUFFER_LEN - total)) > 0) - total += k ; - - if (total != count) - { fprintf (stderr, "\n\nError : Expected %d frames, read %d.\n", count, total) ; - exit (1) ; - } ; - - for (k = 0 ; k < total ; k++) - if (data [k] != PIPE_INDEX (k)) - { printf ("\n\nError : data [%d] == %d, should have been %d.\n\n", k, data [k], k) ; - exit (1) ; - } ; - - sf_close (file) ; - - return ; -} /* stdin_test */ - diff --git a/Engine/lib/libsndfile/tests/stdio_test.c b/Engine/lib/libsndfile/tests/stdio_test.c deleted file mode 100644 index a065a040f..000000000 --- a/Engine/lib/libsndfile/tests/stdio_test.c +++ /dev/null @@ -1,141 +0,0 @@ -/* -** Copyright (C) 2001-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/*========================================================================== -** This is a test program which tests reading from stdin and writing to -** stdout. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include -#include - -#if HAVE_SYS_WAIT_H -#include -#endif - -#include "utils.h" - -/* EMX is OS/2. */ -#if (OS_IS_WIN32) || defined (__EMX__) - -int -main (void) -{ - puts (" stdio_test : this test doesn't work on win32.") ; - return 0 ; -} /* main */ - -#else - -#ifndef WIFEXITED -#define WIFEXITED(s) (((s) & 0xff) == 0) -#endif -#ifndef WEXITSTATUS -#define WEXITSTATUS(s) (((s) & 0xff00) >> 8) -#endif - - -static size_t file_length (const char *filename) ; -static void stdio_test (const char *filetype) ; - -static const char *filetypes [] = -{ "raw", "wav", "aiff", "au", "paf", "svx", "nist", "ircam", - "voc", "w64", "mat4", "mat5", "pvf", - NULL -} ; - -int -main (void) -{ int k ; - - for (k = 0 ; filetypes [k] ; k++) - stdio_test (filetypes [k]) ; - - return 0 ; -} /* main */ - - -static void -stdio_test (const char *filetype) -{ static char buffer [256] ; - - int file_size, retval ; - - print_test_name ("stdio_test", filetype) ; - - snprintf (buffer, sizeof (buffer), "./tests/stdout_test %s > stdio.%s", filetype, filetype) ; - if ((retval = system (buffer))) - { retval = WIFEXITED (retval) ? WEXITSTATUS (retval) : 1 ; - printf ("%s : %s", buffer, (strerror (retval))) ; - exit (1) ; - } ; - - snprintf (buffer, sizeof (buffer), "stdio.%s", filetype) ; - if ((file_size = file_length (buffer)) < PIPE_TEST_LEN) - { printf ("\n Error : test file '%s' too small (%d).\n\n", buffer, file_size) ; - exit (1) ; - } ; - - snprintf (buffer, sizeof (buffer), "./tests/stdin_test %s < stdio.%s", filetype, filetype) ; - if ((retval = system (buffer))) - { retval = WIFEXITED (retval) ? WEXITSTATUS (retval) : 1 ; - printf ("%s : %s", buffer, (strerror (retval))) ; - exit (1) ; - } ; - - snprintf (buffer, sizeof (buffer), "rm stdio.%s", filetype) ; - if ((retval = system (buffer))) - { retval = WIFEXITED (retval) ? WEXITSTATUS (retval) : 1 ; - printf ("%s : %s", buffer, (strerror (retval))) ; - exit (1) ; - } ; - - puts ("ok") ; - - return ; -} /* stdio_test */ - - - - -static size_t -file_length (const char *filename) -{ struct stat buf ; - - if (stat (filename, &buf)) - { perror (filename) ; - exit (1) ; - } ; - - return buf.st_size ; -} /* file_length */ - -#endif - diff --git a/Engine/lib/libsndfile/tests/stdout_test.c b/Engine/lib/libsndfile/tests/stdout_test.c deleted file mode 100644 index e2cbe8d82..000000000 --- a/Engine/lib/libsndfile/tests/stdout_test.c +++ /dev/null @@ -1,169 +0,0 @@ -/* -** Copyright (C) 2001-2014 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -static void stdout_test (int typemajor, int count) ; - -int -main (int argc, char *argv []) -{ int do_all, test_count = 0 ; - - if (argc != 2) - { fprintf (stderr, "This program cannot be run by itself. It needs\n") ; - fprintf (stderr, "to be run from the stdio_test program.\n") ; - exit (1) ; - } ; - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "raw")) - { stdout_test (SF_FORMAT_RAW, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "wav")) - { stdout_test (SF_FORMAT_WAV, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { stdout_test (SF_FORMAT_AIFF, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "au")) - { stdout_test (SF_FORMAT_AU, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "paf")) - { stdout_test (SF_FORMAT_PAF, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "svx")) - { stdout_test (SF_FORMAT_SVX, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "nist")) - { stdout_test (SF_FORMAT_NIST, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "ircam")) - { stdout_test (SF_FORMAT_IRCAM, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "voc")) - { stdout_test (SF_FORMAT_VOC, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "w64")) - { stdout_test (SF_FORMAT_W64, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat4")) - { stdout_test (SF_FORMAT_MAT4, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat5")) - { stdout_test (SF_FORMAT_MAT5, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (do_all || ! strcmp (argv [1], "pvf")) - { stdout_test (SF_FORMAT_PVF, PIPE_TEST_LEN) ; - test_count ++ ; - } ; - - if (test_count == 0) - { fprintf (stderr, "\n******************************************\n") ; - fprintf (stderr, "* stdout_test : No '%s' test defined.\n", argv [1]) ; - fprintf (stderr, "******************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - -static void -stdout_test (int typemajor, int count) -{ static short data [PIPE_TEST_LEN] ; - - SNDFILE *file ; - SF_INFO sfinfo ; - int k, total, this_write ; - - sfinfo.samplerate = 44100 ; - sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - - /* Create some random data. */ - for (k = 0 ; k < PIPE_TEST_LEN ; k++) - data [k] = PIPE_INDEX (k) ; - - if ((file = sf_open ("-", SFM_WRITE, &sfinfo)) == NULL) - { fprintf (stderr, "%s % d: sf_open_write failed with error : %s\n", - __func__, __LINE__, sf_strerror (NULL)) ; - exit (1) ; - } ; - - if (sfinfo.frames != 0) - { fprintf (stderr, "%s % d: Frames is %d (should be 0).\n", - __func__, __LINE__, (int) sfinfo.frames) ; - exit (1) ; - } ; - - total = 0 ; - - while (total < count) - { this_write = (count - total > 1024) ? 1024 : count - total ; - if ((k = (int) sf_write_short (file, data + total, this_write)) != this_write) - { fprintf (stderr, "sf_write_short # %d failed with short write (%d -> %d)\n", count, this_write, k) ; - exit (1) ; - } ; - total += k ; - } ; - - sf_close (file) ; - - return ; -} /* stdout_test */ - diff --git a/Engine/lib/libsndfile/tests/string_test.c b/Engine/lib/libsndfile/tests/string_test.c deleted file mode 100644 index 1e1d73386..000000000 --- a/Engine/lib/libsndfile/tests/string_test.c +++ /dev/null @@ -1,907 +0,0 @@ -/* -** Copyright (C) 2003-2016 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_LEN (1 << 10) -#define LOG_BUFFER_SIZE 1024 - -#define NULL_PRINTF_CHECK(X) (X ? X : "(null)") - -static const char STR_TEST_PREFIX[] = "str" ; - -static void string_start_test (const char *filename, int typemajor) ; -static void string_start_end_test (const char *filename, int typemajor) ; -static void string_multi_set_test (const char *filename, int typemajor) ; -static void string_rdwr_test (const char *filename, int typemajor) ; -static void string_short_rdwr_test (const char *filename, int typemajor) ; -static void string_rdwr_grow_test (const char *filename, int typemajor) ; -static void string_header_update (const char *filename, int typemajor) ; - -static void software_string_test (const char *filename) ; - -static int str_count (const char * haystack, const char * needle) ; - -int -main (int argc, char *argv []) -{ int do_all = 0 ; - int test_count = 0 ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" wav - test adding strings to WAV files\n") ; - printf (" aiff - test adding strings to AIFF files\n") ; - printf (" flac - test adding strings to FLAC files\n") ; - printf (" ogg - test adding strings to OGG files\n") ; - printf (" opus - test adding strings to OPUS files\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all = ! strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "wav")) - { string_start_end_test ("strings.wav", SF_FORMAT_WAV) ; - string_multi_set_test ("multi.wav", SF_FORMAT_WAV) ; - string_rdwr_test ("rdwr.wav", SF_FORMAT_WAV) ; - string_short_rdwr_test ("short_rdwr.wav", SF_FORMAT_WAV) ; - string_rdwr_grow_test ("rdwr_grow.wav", SF_FORMAT_WAV) ; - string_header_update ("header_update.wav", SF_FORMAT_WAV) ; - - string_start_end_test ("strings.wavex", SF_FORMAT_WAVEX) ; - string_multi_set_test ("multi.wavex", SF_FORMAT_WAVEX) ; - string_rdwr_test ("rdwr.wavex", SF_FORMAT_WAVEX) ; - string_short_rdwr_test ("short_rdwr.wavex", SF_FORMAT_WAVEX) ; - - string_start_end_test ("strings.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ; - string_multi_set_test ("multi.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ; - string_rdwr_test ("rdwr.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ; - string_short_rdwr_test ("short_rdwr.rifx", SF_ENDIAN_BIG | SF_FORMAT_WAV) ; - - software_string_test ("software_string.wav") ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { string_start_test ("strings.aiff", SF_FORMAT_AIFF) ; - string_start_end_test ("strings.aiff", SF_FORMAT_AIFF) ; - /* - TODO : Fix src/aiff.c so these tests pass. - string_multi_set_test ("multi.aiff", SF_FORMAT_AIFF) ; - string_rdwr_test ("rdwr.aiff", SF_FORMAT_AIFF) ; - string_short_rdwr_test ("short_rdwr.aiff", SF_FORMAT_AIFF) ; - string_rdwr_grow_test ("rdwr_grow.aiff", SF_FORMAT_AIFF) ; - string_header_update ("header_update.aiff", SF_FORMAT_AIFF) ; - */ - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "flac")) - { if (HAVE_EXTERNAL_XIPH_LIBS) - string_start_test ("strings.flac", SF_FORMAT_FLAC) ; - else - puts (" No FLAC tests because FLAC support was not compiled in.") ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mpeg")) - { if (HAVE_MPEG) - string_start_test ("mpeg.mp3", SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III) ; - else - puts (" No MP3 tests because MPEG support was not compiled in.") ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "ogg")) - { if (HAVE_EXTERNAL_XIPH_LIBS) - string_start_test ("vorbis.oga", SF_FORMAT_OGG | SF_FORMAT_VORBIS) ; - else - puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "opus")) - { if (HAVE_EXTERNAL_XIPH_LIBS) - string_start_test ("opus.opus", SF_FORMAT_OGG | SF_FORMAT_OPUS) ; - else - puts (" No Ogg/Opus tests because Ogg/Opus support was not compiled in.") ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "caf")) - { string_start_test ("strings.caf", SF_FORMAT_CAF) ; - string_start_end_test ("strings.caf", SF_FORMAT_CAF) ; - string_multi_set_test ("multi.caf", SF_FORMAT_CAF) ; - /* - TODO : Fix src/caf.c so these tests pass. - string_rdwr_test ("rdwr.caf", SF_FORMAT_CAF) ; - string_short_rdwr_test ("short_rdwr.caf", SF_FORMAT_CAF) ; - string_header_update ("header_update.caf", SF_FORMAT_CAF) ; - */ - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "rf64")) - { string_start_test ("strings.rf64", SF_FORMAT_RF64) ; - string_start_end_test ("strings.rf64", SF_FORMAT_RF64) ; - string_multi_set_test ("multi.rf64", SF_FORMAT_RF64) ; - /* - TODO : Fix src/rf64.c so these tests pass. - string_rdwr_test ("rdwr.rf64", SF_FORMAT_RF64) ; - string_short_rdwr_test ("short_rdwr.rf64", SF_FORMAT_RF64) ; - string_header_update ("header_update.rf64", SF_FORMAT_RF64) ; - */ - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "w64")) - { puts ("\n\n **** String test not working yet for W64 format. ****\n") ; - /* - string_start_test ("strings.w64", SF_FORMAT_W64) ; - string_start_end_test ("strings.w64", SF_FORMAT_W64) ; - string_multi_set_test ("multi.w64", SF_FORMAT_W64) ; - string_rdwr_test ("rdwr.w64", SF_FORMAT_W64) ; - string_short_rdwr_test ("short_rdwr.w64", SF_FORMAT_W64) ; - string_header_update ("header_update.w64", SF_FORMAT_W64) ; - */ - test_count++ ; - } ; - - if (test_count == 0) - { printf ("Mono : ************************************\n") ; - printf ("Mono : * No '%s' test defined.\n", argv [1]) ; - printf ("Mono : ************************************\n") ; - return 1 ; - } ; - - return 0 ; -} /* main */ - - -/*============================================================================================ -** Here are the test functions. -*/ - -static const char - software [] = "software (libsndfile-X.Y.Z)", - artist [] = "The Artist", - copyright [] = "Copyright (c) 2001 Artist", - comment [] = "Comment goes here!!!", - date [] = "2001/01/27", - album [] = "The Album", - license [] = "The license", - title [] = "This is the title", - long_title [] = "This is a very long and very boring title for this file", - long_artist [] = "The artist who kept on changing its name", - genre [] = "The genre", - trackno [] = "Track three", - id3v1_genre [] = "Rock", - year [] = "2001" ; - - -static short data_out [BUFFER_LEN] ; - -static void -string_start_end_test (const char *filename, int typemajor) -{ const char *cptr ; - SNDFILE *file ; - SF_INFO sfinfo ; - int errors = 0 ; - - get_unique_test_name (&filename, STR_TEST_PREFIX) ; - print_test_name ("string_start_end_test", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - sfinfo.format = typemajor | SF_FORMAT_PCM_16 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - /* Write stuff at start of file. */ - sf_set_string (file, SF_STR_TITLE, filename) ; - sf_set_string (file, SF_STR_SOFTWARE, software) ; - sf_set_string (file, SF_STR_ARTIST, artist) ; - sf_set_string (file, SF_STR_GENRE, genre) ; - sf_set_string (file, SF_STR_TRACKNUMBER, trackno) ; - - /* Write data to file. */ - test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - /* Write more stuff at end of file. */ - sf_set_string (file, SF_STR_COPYRIGHT, copyright) ; - sf_set_string (file, SF_STR_COMMENT, comment) ; - sf_set_string (file, SF_STR_DATE, date) ; - sf_set_string (file, SF_STR_ALBUM, album) ; - sf_set_string (file, SF_STR_LICENSE, license) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - if (sfinfo.frames != BUFFER_LEN) - { printf ("***** Bad frame count %d (should be %d)\n\n", (int) sfinfo.frames, BUFFER_LEN) ; - errors ++ ; - } ; - - cptr = sf_get_string (file, SF_STR_TITLE) ; - if (cptr == NULL || strcmp (filename, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad filename : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - cptr = sf_get_string (file, SF_STR_COPYRIGHT) ; - if (cptr == NULL || strcmp (copyright, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad copyright : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - cptr = sf_get_string (file, SF_STR_SOFTWARE) ; - if (cptr == NULL || strstr (cptr, software) != cptr) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad software : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - if (str_count (cptr, "libsndfile") != 1) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad software : %s\n", cptr) ; - } ; - - cptr = sf_get_string (file, SF_STR_ARTIST) ; - if (cptr == NULL || strcmp (artist, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad artist : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - cptr = sf_get_string (file, SF_STR_COMMENT) ; - if (cptr == NULL || strcmp (comment, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad comment : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - if (typemajor != SF_FORMAT_AIFF) - { cptr = sf_get_string (file, SF_STR_DATE) ; - if (cptr == NULL || strcmp (date, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad date : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - cptr = sf_get_string (file, SF_STR_GENRE) ; - if (cptr == NULL || strcmp (genre, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad genre : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - } ; - - switch (typemajor) - { case SF_FORMAT_AIFF : - case SF_FORMAT_WAV : - case SF_FORMAT_WAVEX : - case SF_ENDIAN_BIG | SF_FORMAT_WAV : - case SF_FORMAT_RF64 : - /* These formats do not support the following. */ - break ; - - default : - cptr = sf_get_string (file, SF_STR_ALBUM) ; - if (cptr == NULL || strcmp (album, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad album : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - cptr = sf_get_string (file, SF_STR_LICENSE) ; - if (cptr == NULL || strcmp (license, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad license : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - cptr = sf_get_string (file, SF_STR_TRACKNUMBER) ; - if (cptr == NULL || strcmp (trackno, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad track no. : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - break ; - } ; - - if (errors > 0) - { printf ("\n*** Error count : %d ***\n\n", errors) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - sf_close (file) ; - unlink (filename) ; - - puts ("ok") ; -} /* string_start_end_test */ - -static void -string_start_test (const char *filename, int formattype) -{ const char *cptr ; - SNDFILE *file ; - SF_INFO sfinfo ; - int errors = 0 ; - int typemajor = SF_FORMAT_TYPEMASK & formattype ; - - get_unique_test_name (&filename, STR_TEST_PREFIX) ; - print_test_name ("string_start_test", filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - - switch (formattype) - { case SF_FORMAT_OGG | SF_FORMAT_OPUS : - /* Opus only supports some discrete sample rates. */ - sfinfo.samplerate = 48000 ; - break ; - - case SF_FORMAT_OGG | SF_FORMAT_VORBIS : - case SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III : - break ; - - default : - formattype |= SF_FORMAT_PCM_16 ; - break ; - } ; - sfinfo.format = formattype ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - /* Write stuff at start of file. */ - sf_set_string (file, SF_STR_TITLE, filename) ; - sf_set_string (file, SF_STR_SOFTWARE, software) ; - sf_set_string (file, SF_STR_ARTIST, artist) ; - sf_set_string (file, SF_STR_COPYRIGHT, copyright) ; - sf_set_string (file, SF_STR_COMMENT, comment) ; - sf_set_string (file, SF_STR_ALBUM, album) ; - sf_set_string (file, SF_STR_LICENSE, license) ; - if (typemajor == SF_FORMAT_MPEG) - { sf_set_string (file, SF_STR_GENRE, id3v1_genre) ; - sf_set_string (file, SF_STR_DATE, year) ; - } - else - { sf_set_string (file, SF_STR_DATE, date) ; - } ; - - /* Write data to file. */ - test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - if (sfinfo.frames != BUFFER_LEN) - { printf ("***** Bad frame count %d (should be %d)\n\n", (int) sfinfo.frames, BUFFER_LEN) ; - errors ++ ; - } ; - - cptr = sf_get_string (file, SF_STR_TITLE) ; - if (cptr == NULL || strcmp (filename, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad filename : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - if (typemajor != SF_FORMAT_MPEG) - { cptr = sf_get_string (file, SF_STR_COPYRIGHT) ; - if (cptr == NULL || strcmp (copyright, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad copyright : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - cptr = sf_get_string (file, SF_STR_SOFTWARE) ; - if (cptr == NULL || strstr (cptr, software) != cptr) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad software : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - if (cptr && str_count (cptr, "libsndfile") != 1) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad software : %s\n", cptr) ; - } ; - } ; - - if (typemajor == SF_FORMAT_MPEG) - { cptr = sf_get_string (file, SF_STR_GENRE) ; - if (cptr == NULL || strcmp (id3v1_genre, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad genre : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - } ; - - cptr = sf_get_string (file, SF_STR_ARTIST) ; - if (cptr == NULL || strcmp (artist, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad artist : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - cptr = sf_get_string (file, SF_STR_COMMENT) ; - if (cptr == NULL || strcmp (comment, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad comment : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - - switch (typemajor) - { case SF_FORMAT_AIFF : - /* not supported */ - break ; - - case SF_FORMAT_MPEG : - /* id3 only supports years */ - cptr = sf_get_string (file, SF_STR_DATE) ; - if (cptr == NULL || strcmp (year, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad date : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - break ; - - default : - cptr = sf_get_string (file, SF_STR_DATE) ; - if (cptr == NULL || strcmp (date, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad date : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - break ; - } ; - - if (typemajor != SF_FORMAT_WAV && typemajor != SF_FORMAT_AIFF) - { cptr = sf_get_string (file, SF_STR_ALBUM) ; - if (cptr == NULL || strcmp (album, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad album : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - } ; - - switch (typemajor) - { case SF_FORMAT_WAV : - case SF_FORMAT_AIFF : - case SF_FORMAT_RF64 : - case SF_FORMAT_MPEG : - /* not supported */ - break ; - - default: - cptr = sf_get_string (file, SF_STR_LICENSE) ; - if (cptr == NULL || strcmp (license, cptr) != 0) - { if (errors++ == 0) - puts ("\n") ; - printf (" Bad license : %s\n", NULL_PRINTF_CHECK(cptr)) ; - } ; - } ; - - if (errors > 0) - { printf ("\n*** Error count : %d ***\n\n", errors) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - sf_close (file) ; - unlink (filename) ; - - puts ("ok") ; -} /* string_start_test */ - -static void -string_multi_set_test (const char *filename, int typemajor) -{ static const char - new_software [] = "new software (libsndfile-X.Y.Z)", - new_copyright [] = "Copyright (c) 2001 New Artist", - new_artist [] = "The New Artist", - new_title [] = "This is the new title" ; - - static char buffer [2048] ; - SNDFILE *file ; - SF_INFO sfinfo ; - int count ; - - get_unique_test_name (&filename, STR_TEST_PREFIX) ; - print_test_name (__func__, filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.format = typemajor | SF_FORMAT_PCM_16 ; - sfinfo.samplerate = 44100 ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - - /* Write stuff at start of file. */ - sf_set_string (file, SF_STR_TITLE, title) ; - sf_set_string (file, SF_STR_SOFTWARE, software) ; - sf_set_string (file, SF_STR_ARTIST, artist) ; - - /* Write data to file. */ - test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; - - /* Write it all again. */ - - sf_set_string (file, SF_STR_TITLE, new_title) ; - sf_set_string (file, SF_STR_SOFTWARE, new_software) ; - sf_set_string (file, SF_STR_ARTIST, new_artist) ; - - sf_set_string (file, SF_STR_COPYRIGHT, copyright) ; - sf_set_string (file, SF_STR_COMMENT, comment) ; - sf_set_string (file, SF_STR_DATE, date) ; - sf_set_string (file, SF_STR_ALBUM, album) ; - sf_set_string (file, SF_STR_LICENSE, license) ; - sf_set_string (file, SF_STR_COPYRIGHT, new_copyright) ; - sf_set_string (file, SF_STR_COMMENT, comment) ; - sf_set_string (file, SF_STR_DATE, date) ; - sf_set_string (file, SF_STR_ALBUM, album) ; - sf_set_string (file, SF_STR_LICENSE, license) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - sf_command (file, SFC_GET_LOG_INFO, buffer, sizeof (buffer)) ; - sf_close (file) ; - - count = str_count (buffer, new_title) ; - exit_if_true (count < 1, "\n\nLine %d : Could not find new_title in :\n%s\n", __LINE__, buffer) ; - exit_if_true (count > 1, "\n\nLine %d : new_title appears %d times in :\n\n%s\n", __LINE__, count, buffer) ; - - count = str_count (buffer, software) ; - exit_if_true (count < 1, "\n\nLine %d : Could not find new_software in :\n%s\n", __LINE__, buffer) ; - exit_if_true (count > 1, "\n\nLine %d : new_software appears %d times in :\n\n%s\n", __LINE__, count, buffer) ; - - count = str_count (buffer, new_artist) ; - exit_if_true (count < 1, "\n\nLine %d : Could not find new_artist in :\n%s\n", __LINE__, buffer) ; - exit_if_true (count > 1, "\n\nLine %d : new_artist appears %d times in :\n\n%s\n", __LINE__, count, buffer) ; - - count = str_count (buffer, new_copyright) ; - exit_if_true (count < 1, "\n\nLine %d : Could not find new_copyright in :\n%s\n", __LINE__, buffer) ; - exit_if_true (count > 1, "\n\nLine %d : new_copyright appears %d times in :\n\n%s\n", __LINE__, count, buffer) ; - - unlink (filename) ; - - puts ("ok") ; -} /* string_multi_set_test */ - -static void -string_rdwr_test (const char *filename, int typemajor) -{ SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t frames ; - const char * str ; - - get_unique_test_name (&filename, STR_TEST_PREFIX) ; - print_test_name (__func__, filename) ; - create_short_sndfile (filename, typemajor | SF_FORMAT_PCM_16, 2) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; - frames = sfinfo.frames ; - sf_set_string (file, SF_STR_TITLE, title) ; - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; - str = sf_get_string (file, SF_STR_TITLE) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; - frames = sfinfo.frames ; - sf_set_string (file, SF_STR_TITLE, title) ; - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; - str = sf_get_string (file, SF_STR_TITLE) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; - sf_set_string (file, SF_STR_ARTIST, artist) ; - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - str = sf_get_string (file, SF_STR_ARTIST) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_ARTIST string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ; - - str = sf_get_string (file, SF_STR_TITLE) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; - - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; - - sf_close (file) ; - unlink (filename) ; - - puts ("ok") ; -} /* string_rdwr_test */ - -static void -string_short_rdwr_test (const char *filename, int typemajor) -{ SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t frames = BUFFER_LEN ; - const char * str ; - - get_unique_test_name (&filename, STR_TEST_PREFIX) ; - print_test_name (__func__, filename) ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.format = typemajor | SF_FORMAT_PCM_16 ; - sfinfo.samplerate = 44100 ; - sfinfo.channels = 1 ; - sfinfo.frames = 0 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; - - /* Write data to file. */ - test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; - - sf_set_string (file, SF_STR_TITLE, long_title) ; - sf_set_string (file, SF_STR_ARTIST, long_artist) ; - sf_close (file) ; - - /* Open the file RDWR. */ - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; - str = sf_get_string (file, SF_STR_TITLE) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, long_title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; - str = sf_get_string (file, SF_STR_ARTIST) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, long_artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ; - - /* Change title and artist. */ - sf_set_string (file, SF_STR_TITLE, title) ; - sf_set_string (file, SF_STR_ARTIST, artist) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; - - check_log_buffer_or_die (file, __LINE__) ; - - str = sf_get_string (file, SF_STR_TITLE) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; - - str = sf_get_string (file, SF_STR_ARTIST) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_ARTIST string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ; - - sf_close (file) ; - unlink (filename) ; - - puts ("ok") ; -} /* string_short_rdwr_test */ - -static int -str_count (const char * haystack, const char * needle) -{ int count = 0 ; - - while ((haystack = strstr (haystack, needle)) != NULL) - { count ++ ; - haystack ++ ; - } ; - - return count ; -} /* str_count */ - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -static void -software_string_test (const char *filename) -{ size_t k ; - - get_unique_test_name (&filename, STR_TEST_PREFIX) ; - print_test_name (__func__, filename) ; - - for (k = 0 ; k < 50 ; k++) - { const char *result ; - char sfname [64] = "" ; - SNDFILE *file ; - SF_INFO info ; - - sf_info_setup (&info, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 44100, 1) ; - file = test_open_file_or_die (filename, SFM_WRITE, &info, SF_TRUE, __LINE__) ; - - snprintf (sfname, MIN (k, sizeof (sfname)), "%s", "abcdefghijklmnopqrestvwxyz0123456789abcdefghijklmnopqrestvwxyz") ; - - exit_if_true (sf_set_string (file, SF_STR_SOFTWARE, sfname), - "\n\nLine %d : sf_set_string (f, SF_STR_SOFTWARE, '%s') failed : %s\n", __LINE__, sfname, sf_strerror (file)) ; - - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &info, SF_TRUE, __LINE__) ; - result = sf_get_string (file, SF_STR_SOFTWARE) ; - - exit_if_true (result == NULL, "\n\nLine %d : sf_get_string (file, SF_STR_SOFTWARE) returned NULL.\n\n", __LINE__) ; - - exit_if_true (strstr (result, sfname) != result, - "\n\nLine %d : Can't fine string '%s' in '%s'\n\n", __LINE__, sfname, result) ; - sf_close (file) ; - } ; - - unlink (filename) ; - puts ("ok") ; -} /* software_string_test */ - - -static void -string_rdwr_grow_test (const char *filename, int typemajor) -{ SNDFILE *file ; - SF_INFO sfinfo ; - sf_count_t frames ; - const char * str ; - - get_unique_test_name (&filename, STR_TEST_PREFIX) ; - print_test_name (__func__, filename) ; - - /* Create a file that contains some strings. Then open the file in RDWR mode and - grow the file by writing more audio data to it. Check that the audio data has - been added to the file, and that the strings are still there. */ - - /* Create a short file that contains a string. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.channels = 2 ; - sfinfo.frames = 0 ; - sfinfo.format = typemajor | SF_FORMAT_PCM_16 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - /* Write data to file. */ - test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; - - /* Write some strings at end of file. */ - sf_set_string (file, SF_STR_TITLE , title) ; - sf_set_string (file, SF_STR_COMMENT, comment) ; - sf_close (file) ; - - - /* Now open file again in SFM_RDWR mode and write more audio data to it. */ - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; - /* Write more data to file. */ - test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; - sf_close (file) ; - - - /* Now open file again. It should now contain two BUFFER_LEN's worth of frames and the strings. */ - frames = 2 * BUFFER_LEN / sfinfo.channels ; - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; - - /* Check the strings */ - str = sf_get_string (file, SF_STR_TITLE) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; - - str = sf_get_string (file, SF_STR_COMMENT) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_COMMENT string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, comment) != 0, "\n\nLine %d : SF_STR_COMMENT doesn't match what was written.\n", __LINE__) ; - - sf_close (file) ; - unlink (filename) ; - - puts ("ok") ; -} /* string_rdwr_grow_test */ - -static void -string_header_update (const char *filename, int typemajor) -{ SNDFILE *file , *file1 ; - SF_INFO sfinfo , sfinfo1 ; - sf_count_t frames ; - const char * str ; - const int GROW_BUFFER_AMOUNT = 4 ; /* this should be less than half the size of the string header */ - - get_unique_test_name (&filename, STR_TEST_PREFIX) ; - print_test_name (__func__, filename) ; - - /* Create a short file. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.channels = 2 ; - sfinfo.frames = 0 ; - sfinfo.format = typemajor | SF_FORMAT_PCM_16 ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; - test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ; - sf_set_string (file, SF_STR_TITLE, long_title) ; - sf_close (file) ; - - - /* Check that SFC_UPDATE_HEADER_NOW correctly calculates datalength. */ - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; - /* Write a very small amount of new audio data that doesn't completely overwrite the existing header. */ - test_write_short_or_die (file, 0, data_out, GROW_BUFFER_AMOUNT, __LINE__) ; - - /* Update the header without closing the file. */ - sf_command (file, SFC_UPDATE_HEADER_NOW, NULL, 0) ; - - /* The file should now contain BUFFER_LEN + GROW_BUFFER_AMOUNT frames. - Open a second handle to the file and check the reported length. */ - memset (&sfinfo1, 0, sizeof (sfinfo1)) ; - file1 = test_open_file_or_die (filename, SFM_READ, &sfinfo1, SF_TRUE, __LINE__) ; - - frames = (BUFFER_LEN + GROW_BUFFER_AMOUNT) / sfinfo.channels ; - exit_if_true (frames != sfinfo1.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo1.frames, frames) ; - - /* The strings are probably not readable by the second soundfile handle because write_tailer has not yet been called. - It's a design decision whether SFC_UPDATE_HEADER_NOW should write the tailer. I think it's fine that it doesn't. */ - - sf_close (file1) ; - sf_close (file) ; - - - /* Check that sf_close correctly calculates datalength. */ - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; - /* Write a very small amount of new audio data that doesn't completely overwrite the existing header. */ - test_write_short_or_die (file, 0, data_out, GROW_BUFFER_AMOUNT, __LINE__) ; - sf_close (file) ; - - - /* Open file again and verify data and string. */ - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; - frames = (BUFFER_LEN + 2*GROW_BUFFER_AMOUNT) / sfinfo.channels ; - exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %" PRId64 " should be %" PRId64 ".\n", __LINE__, sfinfo.frames, frames) ; - str = sf_get_string (file, SF_STR_TITLE) ; - exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ; - exit_if_true (strcmp (str, long_title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ; - sf_close (file) ; - unlink (filename) ; - puts ("ok") ; -} /* string_header_update */ diff --git a/Engine/lib/libsndfile/tests/test_wrapper.sh.in b/Engine/lib/libsndfile/tests/test_wrapper.sh.in deleted file mode 100644 index ab92f7c44..000000000 --- a/Engine/lib/libsndfile/tests/test_wrapper.sh.in +++ /dev/null @@ -1,380 +0,0 @@ -#!/usr/bin/env sh - -# Copyright (C) 2008-2017 Erik de Castro Lopo -# -# 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 author nor the names of any 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. - - -HOST_TRIPLET=@HOST_TRIPLET@ -PACKAGE_VERSION=@PACKAGE_VERSION@ -LIB_VERSION=$(echo $PACKAGE_VERSION | sed "s/[a-z].*//") -ABS_TOP_SRCDIR=@abs_top_srcdir@ -PYTHON=@PYTHON@ - -sfversion=$(./tests/sfversion@EXEEXT@ | grep libsndfile | sed "s/-exp$//") - -if test "$sfversion" != libsndfile-$PACKAGE_VERSION ; then - echo "Error : sfversion ($sfversion) and PACKAGE_VERSION ($PACKAGE_VERSION) don't match." - exit 1 - fi - -# Force exit on errors. -set -e - -# Check the header file. -/usr/bin/env sh tests/pedantic-header-test.sh - -# Need this for when we're running from files collected into the -# libsndfile-testsuite-@PACKAGE_VERSION@ tarball. -echo "Running unit tests from src/ directory of source code tree." -./src/test_main@EXEEXT@ - -echo -echo "Running end-to-end tests from tests/ directory." - -./tests/error_test@EXEEXT@ -./tests/pcm_test@EXEEXT@ -./tests/ulaw_test@EXEEXT@ -./tests/alaw_test@EXEEXT@ -./tests/dwvw_test@EXEEXT@ -./tests/command_test@EXEEXT@ ver -./tests/command_test@EXEEXT@ norm -./tests/command_test@EXEEXT@ format -./tests/command_test@EXEEXT@ peak -./tests/command_test@EXEEXT@ trunc -./tests/command_test@EXEEXT@ inst -./tests/command_test@EXEEXT@ cue -./tests/command_test@EXEEXT@ current_sf_info -./tests/command_test@EXEEXT@ bext -./tests/command_test@EXEEXT@ bextch -./tests/command_test@EXEEXT@ chanmap -./tests/command_test@EXEEXT@ cart -./tests/floating_point_test@EXEEXT@ -./tests/checksum_test@EXEEXT@ -./tests/scale_clip_test@EXEEXT@ -./tests/headerless_test@EXEEXT@ -./tests/rdwr_test@EXEEXT@ -./tests/locale_test@EXEEXT@ -./tests/win32_ordinal_test@EXEEXT@ -./tests/external_libs_test@EXEEXT@ -./tests/format_check_test@EXEEXT@ -./tests/channel_test@EXEEXT@ - -# The w64 G++ compiler requires an extra runtime DLL which we don't have, -# so skip this test. -case "$HOST_TRIPLET" in - x86_64-w64-mingw32) - ;; - i686-w64-mingw32) - ;; - *) - ./tests/cpp_test@EXEEXT@ - ;; - esac - -echo "----------------------------------------------------------------------" -echo " $sfversion passed common tests." -echo "----------------------------------------------------------------------" - -# aiff-tests -./tests/write_read_test@EXEEXT@ aiff -./tests/lossy_comp_test@EXEEXT@ aiff_ulaw -./tests/lossy_comp_test@EXEEXT@ aiff_alaw -./tests/lossy_comp_test@EXEEXT@ aiff_gsm610 -echo "----------------------------------------------------------------------" -echo " lossy_comp_test@EXEEXT@ aiff_ima" -echo "----------------------------------------------------------------------" - -./tests/peak_chunk_test@EXEEXT@ aiff -./tests/header_test@EXEEXT@ aiff -./tests/misc_test@EXEEXT@ aiff -./tests/string_test@EXEEXT@ aiff -./tests/multi_file_test@EXEEXT@ aiff -./tests/aiff_rw_test@EXEEXT@ -./tests/chunk_test@EXEEXT@ aiff -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on AIFF files." -echo "----------------------------------------------------------------------" - -# au-tests -./tests/write_read_test@EXEEXT@ au -./tests/lossy_comp_test@EXEEXT@ au_ulaw -./tests/lossy_comp_test@EXEEXT@ au_alaw -./tests/lossy_comp_test@EXEEXT@ au_g721 -./tests/lossy_comp_test@EXEEXT@ au_g723 -./tests/header_test@EXEEXT@ au -./tests/misc_test@EXEEXT@ au -./tests/multi_file_test@EXEEXT@ au -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on AU files." -echo "----------------------------------------------------------------------" - -# caf-tests -./tests/write_read_test@EXEEXT@ caf -./tests/lossy_comp_test@EXEEXT@ caf_ulaw -./tests/lossy_comp_test@EXEEXT@ caf_alaw -./tests/header_test@EXEEXT@ caf -./tests/peak_chunk_test@EXEEXT@ caf -./tests/misc_test@EXEEXT@ caf -./tests/chunk_test@EXEEXT@ caf -./tests/string_test@EXEEXT@ caf -./tests/long_read_write_test@EXEEXT@ alac -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on CAF files." -echo "----------------------------------------------------------------------" - -# wav-tests -./tests/write_read_test@EXEEXT@ wav -./tests/lossy_comp_test@EXEEXT@ wav_pcm -./tests/lossy_comp_test@EXEEXT@ wav_ima -./tests/lossy_comp_test@EXEEXT@ wav_msadpcm -./tests/lossy_comp_test@EXEEXT@ wav_ulaw -./tests/lossy_comp_test@EXEEXT@ wav_alaw -./tests/lossy_comp_test@EXEEXT@ wav_gsm610 -./tests/lossy_comp_test@EXEEXT@ wav_g721 -./tests/peak_chunk_test@EXEEXT@ wav -./tests/header_test@EXEEXT@ wav -./tests/misc_test@EXEEXT@ wav -./tests/string_test@EXEEXT@ wav -./tests/multi_file_test@EXEEXT@ wav -./tests/chunk_test@EXEEXT@ wav -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on WAV files." -echo "----------------------------------------------------------------------" - -# w64-tests -./tests/write_read_test@EXEEXT@ w64 -./tests/lossy_comp_test@EXEEXT@ w64_ima -./tests/lossy_comp_test@EXEEXT@ w64_msadpcm -./tests/lossy_comp_test@EXEEXT@ w64_ulaw -./tests/lossy_comp_test@EXEEXT@ w64_alaw -./tests/lossy_comp_test@EXEEXT@ w64_gsm610 -./tests/header_test@EXEEXT@ w64 -./tests/misc_test@EXEEXT@ w64 -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on W64 files." -echo "----------------------------------------------------------------------" - -# rf64-tests -./tests/write_read_test@EXEEXT@ rf64 -./tests/header_test@EXEEXT@ rf64 -./tests/misc_test@EXEEXT@ rf64 -./tests/string_test@EXEEXT@ rf64 -./tests/peak_chunk_test@EXEEXT@ rf64 -./tests/chunk_test@EXEEXT@ rf64 -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on RF64 files." -echo "----------------------------------------------------------------------" - -# raw-tests -./tests/write_read_test@EXEEXT@ raw -./tests/lossy_comp_test@EXEEXT@ raw_ulaw -./tests/lossy_comp_test@EXEEXT@ raw_alaw -./tests/lossy_comp_test@EXEEXT@ raw_gsm610 -./tests/lossy_comp_test@EXEEXT@ vox_adpcm -./tests/raw_test@EXEEXT@ -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on RAW (header-less) files." -echo "----------------------------------------------------------------------" - -# paf-tests -./tests/write_read_test@EXEEXT@ paf -./tests/header_test@EXEEXT@ paf -./tests/misc_test@EXEEXT@ paf -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on PAF files." -echo "----------------------------------------------------------------------" - -# svx-tests -./tests/write_read_test@EXEEXT@ svx -./tests/header_test@EXEEXT@ svx -./tests/misc_test@EXEEXT@ svx -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on SVX files." -echo "----------------------------------------------------------------------" - -# nist-tests -./tests/write_read_test@EXEEXT@ nist -./tests/lossy_comp_test@EXEEXT@ nist_ulaw -./tests/lossy_comp_test@EXEEXT@ nist_alaw -./tests/header_test@EXEEXT@ nist -./tests/misc_test@EXEEXT@ nist -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on NIST files." -echo "----------------------------------------------------------------------" - -# ircam-tests -./tests/write_read_test@EXEEXT@ ircam -./tests/lossy_comp_test@EXEEXT@ ircam_ulaw -./tests/lossy_comp_test@EXEEXT@ ircam_alaw -./tests/header_test@EXEEXT@ ircam -./tests/misc_test@EXEEXT@ ircam -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on IRCAM files." -echo "----------------------------------------------------------------------" - -# voc-tests -./tests/write_read_test@EXEEXT@ voc -./tests/lossy_comp_test@EXEEXT@ voc_ulaw -./tests/lossy_comp_test@EXEEXT@ voc_alaw -./tests/header_test@EXEEXT@ voc -./tests/misc_test@EXEEXT@ voc -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on VOC files." -echo "----------------------------------------------------------------------" - -# mat4-tests -./tests/write_read_test@EXEEXT@ mat4 -./tests/header_test@EXEEXT@ mat4 -./tests/misc_test@EXEEXT@ mat4 -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on MAT4 files." -echo "----------------------------------------------------------------------" - -# mat5-tests -./tests/write_read_test@EXEEXT@ mat5 -./tests/header_test@EXEEXT@ mat5 -./tests/misc_test@EXEEXT@ mat5 -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on MAT5 files." -echo "----------------------------------------------------------------------" - -# pvf-tests -./tests/write_read_test@EXEEXT@ pvf -./tests/header_test@EXEEXT@ pvf -./tests/misc_test@EXEEXT@ pvf -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on PVF files." -echo "----------------------------------------------------------------------" - -# xi-tests -./tests/lossy_comp_test@EXEEXT@ xi_dpcm -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on XI files." -echo "----------------------------------------------------------------------" - -# htk-tests -./tests/write_read_test@EXEEXT@ htk -./tests/header_test@EXEEXT@ htk -./tests/misc_test@EXEEXT@ htk -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on HTK files." -echo "----------------------------------------------------------------------" - -# avr-tests -./tests/write_read_test@EXEEXT@ avr -./tests/header_test@EXEEXT@ avr -./tests/misc_test@EXEEXT@ avr -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on AVR files." -echo "----------------------------------------------------------------------" - -# sds-tests -./tests/write_read_test@EXEEXT@ sds -./tests/header_test@EXEEXT@ sds -./tests/misc_test@EXEEXT@ sds -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on SDS files." -echo "----------------------------------------------------------------------" - -# sd2-tests -./tests/write_read_test@EXEEXT@ sd2 -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on SD2 files." -echo "----------------------------------------------------------------------" - -# wve-tests -./tests/lossy_comp_test@EXEEXT@ wve -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on WVE files." -echo "----------------------------------------------------------------------" - -# mpc2k-tests -./tests/write_read_test@EXEEXT@ mpc2k -./tests/header_test@EXEEXT@ mpc2k -./tests/misc_test@EXEEXT@ mpc2k -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on MPC 2000 files." -echo "----------------------------------------------------------------------" - -# flac-tests -./tests/write_read_test@EXEEXT@ flac -./tests/compression_size_test@EXEEXT@ flac -./tests/string_test@EXEEXT@ flac -./tests/header_test@EXEEXT@ flac -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on FLAC files." -echo "----------------------------------------------------------------------" - -# vorbis-tests -./tests/ogg_test@EXEEXT@ -./tests/compression_size_test@EXEEXT@ vorbis -./tests/lossy_comp_test@EXEEXT@ ogg_vorbis -./tests/string_test@EXEEXT@ ogg -./tests/misc_test@EXEEXT@ ogg -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on OGG/VORBIS files." -echo "----------------------------------------------------------------------" - -# opus-tests -./tests/ogg_opus_test@EXEEXT@ -./tests/compression_size_test@EXEEXT@ opus -./tests/lossy_comp_test@EXEEXT@ ogg_opus -./tests/string_test@EXEEXT@ opus - -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on OPUS files." -echo "----------------------------------------------------------------------" - -# mpeg-tests -./tests/mpeg_test@EXEEXT@ -./tests/compression_size_test@EXEEXT@ mpeg -./tests/string_test@EXEEXT@ mpeg - -echo "----------------------------------------------------------------------" -echo " $sfversion passed tests on MPEG files." -echo "----------------------------------------------------------------------" - -# io-tests -./tests/stdio_test@EXEEXT@ -./tests/pipe_test@EXEEXT@ -./tests/virtual_io_test@EXEEXT@ -echo "----------------------------------------------------------------------" -echo " $sfversion passed stdio/pipe/vio tests." -echo "----------------------------------------------------------------------" - -"${PYTHON}" "${ABS_TOP_SRCDIR}/src/binheader_writef_check.py" "${ABS_TOP_SRCDIR}/src"/*.c -echo "----------------------------------------------------------------------" -echo " $sfversion passed binary header tests." -echo "----------------------------------------------------------------------" - -"${PYTHON}" "${ABS_TOP_SRCDIR}/programs/test-sndfile-metadata-set.py" "${HOST_TRIPLET}" -echo "----------------------------------------------------------------------" -echo " $sfversion passed sndfile metadata tests." -echo "----------------------------------------------------------------------" diff --git a/Engine/lib/libsndfile/tests/ulaw_test.c b/Engine/lib/libsndfile/tests/ulaw_test.c deleted file mode 100644 index cf2084bd4..000000000 --- a/Engine/lib/libsndfile/tests/ulaw_test.c +++ /dev/null @@ -1,259 +0,0 @@ -/* -** Copyright (C) 1999-2012 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" - -#define BUFFER_SIZE (65536) - -static unsigned char ulaw_encode (int sample) ; -static int ulaw_decode (unsigned int ulawbyte) ; - -static short short_buffer [BUFFER_SIZE] ; -static unsigned char ulaw_buffer [BUFFER_SIZE] ; - -int -main (void) -{ SNDFILE *file ; - SF_INFO sfinfo ; - const char *filename ; - int k ; - - print_test_name ("ulaw_test", "encoder") ; - - filename = "ulaw_test.raw" ; - - sf_info_setup (&sfinfo, SF_FORMAT_RAW | SF_FORMAT_ULAW, 44100, 1) ; - - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { printf ("sf_open_write failed with error : ") ; - fflush (stdout) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - /* Generate a file containing all possible 16 bit sample values - ** and write it to disk as ulaw encoded.frames. - */ - - for (k = 0 ; k < 0x10000 ; k++) - short_buffer [k] = k & 0xFFFF ; - - sf_write_short (file, short_buffer, BUFFER_SIZE) ; - sf_close (file) ; - - /* Now open that file and compare the ulaw encoded sample values - ** with what they should be. - */ - - if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL) - { printf ("sf_open_write failed with error : ") ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - if (sf_read_raw (file, ulaw_buffer, BUFFER_SIZE) != BUFFER_SIZE) - { printf ("sf_read_raw : ") ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - for (k = 0 ; k < 0x10000 ; k++) - if (ulaw_encode (short_buffer [k]) != ulaw_buffer [k]) - { printf ("Encoder error : sample #%d (0x%02X should be 0x%02X)\n", k, ulaw_buffer [k], ulaw_encode (short_buffer [k])) ; - exit (1) ; - } ; - - sf_close (file) ; - - puts ("ok") ; - - print_test_name ("ulaw_test", "decoder") ; - - /* Now generate a file containing all possible 8 bit encoded - ** sample values and write it to disk as ulaw encoded.frames. - */ - - if (! (file = sf_open (filename, SFM_WRITE, &sfinfo))) - { printf ("sf_open_write failed with error : ") ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - for (k = 0 ; k < 256 ; k++) - ulaw_buffer [k] = k & 0xFF ; - - sf_write_raw (file, ulaw_buffer, 256) ; - sf_close (file) ; - - /* Now open that file and compare the ulaw decoded sample values - ** with what they should be. - */ - - if (! (file = sf_open (filename, SFM_READ, &sfinfo))) - { printf ("sf_open_write failed with error : ") ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - if (sf_read_short (file, short_buffer, 256) != 256) - { printf ("sf_read_short : ") ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - - for (k = 0 ; k < 256 ; k++) - if (short_buffer [k] != ulaw_decode (ulaw_buffer [k])) - { printf ("Decoder error : sample #%d (0x%04X should be 0x%04X)\n", k, short_buffer [k], ulaw_decode (ulaw_buffer [k])) ; - exit (1) ; - } ; - - sf_close (file) ; - - puts ("ok") ; - - unlink (filename) ; - - return 0 ; -} /* main */ - - -/*================================================================================= -** The following routines came from the sox-12.15 (Sound eXcahcnge) distribution. -** -** This code is not compiled into libsndfile. It is only used to test the -** libsndfile lookup tables for correctness. -** -** I have included the original authors comments. -*/ - -/* -** This routine converts from linear to ulaw. -** -** Craig Reese: IDA/Supercomputing Research Center -** Joe Campbell: Department of Defense -** 29 September 1989 -** -** References: -** 1) CCITT Recommendation G.711 (very difficult to follow) -** 2) "A New Digital Technique for Implementation of Any -** Continuous PCM Companding Law," Villeret, Michel, -** et al. 1973 IEEE Int. Conf. on Communications, Vol 1, -** 1973, pg. 11.12-11.17 -** 3) MIL-STD-188-113,"Interoperability and Performance Standards -** for Analog-to_Digital Conversion Techniques," -** 17 February 1987 -** -** Input: Signed 16 bit linear sample -** Output: 8 bit ulaw sample -*/ - -#define uBIAS 0x84 /* define the add-in bias for 16 bit.frames */ -#define uCLIP 32635 - -static -unsigned char ulaw_encode (int sample) -{ static int exp_lut [256] = - { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 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, 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, - 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, 7, 7, 7, 7, 7, 7, 7, 7 - } ; - - int sign, exponent, mantissa ; - unsigned char ulawbyte ; - - /* Get the sample into sign-magnitude. */ - sign = (sample >> 8) & 0x80 ; /* set aside the sign */ - if (sign != 0) - sample = -sample ; /* get magnitude */ - if (sample > uCLIP) - sample = uCLIP ; /* clip the magnitude */ - - /* Convert from 16 bit linear to ulaw. */ - sample = sample + uBIAS ; - exponent = exp_lut [(sample >> 7) & 0xFF] ; - mantissa = (sample >> (exponent + 3)) & 0x0F ; - ulawbyte = ~ (sign | (exponent << 4) | mantissa) ; - - return ulawbyte ; -} /* ulaw_encode */ - - -/* -** This routine converts from ulaw to 16 bit linear. -** -** Craig Reese: IDA/Supercomputing Research Center -** 29 September 1989 -** -** References: -** 1) CCITT Recommendation G.711 (very difficult to follow) -** 2) MIL-STD-188-113,"Interoperability and Performance Standards -** for Analog-to_Digital Conversion Techniques," -** 17 February 1987 -** -** Input: 8 bit ulaw sample -** Output: signed 16 bit linear sample -*/ - -static -int ulaw_decode (unsigned int ulawbyte) -{ static int exp_lut [8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 } ; - int sign, exponent, mantissa, sample ; - - ulawbyte = ~ ulawbyte ; - sign = (ulawbyte & 0x80) ; - exponent = (ulawbyte >> 4) & 0x07 ; - mantissa = ulawbyte & 0x0F ; - sample = exp_lut [exponent] + (mantissa << (exponent + 3)) ; - if (sign != 0) - sample = -sample ; - - return sample ; -} /* ulaw_decode */ - diff --git a/Engine/lib/libsndfile/tests/utils.def b/Engine/lib/libsndfile/tests/utils.def deleted file mode 100644 index 0d94183d2..000000000 --- a/Engine/lib/libsndfile/tests/utils.def +++ /dev/null @@ -1,52 +0,0 @@ -autogen definitions utils.tpl; - -float_type = { - name = float ; - }; - -float_type = { - name = double ; - }; - -/*----------------------------------*/ - -io_type = { - io_element = short ; - format_str = "\"% d\"" ; - }; - -io_type = { - io_element = int ; - format_str = "\"% d\"" ; - }; - -io_type = { - io_element = float ; - format_str = "\"% g\"" ; - }; - -io_type = { - io_element = double ; - format_str = "\"% g\"" ; - }; - -read_op = { - op_element = read ; - count_name = items ; - }; - -read_op = { - op_element = readf ; - count_name = frames ; - }; - -write_op = { - op_element = write ; - count_name = items ; - }; - -write_op = { - op_element = writef ; - count_name = frames ; - }; - diff --git a/Engine/lib/libsndfile/tests/utils.tpl b/Engine/lib/libsndfile/tests/utils.tpl deleted file mode 100644 index 0d1cd8bb9..000000000 --- a/Engine/lib/libsndfile/tests/utils.tpl +++ /dev/null @@ -1,961 +0,0 @@ -[+ AutoGen5 template h c +] -/* -** Copyright (C) 2002-2018 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** Utility functions to make writing the test suite easier. -** -** The .c and .h files were generated automagically with Autogen from -** the files utils.def and utils.tpl. -*/ - -[+ CASE (suffix) +] -[+ == h +] - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "sfconfig.h" - -#include -#include - -#define ARRAY_LEN(x) ((int) (sizeof (x)) / (sizeof ((x) [0]))) -#define SIGNED_SIZEOF(x) ((int64_t) (sizeof (x))) -#define NOT(x) (! (x)) -#define ABS(x) ((x) >= 0 ? (x) : - (x)) - -#define PIPE_INDEX(x) ((x) + 500) -#define PIPE_TEST_LEN 12345 - - -[+ FOR float_type -+]void gen_windowed_sine_[+ (get "name") +] ([+ (get "name") +] *data, int len, double maximum) ; -[+ ENDFOR float_type -+] - -void create_short_sndfile (const char *filename, int format, int channels) ; - -void check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num) ; - -void print_test_name (const char *test, const char *filename) ; - -void dump_data_to_file (const char *filename, const void *data, unsigned int datalen) ; - -void write_mono_file (const char * filename, int format, int srate, float * output, int len) ; - -#ifdef __GNUC__ -static inline void -exit_if_true (int test, const char *format, ...) -#if (defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO && !defined (__clang__)) - __attribute__ ((format (gnu_printf, 2, 3))) ; -#else - __attribute__ ((format (printf, 2, 3))) ; -#endif -#endif - -static inline void -exit_if_true (int test, const char *format, ...) -{ if (test) - { va_list argptr ; - va_start (argptr, format) ; - vprintf (format, argptr) ; - va_end (argptr) ; - exit (1) ; - } ; -} /* exit_if_true */ - -static inline int32_t -arith_shift_left (int32_t x, int shift) -{ return (int32_t) (((uint32_t) x) << shift) ; -} /* arith_shift_left */ - -/* -** Functions for saving two vectors of data in an ascii text file which -** can then be loaded into GNU octave for comparison. -*/ - -[+ FOR io_type -+]int oct_save_[+ (get "io_element") +] (const [+ (get "io_element") +] *a, const [+ (get "io_element") +] *b, int len) ; -[+ ENDFOR io_type -+] - -void delete_file (int format, const char *filename) ; - -int truncate_file_to_zero (const char *fname) ; - -void count_open_files (void) ; -void increment_open_file_count (void) ; -void check_open_file_count_or_die (int lineno) ; - -void get_unique_test_name (const char ** filename, const char * test) ; - -#ifdef SNDFILE_H - -static inline void -sf_info_clear (SF_INFO * info) -{ memset (info, 0, sizeof (SF_INFO)) ; -} /* sf_info_clear */ - -static inline void -sf_info_setup (SF_INFO * info, int format, int samplerate, int channels) -{ sf_info_clear (info) ; - - info->format = format ; - info->samplerate = samplerate ; - info->channels = channels ; -} /* sf_info_setup */ - - -void dump_log_buffer (SNDFILE *file) ; -void check_log_buffer_or_die (SNDFILE *file, int line_num) ; -int string_in_log_buffer (SNDFILE *file, const char *s) ; -void hexdump_file (const char * filename, sf_count_t offset, sf_count_t length) ; - -void test_sf_format_or_die (const SF_INFO *info, int line_num) ; - -SNDFILE *test_open_file_or_die - (const char *filename, int mode, SF_INFO *sfinfo, int allow_fd, int line_num) ; - -void test_read_write_position_or_die - (SNDFILE *file, int line_num, int pass, sf_count_t read_pos, sf_count_t write_pos) ; - -void test_seek_or_die - (SNDFILE *file, sf_count_t offset, int whence, sf_count_t new_pos, int channels, int line_num) ; - -[+ FOR read_op +] -[+ FOR io_type -+]void test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die - (SNDFILE *file, int pass, [+ (get "io_element") +] *test, sf_count_t [+ (get "count_name") +], int line_num) ; -[+ ENDFOR io_type +][+ ENDFOR read_op +] - -void -test_read_raw_or_die (SNDFILE *file, int pass, void *test, sf_count_t items, int line_num) ; - -[+ FOR write_op +] -[+ FOR io_type -+]void test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die - (SNDFILE *file, int pass, const [+ (get "io_element") +] *test, sf_count_t [+ (get "count_name") +], int line_num) ; -[+ ENDFOR io_type +][+ ENDFOR write_op +] - -void -test_write_raw_or_die (SNDFILE *file, int pass, const void *test, sf_count_t items, int line_num) ; - -[+ FOR io_type -+]void compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *expected, const [+ (get "io_element") +] *actual, unsigned count, int line_num) ; -[+ ENDFOR io_type +] - - -void gen_lowpass_signal_float (float *data, int len) ; - -sf_count_t file_length (const char * fname) ; -sf_count_t file_length_fd (int fd) ; - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -[+ == c +] - -#include "sfconfig.h" - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#endif - -#if (HAVE_DECL_S_IRGRP == 0) -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "utils.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846264338 -#endif - -#define LOG_BUFFER_SIZE 4096 - -/* -** Neat solution to the Win32/OS2 binary file flage requirement. -** If O_BINARY isn't already defined by the inclusion of the system -** headers, set it to zero. -*/ -#ifndef O_BINARY -#define O_BINARY 0 -#endif - - -/* -** Compare for equality, with epsilon -*/ -static inline int -equals_short (const short a, const short b) -{ return (a == b); -} /* equals_short */ -static inline int -equals_int (const int a, const int b) -{ return (a == b); -} /* equals_int */ -static inline int -equals_float (const float a, const float b) -{ return (fabsf(a - b) <= FLT_EPSILON); -} /* equals_float */ -static inline int -equals_double (const double a, const double b) -{ return (fabs(a - b) <= DBL_EPSILON); -} /* equals_double */ - - -[+ FOR float_type +] -void -gen_windowed_sine_[+ (get "name") +] ([+ (get "name") +] *data, int len, double maximum) -{ int k ; - - memset (data, 0, len * sizeof ([+ (get "name") +])) ; - - len = (5 * len) / 6 ; - - for (k = 0 ; k < len ; k++) - { data [k] = sin (2.0 * k * M_PI * 1.0 / 32.0 + 0.4) ; - - /* Apply Hanning Window. */ - data [k] *= maximum * (0.5 - 0.5 * cos (2.0 * M_PI * k / ((len) - 1))) ; - } - - return ; -} /* gen_windowed_sine_[+ (get "name") +] */ -[+ ENDFOR float_type +] - -void -create_short_sndfile (const char *filename, int format, int channels) -{ short data [2 * 3 * 4 * 5 * 6 * 7] = { 0, } ; - SNDFILE *file ; - SF_INFO sfinfo ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.samplerate = 44100 ; - sfinfo.channels = channels ; - sfinfo.format = format ; - - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { printf ("Error (%s, %d) : sf_open failed : %s\n", __FILE__, __LINE__, sf_strerror (file)) ; - exit (1) ; - } ; - - sf_write_short (file, data, ARRAY_LEN (data)) ; - - sf_close (file) ; -} /* create_short_sndfile */ - -void -check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num) -{ static unsigned char buf [4096] ; - uint64_t cksum ; - FILE *file ; - int k, read_count ; - - memset (buf, 0, sizeof (buf)) ; - - /* The 'b' in the mode string means binary for Win32. */ - if ((file = fopen (filename, "rb")) == NULL) - { printf ("\n\nLine %d: could not open file '%s'\n\n", line_num, filename) ; - exit (1) ; - } ; - - cksum = 0 ; - - while ((read_count = fread (buf, 1, sizeof (buf), file))) - for (k = 0 ; k < read_count ; k++) - cksum = (cksum * 511 + buf [k]) & 0xfffffffffffff ; - - fclose (file) ; - - if (target_hash == 0) - { printf (" 0x%" PRIx64 "\n", cksum) ; - return ; - } ; - - if (cksum != target_hash) - { printf ("\n\nLine %d: incorrect hash value 0x%" PRIx64 " should be 0x%" PRIx64 ".\n\n", line_num, cksum, target_hash) ; - exit (1) ; - } ; - - return ; -} /* check_file_hash_or_die */ - -void -print_test_name (const char *test, const char *filename) -{ int count ; - - if (test == NULL) - { printf (__FILE__ ": bad test of filename parameter.\n") ; - exit (1) ; - } ; - - if (filename == NULL || strlen (filename) == 0) - { printf (" %-30s : ", test) ; - count = 25 ; - } - else - { printf (" %-30s : %s ", test, filename) ; - count = 24 - strlen (filename) ; - } ; - - while (count -- > 0) - putchar ('.') ; - putchar (' ') ; - - fflush (stdout) ; -} /* print_test_name */ - -void -dump_data_to_file (const char *filename, const void *data, unsigned int datalen) -{ FILE *file ; - - if ((file = fopen (filename, "wb")) == NULL) - { printf ("\n\nLine %d : could not open file : %s\n\n", __LINE__, filename) ; - exit (1) ; - } ; - - if (fwrite (data, 1, datalen, file) != datalen) - { printf ("\n\nLine %d : fwrite failed.\n\n", __LINE__) ; - exit (1) ; - } ; - - fclose (file) ; - -} /* dump_data_to_file */ - -/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -*/ - -static char octfilename [] = "error.dat" ; - -[+ FOR io_type -+]int -oct_save_[+ (get "io_element") +] (const [+ (get "io_element") +] *a, const [+ (get "io_element") +] *b, int len) -{ FILE *file ; - int k ; - - if (! (file = fopen (octfilename, "w"))) - return 1 ; - - fprintf (file, "# Not created by Octave\n") ; - - fprintf (file, "# name: a\n") ; - fprintf (file, "# type: matrix\n") ; - fprintf (file, "# rows: %d\n", len) ; - fprintf (file, "# columns: 1\n") ; - - for (k = 0 ; k < len ; k++) - fprintf (file, [+ (get "format_str") +] "\n", a [k]) ; - - fprintf (file, "# name: b\n") ; - fprintf (file, "# type: matrix\n") ; - fprintf (file, "# rows: %d\n", len) ; - fprintf (file, "# columns: 1\n") ; - - for (k = 0 ; k < len ; k++) - fprintf (file, [+ (get "format_str") +] "\n", b [k]) ; - - fclose (file) ; - return 0 ; -} /* oct_save_[+ (get "io_element") +] */ -[+ ENDFOR io_type -+] - -void -check_log_buffer_or_die (SNDFILE *file, int line_num) -{ static char buffer [LOG_BUFFER_SIZE] ; - int count ; - - memset (buffer, 0, sizeof (buffer)) ; - - /* Get the log buffer data. */ - count = sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; - - if (LOG_BUFFER_SIZE - count < 2) - { printf ("\n\nLine %d : Possible long log buffer.\n", line_num) ; - exit (1) ; - } - - /* Look for "Should" */ - if (strstr (buffer, "ould")) - { printf ("\n\nLine %d : Log buffer contains `ould'. Dumping.\n", line_num) ; - puts (buffer) ; - exit (1) ; - } ; - - /* Look for "**" */ - if (strstr (buffer, "*")) - { printf ("\n\nLine %d : Log buffer contains `*'. Dumping.\n", line_num) ; - puts (buffer) ; - exit (1) ; - } ; - - /* Look for "Should" */ - if (strstr (buffer, "nknown marker")) - { printf ("\n\nLine %d : Log buffer contains `nknown marker'. Dumping.\n", line_num) ; - puts (buffer) ; - exit (1) ; - } ; - - return ; -} /* check_log_buffer_or_die */ - -int -string_in_log_buffer (SNDFILE *file, const char *s) -{ static char buffer [LOG_BUFFER_SIZE] ; - int count ; - - memset (buffer, 0, sizeof (buffer)) ; - - /* Get the log buffer data. */ - count = sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; - - if (LOG_BUFFER_SIZE - count < 2) - { printf ("Possible long log buffer.\n") ; - exit (1) ; - } - - /* Look for string */ - return strstr (buffer, s) ? SF_TRUE : SF_FALSE ; -} /* string_in_log_buffer */ - -void -hexdump_file (const char * filename, sf_count_t offset, sf_count_t length) -{ - FILE * file ; - char buffer [16] ; - int k, m, ch, readcount ; - - if (length > 1000000) - { printf ("\n\nError : length (%" PRId64 ") too long.\n\n", offset) ; - exit (1) ; - } ; - - if ((file = fopen (filename, "r")) == NULL) - { printf ("\n\nError : hexdump_file (%s) could not open file for read.\n\n", filename) ; - exit (1) ; - } ; - - if (fseek (file, offset, SEEK_SET) != 0) - { printf ("\n\nError : fseek(file, %" PRId64 ", SEEK_SET) failed : %s\n\n", offset, strerror (errno)) ; - exit (1) ; - } ; - - puts ("\n\n") ; - - for (k = 0 ; k < length ; k+= sizeof (buffer)) - { readcount = fread (buffer, 1, sizeof (buffer), file) ; - - printf ("%08" PRIx64 " : ", offset + k) ; - - for (m = 0 ; m < readcount ; m++) - printf ("%02x ", buffer [m] & 0xFF) ; - - for (m = readcount ; m < SIGNED_SIZEOF (buffer) ; m++) - printf (" ") ; - - printf (" ") ; - for (m = 0 ; m < readcount ; m++) - { ch = isprint (buffer [m]) ? buffer [m] : '.' ; - putchar (ch) ; - } ; - - if (readcount < SIGNED_SIZEOF (buffer)) - break ; - - putchar ('\n') ; - } ; - - puts ("\n") ; - - fclose (file) ; -} /* hexdump_file */ - -void -dump_log_buffer (SNDFILE *file) -{ static char buffer [LOG_BUFFER_SIZE] ; - - memset (buffer, 0, sizeof (buffer)) ; - - /* Get the log buffer data. */ - sf_command (file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ; - - if (strlen (buffer) < 1) - puts ("Log buffer empty.\n") ; - else - puts (buffer) ; - - return ; -} /* dump_log_buffer */ - -void -test_sf_format_or_die (const SF_INFO *info, int line_num) -{ int res ; - - if ((res = sf_format_check (info)) != 1) - { printf ("\n\nLine %d : sf_format_check returned error (%d)\n\n", line_num, res) ; - exit (1) ; - } ; - - return ; -} /* test_sf_format_or_die */ - -SNDFILE * -test_open_file_or_die (const char *filename, int mode, SF_INFO *sfinfo, int allow_fd, int line_num) -{ static int count = 0 ; - - SNDFILE *file ; - const char *modestr, *func_name ; - int oflags = 0, omode = 0, err ; - - /* - ** Need to test both sf_open() and sf_open_fd(). - ** Do so alternately. - */ - switch (mode) - { case SFM_READ : - modestr = "SFM_READ" ; - oflags = O_RDONLY | O_BINARY ; - omode = 0 ; - break ; - - case SFM_WRITE : - modestr = "SFM_WRITE" ; - oflags = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY ; - omode = S_IRUSR | S_IWUSR | S_IRGRP ; - break ; - - case SFM_RDWR : - modestr = "SFM_RDWR" ; - oflags = O_RDWR | O_CREAT | O_BINARY ; - omode = S_IRUSR | S_IWUSR | S_IRGRP ; - break ; - default : - printf ("\n\nLine %d: Bad mode.\n", line_num) ; - fflush (stdout) ; - exit (1) ; - } ; - - if (OS_IS_WIN32) - { /* Windows does not understand and ignores the S_IRGRP flag, but Wine - ** gives a run time warning message, so just clear it. - */ - omode &= ~S_IRGRP ; - } ; - - if (allow_fd && ((++count) & 1) == 1) - { int fd ; - - /* Only use the three argument open() function if omode != 0. */ - fd = (omode == 0) ? open (filename, oflags) : open (filename, oflags, omode) ; - - if (fd < 0) - { printf ("\n\n%s : open failed : %s\n", __func__, strerror (errno)) ; - exit (1) ; - } ; - - func_name = "sf_open_fd" ; - file = sf_open_fd (fd, mode, sfinfo, SF_TRUE) ; - } - else - { func_name = "sf_open" ; - file = sf_open (filename, mode, sfinfo) ; - } ; - - if (file == NULL) - { printf ("\n\nLine %d: %s (%s) failed : %s\n\n", line_num, func_name, modestr, sf_strerror (NULL)) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - err = sf_error (file) ; - if (err != SF_ERR_NO_ERROR) - { printf ("\n\nLine %d : sf_error : %s\n\n", line_num, sf_error_number (err)) ; - dump_log_buffer (file) ; - exit (1) ; - } ; - - return file ; -} /* test_open_file_or_die */ - -void -test_read_write_position_or_die (SNDFILE *file, int line_num, int pass, sf_count_t read_pos, sf_count_t write_pos) -{ sf_count_t pos ; - - /* Check the current read position. */ - if (read_pos >= 0 && (pos = sf_seek (file, 0, SEEK_CUR | SFM_READ)) != read_pos) - { printf ("\n\nLine %d ", line_num) ; - if (pass > 0) - printf ("(pass %d): ", pass) ; - printf ("Read position (%" PRId64 ") should be %" PRId64 ".\n", pos, read_pos) ; - exit (1) ; - } ; - - /* Check the current write position. */ - if (write_pos >= 0 && (pos = sf_seek (file, 0, SEEK_CUR | SFM_WRITE)) != write_pos) - { printf ("\n\nLine %d", line_num) ; - if (pass > 0) - printf (" (pass %d)", pass) ; - printf (" : Write position (%" PRId64 ") should be %" PRId64 ".\n", pos, write_pos) ; - exit (1) ; - } ; - - return ; -} /* test_read_write_position */ - -void -test_seek_or_die (SNDFILE *file, sf_count_t offset, int whence, sf_count_t new_pos, int channels, int line_num) -{ sf_count_t position ; - const char *channel_name, *whence_name ; - - switch (whence) - { case SEEK_SET : - whence_name = "SEEK_SET" ; - break ; - case SEEK_CUR : - whence_name = "SEEK_CUR" ; - break ; - case SEEK_END : - whence_name = "SEEK_END" ; - break ; - - /* SFM_READ */ - case SEEK_SET | SFM_READ : - whence_name = "SFM_READ | SEEK_SET" ; - break ; - case SEEK_CUR | SFM_READ : - whence_name = "SFM_READ | SEEK_CUR" ; - break ; - case SEEK_END | SFM_READ : - whence_name = "SFM_READ | SEEK_END" ; - break ; - - /* SFM_WRITE */ - case SEEK_SET | SFM_WRITE : - whence_name = "SFM_WRITE | SEEK_SET" ; - break ; - case SEEK_CUR | SFM_WRITE : - whence_name = "SFM_WRITE | SEEK_CUR" ; - break ; - case SEEK_END | SFM_WRITE : - whence_name = "SFM_WRITE | SEEK_END" ; - break ; - - default : - printf ("\n\nLine %d: bad whence parameter.\n", line_num) ; - exit (1) ; - } ; - - channel_name = (channels == 1) ? "Mono" : "Stereo" ; - - if ((position = sf_seek (file, offset, whence)) != new_pos) - { printf ("\n\nLine %d : %s : sf_seek (file, %" PRId64 ", %s) returned %" PRId64 " (should be %" PRId64 ").\n\n", - line_num, channel_name, offset, whence_name, position, new_pos) ; - exit (1) ; - } ; - -} /* test_seek_or_die */ - -[+ FOR read_op +] -[+ FOR io_type +] -void -test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die (SNDFILE *file, int pass, [+ (get "io_element") +] *test, sf_count_t [+ (get "count_name") +], int line_num) -{ sf_count_t count ; - - if ((count = sf_[+ (get "op_element") +]_[+ (get "io_element") +] (file, test, [+ (get "count_name") +])) != [+ (get "count_name") +]) - { printf ("\n\nLine %d", line_num) ; - if (pass > 0) - printf (" (pass %d)", pass) ; - printf (" : sf_[+ (get "op_element") +]_[+ (get "io_element") +] failed with short [+ (get "op_element") +] (%" PRId64 " => %" PRId64 ").\n", - [+ (get "count_name") +], count) ; - fflush (stdout) ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - return ; -} /* test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die */ -[+ ENDFOR io_type +][+ ENDFOR read_op +] - -void -test_read_raw_or_die (SNDFILE *file, int pass, void *test, sf_count_t items, int line_num) -{ sf_count_t count ; - - if ((count = sf_read_raw (file, test, items)) != items) - { printf ("\n\nLine %d", line_num) ; - if (pass > 0) - printf (" (pass %d)", pass) ; - printf (" : sf_read_raw failed with short read (%" PRId64 " => %" PRId64 ").\n", items, count) ; - fflush (stdout) ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - return ; -} /* test_read_raw_or_die */ - -[+ FOR write_op +] -[+ FOR io_type +] -void -test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die (SNDFILE *file, int pass, const [+ (get "io_element") +] *test, sf_count_t [+ (get "count_name") +], int line_num) -{ sf_count_t count ; - - if ((count = sf_[+ (get "op_element") +]_[+ (get "io_element") +] (file, test, [+ (get "count_name") +])) != [+ (get "count_name") +]) - { printf ("\n\nLine %d", line_num) ; - if (pass > 0) - printf (" (pass %d)", pass) ; - printf (" : sf_[+ (get "op_element") +]_[+ (get "io_element") +] failed with short [+ (get "op_element") +] (%" PRId64 " => %" PRId64 ").\n", - [+ (get "count_name") +], count) ; - fflush (stdout) ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - return ; -} /* test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die */ -[+ ENDFOR io_type +][+ ENDFOR write_op +] - -void -test_write_raw_or_die (SNDFILE *file, int pass, const void *test, sf_count_t items, int line_num) -{ sf_count_t count ; - - if ((count = sf_write_raw (file, test, items)) != items) - { printf ("\n\nLine %d", line_num) ; - if (pass > 0) - printf (" (pass %d)", pass) ; - printf (" : sf_write_raw failed with short write (%" PRId64 " => %" PRId64 ").\n", items, count) ; - fflush (stdout) ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - return ; -} /* test_write_raw_or_die */ - - -[+ FOR io_type -+]void -compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *expected, const [+ (get "io_element") +] *actual, unsigned count, int line_num) -{ - unsigned k ; - - for (k = 0 ; k < count ; k++) - if (!equals_[+ (get "io_element") +](expected [k], actual [k])) - { printf ("\n\nLine %d : Error at index %d, got " [+ (get "format_str") +] ", should be " [+ (get "format_str") +] "(delta=" [+ (get "format_str") +] " ).\n\n", line_num, k, actual [k], expected [k], actual [k] - expected [k]) ; - exit (1) ; - } ; - - return ; -} /* compare_[+ (get "io_element") +]_or_die */ -[+ ENDFOR io_type +] - - -void -delete_file (int format, const char *filename) -{ char rsrc_name [512], *fname ; - - unlink (filename) ; - - if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SD2) - return ; - - /* - ** Now try for a resource fork stored as a separate file. - ** Grab the un-adulterated filename again. - */ - snprintf (rsrc_name, sizeof (rsrc_name), "%s", filename) ; - - if ((fname = strrchr (rsrc_name, '/')) != NULL) - fname ++ ; - else if ((fname = strrchr (rsrc_name, '\\')) != NULL) - fname ++ ; - else - fname = rsrc_name ; - - memmove (fname + 2, fname, strlen (fname) + 1) ; - fname [0] = '.' ; - fname [1] = '_' ; - - unlink (rsrc_name) ; -} /* delete_file */ - -int -truncate_file_to_zero (const char * fname) -{ FILE * file ; - - if ((file = fopen (fname, "w")) == NULL) - return errno ; - fclose (file) ; - - return 0 ; -} /* truncate_file_to_zero */ - -static int allowed_open_files = -1 ; - -void -count_open_files (void) -{ -#if OS_IS_WIN32 - return ; -#else - int k, count = 0 ; - struct stat statbuf ; - - if (allowed_open_files > 0) - return ; - - for (k = 0 ; k < 1024 ; k++) - if (fstat (k, &statbuf) == 0) - count ++ ; - - allowed_open_files = count ; -#endif -} /* count_open_files */ - -void -increment_open_file_count (void) -{ allowed_open_files ++ ; -} /* increment_open_file_count */ - -void -check_open_file_count_or_die (int lineno) -{ -#if OS_IS_WIN32 - (void) lineno ; - return ; -#else - int k, count = 0 ; - struct stat statbuf ; - - if (allowed_open_files < 0) - count_open_files () ; - - for (k = 0 ; k < 1024 ; k++) - if (fstat (k, &statbuf) == 0) - count ++ ; - - if (count > allowed_open_files) - { printf ("\nLine %d : number of open files (%d) > allowed (%d).\n\n", lineno, count, allowed_open_files) ; - exit (1) ; - } ; -#endif -} /* check_open_file_count_or_die */ - -void -get_unique_test_name (const char ** filename, const char * test) -{ static char buffer [1024] ; - - snprintf (buffer, sizeof (buffer), "%s_%s", test, *filename) ; - - *filename = buffer ; -} /* get_unique_test_name */ - -void -write_mono_file (const char * filename, int format, int srate, float * output, int len) -{ SNDFILE * file ; - SF_INFO sfinfo ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - sfinfo.samplerate = srate ; - sfinfo.channels = 1 ; - sfinfo.format = format ; - - if ((file = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL) - { printf ("sf_open (%s) : %s\n", filename, sf_strerror (NULL)) ; - exit (1) ; - } ; - - sf_write_float (file, output, len) ; - - sf_close (file) ; -} /* write_mono_file */ - -void -gen_lowpass_signal_float (float *data, int len) -{ int64_t value = 0x1243456 ; - double sample, last_val = 0.0 ; - int k ; - - for (k = 0 ; k < len ; k++) - { /* Not a crypto quality RNG. */ - value = (11117 * value + 211231) & 0xffffffff ; - value = (11117 * value + 211231) & 0xffffffff ; - value = (11117 * value + 211231) & 0xffffffff ; - - sample = value / (0x7fffffff * 1.000001) ; - sample = 0.2 * sample - 0.9 * last_val ; - - last_val = sample ; - - data [k] = 0.5 * (sample + sin (2.0 * k * M_PI * 1.0 / 32.0)) ; - } ; - -} /* gen_lowpass_signal_float */ - - -/* -** Windows is fucked. -** If a file is opened R/W and data is written to it, then fstat will return -** the correct file length, but stat will return zero. -*/ - -sf_count_t -file_length (const char * fname) -{ struct stat data ; - - if (stat (fname, &data) != 0) - return 0 ; - - return (sf_count_t) data.st_size ; -} /* file_length */ - -sf_count_t -file_length_fd (int fd) -{ struct stat data ; - - memset (&data, 0, sizeof (data)) ; - if (fstat (fd, &data) != 0) - return 0 ; - - return (sf_count_t) data.st_size ; -} /* file_length_fd */ - - -[+ ESAC +] - diff --git a/Engine/lib/libsndfile/tests/virtual_io_test.c b/Engine/lib/libsndfile/tests/virtual_io_test.c deleted file mode 100644 index b5f84ac2e..000000000 --- a/Engine/lib/libsndfile/tests/virtual_io_test.c +++ /dev/null @@ -1,237 +0,0 @@ -/* -** Copyright (C) 1999-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include "utils.h" - -static void vio_test (const char *fname, int format) ; - -int -main (void) -{ - vio_test ("vio_pcm16.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - vio_test ("vio_pcm24.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_24) ; - vio_test ("vio_float.au", SF_FORMAT_AU | SF_FORMAT_FLOAT) ; - vio_test ("vio_pcm24.paf", SF_FORMAT_PAF | SF_FORMAT_PCM_24) ; - - return 0 ; -} /* main */ - -/*============================================================================== -*/ - -typedef struct -{ sf_count_t offset, length ; - unsigned char data [16 * 1024] ; -} VIO_DATA ; - -static sf_count_t -vfget_filelen (void *user_data) -{ VIO_DATA *vf = (VIO_DATA *) user_data ; - - return vf->length ; -} /* vfget_filelen */ - -static sf_count_t -vfseek (sf_count_t offset, int whence, void *user_data) -{ VIO_DATA *vf = (VIO_DATA *) user_data ; - - switch (whence) - { case SEEK_SET : - vf->offset = offset ; - break ; - - case SEEK_CUR : - vf->offset = vf->offset + offset ; - break ; - - case SEEK_END : - vf->offset = vf->length + offset ; - break ; - default : - break ; - } ; - - return vf->offset ; -} /* vfseek */ - -static sf_count_t -vfread (void *ptr, sf_count_t count, void *user_data) -{ VIO_DATA *vf = (VIO_DATA *) user_data ; - - /* - ** This will break badly for files over 2Gig in length, but - ** is sufficient for testing. - */ - if (vf->offset + count > vf->length) - count = vf->length - vf->offset ; - - memcpy (ptr, vf->data + vf->offset, count) ; - vf->offset += count ; - - return count ; -} /* vfread */ - -static sf_count_t -vfwrite (const void *ptr, sf_count_t count, void *user_data) -{ VIO_DATA *vf = (VIO_DATA *) user_data ; - - /* - ** This will break badly for files over 2Gig in length, but - ** is sufficient for testing. - */ - if (vf->offset >= SIGNED_SIZEOF (vf->data)) - return 0 ; - - if (vf->offset + count > SIGNED_SIZEOF (vf->data)) - count = sizeof (vf->data) - vf->offset ; - - memcpy (vf->data + vf->offset, ptr, (size_t) count) ; - vf->offset += count ; - - if (vf->offset > vf->length) - vf->length = vf->offset ; - - return count ; -} /* vfwrite */ - -static sf_count_t -vftell (void *user_data) -{ VIO_DATA *vf = (VIO_DATA *) user_data ; - - return vf->offset ; -} /* vftell */ - - -/*============================================================================== -*/ - -static void -gen_short_data (short * data, int len, int start) -{ int k ; - - for (k = 0 ; k < len ; k++) - data [k] = start + k ; -} /* gen_short_data */ - - -static void -check_short_data (short * data, int len, int start, int line) -{ int k ; - - for (k = 0 ; k < len ; k++) - if (data [k] != start + k) - { printf ("\n\nLine %d : data [%d] = %d (should be %d).\n\n", line, k, data [k], start + k) ; - exit (1) ; - } ; -} /* gen_short_data */ - -/*------------------------------------------------------------------------------ -*/ - -static void -vio_test (const char *fname, int format) -{ static VIO_DATA vio_data ; - static short data [256] ; - - SF_VIRTUAL_IO vio ; - SNDFILE * file ; - SF_INFO sfinfo ; - - print_test_name ("virtual i/o test", fname) ; - - /* Set up pointers to the locally defined functions. */ - vio.get_filelen = vfget_filelen ; - vio.seek = vfseek ; - vio.read = vfread ; - vio.write = vfwrite ; - vio.tell = vftell ; - - /* Set virtual file offset and length to zero. */ - vio_data.offset = 0 ; - vio_data.length = 0 ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - sfinfo.format = format ; - sfinfo.channels = 2 ; - sfinfo.samplerate = 44100 ; - - if ((file = sf_open_virtual (&vio, SFM_WRITE, &sfinfo, &vio_data)) == NULL) - { printf ("\n\nLine %d : sf_open_write failed with error : ", __LINE__) ; - fflush (stdout) ; - puts (sf_strerror (NULL)) ; - exit (1) ; - } ; - - if (vfget_filelen (&vio_data) < 0) - { printf ("\n\nLine %d : vfget_filelen returned negative length.\n\n", __LINE__) ; - exit (1) ; - } ; - - gen_short_data (data, ARRAY_LEN (data), 0) ; - sf_write_short (file, data, ARRAY_LEN (data)) ; - - gen_short_data (data, ARRAY_LEN (data), 1) ; - sf_write_short (file, data, ARRAY_LEN (data)) ; - - gen_short_data (data, ARRAY_LEN (data), 2) ; - sf_write_short (file, data, ARRAY_LEN (data)) ; - - sf_close (file) ; - - /* Now test read. */ - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - vio_data.offset = 0 ; - - if ((file = sf_open_virtual (&vio, SFM_READ, &sfinfo, &vio_data)) == NULL) - { printf ("\n\nLine %d : sf_open_write failed with error : ", __LINE__) ; - fflush (stdout) ; - puts (sf_strerror (NULL)) ; - - dump_data_to_file (fname, vio_data.data, (unsigned int) vio_data.length) ; - exit (1) ; - } ; - - - sf_read_short (file, data, ARRAY_LEN (data)) ; - check_short_data (data, ARRAY_LEN (data), 0, __LINE__) ; - - sf_read_short (file, data, ARRAY_LEN (data)) ; - check_short_data (data, ARRAY_LEN (data), 1, __LINE__) ; - - sf_read_short (file, data, ARRAY_LEN (data)) ; - check_short_data (data, ARRAY_LEN (data), 2, __LINE__) ; - - sf_close (file) ; - - puts ("ok") ; -} /* vio_test */ - diff --git a/Engine/lib/libsndfile/tests/win32_ordinal_test.c b/Engine/lib/libsndfile/tests/win32_ordinal_test.c deleted file mode 100644 index 7c9adb153..000000000 --- a/Engine/lib/libsndfile/tests/win32_ordinal_test.c +++ /dev/null @@ -1,148 +0,0 @@ -/* -** Copyright (C) 2006-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include - -#if HAVE_UNISTD_H -#include -#endif - -#if (HAVE_DECL_S_IRGRP == 0) -#include -#endif - -#include -#include -#ifdef HAVE_DIRECT_H -#include -#endif -#include - -#include "utils.h" - -#if (defined (WIN32) || defined (_WIN32) || defined (__CYGWIN__)) -#define TEST_WIN32 1 -#else -#define TEST_WIN32 0 -#endif - -#if TEST_WIN32 -#include - - -static const char * locations [] = -{ ".", "../src/", "src/", "../src/.libs/", "src/.libs/", - NULL -} ; /* locations. */ - -static int -test_ordinal (HMODULE hmod, const char * func_name, int ordinal) -{ char *lpmsg ; - void *name, *ord ; - - print_test_name ("win32_ordinal_test", func_name) ; - -#if SIZEOF_VOIDP == 8 -#define LPCSTR_OF_ORDINAL(x) ((LPCSTR) ((int64_t) (x))) -#else -#define LPCSTR_OF_ORDINAL(x) ((LPCSTR) (x)) -#endif - - ord = GetProcAddress (hmod, LPCSTR_OF_ORDINAL (ordinal)) ; - if ((name = GetProcAddress (hmod, func_name)) == NULL) - { FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (), - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpmsg, 0, NULL) ; - /*-puts (lpmsg) ;-*/ - } ; - - if (name != NULL && ord != NULL && name == ord) - { puts ("ok") ; - return 0 ; - } ; - - puts ("fail") ; - return 1 ; -} /* test_ordinal */ - -static void -win32_ordinal_test (void) -{ static char buffer [1024] ; - static char func_name [1024] ; - HMODULE hmod = NULL ; - FILE * file = NULL ; - int k, ordinal, errors = 0 ; - - for (k = 0 ; locations [k] != NULL ; k++) - { snprintf (buffer, sizeof (buffer), "%s/libsndfile-1.def", locations [k]) ; - if ((file = fopen (buffer, "r")) != NULL) - break ; - } ; - - if (file == NULL) - { puts ("\n\nError : cannot open DEF file.\n") ; - exit (1) ; - } ; - - for (k = 0 ; locations [k] != NULL ; k++) - { snprintf (buffer, sizeof (buffer), "%s/libsndfile-1.dll", locations [k]) ; - if ((hmod = (HMODULE) LoadLibrary (buffer)) != NULL) - break ; - } ; - - if (hmod == NULL) - { printf ("\n\nError : cannot load DLL (cwd is %s).\n", getcwd (buffer, sizeof (buffer))) ; - exit (1) ; - } ; - - while (fgets (buffer, sizeof (buffer), file) != NULL) - { func_name [0] = 0 ; - ordinal = 0 ; - - if (sscanf (buffer, "%s @%d", func_name, &ordinal) != 2) - continue ; - - errors += test_ordinal (hmod, func_name, ordinal) ; - } ; - - FreeLibrary (hmod) ; - - fclose (file) ; - - if (errors > 0) - { printf ("\n\nErrors : %d\n\n", errors) ; - exit (1) ; - } ; - - return ; -} /* win32_ordinal_test */ - -#endif - -int -main (void) -{ -#if (TEST_WIN32 && WIN32_TARGET_DLL) - win32_ordinal_test () ; -#endif - - return 0 ; -} /* main */ - diff --git a/Engine/lib/libsndfile/tests/win32_test.c b/Engine/lib/libsndfile/tests/win32_test.c deleted file mode 100644 index d0dc6d8ea..000000000 --- a/Engine/lib/libsndfile/tests/win32_test.c +++ /dev/null @@ -1,318 +0,0 @@ -/* -** Copyright (C) 2001-2011 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" -#include "sndfile.h" - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#endif - -#if (HAVE_DECL_S_IRGRP == 0) -#include -#endif - -#include -#include -#include -#include -#include - -#define SIGNED_SIZEOF(x) ((int) sizeof (x)) - -/* EMX is OS/2. */ -#if defined (__CYGWIN__) || defined (__EMX__) - - #define LSEEK lseek - #define FSTAT fstat - - typedef struct stat STATBUF ; - typedef off_t INT64 ; - - static char dir_cmd [] = "ls -l" ; - -#elif (defined (WIN32) || defined (_WIN32)) - - #define LSEEK _lseeki64 - #define FSTAT _fstati64 - - typedef struct _stati64 STATBUF ; - typedef __int64 INT64 ; - - static char dir_cmd [] = "dir" ; - -#else - - #define LSEEK lseek - #define FSTAT fstat - - typedef struct stat STATBUF ; - typedef sf_count_t INT64 ; - - #define O_BINARY 0 - static char dir_cmd [] = "ls -l" ; - -#endif - -static void show_fstat_error (void) ; -static void show_lseek_error (void) ; -static void show_stat_fstat_error (void) ; -static void write_to_closed_file (void) ; - -int -main (void) -{ - puts ("\n\n\n\n" - "This program shows up errors in the Win32 implementation of\n" - "a couple of POSIX API functions on some versions of windoze.\n" - "It can also be compiled on Linux (which works correctly) and\n" - "other OSes just to provide a sanity check.\n" - ) ; - - show_fstat_error () ; - show_lseek_error () ; - show_stat_fstat_error () ; - write_to_closed_file () ; - - puts ("\n\n") ; - - return 0 ; -} /* main */ - -static void -show_fstat_error (void) -{ static const char *filename = "fstat.dat" ; - static char data [256] ; - - STATBUF statbuf ; - int fd, mode, flags ; - - if (sizeof (statbuf.st_size) != sizeof (INT64)) - { printf ("\n\nLine %d: Error, sizeof (statbuf.st_size) != 8.\n\n", __LINE__) ; - return ; - } ; - - puts ("\n64 bit fstat() test.\n--------------------") ; - - printf ("0) Create a file, write %d bytes and close it.\n", SIGNED_SIZEOF (data)) ; - mode = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY ; - flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ; - if ((fd = open (filename, mode, flags)) < 0) - { printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ; - return ; - } ; - assert (write (fd, data, sizeof (data)) > 0) ; - close (fd) ; - - printf ("1) Re-open file in read/write mode and write another %d bytes at the end.\n", SIGNED_SIZEOF (data)) ; - mode = O_RDWR | O_BINARY ; - flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ; - if ((fd = open (filename, mode, flags)) < 0) - { printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ; - return ; - } ; - LSEEK (fd, 0, SEEK_END) ; - assert (write (fd, data, sizeof (data)) > 0) ; - - printf ("2) Now use system (\"%s %s\") to show the file length.\n\n", dir_cmd, filename) ; - - /* Would use snprintf, but thats not really available on windows. */ - memset (data, 0, sizeof (data)) ; - strncpy (data, dir_cmd, sizeof (data) - 1) ; - strncat (data, " ", sizeof (data) - 1 - strlen (data)) ; - strncat (data, filename, sizeof (data) - 1 - strlen (data)) ; - - assert (system (data) >= 0) ; - puts ("") ; - - printf ("3) Now use fstat() to get the file length.\n") ; - if (FSTAT (fd, &statbuf) != 0) - { printf ("\n\nLine %d: fstat() returned error : %s\n", __LINE__, strerror (errno)) ; - return ; - } ; - - printf ("4) According to fstat(), the file length is %ld, ", (long) statbuf.st_size) ; - - close (fd) ; - - if (statbuf.st_size != 2 * sizeof (data)) - printf ("but thats just plain ***WRONG***.\n\n") ; - else - { printf ("which is correct.\n\n") ; - unlink (filename) ; - } ; - -} /* show_fstat_error */ - -static void -show_lseek_error (void) -{ static const char *filename = "fstat.dat" ; - static char data [256] ; - - INT64 retval ; - int fd, mode, flags ; - - puts ("\n64 bit lseek() test.\n--------------------") ; - - printf ("0) Create a file, write %d bytes and close it.\n", SIGNED_SIZEOF (data)) ; - mode = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY ; - flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ; - if ((fd = open (filename, mode, flags)) < 0) - { printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ; - return ; - } ; - assert (write (fd, data, sizeof (data)) > 0) ; - close (fd) ; - - printf ("1) Re-open file in read/write mode and write another %d bytes at the end.\n", SIGNED_SIZEOF (data)) ; - mode = O_RDWR | O_BINARY ; - flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ; - if ((fd = open (filename, mode, flags)) < 0) - { printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ; - return ; - } ; - - LSEEK (fd, 0, SEEK_END) ; - assert (write (fd, data, sizeof (data)) > 0) ; - - printf ("2) Now use system (\"%s %s\") to show the file length.\n\n", dir_cmd, filename) ; - - /* Would use snprintf, but thats not really available on windows. */ - memset (data, 0, sizeof (data)) ; - strncpy (data, dir_cmd, sizeof (data) - 1) ; - strncat (data, " ", sizeof (data) - 1 - strlen (data)) ; - strncat (data, filename, sizeof (data) - 1 - strlen (data)) ; - - assert (system (data) >= 0) ; - puts ("") ; - - printf ("3) Now use lseek() to go to the end of the file.\n") ; - retval = LSEEK (fd, 0, SEEK_END) ; - - printf ("4) We are now at position %ld, ", (long) retval) ; - - close (fd) ; - - if (retval != 2 * sizeof (data)) - printf ("but thats just plain ***WRONG***.\n\n") ; - else - { printf ("which is correct.\n\n") ; - unlink (filename) ; - } ; - -} /* show_lseek_error */ - -static void -show_stat_fstat_error (void) -{ static const char *filename = "stat_fstat.dat" ; - static char data [256] ; - - int fd, mode, flags ; - int stat_size, fstat_size ; - struct stat buf ; - - /* Known to fail on WinXP. */ - puts ("\nstat/fstat test.\n----------------") ; - - printf ("0) Create a file and write %d bytes.\n", SIGNED_SIZEOF (data)) ; - - mode = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY ; - flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ; - if ((fd = open (filename, mode, flags)) < 0) - { printf ("\n\nLine %d: open() failed : %s\n\n", __LINE__, strerror (errno)) ; - return ; - } ; - - assert (write (fd, data, sizeof (data)) > 0) ; - - printf ("1) Now call stat and fstat on the file and retreive the file lengths.\n") ; - - if (stat (filename, &buf) != 0) - { printf ("\n\nLine %d: stat() failed : %s\n\n", __LINE__, strerror (errno)) ; - goto error_exit ; - } ; - stat_size = buf.st_size ; - - if (fstat (fd, &buf) != 0) - { printf ("\n\nLine %d: fstat() failed : %s\n\n", __LINE__, strerror (errno)) ; - goto error_exit ; - } ; - fstat_size = buf.st_size ; - - printf ("2) Size returned by stat and fstat is %d and %d, ", stat_size, fstat_size) ; - - - if (stat_size == 0 || stat_size != fstat_size) - printf ("but thats just plain ***WRONG***.\n\n") ; - else - printf ("which is correct.\n\n") ; - -error_exit : - - close (fd) ; - unlink (filename) ; - - return ; -} /* show_stat_fstat_error */ - - -static void -write_to_closed_file (void) -{ const char * filename = "closed_write_test.txt" ; - struct stat buf ; - FILE * file ; - int fd ; - - puts ("\nWrite to closed file test.\n--------------------------") ; - - printf ("0) First we open file for write using fopen().\n") ; - if ((file = fopen (filename, "w")) == NULL) - { printf ("\n\nLine %d: fopen() failed : %s\n\n", __LINE__, strerror (errno)) ; - return ; - } ; - - printf ("1) Now we grab the file descriptor fileno().\n") ; - fd = fileno (file) ; - - printf ("2) Write some text via the file descriptor.\n") ; - assert (write (fd, "a\n", 2) > 0) ; - - printf ("3) Now we close the file using fclose().\n") ; - fclose (file) ; - - stat (filename, &buf) ; - printf (" File size is %d bytes.\n", (int) buf.st_size) ; - - printf ("4) Now write more data to the file descriptor which should fail.\n") ; - if (write (fd, "b\n", 2) < 0) - printf ("5) Good, write returned an error code as it should have.\n") ; - else - { printf ("5) Attempting to write to a closed file should have failed but didn't! *** WRONG ***\n") ; - - stat (filename, &buf) ; - printf (" File size is %d bytes.\n", (int) buf.st_size) ; - } ; - - unlink (filename) ; - - return ; -} /* write_to_closed_file */ diff --git a/Engine/lib/libsndfile/tests/write_read_test.def b/Engine/lib/libsndfile/tests/write_read_test.def deleted file mode 100644 index 3316aec57..000000000 --- a/Engine/lib/libsndfile/tests/write_read_test.def +++ /dev/null @@ -1,75 +0,0 @@ -autogen definitions write_read_test.tpl; - -data_type = { - type_name = char ; - data_type = short ; - data_field = s ; - error_func = CHAR_ERROR ; - format_char = "0x%X" ; - max_val = "32000.0" ; - max_error = "255" ; - } ; - -data_type = { - type_name = short ; - data_type = short ; - data_field = s ; - error_func = INT_ERROR ; - format_char = "0x%X" ; - max_val = "32000.0" ; - max_error = "0" ; - } ; - -data_type = { - type_name = "20bit" ; - data_type = int ; - data_field = i ; - error_func = BIT_20_ERROR ; - format_char = "0x%X" ; - max_val = "(1.0 * 0x7F00000)" ; - max_error = "4096" ; - } ; - -data_type = { - type_name = "24bit" ; - data_type = int ; - data_field = i ; - error_func = TRIBYTE_ERROR ; - format_char = "0x%X" ; - max_val = "(1.0 * 0x7F000000)" ; - max_error = "256" ; - } ; - -data_type = { - type_name = int ; - data_type = int ; - data_field = i ; - error_func = INT_ERROR ; - format_char = "0x%X" ; - max_val = "(1.0 * 0x7F000000)" ; - max_error = "0" ; - } ; - -/* Lite remove start */ - -data_type = { - type_name = float ; - data_type = float ; - data_field = f ; - error_func = FLOAT_ERROR ; - format_char = "%g" ; - max_val = "1.0" ; - max_error = "0" ; - } ; - -data_type = { - type_name = double ; - data_type = double ; - data_field = d ; - error_func = FLOAT_ERROR ; - format_char = "%g" ; - max_val = "1.0" ; - max_error = "0" ; - } ; - -/* Lite remove end */ diff --git a/Engine/lib/libsndfile/tests/write_read_test.tpl b/Engine/lib/libsndfile/tests/write_read_test.tpl deleted file mode 100644 index ed152f893..000000000 --- a/Engine/lib/libsndfile/tests/write_read_test.tpl +++ /dev/null @@ -1,1208 +0,0 @@ -[+ AutoGen5 template c +] -/* -** Copyright (C) 1999-2017 Erik de Castro Lopo -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "sfconfig.h" - -#include -#include -#include -#include -#include - - -#if HAVE_UNISTD_H -#include -#else -#include "sf_unistd.h" -#endif - -#include - -#include "utils.h" -#include "generate.h" - -#define SAMPLE_RATE 11025 -#define DATA_LENGTH (1 << 12) - -#define SILLY_WRITE_COUNT (234) - -static const char WRT_TEST_PREFIX[] = "wrt" ; - -[+ FOR data_type -+]static void pcm_test_[+ (get "type_name") +] (const char *str, int format, int long_file_ok) ; -[+ ENDFOR data_type -+] -static void empty_file_test (const char *filename, int format) ; - -typedef union -{ double d [DATA_LENGTH] ; - float f [DATA_LENGTH] ; - int i [DATA_LENGTH] ; - short s [DATA_LENGTH] ; - char c [DATA_LENGTH] ; -} BUFFER ; - -static BUFFER orig_data ; -static BUFFER test_data ; - -int -main (int argc, char **argv) -{ int do_all = 0 ; - int test_count = 0 ; - - count_open_files () ; - - if (argc != 2) - { printf ("Usage : %s \n", argv [0]) ; - printf (" Where is one of the following:\n") ; - printf (" wav - test WAV file functions (little endian)\n") ; - printf (" aiff - test AIFF file functions (big endian)\n") ; - printf (" au - test AU file functions\n") ; - printf (" avr - test AVR file functions\n") ; - printf (" caf - test CAF file functions\n") ; - printf (" raw - test RAW header-less PCM file functions\n") ; - printf (" paf - test PAF file functions\n") ; - printf (" svx - test 8SVX/16SV file functions\n") ; - printf (" nist - test NIST Sphere file functions\n") ; - printf (" ircam - test IRCAM file functions\n") ; - printf (" voc - Create Voice file functions\n") ; - printf (" w64 - Sonic Foundry's W64 file functions\n") ; - printf (" flac - test FLAC file functions\n") ; - printf (" mpc2k - test MPC 2000 file functions\n") ; - printf (" rf64 - test RF64 file functions\n") ; - printf (" all - perform all tests\n") ; - exit (1) ; - } ; - - do_all = !strcmp (argv [1], "all") ; - - if (do_all || ! strcmp (argv [1], "wav")) - { pcm_test_char ("char.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_U8, SF_FALSE) ; - pcm_test_short ("short.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_32, SF_FALSE) ; - - pcm_test_char ("char.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_U8, SF_FALSE) ; - pcm_test_short ("short.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_32, SF_FALSE) ; - - pcm_test_24bit ("24bit.wavex" , SF_FORMAT_WAVEX | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int.wavex" , SF_FORMAT_WAVEX | SF_FORMAT_PCM_32, SF_FALSE) ; - - /* Lite remove start */ - pcm_test_float ("float.wav" , SF_FORMAT_WAV | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double.wav" , SF_FORMAT_WAV | SF_FORMAT_DOUBLE, SF_FALSE) ; - - pcm_test_float ("float.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_DOUBLE, SF_FALSE) ; - - pcm_test_float ("float.wavex" , SF_FORMAT_WAVEX | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double.wavex" , SF_FORMAT_WAVEX | SF_FORMAT_DOUBLE, SF_FALSE) ; - /* Lite remove end */ - - empty_file_test ("empty_char.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8) ; - empty_file_test ("empty_short.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; - empty_file_test ("empty_float.wav", SF_FORMAT_WAV | SF_FORMAT_FLOAT) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "aiff")) - { pcm_test_char ("char_u8.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_U8, SF_FALSE) ; - pcm_test_char ("char_s8.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_short ("short.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_32, SF_FALSE) ; - - pcm_test_short ("short_sowt.aifc" , SF_ENDIAN_LITTLE | SF_FORMAT_AIFF | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit_sowt.aifc" , SF_ENDIAN_LITTLE | SF_FORMAT_AIFF | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int_sowt.aifc" , SF_ENDIAN_LITTLE | SF_FORMAT_AIFF | SF_FORMAT_PCM_32, SF_FALSE) ; - - pcm_test_short ("short_twos.aifc" , SF_ENDIAN_BIG | SF_FORMAT_AIFF | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit_twos.aifc" , SF_ENDIAN_BIG | SF_FORMAT_AIFF | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int_twos.aifc" , SF_ENDIAN_BIG | SF_FORMAT_AIFF | SF_FORMAT_PCM_32, SF_FALSE) ; - - /* Lite remove start */ - pcm_test_short ("dwvw16.aifc", SF_FORMAT_AIFF | SF_FORMAT_DWVW_16, SF_TRUE) ; - pcm_test_24bit ("dwvw24.aifc", SF_FORMAT_AIFF | SF_FORMAT_DWVW_24, SF_TRUE) ; - - pcm_test_float ("float.aifc" , SF_FORMAT_AIFF | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double.aifc" , SF_FORMAT_AIFF | SF_FORMAT_DOUBLE, SF_FALSE) ; - /* Lite remove end */ - - empty_file_test ("empty_char.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_U8) ; - empty_file_test ("empty_short.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ; - empty_file_test ("empty_float.aiff", SF_FORMAT_AIFF | SF_FORMAT_FLOAT) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "au")) - { pcm_test_char ("char.au" , SF_FORMAT_AU | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_short ("short.au" , SF_FORMAT_AU | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit.au" , SF_FORMAT_AU | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int.au" , SF_FORMAT_AU | SF_FORMAT_PCM_32, SF_FALSE) ; - /* Lite remove start */ - pcm_test_float ("float.au" , SF_FORMAT_AU | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double.au", SF_FORMAT_AU | SF_FORMAT_DOUBLE, SF_FALSE) ; - /* Lite remove end */ - - pcm_test_char ("char_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_short ("short_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, SF_FALSE) ; - /* Lite remove start */ - pcm_test_float ("float_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE, SF_FALSE) ; - /* Lite remove end */ - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "caf")) - { pcm_test_char ("char.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_short ("short.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_32, SF_FALSE) ; - /* Lite remove start */ - pcm_test_float ("float.caf" , SF_FORMAT_CAF | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double.caf" , SF_FORMAT_CAF | SF_FORMAT_DOUBLE, SF_FALSE) ; - /* Lite remove end */ - - pcm_test_short ("short_le.caf" , SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit_le.caf" , SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int_le.caf" , SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_PCM_32, SF_FALSE) ; - /* Lite remove start */ - pcm_test_float ("float_le.caf" , SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double_le.caf", SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_DOUBLE, SF_FALSE) ; - - pcm_test_short ("alac16.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_16, SF_FALSE) ; - pcm_test_20bit ("alac20.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_20, SF_FALSE) ; - pcm_test_24bit ("alac24.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_24, SF_FALSE) ; - pcm_test_int ("alac32.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_32, SF_FALSE) ; - - /* Lite remove end */ - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "raw")) - { pcm_test_char ("char_s8.raw" , SF_FORMAT_RAW | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_char ("char_u8.raw" , SF_FORMAT_RAW | SF_FORMAT_PCM_U8, SF_FALSE) ; - - pcm_test_short ("short_le.raw" , SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_short ("short_be.raw" , SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit_le.raw" , SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_24bit ("24bit_be.raw" , SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int_le.raw" , SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_32, SF_FALSE) ; - pcm_test_int ("int_be.raw" , SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, SF_FALSE) ; - - /* Lite remove start */ - pcm_test_float ("float_le.raw" , SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_float ("float_be.raw" , SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT , SF_FALSE) ; - - pcm_test_double ("double_le.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, SF_FALSE) ; - pcm_test_double ("double_be.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, SF_FALSE) ; - /* Lite remove end */ - test_count++ ; - } ; - - /* Lite remove start */ - if (do_all || ! strcmp (argv [1], "paf")) - { pcm_test_char ("char_le.paf", SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_char ("char_be.paf", SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_short ("short_le.paf", SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_short ("short_be.paf", SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit_le.paf", SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_24, SF_TRUE) ; - pcm_test_24bit ("24bit_be.paf", SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_24, SF_TRUE) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "svx")) - { pcm_test_char ("char.svx" , SF_FORMAT_SVX | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_short ("short.svx", SF_FORMAT_SVX | SF_FORMAT_PCM_16, SF_FALSE) ; - - empty_file_test ("empty_char.svx", SF_FORMAT_SVX | SF_FORMAT_PCM_S8) ; - empty_file_test ("empty_short.svx", SF_FORMAT_SVX | SF_FORMAT_PCM_16) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "nist")) - { pcm_test_short ("short_le.nist", SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_short ("short_be.nist", SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit_le.nist", SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_24bit ("24bit_be.nist", SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int_le.nist" , SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_PCM_32, SF_FALSE) ; - pcm_test_int ("int_be.nist" , SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_PCM_32, SF_FALSE) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "ircam")) - { pcm_test_short ("short_be.ircam" , SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_short ("short_le.ircam" , SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_int ("int_be.ircam" , SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_PCM_32, SF_FALSE) ; - pcm_test_int ("int_le.ircam" , SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_PCM_32, SF_FALSE) ; - pcm_test_float ("float_be.ircam" , SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_float ("float_le.ircam" , SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_FLOAT , SF_FALSE) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "voc")) - { pcm_test_char ("char.voc" , SF_FORMAT_VOC | SF_FORMAT_PCM_U8, SF_FALSE) ; - pcm_test_short ("short.voc", SF_FORMAT_VOC | SF_FORMAT_PCM_16, SF_FALSE) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat4")) - { pcm_test_short ("short_be.mat4" , SF_ENDIAN_BIG | SF_FORMAT_MAT4 | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_short ("short_le.mat4" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT4 | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_int ("int_be.mat4" , SF_ENDIAN_BIG | SF_FORMAT_MAT4 | SF_FORMAT_PCM_32, SF_FALSE) ; - pcm_test_int ("int_le.mat4" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT4 | SF_FORMAT_PCM_32, SF_FALSE) ; - pcm_test_float ("float_be.mat4" , SF_ENDIAN_BIG | SF_FORMAT_MAT4 | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_float ("float_le.mat4" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT4 | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double_be.mat4" , SF_ENDIAN_BIG | SF_FORMAT_MAT4 | SF_FORMAT_DOUBLE, SF_FALSE) ; - pcm_test_double ("double_le.mat4" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT4 | SF_FORMAT_DOUBLE, SF_FALSE) ; - - empty_file_test ("empty_short.mat4", SF_FORMAT_MAT4 | SF_FORMAT_PCM_16) ; - empty_file_test ("empty_float.mat4", SF_FORMAT_MAT4 | SF_FORMAT_FLOAT) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mat5")) - { pcm_test_char ("char_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_PCM_U8, SF_FALSE) ; - pcm_test_char ("char_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_PCM_U8, SF_FALSE) ; - pcm_test_short ("short_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_short ("short_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_int ("int_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_PCM_32, SF_FALSE) ; - pcm_test_int ("int_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_PCM_32, SF_FALSE) ; - pcm_test_float ("float_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_float ("float_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_DOUBLE, SF_FALSE) ; - pcm_test_double ("double_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_DOUBLE, SF_FALSE) ; - - increment_open_file_count () ; - - empty_file_test ("empty_char.mat5", SF_FORMAT_MAT5 | SF_FORMAT_PCM_U8) ; - empty_file_test ("empty_short.mat5", SF_FORMAT_MAT5 | SF_FORMAT_PCM_16) ; - empty_file_test ("empty_float.mat5", SF_FORMAT_MAT5 | SF_FORMAT_FLOAT) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "pvf")) - { pcm_test_char ("char.pvf" , SF_FORMAT_PVF | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_short ("short.pvf", SF_FORMAT_PVF | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_int ("int.pvf" , SF_FORMAT_PVF | SF_FORMAT_PCM_32, SF_FALSE) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "htk")) - { pcm_test_short ("short.htk", SF_FORMAT_HTK | SF_FORMAT_PCM_16, SF_FALSE) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "mpc2k")) - { pcm_test_short ("short.mpc", SF_FORMAT_MPC2K | SF_FORMAT_PCM_16, SF_FALSE) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "avr")) - { pcm_test_char ("char_u8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_U8, SF_FALSE) ; - pcm_test_char ("char_s8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_short ("short.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_16, SF_FALSE) ; - test_count++ ; - } ; - /* Lite remove end */ - - if (do_all || ! strcmp (argv [1], "w64")) - { pcm_test_char ("char.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_U8, SF_FALSE) ; - pcm_test_short ("short.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_32, SF_FALSE) ; - /* Lite remove start */ - pcm_test_float ("float.w64" , SF_FORMAT_W64 | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double.w64" , SF_FORMAT_W64 | SF_FORMAT_DOUBLE, SF_FALSE) ; - /* Lite remove end */ - - empty_file_test ("empty_char.w64", SF_FORMAT_W64 | SF_FORMAT_PCM_U8) ; - empty_file_test ("empty_short.w64", SF_FORMAT_W64 | SF_FORMAT_PCM_16) ; - empty_file_test ("empty_float.w64", SF_FORMAT_W64 | SF_FORMAT_FLOAT) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "sds")) - { pcm_test_char ("char.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_S8, SF_FALSE) ; - pcm_test_short ("short.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_24, SF_FALSE) ; - - empty_file_test ("empty_char.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_S8) ; - empty_file_test ("empty_short.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_16) ; - - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "sd2")) - { pcm_test_char ("char.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_S8, SF_TRUE) ; - pcm_test_short ("short.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_16, SF_TRUE) ; - pcm_test_24bit ("24bit.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_24, SF_TRUE) ; - pcm_test_int ("32bit.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_32, SF_TRUE) ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "flac")) - { if (HAVE_EXTERNAL_XIPH_LIBS) - { pcm_test_char ("char.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, SF_TRUE) ; - pcm_test_short ("short.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_16, SF_TRUE) ; - pcm_test_24bit ("24bit.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_24, SF_TRUE) ; - } - else - puts (" No FLAC tests because FLAC support was not compiled in.") ; - test_count++ ; - } ; - - if (do_all || ! strcmp (argv [1], "rf64")) - { pcm_test_char ("char.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_U8, SF_FALSE) ; - pcm_test_short ("short.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_16, SF_FALSE) ; - pcm_test_24bit ("24bit.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_24, SF_FALSE) ; - pcm_test_int ("int.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_32, SF_FALSE) ; - - /* Lite remove start */ - pcm_test_float ("float.rf64" , SF_FORMAT_RF64 | SF_FORMAT_FLOAT , SF_FALSE) ; - pcm_test_double ("double.rf64" , SF_FORMAT_RF64 | SF_FORMAT_DOUBLE, SF_FALSE) ; - empty_file_test ("empty_char.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_U8) ; - empty_file_test ("empty_short.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; - empty_file_test ("empty_float.rf64", SF_FORMAT_RF64 | SF_FORMAT_FLOAT) ; - /* Lite remove end */ - - test_count++ ; - } ; - - if (test_count == 0) - { printf ("Mono : ************************************\n") ; - printf ("Mono : * No '%s' test defined.\n", argv [1]) ; - printf ("Mono : ************************************\n") ; - return 1 ; - } ; - - /* Only open file descriptors should be stdin, stdout and stderr. */ - check_open_file_count_or_die (__LINE__) ; - - return 0 ; -} /* main */ - -/*============================================================================================ -** Helper functions and macros. -*/ - -static void create_short_file (const char *filename) ; - -#define CHAR_ERROR(x, y) (abs ((x) - (y)) > 255) -#define INT_ERROR(x, y) (((x) - (y)) != 0) -#define BIT_20_ERROR(x, y) (abs ((x) - (y)) > 4095) -#define TRIBYTE_ERROR(x, y) (abs ((x) - (y)) > 255) -#define FLOAT_ERROR(x, y) (fabs ((x) - (y)) > 1e-5) - -#define CONVERT_DATA(k, len, new, orig) \ - { for ((k) = 0 ; (k) < (len) ; (k) ++) \ - (new) [k] = (orig) [k] ; \ - } - -[+ FOR data_type -+] -/*====================================================================================== -*/ - -static void mono_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) ; -static void stereo_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) ; -static void mono_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) ; -static void new_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int allow_fd) ; -static void multi_seek_test (const char * filename, int format) ; -static void write_seek_extend_test (const char * filename, int format) ; - -static void -pcm_test_[+ (get "type_name") +] (const char *filename, int format, int long_file_ok) -{ SF_INFO sfinfo ; - [+ (get "data_type") +] *orig ; - int k, allow_fd ; - - /* Sd2 files cannot be opened from an existing file descriptor. */ - allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; - - get_unique_test_name (&filename, WRT_TEST_PREFIX) ; - print_test_name ("pcm_test_[+ (get "type_name") +]", filename) ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = SILLY_WRITE_COUNT ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = format ; - - test_sf_format_or_die (&sfinfo, __LINE__) ; - - gen_windowed_sine_double (orig_data.d, DATA_LENGTH, [+ (get "max_val") +]) ; - - orig = orig_data.[+ (get "data_field") +] ; - - /* Make this a macro so gdb steps over it in one go. */ - CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; - - /* Some test broken out here. */ - - mono_[+ (get "type_name") +]_test (filename, format, long_file_ok, allow_fd) ; - - /* Sub format DWVW does not allow seeking. */ - if ((format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_16 || - (format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_24) - { unlink (filename) ; - printf ("no seek : ok\n") ; - return ; - } ; - - if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC - && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_16 - && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_20 - && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_24 - && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_32 - ) - mono_rdwr_[+ (get "type_name") +]_test (filename, format, long_file_ok, allow_fd) ; - - /* If the format doesn't support stereo we're done. */ - sfinfo.channels = 2 ; - if (sf_format_check (&sfinfo) == 0) - { unlink (filename) ; - puts ("no stereo : ok") ; - return ; - } ; - - stereo_[+ (get "type_name") +]_test (filename, format, long_file_ok, allow_fd) ; - - /* New read/write test. Not sure if this is needed yet. */ - - if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_PAF - && (format & SF_FORMAT_TYPEMASK) != SF_FORMAT_VOC - && (format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC - && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_16 - && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_20 - && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_24 - && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_32 - ) - new_rdwr_[+ (get "type_name") +]_test (filename, format, allow_fd) ; - - delete_file (format, filename) ; - - puts ("ok") ; - return ; -} /* pcm_test_[+ (get "type_name") +] */ - -static void -mono_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) -{ SNDFILE *file ; - SF_INFO sfinfo ; - [+ (get "data_type") +] *orig, *test ; - sf_count_t count ; - int k, items, total ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = SILLY_WRITE_COUNT ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 1 ; - sfinfo.format = format ; - - orig = orig_data.[+ (get "data_field") +] ; - test = test_data.[+ (get "data_field") +] ; - - items = DATA_LENGTH ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; - - if (sfinfo.frames || sfinfo.sections || sfinfo.seekable) - { printf ("\n\nLine %d : Weird SF_INFO fields.\n", __LINE__) ; - exit (1) ; - } ; - - sf_set_string (file, SF_STR_ARTIST, "Your name here") ; - - test_write_[+ (get "data_type") +]_or_die (file, 0, orig, items, __LINE__) ; - sf_write_sync (file) ; - test_write_[+ (get "data_type") +]_or_die (file, 0, orig, items, __LINE__) ; - sf_write_sync (file) ; - - /* Add non-audio data after the audio. */ - sf_set_string (file, SF_STR_COPYRIGHT, "Copyright (c) 2003") ; - - sf_close (file) ; - - memset (test, 0, items * sizeof ([+ (get "data_type") +])) ; - - if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, allow_fd, __LINE__) ; - - if (sfinfo.format != format) - { printf ("\n\nLine %d : Mono : Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, format, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < 2 * items) - { printf ("\n\nLine %d : Mono : Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, items) ; - exit (1) ; - } ; - - if (! long_file_ok && sfinfo.frames > 2 * items) - { printf ("\n\nLine %d : Mono : Incorrect number of frames in file (too long). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, items) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d : Mono : Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - if (sfinfo.seekable != 1) - { printf ("\n\nLine %d : File should be seekable.\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_read_[+ (get "data_type") +]_or_die (file, 0, test, items, __LINE__) ; - for (k = 0 ; k < items ; k++) - if ([+ (get "error_func") +] (orig [k], test [k])) - { printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; - oct_save_[+ (get "data_type") +] (orig, test, items) ; - exit (1) ; - } ; - - /* Test multiple short reads. */ - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - total = 0 ; - for (k = 1 ; k <= 32 ; k++) - { int ik ; - - test_read_[+ (get "data_type") +]_or_die (file, 0, test + total, k, __LINE__) ; - total += k ; - - for (ik = 0 ; ik < total ; ik++) - if ([+ (get "error_func") +] (orig [ik], test [ik])) - { printf ("\n\nLine %d : Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, ik, orig [ik], test [ik]) ; - exit (1) ; - } ; - } ; - - /* Seek to start of file. */ - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - test_read_[+ (get "data_type") +]_or_die (file, 0, test, 4, __LINE__) ; - for (k = 0 ; k < 4 ; k++) - if ([+ (get "error_func") +] (orig [k], test [k])) - { printf ("\n\nLine %d : Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; - exit (1) ; - } ; - - /* For some codecs we can't go past here. */ - if ((format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_16 || - (format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_24) - { sf_close (file) ; - unlink (filename) ; - printf ("no seek : ") ; - return ; - } ; - - /* Seek to offset from start of file. */ - test_seek_or_die (file, items + 10, SEEK_SET, items + 10, sfinfo.channels, __LINE__) ; - - test_read_[+ (get "data_type") +]_or_die (file, 0, test + 10, 4, __LINE__) ; - for (k = 10 ; k < 14 ; k++) - if ([+ (get "error_func") +] (orig [k], test [k])) - { printf ("\n\nLine %d : Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, test [k], orig [k]) ; - exit (1) ; - } ; - - /* Seek to offset from current position. */ - test_seek_or_die (file, 6, SEEK_CUR, items + 20, sfinfo.channels, __LINE__) ; - - test_read_[+ (get "data_type") +]_or_die (file, 0, test + 20, 4, __LINE__) ; - for (k = 20 ; k < 24 ; k++) - if ([+ (get "error_func") +] (orig [k], test [k])) - { printf ("\n\nLine %d : Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, test [k], orig [k]) ; - exit (1) ; - } ; - - /* Seek to offset from end of file. */ - test_seek_or_die (file, -1 * (sfinfo.frames - 10), SEEK_END, 10, sfinfo.channels, __LINE__) ; - - test_read_[+ (get "data_type") +]_or_die (file, 0, test + 10, 4, __LINE__) ; - for (k = 10 ; k < 14 ; k++) - if ([+ (get "error_func") +] (orig [k], test [k])) - { printf ("\n\nLine %d : Mono : Incorrect sample D (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, test [k], orig [k]) ; - exit (1) ; - } ; - - /* Check read past end of file followed by sf_seek (sndfile, 0, SEEK_CUR). */ - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - count = 0 ; - while (count < sfinfo.frames) - count += sf_read_[+ (get "data_type") +] (file, test, 311) ; - - /* Check that no error has occurred. */ - if (sf_error (file)) - { printf ("\n\nLine %d : Mono : error where there shouldn't have been one.\n", __LINE__) ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - /* Check that we haven't read beyond EOF. */ - if (count > sfinfo.frames) - { printf ("\n\nLines %d : read past end of file (%" PRId64 " should be %" PRId64 ")\n", __LINE__, count, sfinfo.frames) ; - exit (1) ; - } ; - - test_seek_or_die (file, 0, SEEK_CUR, sfinfo.frames, sfinfo.channels, __LINE__) ; - - sf_close (file) ; - - multi_seek_test (filename, format) ; - write_seek_extend_test (filename, format) ; - -} /* mono_[+ (get "type_name") +]_test */ - -static void -stereo_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) -{ SNDFILE *file ; - SF_INFO sfinfo ; - [+ (get "data_type") +] *orig, *test ; - int k, items, frames ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = SILLY_WRITE_COUNT ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 2 ; - sfinfo.format = format ; - - gen_windowed_sine_double (orig_data.d, DATA_LENGTH, [+ (get "max_val") +]) ; - - orig = orig_data.[+ (get "data_field") +] ; - test = test_data.[+ (get "data_field") +] ; - - /* Make this a macro so gdb steps over it in one go. */ - CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; - - items = DATA_LENGTH ; - frames = items / sfinfo.channels ; - - file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; - - sf_set_string (file, SF_STR_ARTIST, "Your name here") ; - - test_writef_[+ (get "data_type") +]_or_die (file, 0, orig, frames, __LINE__) ; - - sf_set_string (file, SF_STR_COPYRIGHT, "Copyright (c) 2003") ; - - sf_close (file) ; - - memset (test, 0, items * sizeof ([+ (get "data_type") +])) ; - - if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) - memset (&sfinfo, 0, sizeof (sfinfo)) ; - - file = test_open_file_or_die (filename, SFM_READ, &sfinfo, allow_fd, __LINE__) ; - - if (sfinfo.format != format) - { printf ("\n\nLine %d : Stereo : Returned format incorrect (0x%08X => 0x%08X).\n", - __LINE__, format, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < frames) - { printf ("\n\nLine %d : Stereo : Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", - __LINE__, sfinfo.frames, frames) ; - exit (1) ; - } ; - - if (! long_file_ok && sfinfo.frames > frames) - { printf ("\n\nLine %d : Stereo : Incorrect number of frames in file (too long). (%" PRId64 " should be %d)\n", - __LINE__, sfinfo.frames, frames) ; - exit (1) ; - } ; - - if (sfinfo.channels != 2) - { printf ("\n\nLine %d : Stereo : Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - check_log_buffer_or_die (file, __LINE__) ; - - test_readf_[+ (get "data_type") +]_or_die (file, 0, test, frames, __LINE__) ; - for (k = 0 ; k < items ; k++) - if ([+ (get "error_func") +] (test [k], orig [k])) - { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; - exit (1) ; - } ; - - /* Seek to start of file. */ - test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; - - test_readf_[+ (get "data_type") +]_or_die (file, 0, test, 2, __LINE__) ; - for (k = 0 ; k < 4 ; k++) - if ([+ (get "error_func") +] (test [k], orig [k])) - { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; - exit (1) ; - } ; - - /* Seek to offset from start of file. */ - test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; - - /* Check for errors here. */ - if (sf_error (file)) - { printf ("Line %d: Should NOT return an error.\n", __LINE__) ; - puts (sf_strerror (file)) ; - exit (1) ; - } ; - - if (sf_read_[+ (get "data_type") +] (file, test, 1) > 0) - { printf ("Line %d: Should return 0.\n", __LINE__) ; - exit (1) ; - } ; - - if (! sf_error (file)) - { printf ("Line %d: Should return an error.\n", __LINE__) ; - exit (1) ; - } ; - /*-----------------------*/ - - test_readf_[+ (get "data_type") +]_or_die (file, 0, test + 10, 2, __LINE__) ; - for (k = 20 ; k < 24 ; k++) - if ([+ (get "error_func") +] (test [k], orig [k])) - { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; - exit (1) ; - } ; - - /* Seek to offset from current position. */ - test_seek_or_die (file, 8, SEEK_CUR, 20, sfinfo.channels, __LINE__) ; - - test_readf_[+ (get "data_type") +]_or_die (file, 0, test + 20, 2, __LINE__) ; - for (k = 40 ; k < 44 ; k++) - if ([+ (get "error_func") +] (test [k], orig [k])) - { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; - exit (1) ; - } ; - - /* Seek to offset from end of file. */ - test_seek_or_die (file, -1 * (sfinfo.frames - 10), SEEK_END, 10, sfinfo.channels, __LINE__) ; - - test_readf_[+ (get "data_type") +]_or_die (file, 0, test + 20, 2, __LINE__) ; - for (k = 20 ; k < 24 ; k++) - if ([+ (get "error_func") +] (test [k], orig [k])) - { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; - exit (1) ; - } ; - - sf_close (file) ; -} /* stereo_[+ (get "type_name") +]_test */ - -static void -mono_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) -{ SNDFILE *file ; - SF_INFO sfinfo ; - [+ (get "data_type") +] *orig, *test ; - int k, pass ; - - switch (format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_ALAC_16 : - case SF_FORMAT_ALAC_20 : - case SF_FORMAT_ALAC_24 : - case SF_FORMAT_ALAC_32 : - allow_fd = 0 ; - break ; - - default : - break ; - } ; - - orig = orig_data.[+ (get "data_field") +] ; - test = test_data.[+ (get "data_field") +] ; - - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = DATA_LENGTH ; - sfinfo.channels = 1 ; - sfinfo.format = format ; - - if ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_RAW - || (format & SF_FORMAT_TYPEMASK) == SF_FORMAT_AU - || (format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) - unlink (filename) ; - else - { /* Create a short file. */ - create_short_file (filename) ; - - /* Opening a already existing short file (ie invalid header) RDWR is disallowed. - ** If this returns a valif pointer sf_open() screwed up. - */ - if ((file = sf_open (filename, SFM_RDWR, &sfinfo))) - { printf ("\n\nLine %d: sf_open should (SFM_RDWR) have failed but didn't.\n", __LINE__) ; - exit (1) ; - } ; - - /* Truncate the file to zero bytes. */ - if (truncate_file_to_zero (filename) < 0) - { printf ("\n\nLine %d: truncate_file_to_zero (%s) failed", __LINE__, filename) ; - perror (NULL) ; - exit (1) ; - } ; - } ; - - /* Opening a zero length file RDWR is allowed, but the SF_INFO struct must contain - ** all the usual data required when opening the file in WRITE mode. - */ - sfinfo.samplerate = SAMPLE_RATE ; - sfinfo.frames = DATA_LENGTH ; - sfinfo.channels = 1 ; - sfinfo.format = format ; - - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ; - - /* Do 3 writes followed by reads. After each, check the data and the current - ** read and write offsets. - */ - for (pass = 1 ; pass <= 3 ; pass ++) - { orig [20] = pass * 2 ; - - /* Write some data. */ - test_write_[+ (get "data_type") +]_or_die (file, pass, orig, DATA_LENGTH, __LINE__) ; - - test_read_write_position_or_die (file, __LINE__, pass, (pass - 1) * DATA_LENGTH, pass * DATA_LENGTH) ; - - /* Read what we just wrote. */ - test_read_[+ (get "data_type") +]_or_die (file, 0, test, DATA_LENGTH, __LINE__) ; - - /* Check the data. */ - for (k = 0 ; k < DATA_LENGTH ; k++) - if ([+ (get "error_func") +] (orig [k], test [k])) - { printf ("\n\nLine %d (pass %d) A : Error at sample %d ([+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, pass, k, orig [k], test [k]) ; - oct_save_[+ (get "data_type") +] (orig, test, DATA_LENGTH) ; - exit (1) ; - } ; - - test_read_write_position_or_die (file, __LINE__, pass, pass * DATA_LENGTH, pass * DATA_LENGTH) ; - } ; /* for (pass ...) */ - - sf_close (file) ; - - /* Open the file again to check the data. */ - file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ; - - if (sfinfo.format != format) - { printf ("\n\nLine %d : Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, format, sfinfo.format) ; - exit (1) ; - } ; - - if (sfinfo.frames < 3 * DATA_LENGTH) - { printf ("\n\nLine %d : Not enough frames in file. (%" PRId64 " < %d)\n", __LINE__, sfinfo.frames, 3 * DATA_LENGTH) ; - exit (1) ; - } - - if (! long_file_ok && sfinfo.frames != 3 * DATA_LENGTH) - { printf ("\n\nLine %d : Incorrect number of frames in file. (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, 3 * DATA_LENGTH) ; - exit (1) ; - } ; - - if (sfinfo.channels != 1) - { printf ("\n\nLine %d : Incorrect number of channels in file.\n", __LINE__) ; - exit (1) ; - } ; - - if (! long_file_ok) - test_read_write_position_or_die (file, __LINE__, 0, 0, 3 * DATA_LENGTH) ; - else - test_seek_or_die (file, 3 * DATA_LENGTH, SFM_WRITE | SEEK_SET, 3 * DATA_LENGTH, sfinfo.channels, __LINE__) ; - - for (pass = 1 ; pass <= 3 ; pass ++) - { orig [20] = pass * 2 ; - - test_read_write_position_or_die (file, __LINE__, pass, (pass - 1) * DATA_LENGTH, 3 * DATA_LENGTH) ; - - /* Read what we just wrote. */ - test_read_[+ (get "data_type") +]_or_die (file, pass, test, DATA_LENGTH, __LINE__) ; - - /* Check the data. */ - for (k = 0 ; k < DATA_LENGTH ; k++) - if ([+ (get "error_func") +] (orig [k], test [k])) - { printf ("\n\nLine %d (pass %d) B : Error at sample %d ([+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, pass, k, orig [k], test [k]) ; - oct_save_[+ (get "data_type") +] (orig, test, DATA_LENGTH) ; - exit (1) ; - } ; - - } ; /* for (pass ...) */ - - sf_close (file) ; -} /* mono_rdwr_[+ (get "data_type") +]_test */ - -static void -new_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int allow_fd) -{ SNDFILE *wfile, *rwfile ; - SF_INFO sfinfo ; - [+ (get "data_type") +] *orig, *test ; - int items, frames ; - - orig = orig_data.[+ (get "data_field") +] ; - test = test_data.[+ (get "data_field") +] ; - - sfinfo.samplerate = 44100 ; - sfinfo.frames = SILLY_WRITE_COUNT ; /* Wrong length. Library should correct this on sf_close. */ - sfinfo.channels = 2 ; - sfinfo.format = format ; - - items = DATA_LENGTH ; - frames = items / sfinfo.channels ; - - wfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; - sf_command (wfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) ; - test_writef_[+ (get "data_type") +]_or_die (wfile, 1, orig, frames, __LINE__) ; - sf_write_sync (wfile) ; - test_writef_[+ (get "data_type") +]_or_die (wfile, 2, orig, frames, __LINE__) ; - sf_write_sync (wfile) ; - - rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ; - if (sfinfo.frames != 2 * frames) - { printf ("\n\nLine %d : incorrect number of frames in file (%" PRId64 " should be %d)\n\n", __LINE__, sfinfo.frames, 2 * frames) ; - exit (1) ; - } ; - - test_writef_[+ (get "data_type") +]_or_die (wfile, 3, orig, frames, __LINE__) ; - - test_readf_[+ (get "data_type") +]_or_die (rwfile, 1, test, frames, __LINE__) ; - test_readf_[+ (get "data_type") +]_or_die (rwfile, 2, test, frames, __LINE__) ; - - sf_close (wfile) ; - sf_close (rwfile) ; -} /* new_rdwr_[+ (get "type_name") +]_test */ - -[+ ENDFOR data_type +] - -/*---------------------------------------------------------------------------------------- -*/ - -static void -empty_file_test (const char *filename, int format) -{ SNDFILE *file ; - SF_INFO info ; - int allow_fd ; - - /* Sd2 files cannot be opened from an existing file descriptor. */ - allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; - - get_unique_test_name (&filename, WRT_TEST_PREFIX) ; - print_test_name ("empty_file_test", filename) ; - - unlink (filename) ; - - info.samplerate = 48000 ; - info.channels = 2 ; - info.format = format ; - info.frames = 0 ; - - if (sf_format_check (&info) == SF_FALSE) - { info.channels = 1 ; - if (sf_format_check (&info) == SF_FALSE) - { puts ("invalid file format") ; - return ; - } ; - } ; - - /* Create an empty file. */ - file = test_open_file_or_die (filename, SFM_WRITE, &info, allow_fd, __LINE__) ; - sf_close (file) ; - - /* Open for read and check the length. */ - file = test_open_file_or_die (filename, SFM_READ, &info, allow_fd, __LINE__) ; - - if (info.frames != 0) - { printf ("\n\nError : frame count (%" PRId64 ") should be zero.\n", info.frames) ; - exit (1) ; - } ; - - sf_close (file) ; - - /* Open for read/write and check the length. */ - file = test_open_file_or_die (filename, SFM_RDWR, &info, allow_fd, __LINE__) ; - - if (info.frames != 0) - { printf ("\n\nError : frame count (%" PRId64 ") should be zero.\n", info.frames) ; - exit (1) ; - } ; - - sf_close (file) ; - - /* Open for read and check the length. */ - file = test_open_file_or_die (filename, SFM_READ, &info, allow_fd, __LINE__) ; - - if (info.frames != 0) - { printf ("\n\nError : frame count (%" PRId64 ") should be zero.\n", info.frames) ; - exit (1) ; - } ; - - sf_close (file) ; - - check_open_file_count_or_die (__LINE__) ; - - unlink (filename) ; - puts ("ok") ; - - return ; -} /* empty_file_test */ - - -/*---------------------------------------------------------------------------------------- -*/ - -static void -create_short_file (const char *filename) -{ FILE *file ; - - if (! (file = fopen (filename, "w"))) - { printf ("create_short_file : fopen (%s, \"w\") failed.", filename) ; - fflush (stdout) ; - perror (NULL) ; - exit (1) ; - } ; - - fprintf (file, "This is the file data.\n") ; - - fclose (file) ; -} /* create_short_file */ - - -static void -multi_seek_test (const char * filename, int format) -{ SNDFILE * file ; - SF_INFO info ; - sf_count_t pos ; - int k ; - - /* This test doesn't work on the following. */ - switch (format & SF_FORMAT_TYPEMASK) - { case SF_FORMAT_RAW : - return ; - - default : - break ; - } ; - - memset (&info, 0, sizeof (info)) ; - - generate_file (filename, format, 88200) ; - - file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ; - - for (k = 0 ; k < 10 ; k++) - { pos = info.frames / (k + 2) ; - test_seek_or_die (file, pos, SEEK_SET, pos, info.channels, __LINE__) ; - } ; - - sf_close (file) ; -} /* multi_seek_test */ - -static void -write_seek_extend_test (const char * filename, int format) -{ SNDFILE * file ; - SF_INFO info ; - short *orig, *test ; - unsigned items, k ; - - /* This test doesn't work on the following container formats. */ - switch (format & SF_FORMAT_TYPEMASK) - { case SF_FORMAT_FLAC : - case SF_FORMAT_HTK : - case SF_FORMAT_PAF : - case SF_FORMAT_SDS : - case SF_FORMAT_SVX : - return ; - - default : - break ; - } ; - - /* This test doesn't work on the following codec formats. */ - switch (format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_ALAC_16 : - case SF_FORMAT_ALAC_20 : - case SF_FORMAT_ALAC_24 : - case SF_FORMAT_ALAC_32 : - return ; - - default : - break ; - } ; - - memset (&info, 0, sizeof (info)) ; - - info.samplerate = 48000 ; - info.channels = 1 ; - info.format = format ; - - items = 512 ; - exit_if_true (items > ARRAY_LEN (orig_data.s), "Line %d : Bad assumption.\n", __LINE__) ; - - orig = orig_data.s ; - test = test_data.s ; - - for (k = 0 ; k < ARRAY_LEN (orig_data.s) ; k++) - orig [k] = 0x3fff ; - - file = test_open_file_or_die (filename, SFM_WRITE, &info, SF_FALSE, __LINE__) ; - test_write_short_or_die (file, 0, orig, items, __LINE__) ; - - /* Extend the file using a seek. */ - test_seek_or_die (file, 2 * items, SEEK_SET, 2 * items, info.channels, __LINE__) ; - - test_writef_short_or_die (file, 0, orig, items, __LINE__) ; - sf_close (file) ; - - file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ; - test_read_short_or_die (file, 0, test, 3 * items, __LINE__) ; - sf_close (file) ; - - if (info.frames < 3 * items) - { printf ("\n\nLine %d : Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, info.frames, 3 * items) ; - exit (1) ; - } ; - - /* Can't do these formats due to scaling. */ - switch (format & SF_FORMAT_SUBMASK) - { case SF_FORMAT_PCM_S8 : - case SF_FORMAT_PCM_U8 : - return ; - default : - break ; - } ; - - for (k = 0 ; k < items ; k++) - { exit_if_true (test [k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, k, test [k]) ; - exit_if_true (test [items + k] != 0, "Line %d : test [%d] == %d, should be 0.\n", __LINE__, items + k, test [items + k]) ; - exit_if_true (test [2 * items + k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, 2 * items + k, test [2 * items + k]) ; - } ; - - return ; -} /* write_seek_extend_test */ - - diff --git a/Engine/lib/libsndfile/vcpkg.json b/Engine/lib/libsndfile/vcpkg.json deleted file mode 100644 index de8a94883..000000000 --- a/Engine/lib/libsndfile/vcpkg.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", - "name": "libsndfile", - "description": "A library for reading and writing audio files", - "version-semver": "1.2.0", - "default-features": [ - "external-libs", - "mpeg" - ], - "features": { - "external-libs": { - "description": "Enable FLAC, Vorbis, and Opus codecs", - "dependencies": [ - "libvorbis", - "libflac", - "opus" - ] - }, - "mpeg": { - "description": "Enable MPEG codecs", - "dependencies": [ - "mpg123", - "mp3lame" - ] - }, - "regtest": { - "description": "Build regtest", - "dependencies": [ - "sqlite3" - ] - }, - "experimental": { - "description": "Enable experimental code", - "dependencies": [ - "speex" - ] - } - } -} diff --git a/Engine/lib/libtheora/CHANGES b/Engine/lib/libtheora/CHANGES deleted file mode 100644 index b30327e63..000000000 --- a/Engine/lib/libtheora/CHANGES +++ /dev/null @@ -1,231 +0,0 @@ -libtheora 1.1.1 (2009 October 1) - - - Fix problems with MSVC inline assembly - - Add the missing encoder_disabled.c to the distribution - - build updates: autogen.sh should work better after switching systems - and the MSVC project now defaults to the dynamic runtime library - - Namespace some variables to avoid conflicts on wince. - -libtheora 1.1.0 (2009 September 24) - - - Fix various small issues with the example and telemetry code - - Fix handing a zero-byte packet as the first frame - - Documentation cleanup - - Two minor build fixes - -libtheora 1.1beta3 (2009 August 22) - - - Rate control fixes to smooth quality - - MSVC build now exports all of the 1.0 api - - Assorted small bug fixes - -libtheora 1.1beta2 (2009 August 12) - - - Fix a rate control problem with difficult input - - Build fixes for OpenBSD and Apple Xcode - - Examples now all use the 1.0 api - - TH_ENCCTL_SET_SPLEVEL works again - - Various bug fixes and source tree rearrangement - -libtheora 1.1beta1 (2009 August 5) - - - Support for two-pass encoding - - Performance optimization of both encoder and decoder - - Encoder supports dynamic adjustment of quality and - bitrate targets - - Encoder is generally more configurable, and all - rate control modes perform better - - Encoder now accepts 4:2:2 and 4:4:4 chroma sampling - - Decoder telemetry output shows quantization choice - and a breakdown of bitrate usage in the frame - - MSVC assembly optimizations up to date and functional - -libtheora 1.1alpha2 (2009 May 26) - - - Reduce lambda for small quantizers. - - New encoder fDCT does better on smooth gradients - - Use SATD for mode decisions (1-2% bitrate reduction) - - Assembly rewrite for new features and general speed up - - Share code between the encoder and decoder for performance - - Fix 4:2:2 decoding and telemetry - - MSVC project files updated, but assembly is disabled. - - New configure option --disable-spec to work around toolchain - detection failures. - - Limit symbol exports on MacOS X. - - Port remaining unit tests from the 1.0 release. - -libtheora 1.1alpha1 (2009 March 27) - - - Encoder rewrite with much improved vbr quality/bitrate and - better tracking of the target rate in cbr mode. - - MSVC project files do not work in this release. - -libtheora 1.0 (2008 November 3) - - - Merge x86 assembly for forward DCT from Thusnelda branch. - - Update 32 bit MMX with loop filter fix. - - Check for an uninitialized state before dereferencing in propagating - decode calls. - - Remove all TH_DEBUG statements. - - Rename the bitpacker source files copied from libogg to avoid - confusing simple build systems using both libraries. - - Declare bitfield entries to be explicitly signed for Solaris cc. - - Set quantization parameters to default values when an empty buffer is - passed with TH_ENCCTL_SET_QUANT_PARAMS. - - Split encoder and decoder tests depending on configure settings. - - Return lstylex.sty to the distribution. - - Disable inline assembly on gcc versions prior to 3.1. - - Remove extern references for OC_*_QUANT_MIN. - - Make various data tables static const so they can be read-only. - - Remove ENCCTL codes from the old encoder API. - - Implement TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE ctl. - - Fix segfault when exactly one of the width or height is not a multiple - of 16, but the other is. - - Compute the correct vertical offset for chroma. - - cpuid assembly fix for MSVC. - - Add VS2008 project files. - - Build updates for 64-bit platforms, Mingw32, VS and XCode. - - Do not clobber the cropping rectangle. - - Declare ourselves 1.0final to pkg-config to sort after beta releases. - - Fix the scons build to include asm in libtheoradec/enc. - -libtheora 1.0beta3 (2008 April 16) - - - Build new libtheoradec and libtheoraenc libraries - supporting the new API from theora-exp. This API should - not be considered stable yet. - - Change granule_frame() to return an index as documented. - This is a change of behaviour from 1.0beta1. - - Document that granule_time() returns the end of the - presentation interval. - - Use a custom copy of the libogg bitpacker in the decoder - to avoid function call overhead. - - MMX code improved and ported to MSVC. - - Fix a problem with the MMX code on SELinux. - - Fix a problem with decoder quantizer initialization. - - Fix a page queue problem with png2theora. - - Improved robustness. - - Updated VS2005 project files. - - Dropped build support for Microsoft VS2003. - - Dropped build support for the unreleased libogg2. - - Added the specification to the autotools build. - - Specification corrections. - -libtheora 1.0beta2 (2007 October 12) - - - Fix a crash bug on char-is-unsigned architectures (PowerPC) - - Fix a buffer sizing issue that caused rare encoder crashes - - Fix a buffer alignment issue - - Build fixes for MingW32, MSVC - - Improved format documentation. - -libtheora 1.0beta1 (2007 September 22) - - - Granulepos scheme modified to match other codecs. This bumps - the bitstream revision to 3.2.1. Bitstreams marked 3.2.0 are - handled correctly by this decoder. Older decoders will show - a one frame sync error in the less noticable direction. - -libtheora 1.0alpha8 (2007 September 18) - - - Switch to new spec compliant decoder from theora-exp branch. - Written by Dr. Timothy Terriberry. - - Add support to the encoder for using quantization settings - provided by the application. - - more assembly optimizations - -libtheora 1.0alpha7 (2006 June 20) - - - Enable mmx assembly by default - - Avoid some relocations that caused problems on SELinux - - Other build fixes - - time testing mode (-f) for the dump_video example - -libtheora 1.0alpha6 (2006 May 30) - - * Merge theora-mmx simd acceleration (x86_32 and x86_64) - * Major RTP payload specification update - * Minor format specification updates - * Fix some spurious calls to free() instead of _ogg_free() - * Fix invalid array indexing in PixelLineSearch() - * Improve robustness against invalid input - * General warning cleanup - * The offset_y member now means what every application thought it meant - (offset from the top). This will mean some old files (those with a - non-centered image created with a buggy encoder) will display differently. - -libtheora 1.0alpha5 (2005 August 20) - - * Fixed bitrate management bugs that caused popping and encode - errors - * Fixed a crash problem with the theora_state internals not - being intialized properly. - * new utility function: - - theora_granule_shift() - * dump_video example now makes YUV4MPEG files by default, so - the results can be fed back to encoder_example and similar - tools. The old behavior is restored through the '-r' switch. - * ./configure now prints a summary - * simple unit test of the comment api under 'make check' - * misc code cleanup, warning and leak fixes - -libtheora 1.0alpha4 (2004 December 15) - - * first draft of the Theora I Format Specification - * API documentation generated from theora.h with Doxygen - * fix a double-update bug in the motion analysis - * apply the loop filter before filling motion vector border - in the reference frame - * new utility functions: - - theora_packet_isheader(), - - theora_packet_iskeyframe() - - theora_granule_frame() - * optional support for building without floating point - * optional support for building without encode support - * various build and packaging fixes - * pkg-config support - * SymbianOS build support - -libtheora 1.0alpha3 (2004 March 20) - - UPDATE: on 2004 July 1 the Theora I bitstream format was frozen. Files - produced by the libtheora 1.0alpha3 reference encoder will always be - decodable by the Theora I spec. - - * Bitstream info header FORMAT CHANGES: - - move the granulepos shift field to maintain byte alignment longer. - - reserve 5 additional bits for subsampling and interlace flags. - * Bitstream setup header FORMAT CHANGES: - - support for a range of interpolated quant matricies. - - include the in-loop block filter coeff. - * Bitsteam data packet FORMAT CHANGES: - - Reserve a bit for per-block Q index selection. - - Flip the coded image orientation for compatibility with VP3. - This allows lossless transcoding of VP3 content, but files - encoded with earlier theora releases would play upside down. - * example VP3 lossless transcoder - * optional support for libogg2 - * timing improvements in the example player - * packaging and build system updates and fixes - -libtheora 1.0alpha2 (2003 June 9) - - * bitstream FORMAT CHANGES: - - store the quant tables in a third setup header for - future encoder flexibility - - store the huffman tables in the third setup header - - add a field for marking the colorspace to the info header - - add crop parameters for non-multiple-of-16 frame sizes - - add a second vorbiscomment-style metadata header - * API changes to handle multiple headers with a single - theora_decode_header() call, like libvorbis - * code cleanup and minor fixes - * new dump_video code example/utility - * experimental win32 code examples - -libtheora 1.0alpha1 (2002 September 25) - - * First release of the theora reference implementation - * Port of the newly opened VP3 code to the Ogg container - * Rewrite of the code for portability and to use the libogg bitpacker - diff --git a/Engine/lib/libtheora/CMakeLists.txt b/Engine/lib/libtheora/CMakeLists.txt deleted file mode 100644 index 5b0749f05..000000000 --- a/Engine/lib/libtheora/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -#if(TORQUE_SFX_OPENAL AND NOT TORQUE_DEDICATED) - project(libtheora) - file(GLOB LIBTHEORA_SOURCE_FILES "lib/*.c" "lib/*.h") - file(GLOB LIBTHEORA_HEADER_FILES "include/theora/*.h") - set(LIBTHEORA_FILES ${LIBTHEORA_SOURCE_FILES} ${LIBTHEORA_HEADER_FILES}) - set(LIBTHEORA_COMPILE_DEFINES "") - if (WIN32 AND TORQUE_CPU_X32) - file(GLOB LIBTHEORA_SOURCE_FILES_X86_VC "lib/x86_vc/*.c") - set(LIBTHEORA_FILES ${LIBTHEORA_FILES} ${LIBTHEORA_SOURCE_FILES_X86_VC}) - set(LIBTHEORA_COMPILE_DEFINES ${LIBTHEORA_COMPILE_DEFINES} OC_X86_ASM) - elseif (TORQUE_CPU_X32) - file(GLOB LIBTHEORA_SOURCE_FILES_X86_VC "lib/x86/*.c") - set(LIBTHEORA_FILES ${LIBTHEORA_FILES} ${LIBTHEORA_SOURCE_FILES_X86_VC}) - set(LIBTHEORA_COMPILE_DEFINES ${LIBTHEORA_COMPILE_DEFINES} OC_X86_ASM) - endif (WIN32 AND TORQUE_CPU_X32) - - add_library(libtheora ${LIBTHEORA_FILES}) - target_include_directories(libtheora PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") - target_link_libraries(libtheora PUBLIC ogg) - target_compile_definitions(libtheora PUBLIC ${LIBTHEORA_COMPILE_DEFINES}) - set(TORQUE_INCLUDE_DIRECTORIES ${TORQUE_INCLUDE_DIRECTORIES} "${CMAKE_CURRENT_SOURCE_DIR}/include/theora") - #set(TORQUE_LINK_LIBRARIES ${TORQUE_LINK_LIBRARIES} libtheora PARENT_SCOPE) -#endif() \ No newline at end of file diff --git a/Engine/lib/libtheora/COPYING b/Engine/lib/libtheora/COPYING deleted file mode 100644 index c8ccce4ff..000000000 --- a/Engine/lib/libtheora/COPYING +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (C) 2002-2009 Xiph.org Foundation - -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 the Xiph.org Foundation nor the names of its -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 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. diff --git a/Engine/lib/libtheora/LICENSE b/Engine/lib/libtheora/LICENSE deleted file mode 100644 index 5e5ec0846..000000000 --- a/Engine/lib/libtheora/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -Please see the file COPYING for the copyright license for this software. - -In addition to and irrespective of the copyright license associated -with this software, On2 Technologies, Inc. makes the following statement -regarding technology used in this software: - - On2 represents and warrants that it shall not assert any rights - relating to infringement of On2's registered patents, nor initiate - any litigation asserting such rights, against any person who, or - entity which utilizes the On2 VP3 Codec Software, including any - use, distribution, and sale of said Software; which make changes, - modifications, and improvements in said Software; and to use, - distribute, and sell said changes as well as applications for other - fields of use. - -This reference implementation is originally derived from the On2 VP3 -Codec Software, and the Theora video format is essentially compatible -with the VP3 video format, consisting of a backward-compatible superset. diff --git a/Engine/lib/libtheora/Torque_postBuild.cmake b/Engine/lib/libtheora/Torque_postBuild.cmake deleted file mode 100644 index d5a1ed607..000000000 --- a/Engine/lib/libtheora/Torque_postBuild.cmake +++ /dev/null @@ -1 +0,0 @@ -set(TORQUE_LINK_LIBRARIES ${TORQUE_LINK_LIBRARIES} libtheora) \ No newline at end of file diff --git a/Engine/lib/libtheora/include/Makefile.am b/Engine/lib/libtheora/include/Makefile.am deleted file mode 100644 index d5db4b40f..000000000 --- a/Engine/lib/libtheora/include/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = theora diff --git a/Engine/lib/libtheora/include/Makefile.in b/Engine/lib/libtheora/include/Makefile.in deleted file mode 100644 index 805e6c29e..000000000 --- a/Engine/lib/libtheora/include/Makefile.in +++ /dev/null @@ -1,414 +0,0 @@ -# Makefile.in generated by automake 1.6.3 from Makefile.am. -# @configure_input@ - -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 -# Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = .. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_HEADER = $(INSTALL_DATA) -transform = @program_transform_name@ -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_alias = @host_alias@ -host_triplet = @host@ - -EXEEXT = @EXEEXT@ -OBJEXT = @OBJEXT@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ -AMTAR = @AMTAR@ -AR = @AR@ -ARGZ_H = @ARGZ_H@ -AS = @AS@ -AWK = @AWK@ -BUILDABLE_EXAMPLES = @BUILDABLE_EXAMPLES@ -CAIRO_CFLAGS = @CAIRO_CFLAGS@ -CAIRO_LIBS = @CAIRO_LIBS@ -CC = @CC@ -CPP = @CPP@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -DEBUG = @DEBUG@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -F77 = @F77@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ -GETOPT_OBJS = @GETOPT_OBJS@ -GREP = @GREP@ -HAVE_BIBTEX = @HAVE_BIBTEX@ -HAVE_DOXYGEN = @HAVE_DOXYGEN@ -HAVE_PDFLATEX = @HAVE_PDFLATEX@ -HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@ -HAVE_TRANSFIG = @HAVE_TRANSFIG@ -HAVE_VALGRIND = @HAVE_VALGRIND@ -INCLTDL = @INCLTDL@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LIBADD_DL = @LIBADD_DL@ -LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ -LIBADD_DLOPEN = @LIBADD_DLOPEN@ -LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ -LIBLTDL = @LIBLTDL@ -LIBM = @LIBM@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTDLDEPS = @LTDLDEPS@ -LTDLINCL = @LTDLINCL@ -LTDLOPEN = @LTDLOPEN@ -LT_CONFIG_H = @LT_CONFIG_H@ -LT_DLLOADERS = @LT_DLLOADERS@ -LT_DLPREOPEN = @LT_DLPREOPEN@ -MAINT = @MAINT@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OGG_CFLAGS = @OGG_CFLAGS@ -OGG_LIBS = @OGG_LIBS@ -OSS_LIBS = @OSS_LIBS@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PKG_CONFIG = @PKG_CONFIG@ -PNG_CFLAGS = @PNG_CFLAGS@ -PNG_LIBS = @PNG_LIBS@ -PROFILE = @PROFILE@ -RANLIB = @RANLIB@ -RC = @RC@ -SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ -SDL_LIBS = @SDL_LIBS@ -SED = @SED@ -STRIP = @STRIP@ -THDEC_LIB_AGE = @THDEC_LIB_AGE@ -THDEC_LIB_CURRENT = @THDEC_LIB_CURRENT@ -THDEC_LIB_REVISION = @THDEC_LIB_REVISION@ -THENC_LIB_AGE = @THENC_LIB_AGE@ -THENC_LIB_CURRENT = @THENC_LIB_CURRENT@ -THENC_LIB_REVISION = @THENC_LIB_REVISION@ -THEORADEC_LDFLAGS = @THEORADEC_LDFLAGS@ -THEORAENC_LDFLAGS = @THEORAENC_LDFLAGS@ -THEORA_LDFLAGS = @THEORA_LDFLAGS@ -TH_LIB_AGE = @TH_LIB_AGE@ -TH_LIB_CURRENT = @TH_LIB_CURRENT@ -TH_LIB_REVISION = @TH_LIB_REVISION@ -VALGRIND_ENVIRONMENT = @VALGRIND_ENVIRONMENT@ -VERSION = @VERSION@ -VORBISENC_LIBS = @VORBISENC_LIBS@ -VORBISFILE_LIBS = @VORBISFILE_LIBS@ -VORBIS_CFLAGS = @VORBIS_CFLAGS@ -VORBIS_LIBS = @VORBIS_LIBS@ -am__include = @am__include@ -am__quote = @am__quote@ -install_sh = @install_sh@ -lt_ECHO = @lt_ECHO@ -ltdl_LIBOBJS = @ltdl_LIBOBJS@ -ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ -sys_symbol_underscore = @sys_symbol_underscore@ - -SUBDIRS = theora -subdir = include -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -DIST_SOURCES = - -RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ - uninstall-info-recursive all-recursive install-data-recursive \ - install-exec-recursive installdirs-recursive install-recursive \ - uninstall-recursive check-recursive installcheck-recursive -DIST_COMMON = Makefile.am Makefile.in -DIST_SUBDIRS = $(SUBDIRS) -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu include/Makefile -Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @set fnord $$MAKEFLAGS; amf=$$2; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -mostlyclean-recursive clean-recursive distclean-recursive \ -maintainer-clean-recursive: - @set fnord $$MAKEFLAGS; amf=$$2; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done - -ETAGS = etags -ETAGSFLAGS = - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$tags$$unique" \ - || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - -top_distdir = .. -distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) - -distdir: $(DISTFILES) - @list='$(DISTFILES)'; for file in $$list; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkinstalldirs) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d $(distdir)/$$subdir \ - || mkdir $(distdir)/$$subdir \ - || exit 1; \ - (cd $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" \ - distdir=../$(distdir)/$$subdir \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: - -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -distclean-am: clean-am distclean-generic distclean-libtool \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-exec-am: - -install-info: install-info-recursive - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -uninstall-am: uninstall-info-am - -uninstall-info: uninstall-info-recursive - -.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ - clean-generic clean-libtool clean-recursive distclean \ - distclean-generic distclean-libtool distclean-recursive \ - distclean-tags distdir dvi dvi-am dvi-recursive info info-am \ - info-recursive install install-am install-data install-data-am \ - install-data-recursive install-exec install-exec-am \ - install-exec-recursive install-info install-info-am \ - install-info-recursive install-man install-recursive \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am installdirs-recursive maintainer-clean \ - maintainer-clean-generic maintainer-clean-recursive mostlyclean \ - mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ - tags tags-recursive uninstall uninstall-am uninstall-info-am \ - uninstall-info-recursive uninstall-recursive - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/Engine/lib/libtheora/include/theora/Makefile.am b/Engine/lib/libtheora/include/theora/Makefile.am deleted file mode 100644 index 5479e82a5..000000000 --- a/Engine/lib/libtheora/include/theora/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -## Process this file with automake to produce Makefile.in - -theoraincludedir = $(includedir)/theora - -theorainclude_HEADERS = theora.h theoradec.h theoraenc.h codec.h - -noinst_HEADERS = codec.h theoradec.h diff --git a/Engine/lib/libtheora/include/theora/Makefile.in b/Engine/lib/libtheora/include/theora/Makefile.in deleted file mode 100644 index d20e60ab4..000000000 --- a/Engine/lib/libtheora/include/theora/Makefile.in +++ /dev/null @@ -1,355 +0,0 @@ -# Makefile.in generated by automake 1.6.3 from Makefile.am. -# @configure_input@ - -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 -# Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = ../.. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_HEADER = $(INSTALL_DATA) -transform = @program_transform_name@ -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_alias = @host_alias@ -host_triplet = @host@ - -EXEEXT = @EXEEXT@ -OBJEXT = @OBJEXT@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ -AMTAR = @AMTAR@ -AR = @AR@ -ARGZ_H = @ARGZ_H@ -AS = @AS@ -AWK = @AWK@ -BUILDABLE_EXAMPLES = @BUILDABLE_EXAMPLES@ -CAIRO_CFLAGS = @CAIRO_CFLAGS@ -CAIRO_LIBS = @CAIRO_LIBS@ -CC = @CC@ -CPP = @CPP@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -DEBUG = @DEBUG@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -F77 = @F77@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ -GETOPT_OBJS = @GETOPT_OBJS@ -GREP = @GREP@ -HAVE_BIBTEX = @HAVE_BIBTEX@ -HAVE_DOXYGEN = @HAVE_DOXYGEN@ -HAVE_PDFLATEX = @HAVE_PDFLATEX@ -HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@ -HAVE_TRANSFIG = @HAVE_TRANSFIG@ -HAVE_VALGRIND = @HAVE_VALGRIND@ -INCLTDL = @INCLTDL@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LIBADD_DL = @LIBADD_DL@ -LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ -LIBADD_DLOPEN = @LIBADD_DLOPEN@ -LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ -LIBLTDL = @LIBLTDL@ -LIBM = @LIBM@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTDLDEPS = @LTDLDEPS@ -LTDLINCL = @LTDLINCL@ -LTDLOPEN = @LTDLOPEN@ -LT_CONFIG_H = @LT_CONFIG_H@ -LT_DLLOADERS = @LT_DLLOADERS@ -LT_DLPREOPEN = @LT_DLPREOPEN@ -MAINT = @MAINT@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OGG_CFLAGS = @OGG_CFLAGS@ -OGG_LIBS = @OGG_LIBS@ -OSS_LIBS = @OSS_LIBS@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PKG_CONFIG = @PKG_CONFIG@ -PNG_CFLAGS = @PNG_CFLAGS@ -PNG_LIBS = @PNG_LIBS@ -PROFILE = @PROFILE@ -RANLIB = @RANLIB@ -RC = @RC@ -SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ -SDL_LIBS = @SDL_LIBS@ -SED = @SED@ -STRIP = @STRIP@ -THDEC_LIB_AGE = @THDEC_LIB_AGE@ -THDEC_LIB_CURRENT = @THDEC_LIB_CURRENT@ -THDEC_LIB_REVISION = @THDEC_LIB_REVISION@ -THENC_LIB_AGE = @THENC_LIB_AGE@ -THENC_LIB_CURRENT = @THENC_LIB_CURRENT@ -THENC_LIB_REVISION = @THENC_LIB_REVISION@ -THEORADEC_LDFLAGS = @THEORADEC_LDFLAGS@ -THEORAENC_LDFLAGS = @THEORAENC_LDFLAGS@ -THEORA_LDFLAGS = @THEORA_LDFLAGS@ -TH_LIB_AGE = @TH_LIB_AGE@ -TH_LIB_CURRENT = @TH_LIB_CURRENT@ -TH_LIB_REVISION = @TH_LIB_REVISION@ -VALGRIND_ENVIRONMENT = @VALGRIND_ENVIRONMENT@ -VERSION = @VERSION@ -VORBISENC_LIBS = @VORBISENC_LIBS@ -VORBISFILE_LIBS = @VORBISFILE_LIBS@ -VORBIS_CFLAGS = @VORBIS_CFLAGS@ -VORBIS_LIBS = @VORBIS_LIBS@ -am__include = @am__include@ -am__quote = @am__quote@ -install_sh = @install_sh@ -lt_ECHO = @lt_ECHO@ -ltdl_LIBOBJS = @ltdl_LIBOBJS@ -ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ -sys_symbol_underscore = @sys_symbol_underscore@ - -theoraincludedir = $(includedir)/theora - -theorainclude_HEADERS = theora.h theoradec.h theoraenc.h codec.h - -noinst_HEADERS = codec.h theoradec.h -subdir = include/theora -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -DIST_SOURCES = -HEADERS = $(noinst_HEADERS) $(theorainclude_HEADERS) - -DIST_COMMON = $(noinst_HEADERS) $(theorainclude_HEADERS) Makefile.am \ - Makefile.in -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu include/theora/Makefile -Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: -theoraincludeHEADERS_INSTALL = $(INSTALL_HEADER) -install-theoraincludeHEADERS: $(theorainclude_HEADERS) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(theoraincludedir) - @list='$(theorainclude_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(theoraincludeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(theoraincludedir)/$$f"; \ - $(theoraincludeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(theoraincludedir)/$$f; \ - done - -uninstall-theoraincludeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(theorainclude_HEADERS)'; for p in $$list; do \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " rm -f $(DESTDIR)$(theoraincludedir)/$$f"; \ - rm -f $(DESTDIR)$(theoraincludedir)/$$f; \ - done - -ETAGS = etags -ETAGSFLAGS = - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$tags$$unique" \ - || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - -top_distdir = ../.. -distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) - -distdir: $(DISTFILES) - @list='$(DISTFILES)'; for file in $$list; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkinstalldirs) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(HEADERS) - -installdirs: - $(mkinstalldirs) $(DESTDIR)$(theoraincludedir) - -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -distclean-am: clean-am distclean-generic distclean-libtool \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -info: info-am - -info-am: - -install-data-am: install-theoraincludeHEADERS - -install-exec-am: - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -uninstall-am: uninstall-info-am uninstall-theoraincludeHEADERS - -.PHONY: GTAGS all all-am check check-am clean clean-generic \ - clean-libtool distclean distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am info info-am install \ - install-am install-data install-data-am install-exec \ - install-exec-am install-info install-info-am install-man \ - install-strip install-theoraincludeHEADERS installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool tags uninstall uninstall-am \ - uninstall-info-am uninstall-theoraincludeHEADERS - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/Engine/lib/libtheora/include/theora/codec.h b/Engine/lib/libtheora/include/theora/codec.h deleted file mode 100644 index 5c2669630..000000000 --- a/Engine/lib/libtheora/include/theora/codec.h +++ /dev/null @@ -1,591 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $ - - ********************************************************************/ - -/**\mainpage - * - * \section intro Introduction - * - * This is the documentation for libtheora C API. - * The current reference - * implementation for Theora, a free, - * patent-unencumbered video codec. - * Theora is derived from On2's VP3 codec with additional features and - * integration with Ogg multimedia formats by - * the Xiph.Org Foundation. - * Complete documentation of the format itself is available in - * the Theora - * specification. - * - * \subsection Organization - * - * The functions documented here are actually subdivided into three - * separate libraries: - * - libtheoraenc contains the encoder interface, - * described in \ref encfuncs. - * - libtheoradec contains the decoder interface and - * routines shared with the encoder. - * You must also link to this if you link to libtheoraenc. - * The routines in this library are described in \ref decfuncs and - * \ref basefuncs. - * - libtheora contains the \ref oldfuncs. - * - * New code should link to libtheoradec and, if using encoder - * features, libtheoraenc. Together these two export both - * the standard and the legacy API, so this is all that is needed by - * any code. The older libtheora library is provided just for - * compatibility with older build configurations. - * - * In general the recommended 1.x API symbols can be distinguished - * by their th_ or TH_ namespace prefix. - * The older, legacy API uses theora_ or OC_ - * prefixes instead. - */ - -/**\file - * The shared libtheoradec and libtheoraenc C API. - * You don't need to include this directly.*/ - -#if !defined(_O_THEORA_CODEC_H_) -# define _O_THEORA_CODEC_H_ (1) -# include - -#if defined(__cplusplus) -extern "C" { -#endif - - - -/**\name Return codes*/ -/*@{*/ -/**An invalid pointer was provided.*/ -#define TH_EFAULT (-1) -/**An invalid argument was provided.*/ -#define TH_EINVAL (-10) -/**The contents of the header were incomplete, invalid, or unexpected.*/ -#define TH_EBADHEADER (-20) -/**The header does not belong to a Theora stream.*/ -#define TH_ENOTFORMAT (-21) -/**The bitstream version is too high.*/ -#define TH_EVERSION (-22) -/**The specified function is not implemented.*/ -#define TH_EIMPL (-23) -/**There were errors in the video data packet.*/ -#define TH_EBADPACKET (-24) -/**The decoded packet represented a dropped frame. - The player can continue to display the current frame, as the contents of the - decoded frame buffer have not changed.*/ -#define TH_DUPFRAME (1) -/*@}*/ - -/**The currently defined color space tags. - * See the Theora - * specification, Chapter 4, for exact details on the meaning - * of each of these color spaces.*/ -typedef enum{ - /**The color space was not specified at the encoder. - It may be conveyed by an external means.*/ - TH_CS_UNSPECIFIED, - /**A color space designed for NTSC content.*/ - TH_CS_ITU_REC_470M, - /**A color space designed for PAL/SECAM content.*/ - TH_CS_ITU_REC_470BG, - /**The total number of currently defined color spaces.*/ - TH_CS_NSPACES -}th_colorspace; - -/**The currently defined pixel format tags. - * See the Theora - * specification, Section 4.4, for details on the precise sample - * locations.*/ -typedef enum{ - /**Chroma decimation by 2 in both the X and Y directions (4:2:0). - The Cb and Cr chroma planes are half the width and half the - height of the luma plane.*/ - TH_PF_420, - /**Currently reserved.*/ - TH_PF_RSVD, - /**Chroma decimation by 2 in the X direction (4:2:2). - The Cb and Cr chroma planes are half the width of the luma plane, but full - height.*/ - TH_PF_422, - /**No chroma decimation (4:4:4). - The Cb and Cr chroma planes are full width and full height.*/ - TH_PF_444, - /**The total number of currently defined pixel formats.*/ - TH_PF_NFORMATS -}th_pixel_fmt; - - - -/**A buffer for a single color plane in an uncompressed image. - * This contains the image data in a left-to-right, top-down format. - * Each row of pixels is stored contiguously in memory, but successive - * rows need not be. - * Use \a stride to compute the offset of the next row. - * The encoder accepts both positive \a stride values (top-down in memory) - * and negative (bottom-up in memory). - * The decoder currently always generates images with positive strides.*/ -typedef struct{ - /**The width of this plane.*/ - int width; - /**The height of this plane.*/ - int height; - /**The offset in bytes between successive rows.*/ - int stride; - /**A pointer to the beginning of the first row.*/ - unsigned char *data; -}th_img_plane; - -/**A complete image buffer for an uncompressed frame. - * The chroma planes may be decimated by a factor of two in either - * direction, as indicated by th_info#pixel_fmt. - * The width and height of the Y' plane must be multiples of 16. - * They may need to be cropped for display, using the rectangle - * specified by th_info#pic_x, th_info#pic_y, th_info#pic_width, - * and th_info#pic_height. - * All samples are 8 bits. - * \note The term YUV often used to describe a colorspace is ambiguous. - * The exact parameters of the RGB to YUV conversion process aside, in - * many contexts the U and V channels actually have opposite meanings. - * To avoid this confusion, we are explicit: the name of the color - * channels are Y'CbCr, and they appear in that order, always. - * The prime symbol denotes that the Y channel is non-linear. - * Cb and Cr stand for "Chroma blue" and "Chroma red", respectively.*/ -typedef th_img_plane th_ycbcr_buffer[3]; - -/**Theora bitstream information. - * This contains the basic playback parameters for a stream, and corresponds to - * the initial 'info' header packet. - * To initialize an encoder, the application fills in this structure and - * passes it to th_encode_alloc(). - * A default encoding mode is chosen based on the values of the #quality and - * #target_bitrate fields. - * On decode, it is filled in by th_decode_headerin(), and then passed to - * th_decode_alloc(). - * - * Encoded Theora frames must be a multiple of 16 in size; - * this is what the #frame_width and #frame_height members represent. - * To handle arbitrary picture sizes, a crop rectangle is specified in the - * #pic_x, #pic_y, #pic_width and #pic_height members. - * - * All frame buffers contain pointers to the full, padded frame. - * However, the current encoder will not reference pixels outside of - * the cropped picture region, and the application does not need to fill them - * in. - * The decoder will allocate storage for a full frame, but the - * application should not rely on the padding containing sensible - * data. - * - * It is also generally recommended that the offsets and sizes should still be - * multiples of 2 to avoid chroma sampling shifts when chroma is sub-sampled. - * See the Theora - * specification, Section 4.4, for more details. - * - * Frame rate, in frames per second, is stored as a rational fraction, as is - * the pixel aspect ratio. - * Note that this refers to the aspect ratio of the individual pixels, not of - * the overall frame itself. - * The frame aspect ratio can be computed from pixel aspect ratio using the - * image dimensions.*/ -typedef struct{ - /**\name Theora version - * Bitstream version information.*/ - /*@{*/ - unsigned char version_major; - unsigned char version_minor; - unsigned char version_subminor; - /*@}*/ - /**The encoded frame width. - * This must be a multiple of 16, and less than 1048576.*/ - ogg_uint32_t frame_width; - /**The encoded frame height. - * This must be a multiple of 16, and less than 1048576.*/ - ogg_uint32_t frame_height; - /**The displayed picture width. - * This must be no larger than width.*/ - ogg_uint32_t pic_width; - /**The displayed picture height. - * This must be no larger than height.*/ - ogg_uint32_t pic_height; - /**The X offset of the displayed picture. - * This must be no larger than #frame_width-#pic_width or 255, whichever is - * smaller.*/ - ogg_uint32_t pic_x; - /**The Y offset of the displayed picture. - * This must be no larger than #frame_height-#pic_height, and - * #frame_height-#pic_height-#pic_y must be no larger than 255. - * This slightly funny restriction is due to the fact that the offset is - * specified from the top of the image for consistency with the standard - * graphics left-handed coordinate system used throughout this API, while - * it is stored in the encoded stream as an offset from the bottom.*/ - ogg_uint32_t pic_y; - /**\name Frame rate - * The frame rate, as a fraction. - * If either is 0, the frame rate is undefined.*/ - /*@{*/ - ogg_uint32_t fps_numerator; - ogg_uint32_t fps_denominator; - /*@}*/ - /**\name Aspect ratio - * The aspect ratio of the pixels. - * If either value is zero, the aspect ratio is undefined. - * If not specified by any external means, 1:1 should be assumed. - * The aspect ratio of the full picture can be computed as - * \code - * aspect_numerator*pic_width/(aspect_denominator*pic_height). - * \endcode */ - /*@{*/ - ogg_uint32_t aspect_numerator; - ogg_uint32_t aspect_denominator; - /*@}*/ - /**The color space.*/ - th_colorspace colorspace; - /**The pixel format.*/ - th_pixel_fmt pixel_fmt; - /**The target bit-rate in bits per second. - If initializing an encoder with this struct, set this field to a non-zero - value to activate CBR encoding by default.*/ - int target_bitrate; - /**The target quality level. - Valid values range from 0 to 63, inclusive, with higher values giving - higher quality. - If initializing an encoder with this struct, and #target_bitrate is set - to zero, VBR encoding at this quality will be activated by default.*/ - /*Currently this is set so that a qi of 0 corresponds to distortions of 24 - times the JND, and each increase by 16 halves that value. - This gives us fine discrimination at low qualities, yet effective rate - control at high qualities. - The qi value 63 is special, however. - For this, the highest quality, we use one half of a JND for our threshold. - Due to the lower bounds placed on allowable quantizers in Theora, we will - not actually be able to achieve quality this good, but this should - provide as close to visually lossless quality as Theora is capable of. - We could lift the quantizer restrictions without breaking VP3.1 - compatibility, but this would result in quantized coefficients that are - too large for the current bitstream to be able to store. - We'd have to redesign the token syntax to store these large coefficients, - which would make transcoding complex.*/ - int quality; - /**The amount to shift to extract the last keyframe number from the granule - * position. - * This can be at most 31. - * th_info_init() will set this to a default value (currently 6, - * which is good for streaming applications), but you can set it to 0 to - * make every frame a keyframe. - * The maximum distance between key frames is - * 1<<#keyframe_granule_shift. - * The keyframe frequency can be more finely controlled with - * #TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE, which can also be adjusted - * during encoding (for example, to force the next frame to be a keyframe), - * but it cannot be set larger than the amount permitted by this field after - * the headers have been output.*/ - int keyframe_granule_shift; -}th_info; - -/**The comment information. - * - * This structure holds the in-stream metadata corresponding to - * the 'comment' header packet. - * The comment header is meant to be used much like someone jotting a quick - * note on the label of a video. - * It should be a short, to the point text note that can be more than a couple - * words, but not more than a short paragraph. - * - * The metadata is stored as a series of (tag, value) pairs, in - * length-encoded string vectors. - * The first occurrence of the '=' character delimits the tag and value. - * A particular tag may occur more than once, and order is significant. - * The character set encoding for the strings is always UTF-8, but the tag - * names are limited to ASCII, and treated as case-insensitive. - * See the Theora - * specification, Section 6.3.3 for details. - * - * In filling in this structure, th_decode_headerin() will null-terminate - * the user_comment strings for safety. - * However, the bitstream format itself treats them as 8-bit clean vectors, - * possibly containing null characters, and so the length array should be - * treated as their authoritative length. - */ -typedef struct th_comment{ - /**The array of comment string vectors.*/ - char **user_comments; - /**An array of the corresponding length of each vector, in bytes.*/ - int *comment_lengths; - /**The total number of comment strings.*/ - int comments; - /**The null-terminated vendor string. - This identifies the software used to encode the stream.*/ - char *vendor; -}th_comment; - - - -/**A single base matrix.*/ -typedef unsigned char th_quant_base[64]; - -/**A set of \a qi ranges.*/ -typedef struct{ - /**The number of ranges in the set.*/ - int nranges; - /**The size of each of the #nranges ranges. - These must sum to 63.*/ - const int *sizes; - /**#nranges +1 base matrices. - Matrices \a i and i+1 form the endpoints of range \a i.*/ - const th_quant_base *base_matrices; -}th_quant_ranges; - -/**A complete set of quantization parameters. - The quantizer for each coefficient is calculated as: - \code - Q=MAX(MIN(qmin[qti][ci!=0],scale[ci!=0][qi]*base[qti][pli][qi][ci]/100), - 1024). - \endcode - - \a qti is the quantization type index: 0 for intra, 1 for inter. - ci!=0 is 0 for the DC coefficient and 1 for AC coefficients. - \a qi is the quality index, ranging between 0 (low quality) and 63 (high - quality). - \a pli is the color plane index: 0 for Y', 1 for Cb, 2 for Cr. - \a ci is the DCT coefficient index. - Coefficient indices correspond to the normal 2D DCT block - ordering--row-major with low frequencies first--\em not zig-zag order. - - Minimum quantizers are constant, and are given by: - \code - qmin[2][2]={{4,2},{8,4}}. - \endcode - - Parameters that can be stored in the bitstream are as follows: - - The two scale matrices ac_scale and dc_scale. - \code - scale[2][64]={dc_scale,ac_scale}. - \endcode - - The base matrices for each \a qi, \a qti and \a pli (up to 384 in all). - In order to avoid storing a full 384 base matrices, only a sparse set of - matrices are stored, and the rest are linearly interpolated. - This is done as follows. - For each \a qti and \a pli, a series of \a n \a qi ranges is defined. - The size of each \a qi range can vary arbitrarily, but they must sum to - 63. - Then, n+1 matrices are specified, one for each endpoint of the - ranges. - For interpolation purposes, each range's endpoints are the first \a qi - value it contains and one past the last \a qi value it contains. - Fractional values are rounded to the nearest integer, with ties rounded - away from zero. - - Base matrices are stored by reference, so if the same matrices are used - multiple times, they will only appear once in the bitstream. - The bitstream is also capable of omitting an entire set of ranges and - its associated matrices if they are the same as either the previous - set (indexed in row-major order) or if the inter set is the same as the - intra set. - - - Loop filter limit values. - The same limits are used for the loop filter in all color planes, despite - potentially differing levels of quantization in each. - - For the current encoder, scale[ci!=0][qi] must be no greater - than scale[ci!=0][qi-1] and base[qti][pli][qi][ci] must - be no greater than base[qti][pli][qi-1][ci]. - These two conditions ensure that the actual quantizer for a given \a qti, - \a pli, and \a ci does not increase as \a qi increases. - This is not required by the decoder.*/ -typedef struct{ - /**The DC scaling factors.*/ - ogg_uint16_t dc_scale[64]; - /**The AC scaling factors.*/ - ogg_uint16_t ac_scale[64]; - /**The loop filter limit values.*/ - unsigned char loop_filter_limits[64]; - /**The \a qi ranges for each \a ci and \a pli.*/ - th_quant_ranges qi_ranges[2][3]; -}th_quant_info; - - - -/**The number of Huffman tables used by Theora.*/ -#define TH_NHUFFMAN_TABLES (80) -/**The number of DCT token values in each table.*/ -#define TH_NDCT_TOKENS (32) - -/**A Huffman code for a Theora DCT token. - * Each set of Huffman codes in a given table must form a complete, prefix-free - * code. - * There is no requirement that all the tokens in a table have a valid code, - * but the current encoder is not optimized to take advantage of this. - * If each of the five grouops of 16 tables does not contain at least one table - * with a code for every token, then the encoder may fail to encode certain - * frames. - * The complete table in the first group of 16 does not have to be in the same - * place as the complete table in the other groups, but the complete tables in - * the remaining four groups must all be in the same place.*/ -typedef struct{ - /**The bit pattern for the code, with the LSbit of the pattern aligned in - * the LSbit of the word.*/ - ogg_uint32_t pattern; - /**The number of bits in the code. - * This must be between 0 and 32, inclusive.*/ - int nbits; -}th_huff_code; - - - -/**\defgroup basefuncs Functions Shared by Encode and Decode*/ -/*@{*/ -/**\name Basic shared functions*/ -/*@{*/ -/**Retrieves a human-readable string to identify the library vendor and - * version. - * \return the version string.*/ -extern const char *th_version_string(void); -/**Retrieves the library version number. - * This is the highest bitstream version that the encoder library will produce, - * or that the decoder library can decode. - * This number is composed of a 16-bit major version, 8-bit minor version - * and 8 bit sub-version, composed as follows: - * \code - * (VERSION_MAJOR<<16)+(VERSION_MINOR<<8)+(VERSION_SUBMINOR) - * \endcode - * \return the version number.*/ -extern ogg_uint32_t th_version_number(void); -/**Converts a granule position to an absolute frame index, starting at - * 0. - * The granule position is interpreted in the context of a given - * #th_enc_ctx or #th_dec_ctx handle (either will suffice). - * \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx - * handle. - * \param _granpos The granule position to convert. - * \returns The absolute frame index corresponding to \a _granpos. - * \retval -1 The given granule position was invalid (i.e. negative).*/ -extern ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos); -/**Converts a granule position to an absolute time in seconds. - * The granule position is interpreted in the context of a given - * #th_enc_ctx or #th_dec_ctx handle (either will suffice). - * \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx - * handle. - * \param _granpos The granule position to convert. - * \return The absolute time in seconds corresponding to \a _granpos. - * This is the "end time" for the frame, or the latest time it should - * be displayed. - * It is not the presentation time. - * \retval -1 The given granule position was invalid (i.e. negative).*/ -extern double th_granule_time(void *_encdec,ogg_int64_t _granpos); -/**Determines whether a Theora packet is a header or not. - * This function does no verification beyond checking the packet type bit, so - * it should not be used for bitstream identification; use - * th_decode_headerin() for that. - * As per the Theora specification, an empty (0-byte) packet is treated as a - * data packet (a delta frame with no coded blocks). - * \param _op An ogg_packet containing encoded Theora data. - * \retval 1 The packet is a header packet - * \retval 0 The packet is a video data packet.*/ -extern int th_packet_isheader(ogg_packet *_op); -/**Determines whether a theora packet is a key frame or not. - * This function does no verification beyond checking the packet type and - * key frame bits, so it should not be used for bitstream identification; use - * th_decode_headerin() for that. - * As per the Theora specification, an empty (0-byte) packet is treated as a - * delta frame (with no coded blocks). - * \param _op An ogg_packet containing encoded Theora data. - * \retval 1 The packet contains a key frame. - * \retval 0 The packet contains a delta frame. - * \retval -1 The packet is not a video data packet.*/ -extern int th_packet_iskeyframe(ogg_packet *_op); -/*@}*/ - - -/**\name Functions for manipulating header data*/ -/*@{*/ -/**Initializes a th_info structure. - * This should be called on a freshly allocated #th_info structure before - * attempting to use it. - * \param _info The #th_info struct to initialize.*/ -extern void th_info_init(th_info *_info); -/**Clears a #th_info structure. - * This should be called on a #th_info structure after it is no longer - * needed. - * \param _info The #th_info struct to clear.*/ -extern void th_info_clear(th_info *_info); - -/**Initialize a #th_comment structure. - * This should be called on a freshly allocated #th_comment structure - * before attempting to use it. - * \param _tc The #th_comment struct to initialize.*/ -extern void th_comment_init(th_comment *_tc); -/**Add a comment to an initialized #th_comment structure. - * \note Neither th_comment_add() nor th_comment_add_tag() support - * comments containing null values, although the bitstream format does - * support them. - * To add such comments you will need to manipulate the #th_comment - * structure directly. - * \param _tc The #th_comment struct to add the comment to. - * \param _comment Must be a null-terminated UTF-8 string containing the - * comment in "TAG=the value" form.*/ -extern void th_comment_add(th_comment *_tc, char *_comment); -/**Add a comment to an initialized #th_comment structure. - * \note Neither th_comment_add() nor th_comment_add_tag() support - * comments containing null values, although the bitstream format does - * support them. - * To add such comments you will need to manipulate the #th_comment - * structure directly. - * \param _tc The #th_comment struct to add the comment to. - * \param _tag A null-terminated string containing the tag associated with - * the comment. - * \param _val The corresponding value as a null-terminated string.*/ -extern void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val); -/**Look up a comment value by its tag. - * \param _tc An initialized #th_comment structure. - * \param _tag The tag to look up. - * \param _count The instance of the tag. - * The same tag can appear multiple times, each with a distinct - * value, so an index is required to retrieve them all. - * The order in which these values appear is significant and - * should be preserved. - * Use th_comment_query_count() to get the legal range for - * the \a _count parameter. - * \return A pointer to the queried tag's value. - * This points directly to data in the #th_comment structure. - * It should not be modified or freed by the application, and - * modifications to the structure may invalidate the pointer. - * \retval NULL If no matching tag is found.*/ -extern char *th_comment_query(th_comment *_tc,char *_tag,int _count); -/**Look up the number of instances of a tag. - * Call this first when querying for a specific tag and then iterate over the - * number of instances with separate calls to th_comment_query() to - * retrieve all the values for that tag in order. - * \param _tc An initialized #th_comment structure. - * \param _tag The tag to look up. - * \return The number on instances of this particular tag.*/ -extern int th_comment_query_count(th_comment *_tc,char *_tag); -/**Clears a #th_comment structure. - * This should be called on a #th_comment structure after it is no longer - * needed. - * It will free all memory used by the structure members. - * \param _tc The #th_comment struct to clear.*/ -extern void th_comment_clear(th_comment *_tc); -/*@}*/ -/*@}*/ - - - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/Engine/lib/libtheora/include/theora/theora.h b/Engine/lib/libtheora/include/theora/theora.h deleted file mode 100644 index af6eb6f38..000000000 --- a/Engine/lib/libtheora/include/theora/theora.h +++ /dev/null @@ -1,784 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: theora.h,v 1.17 2003/12/06 18:06:19 arc Exp $ - - ********************************************************************/ - -#ifndef _O_THEORA_H_ -#define _O_THEORA_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include /* for size_t */ - -#include - -/** \file - * The libtheora pre-1.0 legacy C API. - * - * \ingroup oldfuncs - * - * \section intro Introduction - * - * This is the documentation for the libtheora legacy C API, declared in - * the theora.h header, which describes the old interface used before - * the 1.0 release. This API was widely deployed for several years and - * remains supported, but for new code we recommend the cleaner API - * declared in theoradec.h and theoraenc.h. - * - * libtheora is the reference implementation for - * Theora, a free video codec. - * Theora is derived from On2's VP3 codec with improved integration with - * Ogg multimedia formats by Xiph.Org. - * - * \section overview Overview - * - * This library will both decode and encode theora packets to/from raw YUV - * frames. In either case, the packets will most likely either come from or - * need to be embedded in an Ogg stream. Use - * libogg or - * liboggz - * to extract/package these packets. - * - * \section decoding Decoding Process - * - * Decoding can be separated into the following steps: - * -# initialise theora_info and theora_comment structures using - * theora_info_init() and theora_comment_init(): - \verbatim - theora_info info; - theora_comment comment; - - theora_info_init(&info); - theora_comment_init(&comment); - \endverbatim - * -# retrieve header packets from Ogg stream (there should be 3) and decode - * into theora_info and theora_comment structures using - * theora_decode_header(). See \ref identification for more information on - * identifying which packets are theora packets. - \verbatim - int i; - for (i = 0; i < 3; i++) - { - (get a theora packet "op" from the Ogg stream) - theora_decode_header(&info, &comment, op); - } - \endverbatim - * -# initialise the decoder based on the information retrieved into the - * theora_info struct by theora_decode_header(). You will need a - * theora_state struct. - \verbatim - theora_state state; - - theora_decode_init(&state, &info); - \endverbatim - * -# pass in packets and retrieve decoded frames! See the yuv_buffer - * documentation for information on how to retrieve raw YUV data. - \verbatim - yuf_buffer buffer; - while (last packet was not e_o_s) { - (get a theora packet "op" from the Ogg stream) - theora_decode_packetin(&state, op); - theora_decode_YUVout(&state, &buffer); - } - \endverbatim - * - * - * \subsection identification Identifying Theora Packets - * - * All streams inside an Ogg file have a unique serial_no attached to the - * stream. Typically, you will want to - * - retrieve the serial_no for each b_o_s (beginning of stream) page - * encountered within the Ogg file; - * - test the first (only) packet on that page to determine if it is a theora - * packet; - * - once you have found a theora b_o_s page then use the retrieved serial_no - * to identify future packets belonging to the same theora stream. - * - * Note that you \e cannot use theora_packet_isheader() to determine if a - * packet is a theora packet or not, as this function does not perform any - * checking beyond whether a header bit is present. Instead, use the - * theora_decode_header() function and check the return value; or examine the - * header bytes at the beginning of the Ogg page. - */ - - -/** \defgroup oldfuncs Legacy pre-1.0 C API */ -/* @{ */ - -/** - * A YUV buffer for passing uncompressed frames to and from the codec. - * This holds a Y'CbCr frame in planar format. The CbCr planes can be - * subsampled and have their own separate dimensions and row stride - * offsets. Note that the strides may be negative in some - * configurations. For theora the width and height of the largest plane - * must be a multiple of 16. The actual meaningful picture size and - * offset are stored in the theora_info structure; frames returned by - * the decoder may need to be cropped for display. - * - * All samples are 8 bits. Within each plane samples are ordered by - * row from the top of the frame to the bottom. Within each row samples - * are ordered from left to right. - * - * During decode, the yuv_buffer struct is allocated by the user, but all - * fields (including luma and chroma pointers) are filled by the library. - * These pointers address library-internal memory and their contents should - * not be modified. - * - * Conversely, during encode the user allocates the struct and fills out all - * fields. The user also manages the data addressed by the luma and chroma - * pointers. See the encoder_example.c and dump_video.c example files in - * theora/examples/ for more information. - */ -typedef struct { - int y_width; /**< Width of the Y' luminance plane */ - int y_height; /**< Height of the luminance plane */ - int y_stride; /**< Offset in bytes between successive rows */ - - int uv_width; /**< Width of the Cb and Cr chroma planes */ - int uv_height; /**< Height of the chroma planes */ - int uv_stride; /**< Offset between successive chroma rows */ - unsigned char *y; /**< Pointer to start of luminance data */ - unsigned char *u; /**< Pointer to start of Cb data */ - unsigned char *v; /**< Pointer to start of Cr data */ - -} yuv_buffer; - -/** - * A Colorspace. - */ -typedef enum { - OC_CS_UNSPECIFIED, /**< The colorspace is unknown or unspecified */ - OC_CS_ITU_REC_470M, /**< This is the best option for 'NTSC' content */ - OC_CS_ITU_REC_470BG, /**< This is the best option for 'PAL' content */ - OC_CS_NSPACES /**< This marks the end of the defined colorspaces */ -} theora_colorspace; - -/** - * A Chroma subsampling - * - * These enumerate the available chroma subsampling options supported - * by the theora format. See Section 4.4 of the specification for - * exact definitions. - */ -typedef enum { - OC_PF_420, /**< Chroma subsampling by 2 in each direction (4:2:0) */ - OC_PF_RSVD, /**< Reserved value */ - OC_PF_422, /**< Horizonatal chroma subsampling by 2 (4:2:2) */ - OC_PF_444, /**< No chroma subsampling at all (4:4:4) */ -} theora_pixelformat; - -/** - * Theora bitstream info. - * Contains the basic playback parameters for a stream, - * corresponding to the initial 'info' header packet. - * - * Encoded theora frames must be a multiple of 16 in width and height. - * To handle other frame sizes, a crop rectangle is specified in - * frame_height and frame_width, offset_x and * offset_y. The offset - * and size should still be a multiple of 2 to avoid chroma sampling - * shifts. Offset values in this structure are measured from the - * upper left of the image. - * - * Frame rate, in frames per second, is stored as a rational - * fraction. Aspect ratio is also stored as a rational fraction, and - * refers to the aspect ratio of the frame pixels, not of the - * overall frame itself. - * - * See - * examples/encoder_example.c for usage examples of the - * other paramters and good default settings for the encoder parameters. - */ -typedef struct { - ogg_uint32_t width; /**< encoded frame width */ - ogg_uint32_t height; /**< encoded frame height */ - ogg_uint32_t frame_width; /**< display frame width */ - ogg_uint32_t frame_height; /**< display frame height */ - ogg_uint32_t offset_x; /**< horizontal offset of the displayed frame */ - ogg_uint32_t offset_y; /**< vertical offset of the displayed frame */ - ogg_uint32_t fps_numerator; /**< frame rate numerator **/ - ogg_uint32_t fps_denominator; /**< frame rate denominator **/ - ogg_uint32_t aspect_numerator; /**< pixel aspect ratio numerator */ - ogg_uint32_t aspect_denominator; /**< pixel aspect ratio denominator */ - theora_colorspace colorspace; /**< colorspace */ - int target_bitrate; /**< nominal bitrate in bits per second */ - int quality; /**< Nominal quality setting, 0-63 */ - int quick_p; /**< Quick encode/decode */ - - /* decode only */ - unsigned char version_major; - unsigned char version_minor; - unsigned char version_subminor; - - void *codec_setup; - - /* encode only */ - int dropframes_p; - int keyframe_auto_p; - ogg_uint32_t keyframe_frequency; - ogg_uint32_t keyframe_frequency_force; /* also used for decode init to - get granpos shift correct */ - ogg_uint32_t keyframe_data_target_bitrate; - ogg_int32_t keyframe_auto_threshold; - ogg_uint32_t keyframe_mindistance; - ogg_int32_t noise_sensitivity; - ogg_int32_t sharpness; - - theora_pixelformat pixelformat; /**< chroma subsampling mode to expect */ - -} theora_info; - -/** Codec internal state and context. - */ -typedef struct{ - theora_info *i; - ogg_int64_t granulepos; - - void *internal_encode; - void *internal_decode; - -} theora_state; - -/** - * Comment header metadata. - * - * This structure holds the in-stream metadata corresponding to - * the 'comment' header packet. - * - * Meta data is stored as a series of (tag, value) pairs, in - * length-encoded string vectors. The first occurence of the - * '=' character delimits the tag and value. A particular tag - * may occur more than once. The character set encoding for - * the strings is always UTF-8, but the tag names are limited - * to case-insensitive ASCII. See the spec for details. - * - * In filling in this structure, theora_decode_header() will - * null-terminate the user_comment strings for safety. However, - * the bitstream format itself treats them as 8-bit clean, - * and so the length array should be treated as authoritative - * for their length. - */ -typedef struct theora_comment{ - char **user_comments; /**< An array of comment string vectors */ - int *comment_lengths; /**< An array of corresponding string vector lengths in bytes */ - int comments; /**< The total number of comment string vectors */ - char *vendor; /**< The vendor string identifying the encoder, null terminated */ - -} theora_comment; - - -/**\name theora_control() codes */ -/* \anchor decctlcodes_old - * These are the available request codes for theora_control() - * when called with a decoder instance. - * By convention decoder control codes are odd, to distinguish - * them from \ref encctlcodes_old "encoder control codes" which - * are even. - * - * Note that since the 1.0 release, both the legacy and the final - * implementation accept all the same control codes, but only the - * final API declares the newer codes. - * - * Keep any experimental or vendor-specific values above \c 0x8000.*/ - -/*@{*/ - -/**Get the maximum post-processing level. - * The decoder supports a post-processing filter that can improve - * the appearance of the decoded images. This returns the highest - * level setting for this post-processor, corresponding to maximum - * improvement and computational expense. - */ -#define TH_DECCTL_GET_PPLEVEL_MAX (1) - -/**Set the post-processing level. - * Sets the level of post-processing to use when decoding the - * compressed stream. This must be a value between zero (off) - * and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX. - */ -#define TH_DECCTL_SET_PPLEVEL (3) - -/**Sets the maximum distance between key frames. - * This can be changed during an encode, but will be bounded by - * 1<. - * If it is set before encoding begins, th_info#keyframe_granule_shift will - * be enlarged appropriately. - * - * \param[in] buf ogg_uint32_t: The maximum distance between key - * frames. - * \param[out] buf ogg_uint32_t: The actual maximum distance set. - * \retval OC_FAULT \a theora_state or \a buf is NULL. - * \retval OC_EINVAL \a buf_sz is not sizeof(ogg_uint32_t). - * \retval OC_IMPL Not supported by this implementation.*/ -#define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4) - -/**Set the granule position. - * Call this after a seek, to update the internal granulepos - * in the decoder, to insure that subsequent frames are marked - * properly. If you track timestamps yourself and do not use - * the granule postion returned by the decoder, then you do - * not need to use this control. - */ -#define TH_DECCTL_SET_GRANPOS (5) - -/**\anchor encctlcodes_old */ - -/**Sets the quantization parameters to use. - * The parameters are copied, not stored by reference, so they can be freed - * after this call. - * NULL may be specified to revert to the default parameters. - * - * \param[in] buf #th_quant_info - * \retval OC_FAULT \a theora_state is NULL. - * \retval OC_EINVAL Encoding has already begun, the quantization parameters - * are not acceptable to this version of the encoder, - * \a buf is NULL and \a buf_sz is not zero, - * or \a buf is non-NULL and \a buf_sz is - * not sizeof(#th_quant_info). - * \retval OC_IMPL Not supported by this implementation.*/ -#define TH_ENCCTL_SET_QUANT_PARAMS (2) - -/**Disables any encoder features that would prevent lossless transcoding back - * to VP3. - * This primarily means disabling block-level QI values and not using 4MV mode - * when any of the luma blocks in a macro block are not coded. - * It also includes using the VP3 quantization tables and Huffman codes; if you - * set them explicitly after calling this function, the resulting stream will - * not be VP3-compatible. - * If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source - * material, or when using a picture region smaller than the full frame (e.g. - * a non-multiple-of-16 width or height), then non-VP3 bitstream features will - * still be disabled, but the stream will still not be VP3-compatible, as VP3 - * was not capable of encoding such formats. - * If you call this after encoding has already begun, then the quantization - * tables and codebooks cannot be changed, but the frame-level features will - * be enabled or disabled as requested. - * - * \param[in] buf int: a non-zero value to enable VP3 compatibility, - * or 0 to disable it (the default). - * \param[out] buf int: 1 if all bitstream features required for - * VP3-compatibility could be set, and 0 otherwise. - * The latter will be returned if the pixel format is not - * 4:2:0, the picture region is smaller than the full frame, - * or if encoding has begun, preventing the quantization - * tables and codebooks from being set. - * \retval OC_FAULT \a theora_state or \a buf is NULL. - * \retval OC_EINVAL \a buf_sz is not sizeof(int). - * \retval OC_IMPL Not supported by this implementation.*/ -#define TH_ENCCTL_SET_VP3_COMPATIBLE (10) - -/**Gets the maximum speed level. - * Higher speed levels favor quicker encoding over better quality per bit. - * Depending on the encoding mode, and the internal algorithms used, quality - * may actually improve, but in this case bitrate will also likely increase. - * In any case, overall rate/distortion performance will probably decrease. - * The maximum value, and the meaning of each value, may change depending on - * the current encoding mode (VBR vs. CQI, etc.). - * - * \param[out] buf int: The maximum encoding speed level. - * \retval OC_FAULT \a theora_state or \a buf is NULL. - * \retval OC_EINVAL \a buf_sz is not sizeof(int). - * \retval OC_IMPL Not supported by this implementation in the current - * encoding mode.*/ -#define TH_ENCCTL_GET_SPLEVEL_MAX (12) - -/**Sets the speed level. - * By default a speed value of 1 is used. - * - * \param[in] buf int: The new encoding speed level. - * 0 is slowest, larger values use less CPU. - * \retval OC_FAULT \a theora_state or \a buf is NULL. - * \retval OC_EINVAL \a buf_sz is not sizeof(int), or the - * encoding speed level is out of bounds. - * The maximum encoding speed level may be - * implementation- and encoding mode-specific, and can be - * obtained via #TH_ENCCTL_GET_SPLEVEL_MAX. - * \retval OC_IMPL Not supported by this implementation in the current - * encoding mode.*/ -#define TH_ENCCTL_SET_SPLEVEL (14) - -/*@}*/ - -#define OC_FAULT -1 /**< General failure */ -#define OC_EINVAL -10 /**< Library encountered invalid internal data */ -#define OC_DISABLED -11 /**< Requested action is disabled */ -#define OC_BADHEADER -20 /**< Header packet was corrupt/invalid */ -#define OC_NOTFORMAT -21 /**< Packet is not a theora packet */ -#define OC_VERSION -22 /**< Bitstream version is not handled */ -#define OC_IMPL -23 /**< Feature or action not implemented */ -#define OC_BADPACKET -24 /**< Packet is corrupt */ -#define OC_NEWPACKET -25 /**< Packet is an (ignorable) unhandled extension */ -#define OC_DUPFRAME 1 /**< Packet is a dropped frame */ - -/** - * Retrieve a human-readable string to identify the encoder vendor and version. - * \returns A version string. - */ -extern const char *theora_version_string(void); - -/** - * Retrieve a 32-bit version number. - * This number is composed of a 16-bit major version, 8-bit minor version - * and 8 bit sub-version, composed as follows: -
    -   (VERSION_MAJOR<<16) + (VERSION_MINOR<<8) + (VERSION_SUB)
    -
    -* \returns The version number. -*/ -extern ogg_uint32_t theora_version_number(void); - -/** - * Initialize the theora encoder. - * \param th The theora_state handle to initialize for encoding. - * \param ti A theora_info struct filled with the desired encoding parameters. - * \retval 0 Success - */ -extern int theora_encode_init(theora_state *th, theora_info *ti); - -/** - * Submit a YUV buffer to the theora encoder. - * \param t A theora_state handle previously initialized for encoding. - * \param yuv A buffer of YUV data to encode. Note that both the yuv_buffer - * struct and the luma/chroma buffers within should be allocated by - * the user. - * \retval OC_EINVAL Encoder is not ready, or is finished. - * \retval -1 The size of the given frame differs from those previously input - * \retval 0 Success - */ -extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv); - -/** - * Request the next packet of encoded video. - * The encoded data is placed in a user-provided ogg_packet structure. - * \param t A theora_state handle previously initialized for encoding. - * \param last_p whether this is the last packet the encoder should produce. - * \param op An ogg_packet structure to fill. libtheora will set all - * elements of this structure, including a pointer to encoded - * data. The memory for the encoded data is owned by libtheora. - * \retval 0 No internal storage exists OR no packet is ready - * \retval -1 The encoding process has completed - * \retval 1 Success - */ -extern int theora_encode_packetout( theora_state *t, int last_p, - ogg_packet *op); - -/** - * Request a packet containing the initial header. - * A pointer to the header data is placed in a user-provided ogg_packet - * structure. - * \param t A theora_state handle previously initialized for encoding. - * \param op An ogg_packet structure to fill. libtheora will set all - * elements of this structure, including a pointer to the header - * data. The memory for the header data is owned by libtheora. - * \retval 0 Success - */ -extern int theora_encode_header(theora_state *t, ogg_packet *op); - -/** - * Request a comment header packet from provided metadata. - * A pointer to the comment data is placed in a user-provided ogg_packet - * structure. - * \param tc A theora_comment structure filled with the desired metadata - * \param op An ogg_packet structure to fill. libtheora will set all - * elements of this structure, including a pointer to the encoded - * comment data. The memory for the comment data is owned by - * libtheora. - * \retval 0 Success - */ -extern int theora_encode_comment(theora_comment *tc, ogg_packet *op); - -/** - * Request a packet containing the codebook tables for the stream. - * A pointer to the codebook data is placed in a user-provided ogg_packet - * structure. - * \param t A theora_state handle previously initialized for encoding. - * \param op An ogg_packet structure to fill. libtheora will set all - * elements of this structure, including a pointer to the codebook - * data. The memory for the header data is owned by libtheora. - * \retval 0 Success - */ -extern int theora_encode_tables(theora_state *t, ogg_packet *op); - -/** - * Decode an Ogg packet, with the expectation that the packet contains - * an initial header, comment data or codebook tables. - * - * \param ci A theora_info structure to fill. This must have been previously - * initialized with theora_info_init(). If \a op contains an initial - * header, theora_decode_header() will fill \a ci with the - * parsed header values. If \a op contains codebook tables, - * theora_decode_header() will parse these and attach an internal - * representation to \a ci->codec_setup. - * \param cc A theora_comment structure to fill. If \a op contains comment - * data, theora_decode_header() will fill \a cc with the parsed - * comments. - * \param op An ogg_packet structure which you expect contains an initial - * header, comment data or codebook tables. - * - * \retval OC_BADHEADER \a op is NULL; OR the first byte of \a op->packet - * has the signature of an initial packet, but op is - * not a b_o_s packet; OR this packet has the signature - * of an initial header packet, but an initial header - * packet has already been seen; OR this packet has the - * signature of a comment packet, but the initial header - * has not yet been seen; OR this packet has the signature - * of a comment packet, but contains invalid data; OR - * this packet has the signature of codebook tables, - * but the initial header or comments have not yet - * been seen; OR this packet has the signature of codebook - * tables, but contains invalid data; - * OR the stream being decoded has a compatible version - * but this packet does not have the signature of a - * theora initial header, comments, or codebook packet - * \retval OC_VERSION The packet data of \a op is an initial header with - * a version which is incompatible with this version of - * libtheora. - * \retval OC_NEWPACKET the stream being decoded has an incompatible (future) - * version and contains an unknown signature. - * \retval 0 Success - * - * \note The normal usage is that theora_decode_header() be called on the - * first three packets of a theora logical bitstream in succession. - */ -extern int theora_decode_header(theora_info *ci, theora_comment *cc, - ogg_packet *op); - -/** - * Initialize a theora_state handle for decoding. - * \param th The theora_state handle to initialize. - * \param c A theora_info struct filled with the desired decoding parameters. - * This is of course usually obtained from a previous call to - * theora_decode_header(). - * \retval 0 Success - */ -extern int theora_decode_init(theora_state *th, theora_info *c); - -/** - * Input a packet containing encoded data into the theora decoder. - * \param th A theora_state handle previously initialized for decoding. - * \param op An ogg_packet containing encoded theora data. - * \retval 0 Success - * \retval OC_BADPACKET \a op does not contain encoded video data - */ -extern int theora_decode_packetin(theora_state *th,ogg_packet *op); - -/** - * Output the next available frame of decoded YUV data. - * \param th A theora_state handle previously initialized for decoding. - * \param yuv A yuv_buffer in which libtheora should place the decoded data. - * Note that the buffer struct itself is allocated by the user, but - * that the luma and chroma pointers will be filled in by the - * library. Also note that these luma and chroma regions should be - * considered read-only by the user. - * \retval 0 Success - */ -extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv); - -/** - * Report whether a theora packet is a header or not - * This function does no verification beyond checking the header - * flag bit so it should not be used for bitstream identification; - * use theora_decode_header() for that. - * - * \param op An ogg_packet containing encoded theora data. - * \retval 1 The packet is a header packet - * \retval 0 The packet is not a header packet (and so contains frame data) - * - * Thus function was added in the 1.0alpha4 release. - */ -extern int theora_packet_isheader(ogg_packet *op); - -/** - * Report whether a theora packet is a keyframe or not - * - * \param op An ogg_packet containing encoded theora data. - * \retval 1 The packet contains a keyframe image - * \retval 0 The packet is contains an interframe delta - * \retval -1 The packet is not an image data packet at all - * - * Thus function was added in the 1.0alpha4 release. - */ -extern int theora_packet_iskeyframe(ogg_packet *op); - -/** - * Report the granulepos shift radix - * - * When embedded in Ogg, Theora uses a two-part granulepos, - * splitting the 64-bit field into two pieces. The more-significant - * section represents the frame count at the last keyframe, - * and the less-significant section represents the count of - * frames since the last keyframe. In this way the overall - * field is still non-decreasing with time, but usefully encodes - * a pointer to the last keyframe, which is necessary for - * correctly restarting decode after a seek. - * - * This function reports the number of bits used to represent - * the distance to the last keyframe, and thus how the granulepos - * field must be shifted or masked to obtain the two parts. - * - * Since libtheora returns compressed data in an ogg_packet - * structure, this may be generally useful even if the Theora - * packets are not being used in an Ogg container. - * - * \param ti A previously initialized theora_info struct - * \returns The bit shift dividing the two granulepos fields - * - * This function was added in the 1.0alpha5 release. - */ -int theora_granule_shift(theora_info *ti); - -/** - * Convert a granulepos to an absolute frame index, starting at 0. - * The granulepos is interpreted in the context of a given theora_state handle. - * - * Note that while the granulepos encodes the frame count (i.e. starting - * from 1) this call returns the frame index, starting from zero. Thus - * One can calculate the presentation time by multiplying the index by - * the rate. - * - * \param th A previously initialized theora_state handle (encode or decode) - * \param granulepos The granulepos to convert. - * \returns The frame index corresponding to \a granulepos. - * \retval -1 The given granulepos is undefined (i.e. negative) - * - * Thus function was added in the 1.0alpha4 release. - */ -extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos); - -/** - * Convert a granulepos to absolute time in seconds. The granulepos is - * interpreted in the context of a given theora_state handle, and gives - * the end time of a frame's presentation as used in Ogg mux ordering. - * - * \param th A previously initialized theora_state handle (encode or decode) - * \param granulepos The granulepos to convert. - * \returns The absolute time in seconds corresponding to \a granulepos. - * This is the "end time" for the frame, or the latest time it should - * be displayed. - * It is not the presentation time. - * \retval -1. The given granulepos is undefined (i.e. negative), or - * \retval -1. The function has been disabled because floating - * point support is not available. - */ -extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos); - -/** - * Initialize a theora_info structure. All values within the given theora_info - * structure are initialized, and space is allocated within libtheora for - * internal codec setup data. - * \param c A theora_info struct to initialize. - */ -extern void theora_info_init(theora_info *c); - -/** - * Clear a theora_info structure. All values within the given theora_info - * structure are cleared, and associated internal codec setup data is freed. - * \param c A theora_info struct to initialize. - */ -extern void theora_info_clear(theora_info *c); - -/** - * Free all internal data associated with a theora_state handle. - * \param t A theora_state handle. - */ -extern void theora_clear(theora_state *t); - -/** - * Initialize an allocated theora_comment structure - * \param tc An allocated theora_comment structure - **/ -extern void theora_comment_init(theora_comment *tc); - -/** - * Add a comment to an initialized theora_comment structure - * \param tc A previously initialized theora comment structure - * \param comment A null-terminated string encoding the comment in the form - * "TAG=the value" - * - * Neither theora_comment_add() nor theora_comment_add_tag() support - * comments containing null values, although the bitstream format - * supports this. To add such comments you will need to manipulate - * the theora_comment structure directly. - **/ - -extern void theora_comment_add(theora_comment *tc, char *comment); - -/** - * Add a comment to an initialized theora_comment structure. - * \param tc A previously initialized theora comment structure - * \param tag A null-terminated string containing the tag - * associated with the comment. - * \param value The corresponding value as a null-terminated string - * - * Neither theora_comment_add() nor theora_comment_add_tag() support - * comments containing null values, although the bitstream format - * supports this. To add such comments you will need to manipulate - * the theora_comment structure directly. - **/ -extern void theora_comment_add_tag(theora_comment *tc, - char *tag, char *value); - -/** - * Look up a comment value by tag. - * \param tc Tn initialized theora_comment structure - * \param tag The tag to look up - * \param count The instance of the tag. The same tag can appear multiple - * times, each with a distinct and ordered value, so an index - * is required to retrieve them all. - * \returns A pointer to the queried tag's value - * \retval NULL No matching tag is found - * - * \note Use theora_comment_query_count() to get the legal range for the - * count parameter. - **/ - -extern char *theora_comment_query(theora_comment *tc, char *tag, int count); - -/** Look up the number of instances of a tag. - * \param tc An initialized theora_comment structure - * \param tag The tag to look up - * \returns The number on instances of a particular tag. - * - * Call this first when querying for a specific tag and then interate - * over the number of instances with separate calls to - * theora_comment_query() to retrieve all instances in order. - **/ -extern int theora_comment_query_count(theora_comment *tc, char *tag); - -/** - * Clear an allocated theora_comment struct so that it can be freed. - * \param tc An allocated theora_comment structure. - **/ -extern void theora_comment_clear(theora_comment *tc); - -/**Encoder control function. - * This is used to provide advanced control the encoding process. - * \param th A #theora_state handle. - * \param req The control code to process. - * See \ref encctlcodes_old "the list of available - * control codes" for details. - * \param buf The parameters for this control code. - * \param buf_sz The size of the parameter buffer.*/ -extern int theora_control(theora_state *th,int req,void *buf,size_t buf_sz); - -/* @} */ /* end oldfuncs doxygen group */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _O_THEORA_H_ */ diff --git a/Engine/lib/libtheora/include/theora/theoradec.h b/Engine/lib/libtheora/include/theora/theoradec.h deleted file mode 100644 index b20f0e3a6..000000000 --- a/Engine/lib/libtheora/include/theora/theoradec.h +++ /dev/null @@ -1,325 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $ - - ********************************************************************/ - -/**\file - * The libtheoradec C decoding API.*/ - -#if !defined(_O_THEORA_THEORADEC_H_) -# define _O_THEORA_THEORADEC_H_ (1) -# include -# include -# include "codec.h" - -#if defined(__cplusplus) -extern "C" { -#endif - - - -/**\name th_decode_ctl() codes - * \anchor decctlcodes - * These are the available request codes for th_decode_ctl(). - * By convention, these are odd, to distinguish them from the - * \ref encctlcodes "encoder control codes". - * Keep any experimental or vendor-specific values above \c 0x8000.*/ -/*@{*/ -/**Gets the maximum post-processing level. - * The decoder supports a post-processing filter that can improve - * the appearance of the decoded images. This returns the highest - * level setting for this post-processor, corresponding to maximum - * improvement and computational expense. - * - * \param[out] _buf int: The maximum post-processing level. - * \retval TH_EFAULT \a _dec_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(int). - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_DECCTL_GET_PPLEVEL_MAX (1) -/**Sets the post-processing level. - * By default, post-processing is disabled. - * - * Sets the level of post-processing to use when decoding the - * compressed stream. This must be a value between zero (off) - * and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX. - * - * \param[in] _buf int: The new post-processing level. - * 0 to disable; larger values use more CPU. - * \retval TH_EFAULT \a _dec_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(int), or the - * post-processing level is out of bounds. - * The maximum post-processing level may be - * implementation-specific, and can be obtained via - * #TH_DECCTL_GET_PPLEVEL_MAX. - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_DECCTL_SET_PPLEVEL (3) -/**Sets the granule position. - * Call this after a seek, before decoding the first frame, to ensure that the - * proper granule position is returned for all subsequent frames. - * If you track timestamps yourself and do not use the granule position - * returned by the decoder, then you need not call this function. - * - * \param[in] _buf ogg_int64_t: The granule position of the next - * frame. - * \retval TH_EFAULT \a _dec_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(ogg_int64_t), or the - * granule position is negative.*/ -#define TH_DECCTL_SET_GRANPOS (5) -/**Sets the striped decode callback function. - * If set, this function will be called as each piece of a frame is fully - * decoded in th_decode_packetin(). - * You can pass in a #th_stripe_callback with - * th_stripe_callback#stripe_decoded set to NULL to disable the - * callbacks at any point. - * Enabling striped decode does not prevent you from calling - * th_decode_ycbcr_out() after the frame is fully decoded. - * - * \param[in] _buf #th_stripe_callback: The callback parameters. - * \retval TH_EFAULT \a _dec_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not - * sizeof(th_stripe_callback).*/ -#define TH_DECCTL_SET_STRIPE_CB (7) - -/**Enables telemetry and sets the macroblock display mode */ -#define TH_DECCTL_SET_TELEMETRY_MBMODE (9) -/**Enables telemetry and sets the motion vector display mode */ -#define TH_DECCTL_SET_TELEMETRY_MV (11) -/**Enables telemetry and sets the adaptive quantization display mode */ -#define TH_DECCTL_SET_TELEMETRY_QI (13) -/**Enables telemetry and sets the bitstream breakdown visualization mode */ -#define TH_DECCTL_SET_TELEMETRY_BITS (15) -/*@}*/ - - - -/**A callback function for striped decode. - * This is a function pointer to an application-provided function that will be - * called each time a section of the image is fully decoded in - * th_decode_packetin(). - * This allows the application to process the section immediately, while it is - * still in cache. - * Note that the frame is decoded bottom to top, so \a _yfrag0 will steadily - * decrease with each call until it reaches 0, at which point the full frame - * is decoded. - * The number of fragment rows made available in each call depends on the pixel - * format and the number of post-processing filters enabled, and may not even - * be constant for the entire frame. - * If a non-NULL \a _granpos pointer is passed to - * th_decode_packetin(), the granule position for the frame will be stored - * in it before the first callback is made. - * If an entire frame is dropped (a 0-byte packet), then no callbacks will be - * made at all for that frame. - * \param _ctx An application-provided context pointer. - * \param _buf The image buffer for the decoded frame. - * \param _yfrag0 The Y coordinate of the first row of 8x8 fragments - * decoded. - * Multiply this by 8 to obtain the pixel row number in the - * luma plane. - * If the chroma planes are subsampled in the Y direction, - * this will always be divisible by two. - * \param _yfrag_end The Y coordinate of the first row of 8x8 fragments past - * the newly decoded section. - * If the chroma planes are subsampled in the Y direction, - * this will always be divisible by two. - * I.e., this section contains fragment rows - * \a _yfrag0 ...\a _yfrag_end -1.*/ -typedef void (*th_stripe_decoded_func)(void *_ctx,th_ycbcr_buffer _buf, - int _yfrag0,int _yfrag_end); - -/**The striped decode callback data to pass to #TH_DECCTL_SET_STRIPE_CB.*/ -typedef struct{ - /**An application-provided context pointer. - * This will be passed back verbatim to the application.*/ - void *ctx; - /**The callback function pointer.*/ - th_stripe_decoded_func stripe_decoded; -}th_stripe_callback; - - - -/**\name Decoder state - The following data structures are opaque, and their contents are not - publicly defined by this API. - Referring to their internals directly is unsupported, and may break without - warning.*/ -/*@{*/ -/**The decoder context.*/ -typedef struct th_dec_ctx th_dec_ctx; -/**Setup information. - This contains auxiliary information (Huffman tables and quantization - parameters) decoded from the setup header by th_decode_headerin() to be - passed to th_decode_alloc(). - It can be re-used to initialize any number of decoders, and can be freed - via th_setup_free() at any time.*/ -typedef struct th_setup_info th_setup_info; -/*@}*/ - - - -/**\defgroup decfuncs Functions for Decoding*/ -/*@{*/ -/**\name Functions for decoding - * You must link to libtheoradec if you use any of the - * functions in this section. - * - * The functions are listed in the order they are used in a typical decode. - * The basic steps are: - * - Parse the header packets by repeatedly calling th_decode_headerin(). - * - Allocate a #th_dec_ctx handle with th_decode_alloc(). - * - Call th_setup_free() to free any memory used for codec setup - * information. - * - Perform any additional decoder configuration with th_decode_ctl(). - * - For each video data packet: - * - Submit the packet to the decoder via th_decode_packetin(). - * - Retrieve the uncompressed video data via th_decode_ycbcr_out(). - * - Call th_decode_free() to release all decoder memory.*/ -/*@{*/ -/**Decodes the header packets of a Theora stream. - * This should be called on the initial packets of the stream, in succession, - * until it returns 0, indicating that all headers have been - * processed, or an error is encountered. - * At least three header packets are required, and additional optional header - * packets may follow. - * This can be used on the first packet of any logical stream to determine if - * that stream is a Theora stream. - * \param _info A #th_info structure to fill in. - * This must have been previously initialized with - * th_info_init(). - * The application may immediately begin using the contents of - * this structure after the first header is decoded, though it - * must continue to be passed in on all subsequent calls. - * \param _tc A #th_comment structure to fill in. - * The application may immediately begin using the contents of - * this structure after the second header is decoded, though it - * must continue to be passed in on all subsequent calls. - * \param _setup Returns a pointer to additional, private setup information - * needed by the decoder. - * The contents of this pointer must be initialized to - * NULL on the first call, and the returned value must - * continue to be passed in on all subsequent calls. - * \param _op An ogg_packet structure which contains one of the - * initial packets of an Ogg logical stream. - * \return A positive value indicates that a Theora header was successfully - * processed. - * \retval 0 The first video data packet was encountered after all - * required header packets were parsed. - * The packet just passed in on this call should be saved - * and fed to th_decode_packetin() to begin decoding - * video data. - * \retval TH_EFAULT One of \a _info, \a _tc, or \a _setup was - * NULL. - * \retval TH_EBADHEADER \a _op was NULL, the packet was not the next - * header packet in the expected sequence, or the format - * of the header data was invalid. - * \retval TH_EVERSION The packet data was a Theora info header, but for a - * bitstream version not decodable with this version of - * libtheoradec. - * \retval TH_ENOTFORMAT The packet was not a Theora header. - */ -extern int th_decode_headerin(th_info *_info,th_comment *_tc, - th_setup_info **_setup,ogg_packet *_op); -/**Allocates a decoder instance. - * - * Security Warning: The Theora format supports very large frame sizes, - * potentially even larger than the address space of a 32-bit machine, and - * creating a decoder context allocates the space for several frames of data. - * If the allocation fails here, your program will crash, possibly at some - * future point because the OS kernel returned a valid memory range and will - * only fail when it tries to map the pages in it the first time they are - * used. - * Even if it succeeds, you may experience a denial of service if the frame - * size is large enough to cause excessive paging. - * If you are integrating libtheora in a larger application where such things - * are undesirable, it is highly recommended that you check the frame size in - * \a _info before calling this function and refuse to decode streams where it - * is larger than some reasonable maximum. - * libtheora will not check this for you, because there may be machines that - * can handle such streams and applications that wish to. - * \param _info A #th_info struct filled via th_decode_headerin(). - * \param _setup A #th_setup_info handle returned via - * th_decode_headerin(). - * \return The initialized #th_dec_ctx handle. - * \retval NULL If the decoding parameters were invalid.*/ -extern th_dec_ctx *th_decode_alloc(const th_info *_info, - const th_setup_info *_setup); -/**Releases all storage used for the decoder setup information. - * This should be called after you no longer want to create any decoders for - * a stream whose headers you have parsed with th_decode_headerin(). - * \param _setup The setup information to free. - * This can safely be NULL.*/ -extern void th_setup_free(th_setup_info *_setup); -/**Decoder control function. - * This is used to provide advanced control of the decoding process. - * \param _dec A #th_dec_ctx handle. - * \param _req The control code to process. - * See \ref decctlcodes "the list of available control codes" - * for details. - * \param _buf The parameters for this control code. - * \param _buf_sz The size of the parameter buffer.*/ -extern int th_decode_ctl(th_dec_ctx *_dec,int _req,void *_buf, - size_t _buf_sz); -/**Submits a packet containing encoded video data to the decoder. - * \param _dec A #th_dec_ctx handle. - * \param _op An ogg_packet containing encoded video data. - * \param _granpos Returns the granule position of the decoded packet. - * If non-NULL, the granule position for this specific - * packet is stored in this location. - * This is computed incrementally from previously decoded - * packets. - * After a seek, the correct granule position must be set via - * #TH_DECCTL_SET_GRANPOS for this to work properly. - * \retval 0 Success. - * A new decoded frame can be retrieved by calling - * th_decode_ycbcr_out(). - * \retval TH_DUPFRAME The packet represented a dropped (0-byte) frame. - * The player can skip the call to th_decode_ycbcr_out(), - * as the contents of the decoded frame buffer have not - * changed. - * \retval TH_EFAULT \a _dec or \a _op was NULL. - * \retval TH_EBADPACKET \a _op does not contain encoded video data. - * \retval TH_EIMPL The video data uses bitstream features which this - * library does not support.*/ -extern int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op, - ogg_int64_t *_granpos); -/**Outputs the next available frame of decoded Y'CbCr data. - * If a striped decode callback has been set with #TH_DECCTL_SET_STRIPE_CB, - * then the application does not need to call this function. - * \param _dec A #th_dec_ctx handle. - * \param _ycbcr A video buffer structure to fill in. - * libtheoradec will fill in all the members of this - * structure, including the pointers to the uncompressed video - * data. - * The memory for this video data is owned by - * libtheoradec. - * It may be freed or overwritten without notification when - * subsequent frames are decoded. - * \retval 0 Success - * \retval TH_EFAULT \a _dec or \a _ycbcr was NULL. - */ -extern int th_decode_ycbcr_out(th_dec_ctx *_dec, - th_ycbcr_buffer _ycbcr); -/**Frees an allocated decoder instance. - * \param _dec A #th_dec_ctx handle.*/ -extern void th_decode_free(th_dec_ctx *_dec); -/*@}*/ -/*@}*/ - - - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/Engine/lib/libtheora/include/theora/theoraenc.h b/Engine/lib/libtheora/include/theora/theoraenc.h deleted file mode 100644 index fdf2ab21e..000000000 --- a/Engine/lib/libtheora/include/theora/theoraenc.h +++ /dev/null @@ -1,486 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $ - - ********************************************************************/ - -/**\file - * The libtheoraenc C encoding API.*/ - -#if !defined(_O_THEORA_THEORAENC_H_) -# define _O_THEORA_THEORAENC_H_ (1) -# include -# include -# include "codec.h" - -#if defined(__cplusplus) -extern "C" { -#endif - - - -/**\name th_encode_ctl() codes - * \anchor encctlcodes - * These are the available request codes for th_encode_ctl(). - * By convention, these are even, to distinguish them from the - * \ref decctlcodes "decoder control codes". - * Keep any experimental or vendor-specific values above \c 0x8000.*/ -/*@{*/ -/**Sets the Huffman tables to use. - * The tables are copied, not stored by reference, so they can be freed after - * this call. - * NULL may be specified to revert to the default tables. - * - * \param[in] _buf #th_huff_code[#TH_NHUFFMAN_TABLES][#TH_NDCT_TOKENS] - * \retval TH_EFAULT \a _enc_ctx is NULL. - * \retval TH_EINVAL Encoding has already begun or one or more of the given - * tables is not full or prefix-free, \a _buf is - * NULL and \a _buf_sz is not zero, or \a _buf is - * non-NULL and \a _buf_sz is not - * sizeof(#th_huff_code)*#TH_NHUFFMAN_TABLES*#TH_NDCT_TOKENS. - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_ENCCTL_SET_HUFFMAN_CODES (0) -/**Sets the quantization parameters to use. - * The parameters are copied, not stored by reference, so they can be freed - * after this call. - * NULL may be specified to revert to the default parameters. - * - * \param[in] _buf #th_quant_info - * \retval TH_EFAULT \a _enc_ctx is NULL. - * \retval TH_EINVAL Encoding has already begun, \a _buf is - * NULL and \a _buf_sz is not zero, - * or \a _buf is non-NULL and - * \a _buf_sz is not sizeof(#th_quant_info). - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_ENCCTL_SET_QUANT_PARAMS (2) -/**Sets the maximum distance between key frames. - * This can be changed during an encode, but will be bounded by - * 1<. - * If it is set before encoding begins, th_info#keyframe_granule_shift will - * be enlarged appropriately. - * - * \param[in] _buf ogg_uint32_t: The maximum distance between key - * frames. - * \param[out] _buf ogg_uint32_t: The actual maximum distance set. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(ogg_uint32_t). - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4) -/**Disables any encoder features that would prevent lossless transcoding back - * to VP3. - * This primarily means disabling block-adaptive quantization and always coding - * all four luma blocks in a macro block when 4MV is used. - * It also includes using the VP3 quantization tables and Huffman codes; if you - * set them explicitly after calling this function, the resulting stream will - * not be VP3-compatible. - * If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source - * material, or when using a picture region smaller than the full frame (e.g. - * a non-multiple-of-16 width or height), then non-VP3 bitstream features will - * still be disabled, but the stream will still not be VP3-compatible, as VP3 - * was not capable of encoding such formats. - * If you call this after encoding has already begun, then the quantization - * tables and codebooks cannot be changed, but the frame-level features will - * be enabled or disabled as requested. - * - * \param[in] _buf int: a non-zero value to enable VP3 compatibility, - * or 0 to disable it (the default). - * \param[out] _buf int: 1 if all bitstream features required for - * VP3-compatibility could be set, and 0 otherwise. - * The latter will be returned if the pixel format is not - * 4:2:0, the picture region is smaller than the full frame, - * or if encoding has begun, preventing the quantization - * tables and codebooks from being set. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(int). - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_ENCCTL_SET_VP3_COMPATIBLE (10) -/**Gets the maximum speed level. - * Higher speed levels favor quicker encoding over better quality per bit. - * Depending on the encoding mode, and the internal algorithms used, quality - * may actually improve, but in this case bitrate will also likely increase. - * In any case, overall rate/distortion performance will probably decrease. - * The maximum value, and the meaning of each value, may change depending on - * the current encoding mode (VBR vs. constant quality, etc.). - * - * \param[out] _buf int: The maximum encoding speed level. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(int). - * \retval TH_EIMPL Not supported by this implementation in the current - * encoding mode.*/ -#define TH_ENCCTL_GET_SPLEVEL_MAX (12) -/**Sets the speed level. - * The current speed level may be retrieved using #TH_ENCCTL_GET_SPLEVEL. - * - * \param[in] _buf int: The new encoding speed level. - * 0 is slowest, larger values use less CPU. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(int), or the - * encoding speed level is out of bounds. - * The maximum encoding speed level may be - * implementation- and encoding mode-specific, and can be - * obtained via #TH_ENCCTL_GET_SPLEVEL_MAX. - * \retval TH_EIMPL Not supported by this implementation in the current - * encoding mode.*/ -#define TH_ENCCTL_SET_SPLEVEL (14) -/**Gets the current speed level. - * The default speed level may vary according to encoder implementation, but if - * this control code is not supported (it returns #TH_EIMPL), the default may - * be assumed to be the slowest available speed (0). - * The maximum encoding speed level may be implementation- and encoding - * mode-specific, and can be obtained via #TH_ENCCTL_GET_SPLEVEL_MAX. - * - * \param[out] _buf int: The current encoding speed level. - * 0 is slowest, larger values use less CPU. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(int). - * \retval TH_EIMPL Not supported by this implementation in the current - * encoding mode.*/ -#define TH_ENCCTL_GET_SPLEVEL (16) -/**Sets the number of duplicates of the next frame to produce. - * Although libtheora can encode duplicate frames very cheaply, it costs some - * amount of CPU to detect them, and a run of duplicates cannot span a - * keyframe boundary. - * This control code tells the encoder to produce the specified number of extra - * duplicates of the next frame. - * This allows the encoder to make smarter keyframe placement decisions and - * rate control decisions, and reduces CPU usage as well, when compared to - * just submitting the same frame for encoding multiple times. - * This setting only applies to the next frame submitted for encoding. - * You MUST call th_encode_packetout() repeatedly until it returns 0, or the - * extra duplicate frames will be lost. - * - * \param[in] _buf int: The number of duplicates to produce. - * If this is negative or zero, no duplicates will be produced. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(int), or the - * number of duplicates is greater than or equal to the - * maximum keyframe interval. - * In the latter case, NO duplicate frames will be produced. - * You must ensure that the maximum keyframe interval is set - * larger than the maximum number of duplicates you will - * ever wish to insert prior to encoding. - * \retval TH_EIMPL Not supported by this implementation in the current - * encoding mode.*/ -#define TH_ENCCTL_SET_DUP_COUNT (18) -/**Modifies the default bitrate management behavior. - * Use to allow or disallow frame dropping, and to enable or disable capping - * bit reservoir overflows and underflows. - * See \ref encctlcodes "the list of available flags". - * The flags are set by default to - * #TH_RATECTL_DROP_FRAMES|#TH_RATECTL_CAP_OVERFLOW. - * - * \param[in] _buf int: Any combination of - * \ref ratectlflags "the available flags": - * - #TH_RATECTL_DROP_FRAMES: Enable frame dropping. - * - #TH_RATECTL_CAP_OVERFLOW: Don't bank excess bits for later - * use. - * - #TH_RATECTL_CAP_UNDERFLOW: Don't try to make up shortfalls - * later. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(int) or rate control - * is not enabled. - * \retval TH_EIMPL Not supported by this implementation in the current - * encoding mode.*/ -#define TH_ENCCTL_SET_RATE_FLAGS (20) -/**Sets the size of the bitrate management bit reservoir as a function - * of number of frames. - * The reservoir size affects how quickly bitrate management reacts to - * instantaneous changes in the video complexity. - * Larger reservoirs react more slowly, and provide better overall quality, but - * require more buffering by a client, adding more latency to live streams. - * By default, libtheora sets the reservoir to the maximum distance between - * keyframes, subject to a minimum and maximum limit. - * This call may be used to increase or decrease the reservoir, increasing or - * decreasing the allowed temporary variance in bitrate. - * An implementation may impose some limits on the size of a reservoir it can - * handle, in which case the actual reservoir size may not be exactly what was - * requested. - * The actual value set will be returned. - * - * \param[in] _buf int: Requested size of the reservoir measured in - * frames. - * \param[out] _buf int: The actual size of the reservoir set. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(int), or rate control - * is not enabled. The buffer has an implementation - * defined minimum and maximum size and the value in _buf - * will be adjusted to match the actual value set. - * \retval TH_EIMPL Not supported by this implementation in the current - * encoding mode.*/ -#define TH_ENCCTL_SET_RATE_BUFFER (22) -/**Enable pass 1 of two-pass encoding mode and retrieve the first pass metrics. - * Pass 1 mode must be enabled before the first frame is encoded, and a target - * bitrate must have already been specified to the encoder. - * Although this does not have to be the exact rate that will be used in the - * second pass, closer values may produce better results. - * The first call returns the size of the two-pass header data, along with some - * placeholder content, and sets the encoder into pass 1 mode implicitly. - * This call sets the encoder to pass 1 mode implicitly. - * Then, a subsequent call must be made after each call to - * th_encode_ycbcr_in() to retrieve the metrics for that frame. - * An additional, final call must be made to retrieve the summary data, - * containing such information as the total number of frames, etc. - * This must be stored in place of the placeholder data that was returned - * in the first call, before the frame metrics data. - * All of this data must be presented back to the encoder during pass 2 using - * #TH_ENCCTL_2PASS_IN. - * - * \param[out] char *_buf: Returns a pointer to internal storage - * containing the two pass metrics data. - * This storage is only valid until the next call, or until the - * encoder context is freed, and must be copied by the - * application. - * \retval >=0 The number of bytes of metric data available in the - * returned buffer. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL \a _buf_sz is not sizeof(char *), no target - * bitrate has been set, or the first call was made after - * the first frame was submitted for encoding. - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_ENCCTL_2PASS_OUT (24) -/**Submits two-pass encoding metric data collected the first encoding pass to - * the second pass. - * The first call must be made before the first frame is encoded, and a target - * bitrate must have already been specified to the encoder. - * It sets the encoder to pass 2 mode implicitly; this cannot be disabled. - * The encoder may require reading data from some or all of the frames in - * advance, depending on, e.g., the reservoir size used in the second pass. - * You must call this function repeatedly before each frame to provide data - * until either a) it fails to consume all of the data presented or b) all of - * the pass 1 data has been consumed. - * In the first case, you must save the remaining data to be presented after - * the next frame. - * You can call this function with a NULL argument to get an upper bound on - * the number of bytes that will be required before the next frame. - * - * When pass 2 is first enabled, the default bit reservoir is set to the entire - * file; this gives maximum flexibility but can lead to very high peak rates. - * You can subsequently set it to another value with #TH_ENCCTL_SET_RATE_BUFFER - * (e.g., to set it to the keyframe interval for non-live streaming), however, - * you may then need to provide more data before the next frame. - * - * \param[in] _buf char[]: A buffer containing the data returned by - * #TH_ENCCTL_2PASS_OUT in pass 1. - * You may pass NULL for \a _buf to return an upper - * bound on the number of additional bytes needed before the - * next frame. - * The summary data returned at the end of pass 1 must be at - * the head of the buffer on the first call with a - * non-NULL \a _buf, and the placeholder data - * returned at the start of pass 1 should be omitted. - * After each call you should advance this buffer by the number - * of bytes consumed. - * \retval >0 The number of bytes of metric data required/consumed. - * \retval 0 No more data is required before the next frame. - * \retval TH_EFAULT \a _enc_ctx is NULL. - * \retval TH_EINVAL No target bitrate has been set, or the first call was - * made after the first frame was submitted for - * encoding. - * \retval TH_ENOTFORMAT The data did not appear to be pass 1 from a compatible - * implementation of this library. - * \retval TH_EBADHEADER The data was invalid; this may be returned when - * attempting to read an aborted pass 1 file that still - * has the placeholder data in place of the summary - * data. - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_ENCCTL_2PASS_IN (26) -/**Sets the current encoding quality. - * This is only valid so long as no bitrate has been specified, either through - * the #th_info struct used to initialize the encoder or through - * #TH_ENCCTL_SET_BITRATE (this restriction may be relaxed in a future - * version). - * If it is set before the headers are emitted, the target quality encoded in - * them will be updated. - * - * \param[in] _buf int: The new target quality, in the range 0...63, - * inclusive. - * \retval 0 Success. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL A target bitrate has already been specified, or the - * quality index was not in the range 0...63. - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_ENCCTL_SET_QUALITY (28) -/**Sets the current encoding bitrate. - * Once a bitrate is set, the encoder must use a rate-controlled mode for all - * future frames (this restriction may be relaxed in a future version). - * If it is set before the headers are emitted, the target bitrate encoded in - * them will be updated. - * Due to the buffer delay, the exact bitrate of each section of the encode is - * not guaranteed. - * The encoder may have already used more bits than allowed for the frames it - * has encoded, expecting to make them up in future frames, or it may have - * used fewer, holding the excess in reserve. - * The exact transition between the two bitrates is not well-defined by this - * API, but may be affected by flags set with #TH_ENCCTL_SET_RATE_FLAGS. - * After a number of frames equal to the buffer delay, one may expect further - * output to average at the target bitrate. - * - * \param[in] _buf long: The new target bitrate, in bits per second. - * \retval 0 Success. - * \retval TH_EFAULT \a _enc_ctx or \a _buf is NULL. - * \retval TH_EINVAL The target bitrate was not positive. - * \retval TH_EIMPL Not supported by this implementation.*/ -#define TH_ENCCTL_SET_BITRATE (30) - -/*@}*/ - - -/**\name TH_ENCCTL_SET_RATE_FLAGS flags - * \anchor ratectlflags - * These are the flags available for use with #TH_ENCCTL_SET_RATE_FLAGS.*/ -/*@{*/ -/**Drop frames to keep within bitrate buffer constraints. - * This can have a severe impact on quality, but is the only way to ensure that - * bitrate targets are met at low rates during sudden bursts of activity.*/ -#define TH_RATECTL_DROP_FRAMES (0x1) -/**Ignore bitrate buffer overflows. - * If the encoder uses so few bits that the reservoir of available bits - * overflows, ignore the excess. - * The encoder will not try to use these extra bits in future frames. - * At high rates this may cause the result to be undersized, but allows a - * client to play the stream using a finite buffer; it should normally be - * enabled.*/ -#define TH_RATECTL_CAP_OVERFLOW (0x2) -/**Ignore bitrate buffer underflows. - * If the encoder uses so many bits that the reservoir of available bits - * underflows, ignore the deficit. - * The encoder will not try to make up these extra bits in future frames. - * At low rates this may cause the result to be oversized; it should normally - * be disabled.*/ -#define TH_RATECTL_CAP_UNDERFLOW (0x4) -/*@}*/ - - - -/**The quantization parameters used by VP3.*/ -extern const th_quant_info TH_VP31_QUANT_INFO; - -/**The Huffman tables used by VP3.*/ -extern const th_huff_code - TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]; - - - -/**\name Encoder state - The following data structure is opaque, and its contents are not publicly - defined by this API. - Referring to its internals directly is unsupported, and may break without - warning.*/ -/*@{*/ -/**The encoder context.*/ -typedef struct th_enc_ctx th_enc_ctx; -/*@}*/ - - - -/**\defgroup encfuncs Functions for Encoding*/ -/*@{*/ -/**\name Functions for encoding - * You must link to libtheoraenc and libtheoradec - * if you use any of the functions in this section. - * - * The functions are listed in the order they are used in a typical encode. - * The basic steps are: - * - Fill in a #th_info structure with details on the format of the video you - * wish to encode. - * - Allocate a #th_enc_ctx handle with th_encode_alloc(). - * - Perform any additional encoder configuration required with - * th_encode_ctl(). - * - Repeatedly call th_encode_flushheader() to retrieve all the header - * packets. - * - For each uncompressed frame: - * - Submit the uncompressed frame via th_encode_ycbcr_in() - * - Repeatedly call th_encode_packetout() to retrieve any video data packets - * that are ready. - * - Call th_encode_free() to release all encoder memory.*/ -/*@{*/ -/**Allocates an encoder instance. - * \param _info A #th_info struct filled with the desired encoding parameters. - * \return The initialized #th_enc_ctx handle. - * \retval NULL If the encoding parameters were invalid.*/ -extern th_enc_ctx *th_encode_alloc(const th_info *_info); -/**Encoder control function. - * This is used to provide advanced control the encoding process. - * \param _enc A #th_enc_ctx handle. - * \param _req The control code to process. - * See \ref encctlcodes "the list of available control codes" - * for details. - * \param _buf The parameters for this control code. - * \param _buf_sz The size of the parameter buffer.*/ -extern int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz); -/**Outputs the next header packet. - * This should be called repeatedly after encoder initialization until it - * returns 0 in order to get all of the header packets, in order, before - * encoding actual video data. - * \param _enc A #th_enc_ctx handle. - * \param _comments The metadata to place in the comment header, when it is - * encoded. - * \param _op An ogg_packet structure to fill. - * All of the elements of this structure will be set, - * including a pointer to the header data. - * The memory for the header data is owned by - * libtheoraenc, and may be invalidated when the - * next encoder function is called. - * \return A positive value indicates that a header packet was successfully - * produced. - * \retval 0 No packet was produced, and no more header packets remain. - * \retval TH_EFAULT \a _enc, \a _comments, or \a _op was NULL.*/ -extern int th_encode_flushheader(th_enc_ctx *_enc, - th_comment *_comments,ogg_packet *_op); -/**Submits an uncompressed frame to the encoder. - * \param _enc A #th_enc_ctx handle. - * \param _ycbcr A buffer of Y'CbCr data to encode. - * \retval 0 Success. - * \retval TH_EFAULT \a _enc or \a _ycbcr is NULL. - * \retval TH_EINVAL The buffer size does not match the frame size the encoder - * was initialized with, or encoding has already - * completed.*/ -extern int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _ycbcr); -/**Retrieves encoded video data packets. - * This should be called repeatedly after each frame is submitted to flush any - * encoded packets, until it returns 0. - * The encoder will not buffer these packets as subsequent frames are - * compressed, so a failure to do so will result in lost video data. - * \note Currently the encoder operates in a one-frame-in, one-packet-out - * manner. - * However, this may be changed in the future. - * \param _enc A #th_enc_ctx handle. - * \param _last Set this flag to a non-zero value if no more uncompressed - * frames will be submitted. - * This ensures that a proper EOS flag is set on the last packet. - * \param _op An ogg_packet structure to fill. - * All of the elements of this structure will be set, including a - * pointer to the video data. - * The memory for the video data is owned by - * libtheoraenc, and may be invalidated when the next - * encoder function is called. - * \return A positive value indicates that a video data packet was successfully - * produced. - * \retval 0 No packet was produced, and no more encoded video data - * remains. - * \retval TH_EFAULT \a _enc or \a _op was NULL.*/ -extern int th_encode_packetout(th_enc_ctx *_enc,int _last,ogg_packet *_op); -/**Frees an allocated encoder instance. - * \param _enc A #th_enc_ctx handle.*/ -extern void th_encode_free(th_enc_ctx *_enc); -/*@}*/ -/*@}*/ - - - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/Engine/lib/libtheora/lib/Makefile.am b/Engine/lib/libtheora/lib/Makefile.am deleted file mode 100644 index 89ce26120..000000000 --- a/Engine/lib/libtheora/lib/Makefile.am +++ /dev/null @@ -1,173 +0,0 @@ -INCLUDES = -I$(top_srcdir)/include -AM_CFLAGS = $(OGG_CFLAGS) $(CAIRO_CFLAGS) - -EXTRA_DIST = \ - cpu.c \ - encoder_disabled.c \ - x86/mmxencfrag.c \ - x86/mmxfdct.c \ - x86/sse2fdct.c \ - x86/x86enc.c \ - x86/x86enc.h \ - x86/mmxfrag.c \ - x86/mmxfrag.h \ - x86/mmxidct.c \ - x86/mmxloop.h \ - x86/mmxstate.c \ - x86/x86int.h \ - x86/x86state.c \ - x86_vc - -lib_LTLIBRARIES = libtheoradec.la libtheoraenc.la libtheora.la - -if THEORA_DISABLE_ENCODE -encoder_uniq_sources = \ - encoder_disabled.c - -encoder_sources = \ - $(encoder_uniq_sources) -else -encoder_uniq_x86_sources = \ - x86/mmxencfrag.c \ - x86/mmxfdct.c \ - x86/x86enc.c - -encoder_uniq_x86_64_sources = \ - x86/sse2fdct.c - -encoder_shared_x86_sources = \ - x86/mmxfrag.c \ - x86/mmxidct.c \ - x86/mmxstate.c \ - x86/x86state.c - -encoder_shared_x86_64_sources = - -if CPU_x86_64 -encoder_uniq_arch_sources = \ - $(encoder_uniq_x86_sources) \ - $(encoder_uniq_x86_64_sources) -encoder_shared_arch_sources = \ - $(encoder_shared_x86_sources) \ - $(encoder_shared_x86_64_sources) -else -if CPU_x86_32 -encoder_uniq_arch_sources = $(encoder_uniq_x86_sources) -encoder_shared_arch_sources = $(encoder_shared_x86_sources) -else -encoder_uniq_arch_sources = -encoder_shared_arch_sources = -endif -endif - -encoder_uniq_sources = \ - analyze.c \ - fdct.c \ - encfrag.c \ - encapiwrapper.c \ - encinfo.c \ - encode.c \ - enquant.c \ - huffenc.c \ - mathops.c \ - mcenc.c \ - rate.c \ - tokenize.c \ - $(encoder_uniq_arch_sources) - -encoder_sources = \ - apiwrapper.c \ - fragment.c \ - idct.c \ - internal.c \ - state.c \ - quant.c \ - $(encoder_shared_arch_sources) \ - $(encoder_uniq_sources) - -endif - -decoder_x86_sources = \ - x86/mmxidct.c \ - x86/mmxfrag.c \ - x86/mmxstate.c \ - x86/x86state.c -if CPU_x86_64 -decoder_arch_sources = $(decoder_x86_sources) -else -if CPU_x86_32 -decoder_arch_sources = $(decoder_x86_sources) -else -decoder_arch_sources = -endif -endif - -decoder_sources = \ - apiwrapper.c \ - bitpack.c \ - decapiwrapper.c \ - decinfo.c \ - decode.c \ - dequant.c \ - fragment.c \ - huffdec.c \ - idct.c \ - info.c \ - internal.c \ - quant.c \ - state.c \ - $(decoder_arch_sources) - -noinst_HEADERS = \ - cpu.h \ - internal.h \ - encint.h \ - enquant.h \ - huffenc.h \ - mathops.h \ - modedec.h \ - x86/x86enc.h \ - apiwrapper.h \ - bitpack.h \ - dct.h \ - decint.h \ - dequant.h \ - huffdec.h \ - huffman.h \ - ocintrin.h \ - quant.h \ - x86/mmxfrag.h \ - x86/mmxloop.h \ - x86/x86int.h - -libtheoradec_la_SOURCES = \ - $(decoder_sources) \ - Version_script-dec theoradec.exp -libtheoradec_la_LDFLAGS = \ - -version-info @THDEC_LIB_CURRENT@:@THDEC_LIB_REVISION@:@THDEC_LIB_AGE@ \ - @THEORADEC_LDFLAGS@ @CAIRO_LIBS@ - -libtheoraenc_la_SOURCES = \ - $(encoder_sources) \ - Version_script-enc theoraenc.exp -libtheoraenc_la_LDFLAGS = \ - -version-info @THENC_LIB_CURRENT@:@THENC_LIB_REVISION@:@THENC_LIB_AGE@ \ - @THEORAENC_LDFLAGS@ $(OGG_LIBS) - -libtheora_la_SOURCES = \ - $(decoder_sources) \ - $(encoder_uniq_sources) \ - Version_script theora.exp -libtheora_la_LDFLAGS = \ - -version-info @TH_LIB_CURRENT@:@TH_LIB_REVISION@:@TH_LIB_AGE@ \ - @THEORA_LDFLAGS@ @CAIRO_LIBS@ $(OGG_LIBS) - -debug: - $(MAKE) all CFLAGS="@DEBUG@" - -profile: - $(MAKE) all CFLAGS="@PROFILE@" - -# contstruct various symbol export list files -.def.exp : defexp.awk - awk -f defexp.awk $< > $@ diff --git a/Engine/lib/libtheora/lib/Makefile.in b/Engine/lib/libtheora/lib/Makefile.in deleted file mode 100644 index f26ccdc0e..000000000 --- a/Engine/lib/libtheora/lib/Makefile.in +++ /dev/null @@ -1,845 +0,0 @@ -# Makefile.in generated by automake 1.6.3 from Makefile.am. -# @configure_input@ - -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 -# Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = .. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_HEADER = $(INSTALL_DATA) -transform = @program_transform_name@ -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_alias = @host_alias@ -host_triplet = @host@ - -EXEEXT = @EXEEXT@ -OBJEXT = @OBJEXT@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ -AMTAR = @AMTAR@ -AR = @AR@ -ARGZ_H = @ARGZ_H@ -AS = @AS@ -AWK = @AWK@ -BUILDABLE_EXAMPLES = @BUILDABLE_EXAMPLES@ -CAIRO_CFLAGS = @CAIRO_CFLAGS@ -CAIRO_LIBS = @CAIRO_LIBS@ -CC = @CC@ -CPP = @CPP@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -DEBUG = @DEBUG@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -F77 = @F77@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ -GETOPT_OBJS = @GETOPT_OBJS@ -GREP = @GREP@ -HAVE_BIBTEX = @HAVE_BIBTEX@ -HAVE_DOXYGEN = @HAVE_DOXYGEN@ -HAVE_PDFLATEX = @HAVE_PDFLATEX@ -HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@ -HAVE_TRANSFIG = @HAVE_TRANSFIG@ -HAVE_VALGRIND = @HAVE_VALGRIND@ -INCLTDL = @INCLTDL@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LIBADD_DL = @LIBADD_DL@ -LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ -LIBADD_DLOPEN = @LIBADD_DLOPEN@ -LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ -LIBLTDL = @LIBLTDL@ -LIBM = @LIBM@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTDLDEPS = @LTDLDEPS@ -LTDLINCL = @LTDLINCL@ -LTDLOPEN = @LTDLOPEN@ -LT_CONFIG_H = @LT_CONFIG_H@ -LT_DLLOADERS = @LT_DLLOADERS@ -LT_DLPREOPEN = @LT_DLPREOPEN@ -MAINT = @MAINT@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OGG_CFLAGS = @OGG_CFLAGS@ -OGG_LIBS = @OGG_LIBS@ -OSS_LIBS = @OSS_LIBS@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PKG_CONFIG = @PKG_CONFIG@ -PNG_CFLAGS = @PNG_CFLAGS@ -PNG_LIBS = @PNG_LIBS@ -PROFILE = @PROFILE@ -RANLIB = @RANLIB@ -RC = @RC@ -SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ -SDL_LIBS = @SDL_LIBS@ -SED = @SED@ -STRIP = @STRIP@ -THDEC_LIB_AGE = @THDEC_LIB_AGE@ -THDEC_LIB_CURRENT = @THDEC_LIB_CURRENT@ -THDEC_LIB_REVISION = @THDEC_LIB_REVISION@ -THENC_LIB_AGE = @THENC_LIB_AGE@ -THENC_LIB_CURRENT = @THENC_LIB_CURRENT@ -THENC_LIB_REVISION = @THENC_LIB_REVISION@ -THEORADEC_LDFLAGS = @THEORADEC_LDFLAGS@ -THEORAENC_LDFLAGS = @THEORAENC_LDFLAGS@ -THEORA_LDFLAGS = @THEORA_LDFLAGS@ -TH_LIB_AGE = @TH_LIB_AGE@ -TH_LIB_CURRENT = @TH_LIB_CURRENT@ -TH_LIB_REVISION = @TH_LIB_REVISION@ -VALGRIND_ENVIRONMENT = @VALGRIND_ENVIRONMENT@ -VERSION = @VERSION@ -VORBISENC_LIBS = @VORBISENC_LIBS@ -VORBISFILE_LIBS = @VORBISFILE_LIBS@ -VORBIS_CFLAGS = @VORBIS_CFLAGS@ -VORBIS_LIBS = @VORBIS_LIBS@ -am__include = @am__include@ -am__quote = @am__quote@ -install_sh = @install_sh@ -lt_ECHO = @lt_ECHO@ -ltdl_LIBOBJS = @ltdl_LIBOBJS@ -ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ -sys_symbol_underscore = @sys_symbol_underscore@ -INCLUDES = -I$(top_srcdir)/include -AM_CFLAGS = $(OGG_CFLAGS) $(CAIRO_CFLAGS) - -EXTRA_DIST = \ - cpu.c \ - encoder_disabled.c \ - x86/mmxencfrag.c \ - x86/mmxfdct.c \ - x86/sse2fdct.c \ - x86/x86enc.c \ - x86/x86enc.h \ - x86/mmxfrag.c \ - x86/mmxfrag.h \ - x86/mmxidct.c \ - x86/mmxloop.h \ - x86/mmxstate.c \ - x86/x86int.h \ - x86/x86state.c \ - x86_vc - - -lib_LTLIBRARIES = libtheoradec.la libtheoraenc.la libtheora.la - -@THEORA_DISABLE_ENCODE_TRUE@encoder_uniq_sources = \ -@THEORA_DISABLE_ENCODE_TRUE@ encoder_disabled.c - -@THEORA_DISABLE_ENCODE_FALSE@encoder_uniq_sources = \ -@THEORA_DISABLE_ENCODE_FALSE@ analyze.c \ -@THEORA_DISABLE_ENCODE_FALSE@ fdct.c \ -@THEORA_DISABLE_ENCODE_FALSE@ encfrag.c \ -@THEORA_DISABLE_ENCODE_FALSE@ encapiwrapper.c \ -@THEORA_DISABLE_ENCODE_FALSE@ encinfo.c \ -@THEORA_DISABLE_ENCODE_FALSE@ encode.c \ -@THEORA_DISABLE_ENCODE_FALSE@ enquant.c \ -@THEORA_DISABLE_ENCODE_FALSE@ huffenc.c \ -@THEORA_DISABLE_ENCODE_FALSE@ mathops.c \ -@THEORA_DISABLE_ENCODE_FALSE@ mcenc.c \ -@THEORA_DISABLE_ENCODE_FALSE@ rate.c \ -@THEORA_DISABLE_ENCODE_FALSE@ tokenize.c \ -@THEORA_DISABLE_ENCODE_FALSE@ $(encoder_uniq_arch_sources) - - -@THEORA_DISABLE_ENCODE_TRUE@encoder_sources = \ -@THEORA_DISABLE_ENCODE_TRUE@ $(encoder_uniq_sources) - -@THEORA_DISABLE_ENCODE_FALSE@encoder_sources = \ -@THEORA_DISABLE_ENCODE_FALSE@ apiwrapper.c \ -@THEORA_DISABLE_ENCODE_FALSE@ fragment.c \ -@THEORA_DISABLE_ENCODE_FALSE@ idct.c \ -@THEORA_DISABLE_ENCODE_FALSE@ internal.c \ -@THEORA_DISABLE_ENCODE_FALSE@ state.c \ -@THEORA_DISABLE_ENCODE_FALSE@ quant.c \ -@THEORA_DISABLE_ENCODE_FALSE@ $(encoder_shared_arch_sources) \ -@THEORA_DISABLE_ENCODE_FALSE@ $(encoder_uniq_sources) - -@THEORA_DISABLE_ENCODE_FALSE@encoder_uniq_x86_sources = \ -@THEORA_DISABLE_ENCODE_FALSE@ x86/mmxencfrag.c \ -@THEORA_DISABLE_ENCODE_FALSE@ x86/mmxfdct.c \ -@THEORA_DISABLE_ENCODE_FALSE@ x86/x86enc.c - - -@THEORA_DISABLE_ENCODE_FALSE@encoder_uniq_x86_64_sources = \ -@THEORA_DISABLE_ENCODE_FALSE@ x86/sse2fdct.c - - -@THEORA_DISABLE_ENCODE_FALSE@encoder_shared_x86_sources = \ -@THEORA_DISABLE_ENCODE_FALSE@ x86/mmxfrag.c \ -@THEORA_DISABLE_ENCODE_FALSE@ x86/mmxidct.c \ -@THEORA_DISABLE_ENCODE_FALSE@ x86/mmxstate.c \ -@THEORA_DISABLE_ENCODE_FALSE@ x86/x86state.c - - -@THEORA_DISABLE_ENCODE_FALSE@encoder_shared_x86_64_sources = - -@CPU_x86_32_FALSE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@encoder_uniq_arch_sources = -@CPU_x86_32_TRUE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@encoder_uniq_arch_sources = $(encoder_uniq_x86_sources) -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@encoder_uniq_arch_sources = \ -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@ $(encoder_uniq_x86_sources) \ -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@ $(encoder_uniq_x86_64_sources) - -@CPU_x86_32_FALSE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@encoder_shared_arch_sources = -@CPU_x86_32_TRUE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@encoder_shared_arch_sources = $(encoder_shared_x86_sources) -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@encoder_shared_arch_sources = \ -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@ $(encoder_shared_x86_sources) \ -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@ $(encoder_shared_x86_64_sources) - - -decoder_x86_sources = \ - x86/mmxidct.c \ - x86/mmxfrag.c \ - x86/mmxstate.c \ - x86/x86state.c - -@CPU_x86_32_FALSE@@CPU_x86_64_FALSE@decoder_arch_sources = -@CPU_x86_32_TRUE@@CPU_x86_64_FALSE@decoder_arch_sources = $(decoder_x86_sources) -@CPU_x86_64_TRUE@decoder_arch_sources = $(decoder_x86_sources) - -decoder_sources = \ - apiwrapper.c \ - bitpack.c \ - decapiwrapper.c \ - decinfo.c \ - decode.c \ - dequant.c \ - fragment.c \ - huffdec.c \ - idct.c \ - info.c \ - internal.c \ - quant.c \ - state.c \ - $(decoder_arch_sources) - - -noinst_HEADERS = \ - cpu.h \ - internal.h \ - encint.h \ - enquant.h \ - huffenc.h \ - mathops.h \ - modedec.h \ - x86/x86enc.h \ - apiwrapper.h \ - bitpack.h \ - dct.h \ - decint.h \ - dequant.h \ - huffdec.h \ - huffman.h \ - ocintrin.h \ - quant.h \ - x86/mmxfrag.h \ - x86/mmxloop.h \ - x86/x86int.h - - -libtheoradec_la_SOURCES = \ - $(decoder_sources) \ - Version_script-dec theoradec.exp - -libtheoradec_la_LDFLAGS = \ - -version-info @THDEC_LIB_CURRENT@:@THDEC_LIB_REVISION@:@THDEC_LIB_AGE@ \ - @THEORADEC_LDFLAGS@ @CAIRO_LIBS@ - - -libtheoraenc_la_SOURCES = \ - $(encoder_sources) \ - Version_script-enc theoraenc.exp - -libtheoraenc_la_LDFLAGS = \ - -version-info @THENC_LIB_CURRENT@:@THENC_LIB_REVISION@:@THENC_LIB_AGE@ \ - @THEORAENC_LDFLAGS@ $(OGG_LIBS) - - -libtheora_la_SOURCES = \ - $(decoder_sources) \ - $(encoder_uniq_sources) \ - Version_script theora.exp - -libtheora_la_LDFLAGS = \ - -version-info @TH_LIB_CURRENT@:@TH_LIB_REVISION@:@TH_LIB_AGE@ \ - @THEORA_LDFLAGS@ @CAIRO_LIBS@ $(OGG_LIBS) - -subdir = lib -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -LTLIBRARIES = $(lib_LTLIBRARIES) - -libtheora_la_LIBADD = -am__objects_1 = mmxidct.lo mmxfrag.lo mmxstate.lo x86state.lo -@CPU_x86_32_FALSE@@CPU_x86_64_FALSE@am__objects_2 = -@CPU_x86_32_TRUE@@CPU_x86_64_FALSE@am__objects_2 = $(am__objects_1) -@CPU_x86_64_TRUE@am__objects_2 = $(am__objects_1) -am__objects_3 = apiwrapper.lo bitpack.lo decapiwrapper.lo decinfo.lo \ - decode.lo dequant.lo fragment.lo huffdec.lo idct.lo info.lo \ - internal.lo quant.lo state.lo $(am__objects_2) -@THEORA_DISABLE_ENCODE_FALSE@am__objects_4 = mmxencfrag.lo mmxfdct.lo \ -@THEORA_DISABLE_ENCODE_FALSE@ x86enc.lo -@THEORA_DISABLE_ENCODE_FALSE@am__objects_5 = sse2fdct.lo -@CPU_x86_32_FALSE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@am__objects_6 = -@CPU_x86_32_TRUE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@am__objects_6 = \ -@CPU_x86_32_TRUE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@ $(am__objects_4) -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@am__objects_6 = \ -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@ $(am__objects_4) \ -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@ $(am__objects_5) -@THEORA_DISABLE_ENCODE_TRUE@am__objects_7 = encoder_disabled.lo -@THEORA_DISABLE_ENCODE_FALSE@am__objects_7 = analyze.lo fdct.lo \ -@THEORA_DISABLE_ENCODE_FALSE@ encfrag.lo encapiwrapper.lo \ -@THEORA_DISABLE_ENCODE_FALSE@ encinfo.lo encode.lo enquant.lo \ -@THEORA_DISABLE_ENCODE_FALSE@ huffenc.lo mathops.lo mcenc.lo \ -@THEORA_DISABLE_ENCODE_FALSE@ rate.lo tokenize.lo \ -@THEORA_DISABLE_ENCODE_FALSE@ $(am__objects_6) -am_libtheora_la_OBJECTS = $(am__objects_3) $(am__objects_7) -libtheora_la_OBJECTS = $(am_libtheora_la_OBJECTS) -libtheoradec_la_LIBADD = -am_libtheoradec_la_OBJECTS = $(am__objects_3) -libtheoradec_la_OBJECTS = $(am_libtheoradec_la_OBJECTS) -libtheoraenc_la_LIBADD = -@THEORA_DISABLE_ENCODE_FALSE@am__objects_8 = mmxfrag.lo mmxidct.lo \ -@THEORA_DISABLE_ENCODE_FALSE@ mmxstate.lo x86state.lo -@THEORA_DISABLE_ENCODE_FALSE@am__objects_9 = -@CPU_x86_32_FALSE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@am__objects_10 = -@CPU_x86_32_TRUE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@am__objects_10 = \ -@CPU_x86_32_TRUE@@CPU_x86_64_FALSE@@THEORA_DISABLE_ENCODE_FALSE@ $(am__objects_8) -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@am__objects_10 = \ -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@ $(am__objects_8) \ -@CPU_x86_64_TRUE@@THEORA_DISABLE_ENCODE_FALSE@ $(am__objects_9) -@THEORA_DISABLE_ENCODE_TRUE@am__objects_11 = $(am__objects_7) -@THEORA_DISABLE_ENCODE_FALSE@am__objects_11 = apiwrapper.lo fragment.lo \ -@THEORA_DISABLE_ENCODE_FALSE@ idct.lo internal.lo state.lo \ -@THEORA_DISABLE_ENCODE_FALSE@ quant.lo $(am__objects_10) \ -@THEORA_DISABLE_ENCODE_FALSE@ $(am__objects_7) -am_libtheoraenc_la_OBJECTS = $(am__objects_11) -libtheoraenc_la_OBJECTS = $(am_libtheoraenc_la_OBJECTS) - -DEFS = @DEFS@ -DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/analyze.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/apiwrapper.Plo ./$(DEPDIR)/bitpack.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/decapiwrapper.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/decinfo.Plo ./$(DEPDIR)/decode.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/dequant.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/encapiwrapper.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/encfrag.Plo ./$(DEPDIR)/encinfo.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/encode.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/encoder_disabled.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/enquant.Plo ./$(DEPDIR)/fdct.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/fragment.Plo ./$(DEPDIR)/huffdec.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/huffenc.Plo ./$(DEPDIR)/idct.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/info.Plo ./$(DEPDIR)/internal.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/mathops.Plo ./$(DEPDIR)/mcenc.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/mmxencfrag.Plo ./$(DEPDIR)/mmxfdct.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/mmxfrag.Plo ./$(DEPDIR)/mmxidct.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/mmxstate.Plo ./$(DEPDIR)/quant.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/rate.Plo ./$(DEPDIR)/sse2fdct.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/state.Plo ./$(DEPDIR)/tokenize.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/x86enc.Plo ./$(DEPDIR)/x86state.Plo -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ - $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -CFLAGS = @CFLAGS@ -DIST_SOURCES = $(libtheora_la_SOURCES) $(libtheoradec_la_SOURCES) \ - $(libtheoraenc_la_SOURCES) -HEADERS = $(noinst_HEADERS) - -DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in -SOURCES = $(libtheora_la_SOURCES) $(libtheoradec_la_SOURCES) $(libtheoraenc_la_SOURCES) - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .def .exp .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu lib/Makefile -Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) -libLTLIBRARIES_INSTALL = $(INSTALL) -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(libdir) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \ - $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \ - else :; fi; \ - done - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - p="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \ - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test -z "$dir" && dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done -mmxidct.lo: x86/mmxidct.c -mmxfrag.lo: x86/mmxfrag.c -mmxstate.lo: x86/mmxstate.c -x86state.lo: x86/x86state.c -mmxencfrag.lo: x86/mmxencfrag.c -mmxfdct.lo: x86/mmxfdct.c -x86enc.lo: x86/x86enc.c -sse2fdct.lo: x86/sse2fdct.c -libtheora.la: $(libtheora_la_OBJECTS) $(libtheora_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libtheora_la_LDFLAGS) $(libtheora_la_OBJECTS) $(libtheora_la_LIBADD) $(LIBS) -libtheoradec.la: $(libtheoradec_la_OBJECTS) $(libtheoradec_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libtheoradec_la_LDFLAGS) $(libtheoradec_la_OBJECTS) $(libtheoradec_la_LIBADD) $(LIBS) -libtheoraenc.la: $(libtheoraenc_la_OBJECTS) $(libtheoraenc_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libtheoraenc_la_LDFLAGS) $(libtheoraenc_la_OBJECTS) $(libtheoraenc_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) core *.core - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analyze.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apiwrapper.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitpack.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decapiwrapper.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decinfo.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decode.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dequant.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encapiwrapper.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encfrag.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encinfo.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encoder_disabled.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enquant.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdct.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fragment.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/huffdec.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/huffenc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idct.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/internal.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mathops.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mcenc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmxencfrag.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmxfdct.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmxfrag.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmxidct.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmxstate.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quant.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rate.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sse2fdct.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/state.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tokenize.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86enc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86state.Plo@am__quote@ - -distclean-depend: - -rm -rf ./$(DEPDIR) - -.c.o: -@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< - -.c.obj: -@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(COMPILE) -c `cygpath -w $<` - -.c.lo: -@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< - -mmxidct.o: x86/mmxidct.c -@AMDEP_TRUE@ source='x86/mmxidct.c' object='mmxidct.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxidct.Po' tmpdepfile='$(DEPDIR)/mmxidct.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxidct.o `test -f 'x86/mmxidct.c' || echo '$(srcdir)/'`x86/mmxidct.c - -mmxidct.obj: x86/mmxidct.c -@AMDEP_TRUE@ source='x86/mmxidct.c' object='mmxidct.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxidct.Po' tmpdepfile='$(DEPDIR)/mmxidct.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxidct.obj `cygpath -w x86/mmxidct.c` - -mmxidct.lo: x86/mmxidct.c -@AMDEP_TRUE@ source='x86/mmxidct.c' object='mmxidct.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxidct.Plo' tmpdepfile='$(DEPDIR)/mmxidct.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxidct.lo `test -f 'x86/mmxidct.c' || echo '$(srcdir)/'`x86/mmxidct.c - -mmxfrag.o: x86/mmxfrag.c -@AMDEP_TRUE@ source='x86/mmxfrag.c' object='mmxfrag.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxfrag.Po' tmpdepfile='$(DEPDIR)/mmxfrag.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxfrag.o `test -f 'x86/mmxfrag.c' || echo '$(srcdir)/'`x86/mmxfrag.c - -mmxfrag.obj: x86/mmxfrag.c -@AMDEP_TRUE@ source='x86/mmxfrag.c' object='mmxfrag.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxfrag.Po' tmpdepfile='$(DEPDIR)/mmxfrag.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxfrag.obj `cygpath -w x86/mmxfrag.c` - -mmxfrag.lo: x86/mmxfrag.c -@AMDEP_TRUE@ source='x86/mmxfrag.c' object='mmxfrag.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxfrag.Plo' tmpdepfile='$(DEPDIR)/mmxfrag.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxfrag.lo `test -f 'x86/mmxfrag.c' || echo '$(srcdir)/'`x86/mmxfrag.c - -mmxstate.o: x86/mmxstate.c -@AMDEP_TRUE@ source='x86/mmxstate.c' object='mmxstate.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxstate.Po' tmpdepfile='$(DEPDIR)/mmxstate.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxstate.o `test -f 'x86/mmxstate.c' || echo '$(srcdir)/'`x86/mmxstate.c - -mmxstate.obj: x86/mmxstate.c -@AMDEP_TRUE@ source='x86/mmxstate.c' object='mmxstate.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxstate.Po' tmpdepfile='$(DEPDIR)/mmxstate.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxstate.obj `cygpath -w x86/mmxstate.c` - -mmxstate.lo: x86/mmxstate.c -@AMDEP_TRUE@ source='x86/mmxstate.c' object='mmxstate.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxstate.Plo' tmpdepfile='$(DEPDIR)/mmxstate.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxstate.lo `test -f 'x86/mmxstate.c' || echo '$(srcdir)/'`x86/mmxstate.c - -x86state.o: x86/x86state.c -@AMDEP_TRUE@ source='x86/x86state.c' object='x86state.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/x86state.Po' tmpdepfile='$(DEPDIR)/x86state.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o x86state.o `test -f 'x86/x86state.c' || echo '$(srcdir)/'`x86/x86state.c - -x86state.obj: x86/x86state.c -@AMDEP_TRUE@ source='x86/x86state.c' object='x86state.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/x86state.Po' tmpdepfile='$(DEPDIR)/x86state.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o x86state.obj `cygpath -w x86/x86state.c` - -x86state.lo: x86/x86state.c -@AMDEP_TRUE@ source='x86/x86state.c' object='x86state.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/x86state.Plo' tmpdepfile='$(DEPDIR)/x86state.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o x86state.lo `test -f 'x86/x86state.c' || echo '$(srcdir)/'`x86/x86state.c - -mmxencfrag.o: x86/mmxencfrag.c -@AMDEP_TRUE@ source='x86/mmxencfrag.c' object='mmxencfrag.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxencfrag.Po' tmpdepfile='$(DEPDIR)/mmxencfrag.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxencfrag.o `test -f 'x86/mmxencfrag.c' || echo '$(srcdir)/'`x86/mmxencfrag.c - -mmxencfrag.obj: x86/mmxencfrag.c -@AMDEP_TRUE@ source='x86/mmxencfrag.c' object='mmxencfrag.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxencfrag.Po' tmpdepfile='$(DEPDIR)/mmxencfrag.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxencfrag.obj `cygpath -w x86/mmxencfrag.c` - -mmxencfrag.lo: x86/mmxencfrag.c -@AMDEP_TRUE@ source='x86/mmxencfrag.c' object='mmxencfrag.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxencfrag.Plo' tmpdepfile='$(DEPDIR)/mmxencfrag.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxencfrag.lo `test -f 'x86/mmxencfrag.c' || echo '$(srcdir)/'`x86/mmxencfrag.c - -mmxfdct.o: x86/mmxfdct.c -@AMDEP_TRUE@ source='x86/mmxfdct.c' object='mmxfdct.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxfdct.Po' tmpdepfile='$(DEPDIR)/mmxfdct.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxfdct.o `test -f 'x86/mmxfdct.c' || echo '$(srcdir)/'`x86/mmxfdct.c - -mmxfdct.obj: x86/mmxfdct.c -@AMDEP_TRUE@ source='x86/mmxfdct.c' object='mmxfdct.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxfdct.Po' tmpdepfile='$(DEPDIR)/mmxfdct.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxfdct.obj `cygpath -w x86/mmxfdct.c` - -mmxfdct.lo: x86/mmxfdct.c -@AMDEP_TRUE@ source='x86/mmxfdct.c' object='mmxfdct.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/mmxfdct.Plo' tmpdepfile='$(DEPDIR)/mmxfdct.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mmxfdct.lo `test -f 'x86/mmxfdct.c' || echo '$(srcdir)/'`x86/mmxfdct.c - -x86enc.o: x86/x86enc.c -@AMDEP_TRUE@ source='x86/x86enc.c' object='x86enc.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/x86enc.Po' tmpdepfile='$(DEPDIR)/x86enc.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o x86enc.o `test -f 'x86/x86enc.c' || echo '$(srcdir)/'`x86/x86enc.c - -x86enc.obj: x86/x86enc.c -@AMDEP_TRUE@ source='x86/x86enc.c' object='x86enc.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/x86enc.Po' tmpdepfile='$(DEPDIR)/x86enc.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o x86enc.obj `cygpath -w x86/x86enc.c` - -x86enc.lo: x86/x86enc.c -@AMDEP_TRUE@ source='x86/x86enc.c' object='x86enc.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/x86enc.Plo' tmpdepfile='$(DEPDIR)/x86enc.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o x86enc.lo `test -f 'x86/x86enc.c' || echo '$(srcdir)/'`x86/x86enc.c - -sse2fdct.o: x86/sse2fdct.c -@AMDEP_TRUE@ source='x86/sse2fdct.c' object='sse2fdct.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/sse2fdct.Po' tmpdepfile='$(DEPDIR)/sse2fdct.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sse2fdct.o `test -f 'x86/sse2fdct.c' || echo '$(srcdir)/'`x86/sse2fdct.c - -sse2fdct.obj: x86/sse2fdct.c -@AMDEP_TRUE@ source='x86/sse2fdct.c' object='sse2fdct.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/sse2fdct.Po' tmpdepfile='$(DEPDIR)/sse2fdct.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sse2fdct.obj `cygpath -w x86/sse2fdct.c` - -sse2fdct.lo: x86/sse2fdct.c -@AMDEP_TRUE@ source='x86/sse2fdct.c' object='sse2fdct.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@ depfile='$(DEPDIR)/sse2fdct.Plo' tmpdepfile='$(DEPDIR)/sse2fdct.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sse2fdct.lo `test -f 'x86/sse2fdct.c' || echo '$(srcdir)/'`x86/sse2fdct.c -CCDEPMODE = @CCDEPMODE@ - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: - -ETAGS = etags -ETAGSFLAGS = - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$tags$$unique" \ - || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - -top_distdir = .. -distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) - -distdir: $(DISTFILES) - $(mkinstalldirs) $(distdir)/x86 - @list='$(DISTFILES)'; for file in $$list; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkinstalldirs) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) $(HEADERS) - -installdirs: - $(mkinstalldirs) $(DESTDIR)$(libdir) - -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ - mostlyclean-am - -distclean: distclean-am - -distclean-am: clean-am distclean-compile distclean-depend \ - distclean-generic distclean-libtool distclean-tags - -dvi: dvi-am - -dvi-am: - -info: info-am - -info-am: - -install-data-am: - -install-exec-am: install-libLTLIBRARIES - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES - -.PHONY: GTAGS all all-am check check-am clean clean-generic \ - clean-libLTLIBRARIES clean-libtool distclean distclean-compile \ - distclean-depend distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am info info-am install \ - install-am install-data install-data-am install-exec \ - install-exec-am install-info install-info-am \ - install-libLTLIBRARIES install-man install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool tags uninstall \ - uninstall-am uninstall-info-am uninstall-libLTLIBRARIES - - -debug: - $(MAKE) all CFLAGS="@DEBUG@" - -profile: - $(MAKE) all CFLAGS="@PROFILE@" - -# contstruct various symbol export list files -.def.exp : defexp.awk - awk -f defexp.awk $< > $@ -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/Engine/lib/libtheora/lib/Version_script b/Engine/lib/libtheora/lib/Version_script deleted file mode 100644 index 2ecb5e43a..000000000 --- a/Engine/lib/libtheora/lib/Version_script +++ /dev/null @@ -1,53 +0,0 @@ -# -# Export file for libtheora -# -# Only the symbols listed in the global section will be callable from -# applications linking to the libraries. -# - -# We use something that looks like a versioned so filename here -# to define the old API because of a historical confusion. This -# label must be kept to maintain ABI compatibility. - -libtheora.so.1.0 -{ - global: - theora_version_string; - theora_version_number; - - theora_encode_init; - theora_encode_YUVin; - theora_encode_packetout; - theora_encode_header; - theora_encode_comment; - theora_encode_tables; - - theora_decode_header; - theora_decode_init; - theora_decode_packetin; - theora_decode_YUVout; - - theora_control; - - theora_packet_isheader; - theora_packet_iskeyframe; - - theora_granule_shift; - theora_granule_frame; - theora_granule_time; - - theora_info_init; - theora_info_clear; - - theora_clear; - - theora_comment_init; - theora_comment_add; - theora_comment_add_tag; - theora_comment_query; - theora_comment_query_count; - theora_comment_clear; - - local: - *; -}; diff --git a/Engine/lib/libtheora/lib/Version_script-dec b/Engine/lib/libtheora/lib/Version_script-dec deleted file mode 100644 index cab368397..000000000 --- a/Engine/lib/libtheora/lib/Version_script-dec +++ /dev/null @@ -1,82 +0,0 @@ -# -# Export file for libtheoradec -# -# Only the symbols listed in the global section will be callable from -# applications linking to the libraries. -# - -# The 1.x API -libtheoradec_1.0 -{ - global: - th_version_string; - th_version_number; - - th_decode_headerin; - th_decode_alloc; - th_setup_free; - th_decode_ctl; - th_decode_packetin; - th_decode_ycbcr_out; - th_decode_free; - - th_packet_isheader; - th_packet_iskeyframe; - - th_granule_frame; - th_granule_time; - - th_info_init; - th_info_clear; - - th_comment_init; - th_comment_add; - th_comment_add_tag; - th_comment_query; - th_comment_query_count; - th_comment_clear; - - local: - *; -}; - -# The deprecated legacy api from the libtheora alpha releases. -# We use something that looks like a versioned so filename here -# to define the old API because of a historical confusion. This -# label must be kept to maintain ABI compatibility. - -libtheora.so.1.0 -{ - global: - theora_version_string; - theora_version_number; - - theora_decode_header; - theora_decode_init; - theora_decode_packetin; - theora_decode_YUVout; - - theora_control; - - theora_packet_isheader; - theora_packet_iskeyframe; - - theora_granule_shift; - theora_granule_frame; - theora_granule_time; - - theora_info_init; - theora_info_clear; - - theora_clear; - - theora_comment_init; - theora_comment_add; - theora_comment_add_tag; - theora_comment_query; - theora_comment_query_count; - theora_comment_clear; - - local: - *; -}; diff --git a/Engine/lib/libtheora/lib/Version_script-enc b/Engine/lib/libtheora/lib/Version_script-enc deleted file mode 100644 index 37699edd6..000000000 --- a/Engine/lib/libtheora/lib/Version_script-enc +++ /dev/null @@ -1,43 +0,0 @@ -# -# Export file for libtheora -# -# Only the symbols listed in the global section will be callable from -# applications linking to the libraries. -# - -# The 1.x encoder API -libtheoraenc_1.0 -{ - global: - th_encode_alloc; - th_encode_ctl; - th_encode_flushheader; - th_encode_ycbcr_in; - th_encode_packetout; - th_encode_free; - - TH_VP31_QUANT_INFO; - TH_VP31_HUFF_CODES; - - local: - *; -}; - -# The encoder portion of the deprecated alpha release api. -# We use something that looks like a versioned so filename here -# to define the old API because of a historical confusion. This -# label must be kept to maintain ABI compatibility. - -libtheora.so.1.0 -{ - global: - theora_encode_init; - theora_encode_YUVin; - theora_encode_packetout; - theora_encode_header; - theora_encode_comment; - theora_encode_tables; - - local: - *; -}; diff --git a/Engine/lib/libtheora/lib/analyze.c b/Engine/lib/libtheora/lib/analyze.c deleted file mode 100644 index af01b60df..000000000 --- a/Engine/lib/libtheora/lib/analyze.c +++ /dev/null @@ -1,2709 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: mode selection code - last mod: $Id$ - - ********************************************************************/ -#include -#include -#include "encint.h" -#include "modedec.h" - - - -typedef struct oc_fr_state oc_fr_state; -typedef struct oc_qii_state oc_qii_state; -typedef struct oc_enc_pipeline_state oc_enc_pipeline_state; -typedef struct oc_rd_metric oc_rd_metric; -typedef struct oc_mode_choice oc_mode_choice; - - - -/*There are 8 possible schemes used to encode macro block modes. - Schemes 0-6 use a maximally-skewed Huffman code to code each of the modes. - The same set of Huffman codes is used for each of these 7 schemes, but the - mode assigned to each codeword varies. - Scheme 0 writes a custom mapping from codeword to MB mode to the bitstream, - while schemes 1-6 have a fixed mapping. - Scheme 7 just encodes each mode directly in 3 bits.*/ - -/*The mode orderings for the various mode coding schemes. - Scheme 0 uses a custom alphabet, which is not stored in this table. - This is the inverse of the equivalent table OC_MODE_ALPHABETS in the - decoder.*/ -static const unsigned char OC_MODE_RANKS[7][OC_NMODES]={ - /*Last MV dominates.*/ - /*L P M N I G GM 4*/ - {3,4,2,0,1,5,6,7}, - /*L P N M I G GM 4*/ - {2,4,3,0,1,5,6,7}, - /*L M P N I G GM 4*/ - {3,4,1,0,2,5,6,7}, - /*L M N P I G GM 4*/ - {2,4,1,0,3,5,6,7}, - /*No MV dominates.*/ - /*N L P M I G GM 4*/ - {0,4,3,1,2,5,6,7}, - /*N G L P M I GM 4*/ - {0,5,4,2,3,1,6,7}, - /*Default ordering.*/ - /*N I M L P G GM 4*/ - {0,1,2,3,4,5,6,7} -}; - - - -/*Initialize the mode scheme chooser. - This need only be called once per encoder.*/ -void oc_mode_scheme_chooser_init(oc_mode_scheme_chooser *_chooser){ - int si; - _chooser->mode_ranks[0]=_chooser->scheme0_ranks; - for(si=1;si<8;si++)_chooser->mode_ranks[si]=OC_MODE_RANKS[si-1]; -} - -/*Reset the mode scheme chooser. - This needs to be called once for each frame, including the first.*/ -static void oc_mode_scheme_chooser_reset(oc_mode_scheme_chooser *_chooser){ - int si; - memset(_chooser->mode_counts,0,OC_NMODES*sizeof(*_chooser->mode_counts)); - /*Scheme 0 starts with 24 bits to store the mode list in.*/ - _chooser->scheme_bits[0]=24; - memset(_chooser->scheme_bits+1,0,7*sizeof(*_chooser->scheme_bits)); - for(si=0;si<8;si++){ - /*Scheme 7 should always start first, and scheme 0 should always start - last.*/ - _chooser->scheme_list[si]=7-si; - _chooser->scheme0_list[si]=_chooser->scheme0_ranks[si]=si; - } -} - - -/*This is the real purpose of this data structure: not actually selecting a - mode scheme, but estimating the cost of coding a given mode given all the - modes selected so far. - This is done via opportunity cost: the cost is defined as the number of bits - required to encode all the modes selected so far including the current one - using the best possible scheme, minus the number of bits required to encode - all the modes selected so far not including the current one using the best - possible scheme. - The computational expense of doing this probably makes it overkill. - Just be happy we take a greedy approach instead of trying to solve the - global mode-selection problem (which is NP-hard). - _mb_mode: The mode to determine the cost of. - Return: The number of bits required to code this mode.*/ -static int oc_mode_scheme_chooser_cost(oc_mode_scheme_chooser *_chooser, - int _mb_mode){ - int scheme0; - int scheme1; - int best_bits; - int mode_bits; - int si; - int scheme_bits; - scheme0=_chooser->scheme_list[0]; - scheme1=_chooser->scheme_list[1]; - best_bits=_chooser->scheme_bits[scheme0]; - mode_bits=OC_MODE_BITS[scheme0+1>>3][_chooser->mode_ranks[scheme0][_mb_mode]]; - /*Typical case: If the difference between the best scheme and the next best - is greater than 6 bits, then adding just one mode cannot change which - scheme we use.*/ - if(_chooser->scheme_bits[scheme1]-best_bits>6)return mode_bits; - /*Otherwise, check to see if adding this mode selects a different scheme as - the best.*/ - si=1; - best_bits+=mode_bits; - do{ - /*For any scheme except 0, we can just use the bit cost of the mode's rank - in that scheme.*/ - if(scheme1!=0){ - scheme_bits=_chooser->scheme_bits[scheme1]+ - OC_MODE_BITS[scheme1+1>>3][_chooser->mode_ranks[scheme1][_mb_mode]]; - } - else{ - int ri; - /*For scheme 0, incrementing the mode count could potentially change the - mode's rank. - Find the index where the mode would be moved to in the optimal list, - and use its bit cost instead of the one for the mode's current - position in the list.*/ - /*We don't recompute scheme bits; this is computing opportunity cost, not - an update.*/ - for(ri=_chooser->scheme0_ranks[_mb_mode];ri>0&& - _chooser->mode_counts[_mb_mode]>= - _chooser->mode_counts[_chooser->scheme0_list[ri-1]];ri--); - scheme_bits=_chooser->scheme_bits[0]+OC_MODE_BITS[0][ri]; - } - if(scheme_bits=8)break; - scheme1=_chooser->scheme_list[si]; - } - while(_chooser->scheme_bits[scheme1]-_chooser->scheme_bits[scheme0]<=6); - return best_bits-_chooser->scheme_bits[scheme0]; -} - -/*Incrementally update the mode counts and per-scheme bit counts and re-order - the scheme lists once a mode has been selected. - _mb_mode: The mode that was chosen.*/ -static void oc_mode_scheme_chooser_update(oc_mode_scheme_chooser *_chooser, - int _mb_mode){ - int ri; - int si; - _chooser->mode_counts[_mb_mode]++; - /*Re-order the scheme0 mode list if necessary.*/ - for(ri=_chooser->scheme0_ranks[_mb_mode];ri>0;ri--){ - int pmode; - pmode=_chooser->scheme0_list[ri-1]; - if(_chooser->mode_counts[pmode]>=_chooser->mode_counts[_mb_mode])break; - /*Reorder the mode ranking.*/ - _chooser->scheme0_ranks[pmode]++; - _chooser->scheme0_list[ri]=pmode; - } - _chooser->scheme0_ranks[_mb_mode]=ri; - _chooser->scheme0_list[ri]=_mb_mode; - /*Now add the bit cost for the mode to each scheme.*/ - for(si=0;si<8;si++){ - _chooser->scheme_bits[si]+= - OC_MODE_BITS[si+1>>3][_chooser->mode_ranks[si][_mb_mode]]; - } - /*Finally, re-order the list of schemes.*/ - for(si=1;si<8;si++){ - int sj; - int scheme0; - int bits0; - sj=si; - scheme0=_chooser->scheme_list[si]; - bits0=_chooser->scheme_bits[scheme0]; - do{ - int scheme1; - scheme1=_chooser->scheme_list[sj-1]; - if(bits0>=_chooser->scheme_bits[scheme1])break; - _chooser->scheme_list[sj]=scheme1; - } - while(--sj>0); - _chooser->scheme_list[sj]=scheme0; - } -} - - - -/*The number of bits required to encode a super block run. - _run_count: The desired run count; must be positive and less than 4130.*/ -static int oc_sb_run_bits(int _run_count){ - int i; - for(i=0;_run_count>=OC_SB_RUN_VAL_MIN[i+1];i++); - return OC_SB_RUN_CODE_NBITS[i]; -} - -/*The number of bits required to encode a block run. - _run_count: The desired run count; must be positive and less than 30.*/ -static int oc_block_run_bits(int _run_count){ - return OC_BLOCK_RUN_CODE_NBITS[_run_count-1]; -} - - - -/*State to track coded block flags and their bit cost.*/ -struct oc_fr_state{ - ptrdiff_t bits; - unsigned sb_partial_count:16; - unsigned sb_full_count:16; - unsigned b_coded_count_prev:8; - unsigned b_coded_count:8; - unsigned b_count:8; - signed int sb_partial:2; - signed int sb_full:2; - signed int b_coded_prev:2; - signed int b_coded:2; -}; - - - -static void oc_fr_state_init(oc_fr_state *_fr){ - _fr->bits=0; - _fr->sb_partial_count=0; - _fr->sb_full_count=0; - _fr->b_coded_count_prev=0; - _fr->b_coded_count=0; - _fr->b_count=0; - _fr->sb_partial=-1; - _fr->sb_full=-1; - _fr->b_coded_prev=-1; - _fr->b_coded=-1; -} - - -static void oc_fr_state_advance_sb(oc_fr_state *_fr, - int _sb_partial,int _sb_full){ - ptrdiff_t bits; - int sb_partial_count; - int sb_full_count; - bits=_fr->bits; - /*Extend the sb_partial run, or start a new one.*/ - sb_partial_count=_fr->sb_partial; - if(_fr->sb_partial==_sb_partial){ - if(sb_partial_count>=4129){ - bits++; - sb_partial_count=0; - } - else bits-=oc_sb_run_bits(sb_partial_count); - } - else sb_partial_count=0; - sb_partial_count++; - bits+=oc_sb_run_bits(sb_partial_count); - if(!_sb_partial){ - /*Extend the sb_full run, or start a new one.*/ - sb_full_count=_fr->sb_full_count; - if(_fr->sb_full==_sb_full){ - if(sb_full_count>=4129){ - bits++; - sb_full_count=0; - } - else bits-=oc_sb_run_bits(sb_full_count); - } - else sb_full_count=0; - sb_full_count++; - bits+=oc_sb_run_bits(sb_full_count); - _fr->sb_full=_sb_full; - _fr->sb_full_count=sb_full_count; - } - _fr->bits=bits; - _fr->sb_partial=_sb_partial; - _fr->sb_partial_count=sb_partial_count; -} - -/*Flush any outstanding block flags for a SB (e.g., one with fewer than 16 - blocks).*/ -static void oc_fr_state_flush_sb(oc_fr_state *_fr){ - ptrdiff_t bits; - int sb_partial; - int sb_full=sb_full; - int b_coded_count; - int b_coded; - int b_count; - b_count=_fr->b_count; - if(b_count>0){ - bits=_fr->bits; - b_coded=_fr->b_coded; - b_coded_count=_fr->b_coded_count; - if(b_coded_count>=b_count){ - /*This SB was fully coded/uncoded; roll back the partial block flags.*/ - bits-=oc_block_run_bits(b_coded_count); - if(b_coded_count>b_count)bits+=oc_block_run_bits(b_coded_count-b_count); - sb_partial=0; - sb_full=b_coded; - b_coded=_fr->b_coded_prev; - b_coded_count=_fr->b_coded_count_prev; - } - else{ - /*It was partially coded.*/ - sb_partial=1; - /*sb_full is unused.*/ - } - _fr->bits=bits; - _fr->b_coded_count=b_coded_count; - _fr->b_coded_count_prev=b_coded_count; - _fr->b_count=0; - _fr->b_coded=b_coded; - _fr->b_coded_prev=b_coded; - oc_fr_state_advance_sb(_fr,sb_partial,sb_full); - } -} - -static void oc_fr_state_advance_block(oc_fr_state *_fr,int _b_coded){ - ptrdiff_t bits; - int b_coded_count; - int b_count; - int sb_partial; - int sb_full=sb_full; - bits=_fr->bits; - /*Extend the b_coded run, or start a new one.*/ - b_coded_count=_fr->b_coded_count; - if(_fr->b_coded==_b_coded)bits-=oc_block_run_bits(b_coded_count); - else b_coded_count=0; - b_coded_count++; - b_count=_fr->b_count+1; - if(b_count>=16){ - /*We finished a superblock.*/ - if(b_coded_count>=16){ - /*It was fully coded/uncoded; roll back the partial block flags.*/ - if(b_coded_count>16)bits+=oc_block_run_bits(b_coded_count-16); - sb_partial=0; - sb_full=_b_coded; - _b_coded=_fr->b_coded_prev; - b_coded_count=_fr->b_coded_count_prev; - } - else{ - bits+=oc_block_run_bits(b_coded_count); - /*It was partially coded.*/ - sb_partial=1; - /*sb_full is unused.*/ - } - _fr->bits=bits; - _fr->b_coded_count=b_coded_count; - _fr->b_coded_count_prev=b_coded_count; - _fr->b_count=0; - _fr->b_coded=_b_coded; - _fr->b_coded_prev=_b_coded; - oc_fr_state_advance_sb(_fr,sb_partial,sb_full); - } - else{ - bits+=oc_block_run_bits(b_coded_count); - _fr->bits=bits; - _fr->b_coded_count=b_coded_count; - _fr->b_count=b_count; - _fr->b_coded=_b_coded; - } -} - -static void oc_fr_skip_block(oc_fr_state *_fr){ - oc_fr_state_advance_block(_fr,0); -} - -static void oc_fr_code_block(oc_fr_state *_fr){ - oc_fr_state_advance_block(_fr,1); -} - -static int oc_fr_cost1(const oc_fr_state *_fr){ - oc_fr_state tmp; - ptrdiff_t bits; - *&tmp=*_fr; - oc_fr_skip_block(&tmp); - bits=tmp.bits; - *&tmp=*_fr; - oc_fr_code_block(&tmp); - return (int)(tmp.bits-bits); -} - -static int oc_fr_cost4(const oc_fr_state *_pre,const oc_fr_state *_post){ - oc_fr_state tmp; - *&tmp=*_pre; - oc_fr_skip_block(&tmp); - oc_fr_skip_block(&tmp); - oc_fr_skip_block(&tmp); - oc_fr_skip_block(&tmp); - return (int)(_post->bits-tmp.bits); -} - - - -struct oc_qii_state{ - ptrdiff_t bits; - unsigned qi01_count:14; - signed int qi01:2; - unsigned qi12_count:14; - signed int qi12:2; -}; - - - -static void oc_qii_state_init(oc_qii_state *_qs){ - _qs->bits=0; - _qs->qi01_count=0; - _qs->qi01=-1; - _qs->qi12_count=0; - _qs->qi12=-1; -} - - -static void oc_qii_state_advance(oc_qii_state *_qd, - const oc_qii_state *_qs,int _qii){ - ptrdiff_t bits; - int qi01; - int qi01_count; - int qi12; - int qi12_count; - bits=_qs->bits; - qi01=_qii+1>>1; - qi01_count=_qs->qi01_count; - if(qi01==_qs->qi01){ - if(qi01_count>=4129){ - bits++; - qi01_count=0; - } - else bits-=oc_sb_run_bits(qi01_count); - } - else qi01_count=0; - qi01_count++; - bits+=oc_sb_run_bits(qi01_count); - qi12_count=_qs->qi12_count; - if(_qii){ - qi12=_qii>>1; - if(qi12==_qs->qi12){ - if(qi12_count>=4129){ - bits++; - qi12_count=0; - } - else bits-=oc_sb_run_bits(qi12_count); - } - else qi12_count=0; - qi12_count++; - bits+=oc_sb_run_bits(qi12_count); - } - else qi12=_qs->qi12; - _qd->bits=bits; - _qd->qi01=qi01; - _qd->qi01_count=qi01_count; - _qd->qi12=qi12; - _qd->qi12_count=qi12_count; -} - - - -/*Temporary encoder state for the analysis pipeline.*/ -struct oc_enc_pipeline_state{ - int bounding_values[256]; - oc_fr_state fr[3]; - oc_qii_state qs[3]; - /*Condensed dequantization tables.*/ - const ogg_uint16_t *dequant[3][3][2]; - /*Condensed quantization tables.*/ - const oc_iquant *enquant[3][3][2]; - /*Skip SSD storage for the current MCU in each plane.*/ - unsigned *skip_ssd[3]; - /*Coded/uncoded fragment lists for each plane for the current MCU.*/ - ptrdiff_t *coded_fragis[3]; - ptrdiff_t *uncoded_fragis[3]; - ptrdiff_t ncoded_fragis[3]; - ptrdiff_t nuncoded_fragis[3]; - /*The starting fragment for the current MCU in each plane.*/ - ptrdiff_t froffset[3]; - /*The starting row for the current MCU in each plane.*/ - int fragy0[3]; - /*The ending row for the current MCU in each plane.*/ - int fragy_end[3]; - /*The starting superblock for the current MCU in each plane.*/ - unsigned sbi0[3]; - /*The ending superblock for the current MCU in each plane.*/ - unsigned sbi_end[3]; - /*The number of tokens for zzi=1 for each color plane.*/ - int ndct_tokens1[3]; - /*The outstanding eob_run count for zzi=1 for each color plane.*/ - int eob_run1[3]; - /*Whether or not the loop filter is enabled.*/ - int loop_filter; -}; - - -static void oc_enc_pipeline_init(oc_enc_ctx *_enc,oc_enc_pipeline_state *_pipe){ - ptrdiff_t *coded_fragis; - unsigned mcu_nvsbs; - ptrdiff_t mcu_nfrags; - int hdec; - int vdec; - int pli; - int qii; - int qti; - /*Initialize the per-plane coded block flag trackers. - These are used for bit-estimation purposes only; the real flag bits span - all three planes, so we can't compute them in parallel.*/ - for(pli=0;pli<3;pli++)oc_fr_state_init(_pipe->fr+pli); - for(pli=0;pli<3;pli++)oc_qii_state_init(_pipe->qs+pli); - /*Set up the per-plane skip SSD storage pointers.*/ - mcu_nvsbs=_enc->mcu_nvsbs; - mcu_nfrags=mcu_nvsbs*_enc->state.fplanes[0].nhsbs*16; - hdec=!(_enc->state.info.pixel_fmt&1); - vdec=!(_enc->state.info.pixel_fmt&2); - _pipe->skip_ssd[0]=_enc->mcu_skip_ssd; - _pipe->skip_ssd[1]=_pipe->skip_ssd[0]+mcu_nfrags; - _pipe->skip_ssd[2]=_pipe->skip_ssd[1]+(mcu_nfrags>>hdec+vdec); - /*Set up per-plane pointers to the coded and uncoded fragments lists. - Unlike the decoder, each planes' coded and uncoded fragment list is kept - separate during the analysis stage; we only make the coded list for all - three planes contiguous right before the final packet is output - (destroying the uncoded lists, which are no longer needed).*/ - coded_fragis=_enc->state.coded_fragis; - for(pli=0;pli<3;pli++){ - _pipe->coded_fragis[pli]=coded_fragis; - coded_fragis+=_enc->state.fplanes[pli].nfrags; - _pipe->uncoded_fragis[pli]=coded_fragis; - } - memset(_pipe->ncoded_fragis,0,sizeof(_pipe->ncoded_fragis)); - memset(_pipe->nuncoded_fragis,0,sizeof(_pipe->nuncoded_fragis)); - /*Set up condensed quantizer tables.*/ - for(pli=0;pli<3;pli++){ - for(qii=0;qii<_enc->state.nqis;qii++){ - int qi; - qi=_enc->state.qis[qii]; - for(qti=0;qti<2;qti++){ - _pipe->dequant[pli][qii][qti]=_enc->state.dequant_tables[qi][pli][qti]; - _pipe->enquant[pli][qii][qti]=_enc->enquant_tables[qi][pli][qti]; - } - } - } - /*Initialize the tokenization state.*/ - for(pli=0;pli<3;pli++){ - _pipe->ndct_tokens1[pli]=0; - _pipe->eob_run1[pli]=0; - } - /*Initialize the bounding value array for the loop filter.*/ - _pipe->loop_filter=!oc_state_loop_filter_init(&_enc->state, - _pipe->bounding_values); -} - -/*Sets the current MCU stripe to super block row _sby. - Return: A non-zero value if this was the last MCU.*/ -static int oc_enc_pipeline_set_stripe(oc_enc_ctx *_enc, - oc_enc_pipeline_state *_pipe,int _sby){ - const oc_fragment_plane *fplane; - unsigned mcu_nvsbs; - int sby_end; - int notdone; - int vdec; - int pli; - mcu_nvsbs=_enc->mcu_nvsbs; - sby_end=_enc->state.fplanes[0].nvsbs; - notdone=_sby+mcu_nvsbsstate.fplanes+pli; - _pipe->sbi0[pli]=fplane->sboffset+(_sby>>vdec)*fplane->nhsbs; - _pipe->fragy0[pli]=_sby<<2-vdec; - _pipe->froffset[pli]=fplane->froffset - +_pipe->fragy0[pli]*(ptrdiff_t)fplane->nhfrags; - if(notdone){ - _pipe->sbi_end[pli]=fplane->sboffset+(sby_end>>vdec)*fplane->nhsbs; - _pipe->fragy_end[pli]=sby_end<<2-vdec; - } - else{ - _pipe->sbi_end[pli]=fplane->sboffset+fplane->nsbs; - _pipe->fragy_end[pli]=fplane->nvfrags; - } - vdec=!(_enc->state.info.pixel_fmt&2); - } - return notdone; -} - -static void oc_enc_pipeline_finish_mcu_plane(oc_enc_ctx *_enc, - oc_enc_pipeline_state *_pipe,int _pli,int _sdelay,int _edelay){ - int refi; - /*Copy over all the uncoded fragments from this plane and advance the uncoded - fragment list.*/ - _pipe->uncoded_fragis[_pli]-=_pipe->nuncoded_fragis[_pli]; - oc_state_frag_copy_list(&_enc->state,_pipe->uncoded_fragis[_pli], - _pipe->nuncoded_fragis[_pli],OC_FRAME_SELF,OC_FRAME_PREV,_pli); - _pipe->nuncoded_fragis[_pli]=0; - /*Perform DC prediction.*/ - oc_enc_pred_dc_frag_rows(_enc,_pli, - _pipe->fragy0[_pli],_pipe->fragy_end[_pli]); - /*Finish DC tokenization.*/ - oc_enc_tokenize_dc_frag_list(_enc,_pli, - _pipe->coded_fragis[_pli],_pipe->ncoded_fragis[_pli], - _pipe->ndct_tokens1[_pli],_pipe->eob_run1[_pli]); - _pipe->ndct_tokens1[_pli]=_enc->ndct_tokens[_pli][1]; - _pipe->eob_run1[_pli]=_enc->eob_run[_pli][1]; - /*And advance the coded fragment list.*/ - _enc->state.ncoded_fragis[_pli]+=_pipe->ncoded_fragis[_pli]; - _pipe->coded_fragis[_pli]+=_pipe->ncoded_fragis[_pli]; - _pipe->ncoded_fragis[_pli]=0; - /*Apply the loop filter if necessary.*/ - refi=_enc->state.ref_frame_idx[OC_FRAME_SELF]; - if(_pipe->loop_filter){ - oc_state_loop_filter_frag_rows(&_enc->state,_pipe->bounding_values, - refi,_pli,_pipe->fragy0[_pli]-_sdelay,_pipe->fragy_end[_pli]-_edelay); - } - else _sdelay=_edelay=0; - /*To fill borders, we have an additional two pixel delay, since a fragment - in the next row could filter its top edge, using two pixels from a - fragment in this row. - But there's no reason to delay a full fragment between the two.*/ - oc_state_borders_fill_rows(&_enc->state,refi,_pli, - (_pipe->fragy0[_pli]-_sdelay<<3)-(_sdelay<<1), - (_pipe->fragy_end[_pli]-_edelay<<3)-(_edelay<<1)); -} - - - -/*Cost information about the coded blocks in a MB.*/ -struct oc_rd_metric{ - int uncoded_ac_ssd; - int coded_ac_ssd; - int ac_bits; - int dc_flag; -}; - - - -static int oc_enc_block_transform_quantize(oc_enc_ctx *_enc, - oc_enc_pipeline_state *_pipe,int _pli,ptrdiff_t _fragi,int _overhead_bits, - oc_rd_metric *_mo,oc_token_checkpoint **_stack){ - OC_ALIGN16(ogg_int16_t dct[64]); - OC_ALIGN16(ogg_int16_t data[64]); - ogg_uint16_t dc_dequant; - const ogg_uint16_t *dequant; - const oc_iquant *enquant; - ptrdiff_t frag_offs; - int ystride; - const unsigned char *src; - const unsigned char *ref; - unsigned char *dst; - int frame_type; - int nonzero; - unsigned uncoded_ssd; - unsigned coded_ssd; - int coded_dc; - oc_token_checkpoint *checkpoint; - oc_fragment *frags; - int mb_mode; - int mv_offs[2]; - int nmv_offs; - int ac_bits; - int borderi; - int qti; - int qii; - int pi; - int zzi; - int v; - int val; - int d; - int s; - int dc; - frags=_enc->state.frags; - frag_offs=_enc->state.frag_buf_offs[_fragi]; - ystride=_enc->state.ref_ystride[_pli]; - src=_enc->state.ref_frame_data[OC_FRAME_IO]+frag_offs; - borderi=frags[_fragi].borderi; - qii=frags[_fragi].qii; - if(qii&~3){ -#if !defined(OC_COLLECT_METRICS) - if(_enc->sp_level>=OC_SP_LEVEL_EARLY_SKIP){ - /*Enable early skip detection.*/ - frags[_fragi].coded=0; - return 0; - } -#endif - /*Try and code this block anyway.*/ - qii&=3; - frags[_fragi].qii=qii; - } - mb_mode=frags[_fragi].mb_mode; - ref=_enc->state.ref_frame_data[ - _enc->state.ref_frame_idx[OC_FRAME_FOR_MODE(mb_mode)]]+frag_offs; - dst=_enc->state.ref_frame_data[_enc->state.ref_frame_idx[OC_FRAME_SELF]] - +frag_offs; - /*Motion compensation:*/ - switch(mb_mode){ - case OC_MODE_INTRA:{ - nmv_offs=0; - oc_enc_frag_sub_128(_enc,data,src,ystride); - }break; - case OC_MODE_GOLDEN_NOMV: - case OC_MODE_INTER_NOMV:{ - nmv_offs=1; - mv_offs[0]=0; - oc_enc_frag_sub(_enc,data,src,ref,ystride); - }break; - default:{ - const oc_mv *frag_mvs; - frag_mvs=(const oc_mv *)_enc->state.frag_mvs; - nmv_offs=oc_state_get_mv_offsets(&_enc->state,mv_offs,_pli, - frag_mvs[_fragi][0],frag_mvs[_fragi][1]); - if(nmv_offs>1){ - oc_enc_frag_copy2(_enc,dst, - ref+mv_offs[0],ref+mv_offs[1],ystride); - oc_enc_frag_sub(_enc,data,src,dst,ystride); - } - else oc_enc_frag_sub(_enc,data,src,ref+mv_offs[0],ystride); - }break; - } -#if defined(OC_COLLECT_METRICS) - { - unsigned satd; - switch(nmv_offs){ - case 0:satd=oc_enc_frag_intra_satd(_enc,src,ystride);break; - case 1:{ - satd=oc_enc_frag_satd_thresh(_enc,src,ref+mv_offs[0],ystride,UINT_MAX); - }break; - default:{ - satd=oc_enc_frag_satd_thresh(_enc,src,dst,ystride,UINT_MAX); - } - } - _enc->frag_satd[_fragi]=satd; - } -#endif - /*Transform:*/ - oc_enc_fdct8x8(_enc,dct,data); - /*Quantize the DC coefficient:*/ - qti=mb_mode!=OC_MODE_INTRA; - enquant=_pipe->enquant[_pli][0][qti]; - dc_dequant=_pipe->dequant[_pli][0][qti][0]; - v=dct[0]; - val=v<<1; - s=OC_SIGNMASK(val); - val+=dc_dequant+s^s; - val=((enquant[0].m*(ogg_int32_t)val>>16)+val>>enquant[0].l)-s; - dc=OC_CLAMPI(-580,val,580); - nonzero=0; - /*Quantize the AC coefficients:*/ - dequant=_pipe->dequant[_pli][qii][qti]; - enquant=_pipe->enquant[_pli][qii][qti]; - for(zzi=1;zzi<64;zzi++){ - v=dct[OC_FZIG_ZAG[zzi]]; - d=dequant[zzi]; - val=v<<1; - v=abs(val); - if(v>=d){ - s=OC_SIGNMASK(val); - /*The bias added here rounds ties away from zero, since token - optimization can only decrease the magnitude of the quantized - value.*/ - val+=d+s^s; - /*Note the arithmetic right shift is not guaranteed by ANSI C. - Hopefully no one still uses ones-complement architectures.*/ - val=((enquant[zzi].m*(ogg_int32_t)val>>16)+val>>enquant[zzi].l)-s; - data[zzi]=OC_CLAMPI(-580,val,580); - nonzero=zzi; - } - else data[zzi]=0; - } - /*Tokenize.*/ - checkpoint=*_stack; - ac_bits=oc_enc_tokenize_ac(_enc,_pli,_fragi,data,dequant,dct,nonzero+1, - _stack,qti?0:3); - /*Reconstruct. - TODO: nonzero may need to be adjusted after tokenization.*/ - if(nonzero==0){ - ogg_int16_t p; - int ci; - /*We round this dequant product (and not any of the others) because there's - no iDCT rounding.*/ - p=(ogg_int16_t)(dc*(ogg_int32_t)dc_dequant+15>>5); - /*LOOP VECTORIZES.*/ - for(ci=0;ci<64;ci++)data[ci]=p; - } - else{ - data[0]=dc*dc_dequant; - oc_idct8x8(&_enc->state,data,nonzero+1); - } - if(!qti)oc_enc_frag_recon_intra(_enc,dst,ystride,data); - else{ - oc_enc_frag_recon_inter(_enc,dst, - nmv_offs==1?ref+mv_offs[0]:dst,ystride,data); - } - frame_type=_enc->state.frame_type; -#if !defined(OC_COLLECT_METRICS) - if(frame_type!=OC_INTRA_FRAME) -#endif - { - /*In retrospect, should we have skipped this block?*/ - oc_enc_frag_sub(_enc,data,src,dst,ystride); - coded_ssd=coded_dc=0; - if(borderi<0){ - for(pi=0;pi<64;pi++){ - coded_ssd+=data[pi]*data[pi]; - coded_dc+=data[pi]; - } - } - else{ - ogg_int64_t mask; - mask=_enc->state.borders[borderi].mask; - for(pi=0;pi<64;pi++,mask>>=1)if(mask&1){ - coded_ssd+=data[pi]*data[pi]; - coded_dc+=data[pi]; - } - } - /*Scale to match DCT domain.*/ - coded_ssd<<=4; - /*We actually only want the AC contribution to the SSD.*/ - coded_ssd-=coded_dc*coded_dc>>2; -#if defined(OC_COLLECT_METRICS) - _enc->frag_ssd[_fragi]=coded_ssd; - } - if(frame_type!=OC_INTRA_FRAME){ -#endif - uncoded_ssd=_pipe->skip_ssd[_pli][_fragi-_pipe->froffset[_pli]]; - if(uncoded_ssdlambda&& - /*Don't allow luma blocks to be skipped in 4MV mode when VP3 - compatibility is enabled.*/ - (!_enc->vp3_compatible||mb_mode!=OC_MODE_INTER_MV_FOUR||_pli)){ - /*Hm, not worth it; roll back.*/ - oc_enc_tokenlog_rollback(_enc,checkpoint,(*_stack)-checkpoint); - *_stack=checkpoint; - frags[_fragi].coded=0; - return 0; - } - } - else _mo->dc_flag=1; - _mo->uncoded_ac_ssd+=uncoded_ssd; - _mo->coded_ac_ssd+=coded_ssd; - _mo->ac_bits+=ac_bits; - } - oc_qii_state_advance(_pipe->qs+_pli,_pipe->qs+_pli,qii); - frags[_fragi].dc=dc; - frags[_fragi].coded=1; - return 1; -} - -static int oc_enc_mb_transform_quantize_luma(oc_enc_ctx *_enc, - oc_enc_pipeline_state *_pipe,unsigned _mbi,int _mode_overhead){ - /*Worst case token stack usage for 4 fragments.*/ - oc_token_checkpoint stack[64*4]; - oc_token_checkpoint *stackptr; - const oc_sb_map *sb_maps; - signed char *mb_modes; - oc_fragment *frags; - ptrdiff_t *coded_fragis; - ptrdiff_t ncoded_fragis; - ptrdiff_t *uncoded_fragis; - ptrdiff_t nuncoded_fragis; - oc_rd_metric mo; - oc_fr_state fr_checkpoint; - oc_qii_state qs_checkpoint; - int mb_mode; - int ncoded; - ptrdiff_t fragi; - int bi; - *&fr_checkpoint=*(_pipe->fr+0); - *&qs_checkpoint=*(_pipe->qs+0); - sb_maps=(const oc_sb_map *)_enc->state.sb_maps; - mb_modes=_enc->state.mb_modes; - frags=_enc->state.frags; - coded_fragis=_pipe->coded_fragis[0]; - ncoded_fragis=_pipe->ncoded_fragis[0]; - uncoded_fragis=_pipe->uncoded_fragis[0]; - nuncoded_fragis=_pipe->nuncoded_fragis[0]; - mb_mode=mb_modes[_mbi]; - ncoded=0; - stackptr=stack; - memset(&mo,0,sizeof(mo)); - for(bi=0;bi<4;bi++){ - fragi=sb_maps[_mbi>>2][_mbi&3][bi]; - frags[fragi].mb_mode=mb_mode; - if(oc_enc_block_transform_quantize(_enc, - _pipe,0,fragi,oc_fr_cost1(_pipe->fr+0),&mo,&stackptr)){ - oc_fr_code_block(_pipe->fr+0); - coded_fragis[ncoded_fragis++]=fragi; - ncoded++; - } - else{ - *(uncoded_fragis-++nuncoded_fragis)=fragi; - oc_fr_skip_block(_pipe->fr+0); - } - } - if(_enc->state.frame_type!=OC_INTRA_FRAME){ - if(ncoded>0&&!mo.dc_flag){ - int cost; - /*Some individual blocks were worth coding. - See if that's still true when accounting for mode and MV overhead.*/ - cost=mo.coded_ac_ssd+_enc->lambda*(mo.ac_bits - +oc_fr_cost4(&fr_checkpoint,_pipe->fr+0)+_mode_overhead); - if(mo.uncoded_ac_ssd<=cost){ - /*Taking macroblock overhead into account, it is not worth coding this - MB.*/ - oc_enc_tokenlog_rollback(_enc,stack,stackptr-stack); - *(_pipe->fr+0)=*&fr_checkpoint; - *(_pipe->qs+0)=*&qs_checkpoint; - for(bi=0;bi<4;bi++){ - fragi=sb_maps[_mbi>>2][_mbi&3][bi]; - if(frags[fragi].coded){ - *(uncoded_fragis-++nuncoded_fragis)=fragi; - frags[fragi].coded=0; - } - oc_fr_skip_block(_pipe->fr+0); - } - ncoded_fragis-=ncoded; - ncoded=0; - } - } - /*If no luma blocks coded, the mode is forced.*/ - if(ncoded==0)mb_modes[_mbi]=OC_MODE_INTER_NOMV; - /*Assume that a 1MV with a single coded block is always cheaper than a 4MV - with a single coded block. - This may not be strictly true: a 4MV computes chroma MVs using (0,0) for - skipped blocks, while a 1MV does not.*/ - else if(ncoded==1&&mb_mode==OC_MODE_INTER_MV_FOUR){ - mb_modes[_mbi]=OC_MODE_INTER_MV; - } - } - _pipe->ncoded_fragis[0]=ncoded_fragis; - _pipe->nuncoded_fragis[0]=nuncoded_fragis; - return ncoded; -} - -static void oc_enc_sb_transform_quantize_chroma(oc_enc_ctx *_enc, - oc_enc_pipeline_state *_pipe,int _pli,int _sbi_start,int _sbi_end){ - const oc_sb_map *sb_maps; - oc_sb_flags *sb_flags; - ptrdiff_t *coded_fragis; - ptrdiff_t ncoded_fragis; - ptrdiff_t *uncoded_fragis; - ptrdiff_t nuncoded_fragis; - int sbi; - sb_maps=(const oc_sb_map *)_enc->state.sb_maps; - sb_flags=_enc->state.sb_flags; - coded_fragis=_pipe->coded_fragis[_pli]; - ncoded_fragis=_pipe->ncoded_fragis[_pli]; - uncoded_fragis=_pipe->uncoded_fragis[_pli]; - nuncoded_fragis=_pipe->nuncoded_fragis[_pli]; - for(sbi=_sbi_start;sbi<_sbi_end;sbi++){ - /*Worst case token stack usage for 1 fragment.*/ - oc_token_checkpoint stack[64]; - oc_rd_metric mo; - int quadi; - int bi; - memset(&mo,0,sizeof(mo)); - for(quadi=0;quadi<4;quadi++)for(bi=0;bi<4;bi++){ - ptrdiff_t fragi; - fragi=sb_maps[sbi][quadi][bi]; - if(fragi>=0){ - oc_token_checkpoint *stackptr; - stackptr=stack; - if(oc_enc_block_transform_quantize(_enc, - _pipe,_pli,fragi,oc_fr_cost1(_pipe->fr+_pli),&mo,&stackptr)){ - coded_fragis[ncoded_fragis++]=fragi; - oc_fr_code_block(_pipe->fr+_pli); - } - else{ - *(uncoded_fragis-++nuncoded_fragis)=fragi; - oc_fr_skip_block(_pipe->fr+_pli); - } - } - } - oc_fr_state_flush_sb(_pipe->fr+_pli); - sb_flags[sbi].coded_fully=_pipe->fr[_pli].sb_full; - sb_flags[sbi].coded_partially=_pipe->fr[_pli].sb_partial; - } - _pipe->ncoded_fragis[_pli]=ncoded_fragis; - _pipe->nuncoded_fragis[_pli]=nuncoded_fragis; -} - -/*Mode decision is done by exhaustively examining all potential choices. - Obviously, doing the motion compensation, fDCT, tokenization, and then - counting the bits each token uses is computationally expensive. - Theora's EOB runs can also split the cost of these tokens across multiple - fragments, and naturally we don't know what the optimal choice of Huffman - codes will be until we know all the tokens we're going to encode in all the - fragments. - So we use a simple approach to estimating the bit cost and distortion of each - mode based upon the SATD value of the residual before coding. - The mathematics behind the technique are outlined by Kim \cite{Kim03}, but - the process (modified somewhat from that of the paper) is very simple. - We build a non-linear regression of the mappings from - (pre-transform+quantization) SATD to (post-transform+quantization) bits and - SSD for each qi. - A separate set of mappings is kept for each quantization type and color - plane. - The mappings are constructed by partitioning the SATD values into a small - number of bins (currently 24) and using a linear regression in each bin - (as opposed to the 0th-order regression used by Kim). - The bit counts and SSD measurements are obtained by examining actual encoded - frames, with appropriate lambda values and optimal Huffman codes selected. - EOB bits are assigned to the fragment that started the EOB run (as opposed to - dividing them among all the blocks in the run; though the latter approach - seems more theoretically correct, Monty's testing showed a small improvement - with the former, though that may have been merely statistical noise). - - @ARTICLE{Kim03, - author="Hyun Mun Kim", - title="Adaptive Rate Control Using Nonlinear Regression", - journal="IEEE Transactions on Circuits and Systems for Video Technology", - volume=13, - number=5, - pages="432--439", - month=May, - year=2003 - }*/ - -/*Computes (_ssd+_lambda*_rate)/(1<>OC_BIT_SCALE)+((_rate)>>OC_BIT_SCALE)*(_lambda) \ - +(((_ssd)&(1<>1)>>OC_BIT_SCALE) - -/*Estimate the R-D cost of the DCT coefficients given the SATD of a block after - prediction.*/ -static unsigned oc_dct_cost2(unsigned *_ssd, - int _qi,int _pli,int _qti,int _satd){ - unsigned rmse; - int bin; - int dx; - int y0; - int z0; - int dy; - int dz; - /*SATD metrics for chroma planes vary much less than luma, so we scale them - by 4 to distribute them into the mode decision bins more evenly.*/ - _satd<<=_pli+1&2; - bin=OC_MINI(_satd>>OC_SAD_SHIFT,OC_SAD_BINS-2); - dx=_satd-(bin<>OC_SAD_SHIFT),0); - *_ssd=rmse*rmse>>2*OC_RMSE_SCALE-OC_BIT_SCALE; - return OC_MAXI(y0+(dy*dx>>OC_SAD_SHIFT),0); -} - -/*Select luma block-level quantizers for a MB in an INTRA frame.*/ -static unsigned oc_analyze_intra_mb_luma(oc_enc_ctx *_enc, - const oc_qii_state *_qs,unsigned _mbi){ - const unsigned char *src; - const ptrdiff_t *frag_buf_offs; - const oc_sb_map *sb_maps; - oc_fragment *frags; - ptrdiff_t frag_offs; - ptrdiff_t fragi; - oc_qii_state qs[4][3]; - unsigned cost[4][3]; - unsigned ssd[4][3]; - unsigned rate[4][3]; - int prev[3][3]; - unsigned satd; - unsigned best_cost; - unsigned best_ssd; - unsigned best_rate; - int best_qii; - int qii; - int lambda; - int ystride; - int nqis; - int bi; - frag_buf_offs=_enc->state.frag_buf_offs; - sb_maps=(const oc_sb_map *)_enc->state.sb_maps; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ystride=_enc->state.ref_ystride[0]; - fragi=sb_maps[_mbi>>2][_mbi&3][0]; - frag_offs=frag_buf_offs[fragi]; - satd=oc_enc_frag_intra_satd(_enc,src+frag_offs,ystride); - nqis=_enc->state.nqis; - lambda=_enc->lambda; - for(qii=0;qiistate.qis[qii],0,0,satd) - +(qs[0][qii].bits-_qs->bits<>2][_mbi&3][bi]; - frag_offs=frag_buf_offs[fragi]; - satd=oc_enc_frag_intra_satd(_enc,src+frag_offs,ystride); - for(qii=0;qiistate.qis[qii],0,0,satd); - best_ssd=ssd[bi-1][0]+cur_ssd; - best_rate=rate[bi-1][0]+cur_rate - +(qt[0].bits-qs[bi-1][0].bits<state.frags; - for(bi=3;;){ - fragi=sb_maps[_mbi>>2][_mbi&3][bi]; - frags[fragi].qii=best_qii; - if(bi--<=0)break; - best_qii=prev[bi][best_qii]; - } - return best_cost; -} - -/*Select a block-level quantizer for a single chroma block in an INTRA frame.*/ -static unsigned oc_analyze_intra_chroma_block(oc_enc_ctx *_enc, - const oc_qii_state *_qs,int _pli,ptrdiff_t _fragi){ - const unsigned char *src; - oc_fragment *frags; - ptrdiff_t frag_offs; - oc_qii_state qt[3]; - unsigned cost[3]; - unsigned satd; - unsigned best_cost; - int best_qii; - int qii; - int lambda; - int ystride; - int nqis; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ystride=_enc->state.ref_ystride[_pli]; - frag_offs=_enc->state.frag_buf_offs[_fragi]; - satd=oc_enc_frag_intra_satd(_enc,src+frag_offs,ystride); - nqis=_enc->state.nqis; - lambda=_enc->lambda; - best_qii=0; - for(qii=0;qiistate.qis[qii],_pli,0,satd) - +(qt[qii].bits-_qs->bits<state.frags; - frags[_fragi].qii=best_qii; - return best_cost; -} - -static void oc_enc_sb_transform_quantize_intra_chroma(oc_enc_ctx *_enc, - oc_enc_pipeline_state *_pipe,int _pli,int _sbi_start,int _sbi_end){ - const oc_sb_map *sb_maps; - oc_sb_flags *sb_flags; - ptrdiff_t *coded_fragis; - ptrdiff_t ncoded_fragis; - int sbi; - sb_maps=(const oc_sb_map *)_enc->state.sb_maps; - sb_flags=_enc->state.sb_flags; - coded_fragis=_pipe->coded_fragis[_pli]; - ncoded_fragis=_pipe->ncoded_fragis[_pli]; - for(sbi=_sbi_start;sbi<_sbi_end;sbi++){ - /*Worst case token stack usage for 1 fragment.*/ - oc_token_checkpoint stack[64]; - int quadi; - int bi; - for(quadi=0;quadi<4;quadi++)for(bi=0;bi<4;bi++){ - ptrdiff_t fragi; - fragi=sb_maps[sbi][quadi][bi]; - if(fragi>=0){ - oc_token_checkpoint *stackptr; - oc_analyze_intra_chroma_block(_enc,_pipe->qs+_pli,_pli,fragi); - stackptr=stack; - oc_enc_block_transform_quantize(_enc, - _pipe,_pli,fragi,0,NULL,&stackptr); - coded_fragis[ncoded_fragis++]=fragi; - } - } - } - _pipe->ncoded_fragis[_pli]=ncoded_fragis; -} - -/*Analysis stage for an INTRA frame.*/ -void oc_enc_analyze_intra(oc_enc_ctx *_enc,int _recode){ - oc_enc_pipeline_state pipe; - const unsigned char *map_idxs; - int nmap_idxs; - oc_sb_flags *sb_flags; - signed char *mb_modes; - const oc_mb_map *mb_maps; - oc_mb_enc_info *embs; - oc_fragment *frags; - unsigned stripe_sby; - unsigned mcu_nvsbs; - int notstart; - int notdone; - int refi; - int pli; - _enc->state.frame_type=OC_INTRA_FRAME; - oc_enc_tokenize_start(_enc); - oc_enc_pipeline_init(_enc,&pipe); - /*Choose MVs and MB modes and quantize and code luma. - Must be done in Hilbert order.*/ - map_idxs=OC_MB_MAP_IDXS[_enc->state.info.pixel_fmt]; - nmap_idxs=OC_MB_MAP_NIDXS[_enc->state.info.pixel_fmt]; - _enc->state.ncoded_fragis[0]=0; - _enc->state.ncoded_fragis[1]=0; - _enc->state.ncoded_fragis[2]=0; - sb_flags=_enc->state.sb_flags; - mb_modes=_enc->state.mb_modes; - mb_maps=(const oc_mb_map *)_enc->state.mb_maps; - embs=_enc->mb_info; - frags=_enc->state.frags; - notstart=0; - notdone=1; - mcu_nvsbs=_enc->mcu_nvsbs; - for(stripe_sby=0;notdone;stripe_sby+=mcu_nvsbs){ - unsigned sbi; - unsigned sbi_end; - notdone=oc_enc_pipeline_set_stripe(_enc,&pipe,stripe_sby); - sbi_end=pipe.sbi_end[0]; - for(sbi=pipe.sbi0[0];sbistate.curframe_num>0)oc_mcenc_search(_enc,mbi); - oc_analyze_intra_mb_luma(_enc,pipe.qs+0,mbi); - mb_modes[mbi]=OC_MODE_INTRA; - oc_enc_mb_transform_quantize_luma(_enc,&pipe,mbi,0); - /*Propagate final MB mode and MVs to the chroma blocks.*/ - for(mapii=4;mapii>2; - bi=mapi&3; - fragi=mb_maps[mbi][pli][bi]; - frags[fragi].mb_mode=OC_MODE_INTRA; - } - } - } - oc_enc_pipeline_finish_mcu_plane(_enc,&pipe,0,notstart,notdone); - /*Code chroma planes.*/ - for(pli=1;pli<3;pli++){ - oc_enc_sb_transform_quantize_intra_chroma(_enc,&pipe, - pli,pipe.sbi0[pli],pipe.sbi_end[pli]); - oc_enc_pipeline_finish_mcu_plane(_enc,&pipe,pli,notstart,notdone); - } - notstart=1; - } - /*Finish filling in the reference frame borders.*/ - refi=_enc->state.ref_frame_idx[OC_FRAME_SELF]; - for(pli=0;pli<3;pli++)oc_state_borders_fill_caps(&_enc->state,refi,pli); - _enc->state.ntotal_coded_fragis=_enc->state.nfrags; -} - - - -/*Cost information about a MB mode.*/ -struct oc_mode_choice{ - unsigned cost; - unsigned ssd; - unsigned rate; - unsigned overhead; - unsigned char qii[12]; -}; - - - -static void oc_mode_set_cost(oc_mode_choice *_modec,int _lambda){ - _modec->cost=OC_MODE_RD_COST(_modec->ssd, - _modec->rate+_modec->overhead,_lambda); -} - -/*A set of skip SSD's to use to disable early skipping.*/ -static const unsigned OC_NOSKIP[12]={ - UINT_MAX,UINT_MAX,UINT_MAX,UINT_MAX, - UINT_MAX,UINT_MAX,UINT_MAX,UINT_MAX, - UINT_MAX,UINT_MAX,UINT_MAX,UINT_MAX -}; - -/*The estimated number of bits used by a coded chroma block to specify the AC - quantizer. - TODO: Currently this is just 0.5*log2(3) (estimating about 50% compression); - measurements suggest this is in the right ballpark, but it varies somewhat - with lambda.*/ -#define OC_CHROMA_QII_RATE ((0xCAE00D1DU>>31-OC_BIT_SCALE)+1>>1) - -static void oc_analyze_mb_mode_luma(oc_enc_ctx *_enc, - oc_mode_choice *_modec,const oc_fr_state *_fr,const oc_qii_state *_qs, - const unsigned _frag_satd[12],const unsigned _skip_ssd[12],int _qti){ - oc_fr_state fr; - oc_qii_state qs; - unsigned ssd; - unsigned rate; - int overhead; - unsigned satd; - unsigned best_ssd; - unsigned best_rate; - int best_overhead; - int best_fri; - int best_qii; - unsigned cur_cost; - unsigned cur_ssd; - unsigned cur_rate; - int cur_overhead; - int lambda; - int nqis; - int nskipped; - int bi; - int qii; - lambda=_enc->lambda; - nqis=_enc->state.nqis; - /*We could do a trellis optimization here, but we don't make final skip - decisions until after transform+quantization, so the result wouldn't be - optimal anyway. - Instead we just use a greedy approach; for most SATD values, the - differences between the qiis are large enough to drown out the cost to - code the flags, anyway.*/ - *&fr=*_fr; - *&qs=*_qs; - ssd=rate=overhead=nskipped=0; - for(bi=0;bi<4;bi++){ - oc_fr_state ft[2]; - oc_qii_state qt[3]; - unsigned best_cost; - satd=_frag_satd[bi]; - *(ft+0)=*&fr; - oc_fr_code_block(ft+0); - oc_qii_state_advance(qt+0,&qs,0); - best_overhead=(ft[0].bits-fr.bits<state.qis[0],0,_qti,satd) - +(qt[0].bits-qs.bits<state.qis[qii],0,_qti,satd) - +(qt[qii].bits-qs.bits<qii[bi]=best_qii; - } - _modec->ssd=ssd; - _modec->rate=rate; - _modec->overhead=OC_MAXI(overhead,0); -} - -static void oc_analyze_mb_mode_chroma(oc_enc_ctx *_enc, - oc_mode_choice *_modec,const oc_fr_state *_fr,const oc_qii_state *_qs, - const unsigned _frag_satd[12],const unsigned _skip_ssd[12],int _qti){ - unsigned ssd; - unsigned rate; - unsigned satd; - unsigned best_ssd; - unsigned best_rate; - int best_qii; - unsigned cur_cost; - unsigned cur_ssd; - unsigned cur_rate; - int lambda; - int nblocks; - int nqis; - int pli; - int bi; - int qii; - lambda=_enc->lambda; - nqis=_enc->state.nqis; - ssd=_modec->ssd; - rate=_modec->rate; - /*Because (except in 4:4:4 mode) we aren't considering chroma blocks in coded - order, we assume a constant overhead for coded block and qii flags.*/ - nblocks=OC_MB_MAP_NIDXS[_enc->state.info.pixel_fmt]; - nblocks=(nblocks-4>>1)+4; - bi=4; - for(pli=1;pli<3;pli++){ - for(;bistate.qis[0],pli,_qti,satd) - +OC_CHROMA_QII_RATE; - best_cost=OC_MODE_RD_COST(ssd+best_ssd,rate+best_rate,lambda); - best_qii=0; - for(qii=1;qiistate.qis[qii],0,_qti,satd) - +OC_CHROMA_QII_RATE; - cur_cost=OC_MODE_RD_COST(ssd+cur_ssd,rate+cur_rate,lambda); - if(cur_costqii[bi]=best_qii; - } - nblocks=(nblocks-4<<1)+4; - } - _modec->ssd=ssd; - _modec->rate=rate; -} - -static void oc_skip_cost(oc_enc_ctx *_enc,oc_enc_pipeline_state *_pipe, - unsigned _mbi,unsigned _ssd[12]){ - OC_ALIGN16(ogg_int16_t buffer[64]); - const unsigned char *src; - const unsigned char *ref; - int ystride; - const oc_fragment *frags; - const ptrdiff_t *frag_buf_offs; - const ptrdiff_t *sb_map; - const oc_mb_map_plane *mb_map; - const unsigned char *map_idxs; - int map_nidxs; - ogg_int64_t mask; - unsigned uncoded_ssd; - int uncoded_dc; - unsigned dc_dequant; - int dc_flag; - int mapii; - int mapi; - int pli; - int bi; - ptrdiff_t fragi; - ptrdiff_t frag_offs; - int borderi; - int pi; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ref=_enc->state.ref_frame_data[_enc->state.ref_frame_idx[OC_FRAME_PREV]]; - ystride=_enc->state.ref_ystride[0]; - frags=_enc->state.frags; - frag_buf_offs=_enc->state.frag_buf_offs; - sb_map=_enc->state.sb_maps[_mbi>>2][_mbi&3]; - dc_dequant=_enc->state.dequant_tables[_enc->state.qis[0]][0][1][0]; - for(bi=0;bi<4;bi++){ - fragi=sb_map[bi]; - frag_offs=frag_buf_offs[fragi]; - oc_enc_frag_sub(_enc,buffer,src+frag_offs,ref+frag_offs,ystride); - borderi=frags[fragi].borderi; - uncoded_ssd=uncoded_dc=0; - if(borderi<0){ - for(pi=0;pi<64;pi++){ - uncoded_ssd+=buffer[pi]*buffer[pi]; - uncoded_dc+=buffer[pi]; - } - } - else{ - ogg_int64_t mask; - mask=_enc->state.borders[borderi].mask; - for(pi=0;pi<64;pi++,mask>>=1)if(mask&1){ - uncoded_ssd+=buffer[pi]*buffer[pi]; - uncoded_dc+=buffer[pi]; - } - } - /*Scale to match DCT domain.*/ - uncoded_ssd<<=4; - /*We actually only want the AC contribution to the SSD.*/ - uncoded_ssd-=uncoded_dc*uncoded_dc>>2; - /*DC is a special case; if there's more than a full-quantizer improvement - in the effective DC component, always force-code the block.*/ - dc_flag=abs(uncoded_dc)>dc_dequant<<1; - uncoded_ssd|=-dc_flag; - _pipe->skip_ssd[0][fragi-_pipe->froffset[0]]=_ssd[bi]=uncoded_ssd; - } - mb_map=(const oc_mb_map_plane *)_enc->state.mb_maps[_mbi]; - map_nidxs=OC_MB_MAP_NIDXS[_enc->state.info.pixel_fmt]; - map_idxs=OC_MB_MAP_IDXS[_enc->state.info.pixel_fmt]; - map_nidxs=(map_nidxs-4>>1)+4; - mapii=4; - for(pli=1;pli<3;pli++){ - ystride=_enc->state.ref_ystride[pli]; - dc_dequant=_enc->state.dequant_tables[_enc->state.qis[0]][pli][1][0]; - for(;mapiistate.borders[borderi].mask; - for(pi=0;pi<64;pi++,mask>>=1)if(mask&1){ - uncoded_ssd+=buffer[pi]*buffer[pi]; - uncoded_dc+=buffer[pi]; - } - } - /*Scale to match DCT domain.*/ - uncoded_ssd<<=4; - /*We actually only want the AC contribution to the SSD.*/ - uncoded_ssd-=uncoded_dc*uncoded_dc>>2; - /*DC is a special case; if there's more than a full-quantizer improvement - in the effective DC component, always force-code the block.*/ - dc_flag=abs(uncoded_dc)>dc_dequant<<1; - uncoded_ssd|=-dc_flag; - _pipe->skip_ssd[pli][fragi-_pipe->froffset[pli]]=_ssd[mapii]=uncoded_ssd; - } - map_nidxs=(map_nidxs-4<<1)+4; - } -} - -static void oc_mb_intra_satd(oc_enc_ctx *_enc,unsigned _mbi, - unsigned _frag_satd[12]){ - const unsigned char *src; - const ptrdiff_t *frag_buf_offs; - const ptrdiff_t *sb_map; - const oc_mb_map_plane *mb_map; - const unsigned char *map_idxs; - int map_nidxs; - int mapii; - int mapi; - int ystride; - int pli; - int bi; - ptrdiff_t fragi; - ptrdiff_t frag_offs; - frag_buf_offs=_enc->state.frag_buf_offs; - sb_map=_enc->state.sb_maps[_mbi>>2][_mbi&3]; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ystride=_enc->state.ref_ystride[0]; - for(bi=0;bi<4;bi++){ - fragi=sb_map[bi]; - frag_offs=frag_buf_offs[fragi]; - _frag_satd[bi]=oc_enc_frag_intra_satd(_enc,src+frag_offs,ystride); - } - mb_map=(const oc_mb_map_plane *)_enc->state.mb_maps[_mbi]; - map_idxs=OC_MB_MAP_IDXS[_enc->state.info.pixel_fmt]; - map_nidxs=OC_MB_MAP_NIDXS[_enc->state.info.pixel_fmt]; - /*Note: This assumes ref_ystride[1]==ref_ystride[2].*/ - ystride=_enc->state.ref_ystride[1]; - for(mapii=4;mapii>2; - bi=mapi&3; - fragi=mb_map[pli][bi]; - frag_offs=frag_buf_offs[fragi]; - _frag_satd[mapii]=oc_enc_frag_intra_satd(_enc,src+frag_offs,ystride); - } -} - -static void oc_cost_intra(oc_enc_ctx *_enc,oc_mode_choice *_modec, - unsigned _mbi,const oc_fr_state *_fr,const oc_qii_state *_qs, - const unsigned _frag_satd[12],const unsigned _skip_ssd[12]){ - oc_analyze_mb_mode_luma(_enc,_modec,_fr,_qs,_frag_satd,_skip_ssd,0); - oc_analyze_mb_mode_chroma(_enc,_modec,_fr,_qs,_frag_satd,_skip_ssd,0); - _modec->overhead+= - oc_mode_scheme_chooser_cost(&_enc->chooser,OC_MODE_INTRA)<lambda); -} - -static void oc_cost_inter(oc_enc_ctx *_enc,oc_mode_choice *_modec, - unsigned _mbi,int _mb_mode,const signed char *_mv, - const oc_fr_state *_fr,const oc_qii_state *_qs,const unsigned _skip_ssd[12]){ - unsigned frag_satd[12]; - const unsigned char *src; - const unsigned char *ref; - int ystride; - const ptrdiff_t *frag_buf_offs; - const ptrdiff_t *sb_map; - const oc_mb_map_plane *mb_map; - const unsigned char *map_idxs; - int map_nidxs; - int mapii; - int mapi; - int mv_offs[2]; - int dx; - int dy; - int pli; - int bi; - ptrdiff_t fragi; - ptrdiff_t frag_offs; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ref=_enc->state.ref_frame_data[ - _enc->state.ref_frame_idx[OC_FRAME_FOR_MODE(_mb_mode)]]; - ystride=_enc->state.ref_ystride[0]; - frag_buf_offs=_enc->state.frag_buf_offs; - sb_map=_enc->state.sb_maps[_mbi>>2][_mbi&3]; - dx=_mv[0]; - dy=_mv[1]; - _modec->rate=_modec->ssd=0; - if(oc_state_get_mv_offsets(&_enc->state,mv_offs,0,dx,dy)>1){ - for(bi=0;bi<4;bi++){ - fragi=sb_map[bi]; - frag_offs=frag_buf_offs[fragi]; - frag_satd[bi]=oc_enc_frag_satd2_thresh(_enc,src+frag_offs, - ref+frag_offs+mv_offs[0],ref+frag_offs+mv_offs[1],ystride,UINT_MAX); - } - } - else{ - for(bi=0;bi<4;bi++){ - fragi=sb_map[bi]; - frag_offs=frag_buf_offs[fragi]; - frag_satd[bi]=oc_enc_frag_satd_thresh(_enc,src+frag_offs, - ref+frag_offs+mv_offs[0],ystride,UINT_MAX); - } - } - mb_map=(const oc_mb_map_plane *)_enc->state.mb_maps[_mbi]; - map_idxs=OC_MB_MAP_IDXS[_enc->state.info.pixel_fmt]; - map_nidxs=OC_MB_MAP_NIDXS[_enc->state.info.pixel_fmt]; - /*Note: This assumes ref_ystride[1]==ref_ystride[2].*/ - ystride=_enc->state.ref_ystride[1]; - if(oc_state_get_mv_offsets(&_enc->state,mv_offs,1,dx,dy)>1){ - for(mapii=4;mapii>2; - bi=mapi&3; - fragi=mb_map[pli][bi]; - frag_offs=frag_buf_offs[fragi]; - frag_satd[mapii]=oc_enc_frag_satd2_thresh(_enc,src+frag_offs, - ref+frag_offs+mv_offs[0],ref+frag_offs+mv_offs[1],ystride,UINT_MAX); - } - } - else{ - for(mapii=4;mapii>2; - bi=mapi&3; - fragi=mb_map[pli][bi]; - frag_offs=frag_buf_offs[fragi]; - frag_satd[mapii]=oc_enc_frag_satd_thresh(_enc,src+frag_offs, - ref+frag_offs+mv_offs[0],ystride,UINT_MAX); - } - } - oc_analyze_mb_mode_luma(_enc,_modec,_fr,_qs,frag_satd,_skip_ssd,1); - oc_analyze_mb_mode_chroma(_enc,_modec,_fr,_qs,frag_satd,_skip_ssd,1); - _modec->overhead+= - oc_mode_scheme_chooser_cost(&_enc->chooser,_mb_mode)<lambda); -} - -static void oc_cost_inter_nomv(oc_enc_ctx *_enc,oc_mode_choice *_modec, - unsigned _mbi,int _mb_mode,const oc_fr_state *_fr,const oc_qii_state *_qs, - const unsigned _skip_ssd[12]){ - static const oc_mv OC_MV_ZERO; - oc_cost_inter(_enc,_modec,_mbi,_mb_mode,OC_MV_ZERO,_fr,_qs,_skip_ssd); -} - -static int oc_cost_inter1mv(oc_enc_ctx *_enc,oc_mode_choice *_modec, - unsigned _mbi,int _mb_mode,const signed char *_mv, - const oc_fr_state *_fr,const oc_qii_state *_qs,const unsigned _skip_ssd[12]){ - int bits0; - oc_cost_inter(_enc,_modec,_mbi,_mb_mode,_mv,_fr,_qs,_skip_ssd); - bits0=OC_MV_BITS[0][_mv[0]+31]+OC_MV_BITS[0][_mv[1]+31]; - _modec->overhead+=OC_MINI(_enc->mv_bits[0]+bits0,_enc->mv_bits[1]+12) - -OC_MINI(_enc->mv_bits[0],_enc->mv_bits[1])<lambda); - return bits0; -} - -/*A mapping from oc_mb_map (raster) ordering to oc_sb_map (Hilbert) ordering.*/ -static const unsigned char OC_MB_PHASE[4][4]={ - {0,1,3,2},{0,3,1,2},{0,3,1,2},{2,3,1,0} -}; - -static void oc_cost_inter4mv(oc_enc_ctx *_enc,oc_mode_choice *_modec, - unsigned _mbi,oc_mv _mv[4],const oc_fr_state *_fr,const oc_qii_state *_qs, - const unsigned _skip_ssd[12]){ - unsigned frag_satd[12]; - oc_mv lbmvs[4]; - oc_mv cbmvs[4]; - const unsigned char *src; - const unsigned char *ref; - int ystride; - const ptrdiff_t *frag_buf_offs; - oc_mv *frag_mvs; - const oc_mb_map_plane *mb_map; - const unsigned char *map_idxs; - int map_nidxs; - int nqis; - int mapii; - int mapi; - int mv_offs[2]; - int dx; - int dy; - int pli; - int bi; - ptrdiff_t fragi; - ptrdiff_t frag_offs; - int bits0; - int bits1; - unsigned satd; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ref=_enc->state.ref_frame_data[_enc->state.ref_frame_idx[OC_FRAME_PREV]]; - ystride=_enc->state.ref_ystride[0]; - frag_buf_offs=_enc->state.frag_buf_offs; - frag_mvs=_enc->state.frag_mvs; - mb_map=(const oc_mb_map_plane *)_enc->state.mb_maps[_mbi]; - _modec->rate=_modec->ssd=0; - for(bi=0;bi<4;bi++){ - fragi=mb_map[0][bi]; - dx=_mv[bi][0]; - dy=_mv[bi][1]; - /*Save the block MVs as the current ones while we're here; we'll replace - them if we don't ultimately choose 4MV mode.*/ - frag_mvs[fragi][0]=(signed char)dx; - frag_mvs[fragi][1]=(signed char)dy; - frag_offs=frag_buf_offs[fragi]; - if(oc_state_get_mv_offsets(&_enc->state,mv_offs,0,dx,dy)>1){ - satd=oc_enc_frag_satd2_thresh(_enc,src+frag_offs, - ref+frag_offs+mv_offs[0],ref+frag_offs+mv_offs[1],ystride,UINT_MAX); - } - else{ - satd=oc_enc_frag_satd_thresh(_enc,src+frag_offs, - ref+frag_offs+mv_offs[0],ystride,UINT_MAX); - } - frag_satd[OC_MB_PHASE[_mbi&3][bi]]=satd; - } - oc_analyze_mb_mode_luma(_enc,_modec,_fr,_qs,frag_satd, - _enc->vp3_compatible?OC_NOSKIP:_skip_ssd,1); - /*Figure out which blocks are being skipped and give them (0,0) MVs.*/ - bits0=0; - bits1=0; - nqis=_enc->state.nqis; - for(bi=0;bi<4;bi++){ - if(_modec->qii[OC_MB_PHASE[_mbi&3][bi]]>=nqis){ - memset(lbmvs+bi,0,sizeof(*lbmvs)); - } - else{ - memcpy(lbmvs+bi,_mv+bi,sizeof(*lbmvs)); - bits0+=OC_MV_BITS[0][_mv[bi][0]+31]+OC_MV_BITS[0][_mv[bi][1]+31]; - bits1+=12; - } - } - (*OC_SET_CHROMA_MVS_TABLE[_enc->state.info.pixel_fmt])(cbmvs, - (const oc_mv *)lbmvs); - map_idxs=OC_MB_MAP_IDXS[_enc->state.info.pixel_fmt]; - map_nidxs=OC_MB_MAP_NIDXS[_enc->state.info.pixel_fmt]; - /*Note: This assumes ref_ystride[1]==ref_ystride[2].*/ - ystride=_enc->state.ref_ystride[1]; - for(mapii=4;mapii>2; - bi=mapi&3; - fragi=mb_map[pli][bi]; - dx=cbmvs[bi][0]; - dy=cbmvs[bi][1]; - frag_offs=frag_buf_offs[fragi]; - /*TODO: We could save half these calls by re-using the results for the Cb - and Cr planes; is it worth it?*/ - if(oc_state_get_mv_offsets(&_enc->state,mv_offs,pli,dx,dy)>1){ - satd=oc_enc_frag_satd2_thresh(_enc,src+frag_offs, - ref+frag_offs+mv_offs[0],ref+frag_offs+mv_offs[1],ystride,UINT_MAX); - } - else{ - satd=oc_enc_frag_satd_thresh(_enc,src+frag_offs, - ref+frag_offs+mv_offs[0],ystride,UINT_MAX); - } - frag_satd[mapii]=satd; - } - oc_analyze_mb_mode_chroma(_enc,_modec,_fr,_qs,frag_satd,_skip_ssd,1); - _modec->overhead+= - oc_mode_scheme_chooser_cost(&_enc->chooser,OC_MODE_INTER_MV_FOUR) - +OC_MINI(_enc->mv_bits[0]+bits0,_enc->mv_bits[1]+bits1) - -OC_MINI(_enc->mv_bits[0],_enc->mv_bits[1])<lambda); -} - -int oc_enc_analyze_inter(oc_enc_ctx *_enc,int _allow_keyframe,int _recode){ - oc_set_chroma_mvs_func set_chroma_mvs; - oc_enc_pipeline_state pipe; - oc_qii_state intra_luma_qs; - oc_mv last_mv; - oc_mv prior_mv; - ogg_int64_t interbits; - ogg_int64_t intrabits; - const unsigned char *map_idxs; - int nmap_idxs; - unsigned *coded_mbis; - unsigned *uncoded_mbis; - size_t ncoded_mbis; - size_t nuncoded_mbis; - oc_sb_flags *sb_flags; - signed char *mb_modes; - const oc_sb_map *sb_maps; - const oc_mb_map *mb_maps; - oc_mb_enc_info *embs; - oc_fragment *frags; - oc_mv *frag_mvs; - int qi; - unsigned stripe_sby; - unsigned mcu_nvsbs; - int notstart; - int notdone; - int vdec; - unsigned sbi; - unsigned sbi_end; - int refi; - int pli; - set_chroma_mvs=OC_SET_CHROMA_MVS_TABLE[_enc->state.info.pixel_fmt]; - _enc->state.frame_type=OC_INTER_FRAME; - oc_mode_scheme_chooser_reset(&_enc->chooser); - oc_enc_tokenize_start(_enc); - oc_enc_pipeline_init(_enc,&pipe); - if(_allow_keyframe)oc_qii_state_init(&intra_luma_qs); - _enc->mv_bits[0]=_enc->mv_bits[1]=0; - interbits=intrabits=0; - last_mv[0]=last_mv[1]=prior_mv[0]=prior_mv[1]=0; - /*Choose MVs and MB modes and quantize and code luma. - Must be done in Hilbert order.*/ - map_idxs=OC_MB_MAP_IDXS[_enc->state.info.pixel_fmt]; - nmap_idxs=OC_MB_MAP_NIDXS[_enc->state.info.pixel_fmt]; - qi=_enc->state.qis[0]; - coded_mbis=_enc->coded_mbis; - uncoded_mbis=coded_mbis+_enc->state.nmbs; - ncoded_mbis=0; - nuncoded_mbis=0; - _enc->state.ncoded_fragis[0]=0; - _enc->state.ncoded_fragis[1]=0; - _enc->state.ncoded_fragis[2]=0; - sb_flags=_enc->state.sb_flags; - mb_modes=_enc->state.mb_modes; - sb_maps=(const oc_sb_map *)_enc->state.sb_maps; - mb_maps=(const oc_mb_map *)_enc->state.mb_maps; - embs=_enc->mb_info; - frags=_enc->state.frags; - frag_mvs=_enc->state.frag_mvs; - vdec=!(_enc->state.info.pixel_fmt&2); - notstart=0; - notdone=1; - mcu_nvsbs=_enc->mcu_nvsbs; - for(stripe_sby=0;notdone;stripe_sby+=mcu_nvsbs){ - notdone=oc_enc_pipeline_set_stripe(_enc,&pipe,stripe_sby); - sbi_end=pipe.sbi_end[0]; - for(sbi=pipe.sbi0[0];sbisp_levelsp_levellambda*3; - if(modes[OC_MODE_INTER_MV_FOUR].cost>2][mbi&3][bi]; - frags[fragi].qii=modes[mb_mode].qii[bi]; - } - if(oc_enc_mb_transform_quantize_luma(_enc,&pipe,mbi, - modes[mb_mode].overhead>>OC_BIT_SCALE)>0){ - int orig_mb_mode; - orig_mb_mode=mb_mode; - mb_mode=mb_modes[mbi]; - switch(mb_mode){ - case OC_MODE_INTER_MV:{ - memcpy(prior_mv,last_mv,sizeof(prior_mv)); - /*If we're backing out from 4MV, find the MV we're actually - using.*/ - if(orig_mb_mode==OC_MODE_INTER_MV_FOUR){ - for(bi=0;;bi++){ - fragi=mb_maps[mbi][0][bi]; - if(frags[fragi].coded){ - memcpy(last_mv,frag_mvs[fragi],sizeof(last_mv)); - dx=frag_mvs[fragi][0]; - dy=frag_mvs[fragi][1]; - break; - } - } - mb_mv_bits_0=OC_MV_BITS[0][dx+31]+OC_MV_BITS[0][dy+31]; - } - /*Otherwise we used the original analysis MV.*/ - else{ - memcpy(last_mv, - embs[mbi].analysis_mv[0][OC_FRAME_PREV],sizeof(last_mv)); - } - _enc->mv_bits[0]+=mb_mv_bits_0; - _enc->mv_bits[1]+=12; - }break; - case OC_MODE_INTER_MV_LAST2:{ - oc_mv tmp_mv; - memcpy(tmp_mv,prior_mv,sizeof(tmp_mv)); - memcpy(prior_mv,last_mv,sizeof(prior_mv)); - memcpy(last_mv,tmp_mv,sizeof(last_mv)); - }break; - case OC_MODE_GOLDEN_MV:{ - _enc->mv_bits[0]+=mb_gmv_bits_0; - _enc->mv_bits[1]+=12; - }break; - case OC_MODE_INTER_MV_FOUR:{ - oc_mv lbmvs[4]; - oc_mv cbmvs[4]; - memcpy(prior_mv,last_mv,sizeof(prior_mv)); - for(bi=0;bi<4;bi++){ - fragi=mb_maps[mbi][0][bi]; - if(frags[fragi].coded){ - memcpy(last_mv,frag_mvs[fragi],sizeof(last_mv)); - memcpy(lbmvs[bi],frag_mvs[fragi],sizeof(lbmvs[bi])); - _enc->mv_bits[0]+=OC_MV_BITS[0][frag_mvs[fragi][0]+31] - +OC_MV_BITS[0][frag_mvs[fragi][1]+31]; - _enc->mv_bits[1]+=12; - } - /*Replace the block MVs for not-coded blocks with (0,0).*/ - else memset(lbmvs[bi],0,sizeof(lbmvs[bi])); - } - (*set_chroma_mvs)(cbmvs,(const oc_mv *)lbmvs); - for(mapii=4;mapii>2; - bi=mapi&3; - fragi=mb_maps[mbi][pli][bi]; - frags[fragi].mb_mode=mb_mode; - frags[fragi].qii=modes[OC_MODE_INTER_MV_FOUR].qii[mapii]; - memcpy(frag_mvs[fragi],cbmvs[bi],sizeof(frag_mvs[fragi])); - } - }break; - } - coded_mbis[ncoded_mbis++]=mbi; - oc_mode_scheme_chooser_update(&_enc->chooser,mb_mode); - interbits+=modes[mb_mode].rate+modes[mb_mode].overhead; - } - else{ - *(uncoded_mbis-++nuncoded_mbis)=mbi; - mb_mode=OC_MODE_INTER_NOMV; - dx=dy=0; - } - /*Propagate final MB mode and MVs to the chroma blocks. - This has already been done for 4MV mode, since it requires individual - block motion vectors.*/ - if(mb_mode!=OC_MODE_INTER_MV_FOUR){ - for(mapii=4;mapii>2; - bi=mapi&3; - fragi=mb_maps[mbi][pli][bi]; - frags[fragi].mb_mode=mb_mode; - /*If we switched from 4MV mode to INTER_MV mode, then the qii - values won't have been chosen with the right MV, but it's - probaby not worth re-estimating them.*/ - frags[fragi].qii=modes[mb_mode].qii[mapii]; - frag_mvs[fragi][0]=(signed char)dx; - frag_mvs[fragi][1]=(signed char)dy; - } - } - } - oc_fr_state_flush_sb(pipe.fr+0); - sb_flags[sbi].coded_fully=pipe.fr[0].sb_full; - sb_flags[sbi].coded_partially=pipe.fr[0].sb_partial; - } - oc_enc_pipeline_finish_mcu_plane(_enc,&pipe,0,notstart,notdone); - /*Code chroma planes.*/ - for(pli=1;pli<3;pli++){ - oc_enc_sb_transform_quantize_chroma(_enc,&pipe, - pli,pipe.sbi0[pli],pipe.sbi_end[pli]); - oc_enc_pipeline_finish_mcu_plane(_enc,&pipe,pli,notstart,notdone); - } - notstart=1; - } - /*Finish filling in the reference frame borders.*/ - refi=_enc->state.ref_frame_idx[OC_FRAME_SELF]; - for(pli=0;pli<3;pli++)oc_state_borders_fill_caps(&_enc->state,refi,pli); - /*Finish adding flagging overhead costs to inter bit counts to determine if - we should have coded a key frame instead.*/ - if(_allow_keyframe){ - if(interbits>intrabits)return 1; - /*Technically the chroma plane counts are over-estimations, because they - don't account for continuing runs from the luma planes, but the - inaccuracy is small.*/ - for(pli=0;pli<3;pli++)interbits+=pipe.fr[pli].bits<mv_bits[0],_enc->mv_bits[1])<chooser.scheme_bits[_enc->chooser.scheme_list[0]]<intrabits)return 1; - } - _enc->ncoded_mbis=ncoded_mbis; - /*Compact the coded fragment list.*/ - { - ptrdiff_t ncoded_fragis; - ncoded_fragis=_enc->state.ncoded_fragis[0]; - for(pli=1;pli<3;pli++){ - memmove(_enc->state.coded_fragis+ncoded_fragis, - _enc->state.coded_fragis+_enc->state.fplanes[pli].froffset, - _enc->state.ncoded_fragis[pli]*sizeof(*_enc->state.coded_fragis)); - ncoded_fragis+=_enc->state.ncoded_fragis[pli]; - } - _enc->state.ntotal_coded_fragis=ncoded_fragis; - } - return 0; -} - -#if defined(OC_COLLECT_METRICS) -# include -# include - -/*TODO: It may be helpful (for block-level quantizers especially) to separate - out the contributions from AC and DC into separate tables.*/ - -# define OC_ZWEIGHT (0.25) - -static void oc_mode_metrics_add(oc_mode_metrics *_metrics, - double _w,int _satd,int _rate,double _rmse){ - double rate; - /*Accumulate statistics without the scaling; this lets us change the scale - factor yet still use old data.*/ - rate=ldexp(_rate,-OC_BIT_SCALE); - if(_metrics->fragw>0){ - double dsatd; - double drate; - double drmse; - double w; - dsatd=_satd-_metrics->satd/_metrics->fragw; - drate=rate-_metrics->rate/_metrics->fragw; - drmse=_rmse-_metrics->rmse/_metrics->fragw; - w=_metrics->fragw*_w/(_metrics->fragw+_w); - _metrics->satd2+=dsatd*dsatd*w; - _metrics->satdrate+=dsatd*drate*w; - _metrics->rate2+=drate*drate*w; - _metrics->satdrmse+=dsatd*drmse*w; - _metrics->rmse2+=drmse*drmse*w; - } - _metrics->fragw+=_w; - _metrics->satd+=_satd*_w; - _metrics->rate+=rate*_w; - _metrics->rmse+=_rmse*_w; -} - -static void oc_mode_metrics_merge(oc_mode_metrics *_dst, - const oc_mode_metrics *_src,int _n){ - int i; - /*Find a non-empty set of metrics.*/ - for(i=0;i<_n&&_src[i].fragw<=0;i++); - if(i>=_n){ - memset(_dst,0,sizeof(*_dst)); - return; - } - memcpy(_dst,_src+i,sizeof(*_dst)); - /*And iterate over the remaining non-empty sets of metrics.*/ - for(i++;i<_n;i++)if(_src[i].fragw>0){ - double wa; - double wb; - double dsatd; - double drate; - double drmse; - double w; - wa=_dst->fragw; - wb=_src[i].fragw; - dsatd=_src[i].satd/wb-_dst->satd/wa; - drate=_src[i].rate/wb-_dst->rate/wa; - drmse=_src[i].rmse/wb-_dst->rmse/wa; - w=wa*wb/(wa+wb); - _dst->fragw+=_src[i].fragw; - _dst->satd+=_src[i].satd; - _dst->rate+=_src[i].rate; - _dst->rmse+=_src[i].rmse; - _dst->satd2+=_src[i].satd2+dsatd*dsatd*w; - _dst->satdrate+=_src[i].satdrate+dsatd*drate*w; - _dst->rate2+=_src[i].rate2+drate*drate*w; - _dst->satdrmse+=_src[i].satdrmse+dsatd*drmse*w; - _dst->rmse2+=_src[i].rmse2+drmse*drmse*w; - } -} - -/*Compile collected SATD/rate/RMSE metrics into a form that's immediately - useful for mode decision.*/ -static void oc_enc_mode_metrics_update(oc_enc_ctx *_enc,int _qi){ - int pli; - int qti; - oc_restore_fpu(&_enc->state); - /*Convert raw collected data into cleaned up sample points.*/ - for(pli=0;pli<3;pli++){ - for(qti=0;qti<2;qti++){ - double fragw; - int bin0; - int bin1; - int bin; - fragw=0; - bin0=bin1=0; - for(bin=0;bin=OC_ZWEIGHT){ - fragw-=OC_MODE_METRICS[_qi][pli][qti][bin0++].fragw; - } - /*Merge statistics and fit lines.*/ - oc_mode_metrics_merge(&metrics, - OC_MODE_METRICS[_qi][pli][qti]+bin0,bin1-bin0); - if(metrics.fragw>0&&metrics.satd2>0){ - double a; - double b; - double msatd; - double mrate; - double mrmse; - double rate; - double rmse; - msatd=metrics.satd/metrics.fragw; - mrate=metrics.rate/metrics.fragw; - mrmse=metrics.rmse/metrics.fragw; - /*Compute the points on these lines corresponding to the actual bin - value.*/ - b=metrics.satdrate/metrics.satd2; - a=mrate-b*msatd; - rate=ldexp(a+b*(bin<>1); - return -_extra_bits; -} - -/*Handles the pure zero run tokens.*/ -static ptrdiff_t oc_token_skip_zrl(int _token,int _extra_bits){ - return _extra_bits+1; -} - -/*Handles a normal coefficient value token.*/ -static ptrdiff_t oc_token_skip_val(void){ - return 1; -} - -/*Handles a category 1A zero run/coefficient value combo token.*/ -static ptrdiff_t oc_token_skip_run_cat1a(int _token){ - return _token-OC_DCT_RUN_CAT1A+2; -} - -/*Handles category 1b, 1c, 2a, and 2b zero run/coefficient value combo tokens.*/ -static ptrdiff_t oc_token_skip_run(int _token,int _extra_bits){ - int run_cati; - int ncoeffs_mask; - int ncoeffs_adjust; - run_cati=_token-OC_DCT_RUN_CAT1B; - ncoeffs_mask=OC_BYTE_TABLE32(3,7,0,1,run_cati); - ncoeffs_adjust=OC_BYTE_TABLE32(7,11,2,3,run_cati); - return (_extra_bits&ncoeffs_mask)+ncoeffs_adjust; -} - -/*A jump table for computing the number of coefficients or blocks to skip for - a given token value. - This reduces all the conditional branches, etc., needed to parse these token - values down to one indirect jump.*/ -static const oc_token_skip_func OC_TOKEN_SKIP_TABLE[TH_NDCT_TOKENS]={ - oc_token_skip_eob, - oc_token_skip_eob, - oc_token_skip_eob, - oc_token_skip_eob, - oc_token_skip_eob, - oc_token_skip_eob, - oc_token_skip_eob6, - oc_token_skip_zrl, - oc_token_skip_zrl, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_val, - (oc_token_skip_func)oc_token_skip_run_cat1a, - (oc_token_skip_func)oc_token_skip_run_cat1a, - (oc_token_skip_func)oc_token_skip_run_cat1a, - (oc_token_skip_func)oc_token_skip_run_cat1a, - (oc_token_skip_func)oc_token_skip_run_cat1a, - oc_token_skip_run, - oc_token_skip_run, - oc_token_skip_run, - oc_token_skip_run -}; - -/*Determines the number of blocks or coefficients to be skipped for a given - token value. - _token: The token value to skip. - _extra_bits: The extra bits attached to this token. - Return: A positive value indicates that number of coefficients are to be - skipped in the current block. - Otherwise, the negative of the return value indicates that number of - blocks are to be ended. - 0 will never be returned, so that at least one coefficient in one - block will always be decoded for every token.*/ -static ptrdiff_t oc_dct_token_skip(int _token,int _extra_bits){ - return (*OC_TOKEN_SKIP_TABLE[_token])(_token,_extra_bits); -} - - - -void oc_enc_mode_metrics_collect(oc_enc_ctx *_enc){ - static const unsigned char OC_ZZI_HUFF_OFFSET[64]={ - 0,16,16,16,16,16,32,32, - 32,32,32,32,32,32,32,48, - 48,48,48,48,48,48,48,48, - 48,48,48,48,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64 - }; - const oc_fragment *frags; - const unsigned *frag_satd; - const unsigned *frag_ssd; - const ptrdiff_t *coded_fragis; - ptrdiff_t ncoded_fragis; - ptrdiff_t fragii; - double fragw; - int qti; - int qii; - int qi; - int pli; - int zzi; - int token; - int eb; - oc_restore_fpu(&_enc->state); - /*Load any existing mode metrics if we haven't already.*/ - if(!oc_has_mode_metrics){ - FILE *fmetrics; - memset(OC_MODE_METRICS,0,sizeof(OC_MODE_METRICS)); - fmetrics=fopen("modedec.stats","rb"); - if(fmetrics!=NULL){ - fread(OC_MODE_METRICS,sizeof(OC_MODE_METRICS),1,fmetrics); - fclose(fmetrics); - } - for(qi=0;qi<64;qi++)oc_enc_mode_metrics_update(_enc,qi); - oc_has_mode_metrics=1; - } - qti=_enc->state.frame_type; - frags=_enc->state.frags; - frag_satd=_enc->frag_satd; - frag_ssd=_enc->frag_ssd; - coded_fragis=_enc->state.coded_fragis; - ncoded_fragis=fragii=0; - /*Weight the fragments by the inverse frame size; this prevents HD content - from dominating the statistics.*/ - fragw=1.0/_enc->state.nfrags; - for(pli=0;pli<3;pli++){ - ptrdiff_t ti[64]; - int eob_token[64]; - int eob_run[64]; - /*Set up token indices and eob run counts. - We don't bother trying to figure out the real cost of the runs that span - coefficients; instead we use the costs that were available when R-D - token optimization was done.*/ - for(zzi=0;zzi<64;zzi++){ - ti[zzi]=_enc->dct_token_offs[pli][zzi]; - if(ti[zzi]>0){ - token=_enc->dct_tokens[pli][zzi][0]; - eb=_enc->extra_bits[pli][zzi][0]; - eob_token[zzi]=token; - eob_run[zzi]=-oc_dct_token_skip(token,eb); - } - else{ - eob_token[zzi]=OC_NDCT_EOB_TOKEN_MAX; - eob_run[zzi]=0; - } - } - /*Scan the list of coded fragments for this plane.*/ - ncoded_fragis+=_enc->state.ncoded_fragis[pli]; - for(;fragii0){ - /*We've reached the end of the block.*/ - eob_run[zzi]--; - break; - } - huffi=_enc->huff_idxs[qti][zzi>0][pli+1>>1] - +OC_ZZI_HUFF_OFFSET[zzi]; - if(eob_token[zzi]huff_codes[huffi][eob_token[zzi]].nbits - +OC_DCT_TOKEN_EXTRA_BITS[eob_token[zzi]]; - eob_token[zzi]=OC_NDCT_EOB_TOKEN_MAX; - } - token=_enc->dct_tokens[pli][zzi][ti[zzi]]; - eb=_enc->extra_bits[pli][zzi][ti[zzi]]; - ti[zzi]++; - skip=oc_dct_token_skip(token,eb); - if(skip<0){ - eob_token[zzi]=token; - eob_run[zzi]=-skip; - } - else{ - /*A regular DCT value token; accumulate the bits for it.*/ - frag_bits+=_enc->huff_codes[huffi][token].nbits - +OC_DCT_TOKEN_EXTRA_BITS[token]; - zzi+=skip; - } - } - mb_mode=frags[fragi].mb_mode; - qi=_enc->state.qis[frags[fragi].qii]; - satd=frag_satd[fragi]<<(pli+1&2); - bin=OC_MINI(satd>>OC_SAD_SHIFT,OC_SAD_BINS-1); - oc_mode_metrics_add(OC_MODE_METRICS[qi][pli][mb_mode!=OC_MODE_INTRA]+bin, - fragw,satd,frag_bits<state.nqis;qii++){ - oc_enc_mode_metrics_update(_enc,_enc->state.qis[qii]); - } -} - -void oc_enc_mode_metrics_dump(oc_enc_ctx *_enc){ - FILE *fmetrics; - int qi; - /*Generate sample points for complete list of QI values.*/ - for(qi=0;qi<64;qi++)oc_enc_mode_metrics_update(_enc,qi); - fmetrics=fopen("modedec.stats","wb"); - if(fmetrics!=NULL){ - fwrite(OC_MODE_METRICS,sizeof(OC_MODE_METRICS),1,fmetrics); - fclose(fmetrics); - } - fprintf(stdout, - "/*File generated by libtheora with OC_COLLECT_METRICS" - " defined at compile time.*/\n" - "#if !defined(_modedec_H)\n" - "# define _modedec_H (1)\n" - "\n" - "\n" - "\n" - "# if defined(OC_COLLECT_METRICS)\n" - "typedef struct oc_mode_metrics oc_mode_metrics;\n" - "# endif\n" - "typedef struct oc_mode_rd oc_mode_rd;\n" - "\n" - "\n" - "\n" - "/*The number of extra bits of precision at which to store rate" - " metrics.*/\n" - "# define OC_BIT_SCALE (%i)\n" - "/*The number of extra bits of precision at which to store RMSE metrics.\n" - " This must be at least half OC_BIT_SCALE (rounded up).*/\n" - "# define OC_RMSE_SCALE (%i)\n" - "/*The number of bins to partition statistics into.*/\n" - "# define OC_SAD_BINS (%i)\n" - "/*The number of bits of precision to drop" - " from SAD scores to assign them to a\n" - " bin.*/\n" - "# define OC_SAD_SHIFT (%i)\n" - "\n" - "\n" - "\n" - "# if defined(OC_COLLECT_METRICS)\n" - "struct oc_mode_metrics{\n" - " double fragw;\n" - " double satd;\n" - " double rate;\n" - " double rmse;\n" - " double satd2;\n" - " double satdrate;\n" - " double rate2;\n" - " double satdrmse;\n" - " double rmse2;\n" - "};\n" - "\n" - "\n" - "int oc_has_mode_metrics;\n" - "oc_mode_metrics OC_MODE_METRICS[64][3][2][OC_SAD_BINS];\n" - "# endif\n" - "\n" - "\n" - "\n" - "struct oc_mode_rd{\n" - " ogg_int16_t rate;\n" - " ogg_int16_t rmse;\n" - "};\n" - "\n" - "\n" - "# if !defined(OC_COLLECT_METRICS)\n" - "static const\n" - "# endif\n" - "oc_mode_rd OC_MODE_RD[64][3][2][OC_SAD_BINS]={\n", - OC_BIT_SCALE,OC_RMSE_SCALE,OC_SAD_BINS,OC_SAD_SHIFT); - for(qi=0;qi<64;qi++){ - int pli; - fprintf(stdout," {\n"); - for(pli=0;pli<3;pli++){ - int qti; - fprintf(stdout," {\n"); - for(qti=0;qti<2;qti++){ - int bin; - static const char *pl_names[3]={"Y'","Cb","Cr"}; - static const char *qti_names[2]={"INTRA","INTER"}; - fprintf(stdout," /*%s qi=%i %s*/\n", - pl_names[pli],qi,qti_names[qti]); - fprintf(stdout," {\n"); - fprintf(stdout," "); - for(bin=0;bin -#include -#include -#include "apiwrapper.h" - - - -const char *theora_version_string(void){ - return th_version_string(); -} - -ogg_uint32_t theora_version_number(void){ - return th_version_number(); -} - -void theora_info_init(theora_info *_ci){ - memset(_ci,0,sizeof(*_ci)); -} - -void theora_info_clear(theora_info *_ci){ - th_api_wrapper *api; - api=(th_api_wrapper *)_ci->codec_setup; - memset(_ci,0,sizeof(*_ci)); - if(api!=NULL){ - if(api->clear!=NULL)(*api->clear)(api); - _ogg_free(api); - } -} - -void theora_clear(theora_state *_th){ - /*Provide compatibility with mixed encoder and decoder shared lib versions.*/ - if(_th->internal_decode!=NULL){ - (*((oc_state_dispatch_vtable *)_th->internal_decode)->clear)(_th); - } - if(_th->internal_encode!=NULL){ - (*((oc_state_dispatch_vtable *)_th->internal_encode)->clear)(_th); - } - if(_th->i!=NULL)theora_info_clear(_th->i); - memset(_th,0,sizeof(*_th)); -} - -int theora_control(theora_state *_th,int _req,void *_buf,size_t _buf_sz){ - /*Provide compatibility with mixed encoder and decoder shared lib versions.*/ - if(_th->internal_decode!=NULL){ - return (*((oc_state_dispatch_vtable *)_th->internal_decode)->control)(_th, - _req,_buf,_buf_sz); - } - else if(_th->internal_encode!=NULL){ - return (*((oc_state_dispatch_vtable *)_th->internal_encode)->control)(_th, - _req,_buf,_buf_sz); - } - else return TH_EINVAL; -} - -ogg_int64_t theora_granule_frame(theora_state *_th,ogg_int64_t _gp){ - /*Provide compatibility with mixed encoder and decoder shared lib versions.*/ - if(_th->internal_decode!=NULL){ - return (*((oc_state_dispatch_vtable *)_th->internal_decode)->granule_frame)( - _th,_gp); - } - else if(_th->internal_encode!=NULL){ - return (*((oc_state_dispatch_vtable *)_th->internal_encode)->granule_frame)( - _th,_gp); - } - else return -1; -} - -double theora_granule_time(theora_state *_th, ogg_int64_t _gp){ - /*Provide compatibility with mixed encoder and decoder shared lib versions.*/ - if(_th->internal_decode!=NULL){ - return (*((oc_state_dispatch_vtable *)_th->internal_decode)->granule_time)( - _th,_gp); - } - else if(_th->internal_encode!=NULL){ - return (*((oc_state_dispatch_vtable *)_th->internal_encode)->granule_time)( - _th,_gp); - } - else return -1; -} - -void oc_theora_info2th_info(th_info *_info,const theora_info *_ci){ - _info->version_major=_ci->version_major; - _info->version_minor=_ci->version_minor; - _info->version_subminor=_ci->version_subminor; - _info->frame_width=_ci->width; - _info->frame_height=_ci->height; - _info->pic_width=_ci->frame_width; - _info->pic_height=_ci->frame_height; - _info->pic_x=_ci->offset_x; - _info->pic_y=_ci->offset_y; - _info->fps_numerator=_ci->fps_numerator; - _info->fps_denominator=_ci->fps_denominator; - _info->aspect_numerator=_ci->aspect_numerator; - _info->aspect_denominator=_ci->aspect_denominator; - switch(_ci->colorspace){ - case OC_CS_ITU_REC_470M:_info->colorspace=TH_CS_ITU_REC_470M;break; - case OC_CS_ITU_REC_470BG:_info->colorspace=TH_CS_ITU_REC_470BG;break; - default:_info->colorspace=TH_CS_UNSPECIFIED;break; - } - switch(_ci->pixelformat){ - case OC_PF_420:_info->pixel_fmt=TH_PF_420;break; - case OC_PF_422:_info->pixel_fmt=TH_PF_422;break; - case OC_PF_444:_info->pixel_fmt=TH_PF_444;break; - default:_info->pixel_fmt=TH_PF_RSVD; - } - _info->target_bitrate=_ci->target_bitrate; - _info->quality=_ci->quality; - _info->keyframe_granule_shift=_ci->keyframe_frequency_force>0? - OC_MINI(31,oc_ilog(_ci->keyframe_frequency_force-1)):0; -} - -int theora_packet_isheader(ogg_packet *_op){ - return th_packet_isheader(_op); -} - -int theora_packet_iskeyframe(ogg_packet *_op){ - return th_packet_iskeyframe(_op); -} - -int theora_granule_shift(theora_info *_ci){ - /*This breaks when keyframe_frequency_force is not positive or is larger than - 2**31 (if your int is more than 32 bits), but that's what the original - function does.*/ - return oc_ilog(_ci->keyframe_frequency_force-1); -} - -void theora_comment_init(theora_comment *_tc){ - th_comment_init((th_comment *)_tc); -} - -char *theora_comment_query(theora_comment *_tc,char *_tag,int _count){ - return th_comment_query((th_comment *)_tc,_tag,_count); -} - -int theora_comment_query_count(theora_comment *_tc,char *_tag){ - return th_comment_query_count((th_comment *)_tc,_tag); -} - -void theora_comment_clear(theora_comment *_tc){ - th_comment_clear((th_comment *)_tc); -} - -void theora_comment_add(theora_comment *_tc,char *_comment){ - th_comment_add((th_comment *)_tc,_comment); -} - -void theora_comment_add_tag(theora_comment *_tc, char *_tag, char *_value){ - th_comment_add_tag((th_comment *)_tc,_tag,_value); -} diff --git a/Engine/lib/libtheora/lib/apiwrapper.h b/Engine/lib/libtheora/lib/apiwrapper.h deleted file mode 100644 index 93454d7bd..000000000 --- a/Engine/lib/libtheora/lib/apiwrapper.h +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: apiwrapper.h 13596 2007-08-23 20:05:38Z tterribe $ - - ********************************************************************/ - -#if !defined(_apiwrapper_H) -# define _apiwrapper_H (1) -# include -# include -# include "theora/theoradec.h" -# include "theora/theoraenc.h" -# include "internal.h" - -typedef struct th_api_wrapper th_api_wrapper; -typedef struct th_api_info th_api_info; - -/*Provide an entry point for the codec setup to clear itself in case we ever - want to break pieces off into a common base library shared by encoder and - decoder. - In addition, this makes several other pieces of the API wrapper cleaner.*/ -typedef void (*oc_setup_clear_func)(void *_ts); - -/*Generally only one of these pointers will be non-NULL in any given instance. - Technically we do not even really need this struct, since we should be able - to figure out which one from "context", but doing it this way makes sure we - don't flub it up.*/ -struct th_api_wrapper{ - oc_setup_clear_func clear; - th_setup_info *setup; - th_dec_ctx *decode; - th_enc_ctx *encode; -}; - -struct th_api_info{ - th_api_wrapper api; - theora_info info; -}; - - -void oc_theora_info2th_info(th_info *_info,const theora_info *_ci); - -#endif diff --git a/Engine/lib/libtheora/lib/bitpack.c b/Engine/lib/libtheora/lib/bitpack.c deleted file mode 100644 index 8195003ba..000000000 --- a/Engine/lib/libtheora/lib/bitpack.c +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggTheora SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: packing variable sized words into an octet stream - last mod: $Id: bitpack.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#include -#include -#include "bitpack.h" - -/*We're 'MSb' endian; if we write a word but read individual bits, - then we'll read the MSb first.*/ - -void oc_pack_readinit(oc_pack_buf *_b,unsigned char *_buf,long _bytes){ - memset(_b,0,sizeof(*_b)); - _b->ptr=_buf; - _b->stop=_buf+_bytes; -} - -static oc_pb_window oc_pack_refill(oc_pack_buf *_b,int _bits){ - const unsigned char *ptr; - const unsigned char *stop; - oc_pb_window window; - int available; - window=_b->window; - available=_b->bits; - ptr=_b->ptr; - stop=_b->stop; - while(available<=OC_PB_WINDOW_SIZE-8&&ptrptr=ptr; - if(_bits>available){ - if(ptr>=stop){ - _b->eof=1; - available=OC_LOTS_OF_BITS; - } - else window|=*ptr>>(available&7); - } - _b->bits=available; - return window; -} - -int oc_pack_look1(oc_pack_buf *_b){ - oc_pb_window window; - int available; - window=_b->window; - available=_b->bits; - if(available<1)_b->window=window=oc_pack_refill(_b,1); - return window>>OC_PB_WINDOW_SIZE-1; -} - -void oc_pack_adv1(oc_pack_buf *_b){ - _b->window<<=1; - _b->bits--; -} - -/*Here we assume that 0<=_bits&&_bits<=32.*/ -long oc_pack_read(oc_pack_buf *_b,int _bits){ - oc_pb_window window; - int available; - long result; - window=_b->window; - available=_b->bits; - if(_bits==0)return 0; - if(available<_bits){ - window=oc_pack_refill(_b,_bits); - available=_b->bits; - } - result=window>>OC_PB_WINDOW_SIZE-_bits; - available-=_bits; - window<<=1; - window<<=_bits-1; - _b->bits=available; - _b->window=window; - return result; -} - -int oc_pack_read1(oc_pack_buf *_b){ - oc_pb_window window; - int available; - int result; - window=_b->window; - available=_b->bits; - if(available<1){ - window=oc_pack_refill(_b,1); - available=_b->bits; - } - result=window>>OC_PB_WINDOW_SIZE-1; - available--; - window<<=1; - _b->bits=available; - _b->window=window; - return result; -} - -long oc_pack_bytes_left(oc_pack_buf *_b){ - if(_b->eof)return -1; - return _b->stop-_b->ptr+(_b->bits>>3); -} diff --git a/Engine/lib/libtheora/lib/bitpack.h b/Engine/lib/libtheora/lib/bitpack.h deleted file mode 100644 index a020a292f..000000000 --- a/Engine/lib/libtheora/lib/bitpack.h +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggTheora SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: packing variable sized words into an octet stream - last mod: $Id: bitwise.c 7675 2004-09-01 00:34:39Z xiphmont $ - - ********************************************************************/ -#if !defined(_bitpack_H) -# define _bitpack_H (1) -# include - - - -typedef unsigned long oc_pb_window; -typedef struct oc_pack_buf oc_pack_buf; - - - -# define OC_PB_WINDOW_SIZE ((int)sizeof(oc_pb_window)*CHAR_BIT) -/*This is meant to be a large, positive constant that can still be efficiently - loaded as an immediate (on platforms like ARM, for example). - Even relatively modest values like 100 would work fine.*/ -# define OC_LOTS_OF_BITS (0x40000000) - - - -struct oc_pack_buf{ - oc_pb_window window; - const unsigned char *ptr; - const unsigned char *stop; - int bits; - int eof; -}; - -void oc_pack_readinit(oc_pack_buf *_b,unsigned char *_buf,long _bytes); -int oc_pack_look1(oc_pack_buf *_b); -void oc_pack_adv1(oc_pack_buf *_b); -/*Here we assume 0<=_bits&&_bits<=32.*/ -long oc_pack_read(oc_pack_buf *_b,int _bits); -int oc_pack_read1(oc_pack_buf *_b); -/* returns -1 for read beyond EOF, or the number of whole bytes available */ -long oc_pack_bytes_left(oc_pack_buf *_b); - -/*These two functions are implemented locally in huffdec.c*/ -/*Read in bits without advancing the bitptr. - Here we assume 0<=_bits&&_bits<=32.*/ -/*static int oc_pack_look(oc_pack_buf *_b,int _bits);*/ -/*static void oc_pack_adv(oc_pack_buf *_b,int _bits);*/ - -#endif diff --git a/Engine/lib/libtheora/lib/cpu.c b/Engine/lib/libtheora/lib/cpu.c deleted file mode 100644 index a863aad7f..000000000 --- a/Engine/lib/libtheora/lib/cpu.c +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - CPU capability detection for x86 processors. - Originally written by Rudolf Marek. - - function: - last mod: $Id: cpu.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include "cpu.h" - -#if !defined(OC_X86_ASM) -static ogg_uint32_t oc_cpu_flags_get(void){ - return 0; -} -#else -# if !defined(_MSC_VER) -# if defined(__amd64__)||defined(__x86_64__) -/*On x86-64, gcc seems to be able to figure out how to save %rbx for us when - compiling with -fPIC.*/ -# define cpuid(_op,_eax,_ebx,_ecx,_edx) \ - __asm__ __volatile__( \ - "cpuid\n\t" \ - :[eax]"=a"(_eax),[ebx]"=b"(_ebx),[ecx]"=c"(_ecx),[edx]"=d"(_edx) \ - :"a"(_op) \ - :"cc" \ - ) -# else -/*On x86-32, not so much.*/ -# define cpuid(_op,_eax,_ebx,_ecx,_edx) \ - __asm__ __volatile__( \ - "xchgl %%ebx,%[ebx]\n\t" \ - "cpuid\n\t" \ - "xchgl %%ebx,%[ebx]\n\t" \ - :[eax]"=a"(_eax),[ebx]"=r"(_ebx),[ecx]"=c"(_ecx),[edx]"=d"(_edx) \ - :"a"(_op) \ - :"cc" \ - ) -# endif -# else -/*Why does MSVC need this complicated rigamarole? - At this point I honestly do not care.*/ - -/*Visual C cpuid helper function. - For VS2005 we could as well use the _cpuid builtin, but that wouldn't work - for VS2003 users, so we do it in inline assembler.*/ -static void oc_cpuid_helper(ogg_uint32_t _cpu_info[4],ogg_uint32_t _op){ - _asm{ - mov eax,[_op] - mov esi,_cpu_info - cpuid - mov [esi+0],eax - mov [esi+4],ebx - mov [esi+8],ecx - mov [esi+12],edx - } -} - -# define cpuid(_op,_eax,_ebx,_ecx,_edx) \ - do{ \ - ogg_uint32_t cpu_info[4]; \ - oc_cpuid_helper(cpu_info,_op); \ - (_eax)=cpu_info[0]; \ - (_ebx)=cpu_info[1]; \ - (_ecx)=cpu_info[2]; \ - (_edx)=cpu_info[3]; \ - }while(0) - -static void oc_detect_cpuid_helper(ogg_uint32_t *_eax,ogg_uint32_t *_ebx){ - _asm{ - pushfd - pushfd - pop eax - mov ebx,eax - xor eax,200000h - push eax - popfd - pushfd - pop eax - popfd - mov ecx,_eax - mov [ecx],eax - mov ecx,_ebx - mov [ecx],ebx - } -} -# endif - -static ogg_uint32_t oc_parse_intel_flags(ogg_uint32_t _edx,ogg_uint32_t _ecx){ - ogg_uint32_t flags; - /*If there isn't even MMX, give up.*/ - if(!(_edx&0x00800000))return 0; - flags=OC_CPU_X86_MMX; - if(_edx&0x02000000)flags|=OC_CPU_X86_MMXEXT|OC_CPU_X86_SSE; - if(_edx&0x04000000)flags|=OC_CPU_X86_SSE2; - if(_ecx&0x00000001)flags|=OC_CPU_X86_PNI; - if(_ecx&0x00000100)flags|=OC_CPU_X86_SSSE3; - if(_ecx&0x00080000)flags|=OC_CPU_X86_SSE4_1; - if(_ecx&0x00100000)flags|=OC_CPU_X86_SSE4_2; - return flags; -} - -static ogg_uint32_t oc_parse_amd_flags(ogg_uint32_t _edx,ogg_uint32_t _ecx){ - ogg_uint32_t flags; - /*If there isn't even MMX, give up.*/ - if(!(_edx&0x00800000))return 0; - flags=OC_CPU_X86_MMX; - if(_edx&0x00400000)flags|=OC_CPU_X86_MMXEXT; - if(_edx&0x80000000)flags|=OC_CPU_X86_3DNOW; - if(_edx&0x40000000)flags|=OC_CPU_X86_3DNOWEXT; - if(_ecx&0x00000040)flags|=OC_CPU_X86_SSE4A; - if(_ecx&0x00000800)flags|=OC_CPU_X86_SSE5; - return flags; -} - -static ogg_uint32_t oc_cpu_flags_get(void){ - ogg_uint32_t flags; - ogg_uint32_t eax; - ogg_uint32_t ebx; - ogg_uint32_t ecx; - ogg_uint32_t edx; -# if !defined(__amd64__)&&!defined(__x86_64__) - /*Not all x86-32 chips support cpuid, so we have to check.*/ -# if !defined(_MSC_VER) - __asm__ __volatile__( - "pushfl\n\t" - "pushfl\n\t" - "popl %[a]\n\t" - "movl %[a],%[b]\n\t" - "xorl $0x200000,%[a]\n\t" - "pushl %[a]\n\t" - "popfl\n\t" - "pushfl\n\t" - "popl %[a]\n\t" - "popfl\n\t" - :[a]"=r"(eax),[b]"=r"(ebx) - : - :"cc" - ); -# else - oc_detect_cpuid_helper(&eax,&ebx); -# endif - /*No cpuid.*/ - if(eax==ebx)return 0; -# endif - cpuid(0,eax,ebx,ecx,edx); - /* l e t n I e n i u n e G*/ - if(ecx==0x6C65746E&&edx==0x49656E69&&ebx==0x756E6547|| - /* 6 8 x M T e n i u n e G*/ - ecx==0x3638784D&&edx==0x54656E69&&ebx==0x756E6547){ - /*Intel, Transmeta (tested with Crusoe TM5800):*/ - cpuid(1,eax,ebx,ecx,edx); - flags=oc_parse_intel_flags(edx,ecx); - } - /* D M A c i t n e h t u A*/ - else if(ecx==0x444D4163&&edx==0x69746E65&&ebx==0x68747541|| - /* C S N y b e d o e G*/ - ecx==0x43534e20&&edx==0x79622065&&ebx==0x646f6547){ - /*AMD, Geode:*/ - cpuid(0x80000000,eax,ebx,ecx,edx); - if(eax<0x80000001)flags=0; - else{ - cpuid(0x80000001,eax,ebx,ecx,edx); - flags=oc_parse_amd_flags(edx,ecx); - } - /*Also check for SSE.*/ - cpuid(1,eax,ebx,ecx,edx); - flags|=oc_parse_intel_flags(edx,ecx); - } - /*Technically some VIA chips can be configured in the BIOS to return any - string here the user wants. - There is a special detection method that can be used to identify such - processors, but in my opinion, if the user really wants to change it, they - deserve what they get.*/ - /* s l u a H r u a t n e C*/ - else if(ecx==0x736C7561&&edx==0x48727561&&ebx==0x746E6543){ - /*VIA:*/ - /*I only have documentation for the C7 (Esther) and Isaiah (forthcoming) - chips (thanks to the engineers from Centaur Technology who provided it). - These chips support Intel-like cpuid info. - The C3-2 (Nehemiah) cores appear to, as well.*/ - cpuid(1,eax,ebx,ecx,edx); - flags=oc_parse_intel_flags(edx,ecx); - if(eax>=0x80000001){ - /*The (non-Nehemiah) C3 processors support AMD-like cpuid info. - We need to check this even if the Intel test succeeds to pick up 3DNow! - support on these processors. - Unlike actual AMD processors, we cannot _rely_ on this info, since - some cores (e.g., the 693 stepping of the Nehemiah) claim to support - this function, yet return edx=0, despite the Intel test indicating - MMX support. - Therefore the features detected here are strictly added to those - detected by the Intel test.*/ - /*TODO: How about earlier chips?*/ - cpuid(0x80000001,eax,ebx,ecx,edx); - /*Note: As of the C7, this function returns Intel-style extended feature - flags, not AMD-style. - Currently, this only defines bits 11, 20, and 29 (0x20100800), which - do not conflict with any of the AMD flags we inspect. - For the remaining bits, Intel tells us, "Do not count on their value", - but VIA assures us that they will all be zero (at least on the C7 and - Isaiah chips). - In the (unlikely) event a future processor uses bits 18, 19, 30, or 31 - (0xC0C00000) for something else, we will have to add code to detect - the model to decide when it is appropriate to inspect them.*/ - flags|=oc_parse_amd_flags(edx,ecx); - } - } - else{ - /*Implement me.*/ - flags=0; - } - return flags; -} -#endif diff --git a/Engine/lib/libtheora/lib/cpu.h b/Engine/lib/libtheora/lib/cpu.h deleted file mode 100644 index a43c957a3..000000000 --- a/Engine/lib/libtheora/lib/cpu.h +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - function: - last mod: $Id: cpu.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#if !defined(_x86_cpu_H) -# define _x86_cpu_H (1) -#include "internal.h" - -#define OC_CPU_X86_MMX (1<<0) -#define OC_CPU_X86_3DNOW (1<<1) -#define OC_CPU_X86_3DNOWEXT (1<<2) -#define OC_CPU_X86_MMXEXT (1<<3) -#define OC_CPU_X86_SSE (1<<4) -#define OC_CPU_X86_SSE2 (1<<5) -#define OC_CPU_X86_PNI (1<<6) -#define OC_CPU_X86_SSSE3 (1<<7) -#define OC_CPU_X86_SSE4_1 (1<<8) -#define OC_CPU_X86_SSE4_2 (1<<9) -#define OC_CPU_X86_SSE4A (1<<10) -#define OC_CPU_X86_SSE5 (1<<11) - -#endif diff --git a/Engine/lib/libtheora/lib/dct.h b/Engine/lib/libtheora/lib/dct.h deleted file mode 100644 index 24ba6f111..000000000 --- a/Engine/lib/libtheora/lib/dct.h +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: dct.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -/*Definitions shared by the forward and inverse DCT transforms.*/ -#if !defined(_dct_H) -# define _dct_H (1) - -/*cos(n*pi/16) (resp. sin(m*pi/16)) scaled by 65536.*/ -#define OC_C1S7 ((ogg_int32_t)64277) -#define OC_C2S6 ((ogg_int32_t)60547) -#define OC_C3S5 ((ogg_int32_t)54491) -#define OC_C4S4 ((ogg_int32_t)46341) -#define OC_C5S3 ((ogg_int32_t)36410) -#define OC_C6S2 ((ogg_int32_t)25080) -#define OC_C7S1 ((ogg_int32_t)12785) - -#endif diff --git a/Engine/lib/libtheora/lib/decapiwrapper.c b/Engine/lib/libtheora/lib/decapiwrapper.c deleted file mode 100644 index 12ea475d1..000000000 --- a/Engine/lib/libtheora/lib/decapiwrapper.c +++ /dev/null @@ -1,193 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: decapiwrapper.c 13596 2007-08-23 20:05:38Z tterribe $ - - ********************************************************************/ - -#include -#include -#include -#include "apiwrapper.h" -#include "decint.h" -#include "theora/theoradec.h" - -static void th_dec_api_clear(th_api_wrapper *_api){ - if(_api->setup)th_setup_free(_api->setup); - if(_api->decode)th_decode_free(_api->decode); - memset(_api,0,sizeof(*_api)); -} - -static void theora_decode_clear(theora_state *_td){ - if(_td->i!=NULL)theora_info_clear(_td->i); - memset(_td,0,sizeof(*_td)); -} - -static int theora_decode_control(theora_state *_td,int _req, - void *_buf,size_t _buf_sz){ - return th_decode_ctl(((th_api_wrapper *)_td->i->codec_setup)->decode, - _req,_buf,_buf_sz); -} - -static ogg_int64_t theora_decode_granule_frame(theora_state *_td, - ogg_int64_t _gp){ - return th_granule_frame(((th_api_wrapper *)_td->i->codec_setup)->decode,_gp); -} - -static double theora_decode_granule_time(theora_state *_td,ogg_int64_t _gp){ - return th_granule_time(((th_api_wrapper *)_td->i->codec_setup)->decode,_gp); -} - -static const oc_state_dispatch_vtable OC_DEC_DISPATCH_VTBL={ - (oc_state_clear_func)theora_decode_clear, - (oc_state_control_func)theora_decode_control, - (oc_state_granule_frame_func)theora_decode_granule_frame, - (oc_state_granule_time_func)theora_decode_granule_time, -}; - -static void th_info2theora_info(theora_info *_ci,const th_info *_info){ - _ci->version_major=_info->version_major; - _ci->version_minor=_info->version_minor; - _ci->version_subminor=_info->version_subminor; - _ci->width=_info->frame_width; - _ci->height=_info->frame_height; - _ci->frame_width=_info->pic_width; - _ci->frame_height=_info->pic_height; - _ci->offset_x=_info->pic_x; - _ci->offset_y=_info->pic_y; - _ci->fps_numerator=_info->fps_numerator; - _ci->fps_denominator=_info->fps_denominator; - _ci->aspect_numerator=_info->aspect_numerator; - _ci->aspect_denominator=_info->aspect_denominator; - switch(_info->colorspace){ - case TH_CS_ITU_REC_470M:_ci->colorspace=OC_CS_ITU_REC_470M;break; - case TH_CS_ITU_REC_470BG:_ci->colorspace=OC_CS_ITU_REC_470BG;break; - default:_ci->colorspace=OC_CS_UNSPECIFIED;break; - } - switch(_info->pixel_fmt){ - case TH_PF_420:_ci->pixelformat=OC_PF_420;break; - case TH_PF_422:_ci->pixelformat=OC_PF_422;break; - case TH_PF_444:_ci->pixelformat=OC_PF_444;break; - default:_ci->pixelformat=OC_PF_RSVD; - } - _ci->target_bitrate=_info->target_bitrate; - _ci->quality=_info->quality; - _ci->keyframe_frequency_force=1<<_info->keyframe_granule_shift; -} - -int theora_decode_init(theora_state *_td,theora_info *_ci){ - th_api_info *apiinfo; - th_api_wrapper *api; - th_info info; - api=(th_api_wrapper *)_ci->codec_setup; - /*Allocate our own combined API wrapper/theora_info struct. - We put them both in one malloc'd block so that when the API wrapper is - freed, the info struct goes with it. - This avoids having to figure out whether or not we need to free the info - struct in either theora_info_clear() or theora_clear().*/ - apiinfo=(th_api_info *)_ogg_calloc(1,sizeof(*apiinfo)); - if(apiinfo==NULL)return OC_FAULT; - /*Make our own copy of the info struct, since its lifetime should be - independent of the one we were passed in.*/ - *&apiinfo->info=*_ci; - /*Convert the info struct now instead of saving the the one we decoded with - theora_decode_header(), since the user might have modified values (i.e., - color space, aspect ratio, etc. can be specified from a higher level). - The user also might be doing something "clever" with the header packets if - they are not using an Ogg encapsulation.*/ - oc_theora_info2th_info(&info,_ci); - /*Don't bother to copy the setup info; th_decode_alloc() makes its own copy - of the stuff it needs.*/ - apiinfo->api.decode=th_decode_alloc(&info,api->setup); - if(apiinfo->api.decode==NULL){ - _ogg_free(apiinfo); - return OC_EINVAL; - } - apiinfo->api.clear=(oc_setup_clear_func)th_dec_api_clear; - _td->internal_encode=NULL; - /*Provide entry points for ABI compatibility with old decoder shared libs.*/ - _td->internal_decode=(void *)&OC_DEC_DISPATCH_VTBL; - _td->granulepos=0; - _td->i=&apiinfo->info; - _td->i->codec_setup=&apiinfo->api; - return 0; -} - -int theora_decode_header(theora_info *_ci,theora_comment *_cc,ogg_packet *_op){ - th_api_wrapper *api; - th_info info; - int ret; - api=(th_api_wrapper *)_ci->codec_setup; - /*Allocate an API wrapper struct on demand, since it will not also include a - theora_info struct like the ones that are used in a theora_state struct.*/ - if(api==NULL){ - _ci->codec_setup=_ogg_calloc(1,sizeof(*api)); - if(_ci->codec_setup==NULL)return OC_FAULT; - api=(th_api_wrapper *)_ci->codec_setup; - api->clear=(oc_setup_clear_func)th_dec_api_clear; - } - /*Convert from the theora_info struct instead of saving our own th_info - struct between calls. - The user might be doing something "clever" with the header packets if they - are not using an Ogg encapsulation, and we don't want to break this.*/ - oc_theora_info2th_info(&info,_ci); - /*We rely on the fact that theora_comment and th_comment structures are - actually identical. - Take care not to change this fact unless you change the code here as - well!*/ - ret=th_decode_headerin(&info,(th_comment *)_cc,&api->setup,_op); - /*We also rely on the fact that the error return code values are the same, - and that the implementations of these two functions return the same set of - them. - Note that theora_decode_header() really can return OC_NOTFORMAT, even - though it is not currently documented to do so.*/ - if(ret<0)return ret; - th_info2theora_info(_ci,&info); - return 0; -} - -int theora_decode_packetin(theora_state *_td,ogg_packet *_op){ - th_api_wrapper *api; - ogg_int64_t gp; - int ret; - if(!_td||!_td->i||!_td->i->codec_setup)return OC_FAULT; - api=(th_api_wrapper *)_td->i->codec_setup; - ret=th_decode_packetin(api->decode,_op,&gp); - if(ret<0)return OC_BADPACKET; - _td->granulepos=gp; - return 0; -} - -int theora_decode_YUVout(theora_state *_td,yuv_buffer *_yuv){ - th_api_wrapper *api; - th_dec_ctx *decode; - th_ycbcr_buffer buf; - int ret; - if(!_td||!_td->i||!_td->i->codec_setup)return OC_FAULT; - api=(th_api_wrapper *)_td->i->codec_setup; - decode=(th_dec_ctx *)api->decode; - if(!decode)return OC_FAULT; - ret=th_decode_ycbcr_out(decode,buf); - if(ret>=0){ - _yuv->y_width=buf[0].width; - _yuv->y_height=buf[0].height; - _yuv->y_stride=buf[0].stride; - _yuv->uv_width=buf[1].width; - _yuv->uv_height=buf[1].height; - _yuv->uv_stride=buf[1].stride; - _yuv->y=buf[0].data; - _yuv->u=buf[1].data; - _yuv->v=buf[2].data; - } - return ret; -} diff --git a/Engine/lib/libtheora/lib/decinfo.c b/Engine/lib/libtheora/lib/decinfo.c deleted file mode 100644 index 845eb1361..000000000 --- a/Engine/lib/libtheora/lib/decinfo.c +++ /dev/null @@ -1,246 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: decinfo.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include -#include -#include -#include "decint.h" - - - -/*Unpacks a series of octets from a given byte array into the pack buffer. - No checking is done to ensure the buffer contains enough data. - _opb: The pack buffer to read the octets from. - _buf: The byte array to store the unpacked bytes in. - _len: The number of octets to unpack.*/ -static void oc_unpack_octets(oc_pack_buf *_opb,char *_buf,size_t _len){ - while(_len-->0){ - long val; - val=oc_pack_read(_opb,8); - *_buf++=(char)val; - } -} - -/*Unpacks a 32-bit integer encoded by octets in little-endian form.*/ -static long oc_unpack_length(oc_pack_buf *_opb){ - long ret[4]; - int i; - for(i=0;i<4;i++)ret[i]=oc_pack_read(_opb,8); - return ret[0]|ret[1]<<8|ret[2]<<16|ret[3]<<24; -} - -static int oc_info_unpack(oc_pack_buf *_opb,th_info *_info){ - long val; - /*Check the codec bitstream version.*/ - val=oc_pack_read(_opb,8); - _info->version_major=(unsigned char)val; - val=oc_pack_read(_opb,8); - _info->version_minor=(unsigned char)val; - val=oc_pack_read(_opb,8); - _info->version_subminor=(unsigned char)val; - /*verify we can parse this bitstream version. - We accept earlier minors and all subminors, by spec*/ - if(_info->version_major>TH_VERSION_MAJOR|| - _info->version_major==TH_VERSION_MAJOR&& - _info->version_minor>TH_VERSION_MINOR){ - return TH_EVERSION; - } - /*Read the encoded frame description.*/ - val=oc_pack_read(_opb,16); - _info->frame_width=(ogg_uint32_t)val<<4; - val=oc_pack_read(_opb,16); - _info->frame_height=(ogg_uint32_t)val<<4; - val=oc_pack_read(_opb,24); - _info->pic_width=(ogg_uint32_t)val; - val=oc_pack_read(_opb,24); - _info->pic_height=(ogg_uint32_t)val; - val=oc_pack_read(_opb,8); - _info->pic_x=(ogg_uint32_t)val; - val=oc_pack_read(_opb,8); - _info->pic_y=(ogg_uint32_t)val; - val=oc_pack_read(_opb,32); - _info->fps_numerator=(ogg_uint32_t)val; - val=oc_pack_read(_opb,32); - _info->fps_denominator=(ogg_uint32_t)val; - if(_info->frame_width==0||_info->frame_height==0|| - _info->pic_width+_info->pic_x>_info->frame_width|| - _info->pic_height+_info->pic_y>_info->frame_height|| - _info->fps_numerator==0||_info->fps_denominator==0){ - return TH_EBADHEADER; - } - /*Note: The sense of pic_y is inverted in what we pass back to the - application compared to how it is stored in the bitstream. - This is because the bitstream uses a right-handed coordinate system, while - applications expect a left-handed one.*/ - _info->pic_y=_info->frame_height-_info->pic_height-_info->pic_y; - val=oc_pack_read(_opb,24); - _info->aspect_numerator=(ogg_uint32_t)val; - val=oc_pack_read(_opb,24); - _info->aspect_denominator=(ogg_uint32_t)val; - val=oc_pack_read(_opb,8); - _info->colorspace=(th_colorspace)val; - val=oc_pack_read(_opb,24); - _info->target_bitrate=(int)val; - val=oc_pack_read(_opb,6); - _info->quality=(int)val; - val=oc_pack_read(_opb,5); - _info->keyframe_granule_shift=(int)val; - val=oc_pack_read(_opb,2); - _info->pixel_fmt=(th_pixel_fmt)val; - if(_info->pixel_fmt==TH_PF_RSVD)return TH_EBADHEADER; - val=oc_pack_read(_opb,3); - if(val!=0||oc_pack_bytes_left(_opb)<0)return TH_EBADHEADER; - return 0; -} - -static int oc_comment_unpack(oc_pack_buf *_opb,th_comment *_tc){ - long len; - int i; - /*Read the vendor string.*/ - len=oc_unpack_length(_opb); - if(len<0||len>oc_pack_bytes_left(_opb))return TH_EBADHEADER; - _tc->vendor=_ogg_malloc((size_t)len+1); - if(_tc->vendor==NULL)return TH_EFAULT; - oc_unpack_octets(_opb,_tc->vendor,len); - _tc->vendor[len]='\0'; - /*Read the user comments.*/ - _tc->comments=(int)oc_unpack_length(_opb); - len=_tc->comments; - if(len<0||len>(LONG_MAX>>2)||len<<2>oc_pack_bytes_left(_opb)){ - _tc->comments=0; - return TH_EBADHEADER; - } - _tc->comment_lengths=(int *)_ogg_malloc( - _tc->comments*sizeof(_tc->comment_lengths[0])); - _tc->user_comments=(char **)_ogg_malloc( - _tc->comments*sizeof(_tc->user_comments[0])); - for(i=0;i<_tc->comments;i++){ - len=oc_unpack_length(_opb); - if(len<0||len>oc_pack_bytes_left(_opb)){ - _tc->comments=i; - return TH_EBADHEADER; - } - _tc->comment_lengths[i]=len; - _tc->user_comments[i]=_ogg_malloc((size_t)len+1); - if(_tc->user_comments[i]==NULL){ - _tc->comments=i; - return TH_EFAULT; - } - oc_unpack_octets(_opb,_tc->user_comments[i],len); - _tc->user_comments[i][len]='\0'; - } - return oc_pack_bytes_left(_opb)<0?TH_EBADHEADER:0; -} - -static int oc_setup_unpack(oc_pack_buf *_opb,th_setup_info *_setup){ - int ret; - /*Read the quantizer tables.*/ - ret=oc_quant_params_unpack(_opb,&_setup->qinfo); - if(ret<0)return ret; - /*Read the Huffman trees.*/ - return oc_huff_trees_unpack(_opb,_setup->huff_tables); -} - -static void oc_setup_clear(th_setup_info *_setup){ - oc_quant_params_clear(&_setup->qinfo); - oc_huff_trees_clear(_setup->huff_tables); -} - -static int oc_dec_headerin(oc_pack_buf *_opb,th_info *_info, - th_comment *_tc,th_setup_info **_setup,ogg_packet *_op){ - char buffer[6]; - long val; - int packtype; - int ret; - val=oc_pack_read(_opb,8); - packtype=(int)val; - /*If we're at a data packet and we have received all three headers, we're - done.*/ - if(!(packtype&0x80)&&_info->frame_width>0&&_tc->vendor!=NULL&&*_setup!=NULL){ - return 0; - } - /*Check the codec string.*/ - oc_unpack_octets(_opb,buffer,6); - if(memcmp(buffer,"theora",6)!=0)return TH_ENOTFORMAT; - switch(packtype){ - /*Codec info header.*/ - case 0x80:{ - /*This should be the first packet, and we should not already be - initialized.*/ - if(!_op->b_o_s||_info->frame_width>0)return TH_EBADHEADER; - ret=oc_info_unpack(_opb,_info); - if(ret<0)th_info_clear(_info); - else ret=3; - }break; - /*Comment header.*/ - case 0x81:{ - if(_tc==NULL)return TH_EFAULT; - /*We shoud have already decoded the info header, and should not yet have - decoded the comment header.*/ - if(_info->frame_width==0||_tc->vendor!=NULL)return TH_EBADHEADER; - ret=oc_comment_unpack(_opb,_tc); - if(ret<0)th_comment_clear(_tc); - else ret=2; - }break; - /*Codec setup header.*/ - case 0x82:{ - oc_setup_info *setup; - if(_tc==NULL||_setup==NULL)return TH_EFAULT; - /*We should have already decoded the info header and the comment header, - and should not yet have decoded the setup header.*/ - if(_info->frame_width==0||_tc->vendor==NULL||*_setup!=NULL){ - return TH_EBADHEADER; - } - setup=(oc_setup_info *)_ogg_calloc(1,sizeof(*setup)); - if(setup==NULL)return TH_EFAULT; - ret=oc_setup_unpack(_opb,setup); - if(ret<0){ - oc_setup_clear(setup); - _ogg_free(setup); - } - else{ - *_setup=setup; - ret=1; - } - }break; - default:{ - /*We don't know what this header is.*/ - return TH_EBADHEADER; - }break; - } - return ret; -} - - -/*Decodes one header packet. - This should be called repeatedly with the packets at the beginning of the - stream until it returns 0.*/ -int th_decode_headerin(th_info *_info,th_comment *_tc, - th_setup_info **_setup,ogg_packet *_op){ - oc_pack_buf opb; - if(_op==NULL)return TH_EBADHEADER; - if(_info==NULL)return TH_EFAULT; - oc_pack_readinit(&opb,_op->packet,_op->bytes); - return oc_dec_headerin(&opb,_info,_tc,_setup,_op); -} - -void th_setup_free(th_setup_info *_setup){ - if(_setup!=NULL){ - oc_setup_clear(_setup); - _ogg_free(_setup); - } -} diff --git a/Engine/lib/libtheora/lib/decint.h b/Engine/lib/libtheora/lib/decint.h deleted file mode 100644 index 261b67631..000000000 --- a/Engine/lib/libtheora/lib/decint.h +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: decint.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include -#if !defined(_decint_H) -# define _decint_H (1) -# include "theora/theoradec.h" -# include "internal.h" -# include "bitpack.h" - -typedef struct th_setup_info oc_setup_info; -typedef struct th_dec_ctx oc_dec_ctx; - -# include "huffdec.h" -# include "dequant.h" - -/*Constants for the packet-in state machine specific to the decoder.*/ - -/*Next packet to read: Data packet.*/ -#define OC_PACKET_DATA (0) - - - -struct th_setup_info{ - /*The Huffman codes.*/ - oc_huff_node *huff_tables[TH_NHUFFMAN_TABLES]; - /*The quantization parameters.*/ - th_quant_info qinfo; -}; - - - -struct th_dec_ctx{ - /*Shared encoder/decoder state.*/ - oc_theora_state state; - /*Whether or not packets are ready to be emitted. - This takes on negative values while there are remaining header packets to - be emitted, reaches 0 when the codec is ready for input, and goes to 1 - when a frame has been processed and a data packet is ready.*/ - int packet_state; - /*Buffer in which to assemble packets.*/ - oc_pack_buf opb; - /*Huffman decode trees.*/ - oc_huff_node *huff_tables[TH_NHUFFMAN_TABLES]; - /*The index of the first token in each plane for each coefficient.*/ - ptrdiff_t ti0[3][64]; - /*The number of outstanding EOB runs at the start of each coefficient in each - plane.*/ - ptrdiff_t eob_runs[3][64]; - /*The DCT token lists.*/ - unsigned char *dct_tokens; - /*The extra bits associated with DCT tokens.*/ - unsigned char *extra_bits; - /*The number of dct tokens unpacked so far.*/ - int dct_tokens_count; - /*The out-of-loop post-processing level.*/ - int pp_level; - /*The DC scale used for out-of-loop deblocking.*/ - int pp_dc_scale[64]; - /*The sharpen modifier used for out-of-loop deringing.*/ - int pp_sharp_mod[64]; - /*The DC quantization index of each block.*/ - unsigned char *dc_qis; - /*The variance of each block.*/ - int *variances; - /*The storage for the post-processed frame buffer.*/ - unsigned char *pp_frame_data; - /*Whether or not the post-processsed frame buffer has space for chroma.*/ - int pp_frame_state; - /*The buffer used for the post-processed frame. - Note that this is _not_ guaranteed to have the same strides and offsets as - the reference frame buffers.*/ - th_ycbcr_buffer pp_frame_buf; - /*The striped decode callback function.*/ - th_stripe_callback stripe_cb; -# if defined(HAVE_CAIRO) - /*Output metrics for debugging.*/ - int telemetry; - int telemetry_mbmode; - int telemetry_mv; - int telemetry_qi; - int telemetry_bits; - int telemetry_frame_bytes; - int telemetry_coding_bytes; - int telemetry_mode_bytes; - int telemetry_mv_bytes; - int telemetry_qi_bytes; - int telemetry_dc_bytes; - unsigned char *telemetry_frame_data; -# endif -}; - -#endif diff --git a/Engine/lib/libtheora/lib/decode.c b/Engine/lib/libtheora/lib/decode.c deleted file mode 100644 index 7be66463d..000000000 --- a/Engine/lib/libtheora/lib/decode.c +++ /dev/null @@ -1,2943 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: decode.c 16581 2009-09-25 22:56:16Z gmaxwell $ - - ********************************************************************/ - -#include -#include -#include -#include "decint.h" -#if defined(OC_DUMP_IMAGES) -# include -# include "png.h" -#endif -#if defined(HAVE_CAIRO) -# include -#endif - - -/*No post-processing.*/ -#define OC_PP_LEVEL_DISABLED (0) -/*Keep track of DC qi for each block only.*/ -#define OC_PP_LEVEL_TRACKDCQI (1) -/*Deblock the luma plane.*/ -#define OC_PP_LEVEL_DEBLOCKY (2) -/*Dering the luma plane.*/ -#define OC_PP_LEVEL_DERINGY (3) -/*Stronger luma plane deringing.*/ -#define OC_PP_LEVEL_SDERINGY (4) -/*Deblock the chroma planes.*/ -#define OC_PP_LEVEL_DEBLOCKC (5) -/*Dering the chroma planes.*/ -#define OC_PP_LEVEL_DERINGC (6) -/*Stronger chroma plane deringing.*/ -#define OC_PP_LEVEL_SDERINGC (7) -/*Maximum valid post-processing level.*/ -#define OC_PP_LEVEL_MAX (7) - - - -/*The mode alphabets for the various mode coding schemes. - Scheme 0 uses a custom alphabet, which is not stored in this table.*/ -static const unsigned char OC_MODE_ALPHABETS[7][OC_NMODES]={ - /*Last MV dominates */ - { - OC_MODE_INTER_MV_LAST,OC_MODE_INTER_MV_LAST2,OC_MODE_INTER_MV, - OC_MODE_INTER_NOMV,OC_MODE_INTRA,OC_MODE_GOLDEN_NOMV,OC_MODE_GOLDEN_MV, - OC_MODE_INTER_MV_FOUR - }, - { - OC_MODE_INTER_MV_LAST,OC_MODE_INTER_MV_LAST2,OC_MODE_INTER_NOMV, - OC_MODE_INTER_MV,OC_MODE_INTRA,OC_MODE_GOLDEN_NOMV,OC_MODE_GOLDEN_MV, - OC_MODE_INTER_MV_FOUR - }, - { - OC_MODE_INTER_MV_LAST,OC_MODE_INTER_MV,OC_MODE_INTER_MV_LAST2, - OC_MODE_INTER_NOMV,OC_MODE_INTRA,OC_MODE_GOLDEN_NOMV,OC_MODE_GOLDEN_MV, - OC_MODE_INTER_MV_FOUR - }, - { - OC_MODE_INTER_MV_LAST,OC_MODE_INTER_MV,OC_MODE_INTER_NOMV, - OC_MODE_INTER_MV_LAST2,OC_MODE_INTRA,OC_MODE_GOLDEN_NOMV, - OC_MODE_GOLDEN_MV,OC_MODE_INTER_MV_FOUR - }, - /*No MV dominates.*/ - { - OC_MODE_INTER_NOMV,OC_MODE_INTER_MV_LAST,OC_MODE_INTER_MV_LAST2, - OC_MODE_INTER_MV,OC_MODE_INTRA,OC_MODE_GOLDEN_NOMV,OC_MODE_GOLDEN_MV, - OC_MODE_INTER_MV_FOUR - }, - { - OC_MODE_INTER_NOMV,OC_MODE_GOLDEN_NOMV,OC_MODE_INTER_MV_LAST, - OC_MODE_INTER_MV_LAST2,OC_MODE_INTER_MV,OC_MODE_INTRA,OC_MODE_GOLDEN_MV, - OC_MODE_INTER_MV_FOUR - }, - /*Default ordering.*/ - { - OC_MODE_INTER_NOMV,OC_MODE_INTRA,OC_MODE_INTER_MV,OC_MODE_INTER_MV_LAST, - OC_MODE_INTER_MV_LAST2,OC_MODE_GOLDEN_NOMV,OC_MODE_GOLDEN_MV, - OC_MODE_INTER_MV_FOUR - } -}; - - -/*The original DCT tokens are extended and reordered during the construction of - the Huffman tables. - The extension means more bits can be read with fewer calls to the bitpacker - during the Huffman decoding process (at the cost of larger Huffman tables), - and fewer tokens require additional extra bits (reducing the average storage - per decoded token). - The revised ordering reveals essential information in the token value - itself; specifically, whether or not there are additional extra bits to read - and the parameter to which those extra bits are applied. - The token is used to fetch a code word from the OC_DCT_CODE_WORD table below. - The extra bits are added into code word at the bit position inferred from the - token value, giving the final code word from which all required parameters - are derived. - The number of EOBs and the leading zero run length can be extracted directly. - The coefficient magnitude is optionally negated before extraction, according - to a 'flip' bit.*/ - -/*The number of additional extra bits that are decoded with each of the - internal DCT tokens.*/ -static const unsigned char OC_INTERNAL_DCT_TOKEN_EXTRA_BITS[15]={ - 12,4,3,3,4,4,5,5,8,8,8,8,3,3,6 -}; - -/*Whether or not an internal token needs any additional extra bits.*/ -#define OC_DCT_TOKEN_NEEDS_MORE(token) \ - (token<(sizeof(OC_INTERNAL_DCT_TOKEN_EXTRA_BITS)/ \ - sizeof(*OC_INTERNAL_DCT_TOKEN_EXTRA_BITS))) - -/*This token (OC_DCT_REPEAT_RUN3_TOKEN) requires more than 8 extra bits.*/ -#define OC_DCT_TOKEN_FAT_EOB (0) - -/*The number of EOBs to use for an end-of-frame token. - Note: We want to set eobs to PTRDIFF_MAX here, but that requires C99, which - is not yet available everywhere; this should be equivalent.*/ -#define OC_DCT_EOB_FINISH (~(size_t)0>>1) - -/*The location of the (6) run legth bits in the code word. - These are placed at index 0 and given 8 bits (even though 6 would suffice) - because it may be faster to extract the lower byte on some platforms.*/ -#define OC_DCT_CW_RLEN_SHIFT (0) -/*The location of the (12) EOB bits in the code word.*/ -#define OC_DCT_CW_EOB_SHIFT (8) -/*The location of the (1) flip bit in the code word. - This must be right under the magnitude bits.*/ -#define OC_DCT_CW_FLIP_BIT (20) -/*The location of the (11) token magnitude bits in the code word. - These must be last, and rely on a sign-extending right shift.*/ -#define OC_DCT_CW_MAG_SHIFT (21) - -/*Pack the given fields into a code word.*/ -#define OC_DCT_CW_PACK(_eobs,_rlen,_mag,_flip) \ - ((_eobs)<state,_info,3); - if(ret<0)return ret; - ret=oc_huff_trees_copy(_dec->huff_tables, - (const oc_huff_node *const *)_setup->huff_tables); - if(ret<0){ - oc_state_clear(&_dec->state); - return ret; - } - /*For each fragment, allocate one byte for every DCT coefficient token, plus - one byte for extra-bits for each token, plus one more byte for the long - EOB run, just in case it's the very last token and has a run length of - one.*/ - _dec->dct_tokens=(unsigned char *)_ogg_malloc((64+64+1)* - _dec->state.nfrags*sizeof(_dec->dct_tokens[0])); - if(_dec->dct_tokens==NULL){ - oc_huff_trees_clear(_dec->huff_tables); - oc_state_clear(&_dec->state); - return TH_EFAULT; - } - for(qi=0;qi<64;qi++)for(pli=0;pli<3;pli++)for(qti=0;qti<2;qti++){ - _dec->state.dequant_tables[qi][pli][qti]= - _dec->state.dequant_table_data[qi][pli][qti]; - } - oc_dequant_tables_init(_dec->state.dequant_tables,_dec->pp_dc_scale, - &_setup->qinfo); - for(qi=0;qi<64;qi++){ - int qsum; - qsum=0; - for(qti=0;qti<2;qti++)for(pli=0;pli<3;pli++){ - qsum+=_dec->state.dequant_tables[qti][pli][qi][12]+ - _dec->state.dequant_tables[qti][pli][qi][17]+ - _dec->state.dequant_tables[qti][pli][qi][18]+ - _dec->state.dequant_tables[qti][pli][qi][24]<<(pli==0); - } - _dec->pp_sharp_mod[qi]=-(qsum>>11); - } - memcpy(_dec->state.loop_filter_limits,_setup->qinfo.loop_filter_limits, - sizeof(_dec->state.loop_filter_limits)); - _dec->pp_level=OC_PP_LEVEL_DISABLED; - _dec->dc_qis=NULL; - _dec->variances=NULL; - _dec->pp_frame_data=NULL; - _dec->stripe_cb.ctx=NULL; - _dec->stripe_cb.stripe_decoded=NULL; -#if defined(HAVE_CAIRO) - _dec->telemetry=0; - _dec->telemetry_bits=0; - _dec->telemetry_qi=0; - _dec->telemetry_mbmode=0; - _dec->telemetry_mv=0; - _dec->telemetry_frame_data=NULL; -#endif - return 0; -} - -static void oc_dec_clear(oc_dec_ctx *_dec){ -#if defined(HAVE_CAIRO) - _ogg_free(_dec->telemetry_frame_data); -#endif - _ogg_free(_dec->pp_frame_data); - _ogg_free(_dec->variances); - _ogg_free(_dec->dc_qis); - _ogg_free(_dec->dct_tokens); - oc_huff_trees_clear(_dec->huff_tables); - oc_state_clear(&_dec->state); -} - - -static int oc_dec_frame_header_unpack(oc_dec_ctx *_dec){ - long val; - /*Check to make sure this is a data packet.*/ - val=oc_pack_read1(&_dec->opb); - if(val!=0)return TH_EBADPACKET; - /*Read in the frame type (I or P).*/ - val=oc_pack_read1(&_dec->opb); - _dec->state.frame_type=(int)val; - /*Read in the qi list.*/ - val=oc_pack_read(&_dec->opb,6); - _dec->state.qis[0]=(unsigned char)val; - val=oc_pack_read1(&_dec->opb); - if(!val)_dec->state.nqis=1; - else{ - val=oc_pack_read(&_dec->opb,6); - _dec->state.qis[1]=(unsigned char)val; - val=oc_pack_read1(&_dec->opb); - if(!val)_dec->state.nqis=2; - else{ - val=oc_pack_read(&_dec->opb,6); - _dec->state.qis[2]=(unsigned char)val; - _dec->state.nqis=3; - } - } - if(_dec->state.frame_type==OC_INTRA_FRAME){ - /*Keyframes have 3 unused configuration bits, holdovers from VP3 days. - Most of the other unused bits in the VP3 headers were eliminated. - I don't know why these remain.*/ - /*I wanted to eliminate wasted bits, but not all config wiggle room - --Monty.*/ - val=oc_pack_read(&_dec->opb,3); - if(val!=0)return TH_EIMPL; - } - return 0; -} - -/*Mark all fragments as coded and in OC_MODE_INTRA. - This also builds up the coded fragment list (in coded order), and clears the - uncoded fragment list. - It does not update the coded macro block list nor the super block flags, as - those are not used when decoding INTRA frames.*/ -static void oc_dec_mark_all_intra(oc_dec_ctx *_dec){ - const oc_sb_map *sb_maps; - const oc_sb_flags *sb_flags; - oc_fragment *frags; - ptrdiff_t *coded_fragis; - ptrdiff_t ncoded_fragis; - ptrdiff_t prev_ncoded_fragis; - unsigned nsbs; - unsigned sbi; - int pli; - coded_fragis=_dec->state.coded_fragis; - prev_ncoded_fragis=ncoded_fragis=0; - sb_maps=(const oc_sb_map *)_dec->state.sb_maps; - sb_flags=_dec->state.sb_flags; - frags=_dec->state.frags; - sbi=nsbs=0; - for(pli=0;pli<3;pli++){ - nsbs+=_dec->state.fplanes[pli].nsbs; - for(;sbi=0){ - frags[fragi].coded=1; - frags[fragi].mb_mode=OC_MODE_INTRA; - coded_fragis[ncoded_fragis++]=fragi; - } - } - } - } - _dec->state.ncoded_fragis[pli]=ncoded_fragis-prev_ncoded_fragis; - prev_ncoded_fragis=ncoded_fragis; - } - _dec->state.ntotal_coded_fragis=ncoded_fragis; -} - -/*Decodes the bit flags indicating whether each super block is partially coded - or not. - Return: The number of partially coded super blocks.*/ -static unsigned oc_dec_partial_sb_flags_unpack(oc_dec_ctx *_dec){ - oc_sb_flags *sb_flags; - unsigned nsbs; - unsigned sbi; - unsigned npartial; - unsigned run_count; - long val; - int flag; - val=oc_pack_read1(&_dec->opb); - flag=(int)val; - sb_flags=_dec->state.sb_flags; - nsbs=_dec->state.nsbs; - sbi=npartial=0; - while(sbiopb); - full_run=run_count>=4129; - do{ - sb_flags[sbi].coded_partially=flag; - sb_flags[sbi].coded_fully=0; - npartial+=flag; - sbi++; - } - while(--run_count>0&&sbiopb); - flag=(int)val; - } - else flag=!flag; - } - /*TODO: run_count should be 0 here. - If it's not, we should issue a warning of some kind.*/ - return npartial; -} - -/*Decodes the bit flags for whether or not each non-partially-coded super - block is fully coded or not. - This function should only be called if there is at least one - non-partially-coded super block. - Return: The number of partially coded super blocks.*/ -static void oc_dec_coded_sb_flags_unpack(oc_dec_ctx *_dec){ - oc_sb_flags *sb_flags; - unsigned nsbs; - unsigned sbi; - unsigned run_count; - long val; - int flag; - sb_flags=_dec->state.sb_flags; - nsbs=_dec->state.nsbs; - /*Skip partially coded super blocks.*/ - for(sbi=0;sb_flags[sbi].coded_partially;sbi++); - val=oc_pack_read1(&_dec->opb); - flag=(int)val; - do{ - int full_run; - run_count=oc_sb_run_unpack(&_dec->opb); - full_run=run_count>=4129; - for(;sbiopb); - flag=(int)val; - } - else flag=!flag; - } - while(sbistate.nsbs)oc_dec_coded_sb_flags_unpack(_dec); - if(npartial>0){ - val=oc_pack_read1(&_dec->opb); - flag=!(int)val; - } - else flag=0; - sb_maps=(const oc_sb_map *)_dec->state.sb_maps; - sb_flags=_dec->state.sb_flags; - frags=_dec->state.frags; - sbi=nsbs=run_count=0; - coded_fragis=_dec->state.coded_fragis; - uncoded_fragis=coded_fragis+_dec->state.nfrags; - prev_ncoded_fragis=ncoded_fragis=nuncoded_fragis=0; - for(pli=0;pli<3;pli++){ - nsbs+=_dec->state.fplanes[pli].nsbs; - for(;sbi=0){ - int coded; - if(sb_flags[sbi].coded_fully)coded=1; - else if(!sb_flags[sbi].coded_partially)coded=0; - else{ - if(run_count<=0){ - run_count=oc_block_run_unpack(&_dec->opb); - flag=!flag; - } - run_count--; - coded=flag; - } - if(coded)coded_fragis[ncoded_fragis++]=fragi; - else *(uncoded_fragis-++nuncoded_fragis)=fragi; - frags[fragi].coded=coded; - } - } - } - } - _dec->state.ncoded_fragis[pli]=ncoded_fragis-prev_ncoded_fragis; - prev_ncoded_fragis=ncoded_fragis; - } - _dec->state.ntotal_coded_fragis=ncoded_fragis; - /*TODO: run_count should be 0 here. - If it's not, we should issue a warning of some kind.*/ -} - - - -typedef int (*oc_mode_unpack_func)(oc_pack_buf *_opb); - -static int oc_vlc_mode_unpack(oc_pack_buf *_opb){ - long val; - int i; - for(i=0;i<7;i++){ - val=oc_pack_read1(_opb); - if(!val)break; - } - return i; -} - -static int oc_clc_mode_unpack(oc_pack_buf *_opb){ - long val; - val=oc_pack_read(_opb,3); - return (int)val; -} - -/*Unpacks the list of macro block modes for INTER frames.*/ -static void oc_dec_mb_modes_unpack(oc_dec_ctx *_dec){ - const oc_mb_map *mb_maps; - signed char *mb_modes; - const oc_fragment *frags; - const unsigned char *alphabet; - unsigned char scheme0_alphabet[8]; - oc_mode_unpack_func mode_unpack; - size_t nmbs; - size_t mbi; - long val; - int mode_scheme; - val=oc_pack_read(&_dec->opb,3); - mode_scheme=(int)val; - if(mode_scheme==0){ - int mi; - /*Just in case, initialize the modes to something. - If the bitstream doesn't contain each index exactly once, it's likely - corrupt and the rest of the packet is garbage anyway, but this way we - won't crash, and we'll decode SOMETHING.*/ - /*LOOP VECTORIZES*/ - for(mi=0;miopb,3); - scheme0_alphabet[val]=OC_MODE_ALPHABETS[6][mi]; - } - alphabet=scheme0_alphabet; - } - else alphabet=OC_MODE_ALPHABETS[mode_scheme-1]; - if(mode_scheme==7)mode_unpack=oc_clc_mode_unpack; - else mode_unpack=oc_vlc_mode_unpack; - mb_modes=_dec->state.mb_modes; - mb_maps=(const oc_mb_map *)_dec->state.mb_maps; - nmbs=_dec->state.nmbs; - frags=_dec->state.frags; - for(mbi=0;mbiopb)]; - /*There were none: INTER_NOMV is forced.*/ - else mb_modes[mbi]=OC_MODE_INTER_NOMV; - } - } -} - - - -typedef int (*oc_mv_comp_unpack_func)(oc_pack_buf *_opb); - -static int oc_vlc_mv_comp_unpack(oc_pack_buf *_opb){ - long bits; - int mask; - int mv; - bits=oc_pack_read(_opb,3); - switch(bits){ - case 0:return 0; - case 1:return 1; - case 2:return -1; - case 3: - case 4:{ - mv=(int)(bits-1); - bits=oc_pack_read1(_opb); - }break; - /*case 5: - case 6: - case 7:*/ - default:{ - mv=1<>1); - bits&=1; - }break; - } - mask=-(int)bits; - return mv+mask^mask; -} - -static int oc_clc_mv_comp_unpack(oc_pack_buf *_opb){ - long bits; - int mask; - int mv; - bits=oc_pack_read(_opb,6); - mv=(int)bits>>1; - mask=-((int)bits&1); - return mv+mask^mask; -} - -/*Unpacks the list of motion vectors for INTER frames, and propagtes the macro - block modes and motion vectors to the individual fragments.*/ -static void oc_dec_mv_unpack_and_frag_modes_fill(oc_dec_ctx *_dec){ - const oc_mb_map *mb_maps; - const signed char *mb_modes; - oc_set_chroma_mvs_func set_chroma_mvs; - oc_mv_comp_unpack_func mv_comp_unpack; - oc_fragment *frags; - oc_mv *frag_mvs; - const unsigned char *map_idxs; - int map_nidxs; - oc_mv last_mv[2]; - oc_mv cbmvs[4]; - size_t nmbs; - size_t mbi; - long val; - set_chroma_mvs=OC_SET_CHROMA_MVS_TABLE[_dec->state.info.pixel_fmt]; - val=oc_pack_read1(&_dec->opb); - mv_comp_unpack=val?oc_clc_mv_comp_unpack:oc_vlc_mv_comp_unpack; - map_idxs=OC_MB_MAP_IDXS[_dec->state.info.pixel_fmt]; - map_nidxs=OC_MB_MAP_NIDXS[_dec->state.info.pixel_fmt]; - memset(last_mv,0,sizeof(last_mv)); - frags=_dec->state.frags; - frag_mvs=_dec->state.frag_mvs; - mb_maps=(const oc_mb_map *)_dec->state.mb_maps; - mb_modes=_dec->state.mb_modes; - nmbs=_dec->state.nmbs; - for(mbi=0;mbi>2][mapi&3]; - if(frags[fragi].coded)coded[ncoded++]=mapi; - } - while(++mapiiopb); - lbmvs[bi][1]=(signed char)(*mv_comp_unpack)(&_dec->opb); - memcpy(frag_mvs[fragi],lbmvs[bi],sizeof(lbmvs[bi])); - } - else lbmvs[bi][0]=lbmvs[bi][1]=0; - } - if(codedi>0){ - memcpy(last_mv[1],last_mv[0],sizeof(last_mv[1])); - memcpy(last_mv[0],lbmvs[coded[codedi-1]],sizeof(last_mv[0])); - } - if(codedi>2][bi]; - frags[fragi].mb_mode=mb_mode; - memcpy(frag_mvs[fragi],cbmvs[bi],sizeof(cbmvs[bi])); - } - } - }break; - case OC_MODE_INTER_MV:{ - memcpy(last_mv[1],last_mv[0],sizeof(last_mv[1])); - mbmv[0]=last_mv[0][0]=(signed char)(*mv_comp_unpack)(&_dec->opb); - mbmv[1]=last_mv[0][1]=(signed char)(*mv_comp_unpack)(&_dec->opb); - }break; - case OC_MODE_INTER_MV_LAST:memcpy(mbmv,last_mv[0],sizeof(mbmv));break; - case OC_MODE_INTER_MV_LAST2:{ - memcpy(mbmv,last_mv[1],sizeof(mbmv)); - memcpy(last_mv[1],last_mv[0],sizeof(last_mv[1])); - memcpy(last_mv[0],mbmv,sizeof(last_mv[0])); - }break; - case OC_MODE_GOLDEN_MV:{ - mbmv[0]=(signed char)(*mv_comp_unpack)(&_dec->opb); - mbmv[1]=(signed char)(*mv_comp_unpack)(&_dec->opb); - }break; - default:memset(mbmv,0,sizeof(mbmv));break; - } - /*4MV mode fills in the fragments itself. - For all other modes we can use this common code.*/ - if(mb_mode!=OC_MODE_INTER_MV_FOUR){ - for(codedi=0;codedi>2][mapi&3]; - frags[fragi].mb_mode=mb_mode; - memcpy(frag_mvs[fragi],mbmv,sizeof(mbmv)); - } - } - } - } -} - -static void oc_dec_block_qis_unpack(oc_dec_ctx *_dec){ - oc_fragment *frags; - const ptrdiff_t *coded_fragis; - ptrdiff_t ncoded_fragis; - ptrdiff_t fragii; - ptrdiff_t fragi; - ncoded_fragis=_dec->state.ntotal_coded_fragis; - if(ncoded_fragis<=0)return; - frags=_dec->state.frags; - coded_fragis=_dec->state.coded_fragis; - if(_dec->state.nqis==1){ - /*If this frame has only a single qi value, then just use it for all coded - fragments.*/ - for(fragii=0;fragiiopb); - flag=(int)val; - nqi1=0; - fragii=0; - while(fragiiopb); - full_run=run_count>=4129; - do{ - frags[coded_fragis[fragii++]].qii=flag; - nqi1+=flag; - } - while(--run_count>0&&fragiiopb); - flag=(int)val; - } - else flag=!flag; - } - /*TODO: run_count should be 0 here. - If it's not, we should issue a warning of some kind.*/ - /*If we have 3 different qi's for this frame, and there was at least one - fragment with a non-zero qi, make the second pass.*/ - if(_dec->state.nqis==3&&nqi1>0){ - /*Skip qii==0 fragments.*/ - for(fragii=0;frags[coded_fragis[fragii]].qii==0;fragii++); - val=oc_pack_read1(&_dec->opb); - flag=(int)val; - do{ - int full_run; - run_count=oc_sb_run_unpack(&_dec->opb); - full_run=run_count>=4129; - for(;fragiiopb); - flag=(int)val; - } - else flag=!flag; - } - while(fragiidct_tokens; - frags=_dec->state.frags; - coded_fragis=_dec->state.coded_fragis; - ncoded_fragis=fragii=eobs=ti=0; - for(pli=0;pli<3;pli++){ - ptrdiff_t run_counts[64]; - ptrdiff_t eob_count; - ptrdiff_t eobi; - int rli; - ncoded_fragis+=_dec->state.ncoded_fragis[pli]; - memset(run_counts,0,sizeof(run_counts)); - _dec->eob_runs[pli][0]=eobs; - _dec->ti0[pli][0]=ti; - /*Continue any previous EOB run, if there was one.*/ - eobi=eobs; - if(ncoded_fragis-fragii0)frags[coded_fragis[fragii++]].dc=0; - while(fragiiopb, - _dec->huff_tables[_huff_idxs[pli+1>>1]]); - dct_tokens[ti++]=(unsigned char)token; - if(OC_DCT_TOKEN_NEEDS_MORE(token)){ - eb=(int)oc_pack_read(&_dec->opb, - OC_INTERNAL_DCT_TOKEN_EXTRA_BITS[token]); - dct_tokens[ti++]=(unsigned char)eb; - if(token==OC_DCT_TOKEN_FAT_EOB)dct_tokens[ti++]=(unsigned char)(eb>>8); - eb<<=OC_DCT_TOKEN_EB_POS(token); - } - else eb=0; - cw=OC_DCT_CODE_WORD[token]+eb; - eobs=cw>>OC_DCT_CW_EOB_SHIFT&0xFFF; - if(cw==OC_DCT_CW_FINISH)eobs=OC_DCT_EOB_FINISH; - if(eobs){ - eobi=OC_MINI(eobs,ncoded_fragis-fragii); - eob_count+=eobi; - eobs-=eobi; - while(eobi-->0)frags[coded_fragis[fragii++]].dc=0; - } - else{ - int coeff; - skip=(unsigned char)(cw>>OC_DCT_CW_RLEN_SHIFT); - cw^=-(cw&1<>OC_DCT_CW_MAG_SHIFT; - if(skip)coeff=0; - run_counts[skip]++; - frags[coded_fragis[fragii++]].dc=coeff; - } - } - /*Add the total EOB count to the longest run length.*/ - run_counts[63]+=eob_count; - /*And convert the run_counts array to a moment table.*/ - for(rli=63;rli-->0;)run_counts[rli]+=run_counts[rli+1]; - /*Finally, subtract off the number of coefficients that have been - accounted for by runs started in this coefficient.*/ - for(rli=64;rli-->0;)_ntoks_left[pli][rli]-=run_counts[rli]; - } - _dec->dct_tokens_count=ti; - return eobs; -} - -/*Unpacks the AC coefficient tokens. - This can completely discard coefficient values while unpacking, and so is - somewhat simpler than unpacking the DC coefficient tokens. - _huff_idx: The index of the Huffman table to use for each color plane. - _ntoks_left: The number of tokens left to be decoded in each color plane for - each coefficient. - This is updated as EOB tokens and zero run tokens are decoded. - _eobs: The length of any outstanding EOB run from previous - coefficients. - Return: The length of any outstanding EOB run.*/ -static int oc_dec_ac_coeff_unpack(oc_dec_ctx *_dec,int _zzi,int _huff_idxs[2], - ptrdiff_t _ntoks_left[3][64],ptrdiff_t _eobs){ - unsigned char *dct_tokens; - ptrdiff_t ti; - int pli; - dct_tokens=_dec->dct_tokens; - ti=_dec->dct_tokens_count; - for(pli=0;pli<3;pli++){ - ptrdiff_t run_counts[64]; - ptrdiff_t eob_count; - size_t ntoks_left; - size_t ntoks; - int rli; - _dec->eob_runs[pli][_zzi]=_eobs; - _dec->ti0[pli][_zzi]=ti; - ntoks_left=_ntoks_left[pli][_zzi]; - memset(run_counts,0,sizeof(run_counts)); - eob_count=0; - ntoks=0; - while(ntoks+_eobsopb, - _dec->huff_tables[_huff_idxs[pli+1>>1]]); - dct_tokens[ti++]=(unsigned char)token; - if(OC_DCT_TOKEN_NEEDS_MORE(token)){ - eb=(int)oc_pack_read(&_dec->opb, - OC_INTERNAL_DCT_TOKEN_EXTRA_BITS[token]); - dct_tokens[ti++]=(unsigned char)eb; - if(token==OC_DCT_TOKEN_FAT_EOB)dct_tokens[ti++]=(unsigned char)(eb>>8); - eb<<=OC_DCT_TOKEN_EB_POS(token); - } - else eb=0; - cw=OC_DCT_CODE_WORD[token]+eb; - skip=(unsigned char)(cw>>OC_DCT_CW_RLEN_SHIFT); - _eobs=cw>>OC_DCT_CW_EOB_SHIFT&0xFFF; - if(cw==OC_DCT_CW_FINISH)_eobs=OC_DCT_EOB_FINISH; - if(_eobs==0){ - run_counts[skip]++; - ntoks++; - } - } - /*Add the portion of the last EOB run actually used by this coefficient.*/ - eob_count+=ntoks_left-ntoks; - /*And remove it from the remaining EOB count.*/ - _eobs-=ntoks_left-ntoks; - /*Add the total EOB count to the longest run length.*/ - run_counts[63]+=eob_count; - /*And convert the run_counts array to a moment table.*/ - for(rli=63;rli-->0;)run_counts[rli]+=run_counts[rli+1]; - /*Finally, subtract off the number of coefficients that have been - accounted for by runs started in this coefficient.*/ - for(rli=64-_zzi;rli-->0;)_ntoks_left[pli][_zzi+rli]-=run_counts[rli]; - } - _dec->dct_tokens_count=ti; - return _eobs; -} - -/*Tokens describing the DCT coefficients that belong to each fragment are - stored in the bitstream grouped by coefficient, not by fragment. - - This means that we either decode all the tokens in order, building up a - separate coefficient list for each fragment as we go, and then go back and - do the iDCT on each fragment, or we have to create separate lists of tokens - for each coefficient, so that we can pull the next token required off the - head of the appropriate list when decoding a specific fragment. - - The former was VP3's choice, and it meant 2*w*h extra storage for all the - decoded coefficient values. - - We take the second option, which lets us store just one to three bytes per - token (generally far fewer than the number of coefficients, due to EOB - tokens and zero runs), and which requires us to only maintain a counter for - each of the 64 coefficients, instead of a counter for every fragment to - determine where the next token goes. - - We actually use 3 counters per coefficient, one for each color plane, so we - can decode all color planes simultaneously. - This lets color conversion, etc., be done as soon as a full MCU (one or - two super block rows) is decoded, while the image data is still in cache.*/ - -static void oc_dec_residual_tokens_unpack(oc_dec_ctx *_dec){ - static const unsigned char OC_HUFF_LIST_MAX[5]={1,6,15,28,64}; - ptrdiff_t ntoks_left[3][64]; - int huff_idxs[2]; - ptrdiff_t eobs; - long val; - int pli; - int zzi; - int hgi; - for(pli=0;pli<3;pli++)for(zzi=0;zzi<64;zzi++){ - ntoks_left[pli][zzi]=_dec->state.ncoded_fragis[pli]; - } - val=oc_pack_read(&_dec->opb,4); - huff_idxs[0]=(int)val; - val=oc_pack_read(&_dec->opb,4); - huff_idxs[1]=(int)val; - _dec->eob_runs[0][0]=0; - eobs=oc_dec_dc_coeff_unpack(_dec,huff_idxs,ntoks_left); -#if defined(HAVE_CAIRO) - _dec->telemetry_dc_bytes=oc_pack_bytes_left(&_dec->opb); -#endif - val=oc_pack_read(&_dec->opb,4); - huff_idxs[0]=(int)val; - val=oc_pack_read(&_dec->opb,4); - huff_idxs[1]=(int)val; - zzi=1; - for(hgi=1;hgi<5;hgi++){ - huff_idxs[0]+=16; - huff_idxs[1]+=16; - for(;zzipp_level<=OC_PP_LEVEL_DISABLED){ - if(_dec->dc_qis!=NULL){ - _ogg_free(_dec->dc_qis); - _dec->dc_qis=NULL; - _ogg_free(_dec->variances); - _dec->variances=NULL; - _ogg_free(_dec->pp_frame_data); - _dec->pp_frame_data=NULL; - } - return 1; - } - if(_dec->dc_qis==NULL){ - /*If we haven't been tracking DC quantization indices, there's no point in - starting now.*/ - if(_dec->state.frame_type!=OC_INTRA_FRAME)return 1; - _dec->dc_qis=(unsigned char *)_ogg_malloc( - _dec->state.nfrags*sizeof(_dec->dc_qis[0])); - if(_dec->dc_qis==NULL)return 1; - memset(_dec->dc_qis,_dec->state.qis[0],_dec->state.nfrags); - } - else{ - unsigned char *dc_qis; - const ptrdiff_t *coded_fragis; - ptrdiff_t ncoded_fragis; - ptrdiff_t fragii; - unsigned char qi0; - /*Update the DC quantization index of each coded block.*/ - dc_qis=_dec->dc_qis; - coded_fragis=_dec->state.coded_fragis; - ncoded_fragis=_dec->state.ncoded_fragis[0]+ - _dec->state.ncoded_fragis[1]+_dec->state.ncoded_fragis[2]; - qi0=(unsigned char)_dec->state.qis[0]; - for(fragii=0;fragiipp_level<=OC_PP_LEVEL_TRACKDCQI){ - if(_dec->variances!=NULL){ - _ogg_free(_dec->variances); - _dec->variances=NULL; - _ogg_free(_dec->pp_frame_data); - _dec->pp_frame_data=NULL; - } - return 1; - } - if(_dec->variances==NULL){ - size_t frame_sz; - size_t c_sz; - int c_w; - int c_h; - frame_sz=_dec->state.info.frame_width*(size_t)_dec->state.info.frame_height; - c_w=_dec->state.info.frame_width>>!(_dec->state.info.pixel_fmt&1); - c_h=_dec->state.info.frame_height>>!(_dec->state.info.pixel_fmt&2); - c_sz=c_w*(size_t)c_h; - /*Allocate space for the chroma planes, even if we're not going to use - them; this simplifies allocation state management, though it may waste - memory on the few systems that don't overcommit pages.*/ - frame_sz+=c_sz<<1; - _dec->pp_frame_data=(unsigned char *)_ogg_malloc( - frame_sz*sizeof(_dec->pp_frame_data[0])); - _dec->variances=(int *)_ogg_malloc( - _dec->state.nfrags*sizeof(_dec->variances[0])); - if(_dec->variances==NULL||_dec->pp_frame_data==NULL){ - _ogg_free(_dec->pp_frame_data); - _dec->pp_frame_data=NULL; - _ogg_free(_dec->variances); - _dec->variances=NULL; - return 1; - } - /*Force an update of the PP buffer pointers.*/ - _dec->pp_frame_state=0; - } - /*Update the PP buffer pointers if necessary.*/ - if(_dec->pp_frame_state!=1+(_dec->pp_level>=OC_PP_LEVEL_DEBLOCKC)){ - if(_dec->pp_levelpp_frame_buf[0].width=_dec->state.info.frame_width; - _dec->pp_frame_buf[0].height=_dec->state.info.frame_height; - _dec->pp_frame_buf[0].stride=-_dec->pp_frame_buf[0].width; - _dec->pp_frame_buf[0].data=_dec->pp_frame_data+ - (1-_dec->pp_frame_buf[0].height)*(ptrdiff_t)_dec->pp_frame_buf[0].stride; - } - else{ - size_t y_sz; - size_t c_sz; - int c_w; - int c_h; - /*Otherwise, set up pointers to all three PP planes.*/ - y_sz=_dec->state.info.frame_width*(size_t)_dec->state.info.frame_height; - c_w=_dec->state.info.frame_width>>!(_dec->state.info.pixel_fmt&1); - c_h=_dec->state.info.frame_height>>!(_dec->state.info.pixel_fmt&2); - c_sz=c_w*(size_t)c_h; - _dec->pp_frame_buf[0].width=_dec->state.info.frame_width; - _dec->pp_frame_buf[0].height=_dec->state.info.frame_height; - _dec->pp_frame_buf[0].stride=_dec->pp_frame_buf[0].width; - _dec->pp_frame_buf[0].data=_dec->pp_frame_data; - _dec->pp_frame_buf[1].width=c_w; - _dec->pp_frame_buf[1].height=c_h; - _dec->pp_frame_buf[1].stride=_dec->pp_frame_buf[1].width; - _dec->pp_frame_buf[1].data=_dec->pp_frame_buf[0].data+y_sz; - _dec->pp_frame_buf[2].width=c_w; - _dec->pp_frame_buf[2].height=c_h; - _dec->pp_frame_buf[2].stride=_dec->pp_frame_buf[2].width; - _dec->pp_frame_buf[2].data=_dec->pp_frame_buf[1].data+c_sz; - oc_ycbcr_buffer_flip(_dec->pp_frame_buf,_dec->pp_frame_buf); - } - _dec->pp_frame_state=1+(_dec->pp_level>=OC_PP_LEVEL_DEBLOCKC); - } - /*If we're not processing chroma, copy the reference frame's chroma planes.*/ - if(_dec->pp_levelpp_frame_buf+1, - _dec->state.ref_frame_bufs[_dec->state.ref_frame_idx[OC_FRAME_SELF]]+1, - sizeof(_dec->pp_frame_buf[1])*2); - } - return 0; -} - - - -typedef struct{ - int bounding_values[256]; - ptrdiff_t ti[3][64]; - ptrdiff_t eob_runs[3][64]; - const ptrdiff_t *coded_fragis[3]; - const ptrdiff_t *uncoded_fragis[3]; - ptrdiff_t ncoded_fragis[3]; - ptrdiff_t nuncoded_fragis[3]; - const ogg_uint16_t *dequant[3][3][2]; - int fragy0[3]; - int fragy_end[3]; - int pred_last[3][3]; - int mcu_nvfrags; - int loop_filter; - int pp_level; -}oc_dec_pipeline_state; - - - -/*Initialize the main decoding pipeline.*/ -static void oc_dec_pipeline_init(oc_dec_ctx *_dec, - oc_dec_pipeline_state *_pipe){ - const ptrdiff_t *coded_fragis; - const ptrdiff_t *uncoded_fragis; - int pli; - int qii; - int qti; - /*If chroma is sub-sampled in the vertical direction, we have to decode two - super block rows of Y' for each super block row of Cb and Cr.*/ - _pipe->mcu_nvfrags=4<state.info.pixel_fmt&2); - /*Initialize the token and extra bits indices for each plane and - coefficient.*/ - memcpy(_pipe->ti,_dec->ti0,sizeof(_pipe->ti)); - /*Also copy over the initial the EOB run counts.*/ - memcpy(_pipe->eob_runs,_dec->eob_runs,sizeof(_pipe->eob_runs)); - /*Set up per-plane pointers to the coded and uncoded fragments lists.*/ - coded_fragis=_dec->state.coded_fragis; - uncoded_fragis=coded_fragis+_dec->state.nfrags; - for(pli=0;pli<3;pli++){ - ptrdiff_t ncoded_fragis; - _pipe->coded_fragis[pli]=coded_fragis; - _pipe->uncoded_fragis[pli]=uncoded_fragis; - ncoded_fragis=_dec->state.ncoded_fragis[pli]; - coded_fragis+=ncoded_fragis; - uncoded_fragis+=ncoded_fragis-_dec->state.fplanes[pli].nfrags; - } - /*Set up condensed quantizer tables.*/ - for(pli=0;pli<3;pli++){ - for(qii=0;qii<_dec->state.nqis;qii++){ - for(qti=0;qti<2;qti++){ - _pipe->dequant[pli][qii][qti]= - _dec->state.dequant_tables[_dec->state.qis[qii]][pli][qti]; - } - } - } - /*Set the previous DC predictor to 0 for all color planes and frame types.*/ - memset(_pipe->pred_last,0,sizeof(_pipe->pred_last)); - /*Initialize the bounding value array for the loop filter.*/ - _pipe->loop_filter=!oc_state_loop_filter_init(&_dec->state, - _pipe->bounding_values); - /*Initialize any buffers needed for post-processing. - We also save the current post-processing level, to guard against the user - changing it from a callback.*/ - if(!oc_dec_postprocess_init(_dec))_pipe->pp_level=_dec->pp_level; - /*If we don't have enough information to post-process, disable it, regardless - of the user-requested level.*/ - else{ - _pipe->pp_level=OC_PP_LEVEL_DISABLED; - memcpy(_dec->pp_frame_buf, - _dec->state.ref_frame_bufs[_dec->state.ref_frame_idx[OC_FRAME_SELF]], - sizeof(_dec->pp_frame_buf[0])*3); - } -} - -/*Undo the DC prediction in a single plane of an MCU (one or two super block - rows). - As a side effect, the number of coded and uncoded fragments in this plane of - the MCU is also computed.*/ -static void oc_dec_dc_unpredict_mcu_plane(oc_dec_ctx *_dec, - oc_dec_pipeline_state *_pipe,int _pli){ - const oc_fragment_plane *fplane; - oc_fragment *frags; - int *pred_last; - ptrdiff_t ncoded_fragis; - ptrdiff_t fragi; - int fragx; - int fragy; - int fragy0; - int fragy_end; - int nhfrags; - /*Compute the first and last fragment row of the current MCU for this - plane.*/ - fplane=_dec->state.fplanes+_pli; - fragy0=_pipe->fragy0[_pli]; - fragy_end=_pipe->fragy_end[_pli]; - nhfrags=fplane->nhfrags; - pred_last=_pipe->pred_last[_pli]; - frags=_dec->state.frags; - ncoded_fragis=0; - fragi=fplane->froffset+fragy0*(ptrdiff_t)nhfrags; - for(fragy=fragy0;fragy=nhfrags)ur_ref=-1; - else{ - ur_ref=u_frags[fragi+1].coded? - OC_FRAME_FOR_MODE(u_frags[fragi+1].mb_mode):-1; - } - if(frags[fragi].coded){ - int pred; - int ref; - ref=OC_FRAME_FOR_MODE(frags[fragi].mb_mode); - /*We break out a separate case based on which of our neighbors use - the same reference frames. - This is somewhat faster than trying to make a generic case which - handles all of them, since it reduces lots of poorly predicted - jumps to one switch statement, and also lets a number of the - multiplications be optimized out by strength reduction.*/ - switch((l_ref==ref)|(ul_ref==ref)<<1| - (u_ref==ref)<<2|(ur_ref==ref)<<3){ - default:pred=pred_last[ref];break; - case 1: - case 3:pred=frags[fragi-1].dc;break; - case 2:pred=u_frags[fragi-1].dc;break; - case 4: - case 6: - case 12:pred=u_frags[fragi].dc;break; - case 5:pred=(frags[fragi-1].dc+u_frags[fragi].dc)/2;break; - case 8:pred=u_frags[fragi+1].dc;break; - case 9: - case 11: - case 13:{ - pred=(75*frags[fragi-1].dc+53*u_frags[fragi+1].dc)/128; - }break; - case 10:pred=(u_frags[fragi-1].dc+u_frags[fragi+1].dc)/2;break; - case 14:{ - pred=(3*(u_frags[fragi-1].dc+u_frags[fragi+1].dc) - +10*u_frags[fragi].dc)/16; - }break; - case 7: - case 15:{ - int p0; - int p1; - int p2; - p0=frags[fragi-1].dc; - p1=u_frags[fragi-1].dc; - p2=u_frags[fragi].dc; - pred=(29*(p0+p2)-26*p1)/32; - if(abs(pred-p2)>128)pred=p2; - else if(abs(pred-p0)>128)pred=p0; - else if(abs(pred-p1)>128)pred=p1; - }break; - } - pred_last[ref]=frags[fragi].dc+=pred; - ncoded_fragis++; - l_ref=ref; - } - else l_ref=-1; - ul_ref=u_ref; - u_ref=ur_ref; - } - } - } - _pipe->ncoded_fragis[_pli]=ncoded_fragis; - /*Also save the number of uncoded fragments so we know how many to copy.*/ - _pipe->nuncoded_fragis[_pli]= - (fragy_end-fragy0)*(ptrdiff_t)nhfrags-ncoded_fragis; -} - -/*Reconstructs all coded fragments in a single MCU (one or two super block - rows). - This requires that each coded fragment have a proper macro block mode and - motion vector (if not in INTRA mode), and have it's DC value decoded, with - the DC prediction process reversed, and the number of coded and uncoded - fragments in this plane of the MCU be counted. - The token lists for each color plane and coefficient should also be filled - in, along with initial token offsets, extra bits offsets, and EOB run - counts.*/ -static void oc_dec_frags_recon_mcu_plane(oc_dec_ctx *_dec, - oc_dec_pipeline_state *_pipe,int _pli){ - unsigned char *dct_tokens; - const unsigned char *dct_fzig_zag; - ogg_uint16_t dc_quant[2]; - const oc_fragment *frags; - const ptrdiff_t *coded_fragis; - ptrdiff_t ncoded_fragis; - ptrdiff_t fragii; - ptrdiff_t *ti; - ptrdiff_t *eob_runs; - int qti; - dct_tokens=_dec->dct_tokens; - dct_fzig_zag=_dec->state.opt_data.dct_fzig_zag; - frags=_dec->state.frags; - coded_fragis=_pipe->coded_fragis[_pli]; - ncoded_fragis=_pipe->ncoded_fragis[_pli]; - ti=_pipe->ti[_pli]; - eob_runs=_pipe->eob_runs[_pli]; - for(qti=0;qti<2;qti++)dc_quant[qti]=_pipe->dequant[_pli][0][qti][0]; - for(fragii=0;fragiidequant[_pli][frags[fragi].qii][qti]; - /*Decode the AC coefficients.*/ - for(zzi=0;zzi<64;){ - int token; - last_zzi=zzi; - if(eob_runs[zzi]){ - eob_runs[zzi]--; - break; - } - else{ - ptrdiff_t eob; - int cw; - int rlen; - int coeff; - int lti; - lti=ti[zzi]; - token=dct_tokens[lti++]; - cw=OC_DCT_CODE_WORD[token]; - /*These parts could be done branchless, but the branches are fairly - predictable and the C code translates into more than a few - instructions, so it's worth it to avoid them.*/ - if(OC_DCT_TOKEN_NEEDS_MORE(token)){ - cw+=dct_tokens[lti++]<>OC_DCT_CW_EOB_SHIFT&0xFFF; - if(token==OC_DCT_TOKEN_FAT_EOB){ - eob+=dct_tokens[lti++]<<8; - if(eob==0)eob=OC_DCT_EOB_FINISH; - } - rlen=(unsigned char)(cw>>OC_DCT_CW_RLEN_SHIFT); - cw^=-(cw&1<>OC_DCT_CW_MAG_SHIFT; - eob_runs[zzi]=eob; - ti[zzi]=lti; - zzi+=rlen; - dct_coeffs[dct_fzig_zag[zzi]]=(ogg_int16_t)(coeff*(int)ac_quant[zzi]); - zzi+=!eob; - } - } - /*TODO: zzi should be exactly 64 here. - If it's not, we should report some kind of warning.*/ - zzi=OC_MINI(zzi,64); - dct_coeffs[0]=(ogg_int16_t)frags[fragi].dc; - /*last_zzi is always initialized. - If your compiler thinks otherwise, it is dumb.*/ - oc_state_frag_recon(&_dec->state,fragi,_pli, - dct_coeffs,last_zzi,dc_quant[qti]); - } - _pipe->coded_fragis[_pli]+=ncoded_fragis; - /*Right now the reconstructed MCU has only the coded blocks in it.*/ - /*TODO: We make the decision here to always copy the uncoded blocks into it - from the reference frame. - We could also copy the coded blocks back over the reference frame, if we - wait for an additional MCU to be decoded, which might be faster if only a - small number of blocks are coded. - However, this introduces more latency, creating a larger cache footprint. - It's unknown which decision is better, but this one results in simpler - code, and the hard case (high bitrate, high resolution) is handled - correctly.*/ - /*Copy the uncoded blocks from the previous reference frame.*/ - _pipe->uncoded_fragis[_pli]-=_pipe->nuncoded_fragis[_pli]; - oc_state_frag_copy_list(&_dec->state,_pipe->uncoded_fragis[_pli], - _pipe->nuncoded_fragis[_pli],OC_FRAME_SELF,OC_FRAME_PREV,_pli); -} - -/*Filter a horizontal block edge.*/ -static void oc_filter_hedge(unsigned char *_dst,int _dst_ystride, - const unsigned char *_src,int _src_ystride,int _qstep,int _flimit, - int *_variance0,int *_variance1){ - unsigned char *rdst; - const unsigned char *rsrc; - unsigned char *cdst; - const unsigned char *csrc; - int r[10]; - int sum0; - int sum1; - int bx; - int by; - rdst=_dst; - rsrc=_src; - for(bx=0;bx<8;bx++){ - cdst=rdst; - csrc=rsrc; - for(by=0;by<10;by++){ - r[by]=*csrc; - csrc+=_src_ystride; - } - sum0=sum1=0; - for(by=0;by<4;by++){ - sum0+=abs(r[by+1]-r[by]); - sum1+=abs(r[by+5]-r[by+6]); - } - *_variance0+=OC_MINI(255,sum0); - *_variance1+=OC_MINI(255,sum1); - if(sum0<_flimit&&sum1<_flimit&&r[5]-r[4]<_qstep&&r[4]-r[5]<_qstep){ - *cdst=(unsigned char)(r[0]*3+r[1]*2+r[2]+r[3]+r[4]+4>>3); - cdst+=_dst_ystride; - *cdst=(unsigned char)(r[0]*2+r[1]+r[2]*2+r[3]+r[4]+r[5]+4>>3); - cdst+=_dst_ystride; - for(by=0;by<4;by++){ - *cdst=(unsigned char)(r[by]+r[by+1]+r[by+2]+r[by+3]*2+ - r[by+4]+r[by+5]+r[by+6]+4>>3); - cdst+=_dst_ystride; - } - *cdst=(unsigned char)(r[4]+r[5]+r[6]+r[7]*2+r[8]+r[9]*2+4>>3); - cdst+=_dst_ystride; - *cdst=(unsigned char)(r[5]+r[6]+r[7]+r[8]*2+r[9]*3+4>>3); - } - else{ - for(by=1;by<=8;by++){ - *cdst=(unsigned char)r[by]; - cdst+=_dst_ystride; - } - } - rdst++; - rsrc++; - } -} - -/*Filter a vertical block edge.*/ -static void oc_filter_vedge(unsigned char *_dst,int _dst_ystride, - int _qstep,int _flimit,int *_variances){ - unsigned char *rdst; - const unsigned char *rsrc; - unsigned char *cdst; - int r[10]; - int sum0; - int sum1; - int bx; - int by; - cdst=_dst; - for(by=0;by<8;by++){ - rsrc=cdst-1; - rdst=cdst; - for(bx=0;bx<10;bx++)r[bx]=*rsrc++; - sum0=sum1=0; - for(bx=0;bx<4;bx++){ - sum0+=abs(r[bx+1]-r[bx]); - sum1+=abs(r[bx+5]-r[bx+6]); - } - _variances[0]+=OC_MINI(255,sum0); - _variances[1]+=OC_MINI(255,sum1); - if(sum0<_flimit&&sum1<_flimit&&r[5]-r[4]<_qstep&&r[4]-r[5]<_qstep){ - *rdst++=(unsigned char)(r[0]*3+r[1]*2+r[2]+r[3]+r[4]+4>>3); - *rdst++=(unsigned char)(r[0]*2+r[1]+r[2]*2+r[3]+r[4]+r[5]+4>>3); - for(bx=0;bx<4;bx++){ - *rdst++=(unsigned char)(r[bx]+r[bx+1]+r[bx+2]+r[bx+3]*2+ - r[bx+4]+r[bx+5]+r[bx+6]+4>>3); - } - *rdst++=(unsigned char)(r[4]+r[5]+r[6]+r[7]*2+r[8]+r[9]*2+4>>3); - *rdst=(unsigned char)(r[5]+r[6]+r[7]+r[8]*2+r[9]*3+4>>3); - } - cdst+=_dst_ystride; - } -} - -static void oc_dec_deblock_frag_rows(oc_dec_ctx *_dec, - th_img_plane *_dst,th_img_plane *_src,int _pli,int _fragy0, - int _fragy_end){ - oc_fragment_plane *fplane; - int *variance; - unsigned char *dc_qi; - unsigned char *dst; - const unsigned char *src; - ptrdiff_t froffset; - int dst_ystride; - int src_ystride; - int nhfrags; - int width; - int notstart; - int notdone; - int flimit; - int qstep; - int y_end; - int y; - int x; - _dst+=_pli; - _src+=_pli; - fplane=_dec->state.fplanes+_pli; - nhfrags=fplane->nhfrags; - froffset=fplane->froffset+_fragy0*(ptrdiff_t)nhfrags; - variance=_dec->variances+froffset; - dc_qi=_dec->dc_qis+froffset; - notstart=_fragy0>0; - notdone=_fragy_endnvfrags; - /*We want to clear an extra row of variances, except at the end.*/ - memset(variance+(nhfrags&-notstart),0, - (_fragy_end+notdone-_fragy0-notstart)*(nhfrags*sizeof(variance[0]))); - /*Except for the first time, we want to point to the middle of the row.*/ - y=(_fragy0<<3)+(notstart<<2); - dst_ystride=_dst->stride; - src_ystride=_src->stride; - dst=_dst->data+y*(ptrdiff_t)dst_ystride; - src=_src->data+y*(ptrdiff_t)src_ystride; - width=_dst->width; - for(;y<4;y++){ - memcpy(dst,src,width*sizeof(dst[0])); - dst+=dst_ystride; - src+=src_ystride; - } - /*We also want to skip the last row in the frame for this loop.*/ - y_end=_fragy_end-!notdone<<3; - for(;ypp_dc_scale[*dc_qi]; - flimit=(qstep*3)>>2; - oc_filter_hedge(dst,dst_ystride,src-src_ystride,src_ystride, - qstep,flimit,variance,variance+nhfrags); - variance++; - dc_qi++; - for(x=8;xpp_dc_scale[*dc_qi]; - flimit=(qstep*3)>>2; - oc_filter_hedge(dst+x,dst_ystride,src+x-src_ystride,src_ystride, - qstep,flimit,variance,variance+nhfrags); - oc_filter_vedge(dst+x-(dst_ystride<<2)-4,dst_ystride, - qstep,flimit,variance-1); - variance++; - dc_qi++; - } - dst+=dst_ystride<<3; - src+=src_ystride<<3; - } - /*And finally, handle the last row in the frame, if it's in the range.*/ - if(!notdone){ - int height; - height=_dst->height; - for(;ypp_dc_scale[*dc_qi++]; - flimit=(qstep*3)>>2; - oc_filter_vedge(dst+x-(dst_ystride<<3)-4,dst_ystride, - qstep,flimit,variance++); - } - } -} - -static void oc_dering_block(unsigned char *_idata,int _ystride,int _b, - int _dc_scale,int _sharp_mod,int _strong){ - static const unsigned char OC_MOD_MAX[2]={24,32}; - static const unsigned char OC_MOD_SHIFT[2]={1,0}; - const unsigned char *psrc; - const unsigned char *src; - const unsigned char *nsrc; - unsigned char *dst; - int vmod[72]; - int hmod[72]; - int mod_hi; - int by; - int bx; - mod_hi=OC_MINI(3*_dc_scale,OC_MOD_MAX[_strong]); - dst=_idata; - src=dst; - psrc=src-(_ystride&-!(_b&4)); - for(by=0;by<9;by++){ - for(bx=0;bx<8;bx++){ - int mod; - mod=32+_dc_scale-(abs(src[bx]-psrc[bx])<>7); - for(bx=1;bx<7;bx++){ - a=128; - b=64; - w=hmod[(bx<<3)+by]; - a-=w; - b+=w*src[bx-1]; - w=vmod[(by<<3)+bx]; - a-=w; - b+=w*psrc[bx]; - w=vmod[(by+1<<3)+bx]; - a-=w; - b+=w*nsrc[bx]; - w=hmod[(bx+1<<3)+by]; - a-=w; - b+=w*src[bx+1]; - dst[bx]=OC_CLAMP255(a*src[bx]+b>>7); - } - a=128; - b=64; - w=hmod[(7<<3)+by]; - a-=w; - b+=w*src[6]; - w=vmod[(by<<3)+7]; - a-=w; - b+=w*psrc[7]; - w=vmod[(by+1<<3)+7]; - a-=w; - b+=w*nsrc[7]; - w=hmod[(8<<3)+by]; - a-=w; - b+=w*src[7+!(_b&2)]; - dst[7]=OC_CLAMP255(a*src[7]+b>>7); - dst+=_ystride; - psrc=src; - src=nsrc; - nsrc+=_ystride&-(!(_b&8)|by<6); - } -} - -#define OC_DERING_THRESH1 (384) -#define OC_DERING_THRESH2 (4*OC_DERING_THRESH1) -#define OC_DERING_THRESH3 (5*OC_DERING_THRESH1) -#define OC_DERING_THRESH4 (10*OC_DERING_THRESH1) - -static void oc_dec_dering_frag_rows(oc_dec_ctx *_dec,th_img_plane *_img, - int _pli,int _fragy0,int _fragy_end){ - th_img_plane *iplane; - oc_fragment_plane *fplane; - oc_fragment *frag; - int *variance; - unsigned char *idata; - ptrdiff_t froffset; - int ystride; - int nhfrags; - int sthresh; - int strong; - int y_end; - int width; - int height; - int y; - int x; - iplane=_img+_pli; - fplane=_dec->state.fplanes+_pli; - nhfrags=fplane->nhfrags; - froffset=fplane->froffset+_fragy0*(ptrdiff_t)nhfrags; - variance=_dec->variances+froffset; - frag=_dec->state.frags+froffset; - strong=_dec->pp_level>=(_pli?OC_PP_LEVEL_SDERINGC:OC_PP_LEVEL_SDERINGY); - sthresh=_pli?OC_DERING_THRESH4:OC_DERING_THRESH3; - y=_fragy0<<3; - ystride=iplane->stride; - idata=iplane->data+y*(ptrdiff_t)ystride; - y_end=_fragy_end<<3; - width=iplane->width; - height=iplane->height; - for(;ystate.qis[frag->qii]; - var=*variance; - b=(x<=0)|(x+8>=width)<<1|(y<=0)<<2|(y+8>=height)<<3; - if(strong&&var>sthresh){ - oc_dering_block(idata+x,ystride,b, - _dec->pp_dc_scale[qi],_dec->pp_sharp_mod[qi],1); - if(_pli||!(b&1)&&*(variance-1)>OC_DERING_THRESH4|| - !(b&2)&&variance[1]>OC_DERING_THRESH4|| - !(b&4)&&*(variance-nhfrags)>OC_DERING_THRESH4|| - !(b&8)&&variance[nhfrags]>OC_DERING_THRESH4){ - oc_dering_block(idata+x,ystride,b, - _dec->pp_dc_scale[qi],_dec->pp_sharp_mod[qi],1); - oc_dering_block(idata+x,ystride,b, - _dec->pp_dc_scale[qi],_dec->pp_sharp_mod[qi],1); - } - } - else if(var>OC_DERING_THRESH2){ - oc_dering_block(idata+x,ystride,b, - _dec->pp_dc_scale[qi],_dec->pp_sharp_mod[qi],1); - } - else if(var>OC_DERING_THRESH1){ - oc_dering_block(idata+x,ystride,b, - _dec->pp_dc_scale[qi],_dec->pp_sharp_mod[qi],0); - } - frag++; - variance++; - } - idata+=ystride<<3; - } -} - - - -th_dec_ctx *th_decode_alloc(const th_info *_info,const th_setup_info *_setup){ - oc_dec_ctx *dec; - if(_info==NULL||_setup==NULL)return NULL; - dec=_ogg_malloc(sizeof(*dec)); - if(dec==NULL||oc_dec_init(dec,_info,_setup)<0){ - _ogg_free(dec); - return NULL; - } - dec->state.curframe_num=0; - return dec; -} - -void th_decode_free(th_dec_ctx *_dec){ - if(_dec!=NULL){ - oc_dec_clear(_dec); - _ogg_free(_dec); - } -} - -int th_decode_ctl(th_dec_ctx *_dec,int _req,void *_buf, - size_t _buf_sz){ - switch(_req){ - case TH_DECCTL_GET_PPLEVEL_MAX:{ - if(_dec==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(int))return TH_EINVAL; - (*(int *)_buf)=OC_PP_LEVEL_MAX; - return 0; - }break; - case TH_DECCTL_SET_PPLEVEL:{ - int pp_level; - if(_dec==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(int))return TH_EINVAL; - pp_level=*(int *)_buf; - if(pp_level<0||pp_level>OC_PP_LEVEL_MAX)return TH_EINVAL; - _dec->pp_level=pp_level; - return 0; - }break; - case TH_DECCTL_SET_GRANPOS:{ - ogg_int64_t granpos; - if(_dec==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(ogg_int64_t))return TH_EINVAL; - granpos=*(ogg_int64_t *)_buf; - if(granpos<0)return TH_EINVAL; - _dec->state.granpos=granpos; - _dec->state.keyframe_num=(granpos>>_dec->state.info.keyframe_granule_shift) - -_dec->state.granpos_bias; - _dec->state.curframe_num=_dec->state.keyframe_num - +(granpos&(1<<_dec->state.info.keyframe_granule_shift)-1); - return 0; - }break; - case TH_DECCTL_SET_STRIPE_CB:{ - th_stripe_callback *cb; - if(_dec==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(th_stripe_callback))return TH_EINVAL; - cb=(th_stripe_callback *)_buf; - _dec->stripe_cb.ctx=cb->ctx; - _dec->stripe_cb.stripe_decoded=cb->stripe_decoded; - return 0; - }break; -#ifdef HAVE_CAIRO - case TH_DECCTL_SET_TELEMETRY_MBMODE:{ - if(_dec==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(int))return TH_EINVAL; - _dec->telemetry=1; - _dec->telemetry_mbmode=*(int *)_buf; - return 0; - }break; - case TH_DECCTL_SET_TELEMETRY_MV:{ - if(_dec==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(int))return TH_EINVAL; - _dec->telemetry=1; - _dec->telemetry_mv=*(int *)_buf; - return 0; - }break; - case TH_DECCTL_SET_TELEMETRY_QI:{ - if(_dec==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(int))return TH_EINVAL; - _dec->telemetry=1; - _dec->telemetry_qi=*(int *)_buf; - return 0; - }break; - case TH_DECCTL_SET_TELEMETRY_BITS:{ - if(_dec==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(int))return TH_EINVAL; - _dec->telemetry=1; - _dec->telemetry_bits=*(int *)_buf; - return 0; - }break; -#endif - default:return TH_EIMPL; - } -} - -/*We're decoding an INTER frame, but have no initialized reference - buffers (i.e., decoding did not start on a key frame). - We initialize them to a solid gray here.*/ -static void oc_dec_init_dummy_frame(th_dec_ctx *_dec){ - th_info *info; - size_t yplane_sz; - size_t cplane_sz; - int yhstride; - int yheight; - int chstride; - int cheight; - _dec->state.ref_frame_idx[OC_FRAME_GOLD]=0; - _dec->state.ref_frame_idx[OC_FRAME_PREV]=0; - _dec->state.ref_frame_idx[OC_FRAME_SELF]=1; - info=&_dec->state.info; - yhstride=info->frame_width+2*OC_UMV_PADDING; - yheight=info->frame_height+2*OC_UMV_PADDING; - chstride=yhstride>>!(info->pixel_fmt&1); - cheight=yheight>>!(info->pixel_fmt&2); - yplane_sz=yhstride*(size_t)yheight; - cplane_sz=chstride*(size_t)cheight; - memset(_dec->state.ref_frame_data[0],0x80,yplane_sz+2*cplane_sz); -} - -int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op, - ogg_int64_t *_granpos){ - int ret; - if(_dec==NULL||_op==NULL)return TH_EFAULT; - /*A completely empty packet indicates a dropped frame and is treated exactly - like an inter frame with no coded blocks. - Only proceed if we have a non-empty packet.*/ - if(_op->bytes!=0){ - oc_dec_pipeline_state pipe; - th_ycbcr_buffer stripe_buf; - int stripe_fragy; - int refi; - int pli; - int notstart; - int notdone; - oc_pack_readinit(&_dec->opb,_op->packet,_op->bytes); -#if defined(HAVE_CAIRO) - _dec->telemetry_frame_bytes=_op->bytes; -#endif - ret=oc_dec_frame_header_unpack(_dec); - if(ret<0)return ret; - /*Select a free buffer to use for the reconstructed version of this - frame.*/ - if(_dec->state.frame_type!=OC_INTRA_FRAME&& - (_dec->state.ref_frame_idx[OC_FRAME_GOLD]<0|| - _dec->state.ref_frame_idx[OC_FRAME_PREV]<0)){ - /*No reference frames yet!*/ - oc_dec_init_dummy_frame(_dec); - refi=_dec->state.ref_frame_idx[OC_FRAME_SELF]; - } - else{ - for(refi=0;refi==_dec->state.ref_frame_idx[OC_FRAME_GOLD]|| - refi==_dec->state.ref_frame_idx[OC_FRAME_PREV];refi++); - _dec->state.ref_frame_idx[OC_FRAME_SELF]=refi; - } - if(_dec->state.frame_type==OC_INTRA_FRAME){ - oc_dec_mark_all_intra(_dec); - _dec->state.keyframe_num=_dec->state.curframe_num; -#if defined(HAVE_CAIRO) - _dec->telemetry_coding_bytes= - _dec->telemetry_mode_bytes= - _dec->telemetry_mv_bytes=oc_pack_bytes_left(&_dec->opb); -#endif - } - else{ - oc_dec_coded_flags_unpack(_dec); -#if defined(HAVE_CAIRO) - _dec->telemetry_coding_bytes=oc_pack_bytes_left(&_dec->opb); -#endif - oc_dec_mb_modes_unpack(_dec); -#if defined(HAVE_CAIRO) - _dec->telemetry_mode_bytes=oc_pack_bytes_left(&_dec->opb); -#endif - oc_dec_mv_unpack_and_frag_modes_fill(_dec); -#if defined(HAVE_CAIRO) - _dec->telemetry_mv_bytes=oc_pack_bytes_left(&_dec->opb); -#endif - } - oc_dec_block_qis_unpack(_dec); -#if defined(HAVE_CAIRO) - _dec->telemetry_qi_bytes=oc_pack_bytes_left(&_dec->opb); -#endif - oc_dec_residual_tokens_unpack(_dec); - /*Update granule position. - This must be done before the striped decode callbacks so that the - application knows what to do with the frame data.*/ - _dec->state.granpos=(_dec->state.keyframe_num+_dec->state.granpos_bias<< - _dec->state.info.keyframe_granule_shift) - +(_dec->state.curframe_num-_dec->state.keyframe_num); - _dec->state.curframe_num++; - if(_granpos!=NULL)*_granpos=_dec->state.granpos; - /*All of the rest of the operations -- DC prediction reversal, - reconstructing coded fragments, copying uncoded fragments, loop - filtering, extending borders, and out-of-loop post-processing -- should - be pipelined. - I.e., DC prediction reversal, reconstruction, and uncoded fragment - copying are done for one or two super block rows, then loop filtering is - run as far as it can, then bordering copying, then post-processing. - For 4:2:0 video a Minimum Codable Unit or MCU contains two luma super - block rows, and one chroma. - Otherwise, an MCU consists of one super block row from each plane. - Inside each MCU, we perform all of the steps on one color plane before - moving on to the next. - After reconstruction, the additional filtering stages introduce a delay - since they need some pixels from the next fragment row. - Thus the actual number of decoded rows available is slightly smaller for - the first MCU, and slightly larger for the last. - - This entire process allows us to operate on the data while it is still in - cache, resulting in big performance improvements. - An application callback allows further application processing (blitting - to video memory, color conversion, etc.) to also use the data while it's - in cache.*/ - oc_dec_pipeline_init(_dec,&pipe); - oc_ycbcr_buffer_flip(stripe_buf,_dec->pp_frame_buf); - notstart=0; - notdone=1; - for(stripe_fragy=0;notdone;stripe_fragy+=pipe.mcu_nvfrags){ - int avail_fragy0; - int avail_fragy_end; - avail_fragy0=avail_fragy_end=_dec->state.fplanes[0].nvfrags; - notdone=stripe_fragy+pipe.mcu_nvfragsstate.fplanes+pli; - /*Compute the first and last fragment row of the current MCU for this - plane.*/ - frag_shift=pli!=0&&!(_dec->state.info.pixel_fmt&2); - pipe.fragy0[pli]=stripe_fragy>>frag_shift; - pipe.fragy_end[pli]=OC_MINI(fplane->nvfrags, - pipe.fragy0[pli]+(pipe.mcu_nvfrags>>frag_shift)); - oc_dec_dc_unpredict_mcu_plane(_dec,&pipe,pli); - oc_dec_frags_recon_mcu_plane(_dec,&pipe,pli); - sdelay=edelay=0; - if(pipe.loop_filter){ - sdelay+=notstart; - edelay+=notdone; - oc_state_loop_filter_frag_rows(&_dec->state,pipe.bounding_values, - refi,pli,pipe.fragy0[pli]-sdelay,pipe.fragy_end[pli]-edelay); - } - /*To fill the borders, we have an additional two pixel delay, since a - fragment in the next row could filter its top edge, using two pixels - from a fragment in this row. - But there's no reason to delay a full fragment between the two.*/ - oc_state_borders_fill_rows(&_dec->state,refi,pli, - (pipe.fragy0[pli]-sdelay<<3)-(sdelay<<1), - (pipe.fragy_end[pli]-edelay<<3)-(edelay<<1)); - /*Out-of-loop post-processing.*/ - pp_offset=3*(pli!=0); - if(pipe.pp_level>=OC_PP_LEVEL_DEBLOCKY+pp_offset){ - /*Perform de-blocking in one plane.*/ - sdelay+=notstart; - edelay+=notdone; - oc_dec_deblock_frag_rows(_dec,_dec->pp_frame_buf, - _dec->state.ref_frame_bufs[refi],pli, - pipe.fragy0[pli]-sdelay,pipe.fragy_end[pli]-edelay); - if(pipe.pp_level>=OC_PP_LEVEL_DERINGY+pp_offset){ - /*Perform de-ringing in one plane.*/ - sdelay+=notstart; - edelay+=notdone; - oc_dec_dering_frag_rows(_dec,_dec->pp_frame_buf,pli, - pipe.fragy0[pli]-sdelay,pipe.fragy_end[pli]-edelay); - } - } - /*If no post-processing is done, we still need to delay a row for the - loop filter, thanks to the strange filtering order VP3 chose.*/ - else if(pipe.loop_filter){ - sdelay+=notstart; - edelay+=notdone; - } - /*Compute the intersection of the available rows in all planes. - If chroma is sub-sampled, the effect of each of its delays is - doubled, but luma might have more post-processing filters enabled - than chroma, so we don't know up front which one is the limiting - factor.*/ - avail_fragy0=OC_MINI(avail_fragy0,pipe.fragy0[pli]-sdelay<stripe_cb.stripe_decoded!=NULL){ - /*The callback might want to use the FPU, so let's make sure they can. - We violate all kinds of ABI restrictions by not doing this until - now, but none of them actually matter since we don't use floating - point ourselves.*/ - oc_restore_fpu(&_dec->state); - /*Make the callback, ensuring we flip the sense of the "start" and - "end" of the available region upside down.*/ - (*_dec->stripe_cb.stripe_decoded)(_dec->stripe_cb.ctx,stripe_buf, - _dec->state.fplanes[0].nvfrags-avail_fragy_end, - _dec->state.fplanes[0].nvfrags-avail_fragy0); - } - notstart=1; - } - /*Finish filling in the reference frame borders.*/ - for(pli=0;pli<3;pli++)oc_state_borders_fill_caps(&_dec->state,refi,pli); - /*Update the reference frame indices.*/ - if(_dec->state.frame_type==OC_INTRA_FRAME){ - /*The new frame becomes both the previous and gold reference frames.*/ - _dec->state.ref_frame_idx[OC_FRAME_GOLD]= - _dec->state.ref_frame_idx[OC_FRAME_PREV]= - _dec->state.ref_frame_idx[OC_FRAME_SELF]; - } - else{ - /*Otherwise, just replace the previous reference frame.*/ - _dec->state.ref_frame_idx[OC_FRAME_PREV]= - _dec->state.ref_frame_idx[OC_FRAME_SELF]; - } - /*Restore the FPU before dump_frame, since that _does_ use the FPU (for PNG - gamma values, if nothing else).*/ - oc_restore_fpu(&_dec->state); -#if defined(OC_DUMP_IMAGES) - /*Don't dump images for dropped frames.*/ - oc_state_dump_frame(&_dec->state,OC_FRAME_SELF,"dec"); -#endif - return 0; - } - else{ - if(_dec->state.ref_frame_idx[OC_FRAME_GOLD]<0|| - _dec->state.ref_frame_idx[OC_FRAME_PREV]<0){ - int refi; - /*No reference frames yet!*/ - oc_dec_init_dummy_frame(_dec); - refi=_dec->state.ref_frame_idx[OC_FRAME_PREV]; - _dec->state.ref_frame_idx[OC_FRAME_SELF]=refi; - memcpy(_dec->pp_frame_buf,_dec->state.ref_frame_bufs[refi], - sizeof(_dec->pp_frame_buf[0])*3); - } - /*Just update the granule position and return.*/ - _dec->state.granpos=(_dec->state.keyframe_num+_dec->state.granpos_bias<< - _dec->state.info.keyframe_granule_shift) - +(_dec->state.curframe_num-_dec->state.keyframe_num); - _dec->state.curframe_num++; - if(_granpos!=NULL)*_granpos=_dec->state.granpos; - return TH_DUPFRAME; - } -} - -int th_decode_ycbcr_out(th_dec_ctx *_dec,th_ycbcr_buffer _ycbcr){ - if(_dec==NULL||_ycbcr==NULL)return TH_EFAULT; - oc_ycbcr_buffer_flip(_ycbcr,_dec->pp_frame_buf); -#if defined(HAVE_CAIRO) - /*If telemetry ioctls are active, we need to draw to the output buffer. - Stuff the plane into cairo.*/ - if(_dec->telemetry){ - cairo_surface_t *cs; - unsigned char *data; - unsigned char *y_row; - unsigned char *u_row; - unsigned char *v_row; - unsigned char *rgb_row; - int cstride; - int w; - int h; - int x; - int y; - int hdec; - int vdec; - w=_ycbcr[0].width; - h=_ycbcr[0].height; - hdec=!(_dec->state.info.pixel_fmt&1); - vdec=!(_dec->state.info.pixel_fmt&2); - /*Lazy data buffer init. - We could try to re-use the post-processing buffer, which would save - memory, but complicate the allocation logic there. - I don't think anyone cares about memory usage when using telemetry; it is - not meant for embedded devices.*/ - if(_dec->telemetry_frame_data==NULL){ - _dec->telemetry_frame_data=_ogg_malloc( - (w*h+2*(w>>hdec)*(h>>vdec))*sizeof(*_dec->telemetry_frame_data)); - if(_dec->telemetry_frame_data==NULL)return 0; - } - cs=cairo_image_surface_create(CAIRO_FORMAT_RGB24,w,h); - /*Sadly, no YUV support in Cairo (yet); convert into the RGB buffer.*/ - data=cairo_image_surface_get_data(cs); - if(data==NULL){ - cairo_surface_destroy(cs); - return 0; - } - cstride=cairo_image_surface_get_stride(cs); - y_row=_ycbcr[0].data; - u_row=_ycbcr[1].data; - v_row=_ycbcr[2].data; - rgb_row=data; - for(y=0;y>hdec]-363703744)/1635200; - g=(3827562*y_row[x]-1287801*u_row[x>>hdec] - -2672387*v_row[x>>hdec]+447306710)/3287200; - b=(952000*y_row[x]+1649289*u_row[x>>hdec]-225932192)/817600; - rgb_row[4*x+0]=OC_CLAMP255(b); - rgb_row[4*x+1]=OC_CLAMP255(g); - rgb_row[4*x+2]=OC_CLAMP255(r); - } - y_row+=_ycbcr[0].stride; - u_row+=_ycbcr[1].stride&-((y&1)|!vdec); - v_row+=_ycbcr[2].stride&-((y&1)|!vdec); - rgb_row+=cstride; - } - /*Draw coded identifier for each macroblock (stored in Hilbert order).*/ - { - cairo_t *c; - const oc_fragment *frags; - oc_mv *frag_mvs; - const signed char *mb_modes; - oc_mb_map *mb_maps; - size_t nmbs; - size_t mbi; - int row2; - int col2; - int qim[3]={0,0,0}; - if(_dec->state.nqis==2){ - int bqi; - bqi=_dec->state.qis[0]; - if(_dec->state.qis[1]>bqi)qim[1]=1; - if(_dec->state.qis[1]state.nqis==3){ - int bqi; - int cqi; - int dqi; - bqi=_dec->state.qis[0]; - cqi=_dec->state.qis[1]; - dqi=_dec->state.qis[2]; - if(cqi>bqi&&dqi>bqi){ - if(dqi>cqi){ - qim[1]=1; - qim[2]=2; - } - else{ - qim[1]=2; - qim[2]=1; - } - } - else if(cqistate.frags; - frag_mvs=_dec->state.frag_mvs; - mb_modes=_dec->state.mb_modes; - mb_maps=_dec->state.mb_maps; - nmbs=_dec->state.nmbs; - row2=0; - col2=0; - for(mbi=0;mbi>1)&1))*16-16; - x=(col2>>1)*16; - cairo_set_line_width(c,1.); - /*Keyframe (all intra) red box.*/ - if(_dec->state.frame_type==OC_INTRA_FRAME){ - if(_dec->telemetry_mbmode&0x02){ - cairo_set_source_rgba(c,1.,0,0,.5); - cairo_rectangle(c,x+2.5,y+2.5,11,11); - cairo_stroke_preserve(c); - cairo_set_source_rgba(c,1.,0,0,.25); - cairo_fill(c); - } - } - else{ - const signed char *frag_mv; - ptrdiff_t fragi; - for(bi=0;bi<4;bi++){ - fragi=mb_maps[mbi][0][bi]; - if(fragi>=0&&frags[fragi].coded){ - frag_mv=frag_mvs[fragi]; - break; - } - } - if(bi<4){ - switch(mb_modes[mbi]){ - case OC_MODE_INTRA:{ - if(_dec->telemetry_mbmode&0x02){ - cairo_set_source_rgba(c,1.,0,0,.5); - cairo_rectangle(c,x+2.5,y+2.5,11,11); - cairo_stroke_preserve(c); - cairo_set_source_rgba(c,1.,0,0,.25); - cairo_fill(c); - } - }break; - case OC_MODE_INTER_NOMV:{ - if(_dec->telemetry_mbmode&0x01){ - cairo_set_source_rgba(c,0,0,1.,.5); - cairo_rectangle(c,x+2.5,y+2.5,11,11); - cairo_stroke_preserve(c); - cairo_set_source_rgba(c,0,0,1.,.25); - cairo_fill(c); - } - }break; - case OC_MODE_INTER_MV:{ - if(_dec->telemetry_mbmode&0x04){ - cairo_rectangle(c,x+2.5,y+2.5,11,11); - cairo_set_source_rgba(c,0,1.,0,.5); - cairo_stroke(c); - } - if(_dec->telemetry_mv&0x04){ - cairo_move_to(c,x+8+frag_mv[0],y+8-frag_mv[1]); - cairo_set_source_rgba(c,1.,1.,1.,.9); - cairo_set_line_width(c,3.); - cairo_line_to(c,x+8+frag_mv[0]*.66,y+8-frag_mv[1]*.66); - cairo_stroke_preserve(c); - cairo_set_line_width(c,2.); - cairo_line_to(c,x+8+frag_mv[0]*.33,y+8-frag_mv[1]*.33); - cairo_stroke_preserve(c); - cairo_set_line_width(c,1.); - cairo_line_to(c,x+8,y+8); - cairo_stroke(c); - } - }break; - case OC_MODE_INTER_MV_LAST:{ - if(_dec->telemetry_mbmode&0x08){ - cairo_rectangle(c,x+2.5,y+2.5,11,11); - cairo_set_source_rgba(c,0,1.,0,.5); - cairo_move_to(c,x+13.5,y+2.5); - cairo_line_to(c,x+2.5,y+8); - cairo_line_to(c,x+13.5,y+13.5); - cairo_stroke(c); - } - if(_dec->telemetry_mv&0x08){ - cairo_move_to(c,x+8+frag_mv[0],y+8-frag_mv[1]); - cairo_set_source_rgba(c,1.,1.,1.,.9); - cairo_set_line_width(c,3.); - cairo_line_to(c,x+8+frag_mv[0]*.66,y+8-frag_mv[1]*.66); - cairo_stroke_preserve(c); - cairo_set_line_width(c,2.); - cairo_line_to(c,x+8+frag_mv[0]*.33,y+8-frag_mv[1]*.33); - cairo_stroke_preserve(c); - cairo_set_line_width(c,1.); - cairo_line_to(c,x+8,y+8); - cairo_stroke(c); - } - }break; - case OC_MODE_INTER_MV_LAST2:{ - if(_dec->telemetry_mbmode&0x10){ - cairo_rectangle(c,x+2.5,y+2.5,11,11); - cairo_set_source_rgba(c,0,1.,0,.5); - cairo_move_to(c,x+8,y+2.5); - cairo_line_to(c,x+2.5,y+8); - cairo_line_to(c,x+8,y+13.5); - cairo_move_to(c,x+13.5,y+2.5); - cairo_line_to(c,x+8,y+8); - cairo_line_to(c,x+13.5,y+13.5); - cairo_stroke(c); - } - if(_dec->telemetry_mv&0x10){ - cairo_move_to(c,x+8+frag_mv[0],y+8-frag_mv[1]); - cairo_set_source_rgba(c,1.,1.,1.,.9); - cairo_set_line_width(c,3.); - cairo_line_to(c,x+8+frag_mv[0]*.66,y+8-frag_mv[1]*.66); - cairo_stroke_preserve(c); - cairo_set_line_width(c,2.); - cairo_line_to(c,x+8+frag_mv[0]*.33,y+8-frag_mv[1]*.33); - cairo_stroke_preserve(c); - cairo_set_line_width(c,1.); - cairo_line_to(c,x+8,y+8); - cairo_stroke(c); - } - }break; - case OC_MODE_GOLDEN_NOMV:{ - if(_dec->telemetry_mbmode&0x20){ - cairo_set_source_rgba(c,1.,1.,0,.5); - cairo_rectangle(c,x+2.5,y+2.5,11,11); - cairo_stroke_preserve(c); - cairo_set_source_rgba(c,1.,1.,0,.25); - cairo_fill(c); - } - }break; - case OC_MODE_GOLDEN_MV:{ - if(_dec->telemetry_mbmode&0x40){ - cairo_rectangle(c,x+2.5,y+2.5,11,11); - cairo_set_source_rgba(c,1.,1.,0,.5); - cairo_stroke(c); - } - if(_dec->telemetry_mv&0x40){ - cairo_move_to(c,x+8+frag_mv[0],y+8-frag_mv[1]); - cairo_set_source_rgba(c,1.,1.,1.,.9); - cairo_set_line_width(c,3.); - cairo_line_to(c,x+8+frag_mv[0]*.66,y+8-frag_mv[1]*.66); - cairo_stroke_preserve(c); - cairo_set_line_width(c,2.); - cairo_line_to(c,x+8+frag_mv[0]*.33,y+8-frag_mv[1]*.33); - cairo_stroke_preserve(c); - cairo_set_line_width(c,1.); - cairo_line_to(c,x+8,y+8); - cairo_stroke(c); - } - }break; - case OC_MODE_INTER_MV_FOUR:{ - if(_dec->telemetry_mbmode&0x80){ - cairo_rectangle(c,x+2.5,y+2.5,4,4); - cairo_rectangle(c,x+9.5,y+2.5,4,4); - cairo_rectangle(c,x+2.5,y+9.5,4,4); - cairo_rectangle(c,x+9.5,y+9.5,4,4); - cairo_set_source_rgba(c,0,1.,0,.5); - cairo_stroke(c); - } - /*4mv is odd, coded in raster order.*/ - fragi=mb_maps[mbi][0][0]; - if(frags[fragi].coded&&_dec->telemetry_mv&0x80){ - frag_mv=frag_mvs[fragi]; - cairo_move_to(c,x+4+frag_mv[0],y+12-frag_mv[1]); - cairo_set_source_rgba(c,1.,1.,1.,.9); - cairo_set_line_width(c,3.); - cairo_line_to(c,x+4+frag_mv[0]*.66,y+12-frag_mv[1]*.66); - cairo_stroke_preserve(c); - cairo_set_line_width(c,2.); - cairo_line_to(c,x+4+frag_mv[0]*.33,y+12-frag_mv[1]*.33); - cairo_stroke_preserve(c); - cairo_set_line_width(c,1.); - cairo_line_to(c,x+4,y+12); - cairo_stroke(c); - } - fragi=mb_maps[mbi][0][1]; - if(frags[fragi].coded&&_dec->telemetry_mv&0x80){ - frag_mv=frag_mvs[fragi]; - cairo_move_to(c,x+12+frag_mv[0],y+12-frag_mv[1]); - cairo_set_source_rgba(c,1.,1.,1.,.9); - cairo_set_line_width(c,3.); - cairo_line_to(c,x+12+frag_mv[0]*.66,y+12-frag_mv[1]*.66); - cairo_stroke_preserve(c); - cairo_set_line_width(c,2.); - cairo_line_to(c,x+12+frag_mv[0]*.33,y+12-frag_mv[1]*.33); - cairo_stroke_preserve(c); - cairo_set_line_width(c,1.); - cairo_line_to(c,x+12,y+12); - cairo_stroke(c); - } - fragi=mb_maps[mbi][0][2]; - if(frags[fragi].coded&&_dec->telemetry_mv&0x80){ - frag_mv=frag_mvs[fragi]; - cairo_move_to(c,x+4+frag_mv[0],y+4-frag_mv[1]); - cairo_set_source_rgba(c,1.,1.,1.,.9); - cairo_set_line_width(c,3.); - cairo_line_to(c,x+4+frag_mv[0]*.66,y+4-frag_mv[1]*.66); - cairo_stroke_preserve(c); - cairo_set_line_width(c,2.); - cairo_line_to(c,x+4+frag_mv[0]*.33,y+4-frag_mv[1]*.33); - cairo_stroke_preserve(c); - cairo_set_line_width(c,1.); - cairo_line_to(c,x+4,y+4); - cairo_stroke(c); - } - fragi=mb_maps[mbi][0][3]; - if(frags[fragi].coded&&_dec->telemetry_mv&0x80){ - frag_mv=frag_mvs[fragi]; - cairo_move_to(c,x+12+frag_mv[0],y+4-frag_mv[1]); - cairo_set_source_rgba(c,1.,1.,1.,.9); - cairo_set_line_width(c,3.); - cairo_line_to(c,x+12+frag_mv[0]*.66,y+4-frag_mv[1]*.66); - cairo_stroke_preserve(c); - cairo_set_line_width(c,2.); - cairo_line_to(c,x+12+frag_mv[0]*.33,y+4-frag_mv[1]*.33); - cairo_stroke_preserve(c); - cairo_set_line_width(c,1.); - cairo_line_to(c,x+12,y+4); - cairo_stroke(c); - } - }break; - } - } - } - /*qii illustration.*/ - if(_dec->telemetry_qi&0x2){ - cairo_set_line_cap(c,CAIRO_LINE_CAP_SQUARE); - for(bi=0;bi<4;bi++){ - ptrdiff_t fragi; - int qiv; - int xp; - int yp; - xp=x+(bi&1)*8; - yp=y+8-(bi&2)*4; - fragi=mb_maps[mbi][0][bi]; - if(fragi>=0&&frags[fragi].coded){ - qiv=qim[frags[fragi].qii]; - cairo_set_line_width(c,3.); - cairo_set_source_rgba(c,0.,0.,0.,.5); - switch(qiv){ - /*Double plus:*/ - case 2:{ - if((bi&1)^((bi&2)>>1)){ - cairo_move_to(c,xp+2.5,yp+1.5); - cairo_line_to(c,xp+2.5,yp+3.5); - cairo_move_to(c,xp+1.5,yp+2.5); - cairo_line_to(c,xp+3.5,yp+2.5); - cairo_move_to(c,xp+5.5,yp+4.5); - cairo_line_to(c,xp+5.5,yp+6.5); - cairo_move_to(c,xp+4.5,yp+5.5); - cairo_line_to(c,xp+6.5,yp+5.5); - cairo_stroke_preserve(c); - cairo_set_source_rgba(c,0.,1.,1.,1.); - } - else{ - cairo_move_to(c,xp+5.5,yp+1.5); - cairo_line_to(c,xp+5.5,yp+3.5); - cairo_move_to(c,xp+4.5,yp+2.5); - cairo_line_to(c,xp+6.5,yp+2.5); - cairo_move_to(c,xp+2.5,yp+4.5); - cairo_line_to(c,xp+2.5,yp+6.5); - cairo_move_to(c,xp+1.5,yp+5.5); - cairo_line_to(c,xp+3.5,yp+5.5); - cairo_stroke_preserve(c); - cairo_set_source_rgba(c,0.,1.,1.,1.); - } - }break; - /*Double minus:*/ - case -2:{ - cairo_move_to(c,xp+2.5,yp+2.5); - cairo_line_to(c,xp+5.5,yp+2.5); - cairo_move_to(c,xp+2.5,yp+5.5); - cairo_line_to(c,xp+5.5,yp+5.5); - cairo_stroke_preserve(c); - cairo_set_source_rgba(c,1.,1.,1.,1.); - }break; - /*Plus:*/ - case 1:{ - if(bi&2==0)yp-=2; - if(bi&1==0)xp-=2; - cairo_move_to(c,xp+4.5,yp+2.5); - cairo_line_to(c,xp+4.5,yp+6.5); - cairo_move_to(c,xp+2.5,yp+4.5); - cairo_line_to(c,xp+6.5,yp+4.5); - cairo_stroke_preserve(c); - cairo_set_source_rgba(c,.1,1.,.3,1.); - break; - } - /*Fall through.*/ - /*Minus:*/ - case -1:{ - cairo_move_to(c,xp+2.5,yp+4.5); - cairo_line_to(c,xp+6.5,yp+4.5); - cairo_stroke_preserve(c); - cairo_set_source_rgba(c,1.,.3,.1,1.); - }break; - default:continue; - } - cairo_set_line_width(c,1.); - cairo_stroke(c); - } - } - } - col2++; - if((col2>>1)>=_dec->state.nhmbs){ - col2=0; - row2+=2; - } - } - /*Bit usage indicator[s]:*/ - if(_dec->telemetry_bits){ - int widths[6]; - int fpsn; - int fpsd; - int mult; - int fullw; - int padw; - int i; - fpsn=_dec->state.info.fps_numerator; - fpsd=_dec->state.info.fps_denominator; - mult=(_dec->telemetry_bits>=0xFF?1:_dec->telemetry_bits); - fullw=250.f*h*fpsd*mult/fpsn; - padw=w-24; - /*Header and coded block bits.*/ - if(_dec->telemetry_frame_bytes<0|| - _dec->telemetry_frame_bytes==OC_LOTS_OF_BITS){ - _dec->telemetry_frame_bytes=0; - } - if(_dec->telemetry_coding_bytes<0|| - _dec->telemetry_coding_bytes>_dec->telemetry_frame_bytes){ - _dec->telemetry_coding_bytes=0; - } - if(_dec->telemetry_mode_bytes<0|| - _dec->telemetry_mode_bytes>_dec->telemetry_frame_bytes){ - _dec->telemetry_mode_bytes=0; - } - if(_dec->telemetry_mv_bytes<0|| - _dec->telemetry_mv_bytes>_dec->telemetry_frame_bytes){ - _dec->telemetry_mv_bytes=0; - } - if(_dec->telemetry_qi_bytes<0|| - _dec->telemetry_qi_bytes>_dec->telemetry_frame_bytes){ - _dec->telemetry_qi_bytes=0; - } - if(_dec->telemetry_dc_bytes<0|| - _dec->telemetry_dc_bytes>_dec->telemetry_frame_bytes){ - _dec->telemetry_dc_bytes=0; - } - widths[0]=padw*(_dec->telemetry_frame_bytes-_dec->telemetry_coding_bytes)/fullw; - widths[1]=padw*(_dec->telemetry_coding_bytes-_dec->telemetry_mode_bytes)/fullw; - widths[2]=padw*(_dec->telemetry_mode_bytes-_dec->telemetry_mv_bytes)/fullw; - widths[3]=padw*(_dec->telemetry_mv_bytes-_dec->telemetry_qi_bytes)/fullw; - widths[4]=padw*(_dec->telemetry_qi_bytes-_dec->telemetry_dc_bytes)/fullw; - widths[5]=padw*(_dec->telemetry_dc_bytes)/fullw; - for(i=0;i<6;i++)if(widths[i]>w)widths[i]=w; - cairo_set_source_rgba(c,.0,.0,.0,.6); - cairo_rectangle(c,10,h-33,widths[0]+1,5); - cairo_rectangle(c,10,h-29,widths[1]+1,5); - cairo_rectangle(c,10,h-25,widths[2]+1,5); - cairo_rectangle(c,10,h-21,widths[3]+1,5); - cairo_rectangle(c,10,h-17,widths[4]+1,5); - cairo_rectangle(c,10,h-13,widths[5]+1,5); - cairo_fill(c); - cairo_set_source_rgb(c,1,0,0); - cairo_rectangle(c,10.5,h-32.5,widths[0],4); - cairo_fill(c); - cairo_set_source_rgb(c,0,1,0); - cairo_rectangle(c,10.5,h-28.5,widths[1],4); - cairo_fill(c); - cairo_set_source_rgb(c,0,0,1); - cairo_rectangle(c,10.5,h-24.5,widths[2],4); - cairo_fill(c); - cairo_set_source_rgb(c,.6,.4,.0); - cairo_rectangle(c,10.5,h-20.5,widths[3],4); - cairo_fill(c); - cairo_set_source_rgb(c,.3,.3,.3); - cairo_rectangle(c,10.5,h-16.5,widths[4],4); - cairo_fill(c); - cairo_set_source_rgb(c,.5,.5,.8); - cairo_rectangle(c,10.5,h-12.5,widths[5],4); - cairo_fill(c); - } - /*Master qi indicator[s]:*/ - if(_dec->telemetry_qi&0x1){ - cairo_text_extents_t extents; - char buffer[10]; - int p; - int y; - p=0; - y=h-7.5; - if(_dec->state.qis[0]>=10)buffer[p++]=48+_dec->state.qis[0]/10; - buffer[p++]=48+_dec->state.qis[0]%10; - if(_dec->state.nqis>=2){ - buffer[p++]=' '; - if(_dec->state.qis[1]>=10)buffer[p++]=48+_dec->state.qis[1]/10; - buffer[p++]=48+_dec->state.qis[1]%10; - } - if(_dec->state.nqis==3){ - buffer[p++]=' '; - if(_dec->state.qis[2]>=10)buffer[p++]=48+_dec->state.qis[2]/10; - buffer[p++]=48+_dec->state.qis[2]%10; - } - buffer[p++]='\0'; - cairo_select_font_face(c,"sans", - CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD); - cairo_set_font_size(c,18); - cairo_text_extents(c,buffer,&extents); - cairo_set_source_rgb(c,1,1,1); - cairo_move_to(c,w-extents.x_advance-10,y); - cairo_show_text(c,buffer); - cairo_set_source_rgb(c,0,0,0); - cairo_move_to(c,w-extents.x_advance-10,y); - cairo_text_path(c,buffer); - cairo_set_line_width(c,.8); - cairo_set_line_join(c,CAIRO_LINE_JOIN_ROUND); - cairo_stroke(c); - } - cairo_destroy(c); - } - /*Out of the Cairo plane into the telemetry YUV buffer.*/ - _ycbcr[0].data=_dec->telemetry_frame_data; - _ycbcr[0].stride=_ycbcr[0].width; - _ycbcr[1].data=_ycbcr[0].data+h*_ycbcr[0].stride; - _ycbcr[1].stride=_ycbcr[1].width; - _ycbcr[2].data=_ycbcr[1].data+(h>>vdec)*_ycbcr[1].stride; - _ycbcr[2].stride=_ycbcr[2].width; - y_row=_ycbcr[0].data; - u_row=_ycbcr[1].data; - v_row=_ycbcr[2].data; - rgb_row=data; - /*This is one of the few places it's worth handling chroma on a - case-by-case basis.*/ - switch(_dec->state.info.pixel_fmt){ - case TH_PF_420:{ - for(y=0;y>1]=OC_CLAMP255(u); - v_row[x>>1]=OC_CLAMP255(v); - } - y_row+=_ycbcr[0].stride<<1; - u_row+=_ycbcr[1].stride; - v_row+=_ycbcr[2].stride; - rgb_row+=cstride<<1; - } - }break; - case TH_PF_422:{ - for(y=0;y>1]=OC_CLAMP255(u); - v_row[x>>1]=OC_CLAMP255(v); - } - y_row+=_ycbcr[0].stride; - u_row+=_ycbcr[1].stride; - v_row+=_ycbcr[2].stride; - rgb_row+=cstride; - } - }break; - /*case TH_PF_444:*/ - default:{ - for(y=0;y -#include -#include -#include "dequant.h" -#include "decint.h" - -int oc_quant_params_unpack(oc_pack_buf *_opb,th_quant_info *_qinfo){ - th_quant_base *base_mats; - long val; - int nbase_mats; - int sizes[64]; - int indices[64]; - int nbits; - int bmi; - int ci; - int qti; - int pli; - int qri; - int qi; - int i; - val=oc_pack_read(_opb,3); - nbits=(int)val; - for(qi=0;qi<64;qi++){ - val=oc_pack_read(_opb,nbits); - _qinfo->loop_filter_limits[qi]=(unsigned char)val; - } - val=oc_pack_read(_opb,4); - nbits=(int)val+1; - for(qi=0;qi<64;qi++){ - val=oc_pack_read(_opb,nbits); - _qinfo->ac_scale[qi]=(ogg_uint16_t)val; - } - val=oc_pack_read(_opb,4); - nbits=(int)val+1; - for(qi=0;qi<64;qi++){ - val=oc_pack_read(_opb,nbits); - _qinfo->dc_scale[qi]=(ogg_uint16_t)val; - } - val=oc_pack_read(_opb,9); - nbase_mats=(int)val+1; - base_mats=_ogg_malloc(nbase_mats*sizeof(base_mats[0])); - if(base_mats==NULL)return TH_EFAULT; - for(bmi=0;bmiqi_ranges[qti]+pli; - if(i>0){ - val=oc_pack_read1(_opb); - if(!val){ - int qtj; - int plj; - if(qti>0){ - val=oc_pack_read1(_opb); - if(val){ - qtj=qti-1; - plj=pli; - } - else{ - qtj=(i-1)/3; - plj=(i-1)%3; - } - } - else{ - qtj=(i-1)/3; - plj=(i-1)%3; - } - *qranges=*(_qinfo->qi_ranges[qtj]+plj); - continue; - } - } - val=oc_pack_read(_opb,nbits); - indices[0]=(int)val; - for(qi=qri=0;qi<63;){ - val=oc_pack_read(_opb,oc_ilog(62-qi)); - sizes[qri]=(int)val+1; - qi+=(int)val+1; - val=oc_pack_read(_opb,nbits); - indices[++qri]=(int)val; - } - /*Note: The caller is responsible for cleaning up any partially - constructed qinfo.*/ - if(qi>63){ - _ogg_free(base_mats); - return TH_EBADHEADER; - } - qranges->nranges=qri; - qranges->sizes=qrsizes=(int *)_ogg_malloc(qri*sizeof(qrsizes[0])); - if(qranges->sizes==NULL){ - /*Note: The caller is responsible for cleaning up any partially - constructed qinfo.*/ - _ogg_free(base_mats); - return TH_EFAULT; - } - memcpy(qrsizes,sizes,qri*sizeof(qrsizes[0])); - qrbms=(th_quant_base *)_ogg_malloc((qri+1)*sizeof(qrbms[0])); - if(qrbms==NULL){ - /*Note: The caller is responsible for cleaning up any partially - constructed qinfo.*/ - _ogg_free(base_mats); - return TH_EFAULT; - } - qranges->base_matrices=(const th_quant_base *)qrbms; - do{ - bmi=indices[qri]; - /*Note: The caller is responsible for cleaning up any partially - constructed qinfo.*/ - if(bmi>=nbase_mats){ - _ogg_free(base_mats); - return TH_EBADHEADER; - } - memcpy(qrbms[qri],base_mats[bmi],sizeof(qrbms[qri])); - } - while(qri-->0); - } - _ogg_free(base_mats); - return 0; -} - -void oc_quant_params_clear(th_quant_info *_qinfo){ - int i; - for(i=6;i-->0;){ - int qti; - int pli; - qti=i/3; - pli=i%3; - /*Clear any duplicate pointer references.*/ - if(i>0){ - int qtj; - int plj; - qtj=(i-1)/3; - plj=(i-1)%3; - if(_qinfo->qi_ranges[qti][pli].sizes== - _qinfo->qi_ranges[qtj][plj].sizes){ - _qinfo->qi_ranges[qti][pli].sizes=NULL; - } - if(_qinfo->qi_ranges[qti][pli].base_matrices== - _qinfo->qi_ranges[qtj][plj].base_matrices){ - _qinfo->qi_ranges[qti][pli].base_matrices=NULL; - } - } - if(qti>0){ - if(_qinfo->qi_ranges[1][pli].sizes== - _qinfo->qi_ranges[0][pli].sizes){ - _qinfo->qi_ranges[1][pli].sizes=NULL; - } - if(_qinfo->qi_ranges[1][pli].base_matrices== - _qinfo->qi_ranges[0][pli].base_matrices){ - _qinfo->qi_ranges[1][pli].base_matrices=NULL; - } - } - /*Now free all the non-duplicate storage.*/ - _ogg_free((void *)_qinfo->qi_ranges[qti][pli].sizes); - _ogg_free((void *)_qinfo->qi_ranges[qti][pli].base_matrices); - } -} diff --git a/Engine/lib/libtheora/lib/dequant.h b/Engine/lib/libtheora/lib/dequant.h deleted file mode 100644 index ef25838e3..000000000 --- a/Engine/lib/libtheora/lib/dequant.h +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: dequant.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#if !defined(_dequant_H) -# define _dequant_H (1) -# include "quant.h" -# include "bitpack.h" - -int oc_quant_params_unpack(oc_pack_buf *_opb, - th_quant_info *_qinfo); -void oc_quant_params_clear(th_quant_info *_qinfo); - -#endif diff --git a/Engine/lib/libtheora/lib/encapiwrapper.c b/Engine/lib/libtheora/lib/encapiwrapper.c deleted file mode 100644 index 874f12442..000000000 --- a/Engine/lib/libtheora/lib/encapiwrapper.c +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include -#include -#include "apiwrapper.h" -#include "encint.h" -#include "theora/theoraenc.h" - - - -static void th_enc_api_clear(th_api_wrapper *_api){ - if(_api->encode)th_encode_free(_api->encode); - memset(_api,0,sizeof(*_api)); -} - -static void theora_encode_clear(theora_state *_te){ - if(_te->i!=NULL)theora_info_clear(_te->i); - memset(_te,0,sizeof(*_te)); -} - -static int theora_encode_control(theora_state *_te,int _req, - void *_buf,size_t _buf_sz){ - return th_encode_ctl(((th_api_wrapper *)_te->i->codec_setup)->encode, - _req,_buf,_buf_sz); -} - -static ogg_int64_t theora_encode_granule_frame(theora_state *_te, - ogg_int64_t _gp){ - return th_granule_frame(((th_api_wrapper *)_te->i->codec_setup)->encode,_gp); -} - -static double theora_encode_granule_time(theora_state *_te,ogg_int64_t _gp){ - return th_granule_time(((th_api_wrapper *)_te->i->codec_setup)->encode,_gp); -} - -static const oc_state_dispatch_vtable OC_ENC_DISPATCH_VTBL={ - (oc_state_clear_func)theora_encode_clear, - (oc_state_control_func)theora_encode_control, - (oc_state_granule_frame_func)theora_encode_granule_frame, - (oc_state_granule_time_func)theora_encode_granule_time, -}; - -int theora_encode_init(theora_state *_te,theora_info *_ci){ - th_api_info *apiinfo; - th_info info; - ogg_uint32_t keyframe_frequency_force; - /*Allocate our own combined API wrapper/theora_info struct. - We put them both in one malloc'd block so that when the API wrapper is - freed, the info struct goes with it. - This avoids having to figure out whether or not we need to free the info - struct in either theora_info_clear() or theora_clear().*/ - apiinfo=(th_api_info *)_ogg_malloc(sizeof(*apiinfo)); - if(apiinfo==NULL)return TH_EFAULT; - /*Make our own copy of the info struct, since its lifetime should be - independent of the one we were passed in.*/ - *&apiinfo->info=*_ci; - oc_theora_info2th_info(&info,_ci); - apiinfo->api.encode=th_encode_alloc(&info); - if(apiinfo->api.encode==NULL){ - _ogg_free(apiinfo); - return OC_EINVAL; - } - apiinfo->api.clear=(oc_setup_clear_func)th_enc_api_clear; - /*Provide entry points for ABI compatibility with old decoder shared libs.*/ - _te->internal_encode=(void *)&OC_ENC_DISPATCH_VTBL; - _te->internal_decode=NULL; - _te->granulepos=0; - _te->i=&apiinfo->info; - _te->i->codec_setup=&apiinfo->api; - /*Set the precise requested keyframe frequency.*/ - keyframe_frequency_force=_ci->keyframe_auto_p? - _ci->keyframe_frequency_force:_ci->keyframe_frequency; - th_encode_ctl(apiinfo->api.encode, - TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE, - &keyframe_frequency_force,sizeof(keyframe_frequency_force)); - /*TODO: Additional codec setup using the extra fields in theora_info.*/ - return 0; -} - -int theora_encode_YUVin(theora_state *_te,yuv_buffer *_yuv){ - th_api_wrapper *api; - th_ycbcr_buffer buf; - int ret; - api=(th_api_wrapper *)_te->i->codec_setup; - buf[0].width=_yuv->y_width; - buf[0].height=_yuv->y_height; - buf[0].stride=_yuv->y_stride; - buf[0].data=_yuv->y; - buf[1].width=_yuv->uv_width; - buf[1].height=_yuv->uv_height; - buf[1].stride=_yuv->uv_stride; - buf[1].data=_yuv->u; - buf[2].width=_yuv->uv_width; - buf[2].height=_yuv->uv_height; - buf[2].stride=_yuv->uv_stride; - buf[2].data=_yuv->v; - ret=th_encode_ycbcr_in(api->encode,buf); - if(ret<0)return ret; - _te->granulepos=api->encode->state.granpos; - return ret; -} - -int theora_encode_packetout(theora_state *_te,int _last_p,ogg_packet *_op){ - th_api_wrapper *api; - api=(th_api_wrapper *)_te->i->codec_setup; - return th_encode_packetout(api->encode,_last_p,_op); -} - -int theora_encode_header(theora_state *_te,ogg_packet *_op){ - oc_enc_ctx *enc; - th_api_wrapper *api; - int ret; - api=(th_api_wrapper *)_te->i->codec_setup; - enc=api->encode; - /*If we've already started encoding, fail.*/ - if(enc->packet_state>OC_PACKET_EMPTY||enc->state.granpos!=0){ - return TH_EINVAL; - } - /*Reset the state to make sure we output an info packet.*/ - enc->packet_state=OC_PACKET_INFO_HDR; - ret=th_encode_flushheader(api->encode,NULL,_op); - return ret>=0?0:ret; -} - -int theora_encode_comment(theora_comment *_tc,ogg_packet *_op){ - oggpack_buffer opb; - void *buf; - int packet_state; - int ret; - packet_state=OC_PACKET_COMMENT_HDR; - oggpackB_writeinit(&opb); - ret=oc_state_flushheader(NULL,&packet_state,&opb,NULL,NULL, - th_version_string(),(th_comment *)_tc,_op); - if(ret>=0){ - /*The oggpack_buffer's lifetime ends with this function, so we have to - copy out the packet contents. - Presumably the application knows it is supposed to free this. - This part works nothing like the Vorbis API, and the documentation on it - has been wrong for some time, claiming libtheora owned the memory.*/ - buf=_ogg_malloc(_op->bytes); - if(buf==NULL){ - _op->packet=NULL; - ret=TH_EFAULT; - } - else{ - memcpy(buf,_op->packet,_op->bytes); - _op->packet=buf; - ret=0; - } - } - oggpack_writeclear(&opb); - return ret; -} - -int theora_encode_tables(theora_state *_te,ogg_packet *_op){ - oc_enc_ctx *enc; - th_api_wrapper *api; - int ret; - api=(th_api_wrapper *)_te->i->codec_setup; - enc=api->encode; - /*If we've already started encoding, fail.*/ - if(enc->packet_state>OC_PACKET_EMPTY||enc->state.granpos!=0){ - return TH_EINVAL; - } - /*Reset the state to make sure we output a setup packet.*/ - enc->packet_state=OC_PACKET_SETUP_HDR; - ret=th_encode_flushheader(api->encode,NULL,_op); - return ret>=0?0:ret; -} diff --git a/Engine/lib/libtheora/lib/encfrag.c b/Engine/lib/libtheora/lib/encfrag.c deleted file mode 100644 index bb814c8e4..000000000 --- a/Engine/lib/libtheora/lib/encfrag.c +++ /dev/null @@ -1,388 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: encfrag.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#include -#include -#include "encint.h" - - -void oc_enc_frag_sub(const oc_enc_ctx *_enc,ogg_int16_t _diff[64], - const unsigned char *_src,const unsigned char *_ref,int _ystride){ - (*_enc->opt_vtable.frag_sub)(_diff,_src,_ref,_ystride); -} - -void oc_enc_frag_sub_c(ogg_int16_t _diff[64],const unsigned char *_src, - const unsigned char *_ref,int _ystride){ - int i; - for(i=0;i<8;i++){ - int j; - for(j=0;j<8;j++)_diff[i*8+j]=(ogg_int16_t)(_src[j]-_ref[j]); - _src+=_ystride; - _ref+=_ystride; - } -} - -void oc_enc_frag_sub_128(const oc_enc_ctx *_enc,ogg_int16_t _diff[64], - const unsigned char *_src,int _ystride){ - (*_enc->opt_vtable.frag_sub_128)(_diff,_src,_ystride); -} - -void oc_enc_frag_sub_128_c(ogg_int16_t *_diff, - const unsigned char *_src,int _ystride){ - int i; - for(i=0;i<8;i++){ - int j; - for(j=0;j<8;j++)_diff[i*8+j]=(ogg_int16_t)(_src[j]-128); - _src+=_ystride; - } -} - -unsigned oc_enc_frag_sad(const oc_enc_ctx *_enc,const unsigned char *_x, - const unsigned char *_y,int _ystride){ - return (*_enc->opt_vtable.frag_sad)(_x,_y,_ystride); -} - -unsigned oc_enc_frag_sad_c(const unsigned char *_src, - const unsigned char *_ref,int _ystride){ - unsigned sad; - int i; - sad=0; - for(i=8;i-->0;){ - int j; - for(j=0;j<8;j++)sad+=abs(_src[j]-_ref[j]); - _src+=_ystride; - _ref+=_ystride; - } - return sad; -} - -unsigned oc_enc_frag_sad_thresh(const oc_enc_ctx *_enc, - const unsigned char *_src,const unsigned char *_ref,int _ystride, - unsigned _thresh){ - return (*_enc->opt_vtable.frag_sad_thresh)(_src,_ref,_ystride,_thresh); -} - -unsigned oc_enc_frag_sad_thresh_c(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh){ - unsigned sad; - int i; - sad=0; - for(i=8;i-->0;){ - int j; - for(j=0;j<8;j++)sad+=abs(_src[j]-_ref[j]); - if(sad>_thresh)break; - _src+=_ystride; - _ref+=_ystride; - } - return sad; -} - -unsigned oc_enc_frag_sad2_thresh(const oc_enc_ctx *_enc, - const unsigned char *_src,const unsigned char *_ref1, - const unsigned char *_ref2,int _ystride,unsigned _thresh){ - return (*_enc->opt_vtable.frag_sad2_thresh)(_src,_ref1,_ref2,_ystride, - _thresh); -} - -unsigned oc_enc_frag_sad2_thresh_c(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh){ - unsigned sad; - int i; - sad=0; - for(i=8;i-->0;){ - int j; - for(j=0;j<8;j++)sad+=abs(_src[j]-(_ref1[j]+_ref2[j]>>1)); - if(sad>_thresh)break; - _src+=_ystride; - _ref1+=_ystride; - _ref2+=_ystride; - } - return sad; -} - -static void oc_diff_hadamard(ogg_int16_t _buf[64],const unsigned char *_src, - const unsigned char *_ref,int _ystride){ - int i; - for(i=0;i<8;i++){ - int t0; - int t1; - int t2; - int t3; - int t4; - int t5; - int t6; - int t7; - int r; - /*Hadamard stage 1:*/ - t0=_src[0]-_ref[0]+_src[4]-_ref[4]; - t4=_src[0]-_ref[0]-_src[4]+_ref[4]; - t1=_src[1]-_ref[1]+_src[5]-_ref[5]; - t5=_src[1]-_ref[1]-_src[5]+_ref[5]; - t2=_src[2]-_ref[2]+_src[6]-_ref[6]; - t6=_src[2]-_ref[2]-_src[6]+_ref[6]; - t3=_src[3]-_ref[3]+_src[7]-_ref[7]; - t7=_src[3]-_ref[3]-_src[7]+_ref[7]; - /*Hadamard stage 2:*/ - r=t0; - t0+=t2; - t2=r-t2; - r=t1; - t1+=t3; - t3=r-t3; - r=t4; - t4+=t6; - t6=r-t6; - r=t5; - t5+=t7; - t7=r-t7; - /*Hadamard stage 3:*/ - _buf[0*8+i]=(ogg_int16_t)(t0+t1); - _buf[1*8+i]=(ogg_int16_t)(t0-t1); - _buf[2*8+i]=(ogg_int16_t)(t2+t3); - _buf[3*8+i]=(ogg_int16_t)(t2-t3); - _buf[4*8+i]=(ogg_int16_t)(t4+t5); - _buf[5*8+i]=(ogg_int16_t)(t4-t5); - _buf[6*8+i]=(ogg_int16_t)(t6+t7); - _buf[7*8+i]=(ogg_int16_t)(t6-t7); - _src+=_ystride; - _ref+=_ystride; - } -} - -static void oc_diff_hadamard2(ogg_int16_t _buf[64],const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride){ - int i; - for(i=0;i<8;i++){ - int t0; - int t1; - int t2; - int t3; - int t4; - int t5; - int t6; - int t7; - int r; - /*Hadamard stage 1:*/ - r=_ref1[0]+_ref2[0]>>1; - t4=_ref1[4]+_ref2[4]>>1; - t0=_src[0]-r+_src[4]-t4; - t4=_src[0]-r-_src[4]+t4; - r=_ref1[1]+_ref2[1]>>1; - t5=_ref1[5]+_ref2[5]>>1; - t1=_src[1]-r+_src[5]-t5; - t5=_src[1]-r-_src[5]+t5; - r=_ref1[2]+_ref2[2]>>1; - t6=_ref1[6]+_ref2[6]>>1; - t2=_src[2]-r+_src[6]-t6; - t6=_src[2]-r-_src[6]+t6; - r=_ref1[3]+_ref2[3]>>1; - t7=_ref1[7]+_ref2[7]>>1; - t3=_src[3]-r+_src[7]-t7; - t7=_src[3]-r-_src[7]+t7; - /*Hadamard stage 2:*/ - r=t0; - t0+=t2; - t2=r-t2; - r=t1; - t1+=t3; - t3=r-t3; - r=t4; - t4+=t6; - t6=r-t6; - r=t5; - t5+=t7; - t7=r-t7; - /*Hadamard stage 3:*/ - _buf[0*8+i]=(ogg_int16_t)(t0+t1); - _buf[1*8+i]=(ogg_int16_t)(t0-t1); - _buf[2*8+i]=(ogg_int16_t)(t2+t3); - _buf[3*8+i]=(ogg_int16_t)(t2-t3); - _buf[4*8+i]=(ogg_int16_t)(t4+t5); - _buf[5*8+i]=(ogg_int16_t)(t4-t5); - _buf[6*8+i]=(ogg_int16_t)(t6+t7); - _buf[7*8+i]=(ogg_int16_t)(t6-t7); - _src+=_ystride; - _ref1+=_ystride; - _ref2+=_ystride; - } -} - -static void oc_intra_hadamard(ogg_int16_t _buf[64],const unsigned char *_src, - int _ystride){ - int i; - for(i=0;i<8;i++){ - int t0; - int t1; - int t2; - int t3; - int t4; - int t5; - int t6; - int t7; - int r; - /*Hadamard stage 1:*/ - t0=_src[0]+_src[4]; - t4=_src[0]-_src[4]; - t1=_src[1]+_src[5]; - t5=_src[1]-_src[5]; - t2=_src[2]+_src[6]; - t6=_src[2]-_src[6]; - t3=_src[3]+_src[7]; - t7=_src[3]-_src[7]; - /*Hadamard stage 2:*/ - r=t0; - t0+=t2; - t2=r-t2; - r=t1; - t1+=t3; - t3=r-t3; - r=t4; - t4+=t6; - t6=r-t6; - r=t5; - t5+=t7; - t7=r-t7; - /*Hadamard stage 3:*/ - _buf[0*8+i]=(ogg_int16_t)(t0+t1); - _buf[1*8+i]=(ogg_int16_t)(t0-t1); - _buf[2*8+i]=(ogg_int16_t)(t2+t3); - _buf[3*8+i]=(ogg_int16_t)(t2-t3); - _buf[4*8+i]=(ogg_int16_t)(t4+t5); - _buf[5*8+i]=(ogg_int16_t)(t4-t5); - _buf[6*8+i]=(ogg_int16_t)(t6+t7); - _buf[7*8+i]=(ogg_int16_t)(t6-t7); - _src+=_ystride; - } -} - -unsigned oc_hadamard_sad_thresh(const ogg_int16_t _buf[64],unsigned _thresh){ - unsigned sad; - int t0; - int t1; - int t2; - int t3; - int t4; - int t5; - int t6; - int t7; - int r; - int i; - sad=0; - for(i=0;i<8;i++){ - /*Hadamard stage 1:*/ - t0=_buf[i*8+0]+_buf[i*8+4]; - t4=_buf[i*8+0]-_buf[i*8+4]; - t1=_buf[i*8+1]+_buf[i*8+5]; - t5=_buf[i*8+1]-_buf[i*8+5]; - t2=_buf[i*8+2]+_buf[i*8+6]; - t6=_buf[i*8+2]-_buf[i*8+6]; - t3=_buf[i*8+3]+_buf[i*8+7]; - t7=_buf[i*8+3]-_buf[i*8+7]; - /*Hadamard stage 2:*/ - r=t0; - t0+=t2; - t2=r-t2; - r=t1; - t1+=t3; - t3=r-t3; - r=t4; - t4+=t6; - t6=r-t6; - r=t5; - t5+=t7; - t7=r-t7; - /*Hadamard stage 3:*/ - r=abs(t0+t1); - r+=abs(t0-t1); - r+=abs(t2+t3); - r+=abs(t2-t3); - r+=abs(t4+t5); - r+=abs(t4-t5); - r+=abs(t6+t7); - r+=abs(t6-t7); - sad+=r; - if(sad>_thresh)break; - } - return sad; -} - -unsigned oc_enc_frag_satd_thresh(const oc_enc_ctx *_enc, - const unsigned char *_src,const unsigned char *_ref,int _ystride, - unsigned _thresh){ - return (*_enc->opt_vtable.frag_satd_thresh)(_src,_ref,_ystride,_thresh); -} - -unsigned oc_enc_frag_satd_thresh_c(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh){ - ogg_int16_t buf[64]; - oc_diff_hadamard(buf,_src,_ref,_ystride); - return oc_hadamard_sad_thresh(buf,_thresh); -} - -unsigned oc_enc_frag_satd2_thresh(const oc_enc_ctx *_enc, - const unsigned char *_src,const unsigned char *_ref1, - const unsigned char *_ref2,int _ystride,unsigned _thresh){ - return (*_enc->opt_vtable.frag_satd2_thresh)(_src,_ref1,_ref2,_ystride, - _thresh); -} - -unsigned oc_enc_frag_satd2_thresh_c(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh){ - ogg_int16_t buf[64]; - oc_diff_hadamard2(buf,_src,_ref1,_ref2,_ystride); - return oc_hadamard_sad_thresh(buf,_thresh); -} - -unsigned oc_enc_frag_intra_satd(const oc_enc_ctx *_enc, - const unsigned char *_src,int _ystride){ - return (*_enc->opt_vtable.frag_intra_satd)(_src,_ystride); -} - -unsigned oc_enc_frag_intra_satd_c(const unsigned char *_src,int _ystride){ - ogg_int16_t buf[64]; - oc_intra_hadamard(buf,_src,_ystride); - return oc_hadamard_sad_thresh(buf,UINT_MAX) - -abs(buf[0]+buf[1]+buf[2]+buf[3]+buf[4]+buf[5]+buf[6]+buf[7]); -} - -void oc_enc_frag_copy2(const oc_enc_ctx *_enc,unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride){ - (*_enc->opt_vtable.frag_copy2)(_dst,_src1,_src2,_ystride); -} - -void oc_enc_frag_copy2_c(unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride){ - int i; - int j; - for(i=8;i-->0;){ - for(j=0;j<8;j++)_dst[j]=_src1[j]+_src2[j]>>1; - _dst+=_ystride; - _src1+=_ystride; - _src2+=_ystride; - } -} - -void oc_enc_frag_recon_intra(const oc_enc_ctx *_enc, - unsigned char *_dst,int _ystride,const ogg_int16_t _residue[64]){ - (*_enc->opt_vtable.frag_recon_intra)(_dst,_ystride,_residue); -} - -void oc_enc_frag_recon_inter(const oc_enc_ctx *_enc,unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]){ - (*_enc->opt_vtable.frag_recon_inter)(_dst,_src,_ystride,_residue); -} diff --git a/Engine/lib/libtheora/lib/encinfo.c b/Engine/lib/libtheora/lib/encinfo.c deleted file mode 100644 index 83be1dae7..000000000 --- a/Engine/lib/libtheora/lib/encinfo.c +++ /dev/null @@ -1,121 +0,0 @@ -#include -#include -#include "internal.h" -#include "enquant.h" -#include "huffenc.h" - - - -/*Packs a series of octets from a given byte array into the pack buffer. - _opb: The pack buffer to store the octets in. - _buf: The byte array containing the bytes to pack. - _len: The number of octets to pack.*/ -static void oc_pack_octets(oggpack_buffer *_opb,const char *_buf,int _len){ - int i; - for(i=0;i<_len;i++)oggpackB_write(_opb,_buf[i],8); -} - - - -int oc_state_flushheader(oc_theora_state *_state,int *_packet_state, - oggpack_buffer *_opb,const th_quant_info *_qinfo, - const th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS], - const char *_vendor,th_comment *_tc,ogg_packet *_op){ - unsigned char *packet; - int b_o_s; - if(_op==NULL)return TH_EFAULT; - switch(*_packet_state){ - /*Codec info header.*/ - case OC_PACKET_INFO_HDR:{ - if(_state==NULL)return TH_EFAULT; - oggpackB_reset(_opb); - /*Mark this packet as the info header.*/ - oggpackB_write(_opb,0x80,8); - /*Write the codec string.*/ - oc_pack_octets(_opb,"theora",6); - /*Write the codec bitstream version.*/ - oggpackB_write(_opb,TH_VERSION_MAJOR,8); - oggpackB_write(_opb,TH_VERSION_MINOR,8); - oggpackB_write(_opb,TH_VERSION_SUB,8); - /*Describe the encoded frame.*/ - oggpackB_write(_opb,_state->info.frame_width>>4,16); - oggpackB_write(_opb,_state->info.frame_height>>4,16); - oggpackB_write(_opb,_state->info.pic_width,24); - oggpackB_write(_opb,_state->info.pic_height,24); - oggpackB_write(_opb,_state->info.pic_x,8); - oggpackB_write(_opb,_state->info.pic_y,8); - oggpackB_write(_opb,_state->info.fps_numerator,32); - oggpackB_write(_opb,_state->info.fps_denominator,32); - oggpackB_write(_opb,_state->info.aspect_numerator,24); - oggpackB_write(_opb,_state->info.aspect_denominator,24); - oggpackB_write(_opb,_state->info.colorspace,8); - oggpackB_write(_opb,_state->info.target_bitrate,24); - oggpackB_write(_opb,_state->info.quality,6); - oggpackB_write(_opb,_state->info.keyframe_granule_shift,5); - oggpackB_write(_opb,_state->info.pixel_fmt,2); - /*Spare configuration bits.*/ - oggpackB_write(_opb,0,3); - b_o_s=1; - }break; - /*Comment header.*/ - case OC_PACKET_COMMENT_HDR:{ - int vendor_len; - int i; - if(_tc==NULL)return TH_EFAULT; - vendor_len=strlen(_vendor); - oggpackB_reset(_opb); - /*Mark this packet as the comment header.*/ - oggpackB_write(_opb,0x81,8); - /*Write the codec string.*/ - oc_pack_octets(_opb,"theora",6); - /*Write the vendor string.*/ - oggpack_write(_opb,vendor_len,32); - oc_pack_octets(_opb,_vendor,vendor_len); - oggpack_write(_opb,_tc->comments,32); - for(i=0;i<_tc->comments;i++){ - if(_tc->user_comments[i]!=NULL){ - oggpack_write(_opb,_tc->comment_lengths[i],32); - oc_pack_octets(_opb,_tc->user_comments[i],_tc->comment_lengths[i]); - } - else oggpack_write(_opb,0,32); - } - b_o_s=0; - }break; - /*Codec setup header.*/ - case OC_PACKET_SETUP_HDR:{ - int ret; - oggpackB_reset(_opb); - /*Mark this packet as the setup header.*/ - oggpackB_write(_opb,0x82,8); - /*Write the codec string.*/ - oc_pack_octets(_opb,"theora",6); - /*Write the quantizer tables.*/ - oc_quant_params_pack(_opb,_qinfo); - /*Write the huffman codes.*/ - ret=oc_huff_codes_pack(_opb,_codes); - /*This should never happen, because we validate the tables when they - are set. - If you see, it's a good chance memory is being corrupted.*/ - if(ret<0)return ret; - b_o_s=0; - }break; - /*No more headers to emit.*/ - default:return 0; - } - /*This is kind of fugly: we hand the user a buffer which they do not own. - We will overwrite it when the next packet is output, so the user better be - done with it by then. - Vorbis is little better: it hands back buffers that it will free the next - time the headers are requested, or when the encoder is cleared. - Hopefully libogg2 will make this much cleaner.*/ - packet=oggpackB_get_buffer(_opb); - /*If there's no packet, malloc failed while writing.*/ - if(packet==NULL)return TH_EFAULT; - _op->packet=packet; - _op->bytes=oggpackB_bytes(_opb); - _op->b_o_s=b_o_s; - _op->e_o_s=0; - _op->granulepos=0; - _op->packetno=*_packet_state+3; - return ++(*_packet_state)+3; -} diff --git a/Engine/lib/libtheora/lib/encint.h b/Engine/lib/libtheora/lib/encint.h deleted file mode 100644 index 97897d5a0..000000000 --- a/Engine/lib/libtheora/lib/encint.h +++ /dev/null @@ -1,493 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: encint.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#if !defined(_encint_H) -# define _encint_H (1) -# if defined(HAVE_CONFIG_H) -# include "config.h" -# endif -# include "theora/theoraenc.h" -# include "internal.h" -# include "ocintrin.h" -# include "mathops.h" -# include "enquant.h" -# include "huffenc.h" -/*# define OC_COLLECT_METRICS*/ - - - -typedef oc_mv oc_mv2[2]; - -typedef struct oc_enc_opt_vtable oc_enc_opt_vtable; -typedef struct oc_mb_enc_info oc_mb_enc_info; -typedef struct oc_mode_scheme_chooser oc_mode_scheme_chooser; -typedef struct oc_iir_filter oc_iir_filter; -typedef struct oc_frame_metrics oc_frame_metrics; -typedef struct oc_rc_state oc_rc_state; -typedef struct th_enc_ctx oc_enc_ctx; -typedef struct oc_token_checkpoint oc_token_checkpoint; - - - -/*Constants for the packet-out state machine specific to the encoder.*/ - -/*Next packet to emit: Data packet, but none are ready yet.*/ -#define OC_PACKET_EMPTY (0) -/*Next packet to emit: Data packet, and one is ready.*/ -#define OC_PACKET_READY (1) - -/*All features enabled.*/ -#define OC_SP_LEVEL_SLOW (0) -/*Enable early skip.*/ -#define OC_SP_LEVEL_EARLY_SKIP (1) -/*Disable motion compensation.*/ -#define OC_SP_LEVEL_NOMC (2) -/*Maximum valid speed level.*/ -#define OC_SP_LEVEL_MAX (2) - - -/*The bits used for each of the MB mode codebooks.*/ -extern const unsigned char OC_MODE_BITS[2][OC_NMODES]; - -/*The bits used for each of the MV codebooks.*/ -extern const unsigned char OC_MV_BITS[2][64]; - -/*The minimum value that can be stored in a SB run for each codeword. - The last entry is the upper bound on the length of a single SB run.*/ -extern const ogg_uint16_t OC_SB_RUN_VAL_MIN[8]; -/*The bits used for each SB run codeword.*/ -extern const unsigned char OC_SB_RUN_CODE_NBITS[7]; - -/*The bits used for each block run length (starting with 1).*/ -extern const unsigned char OC_BLOCK_RUN_CODE_NBITS[30]; - - - -/*Encoder specific functions with accelerated variants.*/ -struct oc_enc_opt_vtable{ - unsigned (*frag_sad)(const unsigned char *_src, - const unsigned char *_ref,int _ystride); - unsigned (*frag_sad_thresh)(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh); - unsigned (*frag_sad2_thresh)(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh); - unsigned (*frag_satd_thresh)(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh); - unsigned (*frag_satd2_thresh)(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh); - unsigned (*frag_intra_satd)(const unsigned char *_src,int _ystride); - void (*frag_sub)(ogg_int16_t _diff[64],const unsigned char *_src, - const unsigned char *_ref,int _ystride); - void (*frag_sub_128)(ogg_int16_t _diff[64], - const unsigned char *_src,int _ystride); - void (*frag_copy2)(unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride); - void (*frag_recon_intra)(unsigned char *_dst,int _ystride, - const ogg_int16_t _residue[64]); - void (*frag_recon_inter)(unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]); - void (*fdct8x8)(ogg_int16_t _y[64],const ogg_int16_t _x[64]); -}; - - -void oc_enc_vtable_init(oc_enc_ctx *_enc); - - - -/*Encoder-specific macroblock information.*/ -struct oc_mb_enc_info{ - /*Neighboring macro blocks that have MVs available from the current frame.*/ - unsigned cneighbors[4]; - /*Neighboring macro blocks to use for MVs from the previous frame.*/ - unsigned pneighbors[4]; - /*The number of current-frame neighbors.*/ - unsigned char ncneighbors; - /*The number of previous-frame neighbors.*/ - unsigned char npneighbors; - /*Flags indicating which MB modes have been refined.*/ - unsigned char refined; - /*Motion vectors for a macro block for the current frame and the - previous two frames. - Each is a set of 2 vectors against OC_FRAME_GOLD and OC_FRAME_PREV, which - can be used to estimate constant velocity and constant acceleration - predictors. - Uninitialized MVs are (0,0).*/ - oc_mv2 analysis_mv[3]; - /*Current unrefined analysis MVs.*/ - oc_mv unref_mv[2]; - /*Unrefined block MVs.*/ - oc_mv block_mv[4]; - /*Refined block MVs.*/ - oc_mv ref_mv[4]; - /*Minimum motion estimation error from the analysis stage.*/ - ogg_uint16_t error[2]; - /*MB error for half-pel refinement for each frame type.*/ - unsigned satd[2]; - /*Block error for half-pel refinement.*/ - unsigned block_satd[4]; -}; - - - -/*State machine to estimate the opportunity cost of coding a MB mode.*/ -struct oc_mode_scheme_chooser{ - /*Pointers to the a list containing the index of each mode in the mode - alphabet used by each scheme. - The first entry points to the dynamic scheme0_ranks, while the remaining 7 - point to the constant entries stored in OC_MODE_SCHEMES.*/ - const unsigned char *mode_ranks[8]; - /*The ranks for each mode when coded with scheme 0. - These are optimized so that the more frequent modes have lower ranks.*/ - unsigned char scheme0_ranks[OC_NMODES]; - /*The list of modes, sorted in descending order of frequency, that - corresponds to the ranks above.*/ - unsigned char scheme0_list[OC_NMODES]; - /*The number of times each mode has been chosen so far.*/ - int mode_counts[OC_NMODES]; - /*The list of mode coding schemes, sorted in ascending order of bit cost.*/ - unsigned char scheme_list[8]; - /*The number of bits used by each mode coding scheme.*/ - ptrdiff_t scheme_bits[8]; -}; - - -void oc_mode_scheme_chooser_init(oc_mode_scheme_chooser *_chooser); - - - -/*A 2nd order low-pass Bessel follower. - We use this for rate control because it has fast reaction time, but is - critically damped.*/ -struct oc_iir_filter{ - ogg_int32_t c[2]; - ogg_int64_t g; - ogg_int32_t x[2]; - ogg_int32_t y[2]; -}; - - - -/*The 2-pass metrics associated with a single frame.*/ -struct oc_frame_metrics{ - /*The log base 2 of the scale factor for this frame in Q24 format.*/ - ogg_int32_t log_scale; - /*The number of application-requested duplicates of this frame.*/ - unsigned dup_count:31; - /*The frame type from pass 1.*/ - unsigned frame_type:1; -}; - - - -/*Rate control state information.*/ -struct oc_rc_state{ - /*The target average bits per frame.*/ - ogg_int64_t bits_per_frame; - /*The current buffer fullness (bits available to be used).*/ - ogg_int64_t fullness; - /*The target buffer fullness. - This is where we'd like to be by the last keyframe the appears in the next - buf_delay frames.*/ - ogg_int64_t target; - /*The maximum buffer fullness (total size of the buffer).*/ - ogg_int64_t max; - /*The log of the number of pixels in a frame in Q57 format.*/ - ogg_int64_t log_npixels; - /*The exponent used in the rate model in Q8 format.*/ - unsigned exp[2]; - /*The number of frames to distribute the buffer usage over.*/ - int buf_delay; - /*The total drop count from the previous frame. - This includes duplicates explicitly requested via the - TH_ENCCTL_SET_DUP_COUNT API as well as frames we chose to drop ourselves.*/ - ogg_uint32_t prev_drop_count; - /*The log of an estimated scale factor used to obtain the real framerate, for - VFR sources or, e.g., 12 fps content doubled to 24 fps, etc.*/ - ogg_int64_t log_drop_scale; - /*The log of estimated scale factor for the rate model in Q57 format.*/ - ogg_int64_t log_scale[2]; - /*The log of the target quantizer level in Q57 format.*/ - ogg_int64_t log_qtarget; - /*Will we drop frames to meet bitrate target?*/ - unsigned char drop_frames; - /*Do we respect the maximum buffer fullness?*/ - unsigned char cap_overflow; - /*Can the reservoir go negative?*/ - unsigned char cap_underflow; - /*Second-order lowpass filters to track scale and VFR.*/ - oc_iir_filter scalefilter[2]; - int inter_count; - int inter_delay; - int inter_delay_target; - oc_iir_filter vfrfilter; - /*Two-pass mode state. - 0 => 1-pass encoding. - 1 => 1st pass of 2-pass encoding. - 2 => 2nd pass of 2-pass encoding.*/ - int twopass; - /*Buffer for current frame metrics.*/ - unsigned char twopass_buffer[48]; - /*The number of bytes in the frame metrics buffer. - When 2-pass encoding is enabled, this is set to 0 after each frame is - submitted, and must be non-zero before the next frame will be accepted.*/ - int twopass_buffer_bytes; - int twopass_buffer_fill; - /*Whether or not to force the next frame to be a keyframe.*/ - unsigned char twopass_force_kf; - /*The metrics for the previous frame.*/ - oc_frame_metrics prev_metrics; - /*The metrics for the current frame.*/ - oc_frame_metrics cur_metrics; - /*The buffered metrics for future frames.*/ - oc_frame_metrics *frame_metrics; - int nframe_metrics; - int cframe_metrics; - /*The index of the current frame in the circular metric buffer.*/ - int frame_metrics_head; - /*The frame count of each type (keyframes, delta frames, and dup frames); - 32 bits limits us to 2.268 years at 60 fps.*/ - ogg_uint32_t frames_total[3]; - /*The number of frames of each type yet to be processed.*/ - ogg_uint32_t frames_left[3]; - /*The sum of the scale values for each frame type.*/ - ogg_int64_t scale_sum[2]; - /*The start of the window over which the current scale sums are taken.*/ - int scale_window0; - /*The end of the window over which the current scale sums are taken.*/ - int scale_window_end; - /*The frame count of each type in the current 2-pass window; this does not - include dup frames.*/ - int nframes[3]; - /*The total accumulated estimation bias.*/ - ogg_int64_t rate_bias; -}; - - -void oc_rc_state_init(oc_rc_state *_rc,oc_enc_ctx *_enc); -void oc_rc_state_clear(oc_rc_state *_rc); - -void oc_enc_rc_resize(oc_enc_ctx *_enc); -int oc_enc_select_qi(oc_enc_ctx *_enc,int _qti,int _clamp); -void oc_enc_calc_lambda(oc_enc_ctx *_enc,int _frame_type); -int oc_enc_update_rc_state(oc_enc_ctx *_enc, - long _bits,int _qti,int _qi,int _trial,int _droppable); -int oc_enc_rc_2pass_out(oc_enc_ctx *_enc,unsigned char **_buf); -int oc_enc_rc_2pass_in(oc_enc_ctx *_enc,unsigned char *_buf,size_t _bytes); - - - -/*The internal encoder state.*/ -struct th_enc_ctx{ - /*Shared encoder/decoder state.*/ - oc_theora_state state; - /*Buffer in which to assemble packets.*/ - oggpack_buffer opb; - /*Encoder-specific macroblock information.*/ - oc_mb_enc_info *mb_info; - /*DC coefficients after prediction.*/ - ogg_int16_t *frag_dc; - /*The list of coded macro blocks, in coded order.*/ - unsigned *coded_mbis; - /*The number of coded macro blocks.*/ - size_t ncoded_mbis; - /*Whether or not packets are ready to be emitted. - This takes on negative values while there are remaining header packets to - be emitted, reaches 0 when the codec is ready for input, and becomes - positive when a frame has been processed and data packets are ready.*/ - int packet_state; - /*The maximum distance between keyframes.*/ - ogg_uint32_t keyframe_frequency_force; - /*The number of duplicates to produce for the next frame.*/ - ogg_uint32_t dup_count; - /*The number of duplicates remaining to be emitted for the current frame.*/ - ogg_uint32_t nqueued_dups; - /*The number of duplicates emitted for the last frame.*/ - ogg_uint32_t prev_dup_count; - /*The current speed level.*/ - int sp_level; - /*Whether or not VP3 compatibility mode has been enabled.*/ - unsigned char vp3_compatible; - /*Whether or not any INTER frames have been coded.*/ - unsigned char coded_inter_frame; - /*Whether or not previous frame was dropped.*/ - unsigned char prevframe_dropped; - /*Stores most recently chosen Huffman tables for each frame type, DC and AC - coefficients, and luma and chroma tokens. - The actual Huffman table used for a given coefficient depends not only on - the choice made here, but also its index in the zig-zag ordering.*/ - unsigned char huff_idxs[2][2][2]; - /*Current count of bits used by each MV coding mode.*/ - size_t mv_bits[2]; - /*The mode scheme chooser for estimating mode coding costs.*/ - oc_mode_scheme_chooser chooser; - /*The number of vertical super blocks in an MCU.*/ - int mcu_nvsbs; - /*The SSD error for skipping each fragment in the current MCU.*/ - unsigned *mcu_skip_ssd; - /*The DCT token lists for each coefficient and each plane.*/ - unsigned char **dct_tokens[3]; - /*The extra bits associated with each DCT token.*/ - ogg_uint16_t **extra_bits[3]; - /*The number of DCT tokens for each coefficient for each plane.*/ - ptrdiff_t ndct_tokens[3][64]; - /*Pending EOB runs for each coefficient for each plane.*/ - ogg_uint16_t eob_run[3][64]; - /*The offset of the first DCT token for each coefficient for each plane.*/ - unsigned char dct_token_offs[3][64]; - /*The last DC coefficient for each plane and reference frame.*/ - int dc_pred_last[3][3]; -#if defined(OC_COLLECT_METRICS) - /*Fragment SATD statistics for MB mode estimation metrics.*/ - unsigned *frag_satd; - /*Fragment SSD statistics for MB mode estimation metrics.*/ - unsigned *frag_ssd; -#endif - /*The R-D optimization parameter.*/ - int lambda; - /*The huffman tables in use.*/ - th_huff_code huff_codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]; - /*The quantization parameters in use.*/ - th_quant_info qinfo; - oc_iquant *enquant_tables[64][3][2]; - oc_iquant_table enquant_table_data[64][3][2]; - /*An "average" quantizer for each quantizer type (INTRA or INTER) and qi - value. - This is used to paramterize the rate control decisions. - They are kept in the log domain to simplify later processing. - Keep in mind these are DCT domain quantizers, and so are scaled by an - additional factor of 4 from the pixel domain.*/ - ogg_int64_t log_qavg[2][64]; - /*The buffer state used to drive rate control.*/ - oc_rc_state rc; - /*Table for encoder acceleration functions.*/ - oc_enc_opt_vtable opt_vtable; -}; - - -void oc_enc_analyze_intra(oc_enc_ctx *_enc,int _recode); -int oc_enc_analyze_inter(oc_enc_ctx *_enc,int _allow_keyframe,int _recode); -#if defined(OC_COLLECT_METRICS) -void oc_enc_mode_metrics_collect(oc_enc_ctx *_enc); -void oc_enc_mode_metrics_dump(oc_enc_ctx *_enc); -#endif - - - -/*Perform fullpel motion search for a single MB against both reference frames.*/ -void oc_mcenc_search(oc_enc_ctx *_enc,int _mbi); -/*Refine a MB MV for one frame.*/ -void oc_mcenc_refine1mv(oc_enc_ctx *_enc,int _mbi,int _frame); -/*Refine the block MVs.*/ -void oc_mcenc_refine4mv(oc_enc_ctx *_enc,int _mbi); - - - -/*Used to rollback a tokenlog transaction when we retroactively decide to skip - a fragment. - A checkpoint is taken right before each token is added.*/ -struct oc_token_checkpoint{ - /*The color plane the token was added to.*/ - unsigned char pli; - /*The zig-zag index the token was added to.*/ - unsigned char zzi; - /*The outstanding EOB run count before the token was added.*/ - ogg_uint16_t eob_run; - /*The token count before the token was added.*/ - ptrdiff_t ndct_tokens; -}; - - - -void oc_enc_tokenize_start(oc_enc_ctx *_enc); -int oc_enc_tokenize_ac(oc_enc_ctx *_enc,int _pli,ptrdiff_t _fragi, - ogg_int16_t *_qdct,const ogg_uint16_t *_dequant,const ogg_int16_t *_dct, - int _zzi,oc_token_checkpoint **_stack,int _acmin); -void oc_enc_tokenlog_rollback(oc_enc_ctx *_enc, - const oc_token_checkpoint *_stack,int _n); -void oc_enc_pred_dc_frag_rows(oc_enc_ctx *_enc, - int _pli,int _fragy0,int _frag_yend); -void oc_enc_tokenize_dc_frag_list(oc_enc_ctx *_enc,int _pli, - const ptrdiff_t *_coded_fragis,ptrdiff_t _ncoded_fragis, - int _prev_ndct_tokens1,int _prev_eob_run1); -void oc_enc_tokenize_finish(oc_enc_ctx *_enc); - - - -/*Utility routine to encode one of the header packets.*/ -int oc_state_flushheader(oc_theora_state *_state,int *_packet_state, - oggpack_buffer *_opb,const th_quant_info *_qinfo, - const th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS], - const char *_vendor,th_comment *_tc,ogg_packet *_op); - - - -/*Encoder-specific accelerated functions.*/ -void oc_enc_frag_sub(const oc_enc_ctx *_enc,ogg_int16_t _diff[64], - const unsigned char *_src,const unsigned char *_ref,int _ystride); -void oc_enc_frag_sub_128(const oc_enc_ctx *_enc,ogg_int16_t _diff[64], - const unsigned char *_src,int _ystride); -unsigned oc_enc_frag_sad(const oc_enc_ctx *_enc,const unsigned char *_src, - const unsigned char *_ref,int _ystride); -unsigned oc_enc_frag_sad_thresh(const oc_enc_ctx *_enc, - const unsigned char *_src,const unsigned char *_ref,int _ystride, - unsigned _thresh); -unsigned oc_enc_frag_sad2_thresh(const oc_enc_ctx *_enc, - const unsigned char *_src,const unsigned char *_ref1, - const unsigned char *_ref2,int _ystride,unsigned _thresh); -unsigned oc_enc_frag_satd_thresh(const oc_enc_ctx *_enc, - const unsigned char *_src,const unsigned char *_ref,int _ystride, - unsigned _thresh); -unsigned oc_enc_frag_satd2_thresh(const oc_enc_ctx *_enc, - const unsigned char *_src,const unsigned char *_ref1, - const unsigned char *_ref2,int _ystride,unsigned _thresh); -unsigned oc_enc_frag_intra_satd(const oc_enc_ctx *_enc, - const unsigned char *_src,int _ystride); -void oc_enc_frag_copy2(const oc_enc_ctx *_enc,unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride); -void oc_enc_frag_recon_intra(const oc_enc_ctx *_enc, - unsigned char *_dst,int _ystride,const ogg_int16_t _residue[64]); -void oc_enc_frag_recon_inter(const oc_enc_ctx *_enc,unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]); -void oc_enc_fdct8x8(const oc_enc_ctx *_enc,ogg_int16_t _y[64], - const ogg_int16_t _x[64]); - -/*Default pure-C implementations.*/ -void oc_enc_vtable_init_c(oc_enc_ctx *_enc); - -void oc_enc_frag_sub_c(ogg_int16_t _diff[64], - const unsigned char *_src,const unsigned char *_ref,int _ystride); -void oc_enc_frag_sub_128_c(ogg_int16_t _diff[64], - const unsigned char *_src,int _ystride); -void oc_enc_frag_copy2_c(unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride); -unsigned oc_enc_frag_sad_c(const unsigned char *_src, - const unsigned char *_ref,int _ystride); -unsigned oc_enc_frag_sad_thresh_c(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh); -unsigned oc_enc_frag_sad2_thresh_c(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh); -unsigned oc_enc_frag_satd_thresh_c(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh); -unsigned oc_enc_frag_satd2_thresh_c(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh); -unsigned oc_enc_frag_intra_satd_c(const unsigned char *_src,int _ystride); -void oc_enc_fdct8x8_c(ogg_int16_t _y[64],const ogg_int16_t _x[64]); - -#endif diff --git a/Engine/lib/libtheora/lib/encode.c b/Engine/lib/libtheora/lib/encode.c deleted file mode 100644 index 0c5ea6a17..000000000 --- a/Engine/lib/libtheora/lib/encode.c +++ /dev/null @@ -1,1615 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: encode.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#include -#include -#include "encint.h" -#if defined(OC_X86_ASM) -# include "x86/x86enc.h" -#endif - - - -/*The default quantization parameters used by VP3.1.*/ -static const int OC_VP31_RANGE_SIZES[1]={63}; -static const th_quant_base OC_VP31_BASES_INTRA_Y[2]={ - { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 58, 68,109,103, 77, - 24, 35, 55, 64, 81,104,113, 92, - 49, 64, 78, 87,103,121,120,101, - 72, 92, 95, 98,112,100,103, 99 - }, - { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 58, 68,109,103, 77, - 24, 35, 55, 64, 81,104,113, 92, - 49, 64, 78, 87,103,121,120,101, - 72, 92, 95, 98,112,100,103, 99 - } -}; -static const th_quant_base OC_VP31_BASES_INTRA_C[2]={ - { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 - }, - { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 - } -}; -static const th_quant_base OC_VP31_BASES_INTER[2]={ - { - 16, 16, 16, 20, 24, 28, 32, 40, - 16, 16, 20, 24, 28, 32, 40, 48, - 16, 20, 24, 28, 32, 40, 48, 64, - 20, 24, 28, 32, 40, 48, 64, 64, - 24, 28, 32, 40, 48, 64, 64, 64, - 28, 32, 40, 48, 64, 64, 64, 96, - 32, 40, 48, 64, 64, 64, 96,128, - 40, 48, 64, 64, 64, 96,128,128 - }, - { - 16, 16, 16, 20, 24, 28, 32, 40, - 16, 16, 20, 24, 28, 32, 40, 48, - 16, 20, 24, 28, 32, 40, 48, 64, - 20, 24, 28, 32, 40, 48, 64, 64, - 24, 28, 32, 40, 48, 64, 64, 64, - 28, 32, 40, 48, 64, 64, 64, 96, - 32, 40, 48, 64, 64, 64, 96,128, - 40, 48, 64, 64, 64, 96,128,128 - } -}; - -const th_quant_info TH_VP31_QUANT_INFO={ - { - 220,200,190,180,170,170,160,160, - 150,150,140,140,130,130,120,120, - 110,110,100,100, 90, 90, 90, 80, - 80, 80, 70, 70, 70, 60, 60, 60, - 60, 50, 50, 50, 50, 40, 40, 40, - 40, 40, 30, 30, 30, 30, 30, 30, - 30, 20, 20, 20, 20, 20, 20, 20, - 20, 10, 10, 10, 10, 10, 10, 10 - }, - { - 500,450,400,370,340,310,285,265, - 245,225,210,195,185,180,170,160, - 150,145,135,130,125,115,110,107, - 100, 96, 93, 89, 85, 82, 75, 74, - 70, 68, 64, 60, 57, 56, 52, 50, - 49, 45, 44, 43, 40, 38, 37, 35, - 33, 32, 30, 29, 28, 25, 24, 22, - 21, 19, 18, 17, 15, 13, 12, 10 - }, - { - 30,25,20,20,15,15,14,14, - 13,13,12,12,11,11,10,10, - 9, 9, 8, 8, 7, 7, 7, 7, - 6, 6, 6, 6, 5, 5, 5, 5, - 4, 4, 4, 4, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 - }, - { - { - {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_Y}, - {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_C}, - {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_C} - }, - { - {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER}, - {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER}, - {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER} - } - } -}; - -/*The current default quantization parameters.*/ -static const int OC_DEF_QRANGE_SIZES[3]={32,16,15}; -static const th_quant_base OC_DEF_BASES_INTRA_Y[4]={ - { - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - }, - { - 15, 12, 12, 15, 18, 20, 20, 21, - 13, 13, 14, 17, 18, 21, 21, 20, - 14, 14, 15, 18, 20, 21, 21, 21, - 14, 16, 17, 19, 20, 21, 21, 21, - 16, 17, 20, 21, 21, 21, 21, 21, - 18, 19, 20, 21, 21, 21, 21, 21, - 20, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21 - }, - { - 16, 12, 11, 16, 20, 25, 27, 28, - 13, 13, 14, 18, 21, 28, 28, 27, - 14, 13, 16, 20, 25, 28, 28, 28, - 14, 16, 19, 22, 27, 29, 29, 28, - 17, 19, 25, 28, 28, 30, 30, 29, - 20, 24, 27, 28, 29, 30, 30, 29, - 27, 28, 29, 29, 30, 30, 30, 30, - 29, 29, 29, 29, 30, 30, 30, 29 - }, - { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 58, 68,109,103, 77, - 24, 35, 55, 64, 81,104,113, 92, - 49, 64, 78, 87,103,121,120,101, - 72, 92, 95, 98,112,100,103, 99 - } -}; -static const th_quant_base OC_DEF_BASES_INTRA_C[4]={ - { - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19 - }, - { - 18, 18, 21, 25, 26, 26, 26, 26, - 18, 20, 22, 26, 26, 26, 26, 26, - 21, 22, 25, 26, 26, 26, 26, 26, - 25, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26 - }, - { - 17, 18, 22, 31, 36, 36, 36, 36, - 18, 20, 24, 34, 36, 36, 36, 36, - 22, 24, 33, 36, 36, 36, 36, 36, - 31, 34, 36, 36, 36, 36, 36, 36, - 36, 36, 36, 36, 36, 36, 36, 36, - 36, 36, 36, 36, 36, 36, 36, 36, - 36, 36, 36, 36, 36, 36, 36, 36, - 36, 36, 36, 36, 36, 36, 36, 36 - }, - { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 - } -}; -static const th_quant_base OC_DEF_BASES_INTER[4]={ - { - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21 - }, - { - 18, 18, 18, 21, 23, 24, 25, 27, - 18, 18, 21, 23, 24, 25, 27, 28, - 18, 21, 23, 24, 25, 27, 28, 29, - 21, 23, 24, 25, 27, 28, 29, 29, - 23, 24, 25, 27, 28, 29, 29, 29, - 24, 25, 27, 28, 29, 29, 29, 30, - 25, 27, 28, 29, 29, 29, 30, 30, - 27, 28, 29, 29, 29, 30, 30, 30 - }, - { - 17, 17, 17, 20, 23, 26, 28, 32, - 17, 17, 20, 23, 26, 28, 32, 34, - 17, 20, 23, 26, 28, 32, 34, 37, - 20, 23, 26, 28, 32, 34, 37, 37, - 23, 26, 28, 32, 34, 37, 37, 37, - 26, 28, 32, 34, 37, 37, 37, 41, - 28, 32, 34, 37, 37, 37, 41, 42, - 32, 34, 37, 37, 37, 41, 42, 42 - }, - { - 16, 16, 16, 20, 24, 28, 32, 40, - 16, 16, 20, 24, 28, 32, 40, 48, - 16, 20, 24, 28, 32, 40, 48, 64, - 20, 24, 28, 32, 40, 48, 64, 64, - 24, 28, 32, 40, 48, 64, 64, 64, - 28, 32, 40, 48, 64, 64, 64, 96, - 32, 40, 48, 64, 64, 64, 96,128, - 40, 48, 64, 64, 64, 96,128,128 - } -}; - -const th_quant_info TH_DEF_QUANT_INFO={ - { - 365,348,333,316,300,287,277,265, - 252,240,229,219,206,197,189,180, - 171,168,160,153,146,139,132,127, - 121,115,110,107,101, 97, 94, 89, - 85, 83, 78, 73, 72, 67, 66, 62, - 60, 59, 56, 53, 52, 48, 47, 43, - 42, 40, 36, 35, 34, 33, 31, 30, - 28, 25, 24, 22, 20, 17, 14, 10 - }, - { - 365,348,333,316,300,287,277,265, - 252,240,229,219,206,197,189,180, - 171,168,160,153,146,139,132,127, - 121,115,110,107,101, 97, 94, 89, - 85, 83, 78, 73, 72, 67, 66, 62, - 60, 59, 56, 53, 52, 48, 47, 43, - 42, 40, 36, 35, 34, 33, 31, 30, - 28, 25, 24, 22, 20, 17, 14, 10 - }, - { - 30,25,20,20,15,15,14,14, - 13,13,12,12,11,11,10,10, - 9, 9, 8, 8, 7, 7, 7, 7, - 6, 6, 6, 6, 5, 5, 5, 5, - 4, 4, 4, 4, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 - }, - { - { - {3,OC_DEF_QRANGE_SIZES,OC_DEF_BASES_INTRA_Y}, - {3,OC_DEF_QRANGE_SIZES,OC_DEF_BASES_INTRA_C}, - {3,OC_DEF_QRANGE_SIZES,OC_DEF_BASES_INTRA_C} - }, - { - {3,OC_DEF_QRANGE_SIZES,OC_DEF_BASES_INTER}, - {3,OC_DEF_QRANGE_SIZES,OC_DEF_BASES_INTER}, - {3,OC_DEF_QRANGE_SIZES,OC_DEF_BASES_INTER} - } - } -}; - - - -/*The Huffman codes used for macro block modes.*/ - -const unsigned char OC_MODE_BITS[2][OC_NMODES]={ - /*Codebook 0: a maximally skewed prefix code.*/ - {1,2,3,4,5,6,7,7}, - /*Codebook 1: a fixed-length code.*/ - {3,3,3,3,3,3,3,3} -}; - -static const unsigned char OC_MODE_CODES[2][OC_NMODES]={ - /*Codebook 0: a maximally skewed prefix code.*/ - {0x00,0x02,0x06,0x0E,0x1E,0x3E,0x7E,0x7F}, - /*Codebook 1: a fixed-length code.*/ - {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07} -}; - - -/*The Huffman codes used for motion vectors.*/ - -const unsigned char OC_MV_BITS[2][64]={ - /*Codebook 0: VLC code.*/ - { - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,7,7,7,7,7,7,7,7,6,6,6,6,4,4,3, - 3, - 3,4,4,6,6,6,6,7,7,7,7,7,7,7,7,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 - }, - /*Codebook 1: (5 bit magnitude, 1 bit sign). - This wastes a code word (0x01, negative zero), or a bit (0x00, positive - zero, requires only 5 bits to uniquely decode), but is hopefully not used - very often.*/ - { - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 - } -}; - -static const unsigned char OC_MV_CODES[2][64]={ - /*Codebook 0: VLC code.*/ - { - 0xFF,0xFD,0xFB,0xF9,0xF7,0xF5,0xF3, - 0xF1,0xEF,0xED,0xEB,0xE9,0xE7,0xE5,0xE3, - 0xE1,0x6F,0x6D,0x6B,0x69,0x67,0x65,0x63, - 0x61,0x2F,0x2D,0x2B,0x29,0x09,0x07,0x02, - 0x00, - 0x01,0x06,0x08,0x28,0x2A,0x2C,0x2E,0x60, - 0x62,0x64,0x66,0x68,0x6A,0x6C,0x6E,0xE0, - 0xE2,0xE4,0xE6,0xE8,0xEA,0xEC,0xEE,0xF0, - 0xF2,0xF4,0xF6,0xF8,0xFA,0xFC,0xFE - }, - /*Codebook 1: (5 bit magnitude, 1 bit sign).*/ - { - 0x3F,0x3D,0x3B,0x39,0x37,0x35,0x33, - 0x31,0x2F,0x2D,0x2B,0x29,0x27,0x25,0x23, - 0x21,0x1F,0x1D,0x1B,0x19,0x17,0x15,0x13, - 0x11,0x0F,0x0D,0x0B,0x09,0x07,0x05,0x03, - 0x00, - 0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10, - 0x12,0x14,0x16,0x18,0x1A,0x1C,0x1E,0x20, - 0x22,0x24,0x26,0x28,0x2A,0x2C,0x2E,0x30, - 0x32,0x34,0x36,0x38,0x3A,0x3C,0x3E - } -}; - - - -/*Super block run coding scheme: - Codeword Run Length - 0 1 - 10x 2-3 - 110x 4-5 - 1110xx 6-9 - 11110xxx 10-17 - 111110xxxx 18-33 - 111111xxxxxxxxxxxx 34-4129*/ -const ogg_uint16_t OC_SB_RUN_VAL_MIN[8]={1,2,4,6,10,18,34,4130}; -static const unsigned OC_SB_RUN_CODE_PREFIX[7]={ - 0,4,0xC,0x38,0xF0,0x3E0,0x3F000 -}; -const unsigned char OC_SB_RUN_CODE_NBITS[7]={1,3,4,6,8,10,18}; - - -/*Writes the bit pattern for the run length of a super block run to the given - oggpack_buffer. - _opb: The buffer to write to. - _run_count: The length of the run, which must be positive. - _flag: The current flag. - _done: Whether or not more flags are to be encoded.*/ -static void oc_sb_run_pack(oggpack_buffer *_opb,ptrdiff_t _run_count, - int _flag,int _done){ - int i; - if(_run_count>=4129){ - do{ - oggpackB_write(_opb,0x3FFFF,18); - _run_count-=4129; - if(_run_count>0)oggpackB_write(_opb,_flag,1); - else if(!_done)oggpackB_write(_opb,!_flag,1); - } - while(_run_count>=4129); - if(_run_count<=0)return; - } - for(i=0;_run_count>=OC_SB_RUN_VAL_MIN[i+1];i++); - oggpackB_write(_opb,OC_SB_RUN_CODE_PREFIX[i]+_run_count-OC_SB_RUN_VAL_MIN[i], - OC_SB_RUN_CODE_NBITS[i]); -} - - - -/*Block run coding scheme: - Codeword Run Length - 0x 1-2 - 10x 3-4 - 110x 5-6 - 1110xx 7-10 - 11110xx 11-14 - 11111xxxx 15-30*/ -const unsigned char OC_BLOCK_RUN_CODE_NBITS[30]={ - 2,2,3,3,4,4,6,6,6,6,7,7,7,7,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9 -}; -static const ogg_uint16_t OC_BLOCK_RUN_CODE_PATTERN[30]={ - 0x000,0x001,0x004,0x005,0x00C,0x00D,0x038, - 0x039,0x03A,0x03B,0x078,0x079,0x07A,0x07B,0x1F0, - 0x1F1,0x1F2,0x1F3,0x1F4,0x1F5,0x1F6,0x1F7,0x1F8, - 0x1F9,0x1FA,0x1FB,0x1FC,0x1FD,0x1FE,0x1FF -}; - - -/*Writes the bit pattern for the run length of a block run to the given - oggpack_buffer. - _opb: The buffer to write to. - _run_count: The length of the run. - This must be positive, and no more than 30.*/ -static void oc_block_run_pack(oggpack_buffer *_opb,int _run_count){ - oggpackB_write(_opb,OC_BLOCK_RUN_CODE_PATTERN[_run_count-1], - OC_BLOCK_RUN_CODE_NBITS[_run_count-1]); -} - - - -static void oc_enc_frame_header_pack(oc_enc_ctx *_enc){ - /*Mark this as a data packet.*/ - oggpackB_write(&_enc->opb,0,1); - /*Output the frame type (key frame or delta frame).*/ - oggpackB_write(&_enc->opb,_enc->state.frame_type,1); - /*Write out the current qi list.*/ - oggpackB_write(&_enc->opb,_enc->state.qis[0],6); - if(_enc->state.nqis>1){ - oggpackB_write(&_enc->opb,1,1); - oggpackB_write(&_enc->opb,_enc->state.qis[1],6); - if(_enc->state.nqis>2){ - oggpackB_write(&_enc->opb,1,1); - oggpackB_write(&_enc->opb,_enc->state.qis[2],6); - } - else oggpackB_write(&_enc->opb,0,1); - } - else oggpackB_write(&_enc->opb,0,1); - if(_enc->state.frame_type==OC_INTRA_FRAME){ - /*Key frames have 3 unused configuration bits, holdovers from the VP3 days. - Most of the other unused bits in the VP3 headers were eliminated. - Monty kept these to leave us some wiggle room for future expansion, - though a single bit in all frames would have been far more useful.*/ - oggpackB_write(&_enc->opb,0,3); - } -} - -/*Writes the bit flags for whether or not each super block is partially coded - or not. - These flags are run-length encoded, with the flag value alternating between - each run. - Return: The number partially coded SBs.*/ -static unsigned oc_enc_partial_sb_flags_pack(oc_enc_ctx *_enc){ - const oc_sb_flags *sb_flags; - unsigned nsbs; - unsigned sbi; - unsigned npartial; - int flag; - sb_flags=_enc->state.sb_flags; - nsbs=_enc->state.nsbs; - flag=sb_flags[0].coded_partially; - oggpackB_write(&_enc->opb,flag,1); - sbi=npartial=0; - do{ - unsigned run_count; - for(run_count=0;sbiopb,run_count,flag,sbi>=nsbs); - flag=!flag; - } - while(sbistate.sb_flags; - nsbs=_enc->state.nsbs; - /*Skip partially coded super blocks; their flags have already been coded.*/ - for(sbi=0;sb_flags[sbi].coded_partially;sbi++); - flag=sb_flags[sbi].coded_fully; - oggpackB_write(&_enc->opb,flag,1); - do{ - unsigned run_count; - for(run_count=0;sbiopb,run_count,flag,sbi>=nsbs); - flag=!flag; - } - while(sbistate.nsbs)oc_enc_coded_sb_flags_pack(_enc); - sb_maps=(const oc_sb_map *)_enc->state.sb_maps; - sb_flags=_enc->state.sb_flags; - nsbs=_enc->state.nsbs; - frags=_enc->state.frags; - for(sbi=0;sbiopb,flag,1); - run_count=0; - nsbs=sbi=0; - for(pli=0;pli<3;pli++){ - nsbs+=_enc->state.fplanes[pli].nsbs; - for(;sbi=0){ - if(frags[fragi].coded!=flag){ - oc_block_run_pack(&_enc->opb,run_count); - flag=!flag; - run_count=1; - } - else run_count++; - } - } - } - } - } - } - /*Flush any trailing block coded run.*/ - if(run_count>0)oc_block_run_pack(&_enc->opb,run_count); - } -} - -static void oc_enc_mb_modes_pack(oc_enc_ctx *_enc){ - const unsigned char *mode_codes; - const unsigned char *mode_bits; - const unsigned char *mode_ranks; - unsigned *coded_mbis; - size_t ncoded_mbis; - const signed char *mb_modes; - unsigned mbii; - int scheme; - int mb_mode; - scheme=_enc->chooser.scheme_list[0]; - /*Encode the best scheme.*/ - oggpackB_write(&_enc->opb,scheme,3); - /*If the chosen scheme is scheme 0, send the mode frequency ordering.*/ - if(scheme==0){ - for(mb_mode=0;mb_modeopb,_enc->chooser.scheme0_ranks[mb_mode],3); - } - } - mode_ranks=_enc->chooser.mode_ranks[scheme]; - mode_bits=OC_MODE_BITS[scheme+1>>3]; - mode_codes=OC_MODE_CODES[scheme+1>>3]; - coded_mbis=_enc->coded_mbis; - ncoded_mbis=_enc->ncoded_mbis; - mb_modes=_enc->state.mb_modes; - for(mbii=0;mbiiopb,mode_codes[rank],mode_bits[rank]); - } -} - -static void oc_enc_mv_pack(oc_enc_ctx *_enc,int _mv_scheme,int _dx,int _dy){ - oggpackB_write(&_enc->opb, - OC_MV_CODES[_mv_scheme][_dx+31],OC_MV_BITS[_mv_scheme][_dx+31]); - oggpackB_write(&_enc->opb, - OC_MV_CODES[_mv_scheme][_dy+31],OC_MV_BITS[_mv_scheme][_dy+31]); -} - -static void oc_enc_mvs_pack(oc_enc_ctx *_enc){ - const unsigned *coded_mbis; - size_t ncoded_mbis; - const oc_mb_map *mb_maps; - const signed char *mb_modes; - const oc_fragment *frags; - const oc_mv *frag_mvs; - unsigned mbii; - int mv_scheme; - /*Choose the coding scheme.*/ - mv_scheme=_enc->mv_bits[1]<_enc->mv_bits[0]; - oggpackB_write(&_enc->opb,mv_scheme,1); - /*Encode the motion vectors. - Macro blocks are iterated in Hilbert scan order, but the MVs within the - macro block are coded in raster order.*/ - coded_mbis=_enc->coded_mbis; - ncoded_mbis=_enc->ncoded_mbis; - mb_modes=_enc->state.mb_modes; - mb_maps=(const oc_mb_map *)_enc->state.mb_maps; - frags=_enc->state.frags; - frag_mvs=(const oc_mv *)_enc->state.frag_mvs; - for(mbii=0;mbiistate.nqis<=1)return; - ncoded_fragis=_enc->state.ntotal_coded_fragis; - if(ncoded_fragis<=0)return; - coded_fragis=_enc->state.coded_fragis; - frags=_enc->state.frags; - flag=!!frags[coded_fragis[0]].qii; - oggpackB_write(&_enc->opb,flag,1); - nqi0=0; - for(fragii=0;fragiiopb,run_count,flag,fragii>=ncoded_fragis); - flag=!flag; - } - if(_enc->state.nqis<3||nqi0>=ncoded_fragis)return; - for(fragii=0;!frags[coded_fragis[fragii]].qii;fragii++); - flag=frags[coded_fragis[fragii]].qii-1; - oggpackB_write(&_enc->opb,flag,1); - while(fragiiopb,run_count,flag,fragii>=ncoded_fragis); - flag=!flag; - } -} - -/*Counts the tokens of each type used for the given range of coefficient - indices in zig-zag order. - _zzi_start: The first zig-zag index to include. - _zzi_end: The first zig-zag index to not include. - _token_counts_y: Returns the token counts for the Y' plane. - _token_counts_c: Returns the token counts for the Cb and Cr planes.*/ -static void oc_enc_count_tokens(oc_enc_ctx *_enc,int _zzi_start,int _zzi_end, - ptrdiff_t _token_counts_y[32],ptrdiff_t _token_counts_c[32]){ - const unsigned char *dct_tokens; - ptrdiff_t ndct_tokens; - int pli; - int zzi; - ptrdiff_t ti; - memset(_token_counts_y,0,32*sizeof(*_token_counts_y)); - memset(_token_counts_c,0,32*sizeof(*_token_counts_c)); - for(zzi=_zzi_start;zzi<_zzi_end;zzi++){ - dct_tokens=_enc->dct_tokens[0][zzi]; - ndct_tokens=_enc->ndct_tokens[0][zzi]; - for(ti=_enc->dct_token_offs[0][zzi];tidct_tokens[pli][zzi]; - ndct_tokens=_enc->ndct_tokens[pli][zzi]; - for(ti=_enc->dct_token_offs[pli][zzi];tihuff_codes[huffi+huff_offs][token].nbits; - } - } -} - -/*Returns the Huffman index using the fewest number of bits.*/ -static int oc_select_huff_idx(size_t _bit_counts[16]){ - int best_huffi; - int huffi; - best_huffi=0; - for(huffi=1;huffi<16;huffi++)if(_bit_counts[huffi]<_bit_counts[best_huffi]){ - best_huffi=huffi; - } - return best_huffi; -} - -static void oc_enc_huff_group_pack(oc_enc_ctx *_enc, - int _zzi_start,int _zzi_end,const int _huff_idxs[2]){ - int zzi; - for(zzi=_zzi_start;zzi<_zzi_end;zzi++){ - int pli; - for(pli=0;pli<3;pli++){ - const unsigned char *dct_tokens; - const ogg_uint16_t *extra_bits; - ptrdiff_t ndct_tokens; - const th_huff_code *huff_codes; - ptrdiff_t ti; - dct_tokens=_enc->dct_tokens[pli][zzi]; - extra_bits=_enc->extra_bits[pli][zzi]; - ndct_tokens=_enc->ndct_tokens[pli][zzi]; - huff_codes=_enc->huff_codes[_huff_idxs[pli+1>>1]]; - for(ti=_enc->dct_token_offs[pli][zzi];tiopb,huff_codes[token].pattern, - huff_codes[token].nbits); - neb=OC_DCT_TOKEN_EXTRA_BITS[token]; - if(neb)oggpackB_write(&_enc->opb,extra_bits[ti],neb); - } - } - } -} - -static void oc_enc_residual_tokens_pack(oc_enc_ctx *_enc){ - static const unsigned char OC_HUFF_GROUP_MIN[6]={0,1,6,15,28,64}; - static const unsigned char *OC_HUFF_GROUP_MAX=OC_HUFF_GROUP_MIN+1; - ptrdiff_t token_counts_y[32]; - ptrdiff_t token_counts_c[32]; - size_t bits_y[16]; - size_t bits_c[16]; - int huff_idxs[2]; - int frame_type; - int hgi; - frame_type=_enc->state.frame_type; - /*Choose which Huffman tables to use for the DC token list.*/ - oc_enc_count_tokens(_enc,0,1,token_counts_y,token_counts_c); - memset(bits_y,0,sizeof(bits_y)); - memset(bits_c,0,sizeof(bits_c)); - oc_enc_count_bits(_enc,0,token_counts_y,bits_y); - oc_enc_count_bits(_enc,0,token_counts_c,bits_c); - huff_idxs[0]=oc_select_huff_idx(bits_y); - huff_idxs[1]=oc_select_huff_idx(bits_c); - /*Write the DC token list with the chosen tables.*/ - oggpackB_write(&_enc->opb,huff_idxs[0],4); - oggpackB_write(&_enc->opb,huff_idxs[1],4); - _enc->huff_idxs[frame_type][0][0]=(unsigned char)huff_idxs[0]; - _enc->huff_idxs[frame_type][0][1]=(unsigned char)huff_idxs[1]; - oc_enc_huff_group_pack(_enc,0,1,huff_idxs); - /*Choose which Huffman tables to use for the AC token lists.*/ - memset(bits_y,0,sizeof(bits_y)); - memset(bits_c,0,sizeof(bits_c)); - for(hgi=1;hgi<5;hgi++){ - oc_enc_count_tokens(_enc,OC_HUFF_GROUP_MIN[hgi],OC_HUFF_GROUP_MAX[hgi], - token_counts_y,token_counts_c); - oc_enc_count_bits(_enc,hgi,token_counts_y,bits_y); - oc_enc_count_bits(_enc,hgi,token_counts_c,bits_c); - } - huff_idxs[0]=oc_select_huff_idx(bits_y); - huff_idxs[1]=oc_select_huff_idx(bits_c); - /*Write the AC token lists using the chosen tables.*/ - oggpackB_write(&_enc->opb,huff_idxs[0],4); - oggpackB_write(&_enc->opb,huff_idxs[1],4); - _enc->huff_idxs[frame_type][1][0]=(unsigned char)huff_idxs[0]; - _enc->huff_idxs[frame_type][1][1]=(unsigned char)huff_idxs[1]; - for(hgi=1;hgi<5;hgi++){ - huff_idxs[0]+=16; - huff_idxs[1]+=16; - oc_enc_huff_group_pack(_enc, - OC_HUFF_GROUP_MIN[hgi],OC_HUFF_GROUP_MAX[hgi],huff_idxs); - } -} - -static void oc_enc_frame_pack(oc_enc_ctx *_enc){ - oggpackB_reset(&_enc->opb); - /*Only proceed if we have some coded blocks. - If there are no coded blocks, we can drop this frame simply by emitting a - 0 byte packet.*/ - if(_enc->state.ntotal_coded_fragis>0){ - oc_enc_frame_header_pack(_enc); - if(_enc->state.frame_type==OC_INTER_FRAME){ - /*Coded block flags, MB modes, and MVs are only needed for delta frames.*/ - oc_enc_coded_flags_pack(_enc); - oc_enc_mb_modes_pack(_enc); - oc_enc_mvs_pack(_enc); - } - oc_enc_block_qis_pack(_enc); - oc_enc_tokenize_finish(_enc); - oc_enc_residual_tokens_pack(_enc); - } - /*Success: Mark the packet as ready to be flushed.*/ - _enc->packet_state=OC_PACKET_READY; -#if defined(OC_COLLECT_METRICS) - oc_enc_mode_metrics_collect(_enc); -#endif -} - - -void oc_enc_vtable_init_c(oc_enc_ctx *_enc){ - /*The implementations prefixed with oc_enc_ are encoder-specific. - The rest we re-use from the decoder.*/ - _enc->opt_vtable.frag_sad=oc_enc_frag_sad_c; - _enc->opt_vtable.frag_sad_thresh=oc_enc_frag_sad_thresh_c; - _enc->opt_vtable.frag_sad2_thresh=oc_enc_frag_sad2_thresh_c; - _enc->opt_vtable.frag_satd_thresh=oc_enc_frag_satd_thresh_c; - _enc->opt_vtable.frag_satd2_thresh=oc_enc_frag_satd2_thresh_c; - _enc->opt_vtable.frag_intra_satd=oc_enc_frag_intra_satd_c; - _enc->opt_vtable.frag_sub=oc_enc_frag_sub_c; - _enc->opt_vtable.frag_sub_128=oc_enc_frag_sub_128_c; - _enc->opt_vtable.frag_copy2=oc_enc_frag_copy2_c; - _enc->opt_vtable.frag_recon_intra=oc_frag_recon_intra_c; - _enc->opt_vtable.frag_recon_inter=oc_frag_recon_inter_c; - _enc->opt_vtable.fdct8x8=oc_enc_fdct8x8_c; -} - -/*Initialize the macro block neighbor lists for MC analysis. - This assumes that the entire mb_info memory region has been initialized with - zeros.*/ -static void oc_enc_mb_info_init(oc_enc_ctx *_enc){ - oc_mb_enc_info *embs; - const signed char *mb_modes; - unsigned nhsbs; - unsigned nvsbs; - unsigned nhmbs; - unsigned nvmbs; - unsigned sby; - mb_modes=_enc->state.mb_modes; - embs=_enc->mb_info; - nhsbs=_enc->state.fplanes[0].nhsbs; - nvsbs=_enc->state.fplanes[0].nvsbs; - nhmbs=_enc->state.nhmbs; - nvmbs=_enc->state.nvmbs; - for(sby=0;sby>1); - mby=2*sby+(quadi+1>>1&1); - /*Fill in the neighbors with current motion vectors available.*/ - for(ni=0;ni=nhmbs||nmby<0||nmby>=nvmbs)continue; - nmbi=(nmby&~1)*nhmbs+((nmbx&~1)<<1)+OC_MB_MAP[nmby&1][nmbx&1]; - if(mb_modes[nmbi]==OC_MODE_INVALID)continue; - embs[mbi].cneighbors[embs[mbi].ncneighbors++]=nmbi; - } - /*Fill in the neighbors with previous motion vectors available.*/ - for(ni=0;ni<4;ni++){ - nmbx=mbx+PDX[ni]; - nmby=mby+PDY[ni]; - if(nmbx<0||nmbx>=nhmbs||nmby<0||nmby>=nvmbs)continue; - nmbi=(nmby&~1)*nhmbs+((nmbx&~1)<<1)+OC_MB_MAP[nmby&1][nmbx&1]; - if(mb_modes[nmbi]==OC_MODE_INVALID)continue; - embs[mbi].pneighbors[embs[mbi].npneighbors++]=nmbi; - } - } - } - } -} - -static int oc_enc_set_huffman_codes(oc_enc_ctx *_enc, - const th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]){ - int ret; - if(_enc==NULL)return TH_EFAULT; - if(_enc->packet_state>OC_PACKET_SETUP_HDR)return TH_EINVAL; - if(_codes==NULL)_codes=TH_VP31_HUFF_CODES; - /*Validate the codes.*/ - oggpackB_reset(&_enc->opb); - ret=oc_huff_codes_pack(&_enc->opb,_codes); - if(ret<0)return ret; - memcpy(_enc->huff_codes,_codes,sizeof(_enc->huff_codes)); - return 0; -} - -/*Sets the quantization parameters to use. - This may only be called before the setup header is written. - If it is called multiple times, only the last call has any effect. - _qinfo: The quantization parameters. - These are described in more detail in theoraenc.h. - This can be NULL, in which case the default quantization parameters - will be used.*/ -static int oc_enc_set_quant_params(oc_enc_ctx *_enc, - const th_quant_info *_qinfo){ - int qi; - int pli; - int qti; - if(_enc==NULL)return TH_EFAULT; - if(_enc->packet_state>OC_PACKET_SETUP_HDR)return TH_EINVAL; - if(_qinfo==NULL)_qinfo=&TH_DEF_QUANT_INFO; - /*TODO: Analyze for packing purposes instead of just doing a shallow copy.*/ - memcpy(&_enc->qinfo,_qinfo,sizeof(_enc->qinfo)); - for(qi=0;qi<64;qi++)for(pli=0;pli<3;pli++)for(qti=0;qti<2;qti++){ - _enc->state.dequant_tables[qi][pli][qti]= - _enc->state.dequant_table_data[qi][pli][qti]; - _enc->enquant_tables[qi][pli][qti]=_enc->enquant_table_data[qi][pli][qti]; - } - oc_enquant_tables_init(_enc->state.dequant_tables, - _enc->enquant_tables,_qinfo); - memcpy(_enc->state.loop_filter_limits,_qinfo->loop_filter_limits, - sizeof(_enc->state.loop_filter_limits)); - oc_enquant_qavg_init(_enc->log_qavg,_enc->state.dequant_tables, - _enc->state.info.pixel_fmt); - return 0; -} - -static void oc_enc_clear(oc_enc_ctx *_enc); - -static int oc_enc_init(oc_enc_ctx *_enc,const th_info *_info){ - th_info info; - size_t mcu_nmbs; - ptrdiff_t mcu_nfrags; - int hdec; - int vdec; - int ret; - int pli; - /*Clean up the requested settings.*/ - memcpy(&info,_info,sizeof(info)); - info.version_major=TH_VERSION_MAJOR; - info.version_minor=TH_VERSION_MINOR; - info.version_subminor=TH_VERSION_SUB; - if(info.quality>63)info.quality=63; - if(info.quality<0)info.quality=32; - if(info.target_bitrate<0)info.target_bitrate=0; - /*Initialize the shared encoder/decoder state.*/ - ret=oc_state_init(&_enc->state,&info,4); - if(ret<0)return ret; - _enc->mb_info=_ogg_calloc(_enc->state.nmbs,sizeof(*_enc->mb_info)); - _enc->frag_dc=_ogg_calloc(_enc->state.nfrags,sizeof(*_enc->frag_dc)); - _enc->coded_mbis= - (unsigned *)_ogg_malloc(_enc->state.nmbs*sizeof(*_enc->coded_mbis)); - hdec=!(_enc->state.info.pixel_fmt&1); - vdec=!(_enc->state.info.pixel_fmt&2); - /*If chroma is sub-sampled in the vertical direction, we have to encode two - super block rows of Y' for each super block row of Cb and Cr.*/ - _enc->mcu_nvsbs=1<mcu_nvsbs*_enc->state.fplanes[0].nhsbs*(size_t)4; - mcu_nfrags=4*mcu_nmbs+(8*mcu_nmbs>>hdec+vdec); - _enc->mcu_skip_ssd=(unsigned *)_ogg_malloc( - mcu_nfrags*sizeof(*_enc->mcu_skip_ssd)); - for(pli=0;pli<3;pli++){ - _enc->dct_tokens[pli]=(unsigned char **)oc_malloc_2d(64, - _enc->state.fplanes[pli].nfrags,sizeof(**_enc->dct_tokens)); - _enc->extra_bits[pli]=(ogg_uint16_t **)oc_malloc_2d(64, - _enc->state.fplanes[pli].nfrags,sizeof(**_enc->extra_bits)); - } -#if defined(OC_COLLECT_METRICS) - _enc->frag_satd=_ogg_calloc(_enc->state.nfrags,sizeof(*_enc->frag_satd)); - _enc->frag_ssd=_ogg_calloc(_enc->state.nfrags,sizeof(*_enc->frag_ssd)); -#endif -#if defined(OC_X86_ASM) - oc_enc_vtable_init_x86(_enc); -#else - oc_enc_vtable_init_c(_enc); -#endif - _enc->keyframe_frequency_force=1<<_enc->state.info.keyframe_granule_shift; - _enc->state.qis[0]=_enc->state.info.quality; - _enc->state.nqis=1; - oc_rc_state_init(&_enc->rc,_enc); - oggpackB_writeinit(&_enc->opb); - if(_enc->mb_info==NULL||_enc->frag_dc==NULL||_enc->coded_mbis==NULL|| - _enc->mcu_skip_ssd==NULL||_enc->dct_tokens[0]==NULL|| - _enc->dct_tokens[1]==NULL||_enc->dct_tokens[2]==NULL|| - _enc->extra_bits[0]==NULL||_enc->extra_bits[1]==NULL|| - _enc->extra_bits[2]==NULL -#if defined(OC_COLLECT_METRICS) - ||_enc->frag_satd==NULL||_enc->frag_ssd==NULL -#endif - ){ - oc_enc_clear(_enc); - return TH_EFAULT; - } - oc_mode_scheme_chooser_init(&_enc->chooser); - oc_enc_mb_info_init(_enc); - memset(_enc->huff_idxs,0,sizeof(_enc->huff_idxs)); - /*Reset the packet-out state machine.*/ - _enc->packet_state=OC_PACKET_INFO_HDR; - _enc->dup_count=0; - _enc->nqueued_dups=0; - _enc->prev_dup_count=0; - /*Enable speed optimizations up through early skip by default.*/ - _enc->sp_level=OC_SP_LEVEL_EARLY_SKIP; - /*Disable VP3 compatibility by default.*/ - _enc->vp3_compatible=0; - /*No INTER frames coded yet.*/ - _enc->coded_inter_frame=0; - memcpy(_enc->huff_codes,TH_VP31_HUFF_CODES,sizeof(_enc->huff_codes)); - oc_enc_set_quant_params(_enc,NULL); - return 0; -} - -static void oc_enc_clear(oc_enc_ctx *_enc){ - int pli; - oc_rc_state_clear(&_enc->rc); -#if defined(OC_COLLECT_METRICS) - oc_enc_mode_metrics_dump(_enc); -#endif - oggpackB_writeclear(&_enc->opb); -#if defined(OC_COLLECT_METRICS) - _ogg_free(_enc->frag_ssd); - _ogg_free(_enc->frag_satd); -#endif - for(pli=3;pli-->0;){ - oc_free_2d(_enc->extra_bits[pli]); - oc_free_2d(_enc->dct_tokens[pli]); - } - _ogg_free(_enc->mcu_skip_ssd); - _ogg_free(_enc->coded_mbis); - _ogg_free(_enc->frag_dc); - _ogg_free(_enc->mb_info); - oc_state_clear(&_enc->state); -} - -static void oc_enc_drop_frame(th_enc_ctx *_enc){ - /*Use the previous frame's reconstruction.*/ - _enc->state.ref_frame_idx[OC_FRAME_SELF]= - _enc->state.ref_frame_idx[OC_FRAME_PREV]; - /*Flag motion vector analysis about the frame drop.*/ - _enc->prevframe_dropped=1; - /*Zero the packet.*/ - oggpackB_reset(&_enc->opb); -} - -static void oc_enc_compress_keyframe(oc_enc_ctx *_enc,int _recode){ - if(_enc->state.info.target_bitrate>0){ - _enc->state.qis[0]=oc_enc_select_qi(_enc,OC_INTRA_FRAME, - _enc->state.curframe_num>0); - _enc->state.nqis=1; - } - oc_enc_calc_lambda(_enc,OC_INTRA_FRAME); - oc_enc_analyze_intra(_enc,_recode); - oc_enc_frame_pack(_enc); - /*On the first frame, the previous call was an initial dry-run to prime - feed-forward statistics.*/ - if(!_recode&&_enc->state.curframe_num==0){ - if(_enc->state.info.target_bitrate>0){ - oc_enc_update_rc_state(_enc,oggpackB_bytes(&_enc->opb)<<3, - OC_INTRA_FRAME,_enc->state.qis[0],1,0); - } - oc_enc_compress_keyframe(_enc,1); - } -} - -static void oc_enc_compress_frame(oc_enc_ctx *_enc,int _recode){ - if(_enc->state.info.target_bitrate>0){ - _enc->state.qis[0]=oc_enc_select_qi(_enc,OC_INTER_FRAME,1); - _enc->state.nqis=1; - } - oc_enc_calc_lambda(_enc,OC_INTER_FRAME); - if(oc_enc_analyze_inter(_enc,_enc->rc.twopass!=2,_recode)){ - /*Mode analysis thinks this should have been a keyframe; start over.*/ - oc_enc_compress_keyframe(_enc,1); - } - else{ - oc_enc_frame_pack(_enc); - if(!_enc->coded_inter_frame){ - /*On the first INTER frame, the previous call was an initial dry-run to - prime feed-forward statistics.*/ - _enc->coded_inter_frame=1; - if(_enc->state.info.target_bitrate>0){ - /*Rate control also needs to prime.*/ - oc_enc_update_rc_state(_enc,oggpackB_bytes(&_enc->opb)<<3, - OC_INTER_FRAME,_enc->state.qis[0],1,0); - } - oc_enc_compress_frame(_enc,1); - } - } -} - -/*Set the granule position for the next packet to output based on the current - internal state.*/ -static void oc_enc_set_granpos(oc_enc_ctx *_enc){ - unsigned dup_offs; - /*Add an offset for the number of duplicate frames we've emitted so far.*/ - dup_offs=_enc->prev_dup_count-_enc->nqueued_dups; - /*If the current frame was a keyframe, use it for the high part.*/ - if(_enc->state.frame_type==OC_INTRA_FRAME){ - _enc->state.granpos=(_enc->state.curframe_num+_enc->state.granpos_bias<< - _enc->state.info.keyframe_granule_shift)+dup_offs; - } - /*Otherwise use the last keyframe in the high part and put the current frame - in the low part.*/ - else{ - _enc->state.granpos= - (_enc->state.keyframe_num+_enc->state.granpos_bias<< - _enc->state.info.keyframe_granule_shift) - +_enc->state.curframe_num-_enc->state.keyframe_num+dup_offs; - } -} - - -th_enc_ctx *th_encode_alloc(const th_info *_info){ - oc_enc_ctx *enc; - if(_info==NULL)return NULL; - enc=_ogg_malloc(sizeof(*enc)); - if(enc==NULL||oc_enc_init(enc,_info)<0){ - _ogg_free(enc); - return NULL; - } - return enc; -} - -void th_encode_free(th_enc_ctx *_enc){ - if(_enc!=NULL){ - oc_enc_clear(_enc); - _ogg_free(_enc); - } -} - -int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz){ - switch(_req){ - case TH_ENCCTL_SET_HUFFMAN_CODES:{ - if(_buf==NULL&&_buf_sz!=0|| - _buf!=NULL&&_buf_sz!=sizeof(th_huff_table)*TH_NHUFFMAN_TABLES){ - return TH_EINVAL; - } - return oc_enc_set_huffman_codes(_enc,(const th_huff_table *)_buf); - }break; - case TH_ENCCTL_SET_QUANT_PARAMS:{ - if(_buf==NULL&&_buf_sz!=0|| - _buf!=NULL&&_buf_sz!=sizeof(th_quant_info)){ - return TH_EINVAL; - } - return oc_enc_set_quant_params(_enc,(th_quant_info *)_buf); - }break; - case TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE:{ - ogg_uint32_t keyframe_frequency_force; - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(keyframe_frequency_force))return TH_EINVAL; - keyframe_frequency_force=*(ogg_uint32_t *)_buf; - if(keyframe_frequency_force<=0)keyframe_frequency_force=1; - if(_enc->packet_state==OC_PACKET_INFO_HDR){ - /*It's still early enough to enlarge keyframe_granule_shift.*/ - _enc->state.info.keyframe_granule_shift=OC_CLAMPI( - _enc->state.info.keyframe_granule_shift, - OC_ILOG_32(keyframe_frequency_force-1),31); - } - _enc->keyframe_frequency_force=OC_MINI(keyframe_frequency_force, - (ogg_uint32_t)1U<<_enc->state.info.keyframe_granule_shift); - *(ogg_uint32_t *)_buf=_enc->keyframe_frequency_force; - return 0; - }break; - case TH_ENCCTL_SET_VP3_COMPATIBLE:{ - int vp3_compatible; - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(vp3_compatible))return TH_EINVAL; - vp3_compatible=*(int *)_buf; - _enc->vp3_compatible=vp3_compatible; - if(oc_enc_set_huffman_codes(_enc,TH_VP31_HUFF_CODES)<0)vp3_compatible=0; - if(oc_enc_set_quant_params(_enc,&TH_VP31_QUANT_INFO)<0)vp3_compatible=0; - if(_enc->state.info.pixel_fmt!=TH_PF_420|| - _enc->state.info.pic_width<_enc->state.info.frame_width|| - _enc->state.info.pic_height<_enc->state.info.frame_height|| - /*If we have more than 4095 super blocks, VP3's RLE coding might - overflow. - We could overcome this by ensuring we flip the coded/not-coded flags on - at least one super block in the frame, but we pick the simple solution - of just telling the user the stream will be incompatible instead. - It's unlikely the old VP3 codec would be able to decode streams at this - resolution in real time in the first place.*/ - _enc->state.nsbs>4095){ - vp3_compatible=0; - } - *(int *)_buf=vp3_compatible; - return 0; - }break; - case TH_ENCCTL_GET_SPLEVEL_MAX:{ - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(int))return TH_EINVAL; - *(int *)_buf=OC_SP_LEVEL_MAX; - return 0; - }break; - case TH_ENCCTL_SET_SPLEVEL:{ - int speed; - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(speed))return TH_EINVAL; - speed=*(int *)_buf; - if(speed<0||speed>OC_SP_LEVEL_MAX)return TH_EINVAL; - _enc->sp_level=speed; - return 0; - }break; - case TH_ENCCTL_GET_SPLEVEL:{ - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(int))return TH_EINVAL; - *(int *)_buf=_enc->sp_level; - return 0; - } - case TH_ENCCTL_SET_DUP_COUNT:{ - int dup_count; - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(dup_count))return TH_EINVAL; - dup_count=*(int *)_buf; - if(dup_count>=_enc->keyframe_frequency_force)return TH_EINVAL; - _enc->dup_count=OC_MAXI(dup_count,0); - return 0; - }break; - case TH_ENCCTL_SET_QUALITY:{ - int qi; - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_enc->state.info.target_bitrate>0)return TH_EINVAL; - qi=*(int *)_buf; - if(qi<0||qi>63)return TH_EINVAL; - _enc->state.info.quality=qi; - _enc->state.qis[0]=(unsigned char)qi; - _enc->state.nqis=1; - return 0; - }break; - case TH_ENCCTL_SET_BITRATE:{ - long bitrate; - int reset; - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - bitrate=*(long *)_buf; - if(bitrate<=0)return TH_EINVAL; - reset=_enc->state.info.target_bitrate<=0; - _enc->state.info.target_bitrate=bitrate>INT_MAX?INT_MAX:bitrate; - if(reset)oc_rc_state_init(&_enc->rc,_enc); - else oc_enc_rc_resize(_enc); - return 0; - }break; - case TH_ENCCTL_SET_RATE_FLAGS:{ - int set; - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(set))return TH_EINVAL; - if(_enc->state.info.target_bitrate<=0)return TH_EINVAL; - set=*(int *)_buf; - _enc->rc.drop_frames=set&TH_RATECTL_DROP_FRAMES; - _enc->rc.cap_overflow=set&TH_RATECTL_CAP_OVERFLOW; - _enc->rc.cap_underflow=set&TH_RATECTL_CAP_UNDERFLOW; - return 0; - }break; - case TH_ENCCTL_SET_RATE_BUFFER:{ - int set; - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_buf_sz!=sizeof(set))return TH_EINVAL; - if(_enc->state.info.target_bitrate<=0)return TH_EINVAL; - set=*(int *)_buf; - _enc->rc.buf_delay=set; - oc_enc_rc_resize(_enc); - *(int *)_buf=_enc->rc.buf_delay; - return 0; - }break; - case TH_ENCCTL_2PASS_OUT:{ - if(_enc==NULL||_buf==NULL)return TH_EFAULT; - if(_enc->state.info.target_bitrate<=0|| - _enc->state.curframe_num>=0&&_enc->rc.twopass!=1|| - _buf_sz!=sizeof(unsigned char *)){ - return TH_EINVAL; - } - return oc_enc_rc_2pass_out(_enc,(unsigned char **)_buf); - }break; - case TH_ENCCTL_2PASS_IN:{ - if(_enc==NULL)return TH_EFAULT; - if(_enc->state.info.target_bitrate<=0|| - _enc->state.curframe_num>=0&&_enc->rc.twopass!=2){ - return TH_EINVAL; - } - return oc_enc_rc_2pass_in(_enc,_buf,_buf_sz); - }break; - default:return TH_EIMPL; - } -} - -int th_encode_flushheader(th_enc_ctx *_enc,th_comment *_tc,ogg_packet *_op){ - if(_enc==NULL)return TH_EFAULT; - return oc_state_flushheader(&_enc->state,&_enc->packet_state,&_enc->opb, - &_enc->qinfo,(const th_huff_table *)_enc->huff_codes,th_version_string(), - _tc,_op); -} - -static void oc_img_plane_copy_pad(th_img_plane *_dst,th_img_plane *_src, - ogg_int32_t _pic_x,ogg_int32_t _pic_y, - ogg_int32_t _pic_width,ogg_int32_t _pic_height){ - unsigned char *dst; - int dstride; - ogg_uint32_t frame_width; - ogg_uint32_t frame_height; - ogg_uint32_t y; - frame_width=_dst->width; - frame_height=_dst->height; - /*If we have _no_ data, just encode a dull green.*/ - if(_pic_width==0||_pic_height==0){ - dst=_dst->data; - dstride=_dst->stride; - for(y=0;ystride; - sstride=_src->stride; - dst_data=_dst->data; - src_data=_src->data; - dst=dst_data+_pic_y*(ptrdiff_t)dstride+_pic_x; - src=src_data+_pic_y*(ptrdiff_t)sstride+_pic_x; - for(y=0;y<_pic_height;y++){ - memcpy(dst,src,_pic_width); - dst+=dstride; - src+=sstride; - } - /*Step 2: Perform a low-pass extension into the padding region.*/ - /*Left side.*/ - for(x=_pic_x;x-->0;){ - dst=dst_data+_pic_y*(ptrdiff_t)dstride+x; - for(y=0;y<_pic_height;y++){ - dst[0]=(dst[1]<<1)+(dst-(dstride&-(y>0)))[1] - +(dst+(dstride&-(y+1<_pic_height)))[1]+2>>2; - dst+=dstride; - } - } - /*Right side.*/ - for(x=_pic_x+_pic_width;x0)))[0] - +(dst+(dstride&-(y+1<_pic_height)))[0]+2>>2; - dst+=dstride; - } - } - /*Top.*/ - dst=dst_data+_pic_y*(ptrdiff_t)dstride; - for(y=_pic_y;y-->0;){ - for(x=0;x0)] - +dst[x+(x+1>2; - } - dst-=dstride; - } - /*Bottom.*/ - dst=dst_data+(_pic_y+_pic_height)*(ptrdiff_t)dstride; - for(y=_pic_y+_pic_height;y0)] - +(dst-dstride)[x+(x+1>2; - } - dst+=dstride; - } - } -} - -int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _img){ - th_ycbcr_buffer img; - int cframe_width; - int cframe_height; - int cpic_width; - int cpic_height; - int cpic_x; - int cpic_y; - int hdec; - int vdec; - int pli; - int refi; - int drop; - /*Step 1: validate parameters.*/ - if(_enc==NULL||_img==NULL)return TH_EFAULT; - if(_enc->packet_state==OC_PACKET_DONE)return TH_EINVAL; - if(_enc->rc.twopass&&_enc->rc.twopass_buffer_bytes==0)return TH_EINVAL; - if((ogg_uint32_t)_img[0].width!=_enc->state.info.frame_width|| - (ogg_uint32_t)_img[0].height!=_enc->state.info.frame_height){ - return TH_EINVAL; - } - hdec=!(_enc->state.info.pixel_fmt&1); - vdec=!(_enc->state.info.pixel_fmt&2); - cframe_width=_enc->state.info.frame_width>>hdec; - cframe_height=_enc->state.info.frame_height>>vdec; - if(_img[1].width!=cframe_width||_img[2].width!=cframe_width|| - _img[1].height!=cframe_height||_img[2].height!=cframe_height){ - return TH_EINVAL; - } - /*Step 2: Copy the input to our internal buffer. - This lets us add padding, if necessary, so we don't have to worry about - dereferencing possibly invalid addresses, and allows us to use the same - strides and fragment offsets for both the input frame and the reference - frames.*/ - /*Flip the input buffer upside down.*/ - oc_ycbcr_buffer_flip(img,_img); - oc_img_plane_copy_pad(_enc->state.ref_frame_bufs[OC_FRAME_IO]+0,img+0, - _enc->state.info.pic_x,_enc->state.info.pic_y, - _enc->state.info.pic_width,_enc->state.info.pic_height); - cpic_x=_enc->state.info.pic_x>>hdec; - cpic_y=_enc->state.info.pic_y>>vdec; - cpic_width=(_enc->state.info.pic_x+_enc->state.info.pic_width+hdec>>hdec) - -cpic_x; - cpic_height=(_enc->state.info.pic_y+_enc->state.info.pic_height+vdec>>vdec) - -cpic_y; - for(pli=1;pli<3;pli++){ - oc_img_plane_copy_pad(_enc->state.ref_frame_bufs[OC_FRAME_IO]+pli,img+pli, - cpic_x,cpic_y,cpic_width,cpic_height); - } - /*Step 3: Update the buffer state.*/ - if(_enc->state.ref_frame_idx[OC_FRAME_SELF]>=0){ - _enc->state.ref_frame_idx[OC_FRAME_PREV]= - _enc->state.ref_frame_idx[OC_FRAME_SELF]; - if(_enc->state.frame_type==OC_INTRA_FRAME){ - /*The new frame becomes both the previous and gold reference frames.*/ - _enc->state.keyframe_num=_enc->state.curframe_num; - _enc->state.ref_frame_idx[OC_FRAME_GOLD]= - _enc->state.ref_frame_idx[OC_FRAME_SELF]; - } - } - /*Select a free buffer to use for the reconstructed version of this frame.*/ - for(refi=0;refi==_enc->state.ref_frame_idx[OC_FRAME_GOLD]|| - refi==_enc->state.ref_frame_idx[OC_FRAME_PREV];refi++); - _enc->state.ref_frame_idx[OC_FRAME_SELF]=refi; - _enc->state.curframe_num+=_enc->prev_dup_count+1; - /*Step 4: Compress the frame.*/ - /*Start with a keyframe, and don't allow the generation of invalid files that - overflow the keyframe_granule_shift.*/ - if(_enc->rc.twopass_force_kf||_enc->state.curframe_num==0|| - _enc->state.curframe_num-_enc->state.keyframe_num+_enc->dup_count>= - _enc->keyframe_frequency_force){ - oc_enc_compress_keyframe(_enc,0); - drop=0; - } - else{ - oc_enc_compress_frame(_enc,0); - drop=1; - } - oc_restore_fpu(&_enc->state); - /*drop currently indicates if the frame is droppable.*/ - if(_enc->state.info.target_bitrate>0){ - drop=oc_enc_update_rc_state(_enc,oggpackB_bytes(&_enc->opb)<<3, - _enc->state.frame_type,_enc->state.qis[0],0,drop); - } - else drop=0; - /*drop now indicates if the frame was dropped.*/ - if(drop)oc_enc_drop_frame(_enc); - else _enc->prevframe_dropped=0; - _enc->packet_state=OC_PACKET_READY; - _enc->prev_dup_count=_enc->nqueued_dups=_enc->dup_count; - _enc->dup_count=0; -#if defined(OC_DUMP_IMAGES) - oc_enc_set_granpos(_enc); - oc_state_dump_frame(&_enc->state,OC_FRAME_IO,"src"); - oc_state_dump_frame(&_enc->state,OC_FRAME_SELF,"rec"); -#endif - return 0; -} - -int th_encode_packetout(th_enc_ctx *_enc,int _last_p,ogg_packet *_op){ - if(_enc==NULL||_op==NULL)return TH_EFAULT; - if(_enc->packet_state==OC_PACKET_READY){ - _enc->packet_state=OC_PACKET_EMPTY; - if(_enc->rc.twopass!=1){ - unsigned char *packet; - packet=oggpackB_get_buffer(&_enc->opb); - /*If there's no packet, malloc failed while writing; it's lost forever.*/ - if(packet==NULL)return TH_EFAULT; - _op->packet=packet; - _op->bytes=oggpackB_bytes(&_enc->opb); - } - /*For the first pass in 2-pass mode, don't emit any packet data.*/ - else{ - _op->packet=NULL; - _op->bytes=0; - } - } - else if(_enc->packet_state==OC_PACKET_EMPTY){ - if(_enc->nqueued_dups>0){ - _enc->nqueued_dups--; - _op->packet=NULL; - _op->bytes=0; - } - else{ - if(_last_p)_enc->packet_state=OC_PACKET_DONE; - return 0; - } - } - else return 0; - _last_p=_last_p&&_enc->nqueued_dups<=0; - _op->b_o_s=0; - _op->e_o_s=_last_p; - oc_enc_set_granpos(_enc); - _op->packetno=th_granule_frame(_enc,_enc->state.granpos)+3; - _op->granulepos=_enc->state.granpos; - if(_last_p)_enc->packet_state=OC_PACKET_DONE; - return 1+_enc->nqueued_dups; -} diff --git a/Engine/lib/libtheora/lib/enquant.c b/Engine/lib/libtheora/lib/enquant.c deleted file mode 100644 index 3372fed22..000000000 --- a/Engine/lib/libtheora/lib/enquant.c +++ /dev/null @@ -1,274 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: enquant.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#include -#include -#include "encint.h" - - - -void oc_quant_params_pack(oggpack_buffer *_opb,const th_quant_info *_qinfo){ - const th_quant_ranges *qranges; - const th_quant_base *base_mats[2*3*64]; - int indices[2][3][64]; - int nbase_mats; - int nbits; - int ci; - int qi; - int qri; - int qti; - int pli; - int qtj; - int plj; - int bmi; - int i; - i=_qinfo->loop_filter_limits[0]; - for(qi=1;qi<64;qi++)i=OC_MAXI(i,_qinfo->loop_filter_limits[qi]); - nbits=OC_ILOG_32(i); - oggpackB_write(_opb,nbits,3); - for(qi=0;qi<64;qi++){ - oggpackB_write(_opb,_qinfo->loop_filter_limits[qi],nbits); - } - /*580 bits for VP3.*/ - i=1; - for(qi=0;qi<64;qi++)i=OC_MAXI(_qinfo->ac_scale[qi],i); - nbits=OC_ILOGNZ_32(i); - oggpackB_write(_opb,nbits-1,4); - for(qi=0;qi<64;qi++)oggpackB_write(_opb,_qinfo->ac_scale[qi],nbits); - /*516 bits for VP3.*/ - i=1; - for(qi=0;qi<64;qi++)i=OC_MAXI(_qinfo->dc_scale[qi],i); - nbits=OC_ILOGNZ_32(i); - oggpackB_write(_opb,nbits-1,4); - for(qi=0;qi<64;qi++)oggpackB_write(_opb,_qinfo->dc_scale[qi],nbits); - /*Consolidate any duplicate base matrices.*/ - nbase_mats=0; - for(qti=0;qti<2;qti++)for(pli=0;pli<3;pli++){ - qranges=_qinfo->qi_ranges[qti]+pli; - for(qri=0;qri<=qranges->nranges;qri++){ - for(bmi=0;;bmi++){ - if(bmi>=nbase_mats){ - base_mats[bmi]=qranges->base_matrices+qri; - indices[qti][pli][qri]=nbase_mats++; - break; - } - else if(memcmp(base_mats[bmi][0],qranges->base_matrices[qri], - sizeof(base_mats[bmi][0]))==0){ - indices[qti][pli][qri]=bmi; - break; - } - } - } - } - /*Write out the list of unique base matrices. - 1545 bits for VP3 matrices.*/ - oggpackB_write(_opb,nbase_mats-1,9); - for(bmi=0;bmiqi_ranges[qti]+pli; - if(i>0){ - if(qti>0){ - if(qranges->nranges==_qinfo->qi_ranges[qti-1][pli].nranges&& - memcmp(qranges->sizes,_qinfo->qi_ranges[qti-1][pli].sizes, - qranges->nranges*sizeof(qranges->sizes[0]))==0&& - memcmp(indices[qti][pli],indices[qti-1][pli], - (qranges->nranges+1)*sizeof(indices[qti][pli][0]))==0){ - oggpackB_write(_opb,1,2); - continue; - } - } - qtj=(i-1)/3; - plj=(i-1)%3; - if(qranges->nranges==_qinfo->qi_ranges[qtj][plj].nranges&& - memcmp(qranges->sizes,_qinfo->qi_ranges[qtj][plj].sizes, - qranges->nranges*sizeof(qranges->sizes[0]))==0&& - memcmp(indices[qti][pli],indices[qtj][plj], - (qranges->nranges+1)*sizeof(indices[qti][pli][0]))==0){ - oggpackB_write(_opb,0,1+(qti>0)); - continue; - } - oggpackB_write(_opb,1,1); - } - oggpackB_write(_opb,indices[qti][pli][0],nbits); - for(qi=qri=0;qi<63;qri++){ - oggpackB_write(_opb,qranges->sizes[qri]-1,OC_ILOG_32(62-qi)); - qi+=qranges->sizes[qri]; - oggpackB_write(_opb,indices[qti][pli][qri+1],nbits); - } - } -} - -static void oc_iquant_init(oc_iquant *_this,ogg_uint16_t _d){ - ogg_uint32_t t; - int l; - _d<<=1; - l=OC_ILOGNZ_32(_d)-1; - t=1+((ogg_uint32_t)1<<16+l)/_d; - _this->m=(ogg_int16_t)(t-0x10000); - _this->l=l; -} - -/*See comments at oc_dequant_tables_init() for how the quantization tables' - storage should be initialized.*/ -void oc_enquant_tables_init(ogg_uint16_t *_dequant[64][3][2], - oc_iquant *_enquant[64][3][2],const th_quant_info *_qinfo){ - int qi; - int pli; - int qti; - /*Initialize the dequantization tables first.*/ - oc_dequant_tables_init(_dequant,NULL,_qinfo); - /*Derive the quantization tables directly from the dequantization tables.*/ - for(qi=0;qi<64;qi++)for(qti=0;qti<2;qti++)for(pli=0;pli<3;pli++){ - int zzi; - int plj; - int qtj; - int dupe; - dupe=0; - for(qtj=0;qtj<=qti;qtj++){ - for(plj=0;plj<(qtj>1))/qd; - qp+=rq*(ogg_uint32_t)rq; - } - q2+=OC_PCD[_pixel_fmt][pli]*(ogg_int64_t)qp; - } - /*qavg=1.0/sqrt(q2).*/ - _log_qavg[qti][qi]=OC_Q57(48)-oc_blog64(q2)>>1; - } -} diff --git a/Engine/lib/libtheora/lib/enquant.h b/Engine/lib/libtheora/lib/enquant.h deleted file mode 100644 index d62df10d1..000000000 --- a/Engine/lib/libtheora/lib/enquant.h +++ /dev/null @@ -1,27 +0,0 @@ -#if !defined(_enquant_H) -# define _enquant_H (1) -# include "quant.h" - -typedef struct oc_iquant oc_iquant; - -#define OC_QUANT_MAX_LOG (OC_Q57(OC_STATIC_ILOG_32(OC_QUANT_MAX)-1)) - -/*Used to compute x/d via ((x*m>>16)+x>>l)+(x<0)) - (i.e., one 16x16->16 mul, 2 shifts, and 2 adds). - This is not an approximation; for 16-bit x and d, it is exact.*/ -struct oc_iquant{ - ogg_int16_t m; - ogg_int16_t l; -}; - -typedef oc_iquant oc_iquant_table[64]; - - - -void oc_quant_params_pack(oggpack_buffer *_opb,const th_quant_info *_qinfo); -void oc_enquant_tables_init(ogg_uint16_t *_dequant[64][3][2], - oc_iquant *_enquant[64][3][2],const th_quant_info *_qinfo); -void oc_enquant_qavg_init(ogg_int64_t _log_qavg[2][64], - ogg_uint16_t *_dequant[64][3][2],int _pixel_fmt); - -#endif diff --git a/Engine/lib/libtheora/lib/fdct.c b/Engine/lib/libtheora/lib/fdct.c deleted file mode 100644 index dc3a66f24..000000000 --- a/Engine/lib/libtheora/lib/fdct.c +++ /dev/null @@ -1,422 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: fdct.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#include "encint.h" -#include "dct.h" - - - -/*Performs a forward 8 point Type-II DCT transform. - The output is scaled by a factor of 2 from the orthonormal version of the - transform. - _y: The buffer to store the result in. - Data will be placed the first 8 entries (e.g., in a row of an 8x8 block). - _x: The input coefficients. - Every 8th entry is used (e.g., from a column of an 8x8 block).*/ -static void oc_fdct8(ogg_int16_t _y[8],const ogg_int16_t *_x){ - int t0; - int t1; - int t2; - int t3; - int t4; - int t5; - int t6; - int t7; - int r; - int s; - int u; - int v; - /*Stage 1:*/ - /*0-7 butterfly.*/ - t0=_x[0<<3]+(int)_x[7<<3]; - t7=_x[0<<3]-(int)_x[7<<3]; - /*1-6 butterfly.*/ - t1=_x[1<<3]+(int)_x[6<<3]; - t6=_x[1<<3]-(int)_x[6<<3]; - /*2-5 butterfly.*/ - t2=_x[2<<3]+(int)_x[5<<3]; - t5=_x[2<<3]-(int)_x[5<<3]; - /*3-4 butterfly.*/ - t3=_x[3<<3]+(int)_x[4<<3]; - t4=_x[3<<3]-(int)_x[4<<3]; - /*Stage 2:*/ - /*0-3 butterfly.*/ - r=t0+t3; - t3=t0-t3; - t0=r; - /*1-2 butterfly.*/ - r=t1+t2; - t2=t1-t2; - t1=r; - /*6-5 butterfly.*/ - r=t6+t5; - t5=t6-t5; - t6=r; - /*Stages 3 and 4 are where all the approximation occurs. - These are chosen to be as close to an exact inverse of the approximations - made in the iDCT as possible, while still using mostly 16-bit arithmetic. - We use some 16x16->32 signed MACs, but those still commonly execute in 1 - cycle on a 16-bit DSP. - For example, s=(27146*t5+0x4000>>16)+t5+(t5!=0) is an exact inverse of - t5=(OC_C4S4*s>>16). - That is, applying the latter to the output of the former will recover t5 - exactly (over the valid input range of t5, -23171...23169). - We increase the rounding bias to 0xB500 in this particular case so that - errors inverting the subsequent butterfly are not one-sided (e.g., the - mean error is very close to zero). - The (t5!=0) term could be replaced simply by 1, but we want to send 0 to 0. - The fDCT of an all-zeros block will still not be zero, because of the - biases we added at the very beginning of the process, but it will be close - enough that it is guaranteed to round to zero.*/ - /*Stage 3:*/ - /*4-5 butterfly.*/ - s=(27146*t5+0xB500>>16)+t5+(t5!=0)>>1; - r=t4+s; - t5=t4-s; - t4=r; - /*7-6 butterfly.*/ - s=(27146*t6+0xB500>>16)+t6+(t6!=0)>>1; - r=t7+s; - t6=t7-s; - t7=r; - /*Stage 4:*/ - /*0-1 butterfly.*/ - r=(27146*t0+0x4000>>16)+t0+(t0!=0); - s=(27146*t1+0xB500>>16)+t1+(t1!=0); - u=r+s>>1; - v=r-u; - _y[0]=u; - _y[4]=v; - /*3-2 rotation by 6pi/16*/ - u=(OC_C6S2*t2+OC_C2S6*t3+0x6CB7>>16)+(t3!=0); - s=(OC_C6S2*u>>16)-t2; - v=(s*21600+0x2800>>18)+s+(s!=0); - _y[2]=u; - _y[6]=v; - /*6-5 rotation by 3pi/16*/ - u=(OC_C5S3*t6+OC_C3S5*t5+0x0E3D>>16)+(t5!=0); - s=t6-(OC_C5S3*u>>16); - v=(s*26568+0x3400>>17)+s+(s!=0); - _y[5]=u; - _y[3]=v; - /*7-4 rotation by 7pi/16*/ - u=(OC_C7S1*t4+OC_C1S7*t7+0x7B1B>>16)+(t7!=0); - s=(OC_C7S1*u>>16)-t4; - v=(s*20539+0x3000>>20)+s+(s!=0); - _y[1]=u; - _y[7]=v; -} - -void oc_enc_fdct8x8(const oc_enc_ctx *_enc,ogg_int16_t _y[64], - const ogg_int16_t _x[64]){ - (*_enc->opt_vtable.fdct8x8)(_y,_x); -} - -/*Performs a forward 8x8 Type-II DCT transform. - The output is scaled by a factor of 4 relative to the orthonormal version - of the transform. - _y: The buffer to store the result in. - This may be the same as _x. - _x: The input coefficients. */ -void oc_enc_fdct8x8_c(ogg_int16_t _y[64],const ogg_int16_t _x[64]){ - const ogg_int16_t *in; - ogg_int16_t *end; - ogg_int16_t *out; - ogg_int16_t w[64]; - int i; - /*Add two extra bits of working precision to improve accuracy; any more and - we could overflow.*/ - for(i=0;i<64;i++)w[i]=_x[i]<<2; - /*These biases correct for some systematic error that remains in the full - fDCT->iDCT round trip.*/ - w[0]+=(w[0]!=0)+1; - w[1]++; - w[8]--; - /*Transform columns of w into rows of _y.*/ - for(in=w,out=_y,end=out+64;out>2; -} - - - -/*This does not seem to outperform simple LFE border padding before MC. - It yields higher PSNR, but much higher bitrate usage.*/ -#if 0 -typedef struct oc_extension_info oc_extension_info; - - - -/*Information needed to pad boundary blocks. - We multiply each row/column by an extension matrix that fills in the padding - values as a linear combination of the active values, so that an equivalent - number of coefficients are forced to zero. - This costs at most 16 multiplies, the same as a 1-D fDCT itself, and as - little as 7 multiplies. - We compute the extension matrices for every possible shape in advance, as - there are only 35. - The coefficients for all matrices are stored in a single array to take - advantage of the overlap and repetitiveness of many of the shapes. - A similar technique is applied to the offsets into this array. - This reduces the required table storage by about 48%. - See tools/extgen.c for details. - We could conceivably do the same for all 256 possible shapes.*/ -struct oc_extension_info{ - /*The mask of the active pixels in the shape.*/ - short mask; - /*The number of active pixels in the shape.*/ - short na; - /*The extension matrix. - This is (8-na)xna*/ - const ogg_int16_t *const *ext; - /*The pixel indices: na active pixels followed by 8-na padding pixels.*/ - unsigned char pi[8]; - /*The coefficient indices: na unconstrained coefficients followed by 8-na - coefficients to be forced to zero.*/ - unsigned char ci[8]; -}; - - -/*The number of shapes we need.*/ -#define OC_NSHAPES (35) - -static const ogg_int16_t OC_EXT_COEFFS[229]={ - 0x7FFF,0xE1F8,0x6903,0xAA79,0x5587,0x7FFF,0x1E08,0x7FFF, - 0x5587,0xAA79,0x6903,0xE1F8,0x7FFF,0x0000,0x0000,0x0000, - 0x7FFF,0x0000,0x0000,0x7FFF,0x8000,0x7FFF,0x0000,0x0000, - 0x7FFF,0xE1F8,0x1E08,0xB0A7,0xAA1D,0x337C,0x7FFF,0x4345, - 0x2267,0x4345,0x7FFF,0x337C,0xAA1D,0xB0A7,0x8A8C,0x4F59, - 0x03B4,0xE2D6,0x7FFF,0x2CF3,0x7FFF,0xE2D6,0x03B4,0x4F59, - 0x8A8C,0x1103,0x7AEF,0x5225,0xDF60,0xC288,0xDF60,0x5225, - 0x7AEF,0x1103,0x668A,0xD6EE,0x3A16,0x0E6C,0xFA07,0x0E6C, - 0x3A16,0xD6EE,0x668A,0x2A79,0x2402,0x980F,0x50F5,0x4882, - 0x50F5,0x980F,0x2402,0x2A79,0xF976,0x2768,0x5F22,0x2768, - 0xF976,0x1F91,0x76C1,0xE9AE,0x76C1,0x1F91,0x7FFF,0xD185, - 0x0FC8,0xD185,0x7FFF,0x4F59,0x4345,0xED62,0x4345,0x4F59, - 0xF574,0x5D99,0x2CF3,0x5D99,0xF574,0x5587,0x3505,0x30FC, - 0xF482,0x953C,0xEAC4,0x7FFF,0x4F04,0x7FFF,0xEAC4,0x953C, - 0xF482,0x30FC,0x4F04,0x273D,0xD8C3,0x273D,0x1E09,0x61F7, - 0x1E09,0x273D,0xD8C3,0x273D,0x4F04,0x30FC,0xA57E,0x153C, - 0x6AC4,0x3C7A,0x1E08,0x3C7A,0x6AC4,0x153C,0xA57E,0x7FFF, - 0xA57E,0x5A82,0x6AC4,0x153C,0xC386,0xE1F8,0xC386,0x153C, - 0x6AC4,0x5A82,0xD8C3,0x273D,0x7FFF,0xE1F7,0x7FFF,0x273D, - 0xD8C3,0x4F04,0x30FC,0xD8C3,0x273D,0xD8C3,0x30FC,0x4F04, - 0x1FC8,0x67AD,0x1853,0xE038,0x1853,0x67AD,0x1FC8,0x4546, - 0xE038,0x1FC8,0x3ABA,0x1FC8,0xE038,0x4546,0x3505,0x5587, - 0xF574,0xBC11,0x78F4,0x4AFB,0xE6F3,0x4E12,0x3C11,0xF8F4, - 0x4AFB,0x3C7A,0xF88B,0x3C11,0x78F4,0xCAFB,0x7FFF,0x08CC, - 0x070C,0x236D,0x5587,0x236D,0x070C,0xF88B,0x3C7A,0x4AFB, - 0xF8F4,0x3C11,0x7FFF,0x153C,0xCAFB,0x153C,0x7FFF,0x1E08, - 0xE1F8,0x7FFF,0x08CC,0x7FFF,0xCAFB,0x78F4,0x3C11,0x4E12, - 0xE6F3,0x4AFB,0x78F4,0xBC11,0xFE3D,0x7FFF,0xFE3D,0x2F3A, - 0x7FFF,0x2F3A,0x89BC,0x7FFF,0x89BC -}; - -static const ogg_int16_t *const OC_EXT_ROWS[96]={ - OC_EXT_COEFFS+ 0,OC_EXT_COEFFS+ 0,OC_EXT_COEFFS+ 0,OC_EXT_COEFFS+ 0, - OC_EXT_COEFFS+ 0,OC_EXT_COEFFS+ 0,OC_EXT_COEFFS+ 0,OC_EXT_COEFFS+ 6, - OC_EXT_COEFFS+ 27,OC_EXT_COEFFS+ 38,OC_EXT_COEFFS+ 43,OC_EXT_COEFFS+ 32, - OC_EXT_COEFFS+ 49,OC_EXT_COEFFS+ 58,OC_EXT_COEFFS+ 67,OC_EXT_COEFFS+ 71, - OC_EXT_COEFFS+ 62,OC_EXT_COEFFS+ 53,OC_EXT_COEFFS+ 12,OC_EXT_COEFFS+ 15, - OC_EXT_COEFFS+ 14,OC_EXT_COEFFS+ 13,OC_EXT_COEFFS+ 76,OC_EXT_COEFFS+ 81, - OC_EXT_COEFFS+ 86,OC_EXT_COEFFS+ 91,OC_EXT_COEFFS+ 96,OC_EXT_COEFFS+ 98, - OC_EXT_COEFFS+ 93,OC_EXT_COEFFS+ 88,OC_EXT_COEFFS+ 83,OC_EXT_COEFFS+ 78, - OC_EXT_COEFFS+ 12,OC_EXT_COEFFS+ 15,OC_EXT_COEFFS+ 15,OC_EXT_COEFFS+ 12, - OC_EXT_COEFFS+ 12,OC_EXT_COEFFS+ 15,OC_EXT_COEFFS+ 12,OC_EXT_COEFFS+ 15, - OC_EXT_COEFFS+ 15,OC_EXT_COEFFS+ 12,OC_EXT_COEFFS+ 103,OC_EXT_COEFFS+ 108, - OC_EXT_COEFFS+ 126,OC_EXT_COEFFS+ 16,OC_EXT_COEFFS+ 137,OC_EXT_COEFFS+ 141, - OC_EXT_COEFFS+ 20,OC_EXT_COEFFS+ 130,OC_EXT_COEFFS+ 113,OC_EXT_COEFFS+ 116, - OC_EXT_COEFFS+ 146,OC_EXT_COEFFS+ 153,OC_EXT_COEFFS+ 160,OC_EXT_COEFFS+ 167, - OC_EXT_COEFFS+ 170,OC_EXT_COEFFS+ 163,OC_EXT_COEFFS+ 156,OC_EXT_COEFFS+ 149, - OC_EXT_COEFFS+ 119,OC_EXT_COEFFS+ 122,OC_EXT_COEFFS+ 174,OC_EXT_COEFFS+ 177, - OC_EXT_COEFFS+ 182,OC_EXT_COEFFS+ 187,OC_EXT_COEFFS+ 192,OC_EXT_COEFFS+ 197, - OC_EXT_COEFFS+ 202,OC_EXT_COEFFS+ 207,OC_EXT_COEFFS+ 210,OC_EXT_COEFFS+ 215, - OC_EXT_COEFFS+ 179,OC_EXT_COEFFS+ 189,OC_EXT_COEFFS+ 24,OC_EXT_COEFFS+ 204, - OC_EXT_COEFFS+ 184,OC_EXT_COEFFS+ 194,OC_EXT_COEFFS+ 212,OC_EXT_COEFFS+ 199, - OC_EXT_COEFFS+ 217,OC_EXT_COEFFS+ 100,OC_EXT_COEFFS+ 134,OC_EXT_COEFFS+ 135, - OC_EXT_COEFFS+ 135,OC_EXT_COEFFS+ 12,OC_EXT_COEFFS+ 15,OC_EXT_COEFFS+ 134, - OC_EXT_COEFFS+ 134,OC_EXT_COEFFS+ 135,OC_EXT_COEFFS+ 220,OC_EXT_COEFFS+ 223, - OC_EXT_COEFFS+ 226,OC_EXT_COEFFS+ 227,OC_EXT_COEFFS+ 224,OC_EXT_COEFFS+ 221 -}; - -static const oc_extension_info OC_EXTENSION_INFO[OC_NSHAPES]={ - {0x7F,7,OC_EXT_ROWS+ 0,{0,1,2,3,4,5,6,7},{0,1,2,4,5,6,7,3}}, - {0xFE,7,OC_EXT_ROWS+ 7,{1,2,3,4,5,6,7,0},{0,1,2,4,5,6,7,3}}, - {0x3F,6,OC_EXT_ROWS+ 8,{0,1,2,3,4,5,7,6},{0,1,3,4,6,7,5,2}}, - {0xFC,6,OC_EXT_ROWS+ 10,{2,3,4,5,6,7,1,0},{0,1,3,4,6,7,5,2}}, - {0x1F,5,OC_EXT_ROWS+ 12,{0,1,2,3,4,7,6,5},{0,2,3,5,7,6,4,1}}, - {0xF8,5,OC_EXT_ROWS+ 15,{3,4,5,6,7,2,1,0},{0,2,3,5,7,6,4,1}}, - {0x0F,4,OC_EXT_ROWS+ 18,{0,1,2,3,7,6,5,4},{0,2,4,6,7,5,3,1}}, - {0xF0,4,OC_EXT_ROWS+ 18,{4,5,6,7,3,2,1,0},{0,2,4,6,7,5,3,1}}, - {0x07,3,OC_EXT_ROWS+ 22,{0,1,2,7,6,5,4,3},{0,3,6,7,5,4,2,1}}, - {0xE0,3,OC_EXT_ROWS+ 27,{5,6,7,4,3,2,1,0},{0,3,6,7,5,4,2,1}}, - {0x03,2,OC_EXT_ROWS+ 32,{0,1,7,6,5,4,3,2},{0,4,7,6,5,3,2,1}}, - {0xC0,2,OC_EXT_ROWS+ 32,{6,7,5,4,3,2,1,0},{0,4,7,6,5,3,2,1}}, - {0x01,1,OC_EXT_ROWS+ 0,{0,7,6,5,4,3,2,1},{0,7,6,5,4,3,2,1}}, - {0x80,1,OC_EXT_ROWS+ 0,{7,6,5,4,3,2,1,0},{0,7,6,5,4,3,2,1}}, - {0x7E,6,OC_EXT_ROWS+ 42,{1,2,3,4,5,6,7,0},{0,1,2,5,6,7,4,3}}, - {0x7C,5,OC_EXT_ROWS+ 44,{2,3,4,5,6,7,1,0},{0,1,4,5,7,6,3,2}}, - {0x3E,5,OC_EXT_ROWS+ 47,{1,2,3,4,5,7,6,0},{0,1,4,5,7,6,3,2}}, - {0x78,4,OC_EXT_ROWS+ 50,{3,4,5,6,7,2,1,0},{0,4,5,7,6,3,2,1}}, - {0x3C,4,OC_EXT_ROWS+ 54,{2,3,4,5,7,6,1,0},{0,3,4,7,6,5,2,1}}, - {0x1E,4,OC_EXT_ROWS+ 58,{1,2,3,4,7,6,5,0},{0,4,5,7,6,3,2,1}}, - {0x70,3,OC_EXT_ROWS+ 62,{4,5,6,7,3,2,1,0},{0,5,7,6,4,3,2,1}}, - {0x38,3,OC_EXT_ROWS+ 67,{3,4,5,7,6,2,1,0},{0,5,6,7,4,3,2,1}}, - {0x1C,3,OC_EXT_ROWS+ 72,{2,3,4,7,6,5,1,0},{0,5,6,7,4,3,2,1}}, - {0x0E,3,OC_EXT_ROWS+ 77,{1,2,3,7,6,5,4,0},{0,5,7,6,4,3,2,1}}, - {0x60,2,OC_EXT_ROWS+ 82,{5,6,7,4,3,2,1,0},{0,2,7,6,5,4,3,1}}, - {0x30,2,OC_EXT_ROWS+ 36,{4,5,7,6,3,2,1,0},{0,4,7,6,5,3,2,1}}, - {0x18,2,OC_EXT_ROWS+ 90,{3,4,7,6,5,2,1,0},{0,1,7,6,5,4,3,2}}, - {0x0C,2,OC_EXT_ROWS+ 34,{2,3,7,6,5,4,1,0},{0,4,7,6,5,3,2,1}}, - {0x06,2,OC_EXT_ROWS+ 84,{1,2,7,6,5,4,3,0},{0,2,7,6,5,4,3,1}}, - {0x40,1,OC_EXT_ROWS+ 0,{6,7,5,4,3,2,1,0},{0,7,6,5,4,3,2,1}}, - {0x20,1,OC_EXT_ROWS+ 0,{5,7,6,4,3,2,1,0},{0,7,6,5,4,3,2,1}}, - {0x10,1,OC_EXT_ROWS+ 0,{4,7,6,5,3,2,1,0},{0,7,6,5,4,3,2,1}}, - {0x08,1,OC_EXT_ROWS+ 0,{3,7,6,5,4,2,1,0},{0,7,6,5,4,3,2,1}}, - {0x04,1,OC_EXT_ROWS+ 0,{2,7,6,5,4,3,1,0},{0,7,6,5,4,3,2,1}}, - {0x02,1,OC_EXT_ROWS+ 0,{1,7,6,5,4,3,2,0},{0,7,6,5,4,3,2,1}} -}; - - - -/*Pads a single column of a partial block and then performs a forward Type-II - DCT on the result. - The input is scaled by a factor of 4 and biased appropriately for the current - fDCT implementation. - The output is scaled by an additional factor of 2 from the orthonormal - version of the transform. - _y: The buffer to store the result in. - Data will be placed the first 8 entries (e.g., in a row of an 8x8 block). - _x: The input coefficients. - Every 8th entry is used (e.g., from a column of an 8x8 block). - _e: The extension information for the shape.*/ -static void oc_fdct8_ext(ogg_int16_t _y[8],ogg_int16_t *_x, - const oc_extension_info *_e){ - const unsigned char *pi; - int na; - na=_e->na; - pi=_e->pi; - if(na==1){ - int ci; - /*While the branch below is still correct for shapes with na==1, we can - perform the entire transform with just 1 multiply in this case instead - of 23.*/ - _y[0]=(ogg_int16_t)(OC_DIV2_16(OC_C4S4*(_x[pi[0]]))); - for(ci=1;ci<8;ci++)_y[ci]=0; - } - else{ - const ogg_int16_t *const *ext; - int zpi; - int api; - int nz; - /*First multiply by the extension matrix to compute the padding values.*/ - nz=8-na; - ext=_e->ext; - for(zpi=0;zpi>16)+1>>1; - } - oc_fdct8(_y,_x); - } -} - -/*Performs a forward 8x8 Type-II DCT transform on blocks which overlap the - border of the picture region. - This method ONLY works with rectangular regions. - _border: A description of which pixels are inside the border. - _y: The buffer to store the result in. - This may be the same as _x. - _x: The input pixel values. - Pixel values outside the border will be ignored.*/ -void oc_fdct8x8_border(const oc_border_info *_border, - ogg_int16_t _y[64],const ogg_int16_t _x[64]){ - ogg_int16_t *in; - ogg_int16_t *out; - ogg_int16_t w[64]; - ogg_int64_t mask; - const oc_extension_info *cext; - const oc_extension_info *rext; - int cmask; - int rmask; - int ri; - int ci; - /*Identify the shapes of the non-zero rows and columns.*/ - rmask=cmask=0; - mask=_border->mask; - for(ri=0;ri<8;ri++){ - /*This aggregation is _only_ correct for rectangular masks.*/ - cmask|=((mask&0xFF)!=0)<>=8; - } - /*Find the associated extension info for these shapes.*/ - if(cmask==0xFF)cext=NULL; - else for(cext=OC_EXTENSION_INFO;cext->mask!=cmask;){ - /*If we somehow can't find the shape, then just do an unpadded fDCT. - It won't be efficient, but it should still be correct.*/ - if(++cext>=OC_EXTENSION_INFO+OC_NSHAPES){ - oc_enc_fdct8x8_c(_y,_x); - return; - } - } - if(rmask==0xFF)rext=NULL; - else for(rext=OC_EXTENSION_INFO;rext->mask!=rmask;){ - /*If we somehow can't find the shape, then just do an unpadded fDCT. - It won't be efficient, but it should still be correct.*/ - if(++rext>=OC_EXTENSION_INFO+OC_NSHAPES){ - oc_enc_fdct8x8_c(_y,_x); - return; - } - } - /*Add two extra bits of working precision to improve accuracy; any more and - we could overflow.*/ - for(ci=0;ci<64;ci++)w[ci]=_x[ci]<<2; - /*These biases correct for some systematic error that remains in the full - fDCT->iDCT round trip. - We can safely add them before padding, since if these pixel values are - overwritten, we didn't care what they were anyway (and the unbiased values - will usually yield smaller DCT coefficient magnitudes).*/ - w[0]+=(w[0]!=0)+1; - w[1]++; - w[8]--; - /*Transform the columns. - We can ignore zero columns without a problem.*/ - in=w; - out=_y; - if(cext==NULL)for(ci=0;ci<8;ci++)oc_fdct8(out+(ci<<3),in+ci); - else for(ci=0;ci<8;ci++)if(rmask&(1<>2; -} -#endif diff --git a/Engine/lib/libtheora/lib/fragment.c b/Engine/lib/libtheora/lib/fragment.c deleted file mode 100644 index 15372e9d9..000000000 --- a/Engine/lib/libtheora/lib/fragment.c +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: fragment.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#include -#include "internal.h" - -void oc_frag_copy(const oc_theora_state *_state,unsigned char *_dst, - const unsigned char *_src,int _ystride){ - (*_state->opt_vtable.frag_copy)(_dst,_src,_ystride); -} - -void oc_frag_copy_c(unsigned char *_dst,const unsigned char *_src,int _ystride){ - int i; - for(i=8;i-->0;){ - memcpy(_dst,_src,8*sizeof(*_dst)); - _dst+=_ystride; - _src+=_ystride; - } -} - -void oc_frag_recon_intra(const oc_theora_state *_state,unsigned char *_dst, - int _ystride,const ogg_int16_t _residue[64]){ - _state->opt_vtable.frag_recon_intra(_dst,_ystride,_residue); -} - -void oc_frag_recon_intra_c(unsigned char *_dst,int _ystride, - const ogg_int16_t _residue[64]){ - int i; - for(i=0;i<8;i++){ - int j; - for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+128); - _dst+=_ystride; - } -} - -void oc_frag_recon_inter(const oc_theora_state *_state,unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]){ - _state->opt_vtable.frag_recon_inter(_dst,_src,_ystride,_residue); -} - -void oc_frag_recon_inter_c(unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]){ - int i; - for(i=0;i<8;i++){ - int j; - for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+_src[j]); - _dst+=_ystride; - _src+=_ystride; - } -} - -void oc_frag_recon_inter2(const oc_theora_state *_state,unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride, - const ogg_int16_t _residue[64]){ - _state->opt_vtable.frag_recon_inter2(_dst,_src1,_src2,_ystride,_residue); -} - -void oc_frag_recon_inter2_c(unsigned char *_dst,const unsigned char *_src1, - const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]){ - int i; - for(i=0;i<8;i++){ - int j; - for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+(_src1[j]+_src2[j]>>1)); - _dst+=_ystride; - _src1+=_ystride; - _src2+=_ystride; - } -} - -void oc_restore_fpu(const oc_theora_state *_state){ - _state->opt_vtable.restore_fpu(); -} - -void oc_restore_fpu_c(void){} diff --git a/Engine/lib/libtheora/lib/huffdec.c b/Engine/lib/libtheora/lib/huffdec.c deleted file mode 100644 index 8cf27f034..000000000 --- a/Engine/lib/libtheora/lib/huffdec.c +++ /dev/null @@ -1,489 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: huffdec.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include -#include -#include -#include "huffdec.h" -#include "decint.h" - - -/*The ANSI offsetof macro is broken on some platforms (e.g., older DECs).*/ -#define _ogg_offsetof(_type,_field)\ - ((size_t)((char *)&((_type *)0)->_field-(char *)0)) - -/*The number of internal tokens associated with each of the spec tokens.*/ -static const unsigned char OC_DCT_TOKEN_MAP_ENTRIES[TH_NDCT_TOKENS]={ - 1,1,1,4,8,1,1,8,1,1,1,1,1,2,2,2,2,4,8,2,2,2,4,2,2,2,2,2,8,2,4,8 -}; - -/*The map from external spec-defined tokens to internal tokens. - This is constructed so that any extra bits read with the original token value - can be masked off the least significant bits of its internal token index. - In addition, all of the tokens which require additional extra bits are placed - at the start of the list, and grouped by type. - OC_DCT_REPEAT_RUN3_TOKEN is placed first, as it is an extra-special case, so - giving it index 0 may simplify comparisons on some architectures. - These requirements require some substantial reordering.*/ -static const unsigned char OC_DCT_TOKEN_MAP[TH_NDCT_TOKENS]={ - /*OC_DCT_EOB1_TOKEN (0 extra bits)*/ - 15, - /*OC_DCT_EOB2_TOKEN (0 extra bits)*/ - 16, - /*OC_DCT_EOB3_TOKEN (0 extra bits)*/ - 17, - /*OC_DCT_REPEAT_RUN0_TOKEN (2 extra bits)*/ - 88, - /*OC_DCT_REPEAT_RUN1_TOKEN (3 extra bits)*/ - 80, - /*OC_DCT_REPEAT_RUN2_TOKEN (4 extra bits)*/ - 1, - /*OC_DCT_REPEAT_RUN3_TOKEN (12 extra bits)*/ - 0, - /*OC_DCT_SHORT_ZRL_TOKEN (3 extra bits)*/ - 48, - /*OC_DCT_ZRL_TOKEN (6 extra bits)*/ - 14, - /*OC_ONE_TOKEN (0 extra bits)*/ - 56, - /*OC_MINUS_ONE_TOKEN (0 extra bits)*/ - 57, - /*OC_TWO_TOKEN (0 extra bits)*/ - 58, - /*OC_MINUS_TWO_TOKEN (0 extra bits)*/ - 59, - /*OC_DCT_VAL_CAT2 (1 extra bit)*/ - 60, - 62, - 64, - 66, - /*OC_DCT_VAL_CAT3 (2 extra bits)*/ - 68, - /*OC_DCT_VAL_CAT4 (3 extra bits)*/ - 72, - /*OC_DCT_VAL_CAT5 (4 extra bits)*/ - 2, - /*OC_DCT_VAL_CAT6 (5 extra bits)*/ - 4, - /*OC_DCT_VAL_CAT7 (6 extra bits)*/ - 6, - /*OC_DCT_VAL_CAT8 (10 extra bits)*/ - 8, - /*OC_DCT_RUN_CAT1A (1 extra bit)*/ - 18, - 20, - 22, - 24, - 26, - /*OC_DCT_RUN_CAT1B (3 extra bits)*/ - 32, - /*OC_DCT_RUN_CAT1C (4 extra bits)*/ - 12, - /*OC_DCT_RUN_CAT2A (2 extra bits)*/ - 28, - /*OC_DCT_RUN_CAT2B (3 extra bits)*/ - 40 -}; - -/*These three functions are really part of the bitpack.c module, but - they are only used here. - Declaring local static versions so they can be inlined saves considerable - function call overhead.*/ - -static oc_pb_window oc_pack_refill(oc_pack_buf *_b,int _bits){ - const unsigned char *ptr; - const unsigned char *stop; - oc_pb_window window; - int available; - window=_b->window; - available=_b->bits; - ptr=_b->ptr; - stop=_b->stop; - /*This version of _refill() doesn't bother setting eof because we won't - check for it after we've started decoding DCT tokens.*/ - if(ptr>=stop)available=OC_LOTS_OF_BITS; - while(available<=OC_PB_WINDOW_SIZE-8){ - available+=8; - window|=(oc_pb_window)*ptr++<=stop)available=OC_LOTS_OF_BITS; - } - _b->ptr=ptr; - if(_bits>available)window|=*ptr>>(available&7); - _b->bits=available; - return window; -} - - -/*Read in bits without advancing the bit pointer. - Here we assume 0<=_bits&&_bits<=32.*/ -static long oc_pack_look(oc_pack_buf *_b,int _bits){ - oc_pb_window window; - int available; - long result; - window=_b->window; - available=_b->bits; - if(_bits==0)return 0; - if(_bits>available)_b->window=window=oc_pack_refill(_b,_bits); - result=window>>OC_PB_WINDOW_SIZE-_bits; - return result; -} - -/*Advance the bit pointer.*/ -static void oc_pack_adv(oc_pack_buf *_b,int _bits){ - /*We ignore the special cases for _bits==0 and _bits==32 here, since they are - never used actually used. - OC_HUFF_SLUSH (defined below) would have to be at least 27 to actually read - 32 bits in a single go, and would require a 32 GB lookup table (assuming - 8 byte pointers, since 4 byte pointers couldn't fit such a table).*/ - _b->window<<=_bits; - _b->bits-=_bits; -} - - -/*The log_2 of the size of a lookup table is allowed to grow to relative to - the number of unique nodes it contains. - E.g., if OC_HUFF_SLUSH is 2, then at most 75% of the space in the tree is - wasted (each node will have an amortized cost of at most 20 bytes when using - 4-byte pointers). - Larger numbers can decode tokens with fewer read operations, while smaller - numbers may save more space (requiring as little as 8 bytes amortized per - node, though there will be more nodes). - With a sample file: - 32233473 read calls are required when no tree collapsing is done (100.0%). - 19269269 read calls are required when OC_HUFF_SLUSH is 0 (59.8%). - 11144969 read calls are required when OC_HUFF_SLUSH is 1 (34.6%). - 10538563 read calls are required when OC_HUFF_SLUSH is 2 (32.7%). - 10192578 read calls are required when OC_HUFF_SLUSH is 3 (31.6%). - Since a value of 1 gets us the vast majority of the speed-up with only a - small amount of wasted memory, this is what we use.*/ -#define OC_HUFF_SLUSH (1) - - -/*Determines the size in bytes of a Huffman tree node that represents a - subtree of depth _nbits. - _nbits: The depth of the subtree. - If this is 0, the node is a leaf node. - Otherwise 1<<_nbits pointers are allocated for children. - Return: The number of bytes required to store the node.*/ -static size_t oc_huff_node_size(int _nbits){ - size_t size; - size=_ogg_offsetof(oc_huff_node,nodes); - if(_nbits>0)size+=sizeof(oc_huff_node *)*(1<<_nbits); - return size; -} - -static oc_huff_node *oc_huff_node_init(char **_storage,size_t _size,int _nbits){ - oc_huff_node *ret; - ret=(oc_huff_node *)*_storage; - ret->nbits=(unsigned char)_nbits; - (*_storage)+=_size; - return ret; -} - - -/*Determines the size in bytes of a Huffman tree. - _nbits: The depth of the subtree. - If this is 0, the node is a leaf node. - Otherwise storage for 1<<_nbits pointers are added for children. - Return: The number of bytes required to store the tree.*/ -static size_t oc_huff_tree_size(const oc_huff_node *_node){ - size_t size; - size=oc_huff_node_size(_node->nbits); - if(_node->nbits){ - int nchildren; - int i; - nchildren=1<<_node->nbits; - for(i=0;inbits-_node->nodes[i]->depth){ - size+=oc_huff_tree_size(_node->nodes[i]); - } - } - return size; -} - - -/*Unpacks a sub-tree from the given buffer. - _opb: The buffer to unpack from. - _binodes: The nodes to store the sub-tree in. - _nbinodes: The number of nodes available for the sub-tree. - Return: 0 on success, or a negative value on error.*/ -static int oc_huff_tree_unpack(oc_pack_buf *_opb, - oc_huff_node *_binodes,int _nbinodes){ - oc_huff_node *binode; - long bits; - int nused; - if(_nbinodes<1)return TH_EBADHEADER; - binode=_binodes; - nused=0; - bits=oc_pack_read1(_opb); - if(oc_pack_bytes_left(_opb)<0)return TH_EBADHEADER; - /*Read an internal node:*/ - if(!bits){ - int ret; - nused++; - binode->nbits=1; - binode->depth=1; - binode->nodes[0]=_binodes+nused; - ret=oc_huff_tree_unpack(_opb,_binodes+nused,_nbinodes-nused); - if(ret>=0){ - nused+=ret; - binode->nodes[1]=_binodes+nused; - ret=oc_huff_tree_unpack(_opb,_binodes+nused,_nbinodes-nused); - } - if(ret<0)return ret; - nused+=ret; - } - /*Read a leaf node:*/ - else{ - int ntokens; - int token; - int i; - bits=oc_pack_read(_opb,OC_NDCT_TOKEN_BITS); - if(oc_pack_bytes_left(_opb)<0)return TH_EBADHEADER; - /*Find out how many internal tokens we translate this external token into.*/ - ntokens=OC_DCT_TOKEN_MAP_ENTRIES[bits]; - if(_nbinodes<2*ntokens-1)return TH_EBADHEADER; - /*Fill in a complete binary tree pointing to the internal tokens.*/ - for(i=1;inbits=0; - binode->depth=1; - binode->token=token+i; - } - } - return nused; -} - -/*Finds the depth of shortest branch of the given sub-tree. - The tree must be binary. - _binode: The root of the given sub-tree. - _binode->nbits must be 0 or 1. - Return: The smallest depth of a leaf node in this sub-tree. - 0 indicates this sub-tree is a leaf node.*/ -static int oc_huff_tree_mindepth(oc_huff_node *_binode){ - int depth0; - int depth1; - if(_binode->nbits==0)return 0; - depth0=oc_huff_tree_mindepth(_binode->nodes[0]); - depth1=oc_huff_tree_mindepth(_binode->nodes[1]); - return OC_MINI(depth0,depth1)+1; -} - -/*Finds the number of internal nodes at a given depth, plus the number of - leaves at that depth or shallower. - The tree must be binary. - _binode: The root of the given sub-tree. - _binode->nbits must be 0 or 1. - Return: The number of entries that would be contained in a jump table of the - given depth.*/ -static int oc_huff_tree_occupancy(oc_huff_node *_binode,int _depth){ - if(_binode->nbits==0||_depth<=0)return 1; - else{ - return oc_huff_tree_occupancy(_binode->nodes[0],_depth-1)+ - oc_huff_tree_occupancy(_binode->nodes[1],_depth-1); - } -} - -/*Makes a copy of the given Huffman tree. - _node: The Huffman tree to copy. - Return: The copy of the Huffman tree.*/ -static oc_huff_node *oc_huff_tree_copy(const oc_huff_node *_node, - char **_storage){ - oc_huff_node *ret; - ret=oc_huff_node_init(_storage,oc_huff_node_size(_node->nbits),_node->nbits); - ret->depth=_node->depth; - if(_node->nbits){ - int nchildren; - int i; - int inext; - nchildren=1<<_node->nbits; - for(i=0;inodes[i]=oc_huff_tree_copy(_node->nodes[i],_storage); - inext=i+(1<<_node->nbits-ret->nodes[i]->depth); - while(++inodes[i]=ret->nodes[i-1]; - } - } - else ret->token=_node->token; - return ret; -} - -static size_t oc_huff_tree_collapse_size(oc_huff_node *_binode,int _depth){ - size_t size; - int mindepth; - int depth; - int loccupancy; - int occupancy; - if(_binode->nbits!=0&&_depth>0){ - return oc_huff_tree_collapse_size(_binode->nodes[0],_depth-1)+ - oc_huff_tree_collapse_size(_binode->nodes[1],_depth-1); - } - depth=mindepth=oc_huff_tree_mindepth(_binode); - occupancy=1<loccupancy&&occupancy>=1<0){ - size+=oc_huff_tree_collapse_size(_binode->nodes[0],depth-1); - size+=oc_huff_tree_collapse_size(_binode->nodes[1],depth-1); - } - return size; -} - -static oc_huff_node *oc_huff_tree_collapse(oc_huff_node *_binode, - char **_storage); - -/*Fills the given nodes table with all the children in the sub-tree at the - given depth. - The nodes in the sub-tree with a depth less than that stored in the table - are freed. - The sub-tree must be binary and complete up until the given depth. - _nodes: The nodes table to fill. - _binode: The root of the sub-tree to fill it with. - _binode->nbits must be 0 or 1. - _level: The current level in the table. - 0 indicates that the current node should be stored, regardless of - whether it is a leaf node or an internal node. - _depth: The depth of the nodes to fill the table with, relative to their - parent.*/ -static void oc_huff_node_fill(oc_huff_node **_nodes, - oc_huff_node *_binode,int _level,int _depth,char **_storage){ - if(_level<=0||_binode->nbits==0){ - int i; - _binode->depth=(unsigned char)(_depth-_level); - _nodes[0]=oc_huff_tree_collapse(_binode,_storage); - for(i=1;i<1<<_level;i++)_nodes[i]=_nodes[0]; - } - else{ - _level--; - oc_huff_node_fill(_nodes,_binode->nodes[0],_level,_depth,_storage); - _nodes+=1<<_level; - oc_huff_node_fill(_nodes,_binode->nodes[1],_level,_depth,_storage); - } -} - -/*Finds the largest complete sub-tree rooted at the current node and collapses - it into a single node. - This procedure is then applied recursively to all the children of that node. - _binode: The root of the sub-tree to collapse. - _binode->nbits must be 0 or 1. - Return: The new root of the collapsed sub-tree.*/ -static oc_huff_node *oc_huff_tree_collapse(oc_huff_node *_binode, - char **_storage){ - oc_huff_node *root; - size_t size; - int mindepth; - int depth; - int loccupancy; - int occupancy; - depth=mindepth=oc_huff_tree_mindepth(_binode); - occupancy=1<loccupancy&&occupancy>=1<depth=_binode->depth; - oc_huff_node_fill(root->nodes,_binode,depth,depth,_storage); - return root; -} - -/*Unpacks a set of Huffman trees, and reduces them to a collapsed - representation. - _opb: The buffer to unpack the trees from. - _nodes: The table to fill with the Huffman trees. - Return: 0 on success, or a negative value on error.*/ -int oc_huff_trees_unpack(oc_pack_buf *_opb, - oc_huff_node *_nodes[TH_NHUFFMAN_TABLES]){ - int i; - for(i=0;i0)_ogg_free(_dst[i]); - return TH_EFAULT; - } - _dst[i]=oc_huff_tree_copy(_src[i],&storage); - } - return 0; -} - -/*Frees the memory used by a set of Huffman trees. - _nodes: The array of trees to free.*/ -void oc_huff_trees_clear(oc_huff_node *_nodes[TH_NHUFFMAN_TABLES]){ - int i; - for(i=0;inbits!=0){ - bits=oc_pack_look(_opb,_node->nbits); - _node=_node->nodes[bits]; - oc_pack_adv(_opb,_node->depth); - } - return _node->token; -} diff --git a/Engine/lib/libtheora/lib/huffdec.h b/Engine/lib/libtheora/lib/huffdec.h deleted file mode 100644 index d7ffa0e99..000000000 --- a/Engine/lib/libtheora/lib/huffdec.h +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: huffdec.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#if !defined(_huffdec_H) -# define _huffdec_H (1) -# include "huffman.h" -# include "bitpack.h" - - - -typedef struct oc_huff_node oc_huff_node; - -/*A node in the Huffman tree. - Instead of storing every branching in the tree, subtrees can be collapsed - into one node, with a table of size 1< -#include -#include -#include "huffenc.h" - - - -/*The default Huffman codes used for VP3.1.*/ -const th_huff_code TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]={ - { - {0x002D, 6},{0x0026, 7},{0x0166, 9},{0x004E, 8}, - {0x02CE,10},{0x059E,11},{0x027D,11},{0x0008, 5}, - {0x04F9,12},{0x000F, 4},{0x000E, 4},{0x001B, 5}, - {0x0006, 4},{0x0008, 4},{0x0005, 4},{0x001A, 5}, - {0x0015, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3}, - {0x0000, 3},{0x0009, 4},{0x0017, 5},{0x0029, 6}, - {0x0028, 6},{0x00B2, 8},{0x04F8,12},{0x059F,11}, - {0x009E, 9},{0x013F,10},{0x0012, 6},{0x0058, 7} - }, - { - {0x0010, 5},{0x0047, 7},{0x01FF, 9},{0x008C, 8}, - {0x03FC,10},{0x046A,11},{0x0469,11},{0x0022, 6}, - {0x11A1,13},{0x000E, 4},{0x000D, 4},{0x0004, 4}, - {0x0005, 4},{0x0009, 4},{0x0006, 4},{0x001E, 5}, - {0x0016, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3}, - {0x0000, 3},{0x000A, 4},{0x0017, 5},{0x007D, 7}, - {0x007E, 7},{0x011B, 9},{0x08D1,12},{0x03FD,10}, - {0x046B,11},{0x11A0,13},{0x007C, 7},{0x00FE, 8} - }, - { - {0x0016, 5},{0x0020, 6},{0x0086, 8},{0x0087, 8}, - {0x0367,10},{0x06CC,11},{0x06CB,11},{0x006E, 7}, - {0x366D,14},{0x000F, 4},{0x000E, 4},{0x0004, 4}, - {0x0005, 4},{0x000A, 4},{0x0006, 4},{0x001A, 5}, - {0x0011, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3}, - {0x0000, 3},{0x0009, 4},{0x0017, 5},{0x006F, 7}, - {0x006D, 7},{0x0364,10},{0x0D9A,12},{0x06CA,11}, - {0x1B37,13},{0x366C,14},{0x0042, 7},{0x00D8, 8} - }, - { - {0x0000, 4},{0x002D, 6},{0x00F7, 8},{0x0058, 7}, - {0x0167, 9},{0x02CB,10},{0x02CA,10},{0x000E, 6}, - {0x1661,13},{0x0003, 3},{0x0002, 3},{0x0008, 4}, - {0x0009, 4},{0x000D, 4},{0x0002, 4},{0x001F, 5}, - {0x0017, 5},{0x0001, 4},{0x000C, 4},{0x000E, 4}, - {0x000A, 4},{0x0006, 5},{0x0078, 7},{0x000F, 6}, - {0x007A, 7},{0x0164, 9},{0x0599,11},{0x02CD,10}, - {0x0B31,12},{0x1660,13},{0x0079, 7},{0x00F6, 8} - }, - { - {0x0003, 4},{0x003C, 6},{0x000F, 7},{0x007A, 7}, - {0x001D, 8},{0x0020, 9},{0x0072,10},{0x0006, 6}, - {0x0399,13},{0x0004, 3},{0x0005, 3},{0x0005, 4}, - {0x0006, 4},{0x000E, 4},{0x0004, 4},{0x0000, 4}, - {0x0019, 5},{0x0002, 4},{0x000D, 4},{0x0007, 4}, - {0x001F, 5},{0x0030, 6},{0x0011, 8},{0x0031, 6}, - {0x0005, 6},{0x0021, 9},{0x00E7,11},{0x0038, 9}, - {0x01CD,12},{0x0398,13},{0x007B, 7},{0x0009, 7} - }, - { - {0x0009, 4},{0x0002, 5},{0x0074, 7},{0x0007, 6}, - {0x00EC, 8},{0x00D1, 9},{0x01A6,10},{0x0006, 6}, - {0x0D21,13},{0x0005, 3},{0x0006, 3},{0x0008, 4}, - {0x0007, 4},{0x000F, 4},{0x0004, 4},{0x0000, 4}, - {0x001C, 5},{0x0002, 4},{0x0005, 4},{0x0003, 4}, - {0x000C, 5},{0x0035, 7},{0x01A7,10},{0x001B, 6}, - {0x0077, 7},{0x01A5,10},{0x0349,11},{0x00D0, 9}, - {0x0691,12},{0x0D20,13},{0x0075, 7},{0x00ED, 8} - }, - { - {0x000A, 4},{0x000C, 5},{0x0012, 6},{0x001B, 6}, - {0x00B7, 8},{0x016C, 9},{0x0099, 9},{0x005A, 7}, - {0x16D8,13},{0x0007, 3},{0x0006, 3},{0x0009, 4}, - {0x0008, 4},{0x0000, 3},{0x0005, 4},{0x0017, 5}, - {0x000E, 5},{0x0002, 4},{0x0003, 4},{0x000F, 5}, - {0x001A, 6},{0x004D, 8},{0x2DB3,14},{0x002C, 6}, - {0x0011, 6},{0x02DA,10},{0x05B7,11},{0x0098, 9}, - {0x0B6D,12},{0x2DB2,14},{0x0010, 6},{0x0027, 7} - }, - { - {0x000D, 4},{0x000F, 5},{0x001D, 6},{0x0008, 5}, - {0x0051, 7},{0x0056, 8},{0x00AF, 9},{0x002A, 7}, - {0x148A,13},{0x0007, 3},{0x0000, 2},{0x0008, 4}, - {0x0009, 4},{0x000C, 4},{0x0006, 4},{0x0017, 5}, - {0x000B, 5},{0x0016, 5},{0x0015, 5},{0x0009, 5}, - {0x0050, 7},{0x00AE, 9},{0x2917,14},{0x001C, 6}, - {0x0014, 6},{0x0290,10},{0x0523,11},{0x0149, 9}, - {0x0A44,12},{0x2916,14},{0x0053, 7},{0x00A5, 8} - }, - { - {0x0001, 4},{0x001D, 6},{0x00F5, 8},{0x00F4, 8}, - {0x024D,10},{0x0499,11},{0x0498,11},{0x0001, 5}, - {0x0021, 6},{0x0006, 3},{0x0005, 3},{0x0006, 4}, - {0x0005, 4},{0x0002, 4},{0x0007, 5},{0x0025, 6}, - {0x007B, 7},{0x001C, 6},{0x0020, 6},{0x000D, 6}, - {0x0048, 7},{0x0092, 8},{0x0127, 9},{0x000E, 4}, - {0x0004, 4},{0x0011, 5},{0x000C, 6},{0x003C, 6}, - {0x000F, 5},{0x0000, 5},{0x001F, 5},{0x0013, 5} - }, - { - {0x0005, 4},{0x003C, 6},{0x0040, 7},{0x000D, 7}, - {0x0031, 9},{0x0061,10},{0x0060,10},{0x0002, 5}, - {0x00F5, 8},{0x0006, 3},{0x0005, 3},{0x0007, 4}, - {0x0006, 4},{0x0002, 4},{0x0009, 5},{0x0025, 6}, - {0x0007, 6},{0x0021, 6},{0x0024, 6},{0x0010, 6}, - {0x0041, 7},{0x00F4, 8},{0x0019, 8},{0x000E, 4}, - {0x0003, 4},{0x0011, 5},{0x0011, 6},{0x003F, 6}, - {0x003E, 6},{0x007B, 7},{0x0000, 4},{0x0013, 5} - }, - { - {0x000A, 4},{0x0007, 5},{0x0001, 6},{0x0009, 6}, - {0x0131, 9},{0x0261,10},{0x0260,10},{0x0015, 6}, - {0x0001, 7},{0x0007, 3},{0x0006, 3},{0x0008, 4}, - {0x0007, 4},{0x0006, 4},{0x0012, 5},{0x002F, 6}, - {0x0014, 6},{0x0027, 6},{0x002D, 6},{0x0016, 6}, - {0x004D, 7},{0x0099, 8},{0x0000, 7},{0x0004, 4}, - {0x0001, 4},{0x0005, 5},{0x0017, 6},{0x002E, 6}, - {0x002C, 6},{0x0008, 6},{0x0006, 5},{0x0001, 5} - }, - { - {0x0000, 3},{0x000E, 5},{0x0017, 6},{0x002A, 6}, - {0x0010, 7},{0x00F9,10},{0x00F8,10},{0x001E, 7}, - {0x003F, 8},{0x0007, 3},{0x0006, 3},{0x0009, 4}, - {0x0008, 4},{0x0006, 4},{0x000F, 5},{0x0005, 5}, - {0x0016, 6},{0x0029, 6},{0x002B, 6},{0x0015, 6}, - {0x0050, 7},{0x0011, 7},{0x007D, 9},{0x0004, 4}, - {0x0017, 5},{0x0006, 5},{0x0014, 6},{0x002C, 6}, - {0x002D, 6},{0x000E, 6},{0x0009, 6},{0x0051, 7} - }, - { - {0x0002, 3},{0x0018, 5},{0x002F, 6},{0x000D, 5}, - {0x0053, 7},{0x0295,10},{0x0294,10},{0x00A4, 8}, - {0x007C, 8},{0x0000, 2},{0x0007, 3},{0x0009, 4}, - {0x0008, 4},{0x001B, 5},{0x000C, 5},{0x0028, 6}, - {0x006A, 7},{0x001E, 6},{0x001D, 6},{0x0069, 7}, - {0x00D7, 8},{0x007D, 8},{0x014B, 9},{0x0019, 5}, - {0x0016, 5},{0x002E, 6},{0x001C, 6},{0x002B, 6}, - {0x002A, 6},{0x0068, 7},{0x003F, 7},{0x00D6, 8} - }, - { - {0x0002, 3},{0x001B, 5},{0x000C, 5},{0x0018, 5}, - {0x0029, 6},{0x007F, 8},{0x02F0,10},{0x0198, 9}, - {0x0179, 9},{0x0000, 2},{0x0007, 3},{0x0009, 4}, - {0x0008, 4},{0x001A, 5},{0x000D, 5},{0x002A, 6}, - {0x0064, 7},{0x001E, 6},{0x0067, 7},{0x005F, 7}, - {0x00CD, 8},{0x007E, 8},{0x02F1,10},{0x0016, 5}, - {0x000E, 5},{0x002E, 6},{0x0065, 7},{0x002B, 6}, - {0x0028, 6},{0x003E, 7},{0x00BD, 8},{0x0199, 9} - }, - { - {0x0002, 3},{0x0007, 4},{0x0016, 5},{0x0006, 4}, - {0x0036, 6},{0x005C, 7},{0x015D, 9},{0x015C, 9}, - {0x02BF,10},{0x0000, 2},{0x0007, 3},{0x0009, 4}, - {0x0008, 4},{0x0018, 5},{0x0034, 6},{0x002A, 6}, - {0x005E, 7},{0x006A, 7},{0x0064, 7},{0x005D, 7}, - {0x00CB, 8},{0x00AD, 8},{0x02BE,10},{0x0014, 5}, - {0x0033, 6},{0x006E, 7},{0x005F, 7},{0x006F, 7}, - {0x006B, 7},{0x00CA, 8},{0x00AC, 8},{0x015E, 9} - }, - { - {0x000F, 4},{0x001D, 5},{0x0018, 5},{0x000B, 4}, - {0x0019, 5},{0x0029, 6},{0x00D6, 8},{0x0551,11}, - {0x0AA1,12},{0x0001, 2},{0x0000, 2},{0x0009, 4}, - {0x0008, 4},{0x001B, 5},{0x0038, 6},{0x0028, 6}, - {0x0057, 7},{0x006A, 7},{0x0068, 7},{0x0056, 7}, - {0x00E5, 8},{0x0155, 9},{0x0AA0,12},{0x0073, 7}, - {0x0069, 7},{0x00D7, 8},{0x00AB, 8},{0x00E4, 8}, - {0x00A9, 8},{0x0151, 9},{0x0150, 9},{0x02A9,10} - }, - { - {0x0008, 5},{0x0025, 7},{0x017A, 9},{0x02F7,10}, - {0x0BDB,12},{0x17B4,13},{0x2F6B,14},{0x001D, 5}, - {0x2F6A,14},{0x0008, 4},{0x0007, 4},{0x0001, 4}, - {0x0002, 4},{0x000A, 4},{0x0006, 4},{0x0000, 4}, - {0x001C, 5},{0x0009, 4},{0x000D, 4},{0x000F, 4}, - {0x000C, 4},{0x0003, 4},{0x000A, 5},{0x0016, 5}, - {0x0013, 6},{0x005D, 7},{0x0024, 7},{0x00BC, 8}, - {0x005C, 7},{0x05EC,11},{0x000B, 5},{0x005F, 7} - }, - { - {0x000F, 5},{0x0010, 6},{0x004B, 8},{0x00C6, 8}, - {0x031D,10},{0x0C71,12},{0x0C70,12},{0x0001, 4}, - {0x0C73,12},{0x0008, 4},{0x0009, 4},{0x0002, 4}, - {0x0003, 4},{0x000B, 4},{0x0006, 4},{0x0000, 4}, - {0x001C, 5},{0x0005, 4},{0x000D, 4},{0x000F, 4}, - {0x000A, 4},{0x0019, 5},{0x0013, 6},{0x001D, 5}, - {0x0030, 6},{0x0062, 7},{0x0024, 7},{0x004A, 8}, - {0x018F, 9},{0x0C72,12},{0x000E, 5},{0x0011, 6} - }, - { - {0x001B, 5},{0x0003, 6},{0x008D, 8},{0x0040, 7}, - {0x0239,10},{0x0471,11},{0x08E0,12},{0x0003, 4}, - {0x11C3,13},{0x000A, 4},{0x0009, 4},{0x0004, 4}, - {0x0005, 4},{0x000E, 4},{0x0007, 4},{0x0001, 4}, - {0x001E, 5},{0x0006, 4},{0x000C, 4},{0x000B, 4}, - {0x0002, 4},{0x0000, 5},{0x0041, 7},{0x001F, 5}, - {0x0022, 6},{0x0002, 6},{0x008F, 8},{0x008C, 8}, - {0x011D, 9},{0x11C2,13},{0x001A, 5},{0x0021, 6} - }, - { - {0x001F, 5},{0x0003, 6},{0x0003, 7},{0x0043, 7}, - {0x000B, 9},{0x0015,10},{0x0051,12},{0x0003, 4}, - {0x0050,12},{0x000D, 4},{0x000C, 4},{0x0004, 4}, - {0x0006, 4},{0x000E, 4},{0x000A, 4},{0x0001, 4}, - {0x001E, 5},{0x0005, 4},{0x0009, 4},{0x0007, 4}, - {0x0011, 5},{0x0002, 6},{0x0004, 8},{0x0002, 4}, - {0x002D, 6},{0x0020, 6},{0x0042, 7},{0x0001, 7}, - {0x0000, 7},{0x0029,11},{0x0017, 5},{0x002C, 6} - }, - { - {0x0003, 4},{0x001F, 6},{0x003A, 7},{0x005D, 7}, - {0x0173, 9},{0x02E4,10},{0x172D,13},{0x0004, 4}, - {0x172C,13},{0x000F, 4},{0x000E, 4},{0x0009, 4}, - {0x0008, 4},{0x000C, 4},{0x000A, 4},{0x0001, 4}, - {0x0016, 5},{0x0002, 4},{0x0005, 4},{0x001A, 5}, - {0x002F, 6},{0x0038, 7},{0x05CA,11},{0x0006, 4}, - {0x0037, 6},{0x001E, 6},{0x003B, 7},{0x0039, 7}, - {0x00B8, 8},{0x0B97,12},{0x0000, 4},{0x0036, 6} - }, - { - {0x0006, 4},{0x0037, 6},{0x005D, 7},{0x000C, 6}, - {0x00B9, 8},{0x02E3,10},{0x05C4,11},{0x0004, 4}, - {0x1715,13},{0x0000, 3},{0x000F, 4},{0x0008, 4}, - {0x0007, 4},{0x000C, 4},{0x0009, 4},{0x001D, 5}, - {0x0016, 5},{0x001C, 5},{0x001A, 5},{0x000B, 5}, - {0x005E, 7},{0x0170, 9},{0x1714,13},{0x000A, 4}, - {0x000A, 5},{0x0036, 6},{0x005F, 7},{0x001B, 7}, - {0x001A, 7},{0x0B8B,12},{0x0002, 4},{0x0007, 5} - }, - { - {0x000C, 4},{0x000B, 5},{0x0079, 7},{0x0022, 6}, - {0x00F0, 8},{0x0119, 9},{0x0230,10},{0x001D, 5}, - {0x08C4,12},{0x0001, 3},{0x0000, 3},{0x000A, 4}, - {0x0009, 4},{0x000B, 4},{0x0007, 4},{0x001C, 5}, - {0x003D, 6},{0x000D, 5},{0x0008, 5},{0x0015, 6}, - {0x008D, 8},{0x118B,13},{0x118A,13},{0x000D, 4}, - {0x0010, 5},{0x0009, 5},{0x0014, 6},{0x0047, 7}, - {0x00F1, 8},{0x0463,11},{0x001F, 5},{0x000C, 5} - }, - { - {0x0000, 3},{0x001A, 5},{0x0033, 6},{0x000C, 5}, - {0x0046, 7},{0x01E3, 9},{0x03C5,10},{0x0017, 5}, - {0x1E21,13},{0x0002, 3},{0x0001, 3},{0x0009, 4}, - {0x000A, 4},{0x0007, 4},{0x001B, 5},{0x003D, 6}, - {0x001B, 6},{0x0022, 6},{0x0079, 7},{0x00F0, 8}, - {0x1E20,13},{0x1E23,13},{0x1E22,13},{0x000E, 4}, - {0x0016, 5},{0x0018, 5},{0x0032, 6},{0x001A, 6}, - {0x0047, 7},{0x0789,11},{0x001F, 5},{0x0010, 5} - }, - { - {0x001D, 5},{0x0061, 7},{0x004E, 8},{0x009E, 9}, - {0x027C,11},{0x09F5,13},{0x09F4,13},{0x0003, 4}, - {0x0060, 7},{0x0000, 3},{0x000F, 4},{0x000B, 4}, - {0x000A, 4},{0x0009, 4},{0x0005, 4},{0x000D, 5}, - {0x0031, 6},{0x0008, 5},{0x0038, 6},{0x0012, 6}, - {0x0026, 7},{0x013F,10},{0x04FB,12},{0x000D, 4}, - {0x0002, 4},{0x000C, 5},{0x0039, 6},{0x001C, 6}, - {0x000F, 5},{0x001D, 6},{0x0008, 4},{0x0019, 5} - }, - { - {0x0007, 4},{0x0019, 6},{0x00AB, 8},{0x00AA, 8}, - {0x0119,10},{0x0461,12},{0x0460,12},{0x001B, 5}, - {0x0047, 8},{0x0001, 3},{0x0000, 3},{0x000C, 4}, - {0x000B, 4},{0x0009, 4},{0x0005, 4},{0x000D, 5}, - {0x0035, 6},{0x003D, 6},{0x003C, 6},{0x0018, 6}, - {0x0022, 7},{0x008D, 9},{0x0231,11},{0x000E, 4}, - {0x001F, 5},{0x0009, 5},{0x002B, 6},{0x0010, 6}, - {0x0034, 6},{0x0054, 7},{0x0008, 4},{0x0014, 5} - }, - { - {0x000C, 4},{0x0005, 5},{0x0008, 6},{0x005B, 7}, - {0x004D, 9},{0x0131,11},{0x0261,12},{0x001A, 5}, - {0x0012, 7},{0x0000, 3},{0x000F, 4},{0x000A, 4}, - {0x0009, 4},{0x0006, 4},{0x001B, 5},{0x0006, 5}, - {0x001C, 6},{0x002C, 6},{0x0015, 6},{0x005A, 7}, - {0x0027, 8},{0x0099,10},{0x0260,12},{0x000E, 4}, - {0x0004, 4},{0x000F, 5},{0x0007, 5},{0x001D, 6}, - {0x000B, 5},{0x0014, 6},{0x0008, 4},{0x0017, 5} - }, - { - {0x000F, 4},{0x0013, 5},{0x0075, 7},{0x0024, 6}, - {0x0095, 8},{0x0251,10},{0x04A0,11},{0x0010, 5}, - {0x00C8, 8},{0x0002, 3},{0x0001, 3},{0x0001, 4}, - {0x0000, 4},{0x001A, 5},{0x0011, 5},{0x002C, 6}, - {0x0065, 7},{0x0074, 7},{0x004B, 7},{0x00C9, 8}, - {0x0129, 9},{0x0943,12},{0x0942,12},{0x0003, 3}, - {0x000A, 4},{0x001C, 5},{0x0018, 5},{0x0033, 6}, - {0x0017, 5},{0x002D, 6},{0x001B, 5},{0x003B, 6} - }, - { - {0x0003, 3},{0x001A, 5},{0x002D, 6},{0x0038, 6}, - {0x0028, 7},{0x0395,10},{0x0E51,12},{0x0037, 6}, - {0x00E4, 8},{0x0001, 3},{0x0000, 3},{0x001F, 5}, - {0x001E, 5},{0x0017, 5},{0x003A, 6},{0x0073, 7}, - {0x002A, 7},{0x002B, 7},{0x0029, 7},{0x01CB, 9}, - {0x0729,11},{0x1CA1,13},{0x1CA0,13},{0x0004, 3}, - {0x000A, 4},{0x0004, 4},{0x0018, 5},{0x0036, 6}, - {0x000B, 5},{0x002C, 6},{0x0019, 5},{0x003B, 6} - }, - { - {0x0004, 3},{0x0004, 4},{0x003F, 6},{0x0017, 5}, - {0x0075, 7},{0x01F5, 9},{0x07D1,11},{0x0017, 6}, - {0x01F6, 9},{0x0001, 3},{0x0000, 3},{0x001B, 5}, - {0x001A, 5},{0x000A, 5},{0x0032, 6},{0x0074, 7}, - {0x00F8, 8},{0x00F9, 8},{0x01F7, 9},{0x03E9,10}, - {0x0FA0,12},{0x1F43,13},{0x1F42,13},{0x0003, 3}, - {0x000A, 4},{0x001E, 5},{0x001C, 5},{0x003B, 6}, - {0x0018, 5},{0x0016, 6},{0x0016, 5},{0x0033, 6} - }, - { - {0x0004, 3},{0x0007, 4},{0x0018, 5},{0x001E, 5}, - {0x0036, 6},{0x0031, 7},{0x0177, 9},{0x0077, 7}, - {0x0176, 9},{0x0001, 3},{0x0000, 3},{0x001A, 5}, - {0x0019, 5},{0x003A, 6},{0x0019, 6},{0x005C, 7}, - {0x00BA, 8},{0x0061, 8},{0x00C1, 9},{0x0180,10}, - {0x0302,11},{0x0607,12},{0x0606,12},{0x0002, 3}, - {0x000A, 4},{0x001F, 5},{0x001C, 5},{0x0037, 6}, - {0x0016, 5},{0x0076, 7},{0x000D, 5},{0x002F, 6} - }, - { - {0x0000, 3},{0x000A, 4},{0x001A, 5},{0x000C, 4}, - {0x001D, 5},{0x0039, 6},{0x0078, 7},{0x005E, 7}, - {0x0393,11},{0x0002, 3},{0x0001, 3},{0x0016, 5}, - {0x000F, 5},{0x002E, 6},{0x005F, 7},{0x0073, 8}, - {0x00E5, 9},{0x01C8,10},{0x0E4A,13},{0x1C97,14}, - {0x1C96,14},{0x0E49,13},{0x0E48,13},{0x0004, 3}, - {0x0006, 4},{0x001F, 5},{0x001B, 5},{0x001D, 6}, - {0x0038, 6},{0x0038, 7},{0x003D, 6},{0x0079, 7} - }, - { - {0x000B, 5},{0x002B, 7},{0x0054, 8},{0x01B7, 9}, - {0x06D9,11},{0x0DB1,12},{0x0DB0,12},{0x0002, 4}, - {0x00AB, 9},{0x0009, 4},{0x000A, 4},{0x0007, 4}, - {0x0008, 4},{0x000F, 4},{0x000C, 4},{0x0003, 4}, - {0x001D, 5},{0x0004, 4},{0x000B, 4},{0x0006, 4}, - {0x001A, 5},{0x0003, 6},{0x00AA, 9},{0x0001, 4}, - {0x0000, 5},{0x0014, 6},{0x006C, 7},{0x00DA, 8}, - {0x0002, 6},{0x036D,10},{0x001C, 5},{0x0037, 6} - }, - { - {0x001D, 5},{0x0004, 6},{0x00B6, 8},{0x006A, 8}, - {0x05B9,11},{0x16E1,13},{0x16E0,13},{0x0007, 4}, - {0x016F, 9},{0x000C, 4},{0x000D, 4},{0x0009, 4}, - {0x0008, 4},{0x000F, 4},{0x000A, 4},{0x0003, 4}, - {0x0017, 5},{0x0002, 4},{0x0004, 4},{0x001C, 5}, - {0x002C, 6},{0x006B, 8},{0x0B71,12},{0x0005, 4}, - {0x0003, 5},{0x001B, 6},{0x005A, 7},{0x0034, 7}, - {0x0005, 6},{0x02DD,10},{0x0000, 4},{0x000C, 5} - }, - { - {0x0003, 4},{0x007F, 7},{0x00A1, 8},{0x00A0, 8}, - {0x020C,10},{0x0834,12},{0x106B,13},{0x0007, 4}, - {0x0082, 8},{0x000E, 4},{0x000D, 4},{0x000B, 4}, - {0x000C, 4},{0x0000, 3},{0x0009, 4},{0x0002, 4}, - {0x0011, 5},{0x001E, 5},{0x0015, 5},{0x003E, 6}, - {0x0040, 7},{0x041B,11},{0x106A,13},{0x0006, 4}, - {0x000A, 5},{0x0029, 6},{0x007E, 7},{0x0051, 7}, - {0x0021, 6},{0x0107, 9},{0x0004, 4},{0x000B, 5} - }, - { - {0x0007, 4},{0x001B, 6},{0x00F6, 8},{0x00E9, 8}, - {0x03A1,10},{0x0740,11},{0x0E82,12},{0x001F, 5}, - {0x01EF, 9},{0x0001, 3},{0x0002, 3},{0x000B, 4}, - {0x000C, 4},{0x000D, 4},{0x0008, 4},{0x001C, 5}, - {0x0003, 5},{0x0012, 5},{0x0002, 5},{0x0075, 7}, - {0x01D1, 9},{0x1D07,13},{0x1D06,13},{0x000A, 4}, - {0x0013, 5},{0x003B, 6},{0x001A, 6},{0x007A, 7}, - {0x003C, 6},{0x01EE, 9},{0x0000, 4},{0x000C, 5} - }, - { - {0x000D, 4},{0x003D, 6},{0x0042, 7},{0x0037, 7}, - {0x00D9, 9},{0x0362,11},{0x06C6,12},{0x001F, 5}, - {0x0086, 8},{0x0001, 3},{0x0002, 3},{0x000C, 4}, - {0x000B, 4},{0x000A, 4},{0x0001, 4},{0x000F, 5}, - {0x0025, 6},{0x003C, 6},{0x001A, 6},{0x0087, 8}, - {0x01B0,10},{0x0D8F,13},{0x0D8E,13},{0x000E, 4}, - {0x0013, 5},{0x000C, 5},{0x0024, 6},{0x0020, 6}, - {0x0011, 5},{0x006D, 8},{0x0000, 4},{0x000E, 5} - }, - { - {0x0000, 3},{0x0012, 5},{0x0076, 7},{0x0077, 7}, - {0x014D, 9},{0x0533,11},{0x14C9,13},{0x0013, 5}, - {0x00A5, 8},{0x0002, 3},{0x0003, 3},{0x000B, 4}, - {0x000C, 4},{0x0008, 4},{0x001A, 5},{0x002B, 6}, - {0x0075, 7},{0x0074, 7},{0x00A7, 8},{0x0298,10}, - {0x14C8,13},{0x14CB,13},{0x14CA,13},{0x000F, 4}, - {0x001C, 5},{0x0007, 5},{0x002A, 6},{0x0028, 6}, - {0x001B, 5},{0x00A4, 8},{0x0002, 4},{0x0006, 5} - }, - { - {0x0002, 3},{0x001A, 5},{0x002B, 6},{0x003A, 6}, - {0x00ED, 8},{0x0283,10},{0x0A0A,12},{0x0004, 5}, - {0x00A1, 8},{0x0004, 3},{0x0003, 3},{0x000B, 4}, - {0x000C, 4},{0x001F, 5},{0x0006, 5},{0x0077, 7}, - {0x00A3, 8},{0x00A2, 8},{0x0140, 9},{0x1417,13}, - {0x1416,13},{0x0A09,12},{0x0A08,12},{0x0000, 3}, - {0x001E, 5},{0x0007, 5},{0x002A, 6},{0x0029, 6}, - {0x001C, 5},{0x00EC, 8},{0x001B, 5},{0x0005, 5} - }, - { - {0x0002, 3},{0x0002, 4},{0x0018, 5},{0x001D, 5}, - {0x0035, 6},{0x00E4, 8},{0x01CF,11},{0x001D, 7}, - {0x0072, 9},{0x0004, 3},{0x0005, 3},{0x0006, 4}, - {0x0007, 4},{0x0006, 5},{0x0073, 7},{0x0038, 8}, - {0x01CE,11},{0x039B,12},{0x0398,12},{0x0733,13}, - {0x0732,13},{0x0735,13},{0x0734,13},{0x0000, 3}, - {0x001F, 5},{0x001B, 5},{0x0034, 6},{0x000F, 6}, - {0x001E, 5},{0x00E5, 8},{0x0019, 5},{0x0038, 6} - }, - { - {0x0016, 5},{0x0050, 7},{0x0172, 9},{0x02E7,10}, - {0x1732,13},{0x2E67,14},{0x2E66,14},{0x0006, 4}, - {0x0051, 7},{0x0001, 3},{0x0000, 3},{0x000D, 4}, - {0x000C, 4},{0x0009, 4},{0x001C, 5},{0x0009, 5}, - {0x001C, 6},{0x001D, 6},{0x005D, 7},{0x00B8, 8}, - {0x05CD,11},{0x1731,13},{0x1730,13},{0x000F, 4}, - {0x0005, 4},{0x000F, 5},{0x0008, 5},{0x0029, 6}, - {0x001D, 5},{0x002F, 6},{0x0008, 4},{0x0015, 5} - }, - { - {0x0009, 4},{0x0021, 6},{0x0040, 7},{0x00AD, 8}, - {0x02B0,10},{0x1589,13},{0x1588,13},{0x001C, 5}, - {0x005F, 7},{0x0000, 3},{0x000F, 4},{0x000D, 4}, - {0x000C, 4},{0x0006, 4},{0x0011, 5},{0x002A, 6}, - {0x0057, 7},{0x005E, 7},{0x0041, 7},{0x0159, 9}, - {0x0563,11},{0x158B,13},{0x158A,13},{0x0001, 3}, - {0x0005, 4},{0x0014, 5},{0x003B, 6},{0x002E, 6}, - {0x0004, 4},{0x003A, 6},{0x0007, 4},{0x0016, 5} - }, - { - {0x000E, 4},{0x0007, 5},{0x0046, 7},{0x0045, 7}, - {0x0064, 9},{0x032A,12},{0x0657,13},{0x0018, 5}, - {0x000D, 6},{0x0000, 3},{0x000F, 4},{0x000A, 4}, - {0x000B, 4},{0x001A, 5},{0x0036, 6},{0x0047, 7}, - {0x0044, 7},{0x0018, 7},{0x0033, 8},{0x00CB,10}, - {0x0656,13},{0x0329,12},{0x0328,12},{0x0002, 3}, - {0x0006, 4},{0x0019, 5},{0x000E, 5},{0x0037, 6}, - {0x0009, 4},{0x000F, 5},{0x0002, 4},{0x0010, 5} - }, - { - {0x0003, 3},{0x0018, 5},{0x0023, 6},{0x0077, 7}, - {0x0194, 9},{0x1956,13},{0x32AF,14},{0x003A, 6}, - {0x0076, 7},{0x0002, 3},{0x0001, 3},{0x001F, 5}, - {0x001E, 5},{0x0014, 5},{0x0022, 6},{0x0064, 7}, - {0x0197, 9},{0x0196, 9},{0x032B,10},{0x0654,11}, - {0x32AE,14},{0x1955,13},{0x1954,13},{0x0000, 3}, - {0x0009, 4},{0x001C, 5},{0x0015, 5},{0x0010, 5}, - {0x000D, 4},{0x0017, 5},{0x0016, 5},{0x0033, 6} - }, - { - {0x0005, 3},{0x0006, 4},{0x003E, 6},{0x0010, 5}, - {0x0048, 7},{0x093F,12},{0x24FA,14},{0x0032, 6}, - {0x0067, 7},{0x0002, 3},{0x0001, 3},{0x001B, 5}, - {0x001E, 5},{0x0034, 6},{0x0066, 7},{0x0092, 8}, - {0x0126, 9},{0x024E,10},{0x049E,11},{0x49F7,15}, - {0x49F6,15},{0x24F9,14},{0x24F8,14},{0x0000, 3}, - {0x0007, 4},{0x0018, 5},{0x0011, 5},{0x003F, 6}, - {0x000E, 4},{0x0013, 5},{0x0035, 6},{0x0025, 6} - }, - { - {0x0005, 3},{0x0008, 4},{0x0012, 5},{0x001C, 5}, - {0x001C, 6},{0x00EA, 9},{0x1D75,14},{0x001E, 6}, - {0x0066, 7},{0x0001, 3},{0x0002, 3},{0x001B, 5}, - {0x001A, 5},{0x001F, 6},{0x003B, 7},{0x0074, 8}, - {0x01D6,10},{0x03AF,11},{0x1D74,14},{0x1D77,14}, - {0x1D76,14},{0x0EB9,13},{0x0EB8,13},{0x000F, 4}, - {0x0006, 4},{0x0013, 5},{0x003B, 6},{0x003A, 6}, - {0x0000, 3},{0x0018, 5},{0x0032, 6},{0x0067, 7} - }, - { - {0x0004, 3},{0x000A, 4},{0x001B, 5},{0x000C, 4}, - {0x000D, 5},{0x00E6, 8},{0x0684,11},{0x0072, 7}, - {0x00E7, 8},{0x0002, 3},{0x0001, 3},{0x0017, 5}, - {0x0016, 5},{0x0018, 6},{0x00D1, 8},{0x01A0, 9}, - {0x0686,11},{0x0D0F,12},{0x0D0A,12},{0x1A17,13}, - {0x1A16,13},{0x1A1D,13},{0x1A1C,13},{0x000F, 4}, - {0x001D, 5},{0x000E, 5},{0x0035, 6},{0x0038, 6}, - {0x0000, 3},{0x000F, 5},{0x0019, 6},{0x0069, 7} - }, - { - {0x0003, 3},{0x000C, 4},{0x001B, 5},{0x0000, 3}, - {0x0003, 4},{0x002E, 6},{0x0051, 9},{0x00BC, 8}, - {0x0053, 9},{0x0004, 3},{0x0002, 3},{0x0016, 5}, - {0x0015, 5},{0x0015, 7},{0x0050, 9},{0x00A4,10}, - {0x0294,12},{0x052B,13},{0x052A,13},{0x052D,13}, - {0x052C,13},{0x052F,13},{0x052E,13},{0x000E, 4}, - {0x001A, 5},{0x0004, 5},{0x0028, 6},{0x0029, 6}, - {0x000F, 4},{0x000B, 6},{0x005F, 7},{0x00BD, 8} - }, - { - {0x0003, 4},{0x0009, 6},{0x00D0, 8},{0x01A3, 9}, - {0x0344,10},{0x0D14,12},{0x1A2B,13},{0x0004, 4}, - {0x0015, 7},{0x0000, 3},{0x000F, 4},{0x000B, 4}, - {0x000C, 4},{0x000E, 4},{0x0009, 4},{0x001B, 5}, - {0x000A, 5},{0x0014, 5},{0x000D, 5},{0x002A, 6}, - {0x0014, 7},{0x068B,11},{0x1A2A,13},{0x0008, 4}, - {0x000B, 5},{0x002B, 6},{0x000B, 6},{0x0069, 7}, - {0x0035, 6},{0x0008, 6},{0x0007, 4},{0x000C, 5} - }, - { - {0x000A, 4},{0x003C, 6},{0x0032, 7},{0x0030, 7}, - {0x00C5, 9},{0x0621,12},{0x0620,12},{0x001F, 5}, - {0x0033, 7},{0x0001, 3},{0x0000, 3},{0x000E, 4}, - {0x000D, 4},{0x000C, 4},{0x0004, 4},{0x000D, 5}, - {0x0026, 6},{0x0027, 6},{0x0014, 6},{0x0063, 8}, - {0x0189,10},{0x0623,12},{0x0622,12},{0x000B, 4}, - {0x0012, 5},{0x003D, 6},{0x0022, 6},{0x0015, 6}, - {0x000B, 5},{0x0023, 6},{0x0007, 4},{0x0010, 5} - }, - { - {0x000F, 4},{0x000C, 5},{0x0043, 7},{0x0010, 6}, - {0x0044, 8},{0x0114,10},{0x0455,12},{0x0018, 5}, - {0x0023, 7},{0x0001, 3},{0x0000, 3},{0x000E, 4}, - {0x000D, 4},{0x0009, 4},{0x0019, 5},{0x0009, 5}, - {0x0017, 6},{0x0016, 6},{0x0042, 7},{0x008B, 9}, - {0x0454,12},{0x0457,12},{0x0456,12},{0x000B, 4}, - {0x0015, 5},{0x000A, 5},{0x0029, 6},{0x0020, 6}, - {0x000D, 5},{0x0028, 6},{0x0007, 4},{0x0011, 5} - }, - { - {0x0001, 3},{0x001A, 5},{0x0029, 6},{0x002A, 6}, - {0x00A0, 8},{0x0285,10},{0x1425,13},{0x0002, 5}, - {0x0000, 7},{0x0002, 3},{0x0003, 3},{0x000C, 4}, - {0x000B, 4},{0x0008, 4},{0x0012, 5},{0x0001, 6}, - {0x0051, 7},{0x0001, 7},{0x0143, 9},{0x0508,11}, - {0x1424,13},{0x1427,13},{0x1426,13},{0x000F, 4}, - {0x001C, 5},{0x0003, 5},{0x0037, 6},{0x002B, 6}, - {0x0013, 5},{0x0036, 6},{0x001D, 5},{0x0001, 5} - }, - { - {0x0004, 3},{0x001F, 5},{0x003D, 6},{0x0006, 5}, - {0x0016, 7},{0x0053, 9},{0x014A,11},{0x0034, 6}, - {0x002A, 8},{0x0002, 3},{0x0003, 3},{0x000B, 4}, - {0x000C, 4},{0x001C, 5},{0x0037, 6},{0x0017, 7}, - {0x002B, 8},{0x0028, 8},{0x00A4,10},{0x052D,13}, - {0x052C,13},{0x052F,13},{0x052E,13},{0x0000, 3}, - {0x001D, 5},{0x0007, 5},{0x0004, 5},{0x0035, 6}, - {0x0014, 5},{0x0036, 6},{0x0015, 5},{0x003C, 6} - }, - { - {0x0004, 3},{0x000A, 4},{0x0007, 5},{0x001D, 5}, - {0x0009, 6},{0x01F3, 9},{0x07C7,11},{0x0008, 6}, - {0x01F0, 9},{0x0003, 3},{0x0002, 3},{0x000D, 4}, - {0x000C, 4},{0x0017, 5},{0x007D, 7},{0x01F2, 9}, - {0x07C6,11},{0x07C5,11},{0x1F12,13},{0x3E27,14}, - {0x3E26,14},{0x1F11,13},{0x1F10,13},{0x0000, 3}, - {0x001E, 5},{0x0006, 5},{0x0039, 6},{0x0038, 6}, - {0x003F, 6},{0x002C, 6},{0x0005, 5},{0x002D, 6} - }, - { - {0x0002, 3},{0x0007, 4},{0x0018, 5},{0x0003, 4}, - {0x0005, 5},{0x0035, 7},{0x004F, 9},{0x0012, 7}, - {0x04E5,13},{0x0005, 3},{0x0004, 3},{0x000D, 4}, - {0x000E, 4},{0x0033, 6},{0x0026, 8},{0x009D,10}, - {0x04E4,13},{0x04E7,13},{0x04E6,13},{0x04E1,13}, - {0x04E0,13},{0x04E3,13},{0x04E2,13},{0x0000, 3}, - {0x001F, 5},{0x000C, 5},{0x003D, 6},{0x003C, 6}, - {0x0032, 6},{0x0034, 7},{0x001B, 6},{0x0008, 6} - }, - { - {0x0000, 3},{0x0004, 4},{0x001C, 5},{0x000F, 4}, - {0x0002, 4},{0x0007, 5},{0x0075, 7},{0x00E8, 8}, - {0x1D2A,13},{0x0005, 3},{0x0004, 3},{0x000D, 4}, - {0x000C, 4},{0x0077, 7},{0x0E96,12},{0x3A57,14}, - {0x3A56,14},{0x3A5D,14},{0x3A5C,14},{0x3A5F,14}, - {0x3A5E,14},{0x1D29,13},{0x1D28,13},{0x0003, 3}, - {0x0006, 5},{0x000A, 5},{0x002C, 7},{0x0017, 6}, - {0x0076, 7},{0x01D3, 9},{0x03A4,10},{0x002D, 7} - }, - { - {0x000A, 4},{0x0024, 6},{0x00BF, 8},{0x0085, 8}, - {0x0211,10},{0x0842,12},{0x1087,13},{0x0018, 5}, - {0x0020, 6},{0x0001, 3},{0x0002, 3},{0x000E, 4}, - {0x000D, 4},{0x0007, 4},{0x0013, 5},{0x0025, 6}, - {0x005E, 7},{0x0043, 7},{0x00BE, 8},{0x0109, 9}, - {0x1086,13},{0x0841,12},{0x0840,12},{0x000F, 4}, - {0x0001, 4},{0x0011, 5},{0x0000, 5},{0x002E, 6}, - {0x0019, 5},{0x0001, 5},{0x0006, 4},{0x0016, 5} - }, - { - {0x0002, 3},{0x000F, 5},{0x006F, 7},{0x0061, 7}, - {0x0374,10},{0x1BA8,13},{0x3753,14},{0x0012, 5}, - {0x0036, 6},{0x0000, 3},{0x0001, 3},{0x000A, 4}, - {0x000B, 4},{0x001A, 5},{0x0031, 6},{0x0060, 7}, - {0x00DC, 8},{0x01BB, 9},{0x06EB,11},{0x1BAB,13}, - {0x3752,14},{0x3755,14},{0x3754,14},{0x000E, 4}, - {0x0006, 4},{0x0013, 5},{0x000E, 5},{0x003E, 6}, - {0x0008, 4},{0x001E, 5},{0x0019, 5},{0x003F, 6} - }, - { - {0x0003, 3},{0x001C, 5},{0x0025, 6},{0x0024, 6}, - {0x01DA, 9},{0x1DBD,13},{0x3B7C,14},{0x003C, 6}, - {0x003D, 6},{0x0000, 3},{0x0001, 3},{0x000B, 4}, - {0x000A, 4},{0x000B, 5},{0x0077, 7},{0x00EC, 8}, - {0x03B6,10},{0x076E,11},{0x1DBF,13},{0x76FB,15}, - {0x76FA,15},{0x3B79,14},{0x3B78,14},{0x000D, 4}, - {0x001F, 5},{0x0013, 5},{0x000A, 5},{0x0008, 5}, - {0x000C, 4},{0x0008, 4},{0x0009, 5},{0x003A, 6} - }, - { - {0x0005, 3},{0x0003, 4},{0x0004, 5},{0x0010, 5}, - {0x008F, 8},{0x0475,11},{0x11D1,13},{0x0079, 7}, - {0x0027, 6},{0x0002, 3},{0x0003, 3},{0x0001, 4}, - {0x0000, 4},{0x0026, 6},{0x0046, 7},{0x011C, 9}, - {0x0477,11},{0x08ED,12},{0x11D0,13},{0x11D3,13}, - {0x11D2,13},{0x11D9,13},{0x11D8,13},{0x000D, 4}, - {0x001F, 5},{0x0012, 5},{0x0005, 5},{0x003D, 6}, - {0x000C, 4},{0x000E, 4},{0x0022, 6},{0x0078, 7} - }, - { - {0x0005, 3},{0x000C, 4},{0x001B, 5},{0x0000, 4}, - {0x0006, 6},{0x03E2,10},{0x3E3D,14},{0x000F, 7}, - {0x0034, 6},{0x0003, 3},{0x0002, 3},{0x001E, 5}, - {0x001D, 5},{0x007D, 7},{0x01F0, 9},{0x07C6,11}, - {0x3E3C,14},{0x3E3F,14},{0x3E3E,14},{0x3E39,14}, - {0x3E38,14},{0x3E3B,14},{0x3E3A,14},{0x0008, 4}, - {0x001C, 5},{0x0002, 5},{0x003F, 6},{0x0035, 6}, - {0x0009, 4},{0x0001, 3},{0x000E, 7},{0x00F9, 8} - }, - { - {0x0004, 3},{0x000B, 4},{0x0001, 4},{0x000A, 4}, - {0x001E, 6},{0x00E0, 9},{0x0E1E,13},{0x0071, 8}, - {0x0039, 7},{0x0007, 3},{0x0006, 3},{0x000D, 5}, - {0x000C, 5},{0x0020, 7},{0x01C2,10},{0x1C3F,14}, - {0x1C3E,14},{0x0E19,13},{0x0E18,13},{0x0E1B,13}, - {0x0E1A,13},{0x0E1D,13},{0x0E1C,13},{0x0000, 4}, - {0x0009, 5},{0x001D, 6},{0x001F, 6},{0x0011, 6}, - {0x0005, 4},{0x0001, 3},{0x0043, 8},{0x0042, 8} - }, - { - {0x0004, 3},{0x000D, 4},{0x0007, 4},{0x0002, 3}, - {0x0014, 5},{0x016C, 9},{0x16D1,13},{0x02DF,10}, - {0x016E, 9},{0x0000, 2},{0x0007, 3},{0x002C, 6}, - {0x002B, 6},{0x02DE,10},{0x16D0,13},{0x16D3,13}, - {0x16D2,13},{0x2DB5,14},{0x2DB4,14},{0x2DB7,14}, - {0x2DB6,14},{0x16D9,13},{0x16D8,13},{0x000C, 5}, - {0x002A, 6},{0x005A, 7},{0x001B, 6},{0x001A, 6}, - {0x0017, 5},{0x000C, 4},{0x05B7,11},{0x05B5,11} - }, - { - {0x0002, 2},{0x000F, 4},{0x001C, 5},{0x000C, 4}, - {0x003B, 6},{0x01AC, 9},{0x1AD8,13},{0x35B3,14}, - {0x35B2,14},{0x0001, 2},{0x0000, 2},{0x0069, 7}, - {0x0068, 7},{0x35BD,14},{0x35BC,14},{0x35BF,14}, - {0x35BE,14},{0x35B9,14},{0x35B8,14},{0x35BB,14}, - {0x35BA,14},{0x35B5,14},{0x35B4,14},{0x01A9, 9}, - {0x01A8, 9},{0x035A,10},{0x00D7, 8},{0x00D5, 8}, - {0x003A, 6},{0x001B, 5},{0x35B7,14},{0x35B6,14} - }, - { - {0x0000, 3},{0x0010, 5},{0x0072, 7},{0x0071, 7}, - {0x0154, 9},{0x0AAB,12},{0x0AA8,12},{0x0014, 5}, - {0x0070, 7},{0x0002, 3},{0x0003, 3},{0x000C, 4}, - {0x000B, 4},{0x0003, 4},{0x0011, 5},{0x0073, 7}, - {0x0054, 7},{0x00AB, 8},{0x02AB,10},{0x1553,13}, - {0x1552,13},{0x1555,13},{0x1554,13},{0x000D, 4}, - {0x001E, 5},{0x0012, 5},{0x003E, 6},{0x002B, 6}, - {0x0002, 4},{0x003F, 6},{0x001D, 5},{0x0013, 5} - }, - { - {0x0003, 3},{0x001F, 5},{0x0029, 6},{0x003D, 6}, - {0x000C, 7},{0x0069,10},{0x0345,13},{0x0002, 5}, - {0x0028, 6},{0x0002, 3},{0x0001, 3},{0x000E, 4}, - {0x000C, 4},{0x0015, 5},{0x0007, 6},{0x001B, 8}, - {0x006B,10},{0x006A,10},{0x0344,13},{0x0347,13}, - {0x0346,13},{0x01A1,12},{0x01A0,12},{0x000B, 4}, - {0x001A, 5},{0x0012, 5},{0x0000, 5},{0x003C, 6}, - {0x0008, 4},{0x001B, 5},{0x0013, 5},{0x0001, 5} - }, - { - {0x0004, 3},{0x0004, 4},{0x003F, 6},{0x0014, 5}, - {0x0056, 7},{0x015C, 9},{0x15D5,13},{0x003C, 6}, - {0x002A, 6},{0x0000, 3},{0x0001, 3},{0x000E, 4}, - {0x000D, 4},{0x000C, 5},{0x00AF, 8},{0x02BB,10}, - {0x15D4,13},{0x15D7,13},{0x15D6,13},{0x15D1,13}, - {0x15D0,13},{0x15D3,13},{0x15D2,13},{0x000B, 4}, - {0x0019, 5},{0x000D, 5},{0x003E, 6},{0x0031, 6}, - {0x0007, 4},{0x0005, 4},{0x003D, 6},{0x0030, 6} - }, - { - {0x0005, 3},{0x0008, 4},{0x001A, 5},{0x0000, 4}, - {0x0036, 6},{0x0011, 8},{0x0106,12},{0x000A, 7}, - {0x006E, 7},{0x0002, 3},{0x0003, 3},{0x0003, 4}, - {0x0002, 4},{0x006F, 7},{0x0021, 9},{0x020F,13}, - {0x020E,13},{0x0101,12},{0x0100,12},{0x0103,12}, - {0x0102,12},{0x0105,12},{0x0104,12},{0x000C, 4}, - {0x001E, 5},{0x0003, 5},{0x003E, 6},{0x003F, 6}, - {0x0009, 4},{0x000E, 4},{0x000B, 7},{0x0009, 7} - }, - { - {0x0002, 3},{0x000E, 4},{0x001E, 5},{0x000C, 4}, - {0x001F, 5},{0x006E, 7},{0x00AD,10},{0x00AF,10}, - {0x0014, 7},{0x0004, 3},{0x0003, 3},{0x001A, 5}, - {0x0017, 5},{0x002A, 8},{0x0576,13},{0x0AEF,14}, - {0x0AEE,14},{0x0571,13},{0x0570,13},{0x0573,13}, - {0x0572,13},{0x0575,13},{0x0574,13},{0x0003, 4}, - {0x0016, 5},{0x0004, 5},{0x0036, 6},{0x000B, 6}, - {0x000A, 4},{0x0000, 3},{0x006F, 7},{0x00AC,10} - }, - { - {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3}, - {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13}, - {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6}, - {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13}, - {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13}, - {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3}, - {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8}, - {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14} - }, - { - {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3}, - {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13}, - {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6}, - {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13}, - {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13}, - {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3}, - {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8}, - {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14} - }, - { - {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3}, - {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13}, - {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6}, - {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13}, - {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13}, - {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3}, - {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8}, - {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14} - }, - { - {0x0003, 3},{0x0011, 5},{0x0020, 6},{0x0074, 7}, - {0x010D, 9},{0x0863,12},{0x0860,12},{0x000A, 5}, - {0x0075, 7},{0x0001, 3},{0x0000, 3},{0x000B, 4}, - {0x000A, 4},{0x0018, 5},{0x0038, 6},{0x0042, 7}, - {0x010F, 9},{0x010E, 9},{0x0219,10},{0x10C3,13}, - {0x10C2,13},{0x10C5,13},{0x10C4,13},{0x000F, 4}, - {0x0004, 4},{0x0019, 5},{0x000B, 5},{0x0039, 6}, - {0x0009, 4},{0x001B, 5},{0x001A, 5},{0x003B, 6} - }, - { - {0x0005, 3},{0x0001, 4},{0x003E, 6},{0x0001, 5}, - {0x00E2, 8},{0x1C6F,13},{0x38D9,14},{0x0039, 6}, - {0x001F, 6},{0x0002, 3},{0x0001, 3},{0x0009, 4}, - {0x0008, 4},{0x0000, 5},{0x0070, 7},{0x01C7, 9}, - {0x038C,10},{0x071A,11},{0x38D8,14},{0x38DB,14}, - {0x38DA,14},{0x38DD,14},{0x38DC,14},{0x000D, 4}, - {0x001D, 5},{0x000E, 5},{0x003F, 6},{0x003C, 6}, - {0x000C, 4},{0x0006, 4},{0x003D, 6},{0x001E, 6} - }, - { - {0x0006, 3},{0x000B, 4},{0x0011, 5},{0x001E, 5}, - {0x0074, 7},{0x03AA,10},{0x1D5C,13},{0x0001, 6}, - {0x0021, 6},{0x0001, 3},{0x0002, 3},{0x0007, 4}, - {0x0006, 4},{0x003E, 6},{0x00EB, 8},{0x01D4, 9}, - {0x0EAF,12},{0x3ABB,14},{0x3ABA,14},{0x1D59,13}, - {0x1D58,13},{0x1D5B,13},{0x1D5A,13},{0x000A, 4}, - {0x001C, 5},{0x0001, 5},{0x003F, 6},{0x003B, 6}, - {0x0001, 4},{0x0009, 4},{0x0020, 6},{0x0000, 6} - }, - { - {0x0004, 3},{0x000A, 4},{0x0017, 5},{0x0004, 4}, - {0x0016, 6},{0x016A, 9},{0x16B1,13},{0x0017, 7}, - {0x005B, 7},{0x0006, 3},{0x0007, 3},{0x0001, 4}, - {0x0000, 4},{0x000A, 6},{0x02D7,10},{0x0B5A,12}, - {0x16B0,13},{0x16B3,13},{0x16B2,13},{0x2D6D,14}, - {0x2D6C,14},{0x2D6F,14},{0x2D6E,14},{0x0006, 4}, - {0x000A, 5},{0x0004, 5},{0x002C, 6},{0x0017, 6}, - {0x0003, 4},{0x0007, 4},{0x0016, 7},{0x00B4, 8} - }, - { - {0x0005, 3},{0x000D, 4},{0x0005, 4},{0x0009, 4}, - {0x0033, 6},{0x0193, 9},{0x192C,13},{0x0061, 8}, - {0x0031, 7},{0x0000, 2},{0x0007, 3},{0x0010, 5}, - {0x0011, 5},{0x00C8, 8},{0x192F,13},{0x325B,14}, - {0x325A,14},{0x1929,13},{0x1928,13},{0x192B,13}, - {0x192A,13},{0x325D,14},{0x325C,14},{0x0018, 5}, - {0x001A, 6},{0x001B, 6},{0x0065, 7},{0x0019, 6}, - {0x0004, 4},{0x0007, 4},{0x0060, 8},{0x0324,10} - }, - { - {0x0006, 3},{0x0000, 3},{0x0002, 4},{0x000F, 4}, - {0x0039, 6},{0x01D9, 9},{0x1D82,13},{0x0761,11}, - {0x03BE,10},{0x0001, 2},{0x0002, 2},{0x000F, 6}, - {0x000E, 6},{0x0762,11},{0x3B07,14},{0x3B06,14}, - {0x3B1D,14},{0x3B1C,14},{0x3B1F,14},{0x3B1E,14}, - {0x3B19,14},{0x3B18,14},{0x3B1B,14},{0x0038, 6}, - {0x01DE, 9},{0x00ED, 8},{0x03BF,10},{0x00EE, 8}, - {0x003A, 6},{0x0006, 5},{0x0EC0,12},{0x3B1A,14} - }, - { - {0x0000, 2},{0x0002, 3},{0x000F, 5},{0x0006, 4}, - {0x001C, 6},{0x01D0,10},{0x0E8C,13},{0x1D1B,14}, - {0x1D1A,14},{0x0003, 2},{0x0002, 2},{0x00EA, 9}, - {0x00E9, 9},{0x0E89,13},{0x0E88,13},{0x0E8B,13}, - {0x0E8A,13},{0x1D65,14},{0x1D64,14},{0x1D67,14}, - {0x1D66,14},{0x1D61,14},{0x1D60,14},{0x03AD,11}, - {0x1D63,14},{0x1D62,14},{0x1D1D,14},{0x1D1C,14}, - {0x003B, 7},{0x01D7,10},{0x1D1F,14},{0x1D1E,14} - }, - { - {0x0002, 2},{0x000F, 4},{0x001C, 5},{0x000C, 4}, - {0x003B, 6},{0x01AC, 9},{0x1AD8,13},{0x35B3,14}, - {0x35B2,14},{0x0001, 2},{0x0000, 2},{0x0069, 7}, - {0x0068, 7},{0x35BD,14},{0x35BC,14},{0x35BF,14}, - {0x35BE,14},{0x35B9,14},{0x35B8,14},{0x35BB,14}, - {0x35BA,14},{0x35B5,14},{0x35B4,14},{0x01A9, 9}, - {0x01A8, 9},{0x035A,10},{0x00D7, 8},{0x00D5, 8}, - {0x003A, 6},{0x001B, 5},{0x35B7,14},{0x35B6,14} - } -}; - - - -/*A description of a Huffman code value used when encoding the tree.*/ -typedef struct{ - /*The bit pattern, left-shifted so that the MSB of all patterns is - aligned.*/ - ogg_uint32_t pattern; - /*The amount the bit pattern was shifted.*/ - int shift; - /*The token this bit pattern represents.*/ - int token; -}oc_huff_entry; - - - -/*Compares two oc_huff_entry structures by their bit patterns. - _c1: The first entry to compare. - _c2: The second entry to compare. - Return: <0 if _c1<_c2, >0 if _c1>_c2.*/ -static int huff_entry_cmp(const void *_c1,const void *_c2){ - ogg_uint32_t b1; - ogg_uint32_t b2; - b1=((const oc_huff_entry *)_c1)->pattern; - b2=((const oc_huff_entry *)_c2)->pattern; - return b1b2?1:0; -} - -/*Encodes a description of the given Huffman tables. - Although the codes are stored in the encoder as flat arrays, in the bit - stream and in the decoder they are structured as a tree. - This function recovers the tree structure from the flat array and then - writes it out. - Note that the codes MUST form a Huffman code, and not merely a prefix-free - code, since the binary tree is assumed to be full. - _opb: The buffer to store the tree in. - _codes: The Huffman tables to pack. - Return: 0 on success, or a negative value if one of the given Huffman tables - does not form a full, prefix-free code.*/ -int oc_huff_codes_pack(oggpack_buffer *_opb, - const th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]){ - int i; - for(i=0;i>1)<<(maxlen+1>>1))-1; - /*Copy over the codes into our temporary workspace. - The bit patterns are aligned, and the original entry each code is from - is stored as well.*/ - for(j=0;jentries[j].shift;bpos--)oggpackB_write(_opb,0,1); - /*Mark this as a leaf node, and write its value.*/ - oggpackB_write(_opb,1,1); - oggpackB_write(_opb,entries[j].token,5); - /*For each 1 branch we've descended, back up the tree until we reach a - 0 branch.*/ - bit=1< -#include "internal.h" -#include "dct.h" - -/*Performs an inverse 8 point Type-II DCT transform. - The output is scaled by a factor of 2 relative to the orthonormal version of - the transform. - _y: The buffer to store the result in. - Data will be placed in every 8th entry (e.g., in a column of an 8x8 - block). - _x: The input coefficients. - The first 8 entries are used (e.g., from a row of an 8x8 block).*/ -static void idct8(ogg_int16_t *_y,const ogg_int16_t _x[8]){ - ogg_int32_t t[8]; - ogg_int32_t r; - /*Stage 1:*/ - /*0-1 butterfly.*/ - t[0]=OC_C4S4*(ogg_int16_t)(_x[0]+_x[4])>>16; - t[1]=OC_C4S4*(ogg_int16_t)(_x[0]-_x[4])>>16; - /*2-3 rotation by 6pi/16.*/ - t[2]=(OC_C6S2*_x[2]>>16)-(OC_C2S6*_x[6]>>16); - t[3]=(OC_C2S6*_x[2]>>16)+(OC_C6S2*_x[6]>>16); - /*4-7 rotation by 7pi/16.*/ - t[4]=(OC_C7S1*_x[1]>>16)-(OC_C1S7*_x[7]>>16); - /*5-6 rotation by 3pi/16.*/ - t[5]=(OC_C3S5*_x[5]>>16)-(OC_C5S3*_x[3]>>16); - t[6]=(OC_C5S3*_x[5]>>16)+(OC_C3S5*_x[3]>>16); - t[7]=(OC_C1S7*_x[1]>>16)+(OC_C7S1*_x[7]>>16); - /*Stage 2:*/ - /*4-5 butterfly.*/ - r=t[4]+t[5]; - t[5]=OC_C4S4*(ogg_int16_t)(t[4]-t[5])>>16; - t[4]=r; - /*7-6 butterfly.*/ - r=t[7]+t[6]; - t[6]=OC_C4S4*(ogg_int16_t)(t[7]-t[6])>>16; - t[7]=r; - /*Stage 3:*/ - /*0-3 butterfly.*/ - r=t[0]+t[3]; - t[3]=t[0]-t[3]; - t[0]=r; - /*1-2 butterfly.*/ - r=t[1]+t[2]; - t[2]=t[1]-t[2]; - t[1]=r; - /*6-5 butterfly.*/ - r=t[6]+t[5]; - t[5]=t[6]-t[5]; - t[6]=r; - /*Stage 4:*/ - /*0-7 butterfly.*/ - _y[0<<3]=(ogg_int16_t)(t[0]+t[7]); - /*1-6 butterfly.*/ - _y[1<<3]=(ogg_int16_t)(t[1]+t[6]); - /*2-5 butterfly.*/ - _y[2<<3]=(ogg_int16_t)(t[2]+t[5]); - /*3-4 butterfly.*/ - _y[3<<3]=(ogg_int16_t)(t[3]+t[4]); - _y[4<<3]=(ogg_int16_t)(t[3]-t[4]); - _y[5<<3]=(ogg_int16_t)(t[2]-t[5]); - _y[6<<3]=(ogg_int16_t)(t[1]-t[6]); - _y[7<<3]=(ogg_int16_t)(t[0]-t[7]); -} - -/*Performs an inverse 8 point Type-II DCT transform. - The output is scaled by a factor of 2 relative to the orthonormal version of - the transform. - _y: The buffer to store the result in. - Data will be placed in every 8th entry (e.g., in a column of an 8x8 - block). - _x: The input coefficients. - Only the first 4 entries are used. - The other 4 are assumed to be 0.*/ -static void idct8_4(ogg_int16_t *_y,const ogg_int16_t _x[8]){ - ogg_int32_t t[8]; - ogg_int32_t r; - /*Stage 1:*/ - t[0]=OC_C4S4*_x[0]>>16; - t[2]=OC_C6S2*_x[2]>>16; - t[3]=OC_C2S6*_x[2]>>16; - t[4]=OC_C7S1*_x[1]>>16; - t[5]=-(OC_C5S3*_x[3]>>16); - t[6]=OC_C3S5*_x[3]>>16; - t[7]=OC_C1S7*_x[1]>>16; - /*Stage 2:*/ - r=t[4]+t[5]; - t[5]=OC_C4S4*(ogg_int16_t)(t[4]-t[5])>>16; - t[4]=r; - r=t[7]+t[6]; - t[6]=OC_C4S4*(ogg_int16_t)(t[7]-t[6])>>16; - t[7]=r; - /*Stage 3:*/ - t[1]=t[0]+t[2]; - t[2]=t[0]-t[2]; - r=t[0]+t[3]; - t[3]=t[0]-t[3]; - t[0]=r; - r=t[6]+t[5]; - t[5]=t[6]-t[5]; - t[6]=r; - /*Stage 4:*/ - _y[0<<3]=(ogg_int16_t)(t[0]+t[7]); - _y[1<<3]=(ogg_int16_t)(t[1]+t[6]); - _y[2<<3]=(ogg_int16_t)(t[2]+t[5]); - _y[3<<3]=(ogg_int16_t)(t[3]+t[4]); - _y[4<<3]=(ogg_int16_t)(t[3]-t[4]); - _y[5<<3]=(ogg_int16_t)(t[2]-t[5]); - _y[6<<3]=(ogg_int16_t)(t[1]-t[6]); - _y[7<<3]=(ogg_int16_t)(t[0]-t[7]); -} - -/*Performs an inverse 8 point Type-II DCT transform. - The output is scaled by a factor of 2 relative to the orthonormal version of - the transform. - _y: The buffer to store the result in. - Data will be placed in every 8th entry (e.g., in a column of an 8x8 - block). - _x: The input coefficients. - Only the first 3 entries are used. - The other 5 are assumed to be 0.*/ -static void idct8_3(ogg_int16_t *_y,const ogg_int16_t _x[8]){ - ogg_int32_t t[8]; - ogg_int32_t r; - /*Stage 1:*/ - t[0]=OC_C4S4*_x[0]>>16; - t[2]=OC_C6S2*_x[2]>>16; - t[3]=OC_C2S6*_x[2]>>16; - t[4]=OC_C7S1*_x[1]>>16; - t[7]=OC_C1S7*_x[1]>>16; - /*Stage 2:*/ - t[5]=OC_C4S4*t[4]>>16; - t[6]=OC_C4S4*t[7]>>16; - /*Stage 3:*/ - t[1]=t[0]+t[2]; - t[2]=t[0]-t[2]; - r=t[0]+t[3]; - t[3]=t[0]-t[3]; - t[0]=r; - r=t[6]+t[5]; - t[5]=t[6]-t[5]; - t[6]=r; - /*Stage 4:*/ - _y[0<<3]=(ogg_int16_t)(t[0]+t[7]); - _y[1<<3]=(ogg_int16_t)(t[1]+t[6]); - _y[2<<3]=(ogg_int16_t)(t[2]+t[5]); - _y[3<<3]=(ogg_int16_t)(t[3]+t[4]); - _y[4<<3]=(ogg_int16_t)(t[3]-t[4]); - _y[5<<3]=(ogg_int16_t)(t[2]-t[5]); - _y[6<<3]=(ogg_int16_t)(t[1]-t[6]); - _y[7<<3]=(ogg_int16_t)(t[0]-t[7]); -} - -/*Performs an inverse 8 point Type-II DCT transform. - The output is scaled by a factor of 2 relative to the orthonormal version of - the transform. - _y: The buffer to store the result in. - Data will be placed in every 8th entry (e.g., in a column of an 8x8 - block). - _x: The input coefficients. - Only the first 2 entries are used. - The other 6 are assumed to be 0.*/ -static void idct8_2(ogg_int16_t *_y,const ogg_int16_t _x[8]){ - ogg_int32_t t[8]; - ogg_int32_t r; - /*Stage 1:*/ - t[0]=OC_C4S4*_x[0]>>16; - t[4]=OC_C7S1*_x[1]>>16; - t[7]=OC_C1S7*_x[1]>>16; - /*Stage 2:*/ - t[5]=OC_C4S4*t[4]>>16; - t[6]=OC_C4S4*t[7]>>16; - /*Stage 3:*/ - r=t[6]+t[5]; - t[5]=t[6]-t[5]; - t[6]=r; - /*Stage 4:*/ - _y[0<<3]=(ogg_int16_t)(t[0]+t[7]); - _y[1<<3]=(ogg_int16_t)(t[0]+t[6]); - _y[2<<3]=(ogg_int16_t)(t[0]+t[5]); - _y[3<<3]=(ogg_int16_t)(t[0]+t[4]); - _y[4<<3]=(ogg_int16_t)(t[0]-t[4]); - _y[5<<3]=(ogg_int16_t)(t[0]-t[5]); - _y[6<<3]=(ogg_int16_t)(t[0]-t[6]); - _y[7<<3]=(ogg_int16_t)(t[0]-t[7]); -} - -/*Performs an inverse 8 point Type-II DCT transform. - The output is scaled by a factor of 2 relative to the orthonormal version of - the transform. - _y: The buffer to store the result in. - Data will be placed in every 8th entry (e.g., in a column of an 8x8 - block). - _x: The input coefficients. - Only the first entry is used. - The other 7 are assumed to be 0.*/ -static void idct8_1(ogg_int16_t *_y,const ogg_int16_t _x[1]){ - _y[0<<3]=_y[1<<3]=_y[2<<3]=_y[3<<3]= - _y[4<<3]=_y[5<<3]=_y[6<<3]=_y[7<<3]=(ogg_int16_t)(OC_C4S4*_x[0]>>16); -} - -/*Performs an inverse 8x8 Type-II DCT transform. - The input is assumed to be scaled by a factor of 4 relative to orthonormal - version of the transform. - All coefficients but the first 3 in zig-zag scan order are assumed to be 0: - x x 0 0 0 0 0 0 - x 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - _y: The buffer to store the result in. - This may be the same as _x. - _x: The input coefficients.*/ -static void oc_idct8x8_3(ogg_int16_t _y[64],const ogg_int16_t _x[64]){ - const ogg_int16_t *in; - ogg_int16_t *end; - ogg_int16_t *out; - ogg_int16_t w[64]; - /*Transform rows of x into columns of w.*/ - idct8_2(w,_x); - idct8_1(w+1,_x+8); - /*Transform rows of w into columns of y.*/ - for(in=w,out=_y,end=out+8;out>4); -} - -/*Performs an inverse 8x8 Type-II DCT transform. - The input is assumed to be scaled by a factor of 4 relative to orthonormal - version of the transform. - All coefficients but the first 10 in zig-zag scan order are assumed to be 0: - x x x x 0 0 0 0 - x x x 0 0 0 0 0 - x x 0 0 0 0 0 0 - x 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 - _y: The buffer to store the result in. - This may be the same as _x. - _x: The input coefficients.*/ -static void oc_idct8x8_10(ogg_int16_t _y[64],const ogg_int16_t _x[64]){ - const ogg_int16_t *in; - ogg_int16_t *end; - ogg_int16_t *out; - ogg_int16_t w[64]; - /*Transform rows of x into columns of w.*/ - idct8_4(w,_x); - idct8_3(w+1,_x+8); - idct8_2(w+2,_x+16); - idct8_1(w+3,_x+24); - /*Transform rows of w into columns of y.*/ - for(in=w,out=_y,end=out+8;out>4); -} - -/*Performs an inverse 8x8 Type-II DCT transform. - The input is assumed to be scaled by a factor of 4 relative to orthonormal - version of the transform. - _y: The buffer to store the result in. - This may be the same as _x. - _x: The input coefficients.*/ -static void oc_idct8x8_slow(ogg_int16_t _y[64],const ogg_int16_t _x[64]){ - const ogg_int16_t *in; - ogg_int16_t *end; - ogg_int16_t *out; - ogg_int16_t w[64]; - /*Transform rows of x into columns of w.*/ - for(in=_x,out=w,end=out+8;out>4); -} - -void oc_idct8x8(const oc_theora_state *_state,ogg_int16_t _y[64], - int _last_zzi){ - (*_state->opt_vtable.idct8x8)(_y,_last_zzi); -} - -/*Performs an inverse 8x8 Type-II DCT transform. - The input is assumed to be scaled by a factor of 4 relative to orthonormal - version of the transform.*/ -void oc_idct8x8_c(ogg_int16_t _y[64],int _last_zzi){ - /*_last_zzi is subtly different from an actual count of the number of - coefficients we decoded for this block. - It contains the value of zzi BEFORE the final token in the block was - decoded. - In most cases this is an EOB token (the continuation of an EOB run from a - previous block counts), and so this is the same as the coefficient count. - However, in the case that the last token was NOT an EOB token, but filled - the block up with exactly 64 coefficients, _last_zzi will be less than 64. - Provided the last token was not a pure zero run, the minimum value it can - be is 46, and so that doesn't affect any of the cases in this routine. - However, if the last token WAS a pure zero run of length 63, then _last_zzi - will be 1 while the number of coefficients decoded is 64. - Thus, we will trigger the following special case, where the real - coefficient count would not. - Note also that a zero run of length 64 will give _last_zzi a value of 0, - but we still process the DC coefficient, which might have a non-zero value - due to DC prediction. - Although convoluted, this is arguably the correct behavior: it allows us to - use a smaller transform when the block ends with a long zero run instead - of a normal EOB token. - It could be smarter... multiple separate zero runs at the end of a block - will fool it, but an encoder that generates these really deserves what it - gets. - Needless to say we inherited this approach from VP3.*/ - /*Then perform the iDCT.*/ - if(_last_zzi<3)oc_idct8x8_3(_y,_y); - else if(_last_zzi<10)oc_idct8x8_10(_y,_y); - else oc_idct8x8_slow(_y,_y); -} diff --git a/Engine/lib/libtheora/lib/info.c b/Engine/lib/libtheora/lib/info.c deleted file mode 100644 index 6b9762978..000000000 --- a/Engine/lib/libtheora/lib/info.c +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: info.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include -#include -#include -#include "internal.h" - - - -/*This is more or less the same as strncasecmp, but that doesn't exist - everywhere, and this is a fairly trivial function, so we include it. - Note: We take advantage of the fact that we know _n is less than or equal to - the length of at least one of the strings.*/ -static int oc_tagcompare(const char *_s1,const char *_s2,int _n){ - int c; - for(c=0;c<_n;c++){ - if(toupper(_s1[c])!=toupper(_s2[c]))return !0; - } - return _s1[c]!='='; -} - - - -void th_info_init(th_info *_info){ - memset(_info,0,sizeof(*_info)); - _info->version_major=TH_VERSION_MAJOR; - _info->version_minor=TH_VERSION_MINOR; - _info->version_subminor=TH_VERSION_SUB; - _info->keyframe_granule_shift=6; -} - -void th_info_clear(th_info *_info){ - memset(_info,0,sizeof(*_info)); -} - - - -void th_comment_init(th_comment *_tc){ - memset(_tc,0,sizeof(*_tc)); -} - -void th_comment_add(th_comment *_tc,char *_comment){ - char **user_comments; - int *comment_lengths; - int comment_len; - user_comments=_ogg_realloc(_tc->user_comments, - (_tc->comments+2)*sizeof(*_tc->user_comments)); - if(user_comments==NULL)return; - _tc->user_comments=user_comments; - comment_lengths=_ogg_realloc(_tc->comment_lengths, - (_tc->comments+2)*sizeof(*_tc->comment_lengths)); - if(comment_lengths==NULL)return; - _tc->comment_lengths=comment_lengths; - comment_len=strlen(_comment); - comment_lengths[_tc->comments]=comment_len; - user_comments[_tc->comments]=_ogg_malloc(comment_len+1); - if(user_comments[_tc->comments]==NULL)return; - memcpy(_tc->user_comments[_tc->comments],_comment,comment_len+1); - _tc->comments++; - _tc->user_comments[_tc->comments]=NULL; -} - -void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val){ - char *comment; - int tag_len; - int val_len; - tag_len=strlen(_tag); - val_len=strlen(_val); - /*+2 for '=' and '\0'.*/ - comment=_ogg_malloc(tag_len+val_len+2); - if(comment==NULL)return; - memcpy(comment,_tag,tag_len); - comment[tag_len]='='; - memcpy(comment+tag_len+1,_val,val_len+1); - th_comment_add(_tc,comment); - _ogg_free(comment); -} - -char *th_comment_query(th_comment *_tc,char *_tag,int _count){ - long i; - int found; - int tag_len; - tag_len=strlen(_tag); - found=0; - for(i=0;i<_tc->comments;i++){ - if(!oc_tagcompare(_tc->user_comments[i],_tag,tag_len)){ - /*We return a pointer to the data, not a copy.*/ - if(_count==found++)return _tc->user_comments[i]+tag_len+1; - } - } - /*Didn't find anything.*/ - return NULL; -} - -int th_comment_query_count(th_comment *_tc,char *_tag){ - long i; - int tag_len; - int count; - tag_len=strlen(_tag); - count=0; - for(i=0;i<_tc->comments;i++){ - if(!oc_tagcompare(_tc->user_comments[i],_tag,tag_len))count++; - } - return count; -} - -void th_comment_clear(th_comment *_tc){ - if(_tc!=NULL){ - long i; - for(i=0;i<_tc->comments;i++)_ogg_free(_tc->user_comments[i]); - _ogg_free(_tc->user_comments); - _ogg_free(_tc->comment_lengths); - _ogg_free(_tc->vendor); - memset(_tc,0,sizeof(*_tc)); - } -} diff --git a/Engine/lib/libtheora/lib/internal.c b/Engine/lib/libtheora/lib/internal.c deleted file mode 100644 index 0fe4f63e7..000000000 --- a/Engine/lib/libtheora/lib/internal.c +++ /dev/null @@ -1,262 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: internal.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include -#include -#include -#include "internal.h" - - - -/*A map from the index in the zig zag scan to the coefficient number in a - block. - All zig zag indices beyond 63 are sent to coefficient 64, so that zero runs - past the end of a block in bogus streams get mapped to a known location.*/ -const unsigned char OC_FZIG_ZAG[128]={ - 0, 1, 8,16, 9, 2, 3,10, - 17,24,32,25,18,11, 4, 5, - 12,19,26,33,40,48,41,34, - 27,20,13, 6, 7,14,21,28, - 35,42,49,56,57,50,43,36, - 29,22,15,23,30,37,44,51, - 58,59,52,45,38,31,39,46, - 53,60,61,54,47,55,62,63, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64 -}; - -/*A map from the coefficient number in a block to its index in the zig zag - scan.*/ -const unsigned char OC_IZIG_ZAG[64]={ - 0, 1, 5, 6,14,15,27,28, - 2, 4, 7,13,16,26,29,42, - 3, 8,12,17,25,30,41,43, - 9,11,18,24,31,40,44,53, - 10,19,23,32,39,45,52,54, - 20,22,33,38,46,51,55,60, - 21,34,37,47,50,56,59,61, - 35,36,48,49,57,58,62,63 -}; - -/*A map from physical macro block ordering to bitstream macro block - ordering within a super block.*/ -const unsigned char OC_MB_MAP[2][2]={{0,3},{1,2}}; - -/*A list of the indices in the oc_mb.map array that can be valid for each of - the various chroma decimation types.*/ -const unsigned char OC_MB_MAP_IDXS[TH_PF_NFORMATS][12]={ - {0,1,2,3,4,8}, - {0,1,2,3,4,5,8,9}, - {0,1,2,3,4,6,8,10}, - {0,1,2,3,4,5,6,7,8,9,10,11} -}; - -/*The number of indices in the oc_mb.map array that can be valid for each of - the various chroma decimation types.*/ -const unsigned char OC_MB_MAP_NIDXS[TH_PF_NFORMATS]={6,8,8,12}; - -/*The number of extra bits that are coded with each of the DCT tokens. - Each DCT token has some fixed number of additional bits (possibly 0) stored - after the token itself, containing, for example, coefficient magnitude, - sign bits, etc.*/ -const unsigned char OC_DCT_TOKEN_EXTRA_BITS[TH_NDCT_TOKENS]={ - 0,0,0,2,3,4,12,3,6, - 0,0,0,0, - 1,1,1,1,2,3,4,5,6,10, - 1,1,1,1,1,3,4, - 2,3 -}; - - - -int oc_ilog(unsigned _v){ - int ret; - for(ret=0;_v;ret++)_v>>=1; - return ret; -} - - - -/*The function used to fill in the chroma plane motion vectors for a macro - block when 4 different motion vectors are specified in the luma plane. - This version is for use with chroma decimated in the X and Y directions - (4:2:0). - _cbmvs: The chroma block-level motion vectors to fill in. - _lbmvs: The luma block-level motion vectors.*/ -static void oc_set_chroma_mvs00(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){ - int dx; - int dy; - dx=_lbmvs[0][0]+_lbmvs[1][0]+_lbmvs[2][0]+_lbmvs[3][0]; - dy=_lbmvs[0][1]+_lbmvs[1][1]+_lbmvs[2][1]+_lbmvs[3][1]; - _cbmvs[0][0]=(signed char)OC_DIV_ROUND_POW2(dx,2,2); - _cbmvs[0][1]=(signed char)OC_DIV_ROUND_POW2(dy,2,2); -} - -/*The function used to fill in the chroma plane motion vectors for a macro - block when 4 different motion vectors are specified in the luma plane. - This version is for use with chroma decimated in the Y direction. - _cbmvs: The chroma block-level motion vectors to fill in. - _lbmvs: The luma block-level motion vectors.*/ -static void oc_set_chroma_mvs01(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){ - int dx; - int dy; - dx=_lbmvs[0][0]+_lbmvs[2][0]; - dy=_lbmvs[0][1]+_lbmvs[2][1]; - _cbmvs[0][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1); - _cbmvs[0][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1); - dx=_lbmvs[1][0]+_lbmvs[3][0]; - dy=_lbmvs[1][1]+_lbmvs[3][1]; - _cbmvs[1][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1); - _cbmvs[1][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1); -} - -/*The function used to fill in the chroma plane motion vectors for a macro - block when 4 different motion vectors are specified in the luma plane. - This version is for use with chroma decimated in the X direction (4:2:2). - _cbmvs: The chroma block-level motion vectors to fill in. - _lbmvs: The luma block-level motion vectors.*/ -static void oc_set_chroma_mvs10(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){ - int dx; - int dy; - dx=_lbmvs[0][0]+_lbmvs[1][0]; - dy=_lbmvs[0][1]+_lbmvs[1][1]; - _cbmvs[0][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1); - _cbmvs[0][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1); - dx=_lbmvs[2][0]+_lbmvs[3][0]; - dy=_lbmvs[2][1]+_lbmvs[3][1]; - _cbmvs[2][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1); - _cbmvs[2][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1); -} - -/*The function used to fill in the chroma plane motion vectors for a macro - block when 4 different motion vectors are specified in the luma plane. - This version is for use with no chroma decimation (4:4:4). - _cbmvs: The chroma block-level motion vectors to fill in. - _lmbmv: The luma macro-block level motion vector to fill in for use in - prediction. - _lbmvs: The luma block-level motion vectors.*/ -static void oc_set_chroma_mvs11(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){ - memcpy(_cbmvs,_lbmvs,4*sizeof(_lbmvs[0])); -} - -/*A table of functions used to fill in the chroma plane motion vectors for a - macro block when 4 different motion vectors are specified in the luma - plane.*/ -const oc_set_chroma_mvs_func OC_SET_CHROMA_MVS_TABLE[TH_PF_NFORMATS]={ - (oc_set_chroma_mvs_func)oc_set_chroma_mvs00, - (oc_set_chroma_mvs_func)oc_set_chroma_mvs01, - (oc_set_chroma_mvs_func)oc_set_chroma_mvs10, - (oc_set_chroma_mvs_func)oc_set_chroma_mvs11 -}; - - - -void **oc_malloc_2d(size_t _height,size_t _width,size_t _sz){ - size_t rowsz; - size_t colsz; - size_t datsz; - char *ret; - colsz=_height*sizeof(void *); - rowsz=_sz*_width; - datsz=rowsz*_height; - /*Alloc array and row pointers.*/ - ret=(char *)_ogg_malloc(datsz+colsz); - if(ret==NULL)return NULL; - /*Initialize the array.*/ - if(ret!=NULL){ - size_t i; - void **p; - char *datptr; - p=(void **)ret; - i=_height; - for(datptr=ret+colsz;i-->0;p++,datptr+=rowsz)*p=(void *)datptr; - } - return (void **)ret; -} - -void **oc_calloc_2d(size_t _height,size_t _width,size_t _sz){ - size_t colsz; - size_t rowsz; - size_t datsz; - char *ret; - colsz=_height*sizeof(void *); - rowsz=_sz*_width; - datsz=rowsz*_height; - /*Alloc array and row pointers.*/ - ret=(char *)_ogg_calloc(datsz+colsz,1); - if(ret==NULL)return NULL; - /*Initialize the array.*/ - if(ret!=NULL){ - size_t i; - void **p; - char *datptr; - p=(void **)ret; - i=_height; - for(datptr=ret+colsz;i-->0;p++,datptr+=rowsz)*p=(void *)datptr; - } - return (void **)ret; -} - -void oc_free_2d(void *_ptr){ - _ogg_free(_ptr); -} - -/*Fills in a Y'CbCr buffer with a pointer to the image data in the first - buffer, but with the opposite vertical orientation. - _dst: The destination buffer. - This can be the same as _src. - _src: The source buffer.*/ -void oc_ycbcr_buffer_flip(th_ycbcr_buffer _dst, - const th_ycbcr_buffer _src){ - int pli; - for(pli=0;pli<3;pli++){ - _dst[pli].width=_src[pli].width; - _dst[pli].height=_src[pli].height; - _dst[pli].stride=-_src[pli].stride; - _dst[pli].data=_src[pli].data - +(1-_dst[pli].height)*(ptrdiff_t)_dst[pli].stride; - } -} - -const char *th_version_string(void){ - return OC_VENDOR_STRING; -} - -ogg_uint32_t th_version_number(void){ - return (TH_VERSION_MAJOR<<16)+(TH_VERSION_MINOR<<8)+TH_VERSION_SUB; -} - -/*Determines the packet type. - Note that this correctly interprets a 0-byte packet as a video data packet. - Return: 1 for a header packet, 0 for a data packet.*/ -int th_packet_isheader(ogg_packet *_op){ - return _op->bytes>0?_op->packet[0]>>7:0; -} - -/*Determines the frame type of a video data packet. - Note that this correctly interprets a 0-byte packet as a delta frame. - Return: 1 for a key frame, 0 for a delta frame, and -1 for a header - packet.*/ -int th_packet_iskeyframe(ogg_packet *_op){ - return _op->bytes<=0?0:_op->packet[0]&0x80?-1:!(_op->packet[0]&0x40); -} diff --git a/Engine/lib/libtheora/lib/internal.h b/Engine/lib/libtheora/lib/internal.h deleted file mode 100644 index d81263e13..000000000 --- a/Engine/lib/libtheora/lib/internal.h +++ /dev/null @@ -1,509 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: internal.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#if !defined(_internal_H) -# define _internal_H (1) -# include -# include -# if defined(HAVE_CONFIG_H) -# include -# endif -# include "theora/codec.h" -# include "theora/theora.h" - -# if defined(_MSC_VER) -/*Disable missing EMMS warnings.*/ -# pragma warning(disable:4799) -/*Thank you Microsoft, I know the order of operations.*/ -# pragma warning(disable:4554) -# endif -/*You, too, gcc.*/ -# if defined(__GNUC_PREREQ) -# if __GNUC_PREREQ(4,2) -# pragma GCC diagnostic ignored "-Wparentheses" -# endif -# endif - -# include "ocintrin.h" -# include "huffman.h" -# include "quant.h" - -/*Some assembly constructs require aligned operands.*/ -# if defined(OC_X86_ASM) -# if defined(__GNUC__) -# define OC_ALIGN8(expr) expr __attribute__((aligned(8))) -# define OC_ALIGN16(expr) expr __attribute__((aligned(16))) -# elif defined(_MSC_VER) -# define OC_ALIGN8(expr) __declspec (align(8)) expr -# define OC_ALIGN16(expr) __declspec (align(16)) expr -# endif -# endif -# if !defined(OC_ALIGN8) -# define OC_ALIGN8(expr) expr -# endif -# if !defined(OC_ALIGN16) -# define OC_ALIGN16(expr) expr -# endif - - - -typedef struct oc_sb_flags oc_sb_flags; -typedef struct oc_border_info oc_border_info; -typedef struct oc_fragment oc_fragment; -typedef struct oc_fragment_plane oc_fragment_plane; -typedef struct oc_base_opt_vtable oc_base_opt_vtable; -typedef struct oc_base_opt_data oc_base_opt_data; -typedef struct oc_state_dispatch_vtable oc_state_dispatch_vtable; -typedef struct oc_theora_state oc_theora_state; - - - -/*This library's version.*/ -# define OC_VENDOR_STRING "Xiph.Org libtheora 1.1 20090822 (Thusnelda)" - -/*Theora bitstream version.*/ -# define TH_VERSION_MAJOR (3) -# define TH_VERSION_MINOR (2) -# define TH_VERSION_SUB (1) -# define TH_VERSION_CHECK(_info,_maj,_min,_sub) \ - ((_info)->version_major>(_maj)||(_info)->version_major==(_maj)&& \ - ((_info)->version_minor>(_min)||(_info)->version_minor==(_min)&& \ - (_info)->version_subminor>=(_sub))) - -/*A keyframe.*/ -#define OC_INTRA_FRAME (0) -/*A predicted frame.*/ -#define OC_INTER_FRAME (1) -/*A frame of unknown type (frame type decision has not yet been made).*/ -#define OC_UNKWN_FRAME (-1) - -/*The amount of padding to add to the reconstructed frame buffers on all - sides. - This is used to allow unrestricted motion vectors without special casing. - This must be a multiple of 2.*/ -#define OC_UMV_PADDING (16) - -/*Frame classification indices.*/ -/*The previous golden frame.*/ -#define OC_FRAME_GOLD (0) -/*The previous frame.*/ -#define OC_FRAME_PREV (1) -/*The current frame.*/ -#define OC_FRAME_SELF (2) - -/*The input or output buffer.*/ -#define OC_FRAME_IO (3) - -/*Macroblock modes.*/ -/*Macro block is invalid: It is never coded.*/ -#define OC_MODE_INVALID (-1) -/*Encoded difference from the same macro block in the previous frame.*/ -#define OC_MODE_INTER_NOMV (0) -/*Encoded with no motion compensated prediction.*/ -#define OC_MODE_INTRA (1) -/*Encoded difference from the previous frame offset by the given motion - vector.*/ -#define OC_MODE_INTER_MV (2) -/*Encoded difference from the previous frame offset by the last coded motion - vector.*/ -#define OC_MODE_INTER_MV_LAST (3) -/*Encoded difference from the previous frame offset by the second to last - coded motion vector.*/ -#define OC_MODE_INTER_MV_LAST2 (4) -/*Encoded difference from the same macro block in the previous golden - frame.*/ -#define OC_MODE_GOLDEN_NOMV (5) -/*Encoded difference from the previous golden frame offset by the given motion - vector.*/ -#define OC_MODE_GOLDEN_MV (6) -/*Encoded difference from the previous frame offset by the individual motion - vectors given for each block.*/ -#define OC_MODE_INTER_MV_FOUR (7) -/*The number of (coded) modes.*/ -#define OC_NMODES (8) - -/*Determines the reference frame used for a given MB mode.*/ -#define OC_FRAME_FOR_MODE(_x) \ - OC_UNIBBLE_TABLE32(OC_FRAME_PREV,OC_FRAME_SELF,OC_FRAME_PREV,OC_FRAME_PREV, \ - OC_FRAME_PREV,OC_FRAME_GOLD,OC_FRAME_GOLD,OC_FRAME_PREV,(_x)) - -/*Constants for the packet state machine common between encoder and decoder.*/ - -/*Next packet to emit/read: Codec info header.*/ -#define OC_PACKET_INFO_HDR (-3) -/*Next packet to emit/read: Comment header.*/ -#define OC_PACKET_COMMENT_HDR (-2) -/*Next packet to emit/read: Codec setup header.*/ -#define OC_PACKET_SETUP_HDR (-1) -/*No more packets to emit/read.*/ -#define OC_PACKET_DONE (INT_MAX) - - - -/*Super blocks are 32x32 segments of pixels in a single color plane indexed - in image order. - Internally, super blocks are broken up into four quadrants, each of which - contains a 2x2 pattern of blocks, each of which is an 8x8 block of pixels. - Quadrants, and the blocks within them, are indexed in a special order called - a "Hilbert curve" within the super block. - - In order to differentiate between the Hilbert-curve indexing strategy and - the regular image order indexing strategy, blocks indexed in image order - are called "fragments". - Fragments are indexed in image order, left to right, then bottom to top, - from Y' plane to Cb plane to Cr plane. - - The co-located fragments in all image planes corresponding to the location - of a single quadrant of a luma plane super block form a macro block. - Thus there is only a single set of macro blocks for all planes, each of which - contains between 6 and 12 fragments, depending on the pixel format. - Therefore macro block information is kept in a separate set of arrays from - super blocks to avoid unused space in the other planes. - The lists are indexed in super block order. - That is, the macro block corresponding to the macro block mbi in (luma plane) - super block sbi is at index (sbi<<2|mbi). - Thus the number of macro blocks in each dimension is always twice the number - of super blocks, even when only an odd number fall inside the coded frame. - These "extra" macro blocks are just an artifact of our internal data layout, - and not part of the coded stream; they are flagged with a negative MB mode.*/ - - - -/*A single quadrant of the map from a super block to fragment numbers.*/ -typedef ptrdiff_t oc_sb_map_quad[4]; -/*A map from a super block to fragment numbers.*/ -typedef oc_sb_map_quad oc_sb_map[4]; -/*A single plane of the map from a macro block to fragment numbers.*/ -typedef ptrdiff_t oc_mb_map_plane[4]; -/*A map from a macro block to fragment numbers.*/ -typedef oc_mb_map_plane oc_mb_map[3]; -/*A motion vector.*/ -typedef signed char oc_mv[2]; - - - -/*Super block information.*/ -struct oc_sb_flags{ - unsigned char coded_fully:1; - unsigned char coded_partially:1; - unsigned char quad_valid:4; -}; - - - -/*Information about a fragment which intersects the border of the displayable - region. - This marks which pixels belong to the displayable region.*/ -struct oc_border_info{ - /*A bit mask marking which pixels are in the displayable region. - Pixel (x,y) corresponds to bit (y<<3|x).*/ - ogg_int64_t mask; - /*The number of pixels in the displayable region. - This is always positive, and always less than 64.*/ - int npixels; -}; - - - -/*Fragment information.*/ -struct oc_fragment{ - /*A flag indicating whether or not this fragment is coded.*/ - unsigned coded:1; - /*A flag indicating that this entire fragment lies outside the displayable - region of the frame. - Note the contrast with an invalid macro block, which is outside the coded - frame, not just the displayable one. - There are no fragments outside the coded frame by construction.*/ - unsigned invalid:1; - /*The index of the quality index used for this fragment's AC coefficients.*/ - unsigned qii:6; - /*The mode of the macroblock this fragment belongs to.*/ - unsigned mb_mode:3; - /*The index of the associated border information for fragments which lie - partially outside the displayable region. - For fragments completely inside or outside this region, this is -1. - Note that the C standard requires an explicit signed keyword for bitfield - types, since some compilers may treat them as unsigned without it.*/ - signed int borderi:5; - /*The prediction-corrected DC component. - Note that the C standard requires an explicit signed keyword for bitfield - types, since some compilers may treat them as unsigned without it.*/ - signed int dc:16; -}; - - - -/*A description of each fragment plane.*/ -struct oc_fragment_plane{ - /*The number of fragments in the horizontal direction.*/ - int nhfrags; - /*The number of fragments in the vertical direction.*/ - int nvfrags; - /*The offset of the first fragment in the plane.*/ - ptrdiff_t froffset; - /*The total number of fragments in the plane.*/ - ptrdiff_t nfrags; - /*The number of super blocks in the horizontal direction.*/ - unsigned nhsbs; - /*The number of super blocks in the vertical direction.*/ - unsigned nvsbs; - /*The offset of the first super block in the plane.*/ - unsigned sboffset; - /*The total number of super blocks in the plane.*/ - unsigned nsbs; -}; - - - -/*The shared (encoder and decoder) functions that have accelerated variants.*/ -struct oc_base_opt_vtable{ - void (*frag_copy)(unsigned char *_dst, - const unsigned char *_src,int _ystride); - void (*frag_recon_intra)(unsigned char *_dst,int _ystride, - const ogg_int16_t _residue[64]); - void (*frag_recon_inter)(unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]); - void (*frag_recon_inter2)(unsigned char *_dst,const unsigned char *_src1, - const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]); - void (*idct8x8)(ogg_int16_t _y[64],int _last_zzi); - void (*state_frag_recon)(const oc_theora_state *_state,ptrdiff_t _fragi, - int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,ogg_uint16_t _dc_quant); - void (*state_frag_copy_list)(const oc_theora_state *_state, - const ptrdiff_t *_fragis,ptrdiff_t _nfragis, - int _dst_frame,int _src_frame,int _pli); - void (*state_loop_filter_frag_rows)(const oc_theora_state *_state, - int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end); - void (*restore_fpu)(void); -}; - -/*The shared (encoder and decoder) tables that vary according to which variants - of the above functions are used.*/ -struct oc_base_opt_data{ - const unsigned char *dct_fzig_zag; -}; - - -/*State information common to both the encoder and decoder.*/ -struct oc_theora_state{ - /*The stream information.*/ - th_info info; - /*Table for shared accelerated functions.*/ - oc_base_opt_vtable opt_vtable; - /*Table for shared data used by accelerated functions.*/ - oc_base_opt_data opt_data; - /*CPU flags to detect the presence of extended instruction sets.*/ - ogg_uint32_t cpu_flags; - /*The fragment plane descriptions.*/ - oc_fragment_plane fplanes[3]; - /*The list of fragments, indexed in image order.*/ - oc_fragment *frags; - /*The the offset into the reference frame buffer to the upper-left pixel of - each fragment.*/ - ptrdiff_t *frag_buf_offs; - /*The motion vector for each fragment.*/ - oc_mv *frag_mvs; - /*The total number of fragments in a single frame.*/ - ptrdiff_t nfrags; - /*The list of super block maps, indexed in image order.*/ - oc_sb_map *sb_maps; - /*The list of super block flags, indexed in image order.*/ - oc_sb_flags *sb_flags; - /*The total number of super blocks in a single frame.*/ - unsigned nsbs; - /*The fragments from each color plane that belong to each macro block. - Fragments are stored in image order (left to right then top to bottom). - When chroma components are decimated, the extra fragments have an index of - -1.*/ - oc_mb_map *mb_maps; - /*The list of macro block modes. - A negative number indicates the macro block lies entirely outside the - coded frame.*/ - signed char *mb_modes; - /*The number of macro blocks in the X direction.*/ - unsigned nhmbs; - /*The number of macro blocks in the Y direction.*/ - unsigned nvmbs; - /*The total number of macro blocks.*/ - size_t nmbs; - /*The list of coded fragments, in coded order. - Uncoded fragments are stored in reverse order from the end of the list.*/ - ptrdiff_t *coded_fragis; - /*The number of coded fragments in each plane.*/ - ptrdiff_t ncoded_fragis[3]; - /*The total number of coded fragments.*/ - ptrdiff_t ntotal_coded_fragis; - /*The index of the buffers being used for each OC_FRAME_* reference frame.*/ - int ref_frame_idx[4]; - /*The actual buffers used for the previously decoded frames.*/ - th_ycbcr_buffer ref_frame_bufs[4]; - /*The storage for the reference frame buffers.*/ - unsigned char *ref_frame_data[4]; - /*The strides for each plane in the reference frames.*/ - int ref_ystride[3]; - /*The number of unique border patterns.*/ - int nborders; - /*The unique border patterns for all border fragments. - The borderi field of fragments which straddle the border indexes this - list.*/ - oc_border_info borders[16]; - /*The frame number of the last keyframe.*/ - ogg_int64_t keyframe_num; - /*The frame number of the current frame.*/ - ogg_int64_t curframe_num; - /*The granpos of the current frame.*/ - ogg_int64_t granpos; - /*The type of the current frame.*/ - unsigned char frame_type; - /*The bias to add to the frame count when computing granule positions.*/ - unsigned char granpos_bias; - /*The number of quality indices used in the current frame.*/ - unsigned char nqis; - /*The quality indices of the current frame.*/ - unsigned char qis[3]; - /*The dequantization tables, stored in zig-zag order, and indexed by - qi, pli, qti, and zzi.*/ - ogg_uint16_t *dequant_tables[64][3][2]; - OC_ALIGN16(oc_quant_table dequant_table_data[64][3][2]); - /*Loop filter strength parameters.*/ - unsigned char loop_filter_limits[64]; -}; - - - -/*The function type used to fill in the chroma plane motion vectors for a - macro block when 4 different motion vectors are specified in the luma - plane. - _cbmvs: The chroma block-level motion vectors to fill in. - _lmbmv: The luma macro-block level motion vector to fill in for use in - prediction. - _lbmvs: The luma block-level motion vectors.*/ -typedef void (*oc_set_chroma_mvs_func)(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]); - - - -/*A map from the index in the zig zag scan to the coefficient number in a - block.*/ -extern const unsigned char OC_FZIG_ZAG[128]; -/*A map from the coefficient number in a block to its index in the zig zag - scan.*/ -extern const unsigned char OC_IZIG_ZAG[64]; -/*A map from physical macro block ordering to bitstream macro block - ordering within a super block.*/ -extern const unsigned char OC_MB_MAP[2][2]; -/*A list of the indices in the oc_mb_map array that can be valid for each of - the various chroma decimation types.*/ -extern const unsigned char OC_MB_MAP_IDXS[TH_PF_NFORMATS][12]; -/*The number of indices in the oc_mb_map array that can be valid for each of - the various chroma decimation types.*/ -extern const unsigned char OC_MB_MAP_NIDXS[TH_PF_NFORMATS]; -/*A table of functions used to fill in the Cb,Cr plane motion vectors for a - macro block when 4 different motion vectors are specified in the luma - plane.*/ -extern const oc_set_chroma_mvs_func OC_SET_CHROMA_MVS_TABLE[TH_PF_NFORMATS]; - - - -int oc_ilog(unsigned _v); -void **oc_malloc_2d(size_t _height,size_t _width,size_t _sz); -void **oc_calloc_2d(size_t _height,size_t _width,size_t _sz); -void oc_free_2d(void *_ptr); - -void oc_ycbcr_buffer_flip(th_ycbcr_buffer _dst, - const th_ycbcr_buffer _src); - -int oc_state_init(oc_theora_state *_state,const th_info *_info,int _nrefs); -void oc_state_clear(oc_theora_state *_state); -void oc_state_vtable_init_c(oc_theora_state *_state); -void oc_state_borders_fill_rows(oc_theora_state *_state,int _refi,int _pli, - int _y0,int _yend); -void oc_state_borders_fill_caps(oc_theora_state *_state,int _refi,int _pli); -void oc_state_borders_fill(oc_theora_state *_state,int _refi); -void oc_state_fill_buffer_ptrs(oc_theora_state *_state,int _buf_idx, - th_ycbcr_buffer _img); -int oc_state_mbi_for_pos(oc_theora_state *_state,int _mbx,int _mby); -int oc_state_get_mv_offsets(const oc_theora_state *_state,int _offsets[2], - int _pli,int _dx,int _dy); - -int oc_state_loop_filter_init(oc_theora_state *_state,int *_bv); -void oc_state_loop_filter(oc_theora_state *_state,int _frame); -#if defined(OC_DUMP_IMAGES) -int oc_state_dump_frame(const oc_theora_state *_state,int _frame, - const char *_suf); -#endif - -/*Shared accelerated functions.*/ -void oc_frag_copy(const oc_theora_state *_state,unsigned char *_dst, - const unsigned char *_src,int _ystride); -void oc_frag_recon_intra(const oc_theora_state *_state, - unsigned char *_dst,int _dst_ystride,const ogg_int16_t _residue[64]); -void oc_frag_recon_inter(const oc_theora_state *_state,unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]); -void oc_frag_recon_inter2(const oc_theora_state *_state, - unsigned char *_dst,const unsigned char *_src1,const unsigned char *_src2, - int _ystride,const ogg_int16_t _residue[64]); -void oc_idct8x8(const oc_theora_state *_state,ogg_int16_t _y[64],int _last_zzi); -void oc_state_frag_recon(const oc_theora_state *_state,ptrdiff_t _fragi, - int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,ogg_uint16_t _dc_quant); -void oc_state_frag_copy_list(const oc_theora_state *_state, - const ptrdiff_t *_fragis,ptrdiff_t _nfragis, - int _dst_frame,int _src_frame,int _pli); -void oc_state_loop_filter_frag_rows(const oc_theora_state *_state, - int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end); -void oc_restore_fpu(const oc_theora_state *_state); - -/*Default pure-C implementations.*/ -void oc_frag_copy_c(unsigned char *_dst, - const unsigned char *_src,int _src_ystride); -void oc_frag_recon_intra_c(unsigned char *_dst,int _dst_ystride, - const ogg_int16_t _residue[64]); -void oc_frag_recon_inter_c(unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]); -void oc_frag_recon_inter2_c(unsigned char *_dst,const unsigned char *_src1, - const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]); -void oc_idct8x8_c(ogg_int16_t _y[64],int _last_zzi); -void oc_state_frag_recon_c(const oc_theora_state *_state,ptrdiff_t _fragi, - int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,ogg_uint16_t _dc_quant); -void oc_state_frag_copy_list_c(const oc_theora_state *_state, - const ptrdiff_t *_fragis,ptrdiff_t _nfragis, - int _dst_frame,int _src_frame,int _pli); -void oc_state_loop_filter_frag_rows_c(const oc_theora_state *_state, - int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end); -void oc_restore_fpu_c(void); - -/*We need a way to call a few encoder functions without introducing a link-time - dependency into the decoder, while still allowing the old alpha API which - does not distinguish between encoder and decoder objects to be used. - We do this by placing a function table at the start of the encoder object - which can dispatch into the encoder library. - We do a similar thing for the decoder in case we ever decide to split off a - common base library.*/ -typedef void (*oc_state_clear_func)(theora_state *_th); -typedef int (*oc_state_control_func)(theora_state *th,int _req, - void *_buf,size_t _buf_sz); -typedef ogg_int64_t (*oc_state_granule_frame_func)(theora_state *_th, - ogg_int64_t _granulepos); -typedef double (*oc_state_granule_time_func)(theora_state *_th, - ogg_int64_t _granulepos); - - -struct oc_state_dispatch_vtable{ - oc_state_clear_func clear; - oc_state_control_func control; - oc_state_granule_frame_func granule_frame; - oc_state_granule_time_func granule_time; -}; - -#endif diff --git a/Engine/lib/libtheora/lib/mathops.c b/Engine/lib/libtheora/lib/mathops.c deleted file mode 100644 index d3fb90919..000000000 --- a/Engine/lib/libtheora/lib/mathops.c +++ /dev/null @@ -1,296 +0,0 @@ -#include "mathops.h" -#include - -/*The fastest fallback strategy for platforms with fast multiplication appears - to be based on de Bruijn sequences~\cite{LP98}. - Tests confirmed this to be true even on an ARM11, where it is actually faster - than using the native clz instruction. - Define OC_ILOG_NODEBRUIJN to use a simpler fallback on platforms where - multiplication or table lookups are too expensive. - - @UNPUBLISHED{LP98, - author="Charles E. Leiserson and Harald Prokop", - title="Using de {Bruijn} Sequences to Index a 1 in a Computer Word", - month=Jun, - year=1998, - note="\url{http://supertech.csail.mit.edu/papers/debruijn.pdf}" - }*/ -#if !defined(OC_ILOG_NODEBRUIJN)&& \ - !defined(OC_CLZ32)||!defined(OC_CLZ64)&&LONG_MAX<9223372036854775807LL -static const unsigned char OC_DEBRUIJN_IDX32[32]={ - 0, 1,28, 2,29,14,24, 3,30,22,20,15,25,17, 4, 8, - 31,27,13,23,21,19,16, 7,26,12,18, 6,11, 5,10, 9 -}; -#endif - -int oc_ilog32(ogg_uint32_t _v){ -#if defined(OC_CLZ32) - return (OC_CLZ32_OFFS-OC_CLZ32(_v))&-!!_v; -#else -/*On a Pentium M, this branchless version tested as the fastest version without - multiplications on 1,000,000,000 random 32-bit integers, edging out a - similar version with branches, and a 256-entry LUT version.*/ -# if defined(OC_ILOG_NODEBRUIJN) - int ret; - int m; - ret=_v>0; - m=(_v>0xFFFFU)<<4; - _v>>=m; - ret|=m; - m=(_v>0xFFU)<<3; - _v>>=m; - ret|=m; - m=(_v>0xFU)<<2; - _v>>=m; - ret|=m; - m=(_v>3)<<1; - _v>>=m; - ret|=m; - ret+=_v>1; - return ret; -/*This de Bruijn sequence version is faster if you have a fast multiplier.*/ -# else - int ret; - ret=_v>0; - _v|=_v>>1; - _v|=_v>>2; - _v|=_v>>4; - _v|=_v>>8; - _v|=_v>>16; - _v=(_v>>1)+1; - ret+=OC_DEBRUIJN_IDX32[_v*0x77CB531U>>27&0x1F]; - return ret; -# endif -#endif -} - -int oc_ilog64(ogg_int64_t _v){ -#if defined(OC_CLZ64) - return (OC_CLZ64_OFFS-OC_CLZ64(_v))&-!!_v; -#else -# if defined(OC_ILOG_NODEBRUIJN) - ogg_uint32_t v; - int ret; - int m; - ret=_v>0; - m=(_v>0xFFFFFFFFU)<<5; - v=(ogg_uint32_t)(_v>>m); - ret|=m; - m=(v>0xFFFFU)<<4; - v>>=m; - ret|=m; - m=(v>0xFFU)<<3; - v>>=m; - ret|=m; - m=(v>0xFU)<<2; - v>>=m; - ret|=m; - m=(v>3)<<1; - v>>=m; - ret|=m; - ret+=v>1; - return ret; -# else -/*If we don't have a 64-bit word, split it into two 32-bit halves.*/ -# if LONG_MAX<9223372036854775807LL - ogg_uint32_t v; - int ret; - int m; - ret=_v>0; - m=(_v>0xFFFFFFFFU)<<5; - v=(ogg_uint32_t)(_v>>m); - ret|=m; - v|=v>>1; - v|=v>>2; - v|=v>>4; - v|=v>>8; - v|=v>>16; - v=(v>>1)+1; - ret+=OC_DEBRUIJN_IDX32[v*0x77CB531U>>27&0x1F]; - return ret; -/*Otherwise do it in one 64-bit operation.*/ -# else - static const unsigned char OC_DEBRUIJN_IDX64[64]={ - 0, 1, 2, 7, 3,13, 8,19, 4,25,14,28, 9,34,20,40, - 5,17,26,38,15,46,29,48,10,31,35,54,21,50,41,57, - 63, 6,12,18,24,27,33,39,16,37,45,47,30,53,49,56, - 62,11,23,32,36,44,52,55,61,22,43,51,60,42,59,58 - }; - int ret; - ret=_v>0; - _v|=_v>>1; - _v|=_v>>2; - _v|=_v>>4; - _v|=_v>>8; - _v|=_v>>16; - _v|=_v>>32; - _v=(_v>>1)+1; - ret+=OC_DEBRUIJN_IDX64[_v*0x218A392CD3D5DBF>>58&0x3F]; - return ret; -# endif -# endif -#endif -} - -/*round(2**(62+i)*atanh(2**(-(i+1)))/log(2))*/ -static const ogg_int64_t OC_ATANH_LOG2[32]={ - 0x32B803473F7AD0F4LL,0x2F2A71BD4E25E916LL,0x2E68B244BB93BA06LL, - 0x2E39FB9198CE62E4LL,0x2E2E683F68565C8FLL,0x2E2B850BE2077FC1LL, - 0x2E2ACC58FE7B78DBLL,0x2E2A9E2DE52FD5F2LL,0x2E2A92A338D53EECLL, - 0x2E2A8FC08F5E19B6LL,0x2E2A8F07E51A485ELL,0x2E2A8ED9BA8AF388LL, - 0x2E2A8ECE2FE7384ALL,0x2E2A8ECB4D3E4B1ALL,0x2E2A8ECA94940FE8LL, - 0x2E2A8ECA6669811DLL,0x2E2A8ECA5ADEDD6ALL,0x2E2A8ECA57FC347ELL, - 0x2E2A8ECA57438A43LL,0x2E2A8ECA57155FB4LL,0x2E2A8ECA5709D510LL, - 0x2E2A8ECA5706F267LL,0x2E2A8ECA570639BDLL,0x2E2A8ECA57060B92LL, - 0x2E2A8ECA57060008LL,0x2E2A8ECA5705FD25LL,0x2E2A8ECA5705FC6CLL, - 0x2E2A8ECA5705FC3ELL,0x2E2A8ECA5705FC33LL,0x2E2A8ECA5705FC30LL, - 0x2E2A8ECA5705FC2FLL,0x2E2A8ECA5705FC2FLL -}; - -/*Computes the binary exponential of _z, a log base 2 in Q57 format.*/ -ogg_int64_t oc_bexp64(ogg_int64_t _z){ - ogg_int64_t w; - ogg_int64_t z; - int ipart; - ipart=(int)(_z>>57); - if(ipart<0)return 0; - if(ipart>=63)return 0x7FFFFFFFFFFFFFFFLL; - z=_z-OC_Q57(ipart); - if(z){ - ogg_int64_t mask; - long wlo; - int i; - /*C doesn't give us 64x64->128 muls, so we use CORDIC. - This is not particularly fast, but it's not being used in time-critical - code; it is very accurate.*/ - /*z is the fractional part of the log in Q62 format. - We need 1 bit of headroom since the magnitude can get larger than 1 - during the iteration, and a sign bit.*/ - z<<=5; - /*w is the exponential in Q61 format (since it also needs headroom and can - get as large as 2.0); we could get another bit if we dropped the sign, - but we'll recover that bit later anyway. - Ideally this should start out as - \lim_{n->\infty} 2^{61}/\product_{i=1}^n \sqrt{1-2^{-2i}} - but in order to guarantee convergence we have to repeat iterations 4, - 13 (=3*4+1), and 40 (=3*13+1, etc.), so it winds up somewhat larger.*/ - w=0x26A3D0E401DD846DLL; - for(i=0;;i++){ - mask=-(z<0); - w+=(w>>i+1)+mask^mask; - z-=OC_ATANH_LOG2[i]+mask^mask; - /*Repeat iteration 4.*/ - if(i>=3)break; - z<<=1; - } - for(;;i++){ - mask=-(z<0); - w+=(w>>i+1)+mask^mask; - z-=OC_ATANH_LOG2[i]+mask^mask; - /*Repeat iteration 13.*/ - if(i>=12)break; - z<<=1; - } - for(;i<32;i++){ - mask=-(z<0); - w+=(w>>i+1)+mask^mask; - z=z-(OC_ATANH_LOG2[i]+mask^mask)<<1; - } - wlo=0; - /*Skip the remaining iterations unless we really require that much - precision. - We could have bailed out earlier for smaller iparts, but that would - require initializing w from a table, as the limit doesn't converge to - 61-bit precision until n=30.*/ - if(ipart>30){ - /*For these iterations, we just update the low bits, as the high bits - can't possibly be affected. - OC_ATANH_LOG2 has also converged (it actually did so one iteration - earlier, but that's no reason for an extra special case).*/ - for(;;i++){ - mask=-(z<0); - wlo+=(w>>i)+mask^mask; - z-=OC_ATANH_LOG2[31]+mask^mask; - /*Repeat iteration 40.*/ - if(i>=39)break; - z<<=1; - } - for(;i<61;i++){ - mask=-(z<0); - wlo+=(w>>i)+mask^mask; - z=z-(OC_ATANH_LOG2[31]+mask^mask)<<1; - } - } - w=(w<<1)+wlo; - } - else w=(ogg_int64_t)1<<62; - if(ipart<62)w=(w>>61-ipart)+1>>1; - return w; -} - -/*Computes the binary logarithm of _w, returned in Q57 format.*/ -ogg_int64_t oc_blog64(ogg_int64_t _w){ - ogg_int64_t z; - int ipart; - if(_w<=0)return -1; - ipart=OC_ILOGNZ_64(_w)-1; - if(ipart>61)_w>>=ipart-61; - else _w<<=61-ipart; - z=0; - if(_w&_w-1){ - ogg_int64_t x; - ogg_int64_t y; - ogg_int64_t u; - ogg_int64_t mask; - int i; - /*C doesn't give us 64x64->128 muls, so we use CORDIC. - This is not particularly fast, but it's not being used in time-critical - code; it is very accurate.*/ - /*z is the fractional part of the log in Q61 format.*/ - /*x and y are the cosh() and sinh(), respectively, in Q61 format. - We are computing z=2*atanh(y/x)=2*atanh((_w-1)/(_w+1)).*/ - x=_w+((ogg_int64_t)1<<61); - y=_w-((ogg_int64_t)1<<61); - for(i=0;i<4;i++){ - mask=-(y<0); - z+=(OC_ATANH_LOG2[i]>>i)+mask^mask; - u=x>>i+1; - x-=(y>>i+1)+mask^mask; - y-=u+mask^mask; - } - /*Repeat iteration 4.*/ - for(i--;i<13;i++){ - mask=-(y<0); - z+=(OC_ATANH_LOG2[i]>>i)+mask^mask; - u=x>>i+1; - x-=(y>>i+1)+mask^mask; - y-=u+mask^mask; - } - /*Repeat iteration 13.*/ - for(i--;i<32;i++){ - mask=-(y<0); - z+=(OC_ATANH_LOG2[i]>>i)+mask^mask; - u=x>>i+1; - x-=(y>>i+1)+mask^mask; - y-=u+mask^mask; - } - /*OC_ATANH_LOG2 has converged.*/ - for(;i<40;i++){ - mask=-(y<0); - z+=(OC_ATANH_LOG2[31]>>i)+mask^mask; - u=x>>i+1; - x-=(y>>i+1)+mask^mask; - y-=u+mask^mask; - } - /*Repeat iteration 40.*/ - for(i--;i<62;i++){ - mask=-(y<0); - z+=(OC_ATANH_LOG2[31]>>i)+mask^mask; - u=x>>i+1; - x-=(y>>i+1)+mask^mask; - y-=u+mask^mask; - } - z=z+8>>4; - } - return OC_Q57(ipart)+z; -} diff --git a/Engine/lib/libtheora/lib/mathops.h b/Engine/lib/libtheora/lib/mathops.h deleted file mode 100644 index efbc5377b..000000000 --- a/Engine/lib/libtheora/lib/mathops.h +++ /dev/null @@ -1,141 +0,0 @@ -#if !defined(_mathops_H) -# define _mathops_H (1) -# include - -# ifdef __GNUC_PREREQ -# if __GNUC_PREREQ(3,4) -# include -/*Note the casts to (int) below: this prevents OC_CLZ{32|64}_OFFS from - "upgrading" the type of an entire expression to an (unsigned) size_t.*/ -# if INT_MAX>=2147483647 -# define OC_CLZ32_OFFS ((int)sizeof(unsigned)*CHAR_BIT) -# define OC_CLZ32(_x) (__builtin_clz(_x)) -# elif LONG_MAX>=2147483647L -# define OC_CLZ32_OFFS ((int)sizeof(unsigned long)*CHAR_BIT) -# define OC_CLZ32(_x) (__builtin_clzl(_x)) -# endif -# if INT_MAX>=9223372036854775807LL -# define OC_CLZ64_OFFS ((int)sizeof(unsigned)*CHAR_BIT) -# define OC_CLZ64(_x) (__builtin_clz(_x)) -# elif LONG_MAX>=9223372036854775807LL -# define OC_CLZ64_OFFS ((int)sizeof(unsigned long)*CHAR_BIT) -# define OC_CLZ64(_x) (__builtin_clzl(_x)) -# elif LLONG_MAX>=9223372036854775807LL|| \ - __LONG_LONG_MAX__>=9223372036854775807LL -# define OC_CLZ64_OFFS ((int)sizeof(unsigned long long)*CHAR_BIT) -# define OC_CLZ64(_x) (__builtin_clzll(_x)) -# endif -# endif -# endif - - - -/** - * oc_ilog32 - Integer binary logarithm of a 32-bit value. - * @_v: A 32-bit value. - * Returns floor(log2(_v))+1, or 0 if _v==0. - * This is the number of bits that would be required to represent _v in two's - * complement notation with all of the leading zeros stripped. - * The OC_ILOG_32() or OC_ILOGNZ_32() macros may be able to use a builtin - * function instead, which should be faster. - */ -int oc_ilog32(ogg_uint32_t _v); -/** - * oc_ilog64 - Integer binary logarithm of a 64-bit value. - * @_v: A 64-bit value. - * Returns floor(log2(_v))+1, or 0 if _v==0. - * This is the number of bits that would be required to represent _v in two's - * complement notation with all of the leading zeros stripped. - * The OC_ILOG_64() or OC_ILOGNZ_64() macros may be able to use a builtin - * function instead, which should be faster. - */ -int oc_ilog64(ogg_int64_t _v); - - -# if defined(OC_CLZ32) -/** - * OC_ILOGNZ_32 - Integer binary logarithm of a non-zero 32-bit value. - * @_v: A non-zero 32-bit value. - * Returns floor(log2(_v))+1. - * This is the number of bits that would be required to represent _v in two's - * complement notation with all of the leading zeros stripped. - * If _v is zero, the return value is undefined; use OC_ILOG_32() instead. - */ -# define OC_ILOGNZ_32(_v) (OC_CLZ32_OFFS-OC_CLZ32(_v)) -/** - * OC_ILOG_32 - Integer binary logarithm of a 32-bit value. - * @_v: A 32-bit value. - * Returns floor(log2(_v))+1, or 0 if _v==0. - * This is the number of bits that would be required to represent _v in two's - * complement notation with all of the leading zeros stripped. - */ -# define OC_ILOG_32(_v) (OC_ILOGNZ_32(_v)&-!!(_v)) -# else -# define OC_ILOGNZ_32(_v) (oc_ilog32(_v)) -# define OC_ILOG_32(_v) (oc_ilog32(_v)) -# endif - -# if defined(CLZ64) -/** - * OC_ILOGNZ_64 - Integer binary logarithm of a non-zero 64-bit value. - * @_v: A non-zero 64-bit value. - * Returns floor(log2(_v))+1. - * This is the number of bits that would be required to represent _v in two's - * complement notation with all of the leading zeros stripped. - * If _v is zero, the return value is undefined; use OC_ILOG_64() instead. - */ -# define OC_ILOGNZ_64(_v) (CLZ64_OFFS-CLZ64(_v)) -/** - * OC_ILOG_64 - Integer binary logarithm of a 64-bit value. - * @_v: A 64-bit value. - * Returns floor(log2(_v))+1, or 0 if _v==0. - * This is the number of bits that would be required to represent _v in two's - * complement notation with all of the leading zeros stripped. - */ -# define OC_ILOG_64(_v) (OC_ILOGNZ_64(_v)&-!!(_v)) -# else -# define OC_ILOGNZ_64(_v) (oc_ilog64(_v)) -# define OC_ILOG_64(_v) (oc_ilog64(_v)) -# endif - -# define OC_STATIC_ILOG0(_v) (!!(_v)) -# define OC_STATIC_ILOG1(_v) (((_v)&0x2)?2:OC_STATIC_ILOG0(_v)) -# define OC_STATIC_ILOG2(_v) \ - (((_v)&0xC)?2+OC_STATIC_ILOG1((_v)>>2):OC_STATIC_ILOG1(_v)) -# define OC_STATIC_ILOG3(_v) \ - (((_v)&0xF0)?4+OC_STATIC_ILOG2((_v)>>4):OC_STATIC_ILOG2(_v)) -# define OC_STATIC_ILOG4(_v) \ - (((_v)&0xFF00)?8+OC_STATIC_ILOG3((_v)>>8):OC_STATIC_ILOG3(_v)) -# define OC_STATIC_ILOG5(_v) \ - (((_v)&0xFFFF0000)?16+OC_STATIC_ILOG4((_v)>>16):OC_STATIC_ILOG4(_v)) -# define OC_STATIC_ILOG6(_v) \ - (((_v)&0xFFFFFFFF00000000ULL)?32+OC_STATIC_ILOG5((_v)>>32):OC_STATIC_ILOG5(_v)) -/** - * OC_STATIC_ILOG_32 - The integer logarithm of an (unsigned, 32-bit) constant. - * @_v: A non-negative 32-bit constant. - * Returns floor(log2(_v))+1, or 0 if _v==0. - * This is the number of bits that would be required to represent _v in two's - * complement notation with all of the leading zeros stripped. - * This macro is suitable for evaluation at compile time, but it should not be - * used on values that can change at runtime, as it operates via exhaustive - * search. - */ -# define OC_STATIC_ILOG_32(_v) (OC_STATIC_ILOG5((ogg_uint32_t)(_v))) -/** - * OC_STATIC_ILOG_64 - The integer logarithm of an (unsigned, 64-bit) constant. - * @_v: A non-negative 64-bit constant. - * Returns floor(log2(_v))+1, or 0 if _v==0. - * This is the number of bits that would be required to represent _v in two's - * complement notation with all of the leading zeros stripped. - * This macro is suitable for evaluation at compile time, but it should not be - * used on values that can change at runtime, as it operates via exhaustive - * search. - */ -# define OC_STATIC_ILOG_64(_v) (OC_STATIC_ILOG6((ogg_int64_t)(_v))) - -#define OC_Q57(_v) ((ogg_int64_t)(_v)<<57) - -ogg_int64_t oc_bexp64(ogg_int64_t _z); -ogg_int64_t oc_blog64(ogg_int64_t _w); - -#endif diff --git a/Engine/lib/libtheora/lib/mcenc.c b/Engine/lib/libtheora/lib/mcenc.c deleted file mode 100644 index 797e81f4f..000000000 --- a/Engine/lib/libtheora/lib/mcenc.c +++ /dev/null @@ -1,767 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id$ - - ********************************************************************/ -#include -#include -#include -#include "encint.h" - - - -typedef struct oc_mcenc_ctx oc_mcenc_ctx; - - - -/*Temporary state used for motion estimation.*/ -struct oc_mcenc_ctx{ - /*The candidate motion vectors.*/ - int candidates[13][2]; - /*The start of the Set B candidates.*/ - int setb0; - /*The total number of candidates.*/ - int ncandidates; -}; - - - -/*The maximum Y plane SAD value for accepting the median predictor.*/ -#define OC_YSAD_THRESH1 (256) -/*The amount to right shift the minimum error by when inflating it for - computing the second maximum Y plane SAD threshold.*/ -#define OC_YSAD_THRESH2_SCALE_BITS (4) -/*The amount to add to the second maximum Y plane threshold when inflating - it.*/ -#define OC_YSAD_THRESH2_OFFSET (64) - -/*The vector offsets in the X direction for each search site in the square - pattern.*/ -static const int OC_SQUARE_DX[9]={-1,0,1,-1,0,1,-1,0,1}; -/*The vector offsets in the Y direction for each search site in the square - pattern.*/ -static const int OC_SQUARE_DY[9]={-1,-1,-1,0,0,0,1,1,1}; -/*The number of sites to search for each boundary condition in the square - pattern. - Bit flags for the boundary conditions are as follows: - 1: -16==dx - 2: dx==15(.5) - 4: -16==dy - 8: dy==15(.5)*/ -static const int OC_SQUARE_NSITES[11]={8,5,5,0,5,3,3,0,5,3,3}; -/*The list of sites to search for each boundary condition in the square - pattern.*/ -static const int OC_SQUARE_SITES[11][8]={ - /* -15.5mb_info; - /*Skip a position to store the median predictor in.*/ - ncandidates=1; - if(embs[_mbi].ncneighbors>0){ - /*Fill in the first part of set A: the vectors from adjacent blocks.*/ - for(i=0;icandidates[ncandidates][0]=embs[nmbi].analysis_mv[0][_frame][0]; - _mcenc->candidates[ncandidates][1]=embs[nmbi].analysis_mv[0][_frame][1]; - ncandidates++; - } - } - /*Add a few additional vectors to set A: the vectors used in the previous - frames and the (0,0) vector.*/ - _mcenc->candidates[ncandidates][0]=OC_CLAMPI(-31,_accum[0],31); - _mcenc->candidates[ncandidates][1]=OC_CLAMPI(-31,_accum[1],31); - ncandidates++; - _mcenc->candidates[ncandidates][0]=OC_CLAMPI(-31, - embs[_mbi].analysis_mv[1][_frame][0]+_accum[0],31); - _mcenc->candidates[ncandidates][1]=OC_CLAMPI(-31, - embs[_mbi].analysis_mv[1][_frame][1]+_accum[1],31); - ncandidates++; - _mcenc->candidates[ncandidates][0]=0; - _mcenc->candidates[ncandidates][1]=0; - ncandidates++; - /*Use the first three vectors of set A to find our best predictor: their - median.*/ - memcpy(a,_mcenc->candidates+1,sizeof(a)); - OC_SORT2I(a[0][0],a[1][0]); - OC_SORT2I(a[0][1],a[1][1]); - OC_SORT2I(a[1][0],a[2][0]); - OC_SORT2I(a[1][1],a[2][1]); - OC_SORT2I(a[0][0],a[1][0]); - OC_SORT2I(a[0][1],a[1][1]); - _mcenc->candidates[0][0]=a[1][0]; - _mcenc->candidates[0][1]=a[1][1]; - /*Fill in set B: accelerated predictors for this and adjacent macro blocks.*/ - _mcenc->setb0=ncandidates; - /*The first time through the loop use the current macro block.*/ - nmbi=_mbi; - for(i=0;;i++){ - _mcenc->candidates[ncandidates][0]=OC_CLAMPI(-31, - 2*embs[_mbi].analysis_mv[1][_frame][0] - -embs[_mbi].analysis_mv[2][_frame][0]+_accum[0],31); - _mcenc->candidates[ncandidates][1]=OC_CLAMPI(-31, - 2*embs[_mbi].analysis_mv[1][_frame][1] - -embs[_mbi].analysis_mv[2][_frame][1]+_accum[1],31); - ncandidates++; - if(i>=embs[_mbi].npneighbors)break; - nmbi=embs[_mbi].pneighbors[i]; - } - /*Truncate to full-pel positions.*/ - for(i=0;icandidates[i][0]=OC_DIV2(_mcenc->candidates[i][0]); - _mcenc->candidates[i][1]=OC_DIV2(_mcenc->candidates[i][1]); - } - _mcenc->ncandidates=ncandidates; -} - -#if 0 -static unsigned oc_sad16_halfpel(const oc_enc_ctx *_enc, - const ptrdiff_t *_frag_buf_offs,const ptrdiff_t _fragis[4], - int _mvoffset0,int _mvoffset1,const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _best_err){ - unsigned err; - int bi; - err=0; - for(bi=0;bi<4;bi++){ - ptrdiff_t frag_offs; - frag_offs=_frag_buf_offs[_fragis[bi]]; - err+=oc_enc_frag_sad2_thresh(_enc,_src+frag_offs,_ref+frag_offs+_mvoffset0, - _ref+frag_offs+_mvoffset1,_ystride,_best_err-err); - } - return err; -} -#endif - -static unsigned oc_satd16_halfpel(const oc_enc_ctx *_enc, - const ptrdiff_t *_frag_buf_offs,const ptrdiff_t _fragis[4], - int _mvoffset0,int _mvoffset1,const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _best_err){ - unsigned err; - int bi; - err=0; - for(bi=0;bi<4;bi++){ - ptrdiff_t frag_offs; - frag_offs=_frag_buf_offs[_fragis[bi]]; - err+=oc_enc_frag_satd2_thresh(_enc,_src+frag_offs,_ref+frag_offs+_mvoffset0, - _ref+frag_offs+_mvoffset1,_ystride,_best_err-err); - } - return err; -} - -static unsigned oc_mcenc_ysad_check_mbcandidate_fullpel(const oc_enc_ctx *_enc, - const ptrdiff_t *_frag_buf_offs,const ptrdiff_t _fragis[4],int _dx,int _dy, - const unsigned char *_src,const unsigned char *_ref,int _ystride, - unsigned _block_err[4]){ - unsigned err; - int mvoffset; - int bi; - mvoffset=_dx+_dy*_ystride; - err=0; - for(bi=0;bi<4;bi++){ - ptrdiff_t frag_offs; - unsigned block_err; - frag_offs=_frag_buf_offs[_fragis[bi]]; - block_err=oc_enc_frag_sad(_enc, - _src+frag_offs,_ref+frag_offs+mvoffset,_ystride); - _block_err[bi]=block_err; - err+=block_err; - } - return err; -} - -static int oc_mcenc_ysatd_check_mbcandidate_fullpel(const oc_enc_ctx *_enc, - const ptrdiff_t *_frag_buf_offs,const ptrdiff_t _fragis[4],int _dx,int _dy, - const unsigned char *_src,const unsigned char *_ref,int _ystride){ - int mvoffset; - int err; - int bi; - mvoffset=_dx+_dy*_ystride; - err=0; - for(bi=0;bi<4;bi++){ - ptrdiff_t frag_offs; - frag_offs=_frag_buf_offs[_fragis[bi]]; - err+=oc_enc_frag_satd_thresh(_enc, - _src+frag_offs,_ref+frag_offs+mvoffset,_ystride,UINT_MAX); - } - return err; -} - -static unsigned oc_mcenc_ysatd_check_bcandidate_fullpel(const oc_enc_ctx *_enc, - ptrdiff_t _frag_offs,int _dx,int _dy, - const unsigned char *_src,const unsigned char *_ref,int _ystride){ - return oc_enc_frag_satd_thresh(_enc, - _src+_frag_offs,_ref+_frag_offs+_dx+_dy*_ystride,_ystride,UINT_MAX); -} - -/*Perform a motion vector search for this macro block against a single - reference frame. - As a bonus, individual block motion vectors are computed as well, as much of - the work can be shared. - The actual motion vector is stored in the appropriate place in the - oc_mb_enc_info structure. - _mcenc: The motion compensation context. - _accum: Drop frame/golden MV accumulators. - _mbi: The macro block index. - _frame: The frame to search, either OC_FRAME_PREV or OC_FRAME_GOLD.*/ -void oc_mcenc_search_frame(oc_enc_ctx *_enc,int _accum[2],int _mbi,int _frame){ - /*Note: Traditionally this search is done using a rate-distortion objective - function of the form D+lambda*R. - However, xiphmont tested this and found it produced a small degredation, - while requiring extra computation. - This is most likely due to Theora's peculiar MV encoding scheme: MVs are - not coded relative to a predictor, and the only truly cheap way to use a - MV is in the LAST or LAST2 MB modes, which are not being considered here. - Therefore if we use the MV found here, it's only because both LAST and - LAST2 performed poorly, and therefore the MB is not likely to be uniform - or suffer from the aperture problem. - Furthermore we would like to re-use the MV found here for as many MBs as - possible, so picking a slightly sub-optimal vector to save a bit or two - may cause increased degredation in many blocks to come. - We could artificially reduce lambda to compensate, but it's faster to just - disable it entirely, and use D (the distortion) as the sole criterion.*/ - oc_mcenc_ctx mcenc; - const ptrdiff_t *frag_buf_offs; - const ptrdiff_t *fragis; - const unsigned char *src; - const unsigned char *ref; - int ystride; - oc_mb_enc_info *embs; - ogg_int32_t hit_cache[31]; - ogg_int32_t hitbit; - unsigned best_block_err[4]; - unsigned block_err[4]; - unsigned best_err; - int best_vec[2]; - int best_block_vec[4][2]; - int candx; - int candy; - int bi; - embs=_enc->mb_info; - /*Find some candidate motion vectors.*/ - oc_mcenc_find_candidates(_enc,&mcenc,_accum,_mbi,_frame); - /*Clear the cache of locations we've examined.*/ - memset(hit_cache,0,sizeof(hit_cache)); - /*Start with the median predictor.*/ - candx=mcenc.candidates[0][0]; - candy=mcenc.candidates[0][1]; - hit_cache[candy+15]|=(ogg_int32_t)1<state.frag_buf_offs; - fragis=_enc->state.mb_maps[_mbi][0]; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ref=_enc->state.ref_frame_data[_enc->state.ref_frame_idx[_frame]]; - ystride=_enc->state.ref_ystride[0]; - /*TODO: customize error function for speed/(quality+size) tradeoff.*/ - best_err=oc_mcenc_ysad_check_mbcandidate_fullpel(_enc, - frag_buf_offs,fragis,candx,candy,src,ref,ystride,block_err); - best_vec[0]=candx; - best_vec[1]=candy; - if(_frame==OC_FRAME_PREV){ - for(bi=0;bi<4;bi++){ - best_block_err[bi]=block_err[bi]; - best_block_vec[bi][0]=candx; - best_block_vec[bi][1]=candy; - } - } - /*If this predictor fails, move on to set A.*/ - if(best_err>OC_YSAD_THRESH1){ - unsigned err; - unsigned t2; - int ncs; - int ci; - /*Compute the early termination threshold for set A.*/ - t2=embs[_mbi].error[_frame]; - ncs=OC_MINI(3,embs[_mbi].ncneighbors); - for(ci=0;ci>OC_YSAD_THRESH2_SCALE_BITS)+OC_YSAD_THRESH2_OFFSET; - /*Examine the candidates in set A.*/ - for(ci=1;cit2){ - /*Examine the candidates in set B.*/ - for(;cit2){ - int best_site; - int nsites; - int sitei; - int site; - int b; - /*Square pattern search.*/ - for(;;){ - best_site=4; - /*Compose the bit flags for boundary conditions.*/ - b=OC_DIV16(-best_vec[0]+1)|OC_DIV16(best_vec[0]+1)<<1| - OC_DIV16(-best_vec[1]+1)<<2|OC_DIV16(best_vec[1]+1)<<3; - nsites=OC_SQUARE_NSITES[b]; - for(sitei=0;sitei>=2; - for(bi=0;bi<4;bi++){ - if(best_block_err[bi]>t2){ - /*Square pattern search. - We do this in a slightly interesting manner. - We continue to check the SAD of all four blocks in the - macro block. - This gives us two things: - 1) We can continue to use the hit_cache to avoid duplicate - checks. - Otherwise we could continue to read it, but not write to it - without saving and restoring it for each block. - Note that we could still eliminate a large number of - duplicate checks by taking into account the site we came - from when choosing the site list. - We can still do that to avoid extra hit_cache queries, and - it might even be a speed win. - 2) It gives us a slightly better chance of escaping local - minima. - We would not be here if we weren't doing a fairly bad job - in finding a good vector, and checking these vectors can - save us from 100 to several thousand points off our SAD 1 - in 15 times. - TODO: Is this a good idea? - Who knows. - It needs more testing.*/ - for(;;){ - int bestx; - int besty; - int bj; - bestx=best_block_vec[bi][0]; - besty=best_block_vec[bi][1]; - /*Compose the bit flags for boundary conditions.*/ - b=OC_DIV16(-bestx+1)|OC_DIV16(bestx+1)<<1| - OC_DIV16(-besty+1)<<2|OC_DIV16(besty+1)<<3; - nsites=OC_SQUARE_NSITES[b]; - for(sitei=0;siteimb_info[_mbi].analysis_mv; - if(_enc->prevframe_dropped){ - accum_p[0]=mvs[0][OC_FRAME_PREV][0]; - accum_p[1]=mvs[0][OC_FRAME_PREV][1]; - } - else accum_p[1]=accum_p[0]=0; - accum_g[0]=mvs[2][OC_FRAME_GOLD][0]; - accum_g[1]=mvs[2][OC_FRAME_GOLD][1]; - mvs[0][OC_FRAME_PREV][0]-=mvs[2][OC_FRAME_PREV][0]; - mvs[0][OC_FRAME_PREV][1]-=mvs[2][OC_FRAME_PREV][1]; - /*Move the motion vector predictors back a frame.*/ - memmove(mvs+1,mvs,2*sizeof(*mvs)); - /*Search the last frame.*/ - oc_mcenc_search_frame(_enc,accum_p,_mbi,OC_FRAME_PREV); - mvs[2][OC_FRAME_PREV][0]=accum_p[0]; - mvs[2][OC_FRAME_PREV][1]=accum_p[1]; - /*GOLDEN MVs are different from PREV MVs in that they're each absolute - offsets from some frame in the past rather than relative offsets from the - frame before. - For predictor calculation to make sense, we need them to be in the same - form as PREV MVs.*/ - mvs[1][OC_FRAME_GOLD][0]-=mvs[2][OC_FRAME_GOLD][0]; - mvs[1][OC_FRAME_GOLD][1]-=mvs[2][OC_FRAME_GOLD][1]; - mvs[2][OC_FRAME_GOLD][0]-=accum_g[0]; - mvs[2][OC_FRAME_GOLD][1]-=accum_g[1]; - /*Search the golden frame.*/ - oc_mcenc_search_frame(_enc,accum_g,_mbi,OC_FRAME_GOLD); - /*Put GOLDEN MVs back into absolute offset form. - The newest MV is already an absolute offset.*/ - mvs[2][OC_FRAME_GOLD][0]+=accum_g[0]; - mvs[2][OC_FRAME_GOLD][1]+=accum_g[1]; - mvs[1][OC_FRAME_GOLD][0]+=mvs[2][OC_FRAME_GOLD][0]; - mvs[1][OC_FRAME_GOLD][1]+=mvs[2][OC_FRAME_GOLD][1]; -} - -#if 0 -static int oc_mcenc_ysad_halfpel_mbrefine(const oc_enc_ctx *_enc,int _mbi, - int _vec[2],int _best_err,int _frame){ - const unsigned char *src; - const unsigned char *ref; - const ptrdiff_t *frag_buf_offs; - const ptrdiff_t *fragis; - int offset_y[9]; - int ystride; - int mvoffset_base; - int best_site; - int sitei; - int err; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ref=_enc->state.ref_frame_data[_enc->state.ref_frame_idx[_framei]]; - frag_buf_offs=_enc->state.frag_buf_offs; - fragis=_enc->state.mb_maps[_mbi][0]; - ystride=_enc->state.ref_ystride[0]; - mvoffset_base=_vec[0]+_vec[1]*ystride; - offset_y[0]=offset_y[1]=offset_y[2]=-ystride; - offset_y[3]=offset_y[5]=0; - offset_y[6]=offset_y[7]=offset_y[8]=ystride; - best_site=4; - for(sitei=0;sitei<8;sitei++){ - int site; - int xmask; - int ymask; - int dx; - int dy; - int mvoffset0; - int mvoffset1; - site=OC_SQUARE_SITES[0][sitei]; - dx=OC_SQUARE_DX[site]; - dy=OC_SQUARE_DY[site]; - /*The following code SHOULD be equivalent to - oc_state_get_mv_offsets(&_mcenc->enc.state,&mvoffset0,&mvoffset1, - (_vec[0]<<1)+dx,(_vec[1]<<1)+dy,ref_ystride,0); - However, it should also be much faster, as it involves no multiplies and - doesn't have to handle chroma vectors.*/ - xmask=OC_SIGNMASK(((_vec[0]<<1)+dx)^dx); - ymask=OC_SIGNMASK(((_vec[1]<<1)+dy)^dy); - mvoffset0=mvoffset_base+(dx&xmask)+(offset_y[site]&ymask); - mvoffset1=mvoffset_base+(dx&~xmask)+(offset_y[site]&~ymask); - err=oc_sad16_halfpel(_enc,frag_buf_offs,fragis, - mvoffset0,mvoffset1,src,ref,ystride,_best_err); - if(err<_best_err){ - _best_err=err; - best_site=site; - } - } - _vec[0]=(_vec[0]<<1)+OC_SQUARE_DX[best_site]; - _vec[1]=(_vec[1]<<1)+OC_SQUARE_DY[best_site]; - return _best_err; -} -#endif - -static unsigned oc_mcenc_ysatd_halfpel_mbrefine(const oc_enc_ctx *_enc, - int _mbi,int _vec[2],unsigned _best_err,int _frame){ - const unsigned char *src; - const unsigned char *ref; - const ptrdiff_t *frag_buf_offs; - const ptrdiff_t *fragis; - int offset_y[9]; - int ystride; - int mvoffset_base; - int best_site; - int sitei; - int err; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ref=_enc->state.ref_frame_data[_enc->state.ref_frame_idx[_frame]]; - frag_buf_offs=_enc->state.frag_buf_offs; - fragis=_enc->state.mb_maps[_mbi][0]; - ystride=_enc->state.ref_ystride[0]; - mvoffset_base=_vec[0]+_vec[1]*ystride; - offset_y[0]=offset_y[1]=offset_y[2]=-ystride; - offset_y[3]=offset_y[5]=0; - offset_y[6]=offset_y[7]=offset_y[8]=ystride; - best_site=4; - for(sitei=0;sitei<8;sitei++){ - int site; - int xmask; - int ymask; - int dx; - int dy; - int mvoffset0; - int mvoffset1; - site=OC_SQUARE_SITES[0][sitei]; - dx=OC_SQUARE_DX[site]; - dy=OC_SQUARE_DY[site]; - /*The following code SHOULD be equivalent to - oc_state_get_mv_offsets(&_mcenc->enc.state,&mvoffset0,&mvoffset1, - (_vec[0]<<1)+dx,(_vec[1]<<1)+dy,ref_ystride,0); - However, it should also be much faster, as it involves no multiplies and - doesn't have to handle chroma vectors.*/ - xmask=OC_SIGNMASK(((_vec[0]<<1)+dx)^dx); - ymask=OC_SIGNMASK(((_vec[1]<<1)+dy)^dy); - mvoffset0=mvoffset_base+(dx&xmask)+(offset_y[site]&ymask); - mvoffset1=mvoffset_base+(dx&~xmask)+(offset_y[site]&~ymask); - err=oc_satd16_halfpel(_enc,frag_buf_offs,fragis, - mvoffset0,mvoffset1,src,ref,ystride,_best_err); - if(err<_best_err){ - _best_err=err; - best_site=site; - } - } - _vec[0]=(_vec[0]<<1)+OC_SQUARE_DX[best_site]; - _vec[1]=(_vec[1]<<1)+OC_SQUARE_DY[best_site]; - return _best_err; -} - -void oc_mcenc_refine1mv(oc_enc_ctx *_enc,int _mbi,int _frame){ - oc_mb_enc_info *embs; - int vec[2]; - embs=_enc->mb_info; - vec[0]=OC_DIV2(embs[_mbi].analysis_mv[0][_frame][0]); - vec[1]=OC_DIV2(embs[_mbi].analysis_mv[0][_frame][1]); - embs[_mbi].satd[_frame]=oc_mcenc_ysatd_halfpel_mbrefine(_enc, - _mbi,vec,embs[_mbi].satd[_frame],_frame); - embs[_mbi].analysis_mv[0][_frame][0]=(signed char)vec[0]; - embs[_mbi].analysis_mv[0][_frame][1]=(signed char)vec[1]; -} - -#if 0 -static int oc_mcenc_ysad_halfpel_brefine(const oc_enc_ctx *_enc, - int _vec[2],const unsigned char *_src,const unsigned char *_ref,int _ystride, - int _offset_y[9],unsigned _best_err){ - int mvoffset_base; - int best_site; - int sitei; - mvoffset_base=_vec[0]+_vec[1]*_ystride; - best_site=4; - for(sitei=0;sitei<8;sitei++){ - unsigned err; - int site; - int xmask; - int ymask; - int dx; - int dy; - int mvoffset0; - int mvoffset1; - site=OC_SQUARE_SITES[0][sitei]; - dx=OC_SQUARE_DX[site]; - dy=OC_SQUARE_DY[site]; - /*The following code SHOULD be equivalent to - oc_state_get_mv_offsets(&_mcenc->enc.state,&mvoffset0,&mvoffset1, - (_vec[0]<<1)+dx,(_vec[1]<<1)+dy,ref_ystride,0); - However, it should also be much faster, as it involves no multiplies and - doesn't have to handle chroma vectors.*/ - xmask=OC_SIGNMASK(((_vec[0]<<1)+dx)^dx); - ymask=OC_SIGNMASK(((_vec[1]<<1)+dy)^dy); - mvoffset0=mvoffset_base+(dx&xmask)+(_offset_y[site]&ymask); - mvoffset1=mvoffset_base+(dx&~xmask)+(_offset_y[site]&~ymask); - err=oc_enc_frag_sad2_thresh(_enc,_src, - _ref+mvoffset0,_ref+mvoffset1,ystride,_best_err); - if(err<_best_err){ - _best_err=err; - best_site=site; - } - } - _vec[0]=(_vec[0]<<1)+OC_SQUARE_DX[best_site]; - _vec[1]=(_vec[1]<<1)+OC_SQUARE_DY[best_site]; - return _best_err; -} -#endif - -static unsigned oc_mcenc_ysatd_halfpel_brefine(const oc_enc_ctx *_enc, - int _vec[2],const unsigned char *_src,const unsigned char *_ref,int _ystride, - int _offset_y[9],unsigned _best_err){ - int mvoffset_base; - int best_site; - int sitei; - mvoffset_base=_vec[0]+_vec[1]*_ystride; - best_site=4; - for(sitei=0;sitei<8;sitei++){ - unsigned err; - int site; - int xmask; - int ymask; - int dx; - int dy; - int mvoffset0; - int mvoffset1; - site=OC_SQUARE_SITES[0][sitei]; - dx=OC_SQUARE_DX[site]; - dy=OC_SQUARE_DY[site]; - /*The following code SHOULD be equivalent to - oc_state_get_mv_offsets(&_enc->state,&mvoffsets,0, - (_vec[0]<<1)+dx,(_vec[1]<<1)+dy); - However, it should also be much faster, as it involves no multiplies and - doesn't have to handle chroma vectors.*/ - xmask=OC_SIGNMASK(((_vec[0]<<1)+dx)^dx); - ymask=OC_SIGNMASK(((_vec[1]<<1)+dy)^dy); - mvoffset0=mvoffset_base+(dx&xmask)+(_offset_y[site]&ymask); - mvoffset1=mvoffset_base+(dx&~xmask)+(_offset_y[site]&~ymask); - err=oc_enc_frag_satd2_thresh(_enc,_src, - _ref+mvoffset0,_ref+mvoffset1,_ystride,_best_err); - if(err<_best_err){ - _best_err=err; - best_site=site; - } - } - _vec[0]=(_vec[0]<<1)+OC_SQUARE_DX[best_site]; - _vec[1]=(_vec[1]<<1)+OC_SQUARE_DY[best_site]; - return _best_err; -} - -void oc_mcenc_refine4mv(oc_enc_ctx *_enc,int _mbi){ - oc_mb_enc_info *embs; - const ptrdiff_t *frag_buf_offs; - const ptrdiff_t *fragis; - const unsigned char *src; - const unsigned char *ref; - int offset_y[9]; - int ystride; - int bi; - ystride=_enc->state.ref_ystride[0]; - frag_buf_offs=_enc->state.frag_buf_offs; - fragis=_enc->state.mb_maps[_mbi][0]; - src=_enc->state.ref_frame_data[OC_FRAME_IO]; - ref=_enc->state.ref_frame_data[_enc->state.ref_frame_idx[OC_FRAME_PREV]]; - offset_y[0]=offset_y[1]=offset_y[2]=-ystride; - offset_y[3]=offset_y[5]=0; - offset_y[6]=offset_y[7]=offset_y[8]=ystride; - embs=_enc->mb_info; - for(bi=0;bi<4;bi++){ - ptrdiff_t frag_offs; - int vec[2]; - frag_offs=frag_buf_offs[fragis[bi]]; - vec[0]=OC_DIV2(embs[_mbi].block_mv[bi][0]); - vec[1]=OC_DIV2(embs[_mbi].block_mv[bi][1]); - embs[_mbi].block_satd[bi]=oc_mcenc_ysatd_halfpel_brefine(_enc,vec, - src+frag_offs,ref+frag_offs,ystride,offset_y,embs[_mbi].block_satd[bi]); - embs[_mbi].ref_mv[bi][0]=(signed char)vec[0]; - embs[_mbi].ref_mv[bi][1]=(signed char)vec[1]; - } -} diff --git a/Engine/lib/libtheora/lib/modedec.h b/Engine/lib/libtheora/lib/modedec.h deleted file mode 100644 index ea12c64af..000000000 --- a/Engine/lib/libtheora/lib/modedec.h +++ /dev/null @@ -1,4027 +0,0 @@ -/*File generated by libtheora with OC_COLLECT_METRICS defined at compile time.*/ -#if !defined(_modedec_H) -# define _modedec_H (1) - - - -# if defined(OC_COLLECT_METRICS) -typedef struct oc_mode_metrics oc_mode_metrics; -# endif -typedef struct oc_mode_rd oc_mode_rd; - - - -/*The number of extra bits of precision at which to store rate metrics.*/ -# define OC_BIT_SCALE (6) -/*The number of extra bits of precision at which to store RMSE metrics. - This must be at least half OC_BIT_SCALE (rounded up).*/ -# define OC_RMSE_SCALE (5) -/*The number of bins to partition statistics into.*/ -# define OC_SAD_BINS (24) -/*The number of bits of precision to drop from SAD scores to assign them to a - bin.*/ -# define OC_SAD_SHIFT (9) - - - -# if defined(OC_COLLECT_METRICS) -struct oc_mode_metrics{ - double fragw; - double satd; - double rate; - double rmse; - double satd2; - double satdrate; - double rate2; - double satdrmse; - double rmse2; -}; - - -int oc_has_mode_metrics; -oc_mode_metrics OC_MODE_METRICS[64][3][2][OC_SAD_BINS]; -# endif - - - -struct oc_mode_rd{ - ogg_int16_t rate; - ogg_int16_t rmse; -}; - - -# if !defined(OC_COLLECT_METRICS) -static const -# endif -oc_mode_rd OC_MODE_RD[64][3][2][OC_SAD_BINS]={ - { - { - /*Y' qi=0 INTRA*/ - { - { 87, -66},{ 132, 1611},{ 197, 3474},{ 285, 5130}, - { 376, 6419},{ 450, 7545},{ 521, 8587},{ 600, 9587}, - { 689,10498},{ 790,11348},{ 899,12158},{ 1030,12855}, - { 1166,13459},{ 1276,14052},{ 1353,14732},{ 1444,15425}, - { 1535,16101},{ 1609,16856},{ 1697,17532},{ 1823,17995}, - { 1962,18426},{ 2085,18919},{ 2201,19503},{ 2304,20307} - }, - /*Y' qi=0 INTER*/ - { - { 32, -105},{ 40, 1268},{ 54, 2919},{ 91, 4559}, - { 118, 6244},{ 132, 7932},{ 142, 9514},{ 149,10989}, - { 155,12375},{ 161,13679},{ 168,14958},{ 176,16215}, - { 187,17431},{ 196,18623},{ 207,19790},{ 218,20941}, - { 230,22083},{ 246,23213},{ 265,24333},{ 292,25439}, - { 328,26512},{ 372,27538},{ 427,28522},{ 494,29479} - } - }, - { - /*Cb qi=0 INTRA*/ - { - { 1, 6},{ 27, 368},{ 52, 738},{ 67, 1171}, - { 80, 1642},{ 99, 2134},{ 110, 2642},{ 112, 3144}, - { 126, 3578},{ 154, 3967},{ 167, 4387},{ 172, 4839}, - { 191, 5278},{ 208, 5666},{ 220, 6036},{ 223, 6398}, - { 227, 6814},{ 253, 7157},{ 284, 7403},{ 292, 7699}, - { 314, 7983},{ 339, 8203},{ 363, 8460},{ 399, 8919} - }, - /*Cb qi=0 INTER*/ - { - { 68, -55},{ 63, 275},{ 58, 602},{ 53, 936}, - { 50, 1290},{ 54, 1691},{ 58, 2116},{ 62, 2553}, - { 67, 2992},{ 72, 3422},{ 78, 3843},{ 84, 4253}, - { 89, 4658},{ 94, 5062},{ 98, 5455},{ 100, 5848}, - { 102, 6231},{ 104, 6604},{ 104, 6982},{ 105, 7359}, - { 105, 7733},{ 104, 8104},{ 105, 8465},{ 111, 8828} - } - }, - { - /*Cr qi=0 INTRA*/ - { - { 1, 8},{ 23, 375},{ 47, 759},{ 63, 1220}, - { 71, 1693},{ 82, 2171},{ 94, 2652},{ 109, 3103}, - { 125, 3567},{ 133, 3995},{ 151, 4375},{ 168, 4819}, - { 174, 5244},{ 190, 5635},{ 215, 6005},{ 242, 6347}, - { 257, 6758},{ 280, 7068},{ 311, 7336},{ 326, 7652}, - { 346, 7968},{ 372, 8213},{ 388, 8515},{ 408, 9060} - }, - /*Cr qi=0 INTER*/ - { - { 69, 0},{ 60, 314},{ 49, 624},{ 45, 943}, - { 45, 1285},{ 49, 1691},{ 55, 2130},{ 62, 2560}, - { 71, 2973},{ 79, 3385},{ 85, 3800},{ 89, 4207}, - { 92, 4620},{ 95, 5037},{ 96, 5436},{ 97, 5839}, - { 98, 6252},{ 99, 6653},{ 99, 7038},{ 103, 7426}, - { 107, 7810},{ 108, 8178},{ 107, 8539},{ 106, 8937} - } - } - }, - { - { - /*Y' qi=1 INTRA*/ - { - { 81, -71},{ 133, 1610},{ 203, 3460},{ 296, 5083}, - { 392, 6342},{ 467, 7454},{ 541, 8486},{ 625, 9466}, - { 716,10352},{ 823,11181},{ 940,11961},{ 1074,12643}, - { 1211,13233},{ 1324,13807},{ 1408,14489},{ 1504,15167}, - { 1598,15824},{ 1679,16544},{ 1788,17161},{ 1928,17579}, - { 2070,17991},{ 2202,18456},{ 2324,19021},{ 2425,19894} - }, - /*Y' qi=1 INTER*/ - { - { 34, 4},{ 40, 1307},{ 55, 2914},{ 93, 4555}, - { 120, 6243},{ 134, 7912},{ 144, 9468},{ 152,10918}, - { 158,12275},{ 164,13569},{ 171,14846},{ 180,16098}, - { 191,17310},{ 204,18484},{ 216,19636},{ 228,20779}, - { 242,21912},{ 261,23036},{ 286,24146},{ 320,25221}, - { 363,26265},{ 418,27261},{ 485,28203},{ 551,29148} - } - }, - { - /*Cb qi=1 INTRA*/ - { - { 1, 6},{ 28, 367},{ 52, 738},{ 68, 1172}, - { 86, 1644},{ 106, 2135},{ 115, 2642},{ 119, 3141}, - { 132, 3569},{ 157, 3951},{ 172, 4366},{ 177, 4819}, - { 194, 5258},{ 211, 5638},{ 224, 6006},{ 233, 6367}, - { 236, 6784},{ 258, 7121},{ 299, 7357},{ 319, 7637}, - { 337, 7921},{ 358, 8141},{ 381, 8367},{ 401, 8768} - }, - /*Cb qi=1 INTER*/ - { - { 95, -31},{ 81, 295},{ 67, 614},{ 53, 953}, - { 48, 1305},{ 51, 1700},{ 56, 2125},{ 61, 2563}, - { 67, 3008},{ 73, 3435},{ 79, 3844},{ 85, 4251}, - { 90, 4663},{ 95, 5073},{ 98, 5458},{ 100, 5844}, - { 101, 6231},{ 102, 6606},{ 102, 6980},{ 103, 7347}, - { 104, 7726},{ 105, 8096},{ 105, 8453},{ 105, 8789} - } - }, - { - /*Cr qi=1 INTRA*/ - { - { 1, 8},{ 25, 375},{ 50, 759},{ 65, 1221}, - { 74, 1695},{ 86, 2172},{ 101, 2651},{ 117, 3101}, - { 129, 3561},{ 135, 3985},{ 153, 4368},{ 171, 4807}, - { 182, 5223},{ 202, 5608},{ 225, 5964},{ 251, 6300}, - { 271, 6697},{ 295, 6978},{ 324, 7235},{ 348, 7558}, - { 367, 7877},{ 394, 8101},{ 413, 8386},{ 409, 8945} - }, - /*Cr qi=1 INTER*/ - { - { 66, 11},{ 59, 323},{ 51, 631},{ 44, 949}, - { 44, 1292},{ 49, 1703},{ 56, 2140},{ 62, 2566}, - { 69, 2991},{ 77, 3397},{ 84, 3799},{ 89, 4211}, - { 93, 4634},{ 94, 5049},{ 95, 5444},{ 96, 5854}, - { 94, 6260},{ 95, 6640},{ 96, 7032},{ 101, 7423}, - { 104, 7790},{ 105, 8158},{ 109, 8527},{ 108, 8872} - } - } - }, - { - { - /*Y' qi=2 INTRA*/ - { - { 87, -72},{ 139, 1607},{ 213, 3426},{ 315, 4992}, - { 416, 6217},{ 495, 7315},{ 574, 8317},{ 666, 9265}, - { 763,10124},{ 875,10906},{ 1001,11654},{ 1147,12305}, - { 1289,12865},{ 1407,13424},{ 1503,14076},{ 1610,14724}, - { 1720,15342},{ 1815,16020},{ 1937,16579},{ 2084,16981}, - { 2236,17371},{ 2385,17779},{ 2536,18250},{ 2689,18931} - }, - /*Y' qi=2 INTER*/ - { - { 30, -2},{ 40, 1308},{ 57, 2921},{ 96, 4567}, - { 122, 6260},{ 136, 7902},{ 148, 9418},{ 156,10826}, - { 162,12157},{ 169,13448},{ 177,14709},{ 188,15938}, - { 200,17133},{ 213,18295},{ 228,19433},{ 245,20564}, - { 264,21685},{ 289,22790},{ 323,23876},{ 368,24916}, - { 427,25906},{ 499,26837},{ 585,27700},{ 680,28514} - } - }, - { - /*Cb qi=2 INTRA*/ - { - { 1, 6},{ 30, 367},{ 58, 738},{ 77, 1172}, - { 93, 1645},{ 111, 2137},{ 123, 2642},{ 126, 3133}, - { 136, 3553},{ 162, 3934},{ 178, 4352},{ 183, 4803}, - { 199, 5231},{ 220, 5596},{ 235, 5957},{ 245, 6314}, - { 256, 6718},{ 286, 7048},{ 320, 7285},{ 336, 7568}, - { 366, 7829},{ 387, 8045},{ 405, 8261},{ 445, 8550} - }, - /*Cb qi=2 INTER*/ - { - { 115, -61},{ 93, 277},{ 71, 609},{ 54, 963}, - { 49, 1329},{ 53, 1715},{ 58, 2138},{ 63, 2583}, - { 69, 3017},{ 75, 3442},{ 81, 3857},{ 88, 4263}, - { 93, 4667},{ 96, 5065},{ 101, 5451},{ 101, 5832}, - { 102, 6213},{ 103, 6593},{ 103, 6968},{ 104, 7336}, - { 104, 7710},{ 105, 8076},{ 106, 8440},{ 106, 8822} - } - }, - { - /*Cr qi=2 INTRA*/ - { - { 1, 8},{ 27, 375},{ 54, 759},{ 70, 1222}, - { 79, 1696},{ 89, 2173},{ 106, 2652},{ 123, 3098}, - { 135, 3553},{ 143, 3972},{ 161, 4348},{ 181, 4782}, - { 194, 5189},{ 213, 5565},{ 235, 5907},{ 266, 6229}, - { 286, 6618},{ 311, 6897},{ 339, 7152},{ 362, 7454}, - { 392, 7721},{ 416, 7946},{ 429, 8227},{ 458, 8540} - }, - /*Cr qi=2 INTER*/ - { - { 74, 20},{ 63, 330},{ 51, 635},{ 44, 942}, - { 47, 1287},{ 54, 1710},{ 59, 2147},{ 65, 2571}, - { 72, 2996},{ 79, 3413},{ 86, 3820},{ 91, 4230}, - { 93, 4642},{ 95, 5046},{ 95, 5442},{ 95, 5839}, - { 96, 6243},{ 97, 6641},{ 99, 7021},{ 101, 7396}, - { 103, 7764},{ 106, 8138},{ 109, 8507},{ 114, 8851} - } - } - }, - { - { - /*Y' qi=3 INTRA*/ - { - { 91, -67},{ 141, 1606},{ 219, 3405},{ 328, 4929}, - { 433, 6122},{ 515, 7209},{ 598, 8204},{ 693, 9145}, - { 796, 9986},{ 912,10756},{ 1045,11471},{ 1200,12079}, - { 1345,12640},{ 1471,13179},{ 1571,13809},{ 1678,14450}, - { 1798,15047},{ 1905,15701},{ 2043,16205},{ 2202,16569}, - { 2351,16971},{ 2501,17393},{ 2660,17851},{ 2825,18455} - }, - /*Y' qi=3 INTER*/ - { - { 53, -164},{ 38, 1314},{ 59, 2917},{ 99, 4563}, - { 124, 6253},{ 139, 7882},{ 150, 9375},{ 159,10749}, - { 166,12059},{ 173,13349},{ 183,14608},{ 194,15826}, - { 208,17003},{ 223,18150},{ 240,19287},{ 259,20411}, - { 284,21508},{ 317,22593},{ 359,23656},{ 414,24671}, - { 483,25634},{ 569,26519},{ 670,27332},{ 786,28072} - } - }, - { - /*Cb qi=3 INTRA*/ - { - { 1, 5},{ 31, 367},{ 58, 739},{ 78, 1173}, - { 96, 1645},{ 113, 2134},{ 125, 2638},{ 133, 3127}, - { 148, 3542},{ 171, 3915},{ 184, 4328},{ 192, 4776}, - { 209, 5197},{ 230, 5556},{ 245, 5909},{ 252, 6261}, - { 272, 6641},{ 304, 6942},{ 330, 7184},{ 342, 7477}, - { 380, 7736},{ 404, 7962},{ 428, 8151},{ 469, 8430} - }, - /*Cb qi=3 INTER*/ - { - { 86, -29},{ 72, 296},{ 58, 618},{ 46, 964}, - { 47, 1338},{ 51, 1743},{ 56, 2158},{ 63, 2594}, - { 69, 3035},{ 77, 3455},{ 84, 3859},{ 89, 4266}, - { 94, 4673},{ 98, 5074},{ 101, 5460},{ 101, 5842}, - { 101, 6217},{ 101, 6593},{ 102, 6964},{ 104, 7325}, - { 103, 7696},{ 103, 8056},{ 104, 8430},{ 103, 8792} - } - }, - { - /*Cr qi=3 INTRA*/ - { - { 1, 8},{ 27, 374},{ 56, 759},{ 74, 1221}, - { 83, 1696},{ 96, 2173},{ 113, 2650},{ 127, 3091}, - { 140, 3542},{ 151, 3960},{ 164, 4334},{ 188, 4764}, - { 208, 5144},{ 224, 5493},{ 250, 5841},{ 278, 6162}, - { 298, 6548},{ 334, 6816},{ 365, 7045},{ 388, 7343}, - { 419, 7613},{ 443, 7836},{ 455, 8105},{ 484, 8445} - }, - /*Cr qi=3 INTER*/ - { - { 76, 26},{ 65, 332},{ 53, 638},{ 45, 945}, - { 45, 1304},{ 53, 1725},{ 60, 2153},{ 68, 2584}, - { 74, 3007},{ 81, 3425},{ 87, 3844},{ 91, 4253}, - { 94, 4657},{ 95, 5061},{ 94, 5462},{ 94, 5856}, - { 95, 6250},{ 96, 6635},{ 97, 7014},{ 101, 7393}, - { 104, 7761},{ 106, 8137},{ 109, 8506},{ 111, 8823} - } - } - }, - { - { - /*Y' qi=4 INTRA*/ - { - { 80, -67},{ 143, 1603},{ 227, 3378},{ 344, 4861}, - { 454, 6026},{ 537, 7104},{ 626, 8089},{ 725, 9006}, - { 830, 9827},{ 950,10581},{ 1089,11270},{ 1257,11826}, - { 1409,12366},{ 1535,12912},{ 1640,13528},{ 1753,14173}, - { 1884,14756},{ 2007,15368},{ 2148,15852},{ 2307,16212}, - { 2464,16591},{ 2614,17019},{ 2785,17455},{ 2970,17963} - }, - /*Y' qi=4 INTER*/ - { - { 50, -145},{ 38, 1324},{ 61, 2921},{ 102, 4566}, - { 127, 6248},{ 142, 7845},{ 154, 9300},{ 163,10656}, - { 169,11965},{ 177,13246},{ 188,14495},{ 202,15702}, - { 218,16864},{ 236,18003},{ 256,19124},{ 278,20233}, - { 307,21330},{ 347,22398},{ 398,23437},{ 463,24429}, - { 546,25343},{ 649,26170},{ 767,26935},{ 888,27674} - } - }, - { - /*Cb qi=4 INTRA*/ - { - { 1, 5},{ 33, 367},{ 61, 739},{ 80, 1173}, - { 98, 1646},{ 114, 2136},{ 126, 2639},{ 137, 3124}, - { 152, 3535},{ 176, 3903},{ 194, 4307},{ 206, 4753}, - { 222, 5165},{ 242, 5508},{ 260, 5857},{ 272, 6205}, - { 294, 6559},{ 332, 6848},{ 356, 7104},{ 364, 7389}, - { 396, 7637},{ 415, 7878},{ 446, 8064},{ 506, 8294} - }, - /*Cb qi=4 INTER*/ - { - { 86, -15},{ 73, 308},{ 60, 627},{ 46, 967}, - { 47, 1343},{ 51, 1754},{ 56, 2183},{ 63, 2615}, - { 70, 3044},{ 79, 3459},{ 85, 3866},{ 90, 4276}, - { 94, 4686},{ 97, 5088},{ 100, 5467},{ 102, 5837}, - { 102, 6205},{ 101, 6569},{ 103, 6939},{ 104, 7317}, - { 105, 7690},{ 107, 8043},{ 107, 8394},{ 111, 8736} - } - }, - { - /*Cr qi=4 INTRA*/ - { - { 1, 7},{ 28, 375},{ 57, 759},{ 79, 1221}, - { 92, 1697},{ 105, 2174},{ 122, 2648},{ 135, 3085}, - { 146, 3530},{ 157, 3947},{ 171, 4316},{ 195, 4737}, - { 218, 5117},{ 239, 5445},{ 268, 5767},{ 295, 6074}, - { 315, 6460},{ 355, 6735},{ 392, 6933},{ 418, 7218}, - { 448, 7495},{ 471, 7688},{ 481, 7954},{ 504, 8313} - }, - /*Cr qi=4 INTER*/ - { - { 68, 28},{ 57, 334},{ 47, 639},{ 43, 953}, - { 48, 1314},{ 54, 1736},{ 59, 2169},{ 69, 2592}, - { 78, 3017},{ 84, 3434},{ 88, 3850},{ 92, 4260}, - { 95, 4663},{ 96, 5068},{ 95, 5455},{ 95, 5839}, - { 96, 6243},{ 97, 6626},{ 98, 7006},{ 101, 7390}, - { 104, 7755},{ 108, 8115},{ 111, 8471},{ 110, 8825} - } - } - }, - { - { - /*Y' qi=5 INTRA*/ - { - { 84, -69},{ 147, 1599},{ 237, 3350},{ 360, 4796}, - { 475, 5934},{ 562, 6992},{ 657, 7953},{ 765, 8837}, - { 874, 9641},{ 998,10384},{ 1146,11047},{ 1322,11572}, - { 1484,12076},{ 1617,12609},{ 1731,13203},{ 1856,13806}, - { 1995,14367},{ 2132,14936},{ 2289,15386},{ 2460,15721}, - { 2635,16066},{ 2802,16442},{ 2980,16805},{ 3177,17272} - }, - /*Y' qi=5 INTER*/ - { - { 38, -86},{ 37, 1349},{ 64, 2920},{ 105, 4563}, - { 129, 6236},{ 145, 7809},{ 158, 9236},{ 167,10572}, - { 174,11871},{ 182,13141},{ 195,14368},{ 212,15558}, - { 230,16706},{ 250,17828},{ 274,18944},{ 303,20041}, - { 342,21116},{ 394,22152},{ 460,23144},{ 543,24073}, - { 648,24919},{ 773,25673},{ 922,26323},{ 1084,26924} - } - }, - { - /*Cb qi=5 INTRA*/ - { - { 1, 5},{ 34, 367},{ 63, 739},{ 82, 1174}, - { 102, 1647},{ 119, 2137},{ 134, 2639},{ 145, 3121}, - { 161, 3529},{ 189, 3891},{ 207, 4290},{ 216, 4721}, - { 232, 5113},{ 258, 5455},{ 277, 5798},{ 294, 6124}, - { 322, 6427},{ 352, 6697},{ 370, 6982},{ 384, 7283}, - { 423, 7529},{ 448, 7766},{ 478, 7943},{ 527, 8151} - }, - /*Cb qi=5 INTER*/ - { - { 83, -49},{ 69, 284},{ 55, 611},{ 48, 961}, - { 49, 1355},{ 52, 1769},{ 58, 2191},{ 65, 2616}, - { 73, 3041},{ 80, 3460},{ 87, 3868},{ 92, 4276}, - { 95, 4682},{ 98, 5077},{ 100, 5459},{ 102, 5827}, - { 102, 6200},{ 102, 6568},{ 103, 6930},{ 103, 7303}, - { 104, 7672},{ 106, 8032},{ 106, 8391},{ 106, 8727} - } - }, - { - /*Cr qi=5 INTRA*/ - { - { 1, 8},{ 28, 375},{ 57, 760},{ 81, 1222}, - { 99, 1696},{ 111, 2175},{ 125, 2648},{ 140, 3079}, - { 152, 3520},{ 162, 3927},{ 179, 4294},{ 203, 4714}, - { 225, 5080},{ 254, 5389},{ 286, 5703},{ 318, 5997}, - { 342, 6364},{ 380, 6640},{ 416, 6837},{ 445, 7103}, - { 473, 7370},{ 497, 7562},{ 514, 7811},{ 549, 8148} - }, - /*Cr qi=5 INTER*/ - { - { 60, 6},{ 54, 323},{ 46, 638},{ 43, 958}, - { 45, 1329},{ 54, 1749},{ 61, 2175},{ 70, 2600}, - { 79, 3021},{ 85, 3437},{ 89, 3847},{ 93, 4254}, - { 95, 4660},{ 96, 5065},{ 95, 5456},{ 95, 5849}, - { 96, 6243},{ 96, 6621},{ 97, 6996},{ 101, 7366}, - { 104, 7722},{ 107, 8088},{ 111, 8448},{ 119, 8816} - } - } - }, - { - { - /*Y' qi=6 INTRA*/ - { - { 88, -69},{ 151, 1593},{ 251, 3294},{ 387, 4681}, - { 507, 5790},{ 601, 6837},{ 702, 7787},{ 813, 8648}, - { 927, 9427},{ 1059,10152},{ 1213,10787},{ 1399,11284}, - { 1568,11781},{ 1705,12312},{ 1823,12890},{ 1957,13482}, - { 2106,14036},{ 2249,14600},{ 2411,15042},{ 2588,15359}, - { 2772,15699},{ 2947,16062},{ 3127,16429},{ 3320,16849} - }, - /*Y' qi=6 INTER*/ - { - { 44, -80},{ 36, 1346},{ 69, 2919},{ 111, 4563}, - { 136, 6216},{ 154, 7746},{ 168, 9139},{ 178,10461}, - { 185,11747},{ 195,13007},{ 211,14229},{ 230,15408}, - { 250,16547},{ 274,17663},{ 302,18769},{ 339,19851}, - { 386,20907},{ 446,21933},{ 527,22884},{ 631,23746}, - { 760,24512},{ 914,25178},{ 1087,25758},{ 1278,26262} - } - }, - { - /*Cb qi=6 INTRA*/ - { - { 1, 4},{ 36, 367},{ 66, 739},{ 84, 1174}, - { 105, 1648},{ 126, 2139},{ 140, 2639},{ 149, 3116}, - { 164, 3523},{ 194, 3880},{ 217, 4271},{ 226, 4694}, - { 243, 5077},{ 270, 5407},{ 291, 5742},{ 310, 6061}, - { 340, 6340},{ 373, 6609},{ 394, 6890},{ 409, 7189}, - { 444, 7434},{ 469, 7652},{ 499, 7853},{ 559, 8135} - }, - /*Cb qi=6 INTER*/ - { - { 68, -46},{ 60, 291},{ 50, 623},{ 49, 971}, - { 50, 1357},{ 55, 1781},{ 61, 2211},{ 69, 2634}, - { 78, 3052},{ 86, 3466},{ 91, 3882},{ 95, 4292}, - { 98, 4691},{ 101, 5080},{ 102, 5458},{ 103, 5830}, - { 103, 6192},{ 104, 6554},{ 104, 6916},{ 106, 7278}, - { 108, 7641},{ 110, 8004},{ 112, 8371},{ 112, 8758} - } - }, - { - /*Cr qi=6 INTRA*/ - { - { 1, 8},{ 29, 375},{ 59, 760},{ 84, 1223}, - { 99, 1698},{ 112, 2176},{ 129, 2647},{ 143, 3076}, - { 156, 3510},{ 168, 3906},{ 189, 4269},{ 220, 4682}, - { 241, 5047},{ 266, 5342},{ 299, 5649},{ 331, 5954}, - { 357, 6309},{ 393, 6579},{ 431, 6765},{ 467, 6997}, - { 501, 7276},{ 520, 7488},{ 525, 7749},{ 548, 8146} - }, - /*Cr qi=6 INTER*/ - { - { 94, 31},{ 69, 335},{ 47, 641},{ 43, 967}, - { 50, 1350},{ 57, 1772},{ 65, 2197},{ 74, 2625}, - { 83, 3043},{ 90, 3454},{ 94, 3867},{ 97, 4273}, - { 98, 4671},{ 99, 5068},{ 99, 5461},{ 98, 5857}, - { 98, 6245},{ 99, 6610},{ 103, 6975},{ 105, 7345}, - { 108, 7712},{ 111, 8073},{ 113, 8415},{ 119, 8768} - } - } - }, - { - { - /*Y' qi=7 INTRA*/ - { - { 92, -70},{ 156, 1590},{ 261, 3267},{ 403, 4618}, - { 529, 5704},{ 628, 6730},{ 736, 7657},{ 856, 8491}, - { 978, 9246},{ 1118, 9943},{ 1281,10550},{ 1472,11028}, - { 1645,11507},{ 1793,12008},{ 1924,12565},{ 2067,13130}, - { 2229,13638},{ 2388,14160},{ 2558,14584},{ 2744,14886}, - { 2932,15194},{ 3116,15531},{ 3311,15858},{ 3538,16197} - }, - /*Y' qi=7 INTER*/ - { - { 43, -8},{ 36, 1351},{ 71, 2923},{ 112, 4568}, - { 138, 6201},{ 157, 7705},{ 171, 9083},{ 181,10390}, - { 189,11664},{ 202,12910},{ 220,14121},{ 241,15281}, - { 266,16401},{ 295,17507},{ 328,18608},{ 371,19677}, - { 430,20701},{ 508,21676},{ 604,22588},{ 727,23397}, - { 878,24093},{ 1055,24690},{ 1263,25151},{ 1496,25504} - } - }, - { - /*Cb qi=7 INTRA*/ - { - { 1, 5},{ 40, 367},{ 72, 740},{ 89, 1175}, - { 108, 1649},{ 129, 2140},{ 143, 2637},{ 154, 3110}, - { 169, 3507},{ 198, 3860},{ 224, 4237},{ 235, 4652}, - { 253, 5037},{ 282, 5358},{ 307, 5674},{ 329, 5986}, - { 361, 6273},{ 393, 6527},{ 419, 6777},{ 435, 7078}, - { 467, 7342},{ 495, 7554},{ 529, 7757},{ 591, 8053} - }, - /*Cb qi=7 INTER*/ - { - { 79, -33},{ 68, 299},{ 56, 627},{ 50, 978}, - { 51, 1366},{ 55, 1786},{ 61, 2213},{ 70, 2642}, - { 80, 3062},{ 87, 3474},{ 92, 3886},{ 96, 4292}, - { 99, 4684},{ 102, 5072},{ 103, 5450},{ 104, 5814}, - { 104, 6176},{ 104, 6538},{ 107, 6905},{ 110, 7270}, - { 110, 7625},{ 110, 7978},{ 111, 8340},{ 117, 8674} - } - }, - { - /*Cr qi=7 INTRA*/ - { - { 2, 7},{ 31, 375},{ 62, 760},{ 87, 1223}, - { 103, 1698},{ 115, 2175},{ 131, 2644},{ 147, 3066}, - { 161, 3494},{ 175, 3889},{ 199, 4250},{ 229, 4653}, - { 250, 5001},{ 279, 5275},{ 311, 5577},{ 343, 5889}, - { 376, 6227},{ 417, 6486},{ 457, 6689},{ 484, 6925}, - { 518, 7174},{ 544, 7393},{ 549, 7662},{ 577, 8050} - }, - /*Cr qi=7 INTER*/ - { - { 89, 22},{ 62, 332},{ 45, 641},{ 47, 976}, - { 52, 1363},{ 59, 1779},{ 67, 2203},{ 76, 2628}, - { 84, 3046},{ 90, 3460},{ 94, 3875},{ 98, 4272}, - { 99, 4666},{ 98, 5063},{ 98, 5459},{ 98, 5849}, - { 99, 6226},{ 101, 6594},{ 104, 6957},{ 109, 7324}, - { 109, 7686},{ 111, 8042},{ 115, 8379},{ 119, 8699} - } - } - }, - { - { - /*Y' qi=8 INTRA*/ - { - { 91, -69},{ 160, 1585},{ 274, 3226},{ 423, 4538}, - { 557, 5596},{ 664, 6595},{ 778, 7506},{ 905, 8319}, - { 1038, 9035},{ 1186, 9701},{ 1355,10292},{ 1554,10754}, - { 1739,11196},{ 1904,11639},{ 2047,12184},{ 2194,12763}, - { 2361,13256},{ 2529,13753},{ 2709,14155},{ 2902,14433}, - { 3100,14723},{ 3292,15026},{ 3489,15327},{ 3714,15705} - }, - /*Y' qi=8 INTER*/ - { - { 32, -157},{ 33, 1346},{ 74, 2914},{ 116, 4554}, - { 142, 6172},{ 162, 7648},{ 177, 9004},{ 186,10300}, - { 196,11570},{ 210,12808},{ 231,14001},{ 256,15150}, - { 285,16259},{ 319,17352},{ 359,18435},{ 415,19475}, - { 489,20470},{ 584,21400},{ 703,22246},{ 852,22968}, - { 1038,23556},{ 1253,24032},{ 1503,24367},{ 1778,24628} - } - }, - { - /*Cb qi=8 INTRA*/ - { - { 1, 4},{ 42, 367},{ 75, 740},{ 93, 1176}, - { 111, 1649},{ 128, 2139},{ 144, 2635},{ 157, 3103}, - { 174, 3494},{ 206, 3844},{ 233, 4207},{ 251, 4605}, - { 277, 4980},{ 304, 5284},{ 335, 5584},{ 359, 5888}, - { 393, 6152},{ 432, 6398},{ 455, 6656},{ 471, 6956}, - { 502, 7193},{ 528, 7405},{ 562, 7630},{ 603, 7922} - }, - /*Cb qi=8 INTER*/ - { - { 77, -37},{ 68, 299},{ 58, 632},{ 50, 991}, - { 50, 1382},{ 55, 1799},{ 62, 2226},{ 73, 2647}, - { 82, 3066},{ 90, 3480},{ 94, 3891},{ 96, 4296}, - { 98, 4687},{ 101, 5073},{ 103, 5456},{ 104, 5817}, - { 105, 6170},{ 106, 6523},{ 107, 6886},{ 108, 7250}, - { 109, 7600},{ 110, 7955},{ 111, 8305},{ 112, 8641} - } - }, - { - /*Cr qi=8 INTRA*/ - { - { 2, 7},{ 33, 375},{ 64, 760},{ 92, 1224}, - { 111, 1700},{ 122, 2173},{ 137, 2637},{ 156, 3055}, - { 172, 3476},{ 186, 3856},{ 211, 4211},{ 242, 4597}, - { 263, 4939},{ 292, 5214},{ 335, 5489},{ 376, 5772}, - { 406, 6099},{ 440, 6378},{ 483, 6578},{ 517, 6797}, - { 550, 7049},{ 571, 7283},{ 583, 7560},{ 618, 7967} - }, - /*Cr qi=8 INTER*/ - { - { 74, 25},{ 58, 328},{ 43, 637},{ 45, 980}, - { 51, 1371},{ 59, 1788},{ 69, 2207},{ 79, 2630}, - { 86, 3051},{ 91, 3470},{ 95, 3880},{ 97, 4280}, - { 98, 4680},{ 97, 5074},{ 96, 5456},{ 97, 5839}, - { 99, 6219},{ 101, 6583},{ 103, 6945},{ 106, 7312}, - { 110, 7671},{ 114, 8009},{ 115, 8345},{ 117, 8686} - } - } - }, - { - { - /*Y' qi=9 INTRA*/ - { - { 104, -68},{ 164, 1580},{ 288, 3173},{ 448, 4439}, - { 587, 5485},{ 702, 6465},{ 824, 7351},{ 958, 8148}, - { 1096, 8845},{ 1253, 9480},{ 1432,10047},{ 1640,10494}, - { 1835,10926},{ 2015,11350},{ 2166,11871},{ 2321,12428}, - { 2508,12876},{ 2684,13345},{ 2866,13741},{ 3069,13991}, - { 3281,14243},{ 3487,14518},{ 3689,14813},{ 3911,15175} - }, - /*Y' qi=9 INTER*/ - { - { 47, -140},{ 34, 1348},{ 77, 2915},{ 119, 4552}, - { 145, 6150},{ 166, 7600},{ 182, 8936},{ 192,10221}, - { 203,11482},{ 220,12711},{ 244,13886},{ 274,15012}, - { 308,16111},{ 349,17190},{ 401,18244},{ 470,19257}, - { 561,20209},{ 680,21069},{ 830,21822},{ 1010,22463}, - { 1227,22971},{ 1482,23328},{ 1769,23544},{ 2077,23655} - } - }, - { - /*Cb qi=9 INTRA*/ - { - { 1, 5},{ 43, 367},{ 76, 740},{ 95, 1176}, - { 114, 1649},{ 135, 2138},{ 153, 2629},{ 165, 3091}, - { 184, 3481},{ 217, 3831},{ 244, 4187},{ 260, 4572}, - { 290, 4930},{ 320, 5231},{ 351, 5521},{ 379, 5812}, - { 414, 6055},{ 452, 6307},{ 483, 6564},{ 502, 6848}, - { 525, 7115},{ 554, 7321},{ 589, 7533},{ 626, 7833} - }, - /*Cb qi=9 INTER*/ - { - { 101, -43},{ 81, 298},{ 62, 637},{ 49, 989}, - { 51, 1381},{ 56, 1806},{ 65, 2231},{ 74, 2653}, - { 84, 3071},{ 91, 3482},{ 95, 3892},{ 97, 4293}, - { 99, 4684},{ 101, 5066},{ 103, 5437},{ 103, 5793}, - { 103, 6148},{ 104, 6511},{ 105, 6867},{ 107, 7221}, - { 110, 7572},{ 111, 7926},{ 112, 8283},{ 116, 8625} - } - }, - { - /*Cr qi=9 INTRA*/ - { - { 2, 7},{ 35, 375},{ 66, 761},{ 93, 1224}, - { 112, 1700},{ 126, 2173},{ 144, 2633},{ 165, 3047}, - { 183, 3458},{ 199, 3835},{ 224, 4191},{ 257, 4558}, - { 283, 4887},{ 309, 5176},{ 351, 5446},{ 397, 5713}, - { 433, 6017},{ 469, 6283},{ 508, 6480},{ 546, 6687}, - { 579, 6945},{ 600, 7182},{ 610, 7434},{ 623, 7793} - }, - /*Cr qi=9 INTER*/ - { - { 77, 15},{ 57, 330},{ 45, 640},{ 48, 980}, - { 54, 1380},{ 61, 1802},{ 70, 2220},{ 80, 2639}, - { 87, 3057},{ 92, 3474},{ 94, 3882},{ 98, 4282}, - { 98, 4675},{ 97, 5062},{ 97, 5450},{ 98, 5829}, - { 100, 6197},{ 101, 6561},{ 104, 6927},{ 107, 7289}, - { 113, 7638},{ 117, 7978},{ 119, 8311},{ 117, 8629} - } - } - }, - { - { - /*Y' qi=10 INTRA*/ - { - { 101, -69},{ 168, 1574},{ 299, 3143},{ 465, 4386}, - { 610, 5410},{ 736, 6353},{ 866, 7207},{ 1006, 7982}, - { 1153, 8655},{ 1319, 9261},{ 1504, 9812},{ 1719,10248}, - { 1928,10653},{ 2116,11056},{ 2282,11550},{ 2458,12070}, - { 2654,12492},{ 2846,12923},{ 3043,13291},{ 3249,13537}, - { 3466,13764},{ 3682,13999},{ 3896,14268},{ 4145,14548} - }, - /*Y' qi=10 INTER*/ - { - { 48, -94},{ 34, 1355},{ 81, 2920},{ 124, 4545}, - { 151, 6113},{ 174, 7532},{ 190, 8850},{ 201,10125}, - { 214,11379},{ 235,12591},{ 264,13745},{ 299,14859}, - { 338,15948},{ 388,17008},{ 456,18029},{ 546,18988}, - { 661,19877},{ 808,20666},{ 993,21321},{ 1218,21835}, - { 1481,22203},{ 1783,22420},{ 2117,22504},{ 2469,22481} - } - }, - { - /*Cb qi=10 INTRA*/ - { - { 2, 4},{ 44, 367},{ 79, 740},{ 99, 1178}, - { 117, 1652},{ 137, 2141},{ 156, 2630},{ 170, 3089}, - { 192, 3474},{ 227, 3813},{ 259, 4157},{ 282, 4526}, - { 310, 4860},{ 342, 5140},{ 377, 5425},{ 400, 5714}, - { 436, 5952},{ 475, 6194},{ 496, 6468},{ 522, 6748}, - { 559, 6996},{ 587, 7216},{ 617, 7433},{ 673, 7678} - }, - /*Cb qi=10 INTER*/ - { - { 87, -37},{ 72, 301},{ 58, 636},{ 49, 995}, - { 51, 1394},{ 57, 1819},{ 66, 2241},{ 78, 2660}, - { 87, 3074},{ 93, 3482},{ 97, 3891},{ 99, 4294}, - { 101, 4678},{ 103, 5050},{ 105, 5414},{ 106, 5773}, - { 107, 6134},{ 108, 6485},{ 110, 6832},{ 113, 7187}, - { 113, 7547},{ 114, 7887},{ 117, 8230},{ 112, 8590} - } - }, - { - /*Cr qi=10 INTRA*/ - { - { 2, 7},{ 38, 375},{ 69, 761},{ 96, 1224}, - { 116, 1701},{ 131, 2175},{ 148, 2634},{ 168, 3041}, - { 190, 3439},{ 211, 3802},{ 238, 4151},{ 271, 4506}, - { 297, 4824},{ 331, 5103},{ 373, 5360},{ 415, 5632}, - { 459, 5928},{ 500, 6176},{ 535, 6386},{ 573, 6586}, - { 608, 6834},{ 629, 7079},{ 642, 7337},{ 686, 7680} - }, - /*Cr qi=10 INTER*/ - { - { 81, 34},{ 63, 333},{ 50, 633},{ 48, 987}, - { 53, 1397},{ 61, 1820},{ 71, 2237},{ 83, 2651}, - { 91, 3065},{ 95, 3479},{ 98, 3882},{ 100, 4279}, - { 101, 4673},{ 101, 5054},{ 100, 5429},{ 101, 5801}, - { 102, 6173},{ 104, 6541},{ 108, 6904},{ 110, 7264}, - { 114, 7609},{ 119, 7945},{ 123, 8275},{ 128, 8615} - } - } - }, - { - { - /*Y' qi=11 INTRA*/ - { - { 110, -66},{ 176, 1564},{ 316, 3087},{ 492, 4296}, - { 645, 5299},{ 781, 6217},{ 924, 7039},{ 1075, 7776}, - { 1232, 8421},{ 1410, 9005},{ 1607, 9532},{ 1834, 9929}, - { 2053,10300},{ 2249,10697},{ 2427,11184},{ 2619,11682}, - { 2826,12083},{ 3019,12508},{ 3225,12869},{ 3452,13064}, - { 3670,13280},{ 3890,13519},{ 4123,13750},{ 4367,14059} - }, - /*Y' qi=11 INTER*/ - { - { 72, -115},{ 32, 1354},{ 83, 2911},{ 126, 4534}, - { 154, 6080},{ 178, 7475},{ 194, 8779},{ 205,10047}, - { 222,11290},{ 246,12488},{ 281,13621},{ 322,14714}, - { 372,15786},{ 436,16821},{ 519,17813},{ 628,18728}, - { 770,19549},{ 950,20254},{ 1175,20800},{ 1443,21197}, - { 1752,21446},{ 2095,21555},{ 2457,21553},{ 2808,21544} - } - }, - { - /*Cb qi=11 INTRA*/ - { - { 2, 4},{ 45, 367},{ 81, 740},{ 101, 1177}, - { 121, 1650},{ 142, 2136},{ 159, 2621},{ 174, 3075}, - { 199, 3451},{ 234, 3778},{ 265, 4117},{ 297, 4473}, - { 333, 4789},{ 367, 5054},{ 402, 5319},{ 427, 5613}, - { 462, 5871},{ 503, 6107},{ 532, 6336},{ 560, 6584}, - { 601, 6842},{ 631, 7092},{ 662, 7292},{ 721, 7497} - }, - /*Cb qi=11 INTER*/ - { - { 117, -24},{ 93, 308},{ 69, 638},{ 52, 993}, - { 52, 1395},{ 58, 1822},{ 68, 2246},{ 80, 2665}, - { 89, 3082},{ 94, 3492},{ 96, 3900},{ 98, 4299}, - { 101, 4679},{ 103, 5047},{ 104, 5405},{ 106, 5763}, - { 106, 6120},{ 107, 6474},{ 109, 6823},{ 112, 7163}, - { 115, 7516},{ 117, 7868},{ 118, 8213},{ 119, 8561} - } - }, - { - /*Cr qi=11 INTRA*/ - { - { 2, 7},{ 40, 375},{ 75, 761},{ 100, 1224}, - { 119, 1700},{ 137, 2169},{ 154, 2622},{ 178, 3025}, - { 198, 3416},{ 220, 3770},{ 255, 4114},{ 294, 4459}, - { 323, 4756},{ 359, 5028},{ 399, 5292},{ 438, 5556}, - { 483, 5827},{ 518, 6073},{ 551, 6298},{ 598, 6501}, - { 634, 6754},{ 652, 6997},{ 670, 7211},{ 689, 7560} - }, - /*Cr qi=11 INTER*/ - { - { 75, 30},{ 61, 334},{ 51, 639},{ 49, 995}, - { 53, 1403},{ 62, 1821},{ 73, 2237},{ 84, 2654}, - { 91, 3070},{ 95, 3485},{ 96, 3890},{ 98, 4287}, - { 98, 4672},{ 99, 5050},{ 99, 5427},{ 100, 5798}, - { 103, 6169},{ 105, 6528},{ 107, 6881},{ 113, 7233}, - { 118, 7580},{ 121, 7916},{ 125, 8240},{ 130, 8551} - } - } - }, - { - { - /*Y' qi=12 INTRA*/ - { - { 104, -69},{ 182, 1557},{ 335, 3040},{ 521, 4205}, - { 684, 5178},{ 831, 6068},{ 986, 6854},{ 1151, 7559}, - { 1323, 8169},{ 1523, 8704},{ 1736, 9192},{ 1978, 9558}, - { 2213, 9908},{ 2421,10298},{ 2613,10757},{ 2822,11208}, - { 3042,11585},{ 3250,11991},{ 3474,12308},{ 3710,12480}, - { 3939,12687},{ 4174,12902},{ 4416,13102},{ 4672,13369} - }, - /*Y' qi=12 INTER*/ - { - { 52, -91},{ 34, 1355},{ 86, 2911},{ 129, 4518}, - { 159, 6037},{ 184, 7405},{ 200, 8694},{ 213, 9955}, - { 232,11185},{ 263,12360},{ 304,13479},{ 354,14555}, - { 415,15601},{ 495,16608},{ 601,17549},{ 738,18400}, - { 915,19136},{ 1139,19724},{ 1414,20150},{ 1731,20412}, - { 2090,20520},{ 2473,20509},{ 2851,20442},{ 3227,20328} - } - }, - { - /*Cb qi=12 INTRA*/ - { - { 1, 4},{ 46, 367},{ 85, 740},{ 109, 1178}, - { 126, 1650},{ 145, 2134},{ 165, 2617},{ 182, 3061}, - { 209, 3428},{ 245, 3749},{ 281, 4077},{ 316, 4417}, - { 354, 4718},{ 392, 4970},{ 430, 5217},{ 456, 5501}, - { 490, 5771},{ 534, 5996},{ 571, 6207},{ 600, 6458}, - { 644, 6697},{ 675, 6942},{ 707, 7151},{ 766, 7342} - }, - /*Cb qi=12 INTER*/ - { - { 84, -24},{ 73, 311},{ 60, 644},{ 52, 998}, - { 53, 1398},{ 60, 1825},{ 71, 2249},{ 83, 2665}, - { 90, 3081},{ 94, 3490},{ 97, 3893},{ 99, 4286}, - { 102, 4663},{ 104, 5032},{ 105, 5393},{ 106, 5751}, - { 107, 6102},{ 108, 6445},{ 111, 6788},{ 113, 7136}, - { 114, 7483},{ 117, 7828},{ 121, 8163},{ 122, 8496} - } - }, - { - /*Cr qi=12 INTRA*/ - { - { 3, 7},{ 41, 375},{ 78, 761},{ 106, 1225}, - { 124, 1700},{ 140, 2167},{ 163, 2616},{ 188, 3010}, - { 213, 3385},{ 240, 3718},{ 271, 4062},{ 309, 4406}, - { 345, 4691},{ 387, 4956},{ 430, 5212},{ 469, 5467}, - { 513, 5729},{ 554, 5970},{ 587, 6176},{ 633, 6395}, - { 673, 6659},{ 692, 6868},{ 712, 7061},{ 758, 7259} - }, - /*Cr qi=12 INTER*/ - { - { 73, 31},{ 59, 335},{ 48, 638},{ 50, 998}, - { 56, 1410},{ 65, 1827},{ 75, 2240},{ 85, 2657}, - { 92, 3073},{ 95, 3485},{ 97, 3888},{ 99, 4279}, - { 98, 4663},{ 99, 5042},{ 101, 5412},{ 102, 5779}, - { 105, 6142},{ 107, 6498},{ 108, 6848},{ 113, 7198}, - { 118, 7540},{ 121, 7867},{ 127, 8188},{ 132, 8508} - } - } - }, - { - { - /*Y' qi=13 INTRA*/ - { - { 109, -68},{ 187, 1551},{ 347, 3010},{ 541, 4153}, - { 709, 5107},{ 864, 5975},{ 1026, 6745},{ 1194, 7433}, - { 1375, 8021},{ 1581, 8550},{ 1803, 9026},{ 2054, 9371}, - { 2301, 9713},{ 2522,10082},{ 2728,10515},{ 2949,10956}, - { 3184,11297},{ 3408,11653},{ 3643,11946},{ 3886,12100}, - { 4124,12277},{ 4377,12459},{ 4632,12635},{ 4898,12861} - }, - /*Y' qi=13 INTER*/ - { - { 48, -78},{ 35, 1357},{ 89, 2914},{ 133, 4512}, - { 164, 6004},{ 190, 7348},{ 207, 8627},{ 222, 9881}, - { 247,11096},{ 284,12251},{ 333,13350},{ 392,14407}, - { 466,15426},{ 565,16391},{ 696,17279},{ 865,18058}, - { 1085,18689},{ 1358,19156},{ 1684,19456},{ 2050,19605}, - { 2447,19614},{ 2855,19524},{ 3243,19398},{ 3611,19201} - } - }, - { - /*Cb qi=13 INTRA*/ - { - { 2, 4},{ 47, 367},{ 86, 741},{ 108, 1179}, - { 127, 1651},{ 150, 2133},{ 173, 2611},{ 194, 3050}, - { 222, 3417},{ 262, 3733},{ 303, 4048},{ 337, 4375}, - { 378, 4657},{ 420, 4897},{ 456, 5148},{ 486, 5422}, - { 518, 5682},{ 558, 5903},{ 592, 6113},{ 623, 6372}, - { 662, 6628},{ 700, 6833},{ 751, 6989},{ 805, 7147} - }, - /*Cb qi=13 INTER*/ - { - { 94, -34},{ 78, 303},{ 60, 638},{ 51, 994}, - { 54, 1406},{ 61, 1836},{ 73, 2253},{ 84, 2668}, - { 92, 3082},{ 96, 3492},{ 99, 3894},{ 101, 4284}, - { 103, 4659},{ 105, 5023},{ 106, 5376},{ 108, 5726}, - { 109, 6070},{ 110, 6418},{ 113, 6765},{ 117, 7105}, - { 119, 7448},{ 122, 7784},{ 126, 8119},{ 131, 8463} - } - }, - { - /*Cr qi=13 INTRA*/ - { - { 3, 7},{ 43, 375},{ 80, 762},{ 110, 1226}, - { 131, 1701},{ 149, 2166},{ 172, 2610},{ 196, 2999}, - { 221, 3359},{ 254, 3679},{ 292, 4005},{ 332, 4329}, - { 369, 4612},{ 408, 4880},{ 456, 5139},{ 500, 5388}, - { 544, 5631},{ 581, 5877},{ 615, 6101},{ 660, 6316}, - { 692, 6594},{ 714, 6795},{ 736, 6997},{ 789, 7290} - }, - /*Cr qi=13 INTER*/ - { - { 73, 28},{ 61, 336},{ 46, 642},{ 50, 1003}, - { 58, 1414},{ 67, 1832},{ 79, 2245},{ 87, 2660}, - { 93, 3075},{ 97, 3484},{ 99, 3888},{ 100, 4277}, - { 100, 4651},{ 100, 5027},{ 101, 5403},{ 102, 5765}, - { 105, 6116},{ 109, 6470},{ 113, 6825},{ 119, 7163}, - { 124, 7497},{ 127, 7827},{ 131, 8137},{ 135, 8437} - } - } - }, - { - { - /*Y' qi=14 INTRA*/ - { - { 113, -68},{ 191, 1545},{ 358, 2981},{ 559, 4104}, - { 733, 5044},{ 896, 5890},{ 1066, 6636},{ 1241, 7304}, - { 1428, 7886},{ 1642, 8402},{ 1872, 8871},{ 2128, 9219}, - { 2380, 9547},{ 2609, 9908},{ 2825,10321},{ 3055,10728}, - { 3294,11076},{ 3523,11425},{ 3766,11689},{ 4013,11845}, - { 4254,12022},{ 4506,12209},{ 4759,12383},{ 5013,12637} - }, - /*Y' qi=14 INTER*/ - { - { 58, -82},{ 38, 1362},{ 93, 2914},{ 138, 4492}, - { 171, 5962},{ 198, 7289},{ 216, 8559},{ 234, 9804}, - { 263,11005},{ 306,12143},{ 363,13222},{ 434,14259}, - { 523,15255},{ 639,16188},{ 794,17021},{ 1000,17717}, - { 1262,18260},{ 1575,18645},{ 1943,18841},{ 2356,18872}, - { 2782,18802},{ 3194,18682},{ 3576,18559},{ 3923,18447} - } - }, - { - /*Cb qi=14 INTRA*/ - { - { 2, 3},{ 50, 367},{ 91, 741},{ 114, 1180}, - { 134, 1651},{ 157, 2131},{ 181, 2601},{ 208, 3028}, - { 239, 3391},{ 279, 3706},{ 322, 4000},{ 361, 4309}, - { 406, 4587},{ 445, 4822},{ 482, 5067},{ 515, 5344}, - { 546, 5612},{ 589, 5821},{ 626, 6020},{ 655, 6276}, - { 701, 6523},{ 748, 6717},{ 796, 6876},{ 815, 7151} - }, - /*Cb qi=14 INTER*/ - { - { 80, -43},{ 68, 301},{ 56, 644},{ 50, 1004}, - { 54, 1412},{ 63, 1836},{ 75, 2253},{ 87, 2670}, - { 94, 3083},{ 98, 3487},{ 101, 3885},{ 103, 4271}, - { 106, 4645},{ 107, 5004},{ 108, 5358},{ 109, 5705}, - { 112, 6047},{ 115, 6388},{ 118, 6731},{ 121, 7081}, - { 126, 7421},{ 129, 7747},{ 132, 8076},{ 137, 8419} - } - }, - { - /*Cr qi=14 INTRA*/ - { - { 3, 6},{ 45, 375},{ 85, 762},{ 116, 1226}, - { 138, 1700},{ 158, 2163},{ 180, 2602},{ 206, 2985}, - { 236, 3333},{ 270, 3639},{ 310, 3956},{ 359, 4258}, - { 397, 4524},{ 430, 4802},{ 478, 5068},{ 527, 5316}, - { 572, 5560},{ 613, 5802},{ 654, 6012},{ 699, 6216}, - { 734, 6489},{ 755, 6707},{ 775, 6898},{ 841, 7111} - }, - /*Cr qi=14 INTER*/ - { - { 78, 0},{ 59, 322},{ 46, 649},{ 51, 1016}, - { 58, 1422},{ 68, 1839},{ 81, 2253},{ 90, 2666}, - { 95, 3080},{ 98, 3486},{ 101, 3881},{ 102, 4268}, - { 102, 4644},{ 103, 5017},{ 105, 5382},{ 106, 5743}, - { 108, 6093},{ 112, 6442},{ 118, 6791},{ 124, 7130}, - { 127, 7463},{ 133, 7784},{ 138, 8085},{ 142, 8395} - } - } - }, - { - { - /*Y' qi=15 INTRA*/ - { - { 111, -66},{ 197, 1538},{ 370, 2949},{ 579, 4050}, - { 762, 4968},{ 933, 5798},{ 1112, 6520},{ 1299, 7161}, - { 1497, 7725},{ 1723, 8219},{ 1967, 8654},{ 2234, 8990}, - { 2499, 9302},{ 2740, 9637},{ 2968,10039},{ 3215,10414}, - { 3473,10709},{ 3721,11015},{ 3971,11270},{ 4228,11402}, - { 4487,11543},{ 4752,11707},{ 5011,11871},{ 5290,12099} - }, - /*Y' qi=15 INTER*/ - { - { 59, -113},{ 37, 1349},{ 95, 2904},{ 139, 4478}, - { 174, 5929},{ 201, 7244},{ 220, 8505},{ 241, 9736}, - { 275,10922},{ 327,12040},{ 395,13097},{ 477,14114}, - { 585,15071},{ 730,15947},{ 917,16714},{ 1162,17326}, - { 1468,17770},{ 1833,18029},{ 2251,18111},{ 2694,18068}, - { 3125,17968},{ 3529,17845},{ 3908,17713},{ 4260,17587} - } - }, - { - /*Cb qi=15 INTRA*/ - { - { 2, 3},{ 51, 367},{ 94, 741},{ 120, 1180}, - { 140, 1651},{ 160, 2129},{ 184, 2591},{ 213, 3010}, - { 246, 3371},{ 289, 3680},{ 335, 3969},{ 374, 4274}, - { 418, 4546},{ 460, 4783},{ 498, 5019},{ 532, 5280}, - { 565, 5553},{ 608, 5765},{ 647, 5958},{ 683, 6193}, - { 732, 6433},{ 782, 6620},{ 832, 6769},{ 848, 7027} - }, - /*Cb qi=15 INTER*/ - { - { 71, -52},{ 63, 296},{ 54, 644},{ 50, 1010}, - { 53, 1417},{ 64, 1837},{ 77, 2253},{ 88, 2666}, - { 95, 3079},{ 98, 3487},{ 100, 3882},{ 103, 4264}, - { 106, 4633},{ 108, 4991},{ 109, 5343},{ 109, 5693}, - { 112, 6038},{ 114, 6371},{ 119, 6709},{ 123, 7051}, - { 125, 7385},{ 130, 7716},{ 135, 8050},{ 140, 8374} - } - }, - { - /*Cr qi=15 INTRA*/ - { - { 2, 6},{ 47, 375},{ 87, 763},{ 119, 1225}, - { 143, 1699},{ 162, 2158},{ 185, 2595},{ 213, 2971}, - { 246, 3315},{ 279, 3618},{ 320, 3920},{ 372, 4210}, - { 409, 4480},{ 446, 4756},{ 496, 5017},{ 542, 5263}, - { 590, 5487},{ 639, 5721},{ 687, 5923},{ 724, 6132}, - { 753, 6417},{ 781, 6622},{ 805, 6806},{ 856, 6977} - }, - /*Cr qi=15 INTER*/ - { - { 71, 3},{ 61, 326},{ 52, 651},{ 50, 1017}, - { 58, 1422},{ 69, 1837},{ 82, 2251},{ 90, 2668}, - { 95, 3080},{ 98, 3484},{ 101, 3877},{ 102, 4257}, - { 102, 4632},{ 101, 5005},{ 103, 5370},{ 106, 5733}, - { 110, 6082},{ 116, 6424},{ 120, 6774},{ 124, 7106}, - { 130, 7427},{ 135, 7748},{ 141, 8052},{ 147, 8333} - } - } - }, - { - { - /*Y' qi=16 INTRA*/ - { - { 114, -63},{ 206, 1525},{ 396, 2887},{ 618, 3945}, - { 816, 4832},{ 1002, 5626},{ 1196, 6319},{ 1401, 6923}, - { 1616, 7458},{ 1857, 7928},{ 2121, 8334},{ 2405, 8645}, - { 2685, 8934},{ 2938, 9255},{ 3175, 9638},{ 3433, 9990}, - { 3707,10263},{ 3958,10577},{ 4218,10807},{ 4488,10906}, - { 4760,11028},{ 5037,11148},{ 5306,11286},{ 5625,11463} - }, - /*Y' qi=16 INTER*/ - { - { 69, -153},{ 39, 1348},{ 98, 2894},{ 144, 4448}, - { 181, 5872},{ 209, 7167},{ 228, 8422},{ 254, 9644}, - { 297,10810},{ 359,11908},{ 438,12944},{ 539,13930}, - { 672,14842},{ 850,15650},{ 1085,16318},{ 1391,16793}, - { 1769,17082},{ 2200,17198},{ 2659,17174},{ 3116,17072}, - { 3547,16948},{ 3943,16819},{ 4299,16701},{ 4611,16644} - } - }, - { - /*Cb qi=16 INTRA*/ - { - { 3, 4},{ 54, 367},{ 97, 742},{ 122, 1181}, - { 143, 1651},{ 168, 2123},{ 197, 2575},{ 226, 2985}, - { 263, 3338},{ 314, 3631},{ 367, 3903},{ 409, 4200}, - { 453, 4468},{ 491, 4703},{ 528, 4932},{ 566, 5188}, - { 601, 5459},{ 647, 5672},{ 693, 5844},{ 734, 6058}, - { 784, 6305},{ 836, 6460},{ 882, 6602},{ 905, 6891} - }, - /*Cb qi=16 INTER*/ - { - { 75, -64},{ 67, 292},{ 56, 645},{ 51, 1016}, - { 54, 1421},{ 66, 1842},{ 79, 2257},{ 89, 2670}, - { 95, 3082},{ 98, 3488},{ 101, 3879},{ 104, 4258}, - { 106, 4623},{ 108, 4974},{ 109, 5321},{ 113, 5664}, - { 116, 6001},{ 117, 6341},{ 123, 6677},{ 128, 7004}, - { 130, 7336},{ 136, 7671},{ 143, 7996},{ 148, 8310} - } - }, - { - /*Cr qi=16 INTRA*/ - { - { 4, 7},{ 50, 375},{ 90, 763},{ 124, 1225}, - { 148, 1698},{ 168, 2154},{ 195, 2582},{ 227, 2948}, - { 263, 3279},{ 302, 3575},{ 343, 3865},{ 394, 4137}, - { 439, 4402},{ 482, 4672},{ 533, 4925},{ 579, 5165}, - { 626, 5382},{ 675, 5616},{ 725, 5812},{ 769, 5991}, - { 810, 6242},{ 848, 6430},{ 868, 6615},{ 944, 6732} - }, - /*Cr qi=16 INTER*/ - { - { 78, 11},{ 62, 327},{ 49, 650},{ 50, 1025}, - { 59, 1431},{ 72, 1841},{ 83, 2253},{ 90, 2671}, - { 95, 3084},{ 98, 3487},{ 100, 3879},{ 101, 4254}, - { 102, 4625},{ 103, 4994},{ 106, 5355},{ 108, 5708}, - { 111, 6058},{ 115, 6400},{ 121, 6733},{ 128, 7058}, - { 134, 7374},{ 140, 7691},{ 146, 7993},{ 146, 8317} - } - } - }, - { - { - /*Y' qi=17 INTRA*/ - { - { 112, -59},{ 210, 1515},{ 409, 2850},{ 640, 3882}, - { 844, 4748},{ 1038, 5529},{ 1240, 6206},{ 1452, 6803}, - { 1676, 7330},{ 1925, 7792},{ 2194, 8201},{ 2483, 8512}, - { 2766, 8801},{ 3027, 9121},{ 3279, 9482},{ 3548, 9810}, - { 3825,10069},{ 4088,10345},{ 4362,10544},{ 4638,10644}, - { 4915,10744},{ 5196,10850},{ 5471,10981},{ 5802,11136} - }, - /*Y' qi=17 INTER*/ - { - { 70, -147},{ 45, 1349},{ 106, 2894},{ 155, 4425}, - { 195, 5818},{ 225, 7099},{ 247, 8348},{ 278, 9565}, - { 328,10717},{ 399,11794},{ 491,12807},{ 609,13760}, - { 766,14623},{ 984,15349},{ 1274,15902},{ 1642,16256}, - { 2082,16411},{ 2563,16409},{ 3048,16315},{ 3508,16194}, - { 3924,16064},{ 4306,15938},{ 4656,15828},{ 4966,15733} - } - }, - { - /*Cb qi=17 INTRA*/ - { - { 3, 4},{ 57, 367},{ 101, 742},{ 126, 1182}, - { 148, 1650},{ 175, 2118},{ 207, 2565},{ 241, 2966}, - { 279, 3307},{ 331, 3588},{ 389, 3845},{ 435, 4132}, - { 474, 4408},{ 517, 4641},{ 560, 4869},{ 602, 5122}, - { 638, 5389},{ 672, 5610},{ 716, 5787},{ 758, 6002}, - { 817, 6226},{ 869, 6393},{ 916, 6530},{ 950, 6799} - }, - /*Cb qi=17 INTER*/ - { - { 105, -65},{ 86, 288},{ 66, 638},{ 54, 1014}, - { 59, 1427},{ 71, 1844},{ 86, 2257},{ 95, 2668}, - { 100, 3075},{ 103, 3476},{ 106, 3867},{ 110, 4241}, - { 112, 4598},{ 114, 4948},{ 117, 5294},{ 121, 5633}, - { 123, 5968},{ 126, 6301},{ 131, 6637},{ 136, 6968}, - { 144, 7287},{ 152, 7606},{ 158, 7931},{ 162, 8262} - } - }, - { - /*Cr qi=17 INTRA*/ - { - { 4, 6},{ 55, 376},{ 97, 765},{ 128, 1226}, - { 152, 1696},{ 175, 2144},{ 204, 2568},{ 241, 2928}, - { 282, 3250},{ 323, 3530},{ 368, 3811},{ 420, 4089}, - { 463, 4347},{ 505, 4609},{ 562, 4860},{ 609, 5094}, - { 655, 5303},{ 709, 5535},{ 759, 5740},{ 803, 5913}, - { 844, 6153},{ 879, 6350},{ 905, 6527},{ 972, 6637} - }, - /*Cr qi=17 INTER*/ - { - { 88, 8},{ 68, 330},{ 51, 653},{ 54, 1028}, - { 65, 1433},{ 77, 1845},{ 89, 2257},{ 96, 2669}, - { 100, 3081},{ 102, 3481},{ 105, 3867},{ 106, 4245}, - { 108, 4613},{ 110, 4971},{ 112, 5328},{ 115, 5679}, - { 120, 6019},{ 127, 6355},{ 133, 6686},{ 140, 7007}, - { 149, 7316},{ 158, 7618},{ 166, 7924},{ 170, 8232} - } - } - }, - { - { - /*Y' qi=18 INTRA*/ - { - { 122, -58},{ 216, 1506},{ 425, 2815},{ 665, 3822}, - { 882, 4666},{ 1088, 5425},{ 1301, 6084},{ 1529, 6653}, - { 1766, 7162},{ 2026, 7611},{ 2312, 7987},{ 2612, 8278}, - { 2913, 8551},{ 3196, 8840},{ 3454, 9184},{ 3734, 9490}, - { 4030, 9725},{ 4305, 9973},{ 4585,10162},{ 4864,10251}, - { 5150,10324},{ 5443,10420},{ 5727,10536},{ 6053,10682} - }, - /*Y' qi=18 INTER*/ - { - { 66, -143},{ 47, 1351},{ 108, 2886},{ 158, 4401}, - { 200, 5775},{ 232, 7044},{ 256, 8288},{ 292, 9493}, - { 351,10625},{ 434,11679},{ 541,12665},{ 681,13578}, - { 875,14379},{ 1136,15025},{ 1483,15475},{ 1914,15709}, - { 2399,15767},{ 2907,15699},{ 3400,15579},{ 3852,15453}, - { 4259,15332},{ 4630,15221},{ 4976,15121},{ 5294,15061} - } - }, - { - /*Cb qi=18 INTRA*/ - { - { 2, 3},{ 61, 367},{ 107, 743},{ 131, 1182}, - { 155, 1648},{ 183, 2110},{ 220, 2542},{ 260, 2927}, - { 303, 3265},{ 359, 3540},{ 416, 3785},{ 462, 4063}, - { 506, 4334},{ 553, 4567},{ 595, 4797},{ 636, 5049}, - { 676, 5304},{ 717, 5516},{ 759, 5698},{ 801, 5904}, - { 861, 6133},{ 911, 6311},{ 962, 6443},{ 1021, 6645} - }, - /*Cb qi=18 INTER*/ - { - { 126, 5},{ 95, 326},{ 66, 643},{ 55, 1015}, - { 60, 1427},{ 73, 1843},{ 87, 2256},{ 96, 2667}, - { 101, 3073},{ 104, 3470},{ 108, 3853},{ 111, 4226}, - { 114, 4584},{ 117, 4928},{ 119, 5274},{ 122, 5612}, - { 126, 5942},{ 130, 6271},{ 136, 6606},{ 141, 6931}, - { 148, 7247},{ 156, 7568},{ 164, 7891},{ 173, 8211} - } - }, - { - /*Cr qi=18 INTRA*/ - { - { 4, 6},{ 59, 376},{ 104, 765},{ 133, 1226}, - { 156, 1692},{ 184, 2136},{ 218, 2548},{ 260, 2893}, - { 308, 3204},{ 348, 3481},{ 397, 3751},{ 448, 4024}, - { 490, 4281},{ 541, 4523},{ 593, 4776},{ 634, 5022}, - { 685, 5236},{ 748, 5455},{ 812, 5638},{ 856, 5818}, - { 891, 6048},{ 928, 6230},{ 961, 6405},{ 1055, 6449} - }, - /*Cr qi=18 INTER*/ - { - { 81, 34},{ 68, 342},{ 57, 652},{ 59, 1027}, - { 67, 1439},{ 80, 1848},{ 91, 2257},{ 97, 2670}, - { 100, 3076},{ 103, 3473},{ 106, 3857},{ 108, 4231}, - { 109, 4599},{ 110, 4958},{ 113, 5307},{ 119, 5650}, - { 125, 5991},{ 130, 6325},{ 138, 6651},{ 147, 6971}, - { 153, 7278},{ 162, 7578},{ 172, 7874},{ 177, 8156} - } - } - }, - { - { - /*Y' qi=19 INTRA*/ - { - { 128, -55},{ 228, 1495},{ 448, 2775},{ 699, 3758}, - { 931, 4571},{ 1154, 5296},{ 1386, 5914},{ 1636, 6450}, - { 1894, 6930},{ 2177, 7342},{ 2479, 7698},{ 2792, 7976}, - { 3099, 8235},{ 3392, 8517},{ 3658, 8853},{ 3938, 9155}, - { 4242, 9371},{ 4527, 9605},{ 4810, 9781},{ 5089, 9853}, - { 5378, 9920},{ 5674,10009},{ 5972,10110},{ 6336,10196} - }, - /*Y' qi=19 INTER*/ - { - { 69, -147},{ 49, 1353},{ 111, 2883},{ 162, 4381}, - { 205, 5737},{ 237, 6996},{ 264, 8232},{ 307, 9421}, - { 376,10534},{ 472,11567},{ 596,12525},{ 761,13395}, - { 990,14130},{ 1298,14694},{ 1695,15053},{ 2172,15195}, - { 2696,15173},{ 3213,15075},{ 3696,14948},{ 4141,14829}, - { 4541,14721},{ 4910,14609},{ 5245,14506},{ 5536,14399} - } - }, - { - /*Cb qi=19 INTRA*/ - { - { 3, 3},{ 61, 367},{ 109, 743},{ 135, 1182}, - { 161, 1646},{ 191, 2101},{ 229, 2524},{ 273, 2898}, - { 318, 3221},{ 376, 3490},{ 436, 3731},{ 487, 3994}, - { 539, 4251},{ 584, 4485},{ 621, 4721},{ 664, 4967}, - { 709, 5225},{ 752, 5431},{ 801, 5595},{ 846, 5796}, - { 912, 6011},{ 959, 6193},{ 1015, 6321},{ 1121, 6504} - }, - /*Cb qi=19 INTER*/ - { - { 126, 4},{ 97, 329},{ 69, 649},{ 56, 1017}, - { 61, 1432},{ 74, 1846},{ 88, 2255},{ 98, 2663}, - { 103, 3065},{ 106, 3460},{ 110, 3844},{ 114, 4211}, - { 117, 4564},{ 120, 4911},{ 122, 5253},{ 125, 5588}, - { 129, 5916},{ 135, 6241},{ 142, 6567},{ 149, 6885}, - { 155, 7206},{ 163, 7527},{ 174, 7843},{ 188, 8145} - } - }, - { - /*Cr qi=19 INTRA*/ - { - { 5, 6},{ 61, 376},{ 106, 765},{ 135, 1225}, - { 160, 1689},{ 192, 2126},{ 229, 2531},{ 271, 2869}, - { 321, 3168},{ 370, 3433},{ 421, 3704},{ 476, 3965}, - { 520, 4212},{ 572, 4452},{ 629, 4691},{ 671, 4939}, - { 724, 5152},{ 792, 5347},{ 858, 5510},{ 895, 5696}, - { 939, 5905},{ 991, 6056},{ 1027, 6244},{ 1127, 6333} - }, - /*Cr qi=19 INTER*/ - { - { 80, 45},{ 66, 344},{ 55, 654},{ 56, 1030}, - { 66, 1440},{ 80, 1850},{ 91, 2259},{ 98, 2668}, - { 102, 3072},{ 104, 3466},{ 107, 3845},{ 109, 4215}, - { 110, 4578},{ 112, 4933},{ 116, 5283},{ 122, 5625}, - { 129, 5963},{ 136, 6287},{ 143, 6611},{ 151, 6927}, - { 160, 7229},{ 170, 7528},{ 181, 7818},{ 191, 8092} - } - } - }, - { - { - /*Y' qi=20 INTRA*/ - { - { 129, -50},{ 238, 1481},{ 469, 2728},{ 730, 3684}, - { 974, 4473},{ 1213, 5171},{ 1463, 5763},{ 1729, 6281}, - { 2002, 6744},{ 2299, 7146},{ 2613, 7492},{ 2940, 7746}, - { 3265, 7978},{ 3571, 8228},{ 3853, 8543},{ 4156, 8815}, - { 4476, 9001},{ 4775, 9218},{ 5070, 9373},{ 5352, 9446}, - { 5649, 9510},{ 5956, 9580},{ 6268, 9660},{ 6647, 9705} - }, - /*Y' qi=20 INTER*/ - { - { 64, -93},{ 52, 1340},{ 116, 2862},{ 170, 4344}, - { 216, 5678},{ 249, 6928},{ 281, 8155},{ 333, 9326}, - { 418,10410},{ 533,11411},{ 683,12329},{ 890,13127}, - { 1183,13750},{ 1579,14162},{ 2066,14357},{ 2611,14370}, - { 3159,14284},{ 3675,14167},{ 4142,14053},{ 4568,13953}, - { 4961,13852},{ 5320,13755},{ 5649,13675},{ 5933,13610} - } - }, - { - /*Cb qi=20 INTRA*/ - { - { 3, 3},{ 62, 367},{ 112, 743},{ 140, 1183}, - { 165, 1646},{ 196, 2099},{ 235, 2517},{ 284, 2883}, - { 334, 3198},{ 393, 3460},{ 457, 3690},{ 509, 3945}, - { 560, 4198},{ 605, 4435},{ 647, 4658},{ 699, 4888}, - { 742, 5155},{ 788, 5350},{ 835, 5517},{ 880, 5730}, - { 956, 5914},{ 1007, 6060},{ 1053, 6199},{ 1158, 6358} - }, - /*Cb qi=20 INTER*/ - { - { 128, -6},{ 96, 322},{ 66, 653},{ 54, 1025}, - { 63, 1431},{ 79, 1844},{ 91, 2256},{ 99, 2665}, - { 104, 3065},{ 107, 3455},{ 111, 3831},{ 115, 4189}, - { 120, 4539},{ 123, 4885},{ 126, 5219},{ 130, 5548}, - { 135, 5876},{ 141, 6199},{ 149, 6519},{ 156, 6837}, - { 166, 7153},{ 179, 7468},{ 189, 7784},{ 194, 8102} - } - }, - { - /*Cr qi=20 INTRA*/ - { - { 4, 6},{ 63, 376},{ 109, 765},{ 139, 1225}, - { 165, 1689},{ 199, 2124},{ 239, 2523},{ 285, 2852}, - { 340, 3140},{ 388, 3398},{ 438, 3662},{ 499, 3914}, - { 547, 4155},{ 596, 4392},{ 652, 4634},{ 699, 4877}, - { 759, 5074},{ 824, 5257},{ 883, 5428},{ 936, 5589}, - { 986, 5790},{ 1030, 5960},{ 1074, 6119},{ 1172, 6191} - }, - /*Cr qi=20 INTER*/ - { - { 92, 40},{ 70, 345},{ 55, 658},{ 57, 1034}, - { 69, 1441},{ 84, 1852},{ 94, 2261},{ 98, 2669}, - { 102, 3074},{ 105, 3465},{ 107, 3841},{ 110, 4206}, - { 112, 4562},{ 116, 4915},{ 121, 5260},{ 127, 5591}, - { 134, 5920},{ 142, 6246},{ 153, 6562},{ 163, 6870}, - { 173, 7170},{ 186, 7463},{ 198, 7746},{ 199, 8030} - } - } - }, - { - { - /*Y' qi=21 INTRA*/ - { - { 130, -51},{ 244, 1476},{ 483, 2705},{ 756, 3635}, - { 1013, 4396},{ 1266, 5070},{ 1530, 5647},{ 1806, 6153}, - { 2093, 6600},{ 2411, 6976},{ 2739, 7299},{ 3079, 7534}, - { 3422, 7744},{ 3738, 7987},{ 4032, 8274},{ 4348, 8533}, - { 4675, 8721},{ 4989, 8909},{ 5291, 9051},{ 5577, 9111}, - { 5879, 9163},{ 6190, 9228},{ 6506, 9286},{ 6899, 9295} - }, - /*Y' qi=21 INTER*/ - { - { 64, -56},{ 55, 1341},{ 119, 2859},{ 174, 4324}, - { 223, 5640},{ 258, 6880},{ 295, 8096},{ 359, 9246}, - { 460,10302},{ 595,11268},{ 778,12131},{ 1032,12857}, - { 1387,13385},{ 1850,13683},{ 2399,13774},{ 2976,13729}, - { 3527,13619},{ 4034,13504},{ 4492,13401},{ 4912,13291}, - { 5298,13209},{ 5648,13137},{ 5974,13046},{ 6308,12977} - } - }, - { - /*Cb qi=21 INTRA*/ - { - { 4, 3},{ 64, 367},{ 114, 743},{ 141, 1183}, - { 166, 1645},{ 201, 2092},{ 247, 2502},{ 299, 2856}, - { 352, 3158},{ 413, 3412},{ 480, 3642},{ 536, 3893}, - { 588, 4137},{ 637, 4367},{ 678, 4598},{ 725, 4834}, - { 774, 5083},{ 827, 5269},{ 883, 5420},{ 930, 5633}, - { 999, 5829},{ 1057, 5959},{ 1113, 6082},{ 1200, 6265} - }, - /*Cb qi=21 INTER*/ - { - { 109, -8},{ 84, 321},{ 62, 654},{ 54, 1028}, - { 64, 1434},{ 80, 1847},{ 92, 2259},{ 100, 2664}, - { 105, 3060},{ 109, 3445},{ 114, 3815},{ 118, 4172}, - { 122, 4519},{ 126, 4861},{ 128, 5194},{ 133, 5520}, - { 139, 5847},{ 146, 6169},{ 155, 6487},{ 166, 6801}, - { 177, 7114},{ 189, 7423},{ 201, 7729},{ 208, 8035} - } - }, - { - /*Cr qi=21 INTRA*/ - { - { 4, 6},{ 64, 377},{ 111, 766},{ 144, 1225}, - { 174, 1683},{ 206, 2114},{ 248, 2506},{ 302, 2824}, - { 357, 3099},{ 404, 3357},{ 455, 3622},{ 519, 3867}, - { 573, 4098},{ 625, 4331},{ 683, 4571},{ 733, 4802}, - { 793, 4994},{ 863, 5173},{ 926, 5337},{ 978, 5492}, - { 1030, 5685},{ 1079, 5856},{ 1126, 6027},{ 1217, 6159} - }, - /*Cr qi=21 INTER*/ - { - { 82, 29},{ 67, 341},{ 55, 660},{ 58, 1038}, - { 71, 1443},{ 85, 1851},{ 95, 2258},{ 99, 2666}, - { 103, 3069},{ 107, 3456},{ 110, 3826},{ 112, 4188}, - { 114, 4544},{ 118, 4891},{ 124, 5231},{ 132, 5567}, - { 139, 5894},{ 148, 6210},{ 159, 6520},{ 171, 6822}, - { 185, 7111},{ 196, 7403},{ 209, 7691},{ 225, 7945} - } - } - }, - { - { - /*Y' qi=22 INTRA*/ - { - { 128, -45},{ 254, 1463},{ 507, 2662},{ 794, 3562}, - { 1070, 4292},{ 1340, 4941},{ 1622, 5492},{ 1920, 5968}, - { 2229, 6387},{ 2565, 6742},{ 2911, 7047},{ 3263, 7264}, - { 3615, 7464},{ 3944, 7689},{ 4258, 7950},{ 4591, 8183}, - { 4934, 8347},{ 5259, 8517},{ 5573, 8634},{ 5870, 8683}, - { 6186, 8723},{ 6508, 8762},{ 6831, 8801},{ 7232, 8830} - }, - /*Y' qi=22 INTER*/ - { - { 77, -48},{ 57, 1343},{ 122, 2853},{ 180, 4299}, - { 231, 5597},{ 269, 6826},{ 314, 8025},{ 393, 9150}, - { 512,10179},{ 673,11103},{ 894,11908},{ 1207,12542}, - { 1635,12956},{ 2166,13148},{ 2755,13167},{ 3345,13088}, - { 3895,12966},{ 4386,12848},{ 4832,12746},{ 5252,12647}, - { 5634,12563},{ 5978,12497},{ 6299,12412},{ 6633,12338} - } - }, - { - /*Cb qi=22 INTRA*/ - { - { 4, 3},{ 66, 367},{ 122, 744},{ 153, 1182}, - { 177, 1640},{ 213, 2080},{ 263, 2475},{ 323, 2811}, - { 382, 3103},{ 451, 3346},{ 522, 3568},{ 581, 3814}, - { 633, 4054},{ 674, 4288},{ 719, 4523},{ 768, 4756}, - { 823, 4979},{ 883, 5162},{ 937, 5325},{ 996, 5510}, - { 1070, 5687},{ 1129, 5807},{ 1193, 5929},{ 1311, 6099} - }, - /*Cb qi=22 INTER*/ - { - { 107, -5},{ 83, 322},{ 61, 653},{ 55, 1030}, - { 66, 1436},{ 81, 1845},{ 94, 2253},{ 102, 2656}, - { 107, 3050},{ 111, 3435},{ 115, 3804},{ 119, 4158}, - { 124, 4501},{ 128, 4835},{ 132, 5164},{ 138, 5490}, - { 146, 5812},{ 154, 6128},{ 163, 6442},{ 174, 6754}, - { 188, 7060},{ 205, 7361},{ 219, 7662},{ 233, 7953} - } - }, - { - /*Cr qi=22 INTRA*/ - { - { 4, 6},{ 67, 378},{ 118, 767},{ 151, 1222}, - { 182, 1675},{ 221, 2097},{ 269, 2476},{ 329, 2774}, - { 389, 3039},{ 444, 3292},{ 500, 3545},{ 560, 3788}, - { 615, 4020},{ 671, 4251},{ 734, 4484},{ 781, 4712}, - { 850, 4887},{ 925, 5060},{ 981, 5229},{ 1031, 5369}, - { 1092, 5549},{ 1148, 5715},{ 1200, 5861},{ 1291, 5943} - }, - /*Cr qi=22 INTER*/ - { - { 88, 34},{ 69, 340},{ 57, 657},{ 60, 1039}, - { 73, 1445},{ 87, 1851},{ 96, 2257},{ 100, 2662}, - { 103, 3058},{ 107, 3442},{ 111, 3812},{ 115, 4172}, - { 118, 4524},{ 123, 4864},{ 129, 5199},{ 136, 5531}, - { 145, 5855},{ 156, 6168},{ 170, 6468},{ 184, 6765}, - { 193, 7066},{ 207, 7353},{ 222, 7628},{ 230, 7900} - } - } - }, - { - { - /*Y' qi=23 INTRA*/ - { - { 126, -40},{ 257, 1458},{ 521, 2636},{ 825, 3501}, - { 1111, 4207},{ 1391, 4842},{ 1684, 5385},{ 1992, 5858}, - { 2311, 6277},{ 2653, 6626},{ 3005, 6929},{ 3366, 7134}, - { 3729, 7311},{ 4071, 7526},{ 4396, 7770},{ 4734, 7986}, - { 5086, 8131},{ 5421, 8286},{ 5735, 8404},{ 6033, 8456}, - { 6357, 8486},{ 6682, 8525},{ 7003, 8573},{ 7387, 8604} - }, - /*Y' qi=23 INTER*/ - { - { 64, -57},{ 60, 1345},{ 124, 2853},{ 185, 4284}, - { 239, 5565},{ 282, 6783},{ 336, 7967},{ 429, 9069}, - { 568,10063},{ 758,10943},{ 1028,11679},{ 1407,12216}, - { 1909,12520},{ 2502,12616},{ 3126,12573},{ 3722,12461}, - { 4258,12344},{ 4742,12236},{ 5185,12136},{ 5590,12052}, - { 5970,11980},{ 6315,11901},{ 6631,11826},{ 6954,11769} - } - }, - { - /*Cb qi=23 INTRA*/ - { - { 3, 3},{ 70, 367},{ 124, 744},{ 151, 1182}, - { 181, 1637},{ 222, 2071},{ 276, 2460},{ 343, 2785}, - { 403, 3072},{ 468, 3317},{ 542, 3534},{ 605, 3773}, - { 659, 4009},{ 703, 4243},{ 747, 4479},{ 795, 4707}, - { 852, 4923},{ 908, 5105},{ 972, 5254},{ 1043, 5423}, - { 1118, 5594},{ 1172, 5731},{ 1240, 5853},{ 1365, 6005} - }, - /*Cb qi=23 INTER*/ - { - { 109, -10},{ 87, 325},{ 63, 650},{ 57, 1031}, - { 67, 1439},{ 83, 1847},{ 96, 2253},{ 103, 2652}, - { 109, 3041},{ 114, 3421},{ 117, 3789},{ 122, 4141}, - { 128, 4480},{ 134, 4811},{ 139, 5138},{ 144, 5463}, - { 152, 5781},{ 161, 6096},{ 174, 6404},{ 185, 6714}, - { 198, 7023},{ 216, 7320},{ 233, 7621},{ 245, 7935} - } - }, - { - /*Cr qi=23 INTRA*/ - { - { 5, 6},{ 70, 379},{ 122, 768},{ 155, 1222}, - { 187, 1671},{ 231, 2088},{ 283, 2459},{ 346, 2750}, - { 411, 3009},{ 465, 3261},{ 523, 3509},{ 585, 3746}, - { 639, 3980},{ 695, 4219},{ 754, 4449},{ 803, 4671}, - { 873, 4840},{ 953, 5001},{ 1015, 5156},{ 1071, 5286}, - { 1137, 5464},{ 1191, 5629},{ 1249, 5782},{ 1359, 5885} - }, - /*Cr qi=23 INTER*/ - { - { 84, 29},{ 69, 343},{ 58, 660},{ 62, 1041}, - { 75, 1448},{ 88, 1853},{ 97, 2258},{ 102, 2659}, - { 105, 3050},{ 108, 3430},{ 113, 3799},{ 116, 4155}, - { 121, 4505},{ 126, 4845},{ 132, 5176},{ 142, 5504}, - { 153, 5826},{ 165, 6133},{ 180, 6432},{ 197, 6722}, - { 212, 7005},{ 226, 7287},{ 244, 7555},{ 258, 7828} - } - } - }, - { - { - /*Y' qi=24 INTRA*/ - { - { 125, -34},{ 268, 1444},{ 547, 2590},{ 866, 3422}, - { 1172, 4098},{ 1476, 4702},{ 1790, 5222},{ 2117, 5678}, - { 2453, 6080},{ 2811, 6418},{ 3178, 6700},{ 3552, 6895}, - { 3928, 7055},{ 4286, 7243},{ 4627, 7477},{ 4981, 7674}, - { 5344, 7802},{ 5683, 7944},{ 6009, 8043},{ 6313, 8082}, - { 6633, 8111},{ 6959, 8151},{ 7280, 8197},{ 7660, 8221} - }, - /*Y' qi=24 INTER*/ - { - { 62, -63},{ 68, 1345},{ 134, 2840},{ 199, 4245}, - { 256, 5508},{ 304, 6715},{ 371, 7880},{ 484, 8950}, - { 652, 9899},{ 892,10709},{ 1238,11334},{ 1722,11722}, - { 2326,11875},{ 2983,11864},{ 3616,11783},{ 4189,11678}, - { 4707,11570},{ 5178,11476},{ 5617,11395},{ 6017,11319}, - { 6380,11252},{ 6720,11185},{ 7044,11126},{ 7377,11118} - } - }, - { - /*Cb qi=24 INTRA*/ - { - { 4, 3},{ 75, 367},{ 132, 745},{ 159, 1182}, - { 187, 1634},{ 230, 2061},{ 289, 2439},{ 361, 2753}, - { 425, 3034},{ 492, 3278},{ 566, 3490},{ 630, 3720}, - { 686, 3956},{ 732, 4190},{ 777, 4420},{ 829, 4637}, - { 894, 4840},{ 958, 5012},{ 1023, 5155},{ 1090, 5326}, - { 1165, 5502},{ 1226, 5622},{ 1299, 5717},{ 1408, 5887} - }, - /*Cb qi=24 INTER*/ - { - { 110, 35},{ 92, 337},{ 70, 651},{ 63, 1033}, - { 74, 1440},{ 91, 1846},{ 102, 2248},{ 109, 2644}, - { 114, 3031},{ 120, 3404},{ 127, 3762},{ 133, 4109}, - { 138, 4445},{ 144, 4772},{ 151, 5094},{ 159, 5411}, - { 168, 5728},{ 180, 6037},{ 195, 6338},{ 210, 6640}, - { 227, 6944},{ 249, 7236},{ 272, 7528},{ 299, 7809} - } - }, - { - /*Cr qi=24 INTRA*/ - { - { 5, 6},{ 72, 380},{ 124, 770},{ 158, 1222}, - { 195, 1668},{ 240, 2079},{ 297, 2438},{ 367, 2715}, - { 433, 2966},{ 488, 3218},{ 549, 3467},{ 609, 3701}, - { 664, 3935},{ 728, 4165},{ 792, 4379},{ 845, 4586}, - { 917, 4744},{ 995, 4898},{ 1063, 5049},{ 1120, 5187}, - { 1190, 5359},{ 1249, 5522},{ 1304, 5672},{ 1397, 5806} - }, - /*Cr qi=24 INTER*/ - { - { 91, 56},{ 73, 353},{ 61, 664},{ 66, 1045}, - { 80, 1449},{ 95, 1851},{ 103, 2250},{ 107, 2648}, - { 111, 3038},{ 116, 3413},{ 120, 3774},{ 124, 4128}, - { 130, 4471},{ 138, 4802},{ 145, 5130},{ 156, 5453}, - { 171, 5764},{ 187, 6061},{ 204, 6355},{ 220, 6643}, - { 238, 6923},{ 254, 7204},{ 275, 7475},{ 289, 7752} - } - } - }, - { - { - /*Y' qi=25 INTRA*/ - { - { 125, -28},{ 285, 1426},{ 582, 2540},{ 917, 3351}, - { 1244, 3997},{ 1569, 4570},{ 1903, 5071},{ 2258, 5498}, - { 2626, 5866},{ 3002, 6182},{ 3382, 6448},{ 3770, 6623}, - { 4162, 6760},{ 4528, 6934},{ 4882, 7144},{ 5249, 7328}, - { 5610, 7453},{ 5958, 7578},{ 6291, 7672},{ 6597, 7708}, - { 6928, 7715},{ 7258, 7737},{ 7575, 7781},{ 7950, 7829} - }, - /*Y' qi=25 INTER*/ - { - { 64, -16},{ 72, 1348},{ 139, 2832},{ 206, 4218}, - { 268, 5465},{ 322, 6659},{ 403, 7803},{ 540, 8838}, - { 747, 9734},{ 1044,10465},{ 1473,10981},{ 2048,11249}, - { 2717,11311},{ 3397,11257},{ 4025,11161},{ 4589,11052}, - { 5099,10947},{ 5560,10859},{ 5989,10786},{ 6389,10717}, - { 6753,10652},{ 7078,10592},{ 7389,10535},{ 7697,10460} - } - }, - { - /*Cb qi=25 INTRA*/ - { - { 3, 3},{ 78, 368},{ 133, 745},{ 159, 1180}, - { 193, 1627},{ 242, 2046},{ 304, 2411},{ 381, 2714}, - { 456, 2983},{ 527, 3224},{ 598, 3437},{ 667, 3655}, - { 726, 3888},{ 776, 4117},{ 826, 4333},{ 883, 4543}, - { 954, 4727},{ 1019, 4878},{ 1095, 5014},{ 1171, 5187}, - { 1255, 5342},{ 1319, 5458},{ 1396, 5546},{ 1536, 5678} - }, - /*Cb qi=25 INTER*/ - { - { 117, 32},{ 89, 342},{ 67, 660},{ 64, 1037}, - { 77, 1441},{ 93, 1845},{ 105, 2243},{ 113, 2633}, - { 120, 3016},{ 125, 3387},{ 131, 3739},{ 137, 4080}, - { 144, 4416},{ 152, 4741},{ 160, 5057},{ 169, 5369}, - { 180, 5680},{ 193, 5990},{ 209, 6294},{ 227, 6594}, - { 249, 6888},{ 269, 7180},{ 294, 7467},{ 317, 7768} - } - }, - { - /*Cr qi=25 INTRA*/ - { - { 6, 6},{ 74, 380},{ 129, 770},{ 165, 1220}, - { 201, 1658},{ 253, 2061},{ 315, 2410},{ 388, 2676}, - { 462, 2920},{ 523, 3166},{ 584, 3404},{ 647, 3637}, - { 701, 3870},{ 769, 4086},{ 838, 4296},{ 898, 4491}, - { 980, 4627},{ 1065, 4759},{ 1126, 4920},{ 1187, 5058}, - { 1283, 5180},{ 1347, 5332},{ 1404, 5475},{ 1527, 5534} - }, - /*Cr qi=25 INTER*/ - { - { 92, 41},{ 75, 347},{ 64, 664},{ 70, 1045}, - { 85, 1448},{ 98, 1849},{ 105, 2245},{ 110, 2637}, - { 115, 3023},{ 120, 3395},{ 126, 3753},{ 131, 4102}, - { 136, 4439},{ 145, 4768},{ 156, 5094},{ 168, 5410}, - { 184, 5717},{ 203, 6010},{ 221, 6300},{ 239, 6577}, - { 262, 6847},{ 282, 7123},{ 303, 7390},{ 322, 7665} - } - } - }, - { - { - /*Y' qi=26 INTRA*/ - { - { 130, -24},{ 292, 1423},{ 594, 2525},{ 943, 3307}, - { 1289, 3921},{ 1633, 4467},{ 1991, 4943},{ 2368, 5348}, - { 2753, 5696},{ 3148, 5991},{ 3545, 6247},{ 3942, 6415}, - { 4342, 6535},{ 4726, 6690},{ 5093, 6883},{ 5466, 7047}, - { 5840, 7159},{ 6202, 7274},{ 6545, 7351},{ 6855, 7375}, - { 7186, 7384},{ 7517, 7416},{ 7840, 7447},{ 8238, 7450} - }, - /*Y' qi=26 INTER*/ - { - { 52, 16},{ 75, 1336},{ 143, 2815},{ 213, 4191}, - { 278, 5427},{ 339, 6611},{ 436, 7734},{ 600, 8732}, - { 843, 9579},{ 1195,10243},{ 1702,10660},{ 2355,10825}, - { 3070,10820},{ 3755,10743},{ 4372,10643},{ 4925,10538}, - { 5426,10440},{ 5882,10354},{ 6296,10290},{ 6686,10224}, - { 7049,10163},{ 7380,10113},{ 7672,10062},{ 7937,10021} - } - }, - { - /*Cb qi=26 INTRA*/ - { - { 4, 3},{ 79, 368},{ 138, 745},{ 167, 1180}, - { 200, 1623},{ 252, 2034},{ 322, 2389},{ 403, 2682}, - { 480, 2941},{ 558, 3176},{ 631, 3393},{ 700, 3608}, - { 766, 3825},{ 819, 4046},{ 868, 4265},{ 926, 4472}, - { 1002, 4645},{ 1070, 4800},{ 1151, 4924},{ 1242, 5063}, - { 1325, 5221},{ 1393, 5338},{ 1464, 5431},{ 1595, 5559} - }, - /*Cb qi=26 INTER*/ - { - { 98, 33},{ 83, 343},{ 65, 662},{ 65, 1037}, - { 80, 1437},{ 96, 1839},{ 107, 2238},{ 115, 2628}, - { 122, 3007},{ 128, 3373},{ 134, 3722},{ 142, 4060}, - { 149, 4390},{ 158, 4713},{ 167, 5029},{ 178, 5341}, - { 191, 5647},{ 208, 5948},{ 227, 6244},{ 247, 6539}, - { 269, 6833},{ 295, 7114},{ 328, 7388},{ 369, 7658} - } - }, - { - /*Cr qi=26 INTRA*/ - { - { 5, 6},{ 75, 380},{ 133, 769},{ 172, 1217}, - { 212, 1652},{ 266, 2048},{ 333, 2384},{ 412, 2643}, - { 490, 2880},{ 552, 3124},{ 616, 3365},{ 681, 3594}, - { 739, 3816},{ 810, 4024},{ 880, 4224},{ 945, 4405}, - { 1029, 4538},{ 1114, 4674},{ 1183, 4822},{ 1254, 4946}, - { 1346, 5063},{ 1417, 5201},{ 1478, 5345},{ 1597, 5411} - }, - /*Cr qi=26 INTER*/ - { - { 97, 29},{ 75, 342},{ 62, 667},{ 70, 1047}, - { 87, 1447},{ 100, 1846},{ 107, 2242},{ 113, 2633}, - { 118, 3016},{ 123, 3382},{ 128, 3737},{ 135, 4082}, - { 142, 4417},{ 151, 4746},{ 162, 5066},{ 176, 5377}, - { 194, 5679},{ 217, 5963},{ 239, 6244},{ 260, 6522}, - { 284, 6789},{ 309, 7052},{ 335, 7313},{ 355, 7582} - } - } - }, - { - { - /*Y' qi=27 INTRA*/ - { - { 118, -10},{ 308, 1404},{ 630, 2473},{ 997, 3227}, - { 1360, 3819},{ 1719, 4354},{ 2086, 4829},{ 2470, 5233}, - { 2863, 5576},{ 3267, 5870},{ 3677, 6117},{ 4085, 6268}, - { 4499, 6376},{ 4888, 6521},{ 5257, 6705},{ 5638, 6865}, - { 6020, 6962},{ 6394, 7056},{ 6744, 7130},{ 7051, 7158}, - { 7386, 7164},{ 7717, 7185},{ 8042, 7209},{ 8444, 7206} - }, - /*Y' qi=27 INTER*/ - { - { 54, 19},{ 77, 1333},{ 147, 2806},{ 221, 4166}, - { 290, 5390},{ 360, 6564},{ 474, 7665},{ 664, 8630}, - { 949, 9423},{ 1370,10002},{ 1958,10323},{ 2670,10414}, - { 3406,10375},{ 4086,10285},{ 4691,10182},{ 5233,10085}, - { 5724, 9994},{ 6169, 9918},{ 6582, 9863},{ 6962, 9813}, - { 7316, 9759},{ 7645, 9707},{ 7948, 9660},{ 8262, 9623} - } - }, - { - /*Cb qi=27 INTRA*/ - { - { 4, 3},{ 79, 368},{ 137, 745},{ 166, 1180}, - { 200, 1622},{ 253, 2030},{ 324, 2381},{ 407, 2671}, - { 487, 2925},{ 567, 3156},{ 640, 3372},{ 712, 3580}, - { 782, 3792},{ 833, 4015},{ 887, 4227},{ 954, 4422}, - { 1031, 4592},{ 1103, 4738},{ 1187, 4856},{ 1280, 4990}, - { 1371, 5135},{ 1442, 5244},{ 1520, 5321},{ 1684, 5398} - }, - /*Cb qi=27 INTER*/ - { - { 113, 20},{ 90, 338},{ 66, 661},{ 67, 1034}, - { 82, 1438},{ 97, 1842},{ 108, 2238},{ 115, 2624}, - { 123, 3000},{ 130, 3361},{ 138, 3708},{ 146, 4040}, - { 155, 4367},{ 164, 4688},{ 174, 4999},{ 186, 5306}, - { 203, 5609},{ 222, 5908},{ 243, 6202},{ 268, 6494}, - { 295, 6781},{ 326, 7058},{ 367, 7319},{ 420, 7551} - } - }, - { - /*Cr qi=27 INTRA*/ - { - { 5, 6},{ 75, 380},{ 133, 770},{ 173, 1217}, - { 214, 1650},{ 268, 2040},{ 337, 2375},{ 418, 2631}, - { 496, 2862},{ 558, 3104},{ 625, 3346},{ 692, 3571}, - { 753, 3786},{ 825, 3989},{ 896, 4182},{ 969, 4352}, - { 1059, 4479},{ 1144, 4614},{ 1212, 4757},{ 1284, 4871}, - { 1380, 4982},{ 1457, 5125},{ 1528, 5267},{ 1651, 5346} - }, - /*Cr qi=27 INTER*/ - { - { 92, 24},{ 74, 341},{ 61, 669},{ 71, 1049}, - { 88, 1448},{ 100, 1849},{ 107, 2243},{ 113, 2631}, - { 119, 3010},{ 125, 3373},{ 131, 3723},{ 137, 4064}, - { 146, 4396},{ 159, 4720},{ 172, 5033},{ 189, 5340}, - { 210, 5636},{ 233, 5920},{ 256, 6197},{ 282, 6465}, - { 310, 6730},{ 332, 7000},{ 359, 7259},{ 385, 7515} - } - } - }, - { - { - /*Y' qi=28 INTRA*/ - { - { 116, -8},{ 314, 1400},{ 640, 2458},{ 1013, 3197}, - { 1386, 3768},{ 1762, 4279},{ 2151, 4733},{ 2558, 5117}, - { 2970, 5442},{ 3393, 5714},{ 3820, 5935},{ 4243, 6069}, - { 4671, 6161},{ 5074, 6289},{ 5456, 6457},{ 5849, 6598}, - { 6244, 6689},{ 6632, 6777},{ 6984, 6833},{ 7294, 6855}, - { 7625, 6862},{ 7961, 6875},{ 8302, 6890},{ 8720, 6883} - }, - /*Y' qi=28 INTER*/ - { - { 54, 8},{ 81, 1333},{ 154, 2793},{ 231, 4138}, - { 304, 5352},{ 384, 6512},{ 519, 7585},{ 743, 8508}, - { 1082, 9236},{ 1587, 9717},{ 2267, 9928},{ 3034, 9944}, - { 3775, 9878},{ 4438, 9786},{ 5031, 9686},{ 5563, 9601}, - { 6042, 9523},{ 6481, 9456},{ 6890, 9405},{ 7266, 9356}, - { 7614, 9313},{ 7933, 9265},{ 8238, 9220},{ 8545, 9193} - } - }, - { - /*Cb qi=28 INTRA*/ - { - { 3, 3},{ 80, 368},{ 138, 746},{ 168, 1179}, - { 208, 1615},{ 268, 2014},{ 345, 2354},{ 432, 2637}, - { 515, 2884},{ 595, 3108},{ 669, 3323},{ 745, 3533}, - { 818, 3740},{ 876, 3953},{ 932, 4160},{ 1003, 4349}, - { 1088, 4501},{ 1154, 4648},{ 1241, 4768},{ 1349, 4889}, - { 1441, 5023},{ 1524, 5113},{ 1611, 5187},{ 1783, 5283} - }, - /*Cb qi=28 INTER*/ - { - { 117, 29},{ 91, 341},{ 65, 663},{ 68, 1038}, - { 85, 1440},{ 100, 1841},{ 110, 2234},{ 119, 2616}, - { 127, 2985},{ 135, 3342},{ 142, 3685},{ 151, 4015}, - { 162, 4337},{ 174, 4652},{ 186, 4960},{ 201, 5264}, - { 218, 5567},{ 239, 5863},{ 266, 6149},{ 295, 6434}, - { 328, 6715},{ 371, 6976},{ 409, 7239},{ 460, 7477} - } - }, - { - /*Cr qi=28 INTRA*/ - { - { 6, 7},{ 79, 381},{ 138, 771},{ 178, 1215}, - { 222, 1644},{ 285, 2026},{ 359, 2347},{ 441, 2597}, - { 521, 2827},{ 588, 3066},{ 655, 3303},{ 725, 3523}, - { 791, 3728},{ 870, 3920},{ 950, 4103},{ 1030, 4265}, - { 1121, 4388},{ 1198, 4520},{ 1266, 4659},{ 1356, 4759}, - { 1461, 4865},{ 1540, 4993},{ 1619, 5115},{ 1786, 5160} - }, - /*Cr qi=28 INTER*/ - { - { 96, 18},{ 78, 340},{ 66, 672},{ 74, 1051}, - { 90, 1450},{ 103, 1845},{ 110, 2235},{ 116, 2619}, - { 122, 2995},{ 129, 3356},{ 137, 3702},{ 146, 4038}, - { 156, 4365},{ 168, 4684},{ 182, 4995},{ 203, 5297}, - { 227, 5588},{ 253, 5866},{ 282, 6131},{ 311, 6394}, - { 339, 6664},{ 366, 6918},{ 400, 7171},{ 424, 7450} - } - } - }, - { - { - /*Y' qi=29 INTRA*/ - { - { 112, 7},{ 334, 1382},{ 681, 2410},{ 1081, 3112}, - { 1484, 3650},{ 1894, 4128},{ 2316, 4547},{ 2749, 4905}, - { 3188, 5208},{ 3634, 5458},{ 4079, 5666},{ 4517, 5791}, - { 4952, 5870},{ 5359, 5983},{ 5754, 6137},{ 6165, 6268}, - { 6568, 6351},{ 6958, 6423},{ 7320, 6471},{ 7638, 6490}, - { 7979, 6490},{ 8313, 6499},{ 8651, 6517},{ 9085, 6499} - }, - /*Y' qi=29 INTER*/ - { - { 55, 15},{ 85, 1336},{ 160, 2780},{ 242, 4104}, - { 323, 5302},{ 418, 6443},{ 586, 7480},{ 859, 8342}, - { 1278, 8982},{ 1888, 9347},{ 2658, 9457},{ 3457, 9425}, - { 4192, 9343},{ 4842, 9247},{ 5417, 9162},{ 5935, 9086}, - { 6404, 9011},{ 6841, 8952},{ 7241, 8907},{ 7609, 8867}, - { 7953, 8832},{ 8267, 8792},{ 8562, 8740},{ 8836, 8701} - } - }, - { - /*Cb qi=29 INTRA*/ - { - { 5, 3},{ 84, 368},{ 144, 746},{ 176, 1175}, - { 219, 1604},{ 285, 1991},{ 372, 2318},{ 462, 2591}, - { 546, 2833},{ 628, 3058},{ 704, 3274},{ 788, 3473}, - { 870, 3664},{ 935, 3865},{ 995, 4059},{ 1072, 4239}, - { 1167, 4388},{ 1248, 4518},{ 1334, 4634},{ 1429, 4765}, - { 1536, 4884},{ 1628, 4964},{ 1716, 5038},{ 1885, 5128} - }, - /*Cb qi=29 INTER*/ - { - { 126, 25},{ 95, 340},{ 69, 662},{ 71, 1039}, - { 88, 1440},{ 102, 1839},{ 113, 2227},{ 122, 2604}, - { 132, 2969},{ 141, 3320},{ 151, 3659},{ 161, 3985}, - { 172, 4301},{ 186, 4612},{ 200, 4917},{ 219, 5213}, - { 241, 5509},{ 265, 5800},{ 296, 6081},{ 329, 6360}, - { 369, 6633},{ 414, 6899},{ 465, 7148},{ 520, 7387} - } - }, - { - /*Cr qi=29 INTRA*/ - { - { 6, 7},{ 82, 382},{ 142, 772},{ 185, 1211}, - { 233, 1632},{ 303, 2000},{ 388, 2306},{ 475, 2550}, - { 556, 2779},{ 627, 3007},{ 707, 3237},{ 778, 3459}, - { 843, 3654},{ 927, 3834},{ 1012, 4012},{ 1101, 4152}, - { 1197, 4262},{ 1275, 4399},{ 1359, 4511},{ 1455, 4596}, - { 1562, 4708},{ 1644, 4833},{ 1719, 4954},{ 1888, 4988} - }, - /*Cr qi=29 INTER*/ - { - { 101, 28},{ 81, 343},{ 67, 673},{ 75, 1053}, - { 93, 1450},{ 106, 1844},{ 113, 2230},{ 119, 2610}, - { 127, 2980},{ 135, 3334},{ 143, 3676},{ 153, 4007}, - { 165, 4330},{ 180, 4645},{ 201, 4951},{ 224, 5243}, - { 253, 5522},{ 284, 5794},{ 314, 6060},{ 345, 6322}, - { 381, 6578},{ 419, 6828},{ 455, 7073},{ 495, 7316} - } - } - }, - { - { - /*Y' qi=30 INTRA*/ - { - { 112, 8},{ 335, 1380},{ 682, 2401},{ 1083, 3093}, - { 1489, 3619},{ 1902, 4092},{ 2332, 4511},{ 2777, 4865}, - { 3231, 5156},{ 3693, 5394},{ 4153, 5585},{ 4605, 5689}, - { 5049, 5764},{ 5468, 5871},{ 5875, 6004},{ 6295, 6120}, - { 6706, 6201},{ 7099, 6273},{ 7461, 6311},{ 7785, 6320}, - { 8128, 6322},{ 8469, 6331},{ 8806, 6342},{ 9220, 6338} - }, - /*Y' qi=30 INTER*/ - { - { 58, 8},{ 90, 1340},{ 169, 2771},{ 257, 4079}, - { 345, 5266},{ 459, 6387},{ 660, 7383},{ 990, 8180}, - { 1496, 8726},{ 2203, 8992},{ 3029, 9038},{ 3833, 8984}, - { 4549, 8900},{ 5183, 8813},{ 5745, 8735},{ 6250, 8674}, - { 6715, 8619},{ 7138, 8565},{ 7529, 8528},{ 7899, 8495}, - { 8234, 8465},{ 8550, 8429},{ 8856, 8395},{ 9160, 8374} - } - }, - { - /*Cb qi=30 INTRA*/ - { - { 7, 3},{ 88, 369},{ 149, 747},{ 185, 1175}, - { 232, 1599},{ 304, 1976},{ 392, 2293},{ 486, 2557}, - { 573, 2797},{ 656, 3027},{ 735, 3243},{ 819, 3442}, - { 903, 3629},{ 966, 3828},{ 1025, 4027},{ 1105, 4204}, - { 1201, 4343},{ 1282, 4469},{ 1379, 4575},{ 1486, 4689}, - { 1588, 4813},{ 1678, 4900},{ 1767, 4969},{ 1911, 5080} - }, - /*Cb qi=30 INTER*/ - { - { 120, 23},{ 96, 336},{ 72, 661},{ 75, 1043}, - { 91, 1441},{ 105, 1837},{ 117, 2221},{ 127, 2592}, - { 137, 2953},{ 148, 3301},{ 159, 3635},{ 170, 3959}, - { 184, 4271},{ 199, 4578},{ 216, 4879},{ 238, 5175}, - { 262, 5466},{ 294, 5750},{ 332, 6027},{ 373, 6298}, - { 421, 6559},{ 473, 6805},{ 526, 7053},{ 587, 7298} - } - }, - { - /*Cr qi=30 INTRA*/ - { - { 10, 7},{ 89, 384},{ 147, 773},{ 192, 1211}, - { 245, 1627},{ 322, 1984},{ 412, 2280},{ 501, 2520}, - { 583, 2750},{ 654, 2982},{ 736, 3207},{ 810, 3419}, - { 873, 3614},{ 957, 3794},{ 1048, 3965},{ 1139, 4102}, - { 1237, 4208},{ 1327, 4328},{ 1408, 4448},{ 1496, 4545}, - { 1604, 4652},{ 1699, 4760},{ 1780, 4877},{ 1937, 4942} - }, - /*Cr qi=30 INTER*/ - { - { 115, 26},{ 89, 342},{ 70, 672},{ 79, 1055}, - { 96, 1451},{ 108, 1841},{ 116, 2222},{ 124, 2599}, - { 132, 2965},{ 141, 3316},{ 151, 3655},{ 163, 3984}, - { 178, 4301},{ 197, 4609},{ 219, 4909},{ 247, 5195}, - { 280, 5469},{ 317, 5734},{ 351, 5991},{ 383, 6248}, - { 423, 6500},{ 467, 6744},{ 502, 6995},{ 558, 7226} - } - } - }, - { - { - /*Y' qi=31 INTRA*/ - { - { 116, 20},{ 359, 1361},{ 732, 2350},{ 1162, 3010}, - { 1597, 3507},{ 2042, 3950},{ 2503, 4339},{ 2974, 4670}, - { 3446, 4951},{ 3922, 5179},{ 4394, 5357},{ 4858, 5454}, - { 5313, 5519},{ 5734, 5626},{ 6154, 5755},{ 6585, 5859}, - { 7004, 5928},{ 7408, 5998},{ 7775, 6039},{ 8102, 6048}, - { 8442, 6051},{ 8790, 6054},{ 9136, 6057},{ 9554, 6041} - }, - /*Y' qi=31 INTER*/ - { - { 53, 12},{ 90, 1340},{ 169, 2765},{ 259, 4062}, - { 353, 5236},{ 483, 6340},{ 713, 7305},{ 1086, 8059}, - { 1651, 8548},{ 2423, 8751},{ 3288, 8754},{ 4106, 8674}, - { 4827, 8572},{ 5451, 8482},{ 6007, 8407},{ 6514, 8344}, - { 6970, 8282},{ 7397, 8225},{ 7795, 8193},{ 8159, 8161}, - { 8498, 8120},{ 8814, 8093},{ 9127, 8066},{ 9432, 8040} - } - }, - { - /*Cb qi=31 INTRA*/ - { - { 7, 3},{ 88, 369},{ 149, 746},{ 185, 1173}, - { 234, 1595},{ 308, 1967},{ 399, 2278},{ 494, 2537}, - { 583, 2774},{ 669, 2997},{ 755, 3204},{ 847, 3390}, - { 936, 3569},{ 1008, 3759},{ 1078, 3942},{ 1162, 4104}, - { 1262, 4238},{ 1352, 4364},{ 1442, 4470},{ 1557, 4567}, - { 1676, 4674},{ 1759, 4781},{ 1850, 4853},{ 2043, 4897} - }, - /*Cb qi=31 INTER*/ - { - { 121, 23},{ 96, 335},{ 72, 660},{ 74, 1043}, - { 90, 1440},{ 105, 1834},{ 116, 2217},{ 127, 2586}, - { 138, 2945},{ 148, 3293},{ 159, 3626},{ 172, 3945}, - { 185, 4256},{ 202, 4559},{ 223, 4856},{ 245, 5150}, - { 272, 5440},{ 306, 5719},{ 346, 5989},{ 391, 6253}, - { 443, 6511},{ 510, 6743},{ 583, 6965},{ 651, 7182} - } - }, - { - /*Cr qi=31 INTRA*/ - { - { 10, 7},{ 88, 384},{ 147, 773},{ 192, 1209}, - { 247, 1622},{ 326, 1974},{ 417, 2262},{ 509, 2500}, - { 596, 2726},{ 670, 2949},{ 754, 3170},{ 836, 3370}, - { 912, 3548},{ 999, 3724},{ 1093, 3888},{ 1198, 4000}, - { 1304, 4095},{ 1384, 4230},{ 1470, 4347},{ 1577, 4422}, - { 1696, 4513},{ 1798, 4620},{ 1869, 4746},{ 1991, 4798} - }, - /*Cr qi=31 INTER*/ - { - { 113, 32},{ 88, 345},{ 69, 674},{ 79, 1055}, - { 96, 1451},{ 108, 1839},{ 115, 2218},{ 123, 2592}, - { 132, 2957},{ 141, 3308},{ 151, 3643},{ 163, 3968}, - { 179, 4285},{ 200, 4590},{ 225, 4886},{ 254, 5169}, - { 291, 5436},{ 330, 5696},{ 368, 5951},{ 409, 6200}, - { 452, 6448},{ 493, 6695},{ 536, 6940},{ 571, 7204} - } - } - }, - { - { - /*Y' qi=32 INTRA*/ - { - { 123, 26},{ 370, 1356},{ 756, 2321},{ 1211, 2944}, - { 1674, 3408},{ 2148, 3826},{ 2639, 4193},{ 3138, 4504}, - { 3634, 4765},{ 4133, 4973},{ 4625, 5137},{ 5101, 5225}, - { 5567, 5274},{ 6002, 5363},{ 6437, 5482},{ 6885, 5566}, - { 7312, 5625},{ 7723, 5686},{ 8101, 5721},{ 8429, 5732}, - { 8769, 5728},{ 9120, 5726},{ 9472, 5723},{ 9918, 5700} - }, - /*Y' qi=32 INTER*/ - { - { 54, -3},{ 95, 1343},{ 179, 2750},{ 276, 4027}, - { 382, 5185},{ 543, 6256},{ 830, 7161},{ 1301, 7815}, - { 2003, 8172},{ 2883, 8266},{ 3779, 8217},{ 4578, 8127}, - { 5274, 8035},{ 5886, 7952},{ 6430, 7887},{ 6929, 7835}, - { 7380, 7779},{ 7796, 7737},{ 8190, 7705},{ 8552, 7672}, - { 8896, 7640},{ 9210, 7612},{ 9510, 7589},{ 9746, 7552} - } - }, - { - /*Cb qi=32 INTRA*/ - { - { 6, 3},{ 89, 369},{ 153, 746},{ 193, 1167}, - { 247, 1577},{ 330, 1935},{ 429, 2236},{ 528, 2494}, - { 620, 2732},{ 712, 2948},{ 801, 3146},{ 898, 3325}, - { 999, 3489},{ 1078, 3664},{ 1155, 3832},{ 1251, 3985}, - { 1360, 4115},{ 1451, 4236},{ 1549, 4338},{ 1667, 4433}, - { 1797, 4522},{ 1891, 4613},{ 1989, 4687},{ 2162, 4776} - }, - /*Cb qi=32 INTER*/ - { - { 116, -1},{ 98, 321},{ 80, 656},{ 80, 1042}, - { 96, 1438},{ 110, 1827},{ 122, 2205},{ 133, 2570}, - { 144, 2925},{ 157, 3268},{ 170, 3597},{ 185, 3911}, - { 202, 4216},{ 221, 4516},{ 244, 4809},{ 273, 5096}, - { 308, 5376},{ 350, 5644},{ 401, 5907},{ 459, 6160}, - { 520, 6401},{ 592, 6630},{ 676, 6837},{ 758, 7050} - } - }, - { - /*Cr qi=32 INTRA*/ - { - { 12, 7},{ 91, 386},{ 152, 773},{ 201, 1202}, - { 261, 1603},{ 347, 1942},{ 447, 2223},{ 540, 2460}, - { 626, 2684},{ 711, 2901},{ 801, 3115},{ 887, 3312}, - { 969, 3480},{ 1068, 3633},{ 1176, 3779},{ 1283, 3885}, - { 1392, 3969},{ 1485, 4090},{ 1573, 4206},{ 1686, 4274}, - { 1813, 4354},{ 1911, 4459},{ 2004, 4563},{ 2162, 4590} - }, - /*Cr qi=32 INTER*/ - { - { 129, 5},{ 98, 334},{ 75, 673},{ 84, 1055}, - { 101, 1448},{ 113, 1832},{ 121, 2206},{ 129, 2577}, - { 140, 2937},{ 151, 3282},{ 163, 3614},{ 179, 3932}, - { 198, 4240},{ 221, 4542},{ 252, 4830},{ 290, 5102}, - { 329, 5364},{ 373, 5618},{ 420, 5864},{ 468, 6105}, - { 513, 6351},{ 564, 6587},{ 624, 6810},{ 697, 7017} - } - } - }, - { - { - /*Y' qi=33 INTRA*/ - { - { 115, 36},{ 388, 1338},{ 791, 2289},{ 1258, 2899}, - { 1732, 3352},{ 2220, 3760},{ 2730, 4117},{ 3244, 4415}, - { 3751, 4662},{ 4261, 4858},{ 4766, 5012},{ 5249, 5094}, - { 5719, 5141},{ 6159, 5225},{ 6597, 5333},{ 7044, 5416}, - { 7474, 5472},{ 7893, 5531},{ 8268, 5570},{ 8591, 5580}, - { 8931, 5578},{ 9283, 5579},{ 9634, 5582},{10067, 5560} - }, - /*Y' qi=33 INTER*/ - { - { 65, -14},{ 102, 1345},{ 190, 2736},{ 294, 3999}, - { 411, 5146},{ 597, 6192},{ 934, 7045},{ 1488, 7622}, - { 2281, 7895},{ 3213, 7937},{ 4108, 7871},{ 4883, 7784}, - { 5556, 7709},{ 6150, 7643},{ 6685, 7585},{ 7176, 7539}, - { 7620, 7502},{ 8034, 7466},{ 8427, 7435},{ 8793, 7409}, - { 9136, 7386},{ 9446, 7364},{ 9743, 7339},{10025, 7303} - } - }, - { - /*Cb qi=33 INTRA*/ - { - { 5, 3},{ 92, 369},{ 159, 746},{ 203, 1163}, - { 263, 1564},{ 353, 1911},{ 458, 2204},{ 557, 2460}, - { 650, 2697},{ 744, 2913},{ 836, 3110},{ 934, 3292}, - { 1036, 3454},{ 1125, 3616},{ 1204, 3781},{ 1298, 3932}, - { 1410, 4058},{ 1507, 4170},{ 1606, 4265},{ 1725, 4358}, - { 1853, 4445},{ 1955, 4535},{ 2067, 4597},{ 2258, 4663} - }, - /*Cb qi=33 INTER*/ - { - { 109, 37},{ 94, 343},{ 81, 662},{ 85, 1042}, - { 102, 1436},{ 116, 1823},{ 128, 2195},{ 141, 2554}, - { 154, 2906},{ 167, 3246},{ 183, 3570},{ 202, 3881}, - { 220, 4185},{ 241, 4482},{ 268, 4772},{ 302, 5053}, - { 341, 5328},{ 388, 5592},{ 446, 5846},{ 507, 6096}, - { 581, 6328},{ 670, 6534},{ 762, 6731},{ 842, 6922} - } - }, - { - /*Cr qi=33 INTRA*/ - { - { 11, 7},{ 93, 387},{ 158, 774},{ 211, 1197}, - { 278, 1589},{ 372, 1917},{ 475, 2191},{ 569, 2429}, - { 658, 2655},{ 744, 2868},{ 835, 3083},{ 926, 3271}, - { 1010, 3430},{ 1110, 3586},{ 1224, 3724},{ 1336, 3826}, - { 1449, 3908},{ 1547, 4021},{ 1636, 4136},{ 1751, 4200}, - { 1886, 4277},{ 1977, 4384},{ 2070, 4474},{ 2232, 4510} - }, - /*Cr qi=33 INTER*/ - { - { 77, 9},{ 90, 347},{ 80, 674},{ 91, 1053}, - { 107, 1444},{ 119, 1825},{ 127, 2196},{ 137, 2563}, - { 149, 2919},{ 161, 3259},{ 176, 3588},{ 194, 3905}, - { 217, 4209},{ 246, 4504},{ 280, 4786},{ 320, 5055}, - { 364, 5316},{ 409, 5565},{ 460, 5804},{ 517, 6039}, - { 578, 6264},{ 640, 6489},{ 701, 6721},{ 772, 6948} - } - } - }, - { - { - /*Y' qi=34 INTRA*/ - { - { 124, 40},{ 401, 1333},{ 823, 2262},{ 1318, 2842}, - { 1823, 3265},{ 2339, 3650},{ 2872, 3991},{ 3405, 4274}, - { 3926, 4513},{ 4448, 4704},{ 4961, 4845},{ 5450, 4921}, - { 5925, 4971},{ 6372, 5053},{ 6813, 5160},{ 7264, 5242}, - { 7704, 5291},{ 8124, 5346},{ 8500, 5382},{ 8831, 5384}, - { 9178, 5380},{ 9525, 5387},{ 9869, 5389},{10310, 5356} - }, - /*Y' qi=34 INTER*/ - { - { 64, -17},{ 101, 1344},{ 190, 2730},{ 299, 3981}, - { 430, 5110},{ 648, 6127},{ 1036, 6933},{ 1664, 7445}, - { 2535, 7652},{ 3504, 7653},{ 4402, 7572},{ 5173, 7479}, - { 5843, 7400},{ 6441, 7334},{ 6976, 7280},{ 7464, 7231}, - { 7910, 7189},{ 8332, 7157},{ 8730, 7125},{ 9091, 7103}, - { 9422, 7086},{ 9753, 7061},{10067, 7036},{10316, 7029} - } - }, - { - /*Cb qi=34 INTRA*/ - { - { 5, 3},{ 91, 369},{ 158, 746},{ 204, 1162}, - { 266, 1561},{ 358, 1903},{ 466, 2189},{ 570, 2439}, - { 665, 2671},{ 765, 2880},{ 864, 3069},{ 970, 3238}, - { 1079, 3392},{ 1174, 3545},{ 1265, 3693},{ 1360, 3841}, - { 1471, 3968},{ 1572, 4083},{ 1675, 4181},{ 1804, 4255}, - { 1939, 4332},{ 2048, 4411},{ 2155, 4484},{ 2339, 4584} - }, - /*Cb qi=34 INTER*/ - { - { 99, 44},{ 92, 345},{ 82, 661},{ 86, 1043}, - { 101, 1436},{ 116, 1821},{ 128, 2191},{ 140, 2549}, - { 154, 2898},{ 168, 3235},{ 185, 3556},{ 203, 3865}, - { 224, 4166},{ 248, 4457},{ 278, 4741},{ 315, 5021}, - { 361, 5289},{ 416, 5546},{ 483, 5792},{ 559, 6025}, - { 651, 6237},{ 752, 6432},{ 849, 6626},{ 967, 6790} - } - }, - { - /*Cr qi=34 INTRA*/ - { - { 11, 7},{ 93, 387},{ 158, 773},{ 212, 1195}, - { 282, 1584},{ 378, 1909},{ 483, 2179},{ 578, 2414}, - { 671, 2633},{ 766, 2837},{ 866, 3038},{ 960, 3223}, - { 1049, 3376},{ 1158, 3520},{ 1285, 3644},{ 1400, 3740}, - { 1505, 3828},{ 1616, 3928},{ 1713, 4030},{ 1820, 4104}, - { 1957, 4185},{ 2063, 4280},{ 2160, 4355},{ 2320, 4341} - }, - /*Cr qi=34 INTER*/ - { - { 78, 11},{ 89, 347},{ 79, 674},{ 90, 1053}, - { 106, 1444},{ 117, 1823},{ 127, 2192},{ 137, 2558}, - { 149, 2912},{ 163, 3249},{ 178, 3574},{ 197, 3888}, - { 222, 4189},{ 252, 4481},{ 293, 4755},{ 341, 5013}, - { 386, 5268},{ 436, 5512},{ 498, 5743},{ 563, 5970}, - { 622, 6200},{ 694, 6415},{ 776, 6622},{ 871, 6818} - } - } - }, - { - { - /*Y' qi=35 INTRA*/ - { - { 116, 51},{ 433, 1312},{ 881, 2221},{ 1406, 2771}, - { 1948, 3156},{ 2511, 3501},{ 3085, 3811},{ 3654, 4066}, - { 4212, 4273},{ 4763, 4444},{ 5298, 4572},{ 5799, 4638}, - { 6285, 4678},{ 6747, 4746},{ 7203, 4838},{ 7673, 4905}, - { 8124, 4950},{ 8552, 5003},{ 8938, 5027},{ 9275, 5026}, - { 9628, 5019},{ 9981, 5024},{10331, 5030},{10795, 5000} - }, - /*Y' qi=35 INTER*/ - { - { 71, -10},{ 108, 1348},{ 203, 2710},{ 325, 3938}, - { 485, 5040},{ 766, 6000},{ 1267, 6706},{ 2048, 7089}, - { 3037, 7191},{ 4032, 7146},{ 4903, 7061},{ 5648, 6977}, - { 6301, 6912},{ 6884, 6857},{ 7413, 6812},{ 7898, 6775}, - { 8342, 6739},{ 8764, 6710},{ 9160, 6688},{ 9519, 6668}, - { 9859, 6646},{10190, 6625},{10492, 6612},{10755, 6595} - } - }, - { - /*Cb qi=35 INTRA*/ - { - { 6, 3},{ 95, 369},{ 164, 746},{ 214, 1156}, - { 287, 1542},{ 390, 1869},{ 504, 2143},{ 611, 2388}, - { 712, 2613},{ 822, 2811},{ 937, 2987},{ 1055, 3147}, - { 1174, 3285},{ 1286, 3420},{ 1386, 3560},{ 1488, 3698}, - { 1604, 3814},{ 1714, 3916},{ 1825, 4008},{ 1958, 4088}, - { 2101, 4159},{ 2224, 4226},{ 2339, 4292},{ 2538, 4383} - }, - /*Cb qi=35 INTER*/ - { - { 98, 41},{ 90, 348},{ 86, 665},{ 92, 1042}, - { 108, 1432},{ 122, 1812},{ 136, 2175},{ 151, 2528}, - { 165, 2872},{ 182, 3202},{ 202, 3516},{ 225, 3819}, - { 251, 4112},{ 281, 4398},{ 320, 4675},{ 367, 4944}, - { 421, 5204},{ 493, 5450},{ 579, 5679},{ 672, 5892}, - { 785, 6082},{ 906, 6258},{ 1026, 6432},{ 1153, 6592} - } - }, - { - /*Cr qi=35 INTRA*/ - { - { 12, 7},{ 98, 388},{ 166, 773},{ 226, 1187}, - { 306, 1563},{ 411, 1874},{ 524, 2134},{ 622, 2365}, - { 721, 2577},{ 826, 2768},{ 947, 2946},{ 1066, 3106}, - { 1163, 3250},{ 1274, 3395},{ 1417, 3508},{ 1539, 3590}, - { 1639, 3671},{ 1754, 3765},{ 1865, 3855},{ 1979, 3921}, - { 2127, 3998},{ 2249, 4085},{ 2346, 4172},{ 2473, 4210} - }, - /*Cr qi=35 INTER*/ - { - { 86, 12},{ 94, 354},{ 85, 677},{ 96, 1052}, - { 113, 1439},{ 125, 1811},{ 135, 2177},{ 147, 2537}, - { 160, 2884},{ 177, 3215},{ 195, 3535},{ 219, 3842}, - { 252, 4133},{ 292, 4413},{ 339, 4680},{ 396, 4928}, - { 455, 5169},{ 514, 5408},{ 588, 5626},{ 672, 5835}, - { 750, 6051},{ 837, 6257},{ 943, 6442},{ 1073, 6595} - } - } - }, - { - { - /*Y' qi=36 INTRA*/ - { - { 116, 52},{ 432, 1312},{ 881, 2215},{ 1407, 2759}, - { 1948, 3140},{ 2511, 3484},{ 3090, 3789},{ 3672, 4036}, - { 4243, 4236},{ 4803, 4397},{ 5346, 4517},{ 5856, 4581}, - { 6350, 4614},{ 6821, 4675},{ 7286, 4763},{ 7754, 4832}, - { 8201, 4875},{ 8631, 4922},{ 9015, 4948},{ 9351, 4945}, - { 9706, 4941},{10061, 4948},{10408, 4949},{10878, 4923} - }, - /*Y' qi=36 INTER*/ - { - { 63, -16},{ 114, 1332},{ 216, 2690},{ 343, 3914}, - { 515, 5009},{ 829, 5939},{ 1399, 6586},{ 2263, 6901}, - { 3290, 6967},{ 4272, 6920},{ 5115, 6847},{ 5839, 6779}, - { 6478, 6726},{ 7051, 6685},{ 7571, 6649},{ 8050, 6614}, - { 8495, 6587},{ 8908, 6567},{ 9298, 6550},{ 9673, 6530}, - {10005, 6512},{10324, 6499},{10640, 6483},{10936, 6487} - } - }, - { - /*Cb qi=36 INTRA*/ - { - { 6, 3},{ 98, 370},{ 170, 746},{ 225, 1150}, - { 306, 1527},{ 416, 1845},{ 534, 2116},{ 642, 2363}, - { 743, 2591},{ 851, 2794},{ 964, 2972},{ 1081, 3133}, - { 1198, 3275},{ 1311, 3410},{ 1411, 3547},{ 1519, 3680}, - { 1642, 3789},{ 1750, 3892},{ 1860, 3982},{ 1998, 4054}, - { 2141, 4129},{ 2256, 4204},{ 2372, 4278},{ 2567, 4356} - }, - /*Cb qi=36 INTER*/ - { - { 107, 30},{ 96, 346},{ 88, 667},{ 100, 1039}, - { 115, 1426},{ 128, 1804},{ 142, 2164},{ 158, 2512}, - { 176, 2851},{ 195, 3178},{ 218, 3491},{ 243, 3791}, - { 270, 4084},{ 307, 4365},{ 348, 4638},{ 397, 4908}, - { 464, 5157},{ 545, 5392},{ 635, 5620},{ 734, 5831}, - { 854, 6015},{ 993, 6170},{ 1124, 6327},{ 1234, 6502} - } - }, - { - /*Cr qi=36 INTRA*/ - { - { 12, 7},{ 102, 388},{ 172, 773},{ 239, 1182}, - { 328, 1546},{ 439, 1848},{ 554, 2106},{ 651, 2341}, - { 747, 2561},{ 850, 2757},{ 972, 2934},{ 1086, 3097}, - { 1182, 3245},{ 1302, 3382},{ 1447, 3491},{ 1572, 3567}, - { 1677, 3641},{ 1793, 3733},{ 1899, 3828},{ 2013, 3894}, - { 2163, 3967},{ 2283, 4059},{ 2387, 4142},{ 2559, 4145} - }, - /*Cr qi=36 INTER*/ - { - { 98, -10},{ 96, 347},{ 89, 676},{ 102, 1048}, - { 118, 1433},{ 130, 1804},{ 141, 2167},{ 154, 2523}, - { 171, 2866},{ 190, 3194},{ 212, 3508},{ 240, 3809}, - { 276, 4099},{ 320, 4377},{ 372, 4638},{ 428, 4887}, - { 492, 5122},{ 560, 5353},{ 638, 5572},{ 725, 5779}, - { 814, 5985},{ 902, 6192},{ 1013, 6377},{ 1155, 6527} - } - } - }, - { - { - /*Y' qi=37 INTRA*/ - { - { 109, 58},{ 445, 1302},{ 927, 2177},{ 1489, 2689}, - { 2053, 3052},{ 2632, 3387},{ 3230, 3683},{ 3830, 3922}, - { 4417, 4114},{ 4992, 4266},{ 5546, 4375},{ 6067, 4430}, - { 6571, 4459},{ 7046, 4516},{ 7513, 4599},{ 7991, 4663}, - { 8445, 4706},{ 8883, 4749},{ 9273, 4771},{ 9612, 4770}, - { 9970, 4765},{10325, 4773},{10672, 4778},{11106, 4758} - }, - /*Y' qi=37 INTER*/ - { - { 56, -14},{ 114, 1333},{ 218, 2683},{ 354, 3894}, - { 550, 4966},{ 916, 5854},{ 1569, 6437},{ 2520, 6685}, - { 3596, 6704},{ 4585, 6635},{ 5424, 6556},{ 6147, 6489}, - { 6787, 6437},{ 7358, 6395},{ 7876, 6358},{ 8361, 6325}, - { 8807, 6294},{ 9229, 6271},{ 9631, 6253},{10002, 6238}, - {10356, 6228},{10678, 6212},{10975, 6197},{11274, 6185} - } - }, - { - /*Cb qi=37 INTRA*/ - { - { 6, 3},{ 99, 370},{ 171, 746},{ 227, 1149}, - { 309, 1522},{ 421, 1836},{ 541, 2104},{ 652, 2347}, - { 757, 2572},{ 871, 2768},{ 989, 2936},{ 1111, 3087}, - { 1238, 3223},{ 1357, 3352},{ 1465, 3486},{ 1576, 3612}, - { 1709, 3705},{ 1828, 3801},{ 1937, 3895},{ 2076, 3967}, - { 2220, 4035},{ 2345, 4104},{ 2466, 4173},{ 2680, 4265} - }, - /*Cb qi=37 INTER*/ - { - { 111, 27},{ 97, 344},{ 87, 667},{ 99, 1038}, - { 115, 1425},{ 128, 1802},{ 143, 2160},{ 159, 2506}, - { 176, 2843},{ 198, 3167},{ 220, 3477},{ 247, 3774}, - { 280, 4061},{ 321, 4338},{ 368, 4608},{ 427, 4867}, - { 501, 5109},{ 595, 5332},{ 701, 5544},{ 818, 5738}, - { 956, 5905},{ 1105, 6066},{ 1248, 6217},{ 1381, 6353} - } - }, - { - /*Cr qi=37 INTRA*/ - { - { 12, 7},{ 102, 388},{ 173, 773},{ 242, 1180}, - { 331, 1541},{ 444, 1839},{ 562, 2095},{ 662, 2326}, - { 763, 2540},{ 871, 2728},{ 1003, 2892},{ 1130, 3045}, - { 1230, 3188},{ 1350, 3321},{ 1503, 3418},{ 1634, 3492}, - { 1737, 3568},{ 1856, 3653},{ 1970, 3744},{ 2091, 3802}, - { 2247, 3871},{ 2371, 3962},{ 2477, 4041},{ 2655, 4052} - }, - /*Cr qi=37 INTER*/ - { - { 89, -9},{ 97, 347},{ 88, 677},{ 102, 1048}, - { 118, 1432},{ 130, 1802},{ 141, 2163},{ 154, 2517}, - { 172, 2857},{ 192, 3181},{ 216, 3494},{ 246, 3793}, - { 286, 4074},{ 337, 4343},{ 395, 4600},{ 464, 4837}, - { 534, 5066},{ 608, 5289},{ 694, 5501},{ 788, 5704}, - { 893, 5901},{ 1010, 6088},{ 1151, 6249},{ 1331, 6374} - } - } - }, - { - { - /*Y' qi=38 INTRA*/ - { - { 107, 65},{ 476, 1286},{ 968, 2148},{ 1548, 2641}, - { 2141, 2979},{ 2757, 3289},{ 3390, 3564},{ 4020, 3784}, - { 4632, 3957},{ 5224, 4097},{ 5794, 4201},{ 6326, 4250}, - { 6828, 4274},{ 7309, 4322},{ 7790, 4401},{ 8271, 4463}, - { 8729, 4498},{ 9165, 4540},{ 9552, 4566},{ 9901, 4560}, - {10266, 4552},{10617, 4563},{10964, 4572},{11393, 4567} - }, - /*Y' qi=38 INTER*/ - { - { 57, -13},{ 118, 1332},{ 233, 2665},{ 386, 3856}, - { 620, 4899},{ 1070, 5722},{ 1849, 6211},{ 2898, 6384}, - { 3989, 6376},{ 4947, 6311},{ 5754, 6249},{ 6454, 6199}, - { 7077, 6161},{ 7640, 6132},{ 8159, 6101},{ 8639, 6076}, - { 9081, 6054},{ 9502, 6037},{ 9900, 6027},{10274, 6012}, - {10621, 5999},{10938, 5991},{11237, 5977},{11557, 5966} - } - }, - { - /*Cb qi=38 INTRA*/ - { - { 8, 3},{ 104, 370},{ 179, 744},{ 243, 1139}, - { 338, 1498},{ 458, 1801},{ 584, 2060},{ 700, 2297}, - { 812, 2514},{ 935, 2699},{ 1061, 2858},{ 1189, 3007}, - { 1321, 3141},{ 1446, 3266},{ 1563, 3388},{ 1684, 3512}, - { 1816, 3614},{ 1942, 3702},{ 2055, 3793},{ 2201, 3857}, - { 2357, 3923},{ 2477, 3994},{ 2593, 4061},{ 2768, 4178} - }, - /*Cb qi=38 INTER*/ - { - { 118, 24},{ 102, 342},{ 91, 663},{ 101, 1040}, - { 116, 1427},{ 131, 1799},{ 147, 2152},{ 168, 2491}, - { 191, 2822},{ 215, 3139},{ 244, 3441},{ 276, 3731}, - { 316, 4013},{ 363, 4286},{ 423, 4546},{ 495, 4795}, - { 584, 5028},{ 691, 5242},{ 814, 5439},{ 959, 5608}, - { 1119, 5759},{ 1277, 5906},{ 1449, 6035},{ 1655, 6144} - } - }, - { - /*Cr qi=38 INTRA*/ - { - { 12, 6},{ 106, 387},{ 182, 771},{ 261, 1168}, - { 364, 1514},{ 483, 1802},{ 603, 2053},{ 707, 2282}, - { 817, 2489},{ 933, 2670},{ 1074, 2825},{ 1210, 2967}, - { 1320, 3104},{ 1444, 3229},{ 1599, 3324},{ 1735, 3396}, - { 1846, 3464},{ 1971, 3547},{ 2086, 3646},{ 2206, 3711}, - { 2366, 3773},{ 2499, 3859},{ 2603, 3945},{ 2766, 3952} - }, - /*Cr qi=38 INTER*/ - { - { 86, -9},{ 91, 352},{ 85, 680},{ 102, 1053}, - { 119, 1435},{ 132, 1799},{ 146, 2153},{ 162, 2501}, - { 183, 2835},{ 209, 3154},{ 240, 3458},{ 278, 3751}, - { 327, 4025},{ 388, 4284},{ 455, 4532},{ 529, 4766}, - { 616, 4980},{ 711, 5188},{ 815, 5386},{ 920, 5583}, - { 1042, 5770},{ 1186, 5936},{ 1348, 6080},{ 1542, 6196} - } - } - }, - { - { - /*Y' qi=39 INTRA*/ - { - { 103, 66},{ 479, 1283},{ 998, 2125},{ 1610, 2591}, - { 2223, 2913},{ 2855, 3214},{ 3501, 3482},{ 4146, 3698}, - { 4772, 3868},{ 5376, 3999},{ 5956, 4095},{ 6496, 4140}, - { 7008, 4162},{ 7499, 4209},{ 7987, 4282},{ 8478, 4338}, - { 8947, 4374},{ 9385, 4417},{ 9783, 4437},{10143, 4433}, - {10504, 4424},{10866, 4435},{11225, 4444},{11665, 4430} - }, - /*Y' qi=39 INTER*/ - { - { 56, 2},{ 118, 1332},{ 235, 2660},{ 395, 3843}, - { 653, 4867},{ 1153, 5652},{ 2003, 6089},{ 3113, 6214}, - { 4228, 6178},{ 5189, 6102},{ 6002, 6031},{ 6707, 5976}, - { 7336, 5936},{ 7901, 5900},{ 8424, 5870},{ 8915, 5844}, - { 9361, 5822},{ 9784, 5807},{10187, 5794},{10571, 5778}, - {10931, 5763},{11264, 5751},{11582, 5742},{11916, 5730} - } - }, - { - /*Cb qi=39 INTRA*/ - { - { 8, 3},{ 104, 370},{ 179, 744},{ 244, 1138}, - { 340, 1496},{ 461, 1796},{ 588, 2053},{ 705, 2288}, - { 820, 2503},{ 945, 2684},{ 1073, 2840},{ 1210, 2981}, - { 1352, 3106},{ 1480, 3225},{ 1603, 3342},{ 1728, 3464}, - { 1865, 3559},{ 1990, 3645},{ 2106, 3734},{ 2258, 3796}, - { 2413, 3856},{ 2540, 3920},{ 2667, 3986},{ 2887, 4060} - }, - /*Cb qi=39 INTER*/ - { - { 119, 19},{ 103, 340},{ 90, 664},{ 100, 1040}, - { 115, 1426},{ 131, 1797},{ 148, 2148},{ 169, 2486}, - { 192, 2816},{ 217, 3131},{ 247, 3432},{ 282, 3721}, - { 324, 3999},{ 374, 4268},{ 435, 4526},{ 520, 4766}, - { 621, 4990},{ 738, 5194},{ 878, 5376},{ 1035, 5543}, - { 1202, 5686},{ 1374, 5819},{ 1545, 5950},{ 1729, 6064} - } - }, - { - /*Cr qi=39 INTRA*/ - { - { 12, 6},{ 106, 387},{ 182, 771},{ 262, 1167}, - { 365, 1512},{ 486, 1798},{ 608, 2047},{ 713, 2274}, - { 824, 2479},{ 945, 2655},{ 1091, 2804},{ 1231, 2941}, - { 1346, 3073},{ 1475, 3194},{ 1633, 3282},{ 1778, 3345}, - { 1891, 3414},{ 2013, 3501},{ 2138, 3584},{ 2266, 3640}, - { 2428, 3701},{ 2568, 3782},{ 2674, 3863},{ 2816, 3894} - }, - /*Cr qi=39 INTER*/ - { - { 88, -7},{ 92, 352},{ 85, 680},{ 102, 1053}, - { 119, 1434},{ 132, 1797},{ 146, 2151},{ 163, 2498}, - { 185, 2830},{ 211, 3147},{ 243, 3451},{ 285, 3735}, - { 337, 4005},{ 401, 4260},{ 477, 4499},{ 565, 4721}, - { 655, 4937},{ 749, 5148},{ 858, 5344},{ 979, 5529}, - { 1110, 5710},{ 1264, 5871},{ 1460, 5990},{ 1677, 6086} - } - } - }, - { - { - /*Y' qi=40 INTRA*/ - { - { 98, 71},{ 491, 1274},{ 1023, 2103},{ 1641, 2559}, - { 2257, 2877},{ 2898, 3171},{ 3566, 3429},{ 4233, 3629}, - { 4881, 3784},{ 5499, 3906},{ 6088, 3997},{ 6631, 4040}, - { 7145, 4060},{ 7640, 4107},{ 8128, 4178},{ 8618, 4233}, - { 9077, 4267},{ 9514, 4304},{ 9919, 4324},{10277, 4317}, - {10635, 4312},{10985, 4324},{11338, 4331},{11792, 4334} - }, - /*Y' qi=40 INTER*/ - { - { 63, -26},{ 125, 1331},{ 256, 2640},{ 439, 3801}, - { 757, 4782},{ 1391, 5474},{ 2399, 5805},{ 3582, 5870}, - { 4678, 5824},{ 5600, 5763},{ 6386, 5710},{ 7076, 5667}, - { 7693, 5637},{ 8252, 5610},{ 8775, 5586},{ 9255, 5571}, - { 9694, 5556},{10115, 5541},{10530, 5530},{10903, 5522}, - {11242, 5515},{11596, 5501},{11904, 5482},{12205, 5475} - } - }, - { - /*Cb qi=40 INTRA*/ - { - { 8, 3},{ 108, 371},{ 189, 743},{ 265, 1128}, - { 371, 1475},{ 499, 1767},{ 628, 2022},{ 746, 2256}, - { 864, 2467},{ 991, 2647},{ 1124, 2801},{ 1270, 2933}, - { 1412, 3054},{ 1547, 3165},{ 1677, 3277},{ 1804, 3393}, - { 1946, 3483},{ 2078, 3569},{ 2201, 3651},{ 2352, 3711}, - { 2513, 3766},{ 2643, 3826},{ 2775, 3880},{ 3025, 3919} - }, - /*Cb qi=40 INTER*/ - { - { 114, 35},{ 104, 349},{ 96, 667},{ 106, 1040}, - { 121, 1423},{ 138, 1789},{ 158, 2132},{ 184, 2464}, - { 212, 2787},{ 242, 3095},{ 279, 3389},{ 321, 3671}, - { 374, 3941},{ 438, 4199},{ 517, 4446},{ 617, 4673}, - { 740, 4881},{ 891, 5064},{ 1058, 5225},{ 1239, 5372}, - { 1441, 5499},{ 1638, 5610},{ 1840, 5719},{ 2076, 5814} - } - }, - { - /*Cr qi=40 INTRA*/ - { - { 14, 7},{ 114, 389},{ 193, 771},{ 283, 1156}, - { 399, 1488},{ 523, 1768},{ 643, 2018},{ 752, 2245}, - { 865, 2450},{ 984, 2626},{ 1139, 2763},{ 1290, 2887}, - { 1413, 3014},{ 1550, 3128},{ 1711, 3211},{ 1865, 3268}, - { 1981, 3334},{ 2103, 3415},{ 2237, 3486},{ 2365, 3543}, - { 2529, 3610},{ 2666, 3700},{ 2775, 3779},{ 2929, 3803} - }, - /*Cr qi=40 INTER*/ - { - { 89, -8},{ 95, 353},{ 90, 681},{ 107, 1053}, - { 124, 1430},{ 139, 1787},{ 156, 2136},{ 177, 2477}, - { 203, 2803},{ 237, 3112},{ 276, 3406},{ 329, 3683}, - { 395, 3942},{ 475, 4182},{ 567, 4407},{ 665, 4624}, - { 767, 4834},{ 879, 5032},{ 1011, 5213},{ 1169, 5375}, - { 1348, 5525},{ 1547, 5654},{ 1785, 5743},{ 2066, 5787} - } - } - }, - { - { - /*Y' qi=41 INTRA*/ - { - { 98, 71},{ 495, 1272},{ 1040, 2090},{ 1675, 2533}, - { 2302, 2842},{ 2953, 3132},{ 3631, 3381},{ 4309, 3574}, - { 4966, 3726},{ 5593, 3846},{ 6189, 3934},{ 6738, 3972}, - { 7256, 3991},{ 7754, 4036},{ 8250, 4099},{ 8747, 4150}, - { 9207, 4185},{ 9650, 4222},{10057, 4242},{10411, 4237}, - {10771, 4230},{11127, 4244},{11486, 4254},{11933, 4252} - }, - /*Y' qi=41 INTER*/ - { - { 65, -25},{ 125, 1331},{ 260, 2633},{ 457, 3782}, - { 807, 4740},{ 1499, 5397},{ 2562, 5693},{ 3766, 5743}, - { 4859, 5695},{ 5776, 5638},{ 6556, 5590},{ 7243, 5554}, - { 7859, 5529},{ 8417, 5506},{ 8935, 5486},{ 9419, 5473}, - { 9869, 5460},{10296, 5446},{10711, 5436},{11089, 5430}, - {11445, 5421},{11802, 5412},{12129, 5404},{12465, 5393} - } - }, - { - /*Cb qi=41 INTRA*/ - { - { 8, 3},{ 108, 371},{ 189, 743},{ 267, 1126}, - { 374, 1471},{ 504, 1760},{ 635, 2011},{ 758, 2241}, - { 881, 2447},{ 1013, 2621},{ 1147, 2773},{ 1293, 2906}, - { 1441, 3023},{ 1580, 3131},{ 1712, 3243},{ 1844, 3360}, - { 1985, 3451},{ 2114, 3532},{ 2240, 3613},{ 2390, 3680}, - { 2550, 3740},{ 2687, 3800},{ 2825, 3862},{ 3052, 3944} - }, - /*Cb qi=41 INTER*/ - { - { 104, 39},{ 100, 350},{ 95, 667},{ 105, 1040}, - { 121, 1422},{ 137, 1787},{ 159, 2129},{ 185, 2459}, - { 216, 2778},{ 249, 3083},{ 287, 3374},{ 335, 3653}, - { 393, 3920},{ 462, 4175},{ 549, 4414},{ 660, 4636}, - { 791, 4839},{ 952, 5014},{ 1135, 5166},{ 1337, 5297}, - { 1552, 5411},{ 1752, 5530},{ 1972, 5634},{ 2224, 5724} - } - }, - { - /*Cr qi=41 INTRA*/ - { - { 15, 7},{ 115, 389},{ 193, 770},{ 284, 1154}, - { 401, 1484},{ 528, 1761},{ 652, 2005},{ 764, 2228}, - { 882, 2427},{ 1008, 2599},{ 1167, 2734},{ 1320, 2859}, - { 1443, 2990},{ 1580, 3103},{ 1743, 3181},{ 1894, 3241}, - { 2012, 3309},{ 2141, 3385},{ 2272, 3459},{ 2398, 3519}, - { 2566, 3584},{ 2707, 3680},{ 2816, 3762},{ 2991, 3770} - }, - /*Cr qi=41 INTER*/ - { - { 92, -9},{ 98, 354},{ 90, 682},{ 107, 1052}, - { 124, 1429},{ 139, 1786},{ 156, 2132},{ 178, 2471}, - { 207, 2794},{ 241, 3100},{ 285, 3391},{ 345, 3662}, - { 417, 3915},{ 503, 4151},{ 600, 4375},{ 703, 4589}, - { 815, 4791},{ 942, 4981},{ 1088, 5155},{ 1250, 5316}, - { 1432, 5462},{ 1653, 5575},{ 1930, 5639},{ 2250, 5655} - } - } - }, - { - { - /*Y' qi=42 INTRA*/ - { - { 109, 75},{ 534, 1257},{ 1114, 2047},{ 1793, 2456}, - { 2461, 2735},{ 3157, 2994},{ 3879, 3221},{ 4595, 3396}, - { 5282, 3531},{ 5931, 3638},{ 6546, 3714},{ 7105, 3749}, - { 7633, 3766},{ 8147, 3803},{ 8652, 3865},{ 9148, 3915}, - { 9613, 3946},{10075, 3976},{10489, 3997},{10835, 3994}, - {11195, 3985},{11553, 3997},{11909, 4004},{12369, 3990} - }, - /*Y' qi=42 INTER*/ - { - { 69, -23},{ 134, 1332},{ 287, 2611},{ 521, 3730}, - { 970, 4624},{ 1827, 5176},{ 3028, 5382},{ 4262, 5389}, - { 5325, 5338},{ 6214, 5291},{ 6976, 5255},{ 7651, 5228}, - { 8260, 5206},{ 8821, 5190},{ 9343, 5177},{ 9823, 5165}, - {10273, 5152},{10709, 5143},{11121, 5136},{11502, 5129}, - {11857, 5125},{12193, 5115},{12520, 5107},{12802, 5097} - } - }, - { - /*Cb qi=42 INTRA*/ - { - { 9, 3},{ 113, 371},{ 199, 743},{ 279, 1123}, - { 390, 1462},{ 525, 1743},{ 662, 1986},{ 789, 2208}, - { 916, 2406},{ 1057, 2571},{ 1204, 2712},{ 1362, 2835}, - { 1524, 2943},{ 1676, 3040},{ 1815, 3145},{ 1959, 3249}, - { 2117, 3325},{ 2249, 3406},{ 2377, 3488},{ 2537, 3547}, - { 2706, 3597},{ 2854, 3646},{ 2999, 3705},{ 3236, 3759} - }, - /*Cb qi=42 INTER*/ - { - { 114, 44},{ 107, 353},{ 101, 670},{ 111, 1041}, - { 129, 1418},{ 148, 1775},{ 174, 2110},{ 208, 2432}, - { 244, 2746},{ 283, 3046},{ 330, 3330},{ 388, 3602}, - { 460, 3858},{ 546, 4101},{ 655, 4326},{ 793, 4530}, - { 966, 4703},{ 1165, 4851},{ 1388, 4980},{ 1630, 5088}, - { 1869, 5189},{ 2122, 5268},{ 2403, 5328},{ 2667, 5417} - } - }, - { - /*Cr qi=42 INTRA*/ - { - { 15, 7},{ 120, 390},{ 202, 771},{ 298, 1150}, - { 421, 1473},{ 553, 1743},{ 681, 1982},{ 796, 2199}, - { 923, 2388},{ 1062, 2547},{ 1225, 2678},{ 1392, 2792}, - { 1531, 2907},{ 1682, 3007},{ 1856, 3074},{ 2009, 3134}, - { 2138, 3192},{ 2274, 3257},{ 2407, 3333},{ 2536, 3393}, - { 2711, 3455},{ 2875, 3531},{ 3000, 3598},{ 3186, 3599} - }, - /*Cr qi=42 INTER*/ - { - { 87, -4},{ 95, 358},{ 97, 683},{ 113, 1052}, - { 131, 1423},{ 148, 1774},{ 170, 2116},{ 198, 2448}, - { 234, 2762},{ 276, 3062},{ 331, 3343},{ 404, 3603}, - { 494, 3844},{ 598, 4067},{ 715, 4276},{ 842, 4471}, - { 977, 4661},{ 1128, 4840},{ 1311, 4991},{ 1516, 5127}, - { 1759, 5233},{ 2050, 5300},{ 2377, 5323},{ 2710, 5304} - } - } - }, - { - { - /*Y' qi=43 INTRA*/ - { - { 99, 79},{ 557, 1244},{ 1175, 2016},{ 1882, 2408}, - { 2570, 2677},{ 3288, 2926},{ 4030, 3141},{ 4760, 3307}, - { 5458, 3435},{ 6115, 3537},{ 6743, 3608},{ 7312, 3636}, - { 7841, 3652},{ 8357, 3687},{ 8870, 3742},{ 9376, 3788}, - { 9850, 3821},{10315, 3853},{10734, 3873},{11084, 3870}, - {11442, 3862},{11800, 3874},{12160, 3879},{12618, 3876} - }, - /*Y' qi=43 INTER*/ - { - { 69, -22},{ 134, 1331},{ 294, 2601},{ 551, 3703}, - { 1056, 4563},{ 2003, 5061},{ 3276, 5215},{ 4534, 5194}, - { 5599, 5133},{ 6488, 5083},{ 7257, 5044},{ 7938, 5014}, - { 8556, 4992},{ 9124, 4975},{ 9648, 4960},{10138, 4948}, - {10594, 4939},{11039, 4926},{11462, 4919},{11847, 4912}, - {12216, 4904},{12570, 4896},{12883, 4889},{13189, 4879} - } - }, - { - /*Cb qi=43 INTRA*/ - { - { 9, 3},{ 114, 371},{ 202, 740},{ 294, 1110}, - { 417, 1440},{ 558, 1716},{ 700, 1956},{ 833, 2172}, - { 966, 2365},{ 1116, 2524},{ 1269, 2661},{ 1431, 2781}, - { 1599, 2885},{ 1756, 2980},{ 1902, 3082},{ 2051, 3185}, - { 2209, 3261},{ 2337, 3342},{ 2464, 3420},{ 2633, 3475}, - { 2809, 3525},{ 2948, 3579},{ 3094, 3633},{ 3347, 3678} - }, - /*Cb qi=43 INTER*/ - { - { 111, 44},{ 106, 353},{ 102, 670},{ 112, 1040}, - { 128, 1416},{ 148, 1771},{ 176, 2104},{ 211, 2424}, - { 250, 2734},{ 293, 3030},{ 347, 3309},{ 411, 3575}, - { 490, 3828},{ 589, 4064},{ 716, 4278},{ 869, 4472}, - { 1050, 4640},{ 1264, 4781},{ 1512, 4895},{ 1775, 4991}, - { 2042, 5069},{ 2310, 5141},{ 2593, 5207},{ 2912, 5239} - } - }, - { - /*Cr qi=43 INTRA*/ - { - { 15, 7},{ 121, 390},{ 208, 767},{ 315, 1135}, - { 449, 1449},{ 586, 1715},{ 718, 1950},{ 843, 2158}, - { 977, 2342},{ 1120, 2501},{ 1290, 2632},{ 1466, 2739}, - { 1613, 2845},{ 1763, 2945},{ 1937, 3015},{ 2093, 3070}, - { 2225, 3126},{ 2366, 3194},{ 2501, 3267},{ 2634, 3324}, - { 2815, 3385},{ 2964, 3466},{ 3087, 3538},{ 3263, 3555} - }, - /*Cr qi=43 INTER*/ - { - { 84, -4},{ 93, 358},{ 95, 683},{ 113, 1052}, - { 131, 1421},{ 148, 1770},{ 171, 2110},{ 201, 2439}, - { 240, 2750},{ 287, 3046},{ 348, 3322},{ 429, 3576}, - { 527, 3811},{ 641, 4029},{ 767, 4230},{ 904, 4422}, - { 1053, 4603},{ 1225, 4765},{ 1433, 4903},{ 1661, 5030}, - { 1928, 5121},{ 2252, 5160},{ 2604, 5164},{ 2979, 5125} - } - } - }, - { - { - /*Y' qi=44 INTRA*/ - { - { 103, 80},{ 560, 1244},{ 1183, 2009},{ 1891, 2391}, - { 2586, 2649},{ 3324, 2884},{ 4093, 3089},{ 4850, 3243}, - { 5575, 3358},{ 6252, 3452},{ 6886, 3518},{ 7459, 3546}, - { 7993, 3562},{ 8515, 3594},{ 9030, 3645},{ 9534, 3691}, - {10004, 3723},{10469, 3750},{10887, 3765},{11236, 3766}, - {11596, 3762},{11960, 3775},{12317, 3784},{12766, 3789} - }, - /*Y' qi=44 INTER*/ - { - { 77, -24},{ 145, 1332},{ 332, 2580},{ 642, 3649}, - { 1270, 4438},{ 2360, 4860},{ 3685, 4982},{ 4910, 4966}, - { 5929, 4928},{ 6785, 4900},{ 7529, 4880},{ 8198, 4863}, - { 8804, 4850},{ 9361, 4842},{ 9882, 4836},{10371, 4830}, - {10827, 4822},{11262, 4816},{11672, 4811},{12052, 4807}, - {12431, 4806},{12780, 4798},{13095, 4792},{13401, 4791} - } - }, - { - /*Cb qi=44 INTRA*/ - { - { 9, 2},{ 122, 371},{ 214, 741},{ 307, 1109}, - { 433, 1432},{ 576, 1704},{ 718, 1939},{ 855, 2152}, - { 991, 2340},{ 1141, 2497},{ 1298, 2632},{ 1463, 2749}, - { 1636, 2851},{ 1796, 2944},{ 1947, 3041},{ 2101, 3140}, - { 2260, 3219},{ 2392, 3297},{ 2527, 3366},{ 2693, 3424}, - { 2872, 3477},{ 3025, 3525},{ 3175, 3584},{ 3451, 3626} - }, - /*Cb qi=44 INTER*/ - { - { 111, 14},{ 110, 339},{ 109, 671},{ 120, 1040}, - { 139, 1410},{ 162, 1758},{ 197, 2084},{ 243, 2397}, - { 291, 2702},{ 342, 2992},{ 405, 3265},{ 484, 3521}, - { 584, 3760},{ 705, 3983},{ 855, 4185},{ 1048, 4356}, - { 1274, 4500},{ 1531, 4617},{ 1816, 4707},{ 2111, 4783}, - { 2409, 4846},{ 2720, 4901},{ 3044, 4957},{ 3391, 4985} - } - }, - { - /*Cr qi=44 INTRA*/ - { - { 17, 7},{ 128, 392},{ 219, 770},{ 329, 1135}, - { 465, 1442},{ 601, 1703},{ 734, 1935},{ 862, 2142}, - { 998, 2325},{ 1147, 2482},{ 1321, 2606},{ 1496, 2710}, - { 1649, 2813},{ 1809, 2908},{ 1984, 2977},{ 2143, 3032}, - { 2279, 3087},{ 2423, 3152},{ 2559, 3225},{ 2684, 3288}, - { 2866, 3351},{ 3025, 3426},{ 3161, 3492},{ 3372, 3500} - }, - /*Cr qi=44 INTER*/ - { - { 89, 0},{ 101, 352},{ 104, 683},{ 121, 1051}, - { 141, 1414},{ 163, 1757},{ 192, 2092},{ 231, 2415}, - { 278, 2720},{ 336, 3007},{ 412, 3273},{ 510, 3516}, - { 633, 3733},{ 769, 3936},{ 914, 4130},{ 1076, 4307}, - { 1256, 4472},{ 1469, 4617},{ 1723, 4732},{ 2012, 4822}, - { 2347, 4871},{ 2716, 4875},{ 3082, 4866},{ 3422, 4826} - } - } - }, - { - { - /*Y' qi=45 INTRA*/ - { - { 119, 78},{ 610, 1226},{ 1271, 1965},{ 2026, 2319}, - { 2768, 2550},{ 3556, 2757},{ 4369, 2938},{ 5157, 3076}, - { 5901, 3182},{ 6598, 3268},{ 7253, 3326},{ 7844, 3343}, - { 8392, 3356},{ 8922, 3386},{ 9453, 3433},{ 9973, 3474}, - {10457, 3503},{10929, 3530},{11351, 3543},{11709, 3541}, - {12068, 3537},{12434, 3547},{12805, 3555},{13268, 3563} - }, - /*Y' qi=45 INTER*/ - { - { 77, -20},{ 146, 1330},{ 342, 2566},{ 699, 3604}, - { 1439, 4332},{ 2669, 4672},{ 4075, 4727},{ 5318, 4679}, - { 6345, 4630},{ 7209, 4595},{ 7963, 4570},{ 8644, 4551}, - { 9262, 4535},{ 9831, 4525},{10370, 4515},{10872, 4506}, - {11334, 4500},{11783, 4492},{12219, 4489},{12617, 4483}, - {12995, 4477},{13350, 4472},{13674, 4466},{13968, 4468} - } - }, - { - /*Cb qi=45 INTRA*/ - { - { 9, 2},{ 122, 370},{ 219, 735},{ 324, 1096}, - { 465, 1414},{ 619, 1679},{ 771, 1905},{ 920, 2103}, - { 1070, 2276},{ 1236, 2419},{ 1410, 2539},{ 1595, 2644}, - { 1784, 2736},{ 1949, 2831},{ 2104, 2931},{ 2275, 3021}, - { 2443, 3092},{ 2586, 3166},{ 2735, 3234},{ 2904, 3288}, - { 3093, 3338},{ 3262, 3382},{ 3419, 3427},{ 3708, 3456} - }, - /*Cb qi=45 INTER*/ - { - { 103, 0},{ 109, 339},{ 109, 670},{ 119, 1039}, - { 137, 1408},{ 162, 1754},{ 199, 2076},{ 248, 2386}, - { 301, 2684},{ 360, 2967},{ 433, 3234},{ 525, 3481}, - { 640, 3713},{ 780, 3924},{ 956, 4110},{ 1176, 4266}, - { 1438, 4390},{ 1736, 4481},{ 2057, 4553},{ 2385, 4613}, - { 2718, 4656},{ 3056, 4698},{ 3416, 4733},{ 3799, 4755} - } - }, - { - /*Cr qi=45 INTRA*/ - { - { 16, 7},{ 128, 391},{ 225, 763},{ 350, 1120}, - { 500, 1420},{ 649, 1673},{ 792, 1893},{ 929, 2089}, - { 1084, 2257},{ 1250, 2401},{ 1440, 2518},{ 1633, 2614}, - { 1799, 2708},{ 1968, 2798},{ 2151, 2863},{ 2314, 2914}, - { 2453, 2968},{ 2611, 3025},{ 2759, 3095},{ 2887, 3160}, - { 3082, 3210},{ 3259, 3278},{ 3403, 3342},{ 3593, 3354} - }, - /*Cr qi=45 INTER*/ - { - { 92, 0},{ 101, 352},{ 103, 682},{ 120, 1049}, - { 140, 1412},{ 163, 1752},{ 193, 2083},{ 234, 2402}, - { 287, 2702},{ 353, 2983},{ 442, 3240},{ 557, 3471}, - { 694, 3680},{ 846, 3873},{ 1014, 4056},{ 1200, 4224}, - { 1414, 4369},{ 1664, 4495},{ 1946, 4595},{ 2278, 4654}, - { 2654, 4673},{ 3047, 4658},{ 3438, 4627},{ 3825, 4585} - } - } - }, - { - { - /*Y' qi=46 INTRA*/ - { - { 119, 78},{ 610, 1227},{ 1277, 1960},{ 2043, 2309}, - { 2805, 2529},{ 3618, 2719},{ 4452, 2887},{ 5257, 3016}, - { 6017, 3115},{ 6727, 3195},{ 7392, 3248},{ 7984, 3267}, - { 8528, 3281},{ 9059, 3310},{ 9593, 3354},{10119, 3395}, - {10599, 3425},{11064, 3450},{11493, 3464},{11850, 3466}, - {12207, 3462},{12578, 3471},{12948, 3480},{13407, 3487} - }, - /*Y' qi=46 INTER*/ - { - { 74, -14},{ 149, 1326},{ 382, 2538},{ 807, 3541}, - { 1670, 4211},{ 3000, 4499},{ 4416, 4533},{ 5628, 4490}, - { 6628, 4453},{ 7479, 4425},{ 8228, 4406},{ 8902, 4393}, - { 9521, 4380},{10090, 4371},{10623, 4364},{11124, 4356}, - {11586, 4351},{12043, 4344},{12476, 4341},{12863, 4340}, - {13244, 4337},{13610, 4329},{13936, 4324},{14246, 4329} - } - }, - { - /*Cb qi=46 INTRA*/ - { - { 11, 2},{ 132, 371},{ 234, 737},{ 340, 1094}, - { 481, 1405},{ 637, 1667},{ 791, 1891},{ 944, 2084}, - { 1099, 2253},{ 1268, 2392},{ 1444, 2507},{ 1633, 2610}, - { 1825, 2700},{ 1990, 2794},{ 2147, 2895},{ 2321, 2984}, - { 2493, 3053},{ 2640, 3126},{ 2787, 3198},{ 2954, 3253}, - { 3146, 3297},{ 3313, 3344},{ 3473, 3393},{ 3757, 3434} - }, - /*Cb qi=46 INTER*/ - { - { 97, 0},{ 109, 339},{ 108, 669},{ 120, 1035}, - { 142, 1398},{ 173, 1737},{ 221, 2052},{ 281, 2353}, - { 345, 2646},{ 415, 2924},{ 504, 3183},{ 616, 3421}, - { 749, 3643},{ 914, 3842},{ 1123, 4012},{ 1379, 4150}, - { 1685, 4250},{ 2014, 4327},{ 2366, 4382},{ 2731, 4426}, - { 3083, 4470},{ 3445, 4490},{ 3805, 4511},{ 4146, 4539} - } - }, - { - /*Cr qi=46 INTRA*/ - { - { 19, 7},{ 137, 393},{ 237, 765},{ 364, 1116}, - { 516, 1411},{ 665, 1662},{ 809, 1880},{ 951, 2072}, - { 1109, 2236},{ 1278, 2378},{ 1474, 2491},{ 1669, 2584}, - { 1835, 2678},{ 2014, 2766},{ 2203, 2828},{ 2366, 2880}, - { 2506, 2933},{ 2661, 2988},{ 2810, 3053},{ 2941, 3116}, - { 3131, 3175},{ 3310, 3243},{ 3461, 3303},{ 3656, 3321} - }, - /*Cr qi=46 INTER*/ - { - { 91, 1},{ 103, 351},{ 104, 681},{ 121, 1046}, - { 144, 1401},{ 173, 1736},{ 213, 2060},{ 265, 2373}, - { 330, 2666},{ 410, 2938},{ 517, 3185},{ 655, 3404}, - { 815, 3601},{ 989, 3784},{ 1183, 3951},{ 1400, 4104}, - { 1649, 4241},{ 1933, 4352},{ 2261, 4427},{ 2646, 4458}, - { 3057, 4446},{ 3453, 4418},{ 3820, 4385},{ 4171, 4352} - } - } - }, - { - { - /*Y' qi=47 INTRA*/ - { - { 117, 83},{ 670, 1205},{ 1408, 1904},{ 2239, 2219}, - { 3049, 2414},{ 3905, 2584},{ 4775, 2734},{ 5610, 2852}, - { 6393, 2944},{ 7121, 3017},{ 7804, 3066},{ 8407, 3081}, - { 8957, 3093},{ 9498, 3119},{10043, 3160},{10582, 3199}, - {11083, 3226},{11561, 3250},{11993, 3263},{12352, 3264}, - {12711, 3259},{13092, 3266},{13463, 3271},{13918, 3275} - }, - /*Y' qi=47 INTER*/ - { - { 74, -11},{ 148, 1325},{ 404, 2518},{ 910, 3478}, - { 1916, 4080},{ 3369, 4298},{ 4823, 4292},{ 6035, 4238}, - { 7037, 4197},{ 7894, 4168},{ 8650, 4146},{ 9337, 4129}, - { 9968, 4116},{10549, 4105},{11096, 4096},{11605, 4089}, - {12081, 4083},{12547, 4076},{12990, 4070},{13399, 4070}, - {13776, 4065},{14133, 4059},{14486, 4057},{14842, 4053} - } - }, - { - /*Cb qi=47 INTRA*/ - { - { 11, 2},{ 133, 370},{ 242, 731},{ 367, 1077}, - { 524, 1378},{ 692, 1630},{ 860, 1844},{ 1028, 2024}, - { 1203, 2178},{ 1393, 2305},{ 1582, 2413},{ 1787, 2507}, - { 1992, 2590},{ 2175, 2676},{ 2351, 2767},{ 2534, 2851}, - { 2707, 2923},{ 2862, 2994},{ 3021, 3060},{ 3193, 3111}, - { 3396, 3147},{ 3573, 3184},{ 3752, 3220},{ 4038, 3255} - }, - /*Cb qi=47 INTER*/ - { - { 101, 0},{ 107, 339},{ 108, 667},{ 120, 1033}, - { 142, 1394},{ 175, 1729},{ 227, 2040},{ 295, 2335}, - { 369, 2619},{ 452, 2888},{ 556, 3138},{ 686, 3368}, - { 850, 3574},{ 1050, 3758},{ 1299, 3910},{ 1605, 4024}, - { 1950, 4104},{ 2317, 4163},{ 2689, 4210},{ 3077, 4239}, - { 3466, 4258},{ 3840, 4278},{ 4205, 4298},{ 4515, 4340} - } - }, - { - /*Cr qi=47 INTRA*/ - { - { 19, 7},{ 138, 392},{ 248, 758},{ 396, 1094}, - { 563, 1378},{ 723, 1621},{ 881, 1829},{ 1037, 2011}, - { 1214, 2165},{ 1410, 2290},{ 1623, 2393},{ 1834, 2480}, - { 2016, 2564},{ 2203, 2647},{ 2405, 2707},{ 2569, 2757}, - { 2709, 2810},{ 2871, 2860},{ 3027, 2924},{ 3178, 2980}, - { 3375, 3034},{ 3563, 3097},{ 3724, 3151},{ 3952, 3153} - }, - /*Cr qi=47 INTER*/ - { - { 91, 1},{ 100, 351},{ 102, 681},{ 120, 1043}, - { 144, 1397},{ 175, 1729},{ 219, 2049},{ 277, 2356}, - { 353, 2640},{ 451, 2902},{ 579, 3136},{ 739, 3342}, - { 926, 3525},{ 1125, 3698},{ 1343, 3859},{ 1595, 3998}, - { 1881, 4113},{ 2208, 4205},{ 2589, 4253},{ 3014, 4250}, - { 3444, 4220},{ 3838, 4183},{ 4196, 4147},{ 4521, 4116} - } - } - }, - { - { - /*Y' qi=48 INTRA*/ - { - { 107, 87},{ 681, 1200},{ 1456, 1883},{ 2306, 2193}, - { 3122, 2386},{ 3984, 2548},{ 4862, 2693},{ 5704, 2808}, - { 6495, 2899},{ 7232, 2970},{ 7915, 3018},{ 8524, 3034}, - { 9085, 3043},{ 9635, 3068},{10192, 3108},{10735, 3145}, - {11237, 3171},{11719, 3194},{12153, 3207},{12516, 3206}, - {12888, 3202},{13266, 3210},{13637, 3218},{14101, 3219} - }, - /*Y' qi=48 INTER*/ - { - { 83, -18},{ 147, 1328},{ 398, 2519},{ 923, 3468}, - { 1979, 4047},{ 3472, 4246},{ 4936, 4232},{ 6148, 4178}, - { 7150, 4139},{ 8007, 4111},{ 8765, 4091},{ 9458, 4076}, - {10090, 4063},{10676, 4054},{11226, 4045},{11742, 4038}, - {12223, 4033},{12686, 4029},{13127, 4022},{13527, 4015}, - {13915, 4012},{14277, 4007},{14619, 4004},{14966, 4001} - } - }, - { - /*Cb qi=48 INTRA*/ - { - { 11, 2},{ 134, 369},{ 245, 730},{ 373, 1075}, - { 531, 1374},{ 698, 1625},{ 865, 1839},{ 1033, 2019}, - { 1207, 2173},{ 1397, 2300},{ 1588, 2408},{ 1795, 2501}, - { 2003, 2581},{ 2187, 2666},{ 2362, 2757},{ 2548, 2841}, - { 2719, 2912},{ 2876, 2983},{ 3034, 3047},{ 3209, 3097}, - { 3409, 3137},{ 3589, 3178},{ 3762, 3216},{ 4004, 3252} - }, - /*Cb qi=48 INTER*/ - { - { 113, 26},{ 112, 344},{ 111, 668},{ 120, 1032}, - { 141, 1392},{ 173, 1727},{ 224, 2036},{ 290, 2330}, - { 363, 2612},{ 447, 2880},{ 551, 3130},{ 685, 3358}, - { 852, 3563},{ 1061, 3742},{ 1332, 3884},{ 1654, 3993}, - { 2011, 4068},{ 2394, 4120},{ 2782, 4160},{ 3172, 4186}, - { 3557, 4209},{ 3932, 4228},{ 4306, 4237},{ 4675, 4236} - } - }, - { - /*Cr qi=48 INTRA*/ - { - { 18, 7},{ 139, 389},{ 252, 755},{ 404, 1090}, - { 573, 1372},{ 732, 1615},{ 889, 1823},{ 1045, 2005}, - { 1222, 2159},{ 1417, 2285},{ 1631, 2387},{ 1843, 2474}, - { 2027, 2558},{ 2212, 2639},{ 2413, 2697},{ 2578, 2746}, - { 2720, 2798},{ 2887, 2852},{ 3040, 2913},{ 3181, 2970}, - { 3381, 3024},{ 3581, 3081},{ 3743, 3130},{ 3948, 3133} - }, - /*Cr qi=48 INTER*/ - { - { 89, 0},{ 106, 352},{ 105, 682},{ 120, 1044}, - { 144, 1395},{ 174, 1724},{ 215, 2044},{ 270, 2350}, - { 343, 2635},{ 441, 2895},{ 571, 3129},{ 735, 3334}, - { 926, 3518},{ 1139, 3684},{ 1371, 3836},{ 1628, 3977}, - { 1933, 4089},{ 2279, 4164},{ 2672, 4204},{ 3105, 4205}, - { 3533, 4176},{ 3931, 4135},{ 4290, 4089},{ 4624, 4057} - } - } - }, - { - { - /*Y' qi=49 INTRA*/ - { - { 120, 85},{ 706, 1194},{ 1485, 1875},{ 2348, 2187}, - { 3190, 2372},{ 4076, 2521},{ 4967, 2658},{ 5819, 2771}, - { 6611, 2861},{ 7345, 2936},{ 8026, 2990},{ 8626, 3013}, - { 9182, 3030},{ 9723, 3059},{10266, 3100},{10802, 3143}, - {11293, 3179},{11768, 3206},{12201, 3221},{12556, 3225}, - {12914, 3226},{13281, 3237},{13639, 3247},{14089, 3257} - }, - /*Y' qi=49 INTER*/ - { - { 72, -11},{ 155, 1320},{ 458, 2485},{ 1090, 3386}, - { 2284, 3907},{ 3835, 4075},{ 5272, 4064},{ 6449, 4026}, - { 7426, 4003},{ 8267, 3987},{ 9017, 3976},{ 9698, 3967}, - {10328, 3962},{10913, 3959},{11452, 3954},{11961, 3950}, - {12442, 3947},{12904, 3946},{13347, 3945},{13749, 3943}, - {14123, 3941},{14490, 3941},{14826, 3939},{15153, 3937} - } - }, - { - /*Cb qi=49 INTRA*/ - { - { 11, 2},{ 145, 369},{ 262, 729},{ 393, 1070}, - { 557, 1363},{ 731, 1607},{ 907, 1811},{ 1085, 1983}, - { 1268, 2130},{ 1465, 2251},{ 1658, 2359},{ 1868, 2454}, - { 2079, 2534},{ 2264, 2621},{ 2440, 2717},{ 2625, 2802}, - { 2792, 2878},{ 2945, 2954},{ 3106, 3021},{ 3277, 3075}, - { 3466, 3119},{ 3638, 3170},{ 3824, 3213},{ 4100, 3243} - }, - /*Cb qi=49 INTER*/ - { - { 98, -6},{ 113, 343},{ 110, 669},{ 122, 1029}, - { 149, 1380},{ 192, 1706},{ 258, 2007},{ 340, 2293}, - { 426, 2569},{ 525, 2831},{ 653, 3071},{ 814, 3287}, - { 1013, 3478},{ 1262, 3637},{ 1575, 3761},{ 1936, 3851}, - { 2328, 3910},{ 2741, 3949},{ 3163, 3970},{ 3559, 3994}, - { 3936, 4025},{ 4300, 4050},{ 4655, 4060},{ 4962, 4062} - } - }, - { - /*Cr qi=49 INTRA*/ - { - { 19, 7},{ 151, 389},{ 270, 753},{ 427, 1084}, - { 602, 1360},{ 767, 1595},{ 933, 1794},{ 1098, 1968}, - { 1285, 2115},{ 1489, 2237},{ 1699, 2342},{ 1912, 2435}, - { 2101, 2519},{ 2288, 2601},{ 2486, 2663},{ 2651, 2715}, - { 2799, 2769},{ 2958, 2825},{ 3106, 2890},{ 3257, 2948}, - { 3452, 3007},{ 3634, 3075},{ 3786, 3136},{ 3959, 3164} - }, - /*Cr qi=49 INTER*/ - { - { 85, 1},{ 103, 352},{ 104, 681},{ 121, 1039}, - { 152, 1382},{ 195, 1702},{ 248, 2015},{ 316, 2316}, - { 403, 2595},{ 520, 2847},{ 676, 3068},{ 870, 3258}, - { 1091, 3429},{ 1329, 3585},{ 1597, 3725},{ 1894, 3849}, - { 2242, 3940},{ 2656, 3984},{ 3098, 3992},{ 3531, 3981}, - { 3936, 3950},{ 4304, 3915},{ 4646, 3879},{ 4915, 3861} - } - } - }, - { - { - /*Y' qi=50 INTRA*/ - { - { 122, 89},{ 798, 1170},{ 1682, 1812},{ 2613, 2096}, - { 3501, 2260},{ 4430, 2388},{ 5352, 2510},{ 6228, 2613}, - { 7043, 2698},{ 7793, 2770},{ 8486, 2823},{ 9092, 2846}, - { 9652, 2865},{10210, 2895},{10773, 2936},{11315, 2979}, - {11817, 3014},{12297, 3041},{12734, 3057},{13097, 3064}, - {13443, 3067},{13813, 3078},{14190, 3088},{14646, 3103} - }, - /*Y' qi=50 INTER*/ - { - { 73, -11},{ 154, 1318},{ 501, 2457},{ 1281, 3291}, - { 2685, 3719},{ 4356, 3810},{ 5811, 3769},{ 6988, 3726}, - { 7976, 3700},{ 8835, 3682},{ 9606, 3669},{10307, 3659}, - {10953, 3652},{11556, 3645},{12115, 3643},{12641, 3640}, - {13138, 3636},{13613, 3634},{14068, 3629},{14488, 3627}, - {14876, 3625},{15237, 3621},{15585, 3623},{15922, 3629} - } - }, - { - /*Cb qi=50 INTRA*/ - { - { 11, 2},{ 148, 368},{ 278, 724},{ 431, 1052}, - { 613, 1334},{ 806, 1567},{ 1004, 1756},{ 1203, 1915}, - { 1405, 2051},{ 1621, 2163},{ 1833, 2262},{ 2059, 2347}, - { 2280, 2424},{ 2476, 2512},{ 2670, 2598},{ 2864, 2679}, - { 3037, 2754},{ 3201, 2826},{ 3376, 2887},{ 3562, 2936}, - { 3756, 2976},{ 3932, 3022},{ 4117, 3065},{ 4385, 3094} - }, - /*Cb qi=50 INTER*/ - { - { 92, -3},{ 112, 343},{ 109, 669},{ 121, 1027}, - { 149, 1375},{ 196, 1697},{ 270, 1992},{ 366, 2267}, - { 471, 2532},{ 594, 2782},{ 747, 3011},{ 942, 3212}, - { 1189, 3384},{ 1497, 3521},{ 1875, 3613},{ 2297, 3673}, - { 2739, 3710},{ 3195, 3725},{ 3644, 3737},{ 4057, 3751}, - { 4445, 3763},{ 4841, 3769},{ 5211, 3779},{ 5568, 3769} - } - }, - { - /*Cr qi=50 INTRA*/ - { - { 19, 7},{ 155, 388},{ 290, 744},{ 474, 1060}, - { 666, 1324},{ 847, 1549},{ 1033, 1737},{ 1219, 1898}, - { 1428, 2034},{ 1653, 2147},{ 1885, 2245},{ 2115, 2329}, - { 2316, 2410},{ 2517, 2486},{ 2730, 2539},{ 2901, 2586}, - { 3042, 2638},{ 3199, 2693},{ 3366, 2755},{ 3534, 2805}, - { 3738, 2858},{ 3934, 2916},{ 4079, 2975},{ 4257, 2992} - }, - /*Cr qi=50 INTER*/ - { - { 87, 1},{ 102, 353},{ 103, 680},{ 121, 1036}, - { 153, 1377},{ 199, 1694},{ 260, 1999},{ 339, 2291}, - { 446, 2559},{ 590, 2797},{ 780, 3003},{ 1010, 3176}, - { 1267, 3331},{ 1547, 3474},{ 1874, 3594},{ 2245, 3688}, - { 2666, 3742},{ 3130, 3758},{ 3594, 3748},{ 4028, 3711}, - { 4415, 3674},{ 4771, 3641},{ 5122, 3605},{ 5482, 3569} - } - } - }, - { - { - /*Y' qi=51 INTRA*/ - { - { 115, 93},{ 819, 1164},{ 1739, 1806},{ 2695, 2101}, - { 3612, 2257},{ 4552, 2374},{ 5479, 2490},{ 6352, 2593}, - { 7158, 2683},{ 7898, 2761},{ 8580, 2823},{ 9177, 2854}, - { 9728, 2880},{10268, 2917},{10816, 2966},{11350, 3016}, - {11834, 3058},{12311, 3089},{12741, 3109},{13092, 3119}, - {13434, 3126},{13791, 3142},{14156, 3155},{14590, 3171} - }, - /*Y' qi=51 INTER*/ - { - { 58, 0},{ 171, 1307},{ 610, 2407},{ 1563, 3175}, - { 3116, 3545},{ 4789, 3624},{ 6185, 3602},{ 7320, 3583}, - { 8282, 3574},{ 9124, 3569},{ 9878, 3567},{10569, 3565}, - {11207, 3563},{11801, 3564},{12359, 3566},{12884, 3567}, - {13373, 3568},{13841, 3567},{14289, 3566},{14699, 3568}, - {15086, 3568},{15446, 3566},{15788, 3564},{16103, 3568} - } - }, - { - /*Cb qi=51 INTRA*/ - { - { 14, 3},{ 161, 369},{ 297, 722},{ 454, 1047}, - { 639, 1325},{ 833, 1554},{ 1033, 1742},{ 1236, 1897}, - { 1440, 2032},{ 1653, 2148},{ 1860, 2253},{ 2077, 2347}, - { 2288, 2432},{ 2476, 2525},{ 2661, 2621},{ 2841, 2714}, - { 3010, 2797},{ 3170, 2876},{ 3333, 2945},{ 3510, 3000}, - { 3696, 3054},{ 3865, 3114},{ 4046, 3164},{ 4317, 3200} - }, - /*Cb qi=51 INTER*/ - { - { 88, -11},{ 109, 341},{ 109, 668},{ 126, 1019}, - { 168, 1358},{ 233, 1670},{ 329, 1955},{ 451, 2219}, - { 584, 2472},{ 736, 2711},{ 931, 2923},{ 1179, 3104}, - { 1480, 3254},{ 1846, 3368},{ 2265, 3448},{ 2714, 3501}, - { 3180, 3524},{ 3638, 3529},{ 4074, 3543},{ 4485, 3560}, - { 4868, 3571},{ 5238, 3581},{ 5597, 3594},{ 5953, 3591} - } - }, - { - /*Cr qi=51 INTRA*/ - { - { 24, 7},{ 168, 388},{ 309, 742},{ 496, 1054}, - { 688, 1316},{ 873, 1538},{ 1063, 1723},{ 1252, 1882}, - { 1460, 2018},{ 1682, 2134},{ 1907, 2238},{ 2125, 2332}, - { 2317, 2422},{ 2507, 2510},{ 2705, 2575},{ 2869, 2630}, - { 3015, 2684},{ 3178, 2744},{ 3329, 2815},{ 3477, 2878}, - { 3667, 2945},{ 3848, 3016},{ 3997, 3082},{ 4174, 3121} - }, - /*Cr qi=51 INTER*/ - { - { 83, -2},{ 102, 351},{ 102, 680},{ 126, 1029}, - { 172, 1359},{ 238, 1665},{ 321, 1962},{ 422, 2246}, - { 552, 2505},{ 733, 2728},{ 970, 2912},{ 1247, 3069}, - { 1552, 3209},{ 1876, 3338},{ 2251, 3440},{ 2692, 3502}, - { 3161, 3529},{ 3637, 3525},{ 4084, 3509},{ 4487, 3479}, - { 4850, 3444},{ 5181, 3419},{ 5507, 3406},{ 5786, 3398} - } - } - }, - { - { - /*Y' qi=52 INTRA*/ - { - { 117, 93},{ 814, 1168},{ 1729, 1822},{ 2706, 2119}, - { 3655, 2262},{ 4604, 2374},{ 5528, 2490},{ 6394, 2596}, - { 7189, 2691},{ 7921, 2777},{ 8596, 2846},{ 9184, 2885}, - { 9728, 2918},{10260, 2961},{10796, 3014},{11316, 3069}, - {11793, 3115},{12267, 3150},{12692, 3172},{13037, 3185}, - {13367, 3196},{13717, 3214},{14087, 3227},{14521, 3249} - }, - /*Y' qi=52 INTER*/ - { - { 52, 0},{ 169, 1308},{ 668, 2382},{ 1735, 3112}, - { 3384, 3451},{ 5077, 3519},{ 6461, 3506},{ 7587, 3496}, - { 8545, 3494},{ 9384, 3494},{10142, 3498},{10838, 3501}, - {11475, 3503},{12078, 3508},{12640, 3511},{13162, 3513}, - {13654, 3517},{14130, 3521},{14576, 3522},{14980, 3523}, - {15369, 3523},{15737, 3522},{16071, 3521},{16382, 3516} - } - }, - { - /*Cb qi=52 INTRA*/ - { - { 14, 3},{ 163, 369},{ 299, 722},{ 457, 1044}, - { 645, 1319},{ 843, 1545},{ 1050, 1728},{ 1261, 1879}, - { 1468, 2013},{ 1678, 2132},{ 1883, 2240},{ 2093, 2338}, - { 2301, 2428},{ 2488, 2523},{ 2667, 2619},{ 2843, 2718}, - { 3010, 2805},{ 3163, 2887},{ 3323, 2963},{ 3490, 3028}, - { 3665, 3087},{ 3841, 3145},{ 4011, 3197},{ 4289, 3230} - }, - /*Cb qi=52 INTER*/ - { - { 98, -7},{ 109, 342},{ 109, 668},{ 126, 1018}, - { 170, 1355},{ 242, 1663},{ 352, 1941},{ 490, 2195}, - { 642, 2439},{ 823, 2666},{ 1052, 2868},{ 1333, 3039}, - { 1670, 3178},{ 2074, 3280},{ 2524, 3348},{ 2996, 3390}, - { 3469, 3410},{ 3923, 3420},{ 4355, 3434},{ 4771, 3451}, - { 5166, 3468},{ 5532, 3483},{ 5885, 3499},{ 6263, 3501} - } - }, - { - /*Cr qi=52 INTRA*/ - { - { 25, 7},{ 170, 388},{ 312, 741},{ 500, 1051}, - { 694, 1310},{ 883, 1529},{ 1082, 1709},{ 1280, 1864}, - { 1491, 1998},{ 1710, 2117},{ 1932, 2225},{ 2143, 2324}, - { 2328, 2418},{ 2516, 2506},{ 2708, 2578},{ 2870, 2637}, - { 3017, 2693},{ 3170, 2758},{ 3312, 2835},{ 3455, 2901}, - { 3644, 2972},{ 3827, 3049},{ 3968, 3121},{ 4115, 3166} - }, - /*Cr qi=52 INTER*/ - { - { 86, -2},{ 101, 352},{ 100, 680},{ 126, 1028}, - { 175, 1356},{ 247, 1657},{ 341, 1948},{ 458, 2224}, - { 615, 2471},{ 828, 2681},{ 1091, 2857},{ 1395, 3008}, - { 1732, 3140},{ 2095, 3257},{ 2502, 3348},{ 2968, 3402}, - { 3457, 3420},{ 3926, 3413},{ 4360, 3388},{ 4759, 3357}, - { 5128, 3329},{ 5449, 3306},{ 5741, 3295},{ 6071, 3296} - } - } - }, - { - { - /*Y' qi=53 INTRA*/ - { - { 138, 93},{ 850, 1161},{ 1773, 1810},{ 2763, 2103}, - { 3722, 2245},{ 4675, 2360},{ 5600, 2483},{ 6464, 2597}, - { 7255, 2700},{ 7982, 2792},{ 8652, 2867},{ 9237, 2913}, - { 9775, 2950},{10302, 2998},{10834, 3058},{11347, 3121}, - {11826, 3169},{12299, 3207},{12713, 3235},{13054, 3250}, - {13387, 3265},{13744, 3286},{14110, 3302},{14515, 3323} - }, - /*Y' qi=53 INTER*/ - { - { 52, 2},{ 169, 1308},{ 680, 2377},{ 1763, 3103}, - { 3410, 3450},{ 5094, 3531},{ 6469, 3526},{ 7590, 3525}, - { 8547, 3530},{ 9385, 3534},{10139, 3540},{10835, 3548}, - {11479, 3553},{12075, 3559},{12634, 3565},{13159, 3570}, - {13650, 3573},{14124, 3576},{14575, 3580},{14993, 3583}, - {15375, 3584},{15744, 3584},{16091, 3583},{16421, 3586} - } - }, - { - /*Cb qi=53 INTRA*/ - { - { 14, 3},{ 167, 367},{ 317, 717},{ 492, 1033}, - { 687, 1306},{ 887, 1531},{ 1095, 1715},{ 1309, 1866}, - { 1517, 2000},{ 1729, 2119},{ 1932, 2227},{ 2146, 2325}, - { 2358, 2414},{ 2544, 2511},{ 2724, 2611},{ 2902, 2711}, - { 3070, 2800},{ 3227, 2878},{ 3381, 2954},{ 3548, 3021}, - { 3724, 3077},{ 3888, 3140},{ 4065, 3196},{ 4359, 3225} - }, - /*Cb qi=53 INTER*/ - { - { 93, -8},{ 110, 342},{ 108, 668},{ 125, 1018}, - { 170, 1355},{ 242, 1663},{ 353, 1939},{ 494, 2192}, - { 651, 2433},{ 838, 2658},{ 1076, 2856},{ 1368, 3022}, - { 1716, 3158},{ 2123, 3260},{ 2575, 3330},{ 3042, 3373}, - { 3507, 3396},{ 3962, 3413},{ 4394, 3430},{ 4797, 3452}, - { 5169, 3476},{ 5547, 3496},{ 5914, 3510},{ 6235, 3525} - } - }, - { - /*Cr qi=53 INTRA*/ - { - { 25, 7},{ 175, 386},{ 335, 734},{ 541, 1037}, - { 737, 1296},{ 926, 1516},{ 1125, 1696},{ 1324, 1851}, - { 1540, 1984},{ 1763, 2102},{ 1989, 2210},{ 2202, 2310}, - { 2386, 2404},{ 2572, 2495},{ 2768, 2569},{ 2929, 2627}, - { 3071, 2684},{ 3231, 2749},{ 3374, 2825},{ 3514, 2894}, - { 3703, 2963},{ 3882, 3040},{ 4024, 3111},{ 4190, 3150} - }, - /*Cr qi=53 INTER*/ - { - { 87, -1},{ 99, 352},{ 100, 680},{ 125, 1027}, - { 175, 1355},{ 249, 1657},{ 343, 1946},{ 462, 2220}, - { 624, 2465},{ 844, 2671},{ 1122, 2841},{ 1435, 2989}, - { 1768, 3125},{ 2134, 3243},{ 2545, 3334},{ 3002, 3393}, - { 3490, 3412},{ 3965, 3405},{ 4401, 3384},{ 4797, 3359}, - { 5156, 3328},{ 5482, 3297},{ 5800, 3292},{ 6135, 3293} - } - } - }, - { - { - /*Y' qi=54 INTRA*/ - { - { 184, 94},{ 902, 1151},{ 1876, 1776},{ 2881, 2057}, - { 3832, 2200},{ 4785, 2315},{ 5709, 2442},{ 6570, 2562}, - { 7362, 2672},{ 8092, 2771},{ 8760, 2852},{ 9337, 2901}, - { 9874, 2943},{10402, 2995},{10928, 3059},{11443, 3126}, - {11926, 3178},{12396, 3220},{12805, 3251},{13139, 3266}, - {13466, 3280},{13822, 3304},{14184, 3322},{14585, 3342} - }, - /*Y' qi=54 INTER*/ - { - { 60, 5},{ 169, 1308},{ 683, 2375},{ 1791, 3090}, - { 3478, 3412},{ 5184, 3470},{ 6568, 3455},{ 7697, 3446}, - { 8659, 3446},{ 9503, 3447},{10266, 3450},{10971, 3454}, - {11619, 3458},{12223, 3462},{12789, 3467},{13315, 3471}, - {13811, 3475},{14291, 3479},{14743, 3479},{15148, 3481}, - {15535, 3483},{15913, 3481},{16252, 3479},{16569, 3472} - } - }, - { - /*Cb qi=54 INTRA*/ - { - { 13, 2},{ 165, 367},{ 318, 715},{ 498, 1030}, - { 698, 1301},{ 906, 1523},{ 1121, 1703},{ 1336, 1853}, - { 1549, 1984},{ 1765, 2100},{ 1974, 2207},{ 2192, 2306}, - { 2402, 2396},{ 2587, 2493},{ 2773, 2591},{ 2953, 2691}, - { 3119, 2778},{ 3277, 2858},{ 3430, 2940},{ 3603, 3004}, - { 3788, 3059},{ 3950, 3121},{ 4128, 3173},{ 4398, 3215} - }, - /*Cb qi=54 INTER*/ - { - { 100, -3},{ 109, 343},{ 107, 668},{ 125, 1018}, - { 169, 1354},{ 241, 1662},{ 353, 1938},{ 496, 2190}, - { 655, 2431},{ 843, 2655},{ 1082, 2851},{ 1381, 3015}, - { 1739, 3146},{ 2154, 3243},{ 2610, 3310},{ 3094, 3344}, - { 3581, 3358},{ 4034, 3371},{ 4457, 3384},{ 4867, 3399}, - { 5255, 3413},{ 5630, 3425},{ 6003, 3440},{ 6346, 3440} - } - }, - { - /*Cr qi=54 INTRA*/ - { - { 23, 7},{ 174, 386},{ 338, 732},{ 549, 1034}, - { 751, 1289},{ 947, 1506},{ 1150, 1685},{ 1353, 1837}, - { 1572, 1969},{ 1800, 2087},{ 2031, 2192},{ 2248, 2291}, - { 2434, 2387},{ 2622, 2477},{ 2815, 2549},{ 2976, 2607}, - { 3126, 2663},{ 3286, 2727},{ 3427, 2807},{ 3569, 2877}, - { 3761, 2941},{ 3942, 3016},{ 4084, 3093},{ 4226, 3131} - }, - /*Cr qi=54 INTER*/ - { - { 88, -2},{ 99, 351},{ 100, 680},{ 125, 1027}, - { 175, 1354},{ 248, 1656},{ 343, 1945},{ 463, 2219}, - { 626, 2463},{ 850, 2668},{ 1128, 2837},{ 1445, 2983}, - { 1791, 3111},{ 2168, 3224},{ 2597, 3309},{ 3075, 3351}, - { 3560, 3364},{ 4029, 3356},{ 4464, 3335},{ 4858, 3307}, - { 5218, 3275},{ 5547, 3256},{ 5850, 3247},{ 6171, 3214} - } - } - }, - { - { - /*Y' qi=55 INTRA*/ - { - { 178, 95},{ 968, 1137},{ 2000, 1747},{ 3013, 2027}, - { 3966, 2173},{ 4920, 2294},{ 5842, 2427},{ 6702, 2553}, - { 7489, 2668},{ 8213, 2773},{ 8875, 2858},{ 9452, 2913}, - { 9986, 2959},{10504, 3016},{11023, 3085},{11530, 3157}, - {12011, 3213},{12480, 3257},{12882, 3291},{13214, 3310}, - {13542, 3325},{13890, 3350},{14248, 3371},{14671, 3398} - }, - /*Y' qi=55 INTER*/ - { - { 59, 5},{ 170, 1307},{ 725, 2358},{ 1886, 3058}, - { 3589, 3385},{ 5284, 3459},{ 6654, 3458},{ 7771, 3461}, - { 8727, 3470},{ 9564, 3478},{10322, 3488},{11019, 3497}, - {11658, 3505},{12258, 3513},{12819, 3520},{13344, 3527}, - {13840, 3533},{14314, 3537},{14755, 3541},{15161, 3544}, - {15552, 3548},{15916, 3548},{16257, 3548},{16576, 3540} - } - }, - { - /*Cb qi=55 INTRA*/ - { - { 13, 2},{ 167, 366},{ 322, 714},{ 508, 1026}, - { 716, 1292},{ 930, 1511},{ 1148, 1690},{ 1366, 1839}, - { 1578, 1972},{ 1793, 2090},{ 2001, 2199},{ 2217, 2300}, - { 2427, 2393},{ 2609, 2495},{ 2784, 2600},{ 2961, 2704}, - { 3121, 2797},{ 3268, 2884},{ 3423, 2965},{ 3590, 3032}, - { 3764, 3096},{ 3926, 3165},{ 4101, 3223},{ 4405, 3258} - }, - /*Cb qi=55 INTER*/ - { - { 90, -4},{ 109, 344},{ 107, 668},{ 126, 1017}, - { 172, 1351},{ 249, 1657},{ 370, 1928},{ 527, 2174}, - { 702, 2407},{ 909, 2624},{ 1170, 2814},{ 1493, 2970}, - { 1869, 3097},{ 2292, 3192},{ 2752, 3258},{ 3232, 3295}, - { 3709, 3314},{ 4156, 3335},{ 4592, 3355},{ 5004, 3373}, - { 5377, 3389},{ 5737, 3411},{ 6092, 3432},{ 6473, 3423} - } - }, - { - /*Cr qi=55 INTRA*/ - { - { 23, 7},{ 175, 385},{ 342, 730},{ 561, 1028}, - { 771, 1279},{ 973, 1493},{ 1181, 1669},{ 1384, 1822}, - { 1602, 1956},{ 1830, 2076},{ 2057, 2184},{ 2270, 2288}, - { 2452, 2389},{ 2637, 2484},{ 2823, 2559},{ 2983, 2621}, - { 3129, 2682},{ 3280, 2753},{ 3417, 2833},{ 3554, 2904}, - { 3743, 2977},{ 3921, 3060},{ 4055, 3137},{ 4185, 3186} - }, - /*Cr qi=55 INTER*/ - { - { 85, 0},{ 99, 352},{ 100, 679},{ 126, 1025}, - { 178, 1351},{ 256, 1650},{ 359, 1935},{ 493, 2202}, - { 675, 2439},{ 921, 2636},{ 1220, 2799},{ 1552, 2941}, - { 1910, 3068},{ 2303, 3177},{ 2735, 3262},{ 3206, 3311}, - { 3689, 3333},{ 4152, 3327},{ 4588, 3299},{ 4978, 3272}, - { 5325, 3243},{ 5651, 3221},{ 5969, 3210},{ 6218, 3185} - } - } - }, - { - { - /*Y' qi=56 INTRA*/ - { - { 137, 104},{ 1048, 1128},{ 2147, 1760},{ 3261, 2029}, - { 4319, 2131},{ 5310, 2234},{ 6245, 2351},{ 7101, 2464}, - { 7886, 2572},{ 8610, 2675},{ 9270, 2762},{ 9840, 2818}, - {10365, 2869},{10875, 2928},{11393, 2997},{11900, 3071}, - {12371, 3128},{12834, 3172},{13233, 3208},{13562, 3228}, - {13878, 3245},{14221, 3271},{14584, 3292},{15008, 3320} - }, - /*Y' qi=56 INTER*/ - { - { 19, 21},{ 207, 1292},{ 1031, 2252},{ 2553, 2846}, - { 4463, 3085},{ 6137, 3131},{ 7441, 3151},{ 8526, 3172}, - { 9468, 3193},{10301, 3209},{11059, 3224},{11760, 3237}, - {12405, 3249},{13008, 3261},{13570, 3270},{14100, 3278}, - {14597, 3284},{15074, 3289},{15524, 3297},{15929, 3302}, - {16314, 3306},{16675, 3307},{17004, 3305},{17288, 3301} - } - }, - { - /*Cb qi=56 INTRA*/ - { - { 16, 3},{ 188, 367},{ 353, 712},{ 546, 1017}, - { 765, 1275},{ 989, 1484},{ 1221, 1653},{ 1459, 1791}, - { 1681, 1920},{ 1893, 2046},{ 2102, 2160},{ 2323, 2257}, - { 2534, 2347},{ 2720, 2447},{ 2902, 2549},{ 3075, 2654}, - { 3239, 2749},{ 3392, 2835},{ 3544, 2920},{ 3712, 2988}, - { 3882, 3052},{ 4052, 3123},{ 4227, 3181},{ 4483, 3213} - }, - /*Cb qi=56 INTER*/ - { - { 92, -1},{ 111, 343},{ 114, 665},{ 148, 1003}, - { 224, 1321},{ 345, 1609},{ 526, 1858},{ 754, 2077}, - { 1009, 2281},{ 1319, 2464},{ 1702, 2614},{ 2145, 2732}, - { 2625, 2824},{ 3123, 2890},{ 3634, 2933},{ 4137, 2954}, - { 4614, 2965},{ 5052, 2988},{ 5468, 3015},{ 5852, 3035}, - { 6213, 3060},{ 6557, 3081},{ 6906, 3094},{ 7243, 3112} - } - }, - { - /*Cr qi=56 INTRA*/ - { - { 28, 8},{ 195, 385},{ 373, 727},{ 598, 1019}, - { 816, 1263},{ 1033, 1465},{ 1260, 1630},{ 1482, 1773}, - { 1717, 1900},{ 1949, 2018},{ 2178, 2128},{ 2393, 2233}, - { 2570, 2338},{ 2749, 2435},{ 2937, 2514},{ 3097, 2577}, - { 3240, 2638},{ 3398, 2709},{ 3540, 2791},{ 3673, 2865}, - { 3869, 2938},{ 4049, 3019},{ 4179, 3095},{ 4330, 3137} - }, - /*Cr qi=56 INTER*/ - { - { 83, 0},{ 99, 353},{ 103, 676},{ 146, 1010}, - { 232, 1320},{ 355, 1601},{ 512, 1866},{ 713, 2109}, - { 988, 2312},{ 1344, 2471},{ 1750, 2602},{ 2180, 2719}, - { 2642, 2819},{ 3141, 2892},{ 3653, 2939},{ 4159, 2961}, - { 4636, 2961},{ 5072, 2945},{ 5464, 2917},{ 5813, 2895}, - { 6134, 2890},{ 6458, 2883},{ 6735, 2881},{ 6953, 2902} - } - } - }, - { - { - /*Y' qi=57 INTRA*/ - { - { 170, 106},{ 1106, 1120},{ 2246, 1740},{ 3399, 1993}, - { 4482, 2077},{ 5492, 2167},{ 6446, 2273},{ 7324, 2379}, - { 8130, 2482},{ 8866, 2578},{ 9537, 2661},{10119, 2715}, - {10646, 2762},{11161, 2820},{11694, 2886},{12214, 2957}, - {12693, 3013},{13166, 3053},{13569, 3087},{13897, 3106}, - {14224, 3122},{14568, 3148},{14931, 3167},{15390, 3192} - }, - /*Y' qi=57 INTER*/ - { - { 19, 20},{ 205, 1292},{ 1096, 2229},{ 2775, 2766}, - { 4811, 2943},{ 6512, 2964},{ 7832, 2976},{ 8940, 2990}, - { 9903, 3004},{10755, 3017},{11532, 3029},{12243, 3039}, - {12891, 3047},{13502, 3058},{14073, 3065},{14603, 3071}, - {15097, 3078},{15581, 3083},{16036, 3086},{16452, 3090}, - {16855, 3093},{17222, 3094},{17552, 3092},{17851, 3098} - } - }, - { - /*Cb qi=57 INTRA*/ - { - { 16, 3},{ 197, 365},{ 384, 704},{ 603, 1001}, - { 837, 1252},{ 1077, 1455},{ 1326, 1618},{ 1581, 1748}, - { 1819, 1871},{ 2042, 1993},{ 2264, 2104},{ 2500, 2196}, - { 2722, 2280},{ 2916, 2375},{ 3103, 2473},{ 3290, 2575}, - { 3456, 2667},{ 3612, 2748},{ 3775, 2829},{ 3958, 2896}, - { 4145, 2947},{ 4307, 3012},{ 4476, 3070},{ 4733, 3110} - }, - /*Cb qi=57 INTER*/ - { - { 94, -1},{ 111, 344},{ 112, 665},{ 147, 1002}, - { 227, 1319},{ 353, 1604},{ 543, 1849},{ 785, 2062}, - { 1066, 2257},{ 1408, 2430},{ 1827, 2568},{ 2320, 2670}, - { 2848, 2743},{ 3386, 2791},{ 3934, 2812},{ 4453, 2820}, - { 4929, 2830},{ 5368, 2842},{ 5787, 2856},{ 6190, 2875}, - { 6554, 2896},{ 6895, 2913},{ 7229, 2927},{ 7572, 2932} - } - }, - { - /*Cr qi=57 INTRA*/ - { - { 28, 8},{ 207, 383},{ 413, 716},{ 661, 999}, - { 889, 1237},{ 1123, 1433},{ 1365, 1592},{ 1603, 1731}, - { 1853, 1852},{ 2103, 1965},{ 2345, 2072},{ 2571, 2173}, - { 2763, 2271},{ 2949, 2364},{ 3146, 2438},{ 3315, 2497}, - { 3459, 2552},{ 3618, 2616},{ 3767, 2697},{ 3906, 2773}, - { 4099, 2841},{ 4281, 2916},{ 4429, 2987},{ 4569, 3030} - }, - /*Cr qi=57 INTER*/ - { - { 85, 0},{ 99, 352},{ 102, 675},{ 147, 1008}, - { 235, 1317},{ 363, 1597},{ 529, 1858},{ 748, 2094}, - { 1050, 2287},{ 1439, 2436},{ 1877, 2557},{ 2352, 2660}, - { 2869, 2740},{ 3413, 2791},{ 3962, 2815},{ 4485, 2819}, - { 4955, 2816},{ 5382, 2800},{ 5769, 2772},{ 6107, 2748}, - { 6443, 2740},{ 6754, 2739},{ 7029, 2737},{ 7284, 2745} - } - } - }, - { - { - /*Y' qi=58 INTRA*/ - { - { 164, 109},{ 1198, 1111},{ 2396, 1737},{ 3606, 1978}, - { 4727, 2048},{ 5749, 2138},{ 6708, 2243},{ 7584, 2347}, - { 8388, 2449},{ 9122, 2549},{ 9784, 2635},{10354, 2691}, - {10876, 2740},{11385, 2800},{11912, 2869},{12429, 2941}, - {12902, 2997},{13375, 3040},{13779, 3075},{14103, 3096}, - {14435, 3112},{14783, 3140},{15141, 3160},{15599, 3186} - }, - /*Y' qi=58 INTER*/ - { - { 14, 23},{ 210, 1290},{ 1277, 2178},{ 3118, 2677}, - { 5207, 2834},{ 6902, 2857},{ 8218, 2878},{ 9323, 2900}, - {10285, 2919},{11132, 2934},{11899, 2949},{12599, 2961}, - {13235, 2971},{13835, 2982},{14394, 2991},{14917, 2997}, - {15412, 3005},{15882, 3009},{16325, 3013},{16735, 3016}, - {17131, 3018},{17501, 3021},{17824, 3021},{18125, 3016} - } - }, - { - /*Cb qi=58 INTRA*/ - { - { 17, 3},{ 200, 365},{ 389, 703},{ 613, 996}, - { 853, 1243},{ 1095, 1445},{ 1349, 1604},{ 1613, 1731}, - { 1853, 1853},{ 2074, 1978},{ 2292, 2091},{ 2526, 2184}, - { 2750, 2266},{ 2945, 2360},{ 3134, 2458},{ 3320, 2561}, - { 3482, 2654},{ 3641, 2737},{ 3804, 2818},{ 3985, 2881}, - { 4168, 2935},{ 4331, 3003},{ 4499, 3060},{ 4751, 3100} - }, - /*Cb qi=58 INTER*/ - { - { 94, -1},{ 112, 345},{ 112, 665},{ 152, 998}, - { 247, 1307},{ 406, 1580},{ 644, 1810},{ 938, 2007}, - { 1271, 2189},{ 1668, 2348},{ 2151, 2470},{ 2691, 2558}, - { 3249, 2619},{ 3798, 2659},{ 4334, 2682},{ 4849, 2692}, - { 5314, 2700},{ 5747, 2721},{ 6167, 2742},{ 6547, 2765}, - { 6902, 2790},{ 7251, 2804},{ 7583, 2819},{ 7924, 2833} - } - }, - { - /*Cr qi=58 INTRA*/ - { - { 29, 8},{ 210, 382},{ 419, 714},{ 671, 993}, - { 903, 1229},{ 1141, 1422},{ 1390, 1578},{ 1635, 1713}, - { 1889, 1833},{ 2140, 1946},{ 2379, 2055},{ 2604, 2157}, - { 2794, 2256},{ 2977, 2349},{ 3174, 2422},{ 3339, 2482}, - { 3483, 2537},{ 3643, 2604},{ 3790, 2684},{ 3927, 2757}, - { 4112, 2826},{ 4294, 2900},{ 4451, 2975},{ 4600, 3011} - }, - /*Cr qi=58 INTER*/ - { - { 86, 0},{ 99, 352},{ 103, 675},{ 151, 1004}, - { 256, 1306},{ 417, 1573},{ 628, 1819},{ 901, 2040}, - { 1262, 2217},{ 1705, 2353},{ 2191, 2466},{ 2713, 2556}, - { 3268, 2622},{ 3831, 2664},{ 4374, 2682},{ 4881, 2686}, - { 5339, 2685},{ 5747, 2668},{ 6123, 2646},{ 6465, 2630}, - { 6783, 2618},{ 7082, 2623},{ 7366, 2632},{ 7673, 2654} - } - } - }, - { - { - /*Y' qi=59 INTRA*/ - { - { 142, 112},{ 1259, 1100},{ 2552, 1711},{ 3815, 1933}, - { 4955, 1987},{ 5983, 2068},{ 6949, 2165},{ 7832, 2263}, - { 8645, 2359},{ 9392, 2454},{10066, 2536},{10643, 2589}, - {11174, 2636},{11696, 2693},{12230, 2758},{12752, 2826}, - {13239, 2883},{13721, 2926},{14139, 2959},{14479, 2978}, - {14811, 2993},{15166, 3020},{15532, 3039},{16000, 3062} - }, - /*Y' qi=59 INTER*/ - { - { 8, 25},{ 211, 1289},{ 1394, 2144},{ 3421, 2580}, - { 5611, 2689},{ 7316, 2701},{ 8643, 2717},{ 9762, 2734}, - {10735, 2750},{11587, 2763},{12353, 2775},{13056, 2785}, - {13693, 2793},{14288, 2805},{14843, 2814},{15361, 2821}, - {15857, 2827},{16328, 2831},{16763, 2834},{17171, 2838}, - {17568, 2840},{17941, 2842},{18285, 2843},{18586, 2839} - } - }, - { - /*Cb qi=59 INTRA*/ - { - { 17, 3},{ 224, 363},{ 441, 696},{ 689, 982}, - { 945, 1222},{ 1204, 1416},{ 1474, 1571},{ 1751, 1695}, - { 2001, 1816},{ 2228, 1941},{ 2453, 2055},{ 2693, 2147}, - { 2924, 2227},{ 3125, 2321},{ 3321, 2416},{ 3510, 2520}, - { 3676, 2616},{ 3839, 2699},{ 4008, 2778},{ 4193, 2842}, - { 4371, 2898},{ 4535, 2965},{ 4710, 3023},{ 4921, 3068} - }, - /*Cb qi=59 INTER*/ - { - { 95, -5},{ 111, 343},{ 112, 664},{ 157, 995}, - { 258, 1302},{ 429, 1569},{ 691, 1790},{ 1017, 1977}, - { 1387, 2148},{ 1832, 2294},{ 2368, 2401},{ 2961, 2472}, - { 3553, 2518},{ 4133, 2545},{ 4688, 2557},{ 5198, 2563}, - { 5663, 2574},{ 6100, 2590},{ 6511, 2608},{ 6898, 2621}, - { 7274, 2634},{ 7631, 2655},{ 7984, 2669},{ 8361, 2669} - } - }, - { - /*Cr qi=59 INTRA*/ - { - { 31, 8},{ 240, 379},{ 480, 706},{ 748, 978}, - { 993, 1208},{ 1250, 1394},{ 1519, 1543},{ 1779, 1674}, - { 2047, 1792},{ 2307, 1904},{ 2552, 2013},{ 2780, 2116}, - { 2973, 2216},{ 3165, 2309},{ 3362, 2383},{ 3528, 2444}, - { 3677, 2499},{ 3841, 2566},{ 3995, 2646},{ 4139, 2720}, - { 4324, 2793},{ 4504, 2867},{ 4658, 2939},{ 4806, 2975} - }, - /*Cr qi=59 INTER*/ - { - { 89, -3},{ 98, 352},{ 103, 674},{ 156, 1002}, - { 268, 1300},{ 441, 1562},{ 673, 1801},{ 980, 2010}, - { 1385, 2175},{ 1868, 2301},{ 2401, 2402},{ 2984, 2474}, - { 3591, 2520},{ 4179, 2545},{ 4729, 2555},{ 5232, 2553}, - { 5679, 2545},{ 6081, 2530},{ 6447, 2510},{ 6791, 2496}, - { 7101, 2487},{ 7393, 2489},{ 7684, 2499},{ 7950, 2501} - } - } - }, - { - { - /*Y' qi=60 INTRA*/ - { - { 92, 116},{ 1361, 1085},{ 2746, 1686},{ 4050, 1895}, - { 5209, 1939},{ 6244, 2012},{ 7213, 2103},{ 8105, 2197}, - { 8928, 2290},{ 9685, 2381},{10371, 2460},{10952, 2511}, - {11487, 2556},{12026, 2611},{12574, 2674},{13102, 2739}, - {13597, 2793},{14092, 2831},{14523, 2862},{14862, 2881}, - {15198, 2897},{15568, 2923},{15949, 2941},{16416, 2964} - }, - /*Y' qi=60 INTER*/ - { - { 4, 30},{ 215, 1287},{ 1547, 2104},{ 3729, 2491}, - { 5973, 2568},{ 7672, 2577},{ 9001, 2591},{10123, 2606}, - {11094, 2620},{11943, 2632},{12709, 2643},{13409, 2652}, - {14044, 2660},{14641, 2669},{15193, 2677},{15709, 2684}, - {16201, 2689},{16675, 2693},{17118, 2696},{17522, 2701}, - {17920, 2704},{18293, 2706},{18620, 2702},{18923, 2700} - } - }, - { - /*Cb qi=60 INTRA*/ - { - { 18, 3},{ 227, 362},{ 447, 694},{ 708, 974}, - { 981, 1207},{ 1252, 1397},{ 1532, 1547},{ 1822, 1663}, - { 2082, 1780},{ 2316, 1903},{ 2548, 2013},{ 2794, 2101}, - { 3029, 2178},{ 3242, 2266},{ 3445, 2360},{ 3638, 2459}, - { 3816, 2547},{ 3980, 2628},{ 4146, 2708},{ 4344, 2766}, - { 4546, 2812},{ 4725, 2872},{ 4880, 2930},{ 5054, 2966} - }, - /*Cb qi=60 INTER*/ - { - { 97, -4},{ 112, 343},{ 114, 664},{ 162, 993}, - { 273, 1294},{ 472, 1553},{ 774, 1762},{ 1138, 1939}, - { 1543, 2102},{ 2034, 2236},{ 2620, 2329},{ 3244, 2389}, - { 3860, 2423},{ 4443, 2440},{ 4997, 2449},{ 5502, 2455}, - { 5962, 2458},{ 6413, 2466},{ 6836, 2485},{ 7217, 2506}, - { 7592, 2518},{ 7957, 2533},{ 8291, 2543},{ 8574, 2545} - } - }, - { - /*Cr qi=60 INTRA*/ - { - { 32, 8},{ 243, 379},{ 488, 702},{ 771, 968}, - { 1030, 1192},{ 1300, 1373},{ 1581, 1517},{ 1854, 1643}, - { 2127, 1757},{ 2393, 1864},{ 2645, 1968},{ 2879, 2068}, - { 3078, 2166},{ 3277, 2256},{ 3484, 2325},{ 3660, 2381}, - { 3808, 2433},{ 3970, 2496},{ 4138, 2571},{ 4288, 2643}, - { 4475, 2710},{ 4655, 2778},{ 4810, 2843},{ 4959, 2879} - }, - /*Cr qi=60 INTER*/ - { - { 86, -2},{ 99, 352},{ 103, 673},{ 160, 998}, - { 284, 1292},{ 484, 1546},{ 753, 1774},{ 1100, 1973}, - { 1546, 2129},{ 2072, 2246},{ 2652, 2334},{ 3279, 2392}, - { 3911, 2425},{ 4504, 2440},{ 5044, 2443},{ 5536, 2440}, - { 5979, 2430},{ 6381, 2413},{ 6735, 2397},{ 7062, 2382}, - { 7383, 2376},{ 7680, 2375},{ 7962, 2373},{ 8203, 2379} - } - } - }, - { - { - /*Y' qi=61 INTRA*/ - { - { 54, 121},{ 1477, 1069},{ 3061, 1638},{ 4465, 1808}, - { 5649, 1827},{ 6710, 1884},{ 7716, 1958},{ 8648, 2037}, - { 9514, 2116},{10311, 2192},{11033, 2261},{11641, 2305}, - {12202, 2342},{12771, 2387},{13356, 2440},{13924, 2493}, - {14444, 2541},{14951, 2576},{15409, 2600},{15779, 2615}, - {16131, 2626},{16521, 2648},{16921, 2663},{17409, 2694} - }, - /*Y' qi=61 INTER*/ - { - { -1, 32},{ 216, 1286},{ 1806, 2036},{ 4279, 2327}, - { 6629, 2352},{ 8347, 2352},{ 9707, 2357},{10860, 2364}, - {11857, 2372},{12726, 2377},{13508, 2382},{14225, 2387}, - {14877, 2392},{15484, 2398},{16048, 2401},{16581, 2405}, - {17092, 2409},{17573, 2409},{18016, 2410},{18427, 2413}, - {18829, 2415},{19221, 2415},{19578, 2415},{19980, 2413} - } - }, - { - /*Cb qi=61 INTRA*/ - { - { 19, 3},{ 231, 362},{ 456, 693},{ 733, 965}, - { 1032, 1188},{ 1330, 1369},{ 1637, 1508},{ 1956, 1612}, - { 2241, 1718},{ 2496, 1832},{ 2750, 1932},{ 3019, 2007}, - { 3274, 2074},{ 3505, 2154},{ 3725, 2236},{ 3943, 2323}, - { 4138, 2403},{ 4323, 2476},{ 4505, 2543},{ 4706, 2592}, - { 4909, 2630},{ 5109, 2675},{ 5292, 2724},{ 5495, 2768} - }, - /*Cb qi=61 INTER*/ - { - { 91, -2},{ 111, 344},{ 114, 663},{ 166, 989}, - { 291, 1285},{ 522, 1534},{ 875, 1729},{ 1302, 1889}, - { 1786, 2031},{ 2368, 2141},{ 3042, 2207},{ 3734, 2243}, - { 4388, 2259},{ 4982, 2264},{ 5533, 2265},{ 6043, 2262}, - { 6524, 2264},{ 6982, 2274},{ 7422, 2283},{ 7831, 2295}, - { 8198, 2308},{ 8593, 2319},{ 8965, 2329},{ 9258, 2340} - } - }, - { - /*Cr qi=61 INTRA*/ - { - { 33, 9},{ 245, 378},{ 497, 699},{ 801, 958}, - { 1087, 1171},{ 1384, 1342},{ 1692, 1474},{ 1992, 1589}, - { 2290, 1692},{ 2576, 1789},{ 2852, 1884},{ 3109, 1973}, - { 3324, 2061},{ 3544, 2142},{ 3763, 2199},{ 3945, 2244}, - { 4103, 2292},{ 4283, 2349},{ 4469, 2413},{ 4635, 2476}, - { 4836, 2534},{ 5038, 2592},{ 5210, 2649},{ 5358, 2682} - }, - /*Cr qi=61 INTER*/ - { - { 82, 0},{ 97, 353},{ 104, 672},{ 165, 995}, - { 303, 1284},{ 532, 1529},{ 852, 1742},{ 1273, 1921}, - { 1798, 2057},{ 2409, 2154},{ 3090, 2212},{ 3794, 2240}, - { 4460, 2251},{ 5057, 2249},{ 5596, 2249},{ 6085, 2245}, - { 6519, 2234},{ 6908, 2220},{ 7269, 2203},{ 7618, 2196}, - { 7949, 2198},{ 8269, 2195},{ 8554, 2196},{ 8928, 2217} - } - } - }, - { - { - /*Y' qi=62 INTRA*/ - { - { 29, 124},{ 1527, 1067},{ 3221, 1618},{ 4703, 1751}, - { 5909, 1744},{ 7001, 1779},{ 8057, 1829},{ 9049, 1885}, - { 9968, 1943},{10813, 1999},{11572, 2050},{12206, 2082}, - {12801, 2107},{13402, 2140},{14020, 2180},{14625, 2223}, - {15179, 2260},{15718, 2288},{16196, 2305},{16581, 2313}, - {16963, 2324},{17382, 2341},{17800, 2351},{18318, 2376} - }, - /*Y' qi=62 INTER*/ - { - { -8, 36},{ 218, 1284},{ 2073, 1965},{ 4814, 2159}, - { 7237, 2138},{ 8979, 2124},{10378, 2115},{11570, 2109}, - {12601, 2106},{13503, 2103},{14320, 2103},{15064, 2103}, - {15746, 2103},{16384, 2104},{16975, 2105},{17534, 2105}, - {18062, 2106},{18564, 2107},{19035, 2106},{19471, 2107}, - {19890, 2107},{20288, 2107},{20651, 2107},{21012, 2108} - } - }, - { - /*Cb qi=62 INTRA*/ - { - { 21, 3},{ 283, 360},{ 565, 683},{ 907, 938}, - { 1269, 1143},{ 1611, 1311},{ 1949, 1441},{ 2290, 1535}, - { 2596, 1632},{ 2877, 1738},{ 3162, 1828},{ 3458, 1893}, - { 3745, 1948},{ 4011, 2016},{ 4253, 2089},{ 4506, 2164}, - { 4734, 2233},{ 4943, 2294},{ 5162, 2353},{ 5381, 2393}, - { 5593, 2420},{ 5807, 2454},{ 6003, 2496},{ 6210, 2543} - }, - /*Cb qi=62 INTER*/ - { - { 91, -1},{ 110, 344},{ 113, 663},{ 169, 987}, - { 306, 1279},{ 562, 1519},{ 961, 1701},{ 1450, 1845}, - { 2013, 1967},{ 2686, 2053},{ 3437, 2095},{ 4171, 2109}, - { 4841, 2109},{ 5441, 2105},{ 6002, 2097},{ 6542, 2089}, - { 7028, 2087},{ 7491, 2088},{ 7949, 2090},{ 8377, 2089}, - { 8789, 2095},{ 9195, 2103},{ 9569, 2104},{ 9937, 2102} - } - }, - { - /*Cr qi=62 INTRA*/ - { - { 38, 8},{ 308, 374},{ 619, 685},{ 984, 925}, - { 1326, 1126},{ 1662, 1285},{ 1999, 1407},{ 2328, 1512}, - { 2659, 1604},{ 2976, 1691},{ 3285, 1774},{ 3570, 1853}, - { 3815, 1931},{ 4068, 1998},{ 4304, 2044},{ 4491, 2082}, - { 4666, 2124},{ 4870, 2174},{ 5078, 2231},{ 5262, 2285}, - { 5480, 2335},{ 5703, 2378},{ 5905, 2423},{ 6075, 2454} - }, - /*Cr qi=62 INTER*/ - { - { 79, 1},{ 95, 353},{ 102, 671},{ 169, 992}, - { 318, 1277},{ 569, 1515},{ 936, 1716},{ 1428, 1876}, - { 2034, 1993},{ 2738, 2067},{ 3511, 2095},{ 4268, 2094}, - { 4943, 2087},{ 5543, 2079},{ 6074, 2074},{ 6552, 2069}, - { 6985, 2057},{ 7366, 2043},{ 7728, 2030},{ 8086, 2021}, - { 8423, 2017},{ 8752, 2016},{ 9057, 2014},{ 9376, 2008} - } - } - }, - { - { - /*Y' qi=63 INTRA*/ - { - { -59, 134},{ 1734, 1036},{ 3743, 1521},{ 5309, 1618}, - { 6520, 1597},{ 7664, 1609},{ 8809, 1630},{ 9894, 1657}, - {10907, 1687},{11838, 1717},{12673, 1744},{13379, 1758}, - {14038, 1767},{14698, 1784},{15379, 1806},{16062, 1831}, - {16694, 1852},{17300, 1867},{17827, 1878},{18250, 1881}, - {18702, 1884},{19199, 1892},{19665, 1896},{20273, 1908} - }, - /*Y' qi=63 INTER*/ - { - { -7, 33},{ 209, 1285},{ 2309, 1904},{ 5274, 2025}, - { 7801, 1966},{ 9637, 1924},{11126, 1892},{12403, 1868}, - {13515, 1849},{14491, 1834},{15380, 1822},{16197, 1814}, - {16944, 1806},{17645, 1799},{18303, 1794},{18916, 1789}, - {19494, 1785},{20056, 1782},{20568, 1779},{21047, 1776}, - {21508, 1775},{21925, 1772},{22327, 1770},{22678, 1771} - } - }, - { - /*Cb qi=63 INTRA*/ - { - { 20, 3},{ 294, 357},{ 608, 673},{ 1047, 908}, - { 1501, 1090},{ 1898, 1240},{ 2275, 1353},{ 2654, 1427}, - { 3014, 1502},{ 3366, 1579},{ 3726, 1637},{ 4084, 1674}, - { 4425, 1703},{ 4752, 1743},{ 5058, 1791},{ 5377, 1838}, - { 5676, 1877},{ 5946, 1912},{ 6213, 1945},{ 6458, 1969}, - { 6704, 1982},{ 6969, 1997},{ 7210, 2017},{ 7439, 2037} - }, - /*Cb qi=63 INTER*/ - { - { 86, 1},{ 108, 345},{ 111, 663},{ 168, 985}, - { 307, 1276},{ 577, 1513},{ 1007, 1688},{ 1550, 1819}, - { 2189, 1921},{ 2938, 1981},{ 3744, 2002},{ 4512, 2002}, - { 5199, 1996},{ 5824, 1986},{ 6419, 1971},{ 6978, 1954}, - { 7507, 1940},{ 8015, 1932},{ 8502, 1928},{ 8978, 1920}, - { 9410, 1915},{ 9842, 1910},{10262, 1901},{10634, 1896} - } - }, - { - /*Cr qi=63 INTRA*/ - { - { 38, 7},{ 324, 367},{ 677, 670},{ 1136, 892}, - { 1562, 1070},{ 1951, 1209},{ 2326, 1313},{ 2694, 1399}, - { 3074, 1471},{ 3460, 1531},{ 3850, 1575},{ 4214, 1622}, - { 4522, 1679},{ 4819, 1723},{ 5089, 1749},{ 5315, 1769}, - { 5530, 1792},{ 5756, 1825},{ 6006, 1860},{ 6244, 1889}, - { 6514, 1924},{ 6792, 1946},{ 7026, 1962},{ 7191, 1971} - }, - /*Cr qi=63 INTER*/ - { - { 80, 2},{ 95, 354},{ 101, 671},{ 167, 990}, - { 321, 1274},{ 585, 1509},{ 984, 1702},{ 1534, 1849}, - { 2217, 1947},{ 3005, 1995},{ 3839, 1999},{ 4619, 1986}, - { 5310, 1973},{ 5933, 1961},{ 6486, 1952},{ 6988, 1942}, - { 7435, 1927},{ 7817, 1911},{ 8198, 1900},{ 8552, 1895}, - { 8881, 1890},{ 9253, 1883},{ 9598, 1876},{ 9923, 1859} - } - } - } -}; - -#endif diff --git a/Engine/lib/libtheora/lib/ocintrin.h b/Engine/lib/libtheora/lib/ocintrin.h deleted file mode 100644 index d49ebb215..000000000 --- a/Engine/lib/libtheora/lib/ocintrin.h +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: ocintrin.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -/*Some common macros for potential platform-specific optimization.*/ -#include -#if !defined(_ocintrin_H) -# define _ocintrin_H (1) - -/*Some specific platforms may have optimized intrinsic or inline assembly - versions of these functions which can substantially improve performance. - We define macros for them to allow easy incorporation of these non-ANSI - features.*/ - -/*Note that we do not provide a macro for abs(), because it is provided as a - library function, which we assume is translated into an intrinsic to avoid - the function call overhead and then implemented in the smartest way for the - target platform. - With modern gcc (4.x), this is true: it uses cmov instructions if the - architecture supports it and branchless bit-twiddling if it does not (the - speed difference between the two approaches is not measurable). - Interestingly, the bit-twiddling method was patented in 2000 (US 6,073,150) - by Sun Microsystems, despite prior art dating back to at least 1996: - http://web.archive.org/web/19961201174141/www.x86.org/ftp/articles/pentopt/PENTOPT.TXT - On gcc 3.x, however, our assumption is not true, as abs() is translated to a - conditional jump, which is horrible on deeply piplined architectures (e.g., - all consumer architectures for the past decade or more). - Also be warned that -C*abs(x) where C is a constant is mis-optimized as - abs(C*x) on every gcc release before 4.2.3. - See bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34130 */ - -/*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 - instructions, because of the way they represented ((_b)>(_a)) internally.*/ -#define OC_MAXI(_a,_b) ((_a)-((_a)-(_b)&-((_b)>(_a)))) -#define OC_MINI(_a,_b) ((_a)+((_b)-(_a)&-((_b)<(_a)))) -/*Clamps an integer into the given range. - If _a>_c, then the lower bound _a is respected over the upper bound _c (this - behavior is required to meet our documented API behavior). - _a: The lower bound. - _b: The value to clamp. - _c: The upper boud.*/ -#define OC_CLAMPI(_a,_b,_c) (OC_MAXI(_a,OC_MINI(_b,_c))) -#define OC_CLAMP255(_x) ((unsigned char)((((_x)<0)-1)&((_x)|-((_x)>255)))) -/*This has a chance of compiling branchless, and is just as fast as the - bit-twiddling method, which is slightly less portable, since it relies on a - sign-extended rightshift, which is not guaranteed by ANSI (but present on - every relevant platform).*/ -#define OC_SIGNI(_a) (((_a)>0)-((_a)<0)) -/*Slightly more portable than relying on a sign-extended right-shift (which is - not guaranteed by ANSI), and just as fast, since gcc (3.x and 4.x both) - compile it into the right-shift anyway.*/ -#define OC_SIGNMASK(_a) (-((_a)<0)) -/*Divides an integer by a power of two, truncating towards 0. - _dividend: The integer to divide. - _shift: The non-negative power of two to divide by. - _rmask: (1<<_shift)-1*/ -#define OC_DIV_POW2(_dividend,_shift,_rmask)\ - ((_dividend)+(OC_SIGNMASK(_dividend)&(_rmask))>>(_shift)) -/*Divides _x by 65536, truncating towards 0.*/ -#define OC_DIV2_16(_x) OC_DIV_POW2(_x,16,0xFFFF) -/*Divides _x by 2, truncating towards 0.*/ -#define OC_DIV2(_x) OC_DIV_POW2(_x,1,0x1) -/*Divides _x by 8, truncating towards 0.*/ -#define OC_DIV8(_x) OC_DIV_POW2(_x,3,0x7) -/*Divides _x by 16, truncating towards 0.*/ -#define OC_DIV16(_x) OC_DIV_POW2(_x,4,0xF) -/*Right shifts _dividend by _shift, adding _rval, and subtracting one for - negative dividends first. - When _rval is (1<<_shift-1), this is equivalent to division with rounding - ties away from zero.*/ -#define OC_DIV_ROUND_POW2(_dividend,_shift,_rval)\ - ((_dividend)+OC_SIGNMASK(_dividend)+(_rval)>>(_shift)) -/*Divides a _x by 2, rounding towards even numbers.*/ -#define OC_DIV2_RE(_x) ((_x)+((_x)>>1&1)>>1) -/*Divides a _x by (1<<(_shift)), rounding towards even numbers.*/ -#define OC_DIV_POW2_RE(_x,_shift) \ - ((_x)+((_x)>>(_shift)&1)+((1<<(_shift))-1>>1)>>(_shift)) -/*Swaps two integers _a and _b if _a>_b.*/ -#define OC_SORT2I(_a,_b) \ - do{ \ - int t__; \ - t__=((_a)^(_b))&-((_b)<(_a)); \ - (_a)^=t__; \ - (_b)^=t__; \ - } \ - while(0) - -/*Accesses one of four (signed) bytes given an index. - This can be used to avoid small lookup tables.*/ -#define OC_BYTE_TABLE32(_a,_b,_c,_d,_i) \ - ((signed char) \ - (((_a)&0xFF|((_b)&0xFF)<<8|((_c)&0xFF)<<16|((_d)&0xFF)<<24)>>(_i)*8)) -/*Accesses one of eight (unsigned) nibbles given an index. - This can be used to avoid small lookup tables.*/ -#define OC_UNIBBLE_TABLE32(_a,_b,_c,_d,_e,_f,_g,_h,_i) \ - ((((_a)&0xF|((_b)&0xF)<<4|((_c)&0xF)<<8|((_d)&0xF)<<12| \ - ((_e)&0xF)<<16|((_f)&0xF)<<20|((_g)&0xF)<<24|((_h)&0xF)<<28)>>(_i)*4)&0xF) - - - -/*All of these macros should expect floats as arguments.*/ -#define OC_MAXF(_a,_b) ((_a)<(_b)?(_b):(_a)) -#define OC_MINF(_a,_b) ((_a)>(_b)?(_b):(_a)) -#define OC_CLAMPF(_a,_b,_c) (OC_MINF(_a,OC_MAXF(_b,_c))) -#define OC_FABSF(_f) ((float)fabs(_f)) -#define OC_SQRTF(_f) ((float)sqrt(_f)) -#define OC_POWF(_b,_e) ((float)pow(_b,_e)) -#define OC_LOGF(_f) ((float)log(_f)) -#define OC_IFLOORF(_f) ((int)floor(_f)) -#define OC_ICEILF(_f) ((int)ceil(_f)) - -#endif diff --git a/Engine/lib/libtheora/lib/quant.c b/Engine/lib/libtheora/lib/quant.c deleted file mode 100644 index 8359f5abe..000000000 --- a/Engine/lib/libtheora/lib/quant.c +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: quant.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include -#include -#include -#include "quant.h" -#include "decint.h" - -static const unsigned OC_DC_QUANT_MIN[2]={4<<2,8<<2}; -static const unsigned OC_AC_QUANT_MIN[2]={2<<2,4<<2}; - -/*Initializes the dequantization tables from a set of quantizer info. - Currently the dequantizer (and elsewhere enquantizer) tables are expected to - be initialized as pointing to the storage reserved for them in the - oc_theora_state (resp. oc_enc_ctx) structure. - If some tables are duplicates of others, the pointers will be adjusted to - point to a single copy of the tables, but the storage for them will not be - freed. - If you're concerned about the memory footprint, the obvious thing to do is - to move the storage out of its fixed place in the structures and allocate - it on demand. - However, a much, much better option is to only store the quantization - matrices being used for the current frame, and to recalculate these as the - qi values change between frames (this is what VP3 did).*/ -void oc_dequant_tables_init(ogg_uint16_t *_dequant[64][3][2], - int _pp_dc_scale[64],const th_quant_info *_qinfo){ - /*Coding mode: intra or inter.*/ - int qti; - /*Y', C_b, C_r*/ - int pli; - for(qti=0;qti<2;qti++)for(pli=0;pli<3;pli++){ - /*Quality index.*/ - int qi; - /*Range iterator.*/ - int qri; - for(qi=0,qri=0;qri<=_qinfo->qi_ranges[qti][pli].nranges;qri++){ - th_quant_base base; - ogg_uint32_t q; - int qi_start; - int qi_end; - memcpy(base,_qinfo->qi_ranges[qti][pli].base_matrices[qri], - sizeof(base)); - qi_start=qi; - if(qri==_qinfo->qi_ranges[qti][pli].nranges)qi_end=qi+1; - else qi_end=qi+_qinfo->qi_ranges[qti][pli].sizes[qri]; - /*Iterate over quality indicies in this range.*/ - for(;;){ - ogg_uint32_t qfac; - int zzi; - int ci; - /*In the original VP3.2 code, the rounding offset and the size of the - dead zone around 0 were controlled by a "sharpness" parameter. - The size of our dead zone is now controlled by the per-coefficient - quality thresholds returned by our HVS module. - We round down from a more accurate value when the quality of the - reconstruction does not fall below our threshold and it saves bits. - Hence, all of that VP3.2 code is gone from here, and the remaining - floating point code has been implemented as equivalent integer code - with exact precision.*/ - qfac=(ogg_uint32_t)_qinfo->dc_scale[qi]*base[0]; - /*For postprocessing, not dequantization.*/ - if(_pp_dc_scale!=NULL)_pp_dc_scale[qi]=(int)(qfac/160); - /*Scale DC the coefficient from the proper table.*/ - q=(qfac/100)<<2; - q=OC_CLAMPI(OC_DC_QUANT_MIN[qti],q,OC_QUANT_MAX); - _dequant[qi][pli][qti][0]=(ogg_uint16_t)q; - /*Now scale AC coefficients from the proper table.*/ - for(zzi=1;zzi<64;zzi++){ - q=((ogg_uint32_t)_qinfo->ac_scale[qi]*base[OC_FZIG_ZAG[zzi]]/100)<<2; - q=OC_CLAMPI(OC_AC_QUANT_MIN[qti],q,OC_QUANT_MAX); - _dequant[qi][pli][qti][zzi]=(ogg_uint16_t)q; - } - /*If this is a duplicate of a previous matrix, use that instead. - This simple check helps us improve cache coherency later.*/ - { - int dupe; - int qtj; - int plj; - dupe=0; - for(qtj=0;qtj<=qti;qtj++){ - for(plj=0;plj<(qtj=qi_end)break; - /*Interpolate the next base matrix.*/ - for(ci=0;ci<64;ci++){ - base[ci]=(unsigned char)( - (2*((qi_end-qi)*_qinfo->qi_ranges[qti][pli].base_matrices[qri][ci]+ - (qi-qi_start)*_qinfo->qi_ranges[qti][pli].base_matrices[qri+1][ci]) - +_qinfo->qi_ranges[qti][pli].sizes[qri])/ - (2*_qinfo->qi_ranges[qti][pli].sizes[qri])); - } - } - } - } -} diff --git a/Engine/lib/libtheora/lib/quant.h b/Engine/lib/libtheora/lib/quant.h deleted file mode 100644 index 49ce13a65..000000000 --- a/Engine/lib/libtheora/lib/quant.h +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: quant.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#if !defined(_quant_H) -# define _quant_H (1) -# include "theora/codec.h" -# include "ocintrin.h" - -typedef ogg_uint16_t oc_quant_table[64]; - - -/*Maximum scaled quantizer value.*/ -#define OC_QUANT_MAX (1024<<2) - - -void oc_dequant_tables_init(ogg_uint16_t *_dequant[64][3][2], - int _pp_dc_scale[64],const th_quant_info *_qinfo); - -#endif diff --git a/Engine/lib/libtheora/lib/rate.c b/Engine/lib/libtheora/lib/rate.c deleted file mode 100644 index 4f43bb2e5..000000000 --- a/Engine/lib/libtheora/lib/rate.c +++ /dev/null @@ -1,1137 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: rate.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#include -#include -#include "encint.h" - -/*A rough lookup table for tan(x), 0<=x>24; - if(i>=17)i=16; - t0=OC_ROUGH_TAN_LOOKUP[i]; - t1=OC_ROUGH_TAN_LOOKUP[i+1]; - d=_alpha*36-(i<<24); - return (int)(((ogg_int64_t)t0<<32)+(t1-t0<<8)*(ogg_int64_t)d>>32); -} - -/*Re-initialize the Bessel filter coefficients with the specified delay. - This does not alter the x/y state, but changes the reaction time of the - filter. - Altering the time constant of a reactive filter without alterning internal - state is something that has to be done carefuly, but our design operates at - high enough delays and with small enough time constant changes to make it - safe.*/ -static void oc_iir_filter_reinit(oc_iir_filter *_f,int _delay){ - int alpha; - ogg_int64_t one48; - ogg_int64_t warp; - ogg_int64_t k1; - ogg_int64_t k2; - ogg_int64_t d; - ogg_int64_t a; - ogg_int64_t ik2; - ogg_int64_t b1; - ogg_int64_t b2; - /*This borrows some code from an unreleased version of Postfish. - See the recipe at http://unicorn.us.com/alex/2polefilters.html for details - on deriving the filter coefficients.*/ - /*alpha is Q24*/ - alpha=(1<<24)/_delay; - one48=(ogg_int64_t)1<<48; - /*warp is 7.12*/ - warp=OC_MAXI(oc_warp_alpha(alpha),1); - /*k1 is 9.12*/ - k1=3*warp; - /*k2 is 16.24.*/ - k2=k1*warp; - /*d is 16.15.*/ - d=((1<<12)+k1<<12)+k2+256>>9; - /*a is 0.32, since d is larger than both 1.0 and k2.*/ - a=(k2<<23)/d; - /*ik2 is 25.24.*/ - ik2=one48/k2; - /*b1 is Q56; in practice, the integer ranges between -2 and 2.*/ - b1=2*a*(ik2-(1<<24)); - /*b2 is Q56; in practice, the integer ranges between -2 and 2.*/ - b2=(one48<<8)-(4*a<<24)-b1; - /*All of the filter parameters are Q24.*/ - _f->c[0]=(ogg_int32_t)(b1+((ogg_int64_t)1<<31)>>32); - _f->c[1]=(ogg_int32_t)(b2+((ogg_int64_t)1<<31)>>32); - _f->g=(ogg_int32_t)(a+128>>8); -} - -/*Initialize a 2nd order low-pass Bessel filter with the corresponding delay - and initial value. - _value is Q24.*/ -static void oc_iir_filter_init(oc_iir_filter *_f,int _delay,ogg_int32_t _value){ - oc_iir_filter_reinit(_f,_delay); - _f->y[1]=_f->y[0]=_f->x[1]=_f->x[0]=_value; -} - -static ogg_int64_t oc_iir_filter_update(oc_iir_filter *_f,ogg_int32_t _x){ - ogg_int64_t c0; - ogg_int64_t c1; - ogg_int64_t g; - ogg_int64_t x0; - ogg_int64_t x1; - ogg_int64_t y0; - ogg_int64_t y1; - ogg_int64_t ya; - c0=_f->c[0]; - c1=_f->c[1]; - g=_f->g; - x0=_f->x[0]; - x1=_f->x[1]; - y0=_f->y[0]; - y1=_f->y[1]; - ya=(_x+x0*2+x1)*g+y0*c0+y1*c1+(1<<23)>>24; - _f->x[1]=(ogg_int32_t)x0; - _f->x[0]=_x; - _f->y[1]=(ogg_int32_t)y0; - _f->y[0]=(ogg_int32_t)ya; - return ya; -} - - - -/*Search for the quantizer that matches the target most closely. - We don't assume a linear ordering, but when there are ties we pick the - quantizer closest to the old one.*/ -static int oc_enc_find_qi_for_target(oc_enc_ctx *_enc,int _qti,int _qi_old, - int _qi_min,ogg_int64_t _log_qtarget){ - ogg_int64_t best_qdiff; - int best_qi; - int qi; - best_qi=_qi_min; - best_qdiff=_enc->log_qavg[_qti][best_qi]-_log_qtarget; - best_qdiff=best_qdiff+OC_SIGNMASK(best_qdiff)^OC_SIGNMASK(best_qdiff); - for(qi=_qi_min+1;qi<64;qi++){ - ogg_int64_t qdiff; - qdiff=_enc->log_qavg[_qti][qi]-_log_qtarget; - qdiff=qdiff+OC_SIGNMASK(qdiff)^OC_SIGNMASK(qdiff); - if(qdiffstate.qis[0]; - /*If rate control is active, use the lambda for the _target_ quantizer. - This allows us to scale to rates slightly lower than we'd normally be able - to reach, and give the rate control a semblance of "fractional qi" - precision. - TODO: Add API for changing QI, and allow extra precision.*/ - if(_enc->state.info.target_bitrate>0)lq=_enc->rc.log_qtarget; - else lq=_enc->log_qavg[_qti][qi]; - /*The resulting lambda value is less than 0x500000.*/ - _enc->lambda=(int)oc_bexp64(2*lq-0x4780BD468D6B62BLL); - /*Select additional quantizers. - The R-D optimal block AC quantizer statistics suggest that the distribution - is roughly Gaussian-like with a slight positive skew. - K-means clustering on log_qavg to select 3 quantizers produces cluster - centers of {log_qavg-0.6,log_qavg,log_qavg+0.7}. - Experiments confirm these are relatively good choices. - - Although we do greedy R-D optimization of the qii flags to avoid switching - too frequently, this becomes ineffective at low rates, either because we - do a poor job of predicting the actual R-D cost, or the greedy - optimization is not sufficient. - Therefore adaptive quantization is disabled above an (experimentally - suggested) threshold of log_qavg=7.00 (e.g., below INTRA qi=12 or - INTER qi=20 with current matrices). - This may need to be revised if the R-D cost estimation or qii flag - optimization strategies change.*/ - nqis=1; - if(lq<(OC_Q57(56)>>3)&&!_enc->vp3_compatible){ - qi1=oc_enc_find_qi_for_target(_enc,_qti,OC_MAXI(qi-1,0),0, - lq+(OC_Q57(7)+5)/10); - if(qi1!=qi)_enc->state.qis[nqis++]=qi1; - qi1=oc_enc_find_qi_for_target(_enc,_qti,OC_MINI(qi+1,63),0, - lq-(OC_Q57(6)+5)/10); - if(qi1!=qi&&qi1!=_enc->state.qis[nqis-1])_enc->state.qis[nqis++]=qi1; - } - _enc->state.nqis=nqis; -} - -/*Binary exponential of _log_scale with 24-bit fractional precision and - saturation. - _log_scale: A binary logarithm in Q24 format. - Return: The binary exponential in Q24 format, saturated to 2**47-1 if - _log_scale was too large.*/ -static ogg_int64_t oc_bexp_q24(ogg_int32_t _log_scale){ - if(_log_scale<(ogg_int32_t)23<<24){ - ogg_int64_t ret; - ret=oc_bexp64(((ogg_int64_t)_log_scale<<33)+OC_Q57(24)); - return ret<0x7FFFFFFFFFFFLL?ret:0x7FFFFFFFFFFFLL; - } - return 0x7FFFFFFFFFFFLL; -} - -/*Convenience function converts Q57 value to a clamped 32-bit Q24 value - _in: input in Q57 format. - Return: same number in Q24 */ -static ogg_int32_t oc_q57_to_q24(ogg_int64_t _in){ - ogg_int64_t ret; - ret=_in+((ogg_int64_t)1<<32)>>33; - /*0x80000000 is automatically converted to unsigned on 32-bit systems. - -0x7FFFFFFF-1 is needed to avoid "promoting" the whole expression to - unsigned.*/ - return (ogg_int32_t)OC_CLAMPI(-0x7FFFFFFF-1,ret,0x7FFFFFFF); -} - -/*Binary exponential of _log_scale with 24-bit fractional precision and - saturation. - _log_scale: A binary logarithm in Q57 format. - Return: The binary exponential in Q24 format, saturated to 2**31-1 if - _log_scale was too large.*/ -static ogg_int32_t oc_bexp64_q24(ogg_int64_t _log_scale){ - if(_log_scalerc.bits_per_frame=(_enc->state.info.target_bitrate* - (ogg_int64_t)_enc->state.info.fps_denominator)/ - _enc->state.info.fps_numerator; - /*Insane framerates or frame sizes mean insane bitrates. - Let's not get carried away.*/ - if(_enc->rc.bits_per_frame>0x400000000000LL){ - _enc->rc.bits_per_frame=(ogg_int64_t)0x400000000000LL; - } - else if(_enc->rc.bits_per_frame<32)_enc->rc.bits_per_frame=32; - _enc->rc.buf_delay=OC_MAXI(_enc->rc.buf_delay,12); - _enc->rc.max=_enc->rc.bits_per_frame*_enc->rc.buf_delay; - /*Start with a buffer fullness of 50% plus 25% of the amount we plan to spend - on a single keyframe interval. - We can require fully half the bits in an interval for a keyframe, so this - initial level gives us maximum flexibility for over/under-shooting in - subsequent frames.*/ - _enc->rc.target=(_enc->rc.max+1>>1)+(_enc->rc.bits_per_frame+2>>2)* - OC_MINI(_enc->keyframe_frequency_force,_enc->rc.buf_delay); - _enc->rc.fullness=_enc->rc.target; - /*Pick exponents and initial scales for quantizer selection.*/ - npixels=_enc->state.info.frame_width* - (ogg_int64_t)_enc->state.info.frame_height; - _enc->rc.log_npixels=oc_blog64(npixels); - ibpp=npixels/_enc->rc.bits_per_frame; - if(ibpp<1){ - _enc->rc.exp[0]=59; - _enc->rc.log_scale[0]=oc_blog64(1997)-OC_Q57(8); - } - else if(ibpp<2){ - _enc->rc.exp[0]=55; - _enc->rc.log_scale[0]=oc_blog64(1604)-OC_Q57(8); - } - else{ - _enc->rc.exp[0]=48; - _enc->rc.log_scale[0]=oc_blog64(834)-OC_Q57(8); - } - if(ibpp<4){ - _enc->rc.exp[1]=100; - _enc->rc.log_scale[1]=oc_blog64(2249)-OC_Q57(8); - } - else if(ibpp<8){ - _enc->rc.exp[1]=95; - _enc->rc.log_scale[1]=oc_blog64(1751)-OC_Q57(8); - } - else{ - _enc->rc.exp[1]=73; - _enc->rc.log_scale[1]=oc_blog64(1260)-OC_Q57(8); - } - _enc->rc.prev_drop_count=0; - _enc->rc.log_drop_scale=OC_Q57(0); - /*Set up second order followers, initialized according to corresponding - time constants.*/ - oc_iir_filter_init(&_enc->rc.scalefilter[0],4, - oc_q57_to_q24(_enc->rc.log_scale[0])); - inter_delay=(_enc->rc.twopass? - OC_MAXI(_enc->keyframe_frequency_force,12):_enc->rc.buf_delay)>>1; - _enc->rc.inter_count=0; - /*We clamp the actual inter_delay to a minimum of 10 to work within the range - of values where later incrementing the delay works as designed. - 10 is not an exact choice, but rather a good working trade-off.*/ - _enc->rc.inter_delay=10; - _enc->rc.inter_delay_target=inter_delay; - oc_iir_filter_init(&_enc->rc.scalefilter[1],_enc->rc.inter_delay, - oc_q57_to_q24(_enc->rc.log_scale[1])); - oc_iir_filter_init(&_enc->rc.vfrfilter,4, - oc_bexp64_q24(_enc->rc.log_drop_scale)); -} - -void oc_rc_state_init(oc_rc_state *_rc,oc_enc_ctx *_enc){ - _rc->twopass=0; - _rc->twopass_buffer_bytes=0; - _rc->twopass_force_kf=0; - _rc->frame_metrics=NULL; - _rc->rate_bias=0; - if(_enc->state.info.target_bitrate>0){ - /*The buffer size is set equal to the keyframe interval, clamped to the - range [12,256] frames. - The 12 frame minimum gives us some chance to distribute bit estimation - errors. - The 256 frame maximum means we'll require 8-10 seconds of pre-buffering - at 24-30 fps, which is not unreasonable.*/ - _rc->buf_delay=_enc->keyframe_frequency_force>256? - 256:_enc->keyframe_frequency_force; - /*By default, enforce all buffer constraints.*/ - _rc->drop_frames=1; - _rc->cap_overflow=1; - _rc->cap_underflow=0; - oc_enc_rc_reset(_enc); - } -} - -void oc_rc_state_clear(oc_rc_state *_rc){ - _ogg_free(_rc->frame_metrics); -} - -void oc_enc_rc_resize(oc_enc_ctx *_enc){ - /*If encoding has not yet begun, reset the buffer state.*/ - if(_enc->state.curframe_num<0)oc_enc_rc_reset(_enc); - else{ - int idt; - /*Otherwise, update the bounds on the buffer, but not the current - fullness.*/ - _enc->rc.bits_per_frame=(_enc->state.info.target_bitrate* - (ogg_int64_t)_enc->state.info.fps_denominator)/ - _enc->state.info.fps_numerator; - /*Insane framerates or frame sizes mean insane bitrates. - Let's not get carried away.*/ - if(_enc->rc.bits_per_frame>0x400000000000LL){ - _enc->rc.bits_per_frame=(ogg_int64_t)0x400000000000LL; - } - else if(_enc->rc.bits_per_frame<32)_enc->rc.bits_per_frame=32; - _enc->rc.buf_delay=OC_MAXI(_enc->rc.buf_delay,12); - _enc->rc.max=_enc->rc.bits_per_frame*_enc->rc.buf_delay; - _enc->rc.target=(_enc->rc.max+1>>1)+(_enc->rc.bits_per_frame+2>>2)* - OC_MINI(_enc->keyframe_frequency_force,_enc->rc.buf_delay); - /*Update the INTER-frame scale filter delay. - We jump to it immediately if we've already seen enough frames; otherwise - it is simply set as the new target.*/ - _enc->rc.inter_delay_target=idt=OC_MAXI(_enc->rc.buf_delay>>1,10); - if(idtrc.inter_delay,_enc->rc.inter_count)){ - oc_iir_filter_init(&_enc->rc.scalefilter[1],idt, - _enc->rc.scalefilter[1].y[0]); - _enc->rc.inter_delay=idt; - } - } - /*If we're in pass-2 mode, make sure the frame metrics array is big enough - to hold frame statistics for the full buffer.*/ - if(_enc->rc.twopass==2){ - int cfm; - int buf_delay; - int reset_window; - buf_delay=_enc->rc.buf_delay; - reset_window=_enc->rc.frame_metrics==NULL&&(_enc->rc.frames_total[0]==0|| - buf_delay<_enc->rc.frames_total[0]+_enc->rc.frames_total[1] - +_enc->rc.frames_total[2]); - cfm=_enc->rc.cframe_metrics; - /*Only try to resize the frame metrics buffer if a) it's too small and - b) we were using a finite buffer, or are about to start.*/ - if(cfmrc.frame_metrics!=NULL||reset_window)){ - oc_frame_metrics *fm; - int nfm; - int fmh; - fm=(oc_frame_metrics *)_ogg_realloc(_enc->rc.frame_metrics, - buf_delay*sizeof(*_enc->rc.frame_metrics)); - if(fm==NULL){ - /*We failed to allocate a finite buffer.*/ - /*If we don't have a valid 2-pass header yet, just return; we'll reset - the buffer size when we read the header.*/ - if(_enc->rc.frames_total[0]==0)return; - /*Otherwise revert to the largest finite buffer previously set, or to - whole-file buffering if we were still using that.*/ - _enc->rc.buf_delay=_enc->rc.frame_metrics!=NULL? - cfm:_enc->rc.frames_total[0]+_enc->rc.frames_total[1] - +_enc->rc.frames_total[2]; - oc_enc_rc_resize(_enc); - return; - } - _enc->rc.frame_metrics=fm; - _enc->rc.cframe_metrics=buf_delay; - /*Re-organize the circular buffer.*/ - fmh=_enc->rc.frame_metrics_head; - nfm=_enc->rc.nframe_metrics; - if(fmh+nfm>cfm){ - int shift; - shift=OC_MINI(fmh+nfm-cfm,buf_delay-cfm); - memcpy(fm+cfm,fm,OC_MINI(fmh+nfm-cfm,buf_delay-cfm)*sizeof(*fm)); - if(fmh+nfm>buf_delay)memmove(fm,fm+shift,fmh+nfm-buf_delay); - } - } - /*We were using whole-file buffering; now we're not.*/ - if(reset_window){ - _enc->rc.nframes[0]=_enc->rc.nframes[1]=_enc->rc.nframes[2]=0; - _enc->rc.scale_sum[0]=_enc->rc.scale_sum[1]=0; - _enc->rc.scale_window_end=_enc->rc.scale_window0= - _enc->state.curframe_num+_enc->prev_dup_count+1; - if(_enc->rc.twopass_buffer_bytes){ - int qti; - /*We already read the metrics for the first frame in the window.*/ - *(_enc->rc.frame_metrics)=*&_enc->rc.cur_metrics; - _enc->rc.nframe_metrics++; - qti=_enc->rc.cur_metrics.frame_type; - _enc->rc.nframes[qti]++; - _enc->rc.nframes[2]+=_enc->rc.cur_metrics.dup_count; - _enc->rc.scale_sum[qti]+=oc_bexp_q24(_enc->rc.cur_metrics.log_scale); - _enc->rc.scale_window_end+=_enc->rc.cur_metrics.dup_count+1; - if(_enc->rc.scale_window_end-_enc->rc.scale_window0rc.twopass_buffer_bytes=0; - } - } - } - /*Otherwise, we could shrink the size of the current window, if necessary, - but leaving it like it is lets us adapt to the new buffer size more - gracefully.*/ - } -} - -/*Scale the number of frames by the number of expected drops/duplicates.*/ -static int oc_rc_scale_drop(oc_rc_state *_rc,int _nframes){ - if(_rc->prev_drop_count>0||_rc->log_drop_scale>OC_Q57(0)){ - ogg_int64_t dup_scale; - dup_scale=oc_bexp64((_rc->log_drop_scale - +oc_blog64(_rc->prev_drop_count+1)>>1)+OC_Q57(8)); - if(dup_scale<_nframes<<8){ - int dup_scalei; - dup_scalei=(int)dup_scale; - if(dup_scalei>0)_nframes=((_nframes<<8)+dup_scalei-1)/dup_scalei; - } - else _nframes=!!_nframes; - } - return _nframes; -} - -int oc_enc_select_qi(oc_enc_ctx *_enc,int _qti,int _clamp){ - ogg_int64_t rate_total; - ogg_int64_t rate_bias; - int nframes[2]; - int buf_delay; - int buf_pad; - ogg_int64_t log_qtarget; - ogg_int64_t log_scale0; - ogg_int64_t log_cur_scale; - ogg_int64_t log_qexp; - int exp0; - int old_qi; - int qi; - /*Figure out how to re-distribute bits so that we hit our fullness target - before the last keyframe in our current buffer window (after the current - frame), or the end of the buffer window, whichever comes first.*/ - log_cur_scale=(ogg_int64_t)_enc->rc.scalefilter[_qti].y[0]<<33; - buf_pad=0; - switch(_enc->rc.twopass){ - default:{ - ogg_uint32_t next_key_frame; - /*Single pass mode: assume only forced keyframes and attempt to estimate - the drop count for VFR content.*/ - next_key_frame=_qti?_enc->keyframe_frequency_force - -(_enc->state.curframe_num-_enc->state.keyframe_num):0; - nframes[0]=(_enc->rc.buf_delay-OC_MINI(next_key_frame,_enc->rc.buf_delay) - +_enc->keyframe_frequency_force-1)/_enc->keyframe_frequency_force; - if(nframes[0]+_qti>1){ - nframes[0]--; - buf_delay=next_key_frame+nframes[0]*_enc->keyframe_frequency_force; - } - else buf_delay=_enc->rc.buf_delay; - nframes[1]=buf_delay-nframes[0]; - /*Downgrade the delta frame rate to correspond to the recent drop count - history.*/ - nframes[1]=oc_rc_scale_drop(&_enc->rc,nframes[1]); - }break; - case 1:{ - /*Pass 1 mode: use a fixed qi value.*/ - qi=_enc->state.qis[0]; - _enc->rc.log_qtarget=_enc->log_qavg[_qti][qi]; - return qi; - }break; - case 2:{ - ogg_int64_t scale_sum[2]; - int qti; - /*Pass 2 mode: we know exactly how much of each frame type there is in - the current buffer window, and have estimates for the scales.*/ - nframes[0]=_enc->rc.nframes[0]; - nframes[1]=_enc->rc.nframes[1]; - scale_sum[0]=_enc->rc.scale_sum[0]; - scale_sum[1]=_enc->rc.scale_sum[1]; - /*The window size can be slightly larger than the buffer window for VFR - content; clamp it down, if appropriate (the excess will all be dup - frames).*/ - buf_delay=OC_MINI(_enc->rc.scale_window_end-_enc->rc.scale_window0, - _enc->rc.buf_delay); - /*If we're approaching the end of the file, add some slack to keep us - from slamming into a rail. - Our rate accuracy goes down, but it keeps the result sensible. - We position the target where the first forced keyframe beyond the end - of the file would be (for consistency with 1-pass mode).*/ - buf_pad=OC_MINI(_enc->rc.buf_delay,_enc->state.keyframe_num - +_enc->keyframe_frequency_force-_enc->rc.scale_window0); - if(buf_delayrc.frame_metrics!=NULL){ - int fmi; - int fm_tail; - fm_tail=_enc->rc.frame_metrics_head+_enc->rc.nframe_metrics; - if(fm_tail>=_enc->rc.cframe_metrics)fm_tail-=_enc->rc.cframe_metrics; - for(fmi=fm_tail;;){ - oc_frame_metrics *m; - fmi--; - if(fmi<0)fmi+=_enc->rc.cframe_metrics; - /*Stop before we remove the first frame.*/ - if(fmi==_enc->rc.frame_metrics_head)break; - m=_enc->rc.frame_metrics+fmi; - /*If we find a keyframe, remove it and everything past it.*/ - if(m->frame_type==OC_INTRA_FRAME){ - do{ - qti=m->frame_type; - nframes[qti]--; - scale_sum[qti]-=oc_bexp_q24(m->log_scale); - buf_delay-=m->dup_count+1; - fmi++; - if(fmi>=_enc->rc.cframe_metrics)fmi=0; - m=_enc->rc.frame_metrics+fmi; - } - while(fmi!=fm_tail); - /*And stop scanning backwards.*/ - break; - } - } - } - } - /*If we're not using the same frame type as in pass 1 (because someone - changed the keyframe interval), remove that scale estimate. - We'll add in a replacement for the correct frame type below.*/ - qti=_enc->rc.cur_metrics.frame_type; - if(qti!=_qti){ - nframes[qti]--; - scale_sum[qti]-=oc_bexp_q24(_enc->rc.cur_metrics.log_scale); - } - /*Compute log_scale estimates for each frame type from the pass-1 scales - we measured in the current window.*/ - for(qti=0;qti<2;qti++){ - _enc->rc.log_scale[qti]=nframes[qti]>0? - oc_blog64(scale_sum[qti])-oc_blog64(nframes[qti])-OC_Q57(24): - -_enc->rc.log_npixels; - } - /*If we're not using the same frame type as in pass 1, add a scale - estimate for the corresponding frame using the current low-pass - filter value. - This is mostly to ensure we have a valid estimate even when pass 1 had - no frames of this type in the buffer window. - TODO: We could also plan ahead and figure out how many keyframes we'll - be forced to add in the current buffer window.*/ - qti=_enc->rc.cur_metrics.frame_type; - if(qti!=_qti){ - ogg_int64_t scale; - scale=_enc->rc.log_scale[_qti]rc.log_scale[_qti]+OC_Q57(24)):0x7FFFFFFFFFFFLL; - scale*=nframes[_qti]; - nframes[_qti]++; - scale+=oc_bexp_q24(log_cur_scale>>33); - _enc->rc.log_scale[_qti]=oc_blog64(scale) - -oc_blog64(nframes[qti])-OC_Q57(24); - } - else log_cur_scale=(ogg_int64_t)_enc->rc.cur_metrics.log_scale<<33; - /*Add the padding from above. - This basically reverts to 1-pass estimations in the last keyframe - interval.*/ - if(buf_pad>0){ - ogg_int64_t scale; - int nextra_frames; - /*Extend the buffer.*/ - buf_delay+=buf_pad; - /*Add virtual delta frames according to the estimated drop count.*/ - nextra_frames=oc_rc_scale_drop(&_enc->rc,buf_pad); - /*And blend in the low-pass filtered scale according to how many frames - we added.*/ - scale= - oc_bexp64(_enc->rc.log_scale[1]+OC_Q57(24))*(ogg_int64_t)nframes[1] - +oc_bexp_q24(_enc->rc.scalefilter[1].y[0])*(ogg_int64_t)nextra_frames; - nframes[1]+=nextra_frames; - _enc->rc.log_scale[1]=oc_blog64(scale)-oc_blog64(nframes[1])-OC_Q57(24); - } - }break; - } - /*If we've been missing our target, add a penalty term.*/ - rate_bias=(_enc->rc.rate_bias/(_enc->state.curframe_num+1000))* - (buf_delay-buf_pad); - /*rate_total is the total bits available over the next buf_delay frames.*/ - rate_total=_enc->rc.fullness-_enc->rc.target+rate_bias - +buf_delay*_enc->rc.bits_per_frame; - log_scale0=_enc->rc.log_scale[_qti]+_enc->rc.log_npixels; - /*If there aren't enough bits to achieve our desired fullness level, use the - minimum quality permitted.*/ - if(rate_total<=buf_delay)log_qtarget=OC_QUANT_MAX_LOG; - else{ - static const ogg_int64_t LOG_KEY_RATIO=0x0137222BB70747BALL; - ogg_int64_t log_scale1; - ogg_int64_t rlo; - ogg_int64_t rhi; - log_scale1=_enc->rc.log_scale[1-_qti]+_enc->rc.log_npixels; - rlo=0; - rhi=(rate_total+nframes[_qti]-1)/nframes[_qti]; - while(rlo>1; - log_rpow=oc_blog64(curr)-log_scale0; - log_rpow=(log_rpow+(_enc->rc.exp[_qti]>>1))/_enc->rc.exp[_qti]; - if(_qti)log_rpow+=LOG_KEY_RATIO>>6; - else log_rpow-=LOG_KEY_RATIO>>6; - log_rpow*=_enc->rc.exp[1-_qti]; - rscale=nframes[1-_qti]*oc_bexp64(log_scale1+log_rpow); - rdiff=nframes[_qti]*curr+rscale-rate_total; - if(rdiff<0)rlo=curr+1; - else if(rdiff>0)rhi=curr-1; - else break; - } - log_qtarget=OC_Q57(2)-((oc_blog64(rlo)-log_scale0+(_enc->rc.exp[_qti]>>1))/ - _enc->rc.exp[_qti]<<6); - log_qtarget=OC_MINI(log_qtarget,OC_QUANT_MAX_LOG); - } - /*The above allocation looks only at the total rate we'll accumulate in the - next buf_delay frames. - However, we could overflow the buffer on the very next frame, so check for - that here, if we're not using a soft target.*/ - exp0=_enc->rc.exp[_qti]; - if(_enc->rc.cap_overflow){ - ogg_int64_t margin; - ogg_int64_t soft_limit; - ogg_int64_t log_soft_limit; - /*Allow 3% of the buffer for prediction error. - This should be plenty, and we don't mind if we go a bit over; we only - want to keep these bits from being completely wasted.*/ - margin=_enc->rc.max+31>>5; - /*We want to use at least this many bits next frame.*/ - soft_limit=_enc->rc.fullness+_enc->rc.bits_per_frame-(_enc->rc.max-margin); - log_soft_limit=oc_blog64(soft_limit); - /*If we're predicting we won't use that many...*/ - log_qexp=(log_qtarget-OC_Q57(2)>>6)*exp0; - if(log_scale0-log_qexp>32)* - ((OC_MINI(margin,soft_limit)<<32)/margin); - log_qtarget=((log_qexp+(exp0>>1))/exp0<<6)+OC_Q57(2); - } - } - /*If this was not one of the initial frames, limit the change in quality.*/ - old_qi=_enc->state.qis[0]; - if(_clamp){ - ogg_int64_t log_qmin; - ogg_int64_t log_qmax; - /*Clamp the target quantizer to within [0.8*Q,1.2*Q], where Q is the - current quantizer. - TODO: With user-specified quant matrices, we need to enlarge these limits - if they don't actually let us change qi values.*/ - log_qmin=_enc->log_qavg[_qti][old_qi]-0x00A4D3C25E68DC58LL; - log_qmax=_enc->log_qavg[_qti][old_qi]+0x00A4D3C25E68DC58LL; - log_qtarget=OC_CLAMPI(log_qmin,log_qtarget,log_qmax); - } - /*The above allocation looks only at the total rate we'll accumulate in the - next buf_delay frames. - However, we could bust the budget on the very next frame, so check for that - here, if we're not using a soft target.*/ - /* Disabled when our minimum qi > 0; if we saturate log_qtarget to - to the maximum possible size when we have a minimum qi, the - resulting lambda will interact very strangely with SKIP. The - resulting artifacts look like waterfalls. */ - if(_enc->state.info.quality==0){ - ogg_int64_t log_hard_limit; - /*Compute the maximum number of bits we can use in the next frame. - Allow 50% of the rate for a single frame for prediction error. - This may not be enough for keyframes or sudden changes in complexity.*/ - log_hard_limit=oc_blog64(_enc->rc.fullness+(_enc->rc.bits_per_frame>>1)); - /*If we're predicting we'll use more than this...*/ - log_qexp=(log_qtarget-OC_Q57(2)>>6)*exp0; - if(log_scale0-log_qexp>log_hard_limit){ - /*Force the target to hit our limit exactly.*/ - log_qexp=log_scale0-log_hard_limit; - log_qtarget=((log_qexp+(exp0>>1))/exp0<<6)+OC_Q57(2); - /*If that target is unreasonable, oh well; we'll have to drop.*/ - log_qtarget=OC_MINI(log_qtarget,OC_QUANT_MAX_LOG); - } - } - /*Compute a final estimate of the number of bits we plan to use.*/ - log_qexp=(log_qtarget-OC_Q57(2)>>6)*_enc->rc.exp[_qti]; - _enc->rc.rate_bias+=oc_bexp64(log_cur_scale+_enc->rc.log_npixels-log_qexp); - qi=oc_enc_find_qi_for_target(_enc,_qti,old_qi, - _enc->state.info.quality,log_qtarget); - /*Save the quantizer target for lambda calculations.*/ - _enc->rc.log_qtarget=log_qtarget; - return qi; -} - -int oc_enc_update_rc_state(oc_enc_ctx *_enc, - long _bits,int _qti,int _qi,int _trial,int _droppable){ - ogg_int64_t buf_delta; - ogg_int64_t log_scale; - int dropped; - dropped=0; - /* Drop frames also disabled for now in the case of infinite-buffer - two-pass mode */ - if(!_enc->rc.drop_frames||_enc->rc.twopass&&_enc->rc.frame_metrics==NULL){ - _droppable=0; - } - buf_delta=_enc->rc.bits_per_frame*(1+_enc->dup_count); - if(_bits<=0){ - /*We didn't code any blocks in this frame.*/ - log_scale=OC_Q57(-64); - _bits=0; - } - else{ - ogg_int64_t log_bits; - ogg_int64_t log_qexp; - /*Compute the estimated scale factor for this frame type.*/ - log_bits=oc_blog64(_bits); - log_qexp=_enc->rc.log_qtarget-OC_Q57(2); - log_qexp=(log_qexp>>6)*(_enc->rc.exp[_qti]); - log_scale=OC_MINI(log_bits-_enc->rc.log_npixels+log_qexp,OC_Q57(16)); - } - /*Special two-pass processing.*/ - switch(_enc->rc.twopass){ - case 1:{ - /*Pass 1 mode: save the metrics for this frame.*/ - _enc->rc.cur_metrics.log_scale=oc_q57_to_q24(log_scale); - _enc->rc.cur_metrics.dup_count=_enc->dup_count; - _enc->rc.cur_metrics.frame_type=_enc->state.frame_type; - _enc->rc.twopass_buffer_bytes=0; - }break; - case 2:{ - /*Pass 2 mode:*/ - if(!_trial){ - ogg_int64_t next_frame_num; - int qti; - /*Move the current metrics back one frame.*/ - *&_enc->rc.prev_metrics=*&_enc->rc.cur_metrics; - next_frame_num=_enc->state.curframe_num+_enc->dup_count+1; - /*Back out the last frame's statistics from the sliding window.*/ - qti=_enc->rc.prev_metrics.frame_type; - _enc->rc.frames_left[qti]--; - _enc->rc.frames_left[2]-=_enc->rc.prev_metrics.dup_count; - _enc->rc.nframes[qti]--; - _enc->rc.nframes[2]-=_enc->rc.prev_metrics.dup_count; - _enc->rc.scale_sum[qti]-=oc_bexp_q24(_enc->rc.prev_metrics.log_scale); - _enc->rc.scale_window0=(int)next_frame_num; - /*Free the corresponding entry in the circular buffer.*/ - if(_enc->rc.frame_metrics!=NULL){ - _enc->rc.nframe_metrics--; - _enc->rc.frame_metrics_head++; - if(_enc->rc.frame_metrics_head>=_enc->rc.cframe_metrics){ - _enc->rc.frame_metrics_head=0; - } - } - /*Mark us ready for the next 2-pass packet.*/ - _enc->rc.twopass_buffer_bytes=0; - /*Update state, so the user doesn't have to keep calling 2pass_in after - they've fed in all the data when we're using a finite buffer.*/ - _enc->prev_dup_count=_enc->dup_count; - oc_enc_rc_2pass_in(_enc,NULL,0); - } - }break; - } - /*Common to all passes:*/ - if(_bits>0){ - if(_trial){ - oc_iir_filter *f; - /*Use the estimated scale factor directly if this was a trial.*/ - f=_enc->rc.scalefilter+_qti; - f->y[1]=f->y[0]=f->x[1]=f->x[0]=oc_q57_to_q24(log_scale); - _enc->rc.log_scale[_qti]=log_scale; - } - else{ - /*Lengthen the time constant for the INTER filter as we collect more - frame statistics, until we reach our target.*/ - if(_enc->rc.inter_delay<_enc->rc.inter_delay_target&& - _enc->rc.inter_count>=_enc->rc.inter_delay&&_qti==OC_INTER_FRAME){ - oc_iir_filter_reinit(&_enc->rc.scalefilter[1],++_enc->rc.inter_delay); - } - /*Otherwise update the low-pass scale filter for this frame type, - regardless of whether or not we dropped this frame.*/ - _enc->rc.log_scale[_qti]=oc_iir_filter_update( - _enc->rc.scalefilter+_qti,oc_q57_to_q24(log_scale))<<33; - /*If this frame busts our budget, it must be dropped.*/ - if(_droppable&&_enc->rc.fullness+buf_delta<_bits){ - _enc->rc.prev_drop_count+=1+_enc->dup_count; - _bits=0; - dropped=1; - } - else{ - ogg_uint32_t drop_count; - /*Update a low-pass filter to estimate the "real" frame rate taking - drops and duplicates into account. - This is only done if the frame is coded, as it needs the final - count of dropped frames.*/ - drop_count=_enc->rc.prev_drop_count+1; - if(drop_count>0x7F)drop_count=0x7FFFFFFF; - else drop_count<<=24; - _enc->rc.log_drop_scale=oc_blog64(oc_iir_filter_update( - &_enc->rc.vfrfilter,drop_count))-OC_Q57(24); - /*Initialize the drop count for this frame to the user-requested dup - count. - It will be increased if we drop more frames.*/ - _enc->rc.prev_drop_count=_enc->dup_count; - } - } - /*Increment the INTER frame count, for filter adaptation purposes.*/ - if(_enc->rc.inter_countrc.inter_count+=_qti; - } - /*Increase the drop count.*/ - else _enc->rc.prev_drop_count+=1+_enc->dup_count; - /*And update the buffer fullness level.*/ - if(!_trial){ - _enc->rc.fullness+=buf_delta-_bits; - /*If we're too quick filling the buffer and overflow is capped, - that rate is lost forever.*/ - if(_enc->rc.cap_overflow&&_enc->rc.fullness>_enc->rc.max){ - _enc->rc.fullness=_enc->rc.max; - } - /*If we're too quick draining the buffer and underflow is capped, - don't try to make up that rate later.*/ - if(_enc->rc.cap_underflow&&_enc->rc.fullness<0){ - _enc->rc.fullness=0; - } - /*Adjust the bias for the real bits we've used.*/ - _enc->rc.rate_bias-=_bits; - } - return dropped; -} - -#define OC_RC_2PASS_VERSION (1) -#define OC_RC_2PASS_HDR_SZ (38) -#define OC_RC_2PASS_PACKET_SZ (8) - -static void oc_rc_buffer_val(oc_rc_state *_rc,ogg_int64_t _val,int _bytes){ - while(_bytes-->0){ - _rc->twopass_buffer[_rc->twopass_buffer_bytes++]=(unsigned char)(_val&0xFF); - _val>>=8; - } -} - -int oc_enc_rc_2pass_out(oc_enc_ctx *_enc,unsigned char **_buf){ - if(_enc->rc.twopass_buffer_bytes==0){ - if(_enc->rc.twopass==0){ - int qi; - /*Pick first-pass qi for scale calculations.*/ - qi=oc_enc_select_qi(_enc,0,0); - _enc->state.nqis=1; - _enc->state.qis[0]=qi; - _enc->rc.twopass=1; - _enc->rc.frames_total[0]=_enc->rc.frames_total[1]= - _enc->rc.frames_total[2]=0; - _enc->rc.scale_sum[0]=_enc->rc.scale_sum[1]=0; - /*Fill in dummy summary values.*/ - oc_rc_buffer_val(&_enc->rc,0x5032544F,4); - oc_rc_buffer_val(&_enc->rc,OC_RC_2PASS_VERSION,4); - oc_rc_buffer_val(&_enc->rc,0,OC_RC_2PASS_HDR_SZ-8); - } - else{ - int qti; - qti=_enc->rc.cur_metrics.frame_type; - _enc->rc.scale_sum[qti]+=oc_bexp_q24(_enc->rc.cur_metrics.log_scale); - _enc->rc.frames_total[qti]++; - _enc->rc.frames_total[2]+=_enc->rc.cur_metrics.dup_count; - oc_rc_buffer_val(&_enc->rc, - _enc->rc.cur_metrics.dup_count|_enc->rc.cur_metrics.frame_type<<31,4); - oc_rc_buffer_val(&_enc->rc,_enc->rc.cur_metrics.log_scale,4); - } - } - else if(_enc->packet_state==OC_PACKET_DONE&& - _enc->rc.twopass_buffer_bytes!=OC_RC_2PASS_HDR_SZ){ - _enc->rc.twopass_buffer_bytes=0; - oc_rc_buffer_val(&_enc->rc,0x5032544F,4); - oc_rc_buffer_val(&_enc->rc,OC_RC_2PASS_VERSION,4); - oc_rc_buffer_val(&_enc->rc,_enc->rc.frames_total[0],4); - oc_rc_buffer_val(&_enc->rc,_enc->rc.frames_total[1],4); - oc_rc_buffer_val(&_enc->rc,_enc->rc.frames_total[2],4); - oc_rc_buffer_val(&_enc->rc,_enc->rc.exp[0],1); - oc_rc_buffer_val(&_enc->rc,_enc->rc.exp[1],1); - oc_rc_buffer_val(&_enc->rc,_enc->rc.scale_sum[0],8); - oc_rc_buffer_val(&_enc->rc,_enc->rc.scale_sum[1],8); - } - else{ - /*The data for this frame has already been retrieved.*/ - *_buf=NULL; - return 0; - } - *_buf=_enc->rc.twopass_buffer; - return _enc->rc.twopass_buffer_bytes; -} - -static size_t oc_rc_buffer_fill(oc_rc_state *_rc, - unsigned char *_buf,size_t _bytes,size_t _consumed,size_t _goal){ - while(_rc->twopass_buffer_fill<_goal&&_consumed<_bytes){ - _rc->twopass_buffer[_rc->twopass_buffer_fill++]=_buf[_consumed++]; - } - return _consumed; -} - -static ogg_int64_t oc_rc_unbuffer_val(oc_rc_state *_rc,int _bytes){ - ogg_int64_t ret; - int shift; - ret=0; - shift=0; - while(_bytes-->0){ - ret|=((ogg_int64_t)_rc->twopass_buffer[_rc->twopass_buffer_bytes++])<rc.twopass==0){ - _enc->rc.twopass=2; - _enc->rc.twopass_buffer_fill=0; - _enc->rc.frames_total[0]=0; - _enc->rc.nframe_metrics=0; - _enc->rc.cframe_metrics=0; - _enc->rc.frame_metrics_head=0; - _enc->rc.scale_window0=0; - _enc->rc.scale_window_end=0; - } - /*If we haven't got a valid summary header yet, try to parse one.*/ - if(_enc->rc.frames_total[0]==0){ - if(!_buf){ - int frames_needed; - /*If we're using a whole-file buffer, we just need the first frame. - Otherwise, we may need as many as one per buffer slot.*/ - frames_needed=_enc->rc.frame_metrics==NULL?1:_enc->rc.buf_delay; - return OC_RC_2PASS_HDR_SZ+frames_needed*OC_RC_2PASS_PACKET_SZ - -_enc->rc.twopass_buffer_fill; - } - consumed=oc_rc_buffer_fill(&_enc->rc, - _buf,_bytes,consumed,OC_RC_2PASS_HDR_SZ); - if(_enc->rc.twopass_buffer_fill>=OC_RC_2PASS_HDR_SZ){ - ogg_int64_t scale_sum[2]; - int exp[2]; - int buf_delay; - /*Read the summary header data.*/ - /*Check the magic value and version number.*/ - if(oc_rc_unbuffer_val(&_enc->rc,4)!=0x5032544F|| - oc_rc_unbuffer_val(&_enc->rc,4)!=OC_RC_2PASS_VERSION){ - _enc->rc.twopass_buffer_bytes=0; - return TH_ENOTFORMAT; - } - _enc->rc.frames_total[0]=(ogg_uint32_t)oc_rc_unbuffer_val(&_enc->rc,4); - _enc->rc.frames_total[1]=(ogg_uint32_t)oc_rc_unbuffer_val(&_enc->rc,4); - _enc->rc.frames_total[2]=(ogg_uint32_t)oc_rc_unbuffer_val(&_enc->rc,4); - exp[0]=(int)oc_rc_unbuffer_val(&_enc->rc,1); - exp[1]=(int)oc_rc_unbuffer_val(&_enc->rc,1); - scale_sum[0]=oc_rc_unbuffer_val(&_enc->rc,8); - scale_sum[1]=oc_rc_unbuffer_val(&_enc->rc,8); - /*Make sure the file claims to have at least one frame. - Otherwise we probably got the placeholder data from an aborted pass 1. - Also make sure the total frame count doesn't overflow an integer.*/ - buf_delay=_enc->rc.frames_total[0]+_enc->rc.frames_total[1] - +_enc->rc.frames_total[2]; - if(_enc->rc.frames_total[0]==0||buf_delay<0|| - (ogg_uint32_t)buf_delay<_enc->rc.frames_total[0]|| - (ogg_uint32_t)buf_delay<_enc->rc.frames_total[1]){ - _enc->rc.frames_total[0]=0; - _enc->rc.twopass_buffer_bytes=0; - return TH_EBADHEADER; - } - /*Got a valid header; set up pass 2.*/ - _enc->rc.frames_left[0]=_enc->rc.frames_total[0]; - _enc->rc.frames_left[1]=_enc->rc.frames_total[1]; - _enc->rc.frames_left[2]=_enc->rc.frames_total[2]; - /*If the user hasn't specified a buffer size, use the whole file.*/ - if(_enc->rc.frame_metrics==NULL){ - _enc->rc.buf_delay=buf_delay; - _enc->rc.nframes[0]=_enc->rc.frames_total[0]; - _enc->rc.nframes[1]=_enc->rc.frames_total[1]; - _enc->rc.nframes[2]=_enc->rc.frames_total[2]; - _enc->rc.scale_sum[0]=scale_sum[0]; - _enc->rc.scale_sum[1]=scale_sum[1]; - _enc->rc.scale_window_end=buf_delay; - oc_enc_rc_reset(_enc); - } - _enc->rc.exp[0]=exp[0]; - _enc->rc.exp[1]=exp[1]; - /*Clear the header data from the buffer to make room for packet data.*/ - _enc->rc.twopass_buffer_fill=0; - _enc->rc.twopass_buffer_bytes=0; - } - } - if(_enc->rc.frames_total[0]!=0){ - ogg_int64_t curframe_num; - int nframes_total; - curframe_num=_enc->state.curframe_num; - if(curframe_num>=0){ - /*We just encoded a frame; make sure things matched.*/ - if(_enc->rc.prev_metrics.dup_count!=_enc->prev_dup_count){ - _enc->rc.twopass_buffer_bytes=0; - return TH_EINVAL; - } - } - curframe_num+=_enc->prev_dup_count+1; - nframes_total=_enc->rc.frames_total[0]+_enc->rc.frames_total[1] - +_enc->rc.frames_total[2]; - if(curframe_num>=nframes_total){ - /*We don't want any more data after the last frame, and we don't want to - allow any more frames to be encoded.*/ - _enc->rc.twopass_buffer_bytes=0; - } - else if(_enc->rc.twopass_buffer_bytes==0){ - if(_enc->rc.frame_metrics==NULL){ - /*We're using a whole-file buffer:*/ - if(!_buf)return OC_RC_2PASS_PACKET_SZ-_enc->rc.twopass_buffer_fill; - consumed=oc_rc_buffer_fill(&_enc->rc, - _buf,_bytes,consumed,OC_RC_2PASS_PACKET_SZ); - if(_enc->rc.twopass_buffer_fill>=OC_RC_2PASS_PACKET_SZ){ - ogg_uint32_t dup_count; - ogg_int32_t log_scale; - int qti; - int arg; - /*Read the metrics for the next frame.*/ - dup_count=oc_rc_unbuffer_val(&_enc->rc,4); - log_scale=oc_rc_unbuffer_val(&_enc->rc,4); - _enc->rc.cur_metrics.log_scale=log_scale; - qti=(dup_count&0x80000000)>>31; - _enc->rc.cur_metrics.dup_count=dup_count&0x7FFFFFFF; - _enc->rc.cur_metrics.frame_type=qti; - _enc->rc.twopass_force_kf=qti==OC_INTRA_FRAME; - /*"Helpfully" set the dup count back to what it was in pass 1.*/ - arg=_enc->rc.cur_metrics.dup_count; - th_encode_ctl(_enc,TH_ENCCTL_SET_DUP_COUNT,&arg,sizeof(arg)); - /*Clear the buffer for the next frame.*/ - _enc->rc.twopass_buffer_fill=0; - } - } - else{ - int frames_needed; - /*We're using a finite buffer:*/ - frames_needed=OC_CLAMPI(0,_enc->rc.buf_delay - -(_enc->rc.scale_window_end-_enc->rc.scale_window0), - _enc->rc.frames_left[0]+_enc->rc.frames_left[1] - -_enc->rc.nframes[0]-_enc->rc.nframes[1]); - while(frames_needed>0){ - if(!_buf){ - return OC_RC_2PASS_PACKET_SZ*frames_needed - -_enc->rc.twopass_buffer_fill; - } - consumed=oc_rc_buffer_fill(&_enc->rc, - _buf,_bytes,consumed,OC_RC_2PASS_PACKET_SZ); - if(_enc->rc.twopass_buffer_fill>=OC_RC_2PASS_PACKET_SZ){ - oc_frame_metrics *m; - int fmi; - ogg_uint32_t dup_count; - ogg_int32_t log_scale; - int qti; - /*Read the metrics for the next frame.*/ - dup_count=oc_rc_unbuffer_val(&_enc->rc,4); - log_scale=oc_rc_unbuffer_val(&_enc->rc,4); - /*Add the to the circular buffer.*/ - fmi=_enc->rc.frame_metrics_head+_enc->rc.nframe_metrics++; - if(fmi>=_enc->rc.cframe_metrics)fmi-=_enc->rc.cframe_metrics; - m=_enc->rc.frame_metrics+fmi; - m->log_scale=log_scale; - qti=(dup_count&0x80000000)>>31; - m->dup_count=dup_count&0x7FFFFFFF; - m->frame_type=qti; - /*And accumulate the statistics over the window.*/ - _enc->rc.nframes[qti]++; - _enc->rc.nframes[2]+=m->dup_count; - _enc->rc.scale_sum[qti]+=oc_bexp_q24(m->log_scale); - _enc->rc.scale_window_end+=m->dup_count+1; - /*Compute an upper bound on the number of remaining packets needed - for the current window.*/ - frames_needed=OC_CLAMPI(0,_enc->rc.buf_delay - -(_enc->rc.scale_window_end-_enc->rc.scale_window0), - _enc->rc.frames_left[0]+_enc->rc.frames_left[1] - -_enc->rc.nframes[0]-_enc->rc.nframes[1]); - /*Clear the buffer for the next frame.*/ - _enc->rc.twopass_buffer_fill=0; - _enc->rc.twopass_buffer_bytes=0; - } - /*Go back for more data.*/ - else break; - } - /*If we've got all the frames we need, fill in the current metrics. - We're ready to go.*/ - if(frames_needed<=0){ - int arg; - *&_enc->rc.cur_metrics= - *(_enc->rc.frame_metrics+_enc->rc.frame_metrics_head); - _enc->rc.twopass_force_kf= - _enc->rc.cur_metrics.frame_type==OC_INTRA_FRAME; - /*"Helpfully" set the dup count back to what it was in pass 1.*/ - arg=_enc->rc.cur_metrics.dup_count; - th_encode_ctl(_enc,TH_ENCCTL_SET_DUP_COUNT,&arg,sizeof(arg)); - /*Mark us ready for the next frame.*/ - _enc->rc.twopass_buffer_bytes=1; - } - } - } - } - return (int)consumed; -} diff --git a/Engine/lib/libtheora/lib/state.c b/Engine/lib/libtheora/lib/state.c deleted file mode 100644 index 42ed33a9a..000000000 --- a/Engine/lib/libtheora/lib/state.c +++ /dev/null @@ -1,1227 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: state.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include -#include -#include "internal.h" -#if defined(OC_X86_ASM) -#if defined(_MSC_VER) -# include "x86_vc/x86int.h" -#else -# include "x86/x86int.h" -#endif -#endif -#if defined(OC_DUMP_IMAGES) -# include -# include "png.h" -#endif - -/*Returns the fragment index of the top-left block in a macro block. - This can be used to test whether or not the whole macro block is valid. - _sb_map: The super block map. - _quadi: The quadrant number. - Return: The index of the fragment of the upper left block in the macro - block, or -1 if the block lies outside the coded frame.*/ -static ptrdiff_t oc_sb_quad_top_left_frag(oc_sb_map_quad _sb_map[4],int _quadi){ - /*It so happens that under the Hilbert curve ordering described below, the - upper-left block in each macro block is at index 0, except in macro block - 3, where it is at index 2.*/ - return _sb_map[_quadi][_quadi&_quadi<<1]; -} - -/*Fills in the mapping from block positions to fragment numbers for a single - color plane. - This function also fills in the "valid" flag of each quadrant in the super - block flags. - _sb_maps: The array of super block maps for the color plane. - _sb_flags: The array of super block flags for the color plane. - _frag0: The index of the first fragment in the plane. - _hfrags: The number of horizontal fragments in a coded frame. - _vfrags: The number of vertical fragments in a coded frame.*/ -static void oc_sb_create_plane_mapping(oc_sb_map _sb_maps[], - oc_sb_flags _sb_flags[],ptrdiff_t _frag0,int _hfrags,int _vfrags){ - /*Contains the (macro_block,block) indices for a 4x4 grid of - fragments. - The pattern is a 4x4 Hilbert space-filling curve. - A Hilbert curve has the nice property that as the curve grows larger, its - fractal dimension approaches 2. - The intuition is that nearby blocks in the curve are also close spatially, - with the previous element always an immediate neighbor, so that runs of - blocks should be well correlated.*/ - static const int SB_MAP[4][4][2]={ - {{0,0},{0,1},{3,2},{3,3}}, - {{0,3},{0,2},{3,1},{3,0}}, - {{1,0},{1,3},{2,0},{2,3}}, - {{1,1},{1,2},{2,1},{2,2}} - }; - ptrdiff_t yfrag; - unsigned sbi; - int y; - sbi=0; - yfrag=_frag0; - for(y=0;;y+=4){ - int imax; - int x; - /*Figure out how many columns of blocks in this super block lie within the - image.*/ - imax=_vfrags-y; - if(imax>4)imax=4; - else if(imax<=0)break; - for(x=0;;x+=4,sbi++){ - ptrdiff_t xfrag; - int jmax; - int quadi; - int i; - /*Figure out how many rows of blocks in this super block lie within the - image.*/ - jmax=_hfrags-x; - if(jmax>4)jmax=4; - else if(jmax<=0)break; - /*By default, set all fragment indices to -1.*/ - memset(_sb_maps[sbi][0],0xFF,sizeof(_sb_maps[sbi])); - /*Fill in the fragment map for this super block.*/ - xfrag=yfrag+x; - for(i=0;i=0)<nhfrags+_xfrag0+j; - } -} - -/*Fills in the chroma plane fragment maps for a macro block. - This version is for use with chroma decimated in the X and Y directions - (4:2:0). - _mb_map: The macro block map to fill. - _fplanes: The descriptions of the fragment planes. - _xfrag0: The X location of the upper-left hand fragment in the luma plane. - _yfrag0: The Y location of the upper-left hand fragment in the luma plane.*/ -static void oc_mb_fill_cmapping00(oc_mb_map_plane _mb_map[3], - const oc_fragment_plane _fplanes[3],int _xfrag0,int _yfrag0){ - ptrdiff_t fragi; - _xfrag0>>=1; - _yfrag0>>=1; - fragi=_yfrag0*(ptrdiff_t)_fplanes[1].nhfrags+_xfrag0; - _mb_map[1][0]=fragi+_fplanes[1].froffset; - _mb_map[2][0]=fragi+_fplanes[2].froffset; -} - -/*Fills in the chroma plane fragment maps for a macro block. - This version is for use with chroma decimated in the Y direction. - _mb_map: The macro block map to fill. - _fplanes: The descriptions of the fragment planes. - _xfrag0: The X location of the upper-left hand fragment in the luma plane. - _yfrag0: The Y location of the upper-left hand fragment in the luma plane.*/ -static void oc_mb_fill_cmapping01(oc_mb_map_plane _mb_map[3], - const oc_fragment_plane _fplanes[3],int _xfrag0,int _yfrag0){ - ptrdiff_t fragi; - int j; - _yfrag0>>=1; - fragi=_yfrag0*(ptrdiff_t)_fplanes[1].nhfrags+_xfrag0; - for(j=0;j<2;j++){ - _mb_map[1][j]=fragi+_fplanes[1].froffset; - _mb_map[2][j]=fragi+_fplanes[2].froffset; - fragi++; - } -} - -/*Fills in the chroma plane fragment maps for a macro block. - This version is for use with chroma decimated in the X direction (4:2:2). - _mb_map: The macro block map to fill. - _fplanes: The descriptions of the fragment planes. - _xfrag0: The X location of the upper-left hand fragment in the luma plane. - _yfrag0: The Y location of the upper-left hand fragment in the luma plane.*/ -static void oc_mb_fill_cmapping10(oc_mb_map_plane _mb_map[3], - const oc_fragment_plane _fplanes[3],int _xfrag0,int _yfrag0){ - ptrdiff_t fragi; - int i; - _xfrag0>>=1; - fragi=_yfrag0*(ptrdiff_t)_fplanes[1].nhfrags+_xfrag0; - for(i=0;i<2;i++){ - _mb_map[1][i<<1]=fragi+_fplanes[1].froffset; - _mb_map[2][i<<1]=fragi+_fplanes[2].froffset; - fragi+=_fplanes[1].nhfrags; - } -} - -/*Fills in the chroma plane fragment maps for a macro block. - This version is for use with no chroma decimation (4:4:4). - This uses the already filled-in luma plane values. - _mb_map: The macro block map to fill. - _fplanes: The descriptions of the fragment planes.*/ -static void oc_mb_fill_cmapping11(oc_mb_map_plane _mb_map[3], - const oc_fragment_plane _fplanes[3]){ - int k; - for(k=0;k<4;k++){ - _mb_map[1][k]=_mb_map[0][k]+_fplanes[1].froffset; - _mb_map[2][k]=_mb_map[0][k]+_fplanes[2].froffset; - } -} - -/*The function type used to fill in the chroma plane fragment maps for a - macro block. - _mb_map: The macro block map to fill. - _fplanes: The descriptions of the fragment planes. - _xfrag0: The X location of the upper-left hand fragment in the luma plane. - _yfrag0: The Y location of the upper-left hand fragment in the luma plane.*/ -typedef void (*oc_mb_fill_cmapping_func)(oc_mb_map_plane _mb_map[3], - const oc_fragment_plane _fplanes[3],int _xfrag0,int _yfrag0); - -/*A table of functions used to fill in the chroma plane fragment maps for a - macro block for each type of chrominance decimation.*/ -static const oc_mb_fill_cmapping_func OC_MB_FILL_CMAPPING_TABLE[4]={ - oc_mb_fill_cmapping00, - oc_mb_fill_cmapping01, - oc_mb_fill_cmapping10, - (oc_mb_fill_cmapping_func)oc_mb_fill_cmapping11 -}; - -/*Fills in the mapping from macro blocks to their corresponding fragment - numbers in each plane. - _mb_maps: The list of macro block maps. - _mb_modes: The list of macro block modes; macro blocks completely outside - the coded region are marked invalid. - _fplanes: The descriptions of the fragment planes. - _pixel_fmt: The chroma decimation type.*/ -static void oc_mb_create_mapping(oc_mb_map _mb_maps[], - signed char _mb_modes[],const oc_fragment_plane _fplanes[3],int _pixel_fmt){ - oc_mb_fill_cmapping_func mb_fill_cmapping; - unsigned sbi; - int y; - mb_fill_cmapping=OC_MB_FILL_CMAPPING_TABLE[_pixel_fmt]; - /*Loop through the luma plane super blocks.*/ - for(sbi=y=0;y<_fplanes[0].nvfrags;y+=4){ - int x; - for(x=0;x<_fplanes[0].nhfrags;x+=4,sbi++){ - int ymb; - /*Loop through the macro blocks in each super block in display order.*/ - for(ymb=0;ymb<2;ymb++){ - int xmb; - for(xmb=0;xmb<2;xmb++){ - unsigned mbi; - int mbx; - int mby; - mbi=sbi<<2|OC_MB_MAP[ymb][xmb]; - mbx=x|xmb<<1; - mby=y|ymb<<1; - /*Initialize fragment indices to -1.*/ - memset(_mb_maps[mbi],0xFF,sizeof(_mb_maps[mbi])); - /*Make sure this macro block is within the encoded region.*/ - if(mbx>=_fplanes[0].nhfrags||mby>=_fplanes[0].nvfrags){ - _mb_modes[mbi]=OC_MODE_INVALID; - continue; - } - /*Fill in the fragment indices for the luma plane.*/ - oc_mb_fill_ymapping(_mb_maps[mbi],_fplanes,mbx,mby); - /*Fill in the fragment indices for the chroma planes.*/ - (*mb_fill_cmapping)(_mb_maps[mbi],_fplanes,mbx,mby); - } - } - } - } -} - -/*Marks the fragments which fall all or partially outside the displayable - region of the frame. - _state: The Theora state containing the fragments to be marked.*/ -static void oc_state_border_init(oc_theora_state *_state){ - oc_fragment *frag; - oc_fragment *yfrag_end; - oc_fragment *xfrag_end; - oc_fragment_plane *fplane; - int crop_x0; - int crop_y0; - int crop_xf; - int crop_yf; - int pli; - int y; - int x; - /*The method we use here is slow, but the code is dead simple and handles - all the special cases easily. - We only ever need to do it once.*/ - /*Loop through the fragments, marking those completely outside the - displayable region and constructing a border mask for those that straddle - the border.*/ - _state->nborders=0; - yfrag_end=frag=_state->frags; - for(pli=0;pli<3;pli++){ - fplane=_state->fplanes+pli; - /*Set up the cropping rectangle for this plane.*/ - crop_x0=_state->info.pic_x; - crop_xf=_state->info.pic_x+_state->info.pic_width; - crop_y0=_state->info.pic_y; - crop_yf=_state->info.pic_y+_state->info.pic_height; - if(pli>0){ - if(!(_state->info.pixel_fmt&1)){ - crop_x0=crop_x0>>1; - crop_xf=crop_xf+1>>1; - } - if(!(_state->info.pixel_fmt&2)){ - crop_y0=crop_y0>>1; - crop_yf=crop_yf+1>>1; - } - } - y=0; - for(yfrag_end+=fplane->nfrags;fragnhfrags;frag=crop_xf||crop_y0>=crop_yf){ - frag->invalid=1; - } - /*Otherwise, check to see if it straddles the border.*/ - else if(x=crop_x0&&x+j=crop_y0&&y+i=_state->nborders){ - _state->nborders++; - _state->borders[i].mask=mask; - _state->borders[i].npixels=npixels; - } - else if(_state->borders[i].mask!=mask)continue; - frag->borderi=i; - break; - } - } - else frag->borderi=-1; - } - } - } -} - -static int oc_state_frarray_init(oc_theora_state *_state){ - int yhfrags; - int yvfrags; - int chfrags; - int cvfrags; - ptrdiff_t yfrags; - ptrdiff_t cfrags; - ptrdiff_t nfrags; - unsigned yhsbs; - unsigned yvsbs; - unsigned chsbs; - unsigned cvsbs; - unsigned ysbs; - unsigned csbs; - unsigned nsbs; - size_t nmbs; - int hdec; - int vdec; - int pli; - /*Figure out the number of fragments in each plane.*/ - /*These parameters have already been validated to be multiples of 16.*/ - yhfrags=_state->info.frame_width>>3; - yvfrags=_state->info.frame_height>>3; - hdec=!(_state->info.pixel_fmt&1); - vdec=!(_state->info.pixel_fmt&2); - chfrags=yhfrags+hdec>>hdec; - cvfrags=yvfrags+vdec>>vdec; - yfrags=yhfrags*(ptrdiff_t)yvfrags; - cfrags=chfrags*(ptrdiff_t)cvfrags; - nfrags=yfrags+2*cfrags; - /*Figure out the number of super blocks in each plane.*/ - yhsbs=yhfrags+3>>2; - yvsbs=yvfrags+3>>2; - chsbs=chfrags+3>>2; - cvsbs=cvfrags+3>>2; - ysbs=yhsbs*yvsbs; - csbs=chsbs*cvsbs; - nsbs=ysbs+2*csbs; - nmbs=(size_t)ysbs<<2; - /*Check for overflow. - We support the ridiculous upper limits of the specification (1048560 by - 1048560, or 3 TB frames) if the target architecture has 64-bit pointers, - but for those with 32-bit pointers (or smaller!) we have to check. - If the caller wants to prevent denial-of-service by imposing a more - reasonable upper limit on the size of attempted allocations, they must do - so themselves; we have no platform independent way to determine how much - system memory there is nor an application-independent way to decide what a - "reasonable" allocation is.*/ - if(yfrags/yhfrags!=yvfrags||2*cfrags>2!=ysbs){ - return TH_EIMPL; - } - /*Initialize the fragment array.*/ - _state->fplanes[0].nhfrags=yhfrags; - _state->fplanes[0].nvfrags=yvfrags; - _state->fplanes[0].froffset=0; - _state->fplanes[0].nfrags=yfrags; - _state->fplanes[0].nhsbs=yhsbs; - _state->fplanes[0].nvsbs=yvsbs; - _state->fplanes[0].sboffset=0; - _state->fplanes[0].nsbs=ysbs; - _state->fplanes[1].nhfrags=_state->fplanes[2].nhfrags=chfrags; - _state->fplanes[1].nvfrags=_state->fplanes[2].nvfrags=cvfrags; - _state->fplanes[1].froffset=yfrags; - _state->fplanes[2].froffset=yfrags+cfrags; - _state->fplanes[1].nfrags=_state->fplanes[2].nfrags=cfrags; - _state->fplanes[1].nhsbs=_state->fplanes[2].nhsbs=chsbs; - _state->fplanes[1].nvsbs=_state->fplanes[2].nvsbs=cvsbs; - _state->fplanes[1].sboffset=ysbs; - _state->fplanes[2].sboffset=ysbs+csbs; - _state->fplanes[1].nsbs=_state->fplanes[2].nsbs=csbs; - _state->nfrags=nfrags; - _state->frags=_ogg_calloc(nfrags,sizeof(*_state->frags)); - _state->frag_mvs=_ogg_malloc(nfrags*sizeof(*_state->frag_mvs)); - _state->nsbs=nsbs; - _state->sb_maps=_ogg_malloc(nsbs*sizeof(*_state->sb_maps)); - _state->sb_flags=_ogg_calloc(nsbs,sizeof(*_state->sb_flags)); - _state->nhmbs=yhsbs<<1; - _state->nvmbs=yvsbs<<1; - _state->nmbs=nmbs; - _state->mb_maps=_ogg_calloc(nmbs,sizeof(*_state->mb_maps)); - _state->mb_modes=_ogg_calloc(nmbs,sizeof(*_state->mb_modes)); - _state->coded_fragis=_ogg_malloc(nfrags*sizeof(*_state->coded_fragis)); - if(_state->frags==NULL||_state->frag_mvs==NULL||_state->sb_maps==NULL|| - _state->sb_flags==NULL||_state->mb_maps==NULL||_state->mb_modes==NULL|| - _state->coded_fragis==NULL){ - return TH_EFAULT; - } - /*Create the mapping from super blocks to fragments.*/ - for(pli=0;pli<3;pli++){ - oc_fragment_plane *fplane; - fplane=_state->fplanes+pli; - oc_sb_create_plane_mapping(_state->sb_maps+fplane->sboffset, - _state->sb_flags+fplane->sboffset,fplane->froffset, - fplane->nhfrags,fplane->nvfrags); - } - /*Create the mapping from macro blocks to fragments.*/ - oc_mb_create_mapping(_state->mb_maps,_state->mb_modes, - _state->fplanes,_state->info.pixel_fmt); - /*Initialize the invalid and borderi fields of each fragment.*/ - oc_state_border_init(_state); - return 0; -} - -static void oc_state_frarray_clear(oc_theora_state *_state){ - _ogg_free(_state->coded_fragis); - _ogg_free(_state->mb_modes); - _ogg_free(_state->mb_maps); - _ogg_free(_state->sb_flags); - _ogg_free(_state->sb_maps); - _ogg_free(_state->frag_mvs); - _ogg_free(_state->frags); -} - - -/*Initializes the buffers used for reconstructed frames. - These buffers are padded with 16 extra pixels on each side, to allow - unrestricted motion vectors without special casing the boundary. - If chroma is decimated in either direction, the padding is reduced by a - factor of 2 on the appropriate sides. - _nrefs: The number of reference buffers to init; must be 3 or 4.*/ -static int oc_state_ref_bufs_init(oc_theora_state *_state,int _nrefs){ - th_info *info; - unsigned char *ref_frame_data; - size_t ref_frame_data_sz; - size_t ref_frame_sz; - size_t yplane_sz; - size_t cplane_sz; - int yhstride; - int yheight; - int chstride; - int cheight; - ptrdiff_t yoffset; - ptrdiff_t coffset; - ptrdiff_t *frag_buf_offs; - ptrdiff_t fragi; - int hdec; - int vdec; - int rfi; - int pli; - if(_nrefs<3||_nrefs>4)return TH_EINVAL; - info=&_state->info; - /*Compute the image buffer parameters for each plane.*/ - hdec=!(info->pixel_fmt&1); - vdec=!(info->pixel_fmt&2); - yhstride=info->frame_width+2*OC_UMV_PADDING; - yheight=info->frame_height+2*OC_UMV_PADDING; - chstride=yhstride>>hdec; - cheight=yheight>>vdec; - yplane_sz=yhstride*(size_t)yheight; - cplane_sz=chstride*(size_t)cheight; - yoffset=OC_UMV_PADDING+OC_UMV_PADDING*(ptrdiff_t)yhstride; - coffset=(OC_UMV_PADDING>>hdec)+(OC_UMV_PADDING>>vdec)*(ptrdiff_t)chstride; - ref_frame_sz=yplane_sz+2*cplane_sz; - ref_frame_data_sz=_nrefs*ref_frame_sz; - /*Check for overflow. - The same caveats apply as for oc_state_frarray_init().*/ - if(yplane_sz/yhstride!=yheight||2*cplane_szfrag_buf_offs= - _ogg_malloc(_state->nfrags*sizeof(*frag_buf_offs)); - if(ref_frame_data==NULL||frag_buf_offs==NULL){ - _ogg_free(frag_buf_offs); - _ogg_free(ref_frame_data); - return TH_EFAULT; - } - /*Set up the width, height and stride for the image buffers.*/ - _state->ref_frame_bufs[0][0].width=info->frame_width; - _state->ref_frame_bufs[0][0].height=info->frame_height; - _state->ref_frame_bufs[0][0].stride=yhstride; - _state->ref_frame_bufs[0][1].width=_state->ref_frame_bufs[0][2].width= - info->frame_width>>hdec; - _state->ref_frame_bufs[0][1].height=_state->ref_frame_bufs[0][2].height= - info->frame_height>>vdec; - _state->ref_frame_bufs[0][1].stride=_state->ref_frame_bufs[0][2].stride= - chstride; - for(rfi=1;rfi<_nrefs;rfi++){ - memcpy(_state->ref_frame_bufs[rfi],_state->ref_frame_bufs[0], - sizeof(_state->ref_frame_bufs[0])); - } - /*Set up the data pointers for the image buffers.*/ - for(rfi=0;rfi<_nrefs;rfi++){ - _state->ref_frame_data[rfi]=ref_frame_data; - _state->ref_frame_bufs[rfi][0].data=ref_frame_data+yoffset; - ref_frame_data+=yplane_sz; - _state->ref_frame_bufs[rfi][1].data=ref_frame_data+coffset; - ref_frame_data+=cplane_sz; - _state->ref_frame_bufs[rfi][2].data=ref_frame_data+coffset; - ref_frame_data+=cplane_sz; - /*Flip the buffer upside down. - This allows us to decode Theora's bottom-up frames in their natural - order, yet return a top-down buffer with a positive stride to the user.*/ - oc_ycbcr_buffer_flip(_state->ref_frame_bufs[rfi], - _state->ref_frame_bufs[rfi]); - } - _state->ref_ystride[0]=-yhstride; - _state->ref_ystride[1]=_state->ref_ystride[2]=-chstride; - /*Initialize the fragment buffer offsets.*/ - ref_frame_data=_state->ref_frame_data[0]; - fragi=0; - for(pli=0;pli<3;pli++){ - th_img_plane *iplane; - oc_fragment_plane *fplane; - unsigned char *vpix; - ptrdiff_t stride; - ptrdiff_t vfragi_end; - int nhfrags; - iplane=_state->ref_frame_bufs[0]+pli; - fplane=_state->fplanes+pli; - vpix=iplane->data; - vfragi_end=fplane->froffset+fplane->nfrags; - nhfrags=fplane->nhfrags; - stride=iplane->stride; - while(fragiref_frame_idx[OC_FRAME_GOLD]= - _state->ref_frame_idx[OC_FRAME_PREV]= - _state->ref_frame_idx[OC_FRAME_SELF]=-1; - _state->ref_frame_idx[OC_FRAME_IO]=_nrefs>3?3:-1; - return 0; -} - -static void oc_state_ref_bufs_clear(oc_theora_state *_state){ - _ogg_free(_state->frag_buf_offs); - _ogg_free(_state->ref_frame_data[0]); -} - - -void oc_state_vtable_init_c(oc_theora_state *_state){ - _state->opt_vtable.frag_copy=oc_frag_copy_c; - _state->opt_vtable.frag_recon_intra=oc_frag_recon_intra_c; - _state->opt_vtable.frag_recon_inter=oc_frag_recon_inter_c; - _state->opt_vtable.frag_recon_inter2=oc_frag_recon_inter2_c; - _state->opt_vtable.idct8x8=oc_idct8x8_c; - _state->opt_vtable.state_frag_recon=oc_state_frag_recon_c; - _state->opt_vtable.state_frag_copy_list=oc_state_frag_copy_list_c; - _state->opt_vtable.state_loop_filter_frag_rows= - oc_state_loop_filter_frag_rows_c; - _state->opt_vtable.restore_fpu=oc_restore_fpu_c; - _state->opt_data.dct_fzig_zag=OC_FZIG_ZAG; -} - -/*Initialize the accelerated function pointers.*/ -void oc_state_vtable_init(oc_theora_state *_state){ -#if defined(OC_X86_ASM) - oc_state_vtable_init_x86(_state); -#else - oc_state_vtable_init_c(_state); -#endif -} - - -int oc_state_init(oc_theora_state *_state,const th_info *_info,int _nrefs){ - int ret; - /*First validate the parameters.*/ - if(_info==NULL)return TH_EFAULT; - /*The width and height of the encoded frame must be multiples of 16. - They must also, when divided by 16, fit into a 16-bit unsigned integer. - The displayable frame offset coordinates must fit into an 8-bit unsigned - integer. - Note that the offset Y in the API is specified on the opposite side from - how it is specified in the bitstream, because the Y axis is flipped in - the bitstream. - The displayable frame must fit inside the encoded frame. - The color space must be one known by the encoder.*/ - if((_info->frame_width&0xF)||(_info->frame_height&0xF)|| - _info->frame_width<=0||_info->frame_width>=0x100000|| - _info->frame_height<=0||_info->frame_height>=0x100000|| - _info->pic_x+_info->pic_width>_info->frame_width|| - _info->pic_y+_info->pic_height>_info->frame_height|| - _info->pic_x>255||_info->frame_height-_info->pic_height-_info->pic_y>255|| - /*Note: the following <0 comparisons may generate spurious warnings on - platforms where enums are unsigned. - We could cast them to unsigned and just use the following >= comparison, - but there are a number of compilers which will mis-optimize this. - It's better to live with the spurious warnings.*/ - _info->colorspace<0||_info->colorspace>=TH_CS_NSPACES|| - _info->pixel_fmt<0||_info->pixel_fmt>=TH_PF_NFORMATS){ - return TH_EINVAL; - } - memset(_state,0,sizeof(*_state)); - memcpy(&_state->info,_info,sizeof(*_info)); - /*Invert the sense of pic_y to match Theora's right-handed coordinate - system.*/ - _state->info.pic_y=_info->frame_height-_info->pic_height-_info->pic_y; - _state->frame_type=OC_UNKWN_FRAME; - oc_state_vtable_init(_state); - ret=oc_state_frarray_init(_state); - if(ret>=0)ret=oc_state_ref_bufs_init(_state,_nrefs); - if(ret<0){ - oc_state_frarray_clear(_state); - return ret; - } - /*If the keyframe_granule_shift is out of range, use the maximum allowable - value.*/ - if(_info->keyframe_granule_shift<0||_info->keyframe_granule_shift>31){ - _state->info.keyframe_granule_shift=31; - } - _state->keyframe_num=0; - _state->curframe_num=-1; - /*3.2.0 streams mark the frame index instead of the frame count. - This was changed with stream version 3.2.1 to conform to other Ogg - codecs. - We add an extra bias when computing granule positions for new streams.*/ - _state->granpos_bias=TH_VERSION_CHECK(_info,3,2,1); - return 0; -} - -void oc_state_clear(oc_theora_state *_state){ - oc_state_ref_bufs_clear(_state); - oc_state_frarray_clear(_state); -} - - -/*Duplicates the pixels on the border of the image plane out into the - surrounding padding for use by unrestricted motion vectors. - This function only adds the left and right borders, and only for the fragment - rows specified. - _refi: The index of the reference buffer to pad. - _pli: The color plane. - _y0: The Y coordinate of the first row to pad. - _yend: The Y coordinate of the row to stop padding at.*/ -void oc_state_borders_fill_rows(oc_theora_state *_state,int _refi,int _pli, - int _y0,int _yend){ - th_img_plane *iplane; - unsigned char *apix; - unsigned char *bpix; - unsigned char *epix; - int stride; - int hpadding; - hpadding=OC_UMV_PADDING>>(_pli!=0&&!(_state->info.pixel_fmt&1)); - iplane=_state->ref_frame_bufs[_refi]+_pli; - stride=iplane->stride; - apix=iplane->data+_y0*(ptrdiff_t)stride; - bpix=apix+iplane->width-1; - epix=iplane->data+_yend*(ptrdiff_t)stride; - /*Note the use of != instead of <, which allows the stride to be negative.*/ - while(apix!=epix){ - memset(apix-hpadding,apix[0],hpadding); - memset(bpix+1,bpix[0],hpadding); - apix+=stride; - bpix+=stride; - } -} - -/*Duplicates the pixels on the border of the image plane out into the - surrounding padding for use by unrestricted motion vectors. - This function only adds the top and bottom borders, and must be called after - the left and right borders are added. - _refi: The index of the reference buffer to pad. - _pli: The color plane.*/ -void oc_state_borders_fill_caps(oc_theora_state *_state,int _refi,int _pli){ - th_img_plane *iplane; - unsigned char *apix; - unsigned char *bpix; - unsigned char *epix; - int stride; - int hpadding; - int vpadding; - int fullw; - hpadding=OC_UMV_PADDING>>(_pli!=0&&!(_state->info.pixel_fmt&1)); - vpadding=OC_UMV_PADDING>>(_pli!=0&&!(_state->info.pixel_fmt&2)); - iplane=_state->ref_frame_bufs[_refi]+_pli; - stride=iplane->stride; - fullw=iplane->width+(hpadding<<1); - apix=iplane->data-hpadding; - bpix=iplane->data+(iplane->height-1)*(ptrdiff_t)stride-hpadding; - epix=apix-stride*(ptrdiff_t)vpadding; - while(apix!=epix){ - memcpy(apix-stride,apix,fullw); - memcpy(bpix+stride,bpix,fullw); - apix-=stride; - bpix+=stride; - } -} - -/*Duplicates the pixels on the border of the given reference image out into - the surrounding padding for use by unrestricted motion vectors. - _state: The context containing the reference buffers. - _refi: The index of the reference buffer to pad.*/ -void oc_state_borders_fill(oc_theora_state *_state,int _refi){ - int pli; - for(pli=0;pli<3;pli++){ - oc_state_borders_fill_rows(_state,_refi,pli,0, - _state->ref_frame_bufs[_refi][pli].height); - oc_state_borders_fill_caps(_state,_refi,pli); - } -} - -/*Determines the offsets in an image buffer to use for motion compensation. - _state: The Theora state the offsets are to be computed with. - _offsets: Returns the offset for the buffer(s). - _offsets[0] is always set. - _offsets[1] is set if the motion vector has non-zero fractional - components. - _pli: The color plane index. - _dx: The X component of the motion vector. - _dy: The Y component of the motion vector. - Return: The number of offsets returned: 1 or 2.*/ -int oc_state_get_mv_offsets(const oc_theora_state *_state,int _offsets[2], - int _pli,int _dx,int _dy){ - /*Here is a brief description of how Theora handles motion vectors: - Motion vector components are specified to half-pixel accuracy in - undecimated directions of each plane, and quarter-pixel accuracy in - decimated directions. - Integer parts are extracted by dividing (not shifting) by the - appropriate amount, with truncation towards zero. - These integer values are used to calculate the first offset. - - If either of the fractional parts are non-zero, then a second offset is - computed. - No third or fourth offsets are computed, even if both components have - non-zero fractional parts. - The second offset is computed by dividing (not shifting) by the - appropriate amount, always truncating _away_ from zero.*/ -#if 0 - /*This version of the code doesn't use any tables, but is slower.*/ - int ystride; - int xprec; - int yprec; - int xfrac; - int yfrac; - int offs; - ystride=_state->ref_ystride[_pli]; - /*These two variables decide whether we are in half- or quarter-pixel - precision in each component.*/ - xprec=1+(_pli!=0&&!(_state->info.pixel_fmt&1)); - yprec=1+(_pli!=0&&!(_state->info.pixel_fmt&2)); - /*These two variables are either 0 if all the fractional bits are zero or -1 - if any of them are non-zero.*/ - xfrac=OC_SIGNMASK(-(_dx&(xprec|1))); - yfrac=OC_SIGNMASK(-(_dy&(yprec|1))); - offs=(_dx>>xprec)+(_dy>>yprec)*ystride; - if(xfrac||yfrac){ - int xmask; - int ymask; - xmask=OC_SIGNMASK(_dx); - ymask=OC_SIGNMASK(_dy); - yfrac&=ystride; - _offsets[0]=offs-(xfrac&xmask)+(yfrac&ymask); - _offsets[1]=offs-(xfrac&~xmask)+(yfrac&~ymask); - return 2; - } - else{ - _offsets[0]=offs; - return 1; - } -#else - /*Using tables simplifies the code, and there's enough arithmetic to hide the - latencies of the memory references.*/ - static const signed char OC_MVMAP[2][64]={ - { - -15,-15,-14,-14,-13,-13,-12,-12,-11,-11,-10,-10, -9, -9, -8, - -8, -7, -7, -6, -6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, - 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, - 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15 - }, - { - -7, -7, -7, -7, -6, -6, -6, -6, -5, -5, -5, -5, -4, -4, -4, - -4, -3, -3, -3, -3, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7 - } - }; - static const signed char OC_MVMAP2[2][64]={ - { - -1, 0,-1, 0,-1, 0,-1, 0,-1, 0,-1, 0,-1, 0,-1, - 0,-1, 0,-1, 0,-1, 0,-1, 0,-1, 0,-1, 0,-1, 0,-1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 - }, - { - -1,-1,-1, 0,-1,-1,-1, 0,-1,-1,-1, 0,-1,-1,-1, - 0,-1,-1,-1, 0,-1,-1,-1, 0,-1,-1,-1, 0,-1,-1,-1, - 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, - 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 - } - }; - int ystride; - int qpx; - int qpy; - int mx; - int my; - int mx2; - int my2; - int offs; - ystride=_state->ref_ystride[_pli]; - qpy=_pli!=0&&!(_state->info.pixel_fmt&2); - my=OC_MVMAP[qpy][_dy+31]; - my2=OC_MVMAP2[qpy][_dy+31]; - qpx=_pli!=0&&!(_state->info.pixel_fmt&1); - mx=OC_MVMAP[qpx][_dx+31]; - mx2=OC_MVMAP2[qpx][_dx+31]; - offs=my*ystride+mx; - if(mx2||my2){ - _offsets[1]=offs+my2*ystride+mx2; - _offsets[0]=offs; - return 2; - } - _offsets[0]=offs; - return 1; -#endif -} - -void oc_state_frag_recon(const oc_theora_state *_state,ptrdiff_t _fragi, - int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,ogg_uint16_t _dc_quant){ - _state->opt_vtable.state_frag_recon(_state,_fragi,_pli,_dct_coeffs, - _last_zzi,_dc_quant); -} - -void oc_state_frag_recon_c(const oc_theora_state *_state,ptrdiff_t _fragi, - int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,ogg_uint16_t _dc_quant){ - unsigned char *dst; - ptrdiff_t frag_buf_off; - int ystride; - int mb_mode; - /*Apply the inverse transform.*/ - /*Special case only having a DC component.*/ - if(_last_zzi<2){ - ogg_int16_t p; - int ci; - /*We round this dequant product (and not any of the others) because there's - no iDCT rounding.*/ - p=(ogg_int16_t)(_dct_coeffs[0]*(ogg_int32_t)_dc_quant+15>>5); - /*LOOP VECTORIZES.*/ - for(ci=0;ci<64;ci++)_dct_coeffs[ci]=p; - } - else{ - /*First, dequantize the DC coefficient.*/ - _dct_coeffs[0]=(ogg_int16_t)(_dct_coeffs[0]*(int)_dc_quant); - oc_idct8x8(_state,_dct_coeffs,_last_zzi); - } - /*Fill in the target buffer.*/ - frag_buf_off=_state->frag_buf_offs[_fragi]; - mb_mode=_state->frags[_fragi].mb_mode; - ystride=_state->ref_ystride[_pli]; - dst=_state->ref_frame_data[_state->ref_frame_idx[OC_FRAME_SELF]]+frag_buf_off; - if(mb_mode==OC_MODE_INTRA)oc_frag_recon_intra(_state,dst,ystride,_dct_coeffs); - else{ - const unsigned char *ref; - int mvoffsets[2]; - ref= - _state->ref_frame_data[_state->ref_frame_idx[OC_FRAME_FOR_MODE(mb_mode)]] - +frag_buf_off; - if(oc_state_get_mv_offsets(_state,mvoffsets,_pli, - _state->frag_mvs[_fragi][0],_state->frag_mvs[_fragi][1])>1){ - oc_frag_recon_inter2(_state, - dst,ref+mvoffsets[0],ref+mvoffsets[1],ystride,_dct_coeffs); - } - else oc_frag_recon_inter(_state,dst,ref+mvoffsets[0],ystride,_dct_coeffs); - } -} - -/*Copies the fragments specified by the lists of fragment indices from one - frame to another. - _fragis: A pointer to a list of fragment indices. - _nfragis: The number of fragment indices to copy. - _dst_frame: The reference frame to copy to. - _src_frame: The reference frame to copy from. - _pli: The color plane the fragments lie in.*/ -void oc_state_frag_copy_list(const oc_theora_state *_state, - const ptrdiff_t *_fragis,ptrdiff_t _nfragis, - int _dst_frame,int _src_frame,int _pli){ - _state->opt_vtable.state_frag_copy_list(_state,_fragis,_nfragis,_dst_frame, - _src_frame,_pli); -} - -void oc_state_frag_copy_list_c(const oc_theora_state *_state, - const ptrdiff_t *_fragis,ptrdiff_t _nfragis, - int _dst_frame,int _src_frame,int _pli){ - const ptrdiff_t *frag_buf_offs; - const unsigned char *src_frame_data; - unsigned char *dst_frame_data; - ptrdiff_t fragii; - int ystride; - dst_frame_data=_state->ref_frame_data[_state->ref_frame_idx[_dst_frame]]; - src_frame_data=_state->ref_frame_data[_state->ref_frame_idx[_src_frame]]; - ystride=_state->ref_ystride[_pli]; - frag_buf_offs=_state->frag_buf_offs; - for(fragii=0;fragii<_nfragis;fragii++){ - ptrdiff_t frag_buf_off; - frag_buf_off=frag_buf_offs[_fragis[fragii]]; - oc_frag_copy(_state,dst_frame_data+frag_buf_off, - src_frame_data+frag_buf_off,ystride); - } -} - -static void loop_filter_h(unsigned char *_pix,int _ystride,int *_bv){ - int y; - _pix-=2; - for(y=0;y<8;y++){ - int f; - f=_pix[0]-_pix[3]+3*(_pix[2]-_pix[1]); - /*The _bv array is used to compute the function - f=OC_CLAMPI(OC_MINI(-_2flimit-f,0),f,OC_MAXI(_2flimit-f,0)); - where _2flimit=_state->loop_filter_limits[_state->qis[0]]<<1;*/ - f=*(_bv+(f+4>>3)); - _pix[1]=OC_CLAMP255(_pix[1]+f); - _pix[2]=OC_CLAMP255(_pix[2]-f); - _pix+=_ystride; - } -} - -static void loop_filter_v(unsigned char *_pix,int _ystride,int *_bv){ - int x; - _pix-=_ystride*2; - for(x=0;x<8;x++){ - int f; - f=_pix[x]-_pix[_ystride*3+x]+3*(_pix[_ystride*2+x]-_pix[_ystride+x]); - /*The _bv array is used to compute the function - f=OC_CLAMPI(OC_MINI(-_2flimit-f,0),f,OC_MAXI(_2flimit-f,0)); - where _2flimit=_state->loop_filter_limits[_state->qis[0]]<<1;*/ - f=*(_bv+(f+4>>3)); - _pix[_ystride+x]=OC_CLAMP255(_pix[_ystride+x]+f); - _pix[_ystride*2+x]=OC_CLAMP255(_pix[_ystride*2+x]-f); - } -} - -/*Initialize the bounding values array used by the loop filter. - _bv: Storage for the array. - Return: 0 on success, or a non-zero value if no filtering need be applied.*/ -int oc_state_loop_filter_init(oc_theora_state *_state,int _bv[256]){ - int flimit; - int i; - flimit=_state->loop_filter_limits[_state->qis[0]]; - if(flimit==0)return 1; - memset(_bv,0,sizeof(_bv[0])*256); - for(i=0;i=0)_bv[127-i-flimit]=i-flimit; - _bv[127-i]=-i; - _bv[127+i]=i; - if(127+i+flimit<256)_bv[127+i+flimit]=flimit-i; - } - return 0; -} - -/*Apply the loop filter to a given set of fragment rows in the given plane. - The filter may be run on the bottom edge, affecting pixels in the next row of - fragments, so this row also needs to be available. - _bv: The bounding values array. - _refi: The index of the frame buffer to filter. - _pli: The color plane to filter. - _fragy0: The Y coordinate of the first fragment row to filter. - _fragy_end: The Y coordinate of the fragment row to stop filtering at.*/ -void oc_state_loop_filter_frag_rows(const oc_theora_state *_state,int _bv[256], - int _refi,int _pli,int _fragy0,int _fragy_end){ - _state->opt_vtable.state_loop_filter_frag_rows(_state,_bv,_refi,_pli, - _fragy0,_fragy_end); -} - -void oc_state_loop_filter_frag_rows_c(const oc_theora_state *_state,int *_bv, - int _refi,int _pli,int _fragy0,int _fragy_end){ - const oc_fragment_plane *fplane; - const oc_fragment *frags; - const ptrdiff_t *frag_buf_offs; - unsigned char *ref_frame_data; - ptrdiff_t fragi_top; - ptrdiff_t fragi_bot; - ptrdiff_t fragi0; - ptrdiff_t fragi0_end; - int ystride; - int nhfrags; - _bv+=127; - fplane=_state->fplanes+_pli; - nhfrags=fplane->nhfrags; - fragi_top=fplane->froffset; - fragi_bot=fragi_top+fplane->nfrags; - fragi0=fragi_top+_fragy0*(ptrdiff_t)nhfrags; - fragi0_end=fragi0+(_fragy_end-_fragy0)*(ptrdiff_t)nhfrags; - ystride=_state->ref_ystride[_pli]; - frags=_state->frags; - frag_buf_offs=_state->frag_buf_offs; - ref_frame_data=_state->ref_frame_data[_refi]; - /*The following loops are constructed somewhat non-intuitively on purpose. - The main idea is: if a block boundary has at least one coded fragment on - it, the filter is applied to it. - However, the order that the filters are applied in matters, and VP3 chose - the somewhat strange ordering used below.*/ - while(fragi0fragi0)loop_filter_h(ref,ystride,_bv); - if(fragi0>fragi_top)loop_filter_v(ref,ystride,_bv); - if(fragi+1info.frame_width; - height=_state->info.frame_height; - iframe=_state->granpos>>_state->info.keyframe_granule_shift; - pframe=_state->granpos-(iframe<<_state->info.keyframe_granule_shift); - sprintf(fname,"%08i%s.png",(int)(iframe+pframe),_suf); - fp=fopen(fname,"wb"); - if(fp==NULL)return TH_EFAULT; - image=(png_bytep *)oc_malloc_2d(height,6*width,sizeof(**image)); - if(image==NULL){ - fclose(fp); - return TH_EFAULT; - } - png=png_create_write_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL); - if(png==NULL){ - oc_free_2d(image); - fclose(fp); - return TH_EFAULT; - } - info=png_create_info_struct(png); - if(info==NULL){ - png_destroy_write_struct(&png,NULL); - oc_free_2d(image); - fclose(fp); - return TH_EFAULT; - } - if(setjmp(png_jmpbuf(png))){ - png_destroy_write_struct(&png,&info); - oc_free_2d(image); - fclose(fp); - return TH_EFAULT; - } - framei=_state->ref_frame_idx[_frame]; - y_row=_state->ref_frame_bufs[framei][0].data; - u_row=_state->ref_frame_bufs[framei][1].data; - v_row=_state->ref_frame_bufs[framei][2].data; - y_stride=_state->ref_frame_bufs[framei][0].stride; - u_stride=_state->ref_frame_bufs[framei][1].stride; - v_stride=_state->ref_frame_bufs[framei][2].stride; - /*Chroma up-sampling is just done with a box filter. - This is very likely what will actually be used in practice on a real - display, and also removes one more layer to search in for the source of - artifacts. - As an added bonus, it's dead simple.*/ - for(imgi=height;imgi-->0;){ - int dc; - y=y_row; - u=u_row; - v=v_row; - for(imgj=0;imgj<6*width;){ - float yval; - float uval; - float vval; - unsigned rval; - unsigned gval; - unsigned bval; - /*This is intentionally slow and very accurate.*/ - yval=(*y-16)*(1.0F/219); - uval=(*u-128)*(2*(1-0.114F)/224); - vval=(*v-128)*(2*(1-0.299F)/224); - rval=OC_CLAMPI(0,(int)(65535*(yval+vval)+0.5F),65535); - gval=OC_CLAMPI(0,(int)(65535*( - yval-uval*(0.114F/0.587F)-vval*(0.299F/0.587F))+0.5F),65535); - bval=OC_CLAMPI(0,(int)(65535*(yval+uval)+0.5F),65535); - image[imgi][imgj++]=(unsigned char)(rval>>8); - image[imgi][imgj++]=(unsigned char)(rval&0xFF); - image[imgi][imgj++]=(unsigned char)(gval>>8); - image[imgi][imgj++]=(unsigned char)(gval&0xFF); - image[imgi][imgj++]=(unsigned char)(bval>>8); - image[imgi][imgj++]=(unsigned char)(bval&0xFF); - dc=(y-y_row&1)|(_state->info.pixel_fmt&1); - y++; - u+=dc; - v+=dc; - } - dc=-((height-1-imgi&1)|_state->info.pixel_fmt>>1); - y_row+=y_stride; - u_row+=dc&u_stride; - v_row+=dc&v_stride; - } - png_init_io(png,fp); - png_set_compression_level(png,Z_BEST_COMPRESSION); - png_set_IHDR(png,info,width,height,16,PNG_COLOR_TYPE_RGB, - PNG_INTERLACE_NONE,PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT); - switch(_state->info.colorspace){ - case TH_CS_ITU_REC_470M:{ - png_set_gAMA(png,info,2.2); - png_set_cHRM_fixed(png,info,31006,31616, - 67000,32000,21000,71000,14000,8000); - }break; - case TH_CS_ITU_REC_470BG:{ - png_set_gAMA(png,info,2.67); - png_set_cHRM_fixed(png,info,31271,32902, - 64000,33000,29000,60000,15000,6000); - }break; - default:break; - } - png_set_pHYs(png,info,_state->info.aspect_numerator, - _state->info.aspect_denominator,0); - png_set_rows(png,info,image); - png_write_png(png,info,PNG_TRANSFORM_IDENTITY,NULL); - png_write_end(png,info); - png_destroy_write_struct(&png,&info); - oc_free_2d(image); - fclose(fp); - return 0; -} -#endif - - - -ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos){ - oc_theora_state *state; - state=(oc_theora_state *)_encdec; - if(_granpos>=0){ - ogg_int64_t iframe; - ogg_int64_t pframe; - iframe=_granpos>>state->info.keyframe_granule_shift; - pframe=_granpos-(iframe<info.keyframe_granule_shift); - /*3.2.0 streams store the frame index in the granule position. - 3.2.1 and later store the frame count. - We return the index, so adjust the value if we have a 3.2.1 or later - stream.*/ - return iframe+pframe-TH_VERSION_CHECK(&state->info,3,2,1); - } - return -1; -} - -double th_granule_time(void *_encdec,ogg_int64_t _granpos){ - oc_theora_state *state; - state=(oc_theora_state *)_encdec; - if(_granpos>=0){ - return (th_granule_frame(_encdec, _granpos)+1)*( - (double)state->info.fps_denominator/state->info.fps_numerator); - } - return -1; -} diff --git a/Engine/lib/libtheora/lib/tokenize.c b/Engine/lib/libtheora/lib/tokenize.c deleted file mode 100644 index 60574c359..000000000 --- a/Engine/lib/libtheora/lib/tokenize.c +++ /dev/null @@ -1,1072 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: tokenize.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ -#include -#include -#include "encint.h" - - - -static int oc_make_eob_token(int _run_count){ - if(_run_count<4)return OC_DCT_EOB1_TOKEN+_run_count-1; - else{ - int cat; - cat=OC_ILOGNZ_32(_run_count)-3; - cat=OC_MINI(cat,3); - return OC_DCT_REPEAT_RUN0_TOKEN+cat; - } -} - -static int oc_make_eob_token_full(int _run_count,int *_eb){ - if(_run_count<4){ - *_eb=0; - return OC_DCT_EOB1_TOKEN+_run_count-1; - } - else{ - int cat; - cat=OC_ILOGNZ_32(_run_count)-3; - cat=OC_MINI(cat,3); - *_eb=_run_count-OC_BYTE_TABLE32(4,8,16,0,cat); - return OC_DCT_REPEAT_RUN0_TOKEN+cat; - } -} - -/*Returns the number of blocks ended by an EOB token.*/ -static int oc_decode_eob_token(int _token,int _eb){ - return (0x20820C41U>>_token*5&0x1F)+_eb; -} - -/*TODO: This is now only used during DCT tokenization, and never for runs; it - should be simplified.*/ -static int oc_make_dct_token_full(int _zzi,int _zzj,int _val,int *_eb){ - int neg; - int zero_run; - int token; - int eb; - neg=_val<0; - _val=abs(_val); - zero_run=_zzj-_zzi; - if(zero_run>0){ - int adj; - /*Implement a minor restriction on stack 1 so that we know during DC fixups - that extending a dctrun token from stack 1 will never overflow.*/ - adj=_zzi!=1; - if(_val<2&&zero_run<17+adj){ - if(zero_run<6){ - token=OC_DCT_RUN_CAT1A+zero_run-1; - eb=neg; - } - else if(zero_run<10){ - token=OC_DCT_RUN_CAT1B; - eb=zero_run-6+(neg<<2); - } - else{ - token=OC_DCT_RUN_CAT1C; - eb=zero_run-10+(neg<<3); - } - } - else if(_val<4&&zero_run<3+adj){ - if(zero_run<2){ - token=OC_DCT_RUN_CAT2A; - eb=_val-2+(neg<<1); - } - else{ - token=OC_DCT_RUN_CAT2B; - eb=zero_run-2+(_val-2<<1)+(neg<<2); - } - } - else{ - if(zero_run<9)token=OC_DCT_SHORT_ZRL_TOKEN; - else token=OC_DCT_ZRL_TOKEN; - eb=zero_run-1; - } - } - else if(_val<3){ - token=OC_ONE_TOKEN+(_val-1<<1)+neg; - eb=0; - } - else if(_val<7){ - token=OC_DCT_VAL_CAT2+_val-3; - eb=neg; - } - else if(_val<9){ - token=OC_DCT_VAL_CAT3; - eb=_val-7+(neg<<1); - } - else if(_val<13){ - token=OC_DCT_VAL_CAT4; - eb=_val-9+(neg<<2); - } - else if(_val<21){ - token=OC_DCT_VAL_CAT5; - eb=_val-13+(neg<<3); - } - else if(_val<37){ - token=OC_DCT_VAL_CAT6; - eb=_val-21+(neg<<4); - } - else if(_val<69){ - token=OC_DCT_VAL_CAT7; - eb=_val-37+(neg<<5); - } - else{ - token=OC_DCT_VAL_CAT8; - eb=_val-69+(neg<<9); - } - *_eb=eb; - return token; -} - -/*Token logging to allow a few fragments of efficient rollback. - Late SKIP analysis is tied up in the tokenization process, so we need to be - able to undo a fragment's tokens on a whim.*/ - -static const unsigned char OC_ZZI_HUFF_OFFSET[64]={ - 0,16,16,16,16,16,32,32, - 32,32,32,32,32,32,32,48, - 48,48,48,48,48,48,48,48, - 48,48,48,48,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64 -}; - -static int oc_token_bits(oc_enc_ctx *_enc,int _huffi,int _zzi,int _token){ - return _enc->huff_codes[_huffi+OC_ZZI_HUFF_OFFSET[_zzi]][_token].nbits - +OC_DCT_TOKEN_EXTRA_BITS[_token]; -} - -static void oc_enc_tokenlog_checkpoint(oc_enc_ctx *_enc, - oc_token_checkpoint *_cp,int _pli,int _zzi){ - _cp->pli=_pli; - _cp->zzi=_zzi; - _cp->eob_run=_enc->eob_run[_pli][_zzi]; - _cp->ndct_tokens=_enc->ndct_tokens[_pli][_zzi]; -} - -void oc_enc_tokenlog_rollback(oc_enc_ctx *_enc, - const oc_token_checkpoint *_stack,int _n){ - int i; - for(i=_n;i-->0;){ - int pli; - int zzi; - pli=_stack[i].pli; - zzi=_stack[i].zzi; - _enc->eob_run[pli][zzi]=_stack[i].eob_run; - _enc->ndct_tokens[pli][zzi]=_stack[i].ndct_tokens; - } -} - -static void oc_enc_token_log(oc_enc_ctx *_enc, - int _pli,int _zzi,int _token,int _eb){ - ptrdiff_t ti; - ti=_enc->ndct_tokens[_pli][_zzi]++; - _enc->dct_tokens[_pli][_zzi][ti]=(unsigned char)_token; - _enc->extra_bits[_pli][_zzi][ti]=(ogg_uint16_t)_eb; -} - -static void oc_enc_eob_log(oc_enc_ctx *_enc, - int _pli,int _zzi,int _run_count){ - int token; - int eb; - token=oc_make_eob_token_full(_run_count,&eb); - oc_enc_token_log(_enc,_pli,_zzi,token,eb); -} - - -void oc_enc_tokenize_start(oc_enc_ctx *_enc){ - memset(_enc->ndct_tokens,0,sizeof(_enc->ndct_tokens)); - memset(_enc->eob_run,0,sizeof(_enc->eob_run)); - memset(_enc->dct_token_offs,0,sizeof(_enc->dct_token_offs)); - memset(_enc->dc_pred_last,0,sizeof(_enc->dc_pred_last)); -} - -typedef struct oc_quant_token oc_quant_token; - -/*A single node in the Viterbi trellis. - We maintain up to 2 of these per coefficient: - - A token to code if the value is zero (EOB, zero run, or combo token). - - A token to code if the value is not zero (DCT value token).*/ -struct oc_quant_token{ - unsigned char next; - signed char token; - ogg_int16_t eb; - ogg_uint32_t cost; - int bits; - int qc; -}; - -/*Tokenizes the AC coefficients, possibly adjusting the quantization, and then - dequantizes and de-zig-zags the result. - The DC coefficient is not preserved; it should be restored by the caller.*/ -int oc_enc_tokenize_ac(oc_enc_ctx *_enc,int _pli,ptrdiff_t _fragi, - ogg_int16_t *_qdct,const ogg_uint16_t *_dequant,const ogg_int16_t *_dct, - int _zzi,oc_token_checkpoint **_stack,int _acmin){ - oc_token_checkpoint *stack; - ogg_int64_t zflags; - ogg_int64_t nzflags; - ogg_int64_t best_flags; - ogg_uint32_t d2_accum[64]; - oc_quant_token tokens[64][2]; - ogg_uint16_t *eob_run; - const unsigned char *dct_fzig_zag; - ogg_uint32_t cost; - int bits; - int eob; - int token; - int eb; - int next; - int huffi; - int zzi; - int ti; - int zzj; - int qc; - huffi=_enc->huff_idxs[_enc->state.frame_type][1][_pli+1>>1]; - eob_run=_enc->eob_run[_pli]; - memset(tokens[0],0,sizeof(tokens[0])); - best_flags=nzflags=0; - zflags=1; - d2_accum[0]=0; - zzj=64; - for(zzi=OC_MINI(_zzi,63);zzi>0;zzi--){ - ogg_int32_t lambda; - ogg_uint32_t best_cost; - int best_bits=best_bits; - int best_next=best_next; - int best_token=best_token; - int best_eb=best_eb; - int best_qc=best_qc; - int flush_bits; - ogg_uint32_t d2; - int dq; - int e; - int c; - int s; - int tj; - lambda=_enc->lambda; - qc=_qdct[zzi]; - s=-(qc<0); - qc=qc+s^s; - c=_dct[OC_FZIG_ZAG[zzi]]; - if(qc<=1){ - ogg_uint32_t sum_d2; - int nzeros; - int dc_reserve; - /*The hard case: try a zero run.*/ - if(!qc){ - /*Skip runs that are already quantized to zeros. - If we considered each zero coefficient in turn, we might - theoretically find a better way to partition long zero runs (e.g., - a run of > 17 zeros followed by a 1 might be better coded as a short - zero run followed by a combo token, rather than the longer zero - token followed by a 1 value token), but zeros are so common that - this becomes very computationally expensive (quadratic instead of - linear in the number of coefficients), for a marginal gain.*/ - while(zzi>1&&!_qdct[zzi-1])zzi--; - /*The distortion of coefficients originally quantized to zero is - treated as zero (since we'll never quantize them to anything else).*/ - d2=0; - } - else{ - c=c+s^s; - d2=c*(ogg_int32_t)c; - } - eob=eob_run[zzi]; - nzeros=zzj-zzi; - zzj&=63; - sum_d2=d2+d2_accum[zzj]; - d2_accum[zzi]=sum_d2; - flush_bits=eob>0?oc_token_bits(_enc,huffi,zzi,oc_make_eob_token(eob)):0; - /*We reserve 1 spot for combo run tokens that start in the 1st AC stack - to ensure they can be extended to include the DC coefficient if - necessary; this greatly simplifies stack-rewriting later on.*/ - dc_reserve=zzi+62>>6; - best_cost=0xFFFFFFFF; - for(;;){ - if(nzflags>>zzj&1){ - int cat; - int val; - int val_s; - int zzk; - int tk; - next=tokens[zzj][1].next; - tk=next&1; - zzk=next>>1; - /*Try a pure zero run to this point.*/ - cat=nzeros+55>>6; - token=OC_DCT_SHORT_ZRL_TOKEN+cat; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - d2=sum_d2-d2_accum[zzj]; - cost=d2+lambda*bits+tokens[zzj][1].cost; - if(cost<=best_cost){ - best_next=(zzj<<1)+1; - best_token=token; - best_eb=nzeros-1; - best_cost=cost; - best_bits=bits+tokens[zzj][1].bits; - best_qc=0; - } - if(nzeros<16+dc_reserve){ - val=_qdct[zzj]; - val_s=-(val<0); - val=val+val_s^val_s; - if(val<=2){ - /*Try a +/- 1 combo token.*/ - if(nzeros<6){ - token=OC_DCT_RUN_CAT1A+nzeros-1; - eb=-val_s; - } - else{ - cat=nzeros+54>>6; - token=OC_DCT_RUN_CAT1B+cat; - eb=(-val_s<>1; - token=OC_DCT_RUN_CAT2A+cat; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - val=2+((val+val_s^val_s)>2); - e=(_dct[OC_FZIG_ZAG[zzj]]+val_s^val_s)-_dequant[zzj]*val; - d2=e*(ogg_int32_t)e+sum_d2-d2_accum[zzj]; - cost=d2+lambda*bits+tokens[zzk][tk].cost; - if(cost<=best_cost){ - best_cost=cost; - best_bits=bits+tokens[zzk][tk].bits; - best_next=next; - best_token=token; - best_eb=(-val_s<<1+cat)+(val-2<>1); - best_qc=val+val_s^val_s; - } - } - } - /*zzj can't be coded as a zero, so stop trying to extend the run.*/ - if(!(zflags>>zzj&1))break; - } - /*We could try to consider _all_ potentially non-zero coefficients, but - if we already found a bunch of them not worth coding, it's fairly - unlikely they would now be worth coding from this position; skipping - them saves a lot of work.*/ - zzj=(tokens[zzj][0].next>>1)-(tokens[zzj][0].qc!=0)&63; - if(zzj==0){ - /*We made it all the way to the end of the block; try an EOB token.*/ - if(eob<4095){ - bits=oc_token_bits(_enc,huffi,zzi,oc_make_eob_token(eob+1)) - -flush_bits; - } - else bits=oc_token_bits(_enc,huffi,zzi,OC_DCT_EOB1_TOKEN); - cost=sum_d2+bits*lambda; - /*If the best route so far is still a pure zero run to the end of the - block, force coding it as an EOB. - Even if it's not optimal for this block, it has a good chance of - getting combined with an EOB token from subsequent blocks, saving - bits overall.*/ - if(cost<=best_cost||best_token<=OC_DCT_ZRL_TOKEN&&zzi+best_eb==63){ - best_next=0; - /*This token is just a marker; in reality we may not emit any - tokens, but update eob_run[] instead.*/ - best_token=OC_DCT_EOB1_TOKEN; - best_eb=0; - best_cost=cost; - best_bits=bits; - best_qc=0; - } - break; - } - nzeros=zzj-zzi; - } - tokens[zzi][0].next=(unsigned char)best_next; - tokens[zzi][0].token=(signed char)best_token; - tokens[zzi][0].eb=(ogg_int16_t)best_eb; - tokens[zzi][0].cost=best_cost; - tokens[zzi][0].bits=best_bits; - tokens[zzi][0].qc=best_qc; - zflags|=(ogg_int64_t)1<>zzj&1; - next=(zzj<<1)+tj; - tokens[zzi][1].next=(unsigned char)next; - tokens[zzi][1].token=(signed char)token; - tokens[zzi][1].eb=0; - tokens[zzi][1].cost=d2+lambda*bits+tokens[zzj][tj].cost; - tokens[zzi][1].bits=bits+tokens[zzj][tj].bits; - tokens[zzi][1].qc=1+s^s; - nzflags|=(ogg_int64_t)1<0?oc_token_bits(_enc,huffi,zzi,oc_make_eob_token(eob)):0; - if(qc<=2){ - e=2*dq-c; - d2=e*(ogg_int32_t)e; - best_token=OC_TWO_TOKEN-s; - best_bits=flush_bits+oc_token_bits(_enc,huffi,zzi,best_token); - best_cost=d2+lambda*best_bits; - e-=dq; - d2=e*(ogg_int32_t)e; - token=OC_ONE_TOKEN-s; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - cost=d2+lambda*bits; - if(cost<=best_cost){ - best_token=token; - best_bits=bits; - best_cost=cost; - qc--; - } - best_eb=0; - } - else if(qc<=3){ - e=3*dq-c; - d2=e*(ogg_int32_t)e; - best_token=OC_DCT_VAL_CAT2; - best_eb=-s; - best_bits=flush_bits+oc_token_bits(_enc,huffi,zzi,best_token); - best_cost=d2+lambda*best_bits; - e-=dq; - d2=e*(ogg_int32_t)e; - token=OC_TWO_TOKEN-s; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - cost=d2+lambda*bits; - if(cost<=best_cost){ - best_token=token; - best_eb=0; - best_bits=bits; - best_cost=cost; - qc--; - } - } - else if(qc<=6){ - e=qc*dq-c; - d2=e*(ogg_int32_t)e; - best_token=OC_DCT_VAL_CAT2+qc-3; - best_eb=-s; - best_bits=flush_bits+oc_token_bits(_enc,huffi,zzi,best_token); - best_cost=d2+lambda*best_bits; - e-=dq; - d2=e*(ogg_int32_t)e; - token=best_token-1; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - cost=d2+lambda*bits; - if(cost<=best_cost){ - best_token=token; - best_bits=bits; - best_cost=cost; - qc--; - } - } - else if(qc<=8){ - e=qc*dq-c; - d2=e*(ogg_int32_t)e; - best_token=OC_DCT_VAL_CAT3; - best_eb=(-s<<1)+qc-7; - best_bits=flush_bits+oc_token_bits(_enc,huffi,zzi,best_token); - best_cost=d2+lambda*best_bits; - e=6*dq-c; - d2=e*(ogg_int32_t)e; - token=OC_DCT_VAL_CAT2+3; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - cost=d2+lambda*bits; - if(cost<=best_cost){ - best_token=token; - best_eb=-s; - best_bits=bits; - best_cost=cost; - qc=6; - } - } - else if(qc<=12){ - e=qc*dq-c; - d2=e*(ogg_int32_t)e; - best_token=OC_DCT_VAL_CAT4; - best_eb=(-s<<2)+qc-9; - best_bits=flush_bits+oc_token_bits(_enc,huffi,zzi,best_token); - best_cost=d2+lambda*best_bits; - e=8*dq-c; - d2=e*(ogg_int32_t)e; - token=best_token-1; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - cost=d2+lambda*bits; - if(cost<=best_cost){ - best_token=token; - best_eb=(-s<<1)+1; - best_bits=bits; - best_cost=cost; - qc=8; - } - } - else if(qc<=20){ - e=qc*dq-c; - d2=e*(ogg_int32_t)e; - best_token=OC_DCT_VAL_CAT5; - best_eb=(-s<<3)+qc-13; - best_bits=flush_bits+oc_token_bits(_enc,huffi,zzi,best_token); - best_cost=d2+lambda*best_bits; - e=12*dq-c; - d2=e*(ogg_int32_t)e; - token=best_token-1; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - cost=d2+lambda*bits; - if(cost<=best_cost){ - best_token=token; - best_eb=(-s<<2)+3; - best_bits=bits; - best_cost=cost; - qc=12; - } - } - else if(qc<=36){ - e=qc*dq-c; - d2=e*(ogg_int32_t)e; - best_token=OC_DCT_VAL_CAT6; - best_eb=(-s<<4)+qc-21; - best_bits=flush_bits+oc_token_bits(_enc,huffi,zzi,best_token); - best_cost=d2+lambda*best_bits; - e=20*dq-c; - d2=e*(ogg_int32_t)e; - token=best_token-1; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - cost=d2+lambda*bits; - if(cost<=best_cost){ - best_token=token; - best_eb=(-s<<3)+7; - best_bits=bits; - best_cost=cost; - qc=20; - } - } - else if(qc<=68){ - e=qc*dq-c; - d2=e*(ogg_int32_t)e; - best_token=OC_DCT_VAL_CAT7; - best_eb=(-s<<5)+qc-37; - best_bits=flush_bits+oc_token_bits(_enc,huffi,zzi,best_token); - best_cost=d2+lambda*best_bits; - e=36*dq-c; - d2=e*(ogg_int32_t)e; - token=best_token-1; - bits=flush_bits+oc_token_bits(_enc,huffi,zzi,token); - cost=d2+lambda*bits; - if(cost>zzj&1; - next=(zzj<<1)+tj; - tokens[zzi][1].next=(unsigned char)next; - tokens[zzi][1].token=(signed char)best_token; - tokens[zzi][1].eb=best_eb; - tokens[zzi][1].cost=best_cost+tokens[zzj][tj].cost; - tokens[zzi][1].bits=best_bits+tokens[zzj][tj].bits; - tokens[zzi][1].qc=qc+s^s; - nzflags|=(ogg_int64_t)1<state.opt_data.dct_fzig_zag; - zzi=1; - ti=best_flags>>1&1; - bits=tokens[zzi][ti].bits; - do{ - oc_enc_tokenlog_checkpoint(_enc,stack++,_pli,zzi); - eob=eob_run[zzi]; - if(tokens[zzi][ti].token=4095){ - oc_enc_eob_log(_enc,_pli,zzi,eob); - eob=0; - } - eob_run[zzi]=eob; - /*We don't include the actual EOB cost for this block in the return value. - It will be paid for by the fragment that terminates the EOB run.*/ - bits-=tokens[zzi][ti].bits; - zzi=_zzi; - break; - } - /*Emit pending EOB run if any.*/ - if(eob>0){ - oc_enc_eob_log(_enc,_pli,zzi,eob); - eob_run[zzi]=0; - } - oc_enc_token_log(_enc,_pli,zzi,tokens[zzi][ti].token,tokens[zzi][ti].eb); - next=tokens[zzi][ti].next; - qc=tokens[zzi][ti].qc; - zzj=(next>>1)-1&63; - /*TODO: It may be worth saving the dequantized coefficient in the trellis - above; we had to compute it to measure the error anyway.*/ - _qdct[dct_fzig_zag[zzj]]=(ogg_int16_t)(qc*(int)_dequant[zzj]); - zzi=next>>1; - ti=next&1; - } - while(zzi); - *_stack=stack; - return bits; -} - -void oc_enc_pred_dc_frag_rows(oc_enc_ctx *_enc, - int _pli,int _fragy0,int _frag_yend){ - const oc_fragment_plane *fplane; - const oc_fragment *frags; - ogg_int16_t *frag_dc; - ptrdiff_t fragi; - int *pred_last; - int nhfrags; - int fragx; - int fragy; - fplane=_enc->state.fplanes+_pli; - frags=_enc->state.frags; - frag_dc=_enc->frag_dc; - pred_last=_enc->dc_pred_last[_pli]; - nhfrags=fplane->nhfrags; - fragi=fplane->froffset+_fragy0*nhfrags; - for(fragy=_fragy0;fragy<_frag_yend;fragy++){ - if(fragy==0){ - /*For the first row, all of the cases reduce to just using the previous - predictor for the same reference frame.*/ - for(fragx=0;fragx=nhfrags)ur_ref=-1; - else{ - ur_ref=u_frags[fragi+1].coded? - OC_FRAME_FOR_MODE(u_frags[fragi+1].mb_mode):-1; - } - if(frags[fragi].coded){ - int pred; - int ref; - ref=OC_FRAME_FOR_MODE(frags[fragi].mb_mode); - /*We break out a separate case based on which of our neighbors use - the same reference frames. - This is somewhat faster than trying to make a generic case which - handles all of them, since it reduces lots of poorly predicted - jumps to one switch statement, and also lets a number of the - multiplications be optimized out by strength reduction.*/ - switch((l_ref==ref)|(ul_ref==ref)<<1| - (u_ref==ref)<<2|(ur_ref==ref)<<3){ - default:pred=pred_last[ref];break; - case 1: - case 3:pred=frags[fragi-1].dc;break; - case 2:pred=u_frags[fragi-1].dc;break; - case 4: - case 6: - case 12:pred=u_frags[fragi].dc;break; - case 5:pred=(frags[fragi-1].dc+u_frags[fragi].dc)/2;break; - case 8:pred=u_frags[fragi+1].dc;break; - case 9: - case 11: - case 13:{ - pred=(75*frags[fragi-1].dc+53*u_frags[fragi+1].dc)/128; - }break; - case 10:pred=(u_frags[fragi-1].dc+u_frags[fragi+1].dc)/2;break; - case 14:{ - pred=(3*(u_frags[fragi-1].dc+u_frags[fragi+1].dc) - +10*u_frags[fragi].dc)/16; - }break; - case 7: - case 15:{ - int p0; - int p1; - int p2; - p0=frags[fragi-1].dc; - p1=u_frags[fragi-1].dc; - p2=u_frags[fragi].dc; - pred=(29*(p0+p2)-26*p1)/32; - if(abs(pred-p2)>128)pred=p2; - else if(abs(pred-p0)>128)pred=p0; - else if(abs(pred-p1)>128)pred=p1; - }break; - } - frag_dc[fragi]=(ogg_int16_t)(frags[fragi].dc-pred); - pred_last[ref]=frags[fragi].dc; - l_ref=ref; - } - else l_ref=-1; - ul_ref=u_ref; - u_ref=ur_ref; - } - } - } -} - -void oc_enc_tokenize_dc_frag_list(oc_enc_ctx *_enc,int _pli, - const ptrdiff_t *_coded_fragis,ptrdiff_t _ncoded_fragis, - int _prev_ndct_tokens1,int _prev_eob_run1){ - const ogg_int16_t *frag_dc; - ptrdiff_t fragii; - unsigned char *dct_tokens0; - unsigned char *dct_tokens1; - ogg_uint16_t *extra_bits0; - ogg_uint16_t *extra_bits1; - ptrdiff_t ti0; - ptrdiff_t ti1r; - ptrdiff_t ti1w; - int eob_run0; - int eob_run1; - int neobs1; - int token; - int eb; - int token1=token1; - int eb1=eb1; - /*Return immediately if there are no coded fragments; otherwise we'd flush - any trailing EOB run into the AC 1 list and never read it back out.*/ - if(_ncoded_fragis<=0)return; - frag_dc=_enc->frag_dc; - dct_tokens0=_enc->dct_tokens[_pli][0]; - dct_tokens1=_enc->dct_tokens[_pli][1]; - extra_bits0=_enc->extra_bits[_pli][0]; - extra_bits1=_enc->extra_bits[_pli][1]; - ti0=_enc->ndct_tokens[_pli][0]; - ti1w=ti1r=_prev_ndct_tokens1; - eob_run0=_enc->eob_run[_pli][0]; - /*Flush any trailing EOB run for the 1st AC coefficient. - This is needed to allow us to track tokens to the end of the list.*/ - eob_run1=_enc->eob_run[_pli][1]; - if(eob_run1>0)oc_enc_eob_log(_enc,_pli,1,eob_run1); - /*If there was an active EOB run at the start of the 1st AC stack, read it - in and decode it.*/ - if(_prev_eob_run1>0){ - token1=dct_tokens1[ti1r]; - eb1=extra_bits1[ti1r]; - ti1r++; - eob_run1=oc_decode_eob_token(token1,eb1); - /*Consume the portion of the run that came before these fragments.*/ - neobs1=eob_run1-_prev_eob_run1; - } - else eob_run1=neobs1=0; - for(fragii=0;fragii<_ncoded_fragis;fragii++){ - int val; - /*All tokens in the 1st AC coefficient stack are regenerated as the DC - coefficients are produced. - This can be done in-place; stack 1 cannot get larger.*/ - if(!neobs1){ - /*There's no active EOB run in stack 1; read the next token.*/ - token1=dct_tokens1[ti1r]; - eb1=extra_bits1[ti1r]; - ti1r++; - if(token10){ - token=oc_make_eob_token_full(eob_run0,&eb); - dct_tokens0[ti0]=(unsigned char)token; - extra_bits0[ti0]=(ogg_uint16_t)eb; - ti0++; - eob_run0=0; - } - token=oc_make_dct_token_full(0,0,val,&eb); - dct_tokens0[ti0]=(unsigned char)token; - extra_bits0[ti0]=(ogg_uint16_t)eb; - ti0++; - } - else{ - /*Zero DC value; that means the entry in stack 1 might need to be coded - from stack 0. - This requires a stack 1 fixup.*/ - if(neobs1>0){ - /*We're in the middle of an active EOB run in stack 1. - Move it to stack 0.*/ - if(++eob_run0>=4095){ - token=oc_make_eob_token_full(eob_run0,&eb); - dct_tokens0[ti0]=(unsigned char)token; - extra_bits0[ti0]=(ogg_uint16_t)eb; - ti0++; - eob_run0=0; - } - eob_run1--; - } - else{ - /*No active EOB run in stack 1, so we can't extend one in stack 0. - Flush it if we've got it.*/ - if(eob_run0>0){ - token=oc_make_eob_token_full(eob_run0,&eb); - dct_tokens0[ti0]=(unsigned char)token; - extra_bits0[ti0]=(ogg_uint16_t)eb; - ti0++; - eob_run0=0; - } - /*Stack 1 token is one of: a pure zero run token, a single - coefficient token, or a zero run/coefficient combo token. - A zero run token is expanded and moved to token stack 0, and the - stack 1 entry dropped. - A single coefficient value may be transformed into combo token that - is moved to stack 0, or if it cannot be combined, it is left alone - and a single length-1 zero run is emitted in stack 0. - A combo token is extended and moved to stack 0. - During AC coding, we restrict the run lengths on combo tokens for - stack 1 to guarantee we can extend them.*/ - switch(token1){ - case OC_DCT_SHORT_ZRL_TOKEN:{ - if(eb1<7){ - dct_tokens0[ti0]=OC_DCT_SHORT_ZRL_TOKEN; - extra_bits0[ti0]=(ogg_uint16_t)(eb1+1); - ti0++; - /*Don't write the AC coefficient back out.*/ - continue; - } - /*Fall through.*/ - } - case OC_DCT_ZRL_TOKEN:{ - dct_tokens0[ti0]=OC_DCT_ZRL_TOKEN; - extra_bits0[ti0]=(ogg_uint16_t)(eb1+1); - ti0++; - /*Don't write the AC coefficient back out.*/ - }continue; - case OC_ONE_TOKEN: - case OC_MINUS_ONE_TOKEN:{ - dct_tokens0[ti0]=OC_DCT_RUN_CAT1A; - extra_bits0[ti0]=(ogg_uint16_t)(token1-OC_ONE_TOKEN); - ti0++; - /*Don't write the AC coefficient back out.*/ - }continue; - case OC_TWO_TOKEN: - case OC_MINUS_TWO_TOKEN:{ - dct_tokens0[ti0]=OC_DCT_RUN_CAT2A; - extra_bits0[ti0]=(ogg_uint16_t)(token1-OC_TWO_TOKEN<<1); - ti0++; - /*Don't write the AC coefficient back out.*/ - }continue; - case OC_DCT_VAL_CAT2:{ - dct_tokens0[ti0]=OC_DCT_RUN_CAT2A; - extra_bits0[ti0]=(ogg_uint16_t)((eb1<<1)+1); - ti0++; - /*Don't write the AC coefficient back out.*/ - }continue; - case OC_DCT_RUN_CAT1A: - case OC_DCT_RUN_CAT1A+1: - case OC_DCT_RUN_CAT1A+2: - case OC_DCT_RUN_CAT1A+3:{ - dct_tokens0[ti0]=(unsigned char)(token1+1); - extra_bits0[ti0]=(ogg_uint16_t)eb1; - ti0++; - /*Don't write the AC coefficient back out.*/ - }continue; - case OC_DCT_RUN_CAT1A+4:{ - dct_tokens0[ti0]=OC_DCT_RUN_CAT1B; - extra_bits0[ti0]=(ogg_uint16_t)(eb1<<2); - ti0++; - /*Don't write the AC coefficient back out.*/ - }continue; - case OC_DCT_RUN_CAT1B:{ - if((eb1&3)<3){ - dct_tokens0[ti0]=OC_DCT_RUN_CAT1B; - extra_bits0[ti0]=(ogg_uint16_t)(eb1+1); - ti0++; - /*Don't write the AC coefficient back out.*/ - continue; - } - eb1=((eb1&4)<<1)-1; - /*Fall through.*/ - } - case OC_DCT_RUN_CAT1C:{ - dct_tokens0[ti0]=OC_DCT_RUN_CAT1C; - extra_bits0[ti0]=(ogg_uint16_t)(eb1+1); - ti0++; - /*Don't write the AC coefficient back out.*/ - }continue; - case OC_DCT_RUN_CAT2A:{ - eb1=(eb1<<1)-1; - /*Fall through.*/ - } - case OC_DCT_RUN_CAT2B:{ - dct_tokens0[ti0]=OC_DCT_RUN_CAT2B; - extra_bits0[ti0]=(ogg_uint16_t)(eb1+1); - ti0++; - /*Don't write the AC coefficient back out.*/ - }continue; - } - /*We can't merge tokens, write a short zero run and keep going.*/ - dct_tokens0[ti0]=OC_DCT_SHORT_ZRL_TOKEN; - extra_bits0[ti0]=0; - ti0++; - } - } - if(!neobs1){ - /*Flush any (inactive) EOB run.*/ - if(eob_run1>0){ - token=oc_make_eob_token_full(eob_run1,&eb); - dct_tokens1[ti1w]=(unsigned char)token; - extra_bits1[ti1w]=(ogg_uint16_t)eb; - ti1w++; - eob_run1=0; - } - /*There's no active EOB run, so log the current token.*/ - dct_tokens1[ti1w]=(unsigned char)token1; - extra_bits1[ti1w]=(ogg_uint16_t)eb1; - ti1w++; - } - else{ - /*Otherwise consume one EOB from the current run.*/ - neobs1--; - /*If we have more than 4095 EOBs outstanding in stack1, flush the run.*/ - if(eob_run1-neobs1>=4095){ - token=oc_make_eob_token_full(4095,&eb); - dct_tokens1[ti1w]=(unsigned char)token; - extra_bits1[ti1w]=(ogg_uint16_t)eb; - ti1w++; - eob_run1-=4095; - } - } - } - /*Save the current state.*/ - _enc->ndct_tokens[_pli][0]=ti0; - _enc->ndct_tokens[_pli][1]=ti1w; - _enc->eob_run[_pli][0]=eob_run0; - _enc->eob_run[_pli][1]=eob_run1; -} - -/*Final EOB run welding.*/ -void oc_enc_tokenize_finish(oc_enc_ctx *_enc){ - int pli; - int zzi; - /*Emit final EOB runs.*/ - for(pli=0;pli<3;pli++)for(zzi=0;zzi<64;zzi++){ - int eob_run; - eob_run=_enc->eob_run[pli][zzi]; - if(eob_run>0)oc_enc_eob_log(_enc,pli,zzi,eob_run); - } - /*Merge the final EOB run of one token list with the start of the next, if - possible.*/ - for(zzi=0;zzi<64;zzi++)for(pli=0;pli<3;pli++){ - int old_tok1; - int old_tok2; - int old_eb1; - int old_eb2; - int new_tok; - int new_eb; - int zzj; - int plj; - ptrdiff_t ti=ti; - int run_count; - /*Make sure this coefficient has tokens at all.*/ - if(_enc->ndct_tokens[pli][zzi]<=0)continue; - /*Ensure the first token is an EOB run.*/ - old_tok2=_enc->dct_tokens[pli][zzi][0]; - if(old_tok2>=OC_NDCT_EOB_TOKEN_MAX)continue; - /*Search for a previous coefficient that has any tokens at all.*/ - old_tok1=OC_NDCT_EOB_TOKEN_MAX; - for(zzj=zzi,plj=pli;zzj>=0;zzj--){ - while(plj-->0){ - ti=_enc->ndct_tokens[plj][zzj]-1; - if(ti>=_enc->dct_token_offs[plj][zzj]){ - old_tok1=_enc->dct_tokens[plj][zzj][ti]; - break; - } - } - if(plj>=0)break; - plj=3; - } - /*Ensure its last token was an EOB run.*/ - if(old_tok1>=OC_NDCT_EOB_TOKEN_MAX)continue; - /*Pull off the associated extra bits, if any, and decode the runs.*/ - old_eb1=_enc->extra_bits[plj][zzj][ti]; - old_eb2=_enc->extra_bits[pli][zzi][0]; - run_count=oc_decode_eob_token(old_tok1,old_eb1) - +oc_decode_eob_token(old_tok2,old_eb2); - /*We can't possibly combine these into one run. - It might be possible to split them more optimally, but we'll just leave - them as-is.*/ - if(run_count>=4096)continue; - /*We CAN combine them into one run.*/ - new_tok=oc_make_eob_token_full(run_count,&new_eb); - _enc->dct_tokens[plj][zzj][ti]=(unsigned char)new_tok; - _enc->extra_bits[plj][zzj][ti]=(ogg_uint16_t)new_eb; - _enc->dct_token_offs[pli][zzi]++; - } -} diff --git a/Engine/lib/libtheora/lib/x86/mmxencfrag.c b/Engine/lib/libtheora/lib/x86/mmxencfrag.c deleted file mode 100644 index c79ff01fc..000000000 --- a/Engine/lib/libtheora/lib/x86/mmxencfrag.c +++ /dev/null @@ -1,900 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: dsp_mmx.c 14579 2008-03-12 06:42:40Z xiphmont $ - - ********************************************************************/ -#include -#include "x86enc.h" - -#if defined(OC_X86_ASM) - -unsigned oc_enc_frag_sad_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride){ - ptrdiff_t ystride3; - ptrdiff_t ret; - __asm__ __volatile__( - /*Load the first 4 rows of each block.*/ - "movq (%[src]),%%mm0\n\t" - "movq (%[ref]),%%mm1\n\t" - "movq (%[src],%[ystride]),%%mm2\n\t" - "movq (%[ref],%[ystride]),%%mm3\n\t" - "lea (%[ystride],%[ystride],2),%[ystride3]\n\t" - "movq (%[src],%[ystride],2),%%mm4\n\t" - "movq (%[ref],%[ystride],2),%%mm5\n\t" - "movq (%[src],%[ystride3]),%%mm6\n\t" - "movq (%[ref],%[ystride3]),%%mm7\n\t" - /*Compute their SADs and add them in %%mm0*/ - "psadbw %%mm1,%%mm0\n\t" - "psadbw %%mm3,%%mm2\n\t" - "lea (%[src],%[ystride],4),%[src]\n\t" - "paddw %%mm2,%%mm0\n\t" - "lea (%[ref],%[ystride],4),%[ref]\n\t" - /*Load the next 3 rows as registers become available.*/ - "movq (%[src]),%%mm2\n\t" - "movq (%[ref]),%%mm3\n\t" - "psadbw %%mm5,%%mm4\n\t" - "psadbw %%mm7,%%mm6\n\t" - "paddw %%mm4,%%mm0\n\t" - "movq (%[ref],%[ystride]),%%mm5\n\t" - "movq (%[src],%[ystride]),%%mm4\n\t" - "paddw %%mm6,%%mm0\n\t" - "movq (%[ref],%[ystride],2),%%mm7\n\t" - "movq (%[src],%[ystride],2),%%mm6\n\t" - /*Start adding their SADs to %%mm0*/ - "psadbw %%mm3,%%mm2\n\t" - "psadbw %%mm5,%%mm4\n\t" - "paddw %%mm2,%%mm0\n\t" - "psadbw %%mm7,%%mm6\n\t" - /*Load last row as registers become available.*/ - "movq (%[src],%[ystride3]),%%mm2\n\t" - "movq (%[ref],%[ystride3]),%%mm3\n\t" - /*And finish adding up their SADs.*/ - "paddw %%mm4,%%mm0\n\t" - "psadbw %%mm3,%%mm2\n\t" - "paddw %%mm6,%%mm0\n\t" - "paddw %%mm2,%%mm0\n\t" - "movd %%mm0,%[ret]\n\t" - :[ret]"=a"(ret),[src]"+%r"(_src),[ref]"+r"(_ref),[ystride3]"=&r"(ystride3) - :[ystride]"r"((ptrdiff_t)_ystride) - ); - return (unsigned)ret; -} - -unsigned oc_enc_frag_sad_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh){ - /*Early termination is for suckers.*/ - return oc_enc_frag_sad_mmxext(_src,_ref,_ystride); -} - -/*Assumes the first two rows of %[ref1] and %[ref2] are in %%mm0...%%mm3, the - first two rows of %[src] are in %%mm4,%%mm5, and {1}x8 is in %%mm7. - We pre-load the next two rows of data as registers become available.*/ -#define OC_SAD2_LOOP \ - "#OC_SAD2_LOOP\n\t" \ - /*We want to compute (%%mm0+%%mm1>>1) on unsigned bytes without overflow, but \ - pavgb computes (%%mm0+%%mm1+1>>1). \ - The latter is exactly 1 too large when the low bit of two corresponding \ - bytes is only set in one of them. \ - Therefore we pxor the operands, pand to mask out the low bits, and psubb to \ - correct the output of pavgb.*/ \ - "movq %%mm0,%%mm6\n\t" \ - "lea (%[ref1],%[ystride],2),%[ref1]\n\t" \ - "pxor %%mm1,%%mm0\n\t" \ - "pavgb %%mm1,%%mm6\n\t" \ - "lea (%[ref2],%[ystride],2),%[ref2]\n\t" \ - "movq %%mm2,%%mm1\n\t" \ - "pand %%mm7,%%mm0\n\t" \ - "pavgb %%mm3,%%mm2\n\t" \ - "pxor %%mm3,%%mm1\n\t" \ - "movq (%[ref2],%[ystride]),%%mm3\n\t" \ - "psubb %%mm0,%%mm6\n\t" \ - "movq (%[ref1]),%%mm0\n\t" \ - "pand %%mm7,%%mm1\n\t" \ - "psadbw %%mm6,%%mm4\n\t" \ - "movd %[ret],%%mm6\n\t" \ - "psubb %%mm1,%%mm2\n\t" \ - "movq (%[ref2]),%%mm1\n\t" \ - "lea (%[src],%[ystride],2),%[src]\n\t" \ - "psadbw %%mm2,%%mm5\n\t" \ - "movq (%[ref1],%[ystride]),%%mm2\n\t" \ - "paddw %%mm4,%%mm5\n\t" \ - "movq (%[src]),%%mm4\n\t" \ - "paddw %%mm5,%%mm6\n\t" \ - "movq (%[src],%[ystride]),%%mm5\n\t" \ - "movd %%mm6,%[ret]\n\t" \ - -/*Same as above, but does not pre-load the next two rows.*/ -#define OC_SAD2_TAIL \ - "#OC_SAD2_TAIL\n\t" \ - "movq %%mm0,%%mm6\n\t" \ - "pavgb %%mm1,%%mm0\n\t" \ - "pxor %%mm1,%%mm6\n\t" \ - "movq %%mm2,%%mm1\n\t" \ - "pand %%mm7,%%mm6\n\t" \ - "pavgb %%mm3,%%mm2\n\t" \ - "pxor %%mm3,%%mm1\n\t" \ - "psubb %%mm6,%%mm0\n\t" \ - "pand %%mm7,%%mm1\n\t" \ - "psadbw %%mm0,%%mm4\n\t" \ - "psubb %%mm1,%%mm2\n\t" \ - "movd %[ret],%%mm6\n\t" \ - "psadbw %%mm2,%%mm5\n\t" \ - "paddw %%mm4,%%mm5\n\t" \ - "paddw %%mm5,%%mm6\n\t" \ - "movd %%mm6,%[ret]\n\t" \ - -unsigned oc_enc_frag_sad2_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh){ - ptrdiff_t ret; - __asm__ __volatile__( - "movq (%[ref1]),%%mm0\n\t" - "movq (%[ref2]),%%mm1\n\t" - "movq (%[ref1],%[ystride]),%%mm2\n\t" - "movq (%[ref2],%[ystride]),%%mm3\n\t" - "xor %[ret],%[ret]\n\t" - "movq (%[src]),%%mm4\n\t" - "pxor %%mm7,%%mm7\n\t" - "pcmpeqb %%mm6,%%mm6\n\t" - "movq (%[src],%[ystride]),%%mm5\n\t" - "psubb %%mm6,%%mm7\n\t" - OC_SAD2_LOOP - OC_SAD2_LOOP - OC_SAD2_LOOP - OC_SAD2_TAIL - :[ret]"=&a"(ret),[src]"+r"(_src),[ref1]"+%r"(_ref1),[ref2]"+r"(_ref2) - :[ystride]"r"((ptrdiff_t)_ystride) - ); - return (unsigned)ret; -} - -/*Load an 8x4 array of pixel values from %[src] and %[ref] and compute their - 16-bit difference in %%mm0...%%mm7.*/ -#define OC_LOAD_SUB_8x4(_off) \ - "#OC_LOAD_SUB_8x4\n\t" \ - "movd "_off"(%[src]),%%mm0\n\t" \ - "movd "_off"(%[ref]),%%mm4\n\t" \ - "movd "_off"(%[src],%[src_ystride]),%%mm1\n\t" \ - "lea (%[src],%[src_ystride],2),%[src]\n\t" \ - "movd "_off"(%[ref],%[ref_ystride]),%%mm5\n\t" \ - "lea (%[ref],%[ref_ystride],2),%[ref]\n\t" \ - "movd "_off"(%[src]),%%mm2\n\t" \ - "movd "_off"(%[ref]),%%mm7\n\t" \ - "movd "_off"(%[src],%[src_ystride]),%%mm3\n\t" \ - "movd "_off"(%[ref],%[ref_ystride]),%%mm6\n\t" \ - "punpcklbw %%mm4,%%mm0\n\t" \ - "lea (%[src],%[src_ystride],2),%[src]\n\t" \ - "punpcklbw %%mm4,%%mm4\n\t" \ - "lea (%[ref],%[ref_ystride],2),%[ref]\n\t" \ - "psubw %%mm4,%%mm0\n\t" \ - "movd "_off"(%[src]),%%mm4\n\t" \ - "movq %%mm0,"_off"*2(%[buf])\n\t" \ - "movd "_off"(%[ref]),%%mm0\n\t" \ - "punpcklbw %%mm5,%%mm1\n\t" \ - "punpcklbw %%mm5,%%mm5\n\t" \ - "psubw %%mm5,%%mm1\n\t" \ - "movd "_off"(%[src],%[src_ystride]),%%mm5\n\t" \ - "punpcklbw %%mm7,%%mm2\n\t" \ - "punpcklbw %%mm7,%%mm7\n\t" \ - "psubw %%mm7,%%mm2\n\t" \ - "movd "_off"(%[ref],%[ref_ystride]),%%mm7\n\t" \ - "punpcklbw %%mm6,%%mm3\n\t" \ - "lea (%[src],%[src_ystride],2),%[src]\n\t" \ - "punpcklbw %%mm6,%%mm6\n\t" \ - "psubw %%mm6,%%mm3\n\t" \ - "movd "_off"(%[src]),%%mm6\n\t" \ - "punpcklbw %%mm0,%%mm4\n\t" \ - "lea (%[ref],%[ref_ystride],2),%[ref]\n\t" \ - "punpcklbw %%mm0,%%mm0\n\t" \ - "lea (%[src],%[src_ystride],2),%[src]\n\t" \ - "psubw %%mm0,%%mm4\n\t" \ - "movd "_off"(%[ref]),%%mm0\n\t" \ - "punpcklbw %%mm7,%%mm5\n\t" \ - "neg %[src_ystride]\n\t" \ - "punpcklbw %%mm7,%%mm7\n\t" \ - "psubw %%mm7,%%mm5\n\t" \ - "movd "_off"(%[src],%[src_ystride]),%%mm7\n\t" \ - "punpcklbw %%mm0,%%mm6\n\t" \ - "lea (%[ref],%[ref_ystride],2),%[ref]\n\t" \ - "punpcklbw %%mm0,%%mm0\n\t" \ - "neg %[ref_ystride]\n\t" \ - "psubw %%mm0,%%mm6\n\t" \ - "movd "_off"(%[ref],%[ref_ystride]),%%mm0\n\t" \ - "lea (%[src],%[src_ystride],8),%[src]\n\t" \ - "punpcklbw %%mm0,%%mm7\n\t" \ - "neg %[src_ystride]\n\t" \ - "punpcklbw %%mm0,%%mm0\n\t" \ - "lea (%[ref],%[ref_ystride],8),%[ref]\n\t" \ - "psubw %%mm0,%%mm7\n\t" \ - "neg %[ref_ystride]\n\t" \ - "movq "_off"*2(%[buf]),%%mm0\n\t" \ - -/*Load an 8x4 array of pixel values from %[src] into %%mm0...%%mm7.*/ -#define OC_LOAD_8x4(_off) \ - "#OC_LOAD_8x4\n\t" \ - "movd "_off"(%[src]),%%mm0\n\t" \ - "movd "_off"(%[src],%[ystride]),%%mm1\n\t" \ - "movd "_off"(%[src],%[ystride],2),%%mm2\n\t" \ - "pxor %%mm7,%%mm7\n\t" \ - "movd "_off"(%[src],%[ystride3]),%%mm3\n\t" \ - "punpcklbw %%mm7,%%mm0\n\t" \ - "movd "_off"(%[src4]),%%mm4\n\t" \ - "punpcklbw %%mm7,%%mm1\n\t" \ - "movd "_off"(%[src4],%[ystride]),%%mm5\n\t" \ - "punpcklbw %%mm7,%%mm2\n\t" \ - "movd "_off"(%[src4],%[ystride],2),%%mm6\n\t" \ - "punpcklbw %%mm7,%%mm3\n\t" \ - "movd "_off"(%[src4],%[ystride3]),%%mm7\n\t" \ - "punpcklbw %%mm4,%%mm4\n\t" \ - "punpcklbw %%mm5,%%mm5\n\t" \ - "psrlw $8,%%mm4\n\t" \ - "psrlw $8,%%mm5\n\t" \ - "punpcklbw %%mm6,%%mm6\n\t" \ - "punpcklbw %%mm7,%%mm7\n\t" \ - "psrlw $8,%%mm6\n\t" \ - "psrlw $8,%%mm7\n\t" \ - -/*Performs the first two stages of an 8-point 1-D Hadamard transform. - The transform is performed in place, except that outputs 0-3 are swapped with - outputs 4-7. - Outputs 2, 3, 6 and 7 from the second stage are negated (which allows us to - perform this stage in place with no temporary registers).*/ -#define OC_HADAMARD_AB_8x4 \ - "#OC_HADAMARD_AB_8x4\n\t" \ - /*Stage A: \ - Outputs 0-3 are swapped with 4-7 here.*/ \ - "paddw %%mm1,%%mm5\n\t" \ - "paddw %%mm2,%%mm6\n\t" \ - "paddw %%mm1,%%mm1\n\t" \ - "paddw %%mm2,%%mm2\n\t" \ - "psubw %%mm5,%%mm1\n\t" \ - "psubw %%mm6,%%mm2\n\t" \ - "paddw %%mm3,%%mm7\n\t" \ - "paddw %%mm0,%%mm4\n\t" \ - "paddw %%mm3,%%mm3\n\t" \ - "paddw %%mm0,%%mm0\n\t" \ - "psubw %%mm7,%%mm3\n\t" \ - "psubw %%mm4,%%mm0\n\t" \ - /*Stage B:*/ \ - "paddw %%mm2,%%mm0\n\t" \ - "paddw %%mm3,%%mm1\n\t" \ - "paddw %%mm6,%%mm4\n\t" \ - "paddw %%mm7,%%mm5\n\t" \ - "paddw %%mm2,%%mm2\n\t" \ - "paddw %%mm3,%%mm3\n\t" \ - "paddw %%mm6,%%mm6\n\t" \ - "paddw %%mm7,%%mm7\n\t" \ - "psubw %%mm0,%%mm2\n\t" \ - "psubw %%mm1,%%mm3\n\t" \ - "psubw %%mm4,%%mm6\n\t" \ - "psubw %%mm5,%%mm7\n\t" \ - -/*Performs the last stage of an 8-point 1-D Hadamard transform in place. - Ouputs 1, 3, 5, and 7 are negated (which allows us to perform this stage in - place with no temporary registers).*/ -#define OC_HADAMARD_C_8x4 \ - "#OC_HADAMARD_C_8x4\n\t" \ - /*Stage C:*/ \ - "paddw %%mm1,%%mm0\n\t" \ - "paddw %%mm3,%%mm2\n\t" \ - "paddw %%mm5,%%mm4\n\t" \ - "paddw %%mm7,%%mm6\n\t" \ - "paddw %%mm1,%%mm1\n\t" \ - "paddw %%mm3,%%mm3\n\t" \ - "paddw %%mm5,%%mm5\n\t" \ - "paddw %%mm7,%%mm7\n\t" \ - "psubw %%mm0,%%mm1\n\t" \ - "psubw %%mm2,%%mm3\n\t" \ - "psubw %%mm4,%%mm5\n\t" \ - "psubw %%mm6,%%mm7\n\t" \ - -/*Performs an 8-point 1-D Hadamard transform. - The transform is performed in place, except that outputs 0-3 are swapped with - outputs 4-7. - Outputs 1, 2, 5 and 6 are negated (which allows us to perform the transform - in place with no temporary registers).*/ -#define OC_HADAMARD_8x4 \ - OC_HADAMARD_AB_8x4 \ - OC_HADAMARD_C_8x4 \ - -/*Performs the first part of the final stage of the Hadamard transform and - summing of absolute values. - At the end of this part, %%mm1 will contain the DC coefficient of the - transform.*/ -#define OC_HADAMARD_C_ABS_ACCUM_A_8x4(_r6,_r7) \ - /*We use the fact that \ - (abs(a+b)+abs(a-b))/2=max(abs(a),abs(b)) \ - to merge the final butterfly with the abs and the first stage of \ - accumulation. \ - Thus we can avoid using pabsw, which is not available until SSSE3. \ - Emulating pabsw takes 3 instructions, so the straightforward MMXEXT \ - implementation would be (3+3)*8+7=55 instructions (+4 for spilling \ - registers). \ - Even with pabsw, it would be (3+1)*8+7=39 instructions (with no spills). \ - This implementation is only 26 (+4 for spilling registers).*/ \ - "#OC_HADAMARD_C_ABS_ACCUM_A_8x4\n\t" \ - "movq %%mm7,"_r7"(%[buf])\n\t" \ - "movq %%mm6,"_r6"(%[buf])\n\t" \ - /*mm7={0x7FFF}x4 \ - mm0=max(abs(mm0),abs(mm1))-0x7FFF*/ \ - "pcmpeqb %%mm7,%%mm7\n\t" \ - "movq %%mm0,%%mm6\n\t" \ - "psrlw $1,%%mm7\n\t" \ - "paddw %%mm1,%%mm6\n\t" \ - "pmaxsw %%mm1,%%mm0\n\t" \ - "paddsw %%mm7,%%mm6\n\t" \ - "psubw %%mm6,%%mm0\n\t" \ - /*mm2=max(abs(mm2),abs(mm3))-0x7FFF \ - mm4=max(abs(mm4),abs(mm5))-0x7FFF*/ \ - "movq %%mm2,%%mm6\n\t" \ - "movq %%mm4,%%mm1\n\t" \ - "pmaxsw %%mm3,%%mm2\n\t" \ - "pmaxsw %%mm5,%%mm4\n\t" \ - "paddw %%mm3,%%mm6\n\t" \ - "paddw %%mm5,%%mm1\n\t" \ - "movq "_r7"(%[buf]),%%mm3\n\t" \ - -/*Performs the second part of the final stage of the Hadamard transform and - summing of absolute values.*/ -#define OC_HADAMARD_C_ABS_ACCUM_B_8x4(_r6,_r7) \ - "#OC_HADAMARD_C_ABS_ACCUM_B_8x4\n\t" \ - "paddsw %%mm7,%%mm6\n\t" \ - "movq "_r6"(%[buf]),%%mm5\n\t" \ - "paddsw %%mm7,%%mm1\n\t" \ - "psubw %%mm6,%%mm2\n\t" \ - "psubw %%mm1,%%mm4\n\t" \ - /*mm7={1}x4 (needed for the horizontal add that follows) \ - mm0+=mm2+mm4+max(abs(mm3),abs(mm5))-0x7FFF*/ \ - "movq %%mm3,%%mm6\n\t" \ - "pmaxsw %%mm5,%%mm3\n\t" \ - "paddw %%mm2,%%mm0\n\t" \ - "paddw %%mm5,%%mm6\n\t" \ - "paddw %%mm4,%%mm0\n\t" \ - "paddsw %%mm7,%%mm6\n\t" \ - "paddw %%mm3,%%mm0\n\t" \ - "psrlw $14,%%mm7\n\t" \ - "psubw %%mm6,%%mm0\n\t" \ - -/*Performs the last stage of an 8-point 1-D Hadamard transform, takes the - absolute value of each component, and accumulates everything into mm0. - This is the only portion of SATD which requires MMXEXT (we could use plain - MMX, but it takes 4 instructions and an extra register to work around the - lack of a pmaxsw, which is a pretty serious penalty).*/ -#define OC_HADAMARD_C_ABS_ACCUM_8x4(_r6,_r7) \ - OC_HADAMARD_C_ABS_ACCUM_A_8x4(_r6,_r7) \ - OC_HADAMARD_C_ABS_ACCUM_B_8x4(_r6,_r7) \ - -/*Performs an 8-point 1-D Hadamard transform, takes the absolute value of each - component, and accumulates everything into mm0. - Note that mm0 will have an extra 4 added to each column, and that after - removing this value, the remainder will be half the conventional value.*/ -#define OC_HADAMARD_ABS_ACCUM_8x4(_r6,_r7) \ - OC_HADAMARD_AB_8x4 \ - OC_HADAMARD_C_ABS_ACCUM_8x4(_r6,_r7) - -/*Performs two 4x4 transposes (mostly) in place. - On input, {mm0,mm1,mm2,mm3} contains rows {e,f,g,h}, and {mm4,mm5,mm6,mm7} - contains rows {a,b,c,d}. - On output, {0x40,0x50,0x60,0x70}+_off(%[buf]) contains {e,f,g,h}^T, and - {mm4,mm5,mm6,mm7} contains the transposed rows {a,b,c,d}^T.*/ -#define OC_TRANSPOSE_4x4x2(_off) \ - "#OC_TRANSPOSE_4x4x2\n\t" \ - /*First 4x4 transpose:*/ \ - "movq %%mm5,0x10+"_off"(%[buf])\n\t" \ - /*mm0 = e3 e2 e1 e0 \ - mm1 = f3 f2 f1 f0 \ - mm2 = g3 g2 g1 g0 \ - mm3 = h3 h2 h1 h0*/ \ - "movq %%mm2,%%mm5\n\t" \ - "punpcklwd %%mm3,%%mm2\n\t" \ - "punpckhwd %%mm3,%%mm5\n\t" \ - "movq %%mm0,%%mm3\n\t" \ - "punpcklwd %%mm1,%%mm0\n\t" \ - "punpckhwd %%mm1,%%mm3\n\t" \ - /*mm0 = f1 e1 f0 e0 \ - mm3 = f3 e3 f2 e2 \ - mm2 = h1 g1 h0 g0 \ - mm5 = h3 g3 h2 g2*/ \ - "movq %%mm0,%%mm1\n\t" \ - "punpckldq %%mm2,%%mm0\n\t" \ - "punpckhdq %%mm2,%%mm1\n\t" \ - "movq %%mm3,%%mm2\n\t" \ - "punpckhdq %%mm5,%%mm3\n\t" \ - "movq %%mm0,0x40+"_off"(%[buf])\n\t" \ - "punpckldq %%mm5,%%mm2\n\t" \ - /*mm0 = h0 g0 f0 e0 \ - mm1 = h1 g1 f1 e1 \ - mm2 = h2 g2 f2 e2 \ - mm3 = h3 g3 f3 e3*/ \ - "movq 0x10+"_off"(%[buf]),%%mm5\n\t" \ - /*Second 4x4 transpose:*/ \ - /*mm4 = a3 a2 a1 a0 \ - mm5 = b3 b2 b1 b0 \ - mm6 = c3 c2 c1 c0 \ - mm7 = d3 d2 d1 d0*/ \ - "movq %%mm6,%%mm0\n\t" \ - "punpcklwd %%mm7,%%mm6\n\t" \ - "movq %%mm1,0x50+"_off"(%[buf])\n\t" \ - "punpckhwd %%mm7,%%mm0\n\t" \ - "movq %%mm4,%%mm7\n\t" \ - "punpcklwd %%mm5,%%mm4\n\t" \ - "movq %%mm2,0x60+"_off"(%[buf])\n\t" \ - "punpckhwd %%mm5,%%mm7\n\t" \ - /*mm4 = b1 a1 b0 a0 \ - mm7 = b3 a3 b2 a2 \ - mm6 = d1 c1 d0 c0 \ - mm0 = d3 c3 d2 c2*/ \ - "movq %%mm4,%%mm5\n\t" \ - "punpckldq %%mm6,%%mm4\n\t" \ - "movq %%mm3,0x70+"_off"(%[buf])\n\t" \ - "punpckhdq %%mm6,%%mm5\n\t" \ - "movq %%mm7,%%mm6\n\t" \ - "punpckhdq %%mm0,%%mm7\n\t" \ - "punpckldq %%mm0,%%mm6\n\t" \ - /*mm4 = d0 c0 b0 a0 \ - mm5 = d1 c1 b1 a1 \ - mm6 = d2 c2 b2 a2 \ - mm7 = d3 c3 b3 a3*/ \ - -static unsigned oc_int_frag_satd_thresh_mmxext(const unsigned char *_src, - int _src_ystride,const unsigned char *_ref,int _ref_ystride,unsigned _thresh){ - OC_ALIGN8(ogg_int16_t buf[64]); - ogg_int16_t *bufp; - unsigned ret; - unsigned ret2; - bufp=buf; - __asm__ __volatile__( - OC_LOAD_SUB_8x4("0x00") - OC_HADAMARD_8x4 - OC_TRANSPOSE_4x4x2("0x00") - /*Finish swapping out this 8x4 block to make room for the next one. - mm0...mm3 have been swapped out already.*/ - "movq %%mm4,0x00(%[buf])\n\t" - "movq %%mm5,0x10(%[buf])\n\t" - "movq %%mm6,0x20(%[buf])\n\t" - "movq %%mm7,0x30(%[buf])\n\t" - OC_LOAD_SUB_8x4("0x04") - OC_HADAMARD_8x4 - OC_TRANSPOSE_4x4x2("0x08") - /*Here the first 4x4 block of output from the last transpose is the second - 4x4 block of input for the next transform. - We have cleverly arranged that it already be in the appropriate place, so - we only have to do half the loads.*/ - "movq 0x10(%[buf]),%%mm1\n\t" - "movq 0x20(%[buf]),%%mm2\n\t" - "movq 0x30(%[buf]),%%mm3\n\t" - "movq 0x00(%[buf]),%%mm0\n\t" - OC_HADAMARD_ABS_ACCUM_8x4("0x28","0x38") - /*Up to this point, everything fit in 16 bits (8 input + 1 for the - difference + 2*3 for the two 8-point 1-D Hadamards - 1 for the abs - 1 - for the factor of two we dropped + 3 for the vertical accumulation). - Now we finally have to promote things to dwords. - We break this part out of OC_HADAMARD_ABS_ACCUM_8x4 to hide the long - latency of pmaddwd by starting the next series of loads now.*/ - "mov %[thresh],%[ret2]\n\t" - "pmaddwd %%mm7,%%mm0\n\t" - "movq 0x50(%[buf]),%%mm1\n\t" - "movq 0x58(%[buf]),%%mm5\n\t" - "movq %%mm0,%%mm4\n\t" - "movq 0x60(%[buf]),%%mm2\n\t" - "punpckhdq %%mm0,%%mm0\n\t" - "movq 0x68(%[buf]),%%mm6\n\t" - "paddd %%mm0,%%mm4\n\t" - "movq 0x70(%[buf]),%%mm3\n\t" - "movd %%mm4,%[ret]\n\t" - "movq 0x78(%[buf]),%%mm7\n\t" - /*The sums produced by OC_HADAMARD_ABS_ACCUM_8x4 each have an extra 4 - added to them, and a factor of two removed; correct the final sum here.*/ - "lea -32(%[ret],%[ret]),%[ret]\n\t" - "movq 0x40(%[buf]),%%mm0\n\t" - "cmp %[ret2],%[ret]\n\t" - "movq 0x48(%[buf]),%%mm4\n\t" - "jae 1f\n\t" - OC_HADAMARD_ABS_ACCUM_8x4("0x68","0x78") - "pmaddwd %%mm7,%%mm0\n\t" - /*There isn't much to stick in here to hide the latency this time, but the - alternative to pmaddwd is movq->punpcklwd->punpckhwd->paddd, whose - latency is even worse.*/ - "sub $32,%[ret]\n\t" - "movq %%mm0,%%mm4\n\t" - "punpckhdq %%mm0,%%mm0\n\t" - "paddd %%mm0,%%mm4\n\t" - "movd %%mm4,%[ret2]\n\t" - "lea (%[ret],%[ret2],2),%[ret]\n\t" - ".p2align 4,,15\n\t" - "1:\n\t" - /*Although it looks like we're using 7 registers here, gcc can alias %[ret] - and %[ret2] with some of the inputs, since for once we don't write to - them until after we're done using everything but %[buf] (which is also - listed as an output to ensure gcc _doesn't_ alias them against it).*/ - /*Note that _src_ystride and _ref_ystride must be given non-overlapping - constraints, otherewise if gcc can prove they're equal it will allocate - them to the same register (which is bad); _src and _ref face a similar - problem, though those are never actually the same.*/ - :[ret]"=a"(ret),[ret2]"=r"(ret2),[buf]"+r"(bufp) - :[src]"r"(_src),[src_ystride]"c"((ptrdiff_t)_src_ystride), - [ref]"r"(_ref),[ref_ystride]"d"((ptrdiff_t)_ref_ystride), - [thresh]"m"(_thresh) - /*We have to use neg, so we actually clobber the condition codes for once - (not to mention cmp, sub, and add).*/ - :"cc" - ); - return ret; -} - -unsigned oc_enc_frag_satd_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh){ - return oc_int_frag_satd_thresh_mmxext(_src,_ystride,_ref,_ystride,_thresh); -} - -/*Our internal implementation of frag_copy2 takes an extra stride parameter so - we can share code with oc_enc_frag_satd2_thresh_mmxext().*/ -static void oc_int_frag_copy2_mmxext(unsigned char *_dst,int _dst_ystride, - const unsigned char *_src1,const unsigned char *_src2,int _src_ystride){ - __asm__ __volatile__( - /*Load the first 3 rows.*/ - "movq (%[src1]),%%mm0\n\t" - "movq (%[src2]),%%mm1\n\t" - "movq (%[src1],%[src_ystride]),%%mm2\n\t" - "lea (%[src1],%[src_ystride],2),%[src1]\n\t" - "movq (%[src2],%[src_ystride]),%%mm3\n\t" - "lea (%[src2],%[src_ystride],2),%[src2]\n\t" - "pxor %%mm7,%%mm7\n\t" - "movq (%[src1]),%%mm4\n\t" - "pcmpeqb %%mm6,%%mm6\n\t" - "movq (%[src2]),%%mm5\n\t" - /*mm7={1}x8.*/ - "psubb %%mm6,%%mm7\n\t" - /*Start averaging %%mm0 and %%mm1 into %%mm6.*/ - "movq %%mm0,%%mm6\n\t" - "pxor %%mm1,%%mm0\n\t" - "pavgb %%mm1,%%mm6\n\t" - /*%%mm1 is free, start averaging %%mm3 into %%mm2 using %%mm1.*/ - "movq %%mm2,%%mm1\n\t" - "pand %%mm7,%%mm0\n\t" - "pavgb %%mm3,%%mm2\n\t" - "pxor %%mm3,%%mm1\n\t" - /*%%mm3 is free.*/ - "psubb %%mm0,%%mm6\n\t" - /*%%mm0 is free, start loading the next row.*/ - "movq (%[src1],%[src_ystride]),%%mm0\n\t" - /*Start averaging %%mm5 and %%mm4 using %%mm3.*/ - "movq %%mm4,%%mm3\n\t" - /*%%mm6 (row 0) is done; write it out.*/ - "movq %%mm6,(%[dst])\n\t" - "pand %%mm7,%%mm1\n\t" - "pavgb %%mm5,%%mm4\n\t" - "psubb %%mm1,%%mm2\n\t" - /*%%mm1 is free, continue loading the next row.*/ - "movq (%[src2],%[src_ystride]),%%mm1\n\t" - "pxor %%mm5,%%mm3\n\t" - "lea (%[src1],%[src_ystride],2),%[src1]\n\t" - /*%%mm2 (row 1) is done; write it out.*/ - "movq %%mm2,(%[dst],%[dst_ystride])\n\t" - "pand %%mm7,%%mm3\n\t" - /*Start loading the next row.*/ - "movq (%[src1]),%%mm2\n\t" - "lea (%[dst],%[dst_ystride],2),%[dst]\n\t" - "psubb %%mm3,%%mm4\n\t" - "lea (%[src2],%[src_ystride],2),%[src2]\n\t" - /*%%mm4 (row 2) is done; write it out.*/ - "movq %%mm4,(%[dst])\n\t" - /*Continue loading the next row.*/ - "movq (%[src2]),%%mm3\n\t" - /*Start averaging %%mm0 and %%mm1 into %%mm6.*/ - "movq %%mm0,%%mm6\n\t" - "pxor %%mm1,%%mm0\n\t" - /*Start loading the next row.*/ - "movq (%[src1],%[src_ystride]),%%mm4\n\t" - "pavgb %%mm1,%%mm6\n\t" - /*%%mm1 is free; start averaging %%mm3 into %%mm2 using %%mm1.*/ - "movq %%mm2,%%mm1\n\t" - "pand %%mm7,%%mm0\n\t" - /*Continue loading the next row.*/ - "movq (%[src2],%[src_ystride]),%%mm5\n\t" - "pavgb %%mm3,%%mm2\n\t" - "lea (%[src1],%[src_ystride],2),%[src1]\n\t" - "pxor %%mm3,%%mm1\n\t" - /*%%mm3 is free.*/ - "psubb %%mm0,%%mm6\n\t" - /*%%mm0 is free, start loading the next row.*/ - "movq (%[src1]),%%mm0\n\t" - /*Start averaging %%mm5 into %%mm4 using %%mm3.*/ - "movq %%mm4,%%mm3\n\t" - /*%%mm6 (row 3) is done; write it out.*/ - "movq %%mm6,(%[dst],%[dst_ystride])\n\t" - "pand %%mm7,%%mm1\n\t" - "lea (%[src2],%[src_ystride],2),%[src2]\n\t" - "pavgb %%mm5,%%mm4\n\t" - "lea (%[dst],%[dst_ystride],2),%[dst]\n\t" - "psubb %%mm1,%%mm2\n\t" - /*%%mm1 is free; continue loading the next row.*/ - "movq (%[src2]),%%mm1\n\t" - "pxor %%mm5,%%mm3\n\t" - /*%%mm2 (row 4) is done; write it out.*/ - "movq %%mm2,(%[dst])\n\t" - "pand %%mm7,%%mm3\n\t" - /*Start loading the next row.*/ - "movq (%[src1],%[src_ystride]),%%mm2\n\t" - "psubb %%mm3,%%mm4\n\t" - /*Start averaging %%mm0 and %%mm1 into %%mm6.*/ - "movq %%mm0,%%mm6\n\t" - /*Continue loading the next row.*/ - "movq (%[src2],%[src_ystride]),%%mm3\n\t" - /*%%mm4 (row 5) is done; write it out.*/ - "movq %%mm4,(%[dst],%[dst_ystride])\n\t" - "pxor %%mm1,%%mm0\n\t" - "pavgb %%mm1,%%mm6\n\t" - /*%%mm4 is free; start averaging %%mm3 into %%mm2 using %%mm4.*/ - "movq %%mm2,%%mm4\n\t" - "pand %%mm7,%%mm0\n\t" - "pavgb %%mm3,%%mm2\n\t" - "pxor %%mm3,%%mm4\n\t" - "lea (%[dst],%[dst_ystride],2),%[dst]\n\t" - "psubb %%mm0,%%mm6\n\t" - "pand %%mm7,%%mm4\n\t" - /*%%mm6 (row 6) is done, write it out.*/ - "movq %%mm6,(%[dst])\n\t" - "psubb %%mm4,%%mm2\n\t" - /*%%mm2 (row 7) is done, write it out.*/ - "movq %%mm2,(%[dst],%[dst_ystride])\n\t" - :[dst]"+r"(_dst),[src1]"+%r"(_src1),[src2]"+r"(_src2) - :[dst_ystride]"r"((ptrdiff_t)_dst_ystride), - [src_ystride]"r"((ptrdiff_t)_src_ystride) - :"memory" - ); -} - -unsigned oc_enc_frag_satd2_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh){ - OC_ALIGN8(unsigned char ref[64]); - oc_int_frag_copy2_mmxext(ref,8,_ref1,_ref2,_ystride); - return oc_int_frag_satd_thresh_mmxext(_src,_ystride,ref,8,_thresh); -} - -unsigned oc_enc_frag_intra_satd_mmxext(const unsigned char *_src, - int _ystride){ - OC_ALIGN8(ogg_int16_t buf[64]); - ogg_int16_t *bufp; - unsigned ret; - unsigned ret2; - bufp=buf; - __asm__ __volatile__( - OC_LOAD_8x4("0x00") - OC_HADAMARD_8x4 - OC_TRANSPOSE_4x4x2("0x00") - /*Finish swapping out this 8x4 block to make room for the next one. - mm0...mm3 have been swapped out already.*/ - "movq %%mm4,0x00(%[buf])\n\t" - "movq %%mm5,0x10(%[buf])\n\t" - "movq %%mm6,0x20(%[buf])\n\t" - "movq %%mm7,0x30(%[buf])\n\t" - OC_LOAD_8x4("0x04") - OC_HADAMARD_8x4 - OC_TRANSPOSE_4x4x2("0x08") - /*Here the first 4x4 block of output from the last transpose is the second - 4x4 block of input for the next transform. - We have cleverly arranged that it already be in the appropriate place, so - we only have to do half the loads.*/ - "movq 0x10(%[buf]),%%mm1\n\t" - "movq 0x20(%[buf]),%%mm2\n\t" - "movq 0x30(%[buf]),%%mm3\n\t" - "movq 0x00(%[buf]),%%mm0\n\t" - /*We split out the stages here so we can save the DC coefficient in the - middle.*/ - OC_HADAMARD_AB_8x4 - OC_HADAMARD_C_ABS_ACCUM_A_8x4("0x28","0x38") - "movd %%mm1,%[ret]\n\t" - OC_HADAMARD_C_ABS_ACCUM_B_8x4("0x28","0x38") - /*Up to this point, everything fit in 16 bits (8 input + 1 for the - difference + 2*3 for the two 8-point 1-D Hadamards - 1 for the abs - 1 - for the factor of two we dropped + 3 for the vertical accumulation). - Now we finally have to promote things to dwords. - We break this part out of OC_HADAMARD_ABS_ACCUM_8x4 to hide the long - latency of pmaddwd by starting the next series of loads now.*/ - "pmaddwd %%mm7,%%mm0\n\t" - "movq 0x50(%[buf]),%%mm1\n\t" - "movq 0x58(%[buf]),%%mm5\n\t" - "movq 0x60(%[buf]),%%mm2\n\t" - "movq %%mm0,%%mm4\n\t" - "movq 0x68(%[buf]),%%mm6\n\t" - "punpckhdq %%mm0,%%mm0\n\t" - "movq 0x70(%[buf]),%%mm3\n\t" - "paddd %%mm0,%%mm4\n\t" - "movq 0x78(%[buf]),%%mm7\n\t" - "movd %%mm4,%[ret2]\n\t" - "movq 0x40(%[buf]),%%mm0\n\t" - "movq 0x48(%[buf]),%%mm4\n\t" - OC_HADAMARD_ABS_ACCUM_8x4("0x68","0x78") - "pmaddwd %%mm7,%%mm0\n\t" - /*We assume that the DC coefficient is always positive (which is true, - because the input to the INTRA transform was not a difference).*/ - "movzx %w[ret],%[ret]\n\t" - "add %[ret2],%[ret2]\n\t" - "sub %[ret],%[ret2]\n\t" - "movq %%mm0,%%mm4\n\t" - "punpckhdq %%mm0,%%mm0\n\t" - "paddd %%mm0,%%mm4\n\t" - "movd %%mm4,%[ret]\n\t" - "lea -64(%[ret2],%[ret],2),%[ret]\n\t" - /*Although it looks like we're using 7 registers here, gcc can alias %[ret] - and %[ret2] with some of the inputs, since for once we don't write to - them until after we're done using everything but %[buf] (which is also - listed as an output to ensure gcc _doesn't_ alias them against it).*/ - :[ret]"=a"(ret),[ret2]"=r"(ret2),[buf]"+r"(bufp) - :[src]"r"(_src),[src4]"r"(_src+4*_ystride), - [ystride]"r"((ptrdiff_t)_ystride),[ystride3]"r"((ptrdiff_t)3*_ystride) - /*We have to use sub, so we actually clobber the condition codes for once - (not to mention add).*/ - :"cc" - ); - return ret; -} - -void oc_enc_frag_sub_mmx(ogg_int16_t _residue[64], - const unsigned char *_src,const unsigned char *_ref,int _ystride){ - int i; - __asm__ __volatile__("pxor %%mm7,%%mm7\n\t"::); - for(i=4;i-->0;){ - __asm__ __volatile__( - /*mm0=[src]*/ - "movq (%[src]),%%mm0\n\t" - /*mm1=[ref]*/ - "movq (%[ref]),%%mm1\n\t" - /*mm4=[src+ystride]*/ - "movq (%[src],%[ystride]),%%mm4\n\t" - /*mm5=[ref+ystride]*/ - "movq (%[ref],%[ystride]),%%mm5\n\t" - /*Compute [src]-[ref].*/ - "movq %%mm0,%%mm2\n\t" - "punpcklbw %%mm7,%%mm0\n\t" - "movq %%mm1,%%mm3\n\t" - "punpckhbw %%mm7,%%mm2\n\t" - "punpcklbw %%mm7,%%mm1\n\t" - "punpckhbw %%mm7,%%mm3\n\t" - "psubw %%mm1,%%mm0\n\t" - "psubw %%mm3,%%mm2\n\t" - /*Compute [src+ystride]-[ref+ystride].*/ - "movq %%mm4,%%mm1\n\t" - "punpcklbw %%mm7,%%mm4\n\t" - "movq %%mm5,%%mm3\n\t" - "punpckhbw %%mm7,%%mm1\n\t" - "lea (%[src],%[ystride],2),%[src]\n\t" - "punpcklbw %%mm7,%%mm5\n\t" - "lea (%[ref],%[ystride],2),%[ref]\n\t" - "punpckhbw %%mm7,%%mm3\n\t" - "psubw %%mm5,%%mm4\n\t" - "psubw %%mm3,%%mm1\n\t" - /*Write the answer out.*/ - "movq %%mm0,0x00(%[residue])\n\t" - "movq %%mm2,0x08(%[residue])\n\t" - "movq %%mm4,0x10(%[residue])\n\t" - "movq %%mm1,0x18(%[residue])\n\t" - "lea 0x20(%[residue]),%[residue]\n\t" - :[residue]"+r"(_residue),[src]"+r"(_src),[ref]"+r"(_ref) - :[ystride]"r"((ptrdiff_t)_ystride) - :"memory" - ); - } -} - -void oc_enc_frag_sub_128_mmx(ogg_int16_t _residue[64], - const unsigned char *_src,int _ystride){ - ptrdiff_t ystride3; - __asm__ __volatile__( - /*mm0=[src]*/ - "movq (%[src]),%%mm0\n\t" - /*mm1=[src+ystride]*/ - "movq (%[src],%[ystride]),%%mm1\n\t" - /*mm6={-1}x4*/ - "pcmpeqw %%mm6,%%mm6\n\t" - /*mm2=[src+2*ystride]*/ - "movq (%[src],%[ystride],2),%%mm2\n\t" - /*[ystride3]=3*[ystride]*/ - "lea (%[ystride],%[ystride],2),%[ystride3]\n\t" - /*mm6={1}x4*/ - "psllw $15,%%mm6\n\t" - /*mm3=[src+3*ystride]*/ - "movq (%[src],%[ystride3]),%%mm3\n\t" - /*mm6={128}x4*/ - "psrlw $8,%%mm6\n\t" - /*mm7=0*/ - "pxor %%mm7,%%mm7\n\t" - /*[src]=[src]+4*[ystride]*/ - "lea (%[src],%[ystride],4),%[src]\n\t" - /*Compute [src]-128 and [src+ystride]-128*/ - "movq %%mm0,%%mm4\n\t" - "punpcklbw %%mm7,%%mm0\n\t" - "movq %%mm1,%%mm5\n\t" - "punpckhbw %%mm7,%%mm4\n\t" - "psubw %%mm6,%%mm0\n\t" - "punpcklbw %%mm7,%%mm1\n\t" - "psubw %%mm6,%%mm4\n\t" - "punpckhbw %%mm7,%%mm5\n\t" - "psubw %%mm6,%%mm1\n\t" - "psubw %%mm6,%%mm5\n\t" - /*Write the answer out.*/ - "movq %%mm0,0x00(%[residue])\n\t" - "movq %%mm4,0x08(%[residue])\n\t" - "movq %%mm1,0x10(%[residue])\n\t" - "movq %%mm5,0x18(%[residue])\n\t" - /*mm0=[src+4*ystride]*/ - "movq (%[src]),%%mm0\n\t" - /*mm1=[src+5*ystride]*/ - "movq (%[src],%[ystride]),%%mm1\n\t" - /*Compute [src+2*ystride]-128 and [src+3*ystride]-128*/ - "movq %%mm2,%%mm4\n\t" - "punpcklbw %%mm7,%%mm2\n\t" - "movq %%mm3,%%mm5\n\t" - "punpckhbw %%mm7,%%mm4\n\t" - "psubw %%mm6,%%mm2\n\t" - "punpcklbw %%mm7,%%mm3\n\t" - "psubw %%mm6,%%mm4\n\t" - "punpckhbw %%mm7,%%mm5\n\t" - "psubw %%mm6,%%mm3\n\t" - "psubw %%mm6,%%mm5\n\t" - /*Write the answer out.*/ - "movq %%mm2,0x20(%[residue])\n\t" - "movq %%mm4,0x28(%[residue])\n\t" - "movq %%mm3,0x30(%[residue])\n\t" - "movq %%mm5,0x38(%[residue])\n\t" - /*mm2=[src+6*ystride]*/ - "movq (%[src],%[ystride],2),%%mm2\n\t" - /*mm3=[src+7*ystride]*/ - "movq (%[src],%[ystride3]),%%mm3\n\t" - /*Compute [src+4*ystride]-128 and [src+5*ystride]-128*/ - "movq %%mm0,%%mm4\n\t" - "punpcklbw %%mm7,%%mm0\n\t" - "movq %%mm1,%%mm5\n\t" - "punpckhbw %%mm7,%%mm4\n\t" - "psubw %%mm6,%%mm0\n\t" - "punpcklbw %%mm7,%%mm1\n\t" - "psubw %%mm6,%%mm4\n\t" - "punpckhbw %%mm7,%%mm5\n\t" - "psubw %%mm6,%%mm1\n\t" - "psubw %%mm6,%%mm5\n\t" - /*Write the answer out.*/ - "movq %%mm0,0x40(%[residue])\n\t" - "movq %%mm4,0x48(%[residue])\n\t" - "movq %%mm1,0x50(%[residue])\n\t" - "movq %%mm5,0x58(%[residue])\n\t" - /*Compute [src+6*ystride]-128 and [src+7*ystride]-128*/ - "movq %%mm2,%%mm4\n\t" - "punpcklbw %%mm7,%%mm2\n\t" - "movq %%mm3,%%mm5\n\t" - "punpckhbw %%mm7,%%mm4\n\t" - "psubw %%mm6,%%mm2\n\t" - "punpcklbw %%mm7,%%mm3\n\t" - "psubw %%mm6,%%mm4\n\t" - "punpckhbw %%mm7,%%mm5\n\t" - "psubw %%mm6,%%mm3\n\t" - "psubw %%mm6,%%mm5\n\t" - /*Write the answer out.*/ - "movq %%mm2,0x60(%[residue])\n\t" - "movq %%mm4,0x68(%[residue])\n\t" - "movq %%mm3,0x70(%[residue])\n\t" - "movq %%mm5,0x78(%[residue])\n\t" - :[src]"+r"(_src),[ystride3]"=&r"(ystride3) - :[residue]"r"(_residue),[ystride]"r"((ptrdiff_t)_ystride) - :"memory" - ); -} - -void oc_enc_frag_copy2_mmxext(unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride){ - oc_int_frag_copy2_mmxext(_dst,_ystride,_src1,_src2,_ystride); -} - -#endif diff --git a/Engine/lib/libtheora/lib/x86/mmxfdct.c b/Engine/lib/libtheora/lib/x86/mmxfdct.c deleted file mode 100644 index 211875255..000000000 --- a/Engine/lib/libtheora/lib/x86/mmxfdct.c +++ /dev/null @@ -1,665 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 1999-2006 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ********************************************************************/ -/*MMX fDCT implementation for x86_32*/ -/*$Id: fdct_ses2.c 14579 2008-03-12 06:42:40Z xiphmont $*/ -#include "x86enc.h" - -#if defined(OC_X86_ASM) - -# define OC_FDCT_STAGE1_8x4 \ - "#OC_FDCT_STAGE1_8x4\n\t" \ - /*Stage 1:*/ \ - /*mm0=t7'=t0-t7*/ \ - "psubw %%mm7,%%mm0\n\t" \ - "paddw %%mm7,%%mm7\n\t" \ - /*mm1=t6'=t1-t6*/ \ - "psubw %%mm6,%%mm1\n\t" \ - "paddw %%mm6,%%mm6\n\t" \ - /*mm2=t5'=t2-t5*/ \ - "psubw %%mm5,%%mm2\n\t" \ - "paddw %%mm5,%%mm5\n\t" \ - /*mm3=t4'=t3-t4*/ \ - "psubw %%mm4,%%mm3\n\t" \ - "paddw %%mm4,%%mm4\n\t" \ - /*mm7=t0'=t0+t7*/ \ - "paddw %%mm0,%%mm7\n\t" \ - /*mm6=t1'=t1+t6*/ \ - "paddw %%mm1,%%mm6\n\t" \ - /*mm5=t2'=t2+t5*/ \ - "paddw %%mm2,%%mm5\n\t" \ - /*mm4=t3'=t3+t4*/ \ - "paddw %%mm3,%%mm4\n\t" \ - -# define OC_FDCT8x4(_r0,_r1,_r2,_r3,_r4,_r5,_r6,_r7) \ - "#OC_FDCT8x4\n\t" \ - /*Stage 2:*/ \ - /*mm7=t3''=t0'-t3'*/ \ - "psubw %%mm4,%%mm7\n\t" \ - "paddw %%mm4,%%mm4\n\t" \ - /*mm6=t2''=t1'-t2'*/ \ - "psubw %%mm5,%%mm6\n\t" \ - "movq %%mm7,"_r6"(%[y])\n\t" \ - "paddw %%mm5,%%mm5\n\t" \ - /*mm1=t5''=t6'-t5'*/ \ - "psubw %%mm2,%%mm1\n\t" \ - "movq %%mm6,"_r2"(%[y])\n\t" \ - /*mm4=t0''=t0'+t3'*/ \ - "paddw %%mm7,%%mm4\n\t" \ - "paddw %%mm2,%%mm2\n\t" \ - /*mm5=t1''=t1'+t2'*/ \ - "movq %%mm4,"_r0"(%[y])\n\t" \ - "paddw %%mm6,%%mm5\n\t" \ - /*mm2=t6''=t6'+t5'*/ \ - "paddw %%mm1,%%mm2\n\t" \ - "movq %%mm5,"_r4"(%[y])\n\t" \ - /*mm0=t7', mm1=t5'', mm2=t6'', mm3=t4'.*/ \ - /*mm4, mm5, mm6, mm7 are free.*/ \ - /*Stage 3:*/ \ - /*mm6={2}x4, mm7={27146,0xB500>>1}x2*/ \ - "mov $0x5A806A0A,%[a]\n\t" \ - "pcmpeqb %%mm6,%%mm6\n\t" \ - "movd %[a],%%mm7\n\t" \ - "psrlw $15,%%mm6\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - "paddw %%mm6,%%mm6\n\t" \ - /*mm0=0, m2={-1}x4 \ - mm5:mm4=t5''*27146+0xB500*/ \ - "movq %%mm1,%%mm4\n\t" \ - "movq %%mm1,%%mm5\n\t" \ - "punpcklwd %%mm6,%%mm4\n\t" \ - "movq %%mm2,"_r3"(%[y])\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "movq %%mm0,"_r7"(%[y])\n\t" \ - "punpckhwd %%mm6,%%mm5\n\t" \ - "pxor %%mm0,%%mm0\n\t" \ - "pmaddwd %%mm7,%%mm5\n\t" \ - "pcmpeqb %%mm2,%%mm2\n\t" \ - /*mm2=t6'', mm1=t5''+(t5''!=0) \ - mm4=(t5''*27146+0xB500>>16)*/ \ - "pcmpeqw %%mm1,%%mm0\n\t" \ - "psrad $16,%%mm4\n\t" \ - "psubw %%mm2,%%mm0\n\t" \ - "movq "_r3"(%[y]),%%mm2\n\t" \ - "psrad $16,%%mm5\n\t" \ - "paddw %%mm0,%%mm1\n\t" \ - "packssdw %%mm5,%%mm4\n\t" \ - /*mm4=s=(t5''*27146+0xB500>>16)+t5''+(t5''!=0)>>1*/ \ - "paddw %%mm1,%%mm4\n\t" \ - "movq "_r7"(%[y]),%%mm0\n\t" \ - "psraw $1,%%mm4\n\t" \ - "movq %%mm3,%%mm1\n\t" \ - /*mm3=t4''=t4'+s*/ \ - "paddw %%mm4,%%mm3\n\t" \ - /*mm1=t5'''=t4'-s*/ \ - "psubw %%mm4,%%mm1\n\t" \ - /*mm1=0, mm3={-1}x4 \ - mm5:mm4=t6''*27146+0xB500*/ \ - "movq %%mm2,%%mm4\n\t" \ - "movq %%mm2,%%mm5\n\t" \ - "punpcklwd %%mm6,%%mm4\n\t" \ - "movq %%mm1,"_r5"(%[y])\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "movq %%mm3,"_r1"(%[y])\n\t" \ - "punpckhwd %%mm6,%%mm5\n\t" \ - "pxor %%mm1,%%mm1\n\t" \ - "pmaddwd %%mm7,%%mm5\n\t" \ - "pcmpeqb %%mm3,%%mm3\n\t" \ - /*mm2=t6''+(t6''!=0), mm4=(t6''*27146+0xB500>>16)*/ \ - "psrad $16,%%mm4\n\t" \ - "pcmpeqw %%mm2,%%mm1\n\t" \ - "psrad $16,%%mm5\n\t" \ - "psubw %%mm3,%%mm1\n\t" \ - "packssdw %%mm5,%%mm4\n\t" \ - "paddw %%mm1,%%mm2\n\t" \ - /*mm1=t1'' \ - mm4=s=(t6''*27146+0xB500>>16)+t6''+(t6''!=0)>>1*/ \ - "paddw %%mm2,%%mm4\n\t" \ - "movq "_r4"(%[y]),%%mm1\n\t" \ - "psraw $1,%%mm4\n\t" \ - "movq %%mm0,%%mm2\n\t" \ - /*mm7={54491-0x7FFF,0x7FFF}x2 \ - mm0=t7''=t7'+s*/ \ - "paddw %%mm4,%%mm0\n\t" \ - /*mm2=t6'''=t7'-s*/ \ - "psubw %%mm4,%%mm2\n\t" \ - /*Stage 4:*/ \ - /*mm0=0, mm2=t0'' \ - mm5:mm4=t1''*27146+0xB500*/ \ - "movq %%mm1,%%mm4\n\t" \ - "movq %%mm1,%%mm5\n\t" \ - "punpcklwd %%mm6,%%mm4\n\t" \ - "movq %%mm2,"_r3"(%[y])\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "movq "_r0"(%[y]),%%mm2\n\t" \ - "punpckhwd %%mm6,%%mm5\n\t" \ - "movq %%mm0,"_r7"(%[y])\n\t" \ - "pmaddwd %%mm7,%%mm5\n\t" \ - "pxor %%mm0,%%mm0\n\t" \ - /*mm7={27146,0x4000>>1}x2 \ - mm0=s=(t1''*27146+0xB500>>16)+t1''+(t1''!=0)*/ \ - "psrad $16,%%mm4\n\t" \ - "mov $0x20006A0A,%[a]\n\t" \ - "pcmpeqw %%mm1,%%mm0\n\t" \ - "movd %[a],%%mm7\n\t" \ - "psrad $16,%%mm5\n\t" \ - "psubw %%mm3,%%mm0\n\t" \ - "packssdw %%mm5,%%mm4\n\t" \ - "paddw %%mm1,%%mm0\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - "paddw %%mm4,%%mm0\n\t" \ - /*mm6={0x00000E3D}x2 \ - mm1=-(t0''==0), mm5:mm4=t0''*27146+0x4000*/ \ - "movq %%mm2,%%mm4\n\t" \ - "movq %%mm2,%%mm5\n\t" \ - "punpcklwd %%mm6,%%mm4\n\t" \ - "mov $0x0E3D,%[a]\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "punpckhwd %%mm6,%%mm5\n\t" \ - "movd %[a],%%mm6\n\t" \ - "pmaddwd %%mm7,%%mm5\n\t" \ - "pxor %%mm1,%%mm1\n\t" \ - "punpckldq %%mm6,%%mm6\n\t" \ - "pcmpeqw %%mm2,%%mm1\n\t" \ - /*mm4=r=(t0''*27146+0x4000>>16)+t0''+(t0''!=0)*/ \ - "psrad $16,%%mm4\n\t" \ - "psubw %%mm3,%%mm1\n\t" \ - "psrad $16,%%mm5\n\t" \ - "paddw %%mm1,%%mm2\n\t" \ - "packssdw %%mm5,%%mm4\n\t" \ - "movq "_r5"(%[y]),%%mm1\n\t" \ - "paddw %%mm2,%%mm4\n\t" \ - /*mm2=t6'', mm0=_y[0]=u=r+s>>1 \ - The naive implementation could cause overflow, so we use \ - u=(r&s)+((r^s)>>1).*/ \ - "movq "_r3"(%[y]),%%mm2\n\t" \ - "movq %%mm0,%%mm7\n\t" \ - "pxor %%mm4,%%mm0\n\t" \ - "pand %%mm4,%%mm7\n\t" \ - "psraw $1,%%mm0\n\t" \ - "mov $0x7FFF54DC,%[a]\n\t" \ - "paddw %%mm7,%%mm0\n\t" \ - "movd %[a],%%mm7\n\t" \ - /*mm7={54491-0x7FFF,0x7FFF}x2 \ - mm4=_y[4]=v=r-u*/ \ - "psubw %%mm0,%%mm4\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - "movq %%mm4,"_r4"(%[y])\n\t" \ - /*mm0=0, mm7={36410}x4 \ - mm1=(t5'''!=0), mm5:mm4=54491*t5'''+0x0E3D*/ \ - "movq %%mm1,%%mm4\n\t" \ - "movq %%mm1,%%mm5\n\t" \ - "punpcklwd %%mm1,%%mm4\n\t" \ - "mov $0x8E3A8E3A,%[a]\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "movq %%mm0,"_r0"(%[y])\n\t" \ - "punpckhwd %%mm1,%%mm5\n\t" \ - "pxor %%mm0,%%mm0\n\t" \ - "pmaddwd %%mm7,%%mm5\n\t" \ - "pcmpeqw %%mm0,%%mm1\n\t" \ - "movd %[a],%%mm7\n\t" \ - "psubw %%mm3,%%mm1\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - "paddd %%mm6,%%mm4\n\t" \ - "paddd %%mm6,%%mm5\n\t" \ - /*mm0=0 \ - mm3:mm1=36410*t6'''+((t5'''!=0)<<16)*/ \ - "movq %%mm2,%%mm6\n\t" \ - "movq %%mm2,%%mm3\n\t" \ - "pmulhw %%mm7,%%mm6\n\t" \ - "paddw %%mm2,%%mm1\n\t" \ - "pmullw %%mm7,%%mm3\n\t" \ - "pxor %%mm0,%%mm0\n\t" \ - "paddw %%mm1,%%mm6\n\t" \ - "movq %%mm3,%%mm1\n\t" \ - "punpckhwd %%mm6,%%mm3\n\t" \ - "punpcklwd %%mm6,%%mm1\n\t" \ - /*mm3={-1}x4, mm6={1}x4 \ - mm4=_y[5]=u=(54491*t5'''+36410*t6'''+0x0E3D>>16)+(t5'''!=0)*/ \ - "paddd %%mm3,%%mm5\n\t" \ - "paddd %%mm1,%%mm4\n\t" \ - "psrad $16,%%mm5\n\t" \ - "pxor %%mm6,%%mm6\n\t" \ - "psrad $16,%%mm4\n\t" \ - "pcmpeqb %%mm3,%%mm3\n\t" \ - "packssdw %%mm5,%%mm4\n\t" \ - "psubw %%mm3,%%mm6\n\t" \ - /*mm1=t7'', mm7={26568,0x3400}x2 \ - mm2=s=t6'''-(36410*u>>16)*/ \ - "movq %%mm4,%%mm1\n\t" \ - "mov $0x340067C8,%[a]\n\t" \ - "pmulhw %%mm7,%%mm4\n\t" \ - "movd %[a],%%mm7\n\t" \ - "movq %%mm1,"_r5"(%[y])\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - "paddw %%mm1,%%mm4\n\t" \ - "movq "_r7"(%[y]),%%mm1\n\t" \ - "psubw %%mm4,%%mm2\n\t" \ - /*mm6={0x00007B1B}x2 \ - mm0=(s!=0), mm5:mm4=s*26568+0x3400*/ \ - "movq %%mm2,%%mm4\n\t" \ - "movq %%mm2,%%mm5\n\t" \ - "punpcklwd %%mm6,%%mm4\n\t" \ - "pcmpeqw %%mm2,%%mm0\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "mov $0x7B1B,%[a]\n\t" \ - "punpckhwd %%mm6,%%mm5\n\t" \ - "movd %[a],%%mm6\n\t" \ - "pmaddwd %%mm7,%%mm5\n\t" \ - "psubw %%mm3,%%mm0\n\t" \ - "punpckldq %%mm6,%%mm6\n\t" \ - /*mm7={64277-0x7FFF,0x7FFF}x2 \ - mm2=_y[3]=v=(s*26568+0x3400>>17)+s+(s!=0)*/ \ - "psrad $17,%%mm4\n\t" \ - "paddw %%mm0,%%mm2\n\t" \ - "psrad $17,%%mm5\n\t" \ - "mov $0x7FFF7B16,%[a]\n\t" \ - "packssdw %%mm5,%%mm4\n\t" \ - "movd %[a],%%mm7\n\t" \ - "paddw %%mm4,%%mm2\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - /*mm0=0, mm7={12785}x4 \ - mm1=(t7''!=0), mm2=t4'', mm5:mm4=64277*t7''+0x7B1B*/ \ - "movq %%mm1,%%mm4\n\t" \ - "movq %%mm1,%%mm5\n\t" \ - "movq %%mm2,"_r3"(%[y])\n\t" \ - "punpcklwd %%mm1,%%mm4\n\t" \ - "movq "_r1"(%[y]),%%mm2\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "mov $0x31F131F1,%[a]\n\t" \ - "punpckhwd %%mm1,%%mm5\n\t" \ - "pxor %%mm0,%%mm0\n\t" \ - "pmaddwd %%mm7,%%mm5\n\t" \ - "pcmpeqw %%mm0,%%mm1\n\t" \ - "movd %[a],%%mm7\n\t" \ - "psubw %%mm3,%%mm1\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - "paddd %%mm6,%%mm4\n\t" \ - "paddd %%mm6,%%mm5\n\t" \ - /*mm3:mm1=12785*t4'''+((t7''!=0)<<16)*/ \ - "movq %%mm2,%%mm6\n\t" \ - "movq %%mm2,%%mm3\n\t" \ - "pmulhw %%mm7,%%mm6\n\t" \ - "pmullw %%mm7,%%mm3\n\t" \ - "paddw %%mm1,%%mm6\n\t" \ - "movq %%mm3,%%mm1\n\t" \ - "punpckhwd %%mm6,%%mm3\n\t" \ - "punpcklwd %%mm6,%%mm1\n\t" \ - /*mm3={-1}x4, mm6={1}x4 \ - mm4=_y[1]=u=(12785*t4'''+64277*t7''+0x7B1B>>16)+(t7''!=0)*/ \ - "paddd %%mm3,%%mm5\n\t" \ - "paddd %%mm1,%%mm4\n\t" \ - "psrad $16,%%mm5\n\t" \ - "pxor %%mm6,%%mm6\n\t" \ - "psrad $16,%%mm4\n\t" \ - "pcmpeqb %%mm3,%%mm3\n\t" \ - "packssdw %%mm5,%%mm4\n\t" \ - "psubw %%mm3,%%mm6\n\t" \ - /*mm1=t3'', mm7={20539,0x3000}x2 \ - mm4=s=(12785*u>>16)-t4''*/ \ - "movq %%mm4,"_r1"(%[y])\n\t" \ - "pmulhw %%mm7,%%mm4\n\t" \ - "mov $0x3000503B,%[a]\n\t" \ - "movq "_r6"(%[y]),%%mm1\n\t" \ - "movd %[a],%%mm7\n\t" \ - "psubw %%mm2,%%mm4\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - /*mm6={0x00006CB7}x2 \ - mm0=(s!=0), mm5:mm4=s*20539+0x3000*/ \ - "movq %%mm4,%%mm5\n\t" \ - "movq %%mm4,%%mm2\n\t" \ - "punpcklwd %%mm6,%%mm4\n\t" \ - "pcmpeqw %%mm2,%%mm0\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "mov $0x6CB7,%[a]\n\t" \ - "punpckhwd %%mm6,%%mm5\n\t" \ - "movd %[a],%%mm6\n\t" \ - "pmaddwd %%mm7,%%mm5\n\t" \ - "psubw %%mm3,%%mm0\n\t" \ - "punpckldq %%mm6,%%mm6\n\t" \ - /*mm7={60547-0x7FFF,0x7FFF}x2 \ - mm2=_y[7]=v=(s*20539+0x3000>>20)+s+(s!=0)*/ \ - "psrad $20,%%mm4\n\t" \ - "paddw %%mm0,%%mm2\n\t" \ - "psrad $20,%%mm5\n\t" \ - "mov $0x7FFF6C84,%[a]\n\t" \ - "packssdw %%mm5,%%mm4\n\t" \ - "movd %[a],%%mm7\n\t" \ - "paddw %%mm4,%%mm2\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - /*mm0=0, mm7={25080}x4 \ - mm2=t2'', mm5:mm4=60547*t3''+0x6CB7*/ \ - "movq %%mm1,%%mm4\n\t" \ - "movq %%mm1,%%mm5\n\t" \ - "movq %%mm2,"_r7"(%[y])\n\t" \ - "punpcklwd %%mm1,%%mm4\n\t" \ - "movq "_r2"(%[y]),%%mm2\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "mov $0x61F861F8,%[a]\n\t" \ - "punpckhwd %%mm1,%%mm5\n\t" \ - "pxor %%mm0,%%mm0\n\t" \ - "pmaddwd %%mm7,%%mm5\n\t" \ - "movd %[a],%%mm7\n\t" \ - "pcmpeqw %%mm0,%%mm1\n\t" \ - "psubw %%mm3,%%mm1\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - "paddd %%mm6,%%mm4\n\t" \ - "paddd %%mm6,%%mm5\n\t" \ - /*mm3:mm1=25080*t2''+((t3''!=0)<<16)*/ \ - "movq %%mm2,%%mm6\n\t" \ - "movq %%mm2,%%mm3\n\t" \ - "pmulhw %%mm7,%%mm6\n\t" \ - "pmullw %%mm7,%%mm3\n\t" \ - "paddw %%mm1,%%mm6\n\t" \ - "movq %%mm3,%%mm1\n\t" \ - "punpckhwd %%mm6,%%mm3\n\t" \ - "punpcklwd %%mm6,%%mm1\n\t" \ - /*mm1={-1}x4 \ - mm4=u=(25080*t2''+60547*t3''+0x6CB7>>16)+(t3''!=0)*/ \ - "paddd %%mm3,%%mm5\n\t" \ - "paddd %%mm1,%%mm4\n\t" \ - "psrad $16,%%mm5\n\t" \ - "mov $0x28005460,%[a]\n\t" \ - "psrad $16,%%mm4\n\t" \ - "pcmpeqb %%mm1,%%mm1\n\t" \ - "packssdw %%mm5,%%mm4\n\t" \ - /*mm5={1}x4, mm6=_y[2]=u, mm7={21600,0x2800}x2 \ - mm4=s=(25080*u>>16)-t2''*/ \ - "movq %%mm4,%%mm6\n\t" \ - "pmulhw %%mm7,%%mm4\n\t" \ - "pxor %%mm5,%%mm5\n\t" \ - "movd %[a],%%mm7\n\t" \ - "psubw %%mm1,%%mm5\n\t" \ - "punpckldq %%mm7,%%mm7\n\t" \ - "psubw %%mm2,%%mm4\n\t" \ - /*mm2=s+(s!=0) \ - mm4:mm3=s*21600+0x2800*/ \ - "movq %%mm4,%%mm3\n\t" \ - "movq %%mm4,%%mm2\n\t" \ - "punpckhwd %%mm5,%%mm4\n\t" \ - "pcmpeqw %%mm2,%%mm0\n\t" \ - "pmaddwd %%mm7,%%mm4\n\t" \ - "psubw %%mm1,%%mm0\n\t" \ - "punpcklwd %%mm5,%%mm3\n\t" \ - "paddw %%mm0,%%mm2\n\t" \ - "pmaddwd %%mm7,%%mm3\n\t" \ - /*mm0=_y[4], mm1=_y[7], mm4=_y[0], mm5=_y[5] \ - mm3=_y[6]=v=(s*21600+0x2800>>18)+s+(s!=0)*/ \ - "movq "_r4"(%[y]),%%mm0\n\t" \ - "psrad $18,%%mm4\n\t" \ - "movq "_r5"(%[y]),%%mm5\n\t" \ - "psrad $18,%%mm3\n\t" \ - "movq "_r7"(%[y]),%%mm1\n\t" \ - "packssdw %%mm4,%%mm3\n\t" \ - "movq "_r0"(%[y]),%%mm4\n\t" \ - "paddw %%mm2,%%mm3\n\t" \ - -/*On input, mm4=_y[0], mm6=_y[2], mm0=_y[4], mm5=_y[5], mm3=_y[6], mm1=_y[7]. - On output, {_y[4],mm1,mm2,mm3} contains the transpose of _y[4...7] and - {mm4,mm5,mm6,mm7} contains the transpose of _y[0...3].*/ -# define OC_TRANSPOSE8x4(_r0,_r1,_r2,_r3,_r4,_r5,_r6,_r7) \ - "#OC_TRANSPOSE8x4\n\t" \ - /*First 4x4 transpose:*/ \ - /*mm0 = e3 e2 e1 e0 \ - mm5 = f3 f2 f1 f0 \ - mm3 = g3 g2 g1 g0 \ - mm1 = h3 h2 h1 h0*/ \ - "movq %%mm0,%%mm2\n\t" \ - "punpcklwd %%mm5,%%mm0\n\t" \ - "punpckhwd %%mm5,%%mm2\n\t" \ - "movq %%mm3,%%mm5\n\t" \ - "punpcklwd %%mm1,%%mm3\n\t" \ - "punpckhwd %%mm1,%%mm5\n\t" \ - /*mm0 = f1 e1 f0 e0 \ - mm2 = f3 e3 f2 e2 \ - mm3 = h1 g1 h0 g0 \ - mm5 = h3 g3 h2 g2*/ \ - "movq %%mm0,%%mm1\n\t" \ - "punpckldq %%mm3,%%mm0\n\t" \ - "movq %%mm0,"_r4"(%[y])\n\t" \ - "punpckhdq %%mm3,%%mm1\n\t" \ - "movq "_r1"(%[y]),%%mm0\n\t" \ - "movq %%mm2,%%mm3\n\t" \ - "punpckldq %%mm5,%%mm2\n\t" \ - "punpckhdq %%mm5,%%mm3\n\t" \ - "movq "_r3"(%[y]),%%mm5\n\t" \ - /*_y[4] = h0 g0 f0 e0 \ - mm1 = h1 g1 f1 e1 \ - mm2 = h2 g2 f2 e2 \ - mm3 = h3 g3 f3 e3*/ \ - /*Second 4x4 transpose:*/ \ - /*mm4 = a3 a2 a1 a0 \ - mm0 = b3 b2 b1 b0 \ - mm6 = c3 c2 c1 c0 \ - mm5 = d3 d2 d1 d0*/ \ - "movq %%mm4,%%mm7\n\t" \ - "punpcklwd %%mm0,%%mm4\n\t" \ - "punpckhwd %%mm0,%%mm7\n\t" \ - "movq %%mm6,%%mm0\n\t" \ - "punpcklwd %%mm5,%%mm6\n\t" \ - "punpckhwd %%mm5,%%mm0\n\t" \ - /*mm4 = b1 a1 b0 a0 \ - mm7 = b3 a3 b2 a2 \ - mm6 = d1 c1 d0 c0 \ - mm0 = d3 c3 d2 c2*/ \ - "movq %%mm4,%%mm5\n\t" \ - "punpckldq %%mm6,%%mm4\n\t" \ - "punpckhdq %%mm6,%%mm5\n\t" \ - "movq %%mm7,%%mm6\n\t" \ - "punpckhdq %%mm0,%%mm7\n\t" \ - "punpckldq %%mm0,%%mm6\n\t" \ - /*mm4 = d0 c0 b0 a0 \ - mm5 = d1 c1 b1 a1 \ - mm6 = d2 c2 b2 a2 \ - mm7 = d3 c3 b3 a3*/ \ - -/*MMX implementation of the fDCT.*/ -void oc_enc_fdct8x8_mmx(ogg_int16_t _y[64],const ogg_int16_t _x[64]){ - ptrdiff_t a; - __asm__ __volatile__( - /*Add two extra bits of working precision to improve accuracy; any more and - we could overflow.*/ - /*We also add biases to correct for some systematic error that remains in - the full fDCT->iDCT round trip.*/ - "movq 0x00(%[x]),%%mm0\n\t" - "movq 0x10(%[x]),%%mm1\n\t" - "movq 0x20(%[x]),%%mm2\n\t" - "movq 0x30(%[x]),%%mm3\n\t" - "pcmpeqb %%mm4,%%mm4\n\t" - "pxor %%mm7,%%mm7\n\t" - "movq %%mm0,%%mm5\n\t" - "psllw $2,%%mm0\n\t" - "pcmpeqw %%mm7,%%mm5\n\t" - "movq 0x70(%[x]),%%mm7\n\t" - "psllw $2,%%mm1\n\t" - "psubw %%mm4,%%mm5\n\t" - "psllw $2,%%mm2\n\t" - "mov $1,%[a]\n\t" - "pslld $16,%%mm5\n\t" - "movd %[a],%%mm6\n\t" - "psllq $16,%%mm5\n\t" - "mov $0x10001,%[a]\n\t" - "psllw $2,%%mm3\n\t" - "movd %[a],%%mm4\n\t" - "punpckhwd %%mm6,%%mm5\n\t" - "psubw %%mm6,%%mm1\n\t" - "movq 0x60(%[x]),%%mm6\n\t" - "paddw %%mm5,%%mm0\n\t" - "movq 0x50(%[x]),%%mm5\n\t" - "paddw %%mm4,%%mm0\n\t" - "movq 0x40(%[x]),%%mm4\n\t" - /*We inline stage1 of the transform here so we can get better instruction - scheduling with the shifts.*/ - /*mm0=t7'=t0-t7*/ - "psllw $2,%%mm7\n\t" - "psubw %%mm7,%%mm0\n\t" - "psllw $2,%%mm6\n\t" - "paddw %%mm7,%%mm7\n\t" - /*mm1=t6'=t1-t6*/ - "psllw $2,%%mm5\n\t" - "psubw %%mm6,%%mm1\n\t" - "psllw $2,%%mm4\n\t" - "paddw %%mm6,%%mm6\n\t" - /*mm2=t5'=t2-t5*/ - "psubw %%mm5,%%mm2\n\t" - "paddw %%mm5,%%mm5\n\t" - /*mm3=t4'=t3-t4*/ - "psubw %%mm4,%%mm3\n\t" - "paddw %%mm4,%%mm4\n\t" - /*mm7=t0'=t0+t7*/ - "paddw %%mm0,%%mm7\n\t" - /*mm6=t1'=t1+t6*/ - "paddw %%mm1,%%mm6\n\t" - /*mm5=t2'=t2+t5*/ - "paddw %%mm2,%%mm5\n\t" - /*mm4=t3'=t3+t4*/ - "paddw %%mm3,%%mm4\n\t" - OC_FDCT8x4("0x00","0x10","0x20","0x30","0x40","0x50","0x60","0x70") - OC_TRANSPOSE8x4("0x00","0x10","0x20","0x30","0x40","0x50","0x60","0x70") - /*Swap out this 8x4 block for the next one.*/ - "movq 0x08(%[x]),%%mm0\n\t" - "movq %%mm7,0x30(%[y])\n\t" - "movq 0x78(%[x]),%%mm7\n\t" - "movq %%mm1,0x50(%[y])\n\t" - "movq 0x18(%[x]),%%mm1\n\t" - "movq %%mm6,0x20(%[y])\n\t" - "movq 0x68(%[x]),%%mm6\n\t" - "movq %%mm2,0x60(%[y])\n\t" - "movq 0x28(%[x]),%%mm2\n\t" - "movq %%mm5,0x10(%[y])\n\t" - "movq 0x58(%[x]),%%mm5\n\t" - "movq %%mm3,0x70(%[y])\n\t" - "movq 0x38(%[x]),%%mm3\n\t" - /*And increase its working precision, too.*/ - "psllw $2,%%mm0\n\t" - "movq %%mm4,0x00(%[y])\n\t" - "psllw $2,%%mm7\n\t" - "movq 0x48(%[x]),%%mm4\n\t" - /*We inline stage1 of the transform here so we can get better instruction - scheduling with the shifts.*/ - /*mm0=t7'=t0-t7*/ - "psubw %%mm7,%%mm0\n\t" - "psllw $2,%%mm1\n\t" - "paddw %%mm7,%%mm7\n\t" - "psllw $2,%%mm6\n\t" - /*mm1=t6'=t1-t6*/ - "psubw %%mm6,%%mm1\n\t" - "psllw $2,%%mm2\n\t" - "paddw %%mm6,%%mm6\n\t" - "psllw $2,%%mm5\n\t" - /*mm2=t5'=t2-t5*/ - "psubw %%mm5,%%mm2\n\t" - "psllw $2,%%mm3\n\t" - "paddw %%mm5,%%mm5\n\t" - "psllw $2,%%mm4\n\t" - /*mm3=t4'=t3-t4*/ - "psubw %%mm4,%%mm3\n\t" - "paddw %%mm4,%%mm4\n\t" - /*mm7=t0'=t0+t7*/ - "paddw %%mm0,%%mm7\n\t" - /*mm6=t1'=t1+t6*/ - "paddw %%mm1,%%mm6\n\t" - /*mm5=t2'=t2+t5*/ - "paddw %%mm2,%%mm5\n\t" - /*mm4=t3'=t3+t4*/ - "paddw %%mm3,%%mm4\n\t" - OC_FDCT8x4("0x08","0x18","0x28","0x38","0x48","0x58","0x68","0x78") - OC_TRANSPOSE8x4("0x08","0x18","0x28","0x38","0x48","0x58","0x68","0x78") - /*Here the first 4x4 block of output from the last transpose is the second - 4x4 block of input for the next transform. - We have cleverly arranged that it already be in the appropriate place, - so we only have to do half the stores and loads.*/ - "movq 0x00(%[y]),%%mm0\n\t" - "movq %%mm1,0x58(%[y])\n\t" - "movq 0x10(%[y]),%%mm1\n\t" - "movq %%mm2,0x68(%[y])\n\t" - "movq 0x20(%[y]),%%mm2\n\t" - "movq %%mm3,0x78(%[y])\n\t" - "movq 0x30(%[y]),%%mm3\n\t" - OC_FDCT_STAGE1_8x4 - OC_FDCT8x4("0x00","0x10","0x20","0x30","0x08","0x18","0x28","0x38") - OC_TRANSPOSE8x4("0x00","0x10","0x20","0x30","0x08","0x18","0x28","0x38") - /*mm0={-2}x4*/ - "pcmpeqw %%mm0,%%mm0\n\t" - "paddw %%mm0,%%mm0\n\t" - /*Round the results.*/ - "psubw %%mm0,%%mm1\n\t" - "psubw %%mm0,%%mm2\n\t" - "psraw $2,%%mm1\n\t" - "psubw %%mm0,%%mm3\n\t" - "movq %%mm1,0x18(%[y])\n\t" - "psraw $2,%%mm2\n\t" - "psubw %%mm0,%%mm4\n\t" - "movq 0x08(%[y]),%%mm1\n\t" - "psraw $2,%%mm3\n\t" - "psubw %%mm0,%%mm5\n\t" - "psraw $2,%%mm4\n\t" - "psubw %%mm0,%%mm6\n\t" - "psraw $2,%%mm5\n\t" - "psubw %%mm0,%%mm7\n\t" - "psraw $2,%%mm6\n\t" - "psubw %%mm0,%%mm1\n\t" - "psraw $2,%%mm7\n\t" - "movq 0x40(%[y]),%%mm0\n\t" - "psraw $2,%%mm1\n\t" - "movq %%mm7,0x30(%[y])\n\t" - "movq 0x78(%[y]),%%mm7\n\t" - "movq %%mm1,0x08(%[y])\n\t" - "movq 0x50(%[y]),%%mm1\n\t" - "movq %%mm6,0x20(%[y])\n\t" - "movq 0x68(%[y]),%%mm6\n\t" - "movq %%mm2,0x28(%[y])\n\t" - "movq 0x60(%[y]),%%mm2\n\t" - "movq %%mm5,0x10(%[y])\n\t" - "movq 0x58(%[y]),%%mm5\n\t" - "movq %%mm3,0x38(%[y])\n\t" - "movq 0x70(%[y]),%%mm3\n\t" - "movq %%mm4,0x00(%[y])\n\t" - "movq 0x48(%[y]),%%mm4\n\t" - OC_FDCT_STAGE1_8x4 - OC_FDCT8x4("0x40","0x50","0x60","0x70","0x48","0x58","0x68","0x78") - OC_TRANSPOSE8x4("0x40","0x50","0x60","0x70","0x48","0x58","0x68","0x78") - /*mm0={-2}x4*/ - "pcmpeqw %%mm0,%%mm0\n\t" - "paddw %%mm0,%%mm0\n\t" - /*Round the results.*/ - "psubw %%mm0,%%mm1\n\t" - "psubw %%mm0,%%mm2\n\t" - "psraw $2,%%mm1\n\t" - "psubw %%mm0,%%mm3\n\t" - "movq %%mm1,0x58(%[y])\n\t" - "psraw $2,%%mm2\n\t" - "psubw %%mm0,%%mm4\n\t" - "movq 0x48(%[y]),%%mm1\n\t" - "psraw $2,%%mm3\n\t" - "psubw %%mm0,%%mm5\n\t" - "movq %%mm2,0x68(%[y])\n\t" - "psraw $2,%%mm4\n\t" - "psubw %%mm0,%%mm6\n\t" - "movq %%mm3,0x78(%[y])\n\t" - "psraw $2,%%mm5\n\t" - "psubw %%mm0,%%mm7\n\t" - "movq %%mm4,0x40(%[y])\n\t" - "psraw $2,%%mm6\n\t" - "psubw %%mm0,%%mm1\n\t" - "movq %%mm5,0x50(%[y])\n\t" - "psraw $2,%%mm7\n\t" - "movq %%mm6,0x60(%[y])\n\t" - "psraw $2,%%mm1\n\t" - "movq %%mm7,0x70(%[y])\n\t" - "movq %%mm1,0x48(%[y])\n\t" - :[a]"=&r"(a) - :[y]"r"(_y),[x]"r"(_x) - :"memory" - ); -} - -#endif diff --git a/Engine/lib/libtheora/lib/x86/mmxfrag.c b/Engine/lib/libtheora/lib/x86/mmxfrag.c deleted file mode 100644 index 2c732939c..000000000 --- a/Engine/lib/libtheora/lib/x86/mmxfrag.c +++ /dev/null @@ -1,293 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: mmxfrag.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -/*MMX acceleration of fragment reconstruction for motion compensation. - Originally written by Rudolf Marek. - Additional optimization by Nils Pipenbrinck. - Note: Loops are unrolled for best performance. - The iteration each instruction belongs to is marked in the comments as #i.*/ -#include -#include "x86int.h" -#include "mmxfrag.h" - -#if defined(OC_X86_ASM) - -/*Copies an 8x8 block of pixels from _src to _dst, assuming _ystride bytes - between rows.*/ -void oc_frag_copy_mmx(unsigned char *_dst, - const unsigned char *_src,int _ystride){ - OC_FRAG_COPY_MMX(_dst,_src,_ystride); -} - -void oc_frag_recon_intra_mmx(unsigned char *_dst,int _ystride, - const ogg_int16_t *_residue){ - __asm__ __volatile__( - /*Set mm0 to 0xFFFFFFFFFFFFFFFF.*/ - "pcmpeqw %%mm0,%%mm0\n\t" - /*#0 Load low residue.*/ - "movq 0*8(%[residue]),%%mm1\n\t" - /*#0 Load high residue.*/ - "movq 1*8(%[residue]),%%mm2\n\t" - /*Set mm0 to 0x8000800080008000.*/ - "psllw $15,%%mm0\n\t" - /*#1 Load low residue.*/ - "movq 2*8(%[residue]),%%mm3\n\t" - /*#1 Load high residue.*/ - "movq 3*8(%[residue]),%%mm4\n\t" - /*Set mm0 to 0x0080008000800080.*/ - "psrlw $8,%%mm0\n\t" - /*#2 Load low residue.*/ - "movq 4*8(%[residue]),%%mm5\n\t" - /*#2 Load high residue.*/ - "movq 5*8(%[residue]),%%mm6\n\t" - /*#0 Bias low residue.*/ - "paddsw %%mm0,%%mm1\n\t" - /*#0 Bias high residue.*/ - "paddsw %%mm0,%%mm2\n\t" - /*#0 Pack to byte.*/ - "packuswb %%mm2,%%mm1\n\t" - /*#1 Bias low residue.*/ - "paddsw %%mm0,%%mm3\n\t" - /*#1 Bias high residue.*/ - "paddsw %%mm0,%%mm4\n\t" - /*#1 Pack to byte.*/ - "packuswb %%mm4,%%mm3\n\t" - /*#2 Bias low residue.*/ - "paddsw %%mm0,%%mm5\n\t" - /*#2 Bias high residue.*/ - "paddsw %%mm0,%%mm6\n\t" - /*#2 Pack to byte.*/ - "packuswb %%mm6,%%mm5\n\t" - /*#0 Write row.*/ - "movq %%mm1,(%[dst])\n\t" - /*#1 Write row.*/ - "movq %%mm3,(%[dst],%[ystride])\n\t" - /*#2 Write row.*/ - "movq %%mm5,(%[dst],%[ystride],2)\n\t" - /*#3 Load low residue.*/ - "movq 6*8(%[residue]),%%mm1\n\t" - /*#3 Load high residue.*/ - "movq 7*8(%[residue]),%%mm2\n\t" - /*#4 Load high residue.*/ - "movq 8*8(%[residue]),%%mm3\n\t" - /*#4 Load high residue.*/ - "movq 9*8(%[residue]),%%mm4\n\t" - /*#5 Load high residue.*/ - "movq 10*8(%[residue]),%%mm5\n\t" - /*#5 Load high residue.*/ - "movq 11*8(%[residue]),%%mm6\n\t" - /*#3 Bias low residue.*/ - "paddsw %%mm0,%%mm1\n\t" - /*#3 Bias high residue.*/ - "paddsw %%mm0,%%mm2\n\t" - /*#3 Pack to byte.*/ - "packuswb %%mm2,%%mm1\n\t" - /*#4 Bias low residue.*/ - "paddsw %%mm0,%%mm3\n\t" - /*#4 Bias high residue.*/ - "paddsw %%mm0,%%mm4\n\t" - /*#4 Pack to byte.*/ - "packuswb %%mm4,%%mm3\n\t" - /*#5 Bias low residue.*/ - "paddsw %%mm0,%%mm5\n\t" - /*#5 Bias high residue.*/ - "paddsw %%mm0,%%mm6\n\t" - /*#5 Pack to byte.*/ - "packuswb %%mm6,%%mm5\n\t" - /*#3 Write row.*/ - "movq %%mm1,(%[dst],%[ystride3])\n\t" - /*#4 Write row.*/ - "movq %%mm3,(%[dst4])\n\t" - /*#5 Write row.*/ - "movq %%mm5,(%[dst4],%[ystride])\n\t" - /*#6 Load low residue.*/ - "movq 12*8(%[residue]),%%mm1\n\t" - /*#6 Load high residue.*/ - "movq 13*8(%[residue]),%%mm2\n\t" - /*#7 Load low residue.*/ - "movq 14*8(%[residue]),%%mm3\n\t" - /*#7 Load high residue.*/ - "movq 15*8(%[residue]),%%mm4\n\t" - /*#6 Bias low residue.*/ - "paddsw %%mm0,%%mm1\n\t" - /*#6 Bias high residue.*/ - "paddsw %%mm0,%%mm2\n\t" - /*#6 Pack to byte.*/ - "packuswb %%mm2,%%mm1\n\t" - /*#7 Bias low residue.*/ - "paddsw %%mm0,%%mm3\n\t" - /*#7 Bias high residue.*/ - "paddsw %%mm0,%%mm4\n\t" - /*#7 Pack to byte.*/ - "packuswb %%mm4,%%mm3\n\t" - /*#6 Write row.*/ - "movq %%mm1,(%[dst4],%[ystride],2)\n\t" - /*#7 Write row.*/ - "movq %%mm3,(%[dst4],%[ystride3])\n\t" - : - :[residue]"r"(_residue), - [dst]"r"(_dst), - [dst4]"r"(_dst+(_ystride<<2)), - [ystride]"r"((ptrdiff_t)_ystride), - [ystride3]"r"((ptrdiff_t)_ystride*3) - :"memory" - ); -} - -void oc_frag_recon_inter_mmx(unsigned char *_dst,const unsigned char *_src, - int _ystride,const ogg_int16_t *_residue){ - int i; - /*Zero mm0.*/ - __asm__ __volatile__("pxor %%mm0,%%mm0\n\t"::); - for(i=4;i-->0;){ - __asm__ __volatile__( - /*#0 Load source.*/ - "movq (%[src]),%%mm3\n\t" - /*#1 Load source.*/ - "movq (%[src],%[ystride]),%%mm7\n\t" - /*#0 Get copy of src.*/ - "movq %%mm3,%%mm4\n\t" - /*#0 Expand high source.*/ - "punpckhbw %%mm0,%%mm4\n\t" - /*#0 Expand low source.*/ - "punpcklbw %%mm0,%%mm3\n\t" - /*#0 Add residue high.*/ - "paddsw 8(%[residue]),%%mm4\n\t" - /*#1 Get copy of src.*/ - "movq %%mm7,%%mm2\n\t" - /*#0 Add residue low.*/ - "paddsw (%[residue]), %%mm3\n\t" - /*#1 Expand high source.*/ - "punpckhbw %%mm0,%%mm2\n\t" - /*#0 Pack final row pixels.*/ - "packuswb %%mm4,%%mm3\n\t" - /*#1 Expand low source.*/ - "punpcklbw %%mm0,%%mm7\n\t" - /*#1 Add residue low.*/ - "paddsw 16(%[residue]),%%mm7\n\t" - /*#1 Add residue high.*/ - "paddsw 24(%[residue]),%%mm2\n\t" - /*Advance residue.*/ - "lea 32(%[residue]),%[residue]\n\t" - /*#1 Pack final row pixels.*/ - "packuswb %%mm2,%%mm7\n\t" - /*Advance src.*/ - "lea (%[src],%[ystride],2),%[src]\n\t" - /*#0 Write row.*/ - "movq %%mm3,(%[dst])\n\t" - /*#1 Write row.*/ - "movq %%mm7,(%[dst],%[ystride])\n\t" - /*Advance dst.*/ - "lea (%[dst],%[ystride],2),%[dst]\n\t" - :[residue]"+r"(_residue),[dst]"+r"(_dst),[src]"+r"(_src) - :[ystride]"r"((ptrdiff_t)_ystride) - :"memory" - ); - } -} - -void oc_frag_recon_inter2_mmx(unsigned char *_dst,const unsigned char *_src1, - const unsigned char *_src2,int _ystride,const ogg_int16_t *_residue){ - int i; - /*Zero mm7.*/ - __asm__ __volatile__("pxor %%mm7,%%mm7\n\t"::); - for(i=4;i-->0;){ - __asm__ __volatile__( - /*#0 Load src1.*/ - "movq (%[src1]),%%mm0\n\t" - /*#0 Load src2.*/ - "movq (%[src2]),%%mm2\n\t" - /*#0 Copy src1.*/ - "movq %%mm0,%%mm1\n\t" - /*#0 Copy src2.*/ - "movq %%mm2,%%mm3\n\t" - /*#1 Load src1.*/ - "movq (%[src1],%[ystride]),%%mm4\n\t" - /*#0 Unpack lower src1.*/ - "punpcklbw %%mm7,%%mm0\n\t" - /*#1 Load src2.*/ - "movq (%[src2],%[ystride]),%%mm5\n\t" - /*#0 Unpack higher src1.*/ - "punpckhbw %%mm7,%%mm1\n\t" - /*#0 Unpack lower src2.*/ - "punpcklbw %%mm7,%%mm2\n\t" - /*#0 Unpack higher src2.*/ - "punpckhbw %%mm7,%%mm3\n\t" - /*Advance src1 ptr.*/ - "lea (%[src1],%[ystride],2),%[src1]\n\t" - /*Advance src2 ptr.*/ - "lea (%[src2],%[ystride],2),%[src2]\n\t" - /*#0 Lower src1+src2.*/ - "paddsw %%mm2,%%mm0\n\t" - /*#0 Higher src1+src2.*/ - "paddsw %%mm3,%%mm1\n\t" - /*#1 Copy src1.*/ - "movq %%mm4,%%mm2\n\t" - /*#0 Build lo average.*/ - "psraw $1,%%mm0\n\t" - /*#1 Copy src2.*/ - "movq %%mm5,%%mm3\n\t" - /*#1 Unpack lower src1.*/ - "punpcklbw %%mm7,%%mm4\n\t" - /*#0 Build hi average.*/ - "psraw $1,%%mm1\n\t" - /*#1 Unpack higher src1.*/ - "punpckhbw %%mm7,%%mm2\n\t" - /*#0 low+=residue.*/ - "paddsw (%[residue]),%%mm0\n\t" - /*#1 Unpack lower src2.*/ - "punpcklbw %%mm7,%%mm5\n\t" - /*#0 high+=residue.*/ - "paddsw 8(%[residue]),%%mm1\n\t" - /*#1 Unpack higher src2.*/ - "punpckhbw %%mm7,%%mm3\n\t" - /*#1 Lower src1+src2.*/ - "paddsw %%mm4,%%mm5\n\t" - /*#0 Pack and saturate.*/ - "packuswb %%mm1,%%mm0\n\t" - /*#1 Higher src1+src2.*/ - "paddsw %%mm2,%%mm3\n\t" - /*#0 Write row.*/ - "movq %%mm0,(%[dst])\n\t" - /*#1 Build lo average.*/ - "psraw $1,%%mm5\n\t" - /*#1 Build hi average.*/ - "psraw $1,%%mm3\n\t" - /*#1 low+=residue.*/ - "paddsw 16(%[residue]),%%mm5\n\t" - /*#1 high+=residue.*/ - "paddsw 24(%[residue]),%%mm3\n\t" - /*#1 Pack and saturate.*/ - "packuswb %%mm3,%%mm5\n\t" - /*#1 Write row ptr.*/ - "movq %%mm5,(%[dst],%[ystride])\n\t" - /*Advance residue ptr.*/ - "add $32,%[residue]\n\t" - /*Advance dest ptr.*/ - "lea (%[dst],%[ystride],2),%[dst]\n\t" - :[dst]"+r"(_dst),[residue]"+r"(_residue), - [src1]"+%r"(_src1),[src2]"+r"(_src2) - :[ystride]"r"((ptrdiff_t)_ystride) - :"memory" - ); - } -} - -void oc_restore_fpu_mmx(void){ - __asm__ __volatile__("emms\n\t"); -} -#endif diff --git a/Engine/lib/libtheora/lib/x86/mmxfrag.h b/Engine/lib/libtheora/lib/x86/mmxfrag.h deleted file mode 100644 index a39842762..000000000 --- a/Engine/lib/libtheora/lib/x86/mmxfrag.h +++ /dev/null @@ -1,64 +0,0 @@ -#if !defined(_x86_mmxfrag_H) -# define _x86_mmxfrag_H (1) -# include -# include "x86int.h" - -#if defined(OC_X86_ASM) - -/*Copies an 8x8 block of pixels from _src to _dst, assuming _ystride bytes - between rows.*/ -#define OC_FRAG_COPY_MMX(_dst,_src,_ystride) \ - do{ \ - const unsigned char *src; \ - unsigned char *dst; \ - ptrdiff_t ystride3; \ - src=(_src); \ - dst=(_dst); \ - __asm__ __volatile__( \ - /*src+0*ystride*/ \ - "movq (%[src]),%%mm0\n\t" \ - /*src+1*ystride*/ \ - "movq (%[src],%[ystride]),%%mm1\n\t" \ - /*ystride3=ystride*3*/ \ - "lea (%[ystride],%[ystride],2),%[ystride3]\n\t" \ - /*src+2*ystride*/ \ - "movq (%[src],%[ystride],2),%%mm2\n\t" \ - /*src+3*ystride*/ \ - "movq (%[src],%[ystride3]),%%mm3\n\t" \ - /*dst+0*ystride*/ \ - "movq %%mm0,(%[dst])\n\t" \ - /*dst+1*ystride*/ \ - "movq %%mm1,(%[dst],%[ystride])\n\t" \ - /*Pointer to next 4.*/ \ - "lea (%[src],%[ystride],4),%[src]\n\t" \ - /*dst+2*ystride*/ \ - "movq %%mm2,(%[dst],%[ystride],2)\n\t" \ - /*dst+3*ystride*/ \ - "movq %%mm3,(%[dst],%[ystride3])\n\t" \ - /*Pointer to next 4.*/ \ - "lea (%[dst],%[ystride],4),%[dst]\n\t" \ - /*src+0*ystride*/ \ - "movq (%[src]),%%mm0\n\t" \ - /*src+1*ystride*/ \ - "movq (%[src],%[ystride]),%%mm1\n\t" \ - /*src+2*ystride*/ \ - "movq (%[src],%[ystride],2),%%mm2\n\t" \ - /*src+3*ystride*/ \ - "movq (%[src],%[ystride3]),%%mm3\n\t" \ - /*dst+0*ystride*/ \ - "movq %%mm0,(%[dst])\n\t" \ - /*dst+1*ystride*/ \ - "movq %%mm1,(%[dst],%[ystride])\n\t" \ - /*dst+2*ystride*/ \ - "movq %%mm2,(%[dst],%[ystride],2)\n\t" \ - /*dst+3*ystride*/ \ - "movq %%mm3,(%[dst],%[ystride3])\n\t" \ - :[dst]"+r"(dst),[src]"+r"(src),[ystride3]"=&r"(ystride3) \ - :[ystride]"r"((ptrdiff_t)(_ystride)) \ - :"memory" \ - ); \ - } \ - while(0) - -# endif -#endif diff --git a/Engine/lib/libtheora/lib/x86/mmxidct.c b/Engine/lib/libtheora/lib/x86/mmxidct.c deleted file mode 100644 index 76424e636..000000000 --- a/Engine/lib/libtheora/lib/x86/mmxidct.c +++ /dev/null @@ -1,564 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: mmxidct.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -/*MMX acceleration of Theora's iDCT. - Originally written by Rudolf Marek, based on code from On2's VP3.*/ -#include "x86int.h" -#include "../dct.h" - -#if defined(OC_X86_ASM) - -/*These are offsets into the table of constants below.*/ -/*7 rows of cosines, in order: pi/16 * (1 ... 7).*/ -#define OC_COSINE_OFFSET (0) -/*A row of 8's.*/ -#define OC_EIGHT_OFFSET (56) - - - -/*A table of constants used by the MMX routines.*/ -static const ogg_uint16_t __attribute__((aligned(8),used)) - OC_IDCT_CONSTS[(7+1)*4]={ - (ogg_uint16_t)OC_C1S7,(ogg_uint16_t)OC_C1S7, - (ogg_uint16_t)OC_C1S7,(ogg_uint16_t)OC_C1S7, - (ogg_uint16_t)OC_C2S6,(ogg_uint16_t)OC_C2S6, - (ogg_uint16_t)OC_C2S6,(ogg_uint16_t)OC_C2S6, - (ogg_uint16_t)OC_C3S5,(ogg_uint16_t)OC_C3S5, - (ogg_uint16_t)OC_C3S5,(ogg_uint16_t)OC_C3S5, - (ogg_uint16_t)OC_C4S4,(ogg_uint16_t)OC_C4S4, - (ogg_uint16_t)OC_C4S4,(ogg_uint16_t)OC_C4S4, - (ogg_uint16_t)OC_C5S3,(ogg_uint16_t)OC_C5S3, - (ogg_uint16_t)OC_C5S3,(ogg_uint16_t)OC_C5S3, - (ogg_uint16_t)OC_C6S2,(ogg_uint16_t)OC_C6S2, - (ogg_uint16_t)OC_C6S2,(ogg_uint16_t)OC_C6S2, - (ogg_uint16_t)OC_C7S1,(ogg_uint16_t)OC_C7S1, - (ogg_uint16_t)OC_C7S1,(ogg_uint16_t)OC_C7S1, - 8, 8, 8, 8 -}; - -/*Converts the expression in the argument to a string.*/ -#define OC_M2STR(_s) #_s - -/*38 cycles*/ -#define OC_IDCT_BEGIN \ - "#OC_IDCT_BEGIN\n\t" \ - "movq "OC_I(3)",%%mm2\n\t" \ - "movq "OC_C(3)",%%mm6\n\t" \ - "movq %%mm2,%%mm4\n\t" \ - "movq "OC_J(5)",%%mm7\n\t" \ - "pmulhw %%mm6,%%mm4\n\t" \ - "movq "OC_C(5)",%%mm1\n\t" \ - "pmulhw %%mm7,%%mm6\n\t" \ - "movq %%mm1,%%mm5\n\t" \ - "pmulhw %%mm2,%%mm1\n\t" \ - "movq "OC_I(1)",%%mm3\n\t" \ - "pmulhw %%mm7,%%mm5\n\t" \ - "movq "OC_C(1)",%%mm0\n\t" \ - "paddw %%mm2,%%mm4\n\t" \ - "paddw %%mm7,%%mm6\n\t" \ - "paddw %%mm1,%%mm2\n\t" \ - "movq "OC_J(7)",%%mm1\n\t" \ - "paddw %%mm5,%%mm7\n\t" \ - "movq %%mm0,%%mm5\n\t" \ - "pmulhw %%mm3,%%mm0\n\t" \ - "paddw %%mm7,%%mm4\n\t" \ - "pmulhw %%mm1,%%mm5\n\t" \ - "movq "OC_C(7)",%%mm7\n\t" \ - "psubw %%mm2,%%mm6\n\t" \ - "paddw %%mm3,%%mm0\n\t" \ - "pmulhw %%mm7,%%mm3\n\t" \ - "movq "OC_I(2)",%%mm2\n\t" \ - "pmulhw %%mm1,%%mm7\n\t" \ - "paddw %%mm1,%%mm5\n\t" \ - "movq %%mm2,%%mm1\n\t" \ - "pmulhw "OC_C(2)",%%mm2\n\t" \ - "psubw %%mm5,%%mm3\n\t" \ - "movq "OC_J(6)",%%mm5\n\t" \ - "paddw %%mm7,%%mm0\n\t" \ - "movq %%mm5,%%mm7\n\t" \ - "psubw %%mm4,%%mm0\n\t" \ - "pmulhw "OC_C(2)",%%mm5\n\t" \ - "paddw %%mm1,%%mm2\n\t" \ - "pmulhw "OC_C(6)",%%mm1\n\t" \ - "paddw %%mm4,%%mm4\n\t" \ - "paddw %%mm0,%%mm4\n\t" \ - "psubw %%mm6,%%mm3\n\t" \ - "paddw %%mm7,%%mm5\n\t" \ - "paddw %%mm6,%%mm6\n\t" \ - "pmulhw "OC_C(6)",%%mm7\n\t" \ - "paddw %%mm3,%%mm6\n\t" \ - "movq %%mm4,"OC_I(1)"\n\t" \ - "psubw %%mm5,%%mm1\n\t" \ - "movq "OC_C(4)",%%mm4\n\t" \ - "movq %%mm3,%%mm5\n\t" \ - "pmulhw %%mm4,%%mm3\n\t" \ - "paddw %%mm2,%%mm7\n\t" \ - "movq %%mm6,"OC_I(2)"\n\t" \ - "movq %%mm0,%%mm2\n\t" \ - "movq "OC_I(0)",%%mm6\n\t" \ - "pmulhw %%mm4,%%mm0\n\t" \ - "paddw %%mm3,%%mm5\n\t" \ - "movq "OC_J(4)",%%mm3\n\t" \ - "psubw %%mm1,%%mm5\n\t" \ - "paddw %%mm0,%%mm2\n\t" \ - "psubw %%mm3,%%mm6\n\t" \ - "movq %%mm6,%%mm0\n\t" \ - "pmulhw %%mm4,%%mm6\n\t" \ - "paddw %%mm3,%%mm3\n\t" \ - "paddw %%mm1,%%mm1\n\t" \ - "paddw %%mm0,%%mm3\n\t" \ - "paddw %%mm5,%%mm1\n\t" \ - "pmulhw %%mm3,%%mm4\n\t" \ - "paddw %%mm0,%%mm6\n\t" \ - "psubw %%mm2,%%mm6\n\t" \ - "paddw %%mm2,%%mm2\n\t" \ - "movq "OC_I(1)",%%mm0\n\t" \ - "paddw %%mm6,%%mm2\n\t" \ - "paddw %%mm3,%%mm4\n\t" \ - "psubw %%mm1,%%mm2\n\t" \ - "#end OC_IDCT_BEGIN\n\t" \ - -/*38+8=46 cycles.*/ -#define OC_ROW_IDCT \ - "#OC_ROW_IDCT\n" \ - OC_IDCT_BEGIN \ - /*r3=D'*/ \ - "movq "OC_I(2)",%%mm3\n\t" \ - /*r4=E'=E-G*/ \ - "psubw %%mm7,%%mm4\n\t" \ - /*r1=H'+H'*/ \ - "paddw %%mm1,%%mm1\n\t" \ - /*r7=G+G*/ \ - "paddw %%mm7,%%mm7\n\t" \ - /*r1=R1=A''+H'*/ \ - "paddw %%mm2,%%mm1\n\t" \ - /*r7=G'=E+G*/ \ - "paddw %%mm4,%%mm7\n\t" \ - /*r4=R4=E'-D'*/ \ - "psubw %%mm3,%%mm4\n\t" \ - "paddw %%mm3,%%mm3\n\t" \ - /*r6=R6=F'-B''*/ \ - "psubw %%mm5,%%mm6\n\t" \ - "paddw %%mm5,%%mm5\n\t" \ - /*r3=R3=E'+D'*/ \ - "paddw %%mm4,%%mm3\n\t" \ - /*r5=R5=F'+B''*/ \ - "paddw %%mm6,%%mm5\n\t" \ - /*r7=R7=G'-C'*/ \ - "psubw %%mm0,%%mm7\n\t" \ - "paddw %%mm0,%%mm0\n\t" \ - /*Save R1.*/ \ - "movq %%mm1,"OC_I(1)"\n\t" \ - /*r0=R0=G.+C.*/ \ - "paddw %%mm7,%%mm0\n\t" \ - "#end OC_ROW_IDCT\n\t" \ - -/*The following macro does two 4x4 transposes in place. - At entry, we assume: - r0 = a3 a2 a1 a0 - I(1) = b3 b2 b1 b0 - r2 = c3 c2 c1 c0 - r3 = d3 d2 d1 d0 - - r4 = e3 e2 e1 e0 - r5 = f3 f2 f1 f0 - r6 = g3 g2 g1 g0 - r7 = h3 h2 h1 h0 - - At exit, we have: - I(0) = d0 c0 b0 a0 - I(1) = d1 c1 b1 a1 - I(2) = d2 c2 b2 a2 - I(3) = d3 c3 b3 a3 - - J(4) = h0 g0 f0 e0 - J(5) = h1 g1 f1 e1 - J(6) = h2 g2 f2 e2 - J(7) = h3 g3 f3 e3 - - I(0) I(1) I(2) I(3) is the transpose of r0 I(1) r2 r3. - J(4) J(5) J(6) J(7) is the transpose of r4 r5 r6 r7. - - Since r1 is free at entry, we calculate the Js first.*/ -/*19 cycles.*/ -#define OC_TRANSPOSE \ - "#OC_TRANSPOSE\n\t" \ - "movq %%mm4,%%mm1\n\t" \ - "punpcklwd %%mm5,%%mm4\n\t" \ - "movq %%mm0,"OC_I(0)"\n\t" \ - "punpckhwd %%mm5,%%mm1\n\t" \ - "movq %%mm6,%%mm0\n\t" \ - "punpcklwd %%mm7,%%mm6\n\t" \ - "movq %%mm4,%%mm5\n\t" \ - "punpckldq %%mm6,%%mm4\n\t" \ - "punpckhdq %%mm6,%%mm5\n\t" \ - "movq %%mm1,%%mm6\n\t" \ - "movq %%mm4,"OC_J(4)"\n\t" \ - "punpckhwd %%mm7,%%mm0\n\t" \ - "movq %%mm5,"OC_J(5)"\n\t" \ - "punpckhdq %%mm0,%%mm6\n\t" \ - "movq "OC_I(0)",%%mm4\n\t" \ - "punpckldq %%mm0,%%mm1\n\t" \ - "movq "OC_I(1)",%%mm5\n\t" \ - "movq %%mm4,%%mm0\n\t" \ - "movq %%mm6,"OC_J(7)"\n\t" \ - "punpcklwd %%mm5,%%mm0\n\t" \ - "movq %%mm1,"OC_J(6)"\n\t" \ - "punpckhwd %%mm5,%%mm4\n\t" \ - "movq %%mm2,%%mm5\n\t" \ - "punpcklwd %%mm3,%%mm2\n\t" \ - "movq %%mm0,%%mm1\n\t" \ - "punpckldq %%mm2,%%mm0\n\t" \ - "punpckhdq %%mm2,%%mm1\n\t" \ - "movq %%mm4,%%mm2\n\t" \ - "movq %%mm0,"OC_I(0)"\n\t" \ - "punpckhwd %%mm3,%%mm5\n\t" \ - "movq %%mm1,"OC_I(1)"\n\t" \ - "punpckhdq %%mm5,%%mm4\n\t" \ - "punpckldq %%mm5,%%mm2\n\t" \ - "movq %%mm4,"OC_I(3)"\n\t" \ - "movq %%mm2,"OC_I(2)"\n\t" \ - "#end OC_TRANSPOSE\n\t" \ - -/*38+19=57 cycles.*/ -#define OC_COLUMN_IDCT \ - "#OC_COLUMN_IDCT\n" \ - OC_IDCT_BEGIN \ - "paddw "OC_8",%%mm2\n\t" \ - /*r1=H'+H'*/ \ - "paddw %%mm1,%%mm1\n\t" \ - /*r1=R1=A''+H'*/ \ - "paddw %%mm2,%%mm1\n\t" \ - /*r2=NR2*/ \ - "psraw $4,%%mm2\n\t" \ - /*r4=E'=E-G*/ \ - "psubw %%mm7,%%mm4\n\t" \ - /*r1=NR1*/ \ - "psraw $4,%%mm1\n\t" \ - /*r3=D'*/ \ - "movq "OC_I(2)",%%mm3\n\t" \ - /*r7=G+G*/ \ - "paddw %%mm7,%%mm7\n\t" \ - /*Store NR2 at I(2).*/ \ - "movq %%mm2,"OC_I(2)"\n\t" \ - /*r7=G'=E+G*/ \ - "paddw %%mm4,%%mm7\n\t" \ - /*Store NR1 at I(1).*/ \ - "movq %%mm1,"OC_I(1)"\n\t" \ - /*r4=R4=E'-D'*/ \ - "psubw %%mm3,%%mm4\n\t" \ - "paddw "OC_8",%%mm4\n\t" \ - /*r3=D'+D'*/ \ - "paddw %%mm3,%%mm3\n\t" \ - /*r3=R3=E'+D'*/ \ - "paddw %%mm4,%%mm3\n\t" \ - /*r4=NR4*/ \ - "psraw $4,%%mm4\n\t" \ - /*r6=R6=F'-B''*/ \ - "psubw %%mm5,%%mm6\n\t" \ - /*r3=NR3*/ \ - "psraw $4,%%mm3\n\t" \ - "paddw "OC_8",%%mm6\n\t" \ - /*r5=B''+B''*/ \ - "paddw %%mm5,%%mm5\n\t" \ - /*r5=R5=F'+B''*/ \ - "paddw %%mm6,%%mm5\n\t" \ - /*r6=NR6*/ \ - "psraw $4,%%mm6\n\t" \ - /*Store NR4 at J(4).*/ \ - "movq %%mm4,"OC_J(4)"\n\t" \ - /*r5=NR5*/ \ - "psraw $4,%%mm5\n\t" \ - /*Store NR3 at I(3).*/ \ - "movq %%mm3,"OC_I(3)"\n\t" \ - /*r7=R7=G'-C'*/ \ - "psubw %%mm0,%%mm7\n\t" \ - "paddw "OC_8",%%mm7\n\t" \ - /*r0=C'+C'*/ \ - "paddw %%mm0,%%mm0\n\t" \ - /*r0=R0=G'+C'*/ \ - "paddw %%mm7,%%mm0\n\t" \ - /*r7=NR7*/ \ - "psraw $4,%%mm7\n\t" \ - /*Store NR6 at J(6).*/ \ - "movq %%mm6,"OC_J(6)"\n\t" \ - /*r0=NR0*/ \ - "psraw $4,%%mm0\n\t" \ - /*Store NR5 at J(5).*/ \ - "movq %%mm5,"OC_J(5)"\n\t" \ - /*Store NR7 at J(7).*/ \ - "movq %%mm7,"OC_J(7)"\n\t" \ - /*Store NR0 at I(0).*/ \ - "movq %%mm0,"OC_I(0)"\n\t" \ - "#end OC_COLUMN_IDCT\n\t" \ - -#define OC_MID(_m,_i) OC_M2STR(_m+(_i)*8)"(%[c])" -#define OC_C(_i) OC_MID(OC_COSINE_OFFSET,_i-1) -#define OC_8 OC_MID(OC_EIGHT_OFFSET,0) - -static void oc_idct8x8_slow(ogg_int16_t _y[64]){ - /*This routine accepts an 8x8 matrix, but in partially transposed form. - Every 4x4 block is transposed.*/ - __asm__ __volatile__( -#define OC_I(_k) OC_M2STR((_k*16))"(%[y])" -#define OC_J(_k) OC_M2STR(((_k-4)*16)+8)"(%[y])" - OC_ROW_IDCT - OC_TRANSPOSE -#undef OC_I -#undef OC_J -#define OC_I(_k) OC_M2STR((_k*16)+64)"(%[y])" -#define OC_J(_k) OC_M2STR(((_k-4)*16)+72)"(%[y])" - OC_ROW_IDCT - OC_TRANSPOSE -#undef OC_I -#undef OC_J -#define OC_I(_k) OC_M2STR((_k*16))"(%[y])" -#define OC_J(_k) OC_I(_k) - OC_COLUMN_IDCT -#undef OC_I -#undef OC_J -#define OC_I(_k) OC_M2STR((_k*16)+8)"(%[y])" -#define OC_J(_k) OC_I(_k) - OC_COLUMN_IDCT -#undef OC_I -#undef OC_J - : - :[y]"r"(_y),[c]"r"(OC_IDCT_CONSTS) - ); -} - -/*25 cycles.*/ -#define OC_IDCT_BEGIN_10 \ - "#OC_IDCT_BEGIN_10\n\t" \ - "movq "OC_I(3)",%%mm2\n\t" \ - "nop\n\t" \ - "movq "OC_C(3)",%%mm6\n\t" \ - "movq %%mm2,%%mm4\n\t" \ - "movq "OC_C(5)",%%mm1\n\t" \ - "pmulhw %%mm6,%%mm4\n\t" \ - "movq "OC_I(1)",%%mm3\n\t" \ - "pmulhw %%mm2,%%mm1\n\t" \ - "movq "OC_C(1)",%%mm0\n\t" \ - "paddw %%mm2,%%mm4\n\t" \ - "pxor %%mm6,%%mm6\n\t" \ - "paddw %%mm1,%%mm2\n\t" \ - "movq "OC_I(2)",%%mm5\n\t" \ - "pmulhw %%mm3,%%mm0\n\t" \ - "movq %%mm5,%%mm1\n\t" \ - "paddw %%mm3,%%mm0\n\t" \ - "pmulhw "OC_C(7)",%%mm3\n\t" \ - "psubw %%mm2,%%mm6\n\t" \ - "pmulhw "OC_C(2)",%%mm5\n\t" \ - "psubw %%mm4,%%mm0\n\t" \ - "movq "OC_I(2)",%%mm7\n\t" \ - "paddw %%mm4,%%mm4\n\t" \ - "paddw %%mm5,%%mm7\n\t" \ - "paddw %%mm0,%%mm4\n\t" \ - "pmulhw "OC_C(6)",%%mm1\n\t" \ - "psubw %%mm6,%%mm3\n\t" \ - "movq %%mm4,"OC_I(1)"\n\t" \ - "paddw %%mm6,%%mm6\n\t" \ - "movq "OC_C(4)",%%mm4\n\t" \ - "paddw %%mm3,%%mm6\n\t" \ - "movq %%mm3,%%mm5\n\t" \ - "pmulhw %%mm4,%%mm3\n\t" \ - "movq %%mm6,"OC_I(2)"\n\t" \ - "movq %%mm0,%%mm2\n\t" \ - "movq "OC_I(0)",%%mm6\n\t" \ - "pmulhw %%mm4,%%mm0\n\t" \ - "paddw %%mm3,%%mm5\n\t" \ - "paddw %%mm0,%%mm2\n\t" \ - "psubw %%mm1,%%mm5\n\t" \ - "pmulhw %%mm4,%%mm6\n\t" \ - "paddw "OC_I(0)",%%mm6\n\t" \ - "paddw %%mm1,%%mm1\n\t" \ - "movq %%mm6,%%mm4\n\t" \ - "paddw %%mm5,%%mm1\n\t" \ - "psubw %%mm2,%%mm6\n\t" \ - "paddw %%mm2,%%mm2\n\t" \ - "movq "OC_I(1)",%%mm0\n\t" \ - "paddw %%mm6,%%mm2\n\t" \ - "psubw %%mm1,%%mm2\n\t" \ - "nop\n\t" \ - "#end OC_IDCT_BEGIN_10\n\t" \ - -/*25+8=33 cycles.*/ -#define OC_ROW_IDCT_10 \ - "#OC_ROW_IDCT_10\n\t" \ - OC_IDCT_BEGIN_10 \ - /*r3=D'*/ \ - "movq "OC_I(2)",%%mm3\n\t" \ - /*r4=E'=E-G*/ \ - "psubw %%mm7,%%mm4\n\t" \ - /*r1=H'+H'*/ \ - "paddw %%mm1,%%mm1\n\t" \ - /*r7=G+G*/ \ - "paddw %%mm7,%%mm7\n\t" \ - /*r1=R1=A''+H'*/ \ - "paddw %%mm2,%%mm1\n\t" \ - /*r7=G'=E+G*/ \ - "paddw %%mm4,%%mm7\n\t" \ - /*r4=R4=E'-D'*/ \ - "psubw %%mm3,%%mm4\n\t" \ - "paddw %%mm3,%%mm3\n\t" \ - /*r6=R6=F'-B''*/ \ - "psubw %%mm5,%%mm6\n\t" \ - "paddw %%mm5,%%mm5\n\t" \ - /*r3=R3=E'+D'*/ \ - "paddw %%mm4,%%mm3\n\t" \ - /*r5=R5=F'+B''*/ \ - "paddw %%mm6,%%mm5\n\t" \ - /*r7=R7=G'-C'*/ \ - "psubw %%mm0,%%mm7\n\t" \ - "paddw %%mm0,%%mm0\n\t" \ - /*Save R1.*/ \ - "movq %%mm1,"OC_I(1)"\n\t" \ - /*r0=R0=G'+C'*/ \ - "paddw %%mm7,%%mm0\n\t" \ - "#end OC_ROW_IDCT_10\n\t" \ - -/*25+19=44 cycles'*/ -#define OC_COLUMN_IDCT_10 \ - "#OC_COLUMN_IDCT_10\n\t" \ - OC_IDCT_BEGIN_10 \ - "paddw "OC_8",%%mm2\n\t" \ - /*r1=H'+H'*/ \ - "paddw %%mm1,%%mm1\n\t" \ - /*r1=R1=A''+H'*/ \ - "paddw %%mm2,%%mm1\n\t" \ - /*r2=NR2*/ \ - "psraw $4,%%mm2\n\t" \ - /*r4=E'=E-G*/ \ - "psubw %%mm7,%%mm4\n\t" \ - /*r1=NR1*/ \ - "psraw $4,%%mm1\n\t" \ - /*r3=D'*/ \ - "movq "OC_I(2)",%%mm3\n\t" \ - /*r7=G+G*/ \ - "paddw %%mm7,%%mm7\n\t" \ - /*Store NR2 at I(2).*/ \ - "movq %%mm2,"OC_I(2)"\n\t" \ - /*r7=G'=E+G*/ \ - "paddw %%mm4,%%mm7\n\t" \ - /*Store NR1 at I(1).*/ \ - "movq %%mm1,"OC_I(1)"\n\t" \ - /*r4=R4=E'-D'*/ \ - "psubw %%mm3,%%mm4\n\t" \ - "paddw "OC_8",%%mm4\n\t" \ - /*r3=D'+D'*/ \ - "paddw %%mm3,%%mm3\n\t" \ - /*r3=R3=E'+D'*/ \ - "paddw %%mm4,%%mm3\n\t" \ - /*r4=NR4*/ \ - "psraw $4,%%mm4\n\t" \ - /*r6=R6=F'-B''*/ \ - "psubw %%mm5,%%mm6\n\t" \ - /*r3=NR3*/ \ - "psraw $4,%%mm3\n\t" \ - "paddw "OC_8",%%mm6\n\t" \ - /*r5=B''+B''*/ \ - "paddw %%mm5,%%mm5\n\t" \ - /*r5=R5=F'+B''*/ \ - "paddw %%mm6,%%mm5\n\t" \ - /*r6=NR6*/ \ - "psraw $4,%%mm6\n\t" \ - /*Store NR4 at J(4).*/ \ - "movq %%mm4,"OC_J(4)"\n\t" \ - /*r5=NR5*/ \ - "psraw $4,%%mm5\n\t" \ - /*Store NR3 at I(3).*/ \ - "movq %%mm3,"OC_I(3)"\n\t" \ - /*r7=R7=G'-C'*/ \ - "psubw %%mm0,%%mm7\n\t" \ - "paddw "OC_8",%%mm7\n\t" \ - /*r0=C'+C'*/ \ - "paddw %%mm0,%%mm0\n\t" \ - /*r0=R0=G'+C'*/ \ - "paddw %%mm7,%%mm0\n\t" \ - /*r7=NR7*/ \ - "psraw $4,%%mm7\n\t" \ - /*Store NR6 at J(6).*/ \ - "movq %%mm6,"OC_J(6)"\n\t" \ - /*r0=NR0*/ \ - "psraw $4,%%mm0\n\t" \ - /*Store NR5 at J(5).*/ \ - "movq %%mm5,"OC_J(5)"\n\t" \ - /*Store NR7 at J(7).*/ \ - "movq %%mm7,"OC_J(7)"\n\t" \ - /*Store NR0 at I(0).*/ \ - "movq %%mm0,"OC_I(0)"\n\t" \ - "#end OC_COLUMN_IDCT_10\n\t" \ - -static void oc_idct8x8_10(ogg_int16_t _y[64]){ - __asm__ __volatile__( -#define OC_I(_k) OC_M2STR((_k*16))"(%[y])" -#define OC_J(_k) OC_M2STR(((_k-4)*16)+8)"(%[y])" - /*Done with dequant, descramble, and partial transpose. - Now do the iDCT itself.*/ - OC_ROW_IDCT_10 - OC_TRANSPOSE -#undef OC_I -#undef OC_J -#define OC_I(_k) OC_M2STR((_k*16))"(%[y])" -#define OC_J(_k) OC_I(_k) - OC_COLUMN_IDCT_10 -#undef OC_I -#undef OC_J -#define OC_I(_k) OC_M2STR((_k*16)+8)"(%[y])" -#define OC_J(_k) OC_I(_k) - OC_COLUMN_IDCT_10 -#undef OC_I -#undef OC_J - : - :[y]"r"(_y),[c]"r"(OC_IDCT_CONSTS) - ); -} - -/*Performs an inverse 8x8 Type-II DCT transform. - The input is assumed to be scaled by a factor of 4 relative to orthonormal - version of the transform.*/ -void oc_idct8x8_mmx(ogg_int16_t _y[64],int _last_zzi){ - /*_last_zzi is subtly different from an actual count of the number of - coefficients we decoded for this block. - It contains the value of zzi BEFORE the final token in the block was - decoded. - In most cases this is an EOB token (the continuation of an EOB run from a - previous block counts), and so this is the same as the coefficient count. - However, in the case that the last token was NOT an EOB token, but filled - the block up with exactly 64 coefficients, _last_zzi will be less than 64. - Provided the last token was not a pure zero run, the minimum value it can - be is 46, and so that doesn't affect any of the cases in this routine. - However, if the last token WAS a pure zero run of length 63, then _last_zzi - will be 1 while the number of coefficients decoded is 64. - Thus, we will trigger the following special case, where the real - coefficient count would not. - Note also that a zero run of length 64 will give _last_zzi a value of 0, - but we still process the DC coefficient, which might have a non-zero value - due to DC prediction. - Although convoluted, this is arguably the correct behavior: it allows us to - use a smaller transform when the block ends with a long zero run instead - of a normal EOB token. - It could be smarter... multiple separate zero runs at the end of a block - will fool it, but an encoder that generates these really deserves what it - gets. - Needless to say we inherited this approach from VP3.*/ - /*Then perform the iDCT.*/ - if(_last_zzi<10)oc_idct8x8_10(_y); - else oc_idct8x8_slow(_y); -} - -#endif diff --git a/Engine/lib/libtheora/lib/x86/mmxloop.h b/Engine/lib/libtheora/lib/x86/mmxloop.h deleted file mode 100644 index 2e870c795..000000000 --- a/Engine/lib/libtheora/lib/x86/mmxloop.h +++ /dev/null @@ -1,215 +0,0 @@ -#if !defined(_x86_mmxloop_H) -# define _x86_mmxloop_H (1) -# include -# include "x86int.h" - -#if defined(OC_X86_ASM) - -/*On entry, mm0={a0,...,a7}, mm1={b0,...,b7}, mm2={c0,...,c7}, mm3={d0,...d7}. - On exit, mm1={b0+lflim(R_0,L),...,b7+lflim(R_7,L)} and - mm2={c0-lflim(R_0,L),...,c7-lflim(R_7,L)}; mm0 and mm3 are clobbered.*/ -#define OC_LOOP_FILTER8_MMX \ - "#OC_LOOP_FILTER8_MMX\n\t" \ - /*mm7=0*/ \ - "pxor %%mm7,%%mm7\n\t" \ - /*mm6:mm0={a0,...,a7}*/ \ - "movq %%mm0,%%mm6\n\t" \ - "punpcklbw %%mm7,%%mm0\n\t" \ - "punpckhbw %%mm7,%%mm6\n\t" \ - /*mm3:mm5={d0,...,d7}*/ \ - "movq %%mm3,%%mm5\n\t" \ - "punpcklbw %%mm7,%%mm3\n\t" \ - "punpckhbw %%mm7,%%mm5\n\t" \ - /*mm6:mm0={a0-d0,...,a7-d7}*/ \ - "psubw %%mm3,%%mm0\n\t" \ - "psubw %%mm5,%%mm6\n\t" \ - /*mm3:mm1={b0,...,b7}*/ \ - "movq %%mm1,%%mm3\n\t" \ - "punpcklbw %%mm7,%%mm1\n\t" \ - "movq %%mm2,%%mm4\n\t" \ - "punpckhbw %%mm7,%%mm3\n\t" \ - /*mm5:mm4={c0,...,c7}*/ \ - "movq %%mm2,%%mm5\n\t" \ - "punpcklbw %%mm7,%%mm4\n\t" \ - "punpckhbw %%mm7,%%mm5\n\t" \ - /*mm7={3}x4 \ - mm5:mm4={c0-b0,...,c7-b7}*/ \ - "pcmpeqw %%mm7,%%mm7\n\t" \ - "psubw %%mm1,%%mm4\n\t" \ - "psrlw $14,%%mm7\n\t" \ - "psubw %%mm3,%%mm5\n\t" \ - /*Scale by 3.*/ \ - "pmullw %%mm7,%%mm4\n\t" \ - "pmullw %%mm7,%%mm5\n\t" \ - /*mm7={4}x4 \ - mm5:mm4=f={a0-d0+3*(c0-b0),...,a7-d7+3*(c7-b7)}*/ \ - "psrlw $1,%%mm7\n\t" \ - "paddw %%mm0,%%mm4\n\t" \ - "psllw $2,%%mm7\n\t" \ - "movq (%[ll]),%%mm0\n\t" \ - "paddw %%mm6,%%mm5\n\t" \ - /*R_i has the range [-127,128], so we compute -R_i instead. \ - mm4=-R_i=-(f+4>>3)=0xFF^(f-4>>3)*/ \ - "psubw %%mm7,%%mm4\n\t" \ - "psubw %%mm7,%%mm5\n\t" \ - "psraw $3,%%mm4\n\t" \ - "psraw $3,%%mm5\n\t" \ - "pcmpeqb %%mm7,%%mm7\n\t" \ - "packsswb %%mm5,%%mm4\n\t" \ - "pxor %%mm6,%%mm6\n\t" \ - "pxor %%mm7,%%mm4\n\t" \ - "packuswb %%mm3,%%mm1\n\t" \ - /*Now compute lflim of -mm4 cf. Section 7.10 of the sepc.*/ \ - /*There's no unsigned byte+signed byte with unsigned saturation op code, so \ - we have to split things by sign (the other option is to work in 16 bits, \ - but working in 8 bits gives much better parallelism). \ - We compute abs(R_i), but save a mask of which terms were negative in mm6. \ - Then we compute mm4=abs(lflim(R_i,L))=min(abs(R_i),max(2*L-abs(R_i),0)). \ - Finally, we split mm4 into positive and negative pieces using the mask in \ - mm6, and add and subtract them as appropriate.*/ \ - /*mm4=abs(-R_i)*/ \ - /*mm7=255-2*L*/ \ - "pcmpgtb %%mm4,%%mm6\n\t" \ - "psubb %%mm0,%%mm7\n\t" \ - "pxor %%mm6,%%mm4\n\t" \ - "psubb %%mm0,%%mm7\n\t" \ - "psubb %%mm6,%%mm4\n\t" \ - /*mm7=255-max(2*L-abs(R_i),0)*/ \ - "paddusb %%mm4,%%mm7\n\t" \ - /*mm4=min(abs(R_i),max(2*L-abs(R_i),0))*/ \ - "paddusb %%mm7,%%mm4\n\t" \ - "psubusb %%mm7,%%mm4\n\t" \ - /*Now split mm4 by the original sign of -R_i.*/ \ - "movq %%mm4,%%mm5\n\t" \ - "pand %%mm6,%%mm4\n\t" \ - "pandn %%mm5,%%mm6\n\t" \ - /*mm1={b0+lflim(R_0,L),...,b7+lflim(R_7,L)}*/ \ - /*mm2={c0-lflim(R_0,L),...,c7-lflim(R_7,L)}*/ \ - "paddusb %%mm4,%%mm1\n\t" \ - "psubusb %%mm4,%%mm2\n\t" \ - "psubusb %%mm6,%%mm1\n\t" \ - "paddusb %%mm6,%%mm2\n\t" \ - -#define OC_LOOP_FILTER_V_MMX(_pix,_ystride,_ll) \ - do{ \ - ptrdiff_t ystride3__; \ - __asm__ __volatile__( \ - /*mm0={a0,...,a7}*/ \ - "movq (%[pix]),%%mm0\n\t" \ - /*ystride3=_ystride*3*/ \ - "lea (%[ystride],%[ystride],2),%[ystride3]\n\t" \ - /*mm3={d0,...,d7}*/ \ - "movq (%[pix],%[ystride3]),%%mm3\n\t" \ - /*mm1={b0,...,b7}*/ \ - "movq (%[pix],%[ystride]),%%mm1\n\t" \ - /*mm2={c0,...,c7}*/ \ - "movq (%[pix],%[ystride],2),%%mm2\n\t" \ - OC_LOOP_FILTER8_MMX \ - /*Write it back out.*/ \ - "movq %%mm1,(%[pix],%[ystride])\n\t" \ - "movq %%mm2,(%[pix],%[ystride],2)\n\t" \ - :[ystride3]"=&r"(ystride3__) \ - :[pix]"r"(_pix-_ystride*2),[ystride]"r"((ptrdiff_t)(_ystride)), \ - [ll]"r"(_ll) \ - :"memory" \ - ); \ - } \ - while(0) - -#define OC_LOOP_FILTER_H_MMX(_pix,_ystride,_ll) \ - do{ \ - unsigned char *pix__; \ - ptrdiff_t ystride3__; \ - ptrdiff_t d__; \ - pix__=(_pix)-2; \ - __asm__ __volatile__( \ - /*x x x x d0 c0 b0 a0*/ \ - "movd (%[pix]),%%mm0\n\t" \ - /*x x x x d1 c1 b1 a1*/ \ - "movd (%[pix],%[ystride]),%%mm1\n\t" \ - /*ystride3=_ystride*3*/ \ - "lea (%[ystride],%[ystride],2),%[ystride3]\n\t" \ - /*x x x x d2 c2 b2 a2*/ \ - "movd (%[pix],%[ystride],2),%%mm2\n\t" \ - /*x x x x d3 c3 b3 a3*/ \ - "lea (%[pix],%[ystride],4),%[d]\n\t" \ - "movd (%[pix],%[ystride3]),%%mm3\n\t" \ - /*x x x x d4 c4 b4 a4*/ \ - "movd (%[d]),%%mm4\n\t" \ - /*x x x x d5 c5 b5 a5*/ \ - "movd (%[d],%[ystride]),%%mm5\n\t" \ - /*x x x x d6 c6 b6 a6*/ \ - "movd (%[d],%[ystride],2),%%mm6\n\t" \ - /*x x x x d7 c7 b7 a7*/ \ - "movd (%[d],%[ystride3]),%%mm7\n\t" \ - /*mm0=d1 d0 c1 c0 b1 b0 a1 a0*/ \ - "punpcklbw %%mm1,%%mm0\n\t" \ - /*mm2=d3 d2 c3 c2 b3 b2 a3 a2*/ \ - "punpcklbw %%mm3,%%mm2\n\t" \ - /*mm3=d1 d0 c1 c0 b1 b0 a1 a0*/ \ - "movq %%mm0,%%mm3\n\t" \ - /*mm0=b3 b2 b1 b0 a3 a2 a1 a0*/ \ - "punpcklwd %%mm2,%%mm0\n\t" \ - /*mm3=d3 d2 d1 d0 c3 c2 c1 c0*/ \ - "punpckhwd %%mm2,%%mm3\n\t" \ - /*mm1=b3 b2 b1 b0 a3 a2 a1 a0*/ \ - "movq %%mm0,%%mm1\n\t" \ - /*mm4=d5 d4 c5 c4 b5 b4 a5 a4*/ \ - "punpcklbw %%mm5,%%mm4\n\t" \ - /*mm6=d7 d6 c7 c6 b7 b6 a7 a6*/ \ - "punpcklbw %%mm7,%%mm6\n\t" \ - /*mm5=d5 d4 c5 c4 b5 b4 a5 a4*/ \ - "movq %%mm4,%%mm5\n\t" \ - /*mm4=b7 b6 b5 b4 a7 a6 a5 a4*/ \ - "punpcklwd %%mm6,%%mm4\n\t" \ - /*mm5=d7 d6 d5 d4 c7 c6 c5 c4*/ \ - "punpckhwd %%mm6,%%mm5\n\t" \ - /*mm2=d3 d2 d1 d0 c3 c2 c1 c0*/ \ - "movq %%mm3,%%mm2\n\t" \ - /*mm0=a7 a6 a5 a4 a3 a2 a1 a0*/ \ - "punpckldq %%mm4,%%mm0\n\t" \ - /*mm1=b7 b6 b5 b4 b3 b2 b1 b0*/ \ - "punpckhdq %%mm4,%%mm1\n\t" \ - /*mm2=c7 c6 c5 c4 c3 c2 c1 c0*/ \ - "punpckldq %%mm5,%%mm2\n\t" \ - /*mm3=d7 d6 d5 d4 d3 d2 d1 d0*/ \ - "punpckhdq %%mm5,%%mm3\n\t" \ - OC_LOOP_FILTER8_MMX \ - /*mm2={b0+R_0'',...,b7+R_7''}*/ \ - "movq %%mm1,%%mm0\n\t" \ - /*mm1={b0+R_0'',c0-R_0'',...,b3+R_3'',c3-R_3''}*/ \ - "punpcklbw %%mm2,%%mm1\n\t" \ - /*mm2={b4+R_4'',c4-R_4'',...,b7+R_7'',c7-R_7''}*/ \ - "punpckhbw %%mm2,%%mm0\n\t" \ - /*[d]=c1 b1 c0 b0*/ \ - "movd %%mm1,%[d]\n\t" \ - "movw %w[d],1(%[pix])\n\t" \ - "psrlq $32,%%mm1\n\t" \ - "shr $16,%[d]\n\t" \ - "movw %w[d],1(%[pix],%[ystride])\n\t" \ - /*[d]=c3 b3 c2 b2*/ \ - "movd %%mm1,%[d]\n\t" \ - "movw %w[d],1(%[pix],%[ystride],2)\n\t" \ - "shr $16,%[d]\n\t" \ - "movw %w[d],1(%[pix],%[ystride3])\n\t" \ - "lea (%[pix],%[ystride],4),%[pix]\n\t" \ - /*[d]=c5 b5 c4 b4*/ \ - "movd %%mm0,%[d]\n\t" \ - "movw %w[d],1(%[pix])\n\t" \ - "psrlq $32,%%mm0\n\t" \ - "shr $16,%[d]\n\t" \ - "movw %w[d],1(%[pix],%[ystride])\n\t" \ - /*[d]=c7 b7 c6 b6*/ \ - "movd %%mm0,%[d]\n\t" \ - "movw %w[d],1(%[pix],%[ystride],2)\n\t" \ - "shr $16,%[d]\n\t" \ - "movw %w[d],1(%[pix],%[ystride3])\n\t" \ - :[pix]"+r"(pix__),[ystride3]"=&r"(ystride3__),[d]"=&r"(d__) \ - :[ystride]"r"((ptrdiff_t)(_ystride)),[ll]"r"(_ll) \ - :"memory" \ - ); \ - } \ - while(0) - -# endif -#endif diff --git a/Engine/lib/libtheora/lib/x86/mmxstate.c b/Engine/lib/libtheora/lib/x86/mmxstate.c deleted file mode 100644 index 808b0a789..000000000 --- a/Engine/lib/libtheora/lib/x86/mmxstate.c +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: mmxstate.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -/*MMX acceleration of complete fragment reconstruction algorithm. - Originally written by Rudolf Marek.*/ -#include -#include "x86int.h" -#include "mmxfrag.h" -#include "mmxloop.h" - -#if defined(OC_X86_ASM) - -void oc_state_frag_recon_mmx(const oc_theora_state *_state,ptrdiff_t _fragi, - int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,ogg_uint16_t _dc_quant){ - unsigned char *dst; - ptrdiff_t frag_buf_off; - int ystride; - int mb_mode; - /*Apply the inverse transform.*/ - /*Special case only having a DC component.*/ - if(_last_zzi<2){ - /*Note that this value must be unsigned, to keep the __asm__ block from - sign-extending it when it puts it in a register.*/ - ogg_uint16_t p; - /*We round this dequant product (and not any of the others) because there's - no iDCT rounding.*/ - p=(ogg_int16_t)(_dct_coeffs[0]*(ogg_int32_t)_dc_quant+15>>5); - /*Fill _dct_coeffs with p.*/ - __asm__ __volatile__( - /*mm0=0000 0000 0000 AAAA*/ - "movd %[p],%%mm0\n\t" - /*mm0=0000 0000 AAAA AAAA*/ - "punpcklwd %%mm0,%%mm0\n\t" - /*mm0=AAAA AAAA AAAA AAAA*/ - "punpckldq %%mm0,%%mm0\n\t" - "movq %%mm0,(%[y])\n\t" - "movq %%mm0,8(%[y])\n\t" - "movq %%mm0,16(%[y])\n\t" - "movq %%mm0,24(%[y])\n\t" - "movq %%mm0,32(%[y])\n\t" - "movq %%mm0,40(%[y])\n\t" - "movq %%mm0,48(%[y])\n\t" - "movq %%mm0,56(%[y])\n\t" - "movq %%mm0,64(%[y])\n\t" - "movq %%mm0,72(%[y])\n\t" - "movq %%mm0,80(%[y])\n\t" - "movq %%mm0,88(%[y])\n\t" - "movq %%mm0,96(%[y])\n\t" - "movq %%mm0,104(%[y])\n\t" - "movq %%mm0,112(%[y])\n\t" - "movq %%mm0,120(%[y])\n\t" - : - :[y]"r"(_dct_coeffs),[p]"r"((unsigned)p) - :"memory" - ); - } - else{ - /*Dequantize the DC coefficient.*/ - _dct_coeffs[0]=(ogg_int16_t)(_dct_coeffs[0]*(int)_dc_quant); - oc_idct8x8_mmx(_dct_coeffs,_last_zzi); - } - /*Fill in the target buffer.*/ - frag_buf_off=_state->frag_buf_offs[_fragi]; - mb_mode=_state->frags[_fragi].mb_mode; - ystride=_state->ref_ystride[_pli]; - dst=_state->ref_frame_data[_state->ref_frame_idx[OC_FRAME_SELF]]+frag_buf_off; - if(mb_mode==OC_MODE_INTRA)oc_frag_recon_intra_mmx(dst,ystride,_dct_coeffs); - else{ - const unsigned char *ref; - int mvoffsets[2]; - ref= - _state->ref_frame_data[_state->ref_frame_idx[OC_FRAME_FOR_MODE(mb_mode)]] - +frag_buf_off; - if(oc_state_get_mv_offsets(_state,mvoffsets,_pli, - _state->frag_mvs[_fragi][0],_state->frag_mvs[_fragi][1])>1){ - oc_frag_recon_inter2_mmx(dst,ref+mvoffsets[0],ref+mvoffsets[1],ystride, - _dct_coeffs); - } - else oc_frag_recon_inter_mmx(dst,ref+mvoffsets[0],ystride,_dct_coeffs); - } -} - -/*We copy these entire function to inline the actual MMX routines so that we - use only a single indirect call.*/ - -/*Copies the fragments specified by the lists of fragment indices from one - frame to another. - _fragis: A pointer to a list of fragment indices. - _nfragis: The number of fragment indices to copy. - _dst_frame: The reference frame to copy to. - _src_frame: The reference frame to copy from. - _pli: The color plane the fragments lie in.*/ -void oc_state_frag_copy_list_mmx(const oc_theora_state *_state, - const ptrdiff_t *_fragis,ptrdiff_t _nfragis, - int _dst_frame,int _src_frame,int _pli){ - const ptrdiff_t *frag_buf_offs; - const unsigned char *src_frame_data; - unsigned char *dst_frame_data; - ptrdiff_t fragii; - int ystride; - dst_frame_data=_state->ref_frame_data[_state->ref_frame_idx[_dst_frame]]; - src_frame_data=_state->ref_frame_data[_state->ref_frame_idx[_src_frame]]; - ystride=_state->ref_ystride[_pli]; - frag_buf_offs=_state->frag_buf_offs; - for(fragii=0;fragii<_nfragis;fragii++){ - ptrdiff_t frag_buf_off; - frag_buf_off=frag_buf_offs[_fragis[fragii]]; - OC_FRAG_COPY_MMX(dst_frame_data+frag_buf_off, - src_frame_data+frag_buf_off,ystride); - } -} - -/*Apply the loop filter to a given set of fragment rows in the given plane. - The filter may be run on the bottom edge, affecting pixels in the next row of - fragments, so this row also needs to be available. - _bv: The bounding values array. - _refi: The index of the frame buffer to filter. - _pli: The color plane to filter. - _fragy0: The Y coordinate of the first fragment row to filter. - _fragy_end: The Y coordinate of the fragment row to stop filtering at.*/ -void oc_state_loop_filter_frag_rows_mmx(const oc_theora_state *_state, - int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end){ - OC_ALIGN8(unsigned char ll[8]); - const oc_fragment_plane *fplane; - const oc_fragment *frags; - const ptrdiff_t *frag_buf_offs; - unsigned char *ref_frame_data; - ptrdiff_t fragi_top; - ptrdiff_t fragi_bot; - ptrdiff_t fragi0; - ptrdiff_t fragi0_end; - int ystride; - int nhfrags; - memset(ll,_state->loop_filter_limits[_state->qis[0]],sizeof(ll)); - fplane=_state->fplanes+_pli; - nhfrags=fplane->nhfrags; - fragi_top=fplane->froffset; - fragi_bot=fragi_top+fplane->nfrags; - fragi0=fragi_top+_fragy0*(ptrdiff_t)nhfrags; - fragi0_end=fragi0+(_fragy_end-_fragy0)*(ptrdiff_t)nhfrags; - ystride=_state->ref_ystride[_pli]; - frags=_state->frags; - frag_buf_offs=_state->frag_buf_offs; - ref_frame_data=_state->ref_frame_data[_refi]; - /*The following loops are constructed somewhat non-intuitively on purpose. - The main idea is: if a block boundary has at least one coded fragment on - it, the filter is applied to it. - However, the order that the filters are applied in matters, and VP3 chose - the somewhat strange ordering used below.*/ - while(fragi0fragi0)OC_LOOP_FILTER_H_MMX(ref,ystride,ll); - if(fragi0>fragi_top)OC_LOOP_FILTER_V_MMX(ref,ystride,ll); - if(fragi+1 -#include "x86enc.h" - -#if defined(OC_X86_64_ASM) - -# define OC_FDCT8x8 \ - /*Note: xmm15={0}x8 and xmm14={-1}x8.*/ \ - "#OC_FDCT8x8\n\t" \ - /*Stage 1:*/ \ - "movdqa %%xmm0,%%xmm11\n\t" \ - "movdqa %%xmm1,%%xmm10\n\t" \ - "movdqa %%xmm2,%%xmm9\n\t" \ - "movdqa %%xmm3,%%xmm8\n\t" \ - /*xmm11=t7'=t0-t7*/ \ - "psubw %%xmm7,%%xmm11\n\t" \ - /*xmm10=t6'=t1-t6*/ \ - "psubw %%xmm6,%%xmm10\n\t" \ - /*xmm9=t5'=t2-t5*/ \ - "psubw %%xmm5,%%xmm9\n\t" \ - /*xmm8=t4'=t3-t4*/ \ - "psubw %%xmm4,%%xmm8\n\t" \ - /*xmm0=t0'=t0+t7*/ \ - "paddw %%xmm7,%%xmm0\n\t" \ - /*xmm1=t1'=t1+t6*/ \ - "paddw %%xmm6,%%xmm1\n\t" \ - /*xmm5=t2'=t2+t5*/ \ - "paddw %%xmm2,%%xmm5\n\t" \ - /*xmm4=t3'=t3+t4*/ \ - "paddw %%xmm3,%%xmm4\n\t" \ - /*xmm2,3,6,7 are now free.*/ \ - /*Stage 2:*/ \ - "movdqa %%xmm0,%%xmm3\n\t" \ - "mov $0x5A806A0A,%[a]\n\t" \ - "movdqa %%xmm1,%%xmm2\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "movdqa %%xmm10,%%xmm6\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - /*xmm2=t2''=t1'-t2'*/ \ - "psubw %%xmm5,%%xmm2\n\t" \ - "pxor %%xmm12,%%xmm12\n\t" \ - /*xmm3=t3''=t0'-t3'*/ \ - "psubw %%xmm4,%%xmm3\n\t" \ - "psubw %%xmm14,%%xmm12\n\t" \ - /*xmm10=t5''=t6'-t5'*/ \ - "psubw %%xmm9,%%xmm10\n\t" \ - "paddw %%xmm12,%%xmm12\n\t" \ - /*xmm4=t0''=t0'+t3'*/ \ - "paddw %%xmm0,%%xmm4\n\t" \ - /*xmm1=t1''=t1'+t2'*/ \ - "paddw %%xmm5,%%xmm1\n\t" \ - /*xmm6=t6''=t6'+t5'*/ \ - "paddw %%xmm9,%%xmm6\n\t" \ - /*xmm0,xmm5,xmm9 are now free.*/ \ - /*Stage 3:*/ \ - /*xmm10:xmm5=t5''*27146+0xB500 \ - xmm0=t5''*/ \ - "movdqa %%xmm10,%%xmm5\n\t" \ - "movdqa %%xmm10,%%xmm0\n\t" \ - "punpckhwd %%xmm12,%%xmm10\n\t" \ - "pmaddwd %%xmm13,%%xmm10\n\t" \ - "punpcklwd %%xmm12,%%xmm5\n\t" \ - "pmaddwd %%xmm13,%%xmm5\n\t" \ - /*xmm5=(t5''*27146+0xB500>>16)+t5''*/ \ - "psrad $16,%%xmm10\n\t" \ - "psrad $16,%%xmm5\n\t" \ - "packssdw %%xmm10,%%xmm5\n\t" \ - "paddw %%xmm0,%%xmm5\n\t" \ - /*xmm0=s=(t5''*27146+0xB500>>16)+t5''+(t5''!=0)>>1*/ \ - "pcmpeqw %%xmm15,%%xmm0\n\t" \ - "psubw %%xmm14,%%xmm0\n\t" \ - "paddw %%xmm5,%%xmm0\n\t" \ - "movdqa %%xmm8,%%xmm5\n\t" \ - "psraw $1,%%xmm0\n\t" \ - /*xmm5=t5'''=t4'-s*/ \ - "psubw %%xmm0,%%xmm5\n\t" \ - /*xmm8=t4''=t4'+s*/ \ - "paddw %%xmm0,%%xmm8\n\t" \ - /*xmm0,xmm7,xmm9,xmm10 are free.*/ \ - /*xmm7:xmm9=t6''*27146+0xB500*/ \ - "movdqa %%xmm6,%%xmm7\n\t" \ - "movdqa %%xmm6,%%xmm9\n\t" \ - "punpckhwd %%xmm12,%%xmm7\n\t" \ - "pmaddwd %%xmm13,%%xmm7\n\t" \ - "punpcklwd %%xmm12,%%xmm9\n\t" \ - "pmaddwd %%xmm13,%%xmm9\n\t" \ - /*xmm9=(t6''*27146+0xB500>>16)+t6''*/ \ - "psrad $16,%%xmm7\n\t" \ - "psrad $16,%%xmm9\n\t" \ - "packssdw %%xmm7,%%xmm9\n\t" \ - "paddw %%xmm6,%%xmm9\n\t" \ - /*xmm9=s=(t6''*27146+0xB500>>16)+t6''+(t6''!=0)>>1*/ \ - "pcmpeqw %%xmm15,%%xmm6\n\t" \ - "psubw %%xmm14,%%xmm6\n\t" \ - "paddw %%xmm6,%%xmm9\n\t" \ - "movdqa %%xmm11,%%xmm7\n\t" \ - "psraw $1,%%xmm9\n\t" \ - /*xmm7=t6'''=t7'-s*/ \ - "psubw %%xmm9,%%xmm7\n\t" \ - /*xmm9=t7''=t7'+s*/ \ - "paddw %%xmm11,%%xmm9\n\t" \ - /*xmm0,xmm6,xmm10,xmm11 are free.*/ \ - /*Stage 4:*/ \ - /*xmm10:xmm0=t1''*27146+0xB500*/ \ - "movdqa %%xmm1,%%xmm0\n\t" \ - "movdqa %%xmm1,%%xmm10\n\t" \ - "punpcklwd %%xmm12,%%xmm0\n\t" \ - "pmaddwd %%xmm13,%%xmm0\n\t" \ - "punpckhwd %%xmm12,%%xmm10\n\t" \ - "pmaddwd %%xmm13,%%xmm10\n\t" \ - /*xmm0=(t1''*27146+0xB500>>16)+t1''*/ \ - "psrad $16,%%xmm0\n\t" \ - "psrad $16,%%xmm10\n\t" \ - "mov $0x20006A0A,%[a]\n\t" \ - "packssdw %%xmm10,%%xmm0\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "paddw %%xmm1,%%xmm0\n\t" \ - /*xmm0=s=(t1''*27146+0xB500>>16)+t1''+(t1''!=0)*/ \ - "pcmpeqw %%xmm15,%%xmm1\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - "psubw %%xmm14,%%xmm1\n\t" \ - "paddw %%xmm1,%%xmm0\n\t" \ - /*xmm10:xmm4=t0''*27146+0x4000*/ \ - "movdqa %%xmm4,%%xmm1\n\t" \ - "movdqa %%xmm4,%%xmm10\n\t" \ - "punpcklwd %%xmm12,%%xmm4\n\t" \ - "pmaddwd %%xmm13,%%xmm4\n\t" \ - "punpckhwd %%xmm12,%%xmm10\n\t" \ - "pmaddwd %%xmm13,%%xmm10\n\t" \ - /*xmm4=(t0''*27146+0x4000>>16)+t0''*/ \ - "psrad $16,%%xmm4\n\t" \ - "psrad $16,%%xmm10\n\t" \ - "mov $0x6CB7,%[a]\n\t" \ - "packssdw %%xmm10,%%xmm4\n\t" \ - "movd %[a],%%xmm12\n\t" \ - "paddw %%xmm1,%%xmm4\n\t" \ - /*xmm4=r=(t0''*27146+0x4000>>16)+t0''+(t0''!=0)*/ \ - "pcmpeqw %%xmm15,%%xmm1\n\t" \ - "pshufd $00,%%xmm12,%%xmm12\n\t" \ - "psubw %%xmm14,%%xmm1\n\t" \ - "mov $0x7FFF6C84,%[a]\n\t" \ - "paddw %%xmm1,%%xmm4\n\t" \ - /*xmm0=_y[0]=u=r+s>>1 \ - The naive implementation could cause overflow, so we use \ - u=(r&s)+((r^s)>>1).*/ \ - "movdqa %%xmm0,%%xmm6\n\t" \ - "pxor %%xmm4,%%xmm0\n\t" \ - "pand %%xmm4,%%xmm6\n\t" \ - "psraw $1,%%xmm0\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "paddw %%xmm6,%%xmm0\n\t" \ - /*xmm4=_y[4]=v=r-u*/ \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - "psubw %%xmm0,%%xmm4\n\t" \ - /*xmm1,xmm6,xmm10,xmm11 are free.*/ \ - /*xmm6:xmm10=60547*t3''+0x6CB7*/ \ - "movdqa %%xmm3,%%xmm10\n\t" \ - "movdqa %%xmm3,%%xmm6\n\t" \ - "punpcklwd %%xmm3,%%xmm10\n\t" \ - "pmaddwd %%xmm13,%%xmm10\n\t" \ - "mov $0x61F861F8,%[a]\n\t" \ - "punpckhwd %%xmm3,%%xmm6\n\t" \ - "pmaddwd %%xmm13,%%xmm6\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "paddd %%xmm12,%%xmm10\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - "paddd %%xmm12,%%xmm6\n\t" \ - /*xmm1:xmm2=25080*t2'' \ - xmm12=t2''*/ \ - "movdqa %%xmm2,%%xmm11\n\t" \ - "movdqa %%xmm2,%%xmm12\n\t" \ - "pmullw %%xmm13,%%xmm2\n\t" \ - "pmulhw %%xmm13,%%xmm11\n\t" \ - "movdqa %%xmm2,%%xmm1\n\t" \ - "punpcklwd %%xmm11,%%xmm2\n\t" \ - "punpckhwd %%xmm11,%%xmm1\n\t" \ - /*xmm10=u=(25080*t2''+60547*t3''+0x6CB7>>16)+(t3''!=0)*/ \ - "paddd %%xmm2,%%xmm10\n\t" \ - "paddd %%xmm1,%%xmm6\n\t" \ - "psrad $16,%%xmm10\n\t" \ - "pcmpeqw %%xmm15,%%xmm3\n\t" \ - "psrad $16,%%xmm6\n\t" \ - "psubw %%xmm14,%%xmm3\n\t" \ - "packssdw %%xmm6,%%xmm10\n\t" \ - "paddw %%xmm3,%%xmm10\n\t" \ - /*xmm2=_y[2]=u \ - xmm10=s=(25080*u>>16)-t2''*/ \ - "movdqa %%xmm10,%%xmm2\n\t" \ - "pmulhw %%xmm13,%%xmm10\n\t" \ - "psubw %%xmm12,%%xmm10\n\t" \ - /*xmm1:xmm6=s*21600+0x2800*/ \ - "pxor %%xmm12,%%xmm12\n\t" \ - "psubw %%xmm14,%%xmm12\n\t" \ - "mov $0x28005460,%[a]\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - "movdqa %%xmm10,%%xmm6\n\t" \ - "movdqa %%xmm10,%%xmm1\n\t" \ - "punpcklwd %%xmm12,%%xmm6\n\t" \ - "pmaddwd %%xmm13,%%xmm6\n\t" \ - "mov $0x0E3D,%[a]\n\t" \ - "punpckhwd %%xmm12,%%xmm1\n\t" \ - "pmaddwd %%xmm13,%%xmm1\n\t" \ - /*xmm6=(s*21600+0x2800>>18)+s*/ \ - "psrad $18,%%xmm6\n\t" \ - "psrad $18,%%xmm1\n\t" \ - "movd %[a],%%xmm12\n\t" \ - "packssdw %%xmm1,%%xmm6\n\t" \ - "pshufd $00,%%xmm12,%%xmm12\n\t" \ - "paddw %%xmm10,%%xmm6\n\t" \ - /*xmm6=_y[6]=v=(s*21600+0x2800>>18)+s+(s!=0)*/ \ - "mov $0x7FFF54DC,%[a]\n\t" \ - "pcmpeqw %%xmm15,%%xmm10\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "psubw %%xmm14,%%xmm10\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - "paddw %%xmm10,%%xmm6\n\t " \ - /*xmm1,xmm3,xmm10,xmm11 are free.*/ \ - /*xmm11:xmm10=54491*t5'''+0x0E3D*/ \ - "movdqa %%xmm5,%%xmm10\n\t" \ - "movdqa %%xmm5,%%xmm11\n\t" \ - "punpcklwd %%xmm5,%%xmm10\n\t" \ - "pmaddwd %%xmm13,%%xmm10\n\t" \ - "mov $0x8E3A8E3A,%[a]\n\t" \ - "punpckhwd %%xmm5,%%xmm11\n\t" \ - "pmaddwd %%xmm13,%%xmm11\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "paddd %%xmm12,%%xmm10\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - "paddd %%xmm12,%%xmm11\n\t" \ - /*xmm7:xmm12=36410*t6''' \ - xmm1=t6'''*/ \ - "movdqa %%xmm7,%%xmm3\n\t" \ - "movdqa %%xmm7,%%xmm1\n\t" \ - "pmulhw %%xmm13,%%xmm3\n\t" \ - "pmullw %%xmm13,%%xmm7\n\t" \ - "paddw %%xmm1,%%xmm3\n\t" \ - "movdqa %%xmm7,%%xmm12\n\t" \ - "punpckhwd %%xmm3,%%xmm7\n\t" \ - "punpcklwd %%xmm3,%%xmm12\n\t" \ - /*xmm10=u=(54491*t5'''+36410*t6'''+0x0E3D>>16)+(t5'''!=0)*/ \ - "paddd %%xmm12,%%xmm10\n\t" \ - "paddd %%xmm7,%%xmm11\n\t" \ - "psrad $16,%%xmm10\n\t" \ - "pcmpeqw %%xmm15,%%xmm5\n\t" \ - "psrad $16,%%xmm11\n\t" \ - "psubw %%xmm14,%%xmm5\n\t" \ - "packssdw %%xmm11,%%xmm10\n\t" \ - "pxor %%xmm12,%%xmm12\n\t" \ - "paddw %%xmm5,%%xmm10\n\t" \ - /*xmm5=_y[5]=u \ - xmm1=s=t6'''-(36410*u>>16)*/ \ - "psubw %%xmm14,%%xmm12\n\t" \ - "movdqa %%xmm10,%%xmm5\n\t" \ - "mov $0x340067C8,%[a]\n\t" \ - "pmulhw %%xmm13,%%xmm10\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "paddw %%xmm5,%%xmm10\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - "psubw %%xmm10,%%xmm1\n\t" \ - /*xmm11:xmm3=s*26568+0x3400*/ \ - "movdqa %%xmm1,%%xmm3\n\t" \ - "movdqa %%xmm1,%%xmm11\n\t" \ - "punpcklwd %%xmm12,%%xmm3\n\t" \ - "pmaddwd %%xmm13,%%xmm3\n\t" \ - "mov $0x7B1B,%[a]\n\t" \ - "punpckhwd %%xmm12,%%xmm11\n\t" \ - "pmaddwd %%xmm13,%%xmm11\n\t" \ - /*xmm3=(s*26568+0x3400>>17)+s*/ \ - "psrad $17,%%xmm3\n\t" \ - "psrad $17,%%xmm11\n\t" \ - "movd %[a],%%xmm12\n\t" \ - "packssdw %%xmm11,%%xmm3\n\t" \ - "pshufd $00,%%xmm12,%%xmm12\n\t" \ - "paddw %%xmm1,%%xmm3\n\t" \ - /*xmm3=_y[3]=v=(s*26568+0x3400>>17)+s+(s!=0)*/ \ - "mov $0x7FFF7B16,%[a]\n\t" \ - "pcmpeqw %%xmm15,%%xmm1\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "psubw %%xmm14,%%xmm1\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - "paddw %%xmm1,%%xmm3\n\t " \ - /*xmm1,xmm7,xmm10,xmm11 are free.*/ \ - /*xmm11:xmm10=64277*t7''+0x7B1B*/ \ - "movdqa %%xmm9,%%xmm10\n\t" \ - "movdqa %%xmm9,%%xmm11\n\t" \ - "punpcklwd %%xmm9,%%xmm10\n\t" \ - "pmaddwd %%xmm13,%%xmm10\n\t" \ - "mov $0x31F131F1,%[a]\n\t" \ - "punpckhwd %%xmm9,%%xmm11\n\t" \ - "pmaddwd %%xmm13,%%xmm11\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "paddd %%xmm12,%%xmm10\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - "paddd %%xmm12,%%xmm11\n\t" \ - /*xmm12:xmm7=12785*t4''*/ \ - "movdqa %%xmm8,%%xmm7\n\t" \ - "movdqa %%xmm8,%%xmm1\n\t" \ - "pmullw %%xmm13,%%xmm7\n\t" \ - "pmulhw %%xmm13,%%xmm1\n\t" \ - "movdqa %%xmm7,%%xmm12\n\t" \ - "punpcklwd %%xmm1,%%xmm7\n\t" \ - "punpckhwd %%xmm1,%%xmm12\n\t" \ - /*xmm10=u=(12785*t4''+64277*t7''+0x7B1B>>16)+(t7''!=0)*/ \ - "paddd %%xmm7,%%xmm10\n\t" \ - "paddd %%xmm12,%%xmm11\n\t" \ - "psrad $16,%%xmm10\n\t" \ - "pcmpeqw %%xmm15,%%xmm9\n\t" \ - "psrad $16,%%xmm11\n\t" \ - "psubw %%xmm14,%%xmm9\n\t" \ - "packssdw %%xmm11,%%xmm10\n\t" \ - "pxor %%xmm12,%%xmm12\n\t" \ - "paddw %%xmm9,%%xmm10\n\t" \ - /*xmm1=_y[1]=u \ - xmm10=s=(12785*u>>16)-t4''*/ \ - "psubw %%xmm14,%%xmm12\n\t" \ - "movdqa %%xmm10,%%xmm1\n\t" \ - "mov $0x3000503B,%[a]\n\t" \ - "pmulhw %%xmm13,%%xmm10\n\t" \ - "movd %[a],%%xmm13\n\t" \ - "psubw %%xmm8,%%xmm10\n\t" \ - "pshufd $00,%%xmm13,%%xmm13\n\t" \ - /*xmm8:xmm7=s*20539+0x3000*/ \ - "movdqa %%xmm10,%%xmm7\n\t" \ - "movdqa %%xmm10,%%xmm8\n\t" \ - "punpcklwd %%xmm12,%%xmm7\n\t" \ - "pmaddwd %%xmm13,%%xmm7\n\t" \ - "punpckhwd %%xmm12,%%xmm8\n\t" \ - "pmaddwd %%xmm13,%%xmm8\n\t" \ - /*xmm7=(s*20539+0x3000>>20)+s*/ \ - "psrad $20,%%xmm7\n\t" \ - "psrad $20,%%xmm8\n\t" \ - "packssdw %%xmm8,%%xmm7\n\t" \ - "paddw %%xmm10,%%xmm7\n\t" \ - /*xmm7=_y[7]=v=(s*20539+0x3000>>20)+s+(s!=0)*/ \ - "pcmpeqw %%xmm15,%%xmm10\n\t" \ - "psubw %%xmm14,%%xmm10\n\t" \ - "paddw %%xmm10,%%xmm7\n\t " \ - -# define OC_TRANSPOSE8x8 \ - "#OC_TRANSPOSE8x8\n\t" \ - "movdqa %%xmm4,%%xmm8\n\t" \ - /*xmm4 = f3 e3 f2 e2 f1 e1 f0 e0*/ \ - "punpcklwd %%xmm5,%%xmm4\n\t" \ - /*xmm8 = f7 e7 f6 e6 f5 e5 f4 e4*/ \ - "punpckhwd %%xmm5,%%xmm8\n\t" \ - /*xmm5 is free.*/ \ - "movdqa %%xmm0,%%xmm5\n\t" \ - /*xmm0 = b3 a3 b2 a2 b1 a1 b0 a0*/ \ - "punpcklwd %%xmm1,%%xmm0\n\t" \ - /*xmm5 = b7 a7 b6 a6 b5 a5 b4 a4*/ \ - "punpckhwd %%xmm1,%%xmm5\n\t" \ - /*xmm1 is free.*/ \ - "movdqa %%xmm6,%%xmm1\n\t" \ - /*xmm6 = h3 g3 h2 g2 h1 g1 h0 g0*/ \ - "punpcklwd %%xmm7,%%xmm6\n\t" \ - /*xmm1 = h7 g7 h6 g6 h5 g5 h4 g4*/ \ - "punpckhwd %%xmm7,%%xmm1\n\t" \ - /*xmm7 is free.*/ \ - "movdqa %%xmm2,%%xmm7\n\t" \ - /*xmm7 = d3 c3 d2 c2 d1 c1 d0 c0*/ \ - "punpcklwd %%xmm3,%%xmm7\n\t" \ - /*xmm2 = d7 c7 d6 c6 d5 c5 d4 c4*/ \ - "punpckhwd %%xmm3,%%xmm2\n\t" \ - /*xmm3 is free.*/ \ - "movdqa %%xmm0,%%xmm3\n\t" \ - /*xmm0 = d1 c1 b1 a1 d0 c0 b0 a0*/ \ - "punpckldq %%xmm7,%%xmm0\n\t" \ - /*xmm3 = d3 c3 b3 a3 d2 c2 b2 a2*/ \ - "punpckhdq %%xmm7,%%xmm3\n\t" \ - /*xmm7 is free.*/ \ - "movdqa %%xmm5,%%xmm7\n\t" \ - /*xmm5 = d5 c5 b5 a5 d4 c4 b4 a4*/ \ - "punpckldq %%xmm2,%%xmm5\n\t" \ - /*xmm7 = d7 c7 b7 a7 d6 c6 b6 a6*/ \ - "punpckhdq %%xmm2,%%xmm7\n\t" \ - /*xmm2 is free.*/ \ - "movdqa %%xmm4,%%xmm2\n\t" \ - /*xmm2 = h1 g1 f1 e1 h0 g0 f0 e0*/ \ - "punpckldq %%xmm6,%%xmm2\n\t" \ - /*xmm4 = h3 g3 f3 e3 h2 g2 f2 e2*/ \ - "punpckhdq %%xmm6,%%xmm4\n\t" \ - /*xmm6 is free.*/ \ - "movdqa %%xmm8,%%xmm6\n\t" \ - /*xmm6 = h5 g5 f5 e5 h4 g4 f4 e4*/ \ - "punpckldq %%xmm1,%%xmm6\n\t" \ - /*xmm8 = h7 g7 f7 e7 h6 g6 f6 e6*/ \ - "punpckhdq %%xmm1,%%xmm8\n\t" \ - /*xmm1 is free.*/ \ - "movdqa %%xmm0,%%xmm1\n\t" \ - /*xmm0 = h0 g0 f0 e0 d0 c0 b0 a0*/ \ - "punpcklqdq %%xmm2,%%xmm0\n\t" \ - /*xmm1 = h1 g1 f1 e1 d1 c1 b1 a1*/ \ - "punpckhqdq %%xmm2,%%xmm1\n\t" \ - /*xmm2 is free.*/ \ - "movdqa %%xmm3,%%xmm2\n\t" \ - /*xmm2 = h2 g2 f2 e2 d2 c2 b2 a2*/ \ - "punpcklqdq %%xmm4,%%xmm2\n\t" \ - /*xmm3 = h3 g3 f3 e3 d3 c3 b3 a3*/ \ - "punpckhqdq %%xmm4,%%xmm3\n\t" \ - /*xmm4 is free.*/ \ - "movdqa %%xmm5,%%xmm4\n\t" \ - /*xmm4 = h4 g4 f4 e4 d4 c4 b4 a4*/ \ - "punpcklqdq %%xmm6,%%xmm4\n\t" \ - /*xmm5 = h5 g5 f5 e5 d5 c5 b5 a5*/ \ - "punpckhqdq %%xmm6,%%xmm5\n\t" \ - /*xmm6 is free.*/ \ - "movdqa %%xmm7,%%xmm6\n\t" \ - /*xmm6 = h6 g6 f6 e6 d6 c6 b6 a6*/ \ - "punpcklqdq %%xmm8,%%xmm6\n\t" \ - /*xmm7 = h7 g7 f7 e7 d7 c7 b7 a7*/ \ - "punpckhqdq %%xmm8,%%xmm7\n\t" \ - /*xmm8 is free.*/ \ - -/*SSE2 implementation of the fDCT for x86-64 only. - Because of the 8 extra XMM registers on x86-64, this version can operate - without any temporary stack access at all.*/ -void oc_enc_fdct8x8_x86_64sse2(ogg_int16_t _y[64],const ogg_int16_t _x[64]){ - ptrdiff_t a; - __asm__ __volatile__( - /*Load the input.*/ - "movdqa 0x00(%[x]),%%xmm0\n\t" - "movdqa 0x10(%[x]),%%xmm1\n\t" - "movdqa 0x20(%[x]),%%xmm2\n\t" - "movdqa 0x30(%[x]),%%xmm3\n\t" - "movdqa 0x40(%[x]),%%xmm4\n\t" - "movdqa 0x50(%[x]),%%xmm5\n\t" - "movdqa 0x60(%[x]),%%xmm6\n\t" - "movdqa 0x70(%[x]),%%xmm7\n\t" - /*Add two extra bits of working precision to improve accuracy; any more and - we could overflow.*/ - /*We also add a few biases to correct for some systematic error that - remains in the full fDCT->iDCT round trip.*/ - /*xmm15={0}x8*/ - "pxor %%xmm15,%%xmm15\n\t" - /*xmm14={-1}x8*/ - "pcmpeqb %%xmm14,%%xmm14\n\t" - "psllw $2,%%xmm0\n\t" - /*xmm8=xmm0*/ - "movdqa %%xmm0,%%xmm8\n\t" - "psllw $2,%%xmm1\n\t" - /*xmm8={_x[7...0]==0}*/ - "pcmpeqw %%xmm15,%%xmm8\n\t" - "psllw $2,%%xmm2\n\t" - /*xmm8={_x[7...0]!=0}*/ - "psubw %%xmm14,%%xmm8\n\t" - "psllw $2,%%xmm3\n\t" - /*%[a]=1*/ - "mov $1,%[a]\n\t" - /*xmm8={_x[6]!=0,0,_x[4]!=0,0,_x[2]!=0,0,_x[0]!=0,0}*/ - "pslld $16,%%xmm8\n\t" - "psllw $2,%%xmm4\n\t" - /*xmm9={0,0,0,0,0,0,0,1}*/ - "movd %[a],%%xmm9\n\t" - /*xmm8={0,0,_x[2]!=0,0,_x[0]!=0,0}*/ - "pshufhw $0x00,%%xmm8,%%xmm8\n\t" - "psllw $2,%%xmm5\n\t" - /*%[a]={1}x2*/ - "mov $0x10001,%[a]\n\t" - /*xmm8={0,0,0,0,0,0,0,_x[0]!=0}*/ - "pshuflw $0x01,%%xmm8,%%xmm8\n\t" - "psllw $2,%%xmm6\n\t" - /*xmm10={0,0,0,0,0,0,1,1}*/ - "movd %[a],%%xmm10\n\t" - /*xmm0=_x[7...0]+{0,0,0,0,0,0,0,_x[0]!=0}*/ - "paddw %%xmm8,%%xmm0\n\t" - "psllw $2,%%xmm7\n\t" - /*xmm0=_x[7...0]+{0,0,0,0,0,0,1,(_x[0]!=0)+1}*/ - "paddw %%xmm10,%%xmm0\n\t" - /*xmm1=_x[15...8]-{0,0,0,0,0,0,0,1}*/ - "psubw %%xmm9,%%xmm1\n\t" - /*Transform columns.*/ - OC_FDCT8x8 - /*Transform rows.*/ - OC_TRANSPOSE8x8 - OC_FDCT8x8 - /*TODO: zig-zag ordering?*/ - OC_TRANSPOSE8x8 - /*xmm14={-2,-2,-2,-2,-2,-2,-2,-2}*/ - "paddw %%xmm14,%%xmm14\n\t" - "psubw %%xmm14,%%xmm0\n\t" - "psubw %%xmm14,%%xmm1\n\t" - "psraw $2,%%xmm0\n\t" - "psubw %%xmm14,%%xmm2\n\t" - "psraw $2,%%xmm1\n\t" - "psubw %%xmm14,%%xmm3\n\t" - "psraw $2,%%xmm2\n\t" - "psubw %%xmm14,%%xmm4\n\t" - "psraw $2,%%xmm3\n\t" - "psubw %%xmm14,%%xmm5\n\t" - "psraw $2,%%xmm4\n\t" - "psubw %%xmm14,%%xmm6\n\t" - "psraw $2,%%xmm5\n\t" - "psubw %%xmm14,%%xmm7\n\t" - "psraw $2,%%xmm6\n\t" - "psraw $2,%%xmm7\n\t" - /*Store the result.*/ - "movdqa %%xmm0,0x00(%[y])\n\t" - "movdqa %%xmm1,0x10(%[y])\n\t" - "movdqa %%xmm2,0x20(%[y])\n\t" - "movdqa %%xmm3,0x30(%[y])\n\t" - "movdqa %%xmm4,0x40(%[y])\n\t" - "movdqa %%xmm5,0x50(%[y])\n\t" - "movdqa %%xmm6,0x60(%[y])\n\t" - "movdqa %%xmm7,0x70(%[y])\n\t" - :[a]"=&r"(a) - :[y]"r"(_y),[x]"r"(_x) - :"memory" - ); -} -#endif diff --git a/Engine/lib/libtheora/lib/x86/x86enc.c b/Engine/lib/libtheora/lib/x86/x86enc.c deleted file mode 100644 index 43b7be3ea..000000000 --- a/Engine/lib/libtheora/lib/x86/x86enc.c +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: x86state.c 15675 2009-02-06 09:43:27Z tterribe $ - - ********************************************************************/ -#include "x86enc.h" - -#if defined(OC_X86_ASM) - -#include "../cpu.c" - -void oc_enc_vtable_init_x86(oc_enc_ctx *_enc){ - ogg_uint32_t cpu_flags; - cpu_flags=oc_cpu_flags_get(); - oc_enc_vtable_init_c(_enc); - if(cpu_flags&OC_CPU_X86_MMX){ - _enc->opt_vtable.frag_sub=oc_enc_frag_sub_mmx; - _enc->opt_vtable.frag_sub_128=oc_enc_frag_sub_128_mmx; - _enc->opt_vtable.frag_recon_intra=oc_frag_recon_intra_mmx; - _enc->opt_vtable.frag_recon_inter=oc_frag_recon_inter_mmx; - _enc->opt_vtable.fdct8x8=oc_enc_fdct8x8_mmx; - } - if(cpu_flags&OC_CPU_X86_MMXEXT){ - _enc->opt_vtable.frag_sad=oc_enc_frag_sad_mmxext; - _enc->opt_vtable.frag_sad_thresh=oc_enc_frag_sad_thresh_mmxext; - _enc->opt_vtable.frag_sad2_thresh=oc_enc_frag_sad2_thresh_mmxext; - _enc->opt_vtable.frag_satd_thresh=oc_enc_frag_satd_thresh_mmxext; - _enc->opt_vtable.frag_satd2_thresh=oc_enc_frag_satd2_thresh_mmxext; - _enc->opt_vtable.frag_intra_satd=oc_enc_frag_intra_satd_mmxext; - _enc->opt_vtable.frag_copy2=oc_enc_frag_copy2_mmxext; - } - if(cpu_flags&OC_CPU_X86_SSE2){ -# if defined(OC_X86_64_ASM) - /*_enc->opt_vtable.fdct8x8=oc_enc_fdct8x8_x86_64sse2;*/ -# endif - } -} -#endif diff --git a/Engine/lib/libtheora/lib/x86/x86enc.h b/Engine/lib/libtheora/lib/x86/x86enc.h deleted file mode 100644 index 06c3908bc..000000000 --- a/Engine/lib/libtheora/lib/x86/x86enc.h +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: x86int.h 15675 2009-02-06 09:43:27Z tterribe $ - - ********************************************************************/ - -#if !defined(_x86_x86enc_H) -# define _x86_x86enc_H (1) -# include "../encint.h" -# include "x86int.h" - -void oc_enc_vtable_init_x86(oc_enc_ctx *_enc); - -unsigned oc_enc_frag_sad_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride); -unsigned oc_enc_frag_sad_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh); -unsigned oc_enc_frag_sad2_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh); -unsigned oc_enc_frag_satd_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh); -unsigned oc_enc_frag_satd2_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh); -unsigned oc_enc_frag_intra_satd_mmxext(const unsigned char *_src,int _ystride); -void oc_enc_frag_sub_mmx(ogg_int16_t _diff[64], - const unsigned char *_x,const unsigned char *_y,int _stride); -void oc_enc_frag_sub_128_mmx(ogg_int16_t _diff[64], - const unsigned char *_x,int _stride); -void oc_enc_frag_copy2_mmxext(unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride); -void oc_enc_fdct8x8_mmx(ogg_int16_t _y[64],const ogg_int16_t _x[64]); -void oc_enc_fdct8x8_x86_64sse2(ogg_int16_t _y[64],const ogg_int16_t _x[64]); - -#endif diff --git a/Engine/lib/libtheora/lib/x86/x86int.h b/Engine/lib/libtheora/lib/x86/x86int.h deleted file mode 100644 index ede724f5a..000000000 --- a/Engine/lib/libtheora/lib/x86/x86int.h +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: x86int.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#if !defined(_x86_x86int_H) -# define _x86_x86int_H (1) -# include "../internal.h" - -void oc_state_vtable_init_x86(oc_theora_state *_state); - -void oc_frag_copy_mmx(unsigned char *_dst, - const unsigned char *_src,int _ystride); -void oc_frag_recon_intra_mmx(unsigned char *_dst,int _ystride, - const ogg_int16_t *_residue); -void oc_frag_recon_inter_mmx(unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t *_residue); -void oc_frag_recon_inter2_mmx(unsigned char *_dst,const unsigned char *_src1, - const unsigned char *_src2,int _ystride,const ogg_int16_t *_residue); -void oc_idct8x8_mmx(ogg_int16_t _y[64],int _last_zzi); -void oc_state_frag_recon_mmx(const oc_theora_state *_state,ptrdiff_t _fragi, - int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,ogg_uint16_t _dc_quant); -void oc_state_frag_copy_list_mmx(const oc_theora_state *_state, - const ptrdiff_t *_fragis,ptrdiff_t _nfragis, - int _dst_frame,int _src_frame,int _pli); -void oc_state_loop_filter_frag_rows_mmx(const oc_theora_state *_state, - int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end); -void oc_restore_fpu_mmx(void); - -#endif diff --git a/Engine/lib/libtheora/lib/x86/x86state.c b/Engine/lib/libtheora/lib/x86/x86state.c deleted file mode 100644 index a786bec28..000000000 --- a/Engine/lib/libtheora/lib/x86/x86state.c +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: x86state.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include "x86int.h" - -#if defined(OC_X86_ASM) - -#include "../cpu.c" - -/*This table has been modified from OC_FZIG_ZAG by baking a 4x4 transpose into - each quadrant of the destination.*/ -static const unsigned char OC_FZIG_ZAG_MMX[128]={ - 0, 8, 1, 2, 9,16,24,17, - 10, 3,32,11,18,25, 4,12, - 5,26,19,40,33,34,41,48, - 27, 6,13,20,28,21,14, 7, - 56,49,42,35,43,50,57,36, - 15,22,29,30,23,44,37,58, - 51,59,38,45,52,31,60,53, - 46,39,47,54,61,62,55,63, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, -}; - -void oc_state_vtable_init_x86(oc_theora_state *_state){ - _state->cpu_flags=oc_cpu_flags_get(); - if(_state->cpu_flags&OC_CPU_X86_MMX){ - _state->opt_vtable.frag_copy=oc_frag_copy_mmx; - _state->opt_vtable.frag_recon_intra=oc_frag_recon_intra_mmx; - _state->opt_vtable.frag_recon_inter=oc_frag_recon_inter_mmx; - _state->opt_vtable.frag_recon_inter2=oc_frag_recon_inter2_mmx; - _state->opt_vtable.idct8x8=oc_idct8x8_mmx; - _state->opt_vtable.state_frag_recon=oc_state_frag_recon_mmx; - _state->opt_vtable.state_frag_copy_list=oc_state_frag_copy_list_mmx; - _state->opt_vtable.state_loop_filter_frag_rows= - oc_state_loop_filter_frag_rows_mmx; - _state->opt_vtable.restore_fpu=oc_restore_fpu_mmx; - _state->opt_data.dct_fzig_zag=OC_FZIG_ZAG_MMX; - } - else oc_state_vtable_init_c(_state); -} -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/mmxencfrag.c b/Engine/lib/libtheora/lib/x86_vc/mmxencfrag.c deleted file mode 100644 index 94f1d0651..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/mmxencfrag.c +++ /dev/null @@ -1,969 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: dsp_mmx.c 14579 2008-03-12 06:42:40Z xiphmont $ - - ********************************************************************/ -#include -#include "x86enc.h" - -#if defined(OC_X86_ASM) - -unsigned oc_enc_frag_sad_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride){ - ptrdiff_t ret; - __asm{ -#define SRC esi -#define REF edx -#define YSTRIDE ecx -#define YSTRIDE3 edi - mov YSTRIDE,_ystride - mov SRC,_src - mov REF,_ref - /*Load the first 4 rows of each block.*/ - movq mm0,[SRC] - movq mm1,[REF] - movq mm2,[SRC][YSTRIDE] - movq mm3,[REF][YSTRIDE] - lea YSTRIDE3,[YSTRIDE+YSTRIDE*2] - movq mm4,[SRC+YSTRIDE*2] - movq mm5,[REF+YSTRIDE*2] - movq mm6,[SRC+YSTRIDE3] - movq mm7,[REF+YSTRIDE3] - /*Compute their SADs and add them in mm0*/ - psadbw mm0,mm1 - psadbw mm2,mm3 - lea SRC,[SRC+YSTRIDE*4] - paddw mm0,mm2 - lea REF,[REF+YSTRIDE*4] - /*Load the next 3 rows as registers become available.*/ - movq mm2,[SRC] - movq mm3,[REF] - psadbw mm4,mm5 - psadbw mm6,mm7 - paddw mm0,mm4 - movq mm5,[REF+YSTRIDE] - movq mm4,[SRC+YSTRIDE] - paddw mm0,mm6 - movq mm7,[REF+YSTRIDE*2] - movq mm6,[SRC+YSTRIDE*2] - /*Start adding their SADs to mm0*/ - psadbw mm2,mm3 - psadbw mm4,mm5 - paddw mm0,mm2 - psadbw mm6,mm7 - /*Load last row as registers become available.*/ - movq mm2,[SRC+YSTRIDE3] - movq mm3,[REF+YSTRIDE3] - /*And finish adding up their SADs.*/ - paddw mm0,mm4 - psadbw mm2,mm3 - paddw mm0,mm6 - paddw mm0,mm2 - movd [ret],mm0 -#undef SRC -#undef REF -#undef YSTRIDE -#undef YSTRIDE3 - } - return (unsigned)ret; -} - -unsigned oc_enc_frag_sad_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh){ - /*Early termination is for suckers.*/ - return oc_enc_frag_sad_mmxext(_src,_ref,_ystride); -} - -#define OC_SAD2_LOOP __asm{ \ - /*We want to compute (mm0+mm1>>1) on unsigned bytes without overflow, but \ - pavgb computes (mm0+mm1+1>>1). \ - The latter is exactly 1 too large when the low bit of two corresponding \ - bytes is only set in one of them. \ - Therefore we pxor the operands, pand to mask out the low bits, and psubb to \ - correct the output of pavgb.*/ \ - __asm movq mm6,mm0 \ - __asm lea REF1,[REF1+YSTRIDE*2] \ - __asm pxor mm0,mm1 \ - __asm pavgb mm6,mm1 \ - __asm lea REF2,[REF2+YSTRIDE*2] \ - __asm movq mm1,mm2 \ - __asm pand mm0,mm7 \ - __asm pavgb mm2,mm3 \ - __asm pxor mm1,mm3 \ - __asm movq mm3,[REF2+YSTRIDE] \ - __asm psubb mm6,mm0 \ - __asm movq mm0,[REF1] \ - __asm pand mm1,mm7 \ - __asm psadbw mm4,mm6 \ - __asm movd mm6,RET \ - __asm psubb mm2,mm1 \ - __asm movq mm1,[REF2] \ - __asm lea SRC,[SRC+YSTRIDE*2] \ - __asm psadbw mm5,mm2 \ - __asm movq mm2,[REF1+YSTRIDE] \ - __asm paddw mm5,mm4 \ - __asm movq mm4,[SRC] \ - __asm paddw mm6,mm5 \ - __asm movq mm5,[SRC+YSTRIDE] \ - __asm movd RET,mm6 \ -} - -/*Same as above, but does not pre-load the next two rows.*/ -#define OC_SAD2_TAIL __asm{ \ - __asm movq mm6,mm0 \ - __asm pavgb mm0,mm1 \ - __asm pxor mm6,mm1 \ - __asm movq mm1,mm2 \ - __asm pand mm6,mm7 \ - __asm pavgb mm2,mm3 \ - __asm pxor mm1,mm3 \ - __asm psubb mm0,mm6 \ - __asm pand mm1,mm7 \ - __asm psadbw mm4,mm0 \ - __asm psubb mm2,mm1 \ - __asm movd mm6,RET \ - __asm psadbw mm5,mm2 \ - __asm paddw mm5,mm4 \ - __asm paddw mm6,mm5 \ - __asm movd RET,mm6 \ -} - -unsigned oc_enc_frag_sad2_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh){ - ptrdiff_t ret; - __asm{ -#define REF1 ecx -#define REF2 edi -#define YSTRIDE esi -#define SRC edx -#define RET eax - mov YSTRIDE,_ystride - mov SRC,_src - mov REF1,_ref1 - mov REF2,_ref2 - movq mm0,[REF1] - movq mm1,[REF2] - movq mm2,[REF1+YSTRIDE] - movq mm3,[REF2+YSTRIDE] - xor RET,RET - movq mm4,[SRC] - pxor mm7,mm7 - pcmpeqb mm6,mm6 - movq mm5,[SRC+YSTRIDE] - psubb mm7,mm6 - OC_SAD2_LOOP - OC_SAD2_LOOP - OC_SAD2_LOOP - OC_SAD2_TAIL - mov [ret],RET -#undef REF1 -#undef REF2 -#undef YSTRIDE -#undef SRC -#undef RET - } - return (unsigned)ret; -} - -/*Load an 8x4 array of pixel values from %[src] and %[ref] and compute their - 16-bit difference in mm0...mm7.*/ -#define OC_LOAD_SUB_8x4(_off) __asm{ \ - __asm movd mm0,[_off+SRC] \ - __asm movd mm4,[_off+REF] \ - __asm movd mm1,[_off+SRC+SRC_YSTRIDE] \ - __asm lea SRC,[SRC+SRC_YSTRIDE*2] \ - __asm movd mm5,[_off+REF+REF_YSTRIDE] \ - __asm lea REF,[REF+REF_YSTRIDE*2] \ - __asm movd mm2,[_off+SRC] \ - __asm movd mm7,[_off+REF] \ - __asm movd mm3,[_off+SRC+SRC_YSTRIDE] \ - __asm movd mm6,[_off+REF+REF_YSTRIDE] \ - __asm punpcklbw mm0,mm4 \ - __asm lea SRC,[SRC+SRC_YSTRIDE*2] \ - __asm punpcklbw mm4,mm4 \ - __asm lea REF,[REF+REF_YSTRIDE*2] \ - __asm psubw mm0,mm4 \ - __asm movd mm4,[_off+SRC] \ - __asm movq [_off*2+BUF],mm0 \ - __asm movd mm0,[_off+REF] \ - __asm punpcklbw mm1,mm5 \ - __asm punpcklbw mm5,mm5 \ - __asm psubw mm1,mm5 \ - __asm movd mm5,[_off+SRC+SRC_YSTRIDE] \ - __asm punpcklbw mm2,mm7 \ - __asm punpcklbw mm7,mm7 \ - __asm psubw mm2,mm7 \ - __asm movd mm7,[_off+REF+REF_YSTRIDE] \ - __asm punpcklbw mm3,mm6 \ - __asm lea SRC,[SRC+SRC_YSTRIDE*2] \ - __asm punpcklbw mm6,mm6 \ - __asm psubw mm3,mm6 \ - __asm movd mm6,[_off+SRC] \ - __asm punpcklbw mm4,mm0 \ - __asm lea REF,[REF+REF_YSTRIDE*2] \ - __asm punpcklbw mm0,mm0 \ - __asm lea SRC,[SRC+SRC_YSTRIDE*2] \ - __asm psubw mm4,mm0 \ - __asm movd mm0,[_off+REF] \ - __asm punpcklbw mm5,mm7 \ - __asm neg SRC_YSTRIDE \ - __asm punpcklbw mm7,mm7 \ - __asm psubw mm5,mm7 \ - __asm movd mm7,[_off+SRC+SRC_YSTRIDE] \ - __asm punpcklbw mm6,mm0 \ - __asm lea REF,[REF+REF_YSTRIDE*2] \ - __asm punpcklbw mm0,mm0 \ - __asm neg REF_YSTRIDE \ - __asm psubw mm6,mm0 \ - __asm movd mm0,[_off+REF+REF_YSTRIDE] \ - __asm lea SRC,[SRC+SRC_YSTRIDE*8] \ - __asm punpcklbw mm7,mm0 \ - __asm neg SRC_YSTRIDE \ - __asm punpcklbw mm0,mm0 \ - __asm lea REF,[REF+REF_YSTRIDE*8] \ - __asm psubw mm7,mm0 \ - __asm neg REF_YSTRIDE \ - __asm movq mm0,[_off*2+BUF] \ -} - -/*Load an 8x4 array of pixel values from %[src] into %%mm0...%%mm7.*/ -#define OC_LOAD_8x4(_off) __asm{ \ - __asm movd mm0,[_off+SRC] \ - __asm movd mm1,[_off+SRC+YSTRIDE] \ - __asm movd mm2,[_off+SRC+YSTRIDE*2] \ - __asm pxor mm7,mm7 \ - __asm movd mm3,[_off+SRC+YSTRIDE3] \ - __asm punpcklbw mm0,mm7 \ - __asm movd mm4,[_off+SRC4] \ - __asm punpcklbw mm1,mm7 \ - __asm movd mm5,[_off+SRC4+YSTRIDE] \ - __asm punpcklbw mm2,mm7 \ - __asm movd mm6,[_off+SRC4+YSTRIDE*2] \ - __asm punpcklbw mm3,mm7 \ - __asm movd mm7,[_off+SRC4+YSTRIDE3] \ - __asm punpcklbw mm4,mm4 \ - __asm punpcklbw mm5,mm5 \ - __asm psrlw mm4,8 \ - __asm psrlw mm5,8 \ - __asm punpcklbw mm6,mm6 \ - __asm punpcklbw mm7,mm7 \ - __asm psrlw mm6,8 \ - __asm psrlw mm7,8 \ -} - -/*Performs the first two stages of an 8-point 1-D Hadamard transform. - The transform is performed in place, except that outputs 0-3 are swapped with - outputs 4-7. - Outputs 2, 3, 6 and 7 from the second stage are negated (which allows us to - perform this stage in place with no temporary registers).*/ -#define OC_HADAMARD_AB_8x4 __asm{ \ - /*Stage A: \ - Outputs 0-3 are swapped with 4-7 here.*/ \ - __asm paddw mm5,mm1 \ - __asm paddw mm6,mm2 \ - __asm paddw mm1,mm1 \ - __asm paddw mm2,mm2 \ - __asm psubw mm1,mm5 \ - __asm psubw mm2,mm6 \ - __asm paddw mm7,mm3 \ - __asm paddw mm4,mm0 \ - __asm paddw mm3,mm3 \ - __asm paddw mm0,mm0 \ - __asm psubw mm3,mm7 \ - __asm psubw mm0,mm4 \ - /*Stage B:*/ \ - __asm paddw mm0,mm2 \ - __asm paddw mm1,mm3 \ - __asm paddw mm4,mm6 \ - __asm paddw mm5,mm7 \ - __asm paddw mm2,mm2 \ - __asm paddw mm3,mm3 \ - __asm paddw mm6,mm6 \ - __asm paddw mm7,mm7 \ - __asm psubw mm2,mm0 \ - __asm psubw mm3,mm1 \ - __asm psubw mm6,mm4 \ - __asm psubw mm7,mm5 \ -} - -/*Performs the last stage of an 8-point 1-D Hadamard transform in place. - Ouputs 1, 3, 5, and 7 are negated (which allows us to perform this stage in - place with no temporary registers).*/ -#define OC_HADAMARD_C_8x4 __asm{ \ - /*Stage C:*/ \ - __asm paddw mm0,mm1 \ - __asm paddw mm2,mm3 \ - __asm paddw mm4,mm5 \ - __asm paddw mm6,mm7 \ - __asm paddw mm1,mm1 \ - __asm paddw mm3,mm3 \ - __asm paddw mm5,mm5 \ - __asm paddw mm7,mm7 \ - __asm psubw mm1,mm0 \ - __asm psubw mm3,mm2 \ - __asm psubw mm5,mm4 \ - __asm psubw mm7,mm6 \ -} - -/*Performs an 8-point 1-D Hadamard transform. - The transform is performed in place, except that outputs 0-3 are swapped with - outputs 4-7. - Outputs 1, 2, 5 and 6 are negated (which allows us to perform the transform - in place with no temporary registers).*/ -#define OC_HADAMARD_8x4 __asm{ \ - OC_HADAMARD_AB_8x4 \ - OC_HADAMARD_C_8x4 \ -} - -/*Performs the first part of the final stage of the Hadamard transform and - summing of absolute values. - At the end of this part, mm1 will contain the DC coefficient of the - transform.*/ -#define OC_HADAMARD_C_ABS_ACCUM_A_8x4(_r6,_r7) __asm{ \ - /*We use the fact that \ - (abs(a+b)+abs(a-b))/2=max(abs(a),abs(b)) \ - to merge the final butterfly with the abs and the first stage of \ - accumulation. \ - Thus we can avoid using pabsw, which is not available until SSSE3. \ - Emulating pabsw takes 3 instructions, so the straightforward MMXEXT \ - implementation would be (3+3)*8+7=55 instructions (+4 for spilling \ - registers). \ - Even with pabsw, it would be (3+1)*8+7=39 instructions (with no spills). \ - This implementation is only 26 (+4 for spilling registers).*/ \ - __asm movq [_r7+BUF],mm7 \ - __asm movq [_r6+BUF],mm6 \ - /*mm7={0x7FFF}x4 \ - mm0=max(abs(mm0),abs(mm1))-0x7FFF*/ \ - __asm pcmpeqb mm7,mm7 \ - __asm movq mm6,mm0 \ - __asm psrlw mm7,1 \ - __asm paddw mm6,mm1 \ - __asm pmaxsw mm0,mm1 \ - __asm paddsw mm6,mm7 \ - __asm psubw mm0,mm6 \ - /*mm2=max(abs(mm2),abs(mm3))-0x7FFF \ - mm4=max(abs(mm4),abs(mm5))-0x7FFF*/ \ - __asm movq mm6,mm2 \ - __asm movq mm1,mm4 \ - __asm pmaxsw mm2,mm3 \ - __asm pmaxsw mm4,mm5 \ - __asm paddw mm6,mm3 \ - __asm paddw mm1,mm5 \ - __asm movq mm3,[_r7+BUF] \ -} - -/*Performs the second part of the final stage of the Hadamard transform and - summing of absolute values.*/ -#define OC_HADAMARD_C_ABS_ACCUM_B_8x4(_r6,_r7) __asm{ \ - __asm paddsw mm6,mm7 \ - __asm movq mm5,[_r6+BUF] \ - __asm paddsw mm1,mm7 \ - __asm psubw mm2,mm6 \ - __asm psubw mm4,mm1 \ - /*mm7={1}x4 (needed for the horizontal add that follows) \ - mm0+=mm2+mm4+max(abs(mm3),abs(mm5))-0x7FFF*/ \ - __asm movq mm6,mm3 \ - __asm pmaxsw mm3,mm5 \ - __asm paddw mm0,mm2 \ - __asm paddw mm6,mm5 \ - __asm paddw mm0,mm4 \ - __asm paddsw mm6,mm7 \ - __asm paddw mm0,mm3 \ - __asm psrlw mm7,14 \ - __asm psubw mm0,mm6 \ -} - -/*Performs the last stage of an 8-point 1-D Hadamard transform, takes the - absolute value of each component, and accumulates everything into mm0. - This is the only portion of SATD which requires MMXEXT (we could use plain - MMX, but it takes 4 instructions and an extra register to work around the - lack of a pmaxsw, which is a pretty serious penalty).*/ -#define OC_HADAMARD_C_ABS_ACCUM_8x4(_r6,_r7) __asm{ \ - OC_HADAMARD_C_ABS_ACCUM_A_8x4(_r6,_r7) \ - OC_HADAMARD_C_ABS_ACCUM_B_8x4(_r6,_r7) \ -} - -/*Performs an 8-point 1-D Hadamard transform, takes the absolute value of each - component, and accumulates everything into mm0. - Note that mm0 will have an extra 4 added to each column, and that after - removing this value, the remainder will be half the conventional value.*/ -#define OC_HADAMARD_ABS_ACCUM_8x4(_r6,_r7) __asm{ \ - OC_HADAMARD_AB_8x4 \ - OC_HADAMARD_C_ABS_ACCUM_8x4(_r6,_r7) \ -} - -/*Performs two 4x4 transposes (mostly) in place. - On input, {mm0,mm1,mm2,mm3} contains rows {e,f,g,h}, and {mm4,mm5,mm6,mm7} - contains rows {a,b,c,d}. - On output, {0x40,0x50,0x60,0x70}+_off+BUF contains {e,f,g,h}^T, and - {mm4,mm5,mm6,mm7} contains the transposed rows {a,b,c,d}^T.*/ -#define OC_TRANSPOSE_4x4x2(_off) __asm{ \ - /*First 4x4 transpose:*/ \ - __asm movq [0x10+_off+BUF],mm5 \ - /*mm0 = e3 e2 e1 e0 \ - mm1 = f3 f2 f1 f0 \ - mm2 = g3 g2 g1 g0 \ - mm3 = h3 h2 h1 h0*/ \ - __asm movq mm5,mm2 \ - __asm punpcklwd mm2,mm3 \ - __asm punpckhwd mm5,mm3 \ - __asm movq mm3,mm0 \ - __asm punpcklwd mm0,mm1 \ - __asm punpckhwd mm3,mm1 \ - /*mm0 = f1 e1 f0 e0 \ - mm3 = f3 e3 f2 e2 \ - mm2 = h1 g1 h0 g0 \ - mm5 = h3 g3 h2 g2*/ \ - __asm movq mm1,mm0 \ - __asm punpckldq mm0,mm2 \ - __asm punpckhdq mm1,mm2 \ - __asm movq mm2,mm3 \ - __asm punpckhdq mm3,mm5 \ - __asm movq [0x40+_off+BUF],mm0 \ - __asm punpckldq mm2,mm5 \ - /*mm0 = h0 g0 f0 e0 \ - mm1 = h1 g1 f1 e1 \ - mm2 = h2 g2 f2 e2 \ - mm3 = h3 g3 f3 e3*/ \ - __asm movq mm5,[0x10+_off+BUF] \ - /*Second 4x4 transpose:*/ \ - /*mm4 = a3 a2 a1 a0 \ - mm5 = b3 b2 b1 b0 \ - mm6 = c3 c2 c1 c0 \ - mm7 = d3 d2 d1 d0*/ \ - __asm movq mm0,mm6 \ - __asm punpcklwd mm6,mm7 \ - __asm movq [0x50+_off+BUF],mm1 \ - __asm punpckhwd mm0,mm7 \ - __asm movq mm7,mm4 \ - __asm punpcklwd mm4,mm5 \ - __asm movq [0x60+_off+BUF],mm2 \ - __asm punpckhwd mm7,mm5 \ - /*mm4 = b1 a1 b0 a0 \ - mm7 = b3 a3 b2 a2 \ - mm6 = d1 c1 d0 c0 \ - mm0 = d3 c3 d2 c2*/ \ - __asm movq mm5,mm4 \ - __asm punpckldq mm4,mm6 \ - __asm movq [0x70+_off+BUF],mm3 \ - __asm punpckhdq mm5,mm6 \ - __asm movq mm6,mm7 \ - __asm punpckhdq mm7,mm0 \ - __asm punpckldq mm6,mm0 \ - /*mm4 = d0 c0 b0 a0 \ - mm5 = d1 c1 b1 a1 \ - mm6 = d2 c2 b2 a2 \ - mm7 = d3 c3 b3 a3*/ \ -} - -static unsigned oc_int_frag_satd_thresh_mmxext(const unsigned char *_src, - int _src_ystride,const unsigned char *_ref,int _ref_ystride,unsigned _thresh){ - OC_ALIGN8(ogg_int16_t buf[64]); - ogg_int16_t *bufp; - unsigned ret1; - unsigned ret2; - bufp=buf; - __asm{ -#define SRC esi -#define REF eax -#define SRC_YSTRIDE ecx -#define REF_YSTRIDE edx -#define BUF edi -#define RET eax -#define RET2 edx - mov SRC,_src - mov SRC_YSTRIDE,_src_ystride - mov REF,_ref - mov REF_YSTRIDE,_ref_ystride - mov BUF,bufp - OC_LOAD_SUB_8x4(0x00) - OC_HADAMARD_8x4 - OC_TRANSPOSE_4x4x2(0x00) - /*Finish swapping out this 8x4 block to make room for the next one. - mm0...mm3 have been swapped out already.*/ - movq [0x00+BUF],mm4 - movq [0x10+BUF],mm5 - movq [0x20+BUF],mm6 - movq [0x30+BUF],mm7 - OC_LOAD_SUB_8x4(0x04) - OC_HADAMARD_8x4 - OC_TRANSPOSE_4x4x2(0x08) - /*Here the first 4x4 block of output from the last transpose is the second - 4x4 block of input for the next transform. - We have cleverly arranged that it already be in the appropriate place, so - we only have to do half the loads.*/ - movq mm1,[0x10+BUF] - movq mm2,[0x20+BUF] - movq mm3,[0x30+BUF] - movq mm0,[0x00+BUF] - OC_HADAMARD_ABS_ACCUM_8x4(0x28,0x38) - /*Up to this point, everything fit in 16 bits (8 input + 1 for the - difference + 2*3 for the two 8-point 1-D Hadamards - 1 for the abs - 1 - for the factor of two we dropped + 3 for the vertical accumulation). - Now we finally have to promote things to dwords. - We break this part out of OC_HADAMARD_ABS_ACCUM_8x4 to hide the long - latency of pmaddwd by starting the next series of loads now.*/ - mov RET2,_thresh - pmaddwd mm0,mm7 - movq mm1,[0x50+BUF] - movq mm5,[0x58+BUF] - movq mm4,mm0 - movq mm2,[0x60+BUF] - punpckhdq mm0,mm0 - movq mm6,[0x68+BUF] - paddd mm4,mm0 - movq mm3,[0x70+BUF] - movd RET,mm4 - movq mm7,[0x78+BUF] - /*The sums produced by OC_HADAMARD_ABS_ACCUM_8x4 each have an extra 4 - added to them, and a factor of two removed; correct the final sum here.*/ - lea RET,[RET+RET-32] - movq mm0,[0x40+BUF] - cmp RET,RET2 - movq mm4,[0x48+BUF] - jae at_end - OC_HADAMARD_ABS_ACCUM_8x4(0x68,0x78) - pmaddwd mm0,mm7 - /*There isn't much to stick in here to hide the latency this time, but the - alternative to pmaddwd is movq->punpcklwd->punpckhwd->paddd, whose - latency is even worse.*/ - sub RET,32 - movq mm4,mm0 - punpckhdq mm0,mm0 - paddd mm4,mm0 - movd RET2,mm4 - lea RET,[RET+RET2*2] - align 16 -at_end: - mov ret1,RET -#undef SRC -#undef REF -#undef SRC_YSTRIDE -#undef REF_YSTRIDE -#undef BUF -#undef RET -#undef RET2 - } - return ret1; -} - -unsigned oc_enc_frag_satd_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh){ - return oc_int_frag_satd_thresh_mmxext(_src,_ystride,_ref,_ystride,_thresh); -} - - -/*Our internal implementation of frag_copy2 takes an extra stride parameter so - we can share code with oc_enc_frag_satd2_thresh_mmxext().*/ -static void oc_int_frag_copy2_mmxext(unsigned char *_dst,int _dst_ystride, - const unsigned char *_src1,const unsigned char *_src2,int _src_ystride){ - __asm{ - /*Load the first 3 rows.*/ -#define DST_YSTRIDE edi -#define SRC_YSTRIDE esi -#define DST eax -#define SRC1 edx -#define SRC2 ecx - mov DST_YSTRIDE,_dst_ystride - mov SRC_YSTRIDE,_src_ystride - mov DST,_dst - mov SRC1,_src1 - mov SRC2,_src2 - movq mm0,[SRC1] - movq mm1,[SRC2] - movq mm2,[SRC1+SRC_YSTRIDE] - lea SRC1,[SRC1+SRC_YSTRIDE*2] - movq mm3,[SRC2+SRC_YSTRIDE] - lea SRC2,[SRC2+SRC_YSTRIDE*2] - pxor mm7,mm7 - movq mm4,[SRC1] - pcmpeqb mm6,mm6 - movq mm5,[SRC2] - /*mm7={1}x8.*/ - psubb mm7,mm6 - /*Start averaging mm0 and mm1 into mm6.*/ - movq mm6,mm0 - pxor mm0,mm1 - pavgb mm6,mm1 - /*mm1 is free, start averaging mm3 into mm2 using mm1.*/ - movq mm1,mm2 - pand mm0,mm7 - pavgb mm2,mm3 - pxor mm1,mm3 - /*mm3 is free.*/ - psubb mm6,mm0 - /*mm0 is free, start loading the next row.*/ - movq mm0,[SRC1+SRC_YSTRIDE] - /*Start averaging mm5 and mm4 using mm3.*/ - movq mm3,mm4 - /*mm6 [row 0] is done; write it out.*/ - movq [DST],mm6 - pand mm1,mm7 - pavgb mm4,mm5 - psubb mm2,mm1 - /*mm1 is free, continue loading the next row.*/ - movq mm1,[SRC2+SRC_YSTRIDE] - pxor mm3,mm5 - lea SRC1,[SRC1+SRC_YSTRIDE*2] - /*mm2 [row 1] is done; write it out.*/ - movq [DST+DST_YSTRIDE],mm2 - pand mm3,mm7 - /*Start loading the next row.*/ - movq mm2,[SRC1] - lea DST,[DST+DST_YSTRIDE*2] - psubb mm4,mm3 - lea SRC2,[SRC2+SRC_YSTRIDE*2] - /*mm4 [row 2] is done; write it out.*/ - movq [DST],mm4 - /*Continue loading the next row.*/ - movq mm3,[SRC2] - /*Start averaging mm0 and mm1 into mm6.*/ - movq mm6,mm0 - pxor mm0,mm1 - /*Start loading the next row.*/ - movq mm4,[SRC1+SRC_YSTRIDE] - pavgb mm6,mm1 - /*mm1 is free; start averaging mm3 into mm2 using mm1.*/ - movq mm1,mm2 - pand mm0,mm7 - /*Continue loading the next row.*/ - movq mm5,[SRC2+SRC_YSTRIDE] - pavgb mm2,mm3 - lea SRC1,[SRC1+SRC_YSTRIDE*2] - pxor mm1,mm3 - /*mm3 is free.*/ - psubb mm6,mm0 - /*mm0 is free, start loading the next row.*/ - movq mm0,[SRC1] - /*Start averaging mm5 into mm4 using mm3.*/ - movq mm3,mm4 - /*mm6 [row 3] is done; write it out.*/ - movq [DST+DST_YSTRIDE],mm6 - pand mm1,mm7 - lea SRC2,[SRC2+SRC_YSTRIDE*2] - pavgb mm4,mm5 - lea DST,[DST+DST_YSTRIDE*2] - psubb mm2,mm1 - /*mm1 is free; continue loading the next row.*/ - movq mm1,[SRC2] - pxor mm3,mm5 - /*mm2 [row 4] is done; write it out.*/ - movq [DST],mm2 - pand mm3,mm7 - /*Start loading the next row.*/ - movq mm2,[SRC1+SRC_YSTRIDE] - psubb mm4,mm3 - /*Start averaging mm0 and mm1 into mm6.*/ - movq mm6,mm0 - /*Continue loading the next row.*/ - movq mm3,[SRC2+SRC_YSTRIDE] - /*mm4 [row 5] is done; write it out.*/ - movq [DST+DST_YSTRIDE],mm4 - pxor mm0,mm1 - pavgb mm6,mm1 - /*mm4 is free; start averaging mm3 into mm2 using mm4.*/ - movq mm4,mm2 - pand mm0,mm7 - pavgb mm2,mm3 - pxor mm4,mm3 - lea DST,[DST+DST_YSTRIDE*2] - psubb mm6,mm0 - pand mm4,mm7 - /*mm6 [row 6] is done, write it out.*/ - movq [DST],mm6 - psubb mm2,mm4 - /*mm2 [row 7] is done, write it out.*/ - movq [DST+DST_YSTRIDE],mm2 -#undef SRC1 -#undef SRC2 -#undef SRC_YSTRIDE -#undef DST_YSTRIDE -#undef DST - } -} - -unsigned oc_enc_frag_satd2_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh){ - OC_ALIGN8(unsigned char ref[64]); - oc_int_frag_copy2_mmxext(ref,8,_ref1,_ref2,_ystride); - return oc_int_frag_satd_thresh_mmxext(_src,_ystride,ref,8,_thresh); -} - -unsigned oc_enc_frag_intra_satd_mmxext(const unsigned char *_src, - int _ystride){ - OC_ALIGN8(ogg_int16_t buf[64]); - ogg_int16_t *bufp; - unsigned ret1; - unsigned ret2; - bufp=buf; - __asm{ -#define SRC eax -#define SRC4 esi -#define BUF edi -#define RET eax -#define RET_WORD ax -#define RET2 ecx -#define YSTRIDE edx -#define YSTRIDE3 ecx - mov SRC,_src - mov BUF,bufp - mov YSTRIDE,_ystride - /* src4 = src+4*ystride */ - lea SRC4,[SRC+YSTRIDE*4] - /* ystride3 = 3*ystride */ - lea YSTRIDE3,[YSTRIDE+YSTRIDE*2] - OC_LOAD_8x4(0x00) - OC_HADAMARD_8x4 - OC_TRANSPOSE_4x4x2(0x00) - /*Finish swapping out this 8x4 block to make room for the next one. - mm0...mm3 have been swapped out already.*/ - movq [0x00+BUF],mm4 - movq [0x10+BUF],mm5 - movq [0x20+BUF],mm6 - movq [0x30+BUF],mm7 - OC_LOAD_8x4(0x04) - OC_HADAMARD_8x4 - OC_TRANSPOSE_4x4x2(0x08) - /*Here the first 4x4 block of output from the last transpose is the second - 4x4 block of input for the next transform. - We have cleverly arranged that it already be in the appropriate place, so - we only have to do half the loads.*/ - movq mm1,[0x10+BUF] - movq mm2,[0x20+BUF] - movq mm3,[0x30+BUF] - movq mm0,[0x00+BUF] - /*We split out the stages here so we can save the DC coefficient in the - middle.*/ - OC_HADAMARD_AB_8x4 - OC_HADAMARD_C_ABS_ACCUM_A_8x4(0x28,0x38) - movd RET,mm1 - OC_HADAMARD_C_ABS_ACCUM_B_8x4(0x28,0x38) - /*Up to this point, everything fit in 16 bits (8 input + 1 for the - difference + 2*3 for the two 8-point 1-D Hadamards - 1 for the abs - 1 - for the factor of two we dropped + 3 for the vertical accumulation). - Now we finally have to promote things to dwords. - We break this part out of OC_HADAMARD_ABS_ACCUM_8x4 to hide the long - latency of pmaddwd by starting the next series of loads now.*/ - pmaddwd mm0,mm7 - movq mm1,[0x50+BUF] - movq mm5,[0x58+BUF] - movq mm2,[0x60+BUF] - movq mm4,mm0 - movq mm6,[0x68+BUF] - punpckhdq mm0,mm0 - movq mm3,[0x70+BUF] - paddd mm4,mm0 - movq mm7,[0x78+BUF] - movd RET2,mm4 - movq mm0,[0x40+BUF] - movq mm4,[0x48+BUF] - OC_HADAMARD_ABS_ACCUM_8x4(0x68,0x78) - pmaddwd mm0,mm7 - /*We assume that the DC coefficient is always positive (which is true, - because the input to the INTRA transform was not a difference).*/ - movzx RET,RET_WORD - add RET2,RET2 - sub RET2,RET - movq mm4,mm0 - punpckhdq mm0,mm0 - paddd mm4,mm0 - movd RET,mm4 - lea RET,[-64+RET2+RET*2] - mov [ret1],RET -#undef SRC -#undef SRC4 -#undef BUF -#undef RET -#undef RET_WORD -#undef RET2 -#undef YSTRIDE -#undef YSTRIDE3 - } - return ret1; -} - -void oc_enc_frag_sub_mmx(ogg_int16_t _residue[64], - const unsigned char *_src, const unsigned char *_ref,int _ystride){ - int i; - __asm pxor mm7,mm7 - for(i=4;i-->0;){ - __asm{ -#define SRC edx -#define YSTRIDE esi -#define RESIDUE eax -#define REF ecx - mov YSTRIDE,_ystride - mov RESIDUE,_residue - mov SRC,_src - mov REF,_ref - /*mm0=[src]*/ - movq mm0,[SRC] - /*mm1=[ref]*/ - movq mm1,[REF] - /*mm4=[src+ystride]*/ - movq mm4,[SRC+YSTRIDE] - /*mm5=[ref+ystride]*/ - movq mm5,[REF+YSTRIDE] - /*Compute [src]-[ref].*/ - movq mm2,mm0 - punpcklbw mm0,mm7 - movq mm3,mm1 - punpckhbw mm2,mm7 - punpcklbw mm1,mm7 - punpckhbw mm3,mm7 - psubw mm0,mm1 - psubw mm2,mm3 - /*Compute [src+ystride]-[ref+ystride].*/ - movq mm1,mm4 - punpcklbw mm4,mm7 - movq mm3,mm5 - punpckhbw mm1,mm7 - lea SRC,[SRC+YSTRIDE*2] - punpcklbw mm5,mm7 - lea REF,[REF+YSTRIDE*2] - punpckhbw mm3,mm7 - psubw mm4,mm5 - psubw mm1,mm3 - /*Write the answer out.*/ - movq [RESIDUE+0x00],mm0 - movq [RESIDUE+0x08],mm2 - movq [RESIDUE+0x10],mm4 - movq [RESIDUE+0x18],mm1 - lea RESIDUE,[RESIDUE+0x20] - mov _residue,RESIDUE - mov _src,SRC - mov _ref,REF -#undef SRC -#undef YSTRIDE -#undef RESIDUE -#undef REF - } - } -} - -void oc_enc_frag_sub_128_mmx(ogg_int16_t _residue[64], - const unsigned char *_src,int _ystride){ - __asm{ -#define YSTRIDE edx -#define YSTRIDE3 edi -#define RESIDUE ecx -#define SRC eax - mov YSTRIDE,_ystride - mov RESIDUE,_residue - mov SRC,_src - /*mm0=[src]*/ - movq mm0,[SRC] - /*mm1=[src+ystride]*/ - movq mm1,[SRC+YSTRIDE] - /*mm6={-1}x4*/ - pcmpeqw mm6,mm6 - /*mm2=[src+2*ystride]*/ - movq mm2,[SRC+YSTRIDE*2] - /*[ystride3]=3*[ystride]*/ - lea YSTRIDE3,[YSTRIDE+YSTRIDE*2] - /*mm6={1}x4*/ - psllw mm6,15 - /*mm3=[src+3*ystride]*/ - movq mm3,[SRC+YSTRIDE3] - /*mm6={128}x4*/ - psrlw mm6,8 - /*mm7=0*/ - pxor mm7,mm7 - /*[src]=[src]+4*[ystride]*/ - lea SRC,[SRC+YSTRIDE*4] - /*Compute [src]-128 and [src+ystride]-128*/ - movq mm4,mm0 - punpcklbw mm0,mm7 - movq mm5,mm1 - punpckhbw mm4,mm7 - psubw mm0,mm6 - punpcklbw mm1,mm7 - psubw mm4,mm6 - punpckhbw mm5,mm7 - psubw mm1,mm6 - psubw mm5,mm6 - /*Write the answer out.*/ - movq [RESIDUE+0x00],mm0 - movq [RESIDUE+0x08],mm4 - movq [RESIDUE+0x10],mm1 - movq [RESIDUE+0x18],mm5 - /*mm0=[src+4*ystride]*/ - movq mm0,[SRC] - /*mm1=[src+5*ystride]*/ - movq mm1,[SRC+YSTRIDE] - /*Compute [src+2*ystride]-128 and [src+3*ystride]-128*/ - movq mm4,mm2 - punpcklbw mm2,mm7 - movq mm5,mm3 - punpckhbw mm4,mm7 - psubw mm2,mm6 - punpcklbw mm3,mm7 - psubw mm4,mm6 - punpckhbw mm5,mm7 - psubw mm3,mm6 - psubw mm5,mm6 - /*Write the answer out.*/ - movq [RESIDUE+0x20],mm2 - movq [RESIDUE+0x28],mm4 - movq [RESIDUE+0x30],mm3 - movq [RESIDUE+0x38],mm5 - /*Compute [src+6*ystride]-128 and [src+7*ystride]-128*/ - movq mm2,[SRC+YSTRIDE*2] - movq mm3,[SRC+YSTRIDE3] - movq mm4,mm0 - punpcklbw mm0,mm7 - movq mm5,mm1 - punpckhbw mm4,mm7 - psubw mm0,mm6 - punpcklbw mm1,mm7 - psubw mm4,mm6 - punpckhbw mm5,mm7 - psubw mm1,mm6 - psubw mm5,mm6 - /*Write the answer out.*/ - movq [RESIDUE+0x40],mm0 - movq [RESIDUE+0x48],mm4 - movq [RESIDUE+0x50],mm1 - movq [RESIDUE+0x58],mm5 - /*Compute [src+6*ystride]-128 and [src+7*ystride]-128*/ - movq mm4,mm2 - punpcklbw mm2,mm7 - movq mm5,mm3 - punpckhbw mm4,mm7 - psubw mm2,mm6 - punpcklbw mm3,mm7 - psubw mm4,mm6 - punpckhbw mm5,mm7 - psubw mm3,mm6 - psubw mm5,mm6 - /*Write the answer out.*/ - movq [RESIDUE+0x60],mm2 - movq [RESIDUE+0x68],mm4 - movq [RESIDUE+0x70],mm3 - movq [RESIDUE+0x78],mm5 -#undef YSTRIDE -#undef YSTRIDE3 -#undef RESIDUE -#undef SRC - } -} - -void oc_enc_frag_copy2_mmxext(unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride){ - oc_int_frag_copy2_mmxext(_dst,_ystride,_src1,_src2,_ystride); -} - -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/mmxfdct.c b/Engine/lib/libtheora/lib/x86_vc/mmxfdct.c deleted file mode 100644 index d908ce241..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/mmxfdct.c +++ /dev/null @@ -1,670 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 1999-2006 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ********************************************************************/ - /*MMX fDCT implementation for x86_32*/ -/*$Id: fdct_ses2.c 14579 2008-03-12 06:42:40Z xiphmont $*/ -#include "x86enc.h" - -#if defined(OC_X86_ASM) - -#define OC_FDCT_STAGE1_8x4 __asm{ \ - /*Stage 1:*/ \ - /*mm0=t7'=t0-t7*/ \ - __asm psubw mm0,mm7 \ - __asm paddw mm7,mm7 \ - /*mm1=t6'=t1-t6*/ \ - __asm psubw mm1, mm6 \ - __asm paddw mm6,mm6 \ - /*mm2=t5'=t2-t5*/ \ - __asm psubw mm2,mm5 \ - __asm paddw mm5,mm5 \ - /*mm3=t4'=t3-t4*/ \ - __asm psubw mm3,mm4 \ - __asm paddw mm4,mm4 \ - /*mm7=t0'=t0+t7*/ \ - __asm paddw mm7,mm0 \ - /*mm6=t1'=t1+t6*/ \ - __asm paddw mm6,mm1 \ - /*mm5=t2'=t2+t5*/ \ - __asm paddw mm5,mm2 \ - /*mm4=t3'=t3+t4*/ \ - __asm paddw mm4,mm3\ -} - -#define OC_FDCT8x4(_r0,_r1,_r2,_r3,_r4,_r5,_r6,_r7) __asm{ \ - /*Stage 2:*/ \ - /*mm7=t3''=t0'-t3'*/ \ - __asm psubw mm7,mm4 \ - __asm paddw mm4,mm4 \ - /*mm6=t2''=t1'-t2'*/ \ - __asm psubw mm6,mm5 \ - __asm movq [Y+_r6],mm7 \ - __asm paddw mm5,mm5 \ - /*mm1=t5''=t6'-t5'*/ \ - __asm psubw mm1,mm2 \ - __asm movq [Y+_r2],mm6 \ - /*mm4=t0''=t0'+t3'*/ \ - __asm paddw mm4,mm7 \ - __asm paddw mm2,mm2 \ - /*mm5=t1''=t1'+t2'*/ \ - __asm movq [Y+_r0],mm4 \ - __asm paddw mm5,mm6 \ - /*mm2=t6''=t6'+t5'*/ \ - __asm paddw mm2,mm1 \ - __asm movq [Y+_r4],mm5 \ - /*mm0=t7', mm1=t5'', mm2=t6'', mm3=t4'.*/ \ - /*mm4, mm5, mm6, mm7 are free.*/ \ - /*Stage 3:*/ \ - /*mm6={2}x4, mm7={27146,0xB500>>1}x2*/ \ - __asm mov A,0x5A806A0A \ - __asm pcmpeqb mm6,mm6 \ - __asm movd mm7,A \ - __asm psrlw mm6,15 \ - __asm punpckldq mm7,mm7 \ - __asm paddw mm6,mm6 \ - /*mm0=0, m2={-1}x4 \ - mm5:mm4=t5''*27146+0xB500*/ \ - __asm movq mm4,mm1 \ - __asm movq mm5,mm1 \ - __asm punpcklwd mm4,mm6 \ - __asm movq [Y+_r3],mm2 \ - __asm pmaddwd mm4,mm7 \ - __asm movq [Y+_r7],mm0 \ - __asm punpckhwd mm5,mm6 \ - __asm pxor mm0,mm0 \ - __asm pmaddwd mm5,mm7 \ - __asm pcmpeqb mm2,mm2 \ - /*mm2=t6'', mm1=t5''+(t5''!=0) \ - mm4=(t5''*27146+0xB500>>16)*/ \ - __asm pcmpeqw mm0,mm1 \ - __asm psrad mm4,16 \ - __asm psubw mm0,mm2 \ - __asm movq mm2, [Y+_r3] \ - __asm psrad mm5,16 \ - __asm paddw mm1,mm0 \ - __asm packssdw mm4,mm5 \ - /*mm4=s=(t5''*27146+0xB500>>16)+t5''+(t5''!=0)>>1*/ \ - __asm paddw mm4,mm1 \ - __asm movq mm0, [Y+_r7] \ - __asm psraw mm4,1 \ - __asm movq mm1,mm3 \ - /*mm3=t4''=t4'+s*/ \ - __asm paddw mm3,mm4 \ - /*mm1=t5'''=t4'-s*/ \ - __asm psubw mm1,mm4 \ - /*mm1=0, mm3={-1}x4 \ - mm5:mm4=t6''*27146+0xB500*/ \ - __asm movq mm4,mm2 \ - __asm movq mm5,mm2 \ - __asm punpcklwd mm4,mm6 \ - __asm movq [Y+_r5],mm1 \ - __asm pmaddwd mm4,mm7 \ - __asm movq [Y+_r1],mm3 \ - __asm punpckhwd mm5,mm6 \ - __asm pxor mm1,mm1 \ - __asm pmaddwd mm5,mm7 \ - __asm pcmpeqb mm3,mm3 \ - /*mm2=t6''+(t6''!=0), mm4=(t6''*27146+0xB500>>16)*/ \ - __asm psrad mm4,16 \ - __asm pcmpeqw mm1,mm2 \ - __asm psrad mm5,16 \ - __asm psubw mm1,mm3 \ - __asm packssdw mm4,mm5 \ - __asm paddw mm2,mm1 \ - /*mm1=t1'' \ - mm4=s=(t6''*27146+0xB500>>16)+t6''+(t6''!=0)>>1*/ \ - __asm paddw mm4,mm2 \ - __asm movq mm1,[Y+_r4] \ - __asm psraw mm4,1 \ - __asm movq mm2,mm0 \ - /*mm7={54491-0x7FFF,0x7FFF}x2 \ - mm0=t7''=t7'+s*/ \ - __asm paddw mm0,mm4 \ - /*mm2=t6'''=t7'-s*/ \ - __asm psubw mm2,mm4 \ - /*Stage 4:*/ \ - /*mm0=0, mm2=t0'' \ - mm5:mm4=t1''*27146+0xB500*/ \ - __asm movq mm4,mm1 \ - __asm movq mm5,mm1 \ - __asm punpcklwd mm4,mm6 \ - __asm movq [Y+_r3],mm2 \ - __asm pmaddwd mm4,mm7 \ - __asm movq mm2,[Y+_r0] \ - __asm punpckhwd mm5,mm6 \ - __asm movq [Y+_r7],mm0 \ - __asm pmaddwd mm5,mm7 \ - __asm pxor mm0,mm0 \ - /*mm7={27146,0x4000>>1}x2 \ - mm0=s=(t1''*27146+0xB500>>16)+t1''+(t1''!=0)*/ \ - __asm psrad mm4,16 \ - __asm mov A,0x20006A0A \ - __asm pcmpeqw mm0,mm1 \ - __asm movd mm7,A \ - __asm psrad mm5,16 \ - __asm psubw mm0,mm3 \ - __asm packssdw mm4,mm5 \ - __asm paddw mm0,mm1 \ - __asm punpckldq mm7,mm7 \ - __asm paddw mm0,mm4 \ - /*mm6={0x00000E3D}x2 \ - mm1=-(t0''==0), mm5:mm4=t0''*27146+0x4000*/ \ - __asm movq mm4,mm2 \ - __asm movq mm5,mm2 \ - __asm punpcklwd mm4,mm6 \ - __asm mov A,0x0E3D \ - __asm pmaddwd mm4,mm7 \ - __asm punpckhwd mm5,mm6 \ - __asm movd mm6,A \ - __asm pmaddwd mm5,mm7 \ - __asm pxor mm1,mm1 \ - __asm punpckldq mm6,mm6 \ - __asm pcmpeqw mm1,mm2 \ - /*mm4=r=(t0''*27146+0x4000>>16)+t0''+(t0''!=0)*/ \ - __asm psrad mm4,16 \ - __asm psubw mm1,mm3 \ - __asm psrad mm5,16 \ - __asm paddw mm2,mm1 \ - __asm packssdw mm4,mm5 \ - __asm movq mm1,[Y+_r5] \ - __asm paddw mm4,mm2 \ - /*mm2=t6'', mm0=_y[0]=u=r+s>>1 \ - The naive implementation could cause overflow, so we use \ - u=(r&s)+((r^s)>>1).*/ \ - __asm movq mm2,[Y+_r3] \ - __asm movq mm7,mm0 \ - __asm pxor mm0,mm4 \ - __asm pand mm7,mm4 \ - __asm psraw mm0,1 \ - __asm mov A,0x7FFF54DC \ - __asm paddw mm0,mm7 \ - __asm movd mm7,A \ - /*mm7={54491-0x7FFF,0x7FFF}x2 \ - mm4=_y[4]=v=r-u*/ \ - __asm psubw mm4,mm0 \ - __asm punpckldq mm7,mm7 \ - __asm movq [Y+_r4],mm4 \ - /*mm0=0, mm7={36410}x4 \ - mm1=(t5'''!=0), mm5:mm4=54491*t5'''+0x0E3D*/ \ - __asm movq mm4,mm1 \ - __asm movq mm5,mm1 \ - __asm punpcklwd mm4,mm1 \ - __asm mov A,0x8E3A8E3A \ - __asm pmaddwd mm4,mm7 \ - __asm movq [Y+_r0],mm0 \ - __asm punpckhwd mm5,mm1 \ - __asm pxor mm0,mm0 \ - __asm pmaddwd mm5,mm7 \ - __asm pcmpeqw mm1,mm0 \ - __asm movd mm7,A \ - __asm psubw mm1,mm3 \ - __asm punpckldq mm7,mm7 \ - __asm paddd mm4,mm6 \ - __asm paddd mm5,mm6 \ - /*mm0=0 \ - mm3:mm1=36410*t6'''+((t5'''!=0)<<16)*/ \ - __asm movq mm6,mm2 \ - __asm movq mm3,mm2 \ - __asm pmulhw mm6,mm7 \ - __asm paddw mm1,mm2 \ - __asm pmullw mm3,mm7 \ - __asm pxor mm0,mm0 \ - __asm paddw mm6,mm1 \ - __asm movq mm1,mm3 \ - __asm punpckhwd mm3,mm6 \ - __asm punpcklwd mm1,mm6 \ - /*mm3={-1}x4, mm6={1}x4 \ - mm4=_y[5]=u=(54491*t5'''+36410*t6'''+0x0E3D>>16)+(t5'''!=0)*/ \ - __asm paddd mm5,mm3 \ - __asm paddd mm4,mm1 \ - __asm psrad mm5,16 \ - __asm pxor mm6,mm6 \ - __asm psrad mm4,16 \ - __asm pcmpeqb mm3,mm3 \ - __asm packssdw mm4,mm5 \ - __asm psubw mm6,mm3 \ - /*mm1=t7'', mm7={26568,0x3400}x2 \ - mm2=s=t6'''-(36410*u>>16)*/ \ - __asm movq mm1,mm4 \ - __asm mov A,0x340067C8 \ - __asm pmulhw mm4,mm7 \ - __asm movd mm7,A \ - __asm movq [Y+_r5],mm1 \ - __asm punpckldq mm7,mm7 \ - __asm paddw mm4,mm1 \ - __asm movq mm1,[Y+_r7] \ - __asm psubw mm2,mm4 \ - /*mm6={0x00007B1B}x2 \ - mm0=(s!=0), mm5:mm4=s*26568+0x3400*/ \ - __asm movq mm4,mm2 \ - __asm movq mm5,mm2 \ - __asm punpcklwd mm4,mm6 \ - __asm pcmpeqw mm0,mm2 \ - __asm pmaddwd mm4,mm7 \ - __asm mov A,0x7B1B \ - __asm punpckhwd mm5,mm6 \ - __asm movd mm6,A \ - __asm pmaddwd mm5,mm7 \ - __asm psubw mm0,mm3 \ - __asm punpckldq mm6,mm6 \ - /*mm7={64277-0x7FFF,0x7FFF}x2 \ - mm2=_y[3]=v=(s*26568+0x3400>>17)+s+(s!=0)*/ \ - __asm psrad mm4,17 \ - __asm paddw mm2,mm0 \ - __asm psrad mm5,17 \ - __asm mov A,0x7FFF7B16 \ - __asm packssdw mm4,mm5 \ - __asm movd mm7,A \ - __asm paddw mm2,mm4 \ - __asm punpckldq mm7,mm7 \ - /*mm0=0, mm7={12785}x4 \ - mm1=(t7''!=0), mm2=t4'', mm5:mm4=64277*t7''+0x7B1B*/ \ - __asm movq mm4,mm1 \ - __asm movq mm5,mm1 \ - __asm movq [Y+_r3],mm2 \ - __asm punpcklwd mm4,mm1 \ - __asm movq mm2,[Y+_r1] \ - __asm pmaddwd mm4,mm7 \ - __asm mov A,0x31F131F1 \ - __asm punpckhwd mm5,mm1 \ - __asm pxor mm0,mm0 \ - __asm pmaddwd mm5,mm7 \ - __asm pcmpeqw mm1,mm0 \ - __asm movd mm7,A \ - __asm psubw mm1,mm3 \ - __asm punpckldq mm7,mm7 \ - __asm paddd mm4,mm6 \ - __asm paddd mm5,mm6 \ - /*mm3:mm1=12785*t4'''+((t7''!=0)<<16)*/ \ - __asm movq mm6,mm2 \ - __asm movq mm3,mm2 \ - __asm pmulhw mm6,mm7 \ - __asm pmullw mm3,mm7 \ - __asm paddw mm6,mm1 \ - __asm movq mm1,mm3 \ - __asm punpckhwd mm3,mm6 \ - __asm punpcklwd mm1,mm6 \ - /*mm3={-1}x4, mm6={1}x4 \ - mm4=_y[1]=u=(12785*t4'''+64277*t7''+0x7B1B>>16)+(t7''!=0)*/ \ - __asm paddd mm5,mm3 \ - __asm paddd mm4,mm1 \ - __asm psrad mm5,16 \ - __asm pxor mm6,mm6 \ - __asm psrad mm4,16 \ - __asm pcmpeqb mm3,mm3 \ - __asm packssdw mm4,mm5 \ - __asm psubw mm6,mm3 \ - /*mm1=t3'', mm7={20539,0x3000}x2 \ - mm4=s=(12785*u>>16)-t4''*/ \ - __asm movq [Y+_r1],mm4 \ - __asm pmulhw mm4,mm7 \ - __asm mov A,0x3000503B \ - __asm movq mm1,[Y+_r6] \ - __asm movd mm7,A \ - __asm psubw mm4,mm2 \ - __asm punpckldq mm7,mm7 \ - /*mm6={0x00006CB7}x2 \ - mm0=(s!=0), mm5:mm4=s*20539+0x3000*/ \ - __asm movq mm5,mm4 \ - __asm movq mm2,mm4 \ - __asm punpcklwd mm4,mm6 \ - __asm pcmpeqw mm0,mm2 \ - __asm pmaddwd mm4,mm7 \ - __asm mov A,0x6CB7 \ - __asm punpckhwd mm5,mm6 \ - __asm movd mm6,A \ - __asm pmaddwd mm5,mm7 \ - __asm psubw mm0,mm3 \ - __asm punpckldq mm6,mm6 \ - /*mm7={60547-0x7FFF,0x7FFF}x2 \ - mm2=_y[7]=v=(s*20539+0x3000>>20)+s+(s!=0)*/ \ - __asm psrad mm4,20 \ - __asm paddw mm2,mm0 \ - __asm psrad mm5,20 \ - __asm mov A,0x7FFF6C84 \ - __asm packssdw mm4,mm5 \ - __asm movd mm7,A \ - __asm paddw mm2,mm4 \ - __asm punpckldq mm7,mm7 \ - /*mm0=0, mm7={25080}x4 \ - mm2=t2'', mm5:mm4=60547*t3''+0x6CB7*/ \ - __asm movq mm4,mm1 \ - __asm movq mm5,mm1 \ - __asm movq [Y+_r7],mm2 \ - __asm punpcklwd mm4,mm1 \ - __asm movq mm2,[Y+_r2] \ - __asm pmaddwd mm4,mm7 \ - __asm mov A,0x61F861F8 \ - __asm punpckhwd mm5,mm1 \ - __asm pxor mm0,mm0 \ - __asm pmaddwd mm5,mm7 \ - __asm movd mm7,A \ - __asm pcmpeqw mm1,mm0 \ - __asm psubw mm1,mm3 \ - __asm punpckldq mm7,mm7 \ - __asm paddd mm4,mm6 \ - __asm paddd mm5,mm6 \ - /*mm3:mm1=25080*t2''+((t3''!=0)<<16)*/ \ - __asm movq mm6,mm2 \ - __asm movq mm3,mm2 \ - __asm pmulhw mm6,mm7 \ - __asm pmullw mm3,mm7 \ - __asm paddw mm6,mm1 \ - __asm movq mm1,mm3 \ - __asm punpckhwd mm3,mm6 \ - __asm punpcklwd mm1,mm6 \ - /*mm1={-1}x4 \ - mm4=u=(25080*t2''+60547*t3''+0x6CB7>>16)+(t3''!=0)*/ \ - __asm paddd mm5,mm3 \ - __asm paddd mm4,mm1 \ - __asm psrad mm5,16 \ - __asm mov A,0x28005460 \ - __asm psrad mm4,16 \ - __asm pcmpeqb mm1,mm1 \ - __asm packssdw mm4,mm5 \ - /*mm5={1}x4, mm6=_y[2]=u, mm7={21600,0x2800}x2 \ - mm4=s=(25080*u>>16)-t2''*/ \ - __asm movq mm6,mm4 \ - __asm pmulhw mm4,mm7 \ - __asm pxor mm5,mm5 \ - __asm movd mm7,A \ - __asm psubw mm5,mm1 \ - __asm punpckldq mm7,mm7 \ - __asm psubw mm4,mm2 \ - /*mm2=s+(s!=0) \ - mm4:mm3=s*21600+0x2800*/ \ - __asm movq mm3,mm4 \ - __asm movq mm2,mm4 \ - __asm punpckhwd mm4,mm5 \ - __asm pcmpeqw mm0,mm2 \ - __asm pmaddwd mm4,mm7 \ - __asm psubw mm0,mm1 \ - __asm punpcklwd mm3,mm5 \ - __asm paddw mm2,mm0 \ - __asm pmaddwd mm3,mm7 \ - /*mm0=_y[4], mm1=_y[7], mm4=_y[0], mm5=_y[5] \ - mm3=_y[6]=v=(s*21600+0x2800>>18)+s+(s!=0)*/ \ - __asm movq mm0,[Y+_r4] \ - __asm psrad mm4,18 \ - __asm movq mm5,[Y+_r5] \ - __asm psrad mm3,18 \ - __asm movq mm1,[Y+_r7] \ - __asm packssdw mm3,mm4 \ - __asm movq mm4,[Y+_r0] \ - __asm paddw mm3,mm2 \ -} - -/*On input, mm4=_y[0], mm6=_y[2], mm0=_y[4], mm5=_y[5], mm3=_y[6], mm1=_y[7]. - On output, {_y[4],mm1,mm2,mm3} contains the transpose of _y[4...7] and - {mm4,mm5,mm6,mm7} contains the transpose of _y[0...3].*/ -#define OC_TRANSPOSE8x4(_r0,_r1,_r2,_r3,_r4,_r5,_r6,_r7) __asm{ \ - /*First 4x4 transpose:*/ \ - /*mm0 = e3 e2 e1 e0 \ - mm5 = f3 f2 f1 f0 \ - mm3 = g3 g2 g1 g0 \ - mm1 = h3 h2 h1 h0*/ \ - __asm movq mm2,mm0 \ - __asm punpcklwd mm0,mm5 \ - __asm punpckhwd mm2,mm5 \ - __asm movq mm5,mm3 \ - __asm punpcklwd mm3,mm1 \ - __asm punpckhwd mm5,mm1 \ - /*mm0 = f1 e1 f0 e0 \ - mm2 = f3 e3 f2 e2 \ - mm3 = h1 g1 h0 g0 \ - mm5 = h3 g3 h2 g2*/ \ - __asm movq mm1,mm0 \ - __asm punpckldq mm0,mm3 \ - __asm movq [Y+_r4],mm0 \ - __asm punpckhdq mm1,mm3 \ - __asm movq mm0,[Y+_r1] \ - __asm movq mm3,mm2 \ - __asm punpckldq mm2,mm5 \ - __asm punpckhdq mm3,mm5 \ - __asm movq mm5,[Y+_r3] \ - /*_y[4] = h0 g0 f0 e0 \ - mm1 = h1 g1 f1 e1 \ - mm2 = h2 g2 f2 e2 \ - mm3 = h3 g3 f3 e3*/ \ - /*Second 4x4 transpose:*/ \ - /*mm4 = a3 a2 a1 a0 \ - mm0 = b3 b2 b1 b0 \ - mm6 = c3 c2 c1 c0 \ - mm5 = d3 d2 d1 d0*/ \ - __asm movq mm7,mm4 \ - __asm punpcklwd mm4,mm0 \ - __asm punpckhwd mm7,mm0 \ - __asm movq mm0,mm6 \ - __asm punpcklwd mm6,mm5 \ - __asm punpckhwd mm0,mm5 \ - /*mm4 = b1 a1 b0 a0 \ - mm7 = b3 a3 b2 a2 \ - mm6 = d1 c1 d0 c0 \ - mm0 = d3 c3 d2 c2*/ \ - __asm movq mm5,mm4 \ - __asm punpckldq mm4,mm6 \ - __asm punpckhdq mm5,mm6 \ - __asm movq mm6,mm7 \ - __asm punpckhdq mm7,mm0 \ - __asm punpckldq mm6,mm0 \ - /*mm4 = d0 c0 b0 a0 \ - mm5 = d1 c1 b1 a1 \ - mm6 = d2 c2 b2 a2 \ - mm7 = d3 c3 b3 a3*/ \ -} - -/*MMX implementation of the fDCT.*/ -void oc_enc_fdct8x8_mmx(ogg_int16_t _y[64],const ogg_int16_t _x[64]){ - ptrdiff_t a; - __asm{ -#define Y eax -#define A ecx -#define X edx - /*Add two extra bits of working precision to improve accuracy; any more and - we could overflow.*/ - /*We also add biases to correct for some systematic error that remains in - the full fDCT->iDCT round trip.*/ - mov X, _x - mov Y, _y - movq mm0,[0x00+X] - movq mm1,[0x10+X] - movq mm2,[0x20+X] - movq mm3,[0x30+X] - pcmpeqb mm4,mm4 - pxor mm7,mm7 - movq mm5,mm0 - psllw mm0,2 - pcmpeqw mm5,mm7 - movq mm7,[0x70+X] - psllw mm1,2 - psubw mm5,mm4 - psllw mm2,2 - mov A,1 - pslld mm5,16 - movd mm6,A - psllq mm5,16 - mov A,0x10001 - psllw mm3,2 - movd mm4,A - punpckhwd mm5,mm6 - psubw mm1,mm6 - movq mm6,[0x60+X] - paddw mm0,mm5 - movq mm5,[0x50+X] - paddw mm0,mm4 - movq mm4,[0x40+X] - /*We inline stage1 of the transform here so we can get better instruction - scheduling with the shifts.*/ - /*mm0=t7'=t0-t7*/ - psllw mm7,2 - psubw mm0,mm7 - psllw mm6,2 - paddw mm7,mm7 - /*mm1=t6'=t1-t6*/ - psllw mm5,2 - psubw mm1,mm6 - psllw mm4,2 - paddw mm6,mm6 - /*mm2=t5'=t2-t5*/ - psubw mm2,mm5 - paddw mm5,mm5 - /*mm3=t4'=t3-t4*/ - psubw mm3,mm4 - paddw mm4,mm4 - /*mm7=t0'=t0+t7*/ - paddw mm7,mm0 - /*mm6=t1'=t1+t6*/ - paddw mm6,mm1 - /*mm5=t2'=t2+t5*/ - paddw mm5,mm2 - /*mm4=t3'=t3+t4*/ - paddw mm4,mm3 - OC_FDCT8x4(0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70) - OC_TRANSPOSE8x4(0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70) - /*Swap out this 8x4 block for the next one.*/ - movq mm0,[0x08+X] - movq [0x30+Y],mm7 - movq mm7,[0x78+X] - movq [0x50+Y],mm1 - movq mm1,[0x18+X] - movq [0x20+Y],mm6 - movq mm6,[0x68+X] - movq [0x60+Y],mm2 - movq mm2,[0x28+X] - movq [0x10+Y],mm5 - movq mm5,[0x58+X] - movq [0x70+Y],mm3 - movq mm3,[0x38+X] - /*And increase its working precision, too.*/ - psllw mm0,2 - movq [0x00+Y],mm4 - psllw mm7,2 - movq mm4,[0x48+X] - /*We inline stage1 of the transform here so we can get better instruction - scheduling with the shifts.*/ - /*mm0=t7'=t0-t7*/ - psubw mm0,mm7 - psllw mm1,2 - paddw mm7,mm7 - psllw mm6,2 - /*mm1=t6'=t1-t6*/ - psubw mm1,mm6 - psllw mm2,2 - paddw mm6,mm6 - psllw mm5,2 - /*mm2=t5'=t2-t5*/ - psubw mm2,mm5 - psllw mm3,2 - paddw mm5,mm5 - psllw mm4,2 - /*mm3=t4'=t3-t4*/ - psubw mm3,mm4 - paddw mm4,mm4 - /*mm7=t0'=t0+t7*/ - paddw mm7,mm0 - /*mm6=t1'=t1+t6*/ - paddw mm6,mm1 - /*mm5=t2'=t2+t5*/ - paddw mm5,mm2 - /*mm4=t3'=t3+t4*/ - paddw mm4,mm3 - OC_FDCT8x4(0x08,0x18,0x28,0x38,0x48,0x58,0x68,0x78) - OC_TRANSPOSE8x4(0x08,0x18,0x28,0x38,0x48,0x58,0x68,0x78) - /*Here the first 4x4 block of output from the last transpose is the second - 4x4 block of input for the next transform. - We have cleverly arranged that it already be in the appropriate place, - so we only have to do half the stores and loads.*/ - movq mm0,[0x00+Y] - movq [0x58+Y],mm1 - movq mm1,[0x10+Y] - movq [0x68+Y],mm2 - movq mm2,[0x20+Y] - movq [0x78+Y],mm3 - movq mm3,[0x30+Y] - OC_FDCT_STAGE1_8x4 - OC_FDCT8x4(0x00,0x10,0x20,0x30,0x08,0x18,0x28,0x38) - OC_TRANSPOSE8x4(0x00,0x10,0x20,0x30,0x08,0x18,0x28,0x38) - /*mm0={-2}x4*/ - pcmpeqw mm0,mm0 - paddw mm0,mm0 - /*Round the results.*/ - psubw mm1,mm0 - psubw mm2,mm0 - psraw mm1,2 - psubw mm3,mm0 - movq [0x18+Y],mm1 - psraw mm2,2 - psubw mm4,mm0 - movq mm1,[0x08+Y] - psraw mm3,2 - psubw mm5,mm0 - psraw mm4,2 - psubw mm6,mm0 - psraw mm5,2 - psubw mm7,mm0 - psraw mm6,2 - psubw mm1,mm0 - psraw mm7,2 - movq mm0,[0x40+Y] - psraw mm1,2 - movq [0x30+Y],mm7 - movq mm7,[0x78+Y] - movq [0x08+Y],mm1 - movq mm1,[0x50+Y] - movq [0x20+Y],mm6 - movq mm6,[0x68+Y] - movq [0x28+Y],mm2 - movq mm2,[0x60+Y] - movq [0x10+Y],mm5 - movq mm5,[0x58+Y] - movq [0x38+Y],mm3 - movq mm3,[0x70+Y] - movq [0x00+Y],mm4 - movq mm4,[0x48+Y] - OC_FDCT_STAGE1_8x4 - OC_FDCT8x4(0x40,0x50,0x60,0x70,0x48,0x58,0x68,0x78) - OC_TRANSPOSE8x4(0x40,0x50,0x60,0x70,0x48,0x58,0x68,0x78) - /*mm0={-2}x4*/ - pcmpeqw mm0,mm0 - paddw mm0,mm0 - /*Round the results.*/ - psubw mm1,mm0 - psubw mm2,mm0 - psraw mm1,2 - psubw mm3,mm0 - movq [0x58+Y],mm1 - psraw mm2,2 - psubw mm4,mm0 - movq mm1,[0x48+Y] - psraw mm3,2 - psubw mm5,mm0 - movq [0x68+Y],mm2 - psraw mm4,2 - psubw mm6,mm0 - movq [0x78+Y],mm3 - psraw mm5,2 - psubw mm7,mm0 - movq [0x40+Y],mm4 - psraw mm6,2 - psubw mm1,mm0 - movq [0x50+Y],mm5 - psraw mm7,2 - movq [0x60+Y],mm6 - psraw mm1,2 - movq [0x70+Y],mm7 - movq [0x48+Y],mm1 -#undef Y -#undef A -#undef X - } -} - -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/mmxfrag.c b/Engine/lib/libtheora/lib/x86_vc/mmxfrag.c deleted file mode 100644 index 4eb2084dc..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/mmxfrag.c +++ /dev/null @@ -1,337 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: mmxfrag.c 16578 2009-09-25 19:50:48Z cristianadam $ - - ********************************************************************/ - -/*MMX acceleration of fragment reconstruction for motion compensation. - Originally written by Rudolf Marek. - Additional optimization by Nils Pipenbrinck. - Note: Loops are unrolled for best performance. - The iteration each instruction belongs to is marked in the comments as #i.*/ -#include -#include "x86int.h" -#include "mmxfrag.h" - -#if defined(OC_X86_ASM) - -/*Copies an 8x8 block of pixels from _src to _dst, assuming _ystride bytes - between rows.*/ -void oc_frag_copy_mmx(unsigned char *_dst, - const unsigned char *_src,int _ystride){ -#define SRC edx -#define DST eax -#define YSTRIDE ecx -#define YSTRIDE3 esi - OC_FRAG_COPY_MMX(_dst,_src,_ystride); -#undef SRC -#undef DST -#undef YSTRIDE -#undef YSTRIDE3 -} - -void oc_frag_recon_intra_mmx(unsigned char *_dst,int _ystride, - const ogg_int16_t *_residue){ - __asm{ -#define DST edx -#define DST4 esi -#define YSTRIDE eax -#define YSTRIDE3 edi -#define RESIDUE ecx - mov DST,_dst - mov YSTRIDE,_ystride - mov RESIDUE,_residue - lea DST4,[DST+YSTRIDE*4] - lea YSTRIDE3,[YSTRIDE+YSTRIDE*2] - /*Set mm0 to 0xFFFFFFFFFFFFFFFF.*/ - pcmpeqw mm0,mm0 - /*#0 Load low residue.*/ - movq mm1,[0*8+RESIDUE] - /*#0 Load high residue.*/ - movq mm2,[1*8+RESIDUE] - /*Set mm0 to 0x8000800080008000.*/ - psllw mm0,15 - /*#1 Load low residue.*/ - movq mm3,[2*8+RESIDUE] - /*#1 Load high residue.*/ - movq mm4,[3*8+RESIDUE] - /*Set mm0 to 0x0080008000800080.*/ - psrlw mm0,8 - /*#2 Load low residue.*/ - movq mm5,[4*8+RESIDUE] - /*#2 Load high residue.*/ - movq mm6,[5*8+RESIDUE] - /*#0 Bias low residue.*/ - paddsw mm1,mm0 - /*#0 Bias high residue.*/ - paddsw mm2,mm0 - /*#0 Pack to byte.*/ - packuswb mm1,mm2 - /*#1 Bias low residue.*/ - paddsw mm3,mm0 - /*#1 Bias high residue.*/ - paddsw mm4,mm0 - /*#1 Pack to byte.*/ - packuswb mm3,mm4 - /*#2 Bias low residue.*/ - paddsw mm5,mm0 - /*#2 Bias high residue.*/ - paddsw mm6,mm0 - /*#2 Pack to byte.*/ - packuswb mm5,mm6 - /*#0 Write row.*/ - movq [DST],mm1 - /*#1 Write row.*/ - movq [DST+YSTRIDE],mm3 - /*#2 Write row.*/ - movq [DST+YSTRIDE*2],mm5 - /*#3 Load low residue.*/ - movq mm1,[6*8+RESIDUE] - /*#3 Load high residue.*/ - movq mm2,[7*8+RESIDUE] - /*#4 Load high residue.*/ - movq mm3,[8*8+RESIDUE] - /*#4 Load high residue.*/ - movq mm4,[9*8+RESIDUE] - /*#5 Load high residue.*/ - movq mm5,[10*8+RESIDUE] - /*#5 Load high residue.*/ - movq mm6,[11*8+RESIDUE] - /*#3 Bias low residue.*/ - paddsw mm1,mm0 - /*#3 Bias high residue.*/ - paddsw mm2,mm0 - /*#3 Pack to byte.*/ - packuswb mm1,mm2 - /*#4 Bias low residue.*/ - paddsw mm3,mm0 - /*#4 Bias high residue.*/ - paddsw mm4,mm0 - /*#4 Pack to byte.*/ - packuswb mm3,mm4 - /*#5 Bias low residue.*/ - paddsw mm5,mm0 - /*#5 Bias high residue.*/ - paddsw mm6,mm0 - /*#5 Pack to byte.*/ - packuswb mm5,mm6 - /*#3 Write row.*/ - movq [DST+YSTRIDE3],mm1 - /*#4 Write row.*/ - movq [DST4],mm3 - /*#5 Write row.*/ - movq [DST4+YSTRIDE],mm5 - /*#6 Load low residue.*/ - movq mm1,[12*8+RESIDUE] - /*#6 Load high residue.*/ - movq mm2,[13*8+RESIDUE] - /*#7 Load low residue.*/ - movq mm3,[14*8+RESIDUE] - /*#7 Load high residue.*/ - movq mm4,[15*8+RESIDUE] - /*#6 Bias low residue.*/ - paddsw mm1,mm0 - /*#6 Bias high residue.*/ - paddsw mm2,mm0 - /*#6 Pack to byte.*/ - packuswb mm1,mm2 - /*#7 Bias low residue.*/ - paddsw mm3,mm0 - /*#7 Bias high residue.*/ - paddsw mm4,mm0 - /*#7 Pack to byte.*/ - packuswb mm3,mm4 - /*#6 Write row.*/ - movq [DST4+YSTRIDE*2],mm1 - /*#7 Write row.*/ - movq [DST4+YSTRIDE3],mm3 -#undef DST -#undef DST4 -#undef YSTRIDE -#undef YSTRIDE3 -#undef RESIDUE - } -} - -void oc_frag_recon_inter_mmx(unsigned char *_dst,const unsigned char *_src, - int _ystride,const ogg_int16_t *_residue){ - int i; - /*Zero mm0.*/ - __asm pxor mm0,mm0; - for(i=4;i-->0;){ - __asm{ -#define DST edx -#define SRC ecx -#define YSTRIDE edi -#define RESIDUE eax - mov DST,_dst - mov SRC,_src - mov YSTRIDE,_ystride - mov RESIDUE,_residue - /*#0 Load source.*/ - movq mm3,[SRC] - /*#1 Load source.*/ - movq mm7,[SRC+YSTRIDE] - /*#0 Get copy of src.*/ - movq mm4,mm3 - /*#0 Expand high source.*/ - punpckhbw mm4,mm0 - /*#0 Expand low source.*/ - punpcklbw mm3,mm0 - /*#0 Add residue high.*/ - paddsw mm4,[8+RESIDUE] - /*#1 Get copy of src.*/ - movq mm2,mm7 - /*#0 Add residue low.*/ - paddsw mm3,[RESIDUE] - /*#1 Expand high source.*/ - punpckhbw mm2,mm0 - /*#0 Pack final row pixels.*/ - packuswb mm3,mm4 - /*#1 Expand low source.*/ - punpcklbw mm7,mm0 - /*#1 Add residue low.*/ - paddsw mm7,[16+RESIDUE] - /*#1 Add residue high.*/ - paddsw mm2,[24+RESIDUE] - /*Advance residue.*/ - lea RESIDUE,[32+RESIDUE] - /*#1 Pack final row pixels.*/ - packuswb mm7,mm2 - /*Advance src.*/ - lea SRC,[SRC+YSTRIDE*2] - /*#0 Write row.*/ - movq [DST],mm3 - /*#1 Write row.*/ - movq [DST+YSTRIDE],mm7 - /*Advance dst.*/ - lea DST,[DST+YSTRIDE*2] - mov _residue,RESIDUE - mov _dst,DST - mov _src,SRC -#undef DST -#undef SRC -#undef YSTRIDE -#undef RESIDUE - } - } -} - -void oc_frag_recon_inter2_mmx(unsigned char *_dst,const unsigned char *_src1, - const unsigned char *_src2,int _ystride,const ogg_int16_t *_residue){ - int i; - /*Zero mm7.*/ - __asm pxor mm7,mm7; - for(i=4;i-->0;){ - __asm{ -#define SRC1 ecx -#define SRC2 edi -#define YSTRIDE esi -#define RESIDUE edx -#define DST eax - mov YSTRIDE,_ystride - mov DST,_dst - mov RESIDUE,_residue - mov SRC1,_src1 - mov SRC2,_src2 - /*#0 Load src1.*/ - movq mm0,[SRC1] - /*#0 Load src2.*/ - movq mm2,[SRC2] - /*#0 Copy src1.*/ - movq mm1,mm0 - /*#0 Copy src2.*/ - movq mm3,mm2 - /*#1 Load src1.*/ - movq mm4,[SRC1+YSTRIDE] - /*#0 Unpack lower src1.*/ - punpcklbw mm0,mm7 - /*#1 Load src2.*/ - movq mm5,[SRC2+YSTRIDE] - /*#0 Unpack higher src1.*/ - punpckhbw mm1,mm7 - /*#0 Unpack lower src2.*/ - punpcklbw mm2,mm7 - /*#0 Unpack higher src2.*/ - punpckhbw mm3,mm7 - /*Advance src1 ptr.*/ - lea SRC1,[SRC1+YSTRIDE*2] - /*Advance src2 ptr.*/ - lea SRC2,[SRC2+YSTRIDE*2] - /*#0 Lower src1+src2.*/ - paddsw mm0,mm2 - /*#0 Higher src1+src2.*/ - paddsw mm1,mm3 - /*#1 Copy src1.*/ - movq mm2,mm4 - /*#0 Build lo average.*/ - psraw mm0,1 - /*#1 Copy src2.*/ - movq mm3,mm5 - /*#1 Unpack lower src1.*/ - punpcklbw mm4,mm7 - /*#0 Build hi average.*/ - psraw mm1,1 - /*#1 Unpack higher src1.*/ - punpckhbw mm2,mm7 - /*#0 low+=residue.*/ - paddsw mm0,[RESIDUE] - /*#1 Unpack lower src2.*/ - punpcklbw mm5,mm7 - /*#0 high+=residue.*/ - paddsw mm1,[8+RESIDUE] - /*#1 Unpack higher src2.*/ - punpckhbw mm3,mm7 - /*#1 Lower src1+src2.*/ - paddsw mm5,mm4 - /*#0 Pack and saturate.*/ - packuswb mm0,mm1 - /*#1 Higher src1+src2.*/ - paddsw mm3,mm2 - /*#0 Write row.*/ - movq [DST],mm0 - /*#1 Build lo average.*/ - psraw mm5,1 - /*#1 Build hi average.*/ - psraw mm3,1 - /*#1 low+=residue.*/ - paddsw mm5,[16+RESIDUE] - /*#1 high+=residue.*/ - paddsw mm3,[24+RESIDUE] - /*#1 Pack and saturate.*/ - packuswb mm5,mm3 - /*#1 Write row ptr.*/ - movq [DST+YSTRIDE],mm5 - /*Advance residue ptr.*/ - add RESIDUE,32 - /*Advance dest ptr.*/ - lea DST,[DST+YSTRIDE*2] - mov _dst,DST - mov _residue,RESIDUE - mov _src1,SRC1 - mov _src2,SRC2 -#undef SRC1 -#undef SRC2 -#undef YSTRIDE -#undef RESIDUE -#undef DST - } - } -} - -void oc_restore_fpu_mmx(void){ - __asm emms; -} - -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/mmxfrag.h b/Engine/lib/libtheora/lib/x86_vc/mmxfrag.h deleted file mode 100644 index 45ee93e77..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/mmxfrag.h +++ /dev/null @@ -1,61 +0,0 @@ -#if !defined(_x86_vc_mmxfrag_H) -# define _x86_vc_mmxfrag_H (1) -# include -# include "x86int.h" - -#if defined(OC_X86_ASM) - -/*Copies an 8x8 block of pixels from _src to _dst, assuming _ystride bytes - between rows.*/ -#define OC_FRAG_COPY_MMX(_dst,_src,_ystride) \ - do{ \ - const unsigned char *src; \ - unsigned char *dst; \ - src=(_src); \ - dst=(_dst); \ - __asm mov SRC,src \ - __asm mov DST,dst \ - __asm mov YSTRIDE,_ystride \ - /*src+0*ystride*/ \ - __asm movq mm0,[SRC] \ - /*src+1*ystride*/ \ - __asm movq mm1,[SRC+YSTRIDE] \ - /*ystride3=ystride*3*/ \ - __asm lea YSTRIDE3,[YSTRIDE+YSTRIDE*2] \ - /*src+2*ystride*/ \ - __asm movq mm2,[SRC+YSTRIDE*2] \ - /*src+3*ystride*/ \ - __asm movq mm3,[SRC+YSTRIDE3] \ - /*dst+0*ystride*/ \ - __asm movq [DST],mm0 \ - /*dst+1*ystride*/ \ - __asm movq [DST+YSTRIDE],mm1 \ - /*Pointer to next 4.*/ \ - __asm lea SRC,[SRC+YSTRIDE*4] \ - /*dst+2*ystride*/ \ - __asm movq [DST+YSTRIDE*2],mm2 \ - /*dst+3*ystride*/ \ - __asm movq [DST+YSTRIDE3],mm3 \ - /*Pointer to next 4.*/ \ - __asm lea DST,[DST+YSTRIDE*4] \ - /*src+0*ystride*/ \ - __asm movq mm0,[SRC] \ - /*src+1*ystride*/ \ - __asm movq mm1,[SRC+YSTRIDE] \ - /*src+2*ystride*/ \ - __asm movq mm2,[SRC+YSTRIDE*2] \ - /*src+3*ystride*/ \ - __asm movq mm3,[SRC+YSTRIDE3] \ - /*dst+0*ystride*/ \ - __asm movq [DST],mm0 \ - /*dst+1*ystride*/ \ - __asm movq [DST+YSTRIDE],mm1 \ - /*dst+2*ystride*/ \ - __asm movq [DST+YSTRIDE*2],mm2 \ - /*dst+3*ystride*/ \ - __asm movq [DST+YSTRIDE3],mm3 \ - } \ - while(0) - -# endif -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/mmxidct.c b/Engine/lib/libtheora/lib/x86_vc/mmxidct.c deleted file mode 100644 index 8f5ff6803..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/mmxidct.c +++ /dev/null @@ -1,562 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: mmxidct.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -/*MMX acceleration of Theora's iDCT. - Originally written by Rudolf Marek, based on code from On2's VP3.*/ -#include "x86int.h" -#include "../dct.h" - -#if defined(OC_X86_ASM) - -/*These are offsets into the table of constants below.*/ -/*7 rows of cosines, in order: pi/16 * (1 ... 7).*/ -#define OC_COSINE_OFFSET (0) -/*A row of 8's.*/ -#define OC_EIGHT_OFFSET (56) - - - -/*A table of constants used by the MMX routines.*/ -static const __declspec(align(16))ogg_uint16_t - OC_IDCT_CONSTS[(7+1)*4]={ - (ogg_uint16_t)OC_C1S7,(ogg_uint16_t)OC_C1S7, - (ogg_uint16_t)OC_C1S7,(ogg_uint16_t)OC_C1S7, - (ogg_uint16_t)OC_C2S6,(ogg_uint16_t)OC_C2S6, - (ogg_uint16_t)OC_C2S6,(ogg_uint16_t)OC_C2S6, - (ogg_uint16_t)OC_C3S5,(ogg_uint16_t)OC_C3S5, - (ogg_uint16_t)OC_C3S5,(ogg_uint16_t)OC_C3S5, - (ogg_uint16_t)OC_C4S4,(ogg_uint16_t)OC_C4S4, - (ogg_uint16_t)OC_C4S4,(ogg_uint16_t)OC_C4S4, - (ogg_uint16_t)OC_C5S3,(ogg_uint16_t)OC_C5S3, - (ogg_uint16_t)OC_C5S3,(ogg_uint16_t)OC_C5S3, - (ogg_uint16_t)OC_C6S2,(ogg_uint16_t)OC_C6S2, - (ogg_uint16_t)OC_C6S2,(ogg_uint16_t)OC_C6S2, - (ogg_uint16_t)OC_C7S1,(ogg_uint16_t)OC_C7S1, - (ogg_uint16_t)OC_C7S1,(ogg_uint16_t)OC_C7S1, - 8, 8, 8, 8 -}; - -/*38 cycles*/ -#define OC_IDCT_BEGIN __asm{ \ - __asm movq mm2,OC_I(3) \ - __asm movq mm6,OC_C(3) \ - __asm movq mm4,mm2 \ - __asm movq mm7,OC_J(5) \ - __asm pmulhw mm4,mm6 \ - __asm movq mm1,OC_C(5) \ - __asm pmulhw mm6,mm7 \ - __asm movq mm5,mm1 \ - __asm pmulhw mm1,mm2 \ - __asm movq mm3,OC_I(1) \ - __asm pmulhw mm5,mm7 \ - __asm movq mm0,OC_C(1) \ - __asm paddw mm4,mm2 \ - __asm paddw mm6,mm7 \ - __asm paddw mm2,mm1 \ - __asm movq mm1,OC_J(7) \ - __asm paddw mm7,mm5 \ - __asm movq mm5,mm0 \ - __asm pmulhw mm0,mm3 \ - __asm paddw mm4,mm7 \ - __asm pmulhw mm5,mm1 \ - __asm movq mm7,OC_C(7) \ - __asm psubw mm6,mm2 \ - __asm paddw mm0,mm3 \ - __asm pmulhw mm3,mm7 \ - __asm movq mm2,OC_I(2) \ - __asm pmulhw mm7,mm1 \ - __asm paddw mm5,mm1 \ - __asm movq mm1,mm2 \ - __asm pmulhw mm2,OC_C(2) \ - __asm psubw mm3,mm5 \ - __asm movq mm5,OC_J(6) \ - __asm paddw mm0,mm7 \ - __asm movq mm7,mm5 \ - __asm psubw mm0,mm4 \ - __asm pmulhw mm5,OC_C(2) \ - __asm paddw mm2,mm1 \ - __asm pmulhw mm1,OC_C(6) \ - __asm paddw mm4,mm4 \ - __asm paddw mm4,mm0 \ - __asm psubw mm3,mm6 \ - __asm paddw mm5,mm7 \ - __asm paddw mm6,mm6 \ - __asm pmulhw mm7,OC_C(6) \ - __asm paddw mm6,mm3 \ - __asm movq OC_I(1),mm4 \ - __asm psubw mm1,mm5 \ - __asm movq mm4,OC_C(4) \ - __asm movq mm5,mm3 \ - __asm pmulhw mm3,mm4 \ - __asm paddw mm7,mm2 \ - __asm movq OC_I(2),mm6 \ - __asm movq mm2,mm0 \ - __asm movq mm6,OC_I(0) \ - __asm pmulhw mm0,mm4 \ - __asm paddw mm5,mm3 \ - __asm movq mm3,OC_J(4) \ - __asm psubw mm5,mm1 \ - __asm paddw mm2,mm0 \ - __asm psubw mm6,mm3 \ - __asm movq mm0,mm6 \ - __asm pmulhw mm6,mm4 \ - __asm paddw mm3,mm3 \ - __asm paddw mm1,mm1 \ - __asm paddw mm3,mm0 \ - __asm paddw mm1,mm5 \ - __asm pmulhw mm4,mm3 \ - __asm paddw mm6,mm0 \ - __asm psubw mm6,mm2 \ - __asm paddw mm2,mm2 \ - __asm movq mm0,OC_I(1) \ - __asm paddw mm2,mm6 \ - __asm paddw mm4,mm3 \ - __asm psubw mm2,mm1 \ -} - -/*38+8=46 cycles.*/ -#define OC_ROW_IDCT __asm{ \ - OC_IDCT_BEGIN \ - /*r3=D'*/ \ - __asm movq mm3,OC_I(2) \ - /*r4=E'=E-G*/ \ - __asm psubw mm4,mm7 \ - /*r1=H'+H'*/ \ - __asm paddw mm1,mm1 \ - /*r7=G+G*/ \ - __asm paddw mm7,mm7 \ - /*r1=R1=A''+H'*/ \ - __asm paddw mm1,mm2 \ - /*r7=G'=E+G*/ \ - __asm paddw mm7,mm4 \ - /*r4=R4=E'-D'*/ \ - __asm psubw mm4,mm3 \ - __asm paddw mm3,mm3 \ - /*r6=R6=F'-B''*/ \ - __asm psubw mm6,mm5 \ - __asm paddw mm5,mm5 \ - /*r3=R3=E'+D'*/ \ - __asm paddw mm3,mm4 \ - /*r5=R5=F'+B''*/ \ - __asm paddw mm5,mm6 \ - /*r7=R7=G'-C'*/ \ - __asm psubw mm7,mm0 \ - __asm paddw mm0,mm0 \ - /*Save R1.*/ \ - __asm movq OC_I(1),mm1 \ - /*r0=R0=G.+C.*/ \ - __asm paddw mm0,mm7 \ -} - -/*The following macro does two 4x4 transposes in place. - At entry, we assume: - r0 = a3 a2 a1 a0 - I(1) = b3 b2 b1 b0 - r2 = c3 c2 c1 c0 - r3 = d3 d2 d1 d0 - - r4 = e3 e2 e1 e0 - r5 = f3 f2 f1 f0 - r6 = g3 g2 g1 g0 - r7 = h3 h2 h1 h0 - - At exit, we have: - I(0) = d0 c0 b0 a0 - I(1) = d1 c1 b1 a1 - I(2) = d2 c2 b2 a2 - I(3) = d3 c3 b3 a3 - - J(4) = h0 g0 f0 e0 - J(5) = h1 g1 f1 e1 - J(6) = h2 g2 f2 e2 - J(7) = h3 g3 f3 e3 - - I(0) I(1) I(2) I(3) is the transpose of r0 I(1) r2 r3. - J(4) J(5) J(6) J(7) is the transpose of r4 r5 r6 r7. - - Since r1 is free at entry, we calculate the Js first.*/ -/*19 cycles.*/ -#define OC_TRANSPOSE __asm{ \ - __asm movq mm1,mm4 \ - __asm punpcklwd mm4,mm5 \ - __asm movq OC_I(0),mm0 \ - __asm punpckhwd mm1,mm5 \ - __asm movq mm0,mm6 \ - __asm punpcklwd mm6,mm7 \ - __asm movq mm5,mm4 \ - __asm punpckldq mm4,mm6 \ - __asm punpckhdq mm5,mm6 \ - __asm movq mm6,mm1 \ - __asm movq OC_J(4),mm4 \ - __asm punpckhwd mm0,mm7 \ - __asm movq OC_J(5),mm5 \ - __asm punpckhdq mm6,mm0 \ - __asm movq mm4,OC_I(0) \ - __asm punpckldq mm1,mm0 \ - __asm movq mm5,OC_I(1) \ - __asm movq mm0,mm4 \ - __asm movq OC_J(7),mm6 \ - __asm punpcklwd mm0,mm5 \ - __asm movq OC_J(6),mm1 \ - __asm punpckhwd mm4,mm5 \ - __asm movq mm5,mm2 \ - __asm punpcklwd mm2,mm3 \ - __asm movq mm1,mm0 \ - __asm punpckldq mm0,mm2 \ - __asm punpckhdq mm1,mm2 \ - __asm movq mm2,mm4 \ - __asm movq OC_I(0),mm0 \ - __asm punpckhwd mm5,mm3 \ - __asm movq OC_I(1),mm1 \ - __asm punpckhdq mm4,mm5 \ - __asm punpckldq mm2,mm5 \ - __asm movq OC_I(3),mm4 \ - __asm movq OC_I(2),mm2 \ -} - -/*38+19=57 cycles.*/ -#define OC_COLUMN_IDCT __asm{ \ - OC_IDCT_BEGIN \ - __asm paddw mm2,OC_8 \ - /*r1=H'+H'*/ \ - __asm paddw mm1,mm1 \ - /*r1=R1=A''+H'*/ \ - __asm paddw mm1,mm2 \ - /*r2=NR2*/ \ - __asm psraw mm2,4 \ - /*r4=E'=E-G*/ \ - __asm psubw mm4,mm7 \ - /*r1=NR1*/ \ - __asm psraw mm1,4 \ - /*r3=D'*/ \ - __asm movq mm3,OC_I(2) \ - /*r7=G+G*/ \ - __asm paddw mm7,mm7 \ - /*Store NR2 at I(2).*/ \ - __asm movq OC_I(2),mm2 \ - /*r7=G'=E+G*/ \ - __asm paddw mm7,mm4 \ - /*Store NR1 at I(1).*/ \ - __asm movq OC_I(1),mm1 \ - /*r4=R4=E'-D'*/ \ - __asm psubw mm4,mm3 \ - __asm paddw mm4,OC_8 \ - /*r3=D'+D'*/ \ - __asm paddw mm3,mm3 \ - /*r3=R3=E'+D'*/ \ - __asm paddw mm3,mm4 \ - /*r4=NR4*/ \ - __asm psraw mm4,4 \ - /*r6=R6=F'-B''*/ \ - __asm psubw mm6,mm5 \ - /*r3=NR3*/ \ - __asm psraw mm3,4 \ - __asm paddw mm6,OC_8 \ - /*r5=B''+B''*/ \ - __asm paddw mm5,mm5 \ - /*r5=R5=F'+B''*/ \ - __asm paddw mm5,mm6 \ - /*r6=NR6*/ \ - __asm psraw mm6,4 \ - /*Store NR4 at J(4).*/ \ - __asm movq OC_J(4),mm4 \ - /*r5=NR5*/ \ - __asm psraw mm5,4 \ - /*Store NR3 at I(3).*/ \ - __asm movq OC_I(3),mm3 \ - /*r7=R7=G'-C'*/ \ - __asm psubw mm7,mm0 \ - __asm paddw mm7,OC_8 \ - /*r0=C'+C'*/ \ - __asm paddw mm0,mm0 \ - /*r0=R0=G'+C'*/ \ - __asm paddw mm0,mm7 \ - /*r7=NR7*/ \ - __asm psraw mm7,4 \ - /*Store NR6 at J(6).*/ \ - __asm movq OC_J(6),mm6 \ - /*r0=NR0*/ \ - __asm psraw mm0,4 \ - /*Store NR5 at J(5).*/ \ - __asm movq OC_J(5),mm5 \ - /*Store NR7 at J(7).*/ \ - __asm movq OC_J(7),mm7 \ - /*Store NR0 at I(0).*/ \ - __asm movq OC_I(0),mm0 \ -} - -#define OC_MID(_m,_i) [CONSTS+_m+(_i)*8] -#define OC_C(_i) OC_MID(OC_COSINE_OFFSET,_i-1) -#define OC_8 OC_MID(OC_EIGHT_OFFSET,0) - -static void oc_idct8x8_slow(ogg_int16_t _y[64]){ - /*This routine accepts an 8x8 matrix, but in partially transposed form. - Every 4x4 block is transposed.*/ - __asm{ -#define CONSTS eax -#define Y edx - mov CONSTS,offset OC_IDCT_CONSTS - mov Y,_y -#define OC_I(_k) [Y+_k*16] -#define OC_J(_k) [Y+(_k-4)*16+8] - OC_ROW_IDCT - OC_TRANSPOSE -#undef OC_I -#undef OC_J -#define OC_I(_k) [Y+(_k*16)+64] -#define OC_J(_k) [Y+(_k-4)*16+72] - OC_ROW_IDCT - OC_TRANSPOSE -#undef OC_I -#undef OC_J -#define OC_I(_k) [Y+_k*16] -#define OC_J(_k) OC_I(_k) - OC_COLUMN_IDCT -#undef OC_I -#undef OC_J -#define OC_I(_k) [Y+_k*16+8] -#define OC_J(_k) OC_I(_k) - OC_COLUMN_IDCT -#undef OC_I -#undef OC_J -#undef CONSTS -#undef Y - } -} - -/*25 cycles.*/ -#define OC_IDCT_BEGIN_10 __asm{ \ - __asm movq mm2,OC_I(3) \ - __asm nop \ - __asm movq mm6,OC_C(3) \ - __asm movq mm4,mm2 \ - __asm movq mm1,OC_C(5) \ - __asm pmulhw mm4,mm6 \ - __asm movq mm3,OC_I(1) \ - __asm pmulhw mm1,mm2 \ - __asm movq mm0,OC_C(1) \ - __asm paddw mm4,mm2 \ - __asm pxor mm6,mm6 \ - __asm paddw mm2,mm1 \ - __asm movq mm5,OC_I(2) \ - __asm pmulhw mm0,mm3 \ - __asm movq mm1,mm5 \ - __asm paddw mm0,mm3 \ - __asm pmulhw mm3,OC_C(7) \ - __asm psubw mm6,mm2 \ - __asm pmulhw mm5,OC_C(2) \ - __asm psubw mm0,mm4 \ - __asm movq mm7,OC_I(2) \ - __asm paddw mm4,mm4 \ - __asm paddw mm7,mm5 \ - __asm paddw mm4,mm0 \ - __asm pmulhw mm1,OC_C(6) \ - __asm psubw mm3,mm6 \ - __asm movq OC_I(1),mm4 \ - __asm paddw mm6,mm6 \ - __asm movq mm4,OC_C(4) \ - __asm paddw mm6,mm3 \ - __asm movq mm5,mm3 \ - __asm pmulhw mm3,mm4 \ - __asm movq OC_I(2),mm6 \ - __asm movq mm2,mm0 \ - __asm movq mm6,OC_I(0) \ - __asm pmulhw mm0,mm4 \ - __asm paddw mm5,mm3 \ - __asm paddw mm2,mm0 \ - __asm psubw mm5,mm1 \ - __asm pmulhw mm6,mm4 \ - __asm paddw mm6,OC_I(0) \ - __asm paddw mm1,mm1 \ - __asm movq mm4,mm6 \ - __asm paddw mm1,mm5 \ - __asm psubw mm6,mm2 \ - __asm paddw mm2,mm2 \ - __asm movq mm0,OC_I(1) \ - __asm paddw mm2,mm6 \ - __asm psubw mm2,mm1 \ - __asm nop \ -} - -/*25+8=33 cycles.*/ -#define OC_ROW_IDCT_10 __asm{ \ - OC_IDCT_BEGIN_10 \ - /*r3=D'*/ \ - __asm movq mm3,OC_I(2) \ - /*r4=E'=E-G*/ \ - __asm psubw mm4,mm7 \ - /*r1=H'+H'*/ \ - __asm paddw mm1,mm1 \ - /*r7=G+G*/ \ - __asm paddw mm7,mm7 \ - /*r1=R1=A''+H'*/ \ - __asm paddw mm1,mm2 \ - /*r7=G'=E+G*/ \ - __asm paddw mm7,mm4 \ - /*r4=R4=E'-D'*/ \ - __asm psubw mm4,mm3 \ - __asm paddw mm3,mm3 \ - /*r6=R6=F'-B''*/ \ - __asm psubw mm6,mm5 \ - __asm paddw mm5,mm5 \ - /*r3=R3=E'+D'*/ \ - __asm paddw mm3,mm4 \ - /*r5=R5=F'+B''*/ \ - __asm paddw mm5,mm6 \ - /*r7=R7=G'-C'*/ \ - __asm psubw mm7,mm0 \ - __asm paddw mm0,mm0 \ - /*Save R1.*/ \ - __asm movq OC_I(1),mm1 \ - /*r0=R0=G'+C'*/ \ - __asm paddw mm0,mm7 \ -} - -/*25+19=44 cycles'*/ -#define OC_COLUMN_IDCT_10 __asm{ \ - OC_IDCT_BEGIN_10 \ - __asm paddw mm2,OC_8 \ - /*r1=H'+H'*/ \ - __asm paddw mm1,mm1 \ - /*r1=R1=A''+H'*/ \ - __asm paddw mm1,mm2 \ - /*r2=NR2*/ \ - __asm psraw mm2,4 \ - /*r4=E'=E-G*/ \ - __asm psubw mm4,mm7 \ - /*r1=NR1*/ \ - __asm psraw mm1,4 \ - /*r3=D'*/ \ - __asm movq mm3,OC_I(2) \ - /*r7=G+G*/ \ - __asm paddw mm7,mm7 \ - /*Store NR2 at I(2).*/ \ - __asm movq OC_I(2),mm2 \ - /*r7=G'=E+G*/ \ - __asm paddw mm7,mm4 \ - /*Store NR1 at I(1).*/ \ - __asm movq OC_I(1),mm1 \ - /*r4=R4=E'-D'*/ \ - __asm psubw mm4,mm3 \ - __asm paddw mm4,OC_8 \ - /*r3=D'+D'*/ \ - __asm paddw mm3,mm3 \ - /*r3=R3=E'+D'*/ \ - __asm paddw mm3,mm4 \ - /*r4=NR4*/ \ - __asm psraw mm4,4 \ - /*r6=R6=F'-B''*/ \ - __asm psubw mm6,mm5 \ - /*r3=NR3*/ \ - __asm psraw mm3,4 \ - __asm paddw mm6,OC_8 \ - /*r5=B''+B''*/ \ - __asm paddw mm5,mm5 \ - /*r5=R5=F'+B''*/ \ - __asm paddw mm5,mm6 \ - /*r6=NR6*/ \ - __asm psraw mm6,4 \ - /*Store NR4 at J(4).*/ \ - __asm movq OC_J(4),mm4 \ - /*r5=NR5*/ \ - __asm psraw mm5,4 \ - /*Store NR3 at I(3).*/ \ - __asm movq OC_I(3),mm3 \ - /*r7=R7=G'-C'*/ \ - __asm psubw mm7,mm0 \ - __asm paddw mm7,OC_8 \ - /*r0=C'+C'*/ \ - __asm paddw mm0,mm0 \ - /*r0=R0=G'+C'*/ \ - __asm paddw mm0,mm7 \ - /*r7=NR7*/ \ - __asm psraw mm7,4 \ - /*Store NR6 at J(6).*/ \ - __asm movq OC_J(6),mm6 \ - /*r0=NR0*/ \ - __asm psraw mm0,4 \ - /*Store NR5 at J(5).*/ \ - __asm movq OC_J(5),mm5 \ - /*Store NR7 at J(7).*/ \ - __asm movq OC_J(7),mm7 \ - /*Store NR0 at I(0).*/ \ - __asm movq OC_I(0),mm0 \ -} - -static void oc_idct8x8_10(ogg_int16_t _y[64]){ - __asm{ -#define CONSTS eax -#define Y edx - mov CONSTS,offset OC_IDCT_CONSTS - mov Y,_y -#define OC_I(_k) [Y+_k*16] -#define OC_J(_k) [Y+(_k-4)*16+8] - /*Done with dequant, descramble, and partial transpose. - Now do the iDCT itself.*/ - OC_ROW_IDCT_10 - OC_TRANSPOSE -#undef OC_I -#undef OC_J -#define OC_I(_k) [Y+_k*16] -#define OC_J(_k) OC_I(_k) - OC_COLUMN_IDCT_10 -#undef OC_I -#undef OC_J -#define OC_I(_k) [Y+_k*16+8] -#define OC_J(_k) OC_I(_k) - OC_COLUMN_IDCT_10 -#undef OC_I -#undef OC_J -#undef CONSTS -#undef Y - } -} - -/*Performs an inverse 8x8 Type-II DCT transform. - The input is assumed to be scaled by a factor of 4 relative to orthonormal - version of the transform.*/ -void oc_idct8x8_mmx(ogg_int16_t _y[64],int _last_zzi){ - /*_last_zzi is subtly different from an actual count of the number of - coefficients we decoded for this block. - It contains the value of zzi BEFORE the final token in the block was - decoded. - In most cases this is an EOB token (the continuation of an EOB run from a - previous block counts), and so this is the same as the coefficient count. - However, in the case that the last token was NOT an EOB token, but filled - the block up with exactly 64 coefficients, _last_zzi will be less than 64. - Provided the last token was not a pure zero run, the minimum value it can - be is 46, and so that doesn't affect any of the cases in this routine. - However, if the last token WAS a pure zero run of length 63, then _last_zzi - will be 1 while the number of coefficients decoded is 64. - Thus, we will trigger the following special case, where the real - coefficient count would not. - Note also that a zero run of length 64 will give _last_zzi a value of 0, - but we still process the DC coefficient, which might have a non-zero value - due to DC prediction. - Although convoluted, this is arguably the correct behavior: it allows us to - use a smaller transform when the block ends with a long zero run instead - of a normal EOB token. - It could be smarter... multiple separate zero runs at the end of a block - will fool it, but an encoder that generates these really deserves what it - gets. - Needless to say we inherited this approach from VP3.*/ - /*Perform the iDCT.*/ - if(_last_zzi<10)oc_idct8x8_10(_y); - else oc_idct8x8_slow(_y); -} - -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/mmxloop.h b/Engine/lib/libtheora/lib/x86_vc/mmxloop.h deleted file mode 100644 index 2561fca2a..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/mmxloop.h +++ /dev/null @@ -1,219 +0,0 @@ -#if !defined(_x86_vc_mmxloop_H) -# define _x86_vc_mmxloop_H (1) -# include -# include "x86int.h" - -#if defined(OC_X86_ASM) - -/*On entry, mm0={a0,...,a7}, mm1={b0,...,b7}, mm2={c0,...,c7}, mm3={d0,...d7}. - On exit, mm1={b0+lflim(R_0,L),...,b7+lflim(R_7,L)} and - mm2={c0-lflim(R_0,L),...,c7-lflim(R_7,L)}; mm0 and mm3 are clobbered.*/ -#define OC_LOOP_FILTER8_MMX __asm{ \ - /*mm7=0*/ \ - __asm pxor mm7,mm7 \ - /*mm6:mm0={a0,...,a7}*/ \ - __asm movq mm6,mm0 \ - __asm punpcklbw mm0,mm7 \ - __asm punpckhbw mm6,mm7 \ - /*mm3:mm5={d0,...,d7}*/ \ - __asm movq mm5,mm3 \ - __asm punpcklbw mm3,mm7 \ - __asm punpckhbw mm5,mm7 \ - /*mm6:mm0={a0-d0,...,a7-d7}*/ \ - __asm psubw mm0,mm3 \ - __asm psubw mm6,mm5 \ - /*mm3:mm1={b0,...,b7}*/ \ - __asm movq mm3,mm1 \ - __asm punpcklbw mm1,mm7 \ - __asm movq mm4,mm2 \ - __asm punpckhbw mm3,mm7 \ - /*mm5:mm4={c0,...,c7}*/ \ - __asm movq mm5,mm2 \ - __asm punpcklbw mm4,mm7 \ - __asm punpckhbw mm5,mm7 \ - /*mm7={3}x4 \ - mm5:mm4={c0-b0,...,c7-b7}*/ \ - __asm pcmpeqw mm7,mm7 \ - __asm psubw mm4,mm1 \ - __asm psrlw mm7,14 \ - __asm psubw mm5,mm3 \ - /*Scale by 3.*/ \ - __asm pmullw mm4,mm7 \ - __asm pmullw mm5,mm7 \ - /*mm7={4}x4 \ - mm5:mm4=f={a0-d0+3*(c0-b0),...,a7-d7+3*(c7-b7)}*/ \ - __asm psrlw mm7,1 \ - __asm paddw mm4,mm0 \ - __asm psllw mm7,2 \ - __asm movq mm0,[LL] \ - __asm paddw mm5,mm6 \ - /*R_i has the range [-127,128], so we compute -R_i instead. \ - mm4=-R_i=-(f+4>>3)=0xFF^(f-4>>3)*/ \ - __asm psubw mm4,mm7 \ - __asm psubw mm5,mm7 \ - __asm psraw mm4,3 \ - __asm psraw mm5,3 \ - __asm pcmpeqb mm7,mm7 \ - __asm packsswb mm4,mm5 \ - __asm pxor mm6,mm6 \ - __asm pxor mm4,mm7 \ - __asm packuswb mm1,mm3 \ - /*Now compute lflim of -mm4 cf. Section 7.10 of the sepc.*/ \ - /*There's no unsigned byte+signed byte with unsigned saturation op code, so \ - we have to split things by sign (the other option is to work in 16 bits, \ - but working in 8 bits gives much better parallelism). \ - We compute abs(R_i), but save a mask of which terms were negative in mm6. \ - Then we compute mm4=abs(lflim(R_i,L))=min(abs(R_i),max(2*L-abs(R_i),0)). \ - Finally, we split mm4 into positive and negative pieces using the mask in \ - mm6, and add and subtract them as appropriate.*/ \ - /*mm4=abs(-R_i)*/ \ - /*mm7=255-2*L*/ \ - __asm pcmpgtb mm6,mm4 \ - __asm psubb mm7,mm0 \ - __asm pxor mm4,mm6 \ - __asm psubb mm7,mm0 \ - __asm psubb mm4,mm6 \ - /*mm7=255-max(2*L-abs(R_i),0)*/ \ - __asm paddusb mm7,mm4 \ - /*mm4=min(abs(R_i),max(2*L-abs(R_i),0))*/ \ - __asm paddusb mm4,mm7 \ - __asm psubusb mm4,mm7 \ - /*Now split mm4 by the original sign of -R_i.*/ \ - __asm movq mm5,mm4 \ - __asm pand mm4,mm6 \ - __asm pandn mm6,mm5 \ - /*mm1={b0+lflim(R_0,L),...,b7+lflim(R_7,L)}*/ \ - /*mm2={c0-lflim(R_0,L),...,c7-lflim(R_7,L)}*/ \ - __asm paddusb mm1,mm4 \ - __asm psubusb mm2,mm4 \ - __asm psubusb mm1,mm6 \ - __asm paddusb mm2,mm6 \ -} - -#define OC_LOOP_FILTER_V_MMX(_pix,_ystride,_ll) \ - do{ \ - /*Used local variable pix__ in order to fix compilation errors like: \ - "error C2425: 'SHL' : non-constant expression in 'second operand'".*/ \ - unsigned char *pix__; \ - unsigned char *ll__; \ - ll__=(_ll); \ - pix__=(_pix); \ - __asm mov YSTRIDE,_ystride \ - __asm mov LL,ll__ \ - __asm mov PIX,pix__ \ - __asm sub PIX,YSTRIDE \ - __asm sub PIX,YSTRIDE \ - /*mm0={a0,...,a7}*/ \ - __asm movq mm0,[PIX] \ - /*ystride3=_ystride*3*/ \ - __asm lea YSTRIDE3,[YSTRIDE+YSTRIDE*2] \ - /*mm3={d0,...,d7}*/ \ - __asm movq mm3,[PIX+YSTRIDE3] \ - /*mm1={b0,...,b7}*/ \ - __asm movq mm1,[PIX+YSTRIDE] \ - /*mm2={c0,...,c7}*/ \ - __asm movq mm2,[PIX+YSTRIDE*2] \ - OC_LOOP_FILTER8_MMX \ - /*Write it back out.*/ \ - __asm movq [PIX+YSTRIDE],mm1 \ - __asm movq [PIX+YSTRIDE*2],mm2 \ - } \ - while(0) - -#define OC_LOOP_FILTER_H_MMX(_pix,_ystride,_ll) \ - do{ \ - /*Used local variable ll__ in order to fix compilation errors like: \ - "error C2443: operand size conflict".*/ \ - unsigned char *ll__; \ - unsigned char *pix__; \ - ll__=(_ll); \ - pix__=(_pix)-2; \ - __asm mov PIX,pix__ \ - __asm mov YSTRIDE,_ystride \ - __asm mov LL,ll__ \ - /*x x x x d0 c0 b0 a0*/ \ - __asm movd mm0,[PIX] \ - /*x x x x d1 c1 b1 a1*/ \ - __asm movd mm1,[PIX+YSTRIDE] \ - /*ystride3=_ystride*3*/ \ - __asm lea YSTRIDE3,[YSTRIDE+YSTRIDE*2] \ - /*x x x x d2 c2 b2 a2*/ \ - __asm movd mm2,[PIX+YSTRIDE*2] \ - /*x x x x d3 c3 b3 a3*/ \ - __asm lea D,[PIX+YSTRIDE*4] \ - __asm movd mm3,[PIX+YSTRIDE3] \ - /*x x x x d4 c4 b4 a4*/ \ - __asm movd mm4,[D] \ - /*x x x x d5 c5 b5 a5*/ \ - __asm movd mm5,[D+YSTRIDE] \ - /*x x x x d6 c6 b6 a6*/ \ - __asm movd mm6,[D+YSTRIDE*2] \ - /*x x x x d7 c7 b7 a7*/ \ - __asm movd mm7,[D+YSTRIDE3] \ - /*mm0=d1 d0 c1 c0 b1 b0 a1 a0*/ \ - __asm punpcklbw mm0,mm1 \ - /*mm2=d3 d2 c3 c2 b3 b2 a3 a2*/ \ - __asm punpcklbw mm2,mm3 \ - /*mm3=d1 d0 c1 c0 b1 b0 a1 a0*/ \ - __asm movq mm3,mm0 \ - /*mm0=b3 b2 b1 b0 a3 a2 a1 a0*/ \ - __asm punpcklwd mm0,mm2 \ - /*mm3=d3 d2 d1 d0 c3 c2 c1 c0*/ \ - __asm punpckhwd mm3,mm2 \ - /*mm1=b3 b2 b1 b0 a3 a2 a1 a0*/ \ - __asm movq mm1,mm0 \ - /*mm4=d5 d4 c5 c4 b5 b4 a5 a4*/ \ - __asm punpcklbw mm4,mm5 \ - /*mm6=d7 d6 c7 c6 b7 b6 a7 a6*/ \ - __asm punpcklbw mm6,mm7 \ - /*mm5=d5 d4 c5 c4 b5 b4 a5 a4*/ \ - __asm movq mm5,mm4 \ - /*mm4=b7 b6 b5 b4 a7 a6 a5 a4*/ \ - __asm punpcklwd mm4,mm6 \ - /*mm5=d7 d6 d5 d4 c7 c6 c5 c4*/ \ - __asm punpckhwd mm5,mm6 \ - /*mm2=d3 d2 d1 d0 c3 c2 c1 c0*/ \ - __asm movq mm2,mm3 \ - /*mm0=a7 a6 a5 a4 a3 a2 a1 a0*/ \ - __asm punpckldq mm0,mm4 \ - /*mm1=b7 b6 b5 b4 b3 b2 b1 b0*/ \ - __asm punpckhdq mm1,mm4 \ - /*mm2=c7 c6 c5 c4 c3 c2 c1 c0*/ \ - __asm punpckldq mm2,mm5 \ - /*mm3=d7 d6 d5 d4 d3 d2 d1 d0*/ \ - __asm punpckhdq mm3,mm5 \ - OC_LOOP_FILTER8_MMX \ - /*mm2={b0+R_0'',...,b7+R_7''}*/ \ - __asm movq mm0,mm1 \ - /*mm1={b0+R_0'',c0-R_0'',...,b3+R_3'',c3-R_3''}*/ \ - __asm punpcklbw mm1,mm2 \ - /*mm2={b4+R_4'',c4-R_4'',...,b7+R_7'',c7-R_7''}*/ \ - __asm punpckhbw mm0,mm2 \ - /*[d]=c1 b1 c0 b0*/ \ - __asm movd D,mm1 \ - __asm mov [PIX+1],D_WORD \ - __asm psrlq mm1,32 \ - __asm shr D,16 \ - __asm mov [PIX+YSTRIDE+1],D_WORD \ - /*[d]=c3 b3 c2 b2*/ \ - __asm movd D,mm1 \ - __asm mov [PIX+YSTRIDE*2+1],D_WORD \ - __asm shr D,16 \ - __asm mov [PIX+YSTRIDE3+1],D_WORD \ - __asm lea PIX,[PIX+YSTRIDE*4] \ - /*[d]=c5 b5 c4 b4*/ \ - __asm movd D,mm0 \ - __asm mov [PIX+1],D_WORD \ - __asm psrlq mm0,32 \ - __asm shr D,16 \ - __asm mov [PIX+YSTRIDE+1],D_WORD \ - /*[d]=c7 b7 c6 b6*/ \ - __asm movd D,mm0 \ - __asm mov [PIX+YSTRIDE*2+1],D_WORD \ - __asm shr D,16 \ - __asm mov [PIX+YSTRIDE3+1],D_WORD \ - } \ - while(0) - -# endif -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/mmxstate.c b/Engine/lib/libtheora/lib/x86_vc/mmxstate.c deleted file mode 100644 index 73bd1981c..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/mmxstate.c +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: mmxstate.c 16584 2009-09-26 19:35:55Z tterribe $ - - ********************************************************************/ - -/*MMX acceleration of complete fragment reconstruction algorithm. - Originally written by Rudolf Marek.*/ -#include -#include "x86int.h" -#include "mmxfrag.h" -#include "mmxloop.h" - -#if defined(OC_X86_ASM) - -void oc_state_frag_recon_mmx(const oc_theora_state *_state,ptrdiff_t _fragi, - int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,ogg_uint16_t _dc_quant){ - unsigned char *dst; - ptrdiff_t frag_buf_off; - int ystride; - int mb_mode; - /*Apply the inverse transform.*/ - /*Special case only having a DC component.*/ - if(_last_zzi<2){ - /*Note that this value must be unsigned, to keep the __asm__ block from - sign-extending it when it puts it in a register.*/ - ogg_uint16_t p; - /*We round this dequant product (and not any of the others) because there's - no iDCT rounding.*/ - p=(ogg_int16_t)(_dct_coeffs[0]*(ogg_int32_t)_dc_quant+15>>5); - /*Fill _dct_coeffs with p.*/ - __asm{ -#define Y eax -#define P ecx - mov Y,_dct_coeffs - movzx P,p - /*mm0=0000 0000 0000 AAAA*/ - movd mm0,P - /*mm0=0000 0000 AAAA AAAA*/ - punpcklwd mm0,mm0 - /*mm0=AAAA AAAA AAAA AAAA*/ - punpckldq mm0,mm0 - movq [Y],mm0 - movq [8+Y],mm0 - movq [16+Y],mm0 - movq [24+Y],mm0 - movq [32+Y],mm0 - movq [40+Y],mm0 - movq [48+Y],mm0 - movq [56+Y],mm0 - movq [64+Y],mm0 - movq [72+Y],mm0 - movq [80+Y],mm0 - movq [88+Y],mm0 - movq [96+Y],mm0 - movq [104+Y],mm0 - movq [112+Y],mm0 - movq [120+Y],mm0 -#undef Y -#undef P - } - } - else{ - /*Dequantize the DC coefficient.*/ - _dct_coeffs[0]=(ogg_int16_t)(_dct_coeffs[0]*(int)_dc_quant); - oc_idct8x8_mmx(_dct_coeffs,_last_zzi); - } - /*Fill in the target buffer.*/ - frag_buf_off=_state->frag_buf_offs[_fragi]; - mb_mode=_state->frags[_fragi].mb_mode; - ystride=_state->ref_ystride[_pli]; - dst=_state->ref_frame_data[_state->ref_frame_idx[OC_FRAME_SELF]]+frag_buf_off; - if(mb_mode==OC_MODE_INTRA)oc_frag_recon_intra_mmx(dst,ystride,_dct_coeffs); - else{ - const unsigned char *ref; - int mvoffsets[2]; - ref= - _state->ref_frame_data[_state->ref_frame_idx[OC_FRAME_FOR_MODE(mb_mode)]] - +frag_buf_off; - if(oc_state_get_mv_offsets(_state,mvoffsets,_pli, - _state->frag_mvs[_fragi][0],_state->frag_mvs[_fragi][1])>1){ - oc_frag_recon_inter2_mmx(dst,ref+mvoffsets[0],ref+mvoffsets[1],ystride, - _dct_coeffs); - } - else oc_frag_recon_inter_mmx(dst,ref+mvoffsets[0],ystride,_dct_coeffs); - } -} - -/*We copy these entire function to inline the actual MMX routines so that we - use only a single indirect call.*/ - -/*Copies the fragments specified by the lists of fragment indices from one - frame to another. - _fragis: A pointer to a list of fragment indices. - _nfragis: The number of fragment indices to copy. - _dst_frame: The reference frame to copy to. - _src_frame: The reference frame to copy from. - _pli: The color plane the fragments lie in.*/ -void oc_state_frag_copy_list_mmx(const oc_theora_state *_state, - const ptrdiff_t *_fragis,ptrdiff_t _nfragis, - int _dst_frame,int _src_frame,int _pli){ - const ptrdiff_t *frag_buf_offs; - const unsigned char *src_frame_data; - unsigned char *dst_frame_data; - ptrdiff_t fragii; - int ystride; - dst_frame_data=_state->ref_frame_data[_state->ref_frame_idx[_dst_frame]]; - src_frame_data=_state->ref_frame_data[_state->ref_frame_idx[_src_frame]]; - ystride=_state->ref_ystride[_pli]; - frag_buf_offs=_state->frag_buf_offs; - for(fragii=0;fragii<_nfragis;fragii++){ - ptrdiff_t frag_buf_off; - frag_buf_off=frag_buf_offs[_fragis[fragii]]; -#define SRC edx -#define DST eax -#define YSTRIDE ecx -#define YSTRIDE3 edi - OC_FRAG_COPY_MMX(dst_frame_data+frag_buf_off, - src_frame_data+frag_buf_off,ystride); -#undef SRC -#undef DST -#undef YSTRIDE -#undef YSTRIDE3 - } -} - -/*Apply the loop filter to a given set of fragment rows in the given plane. - The filter may be run on the bottom edge, affecting pixels in the next row of - fragments, so this row also needs to be available. - _bv: The bounding values array. - _refi: The index of the frame buffer to filter. - _pli: The color plane to filter. - _fragy0: The Y coordinate of the first fragment row to filter. - _fragy_end: The Y coordinate of the fragment row to stop filtering at.*/ -void oc_state_loop_filter_frag_rows_mmx(const oc_theora_state *_state, - int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end){ - OC_ALIGN8(unsigned char ll[8]); - const oc_fragment_plane *fplane; - const oc_fragment *frags; - const ptrdiff_t *frag_buf_offs; - unsigned char *ref_frame_data; - ptrdiff_t fragi_top; - ptrdiff_t fragi_bot; - ptrdiff_t fragi0; - ptrdiff_t fragi0_end; - int ystride; - int nhfrags; - memset(ll,_state->loop_filter_limits[_state->qis[0]],sizeof(ll)); - fplane=_state->fplanes+_pli; - nhfrags=fplane->nhfrags; - fragi_top=fplane->froffset; - fragi_bot=fragi_top+fplane->nfrags; - fragi0=fragi_top+_fragy0*(ptrdiff_t)nhfrags; - fragi0_end=fragi0+(_fragy_end-_fragy0)*(ptrdiff_t)nhfrags; - ystride=_state->ref_ystride[_pli]; - frags=_state->frags; - frag_buf_offs=_state->frag_buf_offs; - ref_frame_data=_state->ref_frame_data[_refi]; - /*The following loops are constructed somewhat non-intuitively on purpose. - The main idea is: if a block boundary has at least one coded fragment on - it, the filter is applied to it. - However, the order that the filters are applied in matters, and VP3 chose - the somewhat strange ordering used below.*/ - while(fragi0fragi0)OC_LOOP_FILTER_H_MMX(ref,ystride,ll); - if(fragi0>fragi_top)OC_LOOP_FILTER_V_MMX(ref,ystride,ll); - if(fragi+1opt_vtable.frag_sub=oc_enc_frag_sub_mmx; - _enc->opt_vtable.frag_sub_128=oc_enc_frag_sub_128_mmx; - _enc->opt_vtable.frag_recon_intra=oc_frag_recon_intra_mmx; - _enc->opt_vtable.frag_recon_inter=oc_frag_recon_inter_mmx; - _enc->opt_vtable.fdct8x8=oc_enc_fdct8x8_mmx; - } - if(cpu_flags&OC_CPU_X86_MMXEXT){ - _enc->opt_vtable.frag_sad=oc_enc_frag_sad_mmxext; - _enc->opt_vtable.frag_sad_thresh=oc_enc_frag_sad_thresh_mmxext; - _enc->opt_vtable.frag_sad2_thresh=oc_enc_frag_sad2_thresh_mmxext; - _enc->opt_vtable.frag_satd_thresh=oc_enc_frag_satd_thresh_mmxext; - _enc->opt_vtable.frag_satd2_thresh=oc_enc_frag_satd2_thresh_mmxext; - _enc->opt_vtable.frag_intra_satd=oc_enc_frag_intra_satd_mmxext; - _enc->opt_vtable.frag_copy2=oc_enc_frag_copy2_mmxext; - } - if(cpu_flags&OC_CPU_X86_SSE2){ -# if defined(OC_X86_64_ASM) - _enc->opt_vtable.fdct8x8=oc_enc_fdct8x8_x86_64sse2; -# endif - } -} -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/x86enc.h b/Engine/lib/libtheora/lib/x86_vc/x86enc.h deleted file mode 100644 index 581484641..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/x86enc.h +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: x86int.h 15675 2009-02-06 09:43:27Z tterribe $ - - ********************************************************************/ - -#if !defined(_x86_vc_x86enc_H) -# define _x86_vc_x86enc_H (1) -# include "../encint.h" -# include "x86int.h" - -void oc_enc_vtable_init_x86(oc_enc_ctx *_enc); - -unsigned oc_enc_frag_sad_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride); -unsigned oc_enc_frag_sad_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh); -unsigned oc_enc_frag_sad2_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh); -unsigned oc_enc_frag_satd_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref,int _ystride,unsigned _thresh); -unsigned oc_enc_frag_satd2_thresh_mmxext(const unsigned char *_src, - const unsigned char *_ref1,const unsigned char *_ref2,int _ystride, - unsigned _thresh); -unsigned oc_enc_frag_intra_satd_mmxext(const unsigned char *_src,int _ystride); -void oc_enc_frag_sub_mmx(ogg_int16_t _diff[64], - const unsigned char *_x,const unsigned char *_y,int _stride); -void oc_enc_frag_sub_128_mmx(ogg_int16_t _diff[64], - const unsigned char *_x,int _stride); -void oc_enc_frag_copy2_mmxext(unsigned char *_dst, - const unsigned char *_src1,const unsigned char *_src2,int _ystride); -void oc_enc_fdct8x8_mmx(ogg_int16_t _y[64],const ogg_int16_t _x[64]); -void oc_enc_fdct8x8_x86_64sse2(ogg_int16_t _y[64],const ogg_int16_t _x[64]); - -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/x86int.h b/Engine/lib/libtheora/lib/x86_vc/x86int.h deleted file mode 100644 index 4cca48531..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/x86int.h +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: x86int.h 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#if !defined(_x86_vc_x86int_H) -# define _x86_vc_x86int_H (1) -# include "../internal.h" - -void oc_state_vtable_init_x86(oc_theora_state *_state); - -void oc_frag_copy_mmx(unsigned char *_dst, - const unsigned char *_src,int _ystride); -void oc_frag_recon_intra_mmx(unsigned char *_dst,int _ystride, - const ogg_int16_t *_residue); -void oc_frag_recon_inter_mmx(unsigned char *_dst, - const unsigned char *_src,int _ystride,const ogg_int16_t *_residue); -void oc_frag_recon_inter2_mmx(unsigned char *_dst,const unsigned char *_src1, - const unsigned char *_src2,int _ystride,const ogg_int16_t *_residue); -void oc_idct8x8_mmx(ogg_int16_t _y[64],int _last_zzi); -void oc_state_frag_recon_mmx(const oc_theora_state *_state,ptrdiff_t _fragi, - int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,ogg_uint16_t _dc_quant); -void oc_state_frag_copy_list_mmx(const oc_theora_state *_state, - const ptrdiff_t *_fragis,ptrdiff_t _nfragis, - int _dst_frame,int _src_frame,int _pli); -void oc_state_loop_filter_frag_rows_mmx(const oc_theora_state *_state, - int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end); -void oc_restore_fpu_mmx(void); - -#endif diff --git a/Engine/lib/libtheora/lib/x86_vc/x86state.c b/Engine/lib/libtheora/lib/x86_vc/x86state.c deleted file mode 100644 index a786bec28..000000000 --- a/Engine/lib/libtheora/lib/x86_vc/x86state.c +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - function: - last mod: $Id: x86state.c 16503 2009-08-22 18:14:02Z giles $ - - ********************************************************************/ - -#include "x86int.h" - -#if defined(OC_X86_ASM) - -#include "../cpu.c" - -/*This table has been modified from OC_FZIG_ZAG by baking a 4x4 transpose into - each quadrant of the destination.*/ -static const unsigned char OC_FZIG_ZAG_MMX[128]={ - 0, 8, 1, 2, 9,16,24,17, - 10, 3,32,11,18,25, 4,12, - 5,26,19,40,33,34,41,48, - 27, 6,13,20,28,21,14, 7, - 56,49,42,35,43,50,57,36, - 15,22,29,30,23,44,37,58, - 51,59,38,45,52,31,60,53, - 46,39,47,54,61,62,55,63, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, - 64,64,64,64,64,64,64,64, -}; - -void oc_state_vtable_init_x86(oc_theora_state *_state){ - _state->cpu_flags=oc_cpu_flags_get(); - if(_state->cpu_flags&OC_CPU_X86_MMX){ - _state->opt_vtable.frag_copy=oc_frag_copy_mmx; - _state->opt_vtable.frag_recon_intra=oc_frag_recon_intra_mmx; - _state->opt_vtable.frag_recon_inter=oc_frag_recon_inter_mmx; - _state->opt_vtable.frag_recon_inter2=oc_frag_recon_inter2_mmx; - _state->opt_vtable.idct8x8=oc_idct8x8_mmx; - _state->opt_vtable.state_frag_recon=oc_state_frag_recon_mmx; - _state->opt_vtable.state_frag_copy_list=oc_state_frag_copy_list_mmx; - _state->opt_vtable.state_loop_filter_frag_rows= - oc_state_loop_filter_frag_rows_mmx; - _state->opt_vtable.restore_fpu=oc_restore_fpu_mmx; - _state->opt_data.dct_fzig_zag=OC_FZIG_ZAG_MMX; - } - else oc_state_vtable_init_c(_state); -} -#endif diff --git a/Engine/lib/libvorbis/.gitignore b/Engine/lib/libvorbis/.gitignore deleted file mode 100644 index 27ec90e06..000000000 --- a/Engine/lib/libvorbis/.gitignore +++ /dev/null @@ -1,61 +0,0 @@ -*.o -*.lo -*.la -.libs -.deps -aclocal.m4 -configure -Makefile -Makefile.in -autom4te.cache -compile -config.guess -config.h -config.h.in -config.h.in~ -config.log -config.status -config.sub -depcomp -install-sh -libtool -ltmain.sh -missing -stamp-h1 -m4/libtool.m4 -m4/ltoptions.m4 -m4/ltsugar.m4 -m4/ltversion.m4 -m4/lt~obsolete.m4 -libvorbis.spec -vorbis-uninstalled.pc -vorbis.pc -vorbisenc-uninstalled.pc -vorbisenc.pc -vorbisfile-uninstalled.pc -vorbisfile.pc -doc/Doxyfile -doc/doxygen-build.stamp -examples/chaining_example -examples/decoder_example -examples/encoder_example -examples/seeking_example -examples/vorbisfile_example -lib/test_sharedbook -test/test - -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -CMakeSettings.json - -*[Bb]uild*/ - -.vs/ -.vscode/ diff --git a/Engine/lib/libvorbis/.gitlab-ci.yml b/Engine/lib/libvorbis/.gitlab-ci.yml deleted file mode 100644 index e438d9724..000000000 --- a/Engine/lib/libvorbis/.gitlab-ci.yml +++ /dev/null @@ -1,27 +0,0 @@ -default: - tags: - - docker - # Image from https://hub.docker.com/_/gcc/ based on Debian - image: gcc:9 - -autoconf: - stage: build - before_script: - - apt-get update && - apt-get install -y libogg-dev zip doxygen - script: - - ./autogen.sh - - ./configure - - make - - make distcheck - -cmake: - stage: build - before_script: - - apt-get update && - apt-get install -y libogg-dev zip doxygen - cmake ninja-build - script: - - mkdir build - - cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release - - cmake --build build diff --git a/Engine/lib/libvorbis/.travis.yml b/Engine/lib/libvorbis/.travis.yml deleted file mode 100644 index 23fec3d40..000000000 --- a/Engine/lib/libvorbis/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: c - -os: - - linux - - osx - -osx_image: xcode11 - -compiler: - - gcc - - clang - -env: - - BUILD_SYSTEM=AUTOTOOLS - - BUILD_SYSTEM=CMAKE - -addons: - apt: - packages: - - libogg-dev - homebrew: - brewfile: true - update: true - -script: - - if [[ "$BUILD_SYSTEM" == "AUTOTOOLS" ]] ; then ./autogen.sh && ./configure && make -j2 V=1 distcheck; fi - - if [[ "$BUILD_SYSTEM" == "CMAKE" ]] ; then mkdir build && pushd build && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. && cmake --build . && popd; fi diff --git a/Engine/lib/libvorbis/.ycm_extra_conf.py b/Engine/lib/libvorbis/.ycm_extra_conf.py deleted file mode 100644 index f4e30e890..000000000 --- a/Engine/lib/libvorbis/.ycm_extra_conf.py +++ /dev/null @@ -1,8 +0,0 @@ -def FlagsForFile(filename, **kwargs): - return { - 'flags': [ - '-x', 'c', - '-g', '-Wall', '-Wextra', - '-D_REENTRANT', '-D__NO_MATH_INLINES', '-fsigned-char' - ], - } diff --git a/Engine/lib/libvorbis/AUTHORS b/Engine/lib/libvorbis/AUTHORS deleted file mode 100644 index 0da10363c..000000000 --- a/Engine/lib/libvorbis/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -Monty - -and the rest of the Xiph.org Foundation. diff --git a/Engine/lib/libvorbis/Brewfile b/Engine/lib/libvorbis/Brewfile deleted file mode 100644 index af81e5b46..000000000 --- a/Engine/lib/libvorbis/Brewfile +++ /dev/null @@ -1,3 +0,0 @@ -brew 'doxygen' -brew 'libogg' -brew 'xz' diff --git a/Engine/lib/libvorbis/CHANGES b/Engine/lib/libvorbis/CHANGES deleted file mode 100644 index c4a0addf0..000000000 --- a/Engine/lib/libvorbis/CHANGES +++ /dev/null @@ -1,184 +0,0 @@ -libvorbis 1.3.7 (2020-07-04) -- "Xiph.Org libVorbis I 20200704 (Reducing Environment)" - -* Fix CVE-2018-10393 - out-of-bounds read encoding very low sample rates. -* Fix CVE-2017-14160 - out-of-bounds read encoding very low sample rates. -* Fix handling invalid bytes per sample arguments. -* Fix handling invalid channel count arguments. -* Fix invalid free on seek failure. -* Fix negative shift reading blocksize. -* Fix accepting unreasonable float32 values. -* Fix tag comparison depending on locale. -* Fix unnecessarily linking libm. -* Fix memory leak in test_sharedbook. -* Update Visual Studio projects for ogg library filename change. -* Distribute CMake build files with the source package. -* Remove unnecessary configure --target switch. -* Add gitlab CI support. -* Add OSS-Fuzz support. -* Build system and integration updates. - -libvorbis 1.3.6 (2018-03-16) -- "Xiph.Org libVorbis I 20180316 (Now 100% fewer shells)" - -* Fix CVE-2018-5146 - out-of-bounds write on codebook decoding. -* Fix CVE-2017-14632 - free() on unitialized data -* Fix CVE-2017-14633 - out-of-bounds read -* Fix bitrate metadata parsing. -* Fix out-of-bounds read in codebook parsing. -* Fix residue vector size in Vorbis I spec. -* Appveyor support -* Travis CI support -* Add secondary CMake build system. -* Build system fixes - -libvorbis 1.3.5 (2015-03-03) -- "Xiph.Org libVorbis I 20150105 (⛄⛄⛄⛄)" - -* Tolerate single-entry codebooks. -* Fix decoder crash with invalid input. -* Fix encoder crash with non-positive sample rates. -# Fix issues in vorbisfile's seek bisection code. -* Spec errata. -* Reject multiple headers of the same type. -* Various build fixes and code cleanup. - -libvorbis 1.3.4 (2014-01-22) -- "Xiph.Org libVorbis I 20140122 (Turpakäräjiin)" - -* Reduce codebook footprint in library code. -* Various build and documentation fixes. - -libvorbis 1.3.3 (2012-02-03) -- "Xiph.Org libVorbis I 20120203 (Omnipresent)" - -* vorbis: additional proofing against invalid/malicious - streams in decode (see SVN for details). -* vorbis: fix a memory leak in vorbis_commentheader_out(). -* updates, corrections and clarifications in the Vorbis I specification - document -* win32: fixed project configuration which referenced two CRT versions - in output binaries. -* build warning fixes - -libvorbis 1.3.2 (2010-11-01) -- "Xiph.Org libVorbis I 20101101 (Schaufenugget)" - - * vorbis: additional proofing against invalid/malicious - streams in floor, residue, and bos/eos packet trimming - code (see SVN for details). - * vorbis: Added programming documentation tree for the - low-level calls - * vorbisfile: Correct handling of serial numbers array - element [0] on non-seekable streams - * vorbisenc: Back out an [old] AoTuV HF weighting that was - first enabled in 1.3.0; there are a few samples where I - really don't like the effect it causes. - * vorbis: return correct timestamp for granule positions - with high bit set. - * vorbisfile: the [undocumented] half-rate decode api made no - attempt to keep the pcm offset tracking consistent in seeks. - Fix and add a testing mode to seeking_example.c to torture - test seeking in halfrate mode. Also remove requirement that - halfrate mode only work with seekable files. - * vorbisfile: Fix a chaining bug in raw_seeks where seeking - out of the current link would fail due to not - reinitializing the decode machinery. - * vorbisfile: improve seeking strategy. Reduces the - necessary number of seek callbacks in an open or seek - operation by well over 2/3. - -libvorbis 1.3.1 (2010-02-26) -- "Xiph.Org libVorbis I 20100325 (Everywhere)" - - * tweak + minor arithmetic fix in floor1 fit - * revert noise norm to conservative 1.2.3 behavior pending - more listening testing - -libvorbis 1.3.0 (2010-02-25) -- unreleased staging snapshot - - * Optimized surround support for 5.1 encoding at 44.1/48kHz - * Added encoder control call to disable channel coupling - * Correct an overflow bug in very low-bitrate encoding on 32 bit - machines that caused inflated bitrates - * Numerous API hardening, leak and build fixes - * Correct bug in 22kHz compand setup that could cause a crash - * Correct bug in 16kHz codebooks that could cause unstable pure - tones at high bitrates - -libvorbis 1.2.3 (2009-07-09) -- "Xiph.Org libVorbis I 20090709" - - * correct a vorbisfile bug that prevented proper playback of - Vorbis files where all audio in a logical stream is in a - single page - * Additional decode setup hardening against malicious streams - * Add 'OV_EXCLUDE_STATIC_CALLBACKS' define for developers who - wish to avoid unused symbol warnings from the static callbacks - defined in vorbisfile.h - -libvorbis 1.2.2 (2009-06-24) -- "Xiph.Org libVorbis I 20090624" - - * define VENDOR and ENCODER strings - * seek correctly in files bigger than 2 GB (Windows) - * fix regression from CVE-2008-1420; 1.0b1 files work again - * mark all tables as constant to reduce memory occupation - * additional decoder hardening against malicious streams - * substantially reduce amount of seeking performed by Vorbisfile - * Multichannel decode bugfix - * build system updates - * minor specification clarifications/fixes - -libvorbis 1.2.1 (unreleased) -- "Xiph.Org libVorbis I 20080501" - - * Improved robustness with corrupt streams. - * New ov_read_filter() vorbisfile call allows filtering decoded - audio as floats before converting to integer samples. - * Fix an encoder bug with multichannel streams. - * Replaced RTP payload format draft with RFC 5215. - * Bare bones self test under 'make check'. - * Fix a problem encoding some streams between 14 and 28 kHz. - * Fix a numerical instability in the edge extrapolation filter. - * Build system improvements. - * Specification correction. - -libvorbis 1.2.0 (2007-07-25) -- "Xiph.Org libVorbis I 20070622" - - * new ov_fopen() convenience call that avoids the common - stdio conflicts with ov_open() and MSVC runtimes. - * libvorbisfile now handles multiplexed streams - * improve robustness to corrupt input streams - * fix a minor encoder bug - * updated RTP draft - * build system updates - * minor corrections to the specification - -libvorbis 1.1.2 (2005-11-27) -- "Xiph.Org libVorbis I 20050304" - - * fix a serious encoder bug with gcc 4 optimized builds - * documentation and spec fixes - * updated VS2003 and XCode builds - * new draft RTP encapsulation spec - -libvorbis 1.1.1 (2005-06-27) -- "Xiph.Org libVorbis I 20050304" - - * bug fix to the bitrate management encoder interface - * bug fix to properly set packetno field in the encoder - * new draft RTP encapsulation spec - * library API documentation improvements - -libvorbis 1.1.0 (2004-09-22) -- "Xiph.Org libVorbis I 20040629" - - * merges tuning improvements from Aoyumi's aoTuV with fixups - * new managed bitrate (CBR) mode support - * new vorbis_encoder_ctl() interface - * extensive documentation updates - * application/ogg mimetype is now official - * autotools cleanup from Thomas Vander Stichele - * SymbianOS build support from Colin Ward at CSIRO - * various bugfixes - * various packaging improvements - -libvorbis 1.0.1 (2003-11-17) -- "Xiph.Org libVorbis I 20030909" - - * numerous bug fixes - * specification corrections - * new crosslap and halfrate APIs for game use - * packaging and build updates - -libvorbis 1.0.0 (2002-07-19) -- "Xiph.Org libVorbis I 20020717" - - * first stable release - diff --git a/Engine/lib/libvorbis/CMakeLists.txt b/Engine/lib/libvorbis/CMakeLists.txt deleted file mode 100644 index 3de1bbe19..000000000 --- a/Engine/lib/libvorbis/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -cmake_minimum_required(VERSION 3.6) -project(vorbis) - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -# Required modules -include(GNUInstallDirs) -include(CheckIncludeFiles) -include(CheckLibraryExists) - -# Build options -option(BUILD_SHARED_LIBS "Build shared library" OFF) -if(APPLE) - option(BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF) -endif() - -if(BUILD_FRAMEWORK) - set(BUILD_SHARED_LIBS TRUE) -endif() - -option(INSTALL_CMAKE_PACKAGE_MODULE "Install CMake package configiguration module" ON) - -# Extract project version from configure.ac -file(READ configure.ac CONFIGURE_AC_CONTENTS) -string(REGEX MATCH "AC_INIT\\(\\[libvorbis\\],\\[([0-9]*).([0-9]*).([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS}) -set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1}) -set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2}) -set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3}) -set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) - -# Helper function to get version-info -function(get_version_info result current_var_name age_var_name revision_var_name) - string(REGEX MATCH "${current_var_name}=([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS}) - set(VERSION_INFO_CURRENT ${CMAKE_MATCH_1}) - - string(REGEX MATCH "${age_var_name}=([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS}) - set(VERSION_INFO_AGE ${CMAKE_MATCH_1}) - - string(REGEX MATCH "${revision_var_name}=([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS}) - set(VERSION_INFO_REVISION ${CMAKE_MATCH_1}) - - math(EXPR VERSION_INFO_CURRENT_MINUS_AGE "${VERSION_INFO_CURRENT} - ${VERSION_INFO_AGE}") - - set(${result} "${VERSION_INFO_CURRENT_MINUS_AGE}.${VERSION_INFO_AGE}.${VERSION_INFO_REVISION}" PARENT_SCOPE) -endfunction() - -# Helper function to configure pkg-config files -function(configure_pkg_config_file pkg_config_file_in) - set(prefix ${CMAKE_INSTALL_PREFIX}) - set(exec_prefix ${CMAKE_INSTALL_FULL_BINDIR}) - set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) - set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) - set(VERSION ${PROJECT_VERSION}) - string(REPLACE ".in" "" pkg_config_file ${pkg_config_file_in}) - configure_file(${pkg_config_file_in} ${pkg_config_file} @ONLY) -endfunction() - -message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}") - -# Find math library - -check_library_exists(m floor "" HAVE_LIBM) - -# Find ogg dependency -#find_package(ogg CONFIG REQUIRED) - -add_subdirectory(lib) - -configure_pkg_config_file(vorbis.pc.in) -configure_pkg_config_file(vorbisenc.pc.in) -configure_pkg_config_file(vorbisfile.pc.in) - -install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/vorbis.pc - ${CMAKE_CURRENT_BINARY_DIR}/vorbisenc.pc - ${CMAKE_CURRENT_BINARY_DIR}/vorbisfile.pc - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/pkgconfig -) diff --git a/Engine/lib/libvorbis/COPYING b/Engine/lib/libvorbis/COPYING deleted file mode 100644 index fb456a87b..000000000 --- a/Engine/lib/libvorbis/COPYING +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2002-2020 Xiph.org Foundation - -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 the Xiph.org Foundation nor the names of its -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 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. diff --git a/Engine/lib/libvorbis/Makefile.am b/Engine/lib/libvorbis/Makefile.am deleted file mode 100644 index 359a70199..000000000 --- a/Engine/lib/libvorbis/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -## Process this file with automake to produce Makefile.in - -AUTOMAKE_OPTIONS = foreign 1.11 dist-zip dist-xz - -ACLOCAL_AMFLAGS = -I m4 - -SUBDIRS = m4 include vq lib test doc - -if BUILD_EXAMPLES -SUBDIRS += examples -endif - -m4datadir = $(datadir)/aclocal -m4data_DATA = vorbis.m4 - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = vorbis.pc vorbisenc.pc vorbisfile.pc - -EXTRA_DIST = \ - CHANGES COPYING \ - autogen.sh \ - libvorbis.spec libvorbis.spec.in \ - vorbis.m4 \ - vorbis.pc.in vorbisenc.pc.in vorbisfile.pc.in \ - vorbis-uninstalled.pc.in \ - vorbisenc-uninstalled.pc.in \ - vorbisfile-uninstalled.pc.in \ - symbian macosx win32 \ - CMakeLists.txt cmake/FindOgg.cmake cmake/VorbisConfig.cmake.in - -DISTCHECK_CONFIGURE_FLAGS = --enable-docs - -dist-hook: - for item in $(EXTRA_DIST); do \ - if test -d $$item; then \ - echo -n "cleaning $$item dir for distribution..."; \ - rm -rf `find $(distdir)/$$item -name .svn`; \ - echo "OK"; \ - fi; \ - done - -debug: - $(MAKE) all CFLAGS="@DEBUG@" - -profile: - $(MAKE) all CFLAGS="@PROFILE@" diff --git a/Engine/lib/libvorbis/README.md b/Engine/lib/libvorbis/README.md deleted file mode 100644 index 30c88d391..000000000 --- a/Engine/lib/libvorbis/README.md +++ /dev/null @@ -1,147 +0,0 @@ -# Vorbis - -[![GitLab Build Status](https://gitlab.xiph.org/xiph/vorbis/badges/master/pipeline.svg)](https://gitlab.xiph.org/xiph/vorbis/-/pipelines) -[![Travis Build Status](https://travis-ci.org/xiph/vorbis.svg?branch=master)](https://travis-ci.org/xiph/vorbis) -[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/github/xiph/vorbis?branch=master&svg=true)](https://ci.appveyor.com/project/rillian/vorbis) - -Vorbis is a general purpose audio and music encoding format -contemporary to MPEG-4's AAC and TwinVQ, the next generation beyond -MPEG audio layer 3. Unlike the MPEG sponsored formats (and other -proprietary formats such as RealAudio G2 and Windows' flavor of the -month), the Vorbis CODEC specification belongs to the public domain. -All the technical details are published and documented, and any -software entity may make full use of the format without license -fee, royalty or patent concerns. - -This package contains: - -- libvorbis, a BSD-style license software implementation of - the Vorbis specification by the Xiph.Org Foundation - (https://xiph.org/) - -- libvorbisfile, a BSD-style license convenience library - built on Vorbis designed to simplify common uses - -- libvorbisenc, a BSD-style license library that provides a simple, - programmatic encoding setup interface - -- example code making use of libogg, libvorbis, libvorbisfile and - libvorbisenc - -## What's here ## - -This source distribution includes libvorbis and an example -encoder/player to demonstrate use of libvorbis as well as -documentation on the Ogg Vorbis audio coding format. - -You'll need libogg (distributed separately) to compile this library. -A more comprehensive set of utilities is available in the vorbis-tools -package. - -Directory: - -- `lib` The source for the libraries, a BSD-license implementation of the public domain Ogg Vorbis audio encoding format. - -- `include` Library API headers - -- `debian` Rules/spec files for building Debian .deb packages - -- `doc` Vorbis documentation - -- `examples` Example code illustrating programmatic use of libvorbis, libvorbisfile and libvorbisenc - -- `macosx` Project files for MacOS X. - -- `win32` Win32 projects files and build automation - -- `vq` Internal utilities for training/building new LSP/residue and auxiliary codebooks. - -## Contact ## - -The Ogg homepage is located at 'https://xiph.org/ogg/'. -Vorbis's homepage is located at 'https://xiph.org/vorbis/'. -Up to date technical documents, contact information, source code and -pre-built utilities may be found there. - -## Building ## - -#### Building from master #### - -Development source is under git revision control at -https://gitlab.xiph.org/xiph/vorbis.git. You will also need the -newest versions of autoconf, automake, libtool and pkg-config in -order to compile Vorbis from development source. A configure script -is provided for you in the source tarball distributions. - - ./autogen.sh - ./configure - make - -and as root if desired: - - make install - -This will install the Vorbis libraries (static and shared) into -/usr/local/lib, includes into /usr/local/include and API manpages -(once we write some) into /usr/local/man. - -Documentation building requires xsltproc and pdfxmltex. - -#### Building from tarball distributions #### - - ./configure - make - -and optionally (as root): - - make install - -#### Building RPM packages #### - -after normal configuring: - - make dist - rpm -ta libvorbis-.tar.gz - -## Building with CMake ## - -Ogg supports building using [CMake](https://cmake.org/). CMake is a meta build system that generates native projects for each platform. -To generate projects just run cmake replacing `YOUR-PROJECT-GENERATOR` with a proper generator from a list [here](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html): - - cmake -G YOUR-PROJECT-GENERATOR . - -Note that by default cmake generates projects that will build static libraries. -To generate projects that will build dynamic library use `BUILD_SHARED_LIBS` option like this: - - cmake -G YOUR-PROJECT-GENERATOR -DBUILD_SHARED_LIBS=1 . - -After projects are generated use them as usual - -#### Building on Windows #### - -Use proper generator for your Visual Studio version like: - - cmake -G "Visual Studio 12 2013" . - -#### Building on Mac OS X #### - -Use Xcode generator. To build framework run: - - cmake -G Xcode -DBUILD_FRAMEWORK=1 . - -#### Building on Linux #### - -Use Makefile generator which is default one. - - cmake . - make - -## License ## - -THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. -USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS -GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE -IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. - -THE OggVorbis SOURCE CODE IS COPYRIGHT (C) 1994-2020 -by the Xiph.Org Foundation https://xiph.org/ diff --git a/Engine/lib/libvorbis/appveyor.yml b/Engine/lib/libvorbis/appveyor.yml deleted file mode 100644 index 154c3c26a..000000000 --- a/Engine/lib/libvorbis/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -image: Visual Studio 2015 -configuration: -- Debug - -platform: -- Win32 - -environment: - matrix: - - BUILD_SYSTEM: MSVC - - BUILD_SYSTEM: CMAKE - -install: -- git clone -q https://github.com/xiph/ogg.git %APPVEYOR_BUILD_FOLDER%\..\libogg -- if "%BUILD_SYSTEM%"=="MSVC" msbuild "%APPVEYOR_BUILD_FOLDER%\..\libogg\win32\VS2015\libogg.sln" /m /v:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /property:Configuration=%CONFIGURATION%;Platform=%PLATFORM% -- if "%BUILD_SYSTEM%"=="CMAKE" mkdir "%APPVEYOR_BUILD_FOLDER%\..\libogg\build" -- if "%BUILD_SYSTEM%"=="CMAKE" pushd "%APPVEYOR_BUILD_FOLDER%\..\libogg\build" -- if "%BUILD_SYSTEM%"=="CMAKE" cmake -A "%PLATFORM%" -G "Visual Studio 14 2015" -DCMAKE_INSTALL_PREFIX="%APPVEYOR_BUILD_FOLDER%\..\libogg\install" .. -- if "%BUILD_SYSTEM%"=="CMAKE" cmake --build . --config "%CONFIGURATION%" --target install -- /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" -- if "%BUILD_SYSTEM%"=="CMAKE" popd - -before_build: -- if "%BUILD_SYSTEM%" == "CMAKE" mkdir "%APPVEYOR_BUILD_FOLDER%\build" -- if "%BUILD_SYSTEM%" == "CMAKE" pushd "%APPVEYOR_BUILD_FOLDER%\build" -- if "%BUILD_SYSTEM%" == "CMAKE" cmake -A "%PLATFORM%" -G "Visual Studio 14 2015" -DOGG_ROOT=%APPVEYOR_BUILD_FOLDER%\..\libogg\install .. -- if "%BUILD_SYSTEM%" == "CMAKE" popd - -build_script: -- if "%BUILD_SYSTEM%"=="MSVC" msbuild "%APPVEYOR_BUILD_FOLDER%\win32\VS2010\vorbis_dynamic.sln" /m /v:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /property:Configuration=%CONFIGURATION%;Platform=%PLATFORM% -- if "%BUILD_SYSTEM%" == "CMAKE" pushd "%APPVEYOR_BUILD_FOLDER%\build" -- if "%BUILD_SYSTEM%" == "CMAKE" cmake --build . --config "%CONFIGURATION%" -- /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" -- if "%BUILD_SYSTEM%" == "CMAKE" popd diff --git a/Engine/lib/libvorbis/autogen.sh b/Engine/lib/libvorbis/autogen.sh deleted file mode 100644 index d859d327b..000000000 --- a/Engine/lib/libvorbis/autogen.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# Run this to set up the build system: configure, makefiles, etc. -set -e - -package="vorbis" - -srcdir=`dirname $0` -test -n "$srcdir" && cd "$srcdir" - -echo "Updating build configuration files for $package, please wait...." - -autoreconf -if diff --git a/Engine/lib/libvorbis/cmake/FindOgg.cmake b/Engine/lib/libvorbis/cmake/FindOgg.cmake deleted file mode 100644 index ebcd7d4e2..000000000 --- a/Engine/lib/libvorbis/cmake/FindOgg.cmake +++ /dev/null @@ -1,94 +0,0 @@ -#[=======================================================================[.rst: - -FindOgg --------- - -Find the native Ogg includes and library. - -IMPORTED Targets -^^^^^^^^^^^^^^^^ - -This module defines :prop_tgt:`IMPORTED` target ``Ogg::ogg``, if -Ogg has been found. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -:: - - OGG_INCLUDE_DIRS - where to find ogg.h, etc. - OGG_LIBRARIES - List of libraries when using ogg. - OGG_FOUND - True if ogg found. - -:: - - OGG_VERSION_STRING - The version of ogg found (x.y.z) - -Hints -^^^^^ - -A user may set ``OGG_ROOT`` to a ogg installation root to tell this -module where to look. -#]=======================================================================] - -if(OGG_INCLUDE_DIR) - # Already in cache, be silent - set(OGG_FIND_QUIETLY TRUE) -endif() - -find_package(PkgConfig QUIET) -pkg_check_modules(PC_OGG QUIET ogg) - -set(OGG_VERSION_STRING ${PC_OGG_VERSION}) - -find_path(OGG_INCLUDE_DIR ogg/ogg.h - HINTS - ${PC_OGG_INCLUDEDIR} - ${PC_OGG_INCLUDE_DIRS} - ${OGG_ROOT} - PATH_SUFFIXES - include -) -# MSVC built ogg may be named ogg_static. -# The provided project files name the library with the lib prefix. -find_library(OGG_LIBRARY - NAMES - ogg - ogg_static - libogg - libogg_static - HINTS - ${PC_OGG_LIBDIR} - ${PC_OGG_LIBRARY_DIRS} - ${OGG_ROOT} - PATH_SUFFIXES - lib -) - -# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND -# to TRUE if all listed variables are TRUE. -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Ogg - REQUIRED_VARS - OGG_LIBRARY - OGG_INCLUDE_DIR - VERSION_VAR - OGG_VERSION_STRING -) - -if(OGG_FOUND) - set(OGG_LIBRARIES ${OGG_LIBRARY}) - set(OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR}) - - if(NOT TARGET Ogg::ogg) - add_library(Ogg::ogg UNKNOWN IMPORTED) - set_target_properties(Ogg::ogg PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}" - IMPORTED_LOCATION "${OGG_LIBRARIES}" - ) - endif() -endif() - -mark_as_advanced(OGG_INCLUDE_DIR OGG_LIBRARY) diff --git a/Engine/lib/libvorbis/cmake/VorbisConfig.cmake.in b/Engine/lib/libvorbis/cmake/VorbisConfig.cmake.in deleted file mode 100644 index 6fc079415..000000000 --- a/Engine/lib/libvorbis/cmake/VorbisConfig.cmake.in +++ /dev/null @@ -1,19 +0,0 @@ -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) -find_dependency(Ogg REQUIRED) - -include(${CMAKE_CURRENT_LIST_DIR}/VorbisTargets.cmake) - -set(Vorbis_Vorbis_FOUND 1) -set(Vorbis_Enc_FOUND 0) -set(Vorbis_File_FOUND 0) - -if(TARGET Vorbis::vorbisenc) - set(Vorbis_Enc_FOUND TRUE) -endif() -if(TARGET Vorbis::vorbisfile) - set(Vorbis_File_FOUND TRUE) -endif() - -check_required_components(Vorbis Enc File) diff --git a/Engine/lib/libvorbis/configure.ac b/Engine/lib/libvorbis/configure.ac deleted file mode 100644 index 14a267f89..000000000 --- a/Engine/lib/libvorbis/configure.ac +++ /dev/null @@ -1,304 +0,0 @@ -dnl Process this file with autoconf to produce a configure script - -dnl ------------------------------------------------ -dnl Initialization and Versioning -dnl ------------------------------------------------ - - -AC_INIT([libvorbis],[1.3.7],[vorbis-dev@xiph.org]) - -AC_CONFIG_MACRO_DIR([m4]) - -AC_CONFIG_SRCDIR([lib/mdct.c]) - -AC_CANONICAL_HOST - -AM_INIT_AUTOMAKE -AM_MAINTAINER_MODE - -dnl Add parameters for aclocal -AC_SUBST(ACLOCAL_AMFLAGS, "-I m4") - -dnl enable silent rules on automake 1.11 and later -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -dnl Library versioning -dnl - library source changed -> increment REVISION -dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0 -dnl - interfaces added -> increment AGE -dnl - interfaces removed -> AGE = 0 - -V_LIB_CURRENT=4 -V_LIB_REVISION=9 -V_LIB_AGE=4 - -VF_LIB_CURRENT=6 -VF_LIB_REVISION=8 -VF_LIB_AGE=3 - -VE_LIB_CURRENT=2 -VE_LIB_REVISION=12 -VE_LIB_AGE=0 - -AC_SUBST(V_LIB_CURRENT) -AC_SUBST(V_LIB_REVISION) -AC_SUBST(V_LIB_AGE) -AC_SUBST(VF_LIB_CURRENT) -AC_SUBST(VF_LIB_REVISION) -AC_SUBST(VF_LIB_AGE) -AC_SUBST(VE_LIB_CURRENT) -AC_SUBST(VE_LIB_REVISION) -AC_SUBST(VE_LIB_AGE) - -dnl -------------------------------------------------- -dnl Check for programs -dnl -------------------------------------------------- - -dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2" -dnl if $CFLAGS is blank -cflags_save="$CFLAGS" -AC_PROG_CC -AC_PROG_CPP -CFLAGS="$cflags_save" - -AC_C_INLINE - -AC_LIBTOOL_WIN32_DLL -AC_PROG_LIBTOOL -AM_PROG_CC_C_O - -dnl Check for doxygen -if test "x$enable_docs" = xyes; then - AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false) - if test $HAVE_DOXYGEN = "false"; then - AC_MSG_WARN([*** doxygen not found, API documentation will not be built]) - fi -else - HAVE_DOXYGEN=false -fi -AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN) - -dnl latex tools for the specification document -AC_ARG_ENABLE(docs, - AC_HELP_STRING([--enable-docs], [build the documentation])) - -if test "x$enable_docs" = xyes; then - AC_CHECK_PROGS([PDFLATEX], pdflatex, [/bin/false]) - AC_CHECK_PROGS([HTLATEX], htlatex, [/bin/false]) - if test "x$PDFLATEX" = x/bin/false || test "x$HTLATEX" = x/bin/false; then - enable_docs=no - AC_MSG_WARN([Documentation will not be built!]) - fi -fi - -AM_CONDITIONAL(BUILD_DOCS, [test "x$enable_docs" = xyes]) - -AC_ARG_ENABLE(examples, - AS_HELP_STRING([--enable-examples], [build the examples])) - -AM_CONDITIONAL(BUILD_EXAMPLES, [test "x$enable_examples" = xyes]) - -dnl -------------------------------------------------- -dnl Set build flags based on environment -dnl -------------------------------------------------- - -dnl Set some target options - -cflags_save="$CFLAGS" -if test -z "$GCC"; then - case $host in - *-*-irix*) - dnl If we're on IRIX, we wanna use cc even if gcc - dnl is there (unless the user has overriden us)... - if test -z "$CC"; then - CC=cc - fi - DEBUG="-g -signed" - CFLAGS="-O2 -w -signed" - PROFILE="-p -g3 -O2 -signed" ;; - sparc-sun-solaris*) - DEBUG="-v -g" - CFLAGS="-xO4 -fast -w -fsimple -native -xcg92" - PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc" ;; - *) - DEBUG="-g" - CFLAGS="-O" - PROFILE="-g -p" ;; - esac -else - - AC_MSG_CHECKING([GCC version]) - GCC_VERSION=`$CC -dumpversion` - AC_MSG_RESULT([$GCC_VERSION]) - case $host in - *86-*-linux*) - DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char" - CFLAGS="-O3 -Wall -Wextra -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char" -# PROFILE="-Wall -Wextra -pg -g -O3 -ffast-math -D_REENTRANT -fsigned-char -fno-inline -static" - PROFILE="-Wall -Wextra -pg -g -O3 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char -fno-inline" - - # glibc < 2.1.3 has a serious FP bug in the math inline header - # that will cripple Vorbis. Look to see if the magic FP stack - # clobber is missing in the mathinline header, thus indicating - # the buggy version - - AC_EGREP_CPP(log10.*fldlg2.*fxch,[ - #define __LIBC_INTERNAL_MATH_INLINES 1 - #define __OPTIMIZE__ - #include - ],bad=maybe,bad=no) - if test ${bad} = "maybe" ;then - AC_EGREP_CPP(log10.*fldlg2.*fxch.*st\([[0123456789]]*\), - [ - #define __LIBC_INTERNAL_MATH_INLINES 1 - #define __OPTIMIZE__ - #include - ],bad=no,bad=yes) - fi - if test ${bad} = "yes" ;then - AC_MSG_WARN([ ]) - AC_MSG_WARN([********************************************************]) - AC_MSG_WARN([* The glibc headers on this machine have a serious bug *]) - AC_MSG_WARN([* in /usr/include/bits/mathinline.h This bug affects *]) - AC_MSG_WARN([* all floating point code, not just Ogg, built on this *]) - AC_MSG_WARN([* machine. Upgrading to glibc 2.1.3 is strongly urged *]) - AC_MSG_WARN([* to correct the problem. Note that upgrading glibc *]) - AC_MSG_WARN([* will not fix any previously built programs; this is *]) - AC_MSG_WARN([* a compile-time bug. *]) - AC_MSG_WARN([* To work around the problem for this build of Ogg, *]) - AC_MSG_WARN([* autoconf is disabling all math inlining. This will *]) - AC_MSG_WARN([* hurt Ogg performace but is necessary for an Ogg that *]) - AC_MSG_WARN([* will actually work. Once glibc is upgraded, rerun *]) - AC_MSG_WARN([* configure and make to build with inlining. *]) - AC_MSG_WARN([********************************************************]) - AC_MSG_WARN([ ]) - - CFLAGS=${OPT}" -D__NO_MATH_INLINES" - PROFILE=${PROFILE}" -D__NO_MATH_INLINES" - fi;; - powerpc-*-linux*spe) - DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES" - CFLAGS="-O3 -Wall -Wextra -ffast-math -mfused-madd -D_REENTRANT" - PROFILE="-pg -g -O3 -ffast-math -mfused-madd -D_REENTRANT";; - powerpc-*-linux*) - DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES" - CFLAGS="-O3 -Wall -Wextra -ffast-math -mfused-madd -mcpu=750 -D_REENTRANT" - PROFILE="-pg -g -O3 -ffast-math -mfused-madd -mcpu=750 -D_REENTRANT";; - *-*-linux*) - DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char" - CFLAGS="-O3 -Wall -Wextra -ffast-math -D_REENTRANT -fsigned-char" - PROFILE="-pg -g -O3 -ffast-math -D_REENTRANT -fsigned-char";; - sparc-sun-*) - sparc_cpu="" - AC_MSG_CHECKING([if gcc supports -mv8]) - old_cflags="$CFLAGS" - CFLAGS="$CFLAGS -mv8" - AC_TRY_COMPILE(, [return 0;], [ - AC_MSG_RESULT([yes]) - sparc_cpu="-mv8" - ]) - CFLAGS="$old_cflags" - DEBUG="-g -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char $sparc_cpu" - CFLAGS="-O3 -Wall -Wextra -ffast-math -D__NO_MATH_INLINES -fsigned-char $sparc_cpu" - PROFILE="-pg -g -O3 -D__NO_MATH_INLINES -fsigned-char $sparc_cpu" ;; - *-*-darwin*) - DEBUG="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O0 -fsigned-char" - CFLAGS="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O3 -ffast-math -fsigned-char" - PROFILE="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -pg -O3 -ffast-math -fsigned-char";; - *-*-os2*) - # Use -W instead of -Wextra because gcc on OS/2 is an old version. - DEBUG="-g -Wall -W -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char" - CFLAGS="-O3 -Wall -W -ffast-math -D_REENTRANT -fsigned-char" - PROFILE="-pg -g -O3 -ffast-math -D_REENTRANT -fsigned-char";; - *) - DEBUG="-g -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char" - CFLAGS="-O3 -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char" - PROFILE="-O3 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;; - esac - - AC_ADD_CFLAGS([-Wdeclaration-after-statement]) -fi -CFLAGS="$CFLAGS $cflags_save" - -dnl -------------------------------------------------- -dnl Check for headers -dnl -------------------------------------------------- - -AC_CHECK_HEADER(memory.h,CFLAGS="$CFLAGS -DUSE_MEMORY_H",:) - -dnl -------------------------------------------------- -dnl Check for typedefs, structures, etc -dnl -------------------------------------------------- - -dnl none - -dnl -------------------------------------------------- -dnl Check for libraries -dnl -------------------------------------------------- - -AC_CHECK_LIB(m, cos, VORBIS_LIBS="-lm", VORBIS_LIBS="") -AC_CHECK_LIB(pthread, pthread_create, pthread_lib="-lpthread", :) - -PKG_PROG_PKG_CONFIG - -HAVE_OGG=no -if test "x$PKG_CONFIG" != "x" -then - PKG_CHECK_MODULES(OGG, ogg >= 1.0, HAVE_OGG=yes, HAVE_OGG=no) -fi -if test "x$HAVE_OGG" = "xno" -then - dnl fall back to the old school test - XIPH_PATH_OGG(, AC_MSG_ERROR(must have Ogg installed!)) - libs_save=$LIBS - LIBS="$OGG_LIBS $VORBIS_LIBS" - AC_CHECK_FUNC(oggpack_writealign, , AC_MSG_ERROR(Ogg >= 1.0 required !)) - LIBS=$libs_save -fi - -dnl -------------------------------------------------- -dnl Check for library functions -dnl -------------------------------------------------- - -AC_FUNC_ALLOCA -AC_FUNC_MEMCMP - -dnl -------------------------------------------------- -dnl Do substitutions -dnl -------------------------------------------------- - -AC_SUBST(VORBIS_LIBS) -AC_SUBST(DEBUG) -AC_SUBST(PROFILE) -AC_SUBST(pthread_lib) - -dnl The following line causes the libtool distributed with the source -dnl to be replaced if the build system has a more recent version. -AC_SUBST(LIBTOOL_DEPS) - -AC_CONFIG_FILES([ -Makefile -m4/Makefile -lib/Makefile -lib/modes/Makefile -lib/books/Makefile -lib/books/coupled/Makefile -lib/books/uncoupled/Makefile -lib/books/floor/Makefile -doc/Makefile doc/vorbisfile/Makefile doc/vorbisenc/Makefile doc/libvorbis/Makefile -doc/Doxyfile -include/Makefile include/vorbis/Makefile -examples/Makefile -test/Makefile -vq/Makefile -libvorbis.spec -vorbis.pc -vorbisenc.pc -vorbisfile.pc -vorbis-uninstalled.pc -vorbisenc-uninstalled.pc -vorbisfile-uninstalled.pc -]) -AC_CONFIG_HEADERS([config.h]) - -AC_OUTPUT diff --git a/Engine/lib/libvorbis/contrib/oss-fuzz/build.sh b/Engine/lib/libvorbis/contrib/oss-fuzz/build.sh deleted file mode 100644 index 1f76b4a3e..000000000 --- a/Engine/lib/libvorbis/contrib/oss-fuzz/build.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -eu - -pushd $SRC -mv people.xiph.org/*.ogg decode_corpus/ -zip -r "$OUT/decode_fuzzer_seed_corpus.zip" decode_corpus/ -popd - -pushd $SRC/ogg -./autogen.sh -./configure --prefix="$WORK" --enable-static --disable-shared --disable-crc -make clean -make -j$(nproc) -make install -popd - - -./autogen.sh -./configure --prefix="$WORK" --enable-static --disable-shared -make clean -make -j$(nproc) -make install - -$CXX $CXXFLAGS $SRC/vorbis/contrib/oss-fuzz/decode_fuzzer.cc -o $OUT/decode_fuzzer -L"$WORK/lib" -I"$WORK/include" $LIB_FUZZING_ENGINE -lvorbisfile -lvorbis -logg diff --git a/Engine/lib/libvorbis/contrib/oss-fuzz/decode_fuzzer.cc b/Engine/lib/libvorbis/contrib/oss-fuzz/decode_fuzzer.cc deleted file mode 100644 index b8840c145..000000000 --- a/Engine/lib/libvorbis/contrib/oss-fuzz/decode_fuzzer.cc +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include -#include - -struct vorbis_data { - const uint8_t *current; - const uint8_t *data; - size_t size; -}; - -size_t read_func(void *ptr, size_t size1, size_t size2, void *datasource) { - vorbis_data* vd = (vorbis_data *)(datasource); - size_t len = size1 * size2; - if (vd->current + len > vd->data + vd->size) { - len = vd->data + vd->size - vd->current; - } - memcpy(ptr, vd->current, len); - vd->current += len; - return len; -} - - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { - ov_callbacks memory_callbacks = {0}; - memory_callbacks.read_func = read_func; - vorbis_data data_st; - data_st.size = Size; - data_st.current = Data; - data_st.data = Data; - OggVorbis_File vf; - int result = ov_open_callbacks(&data_st, &vf, NULL, 0, memory_callbacks); - if (result < 0) { - return 0; - } - int current_section = 0; - int eof = 0; - char buf[4096]; - int read_result; - while (!eof) { - read_result = ov_read(&vf, buf, sizeof(buf), 0, 2, 1, ¤t_section); - if (read_result != OV_HOLE && read_result <= 0) { - eof = 1; - } - } - ov_clear(&vf); - return 0; -} diff --git a/Engine/lib/libvorbis/debian/changelog b/Engine/lib/libvorbis/debian/changelog deleted file mode 100644 index fae34ba76..000000000 --- a/Engine/lib/libvorbis/debian/changelog +++ /dev/null @@ -1,208 +0,0 @@ -libvorbis (1.2.0.dfsg-3.1) unstable; urgency=high - - * Non-maintainer upload by the security team - * Fix integer overflows (and possible DoS attacks) via crafted - OGG files (Closes: #482518) - Fixes: CVE-2008-1423, CVE-2008-1420, CVE-2008-1419 - - -- Steffen Joeris Mon, 26 May 2008 12:48:06 +0000 - -libvorbis (1.2.0.dfsg-3) unstable; urgency=low - - * Use dpkg-gensymbols, with symbol files obtained from Mole (stripping - debian revision and .dfsg suffix). - - * Install upstream CHANGES file as changelog.gz. (Closes: #302037) - - * Bump debian/compat to 5, and Standards-Version to 3.7.3 (no changes - needed). - - * Use quilt.make in debian/rules. - - -- Adeodato Simó Thu, 27 Dec 2007 14:33:45 +0100 - -libvorbis (1.2.0.dfsg-2) unstable; urgency=high - - * Bump shlibs for libvorbis0a due to new vorbis_synthesis_idheader header. - (Closes: #436083) - - -- Adeodato Simó Tue, 14 Aug 2007 20:55:54 +0200 - -libvorbis (1.2.0.dfsg-1) unstable; urgency=low - - [ Adeodato Simó ] - * Use ${binary:Version} instead of ${Source-Version}. - - [ Clint Adams ] - * New upstream release. - - Remove upstream_r13198-fix_segfault_in_ov_time_seek.diff . - * Bump shlibs for libvorbisfile3 to >= 1.2.0 due to new ov_fopen - function. - - -- Clint Adams Fri, 27 Jul 2007 02:57:44 -0400 - -libvorbis (1.1.2.dfsg-2) unstable; urgency=low - - * Bump to Standards-Version 3.7.2. - * Add upstream_r13198-fix_segfault_in_ov_time_seek.diff. closes: #281995. - - -- Clint Adams Fri, 29 Jun 2007 09:46:12 -0400 - -libvorbis (1.1.2.dfsg-1.2) unstable; urgency=high - - * Fix shlibs files for libvorbisenc and libvorbisfile, which were broken - by my first NMU to have dependencies for libvorbis0a. Closes: #395048 - - -- Joey Hess Tue, 24 Oct 2006 19:55:19 -0400 - -libvorbis (1.1.2.dfsg-1.1) unstable; urgency=low - - * NMU - * Remove draft RFC files, as they are not under a free license. - Closes: #390660 - * Repackage the source package without these files. - * Add README.Source documenting how the upstream source is repackaged. - * Modify dh_makeshlibs call to avoid generating a shlibs file that has - an unncessarily tight versioned dependency on this new pseudo-version - of libvorbis. - - -- Joey Hess Sun, 15 Oct 2006 17:21:37 -0400 - -libvorbis (1.1.2-1) unstable; urgency=low - - * Switch maintenance to the Debian Xiph.org Maintainers (alioth/pkg-xiph). - - * New upstream release packaged. (Closes: #327586) - - * Move HTML documentation from /usr/share/doc/libvorbis-dev itself to an - html/ subdirectory of it. - - * Update debian/control: - + drop unnecessary build-dependency on devscripts. - + drop version restriction on debhelper and libogg-dev build-dependencies, - since they're already satisfied with stable. - - * Overhaul debian/rules, and switch to quilt for patch management. - - * Add debian/compat file, instead of exporting DH_COMPAT. - - * Update download URL in debian/copyright. - - * Add debian/watch file. - - * Bumped Standards-Version to 3.6.2 (no changes required). - - -- Adeodato Simó Thu, 26 Jan 2006 01:35:39 +0100 - -libvorbis (1.1.0-1) unstable; urgency=low - - * New upstream. - - -- Christopher L Cheney Thu, 17 Mar 2005 21:30:00 -0600 - -libvorbis (1.0.1-1) unstable; urgency=low - - * New upstream. - * Improved descriptions. (Closes: #166649) - * Updated DEB_BUILD_OPTIONS support. (Closes: #188464) - - -- Christopher L Cheney Tue, 9 Dec 2003 01:00:00 -0600 - -libvorbis (1.0.0-3) unstable; urgency=low - - * Add libvorbis0 conflict to libvorbis0a. - - -- Christopher L Cheney Wed, 12 Mar 2003 17:00:00 -0600 - -libvorbis (1.0.0-2) unstable; urgency=low - - * Rename libvorbis0 -> libvorbis0a to keep packages from upgrading to it - by mistake. (Closes: #156227, #156365, #161961, #171548, #172466, - #172469, #178756) - * GNU config automated update: config.sub (20020621 to 20030103), - config.guess (20020529 to 20030110) - - -- Christopher L Cheney Sat, 8 Mar 2003 13:00:00 -0600 - -libvorbis (1.0.0-1) unstable; urgency=low - - * New upstream. - * Split libvorbis package into libvorbis libvorbisenc libvorbisfile due to - shared object major versions going out of sync. - - -- Christopher L Cheney Fri, 19 Jul 2002 09:00:00 -0500 - -libvorbis (1.0rc3-1) unstable; urgency=low - - * New upstream. (Closes: #121995, #123472) - * added autotools target (config.* updater) to rules - - -- Christopher L Cheney Mon, 24 Dec 2001 11:00:00 -0600 - -libvorbis (1.0rc2-1) unstable; urgency=low - - * New upstream. - - -- Christopher L Cheney Sun, 12 Aug 2001 22:00:00 -0500 - -libvorbis (1.0rc1-1) unstable; urgency=low - - * New upstream. (Closes: #84977, #95330) - * Upstream says lame at fault. See bug details. (Closes: #98010) - * Fixed versioned depends. - * Changed clean method to distclean. - - -- Christopher L Cheney Sun, 17 Jun 2001 20:00:00 -0500 - -libvorbis (1.0beta4-1) unstable; urgency=low - - * New upstream. - * Appears to be fixed, can't reproduce bug (closes: #78848) - - -- Christopher L Cheney Mon, 26 Feb 2001 08:00:00 -0600 - -libvorbis (1.0beta3-3) unstable; urgency=low - - * Fixed Build-Depends libogg-dev version dependency. - * Fixed Sections. - * Updated to Standards-Version to 3.5.1.0 - - -- Christopher L Cheney Sat, 17 Feb 2001 18:14:53 -0600 - -libvorbis (1.0beta3-2) unstable; urgency=low - - * Added dependency for libogg-dev (closes: #78262) - * Added dependency for libogg-dev (closes: #81432) - * Corrected development library package name (closes: #82464) - - -- Christopher L Cheney Sat, 3 Feb 2001 13:29:30 -0600 - -libvorbis (1.0beta3-1) unstable; urgency=low - - * New Maintainer. - * Upstream source was reorganized. - * Package split according to the upstream reorganization. - - -- Christopher L Cheney Tue, 31 Oct 2000 15:08:22 -0600 - -vorbis (1.0beta2-1) unstable; urgency=low - - * New upstream version. Closes: #67326, #68416 - * Changed xmms-vorbis to Architechture: any. Closes: #67395 - * Added Build-deps. Closes: #66628 - * Moved vorbize to vorbis-tools along with oggenc and vorbiscomment - - -- Michael Beattie Wed, 9 Aug 2000 00:30:15 +1200 - -vorbis (1.0beta1-1) unstable; urgency=low - - * First Beta, Ready for debian release. - - -- Michael Beattie Fri, 30 Jun 2000 19:26:59 +1200 - -vorbis (0.0-1) unstable; urgency=low - - * Initial Release. - * Initial package, not placed in archive. - - -- Michael Beattie Mon, 26 Jun 2000 18:59:56 +1200 diff --git a/Engine/lib/libvorbis/debian/control b/Engine/lib/libvorbis/debian/control deleted file mode 100644 index b3f26469e..000000000 --- a/Engine/lib/libvorbis/debian/control +++ /dev/null @@ -1,60 +0,0 @@ -Source: libvorbis -Section: libs -Priority: optional -Maintainer: Christopher L Cheney -Build-Depends: autotools-dev, debhelper (>> 4.0.18), devscripts, libogg-dev (>> 1.1.0) -Standards-Version: 3.6.1.0 - -Package: libvorbis0a -Architecture: any -Section: libs -Depends: ${shlibs:Depends} -Conflicts: libvorbis0 -Replaces: libvorbis0 -Description: The Vorbis General Audio Compression Codec - Ogg Vorbis is a fully open, non-proprietary, patent-and-royalty-free, - general-purpose compressed audio format for audio and music at fixed - and variable bitrates from 16 to 128 kbps/channel. - . - The Vorbis library is the primary Ogg Vorbis library. - -Package: libvorbisenc2 -Architecture: any -Section: libs -Depends: ${shlibs:Depends} -Conflicts: libvorbis0 (<< 1.0.0) -Replaces: libvorbis0 (<< 1.0.0) -Description: The Vorbis General Audio Compression Codec - Ogg Vorbis is a fully open, non-proprietary, patent-and-royalty-free, - general-purpose compressed audio format for audio and music at fixed - and variable bitrates from 16 to 128 kbps/channel. - . - The Vorbisenc library provides a convenient API for setting up an encoding - environment using libvorbis. - -Package: libvorbisfile3 -Architecture: any -Section: libs -Depends: ${shlibs:Depends} -Conflicts: libvorbis0 (<< 1.0.0) -Replaces: libvorbis0 (<< 1.0.0) -Description: The Vorbis General Audio Compression Codec - Ogg Vorbis is a fully open, non-proprietary, patent-and-royalty-free, - general-purpose compressed audio format for audio and music at fixed - and variable bitrates from 16 to 128 kbps/channel. - . - The Vorbisfile library provides a convenient high-level API for decoding - and basic manipulation of all Vorbis I audio streams. - -Package: libvorbis-dev -Architecture: any -Section: libdevel -Depends: libogg-dev, libvorbis0a (= ${Source-Version}), libvorbisenc2 (= ${Source-Version}), libvorbisfile3 (= ${Source-Version}) -Description: The Vorbis General Audio Compression Codec (development files) - Ogg Vorbis is a fully open, non-proprietary, patent-and-royalty-free, - general-purpose compressed audio format for audio and music at fixed - and variable bitrates from 16 to 128 kbps/channel. - . - This package contains the header files and documentation needed to develop - applications with libvorbis. - diff --git a/Engine/lib/libvorbis/debian/copyright b/Engine/lib/libvorbis/debian/copyright deleted file mode 100644 index c6bf857ed..000000000 --- a/Engine/lib/libvorbis/debian/copyright +++ /dev/null @@ -1,38 +0,0 @@ -This package was debianized by Christopher L Cheney on -Tue, 31 Oct 2000 15:08:22 -0600. - -It was downloaded from https://downloads.xiph.org/releases/vorbis/ - -Upstream Author: Monty - -Copyright: - -Copyright (c) 2020, Xiph.org Foundation - -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 the Xiph.org Foundation nor the names of its -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 REGENTS 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. - diff --git a/Engine/lib/libvorbis/debian/libvorbis-dev.docs b/Engine/lib/libvorbis/debian/libvorbis-dev.docs deleted file mode 100644 index d1df5710a..000000000 --- a/Engine/lib/libvorbis/debian/libvorbis-dev.docs +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/share/doc/libvorbis-*/* diff --git a/Engine/lib/libvorbis/debian/libvorbis-dev.examples b/Engine/lib/libvorbis/debian/libvorbis-dev.examples deleted file mode 100644 index 1ae77b56a..000000000 --- a/Engine/lib/libvorbis/debian/libvorbis-dev.examples +++ /dev/null @@ -1,2 +0,0 @@ -examples/*.c -examples/*.pl diff --git a/Engine/lib/libvorbis/debian/libvorbis-dev.install b/Engine/lib/libvorbis/debian/libvorbis-dev.install deleted file mode 100644 index db22e5020..000000000 --- a/Engine/lib/libvorbis/debian/libvorbis-dev.install +++ /dev/null @@ -1,16 +0,0 @@ -debian/tmp/usr/include/vorbis/codec.h -debian/tmp/usr/include/vorbis/vorbisenc.h -debian/tmp/usr/include/vorbis/vorbisfile.h -debian/tmp/usr/lib/libvorbis.a -debian/tmp/usr/lib/libvorbis.la -debian/tmp/usr/lib/libvorbis.so -debian/tmp/usr/lib/libvorbisenc.a -debian/tmp/usr/lib/libvorbisenc.la -debian/tmp/usr/lib/libvorbisenc.so -debian/tmp/usr/lib/libvorbisfile.a -debian/tmp/usr/lib/libvorbisfile.la -debian/tmp/usr/lib/libvorbisfile.so -debian/tmp/usr/lib/pkgconfig/vorbis.pc -debian/tmp/usr/lib/pkgconfig/vorbisenc.pc -debian/tmp/usr/lib/pkgconfig/vorbisfile.pc -debian/tmp/usr/share/aclocal/vorbis.m4 diff --git a/Engine/lib/libvorbis/debian/libvorbis0a.install b/Engine/lib/libvorbis/debian/libvorbis0a.install deleted file mode 100644 index ad38b8b6d..000000000 --- a/Engine/lib/libvorbis/debian/libvorbis0a.install +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/lib/libvorbis.so.* diff --git a/Engine/lib/libvorbis/debian/libvorbisenc2.install b/Engine/lib/libvorbis/debian/libvorbisenc2.install deleted file mode 100644 index eb70258f3..000000000 --- a/Engine/lib/libvorbis/debian/libvorbisenc2.install +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/lib/libvorbisenc.so.* diff --git a/Engine/lib/libvorbis/debian/libvorbisfile3.install b/Engine/lib/libvorbis/debian/libvorbisfile3.install deleted file mode 100644 index 83bf445e6..000000000 --- a/Engine/lib/libvorbis/debian/libvorbisfile3.install +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/lib/libvorbisfile.so.* diff --git a/Engine/lib/libvorbis/debian/rules b/Engine/lib/libvorbis/debian/rules deleted file mode 100644 index 419ca7a32..000000000 --- a/Engine/lib/libvorbis/debian/rules +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/make -f -# Sample debian/rules that uses debhelper. -# GNU copyright 1997 to 1999 by Joey Hess. -# -# Modified to make a template file for a multi-binary package with separated -# build-arch and build-indep targets by Bill Allombert 2001 - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -# This is the debhelper compatibility version to use. -export DH_COMPAT=4 - -# This has to be exported to make some magic below work. -export DH_OPTIONS - -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) - -objdir = $(CURDIR)/obj-$(DEB_BUILD_GNU_TYPE) - -CFLAGS = -Wall -g - -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif -ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) - INSTALL_PROGRAM += -s -endif - -configure: configure-stamp -configure-stamp: - dh_testdir - - # make build directory - mkdir $(objdir) - - # run configure with build tree $(objdir) - # change ../configure to ../autogen.sh for CVS build - cd $(objdir) && \ - ../configure --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \ - --prefix=/usr --enable-static - - touch configure-stamp - -#Architecture -build: build-arch build-indep - -build-arch: build-arch-stamp -build-arch-stamp: configure-stamp - - cd $(objdir) && \ - $(MAKE) - - touch build-arch-stamp - -build-indep: build-indep-stamp -build-indep-stamp: configure-stamp - - # Add here commands to compile the indep part of the package. - #$(MAKE) doc - touch build-indep-stamp - -debian-clean: - dh_testdir - dh_testroot - - dh_clean - -clean: - dh_testdir - dh_testroot - rm -f build-arch-stamp build-indep-stamp configure-stamp - - # Remove build tree - rm -rf $(objdir) - - # if Makefile exists run distclean - if test -f Makefile; then \ - $(MAKE) distclean; \ - fi - - #if test -d CVS; then \ - $(MAKE) cvs-clean ;\ - fi - - dh_clean - -install: install-indep install-arch -install-indep: - dh_testdir - dh_testroot -# dh_clean -k -i -# dh_installdirs -i - -# dh_install -i --list-missing - -install-arch: - dh_testdir - dh_testroot - dh_clean -k -s - dh_installdirs -s - - cd $(objdir) && \ - $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp - - dh_install -s --list-missing - -# Must not depend on anything. This is to be called by -# binary-arch/binary-indep -# in another 'make' thread. -binary-common: - dh_testdir - dh_testroot - dh_installchangelogs CHANGES - dh_installdocs - dh_installexamples -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_perl -# dh_python - dh_makeshlibs -V - dh_installdeb - dh_shlibdeps -ldebian/libvorbis0a/usr/lib - dh_gencontrol - dh_md5sums - dh_builddeb - -# Build architecture independant packages using the common target. -binary-indep: build-indep install-indep -# $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common - -# Build architecture dependant packages using the common target. -binary-arch: build-arch install-arch - $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common - -binary: binary-arch binary-indep -.PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure diff --git a/Engine/lib/libvorbis/debian/watch b/Engine/lib/libvorbis/debian/watch deleted file mode 100644 index 3a050841c..000000000 --- a/Engine/lib/libvorbis/debian/watch +++ /dev/null @@ -1,3 +0,0 @@ -version=2 - -https://downloads.xiph.org/releases/vorbis/libvorbis-(.*)\.tar\.gz debian uupdate diff --git a/Engine/lib/libvorbis/doc/01-introduction.tex b/Engine/lib/libvorbis/doc/01-introduction.tex deleted file mode 100644 index d7767df08..000000000 --- a/Engine/lib/libvorbis/doc/01-introduction.tex +++ /dev/null @@ -1,528 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Introduction and Description} \label{vorbis:spec:intro} - -\subsection{Overview} - -This document provides a high level description of the Vorbis codec's -construction. A bit-by-bit specification appears beginning in -\xref{vorbis:spec:codec}. -The later sections assume a high-level -understanding of the Vorbis decode process, which is -provided here. - -\subsubsection{Application} -Vorbis is a general purpose perceptual audio CODEC intended to allow -maximum encoder flexibility, thus allowing it to scale competitively -over an exceptionally wide range of bitrates. At the high -quality/bitrate end of the scale (CD or DAT rate stereo, 16/24 bits) -it is in the same league as MPEG-2 and MPC. Similarly, the 1.0 -encoder can encode high-quality CD and DAT rate stereo at below 48kbps -without resampling to a lower rate. Vorbis is also intended for -lower and higher sample rates (from 8kHz telephony to 192kHz digital -masters) and a range of channel representations (monaural, -polyphonic, stereo, quadraphonic, 5.1, ambisonic, or up to 255 -discrete channels). - - -\subsubsection{Classification} -Vorbis I is a forward-adaptive monolithic transform CODEC based on the -Modified Discrete Cosine Transform. The codec is structured to allow -addition of a hybrid wavelet filterbank in Vorbis II to offer better -transient response and reproduction using a transform better suited to -localized time events. - - -\subsubsection{Assumptions} - -The Vorbis CODEC design assumes a complex, psychoacoustically-aware -encoder and simple, low-complexity decoder. Vorbis decode is -computationally simpler than mp3, although it does require more -working memory as Vorbis has no static probability model; the vector -codebooks used in the first stage of decoding from the bitstream are -packed in their entirety into the Vorbis bitstream headers. In -packed form, these codebooks occupy only a few kilobytes; the extent -to which they are pre-decoded into a cache is the dominant factor in -decoder memory usage. - - -Vorbis provides none of its own framing, synchronization or protection -against errors; it is solely a method of accepting input audio, -dividing it into individual frames and compressing these frames into -raw, unformatted 'packets'. The decoder then accepts these raw -packets in sequence, decodes them, synthesizes audio frames from -them, and reassembles the frames into a facsimile of the original -audio stream. Vorbis is a free-form variable bit rate (VBR) codec and packets have no -minimum size, maximum size, or fixed/expected size. Packets -are designed that they may be truncated (or padded) and remain -decodable; this is not to be considered an error condition and is used -extensively in bitrate management in peeling. Both the transport -mechanism and decoder must allow that a packet may be any size, or -end before or after packet decode expects. - -Vorbis packets are thus intended to be used with a transport mechanism -that provides free-form framing, sync, positioning and error correction -in accordance with these design assumptions, such as Ogg (for file -transport) or RTP (for network multicast). For purposes of a few -examples in this document, we will assume that Vorbis is to be -embedded in an Ogg stream specifically, although this is by no means a -requirement or fundamental assumption in the Vorbis design. - -The specification for embedding Vorbis into -an Ogg transport stream is in \xref{vorbis:over:ogg}. - - - -\subsubsection{Codec Setup and Probability Model} - -Vorbis' heritage is as a research CODEC and its current design -reflects a desire to allow multiple decades of continuous encoder -improvement before running out of room within the codec specification. -For these reasons, configurable aspects of codec setup intentionally -lean toward the extreme of forward adaptive. - -The single most controversial design decision in Vorbis (and the most -unusual for a Vorbis developer to keep in mind) is that the entire -probability model of the codec, the Huffman and VQ codebooks, is -packed into the bitstream header along with extensive CODEC setup -parameters (often several hundred fields). This makes it impossible, -as it would be with MPEG audio layers, to embed a simple frame type -flag in each audio packet, or begin decode at any frame in the stream -without having previously fetched the codec setup header. - - -\begin{note} -Vorbis \emph{can} initiate decode at any arbitrary packet within a -bitstream so long as the codec has been initialized/setup with the -setup headers. -\end{note} - -Thus, Vorbis headers are both required for decode to begin and -relatively large as bitstream headers go. The header size is -unbounded, although for streaming a rule-of-thumb of 4kB or less is -recommended (and Xiph.Org's Vorbis encoder follows this suggestion). - -Our own design work indicates the primary liability of the -required header is in mindshare; it is an unusual design and thus -causes some amount of complaint among engineers as this runs against -current design trends (and also points out limitations in some -existing software/interface designs, such as Windows' ACM codec -framework). However, we find that it does not fundamentally limit -Vorbis' suitable application space. - - -\subsubsection{Format Specification} -The Vorbis format is well-defined by its decode specification; any -encoder that produces packets that are correctly decoded by the -reference Vorbis decoder described below may be considered a proper -Vorbis encoder. A decoder must faithfully and completely implement -the specification defined below (except where noted) to be considered -a proper Vorbis decoder. - -\subsubsection{Hardware Profile} -Although Vorbis decode is computationally simple, it may still run -into specific limitations of an embedded design. For this reason, -embedded designs are allowed to deviate in limited ways from the -`full' decode specification yet still be certified compliant. These -optional omissions are labelled in the spec where relevant. - - -\subsection{Decoder Configuration} - -Decoder setup consists of configuration of multiple, self-contained -component abstractions that perform specific functions in the decode -pipeline. Each different component instance of a specific type is -semantically interchangeable; decoder configuration consists both of -internal component configuration, as well as arrangement of specific -instances into a decode pipeline. Componentry arrangement is roughly -as follows: - -\begin{center} -\includegraphics[width=\textwidth]{components} -\captionof{figure}{decoder pipeline configuration} -\end{center} - -\subsubsection{Global Config} -Global codec configuration consists of a few audio related fields -(sample rate, channels), Vorbis version (always '0' in Vorbis I), -bitrate hints, and the lists of component instances. All other -configuration is in the context of specific components. - -\subsubsection{Mode} - -Each Vorbis frame is coded according to a master 'mode'. A bitstream -may use one or many modes. - -The mode mechanism is used to encode a frame according to one of -multiple possible methods with the intention of choosing a method best -suited to that frame. Different modes are, e.g. how frame size -is changed from frame to frame. The mode number of a frame serves as a -top level configuration switch for all other specific aspects of frame -decode. - -A 'mode' configuration consists of a frame size setting, window type -(always 0, the Vorbis window, in Vorbis I), transform type (always -type 0, the MDCT, in Vorbis I) and a mapping number. The mapping -number specifies which mapping configuration instance to use for -low-level packet decode and synthesis. - - -\subsubsection{Mapping} - -A mapping contains a channel coupling description and a list of -'submaps' that bundle sets of channel vectors together for grouped -encoding and decoding. These submaps are not references to external -components; the submap list is internal and specific to a mapping. - -A 'submap' is a configuration/grouping that applies to a subset of -floor and residue vectors within a mapping. The submap functions as a -last layer of indirection such that specific special floor or residue -settings can be applied not only to all the vectors in a given mode, -but also specific vectors in a specific mode. Each submap specifies -the proper floor and residue instance number to use for decoding that -submap's spectral floor and spectral residue vectors. - -As an example: - -Assume a Vorbis stream that contains six channels in the standard 5.1 -format. The sixth channel, as is normal in 5.1, is bass only. -Therefore it would be wasteful to encode a full-spectrum version of it -as with the other channels. The submapping mechanism can be used to -apply a full range floor and residue encoding to channels 0 through 4, -and a bass-only representation to the bass channel, thus saving space. -In this example, channels 0-4 belong to submap 0 (which indicates use -of a full-range floor) and channel 5 belongs to submap 1, which uses a -bass-only representation. - - -\subsubsection{Floor} - -Vorbis encodes a spectral 'floor' vector for each PCM channel. This -vector is a low-resolution representation of the audio spectrum for -the given channel in the current frame, generally used akin to a -whitening filter. It is named a 'floor' because the Xiph.Org -reference encoder has historically used it as a unit-baseline for -spectral resolution. - -A floor encoding may be of two types. Floor 0 uses a packed LSP -representation on a dB amplitude scale and Bark frequency scale. -Floor 1 represents the curve as a piecewise linear interpolated -representation on a dB amplitude scale and linear frequency scale. -The two floors are semantically interchangeable in -encoding/decoding. However, floor type 1 provides more stable -inter-frame behavior, and so is the preferred choice in all -coupled-stereo and high bitrate modes. Floor 1 is also considerably -less expensive to decode than floor 0. - -Floor 0 is not to be considered deprecated, but it is of limited -modern use. No known Vorbis encoder past Xiph.Org's own beta 4 makes -use of floor 0. - -The values coded/decoded by a floor are both compactly formatted and -make use of entropy coding to save space. For this reason, a floor -configuration generally refers to multiple codebooks in the codebook -component list. Entropy coding is thus provided as an abstraction, -and each floor instance may choose from any and all available -codebooks when coding/decoding. - - -\subsubsection{Residue} -The spectral residue is the fine structure of the audio spectrum -once the floor curve has been subtracted out. In simplest terms, it -is coded in the bitstream using cascaded (multi-pass) vector -quantization according to one of three specific packing/coding -algorithms numbered 0 through 2. The packing algorithm details are -configured by residue instance. As with the floor components, the -final VQ/entropy encoding is provided by external codebook instances -and each residue instance may choose from any and all available -codebooks. - -\subsubsection{Codebooks} - -Codebooks are a self-contained abstraction that perform entropy -decoding and, optionally, use the entropy-decoded integer value as an -offset into an index of output value vectors, returning the indicated -vector of values. - -The entropy coding in a Vorbis I codebook is provided by a standard -Huffman binary tree representation. This tree is tightly packed using -one of several methods, depending on whether codeword lengths are -ordered or unordered, or the tree is sparse. - -The codebook vector index is similarly packed according to index -characteristic. Most commonly, the vector index is encoded as a -single list of values of possible values that are then permuted into -a list of n-dimensional rows (lattice VQ). - - - -\subsection{High-level Decode Process} - -\subsubsection{Decode Setup} - -Before decoding can begin, a decoder must initialize using the -bitstream headers matching the stream to be decoded. Vorbis uses -three header packets; all are required, in-order, by this -specification. Once set up, decode may begin at any audio packet -belonging to the Vorbis stream. In Vorbis I, all packets after the -three initial headers are audio packets. - -The header packets are, in order, the identification -header, the comments header, and the setup header. - -\paragraph{Identification Header} -The identification header identifies the bitstream as Vorbis, Vorbis -version, and the simple audio characteristics of the stream such as -sample rate and number of channels. - -\paragraph{Comment Header} -The comment header includes user text comments (``tags'') and a vendor -string for the application/library that produced the bitstream. The -encoding and proper use of the comment header is described in \xref{vorbis:spec:comment}. - -\paragraph{Setup Header} -The setup header includes extensive CODEC setup information as well as -the complete VQ and Huffman codebooks needed for decode. - - -\subsubsection{Decode Procedure} - -The decoding and synthesis procedure for all audio packets is -fundamentally the same. -\begin{enumerate} -\item decode packet type flag -\item decode mode number -\item decode window shape (long windows only) -\item decode floor -\item decode residue into residue vectors -\item inverse channel coupling of residue vectors -\item generate floor curve from decoded floor data -\item compute dot product of floor and residue, producing audio spectrum vector -\item inverse monolithic transform of audio spectrum vector, always an MDCT in Vorbis I -\item overlap/add left-hand output of transform with right-hand output of previous frame -\item store right hand-data from transform of current frame for future lapping -\item if not first frame, return results of overlap/add as audio result of current frame -\end{enumerate} - -Note that clever rearrangement of the synthesis arithmetic is -possible; as an example, one can take advantage of symmetries in the -MDCT to store the right-hand transform data of a partial MDCT for a -50\% inter-frame buffer space savings, and then complete the transform -later before overlap/add with the next frame. This optimization -produces entirely equivalent output and is naturally perfectly legal. -The decoder must be \emph{entirely mathematically equivalent} to the -specification, it need not be a literal semantic implementation. - -\paragraph{Packet type decode} - -Vorbis I uses four packet types. The first three packet types mark each -of the three Vorbis headers described above. The fourth packet type -marks an audio packet. All other packet types are reserved; packets -marked with a reserved type should be ignored. - -Following the three header packets, all packets in a Vorbis I stream -are audio. The first step of audio packet decode is to read and -verify the packet type; \emph{a non-audio packet when audio is expected -indicates stream corruption or a non-compliant stream. The decoder -must ignore the packet and not attempt decoding it to -audio}. - - - - -\paragraph{Mode decode} -Vorbis allows an encoder to set up multiple, numbered packet 'modes', -as described earlier, all of which may be used in a given Vorbis -stream. The mode is encoded as an integer used as a direct offset into -the mode instance index. - - -\paragraph{Window shape decode (long windows only)} \label{vorbis:spec:window} - -Vorbis frames may be one of two PCM sample sizes specified during -codec setup. In Vorbis I, legal frame sizes are powers of two from 64 -to 8192 samples. Aside from coupling, Vorbis handles channels as -independent vectors and these frame sizes are in samples per channel. - -Vorbis uses an overlapping transform, namely the MDCT, to blend one -frame into the next, avoiding most inter-frame block boundary -artifacts. The MDCT output of one frame is windowed according to MDCT -requirements, overlapped 50\% with the output of the previous frame and -added. The window shape assures seamless reconstruction. - -This is easy to visualize in the case of equal sized-windows: - -\begin{center} -\includegraphics[width=\textwidth]{window1} -\captionof{figure}{overlap of two equal-sized windows} -\end{center} - -And slightly more complex in the case of overlapping unequal sized -windows: - -\begin{center} -\includegraphics[width=\textwidth]{window2} -\captionof{figure}{overlap of a long and a short window} -\end{center} - -In the unequal-sized window case, the window shape of the long window -must be modified for seamless lapping as above. It is possible to -correctly infer window shape to be applied to the current window from -knowing the sizes of the current, previous and next window. It is -legal for a decoder to use this method. However, in the case of a long -window (short windows require no modification), Vorbis also codes two -flag bits to specify pre- and post- window shape. Although not -strictly necessary for function, this minor redundancy allows a packet -to be fully decoded to the point of lapping entirely independently of -any other packet, allowing easier abstraction of decode layers as well -as allowing a greater level of easy parallelism in encode and -decode. - -A description of valid window functions for use with an inverse MDCT -can be found in \cite{Sporer/Brandenburg/Edler}. Vorbis windows -all use the slope function -\[ y = \sin(.5*\pi \, \sin^2((x+.5)/n*\pi)) . \] - - - -\paragraph{floor decode} -Each floor is encoded/decoded in channel order, however each floor -belongs to a 'submap' that specifies which floor configuration to -use. All floors are decoded before residue decode begins. - - -\paragraph{residue decode} - -Although the number of residue vectors equals the number of channels, -channel coupling may mean that the raw residue vectors extracted -during decode do not map directly to specific channels. When channel -coupling is in use, some vectors will correspond to coupled magnitude -or angle. The coupling relationships are described in the codec setup -and may differ from frame to frame, due to different mode numbers. - -Vorbis codes residue vectors in groups by submap; the coding is done -in submap order from submap 0 through n-1. This differs from floors -which are coded using a configuration provided by submap number, but -are coded individually in channel order. - - - -\paragraph{inverse channel coupling} - -A detailed discussion of stereo in the Vorbis codec can be found in -the document \href{stereo.html}{Stereo Channel Coupling in the -Vorbis CODEC}. Vorbis is not limited to only stereo coupling, but -the stereo document also gives a good overview of the generic coupling -mechanism. - -Vorbis coupling applies to pairs of residue vectors at a time; -decoupling is done in-place a pair at a time in the order and using -the vectors specified in the current mapping configuration. The -decoupling operation is the same for all pairs, converting square -polar representation (where one vector is magnitude and the second -angle) back to Cartesian representation. - -After decoupling, in order, each pair of vectors on the coupling list, -the resulting residue vectors represent the fine spectral detail -of each output channel. - - - -\paragraph{generate floor curve} - -The decoder may choose to generate the floor curve at any appropriate -time. It is reasonable to generate the output curve when the floor -data is decoded from the raw packet, or it can be generated after -inverse coupling and applied to the spectral residue directly, -combining generation and the dot product into one step and eliminating -some working space. - -Both floor 0 and floor 1 generate a linear-range, linear-domain output -vector to be multiplied (dot product) by the linear-range, -linear-domain spectral residue. - - - -\paragraph{compute floor/residue dot product} - -This step is straightforward; for each output channel, the decoder -multiplies the floor curve and residue vectors element by element, -producing the finished audio spectrum of each channel. - -% TODO/FIXME: The following two paragraphs have identical twins -% in section 4 (under "dot product") -One point is worth mentioning about this dot product; a common mistake -in a fixed point implementation might be to assume that a 32 bit -fixed-point representation for floor and residue and direct -multiplication of the vectors is sufficient for acceptable spectral -depth in all cases because it happens to mostly work with the current -Xiph.Org reference encoder. - -However, floor vector values can span \~{}140dB (\~{}24 bits unsigned), and -the audio spectrum vector should represent a minimum of 120dB (\~{}21 -bits with sign), even when output is to a 16 bit PCM device. For the -residue vector to represent full scale if the floor is nailed to -$-140$dB, it must be able to span 0 to $+140$dB. For the residue vector -to reach full scale if the floor is nailed at 0dB, it must be able to -represent $-140$dB to $+0$dB. Thus, in order to handle full range -dynamics, a residue vector may span $-140$dB to $+140$dB entirely within -spec. A 280dB range is approximately 48 bits with sign; thus the -residue vector must be able to represent a 48 bit range and the dot -product must be able to handle an effective 48 bit times 24 bit -multiplication. This range may be achieved using large (64 bit or -larger) integers, or implementing a movable binary point -representation. - - - -\paragraph{inverse monolithic transform (MDCT)} - -The audio spectrum is converted back into time domain PCM audio via an -inverse Modified Discrete Cosine Transform (MDCT). A detailed -description of the MDCT is available in \cite{Sporer/Brandenburg/Edler}. - -Note that the PCM produced directly from the MDCT is not yet finished -audio; it must be lapped with surrounding frames using an appropriate -window (such as the Vorbis window) before the MDCT can be considered -orthogonal. - - - -\paragraph{overlap/add data} -Windowed MDCT output is overlapped and added with the right hand data -of the previous window such that the 3/4 point of the previous window -is aligned with the 1/4 point of the current window (as illustrated in -the window overlap diagram). At this point, the audio data between the -center of the previous frame and the center of the current frame is -now finished and ready to be returned. - - -\paragraph{cache right hand data} -The decoder must cache the right hand portion of the current frame to -be lapped with the left hand portion of the next frame. - - - -\paragraph{return finished audio data} - -The overlapped portion produced from overlapping the previous and -current frame data is finished data to be returned by the decoder. -This data spans from the center of the previous window to the center -of the current window. In the case of same-sized windows, the amount -of data to return is one-half block consisting of and only of the -overlapped portions. When overlapping a short and long window, much of -the returned range is not actually overlap. This does not damage -transform orthogonality. Pay attention however to returning the -correct data range; the amount of data to be returned is: - -\begin{Verbatim}[commandchars=\\\{\}] -window\_blocksize(previous\_window)/4+window\_blocksize(current\_window)/4 -\end{Verbatim} - -from the center of the previous window to the center of the current -window. - -Data is not returned from the first frame; it must be used to 'prime' -the decode engine. The encoder accounts for this priming when -calculating PCM offsets; after the first frame, the proper PCM output -offset is '0' (as no data has been returned yet). diff --git a/Engine/lib/libvorbis/doc/02-bitpacking.tex b/Engine/lib/libvorbis/doc/02-bitpacking.tex deleted file mode 100644 index 905dcaf25..000000000 --- a/Engine/lib/libvorbis/doc/02-bitpacking.tex +++ /dev/null @@ -1,246 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Bitpacking Convention} \label{vorbis:spec:bitpacking} - -\subsection{Overview} - -The Vorbis codec uses relatively unstructured raw packets containing -arbitrary-width binary integer fields. Logically, these packets are a -bitstream in which bits are coded one-by-one by the encoder and then -read one-by-one in the same monotonically increasing order by the -decoder. Most current binary storage arrangements group bits into a -native word size of eight bits (octets), sixteen bits, thirty-two bits -or, less commonly other fixed word sizes. The Vorbis bitpacking -convention specifies the correct mapping of the logical packet -bitstream into an actual representation in fixed-width words. - - -\subsubsection{octets, bytes and words} - -In most contemporary architectures, a 'byte' is synonymous with an -'octet', that is, eight bits. This has not always been the case; -seven, ten, eleven and sixteen bit 'bytes' have been used. For -purposes of the bitpacking convention, a byte implies the native, -smallest integer storage representation offered by a platform. On -modern platforms, this is generally assumed to be eight bits (not -necessarily because of the processor but because of the -filesystem/memory architecture. Modern filesystems invariably offer -bytes as the fundamental atom of storage). A 'word' is an integer -size that is a grouped multiple of this smallest size. - -The most ubiquitous architectures today consider a 'byte' to be an -octet (eight bits) and a word to be a group of two, four or eight -bytes (16, 32 or 64 bits). Note however that the Vorbis bitpacking -convention is still well defined for any native byte size; Vorbis uses -the native bit-width of a given storage system. This document assumes -that a byte is one octet for purposes of example. - -\subsubsection{bit order} - -A byte has a well-defined 'least significant' bit (LSb), which is the -only bit set when the byte is storing the two's complement integer -value +1. A byte's 'most significant' bit (MSb) is at the opposite -end of the byte. Bits in a byte are numbered from zero at the LSb to -$n$ ($n=7$ in an octet) for the -MSb. - - - -\subsubsection{byte order} - -Words are native groupings of multiple bytes. Several byte orderings -are possible in a word; the common ones are 3-2-1-0 ('big endian' or -'most significant byte first' in which the highest-valued byte comes -first), 0-1-2-3 ('little endian' or 'least significant byte first' in -which the lowest value byte comes first) and less commonly 3-1-2-0 and -0-2-1-3 ('mixed endian'). - -The Vorbis bitpacking convention specifies storage and bitstream -manipulation at the byte, not word, level, thus host word ordering is -of a concern only during optimization when writing high performance -code that operates on a word of storage at a time rather than by byte. -Logically, bytes are always coded and decoded in order from byte zero -through byte $n$. - - - -\subsubsection{coding bits into byte sequences} - -The Vorbis codec has need to code arbitrary bit-width integers, from -zero to 32 bits wide, into packets. These integer fields are not -aligned to the boundaries of the byte representation; the next field -is written at the bit position at which the previous field ends. - -The encoder logically packs integers by writing the LSb of a binary -integer to the logical bitstream first, followed by next least -significant bit, etc, until the requested number of bits have been -coded. When packing the bits into bytes, the encoder begins by -placing the LSb of the integer to be written into the least -significant unused bit position of the destination byte, followed by -the next-least significant bit of the source integer and so on up to -the requested number of bits. When all bits of the destination byte -have been filled, encoding continues by zeroing all bits of the next -byte and writing the next bit into the bit position 0 of that byte. -Decoding follows the same process as encoding, but by reading bits -from the byte stream and reassembling them into integers. - - - -\subsubsection{signedness} - -The signedness of a specific number resulting from decode is to be -interpreted by the decoder given decode context. That is, the three -bit binary pattern 'b111' can be taken to represent either 'seven' as -an unsigned integer, or '-1' as a signed, two's complement integer. -The encoder and decoder are responsible for knowing if fields are to -be treated as signed or unsigned. - - - -\subsubsection{coding example} - -Code the 4 bit integer value '12' [b1100] into an empty bytestream. -Bytestream result: - -\begin{Verbatim}[commandchars=\\\{\}] - | - V - - 7 6 5 4 3 2 1 0 -byte 0 [0 0 0 0 1 1 0 0] <- -byte 1 [ ] -byte 2 [ ] -byte 3 [ ] - ... -byte n [ ] bytestream length == 1 byte - -\end{Verbatim} - - -Continue by coding the 3 bit integer value '-1' [b111]: - -\begin{Verbatim}[commandchars=\\\{\}] - | - V - - 7 6 5 4 3 2 1 0 -byte 0 [0 1 1 1 1 1 0 0] <- -byte 1 [ ] -byte 2 [ ] -byte 3 [ ] - ... -byte n [ ] bytestream length == 1 byte -\end{Verbatim} - - -Continue by coding the 7 bit integer value '17' [b0010001]: - -\begin{Verbatim}[commandchars=\\\{\}] - | - V - - 7 6 5 4 3 2 1 0 -byte 0 [1 1 1 1 1 1 0 0] -byte 1 [0 0 0 0 1 0 0 0] <- -byte 2 [ ] -byte 3 [ ] - ... -byte n [ ] bytestream length == 2 bytes - bit cursor == 6 -\end{Verbatim} - - -Continue by coding the 13 bit integer value '6969' [b110 11001110 01]: - -\begin{Verbatim}[commandchars=\\\{\}] - | - V - - 7 6 5 4 3 2 1 0 -byte 0 [1 1 1 1 1 1 0 0] -byte 1 [0 1 0 0 1 0 0 0] -byte 2 [1 1 0 0 1 1 1 0] -byte 3 [0 0 0 0 0 1 1 0] <- - ... -byte n [ ] bytestream length == 4 bytes - -\end{Verbatim} - - - - -\subsubsection{decoding example} - -Reading from the beginning of the bytestream encoded in the above example: - -\begin{Verbatim}[commandchars=\\\{\}] - | - V - - 7 6 5 4 3 2 1 0 -byte 0 [1 1 1 1 1 1 0 0] <- -byte 1 [0 1 0 0 1 0 0 0] -byte 2 [1 1 0 0 1 1 1 0] -byte 3 [0 0 0 0 0 1 1 0] bytestream length == 4 bytes - -\end{Verbatim} - - -We read two, two-bit integer fields, resulting in the returned numbers -'b00' and 'b11'. Two things are worth noting here: - -\begin{itemize} -\item Although these four bits were originally written as a single -four-bit integer, reading some other combination of bit-widths from the -bitstream is well defined. There are no artificial alignment -boundaries maintained in the bitstream. - -\item The second value is the -two-bit-wide integer 'b11'. This value may be interpreted either as -the unsigned value '3', or the signed value '-1'. Signedness is -dependent on decode context. -\end{itemize} - - - - -\subsubsection{end-of-packet alignment} - -The typical use of bitpacking is to produce many independent -byte-aligned packets which are embedded into a larger byte-aligned -container structure, such as an Ogg transport bitstream. Externally, -each bytestream (encoded bitstream) must begin and end on a byte -boundary. Often, the encoded bitstream is not an integer number of -bytes, and so there is unused (uncoded) space in the last byte of a -packet. - -Unused space in the last byte of a bytestream is always zeroed during -the coding process. Thus, should this unused space be read, it will -return binary zeroes. - -Attempting to read past the end of an encoded packet results in an -'end-of-packet' condition. End-of-packet is not to be considered an -error; it is merely a state indicating that there is insufficient -remaining data to fulfill the desired read size. Vorbis uses truncated -packets as a normal mode of operation, and as such, decoders must -handle reading past the end of a packet as a typical mode of -operation. Any further read operations after an 'end-of-packet' -condition shall also return 'end-of-packet'. - - - -\subsubsection{reading zero bits} - -Reading a zero-bit-wide integer returns the value '0' and does not -increment the stream cursor. Reading to the end of the packet (but -not past, such that an 'end-of-packet' condition has not triggered) -and then reading a zero bit integer shall succeed, returning 0, and -not trigger an end-of-packet condition. Reading a zero-bit-wide -integer after a previous read sets 'end-of-packet' shall also fail -with 'end-of-packet'. - - - - - - diff --git a/Engine/lib/libvorbis/doc/03-codebook.tex b/Engine/lib/libvorbis/doc/03-codebook.tex deleted file mode 100644 index 11516a3bb..000000000 --- a/Engine/lib/libvorbis/doc/03-codebook.tex +++ /dev/null @@ -1,456 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Probability Model and Codebooks} \label{vorbis:spec:codebook} - -\subsection{Overview} - -Unlike practically every other mainstream audio codec, Vorbis has no -statically configured probability model, instead packing all entropy -decoding configuration, VQ and Huffman, into the bitstream itself in -the third header, the codec setup header. This packed configuration -consists of multiple 'codebooks', each containing a specific -Huffman-equivalent representation for decoding compressed codewords as -well as an optional lookup table of output vector values to which a -decoded Huffman value is applied as an offset, generating the final -decoded output corresponding to a given compressed codeword. - -\subsubsection{Bitwise operation} -The codebook mechanism is built on top of the vorbis bitpacker. Both -the codebooks themselves and the codewords they decode are unrolled -from a packet as a series of arbitrary-width values read from the -stream according to \xref{vorbis:spec:bitpacking}. - - - - -\subsection{Packed codebook format} - -For purposes of the examples below, we assume that the storage -system's native byte width is eight bits. This is not universally -true; see \xref{vorbis:spec:bitpacking} for discussion -relating to non-eight-bit bytes. - -\subsubsection{codebook decode} - -A codebook begins with a 24 bit sync pattern, 0x564342: - -\begin{Verbatim}[commandchars=\\\{\}] -byte 0: [ 0 1 0 0 0 0 1 0 ] (0x42) -byte 1: [ 0 1 0 0 0 0 1 1 ] (0x43) -byte 2: [ 0 1 0 1 0 1 1 0 ] (0x56) -\end{Verbatim} - -16 bit \varname{[codebook\_dimensions]} and 24 bit \varname{[codebook\_entries]} fields: - -\begin{Verbatim}[commandchars=\\\{\}] - -byte 3: [ X X X X X X X X ] -byte 4: [ X X X X X X X X ] [codebook\_dimensions] (16 bit unsigned) - -byte 5: [ X X X X X X X X ] -byte 6: [ X X X X X X X X ] -byte 7: [ X X X X X X X X ] [codebook\_entries] (24 bit unsigned) - -\end{Verbatim} - -Next is the \varname{[ordered]} bit flag: - -\begin{Verbatim}[commandchars=\\\{\}] - -byte 8: [ X ] [ordered] (1 bit) - -\end{Verbatim} - -Each entry, numbering a -total of \varname{[codebook\_entries]}, is assigned a codeword length. -We now read the list of codeword lengths and store these lengths in -the array \varname{[codebook\_codeword\_lengths]}. Decode of lengths is -according to whether the \varname{[ordered]} flag is set or unset. - -\begin{itemize} -\item - If the \varname{[ordered]} flag is unset, the codeword list is not - length ordered and the decoder needs to read each codeword length - one-by-one. - - The decoder first reads one additional bit flag, the - \varname{[sparse]} flag. This flag determines whether or not the - codebook contains unused entries that are not to be included in the - codeword decode tree: - -\begin{Verbatim}[commandchars=\\\{\}] -byte 8: [ X 1 ] [sparse] flag (1 bit) -\end{Verbatim} - - The decoder now performs for each of the \varname{[codebook\_entries]} - codebook entries: - -\begin{Verbatim}[commandchars=\\\{\}] - - 1) if([sparse] is set) \{ - - 2) [flag] = read one bit; - 3) if([flag] is set) \{ - - 4) [length] = read a five bit unsigned integer; - 5) codeword length for this entry is [length]+1; - - \} else \{ - - 6) this entry is unused. mark it as such. - - \} - - \} else the sparse flag is not set \{ - - 7) [length] = read a five bit unsigned integer; - 8) the codeword length for this entry is [length]+1; - - \} - -\end{Verbatim} - -\item - If the \varname{[ordered]} flag is set, the codeword list for this - codebook is encoded in ascending length order. Rather than reading - a length for every codeword, the encoder reads the number of - codewords per length. That is, beginning at entry zero: - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [current\_entry] = 0; - 2) [current\_length] = read a five bit unsigned integer and add 1; - 3) [number] = read \link{vorbis:spec:ilog}{ilog}([codebook\_entries] - [current\_entry]) bits as an unsigned integer - 4) set the entries [current\_entry] through [current\_entry]+[number]-1, inclusive, - of the [codebook\_codeword\_lengths] array to [current\_length] - 5) set [current\_entry] to [number] + [current\_entry] - 6) increment [current\_length] by 1 - 7) if [current\_entry] is greater than [codebook\_entries] ERROR CONDITION; - the decoder will not be able to read this stream. - 8) if [current\_entry] is less than [codebook\_entries], repeat process starting at 3) - 9) done. -\end{Verbatim} - -\end{itemize} - -After all codeword lengths have been decoded, the decoder reads the -vector lookup table. Vorbis I supports three lookup types: -\begin{enumerate} -\item -No lookup -\item -Implicitly populated value mapping (lattice VQ) -\item -Explicitly populated value mapping (tessellated or 'foam' -VQ) -\end{enumerate} - - -The lookup table type is read as a four bit unsigned integer: -\begin{Verbatim}[commandchars=\\\{\}] - 1) [codebook\_lookup\_type] = read four bits as an unsigned integer -\end{Verbatim} - -Codebook decode precedes according to \varname{[codebook\_lookup\_type]}: -\begin{itemize} -\item -Lookup type zero indicates no lookup to be read. Proceed past -lookup decode. -\item -Lookup types one and two are similar, differing only in the -number of lookup values to be read. Lookup type one reads a list of -values that are permuted in a set pattern to build a list of vectors, -each vector of order \varname{[codebook\_dimensions]} scalars. Lookup -type two builds the same vector list, but reads each scalar for each -vector explicitly, rather than building vectors from a smaller list of -possible scalar values. Lookup decode proceeds as follows: - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [codebook\_minimum\_value] = \link{vorbis:spec:float32:unpack}{float32\_unpack}( read 32 bits as an unsigned integer) - 2) [codebook\_delta\_value] = \link{vorbis:spec:float32:unpack}{float32\_unpack}( read 32 bits as an unsigned integer) - 3) [codebook\_value\_bits] = read 4 bits as an unsigned integer and add 1 - 4) [codebook\_sequence\_p] = read 1 bit as a boolean flag - - if ( [codebook\_lookup\_type] is 1 ) \{ - - 5) [codebook\_lookup\_values] = \link{vorbis:spec:lookup1:values}{lookup1\_values}(\varname{[codebook\_entries]}, \varname{[codebook\_dimensions]} ) - - \} else \{ - - 6) [codebook\_lookup\_values] = \varname{[codebook\_entries]} * \varname{[codebook\_dimensions]} - - \} - - 7) read a total of [codebook\_lookup\_values] unsigned integers of [codebook\_value\_bits] each; - store these in order in the array [codebook\_multiplicands] -\end{Verbatim} -\item -A \varname{[codebook\_lookup\_type]} of greater than two is reserved -and indicates a stream that is not decodable by the specification in this -document. - -\end{itemize} - - -An 'end of packet' during any read operation in the above steps is -considered an error condition rendering the stream undecodable. - -\paragraph{Huffman decision tree representation} - -The \varname{[codebook\_codeword\_lengths]} array and -\varname{[codebook\_entries]} value uniquely define the Huffman decision -tree used for entropy decoding. - -Briefly, each used codebook entry (recall that length-unordered -codebooks support unused codeword entries) is assigned, in order, the -lowest valued unused binary Huffman codeword possible. Assume the -following codeword length list: - -\begin{Verbatim}[commandchars=\\\{\}] -entry 0: length 2 -entry 1: length 4 -entry 2: length 4 -entry 3: length 4 -entry 4: length 4 -entry 5: length 2 -entry 6: length 3 -entry 7: length 3 -\end{Verbatim} - -Assigning codewords in order (lowest possible value of the appropriate -length to highest) results in the following codeword list: - -\begin{Verbatim}[commandchars=\\\{\}] -entry 0: length 2 codeword 00 -entry 1: length 4 codeword 0100 -entry 2: length 4 codeword 0101 -entry 3: length 4 codeword 0110 -entry 4: length 4 codeword 0111 -entry 5: length 2 codeword 10 -entry 6: length 3 codeword 110 -entry 7: length 3 codeword 111 -\end{Verbatim} - - -\begin{note} -Unlike most binary numerical values in this document, we -intend the above codewords to be read and used bit by bit from left to -right, thus the codeword '001' is the bit string 'zero, zero, one'. -When determining 'lowest possible value' in the assignment definition -above, the leftmost bit is the MSb. -\end{note} - -It is clear that the codeword length list represents a Huffman -decision tree with the entry numbers equivalent to the leaves numbered -left-to-right: - -\begin{center} -\includegraphics[width=10cm]{hufftree} -\captionof{figure}{huffman tree illustration} -\end{center} - - -As we assign codewords in order, we see that each choice constructs a -new leaf in the leftmost possible position. - -Note that it's possible to underspecify or overspecify a Huffman tree -via the length list. In the above example, if codeword seven were -eliminated, it's clear that the tree is unfinished: - -\begin{center} -\includegraphics[width=10cm]{hufftree-under} -\captionof{figure}{underspecified huffman tree illustration} -\end{center} - - -Similarly, in the original codebook, it's clear that the tree is fully -populated and a ninth codeword is impossible. Both underspecified and -overspecified trees are an error condition rendering the stream -undecodable. - -Codebook entries marked 'unused' are simply skipped in the assigning -process. They have no codeword and do not appear in the decision -tree, thus it's impossible for any bit pattern read from the stream to -decode to that entry number. - -\paragraph{Errata 20150226: Single entry codebooks} - -A 'single-entry codebook' is a codebook with one active codeword -entry. A single-entry codebook may be either a fully populated -codebook with only one declared entry, or a sparse codebook with only -one entry marked used. The Vorbis I spec provides no means to specify -a codeword length of zero, and as a result, a single-entry codebook is -inherently malformed because it is underpopulated. The original -specification did not address directly the matter of single-entry -codebooks; they were implicitly illegal as it was not possible to -write such a codebook with a valid tree structure. - -In r14811 of the libvorbis reference implementation, Xiph added an -additional check to the codebook implementation to reject -underpopulated Huffman trees. This change led to the discovery of -single-entry books used 'in the wild' when the new, stricter checks -rejected a number of apparently working streams. - -In order to minimize breakage of deployed (if technically erroneous) -streams, r16073 of the reference implementation explicitly -special-cased single-entry codebooks to tolerate the single-entry -case. Commit r16073 also added the following to the specification: - -\blockquote{\sout{Take special care that a codebook with a single used - entry is handled properly; it consists of a single codework of - zero bits and ’reading’ a value out of such a codebook always - returns the single used value and sinks zero bits. -}} - -The intent was to clarify the spec and codify current practice. -However, this addition is erroneously at odds with the intent of preserving -usability of existing streams using single-entry codebooks, disagrees -with the code changes that reinstated decoding, and does not address how -single-entry codebooks should be encoded. - -As such, the above addition made in r16037 is struck from the -specification and replaced by the following: - -\blockquote{It is possible to declare a Vorbis codebook containing a - single codework entry. A single-entry codebook may be either a - fully populated codebook with \varname{[codebook\_entries]} set to - 1, or a sparse codebook marking only one entry used. Note that it - is not possible to also encode a \varname{[codeword\_length]} of - zero for the single used codeword, as the unsigned value written to - the stream is \varname{[codeword\_length]-1}. Instead, encoder - implementations should indicate a \varname{[codeword\_length]} of 1 - and 'write' the codeword to a stream during audio encoding by - writing a single zero bit. - - Decoder implementations shall reject a codebook if it contains only - one used entry and the encoded \varname{[codeword\_length]} of that - entry is not 1. 'Reading' a value from single-entry codebook always - returns the single used codeword value and sinks one bit. Decoders - should tolerate that the bit read from the stream be '1' instead of - '0'; both values shall return the single used codeword.} - -\paragraph{VQ lookup table vector representation} - -Unpacking the VQ lookup table vectors relies on the following values: -\begin{programlisting} -the [codebook\_multiplicands] array -[codebook\_minimum\_value] -[codebook\_delta\_value] -[codebook\_sequence\_p] -[codebook\_lookup\_type] -[codebook\_entries] -[codebook\_dimensions] -[codebook\_lookup\_values] -\end{programlisting} - -\bigskip - -Decoding (unpacking) a specific vector in the vector lookup table -proceeds according to \varname{[codebook\_lookup\_type]}. The unpacked -vector values are what a codebook would return during audio packet -decode in a VQ context. - -\paragraph{Vector value decode: Lookup type 1} - -Lookup type one specifies a lattice VQ lookup table built -algorithmically from a list of scalar values. Calculate (unpack) the -final values of a codebook entry vector from the entries in -\varname{[codebook\_multiplicands]} as follows (\varname{[value\_vector]} -is the output vector representing the vector of values for entry number -\varname{[lookup\_offset]} in this codebook): - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [last] = 0; - 2) [index\_divisor] = 1; - 3) iterate [i] over the range 0 ... [codebook\_dimensions]-1 (once for each scalar value in the value vector) \{ - - 4) [multiplicand\_offset] = ( [lookup\_offset] divided by [index\_divisor] using integer - division ) integer modulo [codebook\_lookup\_values] - - 5) vector [value\_vector] element [i] = - ( [codebook\_multiplicands] array element number [multiplicand\_offset] ) * - [codebook\_delta\_value] + [codebook\_minimum\_value] + [last]; - - 6) if ( [codebook\_sequence\_p] is set ) then set [last] = vector [value\_vector] element [i] - - 7) [index\_divisor] = [index\_divisor] * [codebook\_lookup\_values] - - \} - - 8) vector calculation completed. -\end{Verbatim} - - - -\paragraph{Vector value decode: Lookup type 2} - -Lookup type two specifies a VQ lookup table in which each scalar in -each vector is explicitly set by the \varname{[codebook\_multiplicands]} -array in a one-to-one mapping. Calculate [unpack] the -final values of a codebook entry vector from the entries in -\varname{[codebook\_multiplicands]} as follows (\varname{[value\_vector]} -is the output vector representing the vector of values for entry number -\varname{[lookup\_offset]} in this codebook): - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [last] = 0; - 2) [multiplicand\_offset] = [lookup\_offset] * [codebook\_dimensions] - 3) iterate [i] over the range 0 ... [codebook\_dimensions]-1 (once for each scalar value in the value vector) \{ - - 4) vector [value\_vector] element [i] = - ( [codebook\_multiplicands] array element number [multiplicand\_offset] ) * - [codebook\_delta\_value] + [codebook\_minimum\_value] + [last]; - - 5) if ( [codebook\_sequence\_p] is set ) then set [last] = vector [value\_vector] element [i] - - 6) increment [multiplicand\_offset] - - \} - - 7) vector calculation completed. -\end{Verbatim} - - - - - - - - - -\subsection{Use of the codebook abstraction} - -The decoder uses the codebook abstraction much as it does the -bit-unpacking convention; a specific codebook reads a -codeword from the bitstream, decoding it into an entry number, and then -returns that entry number to the decoder (when used in a scalar -entropy coding context), or uses that entry number as an offset into -the VQ lookup table, returning a vector of values (when used in a context -desiring a VQ value). Scalar or VQ context is always explicit; any call -to the codebook mechanism requests either a scalar entry number or a -lookup vector. - -Note that VQ lookup type zero indicates that there is no lookup table; -requesting decode using a codebook of lookup type 0 in any context -expecting a vector return value (even in a case where a vector of -dimension one) is forbidden. If decoder setup or decode requests such -an action, that is an error condition rendering the packet -undecodable. - -Using a codebook to read from the packet bitstream consists first of -reading and decoding the next codeword in the bitstream. The decoder -reads bits until the accumulated bits match a codeword in the -codebook. This process can be though of as logically walking the -Huffman decode tree by reading one bit at a time from the bitstream, -and using the bit as a decision boolean to take the 0 branch (left in -the above examples) or the 1 branch (right in the above examples). -Walking the tree finishes when the decode process hits a leaf in the -decision tree; the result is the entry number corresponding to that -leaf. Reading past the end of a packet propagates the 'end-of-stream' -condition to the decoder. - -When used in a scalar context, the resulting codeword entry is the -desired return value. - -When used in a VQ context, the codeword entry number is used as an -offset into the VQ lookup table. The value returned to the decoder is -the vector of scalars corresponding to this offset. diff --git a/Engine/lib/libvorbis/doc/04-codec.tex b/Engine/lib/libvorbis/doc/04-codec.tex deleted file mode 100644 index 333c22729..000000000 --- a/Engine/lib/libvorbis/doc/04-codec.tex +++ /dev/null @@ -1,660 +0,0 @@ - -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Codec Setup and Packet Decode} \label{vorbis:spec:codec} - -\subsection{Overview} - -This document serves as the top-level reference document for the -bit-by-bit decode specification of Vorbis I. This document assumes a -high-level understanding of the Vorbis decode process, which is -provided in \xref{vorbis:spec:intro}. \xref{vorbis:spec:bitpacking} covers reading and writing bit fields from -and to bitstream packets. - - - -\subsection{Header decode and decode setup} - -A Vorbis bitstream begins with three header packets. The header -packets are, in order, the identification header, the comments header, -and the setup header. All are required for decode compliance. An -end-of-packet condition during decoding the first or third header -packet renders the stream undecodable. End-of-packet decoding the -comment header is a non-fatal error condition. - -\subsubsection{Common header decode} - -Each header packet begins with the same header fields. - - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [packet\_type] : 8 bit value - 2) 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73: the characters 'v','o','r','b','i','s' as six octets -\end{Verbatim} - -Decode continues according to packet type; the identification header -is type 1, the comment header type 3 and the setup header type 5 -(these types are all odd as a packet with a leading single bit of '0' -is an audio packet). The packets must occur in the order of -identification, comment, setup. - - - -\subsubsection{Identification header} - -The identification header is a short header of only a few fields used -to declare the stream definitively as Vorbis, and provide a few externally -relevant pieces of information about the audio stream. The -identification header is coded as follows: - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [vorbis\_version] = read 32 bits as unsigned integer - 2) [audio\_channels] = read 8 bit integer as unsigned - 3) [audio\_sample\_rate] = read 32 bits as unsigned integer - 4) [bitrate\_maximum] = read 32 bits as signed integer - 5) [bitrate\_nominal] = read 32 bits as signed integer - 6) [bitrate\_minimum] = read 32 bits as signed integer - 7) [blocksize\_0] = 2 exponent (read 4 bits as unsigned integer) - 8) [blocksize\_1] = 2 exponent (read 4 bits as unsigned integer) - 9) [framing\_flag] = read one bit -\end{Verbatim} - -\varname{[vorbis\_version]} is to read '0' in order to be compatible -with this document. Both \varname{[audio\_channels]} and -\varname{[audio\_sample\_rate]} must read greater than zero. Allowed final -blocksize values are 64, 128, 256, 512, 1024, 2048, 4096 and 8192 in -Vorbis I. \varname{[blocksize\_0]} must be less than or equal to -\varname{[blocksize\_1]}. The framing bit must be nonzero. Failure to -meet any of these conditions renders a stream undecodable. - -The bitrate fields above are used only as hints. The nominal bitrate -field especially may be considerably off in purely VBR streams. The -fields are meaningful only when greater than zero. - -\begin{itemize} - \item All three fields set to the same value implies a fixed rate, or tightly bounded, nearly fixed-rate bitstream - \item Only nominal set implies a VBR or ABR stream that averages the nominal bitrate - \item Maximum and or minimum set implies a VBR bitstream that obeys the bitrate limits - \item None set indicates the encoder does not care to speculate. -\end{itemize} - - - - -\subsubsection{Comment header} -Comment header decode and data specification is covered in -\xref{vorbis:spec:comment}. - - -\subsubsection{Setup header} - -Vorbis codec setup is configurable to an extreme degree: - -\begin{center} -\includegraphics[width=\textwidth]{components} -\captionof{figure}{decoder pipeline configuration} -\end{center} - - -The setup header contains the bulk of the codec setup information -needed for decode. The setup header contains, in order, the lists of -codebook configurations, time-domain transform configurations -(placeholders in Vorbis I), floor configurations, residue -configurations, channel mapping configurations and mode -configurations. It finishes with a framing bit of '1'. Header decode -proceeds in the following order: - -\paragraph{Codebooks} - -\begin{enumerate} -\item \varname{[vorbis\_codebook\_count]} = read eight bits as unsigned integer and add one -\item Decode \varname{[vorbis\_codebook\_count]} codebooks in order as defined -in \xref{vorbis:spec:codebook}. Save each configuration, in -order, in an array of -codebook configurations \varname{[vorbis\_codebook\_configurations]}. -\end{enumerate} - - - -\paragraph{Time domain transforms} - -These hooks are placeholders in Vorbis I. Nevertheless, the -configuration placeholder values must be read to maintain bitstream -sync. - -\begin{enumerate} -\item \varname{[vorbis\_time\_count]} = read 6 bits as unsigned integer and add one -\item read \varname{[vorbis\_time\_count]} 16 bit values; each value should be zero. If any value is nonzero, this is an error condition and the stream is undecodable. -\end{enumerate} - - - -\paragraph{Floors} - -Vorbis uses two floor types; header decode is handed to the decode -abstraction of the appropriate type. - -\begin{enumerate} - \item \varname{[vorbis\_floor\_count]} = read 6 bits as unsigned integer and add one - \item For each \varname{[i]} of \varname{[vorbis\_floor\_count]} floor numbers: - \begin{enumerate} - \item read the floor type: vector \varname{[vorbis\_floor\_types]} element \varname{[i]} = -read 16 bits as unsigned integer - \item If the floor type is zero, decode the floor -configuration as defined in \xref{vorbis:spec:floor0}; save -this -configuration in slot \varname{[i]} of the floor configuration array \varname{[vorbis\_floor\_configurations]}. - \item If the floor type is one, -decode the floor configuration as defined in \xref{vorbis:spec:floor1}; save this configuration in slot \varname{[i]} of the floor configuration array \varname{[vorbis\_floor\_configurations]}. - \item If the the floor type is greater than one, this stream is undecodable; ERROR CONDITION - \end{enumerate} - -\end{enumerate} - - - -\paragraph{Residues} - -Vorbis uses three residue types; header decode of each type is identical. - - -\begin{enumerate} -\item \varname{[vorbis\_residue\_count]} = read 6 bits as unsigned integer and add one - -\item For each of \varname{[vorbis\_residue\_count]} residue numbers: - \begin{enumerate} - \item read the residue type; vector \varname{[vorbis\_residue\_types]} element \varname{[i]} = read 16 bits as unsigned integer - \item If the residue type is zero, -one or two, decode the residue configuration as defined in \xref{vorbis:spec:residue}; save this configuration in slot \varname{[i]} of the residue configuration array \varname{[vorbis\_residue\_configurations]}. - \item If the the residue type is greater than two, this stream is undecodable; ERROR CONDITION - \end{enumerate} - -\end{enumerate} - - - -\paragraph{Mappings} - -Mappings are used to set up specific pipelines for encoding -multichannel audio with varying channel mapping applications. Vorbis I -uses a single mapping type (0), with implicit PCM channel mappings. - -% FIXME/TODO: LaTeX cannot nest enumerate that deeply, so I have to use -% itemize at the innermost level. However, it would be much better to -% rewrite this pseudocode using listings or algoritmicx or some other -% package geared towards this. -\begin{enumerate} - \item \varname{[vorbis\_mapping\_count]} = read 6 bits as unsigned integer and add one - \item For each \varname{[i]} of \varname{[vorbis\_mapping\_count]} mapping numbers: - \begin{enumerate} - \item read the mapping type: 16 bits as unsigned integer. There's no reason to save the mapping type in Vorbis I. - \item If the mapping type is nonzero, the stream is undecodable - \item If the mapping type is zero: - \begin{enumerate} - \item read 1 bit as a boolean flag - \begin{enumerate} - \item if set, \varname{[vorbis\_mapping\_submaps]} = read 4 bits as unsigned integer and add one - \item if unset, \varname{[vorbis\_mapping\_submaps]} = 1 - \end{enumerate} - - - \item read 1 bit as a boolean flag - \begin{enumerate} - \item if set, square polar channel mapping is in use: - \begin{itemize} - \item \varname{[vorbis\_mapping\_coupling\_steps]} = read 8 bits as unsigned integer and add one - \item for \varname{[j]} each of \varname{[vorbis\_mapping\_coupling\_steps]} steps: - \begin{itemize} - \item vector \varname{[vorbis\_mapping\_magnitude]} element \varname{[j]}= read \link{vorbis:spec:ilog}{ilog}(\varname{[audio\_channels]} - 1) bits as unsigned integer - \item vector \varname{[vorbis\_mapping\_angle]} element \varname{[j]}= read \link{vorbis:spec:ilog}{ilog}(\varname{[audio\_channels]} - 1) bits as unsigned integer - \item the numbers read in the above two steps are channel numbers representing the channel to treat as magnitude and the channel to treat as angle, respectively. If for any coupling step the angle channel number equals the magnitude channel number, the magnitude channel number is greater than \varname{[audio\_channels]}-1, or the angle channel is greater than \varname{[audio\_channels]}-1, the stream is undecodable. - \end{itemize} - - - \end{itemize} - - - \item if unset, \varname{[vorbis\_mapping\_coupling\_steps]} = 0 - \end{enumerate} - - - \item read 2 bits (reserved field); if the value is nonzero, the stream is undecodable - \item if \varname{[vorbis\_mapping\_submaps]} is greater than one, we read channel multiplex settings. For each \varname{[j]} of \varname{[audio\_channels]} channels: - \begin{enumerate} - \item vector \varname{[vorbis\_mapping\_mux]} element \varname{[j]} = read 4 bits as unsigned integer - \item if the value is greater than the highest numbered submap (\varname{[vorbis\_mapping\_submaps]} - 1), this in an error condition rendering the stream undecodable - \end{enumerate} - - \item for each submap \varname{[j]} of \varname{[vorbis\_mapping\_submaps]} submaps, read the floor and residue numbers for use in decoding that submap: - \begin{enumerate} - \item read and discard 8 bits (the unused time configuration placeholder) - \item read 8 bits as unsigned integer for the floor number; save in vector \varname{[vorbis\_mapping\_submap\_floor]} element \varname{[j]} - \item verify the floor number is not greater than the highest number floor configured for the bitstream. If it is, the bitstream is undecodable - \item read 8 bits as unsigned integer for the residue number; save in vector \varname{[vorbis\_mapping\_submap\_residue]} element \varname{[j]} - \item verify the residue number is not greater than the highest number residue configured for the bitstream. If it is, the bitstream is undecodable - \end{enumerate} - - \item save this mapping configuration in slot \varname{[i]} of the mapping configuration array \varname{[vorbis\_mapping\_configurations]}. - \end{enumerate} - - \end{enumerate} - -\end{enumerate} - - - -\paragraph{Modes} - -\begin{enumerate} - \item \varname{[vorbis\_mode\_count]} = read 6 bits as unsigned integer and add one - \item For each of \varname{[vorbis\_mode\_count]} mode numbers: - \begin{enumerate} - \item \varname{[vorbis\_mode\_blockflag]} = read 1 bit - \item \varname{[vorbis\_mode\_windowtype]} = read 16 bits as unsigned integer - \item \varname{[vorbis\_mode\_transformtype]} = read 16 bits as unsigned integer - \item \varname{[vorbis\_mode\_mapping]} = read 8 bits as unsigned integer - \item verify ranges; zero is the only legal value in Vorbis I for -\varname{[vorbis\_mode\_windowtype]} -and \varname{[vorbis\_mode\_transformtype]}. \varname{[vorbis\_mode\_mapping]} must not be greater than the highest number mapping in use. Any illegal values render the stream undecodable. - \item save this mode configuration in slot \varname{[i]} of the mode configuration array -\varname{[vorbis\_mode\_configurations]}. - \end{enumerate} - -\item read 1 bit as a framing flag. If unset, a framing error occurred and the stream is not -decodable. -\end{enumerate} - -After reading mode descriptions, setup header decode is complete. - - - - - - - - -\subsection{Audio packet decode and synthesis} - -Following the three header packets, all packets in a Vorbis I stream -are audio. The first step of audio packet decode is to read and -verify the packet type. \emph{A non-audio packet when audio is expected -indicates stream corruption or a non-compliant stream. The decoder -must ignore the packet and not attempt decoding it to audio}. - - -\subsubsection{packet type, mode and window decode} - -\begin{enumerate} - \item read 1 bit \varname{[packet\_type]}; check that packet type is 0 (audio) - \item read \link{vorbis:spec:ilog}{ilog}([vorbis\_mode\_count]-1) bits -\varname{[mode\_number]} - \item decode blocksize \varname{[n]} is equal to \varname{[blocksize\_0]} if -\varname{[vorbis\_mode\_blockflag]} is 0, else \varname{[n]} is equal to \varname{[blocksize\_1]}. - \item perform window selection and setup; this window is used later by the inverse MDCT: - \begin{enumerate} - \item if this is a long window (the \varname{[vorbis\_mode\_blockflag]} flag of this mode is -set): - \begin{enumerate} - \item read 1 bit for \varname{[previous\_window\_flag]} - \item read 1 bit for \varname{[next\_window\_flag]} - \item if \varname{[previous\_window\_flag]} is not set, the left half - of the window will be a hybrid window for lapping with a - short block. See \xref{vorbis:spec:window} for an illustration of overlapping -dissimilar - windows. Else, the left half window will have normal long - shape. - \item if \varname{[next\_window\_flag]} is not set, the right half of - the window will be a hybrid window for lapping with a short - block. See \xref{vorbis:spec:window} for an -illustration of overlapping dissimilar - windows. Else, the left right window will have normal long - shape. - \end{enumerate} - - \item if this is a short window, the window is always the same - short-window shape. - \end{enumerate} - -\end{enumerate} - -Vorbis windows all use the slope function $y=\sin(\frac{\pi}{2} * \sin^2((x+0.5)/n * \pi))$, -where $n$ is window size and $x$ ranges $0 \ldots n-1$, but dissimilar -lapping requirements can affect overall shape. Window generation -proceeds as follows: - -\begin{enumerate} - \item \varname{[window\_center]} = \varname{[n]} / 2 - \item if (\varname{[vorbis\_mode\_blockflag]} is set and \varname{[previous\_window\_flag]} is -not set) then - \begin{enumerate} - \item \varname{[left\_window\_start]} = \varname{[n]}/4 - -\varname{[blocksize\_0]}/4 - \item \varname{[left\_window\_end]} = \varname{[n]}/4 + \varname{[blocksize\_0]}/4 - \item \varname{[left\_n]} = \varname{[blocksize\_0]}/2 - \end{enumerate} - else - \begin{enumerate} - \item \varname{[left\_window\_start]} = 0 - \item \varname{[left\_window\_end]} = \varname{[window\_center]} - \item \varname{[left\_n]} = \varname{[n]}/2 - \end{enumerate} - - \item if (\varname{[vorbis\_mode\_blockflag]} is set and \varname{[next\_window\_flag]} is not -set) then - \begin{enumerate} - \item \varname{[right\_window\_start]} = \varname{[n]*3}/4 - -\varname{[blocksize\_0]}/4 - \item \varname{[right\_window\_end]} = \varname{[n]*3}/4 + -\varname{[blocksize\_0]}/4 - \item \varname{[right\_n]} = \varname{[blocksize\_0]}/2 - \end{enumerate} - else - \begin{enumerate} - \item \varname{[right\_window\_start]} = \varname{[window\_center]} - \item \varname{[right\_window\_end]} = \varname{[n]} - \item \varname{[right\_n]} = \varname{[n]}/2 - \end{enumerate} - - \item window from range 0 ... \varname{[left\_window\_start]}-1 inclusive is zero - \item for \varname{[i]} in range \varname{[left\_window\_start]} ... -\varname{[left\_window\_end]}-1, window(\varname{[i]}) = $\sin(\frac{\pi}{2} * \sin^2($ (\varname{[i]}-\varname{[left\_window\_start]}+0.5) / \varname{[left\_n]} $* \frac{\pi}{2})$ ) - \item window from range \varname{[left\_window\_end]} ... \varname{[right\_window\_start]}-1 -inclusive is one\item for \varname{[i]} in range \varname{[right\_window\_start]} ... \varname{[right\_window\_end]}-1, window(\varname{[i]}) = $\sin(\frac{\pi}{2} * \sin^2($ (\varname{[i]}-\varname{[right\_window\_start]}+0.5) / \varname{[right\_n]} $ * \frac{\pi}{2} + \frac{\pi}{2})$ ) -\item window from range \varname{[right\_window\_start]} ... \varname{[n]}-1 is -zero -\end{enumerate} - -An end-of-packet condition up to this point should be considered an -error that discards this packet from the stream. An end of packet -condition past this point is to be considered a possible nominal -occurrence. - - - -\subsubsection{floor curve decode} - -From this point on, we assume out decode context is using mode number -\varname{[mode\_number]} from configuration array -\varname{[vorbis\_mode\_configurations]} and the map number -\varname{[vorbis\_mode\_mapping]} (specified by the current mode) taken -from the mapping configuration array -\varname{[vorbis\_mapping\_configurations]}. - -Floor curves are decoded one-by-one in channel order. - -For each floor \varname{[i]} of \varname{[audio\_channels]} - \begin{enumerate} - \item \varname{[submap\_number]} = element \varname{[i]} of vector [vorbis\_mapping\_mux] - \item \varname{[floor\_number]} = element \varname{[submap\_number]} of vector -[vorbis\_submap\_floor] - \item if the floor type of this -floor (vector \varname{[vorbis\_floor\_types]} element -\varname{[floor\_number]}) is zero then decode the floor for -channel \varname{[i]} according to the -\xref{vorbis:spec:floor0-decode} - \item if the type of this floor -is one then decode the floor for channel \varname{[i]} according -to the \xref{vorbis:spec:floor1-decode} - \item save the needed decoded floor information for channel for later synthesis - \item if the decoded floor returned 'unused', set vector \varname{[no\_residue]} element -\varname{[i]} to true, else set vector \varname{[no\_residue]} element \varname{[i]} to -false - \end{enumerate} - - -An end-of-packet condition during floor decode shall result in packet -decode zeroing all channel output vectors and skipping to the -add/overlap output stage. - - - -\subsubsection{nonzero vector propagate} - -A possible result of floor decode is that a specific vector is marked -'unused' which indicates that that final output vector is all-zero -values (and the floor is zero). The residue for that vector is not -coded in the stream, save for one complication. If some vectors are -used and some are not, channel coupling could result in mixing a -zeroed and nonzeroed vector to produce two nonzeroed vectors. - -for each \varname{[i]} from 0 ... \varname{[vorbis\_mapping\_coupling\_steps]}-1 - -\begin{enumerate} - \item if either \varname{[no\_residue]} entry for channel -(\varname{[vorbis\_mapping\_magnitude]} element \varname{[i]}) -or channel -(\varname{[vorbis\_mapping\_angle]} element \varname{[i]}) -are set to false, then both must be set to false. Note that an 'unused' -floor has no decoded floor information; it is important that this is -remembered at floor curve synthesis time. -\end{enumerate} - - - - -\subsubsection{residue decode} - -Unlike floors, which are decoded in channel order, the residue vectors -are decoded in submap order. - -for each submap \varname{[i]} in order from 0 ... \varname{[vorbis\_mapping\_submaps]}-1 - -\begin{enumerate} - \item \varname{[ch]} = 0 - \item for each channel \varname{[j]} in order from 0 ... \varname{[audio\_channels]} - 1 - \begin{enumerate} - \item if channel \varname{[j]} in submap \varname{[i]} (vector \varname{[vorbis\_mapping\_mux]} element \varname{[j]} is equal to \varname{[i]}) - \begin{enumerate} - \item if vector \varname{[no\_residue]} element \varname{[j]} is true - \begin{enumerate} - \item vector \varname{[do\_not\_decode\_flag]} element \varname{[ch]} is set - \end{enumerate} - else - \begin{enumerate} - \item vector \varname{[do\_not\_decode\_flag]} element \varname{[ch]} is unset - \end{enumerate} - - \item increment \varname{[ch]} - \end{enumerate} - - \end{enumerate} - \item \varname{[residue\_number]} = vector \varname{[vorbis\_mapping\_submap\_residue]} element \varname{[i]} - \item \varname{[residue\_type]} = vector \varname{[vorbis\_residue\_types]} element \varname{[residue\_number]} - \item decode \varname{[ch]} vectors using residue \varname{[residue\_number]}, according to type \varname{[residue\_type]}, also passing vector \varname{[do\_not\_decode\_flag]} to indicate which vectors in the bundle should not be decoded. Correct per-vector decode length is \varname{[n]}/2. - \item \varname{[ch]} = 0 - \item for each channel \varname{[j]} in order from 0 ... \varname{[audio\_channels]} - \begin{enumerate} - \item if channel \varname{[j]} is in submap \varname{[i]} (vector \varname{[vorbis\_mapping\_mux]} element \varname{[j]} is equal to \varname{[i]}) - \begin{enumerate} - \item residue vector for channel \varname{[j]} is set to decoded residue vector \varname{[ch]} - \item increment \varname{[ch]} - \end{enumerate} - - \end{enumerate} - -\end{enumerate} - - - -\subsubsection{inverse coupling} - -for each \varname{[i]} from \varname{[vorbis\_mapping\_coupling\_steps]}-1 descending to 0 - -\begin{enumerate} - \item \varname{[magnitude\_vector]} = the residue vector for channel -(vector \varname{[vorbis\_mapping\_magnitude]} element \varname{[i]}) - \item \varname{[angle\_vector]} = the residue vector for channel (vector -\varname{[vorbis\_mapping\_angle]} element \varname{[i]}) - \item for each scalar value \varname{[M]} in vector \varname{[magnitude\_vector]} and the corresponding scalar value \varname{[A]} in vector \varname{[angle\_vector]}: - \begin{enumerate} - \item if (\varname{[M]} is greater than zero) - \begin{enumerate} - \item if (\varname{[A]} is greater than zero) - \begin{enumerate} - \item \varname{[new\_M]} = \varname{[M]} - \item \varname{[new\_A]} = \varname{[M]}-\varname{[A]} - \end{enumerate} - else - \begin{enumerate} - \item \varname{[new\_A]} = \varname{[M]} - \item \varname{[new\_M]} = \varname{[M]}+\varname{[A]} - \end{enumerate} - - \end{enumerate} - else - \begin{enumerate} - \item if (\varname{[A]} is greater than zero) - \begin{enumerate} - \item \varname{[new\_M]} = \varname{[M]} - \item \varname{[new\_A]} = \varname{[M]}+\varname{[A]} - \end{enumerate} - else - \begin{enumerate} - \item \varname{[new\_A]} = \varname{[M]} - \item \varname{[new\_M]} = \varname{[M]}-\varname{[A]} - \end{enumerate} - - \end{enumerate} - - \item set scalar value \varname{[M]} in vector \varname{[magnitude\_vector]} to \varname{[new\_M]} - \item set scalar value \varname{[A]} in vector \varname{[angle\_vector]} to \varname{[new\_A]} - \end{enumerate} - -\end{enumerate} - - - - -\subsubsection{dot product} - -For each channel, synthesize the floor curve from the decoded floor -information, according to packet type. Note that the vector synthesis -length for floor computation is \varname{[n]}/2. - -For each channel, multiply each element of the floor curve by each -element of that channel's residue vector. The result is the dot -product of the floor and residue vectors for each channel; the produced -vectors are the length \varname{[n]}/2 audio spectrum for each -channel. - -% TODO/FIXME: The following two paragraphs have identical twins -% in section 1 (under "compute floor/residue dot product") -One point is worth mentioning about this dot product; a common mistake -in a fixed point implementation might be to assume that a 32 bit -fixed-point representation for floor and residue and direct -multiplication of the vectors is sufficient for acceptable spectral -depth in all cases because it happens to mostly work with the current -Xiph.Org reference encoder. - -However, floor vector values can span \~140dB (\~24 bits unsigned), and -the audio spectrum vector should represent a minimum of 120dB (\~21 -bits with sign), even when output is to a 16 bit PCM device. For the -residue vector to represent full scale if the floor is nailed to -$-140$dB, it must be able to span 0 to $+140$dB. For the residue vector -to reach full scale if the floor is nailed at 0dB, it must be able to -represent $-140$dB to $+0$dB. Thus, in order to handle full range -dynamics, a residue vector may span $-140$dB to $+140$dB entirely within -spec. A 280dB range is approximately 48 bits with sign; thus the -residue vector must be able to represent a 48 bit range and the dot -product must be able to handle an effective 48 bit times 24 bit -multiplication. This range may be achieved using large (64 bit or -larger) integers, or implementing a movable binary point -representation. - - - -\subsubsection{inverse MDCT} - -Convert the audio spectrum vector of each channel back into time -domain PCM audio via an inverse Modified Discrete Cosine Transform -(MDCT). A detailed description of the MDCT is available in \cite{Sporer/Brandenburg/Edler}. The window -function used for the MDCT is the function described earlier. - - - -\subsubsection{overlap\_add} - -Windowed MDCT output is overlapped and added with the right hand data -of the previous window such that the 3/4 point of the previous window -is aligned with the 1/4 point of the current window (as illustrated in -\xref{vorbis:spec:window}). The overlapped portion -produced from overlapping the previous and current frame data is -finished data to be returned by the decoder. This data spans from the -center of the previous window to the center of the current window. In -the case of same-sized windows, the amount of data to return is -one-half block consisting of and only of the overlapped portions. When -overlapping a short and long window, much of the returned range does not -actually overlap. This does not damage transform orthogonality. Pay -attention however to returning the correct data range; the amount of -data to be returned is: - -\begin{programlisting} -window_blocksize(previous_window)/4+window_blocksize(current_window)/4 -\end{programlisting} - -from the center (element windowsize/2) of the previous window to the -center (element windowsize/2-1, inclusive) of the current window. - -Data is not returned from the first frame; it must be used to 'prime' -the decode engine. The encoder accounts for this priming when -calculating PCM offsets; after the first frame, the proper PCM output -offset is '0' (as no data has been returned yet). - - - -\subsubsection{output channel order} - -Vorbis I specifies only a channel mapping type 0. In mapping type 0, -channel mapping is implicitly defined as follows for standard audio -applications. As of revision 16781 (20100113), the specification adds -defined channel locations for 6.1 and 7.1 surround. Ordering/location -for greater-than-eight channels remains 'left to the implementation'. - -These channel orderings refer to order within the encoded stream. It -is naturally possible for a decoder to produce output with channels in -any order. Any such decoder should explicitly document channel -reordering behavior. - -\begin{description} %[style=nextline] - \item[one channel] - the stream is monophonic - -\item[two channels] - the stream is stereo. channel order: left, right - -\item[three channels] - the stream is a 1d-surround encoding. channel order: left, -center, right - -\item[four channels] - the stream is quadraphonic surround. channel order: front left, -front right, rear left, rear right - -\item[five channels] - the stream is five-channel surround. channel order: front left, -center, front right, rear left, rear right - -\item[six channels] - the stream is 5.1 surround. channel order: front left, center, -front right, rear left, rear right, LFE - -\item[seven channels] - the stream is 6.1 surround. channel order: front left, center, -front right, side left, side right, rear center, LFE - -\item[eight channels] - the stream is 7.1 surround. channel order: front left, center, -front right, side left, side right, rear left, rear right, -LFE - -\item[greater than eight channels] - channel use and order is defined by the application - -\end{description} - -Applications using Vorbis for dedicated purposes may define channel -mapping as seen fit. Future channel mappings (such as three and four -channel \href{http://www.ambisonic.net/}{Ambisonics}) will -make use of channel mappings other than mapping 0. - - diff --git a/Engine/lib/libvorbis/doc/05-comment.tex b/Engine/lib/libvorbis/doc/05-comment.tex deleted file mode 100644 index 7e5445534..000000000 --- a/Engine/lib/libvorbis/doc/05-comment.tex +++ /dev/null @@ -1,236 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{comment field and header specification} \label{vorbis:spec:comment} - -\subsection{Overview} - -The Vorbis text comment header is the second (of three) header -packets that begin a Vorbis bitstream. It is meant for short text -comments, not arbitrary metadata; arbitrary metadata belongs in a -separate logical bitstream (usually an XML stream type) that provides -greater structure and machine parseability. - -The comment field is meant to be used much like someone jotting a -quick note on the bottom of a CDR. It should be a little information to -remember the disc by and explain it to others; a short, to-the-point -text note that need not only be a couple words, but isn't going to be -more than a short paragraph. The essentials, in other words, whatever -they turn out to be, eg: - -\begin{quote} -Honest Bob and the Factory-to-Dealer-Incentives, \textit{``I'm Still -Around''}, opening for Moxy Fr\"{u}vous, 1997. -\end{quote} - - - - -\subsection{Comment encoding} - -\subsubsection{Structure} - -The comment header is logically a list of eight-bit-clean vectors; the -number of vectors is bounded to $2^{32}-1$ and the length of each vector -is limited to $2^{32}-1$ bytes. The vector length is encoded; the vector -contents themselves are not null terminated. In addition to the vector -list, there is a single vector for vendor name (also 8 bit clean, -length encoded in 32 bits). For example, the 1.0 release of libvorbis -set the vendor string to ``Xiph.Org libVorbis I 20020717''. - -The vector lengths and number of vectors are stored lsb first, according -to the bit packing conventions of the vorbis codec. However, since data -in the comment header is octet-aligned, they can simply be read as -unaligned 32 bit little endian unsigned integers. - -The comment header is decoded as follows: - -\begin{programlisting} - 1) [vendor\_length] = read an unsigned integer of 32 bits - 2) [vendor\_string] = read a UTF-8 vector as [vendor\_length] octets - 3) [user\_comment\_list\_length] = read an unsigned integer of 32 bits - 4) iterate [user\_comment\_list\_length] times { - 5) [length] = read an unsigned integer of 32 bits - 6) this iteration's user comment = read a UTF-8 vector as [length] octets - } - 7) [framing\_bit] = read a single bit as boolean - 8) if ( [framing\_bit] unset or end-of-packet ) then ERROR - 9) done. -\end{programlisting} - - - - -\subsubsection{Content vector format} - -The comment vectors are structured similarly to a UNIX environment variable. -That is, comment fields consist of a field name and a corresponding value and -look like: - -\begin{quote} -\begin{programlisting} -comment[0]="ARTIST=me"; -comment[1]="TITLE=the sound of Vorbis"; -\end{programlisting} -\end{quote} - -The field name is case-insensitive and may consist of ASCII 0x20 -through 0x7D, 0x3D ('=') excluded. ASCII 0x41 through 0x5A inclusive -(characters A-Z) is to be considered equivalent to ASCII 0x61 through -0x7A inclusive (characters a-z). - - -The field name is immediately followed by ASCII 0x3D ('='); -this equals sign is used to terminate the field name. - - -0x3D is followed by 8 bit clean UTF-8 encoded value of the -field contents to the end of the field. - - -\paragraph{Field names} - -Below is a proposed, minimal list of standard field names with a -description of intended use. No single or group of field names is -mandatory; a comment header may contain one, all or none of the names -in this list. - -\begin{description} %[style=nextline] -\item[TITLE] - Track/Work name - -\item[VERSION] - The version field may be used to differentiate multiple -versions of the same track title in a single collection. (e.g. remix -info) - -\item[ALBUM] - The collection name to which this track belongs - -\item[TRACKNUMBER] - The track number of this piece if part of a specific larger collection or album - -\item[ARTIST] - The artist generally considered responsible for the work. In popular music this is usually the performing band or singer. For classical music it would be the composer. For an audio book it would be the author of the original text. - -\item[PERFORMER] - The artist(s) who performed the work. In classical music this would be the conductor, orchestra, soloists. In an audio book it would be the actor who did the reading. In popular music this is typically the same as the ARTIST and is omitted. - -\item[COPYRIGHT] - Copyright attribution, e.g., '2001 Nobody's Band' or '1999 Jack Moffitt' - -\item[LICENSE] - License information, for example, 'All Rights Reserved', 'Any -Use Permitted', a URL to a license such as a Creative Commons license -(e.g. "creativecommons.org/license/by/4.0/") or similar. - -\item[ORGANIZATION] - Name of the organization producing the track (i.e. -the 'record label') - -\item[DESCRIPTION] - A short text description of the contents - -\item[GENRE] - A short text indication of music genre - -\item[DATE] - Date the track was recorded - -\item[LOCATION] - Location where track was recorded - -\item[CONTACT] - Contact information for the creators or distributors of the track. This could be a URL, an email address, the physical address of the producing label. - -\item[ISRC] - International Standard Recording Code for the -track; see \href{https://isrc.ifpi.org/}{the ISRC -intro page} for more information on ISRC numbers. - -\end{description} - - - -\paragraph{Implications} - -Field names should not be 'internationalized'; this is a -concession to simplicity not an attempt to exclude the majority of -the world that doesn't speak English. Field \emph{contents}, -however, use the UTF-8 character encoding to allow easy representation -of any language. - -We have the length of the entirety of the field and restrictions on -the field name so that the field name is bounded in a known way. Thus -we also have the length of the field contents. - -Individual 'vendors' may use non-standard field names within -reason. The proper use of comment fields should be clear through -context at this point. Abuse will be discouraged. - -There is no vendor-specific prefix to 'nonstandard' field names. -Vendors should make some effort to avoid arbitrarily polluting the -common namespace. We will generally collect the more useful tags -here to help with standardization. - -Field names are not required to be unique (occur once) within a -comment header. As an example, assume a track was recorded by three -well know artists; the following is permissible, and encouraged: - -\begin{quote} -\begin{programlisting} -ARTIST=Dizzy Gillespie -ARTIST=Sonny Rollins -ARTIST=Sonny Stitt -\end{programlisting} -\end{quote} - - - - - - - -\subsubsection{Encoding} - -The comment header comprises the entirety of the second bitstream -header packet. Unlike the first bitstream header packet, it is not -generally the only packet on the second page and may not be restricted -to within the second bitstream page. The length of the comment header -packet is (practically) unbounded. The comment header packet is not -optional; it must be present in the bitstream even if it is -effectively empty. - -The comment header is encoded as follows (as per Ogg's standard -bitstream mapping which renders least-significant-bit of the word to be -coded into the least significant available bit of the current -bitstream octet first): - -\begin{enumerate} - \item - Vendor string length (32 bit unsigned quantity specifying number of octets) - - \item - Vendor string ([vendor string length] octets coded from beginning of string to end of string, not null terminated) - - \item - Number of comment fields (32 bit unsigned quantity specifying number of fields) - - \item - Comment field 0 length (if [Number of comment fields] $>0$; 32 bit unsigned quantity specifying number of octets) - - \item - Comment field 0 ([Comment field 0 length] octets coded from beginning of string to end of string, not null terminated) - - \item - Comment field 1 length (if [Number of comment fields] $>1$...)... - -\end{enumerate} - - -This is actually somewhat easier to describe in code; implementation of the above can be found in \filename{vorbis/lib/info.c}, \function{\_vorbis\_pack\_comment()} and \function{\_vorbis\_unpack\_comment()}. - - - - - - diff --git a/Engine/lib/libvorbis/doc/06-floor0.tex b/Engine/lib/libvorbis/doc/06-floor0.tex deleted file mode 100644 index f3042a644..000000000 --- a/Engine/lib/libvorbis/doc/06-floor0.tex +++ /dev/null @@ -1,201 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Floor type 0 setup and decode} \label{vorbis:spec:floor0} - -\subsection{Overview} - -Vorbis floor type zero uses Line Spectral Pair (LSP, also alternately -known as Line Spectral Frequency or LSF) representation to encode a -smooth spectral envelope curve as the frequency response of the LSP -filter. This representation is equivalent to a traditional all-pole -infinite impulse response filter as would be used in linear predictive -coding; LSP representation may be converted to LPC representation and -vice-versa. - - - -\subsection{Floor 0 format} - -Floor zero configuration consists of six integer fields and a list of -VQ codebooks for use in coding/decoding the LSP filter coefficient -values used by each frame. - -\subsubsection{header decode} - -Configuration information for instances of floor zero decodes from the -codec setup header (third packet). configuration decode proceeds as -follows: - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [floor0\_order] = read an unsigned integer of 8 bits - 2) [floor0\_rate] = read an unsigned integer of 16 bits - 3) [floor0\_bark\_map\_size] = read an unsigned integer of 16 bits - 4) [floor0\_amplitude\_bits] = read an unsigned integer of six bits - 5) [floor0\_amplitude\_offset] = read an unsigned integer of eight bits - 6) [floor0\_number\_of\_books] = read an unsigned integer of four bits and add 1 - 7) array [floor0\_book\_list] = read a list of [floor0\_number\_of\_books] unsigned integers of eight bits each; -\end{Verbatim} - -An end-of-packet condition during any of these bitstream reads renders -this stream undecodable. In addition, any element of the array -\varname{[floor0\_book\_list]} that is greater than the maximum codebook -number for this bitstream is an error condition that also renders the -stream undecodable. - - - -\subsubsection{packet decode} \label{vorbis:spec:floor0-decode} - -Extracting a floor0 curve from an audio packet consists of first -decoding the curve amplitude and \varname{[floor0\_order]} LSP -coefficient values from the bitstream, and then computing the floor -curve, which is defined as the frequency response of the decoded LSP -filter. - -Packet decode proceeds as follows: -\begin{Verbatim}[commandchars=\\\{\}] - 1) [amplitude] = read an unsigned integer of [floor0\_amplitude\_bits] bits - 2) if ( [amplitude] is greater than zero ) \{ - 3) [coefficients] is an empty, zero length vector - 4) [booknumber] = read an unsigned integer of \link{vorbis:spec:ilog}{ilog}( [floor0\_number\_of\_books] ) bits - 5) if ( [booknumber] is greater than the highest number decode codebook ) then packet is undecodable - 6) [last] = zero; - 7) vector [temp\_vector] = read vector from bitstream using codebook number [floor0\_book\_list] element [booknumber] in VQ context. - 8) add the scalar value [last] to each scalar in vector [temp\_vector] - 9) [last] = the value of the last scalar in vector [temp\_vector] - 10) concatenate [temp\_vector] onto the end of the [coefficients] vector - 11) if (length of vector [coefficients] is less than [floor0\_order], continue at step 6 - - \} - - 12) done. - -\end{Verbatim} - -Take note of the following properties of decode: -\begin{itemize} - \item An \varname{[amplitude]} value of zero must result in a return code that indicates this channel is unused in this frame (the output of the channel will be all-zeroes in synthesis). Several later stages of decode don't occur for an unused channel. - \item An end-of-packet condition during decode should be considered a -nominal occruence; if end-of-packet is reached during any read -operation above, floor decode is to return 'unused' status as if the -\varname{[amplitude]} value had read zero at the beginning of decode. - - \item The book number used for decode -can, in fact, be stored in the bitstream in \link{vorbis:spec:ilog}{ilog}( \varname{[floor0\_number\_of\_books]} - -1 ) bits. Nevertheless, the above specification is correct and values -greater than the maximum possible book value are reserved. - - \item The number of scalars read into the vector \varname{[coefficients]} -may be greater than \varname{[floor0\_order]}, the number actually -required for curve computation. For example, if the VQ codebook used -for the floor currently being decoded has a -\varname{[codebook\_dimensions]} value of three and -\varname{[floor0\_order]} is ten, the only way to fill all the needed -scalars in \varname{[coefficients]} is to to read a total of twelve -scalars as four vectors of three scalars each. This is not an error -condition, and care must be taken not to allow a buffer overflow in -decode. The extra values are not used and may be ignored or discarded. -\end{itemize} - - - - -\subsubsection{curve computation} \label{vorbis:spec:floor0-synth} - -Given an \varname{[amplitude]} integer and \varname{[coefficients]} -vector from packet decode as well as the [floor0\_order], -[floor0\_rate], [floor0\_bark\_map\_size], [floor0\_amplitude\_bits] and -[floor0\_amplitude\_offset] values from floor setup, and an output -vector size \varname{[n]} specified by the decode process, we compute a -floor output vector. - -If the value \varname{[amplitude]} is zero, the return value is a -length \varname{[n]} vector with all-zero scalars. Otherwise, begin by -assuming the following definitions for the given vector to be -synthesized: - - \begin{displaymath} - \mathrm{map}_i = \left\{ - \begin{array}{ll} - \min ( - \mathtt{floor0\texttt{\_}bark\texttt{\_}map\texttt{\_}size} - 1, - foobar - ) & \textrm{for } i \in [0,n-1] \\ - -1 & \textrm{for } i = n - \end{array} - \right. - \end{displaymath} - - where - - \begin{displaymath} - foobar = - \left\lfloor - \mathrm{bark}\left(\frac{\mathtt{floor0\texttt{\_}rate} \cdot i}{2n}\right) \cdot \frac{\mathtt{floor0\texttt{\_}bark\texttt{\_}map\texttt{\_}size}} {\mathrm{bark}(.5 \cdot \mathtt{floor0\texttt{\_}rate})} - \right\rfloor - \end{displaymath} - - and - - \begin{displaymath} - \mathrm{bark}(x) = 13.1 \arctan (.00074x) + 2.24 \arctan (.0000000185x^2) + .0001x - \end{displaymath} - -The above is used to synthesize the LSP curve on a Bark-scale frequency -axis, then map the result to a linear-scale frequency axis. -Similarly, the below calculation synthesizes the output LSP curve \varname{[output]} on a log -(dB) amplitude scale, mapping it to linear amplitude in the last step: - -\begin{enumerate} - \item \varname{[i]} = 0 - \item \varname{[$\omega$]} = $\pi$ * map element \varname{[i]} / \varname{[floor0\_bark\_map\_size]} - \item if ( \varname{[floor0\_order]} is odd ) { - \begin{enumerate} - \item calculate \varname{[p]} and \varname{[q]} according to: - \begin{eqnarray*} - p & = & (1 - \cos^2\omega)\prod_{j=0}^{\frac{\mathtt{floor0\texttt{\_}order}-3}{2}} 4 (\cos([\mathtt{coefficients}]_{2j+1}) - \cos \omega)^2 \\ - q & = & \frac{1}{4} \prod_{j=0}^{\frac{\mathtt{floor0\texttt{\_}order}-1}{2}} 4 (\cos([\mathtt{coefficients}]_{2j}) - \cos \omega)^2 - \end{eqnarray*} - - \end{enumerate} - } else \varname{[floor0\_order]} is even { - \begin{enumerate}[resume] - \item calculate \varname{[p]} and \varname{[q]} according to: - \begin{eqnarray*} - p & = & \frac{(1 - \cos\omega)}{2} \prod_{j=0}^{\frac{\mathtt{floor0\texttt{\_}order}-2}{2}} 4 (\cos([\mathtt{coefficients}]_{2j+1}) - \cos \omega)^2 \\ - q & = & \frac{(1 + \cos\omega)}{2} \prod_{j=0}^{\frac{\mathtt{floor0\texttt{\_}order}-2}{2}} 4 (\cos([\mathtt{coefficients}]_{2j}) - \cos \omega)^2 - \end{eqnarray*} - - \end{enumerate} - } - - \item calculate \varname{[linear\_floor\_value]} according to: - \begin{displaymath} - \exp \left( .11512925 \left(\frac{\mathtt{amplitude} \cdot \mathtt{floor0\texttt{\_}amplitute\texttt{\_}offset}}{(2^{\mathtt{floor0\texttt{\_}amplitude\texttt{\_}bits}}-1)\sqrt{p+q}} - - \mathtt{floor0\texttt{\_}amplitude\texttt{\_}offset} \right) \right) - \end{displaymath} - - \item \varname{[iteration\_condition]} = map element \varname{[i]} - \item \varname{[output]} element \varname{[i]} = \varname{[linear\_floor\_value]} - \item increment \varname{[i]} - \item if ( map element \varname{[i]} is equal to \varname{[iteration\_condition]} ) continue at step 5 - \item if ( \varname{[i]} is less than \varname{[n]} ) continue at step 2 - \item done -\end{enumerate} - -\paragraph{Errata 20150227: Bark scale computation} - -Due to a typo when typesetting this version of the specification from the original HTML document, the Bark scale computation previously erroneously read: - - \begin{displaymath} - \hbox{\sout{$ - \mathrm{bark}(x) = 13.1 \arctan (.00074x) + 2.24 \arctan (.0000000185x^2 + .0001x) - $}} - \end{displaymath} - -Note that the last parenthesis is misplaced. This document now uses the correct equation as it appeared in the original HTML spec document: - - \begin{displaymath} - \mathrm{bark}(x) = 13.1 \arctan (.00074x) + 2.24 \arctan (.0000000185x^2) + .0001x - \end{displaymath} - diff --git a/Engine/lib/libvorbis/doc/07-floor1.tex b/Engine/lib/libvorbis/doc/07-floor1.tex deleted file mode 100644 index 47ad798ca..000000000 --- a/Engine/lib/libvorbis/doc/07-floor1.tex +++ /dev/null @@ -1,404 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Floor type 1 setup and decode} \label{vorbis:spec:floor1} - -\subsection{Overview} - -Vorbis floor type one uses a piecewise straight-line representation to -encode a spectral envelope curve. The representation plots this curve -mechanically on a linear frequency axis and a logarithmic (dB) -amplitude axis. The integer plotting algorithm used is similar to -Bresenham's algorithm. - - - -\subsection{Floor 1 format} - -\subsubsection{model} - -Floor type one represents a spectral curve as a series of -line segments. Synthesis constructs a floor curve using iterative -prediction in a process roughly equivalent to the following simplified -description: - -\begin{itemize} - \item the first line segment (base case) is a logical line spanning -from x_0,y_0 to x_1,y_1 where in the base case x_0=0 and x_1=[n], the -full range of the spectral floor to be computed. - -\item the induction step chooses a point x_new within an existing -logical line segment and produces a y_new value at that point computed -from the existing line's y value at x_new (as plotted by the line) and -a difference value decoded from the bitstream packet. - -\item floor computation produces two new line segments, one running from -x_0,y_0 to x_new,y_new and from x_new,y_new to x_1,y_1. This step is -performed logically even if y_new represents no change to the -amplitude value at x_new so that later refinement is additionally -bounded at x_new. - -\item the induction step repeats, using a list of x values specified in -the codec setup header at floor 1 initialization time. Computation -is completed at the end of the x value list. - -\end{itemize} - - -Consider the following example, with values chosen for ease of -understanding rather than representing typical configuration: - -For the below example, we assume a floor setup with an [n] of 128. -The list of selected X values in increasing order is -0,16,32,48,64,80,96,112 and 128. In list order, the values interleave -as 0, 128, 64, 32, 96, 16, 48, 80 and 112. The corresponding -list-order Y values as decoded from an example packet are 110, 20, -5, --45, 0, -25, -10, 30 and -10. We compute the floor in the following -way, beginning with the first line: - -\begin{center} -\includegraphics[width=8cm]{floor1-1} -\captionof{figure}{graph of example floor} -\end{center} - -We now draw new logical lines to reflect the correction to new_Y, and -iterate for X positions 32 and 96: - -\begin{center} -\includegraphics[width=8cm]{floor1-2} -\captionof{figure}{graph of example floor} -\end{center} - -Although the new Y value at X position 96 is unchanged, it is still -used later as an endpoint for further refinement. From here on, the -pattern should be clear; we complete the floor computation as follows: - -\begin{center} -\includegraphics[width=8cm]{floor1-3} -\captionof{figure}{graph of example floor} -\end{center} - -\begin{center} -\includegraphics[width=8cm]{floor1-4} -\captionof{figure}{graph of example floor} -\end{center} - -A more efficient algorithm with carefully defined integer rounding -behavior is used for actual decode, as described later. The actual -algorithm splits Y value computation and line plotting into two steps -with modifications to the above algorithm to eliminate noise -accumulation through integer roundoff/truncation. - - - -\subsubsection{header decode} - -A list of floor X values is stored in the packet header in interleaved -format (used in list order during packet decode and synthesis). This -list is split into partitions, and each partition is assigned to a -partition class. X positions 0 and [n] are implicit and do not belong -to an explicit partition or partition class. - -A partition class consists of a representation vector width (the -number of Y values which the partition class encodes at once), a -'subclass' value representing the number of alternate entropy books -the partition class may use in representing Y values, the list of -[subclass] books and a master book used to encode which alternate -books were chosen for representation in a given packet. The -master/subclass mechanism is meant to be used as a flexible -representation cascade while still using codebooks only in a scalar -context. - -\begin{Verbatim}[commandchars=\\\{\}] - - 1) [floor1\_partitions] = read 5 bits as unsigned integer - 2) [maximum\_class] = -1 - 3) iterate [i] over the range 0 ... [floor1\_partitions]-1 \{ - - 4) vector [floor1\_partition\_class\_list] element [i] = read 4 bits as unsigned integer - - \} - - 5) [maximum\_class] = largest integer scalar value in vector [floor1\_partition\_class\_list] - 6) iterate [i] over the range 0 ... [maximum\_class] \{ - - 7) vector [floor1\_class\_dimensions] element [i] = read 3 bits as unsigned integer and add 1 - 8) vector [floor1\_class\_subclasses] element [i] = read 2 bits as unsigned integer - 9) if ( vector [floor1\_class\_subclasses] element [i] is nonzero ) \{ - - 10) vector [floor1\_class\_masterbooks] element [i] = read 8 bits as unsigned integer - - \} - - 11) iterate [j] over the range 0 ... (2 exponent [floor1\_class\_subclasses] element [i]) - 1 \{ - - 12) array [floor1\_subclass\_books] element [i],[j] = - read 8 bits as unsigned integer and subtract one - \} - \} - - 13) [floor1\_multiplier] = read 2 bits as unsigned integer and add one - 14) [rangebits] = read 4 bits as unsigned integer - 15) vector [floor1\_X\_list] element [0] = 0 - 16) vector [floor1\_X\_list] element [1] = 2 exponent [rangebits]; - 17) [floor1\_values] = 2 - 18) iterate [i] over the range 0 ... [floor1\_partitions]-1 \{ - - 19) [current\_class\_number] = vector [floor1\_partition\_class\_list] element [i] - 20) iterate [j] over the range 0 ... ([floor1\_class\_dimensions] element [current\_class\_number])-1 \{ - 21) vector [floor1\_X\_list] element ([floor1\_values]) = - read [rangebits] bits as unsigned integer - 22) increment [floor1\_values] by one - \} - \} - - 23) done -\end{Verbatim} - -An end-of-packet condition while reading any aspect of a floor 1 -configuration during setup renders a stream undecodable. In addition, -a \varname{[floor1\_class\_masterbooks]} or -\varname{[floor1\_subclass\_books]} scalar element greater than the -highest numbered codebook configured in this stream is an error -condition that renders the stream undecodable. Vector -[floor1\_x\_list] is limited to a maximum length of 65 elements; a -setup indicating more than 65 total elements (including elements 0 and -1 set prior to the read loop) renders the stream undecodable. All -vector [floor1\_x\_list] element values must be unique within the -vector; a non-unique value renders the stream undecodable. - -\subsubsection{packet decode} \label{vorbis:spec:floor1-decode} - -Packet decode begins by checking the \varname{[nonzero]} flag: - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [nonzero] = read 1 bit as boolean -\end{Verbatim} - -If \varname{[nonzero]} is unset, that indicates this channel contained -no audio energy in this frame. Decode immediately returns a status -indicating this floor curve (and thus this channel) is unused this -frame. (A return status of 'unused' is different from decoding a -floor that has all points set to minimum representation amplitude, -which happens to be approximately -140dB). - - -Assuming \varname{[nonzero]} is set, decode proceeds as follows: - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [range] = vector \{ 256, 128, 86, 64 \} element ([floor1\_multiplier]-1) - 2) vector [floor1\_Y] element [0] = read \link{vorbis:spec:ilog}{ilog}([range]-1) bits as unsigned integer - 3) vector [floor1\_Y] element [1] = read \link{vorbis:spec:ilog}{ilog}([range]-1) bits as unsigned integer - 4) [offset] = 2; - 5) iterate [i] over the range 0 ... [floor1\_partitions]-1 \{ - - 6) [class] = vector [floor1\_partition\_class] element [i] - 7) [cdim] = vector [floor1\_class\_dimensions] element [class] - 8) [cbits] = vector [floor1\_class\_subclasses] element [class] - 9) [csub] = (2 exponent [cbits])-1 - 10) [cval] = 0 - 11) if ( [cbits] is greater than zero ) \{ - - 12) [cval] = read from packet using codebook number - (vector [floor1\_class\_masterbooks] element [class]) in scalar context - \} - - 13) iterate [j] over the range 0 ... [cdim]-1 \{ - - 14) [book] = array [floor1\_subclass\_books] element [class],([cval] bitwise AND [csub]) - 15) [cval] = [cval] right shifted [cbits] bits - 16) if ( [book] is not less than zero ) \{ - - 17) vector [floor1\_Y] element ([j]+[offset]) = read from packet using codebook - [book] in scalar context - - \} else [book] is less than zero \{ - - 18) vector [floor1\_Y] element ([j]+[offset]) = 0 - - \} - \} - - 19) [offset] = [offset] + [cdim] - - \} - - 20) done -\end{Verbatim} - -An end-of-packet condition during curve decode should be considered a -nominal occurrence; if end-of-packet is reached during any read -operation above, floor decode is to return 'unused' status as if the -\varname{[nonzero]} flag had been unset at the beginning of decode. - - -Vector \varname{[floor1\_Y]} contains the values from packet decode -needed for floor 1 synthesis. - - - -\subsubsection{curve computation} \label{vorbis:spec:floor1-synth} - -Curve computation is split into two logical steps; the first step -derives final Y amplitude values from the encoded, wrapped difference -values taken from the bitstream. The second step plots the curve -lines. Also, although zero-difference values are used in the -iterative prediction to find final Y values, these points are -conditionally skipped during final line computation in step two. -Skipping zero-difference values allows a smoother line fit. - -Although some aspects of the below algorithm look like inconsequential -optimizations, implementors are warned to follow the details closely. -Deviation from implementing a strictly equivalent algorithm can result -in serious decoding errors. - -{\em Additional note:} Although \varname{[floor1\_final\_Y]} values in -the prediction loop and at the end of step 1 are inherently limited by -the prediction algorithm to [0, \varname{[range]}), it is possible to - abuse the setup and codebook machinery to produce negative or - over-range results. We suggest that decoder implementations guard - the values in vector \varname{[floor1\_final\_Y]} by clamping each - element to [0, \varname{[range]}) after step 1. Variants of this - suggestion are acceptable as valid floor1 setups cannot produce - out of range values. - -\begin{description} -\item[step 1: amplitude value synthesis] - -Unwrap the always-positive-or-zero values read from the packet into -+/- difference values, then apply to line prediction. - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [range] = vector \{ 256, 128, 86, 64 \} element ([floor1\_multiplier]-1) - 2) vector [floor1\_step2\_flag] element [0] = set - 3) vector [floor1\_step2\_flag] element [1] = set - 4) vector [floor1\_final\_Y] element [0] = vector [floor1\_Y] element [0] - 5) vector [floor1\_final\_Y] element [1] = vector [floor1\_Y] element [1] - 6) iterate [i] over the range 2 ... [floor1\_values]-1 \{ - - 7) [low\_neighbor\_offset] = \link{vorbis:spec:low:neighbor}{low\_neighbor}([floor1\_X\_list],[i]) - 8) [high\_neighbor\_offset] = \link{vorbis:spec:high:neighbor}{high\_neighbor}([floor1\_X\_list],[i]) - - 9) [predicted] = \link{vorbis:spec:render:point}{render\_point}( vector [floor1\_X\_list] element [low\_neighbor\_offset], - vector [floor1\_final\_Y] element [low\_neighbor\_offset], - vector [floor1\_X\_list] element [high\_neighbor\_offset], - vector [floor1\_final\_Y] element [high\_neighbor\_offset], - vector [floor1\_X\_list] element [i] ) - - 10) [val] = vector [floor1\_Y] element [i] - 11) [highroom] = [range] - [predicted] - 12) [lowroom] = [predicted] - 13) if ( [highroom] is less than [lowroom] ) \{ - - 14) [room] = [highroom] * 2 - - \} else [highroom] is not less than [lowroom] \{ - - 15) [room] = [lowroom] * 2 - - \} - - 16) if ( [val] is nonzero ) \{ - - 17) vector [floor1\_step2\_flag] element [low\_neighbor\_offset] = set - 18) vector [floor1\_step2\_flag] element [high\_neighbor\_offset] = set - 19) vector [floor1\_step2\_flag] element [i] = set - 20) if ( [val] is greater than or equal to [room] ) \{ - - 21) if ( [highroom] is greater than [lowroom] ) \{ - - 22) vector [floor1\_final\_Y] element [i] = [val] - [lowroom] + [predicted] - - \} else [highroom] is not greater than [lowroom] \{ - - 23) vector [floor1\_final\_Y] element [i] = [predicted] - [val] + [highroom] - 1 - - \} - - \} else [val] is less than [room] \{ - - 24) if ([val] is odd) \{ - - 25) vector [floor1\_final\_Y] element [i] = - [predicted] - (([val] + 1) divided by 2 using integer division) - - \} else [val] is even \{ - - 26) vector [floor1\_final\_Y] element [i] = - [predicted] + ([val] / 2 using integer division) - - \} - - \} - - \} else [val] is zero \{ - - 27) vector [floor1\_step2\_flag] element [i] = unset - 28) vector [floor1\_final\_Y] element [i] = [predicted] - - \} - - \} - - 29) done - -\end{Verbatim} - - - -\item[step 2: curve synthesis] - -Curve synthesis generates a return vector \varname{[floor]} of length -\varname{[n]} (where \varname{[n]} is provided by the decode process -calling to floor decode). Floor 1 curve synthesis makes use of the -\varname{[floor1\_X\_list]}, \varname{[floor1\_final\_Y]} and -\varname{[floor1\_step2\_flag]} vectors, as well as [floor1\_multiplier] -and [floor1\_values] values. - -Decode begins by sorting the scalars from vectors -\varname{[floor1\_X\_list]}, \varname{[floor1\_final\_Y]} and -\varname{[floor1\_step2\_flag]} together into new vectors -\varname{[floor1\_X\_list]'}, \varname{[floor1\_final\_Y]'} and -\varname{[floor1\_step2\_flag]'} according to ascending sort order of the -values in \varname{[floor1\_X\_list]}. That is, sort the values of -\varname{[floor1\_X\_list]} and then apply the same permutation to -elements of the other two vectors so that the X, Y and step2\_flag -values still match. - -Then compute the final curve in one pass: - -\begin{Verbatim}[commandchars=\\\{\}] - 1) [hx] = 0 - 2) [lx] = 0 - 3) [ly] = vector [floor1\_final\_Y]' element [0] * [floor1\_multiplier] - 4) iterate [i] over the range 1 ... [floor1\_values]-1 \{ - - 5) if ( [floor1\_step2\_flag]' element [i] is set ) \{ - - 6) [hy] = [floor1\_final\_Y]' element [i] * [floor1\_multiplier] - 7) [hx] = [floor1\_X\_list]' element [i] - 8) \link{vorbis:spec:render:line}{render\_line}( [lx], [ly], [hx], [hy], [floor] ) - 9) [lx] = [hx] - 10) [ly] = [hy] - \} - \} - - 11) if ( [hx] is less than [n] ) \{ - - 12) \link{vorbis:spec:render:line}{render\_line}( [hx], [hy], [n], [hy], [floor] ) - - \} - - 13) if ( [hx] is greater than [n] ) \{ - - 14) truncate vector [floor] to [n] elements - - \} - - 15) for each scalar in vector [floor], perform a lookup substitution using - the scalar value from [floor] as an offset into the vector \link{vorbis:spec:floor1:inverse:dB:table}{[floor1\_inverse\_dB\_static\_table]} - - 16) done - -\end{Verbatim} - -\end{description} diff --git a/Engine/lib/libvorbis/doc/08-residue.tex b/Engine/lib/libvorbis/doc/08-residue.tex deleted file mode 100644 index ea382437d..000000000 --- a/Engine/lib/libvorbis/doc/08-residue.tex +++ /dev/null @@ -1,451 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Residue setup and decode} \label{vorbis:spec:residue} - -\subsection{Overview} - -A residue vector represents the fine detail of the audio spectrum of -one channel in an audio frame after the encoder subtracts the floor -curve and performs any channel coupling. A residue vector may -represent spectral lines, spectral magnitude, spectral phase or -hybrids as mixed by channel coupling. The exact semantic content of -the vector does not matter to the residue abstraction. - -Whatever the exact qualities, the Vorbis residue abstraction codes the -residue vectors into the bitstream packet, and then reconstructs the -vectors during decode. Vorbis makes use of three different encoding -variants (numbered 0, 1 and 2) of the same basic vector encoding -abstraction. - - - -\subsection{Residue format} - -Residue format partitions each vector in the vector bundle into chunks, -classifies each chunk, encodes the chunk classifications and finally -encodes the chunks themselves using the the specific VQ arrangement -defined for each selected classification. -The exact interleaving and partitioning vary by residue encoding number, -however the high-level process used to classify and encode the residue -vector is the same in all three variants. - -A set of coded residue vectors are all of the same length. High level -coding structure, ignoring for the moment exactly how a partition is -encoded and simply trusting that it is, is as follows: - -\begin{itemize} -\item Each vector is partitioned into multiple equal sized chunks -according to configuration specified. If we have a vector size of -\emph{n}, a partition size \emph{residue\_partition\_size}, and a total -of \emph{ch} residue vectors, the total number of partitioned chunks -coded is \emph{n}/\emph{residue\_partition\_size}*\emph{ch}. It is -important to note that the integer division truncates. In the below -example, we assume an example \emph{residue\_partition\_size} of 8. - -\item Each partition in each vector has a classification number that -specifies which of multiple configured VQ codebook setups are used to -decode that partition. The classification numbers of each partition -can be thought of as forming a vector in their own right, as in the -illustration below. Just as the residue vectors are coded in grouped -partitions to increase encoding efficiency, the classification vector -is also partitioned into chunks. The integer elements of each scalar -in a classification chunk are built into a single scalar that -represents the classification numbers in that chunk. In the below -example, the classification codeword encodes two classification -numbers. - -\item The values in a residue vector may be encoded monolithically in a -single pass through the residue vector, but more often efficient -codebook design dictates that each vector is encoded as the additive -sum of several passes through the residue vector using more than one -VQ codebook. Thus, each residue value potentially accumulates values -from multiple decode passes. The classification value associated with -a partition is the same in each pass, thus the classification codeword -is coded only in the first pass. - -\end{itemize} - - -\begin{center} -\includegraphics[width=\textwidth]{residue-pack} -\captionof{figure}{illustration of residue vector format} -\end{center} - - - -\subsection{residue 0} - -Residue 0 and 1 differ only in the way the values within a residue -partition are interleaved during partition encoding (visually treated -as a black box--or cyan box or brown box--in the above figure). - -Residue encoding 0 interleaves VQ encoding according to the -dimension of the codebook used to encode a partition in a specific -pass. The dimension of the codebook need not be the same in multiple -passes, however the partition size must be an even multiple of the -codebook dimension. - -As an example, assume a partition vector of size eight, to be encoded -by residue 0 using codebook sizes of 8, 4, 2 and 1: - -\begin{programlisting} - - original residue vector: [ 0 1 2 3 4 5 6 7 ] - -codebook dimensions = 8 encoded as: [ 0 1 2 3 4 5 6 7 ] - -codebook dimensions = 4 encoded as: [ 0 2 4 6 ], [ 1 3 5 7 ] - -codebook dimensions = 2 encoded as: [ 0 4 ], [ 1 5 ], [ 2 6 ], [ 3 7 ] - -codebook dimensions = 1 encoded as: [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ] - -\end{programlisting} - -It is worth mentioning at this point that no configurable value in the -residue coding setup is restricted to a power of two. - - - -\subsection{residue 1} - -Residue 1 does not interleave VQ encoding. It represents partition -vector scalars in order. As with residue 0, however, partition length -must be an integer multiple of the codebook dimension, although -dimension may vary from pass to pass. - -As an example, assume a partition vector of size eight, to be encoded -by residue 0 using codebook sizes of 8, 4, 2 and 1: - -\begin{programlisting} - - original residue vector: [ 0 1 2 3 4 5 6 7 ] - -codebook dimensions = 8 encoded as: [ 0 1 2 3 4 5 6 7 ] - -codebook dimensions = 4 encoded as: [ 0 1 2 3 ], [ 4 5 6 7 ] - -codebook dimensions = 2 encoded as: [ 0 1 ], [ 2 3 ], [ 4 5 ], [ 6 7 ] - -codebook dimensions = 1 encoded as: [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ] - -\end{programlisting} - - - -\subsection{residue 2} - -Residue type two can be thought of as a variant of residue type 1. -Rather than encoding multiple passed-in vectors as in residue type 1, -the \emph{ch} passed in vectors of length \emph{n} are first -interleaved and flattened into a single vector of length -\emph{ch}*\emph{n}. Encoding then proceeds as in type 1. Decoding is -as in type 1 with decode interleave reversed. If operating on a single -vector to begin with, residue type 1 and type 2 are equivalent. - -\begin{center} -\includegraphics[width=\textwidth]{residue2} -\captionof{figure}{illustration of residue type 2} -\end{center} - - -\subsection{Residue decode} - -\subsubsection{header decode} - -Header decode for all three residue types is identical. -\begin{programlisting} - 1) [residue\_begin] = read 24 bits as unsigned integer - 2) [residue\_end] = read 24 bits as unsigned integer - 3) [residue\_partition\_size] = read 24 bits as unsigned integer and add one - 4) [residue\_classifications] = read 6 bits as unsigned integer and add one - 5) [residue\_classbook] = read 8 bits as unsigned integer -\end{programlisting} - -\varname{[residue\_begin]} and -\varname{[residue\_end]} select the specific sub-portion of -each vector that is actually coded; it implements akin to a bandpass -where, for coding purposes, the vector effectively begins at element -\varname{[residue\_begin]} and ends at -\varname{[residue\_end]}. Preceding and following values in -the unpacked vectors are zeroed. Note that for residue type 2, these -values as well as \varname{[residue\_partition\_size]}apply to -the interleaved vector, not the individual vectors before interleave. -\varname{[residue\_partition\_size]} is as explained above, -\varname{[residue\_classifications]} is the number of possible -classification to which a partition can belong and -\varname{[residue\_classbook]} is the codebook number used to -code classification codewords. The number of dimensions in book -\varname{[residue\_classbook]} determines how many -classification values are grouped into a single classification -codeword. Note that the number of entries and dimensions in book -\varname{[residue\_classbook]}, along with -\varname{[residue\_classifications]}, overdetermines to -possible number of classification codewords. -If \varname{[residue\_classifications]}\^{}\varname{[residue\_classbook]}.dimensions -exceeds \varname{[residue\_classbook]}.entries, the -bitstream should be regarded to be undecodable. - -Next we read a bitmap pattern that specifies which partition classes -code values in which passes. - -\begin{programlisting} - 1) iterate [i] over the range 0 ... [residue\_classifications]-1 { - - 2) [high\_bits] = 0 - 3) [low\_bits] = read 3 bits as unsigned integer - 4) [bitflag] = read one bit as boolean - 5) if ( [bitflag] is set ) then [high\_bits] = read five bits as unsigned integer - 6) vector [residue\_cascade] element [i] = [high\_bits] * 8 + [low\_bits] - } - 7) done -\end{programlisting} - -Finally, we read in a list of book numbers, each corresponding to -specific bit set in the cascade bitmap. We loop over the possible -codebook classifications and the maximum possible number of encoding -stages (8 in Vorbis I, as constrained by the elements of the cascade -bitmap being eight bits): - -\begin{programlisting} - 1) iterate [i] over the range 0 ... [residue\_classifications]-1 { - - 2) iterate [j] over the range 0 ... 7 { - - 3) if ( vector [residue\_cascade] element [i] bit [j] is set ) { - - 4) array [residue\_books] element [i][j] = read 8 bits as unsigned integer - - } else { - - 5) array [residue\_books] element [i][j] = unused - - } - } - } - - 6) done -\end{programlisting} - -An end-of-packet condition at any point in header decode renders the -stream undecodable. In addition, any codebook number greater than the -maximum numbered codebook set up in this stream also renders the -stream undecodable. All codebooks in array [residue\_books] are -required to have a value mapping. The presence of codebook in array -[residue\_books] without a value mapping (maptype equals zero) renders -the stream undecodable. - - - -\subsubsection{packet decode} - -Format 0 and 1 packet decode is identical except for specific -partition interleave. Format 2 packet decode can be built out of the -format 1 decode process. Thus we describe first the decode -infrastructure identical to all three formats. - -In addition to configuration information, the residue decode process -is passed the number of vectors in the submap bundle and a vector of -flags indicating if any of the vectors are not to be decoded. If the -passed in number of vectors is 3 and vector number 1 is marked 'do not -decode', decode skips vector 1 during the decode loop. However, even -'do not decode' vectors are allocated and zeroed. - -Depending on the values of \varname{[residue\_begin]} and -\varname{[residue\_end]}, it is obvious that the encoded -portion of a residue vector may be the entire possible residue vector -or some other strict subset of the actual residue vector size with -zero padding at either uncoded end. However, it is also possible to -set \varname{[residue\_begin]} and -\varname{[residue\_end]} to specify a range partially or -wholly beyond the maximum vector size. Before beginning residue -decode, limit \varname{[residue\_begin]} and -\varname{[residue\_end]} to the maximum possible vector size -as follows. We assume that the number of vectors being encoded, -\varname{[ch]} is provided by the higher level decoding -process. - -\begin{programlisting} - 1) [actual\_size] = current blocksize/2; - 2) if residue encoding is format 2 - 3) [actual\_size] = [actual\_size] * [ch]; - 4) [limit\_residue\_begin] = minimum of ([residue\_begin],[actual\_size]); - 5) [limit\_residue\_end] = minimum of ([residue\_end],[actual\_size]); -\end{programlisting} - -The following convenience values are conceptually useful to clarifying -the decode process: - -\begin{programlisting} - 1) [classwords\_per\_codeword] = [codebook\_dimensions] value of codebook [residue\_classbook] - 2) [n\_to\_read] = [limit\_residue\_end] - [limit\_residue\_begin] - 3) [partitions\_to\_read] = [n\_to\_read] / [residue\_partition\_size] -\end{programlisting} - -Packet decode proceeds as follows, matching the description offered earlier in the document. -\begin{programlisting} - 1) allocate and zero all vectors that will be returned. - 2) if ([n\_to\_read] is zero), stop; there is no residue to decode. - 3) iterate [pass] over the range 0 ... 7 { - - 4) [partition\_count] = 0 - - 5) while [partition\_count] is less than [partitions\_to\_read] - - 6) if ([pass] is zero) { - - 7) iterate [j] over the range 0 .. [ch]-1 { - - 8) if vector [j] is not marked 'do not decode' { - - 9) [temp] = read from packet using codebook [residue\_classbook] in scalar context - 10) iterate [i] descending over the range [classwords\_per\_codeword]-1 ... 0 { - - 11) array [classifications] element [j],([i]+[partition\_count]) = - [temp] integer modulo [residue\_classifications] - 12) [temp] = [temp] / [residue\_classifications] using integer division - - } - - } - - } - - } - - 13) iterate [i] over the range 0 .. ([classwords\_per\_codeword] - 1) while [partition\_count] - is also less than [partitions\_to\_read] { - - 14) iterate [j] over the range 0 .. [ch]-1 { - - 15) if vector [j] is not marked 'do not decode' { - - 16) [vqclass] = array [classifications] element [j],[partition\_count] - 17) [vqbook] = array [residue\_books] element [vqclass],[pass] - 18) if ([vqbook] is not 'unused') { - - 19) decode partition into output vector number [j], starting at scalar - offset [limit\_residue\_begin]+[partition\_count]*[residue\_partition\_size] using - codebook number [vqbook] in VQ context - } - } - - 20) increment [partition\_count] by one - - } - } - } - - 21) done - -\end{programlisting} - -An end-of-packet condition during packet decode is to be considered a -nominal occurrence. Decode returns the result of vector decode up to -that point. - - - -\subsubsection{format 0 specifics} - -Format zero decodes partitions exactly as described earlier in the -'Residue Format: residue 0' section. The following pseudocode -presents the same algorithm. Assume: - -\begin{itemize} -\item \varname{[n]} is the value in \varname{[residue\_partition\_size]} -\item \varname{[v]} is the residue vector -\item \varname{[offset]} is the beginning read offset in [v] -\end{itemize} - - -\begin{programlisting} - 1) [step] = [n] / [codebook\_dimensions] - 2) iterate [i] over the range 0 ... [step]-1 { - - 3) vector [entry\_temp] = read vector from packet using current codebook in VQ context - 4) iterate [j] over the range 0 ... [codebook\_dimensions]-1 { - - 5) vector [v] element ([offset]+[i]+[j]*[step]) = - vector [v] element ([offset]+[i]+[j]*[step]) + - vector [entry\_temp] element [j] - - } - - } - - 6) done - -\end{programlisting} - - - -\subsubsection{format 1 specifics} - -Format 1 decodes partitions exactly as described earlier in the -'Residue Format: residue 1' section. The following pseudocode -presents the same algorithm. Assume: - -\begin{itemize} -\item \varname{[n]} is the value in -\varname{[residue\_partition\_size]} -\item \varname{[v]} is the residue vector -\item \varname{[offset]} is the beginning read offset in [v] -\end{itemize} - - -\begin{programlisting} - 1) [i] = 0 - 2) vector [entry\_temp] = read vector from packet using current codebook in VQ context - 3) iterate [j] over the range 0 ... [codebook\_dimensions]-1 { - - 4) vector [v] element ([offset]+[i]) = - vector [v] element ([offset]+[i]) + - vector [entry\_temp] element [j] - 5) increment [i] - - } - - 6) if ( [i] is less than [n] ) continue at step 2 - 7) done -\end{programlisting} - - - -\subsubsection{format 2 specifics} - -Format 2 is reducible to format 1. It may be implemented as an additional step prior to and an additional post-decode step after a normal format 1 decode. - - -Format 2 handles 'do not decode' vectors differently than residue 0 or -1; if all vectors are marked 'do not decode', no decode occurrs. -However, if at least one vector is to be decoded, all the vectors are -decoded. We then request normal format 1 to decode a single vector -representing all output channels, rather than a vector for each -channel. After decode, deinterleave the vector into independent vectors, one for each output channel. That is: - -\begin{enumerate} - \item If all vectors 0 through \emph{ch}-1 are marked 'do not decode', allocate and clear a single vector \varname{[v]}of length \emph{ch*n} and skip step 2 below; proceed directly to the post-decode step. - \item Rather than performing format 1 decode to produce \emph{ch} vectors of length \emph{n} each, call format 1 decode to produce a single vector \varname{[v]} of length \emph{ch*n}. - \item Post decode: Deinterleave the single vector \varname{[v]} returned by format 1 decode as described above into \emph{ch} independent vectors, one for each outputchannel, according to: - \begin{programlisting} - 1) iterate [i] over the range 0 ... [n]-1 { - - 2) iterate [j] over the range 0 ... [ch]-1 { - - 3) output vector number [j] element [i] = vector [v] element ([i] * [ch] + [j]) - - } - } - - 4) done - \end{programlisting} - -\end{enumerate} - - - - - - - diff --git a/Engine/lib/libvorbis/doc/09-helper.tex b/Engine/lib/libvorbis/doc/09-helper.tex deleted file mode 100644 index 0a13795b2..000000000 --- a/Engine/lib/libvorbis/doc/09-helper.tex +++ /dev/null @@ -1,180 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Helper equations} \label{vorbis:spec:helper} - -\subsection{Overview} - -The equations below are used in multiple places by the Vorbis codec -specification. Rather than cluttering up the main specification -documents, they are defined here and referenced where appropriate. - - -\subsection{Functions} - -\subsubsection{ilog} \label{vorbis:spec:ilog} - -The "ilog(x)" function returns the position number (1 through n) of the highest set bit in the two's complement integer value -\varname{[x]}. Values of \varname{[x]} less than zero are defined to return zero. - -\begin{programlisting} - 1) [return\_value] = 0; - 2) if ( [x] is greater than zero ) { - - 3) increment [return\_value]; - 4) logical shift [x] one bit to the right, padding the MSb with zero - 5) repeat at step 2) - - } - - 6) done -\end{programlisting} - -Examples: - -\begin{itemize} - \item ilog(0) = 0; - \item ilog(1) = 1; - \item ilog(2) = 2; - \item ilog(3) = 2; - \item ilog(4) = 3; - \item ilog(7) = 3; - \item ilog(negative number) = 0; -\end{itemize} - - - - -\subsubsection{float32\_unpack} \label{vorbis:spec:float32:unpack} - -"float32\_unpack(x)" is intended to translate the packed binary -representation of a Vorbis codebook float value into the -representation used by the decoder for floating point numbers. For -purposes of this example, we will unpack a Vorbis float32 into a -host-native floating point number. - -\begin{programlisting} - 1) [mantissa] = [x] bitwise AND 0x1fffff (unsigned result) - 2) [sign] = [x] bitwise AND 0x80000000 (unsigned result) - 3) [exponent] = ( [x] bitwise AND 0x7fe00000) shifted right 21 bits (unsigned result) - 4) if ( [sign] is nonzero ) then negate [mantissa] - 5) return [mantissa] * ( 2 ^ ( [exponent] - 788 ) ) -\end{programlisting} - - - -\subsubsection{lookup1\_values} \label{vorbis:spec:lookup1:values} - -"lookup1\_values(codebook\_entries,codebook\_dimensions)" is used to -compute the correct length of the value index for a codebook VQ lookup -table of lookup type 1. The values on this list are permuted to -construct the VQ vector lookup table of size -\varname{[codebook\_entries]}. - -The return value for this function is defined to be 'the greatest -integer value for which \varname{[return\_value]} to the power of -\varname{[codebook\_dimensions]} is less than or equal to -\varname{[codebook\_entries]}'. - - - -\subsubsection{low\_neighbor} \label{vorbis:spec:low:neighbor} - -"low\_neighbor(v,x)" finds the position \varname{n} in vector \varname{[v]} of -the greatest value scalar element for which \varname{n} is less than -\varname{[x]} and vector \varname{[v]} element \varname{n} is less -than vector \varname{[v]} element \varname{[x]}. - -\subsubsection{high\_neighbor} \label{vorbis:spec:high:neighbor} - -"high\_neighbor(v,x)" finds the position \varname{n} in vector [v] of -the lowest value scalar element for which \varname{n} is less than -\varname{[x]} and vector \varname{[v]} element \varname{n} is greater -than vector \varname{[v]} element \varname{[x]}. - - - -\subsubsection{render\_point} \label{vorbis:spec:render:point} - -"render\_point(x0,y0,x1,y1,X)" is used to find the Y value at point X -along the line specified by x0, x1, y0 and y1. This function uses an -integer algorithm to solve for the point directly without calculating -intervening values along the line. - -\begin{programlisting} - 1) [dy] = [y1] - [y0] - 2) [adx] = [x1] - [x0] - 3) [ady] = absolute value of [dy] - 4) [err] = [ady] * ([X] - [x0]) - 5) [off] = [err] / [adx] using integer division - 6) if ( [dy] is less than zero ) { - - 7) [Y] = [y0] - [off] - - } else { - - 8) [Y] = [y0] + [off] - - } - - 9) done -\end{programlisting} - - - -\subsubsection{render\_line} \label{vorbis:spec:render:line} - -Floor decode type one uses the integer line drawing algorithm of -"render\_line(x0, y0, x1, y1, v)" to construct an integer floor -curve for contiguous piecewise line segments. Note that it has not -been relevant elsewhere, but here we must define integer division as -rounding division of both positive and negative numbers toward zero. - - -\begin{programlisting} - 1) [dy] = [y1] - [y0] - 2) [adx] = [x1] - [x0] - 3) [ady] = absolute value of [dy] - 4) [base] = [dy] / [adx] using integer division - 5) [x] = [x0] - 6) [y] = [y0] - 7) [err] = 0 - - 8) if ( [dy] is less than 0 ) { - - 9) [sy] = [base] - 1 - - } else { - - 10) [sy] = [base] + 1 - - } - - 11) [ady] = [ady] - (absolute value of [base]) * [adx] - 12) vector [v] element [x] = [y] - - 13) iterate [x] over the range [x0]+1 ... [x1]-1 { - - 14) [err] = [err] + [ady]; - 15) if ( [err] >= [adx] ) { - - 16) [err] = [err] - [adx] - 17) [y] = [y] + [sy] - - } else { - - 18) [y] = [y] + [base] - - } - - 19) vector [v] element [x] = [y] - - } -\end{programlisting} - - - - - - - - diff --git a/Engine/lib/libvorbis/doc/10-tables.tex b/Engine/lib/libvorbis/doc/10-tables.tex deleted file mode 100644 index c2881d63b..000000000 --- a/Engine/lib/libvorbis/doc/10-tables.tex +++ /dev/null @@ -1,76 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Tables} \label{vorbis:spec:tables} - -\subsection{floor1\_inverse\_dB\_table} \label{vorbis:spec:floor1:inverse:dB:table} - -The vector \varname{[floor1\_inverse\_dB\_table]} is a 256 element static -lookup table consisting of the following values (read left to right -then top to bottom): - -\begin{Verbatim} - 1.0649863e-07, 1.1341951e-07, 1.2079015e-07, 1.2863978e-07, - 1.3699951e-07, 1.4590251e-07, 1.5538408e-07, 1.6548181e-07, - 1.7623575e-07, 1.8768855e-07, 1.9988561e-07, 2.1287530e-07, - 2.2670913e-07, 2.4144197e-07, 2.5713223e-07, 2.7384213e-07, - 2.9163793e-07, 3.1059021e-07, 3.3077411e-07, 3.5226968e-07, - 3.7516214e-07, 3.9954229e-07, 4.2550680e-07, 4.5315863e-07, - 4.8260743e-07, 5.1396998e-07, 5.4737065e-07, 5.8294187e-07, - 6.2082472e-07, 6.6116941e-07, 7.0413592e-07, 7.4989464e-07, - 7.9862701e-07, 8.5052630e-07, 9.0579828e-07, 9.6466216e-07, - 1.0273513e-06, 1.0941144e-06, 1.1652161e-06, 1.2409384e-06, - 1.3215816e-06, 1.4074654e-06, 1.4989305e-06, 1.5963394e-06, - 1.7000785e-06, 1.8105592e-06, 1.9282195e-06, 2.0535261e-06, - 2.1869758e-06, 2.3290978e-06, 2.4804557e-06, 2.6416497e-06, - 2.8133190e-06, 2.9961443e-06, 3.1908506e-06, 3.3982101e-06, - 3.6190449e-06, 3.8542308e-06, 4.1047004e-06, 4.3714470e-06, - 4.6555282e-06, 4.9580707e-06, 5.2802740e-06, 5.6234160e-06, - 5.9888572e-06, 6.3780469e-06, 6.7925283e-06, 7.2339451e-06, - 7.7040476e-06, 8.2047000e-06, 8.7378876e-06, 9.3057248e-06, - 9.9104632e-06, 1.0554501e-05, 1.1240392e-05, 1.1970856e-05, - 1.2748789e-05, 1.3577278e-05, 1.4459606e-05, 1.5399272e-05, - 1.6400004e-05, 1.7465768e-05, 1.8600792e-05, 1.9809576e-05, - 2.1096914e-05, 2.2467911e-05, 2.3928002e-05, 2.5482978e-05, - 2.7139006e-05, 2.8902651e-05, 3.0780908e-05, 3.2781225e-05, - 3.4911534e-05, 3.7180282e-05, 3.9596466e-05, 4.2169667e-05, - 4.4910090e-05, 4.7828601e-05, 5.0936773e-05, 5.4246931e-05, - 5.7772202e-05, 6.1526565e-05, 6.5524908e-05, 6.9783085e-05, - 7.4317983e-05, 7.9147585e-05, 8.4291040e-05, 8.9768747e-05, - 9.5602426e-05, 0.00010181521, 0.00010843174, 0.00011547824, - 0.00012298267, 0.00013097477, 0.00013948625, 0.00014855085, - 0.00015820453, 0.00016848555, 0.00017943469, 0.00019109536, - 0.00020351382, 0.00021673929, 0.00023082423, 0.00024582449, - 0.00026179955, 0.00027881276, 0.00029693158, 0.00031622787, - 0.00033677814, 0.00035866388, 0.00038197188, 0.00040679456, - 0.00043323036, 0.00046138411, 0.00049136745, 0.00052329927, - 0.00055730621, 0.00059352311, 0.00063209358, 0.00067317058, - 0.00071691700, 0.00076350630, 0.00081312324, 0.00086596457, - 0.00092223983, 0.00098217216, 0.0010459992, 0.0011139742, - 0.0011863665, 0.0012634633, 0.0013455702, 0.0014330129, - 0.0015261382, 0.0016253153, 0.0017309374, 0.0018434235, - 0.0019632195, 0.0020908006, 0.0022266726, 0.0023713743, - 0.0025254795, 0.0026895994, 0.0028643847, 0.0030505286, - 0.0032487691, 0.0034598925, 0.0036847358, 0.0039241906, - 0.0041792066, 0.0044507950, 0.0047400328, 0.0050480668, - 0.0053761186, 0.0057254891, 0.0060975636, 0.0064938176, - 0.0069158225, 0.0073652516, 0.0078438871, 0.0083536271, - 0.0088964928, 0.009474637, 0.010090352, 0.010746080, - 0.011444421, 0.012188144, 0.012980198, 0.013823725, - 0.014722068, 0.015678791, 0.016697687, 0.017782797, - 0.018938423, 0.020169149, 0.021479854, 0.022875735, - 0.024362330, 0.025945531, 0.027631618, 0.029427276, - 0.031339626, 0.033376252, 0.035545228, 0.037855157, - 0.040315199, 0.042935108, 0.045725273, 0.048696758, - 0.051861348, 0.055231591, 0.058820850, 0.062643361, - 0.066714279, 0.071049749, 0.075666962, 0.080584227, - 0.085821044, 0.091398179, 0.097337747, 0.10366330, - 0.11039993, 0.11757434, 0.12521498, 0.13335215, - 0.14201813, 0.15124727, 0.16107617, 0.17154380, - 0.18269168, 0.19456402, 0.20720788, 0.22067342, - 0.23501402, 0.25028656, 0.26655159, 0.28387361, - 0.30232132, 0.32196786, 0.34289114, 0.36517414, - 0.38890521, 0.41417847, 0.44109412, 0.46975890, - 0.50028648, 0.53279791, 0.56742212, 0.60429640, - 0.64356699, 0.68538959, 0.72993007, 0.77736504, - 0.82788260, 0.88168307, 0.9389798, 1. -\end{Verbatim} diff --git a/Engine/lib/libvorbis/doc/Doxyfile.in b/Engine/lib/libvorbis/doc/Doxyfile.in deleted file mode 100644 index cdb894fa6..000000000 --- a/Engine/lib/libvorbis/doc/Doxyfile.in +++ /dev/null @@ -1,1142 +0,0 @@ -# Doxyfile 1.3.7 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = @PACKAGE@ - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = @VERSION@ - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = vorbis - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 2 levels of 10 sub-directories under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of source -# files, where putting all generated files in the same directory would otherwise -# cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en -# (Japanese with English messages), Korean, Korean-en, Norwegian, Polish, Portuguese, -# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). -#This tag is now obsolete, according to doxygen 1.5.2 -#USE_WINDOWS_ENCODING = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is used -# as the annotated text. Otherwise, the brief description is used as-is. If left -# blank, the following values are used ("$name" is automatically replaced with the -# name of the entity): "The $name class" "The $name widget" "The $name file" -# "is" "provides" "specifies" "contains" "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = @top_srcdir@/include/vorbis - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories -# that are symbolic links (a Unix filesystem feature) are excluded from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. - -INPUT_FILTER = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse the -# parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. Note that this -# option is superseded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. -#This tag is now obsolete, according to doxygen 1.5.2 -#MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. -#This tag is now obsolete, according to doxygen 1.5.2 -#MAX_DOT_GRAPH_HEIGHT = 1024 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes that -# lay further from the root node will be omitted. Note that setting this option to -# 1 or 2 may greatly reduce the computation time needed for large code bases. Also -# note that a graph may be further truncated if the graph's image dimensions are -# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). -# If 0 is used for the depth value (the default), the graph is not depth-constrained. -#This tag is now obsolete, according to doxygen 1.5.2 -#MAX_DOT_GRAPH_DEPTH = 0 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/Engine/lib/libvorbis/doc/Makefile.am b/Engine/lib/libvorbis/doc/Makefile.am deleted file mode 100644 index 3f1424797..000000000 --- a/Engine/lib/libvorbis/doc/Makefile.am +++ /dev/null @@ -1,152 +0,0 @@ -## Process this with automake to create Makefile.in - -SUBDIRS = libvorbis vorbisfile vorbisenc - -docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION) - -### all of the static docs, commited to SVN and included as is -static_docs = \ - rfc5215.xml \ - rfc5215.txt \ - eightphase.png \ - fish_xiph_org.png \ - floor1_inverse_dB_table.html \ - floorval.png \ - fourphase.png \ - framing.html \ - helper.html \ - index.html \ - oggstream.html \ - programming.html \ - squarepolar.png \ - stereo.html \ - stream.png \ - v-comment.html \ - vorbis-clip.txt \ - vorbis-errors.txt \ - vorbis-fidelity.html - -# bits needed by the spec -SPEC_TEX = \ - Vorbis_I_spec.tex \ - 01-introduction.tex \ - 02-bitpacking.tex \ - 03-codebook.tex \ - 04-codec.tex \ - 05-comment.tex \ - 06-floor0.tex \ - 07-floor1.tex \ - 08-residue.tex \ - 09-helper.tex \ - 10-tables.tex \ - a1-encapsulation-ogg.tex \ - a2-encapsulation-rtp.tex \ - footer.tex - -SPEC_PNG = \ - components.png \ - floor1-1.png \ - floor1-2.png \ - floor1-3.png \ - floor1-4.png \ - hufftree.png \ - hufftree-under.png \ - residue-pack.png \ - residue2.png \ - window1.png \ - window2.png - -# Figure images generated by htlatex -built_SPEC_PNG = \ - Vorbis_I_spec0x.png \ - Vorbis_I_spec1x.png \ - Vorbis_I_spec2x.png \ - Vorbis_I_spec3x.png \ - Vorbis_I_spec4x.png \ - Vorbis_I_spec5x.png \ - Vorbis_I_spec6x.png \ - Vorbis_I_spec7x.png \ - Vorbis_I_spec8x.png \ - Vorbis_I_spec9x.png \ - Vorbis_I_spec10x.png \ - Vorbis_I_spec11x.png \ - Vorbis_I_spec12x.png \ - Vorbis_I_spec13x.png \ - Vorbis_I_spec14x.png - - -built_docs = Vorbis_I_spec.pdf \ - Vorbis_I_spec.html Vorbis_I_spec.css $(built_SPEC_PNG) - -# conditionally make the generated documentation -if BUILD_DOCS -doc_DATA = $(static_docs) $(SPEC_PNG) $(built_docs) doxygen-build.stamp -else -doc_DATA = $(static_docs) doxygen-build.stamp -endif - -EXTRA_DIST = $(static_docs) $(built_docs) \ - $(SPEC_TEX) $(SPEC_PNG) $(SPEC_PDF) Vorbis_I_spec.cfg Doxyfile.in - -# these are expensive; only remove if we have to -MAINTAINERCLEANFILES = $(built_docs) -CLEANFILES = $(SPEC_TEX:%.tex=%.aux) \ - Vorbis_I_spec.4ct Vorbis_I_spec.4tc \ - Vorbis_I_spec.dvi Vorbis_I_spec.idv \ - Vorbis_I_spec.lg Vorbis_I_spec.log \ - Vorbis_I_spec.out Vorbis_I_spec.tmp \ - Vorbis_I_spec.toc Vorbis_I_spec.xref \ - Vorbis_I_spec.out.ps \ - zzVorbis_I_spec.ps - -# explicit rules for generating docs -if BUILD_DOCS -Vorbis_I_spec.html Vorbis_I_spec.css: $(SPEC_TEX) $(SPEC_PNG) fish_xiph_org.png - htlatex $< - -Vorbis_I_spec.pdf: $(SPEC_TEX) $(SPEC_PNG) - pdflatex $< - pdflatex $< - pdflatex $< -else -Vorbis_I_spec.html: NO_DOCS_ERROR -Vorbis_I_spec.pdf: NO_DOCS_ERROR -NO_DOCS_ERROR: - @echo - @echo "*** Documentation has not been built! ***" - @echo "Try re-running after passing --enable-docs to configure." - @echo -endif - -if HAVE_DOXYGEN -doxygen-build.stamp: Doxyfile $(top_srcdir)/include/vorbis/*.h - doxygen - touch doxygen-build.stamp -else -doxygen-build.stamp: - echo "*** Warning: Documentation build is disabled." - touch doxygen-build.stamp -endif - -install-data-local: doxygen-build.stamp - $(mkinstalldirs) $(DESTDIR)$(docdir) - if test -d vorbis; then \ - for dir in vorbis/*; do \ - if test -d $$dir; then \ - b=`basename $$dir`; \ - $(mkinstalldirs) $(DESTDIR)$(docdir)/$$b; \ - for f in $$dir/*; do \ - $(INSTALL_DATA) $$f $(DESTDIR)$(docdir)/$$b; \ - done \ - fi \ - done \ - fi - -uninstall-local: - rm -rf $(DESTDIR)$(docdir) - -clean-local: - if test -d vorbis; then rm -rf vorbis; fi - if test -f doxygen-build.stamp; then rm -f doxygen-build.stamp; fi - - diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec.cfg b/Engine/lib/libvorbis/doc/Vorbis_I_spec.cfg deleted file mode 100644 index 6fca7cece..000000000 --- a/Engine/lib/libvorbis/doc/Vorbis_I_spec.cfg +++ /dev/null @@ -1,4 +0,0 @@ -\Preamble{html} -\begin{document} - \DeclareGraphicsExtensions{.png} -\EndPreamble diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec.css b/Engine/lib/libvorbis/doc/Vorbis_I_spec.css deleted file mode 100644 index 5331f1841..000000000 --- a/Engine/lib/libvorbis/doc/Vorbis_I_spec.css +++ /dev/null @@ -1,144 +0,0 @@ - -/* start css.sty */ -.cmex-10{font-size:83%;} -.cmssbx-10x-x-120{ font-family: sans-serif; font-weight: bold;} -.cmssbx-10x-x-120{ font-family: sans-serif; font-weight: bold;} -.cmssbx-10x-x-248{font-size:206%; font-family: sans-serif; font-weight: bold;} -.cmssbx-10x-x-248{ font-family: sans-serif; font-weight: bold;} -.cmr-17{font-size:141%;} -.cmmi-12{font-style: italic;} -.cmtt-12{font-family: monospace;} -.cmtt-12{font-family: monospace;} -.cmtt-12{font-family: monospace;} -.cmbx-12{ font-weight: bold;} -.cmti-12{ font-style: italic;} -.cmr-8{font-size:66%;} -.cmr-6{font-size:50%;} -.cmmi-8{font-size:66%;font-style: italic;} -.cmsy-8{font-size:66%;} -.cmsy-6{font-size:50%;} -.cmtt-8{font-size:66%;font-family: monospace;} -.cmtt-8{font-family: monospace;} -.cmtt-8{font-family: monospace;} -.cmtt-8x-x-75{font-size:50%;font-family: monospace;} -.cmtt-8x-x-75{font-family: monospace;} -.cmtt-8x-x-75{font-family: monospace;} -p.noindent { text-indent: 0em } -td p.noindent { text-indent: 0em; margin-top:0em; } -p.nopar { text-indent: 0em; } -p.indent{ text-indent: 1.5em } -@media print {div.crosslinks {visibility:hidden;}} -a img { border-top: 0; border-left: 0; border-right: 0; } -center { margin-top:1em; margin-bottom:1em; } -td center { margin-top:0em; margin-bottom:0em; } -.Canvas { position:relative; } -img.math{vertical-align:middle;} -li p.indent { text-indent: 0em } -li p:first-child{ margin-top:0em; } -li p:last-child, li div:last-child { margin-bottom:0.5em; } -li p~ul:last-child, li p~ol:last-child{ margin-bottom:0.5em; } -.enumerate1 {list-style-type:decimal;} -.enumerate2 {list-style-type:lower-alpha;} -.enumerate3 {list-style-type:lower-roman;} -.enumerate4 {list-style-type:upper-alpha;} -div.newtheorem { margin-bottom: 2em; margin-top: 2em;} -.obeylines-h,.obeylines-v {white-space: nowrap; } -div.obeylines-v p { margin-top:0; margin-bottom:0; } -.overline{ text-decoration:overline; } -.overline img{ border-top: 1px solid black; } -td.displaylines {text-align:center; white-space:nowrap;} -.centerline {text-align:center;} -.rightline {text-align:right;} -div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; } -.fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; } -div.fbox {display:table} -div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; } -div.minipage{width:100%;} -div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;} -div.center div {text-align: left;} -div.flushright, div.flushright div.flushright {text-align: right;} -div.flushright div {text-align: left;} -div.flushleft {text-align: left;} -.underline{ text-decoration:underline; } -.underline img{ border-bottom: 1px solid black; margin-bottom:1pt; } -.framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; } -.framebox-c {text-align:center;} -.framebox-l {text-align:left;} -.framebox-r {text-align:right;} -span.thank-mark{ vertical-align: super } -span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; } -div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; } -table.tabular td p{margin-top:0em;} -table.tabular {margin-left: auto; margin-right: auto;} -td p:first-child{ margin-top:0em; } -td p:last-child{ margin-bottom:0em; } -div.td00{ margin-left:0pt; margin-right:0pt; } -div.td01{ margin-left:0pt; margin-right:5pt; } -div.td10{ margin-left:5pt; margin-right:0pt; } -div.td11{ margin-left:5pt; margin-right:5pt; } -table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; } -td.td00{ padding-left:0pt; padding-right:0pt; } -td.td01{ padding-left:0pt; padding-right:5pt; } -td.td10{ padding-left:5pt; padding-right:0pt; } -td.td11{ padding-left:5pt; padding-right:5pt; } -table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; } -.hline hr, .cline hr{ height : 1px; margin:0px; } -.tabbing-right {text-align:right;} -span.TEX {letter-spacing: -0.125em; } -span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;} -a span.TEX span.E {text-decoration: none; } -span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;} -span.LATEX span.TEX{ position:relative; left: -0.4em; } -div.float, div.figure {margin-left: auto; margin-right: auto;} -div.float img {text-align:center;} -div.figure img {text-align:center;} -.marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;} -.marginpar p{margin-top:0.4em; margin-bottom:0.4em;} -table.equation {width:100%;} -.equation td{text-align:center; } -td.equation { margin-top:1em; margin-bottom:1em; } -td.equation-label { width:5%; text-align:center; } -td.eqnarray4 { width:5%; white-space: normal; } -td.eqnarray2 { width:5%; } -table.eqnarray-star, table.eqnarray {width:100%;} -div.eqnarray{text-align:center;} -div.array {text-align:center;} -div.pmatrix {text-align:center;} -table.pmatrix {width:100%;} -span.pmatrix img{vertical-align:middle;} -div.pmatrix {text-align:center;} -table.pmatrix {width:100%;} -span.bar-css {text-decoration:overline;} -img.cdots{vertical-align:middle;} -.partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;} -.chapterToc a, .chapterToc, .likechapterToc a, .likechapterToc, .appendixToc a, .appendixToc {line-height: 200%; font-weight:bold;} -.index-item, .index-subitem, .index-subsubitem {display:block} -div.caption {text-indent:-2em; margin-left:3em; margin-right:1em; text-align:left;} -div.caption span.id{font-weight: bold; white-space: nowrap; } -h1.partHead{text-align: center} -p.bibitem { text-indent: -2em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; } -p.bibitem-p { text-indent: 0em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; } -.paragraphHead, .likeparagraphHead { margin-top:2em; font-weight: bold;} -.subparagraphHead, .likesubparagraphHead { font-weight: bold;} -.quote {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; margin-right:1em; text-align:justify;} -.verse{white-space:nowrap; margin-left:2em} -div.maketitle {text-align:center;} -h2.titleHead{text-align:center;} -div.maketitle{ margin-bottom: 2em; } -div.author, div.date {text-align:center;} -div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; } -div.author{white-space: nowrap;} -.quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; } -.abstract p {margin-left:5%; margin-right:5%;} -div.abstract {width:100%;} -span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; } -.figure img.graphics {margin-left:10%;} -P.fancyvrb {white-space: nowrap; margin:0em;} -dt.enumerate-enumitem{float:left; clear:left; margin-left:1em; margin-right:1em;} -.uline{ text-decoration:underline; } -.uuline{ text-decoration:underline; } -span.sout {text-decoration: line-through } -span.xout {text-decoration: line-through } -span.uwave {text-decoration:underline } -/* end css.sty */ - diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec.html b/Engine/lib/libvorbis/doc/Vorbis_I_spec.html deleted file mode 100644 index a1d9496ff..000000000 --- a/Engine/lib/libvorbis/doc/Vorbis_I_spec.html +++ /dev/null @@ -1,12524 +0,0 @@ - - -Vorbis I specification - - - - - - - -
    - - - - -

    Vorbis I specification

    -
    Xiph.Org Foundation

    -
    July 4, 2020
    -
    -

    Contents

    -
    1 Introduction and Description -
      1.1 Overview -
       1.1.1 Application -
       1.1.2 Classification -
       1.1.3 Assumptions -
       1.1.4 Codec Setup and Probability Model -
       1.1.5 Format Specification -
       1.1.6 Hardware Profile -
      1.2 Decoder Configuration -
       1.2.1 Global Config -
       1.2.2 Mode -
       1.2.3 Mapping - - - -
       1.2.4 Floor -
       1.2.5 Residue -
       1.2.6 Codebooks -
      1.3 High-level Decode Process -
       1.3.1 Decode Setup -
       1.3.2 Decode Procedure -
     2 Bitpacking Convention -
      2.1 Overview -
       2.1.1 octets, bytes and words -
       2.1.2 bit order -
       2.1.3 byte order -
       2.1.4 coding bits into byte sequences -
       2.1.5 signedness -
       2.1.6 coding example -
       2.1.7 decoding example -
       2.1.8 end-of-packet alignment -
       2.1.9 reading zero bits -
     3 Probability Model and Codebooks -
      3.1 Overview -
       3.1.1 Bitwise operation -
      3.2 Packed codebook format -
       3.2.1 codebook decode -
      3.3 Use of the codebook abstraction -
     4 Codec Setup and Packet Decode -
      4.1 Overview -
      4.2 Header decode and decode setup -
       4.2.1 Common header decode -
       4.2.2 Identification header -
       4.2.3 Comment header - - - -
       4.2.4 Setup header -
      4.3 Audio packet decode and synthesis -
       4.3.1 packet type, mode and window decode -
       4.3.2 floor curve decode -
       4.3.3 nonzero vector propagate -
       4.3.4 residue decode -
       4.3.5 inverse coupling -
       4.3.6 dot product -
       4.3.7 inverse MDCT -
       4.3.8 overlap_add -
       4.3.9 output channel order -
     5 comment field and header specification -
      5.1 Overview -
      5.2 Comment encoding -
       5.2.1 Structure -
       5.2.2 Content vector format -
       5.2.3 Encoding -
     6 Floor type 0 setup and decode -
      6.1 Overview -
      6.2 Floor 0 format -
       6.2.1 header decode -
       6.2.2 packet decode -
       6.2.3 curve computation -
     7 Floor type 1 setup and decode -
      7.1 Overview -
      7.2 Floor 1 format -
       7.2.1 model -
       7.2.2 header decode -
       7.2.3 packet decode - - - -
       7.2.4 curve computation -
     8 Residue setup and decode -
      8.1 Overview -
      8.2 Residue format -
      8.3 residue 0 -
      8.4 residue 1 -
      8.5 residue 2 -
      8.6 Residue decode -
       8.6.1 header decode -
       8.6.2 packet decode -
       8.6.3 format 0 specifics -
       8.6.4 format 1 specifics -
       8.6.5 format 2 specifics -
     9 Helper equations -
      9.1 Overview -
      9.2 Functions -
       9.2.1 ilog -
       9.2.2 float32_unpack -
       9.2.3 lookup1_values -
       9.2.4 low_neighbor -
       9.2.5 high_neighbor -
       9.2.6 render_point -
       9.2.7 render_line -
     10 Tables -
      10.1 floor1_inverse_dB_table -
     A Embedding Vorbis into an Ogg stream -
      A.1 Overview -
       A.1.1 Restrictions -
       A.1.2 MIME type - - - -
      A.2 Encapsulation -
     B Vorbis encapsulation in RTP -
    - - - -

    1. Introduction and Description

    -

    -

    1.1. Overview

    -

    This document provides a high level description of the Vorbis codec’s construction. A bit-by-bit -specification appears beginning in section 4, “Codec Setup and Packet Decode”. The later -sections assume a high-level understanding of the Vorbis decode process, which is provided -here. -

    -

    1.1.1. Application
    -

    Vorbis is a general purpose perceptual audio CODEC intended to allow maximum encoder -flexibility, thus allowing it to scale competitively over an exceptionally wide range of bitrates. At -the high quality/bitrate end of the scale (CD or DAT rate stereo, 16/24 bits) it is in the same -league as MPEG-2 and MPC. Similarly, the 1.0 encoder can encode high-quality CD and DAT -rate stereo at below 48kbps without resampling to a lower rate. Vorbis is also intended for lower -and higher sample rates (from 8kHz telephony to 192kHz digital masters) and a range of channel -representations (monaural, polyphonic, stereo, quadraphonic, 5.1, ambisonic, or up to 255 -discrete channels). -

    -

    1.1.2. Classification
    -

    Vorbis I is a forward-adaptive monolithic transform CODEC based on the Modified Discrete -Cosine Transform. The codec is structured to allow addition of a hybrid wavelet filterbank in -Vorbis II to offer better transient response and reproduction using a transform better suited to -localized time events. - - - -

    -

    1.1.3. Assumptions
    -

    The Vorbis CODEC design assumes a complex, psychoacoustically-aware encoder and simple, -low-complexity decoder. Vorbis decode is computationally simpler than mp3, although it does -require more working memory as Vorbis has no static probability model; the vector codebooks -used in the first stage of decoding from the bitstream are packed in their entirety into the Vorbis -bitstream headers. In packed form, these codebooks occupy only a few kilobytes; the extent to -which they are pre-decoded into a cache is the dominant factor in decoder memory -usage. -

    Vorbis provides none of its own framing, synchronization or protection against errors; it -is solely a method of accepting input audio, dividing it into individual frames and -compressing these frames into raw, unformatted ’packets’. The decoder then accepts -these raw packets in sequence, decodes them, synthesizes audio frames from them, and -reassembles the frames into a facsimile of the original audio stream. Vorbis is a free-form -variable bit rate (VBR) codec and packets have no minimum size, maximum size, or -fixed/expected size. Packets are designed that they may be truncated (or padded) -and remain decodable; this is not to be considered an error condition and is used -extensively in bitrate management in peeling. Both the transport mechanism and -decoder must allow that a packet may be any size, or end before or after packet decode -expects. -

    Vorbis packets are thus intended to be used with a transport mechanism that provides free-form -framing, sync, positioning and error correction in accordance with these design assumptions, such -as Ogg (for file transport) or RTP (for network multicast). For purposes of a few examples in this -document, we will assume that Vorbis is to be embedded in an Ogg stream specifically, -although this is by no means a requirement or fundamental assumption in the Vorbis -design. -

    The specification for embedding Vorbis into an Ogg transport stream is in section A, -“Embedding Vorbis into an Ogg stream”. -

    -

    1.1.4. Codec Setup and Probability Model
    -

    Vorbis’ heritage is as a research CODEC and its current design reflects a desire to allow multiple -decades of continuous encoder improvement before running out of room within the codec -specification. For these reasons, configurable aspects of codec setup intentionally lean toward the -extreme of forward adaptive. - - - -

    The single most controversial design decision in Vorbis (and the most unusual for a Vorbis -developer to keep in mind) is that the entire probability model of the codec, the Huffman and -VQ codebooks, is packed into the bitstream header along with extensive CODEC setup -parameters (often several hundred fields). This makes it impossible, as it would be with -MPEG audio layers, to embed a simple frame type flag in each audio packet, or begin -decode at any frame in the stream without having previously fetched the codec setup -header. -

    Note: Vorbis can initiate decode at any arbitrary packet within a bitstream so long as the codec -has been initialized/setup with the setup headers. -

    Thus, Vorbis headers are both required for decode to begin and relatively large as bitstream -headers go. The header size is unbounded, although for streaming a rule-of-thumb of 4kB or less -is recommended (and Xiph.Org’s Vorbis encoder follows this suggestion). -

    Our own design work indicates the primary liability of the required header is in mindshare; it is -an unusual design and thus causes some amount of complaint among engineers as this runs -against current design trends (and also points out limitations in some existing software/interface -designs, such as Windows’ ACM codec framework). However, we find that it does not -fundamentally limit Vorbis’ suitable application space. -

    -

    1.1.5. Format Specification
    -

    The Vorbis format is well-defined by its decode specification; any encoder that produces packets -that are correctly decoded by the reference Vorbis decoder described below may be considered -a proper Vorbis encoder. A decoder must faithfully and completely implement the -specification defined below (except where noted) to be considered a proper Vorbis -decoder. -

    -

    1.1.6. Hardware Profile
    - - - -

    Although Vorbis decode is computationally simple, it may still run into specific limitations of an -embedded design. For this reason, embedded designs are allowed to deviate in limited ways from -the ‘full’ decode specification yet still be certified compliant. These optional omissions are -labelled in the spec where relevant. -

    -

    1.2. Decoder Configuration

    -

    Decoder setup consists of configuration of multiple, self-contained component abstractions that -perform specific functions in the decode pipeline. Each different component instance of a specific -type is semantically interchangeable; decoder configuration consists both of internal component -configuration, as well as arrangement of specific instances into a decode pipeline. Componentry -arrangement is roughly as follows: -

    -

    - -

    PIC -

    Figure 1: decoder pipeline configuration
    -
    -

    -

    1.2.1. Global Config
    -

    Global codec configuration consists of a few audio related fields (sample rate, channels), Vorbis -version (always ’0’ in Vorbis I), bitrate hints, and the lists of component instances. All other -configuration is in the context of specific components. -

    -

    1.2.2. Mode
    - - - -

    Each Vorbis frame is coded according to a master ’mode’. A bitstream may use one or many -modes. -

    The mode mechanism is used to encode a frame according to one of multiple possible -methods with the intention of choosing a method best suited to that frame. Different -modes are, e.g. how frame size is changed from frame to frame. The mode number of a -frame serves as a top level configuration switch for all other specific aspects of frame -decode. -

    A ’mode’ configuration consists of a frame size setting, window type (always 0, the Vorbis -window, in Vorbis I), transform type (always type 0, the MDCT, in Vorbis I) and a mapping -number. The mapping number specifies which mapping configuration instance to use for low-level -packet decode and synthesis. -

    -

    1.2.3. Mapping
    -

    A mapping contains a channel coupling description and a list of ’submaps’ that bundle sets -of channel vectors together for grouped encoding and decoding. These submaps are -not references to external components; the submap list is internal and specific to a -mapping. -

    A ’submap’ is a configuration/grouping that applies to a subset of floor and residue vectors -within a mapping. The submap functions as a last layer of indirection such that specific special -floor or residue settings can be applied not only to all the vectors in a given mode, but also -specific vectors in a specific mode. Each submap specifies the proper floor and residue -instance number to use for decoding that submap’s spectral floor and spectral residue -vectors. -

    As an example: -

    Assume a Vorbis stream that contains six channels in the standard 5.1 format. The sixth -channel, as is normal in 5.1, is bass only. Therefore it would be wasteful to encode a -full-spectrum version of it as with the other channels. The submapping mechanism can be used -to apply a full range floor and residue encoding to channels 0 through 4, and a bass-only -representation to the bass channel, thus saving space. In this example, channels 0-4 belong to -submap 0 (which indicates use of a full-range floor) and channel 5 belongs to submap 1, which -uses a bass-only representation. - - - -

    -

    1.2.4. Floor
    -

    Vorbis encodes a spectral ’floor’ vector for each PCM channel. This vector is a low-resolution -representation of the audio spectrum for the given channel in the current frame, generally used -akin to a whitening filter. It is named a ’floor’ because the Xiph.Org reference encoder has -historically used it as a unit-baseline for spectral resolution. -

    A floor encoding may be of two types. Floor 0 uses a packed LSP representation on a dB -amplitude scale and Bark frequency scale. Floor 1 represents the curve as a piecewise linear -interpolated representation on a dB amplitude scale and linear frequency scale. The two floors -are semantically interchangeable in encoding/decoding. However, floor type 1 provides more -stable inter-frame behavior, and so is the preferred choice in all coupled-stereo and -high bitrate modes. Floor 1 is also considerably less expensive to decode than floor -0. -

    Floor 0 is not to be considered deprecated, but it is of limited modern use. No known Vorbis -encoder past Xiph.Org’s own beta 4 makes use of floor 0. -

    The values coded/decoded by a floor are both compactly formatted and make use of entropy -coding to save space. For this reason, a floor configuration generally refers to multiple -codebooks in the codebook component list. Entropy coding is thus provided as an -abstraction, and each floor instance may choose from any and all available codebooks when -coding/decoding. -

    -

    1.2.5. Residue
    -

    The spectral residue is the fine structure of the audio spectrum once the floor curve has been -subtracted out. In simplest terms, it is coded in the bitstream using cascaded (multi-pass) vector -quantization according to one of three specific packing/coding algorithms numbered -0 through 2. The packing algorithm details are configured by residue instance. As -with the floor components, the final VQ/entropy encoding is provided by external -codebook instances and each residue instance may choose from any and all available -codebooks. -

    - - - -

    1.2.6. Codebooks
    -

    Codebooks are a self-contained abstraction that perform entropy decoding and, optionally, use -the entropy-decoded integer value as an offset into an index of output value vectors, returning -the indicated vector of values. -

    The entropy coding in a Vorbis I codebook is provided by a standard Huffman binary tree -representation. This tree is tightly packed using one of several methods, depending on whether -codeword lengths are ordered or unordered, or the tree is sparse. -

    The codebook vector index is similarly packed according to index characteristic. Most commonly, -the vector index is encoded as a single list of values of possible values that are then permuted -into a list of n-dimensional rows (lattice VQ). -

    -

    1.3. High-level Decode Process

    -

    -

    1.3.1. Decode Setup
    -

    Before decoding can begin, a decoder must initialize using the bitstream headers matching the -stream to be decoded. Vorbis uses three header packets; all are required, in-order, by -this specification. Once set up, decode may begin at any audio packet belonging to -the Vorbis stream. In Vorbis I, all packets after the three initial headers are audio -packets. -

    The header packets are, in order, the identification header, the comments header, and the setup -header. -

    Identification Header -The identification header identifies the bitstream as Vorbis, Vorbis version, and the simple audio -characteristics of the stream such as sample rate and number of channels. - - - -

    Comment Header -The comment header includes user text comments (“tags”) and a vendor string for the -application/library that produced the bitstream. The encoding and proper use of the comment -header is described in section 5, “comment field and header specification”. -

    Setup Header -The setup header includes extensive CODEC setup information as well as the complete VQ and -Huffman codebooks needed for decode. -

    -

    1.3.2. Decode Procedure
    -

    The decoding and synthesis procedure for all audio packets is fundamentally the same. -

    - 1.
    decode packet type flag -
    - 2.
    decode mode number -
    - 3.
    decode window shape (long windows only) -
    - 4.
    decode floor -
    - 5.
    decode residue into residue vectors -
    - 6.
    inverse channel coupling of residue vectors -
    - 7.
    generate floor curve from decoded floor data -
    - 8.
    compute dot product of floor and residue, producing audio spectrum vector -
    - 9.
    inverse monolithic transform of audio spectrum vector, always an MDCT in Vorbis - I - - - -
    - 10.
    overlap/add left-hand output of transform with right-hand output of previous frame -
    - 11.
    store right hand-data from transform of current frame for future lapping -
    - 12.
    if not first frame, return results of overlap/add as audio result of current frame
    -

    Note that clever rearrangement of the synthesis arithmetic is possible; as an example, one can -take advantage of symmetries in the MDCT to store the right-hand transform data of a partial -MDCT for a 50% inter-frame buffer space savings, and then complete the transform later before -overlap/add with the next frame. This optimization produces entirely equivalent output and is -naturally perfectly legal. The decoder must be entirely mathematically equivalent to the -specification, it need not be a literal semantic implementation. -

    Packet type decode -Vorbis I uses four packet types. The first three packet types mark each of the three Vorbis -headers described above. The fourth packet type marks an audio packet. All other packet types -are reserved; packets marked with a reserved type should be ignored. -

    Following the three header packets, all packets in a Vorbis I stream are audio. The first step of -audio packet decode is to read and verify the packet type; a non-audio packet when audio is -expected indicates stream corruption or a non-compliant stream. The decoder must ignore the -packet and not attempt decoding it to audio. -

    Mode decode -Vorbis allows an encoder to set up multiple, numbered packet ’modes’, as described earlier, all of -which may be used in a given Vorbis stream. The mode is encoded as an integer used as a direct -offset into the mode instance index. -

    Window shape decode (long windows only) -Vorbis frames may be one of two PCM sample sizes specified during codec setup. In Vorbis I, -legal frame sizes are powers of two from 64 to 8192 samples. Aside from coupling, Vorbis -handles channels as independent vectors and these frame sizes are in samples per -channel. - - - -

    Vorbis uses an overlapping transform, namely the MDCT, to blend one frame into the next, -avoiding most inter-frame block boundary artifacts. The MDCT output of one frame is windowed -according to MDCT requirements, overlapped 50% with the output of the previous frame and -added. The window shape assures seamless reconstruction. -

    This is easy to visualize in the case of equal sized-windows: -

    -

    - -

    PIC -

    Figure 2: overlap of two equal-sized windows
    -
    -

    And slightly more complex in the case of overlapping unequal sized windows: -

    -

    - -

    PIC -

    Figure 3: overlap of a long and a short window
    -
    -

    In the unequal-sized window case, the window shape of the long window must be modified for -seamless lapping as above. It is possible to correctly infer window shape to be applied to the -current window from knowing the sizes of the current, previous and next window. It is legal for a -decoder to use this method. However, in the case of a long window (short windows require no -modification), Vorbis also codes two flag bits to specify pre- and post- window shape. Although -not strictly necessary for function, this minor redundancy allows a packet to be fully decoded to -the point of lapping entirely independently of any other packet, allowing easier abstraction of -decode layers as well as allowing a greater level of easy parallelism in encode and -decode. -

    A description of valid window functions for use with an inverse MDCT can be found in [1]. -Vorbis windows all use the slope function -

    -y = sin (.5 * π sin2((x + .5)∕n * π)).
-                                                                                        
-
-                                                                                        
-
    -

    -

    floor decode -Each floor is encoded/decoded in channel order, however each floor belongs to a ’submap’ that -specifies which floor configuration to use. All floors are decoded before residue decode -begins. -

    residue decode -Although the number of residue vectors equals the number of channels, channel coupling may -mean that the raw residue vectors extracted during decode do not map directly to specific -channels. When channel coupling is in use, some vectors will correspond to coupled magnitude or -angle. The coupling relationships are described in the codec setup and may differ from frame to -frame, due to different mode numbers. -

    Vorbis codes residue vectors in groups by submap; the coding is done in submap order from -submap 0 through n-1. This differs from floors which are coded using a configuration provided by -submap number, but are coded individually in channel order. -

    inverse channel coupling -A detailed discussion of stereo in the Vorbis codec can be found in the document -Stereo Channel Coupling in the Vorbis CODEC. Vorbis is not limited to only stereo -coupling, but the stereo document also gives a good overview of the generic coupling -mechanism. -

    Vorbis coupling applies to pairs of residue vectors at a time; decoupling is done in-place a -pair at a time in the order and using the vectors specified in the current mapping -configuration. The decoupling operation is the same for all pairs, converting square polar -representation (where one vector is magnitude and the second angle) back to Cartesian -representation. -

    After decoupling, in order, each pair of vectors on the coupling list, the resulting residue vectors -represent the fine spectral detail of each output channel. - - - -

    generate floor curve -The decoder may choose to generate the floor curve at any appropriate time. It is reasonable to -generate the output curve when the floor data is decoded from the raw packet, or it -can be generated after inverse coupling and applied to the spectral residue directly, -combining generation and the dot product into one step and eliminating some working -space. -

    Both floor 0 and floor 1 generate a linear-range, linear-domain output vector to be multiplied -(dot product) by the linear-range, linear-domain spectral residue. -

    compute floor/residue dot product -This step is straightforward; for each output channel, the decoder multiplies the floor curve and -residue vectors element by element, producing the finished audio spectrum of each -channel. -

    One point is worth mentioning about this dot product; a common mistake in a fixed point -implementation might be to assume that a 32 bit fixed-point representation for floor and -residue and direct multiplication of the vectors is sufficient for acceptable spectral depth -in all cases because it happens to mostly work with the current Xiph.Org reference -encoder. -

    However, floor vector values can span ~140dB (~24 bits unsigned), and the audio spectrum -vector should represent a minimum of 120dB (~21 bits with sign), even when output is to a 16 -bit PCM device. For the residue vector to represent full scale if the floor is nailed -to -140dB, it must be able to span 0 to +140dB. For the residue vector to reach -full scale if the floor is nailed at 0dB, it must be able to represent -140dB to +0dB. -Thus, in order to handle full range dynamics, a residue vector may span -140dB to -+140dB entirely within spec. A 280dB range is approximately 48 bits with sign; thus the -residue vector must be able to represent a 48 bit range and the dot product must -be able to handle an effective 48 bit times 24 bit multiplication. This range may be -achieved using large (64 bit or larger) integers, or implementing a movable binary point -representation. -

    inverse monolithic transform (MDCT) -The audio spectrum is converted back into time domain PCM audio via an inverse Modified -Discrete Cosine Transform (MDCT). A detailed description of the MDCT is available in -[1]. -

    Note that the PCM produced directly from the MDCT is not yet finished audio; it must be - - - -lapped with surrounding frames using an appropriate window (such as the Vorbis window) before -the MDCT can be considered orthogonal. -

    overlap/add data -Windowed MDCT output is overlapped and added with the right hand data of the previous -window such that the 3/4 point of the previous window is aligned with the 1/4 point of the -current window (as illustrated in the window overlap diagram). At this point, the audio data -between the center of the previous frame and the center of the current frame is now finished and -ready to be returned. -

    cache right hand data -The decoder must cache the right hand portion of the current frame to be lapped with the left -hand portion of the next frame. -

    return finished audio data -The overlapped portion produced from overlapping the previous and current frame data -is finished data to be returned by the decoder. This data spans from the center of -the previous window to the center of the current window. In the case of same-sized -windows, the amount of data to return is one-half block consisting of and only of the -overlapped portions. When overlapping a short and long window, much of the returned -range is not actually overlap. This does not damage transform orthogonality. Pay -attention however to returning the correct data range; the amount of data to be returned -is: -

    -

    1window_blocksize(previous_window)/4+window_blocksize(current_window)/4
    -

    from the center of the previous window to the center of the current window. -

    Data is not returned from the first frame; it must be used to ’prime’ the decode engine. The -encoder accounts for this priming when calculating PCM offsets; after the first frame, the proper -PCM output offset is ’0’ (as no data has been returned yet). - - - - - - -

    2. Bitpacking Convention

    -

    -

    2.1. Overview

    -

    The Vorbis codec uses relatively unstructured raw packets containing arbitrary-width binary -integer fields. Logically, these packets are a bitstream in which bits are coded one-by-one by the -encoder and then read one-by-one in the same monotonically increasing order by the decoder. -Most current binary storage arrangements group bits into a native word size of eight bits -(octets), sixteen bits, thirty-two bits or, less commonly other fixed word sizes. The Vorbis -bitpacking convention specifies the correct mapping of the logical packet bitstream into an actual -representation in fixed-width words. -

    -

    2.1.1. octets, bytes and words
    -

    In most contemporary architectures, a ’byte’ is synonymous with an ’octet’, that is, eight bits. -This has not always been the case; seven, ten, eleven and sixteen bit ’bytes’ have been used. -For purposes of the bitpacking convention, a byte implies the native, smallest integer -storage representation offered by a platform. On modern platforms, this is generally -assumed to be eight bits (not necessarily because of the processor but because of the -filesystem/memory architecture. Modern filesystems invariably offer bytes as the fundamental -atom of storage). A ’word’ is an integer size that is a grouped multiple of this smallest -size. -

    The most ubiquitous architectures today consider a ’byte’ to be an octet (eight bits) and a word -to be a group of two, four or eight bytes (16, 32 or 64 bits). Note however that the Vorbis -bitpacking convention is still well defined for any native byte size; Vorbis uses the native -bit-width of a given storage system. This document assumes that a byte is one octet for purposes -of example. -

    - - - -

    2.1.2. bit order
    -

    A byte has a well-defined ’least significant’ bit (LSb), which is the only bit set when the byte is -storing the two’s complement integer value +1. A byte’s ’most significant’ bit (MSb) is at the -opposite end of the byte. Bits in a byte are numbered from zero at the LSb to n (n = 7 in an -octet) for the MSb. -

    -

    2.1.3. byte order
    -

    Words are native groupings of multiple bytes. Several byte orderings are possible in a word; the -common ones are 3-2-1-0 (’big endian’ or ’most significant byte first’ in which the -highest-valued byte comes first), 0-1-2-3 (’little endian’ or ’least significant byte first’ in -which the lowest value byte comes first) and less commonly 3-1-2-0 and 0-2-1-3 (’mixed -endian’). -

    The Vorbis bitpacking convention specifies storage and bitstream manipulation at the byte, not -word, level, thus host word ordering is of a concern only during optimization when writing high -performance code that operates on a word of storage at a time rather than by byte. -Logically, bytes are always coded and decoded in order from byte zero through byte -n. -

    -

    2.1.4. coding bits into byte sequences
    -

    The Vorbis codec has need to code arbitrary bit-width integers, from zero to 32 bits -wide, into packets. These integer fields are not aligned to the boundaries of the byte -representation; the next field is written at the bit position at which the previous field -ends. -

    The encoder logically packs integers by writing the LSb of a binary integer to the logical -bitstream first, followed by next least significant bit, etc, until the requested number of bits -have been coded. When packing the bits into bytes, the encoder begins by placing -the LSb of the integer to be written into the least significant unused bit position of -the destination byte, followed by the next-least significant bit of the source integer -and so on up to the requested number of bits. When all bits of the destination byte -have been filled, encoding continues by zeroing all bits of the next byte and writing -the next bit into the bit position 0 of that byte. Decoding follows the same process - - - -as encoding, but by reading bits from the byte stream and reassembling them into -integers. -

    -

    2.1.5. signedness
    -

    The signedness of a specific number resulting from decode is to be interpreted by the decoder -given decode context. That is, the three bit binary pattern ’b111’ can be taken to represent -either ’seven’ as an unsigned integer, or ’-1’ as a signed, two’s complement integer. The -encoder and decoder are responsible for knowing if fields are to be treated as signed or -unsigned. -

    -

    2.1.6. coding example
    -

    Code the 4 bit integer value ’12’ [b1100] into an empty bytestream. Bytestream result: -

    -

    1              |
    2              V
    3
    4        7 6 5 4 3 2 1 0
    5byte 0 [0 0 0 0 1 1 0 0]  <-
    6byte 1 [               ] -
    7byte 2 [               ]
    8byte 3 [               ]
    9             ...
    10byte n [               ]  bytestream length == 1 byte
    11
    -

    Continue by coding the 3 bit integer value ’-1’ [b111]: -

    -

    1        |
    2        V
    3
    4        7 6 5 4 3 2 1 0
    5byte 0 [0 1 1 1 1 1 0 0]  <-
    6byte 1 [               ]
    7byte 2 [               ] -
    8byte 3 [               ]
    9             ...
    10byte n [               ]  bytestream length == 1 byte
    -

    Continue by coding the 7 bit integer value ’17’ [b0010001]: -

    -

    1          |
    2          V
    3
    4        7 6 5 4 3 2 1 0
    5byte 0 [1 1 1 1 1 1 0 0]
    6byte 1 [0 0 0 0 1 0 0 0]  <-
    7byte 2 [               ] -
    8byte 3 [               ]
    9             ...
    10byte n [               ]  bytestream length == 2 bytes
    11                          bit cursor == 6
    -

    Continue by coding the 13 bit integer value ’6969’ [b110 11001110 01]: -

    -

    1                |
    2                V
    3
    4        7 6 5 4 3 2 1 0
    5byte 0 [1 1 1 1 1 1 0 0]
    6byte 1 [0 1 0 0 1 0 0 0] -
    7byte 2 [1 1 0 0 1 1 1 0]
    8byte 3 [0 0 0 0 0 1 1 0]  <-
    9             ...
    10byte n [               ]  bytestream length == 4 bytes
    11
    - - - -

    -

    2.1.7. decoding example
    -

    Reading from the beginning of the bytestream encoded in the above example: -

    -

    1                      |
    2                      V
    3
    4        7 6 5 4 3 2 1 0
    5byte 0 [1 1 1 1 1 1 0 0]  <-
    6byte 1 [0 1 0 0 1 0 0 0] -
    7byte 2 [1 1 0 0 1 1 1 0]
    8byte 3 [0 0 0 0 0 1 1 0]  bytestream length == 4 bytes
    9
    -

    We read two, two-bit integer fields, resulting in the returned numbers ’b00’ and ’b11’. Two things -are worth noting here: -

      -
    • Although these four bits were originally written as a single four-bit integer, reading - some other combination of bit-widths from the bitstream is well defined. There are - no artificial alignment boundaries maintained in the bitstream. -
    • -
    • The second value is the two-bit-wide integer ’b11’. This value may be interpreted - either as the unsigned value ’3’, or the signed value ’-1’. Signedness is dependent on - decode context.
    -

    -

    2.1.8. end-of-packet alignment
    -

    The typical use of bitpacking is to produce many independent byte-aligned packets which are -embedded into a larger byte-aligned container structure, such as an Ogg transport bitstream. -Externally, each bytestream (encoded bitstream) must begin and end on a byte boundary. Often, -the encoded bitstream is not an integer number of bytes, and so there is unused (uncoded) space -in the last byte of a packet. -

    Unused space in the last byte of a bytestream is always zeroed during the coding process. Thus, -should this unused space be read, it will return binary zeroes. -

    Attempting to read past the end of an encoded packet results in an ’end-of-packet’ condition. -End-of-packet is not to be considered an error; it is merely a state indicating that there is -insufficient remaining data to fulfill the desired read size. Vorbis uses truncated packets as a - - - -normal mode of operation, and as such, decoders must handle reading past the end of a packet as -a typical mode of operation. Any further read operations after an ’end-of-packet’ condition shall -also return ’end-of-packet’. -

    -

    2.1.9. reading zero bits
    -

    Reading a zero-bit-wide integer returns the value ’0’ and does not increment the stream cursor. -Reading to the end of the packet (but not past, such that an ’end-of-packet’ condition has not -triggered) and then reading a zero bit integer shall succeed, returning 0, and not trigger an -end-of-packet condition. Reading a zero-bit-wide integer after a previous read sets ’end-of-packet’ -shall also fail with ’end-of-packet’. - - - - - - -

    3. Probability Model and Codebooks

    -

    -

    3.1. Overview

    -

    Unlike practically every other mainstream audio codec, Vorbis has no statically configured -probability model, instead packing all entropy decoding configuration, VQ and Huffman, into the -bitstream itself in the third header, the codec setup header. This packed configuration consists of -multiple ’codebooks’, each containing a specific Huffman-equivalent representation for decoding -compressed codewords as well as an optional lookup table of output vector values to which a -decoded Huffman value is applied as an offset, generating the final decoded output corresponding -to a given compressed codeword. -

    -

    3.1.1. Bitwise operation
    -

    The codebook mechanism is built on top of the vorbis bitpacker. Both the codebooks themselves -and the codewords they decode are unrolled from a packet as a series of arbitrary-width values -read from the stream according to section 2, “Bitpacking Convention”. -

    -

    3.2. Packed codebook format

    -

    For purposes of the examples below, we assume that the storage system’s native byte width is -eight bits. This is not universally true; see section 2, “Bitpacking Convention” for discussion -relating to non-eight-bit bytes. - - - -

    -

    3.2.1. codebook decode
    -

    A codebook begins with a 24 bit sync pattern, 0x564342: -

    -

    1byte 0: [ 0 1 0 0 0 0 1 0 ] (0x42)
    2byte 1: [ 0 1 0 0 0 0 1 1 ] (0x43)
    3byte 2: [ 0 1 0 1 0 1 1 0 ] (0x56)
    -

    16 bit [codebook_dimensions] and 24 bit [codebook_entries] fields: -

    -

    1
    2byte 3: [ X X X X X X X X ]
    3byte 4: [ X X X X X X X X ] [codebook_dimensions] (16 bit unsigned)
    4
    5byte 5: [ X X X X X X X X ] -
    6byte 6: [ X X X X X X X X ]
    7byte 7: [ X X X X X X X X ] [codebook_entries] (24 bit unsigned)
    8
    -

    Next is the [ordered] bit flag: -

    -

    1
    2byte 8: [               X ] [ordered] (1 bit)
    3
    -

    Each entry, numbering a total of [codebook_entries], is assigned a codeword length. -We now read the list of codeword lengths and store these lengths in the array -[codebook_codeword_lengths]. Decode of lengths is according to whether the [ordered] flag -is set or unset. -

      -
    • If the [ordered] flag is unset, the codeword list is not length ordered and the decoder - needs to read each codeword length one-by-one. -

      The decoder first reads one additional bit flag, the [sparse] flag. This flag determines - whether or not the codebook contains unused entries that are not to be included in - the codeword decode tree: -

      -

      1byte 8: [             X 1 ] [sparse] flag (1 bit)
      -

      The decoder now performs for each of the [codebook_entries] codebook entries: -

      -

      1
      2  1) if([sparse] is set) {
      3
      4         2) [flag] = read one bit;
      5         3) if([flag] is set) {
      6 -
      7              4) [length] = read a five bit unsigned integer;
      8              5) codeword length for this entry is [length]+1;
      9 -
      10            } else {
      11
      12              6) this entry is unused.  mark it as such.
      13
      14            }
      15
      16     } else the sparse flag is not set {
      17 -
      18        7) [length] = read a five bit unsigned integer;
      19        8) the codeword length for this entry is [length]+1;
      20
      21     }
      22
      - - - -
    • -
    • If the [ordered] flag is set, the codeword list for this codebook is encoded in - ascending length order. Rather than reading a length for every codeword, the - encoder reads the number of codewords per length. That is, beginning at entry - zero: -

      -

      1  1) [current_entry] = 0;
      2  2) [current_length] = read a five bit unsigned integer and add 1; -
      3  3) [number] = read ilog([codebook_entries] - [current_entry]) bits as an unsigned integer -
      4  4) set the entries [current_entry] through [current_entry]+[number]-1, inclusive, -
      5    of the [codebook_codeword_lengths] array to [current_length]
      6  5) set [current_entry] to [number] + [current_entry] -
      7  6) increment [current_length] by 1
      8  7) if [current_entry] is greater than [codebook_entries] ERROR CONDITION; -
      9    the decoder will not be able to read this stream.
      10  8) if [current_entry] is less than [codebook_entries], repeat process starting at 3) -
      11  9) done.
      -
    -

    After all codeword lengths have been decoded, the decoder reads the vector lookup table. Vorbis -I supports three lookup types: -

    - 1.
    No lookup -
    - 2.
    Implicitly populated value mapping (lattice VQ) -
    - 3.
    Explicitly populated value mapping (tessellated or ’foam’ VQ)
    -

    The lookup table type is read as a four bit unsigned integer: -

    1  1) [codebook_lookup_type] = read four bits as an unsigned integer
    -

    Codebook decode precedes according to [codebook_lookup_type]: -

      -
    • Lookup type zero indicates no lookup to be read. Proceed past lookup decode. -
    • -
    • Lookup types one and two are similar, differing only in the number of lookup values to - be read. Lookup type one reads a list of values that are permuted in a set pattern to - build a list of vectors, each vector of order [codebook_dimensions] scalars. Lookup - type two builds the same vector list, but reads each scalar for each vector explicitly, - rather than building vectors from a smaller list of possible scalar values. Lookup - decode proceeds as follows: -

      -

      1  1) [codebook_minimum_value] = float32_unpack( read 32 bits as an unsigned integer) -
      2  2) [codebook_delta_value] = float32_unpack( read 32 bits as an unsigned integer) -
      3  3) [codebook_value_bits] = read 4 bits as an unsigned integer and add 1
      4  4) [codebook_sequence_p] = read 1 bit as a boolean flag
      5 - - - -
      6  if ( [codebook_lookup_type] is 1 ) {
      7
      8     5) [codebook_lookup_values] = lookup1_values([codebook_entries], [codebook_dimensions] )
      9 -
      10  } else {
      11
      12     6) [codebook_lookup_values] = [codebook_entries] * [codebook_dimensions]
      13
      14  }
      15 -
      16  7) read a total of [codebook_lookup_values] unsigned integers of [codebook_value_bits] each; -
      17     store these in order in the array [codebook_multiplicands]
      -
    • -
    • A [codebook_lookup_type] of greater than two is reserved and indicates a stream that is - not decodable by the specification in this document. -
    -

    An ’end of packet’ during any read operation in the above steps is considered an error condition -rendering the stream undecodable. -

    Huffman decision tree representation -The [codebook_codeword_lengths] array and [codebook_entries] value uniquely define the -Huffman decision tree used for entropy decoding. -

    Briefly, each used codebook entry (recall that length-unordered codebooks support unused -codeword entries) is assigned, in order, the lowest valued unused binary Huffman codeword -possible. Assume the following codeword length list: -

    -

    1entry 0: length 2
    2entry 1: length 4
    3entry 2: length 4
    4entry 3: length 4
    5entry 4: length 4
    6entry 5: length 2
    7entry 6: length 3
    8entry 7: length 3
    -

    Assigning codewords in order (lowest possible value of the appropriate length to highest) results -in the following codeword list: -

    -

    1entry 0: length 2 codeword 00
    2entry 1: length 4 codeword 0100
    3entry 2: length 4 codeword 0101
    4entry 3: length 4 codeword 0110 -
    5entry 4: length 4 codeword 0111
    6entry 5: length 2 codeword 10
    7entry 6: length 3 codeword 110
    8entry 7: length 3 codeword 111
    -

    Note: Unlike most binary numerical values in this document, we intend the above codewords to -be read and used bit by bit from left to right, thus the codeword ’001’ is the bit string ’zero, zero, -one’. When determining ’lowest possible value’ in the assignment definition above, the leftmost -bit is the MSb. -

    It is clear that the codeword length list represents a Huffman decision tree with the entry -numbers equivalent to the leaves numbered left-to-right: - - - -

    -

    - -

    PIC -

    Figure 4: huffman tree illustration
    -
    -

    As we assign codewords in order, we see that each choice constructs a new leaf in the leftmost -possible position. -

    Note that it’s possible to underspecify or overspecify a Huffman tree via the length list. -In the above example, if codeword seven were eliminated, it’s clear that the tree is -unfinished: -

    -

    - -

    PIC -

    Figure 5: underspecified huffman tree illustration
    -
    -

    Similarly, in the original codebook, it’s clear that the tree is fully populated and a ninth -codeword is impossible. Both underspecified and overspecified trees are an error condition -rendering the stream undecodable. -

    Codebook entries marked ’unused’ are simply skipped in the assigning process. They have no -codeword and do not appear in the decision tree, thus it’s impossible for any bit pattern read -from the stream to decode to that entry number. -

    Errata 20150226: Single entry codebooks -A ’single-entry codebook’ is a codebook with one active codeword entry. A single-entry codebook -may be either a fully populated codebook with only one declared entry, or a sparse codebook -with only one entry marked used. The Vorbis I spec provides no means to specify a codeword -length of zero, and as a result, a single-entry codebook is inherently malformed because it is -underpopulated. The original specification did not address directly the matter of single-entry -codebooks; they were implicitly illegal as it was not possible to write such a codebook with a -valid tree structure. - - - -

    In r14811 of the libvorbis reference implementation, Xiph added an additional check to the -codebook implementation to reject underpopulated Huffman trees. This change led to the -discovery of single-entry books used ’in the wild’ when the new, stricter checks rejected a number -of apparently working streams. -

    In order to minimize breakage of deployed (if technically erroneous) streams, r16073 of the -reference implementation explicitly special-cased single-entry codebooks to tolerate the -single-entry case. Commit r16073 also added the following to the specification: -

    Take special care that a codebook with a single used entry is handled properly; it consists of a -single codework of zero bits and reading a value out of such a codebook always returns the single -used value and sinks zero bits. ” -

    The intent was to clarify the spec and codify current practice. However, this addition is -erroneously at odds with the intent of preserving usability of existing streams using single-entry -codebooks, disagrees with the code changes that reinstated decoding, and does not address how -single-entry codebooks should be encoded. -

    As such, the above addition made in r16037 is struck from the specification and replaced by the -following: -

    -

    -

    It is possible to declare a Vorbis codebook containing a single codework - entry. A single-entry codebook may be either a fully populated codebook with - [codebook_entries] set to 1, or a sparse codebook marking only one entry - used. Note that it is not possible to also encode a [codeword_length] of zero - for the single used codeword, as the unsigned value written to the stream - is [codeword_length]-1. Instead, encoder implementations should indicate a - [codeword_length] of 1 and ’write’ the codeword to a stream during audio - encoding by writing a single zero bit. -

    Decoder implementations shall reject a codebook if it contains only one used - entry and the encoded [codeword_length] of that entry is not 1. ’Reading’ a - value from single-entry codebook always returns the single used codeword value - and sinks one bit. Decoders should tolerate that the bit read from the stream - be ’1’ instead of ’0’; both values shall return the single used codeword.

    -

    VQ lookup table vector representation -Unpacking the VQ lookup table vectors relies on the following values: - - - -

    1the [codebook\_multiplicands] array
    2[codebook\_minimum\_value]
    3[codebook\_delta\_value]
    4[codebook\_sequence\_p] -
    5[codebook\_lookup\_type]
    6[codebook\_entries]
    7[codebook\_dimensions]
    8[codebook\_lookup\_values]
    -

    Decoding (unpacking) a specific vector in the vector lookup table proceeds according to -[codebook_lookup_type]. The unpacked vector values are what a codebook would return -during audio packet decode in a VQ context. -

    Vector value decode: Lookup type 1 -Lookup type one specifies a lattice VQ lookup table built algorithmically from a list of -scalar values. Calculate (unpack) the final values of a codebook entry vector from -the entries in [codebook_multiplicands] as follows ([value_vector] is the output -vector representing the vector of values for entry number [lookup_offset] in this -codebook): -

    -

    1  1) [last] = 0;
    2  2) [index_divisor] = 1;
    3  3) iterate [i] over the range 0 ... [codebook_dimensions]-1 (once for each scalar value in the value vector) {
    4 -
    5       4) [multiplicand_offset] = ( [lookup_offset] divided by [index_divisor] using integer -
    6          division ) integer modulo [codebook_lookup_values]
    7
    8       5) vector [value_vector] element [i] = -
    9            ( [codebook_multiplicands] array element number [multiplicand_offset] ) * -
    10            [codebook_delta_value] + [codebook_minimum_value] + [last];
    11 -
    12       6) if ( [codebook_sequence_p] is set ) then set [last] = vector [value_vector] element [i]
    13 -
    14       7) [index_divisor] = [index_divisor] * [codebook_lookup_values]
    15
    16     }
    17
    18  8) vector calculation completed.
    -

    Vector value decode: Lookup type 2 -Lookup type two specifies a VQ lookup table in which each scalar in each vector is explicitly set -by the [codebook_multiplicands] array in a one-to-one mapping. Calculate [unpack] the final -values of a codebook entry vector from the entries in [codebook_multiplicands] as follows -([value_vector] is the output vector representing the vector of values for entry number -[lookup_offset] in this codebook): -

    -

    1  1) [last] = 0;
    2  2) [multiplicand_offset] = [lookup_offset] * [codebook_dimensions] -
    3  3) iterate [i] over the range 0 ... [codebook_dimensions]-1 (once for each scalar value in the value vector) {
    4 -
    5       4) vector [value_vector] element [i] =
    6            ( [codebook_multiplicands] array element number [multiplicand_offset] ) * -
    7            [codebook_delta_value] + [codebook_minimum_value] + [last];
    8 -
    9       5) if ( [codebook_sequence_p] is set ) then set [last] = vector [value_vector] element [i]
    10 -
    11       6) increment [multiplicand_offset]
    12
    13     }
    14
    15  7) vector calculation completed.
    - - - -

    -

    3.3. Use of the codebook abstraction

    -

    The decoder uses the codebook abstraction much as it does the bit-unpacking convention; a -specific codebook reads a codeword from the bitstream, decoding it into an entry number, and -then returns that entry number to the decoder (when used in a scalar entropy coding context), or -uses that entry number as an offset into the VQ lookup table, returning a vector of values (when -used in a context desiring a VQ value). Scalar or VQ context is always explicit; any -call to the codebook mechanism requests either a scalar entry number or a lookup -vector. -

    Note that VQ lookup type zero indicates that there is no lookup table; requesting -decode using a codebook of lookup type 0 in any context expecting a vector return -value (even in a case where a vector of dimension one) is forbidden. If decoder setup -or decode requests such an action, that is an error condition rendering the packet -undecodable. -

    Using a codebook to read from the packet bitstream consists first of reading and decoding the -next codeword in the bitstream. The decoder reads bits until the accumulated bits match a -codeword in the codebook. This process can be though of as logically walking the -Huffman decode tree by reading one bit at a time from the bitstream, and using the -bit as a decision boolean to take the 0 branch (left in the above examples) or the 1 -branch (right in the above examples). Walking the tree finishes when the decode process -hits a leaf in the decision tree; the result is the entry number corresponding to that -leaf. Reading past the end of a packet propagates the ’end-of-stream’ condition to the -decoder. -

    When used in a scalar context, the resulting codeword entry is the desired return -value. -

    When used in a VQ context, the codeword entry number is used as an offset into the VQ lookup -table. The value returned to the decoder is the vector of scalars corresponding to this -offset. - - - - - - -

    4. Codec Setup and Packet Decode

    -

    -

    4.1. Overview

    -

    This document serves as the top-level reference document for the bit-by-bit decode specification -of Vorbis I. This document assumes a high-level understanding of the Vorbis decode -process, which is provided in section 1, “Introduction and Description”. section 2, -“Bitpacking Convention” covers reading and writing bit fields from and to bitstream -packets. -

    -

    4.2. Header decode and decode setup

    -

    A Vorbis bitstream begins with three header packets. The header packets are, in order, the -identification header, the comments header, and the setup header. All are required for decode -compliance. An end-of-packet condition during decoding the first or third header packet renders -the stream undecodable. End-of-packet decoding the comment header is a non-fatal error -condition. -

    -

    4.2.1. Common header decode
    -

    Each header packet begins with the same header fields. -

    -

    1  1) [packet_type] : 8 bit value
    2  2) 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73: the characters ’v’,’o’,’r’,’b’,’i’,’s’ as six octets
    -

    Decode continues according to packet type; the identification header is type 1, the comment -header type 3 and the setup header type 5 (these types are all odd as a packet with a leading -single bit of ’0’ is an audio packet). The packets must occur in the order of identification, - - - -comment, setup. -

    -

    4.2.2. Identification header
    -

    The identification header is a short header of only a few fields used to declare the stream -definitively as Vorbis, and provide a few externally relevant pieces of information about the audio -stream. The identification header is coded as follows: -

    -

    1 1) [vorbis_version] = read 32 bits as unsigned integer
    2 2) [audio_channels] = read 8 bit integer as unsigned -
    3 3) [audio_sample_rate] = read 32 bits as unsigned integer
    4 4) [bitrate_maximum] = read 32 bits as signed integer -
    5 5) [bitrate_nominal] = read 32 bits as signed integer
    6 6) [bitrate_minimum] = read 32 bits as signed integer -
    7 7) [blocksize_0] = 2 exponent (read 4 bits as unsigned integer)
    8 8) [blocksize_1] = 2 exponent (read 4 bits as unsigned integer) -
    9 9) [framing_flag] = read one bit
    -

    [vorbis_version] is to read ’0’ in order to be compatible with this document. Both -[audio_channels] and [audio_sample_rate] must read greater than zero. Allowed final -blocksize values are 64, 128, 256, 512, 1024, 2048, 4096 and 8192 in Vorbis I. [blocksize_0] -must be less than or equal to [blocksize_1]. The framing bit must be nonzero. Failure to meet -any of these conditions renders a stream undecodable. -

    The bitrate fields above are used only as hints. The nominal bitrate field especially may be -considerably off in purely VBR streams. The fields are meaningful only when greater than -zero. -

      -
    • All three fields set to the same value implies a fixed rate, or tightly bounded, nearly - fixed-rate bitstream -
    • -
    • Only nominal set implies a VBR or ABR stream that averages the nominal bitrate -
    • -
    • Maximum and or minimum set implies a VBR bitstream that obeys the bitrate limits -
    • -
    • None set indicates the encoder does not care to speculate.
    - - - -

    -

    4.2.3. Comment header
    -

    Comment header decode and data specification is covered in section 5, “comment field and -header specification”. -

    -

    4.2.4. Setup header
    -

    Vorbis codec setup is configurable to an extreme degree: -

    -

    - -

    PIC -

    Figure 6: decoder pipeline configuration
    -
    -

    The setup header contains the bulk of the codec setup information needed for decode. The setup -header contains, in order, the lists of codebook configurations, time-domain transform -configurations (placeholders in Vorbis I), floor configurations, residue configurations, channel -mapping configurations and mode configurations. It finishes with a framing bit of ’1’. Header -decode proceeds in the following order: -

    Codebooks -

    - 1.
    [vorbis_codebook_count] = read eight bits as unsigned integer and add one -
    - 2.
    Decode [vorbis_codebook_count] codebooks in order as defined in section 3, - “Probability Model and Codebooks”. Save each configuration, in order, in an array - of codebook configurations [vorbis_codebook_configurations].
    - - - -

    Time domain transforms -These hooks are placeholders in Vorbis I. Nevertheless, the configuration placeholder values must -be read to maintain bitstream sync. -

    -

    - 1.
    [vorbis_time_count] = read 6 bits as unsigned integer and add one -
    - 2.
    read [vorbis_time_count] 16 bit values; each value should be zero. If any value is - nonzero, this is an error condition and the stream is undecodable.
    -

    Floors -Vorbis uses two floor types; header decode is handed to the decode abstraction of the appropriate -type. -

    -

    - 1.
    [vorbis_floor_count] = read 6 bits as unsigned integer and add one -
    - 2.
    For each [i] of [vorbis_floor_count] floor numbers: -
    - a)
    read the floor type: vector [vorbis_floor_types] element [i] = read 16 bits - as unsigned integer -
    - b)
    If the floor type is zero, decode the floor configuration as defined in section 6, - “Floor type 0 setup and decode”; save this configuration in slot [i] of the floor - configuration array [vorbis_floor_configurations]. -
    - c)
    If the floor type is one, decode the floor configuration as defined in section 7, - “Floor type 1 setup and decode”; save this configuration in slot [i] of the floor - configuration array [vorbis_floor_configurations]. -
    - d)
    If the the floor type is greater than one, this stream is undecodable; ERROR - CONDITION
    - - - -
    -

    Residues -Vorbis uses three residue types; header decode of each type is identical. -

    -

    - 1.
    [vorbis_residue_count] = read 6 bits as unsigned integer and add one -
    - 2.
    For each of [vorbis_residue_count] residue numbers: -
    - a)
    read the residue type; vector [vorbis_residue_types] element [i] = read 16 - bits as unsigned integer -
    - b)
    If the residue type is zero, one or two, decode the residue configuration as defined - in section 8, “Residue setup and decode”; save this configuration in slot [i] of - the residue configuration array [vorbis_residue_configurations]. -
    - c)
    If the the residue type is greater than two, this stream is undecodable; ERROR - CONDITION
    -
    -

    Mappings -Mappings are used to set up specific pipelines for encoding multichannel audio with varying -channel mapping applications. Vorbis I uses a single mapping type (0), with implicit PCM -channel mappings. -

    -

    - 1.
    [vorbis_mapping_count] = read 6 bits as unsigned integer and add one -
    - 2.
    For each [i] of [vorbis_mapping_count] mapping numbers: - - - -
    - a)
    read the mapping type: 16 bits as unsigned integer. There’s no reason to save - the mapping type in Vorbis I. -
    - b)
    If the mapping type is nonzero, the stream is undecodable -
    - c)
    If the mapping type is zero: -
    - i.
    read 1 bit as a boolean flag -
    - A.
    if set, [vorbis_mapping_submaps] = read 4 bits as unsigned integer - and add one -
    - B.
    if unset, [vorbis_mapping_submaps] = 1
    -
    - ii.
    read 1 bit as a boolean flag -
    - A.
    if set, square polar channel mapping is in use: -
      -
    • [vorbis_mapping_coupling_steps] = read 8 bits as unsigned - integer and add one -
    • -
    • for [j] each of [vorbis_mapping_coupling_steps] steps: -
        -
      • vector [vorbis_mapping_magnitude] element [j]= read - ilog([audio_channels] - 1) bits as unsigned integer -
      • -
      • vector [vorbis_mapping_angle] element [j]= read - ilog([audio_channels] - 1) bits as unsigned integer -
      • -
      • the numbers read in the above two steps are channel numbers - representing the channel to treat as magnitude and the channel - to treat as angle, respectively. If for any coupling step the - angle channel number equals the magnitude channel number, the - magnitude channel number is greater than [audio_channels]-1, or - the angle channel is greater than [audio_channels]-1, the stream - is undecodable.
      - - - -
    -
    - B.
    if unset, [vorbis_mapping_coupling_steps] = 0
    -
    - iii.
    read 2 bits (reserved field); if the value is nonzero, the stream is undecodable -
    - iv.
    if [vorbis_mapping_submaps] is greater than one, we read channel multiplex - settings. For each [j] of [audio_channels] channels: -
    - A.
    vector [vorbis_mapping_mux] element [j] = read 4 bits as unsigned - integer -
    - B.
    if the value is greater than the highest numbered submap - ([vorbis_mapping_submaps] - 1), this in an error condition rendering - the stream undecodable
    -
    - v.
    for each submap [j] of [vorbis_mapping_submaps] submaps, read the floor and - residue numbers for use in decoding that submap: -
    - A.
    read and discard 8 bits (the unused time configuration placeholder) -
    - B.
    read 8 bits as unsigned integer for the floor number; save in vector - [vorbis_mapping_submap_floor] element [j] -
    - C.
    verify the floor number is not greater than the highest number floor - configured for the bitstream. If it is, the bitstream is undecodable -
    - D.
    read 8 bits as unsigned integer for the residue number; save in vector - [vorbis_mapping_submap_residue] element [j] -
    - E.
    verify the residue number is not greater than the highest number residue - configured for the bitstream. If it is, the bitstream is undecodable
    -
    - vi.
    save this mapping configuration in slot [i] of the mapping configuration array - [vorbis_mapping_configurations].
    -
    - - - -
    -

    Modes -

    - 1.
    [vorbis_mode_count] = read 6 bits as unsigned integer and add one -
    - 2.
    For each of [vorbis_mode_count] mode numbers: -
    - a)
    [vorbis_mode_blockflag] = read 1 bit -
    - b)
    [vorbis_mode_windowtype] = read 16 bits as unsigned integer -
    - c)
    [vorbis_mode_transformtype] = read 16 bits as unsigned integer -
    - d)
    [vorbis_mode_mapping] = read 8 bits as unsigned integer -
    - e)
    verify ranges; zero is the only legal value in - Vorbis I for [vorbis_mode_windowtype] and [vorbis_mode_transformtype]. - [vorbis_mode_mapping] must not be greater than the highest number mapping - in use. Any illegal values render the stream undecodable. -
    - f)
    save this mode configuration in slot [i] of the mode configuration array - [vorbis_mode_configurations].
    -
    - 3.
    read 1 bit as a framing flag. If unset, a framing error occurred and the stream is not - decodable.
    -

    After reading mode descriptions, setup header decode is complete. -

    -

    4.3. Audio packet decode and synthesis

    - - - -

    Following the three header packets, all packets in a Vorbis I stream are audio. The first step of -audio packet decode is to read and verify the packet type. A non-audio packet when audio is -expected indicates stream corruption or a non-compliant stream. The decoder must ignore the -packet and not attempt decoding it to audio. -

    -

    4.3.1. packet type, mode and window decode
    -

    -

    - 1.
    read 1 bit [packet_type]; check that packet type is 0 (audio) -
    - 2.
    read ilog([vorbis_mode_count]-1) bits [mode_number] -
    - 3.
    decode blocksize [n] is equal to [blocksize_0] if [vorbis_mode_blockflag] is 0, - else [n] is equal to [blocksize_1]. -
    - 4.
    perform window selection and setup; this window is used later by the inverse - MDCT: -
    - a)
    if this is a long window (the [vorbis_mode_blockflag] flag of this mode is - set): -
    - i.
    read 1 bit for [previous_window_flag] -
    - ii.
    read 1 bit for [next_window_flag] -
    - iii.
    if [previous_window_flag] is not set, the left half of the window will - be a hybrid window for lapping with a short block. See paragraph 1.3.2, - “Window shape decode (long windows only)” for an illustration of - overlapping dissimilar windows. Else, the left half window will have normal - long shape. -
    - iv.
    if [next_window_flag] is not set, the right half of the window will be - a hybrid window for lapping with a short block. See paragraph 1.3.2, - - - - “Window shape decode (long windows only)” for an illustration of - overlapping dissimilar windows. Else, the left right window will have normal - long shape.
    -
    - b)
    if this is a short window, the window is always the same short-window - shape.
    -
    -

    Vorbis windows all use the slope function y = sin(π
-2 * sin 2((x + 0.5)∕n * π)), where n is window -size and x ranges 0n- 1, but dissimilar lapping requirements can affect overall shape. Window -generation proceeds as follows: -

    -

    - 1.
    [window_center] = [n] / 2 -
    - 2.
    if ([vorbis_mode_blockflag] is set and [previous_window_flag] is not set) - then -
    - a)
    [left_window_start] = [n]/4 - [blocksize_0]/4 -
    - b)
    [left_window_end] = [n]/4 + [blocksize_0]/4 -
    - c)
    [left_n] = [blocksize_0]/2
    -

    else -

    - a)
    [left_window_start] = 0 -
    - b)
    [left_window_end] = [window_center] -
    - c)
    [left_n] = [n]/2
    -
    - 3.
    if ([vorbis_mode_blockflag] is set and [next_window_flag] is not set) then -
    - a)
    [right_window_start] = [n]*3/4 - [blocksize_0]/4 -
    - b)
    [right_window_end] = [n]*3/4 + [blocksize_0]/4 - - - -
    - c)
    [right_n] = [blocksize_0]/2
    -

    else -

    - a)
    [right_window_start] = [window_center] -
    - b)
    [right_window_end] = [n] -
    - c)
    [right_n] = [n]/2
    -
    - 4.
    window from range 0 ... [left_window_start]-1 inclusive is zero -
    - 5.
    for [i] in range [left_window_start] ... [left_window_end]-1, window([i]) = - sin(π
-2 * sin 2( ([i]-[left_window_start]+0.5) / [left_n] *π
-2) ) -
    - 6.
    window from range [left_window_end] ... [right_window_start]-1 inclusive is - one -
    - 7.
    for [i] in range [right_window_start] ... [right_window_end]-1, window([i]) = - sin(π2 * sin 2( ([i]-[right_window_start]+0.5) / [right_n] *π2 + π2) ) -
    - 8.
    window from range [right_window_start] ... [n]-1 is zero
    -

    An end-of-packet condition up to this point should be considered an error that discards this -packet from the stream. An end of packet condition past this point is to be considered a possible -nominal occurrence. -

    -

    4.3.2. floor curve decode
    -

    From this point on, we assume out decode context is using mode number [mode_number] -from configuration array [vorbis_mode_configurations] and the map number -[vorbis_mode_mapping] (specified by the current mode) taken from the mapping configuration -array [vorbis_mapping_configurations]. -

    Floor curves are decoded one-by-one in channel order. - - - -

    For each floor [i] of [audio_channels] -

    - 1.
    [submap_number] = element [i] of vector [vorbis_mapping_mux] -
    - 2.
    [floor_number] = element [submap_number] of vector [vorbis_submap_floor] -
    - 3.
    if the floor type of this floor (vector - [vorbis_floor_types] element [floor_number]) is zero then decode the floor for - channel [i] according to the subsubsection 6.2.2, “packet decode” -
    - 4.
    if the type of this floor is one then decode the floor for channel [i] according to the - subsubsection 7.2.3, “packet decode” -
    - 5.
    save the needed decoded floor information for channel for later synthesis -
    - 6.
    if the decoded floor returned ’unused’, set vector [no_residue] element [i] to true, - else set vector [no_residue] element [i] to false
    -

    An end-of-packet condition during floor decode shall result in packet decode zeroing all channel -output vectors and skipping to the add/overlap output stage. -

    -

    4.3.3. nonzero vector propagate
    -

    A possible result of floor decode is that a specific vector is marked ’unused’ which indicates that -that final output vector is all-zero values (and the floor is zero). The residue for that vector is not -coded in the stream, save for one complication. If some vectors are used and some are not, -channel coupling could result in mixing a zeroed and nonzeroed vector to produce two nonzeroed -vectors. -

    for each [i] from 0 ... [vorbis_mapping_coupling_steps]-1 -

    -

    - 1.
    if either [no_residue] entry for channel ([vorbis_mapping_magnitude] element - [i]) or channel ([vorbis_mapping_angle] element [i]) are set to false, then both - must be set to false. Note that an ’unused’ floor has no decoded floor information; it - - - - is important that this is remembered at floor curve synthesis time.
    -

    -

    4.3.4. residue decode
    -

    Unlike floors, which are decoded in channel order, the residue vectors are decoded in submap -order. -

    for each submap [i] in order from 0 ... [vorbis_mapping_submaps]-1 -

    -

    - 1.
    [ch] = 0 -
    - 2.
    for each channel [j] in order from 0 ... [audio_channels] - 1 -
    - a)
    if channel [j] in submap [i] (vector [vorbis_mapping_mux] element [j] is equal to - [i]) -
    - i.
    if vector [no_residue] element [j] is true -
    - A.
    vector [do_not_decode_flag] element [ch] is set
    -

    else -

    - A.
    vector [do_not_decode_flag] element [ch] is unset
    -
    - ii.
    increment [ch]
    -
    -
    - 3.
    [residue_number] = vector [vorbis_mapping_submap_residue] element [i] -
    - 4.
    [residue_type] = vector [vorbis_residue_types] element [residue_number] -
    - 5.
    decode [ch] vectors using residue [residue_number], according to type [residue_type], - - - - also passing vector [do_not_decode_flag] to indicate which vectors in the bundle should - not be decoded. Correct per-vector decode length is [n]/2. -
    - 6.
    [ch] = 0 -
    - 7.
    for each channel [j] in order from 0 ... [audio_channels] -
    - a)
    if channel [j] is in submap [i] (vector [vorbis_mapping_mux] element [j] is equal - to [i]) -
    - i.
    residue vector for channel [j] is set to decoded residue vector [ch] -
    - ii.
    increment [ch]
    -
    -
    -

    -

    4.3.5. inverse coupling
    -

    for each [i] from [vorbis_mapping_coupling_steps]-1 descending to 0 -

    -

    - 1.
    [magnitude_vector] = the residue vector for channel (vector - [vorbis_mapping_magnitude] element [i]) -
    - 2.
    [angle_vector] = the residue vector for channel (vector [vorbis_mapping_angle] - element [i]) -
    - 3.
    for each scalar value [M] in vector [magnitude_vector] and the corresponding scalar value - [A] in vector [angle_vector]: -
    - a)
    if ([M] is greater than zero) - - - -
    - i.
    if ([A] is greater than zero) -
    - A.
    [new_M] = [M] -
    - B.
    [new_A] = [M]-[A]
    -

    else -

    - A.
    [new_A] = [M] -
    - B.
    [new_M] = [M]+[A]
    -
    -

    else -

    - i.
    if ([A] is greater than zero) -
    - A.
    [new_M] = [M] -
    - B.
    [new_A] = [M]+[A]
    -

    else -

    - A.
    [new_A] = [M] -
    - B.
    [new_M] = [M]-[A]
    -
    -
    - b)
    set scalar value [M] in vector [magnitude_vector] to [new_M] -
    - c)
    set scalar value [A] in vector [angle_vector] to [new_A]
    -
    - - - -

    -

    4.3.6. dot product
    -

    For each channel, synthesize the floor curve from the decoded floor information, according to -packet type. Note that the vector synthesis length for floor computation is [n]/2. -

    For each channel, multiply each element of the floor curve by each element of that -channel’s residue vector. The result is the dot product of the floor and residue vectors for -each channel; the produced vectors are the length [n]/2 audio spectrum for each -channel. -

    One point is worth mentioning about this dot product; a common mistake in a fixed point -implementation might be to assume that a 32 bit fixed-point representation for floor and -residue and direct multiplication of the vectors is sufficient for acceptable spectral depth -in all cases because it happens to mostly work with the current Xiph.Org reference -encoder. -

    However, floor vector values can span ~140dB (~24 bits unsigned), and the audio spectrum -vector should represent a minimum of 120dB (~21 bits with sign), even when output is to a 16 -bit PCM device. For the residue vector to represent full scale if the floor is nailed -to -140dB, it must be able to span 0 to +140dB. For the residue vector to reach -full scale if the floor is nailed at 0dB, it must be able to represent -140dB to +0dB. -Thus, in order to handle full range dynamics, a residue vector may span -140dB to -+140dB entirely within spec. A 280dB range is approximately 48 bits with sign; thus the -residue vector must be able to represent a 48 bit range and the dot product must -be able to handle an effective 48 bit times 24 bit multiplication. This range may be -achieved using large (64 bit or larger) integers, or implementing a movable binary point -representation. -

    -

    4.3.7. inverse MDCT
    -

    Convert the audio spectrum vector of each channel back into time domain PCM audio via an -inverse Modified Discrete Cosine Transform (MDCT). A detailed description of the MDCT is -available in [1]. The window function used for the MDCT is the function described -earlier. - - - -

    -

    4.3.8. overlap_add
    -

    Windowed MDCT output is overlapped and added with the right hand data of the previous -window such that the 3/4 point of the previous window is aligned with the 1/4 point of the -current window (as illustrated in paragraph 1.3.2, “Window shape decode (long windows -only)”). The overlapped portion produced from overlapping the previous and current frame data -is finished data to be returned by the decoder. This data spans from the center of -the previous window to the center of the current window. In the case of same-sized -windows, the amount of data to return is one-half block consisting of and only of the -overlapped portions. When overlapping a short and long window, much of the returned -range does not actually overlap. This does not damage transform orthogonality. Pay -attention however to returning the correct data range; the amount of data to be returned -is: -

    -

    1window_blocksize(previous_window)/4+window_blocksize(current_window)/4
    -

    from the center (element windowsize/2) of the previous window to the center (element -windowsize/2-1, inclusive) of the current window. -

    Data is not returned from the first frame; it must be used to ’prime’ the decode engine. The -encoder accounts for this priming when calculating PCM offsets; after the first frame, the proper -PCM output offset is ’0’ (as no data has been returned yet). -

    -

    4.3.9. output channel order
    -

    Vorbis I specifies only a channel mapping type 0. In mapping type 0, channel mapping is -implicitly defined as follows for standard audio applications. As of revision 16781 (20100113), the -specification adds defined channel locations for 6.1 and 7.1 surround. Ordering/location for -greater-than-eight channels remains ’left to the implementation’. -

    These channel orderings refer to order within the encoded stream. It is naturally possible for a -decoder to produce output with channels in any order. Any such decoder should explicitly -document channel reordering behavior. -

    -

    -one channel
    the stream is monophonic - - - -
    -two channels
    the stream is stereo. channel order: left, right -
    -three channels
    the stream is a 1d-surround encoding. channel order: left, center, right -
    -four channels
    the stream is quadraphonic surround. channel order: front left, front right, - rear left, rear right -
    -five channels
    the stream is five-channel surround. channel order: front left, center, front - right, rear left, rear right -
    -six channels
    the stream is 5.1 surround. channel order: front left, center, front right, rear - left, rear right, LFE -
    -seven channels
    the stream is 6.1 surround. channel order: front left, center, front right, - side left, side right, rear center, LFE -
    -eight channels
    the stream is 7.1 surround. channel order: front left, center, front right, - side left, side right, rear left, rear right, LFE -
    -greater than eight channels
    channel use and order is defined by the application -
    -

    Applications using Vorbis for dedicated purposes may define channel mapping as seen fit. Future -channel mappings (such as three and four channel Ambisonics) will make use of channel -mappings other than mapping 0. - - - - - - -

    5. comment field and header specification

    -

    -

    5.1. Overview

    -

    The Vorbis text comment header is the second (of three) header packets that begin a Vorbis -bitstream. It is meant for short text comments, not arbitrary metadata; arbitrary metadata -belongs in a separate logical bitstream (usually an XML stream type) that provides greater -structure and machine parseability. -

    The comment field is meant to be used much like someone jotting a quick note on the bottom of -a CDR. It should be a little information to remember the disc by and explain it to others; a -short, to-the-point text note that need not only be a couple words, but isn’t going to be more -than a short paragraph. The essentials, in other words, whatever they turn out to be, -eg: -

    -

    -

    Honest Bob and the Factory-to-Dealer-Incentives, “I’m Still Around”, opening - for Moxy Frvous, 1997.

    -

    -

    5.2. Comment encoding

    -

    -

    5.2.1. Structure
    -

    The comment header is logically a list of eight-bit-clean vectors; the number of vectors is -bounded to 232 - 1 and the length of each vector is limited to 232 - 1 bytes. The vector length is - - - -encoded; the vector contents themselves are not null terminated. In addition to the vector list, -there is a single vector for vendor name (also 8 bit clean, length encoded in 32 bits). For -example, the 1.0 release of libvorbis set the vendor string to “Xiph.Org libVorbis I -20020717”. -

    The vector lengths and number of vectors are stored lsb first, according to the bit -packing conventions of the vorbis codec. However, since data in the comment header -is octet-aligned, they can simply be read as unaligned 32 bit little endian unsigned -integers. -

    The comment header is decoded as follows: -

    -

    1  1) [vendor\_length] = read an unsigned integer of 32 bits
    2  2) [vendor\_string] = read a UTF-8 vector as [vendor\_length] octets -
    3  3) [user\_comment\_list\_length] = read an unsigned integer of 32 bits
    4  4) iterate [user\_comment\_list\_length] times { -
    5       5) [length] = read an unsigned integer of 32 bits
    6       6) this iteration’s user comment = read a UTF-8 vector as [length] octets -
    7     }
    8  7) [framing\_bit] = read a single bit as boolean
    9  8) if ( [framing\_bit] unset or end-of-packet ) then ERROR
    10  9) done.
    -

    -

    5.2.2. Content vector format
    -

    The comment vectors are structured similarly to a UNIX environment variable. That is, -comment fields consist of a field name and a corresponding value and look like: -

    -

    -

    -

    1comment[0]="ARTIST=me";
    2comment[1]="TITLE=the sound of Vorbis";
    -
    -

    The field name is case-insensitive and may consist of ASCII 0x20 through 0x7D, 0x3D (’=’) -excluded. ASCII 0x41 through 0x5A inclusive (characters A-Z) is to be considered equivalent to -ASCII 0x61 through 0x7A inclusive (characters a-z). -

    The field name is immediately followed by ASCII 0x3D (’=’); this equals sign is used to -terminate the field name. -

    0x3D is followed by 8 bit clean UTF-8 encoded value of the field contents to the end of the -field. - - - -

    Field names -Below is a proposed, minimal list of standard field names with a description of intended use. No -single or group of field names is mandatory; a comment header may contain one, all or none of -the names in this list. -

    -

    -TITLE
    Track/Work name -
    -VERSION
    The version field may be used to differentiate multiple versions of the same - track title in a single collection. (e.g. remix info) -
    -ALBUM
    The collection name to which this track belongs -
    -TRACKNUMBER
    The track number of this piece if part of a specific larger collection or - album -
    -ARTIST
    The artist generally considered responsible for the work. In popular music this is - usually the performing band or singer. For classical music it would be the composer. - For an audio book it would be the author of the original text. -
    -PERFORMER
    The artist(s) who performed the work. In classical music this would be the - conductor, orchestra, soloists. In an audio book it would be the actor who did the - reading. In popular music this is typically the same as the ARTIST and is omitted. -
    -COPYRIGHT
    Copyright attribution, e.g., ’2001 Nobody’s Band’ or ’1999 Jack Moffitt’ -
    -LICENSE
    License information, for example, ’All Rights Reserved’, ’Any Use - Permitted’, a URL to a license such as a Creative Commons license (e.g. - ”creativecommons.org/license/by/4.0/”) or similar. -
    -ORGANIZATION
    Name of the organization producing the track (i.e. the ’record label’) -
    -DESCRIPTION
    A short text description of the contents -
    -GENRE
    A short text indication of music genre - - - -
    -DATE
    Date the track was recorded -
    -LOCATION
    Location where track was recorded -
    -CONTACT
    Contact information for the creators or distributors of the track. This could - be a URL, an email address, the physical address of the producing label. -
    -ISRC
    International Standard Recording Code for the track; see the ISRC intro page for - more information on ISRC numbers. -
    -

    Implications -Field names should not be ’internationalized’; this is a concession to simplicity not -an attempt to exclude the majority of the world that doesn’t speak English. Field -contents, however, use the UTF-8 character encoding to allow easy representation of any -language. -

    We have the length of the entirety of the field and restrictions on the field name so that -the field name is bounded in a known way. Thus we also have the length of the field -contents. -

    Individual ’vendors’ may use non-standard field names within reason. The proper -use of comment fields should be clear through context at this point. Abuse will be -discouraged. -

    There is no vendor-specific prefix to ’nonstandard’ field names. Vendors should make some effort -to avoid arbitrarily polluting the common namespace. We will generally collect the more useful -tags here to help with standardization. -

    Field names are not required to be unique (occur once) within a comment header. As an -example, assume a track was recorded by three well know artists; the following is permissible, -and encouraged: -

    -

    -

    -

    1ARTIST=Dizzy Gillespie
    2ARTIST=Sonny Rollins
    3ARTIST=Sonny Stitt
    - - - -
    -

    -

    5.2.3. Encoding
    -

    The comment header comprises the entirety of the second bitstream header packet. Unlike the -first bitstream header packet, it is not generally the only packet on the second page and may not -be restricted to within the second bitstream page. The length of the comment header packet is -(practically) unbounded. The comment header packet is not optional; it must be present in the -bitstream even if it is effectively empty. -

    The comment header is encoded as follows (as per Ogg’s standard bitstream mapping which -renders least-significant-bit of the word to be coded into the least significant available bit of the -current bitstream octet first): -

    -

    - 1.
    Vendor string length (32 bit unsigned quantity specifying number of octets) -
    - 2.
    Vendor string ([vendor string length] octets coded from beginning of string to end of - string, not null terminated) -
    - 3.
    Number of comment fields (32 bit unsigned quantity specifying number of fields) -
    - 4.
    Comment field 0 length (if [Number of comment fields] > 0; 32 bit unsigned quantity - specifying number of octets) -
    - 5.
    Comment field 0 ([Comment field 0 length] octets coded from beginning of string to - end of string, not null terminated) -
    - 6.
    Comment field 1 length (if [Number of comment fields] > 1...)... -
    -

    This is actually somewhat easier to describe in code; implementation of the above can be found -in vorbis/lib/info.c, _vorbis_pack_comment() and _vorbis_unpack_comment(). - - - - - - -

    6. Floor type 0 setup and decode

    -

    -

    6.1. Overview

    -

    Vorbis floor type zero uses Line Spectral Pair (LSP, also alternately known as Line Spectral -Frequency or LSF) representation to encode a smooth spectral envelope curve as the frequency -response of the LSP filter. This representation is equivalent to a traditional all-pole infinite -impulse response filter as would be used in linear predictive coding; LSP representation may be -converted to LPC representation and vice-versa. -

    -

    6.2. Floor 0 format

    -

    Floor zero configuration consists of six integer fields and a list of VQ codebooks for use in -coding/decoding the LSP filter coefficient values used by each frame. -

    -

    6.2.1. header decode
    -

    Configuration information for instances of floor zero decodes from the codec setup header (third -packet). configuration decode proceeds as follows: -

    -

    1  1) [floor0_order] = read an unsigned integer of 8 bits
    2  2) [floor0_rate] = read an unsigned integer of 16 bits -
    3  3) [floor0_bark_map_size] = read an unsigned integer of 16 bits
    4  4) [floor0_amplitude_bits] = read an unsigned integer of six bits -
    5  5) [floor0_amplitude_offset] = read an unsigned integer of eight bits
    6  6) [floor0_number_of_books] = read an unsigned integer of four bits and add 1 -
    7  7) array [floor0_book_list] = read a list of [floor0_number_of_books] unsigned integers of eight bits each;
    -

    An end-of-packet condition during any of these bitstream reads renders this stream undecodable. -In addition, any element of the array [floor0_book_list] that is greater than the maximum -codebook number for this bitstream is an error condition that also renders the stream - - - -undecodable. -

    -

    6.2.2. packet decode
    -

    Extracting a floor0 curve from an audio packet consists of first decoding the curve -amplitude and [floor0_order] LSP coefficient values from the bitstream, and then -computing the floor curve, which is defined as the frequency response of the decoded LSP -filter. -

    Packet decode proceeds as follows: -

    1  1) [amplitude] = read an unsigned integer of [floor0_amplitude_bits] bits
    2  2) if ( [amplitude] is greater than zero ) { -
    3       3) [coefficients] is an empty, zero length vector
    4       4) [booknumber] = read an unsigned integer of ilog( [floor0_number_of_books] ) bits -
    5       5) if ( [booknumber] is greater than the highest number decode codebook ) then packet is undecodable
    6       6) [last] = zero; -
    7       7) vector [temp_vector] = read vector from bitstream using codebook number [floor0_book_list] element [booknumber] in VQ context. -
    8       8) add the scalar value [last] to each scalar in vector [temp_vector]
    9       9) [last] = the value of the last scalar in vector [temp_vector] -
    10      10) concatenate [temp_vector] onto the end of the [coefficients] vector -
    11      11) if (length of vector [coefficients] is less than [floor0_order], continue at step 6
    12
    13     }
    14
    15 12) done.
    16
    -

    Take note of the following properties of decode: -

      -
    • An [amplitude] value of zero must result in a return code that indicates this channel - is unused in this frame (the output of the channel will be all-zeroes in synthesis). - Several later stages of decode don’t occur for an unused channel. -
    • -
    • An end-of-packet condition during decode should be considered a nominal occruence; - if end-of-packet is reached during any read operation above, floor decode is to return - ’unused’ status as if the [amplitude] value had read zero at the beginning of decode. -
    • -
    • The book number used for decode can, in fact, be stored in the bitstream in ilog( - [floor0_number_of_books] - 1 ) bits. Nevertheless, the above specification is correct - and values greater than the maximum possible book value are reserved. -
    • -
    • The number of scalars read into the vector [coefficients] may be greater - than [floor0_order], the number actually required for curve computation. For - example, if the VQ codebook used for the floor currently being decoded has a - [codebook_dimensions] value of three and [floor0_order] is ten, the only way to - fill all the needed scalars in [coefficients] is to to read a total of twelve scalars - as four vectors of three scalars each. This is not an error condition, and care must - be taken not to allow a buffer overflow in decode. The extra values are not used and - - - - may be ignored or discarded.
    -

    -

    6.2.3. curve computation
    -

    Given an [amplitude] integer and [coefficients] vector from packet decode as well as -the [floor0_order], [floor0_rate], [floor0_bark_map_size], [floor0_amplitude_bits] and -[floor0_amplitude_offset] values from floor setup, and an output vector size [n] specified by the -decode process, we compute a floor output vector. -

    If the value [amplitude] is zero, the return value is a length [n] vector with all-zero -scalars. Otherwise, begin by assuming the following definitions for the given vector to be -synthesized: -

    -        {
-          min (floor0xbarkxmapxsize    - 1,f oobar)  for i ∈ [0, n - 1]
-mapi =    - 1                                        for i = n
-
    -

    -

    where -

    -          ⌊     ( floor0xrate  ⋅ i) floor0xbarkxmapxsize    ⌋
-f oobar =  bark   ---------------- ⋅------------------------
-                        2n           bark(.5 ⋅ floor0xrate )
-
    -

    -

    and -

    -bark(x) = 13.1arctan (.00074x ) + 2.24 arctan(.0000000185x2 ) + .0001x
-
    -

    - - - -

    The above is used to synthesize the LSP curve on a Bark-scale frequency axis, then map the -result to a linear-scale frequency axis. Similarly, the below calculation synthesizes the output -LSP curve [output] on a log (dB) amplitude scale, mapping it to linear amplitude in the last -step: -

    -

    - 1.
    [i] = 0 -
    - 2.
    [ω] = π * map element [i] / [floor0_bark_map_size] -
    - 3.
    if ( [floor0_order] is odd ) -
    - a)
    calculate [p] and [q] according to:
    -
    -                    floor0∏x2order-3
-p  =   (1 - cos2ω)           4(cos([coefficients  ]2j+1) - cosω )2
-                      j=0
-         floor0xorder-1
-       1     ∏2                                     2
-q  =   --          4(cos([coefficients  ]2j) - cosω )
-       4    j=0
-
    -
    -
    -

    else [floor0_order] is even -

    - a)
    calculate [p] and [q] according to:
    - - - -
    -                    floor0x∏o2rder-2
-p  =   (1---cosω-)           4(cos([coefficients   ]2j+1) - cosω)2
-            2         j=0
-                   floor0xorder--2
-       (1 + cosω )    ∏2                                     2
-q  =   -----------           4(cos([coefficients  ]2j) - cos ω)
-            2         j=0
-
    -
    -
    -
    - 4.
    calculate [linear_floor_value] according to: -
    -     (           (                                                                      ))
-                 amplitude   ⋅ floor0xamplitutexoffset
-exp   .11512925   ------floor0xamplitudexbits-----√-----------  floor0xamplitudexoffset
-                     (2                   - 1)  p + q
-
    -

    -

    - 5.
    [iteration_condition] = map element [i] -
    - 6.
    [output] element [i] = [linear_floor_value] -
    - 7.
    increment [i] -
    - 8.
    if ( map element [i] is equal to [iteration_condition] ) continue at step - 5 -
    - 9.
    if ( [i] is less than [n] ) continue at step 2 - - - -
    - 10.
    done
    -

    Errata 20150227: Bark scale computation -Due to a typo when typesetting this version of the specification from the original HTML -document, the Bark scale computation previously erroneously read: -

    -bark(x) = 13.1arctan (.00074x ) + 2.24 arctan(.0000000185x2 +  .0001x )
-
    -

    -

    Note that the last parenthesis is misplaced. This document now uses the correct equation as it -appeared in the original HTML spec document: -

    -bark(x) = 13.1arctan (.00074x ) + 2.24 arctan(.0000000185x2 ) + .0001x
-
    -

    - - - - - - -

    7. Floor type 1 setup and decode

    -

    -

    7.1. Overview

    -

    Vorbis floor type one uses a piecewise straight-line representation to encode a spectral envelope -curve. The representation plots this curve mechanically on a linear frequency axis and a -logarithmic (dB) amplitude axis. The integer plotting algorithm used is similar to Bresenham’s -algorithm. -

    -

    7.2. Floor 1 format

    -

    -

    7.2.1. model
    -

    Floor type one represents a spectral curve as a series of line segments. Synthesis constructs a -floor curve using iterative prediction in a process roughly equivalent to the following simplified -description: -

      -
    • the first line segment (base case) is a logical line spanning from x˙0,y˙0 to x˙1,y˙1 - where in the base case x˙0=0 and x˙1=[n], the full range of the spectral floor to be - computed. -
    • -
    • the induction step chooses a point x˙new within an existing logical line segment and - produces a y˙new value at that point computed from the existing line’s y value at - x˙new (as plotted by the line) and a difference value decoded from the bitstream - packet. - - - -
    • -
    • floor computation produces two new line segments, one running from x˙0,y˙0 to - x˙new,y˙new and from x˙new,y˙new to x˙1,y˙1. This step is performed logically even if - y˙new represents no change to the amplitude value at x˙new so that later refinement - is additionally bounded at x˙new. -
    • -
    • the induction step repeats, using a list of x values specified in the codec setup header - at floor 1 initialization time. Computation is completed at the end of the x value list. -
    -

    Consider the following example, with values chosen for ease of understanding rather than -representing typical configuration: -

    For the below example, we assume a floor setup with an [n] of 128. The list of selected X values -in increasing order is 0,16,32,48,64,80,96,112 and 128. In list order, the values interleave as 0, -128, 64, 32, 96, 16, 48, 80 and 112. The corresponding list-order Y values as decoded from an -example packet are 110, 20, -5, -45, 0, -25, -10, 30 and -10. We compute the floor in the following -way, beginning with the first line: -

    -

    - -

    PIC -

    Figure 7: graph of example floor
    -
    -

    We now draw new logical lines to reflect the correction to new˙Y, and iterate for X positions 32 -and 96: -

    -

    - -

    PIC -

    Figure 8: graph of example floor
    -
    -

    Although the new Y value at X position 96 is unchanged, it is still used later as an endpoint for -further refinement. From here on, the pattern should be clear; we complete the floor computation -as follows: - - - -

    -

    - -

    PIC -

    Figure 9: graph of example floor
    -
    -
    -

    - -

    PIC -

    Figure 10: graph of example floor
    -
    -

    A more efficient algorithm with carefully defined integer rounding behavior is used for actual -decode, as described later. The actual algorithm splits Y value computation and line plotting -into two steps with modifications to the above algorithm to eliminate noise accumulation -through integer roundoff/truncation. -

    -

    7.2.2. header decode
    -

    A list of floor X values is stored in the packet header in interleaved format (used in list order -during packet decode and synthesis). This list is split into partitions, and each partition is -assigned to a partition class. X positions 0 and [n] are implicit and do not belong to an explicit -partition or partition class. -

    A partition class consists of a representation vector width (the number of Y values which -the partition class encodes at once), a ’subclass’ value representing the number of -alternate entropy books the partition class may use in representing Y values, the list of -[subclass] books and a master book used to encode which alternate books were chosen -for representation in a given packet. The master/subclass mechanism is meant to be -used as a flexible representation cascade while still using codebooks only in a scalar -context. - - - -

    -

    1
    2  1) [floor1_partitions] = read 5 bits as unsigned integer
    3  2) [maximum_class] = -1
    4  3) iterate [i] over the range 0 ... [floor1_partitions]-1 {
    5 -
    6        4) vector [floor1_partition_class_list] element [i] = read 4 bits as unsigned integer
    7
    8     }
    9 -
    10  5) [maximum_class] = largest integer scalar value in vector [floor1_partition_class_list]
    11  6) iterate [i] over the range 0 ... [maximum_class] {
    12 -
    13        7) vector [floor1_class_dimensions] element [i] = read 3 bits as unsigned integer and add 1 -
    14 8) vector [floor1_class_subclasses] element [i] = read 2 bits as unsigned integer -
    15        9) if ( vector [floor1_class_subclasses] element [i] is nonzero ) {
    16 -
    17             10) vector [floor1_class_masterbooks] element [i] = read 8 bits as unsigned integer
    18
    19           }
    20 -
    21       11) iterate [j] over the range 0 ... (2 exponent [floor1_class_subclasses] element [i]) - 1 {
    22 -
    23             12) array [floor1_subclass_books] element [i],[j] =
    24                 read 8 bits as unsigned integer and subtract one -
    25           }
    26      }
    27
    28 13) [floor1_multiplier] = read 2 bits as unsigned integer and add one
    29 14) [rangebits] = read 4 bits as unsigned integer -
    30 15) vector [floor1_X_list] element [0] = 0
    31 16) vector [floor1_X_list] element [1] = 2 exponent [rangebits];
    32 17) [floor1_values] = 2 -
    33 18) iterate [i] over the range 0 ... [floor1_partitions]-1 {
    34
    35       19) [current_class_number] = vector [floor1_partition_class_list] element [i] -
    36       20) iterate [j] over the range 0 ... ([floor1_class_dimensions] element [current_class_number])-1 { -
    37             21) vector [floor1_X_list] element ([floor1_values]) =
    38                 read [rangebits] bits as unsigned integer -
    39             22) increment [floor1_values] by one
    40           }
    41     }
    42
    43 23) done
    -

    An end-of-packet condition while reading any aspect of a floor 1 configuration during -setup renders a stream undecodable. In addition, a [floor1_class_masterbooks] or -[floor1_subclass_books] scalar element greater than the highest numbered codebook -configured in this stream is an error condition that renders the stream undecodable. Vector -[floor1_x_list] is limited to a maximum length of 65 elements; a setup indicating more than 65 -total elements (including elements 0 and 1 set prior to the read loop) renders the stream -undecodable. All vector [floor1_x_list] element values must be unique within the vector; a -non-unique value renders the stream undecodable. -

    -

    7.2.3. packet decode
    -

    Packet decode begins by checking the [nonzero] flag: -

    -

    1  1) [nonzero] = read 1 bit as boolean
    -

    If [nonzero] is unset, that indicates this channel contained no audio energy in this frame. -Decode immediately returns a status indicating this floor curve (and thus this channel) is unused -this frame. (A return status of ’unused’ is different from decoding a floor that has all -points set to minimum representation amplitude, which happens to be approximately --140dB). -

    Assuming [nonzero] is set, decode proceeds as follows: -

    -

    1  1) [range] = vector { 256, 128, 86, 64 } element ([floor1_multiplier]-1) -
    2  2) vector [floor1_Y] element [0] = read ilog([range]-1) bits as unsigned integer - - - -
    3  3) vector [floor1_Y] element [1] = read ilog([range]-1) bits as unsigned integer -
    4  4) [offset] = 2;
    5  5) iterate [i] over the range 0 ... [floor1_partitions]-1 {
    6 -
    7       6) [class] = vector [floor1_partition_class]  element [i]
    8       7) [cdim]  = vector [floor1_class_dimensions] element [class] -
    9       8) [cbits] = vector [floor1_class_subclasses] element [class]
    10       9) [csub]  = (2 exponent [cbits])-1
    11      10) [cval]  = 0 -
    12      11) if ( [cbits] is greater than zero ) {
    13
    14             12) [cval] = read from packet using codebook number -
    15                 (vector [floor1_class_masterbooks] element [class]) in scalar context
    16          }
    17
    18      13) iterate [j] over the range 0 ... [cdim]-1 {
    19 -
    20             14) [book] = array [floor1_subclass_books] element [class],([cval] bitwise AND [csub]) -
    21             15) [cval] = [cval] right shifted [cbits] bits
    22      16) if ( [book] is not less than zero ) {
    23 -
    24            17) vector [floor1_Y] element ([j]+[offset]) = read from packet using codebook
    25                       [book] in scalar context
    26 -
    27                 } else [book] is less than zero {
    28
    29            18) vector [floor1_Y] element ([j]+[offset]) = 0
    30 -
    31                 }
    32          }
    33
    34      19) [offset] = [offset] + [cdim]
    35
    36     }
    37
    38 20) done
    -

    An end-of-packet condition during curve decode should be considered a nominal occurrence; if -end-of-packet is reached during any read operation above, floor decode is to return ’unused’ -status as if the [nonzero] flag had been unset at the beginning of decode. -

    Vector [floor1_Y] contains the values from packet decode needed for floor 1 synthesis. -

    -

    7.2.4. curve computation
    -

    Curve computation is split into two logical steps; the first step derives final Y amplitude values -from the encoded, wrapped difference values taken from the bitstream. The second step -plots the curve lines. Also, although zero-difference values are used in the iterative -prediction to find final Y values, these points are conditionally skipped during final -line computation in step two. Skipping zero-difference values allows a smoother line -fit. -

    Although some aspects of the below algorithm look like inconsequential optimizations, -implementors are warned to follow the details closely. Deviation from implementing a strictly -equivalent algorithm can result in serious decoding errors. -

    Additional note: Although [floor1_final_Y] values in the prediction loop and at the end of -step 1 are inherently limited by the prediction algorithm to [0, [range]), it is possible to abuse -the setup and codebook machinery to produce negative or over-range results. We suggest that -decoder implementations guard the values in vector [floor1_final_Y] by clamping each -element to [0, [range]) after step 1. Variants of this suggestion are acceptable as valid floor1 -setups cannot produce out of range values. -

    -

    -step 1: amplitude value synthesis
    -

    Unwrap the always-positive-or-zero values read from the packet into +/- difference - values, then apply to line prediction. - - - -

    -

    1  1) [range] = vector { 256, 128, 86, 64 } element ([floor1_multiplier]-1)
    2  2) vector [floor1_step2_flag] element [0] = set -
    3  3) vector [floor1_step2_flag] element [1] = set
    4  4) vector [floor1_final_Y] element [0] = vector [floor1_Y] element [0] -
    5  5) vector [floor1_final_Y] element [1] = vector [floor1_Y] element [1]
    6  6) iterate [i] over the range 2 ... [floor1_values]-1 {
    7 -
    8       7) [low_neighbor_offset] = low_neighbor([floor1_X_list],[i])
    9       8) [high_neighbor_offset] = high_neighbor([floor1_X_list],[i])
    10 -
    11       9) [predicted] = render_point( vector [floor1_X_list] element [low_neighbor_offset], -
    12       vector [floor1_final_Y] element [low_neighbor_offset], -
    13                                      vector [floor1_X_list] element [high_neighbor_offset], -
    14       vector [floor1_final_Y] element [high_neighbor_offset], -
    15                                      vector [floor1_X_list] element [i] )
    16
    17      10) [val] = vector [floor1_Y] element [i] -
    18      11) [highroom] = [range] - [predicted]
    19      12) [lowroom]  = [predicted]
    20      13) if ( [highroom] is less than [lowroom] ) {
    21 -
    22            14) [room] = [highroom] * 2
    23
    24          } else [highroom] is not less than [lowroom] {
    25
    26            15) [room] = [lowroom] * 2
    27 -
    28          }
    29
    30      16) if ( [val] is nonzero ) {
    31
    32            17) vector [floor1_step2_flag] element [low_neighbor_offset] = set -
    33            18) vector [floor1_step2_flag] element [high_neighbor_offset] = set
    34            19) vector [floor1_step2_flag] element [i] = set -
    35            20) if ( [val] is greater than or equal to [room] ) {
    36
    37                  21) if ( [highroom] is greater than [lowroom] ) {
    38 -
    39                        22) vector [floor1_final_Y] element [i] = [val] - [lowroom] + [predicted]
    40 -
    41       } else [highroom] is not greater than [lowroom] {
    42 -
    43                        23) vector [floor1_final_Y] element [i] = [predicted] - [val] + [highroom] - 1
    44 -
    45                      }
    46
    47                } else [val] is less than [room] {
    48 -
    49                    24) if ([val] is odd) {
    50
    51                        25) vector [floor1_final_Y] element [i] = -
    52                            [predicted] - (([val] + 1) divided by  2 using integer division)
    53 -
    54                      } else [val] is even {
    55
    56                        26) vector [floor1_final_Y] element [i] = -
    57                            [predicted] + ([val] / 2 using integer division)
    58
    59                      }
    60 -
    61                }
    62
    63          } else [val] is zero {
    64
    65            27) vector [floor1_step2_flag] element [i] = unset -
    66            28) vector [floor1_final_Y] element [i] = [predicted]
    67
    68          }
    69
    70     }
    71
    72 29) done
    73
    -
    -step 2: curve synthesis
    -

    Curve synthesis generates a return vector [floor] of length [n] (where [n] is provided by - the decode process calling to floor decode). Floor 1 curve synthesis makes use of the - [floor1_X_list], [floor1_final_Y] and [floor1_step2_flag] vectors, as well as - [floor1_multiplier] and [floor1_values] values. -

    Decode begins by sorting the scalars from vectors [floor1_X_list], [floor1_final_Y] and - [floor1_step2_flag] together into new vectors [floor1_X_list]’, [floor1_final_Y]’ - and [floor1_step2_flag]’ according to ascending sort order of the values in - [floor1_X_list]. That is, sort the values of [floor1_X_list] and then apply the same - permutation to elements of the other two vectors so that the X, Y and step2_flag values - still match. -

    Then compute the final curve in one pass: -

    -

    1  1) [hx] = 0
    2  2) [lx] = 0
    3  3) [ly] = vector [floor1_final_Y]’ element [0] * [floor1_multiplier] -
    4  4) iterate [i] over the range 1 ... [floor1_values]-1 {
    5
    6       5) if ( [floor1_step2_flag]’ element [i] is set ) {
    7 -
    8             6) [hy] = [floor1_final_Y]’ element [i] * [floor1_multiplier]
    9       7) [hx] = [floor1_X_list]’ element [i] -
    10             8) render_line( [lx], [ly], [hx], [hy], [floor] )
    11             9) [lx] = [hx]
    12     10) [ly] = [hy]
    13          }
    14     }
    15 -
    16 11) if ( [hx] is less than [n] ) {
    17
    18        12) render_line( [hx], [hy], [n], [hy], [floor] )
    19
    20     }
    21
    22 13) if ( [hx] is greater than [n] ) {
    23 -
    24            14) truncate vector [floor] to [n] elements
    25
    26     }
    27
    28 15) for each scalar in vector [floor], perform a lookup substitution using -
    29     the scalar value from [floor] as an offset into the vector [floor1_inverse_dB_static_table]
    30
    31 16) done
    32
    -
    - - - -

    8. Residue setup and decode

    -

    -

    8.1. Overview

    -

    A residue vector represents the fine detail of the audio spectrum of one channel in an audio frame -after the encoder subtracts the floor curve and performs any channel coupling. A residue vector -may represent spectral lines, spectral magnitude, spectral phase or hybrids as mixed by channel -coupling. The exact semantic content of the vector does not matter to the residue -abstraction. -

    Whatever the exact qualities, the Vorbis residue abstraction codes the residue vectors into the -bitstream packet, and then reconstructs the vectors during decode. Vorbis makes use of three -different encoding variants (numbered 0, 1 and 2) of the same basic vector encoding -abstraction. -

    -

    8.2. Residue format

    -

    Residue format partitions each vector in the vector bundle into chunks, classifies each -chunk, encodes the chunk classifications and finally encodes the chunks themselves -using the the specific VQ arrangement defined for each selected classification. The -exact interleaving and partitioning vary by residue encoding number, however the -high-level process used to classify and encode the residue vector is the same in all three -variants. -

    A set of coded residue vectors are all of the same length. High level coding structure, ignoring for -the moment exactly how a partition is encoded and simply trusting that it is, is as -follows: -

      -
    • Each vector is partitioned into multiple equal sized chunks according to configuration - specified. If we have a vector size of n, a partition size residue_partition_size, - and a total of ch residue vectors, the total number of partitioned chunks coded - - - - is n/residue_partition_size*ch. It is important to note that the integer division - truncates. In the below example, we assume an example residue_partition_size of 8. -
    • -
    • Each partition in each vector has a classification number that specifies which of - multiple configured VQ codebook setups are used to decode that partition. The - classification numbers of each partition can be thought of as forming a vector in - their own right, as in the illustration below. Just as the residue vectors are coded - in grouped partitions to increase encoding efficiency, the classification vector is also - partitioned into chunks. The integer elements of each scalar in a classification chunk - are built into a single scalar that represents the classification numbers in that chunk. - In the below example, the classification codeword encodes two classification numbers. -
    • -
    • The values in a residue vector may be encoded monolithically in a single pass through - the residue vector, but more often efficient codebook design dictates that each vector - is encoded as the additive sum of several passes through the residue vector using - more than one VQ codebook. Thus, each residue value potentially accumulates values - from multiple decode passes. The classification value associated with a partition is - the same in each pass, thus the classification codeword is coded only in the first pass. -
    -
    -

    - -

    PIC -

    Figure 11: illustration of residue vector format
    -
    -

    -

    8.3. residue 0

    -

    Residue 0 and 1 differ only in the way the values within a residue partition are interleaved during -partition encoding (visually treated as a black box–or cyan box or brown box–in the above -figure). -

    Residue encoding 0 interleaves VQ encoding according to the dimension of the codebook used to - - - -encode a partition in a specific pass. The dimension of the codebook need not be the same in -multiple passes, however the partition size must be an even multiple of the codebook -dimension. -

    As an example, assume a partition vector of size eight, to be encoded by residue 0 using -codebook sizes of 8, 4, 2 and 1: -

    -

    1
    2            original residue vector: [ 0 1 2 3 4 5 6 7 ]
    3
    4codebook dimensions = 8  encoded as: [ 0 1 2 3 4 5 6 7 ]
    5 -
    6codebook dimensions = 4  encoded as: [ 0 2 4 6 ], [ 1 3 5 7 ]
    7
    8codebook dimensions = 2  encoded as: [ 0 4 ], [ 1 5 ], [ 2 6 ], [ 3 7 ]
    9 -
    10codebook dimensions = 1  encoded as: [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ]
    11
    -

    It is worth mentioning at this point that no configurable value in the residue coding setup is -restricted to a power of two. -

    -

    8.4. residue 1

    -

    Residue 1 does not interleave VQ encoding. It represents partition vector scalars in order. As -with residue 0, however, partition length must be an integer multiple of the codebook dimension, -although dimension may vary from pass to pass. -

    As an example, assume a partition vector of size eight, to be encoded by residue 0 using -codebook sizes of 8, 4, 2 and 1: -

    -

    1
    2            original residue vector: [ 0 1 2 3 4 5 6 7 ]
    3
    4codebook dimensions = 8  encoded as: [ 0 1 2 3 4 5 6 7 ]
    5 -
    6codebook dimensions = 4  encoded as: [ 0 1 2 3 ], [ 4 5 6 7 ]
    7
    8codebook dimensions = 2  encoded as: [ 0 1 ], [ 2 3 ], [ 4 5 ], [ 6 7 ]
    9 -
    10codebook dimensions = 1  encoded as: [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ]
    11
    -

    -

    8.5. residue 2

    -

    Residue type two can be thought of as a variant of residue type 1. Rather than encoding multiple -passed-in vectors as in residue type 1, the ch passed in vectors of length n are first interleaved -and flattened into a single vector of length ch*n. Encoding then proceeds as in type 1. Decoding -is as in type 1 with decode interleave reversed. If operating on a single vector to begin with, -residue type 1 and type 2 are equivalent. - - - -

    -

    - -

    PIC -

    Figure 12: illustration of residue type 2
    -
    -

    -

    8.6. Residue decode

    -

    -

    8.6.1. header decode
    -

    Header decode for all three residue types is identical. -

    1  1) [residue\_begin] = read 24 bits as unsigned integer
    2  2) [residue\_end] = read 24 bits as unsigned integer -
    3  3) [residue\_partition\_size] = read 24 bits as unsigned integer and add one -
    4  4) [residue\_classifications] = read 6 bits as unsigned integer and add one
    5  5) [residue\_classbook] = read 8 bits as unsigned integer
    -

    [residue_begin] and [residue_end] select the specific sub-portion of each vector that is -actually coded; it implements akin to a bandpass where, for coding purposes, the vector -effectively begins at element [residue_begin] and ends at [residue_end]. Preceding and -following values in the unpacked vectors are zeroed. Note that for residue type 2, these -values as well as [residue_partition_size]apply to the interleaved vector, not the -individual vectors before interleave. [residue_partition_size] is as explained above, -[residue_classifications] is the number of possible classification to which a partition can -belong and [residue_classbook] is the codebook number used to code classification -codewords. The number of dimensions in book [residue_classbook] determines how -many classification values are grouped into a single classification codeword. Note that -the number of entries and dimensions in book [residue_classbook], along with -[residue_classifications], overdetermines to possible number of classification -codewords. If [residue_classifications]ˆ[residue_classbook].dimensions exceeds -[residue_classbook].entries, the bitstream should be regarded to be undecodable. - - - -

    Next we read a bitmap pattern that specifies which partition classes code values in which -passes. -

    -

    1  1) iterate [i] over the range 0 ... [residue\_classifications]-1 {
    2
    3       2) [high\_bits] = 0
    4       3) [low\_bits] = read 3 bits as unsigned integer -
    5       4) [bitflag] = read one bit as boolean
    6       5) if ( [bitflag] is set ) then [high\_bits] = read five bits as unsigned integer -
    7       6) vector [residue\_cascade] element [i] = [high\_bits] * 8 + [low\_bits]
    8     }
    9  7) done
    -

    Finally, we read in a list of book numbers, each corresponding to specific bit set in the cascade -bitmap. We loop over the possible codebook classifications and the maximum possible number of -encoding stages (8 in Vorbis I, as constrained by the elements of the cascade bitmap being eight -bits): -

    -

    1  1) iterate [i] over the range 0 ... [residue\_classifications]-1 {
    2
    3       2) iterate [j] over the range 0 ... 7 {
    4 -
    5            3) if ( vector [residue\_cascade] element [i] bit [j] is set ) {
    6 -
    7                 4) array [residue\_books] element [i][j] = read 8 bits as unsigned integer
    8
    9               } else {
    10 -
    11                 5) array [residue\_books] element [i][j] = unused
    12
    13               }
    14          }
    15      }
    16
    17  6) done
    -

    An end-of-packet condition at any point in header decode renders the stream undecodable. -In addition, any codebook number greater than the maximum numbered codebook -set up in this stream also renders the stream undecodable. All codebooks in array -[residue_books] are required to have a value mapping. The presence of codebook in array -[residue_books] without a value mapping (maptype equals zero) renders the stream -undecodable. -

    -

    8.6.2. packet decode
    -

    Format 0 and 1 packet decode is identical except for specific partition interleave. Format 2 packet -decode can be built out of the format 1 decode process. Thus we describe first the decode -infrastructure identical to all three formats. -

    In addition to configuration information, the residue decode process is passed the number of -vectors in the submap bundle and a vector of flags indicating if any of the vectors are not to be -decoded. If the passed in number of vectors is 3 and vector number 1 is marked ’do not decode’, -decode skips vector 1 during the decode loop. However, even ’do not decode’ vectors are -allocated and zeroed. -

    Depending on the values of [residue_begin] and [residue_end], it is obvious that the -encoded portion of a residue vector may be the entire possible residue vector or some other strict -subset of the actual residue vector size with zero padding at either uncoded end. However, it is -also possible to set [residue_begin] and [residue_end] to specify a range partially or wholly - - - -beyond the maximum vector size. Before beginning residue decode, limit [residue_begin] -and [residue_end] to the maximum possible vector size as follows. We assume that -the number of vectors being encoded, [ch] is provided by the higher level decoding -process. -

    -

    1  1) [actual\_size] = current blocksize/2;
    2  2) if residue encoding is format 2
    3       3) [actual\_size] = [actual\_size] * [ch]; -
    4  4) [limit\_residue\_begin] = minimum of ([residue\_begin],[actual\_size]);
    5  5) [limit\_residue\_end] = minimum of ([residue\_end],[actual\_size]);
    -

    The following convenience values are conceptually useful to clarifying the decode process: -

    -

    1  1) [classwords\_per\_codeword] = [codebook\_dimensions] value of codebook [residue\_classbook] -
    2  2) [n\_to\_read] = [limit\_residue\_end] - [limit\_residue\_begin]
    3  3) [partitions\_to\_read] = [n\_to\_read] / [residue\_partition\_size]
    -

    Packet decode proceeds as follows, matching the description offered earlier in the document. -

    1  1) allocate and zero all vectors that will be returned.
    2  2) if ([n\_to\_read] is zero), stop; there is no residue to decode. -
    3  3) iterate [pass] over the range 0 ... 7 {
    4
    5       4) [partition\_count] = 0
    6 -
    7       5) while [partition\_count] is less than [partitions\_to\_read]
    8
    9            6) if ([pass] is zero) {
    10 -
    11                 7) iterate [j] over the range 0 .. [ch]-1 {
    12
    13                      8) if vector [j] is not marked ’do not decode’ {
    14 -
    15                           9) [temp] = read from packet using codebook [residue\_classbook] in scalar context -
    16                          10) iterate [i] descending over the range [classwords\_per\_codeword]-1 ... 0 {
    17 -
    18                               11) array [classifications] element [j],([i]+[partition\_count]) = -
    19                                   [temp] integer modulo [residue\_classifications] -
    20                               12) [temp] = [temp] / [residue\_classifications] using integer division
    21 -
    22                              }
    23
    24                         }
    25
    26                    }
    27
    28               }
    29 -
    30           13) iterate [i] over the range 0 .. ([classwords\_per\_codeword] - 1) while [partition\_count] -
    31               is also less than [partitions\_to\_read] {
    32
    33                 14) iterate [j] over the range 0 .. [ch]-1 {
    34 -
    35                      15) if vector [j] is not marked ’do not decode’ {
    36 -
    37                           16) [vqclass] = array [classifications] element [j],[partition\_count] -
    38                           17) [vqbook] = array [residue\_books] element [vqclass],[pass]
    39                           18) if ([vqbook] is not ’unused’) {
    40 -
    41                                19) decode partition into output vector number [j], starting at scalar -
    42                                    offset [limit\_residue\_begin]+[partition\_count]*[residue\_partition\_size] using -
    43                                    codebook number [vqbook] in VQ context
    44                          } -
    45                     }
    46
    47                 20) increment [partition\_count] by one
    48
    49               }
    50          }
    51     }
    52
    53 21) done
    54
    -

    An end-of-packet condition during packet decode is to be considered a nominal occurrence. -Decode returns the result of vector decode up to that point. -

    -

    8.6.3. format 0 specifics
    -

    Format zero decodes partitions exactly as described earlier in the ’Residue Format: residue 0’ -section. The following pseudocode presents the same algorithm. Assume: - - - -

      -
    • [n] is the value in [residue_partition_size] -
    • -
    • [v] is the residue vector -
    • -
    • [offset] is the beginning read offset in [v]
    -

    -

    1 1) [step] = [n] / [codebook\_dimensions]
    2 2) iterate [i] over the range 0 ... [step]-1 {
    3 -
    4      3) vector [entry\_temp] = read vector from packet using current codebook in VQ context -
    5      4) iterate [j] over the range 0 ... [codebook\_dimensions]-1 {
    6
    7           5) vector [v] element ([offset]+[i]+[j]*[step]) = -
    8         vector [v] element ([offset]+[i]+[j]*[step]) +
    9                vector [entry\_temp] element [j]
    10
    11         }
    12
    13    }
    14
    15  6) done
    16
    -

    -

    8.6.4. format 1 specifics
    -

    Format 1 decodes partitions exactly as described earlier in the ’Residue Format: residue 1’ -section. The following pseudocode presents the same algorithm. Assume: -

      -
    • [n] is the value in [residue_partition_size] -
    • -
    • [v] is the residue vector -
    • -
    • [offset] is the beginning read offset in [v]
    -

    -

    1 1) [i] = 0
    2 2) vector [entry\_temp] = read vector from packet using current codebook in VQ context -
    3 3) iterate [j] over the range 0 ... [codebook\_dimensions]-1 {
    4
    5      4) vector [v] element ([offset]+[i]) =
    6   vector [v] element ([offset]+[i]) + -
    7          vector [entry\_temp] element [j]
    8      5) increment [i]
    9
    10    }
    11
    12  6) if ( [i] is less than [n] ) continue at step 2
    13  7) done
    -

    -

    8.6.5. format 2 specifics
    - - - -

    Format 2 is reducible to format 1. It may be implemented as an additional step prior to and an -additional post-decode step after a normal format 1 decode. -

    Format 2 handles ’do not decode’ vectors differently than residue 0 or 1; if all vectors are marked -’do not decode’, no decode occurrs. However, if at least one vector is to be decoded, all -the vectors are decoded. We then request normal format 1 to decode a single vector -representing all output channels, rather than a vector for each channel. After decode, -deinterleave the vector into independent vectors, one for each output channel. That -is: -

    -

    - 1.
    If all vectors 0 through ch-1 are marked ’do not decode’, allocate and clear a single - vector [v]of length ch*n and skip step 2 below; proceed directly to the post-decode - step. -
    - 2.
    Rather than performing format 1 decode to produce ch vectors of length n each, call - format 1 decode to produce a single vector [v] of length ch*n. -
    - 3.
    Post decode: Deinterleave the single vector [v] returned by format 1 decode as - described above into ch independent vectors, one for each outputchannel, according - to: -
    1  1) iterate [i] over the range 0 ... [n]-1 {
    2
    3       2) iterate [j] over the range 0 ... [ch]-1 {
    4 -
    5            3) output vector number [j] element [i] = vector [v] element ([i] * [ch] + [j])
    6
    7          }
    8     }
    9
    10  4) done
    -
    - - - - - - -

    9. Helper equations

    -

    -

    9.1. Overview

    -

    The equations below are used in multiple places by the Vorbis codec specification. Rather than -cluttering up the main specification documents, they are defined here and referenced where -appropriate. -

    -

    9.2. Functions

    -

    -

    9.2.1. ilog
    -

    The ”ilog(x)” function returns the position number (1 through n) of the highest set bit in the -two’s complement integer value [x]. Values of [x] less than zero are defined to return -zero. -

    -

    1  1) [return\_value] = 0;
    2  2) if ( [x] is greater than zero ) {
    3
    4       3) increment [return\_value]; -
    5       4) logical shift [x] one bit to the right, padding the MSb with zero
    6       5) repeat at step 2)
    7
    8     }
    9
    10   6) done
    -

    Examples: -

      -
    • ilog(0) = 0; -
    • -
    • ilog(1) = 1; - - - -
    • -
    • ilog(2) = 2; -
    • -
    • ilog(3) = 2; -
    • -
    • ilog(4) = 3; -
    • -
    • ilog(7) = 3; -
    • -
    • ilog(negative number) = 0;
    -

    -

    9.2.2. float32_unpack
    -

    ”float32_unpack(x)” is intended to translate the packed binary representation of a Vorbis -codebook float value into the representation used by the decoder for floating point numbers. For -purposes of this example, we will unpack a Vorbis float32 into a host-native floating point -number. -

    -

    1  1) [mantissa] = [x] bitwise AND 0x1fffff (unsigned result)
    2  2) [sign] = [x] bitwise AND 0x80000000 (unsigned result) -
    3  3) [exponent] = ( [x] bitwise AND 0x7fe00000) shifted right 21 bits (unsigned result) -
    4  4) if ( [sign] is nonzero ) then negate [mantissa]
    5  5) return [mantissa] * ( 2 ^ ( [exponent] - 788 ) )
    -

    -

    9.2.3. lookup1_values
    -

    ”lookup1_values(codebook_entries,codebook_dimensions)” is used to compute the -correct length of the value index for a codebook VQ lookup table of lookup type 1. -The values on this list are permuted to construct the VQ vector lookup table of size -[codebook_entries]. -

    The return value for this function is defined to be ’the greatest integer value for which -[return_value] to the power of [codebook_dimensions] is less than or equal to -[codebook_entries]’. - - - -

    -

    9.2.4. low_neighbor
    -

    ”low_neighbor(v,x)” finds the position n in vector [v] of the greatest value scalar element for -which n is less than [x] and vector [v] element n is less than vector [v] element -[x]. -

    -

    9.2.5. high_neighbor
    -

    ”high_neighbor(v,x)” finds the position n in vector [v] of the lowest value scalar element for -which n is less than [x] and vector [v] element n is greater than vector [v] element -[x]. -

    -

    9.2.6. render_point
    -

    ”render_point(x0,y0,x1,y1,X)” is used to find the Y value at point X along the line specified by -x0, x1, y0 and y1. This function uses an integer algorithm to solve for the point directly without -calculating intervening values along the line. -

    -

    1  1)  [dy] = [y1] - [y0]
    2  2) [adx] = [x1] - [x0]
    3  3) [ady] = absolute value of [dy]
    4  4) [err] = [ady] * ([X] - [x0]) -
    5  5) [off] = [err] / [adx] using integer division
    6  6) if ( [dy] is less than zero ) {
    7
    8       7) [Y] = [y0] - [off]
    9 -
    10     } else {
    11
    12       8) [Y] = [y0] + [off]
    13
    14     }
    15
    16  9) done
    -

    -

    9.2.7. render_line
    - - - -

    Floor decode type one uses the integer line drawing algorithm of ”render_line(x0, y0, x1, y1, v)” -to construct an integer floor curve for contiguous piecewise line segments. Note that it has not -been relevant elsewhere, but here we must define integer division as rounding division of both -positive and negative numbers toward zero. -

    -

    1  1)   [dy] = [y1] - [y0]
    2  2)  [adx] = [x1] - [x0]
    3  3)  [ady] = absolute value of [dy]
    4  4) [base] = [dy] / [adx] using integer division -
    5  5)    [x] = [x0]
    6  6)    [y] = [y0]
    7  7)  [err] = 0
    8
    9  8) if ( [dy] is less than 0 ) {
    10
    11        9) [sy] = [base] - 1
    12 -
    13     } else {
    14
    15       10) [sy] = [base] + 1
    16
    17     }
    18
    19 11) [ady] = [ady] - (absolute value of [base]) * [adx] -
    20 12) vector [v] element [x] = [y]
    21
    22 13) iterate [x] over the range [x0]+1 ... [x1]-1 {
    23
    24       14) [err] = [err] + [ady]; -
    25       15) if ( [err] >= [adx] ) {
    26
    27             16) [err] = [err] - [adx]
    28             17)   [y] = [y] + [sy]
    29 -
    30           } else {
    31
    32             18) [y] = [y] + [base]
    33
    34           }
    35
    36       19) vector [v] element [x] = [y]
    37
    38     }
    - - - - - - -

    10. Tables

    -

    -

    10.1. floor1_inverse_dB_table

    -

    The vector [floor1_inverse_dB_table] is a 256 element static lookup table consisting of the -following values (read left to right then top to bottom): -

    -

    1  1.0649863e-07, 1.1341951e-07, 1.2079015e-07, 1.2863978e-07,
    2  1.3699951e-07, 1.4590251e-07, 1.5538408e-07, 1.6548181e-07, -
    3  1.7623575e-07, 1.8768855e-07, 1.9988561e-07, 2.1287530e-07,
    4  2.2670913e-07, 2.4144197e-07, 2.5713223e-07, 2.7384213e-07, -
    5  2.9163793e-07, 3.1059021e-07, 3.3077411e-07, 3.5226968e-07,
    6  3.7516214e-07, 3.9954229e-07, 4.2550680e-07, 4.5315863e-07, -
    7  4.8260743e-07, 5.1396998e-07, 5.4737065e-07, 5.8294187e-07,
    8  6.2082472e-07, 6.6116941e-07, 7.0413592e-07, 7.4989464e-07, -
    9  7.9862701e-07, 8.5052630e-07, 9.0579828e-07, 9.6466216e-07,
    10  1.0273513e-06, 1.0941144e-06, 1.1652161e-06, 1.2409384e-06, -
    11  1.3215816e-06, 1.4074654e-06, 1.4989305e-06, 1.5963394e-06,
    12  1.7000785e-06, 1.8105592e-06, 1.9282195e-06, 2.0535261e-06, -
    13  2.1869758e-06, 2.3290978e-06, 2.4804557e-06, 2.6416497e-06,
    14  2.8133190e-06, 2.9961443e-06, 3.1908506e-06, 3.3982101e-06, -
    15  3.6190449e-06, 3.8542308e-06, 4.1047004e-06, 4.3714470e-06,
    16  4.6555282e-06, 4.9580707e-06, 5.2802740e-06, 5.6234160e-06, -
    17  5.9888572e-06, 6.3780469e-06, 6.7925283e-06, 7.2339451e-06,
    18  7.7040476e-06, 8.2047000e-06, 8.7378876e-06, 9.3057248e-06, -
    19  9.9104632e-06, 1.0554501e-05, 1.1240392e-05, 1.1970856e-05,
    20  1.2748789e-05, 1.3577278e-05, 1.4459606e-05, 1.5399272e-05, -
    21  1.6400004e-05, 1.7465768e-05, 1.8600792e-05, 1.9809576e-05,
    22  2.1096914e-05, 2.2467911e-05, 2.3928002e-05, 2.5482978e-05, -
    23  2.7139006e-05, 2.8902651e-05, 3.0780908e-05, 3.2781225e-05,
    24  3.4911534e-05, 3.7180282e-05, 3.9596466e-05, 4.2169667e-05, -
    25  4.4910090e-05, 4.7828601e-05, 5.0936773e-05, 5.4246931e-05,
    26  5.7772202e-05, 6.1526565e-05, 6.5524908e-05, 6.9783085e-05, -
    27  7.4317983e-05, 7.9147585e-05, 8.4291040e-05, 8.9768747e-05,
    28  9.5602426e-05, 0.00010181521, 0.00010843174, 0.00011547824, -
    29  0.00012298267, 0.00013097477, 0.00013948625, 0.00014855085,
    30  0.00015820453, 0.00016848555, 0.00017943469, 0.00019109536, -
    31  0.00020351382, 0.00021673929, 0.00023082423, 0.00024582449,
    32  0.00026179955, 0.00027881276, 0.00029693158, 0.00031622787, -
    33  0.00033677814, 0.00035866388, 0.00038197188, 0.00040679456,
    34  0.00043323036, 0.00046138411, 0.00049136745, 0.00052329927, -
    35  0.00055730621, 0.00059352311, 0.00063209358, 0.00067317058,
    36  0.00071691700, 0.00076350630, 0.00081312324, 0.00086596457, -
    37  0.00092223983, 0.00098217216, 0.0010459992,  0.0011139742,
    38  0.0011863665,  0.0012634633,  0.0013455702,  0.0014330129, -
    39  0.0015261382,  0.0016253153,  0.0017309374,  0.0018434235,
    40  0.0019632195,  0.0020908006,  0.0022266726,  0.0023713743, -
    41  0.0025254795,  0.0026895994,  0.0028643847,  0.0030505286,
    42  0.0032487691,  0.0034598925,  0.0036847358,  0.0039241906, -
    43  0.0041792066,  0.0044507950,  0.0047400328,  0.0050480668,
    44  0.0053761186,  0.0057254891,  0.0060975636,  0.0064938176, -
    45  0.0069158225,  0.0073652516,  0.0078438871,  0.0083536271,
    46  0.0088964928,  0.009474637,   0.010090352,   0.010746080, -
    47  0.011444421,   0.012188144,   0.012980198,   0.013823725,
    48  0.014722068,   0.015678791,   0.016697687,   0.017782797, -
    49  0.018938423,   0.020169149,   0.021479854,   0.022875735,
    50  0.024362330,   0.025945531,   0.027631618,   0.029427276, -
    51  0.031339626,   0.033376252,   0.035545228,   0.037855157,
    52  0.040315199,   0.042935108,   0.045725273,   0.048696758, -
    53  0.051861348,   0.055231591,   0.058820850,   0.062643361,
    54  0.066714279,   0.071049749,   0.075666962,   0.080584227, -
    55  0.085821044,   0.091398179,   0.097337747,   0.10366330,
    56  0.11039993,    0.11757434,    0.12521498,    0.13335215, -
    57  0.14201813,    0.15124727,    0.16107617,    0.17154380,
    58  0.18269168,    0.19456402,    0.20720788,    0.22067342, -
    59  0.23501402,    0.25028656,    0.26655159,    0.28387361,
    60  0.30232132,    0.32196786,    0.34289114,    0.36517414, -
    61  0.38890521,    0.41417847,    0.44109412,    0.46975890,
    62  0.50028648,    0.53279791,    0.56742212,    0.60429640, -
    63  0.64356699,    0.68538959,    0.72993007,    0.77736504,
    64  0.82788260,    0.88168307,    0.9389798,     1.
    - - - - - - -

    A. Embedding Vorbis into an Ogg stream

    -

    -

    A.1. Overview

    -

    This document describes using Ogg logical and physical transport streams to encapsulate Vorbis -compressed audio packet data into file form. -

    The section 1, “Introduction and Description” provides an overview of the construction of Vorbis -audio packets. -

    The Ogg bitstream overview and Ogg logical bitstream and framing spec provide detailed -descriptions of Ogg transport streams. This specification document assumes a working -knowledge of the concepts covered in these named backround documents. Please read them -first. -

    -

    A.1.1. Restrictions
    -

    The Ogg/Vorbis I specification currently dictates that Ogg/Vorbis streams use Ogg transport -streams in degenerate, unmultiplexed form only. That is: -

      -
    • A meta-headerless Ogg file encapsulates the Vorbis I packets -
    • -
    • The Ogg stream may be chained, i.e., contain multiple, contigous logical streams - (links). -
    • -
    • The Ogg stream must be unmultiplexed (only one stream, a Vorbis audio stream, - per link) -
    - - - -

    This is not to say that it is not currently possible to multiplex Vorbis with other media -types into a multi-stream Ogg file. At the time this document was written, Ogg was -becoming a popular container for low-bitrate movies consisting of DivX video and Vorbis -audio. However, a ’Vorbis I audio file’ is taken to imply Vorbis audio existing alone -within a degenerate Ogg stream. A compliant ’Vorbis audio player’ is not required to -implement Ogg support beyond the specific support of Vorbis within a degenrate Ogg -stream (naturally, application authors are encouraged to support full multiplexed Ogg -handling). -

    -

    A.1.2. MIME type
    -

    The MIME type of Ogg files depend on the context. Specifically, complex multimedia and -applications should use application/ogg, while visual media should use video/ogg, and audio -audio/ogg. Vorbis data encapsulated in Ogg may appear in any of those types. RTP -encapsulated Vorbis should use audio/vorbis + audio/vorbis-config. -

    -

    A.2. Encapsulation

    -

    Ogg encapsulation of a Vorbis packet stream is straightforward. -

      -
    • The first Vorbis packet (the identification header), which uniquely identifies a stream - as Vorbis audio, is placed alone in the first page of the logical Ogg stream. This - results in a first Ogg page of exactly 58 bytes at the very beginning of the logical - stream. -
    • -
    • This first page is marked ’beginning of stream’ in the page flags. -
    • -
    • The second and third vorbis packets (comment and setup headers) may span one or - more pages beginning on the second page of the logical stream. However many pages - they span, the third header packet finishes the page on which it ends. The next (first - audio) packet must begin on a fresh page. - - - -
    • -
    • The granule position of these first pages containing only headers is zero. -
    • -
    • The first audio packet of the logical stream begins a fresh Ogg page. -
    • -
    • Packets are placed into ogg pages in order until the end of stream. -
    • -
    • The last page is marked ’end of stream’ in the page flags. -
    • -
    • Vorbis packets may span page boundaries. -
    • -
    • The granule position of pages containing Vorbis audio is in units of PCM audio - samples (per channel; a stereo stream’s granule position does not increment at twice - the speed of a mono stream). -
    • -
    • The granule position of a page represents the end PCM sample position of the last - packet completed on that page. The ’last PCM sample’ is the last complete sample - returned by decode, not an internal sample awaiting lapping with a subsequent block. - A page that is entirely spanned by a single packet (that completes on a subsequent - page) has no granule position, and the granule position is set to ’-1’. -

      Note that the last decoded (fully lapped) PCM sample from a packet is not - necessarily the middle sample from that block. If, eg, the current Vorbis packet - encodes a ”long block” and the next Vorbis packet encodes a ”short block”, the last - decodable sample from the current packet be at position (3*long_block_length/4) - - (short_block_length/4). -

    • -
    • The granule (PCM) position of the first page need not indicate that the stream - started at position zero. Although the granule position belongs to the last completed - packet on the page and a valid granule position must be positive, by inference it may - indicate that the PCM position of the beginning of audio is positive or negative. -
        -
      • A positive starting value simply indicates that this stream begins at some - positive time offset, potentially within a larger program. This is a common case - when connecting to the middle of broadcast stream. -
      • -
      • A negative value indicates that output samples preceeding time zero should be - - - - discarded during decoding; this technique is used to allow sample-granularity - editing of the stream start time of already-encoded Vorbis streams. The number - of samples to be discarded must not exceed the overlap-add span of the first two - audio packets. -
      -

      In both of these cases in which the initial audio PCM starting offset is nonzero, the - second finished audio packet must flush the page on which it appears and the - third packet begin a fresh page. This allows the decoder to always be able to - perform PCM position adjustments before needing to return any PCM data from - synthesis, resulting in correct positioning information without any aditional seeking - logic. -

      Note: Failure to do so should, at worst, cause a decoder implementation to return - incorrect positioning information for seeking operations at the very beginning of the - stream. -

    • -
    • A granule position on the final page in a stream that indicates less audio data than the - final packet would normally return is used to end the stream on other than even frame - boundaries. The difference between the actual available data returned and the - declared amount indicates how many trailing samples to discard from the decoding - process. -
    - - - -

    B. Vorbis encapsulation in RTP

    -

    Please consult RFC 5215 “RTP Payload Format for Vorbis Encoded Audio” for description of -how to embed Vorbis audio in an RTP stream. - - - - - - -

    Colophon

    -

    PIC -

    Ogg is a Xiph.Org Foundation effort to protect essential tenets of Internet multimedia from -corporate hostage-taking; Open Source is the net’s greatest tool to keep everyone honest. See -About the Xiph.Org Foundation for details. -

    Ogg Vorbis is the first Ogg audio CODEC. Anyone may freely use and distribute the Ogg and -Vorbis specification, whether in a private, public or corporate capacity. However, the Xiph.Org -Foundation and the Ogg project (xiph.org) reserve the right to set the Ogg Vorbis specification -and certify specification compliance. -

    Xiph.Org’s Vorbis software CODEC implementation is distributed under a BSD-like license. This -does not restrict third parties from distributing independent implementations of Vorbis software -under other licenses. -

    Ogg, Vorbis, Xiph.Org Foundation and their logos are trademarks (tm) of the Xiph.Org -Foundation. These pages are copyright (C) 1994-2015 Xiph.Org Foundation. All rights -reserved. -

    This document is set using LATEX. - - - -

    References

    -

    -

    -

    - [1]   T. Sporer, K. Brandenburg and - B. Edler, The use of multirate filter banks for coding of high quality digital audio, - https://media.taricorp.net/eusipco_corrected.pdf. -

    -
    - - - - - - diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec.pdf b/Engine/lib/libvorbis/doc/Vorbis_I_spec.pdf deleted file mode 100644 index 165628fdf..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec.pdf and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec.tex b/Engine/lib/libvorbis/doc/Vorbis_I_spec.tex deleted file mode 100644 index 1213a25aa..000000000 --- a/Engine/lib/libvorbis/doc/Vorbis_I_spec.tex +++ /dev/null @@ -1,141 +0,0 @@ -\documentclass[12pt,paper=a4]{scrartcl} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Packages -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% ... -%\usepackage[margin=3cm]{geometry} -\usepackage{a4wide} - -% ... -\usepackage[english]{babel} - -%\usepackage[latin1]{inputenc} -%\usepackage[T1]{fontenc} - -% Do not indent paragraphs, instead separate them via vertical spacing -\usepackage{parskip} - -% Support for graphics, provides \includegraphics -\usepackage{graphicx} -%\graphicspath{{images/}} % Specify subdir containing the images - -% Hyperref enriches the generated PDF with clickable links, -% and provides many other useful features. -\usepackage{nameref} -\usepackage[colorlinks]{hyperref} -\def\sectionautorefname{Section} % Write section with capital 'S' -\def\subsectionautorefname{Subsection} % Write subsection with capital 'S' - - -% The fancyvrb package provides the "Verbatim" environment, which, -% unlike the built-in "verbatim", allows embedding TeX commands, as -% well as tons of other neat stuff (line numbers, formatting adjustments, ...) -\usepackage{fancyvrb} -\fvset{tabsize=4,fontsize=\scriptsize,numbers=left} - -% Normally, one can not use the underscore character in LaTeX without -% escaping it (\_ instead of _). Since the Vorbis specs use it a lot, -% we use the underscore package to change this default behavior. -\usepackage[nohyphen]{underscore} - -\usepackage{enumitem} - -% In LaTeX, pictures are normally put into floating environments, and it is -% left to the typesetting engine to place them in the "optimal" spot. These -% docs however expect pictures to be placed in a *specific* position. So we -% don't use \begin{figure}...\end{figure}, but rather a center environment. -% To still be able to use captions, we use the capt-of package. -\usepackage{capt-of} - -% strikeout support -\usepackage[normalem]{ulem} - -% blockquote support -\usepackage{csquotes} - -% allow 'special' characters in filenames, like undescore :-P -\usepackage{grffile} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Custom commands -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% Custom ref command, using hyperrefs autoref & nameref, to simulate the -% behavior of DocBook's ''. -\newcommand{\xref}[1]{\autoref{#1}, ``\nameref{#1}''} - -% Emulat DocBook's ''. -\newcommand{\link}[2]{\hyperref[#1]{#2}} - -% Simple 'Note' environment. Can be customized later on. -\newenvironment{note}{\subparagraph*{Note:}}{} - -% Map DocBook's to fancyvrb's Verbatim environment -\let\programlisting\Verbatim -\let\endprogramlisting\endVerbatim - -% Fake some more DocBook elements -\newcommand{\function}[1]{\texttt{#1}} -\newcommand{\filename}[1]{\texttt{#1}} -\newcommand{\varname}[1]{\texttt{#1}} -\newcommand{\literal}[1]{\texttt{#1}} - -% Redefine \~ to generate something that looks more appropriate when used in text. -\renewcommand{\~}{$\sim$} - -% Useful helper macro that inserts TODO comments very visibly into the generated -% file. Helps you to not forget to resolve those TODOs... :) -\newcommand{\TODO}[1]{\textcolor{red}{*** #1 ***}} - -% Configure graphics formats: Prefer PDF, fall back to PNG or JPG, as available. -\DeclareGraphicsExtensions{.pdf,.png,.jpg,.jpeg} - - -% NOTE: Things to watch out for: Some chars are reserved in LaTeX. You need to translate them... -% ~ -> $\sim$ (or \~ which we defined above) -% % -> \% -% & -> \& -% < -> $<$ -% > -> $>$ -% and others. Refer to any of the many LaTeX refs out there if in doubt! - -\begin{document} - - -\title{Vorbis I specification} -\author{Xiph.Org Foundation} -\maketitle - -\tableofcontents - -\include{01-introduction} -\include{02-bitpacking} -\include{03-codebook} -\include{04-codec} -\include{05-comment} -\include{06-floor0} -\include{07-floor1} -\include{08-residue} -\include{09-helper} -\include{10-tables} - -\appendix -\include{a1-encapsulation-ogg} -\include{a2-encapsulation-rtp} - -\include{footer} - - -% TODO: Use a bibliography, as in the example below? -\begin{thebibliography}{99} - -\bibitem{Sporer/Brandenburg/Edler} T.~Sporer, K.~Brandenburg and B.~Edler, -The use of multirate filter banks for coding of high quality digital audio, -\url{https://media.taricorp.net/eusipco_corrected.pdf}. - - -\end{thebibliography} - -\end{document} diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec0x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec0x.png deleted file mode 100644 index a6b90fa7f..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec0x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec10x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec10x.png deleted file mode 100644 index 571f324bd..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec10x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec11x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec11x.png deleted file mode 100644 index 50c3994fb..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec11x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec12x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec12x.png deleted file mode 100644 index 4dcbe6a9b..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec12x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec13x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec13x.png deleted file mode 100644 index dd80c1ed4..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec13x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec14x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec14x.png deleted file mode 100644 index 38cbbdb13..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec14x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec1x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec1x.png deleted file mode 100644 index 2e72115b7..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec1x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec2x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec2x.png deleted file mode 100644 index 334be846a..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec2x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec3x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec3x.png deleted file mode 100644 index a280384d4..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec3x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec4x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec4x.png deleted file mode 100644 index a79c2fe51..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec4x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec5x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec5x.png deleted file mode 100644 index 3c7ff1437..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec5x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec6x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec6x.png deleted file mode 100644 index 8d78a0065..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec6x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec7x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec7x.png deleted file mode 100644 index 67440ea38..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec7x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec8x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec8x.png deleted file mode 100644 index c7e58704d..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec8x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/Vorbis_I_spec9x.png b/Engine/lib/libvorbis/doc/Vorbis_I_spec9x.png deleted file mode 100644 index 38cbbdb13..000000000 Binary files a/Engine/lib/libvorbis/doc/Vorbis_I_spec9x.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/a1-encapsulation-ogg.tex b/Engine/lib/libvorbis/doc/a1-encapsulation-ogg.tex deleted file mode 100644 index 8bbd31bc5..000000000 --- a/Engine/lib/libvorbis/doc/a1-encapsulation-ogg.tex +++ /dev/null @@ -1,184 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Embedding Vorbis into an Ogg stream} \label{vorbis:over:ogg} - -\subsection{Overview} - -This document describes using Ogg logical and physical transport -streams to encapsulate Vorbis compressed audio packet data into file -form. - -The \xref{vorbis:spec:intro} provides an overview of the construction -of Vorbis audio packets. - -The \href{oggstream.html}{Ogg -bitstream overview} and \href{framing.html}{Ogg logical -bitstream and framing spec} provide detailed descriptions of Ogg -transport streams. This specification document assumes a working -knowledge of the concepts covered in these named backround -documents. Please read them first. - -\subsubsection{Restrictions} - -The Ogg/Vorbis I specification currently dictates that Ogg/Vorbis -streams use Ogg transport streams in degenerate, unmultiplexed -form only. That is: - -\begin{itemize} - \item - A meta-headerless Ogg file encapsulates the Vorbis I packets - - \item - The Ogg stream may be chained, i.e., contain multiple, contigous logical streams (links). - - \item - The Ogg stream must be unmultiplexed (only one stream, a Vorbis audio stream, per link) - -\end{itemize} - - -This is not to say that it is not currently possible to multiplex -Vorbis with other media types into a multi-stream Ogg file. At the -time this document was written, Ogg was becoming a popular container -for low-bitrate movies consisting of DivX video and Vorbis audio. -However, a 'Vorbis I audio file' is taken to imply Vorbis audio -existing alone within a degenerate Ogg stream. A compliant 'Vorbis -audio player' is not required to implement Ogg support beyond the -specific support of Vorbis within a degenrate Ogg stream (naturally, -application authors are encouraged to support full multiplexed Ogg -handling). - - - - -\subsubsection{MIME type} - -The MIME type of Ogg files depend on the context. Specifically, complex -multimedia and applications should use \literal{application/ogg}, -while visual media should use \literal{video/ogg}, and audio -\literal{audio/ogg}. Vorbis data encapsulated in Ogg may appear -in any of those types. RTP encapsulated Vorbis should use -\literal{audio/vorbis} + \literal{audio/vorbis-config}. - - -\subsection{Encapsulation} - -Ogg encapsulation of a Vorbis packet stream is straightforward. - -\begin{itemize} - -\item - The first Vorbis packet (the identification header), which - uniquely identifies a stream as Vorbis audio, is placed alone in the - first page of the logical Ogg stream. This results in a first Ogg - page of exactly 58 bytes at the very beginning of the logical stream. - - -\item - This first page is marked 'beginning of stream' in the page flags. - - -\item - The second and third vorbis packets (comment and setup - headers) may span one or more pages beginning on the second page of - the logical stream. However many pages they span, the third header - packet finishes the page on which it ends. The next (first audio) packet - must begin on a fresh page. - - -\item - The granule position of these first pages containing only headers is zero. - - -\item - The first audio packet of the logical stream begins a fresh Ogg page. - - -\item - Packets are placed into ogg pages in order until the end of stream. - - -\item - The last page is marked 'end of stream' in the page flags. - - -\item - Vorbis packets may span page boundaries. - - -\item - The granule position of pages containing Vorbis audio is in units - of PCM audio samples (per channel; a stereo stream's granule position - does not increment at twice the speed of a mono stream). - - -\item - The granule position of a page represents the end PCM sample - position of the last packet \emph{completed} on that - page. The 'last PCM sample' is the last complete sample returned by - decode, not an internal sample awaiting lapping with a - subsequent block. A page that is entirely spanned by a single - packet (that completes on a subsequent page) has no granule - position, and the granule position is set to '-1'. - - - Note that the last decoded (fully lapped) PCM sample from a packet - is not necessarily the middle sample from that block. If, eg, the - current Vorbis packet encodes a "long block" and the next Vorbis - packet encodes a "short block", the last decodable sample from the - current packet be at position (3*long\_block\_length/4) - - (short\_block\_length/4). - - -\item - The granule (PCM) position of the first page need not indicate - that the stream started at position zero. Although the granule - position belongs to the last completed packet on the page and a - valid granule position must be positive, by - inference it may indicate that the PCM position of the beginning - of audio is positive or negative. - - - \begin{itemize} - \item - A positive starting value simply indicates that this stream begins at - some positive time offset, potentially within a larger - program. This is a common case when connecting to the middle - of broadcast stream. - - \item - A negative value indicates that - output samples preceeding time zero should be discarded during - decoding; this technique is used to allow sample-granularity - editing of the stream start time of already-encoded Vorbis - streams. The number of samples to be discarded must not exceed - the overlap-add span of the first two audio packets. - - \end{itemize} - - - In both of these cases in which the initial audio PCM starting - offset is nonzero, the second finished audio packet must flush the - page on which it appears and the third packet begin a fresh page. - This allows the decoder to always be able to perform PCM position - adjustments before needing to return any PCM data from synthesis, - resulting in correct positioning information without any aditional - seeking logic. - - - \begin{note} - Failure to do so should, at worst, cause a - decoder implementation to return incorrect positioning information - for seeking operations at the very beginning of the stream. - \end{note} - - -\item - A granule position on the final page in a stream that indicates - less audio data than the final packet would normally return is used to - end the stream on other than even frame boundaries. The difference - between the actual available data returned and the declared amount - indicates how many trailing samples to discard from the decoding - process. - -\end{itemize} diff --git a/Engine/lib/libvorbis/doc/a2-encapsulation-rtp.tex b/Engine/lib/libvorbis/doc/a2-encapsulation-rtp.tex deleted file mode 100644 index 35a93c6f9..000000000 --- a/Engine/lib/libvorbis/doc/a2-encapsulation-rtp.tex +++ /dev/null @@ -1,8 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section{Vorbis encapsulation in RTP} \label{vorbis:over:rtp} - -% TODO: Include draft-rtp.xml somehow? - -Please consult RFC 5215 \textit{``RTP Payload Format for Vorbis Encoded - Audio''} for description of how to embed Vorbis audio in an RTP stream. diff --git a/Engine/lib/libvorbis/doc/components.png b/Engine/lib/libvorbis/doc/components.png deleted file mode 100644 index 0c4e75c6e..000000000 Binary files a/Engine/lib/libvorbis/doc/components.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/eightphase.png b/Engine/lib/libvorbis/doc/eightphase.png deleted file mode 100644 index 8272e4482..000000000 Binary files a/Engine/lib/libvorbis/doc/eightphase.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/fish_xiph_org.png b/Engine/lib/libvorbis/doc/fish_xiph_org.png deleted file mode 100644 index dc64a038f..000000000 Binary files a/Engine/lib/libvorbis/doc/fish_xiph_org.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/floor1-1.png b/Engine/lib/libvorbis/doc/floor1-1.png deleted file mode 100644 index bd7faba66..000000000 Binary files a/Engine/lib/libvorbis/doc/floor1-1.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/floor1-2.png b/Engine/lib/libvorbis/doc/floor1-2.png deleted file mode 100644 index 46f0ac230..000000000 Binary files a/Engine/lib/libvorbis/doc/floor1-2.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/floor1-3.png b/Engine/lib/libvorbis/doc/floor1-3.png deleted file mode 100644 index 4d03c6a1b..000000000 Binary files a/Engine/lib/libvorbis/doc/floor1-3.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/floor1-4.png b/Engine/lib/libvorbis/doc/floor1-4.png deleted file mode 100644 index f96e77dd7..000000000 Binary files a/Engine/lib/libvorbis/doc/floor1-4.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/floor1_inverse_dB_table.html b/Engine/lib/libvorbis/doc/floor1_inverse_dB_table.html deleted file mode 100644 index 88412500f..000000000 --- a/Engine/lib/libvorbis/doc/floor1_inverse_dB_table.html +++ /dev/null @@ -1,154 +0,0 @@ - - - - - -Ogg Vorbis Documentation - - - - - - - - - -

    Ogg Vorbis I format specification: floor1_inverse_dB_table

    - -

    The vector [floor1_inverse_dB_table] is a 256 element static -lookup table consiting of the following values (read left to right -then top to bottom):

    - -
    -  1.0649863e-07, 1.1341951e-07, 1.2079015e-07, 1.2863978e-07, 
    -  1.3699951e-07, 1.4590251e-07, 1.5538408e-07, 1.6548181e-07, 
    -  1.7623575e-07, 1.8768855e-07, 1.9988561e-07, 2.1287530e-07, 
    -  2.2670913e-07, 2.4144197e-07, 2.5713223e-07, 2.7384213e-07, 
    -  2.9163793e-07, 3.1059021e-07, 3.3077411e-07, 3.5226968e-07, 
    -  3.7516214e-07, 3.9954229e-07, 4.2550680e-07, 4.5315863e-07, 
    -  4.8260743e-07, 5.1396998e-07, 5.4737065e-07, 5.8294187e-07, 
    -  6.2082472e-07, 6.6116941e-07, 7.0413592e-07, 7.4989464e-07, 
    -  7.9862701e-07, 8.5052630e-07, 9.0579828e-07, 9.6466216e-07, 
    -  1.0273513e-06, 1.0941144e-06, 1.1652161e-06, 1.2409384e-06, 
    -  1.3215816e-06, 1.4074654e-06, 1.4989305e-06, 1.5963394e-06, 
    -  1.7000785e-06, 1.8105592e-06, 1.9282195e-06, 2.0535261e-06, 
    -  2.1869758e-06, 2.3290978e-06, 2.4804557e-06, 2.6416497e-06, 
    -  2.8133190e-06, 2.9961443e-06, 3.1908506e-06, 3.3982101e-06, 
    -  3.6190449e-06, 3.8542308e-06, 4.1047004e-06, 4.3714470e-06, 
    -  4.6555282e-06, 4.9580707e-06, 5.2802740e-06, 5.6234160e-06, 
    -  5.9888572e-06, 6.3780469e-06, 6.7925283e-06, 7.2339451e-06, 
    -  7.7040476e-06, 8.2047000e-06, 8.7378876e-06, 9.3057248e-06, 
    -  9.9104632e-06, 1.0554501e-05, 1.1240392e-05, 1.1970856e-05, 
    -  1.2748789e-05, 1.3577278e-05, 1.4459606e-05, 1.5399272e-05, 
    -  1.6400004e-05, 1.7465768e-05, 1.8600792e-05, 1.9809576e-05, 
    -  2.1096914e-05, 2.2467911e-05, 2.3928002e-05, 2.5482978e-05, 
    -  2.7139006e-05, 2.8902651e-05, 3.0780908e-05, 3.2781225e-05, 
    -  3.4911534e-05, 3.7180282e-05, 3.9596466e-05, 4.2169667e-05, 
    -  4.4910090e-05, 4.7828601e-05, 5.0936773e-05, 5.4246931e-05, 
    -  5.7772202e-05, 6.1526565e-05, 6.5524908e-05, 6.9783085e-05, 
    -  7.4317983e-05, 7.9147585e-05, 8.4291040e-05, 8.9768747e-05, 
    -  9.5602426e-05, 0.00010181521, 0.00010843174, 0.00011547824, 
    -  0.00012298267, 0.00013097477, 0.00013948625, 0.00014855085, 
    -  0.00015820453, 0.00016848555, 0.00017943469, 0.00019109536, 
    -  0.00020351382, 0.00021673929, 0.00023082423, 0.00024582449, 
    -  0.00026179955, 0.00027881276, 0.00029693158, 0.00031622787, 
    -  0.00033677814, 0.00035866388, 0.00038197188, 0.00040679456, 
    -  0.00043323036, 0.00046138411, 0.00049136745, 0.00052329927, 
    -  0.00055730621, 0.00059352311, 0.00063209358, 0.00067317058, 
    -  0.00071691700, 0.00076350630, 0.00081312324, 0.00086596457, 
    -  0.00092223983, 0.00098217216, 0.0010459992,  0.0011139742, 
    -  0.0011863665,  0.0012634633,  0.0013455702,  0.0014330129, 
    -  0.0015261382,  0.0016253153,  0.0017309374,  0.0018434235, 
    -  0.0019632195,  0.0020908006,  0.0022266726,  0.0023713743, 
    -  0.0025254795,  0.0026895994,  0.0028643847,  0.0030505286, 
    -  0.0032487691,  0.0034598925,  0.0036847358,  0.0039241906, 
    -  0.0041792066,  0.0044507950,  0.0047400328,  0.0050480668, 
    -  0.0053761186,  0.0057254891,  0.0060975636,  0.0064938176, 
    -  0.0069158225,  0.0073652516,  0.0078438871,  0.0083536271, 
    -  0.0088964928,  0.009474637,   0.010090352,   0.010746080, 
    -  0.011444421,   0.012188144,   0.012980198,   0.013823725, 
    -  0.014722068,   0.015678791,   0.016697687,   0.017782797, 
    -  0.018938423,   0.020169149,   0.021479854,   0.022875735, 
    -  0.024362330,   0.025945531,   0.027631618,   0.029427276, 
    -  0.031339626,   0.033376252,   0.035545228,   0.037855157, 
    -  0.040315199,   0.042935108,   0.045725273,   0.048696758, 
    -  0.051861348,   0.055231591,   0.058820850,   0.062643361, 
    -  0.066714279,   0.071049749,   0.075666962,   0.080584227, 
    -  0.085821044,   0.091398179,   0.097337747,   0.10366330, 
    -  0.11039993,    0.11757434,    0.12521498,    0.13335215, 
    -  0.14201813,    0.15124727,    0.16107617,    0.17154380, 
    -  0.18269168,    0.19456402,    0.20720788,    0.22067342, 
    -  0.23501402,    0.25028656,    0.26655159,    0.28387361, 
    -  0.30232132,    0.32196786,    0.34289114,    0.36517414, 
    -  0.38890521,    0.41417847,    0.44109412,    0.46975890, 
    -  0.50028648,    0.53279791,    0.56742212,    0.60429640, 
    -  0.64356699,    0.68538959,    0.72993007,    0.77736504, 
    -  0.82788260,    0.88168307,    0.9389798,     1.
    -
    - - - - - diff --git a/Engine/lib/libvorbis/doc/floorval.png b/Engine/lib/libvorbis/doc/floorval.png deleted file mode 100644 index 49d6ec190..000000000 Binary files a/Engine/lib/libvorbis/doc/floorval.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/footer.tex b/Engine/lib/libvorbis/doc/footer.tex deleted file mode 100644 index bb5e590c8..000000000 --- a/Engine/lib/libvorbis/doc/footer.tex +++ /dev/null @@ -1,31 +0,0 @@ -% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*- -%!TEX root = Vorbis_I_spec.tex -\section*{Colophon} - -\includegraphics[width=5cm]{fish_xiph_org} -\label{footer} - -Ogg is a \href{https://xiph.org/}{Xiph.Org Foundation} effort -to protect essential tenets of Internet multimedia from corporate -hostage-taking; Open Source is the net's greatest tool to keep -everyone honest. See \href{https://xiph.org/about/}{About -the Xiph.Org Foundation} for details. - - -Ogg Vorbis is the first Ogg audio CODEC. Anyone may freely use and -distribute the Ogg and Vorbis specification, whether in a private, -public or corporate capacity. However, the Xiph.Org Foundation and -the Ogg project (xiph.org) reserve the right to set the Ogg Vorbis -specification and certify specification compliance. - -Xiph.Org's Vorbis software CODEC implementation is distributed under a -BSD-like license. This does not restrict third parties from -distributing independent implementations of Vorbis software under -other licenses. - -Ogg, Vorbis, Xiph.Org Foundation and their logos are trademarks (tm) -of the \href{https://xiph.org/}{Xiph.Org Foundation}. These -pages are copyright (C) 1994-2015 Xiph.Org Foundation. All rights -reserved. - -This document is set using \LaTeX. diff --git a/Engine/lib/libvorbis/doc/fourphase.png b/Engine/lib/libvorbis/doc/fourphase.png deleted file mode 100644 index a86e128d2..000000000 Binary files a/Engine/lib/libvorbis/doc/fourphase.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/framing.html b/Engine/lib/libvorbis/doc/framing.html deleted file mode 100644 index b362d6cac..000000000 --- a/Engine/lib/libvorbis/doc/framing.html +++ /dev/null @@ -1,430 +0,0 @@ - - - - - -Ogg Vorbis Documentation - - - - - - - - - -

    Ogg logical bitstream framing

    - -

    Ogg bitstreams

    - -

    The Ogg transport bitstream is designed to provide framing, error -protection and seeking structure for higher-level codec streams that -consist of raw, unencapsulated data packets, such as the Vorbis audio -codec or Theora video codec.

    - -

    Application example: Vorbis

    - -

    Vorbis encodes short-time blocks of PCM data into raw packets of -bit-packed data. These raw packets may be used directly by transport -mechanisms that provide their own framing and packet-separation -mechanisms (such as UDP datagrams). For stream based storage (such as -files) and transport (such as TCP streams or pipes), Vorbis uses the -Ogg bitstream format to provide framing/sync, sync recapture -after error, landmarks during seeking, and enough information to -properly separate data back into packets at the original packet -boundaries without relying on decoding to find packet boundaries.

    - -

    Design constraints for Ogg bitstreams

    - -
      -
    1. True streaming; we must not need to seek to build a 100% - complete bitstream.
    2. -
    3. Use no more than approximately 1-2% of bitstream bandwidth for - packet boundary marking, high-level framing, sync and seeking.
    4. -
    5. Specification of absolute position within the original sample - stream.
    6. -
    7. Simple mechanism to ease limited editing, such as a simplified - concatenation mechanism.
    8. -
    9. Detection of corruption, recapture after error and direct, random - access to data at arbitrary positions in the bitstream.
    10. -
    - -

    Logical and Physical Bitstreams

    - -

    A logical Ogg bitstream is a contiguous stream of -sequential pages belonging only to the logical bitstream. A -physical Ogg bitstream is constructed from one or more -than one logical Ogg bitstream (the simplest physical bitstream -is simply a single logical bitstream). We describe below the exact -formatting of an Ogg logical bitstream. Combining logical -bitstreams into more complex physical bitstreams is described in the -Ogg bitstream overview. The exact -mapping of raw Vorbis packets into a valid Ogg Vorbis physical -bitstream is described in the Vorbis I Specification.

    - -

    Bitstream structure

    - -

    An Ogg stream is structured by dividing incoming packets into -segments of up to 255 bytes and then wrapping a group of contiguous -packet segments into a variable length page preceded by a page -header. Both the header size and page size are variable; the page -header contains sizing information and checksum data to determine -header/page size and data integrity.

    - -

    The bitstream is captured (or recaptured) by looking for the beginning -of a page, specifically the capture pattern. Once the capture pattern -is found, the decoder verifies page sync and integrity by computing -and comparing the checksum. At that point, the decoder can extract the -packets themselves.

    - -

    Packet segmentation

    - -

    Packets are logically divided into multiple segments before encoding -into a page. Note that the segmentation and fragmentation process is a -logical one; it's used to compute page header values and the original -page data need not be disturbed, even when a packet spans page -boundaries.

    - -

    The raw packet is logically divided into [n] 255 byte segments and a -last fractional segment of < 255 bytes. A packet size may well -consist only of the trailing fractional segment, and a fractional -segment may be zero length. These values, called "lacing values" are -then saved and placed into the header segment table.

    - -

    An example should make the basic concept clear:

    - -
    -
    -raw packet:
    -  ___________________________________________
    - |______________packet data__________________| 753 bytes
    -
    -lacing values for page header segment table: 255,255,243
    -
    -
    - -

    We simply add the lacing values for the total size; the last lacing -value for a packet is always the value that is less than 255. Note -that this encoding both avoids imposing a maximum packet size as well -as imposing minimum overhead on small packets (as opposed to, eg, -simply using two bytes at the head of every packet and having a max -packet size of 32k. Small packets (<255, the typical case) are -penalized with twice the segmentation overhead). Using the lacing -values as suggested, small packets see the minimum possible -byte-aligned overheade (1 byte) and large packets, over 512 bytes or -so, see a fairly constant ~.5% overhead on encoding space.

    - -

    Note that a lacing value of 255 implies that a second lacing value -follows in the packet, and a value of < 255 marks the end of the -packet after that many additional bytes. A packet of 255 bytes (or a -multiple of 255 bytes) is terminated by a lacing value of 0:

    - -
    
    -raw packet:
    -  _______________________________
    - |________packet data____________|          255 bytes
    -
    -lacing values: 255, 0
    -
    - -

    Note also that a 'nil' (zero length) packet is not an error; it -consists of nothing more than a lacing value of zero in the header.

    - -

    Packets spanning pages

    - -

    Packets are not restricted to beginning and ending within a page, -although individual segments are, by definition, required to do so. -Packets are not restricted to a maximum size, although excessively -large packets in the data stream are discouraged; the Ogg -bitstream specification strongly recommends nominal page size of -approximately 4-8kB (large packets are foreseen as being useful for -initialization data at the beginning of a logical bitstream).

    - -

    After segmenting a packet, the encoder may decide not to place all the -resulting segments into the current page; to do so, the encoder places -the lacing values of the segments it wishes to belong to the current -page into the current segment table, then finishes the page. The next -page is begun with the first value in the segment table belonging to -the next packet segment, thus continuing the packet (data in the -packet body must also correspond properly to the lacing values in the -spanned pages. The segment data in the first packet corresponding to -the lacing values of the first page belong in that page; packet -segments listed in the segment table of the following page must begin -the page body of the subsequent page).

    - -

    The last mechanic to spanning a page boundary is to set the header -flag in the new page to indicate that the first lacing value in the -segment table continues rather than begins a packet; a header flag of -0x01 is set to indicate a continued packet. Although mandatory, it -is not actually algorithmically necessary; one could inspect the -preceding segment table to determine if the packet is new or -continued. Adding the information to the packet_header flag allows a -simpler design (with no overhead) that needs only inspect the current -page header after frame capture. This also allows faster error -recovery in the event that the packet originates in a corrupt -preceding page, implying that the previous page's segment table -cannot be trusted.

    - -

    Note that a packet can span an arbitrary number of pages; the above -spanning process is repeated for each spanned page boundary. Also a -'zero termination' on a packet size that is an even multiple of 255 -must appear even if the lacing value appears in the next page as a -zero-length continuation of the current packet. The header flag -should be set to 0x01 to indicate that the packet spanned, even though -the span is a nil case as far as data is concerned.

    - -

    The encoding looks odd, but is properly optimized for speed and the -expected case of the majority of packets being between 50 and 200 -bytes (note that it is designed such that packets of wildly different -sizes can be handled within the model; placing packet size -restrictions on the encoder would have only slightly simplified design -in page generation and increased overall encoder complexity).

    - -

    The main point behind tracking individual packets (and packet -segments) is to allow more flexible encoding tricks that requiring -explicit knowledge of packet size. An example is simple bandwidth -limiting, implemented by simply truncating packets in the nominal case -if the packet is arranged so that the least sensitive portion of the -data comes last.

    - -

    Page header

    - -

    The headering mechanism is designed to avoid copying and re-assembly -of the packet data (ie, making the packet segmentation process a -logical one); the header can be generated directly from incoming -packet data. The encoder buffers packet data until it finishes a -complete page at which point it writes the header followed by the -buffered packet segments.

    - -

    capture_pattern

    - -

    A header begins with a capture pattern that simplifies identifying -pages; once the decoder has found the capture pattern it can do a more -intensive job of verifying that it has in fact found a page boundary -(as opposed to an inadvertent coincidence in the byte stream).

    - -
    
    - byte value
    -
    -  0  0x4f 'O'
    -  1  0x67 'g'
    -  2  0x67 'g'
    -  3  0x53 'S'  
    -
    - -

    stream_structure_version

    - -

    The capture pattern is followed by the stream structure revision:

    - -
    
    - byte value
    -
    -  4  0x00
    -
    - -

    header_type_flag

    - -

    The header type flag identifies this page's context in the bitstream:

    - -
    
    - byte value
    -
    -  5  bitflags: 0x01: unset = fresh packet
    -	               set = continued packet
    -	       0x02: unset = not first page of logical bitstream
    -                       set = first page of logical bitstream (bos)
    -	       0x04: unset = not last page of logical bitstream
    -                       set = last page of logical bitstream (eos)
    -
    - -

    absolute granule position

    - -

    (This is packed in the same way the rest of Ogg data is packed; LSb -of LSB first. Note that the 'position' data specifies a 'sample' -number (eg, in a CD quality sample is four octets, 16 bits for left -and 16 bits for right; in video it would likely be the frame number. -It is up to the specific codec in use to define the semantic meaning -of the granule position value). The position specified is the total -samples encoded after including all packets finished on this page -(packets begun on this page but continuing on to the next page do not -count). The rationale here is that the position specified in the -frame header of the last page tells how long the data coded by the -bitstream is. A truncated stream will still return the proper number -of samples that can be decoded fully.

    - -

    A special value of '-1' (in two's complement) indicates that no packets -finish on this page.

    - -
    
    - byte value
    -
    -  6  0xXX LSB
    -  7  0xXX
    -  8  0xXX
    -  9  0xXX
    - 10  0xXX
    - 11  0xXX
    - 12  0xXX
    - 13  0xXX MSB
    -
    - -

    stream serial number

    - -

    Ogg allows for separate logical bitstreams to be mixed at page -granularity in a physical bitstream. The most common case would be -sequential arrangement, but it is possible to interleave pages for -two separate bitstreams to be decoded concurrently. The serial -number is the means by which pages physical pages are associated with -a particular logical stream. Each logical stream must have a unique -serial number within a physical stream:

    - -
    
    - byte value
    -
    - 14  0xXX LSB
    - 15  0xXX
    - 16  0xXX
    - 17  0xXX MSB
    -
    - -

    page sequence no

    - -

    Page counter; lets us know if a page is lost (useful where packets -span page boundaries).

    - -
    
    - byte value
    -
    - 18  0xXX LSB
    - 19  0xXX
    - 20  0xXX
    - 21  0xXX MSB
    -
    - -

    page checksum

    - -

    32 bit CRC value (direct algorithm, initial val and final XOR = 0, -generator polynomial=0x04c11db7). The value is computed over the -entire header (with the CRC field in the header set to zero) and then -continued over the page. The CRC field is then filled with the -computed value.

    - -

    (A thorough discussion of CRC algorithms can be found in -"A Painless Guide to CRC Error Detection Algorithms" -by Ross Williams.)

    - -
    
    - byte value
    -
    - 22  0xXX LSB
    - 23  0xXX
    - 24  0xXX
    - 25  0xXX MSB
    -
    - -

    page_segments

    - -

    The number of segment entries to appear in the segment table. The -maximum number of 255 segments (255 bytes each) sets the maximum -possible physical page size at 65307 bytes or just under 64kB (thus -we know that a header corrupted so as destroy sizing/alignment -information will not cause a runaway bitstream. We'll read in the -page according to the corrupted size information that's guaranteed to -be a reasonable size regardless, notice the checksum mismatch, drop -sync and then look for recapture).

    - -
    
    - byte value
    -
    - 26 0x00-0xff (0-255)
    -
    - -

    segment_table (containing packet lacing values)

    - -

    The lacing values for each packet segment physically appearing in -this page are listed in contiguous order.

    - -
    
    - byte value
    -
    - 27 0x00-0xff (0-255)
    - [...]
    - n  0x00-0xff (0-255, n=page_segments+26)
    -
    - -

    Total page size is calculated directly from the known header size and -lacing values in the segment table. Packet data segments follow -immediately after the header.

    - -

    Page headers typically impose a flat .25-.5% space overhead assuming -nominal ~8k page sizes. The segmentation table needed for exact -packet recovery in the streaming layer adds approximately .5-1% -nominal assuming expected encoder behavior in the 44.1kHz, 128kbps -stereo encodings.

    - - - - - diff --git a/Engine/lib/libvorbis/doc/helper.html b/Engine/lib/libvorbis/doc/helper.html deleted file mode 100644 index 5da77653e..000000000 --- a/Engine/lib/libvorbis/doc/helper.html +++ /dev/null @@ -1,239 +0,0 @@ - - - - - -Ogg Vorbis Documentation - - - - - - - - - -

    Ogg Vorbis I format specification: helper equations

    - -

    Overview

    - -

    The equations below are used in multiple places by the Vorbis codec -specification. Rather than cluttering up the main specification -documents, they are defined here and linked in the main documents -where appropriate.

    - -

    ilog

    - -

    The "ilog(x)" function returns the position number (1 through n) of the -highest set bit in the two's complement integer value -[x]. Values of [x] less than zero are defined to return zero.

    - -
    -  1) [return_value] = 0;
    -  2) if ( [x] is greater than zero ){
    -      
    -       3) increment [return_value];
    -       4) logical shift [x] one bit to the right, padding the MSb with zero
    -       5) repeat at step 2)
    -
    -     }
    -
    -   6) done
    -
    - -

    Examples:

    - -
      -
    • ilog(0) = 0;
    • -
    • ilog(1) = 1;
    • -
    • ilog(2) = 2;
    • -
    • ilog(3) = 2;
    • -
    • ilog(4) = 3;
    • -
    • ilog(7) = 3;
    • -
    • ilog(negative number) = 0;
    • -
    - -

    float32_unpack

    - -

    "float32_unpack(x)" is intended to translate the packed binary -representation of a Vorbis codebook float value into the -representation used by the decoder for floating point numbers. For -purposes of this example, we will unpack a Vorbis float32 into a -host-native floating point number.

    - -
    -  1) [mantissa] = [x] bitwise AND 0x1fffff (unsigned result)
    -  2) [sign] = [x] bitwise AND 0x80000000 (unsigned result)
    -  3) [exponent] = ( [x] bitwise AND 0x7fe00000) shifted right 21 bits (unsigned result)
    -  4) if ( [sign] is nonzero ) then negate [mantissa]
    -  5) return [mantissa] * ( 2 ^ ( [exponent] - 788 ) )
    -
    - -

    lookup1_values

    - -

    "lookup1_values(codebook_entries,codebook_dimensions)" is used to -compute the correct length of the value index for a codebook VQ lookup -table of lookup type 1. The values on this list are permuted to -construct the VQ vector lookup table of size -[codebook_entries].

    - -

    The return value for this function is defined to be 'the greatest -integer value for which [return_value] to the power of -[codebook_dimensions] is less than or equal to -[codebook_entries]'.

    - -

    low_neighbor

    - -

    "low_neighbor(v,x)" finds the position n in vector [v] of -the greatest value scalar element for which n is less than -[x] and vector [v] element n is less -than vector [v] element [x].

    - -

    high_neighbor

    - -

    "high_neighbor(v,x)" finds the position n in vector [v] of -the lowest value scalar element for which n is less than -[x] and vector [v] element n is greater -than vector [v] element [x].

    - -

    render_point

    - -

    "render_point(x0,y0,x1,y1,X)" is used to find the Y value at point X -along the line specified by x0, x1, y0 and y1. This function uses an -integer algorithm to solve for the point directly without calculating -intervening values along the line.

    - -
    -  1)  [dy] = [y1] - [y0]
    -  2) [adx] = [x1] - [x0]
    -  3) [ady] = absolute value of [dy]
    -  4) [err] = [ady] * ([X] - [x0])
    -  5) [off] = [err] / [adx] using integer division
    -  6) if ( [dy] is less than zero ) {
    -
    -       7) [Y] = [y0] - [off]
    -
    -     } else {
    -
    -       8) [Y] = [y0] + [off]
    -  
    -     }
    -
    -  9) done
    -
    - -

    render_line

    - -

    Floor decode type one uses the integer line drawing algorithm of -"render_line(x0, y0, x1, y1, v)" to construct an integer floor -curve for contiguous piecewise line segments. Note that it has not -been relevant elsewhere, but here we must define integer division as -rounding division of both positive and negative numbers toward zero.

    - -
    -  1)   [dy] = [y1] - [y0]
    -  2)  [adx] = [x1] - [x0]
    -  3)  [ady] = absolute value of [dy]
    -  4) [base] = [dy] / [adx] using integer division
    -  5)    [x] = [x0]
    -  6)    [y] = [y0]
    -  7)  [err] = 0
    -
    -  8) if ( [dy] is less than 0 ) {
    -
    -        9) [sy] = [base] - 1
    -
    -     } else {
    -
    -       10) [sy] = [base] + 1
    -
    -     }
    -
    - 11) [ady] = [ady] - (absolute value of [base]) * [adx]
    - 12) vector [v] element [x] = [y]
    -
    - 13) iterate [x] over the range [x0]+1 ... [x1]-1 {
    -
    -       14) [err] = [err] + [ady];
    -       15) if ( [err] >= [adx] ) {
    -
    -             15) [err] = [err] - [adx]
    -             16)   [y] = [y] + [sy]
    -
    -           } else {
    -
    -             17) [y] = [y] + [base]
    -   
    -           }
    -
    -       18) vector [v] element [x] = [y]
    -
    -     }
    -
    - - - - - diff --git a/Engine/lib/libvorbis/doc/hufftree-under.png b/Engine/lib/libvorbis/doc/hufftree-under.png deleted file mode 100644 index be6e8d6bb..000000000 Binary files a/Engine/lib/libvorbis/doc/hufftree-under.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/hufftree.png b/Engine/lib/libvorbis/doc/hufftree.png deleted file mode 100644 index f4dc53742..000000000 Binary files a/Engine/lib/libvorbis/doc/hufftree.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/index.html b/Engine/lib/libvorbis/doc/index.html deleted file mode 100644 index 5c260ceab..000000000 --- a/Engine/lib/libvorbis/doc/index.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - -Ogg Vorbis Documentation - - - - - - - - - -

    Ogg Vorbis Documentation

    - -

    Vorbis technical discussion documents

    - - -

    Ogg Vorbis I specification

    - - - -

    Ogg Vorbis programming documents

    - - - -

    Ogg bitstream documentation

    - - - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/Makefile.am b/Engine/lib/libvorbis/doc/libvorbis/Makefile.am deleted file mode 100644 index 0bcc135b7..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -## Process this file with automake to produce Makefile.in - -docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION)/libvorbis - -doc_DATA = index.html reference.html style.css vorbis_comment.html\ - vorbis_info.html vorbis_analysis_blockout.html vorbis_analysis_buffer.html\ - vorbis_analysis_headerout.html vorbis_analysis_init.html \ - vorbis_analysis_wrote.html vorbis_analysis.html vorbis_bitrate_addblock.html\ - vorbis_bitrate_flushpacket.html vorbis_block_init.html \ - vorbis_block_clear.html vorbis_dsp_clear.html vorbis_granule_time.html \ - vorbis_version_string.html vorbis_info_blocksize.html vorbis_info_clear.html\ - vorbis_info_init.html vorbis_comment_add.html vorbis_comment_add_tag.html\ - vorbis_comment_clear.html vorbis_comment_init.html vorbis_comment_query.html\ - vorbis_comment_query_count.html vorbis_commentheader_out.html\ - vorbis_packet_blocksize.html vorbis_synthesis.html \ - vorbis_synthesis_blockin.html vorbis_synthesis_halfrate.html \ - vorbis_synthesis_halfrate_p.html vorbis_synthesis_headerin.html \ - vorbis_synthesis_idheader.html vorbis_synthesis_init.html \ - vorbis_synthesis_lapout.html vorbis_synthesis_pcmout.html \ - vorbis_synthesis_read.html vorbis_synthesis_restart.html \ - vorbis_synthesis_trackonly.html vorbis_block.html vorbis_dsp_state.html \ - return.html overview.html - -EXTRA_DIST = $(doc_DATA) diff --git a/Engine/lib/libvorbis/doc/libvorbis/index.html b/Engine/lib/libvorbis/doc/libvorbis/index.html deleted file mode 100644 index 7d87cc4dc..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/index.html +++ /dev/null @@ -1,44 +0,0 @@ - - - -libvorbis - Documentation - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    Libvorbis Documentation

    - -

    -Libvorbis contains the Vorbis reference encoder and decoder. -

    -This is the lowest-level interface to the Vorbis encoder and decoder. If -you're just looking for a simple way to extract the -audio from an Ogg Vorbis file, you probably want to use vorbisfile rather than using libogg -and libvorbis directly. -

    -Libvorbis API overview
    -Libvorbis API reference
    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/overview.html b/Engine/lib/libvorbis/doc/libvorbis/overview.html deleted file mode 100644 index 574db7457..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/overview.html +++ /dev/null @@ -1,136 +0,0 @@ - - - -libvorbis - API Overview - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    Libvorbis API Overview

    - -

    Libvorbis is the reference implementation of the Vorbis codec. It is -the lowest-level interface to the Vorbis encoder and decoder, working -with packets directly.

    - -

    All libvorbis routines and structures are declared in "vorbis/codec.h".

    - -

    Encoding workflow

    - -
      -
    1. Initialize a vorbis_info structure -by calling vorbis_info_init and -then functions from libvorbisenc -on it.
    2. -
    3. Initialize a vorbis_dsp_state -for encoding based on the parameters in the vorbis_info by using vorbis_analysis_init.
    4. -
    5. Initialize a vorbis_comment -structure using vorbis_comment_init, -populate it with any comments you wish to store in the stream, and call -vorbis_analysis_headerout to -get the three Vorbis stream header packets. Output the packets.
    6. -
    7. Initialize a vorbis_block structure -using vorbis_block_init.
    8. -
    9. While there is more audio to encode:
        -
      1. Submit a chunk of audio data using vorbis_analysis_buffer and vorbis_analysis_wrote.
      2. -
      3. Obtain all available blocks using vorbis_analysis_blockout -in a loop. For each block obtained:
          -
        1. Encode the block into a packet (or prepare it for bitrate management) -using vorbis_analysis. (It's a good -idea to always pass the blocks through the bitrate -management mechanism; more information is on the vorbis_analysis page. It does not affect -the resulting packets unless you are actually using a bitrate-managed -mode.)
        2. -
        3. If you are using bitrate management, submit the block using vorbis_bitrate_addblock and obtain -packets using vorbis_bitrate_flushpacket.
        4. -
        5. Output any obtained packets.
        6. -
      4. -
    10. -
    11. Submit an empty buffer to indicate the end of input; this will result -in an end-of-stream packet after all encoding steps are done to it.
    12. -
    13. Destroy the structures using the appropriate vorbis_*_clear routines.
    14. -
    - -

    Decoding workflow

    - -Note: if you do not need to do anything more involved than just -decoding the audio from an Ogg Vorbis file, you can use the far simpler -libvorbisfile interface, which -will take care of all of the demuxing and low-level decoding operations -(and even the I/O, if you want) for you. - -
      -
    1. When reading the header packets of an Ogg stream, you can use vorbis_synthesis_idheader to -check whether a stream might be Vorbis.
    2. -
    3. Initialize a vorbis_info and a vorbis_comment structure using the -appropriate vorbis_*_init routines, then pass the first three packets -from the stream (the Vorbis stream header packets) to vorbis_synthesis_headerin in -order. At this point, you can see the comments and basic parameters of -the Vorbis stream.
    4. -
    5. Initialize a vorbis_dsp_state -for decoding based on the parameters in the vorbis_info by using vorbis_synthesis_init.
    6. -
    7. Initialize a vorbis_block structure -using vorbis_block_init.
    8. -
    9. While there are more packets to decode:
        -
      1. Decode the next packet into a block using vorbis_synthesis.
      2. -
      3. Submit the block to the reassembly layer using vorbis_synthesis_blockin.
      4. -
      5. Obtain some decoded audio using vorbis_synthesis_pcmout and vorbis_synthesis_read. Any audio data -returned but not marked as consumed using vorbis_synthesis_read carries -over to the next call to vorbis_synthesis_pcmout.
      6. -
    10. -
    11. Destroy the structures using the appropriate vorbis_*_clear routines.
    12. -
    - -

    Metadata workflow

    - -Note: if you do not need to do anything more involved than just -reading the metadata from an Ogg Vorbis file, libvorbisfile can do this for you. - -
      -
    1. Follow the decoding workflow above until you have access to the comments -and basic parameters of the Vorbis stream.
    2. -
    3. If you want to alter the comments, copy the first packet to the output -file, then create a packet for the modified comments using vorbis_commentheader_out and output -it, then copy the third packet and all subsequent packets into the output -file.
    4. -
    - -

    -
    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/reference.html b/Engine/lib/libvorbis/doc/libvorbis/reference.html deleted file mode 100644 index 7c254c7db..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/reference.html +++ /dev/null @@ -1,86 +0,0 @@ - - - -Libvorbis API Reference - - - - - - - - - -

    Libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    Libvorbis API Reference

    - -

    -Data Structures
    -vorbis_block
    -vorbis_comment
    -vorbis_dsp_state
    -vorbis_info
    -
    -Functions used by both decode and encode
    -vorbis_block_clear()
    -vorbis_block_init()
    -vorbis_dsp_clear()
    -vorbis_granule_time()
    -vorbis_info_blocksize()
    -vorbis_info_clear()
    -vorbis_info_init()
    -vorbis_version_string()
    -
    -Decoding
    -vorbis_packet_blocksize()
    -vorbis_synthesis()
    -vorbis_synthesis_blockin()
    -vorbis_synthesis_halfrate()
    -vorbis_synthesis_halfrate_p()
    -vorbis_synthesis_headerin()
    -vorbis_synthesis_idheader()
    -vorbis_synthesis_init()
    -vorbis_synthesis_lapout()
    -vorbis_synthesis_pcmout()
    -vorbis_synthesis_read()
    -vorbis_synthesis_restart()
    -vorbis_synthesis_trackonly()
    -
    -Encoding
    -vorbis_analysis()
    -vorbis_analysis_blockout()
    -vorbis_analysis_buffer()
    -vorbis_analysis_headerout()
    -vorbis_analysis_init()
    -vorbis_analysis_wrote()
    -vorbis_bitrate_addblock()
    -vorbis_bitrate_flushpacket()
    -
    -Metadata
    -vorbis_comment_add()
    -vorbis_comment_add_tag()
    -vorbis_comment_clear()
    -vorbis_comment_init()
    -vorbis_comment_query()
    -vorbis_comment_query_count()
    -vorbis_commentheader_out()
    -
    -Return Codes
    - - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/return.html b/Engine/lib/libvorbis/doc/libvorbis/return.html deleted file mode 100644 index 2ce46fab0..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/return.html +++ /dev/null @@ -1,79 +0,0 @@ - - - -libvorbis - Return Codes - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    Return Codes

    - -

    - -The following return codes are #defined in "vorbis/codec.h" and -may be returned by functions from libvorbis, libvorbisfile, and libvorbisenc. Descriptions of a code -relevant to a specific function are found in the reference description -of that function. - -

    - -
    OV_FALSE
    -
    Not true, or no data available
    - -
    OV_HOLE
    -
    Vorbisfile encoutered missing or corrupt data in the bitstream. Recovery -is normally automatic and this return code is for informational purposes only.
    - -
    OV_EREAD
    -
    Read error while fetching compressed data for decode
    - -
    OV_EFAULT
    -
    Internal inconsistency in encode or decode state. Continuing is likely not possible.
    - -
    OV_EIMPL
    -
    Feature not implemented
    - -
    OV_EINVAL
    -
    Either an invalid argument, or incompletely initialized argument passed to a call
    - -
    OV_ENOTVORBIS
    -
    The given file/data was not recognized as Ogg Vorbis data.
    - -
    OV_EBADHEADER
    -
    The file/data is apparently an Ogg Vorbis stream, but contains a corrupted or undecipherable header.
    - -
    OV_EVERSION
    -
    The bitstream format revision of the given stream is not supported.
    - -
    OV_EBADLINK
    -
    The given link exists in the Vorbis data stream, but is not decipherable due to garbacge or corruption.
    - -
    OV_ENOSEEK
    -
    The given stream is not seekable
    - -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/style.css b/Engine/lib/libvorbis/doc/libvorbis/style.css deleted file mode 100644 index 81cf41795..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/style.css +++ /dev/null @@ -1,7 +0,0 @@ -BODY { font-family: Helvetica, sans-serif } -TD { font-family: Helvetica, sans-serif } -P { font-family: Helvetica, sans-serif } -H1 { font-family: Helvetica, sans-serif } -H2 { font-family: Helvetica, sans-serif } -H4 { font-family: Helvetica, sans-serif } -P.tiny { font-size: 8pt } diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis.html deleted file mode 100644 index 78bab433f..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis.html +++ /dev/null @@ -1,86 +0,0 @@ - - - -libvorbis - function - vorbis_analysis - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_analysis

    - -

    declared in "vorbis/codec.h";

    - -

    Once the uncompressed audio data has been divided into blocks, this -function is called on each block. It looks up the encoding mode and -dispatches the block to the forward transform provided by that mode. -

    -

    When using a basic encoding mode, with no bitrate management, -an ogg_packet pointer can be given, and the coded block is returned -directly through that structure and can be placed in the output stream. -

    -

    Otherwise, NULL should be passed for the ogg_packet pointer. In -that case, after the transform has been applied, the block must passed -to vorbis_bitrate_addblock() for further coding. This method works with -both basic and managed encoding modes, so it's recommended for new code. -

    - - - - - -
    -
    
    -extern int      vorbis_analysis(vorbis_block *vb,ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    vb
    -
    Pointer to the vorbis_block to be encoded.
    -
    op
    -
    Optional pointer to an ogg_packet. This is normally NULL, -and the final output is obtained by passing vb though the -vorbis_bitrate_*() interface to perform further refinement. -However, when not using a bitrate managed encoding mode, it -is possible to skip that step by providing an ogg_packet pointer -here, obtaining the compressed data directly.
    -
    - - -

    Return Values

    -
      -
    • 0 for success
    • -
    • negative values for failure: -
        -
      • OV_EINVAL - Invalid request; a non-NULL value was passed for op when the encoder is using a bitrate managed mode.
      • -
      • OV_EFAULT - Internal fault; indicates a bug or memory corruption.
      • -
      • OV_EIMPL - Unimplemented; not supported by this version of the library.
      • -
      -
    • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_blockout.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_blockout.html deleted file mode 100644 index 2ca51c0ae..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_blockout.html +++ /dev/null @@ -1,79 +0,0 @@ - - - -libvorbis - function - vorbis_analysis_blockout - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_analysis_blockout

    - -

    declared in "vorbis/codec.h";

    - -

    This fuction examines the available uncompressed data and tries to -break it into appropriate sized blocks. It should be called in a loop -after adding new data with vorbis_analysis_buffer()/vorbis_analysis_wrote() -until it returns zero (need more data) or an negative value (error). -

    -

    -Each block returned should be passed to vorbis_analysis() for transform -and coding. -

    - - - - - -
    -
    
    -extern int      vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    Pointer to the vorbis_dsp_state representing the encoder.
    -
    vb
    -
    Pointer to a previously initialized vorbis_block object to hold the -returned data. -
    - - -

    Return Values

    -
      -
    • 1 for success when more blocks are available.
    • -
    • 0 for success when this is the last block available from the current input.
    • -
    • negative values for failure: -
        -
      • OV_EINVAL - Invalid parameters.
      • -
      • OV_EFAULT - Internal fault; indicates a bug or memory corruption.
      • -
      • OV_EIMPL - Unimplemented; not supported by this version of the library.
      • -
      -
    • - -
    - -

    -
    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_buffer.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_buffer.html deleted file mode 100644 index 7a8a34a5d..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_buffer.html +++ /dev/null @@ -1,74 +0,0 @@ - - - -libvorbis - function - vorbis_analysis_buffer - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_analysis_buffer

    - -

    declared in "vorbis/codec.h";

    - -

    This fuction requests a buffer array for delivering audio to the -encoder for compression.

    - -

    The Vorbis encoder expects the caller to write audio data as -non-interleaved floating point samples into its internal buffers. -

    -

    -The general procedure is to call this function with the number of samples -you have available. The encoder will arrange for that much internal storage -and return an array of buffer pointers, one for each channel of audio. -The caller must then write the audio samples into those buffers, as -float values, and finally call vorbis_analysis_wrote() to tell the -encoder the data is available for analysis. -

    - - - - - -
    -
    
    -extern float  **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    Pointer to the vorbis_dsp_state representing the encoder.
    -
    vals
    -
    Number of samples to provide space for in the returned buffer. 1024 is a reasonable choice.
    -
    - - -

    Return Values

    -

    Returns an array of floating point buffers which can accept data. -A (**float) where the first index is the channel, and the second is -the sample index.

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_headerout.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_headerout.html deleted file mode 100644 index 9880fb964..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_headerout.html +++ /dev/null @@ -1,83 +0,0 @@ - - - -libvorbis - function - vorbis_analysis_headerout - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_analysis_headerout

    - -

    declared in "vorbis/codec.h";

    - -

    This function creates and returns the three header packets needed -to configure a decoder to accept compressed data. I should be called -after all encoder initialization and configuration is complete. The -output packets should be placed in order at the start of the compressed -vorbis stream, prior to the first data packet. -

    - - - - - -
    -
    
    -extern int      vorbis_analysis_headerout(vorbis_dsp_state *v,
    -                                          vorbis_comment *vc,
    -                                          ogg_packet *op,
    -                                          ogg_packet *op_comm,
    -                                          ogg_packet *op_code);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    Pointer to an initialized vorbis_dsp_state which holds the encoder configuration.
    -
    vc
    -
    Pointer to an initialized vorbis_comment structure which holds the metadata associated with the stream being encoded.
    -
    op
    -
    Pointer to an ogg_packet structure to be filled out with the stream identification header.
    -
    op_comm
    -
    Pointer to an ogg_packet structure to be filled out with the serialied vorbis_comment data.
    -
    op_code
    -
    Pointer to an ogg_packet structure to be filled out with the codebooks, mode descriptions, etc. which will be used encoding the stream.
    -
    - - -

    Return Values

    -
      -
    • 0 for success
    • -
    • negative values for failure: -
        -
      • OV_EFAULT - Internal fault; indicates a bug or memory corruption.
      • -
      • OV_EIMPL - Unimplemented; not supported by this version of the library.
      • -
      -
    • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_init.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_init.html deleted file mode 100644 index 2ffde1fb7..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_init.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -libvorbis - function - vorbis_analysis_init - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_analysis_init

    - -

    declared in "vorbis/codec.h";

    - -

    This function allocates and initializes the encoder's analysis state -inside a is vorbis_dsp_state, based on the configuration in a vorbis_info -struct. -

    - - - - - -
    -
    
    -extern int      vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
    -
    -
    - -

    Parameters

    -
    -
    v -
    Pointer to the vorbis_dsp_state structure to be initialized for encoding.
    -
    vi
    -
    Pointer to an initialized vorbis_info struct describing the encoder configuration.
    -
    - - -

    Return Values

    -
    -
  • -0 for success
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_wrote.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_wrote.html deleted file mode 100644 index 16ace2da6..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_analysis_wrote.html +++ /dev/null @@ -1,80 +0,0 @@ - - - -libvorbis - function - vorbis_analysis_wrote - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_analysis_wrote

    - -

    declared in "vorbis/codec.h";

    - -

    This function tells the encoder new data is available for compression. -Call this after writing new audio into the buffer array returned by -vorbis_analysis_buffer(). -

    - -

    -Call with the vals parameter set to zero to signal the end -of the input data. -

    - - - - - -
    -
    
    -extern int      vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    Pointer to the vorbis_dsp_state representing the encoder.
    -
    vals
    -
    Number of samples successfully written. This must be less than -or equal to the value passed to vorbis_analysis_buffer(). A value -of zero means all input data has been provided and the compressed -stream should be finalized.
    -
    - - -

    Return Values

    -
      -
    • 0 for success
    • -
    • negative values for failure: -
        -
      • OV_EINVAL - Invalid request; e.g. vals overflows the allocated space.
      • -
      • OV_EFAULT - Internal fault; indicates a bug or memory corruption.
      • -
      • OV_EIMPL - Unimplemented; not supported by this version of the library.
      • -
      -
    • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_bitrate_addblock.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_bitrate_addblock.html deleted file mode 100644 index 334a9e084..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_bitrate_addblock.html +++ /dev/null @@ -1,74 +0,0 @@ - - - -libvorbis - function - vorbis_bitrate_addblock - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_bitrate_addblock

    - -

    declared in "vorbis/codec.h";

    - -

    This fuction submits a transformed block to the bitrate management -engine for final encoding. Packets are buffered and the packet boundaries -adjusted and padded to meet the target bitrate, if any.

    - -

    After calling vorbis_bitrate_addblock(), the passed vorbis_block -structure can be reused in another call to vorbis_analysis_blockout(). -Call vorbis_bitrate_flushpacket() to obtain the final compressed data. -

    - - - - - -
    -
    
    -extern int      vorbis_bitrate_addblock(vorbis_block *vb);
    -
    -
    - -

    Parameters

    -
    -
    vb
    -
    Pointer to the vorbis_block to be submitted.
    -
    - - -

    Return Values

    -
      -
    • 0 for success.
    • -
    • negative values for failure: -
        -
      • OV_EINVAL - Invalid parameters.
      • -
      • OV_EFAULT - Internal fault; indicates a bug or memory corruption.
      • -
      • OV_EIMPL - Unimplemented; not supported by this version of the library.
      • -
      -
    • - -
    - -

    -
    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_bitrate_flushpacket.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_bitrate_flushpacket.html deleted file mode 100644 index 7277bc4e0..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_bitrate_flushpacket.html +++ /dev/null @@ -1,80 +0,0 @@ - - - -libvorbis - function - vorbis_bitrate_flushpacket - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_bitrate_flushpacket

    - -

    declared in "vorbis/codec.h";

    - -

    This function returns the next available completed packet from the -bitrate management engine. It should be called in a loop after any call -to vorbis_bitrate_addblock() until it returns either 0 (more data needed) -or a negative value (error). -

    - -

    -The data returned in the ogg_packet structure can be copied to the -final compressed output stream. -

    - - - - - -
    -
    
    -extern int      vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,
    -                                           ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    vd
    -
    Pointer to the vorbis_dsp_state represending the encoder.
    -
    op
    -
    Pointer to an ogg_packet to be filled out with the compressed data.
    -
    - - -

    Return Values

    -
      -
    • 1 for success when more packets are available. -
    • 0 for success when this is the last packet available from the current input.
    • -
    • negative values for failure: -
        -
      • OV_EINVAL - Invalid parameters.
      • -
      • OV_EFAULT - Internal fault; indicates a bug or memory corruption.
      • -
      • OV_EIMPL - Unimplemented; not supported by this version of the library.
      • -
      -
    • - -
    - -

    -
    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_block.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_block.html deleted file mode 100644 index 0c4f21470..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_block.html +++ /dev/null @@ -1,60 +0,0 @@ - - - -libvorbis - datatype - vorbis_block - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_block

    - -

    declared in "vorbis/codec.h"

    - -

    -The vorbis_block structure holds the data for a single block of audio. One -vorbis_block translates to one codec packet. The encoding process consists -of splitting the audio into blocks and encoding the blocks into packets; -decoding consists of decoding the packets into blocks and reassembling -the audio from the blocks. -

    -This structure is intended to be private. Although the fields are given -in the header file, they should not be directly modified or relied upon -in any way. -

    - - - - - -
    -
    typedef struct vorbis_block{
    -  /* private */
    -} vorbis_block;
    -
    - -

    Parameters

    -
    • None public.
    - - -

    -
    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_block_clear.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_block_clear.html deleted file mode 100644 index 5d4a5ca7d..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_block_clear.html +++ /dev/null @@ -1,61 +0,0 @@ - - - -libvorbis - function - vorbis_block_clear - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_block_clear

    - -

    declared in "vorbis/codec.h";

    - -

    This function frees the internal storage for a vorbis_block structure.

    - - - - - -
    -
    
    -extern int      vorbis_block_clear(vorbis_block *vb);
    -
    -
    - -

    Parameters

    -
    -
    vb
    -
    Pointer to a vorbis_block struct to be cleared.
    -
    - - -

    Return Values

    -
    -
  • -0 for success
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_block_init.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_block_init.html deleted file mode 100644 index 10bb27348..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_block_init.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -libvorbis - function - vorbis_block_init - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_block_init

    - -

    declared in "vorbis/codec.h";

    - -

    This function initializes a vorbis_block structure and allocates its -internal storage. A vorbis_block is used to represent a particular block -of input audio which can be analyzed and coded as a unit. -

    - - - - - -
    -
    
    -extern int      vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
    -
    -
    - -

    Parameters

    -
    -
    v -
    Pointer to an initialized vorbis_dsp_state with which to associate the new block.
    -
    vb
    -
    Pointer to a vorbis_block struct to be initialized.
    -
    - - -

    Return Values

    -
    -
  • -0 for success
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment.html deleted file mode 100644 index 25dc9218d..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment.html +++ /dev/null @@ -1,80 +0,0 @@ - - - -libvorbis - datatype - vorbis_comment - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_comment

    - -

    declared in "vorbis/codec.h"

    - -

    -The vorbis_comment structure defines an Ogg Vorbis comment. -

    -Only the fields the program needs must be defined. If a field isn't -defined by the application, it will either be blank (if it's a string value) -or set to some reasonable default (usually 0). -

    -Note: When encoding, while it is supported to modify a -vorbis_comment structure directly, be sure to read the notes on the -vorbis_comment_init and -vorbis_comment_clear pages for -considerations on memory allocation and freeing before you do so. Rule of -thumb: call vorbis_comment_init, then either do all allocation, -freeing, and modification yourself and do not call -vorbis_comment_clear, or do all modification using libvorbis -functions and do call vorbis_comment_clear. -

    - - - - - -
    -
    typedef struct vorbis_comment{
    -  /* unlimited user comment fields. */
    -  char **user_comments;
    -  int  *comment_lengths;
    -  int  comments;
    -  char *vendor;
    -
    -} vorbis_comment;
    -
    - -

    Parameters

    -
    -
    user_comments
    -
    Unlimited user comment array. The individual strings in the array are 8 bit clean, by the Vorbis specification, and as such the comment_lengths array should be consulted to determine string length. For convenience, each string is also NULL-terminated by the decode library (although Vorbis comments are not NULL terminated within the bitstream itself).
    -
    comment_lengths
    -
    An int array that stores the length of each comment string
    -
    comments
    -
    Int signifying number of user comments in user_comments field.
    -
    vendor
    -
    Information about the Vorbis implementation that encoded the file. Stored in a standard C 0-terminated string. Libvorbis will fill this in itself when encoding a comment packet from this structure; when decoding, this contains the vendor string that was in the comment packet.
    -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_add.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_add.html deleted file mode 100644 index 7fa7fec4c..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_add.html +++ /dev/null @@ -1,70 +0,0 @@ - - - -libvorbis - function - vorbis_comment_add - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_comment_add

    - -

    declared in "vorbis/codec.h";

    - -

    This function adds a raw comment string to a -vorbis_comment structure.

    - -

    This function should be used if the string is already in the -form "KEY=value". If you have a separate key and value, use -vorbis_comment_add_tag -instead.

    - - - - - -
    -
    
    -extern void     vorbis_comment_add(vorbis_comment *vc, const char *comment);
    -
    -
    - -

    Parameters

    -
    -
    vc
    -
    Pointer to a vorbis_comment structure to add the comment to.
    -
    comment
    -
    Pointer to the null-terminated raw comment string. The string will -be copied, so it can be freed or modified after this function returns -without affecting the vorbis_comment structure's contents.
    -
    - - -

    Return Values

    -
    -
  • None.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_add_tag.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_add_tag.html deleted file mode 100644 index 13ac01607..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_add_tag.html +++ /dev/null @@ -1,74 +0,0 @@ - - - -libvorbis - function - vorbis_comment_add_tag - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_comment_add_tag

    - -

    declared in "vorbis/codec.h";

    - -

    This function adds a tag-comment pair to a -vorbis_comment structure. There can -be more than one comment value for the same tag; if a comment with the -same tag already exists, another comment with the same tag is added.

    - -

    If you already have a string in the form "KEY=value", see -vorbis_comment_add instead.

    - - - - - -
    -
    
    -extern void     vorbis_comment_add_tag(vorbis_comment *vc,
    -                                       const char *tag, const char *contents);
    -
    -
    - -

    Parameters

    -
    -
    vc
    -
    Pointer to a vorbis_comment structure to add the comment to.
    -
    tag
    -
    Pointer to the null-terminated tag string. The string will -be copied, so it can be freed or modified after this function returns -without affecting the vorbis_comment structure's contents.
    -
    contents
    -
    Pointer to the null-terminated comment contents string. This will -also be copied.
    -
    - - -

    Return Values

    -
    -
  • None.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_clear.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_clear.html deleted file mode 100644 index bb9684cdf..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_clear.html +++ /dev/null @@ -1,69 +0,0 @@ - - - -libvorbis - function - vorbis_comment_clear - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_comment_clear

    - -

    declared in "vorbis/codec.h";

    - -

    This function frees the internal storage associated with a vorbis_comment structure.

    - -

    Note: Be careful if you have modified the vorbis_comment -structure yourself, as libvorbis will try to use its own wrappers of -memory allocation functions to free the contents of the vorbis_comment -structure. This will not work correctly unless all arrays and comment -strings contained in the vorbis_comment structure were allocated by -libvorbis itself. This function is only guaranteed to be safe if all -modification to the vorbis_comment structure was done using libvorbis -functions.

    - - - - - -
    -
    
    -extern void     vorbis_comment_clear(vorbis_comment *vc);
    -
    -
    - -

    Parameters

    -
    -
    vc
    -
    The vorbis_comment structure to clear.
    -
    - - -

    Return Values

    -
    -
  • None.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_init.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_init.html deleted file mode 100644 index bb6333b7c..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_init.html +++ /dev/null @@ -1,72 +0,0 @@ - - - -libvorbis - function - vorbis_comment_init - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_comment_init

    - -

    declared in "vorbis/codec.h";

    - -

    This function initializes a vorbis_comment -structure for use. After calling this function, the vorbis_comment -structure contains no comments.

    - -

    Note: No internal storage is allocated by this function; -internal storage is allocated as needed by other libvorbis functions that -modify the vorbis_comment structure. If you modify the vorbis_comment -structure directly, without using libvorbis, you should not -call vorbis_comment_clear when -you are finished but instead clean up after it yourself. See the note -on the vorbis_comment_clear -page for more information.

    - - - - - -
    -
    
    -extern void     vorbis_comment_init(vorbis_comment *vc);
    -
    -
    - -

    Parameters

    -
    -
    vc
    -
    Pointer to the vorbis_comment -structure to initialize.
    -
    - - -

    Return Values

    -
    -
  • None.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_query.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_query.html deleted file mode 100644 index 71cf97ac7..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_query.html +++ /dev/null @@ -1,72 +0,0 @@ - - - -libvorbis - function - vorbis_comment_query - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_comment_query

    - -

    declared in "vorbis/codec.h";

    - -

    This function retrieves a comment string for a given tag in a -vorbis_comment structure.

    - - - - - -
    -
    
    -extern char    *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count);
    -
    -
    - -

    Parameters

    -
    -
    vc
    -
    Pointer to the vorbis_comment structure.
    -
    tag
    -
    Pointer to a null-terminated string of the comment tag to look -for. Tags are compared case-insensitively.
    -
    count
    -
    The index of the comment string to retrieve. A value of 0 indicates -the first comment whose tag matches tag. Use -vorbis_comment_query_count -to determine the number of matching comments.
    -
    - - -

    Return Values

    -
    -
  • A pointer to the comment string. The underlying buffer is owned by -the vorbis_comment structure.
  • -
  • NULL on a nonexistent tag or if count is greater than or -equal to the number of matching comments.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_query_count.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_query_count.html deleted file mode 100644 index dc1e84c97..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_comment_query_count.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -libvorbis - function - vorbis_comment_query_count - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_comment_query_count

    - -

    declared in "vorbis/codec.h";

    - -

    This function determines the number of comments with a given tag -that are present in a vorbis_comment -structure.

    - - - - - -
    -
    
    -extern int      vorbis_comment_query_count(vorbis_comment *vc, const char *tag);
    -
    -
    - -

    Parameters

    -
    -
    vc
    -
    Pointer to the vorbis_comment structure.
    -
    tag
    -
    Pointer to a null-terminated string of the comment tag to look -for. Tags are compared case-insensitively.
    -
    - - -

    Return Values

    -
    -
  • The number of comments present with the given tag.
  • -
  • 0 if no such comments are present.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_commentheader_out.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_commentheader_out.html deleted file mode 100644 index e880b0163..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_commentheader_out.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -libvorbis - function - vorbis_commentheader_out - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_commentheader_out

    - -

    declared in "vorbis/codec.h";

    - -

    This function encodes the contents of a -vorbis_comment structure into an -ogg_packet.

    - - - - - -
    -
    
    -extern int      vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    vc
    -
    The vorbis_comment structure to encode.
    -
    op
    -
    The ogg_packet to place the encoded comment packet into.
    -
    - - -

    Return Values

    -
    -
  • 0 on success.
  • -
  • OV_EIMPL on error.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_dsp_clear.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_dsp_clear.html deleted file mode 100644 index a012a7e38..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_dsp_clear.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -libvorbis - function - vorbis_dsp_clear - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_dsp_clear

    - -

    declared in "vorbis/codec.h";

    - -

    This function frees the internal storage for a vorbis_dsp_state -structure. This can be used independent of whether the vorbis_dsp_state -is set up for analysis (encoding) or synthesis (decoding).

    - - - - - -
    -
    
    -extern void     vorbis_dsp_clear(vorbis_dsp_state *v);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    Pointer to the vorbis_dsp_state to be cleared.
    -
    - - -

    Return Values

    -
    -
  • -None
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_dsp_state.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_dsp_state.html deleted file mode 100644 index 3ac31a5df..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_dsp_state.html +++ /dev/null @@ -1,57 +0,0 @@ - - - -libvorbis - datatype - vorbis_dsp_state - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_dsp_state

    - -

    declared in "vorbis/codec.h"

    - -

    -The vorbis_dsp_state structure is the state for one instance of the -Vorbis encoder or decoder. -

    -This structure is intended to be private. Although the fields are given -in the header file, they should not be directly modified or relied upon -in any way. -

    - - - - - -
    -
    typedef struct vorbis_dsp_state{
    -  /* private */
    -} vorbis_dsp_state;
    -
    - -

    Parameters

    -
    • None public.
    - - -

    -
    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_granule_time.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_granule_time.html deleted file mode 100644 index adca9b01e..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_granule_time.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -libvorbis - function - vorbis_granule_time - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_granule_time

    - -

    declared in "vorbis/codec.h";

    - -

    This function converts a granule position to a time for a given Vorbis stream.

    - - - - - -
    -
    
    -extern double   vorbis_granule_time(vorbis_dsp_state *v,
    -                                    ogg_int64_t granulepos);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    Pointer to the vorbis_dsp_state for the stream.
    -
    granulepos
    -
    The granule position.
    -
    - - -

    Return Values

    -
    -
  • -The time (in seconds) corresponding to the granulepos.
  • -
  • -1 if the given granulepos is negative
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_info.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_info.html deleted file mode 100644 index fccea2124..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_info.html +++ /dev/null @@ -1,80 +0,0 @@ - - - -libvorbis - datatype - vorbis_info - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_info

    - -

    declared in "vorbis/codec.h"

    - -

    -The vorbis_info structure contains basic information about the audio in a vorbis bitstream. -

    - - - - - -
    -
    typedef struct vorbis_info{
    -  int version;
    -  int channels;
    -  long rate;
    -  
    -  long bitrate_upper;
    -  long bitrate_nominal;
    -  long bitrate_lower;
    -  long bitrate_window;
    -
    -  void *codec_setup;
    -
    -} vorbis_info;
    -
    - -

    Relevant Struct Members

    -
    -
    version
    -
    Vorbis encoder version used to create this bitstream.
    -
    channels
    -
    Int signifying number of channels in bitstream.
    -
    rate
    -
    Sampling rate of the bitstream.
    -
    bitrate_upper
    -
    Specifies the upper limit in a VBR bitstream. If the value matches the bitrate_nominal and bitrate_lower parameters, the stream is fixed bitrate. May be unset if no limit exists.
    -
    bitrate_nominal
    -
    Specifies the average bitrate for a VBR bitstream. May be unset. If the bitrate_upper and bitrate_lower parameters match, the stream is fixed bitrate.
    -
    bitrate_lower
    -
    Specifies the lower limit in a VBR bitstream. If the value matches the bitrate_nominal and bitrate_upper parameters, the stream is fixed bitrate. May be unset if no limit exists.
    -
    bitrate_window
    -
    Currently unset.
    - -
    codec_setup
    -
    Internal structure that contains the detailed/unpacked configuration for decoding the current Vorbis bitstream.
    -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_info_blocksize.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_info_blocksize.html deleted file mode 100644 index 47d00e1bd..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_info_blocksize.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -libvorbis - function - vorbis_info_blocksize - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_info_blocksize

    - -

    declared in "vorbis/codec.h";

    - -

    This function gets the possible sizes for encoded blocks. There -are short blocks (zo = 0) and long blocks (zo = 1). The size of a long -block is guaranteed to be greater than or equal to the size of a short -block.

    - - - - - -
    -
    
    -extern int      vorbis_info_blocksize(vorbis_info *vi,int zo);
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    Pointer to the vorbis_info struct.
    -
    zo
    -
    Integer for which block size to get: 0 for short and 1 for long
    -
    - - -

    Return Values

    -
    -
  • A positive integer for the block size.
  • -
  • -1 on error.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_info_clear.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_info_clear.html deleted file mode 100644 index da52223f0..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_info_clear.html +++ /dev/null @@ -1,61 +0,0 @@ - - - -libvorbis - function - vorbis_info_clear - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_info_clear

    - -

    declared in "vorbis/codec.h";

    - -

    This function frees the internal storage for a vorbis_info structure.

    - - - - - -
    -
    
    -extern void     vorbis_info_clear(vorbis_info *vi);
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    Pointer to a vorbis_info struct to be cleared.
    -
    - - -

    Return Values

    -
    -
  • -None.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_info_init.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_info_init.html deleted file mode 100644 index ab81515bf..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_info_init.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -libvorbis - function - vorbis_info_init - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_info_init

    - -

    declared in "vorbis/codec.h";

    - -

    This function initializes a vorbis_info -structure and allocates its internal storage.

    - - - - - -
    -
    
    -extern void     vorbis_info_init(vorbis_info *vi);
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    Pointer to a vorbis_info struct to be initialized.
    -
    - - -

    Return Values

    -
    -
  • -None.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_packet_blocksize.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_packet_blocksize.html deleted file mode 100644 index 7ae8ff6f3..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_packet_blocksize.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -libvorbis - function - vorbis_packet_blocksize - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_packet_blocksize

    - -

    declared in "vorbis/codec.h";

    - -

    This function gets the size of the block that would result from -decoding a Vorbis packet but does not actually decode the packet.

    - - - - - -
    -
    
    -extern long     vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    The vorbis_info structure for the -stream the packet is from.
    -
    op
    -
    The packet to get the block size of.
    -
    - - -

    Return Values

    -
    -
  • The block size on success.
  • -
  • OV_ENOTAUDIO if the packet is not an audio packet.
  • -
  • OV_EBADPACKET if there was an error in the packet.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis.html deleted file mode 100644 index 902e3b6a5..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis.html +++ /dev/null @@ -1,70 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis

    - -

    declared in "vorbis/codec.h";

    - -

    This function decodes a Vorbis packet into a block of data. The -vorbis_block should then be submitted -to the vorbis_dsp_state -for the decoder instance using -vorbis_synthesis_blockin -to be assembled into the final decoded audio.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    vb
    -
    The vorbis_block to decode the -packet into.
    -
    op
    -
    The ogg_packet to decode.
    -
    - - -

    Return Values

    -
    -
  • 0 on success.
  • -
  • OV_ENOTAUDIO if the packet is not an audio packet.
  • -
  • OV_EBADPACKET if there was an error in the packet.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_blockin.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_blockin.html deleted file mode 100644 index 32ec6681d..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_blockin.html +++ /dev/null @@ -1,69 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_blockin - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_blockin

    - -

    declared in "vorbis/codec.h";

    - -

    This function submits a vorbis_block -for assembly into the final decoded audio. After calling -this function, decoded audio can be obtained with -vorbis_synthesis_pcmout.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    The vorbis_dsp_state for the -decoder instance.
    -
    vb
    -
    The vorbis_block to submit. After -this function returns, it can be reused in another call to -vorbis_synthesis.
    -
    - - -

    Return Values

    -
    -
  • 0 on success.
  • -
  • OV_EINVAL if the decoder is in an invalid state to accept blocks.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_halfrate.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_halfrate.html deleted file mode 100644 index 8869723f8..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_halfrate.html +++ /dev/null @@ -1,68 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_halfrate - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_halfrate

    - -

    declared in "vorbis/codec.h";

    - -

    This function puts the Vorbis decoder into or out of half-rate -mode. In half-rate mode, the audio is decoded to only half its original -sampling rate. Half-rate mode speeds up decoding at the expense of -decoded audio quality.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_halfrate(vorbis_info *v,int flag);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    The vorbis_info structure for the -decoder instance.
    -
    flag
    -
    Whether half-rate mode is to be turned on or off. Zero turns it off; -nonzero turns it on.
    -
    - - -

    Return Values

    -
    -
  • 0 on success.
  • -
  • -1 if half-rate mode could not be set.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_halfrate_p.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_halfrate_p.html deleted file mode 100644 index b2b3f983e..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_halfrate_p.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_halfrate_p - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_halfrate_p

    - -

    declared in "vorbis/codec.h";

    - -

    This function gets whether a decoder is in half-rate mode. See -vorbis_synthesis_halfrate -for more information on half-rate mode.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_halfrate_p(vorbis_info *v);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    The vorbis_info structure for the -decoder instance.
    -
    - - -

    Return Values

    -
    -
  • 1 if half-rate mode is on.
  • -
  • 0 if half-rate mode is off.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_headerin.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_headerin.html deleted file mode 100644 index 5234bbec3..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_headerin.html +++ /dev/null @@ -1,80 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_headerin - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_headerin

    - -

    declared in "vorbis/codec.h";

    - -

    This function decodes a header packet from a Vorbis stream and applies -the contents to the given vorbis_info -structure (to provide codec parameters to the decoder) and -vorbis_comment structure (to provide -access to the embedded Vorbis comments).

    - -

    Once the three Vorbis header packets (info, comments, -and codebooks, in that order) have been passed to this -function, the vorbis_info -structure is ready to be used in a call to -vorbis_synthesis_init.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
    -                                          ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    The vorbis_info structure to apply -the decoded information to.
    -
    vc
    -
    The vorbis_comment structure to -apply the decoded comments to.
    -
    op
    -
    The ogg_packet to decode.
    -
    - - -

    Return Values

    -
    -
  • 0 on success.
  • -
  • OV_ENOTVORBIS if the packet is not a Vorbis header packet.
  • -
  • OV_EBADHEADER if there was an error interpreting the packet.
  • -
  • OV_EFAULT on internal error.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_idheader.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_idheader.html deleted file mode 100644 index cc58eb25d..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_idheader.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_idheader - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_idheader

    - -

    declared in "vorbis/codec.h";

    - -

    This function checks whether a packet is a valid Vorbis identification -header packet. This function can be used to detect whether a logical -Ogg stream could be a Vorbis stream, given its very first packet.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_idheader(ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    op
    -
    Pointer to the ogg_packet to check.
    -
    - - -

    Return Values

    -
    -
  • 1 if the packet is a valid first packet for a Vorbis bitstream.
  • -
  • 0 if not.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_init.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_init.html deleted file mode 100644 index 6d2c7a9cb..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_init.html +++ /dev/null @@ -1,69 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_init - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_init

    - -

    declared in "vorbis/codec.h";

    - -

    This function initializes a -vorbis_dsp_state structure for -decoding and allocates internal storage for it.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    The vorbis_dsp_state to initialize -for decoding.
    -
    vi
    -
    The vorbis_info structure -for the stream. The vorbis_info structure must have had vorbis_synthesis_headerin -called on it for each header packet in the stream.
    -
    - - -

    Return Values

    -
    -
  • 0 on success.
  • -
  • 1 on error.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_lapout.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_lapout.html deleted file mode 100644 index 77696e4c8..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_lapout.html +++ /dev/null @@ -1,74 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_lapout - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_lapout

    - -

    declared in "vorbis/codec.h";

    - -

    This function retrieves buffers containing decoded audio samples, similarly -to vorbis_synthesis_pcmout. -However, it includes some extra samples extrapolated from the end of -the audio, suitable for crosslapping with other blocks. This exists mainly -for libvorbisfile to use for -handling chained bitstreams and bitstreams with holes.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    The vorbis_dsp_state for the -decoder instance.
    -
    pcm
    -
    A pointer to a float** which will be made to point to an array of -pointers to the decoded samples for each channel. The memory is owned -by the decoder instance and will be freed when the application continues -decoding or destroys the decoder instance. This can be NULL, in which -case the return value gives the number of samples that would be returned -if this function were called with a non-NULL pointer here.
    -
    - - -

    Return Values

    -
    -
  • The number of samples available in the output buffer.
  • -
  • 0 if no more samples are currently available.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_pcmout.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_pcmout.html deleted file mode 100644 index 8a22bb8f4..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_pcmout.html +++ /dev/null @@ -1,75 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_pcmout - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_pcmout

    - -

    declared in "vorbis/codec.h";

    - -

    This function retrieves buffers containing decoded audio samples.

    -

    The application is not required to make use of all of the samples -made available to it by one call to this function before it continues to -decode. Use vorbis_synthesis_read -to inform the decoder of how many samples were actually used. Any -unused samples will be included in the buffers output by the next call -to this function.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    The vorbis_dsp_state for the -decoder instance.
    -
    pcm
    -
    A pointer to a float** which will be made to point to an array of -pointers to the decoded samples for each channel. The memory is owned -by the decoder instance and will be freed when the application continues -decoding or destroys the decoder instance. This can be NULL, in which -case the return value gives the number of samples that would be returned -if this function were called with a non-NULL pointer here.
    -
    - - -

    Return Values

    -
    -
  • The number of samples available in the output buffer.
  • -
  • 0 if no more samples are currently available.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_read.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_read.html deleted file mode 100644 index 3b1ee70e5..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_read.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_read - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_read

    - -

    declared in "vorbis/codec.h";

    - -

    This function informs the Vorbis decoder of how many -samples the application used from the last buffer output by -vorbis_synthesis_pcmout.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    The vorbis_dsp_state for the -decoder instance.
    -
    samples
    -
    The number of samples the application has used.
    -
    - - -

    Return Values

    -
    -
  • 0 on success.
  • -
  • OV_EINVAL if samples is greater than the number of remaining -samples in the buffer.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_restart.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_restart.html deleted file mode 100644 index efcf13364..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_restart.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_restart - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_restart

    - -

    declared in "vorbis/codec.h";

    - -

    This function restores a -vorbis_dsp_state structure -representing a decoder to its freshly-initialized state. This should be -called if the application seeks within a Vorbis bitstream.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_restart(vorbis_dsp_state *v);
    -
    -
    - -

    Parameters

    -
    -
    v
    -
    The vorbis_dsp_state to reset.
    -
    - - -

    Return Values

    -
    -
  • 0 on success.
  • -
  • -1 on error.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_trackonly.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_trackonly.html deleted file mode 100644 index 550f32d0b..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_synthesis_trackonly.html +++ /dev/null @@ -1,71 +0,0 @@ - - - -libvorbis - function - vorbis_synthesis_trackonly - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_synthesis_trackonly

    - -

    declared in "vorbis/codec.h";

    - -

    This function decodes a Vorbis packet similarly to -vorbis_synthesis, except that the -vorbis_block produced does not contain -any audio data but merely updates the decoder's state as though the -block had been actually decoded when -vorbis_synthesis_blockin -is called on it.

    - - - - - -
    -
    
    -extern int      vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
    -
    -
    - -

    Parameters

    -
    -
    vb
    -
    The vorbis_block to decode the -packet into.
    -
    op
    -
    The ogg_packet to decode.
    -
    - - -

    Return Values

    -
    -
  • 0 on success.
  • -
  • OV_ENOTAUDIO if the packet is not an audio packet.
  • -
  • OV_EBADPACKET if there was an error in the packet.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/libvorbis/vorbis_version_string.html b/Engine/lib/libvorbis/doc/libvorbis/vorbis_version_string.html deleted file mode 100644 index 017d68461..000000000 --- a/Engine/lib/libvorbis/doc/libvorbis/vorbis_version_string.html +++ /dev/null @@ -1,56 +0,0 @@ - - - -libvorbis - function - vorbis_version_string - - - - - - - - - -

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - -

    vorbis_version_string

    - -

    declared in "vorbis/codec.h";

    - -

    This function returns a string giving version information for libvorbis. (This is not the same string that libvorbis encodes into the vendor field of comment headers.)

    - - - - - -
    -
    
    -extern const char *vorbis_version_string(void);
    -
    -
    - -

    Parameters

    -

    None.

    - -

    Return Values

    -
    -
  • The libvorbis version string. The string is in static storage.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2010 Xiph.Org

    Ogg Vorbis

    libvorbis documentation

    libvorbis version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/oggstream.html b/Engine/lib/libvorbis/doc/oggstream.html deleted file mode 100644 index 48c337edf..000000000 --- a/Engine/lib/libvorbis/doc/oggstream.html +++ /dev/null @@ -1,234 +0,0 @@ - - - - - -Ogg Vorbis Documentation - - - - - - - - - -

    Ogg logical and physical bitstream overview

    - -

    Ogg bitstreams

    - -

    Ogg codecs use octet vectors of raw, compressed data -(packets). These compressed packets do not have any -high-level structure or boundary information; strung together, they -appear to be streams of random bytes with no landmarks.

    - -

    Raw packets may be used directly by transport mechanisms that provide -their own framing and packet-separation mechanisms (such as UDP -datagrams). For stream based storage (such as files) and transport -(such as TCP streams or pipes), Vorbis and other future Ogg codecs use -the Ogg bitstream format to provide framing/sync, sync recapture -after error, landmarks during seeking, and enough information to -properly separate data back into packets at the original packet -boundaries without relying on decoding to find packet boundaries.

    - -

    Logical and physical bitstreams

    - -

    Raw packets are grouped and encoded into contiguous pages of -structured bitstream data called logical bitstreams. A -logical bitstream consists of pages, in order, belonging to a single -codec instance. Each page is a self contained entity (although it is -possible that a packet may be split and encoded across one or more -pages); that is, the page decode mechanism is designed to recognize, -verify and handle single pages at a time from the overall bitstream.

    - -

    Multiple logical bitstreams can be combined (with restrictions) into a -single physical bitstream. A physical bitstream consists of -multiple logical bitstreams multiplexed at the page level and may -include a 'meta-header' at the beginning of the multiplexed logical -stream that serves as identification magic. Whole pages are taken in -order from multiple logical bitstreams and combined into a single -physical stream of pages. The decoder reconstructs the original -logical bitstreams from the physical bitstream by taking the pages in -order from the physical bitstream and redirecting them into the -appropriate logical decoding entity. The simplest physical bitstream -is a single, unmultiplexed logical bitstream with no meta-header; this -is referred to as a 'degenerate stream'.

    - -

    Ogg Logical Bitstream Framing discusses -the page format of an Ogg bitstream, the packet coding process -and logical bitstreams in detail. The remainder of this document -specifies requirements for constructing finished, physical Ogg -bitstreams.

    - -

    Mapping Restrictions

    - -

    Logical bitstreams may not be mapped/multiplexed into physical -bitstreams without restriction. Here we discuss design restrictions -on Ogg physical bitstreams in general, mostly to introduce -design rationale. Each 'media' format defines its own (generally more -restrictive) mapping. An 'Ogg Vorbis Audio Bitstream', for example, has a -specific physical bitstream structure. -An 'Ogg A/V' bitstream (not currently specified) will also mandate a -specific, restricted physical bitstream format.

    - -

    additional end-to-end structure

    - -

    The framing specification defines -'beginning of stream' and 'end of stream' page markers via a header -flag (it is possible for a stream to consist of a single page). A -stream always consists of an integer number of pages, an easy -requirement given the variable size nature of pages.

    - -

    In addition to the header flag marking the first and last pages of a -logical bitstream, the first page of an Ogg bitstream obeys -additional restrictions. Each individual media mapping specifies its -own implementation details regarding these restrictions.

    - -

    The first page of a logical Ogg bitstream consists of a single, -small 'initial header' packet that includes sufficient information to -identify the exact CODEC type and media requirements of the logical -bitstream. The intent of this restriction is to simplify identifying -the bitstream type and content; for a given media type (or across all -Ogg media types) we can know that we only need a small, fixed -amount of data to uniquely identify the bitstream type.

    - -

    As an example, Ogg Vorbis places the name and revision of the Vorbis -CODEC, the audio rate and the audio quality into this initial header, -thus simplifying vastly the certain identification of an Ogg Vorbis -audio bitstream.

    - -

    sequential multiplexing (chaining)

    - -

    The simplest form of logical bitstream multiplexing is concatenation -(chaining). Complete logical bitstreams are strung -one-after-another in order. The bitstreams do not overlap; the final -page of a given logical bitstream is immediately followed by the -initial page of the next. Chaining is the only logical->physical -mapping allowed by Ogg Vorbis.

    - -

    Each chained logical bitstream must have a unique serial number within -the scope of the physical bitstream.

    - -

    concurrent multiplexing (grouping)

    - -

    Logical bitstreams may also be multiplexed 'in parallel' -(grouped). An example of grouping would be to allow -streaming of separate audio and video streams, using different codecs -and different logical bitstreams, in the same physical bitstream. -Whole pages from multiple logical bitstreams are mixed together.

    - -

    The initial pages of each logical bitstream must appear first; the -media mapping specifies the order of the initial pages. For example, -Ogg A/V will eventually specify an Ogg video bitstream with -audio. The mapping may specify that the physical bitstream must begin -with the initial page of a logical video bitstream, followed by the -initial page of an audio stream. Unlike initial pages, terminal pages -for the logical bitstreams need not all occur contiguously (although a -specific media mapping may require this; it is not mandated by the -generic Ogg stream spec). Terminal pages may be 'nil' pages, -that is, pages containing no content but simply a page header with -position information and the 'last page of bitstream' flag set in the -page header.

    - -

    Each grouped bitstream must have a unique serial number within the -scope of the physical bitstream.

    - -

    sequential and concurrent multiplexing

    - -

    Groups of concurrently multiplexed bitstreams may be chained -consecutively. Such a physical bitstream obeys all the rules of both -grouped and chained multiplexed streams; the groups, when unchained , -must stand on their own as a valid concurrently multiplexed -bitstream.

    - -

    multiplexing example

    - -

    Below, we present an example of a grouped and chained bitstream:

    - -

    stream

    - -

    In this example, we see pages from five total logical bitstreams -multiplexed into a physical bitstream. Note the following -characteristics:

    - -
      -
    1. Grouped bitstreams begin together; all of the initial pages -must appear before any data pages. When concurrently multiplexed -groups are chained, the new group does not begin until all the -bitstreams in the previous group have terminated.
    2. - -
    3. The pages of concurrently multiplexed bitstreams need not conform -to a regular order; the only requirement is that page n of a -logical bitstream follow page n-1 in the physical bitstream. -There are no restrictions on intervening pages belonging to other -logical bitstreams. (Tying page appearance to bitrate demands is one -logical strategy, ie, the page appears at the chronological point -where decode requires more information).
    4. -
    - - - - - diff --git a/Engine/lib/libvorbis/doc/programming.html b/Engine/lib/libvorbis/doc/programming.html deleted file mode 100644 index b0ad255cf..000000000 --- a/Engine/lib/libvorbis/doc/programming.html +++ /dev/null @@ -1,554 +0,0 @@ - - - - - -Ogg Vorbis Documentation - - - - - - - - - -

    Programming with Xiph.Org libvorbis

    - -

    Description

    - -

    Libvorbis is the Xiph.Org Foundation's portable Ogg Vorbis CODEC -implemented as a programmatic library. Libvorbis provides primitives -to handle framing and manipulation of Ogg bitstreams (used by the -Vorbis for streaming), a full analysis (encoding) interface as well as -packet decoding and synthesis for playback.

    - -

    The libvorbis library does not provide any system interface; a -full-featured demonstration player included with the library -distribtion provides example code for a variety of system interfaces -as well as a working example of using libvorbis in production code.

    - -

    Encoding Overview

    - -

    Decoding Overview

    - -

    Decoding a bitstream with libvorbis follows roughly the following -steps:

    - -
      -
    1. Frame the incoming bitstream into pages
    2. -
    3. Sort the pages by logical bitstream and buffer then into logical streams
    4. -
    5. Decompose the logical streams into raw packets
    6. -
    7. Reconstruct segments of the original data from each packet
    8. -
    9. Glue the reconstructed segments back into a decoded stream
    10. -
    - -

    Framing

    - -

    An Ogg bitstream is logically arranged into pages, but to decode -the pages, we have to find them first. The raw bitstream is first fed -into an ogg_sync_state buffer using ogg_sync_buffer() -and ogg_sync_wrote(). After each block we submit to the sync -buffer, we should check to see if we can frame and extract a complete -page or pages using ogg_sync_pageout(). Extra pages are -buffered; allowing them to build up in the ogg_sync_state -buffer will eventually exhaust memory.

    - -

    The Ogg pages returned from ogg_sync_pageout need not be -decoded further to be used as landmarks in seeking; seeking can be -either a rough process of simply jumping to approximately intuited -portions of the bitstream, or it can be a precise bisection process -that captures pages and inspects data position. When seeking, -however, sequential multiplexing (chaining) must be accounted for; -beginning play in a new logical bitstream requires initializing a -synthesis engine with the headers from that bitstream. Vorbis -bitstreams do not make use of concurent multiplexing (grouping).

    - -

    Sorting

    - -

    The pages produced by ogg_sync_pageout are then sorted by -serial number to seperate logical bitstreams. Initialize logical -bitstream buffers (og_stream_state) using -ogg_stream_init(). Pages are submitted to the matching -logical bitstream buffer using ogg_stream_pagein; the serial -number of the page and the stream buffer must match, or the page will -be rejected. A page submitted out of sequence will simply be noted, -and in the course of outputting packets, the hole will be flagged -(ogg_sync_pageout and ogg_stream_packetout will -return a negative value at positions where they had to recapture the -stream).

    - -

    Extracting packets

    - -

    After submitting page[s] to a logical stream, read available packets -using ogg_stream_packetout.

    - -

    Decoding packets

    - -

    Reassembling data segments

    - -

    Ogg Bitstream Manipulation Structures

    - -

    Two of the Ogg bitstream data structures are intended to be -transparent to the developer; the fields should be used directly.

    - -

    ogg_packet

    - -
    -typedef struct {
    -  unsigned char *packet;
    -  long  bytes;
    -  long  b_o_s;
    -  long  e_o_s;
    -
    -  size64 granulepos;
    -
    -} ogg_packet;
    -
    - -
    -
    packet:
    -
    a pointer to the byte data of the raw packet
    -
    bytes:
    -
    the size of the packet' raw data
    -
    b_o_s:
    -
    beginning of stream; nonzero if this is the first packet of - the logical bitstream
    -
    e_o_s:
    -
    end of stream; nonzero if this is the last packet of the - logical bitstream
    -
    granulepos:
    -
    the absolute position of this packet in the original - uncompressed data stream.
    -
    - -

    encoding notes

    - -

    The encoder is responsible for setting all of -the fields of the packet to appropriate values before submission to -ogg_stream_packetin(); however, it is noted that the value in -b_o_s is ignored; the first page produced from a given -ogg_stream_state structure will be stamped as the initial -page. e_o_s, however, must be set; this is the means by -which the stream encoding primitives handle end of stream and cleanup.

    - -

    decoding notes

    - -

    ogg_stream_packetout() sets the fields -to appropriate values. Note that granulepos will be >= 0 only in the -case that the given packet actually represents that position (ie, only -the last packet completed on any page will have a meaningful -granulepos). Intervening frames will see granulepos set -to -1.

    - -

    ogg_page

    - -
    -typedef struct {
    -  unsigned char *header;
    -  long header_len;
    -  unsigned char *body;
    -  long body_len;
    -} ogg_page;
    -
    - -
    -
    header:
    -
    pointer to the page header data
    -
    header_len:
    -
    length of the page header in bytes
    -
    body:
    -
    pointer to the page body
    -
    body_len:
    -
    length of the page body
    -
    - -

    Note that although the header and body pointers do -not necessarily point into a single contiguous page vector, the page -body must immediately follow the header in the bitstream.

    - -

    Ogg Bitstream Manipulation Functions

    - -

    -int ogg_page_bos(ogg_page *og); -

    - -

    Returns the 'beginning of stream' flag for the given Ogg page. The -beginning of stream flag is set on the initial page of a logical -bitstream.

    - -

    Zero indicates the flag is cleared (this is not the initial page of a -logical bitstream). Nonzero indicates the flag is set (this is the -initial page of a logical bitstream).

    - -

    -int ogg_page_continued(ogg_page *og); -

    - -

    Returns the 'packet continued' flag for the given Ogg page. The packet -continued flag indicates whether or not the body data of this page -begins with packet continued from a preceeding page.

    - -

    Zero (unset) indicates that the body data begins with a new packet. -Nonzero (set) indicates that the first packet data on the page is a -continuation from the preceeding page.

    - -

    -int ogg_page_eos(ogg_page *og); -

    - -

    Returns the 'end of stream' flag for a give Ogg page. The end of page -flag is set on the last (terminal) page of a logical bitstream.

    - -

    Zero (unset) indicates that this is not the last page of a logical -bitstream. Nonzero (set) indicates that this is the last page of a -logical bitstream and that no addiitonal pages belonging to this -bitstream may follow.

    - -

    -size64 ogg_page_granulepos(ogg_page *og); -

    - -

    Returns the position of this page as an absolute position within the -original uncompressed data. The position, as returned, is 'frames -encoded to date up to and including the last whole packet on this -page'. Partial packets begun on this page but continued to the -following page are not included. If no packet ends on this page, the -frame position value will be equal to the frame position value of the -preceeding page. If none of the original uncompressed data is yet -represented in the logical bitstream (for example, the first page of a -bitstream consists only of a header packet; this packet encodes only -metadata), the value shall be zero.

    - -

    The units of the framenumber are determined by media mapping. A -vorbis audio bitstream, for example, defines one frame to be the -channel values from a single sampling period (eg, a 16 bit stereo -bitstream consists of two samples of two bytes for a total of four -bytes, thus a frame would be four bytes). A video stream defines one -frame to be a single frame of video.

    - -

    -int ogg_page_pageno(ogg_page *og); -

    - -

    Returns the sequential page number of the given Ogg page. The first -page in a logical bitstream is numbered zero; following pages are -numbered in increasing monotonic order.

    - -

    -int ogg_page_serialno(ogg_page *og); -

    - -

    Returns the serial number of the given Ogg page. The serial number is -used as a handle to distinguish various logical bitstreams in a -physical Ogg bitstresm. Every logical bitstream within a -physical bitstream must use a unique (within the scope of the physical -bitstream) serial number, which is stamped on all bitstream pages.

    - -

    -int ogg_page_version(ogg_page *og); -

    - -

    Returns the revision of the Ogg bitstream structure of the given page. -Currently, the only permitted number is zero. Later revisions of the -bitstream spec will increment this version should any changes be -incompatable.

    - -

    -int ogg_stream_clear(ogg_stream_state *os); -

    - -

    Clears and deallocates the internal storage of the given Ogg stream. -After clearing, the stream structure is not initialized for use; -ogg_stream_init must be called to reinitialize for use. -Use ogg_stream_reset to reset the stream state -to a fresh, intiialized state.

    - -

    ogg_stream_clear does not call free() on the pointer -os, allowing use of this call on stream structures in static -or automatic storage. ogg_stream_destroyis a complimentary -function that frees the pointer as well.

    - -

    Returns zero on success and non-zero on failure. This function always -succeeds.

    - -

    -int ogg_stream_destroy(ogg_stream_state *os); -

    - -

    Clears and deallocates the internal storage of the given Ogg stream, -then frees the storage associated with the pointer os.

    - -

    ogg_stream_clear does not call free() on the pointer -os, allowing use of that call on stream structures in static -or automatic storage.

    - -

    Returns zero on success and non-zero on failure. This function always -succeeds.

    - -

    -int ogg_stream_init(ogg_stream_state *os,int serialno); -

    - -

    Initialize the storage associated with os for use as an Ogg -stream. This call is used to initialize a stream for both encode and -decode. The given serial number is the serial number that will be -stamped on pages of the produced bitstream (during encode), or used as -a check that pages match (during decode).

    - -

    Returns zero on success, nonzero on failure.

    - -

    -int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); -

    - -

    Used during encoding to add the given raw packet to the given Ogg -bitstream. The contents of op are copied; -ogg_stream_packetin does not retain any pointers into -op's storage. The encoding proccess buffers incoming packets -until enough packets have been assembled to form an entire page; -ogg_stream_pageout is used to read complete pages.

    - -

    Returns zero on success, nonzero on failure.

    - -

    -int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); -

    - -

    Used during decoding to read raw packets from the given logical -bitstream. ogg_stream_packetout will only return complete -packets for which checksumming indicates no corruption. The size and -contents of the packet exactly match those given in the encoding -process.

    - -

    Returns zero if the next packet is not ready to be read (not buffered -or incomplete), positive if it returned a complete packet in -op and negative if there is a gap, extra bytes or corruption -at this position in the bitstream (essentially that the bitstream had -to be recaptured). A negative value is not necessarily an error. It -would be a common occurence when seeking, for example, which requires -recapture of the bitstream at the position decoding continued.

    - -

    If the return value is positive, ogg_stream_packetout placed -a packet in op. The data in op points to static -storage that is valid until the next call to -ogg_stream_pagein, ogg_stream_clear, -ogg_stream_reset, or ogg_stream_destroy. The -pointers are not invalidated by more calls to -ogg_stream_packetout.

    - -

    -int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og); -

    - -

    Used during decoding to buffer the given complete, pre-verified page -for decoding into raw Ogg packets. The given page must be framed, -normally produced by ogg_sync_pageout, and from the logical -bitstream associated with os (the serial numbers must match). -The contents of the given page are copied; ogg_stream_pagein -retains no pointers into og storage.

    - -

    Returns zero on success and non-zero on failure.

    - -

    -int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); -

    - -

    Used during encode to read complete pages from the stream buffer. The -returned page is ready for sending out to the real world.

    - -

    Returns zero if there is no complete page ready for reading. Returns -nonzero when it has placed data for a complete page into -og. Note that the storage returned in og points into internal -storage; the pointers in og are valid until the next call to -ogg_stream_pageout, ogg_stream_packetin, -ogg_stream_reset, ogg_stream_clear or -ogg_stream_destroy.

    - -

    -int ogg_stream_reset(ogg_stream_state *os); -

    - -

    Resets the given stream's state to that of a blank, unused stream; -this may be used during encode or decode.

    - -

    Note that if used during encode, it does not alter the stream's serial -number. In addition, the next page produced during encoding will be -marked as the 'initial' page of the logical bitstream.

    - -

    When used during decode, this simply clears the data buffer of any -pending pages. Beginning and end of stream cues are read from the -bitstream and are unaffected by reset.

    - -

    Returns zero on success and non-zero on failure. This function always -succeeds.

    - -

    -char *ogg_sync_buffer(ogg_sync_state *oy, long size); -

    - -

    This call is used to buffer a raw bitstream for framing and -verification. ogg_sync_buffer handles stream capture and -recapture, checksumming, and division into Ogg pages (as required by -ogg_stream_pagein).

    - -

    ogg_sync_buffer exposes a buffer area into which the decoder -copies the next (up to) size bytes. We expose the buffer -(rather than taking a buffer) in order to avoid an extra copy many -uses; this way, for example, read() can transfer data -directly into the stream buffer without first needing to place it in -temporary storage.

    - -

    Returns a pointer into oy's internal bitstream sync buffer; -the remaining space in the sync buffer is at least size -bytes. The decoder need not write all of size bytes; -ogg_sync_wrote is used to inform the engine how many bytes -were actually written. Use of ogg_sync_wrote after writing -into the exposed buffer is mandantory.

    - -

    -int ogg_sync_clear(ogg_sync_state *oy); -

    - -

    ogg_sync_clear -clears and deallocates the internal storage of the given Ogg sync -buffer. After clearing, the sync structure is not initialized for -use; ogg_sync_init must be called to reinitialize for use. -Use ogg_sync_reset to reset the sync state and buffer to a -fresh, intiialized state.

    - -

    ogg_sync_clear does not call free() on the pointer -oy, allowing use of this call on sync structures in static -or automatic storage. ogg_sync_destroyis a complimentary -function that frees the pointer as well.

    - -

    Returns zero on success and non-zero on failure. This function always -succeeds.

    - -

    -int ogg_sync_destroy(ogg_sync_state *oy); -

    - -

    Clears and deallocates the internal storage of the given Ogg sync -buffer, then frees the storage associated with the pointer -oy.

    - -

    An alternative function,ogg_sync_clear, does not call -free() on the pointer oy, allowing use of that call on -stream structures in static or automatic storage.

    - -

    Returns zero on success and non-zero on failure. This function always -succeeds.

    - -

    -int ogg_sync_init(ogg_sync_state *oy); -

    - -

    Initializes the sync buffer oy for use.

    - -

    Returns zero on success and non-zero on failure. This function always -succeeds.

    - -

    -int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); -

    - -

    Reads complete, framed, verified Ogg pages from the sync buffer, -placing the page data in og.

    - -

    Returns zero when there's no complete pages buffered for -retrieval. Returns negative when a loss of sync or recapture occurred -(this is not necessarily an error; recapture would be required after -seeking, for example). Returns positive when a page is returned in -og. Note that the data in og points into the sync -buffer storage; the pointers are valid until the next call to -ogg_sync_buffer, ogg_sync_clear, -ogg_sync_destroy or ogg_sync_reset.

    - -

    -int ogg_sync_reset(ogg_sync_state *oy); -

    - -

    ogg_sync_reset resets the sync state in oy to a -clean, empty state. This is useful, for example, when seeking to a -new location in a bitstream.

    - -

    Returns zero on success, nonzero on failure.

    - -

    -int ogg_sync_wrote(ogg_sync_state *oy, long bytes); -

    - -

    Used to inform the sync state as to how many bytes were actually -written into the exposed sync buffer. It must be equal to or less -than the size of the buffer requested.

    - -

    Returns zero on success and non-zero on failure; failure occurs only -when the number of bytes written were larger than the buffer.

    - - - - - diff --git a/Engine/lib/libvorbis/doc/release.txt b/Engine/lib/libvorbis/doc/release.txt deleted file mode 100644 index 38d90d714..000000000 --- a/Engine/lib/libvorbis/doc/release.txt +++ /dev/null @@ -1,16 +0,0 @@ -libvorbis release checklist. - -- Bump vendor string for encoder changes in lib/info.c -- Bump release version and sonames in configure.ac -- Update CHANGES. -- Update overall copyright dates on COPYING and README. -- Verify everything is committed. -- Tag release: `git tag -S v1.x.y` Paste the CHANGES entry as a tag msg. -- Verify 'make distcheck' works. -- Publish the tag: `git push --tags` -- Copy source packages to a checkout of https://svn.xiph.org/releases/vorbis/ -- Add the packages to the repo and update checksum files there. -- Update https://xiph.org/downloads/ -- Update topic in the #vorbis irc channel on freenode.net. -- Post announcement to https://xiph.org/press/ and link from front page. -- Announce new release to mailing list. diff --git a/Engine/lib/libvorbis/doc/residue-pack.png b/Engine/lib/libvorbis/doc/residue-pack.png deleted file mode 100644 index 6ed071b85..000000000 Binary files a/Engine/lib/libvorbis/doc/residue-pack.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/residue2.png b/Engine/lib/libvorbis/doc/residue2.png deleted file mode 100644 index e8bde3262..000000000 Binary files a/Engine/lib/libvorbis/doc/residue2.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/rfc5215.txt b/Engine/lib/libvorbis/doc/rfc5215.txt deleted file mode 100644 index 67adf92a8..000000000 --- a/Engine/lib/libvorbis/doc/rfc5215.txt +++ /dev/null @@ -1,1459 +0,0 @@ - - - - - - -Network Working Group L. Barbato -Request for Comments: 5215 Xiph -Category: Standards Track August 2008 - - - RTP Payload Format for Vorbis Encoded Audio - -Status of This Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Abstract - - This document describes an RTP payload format for transporting Vorbis - encoded audio. It details the RTP encapsulation mechanism for raw - Vorbis data and the delivery mechanisms for the decoder probability - model (referred to as a codebook), as well as other setup - information. - - Also included within this memo are media type registrations and the - details necessary for the use of Vorbis with the Session Description - Protocol (SDP). - - - - - - - - - - - - - - - - - - - - - - - - - -Barbato Standards Track [Page 1] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - -Table of Contents - - 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 - 1.1. Conformance and Document Conventions . . . . . . . . . . . 3 - 2. Payload Format . . . . . . . . . . . . . . . . . . . . . . . . 3 - 2.1. RTP Header . . . . . . . . . . . . . . . . . . . . . . . . 4 - 2.2. Payload Header . . . . . . . . . . . . . . . . . . . . . . 5 - 2.3. Payload Data . . . . . . . . . . . . . . . . . . . . . . . 6 - 2.4. Example RTP Packet . . . . . . . . . . . . . . . . . . . . 8 - 3. Configuration Headers . . . . . . . . . . . . . . . . . . . . 8 - 3.1. In-band Header Transmission . . . . . . . . . . . . . . . 9 - 3.1.1. Packed Configuration . . . . . . . . . . . . . . . . . 10 - 3.2. Out of Band Transmission . . . . . . . . . . . . . . . . . 12 - 3.2.1. Packed Headers . . . . . . . . . . . . . . . . . . . . 12 - 3.3. Loss of Configuration Headers . . . . . . . . . . . . . . 13 - 4. Comment Headers . . . . . . . . . . . . . . . . . . . . . . . 13 - 5. Frame Packetization . . . . . . . . . . . . . . . . . . . . . 14 - 5.1. Example Fragmented Vorbis Packet . . . . . . . . . . . . . 15 - 5.2. Packet Loss . . . . . . . . . . . . . . . . . . . . . . . 17 - 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 18 - 6.1. Packed Headers IANA Considerations . . . . . . . . . . . . 19 - 7. SDP Related Considerations . . . . . . . . . . . . . . . . . . 20 - 7.1. Mapping Media Type Parameters into SDP . . . . . . . . . . 20 - 7.1.1. SDP Example . . . . . . . . . . . . . . . . . . . . . 21 - 7.2. Usage with the SDP Offer/Answer Model . . . . . . . . . . 22 - 8. Congestion Control . . . . . . . . . . . . . . . . . . . . . . 22 - 9. Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 - 9.1. Stream Radio . . . . . . . . . . . . . . . . . . . . . . . 22 - 10. Security Considerations . . . . . . . . . . . . . . . . . . . 23 - 11. Copying Conditions . . . . . . . . . . . . . . . . . . . . . . 23 - 12. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 23 - 13. References . . . . . . . . . . . . . . . . . . . . . . . . . . 24 - 13.1. Normative References . . . . . . . . . . . . . . . . . . . 24 - 13.2. Informative References . . . . . . . . . . . . . . . . . . 25 - - - - - - - - - - - - - - - - - -Barbato Standards Track [Page 2] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - -1. Introduction - - Vorbis is a general purpose perceptual audio codec intended to allow - maximum encoder flexibility, thus allowing it to scale competitively - over an exceptionally wide range of bit rates. At the high quality/ - bitrate end of the scale (CD or DAT rate stereo, 16/24 bits), it is - in the same league as MPEG-4 AAC. Vorbis is also intended for lower - and higher sample rates (from 8kHz telephony to 192kHz digital - masters) and a range of channel representations (monaural, - polyphonic, stereo, quadraphonic, 5.1, ambisonic, or up to 255 - discrete channels). - - Vorbis encoded audio is generally encapsulated within an Ogg format - bitstream [RFC3533], which provides framing and synchronization. For - the purposes of RTP transport, this layer is unnecessary, and so raw - Vorbis packets are used in the payload. - -1.1. Conformance and Document Conventions - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this - document are to be interpreted as described in BCP 14, [RFC2119] and - indicate requirement levels for compliant implementations. - Requirements apply to all implementations unless otherwise stated. - - An implementation is a software module that supports one of the media - types defined in this document. Software modules may support - multiple media types, but conformance is considered individually for - each type. - - Implementations that fail to satisfy one or more "MUST" requirements - are considered non-compliant. Implementations that satisfy all - "MUST" requirements, but fail to satisfy one or more "SHOULD" - requirements, are said to be "conditionally compliant". All other - implementations are "unconditionally compliant". - -2. Payload Format - - For RTP-based transport of Vorbis-encoded audio, the standard RTP - header is followed by a 4-octet payload header, and then the payload - data. The payload headers are used to associate the Vorbis data with - its associated decoding codebooks as well as indicate if the - following packet contains fragmented Vorbis data and/or the number of - whole Vorbis data frames. The payload data contains the raw Vorbis - bitstream information. There are 3 types of Vorbis data; an RTP - payload MUST contain just one of them at a time. - - - - - -Barbato Standards Track [Page 3] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - -2.1. RTP Header - - The format of the RTP header is specified in [RFC3550] and shown in - Figure 1. This payload format uses the fields of the header in a - manner consistent with that specification. - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |V=2|P|X| CC |M| PT | sequence number | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | timestamp | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | synchronization source (SSRC) identifier | - +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - | contributing source (CSRC) identifiers | - | ... | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 1: RTP Header - - The RTP header begins with an octet of fields (V, P, X, and CC) to - support specialized RTP uses (see [RFC3550] and [RFC3551] for - details). For Vorbis RTP, the following values are used. - - Version (V): 2 bits - - This field identifies the version of RTP. The version used by this - specification is two (2). - - Padding (P): 1 bit - - Padding MAY be used with this payload format according to Section 5.1 - of [RFC3550]. - - Extension (X): 1 bit - - The Extension bit is used in accordance with [RFC3550]. - - CSRC count (CC): 4 bits - - The CSRC count is used in accordance with [RFC3550]. - - Marker (M): 1 bit - - Set to zero. Audio silence suppression is not used. This conforms - to Section 4.1 of [VORBIS-SPEC-REF]. - - - - -Barbato Standards Track [Page 4] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - Payload Type (PT): 7 bits - - An RTP profile for a class of applications is expected to assign a - payload type for this format, or a dynamically allocated payload type - SHOULD be chosen that designates the payload as Vorbis. - - Sequence number: 16 bits - - The sequence number increments by one for each RTP data packet sent, - and may be used by the receiver to detect packet loss and to restore - the packet sequence. This field is detailed further in [RFC3550]. - - Timestamp: 32 bits - - A timestamp representing the sampling time of the first sample of the - first Vorbis packet in the RTP payload. The clock frequency MUST be - set to the sample rate of the encoded audio data and is conveyed out- - of-band (e.g., as an SDP parameter). - - SSRC/CSRC identifiers: - - These two fields, 32 bits each with one SSRC field and a maximum of - 16 CSRC fields, are as defined in [RFC3550]. - -2.2. Payload Header - - The 4 octets following the RTP Header section are the Payload Header. - This header is split into a number of bit fields detailing the format - of the following payload data packets. - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Ident | F |VDT|# pkts.| - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 2: Payload Header - - Ident: 24 bits - - This 24-bit field is used to associate the Vorbis data to a decoding - Configuration. It is stored as a network byte order integer. - - Fragment type (F): 2 bits - - - - - - - -Barbato Standards Track [Page 5] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - This field is set according to the following list: - - 0 = Not Fragmented - - 1 = Start Fragment - - 2 = Continuation Fragment - - 3 = End Fragment - - Vorbis Data Type (VDT): 2 bits - - This field specifies the kind of Vorbis data stored in this RTP - packet. There are currently three different types of Vorbis - payloads. Each packet MUST contain only a single type of Vorbis - packet (e.g., you must not aggregate configuration and comment - packets in the same RTP payload). - - 0 = Raw Vorbis payload - - 1 = Vorbis Packed Configuration payload - - 2 = Legacy Vorbis Comment payload - - 3 = Reserved - - The packets with a VDT of value 3 MUST be ignored. - - The last 4 bits represent the number of complete packets in this - payload. This provides for a maximum number of 15 Vorbis packets in - the payload. If the payload contains fragmented data, the number of - packets MUST be set to 0. - -2.3. Payload Data - - Raw Vorbis packets are currently unbounded in length; application - profiles will likely define a practical limit. Typical Vorbis packet - sizes range from very small (2-3 bytes) to quite large (8-12 - kilobytes). The reference implementation [LIBVORBIS] typically - produces packets less than ~800 bytes, except for the setup header - packets, which are ~4-12 kilobytes. Within an RTP context, to avoid - fragmentation, the Vorbis data packet size SHOULD be kept - sufficiently small so that after adding the RTP and payload headers, - the complete RTP packet is smaller than the path MTU. - - - - - - - -Barbato Standards Track [Page 6] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | length | vorbis packet data .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 3: Payload Data Header - - Each Vorbis payload packet starts with a two octet length header, - which is used to represent the size in bytes of the following data - payload, and is followed by the raw Vorbis data padded to the nearest - byte boundary, as explained by the Vorbis I Specification - [VORBIS-SPEC-REF]. The length value is stored as a network byte - order integer. - - For payloads that consist of multiple Vorbis packets, the payload - data consists of the packet length followed by the packet data for - each of the Vorbis packets in the payload. - - The Vorbis packet length header is the length of the Vorbis data - block only and does not include the length field. - - The payload packing of the Vorbis data packets MUST follow the - guidelines set out in [RFC3551], where the oldest Vorbis packet - occurs immediately after the RTP packet header. Subsequent Vorbis - packets, if any, MUST follow in temporal order. - - Audio channel mapping is in accordance with the Vorbis I - Specification [VORBIS-SPEC-REF]. - - - - - - - - - - - - - - - - - - - - - - -Barbato Standards Track [Page 7] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - -2.4. Example RTP Packet - - Here is an example RTP payload containing two Vorbis packets. - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | 2 |0|0| 0 |0| PT | sequence number | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | timestamp (in sample rate units) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | synchronisation source (SSRC) identifier | - +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - | contributing source (CSRC) identifiers | - | ... | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Ident | 0 | 0 | 2 pks | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | length | vorbis data .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. vorbis data | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | length | next vorbis packet data .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. vorbis data .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. vorbis data | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 4: Example Raw Vorbis Packet - - The payload data section of the RTP packet begins with the 24-bit - Ident field followed by the one octet bit field header, which has the - number of Vorbis frames set to 2. Each of the Vorbis data frames is - prefixed by the two octets length field. The Packet Type and - Fragment Type are set to 0. The Configuration that will be used to - decode the packets is the one indexed by the ident value. - -3. Configuration Headers - - Unlike other mainstream audio codecs, Vorbis has no statically - configured probability model. Instead, it packs all entropy decoding - configuration, Vector Quantization and Huffman models into a data - block that must be transmitted to the decoder with the compressed - data. A decoder also requires information detailing the number of - audio channels, bitrates, and similar information to configure itself - for a particular compressed data stream. These two blocks of - - - -Barbato Standards Track [Page 8] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - information are often referred to collectively as the "codebooks" for - a Vorbis stream, and are included as special "header" packets at the - start of the compressed data. In addition, the Vorbis I - specification [VORBIS-SPEC-REF] requires the presence of a comment - header packet that gives simple metadata about the stream, but this - information is not required for decoding the frame sequence. - - Thus, these two codebook header packets must be received by the - decoder before any audio data can be interpreted. These requirements - pose problems in RTP, which is often used over unreliable transports. - - Since this information must be transmitted reliably and, as the RTP - stream may change certain configuration data mid-session, there are - different methods for delivering this configuration data to a client, - both in-band and out-of-band, which are detailed below. In order to - set up an initial state for the client application, the configuration - MUST be conveyed via the signalling channel used to set up the - session. One example of such signalling is SDP [RFC4566] with the - Offer/Answer Model [RFC3264]. Changes to the configuration MAY be - communicated via a re-invite, conveying a new SDP, or sent in-band in - the RTP channel. Implementations MUST support an in-band delivery of - updated codebooks, and SHOULD support out-of-band codebook update - using a new SDP file. The changes may be due to different codebooks - as well as different bitrates of the RTP stream. - - For non-chained streams, the recommended Configuration delivery - method is inside the Packed Configuration (Section 3.1.1) in the SDP - as explained the Mapping Media Type Parameters into SDP - (Section 7.1). - - The 24-bit Ident field is used to map which Configuration will be - used to decode a packet. When the Ident field changes, it indicates - that a change in the stream has taken place. The client application - MUST have in advance the correct configuration. If the client - detects a change in the Ident value and does not have this - information, it MUST NOT decode the raw associated Vorbis data until - it fetches the correct Configuration. - -3.1. In-band Header Transmission - - The Packed Configuration (Section 3.1.1) Payload is sent in-band with - the packet type bits set to match the Vorbis Data Type. Clients MUST - be capable of dealing with fragmentation and periodic re-transmission - of [RFC4588] the configuration headers. The RTP timestamp value MUST - reflect the transmission time of the first data packet for which this - configuration applies. - - - - - -Barbato Standards Track [Page 9] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - -3.1.1. Packed Configuration - - A Vorbis Packed Configuration is indicated with the Vorbis Data Type - field set to 1. Of the three headers defined in the Vorbis I - specification [VORBIS-SPEC-REF], the Identification and the Setup - MUST be packed as they are, while the Comment header MAY be replaced - with a dummy one. - - The packed configuration stores Xiph codec configurations in a - generic way: the first field stores the number of the following - packets minus one (count field), the next ones represent the size of - the headers (length fields), and the headers immediately follow the - list of length fields. The size of the last header is implicit. - - The count and the length fields are encoded using the following - logic: the data is in network byte order; every byte has the most - significant bit used as a flag, and the following 7 bits are used to - store the value. The first 7 most significant bits are stored in the - first byte. If there are remaining bits, the flag bit is set to 1 - and the subsequent 7 bits are stored in the following byte. If there - are remaining bits, set the flag to 1 and the same procedure is - repeated. The ending byte has the flag bit set to 0. To decode, - simply iterate over the bytes until the flag bit is set to 0. For - every byte, the data is added to the accumulated value multiplied by - 128. - - The headers are packed in the same order as they are present in Ogg - [VORBIS-SPEC-REF]: Identification, Comment, Setup. - - The 2 byte length tag defines the length of the packed headers as the - sum of the Configuration, Comment, and Setup lengths. - - - - - - - - - - - - - - - - - - - - -Barbato Standards Track [Page 10] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |V=2|P|X| CC |M| PT | xxxx | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | xxxxx | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | synchronization source (SSRC) identifier | - +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - | contributing source (CSRC) identifiers | - | ... | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Ident | 0 | 1 | 1| - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | length | n. of headers | length1 | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | length2 | Identification .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Identification .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Identification .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Identification .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Identification | Comment .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Comment .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Comment .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Comment .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Comment | Setup .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Setup .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Setup .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 5: Packed Configuration Figure - - The Ident field is set with the value that will be used by the Raw - Payload Packets to address this Configuration. The Fragment type is - set to 0 because the packet bears the full Packed configuration. The - number of the packet is set to 1. - - - - - -Barbato Standards Track [Page 11] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - -3.2. Out of Band Transmission - - The following packet definition MUST be used when Configuration is - inside in the SDP. - -3.2.1. Packed Headers - - As mentioned above, the RECOMMENDED delivery vector for Vorbis - configuration data is via a retrieval method that can be performed - using a reliable transport protocol. As the RTP headers are not - required for this method of delivery, the structure of the - configuration data is slightly different. The packed header starts - with a 32-bit (network-byte ordered) count field, which details the - number of packed headers that are contained in the bundle. The - following shows the Packed header payload for each chained Vorbis - stream. - - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Number of packed headers | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Packed header | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Packed header | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 6: Packed Headers Overview - - - - - - - - - - - - - - - - - - - - - - - -Barbato Standards Track [Page 12] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Ident | length .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. | n. of headers | length1 | length2 .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. | Identification Header .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ................................................................. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. | Comment Header .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ................................................................. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Comment Header | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Setup Header .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ................................................................. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Setup Header | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 7: Packed Headers Detail - - The key difference between the in-band format and this one is that - there is no need for the payload header octet. In this figure, the - comment has a size bigger than 127 bytes. - -3.3. Loss of Configuration Headers - - Unlike the loss of raw Vorbis payload data, loss of a configuration - header leads to a situation where it will not be possible to - successfully decode the stream. Implementations MAY try to recover - from an error by requesting again the missing Configuration or, if - the delivery method is in-band, by buffering the payloads waiting for - the Configuration needed to decode them. The baseline reaction - SHOULD either be reset or end the RTP session. - -4. Comment Headers - - Vorbis Data Type flag set to 2 indicates that the packet contains the - comment metadata, such as artist name, track title, and so on. These - metadata messages are not intended to be fully descriptive but rather - to offer basic track/song information. Clients MAY ignore it - completely. The details on the format of the comments can be found - in the Vorbis I Specification [VORBIS-SPEC-REF]. - - - -Barbato Standards Track [Page 13] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |V=2|P|X| CC |M| PT | xxxx | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | xxxxx | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | synchronization source (SSRC) identifier | - +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - | contributing source (CSRC) identifiers | - | ... | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Ident | 0 | 2 | 1| - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | length | Comment .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Comment .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. Comment | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 8: Comment Packet - - The 2-byte length field is necessary since this packet could be - fragmented. - -5. Frame Packetization - - Each RTP payload contains either one Vorbis packet fragment or an - integer number of complete Vorbis packets (up to a maximum of 15 - packets, since the number of packets is defined by a 4-bit value). - - Any Vorbis data packet that is less than path MTU SHOULD be bundled - in the RTP payload with as many Vorbis packets as will fit, up to a - maximum of 15, except when such bundling would exceed an - application's desired transmission latency. Path MTU is detailed in - [RFC1191] and [RFC1981]. - - A fragmented packet has a zero in the last four bits of the payload - header. The first fragment will set the Fragment type to 1. Each - fragment after the first will set the Fragment type to 2 in the - payload header. The consecutive fragments MUST be sent without any - other payload being sent between the first and the last fragment. - The RTP payload containing the last fragment of the Vorbis packet - will have the Fragment type set to 3. To maintain the correct - sequence for fragmented packet reception, the timestamp field of - fragmented packets MUST be the same as the first packet sent, with - - - -Barbato Standards Track [Page 14] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - the sequence number incremented as normal for the subsequent RTP - payloads; this will affect the RTCP jitter measurement. The length - field shows the fragment length. - -5.1. Example Fragmented Vorbis Packet - - Here is an example of a fragmented Vorbis packet split over three RTP - payloads. Each of them contains the standard RTP headers as well as - the 4-octet Vorbis headers. - - Packet 1: - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |V=2|P|X| CC |M| PT | 1000 | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | 12345 | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | synchronization source (SSRC) identifier | - +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - | contributing source (CSRC) identifiers | - | ... | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Ident | 1 | 0 | 0| - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | length | vorbis data .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. vorbis data | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 9: Example Fragmented Packet (Packet 1) - - In this payload, the initial sequence number is 1000 and the - timestamp is 12345. The Fragment type is set to 1, the number of - packets field is set to 0, and as the payload is raw Vorbis data, the - VDT field is set to 0. - - - - - - - - - - - - - -Barbato Standards Track [Page 15] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - Packet 2: - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |V=2|P|X| CC |M| PT | 1001 | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | 12345 | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | synchronization source (SSRC) identifier | - +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - | contributing source (CSRC) identifiers | - | ... | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Ident | 2 | 0 | 0| - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | length | vorbis data .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. vorbis data | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 10: Example Fragmented Packet (Packet 2) - - The Fragment type field is set to 2, and the number of packets field - is set to 0. For large Vorbis fragments, there can be several of - these types of payloads. The maximum packet size SHOULD be no - greater than the path MTU, including all RTP and payload headers. - The sequence number has been incremented by one, but the timestamp - field remains the same as the initial payload. - - - - - - - - - - - - - - - - - - - - - -Barbato Standards Track [Page 16] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - Packet 3: - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |V=2|P|X| CC |M| PT | 1002 | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | 12345 | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | synchronization source (SSRC) identifier | - +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - | contributing source (CSRC) identifiers | - | ... | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Ident | 3 | 0 | 0| - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | length | vorbis data .. - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - .. vorbis data | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - Figure 11: Example Fragmented Packet (Packet 3) - - This is the last Vorbis fragment payload. The Fragment type is set - to 3 and the packet count remains set to 0. As in the previous - payloads, the timestamp remains set to the first payload timestamp in - the sequence and the sequence number has been incremented. - -5.2. Packet Loss - - As there is no error correction within the Vorbis stream, packet loss - will result in a loss of signal. Packet loss is more of an issue for - fragmented Vorbis packets as the client will have to cope with the - handling of the Fragment Type. In case of loss of fragments, the - client MUST discard all the remaining Vorbis fragments and decode the - incomplete packet. If we use the fragmented Vorbis packet example - above and the first RTP payload is lost, the client MUST detect that - the next RTP payload has the packet count field set to 0 and the - Fragment type 2 and MUST drop it. The next RTP payload, which is the - final fragmented packet, MUST be dropped in the same manner. If the - missing RTP payload is the last, the two fragments received will be - kept and the incomplete Vorbis packet decoded. - - Loss of any of the Configuration fragment will result in the loss of - the full Configuration packet with the result detailed in the Loss of - Configuration Headers (Section 3.3) section. - - - - -Barbato Standards Track [Page 17] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - -6. IANA Considerations - - Type name: audio - - Subtype name: vorbis - - Required parameters: - - rate: indicates the RTP timestamp clock rate as described in RTP - Profile for Audio and Video Conferences with Minimal Control - [RFC3551]. - - channels: indicates the number of audio channels as described in - RTP Profile for Audio and Video Conferences with Minimal - Control [RFC3551]. - - configuration: the base64 [RFC4648] representation of the Packed - Headers (Section 3.2.1). - - Encoding considerations: - - This media type is framed and contains binary data. - - Security considerations: - - See Section 10 of RFC 5215. - - Interoperability considerations: - - None - - Published specification: - - RFC 5215 - - Ogg Vorbis I specification: Codec setup and packet decode. - Available from the Xiph website, http://xiph.org/ - - Applications which use this media type: - - Audio streaming and conferencing tools - - Additional information: - - None - - - - - - -Barbato Standards Track [Page 18] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - Person & email address to contact for further information: - - Luca Barbato: - IETF Audio/Video Transport Working Group - - Intended usage: - - COMMON - - Restriction on usage: - - This media type depends on RTP framing, hence is only defined for - transfer via RTP [RFC3550]. - - Author: - - Luca Barbato - - Change controller: - - IETF AVT Working Group delegated from the IESG - -6.1. Packed Headers IANA Considerations - - The following IANA considerations refers to the split configuration - Packed Headers (Section 3.2.1) used within RFC 5215. - - Type name: audio - - Subtype name: vorbis-config - - Required parameters: - - None - - Optional parameters: - - None - - Encoding considerations: - - This media type contains binary data. - - Security considerations: - - See Section 10 of RFC 5215. - - - - - -Barbato Standards Track [Page 19] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - Interoperability considerations: - - None - - Published specification: - - RFC 5215 - - Applications which use this media type: - - Vorbis encoded audio, configuration data - - Additional information: - - None - - Person & email address to contact for further information: - - Luca Barbato: - IETF Audio/Video Transport Working Group - - Intended usage: COMMON - - Restriction on usage: - - This media type doesn't depend on the transport. - - Author: - - Luca Barbato - - Change controller: - - IETF AVT Working Group delegated from the IESG - -7. SDP Related Considerations - - The following paragraphs define the mapping of the parameters - described in the IANA considerations section and their usage in the - Offer/Answer Model [RFC3264]. In order to be forward compatible, the - implementation MUST ignore unknown parameters. - -7.1. Mapping Media Type Parameters into SDP - - The information carried in the Media Type specification has a - specific mapping to fields in the Session Description Protocol (SDP) - [RFC4566], which is commonly used to describe RTP sessions. When SDP - is used to specify sessions, the mapping are as follows: - - - -Barbato Standards Track [Page 20] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - o The type name ("audio") goes in SDP "m=" as the media name. - - o The subtype name ("vorbis") goes in SDP "a=rtpmap" as the encoding - name. - - o The parameter "rate" also goes in "a=rtpmap" as the clock rate. - - o The parameter "channels" also goes in "a=rtpmap" as the channel - count. - - o The mandated parameters "configuration" MUST be included in the - SDP "a=fmtp" attribute. - - If the stream comprises chained Vorbis files and all of them are - known in advance, the Configuration Packet for each file SHOULD be - passed to the client using the configuration attribute. - - The port value is specified by the server application bound to the - address specified in the c= line. The channel count value specified - in the rtpmap attribute SHOULD match the current Vorbis stream or - should be considered the maximum number of channels to be expected. - The timestamp clock rate MUST be a multiple of the sample rate; a - different payload number MUST be used if the clock rate changes. The - Configuration payload delivers the exact information, thus the SDP - information SHOULD be considered a hint. An example is found below. - -7.1.1. SDP Example - - The following example shows a basic SDP single stream. The first - configuration packet is inside the SDP; other configurations could be - fetched at any time from the URIs provided. The following base64 - [RFC4648] configuration string is folded in this example due to RFC - line length limitations. - - c=IN IP4 192.0.2.1 - - m=audio RTP/AVP 98 - - a=rtpmap:98 vorbis/44100/2 - - a=fmtp:98 configuration=AAAAAZ2f4g9NAh4aAXZvcmJpcwA...; - - Note that the payload format (encoding) names are commonly shown in - uppercase. Media Type subtypes are commonly shown in lowercase. - These names are case-insensitive in both places. Similarly, - parameter names are case-insensitive both in Media Type types and in - the default mapping to the SDP a=fmtp attribute. The a=fmtp line is - - - - -Barbato Standards Track [Page 21] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - a single line, even if it is shown as multiple lines in this document - for clarity. - -7.2. Usage with the SDP Offer/Answer Model - - There are no negotiable parameters. All of them are declarative. - -8. Congestion Control - - The general congestion control considerations for transporting RTP - data apply to Vorbis audio over RTP as well. See the RTP - specification [RFC3550] and any applicable RTP profile (e.g., - [RFC3551]). Audio data can be encoded using a range of different bit - rates, so it is possible to adapt network bandwidth by adjusting the - encoder bit rate in real time or by having multiple copies of content - encoded at different bit rates. - -9. Example - - The following example shows a common usage pattern that MAY be - applied in such a situation. The main scope of this section is to - explain better usage of the transmission vectors. - -9.1. Stream Radio - - This is one of the most common situations: there is one single server - streaming content in multicast, and the clients may start a session - at a random time. The content itself could be a mix of a live stream - (as the webjockey's voice) and stored streams (as the music she - plays). - - In this situation, we don't know in advance how many codebooks we - will use. The clients can join anytime and users expect to start - listening to the content in a short time. - - Upon joining, the client will receive the current Configuration - necessary to decode the current stream inside the SDP so that the - decoding will start immediately after. - - When the streamed content changes, the new Configuration is sent in- - band before the actual stream, and the Configuration that has to be - sent inside the SDP is updated. Since the in-band method is - unreliable, an out-of-band fallback is provided. - - The client may choose to fetch the Configuration from the alternate - source as soon as it discovers a Configuration packet got lost in- - band, or use selective retransmission [RFC3611] if the server - supports this feature. - - - -Barbato Standards Track [Page 22] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - A server-side optimization would be to keep a hash list of the - Configurations per session, which avoids packing all of them and - sending the same Configuration with different Ident tags. - - A client-side optimization would be to keep a tag list of the - Configurations per session and not process configuration packets that - are already known. - -10. Security Considerations - - RTP packets using this payload format are subject to the security - considerations discussed in the RTP specification [RFC3550], the - base64 specification [RFC4648], and the URI Generic syntax - specification [RFC3986]. Among other considerations, this implies - that the confidentiality of the media stream is achieved by using - encryption. Because the data compression used with this payload - format is applied end-to-end, encryption may be performed on the - compressed data. - -11. Copying Conditions - - The authors agree to grant third parties the irrevocable right to - copy, use, and distribute the work, with or without modification, in - any medium, without royalty, provided that, unless separate - permission is granted, redistributed modified works do not contain - misleading author, version, name of work, or endorsement information. - -12. Acknowledgments - - This document is a continuation of the following documents: - - Moffitt, J., "RTP Payload Format for Vorbis Encoded Audio", February - 2001. - - Kerr, R., "RTP Payload Format for Vorbis Encoded Audio", December - 2004. - - The Media Type declaration is a continuation of the following - document: - - Short, B., "The audio/rtp-vorbis MIME Type", January 2008. - - Thanks to the AVT, Vorbis Communities / Xiph.Org Foundation including - Steve Casner, Aaron Colwell, Ross Finlayson, Fluendo, Ramon Garcia, - Pascal Hennequin, Ralph Giles, Tor-Einar Jarnbjo, Colin Law, John - Lazzaro, Jack Moffitt, Christopher Montgomery, Colin Perkins, Barry - Short, Mike Smith, Phil Kerr, Michael Sparks, Magnus Westerlund, - David Barrett, Silvia Pfeiffer, Stefan Ehmann, Gianni Ceccarelli, and - - - -Barbato Standards Track [Page 23] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - - Alessandro Salvatori. Thanks to the LScube Group, in particular - Federico Ridolfo, Francesco Varano, Giampaolo Mancini, Dario - Gallucci, and Juan Carlos De Martin. - -13. References - -13.1. Normative References - - [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", - RFC 1191, November 1990. - - [RFC1981] McCann, J., Deering, S., and J. Mogul, "Path MTU - Discovery for IP version 6", RFC 1981, - August 1996. - - [RFC2119] Bradner, S., "Key words for use in RFCs to - Indicate Requirement Levels", BCP 14, RFC 2119, - March 1997. - - [RFC3264] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer - Model with Session Description Protocol (SDP)", - RFC 3264, June 2002. - - [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. - Jacobson, "RTP: A Transport Protocol for Real-Time - Applications", STD 64, RFC 3550, July 2003. - - [RFC3551] Schulzrinne, H. and S. Casner, "RTP Profile for - Audio and Video Conferences with Minimal Control", - STD 65, RFC 3551, July 2003. - - [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, - "Uniform Resource Identifier (URI): Generic - Syntax", STD 66, RFC 3986, January 2005. - - [RFC4566] Handley, M., Jacobson, V., and C. Perkins, "SDP: - Session Description Protocol", RFC 4566, - July 2006. - - [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 - Data Encodings", RFC 4648, October 2006. - - [VORBIS-SPEC-REF] "Ogg Vorbis I specification: Codec setup and - packet decode. Available from the Xiph website, - http://xiph.org/vorbis/doc/Vorbis_I_spec.html". - - - - - - -Barbato Standards Track [Page 24] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - -13.2. Informative References - - [LIBVORBIS] "libvorbis: Available from the dedicated website, - http://vorbis.com/". - - [RFC3533] Pfeiffer, S., "The Ogg Encapsulation Format - Version 0", RFC 3533, May 2003. - - [RFC3611] Friedman, T., Caceres, R., and A. Clark, "RTP - Control Protocol Extended Reports (RTCP XR)", - RFC 3611, November 2003. - - [RFC4588] Rey, J., Leon, D., Miyazaki, A., Varsa, V., and R. - Hakenberg, "RTP Retransmission Payload Format", - RFC 4588, July 2006. - -Author's Address - - Luca Barbato - Xiph.Org Foundation - - EMail: lu_zero@gentoo.org - URI: http://xiph.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Barbato Standards Track [Page 25] - -RFC 5215 Vorbis RTP Payload Format August 2008 - - -Full Copyright Statement - - Copyright (C) The IETF Trust (2008). - - This document is subject to the rights, licenses and restrictions - contained in BCP 78, and except as set forth therein, the authors - retain all their rights. - - This document and the information contained herein are provided on an - "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS - OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND - THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF - THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED - WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -Intellectual Property - - The IETF takes no position regarding the validity or scope of any - Intellectual Property Rights or other rights that might be claimed to - pertain to the implementation or use of the technology described in - this document or the extent to which any license under such rights - might or might not be available; nor does it represent that it has - made any independent effort to identify any such rights. Information - on the procedures with respect to rights in RFC documents can be - found in BCP 78 and BCP 79. - - Copies of IPR disclosures made to the IETF Secretariat and any - assurances of licenses to be made available, or the result of an - attempt made to obtain a general license or permission for the use of - such proprietary rights by implementers or users of this - specification can be obtained from the IETF on-line IPR repository at - http://www.ietf.org/ipr. - - The IETF invites any interested party to bring to its attention any - copyrights, patents or patent applications, or other proprietary - rights that may cover technology that may be required to implement - this standard. Please address the information to the IETF at - ietf-ipr@ietf.org. - - - - - - - - - - - - -Barbato Standards Track [Page 26] - diff --git a/Engine/lib/libvorbis/doc/rfc5215.xml b/Engine/lib/libvorbis/doc/rfc5215.xml deleted file mode 100644 index 719c10043..000000000 --- a/Engine/lib/libvorbis/doc/rfc5215.xml +++ /dev/null @@ -1,1176 +0,0 @@ - - - - - - - - - - - - -RTP Payload Format for Vorbis Encoded Audio - - -Xiph.Org Foundation -
    -lu_zero@gentoo.org -http://xiph.org/ -
    -
    - - - -General -AVT Working Group -I-D - -Internet-Draft -Vorbis -RTP - -example - - - - -This document describes an RTP payload format for transporting Vorbis encoded -audio. It details the RTP encapsulation mechanism for raw Vorbis data and -the delivery mechanisms for the decoder probability model (referred to -as a codebook), as well as other setup information. - - - -Also included within this memo are media type registrations and the details -necessary for the use of Vorbis with the Session Description Protocol (SDP). - - - - -
    - - - -
    - - -Vorbis is a general purpose perceptual audio codec intended to allow -maximum encoder flexibility, thus allowing it to scale competitively -over an exceptionally wide range of bit rates. At the high -quality/bitrate end of the scale (CD or DAT rate stereo, 16/24 bits), it -is in the same league as MPEG-4 AAC. -Vorbis is also intended for lower and higher sample rates (from -8kHz telephony to 192kHz digital masters) and a range of channel -representations (monaural, polyphonic, stereo, quadraphonic, 5.1, -ambisonic, or up to 255 discrete channels). - - - -Vorbis encoded audio is generally encapsulated within an Ogg format bitstream -, which provides framing and synchronization. -For the purposes of RTP transport, this layer is unnecessary, and so raw Vorbis -packets are used in the payload. - - -
    - -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14, and indicate requirement levels for compliant implementations. Requirements apply to all implementations unless otherwise stated. -An implementation is a software module that supports one of the media types defined in this document. Software modules may support multiple media types, but conformance is considered individually for each type. -Implementations that fail to satisfy one or more "MUST" requirements are considered non-compliant. Implementations that satisfy all "MUST" requirements, but fail to satisfy one or more "SHOULD" requirements, are said to be "conditionally compliant". All other implementations are "unconditionally compliant". - -
    -
    - -
    - - -For RTP-based transport of Vorbis-encoded audio, the standard RTP header is -followed by a 4-octet payload header, and then the payload data. The payload -headers are used to associate the Vorbis data with its associated decoding -codebooks as well as indicate if the following packet contains fragmented -Vorbis data and/or the number of whole Vorbis data frames. The payload data -contains the raw Vorbis bitstream information. There are 3 types of Vorbis -data; an RTP payload MUST contain just one of them at a time. - - -
    - - -The format of the RTP header is specified in -and shown in . This payload format -uses the fields of the header in a manner consistent with that specification. - - - -
    - -
    -
    - - -The RTP header begins with an octet of fields (V, P, X, and CC) to support -specialized RTP uses (see and - for details). For Vorbis RTP, the following -values are used. - - - -Version (V): 2 bits - -This field identifies the version of RTP. The version used by this -specification is two (2). - - - -Padding (P): 1 bit - -Padding MAY be used with this payload format according to Section 5.1 of -. - - - -Extension (X): 1 bit - -The Extension bit is used in accordance with . - - - -CSRC count (CC): 4 bits - -The CSRC count is used in accordance with . - - - -Marker (M): 1 bit - -Set to zero. Audio silence suppression is not used. This conforms to Section 4.1 -of . - - - -Payload Type (PT): 7 bits - -An RTP profile for a class of applications is expected to assign a payload type -for this format, or a dynamically allocated payload type SHOULD be chosen that -designates the payload as Vorbis. - - - -Sequence number: 16 bits - -The sequence number increments by one for each RTP data packet sent, and may be -used by the receiver to detect packet loss and to restore the packet sequence. This -field is detailed further in . - - - -Timestamp: 32 bits - -A timestamp representing the sampling time of the first sample of the first -Vorbis packet in the RTP payload. The clock frequency MUST be set to the sample -rate of the encoded audio data and is conveyed out-of-band (e.g., as an SDP parameter). - - - -SSRC/CSRC identifiers: - -These two fields, 32 bits each with one SSRC field and a maximum of 16 CSRC -fields, are as defined in -. - - -
    - -
    - - -The 4 octets following the RTP Header section are the Payload Header. This -header is split into a number of bit fields detailing the format of the -following payload data packets. - - -
    - -
    - - -Ident: 24 bits - -This 24-bit field is used to associate the Vorbis data to a decoding -Configuration. It is stored as a network byte order integer. - - - -Fragment type (F): 2 bits - -This field is set according to the following list: - - - - 0 = Not Fragmented - 1 = Start Fragment - 2 = Continuation Fragment - 3 = End Fragment - - - -Vorbis Data Type (VDT): 2 bits - -This field specifies the kind of Vorbis data stored in this RTP packet. There -are currently three different types of Vorbis payloads. Each packet MUST contain only a single type of Vorbis packet (e.g., you must not aggregate configuration and comment packets in the same RTP payload). - - - - - 0 = Raw Vorbis payload - 1 = Vorbis Packed Configuration payload - 2 = Legacy Vorbis Comment payload - 3 = Reserved - - - The packets with a VDT of value 3 MUST be ignored. - - -The last 4 bits represent the number of complete packets in this payload. This -provides for a maximum number of 15 Vorbis packets in the payload. If the -payload contains fragmented data, the number of packets MUST be set to 0. - - -
    - -
    - - -Raw Vorbis packets are currently unbounded in length; application profiles will -likely define a practical limit. Typical Vorbis packet sizes range from very -small (2-3 bytes) to quite large (8-12 kilobytes). The reference implementation - typically produces packets less than ~800 -bytes, except for the setup header packets, which are ~4-12 kilobytes. Within an -RTP context, to avoid fragmentation, the Vorbis data packet size SHOULD be kept -sufficiently small so that after adding the RTP and payload headers, the -complete RTP packet is smaller than the path MTU. - - -
    - -
    - - -Each Vorbis payload packet starts with a two octet length header, which is used -to represent the size in bytes of the following data payload, and is followed by the -raw Vorbis data padded to the nearest byte boundary, as explained by the Vorbis I Specification. The length value is stored -as a network byte order integer. - - - -For payloads that consist of multiple Vorbis packets, the payload data consists -of the packet length followed by the packet data for each of the Vorbis packets -in the payload. - - - -The Vorbis packet length header is the length of the Vorbis data block only and -does not include the length field. - - - -The payload packing of the Vorbis data packets MUST follow the guidelines -set out in , where the oldest Vorbis packet occurs -immediately after the RTP packet header. Subsequent Vorbis packets, if any, MUST -follow in temporal order. - - - -Audio channel mapping is in accordance with the -Vorbis I Specification. - - -
    - -
    - - -Here is an example RTP payload containing two Vorbis packets. - - -
    - -
    - - -The payload data section of the RTP packet begins with the 24-bit Ident field -followed by the one octet bit field header, which has the number of Vorbis -frames set to 2. Each of the Vorbis data frames is prefixed by the two octets -length field. The Packet Type and Fragment Type are set to 0. The Configuration -that will be used to decode the packets is the one indexed by the ident value. - - -
    -
    - - - -
    - - -Unlike other mainstream audio codecs, Vorbis has no statically -configured probability model. Instead, it packs all entropy decoding -configuration, Vector Quantization and Huffman models into a data block -that must be transmitted to the decoder with the compressed data. -A decoder also requires information detailing the number of audio -channels, bitrates, and similar information to configure itself for a -particular compressed data stream. These two blocks of information are -often referred to collectively as the "codebooks" for a Vorbis stream, -and are included as special "header" packets at the start -of the compressed data. In addition, -the Vorbis I specification -requires the presence of a comment header packet that gives simple -metadata about the stream, but this information is not required for -decoding the frame sequence. - - - -Thus, these two codebook header packets must be received by the decoder before -any audio data can be interpreted. These requirements pose problems in RTP, -which is often used over unreliable transports. - - - -Since this information must be transmitted reliably and, as the RTP -stream may change certain configuration data mid-session, there are -different methods for delivering this configuration data to a -client, both in-band and out-of-band, which are detailed below. -In order to set up an initial state for the client application, the -configuration MUST be conveyed via the signalling channel used to set up -the session. One example of such signalling is -SDP with the -Offer/Answer Model. -Changes to the configuration MAY be communicated via a re-invite, -conveying a new SDP, or sent in-band in the RTP channel. -Implementations MUST support an in-band delivery of updated codebooks, -and SHOULD support out-of-band codebook update using a new SDP file. -The changes may be due to different codebooks as well as -different bitrates of the RTP stream. - - -For non-chained streams, the recommended Configuration delivery -method is inside the Packed -Configuration in the SDP as explained the Mapping Media Type -Parameters into SDP. - - - -The 24-bit Ident field is used to map which Configuration will be used to -decode a packet. When the Ident field changes, it indicates that a change in -the stream has taken place. The client application MUST have in advance the -correct configuration. If the client detects a change in the Ident value and -does not have this information, it MUST NOT decode the raw associated Vorbis -data until it fetches the correct Configuration. - - -
    - - -The Packed Configuration Payload is -sent in-band with the packet type bits set to match the Vorbis Data Type. -Clients MUST be capable of dealing with fragmentation and periodic -re-transmission of the configuration headers. -The RTP timestamp value MUST reflect the transmission time of the first data packet for which this configuration applies. - - -
    - - -A Vorbis Packed Configuration is indicated with the Vorbis Data Type field set -to 1. Of the three headers defined in the -Vorbis I specification, the -Identification and the Setup MUST be packed as they are, while the Comment -header MAY be replaced with a dummy one. - -The packed configuration stores Xiph codec -configurations in a generic way: the first field stores the number of the following packets -minus one (count field), the next ones represent the size of the headers -(length fields), and the headers immediately follow the list of length fields. -The size of the last header is implicit. - -The count and the length fields are encoded using the following logic: the data -is in network byte order; every byte has the most significant bit used -as a flag, and the following 7 bits are used to store the value. -The first 7 most significant bits are stored in the first byte. -If there are remaining bits, the flag bit is set to 1 and the subsequent -7 bits are stored in the following byte. -If there are remaining bits, set the flag to 1 and the same procedure is -repeated. -The ending byte has the flag bit set to 0. To decode, simply iterate -over the bytes until the flag bit is set to 0. For every byte, the data -is added to the accumulated value multiplied by 128. - -The headers are packed in the same order as they are present in Ogg : -Identification, Comment, Setup. - - -The 2 byte length tag defines the length of the packed headers as the sum of -the Configuration, Comment, and Setup lengths. - -
    - -
    - -The Ident field is set with the value that will be used by the Raw Payload -Packets to address this Configuration. The Fragment type is set to 0 because the -packet bears the full Packed configuration. The number of the packet is set to 1. -
    -
    - -
    - - -The following packet definition MUST be used when Configuration is inside -in the SDP. - - -
    - - -As mentioned above, the RECOMMENDED delivery vector for Vorbis configuration -data is via a retrieval method that can be performed using a reliable transport -protocol. As the RTP headers are not required for this method of delivery, the -structure of the configuration data is slightly different. The packed header -starts with a 32-bit (network-byte ordered) count field, which details -the number of packed headers that are contained in the bundle. The -following shows the Packed header -payload for each chained Vorbis stream. - - -
    - -
    - -
    - -
    - -The key difference between the in-band format and this one is that there is no -need for the payload header octet. In this figure, the comment has a size bigger -than 127 bytes. - -
    - -
    - -
    - - -Unlike the loss of raw Vorbis payload data, loss of a configuration header -leads to a situation where it will not be possible to successfully decode the -stream. Implementations MAY try to recover from an error by requesting again the -missing Configuration or, if the delivery method is in-band, by buffering the -payloads waiting for the Configuration needed to decode them. -The baseline reaction SHOULD either be reset or end the RTP session. - - -
    - -
    - -
    - - -Vorbis Data Type flag set to 2 indicates that the packet contains -the comment metadata, such as artist name, track title, and so on. These -metadata messages are not intended to be fully descriptive but rather to offer basic -track/song information. Clients MAY ignore it completely. The details on the -format of the comments can be found in the Vorbis I Specification. - -
    - -
    - - -The 2-byte length field is necessary since this packet could be fragmented. - - -
    -
    - - -Each RTP payload contains either one Vorbis packet fragment or an integer -number of complete Vorbis packets (up to a maximum of 15 packets, since the -number of packets is defined by a 4-bit value). - - - -Any Vorbis data packet that is less than path MTU SHOULD be bundled in the RTP -payload with as many Vorbis packets as will fit, up to a maximum of 15, except -when such bundling would exceed an application's desired transmission latency. -Path MTU is detailed in and . - - - -A fragmented packet has a zero in the last four bits of the payload header. -The first fragment will set the Fragment type to 1. Each fragment after the -first will set the Fragment type to 2 in the payload header. The consecutive -fragments MUST be sent without any other payload being sent between the first -and the last fragment. The RTP payload containing the last fragment of the -Vorbis packet will have the Fragment type set to 3. To maintain the correct -sequence for fragmented packet reception, the timestamp field of fragmented -packets MUST be the same as the first packet sent, with the sequence number -incremented as normal for the subsequent RTP payloads; this will affect the -RTCP jitter measurement. The length field shows the fragment length. - - -
    - - -Here is an example of a fragmented Vorbis packet split over three RTP payloads. -Each of them contains the standard RTP headers as well as the 4-octet Vorbis -headers. - - -
    - -
    - - -In this payload, the initial sequence number is 1000 and the timestamp is 12345. The Fragment type is set to 1, the number of packets field is set to 0, and as -the payload is raw Vorbis data, the VDT field is set to 0. - - -
    - -
    - - -The Fragment type field is set to 2, and the number of packets field is set to 0. -For large Vorbis fragments, there can be several of these types of payloads. -The maximum packet size SHOULD be no greater than the path MTU, -including all RTP and payload headers. The sequence number has been incremented -by one, but the timestamp field remains the same as the initial payload. - - -
    - -
    - - -This is the last Vorbis fragment payload. The Fragment type is set to 3 and the -packet count remains set to 0. As in the previous payloads, the timestamp remains -set to the first payload timestamp in the sequence and the sequence number has -been incremented. - -
    - -
    - - -As there is no error correction within the Vorbis stream, packet loss will -result in a loss of signal. Packet loss is more of an issue for fragmented -Vorbis packets as the client will have to cope with the handling of the -Fragment Type. In case of loss of fragments, the client MUST discard all the -remaining Vorbis fragments and decode the incomplete packet. If we use the -fragmented Vorbis packet example above and the first RTP payload is lost, the -client MUST detect that the next RTP payload has the packet count field set -to 0 and the Fragment type 2 and MUST drop it. -The next RTP payload, which is the final fragmented packet, MUST be dropped -in the same manner. -If the missing RTP payload is the last, the two fragments received will be -kept and the incomplete Vorbis packet decoded. - - - -Loss of any of the Configuration fragment will result in the loss of the full -Configuration packet with the result detailed in the Loss of Configuration Headers section. - - -
    -
    -
    - - - audio - - vorbis - - - - - indicates the RTP timestamp clock rate as described in RTP Profile for Audio and Video Conferences with Minimal Control. - - - indicates the number of audio channels as described in RTP Profile for Audio and Video Conferences with Minimal Control. - - - - the base64 representation of the Packed Headers. - - - - - - -This media type is framed and contains binary data. - - - - -See Section 10 of RFC 5215. - - - -None - - - -RFC 5215 - -Ogg Vorbis I specification: Codec setup and packet decode. Available from the Xiph website, http://xiph.org/ - - - - - -Audio streaming and conferencing tools - - - -None - - - -Luca Barbato: <lu_zero@gentoo.org>
    - -IETF Audio/Video Transport Working Group - -
    - - - -COMMON - - - -This media type depends on RTP framing, hence is only defined for transfer via RTP. - - -Luca Barbato - - -IETF AVT Working Group delegated from the IESG -
    - -
    - - -The following IANA considerations refers to the split configuration Packed Headers used within RFC 5215. - - - - audio - - vorbis-config - - - -None - - - - -None - - - - -This media type contains binary data. - - - - -See Section 10 of RFC 5215. - - - - -None - - - - -RFC 5215 - - - - -Vorbis encoded audio, configuration data - - - - -None - - - - -Luca Barbato: <lu_zero@gentoo.org> - -IETF Audio/Video Transport Working Group - - - -COMMON - - - - -This media type doesn't depend on the transport. - - - - -Luca Barbato - - - -IETF AVT Working Group delegated from the IESG - - -
    - -
    - -
    - -The following paragraphs define the mapping of the parameters described in the IANA considerations section and their usage in the Offer/Answer Model. In order to be forward compatible, the implementation MUST ignore unknown parameters. - - -
    - - -The information carried in the Media Type specification has a -specific mapping to fields in the Session Description -Protocol (SDP), which is commonly used to describe RTP sessions. -When SDP is used to specify sessions, the mapping are as follows: - - - - -The type name ("audio") goes in SDP "m=" as the media name. - -The subtype name ("vorbis") goes in SDP "a=rtpmap" as the encoding name. - -The parameter "rate" also goes in "a=rtpmap" as the clock rate. - -The parameter "channels" also goes in "a=rtpmap" as the channel count. - -The mandated parameters "configuration" MUST be included in the SDP -"a=fmtp" attribute. - - - - -If the stream comprises chained Vorbis files and all of them are known in -advance, the Configuration Packet for each file SHOULD be passed to the client -using the configuration attribute. - - - -The port value is specified by the server application bound to the address -specified in the c= line. The channel count value specified in the rtpmap -attribute SHOULD match the current Vorbis stream or should be considered the maximum -number of channels to be expected. The timestamp clock rate MUST be a multiple -of the sample rate; a different payload number MUST be used if the clock rate -changes. The Configuration payload delivers the exact information, thus the -SDP information SHOULD be considered a hint. -An example is found below. - - -
    -The following example shows a basic SDP single stream. The first -configuration packet is inside the SDP; other configurations could be -fetched at any time from the URIs provided. The following -base64 configuration string is folded in this -example due to RFC line length limitations. - - - -c=IN IP4 192.0.2.1 -m=audio RTP/AVP 98 -a=rtpmap:98 vorbis/44100/2 -a=fmtp:98 configuration=AAAAAZ2f4g9NAh4aAXZvcmJpcwA...; - -
    - - -Note that the payload format (encoding) names are commonly shown in uppercase. -Media Type subtypes are commonly shown in lowercase. These names are -case-insensitive in both places. Similarly, parameter names are -case-insensitive both in Media Type types and in the default mapping to the SDP -a=fmtp attribute. The a=fmtp line is a single line, even if it is shown as multiple lines in this document for clarity. - - -
    - -
    - - -There are no negotiable parameters. All of them are declarative. - - -
    - -
    -
    - -The general congestion control considerations for transporting RTP -data apply to Vorbis audio over RTP as well. See the RTP specification - and any applicable RTP profile (e.g., ). -Audio data can be encoded using a range of different bit rates, so -it is possible to adapt network bandwidth by adjusting the encoder -bit rate in real time or by having multiple copies of content encoded - at different bit rates. - -
    -
    - - -The following example shows a common usage pattern that MAY be applied in -such a situation. The main scope of this section is to explain better usage -of the transmission vectors. - - -
    - -This is one of the most common situations: there is one single server streaming -content in multicast, and the clients may start a session at a random time. The -content itself could be a mix of a live stream (as the webjockey's voice) -and stored streams (as the music she plays). - -In this situation, we don't know in advance how many codebooks we will use. -The clients can join anytime and users expect to start listening to the content -in a short time. - -Upon joining, the client will receive the current Configuration necessary to -decode the current stream inside the SDP so that the decoding will start -immediately after. - -When the streamed content changes, the new Configuration is sent in-band -before the actual stream, and the Configuration that has to be sent inside -the SDP is updated. Since the in-band method is unreliable, an out-of-band -fallback is provided. - -The client may choose to fetch the Configuration from the alternate source -as soon as it discovers a Configuration packet got lost in-band, or use -selective retransmission if the server supports -this feature. - -A server-side optimization would be to keep a hash list of the -Configurations per session, which avoids packing all of them and sending the same -Configuration with different Ident tags. - -A client-side optimization would be to keep a tag list of the Configurations -per session and not process configuration packets that are already known. - -
    -
    - -
    - -RTP packets using this payload format are subject to the security -considerations discussed in the -RTP specification, the -base64 specification, and the -URI Generic syntax specification. -Among other considerations, this implies that the confidentiality of the -media stream is achieved by using encryption. Because the data compression used -with this payload format is applied end-to-end, encryption may be performed on -the compressed data. - - -
    -
    - The authors agree to grant third parties the irrevocable right to copy, - use, and distribute the work, with or without modification, in any medium, - without royalty, provided that, unless separate permission is granted, - redistributed modified works do not contain misleading author, version, - name of work, or endorsement information. -
    -
    - - -This document is a continuation of the following documents: - -Moffitt, J., "RTP Payload Format for Vorbis Encoded Audio", February 2001. - -Kerr, R., "RTP Payload Format for Vorbis Encoded Audio", December 2004. - -The Media Type declaration is a continuation of the following -document: -Short, B., "The audio/rtp-vorbis MIME Type", January 2008. - - - -Thanks to the AVT, Vorbis Communities / Xiph.Org Foundation including Steve Casner, -Aaron Colwell, Ross Finlayson, Fluendo, Ramon Garcia, Pascal Hennequin, Ralph -Giles, Tor-Einar Jarnbjo, Colin Law, John Lazzaro, Jack Moffitt, Christopher -Montgomery, Colin Perkins, Barry Short, Mike Smith, Phil Kerr, Michael Sparks, -Magnus Westerlund, David Barrett, Silvia Pfeiffer, Stefan Ehmann, Gianni Ceccarelli and Alessandro Salvatori. Thanks to the LScube Group, in particular Federico -Ridolfo, Francesco Varano, Giampaolo Mancini, Dario Gallucci, and Juan Carlos De Martin. - - -
    - -
    - - - - - - - - - - - - - - - - - -Ogg Vorbis I specification: Codec setup and packet decode. Available from the Xiph website, http://xiph.org/vorbis/doc/Vorbis_I_spec.html - - - - - - - - - - - -libvorbis: Available from the dedicated website, http://vorbis.com/ - - - - - - - - -
    diff --git a/Engine/lib/libvorbis/doc/squarepolar.png b/Engine/lib/libvorbis/doc/squarepolar.png deleted file mode 100644 index 4f9b03d33..000000000 Binary files a/Engine/lib/libvorbis/doc/squarepolar.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/stereo.html b/Engine/lib/libvorbis/doc/stereo.html deleted file mode 100644 index c7180e0e9..000000000 --- a/Engine/lib/libvorbis/doc/stereo.html +++ /dev/null @@ -1,419 +0,0 @@ - - - - - -Ogg Vorbis Documentation - - - - - - - - - -

    Ogg Vorbis stereo-specific channel coupling discussion

    - -

    Abstract

    - -

    The Vorbis audio CODEC provides a channel coupling -mechanisms designed to reduce effective bitrate by both eliminating -interchannel redundancy and eliminating stereo image information -labeled inaudible or undesirable according to spatial psychoacoustic -models. This document describes both the mechanical coupling -mechanisms available within the Vorbis specification, as well as the -specific stereo coupling models used by the reference -libvorbis codec provided by xiph.org.

    - -

    Mechanisms

    - -

    In encoder release beta 4 and earlier, Vorbis supported multiple -channel encoding, but the channels were encoded entirely separately -with no cross-analysis or redundancy elimination between channels. -This multichannel strategy is very similar to the mp3's dual -stereo mode and Vorbis uses the same name for its analogous -uncoupled multichannel modes.

    - -

    However, the Vorbis spec provides for, and Vorbis release 1.0 rc1 and -later implement a coupled channel strategy. Vorbis has two specific -mechanisms that may be used alone or in conjunction to implement -channel coupling. The first is channel interleaving via -residue backend type 2, and the second is square polar -mapping. These two general mechanisms are particularly well -suited to coupling due to the structure of Vorbis encoding, as we'll -explore below, and using both we can implement both totally -lossless stereo image coupling [bit-for-bit decode-identical -to uncoupled modes], as well as various lossy models that seek to -eliminate inaudible or unimportant aspects of the stereo image in -order to enhance bitrate. The exact coupling implementation is -generalized to allow the encoder a great deal of flexibility in -implementation of a stereo or surround model without requiring any -significant complexity increase over the combinatorially simpler -mid/side joint stereo of mp3 and other current audio codecs.

    - -

    A particular Vorbis bitstream may apply channel coupling directly to -more than a pair of channels; polar mapping is hierarchical such that -polar coupling may be extrapolated to an arbitrary number of channels -and is not restricted to only stereo, quadraphonics, ambisonics or 5.1 -surround. However, the scope of this document restricts itself to the -stereo coupling case.

    - - -

    Square Polar Mapping

    - -

    maximal correlation

    - -

    Recall that the basic structure of a a Vorbis I stream first generates -from input audio a spectral 'floor' function that serves as an -MDCT-domain whitening filter. This floor is meant to represent the -rough envelope of the frequency spectrum, using whatever metric the -encoder cares to define. This floor is subtracted from the log -frequency spectrum, effectively normalizing the spectrum by frequency. -Each input channel is associated with a unique floor function.

    - -

    The basic idea behind any stereo coupling is that the left and right -channels usually correlate. This correlation is even stronger if one -first accounts for energy differences in any given frequency band -across left and right; think for example of individual instruments -mixed into different portions of the stereo image, or a stereo -recording with a dominant feature not perfectly in the center. The -floor functions, each specific to a channel, provide the perfect means -of normalizing left and right energies across the spectrum to maximize -correlation before coupling. This feature of the Vorbis format is not -a convenient accident.

    - -

    Because we strive to maximally correlate the left and right channels -and generally succeed in doing so, left and right residue is typically -nearly identical. We could use channel interleaving (discussed below) -alone to efficiently remove the redundancy between the left and right -channels as a side effect of entropy encoding, but a polar -representation gives benefits when left/right correlation is -strong.

    - -

    point and diffuse imaging

    - -

    The first advantage of a polar representation is that it effectively -separates the spatial audio information into a 'point image' -(magnitude) at a given frequency and located somewhere in the sound -field, and a 'diffuse image' (angle) that fills a large amount of -space simultaneously. Even if we preserve only the magnitude (point) -data, a detailed and carefully chosen floor function in each channel -provides us with a free, fine-grained, frequency relative intensity -stereo*. Angle information represents diffuse sound fields, such as -reverberation that fills the entire space simultaneously.

    - -

    *Because the Vorbis model supports a number of different possible -stereo models and these models may be mixed, we do not use the term -'intensity stereo' talking about Vorbis; instead we use the terms -'point stereo', 'phase stereo' and subcategories of each.

    - -

    The majority of a stereo image is representable by polar magnitude -alone, as strong sounds tend to be produced at near-point sources; -even non-diffuse, fast, sharp echoes track very accurately using -magnitude representation almost alone (for those experimenting with -Vorbis tuning, this strategy works much better with the precise, -piecewise control of floor 1; the continuous approximation of floor 0 -results in unstable imaging). Reverberation and diffuse sounds tend -to contain less energy and be psychoacoustically dominated by the -point sources embedded in them. Thus, we again tend to concentrate -more represented energy into a predictably smaller number of numbers. -Separating representation of point and diffuse imaging also allows us -to model and manipulate point and diffuse qualities separately.

    - -

    controlling bit leakage and symbol crosstalk

    - -

    Because polar -representation concentrates represented energy into fewer large -values, we reduce bit 'leakage' during cascading (multistage VQ -encoding) as a secondary benefit. A single large, monolithic VQ -codebook is more efficient than a cascaded book due to entropy -'crosstalk' among symbols between different stages of a multistage cascade. -Polar representation is a way of further concentrating entropy into -predictable locations so that codebook design can take steps to -improve multistage codebook efficiency. It also allows us to cascade -various elements of the stereo image independently.

    - -

    eliminating trigonometry and rounding

    - -

    Rounding and computational complexity are potential problems with a -polar representation. As our encoding process involves quantization, -mixing a polar representation and quantization makes it potentially -impossible, depending on implementation, to construct a coupled stereo -mechanism that results in bit-identical decompressed output compared -to an uncoupled encoding should the encoder desire it.

    - -

    Vorbis uses a mapping that preserves the most useful qualities of -polar representation, relies only on addition/subtraction (during -decode; high quality encoding still requires some trig), and makes it -trivial before or after quantization to represent an angle/magnitude -through a one-to-one mapping from possible left/right value -permutations. We do this by basing our polar representation on the -unit square rather than the unit-circle.

    - -

    Given a magnitude and angle, we recover left and right using the -following function (note that A/B may be left/right or right/left -depending on the coupling definition used by the encoder):

    - -
    -      if(magnitude>0)
    -        if(angle>0){
    -          A=magnitude;
    -          B=magnitude-angle;
    -        }else{
    -          B=magnitude;
    -          A=magnitude+angle;
    -        }
    -      else
    -        if(angle>0){
    -          A=magnitude;
    -          B=magnitude+angle;
    -        }else{
    -          B=magnitude;
    -          A=magnitude-angle;
    -        }
    -    }
    -
    - -

    The function is antisymmetric for positive and negative magnitudes in -order to eliminate a redundant value when quantizing. For example, if -we're quantizing to integer values, we can visualize a magnitude of 5 -and an angle of -2 as follows:

    - -

    square polar

    - -

    This representation loses or replicates no values; if the range of A -and B are integral -5 through 5, the number of possible Cartesian -permutations is 121. Represented in square polar notation, the -possible values are:

    - -
    - 0, 0
    -
    --1,-2  -1,-1  -1, 0  -1, 1
    -
    - 1,-2   1,-1   1, 0   1, 1
    -
    --2,-4  -2,-3  -2,-2  -2,-1  -2, 0  -2, 1  -2, 2  -2, 3  
    -
    - 2,-4   2,-3   ... following the pattern ...
    -
    - ...   5, 1   5, 2   5, 3   5, 4   5, 5   5, 6   5, 7   5, 8   5, 9
    -
    -
    - -

    ...for a grand total of 121 possible values, the same number as in -Cartesian representation (note that, for example, 5,-10 is -the same as -5,10, so there's no reason to represent -both. 2,10 cannot happen, and there's no reason to account for it.) -It's also obvious that this mapping is exactly reversible.

    - -

    Channel interleaving

    - -

    We can remap and A/B vector using polar mapping into a magnitude/angle -vector, and it's clear that, in general, this concentrates energy in -the magnitude vector and reduces the amount of information to encode -in the angle vector. Encoding these vectors independently with -residue backend #0 or residue backend #1 will result in bitrate -savings. However, there are still implicit correlations between the -magnitude and angle vectors. The most obvious is that the amplitude -of the angle is bounded by its corresponding magnitude value.

    - -

    Entropy coding the results, then, further benefits from the entropy -model being able to compress magnitude and angle simultaneously. For -this reason, Vorbis implements residue backend #2 which pre-interleaves -a number of input vectors (in the stereo case, two, A and B) into a -single output vector (with the elements in the order of -A_0, B_0, A_1, B_1, A_2 ... A_n-1, B_n-1) before entropy encoding. Thus -each vector to be coded by the vector quantization backend consists of -matching magnitude and angle values.

    - -

    The astute reader, at this point, will notice that in the theoretical -case in which we can use monolithic codebooks of arbitrarily large -size, we can directly interleave and encode left and right without -polar mapping; in fact, the polar mapping does not appear to lend any -benefit whatsoever to the efficiency of the entropy coding. In fact, -it is perfectly possible and reasonable to build a Vorbis encoder that -dispenses with polar mapping entirely and merely interleaves the -channel. Libvorbis based encoders may configure such an encoding and -it will work as intended.

    - -

    However, when we leave the ideal/theoretical domain, we notice that -polar mapping does give additional practical benefits, as discussed in -the above section on polar mapping and summarized again here:

    - -
      -
    • Polar mapping aids in controlling entropy 'leakage' between stages -of a cascaded codebook.
    • -
    • Polar mapping separates the stereo image -into point and diffuse components which may be analyzed and handled -differently.
    • -
    - -

    Stereo Models

    - -

    Dual Stereo

    - -

    Dual stereo refers to stereo encoding where the channels are entirely -separate; they are analyzed and encoded as entirely distinct entities. -This terminology is familiar from mp3.

    - -

    Lossless Stereo

    - -

    Using polar mapping and/or channel interleaving, it's possible to -couple Vorbis channels losslessly, that is, construct a stereo -coupling encoding that both saves space but also decodes -bit-identically to dual stereo. OggEnc 1.0 and later uses this -mode in all high-bitrate encoding.

    - -

    Overall, this stereo mode is overkill; however, it offers a safe -alternative to users concerned about the slightest possible -degradation to the stereo image or archival quality audio.

    - -

    Phase Stereo

    - -

    Phase stereo is the least aggressive means of gracefully dropping -resolution from the stereo image; it affects only diffuse imaging.

    - -

    It's often quoted that the human ear is deaf to signal phase above -about 4kHz; this is nearly true and a passable rule of thumb, but it -can be demonstrated that even an average user can tell the difference -between high frequency in-phase and out-of-phase noise. Obviously -then, the statement is not entirely true. However, it's also the case -that one must resort to nearly such an extreme demonstration before -finding the counterexample.

    - -

    'Phase stereo' is simply a more aggressive quantization of the polar -angle vector; above 4kHz it's generally quite safe to quantize noise -and noisy elements to only a handful of allowed phases, or to thin the -phase with respect to the magnitude. The phases of high amplitude -pure tones may or may not be preserved more carefully (they are -relatively rare and L/R tend to be in phase, so there is generally -little reason not to spend a few more bits on them)

    - -

    example: eight phase stereo

    - -

    Vorbis may implement phase stereo coupling by preserving the entirety -of the magnitude vector (essential to fine amplitude and energy -resolution overall) and quantizing the angle vector to one of only -four possible values. Given that the magnitude vector may be positive -or negative, this results in left and right phase having eight -possible permutation, thus 'eight phase stereo':

    - -

    eight phase

    - -

    Left and right may be in phase (positive or negative), the most common -case by far, or out of phase by 90 or 180 degrees.

    - -

    example: four phase stereo

    - -

    Similarly, four phase stereo takes the quantization one step further; -it allows only in-phase and 180 degree out-out-phase signals:

    - -

    four phase

    - -

    example: point stereo

    - -

    Point stereo eliminates the possibility of out-of-phase signal -entirely. Any diffuse quality to a sound source tends to collapse -inward to a point somewhere within the stereo image. A practical -example would be balanced reverberations within a large, live space; -normally the sound is diffuse and soft, giving a sonic impression of -volume. In point-stereo, the reverberations would still exist, but -sound fairly firmly centered within the image (assuming the -reverberation was centered overall; if the reverberation is stronger -to the left, then the point of localization in point stereo would be -to the left). This effect is most noticeable at low and mid -frequencies and using headphones (which grant perfect stereo -separation). Point stereo is is a graceful but generally easy to -detect degradation to the sound quality and is thus used in frequency -ranges where it is least noticeable.

    - -

    Mixed Stereo

    - -

    Mixed stereo is the simultaneous use of more than one of the above -stereo encoding models, generally using more aggressive modes in -higher frequencies, lower amplitudes or 'nearly' in-phase sound.

    - -

    It is also the case that near-DC frequencies should be encoded using -lossless coupling to avoid frame blocking artifacts.

    - -

    Vorbis Stereo Modes

    - -

    Vorbis, as of 1.0, uses lossless stereo and a number of mixed modes -constructed out of lossless and point stereo. Phase stereo was used -in the rc2 encoder, but is not currently used for simplicity's sake. It -will likely be re-added to the stereo model in the future.

    - - - - - - - - - - - diff --git a/Engine/lib/libvorbis/doc/stream.png b/Engine/lib/libvorbis/doc/stream.png deleted file mode 100644 index d1d2f3685..000000000 Binary files a/Engine/lib/libvorbis/doc/stream.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/v-comment.html b/Engine/lib/libvorbis/doc/v-comment.html deleted file mode 100644 index 0093447cd..000000000 --- a/Engine/lib/libvorbis/doc/v-comment.html +++ /dev/null @@ -1,282 +0,0 @@ - - - - - -Ogg Vorbis Documentation - - - - - - - - - -

    Ogg Vorbis I format specification: comment field and header specification

    - -

    Overview

    - -

    The Vorbis text comment header is the second (of three) header -packets that begin a Vorbis bitstream. It is meant for short, text -comments, not arbitrary metadata; arbitrary metadata belongs in a -separate logical bitstream (usually an XML stream type) that provides -greater structure and machine parseability.

    - -

    The comment field is meant to be used much like someone jotting a -quick note on the bottom of a CDR. It should be a little information to -remember the disc by and explain it to others; a short, to-the-point -text note that need not only be a couple words, but isn't going to be -more than a short paragraph. The essentials, in other words, whatever -they turn out to be, eg:

    - -

    -"Honest Bob and the Factory-to-Dealer-Incentives, _I'm Still Around_, -opening for Moxy Früvous, 1997" -

    - -

    Comment encoding

    - -

    Structure

    - -

    The comment header logically is a list of eight-bit-clean vectors; the -number of vectors is bounded to 2^32-1 and the length of each vector -is limited to 2^32-1 bytes. The vector length is encoded; the vector -contents themselves are not null terminated. In addition to the vector -list, there is a single vector for vendor name (also 8 bit clean, -length encoded in 32 bits). For example, the 1.0 release of libvorbis -set the vendor string to "Xiph.Org libVorbis I 20020717".

    - -

    The comment header is decoded as follows:

    - -
    -  1) [vendor_length] = read an unsigned integer of 32 bits
    -  2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets
    -  3) [user_comment_list_length] = read an unsigned integer of 32 bits
    -  4) iterate [user_comment_list_length] times {
    -
    -       5) [length] = read an unsigned integer of 32 bits
    -       6) this iteration's user comment = read a UTF-8 vector as [length] octets
    -
    -     }
    -
    -  7) [framing_bit] = read a single bit as boolean
    -  8) if ( [framing_bit] unset or end of packet ) then ERROR
    -  9) done.
    -
    - -

    Content vector format

    - -

    The comment vectors are structured similarly to a UNIX environment variable. -That is, comment fields consist of a field name and a corresponding value and -look like:

    - -
    -comment[0]="ARTIST=me"; 
    -comment[1]="TITLE=the sound of Vorbis"; 
    -
    - -
      -
    • A case-insensitive field name that may consist of ASCII 0x20 through -0x7D, 0x3D ('=') excluded. ASCII 0x41 through 0x5A inclusive (A-Z) is -to be considered equivalent to ASCII 0x61 through 0x7A inclusive -(a-z).
    • -
    • The field name is immediately followed by ASCII 0x3D ('='); -this equals sign is used to terminate the field name.
    • -
    • 0x3D is followed by the 8 bit clean UTF-8 encoded value of the -field contents to the end of the field.
    • -
    - -

    Field names

    - -

    Below is a proposed, minimal list of standard field names with a -description of intended use. No single or group of field names is -mandatory; a comment header may contain one, all or none of the names -in this list.

    - -
    - -
    TITLE
    -
    Track/Work name
    - -
    VERSION
    -
    The version field may be used to differentiate multiple -versions of the same track title in a single collection. -(e.g. remix info)
    - -
    ALBUM
    -
    The collection name to which this track belongs
    - -
    TRACKNUMBER
    -
    The track number of this piece if part of a specific larger collection or album
    - -
    ARTIST
    -
    The artist generally considered responsible for the work. In popular music -this is usually the performing band or singer. For classical music it would be -the composer. For an audio book it would be the author of the original text.
    - -
    PERFORMER
    -
    The artist(s) who performed the work. In classical music this would be the -conductor, orchestra, soloists. In an audio book it would be the actor who did -the reading. In popular music this is typically the same as the ARTIST and -is omitted.
    - -
    COPYRIGHT
    -
    Copyright attribution, e.g., '2001 Nobody's Band' or '1999 Jack Moffitt'
    - -
    LICENSE
    -
    License information, for example, 'All Rights Reserved', 'Any -Use Permitted', a URL to a license such as a Creative Commons license -(e.g. "creativecommons.org/licenses/by/4.0/"), or similar.
    - -
    ORGANIZATION
    -
    Name of the organization producing the track (i.e. -the 'record label')
    - -
    DESCRIPTION
    -
    A short text description of the contents
    - -
    GENRE
    -
    A short text indication of music genre
    - -
    DATE
    -
    Date the track was recorded
    - -
    LOCATION
    -
    Location where track was recorded
    - -
    CONTACT
    -
    Contact information for the creators or distributors of the track. -This could be a URL, an email address, the physical address of -the producing label.
    - -
    ISRC
    -
    ISRC number for the track; see the -ISRC intro page for more information on ISRC numbers.
    - -
    - -

    Implications

    - -
      -
    • Field names should not be 'internationalized'; this is a -concession to simplicity not an attempt to exclude the majority of -the world that doesn't speak English. Field contents, -however, use the UTF-8 character encoding to allow easy representation -of any language.
    • -
    • We have the length of the entirety of the field and restrictions on -the field name so that the field name is bounded in a known way. Thus -we also have the length of the field contents.
    • -
    • Individual 'vendors' may use non-standard field names within -reason. The proper use of comment fields should be clear through -context at this point. Abuse will be discouraged.
    • -
    • There is no vendor-specific prefix to 'nonstandard' field names. -Vendors should make some effort to avoid arbitrarily polluting the -common namespace. We will generally collect the more useful tags -here to help with standardization.
    • -
    • Field names are not required to be unique (occur once) within a -comment header. As an example, assume a track was recorded by three -well know artists; the following is permissible, and encouraged: -
      -              ARTIST=Dizzy Gillespie 
      -              ARTIST=Sonny Rollins 
      -              ARTIST=Sonny Stitt 
      -
    • -
    - -

    Encoding

    - -

    The comment header comprises the entirety of the second bitstream -header packet. Unlike the first bitstream header packet, it is not -generally the only packet on the second page and may not be restricted -to within the second bitstream page. The length of the comment header -packet is (practically) unbounded. The comment header packet is not -optional; it must be present in the bitstream even if it is -effectively empty.

    - -

    The comment header is encoded as follows (as per Ogg's standard -bitstream mapping which renders least-significant-bit of the word to be -coded into the least significant available bit of the current -bitstream octet first):

    - -
      -
    1. Vendor string length (32 bit unsigned quantity specifying number of octets)
    2. -
    3. Vendor string ([vendor string length] octets coded from beginning of string -to end of string, not null terminated)
    4. -
    5. Number of comment fields (32 bit unsigned quantity specifying number of fields)
    6. -
    7. Comment field 0 length (if [Number of comment fields]>0; 32 bit unsigned -quantity specifying number of octets)
    8. -
    9. Comment field 0 ([Comment field 0 length] octets coded from beginning of -string to end of string, not null terminated)
    10. -
    11. Comment field 1 length (if [Number of comment fields]>1...)...
    12. -
    - -

    This is actually somewhat easier to describe in code; implementation of the above -can be found in vorbis/lib/info.c:_vorbis_pack_comment(),_vorbis_unpack_comment()

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbis-clip.txt b/Engine/lib/libvorbis/doc/vorbis-clip.txt deleted file mode 100644 index 2e6703445..000000000 --- a/Engine/lib/libvorbis/doc/vorbis-clip.txt +++ /dev/null @@ -1,139 +0,0 @@ -Topic: - -Sample granularity editing of a Vorbis file; inferred arbitrary sample -length starting offsets / PCM stream lengths - -Overview: - -Vorbis, like mp3, is a frame-based* audio compression where audio is -broken up into discrete short time segments. These segments are -'atomic' that is, one must recover the entire short time segment from -the frame packet; there's no way to recover only a part of the PCM time -segment from part of the coded packet without expanding the entire -packet and then discarding a portion of the resulting PCM audio. - -* In mp3, the data segment representing a given time period is called - a 'frame'; the roughly equivalent Vorbis construct is a 'packet'. - -Thus, when we edit a Vorbis stream, the finest physical editing -granularity is on these packet boundaries (the mp3 case is -actually somewhat more complex and mp3 editing is more complicated -than just snipping on a frame boundary because time data can be spread -backward or forward over frames. In Vorbis, packets are all -stand-alone). Thus, at the physical packet level, Vorbis is still -limited to streams that contain an integral number of packets. - -However, Vorbis streams may still exactly represent and be edited to a -PCM stream of arbitrary length and starting offset without padding the -beginning or end of the decoded stream or requiring that the desired -edit points be packet aligned. Vorbis makes use of Ogg stream -framing, and this framing provides time-stamping data, called a -'granule position'; our starting offset and finished stream length may -be inferred from correct usage of the granule position data. - -Time stamping mechanism: - -Vorbis packets are bundled into into Ogg pages (note that pages do not -necessarily contain integral numbers of packets, but that isn't -inportant in this discussion. More about Ogg framing can be found in -ogg/doc/framing.html). Each page that contains a packet boundary is -stamped with the absolute sample-granularity offset of the data, that -is, 'complete samples-to-date' up to the last completed packet of that -page. (The same mechanism is used for eg, video, where the number -represents complete 2-D frames, and so on). - -(It's possible but rare for a packet to span more than two pages such -that page[s] in the middle have no packet boundary; these packets have -a granule position of '-1'.) - -This granule position mechaism in Ogg is used by Vorbis to indicate when the -PCM data intended to be represented in a Vorbis segment begins a -number of samples into the data represented by the first packet[s] -and/or ends before the physical PCM data represented in the last -packet[s]. - -File length a non-integral number of frames: - -A file to be encoded in Vorbis will probably not encode into an -integral number of packets; such a file is encoded with the last -packet containing 'extra'* samples. These samples are not padding; they -will be discarded in decode. - -*(For best results, the encoder should use extra samples that preserve -the character of the last frame. Simply setting them to zero will -introduce a 'cliff' that's hard to encode, resulting in spread-frame -noise. Libvorbis extrapolates the last frame past the end of data to -produce the extra samples. Even simply duplicating the last value is -better than clamping the signal to zero). - -The encoder indicates to the decoder that the file is actually shorter -than all of the samples ('original' + 'extra') by setting the granule -position in the last page to a short value, that is, the last -timestamp is the original length of the file discarding extra samples. -The decoder will see that the number of samples it has decoded in the -last page is too many; it is 'original' + 'extra', where the -granulepos says that through the last packet we only have 'original' -number of samples. The decoder then ignores the 'extra' samples. -This behavior is to occur only when the end-of-stream bit is set in -the page (indicating last page of the logical stream). - -Note that it not legal for the granule position of the last page to -indicate that there are more samples in the file than actually exist, -however, implementations should handle such an illegal file gracefully -in the interests of robust programming. - -Beginning point not on integral packet boundary: - -It is possible that we will the PCM data represented by a Vorbis -stream to begin at a position later than where the decoded PCM data -really begins after an integral packet boundary, a situation analagous -to the above description where the PCM data does not end at an -integral packet boundary. The easiest example is taking a clip out of -a larger Vorbis stream, and choosing a beginning point of the clip -that is not on a packet boundary; we need to ignore a few samples to -get the desired beginning point. - -The process of marking the desired beginning point is similar to -marking an arbitrary ending point. If the encoder wishes sample zero -to be some location past the actual beginning of data, it associates a -'short' granule position value with the completion of the second* -audio packet. The granule position is associated with the second -packet simply by making sure the second packet completes its page. - -*(We associate the short value with the second packet for two reasons. - a) The first packet only primes the overlap/add buffer. No data is - returned before decoding the second packet; this places the decision - information at the point of decision. b) Placing the short value on - the first packet would make the value negative (as the first packet - normally represents position zero); a negative value would break the - requirement that granule positions increase; the headers have - position values of zero) - -The decoder sees that on the first page that will return -data from the overlap/add queue, we have more samples than the granule -position accounts for, and discards the 'surplus' from the beginning -of the queue. - -Note that short granule values (indicating less than the actually -returned about of data) are not legal in the Vorbis spec outside of -indicating beginning and ending sample positions. However, decoders -should, at minimum, tolerate inadvertant short values elsewhere in the -stream (just as they should tolerate out-of-order/non-increasing -granulepos values, although this too is illegal). - -Beginning point at arbitrary positive timestamp (no 'zero' sample): - -It's also possible that the granule position of the first page of an -audio stream is a 'long value', that is, a value larger than the -amount of PCM audio decoded. This implies only that we are starting -playback at some point into the logical stream, a potentially common -occurence in streaming applications where the decoder may be -connecting into a live stream. The decoder should not treat the long -value specially. - -A long value elsewhere in the stream would normally occur only when a -page is lost or out of sequence, as indicated by the page's sequence -number. A long value under any other situation is not legal, however -a decoder should tolerate both possibilities. - - diff --git a/Engine/lib/libvorbis/doc/vorbis-errors.txt b/Engine/lib/libvorbis/doc/vorbis-errors.txt deleted file mode 100644 index e873d8ab0..000000000 --- a/Engine/lib/libvorbis/doc/vorbis-errors.txt +++ /dev/null @@ -1,103 +0,0 @@ -Error return codes possible from libvorbis and libvorbisfile: - -All 'failure' style returns are <0; this either indicates a generic -'false' value (eg, ready? T or F) or an error condition. Code can -safely just test for < 0, or look at the specific return code for more -detail. - -*** Return codes: - -OV_FALSE The call returned a 'false' status (eg, ov_bitrate_instant - can return OV_FALSE if playback is not in progress, and thus - there is no instantaneous bitrate information to report. - -OV_HOLE libvorbis/libvorbisfile is alerting the application that - there was an interruption in the data (one of: garbage - between pages, loss of sync followed by recapture, or a - corrupt page) - -OV_EREAD A read from media returned an error. - -OV_EFAULT Internal logic fault; indicates a bug or heap/stack - corruption. - -OV_EIMPL The bitstream makes use of a feature not implemented in this - library version. - -OV_EINVAL Invalid argument value. - -OV_ENOTVORBIS Bitstream/page/packet is not Vorbis data. - -OV_EBADHEADER Invalid Vorbis bitstream header. - -OV_EVERSION Vorbis version mismatch. - -OV_ENOTAUDIO Packet data submitted to vorbis_synthesis is not audio data. - -OV_EBADPACKET Invalid packet submitted to vorbis_synthesis. - -OV_EBADLINK Invalid stream section supplied to libvorbis/libvorbisfile, - or the requested link is corrupt. - -OV_ENOSEEK Bitstream is not seekable. - - -**************************************************************** -*** Libvorbis functions that can return failure/error codes: - -int vorbis_analysis_headerout() - OV_EIMPL - -int vorbis_analysis_wrote() - OV_EINVAL - -int vorbis_synthesis_headerin() - OV_ENOTVORBIS, OV_EVERSION, OV_EBADHEADER - -int vorbis_synthesis() - OV_ENOTAUDIO, OV_EBADPACKET - -int vorbis_synthesis_read() - OV_EINVAL - -**************************************************************** -*** Libvorbisfile functions that can return failure/error codes: - -int ov_open_callbacks() - OV_EREAD, OV_ENOTVORBIS, OV_EVERSION, OV_EBADHEADER, OV_FAULT - -int ov_open() - OV_EREAD, OV_ENOTVORBIS, OV_EVERSION, OV_EBADHEADER, OV_FAULT - -long ov_bitrate() - OV_EINVAL, OV_FALSE - -long ov_bitrate_instant() - OV_FALSE - -ogg_int64_t ov_raw_total() - OV_EINVAL - -ogg_int64_t ov_pcm_total() - OV_EINVAL - -double ov_time_total() - OV_EINVAL - -int ov_raw_seek() - OV_ENOSEEK, OV_EINVAL, OV_BADLINK - -int ov_pcm_seek_page() - OV_ENOSEEK, OV_EINVAL, OV_EREAD, OV_BADLINK, OV_FAULT - -int ov_pcm_seek() - OV_ENOSEEK, OV_EINVAL, OV_EREAD, OV_BADLINK, OV_FAULT - -int ov_time_seek() - OV_ENOSEEK, OV_EINVAL, OV_EREAD, OV_BADLINK, OV_FAULT - -int ov_time_seek_page() - OV_ENOSEEK, OV_EINVAL, OV_EREAD, OV_BADLINK, OV_FAULT - -long ov_read() - OV_HOLE, OV_EBADLINK diff --git a/Engine/lib/libvorbis/doc/vorbis-fidelity.html b/Engine/lib/libvorbis/doc/vorbis-fidelity.html deleted file mode 100644 index 85229282f..000000000 --- a/Engine/lib/libvorbis/doc/vorbis-fidelity.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - -Ogg Vorbis Documentation - - - - - - - - - -

    Ogg Vorbis: Fidelity measurement and terminology discussion

    - -

    Terminology discussed in this document is based on common terminology -associated with contemporary codecs such as MPEG I audio layer 3 -(mp3). However, some differences in terminology are useful in the -context of Vorbis as Vorbis functions somewhat differently than most -current formats. For clarity, then, we describe a common terminology -for discussion of Vorbis's and other formats' audio quality.

    - -

    Subjective and Objective

    - -

    Objective fidelity is a measure, based on a computable, -mechanical metric, of how carefully an output matches an input. For -example, a stereo amplifier may claim to introduce less that .01% -total harmonic distortion when amplifying an input signal; this claim -is easy to verify given proper equipment, and any number of testers are -likely to arrive at the same, exact results. One need not listen to -the equipment to make this measurement.

    - -

    However, given two amplifiers with identical, verifiable objective -specifications, listeners may strongly prefer the sound quality of one -over the other. This is actually the case in the decades old debate -[some would say jihad] among audiophiles involving vacuum tube versus -solid state amplifiers. There are people who can tell the difference, -and strongly prefer one over the other despite seemingly identical, -measurable quality. This preference is subjective and -difficult to measure but nonetheless real.

    - -

    Individual elements of subjective differences often can be qualified, -but overall subjective quality generally is not measurable. Different -observers are likely to disagree on the exact results of a subjective -test as each observer's perspective differs. When measuring -subjective qualities, the best one can hope for is average, empirical -results that show statistical significance across a group.

    - -

    Perceptual codecs are most concerned with subjective, not objective, -quality. This is why evaluating a perceptual codec via distortion -measures and sonograms alone is useless; these objective measures may -provide insight into the quality or functioning of a codec, but cannot -answer the much squishier subjective question, "Does it sound -good?". The tube amplifier example is perhaps not the best as very few -people can hear, or care to hear, the minute differences between tubes -and transistors, whereas the subjective differences in perceptual -codecs tend to be quite large even when objective differences are -not.

    - -

    Fidelity, Artifacts and Differences

    - -

    Audio artifacts and loss of fidelity or more simply -put, audio differences are not the same thing.

    - -

    A loss of fidelity implies differences between the perceived input and -output signal; it does not necessarily imply that the differences in -output are displeasing or that the output sounds poor (although this -is often the case). Tube amplifiers are not higher fidelity -than modern solid state and digital systems. They simply produce a -form of distortion and coloring that is either unnoticeable or actually -pleasing to many ears.

    - -

    As compared to an original signal using hard metrics, all perceptual -codecs [ASPEC, ATRAC, MP3, WMA, AAC, TwinVQ, AC3 and Vorbis included] -lose objective fidelity in order to reduce bitrate. This is fact. The -idea is to lose fidelity in ways that cannot be perceived. However, -most current streaming applications demand bitrates lower than what -can be achieved by sacrificing only objective fidelity; this is also -fact, despite whatever various company press releases might claim. -Subjective fidelity eventually must suffer in one way or another.

    - -

    The goal is to choose the best possible tradeoff such that the -fidelity loss is graceful and not obviously noticeable. Most listeners -of FM radio do not realize how much lower fidelity that medium is as -compared to compact discs or DAT. However, when compared directly to -source material, the difference is obvious. A cassette tape is lower -fidelity still, and yet the degradation, relatively speaking, is -graceful and generally easy not to notice. Compare this graceful loss -of quality to an average 44.1kHz stereo mp3 encoded at 80 or 96kbps. -The mp3 might actually be higher objective fidelity but subjectively -sounds much worse.

    - -

    Thus, when a CODEC must sacrifice subjective quality in order -to satisfy a user's requirements, the result should be a -difference that is generally either difficult to notice -without comparison, or easy to ignore. An artifact, on the -other hand, is an element introduced into the output that is -immediately noticeable, obviously foreign, and undesired. The famous -'underwater' or 'twinkling' effect synonymous with low bitrate (or -poorly encoded) mp3 is an example of an artifact. This -working definition differs slightly from common usage, but the coined -distinction between differences and artifacts is useful for our -discussion.

    - -

    The goal, when it is absolutely necessary to sacrifice subjective -fidelity, is obviously to strive for differences and not artifacts. -The vast majority of codecs today fail at this task miserably, -predictably, and regularly in one way or another. Avoiding such -failures when it is necessary to sacrifice subjective quality is a -fundamental design objective of Vorbis and that objective is reflected -in Vorbis's design and tuning.

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/Makefile.am b/Engine/lib/libvorbis/doc/vorbisenc/Makefile.am deleted file mode 100644 index bbab3c5ba..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -## Process this file with automake to produce Makefile.in - -docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION)/vorbisenc - -doc_DATA = changes.html examples.html index.html ovectl_ratemanage2_arg.html \ - ovectl_ratemanage_arg.html overview.html reference.html style.css\ - vorbis_encode_ctl.html vorbis_encode_init.html vorbis_encode_setup_init.html \ - vorbis_encode_setup_managed.html vorbis_encode_setup_vbr.html \ - vorbis_encode_init_vbr.html - -EXTRA_DIST = $(doc_DATA) diff --git a/Engine/lib/libvorbis/doc/vorbisenc/changes.html b/Engine/lib/libvorbis/doc/vorbisenc/changes.html deleted file mode 100644 index fbf0ebc48..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/changes.html +++ /dev/null @@ -1,104 +0,0 @@ - - - -libvorbisenc - Documentation - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    Libvorbisenc API changes 1.0 through 1.1

    - -This document describes API additions to libvorbisenc between release -1.0 and 1.1. - -

    1.0.1

    - -The programming API and binary application ABI are unchanged and fully -forward/backward compatible between release 1.0 and 1.0.1. Libvorbis, -libvorbisenc and libvorbisfile must match versions amongst themselves, -however. - -

    1.1

    - -The binary ABI from release 1.0.1 to 1.1 is backward compatible; -applications linked against libvorbis/libvorbisenc 1.0 and 1.0.1 will -continue to function correctly when upgrading the libvorbis and -libvorbisenc dynamic libraries without re-linking.

    - -Release 1.1 adds several possible requests to the libvorbisenc vorbis_encode_ctl() call in order to -reflect the shift to bit-reservoir style -bitrate management. In addition, several vorbis_encode_ctl() requests are -deprecated (but functional) as they are redered semantically obsolete -by the new bitrate management.

    - -

    Deprecated in 1.1

    - -These calls are still available to older codebases to preserve -compatability; the fields of the ovectl_ratemanage_arg argument -are mapped as closely as possible to the fields of the new ovectl_ratemanage2_arg -structure. - -
    -
    OV_ECTL_RATEMANAGE_GET:
    Use OV_ECTL_RATEMANAGE2_GET -instead. - - -
    OV_ECTL_RATEMANAGE_SET:
    Use OV_ECTL_RATEMANAGE2_SET -instead. - -
    OV_ECTL_RATEMANAGE_AVG:
    Use OV_ECTL_RATEMANAGE2_SET -instead. - -
    OV_ECTL_RATEMANAGE_HARD:
    Use OV_ECTL_RATEMANAGE2_SET -instead. -
    - -

    Newly added in 1.1

    - -The following calls are added in 1.1 to semantically reflect movement -to a bit-reservoir-based bitrate -management scheme by introducing the ovectl_ratemanage2_arg -structure in order to better represent the abilities of the bitrate -manager.

    - -

    -
    OV_ECTL_RATEMANAGE2_GET
    - -Used to query the current state of bitrate management setup. - -
    OV_ECTL_RATEMANAGE2_SET
    - -Used to set or alter bitrate management settings. -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/examples.html b/Engine/lib/libvorbis/doc/vorbisenc/examples.html deleted file mode 100644 index 72282eb91..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/examples.html +++ /dev/null @@ -1,133 +0,0 @@ - - - -libvorbisenc - Documentation - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    Libvorbisenc Setup Examples

    - -VBR is always the recommended mode for Vorbis encoding when -there's no need to impose bitrate constraints. True VBR encoding will -always produce the most consistent quality output as well as the -highest quality for a the bits used. - -

    The following code examples prepare a -vorbis_info structure for encoding -use with libvorbis.

    - -

    Example: encoding using a VBR quality mode

    - - -
     
    -   vorbis_info_init(&vi);
    -
    -  /*********************************************************************
    -   Encoding using a VBR quality mode.  The usable range is -.1
    -   (lowest quality, smallest file) to 1.0 (highest quality, largest file).
    -   Example quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR 
    -   *********************************************************************/
    -  
    -   ret = vorbis_encode_init_vbr(&vi,2,44100,.4);
    -
    -  /*********************************************************************
    -   do not continue if setup failed; this can happen if we ask for a
    -   mode that libVorbis does not support (eg, too low a quality mode, etc,
    -   will return 'OV_EIMPL')
    -   *********************************************************************/
    -
    -   if(ret) exit(1);
    -
    - -

    Example: encoding using average bitrate (ABR)

    - - -
     
    -   vorbis_info_init(&vi);
    -
    -  /*********************************************************************
    -   Encoding using an average bitrate mode (ABR).
    -   example: 44kHz stereo coupled, average 128kbps ABR 
    -   *********************************************************************/
    -  
    -   ret = vorbis_encode_init(&vi,2,44100,-1,128000,-1);
    -
    -  /*********************************************************************
    -   do not continue if setup failed; this can happen if we ask for a
    -   mode that libVorbis does not support (eg, too low a bitrate, etc,
    -   will return 'OV_EIMPL')
    -   *********************************************************************/
    -
    -   if(ret) exit(1);
    -
    - -

    Example: encoding using constant bitrate (CBR)

    - - -
     
    -   vorbis_info_init(&vi);
    -
    -  /*********************************************************************
    -   Encoding using a constant bitrate mode (CBR).
    -   example: 44kHz stereo coupled, average 128kbps CBR 
    -   *********************************************************************/
    -  
    -   ret = vorbis_encode_init(&vi,2,44100,128000,128000,128000);
    -
    -  /*********************************************************************
    -   do not continue if setup failed; this can happen if we ask for a
    -   mode that libVorbis does not support (eg, too low a bitrate, etc,
    -   will return 'OV_EIMPL')
    -   *********************************************************************/
    -
    -   if(ret) exit(1);
    -
    - -

    Example: encoding using VBR selected by approximate bitrate

    - - -
     
    -   vorbis_info_init(&vi);
    -
    -  /*********************************************************************
    -   Encode using a quality mode, but select that quality mode by asking for
    -   an approximate bitrate.  This is not ABR, it is true VBR, but selected
    -   using the bitrate interface, and then turning bitrate management off:
    -   *********************************************************************/
    -
    -   ret = ( vorbis_encode_setup_managed(&vi,2,44100,-1,128000,-1) ||
    -           vorbis_encode_ctl(&vi,OV_ECTL_RATEMANAGE2_SET,NULL) ||
    -           vorbis_encode_setup_init(&vi));
    -
    -  /*********************************************************************
    -   do not continue if setup failed; this can happen if we ask for a
    -   mode that libVorbis does not support (eg, too low a bitrate, etc,
    -   will return 'OV_EIMPL')
    -   *********************************************************************/
    -
    -   if(ret) exit(1);
    -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/index.html b/Engine/lib/libvorbis/doc/vorbisenc/index.html deleted file mode 100644 index b39c04f24..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - -libvorbisenc - Documentation - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    Libvorbisenc Documentation

    - -

    -Libvorbisenc is a convenient API for setting up an encoding environment using libvorbis. Libvorbisenc encapsulates the actions needed to set up the encoder properly. -

    -libvorbisenc api overview
    -libvorbisenc api reference
    -libvorbisenc api changes from 1.0 and 1.0.1
    -libvorbisenc encode setup examples
    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/ovectl_ratemanage2_arg.html b/Engine/lib/libvorbis/doc/vorbisenc/ovectl_ratemanage2_arg.html deleted file mode 100644 index cc7962544..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/ovectl_ratemanage2_arg.html +++ /dev/null @@ -1,92 +0,0 @@ - - - -vorbis - datatype - ovectl_ratemanage2_arg - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    ovectl_ratemanage2_arg

    - -

    declared in "vorbis/vorbisenc.h"

    - -

    - -The ovectl_ratemanage2_arg structure is used with vorbis_encode_ctl() and the OV_ECTL_RATEMANAGE2_GET and -OV_ECTL_RATEMANAGE2_SET calls in order to query and modify specifics -of the encoder's bitrate management configuration. - -

    - - - - - -
    -
    struct ovectl_ratemanage2_arg {
    -  int    management_active;
    -
    -  long   bitrate_limit_min_kbps;
    -  long   bitrate_limit_max_kbps;
    -  long   bitrate_limit_reservoir_bits;
    -  double bitrate_limit_reservoir_bias;
    -
    -  long   bitrate_average_kbps;
    -  double bitrate_average_damping;
    -};
    -
    - -

    Relevant Struct Members

    -
    -
    management_active
    -
    nonzero if bitrate management is active
    - -
    bitrate_limit_min_kbps
    -
    Lower allowed bitrate limit in kilobits per second
    -
    bitrate_limit_max_kbps
    -
    Upper allowed bitrate limit in kilobits per second
    -
    bitrate_limit_reservoir_bits
    -
    Size of the bitrate reservoir in bits
    -
    bitrate_limit_reservoir_bias
    - -
    Regulates the bitrate reservoir's preferred fill level in a range -from 0.0 to 1.0; 0.0 tries to bank bits to buffer against future -bitrate spikes, 1.0 buffers against future sudden drops in -instantaneous bitrate. Default is 0.1
    - -
    bitrate_average_kbps
    -
    Average bitrate setting in kilobits per second
    - -
    bitrate_average_damping
    Slew rate limit setting -for average bitrate adjustment; sets the minimum time in seconds the -bitrate tracker may swing from one extreme to the other when boosting -or damping average bitrate.
    - - - -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/ovectl_ratemanage_arg.html b/Engine/lib/libvorbis/doc/vorbisenc/ovectl_ratemanage_arg.html deleted file mode 100644 index f64c05782..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/ovectl_ratemanage_arg.html +++ /dev/null @@ -1,92 +0,0 @@ - - - -vorbis - datatype - ovectl_ratemanage_arg - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    ovectl_ratemanage_arg

    - -

    declared in "vorbis/vorbisenc.h"

    - -

    - -The ovectl_ratemanage_arg structure is used with vorbis_encode_ctl() and the OV_ECTL_RATEMANAGE_GET, -OV_ECTL_RATEMANAGE_SET, OV_ECTL_RATEMANAGE_AVG, -OV_ECTL_RATEMANAGE_HARD calls in order to query and modify specifics -of the encoder's bitrate management configuration. Note that this is -a deprecated interface; please use vorbis_encode_ctl() with the ovectl_ratemanage2_arg struct -and OV_ECTL_RATEMANAGE2_GET and OV_ECTL_RATEMANAGE2_SET calls in new -code. - -

    - - - - - -
    -
    struct ovectl_ratemanage_arg {
    -  int    management_active;
    -
    -  long   bitrate_hard_min;
    -  long   bitrate_hard_max;
    -  double bitrate_hard_window;
    -
    -  long   bitrate_av_lo;
    -  long   bitrate_av_hi;
    -  double bitrate_av_window;
    -  double bitrate_av_window_center;
    -};
    -
    - -

    Relevant Struct Members

    -
    - -
    management_active
    -
    nonzero if bitrate management is active
    - -
    bitrate_hard_min
    -
    hard lower limit (in kilobits per second) below which the stream bitrate will never be allowed for any given bitrate_hard_window seconds of time.
    -
    bitrate_hard_max
    -
    hard upper limit (in kilobits per second) above which the stream bitrate will never be allowed for any given bitrate_hard_window seconds of time.
    -
    bitrate_hard_window
    -
    the window period (in seconds) used to regulate the hard bitrate minimum and maximum
    - -
    bitrate_av_lo
    -
    soft lower limit (in kilobits per second) below which the average bitrate tracker will start nudging the bitrate higher.
    -
    bitrate_av_hi
    -
    soft upper limit (in kilobits per second) above which the average bitrate tracker will start nudging the bitrate lower.
    -
    bitrate_av_window
    -
    the window period (in seconds) used to regulate the average bitrate minimum and maximum.
    -
    bitrate_av_window_center
    -
    Regulates the relative centering of the average and hard windows; in libvorbis 1.0 and 1.0.1, the hard window regulation overlapped but followed the average window regulation. In libvorbis 1.1 a bit-reservoir interface replaces the old windowing interface; the older windowing interface is simulated and this field has no effect.
    - -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/overview.html b/Engine/lib/libvorbis/doc/vorbisenc/overview.html deleted file mode 100644 index cf439b5b5..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/overview.html +++ /dev/null @@ -1,382 +0,0 @@ - - - -libvorbisenc - API Overview - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    Libvorbisenc API Overview

    - -

    Libvorbisenc is an encoding convenience library intended to -encapsulate the elaborate setup that libvorbis requires for encoding. -Libvorbisenc gives easy access to all high-level adjustments an -application may require when encoding and also exposes some low-level -tuning parameters to allow applications to make detailed adjustments -to the encoding process.

    - -All the libvorbisenc routines are declared in "vorbis/vorbisenc.h". - -Note: libvorbis and libvorbisenc always -encode in a single pass. Thus, all possible encoding setups will work -properly with live input and produce streams that decode properly when -streamed. See the subsection titled "managed bitrate -modes" for details on setting limits on bitrate usage when Vorbis -streams are used in a limited-bandwidth environment. - -

    workflow

    - -

    Libvorbisenc is used only during encoder setup; its function -is to automate initialization of a multitude of settings in a -vorbis_info structure which libvorbis then uses as a reference -during the encoding process. Libvorbisenc plays no part in the -encoding process after setup. - -

    Encode setup using libvorbisenc consists of three steps: - -

      -
    1. high-level initialization of a vorbis_info structure by -calling one of vorbis_encode_setup_vbr() or vorbis_encode_setup_managed() -with the basic input audio parameters (rate and channels) and the -basic desired encoded audio output parameters (VBR quality or ABR/CBR -bitrate)

      - -

    2. optional adjustment of the basic setup defaults using vorbis_encode_ctl()

      - -

    3. calling vorbis_encode_setup_init() to -finalize the high-level setup into the detailed low-level reference -values needed by libvorbis to encode audio. The vorbis_info -structure is then ready to use for encoding by libvorbis.

      - -

    - -These three steps can be collapsed into a single call by using vorbis_encode_init_vbr to set up a -quality-based VBR stream or vorbis_encode_init to set up a managed -bitrate (ABR or CBR) stream.

    - -

    adjustable encoding parameters

    - -

    input audio parameters

    - -

    - - - - - - - - - - - - - -
    parameterdescription
    sampling rate -The sampling rate (in samples per second) of the input audio. Common examples are 8000 for telephony, 44100 for CD audio and 48000 for DAT. Note that a mono sample (one center value) and a stereo sample (one left value and one right value) both are a single sample. - -
    channels - -The number of channels encoded in each input sample. By default, -stereo input modes (two channels) are 'coupled' by Vorbis 1.1 such -that the stereo relationship between the samples is taken into account -when encoding. Stereo coupling my be disabled by using vorbis_encode_ctl() with OV_ECTL_COUPLE_SET. - -
    - -

    quality and VBR modes

    - -Vorbis is natively a VBR codec; a user requests a given constant -quality and the encoder keeps the encoding quality constant -while allowing the bitrate to vary. 'Quality' modes (Variable BitRate) -will always produce the most consistent encoding results as well as -the highest quality for the amount of bits used. - -

    - - - - - - - - - -
    parameterdescription
    quality -A decimal float value requesting a desired quality. Libvorbisenc 1.1 allows quality requests in the range of -0.1 (lowest quality, smallest files) through +1.0 (highest-quality, largest files). Quality -0.1 is intended as an ultra-low setting in which low bitrate is much more important than quality consistency. Quality settings 0.0 and above are intended to produce consistent results at all times. - -
    - - -

    managed bitrate modes

    - -Although the Vorbis codec is natively VBR, libvorbis includes -infrastructure for 'managing' the bitrate of streams by setting -minimum and maximum usage constraints, as well as functionality for -nudging a stream toward a desired average value. These features -should only be used when there is a requirement to limit -bitrate in some way. Although the difference is usually slight, -managed bitrate modes will always produce output inferior to VBR -(given equal bitrate usage). Setting overly or impossibly tight -bitrate management requirements can affect output quality dramatically -for the worse.

    - -Beginning in libvorbis 1.1, bitrate management is implemented using a -bit-reservoir algorithm. The encoder has a fixed-size -reservoir used as a 'savings account' in encoding. When a frame is -smaller than the target rate, the unused bits go into the reservoir so -that they may be used by future frames. When a frame is larger than -target bitrate, it draws 'banked' bits out of the reservoir. Encoding -is managed so that the reservoir never goes negative (when a maximum -bitrate is specified) or fills beyond a fixed limit (when a minimum -bitrate is specified). An 'average bitrate' request is used as the -set-point in a long-range bitrate tracker which adjusts the encoder's -aggressiveness up or down depending on whether or not frames are coming -in larger or smaller than the requested average point. - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    parameterdescription
    maximum bitrate The maximum allowed bitrate, set in bits -per second. If the bitrate would otherwise rise such that oversized -frames would underflow the bit-reservoir by consuming banked bits, -bitrate management will force the encoder to use fewer bits per frame -by encoding with a more aggressive psychoacoustic model.

    This -setting is a hard limit; the bitstream will never be allowed, under -any circumstances, to increase above the specified bitrate over the -average period set by the reservoir; it may momentarily rise over if -inspected on a granularity much finer than the average period across -the reservoir. Normally, the encoder will conserve bits gracefully by -using more aggressive psychoacoustics to shrink a frame when forced -to. However, if the encoder runs out of means of gracefully shrinking -a frame, it will simply take the smallest frame it can otherwise -generate and truncate it to the maximum allowed length. Note that -this is not an error and although it will obviously adversely affect -audio quality, a Vorbis decoder will be able to decode a truncated -frame into audio. - -

    average bitrate - -The average desired bitrate of a stream, set -in bits per second. Average bitrate is tracked via a reservoir like -minimum and maximum bitrate, however the averaging reservior does not -impose a hard limit; it is used to nudge the bitrate toward the -desired average by slowly adjusting the psychoacoustic aggressiveness. -As such, the reservoir size does not affect the average bitrate -behavior. Because this setting alone is not used to impose hard -bitrate limits, the bitrate of a stream produced using only the -average bitrate constraint will track the average over time -but not necessarily adhere strictly to that average for any given -period. Should a strict localized average be required, average -bitrate should be used along with minimum bitrate and -maximum bitrate. -
    minimum bitrate - The minimum allowed bitrate, set in bits per second. If -the bitrate would otherwise fall such that undersized frames would -overflow the bit-reservoir with unused bits, bitrate management will -force the encoder to use more bits per frame by encoding with a less -aggressive psychoacoustic model.

    This setting is a hard limit; the -bitstream will never be allowed, under any circumstances, to drop -below the specified bitrate over the average period set by the -reservoir; it may momentarily fall under if inspected on a granularity -much finer than the average period across the reservoir. Normally, -the encoder will fill out undersided frames with additional useful -coding information by increasing the perceived quality of the stream. -If the encoder runs out of useful ways to consume more bits, it will -pad frames out with zeroes. -

    reservoir size The size of the minimum/maximum bitrate -tracking reservoir, set in bits. The reservoir is used as a 'bit -bank' to average out localized surges and dips in bitrate while -providing predictable, guaranteed buffering behavior for streams to be -used in situations with constrained transport bandwidth. The default -setting is two seconds of average bitrate.

    - -When a single frame is larger than the maximum allowed overall -bitrate, the bits are 'borrowed' from the bitrate reservoir; if the -reservoir contains insufficient bits to cover the defecit, the encoder -must find some way to reduce the frame size.

    - -When a frame is under the minimum limit, the surplus bits are placed -into the reservoir, banking them for future use. If the reservoir is -already full of banked bits, the encoder is forced to find some way to -make the frame larger.

    - -If the frame size is between the minimum and maximum rates (thus -implying the minimum and maximum allowed rates are different), the -reservoir gravitates toward a fill point configured by the -reservoir bias setting described next. If the reservoir is -fuller than the fill point (a 'surplus of surplus'), the encoder will -consume a number bits from the reservoir equal to the number of the -bits by which the frame exceeds minimum size. If the reservoir is -emptier than the fillpoint (a 'surplus of defecit'), bits are returned -to the reservoir equaling the current frame's number of bits under the -maximum frame size. The idea of the fill point is to buffer against -both underruns and overruns, by trying to hold the reservoir to a -middle course. -

    reservoir bias - -Reservoir bias is a setting between 0.0 and 1.0 that biases bitrate -management toward smoothing bitrate spikes (0.0) or bitrate peaks -(1.0); the default setting is 0.1.

    - -Using settings toward 0.0 causes the bitrate manager to hoard bits in -the bit reservoir such that there is a large pool of banked surplus to -draw upon during short spikes in bitrate. As a result, the encoder -will react less aggressively and less drastically to curtail framesize -during brief surges in bitrate.

    - -Using settings toward 1.0 causes the bitrate manager to empty the bit -reservoir such that there is a large buffer available to store surplus -bits during sudden drops in bitrate. As a result, the encoder will -react less aggressively and less drastically to support minimum frame -sizes during drops in bitrate and will tend not to store any extra -bits in the reservoir for future bitrate spikes.

    - -

    average track damping - -A decimal value, in seconds, that controls how quickly the average -bitrate tracker is allowed to slew from enforcing minimum frame sizes -to maximum framesizes and vice versa. Default value is 1.5 -seconds.

    - -When the 'average bitrate' setting is in use, the average bitrate -tracker uses an unbounded reservoir to track overall bitrate-to-date -in the stream. When bitrates are too low, the tracker will try to -nudge bitrates up and when the bitrate is too high, nudge it down. -The damping value regulates the maximum strength of the nudge; it -describes, in seconds, how quickly the tracker may transition from an -extreme nudge in one direction to an extreme nudge in the other.

    - -

    - -

    encoding model adjustments

    - -The
    vorbis_encode_ctl() call provides -a generalized interface for making encoding setup adjustments to the -basic high-level setup provided by vorbis_encode_setup_vbr() or vorbis_encode_setup_managed(). -In reality, these two calls use vorbis_encode_ctl() internally, and vorbis_encode_ctl() can be used to adjust -most of the parameters set by other calls.

    - -In Vorbis 1.1, vorbis_encode_ctl() can -adjust the following additional parameters not described elsewhere: - -

    - - - - - - - - - - - - - - - - - - - - -
    parameterdescription
    management mode Configures whether or not bitrate -management is in use or not. Normally, this value is set implicitly -during encoding setup; however, the supported means of selecting a -quality mode by bitrate (that is, requesting a true VBR stream, but -doing so by asking for an approximate bitrate) is to use vorbis_encode_setup_managed() -and then to explicitly turn off bitrate management by calling vorbis_encode_ctl() with OV_ECTL_RATEMANAGE2_SET -
    coupling Stereo encoding (and in the future, surround -encodings) are normally encoded assuming the channels form a stereo -image and that lossy-stereo modelling is appropriate; this is called -'coupling'. Stereo coupling may be explicitly enabled or disabled. -
    lowpass Sets the hard lowpass of a given encoding mode; -this may be used to conserve a few bits in high-rate audio that has -limited bandwidth, or in testing of the encoder's acoustic model. The -encoder is generally already configured with ideal lowpasses (if any -at all) for given modes; use of this parameter is strongly discouraged -if the point is to try to 'improve' a given encoding mode for general -encoding. -
    impulse coding aggressiveness By default, libvorbis -attempts to compromise between preventing wide bitrate swings and -high-resolution impulse coding (which is required for the crispest -possible attacks, but also requires a relatively large momentary -bitrate increase). This parameter allows an application to tune the -compromise or eliminate it; A value of 0.0 indicates normal behavior -while a value of -15.0 requests maximum possible impulse -resolution.
    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/reference.html b/Engine/lib/libvorbis/doc/vorbisenc/reference.html deleted file mode 100644 index 041ebd3aa..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/reference.html +++ /dev/null @@ -1,54 +0,0 @@ - - - -Vorbisfile API Reference - - - - - - - - - -

    vorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    Vorbisenc API Reference

    - -

    Data Structures

    - -

    -vorbis_info (from libvorbis)
    -ovectl_ratemanage_arg
    -ovectl_ratemanage2_arg
    -

    - -

    Encoder Setup

    - -

    -vorbis_encode_ctl()
    -vorbis_encode_init()
    -vorbis_encode_init_vbr()
    -vorbis_encode_setup_init()
    -vorbis_encode_setup_managed()
    -vorbis_encode_setup_vbr()
    -

    - -

    The actual encoding is done using the libvorbis API.

    - -
    -
    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/style.css b/Engine/lib/libvorbis/doc/vorbisenc/style.css deleted file mode 100644 index 81cf41795..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/style.css +++ /dev/null @@ -1,7 +0,0 @@ -BODY { font-family: Helvetica, sans-serif } -TD { font-family: Helvetica, sans-serif } -P { font-family: Helvetica, sans-serif } -H1 { font-family: Helvetica, sans-serif } -H2 { font-family: Helvetica, sans-serif } -H4 { font-family: Helvetica, sans-serif } -P.tiny { font-size: 8pt } diff --git a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_ctl.html b/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_ctl.html deleted file mode 100644 index b1d836e03..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_ctl.html +++ /dev/null @@ -1,183 +0,0 @@ - - - -libvorbisenc - function - vorbis_encode_ctl - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    vorbis_encode_ctl

    - -

    declared in "vorbis/vorbisenc.h";

    - -

    This function implements a generic interface to miscellaneous -encoder settings similar to the clasasic UNIX 'ioctl()' system call. -Applications may use vorbis_encode_ctl() to query or set bitrate -management or quality mode details by using one of several -request arguments detailed below. Vorbis_encode_ctl() must be -called after one of vorbis_encode_setup_managed() -or vorbis_encode_setup_vbr(). -When used to modify settings, vorbis_encode_ctl() must be called -before vorbis_encode_setup_init(). - -

    -

    - - - - -
    -
    
    -extern int vorbis_encode_ctl(vorbis_info *vi,int request,void *arg);
    -
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    Pointer to an initialized vorbis_info struct.

    -

    request
    -
    Specifies the desired action; possible request fields are detailed below.

    -

    arg
    -
    void * pointing to a data structure matching the request argument.

    -

    - -

    Requests

    -
    - -
    OV_ECTL_RATEMANAGE2_GET
    - -
    Argument: struct -ovectl_ratemanage2_arg *
    Used to query the current -encoder bitrate management setting. Also used to initialize fields of -an ovectl_ratemanage2_arg structure for use with -OV_ECTL_RATEMANAGE2_SET.

    - -

    OV_ECTL_RATEMANAGE2_SET
    -
    Argument: struct -ovectl_ratemanage2_arg *
    Used to set the current -encoder bitrate management settings to the values listed in the -ovectl_ratemanage2_arg. Passing a NULL pointer will disable bitrate -management. -

    - -

    OV_ECTL_LOWPASS_GET
    -
    Argument: double *
    Returns the current encoder hard-lowpass -setting (kHz) in the double pointed to by arg. -

    - -

    OV_ECTL_LOWPASS_SET
    -
    Argument: double *
    Sets the encoder hard-lowpass to the value -(kHz) pointed to by arg. Valid lowpass settings range from 2 to 99. -

    - -

    OV_ECTL_IBLOCK_GET
    -
    Argument: double *
    Returns the current encoder impulse -block setting in the double pointed to by arg.

    - -

    OV_ECTL_IBLOCK_SET
    Argument: double *
    Sets -the impulse block bias to the the value pointed to by arg; valid range -is -15.0 to 0.0 [default]. A negative impulse block bias will direct -to encoder to use more bits when incoding short blocks that contain -strong impulses, thus improving the accuracy of impulse encoding.

    - -

    OV_ECTL_COUPLING_GET
    -
    Argument: int *
    -Returns the current encoder coupling enabled/disabled -setting in the int pointed to by arg. -

    - -

    OV_ECTL_COUPLING_SET
    -
    Argument: int *
    -Enables/disables channel coupling in multichannel encoding according to arg. -*arg of zero disables all channel coupling, nonzero allows the encoder to use -coupling if a coupled mode is available for the input. At present, coupling -is available for stereo and 5.1 input modes. -

    - -

    OV_ECTL_RATEMANAGE_GET [deprecated]
    -
    - -Argument: struct -ovectl_ratemanage_arg *
    Old interface to querying bitrate -management settings; deprecated after move to bit-reservoir style -management in 1.1 rendered this interface partially obsolete. Please -use OV_ECTL_RATEMANGE2_GET instead. - -

    - -

    OV_ECTL_RATEMANAGE_SET [deprecated]
    -
    -Argument: struct -ovectl_ratemanage_arg *
    Old interface to modifying bitrate -management settings; deprecated after move to bit-reservoir style -management in 1.1 rendered this interface partially obsolete. Please -use OV_ECTL_RATEMANGE2_SET instead. -

    - -

    OV_ECTL_RATEMANAGE_AVG [deprecated]
    -
    -Argument: struct -ovectl_ratemanage_arg *
    Old interface to setting -average-bitrate encoding mode; deprecated after move to bit-reservoir -style management in 1.1 rendered this interface partially obsolete. -Please use OV_ECTL_RATEMANGE2_SET instead. -

    - -

    OV_ECTL_RATEMANAGE_HARD [deprecated]
    -
    -Argument: struct -ovectl_ratemanage_arg *
    Old interface to setting -bounded-bitrate encoding modes; deprecated after move to bit-reservoir -style management in 1.1 rendered this interface partially obsolete. -Please use OV_ECTL_RATEMANGE2_SET instead. -

    - - -

    - - -

    Return Values

    vorbis_encode_ctl() returns zero on success, -placing any further return information (such as the result of a query) -into the storage pointed to by *arg. On error, -vorbis_encode_ctl() may return one of the following error codes: - -
    - -
    OV_EINVAL
    Invalid argument, or an attempt to modify a -setting after calling vorbis_encode_setup_init().

    - -

    OV_EIMPL
    Unimplemented or unknown request

    - -

    - -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_init.html b/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_init.html deleted file mode 100644 index 4f5728095..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_init.html +++ /dev/null @@ -1,88 +0,0 @@ - - - -libvorbisenc - function - vorbis_encode_init - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    vorbis_encode_init

    - -

    declared in "vorbis/vorbisenc.h";

    - -

    This is the primary function within libvorbisenc for setting up managed bitrate modes. -

    Before this function is called, the vorbis_info struct should be initialized by using vorbis_info_init() from the libvorbis API. After encoding, vorbis_info_clear should be called. -

    The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set constraints for the encoded file. This function uses these settings to select the appropriate encoding mode and set it up. -

    -

    - - - - -
    -
    
    -extern int vorbis_encode_init(vorbis_info *vi,
    -			      long channels,
    -			      long rate,
    -			      
    -			      long max_bitrate,
    -			      long nominal_bitrate,
    -			      long min_bitrate);
    -
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    Pointer to an initialized vorbis_info struct.
    -
    channels
    -
    The number of channels to be encoded.
    -
    rate
    -
    The sampling rate of the source audio.
    -
    max_bitrate
    -
    Desired maximum bitrate (limit). -1 indicates unset.
    -
    nominal_bitrate
    -
    Desired average, or central, bitrate. -1 indicates unset.
    -
    min_bitrate
    -
    Desired minimum bitrate. -1 indicates unset.
    -
    - - -

    Return Values

    -
    -
  • -0 for success
  • - -
  • less than zero for failure:
  • -
      -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    • OV_EINVAL - Invalid setup request, eg, out of range argument.
    • -
    • OV_EIMPL - Unimplemented mode; unable to comply with bitrate request.
    • -
    -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_init_vbr.html b/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_init_vbr.html deleted file mode 100644 index d37b87c57..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_init_vbr.html +++ /dev/null @@ -1,81 +0,0 @@ - - - -libvorbisenc - function - vorbis_encode_init_vbr - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    vorbis_encode_init_vbr

    - -

    declared in "vorbis/vorbisenc.h";

    - -

    This is the primary function within libvorbisenc for setting up variable bitrate ("quality" based) modes. -

    Before this function is called, the vorbis_info struct should be initialized by using vorbis_info_init() from the libvorbis API. After encoding, vorbis_info_clear should be called. -

    -

    - - - - -
    -
    
    -extern int vorbis_encode_init_vbr(vorbis_info *vi,
    -			      long channels,
    -			      long rate,
    -			      
    -			      float base_quality);
    -
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    Pointer to an initialized vorbis_info struct.
    -
    channels
    -
    The number of channels to be encoded.
    -
    rate
    -
    The sampling rate of the source audio.
    -
    base_quality
    -
    Desired quality level, currently from -0.1 to 1.0 (lo to hi).
    -
    - - -

    Return Values

    -
    -
  • -0 for success
  • - -
  • less than zero for failure:
  • -
      -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    • OV_EINVAL - Invalid setup request, eg, out of range argument.
    • -
    • OV_EIMPL - Unimplemented mode; unable to comply with quality level request.
    • -
    -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_setup_init.html b/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_setup_init.html deleted file mode 100644 index 752d40af9..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_setup_init.html +++ /dev/null @@ -1,88 +0,0 @@ - - - -libvorbisenc - function - vorbis_encode_setup_init - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    vorbis_encode_setup_init

    - -

    declared in "vorbis/vorbisenc.h";

    - -

    This function performs the last stage of three-step encoding setup, as described in the API overview under managed bitrate modes. - -

    Before this function is called, the vorbis_info struct should be initialized -by using vorbis_info_init() from the libvorbis API, one of vorbis_encode_setup_managed() -or vorbis_encode_setup_vbr() -called to initialize the high-level encoding setup, and vorbis_encode_ctl() called if -necessary to make encoding setup changes. vorbis_encode_setup_init() -finalizes the highlevel encoding structure into a complete encoding -setup after which the application may make no further setup changes.

    - -After encoding, vorbis_info_clear should be called. -

    -

    - - - - -
    -
    
    -extern int vorbis_encode_setup_init(vorbis_info *vi);
    -
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    Pointer to an initialized vorbis_info struct.
    -
    - - -

    Return Values

    -
    -
  • -0 for success
  • - -
  • less than zero for failure:
  • -
      -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    • OV_EINVAL - Attempt to use vorbis_encode_setup_init() without first calling one of vorbis_encode_setup_managed() -or vorbis_encode_setup_vbr() -to initialize the high-level encoding setup -
    • -
    -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_setup_managed.html b/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_setup_managed.html deleted file mode 100644 index bea9aa233..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_setup_managed.html +++ /dev/null @@ -1,102 +0,0 @@ - - - -libvorbisenc - function - vorbis_encode_setup_managed - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    vorbis_encode_setup_managed

    - -

    declared in "vorbis/vorbisenc.h";

    - -

    This function performs step-one of a three-step bitrate-managed -encode setup. It functions similarly to the one-step setup performed -by vorbis_encode_init() but -allows an application to make further encode setup tweaks using vorbis_encode_ctl() before finally -calling vorbis_encode_setup_init() to -complete the setup process. - -

    Before this function is called, the vorbis_info struct should be initialized -by using vorbis_info_init() from the libvorbis API. After encoding, -vorbis_info_clear should be called. - -

    The max_bitrate, nominal_bitrate, and min_bitrate settings are used -to set constraints for the encoded file. This function uses these -settings to select the appropriate encoding mode and set it up. -

    -

    - - - - -
    -
    
    -extern int vorbis_encode_init(vorbis_info *vi,
    -			      long channels,
    -			      long rate,
    -			      
    -			      long max_bitrate,
    -			      long nominal_bitrate,
    -			      long min_bitrate);
    -
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    Pointer to an initialized vorbis_info struct.
    -
    channels
    -
    The number of channels to be encoded.
    -
    rate
    -
    The sampling rate of the source audio.
    -
    max_bitrate
    -
    Desired maximum bitrate (limit). -1 indicates unset.
    -
    nominal_bitrate
    -
    Desired average, or central, bitrate. -1 indicates unset.
    -
    min_bitrate
    -
    Desired minimum bitrate. -1 indicates unset.
    -
    - - -

    Return Values

    -
    -
  • -0 for success
  • - -
  • less than zero for failure:
  • -
      -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    • OV_EINVAL - Invalid setup request, eg, out of range argument.
    • -
    • OV_EIMPL - Unimplemented mode; unable to comply with bitrate request.
    • -
    -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_setup_vbr.html b/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_setup_vbr.html deleted file mode 100644 index 4b59c3c28..000000000 --- a/Engine/lib/libvorbis/doc/vorbisenc/vorbis_encode_setup_vbr.html +++ /dev/null @@ -1,90 +0,0 @@ - - - -libvorbisenc - function - vorbis_encode_setup_vbr - - - - - - - - - -

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - -

    vorbis_encode_setup_vbr

    - -

    declared in "vorbis/vorbisenc.h";

    - -

    This function performs step-one of a three-step variable bitrate -(quality-based) encode setup. It functions similarly to the one-step -setup performed by vorbis_encode_init_vbr() but -allows an application to make further encode setup tweaks using vorbis_encode_ctl() before finally -calling vorbis_encode_setup_init() to -complete the setup process. - -

    Before this function is called, the vorbis_info struct should be initialized by using vorbis_info_init() from the libvorbis API. After encoding, vorbis_info_clear should be called. -

    -

    - - - - -
    -
    
    -extern int vorbis_encode_init_vbr(vorbis_info *vi,
    -			      long channels,
    -			      long rate,
    -			      
    -			      float base_quality);
    -
    -
    -
    - -

    Parameters

    -
    -
    vi
    -
    Pointer to an initialized vorbis_info struct.
    -
    channels
    -
    The number of channels to be encoded.
    -
    rate
    -
    The sampling rate of the source audio.
    -
    base_quality
    -
    Desired quality level, currently from -0.1 to 1.0 (lo to hi).
    -
    - - -

    Return Values

    -
    -
  • -0 for success
  • - -
  • less than zero for failure:
  • -
      -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    • OV_EINVAL - Invalid setup request, eg, out of range argument.
    • -
    • OV_EIMPL - Unimplemented mode; unable to comply with quality level request.
    • -
    -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    libvorbisenc documentation

    libvorbisenc version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/Makefile.am b/Engine/lib/libvorbis/doc/vorbisfile/Makefile.am deleted file mode 100644 index fb27d44ae..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -## Process this file with automake to produce Makefile.in - -docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION)/vorbisfile - -doc_DATA = OggVorbis_File.html callbacks.html chaining_example_c.html\ - chainingexample.html crosslap.html datastructures.html decoding.html\ - example.html exampleindex.html fileinfo.html index.html\ - initialization.html ov_bitrate.html ov_bitrate_instant.html\ - ov_callbacks.html ov_clear.html ov_comment.html ov_crosslap.html\ - ov_fopen.html\ - ov_info.html ov_open.html ov_open_callbacks.html ov_pcm_seek.html\ - ov_pcm_seek_lap.html ov_pcm_seek_page.html ov_pcm_seek_page_lap.html\ - ov_pcm_tell.html ov_pcm_total.html ov_raw_seek.html\ - ov_raw_seek_lap.html ov_raw_tell.html ov_raw_total.html ov_read.html\ - ov_read_float.html ov_read_filter.html\ - ov_seekable.html ov_serialnumber.html\ - ov_streams.html ov_test.html ov_test_callbacks.html ov_test_open.html\ - ov_time_seek.html ov_time_seek_lap.html ov_time_seek_page.html\ - ov_time_seek_page_lap.html ov_time_tell.html ov_time_total.html\ - overview.html reference.html seekexample.html seeking.html\ - seeking_example_c.html seeking_test_c.html seekingexample.html\ - style.css threads.html\ - vorbisfile_example_c.html - -EXTRA_DIST = $(doc_DATA) diff --git a/Engine/lib/libvorbis/doc/vorbisfile/OggVorbis_File.html b/Engine/lib/libvorbis/doc/vorbisfile/OggVorbis_File.html deleted file mode 100644 index 795beb10e..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/OggVorbis_File.html +++ /dev/null @@ -1,137 +0,0 @@ - - - -Vorbisfile - datatype - OggVorbis_File - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    OggVorbis_File

    - -

    declared in "vorbis/vorbisfile.h"

    - -

    -The OggVorbis_File structure defines an Ogg Vorbis file. -

    - -This structure is used in all libvorbisfile routines. Before it can -be used, it must be initialized by ov_open(), ov_fopen(), or ov_open_callbacks(). Important -Note: The use of ov_open() is -discouraged under Windows due to a peculiarity of Windows linking -convention; use ov_fopen() or ov_open_callbacks() instead. This -caution only applies to Windows; use of ov_open() is appropriate for all other -platforms. See the ov_open() page for more -information. - -

    -After use, the OggVorbis_File structure must be deallocated with a -call to ov_clear(). - -

    -Note that once a file handle is passed to a successful ov_open() call, the handle is owned by -libvorbisfile and will be closed by libvorbisfile later during the -call to ov_clear(). The handle should not -be used or closed outside of the libvorbisfile API. Similarly, files -opened by ov_fopen() will also be closed -internally by vorbisfile in ov_clear().

    - -ov_open_callbacks() allows the -application to choose whether libvorbisfile will or will not close the -handle in ov_clear(); see the ov_open_callbacks() page for more information.

    - -If a call to ov_open() or ov_open_callbacks() fails, -libvorbisfile does not assume ownership of the handle and the -application is expected to close it if necessary. A failed ov_fopen() call will internally close the -file handle if the open process fails.

    - -

    - - - - -
    -
    typedef struct {
    -  void             *datasource; /* Pointer to a FILE *, etc. */
    -  int              seekable;
    -  ogg_int64_t      offset;
    -  ogg_int64_t      end;
    -  ogg_sync_state   oy; 
    -
    -  /* If the FILE handle isn't seekable (eg, a pipe), only the current
    -     stream appears */
    -  int              links;
    -  ogg_int64_t      *offsets;
    -  ogg_int64_t      *dataoffsets;
    -  long             *serialnos;
    -  ogg_int64_t      *pcmlengths;
    -  vorbis_info      *vi;
    -  vorbis_comment   *vc;
    -
    -  /* Decoding working state local storage */
    -  ogg_int64_t      pcm_offset;
    -  int              ready_state;
    -  long             current_serialno;
    -  int              current_link;
    -
    -  ogg_int64_t      bittrack;
    -  ogg_int64_t      samptrack;
    -
    -  ogg_stream_state os; /* take physical pages, weld into a logical
    -                          stream of packets */
    -  vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
    -  vorbis_block     vb; /* local working space for packet->PCM decode */
    -
    -  ov_callbacks callbacks;
    -
    -} OggVorbis_File;
    -
    - -

    Relevant Struct Members

    -
    -
    datasource
    - -
    Pointer to file or other ogg source. When using stdio based -file/stream access, this field contains a FILE pointer. When using -custom IO via callbacks, libvorbisfile treats this void pointer as a -black box only to be passed to the callback routines provided by the -application.
    - -
    seekable
    -
    Read-only int indicating whether file is seekable. E.g., a physical file is seekable, a pipe isn't.
    -
    links
    -
    Read-only int indicating the number of logical bitstreams within the physical bitstream.
    -
    ov_callbacks
    -
    Collection of file manipulation routines to be used on this data source. When using stdio/FILE access via ov_open(), the callbacks will be filled in with stdio calls or wrappers to stdio calls.
    -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/callbacks.html b/Engine/lib/libvorbis/doc/vorbisfile/callbacks.html deleted file mode 100644 index 7ce493a99..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/callbacks.html +++ /dev/null @@ -1,121 +0,0 @@ - - - -Vorbisfile - Callbacks and non-stdio I/O - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Callbacks and non-stdio I/O

    - -Although stdio is convenient and nearly universally implemented as per -ANSI C, it is not suited to all or even most potential uses of Vorbis. -For additional flexibility, embedded applications may provide their -own I/O functions for use with Vorbisfile when stdio is unavailable or not -suitable. One common example is decoding a Vorbis stream from a -memory buffer.

    - -Use custom I/O functions by populating an ov_callbacks structure and calling ov_open_callbacks() or ov_test_callbacks() rather than the -typical ov_open() or ov_test(). Past the open call, use of -libvorbisfile is identical to using it with stdio. - -

    Read function

    - -The read-like function provided in the read_func field is -used to fetch the requested amount of data. It expects the fetch -operation to function similar to file-access, that is, a multiple read -operations will retrieve contiguous sequential pieces of data, -advancing a position cursor after each read.

    - -The following behaviors are also expected:

    -

      -
    • a return of '0' indicates end-of-data (if the by-thread errno is unset) -
    • short reads mean nothing special (short reads are not treated as error conditions) -
    • a return of zero with the by-thread errno set to nonzero indicates a read error -
    -

    - -

    Seek function

    - -The seek-like function provided in the seek_func field is -used to request non-sequential data access by libvorbisfile, moving -the access cursor to the requested position. The seek function is -optional; if callbacks are only to handle non-seeking (streaming) data -or the application wishes to force streaming behavior, -seek_func and tell_func should be set to NULL. If -the seek function is non-NULL, libvorbisfile mandates the following -behavior: - -
      -
    • The seek function must always return -1 (failure) if the given -data abstraction is not seekable. It may choose to always return -1 -if the application desires libvorbisfile to treat the Vorbis data -strictly as a stream (which makes for a less expensive open -operation).

      - -

    • If the seek function initially indicates seekability, it must -always succeed upon being given a valid seek request.

      - -

    • The seek function must implement all of SEEK_SET, SEEK_CUR and -SEEK_END. The implementation of SEEK_END should set the access cursor -one past the last byte of accessible data, as would stdio -fseek()

      -

    - -

    Close function

    - -The close function should deallocate any access state used by the -passed in instance of the data access abstraction and invalidate the -instance handle. The close function is assumed to succeed; its return -code is not checked.

    - -The close_func may be set to NULL to indicate that libvorbis -should not attempt to close the file/data handle in ov_clear but allow the application to handle -file/data access cleanup itself. For example, by passing the normal -stdio calls as callback functions, but passing a close_func -that is NULL or does nothing (as in the case of OV_CALLBACKS_NOCLOSE), an -application may call ov_clear() and then -later fclose() the file originally passed to libvorbisfile. - -

    Tell function

    - -The tell function is intended to mimic the -behavior of ftell() and must return the byte position of the -next data byte that would be read. If the data access cursor is at -the end of the 'file' (pointing to one past the last byte of data, as -it would be after calling fseek(file,SEEK_END,0)), the tell -function must return the data position (and thus the total file size), -not an error.

    - -The tell function need not be provided if the data IO abstraction is -not seekable, or the application wishes to force streaming -behavior. In this case, the tell_func and seek_func -fields should be set to NULL.

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/chaining_example_c.html b/Engine/lib/libvorbis/doc/vorbisfile/chaining_example_c.html deleted file mode 100644 index b3e146cfa..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/chaining_example_c.html +++ /dev/null @@ -1,90 +0,0 @@ - - - -vorbisfile - chaining_example.c - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    chaining_example.c

    - -

    -The example program source: - -

    - - - - -
    -
    
    -
    -#include <vorbis/codec.h>
    -#include <vorbis/vorbisfile.h>
    -
    -int main(){
    -  OggVorbis_File ov;
    -  int i;
    -
    -#ifdef _WIN32 /* We need to set stdin to binary mode on windows. */
    -  _setmode( _fileno( stdin ), _O_BINARY );
    -#endif
    -
    -  /* open the file/pipe on stdin */
    -  if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)<0){
    -    printf("Could not open input as an OggVorbis file.\n\n");
    -    exit(1);
    -  }
    -  
    -  /* print details about each logical bitstream in the input */
    -  if(ov_seekable(&ov)){
    -    printf("Input bitstream contained %ld logical bitstream section(s).\n",
    -           ov_streams(&ov));
    -    printf("Total bitstream playing time: %ld seconds\n\n",
    -           (long)ov_time_total(&ov,-1));
    -
    -  }else{
    -    printf("Standard input was not seekable.\n"
    -           "First logical bitstream information:\n\n");
    -  }
    -
    -  for(i=0;i<ov_streams(&ov);i++){
    -    vorbis_info *vi=ov_info(&ov,i);
    -    printf("\tlogical bitstream section %d information:\n",i+1);
    -    printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
    -           vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
    -           ov_serialnumber(&ov,i));
    -    printf("\t\tcompressed length: %ld bytes ",(long)(ov_raw_total(&ov,i)));
    -    printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
    -  }
    -
    -  ov_clear(&ov);
    -  return 0;
    -}
    -
    -
    -
    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/chainingexample.html b/Engine/lib/libvorbis/doc/vorbisfile/chainingexample.html deleted file mode 100644 index 4c190b16b..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/chainingexample.html +++ /dev/null @@ -1,175 +0,0 @@ - - - -vorbisfile - Example Code - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Chaining Example Code

    - -

    -The following is a run-through of the chaining example program supplied -with vorbisfile - chaining_example.c. -This program demonstrates how to work with a chained bitstream. - -

    -First, relevant headers, including vorbis-specific "codec.h" and "vorbisfile.h" have to be included. - -

    - - - - -
    -
    
    -#include "vorbis/codec.h"
    -#include "vorbis/vorbisfile.h"
    -#include "../lib/misc.h"
    -
    -
    - -

    Inside main(), we declare our primary OggVorbis_File structure. We also declare a other helpful variables to track our progress within the file. -

    - - - - -
    -
    
    -int main(){
    -  OggVorbis_File ov;
    -  int i;
    -
    -
    - -

    This example takes its input on stdin which is in 'text' mode by default under Windows; this will corrupt the input data unless set to binary mode. This applies only to Windows. -

    - - - - -
    -
    
    -#ifdef _WIN32 /* We need to set stdin to binary mode under Windows */
    -  _setmode( _fileno( stdin ), _O_BINARY );
    -#endif
    -
    -
    - -

    We call ov_open_callbacks() to -initialize the OggVorbis_File -structure. ov_open_callbacks() -also checks to ensure that we're reading Vorbis format and not -something else. The OV_CALLBACKS_NOCLOSE callbacks instruct -libvorbisfile not to close stdin later during cleanup.

    - -

    - - - - -
    -
    
    -  if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)<0){
    -    printf("Could not open input as an OggVorbis file.\n\n");
    -    exit(1);
    -  }
    -
    -
    -
    - -

    -First we check to make sure the stream is seekable using ov_seekable. - -

    Then we're going to find the number of logical bitstreams in the physical bitstream using ov_streams. - -

    We use ov_time_total to determine the total length of the physical bitstream. We specify that we want the entire bitstream by using the argument -1. - -

    - - - - -
    -
    
    -  if(ov_seekable(&ov)){
    -    printf("Input bitstream contained %ld logical bitstream section(s).\n",
    -	   ov_streams(&ov));
    -    printf("Total bitstream playing time: %ld seconds\n\n",
    -	   (long)ov_time_total(&ov,-1));
    -
    -  }else{
    -    printf("Standard input was not seekable.\n"
    -	   "First logical bitstream information:\n\n");
    -  }
    -  
    -
    -
    - -

    Now we're going to iterate through each logical bitstream and print information about that bitstream. - -

    We use ov_info to pull out the vorbis_info struct for each logical bitstream. This struct contains bitstream-specific info. - -

    ov_serialnumber retrieves the unique serial number for the logical bistream. ov_raw_total gives the total compressed bytes for the logical bitstream, and ov_time_total gives the total time in the logical bitstream. - -

    - - - - -
    -
    
    -  for(i=0;i<ov_streams(&ov);i++){
    -    vorbis_info *vi=ov_info(&ov,i);
    -    printf("\tlogical bitstream section %d information:\n",i+1);
    -    printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
    -	   vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
    -	   ov_serialnumber(&ov,i));
    -    printf("\t\tcompressed length: %ld bytes ",(long)(ov_raw_total(&ov,i)));
    -    printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
    -  } 
    -
    -
    -

    -When we're done with the entire physical bitstream, we need to call ov_clear() to release the bitstream. - -

    - - - - -
    -
    
    -  ov_clear(&ov);
    -  return 0;
    -}
    -
    -
    - -

    -The full source for chaining_example.c can be found with the vorbis -distribution in chaining_example.c. - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/crosslap.html b/Engine/lib/libvorbis/doc/vorbisfile/crosslap.html deleted file mode 100644 index b6693249f..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/crosslap.html +++ /dev/null @@ -1,121 +0,0 @@ - - - -Vorbisfile - Sample Crosslapping - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    What is Crosslapping?

    - -

    Crosslapping blends two samples together using a window function, -such that any sudden discontinuities between the samples that may -cause clicks or thumps are eliminated or blended away. The technique -is nearly identical to how Vorbis internally splices together frames -of audio data during normal decode. API functions are provided to crosslap transitions between seperate -streams, or to crosslap when seeking within -a single stream. - -

    Why Crosslap?

    -

    The source of boundary clicks

    - -

    Vorbis is a lossy compression format such that any compressed -signal is at best a close approximation of the original. The -approximation may be very good (ie, indistingushable to the human -ear), but it is an approximation nonetheless. Even if a sample or set -of samples is contructed carefully such that transitions from one to -another match perfectly in the original, the compression process -introduces minute amplitude and phase errors. It's an unavoidable -result of such high compression rates. - -

    If an application transitions instantly from one sample to another, -any tiny discrepancy introduced in the lossy compression process -becomes audible as a stairstep discontinuity. Even if the discrepancy -in a normal lapped frame is only .1dB (usually far below the -threshhold of perception), that's a sudden cliff of 380 steps in a 16 -bit sample (when there's a boundary with no lapping). - -

    I thought Vorbis was gapless

    - -

    It is. Vorbis introduces no extra samples at the beginning or end -of a stream, nor does it remove any samples. Gapless encoding -eliminates 99% of the click, pop or outright blown speaker that would -occur if boundaries had gaps or made no effort to align -transitions. However, gapless encoding is not enough to entirely -eliminate stairstep discontinuities all the time for exactly the -reasons described above. - -

    Frame lapping, like Vorbis performs internally during continuous -playback, is necessary to eliminate that last epsilon of trouble. - -

    Easiest Crosslap

    - -The easiest way to perform crosslapping in Vorbis is to use the -lapping functions with no other extra effort. These functions behave -identically to when lapping isn't used except to provide -at-least-very-good lapping results. Crosslapping will not introduce -any samples into or remove any samples from the decoded audio; the -only difference is that the transition is lapped. Lapping occurs from -the current PCM position (either in the old stream, or at the position -prior to calling a lapping seek) forward into the next -half-short-block of audio data to be read from the new stream or -position. - -

    Ideally, vorbisfile internally reads an extra frame of audio from -the old stream/position to perform lapping into the new -stream/position. However, automagic crosslapping works properly even -if the old stream/position is at EOF. In this case, the synthetic -post-extrapolation generated by the encoder to pad out the last block -with appropriate data (and avoid encoding a stairstep, which is -inefficient) is used for crosslapping purposes. Although this is -synthetic data, the result is still usually completely unnoticable -even in careful listening (and always preferable to a click or pop). - -

    Vorbisfile will lap between streams of differing numbers of -channels. Any extra channels from the old stream are ignored; playback -of these channels simply ends. Extra channels in the new stream are -lapped from silence. Vorbisfile will also lap between streams links -of differing sample rates. In this case, the sample rates are ignored -(no implicit resampling is done to match playback). It is up to the -application developer to decide if this behavior makes any sense in a -given context; in practical use, these default behaviors perform -sensibly. - -

    Best Crosslap

    - -

    To acheive the best possible crosslapping results, avoid the case -where synthetic extrapolation data is used for crosslapping. That is, -design loops and samples such that a little bit of data is left over -in sample A when seeking to sample B. Normally, the end of sample A -and the beginning of B would overlap exactly; this allows -crosslapping to perform exactly as it would within vorbis when -stitching audio frames together into continuous decoded audio. - -

    The optimal amount of overlap is half a short-block, and this -varies by compression mode. Each encoder will vary in exact block -size selection; for vorbis 1.0, for -q0 through -q10 and 44kHz or -greater, a half-short block is 64 samples. - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/datastructures.html b/Engine/lib/libvorbis/doc/vorbisfile/datastructures.html deleted file mode 100644 index caf023c5e..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/datastructures.html +++ /dev/null @@ -1,61 +0,0 @@ - - - -Vorbisfile - Base Data Structures - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Base Data Structures

    -

    There are several data structures used to hold file and bitstream information during libvorbisfile decoding. These structures are declared in "vorbis/vorbisfile.h" and "vorbis/codec.h". -

    -

    When using libvorbisfile, it's not necessary to know about most of the contents of these data structures, but it may be helpful to understand what they contain. -

    - - - - - - - - - - - - - - - - - - - - - - -
    datatypepurpose
    OggVorbis_FileThis structure represents the basic file information. It contains - a pointer to the physical file or bitstream and various information about that bitstream.
    vorbis_commentThis structure contains the file comments. It contains - a pointer to unlimited user comments, information about the number of comments, and a vendor description.
    vorbis_infoThis structure contains encoder-related information about the bitstream. It includes encoder info, channel info, and bitrate limits.
    ov_callbacksThis structure contains pointers to the application-specified file manipulation routines set for use by ov_open_callbacks(). See also the provided document on using application-provided callbacks instead of stdio.
    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/decoding.html b/Engine/lib/libvorbis/doc/vorbisfile/decoding.html deleted file mode 100644 index 3ff8a0369..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/decoding.html +++ /dev/null @@ -1,92 +0,0 @@ - - - -Vorbisfile - Decoding - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Decoding

    - -

    -All libvorbisfile decoding routines are declared in "vorbis/vorbisfile.h". -

    - -After initialization, decoding audio -is as simple as calling ov_read() (or the -similar functions ov_read_float() and -ov_read_filter). This function works -similarly to reading from a normal file using read().

    - -However, a few differences are worth noting: - -

    multiple stream links

    - -A Vorbis stream may consist of multiple sections (called links) that -encode differing numbers of channels or sample rates. It is vitally -important to pay attention to the link numbers returned by ov_read and handle audio changes that may -occur at link boundaries. Such multi-section files do exist in the -wild and are not merely a specification curiosity. - -

    returned data amount

    - -ov_read does not attempt to completely fill -a large, passed in data buffer; it merely guarantees that the passed -back data does not overflow the passed in buffer size. Large buffers -may be filled by iteratively looping over calls to ov_read (incrementing the buffer pointer) -until the original buffer is filled. - -

    file cursor position

    - -Vorbis files do not necessarily start at a sample number or time offset -of zero. Do not be surprised if a file begins at a positive offset of -several minutes or hours, such as would happen if a large stream (such -as a concert recording) is chopped into multiple seperate files. - -

    - - - - - - - - - - - - - - - - - -
    functionpurpose
    ov_readThis function makes up the main chunk of a decode loop. It takes an -OggVorbis_File structure, which must have been initialized by a previous -call to ov_open(), ov_fopen(), -or ov_open_callbacks().
    ov_read_floatThis function decodes to floats instead of integer samples.
    ov_read_filterThis function works like ov_read, but passes the PCM data through the provided filter before converting to integer sample data.
    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/example.html b/Engine/lib/libvorbis/doc/vorbisfile/example.html deleted file mode 100644 index 9a6b0f62a..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/example.html +++ /dev/null @@ -1,208 +0,0 @@ - - - -Vorbisfile - Example Code - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Decoding Example Code

    - -

    -The following is a run-through of the decoding example program supplied -with libvorbisfile, vorbisfile_example.c. -This program takes a vorbis bitstream from stdin and writes raw pcm to stdout. - -

    -First, relevant headers, including vorbis-specific "vorbis/codec.h" and "vorbisfile.h" have to be included. - -

    - - - - -
    -
    
    -#include <stdio.h>
    -#include <stdlib.h>
    -#include <math.h>
    -#include "vorbis/codec.h"
    -#include "vorbisfile.h"
    -
    -
    -

    -We also have to make a concession to Windows users here. If we are using windows for decoding, we must declare these libraries so that we can set stdin/stdout to binary. -

    - - - - -
    -
    
    -#ifdef _WIN32
    -#include <io.h>
    -#include <fcntl.h>
    -#endif
    -
    -
    -

    -Next, a buffer for the pcm audio output is declared. - -

    - - - - -
    -
    
    -char pcmout[4096];
    -
    -
    - -

    Inside main(), we declare our primary OggVorbis_File structure. We also declare a few other helpful variables to track out progress within the file. -Also, we make our final concession to Windows users by setting the stdin and stdout to binary mode. -

    - - - - -
    -
    
    -int main(int argc, char **argv){
    -  OggVorbis_File vf;
    -  int eof=0;
    -  int current_section;
    -
    -#ifdef _WIN32
    -  _setmode( _fileno( stdin ), _O_BINARY );
    -  _setmode( _fileno( stdout ), _O_BINARY );
    -#endif
    -
    -
    - -

    We call ov_open_callbacks() to -initialize the OggVorbis_File structure with default values. -ov_open_callbacks() also checks -to ensure that we're reading Vorbis format and not something else. The -OV_CALLBACKS_NOCLOSE callbacks instruct libvorbisfile not to close -stdin later during cleanup. - -

    - - - - -
    -
    
    -  if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) {
    -      fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
    -      exit(1);
    -  }
    -
    -
    -
    - -

    -We're going to pull the channel and bitrate info from the file using ov_info() and show them to the user. -We also want to pull out and show the user a comment attached to the file using ov_comment(). - -

    - - - - -
    -
    
    -  {
    -    char **ptr=ov_comment(&vf,-1)->user_comments;
    -    vorbis_info *vi=ov_info(&vf,-1);
    -    while(*ptr){
    -      fprintf(stderr,"%s\n",*ptr);
    -      ++ptr;
    -    }
    -    fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
    -    fprintf(stderr,"\nDecoded length: %ld samples\n",
    -            (long)ov_pcm_total(&vf,-1));
    -    fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
    -  }
    -  
    -
    -
    - -

    -Here's the read loop: - -

    - - - - -
    -
    
    -
    -  while(!eof){
    -    long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&current_section);
    -    if (ret == 0) {
    -      /* EOF */
    -      eof=1;
    -    } else if (ret < 0) {
    -      /* error in the stream.  Not a problem, just reporting it in
    -	 case we (the app) cares.  In this case, we don't. */
    -    } else {
    -      /* we don't bother dealing with sample rate changes, etc, but
    -	 you'll have to*/
    -      fwrite(pcmout,1,ret,stdout);
    -    }
    -  }
    -
    -  
    -
    -
    - -

    -The code is reading blocks of data using ov_read(). -Based on the value returned, we know if we're at the end of the file or have invalid data. If we have valid data, we write it to the pcm output. - -

    -Now that we've finished playing, we can pack up and go home. It's important to call ov_clear() when we're finished. - -

    - - - - -
    -
    
    -
    -  ov_clear(&vf);
    -    
    -  fprintf(stderr,"Done.\n");
    -  return(0);
    -}
    -
    -
    - -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/exampleindex.html b/Engine/lib/libvorbis/doc/vorbisfile/exampleindex.html deleted file mode 100644 index afe9adab4..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/exampleindex.html +++ /dev/null @@ -1,39 +0,0 @@ - - - -vorbisfile - Documentation - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    VorbisFile Example Code

    - -

    -Three sample programs are included with the vorbisfile distribution. -

    -vorbisfile decoding
    -vorbisfile seeking
    -vorbisfile bitstream chaining
    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/fileinfo.html b/Engine/lib/libvorbis/doc/vorbisfile/fileinfo.html deleted file mode 100644 index a77bd2377..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/fileinfo.html +++ /dev/null @@ -1,95 +0,0 @@ - - - -Vorbisfile - File Information - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    File Information

    -

    Libvorbisfile contains many functions to get information about bitstream attributes and decoding status. -

    -All libvorbisfile file information routines are declared in "vorbis/vorbisfile.h". -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    functionpurpose
    ov_bitrateReturns the average bitrate of the current logical bitstream.
    ov_bitrate_instantReturns the exact bitrate since the last call of this function, or -1 if at the beginning of the bitream or no new information is available.
    ov_streamsGives the number of logical bitstreams within the current physical bitstream.
    ov_seekableIndicates whether the bitstream is seekable.
    ov_serialnumberReturns the unique serial number of the specified logical bitstream.
    ov_raw_totalReturns the total (compressed) bytes in a physical or logical seekable bitstream.
    ov_pcm_totalReturns the total number of samples in a physical or logical seekable bitstream.
    ov_time_totalReturns the total time length in seconds of a physical or logical seekable bitstream.
    ov_raw_tellReturns the byte location of the next sample to be read, giving the approximate location in the stream that the decoding engine has reached.
    ov_pcm_tellReturns the sample location of the next sample to be read, giving the approximate location in the stream that the decoding engine has reached.
    ov_time_tellReturns the time location of the next sample to be read, giving the approximate location in the stream that the decoding engine has reached.
    ov_infoReturns the vorbis_info struct for a specific bitstream section.
    ov_commentReturns attached comments for the current bitstream.
    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/index.html b/Engine/lib/libvorbis/doc/vorbisfile/index.html deleted file mode 100644 index b5bde1571..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/index.html +++ /dev/null @@ -1,49 +0,0 @@ - - - -Vorbisfile - Documentation - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Vorbisfile Documentation

    - -

    - -The Vorbisfile library provides a convenient high-level API for -decoding and basic manipulation of all Vorbis I audio streams. -Libvorbisfile is implemented as a layer on top of Xiph.Org's reference -libogg and libvorbis libraries.

    - -Vorbisfile can be used along with any ANSI compliant stdio implementation -for file/stream access, or use custom stream i/o routines provided by -the embedded environment. Both uses are described in detail in this -documentation. - -

    -API overview
    -API reference
    -Code Examples
    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/initialization.html b/Engine/lib/libvorbis/doc/vorbisfile/initialization.html deleted file mode 100644 index 346ee72f5..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/initialization.html +++ /dev/null @@ -1,118 +0,0 @@ - - - -Vorbisfile - Setup/Teardown - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Setup/Teardown

    In order to decode audio using -libvorbisfile, a bitstream containing Vorbis audio must be properly -initialized before decoding and cleared when decoding is finished. -The simplest possible case is to use ov_fopen() to open the file for access, check -it for Vorbis content, and prepare it for playback. A successful return code from ov_fopen() indicates the file is ready for use. -Once the file is no longer needed, ov_clear() is used to close the file and -deallocate decoding resources.

    - -On systems other than Windows[a], an -application may also open a file itself using fopen(), then pass the -FILE * to libvorbisfile using ov_open(). Do not call -fclose() on a file handle successfully submitted to ov_open(); libvorbisfile does this in the ov_clear() call.

    - -An application that requires more setup flexibility may open a data -stream using ov_open_callbacks() -to change default libvorbis behavior or specify non-stdio data access -mechanisms.

    - -

    -All libvorbisfile initialization and deallocation routines are declared in "vorbis/vorbisfile.h". -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    functionpurpose
    ov_fopenOpens a file and initializes the Ogg Vorbis bitstream with default values. This must be called before other functions in the library may be - used.
    ov_openInitializes the Ogg Vorbis bitstream with default values from a passed in file handle. This must be called before other functions in the library may be - used. Do not use this call under Windows [a]; Use ov_fopen() or ov_open_callbacks() instead.
    ov_open_callbacksInitializes the Ogg Vorbis bitstream from a file handle and custom file/bitstream manipulation routines. Used instead of ov_open() or ov_fopen() when altering or replacing libvorbis's default stdio I/O behavior, or when a bitstream must be initialized from a FILE * under Windows.
    ov_testPartially opens a file just far enough to determine if the file -is an Ogg Vorbis file or not. A successful return indicates that the -file appears to be an Ogg Vorbis file, but the OggVorbis_File struct is not yet fully -initialized for actual decoding. After a successful return, the file -may be closed using ov_clear() or fully -opened for decoding using ov_test_open().

    This call is intended to -be used as a less expensive file open test than a full ov_open().

    -Note that libvorbisfile owns the passed in file resource is it returns success; do not fclose() files owned by libvorbisfile.

    ov_test_callbacksAs above but allowing application-define I/O callbacks.

    -Note that libvorbisfile owns the passed in file resource is it returns success; do not fclose() files owned by libvorbisfile.

    ov_test_open -Finish opening a file after a successful call to ov_test() or ov_test_callbacks().
    ov_clear Closes the - bitstream and cleans up loose ends. Must be called when - finished with the bitstream. After return, the OggVorbis_File struct is - invalid and may not be used before being initialized again - before begin reinitialized. - -
    - -

    -


    - - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_bitrate.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_bitrate.html deleted file mode 100644 index ae1495b75..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_bitrate.html +++ /dev/null @@ -1,72 +0,0 @@ - - - -Vorbisfile - function - ov_bitrate - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_bitrate

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    This function returns the average bitrate for the specified logical bitstream. This may be different from the ov_info->nominal_bitrate value, as it is based on the actual average for this bitstream if the file is seekable. -

    Nonseekable files will return the nominal bitrate setting or the average of the upper and lower bounds, if any of these values are set. -

    - -

    - - - - -
    -
    
    -long ov_bitrate(OggVorbis_File *vf,int i);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    i
    -
    Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the bitrate for the entire bitstream, this parameter should be set to -1.
    -
    - - -

    Return Values

    -
    -
  • OV_EINVAL indicates that an invalid argument value was submitted or that the stream represented by vf is not open.
  • -
  • OV_FALSE means the call returned a 'false' status, which in this case most likely indicates that the file is nonseekable and the upper, lower, and nominal bitrates were unset. -
  • n indicates the bitrate for the given logical bitstream or the entire - physical bitstream. If the file is open for random (seekable) access, it will - find the *actual* average bitrate. If the file is streaming (nonseekable), it - returns the nominal bitrate (if set) or else the average of the - upper/lower bounds (if set).
  • -
    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_bitrate_instant.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_bitrate_instant.html deleted file mode 100644 index 2edfd044d..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_bitrate_instant.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -Vorbisfile - function - ov_bitrate - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_bitrate_instant

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Used to find the most recent bitrate played back within the file. Will return 0 if the bitrate has not changed or it is the beginning of the file. - -

    - - - - -
    -
    
    -long ov_bitrate_instant(OggVorbis_File *vf);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions. -
    - - -

    Return Values

    -
    -
  • 0 indicates the beginning of the file or unchanged bitrate info.
  • -
  • n indicates the actual bitrate since the last call.
  • -
  • OV_FALSE indicates that playback is not in progress, and thus there is no instantaneous bitrate information to report.
  • -
  • OV_EINVAL indicates that the stream represented by vf is not open.
  • -
    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_callbacks.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_callbacks.html deleted file mode 100644 index b9e580287..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_callbacks.html +++ /dev/null @@ -1,117 +0,0 @@ - - - -Vorbisfile - datatype - ov_callbacks - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_callbacks

    - -

    declared in "vorbis/codec.h"

    - -

    -The ov_callbacks structure contains file manipulation function prototypes necessary for opening, closing, seeking, and location. - -

    -The ov_callbacks structure does not need to be user-defined if you are -working with stdio-based file manipulation; the ov_fopen() and ov_open() calls internally provide default callbacks for -stdio. ov_callbacks are defined and passed to ov_open_callbacks() when -implementing non-stdio based stream manipulation (such as playback -from a memory buffer) or when ov_open()-style initialization from a FILE * is required under Windows [a]. -

    - - - - - -
    -
    typedef struct {
    -  size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
    -  int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
    -  int    (*close_func) (void *datasource);
    -  long   (*tell_func)  (void *datasource);
    -} ov_callbacks;
    -
    - -

    Relevant Struct Members

    -
    -
    read_func
    -
    Pointer to custom data reading function.
    -
    seek_func
    -
    Pointer to custom data seeking function. If the data source is not seekable (or the application wants the data source to be treated as unseekable at all times), the provided seek callback should always return -1 (failure) or the seek_func and tell_func fields should be set to NULL.
    -
    close_func
    -
    Pointer to custom data source closure function. Set to NULL if libvorbisfile should not attempt to automatically close the file/data handle.
    -
    tell_func
    -
    Pointer to custom data location function. If the data source is not seekable (or the application wants the data source to be treated as unseekable at all times), the provided tell callback should always return -1 (failure) or the seek_func and tell_func fields should be set to NULL.
    -
    - -

    - -

    Predefined callbacks

    -The header vorbis/vorbisfile.h provides several predefined static ov_callbacks structures that may be passed to ov_open_callbacks(): -
    -
    OV_CALLBACKS_DEFAULT
    - -These callbacks provide the same behavior as used internally by ov_fopen() and ov_open(). - -
    OV_CALLBACKS_NOCLOSE
    - -The same as OV_CALLBACKS_DEFAULT, but with the -close_func field set to NULL. The most typical use would be -to use ov_open_callbacks() to -provide the same behavior as ov_open(), but -not close the file/data handle in ov_clear(). - -
    OV_CALLBACKS_STREAMONLY
    - -A set of callbacks that set seek_func and tell_func -to NULL, thus forcing strict streaming-only behavior regardless of -whether or not the input is actually seekable. - -
    OV_CALLBACKS_STREAMONLY_NOCLOSE
    - -The same as OV_CALLBACKS_STREAMONLY, but with -close_func also set to null, preventing libvorbisfile from -attempting to close the file/data handle in ov_clear(). - -
    -

    - -

    Examples and usage

    - -See the callbacks and non-stdio I/O document for more -detailed information on required behavior of the various callback -functions.

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_clear.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_clear.html deleted file mode 100644 index 0c011bfed..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_clear.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -Vorbisfile - function - ov_clear - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_clear

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    After a bitstream has been opened using ov_fopen()/ov_open()/ov_open_callbacks() and decoding is complete, the application must call ov_clear() to clear -the decoder's buffers. ov_clear() will also close the file unless it was opened using ov_open_callbacks() with the close_func callback set to NULL.

    - -ov_clear() must also be called after a successful call to ov_test() or ov_test_callbacks().

    - -

    - - - - -
    -
    
    -int ov_clear(OggVorbis_File *vf);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions. After ov_clear has been called, the contents of this structure are deallocated, and it can no longer be used without being reinitialized by a call to ov_fopen(), ov_open() or ov_open_callbacks().
    -
    - - -

    Return Values

    -
    -
  • 0 for success
  • -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_comment.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_comment.html deleted file mode 100644 index 02795b75b..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_comment.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -Vorbisfile - function - ov_bitrate - - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_comment

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Returns a pointer to the vorbis_comment struct for the specified bitstream. For nonseekable streams, returns the struct for the current bitstream. -

    - -

    - - - - -
    -
    
    -vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    i
    -
    Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the vorbis_comment struct for the current bitstream, this parameter should be set to -1.
    -
    - - -

    Return Values

    -
    -
  • Returns the vorbis_comment struct for the specified bitstream.
  • -
  • NULL if the specified bitstream does not exist or the file has been initialized improperly.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_crosslap.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_crosslap.html deleted file mode 100644 index 6b563f622..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_crosslap.html +++ /dev/null @@ -1,100 +0,0 @@ - - - -Vorbisfile - function - ov_crosslap - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_crosslap()

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    ov_crosslap overlaps and blends the boundary at a transition -between two separate streams represented by separate OggVorbis_File structures. For lapping -transitions due to seeking within a single stream represented by a -single OggVorbis_File structure, -consider using the lapping versions of the vorbisfile seeking functions instead. - -

    ov_crosslap is used between the last (usually ov_read) call on -the old stream and the first ov_read from the new stream. Any -desired positioning of the new stream must occur before the call to -ov_crosslap() as a seek dumps all prior lapping information from a -stream's decode state. Crosslapping does not introduce or remove any -extraneous samples; positioning works exactly as if ov_crosslap was not -called. - -

    ov_crosslap will lap between streams of differing numbers of -channels. Any extra channels from the old stream are ignored; playback -of these channels simply ends. Extra channels in the new stream are -lapped from silence. ov_crosslap will also lap between streams links -of differing sample rates. In this case, the sample rates are ignored -(no implicit resampling is done to match playback). It is up to the -application developer to decide if this behavior makes any sense in a -given context; in practical use, these default behaviors perform -sensibly. - -

    - - - - -
    -
    
    -long ov_crosslap(OggVorbis_File *old, OggVorbis_File *new);
    -
    -
    -
    - -

    Parameters

    -
    -
    old
    -
    A pointer to the OggVorbis_File structure representing the origin stream from which to transition playback.
    - -
    new
    -
    A pointer to the OggVorbis_File structure representing the stream with which playback continues.
    -
    - - -

    Return Values

    -
    -
    -
    OV_EINVAL
    -
    crosslap called with an OggVorbis_File structure that isn't open.
    -
    OV_EFAULT
    -
    internal error; implies a library bug or external heap corruption.
    -
    OV_EREAD
    -
    A read from media returned an error.
    -
    OV_EOF
    -
    indicates stream vf2 is at end of file, or that vf1 is at end of file immediately after a seek (making crosslap impossible as there's no preceding decode state to crosslap).
    -
    0
    -
    success.
    -
    -
    - - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_fopen.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_fopen.html deleted file mode 100644 index 75927149e..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_fopen.html +++ /dev/null @@ -1,124 +0,0 @@ - - - -Vorbisfile - function - ov_fopen - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_fopen

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    This is the simplest function used to open and initialize an OggVorbis_File -structure. It sets up all the related decoding structure. -

    The first argument is a file path suitable -for passing to fopen(). vf should be a pointer to an empty -OggVorbis_File structure -- this is used for ALL the externally visible -libvorbisfile functions. Once this has been called, the same OggVorbis_File struct should be passed -to all the libvorbisfile functions. -

    The vf structure initialized using ov_fopen() must -eventually be cleaned using ov_clear(). - -

    -It is often useful to call ov_fopen() simply to determine -whether a given file is a Vorbis bitstream. If the ov_fopen() -call fails, then the file is either inaccessable (errno is set) or not -recognizable as Vorbis (errno unchanged). If the call succeeds but -the initialized vf structure will not be used, the -application is responsible for calling ov_clear() to clear the decoder's buffers and -close the file.

    - -

    - - - - -
    -
    
    -int ov_fopen(const char *path,OggVorbis_File *vf);
    -
    -
    - -

    Parameters

    -
    -
    path
    -
    Null terminated string containing a file path suitable for passing to fopen(). -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions. Once this has been called, the same OggVorbis_File -struct should be passed to all the libvorbisfile functions.
    -
    - - -

    Return Values

    -
    -
  • 0 indicates success
  • - -
  • less than zero for failure:
  • -
      -
    • OV_EREAD - A read from media returned an error.
    • -
    • OV_ENOTVORBIS - Bitstream does not contain any Vorbis data.
    • -
    • OV_EVERSION - Vorbis version mismatch.
    • -
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    -
    -

    - -

    Notes

    -
    - -
    [a] Threaded decode

    -

    If your decoder is threaded, it is recommended that you NOT call -ov_open_callbacks() -in the main control thread--instead, call ov_open_callbacks() in your decode/playback -thread. This is important because ov_open_callbacks() may be a fairly time-consuming -call, given that the full structure of the file is determined at this point, -which may require reading large parts of the file under certain circumstances -(determining all the logical bitstreams in one physical bitstream, for -example). See Thread Safety for other information on using libvorbisfile with threads. -

    - -

    [b] Mixed media streams

    -

    -As of Vorbisfile release 1.2.0, Vorbisfile is able to access the -Vorbis content in mixed-media Ogg streams, not just Vorbis-only -streams. For example, Vorbisfile may be used to open and access the -audio from an Ogg stream consisting of Theora video and Vorbis audio. -Vorbisfile 1.2.0 decodes the first logical audio stream of each -physical stream section.

    - -

    [c] Faster testing for Vorbis files

    -

    ov_test() and ov_test_callbacks() provide less -computationally expensive ways to test a file for Vorbisness, but -require more setup code.

    - -

    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_info.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_info.html deleted file mode 100644 index e29c516d8..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_info.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -Vorbisfile - function - ov_info - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_info

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Returns the vorbis_info struct for the specified bitstream. For nonseekable files, always returns the current vorbis_info struct. - -

    - - - - -
    -
    
    -vorbis_info *ov_info(OggVorbis_File *vf,int link);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    i
    -
    Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the vorbis_info struct for the current bitstream, this parameter should be set to -1.
    -
    - - -

    Return Values

    -
    -
  • Returns the vorbis_info struct for the specified bitstream. Returns vorbis_info for current bitstream if the file is nonseekable or i=-1.
  • -
  • NULL if the specified bitstream does not exist or the file has been initialized improperly.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_open.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_open.html deleted file mode 100644 index bf214aaf3..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_open.html +++ /dev/null @@ -1,183 +0,0 @@ - - - -Vorbisfile - function - ov_open - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_open

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    ov_open is one of three initialization functions used to initialize -an OggVorbis_File structure and prepare a bitstream for playback. - -

    WARNING for Windows developers: Do not use ov_open() in -Windows applications; Windows linking places restrictions on -passing FILE * handles successfully, and ov_open() runs -afoul of these restrictions [a]. See the ov_open_callbacks() page for -details on using ov_open_callbacks() instead. - -

    The first argument must be a file pointer to an already opened file -or pipe (it need not be seekable--though this obviously restricts what -can be done with the bitstream). vf should be a pointer to the -OggVorbis_File structure -- this is used for ALL the externally visible libvorbisfile -functions. Once this has been called, the same OggVorbis_File -struct should be passed to all the libvorbisfile functions.

    - -The vf structure initialized using ov_fopen() must eventually -be cleaned using ov_clear(). Once a -FILE * handle is passed to ov_open() successfully, the -application MUST NOT fclose() or in any other way manipulate -that file handle. Vorbisfile will close the file in ov_clear(). If the application must be able -to close the FILE * handle itself, see ov_open_callbacks() with the use of -OV_CALLBACKS_NOCLOSE. - -

    It is often useful to call ov_open() simply to determine -whether a given file is a Vorbis bitstream. If the ov_open() -call fails, then the file is not recognizable as Vorbis. If the call -succeeds but the initialized vf structure will not be used, -the application is responsible for calling ov_clear() to clear the decoder's buffers and -close the file.

    - -If [and only if] an ov_open() call fails, the application -must explicitly fclose() the FILE * pointer itself. - - -

    - - - - -
    -
    
    -int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
    -
    -
    - -

    Parameters

    -
    -
    f
    -
    File pointer to an already opened file -or pipe (it need not be seekable--though this obviously restricts what -can be done with the bitstream).
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions. Once this has been called, the same OggVorbis_File -struct should be passed to all the libvorbisfile functions.
    -
    initial
    -
    Typically set to NULL. This parameter is useful if some data has already been -read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial -should be a pointer to a buffer containing the data read.
    -
    ibytes
    -
    Typically set to 0. This parameter is useful if some data has already been -read from the file and the stream is not seekable. In this case, ibytes -should contain the length (in bytes) of the buffer. Used together with initial
    -
    - - -

    Return Values

    -
    -
  • 0 indicates success
  • - -
  • less than zero for failure:
  • -
      -
    • OV_EREAD - A read from media returned an error.
    • -
    • OV_ENOTVORBIS - Bitstream is not Vorbis data.
    • -
    • OV_EVERSION - Vorbis version mismatch.
    • -
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    -
    -

    - - -

    Notes

    -
    - - -
    [a] Windows and ov_open()

    - -

    Under Windows, stdio file access is implemented in each of many -variants of crt.o, several of which are typically installed on any one -Windows machine. If libvorbisfile and the application using -libvorbisfile are not linked against the exact same -version/variant/build of crt.o (and they usually won't be, especially -using a prebuilt libvorbis DLL), FILE * handles cannot be -opened in the application and then passed to vorbisfile to be used -by stdio calls from vorbisfile's different version of CRT. For this -reason, using ov_open() under Windows -without careful, expert linking will typically cause a protection -fault. Windows programmers should use ov_fopen() (which will only use libvorbis's -crt.o) or ov_open_callbacks() -(which will only use the application's crt.o) instead.

    - -This warning only applies to Windows and only applies to ov_open(). It is perfectly safe to use ov_open() on all other platforms.

    - -For more information, see the following microsoft pages on C -runtime library linking and a specific description of restrictions -on passing CRT objects across DLL boundaries. - -

    - -

    [b] Threaded decode

    -

    If your decoder is threaded, it is recommended that you NOT call -ov_open() -in the main control thread--instead, call ov_open() in your decode/playback -thread. This is important because ov_open() may be a fairly time-consuming -call, given that the full structure of the file is determined at this point, -which may require reading large parts of the file under certain circumstances -(determining all the logical bitstreams in one physical bitstream, for -example). See Thread Safety for other information on using libvorbisfile with threads. -

    - -

    [c] Mixed media streams

    -

    -As of Vorbisfile release 1.2.0, Vorbisfile is able to access the -Vorbis content in mixed-media Ogg streams, not just Vorbis-only -streams. For example, Vorbisfile may be used to open and access the -audio from an Ogg stream consisting of Theora video and Vorbis audio. -Vorbisfile 1.2.0 decodes the first logical audio stream of each -physical stream section.

    - -

    [d] Faster testing for Vorbis files

    -

    ov_test() and ov_test_callbacks() provide less -computationally expensive ways to test a file for Vorbisness, but -require more setup code.

    - -

    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_open_callbacks.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_open_callbacks.html deleted file mode 100644 index 60816803b..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_open_callbacks.html +++ /dev/null @@ -1,147 +0,0 @@ - - - -Vorbisfile - function - ov_open_callbacks - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_open_callbacks

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    This is an alternative function used to open and initialize an -OggVorbis_File structure when using a data source other than a file, -when its necessary to modify default file access behavior, or to -initialize a Vorbis decode from a FILE * pointer under -Windows where ov_open() cannot be used. It -allows the application to specify custom file manipulation routines -and sets up all the related decoding structures. - -

    Once ov_open_callbacks() has been called, the same -OggVorbis_File struct should be passed to all the -libvorbisfile functions. Unlike ov_fopen() and ov_open(), ov_open_callbacks() may be used to -instruct vorbisfile to either automatically close or not to close the -file/data access handle in ov_clear(). -Automatic closure is disabled by passing NULL as the close callback, -or using one of the predefined callback sets that specify a NULL close -callback. The application is responsible for closing a file when a -call to ov_open_callbacks() is unsuccessful.

    - -See also Callbacks and Non-stdio I/O for -information on designing and specifying custom callback functions.

    - -

    - - - - -
    -
    
    -int ov_open_callbacks(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
    -
    -
    - -

    Parameters

    -
    -
    datasource
    -
    Pointer to a data structure allocated by the calling application, containing any state needed by the callbacks provided.
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions. Once this has been called, the same OggVorbis_File -struct should be passed to all the libvorbisfile functions.
    -
    initial
    -
    Typically set to NULL. This parameter is useful if some data has already been -read from the stream and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial -should be a pointer to a buffer containing the data read.
    -
    ibytes
    -
    Typically set to 0. This parameter is useful if some data has already been -read from the stream and the stream is not seekable. In this case, ibytes -should contain the length (in bytes) of the buffer. Used together with initial.
    -
    callbacks
    -
    A completed ov_callbacks struct which indicates desired custom file manipulation routines. vorbisfile.h defines several preprovided callback sets; see ov_callbacks for details.
    -
    - - -

    Return Values

    -
    -
  • 0 for success
  • -
  • less than zero for failure:
  • -
      -
    • OV_EREAD - A read from media returned an error.
    • -
    • OV_ENOTVORBIS - Bitstream does not contain any Vorbis data.
    • -
    • OV_EVERSION - Vorbis version mismatch.
    • -
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    -
    -

    - -

    Notes

    -
    - -
    [a] Windows and use as an ov_open() substitute

    Windows -applications should not use ov_open() due -to the likelihood of CRT linking -mismatches and runtime protection faults -[ov_open:a]. ov_open_callbacks() is a safe substitute; specifically: - -

    ov_open_callbacks(f, vf, initial, ibytes, OV_CALLBACKS_DEFAULT);
    -
    - -... provides exactly the same functionality as ov_open() but will always work correctly under -Windows, regardless of linking setup details.

    - -

    [b] Threaded decode

    -

    If your decoder is threaded, it is recommended that you NOT call -ov_open_callbacks() -in the main control thread--instead, call ov_open_callbacks() in your decode/playback -thread. This is important because ov_open_callbacks() may be a fairly time-consuming -call, given that the full structure of the file is determined at this point, -which may require reading large parts of the file under certain circumstances -(determining all the logical bitstreams in one physical bitstream, for -example). See Thread Safety for other information on using libvorbisfile with threads. -

    - -

    [c] Mixed media streams

    -

    -As of Vorbisfile release 1.2.0, Vorbisfile is able to access the -Vorbis content in mixed-media Ogg streams, not just Vorbis-only -streams. For example, Vorbisfile may be used to open and access the -audio from an Ogg stream consisting of Theora video and Vorbis audio. -Vorbisfile 1.2.0 decodes the first logical audio stream of each -physical stream section.

    - -

    [d] Faster testing for Vorbis files

    -

    ov_test() and ov_test_callbacks() provide less -computationally expensive ways to test a file for Vorbisness, but -require more setup code.

    - -

    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek.html deleted file mode 100644 index 3709467a1..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek.html +++ /dev/null @@ -1,83 +0,0 @@ - - - -Vorbisfile - function - ov_pcm_seek - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_pcm_seek

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Seeks to the offset specified (in pcm samples) within the physical bitstream. This function only works for seekable streams. -

    This also updates everything needed within the -decoder, so you can immediately call ov_read() and get data from -the newly seeked to position. -

    - -

    - - - - -
    -
    
    -int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    pos
    -
    Position in pcm samples to seek to in the bitstream.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek_lap.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek_lap.html deleted file mode 100644 index 71c490aa8..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek_lap.html +++ /dev/null @@ -1,103 +0,0 @@ - - - -Vorbisfile - function - ov_pcm_seek_lap - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_pcm_seek_lap

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Seeks to the offset specified (in pcm samples) within the physical bitstream. This variant of ov_pcm_seek also automatically -crosslaps the transition from the previous playback position into the -new playback position in order to eliminate clicking and boundary -discontinuities. Otherwise, usage and behavior is identical to ov_pcm_seek. - -

    ov_pcm_seek_lap also updates everything needed within the decoder, -so you can immediately call ov_read() and -get data from the newly seeked to position. - -

    ov_pcm_seek_lap will lap between logical stream links of differing -numbers of channels. Any extra channels from the origin of the seek -are ignored; playback of these channels simply ends. Extra channels at -the destination are lapped from silence. ov_pcm_seek_lap will also -lap between logical stream links of differing sample rates. In this -case, the sample rates are ignored (no implicit resampling is done to -match playback). It is up to the application developer to decide if -this behavior makes any sense in a given context; in practical use, -these default behaviors perform sensibly. - -

    This function only works for seekable streams. - -

    - - - - -
    -
    
    -int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    pos
    -
    Position in pcm samples to seek to in the bitstream.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EOF - Indicates stream is at end of file immediately after a seek - (making crosslap impossible as there's no preceeding decode state to crosslap). -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek_page.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek_page.html deleted file mode 100644 index 6f33505e1..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek_page.html +++ /dev/null @@ -1,84 +0,0 @@ - - - -Vorbisfile - function - ov_pcm_seek_page - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_pcm_seek_page

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Seeks to the closest page preceding the specified location (in pcm samples) within the physical bitstream. This function only works for seekable streams. -

    This function is faster than ov_pcm_seek because the function can begin decoding at a page boundary rather than seeking through any remaining samples before the specified location. However, it is less accurate. -

    This also updates everything needed within the -decoder, so you can immediately call ov_read() and get data from -the newly seeked to position. -

    - -

    - - - - -
    -
    
    -int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    pos
    -
    Position in pcm samples to seek to in the bitstream.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek_page_lap.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek_page_lap.html deleted file mode 100644 index d4736eb40..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_seek_page_lap.html +++ /dev/null @@ -1,112 +0,0 @@ - - - -Vorbisfile - function - ov_pcm_seek_page_lap - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_pcm_seek_page_lap

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Seeks to the closest page preceding the specified location (in pcm -samples) within the physical bitstream. This variant of ov_pcm_seek_page also automatically -crosslaps the transition from the previous playback position into the -new playback position in order to eliminate clicking and boundary -discontinuities. Otherwise, usage and behavior is identical to ov_pcm_seek_page. - -

    This function is faster than ov_pcm_seek_lap because the function -can begin decoding at a page boundary rather than seeking through any -remaining samples before the specified location. However, it is less -accurate. - -

    ov_pcm_seek_page_lap also updates everything needed within the -decoder, so you can immediately call ov_read() and get data from the newly seeked -to position. - -

    ov_pcm_seek_page_lap will lap between logical stream links of -differing numbers of channels. Any extra channels from the origin of -the seek are ignored; playback of these channels simply ends. Extra -channels at the destination are lapped from silence. -ov_pcm_seek_page_lap will also lap between logical stream links of -differing sample rates. In this case, the sample rates are ignored -(no implicit resampling is done to match playback). It is up to the -application developer to decide if this behavior makes any sense in a -given context; in practical use, these default behaviors perform -sensibly. - -

    This function only works for seekable streams. - -

    - - - - -
    -
    
    -int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    pos
    -
    Position in pcm samples to seek to in the bitstream.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EOF - Indicates stream is at end of file immediately after a seek - (making crosslap impossible as there's no preceeding decode state to crosslap). -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_tell.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_tell.html deleted file mode 100644 index 114bec54f..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_tell.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -Vorbisfile - function - ov_pcm_tell - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_pcm_tell

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Returns the current offset in samples. - -

    - - - - -
    -
    
    -ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    - - -

    Return Values

    -
    -
  • n indicates the current offset in samples.
  • -
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist.
  • -
    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_total.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_total.html deleted file mode 100644 index cad8c318b..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_pcm_total.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -Vorbisfile - function - ov_pcm_total - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_pcm_total

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Returns the total pcm samples of the physical bitstream or a specified logical bitstream. - -

    - - - - -
    -
    
    -ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    i
    -
    Link to the desired logical bitstream. To retrieve the total pcm samples for the entire physical bitstream, this parameter should be set to -1.
    -
    - - -

    Return Values

    -
    -
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist or the bitstream is unseekable.
  • -
  • -total length in pcm samples of content if i=-1.
  • -
  • length in pcm samples of logical bitstream if i=0 to n.
  • -
    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_seek.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_seek.html deleted file mode 100644 index 9074b3540..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_seek.html +++ /dev/null @@ -1,83 +0,0 @@ - - - -Vorbisfile - function - ov_raw_seek - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_raw_seek

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Seeks to the offset specified (in compressed raw bytes) within the physical bitstream. This function only works for seekable streams. -

    This also updates everything needed within the -decoder, so you can immediately call ov_read() and get data from -the newly seeked to position. -

    When seek speed is a priority, this is the best seek funtion to use. -

    - - - - -
    -
    
    -int ov_raw_seek(OggVorbis_File *vf,long pos);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    pos
    -
    Position in compressed bytes to seek to in the bitstream.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_seek_lap.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_seek_lap.html deleted file mode 100644 index 87d0e7ebd..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_seek_lap.html +++ /dev/null @@ -1,110 +0,0 @@ - - - -Vorbisfile - function - ov_raw_seek_lap - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_raw_seek_lap

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Seeks to the offset specified (in compressed raw bytes) within the -physical bitstream. This variant of ov_raw_seek also automatically crosslaps -the transition from the previous playback position into the new -playback position in order to eliminate clicking and boundary -discontinuities. Otherwise, usage and behavior is identical to ov_raw_seek. - -

    When seek speed is a priority, but crosslapping is still desired, -this is the best seek funtion to use. - -

    ov_raw_seek_lap also updates everything needed within the decoder, -so you can immediately call ov_read() and -get data from the newly seeked to position. - -

    ov_raw_seek_lap will lap between logical stream links of differing -numbers of channels. Any extra channels from the origin of the seek -are ignored; playback of these channels simply ends. Extra channels at -the destination are lapped from silence. ov_raw_seek_lap will also -lap between logical stream links of differing sample rates. In this -case, the sample rates are ignored (no implicit resampling is done to -match playback). It is up to the application developer to decide if -this behavior makes any sense in a given context; in practical use, -these default behaviors perform sensibly. - -

    This function only works for seekable streams. - - -

    - - - - -
    -
    
    -int ov_raw_seek_lap(OggVorbis_File *vf,long pos);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    pos
    -
    Position in compressed bytes to seek to in the bitstream.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EOF - Indicates stream is at end of file immediately after a seek - (making crosslap impossible as there's no preceeding decode state to crosslap). -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    - -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_tell.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_tell.html deleted file mode 100644 index 419a5b32c..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_tell.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -Vorbisfile - function - ov_raw_tell - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_raw_tell

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Returns the current offset in raw compressed bytes.

    - -

    Note that if you later use ov_raw_seek() to return to this point, you won't generally get back to exactly the same place, due to internal buffering. Also note that a read operation may not cause a change to the current raw offset - only a read that requires reading more data from the underlying data source will do that.

    - -

    - - - - -
    -
    
    -ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    - - -

    Return Values

    -
    -
  • n indicates the current offset in bytes.
  • -
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist.
  • -
    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_total.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_total.html deleted file mode 100644 index 54c93c196..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_raw_total.html +++ /dev/null @@ -1,68 +0,0 @@ - - - -Vorbisfile - function - ov_raw_total - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_raw_total

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Returns the total (compressed) bytes of the physical bitstream or a specified logical bitstream. - -

    - - - - -
    -
    
    -ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    i
    -
    Link to the desired logical bitstream. To retrieve the total bytes for the entire physical bitstream, this parameter should be set to -1.
    -
    - - -

    Return Values

    -
    -
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist or the bitstream is nonseekable
  • -
  • n -total length in compressed bytes of content if i=-1.
  • -
  • n length in compressed bytes of logical bitstream if i=0 to n.
  • -
    -

    - - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_read.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_read.html deleted file mode 100644 index e696086e8..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_read.html +++ /dev/null @@ -1,148 +0,0 @@ - - - -Vorbisfile - function - ov_read - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_read()

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    - This is the main function used to decode a Vorbis file within a - loop. It returns up to the specified number of bytes of decoded PCM audio - in the requested endianness, signedness, and word size. If the audio is - multichannel, the channels are interleaved in the output buffer. - If the passed in buffer is large, ov_read() will not fill - it; the passed in buffer size is treated as a limit and - not a request. - -

    The output channels are in stream order and not remapped. Vorbis I -defines channel order as follows: - -

      -
    • one channel - the stream is monophonic -
    • two channels - the stream is stereo. channel order: left, right -
    • three channels - the stream is a 1d-surround encoding. channel order: left, -center, right -
    • four channels - the stream is quadraphonic surround. channel order: front left, -front right, rear left, rear right -
    • five channels - the stream is five-channel surround. channel order: front left, -center, front right, rear left, rear right -
    • six channels - the stream is 5.1 surround. channel order: front left, center, -front right, rear left, rear right, LFE -
    • seven channels - the stream is 6.1 surround. channel order: front left, center, -front right, side left, side right, rear center, LFE -
    • eight channels - the stream is 7.1 surround. channel order: front left, center, -front right, side left, side right, rear left, rear right, -LFE -
    • greater than eight channels - channel use and order is undefined -
    - -

    Note that up to this point, the Vorbisfile API could more or less hide the - multiple logical bitstream nature of chaining from the toplevel - application if the toplevel application didn't particularly care. - However, when reading audio back, the application must be aware - that multiple bitstream sections do not necessarily use the same - number of channels or sampling rate.

    ov_read() passes - back the index of the sequential logical bitstream currently being - decoded (in *bitstream) along with the PCM data in order - that the toplevel application can handle channel and/or sample - rate changes. This number will be incremented at chaining - boundaries even for non-seekable streams. For seekable streams, it - represents the actual chaining index within the physical bitstream. -

    - -

    - - - - -
    -
    
    -long ov_read(OggVorbis_File *vf, char *buffer, int length, int bigendianp, int word, int sgned, int *bitstream);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    buffer
    -
    A pointer to an output buffer. The decoded output is inserted into this buffer.
    -
    length
    -
    Number of bytes to be read into the buffer. Should be the same size as the buffer. A typical value is 4096.
    -
    bigendianp
    -
    Specifies big or little endian byte packing. 0 for little endian, 1 for b -ig endian. Typical value is 0.
    -
    word
    -
    Specifies word size. Possible arguments are 1 for 8-bit samples, or 2 or -16-bit samples. Typical value is 2.
    -
    sgned
    -
    Signed or unsigned data. 0 for unsigned, 1 for signed. Typically 1.
    -
    bitstream
    -
    A pointer to the number of the current logical bitstream.
    -
    - - -

    Return Values

    -
    -
    -
    OV_HOLE
    -
    indicates there was an interruption in the data. -
    (one of: garbage between pages, loss of sync followed by - recapture, or a corrupt page)
    -
    OV_EBADLINK
    -
    indicates that an invalid stream section was supplied to - libvorbisfile, or the requested link is corrupt.
    -
    OV_EINVAL
    -
    indicates the initial file headers couldn't be read or - are corrupt, or that the initial open call for vf - failed.
    -
    0
    -
    indicates EOF
    -
    n
    -
    indicates actual number of bytes read. ov_read() will - decode at most one vorbis packet per invocation, so the value - returned will generally be less than length. -
    -
    - -

    Notes

    -

    Typical usage: -

    -bytes_read = ov_read(&vf, -buffer, 4096,0,2,1,&current_section) -
    - -This reads up to 4096 bytes into a buffer, with signed 16-bit -little-endian samples. -

    - - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_read_filter.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_read_filter.html deleted file mode 100644 index 932b7a92f..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_read_filter.html +++ /dev/null @@ -1,114 +0,0 @@ - - - -Vorbisfile - function - ov_read_filter - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_read_filter()

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    - ov_read_filter() is a variant of ov_read(), the main function used to decode - a Vorbis file within a loop. It passes the decoded floating point - PCM data to the filter specified in the function arguments before - converting the data to integer output samples. All other aspects of - its behavior are as with ov_read(). -

    - -

    - - - - -
    -
    
    -long ov_read_filter(OggVorbis_File *vf, char *buffer, int length, int bigendianp, int word, int sgned, int *bitstream, 
    -                    void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    buffer
    -
    A pointer to an output buffer. The decoded output is inserted into this buffer.
    -
    length
    -
    Number of bytes to be read into the buffer. Should be the same size as the buffer. A typical value is 4096.
    -
    bigendianp
    -
    Specifies big or little endian byte packing. 0 for little endian, 1 for b -ig endian. Typical value is 0.
    -
    word
    -
    Specifies word size. Possible arguments are 1 for 8-bit samples, or 2 or -16-bit samples. Typical value is 2.
    -
    sgned
    -
    Signed or unsigned data. 0 for unsigned, 1 for signed. Typically 1.
    -
    bitstream
    -
    A pointer to the number of the current logical bitstream.
    -
    filter
    -
    Filter function to process float PCM data prior to conversion to interleaved integer output.
    -
    filter_param
    -
    Data to pass through to the filter function.
    - -
    - - -

    Return Values

    -
    -
    -
    OV_HOLE
    -
    indicates there was an interruption in the data. -
    (one of: garbage between pages, loss of sync followed by - recapture, or a corrupt page)
    -
    OV_EBADLINK
    -
    indicates that an invalid stream section was supplied to - libvorbisfile, or the requested link is corrupt.
    -
    0
    -
    indicates EOF
    -
    n
    -
    indicates actual number of bytes read. ov_read() will - decode at most one vorbis packet per invocation, so the value - returned will generally be less than length. -
    -
    - -

    Notes

    -

    Typical usage: -

    -bytes_read = ov_read_filter(&vf, -buffer, 4096,0,2,1,&current_section, filter, (void *)filter_data_ptr) -
    - -This reads up to 4096 bytes into a buffer, with signed 16-bit -little-endian samples. The decoded data is passed to the function filter before integer conversiona nd interleave. -

    - - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_read_float.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_read_float.html deleted file mode 100644 index 00c2f37b5..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_read_float.html +++ /dev/null @@ -1,105 +0,0 @@ - - - -Vorbisfile - function - ov_read_float - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_read_float()

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    - This is the function used to decode a Vorbis file within a loop, but - returns samples in native float format instead of in integer formats. -

    - For information on channel ordering and how ov_read_float() deals with the complex issues - of chaining, etc, refer to the documentation for ov_read(). -

    - -

    - - - - -
    -
    
    -long ov_read_float(OggVorbis_File *vf, float ***pcm_channels, int samples, int *bitstream);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible vorbisfile -functions.
    -
    pcm_channels
    -
    A pointer to an output buffer. The pointer will be set to the decoded output buffer.
    -
    samples
    -
    Maximum number of decoded samples to produce.
    -
    bitstream
    -
    A pointer to the number of the current logical bitstream.
    -
    - - -

    Return Values

    -
    -
    -
    OV_HOLE
    -
    indicates there was an interruption in the data. -
    (one of: garbage between pages, loss of sync followed by - recapture, or a corrupt page)
    -
    OV_EBADLINK
    -
    indicates that an invalid stream section was supplied to - libvorbisfile, or the requested link is corrupt.
    -
    OV_EINVAL
    -
    indicates the initial file headers couldn't be read or - are corrupt, or that the initial open call for vf - failed.
    -
    0
    -
    indicates EOF
    -
    n
    -
    indicates actual number of samples read. ov_read_float() will - decode at most one vorbis packet per invocation, so the value - returned will generally be less than length. -
    -
    - -

    Notes

    -

    Typical usage: -

    -float **pcm; -samples_read = ov_read_float(&vf,pcm, 1024, &current_section) -
    - -This decodes up to 1024 float samples. -

    - -
    -

    -
    - - - - - - - - -

    copyright © 2002 vorbis team

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_seekable.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_seekable.html deleted file mode 100644 index c4448ba57..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_seekable.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -Vorbisfile - function - ov_seekable - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_seekable

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    This indicates whether or not the bitstream is seekable. - - -

    - - - - -
    -
    
    -long ov_seekable(OggVorbis_File *vf);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    - - -

    Return Values

    -
    -
  • 0 indicates that the file is not seekable.
  • -
  • nonzero indicates that the file is seekable.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_serialnumber.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_serialnumber.html deleted file mode 100644 index eaf24b0c0..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_serialnumber.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -Vorbisfile - function - ov_serialnumber - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_serialnumber

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Returns the serialnumber of the specified logical bitstream link number within the overall physical bitstream. - -

    - - - - -
    -
    
    -long ov_serialnumber(OggVorbis_File *vf,int i);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    i
    -
    Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the serial number of the current bitstream, this parameter should be set to -1.
    -
    - - -

    Return Values

    -
    -
  • --1 if the specified logical bitstream i does not exist.
  • - -
  • Returns the serial number of the logical bitstream i or the serial number of the current bitstream if the file is nonseekable.
  • -
    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_streams.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_streams.html deleted file mode 100644 index 233490464..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_streams.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -Vorbisfile - function - ov_streams - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_streams

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Returns the number of logical bitstreams within our physical bitstream. - -

    - - - - -
    -
    
    -long ov_streams(OggVorbis_File *vf);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    - - -

    Return Values

    -
    -
  • -1 indicates a single logical bitstream or an unseekable file.
  • -
  • n indicates the number of logical bitstreams.
  • -
    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_test.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_test.html deleted file mode 100644 index 663927f8b..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_test.html +++ /dev/null @@ -1,104 +0,0 @@ - - - -Vorbisfile - function - ov_test - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_test

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    -This partially opens a vorbis file to test for Vorbis-ness. It loads -the headers for the first chain and tests for seekability (but does -not seek). Use ov_test_open() to -finish opening the file or ov_clear to -close/free it. Note that vorbisfile does not take ownership of -the file if the call fails; the calling applicaiton is responsible for -closing the file if this call returns an error. -

    - -

    WARNING for Windows developers: Do not use ov_test() -in Windows applications; Windows linking places restrictions on -passing FILE * handles successfully, and ov_test() runs afoul -of these restrictions [a] in exactly the same -way as ov_open(). See the ov_test_callbacks() page for -details on using ov_test_callbacks() instead. -

    - - - - - -
    -
    
    -int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
    -
    -
    - -

    Parameters

    -
    -
    f
    -
    File pointer to an already opened file -or pipe (it need not be seekable--though this obviously restricts what -can be done with the bitstream).
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions. Once this has been called, the same OggVorbis_File -struct should be passed to all the libvorbisfile functions.
    -
    initial
    -
    Typically set to NULL. This parameter is useful if some data has already been -read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial -should be a pointer to a buffer containing the data read.
    -
    ibytes
    -
    Typically set to 0. This parameter is useful if some data has already been -read from the file and the stream is not seekable. In this case, ibytes -should contain the length (in bytes) of the buffer. Used together with initial
    -
    - - -

    Return Values

    -
    -
  • 0 for success
  • - -
  • less than zero for failure:
  • -
      -
    • OV_EREAD - A read from media returned an error.
    • -
    • OV_ENOTVORBIS - Bitstream contains no Vorbis data.
    • -
    • OV_EVERSION - Vorbis version mismatch.
    • -
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    -
    -

    - -

    Notes

    - -All the notes from ov_open() apply to ov_test(). - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_test_callbacks.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_test_callbacks.html deleted file mode 100644 index 77ee16d64..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_test_callbacks.html +++ /dev/null @@ -1,111 +0,0 @@ - - - -Vorbisfile - function - ov_test_callbacks - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_test_callbacks

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    This is an alternative function used to open and test an OggVorbis_File -structure when using a data source other than a file, -when its necessary to modify default file access behavior, or to -test for Vorbis content from a FILE * pointer under -Windows where ov_test() cannot be used. It -allows the application to specify custom file manipulation routines -and sets up all the related decoding structures. - -

    Once this has been called, the same OggVorbis_File -struct should be passed to all the libvorbisfile functions. -

    -

    - - - - -
    -
    
    -int ov_test_callbacks(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
    -
    -
    - -

    Parameters

    -
    -
    f
    -
    File pointer to an already opened file -or pipe (it need not be seekable--though this obviously restricts what -can be done with the bitstream).
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions. Once this has been called, the same OggVorbis_File -struct should be passed to all the libvorbisfile functions.
    -
    initial
    -
    Typically set to NULL. This parameter is useful if some data has already been -read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial -should be a pointer to a buffer containing the data read.
    -
    ibytes
    -
    Typically set to 0. This parameter is useful if some data has already been -read from the file and the stream is not seekable. In this case, ibytes -should contain the length (in bytes) of the buffer. Used together with initial.
    -
    callbacks
    -
    A completed ov_callbacks struct which indicates desired custom file manipulation routines. vorbisfile.h defines several preprovided callback sets; see ov_callbacks for details.
    -
    - - -

    Return Values

    -
    -
  • 0 for success
  • -
  • less than zero for failure:
  • -
      -
    • OV_EREAD - A read from media returned an error.
    • -
    • OV_ENOTVORBIS - Bitstream contains no Vorbis data.
    • -
    • OV_EVERSION - Vorbis version mismatch.
    • -
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    -
    -

    - -

    Notes

    -
    - -
    [a] Windows and use as an ov_test() substitute

    Windows -applications should not use ov_test() due -to the likelihood of CRT linking -mismatches and runtime protection faults -[ov_open:a]. ov_test_callbacks() is a safe substitute; specifically: - -

    ov_test_callbacks(f, vf, initial, ibytes, OV_CALLBACKS_DEFAULT);
    -
    - -... provides exactly the same functionality as ov_test() but will always work correctly under -Windows, regardless of linking setup details.

    - -

    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_test_open.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_test_open.html deleted file mode 100644 index f6ef0ed68..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_test_open.html +++ /dev/null @@ -1,82 +0,0 @@ - - - -Vorbisfile - function - ov_test_open - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_test_open

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    -Finish opening a file partially opened with ov_test() -or ov_test_callbacks(). -

    - - - - - -
    -
    
    -int ov_test_open(OggVorbis_File *vf);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions. Once this has been called, the same OggVorbis_File -struct should be passed to all the libvorbisfile functions.
    -
    - - -

    Return Values

    -
    -
  • -0 for success
  • - -
  • less than zero for failure:
  • -
      -
    • OV_EREAD - A read from media returned an error.
    • -
    • OV_ENOTVORBIS - Bitstream is not Vorbis data.
    • -
    • OV_EVERSION - Vorbis version mismatch.
    • -
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • -
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • -
    -
    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - - - - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek.html deleted file mode 100644 index 067ac01d2..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek.html +++ /dev/null @@ -1,82 +0,0 @@ - - - -Vorbisfile - function - ov_time_seek - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_time_seek

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    For seekable -streams, this seeks to the given time. For implementing seeking in a player, -this is the only function generally needed. This also updates everything needed within the -decoder, so you can immediately call ov_read() and get data from -the newly seeked to position. This function does not work for unseekable streams. - -

    - - - - -
    -
    
    -int ov_time_seek(OggVorbis_File *vf, double s);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    Pointer to our already opened and initialized OggVorbis_File structure.
    -
    pos
    -
    Location to seek to within the file, specified in seconds.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek_lap.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek_lap.html deleted file mode 100644 index e163949a1..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek_lap.html +++ /dev/null @@ -1,105 +0,0 @@ - - - -Vorbisfile - function - ov_time_seek_lap - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_time_seek_lap

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    For seekable -streams, ov_time_seek_lap seeks to the given time. This variant of ov_time_seek also automatically -crosslaps the transition from the previous playback position into the -new playback position in order to eliminate clicking and boundary -discontinuities. Otherwise, usage and behavior is identical to ov_time_seek. - -

    ov_time_seek_lap also updates everything needed within the decoder, -so you can immediately call ov_read() and -get data from the newly seeked to position. - -

    ov_time_seek_lap will lap between logical stream links of differing -numbers of channels. Any extra channels from the origin of the seek -are ignored; playback of these channels simply ends. Extra channels at -the destination are lapped from silence. ov_time_seek_lap will also -lap between logical stream links of differing sample rates. In this -case, the sample rates are ignored (no implicit resampling is done to -match playback). It is up to the application developer to decide if -this behavior makes any sense in a given context; in practical use, -these default behaviors perform sensibly. - -

    This function does not work for unseekable streams. - - -

    - - - - -
    -
    
    -int ov_time_seek_lap(OggVorbis_File *vf, double s);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    Pointer to our already opened and initialized OggVorbis_File structure.
    -
    pos
    -
    Location to seek to within the file, specified in seconds.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EOF - Indicates stream is at end of file immediately after a seek - (making crosslap impossible as there's no preceeding decode state to crosslap). -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek_page.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek_page.html deleted file mode 100644 index a76750af8..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek_page.html +++ /dev/null @@ -1,83 +0,0 @@ - - - -Vorbisfile - function - ov_time_seek_page - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_time_seek_page

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    For seekable -streams, this seeks to closest full page preceding the given time. This function is faster than ov_time_seek because it doesn't seek through the last few samples to reach an exact time, but it is also less accurate. This should be used when speed is important. -

    This function also updates everything needed within the -decoder, so you can immediately call ov_read() and get data from -the newly seeked to position. -

    This function does not work for unseekable streams. - -

    - - - - -
    -
    
    -int ov_time_seek_page(OggVorbis_File *vf, double s);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    Pointer to our already opened and initialized OggVorbis_File structure.
    -
    pos
    -
    Location to seek to within the file, specified in seconds.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek_page_lap.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek_page_lap.html deleted file mode 100644 index 2d7c606ea..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_seek_page_lap.html +++ /dev/null @@ -1,112 +0,0 @@ - - - -Vorbisfile - function - ov_time_seek_page_lap - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_time_seek_page_lap

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    For seekable streams, ov_time_seek_page_lap seeks to the closest -full page preceeding the given time. This variant of ov_time_seek_page also automatically -crosslaps the transition from the previous playback position into the -new playback position in order to eliminate clicking and boundary -discontinuities. Otherwise, usage and behavior is identical to ov_time_seek_page. - -

    ov_time_seek_page_lap is faster than ov_time_seek_lap because it doesn't -seek through the last few samples to reach an exact time, but it is -also less accurate. This should be used when speed is important, but -crosslapping is still desired. - -

    ov_time_seek_page_lap also updates everything needed within the -decoder, so you can immediately call ov_read() and get data from the newly seeked -to position. - -

    ov_time_seek_page_lap will lap between logical stream links of -differing numbers of channels. Any extra channels from the origin of -the seek are ignored; playback of these channels simply ends. Extra -channels at the destination are lapped from silence. -ov_time_seek_page_lap will also lap between logical stream links of -differing sample rates. In this case, the sample rates are ignored -(no implicit resampling is done to match playback). It is up to the -application developer to decide if this behavior makes any sense in a -given context; in practical use, these default behaviors perform -sensibly. - -

    This function does not work for unseekable streams. - -

    - - - - -
    -
    
    -int ov_time_seek_page_lap(OggVorbis_File *vf, double s);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    Pointer to our already opened and initialized OggVorbis_File structure.
    -
    pos
    -
    Location to seek to within the file, specified in seconds.
    -
    - - -

    Return Values

    -
    -
      -
    • 0 for success
    • - -
    • -nonzero indicates failure, described by several error codes: -
        -
      • OV_ENOSEEK - Bitstream is not seekable. -
      • -
      • OV_EINVAL - Invalid argument value; possibly called with an OggVorbis_File structure that isn't open. -
      • -
      • OV_EREAD - A read from media returned an error. -
      • -
      • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack - corruption. -
      • -
      • OV_EOF - Indicates stream is at end of file immediately after a seek - (making crosslap impossible as there's no preceeding decode state to crosslap). -
      • -
      • OV_EBADLINK - Invalid stream section supplied to libvorbisfile, or the requested link is corrupt. -
      • -
    • -
    - - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_tell.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_time_tell.html deleted file mode 100644 index 73cbe60f9..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_tell.html +++ /dev/null @@ -1,63 +0,0 @@ - - - -Vorbisfile - function - ov_time_tell - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_time_tell

    - -

    declared in "vorbis/vorbisfile.h";

    - -

    Returns the current decoding offset in seconds. - -

    - - - - -
    -
    
    -double ov_time_tell(OggVorbis_File *vf);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    - - -

    Return Values

    -
    -
  • n indicates the current decoding time offset in seconds.
  • -
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist.
  • -
    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_total.html b/Engine/lib/libvorbis/doc/vorbisfile/ov_time_total.html deleted file mode 100644 index 98133d264..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/ov_time_total.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -Vorbisfile - function - ov_time_total - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    ov_time_total

    - -

    declared in "vorbis/vorbisfile.h";

    - - -

    Returns the total time in seconds of the physical bitstream or a specified logical bitstream. - - -

    - - - - -
    -
    
    -double ov_time_total(OggVorbis_File *vf,int i);
    -
    -
    - -

    Parameters

    -
    -
    vf
    -
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile -functions.
    -
    i
    -
    Link to the desired logical bitstream. To retrieve the time total for the entire physical bitstream, this parameter should be set to -1.
    -
    - - -

    Return Values

    -
    -
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist or the bitstream is nonseekable.
  • -
  • n total length in seconds of content if i=-1.
  • -
  • n length in seconds of logical bitstream if i=0 to n.
  • -
    -

    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/overview.html b/Engine/lib/libvorbis/doc/vorbisfile/overview.html deleted file mode 100644 index dfe80297d..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/overview.html +++ /dev/null @@ -1,61 +0,0 @@ - - - -Vorbisfile - API Overview - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Vorbisfile API Overview

    - -

    The makeup of the Vorbisfile libvorbisfile library API is relatively -simple. It revolves around a single file resource. This file resource is -passed to libvorbisfile, where it is opened, manipulated, and closed, -in the form of an OggVorbis_File -struct. -

    -The Vorbisfile API consists of the following functional categories: -

    -

    -

    -In addition, the following subjects deserve attention additional to -the above general overview: -

    -

    -

    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/reference.html b/Engine/lib/libvorbis/doc/vorbisfile/reference.html deleted file mode 100644 index 4c00a4d73..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/reference.html +++ /dev/null @@ -1,86 +0,0 @@ - - - -Vorbisfile API Reference - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Vorbisfile API Reference

    - -

    -Data Structures
    -OggVorbis_File
    -ov_callbacks
    -
    -Data Structures from libvorbis
    -vorbis_comment
    -vorbis_info
    -
    -Setup/Teardown
    -ov_fopen()
    -ov_open()
    -ov_open_callbacks()
    -ov_clear()
    -ov_test()
    -ov_test_callbacks()
    -ov_test_open()
    -
    -Decoding
    -ov_read()
    -ov_read_float()
    -ov_read_filter()
    -ov_crosslap()
    -
    -Seeking
    -ov_raw_seek()
    -ov_pcm_seek()
    -ov_time_seek()
    -ov_pcm_seek_page()
    -ov_time_seek_page()

    -ov_raw_seek_lap()
    -ov_pcm_seek_lap()
    -ov_time_seek_lap()
    -ov_pcm_seek_page_lap()
    -ov_time_seek_page_lap()
    -
    -File Information
    -ov_bitrate()
    -ov_bitrate_instant()
    -ov_streams()
    -ov_seekable()
    -ov_serialnumber()
    -ov_raw_total()
    -ov_pcm_total()
    -ov_time_total()
    -ov_raw_tell()
    -ov_pcm_tell()
    -ov_time_tell()
    -ov_info()
    -ov_comment()
    -
    -Return Codes (from libvorbis)
    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/seekexample.html b/Engine/lib/libvorbis/doc/vorbisfile/seekexample.html deleted file mode 100644 index 5da157e5b..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/seekexample.html +++ /dev/null @@ -1,152 +0,0 @@ - - - -vorbisfile - Example Code - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Example Code: seeking

    - -

    -The following is a run-through of the seeking example program supplied -with vorbisfile - seeking_test.c. -This program tests the vorbisfile ov_time_seek function by seeking to random points within the file. - -

    -First, relevant headers, including vorbis-specific "codec.h" and "vorbisfile.h" have to be included. - -

    - - - - -
    -
    
    -#include <stdlib.h>
    -#include <stdio.h>
    -#include "vorbis/codec.h"
    -#include "vorbis/vorbisfile.h"
    -
    -
    - -

    Inside main(), we declare our primary OggVorbis_File structure. We also declare other helpful variables to track our progress within the file. -

    - - - - -
    -
    
    -int main(){
    -  OggVorbis_File ov;
    -  int i;
    -
    -
    - -

    This example takes its input on stdin which is in 'text' mode by default under Windows; this will corrupt the input data unless set to binary mode. This applies only to Windows. -

    - - - - -
    -
    
    -#ifdef _WIN32 /* We need to set stdin to binary mode under Windows */
    -  _setmode( _fileno( stdin ), _O_BINARY );
    -#endif
    -
    -
    - -

    ov_open() must be -called to initialize the OggVorbis_File structure with default values. -ov_open_callbacks() also checks to ensure that we're reading Vorbis format and not something else. - -

    - - - - -
    -
    
    -  if(ov_open_callbacks(stdin,&ov,NULL,-1, OV_CALLBACKS_NOCLOSE)<0){
    -    printf("Could not open input as an OggVorbis file.\n\n");
    -    exit(1);
    -  }
    -
    -
    -
    - -

    -First we check to make sure the stream is seekable using ov_seekable. - -

    Then we seek to 100 random spots in the bitstream using ov_time_seek with randomly generated values. - -

    - - - - -
    -
    
    -  
    -  /* print details about each logical bitstream in the input */
    -  if(ov_seekable(&ov)){
    -    double length=ov_time_total(&ov,-1);
    -    printf("testing seeking to random places in %g seconds....\n",length);
    -    for(i=0;i<100;i++){
    -      double val=(double)rand()/RAND_MAX*length;
    -      ov_time_seek(&ov,val);
    -      printf("\r\t%d [%gs]...     ",i,val);
    -      fflush(stdout);
    -    }
    -    
    -    printf("\r                                   \nOK.\n\n");
    -  }else{
    -    printf("Standard input was not seekable.\n");
    -  }
    -  
    -
    -
    -

    -When we're done seeking, we need to call ov_clear() to release the bitstream. - -

    - - - - -
    -
    
    -  ov_clear(&ov);
    -  return 0;
    -}
    -
    -
    - -

    -The full source for seeking_test.c can be found with the vorbis -distribution in seeking_test.c. - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/seeking.html b/Engine/lib/libvorbis/doc/vorbisfile/seeking.html deleted file mode 100644 index f4eb075e3..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/seeking.html +++ /dev/null @@ -1,107 +0,0 @@ - - - -Vorbisfile - Seeking - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Seeking

    -

    Seeking functions allow you to specify a specific point in the stream to begin or continue decoding. -

    -All libvorbisfile seeking routines are declared in "vorbis/vorbisfile.h". - -

    Certain seeking functions are best suited to different situations. -When speed is important and exact positioning isn't required, -page-level seeking should be used. Note also that Vorbis files do not -necessarily start at a sample number or time offset of zero. Do not -be surprised if a file begins at a positive offset of several minutes -or hours, such as would happen if a large stream (such as a concert -recording) is chopped into multiple separate files. Requesting to -seek to a position before the beginning of such a file will seek to -the position where audio begins. - -

    As of vorbisfile version 1.68, seeking also optionally provides -automatic crosslapping to eliminate clicks and other discontinuity -artifacts at seeking boundaries. This fetaure is of particular -interest to player and game developers implementing dynamic music and -audio engines, or others looking for smooth transitions within a -single sample or across multiple samples.

    - -

    Naturally, seeking is available only within a seekable file or -stream. Seeking functions will return OV_ENOSEEK on -nonseekable files and streams. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    functionpurpose
    ov_raw_seekThis function seeks to a position specified in the compressed bitstream, specified in bytes.
    ov_pcm_seekThis function seeks to a specific audio sample number, specified in pcm samples.
    ov_pcm_seek_pageThis function seeks to the closest page preceding the specified audio sample number, specified in pcm samples.
    ov_time_seekThis function seeks to the specific time location in the bitstream, specified in seconds
    ov_time_seek_pageThis function seeks to the closest page preceding the specified time position in the bitstream
    ov_raw_seek_lapThis function seeks to a position specified in the compressed bitstream, specified in bytes. The boundary between the old and new playback positions is crosslapped to eliminate discontinuities.
    ov_pcm_seek_lapThis function seeks to a specific audio sample number, specified in pcm samples. The boundary between the old and new playback positions is crosslapped to eliminate discontinuities.
    ov_pcm_seek_page_lapThis function seeks to the closest page preceding the specified audio sample number, specified in pcm samples. The boundary between the old and new playback positions is crosslapped to eliminate discontinuities.
    ov_time_seek_lapThis function seeks to the specific time location in the bitstream, specified in seconds. The boundary between the old and new playback positions is crosslapped to eliminate discontinuities.
    ov_time_seek_page_lapThis function seeks to the closest page preceding the specified time position in the bitstream. The boundary between the old and new playback positions is crosslapped to eliminate discontinuities.
    - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/seeking_example_c.html b/Engine/lib/libvorbis/doc/vorbisfile/seeking_example_c.html deleted file mode 100644 index a7b9759c7..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/seeking_example_c.html +++ /dev/null @@ -1,86 +0,0 @@ - - - -vorbisfile - seeking_test.c - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    seeking_test.c

    - -

    -The example program source: - -

    - - - - -
    -
    
    -
    -#include <stdlib.h>
    -#include <stdio.h>
    -#include "vorbis/codec.h"
    -#include "vorbis/vorbisfile.h"
    -
    -int main(){
    -  OggVorbis_File ov;
    -  int i;
    -
    -#ifdef _WIN32 /* We need to set stdin to binary mode under Windows */
    -  _setmode( _fileno( stdin ), _O_BINARY );
    -#endif
    -
    -  /* open the file/pipe on stdin */
    -  if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)==-1){
    -    printf("Could not open input as an OggVorbis file.\n\n");
    -    exit(1);
    -  }
    -  
    -  /* print details about each logical bitstream in the input */
    -  if(ov_seekable(&ov)){
    -    double length=ov_time_total(&ov,-1);
    -    printf("testing seeking to random places in %g seconds....\n",length);
    -    for(i=0;i<100;i++){
    -      double val=(double)rand()/RAND_MAX*length;
    -      ov_time_seek(&ov,val);
    -      printf("\r\t%d [%gs]...     ",i,val);
    -      fflush(stdout);
    -    }
    -    
    -    printf("\r                                   \nOK.\n\n");
    -  }else{
    -    printf("Standard input was not seekable.\n");
    -  }
    -
    -  ov_clear(&ov);
    -  return 0;
    -}
    -
    -
    -
    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/seeking_test_c.html b/Engine/lib/libvorbis/doc/vorbisfile/seeking_test_c.html deleted file mode 100644 index a7b9759c7..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/seeking_test_c.html +++ /dev/null @@ -1,86 +0,0 @@ - - - -vorbisfile - seeking_test.c - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    seeking_test.c

    - -

    -The example program source: - -

    - - - - -
    -
    
    -
    -#include <stdlib.h>
    -#include <stdio.h>
    -#include "vorbis/codec.h"
    -#include "vorbis/vorbisfile.h"
    -
    -int main(){
    -  OggVorbis_File ov;
    -  int i;
    -
    -#ifdef _WIN32 /* We need to set stdin to binary mode under Windows */
    -  _setmode( _fileno( stdin ), _O_BINARY );
    -#endif
    -
    -  /* open the file/pipe on stdin */
    -  if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)==-1){
    -    printf("Could not open input as an OggVorbis file.\n\n");
    -    exit(1);
    -  }
    -  
    -  /* print details about each logical bitstream in the input */
    -  if(ov_seekable(&ov)){
    -    double length=ov_time_total(&ov,-1);
    -    printf("testing seeking to random places in %g seconds....\n",length);
    -    for(i=0;i<100;i++){
    -      double val=(double)rand()/RAND_MAX*length;
    -      ov_time_seek(&ov,val);
    -      printf("\r\t%d [%gs]...     ",i,val);
    -      fflush(stdout);
    -    }
    -    
    -    printf("\r                                   \nOK.\n\n");
    -  }else{
    -    printf("Standard input was not seekable.\n");
    -  }
    -
    -  ov_clear(&ov);
    -  return 0;
    -}
    -
    -
    -
    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/seekingexample.html b/Engine/lib/libvorbis/doc/vorbisfile/seekingexample.html deleted file mode 100644 index 6b831dbca..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/seekingexample.html +++ /dev/null @@ -1,203 +0,0 @@ - - - -vorbisfile - Example Code - - - - - - - - - -

    vorbisfile documentation

    vorbisfile version 1.25 - 20000615

    - -

    Example Code

    - -

    -The following is a run-through of the decoding example program supplied -with vorbisfile - vorbisfile_example.c. -This program takes a vorbis bitstream from stdin and writes raw pcm to stdout. - -

    -First, relevant headers, including vorbis-specific "codec.h" and "vorbisfile.h" have to be included. - -

    - - - - -
    -
    
    -#include <stdio.h>
    -#include <stdlib.h>
    -#include <math.h>
    -#include "vorbis/codec.h"
    -#include "vorbis/vorbisfile.h"
    -
    -
    -

    -We also have to make a concession to Windows users here. If we are using windows for decoding, we must declare these libraries so that we can set stdin/stdout to binary. -

    - - - - -
    -
    
    -#ifdef _WIN32
    -#include <io.h>
    -#include <fcntl.h>
    -#endif
    -
    -
    -

    -Next, a buffer for the pcm audio output is declared. - -

    - - - - -
    -
    
    -char pcmout[4096];
    -
    -
    - -

    Inside main(), we declare our primary OggVorbis_File structure. We also declare a few other helpful variables to track out progress within the file. -Also, we make our final concession to Windows users by setting the stdin and stdout to binary mode. -

    - - - - -
    -
    
    -int main(int argc, char **argv){
    -  OggVorbis_File vf;
    -  int eof=0;
    -  int current_section;
    -
    -#ifdef _WIN32
    -  _setmode( _fileno( stdin ), _O_BINARY );
    -#endif
    -
    -
    - -

    ov_open_callbacks() must be -called to initialize the OggVorbis_File structure with default values. -ov_open_callbacks() also checks to ensure that we're reading Vorbis format and not something else. - -

    - - - - -
    -
    
    -  if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) {
    -      fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
    -      exit(1);
    -  }
    -
    -
    -
    - -

    -We're going to pull the channel and bitrate info from the file using ov_info() and show them to the user. -We also want to pull out and show the user a comment attached to the file using ov_comment(). - -

    - - - - -
    -
    
    -  {
    -    char **ptr=ov_comment(&vf,-1)->user_comments;
    -    vorbis_info *vi=ov_info(&vf,-1);
    -    while(*ptr){
    -      fprintf(stderr,"%s\n",*ptr);
    -      ++ptr;
    -    }
    -    fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
    -    fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
    -  }
    -  
    -
    -
    - -

    -Here's the read loop: - -

    - - - - -
    -
    
    -
    -  while(!eof){
    -    long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&current_section);
    -    switch(ret){
    -    case 0:
    -      /* EOF */
    -      eof=1;
    -      break;
    -    case -1:
    -      break;
    -    default:
    -      fwrite(pcmout,1,ret,stdout);
    -      break;
    -    }
    -  }
    -  
    -
    -
    - -

    -The code is reading blocks of data using ov_read(). -Based on the value returned, we know if we're at the end of the file or have invalid data. If we have valid data, we write it to the pcm output. - -

    -Now that we've finished playing, we can pack up and go home. It's important to call ov_clear() when we're finished. - -

    - - - - -
    -
    
    -
    -  ov_clear(&vf);
    -    
    -  fprintf(stderr,"Done.\n");
    -  return(0);
    -}
    -
    -
    - -

    -The full source for vorbisfile_example.c can be found with the vorbis -distribution in vorbisfile_example.c. - -

    -


    - - - - - - - - -

    copyright © 2000 vorbis team

    Ogg Vorbis

    vorbisfile documentation

    vorbisfile version 1.25 - 20000615

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/style.css b/Engine/lib/libvorbis/doc/vorbisfile/style.css deleted file mode 100644 index 81cf41795..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/style.css +++ /dev/null @@ -1,7 +0,0 @@ -BODY { font-family: Helvetica, sans-serif } -TD { font-family: Helvetica, sans-serif } -P { font-family: Helvetica, sans-serif } -H1 { font-family: Helvetica, sans-serif } -H2 { font-family: Helvetica, sans-serif } -H4 { font-family: Helvetica, sans-serif } -P.tiny { font-size: 8pt } diff --git a/Engine/lib/libvorbis/doc/vorbisfile/threads.html b/Engine/lib/libvorbis/doc/vorbisfile/threads.html deleted file mode 100644 index 3d2015163..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/threads.html +++ /dev/null @@ -1,50 +0,0 @@ - - - -Vorbisfile - Thread Safety - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    Thread Safety

    - -Vorbisfile's libvorbisfile may be used safely in a threading environment -so long as thread access to individual OggVorbis_File instances is serialized. -
      - -
    • Only one thread at a time may enter a function that takes a given OggVorbis_File instance, even if the -functions involved appear to be read-only.

      - -

    • Multiple threads may enter -libvorbisfile at a given time, so long as each thread's function calls -are using different OggVorbis_File -instances.

      - -

    • Any one OggVorbis_File instance may be used safely from multiple threads so long as only one thread at a time is making calls using that instance.

      -

    - -

    -
    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/vorbisfile/vorbisfile_example_c.html b/Engine/lib/libvorbis/doc/vorbisfile/vorbisfile_example_c.html deleted file mode 100644 index 8662d9961..000000000 --- a/Engine/lib/libvorbis/doc/vorbisfile/vorbisfile_example_c.html +++ /dev/null @@ -1,106 +0,0 @@ - - - -vorbisfile - vorbisfile_example.c - - - - - - - - - -

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - -

    vorbisfile_example.c

    - -

    -The example program source: - -

    - - - - -
    -
    
    -#include <stdio.h>
    -#include <stdlib.h>
    -#include <math.h>
    -#include "vorbis/codec.h"
    -#include "vorbis/vorbisfile.h"
    -
    -#ifdef _WIN32
    -#include <io.h>
    -#include <fcntl.h>
    -#endif
    -
    -char pcmout[4096];
    -
    -int main(int argc, char **argv){
    -  OggVorbis_File vf;
    -  int eof=0;
    -  int current_section;
    -
    -#ifdef _WIN32
    -  _setmode( _fileno( stdin ), _O_BINARY );
    -  _setmode( _fileno( stdout ), _O_BINARY );
    -#endif
    -
    -  if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) {
    -      fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
    -      exit(1);
    -  }
    -
    -  {
    -    char **ptr=ov_comment(&vf,-1)->user_comments;
    -    vorbis_info *vi=ov_info(&vf,-1);
    -    while(*ptr){
    -      fprintf(stderr,"%s\n",*ptr);
    -      ++ptr;
    -    }
    -    fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
    -    fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
    -  }
    -  
    -  while(!eof){
    -    long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&current_section);
    -    if (ret == 0) {
    -      /* EOF */
    -      eof=1;
    -    } else if (ret < 0) {
    -      /* error in the stream.  Not a problem, just reporting it in
    -	 case we (the app) cares.  In this case, we don't. */
    -    } else {
    -      /* we don't bother dealing with sample rate changes, etc, but
    -	 you'll have to */
    -      fwrite(pcmout,1,ret,stdout);
    -    }
    -  }
    -
    -  ov_clear(&vf);
    -    
    -  fprintf(stderr,"Done.\n");
    -  return(0);
    -}
    -
    -
    -
    - - -

    -


    - - - - - - - - -

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    - - - - diff --git a/Engine/lib/libvorbis/doc/window1.png b/Engine/lib/libvorbis/doc/window1.png deleted file mode 100644 index 968bd3fe9..000000000 Binary files a/Engine/lib/libvorbis/doc/window1.png and /dev/null differ diff --git a/Engine/lib/libvorbis/doc/window2.png b/Engine/lib/libvorbis/doc/window2.png deleted file mode 100644 index bd8e3bb07..000000000 Binary files a/Engine/lib/libvorbis/doc/window2.png and /dev/null differ diff --git a/Engine/lib/libvorbis/examples/Makefile.am b/Engine/lib/libvorbis/examples/Makefile.am deleted file mode 100644 index 63dc8985f..000000000 --- a/Engine/lib/libvorbis/examples/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -## Process this file with automake to produce Makefile.in - -AUTOMAKE_OPTIONS = foreign - -noinst_PROGRAMS = decoder_example encoder_example chaining_example\ - vorbisfile_example seeking_example - -EXTRA_DIST = frameview.pl - -AM_CPPFLAGS = -I$(top_srcdir)/include @OGG_CFLAGS@ - -# uncomment to build static executables from the example code -#LDFLAGS = -all-static - -decoder_example_SOURCES = decoder_example.c -decoder_example_LDADD = $(top_builddir)/lib/libvorbis.la @VORBIS_LIBS@ @OGG_LIBS@ - -encoder_example_SOURCES = encoder_example.c -encoder_example_LDADD = $(top_builddir)/lib/libvorbisenc.la $(top_builddir)/lib/libvorbis.la @VORBIS_LIBS@ @OGG_LIBS@ - -chaining_example_SOURCES = chaining_example.c -chaining_example_LDADD = $(top_builddir)/lib/libvorbisfile.la $(top_builddir)/lib/libvorbis.la @VORBIS_LIBS@ @OGG_LIBS@ - -vorbisfile_example_SOURCES = vorbisfile_example.c -vorbisfile_example_LDADD = $(top_builddir)/lib/libvorbisfile.la $(top_builddir)/lib/libvorbis.la @VORBIS_LIBS@ @OGG_LIBS@ - -seeking_example_SOURCES = seeking_example.c -seeking_example_LDADD = $(top_builddir)/lib/libvorbisfile.la $(top_builddir)/lib/libvorbis.la @VORBIS_LIBS@ @OGG_LIBS@ - -debug: - $(MAKE) all CFLAGS="@DEBUG@" - -profile: - $(MAKE) all CFLAGS="@PROFILE@" diff --git a/Engine/lib/libvorbis/examples/chaining_example.c b/Engine/lib/libvorbis/examples/chaining_example.c deleted file mode 100644 index bde374900..000000000 --- a/Engine/lib/libvorbis/examples/chaining_example.c +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: illustrate simple use of chained bitstream and vorbisfile.a - - ********************************************************************/ - -#include -#include -#include - -#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ -#include -#include -#endif - -int main(){ - OggVorbis_File ov; - int i; - -#ifdef _WIN32 /* We need to set stdin to binary mode. Damn windows. */ - /* Beware the evil ifdef. We avoid these where we can, but this one we - cannot. Don't add any more, you'll probably go to hell if you do. */ - _setmode( _fileno( stdin ), _O_BINARY ); -#endif - - /* open the file/pipe on stdin */ - if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)<0){ - printf("Could not open input as an OggVorbis file.\n\n"); - exit(1); - } - - /* print details about each logical bitstream in the input */ - if(ov_seekable(&ov)){ - printf("Input bitstream contained %ld logical bitstream section(s).\n", - ov_streams(&ov)); - printf("Total bitstream samples: %ld\n\n", - (long)ov_pcm_total(&ov,-1)); - printf("Total bitstream playing time: %ld seconds\n\n", - (long)ov_time_total(&ov,-1)); - - }else{ - printf("Standard input was not seekable.\n" - "First logical bitstream information:\n\n"); - } - - for(i=0;irate,vi->channels,ov_bitrate(&ov,i)/1000, - ov_serialnumber(&ov,i)); - printf("\t\theader length: %ld bytes\n",(long) - (ov.dataoffsets[i]-ov.offsets[i])); - printf("\t\tcompressed length: %ld bytes\n",(long)(ov_raw_total(&ov,i))); - printf("\t\tplay time: %lds\n",(long)ov_time_total(&ov,i)); - } - - ov_clear(&ov); - return 0; -} - diff --git a/Engine/lib/libvorbis/examples/decoder_example.c b/Engine/lib/libvorbis/examples/decoder_example.c deleted file mode 100644 index 082f1bc9f..000000000 --- a/Engine/lib/libvorbis/examples/decoder_example.c +++ /dev/null @@ -1,313 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: simple example decoder - - ********************************************************************/ - -/* Takes a vorbis bitstream from stdin and writes raw stereo PCM to - stdout. Decodes simple and chained OggVorbis files from beginning - to end. Vorbisfile.a is somewhat more complex than the code below. */ - -/* Note that this is POSIX, not ANSI code */ - -#include -#include -#include -#include - -#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ -#include -#include -#endif - -#if defined(__MACOS__) && defined(__MWERKS__) -#include /* CodeWarrior's Mac "command-line" support */ -#endif - -ogg_int16_t convbuffer[4096]; /* take 8k out of the data segment, not the stack */ -int convsize=4096; - -extern void _VDBG_dump(void); - -int main(){ - ogg_sync_state oy; /* sync and verify incoming physical bitstream */ - ogg_stream_state os; /* take physical pages, weld into a logical - stream of packets */ - ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ - ogg_packet op; /* one raw packet of data for decode */ - - vorbis_info vi; /* struct that stores all the static vorbis bitstream - settings */ - vorbis_comment vc; /* struct that stores all the bitstream user comments */ - vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ - vorbis_block vb; /* local working space for packet->PCM decode */ - - char *buffer; - int bytes; - -#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ - /* Beware the evil ifdef. We avoid these where we can, but this one we - cannot. Don't add any more, you'll probably go to hell if you do. */ - _setmode( _fileno( stdin ), _O_BINARY ); - _setmode( _fileno( stdout ), _O_BINARY ); -#endif - -#if defined(macintosh) && defined(__MWERKS__) - { - int argc; - char **argv; - argc=ccommand(&argv); /* get a "command line" from the Mac user */ - /* this also lets the user set stdin and stdout */ - } -#endif - - /********** Decode setup ************/ - - ogg_sync_init(&oy); /* Now we can read pages */ - - while(1){ /* we repeat if the bitstream is chained */ - int eos=0; - int i; - - /* grab some data at the head of the stream. We want the first page - (which is guaranteed to be small and only contain the Vorbis - stream initial header) We need the first page to get the stream - serialno. */ - - /* submit a 4k block to libvorbis' Ogg layer */ - buffer=ogg_sync_buffer(&oy,4096); - bytes=fread(buffer,1,4096,stdin); - ogg_sync_wrote(&oy,bytes); - - /* Get the first page. */ - if(ogg_sync_pageout(&oy,&og)!=1){ - /* have we simply run out of data? If so, we're done. */ - if(bytes<4096)break; - - /* error case. Must not be Vorbis data */ - fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); - exit(1); - } - - /* Get the serial number and set up the rest of decode. */ - /* serialno first; use it to set up a logical stream */ - ogg_stream_init(&os,ogg_page_serialno(&og)); - - /* extract the initial header from the first page and verify that the - Ogg bitstream is in fact Vorbis data */ - - /* I handle the initial header first instead of just having the code - read all three Vorbis headers at once because reading the initial - header is an easy way to identify a Vorbis bitstream and it's - useful to see that functionality seperated out. */ - - vorbis_info_init(&vi); - vorbis_comment_init(&vc); - if(ogg_stream_pagein(&os,&og)<0){ - /* error; stream version mismatch perhaps */ - fprintf(stderr,"Error reading first page of Ogg bitstream data.\n"); - exit(1); - } - - if(ogg_stream_packetout(&os,&op)!=1){ - /* no page? must not be vorbis */ - fprintf(stderr,"Error reading initial header packet.\n"); - exit(1); - } - - if(vorbis_synthesis_headerin(&vi,&vc,&op)<0){ - /* error case; not a vorbis header */ - fprintf(stderr,"This Ogg bitstream does not contain Vorbis " - "audio data.\n"); - exit(1); - } - - /* At this point, we're sure we're Vorbis. We've set up the logical - (Ogg) bitstream decoder. Get the comment and codebook headers and - set up the Vorbis decoder */ - - /* The next two packets in order are the comment and codebook headers. - They're likely large and may span multiple pages. Thus we read - and submit data until we get our two packets, watching that no - pages are missing. If a page is missing, error out; losing a - header page is the only place where missing data is fatal. */ - - i=0; - while(i<2){ - while(i<2){ - int result=ogg_sync_pageout(&oy,&og); - if(result==0)break; /* Need more data */ - /* Don't complain about missing or corrupt data yet. We'll - catch it at the packet output phase */ - if(result==1){ - ogg_stream_pagein(&os,&og); /* we can ignore any errors here - as they'll also become apparent - at packetout */ - while(i<2){ - result=ogg_stream_packetout(&os,&op); - if(result==0)break; - if(result<0){ - /* Uh oh; data at some point was corrupted or missing! - We can't tolerate that in a header. Die. */ - fprintf(stderr,"Corrupt secondary header. Exiting.\n"); - exit(1); - } - result=vorbis_synthesis_headerin(&vi,&vc,&op); - if(result<0){ - fprintf(stderr,"Corrupt secondary header. Exiting.\n"); - exit(1); - } - i++; - } - } - } - /* no harm in not checking before adding more */ - buffer=ogg_sync_buffer(&oy,4096); - bytes=fread(buffer,1,4096,stdin); - if(bytes==0 && i<2){ - fprintf(stderr,"End of file before finding all Vorbis headers!\n"); - exit(1); - } - ogg_sync_wrote(&oy,bytes); - } - - /* Throw the comments plus a few lines about the bitstream we're - decoding */ - { - char **ptr=vc.user_comments; - while(*ptr){ - fprintf(stderr,"%s\n",*ptr); - ++ptr; - } - fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi.channels,vi.rate); - fprintf(stderr,"Encoded by: %s\n\n",vc.vendor); - } - - convsize=4096/vi.channels; - - /* OK, got and parsed all three headers. Initialize the Vorbis - packet->PCM decoder. */ - if(vorbis_synthesis_init(&vd,&vi)==0){ /* central decode state */ - vorbis_block_init(&vd,&vb); /* local state for most of the decode - so multiple block decodes can - proceed in parallel. We could init - multiple vorbis_block structures - for vd here */ - - /* The rest is just a straight decode loop until end of stream */ - while(!eos){ - while(!eos){ - int result=ogg_sync_pageout(&oy,&og); - if(result==0)break; /* need more data */ - if(result<0){ /* missing or corrupt data at this page position */ - fprintf(stderr,"Corrupt or missing data in bitstream; " - "continuing...\n"); - }else{ - ogg_stream_pagein(&os,&og); /* can safely ignore errors at - this point */ - while(1){ - result=ogg_stream_packetout(&os,&op); - - if(result==0)break; /* need more data */ - if(result<0){ /* missing or corrupt data at this page position */ - /* no reason to complain; already complained above */ - }else{ - /* we have a packet. Decode it */ - float **pcm; - int samples; - - if(vorbis_synthesis(&vb,&op)==0) /* test for success! */ - vorbis_synthesis_blockin(&vd,&vb); - /* - - **pcm is a multichannel float vector. In stereo, for - example, pcm[0] is left, and pcm[1] is right. samples is - the size of each channel. Convert the float values - (-1.<=range<=1.) to whatever PCM format and write it out */ - - while((samples=vorbis_synthesis_pcmout(&vd,&pcm))>0){ - int j; - int clipflag=0; - int bout=(samples32767){ - val=32767; - clipflag=1; - } - if(val<-32768){ - val=-32768; - clipflag=1; - } - *ptr=val; - ptr+=vi.channels; - } - } - - if(clipflag) - fprintf(stderr,"Clipping in frame %ld\n",(long)(vd.sequence)); - - - fwrite(convbuffer,2*vi.channels,bout,stdout); - - vorbis_synthesis_read(&vd,bout); /* tell libvorbis how - many samples we - actually consumed */ - } - } - } - if(ogg_page_eos(&og))eos=1; - } - } - if(!eos){ - buffer=ogg_sync_buffer(&oy,4096); - bytes=fread(buffer,1,4096,stdin); - ogg_sync_wrote(&oy,bytes); - if(bytes==0)eos=1; - } - } - - /* ogg_page and ogg_packet structs always point to storage in - libvorbis. They're never freed or manipulated directly */ - - vorbis_block_clear(&vb); - vorbis_dsp_clear(&vd); - }else{ - fprintf(stderr,"Error: Corrupt header during playback initialization.\n"); - } - - /* clean up this logical bitstream; before exit we see if we're - followed by another [chained] */ - - ogg_stream_clear(&os); - vorbis_comment_clear(&vc); - vorbis_info_clear(&vi); /* must be called last */ - } - - /* OK, clean up the framer */ - ogg_sync_clear(&oy); - - fprintf(stderr,"Done.\n"); - return(0); -} diff --git a/Engine/lib/libvorbis/examples/encoder_example.c b/Engine/lib/libvorbis/examples/encoder_example.c deleted file mode 100644 index 9a527f33d..000000000 --- a/Engine/lib/libvorbis/examples/encoder_example.c +++ /dev/null @@ -1,251 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: simple example encoder - - ********************************************************************/ - -/* takes a stereo 16bit 44.1kHz WAV file from stdin and encodes it into - a Vorbis bitstream */ - -/* Note that this is POSIX, not ANSI, code */ - -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ -#include -#include -#endif - -#if defined(__MACOS__) && defined(__MWERKS__) -#include /* CodeWarrior's Mac "command-line" support */ -#endif - -#define READ 1024 -signed char readbuffer[READ*4+44]; /* out of the data segment, not the stack */ - -int main(){ - ogg_stream_state os; /* take physical pages, weld into a logical - stream of packets */ - ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ - ogg_packet op; /* one raw packet of data for decode */ - - vorbis_info vi; /* struct that stores all the static vorbis bitstream - settings */ - vorbis_comment vc; /* struct that stores all the user comments */ - - vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ - vorbis_block vb; /* local working space for packet->PCM decode */ - - int eos=0,ret; - int i, founddata; - -#if defined(macintosh) && defined(__MWERKS__) - int argc = 0; - char **argv = NULL; - argc = ccommand(&argv); /* get a "command line" from the Mac user */ - /* this also lets the user set stdin and stdout */ -#endif - - /* we cheat on the WAV header; we just bypass 44 bytes (simplest WAV - header is 44 bytes) and assume that the data is 44.1khz, stereo, 16 bit - little endian pcm samples. This is just an example, after all. */ - -#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ - /* if we were reading/writing a file, it would also need to in - binary mode, eg, fopen("file.wav","wb"); */ - /* Beware the evil ifdef. We avoid these where we can, but this one we - cannot. Don't add any more, you'll probably go to hell if you do. */ - _setmode( _fileno( stdin ), _O_BINARY ); - _setmode( _fileno( stdout ), _O_BINARY ); -#endif - - - /* we cheat on the WAV header; we just bypass the header and never - verify that it matches 16bit/stereo/44.1kHz. This is just an - example, after all. */ - - readbuffer[0] = '\0'; - for (i=0, founddata=0; i<30 && ! feof(stdin) && ! ferror(stdin); i++) - { - fread(readbuffer,1,2,stdin); - - if ( ! strncmp((char*)readbuffer, "da", 2) ){ - founddata = 1; - fread(readbuffer,1,6,stdin); - break; - } - } - - /********** Encode setup ************/ - - vorbis_info_init(&vi); - - /* choose an encoding mode. A few possibilities commented out, one - actually used: */ - - /********************************************************************* - Encoding using a VBR quality mode. The usable range is -.1 - (lowest quality, smallest file) to 1. (highest quality, largest file). - Example quality mode .4: 44kHz stereo coupled, roughly 128kbps VBR - - ret = vorbis_encode_init_vbr(&vi,2,44100,.4); - - --------------------------------------------------------------------- - - Encoding using an average bitrate mode (ABR). - example: 44kHz stereo coupled, average 128kbps VBR - - ret = vorbis_encode_init(&vi,2,44100,-1,128000,-1); - - --------------------------------------------------------------------- - - Encode using a quality mode, but select that quality mode by asking for - an approximate bitrate. This is not ABR, it is true VBR, but selected - using the bitrate interface, and then turning bitrate management off: - - ret = ( vorbis_encode_setup_managed(&vi,2,44100,-1,128000,-1) || - vorbis_encode_ctl(&vi,OV_ECTL_RATEMANAGE2_SET,NULL) || - vorbis_encode_setup_init(&vi)); - - *********************************************************************/ - - ret=vorbis_encode_init_vbr(&vi,2,44100,0.1); - - /* do not continue if setup failed; this can happen if we ask for a - mode that libVorbis does not support (eg, too low a bitrate, etc, - will return 'OV_EIMPL') */ - - if(ret)exit(1); - - /* add a comment */ - vorbis_comment_init(&vc); - vorbis_comment_add_tag(&vc,"ENCODER","encoder_example.c"); - - /* set up the analysis state and auxiliary encoding storage */ - vorbis_analysis_init(&vd,&vi); - vorbis_block_init(&vd,&vb); - - /* set up our packet->stream encoder */ - /* pick a random serial number; that way we can more likely build - chained streams just by concatenation */ - srand(time(NULL)); - ogg_stream_init(&os,rand()); - - /* Vorbis streams begin with three headers; the initial header (with - most of the codec setup parameters) which is mandated by the Ogg - bitstream spec. The second header holds any comment fields. The - third header holds the bitstream codebook. We merely need to - make the headers, then pass them to libvorbis one at a time; - libvorbis handles the additional Ogg bitstream constraints */ - - { - ogg_packet header; - ogg_packet header_comm; - ogg_packet header_code; - - vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code); - ogg_stream_packetin(&os,&header); /* automatically placed in its own - page */ - ogg_stream_packetin(&os,&header_comm); - ogg_stream_packetin(&os,&header_code); - - /* This ensures the actual - * audio data will start on a new page, as per spec - */ - while(!eos){ - int result=ogg_stream_flush(&os,&og); - if(result==0)break; - fwrite(og.header,1,og.header_len,stdout); - fwrite(og.body,1,og.body_len,stdout); - } - - } - - while(!eos){ - long i; - long bytes=fread(readbuffer,1,READ*4,stdin); /* stereo hardwired here */ - - if(bytes==0){ - /* end of file. this can be done implicitly in the mainline, - but it's easier to see here in non-clever fashion. - Tell the library we're at end of stream so that it can handle - the last frame and mark end of stream in the output properly */ - vorbis_analysis_wrote(&vd,0); - - }else{ - /* data to encode */ - - /* expose the buffer to submit data */ - float **buffer=vorbis_analysis_buffer(&vd,READ); - - /* uninterleave samples */ - for(i=0;i'AnalyzerGraph'); -my $Xname=$toplevel->Class; -$toplevel->optionAdd("$Xname.geometry", "800x600",20); - -my $geometry=$toplevel->optionGet('geometry',''); -$geometry=~/^(\d+)x(\d+)/; - -$toplevel->configure(-width=>$1); -$toplevel->configure(-height=>$2); - - - - - -$toplevel->optionAdd("$Xname.background", "#4fc627",20); -$toplevel->optionAdd("$Xname*highlightBackground", "#80c0d3",20); -$toplevel->optionAdd("$Xname.Panel.background", "#4fc627",20); -$toplevel->optionAdd("$Xname.Panel.foreground", "#d0d0d0",20); -$toplevel->optionAdd("$Xname.Panel.font", - '-*-helvetica-bold-r-*-*-18-*-*-*-*-*-*-*',20); -$toplevel->optionAdd("$Xname*Statuslabel.font", - '-*-helvetica-bold-r-*-*-18-*-*-*-*-*-*-*',20); -$toplevel->optionAdd("$Xname*Statuslabel.foreground", "#606060"); -$toplevel->optionAdd("$Xname*Status.font", - '-*-helvetica-bold-r-*-*-18-*-*-*-*-*-*-*',20); - -$toplevel->optionAdd("$Xname*AlertDetail.font", - '-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*',20); - - -$toplevel->optionAdd("$Xname*background", "#d0d0d0",20); -$toplevel->optionAdd("$Xname*foreground", '#000000',20); - -$toplevel->optionAdd("$Xname*Button*background", "#f0d0b0",20); -$toplevel->optionAdd("$Xname*Button*foreground", '#000000',20); -$toplevel->optionAdd("$Xname*Button*borderWidth", '2',20); -$toplevel->optionAdd("$Xname*Button*relief", 'groove',20); -$toplevel->optionAdd("$Xname*Button*padY", 1,20); - -#$toplevel->optionAdd("$Xname*Scale*background", "#f0d0b0",20); -$toplevel->optionAdd("$Xname*Scale*foreground", '#000000',20); -$toplevel->optionAdd("$Xname*Scale*borderWidth", '1',20); -#$toplevel->optionAdd("$Xname*Scale*relief", 'groove',20); -$toplevel->optionAdd("$Xname*Scale*padY", 1,20); - -$toplevel->optionAdd("$Xname*Checkbutton*background", "#f0d0b0",20); -$toplevel->optionAdd("$Xname*Checkbutton*foreground", '#000000',20); -$toplevel->optionAdd("$Xname*Checkbutton*borderWidth", '2',20); -$toplevel->optionAdd("$Xname*Checkbutton*relief", 'groove',20); - -$toplevel->optionAdd("$Xname*activeBackground", "#ffffff",20); -$toplevel->optionAdd("$Xname*activeForeground", '#0000a0',20); -$toplevel->optionAdd("$Xname*borderWidth", 0,20); -$toplevel->optionAdd("$Xname*relief", 'flat',20); -$toplevel->optionAdd("$Xname*activeBorderWidth", 1,20); -$toplevel->optionAdd("$Xname*highlightThickness", 0,20); -$toplevel->optionAdd("$Xname*padX", 2,20); -$toplevel->optionAdd("$Xname*padY", 2,20); -$toplevel->optionAdd("$Xname*font", - '-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*',20); -$toplevel->optionAdd("$Xname*Entry.font", - '-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*',20); -$toplevel->optionAdd("$Xname*Exit.font", - '-*-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*',20); -$toplevel->optionAdd("$Xname*Exit.relief", 'groove',20); -$toplevel->optionAdd("$Xname*Exit.padX", 1,20); -$toplevel->optionAdd("$Xname*Exit.padY", 1,20); -$toplevel->optionAdd("$Xname*Exit.borderWidth", 2,20); -$toplevel->optionAdd("$Xname*Exit*background", "#a0a0a0",20); -$toplevel->optionAdd("$Xname*Exit*disabledForeground", "#ffffff",20); - -#$toplevel->optionAdd("$Xname*Canvas.background", "#c0c0c0",20); - -$toplevel->optionAdd("$Xname*Entry.background", "#ffffff",20); -$toplevel->optionAdd("$Xname*Entry.disabledForeground", "#c0c0c0",20); -$toplevel->optionAdd("$Xname*Entry.relief", "sunken",20); -$toplevel->optionAdd("$Xname*Entry.borderWidth", 1,20); - -$toplevel->optionAdd("$Xname*Field.background", "#ffffff",20); -$toplevel->optionAdd("$Xname*Field.disabledForeground", "#c0c0c0",20); -$toplevel->optionAdd("$Xname*Field.relief", "flat",20); -$toplevel->optionAdd("$Xname*Field.borderWidth", 1,20); - -$toplevel->optionAdd("$Xname*Label.disabledForeground", "#c0c0c0",20); -$toplevel->optionAdd("$Xname*Label.borderWidth", 1,20); - -$toplevel->configure(-background=>$toplevel->optionGet("background","")); - -#$toplevel->resizable(FALSE,FALSE); - -my $panel=new MainWindow(-class=>'AnalyzerPanel'); -my $X2name=$panel->Class; - -$panel->optionAdd("$X2name.background", "#353535",20); -$panel->optionAdd("$X2name*highlightBackground", "#80c0d3",20); -$panel->optionAdd("$X2name.Panel.background", "#353535",20); -$panel->optionAdd("$X2name.Panel.foreground", "#4fc627",20); -$panel->optionAdd("$X2name.Panel.font", - '-*-helvetica-bold-o-*-*-18-*-*-*-*-*-*-*',20); -$panel->optionAdd("$X2name*Statuslabel.font", - '-*-helvetica-bold-r-*-*-18-*-*-*-*-*-*-*',20); -$panel->optionAdd("$X2name*Statuslabel.foreground", "#4fc627",20); -$panel->optionAdd("$X2name*Status.font", - '-*-helvetica-bold-r-*-*-18-*-*-*-*-*-*-*',20); - -$panel->optionAdd("$X2name*AlertDetail.font", - '-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*',20); - - -$panel->optionAdd("$X2name*background", "#d0d0d0",20); -$panel->optionAdd("$X2name*foreground", '#000000',20); - -$panel->optionAdd("$X2name*Button*background", "#f0d0b0",20); -$panel->optionAdd("$X2name*Button*foreground", '#000000',20); -$panel->optionAdd("$X2name*Button*borderWidth", '2',20); -$panel->optionAdd("$X2name*Button*relief", 'groove',20); -$panel->optionAdd("$X2name*Button*padY", 1,20); - -$panel->optionAdd("$X2name*Checkbutton*background", "#f0d0b0",20); -$panel->optionAdd("$X2name*Checkbutton*foreground", '#000000',20); -$panel->optionAdd("$X2name*Checkbutton*borderWidth", '2',20); -#$panel->optionAdd("$X2name*Checkbutton*padX", '0',20); -#$panel->optionAdd("$X2name*Checkbutton*padY", '0',20); -#$panel->optionAdd("$X2name*Checkbutton*relief", 'groove',20); - -$panel->optionAdd("$X2name*activeBackground", "#ffffff",20); -$panel->optionAdd("$X2name*activeForeground", '#0000a0',20); -$panel->optionAdd("$X2name*borderWidth", 0,20); -$panel->optionAdd("$X2name*relief", 'flat',20); -$panel->optionAdd("$X2name*activeBorderWidth", 1,20); -$panel->optionAdd("$X2name*highlightThickness", 0,20); -$panel->optionAdd("$X2name*padX", 2,20); -$panel->optionAdd("$X2name*padY", 2,20); -$panel->optionAdd("$X2name*font", - '-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*',20); -$panel->optionAdd("$X2name*Entry.font", - '-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*',20); - -$panel->optionAdd("$X2name*Exit.font", - '-*-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*',20); -$panel->optionAdd("$X2name*Exit.relief", 'groove',20); -$panel->optionAdd("$X2name*Exit.padX", 1,20); -$panel->optionAdd("$X2name*Exit.padY", 1,20); -$panel->optionAdd("$X2name*Exit.borderWidth", 2,20); -$panel->optionAdd("$X2name*Exit*background", "#a0a0a0",20); -$panel->optionAdd("$X2name*Exit*disabledForeground", "#ffffff",20); - -$panel->optionAdd("$X2name*Entry.background", "#ffffff",20); -$panel->optionAdd("$X2name*Entry.disabledForeground", "#c0c0c0",20); -$panel->optionAdd("$X2name*Entry.relief", "sunken",20); -$panel->optionAdd("$X2name*Entry.borderWidth", 1,20); - -$panel->optionAdd("$X2name*Field.background", "#ffffff",20); -$panel->optionAdd("$X2name*Field.disabledForeground", "#c0c0c0",20); -$panel->optionAdd("$X2name*Field.relief", "flat",20); -$panel->optionAdd("$X2name*Field.borderWidth", 1,20); - -$panel->optionAdd("$X2name*Label.disabledForeground", "#c0c0c0",20); -$panel->optionAdd("$X2name*Label.borderWidth", 1,20); - -$panel->configure(-background=>$panel->optionGet("background","")); - -#$panel->resizable("FALSE","FALSE"); - -my $panel_shell=$panel->Label(Name=>"shell",-borderwidth=>1,-relief=>'raised')-> - place(-x=>10,-y=>36,-relwidth=>1.0,-relheight=>1.0, - -width=>-20,-height=>-46,-anchor=>'nw'); - -my $panel_quit=$panel_shell->Button(-class=>"Exit",-text=>"quit",-command=>[sub{Shutdown()}])-> - place(-x=>-1,-y=>-1,-relx=>1.0,-rely=>1.0,-anchor=>'se'); - -$panel->Label(Name=>"logo text",-class=>"Panel",-text=>$version)-> - place(-x=>5,-y=>5,-anchor=>'nw'); - - -my $graph_shell=$toplevel->Label(Name=>"shell",-borderwidth=>1,-relief=>'raised')-> - place(-x=>10,-y=>36,-relwidth=>1.0,-relheight=>1.0, - -width=>-20,-height=>-46,-anchor=>'nw'); - -my $graph_status=$toplevel->Label(Name=>"logo text",-class=>"Panel",-text=>"Starting up")-> - place(-x=>5,-y=>5,-anchor=>'nw'); - - -my $panely=5; -my $panel_rescan=$panel_shell->Button(-text=>"rescan",-command=>[sub{scan_directory()}])-> - place(-x=>-5,-relx=>1.,-y=>$panely,-anchor=>'ne'); -$panely+=$panel_rescan->reqheight()+6; - - -my$temp=$graph_shell->Button(-text=>"<<", - -command=>[sub{$fileno-=10;$fileno=$first_file if($fileno<$first_file); - load_graph();}])-> - place(-x=>5,-y=>-5,-rely=>1.,-relwidth=>.2,-width=>-5,-anchor=>'sw'); -$graph_shell->Button(-text=>">>", - -command=>[sub{$fileno+=10;$fileno=$last_file if($fileno>$last_file); - load_graph();}])-> - place(-x=>-5,-y=>-5,-relwidth=>.2,-rely=>1.,-width=>-5,-relx=>1.,-anchor=>'se'); -$graph_shell->Button(-text=>"<", - -command=>[sub{$fileno-=1;$fileno=$first_file if($fileno<$first_file); - load_graph();}])-> - place(-x=>5,-y=>-5,-relwidth=>.3,-width=>-7,-rely=>1.,-relx=>.2,-anchor=>'sw'); -$graph_shell->Button(-text=>">", - -command=>[sub{$fileno+=1;$fileno=$last_file if($fileno>$last_file); - load_graph();}])-> - place(-x=>-5,-y=>-5,-relwidth=>.3,-width=>-7,-rely=>1.,-relx=>.8,-anchor=>'se'); -my$graphy=-10-$temp->reqheight(); -my$graph_slider=$temp=$graph_shell->Scale(-bigincrement=>1, - -resolution=>1, - -showvalue=>'TRUE',-variable=>\$fileno,-orient=>'horizontal')-> - place(-x=>5,-y=>$graphy,-relwidth=>1.,-rely=>1.,-width=>-10,-anchor=>'sw'); -$graphy-=$temp->reqheight()+5; - -my$onecrop; -my$twocrop; - -my$oneresize=$temp=$graph_shell->Checkbutton(-text=>"rescale",-variable=>\$onecrop, - -command=>[sub{draw_graph();}])-> - place(-x=>5,-y=>5,-anchor=>'nw'); - -my$one=$graph_shell->Canvas()-> - place(-relwidth=>1.,-width=>-10,-relheight=>.5,-height=>($graphy/2)-5-$temp->reqheight(), - -x=>5,-y=>5+$temp->reqheight,-anchor=>'nw'); - - -my$tworesize=$temp=$graph_shell->Checkbutton(-text=>"rescale",-variable=>\$twocrop, - -command=>[sub{draw_graph();}])-> - place(-rely=>1.,-y=>5,-anchor=>'nw',-in=>$one); -my$two=$graph_shell->Canvas()-> - place(-relwidth=>1.,-relheight=>1.,-rely=>1.,-y=>5+$temp->reqheight(),-anchor=>'nw',-in=>$one); - -scan_directory(); - -my%onestate; -my%twostate; -my @data; - -$onestate{"canvas"}=$one; -$onestate{"vars"}=\@panel_onevars; -$twostate{"canvas"}=$two; -$twostate{"vars"}=\@panel_twovars; - -$graph_slider->configure(-command=>[sub{load_graph()}]); -load_graph(); -$toplevel->bind('MainWindow','',[sub{$toplevel->update(); - draw_graph()}]); - -Tk::MainLoop(); - -sub load_graph{ - - scan_directory()if(!defined($panel_count)); - - @data=undef; - - for(my$i=0;$i<$panel_count;$i++){ - my$filename=$panel_keys[$i]."_$fileno.m"; - if(open F, "$filename"){ - $data[$i]=[()]; - close F; - } - } - draw_graph(); -} - -sub graphhelper{ - my($graph)=@_; - my$count=0; - my@colors=("#ff0000","#00df00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffffff", - "#9f0000","#007f00","#00009f","#8f8f00","#8f008f","#008f8f","#000000"); - - my$w=$graph->{"canvas"}; - my$rescale=0; - - Status("Plotting $fileno"); - $w->delete('foo'); - $w->delete('legend'); - $w->delete('lines'); - - # count range - for(my$i=0;$i<$panel_count;$i++){ - if($graph->{"vars"}->[$i]){ - if(defined($data[$i])){ - if(!defined($graph->{"minx"})){ - $data[$i]->[0]=~m/^\s*(-?[0-9\.]*)[ ,]+(-?[0-9\.]*)/; - $graph->{"maxx"}=$1; - $graph->{"minx"}=$1; - $graph->{"maxy"}=$2; - $graph->{"miny"}=$2; - $rescale=1; - } - - for(my$j=0;$j<=$#{$data[$i]};$j++){ - $data[$i]->[$j]=~m/^\s*(-?[0-9\.]*)[ ,]+(-?[0-9\.]*)/; - $rescale=1 if($1>$graph->{"maxx"}); - $rescale=1 if($1<$graph->{"minx"}); - $rescale=1 if($2>$graph->{"maxy"}); - $rescale=1 if($2<$graph->{"miny"}); - $graph->{"maxx"}=$1 if($1>$graph->{"maxx"}); - $graph->{"minx"}=$1 if($1<$graph->{"minx"}); - $graph->{"maxy"}=$2 if($2>$graph->{"maxy"}); - $graph->{"miny"}=$2 if($2<$graph->{"miny"}); - } - } - $count++; - } - } - - my$width=$w->width(); - my$height=$w->height(); - - $rescale=1 if(!defined($graph->{"width"}) || - $width!=$graph->{"width"} || - $height!=$graph->{"height"}); - - $graph->{"width"}=$width; - $graph->{"height"}=$height; - - if(defined($graph->{"maxx"})){ - # draw axes, labels - # look for appropriate axis scales - - if($rescale){ - - $w->delete('ylabel'); - $w->delete('xlabel'); - $w->delete('axes'); - - my$yscale=1.; - my$xscale=1.; - my$iyscale=1.; - my$ixscale=1.; - while(($graph->{"maxx"}-$graph->{"minx"})*$xscale>15){$xscale*=.1;$ixscale*=10.;} - while(($graph->{"maxy"}-$graph->{"miny"})*$yscale>15){$yscale*=.1;$iyscale*=10.;} - - while(($graph->{"maxx"}-$graph->{"minx"})*$xscale<3){$xscale*=10.;$ixscale*=.1;} - while(($graph->{"maxy"}-$graph->{"miny"})*$yscale<3){$yscale*=10.;$iyscale*=.1;} - - # how tall are the x axis labels? - $w->createText(-1,-1,-anchor=>'se',-tags=>['foo'],-text=>"0123456789."); - my($x1,$y1,$x2,$y2)=$w->bbox('foo'); - $w->delete('foo'); - my$maxlabelheight=$y2-$y1; - my$useabley=$height-$maxlabelheight-3; - my$pixelpery=$useabley/($graph->{"maxy"}-$graph->{"miny"}); - - # place y axis labels at proper spacing/height - my$lasty=-$maxlabelheight/2; - my$topyval=int($graph->{"maxy"}*$yscale+1.)*$iyscale; - - for(my$i=0;;$i++){ - my$yval= $topyval-$i*$iyscale; - my$y= ($graph->{"maxy"}-$yval)*$pixelpery; - last if($y>$useabley); - if($y-$maxlabelheight>=$lasty){ - $w->createText(0,$y,-anchor=>'e',-tags=>['ylabel'],-text=>"$yval"); - $lasty=$y; - } - } - - # get the max ylabel width and place them at proper x - ($x1,$y1,$x2,$y2)=$w->bbox('ylabel'); - my$maxylabelwidth=$x2-$x1; - $w->move('ylabel',$maxylabelwidth,0); - - my$beginx=$maxylabelwidth+3; - my$useablex=$width-$beginx; - - # draw basic axes - $w->createLine($beginx,0,$beginx,$useabley,$width,$useabley, - -tags=>['axes'],-width=>2); - # draw y tix - $lasty=-$maxlabelheight/2; - for(my$i=0;;$i++){ - my$yval= $topyval-$i*$iyscale; - my$y= ($graph->{"maxy"}-$yval)*$pixelpery; - last if($y>$useabley); - if($yval==0){ - $w->createLine($beginx,$y,$width,$y, - -tags=>['axes'],-width=>1); - }else{ - if($y-$maxlabelheight>=$lasty){ - $w->createLine($beginx,$y,$width,$y, - -tags=>['axes'],-width=>1, - -stipple=>'gray50'); - - $lasty=$y; - } - } - } - - # place x axis labels at proper spacing - my$topxval=int($graph->{"maxx"}*$xscale+1.)*$ixscale; - my$pixelperx=$useablex/($graph->{"maxx"}-$graph->{"minx"}); - - for(my$i=0;;$i++){ - my$xval= $topxval-$i*$ixscale; - my$x= $width-($graph->{"maxx"}-$xval)*$pixelperx; - - last if($x<$beginx); - # bounding boxen are hard. place temp labels. - $w->createText(-1,-1,-anchor=>'e',-tags=>['foo'],-text=>"$xval"); - } - - ($x1,$y1,$x2,$y2)=$w->bbox('foo'); - my$maxxlabelwidth=$x2-$x1; - $w->delete('foo'); - my$lastx=$width; - - for(my$i=0;;$i++){ - my$xval= $topxval-$i*$ixscale; - my$x= $width-($graph->{"maxx"}-$xval)*$pixelperx; - - last if($x-$maxxlabelwidth/2<0 || $x<$beginx); - if($xval==0 && $x<$width){ - $w->createLine($x,0,$x,$useabley,-tags=>['axes'],-width=>1); - } - - if($x+$maxxlabelwidth<=$lastx){ - $w->createText($x,$height-1,-anchor=>'s',-tags=>['xlabel'],-text=>"$xval"); - $w->createLine($x,0,$x,$useabley,-tags=>['axes'],-width=>1,-stipple=>"gray50"); - $lastx=$x; - } - } - $graph->{"labelheight"}=$maxlabelheight; - $graph->{"xo"}=$beginx; - $graph->{"ppx"}=$pixelperx; - $graph->{"ppy"}=$pixelpery; - } - - # plot the files - $count=0; - my$legendy=$graph->{"labelheight"}/2; - for(my$i=0;$i<$panel_count;$i++){ - if($graph->{"vars"}->[$i]){ - $count++; # count here for legend color selection stability - if(defined($data[$i])){ - # place a legend placard; - my$color=$colors[($count-1)%($#colors+1)]; - $w->createText($width,$legendy,-anchor=>'e',-tags=>['legend'], - -fill=>$color,-text=>$panel_keys[$i]); - $legendy+=$graph->{"labelheight"}; - - # plot the lines - my@pairs=map{if(/^\s*(-?[0-9\.]*)[ ,]+(-?[0-9\.]*)/){ - (($1-$graph->{"minx"})*$graph->{"ppx"}+$graph->{"xo"}, - (-$2+$graph->{"maxy"})*$graph->{"ppy"})}} (@{$data[$i]}); - - $w->createLine((@pairs),-fill=>$color,-tags=>['lines']); - } - } - } - } -} - -sub draw_graph{ - - if($onecrop){ - $onestate{"minx"}=undef; - $onestate{"miny"}=undef; - $onestate{"maxx"}=undef; - $onestate{"maxy"}=undef; - } - if($twocrop){ - $twostate{"minx"}=undef; - $twostate{"miny"}=undef; - $twostate{"maxx"}=undef; - $twostate{"maxy"}=undef; - } - - for(my$i=0;$i<$panel_count;$i++){ - if($twostate{"vars"}->[$i]){ - - #re-place the canvases - - $oneresize->place(-x=>5,-y=>5,-anchor=>'nw'); - - $one->place(-relwidth=>1.,-width=>-10,-relheight=>.5, - -height=>($graphy/2)-5-$oneresize->reqheight(), - -x=>5,-y=>5+$oneresize->reqheight,-anchor=>'nw'); - - $tworesize->place(-rely=>1.,-y=>5,-anchor=>'nw',-in=>$one); - $two->place(-relwidth=>1.,-relheight=>1.,-rely=>1., - -y=>5+$tworesize->reqheight(),-anchor=>'nw',-in=>$one); - - graphhelper(\%onestate); - graphhelper(\%twostate); - return; - } - } - - $oneresize->place(-x=>5,-y=>5,-anchor=>'nw'); - - $one->place(-relwidth=>1.,-width=>-10,-relheight=>1., - -height=>$graphy-5-$oneresize->reqheight(), - -x=>5,-y=>5+$oneresize->reqheight,-anchor=>'nw'); - - $tworesize->placeForget(); - $two->placeForget(); - - graphhelper(\%onestate); -} - -sub depopulate_panel{ - my $win; - foreach $win (@panel_labels){ - $win->destroy(); - } - @panel_labels=(); - foreach $win (@panel_ones){ - $win->destroy(); - } - @panel_ones=(); - foreach $win (@panel_twos){ - $win->destroy(); - } - @panel_twos=(); - @panel_keys=(); -} - -sub populate_panel{ - my $localy=$panely; - my $key; - my $i=0; - foreach $key (sort (keys %bases)){ - $panel_keys[$i]=$key; - if(!defined($panel_onevars[$i])){ - $panel_onevars[$i]=0; - $panel_twovars[$i]=0; - } - - my $temp=$panel_twos[$i]=$panel_shell-> - Checkbutton(-variable=>\$panel_twovars[$i],-command=>['main::draw_graph'],-text=>'2')-> - place(-y=>$localy,-x=>-5,-anchor=>"ne",-relx=>1.); - my $oney=$temp->reqheight(); - my $onex=$temp->reqwidth()+15; - - $temp=$panel_ones[$i]=$panel_shell-> - Checkbutton(-variable=>\$panel_onevars[$i],-command=>['main::draw_graph'],-text=>'1')-> - place(-y=>0,-x=>0,-anchor=>"ne",-in=>$temp,-bordermode=>'outside'); - $oney=$temp->reqheight() if ($oney<$temp->reqheight()); - $onex+=$temp->reqwidth(); - - $temp=$panel_labels[$i]=$panel_shell->Label(-text=>$key,-class=>'Field',-justify=>'left')-> - place(-y=>$localy,-x=>5,-anchor=>"nw",-relwidth=>1.,-width=>-$onex, - -bordermode=>'outside'); - $oney=$temp->reqheight() if ($oney<$temp->reqheight()); - - $localy+=$oney+2; - $i++; - } - $panel_count=$i; - - $localy+=$panel_quit->reqheight()+50; - my $geometry=$panel->geometry(); - $geometry=~/^(\d+)/; - - $panel->configure(-height=>$localy); - $panel->configure(-width=>$1); -} - -sub Shutdown{ - Tk::exit(); -} - -sub Status{ - my$text=shift @_; - $graph_status->configure(-text=>"$text"); - $toplevel->update(); -} - -sub scan_directory{ - - %bases=(); - my$count=0; - - $first_file=undef; - $last_file=undef; - - if(opendir(D,".")){ - my$file; - while(defined($file=readdir(D))){ - if($file=~m/^(\S*)_(\d+).m/){ - $bases{"$1"}="0"; - $first_file=$2 if(!defined($first_file) || $2<$first_file); - $last_file=$2 if(!defined($last_file) || $2>$last_file); - $count++; - - Status("Reading... $count")if($count%117==0); - } - } - closedir(D); - } - Status("Done Reading: $count files"); - depopulate_panel(); - populate_panel(); - - $fileno=$first_file if($fileno<$first_file); - $fileno=$last_file if($fileno>$last_file); - - $graph_slider->configure(-from=>$first_file,-to=>$last_file); - -} - - - - - diff --git a/Engine/lib/libvorbis/examples/seeking_example.c b/Engine/lib/libvorbis/examples/seeking_example.c deleted file mode 100644 index 9588680b1..000000000 --- a/Engine/lib/libvorbis/examples/seeking_example.c +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: illustrate seeking, and test it too - - ********************************************************************/ - -#include -#include -#include "vorbis/codec.h" -#include "vorbis/vorbisfile.h" - -#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ -# include -# include -#endif - -void _verify(OggVorbis_File *ov, - ogg_int64_t val,ogg_int64_t pcmval,double timeval, - ogg_int64_t pcmlength, - char *bigassbuffer){ - off_t i; - int j; - long bread; - char buffer[4096]; - int dummy; - ogg_int64_t pos; - int hs = ov_halfrate_p(ov); - - /* verify the raw position, the pcm position and position decode */ - if(val!=-1 && ov_raw_tell(ov)pcmval){ - fprintf(stderr,"pcm position out of tolerance: requested %ld, got %ld\n", - (long)pcmval,(long)ov_pcm_tell(ov)); - exit(1); - } - if(timeval!=-1 && ov_time_tell(ov)>timeval){ - fprintf(stderr,"time position out of tolerance: requested %f, got %f\n", - timeval,ov_time_tell(ov)); - exit(1); - } - pos=ov_pcm_tell(ov); - if(pos<0 || pos>pcmlength){ - fprintf(stderr,"pcm position out of bounds: got %ld\n",(long)pos); - exit(1); - } - bread=ov_read(ov,buffer,4096,1,1,1,&dummy); - for(j=0;j>hs)*2)]){ - fprintf(stderr,"data after seek doesn't match declared pcm position %ld\n",(long)pos); - - for(i=0;i<(pcmlength>>hs)*2-bread;i++){ - for(j=0;j>hs)>=0 && (j+((pos*2)>>hs))<(pcmlength>>hs)*2) - fprintf(f,"%d %d\n",j,(int)bigassbuffer[j+((pos*2)>>hs)]); - fclose(f); - } - - exit(1); - } - } -} - -int main(){ - OggVorbis_File ov; - int i,ret; - ogg_int64_t pcmlength; - double timelength; - char *bigassbuffer; - int dummy; - int hs=0; - -#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ - _setmode( _fileno( stdin ), _O_BINARY ); -#endif - - - /* open the file/pipe on stdin */ - if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)<0){ - fprintf(stderr,"Could not open input as an OggVorbis file.\n\n"); - exit(1); - } - -#if 0 /*enable this code to test seeking with halfrate decode */ - if(ov_halfrate(&ov,1)){ - fprintf(stderr,"Sorry; unable to set half-rate decode.\n\n"); - exit(1); - }else - hs=1; -#endif - - if(ov_seekable(&ov)){ - - /* to simplify our own lives, we want to assume the whole file is - stereo. Verify this to avoid potentially mystifying users - (pissing them off is OK, just don't confuse them) */ - for(i=0;ichannels!=2){ - fprintf(stderr,"Sorry; right now seeking_test can only use Vorbis files\n" - "that are entirely stereo.\n\n"); - exit(1); - } - } - - /* because we want to do sample-level verification that the seek - does what it claimed, decode the entire file into memory */ - pcmlength=ov_pcm_total(&ov,-1); - timelength=ov_time_total(&ov,-1); - bigassbuffer=malloc((pcmlength>>hs)*2); /* w00t */ - i=0; - while(i<(pcmlength>>hs)*2){ - int ret=ov_read(&ov,bigassbuffer+i,((pcmlength>>hs)*2)-i,1,1,1,&dummy); - if(ret<0){ - fprintf(stderr,"Error reading file.\n"); - exit(1); - } - if(ret){ - i+=ret; - }else{ - pcmlength=(i/2)<>hs)*2-i)); - } - - { - ogg_int64_t length=ov.end; - fprintf(stderr,"\rtesting raw seeking to random places in %ld bytes....\n", - (long)length); - - for(i=0;i<1000;i++){ - ogg_int64_t val=(double)rand()/RAND_MAX*length; - fprintf(stderr,"\r\t%d [raw position %ld]... ",i,(long)val); - ret=ov_raw_seek(&ov,val); - if(ret<0){ - fprintf(stderr,"seek failed: %d\n",ret); - exit(1); - } - - _verify(&ov,val,-1,-1.,pcmlength,bigassbuffer); - - } - } - - fprintf(stderr,"\r"); - { - fprintf(stderr,"testing pcm page seeking to random places in %ld samples....\n", - (long)pcmlength); - - for(i=0;i<1000;i++){ - ogg_int64_t val= i==0?(ogg_int64_t)0:(double)rand()/RAND_MAX*pcmlength; - fprintf(stderr,"\r\t%d [pcm position %ld]... ",i,(long)val); - ret=ov_pcm_seek_page(&ov,val); - if(ret<0){ - fprintf(stderr,"seek failed: %d\n",ret); - exit(1); - } - - _verify(&ov,-1,val,-1.,pcmlength,bigassbuffer); - - } - } - - fprintf(stderr,"\r"); - { - fprintf(stderr,"testing pcm exact seeking to random places in %f seconds....\n", - timelength); - for(i=0;i<1000;i++){ - ogg_int64_t val= i==0?(ogg_int64_t)0:(double)rand()/RAND_MAX*pcmlength; - fprintf(stderr,"\r\t%d [pcm position %ld]... ",i,(long)val); - ret=ov_pcm_seek(&ov,val); - if(ret<0){ - fprintf(stderr,"seek failed: %d\n",ret); - exit(1); - } - if(ov_pcm_tell(&ov)!=((val>>hs)<val+1){ - fprintf(stderr,"Declared position didn't perfectly match request: %f != %f\n", - val,ov_time_tell(&ov)); - exit(1); - } - - _verify(&ov,-1,-1,val,pcmlength,bigassbuffer); - - } - } - - fprintf(stderr,"\r \nOK.\n\n"); - - - }else{ - fprintf(stderr,"Standard input was not seekable.\n"); - } - - ov_clear(&ov); - return 0; -} - - - - - - - - - - - - - diff --git a/Engine/lib/libvorbis/examples/vorbisfile_example.c b/Engine/lib/libvorbis/examples/vorbisfile_example.c deleted file mode 100644 index 78c8a04fe..000000000 --- a/Engine/lib/libvorbis/examples/vorbisfile_example.c +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: simple example decoder using vorbisfile - - ********************************************************************/ - -/* Takes a vorbis bitstream from stdin and writes raw stereo PCM to - stdout using vorbisfile. Using vorbisfile is much simpler than - dealing with libvorbis. */ - -#include -#include -#include -#include -#include - -#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ -#include -#include -#endif - -char pcmout[4096]; /* take 4k out of the data segment, not the stack */ - -int main(){ - OggVorbis_File vf; - int eof=0; - int current_section; - -#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ - /* Beware the evil ifdef. We avoid these where we can, but this one we - cannot. Don't add any more, you'll probably go to hell if you do. */ - _setmode( _fileno( stdin ), _O_BINARY ); - _setmode( _fileno( stdout ), _O_BINARY ); -#endif - - if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) { - fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); - exit(1); - } - - /* Throw the comments plus a few lines about the bitstream we're - decoding */ - { - char **ptr=ov_comment(&vf,-1)->user_comments; - vorbis_info *vi=ov_info(&vf,-1); - while(*ptr){ - fprintf(stderr,"%s\n",*ptr); - ++ptr; - } - fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate); - fprintf(stderr,"\nDecoded length: %ld samples\n", - (long)ov_pcm_total(&vf,-1)); - fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor); - } - - while(!eof){ - long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,¤t_section); - if (ret == 0) { - /* EOF */ - eof=1; - } else if (ret < 0) { - if(ret==OV_EBADLINK){ - fprintf(stderr,"Corrupt bitstream section! Exiting.\n"); - exit(1); - } - - /* some other error in the stream. Not a problem, just reporting it in - case we (the app) cares. In this case, we don't. */ - } else { - /* we don't bother dealing with sample rate changes, etc, but - you'll have to*/ - fwrite(pcmout,1,ret,stdout); - } - } - - /* cleanup */ - ov_clear(&vf); - - fprintf(stderr,"Done.\n"); - return(0); -} diff --git a/Engine/lib/libvorbis/include/Makefile.am b/Engine/lib/libvorbis/include/Makefile.am deleted file mode 100644 index 0f34fab4c..000000000 --- a/Engine/lib/libvorbis/include/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = vorbis diff --git a/Engine/lib/libvorbis/include/vorbis/Makefile.am b/Engine/lib/libvorbis/include/vorbis/Makefile.am deleted file mode 100644 index dbba34e55..000000000 --- a/Engine/lib/libvorbis/include/vorbis/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -## Process this file with automake to produce Makefile.in - -vorbisincludedir = $(includedir)/vorbis - -vorbisinclude_HEADERS = codec.h vorbisfile.h vorbisenc.h - - diff --git a/Engine/lib/libvorbis/include/vorbis/codec.h b/Engine/lib/libvorbis/include/vorbis/codec.h deleted file mode 100644 index f8a912bc2..000000000 --- a/Engine/lib/libvorbis/include/vorbis/codec.h +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation https://xiph.org/ * - - ******************************************************************** - - function: libvorbis codec headers - - ********************************************************************/ - -#ifndef _vorbis_codec_h_ -#define _vorbis_codec_h_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include - -typedef struct vorbis_info{ - int version; - int channels; - long rate; - - /* The below bitrate declarations are *hints*. - Combinations of the three values carry the following implications: - - all three set to the same value: - implies a fixed rate bitstream - only nominal set: - implies a VBR stream that averages the nominal bitrate. No hard - upper/lower limit - upper and or lower set: - implies a VBR bitstream that obeys the bitrate limits. nominal - may also be set to give a nominal rate. - none set: - the coder does not care to speculate. - */ - - long bitrate_upper; - long bitrate_nominal; - long bitrate_lower; - long bitrate_window; - - void *codec_setup; -} vorbis_info; - -/* vorbis_dsp_state buffers the current vorbis audio - analysis/synthesis state. The DSP state belongs to a specific - logical bitstream ****************************************************/ -typedef struct vorbis_dsp_state{ - int analysisp; - vorbis_info *vi; - - float **pcm; - float **pcmret; - int pcm_storage; - int pcm_current; - int pcm_returned; - - int preextrapolate; - int eofflag; - - long lW; - long W; - long nW; - long centerW; - - ogg_int64_t granulepos; - ogg_int64_t sequence; - - ogg_int64_t glue_bits; - ogg_int64_t time_bits; - ogg_int64_t floor_bits; - ogg_int64_t res_bits; - - void *backend_state; -} vorbis_dsp_state; - -typedef struct vorbis_block{ - /* necessary stream state for linking to the framing abstraction */ - float **pcm; /* this is a pointer into local storage */ - oggpack_buffer opb; - - long lW; - long W; - long nW; - int pcmend; - int mode; - - int eofflag; - ogg_int64_t granulepos; - ogg_int64_t sequence; - vorbis_dsp_state *vd; /* For read-only access of configuration */ - - /* local storage to avoid remallocing; it's up to the mapping to - structure it */ - void *localstore; - long localtop; - long localalloc; - long totaluse; - struct alloc_chain *reap; - - /* bitmetrics for the frame */ - long glue_bits; - long time_bits; - long floor_bits; - long res_bits; - - void *internal; - -} vorbis_block; - -/* vorbis_block is a single block of data to be processed as part of -the analysis/synthesis stream; it belongs to a specific logical -bitstream, but is independent from other vorbis_blocks belonging to -that logical bitstream. *************************************************/ - -struct alloc_chain{ - void *ptr; - struct alloc_chain *next; -}; - -/* vorbis_info contains all the setup information specific to the - specific compression/decompression mode in progress (eg, - psychoacoustic settings, channel setup, options, codebook - etc). vorbis_info and substructures are in backends.h. -*********************************************************************/ - -/* the comments are not part of vorbis_info so that vorbis_info can be - static storage */ -typedef struct vorbis_comment{ - /* unlimited user comment fields. libvorbis writes 'libvorbis' - whatever vendor is set to in encode */ - char **user_comments; - int *comment_lengths; - int comments; - char *vendor; - -} vorbis_comment; - - -/* libvorbis encodes in two abstraction layers; first we perform DSP - and produce a packet (see docs/analysis.txt). The packet is then - coded into a framed OggSquish bitstream by the second layer (see - docs/framing.txt). Decode is the reverse process; we sync/frame - the bitstream and extract individual packets, then decode the - packet back into PCM audio. - - The extra framing/packetizing is used in streaming formats, such as - files. Over the net (such as with UDP), the framing and - packetization aren't necessary as they're provided by the transport - and the streaming layer is not used */ - -/* Vorbis PRIMITIVES: general ***************************************/ - -extern void vorbis_info_init(vorbis_info *vi); -extern void vorbis_info_clear(vorbis_info *vi); -extern int vorbis_info_blocksize(vorbis_info *vi,int zo); -extern void vorbis_comment_init(vorbis_comment *vc); -extern void vorbis_comment_add(vorbis_comment *vc, const char *comment); -extern void vorbis_comment_add_tag(vorbis_comment *vc, - const char *tag, const char *contents); -extern char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count); -extern int vorbis_comment_query_count(vorbis_comment *vc, const char *tag); -extern void vorbis_comment_clear(vorbis_comment *vc); - -extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); -extern int vorbis_block_clear(vorbis_block *vb); -extern void vorbis_dsp_clear(vorbis_dsp_state *v); -extern double vorbis_granule_time(vorbis_dsp_state *v, - ogg_int64_t granulepos); - -extern const char *vorbis_version_string(void); - -/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/ - -extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); -extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op); -extern int vorbis_analysis_headerout(vorbis_dsp_state *v, - vorbis_comment *vc, - ogg_packet *op, - ogg_packet *op_comm, - ogg_packet *op_code); -extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals); -extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals); -extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb); -extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op); - -extern int vorbis_bitrate_addblock(vorbis_block *vb); -extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, - ogg_packet *op); - -/* Vorbis PRIMITIVES: synthesis layer *******************************/ -extern int vorbis_synthesis_idheader(ogg_packet *op); -extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, - ogg_packet *op); - -extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); -extern int vorbis_synthesis_restart(vorbis_dsp_state *v); -extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); -extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); -extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); -extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm); -extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm); -extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); -extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); - -extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag); -extern int vorbis_synthesis_halfrate_p(vorbis_info *v); - -/* Vorbis ERRORS and return codes ***********************************/ - -#define OV_FALSE -1 -#define OV_EOF -2 -#define OV_HOLE -3 - -#define OV_EREAD -128 -#define OV_EFAULT -129 -#define OV_EIMPL -130 -#define OV_EINVAL -131 -#define OV_ENOTVORBIS -132 -#define OV_EBADHEADER -133 -#define OV_EVERSION -134 -#define OV_ENOTAUDIO -135 -#define OV_EBADPACKET -136 -#define OV_EBADLINK -137 -#define OV_ENOSEEK -138 - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif - diff --git a/Engine/lib/libvorbis/include/vorbis/vorbisenc.h b/Engine/lib/libvorbis/include/vorbis/vorbisenc.h deleted file mode 100644 index 085b15e66..000000000 --- a/Engine/lib/libvorbis/include/vorbis/vorbisenc.h +++ /dev/null @@ -1,435 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: vorbis encode-engine setup - - ********************************************************************/ - -/** \file - * Libvorbisenc is a convenient API for setting up an encoding - * environment using libvorbis. Libvorbisenc encapsulates the - * actions needed to set up the encoder properly. - */ - -#ifndef _OV_ENC_H_ -#define _OV_ENC_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include "codec.h" - -/** - * This is the primary function within libvorbisenc for setting up managed - * bitrate modes. - * - * Before this function is called, the \ref vorbis_info - * struct should be initialized by using vorbis_info_init() from the libvorbis - * API. After encoding, vorbis_info_clear() should be called. - * - * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set - * constraints for the encoded file. This function uses these settings to - * select the appropriate encoding mode and set it up. - * - * \param vi Pointer to an initialized \ref vorbis_info struct. - * \param channels The number of channels to be encoded. - * \param rate The sampling rate of the source audio. - * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. - * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. - * \param min_bitrate Desired minimum bitrate. -1 indicates unset. - * - * \return Zero for success, and negative values for failure. - * - * \retval 0 Success. - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * \retval OV_EINVAL Invalid setup request, eg, out of range argument. - * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. - */ -extern int vorbis_encode_init(vorbis_info *vi, - long channels, - long rate, - - long max_bitrate, - long nominal_bitrate, - long min_bitrate); - -/** - * This function performs step-one of a three-step bitrate-managed encode - * setup. It functions similarly to the one-step setup performed by \ref - * vorbis_encode_init but allows an application to make further encode setup - * tweaks using \ref vorbis_encode_ctl before finally calling \ref - * vorbis_encode_setup_init to complete the setup process. - * - * Before this function is called, the \ref vorbis_info struct should be - * initialized by using vorbis_info_init() from the libvorbis API. After - * encoding, vorbis_info_clear() should be called. - * - * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set - * constraints for the encoded file. This function uses these settings to - * select the appropriate encoding mode and set it up. - * - * \param vi Pointer to an initialized vorbis_info struct. - * \param channels The number of channels to be encoded. - * \param rate The sampling rate of the source audio. - * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. - * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. - * \param min_bitrate Desired minimum bitrate. -1 indicates unset. - * - * \return Zero for success, and negative for failure. - * - * \retval 0 Success - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * \retval OV_EINVAL Invalid setup request, eg, out of range argument. - * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. - */ -extern int vorbis_encode_setup_managed(vorbis_info *vi, - long channels, - long rate, - - long max_bitrate, - long nominal_bitrate, - long min_bitrate); - -/** - * This function performs step-one of a three-step variable bitrate - * (quality-based) encode setup. It functions similarly to the one-step setup - * performed by \ref vorbis_encode_init_vbr() but allows an application to - * make further encode setup tweaks using \ref vorbis_encode_ctl() before - * finally calling \ref vorbis_encode_setup_init to complete the setup - * process. - * - * Before this function is called, the \ref vorbis_info struct should be - * initialized by using \ref vorbis_info_init() from the libvorbis API. After - * encoding, vorbis_info_clear() should be called. - * - * \param vi Pointer to an initialized vorbis_info struct. - * \param channels The number of channels to be encoded. - * \param rate The sampling rate of the source audio. - * \param quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). - * - * \return Zero for success, and negative values for failure. - * - * \retval 0 Success - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * \retval OV_EINVAL Invalid setup request, eg, out of range argument. - * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. - */ -extern int vorbis_encode_setup_vbr(vorbis_info *vi, - long channels, - long rate, - - float quality - ); - -/** - * This is the primary function within libvorbisenc for setting up variable - * bitrate ("quality" based) modes. - * - * - * Before this function is called, the vorbis_info struct should be - * initialized by using vorbis_info_init() from the libvorbis API. After - * encoding, vorbis_info_clear() should be called. - * - * \param vi Pointer to an initialized vorbis_info struct. - * \param channels The number of channels to be encoded. - * \param rate The sampling rate of the source audio. - * \param base_quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). - * - * - * \return Zero for success, or a negative number for failure. - * - * \retval 0 Success - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * \retval OV_EINVAL Invalid setup request, eg, out of range argument. - * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. - */ -extern int vorbis_encode_init_vbr(vorbis_info *vi, - long channels, - long rate, - - float base_quality - ); - -/** - * This function performs the last stage of three-step encoding setup, as - * described in the API overview under managed bitrate modes. - * - * Before this function is called, the \ref vorbis_info struct should be - * initialized by using vorbis_info_init() from the libvorbis API, one of - * \ref vorbis_encode_setup_managed() or \ref vorbis_encode_setup_vbr() called to - * initialize the high-level encoding setup, and \ref vorbis_encode_ctl() - * called if necessary to make encoding setup changes. - * vorbis_encode_setup_init() finalizes the highlevel encoding structure into - * a complete encoding setup after which the application may make no further - * setup changes. - * - * After encoding, vorbis_info_clear() should be called. - * - * \param vi Pointer to an initialized \ref vorbis_info struct. - * - * \return Zero for success, and negative values for failure. - * - * \retval 0 Success. - * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. - * - * \retval OV_EINVAL Attempt to use vorbis_encode_setup_init() without first - * calling one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() to - * initialize the high-level encoding setup - * - */ -extern int vorbis_encode_setup_init(vorbis_info *vi); - -/** - * This function implements a generic interface to miscellaneous encoder - * settings similar to the classic UNIX 'ioctl()' system call. Applications - * may use vorbis_encode_ctl() to query or set bitrate management or quality - * mode details by using one of several \e request arguments detailed below. - * vorbis_encode_ctl() must be called after one of - * vorbis_encode_setup_managed() or vorbis_encode_setup_vbr(). When used - * to modify settings, \ref vorbis_encode_ctl() must be called before \ref - * vorbis_encode_setup_init(). - * - * \param vi Pointer to an initialized vorbis_info struct. - * - * \param number Specifies the desired action; See \ref encctlcodes "the list - * of available requests". - * - * \param arg void * pointing to a data structure matching the request - * argument. - * - * \retval 0 Success. Any further return information (such as the result of a - * query) is placed into the storage pointed to by *arg. - * - * \retval OV_EINVAL Invalid argument, or an attempt to modify a setting after - * calling vorbis_encode_setup_init(). - * - * \retval OV_EIMPL Unimplemented or unknown request - */ -extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg); - -/** - * \deprecated This is a deprecated interface. Please use vorbis_encode_ctl() - * with the \ref ovectl_ratemanage2_arg struct and \ref - * OV_ECTL_RATEMANAGE2_GET and \ref OV_ECTL_RATEMANAGE2_SET calls in new code. - * - * The \ref ovectl_ratemanage_arg structure is used with vorbis_encode_ctl() - * and the \ref OV_ECTL_RATEMANAGE_GET, \ref OV_ECTL_RATEMANAGE_SET, \ref - * OV_ECTL_RATEMANAGE_AVG, \ref OV_ECTL_RATEMANAGE_HARD calls in order to - * query and modify specifics of the encoder's bitrate management - * configuration. -*/ -struct ovectl_ratemanage_arg { - int management_active; /**< nonzero if bitrate management is active*/ -/** hard lower limit (in kilobits per second) below which the stream bitrate - will never be allowed for any given bitrate_hard_window seconds of time.*/ - long bitrate_hard_min; -/** hard upper limit (in kilobits per second) above which the stream bitrate - will never be allowed for any given bitrate_hard_window seconds of time.*/ - long bitrate_hard_max; -/** the window period (in seconds) used to regulate the hard bitrate minimum - and maximum*/ - double bitrate_hard_window; -/** soft lower limit (in kilobits per second) below which the average bitrate - tracker will start nudging the bitrate higher.*/ - long bitrate_av_lo; -/** soft upper limit (in kilobits per second) above which the average bitrate - tracker will start nudging the bitrate lower.*/ - long bitrate_av_hi; -/** the window period (in seconds) used to regulate the average bitrate - minimum and maximum.*/ - double bitrate_av_window; -/** Regulates the relative centering of the average and hard windows; in - libvorbis 1.0 and 1.0.1, the hard window regulation overlapped but - followed the average window regulation. In libvorbis 1.1 a bit-reservoir - interface replaces the old windowing interface; the older windowing - interface is simulated and this field has no effect.*/ - double bitrate_av_window_center; -}; - -/** - * \name struct ovectl_ratemanage2_arg - * - * The ovectl_ratemanage2_arg structure is used with vorbis_encode_ctl() and - * the OV_ECTL_RATEMANAGE2_GET and OV_ECTL_RATEMANAGE2_SET calls in order to - * query and modify specifics of the encoder's bitrate management - * configuration. - * -*/ -struct ovectl_ratemanage2_arg { - int management_active; /**< nonzero if bitrate management is active */ -/** Lower allowed bitrate limit in kilobits per second */ - long bitrate_limit_min_kbps; -/** Upper allowed bitrate limit in kilobits per second */ - long bitrate_limit_max_kbps; - long bitrate_limit_reservoir_bits; /**struct ovectl_ratemanage2_arg *
    - * - * Used to query the current encoder bitrate management setting. Also used to - * initialize fields of an ovectl_ratemanage2_arg structure for use with - * \ref OV_ECTL_RATEMANAGE2_SET. - */ -#define OV_ECTL_RATEMANAGE2_GET 0x14 - -/** - * Set the current encoder bitrate management settings. - * - * Argument: struct ovectl_ratemanage2_arg * - * - * Used to set the current encoder bitrate management settings to the values - * listed in the ovectl_ratemanage2_arg. Passing a NULL pointer will disable - * bitrate management. -*/ -#define OV_ECTL_RATEMANAGE2_SET 0x15 - -/** - * Returns the current encoder hard-lowpass setting (kHz) in the double - * pointed to by arg. - * - * Argument: double * -*/ -#define OV_ECTL_LOWPASS_GET 0x20 - -/** - * Sets the encoder hard-lowpass to the value (kHz) pointed to by arg. Valid - * lowpass settings range from 2 to 99. - * - * Argument: double * -*/ -#define OV_ECTL_LOWPASS_SET 0x21 - -/** - * Returns the current encoder impulse block setting in the double pointed - * to by arg. - * - * Argument: double * -*/ -#define OV_ECTL_IBLOCK_GET 0x30 - -/** - * Sets the impulse block bias to the the value pointed to by arg. - * - * Argument: double * - * - * Valid range is -15.0 to 0.0 [default]. A negative impulse block bias will - * direct to encoder to use more bits when incoding short blocks that contain - * strong impulses, thus improving the accuracy of impulse encoding. - */ -#define OV_ECTL_IBLOCK_SET 0x31 - -/** - * Returns the current encoder coupling setting in the int pointed - * to by arg. - * - * Argument: int * -*/ -#define OV_ECTL_COUPLING_GET 0x40 - -/** - * Enables/disables channel coupling in multichannel encoding according to arg. - * - * Argument: int * - * - * Zero disables channel coupling for multichannel inputs, nonzer enables - * channel coupling. Setting has no effect on monophonic encoding or - * multichannel counts that do not offer coupling. At present, coupling is - * available for stereo and 5.1 encoding. - */ -#define OV_ECTL_COUPLING_SET 0x41 - - /* deprecated rate management supported only for compatibility */ - -/** - * Old interface to querying bitrate management settings. - * - * Deprecated after move to bit-reservoir style management in 1.1 rendered - * this interface partially obsolete. - - * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_GET instead. - * - * Argument: struct ovectl_ratemanage_arg * - */ -#define OV_ECTL_RATEMANAGE_GET 0x10 -/** - * Old interface to modifying bitrate management settings. - * - * deprecated after move to bit-reservoir style management in 1.1 rendered - * this interface partially obsolete. - * - * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. - * - * Argument: struct ovectl_ratemanage_arg * - */ -#define OV_ECTL_RATEMANAGE_SET 0x11 -/** - * Old interface to setting average-bitrate encoding mode. - * - * Deprecated after move to bit-reservoir style management in 1.1 rendered - * this interface partially obsolete. - * - * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. - * - * Argument: struct ovectl_ratemanage_arg * - */ -#define OV_ECTL_RATEMANAGE_AVG 0x12 -/** - * Old interface to setting bounded-bitrate encoding modes. - * - * deprecated after move to bit-reservoir style management in 1.1 rendered - * this interface partially obsolete. - * - * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. - * - * Argument: struct ovectl_ratemanage_arg * - */ -#define OV_ECTL_RATEMANAGE_HARD 0x13 - -/*@}*/ - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Engine/lib/libvorbis/include/vorbis/vorbisfile.h b/Engine/lib/libvorbis/include/vorbis/vorbisfile.h deleted file mode 100644 index 3d65393f5..000000000 --- a/Engine/lib/libvorbis/include/vorbis/vorbisfile.h +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: stdio-based convenience library for opening/seeking/decoding - - ********************************************************************/ - -#ifndef _OV_FILE_H_ -#define _OV_FILE_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include -#include "codec.h" - -/* The function prototypes for the callbacks are basically the same as for - * the stdio functions fread, fseek, fclose, ftell. - * The one difference is that the FILE * arguments have been replaced with - * a void * - this is to be used as a pointer to whatever internal data these - * functions might need. In the stdio case, it's just a FILE * cast to a void * - * - * If you use other functions, check the docs for these functions and return - * the right values. For seek_func(), you *MUST* return -1 if the stream is - * unseekable - */ -typedef struct { - size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); - int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); - int (*close_func) (void *datasource); - long (*tell_func) (void *datasource); -} ov_callbacks; - -#ifndef OV_EXCLUDE_STATIC_CALLBACKS - -/* a few sets of convenient callbacks, especially for use under - * Windows where ov_open_callbacks() should always be used instead of - * ov_open() to avoid problems with incompatible crt.o version linking - * issues. */ - -static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ - if(f==NULL)return(-1); - -#ifdef __MINGW32__ - return fseeko64(f,off,whence); -#elif defined (_WIN32) - return _fseeki64(f,off,whence); -#else - return fseek(f,off,whence); -#endif -} - -/* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as - * static data. That means that every file which includes this header - * will get its own copy of these structs whether it uses them or - * not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS. - * These static symbols are essential on platforms such as Windows on - * which several different versions of stdio support may be linked to - * by different DLLs, and we need to be certain we know which one - * we're using (the same one as the main application). - */ - -static ov_callbacks OV_CALLBACKS_DEFAULT = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, - (int (*)(void *)) fclose, - (long (*)(void *)) ftell -}; - -static ov_callbacks OV_CALLBACKS_NOCLOSE = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, - (int (*)(void *)) NULL, - (long (*)(void *)) ftell -}; - -static ov_callbacks OV_CALLBACKS_STREAMONLY = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) NULL, - (int (*)(void *)) fclose, - (long (*)(void *)) NULL -}; - -static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) NULL, - (int (*)(void *)) NULL, - (long (*)(void *)) NULL -}; - -#endif - -#define NOTOPEN 0 -#define PARTOPEN 1 -#define OPENED 2 -#define STREAMSET 3 -#define INITSET 4 - -typedef struct OggVorbis_File { - void *datasource; /* Pointer to a FILE *, etc. */ - int seekable; - ogg_int64_t offset; - ogg_int64_t end; - ogg_sync_state oy; - - /* If the FILE handle isn't seekable (eg, a pipe), only the current - stream appears */ - int links; - ogg_int64_t *offsets; - ogg_int64_t *dataoffsets; - long *serialnos; - ogg_int64_t *pcmlengths; /* overloaded to maintain binary - compatibility; x2 size, stores both - beginning and end values */ - vorbis_info *vi; - vorbis_comment *vc; - - /* Decoding working state local storage */ - ogg_int64_t pcm_offset; - int ready_state; - long current_serialno; - int current_link; - - double bittrack; - double samptrack; - - ogg_stream_state os; /* take physical pages, weld into a logical - stream of packets */ - vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ - vorbis_block vb; /* local working space for packet->PCM decode */ - - ov_callbacks callbacks; - -} OggVorbis_File; - - -extern int ov_clear(OggVorbis_File *vf); -extern int ov_fopen(const char *path,OggVorbis_File *vf); -extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); -extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, - const char *initial, long ibytes, ov_callbacks callbacks); - -extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); -extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, - const char *initial, long ibytes, ov_callbacks callbacks); -extern int ov_test_open(OggVorbis_File *vf); - -extern long ov_bitrate(OggVorbis_File *vf,int i); -extern long ov_bitrate_instant(OggVorbis_File *vf); -extern long ov_streams(OggVorbis_File *vf); -extern long ov_seekable(OggVorbis_File *vf); -extern long ov_serialnumber(OggVorbis_File *vf,int i); - -extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); -extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); -extern double ov_time_total(OggVorbis_File *vf,int i); - -extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_time_seek(OggVorbis_File *vf,double pos); -extern int ov_time_seek_page(OggVorbis_File *vf,double pos); - -extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_time_seek_lap(OggVorbis_File *vf,double pos); -extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos); - -extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); -extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); -extern double ov_time_tell(OggVorbis_File *vf); - -extern vorbis_info *ov_info(OggVorbis_File *vf,int link); -extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); - -extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples, - int *bitstream); -extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, - int bigendianp,int word,int sgned,int *bitstream, - void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param); -extern long ov_read(OggVorbis_File *vf,char *buffer,int length, - int bigendianp,int word,int sgned,int *bitstream); -extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2); - -extern int ov_halfrate(OggVorbis_File *vf,int flag); -extern int ov_halfrate_p(OggVorbis_File *vf); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif - diff --git a/Engine/lib/libvorbis/lib/CMakeLists.txt b/Engine/lib/libvorbis/lib/CMakeLists.txt deleted file mode 100644 index 7cd68e509..000000000 --- a/Engine/lib/libvorbis/lib/CMakeLists.txt +++ /dev/null @@ -1,163 +0,0 @@ -set(VORBIS_PUBLIC_HEADERS - ../include/vorbis/codec.h - ../include/vorbis/vorbisenc.h - ../include/vorbis/vorbisfile.h -) - -set(VORBIS_HEADERS - envelope.h - lpc.h - lsp.h - codebook.h - misc.h - psy.h - masking.h - os.h - mdct.h - smallft.h - highlevel.h - registry.h - scales.h - window.h - lookup.h - lookup_data.h - codec_internal.h - backends.h - bitrate.h -) - -set(VORBIS_SOURCES - mdct.c - smallft.c - block.c - envelope.c - window.c - lsp.c - lpc.c - analysis.c - synthesis.c - psy.c - info.c - floor1.c - floor0.c - res0.c - mapping0.c - registry.c - codebook.c - sharedbook.c - lookup.c - bitrate.c -) - -set(VORBISFILE_SOURCES - vorbisfile.c -) - -set(VORBISENC_SOURCES - vorbisenc.c -) - -if(WIN32) - list(APPEND VORBIS_SOURCES vorbisenc.c) -endif() - -if(WIN32) - list(APPEND VORBIS_SOURCES ../win32/vorbis.def) - list(APPEND VORBISENC_SOURCES ../win32/vorbisenc.def) - list(APPEND VORBISFILE_SOURCES ../win32/vorbisfile.def) -endif() - -if(MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) -endif() - -if (NOT BUILD_FRAMEWORK) - add_library(vorbis ${VORBIS_HEADERS} ${VORBIS_SOURCES}) - add_library(vorbisenc ${VORBISENC_SOURCES}) - add_library(vorbisfile ${VORBISFILE_SOURCES}) - - get_version_info(VORBIS_VERSION_INFO "V_LIB_CURRENT" "V_LIB_AGE" "V_LIB_REVISION") - set_target_properties(vorbis PROPERTIES SOVERSION ${VORBIS_VERSION_INFO}) - get_version_info(VORBISENC_VERSION_INFO "VE_LIB_CURRENT" "VE_LIB_AGE" "VE_LIB_REVISION") - set_target_properties(vorbisenc PROPERTIES SOVERSION ${VORBISENC_VERSION_INFO}) - get_version_info(VORBISFILE_VERSION_INFO "VF_LIB_CURRENT" "VF_LIB_AGE" "VF_LIB_REVISION") - set_target_properties(vorbisfile PROPERTIES SOVERSION ${VORBISFILE_VERSION_INFO}) - - target_include_directories(vorbis - PUBLIC - $ - $ - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ) - target_include_directories(vorbisenc - PUBLIC - $ - $ - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ) - target_include_directories(vorbisfile - PUBLIC - $ - $ - ) - - target_link_libraries(vorbis - PUBLIC Ogg::ogg - PRIVATE $<$:m> - ) - target_link_libraries(vorbisenc PUBLIC vorbis) - target_link_libraries(vorbisfile PUBLIC vorbis) - - install(FILES ${VORBIS_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/vorbis) - - install(TARGETS vorbis vorbisenc vorbisfile - EXPORT VorbisTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} - ) - - if(INSTALL_CMAKE_PACKAGE_MODULE) - - set(CMAKE_INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Vorbis) - - install(EXPORT VorbisTargets - DESTINATION ${CMAKE_INSTALL_CONFIGDIR} - NAMESPACE Vorbis:: - ) - - - include(CMakePackageConfigHelpers) - - configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/VorbisConfig.cmake.in ${PROJECT_BINARY_DIR}/VorbisConfig.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_CONFIGDIR} - ) - - write_basic_package_version_file(${PROJECT_BINARY_DIR}/VorbisConfigVersion.cmake - COMPATIBILITY SameMajorVersion - ) - - install(FILES ${PROJECT_BINARY_DIR}/VorbisConfig.cmake ${PROJECT_BINARY_DIR}/VorbisConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_CONFIGDIR} - ) - - endif() -else() - add_library(vorbis ${VORBIS_PUBLIC_HEADERS} ${VORBIS_HEADERS} ${VORBIS_SOURCES} ${VORBISFILE_SOURCES} ${VORBISENC_SOURCES}) - set_target_properties(vorbis PROPERTIES - FRAMEWORK TRUE - FRAMEWORK_VERSION ${PROJECT_VERSION} - MACOSX_FRAMEWORK_IDENTIFIER org.xiph.vorbis - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} - MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION} - XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" - PUBLIC_HEADER "${VORBIS_PUBLIC_HEADERS}" - OUTPUT_NAME Vorbis - ) - target_link_libraries(vorbis ${OGG_LIBRARIES}) -endif() diff --git a/Engine/lib/libvorbis/lib/Makefile.am b/Engine/lib/libvorbis/lib/Makefile.am deleted file mode 100644 index e22895eab..000000000 --- a/Engine/lib/libvorbis/lib/Makefile.am +++ /dev/null @@ -1,63 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = modes books - -AM_CPPFLAGS = -I$(top_srcdir)/include @OGG_CFLAGS@ - -lib_LTLIBRARIES = libvorbis.la libvorbisfile.la libvorbisenc.la - -libvorbis_la_SOURCES = mdct.c smallft.c block.c envelope.c window.c lsp.c \ - lpc.c analysis.c synthesis.c psy.c info.c \ - floor1.c floor0.c\ - res0.c mapping0.c registry.c codebook.c sharedbook.c\ - lookup.c bitrate.c\ - envelope.h lpc.h lsp.h codebook.h misc.h psy.h\ - masking.h os.h mdct.h smallft.h highlevel.h\ - registry.h scales.h window.h lookup.h lookup_data.h\ - codec_internal.h backends.h bitrate.h -libvorbis_la_LDFLAGS = -no-undefined -version-info @V_LIB_CURRENT@:@V_LIB_REVISION@:@V_LIB_AGE@ -libvorbis_la_LIBADD = @VORBIS_LIBS@ @OGG_LIBS@ - -libvorbisfile_la_SOURCES = vorbisfile.c -libvorbisfile_la_LDFLAGS = -no-undefined -version-info @VF_LIB_CURRENT@:@VF_LIB_REVISION@:@VF_LIB_AGE@ -libvorbisfile_la_LIBADD = libvorbis.la @OGG_LIBS@ - -libvorbisenc_la_SOURCES = vorbisenc.c -libvorbisenc_la_LDFLAGS = -no-undefined -version-info @VE_LIB_CURRENT@:@VE_LIB_REVISION@:@VE_LIB_AGE@ -libvorbisenc_la_LIBADD = libvorbis.la @OGG_LIBS@ - -EXTRA_PROGRAMS = barkmel tone psytune -CLEANFILES = $(EXTRA_PROGRAMS) - -barkmel_SOURCES = barkmel.c -tone_SOURCES = tone.c -psytune_SOURCES = psytune.c -psytune_LDFLAGS = -static -psytune_LDADD = libvorbis.la - -EXTRA_DIST = lookups.pl CMakeLists.txt - -# build and run the self tests on 'make check' - -#vorbis_selftests = test_codebook test_sharedbook -vorbis_selftests = test_sharedbook - -noinst_PROGRAMS = $(vorbis_selftests) - -check: $(noinst_PROGRAMS) - ./test_sharedbook$(EXEEXT) - -#test_codebook_SOURCES = codebook.c -#test_codebook_CFLAGS = -D_V_SELFTEST - -test_sharedbook_SOURCES = sharedbook.c -test_sharedbook_CFLAGS = -D_V_SELFTEST -test_sharedbook_LDADD = @VORBIS_LIBS@ - -# recurse for alternate targets - -debug: - $(MAKE) all CFLAGS="@DEBUG@" - -profile: - $(MAKE) all CFLAGS="@PROFILE@" diff --git a/Engine/lib/libvorbis/lib/analysis.c b/Engine/lib/libvorbis/lib/analysis.c deleted file mode 100644 index 14919737e..000000000 --- a/Engine/lib/libvorbis/lib/analysis.c +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: single-block PCM analysis mode dispatch - - ********************************************************************/ - -#include -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "registry.h" -#include "scales.h" -#include "os.h" -#include "misc.h" - -/* decides between modes, dispatches to the appropriate mapping. */ -int vorbis_analysis(vorbis_block *vb, ogg_packet *op){ - int ret,i; - vorbis_block_internal *vbi=vb->internal; - - vb->glue_bits=0; - vb->time_bits=0; - vb->floor_bits=0; - vb->res_bits=0; - - /* first things first. Make sure encode is ready */ - for(i=0;ipacketblob[i]); - - /* we only have one mapping type (0), and we let the mapping code - itself figure out what soft mode to use. This allows easier - bitrate management */ - - if((ret=_mapping_P[0]->forward(vb))) - return(ret); - - if(op){ - if(vorbis_bitrate_managed(vb)) - /* The app is using a bitmanaged mode... but not using the - bitrate management interface. */ - return(OV_EINVAL); - - op->packet=oggpack_get_buffer(&vb->opb); - op->bytes=oggpack_bytes(&vb->opb); - op->b_o_s=0; - op->e_o_s=vb->eofflag; - op->granulepos=vb->granulepos; - op->packetno=vb->sequence; /* for sake of completeness */ - } - return(0); -} - -#ifdef ANALYSIS -int analysis_noisy=1; - -/* there was no great place to put this.... */ -void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){ - int j; - FILE *of; - char buffer[80]; - - sprintf(buffer,"%s_%d.m",base,i); - of=fopen(buffer,"w"); - - if(!of)perror("failed to open data dump file"); - - for(j=0;j -#include "scales.h" -int main(){ - int i; - double rate; - for(i=64;i<32000;i*=2){ - rate=48000.f; - fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n", - rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2)); - - rate=44100.f; - fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n", - rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2)); - - rate=32000.f; - fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n", - rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2)); - - rate=22050.f; - fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n", - rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2)); - - rate=16000.f; - fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n", - rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2)); - - rate=11025.f; - fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n", - rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2)); - - rate=8000.f; - fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n\n", - rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2)); - - - } - { - float i; - int j; - for(i=0.,j=0;i<28;i+=1,j++){ - fprintf(stderr,"(%d) bark=%f %gHz (%d of 128)\n", - j,i,fromBARK(i),(int)(fromBARK(i)/22050.*128.)); - } - } - return(0); -} - diff --git a/Engine/lib/libvorbis/lib/bitrate.c b/Engine/lib/libvorbis/lib/bitrate.c deleted file mode 100644 index 132553cbe..000000000 --- a/Engine/lib/libvorbis/lib/bitrate.c +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: bitrate tracking and management - - ********************************************************************/ - -#include -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "os.h" -#include "misc.h" -#include "bitrate.h" - -/* compute bitrate tracking setup */ -void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bm){ - codec_setup_info *ci=vi->codec_setup; - bitrate_manager_info *bi=&ci->bi; - - memset(bm,0,sizeof(*bm)); - - if(bi && (bi->reservoir_bits>0)){ - long ratesamples=vi->rate; - int halfsamples=ci->blocksizes[0]>>1; - - bm->short_per_long=ci->blocksizes[1]/ci->blocksizes[0]; - bm->managed=1; - - bm->avg_bitsper= rint(1.*bi->avg_rate*halfsamples/ratesamples); - bm->min_bitsper= rint(1.*bi->min_rate*halfsamples/ratesamples); - bm->max_bitsper= rint(1.*bi->max_rate*halfsamples/ratesamples); - - bm->avgfloat=PACKETBLOBS/2; - - /* not a necessary fix, but one that leads to a more balanced - typical initialization */ - { - long desired_fill=bi->reservoir_bits*bi->reservoir_bias; - bm->minmax_reservoir=desired_fill; - bm->avg_reservoir=desired_fill; - } - - } -} - -void vorbis_bitrate_clear(bitrate_manager_state *bm){ - memset(bm,0,sizeof(*bm)); - return; -} - -int vorbis_bitrate_managed(vorbis_block *vb){ - vorbis_dsp_state *vd=vb->vd; - private_state *b=vd->backend_state; - bitrate_manager_state *bm=&b->bms; - - if(bm && bm->managed)return(1); - return(0); -} - -/* finish taking in the block we just processed */ -int vorbis_bitrate_addblock(vorbis_block *vb){ - vorbis_block_internal *vbi=vb->internal; - vorbis_dsp_state *vd=vb->vd; - private_state *b=vd->backend_state; - bitrate_manager_state *bm=&b->bms; - vorbis_info *vi=vd->vi; - codec_setup_info *ci=vi->codec_setup; - bitrate_manager_info *bi=&ci->bi; - - int choice=rint(bm->avgfloat); - long this_bits=oggpack_bytes(vbi->packetblob[choice])*8; - long min_target_bits=(vb->W?bm->min_bitsper*bm->short_per_long:bm->min_bitsper); - long max_target_bits=(vb->W?bm->max_bitsper*bm->short_per_long:bm->max_bitsper); - int samples=ci->blocksizes[vb->W]>>1; - long desired_fill=bi->reservoir_bits*bi->reservoir_bias; - if(!bm->managed){ - /* not a bitrate managed stream, but for API simplicity, we'll - buffer the packet to keep the code path clean */ - - if(bm->vb)return(-1); /* one has been submitted without - being claimed */ - bm->vb=vb; - return(0); - } - - bm->vb=vb; - - /* look ahead for avg floater */ - if(bm->avg_bitsper>0){ - double slew=0.; - long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper); - double slewlimit= 15./bi->slew_damp; - - /* choosing a new floater: - if we're over target, we slew down - if we're under target, we slew up - - choose slew as follows: look through packetblobs of this frame - and set slew as the first in the appropriate direction that - gives us the slew we want. This may mean no slew if delta is - already favorable. - - Then limit slew to slew max */ - - if(bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){ - while(choice>0 && this_bits>avg_target_bits && - bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){ - choice--; - this_bits=oggpack_bytes(vbi->packetblob[choice])*8; - } - }else if(bm->avg_reservoir+(this_bits-avg_target_bits)avg_reservoir+(this_bits-avg_target_bits)packetblob[choice])*8; - } - } - - slew=rint(choice-bm->avgfloat)/samples*vi->rate; - if(slew<-slewlimit)slew=-slewlimit; - if(slew>slewlimit)slew=slewlimit; - choice=rint(bm->avgfloat+= slew/vi->rate*samples); - this_bits=oggpack_bytes(vbi->packetblob[choice])*8; - } - - - - /* enforce min(if used) on the current floater (if used) */ - if(bm->min_bitsper>0){ - /* do we need to force the bitrate up? */ - if(this_bitsminmax_reservoir-(min_target_bits-this_bits)<0){ - choice++; - if(choice>=PACKETBLOBS)break; - this_bits=oggpack_bytes(vbi->packetblob[choice])*8; - } - } - } - - /* enforce max (if used) on the current floater (if used) */ - if(bm->max_bitsper>0){ - /* do we need to force the bitrate down? */ - if(this_bits>max_target_bits){ - while(bm->minmax_reservoir+(this_bits-max_target_bits)>bi->reservoir_bits){ - choice--; - if(choice<0)break; - this_bits=oggpack_bytes(vbi->packetblob[choice])*8; - } - } - } - - /* Choice of packetblobs now made based on floater, and min/max - requirements. Now boundary check extreme choices */ - - if(choice<0){ - /* choosing a smaller packetblob is insufficient to trim bitrate. - frame will need to be truncated */ - long maxsize=(max_target_bits+(bi->reservoir_bits-bm->minmax_reservoir))/8; - bm->choice=choice=0; - - if(oggpack_bytes(vbi->packetblob[choice])>maxsize){ - - oggpack_writetrunc(vbi->packetblob[choice],maxsize*8); - this_bits=oggpack_bytes(vbi->packetblob[choice])*8; - } - }else{ - long minsize=(min_target_bits-bm->minmax_reservoir+7)/8; - if(choice>=PACKETBLOBS) - choice=PACKETBLOBS-1; - - bm->choice=choice; - - /* prop up bitrate according to demand. pad this frame out with zeroes */ - minsize-=oggpack_bytes(vbi->packetblob[choice]); - while(minsize-->0)oggpack_write(vbi->packetblob[choice],0,8); - this_bits=oggpack_bytes(vbi->packetblob[choice])*8; - - } - - /* now we have the final packet and the final packet size. Update statistics */ - /* min and max reservoir */ - if(bm->min_bitsper>0 || bm->max_bitsper>0){ - - if(max_target_bits>0 && this_bits>max_target_bits){ - bm->minmax_reservoir+=(this_bits-max_target_bits); - }else if(min_target_bits>0 && this_bitsminmax_reservoir+=(this_bits-min_target_bits); - }else{ - /* inbetween; we want to take reservoir toward but not past desired_fill */ - if(bm->minmax_reservoir>desired_fill){ - if(max_target_bits>0){ /* logical bulletproofing against initialization state */ - bm->minmax_reservoir+=(this_bits-max_target_bits); - if(bm->minmax_reservoirminmax_reservoir=desired_fill; - }else{ - bm->minmax_reservoir=desired_fill; - } - }else{ - if(min_target_bits>0){ /* logical bulletproofing against initialization state */ - bm->minmax_reservoir+=(this_bits-min_target_bits); - if(bm->minmax_reservoir>desired_fill)bm->minmax_reservoir=desired_fill; - }else{ - bm->minmax_reservoir=desired_fill; - } - } - } - } - - /* avg reservoir */ - if(bm->avg_bitsper>0){ - long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper); - bm->avg_reservoir+=this_bits-avg_target_bits; - } - - return(0); -} - -int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,ogg_packet *op){ - private_state *b=vd->backend_state; - bitrate_manager_state *bm=&b->bms; - vorbis_block *vb=bm->vb; - int choice=PACKETBLOBS/2; - if(!vb)return 0; - - if(op){ - vorbis_block_internal *vbi=vb->internal; - - if(vorbis_bitrate_managed(vb)) - choice=bm->choice; - - op->packet=oggpack_get_buffer(vbi->packetblob[choice]); - op->bytes=oggpack_bytes(vbi->packetblob[choice]); - op->b_o_s=0; - op->e_o_s=vb->eofflag; - op->granulepos=vb->granulepos; - op->packetno=vb->sequence; /* for sake of completeness */ - } - - bm->vb=0; - return(1); -} diff --git a/Engine/lib/libvorbis/lib/bitrate.h b/Engine/lib/libvorbis/lib/bitrate.h deleted file mode 100644 index 48fa15059..000000000 --- a/Engine/lib/libvorbis/lib/bitrate.h +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: bitrate tracking and management - - ********************************************************************/ - -#ifndef _V_BITRATE_H_ -#define _V_BITRATE_H_ - -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "os.h" - -/* encode side bitrate tracking */ -typedef struct bitrate_manager_state { - int managed; - - long avg_reservoir; - long minmax_reservoir; - long avg_bitsper; - long min_bitsper; - long max_bitsper; - - long short_per_long; - double avgfloat; - - vorbis_block *vb; - int choice; -} bitrate_manager_state; - -typedef struct bitrate_manager_info{ - long avg_rate; - long min_rate; - long max_rate; - long reservoir_bits; - double reservoir_bias; - - double slew_damp; - -} bitrate_manager_info; - -extern void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bs); -extern void vorbis_bitrate_clear(bitrate_manager_state *bs); -extern int vorbis_bitrate_managed(vorbis_block *vb); -extern int vorbis_bitrate_addblock(vorbis_block *vb); -extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, ogg_packet *op); - -#endif diff --git a/Engine/lib/libvorbis/lib/block.c b/Engine/lib/libvorbis/lib/block.c deleted file mode 100644 index 6a50da084..000000000 --- a/Engine/lib/libvorbis/lib/block.c +++ /dev/null @@ -1,1046 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: PCM data vector blocking, windowing and dis/reassembly - - Handle windowing, overlap-add, etc of the PCM vectors. This is made - more amusing by Vorbis' current two allowed block sizes. - - ********************************************************************/ - -#include -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" - -#include "window.h" -#include "mdct.h" -#include "lpc.h" -#include "registry.h" -#include "misc.h" - -/* pcm accumulator examples (not exhaustive): - - <-------------- lW ----------------> - <--------------- W ----------------> -: .....|..... _______________ | -: .''' | '''_--- | |\ | -:.....''' |_____--- '''......| | \_______| -:.................|__________________|_______|__|______| - |<------ Sl ------>| > Sr < |endW - |beginSl |endSl | |endSr - |beginW |endlW |beginSr - - - |< lW >| - <--------------- W ----------------> - | | .. ______________ | - | | ' `/ | ---_ | - |___.'___/`. | ---_____| - |_______|__|_______|_________________| - | >|Sl|< |<------ Sr ----->|endW - | | |endSl |beginSr |endSr - |beginW | |endlW - mult[0] |beginSl mult[n] - - <-------------- lW -----------------> - |<--W-->| -: .............. ___ | | -: .''' |`/ \ | | -:.....''' |/`....\|...| -:.........................|___|___|___| - |Sl |Sr |endW - | | |endSr - | |beginSr - | |endSl - |beginSl - |beginW -*/ - -/* block abstraction setup *********************************************/ - -#ifndef WORD_ALIGN -#define WORD_ALIGN 8 -#endif - -int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){ - int i; - memset(vb,0,sizeof(*vb)); - vb->vd=v; - vb->localalloc=0; - vb->localstore=NULL; - if(v->analysisp){ - vorbis_block_internal *vbi= - vb->internal=_ogg_calloc(1,sizeof(vorbis_block_internal)); - vbi->ampmax=-9999; - - for(i=0;ipacketblob[i]=&vb->opb; - }else{ - vbi->packetblob[i]= - _ogg_calloc(1,sizeof(oggpack_buffer)); - } - oggpack_writeinit(vbi->packetblob[i]); - } - } - - return(0); -} - -void *_vorbis_block_alloc(vorbis_block *vb,long bytes){ - bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1); - if(bytes+vb->localtop>vb->localalloc){ - /* can't just _ogg_realloc... there are outstanding pointers */ - if(vb->localstore){ - struct alloc_chain *link=_ogg_malloc(sizeof(*link)); - vb->totaluse+=vb->localtop; - link->next=vb->reap; - link->ptr=vb->localstore; - vb->reap=link; - } - /* highly conservative */ - vb->localalloc=bytes; - vb->localstore=_ogg_malloc(vb->localalloc); - vb->localtop=0; - } - { - void *ret=(void *)(((char *)vb->localstore)+vb->localtop); - vb->localtop+=bytes; - return ret; - } -} - -/* reap the chain, pull the ripcord */ -void _vorbis_block_ripcord(vorbis_block *vb){ - /* reap the chain */ - struct alloc_chain *reap=vb->reap; - while(reap){ - struct alloc_chain *next=reap->next; - _ogg_free(reap->ptr); - memset(reap,0,sizeof(*reap)); - _ogg_free(reap); - reap=next; - } - /* consolidate storage */ - if(vb->totaluse){ - vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc); - vb->localalloc+=vb->totaluse; - vb->totaluse=0; - } - - /* pull the ripcord */ - vb->localtop=0; - vb->reap=NULL; -} - -int vorbis_block_clear(vorbis_block *vb){ - int i; - vorbis_block_internal *vbi=vb->internal; - - _vorbis_block_ripcord(vb); - if(vb->localstore)_ogg_free(vb->localstore); - - if(vbi){ - for(i=0;ipacketblob[i]); - if(i!=PACKETBLOBS/2)_ogg_free(vbi->packetblob[i]); - } - _ogg_free(vbi); - } - memset(vb,0,sizeof(*vb)); - return(0); -} - -/* Analysis side code, but directly related to blocking. Thus it's - here and not in analysis.c (which is for analysis transforms only). - The init is here because some of it is shared */ - -static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ - int i; - codec_setup_info *ci=vi->codec_setup; - private_state *b=NULL; - int hs; - - if(ci==NULL|| - ci->modes<=0|| - ci->blocksizes[0]<64|| - ci->blocksizes[1]blocksizes[0]){ - return 1; - } - hs=ci->halfrate_flag; - - memset(v,0,sizeof(*v)); - b=v->backend_state=_ogg_calloc(1,sizeof(*b)); - - v->vi=vi; - b->modebits=ov_ilog(ci->modes-1); - - b->transform[0]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[0])); - b->transform[1]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[1])); - - /* MDCT is tranform 0 */ - - b->transform[0][0]=_ogg_calloc(1,sizeof(mdct_lookup)); - b->transform[1][0]=_ogg_calloc(1,sizeof(mdct_lookup)); - mdct_init(b->transform[0][0],ci->blocksizes[0]>>hs); - mdct_init(b->transform[1][0],ci->blocksizes[1]>>hs); - - /* Vorbis I uses only window type 0 */ - /* note that the correct computation below is technically: - b->window[0]=ov_ilog(ci->blocksizes[0]-1)-6; - b->window[1]=ov_ilog(ci->blocksizes[1]-1)-6; - but since blocksizes are always powers of two, - the below is equivalent. - */ - b->window[0]=ov_ilog(ci->blocksizes[0])-7; - b->window[1]=ov_ilog(ci->blocksizes[1])-7; - - if(encp){ /* encode/decode differ here */ - - /* analysis always needs an fft */ - drft_init(&b->fft_look[0],ci->blocksizes[0]); - drft_init(&b->fft_look[1],ci->blocksizes[1]); - - /* finish the codebooks */ - if(!ci->fullbooks){ - ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); - for(i=0;ibooks;i++) - vorbis_book_init_encode(ci->fullbooks+i,ci->book_param[i]); - } - - b->psy=_ogg_calloc(ci->psys,sizeof(*b->psy)); - for(i=0;ipsys;i++){ - _vp_psy_init(b->psy+i, - ci->psy_param[i], - &ci->psy_g_param, - ci->blocksizes[ci->psy_param[i]->blockflag]/2, - vi->rate); - } - - v->analysisp=1; - }else{ - /* finish the codebooks */ - if(!ci->fullbooks){ - ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); - for(i=0;ibooks;i++){ - if(ci->book_param[i]==NULL) - goto abort_books; - if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i])) - goto abort_books; - /* decode codebooks are now standalone after init */ - vorbis_staticbook_destroy(ci->book_param[i]); - ci->book_param[i]=NULL; - } - } - } - - /* initialize the storage vectors. blocksize[1] is small for encode, - but the correct size for decode */ - v->pcm_storage=ci->blocksizes[1]; - v->pcm=_ogg_malloc(vi->channels*sizeof(*v->pcm)); - v->pcmret=_ogg_malloc(vi->channels*sizeof(*v->pcmret)); - { - int i; - for(i=0;ichannels;i++) - v->pcm[i]=_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); - } - - /* all 1 (large block) or 0 (small block) */ - /* explicitly set for the sake of clarity */ - v->lW=0; /* previous window size */ - v->W=0; /* current window size */ - - /* all vector indexes */ - v->centerW=ci->blocksizes[1]/2; - - v->pcm_current=v->centerW; - - /* initialize all the backend lookups */ - b->flr=_ogg_calloc(ci->floors,sizeof(*b->flr)); - b->residue=_ogg_calloc(ci->residues,sizeof(*b->residue)); - - for(i=0;ifloors;i++) - b->flr[i]=_floor_P[ci->floor_type[i]]-> - look(v,ci->floor_param[i]); - - for(i=0;iresidues;i++) - b->residue[i]=_residue_P[ci->residue_type[i]]-> - look(v,ci->residue_param[i]); - - return 0; - abort_books: - for(i=0;ibooks;i++){ - if(ci->book_param[i]!=NULL){ - vorbis_staticbook_destroy(ci->book_param[i]); - ci->book_param[i]=NULL; - } - } - vorbis_dsp_clear(v); - return -1; -} - -/* arbitrary settings and spec-mandated numbers get filled in here */ -int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi){ - private_state *b=NULL; - - if(_vds_shared_init(v,vi,1))return 1; - b=v->backend_state; - b->psy_g_look=_vp_global_look(vi); - - /* Initialize the envelope state storage */ - b->ve=_ogg_calloc(1,sizeof(*b->ve)); - _ve_envelope_init(b->ve,vi); - - vorbis_bitrate_init(vi,&b->bms); - - /* compressed audio packets start after the headers - with sequence number 3 */ - v->sequence=3; - - return(0); -} - -void vorbis_dsp_clear(vorbis_dsp_state *v){ - int i; - if(v){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=(vi?vi->codec_setup:NULL); - private_state *b=v->backend_state; - - if(b){ - - if(b->ve){ - _ve_envelope_clear(b->ve); - _ogg_free(b->ve); - } - - if(b->transform[0]){ - mdct_clear(b->transform[0][0]); - _ogg_free(b->transform[0][0]); - _ogg_free(b->transform[0]); - } - if(b->transform[1]){ - mdct_clear(b->transform[1][0]); - _ogg_free(b->transform[1][0]); - _ogg_free(b->transform[1]); - } - - if(b->flr){ - if(ci) - for(i=0;ifloors;i++) - _floor_P[ci->floor_type[i]]-> - free_look(b->flr[i]); - _ogg_free(b->flr); - } - if(b->residue){ - if(ci) - for(i=0;iresidues;i++) - _residue_P[ci->residue_type[i]]-> - free_look(b->residue[i]); - _ogg_free(b->residue); - } - if(b->psy){ - if(ci) - for(i=0;ipsys;i++) - _vp_psy_clear(b->psy+i); - _ogg_free(b->psy); - } - - if(b->psy_g_look)_vp_global_free(b->psy_g_look); - vorbis_bitrate_clear(&b->bms); - - drft_clear(&b->fft_look[0]); - drft_clear(&b->fft_look[1]); - - } - - if(v->pcm){ - if(vi) - for(i=0;ichannels;i++) - if(v->pcm[i])_ogg_free(v->pcm[i]); - _ogg_free(v->pcm); - if(v->pcmret)_ogg_free(v->pcmret); - } - - if(b){ - /* free header, header1, header2 */ - if(b->header)_ogg_free(b->header); - if(b->header1)_ogg_free(b->header1); - if(b->header2)_ogg_free(b->header2); - _ogg_free(b); - } - - memset(v,0,sizeof(*v)); - } -} - -float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){ - int i; - vorbis_info *vi=v->vi; - private_state *b=v->backend_state; - - /* free header, header1, header2 */ - if(b->header)_ogg_free(b->header);b->header=NULL; - if(b->header1)_ogg_free(b->header1);b->header1=NULL; - if(b->header2)_ogg_free(b->header2);b->header2=NULL; - - /* Do we have enough storage space for the requested buffer? If not, - expand the PCM (and envelope) storage */ - - if(v->pcm_current+vals>=v->pcm_storage){ - v->pcm_storage=v->pcm_current+vals*2; - - for(i=0;ichannels;i++){ - v->pcm[i]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(*v->pcm[i])); - } - } - - for(i=0;ichannels;i++) - v->pcmret[i]=v->pcm[i]+v->pcm_current; - - return(v->pcmret); -} - -static void _preextrapolate_helper(vorbis_dsp_state *v){ - int i; - int order=16; - float *lpc=alloca(order*sizeof(*lpc)); - float *work=alloca(v->pcm_current*sizeof(*work)); - long j; - v->preextrapolate=1; - - if(v->pcm_current-v->centerW>order*2){ /* safety */ - for(i=0;ivi->channels;i++){ - /* need to run the extrapolation in reverse! */ - for(j=0;jpcm_current;j++) - work[j]=v->pcm[i][v->pcm_current-j-1]; - - /* prime as above */ - vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order); - -#if 0 - if(v->vi->channels==2){ - if(i==0) - _analysis_output("predataL",0,work,v->pcm_current-v->centerW,0,0,0); - else - _analysis_output("predataR",0,work,v->pcm_current-v->centerW,0,0,0); - }else{ - _analysis_output("predata",0,work,v->pcm_current-v->centerW,0,0,0); - } -#endif - - /* run the predictor filter */ - vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order, - order, - work+v->pcm_current-v->centerW, - v->centerW); - - for(j=0;jpcm_current;j++) - v->pcm[i][v->pcm_current-j-1]=work[j]; - - } - } -} - - -/* call with val<=0 to set eof */ - -int vorbis_analysis_wrote(vorbis_dsp_state *v, int vals){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=vi->codec_setup; - - if(vals<=0){ - int order=32; - int i; - float *lpc=alloca(order*sizeof(*lpc)); - - /* if it wasn't done earlier (very short sample) */ - if(!v->preextrapolate) - _preextrapolate_helper(v); - - /* We're encoding the end of the stream. Just make sure we have - [at least] a few full blocks of zeroes at the end. */ - /* actually, we don't want zeroes; that could drop a large - amplitude off a cliff, creating spread spectrum noise that will - suck to encode. Extrapolate for the sake of cleanliness. */ - - vorbis_analysis_buffer(v,ci->blocksizes[1]*3); - v->eofflag=v->pcm_current; - v->pcm_current+=ci->blocksizes[1]*3; - - for(i=0;ichannels;i++){ - if(v->eofflag>order*2){ - /* extrapolate with LPC to fill in */ - long n; - - /* make a predictor filter */ - n=v->eofflag; - if(n>ci->blocksizes[1])n=ci->blocksizes[1]; - vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order); - - /* run the predictor filter */ - vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order, - v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag); - }else{ - /* not enough data to extrapolate (unlikely to happen due to - guarding the overlap, but bulletproof in case that - assumtion goes away). zeroes will do. */ - memset(v->pcm[i]+v->eofflag,0, - (v->pcm_current-v->eofflag)*sizeof(*v->pcm[i])); - - } - } - }else{ - - if(v->pcm_current+vals>v->pcm_storage) - return(OV_EINVAL); - - v->pcm_current+=vals; - - /* we may want to reverse extrapolate the beginning of a stream - too... in case we're beginning on a cliff! */ - /* clumsy, but simple. It only runs once, so simple is good. */ - if(!v->preextrapolate && v->pcm_current-v->centerW>ci->blocksizes[1]) - _preextrapolate_helper(v); - - } - return(0); -} - -/* do the deltas, envelope shaping, pre-echo and determine the size of - the next block on which to continue analysis */ -int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){ - int i; - vorbis_info *vi=v->vi; - codec_setup_info *ci=vi->codec_setup; - private_state *b=v->backend_state; - vorbis_look_psy_global *g=b->psy_g_look; - long beginW=v->centerW-ci->blocksizes[v->W]/2,centerNext; - vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal; - - /* check to see if we're started... */ - if(!v->preextrapolate)return(0); - - /* check to see if we're done... */ - if(v->eofflag==-1)return(0); - - /* By our invariant, we have lW, W and centerW set. Search for - the next boundary so we can determine nW (the next window size) - which lets us compute the shape of the current block's window */ - - /* we do an envelope search even on a single blocksize; we may still - be throwing more bits at impulses, and envelope search handles - marking impulses too. */ - { - long bp=_ve_envelope_search(v); - if(bp==-1){ - - if(v->eofflag==0)return(0); /* not enough data currently to search for a - full long block */ - v->nW=0; - }else{ - - if(ci->blocksizes[0]==ci->blocksizes[1]) - v->nW=0; - else - v->nW=bp; - } - } - - centerNext=v->centerW+ci->blocksizes[v->W]/4+ci->blocksizes[v->nW]/4; - - { - /* center of next block + next block maximum right side. */ - - long blockbound=centerNext+ci->blocksizes[v->nW]/2; - if(v->pcm_currentlW=v->lW; - vb->W=v->W; - vb->nW=v->nW; - - if(v->W){ - if(!v->lW || !v->nW){ - vbi->blocktype=BLOCKTYPE_TRANSITION; - /*fprintf(stderr,"-");*/ - }else{ - vbi->blocktype=BLOCKTYPE_LONG; - /*fprintf(stderr,"_");*/ - } - }else{ - if(_ve_envelope_mark(v)){ - vbi->blocktype=BLOCKTYPE_IMPULSE; - /*fprintf(stderr,"|");*/ - - }else{ - vbi->blocktype=BLOCKTYPE_PADDING; - /*fprintf(stderr,".");*/ - - } - } - - vb->vd=v; - vb->sequence=v->sequence++; - vb->granulepos=v->granulepos; - vb->pcmend=ci->blocksizes[v->W]; - - /* copy the vectors; this uses the local storage in vb */ - - /* this tracks 'strongest peak' for later psychoacoustics */ - /* moved to the global psy state; clean this mess up */ - if(vbi->ampmax>g->ampmax)g->ampmax=vbi->ampmax; - g->ampmax=_vp_ampmax_decay(g->ampmax,v); - vbi->ampmax=g->ampmax; - - vb->pcm=_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); - vbi->pcmdelay=_vorbis_block_alloc(vb,sizeof(*vbi->pcmdelay)*vi->channels); - for(i=0;ichannels;i++){ - vbi->pcmdelay[i]= - _vorbis_block_alloc(vb,(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i])); - memcpy(vbi->pcmdelay[i],v->pcm[i],(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i])); - vb->pcm[i]=vbi->pcmdelay[i]+beginW; - - /* before we added the delay - vb->pcm[i]=_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); - memcpy(vb->pcm[i],v->pcm[i]+beginW,ci->blocksizes[v->W]*sizeof(*vb->pcm[i])); - */ - - } - - /* handle eof detection: eof==0 means that we've not yet received EOF - eof>0 marks the last 'real' sample in pcm[] - eof<0 'no more to do'; doesn't get here */ - - if(v->eofflag){ - if(v->centerW>=v->eofflag){ - v->eofflag=-1; - vb->eofflag=1; - return(1); - } - } - - /* advance storage vectors and clean up */ - { - int new_centerNext=ci->blocksizes[1]/2; - int movementW=centerNext-new_centerNext; - - if(movementW>0){ - - _ve_envelope_shift(b->ve,movementW); - v->pcm_current-=movementW; - - for(i=0;ichannels;i++) - memmove(v->pcm[i],v->pcm[i]+movementW, - v->pcm_current*sizeof(*v->pcm[i])); - - - v->lW=v->W; - v->W=v->nW; - v->centerW=new_centerNext; - - if(v->eofflag){ - v->eofflag-=movementW; - if(v->eofflag<=0)v->eofflag=-1; - /* do not add padding to end of stream! */ - if(v->centerW>=v->eofflag){ - v->granulepos+=movementW-(v->centerW-v->eofflag); - }else{ - v->granulepos+=movementW; - } - }else{ - v->granulepos+=movementW; - } - } - } - - /* done */ - return(1); -} - -int vorbis_synthesis_restart(vorbis_dsp_state *v){ - vorbis_info *vi=v->vi; - codec_setup_info *ci; - int hs; - - if(!v->backend_state)return -1; - if(!vi)return -1; - ci=vi->codec_setup; - if(!ci)return -1; - hs=ci->halfrate_flag; - - v->centerW=ci->blocksizes[1]>>(hs+1); - v->pcm_current=v->centerW>>hs; - - v->pcm_returned=-1; - v->granulepos=-1; - v->sequence=-1; - v->eofflag=0; - ((private_state *)(v->backend_state))->sample_count=-1; - - return(0); -} - -int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ - if(_vds_shared_init(v,vi,0)){ - vorbis_dsp_clear(v); - return 1; - } - vorbis_synthesis_restart(v); - return 0; -} - -/* Unlike in analysis, the window is only partially applied for each - block. The time domain envelope is not yet handled at the point of - calling (as it relies on the previous block). */ - -int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=vi->codec_setup; - private_state *b=v->backend_state; - int hs=ci->halfrate_flag; - int i,j; - - if(!vb)return(OV_EINVAL); - if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); - - v->lW=v->W; - v->W=vb->W; - v->nW=-1; - - if((v->sequence==-1)|| - (v->sequence+1 != vb->sequence)){ - v->granulepos=-1; /* out of sequence; lose count */ - b->sample_count=-1; - } - - v->sequence=vb->sequence; - - if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly - was called on block */ - int n=ci->blocksizes[v->W]>>(hs+1); - int n0=ci->blocksizes[0]>>(hs+1); - int n1=ci->blocksizes[1]>>(hs+1); - - int thisCenter; - int prevCenter; - - v->glue_bits+=vb->glue_bits; - v->time_bits+=vb->time_bits; - v->floor_bits+=vb->floor_bits; - v->res_bits+=vb->res_bits; - - if(v->centerW){ - thisCenter=n1; - prevCenter=0; - }else{ - thisCenter=0; - prevCenter=n1; - } - - /* v->pcm is now used like a two-stage double buffer. We don't want - to have to constantly shift *or* adjust memory usage. Don't - accept a new block until the old is shifted out */ - - for(j=0;jchannels;j++){ - /* the overlap/add section */ - if(v->lW){ - if(v->W){ - /* large/large */ - const float *w=_vorbis_window_get(b->window[1]-hs); - float *pcm=v->pcm[j]+prevCenter; - float *p=vb->pcm[j]; - for(i=0;iwindow[0]-hs); - float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; - float *p=vb->pcm[j]; - for(i=0;iW){ - /* small/large */ - const float *w=_vorbis_window_get(b->window[0]-hs); - float *pcm=v->pcm[j]+prevCenter; - float *p=vb->pcm[j]+n1/2-n0/2; - for(i=0;iwindow[0]-hs); - float *pcm=v->pcm[j]+prevCenter; - float *p=vb->pcm[j]; - for(i=0;ipcm[j]+thisCenter; - float *p=vb->pcm[j]+n; - for(i=0;icenterW) - v->centerW=0; - else - v->centerW=n1; - - /* deal with initial packet state; we do this using the explicit - pcm_returned==-1 flag otherwise we're sensitive to first block - being short or long */ - - if(v->pcm_returned==-1){ - v->pcm_returned=thisCenter; - v->pcm_current=thisCenter; - }else{ - v->pcm_returned=prevCenter; - v->pcm_current=prevCenter+ - ((ci->blocksizes[v->lW]/4+ - ci->blocksizes[v->W]/4)>>hs); - } - - } - - /* track the frame number... This is for convenience, but also - making sure our last packet doesn't end with added padding. If - the last packet is partial, the number of samples we'll have to - return will be past the vb->granulepos. - - This is not foolproof! It will be confused if we begin - decoding at the last page after a seek or hole. In that case, - we don't have a starting point to judge where the last frame - is. For this reason, vorbisfile will always try to make sure - it reads the last two marked pages in proper sequence */ - - if(b->sample_count==-1){ - b->sample_count=0; - }else{ - b->sample_count+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; - } - - if(v->granulepos==-1){ - if(vb->granulepos!=-1){ /* only set if we have a position to set to */ - - v->granulepos=vb->granulepos; - - /* is this a short page? */ - if(b->sample_count>v->granulepos){ - /* corner case; if this is both the first and last audio page, - then spec says the end is cut, not beginning */ - long extra=b->sample_count-vb->granulepos; - - /* we use ogg_int64_t for granule positions because a - uint64 isn't universally available. Unfortunately, - that means granposes can be 'negative' and result in - extra being negative */ - if(extra<0) - extra=0; - - if(vb->eofflag){ - /* trim the end */ - /* no preceding granulepos; assume we started at zero (we'd - have to in a short single-page stream) */ - /* granulepos could be -1 due to a seek, but that would result - in a long count, not short count */ - - /* Guard against corrupt/malicious frames that set EOP and - a backdated granpos; don't rewind more samples than we - actually have */ - if(extra > (v->pcm_current - v->pcm_returned)<pcm_current - v->pcm_returned)<pcm_current-=extra>>hs; - }else{ - /* trim the beginning */ - v->pcm_returned+=extra>>hs; - if(v->pcm_returned>v->pcm_current) - v->pcm_returned=v->pcm_current; - } - - } - - } - }else{ - v->granulepos+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; - if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ - - if(v->granulepos>vb->granulepos){ - long extra=v->granulepos-vb->granulepos; - - if(extra) - if(vb->eofflag){ - /* partial last frame. Strip the extra samples off */ - - /* Guard against corrupt/malicious frames that set EOP and - a backdated granpos; don't rewind more samples than we - actually have */ - if(extra > (v->pcm_current - v->pcm_returned)<pcm_current - v->pcm_returned)<pcm_current-=extra>>hs; - } /* else {Shouldn't happen *unless* the bitstream is out of - spec. Either way, believe the bitstream } */ - } /* else {Shouldn't happen *unless* the bitstream is out of - spec. Either way, believe the bitstream } */ - v->granulepos=vb->granulepos; - } - } - - /* Update, cleanup */ - - if(vb->eofflag)v->eofflag=1; - return(0); - -} - -/* pcm==NULL indicates we just want the pending samples, no more */ -int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm){ - vorbis_info *vi=v->vi; - - if(v->pcm_returned>-1 && v->pcm_returnedpcm_current){ - if(pcm){ - int i; - for(i=0;ichannels;i++) - v->pcmret[i]=v->pcm[i]+v->pcm_returned; - *pcm=v->pcmret; - } - return(v->pcm_current-v->pcm_returned); - } - return(0); -} - -int vorbis_synthesis_read(vorbis_dsp_state *v,int n){ - if(n && v->pcm_returned+n>v->pcm_current)return(OV_EINVAL); - v->pcm_returned+=n; - return(0); -} - -/* intended for use with a specific vorbisfile feature; we want access - to the [usually synthetic/postextrapolated] buffer and lapping at - the end of a decode cycle, specifically, a half-short-block worth. - This funtion works like pcmout above, except it will also expose - this implicit buffer data not normally decoded. */ -int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=vi->codec_setup; - int hs=ci->halfrate_flag; - - int n=ci->blocksizes[v->W]>>(hs+1); - int n0=ci->blocksizes[0]>>(hs+1); - int n1=ci->blocksizes[1]>>(hs+1); - int i,j; - - if(v->pcm_returned<0)return 0; - - /* our returned data ends at pcm_returned; because the synthesis pcm - buffer is a two-fragment ring, that means our data block may be - fragmented by buffering, wrapping or a short block not filling - out a buffer. To simplify things, we unfragment if it's at all - possibly needed. Otherwise, we'd need to call lapout more than - once as well as hold additional dsp state. Opt for - simplicity. */ - - /* centerW was advanced by blockin; it would be the center of the - *next* block */ - if(v->centerW==n1){ - /* the data buffer wraps; swap the halves */ - /* slow, sure, small */ - for(j=0;jchannels;j++){ - float *p=v->pcm[j]; - for(i=0;ipcm_current-=n1; - v->pcm_returned-=n1; - v->centerW=0; - } - - /* solidify buffer into contiguous space */ - if((v->lW^v->W)==1){ - /* long/short or short/long */ - for(j=0;jchannels;j++){ - float *s=v->pcm[j]; - float *d=v->pcm[j]+(n1-n0)/2; - for(i=(n1+n0)/2-1;i>=0;--i) - d[i]=s[i]; - } - v->pcm_returned+=(n1-n0)/2; - v->pcm_current+=(n1-n0)/2; - }else{ - if(v->lW==0){ - /* short/short */ - for(j=0;jchannels;j++){ - float *s=v->pcm[j]; - float *d=v->pcm[j]+n1-n0; - for(i=n0-1;i>=0;--i) - d[i]=s[i]; - } - v->pcm_returned+=n1-n0; - v->pcm_current+=n1-n0; - } - } - - if(pcm){ - int i; - for(i=0;ichannels;i++) - v->pcmret[i]=v->pcm[i]+v->pcm_returned; - *pcm=v->pcmret; - } - - return(n1+n-v->pcm_returned); - -} - -const float *vorbis_window(vorbis_dsp_state *v,int W){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=vi->codec_setup; - int hs=ci->halfrate_flag; - private_state *b=v->backend_state; - - if(b->window[W]-1<0)return NULL; - return _vorbis_window_get(b->window[W]-hs); -} diff --git a/Engine/lib/libvorbis/lib/books/Makefile.am b/Engine/lib/libvorbis/lib/books/Makefile.am deleted file mode 100644 index 3697a7177..000000000 --- a/Engine/lib/libvorbis/lib/books/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -SUBDIRS = coupled uncoupled floor diff --git a/Engine/lib/libvorbis/lib/books/coupled/Makefile.am b/Engine/lib/libvorbis/lib/books/coupled/Makefile.am deleted file mode 100644 index 1115201dd..000000000 --- a/Engine/lib/libvorbis/lib/books/coupled/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = res_books_stereo.h res_books_51.h diff --git a/Engine/lib/libvorbis/lib/books/coupled/res_books_51.h b/Engine/lib/libvorbis/lib/books/coupled/res_books_51.h deleted file mode 100644 index eb569c6f0..000000000 --- a/Engine/lib/libvorbis/lib/books/coupled/res_books_51.h +++ /dev/null @@ -1,12273 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - * - * function: static codebooks for 5.1 surround - * - ********************************************************************/ - -static const long _vq_quantlist__44p0_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p0_l0_0[] = { - 1, 3, 4, 7, 7, 8, 8, 9, 9, 9,10,10,10, 5, 6, 5, - 8, 7, 9, 8, 9, 9,10, 9,11,10, 5, 5, 7, 7, 8, 8, - 9, 9, 9, 9,10,10,11, 8, 9, 8,10, 9,10, 9,10, 9, - 11,10,11,10, 8, 8, 9, 9,10, 9,10, 9,11,10,11,10, - 11,10,11,11,11,11,11,11,11,11,11,11,11,11,10,11, - 11,11,12,11,11,11,11,11,11,10,12,12,12,12,12,12, - 12,11,12,12,12,11,11,11,12,12,12,12,12,12,12,11, - 12,11,12,11,11,13,12,12,12,13,12,12,12,12,11,12, - 11,11,13,13,13,12,12,12,12,12,12,11,11,11,10,13, - 13,13,12,13,12,13,11,13,10,12,11,11,13,13,12,13, - 12,12,12,12,11,12,11,11,11, -}; - -static const static_codebook _44p0_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p0_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p0_l0_0, - 0 -}; - -static const long _vq_quantlist__44p0_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p0_l0_1[] = { - 1, 4, 4, 6, 6, 5, 5, 5, 7, 5, 5, 5, 5, 6, 7, 7, - 6, 7, 7, 7, 6, 7, 7, 7, 7, -}; - -static const static_codebook _44p0_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p0_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p0_l0_1, - 0 -}; - -static const long _vq_quantlist__44p0_l1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p0_l1_0[] = { - 1, 4, 4, 4, 4, 4, 4, 4, 4, -}; - -static const static_codebook _44p0_l1_0 = { - 2, 9, - (char *)_vq_lengthlist__44p0_l1_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p0_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p0_lfe[] = { - 1, 3, 2, 3, -}; - -static const static_codebook _huff_book__44p0_lfe = { - 2, 4, - (char *)_huff_lengthlist__44p0_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p0_long[] = { - 2, 3, 6, 7,10,14,16, 3, 2, 5, 7,11,14,17, 6, 5, - 5, 7,10,12,14, 7, 7, 6, 6, 7, 9,13,10,11, 9, 6, - 6, 9,11,15,15,13,10, 9,10,12,18,18,16,14,12,13, - 16, -}; - -static const static_codebook _huff_book__44p0_long = { - 2, 49, - (char *)_huff_lengthlist__44p0_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p0_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p0_p1_0[] = { - 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44p0_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p0_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p0_p1_0, - 0 -}; - -static const long _vq_quantlist__44p0_p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p0_p2_0[] = { - 1, 5, 5, 0, 7, 7, 0, 8, 8, 0, 9, 9, 0,12,12, 0, - 8, 8, 0, 9, 9, 0,12,12, 0, 8, 8, 0, 6, 6, 0,11, - 11, 0,12,12, 0,12,12, 0,15,15, 0,11,11, 0,12,12, - 0,15,15, 0,12,12, 0, 5, 5, 0, 5, 5, 0, 6, 6, 0, - 7, 7, 0,11,11, 0, 6, 6, 0, 7, 7, 0,10,11, 0, 6, - 6, 0, 7, 7, 0,11,11, 0,12,12, 0,11,11, 0,15,15, - 0,10,10, 0,12,12, 0,15,15, 0,12,12, 0, 6, 6, 0, - 12,12, 0,12,12, 0,12,12, 0,15,15, 0,11,11, 0,12, - 12, 0,15,15, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 8, 0,12,12, 0,12,12, 0,12,12, 0,15, - 15, 0,12,12, 0,11,12, 0,15,16, 0,11,11, 0, 6, 6, - 0,11,12, 0,12,12, 0,12,12, 0,16,15, 0,12,12, 0, - 13,12, 0,15,14, 0,12,12, 0, 0, 0, 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 static_codebook _44p0_p2_0 = { - 5, 243, - (char *)_vq_lengthlist__44p0_p2_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p0_p2_0, - 0 -}; - -static const long _vq_quantlist__44p0_p2_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p0_p2_1[] = { - 1, 3, 3, 0, 9, 9, 0, 9, 9, 0,10,10, 0, 9, 9, 0, - 10,10, 0,10,10, 0, 9, 9, 0,10,10, 0, 7, 7, 0, 7, - 7, 0, 6, 6, 0, 8, 8, 0, 7, 7, 0, 8, 8, 0, 8, 9, - 0, 8, 8, 0, 8, 8, 0, 7, 7, 0, 9, 9, 0, 8, 8, 0, - 10,10, 0, 9, 9, 0,10,10, 0,10,10, 0, 9, 9, 0,10, - 10, 0, 9, 9, 0,11,11, 0,11,11, 0,12,12, 0,11,11, - 0,12,12, 0,13,13, 0,12,12, 0,13,12, 0, 8, 8, 0, - 12,12, 0,12,12, 0,13,13, 0,12,12, 0,13,13, 0,13, - 13, 0,13,13, 0,13,13, 0, 7, 7, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 0,11,11, 0,12,12, 0,13,13, 0,12, - 12, 0,13,13, 0,13,13, 0,12,12, 0,12,12, 0, 8, 8, - 0,12,12, 0,12,12, 0,13,13, 0,13,13, 0,13,14, 0, - 14,13, 0,13,13, 0,13,13, 0, 7, 7, 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 static_codebook _44p0_p2_1 = { - 5, 243, - (char *)_vq_lengthlist__44p0_p2_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p0_p2_1, - 0 -}; - -static const long _vq_quantlist__44p0_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p0_p3_0[] = { - 1, 6, 6, 7, 8, 8, 7, 8, 8, 7, 9, 9,10,12,11, 9, - 8, 8, 7, 9, 9,11,12,12, 9, 9, 9, 6, 7, 7,10,11, - 11,10,11,11,10,11,11,13,13,14,12,12,12,11,11,11, - 14,14,14,12,12,12, 6, 5, 5, 9, 6, 5, 9, 6, 6, 9, - 7, 7,12,10,10,11, 6, 6,10, 7, 7,13,10,10,12, 7, - 7, 7, 8, 8,12,10,10,12,10,10,11,10,10,15,13,13, - 13, 9, 9,12,11,11,16,13,13,15,11,11, 8, 7, 7,12, - 12,12,12,11,11,12,11,11,14,14,14,14,12,12,12,12, - 12,16,15,15,14,12,12, 0,10,10, 0,12,12, 0,12,12, - 0,11,11, 0,14,14, 0,11,11, 0,12,12, 0,15,15, 0, - 11,11, 8, 8, 8,13,11,11,13,10,10,13,11,11,15,13, - 13,14,11,11,12,10,10,16,14,14,14,10,10, 9, 7, 7, - 13,11,11,13,11,11,12,11,11,16,14,14,14,12,12,13, - 12,12,15,14,14,15,13,12, 0,11,11, 0,12,12, 0,12, - 12, 0,12,12, 0,15,15, 0,12,12, 0,13,12, 0,14,15, - 0,12,12, -}; - -static const static_codebook _44p0_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p0_p3_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p0_p3_0, - 0 -}; - -static const long _vq_quantlist__44p0_p3_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p0_p3_1[] = { - 2, 4, 4, 8, 8,10,12,12,11,11, 9,11,11,12,13,11, - 12,12,11,11,11,12,12,12,12,10,13,12,13,13,11,12, - 12,13,13,11,12,12,13,13,11,12,13,13,13,11,13,13, - 13,13,10,13,13,12,13,11,12,12,14,14,11,13,12,12, - 12,11,12,12,13,13,11,13,13,12,12,11,13,13,13,13, - 11,12,12,13,13,11,13,13,12,12,11,12,12,13,13,11, - 13,13,12,12,11,13,13,13,13,11,12,12,14,14,11,13, - 13,12,12,11,12,12,13,13,11,13,13,12,12,11,10,10, - 10,10,12,10,10,11,11,11, 8, 8,11,11,13,10,10,10, - 10,12,10,10,10,10,13,11,11,11,11,13,10,10,11,11, - 13,11,11,12,12,13,11,11,11,11,13,11,11,12,12,13, - 11,11,12,12,13,10,10,11,11,13,11,11,11,11,13,11, - 10,11,11,13,11,11,11,11,13,11,11,11,11,13,10,10, - 11,11,13,11,11,11,11,12,10,11,11,11,13,11,11,11, - 11,13,11,11,11,11,13,10,10,11,11,13,11,11,11,11, - 13,11,11,11,11,13,11,11,11,11,11,10,10,10,10,12, - 10,10, 9, 9,12,12,12,11,11,13,12,12, 9, 9,13,12, - 12,10,10,12,12,12,12,12,13,13,13,14,14,13,12,12, - 11,11,13,13,13,12,12,13,12,12,11,11,13,12,13,11, - 11,13,13,13,14,14,13,12,12,10,10,13,13,13,11,11, - 13,12,12,10,10,13,13,13,11,11,13,13,13,14,14,13, - 12,12,10,10,13,13,13,11,11,13,12,13,10,10,13,13, - 13,11,11,13,13,13,14,14,13,12,12,10,10,13,13,13, - 11,11,13,13,12,10,10,14,12,12, 8, 8,14,12,12, 9, - 9,14,11,11, 9, 9,14,12,12, 8, 8,14,11,11, 7, 7, - 14,13,13,10,10,15,12,12,10,10,15,13,13,10,10,15, - 12,12, 9, 9,15,13,13,10,10,15,13,13,10,10,15,12, - 12,10,10,15,13,13,10,10,14,12,12, 9, 9,14,13,13, - 9, 9,14,13,13, 9, 9,15,12,12, 9, 9,15,13,13, 9, - 9,14,12,12, 9, 9,14,13,13, 9, 9,14,13,13, 9, 9, - 15,12,12, 9, 9,14,13,13, 9, 9,14,12,12, 9, 9,14, - 13,13, 9, 9,13,12,12, 8, 8,13,13,13, 8, 8,14,13, - 13, 9, 9,13,13,13, 7, 7,14,13,13, 8, 8,14,14,14, - 10,10,14,14,14,11,11,14,14,14, 9, 9,14,14,14,10, - 10,14,14,14, 9, 9,14,14,14,10, 9,15,14,14,11,11, - 14,14,14, 9, 9,14,14,14,10,10,14,14,14, 9, 9,14, - 14,14, 9, 9,15,14,14,11,11,14,14,14, 8, 8,14,14, - 14, 9, 9,14,14,14, 8, 8,14,14,14, 9, 9,15,14,14, - 11,11,14,14,14, 8, 8,14,14,14, 9, 9,14,14,14, 8, - 8,12,12,12,13,13,16,15,15,11,11,16,15,16,12,12, - 17,16,16,11,11,17,15,15,12,11,16,16,16,12,13,16, - 15,15,13,13,16,16,16,12,12,16,16,15,13,13,16,16, - 16,12,12,16,16,16,13,13,17,16,16,14,14,17,17,16, - 12,12,17,16,16,13,13,17,17,16,12,13,16,16,17,13, - 12,17,16,16,14,13,17,16,16,12,12,17,16,16,12,12, - 17,16,17,12,12,17,17,17,13,13,16,16,16,13,14,17, - 17,16,12,12,16,16,16,13,13,17,17,17,12,12,13,14, - 14,10,10,16,14,14,12,12,16,15,15,14,14,16,14,14, - 12,12,15,14,14,13,13,17,15,15,14,13,16,16,15,15, - 15,16,15,15,14,14,16,15,15,14,14,17,15,15,14,14, - 16,15,15,14,14,16,16,15,15,15,17,15,15,13,13,16, - 15,15,14,14,17,15,15,13,13,17,15,15,14,14,16,15, - 15,15,15,16,14,14,13,13,16,15,15,14,14,16,14,14, - 13,13,17,15,15,14,14,16,16,15,15,15,17,14,14,13, - 13,16,15,15,14,14,17,14,14,13,13,13,11,11,10,10, - 16,14,14,13,13,15,14,14,13,13,16,14,14,12,12,16, - 14,14,12,12,15,15,15,14,14,16,14,14,14,14,16,15, - 14,14,14,16,14,14,14,14,16,15,15,14,13,16,15,15, - 14,14,16,14,14,14,14,17,15,15,14,14,16,14,14,14, - 14,16,15,15,13,14,16,15,15,14,14,16,14,14,14,14, - 16,15,15,13,13,16,14,14,13,13,16,15,15,13,13,16, - 15,15,14,14,16,14,14,14,14,17,15,15,13,13,16,15, - 14,13,13,17,15,15,13,13,14,14,14, 9, 9,14,14,14, - 17,17,14,15,15,18,18,14,14,14,18,19,14,14,14,18, - 18,15,15,15,19,18,15,16,15,18,20,15,15,15,18,19, - 15,15,15,19,19,15,15,15,18,20,15,15,15,18,19,15, - 15,16,20,18,15,15,15,18,18,15,15,15,19,19,15,15, - 15,18,19,15,15,15,18,19,15,15,15,19,19,14,15,14, - 19,19,15,15,15,20,19,15,14,14,19,18,14,15,15,18, - 19,15,15,16,20,20,14,14,14,18,19,15,15,15,19,18, - 14,14,14,18,18,14,12,12, 9, 9,13,14,14,18,18,14, - 13,13,18,19,14,14,14,18,18,14,14,14,18,18,15,15, - 15,19,19,15,14,14,19,18,14,15,15,19,18,15,14,14, - 18,18,15,15,15,19,18,14,15,15,19,19,15,14,14,19, - 18,14,15,15,19,18,15,14,14,19,18,14,15,15,19,18, - 15,15,15,21,18,15,14,14,19,18,14,15,15,18,19,14, - 15,14,20,19,14,15,15,18,19,14,15,15,19,19,15,14, - 14,19,20,14,15,15,18,18,14,14,14,19,19,14,15,15, - 19,18,12,12,12,13,13,16,15,15,11,11,16,15,15,12, - 12,16,16,16,11,11,16,15,15,11,11,16,16,16,13,13, - 17,16,16,13,13,17,17,17,12,12,16,16,16,13,13,17, - 16,17,13,12,15,16,16,12,12,16,15,15,13,13,17,16, - 16,12,12,16,16,15,12,12,16,16,16,12,12,17,17,16, - 13,12,16,16,16,13,13,17,16,16,12,12,17,16,16,12, - 12,17,17,16,12,12,16,17,16,12,12,17,15,15,13,13, - 17,16,16,12,12,16,16,16,12,12,16,16,16,12,12,13, - 13,13, 9, 9,15,14,14,13,13,16,15,14,14,14,16,14, - 14,13,13,15,14,14,13,13,17,15,15,14,14,16,15,15, - 15,15,16,15,15,14,14,16,15,15,15,15,17,15,15,14, - 14,16,15,15,14,14,16,15,15,15,15,17,14,15,14,14, - 16,15,15,14,14,17,15,15,13,14,17,15,15,14,14,16, - 15,15,15,15,17,14,14,13,13,16,15,15,14,14,17,14, - 14,13,13,17,15,15,14,14,16,15,16,15,15,17,14,14, - 13,13,16,15,15,14,14,18,14,14,13,13,13,11,11,11, - 11,15,14,14,12,12,15,14,14,13,13,16,14,14,12,12, - 16,13,14,12,12,16,15,15,13,13,16,14,14,14,14,16, - 15,15,13,13,16,14,14,13,13,16,14,15,13,13,15,15, - 15,13,13,16,14,14,14,13,16,14,14,13,13,16,14,14, - 13,13,16,15,15,13,13,16,15,15,13,13,16,14,14,14, - 14,16,15,15,12,12,16,14,14,13,13,16,15,15,12,12, - 16,15,15,13,13,16,14,14,14,14,17,15,14,12,12,16, - 14,14,13,13,16,15,15,12,12,14,14,14, 8, 8,14,14, - 14,17,18,14,15,15,17,18,14,14,14,17,18,14,14,14, - 18,18,14,15,15,18,18,14,16,15,19,19,15,15,15,18, - 19,15,16,15,20,19,15,15,15,18,18,14,15,15,18,19, - 15,16,16,20,19,15,15,15,19,17,14,15,15,20,18,14, - 15,15,18,18,14,15,15,18,19,14,15,15,19,20,14,14, - 14,18,18,14,15,15,18,19,14,14,14,18,19,14,15,15, - 19,18,15,16,16,20,21,14,14,15,19,19,14,15,15,19, - 19,14,14,14,19,18,13,12,12, 9, 9,13,14,14,18,19, - 14,14,14,18,19,14,14,14,18,18,14,14,14,18,18,14, - 15,15,19,19,15,14,14,19,18,15,15,15,19,19,15,14, - 14,19,20,14,15,15,18,19,14,15,15,20,18,15,14,14, - 18,18,14,15,15,18,18,14,14,14,19,19,14,15,15,18, - 18,14,15,15,19,18,15,14,14,19,19,14,15,15,19,18, - 15,14,14,19,18,14,14,15,18,19,14,15,15,19,18,15, - 14,14,18,19,14,15,14,19,20,14,14,14,19,19,14,15, - 15,19,19,12,12,12,13,13,16,16,16,11,11,16,16,16, - 12,12,17,16,16,11,11,17,15,15,11,11,16,16,16,13, - 13,17,15,16,13,13,16,16,16,12,12,17,16,16,13,13, - 17,17,16,12,12,17,17,16,13,13,17,16,16,13,13,17, - 17,17,12,12,17,16,16,13,13,17,17,17,12,12,16,16, - 16,12,12,17,15,15,13,13,17,16,16,11,11,17,16,16, - 12,12,16,16,16,11,11,16,17,16,12,12,17,16,16,13, - 13,17,17,16,12,12,17,17,16,12,12,17,16,16,11,11, - 13,14,14, 9, 9,16,14,14,13,13,16,14,15,14,14,16, - 14,14,12,12,16,14,14,13,13,17,15,15,14,14,16,15, - 15,15,15,17,15,15,14,14,16,15,15,14,14,17,15,15, - 14,14,16,15,15,14,14,16,15,15,15,16,17,14,15,14, - 14,16,15,15,14,14,17,15,15,14,14,16,15,15,14,14, - 16,15,15,15,15,17,14,14,13,13,16,15,15,14,14,16, - 14,14,13,13,17,15,15,14,14,16,16,15,15,15,17,14, - 14,13,13,16,15,15,14,14,17,14,14,13,13,13,11,11, - 10,10,16,14,14,12,12,15,13,13,13,12,16,14,14,11, - 11,16,14,14,11,11,16,14,15,13,14,16,14,14,13,13, - 16,15,15,13,13,16,14,14,13,13,16,15,15,13,13,16, - 15,15,13,13,17,14,14,14,14,17,15,15,13,13,16,14, - 15,13,13,16,15,15,13,13,16,15,15,13,13,16,14,14, - 13,13,17,15,15,12,12,16,14,14,12,12,16,15,15,12, - 12,16,15,15,13,13,16,14,14,13,13,17,15,15,12,12, - 17,14,14,12,12,16,15,15,12,12,13,14,14, 8, 8,13, - 14,14,18,18,13,15,15,17,18,14,14,14,18,19,14,14, - 14,19,18,14,15,15,19,18,15,15,16,21,18,15,15,15, - 19,19,14,16,16,19,19,14,15,15,18,19,14,15,15,19, - 20,14,16,16,19,18,15,15,15,18,19,14,15,15,19,18, - 15,15,15,18,18,15,15,15,20,18,15,16,16,20,19,14, - 15,14,18,19,14,15,16,19,20,14,15,15,19,18,15,15, - 15,19,18,15,16,16,20,19,15,14,14,18,18,14,15,15, - 19,19,14,15,15,18,18,13,12,12, 8, 8,13,14,14,19, - 18,14,13,13,20,18,14,14,14,19,18,14,13,13,18,19, - 14,15,15,20,19,15,14,14,19,19,14,15,15,19,18,15, - 14,14,20,20,15,15,15,19,18,14,15,15,19,18,15,14, - 14,19,18,14,15,15,20,19,14,14,14,20,19,14,15,15, - 19,18,15,15,15,18,18,15,14,14,18,18,14,15,15,19, - 19,14,14,14,19,19,14,15,15,19,19,15,15,15,19,18, - 15,14,14,20,19,15,15,15,19,19,14,14,14,20,19,14, - 15,15,20,20,12,12,12,13,13,17,16,16,11,11,16,16, - 15,12,12,17,16,16,11,11,17,15,15,11,11,17,17,17, - 13,13,17,16,16,13,13,17,17,17,12,12,17,16,16,13, - 13,17,17,16,12,13,16,17,16,13,13,17,16,15,13,13, - 17,16,16,12,12,17,16,16,12,13,17,16,17,12,12,17, - 17,17,12,12,17,16,15,13,13,17,16,16,12,12,17,16, - 16,12,12,17,16,16,11,11,16,16,16,12,12,17,15,15, - 13,13,17,16,15,11,11,16,16,16,12,12,17,16,16,11, - 11,13,14,14, 9, 9,16,14,14,13,13,16,14,15,14,14, - 16,14,14,12,12,16,14,14,13,13,17,15,15,14,15,16, - 15,15,15,15,17,15,15,14,14,16,15,15,15,14,16,15, - 15,14,14,16,15,15,14,14,16,15,16,15,15,17,15,14, - 14,14,16,15,15,14,14,17,15,15,13,13,16,15,15,14, - 14,16,16,16,15,15,17,14,14,13,13,16,15,15,14,14, - 18,14,15,13,13,16,15,15,14,14,16,16,15,15,15,16, - 14,14,13,13,16,15,15,14,14,17,14,15,13,13,13,11, - 11,10,10,15,14,14,12,12,15,14,14,13,13,16,14,14, - 12,12,16,13,14,12,12,16,14,15,14,13,16,14,14,14, - 14,16,15,15,13,13,16,14,14,13,13,16,15,15,13,13, - 15,15,15,13,13,16,14,14,14,14,17,15,15,13,13,16, - 14,14,13,13,16,15,15,13,13,16,15,15,13,13,16,14, - 14,13,13,17,15,15,12,12,16,14,14,12,12,16,14,15, - 12,12,16,15,15,13,13,16,14,14,13,13,17,15,15,12, - 12,16,14,14,12,12,16,15,15,12,12,14,14,14, 8, 8, - 14,14,14,17,17,14,15,15,18,18,14,14,14,18,17,14, - 14,14,18,18,14,15,15,18,20,15,16,15,19,18,15,15, - 15,19,18,15,15,16,19,18,15,15,15,18,18,14,15,15, - 18,18,15,16,16,18,19,15,15,15,18,18,15,15,15,19, - 20,15,15,15,18,18,15,15,15,18,18,15,16,16,19,19, - 15,14,15,19,19,15,15,15,19,20,14,14,15,18,18,15, - 15,15,19,19,15,16,16,19,19,15,15,14,18,19,15,15, - 15,20,20,15,15,14,18,18,13,12,12, 8, 8,13,14,14, - 18,18,14,14,14,18,18,14,14,14,18,20,14,14,14,18, - 18,14,15,15,19,18,15,14,14,18,19,15,15,15,18,19, - 15,14,14,18,19,15,15,15,18,18,14,15,14,18,19,15, - 14,14,21,19,15,15,15,19,18,14,14,14,19,18,14,15, - 15,19,18,15,15,15,20,19,15,14,14,20,18,14,15,15, - 18,19,14,14,14,19,18,14,15,15,18,19,15,15,15,18, - 19,15,14,14,19,19,15,15,15,19,19,14,14,14,19,20, - 14,15,15,18,19, -}; - -static const static_codebook _44p0_p3_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p0_p3_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p0_p3_1, - 0 -}; - -static const long _vq_quantlist__44p0_p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p0_p4_0[] = { - 2, 6, 6,14,14, 6, 8, 8,14,14, 7, 7, 7,14,14, 0, - 13,13,15,16, 0,13,13,15,15, 7, 8, 8,15,15, 9,10, - 10,16,16, 9, 8, 8,14,15, 0,13,13,17,17, 0,13,13, - 16,16, 8, 8, 8,15,15,12,11,11,16,16, 9, 8, 8,14, - 14, 0,13,13,17,17, 0,13,13,15,15, 0,14,14,16,16, - 0, 0, 0,18,19, 0,12,12,16,15, 0,16,16, 0,20, 0, - 14,14,16,16, 0,14,14,17,17, 0, 0, 0,19,19, 0,12, - 12,15,15, 0,18,17,21,21, 0,14,14,16,16, 5, 7, 7, - 12,13, 9,10, 9,14,14,11,10,10,14,14, 0, 0, 0,18, - 17, 0,20,21,18,18, 9,10,10,14,14,12,12,12,17,16, - 12,10,10,14,14, 0,20,20,18,17, 0,21,21,17,17,11, - 10,10,14,14,15,13,13,18,18,13,11,11,14,14, 0,20, - 0,18,18, 0,20,21,18,17, 0,21, 0,18,19, 0, 0, 0, - 0,21, 0,21,20,16,17, 0, 0, 0,21,21, 0, 0, 0,20, - 18, 0,20, 0,17,18, 0, 0, 0, 0, 0, 0, 0,20,16,17, - 0, 0, 0,20, 0, 0, 0, 0,18,18, 6, 6, 6,13,13, 8, - 5, 5,11,11, 9, 6, 6,13,13, 0, 9, 9,12,12, 0,10, - 10,14,14, 9, 7, 7,13,13,12, 9, 9,13,13,10, 6, 6, - 13,13, 0,10,10,14,14, 0,10,10,13,13, 9, 7, 7,13, - 13,13,10,10,13,13,11, 6, 6,13,13, 0,10,10,15,15, - 0,10,10,13,13, 0,12,11,15,15, 0,20,19,17,16, 0, - 9, 9,13,13, 0,13,13,20,19, 0,11,11,13,13, 0,11, - 11,15,15, 0,20,19,17,17, 0,10,10,13,13, 0,14,15, - 0,21, 0,12,12,13,13, 0,10,10,12,12, 0,11,11,15, - 15, 0,11,11,15,15, 0,15,15,20,20, 0,16,16, 0, 0, - 0,11,11,15,15, 0,14,14,17,17, 0,11,11,15,15, 0, - 15,15,20,21, 0,16,16,21,21, 0,12,12,15,15, 0,15, - 15,18,20, 0,11,11,16,15, 0,15,15,21,21, 0,16,16, - 0,21, 0,16,16, 0, 0, 0, 0, 0, 0, 0, 0,14,14,21, - 21, 0,17,18, 0, 0, 0,16,17,20, 0, 0,16,16, 0, 0, - 0, 0, 0, 0, 0, 0,15,15,20,20, 0,19,18, 0,21, 0, - 18,17, 0, 0, 0,10,10,11,11, 0,10,10,10,10, 0,11, - 11,12,12, 0,11,11, 9, 9, 0,13,13,12,12, 0,11,11, - 12,12, 0,13,13,12,12, 0,10,10,12,12, 0,12,12,13, - 13, 0,12,12,12,12, 0,11,11,12,12, 0,13,13,12,12, - 0,10,10,12,12, 0,13,13,13,13, 0,12,12,12,12, 0, - 14,13,13,13, 0,19,21,15,15, 0,12,11,12,12, 0,16, - 15,19,19, 0,13,13,11,11, 0,13,13,13,13, 0, 0,21, - 15,16, 0,12,12,12,12, 0,16,16,19,21, 0,13,13,12, - 12, 7, 7, 7,16,16,11, 9, 9,16,16,12, 9, 9,16,16, - 0,13,13,16,16, 0,14,14,17,16,11, 9, 9,16,16,14, - 12,11,17,17,13, 8, 9,15,15, 0,13,13,19,19, 0,13, - 13,16,15,12,10,10,17,17,15,12,12,19,18,14, 9, 9, - 17,16, 0,14,14,18, 0, 0,14,13,16,16, 0,14,15,18, - 17, 0,21, 0,19,21, 0,12,12,16,16, 0,16,16, 0, 0, - 0,14,14,16,16, 0,14,14,18,18, 0, 0,21,20, 0, 0, - 13,13,16,17, 0,18,18, 0, 0, 0,15,14,17,16, 8, 7, - 7,14,14,11,10,10,15,15,13,10,10,15,15, 0,21,20, - 19,19, 0,21, 0,17,18,11,10,10,15,16,14,12,12,18, - 18,14,11,11,15,14, 0,21,20,18,19, 0, 0,21,18,18, - 12,11,11,16,16,16,14,14,18,20,14,11,11,16,15, 0, - 20,20,19,19, 0, 0,20,18,18, 0,21, 0,18,19, 0, 0, - 0, 0, 0, 0,20,20,17,18, 0, 0, 0,20,20, 0, 0, 0, - 19,19, 0, 0, 0,20,18, 0, 0, 0, 0, 0, 0, 0,21,18, - 18, 0,21,21, 0,21, 0, 0, 0,19,20,11, 9, 9,14,14, - 13,10,10,14,14,13,11,11,15,15, 0,13,13,13,13, 0, - 14,14,16,16,13,11,11,15,15,16,12,12,15,15,14,10, - 10,14,14, 0,14,14,16,16, 0,14,14,15,15,13,10,10, - 15,15,17,13,14,15,16,15,10,10,15,15, 0,14,14,17, - 16, 0,14,14,15,15, 0,15,15,17,17, 0, 0,21,18,18, - 0,13,13,15,15, 0,16,16,21,20, 0,14,14,15,14, 0, - 15,14,16,17, 0, 0,20,20,19, 0,13,13,15,15, 0,19, - 18, 0, 0, 0,15,15,15,15, 0,11,11,14,14, 0,12,12, - 16,16, 0,12,12,16,16, 0,15,16,21,21, 0,16,17,21, - 0, 0,12,12,17,16, 0,14,14,18,19, 0,11,11,16,16, - 0,15,15,20,21, 0,16,16,21, 0, 0,12,12,17,16, 0, - 15,15,19,19, 0,12,12,16,17, 0,16,15, 0, 0, 0,16, - 16, 0, 0, 0,17,17, 0,21, 0, 0, 0, 0, 0, 0,14,15, - 20, 0, 0,17,17, 0, 0, 0,17,17, 0, 0, 0,17,16, 0, - 0, 0, 0, 0, 0, 0, 0,15,15, 0, 0, 0,18,18, 0, 0, - 0,18,17, 0, 0, 0,11,11,14,14, 0,12,12,15,15, 0, - 12,12,15,15, 0,13,13,14,14, 0,14,14,17,17, 0,12, - 12,16,16, 0,14,14,16,16, 0,11,11,15,15, 0,13,13, - 16,17, 0,13,13,16,16, 0,12,12,15,15, 0,14,14,17, - 16, 0,11,11,15,15, 0,14,14,17,17, 0,13,13,16,16, - 0,15,15,17,18, 0,21,20,20,21, 0,12,12,15,15, 0, - 16,16,20,21, 0,14,14,15,15, 0,14,14,17,17, 0, 0, - 0,18,19, 0,12,13,15,15, 0,18,17,21, 0, 0,14,15, - 15,15, 8, 8, 8,16,16,12,10,10,16,16,13, 9, 9,16, - 16, 0,14,14,18,17, 0,14,14,16,17,12,10,10,18,17, - 14,12,11,18,18,14, 9, 9,16,16, 0,13,13,18,18, 0, - 13,13,17,16,12, 9, 9,16,17,17,13,13,17,17,14, 9, - 9,15,15, 0,14,14,20,19, 0,13,13,16,16, 0,15,15, - 19,18, 0, 0, 0,20,19, 0,12,13,17,17, 0,16,16,20, - 0, 0,14,14,16,17, 0,14,14,19,18, 0, 0, 0,20,20, - 0,13,13,16,16, 0,18,17, 0, 0, 0,15,15,16,16, 9, - 7, 7,14,14,12,10,10,15,15,13,10,10,15,15, 0,21, - 0,18,19, 0,20,21,19,18,12,10,10,16,15,15,13,13, - 18,18,14,11,11,15,15, 0, 0, 0,19,18, 0, 0,21,18, - 18,13,11,11,15,15,16,14,14,17,19,15,11,11,15,15, - 0,21,21,20,18, 0, 0,21,18,18, 0, 0,21,21,19, 0, - 0, 0, 0, 0, 0,19,20,18,17, 0, 0, 0,21,21, 0,21, - 0,20,18, 0, 0,21,19,19, 0, 0, 0, 0, 0, 0,20,21, - 17,17, 0, 0, 0, 0, 0, 0,21, 0,18,20, 0,10,10,14, - 14, 0,11,11,15,15, 0,11,11,15,15, 0,14,14,15,15, - 0,15,15,16,16, 0,11,12,16,16, 0,13,13,16,16, 0, - 11,11,15,15, 0,14,14,17,17, 0,14,14,15,15, 0,11, - 11,16,15, 0,14,14,15,15, 0,11,11,15,15, 0,15,15, - 17,17, 0,14,14,15,15, 0,16,16,18,18, 0, 0, 0,20, - 19, 0,14,13,16,15, 0,17,17,21, 0, 0,15,15,15,15, - 0,16,15,17,16, 0,20, 0,20,18, 0,13,14,15,15, 0, - 19,18, 0,21, 0,15,15,15,15, 0,11,11,14,14, 0,12, - 12,16,16, 0,12,12,16,16, 0,16,15,20,21, 0,17,16, - 0, 0, 0,12,12,16,16, 0,14,14,18,18, 0,11,11,16, - 16, 0,15,15,21,20, 0,16,16, 0, 0, 0,12,12,16,17, - 0,15,14,19,19, 0,11,12,16,16, 0,15,15,21, 0, 0, - 16,16, 0, 0, 0,16,17, 0, 0, 0, 0, 0, 0, 0, 0,15, - 15,21, 0, 0,17,17, 0, 0, 0,17,17, 0, 0, 0,17,16, - 0, 0, 0, 0, 0, 0, 0, 0,15,15, 0,20, 0,19,20, 0, - 0, 0,17,17, 0, 0, 0,12,12,15,15, 0,12,12,15,15, - 0,12,12,16,16, 0,13,13,15,15, 0,15,15,17,17, 0, - 13,13,17,16, 0,14,14,17,17, 0,11,11,16,16, 0,14, - 14,17,17, 0,13,13,16,16, 0,12,12,16,16, 0,15,15, - 16,17, 0,11,11,15,16, 0,14,14,17,17, 0,13,14,16, - 16, 0,15,15,18,18, 0,21,20,20,19, 0,13,13,16,17, - 0,16,16, 0, 0, 0,14,14,16,16, 0,15,15,18,18, 0, - 0, 0,20,19, 0,13,13,16,16, 0,17,17, 0, 0, 0,14, - 14,16,16, 0,11,11,16,16, 0,13,13,18,17, 0,13,13, - 17,17, 0,16,16,17,17, 0,16,16,17,18, 0,12,12,17, - 17, 0,15,15,18,18, 0,12,12,16,16, 0,16,16,19,19, - 0,15,15,16,17, 0,12,12,17,17, 0,17,17,18,18, 0, - 12,12,17,17, 0,16,16,19,19, 0,15,16,17,17, 0,16, - 16,18,17, 0, 0, 0,21,21, 0,13,13,16,16, 0,17,17, - 0,20, 0,15,15,16,17, 0,16,16,19,18, 0, 0,21,20, - 21, 0,14,14,17,16, 0,20, 0, 0, 0, 0,15,16,16,17, - 0, 9, 9,14,14, 0,13,13,16,16, 0,14,14,15,15, 0, - 0,20,19,19, 0, 0, 0,19,19, 0,12,12,15,15, 0,15, - 16,19,18, 0,14,14,15,15, 0,21, 0,18,18, 0,20, 0, - 17,18, 0,13,13,16,16, 0,17,17,17,19, 0,14,14,16, - 15, 0,21,20,20,19, 0, 0, 0,19,19, 0, 0, 0,19,18, - 0, 0, 0, 0, 0, 0,20,20,17,18, 0, 0, 0,21,21, 0, - 0, 0,18,18, 0,21, 0,18,19, 0, 0, 0, 0, 0, 0,20, - 21,18,18, 0, 0, 0,20,21, 0, 0, 0,19,19, 0,18,18, - 15,15, 0,20,21,17,17, 0,19,21,17,17, 0, 0, 0,17, - 18, 0, 0, 0,20,19, 0,19,19,17,17, 0, 0, 0,18,18, - 0,19,20,16,17, 0, 0,21,20,20, 0,19,20,19,18, 0, - 19,20,16,16, 0, 0, 0,18,19, 0,19,20,17,17, 0, 0, - 21, 0,20, 0,21,21,17,19, 0,20, 0,19,20, 0, 0, 0, - 20, 0, 0,19,18,17,16, 0, 0, 0, 0, 0, 0, 0,20,17, - 17, 0,20,21,18,20, 0, 0, 0, 0,21, 0,19,20,17,17, - 0, 0, 0, 0, 0, 0,20,21,17,17, 0,11,11,14,14, 0, - 13,13,16,17, 0,13,13,16,16, 0,17,17, 0,21, 0,18, - 17,21, 0, 0,13,13,16,16, 0,15,15,18,18, 0,12,12, - 16,16, 0,17,16,21, 0, 0,17,17, 0, 0, 0,12,12,17, - 17, 0,17,17,19,21, 0,13,12,16,16, 0,17,17, 0, 0, - 0,17,17, 0, 0, 0,18,17, 0,21, 0, 0, 0, 0, 0, 0, - 15,15,20, 0, 0,20,18, 0, 0, 0,17,18, 0, 0, 0,16, - 17, 0, 0, 0, 0, 0, 0, 0, 0,15,15, 0, 0, 0,19,19, - 0, 0, 0,18,18, 0, 0, 0,14,14,18,18, 0,16,16, 0, - 21, 0,16,16,21,21, 0,17,17, 0,20, 0,17,17,20, 0, - 0,16,15, 0, 0, 0,20,20, 0, 0, 0,15,15,20,20, 0, - 17,17,21, 0, 0,17,18,20,20, 0,15,15,20,20, 0,18, - 18, 0, 0, 0,15,15,19,20, 0,17,18, 0, 0, 0,17,17, - 20,20, 0,18,17,21, 0, 0, 0, 0, 0,21, 0,15,15,20, - 20, 0,19,19, 0, 0, 0,17,17,21, 0, 0,17,17, 0, 0, - 0, 0, 0,21, 0, 0,15,15,19,19, 0,20,21, 0, 0, 0, - 18,17,21,21, 0,12,12,16,16, 0,14,14,17,17, 0,13, - 13,17,18, 0,16,16,18,17, 0,16,16,18,18, 0,13,13, - 18,18, 0,15,16,19,18, 0,13,13,16,16, 0,16,16,20, - 18, 0,16,16,17,17, 0,12,13,17,17, 0,17,16,18,18, - 0,12,12,16,16, 0,17,16,20,19, 0,16,16,16,16, 0, - 16,17,18,20, 0, 0, 0,21,20, 0,14,14,17,16, 0,19, - 18, 0,20, 0,16,16,17,16, 0,16,16,17,18, 0, 0,21, - 21,21, 0,14,14,16,16, 0,20,20,21, 0, 0,16,16,16, - 16, 0,10,10,14,14, 0,14,14,15,16, 0,14,14,15,15, - 0, 0,21,18,18, 0, 0,21,18,19, 0,13,13,16,16, 0, - 16,16,18,18, 0,14,14,15,15, 0,21, 0,18,18, 0,21, - 0,18,18, 0,13,13,16,16, 0,17,17,19,20, 0,14,14, - 15,15, 0, 0, 0,18,20, 0, 0,21,18,18, 0, 0,21,19, - 18, 0, 0, 0, 0, 0, 0,20,21,18,17, 0, 0, 0,21,21, - 0, 0, 0,19,19, 0,21, 0,18,19, 0, 0, 0, 0, 0, 0, - 21,20,17,17, 0, 0,21,20, 0, 0, 0, 0,19,19, 0,19, - 20,15,16, 0, 0,20,18,17, 0,20,21,17,18, 0,21, 0, - 18,18, 0, 0, 0,19,19, 0,20,20,17,18, 0, 0, 0,18, - 19, 0,20,20,18,17, 0, 0, 0, 0,20, 0, 0,21,17,18, - 0,20,21,17,17, 0, 0, 0,18,18, 0,19,19,17,17, 0, - 0, 0,21,21, 0,20,20,17,17, 0, 0, 0,21,19, 0, 0, - 0,20,19, 0,21,20,17,18, 0, 0, 0, 0, 0, 0, 0,20, - 18,17, 0,21,20,18,18, 0, 0, 0,20,21, 0,20,20,17, - 17, 0, 0, 0, 0, 0, 0,20, 0,17,17, 0,11,11,13,14, - 0,13,13,16,16, 0,13,13,16,16, 0,17,17, 0, 0, 0, - 17,18, 0, 0, 0,13,13,16,16, 0,15,16,18,18, 0,13, - 13,16,17, 0,16,17,20, 0, 0,17,18,20, 0, 0,13,13, - 17,17, 0,16,16,20,21, 0,13,13,16,16, 0,17,17,21, - 0, 0,17,18, 0, 0, 0,17,18, 0,21, 0, 0, 0, 0, 0, - 0,15,15,20, 0, 0,19,19, 0, 0, 0,17,17, 0, 0, 0, - 18,17,21,20, 0, 0, 0, 0, 0, 0,16,16,20,21, 0,21, - 20, 0,21, 0,19,21, 0, 0, 0,15,15, 0, 0, 0,16,17, - 0,19, 0,16,16, 0, 0, 0,17,17, 0, 0, 0,19,18, 0, - 0, 0,16,16,20,20, 0,20,18,21, 0, 0,15,15,21,21, - 0,18,18, 0, 0, 0,18,19, 0, 0, 0,16,15, 0,21, 0, - 20,19, 0, 0, 0,16,16, 0, 0, 0,20,18, 0,21, 0,17, - 18,21, 0, 0,18,19, 0, 0, 0, 0, 0, 0, 0, 0,16,16, - 20,20, 0,19,20, 0, 0, 0,17,17, 0, 0, 0,18,17,20, - 21, 0, 0, 0, 0, 0, 0,16,16, 0,20, 0,20,22, 0, 0, - 0,18,18, 0,22, -}; - -static const static_codebook _44p0_p4_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p0_p4_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p0_p4_0, - 0 -}; - -static const long _vq_quantlist__44p0_p4_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p0_p4_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p0_p4_1 = { - 1, 7, - (char *)_vq_lengthlist__44p0_p4_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p0_p4_1, - 0 -}; - -static const long _vq_quantlist__44p0_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p0_p5_0[] = { - 1, 6, 6, 6, 8, 8, 7, 8, 8, 7, 9, 8,10,11,11, 9, - 8, 8, 7, 8, 8,11,11,11, 9, 8, 8, 6, 7, 7,10,10, - 10,10,10,10,10,10,10,14,13,13,12,11,11,10,10,10, - 14,14,13,13,11,11, 6, 6, 6, 8, 5, 5, 8, 7, 7, 8, - 7, 7,11, 9, 9, 9, 7, 7, 8, 7, 7,12,10,10,10, 7, - 7, 7, 8, 8,12,11,11,12,10,10,11,10,10,14,13,13, - 13,10,10,11,10,11,16,14,14,13,10,10, 7, 8, 7,12, - 12,12,12,11,11,12,11,11,16,14,15,13,12,12,11,11, - 11,17,15,14,14,13,13,10, 9, 9,13,11,11,13,11,11, - 12,11,11,16,14,13,14,11,11,12,11,11,16,15,14,14, - 11,11, 7, 8, 8,12,11,11,12,10,10,12,10,10,16,14, - 13,13,11,11,12,10,10,16,14,14,13,10,10, 8, 8, 8, - 12,12,12,12,11,11,12,11,11,16,14,15,14,12,12,12, - 11,11,16,15,15,14,12,12,10,10,10,13,11,11,13,11, - 11,12,12,12,16,14,14,14,11,11,12,11,11,17,14,15, - 14,11,11, -}; - -static const static_codebook _44p0_p5_0 = { - 5, 243, - (char *)_vq_lengthlist__44p0_p5_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p0_p5_0, - 0 -}; - -static const long _vq_quantlist__44p0_p5_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p0_p5_1[] = { - 2, 7, 7, 7, 8, 8, 7, 7, 7, 7, 8, 8, 8, 8, 9, 8, - 7, 7, 8, 8, 8, 9, 9, 9, 9, 7, 7, 6, 6, 6, 9, 7, - 7, 9, 7, 7, 9, 8, 8,10, 8, 8,10, 8, 8,10, 8, 8, - 10, 8, 8,10, 8, 8, 7, 6, 6, 9, 6, 6, 9, 6, 6, 9, - 7, 7,10, 8, 8, 9, 6, 6, 9, 7, 7,10, 8, 8, 9, 7, - 7, 7, 8, 8,11, 9, 9,11, 9, 9,11, 9, 9,12, 9, 9, - 12, 8, 8,12, 9, 9,12,10, 9,12, 8, 8, 8, 7, 7,10, - 9, 9,11, 9, 9,11, 9, 9,11,11,10,11, 9, 9,11,10, - 9,11,10,11,11, 9, 9,10, 8, 8,11, 9, 9,11, 9, 9, - 11, 9, 9,11,10,10,11, 9, 9,11, 9, 9,11,10,10,11, - 9, 9, 9, 8, 8,12, 9, 9,12, 9, 9,11, 9, 9,12, 9, - 9,12, 8, 8,12, 9, 9,12, 9, 9,12, 8, 8, 9, 7, 7, - 11, 9,10,11,10, 9,11, 9, 9,11,11,11,11, 9, 9,11, - 10,10,11,11,11,11, 9, 9,10, 9, 9,11, 9, 9,11,10, - 10,11,10, 9,11,10,10,11, 9, 9,11,10,10,11,10,11, - 11, 9, 9, -}; - -static const static_codebook _44p0_p5_1 = { - 5, 243, - (char *)_vq_lengthlist__44p0_p5_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p0_p5_1, - 0 -}; - -static const long _vq_quantlist__44p0_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p0_p6_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p0_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p0_p6_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p0_p6_0, - 0 -}; - -static const long _vq_quantlist__44p0_p6_1[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p0_p6_1[] = { - 1, 3, 2, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11, - 11,12,12,12,14,14,14,15,15, -}; - -static const static_codebook _44p0_p6_1 = { - 1, 25, - (char *)_vq_lengthlist__44p0_p6_1, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p0_p6_1, - 0 -}; - -static const long _vq_quantlist__44p0_p6_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p0_p6_2[] = { - 3, 4, 4, 5, 4, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p0_p6_2 = { - 1, 25, - (char *)_vq_lengthlist__44p0_p6_2, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p0_p6_2, - 0 -}; - -static const char _huff_lengthlist__44p0_short[] = { - 3, 3, 7, 8,10,13,16, 3, 2, 5, 7, 9,13,16, 6, 4, - 4, 6,10,14,15, 7, 5, 5, 7,10,13,14, 9, 8, 9, 9, - 9,11,13,12,11,12, 9, 7, 8,11,14,12,10, 6, 5, 7, - 10, -}; - -static const static_codebook _huff_book__44p0_short = { - 2, 49, - (char *)_huff_lengthlist__44p0_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p1_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p1_l0_0[] = { - 1, 4, 4, 7, 7, 8, 8, 9, 9,10,10,11,11, 4, 6, 5, - 8, 6, 9, 8,10, 9,10,10,11,10, 5, 5, 6, 6, 8, 8, - 9, 9,10,10,10,10,11, 7, 8, 8, 9, 8,10, 9,10, 9, - 11,10,11,10, 7, 8, 8, 8,10, 9,10,10,10,10,11,10, - 11, 9,10,10,11,11,11,11,12,11,12,11,12,11, 9,10, - 10,11,11,11,11,11,11,11,12,11,12,11,11,11,12,12, - 12,12,12,12,12,12,12,11,11,12,11,12,12,12,12,12, - 12,12,12,11,12,12,12,12,12,13,12,13,12,12,12,12, - 12,12,12,12,12,13,13,13,13,12,13,12,12,12,12,12, - 13,13,12,13,12,13,12,13,12,12,12,12,13,13,13,13, - 13,13,12,12,12,12,12,11,12, -}; - -static const static_codebook _44p1_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p1_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p1_l0_0, - 0 -}; - -static const long _vq_quantlist__44p1_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p1_l0_1[] = { - 1, 4, 4, 6, 6, 5, 5, 5, 6, 6, 5, 6, 5, 6, 6, 6, - 6, 7, 7, 7, 6, 7, 6, 7, 7, -}; - -static const static_codebook _44p1_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p1_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p1_l0_1, - 0 -}; - -static const long _vq_quantlist__44p1_l1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p1_l1_0[] = { - 1, 4, 4, 4, 4, 4, 4, 4, 4, -}; - -static const static_codebook _44p1_l1_0 = { - 2, 9, - (char *)_vq_lengthlist__44p1_l1_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p1_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p1_lfe[] = { - 1, 3, 2, 3, -}; - -static const static_codebook _huff_book__44p1_lfe = { - 2, 4, - (char *)_huff_lengthlist__44p1_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p1_long[] = { - 3, 3, 7, 7, 9,13,16, 3, 2, 4, 6,10,13,17, 7, 4, - 4, 6, 9,12,14, 7, 6, 6, 5, 7, 9,12,10,10, 9, 6, - 6, 9,12,14,14,13, 9, 8,10,11,18,18,15,13,11,10, - 11, -}; - -static const static_codebook _huff_book__44p1_long = { - 2, 49, - (char *)_huff_lengthlist__44p1_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p1_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p1_p1_0[] = { - 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44p1_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p1_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p1_p1_0, - 0 -}; - -static const long _vq_quantlist__44p1_p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p1_p2_0[] = { - 1, 4, 4, 0, 7, 7, 0, 8, 8, 0, 9, 9, 0,12,12, 0, - 8, 8, 0, 9, 9, 0,12,12, 0, 8, 8, 0, 6, 6, 0,11, - 11, 0,11,11, 0,12,12, 0,14,14, 0,11,11, 0,12,12, - 0,14,14, 0,11,11, 0, 6, 6, 0, 6, 5, 0, 7, 6, 0, - 7, 7, 0,10,10, 0, 6, 6, 0, 7, 7, 0,10,10, 0, 7, - 7, 0, 7, 7, 0,10,10, 0,11,11, 0,11,11, 0,14,14, - 0,10,10, 0,12,12, 0,14,14, 0,12,12, 0, 6, 6, 0, - 11,11, 0,11,11, 0,12,12, 0,14,14, 0,11,11, 0,12, - 12, 0,15,15, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 8, 0,11,11, 0,11,11, 0,12,12, 0,15, - 15, 0,12,12, 0,11,11, 0,15,15, 0,11,11, 0, 6, 6, - 0,11,11, 0,12,12, 0,12,12, 0,15,15, 0,11,11, 0, - 12,12, 0,14,14, 0,12,12, 0, 0, 0, 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 static_codebook _44p1_p2_0 = { - 5, 243, - (char *)_vq_lengthlist__44p1_p2_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p1_p2_0, - 0 -}; - -static const long _vq_quantlist__44p1_p2_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p1_p2_1[] = { - 1, 3, 3, 0, 8, 8, 0, 8, 8, 0,10,10, 0, 9, 9, 0, - 10,10, 0,10,10, 0, 9, 9, 0,10,10, 0, 7, 7, 0, 7, - 7, 0, 7, 7, 0, 8, 8, 0, 8, 8, 0, 8, 8, 0, 9, 9, - 0, 8, 8, 0, 8, 8, 0, 7, 7, 0, 8, 8, 0, 8, 8, 0, - 10,10, 0, 9, 9, 0, 9, 9, 0,10,10, 0, 9, 9, 0,10, - 10, 0, 8, 8, 0,11,11, 0,11,11, 0,12,12, 0,11,11, - 0,12,12, 0,12,12, 0,12,12, 0,12,12, 0, 8, 8, 0, - 11,11, 0,11,11, 0,13,12, 0,12,12, 0,13,12, 0,13, - 13, 0,12,12, 0,13,13, 0, 7, 7, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 8, 0,11,11, 0,11,11, 0,13,12, 0,12, - 12, 0,12,12, 0,12,12, 0,11,11, 0,12,12, 0, 8, 8, - 0,12,12, 0,12,12, 0,13,13, 0,12,12, 0,13,13, 0, - 13,13, 0,12,13, 0,13,13, 0, 7, 7, 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 static_codebook _44p1_p2_1 = { - 5, 243, - (char *)_vq_lengthlist__44p1_p2_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p1_p2_1, - 0 -}; - -static const long _vq_quantlist__44p1_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p1_p3_0[] = { - 1, 6, 6, 6, 7, 7, 7, 8, 8, 7, 8, 8,10,11,11, 9, - 8, 8, 7, 9, 9,11,12,12, 9, 8, 8, 6, 7, 7, 9,11, - 11,10,11,11,10,11,11,13,13,13,11,12,12,10,11,11, - 13,14,14,12,12,12, 6, 6, 6, 8, 6, 6, 8, 6, 6, 9, - 7, 7,12,10,10,10, 6, 6, 9, 7, 7,12,10,10,11, 7, - 6, 7, 8, 8,12,10,10,12,10,10,11,10,10,15,13,13, - 13,10,10,12,11,11,15,13,13,14,11,11, 8, 7, 7,12, - 11,11,12,11,11,11,11,11,14,14,14,13,12,12,12,11, - 11,16,15,15,14,12,12, 0,10,10, 0,11,11, 0,12,12, - 0,11,11, 0,14,14, 0,11,11, 0,11,11, 0,15,15, 0, - 11,11, 7, 8, 8,13,10,10,12,10,10,12,11,11,15,13, - 13,14,11,11,12,10,10,16,14,14,14,10,10, 8, 7, 7, - 12,11,11,13,11,11,12,11,11,15,14,14,14,12,12,13, - 12,12,15,14,14,15,12,12, 0,11,11, 0,12,12, 0,12, - 12, 0,12,12, 0,15,15, 0,12,12, 0,12,12, 0,15,14, - 0,12,12, -}; - -static const static_codebook _44p1_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p1_p3_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p1_p3_0, - 0 -}; - -static const long _vq_quantlist__44p1_p3_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p1_p3_1[] = { - 2, 3, 4, 7, 7,10,12,12,12,12,10,11,11,13,13,11, - 12,12,11,11,12,12,12,12,12,11,13,13,13,13,12,12, - 12,13,14,12,13,13,13,13,12,13,13,13,13,12,13,13, - 13,13,11,13,13,13,13,12,12,12,14,14,12,13,13,12, - 12,12,12,13,13,13,12,13,13,13,13,12,13,13,13,13, - 12,12,12,14,14,12,13,13,12,12,12,13,13,13,13,12, - 13,13,12,12,12,13,13,13,13,12,12,12,14,14,12,13, - 13,12,12,12,13,13,13,13,12,13,13,12,12,10,10,11, - 10,10,11,11,11,11,11,11, 9, 9,10,10,12,11,11,10, - 10,12,10,10,10,10,13,12,12,12,12,13,11,11,11,11, - 13,12,12,12,12,13,11,11,11,11,13,12,12,12,12,13, - 12,12,12,12,13,11,11,11,11,13,12,12,12,12,13,11, - 11,11,11,13,12,12,11,11,13,12,12,11,11,13,11,11, - 11,11,13,12,12,11,11,13,11,11,11,11,13,12,12,11, - 11,13,12,12,11,11,13,11,11,11,11,13,12,12,11,11, - 13,11,11,11,11,13,12,12,11,11,11,11,11,10,10,11, - 11,11, 9, 9,11,12,12,11,11,12,12,12, 9, 9,13,13, - 13,10,10,13,13,13,11,11,13,13,13,14,14,13,13,13, - 11,10,13,13,14,12,12,13,13,13,11,11,13,13,13,11, - 11,13,13,13,14,14,13,13,13,10,10,13,13,13,11,11, - 13,13,13,10,10,13,14,13,11,11,13,14,14,14,14,13, - 13,13,10,10,13,14,14,11,11,13,13,13,10,10,13,14, - 14,11,11,13,13,13,14,14,14,13,13,10,10,13,14,14, - 11,11,13,13,13,10,10,14,12,12, 9, 9,14,12,12, 9, - 9,14,11,11, 9, 9,14,12,12, 8, 8,14,11,11, 7, 7, - 15,13,13,10,10,15,12,12,10,10,15,13,13,10,10,15, - 12,12,10,10,15,13,13,10,10,15,13,13,10,10,15,12, - 12,10,10,15,13,13,10,10,15,12,12,10,10,15,13,13, - 10,10,15,13,13,10,10,15,12,12,10,10,15,13,13, 9, - 9,15,12,12, 9, 9,14,13,13, 9, 9,15,13,13,10,10, - 15,12,12,10,10,15,13,13, 9, 9,15,12,12, 9, 9,15, - 13,13, 9, 9,13,12,12, 9, 9,13,13,13, 8, 8,13,13, - 13, 9, 9,13,13,13, 7, 7,14,13,13, 8, 8,14,14,14, - 10,10,15,14,14,11,11,14,14,14, 9, 9,15,14,14,10, - 10,15,14,14, 9, 9,14,14,14,10,10,15,14,14,11,11, - 15,14,14, 9, 9,14,14,14,10,10,14,14,14, 9, 9,15, - 14,15,10,10,15,14,14,11,11,14,14,14, 9, 9,14,14, - 14, 9, 9,14,14,14, 8, 8,15,14,14,10,10,15,14,14, - 11,11,14,14,14, 9, 9,15,14,14, 9, 9,14,14,14, 8, - 8,12,12,12,13,13,16,16,16,11,11,17,16,16,12,12, - 17,16,16,11,11,17,16,16,11,11,17,17,16,13,13,17, - 16,16,13,13,18,17,16,12,12,17,16,16,13,13,17,16, - 17,12,12,18,17,17,13,13,17,16,16,14,14,18,17,17, - 12,12,18,16,16,13,13,17,17,17,13,12,17,17,17,13, - 13,17,16,16,13,13,18,17,17,12,12,17,16,16,13,12, - 17,17,17,12,12,18,17,17,13,13,18,16,16,14,14,18, - 17,17,12,12,17,17,17,13,13,18,17,18,12,12,13,14, - 14,10,10,16,14,14,13,13,17,15,15,14,14,17,14,14, - 12,13,16,14,14,13,13,17,15,15,14,14,16,16,16,15, - 15,17,15,15,14,14,17,16,16,14,15,17,15,15,14,14, - 17,15,16,14,14,17,16,16,15,15,17,15,15,13,13,17, - 15,15,14,14,18,15,15,13,14,17,15,15,14,14,16,16, - 16,15,15,17,15,15,13,13,17,15,15,14,14,17,15,15, - 13,13,17,15,15,14,14,16,16,16,15,15,17,15,15,13, - 13,17,15,15,14,14,18,15,15,13,13,13,11,11,10,10, - 16,14,14,13,12,16,14,14,13,13,16,15,14,12,12,16, - 14,14,12,12,16,15,15,14,14,16,14,14,14,14,17,15, - 15,13,13,16,15,15,14,14,17,15,15,13,14,17,15,15, - 14,14,17,15,14,14,14,17,15,15,13,13,17,15,15,14, - 14,17,15,15,13,13,17,15,15,14,14,17,14,14,14,14, - 17,15,15,13,13,17,15,15,13,13,17,15,15,13,13,17, - 15,15,14,14,17,15,15,14,14,17,15,15,13,13,17,15, - 15,13,13,17,15,15,13,13,14,14,15, 8, 8,14,14,14, - 19,19,14,15,15,18,19,14,14,14,19,18,14,14,14,19, - 19,15,15,15,19,18,15,16,16,19,19,15,15,15,19,19, - 15,16,16,20,19,15,15,15,19,19,15,15,15,19,19,16, - 16,16,20,19,15,15,15,19,18,15,16,16,20,19,15,15, - 15,18,18,15,15,15,19,20,15,16,16,19,19,15,15,15, - 20,19,15,15,15,20,19,15,15,15,19,18,15,15,15,19, - 19,15,16,16,19,20,15,15,15,19,19,15,15,15,19,20, - 15,15,15,19,19,14,12,12, 9, 9,14,14,14,19,19,14, - 14,14,19,19,14,14,15,20,19,15,14,14,18,19,15,15, - 15,19,19,15,15,14,20,19,15,15,15,20,19,15,15,14, - 20,19,15,15,15,20,19,15,15,15,19,20,15,14,14,19, - 20,15,15,15,20,20,15,14,14,20,19,15,15,15,19,19, - 15,15,15,19,19,15,14,14,19,19,15,15,15,19,20,15, - 15,15,20,20,15,15,15,19,19,15,15,15,20,19,16,14, - 14,19,19,15,15,15,20,19,15,14,15,20,19,14,15,15, - 20,19,12,12,12,13,13,16,16,16,11,11,16,16,16,12, - 12,17,16,16,11,11,17,15,16,11,11,17,17,17,13,13, - 18,16,17,13,13,18,17,17,13,12,17,16,17,13,13,17, - 17,17,13,13,16,16,16,12,12,17,16,16,13,13,17,16, - 16,12,12,17,16,16,12,13,17,17,17,12,12,17,17,17, - 13,13,18,16,16,13,13,18,17,17,12,12,18,17,17,12, - 12,17,17,17,12,12,17,17,17,12,12,17,16,16,13,13, - 17,17,17,12,12,17,16,16,12,12,17,17,17,12,12,13, - 14,14, 9, 9,16,14,14,13,13,16,15,15,14,14,17,14, - 14,13,13,16,14,14,13,13,17,15,15,15,15,16,16,16, - 15,15,17,15,15,14,14,17,15,15,15,15,17,15,15,14, - 14,17,15,15,14,14,16,16,16,15,15,17,15,15,14,14, - 17,15,15,14,14,17,15,15,14,14,17,15,15,14,14,16, - 16,16,15,15,18,15,15,14,13,17,15,15,14,14,17,15, - 15,13,13,17,15,15,14,14,16,16,16,15,15,17,15,15, - 14,13,17,15,15,14,14,17,15,15,13,13,13,11,11,11, - 11,16,14,14,12,12,16,14,14,13,13,16,15,14,12,12, - 17,14,14,12,12,17,15,15,13,13,17,14,14,14,14,17, - 15,15,13,13,17,14,15,14,13,17,15,15,13,13,16,15, - 15,13,13,16,14,14,14,14,17,15,15,13,13,16,14,14, - 13,13,16,15,15,13,13,17,15,15,13,13,17,14,14,14, - 14,17,15,15,12,12,17,15,15,13,13,17,15,15,12,12, - 16,15,15,13,13,17,14,14,13,14,17,15,15,12,12,17, - 14,14,13,13,17,15,15,12,12,14,14,14, 8, 8,14,14, - 14,18,18,14,15,15,19,19,14,14,14,19,19,14,15,14, - 18,19,15,15,15,18,19,15,16,16,20,20,15,15,15,19, - 20,15,16,16,19,20,15,15,15,19,20,15,15,16,19,19, - 15,16,16,20,20,15,15,15,20,19,15,16,16,20,19,15, - 15,15,19,20,15,15,15,19,19,15,16,16,20,19,15,15, - 15,19,19,15,16,15,20,19,15,15,15,19,19,15,15,15, - 19,20,15,16,16,20,20,15,15,15,19,19,15,15,15,20, - 20,15,15,15,19,19,14,12,12, 9, 9,14,14,14,18,18, - 14,14,14,19,20,14,14,14,18,18,14,14,14,18,19,15, - 15,15,19,20,15,14,14,19,19,15,15,15,19,19,15,14, - 15,19,19,15,15,15,18,20,15,15,15,19,19,15,14,14, - 19,19,15,15,15,20,19,15,15,14,20,20,15,15,15,19, - 19,15,15,15,19,19,15,14,14,19,19,15,15,15,19,19, - 15,14,14,19,20,14,15,15,19,19,15,15,15,19,19,15, - 14,14,20,19,15,15,15,19,19,15,14,14,20,19,15,15, - 15,19,19,13,12,12,13,13,17,17,16,11,11,16,16,16, - 12,12,17,17,16,11,11,17,16,16,11,11,17,17,17,13, - 13,17,16,16,13,13,18,17,17,12,12,17,16,16,13,13, - 18,17,17,12,12,18,17,17,13,13,18,16,17,13,13,17, - 17,17,12,12,18,17,17,13,13,18,17,17,12,12,17,16, - 17,12,12,17,16,16,13,13,17,16,16,11,11,17,16,16, - 12,12,17,17,17,11,11,17,17,17,12,12,18,16,16,13, - 13,18,17,17,12,11,17,16,16,12,12,18,17,17,11,11, - 13,14,14, 9, 9,16,14,14,13,13,16,15,15,14,14,17, - 14,14,12,12,16,14,14,13,13,17,15,15,14,14,17,16, - 16,15,16,18,15,15,14,14,17,15,15,14,14,17,15,15, - 14,14,18,15,15,14,14,16,16,16,15,16,18,15,15,14, - 14,17,16,15,14,14,18,15,15,14,14,17,15,15,14,14, - 17,16,16,15,15,18,14,15,13,13,17,15,15,14,14,18, - 15,15,13,13,17,15,15,14,14,17,16,15,15,15,17,15, - 15,13,13,17,15,15,14,14,18,15,15,13,13,13,11,11, - 10,10,16,14,14,12,12,16,14,14,12,12,17,14,15,11, - 11,17,14,14,11,11,17,15,15,13,13,17,14,14,14,13, - 17,15,15,13,13,16,15,15,13,13,17,15,15,13,13,17, - 15,15,13,13,17,14,14,14,14,17,15,15,13,13,17,14, - 15,13,13,16,15,15,13,13,17,15,15,13,13,17,14,14, - 13,13,17,15,15,12,12,16,14,14,12,12,17,15,15,12, - 12,17,15,15,13,13,17,14,14,13,13,17,15,15,12,12, - 17,14,14,12,12,17,15,15,12,12,13,15,14, 8, 8,14, - 14,14,19,19,14,15,15,18,19,14,14,14,18,19,14,15, - 14,19,19,15,16,15,19,19,15,16,16,19,20,15,15,15, - 19,19,15,16,16,19,19,15,16,16,19,19,15,15,15,19, - 19,15,16,16,20,20,15,15,15,19,19,15,15,15,19,19, - 15,15,15,19,19,15,15,15,19,19,15,16,16,20,19,15, - 15,15,19,19,15,15,15,19,19,15,15,15,19,19,15,16, - 15,19,19,15,16,16,21,19,15,15,15,20,20,15,15,15, - 20,21,15,15,15,19,20,14,12,12, 8, 8,14,14,14,19, - 19,14,13,13,19,19,14,14,14,19,19,14,13,14,19,19, - 15,15,15,20,20,15,14,14,20,19,15,15,15,19,20,15, - 14,14,19,20,15,15,15,20,19,15,15,15,19,20,15,14, - 14,20,20,15,15,15,20,19,15,14,14,19,19,15,15,15, - 19,19,15,15,15,20,19,15,14,14,21,19,15,15,15,20, - 21,15,14,14,21,19,15,15,15,19,19,15,15,15,20,20, - 15,14,14,19,21,15,15,15,19,19,15,14,14,19,20,15, - 15,15,19,19,13,12,12,13,13,17,16,16,11,11,17,16, - 15,12,12,18,16,16,11,11,17,16,16,11,11,18,17,17, - 13,13,18,16,16,13,13,17,17,17,12,13,18,17,16,13, - 13,18,17,17,13,13,17,17,17,13,13,17,16,16,13,13, - 18,16,17,12,12,17,16,16,13,12,17,17,17,12,12,18, - 17,17,13,12,18,16,16,13,13,18,17,17,12,12,17,16, - 16,12,12,17,17,17,11,11,17,16,16,12,12,17,16,16, - 13,13,17,16,16,11,11,17,16,16,12,12,17,17,17,11, - 11,13,14,14, 9, 9,16,14,14,13,13,16,15,15,14,14, - 17,14,14,12,12,16,14,14,13,13,17,15,15,14,14,17, - 15,16,15,15,17,15,15,14,14,17,15,16,14,15,18,15, - 15,14,14,17,15,15,14,14,16,16,16,15,15,18,15,15, - 13,14,17,15,15,14,14,18,15,15,14,14,17,15,15,14, - 14,17,16,16,15,15,17,15,15,13,13,17,15,15,14,14, - 18,15,15,13,13,17,15,15,14,14,17,16,16,15,15,17, - 15,15,13,13,17,15,15,14,14,18,15,15,13,13,13,11, - 11,10,10,16,14,14,12,12,16,14,14,13,13,17,14,14, - 11,11,17,14,14,12,12,17,15,15,14,14,17,14,14,14, - 14,17,15,15,13,13,17,15,14,13,13,16,15,15,13,13, - 16,15,15,13,13,17,14,14,14,14,17,15,15,13,13,17, - 14,14,13,13,16,15,15,13,13,16,15,15,13,13,17,14, - 14,13,13,17,15,15,12,12,17,14,14,12,12,16,15,15, - 12,12,17,15,15,13,13,17,14,14,13,13,17,15,15,12, - 12,17,14,14,12,12,16,15,15,12,12,14,14,14, 8, 8, - 14,14,14,18,18,14,15,15,19,18,14,14,14,18,18,14, - 14,14,18,19,15,16,15,19,19,15,17,16,20,20,15,15, - 15,19,19,15,16,16,19,19,15,15,15,19,19,15,16,15, - 18,19,15,16,16,20,20,15,15,15,19,19,15,16,16,19, - 20,15,15,15,19,19,15,15,16,19,19,15,16,16,20,20, - 15,15,15,19,19,15,15,15,19,20,15,15,15,19,19,15, - 15,15,19,19,15,16,16,20,20,15,15,15,19,20,15,16, - 16,20,20,15,15,15,19,19,13,12,12, 8, 8,14,14,14, - 19,20,14,14,14,19,19,14,14,14,18,19,14,14,14,19, - 20,15,15,15,19,20,15,14,14,21,20,15,15,15,20,20, - 15,15,14,19,19,15,15,15,19,19,15,15,15,19,19,15, - 14,14,19,20,15,15,15,19,20,15,14,14,19,19,15,15, - 15,19,19,15,15,15,19,19,16,14,14,19,19,15,15,15, - 20,20,15,14,14,21,19,15,15,15,19,19,15,15,15,19, - 20,16,14,14,19,20,15,15,15,19,19,15,14,14,19,19, - 15,15,15,20,19, -}; - -static const static_codebook _44p1_p3_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p1_p3_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p1_p3_1, - 0 -}; - -static const long _vq_quantlist__44p1_p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p1_p4_0[] = { - 2, 6, 6,14,14, 6, 7, 7,14,14, 7, 7, 7,14,14, 0, - 13,13,16,16, 0,13,13,15,14, 7, 8, 8,15,15, 9,10, - 10,16,16, 9, 8, 8,15,15, 0,13,13,17,16, 0,13,13, - 15,16, 8, 8, 8,15,15,12,11,11,16,16, 9, 8, 8,14, - 14, 0,13,13,17,18, 0,13,13,15,15, 0,14,14,16,16, - 0, 0, 0,19,18, 0,12,12,16,15, 0,15,16, 0,20, 0, - 14,14,16,16, 0,14,14,17,17, 0, 0, 0,19,18, 0,12, - 12,15,15, 0,17,17, 0,20, 0,14,14,16,16, 5, 6, 7, - 12,12, 9, 9, 9,14,14,10,10,10,14,14, 0,21,21,18, - 17, 0,20,20,18,17, 9,10,10,14,14,12,12,12,16,16, - 12,10,10,14,14, 0,20,19,18,17, 0, 0,20,17,18,11, - 10,10,14,14,14,13,13,18,18,13,11,11,14,14, 0,20, - 20,17,18, 0,21,21,17,17, 0,21, 0,18,18, 0, 0, 0, - 0, 0, 0,20,19,16,17, 0, 0, 0,19,19, 0, 0, 0,18, - 18, 0,21,21,18,18, 0, 0, 0, 0, 0, 0,20,20,16,17, - 0, 0, 0,21,21, 0, 0, 0,18,19, 6, 6, 6,13,12, 8, - 6, 6,11,11, 8, 6, 6,13,13, 0, 9, 9,11,11, 0,11, - 10,14,14, 9, 7, 7,13,13,11, 9, 9,13,13,10, 6, 6, - 13,13, 0,10,10,14,15, 0,10,10,13,13, 9, 7, 7,13, - 13,13,10, 9,13,13,10, 6, 6,13,13, 0,10,10,15,14, - 0,10,10,13,13, 0,11,11,15,15, 0,19,20,17,17, 0, - 9, 9,13,13, 0,13,13,20,20, 0,11,11,13,13, 0,11, - 11,15,15, 0,19,19,17,17, 0,10,10,13,13, 0,15,15, - 20,20, 0,12,12,13,13, 0,10,10,12,12, 0,11,11,15, - 15, 0,11,11,15,15, 0,15,15,20, 0, 0,16,16, 0,21, - 0,11,11,15,15, 0,14,14,18,17, 0,11,11,15,15, 0, - 15,16,19,20, 0,16,16,21,21, 0,12,12,15,15, 0,15, - 14,18,18, 0,11,11,16,16, 0,15,15,21,21, 0,16,15, - 0, 0, 0,16,16,21, 0, 0, 0, 0, 0, 0, 0,14,14,20, - 20, 0,18,18, 0, 0, 0,16,17,21, 0, 0,16,16,21,21, - 0, 0, 0, 0, 0, 0,15,15,21,21, 0,20,19, 0,21, 0, - 17,17, 0, 0, 0,10,10,12,11, 0,10,10,10,11, 0,11, - 11,12,12, 0,11,11, 9, 9, 0,13,13,11,12, 0,11,11, - 12,12, 0,13,13,12,12, 0,10,10,12,12, 0,12,12,13, - 13, 0,12,12,12,12, 0,11,11,12,12, 0,13,13,12,12, - 0,10,10,12,12, 0,13,13,14,14, 0,12,12,12,12, 0, - 14,14,14,13, 0,19,20,15,15, 0,12,11,12,12, 0,15, - 15,21,20, 0,13,13,11,11, 0,13,13,13,13, 0,19, 0, - 15,15, 0,12,12,12,12, 0,17,16,19, 0, 0,13,13,12, - 12, 7, 7, 7,16,16,11, 9, 9,15,15,12, 9, 9,16,16, - 0,13,13,15,14, 0,14,14,17,16,10, 9, 9,16,16,14, - 11,11,17,16,12, 9, 8,15,15, 0,13,13,18,18, 0,13, - 13,15,15,12,10,10,18,17,15,12,12,17,17,14, 9, 9, - 16,16, 0,13,13,18,19, 0,14,13,17,16, 0,14,14,18, - 18, 0, 0, 0,20,21, 0,12,12,16,16, 0,16,16,20,21, - 0,14,14,17,16, 0,14,14,18,19, 0, 0, 0,19,21, 0, - 13,13,17,17, 0,17,17, 0,21, 0,15,15,16,16, 8, 7, - 7,14,14,11,10,10,15,15,12,10,10,15,15, 0,20,20, - 18,18, 0, 0, 0,17,17,11,10,10,16,16,14,12,12,18, - 17,14,11,11,15,15, 0,20,21,18,18, 0, 0,19,18,17, - 12,10,10,16,16,17,14,14,19,19,14,11,11,15,15, 0, - 21,21,19,19, 0,21,20,19,18, 0,21, 0,18,19, 0, 0, - 0, 0, 0, 0,20,20,18,17, 0,21, 0, 0, 0, 0, 0, 0, - 19,18, 0, 0, 0,18,19, 0, 0, 0, 0, 0, 0, 0,21,17, - 18, 0, 0, 0, 0,21, 0, 0,21,18,19,11, 9, 9,14,14, - 13,10,10,13,13,13,11,11,15,15, 0,13,13,12,12, 0, - 15,15,16,16,13,10,10,15,15,16,12,12,15,15,15,10, - 10,15,15, 0,14,13,16,15, 0,14,13,15,15,13,10,10, - 15,15,18,14,14,15,15,15,10,10,14,15, 0,14,14,16, - 16, 0,14,14,16,15, 0,15,15,17,16, 0,21, 0,18,18, - 0,12,13,15,15, 0,16,16, 0, 0, 0,14,14,15,15, 0, - 15,15,16,16, 0,21,20,18,18, 0,13,13,15,15, 0,19, - 18, 0, 0, 0,15,15,15,15, 0,11,11,13,13, 0,12,12, - 16,16, 0,12,12,16,16, 0,15,16,20, 0, 0,16,17, 0, - 0, 0,12,12,16,16, 0,14,14,18,18, 0,11,11,16,17, - 0,15,15,20, 0, 0,16,16, 0, 0, 0,12,12,16,16, 0, - 15,15,19,19, 0,11,11,17,17, 0,16,16,21, 0, 0,16, - 16, 0, 0, 0,17,17,20,20, 0, 0, 0, 0, 0, 0,15,15, - 20, 0, 0,17,18, 0, 0, 0,17,17, 0, 0, 0,16,16, 0, - 21, 0, 0, 0, 0, 0, 0,15,15,21, 0, 0,19,18, 0, 0, - 0,18,17, 0, 0, 0,11,11,14,14, 0,11,11,15,15, 0, - 12,12,16,16, 0,13,13,14,14, 0,14,14,17,17, 0,12, - 12,16,16, 0,14,14,16,16, 0,11,11,16,15, 0,13,13, - 16,17, 0,13,13,16,16, 0,12,12,15,16, 0,15,14,16, - 16, 0,11,11,15,15, 0,14,14,17,17, 0,13,13,16,16, - 0,15,14,18,18, 0,21, 0,19,19, 0,13,13,15,15, 0, - 16,16,20,20, 0,14,14,16,15, 0,14,14,17,17, 0,21, - 0,20,18, 0,13,13,15,15, 0,17,17, 0, 0, 0,14,14, - 16,15, 8, 8, 8,16,16,12, 9, 9,16,16,13, 9, 9,16, - 16, 0,14,14,18,17, 0,14,14,16,17,12,10,10,18,17, - 14,11,11,18,18,14, 9, 9,16,16, 0,13,13,18,18, 0, - 13,13,17,16,12, 9, 9,16,17,17,13,13,16,16,14, 9, - 9,15,15, 0,14,14,20,20, 0,13,13,15,15, 0,15,14, - 18,18, 0, 0, 0,20,21, 0,12,13,16,17, 0,16,16,20, - 21, 0,14,14,16,17, 0,14,14,18,17, 0, 0, 0,20,21, - 0,13,13,16,16, 0,19,17, 0,21, 0,14,15,16,16, 8, - 7, 7,14,13,12,10,10,15,15,13,10,10,15,15, 0,21, - 21,18,19, 0,20,21,18,18,12,10,10,16,15,15,12,12, - 17,17,14,11,11,15,15, 0,21,21,19,18, 0, 0,21,17, - 18,13,11,11,15,15,16,13,13,18,19,15,11,11,15,14, - 0,21, 0,19,19, 0, 0,21,18,18, 0, 0,21,19,19, 0, - 0, 0, 0, 0, 0,20,19,17,17, 0, 0, 0,21, 0, 0,21, - 0,18,19, 0, 0,20,20,19, 0, 0, 0, 0, 0, 0,21,20, - 18,17, 0, 0, 0, 0,20, 0, 0, 0,18,19, 0,10,10,15, - 14, 0,11,11,14,14, 0,11,11,15,16, 0,14,14,15,15, - 0,15,15,16,16, 0,11,11,16,16, 0,14,13,16,16, 0, - 11,11,15,15, 0,14,14,16,16, 0,14,14,15,15, 0,11, - 11,15,15, 0,13,13,15,15, 0,11,11,15,15, 0,15,15, - 18,17, 0,14,14,15,15, 0,15,16,18,18, 0, 0, 0,20, - 20, 0,14,13,16,15, 0,17,17,21, 0, 0,15,15,15,15, - 0,16,15,17,17, 0, 0, 0,19,19, 0,13,13,15,15, 0, - 20,19, 0, 0, 0,15,15,15,15, 0,11,11,13,13, 0,12, - 12,16,16, 0,12,12,16,16, 0,15,15,21,21, 0,17,16, - 0, 0, 0,12,12,16,16, 0,14,14,17,17, 0,11,11,16, - 16, 0,15,15, 0, 0, 0,16,16,21, 0, 0,12,12,17,16, - 0,14,15,20,20, 0,11,11,16,16, 0,15,15, 0,20, 0, - 16,16, 0,21, 0,16,17,21, 0, 0, 0, 0, 0, 0, 0,15, - 15, 0,21, 0,18,18, 0, 0, 0,17,16, 0, 0, 0,17,17, - 21, 0, 0, 0, 0, 0, 0, 0,15,15, 0,20, 0,19,20,21, - 0, 0,17,18, 0, 0, 0,12,12,15,15, 0,12,12,15,15, - 0,12,12,16,16, 0,13,13,15,15, 0,15,15,17,17, 0, - 13,12,17,16, 0,14,14,17,16, 0,11,11,16,16, 0,14, - 14,17,17, 0,14,14,17,17, 0,12,12,16,16, 0,15,15, - 17,17, 0,11,11,16,16, 0,14,14,17,17, 0,14,14,16, - 16, 0,15,15,18,17, 0, 0, 0,19, 0, 0,13,13,16,16, - 0,16,16, 0,21, 0,14,14,16,16, 0,15,15,18,17, 0, - 0, 0,19,19, 0,13,13,16,16, 0,18,17, 0,21, 0,14, - 15,16,16, 0,11,11,16,16, 0,13,13,17,17, 0,13,13, - 17,17, 0,16,16,16,17, 0,16,16,18,18, 0,12,12,17, - 17, 0,16,15,18,17, 0,12,12,16,16, 0,16,15,19,19, - 0,16,15,17,17, 0,12,12,17,18, 0,16,16,18,18, 0, - 12,12,16,16, 0,16,16,19,19, 0,15,16,17,17, 0,15, - 16,18,18, 0, 0, 0,20,20, 0,13,13,16,16, 0,18,18, - 21,20, 0,15,15,16,16, 0,16,16,19,18, 0, 0, 0,19, - 20, 0,14,14,17,17, 0,19,19, 0,21, 0,15,16,16,16, - 0, 9, 9,14,14, 0,13,13,15,15, 0,14,14,15,15, 0, - 0,21,19,19, 0, 0,21,18,18, 0,12,12,15,15, 0,15, - 15,18,18, 0,14,13,15,15, 0,21,21,18,19, 0,21,20, - 18,18, 0,13,13,16,16, 0,17,17,18,19, 0,14,14,15, - 15, 0, 0,21,19,19, 0,21,20,18,19, 0,20,20,19,19, - 0, 0, 0, 0, 0, 0,19,20,17,17, 0, 0, 0,21,21, 0, - 21, 0,18,20, 0,21, 0,18,21, 0, 0, 0, 0, 0, 0,21, - 21,19,18, 0, 0, 0, 0, 0, 0, 0, 0,19,19, 0,18,18, - 15,15, 0,18,20,17,16, 0,20, 0,17,17, 0,21, 0,17, - 17, 0,21,20,19,20, 0,19,19,16,16, 0,21,21,17,18, - 0,19,19,17,17, 0,20,21,21,21, 0,20,20,18,18, 0, - 19,19,16,16, 0, 0,21,18,19, 0,18,19,16,17, 0,21, - 21,19,20, 0,21,19,18,18, 0,21,20,19,21, 0, 0, 0, - 20,21, 0,19,19,17,16, 0, 0, 0, 0, 0, 0,21,20,17, - 17, 0,20,21,19,18, 0, 0, 0, 0,21, 0,19,18,16,17, - 0, 0, 0, 0, 0, 0,20,20,17,17, 0,11,11,14,14, 0, - 13,13,16,16, 0,13,13,16,16, 0,17,17,21, 0, 0,17, - 18, 0, 0, 0,12,12,16,16, 0,15,15,17,18, 0,12,12, - 16,16, 0,16,16, 0,20, 0,17,17, 0,21, 0,12,12,17, - 17, 0,16,16,19,20, 0,12,12,17,17, 0,17,17, 0,20, - 0,17,17, 0, 0, 0,17,17,21, 0, 0, 0, 0, 0, 0, 0, - 15,15, 0,20, 0,19,19, 0, 0, 0,18,18, 0, 0, 0,17, - 17, 0, 0, 0, 0, 0, 0, 0, 0,15,15, 0, 0, 0,20,19, - 0, 0, 0,19,18, 0, 0, 0,14,14,21,19, 0,16,16,20, - 21, 0,16,16,20,20, 0,17,17,20, 0, 0,17,17,20,20, - 0,15,15,20,20, 0,19,18,20, 0, 0,15,15,20,20, 0, - 17,18,21,20, 0,17,17,20,21, 0,15,15,19,19, 0,19, - 18,21,21, 0,15,15,19,20, 0,17,18, 0, 0, 0,17,17, - 20,20, 0,17,18,20,21, 0, 0, 0, 0, 0, 0,15,15,20, - 20, 0,19,19, 0, 0, 0,17,17,19,21, 0,17,17, 0,21, - 0, 0, 0, 0,21, 0,15,15,20,19, 0, 0,20, 0, 0, 0, - 17,17,21,20, 0,12,12,16,16, 0,14,14,17,17, 0,13, - 13,17,17, 0,16,16,17,18, 0,17,16,18,18, 0,13,13, - 18,17, 0,15,16,19,18, 0,13,13,16,16, 0,16,16,19, - 19, 0,16,16,17,17, 0,13,12,17,17, 0,16,16,18,17, - 0,12,12,16,16, 0,17,17,19,18, 0,16,15,16,16, 0, - 16,17,18,19, 0, 0, 0,20,20, 0,14,14,17,16, 0,18, - 18,21, 0, 0,16,16,16,16, 0,16,16,18,17, 0, 0,21, - 21,21, 0,14,14,16,16, 0,21,20,21, 0, 0,16,16,16, - 16, 0,10,10,14,14, 0,14,14,15,16, 0,14,14,15,15, - 0, 0,21,18,18, 0, 0,21,18,19, 0,13,13,16,16, 0, - 16,16,18,17, 0,14,14,15,15, 0,20, 0,18,18, 0,21, - 0,18,17, 0,13,13,16,15, 0,17,17,19,19, 0,14,14, - 15,15, 0,20,20,18,19, 0, 0, 0,18,17, 0, 0,21,18, - 18, 0, 0, 0, 0, 0, 0,20,21,18,17, 0, 0, 0, 0, 0, - 0, 0, 0,19,19, 0, 0,21,18,18, 0, 0, 0, 0, 0, 0, - 21, 0,18,17, 0, 0, 0, 0,21, 0, 0, 0,19,20, 0,19, - 19,16,16, 0, 0,21,18,17, 0,21, 0,18,18, 0,20, 0, - 19,18, 0,21,20,19,19, 0,21,19,17,18, 0, 0,21,19, - 19, 0,21,19,18,18, 0,21, 0,20,18, 0, 0,21,18,18, - 0,20,21,17,17, 0,21, 0,18,18, 0,21,19,17,17, 0, - 21, 0, 0,20, 0, 0,20,17,18, 0, 0, 0,19,20, 0, 0, - 0,20,19, 0,19,21,17,18, 0,21, 0, 0, 0, 0,21,21, - 18,17, 0, 0,21,18,18, 0, 0, 0, 0,21, 0,20,19,16, - 17, 0, 0, 0, 0, 0, 0,21,20,17,17, 0,11,11,13,13, - 0,13,13,16,16, 0,13,13,16,16, 0,17,17, 0,21, 0, - 18,19,21, 0, 0,12,12,16,16, 0,15,15,19,18, 0,13, - 13,16,16, 0,16,17,21,19, 0,17,17,21,21, 0,13,13, - 16,16, 0,16,16,20,18, 0,13,13,16,16, 0,17,17, 0, - 0, 0,18,18, 0, 0, 0,18,17, 0,20, 0, 0, 0, 0, 0, - 0,15,15,21,21, 0,19,18, 0, 0, 0,17,17,21,21, 0, - 17,17, 0, 0, 0, 0, 0, 0, 0, 0,15,15,20,21, 0,20, - 20, 0, 0, 0,19,19, 0, 0, 0,14,15,21,19, 0,16,16, - 0,21, 0,17,16,21,21, 0,17,18,21,20, 0,18,18, 0, - 21, 0,16,16, 0,20, 0,19,19, 0, 0, 0,16,15, 0,20, - 0,18,18, 0, 0, 0,17,17, 0,21, 0,16,16,20,20, 0, - 20,19, 0, 0, 0,15,16,21,22, 0,18,18, 0, 0, 0,18, - 17, 0, 0, 0,18,18, 0, 0, 0, 0, 0, 0, 0, 0,16,16, - 21,20, 0,19,20, 0, 0, 0,18,17,21, 0, 0,17,18, 0, - 0, 0, 0, 0, 0, 0, 0,16,16, 0,20, 0, 0,20, 0, 0, - 0,18,18,22, 0, -}; - -static const static_codebook _44p1_p4_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p1_p4_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p1_p4_0, - 0 -}; - -static const long _vq_quantlist__44p1_p4_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p1_p4_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p1_p4_1 = { - 1, 7, - (char *)_vq_lengthlist__44p1_p4_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p1_p4_1, - 0 -}; - -static const long _vq_quantlist__44p1_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p1_p5_0[] = { - 1, 6, 6, 7, 8, 8, 7, 8, 8, 7, 9, 8,10,11,11, 9, - 8, 8, 7, 8, 8,11,11,11, 9, 8, 8, 6, 7, 7,10,10, - 10,10,10,10,10,10,10,14,13,13,12,11,11,10,10,10, - 14,14,13,12,11,11, 6, 6, 6, 8, 5, 5, 8, 7, 7, 9, - 7, 7,11,10,10, 9, 7, 7, 9, 7, 7,12,10,10,10, 7, - 7, 7, 8, 8,12,11,10,12,10,10,11,10,10,15,13,13, - 13,10,10,11,10,10,17,14,13,13,10,10, 7, 7, 7,12, - 11,12,12,11,11,12,11,11,16,14,14,13,12,12,12,11, - 11,17,15,14,14,12,12,10, 9, 9,13,11,11,13,11,11, - 13,11,11,17,14,13,14,11,11,12,11,11,16,15,14,14, - 11,11, 7, 8, 8,12,11,11,12,10,10,12,10,10,15,13, - 13,14,11,10,12,10,10,16,14,14,14,10,10, 8, 7, 7, - 12,11,11,12,11,11,12,11,11,17,14,14,14,12,12,12, - 11,11,16,15,15,14,12,12,10,10,10,13,11,11,13,11, - 11,13,11,12,16,14,14,14,11,11,13,12,11,16,15,15, - 14,11,11, -}; - -static const static_codebook _44p1_p5_0 = { - 5, 243, - (char *)_vq_lengthlist__44p1_p5_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p1_p5_0, - 0 -}; - -static const long _vq_quantlist__44p1_p5_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p1_p5_1[] = { - 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 9, 8, 8, 8, - 7, 7, 8, 8, 8, 9, 8, 8, 9, 7, 7, 6, 6, 6, 9, 8, - 7, 9, 7, 7, 9, 8, 8,10, 8, 8,10, 8, 8,10, 8, 8, - 10, 8, 8,10, 8, 8, 7, 6, 6, 9, 6, 6, 9, 7, 7, 9, - 7, 7,10, 8, 8, 9, 6, 6, 9, 7, 7,10, 8, 8, 9, 7, - 7, 7, 8, 8,11, 9, 9,11, 9, 9,11, 8, 9,12, 9, 9, - 12, 8, 8,11, 9, 9,12, 9, 9,12, 8, 8, 8, 7, 7,10, - 9, 9,10,10, 9,10, 9, 9,11,10,10,11, 9, 9,11, 9, - 9,11,10,11,11, 9, 9,10, 8, 8,11, 9, 9,10, 9, 9, - 11, 9, 9,11,10,10,11, 9, 9,11, 9, 9,11,10,10,11, - 9, 9, 9, 8, 8,11, 9, 9,12, 9, 9,11, 9, 9,12, 9, - 9,12, 8, 8,12, 9, 9,12, 9, 9,12, 8, 8, 9, 7, 7, - 11, 9, 9,11,10,10,11, 9, 9,11,11,11,11, 9, 9,11, - 10,10,11,11,11,11, 9, 9,10, 9, 9,11, 9, 9,11,10, - 10,11, 9, 9,11,10,10,11, 9, 9,11, 9,10,11,10,10, - 11, 9, 9, -}; - -static const static_codebook _44p1_p5_1 = { - 5, 243, - (char *)_vq_lengthlist__44p1_p5_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p1_p5_1, - 0 -}; - -static const long _vq_quantlist__44p1_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p1_p6_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p1_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p1_p6_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p1_p6_0, - 0 -}; - -static const long _vq_quantlist__44p1_p6_1[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p1_p6_1[] = { - 1, 3, 2, 5, 4, 7, 7, 8, 8, 9, 9,10,10,11,11,12, - 12,13,13,13,14,16,16,16,16, -}; - -static const static_codebook _44p1_p6_1 = { - 1, 25, - (char *)_vq_lengthlist__44p1_p6_1, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p1_p6_1, - 0 -}; - -static const long _vq_quantlist__44p1_p6_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p1_p6_2[] = { - 3, 4, 4, 5, 4, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p1_p6_2 = { - 1, 25, - (char *)_vq_lengthlist__44p1_p6_2, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p1_p6_2, - 0 -}; - -static const char _huff_lengthlist__44p1_short[] = { - 4, 5, 7, 8,10,13,14, 4, 2, 4, 6, 8,11,12, 7, 4, - 3, 5, 8,12,14, 8, 5, 4, 4, 8,12,12, 9, 7, 7, 7, - 9,10,11,13,11,11, 9, 7, 8,10,13,11,10, 6, 5, 7, - 9, -}; - -static const static_codebook _huff_book__44p1_short = { - 2, 49, - (char *)_huff_lengthlist__44p1_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p2_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p2_l0_0[] = { - 1, 4, 4, 7, 7, 8, 8, 9, 9,10,10,11,11, 4, 6, 5, - 8, 7, 9, 8,10, 9,11,10,11,11, 4, 5, 6, 7, 8, 8, - 9, 9,10,10,10,10,11, 8, 9, 8,10, 8,10, 9,11,10, - 11,11,11,11, 8, 8, 9, 8,10, 9,10,10,11,11,11,11, - 11, 9,10,10,11,11,11,11,11,11,12,11,12,11, 9,10, - 10,10,11,11,11,11,11,11,12,11,12,10,11,11,12,11, - 12,12,12,12,12,12,12,12,10,11,11,11,11,12,12,12, - 13,12,12,12,12,11,12,12,12,12,13,13,12,12,12,12, - 12,12,11,12,12,12,12,13,13,12,13,12,12,12,12,12, - 13,13,13,13,13,13,12,13,12,13,12,12,12,13,13,13, - 13,13,13,13,12,13,12,12,12, -}; - -static const static_codebook _44p2_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p2_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p2_l0_0, - 0 -}; - -static const long _vq_quantlist__44p2_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p2_l0_1[] = { - 2, 4, 4, 5, 5, 4, 5, 5, 6, 5, 4, 5, 5, 5, 6, 5, - 5, 6, 6, 6, 5, 6, 5, 6, 6, -}; - -static const static_codebook _44p2_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p2_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p2_l0_1, - 0 -}; - -static const long _vq_quantlist__44p2_l1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p2_l1_0[] = { - 1, 4, 4, 4, 4, 4, 4, 4, 4, -}; - -static const static_codebook _44p2_l1_0 = { - 2, 9, - (char *)_vq_lengthlist__44p2_l1_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p2_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p2_lfe[] = { - 1, 3, 2, 3, -}; - -static const static_codebook _huff_book__44p2_lfe = { - 2, 4, - (char *)_huff_lengthlist__44p2_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p2_long[] = { - 3, 4, 9, 8, 8,10,13,16, 4, 2, 9, 5, 7,10,14,18, - 9, 7, 6, 5, 7, 9,12,16, 7, 5, 5, 3, 5, 8,11,13, - 8, 7, 7, 5, 5, 7, 9,11,10,10, 9, 8, 6, 6, 8,10, - 13,14,13,11, 9, 8, 9,10,17,18,16,14,11,10,10,10, -}; - -static const static_codebook _huff_book__44p2_long = { - 2, 64, - (char *)_huff_lengthlist__44p2_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p2_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p2_p1_0[] = { - 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44p2_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p2_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p2_p1_0, - 0 -}; - -static const long _vq_quantlist__44p2_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p2_p2_0[] = { - 1, 4, 4, 0, 0, 0, 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, - 10,10, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0,11,11, 0, 0, 0, 0, 0, - 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, - 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0,11,11, 0, 0, - 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0,11,11, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, - 6, 6, 0, 0, 0, 7, 7, 0, 0, 0, 8, 8, 0, 0, 0, 0, - 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, - 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 8, 8, 0, - 0, 0,10,10, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, - 11,11, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0,11,10, 0, 0, 0, 0, 0, - 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, - 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 8, 8, 0, 0, 0,10,10, 0, 0, 0,11,11, 0, 0, - 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0,11,11, 0, 0, 0, - 0, 0, 0, 0, 0,10,10, 0, 0, 0,13,13, 0, 0, 0, 0, - 0, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0,12,12, - 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0,13,13, 0, - 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0, 0,13,13, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, - 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0,11,11, - 0, 0, 0,12,12, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, - 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0,12,11, 0, 0, - 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0,13,13, 0, 0, 0, - 0, 0, 0, 0, 0,12,12, 0, 0, 0,13,13, 0, 0, 0, 0, - 0, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0,12,12, - 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 8, 0, 0, 0,10,10, 0, 0, 0,11,11, 0, - 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0,13,13, 0, 0, - 0, 0, 0, 0, 0, 0,12,12, 0, 0, 0,13,13, 0, 0, 0, - 0, 0, 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0,10, - 10, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0,14,13, - 0, 0, 0, 0, 0, 0, 0, 0,13,12, 0, 0, 0,13,13, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0,11, - 11, 0, 0, 0,12,12, 0, 0, 0,12,12, 0, 0, 0, 0, 0, - 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0,12,12, 0, - 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0,13,13, 0, 0, - 0, 0, 0, 0, 0, 0,12,12, 0, 0, 0,12,12, 0, 0, 0, - 0, 0, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0,12, - 12, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0,11,11, 0, 0, 0,12,12, - 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0,12,12, 0, - 0, 0, 0, 0, 0, 0, 0,11,11, 0, 0, 0,14,14, 0, 0, - 0, 0, 0, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, - 12,12, 0, 0, 0,12,13, 0, 0, 0, 0, 0, 0, 0, 0,12, - 12, 0, 0, 0, 0, 0, 0, 0, 0,11,11, 0, 0, 0,14,13, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, - 11,11, 0, 0, 0,12,12, 0, 0, 0,13,13, 0, 0, 0, 0, - 0, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0,12,12, - 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0,12,12, 0, - 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0, 0,14,14, 0, 0, - 0, 0, 0, 0, 0, 0,14,14, 0, 0, 0, 0, 0, 0, 0, 0, - 12,12, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44p2_p2_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p2_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p2_p2_0, - 0 -}; - -static const long _vq_quantlist__44p2_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p2_p3_0[] = { - 1, 5, 5, 6, 7, 7, 0, 8, 8, 6, 9, 9, 8,11,11, 0, - 8, 8, 0, 9, 9, 0,12,12, 0, 8, 8, 5, 7, 7, 7,10, - 10, 0,12,12, 8,11,11, 9,12,12, 0,11,12, 0,12,12, - 0,15,15, 0,12,12, 0, 6, 6, 0, 6, 6, 0, 7, 7, 0, - 7, 7, 0,10,10, 0, 7, 7, 0, 8, 8, 0,11,11, 0, 7, - 7, 6, 7, 7,10, 9, 9, 0,11,10,10, 9, 9,12,12,12, - 0,10,10, 0,11,11, 0,13,13, 0,11,11, 7, 6, 6,10, - 10,10, 0,11,11,11,11,11,12,12,12, 0,11,11, 0,12, - 12, 0,15,15, 0,11,11, 0,11,11, 0,11,11, 0,12,12, - 0,12,12, 0,14,14, 0,12,12, 0,12,12, 0,15,15, 0, - 11,11, 0, 8, 8, 0,10,10, 0,11,11, 0,11,11, 0,12, - 12, 0,12,12, 0,11,11, 0,15,15, 0,11,11, 0, 6, 6, - 0,10,10, 0,12,12, 0,10,10, 0,13,13, 0,12,12, 0, - 13,13, 0,14,14, 0,12,12, 0, 0, 0, 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 static_codebook _44p2_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p2_p3_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p2_p3_0, - 0 -}; - -static const long _vq_quantlist__44p2_p3_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p2_p3_1[] = { - 2, 3, 3, 0, 8, 8, 0, 8, 8, 0, 9, 9, 0, 9, 9, 0, - 9, 9, 0, 9, 9, 0, 9, 9, 0, 8, 8, 0, 6, 6, 0, 7, - 7, 0, 7, 7, 0, 8, 8, 0, 8, 8, 0, 8, 8, 0, 8, 8, - 0, 8, 8, 0, 8, 8, 0, 6, 6, 0, 6, 6, 0, 6, 6, 0, - 8, 8, 0, 9, 9, 0, 7, 7, 0, 8, 8, 0, 9, 9, 0, 6, - 6, 0, 8, 8, 0, 9, 9, 0, 9, 9, 0,10,10, 0,10,10, - 0,10,10, 0,10,10, 0,11,11, 0, 9, 9, 0, 7, 7, 0, - 10,10, 0,10,10, 0,12,11, 0,12,12, 0,11,11, 0,11, - 11, 0,12,12, 0,10,10, 0, 7, 7, 0,10,10, 0,10,10, - 0,12,12, 0,11,12, 0,11,11, 0,11,11, 0,11,11, 0, - 10,10, 0, 8, 8, 0, 9, 9, 0, 9, 9, 0,10,10, 0,10, - 10, 0,10, 9, 0,10,10, 0,10,10, 0, 9, 9, 0, 6, 6, - 0,10,10, 0,10,10, 0,11,11, 0,12,12, 0,11,11, 0, - 11,11, 0,12,12, 0,11,11, 0, 7, 7, 0, 9, 9, 0, 9, - 9, 0,11,11, 0,11,11, 0,10,10, 0,10,10, 0,11,11, - 0, 9, 9, -}; - -static const static_codebook _44p2_p3_1 = { - 5, 243, - (char *)_vq_lengthlist__44p2_p3_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p2_p3_1, - 0 -}; - -static const long _vq_quantlist__44p2_p4_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p2_p4_0[] = { - 1, 6, 6, 6, 7, 7, 7, 8, 8, 7, 8, 8,10,11,11, 9, - 8, 8, 7, 8, 8,11,11,11, 9, 8, 8, 6, 7, 7, 9,11, - 11, 9,11,11,10,11,11,12,13,13,11,12,12,10,11,11, - 13,14,14,12,12,12, 6, 6, 6, 8, 6, 6, 8, 7, 7, 9, - 7, 7,11,10,10,10, 6, 6, 9, 7, 7,12,10,10,11, 6, - 7, 7, 7, 7,11,10,10,12,10,10,11,10,10,14,13,13, - 13,10,10,12,11,11,15,13,13,14,10,10, 8, 7, 7,12, - 11,11,12,11,11,11,11,11,14,14,14,13,12,12,12,11, - 11,15,15,15,13,12,12, 0,10,10, 0,11,11, 0,11,11, - 0,11,11, 0,14,14, 0,11,11, 0,11,11, 0,15,15, 0, - 11,11, 7, 8, 8,12,10,10,12,10,10,12,11,11,15,13, - 13,14,11,11,12,10,10,16,14,14,14,10,10, 8, 7, 7, - 12,11,11,12,11,11,12,11,11,16,14,14,14,12,12,13, - 12,12,15,14,14,15,12,12, 0,11,11, 0,12,12, 0,12, - 12, 0,12,12, 0,15,15, 0,12,12, 0,12,12, 0,14,14, - 0,12,12, -}; - -static const static_codebook _44p2_p4_0 = { - 5, 243, - (char *)_vq_lengthlist__44p2_p4_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p2_p4_0, - 0 -}; - -static const long _vq_quantlist__44p2_p4_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p2_p4_1[] = { - 3, 4, 4, 8, 8,11, 9, 9,12,12,11,10,10,12,12,12, - 10,10,11,11,12,12,12,12,12,12,11,11,13,13,12,12, - 12,13,13,12,10,10,12,12,12,11,11,13,13,12,13,13, - 13,13,12,11,11,13,13,12,12,12,13,13,12,10,10,12, - 12,12,11,11,13,13,12,13,13,12,12,12,11,11,13,13, - 12,13,13,13,13,12,11,11,12,12,12,11,11,12,12,12, - 13,13,12,12,12,13,13,13,13,12,13,13,13,13,13,13, - 13,12,12,12,13,13,13,13,12,13,13,12,12,11, 8, 8, - 10,10,12,11,11,11,11,12,10,10,10,10,13,11,11,10, - 10,13,11,11,10,10,13,12,12,12,12,13,11,11,11,11, - 13,12,12,11,11,13,12,12,11,11,13,12,12,12,11,13, - 12,12,12,12,13,11,11,11,11,13,12,12,11,11,13,11, - 12,11,11,13,12,12,11,11,14,12,12,11,11,13,11,11, - 11,11,14,12,12,11,11,13,11,12,10,10,14,12,12,11, - 11,14,12,12,11,11,14,11,11,11,11,14,12,12,11,11, - 13,12,12,11,11,14,12,12,11,11,11, 8, 8,10,10,12, - 7, 7,10,10,12, 9, 9,11,11,13, 9, 9, 9, 9,13,13, - 13,10,10,13, 9, 9,12,12,13,13,13,12,12,13, 9, 8, - 11,11,13,10,10,12,12,14,13,13,11,11,13, 9, 9,11, - 11,13,13,13,12,12,13, 9, 9,10,10,13,10,10,11,11, - 13,13,13,10,10,14,10,10,11,11,14,14,14,12,12,13, - 9, 9,10,10,13,10,10,11,11,14,13,14,10,10,14,14, - 14,11,12,14,14,14,14,14,14,13,13,10,10,13,14,14, - 11,11,14,14,14,10,10,14, 9, 9, 9, 9,14, 9, 9, 9, - 9,14,10,10, 9, 9,14,10,10, 8, 8,14,11,11, 8, 8, - 15,11,11,10,10,15,12,12,10,10,15,10,10,10,10,15, - 11,11,10,10,15,13,13,10,10,15,11,11,10,10,15,12, - 12,10,10,15,10,10,10,10,15,11,11,10,10,15,13,13, - 10,10,15,11,11,10,10,15,12,12,10,10,15,11,11, 9, - 9,15,11,11, 9, 9,15,13,13, 9, 9,15,13,13,10,10, - 15,12,12,10,10,15,13,13,10,10,15,13,12, 9, 9,15, - 13,13, 9, 9,14,12,12, 9, 9,14,13,13, 9, 9,14,13, - 13, 9, 9,14,13,13, 7, 7,14,13,13, 8, 8,15,14,14, - 10,10,15,14,14,10,10,15,14,14,10,10,15,14,14,10, - 10,15,14,14, 9, 9,15,14,14,10,10,15,14,14,10,10, - 14,14,14, 9, 9,15,14,14,10,10,14,14,14, 9, 9,15, - 14,14,10,10,15,14,14,10,10,14,14,14, 9, 9,14,14, - 14, 9, 9,14,14,14, 8, 8,15,14,14,10,10,15,14,14, - 11,11,15,14,14, 9, 9,15,14,14, 9, 9,14,14,14, 8, - 8,13, 9, 9,12,12,17,11,11,12,12,17,12,12,12,12, - 17,12,12,11,11,18,15,15,12,12,17,12,12,12,12,17, - 14,15,13,13,17,12,12,12,12,17,13,13,12,13,17,15, - 15,12,12,18,13,13,13,13,18,15,15,13,13,18,12,12, - 12,12,18,13,13,13,13,18,15,15,12,12,18,13,13,12, - 12,18,15,15,13,13,18,13,13,12,12,17,13,13,12,12, - 17,15,15,12,12,18,15,15,13,13,18,15,15,13,14,18, - 15,16,12,12,18,15,15,12,12,18,16,16,12,12,13, 8, - 8,10,10,14,15,14,11,11,14,15,15,12,12,15,14,14, - 12,11,15,15,15,12,12,15,15,15,12,12,15,15,15,13, - 13,15,15,15,12,12,15,15,15,13,13,15,15,15,13,13, - 15,15,15,13,13,15,15,16,13,13,15,15,15,12,12,15, - 15,15,13,13,15,15,15,13,13,15,15,15,13,13,15,15, - 15,13,13,15,15,14,12,12,15,15,15,12,12,16,15,14, - 12,12,16,15,15,13,13,16,16,16,13,13,16,15,15,12, - 12,15,15,15,13,13,15,15,15,12,12,13,12,12,10,10, - 14,14,14,11,11,15,14,14,12,12,15,14,14,11,11,15, - 14,14,11,11,15,15,15,13,13,15,14,14,13,13,15,15, - 15,12,12,15,14,15,13,13,16,15,15,12,12,15,15,15, - 13,13,16,14,14,13,13,15,15,15,12,12,15,15,15,13, - 13,16,15,15,12,12,16,15,15,12,12,16,14,14,13,13, - 15,15,15,11,11,15,15,15,12,12,16,15,15,11,11,16, - 15,15,13,13,16,14,15,14,14,16,15,15,12,12,16,15, - 14,12,12,16,15,15,12,12,14,10,10, 9, 9,14,11,11, - 12,12,14,12,12,13,13,14,12,12,12,12,15,14,14,13, - 13,15,13,13,14,14,15,14,14,15,15,15,12,12,13,13, - 15,13,13,14,14,15,14,14,13,13,15,13,13,13,14,15, - 14,14,15,15,15,12,12,13,13,15,13,13,14,14,15,14, - 14,13,13,15,13,13,14,14,15,14,14,15,15,15,13,13, - 12,12,15,13,13,13,13,15,14,14,13,12,15,15,15,14, - 15,15,15,14,20,20,15,14,14,13,13,15,14,14,13,13, - 15,14,14,13,13,14,12,12, 9, 9,14,14,14,12,12,14, - 13,13,12,13,14,14,14,12,12,15,14,14,12,12,15,14, - 14,14,13,15,14,14,14,14,15,14,14,13,13,15,14,14, - 13,13,15,15,15,14,14,15,14,14,13,13,15,14,14,14, - 14,15,14,14,13,13,15,14,14,13,13,15,15,15,15,14, - 15,15,15,13,13,15,14,14,14,14,15,14,14,13,13,15, - 14,14,13,13,14,15,15,14,14,15,15,15,14,14,15,14, - 14,14,14,15,15,15,14,14,15,14,14,13,14,15,15,15, - 14,14,13,10,10,12,12,17,11,11,12,12,17,12,12,12, - 12,17,12,12,11,11,17,15,15,12,11,18,13,13,13,13, - 18,15,15,13,13,17,12,12,12,12,18,13,13,13,13,17, - 15,15,12,12,17,12,12,12,12,17,15,15,13,13,17,12, - 12,12,12,17,13,13,12,12,17,15,15,12,12,18,14,13, - 12,12,18,15,15,13,13,18,13,13,12,12,18,13,13,12, - 12,18,16,16,12,12,18,16,16,12,12,18,15,15,13,13, - 18,16,16,12,12,17,15,15,12,12,17,16,16,12,12,13, - 8, 8,10,10,14,14,15,12,12,14,15,15,12,12,15,14, - 14,12,12,15,15,14,12,12,15,15,15,13,13,15,15,15, - 13,13,15,15,15,12,12,16,15,15,13,13,16,15,15,13, - 13,15,15,15,12,12,15,15,15,14,14,15,15,15,12,12, - 15,15,15,13,13,16,15,15,13,13,15,15,15,13,13,16, - 15,15,13,13,15,15,14,12,12,15,15,15,12,12,16,14, - 15,13,13,16,15,15,13,13,15,16,15,13,13,16,15,14, - 13,13,16,15,15,13,13,16,15,15,13,13,13,12,12,11, - 11,14,14,14,11,11,14,14,14,12,12,15,14,14,11,11, - 16,14,14,11,11,15,15,15,12,13,16,14,14,13,13,15, - 15,15,12,12,15,14,14,13,13,16,15,15,12,12,15,15, - 15,12,12,15,14,14,13,13,15,15,15,12,12,15,14,14, - 12,12,16,15,15,12,12,16,15,15,12,12,16,14,14,13, - 13,15,15,15,11,11,15,15,14,12,12,16,15,15,11,11, - 16,15,15,12,12,16,14,14,13,13,16,15,15,11,11,16, - 14,14,12,12,16,15,15,11,11,14,10,10, 9, 9,14,11, - 11,12,12,14,12,12,13,14,14,12,12,12,12,14,14,14, - 13,13,15,13,13,14,14,15,14,14,15,15,15,12,12,13, - 13,15,13,13,14,14,15,15,15,14,14,15,13,13,14,14, - 15,15,15,15,15,15,12,12,13,13,15,13,13,14,14,15, - 14,14,13,13,15,13,13,14,14,15,14,14,15,15,15,12, - 12,13,13,15,13,13,13,13,14,14,14,13,13,15,15,15, - 14,15,15,15,15,21,19,15,14,14,13,13,15,14,14,14, - 14,14,14,14,13,13,14,12,12, 9, 9,14,14,14,12,12, - 14,14,13,13,13,14,14,14,12,12,14,14,14,12,12,15, - 14,14,13,13,15,14,14,14,14,15,14,14,13,13,15,14, - 14,13,13,15,15,15,15,15,15,14,14,13,13,15,14,14, - 14,14,15,14,14,13,13,15,14,14,13,13,14,15,15,15, - 15,15,14,15,13,13,15,14,14,14,14,15,14,14,13,13, - 15,14,14,13,13,14,15,15,14,14,15,15,15,14,14,15, - 14,14,14,14,15,15,15,15,15,15,14,14,14,13,14,15, - 15,14,14,13,10,10,12,12,18,12,12,12,12,17,12,12, - 12,12,18,13,13,11,11,18,15,14,11,11,17,13,13,13, - 13,18,15,15,12,12,18,12,12,12,12,17,13,13,12,12, - 18,15,15,12,12,18,13,13,13,12,18,15,15,13,13,18, - 13,13,12,12,18,13,13,12,12,18,15,15,12,12,17,13, - 13,12,12,17,15,15,12,12,17,12,12,11,11,17,13,13, - 11,11,17,15,15,11,11,18,16,16,12,12,18,15,15,13, - 13,18,15,15,11,11,17,15,15,12,12,18,15,15,11,11, - 13, 8, 8,10,10,14,14,14,11,11,15,15,15,12,12,15, - 14,14,11,11,16,14,14,12,12,15,15,15,12,12,15,15, - 15,13,13,15,15,15,12,12,15,15,15,12,12,16,15,15, - 13,13,15,15,15,12,12,15,15,15,13,13,16,15,15,12, - 12,15,15,15,12,12,16,15,15,13,13,16,15,15,12,12, - 15,15,15,13,13,15,14,14,12,12,15,15,15,12,12,16, - 15,14,12,12,16,15,15,13,13,16,16,16,13,13,16,14, - 15,13,13,15,15,15,13,13,16,15,15,12,12,13,12,12, - 10,10,14,14,14,11,11,15,14,14,12,12,15,14,14,11, - 11,16,14,14,11,11,15,14,15,12,12,15,14,14,13,13, - 15,15,15,12,12,15,14,14,12,12,15,14,15,12,12,15, - 15,15,12,12,16,14,14,13,13,15,15,15,11,12,16,14, - 14,12,12,16,15,15,12,12,15,15,15,12,12,16,14,14, - 12,12,15,15,15,11,11,15,14,14,11,12,15,15,14,11, - 11,16,15,15,12,12,16,14,14,13,13,16,15,15,11,11, - 16,14,14,12,12,16,15,15,11,11,13,10,10, 8, 8,14, - 12,12,12,12,14,12,12,13,13,14,12,12,12,12,14,14, - 14,13,13,15,13,13,14,14,15,15,14,15,15,15,13,13, - 13,13,15,13,13,14,14,15,14,15,14,14,15,13,13,13, - 13,15,15,15,15,15,15,12,12,13,12,15,13,13,14,14, - 15,14,14,13,13,15,13,13,14,13,15,15,15,16,16,15, - 13,13,12,12,15,13,13,13,13,14,14,14,12,12,15,15, - 15,14,14,15,15,15,20,20,15,14,14,13,13,15,15,14, - 14,14,15,14,14,13,13,13,12,12, 9, 9,14,13,13,12, - 12,14,13,13,12,12,14,14,14,12,12,14,14,14,13,13, - 15,14,14,13,13,15,14,14,14,14,15,15,14,12,12,15, - 14,14,13,13,15,14,15,14,15,15,14,14,13,13,15,14, - 14,14,14,15,14,14,12,12,15,14,14,13,13,14,15,14, - 15,14,15,14,14,13,13,15,14,14,14,14,15,14,14,12, - 12,15,14,14,13,13,15,15,15,14,14,15,15,15,14,14, - 16,14,14,14,14,15,15,15,14,14,15,14,14,14,14,14, - 15,15,14,14,13,13,13,12,13,17,15,15,12,12,17,15, - 15,12,12,18,15,15,11,11,17,16,16,11,11,18,16,16, - 13,13,18,17,16,13,13,18,16,16,12,12,18,16,16,12, - 12,18,17,17,12,12,17,16,16,12,13,17,16,16,12,13, - 17,16,16,12,12,17,16,16,12,12,18,17,16,12,12,18, - 16,16,12,12,17,16,17,12,12,18,15,15,11,11,18,15, - 15,12,12,17,17,17,11,11,17,17,17,12,12,17,16,16, - 13,13,18,16,16,11,11,18,16,16,12,12,18,17,16,11, - 11,14,14,14,10,10,16,15,14,11,11,16,15,15,12,12, - 16,14,14,12,12,17,14,14,13,13,17,15,15,13,13,17, - 15,15,14,14,16,15,15,12,12,16,15,15,13,13,18,15, - 15,14,14,16,15,15,12,12,16,15,15,14,14,16,15,15, - 12,12,16,15,15,13,13,17,15,15,13,13,17,15,15,13, - 13,17,15,15,14,14,16,14,14,12,12,17,15,15,12,12, - 18,15,15,13,13,17,15,15,14,14,17,16,16,15,15,17, - 15,14,13,13,17,15,15,14,14,17,15,15,13,13,14,12, - 12,11,11,15,14,14,12,12,16,14,14,12,12,16,14,14, - 11,11,17,14,14,12,12,16,15,14,13,13,16,14,14,13, - 13,16,15,15,12,12,16,14,14,13,13,17,15,15,13,13, - 16,15,15,13,13,17,14,14,13,13,16,15,15,12,12,16, - 14,14,12,12,16,15,15,12,12,17,15,15,12,12,17,14, - 14,13,13,16,15,15,12,12,16,14,14,12,12,16,15,15, - 12,12,17,15,15,13,13,17,14,14,13,13,17,15,15,12, - 12,17,14,14,12,12,17,15,15,12,12,14,14,14, 8, 8, - 14,14,14,13,13,14,15,15,14,14,14,14,14,14,14,15, - 15,15,19,19,15,15,15,14,14,15,15,16,20,19,15,15, - 15,14,14,15,16,16,15,15,15,15,15,19,19,15,15,15, - 14,14,15,16,16,19,20,15,15,15,14,14,15,15,15,15, - 15,15,15,15,19,19,15,15,15,15,15,15,15,16,19,20, - 15,14,15,14,14,15,15,15,15,15,15,15,15,20,19,15, - 15,15,21,19,15,16,16,20,20,15,15,14,19,19,15,15, - 16,20,21,15,15,15,20,19,13,12,12, 9, 9,14,14,14, - 12,12,14,13,13,13,13,14,14,14,13,13,15,14,14,20, - 19,15,14,14,14,13,15,14,14,19,19,15,15,14,13,13, - 15,14,14,14,14,15,15,15,19,20,15,14,14,13,13,15, - 14,14,20,19,14,15,14,13,13,15,14,14,14,13,15,15, - 15,19,20,15,15,14,14,14,15,14,14,21,19,15,15,15, - 13,13,15,14,14,14,14,14,15,15,20,20,15,15,15,21, - 20,15,14,14,19,20,15,15,15,20,20,15,14,14,19,20, - 15,15,15,21,19, -}; - -static const static_codebook _44p2_p4_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p2_p4_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p2_p4_1, - 0 -}; - -static const long _vq_quantlist__44p2_p5_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p2_p5_0[] = { - 2, 6, 6,14,14, 6, 7, 7,14,14, 7, 7, 7,15,15, 0, - 13,13,16,16, 0,13,13,15,15, 7, 8, 8,15,15, 9,10, - 10,17,16, 9, 8, 8,15,15, 0,13,13,18,17, 0,13,13, - 16,16, 8, 8, 8,15,15,12,11,11,16,17, 9, 8, 8,14, - 14, 0,13,13,18,17, 0,13,13,16,15, 0,14,14,18,17, - 0,20,22,18,20, 0,12,12,16,16, 0,16,16,22,20, 0, - 14,14,16,16, 0,14,14,17,17, 0,22,22,22,19, 0,12, - 13,16,16, 0,17,17, 0, 0, 0,15,15,16,16, 5, 7, 7, - 13,13, 9, 9, 9,15,14,10,10,10,14,14, 0,21,21,18, - 17, 0,21,22,18,17, 9,10,10,14,14,12,12,12,17,17, - 12,10,10,14,14, 0,19,21,18,17, 0,20,22,18,18,11, - 10,10,14,14,14,13,13,18,17,12,11,11,14,14, 0,22, - 19,17,18, 0,20, 0,18,17, 0,22,21,17,17, 0, 0, 0, - 0, 0, 0,20,22,17,17, 0,22, 0,21,19, 0,22, 0,18, - 18, 0, 0,22,18,19, 0, 0, 0, 0, 0, 0,19,21,17,17, - 0, 0, 0,20,20, 0, 0, 0,18,18, 6, 6, 6,13,12, 8, - 6, 6,11,11, 8, 6, 6,13,13, 0, 9, 9,11,11, 0,11, - 11,14,14, 9, 7, 7,13,13,11, 9, 9,13,13,10, 6, 6, - 13,13, 0,10,10,14,14, 0,10,10,13,13, 9, 7, 7,13, - 14,13, 9, 9,13,13,10, 6, 6,13,12, 0,11,11,15,15, - 0,10,10,13,13, 0,12,12,15,15, 0,19, 0,17,17, 0, - 9, 9,13,13, 0,13,14,19,20, 0,11,11,13,13, 0,11, - 11,14,14, 0,19,20,17,18, 0,10,10,13,13, 0,15,15, - 21,19, 0,12,12,13,13, 0,10,10,12,13, 0,11,11,15, - 15, 0,11,11,15,15, 0,15,15,22, 0, 0,16,17,22, 0, - 0,11,11,15,15, 0,14,14,18,17, 0,11,11,15,16, 0, - 15,15,22,21, 0,16,16, 0,20, 0,12,12,16,15, 0,15, - 14,19,19, 0,11,11,16,16, 0,15,15,21, 0, 0,16,15, - 0, 0, 0,16,16,22,21, 0, 0, 0, 0, 0, 0,15,15,20, - 20, 0,18,18, 0, 0, 0,16,17, 0, 0, 0,17,17, 0,22, - 0, 0, 0, 0, 0, 0,15,15,21,22, 0,20,18, 0, 0, 0, - 18,17,22, 0, 0,10,10,12,11, 0,10,10,10,10, 0,11, - 11,12,12, 0,11,11, 9, 9, 0,13,13,12,12, 0,11,11, - 12,12, 0,13,13,12,12, 0,10,10,12,12, 0,13,12,13, - 13, 0,12,12,12,12, 0,11,11,12,12, 0,13,13,12,12, - 0,10,10,12,12, 0,13,13,13,14, 0,12,12,12,12, 0, - 13,14,14,14, 0,20,21,15,15, 0,12,11,12,12, 0,15, - 16,20,22, 0,13,12,11,11, 0,13,13,14,13, 0,20, 0, - 16,15, 0,12,12,12,12, 0,16,16,22,21, 0,13,13,12, - 12, 6, 7, 7,16,16,11, 9, 9,15,15,12, 9, 9,16,16, - 0,13,13,14,14, 0,14,14,16,17,10, 9, 9,16,16,14, - 12,12,16,16,12, 9, 9,15,15, 0,13,13,18,18, 0,13, - 13,15,16,12,10,10,17,18,15,12,12,17,17,13, 9, 9, - 16,16, 0,13,13,17,18, 0,14,14,16,16, 0,15,15,18, - 18, 0,22, 0,20,20, 0,12,12,16,16, 0,16,16,20,22, - 0,14,14,16,16, 0,15,14,18,18, 0, 0,22,19,21, 0, - 13,13,16,17, 0,17,17,22,22, 0,15,15,16,16, 7, 7, - 7,14,14,11,10,10,15,15,12,10,10,15,14, 0,22, 0, - 18,18, 0, 0,21,17,18,11,10,10,15,15,14,12,12,17, - 17,14,11,11,15,15, 0,22,20,18,18, 0, 0,20,18,17, - 12,10,10,16,16,17,14,14,19,18,14,11,11,15,15, 0, - 21,22,19,19, 0,21,22,18,18, 0,22, 0,19,21, 0, 0, - 0, 0, 0, 0,22,22,18,17, 0, 0, 0,21,20, 0,22,22, - 20,19, 0, 0,22,20,20, 0, 0, 0, 0, 0, 0,20,21,17, - 17, 0, 0,22,21,21, 0, 0, 0,18,18,10, 9, 9,14,14, - 13,10,10,13,13,13,10,11,14,14, 0,13,13,12,12, 0, - 15,15,16,16,13,10,10,15,15,15,12,12,14,14,15,10, - 10,14,15, 0,14,14,16,15, 0,14,14,15,15,13,10,10, - 15,15,18,13,13,15,15,15,10,10,14,15, 0,14,14,16, - 16, 0,14,14,15,15, 0,15,15,16,16, 0,22, 0,18,18, - 0,12,13,14,14, 0,17,17,22, 0, 0,14,14,14,14, 0, - 15,15,16,16, 0,22, 0,18,17, 0,13,13,14,14, 0,19, - 18,21,22, 0,15,15,14,14, 0,11,11,13,13, 0,12,12, - 16,16, 0,12,12,16,16, 0,15,16,21, 0, 0,16,17, 0, - 22, 0,12,12,16,16, 0,14,14,17,18, 0,11,11,16,16, - 0,15,15,21,22, 0,16,16, 0, 0, 0,12,12,16,16, 0, - 15,15, 0,19, 0,12,12,16,17, 0,16,16,22, 0, 0,16, - 16, 0,22, 0,17,17, 0,22, 0, 0, 0, 0, 0, 0,15,15, - 20,19, 0,18,18, 0, 0, 0,17,18, 0, 0, 0,17,17, 0, - 0, 0, 0, 0, 0, 0, 0,15,15, 0,22, 0,20,18, 0, 0, - 0,18,18,22,22, 0,11,11,14,14, 0,12,12,14,14, 0, - 12,12,15,15, 0,13,13,14,14, 0,14,14,17,16, 0,12, - 12,16,16, 0,14,14,16,16, 0,11,11,15,15, 0,13,13, - 16,16, 0,13,13,15,15, 0,12,12,15,15, 0,15,14,16, - 16, 0,11,11,15,15, 0,14,14,17,17, 0,13,13,15,15, - 0,15,15,17,17, 0, 0, 0,19,18, 0,13,12,15,15, 0, - 16,16, 0, 0, 0,14,14,15,15, 0,14,14,16,17, 0,22, - 0,18,18, 0,13,13,15,15, 0,17,17, 0, 0, 0,14,14, - 15,15, 8, 8, 8,16,16,12,10,10,16,16,13, 9, 9,16, - 16, 0,14,14,17,17, 0,14,14,17,16,12,10,10,18,17, - 14,11,11,18,18,14, 9,10,16,16, 0,13,13,18,19, 0, - 14,13,16,16,12, 9, 9,16,16,17,13,13,17,17,14, 9, - 9,15,15, 0,14,14,19,20, 0,13,13,15,15, 0,15,15, - 18,19, 0, 0,22,22,22, 0,13,13,17,17, 0,16,16,19, - 21, 0,14,14,16,16, 0,14,14,18,18, 0, 0, 0, 0, 0, - 0,13,13,16,16, 0,18,18, 0, 0, 0,15,15,16,16, 8, - 7, 7,14,14,12,10,10,15,15,13,10,10,15,14, 0,22, - 0,18,18, 0,22, 0,18,18,12,10,10,16,15,15,12,12, - 17,17,14,11,11,15,15, 0,20,21,19,18, 0, 0, 0,17, - 18,13,11,11,15,15,16,13,13,18,18,15,11,11,14,14, - 0,22,21,19,19, 0,21,22,18,18, 0,22,22,20,18, 0, - 0, 0, 0, 0, 0,22,19,17,17, 0, 0, 0,22,21, 0, 0, - 22,19,17, 0, 0,22,19,19, 0, 0, 0, 0, 0, 0,22,21, - 18,17, 0, 0, 0,22, 0, 0, 0, 0,19,19, 0,10,10,14, - 14, 0,11,11,15,14, 0,11,11,15,15, 0,14,14,15,14, - 0,15,15,16,16, 0,11,11,16,16, 0,13,13,16,16, 0, - 11,11,15,15, 0,14,14,17,16, 0,14,14,15,15, 0,11, - 11,16,16, 0,14,13,15,15, 0,11,11,15,15, 0,15,15, - 17,17, 0,14,14,15,14, 0,16,16,17,17, 0, 0,22,18, - 18, 0,13,13,15,15, 0,17,17,22, 0, 0,15,15,15,14, - 0,15,16,16,17, 0, 0,22,18,19, 0,13,13,15,15, 0, - 20,18,21, 0, 0,15,15,14,14, 0,11,11,13,13, 0,12, - 12,16,16, 0,12,12,16,15, 0,15,16,22,22, 0,17,17, - 0, 0, 0,12,12,16,16, 0,14,14,18,18, 0,11,11,16, - 16, 0,15,16,22,20, 0,16,16, 0,22, 0,12,12,16,16, - 0,15,15,18,20, 0,11,11,16,16, 0,15,15, 0, 0, 0, - 16,16, 0, 0, 0,17,17,22, 0, 0, 0, 0, 0, 0, 0,15, - 15, 0,21, 0,18,18, 0, 0, 0,17,16, 0, 0, 0,17,17, - 22,22, 0, 0, 0, 0, 0, 0,15,15,21, 0, 0,20,22, 0, - 0, 0,18,18, 0, 0, 0,12,12,15,15, 0,12,12,15,15, - 0,12,12,16,16, 0,13,13,15,15, 0,15,15,17,17, 0, - 13,12,16,16, 0,14,14,16,16, 0,12,11,16,16, 0,14, - 14,17,17, 0,14,14,16,16, 0,12,12,16,16, 0,15,15, - 17,16, 0,11,11,15,16, 0,14,14,17,17, 0,14,14,16, - 16, 0,15,15,18,18, 0, 0, 0,22,19, 0,13,13,15,16, - 0,16,17, 0, 0, 0,14,14,16,16, 0,15,15,18,17, 0, - 0, 0,20,20, 0,13,13,16,15, 0,17,17,22,22, 0,14, - 14,15,15, 0,11,11,16,16, 0,13,13,16,17, 0,13,13, - 17,18, 0,16,16,17,17, 0,17,17,18,18, 0,12,12,17, - 17, 0,16,15,18,18, 0,12,12,16,16, 0,16,16,18,18, - 0,15,15,17,17, 0,12,12,17,17, 0,16,16,19,18, 0, - 12,12,16,17, 0,16,16,19,19, 0,15,16,16,17, 0,16, - 16,19,17, 0, 0, 0,20,22, 0,13,13,16,16, 0,19,18, - 21, 0, 0,15,15,16,16, 0,16,16,18,18, 0, 0, 0,22, - 21, 0,14,14,16,16, 0,21,19,21,22, 0,16,16,16,16, - 0, 9, 9,14,14, 0,13,13,15,15, 0,14,14,15,15, 0, - 0,20,18,19, 0, 0,22,18,18, 0,12,12,15,15, 0,15, - 15,17,18, 0,14,13,14,14, 0,20, 0,18,18, 0,21, 0, - 18,17, 0,13,13,15,16, 0,17,17,18,18, 0,14,14,15, - 15, 0,22,22,20,19, 0,20,21,18,18, 0,20,22,19,19, - 0, 0, 0, 0, 0, 0,20,20,17,17, 0, 0,22,22,21, 0, - 22, 0,18,18, 0,20,22,19,19, 0, 0, 0, 0, 0, 0,21, - 21,17,18, 0, 0, 0,21,20, 0, 0,22,19,18, 0,18,18, - 15,15, 0,22,21,17,16, 0, 0,22,17,17, 0,20,22,18, - 18, 0, 0,22,20,20, 0,21,19,16,16, 0,21,21,18,18, - 0,19,19,17,17, 0, 0,22,19,19, 0,22,20,17,17, 0, - 21,19,16,16, 0,22,22,19,18, 0,19,20,16,16, 0,22, - 21,19,21, 0,21,22,17,18, 0,21,20,18,18, 0, 0, 0, - 19,20, 0,20,19,16,16, 0,22,22, 0, 0, 0,21,21,17, - 16, 0,22,20,19,18, 0, 0, 0,20,20, 0,20,19,16,16, - 0, 0, 0, 0, 0, 0,21,22,17,17, 0,11,11,13,13, 0, - 13,13,15,16, 0,13,13,16,16, 0,17,18,21, 0, 0,17, - 18, 0, 0, 0,12,12,15,16, 0,15,15,19,18, 0,12,12, - 16,16, 0,17,17,22, 0, 0,17,17, 0,22, 0,12,12,17, - 16, 0,16,16,19,20, 0,12,12,16,16, 0,17,17, 0, 0, - 0,17,17, 0,21, 0,17,16,22, 0, 0, 0, 0, 0, 0, 0, - 15,15,20,22, 0,20,18, 0, 0, 0,18,18, 0, 0, 0,17, - 17,21, 0, 0, 0, 0, 0, 0, 0,15,15,21,22, 0,19,20, - 22, 0, 0,19,18, 0, 0, 0,14,14,18,18, 0,16,16,22, - 20, 0,16,16,22,19, 0,17,17,20,22, 0,19,19, 0, 0, - 0,15,15,20, 0, 0,18,21, 0,20, 0,15,15,21,20, 0, - 18,17, 0, 0, 0,17,17, 0,22, 0,15,15,19,19, 0,19, - 18, 0, 0, 0,15,15,20, 0, 0,18,18,22,22, 0,17,17, - 0,20, 0,18,18, 0, 0, 0, 0,22, 0, 0, 0,15,15,19, - 20, 0,20,19, 0, 0, 0,17,17,20,21, 0,17,18,20,22, - 0, 0, 0, 0,22, 0,15,15,20,20, 0,22,20, 0, 0, 0, - 17,18,20, 0, 0,12,12,17,16, 0,14,14,17,17, 0,13, - 13,17,17, 0,16,16,18,18, 0,17,16,17,17, 0,13,13, - 17,17, 0,15,16,18,18, 0,13,13,16,16, 0,16,16,18, - 18, 0,16,16,17,16, 0,13,13,16,16, 0,17,17,18,17, - 0,12,12,15,16, 0,17,17,19,19, 0,16,16,16,16, 0, - 16,17,19,18, 0, 0, 0,21,22, 0,14,14,16,16, 0,18, - 18, 0,22, 0,16,16,16,16, 0,16,16,18,17, 0, 0, 0, - 21,20, 0,14,14,16,16, 0,21,22,22, 0, 0,16,16,16, - 16, 0, 9, 9,14,13, 0,13,14,15,16, 0,14,13,15,14, - 0,22, 0,18,18, 0,21, 0,17,18, 0,13,13,15,15, 0, - 15,16,18,17, 0,14,14,15,14, 0,20,22,18,18, 0,22, - 21,17,17, 0,13,13,15,15, 0,17,17,19,19, 0,14,14, - 14,14, 0, 0,22,18,18, 0, 0,22,17,17, 0, 0,22,19, - 20, 0, 0, 0, 0, 0, 0,21,20,17,16, 0, 0, 0,21,22, - 0, 0, 0,18,19, 0, 0, 0,18,18, 0, 0, 0, 0, 0, 0, - 22, 0,17,17, 0, 0, 0,20,22, 0, 0, 0,18,19, 0,18, - 19,16,16, 0,22,20,17,17, 0,22,22,17,18, 0,22,22, - 18,17, 0, 0,22,18,19, 0,20,20,17,18, 0, 0,22,19, - 18, 0,22,22,17,17, 0,22, 0,19,19, 0, 0,22,18,18, - 0,20,22,17,17, 0, 0,22,18,18, 0,19,20,17,17, 0, - 22, 0,20,19, 0,22,21,17,17, 0, 0, 0,18,18, 0, 0, - 0,22,19, 0,20, 0,17,17, 0,22, 0, 0,22, 0, 0,20, - 17,18, 0,22, 0,19,19, 0, 0, 0, 0,19, 0,19,21,17, - 17, 0, 0, 0, 0, 0, 0,20,21,17,16, 0,11,11,13,13, - 0,13,13,16,16, 0,13,13,15,16, 0,17,17,21,22, 0, - 17,18, 0, 0, 0,12,12,16,16, 0,15,15,18,18, 0,13, - 13,16,16, 0,17,16,21,21, 0,17,17, 0, 0, 0,13,13, - 16,16, 0,16,16,19,18, 0,13,13,16,16, 0,17,17, 0, - 22, 0,17,18,20,22, 0,17,18, 0, 0, 0, 0, 0, 0, 0, - 0,15,15,20, 0, 0,18,19, 0, 0, 0,17,17, 0, 0, 0, - 18,17,22, 0, 0, 0, 0, 0, 0, 0,15,16,21,20, 0,20, - 20, 0, 0, 0,18,19, 0, 0, 0,15,15,22,22, 0,17,16, - 20,22, 0,17,17,20,22, 0,18,18, 0,21, 0,19,18, 0, - 0, 0,16,16,20,20, 0,19,19,22, 0, 0,15,16,21,22, - 0,18,19,22, 0, 0,17,18, 0, 0, 0,16,16,22, 0, 0, - 19,19, 0,21, 0,15,16,20, 0, 0,18,18, 0,22, 0,18, - 17, 0, 0, 0,18,18, 0, 0, 0, 0, 0, 0, 0, 0,16,16, - 22,21, 0,20,21, 0, 0, 0,17,18,22, 0, 0,18,18, 0, - 0, 0, 0, 0, 0, 0, 0,16,16,20,19, 0,22,21, 0, 0, - 0,18,18,22,22, -}; - -static const static_codebook _44p2_p5_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p2_p5_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p2_p5_0, - 0 -}; - -static const long _vq_quantlist__44p2_p5_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p2_p5_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p2_p5_1 = { - 1, 7, - (char *)_vq_lengthlist__44p2_p5_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p2_p5_1, - 0 -}; - -static const long _vq_quantlist__44p2_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p2_p6_0[] = { - 1, 7, 7, 7, 8, 8, 7, 8, 8, 7, 9, 9,10,11,11, 9, - 8, 8, 7, 8, 9,11,11,11, 9, 8, 8, 6, 7, 7,10,10, - 10,10,10,10,10,10,10,14,14,14,12,11,11,10,11,11, - 15,14,14,13,11,11, 6, 6, 6, 8, 5, 5, 8, 7, 7, 8, - 7, 7,11,10,10, 9, 7, 7, 9, 7, 7,12,10,10,10, 7, - 7, 6, 8, 7,12,10,10,12,10,10,11,10,10,15,14,13, - 13,10,10,11,10,10,16,14,14,14,10,10, 7, 7, 7,12, - 11,11,12,11,11,11,11,11,16,14,14,13,12,12,11,11, - 11,17,15,15,14,12,12,10, 9, 9,13,11,11,13,11,11, - 12,11,11,16,14,13,14,11,11,12,11,11,17,15,14,14, - 11,11, 7, 8, 8,12,11,11,12,10,10,12,10,10,16,13, - 14,13,10,10,11,10,10,17,14,14,14,10,10, 7, 7, 7, - 12,11,11,12,11,11,12,11,11,15,14,15,14,12,12,12, - 11,11,17,15,15,14,12,12,10,10, 9,13,11,11,13,11, - 11,13,11,11,16,14,14,14,11,11,13,11,11,16,15,15, - 15,11,11, -}; - -static const static_codebook _44p2_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p2_p6_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p2_p6_0, - 0 -}; - -static const long _vq_quantlist__44p2_p6_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p2_p6_1[] = { - 2, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 9, 9, 9, 8, - 7, 7, 8, 8, 8, 9, 9, 9, 9, 8, 8, 6, 7, 7, 9, 8, - 8, 9, 7, 7, 9, 8, 8,10, 8, 8,10, 8, 8,10, 8, 8, - 10, 8, 9,10, 8, 8, 7, 6, 6, 8, 6, 6, 9, 6, 6, 9, - 7, 7,10, 8, 8, 9, 6, 6, 9, 7, 7,10, 9, 8, 9, 7, - 7, 7, 7, 7,11, 8, 8,11, 9, 9,10, 9, 9,12, 9, 9, - 12, 8, 8,11, 9, 9,12, 9, 9,12, 8, 8, 8, 7, 7,10, - 9, 9,10, 9, 9,10, 9, 9,11,10,11,11, 9, 9,11, 9, - 9,11,11,11,11, 9, 9,10, 8, 8,11, 9, 9,10, 9, 9, - 11, 9, 9,11,10,10,11, 9, 9,11, 9, 9,12,10,10,11, - 9, 9, 8, 8, 8,11, 9, 9,12, 9, 9,11, 9, 9,12, 9, - 9,12, 8, 8,12, 9, 9,12, 9,10,12, 8, 8, 9, 7, 7, - 11, 9, 9,11,10,10,11, 9, 9,11,11,11,11, 9, 9,11, - 10,10,12,11,11,11, 9,10,10, 9, 9,11, 9, 9,11,10, - 10,11,10,10,11,11,11,11, 9, 9,11, 9,10,11,11,11, - 11, 9, 9, -}; - -static const static_codebook _44p2_p6_1 = { - 5, 243, - (char *)_vq_lengthlist__44p2_p6_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p2_p6_1, - 0 -}; - -static const long _vq_quantlist__44p2_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p2_p7_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p2_p7_0 = { - 5, 243, - (char *)_vq_lengthlist__44p2_p7_0, - 1, -513979392, 1633504256, 2, 0, - (long *)_vq_quantlist__44p2_p7_0, - 0 -}; - -static const long _vq_quantlist__44p2_p7_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p2_p7_1[] = { - 1, 9, 9, 6, 9, 9, 5, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10, -}; - -static const static_codebook _44p2_p7_1 = { - 5, 243, - (char *)_vq_lengthlist__44p2_p7_1, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p2_p7_1, - 0 -}; - -static const long _vq_quantlist__44p2_p7_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p2_p7_2[] = { - 1, 3, 2, 5, 4, 7, 7, 8, 8, 9, 9,10,10,11,11,12, - 12,13,13,14,14,15,15,15,15, -}; - -static const static_codebook _44p2_p7_2 = { - 1, 25, - (char *)_vq_lengthlist__44p2_p7_2, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p2_p7_2, - 0 -}; - -static const long _vq_quantlist__44p2_p7_3[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p2_p7_3[] = { - 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p2_p7_3 = { - 1, 25, - (char *)_vq_lengthlist__44p2_p7_3, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p2_p7_3, - 0 -}; - -static const char _huff_lengthlist__44p2_short[] = { - 4, 4,12, 9, 8,12,15,17, 4, 2,11, 6, 5, 9,13,15, - 11, 7, 8, 7, 7,10,14,13, 8, 5, 7, 5, 5, 8,12,12, - 8, 4, 7, 4, 3, 6,11,12,11, 8, 9, 7, 6, 8,11,12, - 15,13,14,12, 9, 7,10,13,16,12,17,12, 7, 5, 8,11, -}; - -static const static_codebook _huff_book__44p2_short = { - 2, 64, - (char *)_huff_lengthlist__44p2_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p3_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p3_l0_0[] = { - 1, 4, 4, 8, 8, 8, 8, 9, 9,10,10,10,10, 4, 6, 5, - 8, 7, 9, 9, 9, 9,10, 9,11, 9, 4, 5, 6, 7, 8, 9, - 9, 9, 9, 9,10, 9,10, 8, 9, 8, 9, 8,10, 9,11, 9, - 12,10,12,10, 8, 8, 9, 8, 9, 9,10, 9,11,10,12,10, - 12, 9,10,10,11,10,12,11,12,11,12,12,12,12, 9,10, - 10,11,11,11,11,11,12,12,12,12,12,10,11,11,12,12, - 12,12,12,12,12,12,12,12,10,11,11,12,12,12,12,12, - 12,12,12,12,12,11,12,12,12,12,12,13,12,13,12,13, - 12,12,11,12,12,12,12,12,12,13,12,12,12,12,12,12, - 12,12,13,13,12,13,12,13,12,13,12,12,12,13,12,13, - 12,13,12,13,12,13,12,12,12, -}; - -static const static_codebook _44p3_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p3_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p3_l0_0, - 0 -}; - -static const long _vq_quantlist__44p3_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p3_l0_1[] = { - 3, 4, 4, 5, 5, 4, 4, 5, 5, 5, 4, 5, 4, 5, 5, 5, - 5, 6, 5, 6, 5, 6, 5, 6, 5, -}; - -static const static_codebook _44p3_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p3_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p3_l0_1, - 0 -}; - -static const long _vq_quantlist__44p3_l1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p3_l1_0[] = { - 1, 4, 4, 4, 4, 4, 4, 4, 4, -}; - -static const static_codebook _44p3_l1_0 = { - 2, 9, - (char *)_vq_lengthlist__44p3_l1_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p3_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p3_lfe[] = { - 1, 3, 2, 3, -}; - -static const static_codebook _huff_book__44p3_lfe = { - 2, 4, - (char *)_huff_lengthlist__44p3_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p3_long[] = { - 3, 4,13, 9, 9,12,15,17, 4, 2,18, 5, 7,10,14,18, - 11, 8, 6, 5, 6, 8,11,14, 8, 5, 5, 3, 5, 8,11,13, - 9, 6, 7, 5, 5, 7, 9,10,11,10, 9, 8, 6, 6, 8,10, - 14,14,11,11, 9, 8, 9,10,17,17,14,13,10, 9,10,10, -}; - -static const static_codebook _huff_book__44p3_long = { - 2, 64, - (char *)_huff_lengthlist__44p3_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p3_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p3_p1_0[] = { - 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44p3_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p3_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p3_p1_0, - 0 -}; - -static const long _vq_quantlist__44p3_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p3_p2_0[] = { - 3, 7, 7, 0, 0, 0, 8, 8, 0, 0, 0, 8, 8, 0, 0, 0, - 11,11, 0, 0, 0, 0, 0, 0, 0, 0,10, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0,10,11, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0, - 0, 0, 0, 0, 0, 0,11,11, 0, 0, 0,12,12, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, - 5, 5, 0, 0, 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, - 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, - 0, 0, 0, 0, 0, 0, 0, 5, 6, 0, 0, 0, 7, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0,11,11, 0, 0, 0, 9, 9, 0, - 0, 0,10,10, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, - 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, - 10,10, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, - 0, 0, 0,11,12, 0, 0, 0, 0, 0, 0, 0, 0,11,11, 0, - 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 7, 7, 0, 0, 0, 8, 8, 0, 0, - 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, - 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0,11,11, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, - 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 7, 7, - 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, - 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, - 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 0, 0, 0, 7, 7, 0, 0, 0, 8, 8, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 8, 7, 0, 0, 0, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 7, - 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0,11,11, - 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 7, - 7, 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, - 9, 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0,10,10, 0, 0, 0, 9, 9, 0, 0, 0,10,10, - 0, 0, 0,11,12, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0,11,11, 0, 0, - 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0,11, - 11, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0,12,12, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, - 9, 9, 0, 0, 0,10,10, 0, 0, 0,12,12, 0, 0, 0, 0, - 0, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, - 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0,11,11, 0, 0, - 0, 0, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, - 10,10, 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44p3_p2_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p3_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p3_p2_0, - 0 -}; - -static const long _vq_quantlist__44p3_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p3_p3_0[] = { - 1, 5, 5, 5, 8, 8, 0, 8, 8, 6, 9, 9, 8,10,10, 0, - 8, 8, 0, 9, 9, 0,12,12, 0, 8, 8, 4, 7, 7, 6,10, - 10, 0,12,12, 7,11,11, 9,12,12, 0,12,12, 0,13,13, - 0,15,15, 0,12,12, 0, 7, 7, 0, 7, 7, 0, 8, 8, 0, - 8, 8, 0,10,10, 0, 7, 7, 0, 8, 8, 0,11,11, 0, 7, - 7, 5, 7, 7, 9, 9, 9, 0,11,10, 9, 9, 9,11,12,12, - 0,10,10, 0,11,11, 0,13,13, 0,11,11, 6, 7, 7, 9, - 10,10, 0,12,12,10,11,11,11,12,12, 0,12,12, 0,13, - 13, 0,15,15, 0,12,12, 0,10,10, 0,11,11, 0,11,11, - 0,12,12, 0,13,13, 0,11,11, 0,12,12, 0,15,15, 0, - 11,11, 0, 8, 8, 0,10,10, 0,12,12, 0,11,11, 0,12, - 12, 0,12,12, 0,12,12, 0,15,15, 0,11,11, 0, 7, 7, - 0,10,10, 0,12,12, 0,10,10, 0,12,13, 0,12,12, 0, - 13,13, 0,14,14, 0,12,12, 0, 0, 0, 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 static_codebook _44p3_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p3_p3_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p3_p3_0, - 0 -}; - -static const long _vq_quantlist__44p3_p3_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p3_p3_1[] = { - 3, 4, 4, 0, 8, 8, 0, 8, 8, 0, 9, 9, 0,10,10, 0, - 8, 8, 0, 9, 9, 0,10,10, 0, 8, 8, 0, 7, 7, 0, 8, - 8, 0, 8, 8, 0, 8, 8, 0, 8, 8, 0, 8, 8, 0, 8, 8, - 0, 8, 8, 0, 8, 8, 0, 7, 7, 0, 6, 6, 0, 7, 7, 0, - 7, 7, 0,10,10, 0, 6, 6, 0, 7, 7, 0,10,10, 0, 6, - 5, 0, 8, 8, 0, 7, 7, 0, 8, 8, 0, 8, 8, 0, 9, 9, - 0, 7, 7, 0, 8, 8, 0, 9, 9, 0, 7, 7, 0, 6, 6, 0, - 9,10, 0,10,10, 0,10,10, 0,11,11, 0, 9, 9, 0,10, - 10, 0,11,11, 0, 9, 9, 0, 8, 8, 0, 8, 8, 0, 8, 8, - 0, 9, 9, 0, 9, 9, 0, 8, 8, 0, 8, 8, 0, 9, 9, 0, - 7, 7, 0, 8, 8, 0, 7, 7, 0, 7, 7, 0, 8, 8, 0, 9, - 9, 0, 7, 7, 0, 7, 7, 0, 9, 9, 0, 6, 6, 0, 6, 6, - 0,10,10, 0,10,10, 0,10,10, 0,12,12, 0, 9, 9, 0, - 10,10, 0,12,12, 0, 9, 9, 0, 8, 8, 0, 7, 7, 0, 8, - 8, 0, 8, 8, 0, 9, 9, 0, 7, 7, 0, 8, 8, 0, 9, 9, - 0, 7, 7, -}; - -static const static_codebook _44p3_p3_1 = { - 5, 243, - (char *)_vq_lengthlist__44p3_p3_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p3_p3_1, - 0 -}; - -static const long _vq_quantlist__44p3_p4_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p3_p4_0[] = { - 1, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8,10,11,11, 9, - 8, 8, 8, 8, 8,11,11,11,10, 8, 8, 5, 7, 7, 9,11, - 11,10,11,11,10,11,11,12,13,14,11,12,12,10,11,11, - 13,14,14,12,12,12, 5, 6, 6, 8, 6, 6, 8, 7, 7, 8, - 7, 7,11,10,10,10, 7, 7, 9, 7, 7,12,11,11,11, 7, - 7, 7, 7, 7,11,10,10,12,10,10,11,10,10,15,13,13, - 13,10,10,12,11,11,15,13,13,14,11,11, 7, 7, 7,11, - 11,11,12,11,11,12,11,11,14,14,14,14,12,12,12,12, - 12,16,15,15,14,12,12, 0,10,10, 0,11,11, 0,11,12, - 0,11,11, 0,14,14, 0,11,11, 0,12,12, 0,15,15, 0, - 11,11, 8, 8, 8,12,10,10,12,10,10,13,11,11,15,13, - 13,14,11,11,12,10,10,16,14,14,14,10,10, 8, 7, 7, - 12,11,11,13,11,11,12,11,11,15,14,14,14,12,12,13, - 12,12,15,14,14,15,12,12, 0,11,11, 0,12,12, 0,12, - 12, 0,12,12, 0,15,15, 0,12,12, 0,13,13, 0,14,15, - 0,12,12, -}; - -static const static_codebook _44p3_p4_0 = { - 5, 243, - (char *)_vq_lengthlist__44p3_p4_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p3_p4_0, - 0 -}; - -static const long _vq_quantlist__44p3_p4_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p3_p4_1[] = { - 3, 4, 5, 8, 8,12,10,10,12,12,12,10,10,12,12,13, - 11,11,12,12,13,12,12,12,12,13,10,10,13,13,13,13, - 13,13,13,13,10,10,13,13,13,11,11,13,13,14,13,13, - 12,12,13,10,10,13,13,13,13,13,13,13,13,10,10,12, - 12,13,11,11,13,13,13,13,13,12,12,13,12,12,13,13, - 13,13,13,13,13,14,11,11,12,12,14,12,12,13,12,14, - 14,14,12,12,13,14,14,13,13,14,13,13,13,13,14,14, - 14,12,12,14,13,13,13,13,14,14,14,12,12,12, 8, 8, - 11,11,12,12,12,11,11,12,11,11,10,10,13,12,12,10, - 10,13,12,12,10,10,13,12,12,12,12,14,12,12,12,12, - 13,13,13,11,11,14,12,12,11,11,14,12,12,12,12,14, - 12,12,12,12,13,12,12,12,12,13,13,13,11,11,14,12, - 12,11,11,14,12,12,12,12,14,13,13,12,12,14,12,12, - 12,11,14,13,13,11,11,14,13,12,11,11,14,13,13,11, - 11,14,13,13,12,12,14,12,12,12,12,15,13,13,12,12, - 14,12,12,11,11,14,13,13,11,11,12, 9, 9,10,10,12, - 7, 7,11,11,12, 9, 9,12,12,13,10,10,10,10,14,14, - 14,11,11,13, 9, 9,12,12,14,14,14,12,12,13, 8, 8, - 11,11,14, 9, 9,12,12,14,14,14,11,11,13, 9, 9,12, - 12,14,14,14,12,12,14, 8, 8,11,11,14, 9, 9,12,12, - 14,14,14,11,11,14,10,10,12,12,14,14,14,13,13,14, - 9, 9,11,11,14,10,10,12,12,14,14,14,11,11,14,14, - 15,12,12,15,14,14,14,14,15,14,14,11,11,14,14,14, - 12,12,14,14,14,11,11,14,11,11,10,10,14,10,10,10, - 10,14,10,10,10,10,15,11,11, 9, 9,14,12,12, 9, 9, - 15,11,11,11,11,15,13,13,11,11,15,10,10,10,10,15, - 11,11,10,10,15,13,13,11,11,15,11,11,11,11,15,13, - 13,11,11,15,10,10,10,10,15,11,11,10,10,15,13,13, - 11,11,15,12,12,11,11,15,13,13,11,11,15,11,11,10, - 10,15,12,12,10,10,15,13,13,10,10,15,14,14,11,11, - 15,13,13,11,11,15,14,14,10,11,15,13,13,10,10,15, - 13,14,10,10,14,13,13,10,10,14,13,13,10,10,14,13, - 13,10,10,14,13,13, 9, 9,14,14,14, 9, 9,15,14,14, - 11,11,15,14,14,10,10,15,14,14,10,10,15,14,14,11, - 11,15,14,14,10,10,15,14,14,11,11,15,14,14,10,10, - 14,14,14,10,10,15,14,14,10,10,14,14,14,10,10,15, - 14,14,11,11,15,14,14,11,11,14,14,14,10,10,15,14, - 14,10,10,14,14,14, 9, 9,15,15,15,11,11,15,14,14, - 12,12,15,15,14,10,10,15,14,14,10,10,14,15,15, 9, - 9,14,10,10,12,12,17, 9, 9,12,12,17,10,10,13,13, - 17,11,11,12,12,18,14,14,12,12,17,10,10,13,13,17, - 14,14,12,12,17, 9, 9,12,12,17,11,11,12,12,17,14, - 14,12,12,18,10,10,13,13,18,14,14,13,13,18, 9, 9, - 12,12,18,10,10,13,13,18,14,14,12,12,18,11,11,13, - 13,18,14,14,13,13,18,10,10,12,12,17,11,11,12,12, - 17,14,14,12,12,18,15,15,13,13,18,14,14,14,14,18, - 15,15,12,12,18,14,14,12,12,18,15,15,12,12,13, 7, - 7,11,11,14,15,15,11,11,14,15,15,12,12,14,15,15, - 11,11,15,15,15,11,11,14,15,15,12,12,14,15,15,12, - 12,14,15,15,11,11,14,15,15,11,11,15,15,15,12,12, - 14,15,15,12,12,14,15,15,12,12,14,15,15,11,11,14, - 15,15,11,11,15,15,15,12,12,15,15,15,12,12,14,15, - 15,12,12,14,15,14,12,12,14,15,15,11,11,15,14,14, - 12,12,15,15,15,12,12,15,16,16,12,12,15,15,15,12, - 12,15,15,15,12,12,15,15,15,12,12,13,13,13,11,10, - 14,14,15,11,11,14,14,14,12,12,15,14,14,10,10,15, - 15,15,11,11,14,15,15,12,12,14,14,14,11,11,14,15, - 15,11,11,14,15,15,12,12,15,15,15,11,11,14,15,15, - 12,12,14,14,14,12,12,14,15,15,11,11,14,15,15,12, - 12,15,15,15,11,11,15,15,15,12,12,15,14,14,12,12, - 14,15,15,11,11,14,15,15,11,11,15,15,15,10,10,15, - 15,16,12,12,15,15,15,14,14,15,15,15,11,11,15,15, - 15,12,12,15,15,15,11,11,14,11,11,10,10,15, 9, 9, - 12,12,15,10,10,12,12,15,11,11,11,11,15,14,14,12, - 12,15,10,10,13,13,15,14,14,12,12,15, 9, 9,12,12, - 15,10,10,13,13,15,13,13,12,11,15,10,10,12,12,15, - 14,14,12,12,15, 9, 9,11,11,15,11,11,12,12,15,13, - 13,11,11,15,11,11,13,13,15,13,14,13,14,15,11,11, - 11,11,15,11,11,12,12,15,14,14,11,11,15,14,14,13, - 13,15,14,14,20,20,15,14,14,12,12,15,14,14,12,12, - 15,14,14,11,11,14,13,13,10,10,14,13,13,12,12,14, - 14,13,12,12,15,14,14,12,12,15,14,14,11,11,15,14, - 14,12,12,15,14,14,13,13,15,14,14,12,11,15,14,14, - 11,11,15,14,14,13,13,15,14,14,12,12,15,14,14,13, - 13,15,14,14,12,11,15,14,14,12,12,15,14,14,13,13, - 15,14,14,13,13,15,14,14,12,12,15,14,14,12,12,15, - 14,14,12,12,15,15,15,13,13,15,15,15,13,13,15,14, - 14,13,13,15,15,15,13,13,15,14,15,12,12,15,15,15, - 13,13,14,10,10,12,13,17, 9, 9,12,12,17,10,10,13, - 13,17,11,11,12,12,18,14,14,12,12,18,10,10,13,13, - 18,14,14,12,12,17, 9, 9,12,12,18,10,11,13,13,18, - 14,14,12,12,17,10,10,12,12,17,14,14,12,12,17, 9, - 9,12,12,17,11,11,12,12,17,14,14,12,12,18,11,11, - 12,12,18,14,14,13,13,18,11,11,12,12,18,11,11,12, - 12,18,14,14,12,12,18,15,15,12,12,18,14,14,13,13, - 18,15,15,12,12,17,14,14,12,12,17,15,15,12,12,13, - 7, 7,11,11,14,15,15,11,11,14,15,15,11,11,14,15, - 14,12,12,15,15,15,12,11,14,15,15,12,12,14,15,15, - 12,12,14,15,15,11,11,14,15,15,11,11,15,15,15,13, - 13,14,15,15,11,11,14,15,15,13,12,14,15,15,11,11, - 14,15,15,11,11,15,15,15,13,13,14,15,15,12,12,15, - 15,15,12,12,15,15,15,11,11,15,15,15,11,11,15,15, - 15,12,12,15,15,15,13,13,15,16,16,12,12,15,15,15, - 12,13,15,15,15,12,12,15,15,15,12,12,13,13,13,11, - 11,14,14,14,11,11,14,14,14,12,12,14,14,14,10,10, - 15,14,14,11,11,14,15,15,12,12,14,14,14,12,12,14, - 15,15,11,11,14,15,14,12,12,15,14,14,11,11,14,15, - 15,12,12,14,14,14,11,11,14,15,15,11,11,14,14,14, - 12,12,15,15,14,11,11,15,15,15,12,12,15,14,14,12, - 12,14,15,15,11,11,14,15,14,11,11,15,15,15,10,10, - 15,15,15,12,12,15,14,14,14,13,15,15,15,11,11,15, - 15,15,11,11,15,15,15,10,10,14,11,11,10,10,15, 9, - 9,12,12,15,10,10,12,12,15,11,11,11,11,15,14,14, - 12,12,15,10,10,13,13,15,13,13,12,12,15, 9, 9,12, - 12,15,11,11,13,13,15,14,14,12,12,15,10,10,13,13, - 15,13,14,12,12,15, 9, 9,12,12,15,10,10,13,13,15, - 13,13,11,11,15,11,11,13,13,15,14,14,13,13,15,10, - 10,11,11,15,11,11,12,12,15,14,14,11,11,15,14,14, - 13,13,15,14,14,21,20,15,14,14,11,11,15,14,14,12, - 12,15,14,14,11,11,14,13,13,10,10,14,13,13,11,11, - 15,14,14,12,12,15,14,14,12,12,14,14,14,12,12,15, - 14,14,12,12,15,14,14,13,13,14,14,14,11,11,15,14, - 14,11,11,15,14,14,13,13,15,14,14,12,12,15,14,14, - 13,13,14,14,14,11,11,15,14,14,11,11,14,14,14,13, - 13,15,14,14,12,12,15,14,14,12,12,15,14,14,12,12, - 15,14,14,12,12,14,14,14,13,13,15,15,15,13,13,16, - 14,14,12,13,15,15,15,13,13,15,14,14,12,12,15,15, - 15,13,13,15,11,11,13,12,18,10,10,12,12,17,11,11, - 12,12,18,12,12,11,11,18,14,14,12,12,18,11,11,13, - 13,17,14,14,12,12,18,10,10,12,12,18,12,12,12,12, - 18,14,15,12,12,18,11,11,13,13,18,14,14,12,12,17, - 10,10,12,12,18,11,11,12,12,18,15,14,12,12,17,12, - 12,12,12,17,14,14,12,12,17,11,11,11,11,17,12,12, - 12,11,17,15,15,11,11,18,15,15,12,12,18,14,15,13, - 13,18,15,15,11,11,17,15,15,12,12,18,15,15,11,11, - 14, 9, 9,11,11,14,15,15,11,11,15,15,15,11,11,15, - 15,15,12,11,15,15,15,12,12,15,15,15,11,11,15,15, - 15,13,13,14,15,15,11,11,15,15,15,11,11,15,15,15, - 13,13,15,15,15,11,11,15,15,15,13,13,15,15,15,11, - 11,15,15,15,11,11,15,15,15,13,13,15,15,15,12,12, - 15,15,15,13,13,15,15,14,11,11,15,15,15,12,12,15, - 15,15,12,12,16,15,15,13,13,15,16,16,13,13,16,15, - 15,12,12,15,15,15,13,12,15,15,15,12,12,13,12,12, - 11,11,14,14,14,11,11,14,14,14,12,12,15,14,14,11, - 11,15,14,14,12,12,15,14,14,12,12,15,14,14,12,12, - 14,15,15,11,11,15,14,14,12,12,15,14,14,11,11,15, - 14,14,12,12,15,14,14,12,12,14,15,15,11,11,15,14, - 14,12,12,15,14,14,11,11,15,15,15,12,12,15,14,14, - 12,12,15,15,15,11,11,15,14,14,11,11,15,14,15,11, - 11,15,15,15,12,12,15,14,14,13,13,16,15,15,11,11, - 15,14,14,12,12,15,15,15,11,11,14,11,11, 9, 9,15, - 10,10,12,12,14,11,11,12,12,15,12,12,12,12,15,14, - 14,13,13,15,11,11,13,13,15,14,14,13,13,15,10,10, - 12,12,15,12,12,13,13,15,14,14,13,13,15,11,11,12, - 12,15,14,14,13,13,14,10,10,12,12,15,12,12,13,13, - 15,14,14,12,12,15,12,12,13,13,15,14,14,15,15,15, - 11,11,12,12,15,12,12,12,13,15,14,14,12,12,15,15, - 15,14,14,15,14,14,20,20,15,14,14,12,12,15,14,14, - 13,13,15,14,14,12,12,14,13,13,10,10,14,13,13,11, - 11,14,13,13,12,12,14,14,14,12,12,15,14,14,13,13, - 15,14,14,12,12,14,14,14,14,14,14,14,14,11,11,15, - 14,14,12,12,15,14,14,14,14,15,14,14,12,12,14,14, - 14,14,14,14,14,14,11,11,15,14,14,12,12,14,14,14, - 14,14,15,14,14,12,12,15,14,14,13,13,15,14,14,12, - 12,15,14,14,12,12,14,14,14,14,13,15,15,15,14,14, - 15,14,14,13,13,15,15,15,14,14,15,14,14,13,13,15, - 15,15,13,13,14,13,13,13,13,18,15,15,12,12,18,15, - 15,13,12,18,15,16,11,11,18,16,17,12,12,18,15,15, - 13,13,18,17,17,12,12,18,15,15,12,12,17,15,15,12, - 12,18,17,17,12,12,18,15,15,13,13,18,16,17,12,12, - 17,15,15,12,12,18,15,15,12,12,18,16,17,11,12,18, - 16,16,12,12,17,16,17,12,12,18,15,15,11,11,18,15, - 15,12,12,18,17,17,11,11,17,17,17,12,12,18,16,16, - 13,13,18,17,17,11,11,18,16,16,12,12,18,17,17,11, - 11,15,14,14,11,11,16,15,15,11,11,16,15,15,12,12, - 16,15,15,12,12,17,15,15,14,13,16,15,15,12,12,17, - 15,15,14,14,16,15,15,11,11,16,15,15,12,12,18,15, - 15,13,13,16,15,15,11,11,17,15,15,14,14,16,15,15, - 11,11,16,15,15,12,12,17,15,15,13,13,16,15,15,12, - 12,17,16,15,14,14,16,14,15,12,12,16,15,15,12,12, - 18,15,15,13,13,17,15,15,14,14,17,16,16,15,15,17, - 15,15,13,13,17,15,15,14,14,18,15,15,13,13,15,12, - 13,11,11,15,14,14,12,12,16,14,14,12,12,16,14,14, - 12,12,16,14,14,12,12,16,14,14,13,12,17,14,14,13, - 13,16,15,15,12,12,16,14,14,12,12,17,14,14,12,12, - 16,14,14,12,12,17,14,14,13,13,15,15,15,12,12,16, - 14,14,12,12,17,14,14,12,12,17,15,15,12,12,17,14, - 14,13,13,16,15,15,12,12,16,14,14,12,12,17,15,15, - 12,12,18,15,15,13,13,17,14,14,13,13,17,15,15,12, - 12,17,14,14,12,12,17,15,15,12,12,14,15,15, 9, 9, - 15,15,15,12,12,15,15,15,13,13,15,15,15,14,14,15, - 15,15,19,19,15,15,16,13,13,15,15,16,19,20,15,15, - 15,13,12,15,16,16,14,14,15,15,15,19,19,15,15,15, - 13,13,15,16,15,20,19,14,15,15,13,13,15,15,15,14, - 14,15,15,15,19,19,15,15,15,14,14,15,16,16,19,20, - 15,15,15,14,14,15,15,15,14,14,15,15,15,19,19,15, - 15,15,20,19,15,16,16,20,19,15,15,15,19,19,15,16, - 16,20,20,15,15,15,19,20,14,13,13,10,10,14,14,14, - 11,11,14,14,14,12,12,15,14,14,13,13,15,14,14,19, - 20,15,14,14,12,12,14,14,14,20,19,14,14,14,11,11, - 15,14,14,12,12,15,14,14,20,20,15,14,14,12,12,14, - 14,14,20,19,14,14,14,11,11,15,14,14,12,12,15,14, - 14,19,20,15,14,14,13,13,15,14,14,22,19,15,15,14, - 12,12,15,14,14,13,13,14,15,15,22,20,15,15,15,20, - 20,15,14,14,21,20,15,15,15,20,21,15,14,14,20,20, - 14,15,15,20,20, -}; - -static const static_codebook _44p3_p4_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p3_p4_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p3_p4_1, - 0 -}; - -static const long _vq_quantlist__44p3_p5_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p3_p5_0[] = { - 2, 6, 6,14,14, 6, 7, 7,14,14, 7, 7, 7,15,15, 0, - 12,12,15,15, 0,13,13,15,15, 7, 8, 8,15,15,10,10, - 10,16,16, 9, 8, 8,15,15, 0,13,13,18,17, 0,13,13, - 16,16, 8, 8, 8,15,15,12,11,11,16,16, 9, 8, 8,15, - 15, 0,13,13,18,18, 0,13,13,16,16, 0,14,14,17,17, - 0,20, 0,19,20, 0,12,12,16,16, 0,16,16,20,22, 0, - 14,14,16,16, 0,14,14,17,17, 0,20,22,20,19, 0,13, - 13,15,16, 0,17,18, 0,21, 0,15,15,16,16, 5, 7, 7, - 13,13, 8, 9, 9,14,14,10,10,10,14,14, 0,20,22,18, - 18, 0,22,21,18,17, 9,10,10,14,14,12,12,12,17,17, - 12,10,10,14,14, 0, 0,20,17,17, 0,22,21,17,18,11, - 10,10,14,14,14,13,13,18,18,12,11,11,14,14, 0,22, - 21,18,19, 0,20, 0,17,17, 0,22, 0,18,18, 0, 0, 0, - 0, 0, 0,20,20,17,17, 0,22, 0,22,21, 0,21, 0,19, - 18, 0,22,22,18,18, 0, 0, 0, 0, 0, 0,21, 0,17,17, - 0,22, 0,20,20, 0, 0, 0,19,18, 6, 6, 6,12,12, 8, - 6, 6,10,10, 8, 6, 6,13,12, 0,10,10,11,11, 0,11, - 11,13,13, 8, 7, 7,13,13,11, 9, 9,13,13,10, 6, 6, - 12,12, 0,10,10,14,14, 0,10,10,13,13, 9, 7, 7,13, - 13,12,10,10,13,13,10, 6, 6,12,12, 0,11,11,15,15, - 0,10,10,13,13, 0,12,12,15,14, 0,19,20,16,17, 0, - 9, 9,13,13, 0,14,14,20,21, 0,12,11,13,12, 0,12, - 12,15,14, 0,20,19,17,17, 0,10,10,12,13, 0,15,15, - 22,21, 0,12,12,12,13, 0,10,10,12,12, 0,11,11,15, - 15, 0,11,11,15,15, 0,15,15,22,22, 0,16,17, 0, 0, - 0,11,11,15,15, 0,14,14,18,18, 0,11,11,16,16, 0, - 16,15, 0,21, 0,16,16, 0, 0, 0,12,12,15,15, 0,14, - 14,19,19, 0,11,11,15,15, 0,15,15,22, 0, 0,16,16, - 22, 0, 0,16,16, 0,21, 0, 0, 0, 0, 0, 0,15,15,19, - 20, 0,18,18, 0, 0, 0,17,17, 0, 0, 0,17,17, 0, 0, - 0, 0, 0, 0, 0, 0,16,15,22,21, 0,20,20, 0, 0, 0, - 18,18, 0, 0, 0,10,10,12,12, 0,10,10,11,11, 0,11, - 11,12,12, 0,11,11, 9, 9, 0,13,12,12,12, 0,11,11, - 13,13, 0,13,13,12,12, 0,10,10,12,12, 0,13,12,13, - 13, 0,12,12,12,12, 0,11,11,13,13, 0,13,13,12,12, - 0,10,10,12,12, 0,13,13,14,13, 0,12,12,12,12, 0, - 14,13,13,14, 0,20,21,15,15, 0,11,11,12,12, 0,15, - 16,20,20, 0,12,13,10,10, 0,13,13,14,13, 0,20,20, - 15,15, 0,11,11,12,12, 0,16,17,21,21, 0,13,13,11, - 11, 6, 7, 7,16,15,11, 9, 9,14,15,12, 9, 9,16,16, - 0,13,13,15,15, 0,14,14,17,17,10, 9, 9,16,16,14, - 12,12,16,16,12, 9, 9,15,15, 0,13,13,17,18, 0,13, - 13,15,15,12,10,10,17,17,15,12,12,17,17,13, 9, 9, - 16,16, 0,13,13,18,19, 0,14,14,16,16, 0,15,15,18, - 18, 0, 0, 0,20,19, 0,12,12,17,16, 0,16,17, 0,21, - 0,14,15,16,16, 0,15,15,18,18, 0, 0,22,19,21, 0, - 13,13,16,16, 0,18,17,22,22, 0,15,15,16,16, 7, 7, - 7,13,13,11,10,10,15,15,12,10,10,14,14, 0,21, 0, - 18,17, 0,21,22,18,18,11,10,10,15,15,14,12,12,17, - 17,14,11,11,14,14, 0,21,20,18,18, 0,22,21,18,17, - 12,11,10,16,16,16,14,14,17,19,14,11,11,15,15, 0, - 0,22,19,19, 0,21,22,18,18, 0,21, 0,18,19, 0, 0, - 0,22, 0, 0,22,21,17,17, 0, 0, 0,20,22, 0, 0,21, - 18,18, 0, 0, 0,19,20, 0, 0, 0, 0, 0, 0, 0,21,17, - 17, 0, 0, 0,22,21, 0, 0, 0,19,19,10, 9, 9,14,13, - 13,10,10,12,12,13,10,10,14,14, 0,13,13,12,12, 0, - 15,14,16,15,13,10,10,14,14,15,12,12,14,14,15,10, - 10,14,14, 0,14,14,15,15, 0,14,13,14,14,13,10,10, - 15,15,17,13,13,15,15,14,10,10,14,14, 0,14,14,15, - 16, 0,14,14,15,15, 0,15,15,16,16, 0,21,22,17,18, - 0,12,12,14,14, 0,17,17,20,21, 0,14,14,14,14, 0, - 15,15,16,16, 0,21,22,18,18, 0,13,13,14,14, 0,18, - 18,22, 0, 0,15,15,14,14, 0,11,11,13,13, 0,12,12, - 16,15, 0,12,12,16,16, 0,16,16, 0, 0, 0,16,17, 0, - 22, 0,12,12,16,16, 0,14,14,17,18, 0,11,11,16,16, - 0,15,15, 0,21, 0,16,16,21,22, 0,12,12,16,16, 0, - 15,15,19,19, 0,12,12,17,16, 0,16,16,21,22, 0,16, - 16, 0, 0, 0,17,17, 0,22, 0, 0, 0, 0, 0, 0,15,15, - 19,20, 0,17,19, 0, 0, 0,17,17,22, 0, 0,17,17, 0, - 22, 0, 0, 0, 0, 0, 0,15,15,21, 0, 0,19,20, 0, 0, - 0,19,18,22, 0, 0,11,12,14,14, 0,11,11,14,14, 0, - 12,12,15,15, 0,13,13,13,13, 0,14,14,16,16, 0,12, - 12,15,15, 0,14,14,16,15, 0,11,11,15,15, 0,13,13, - 16,16, 0,13,13,15,15, 0,12,12,15,15, 0,15,14,16, - 16, 0,11,11,15,15, 0,14,14,17,17, 0,13,13,15,15, - 0,15,15,16,16, 0, 0, 0,18,18, 0,12,12,14,14, 0, - 16,16,22, 0, 0,14,14,15,15, 0,15,15,16,17, 0,21, - 22,18,18, 0,13,13,15,14, 0,18,17,22, 0, 0,14,14, - 15,15, 8, 8, 8,16,15,12,10,10,16,15,12,10,10,16, - 16, 0,14,14,16,17, 0,14,14,17,16,12,10,10,17,18, - 14,12,12,18,18,14,10,10,16,16, 0,14,14,18,18, 0, - 14,14,16,16,12, 9, 9,16,16,17,13,13,16,17,14, 9, - 9,15,15, 0,14,14,18,19, 0,13,13,15,15, 0,15,15, - 18,19, 0, 0, 0,22,21, 0,13,13,16,16, 0,16,16,22, - 0, 0,15,15,16,16, 0,14,14,18,17, 0, 0, 0,20, 0, - 0,13,13,16,16, 0,18,18, 0, 0, 0,15,15,16,16, 8, - 7, 7,13,13,12,10,10,15,15,12,10,10,14,14, 0,22, - 22,19,18, 0, 0, 0,18,18,12,10,10,15,15,14,13,13, - 17,17,14,11,11,15,15, 0,19,20,18,18, 0,22,21,17, - 18,13,11,11,15,15,16,13,13,18,18,14,11,11,14,15, - 0,22,21,20,19, 0,22,21,17,17, 0, 0,22,19,18, 0, - 0, 0, 0, 0, 0,22,20,17,17, 0, 0, 0,21,20, 0, 0, - 0,19,17, 0, 0,22,19,19, 0, 0, 0, 0, 0, 0,22,20, - 18,17, 0, 0, 0, 0, 0, 0, 0, 0,18,18, 0,10,10,14, - 14, 0,11,11,14,14, 0,11,11,15,15, 0,14,14,14,14, - 0,15,15,16,16, 0,11,11,16,16, 0,13,13,16,16, 0, - 11,11,15,15, 0,14,14,16,16, 0,14,14,15,15, 0,11, - 11,15,15, 0,13,13,15,15, 0,10,10,15,15, 0,15,15, - 17,17, 0,14,14,14,14, 0,16,16,16,16, 0, 0,22,19, - 19, 0,13,13,14,14, 0,17,17, 0, 0, 0,15,15,14,14, - 0,16,16,17,17, 0, 0,22,18,18, 0,13,13,14,14, 0, - 21,18, 0, 0, 0,15,15,14,14, 0,11,11,13,13, 0,12, - 12,15,15, 0,12,12,16,15, 0,16,16, 0, 0, 0,17,17, - 22,22, 0,12,12,16,16, 0,14,14,18,18, 0,11,12,16, - 16, 0,15,16, 0,21, 0,16,16,22,21, 0,12,12,16,16, - 0,15,15,19,20, 0,11,12,16,16, 0,15,15,20,22, 0, - 16,16, 0,22, 0,17,17,22, 0, 0, 0, 0, 0, 0, 0,15, - 15,21,22, 0,19,18, 0, 0, 0,17,17, 0, 0, 0,17,17, - 0,22, 0, 0, 0, 0, 0, 0,16,15,22, 0, 0,19,19, 0, - 0, 0,17,18, 0, 0, 0,12,12,15,15, 0,12,12,15,15, - 0,12,12,15,15, 0,13,13,14,14, 0,15,15,16,17, 0, - 12,12,16,16, 0,14,14,16,16, 0,12,11,15,16, 0,14, - 14,16,17, 0,14,14,16,16, 0,13,12,16,16, 0,15,15, - 16,16, 0,11,11,15,15, 0,14,14,16,16, 0,14,14,15, - 15, 0,15,15,18,17, 0, 0,22, 0,20, 0,13,13,15,15, - 0,16,17,22,22, 0,14,14,15,15, 0,15,15,17,18, 0, - 20, 0,19,19, 0,13,13,15,15, 0,18,18,22, 0, 0,14, - 14,15,15, 0,11,11,16,16, 0,14,14,17,16, 0,13,13, - 17,17, 0,16,16,17,17, 0,17,17,18,19, 0,12,12,16, - 17, 0,15,15,18,18, 0,12,12,16,16, 0,16,16,19,18, - 0,16,16,17,16, 0,12,13,17,17, 0,17,16,18,17, 0, - 13,12,16,16, 0,16,16,18,19, 0,16,16,16,17, 0,16, - 16,18,18, 0,22, 0,22,22, 0,13,13,16,16, 0,19,18, - 22,20, 0,16,15,16,16, 0,16,17,18,18, 0, 0, 0,22, - 20, 0,14,14,16,16, 0,19,19, 0, 0, 0,16,16,16,16, - 0, 9, 9,13,13, 0,13,13,15,15, 0,14,14,15,15, 0, - 0,22,17,18, 0,22, 0,18,19, 0,12,12,15,15, 0,15, - 16,17,17, 0,14,14,14,14, 0,22, 0,18,18, 0,21,22, - 17,17, 0,13,13,15,15, 0,17,17,17,18, 0,14,14,15, - 15, 0,22,21,21,19, 0,20,21,17,17, 0,21,21,19,18, - 0, 0, 0, 0, 0, 0,21,21,17,17, 0, 0, 0,22,22, 0, - 0,22,19,18, 0, 0,21,19,18, 0, 0, 0, 0,22, 0,19, - 20,17,17, 0, 0, 0, 0,22, 0, 0, 0,19,18, 0,19,19, - 15,16, 0,21,19,16,17, 0, 0,21,17,17, 0, 0,22,17, - 17, 0,22,22,18,19, 0,20,20,16,16, 0, 0,22,18,18, - 0,20,19,16,17, 0,22,21,20,19, 0, 0,21,17,17, 0, - 21,20,17,17, 0, 0, 0,18,18, 0,19,19,17,16, 0,22, - 0,19,19, 0,21,22,17,18, 0, 0,22,19,18, 0, 0, 0, - 19,20, 0,19,19,16,16, 0,22,22,22, 0, 0,20,22,16, - 16, 0,22,20,18,19, 0, 0, 0,20,19, 0,20,20,16,16, - 0, 0, 0, 0, 0, 0,22,20,17,16, 0,11,11,13,13, 0, - 14,13,15,15, 0,13,13,16,15, 0,18,17,21, 0, 0,18, - 18,21, 0, 0,12,12,15,15, 0,15,16,17,18, 0,12,12, - 15,15, 0,17,17,22,20, 0,17,18,22, 0, 0,12,12,17, - 16, 0,16,17,19,19, 0,13,13,16,16, 0,17,17, 0,22, - 0,17,17, 0,21, 0,18,18,20,22, 0, 0, 0, 0, 0, 0, - 15,15,21,20, 0,20,19, 0, 0, 0,18,18,22, 0, 0,17, - 17,22, 0, 0, 0, 0, 0, 0, 0,15,16,20,22, 0,20,21, - 0, 0, 0,19,18, 0, 0, 0,15,15,19,19, 0,17,16,20, - 20, 0,16,17,20,21, 0,18,17, 0, 0, 0,19,19, 0, 0, - 0,15,15,21,19, 0,19,19, 0, 0, 0,15,15,22,22, 0, - 18,18, 0,22, 0,17,18,22,21, 0,15,15,20,19, 0,19, - 19, 0, 0, 0,15,15,20,22, 0,18,19,20, 0, 0,18,17, - 21,21, 0,18,18,19,22, 0, 0, 0, 0, 0, 0,15,15,20, - 19, 0,19,19, 0, 0, 0,18,18,21,22, 0,18,18,22, 0, - 0, 0, 0, 0, 0, 0,15,15,19,20, 0,21,21, 0, 0, 0, - 17,17,20,20, 0,12,12,17,17, 0,14,14,16,17, 0,13, - 14,17,17, 0,16,16,17,17, 0,17,17,17,19, 0,13,13, - 17,17, 0,16,16,18,18, 0,13,13,16,16, 0,16,16,18, - 18, 0,16,16,17,17, 0,13,13,17,17, 0,17,17,18,17, - 0,12,12,15,16, 0,17,18,19,20, 0,16,16,16,16, 0, - 17,16,18,19, 0, 0,22,21,22, 0,14,14,16,16, 0,19, - 19, 0, 0, 0,16,16,16,16, 0,16,16,18,17, 0, 0,22, - 21,21, 0,14,14,16,16, 0,22,20,22, 0, 0,16,16,15, - 15, 0, 9, 9,13,13, 0,14,14,15,15, 0,14,14,14,14, - 0,22,22,18,18, 0, 0,22,18,18, 0,12,12,15,15, 0, - 16,16,18,17, 0,14,14,14,14, 0,20,21,18,18, 0,22, - 21,17,17, 0,13,13,15,15, 0,17,17,18,18, 0,14,14, - 14,14, 0, 0,21,18,19, 0, 0,22,17,17, 0,22,22,19, - 18, 0, 0, 0, 0, 0, 0,19,21,17,17, 0, 0, 0,22,20, - 0, 0,21,18,19, 0, 0,22,18,18, 0, 0, 0, 0,22, 0, - 20,22,17,17, 0, 0, 0,20,22, 0, 0, 0,18,18, 0,19, - 21,16,16, 0,20,22,16,17, 0,20, 0,17,17, 0,22, 0, - 18,17, 0,21, 0,18,19, 0,20,20,17,17, 0,22, 0,18, - 18, 0,21,20,17,17, 0, 0,20,20,19, 0, 0,21,18,17, - 0,21,21,17,17, 0,22, 0,18,17, 0,19,19,17,17, 0, - 0,22,20,21, 0, 0,21,17,17, 0,22, 0,18,18, 0, 0, - 0,20,22, 0,20,19,16,16, 0, 0, 0, 0, 0, 0,22,22, - 17,17, 0,22, 0,18,19, 0, 0, 0,21,20, 0,19,21,16, - 17, 0, 0, 0, 0, 0, 0,22,22,17,16, 0,11,11,13,13, - 0,13,13,15,15, 0,13,13,15,15, 0,17,17,22,21, 0, - 18,18,22, 0, 0,12,13,16,15, 0,15,16,18,18, 0,13, - 13,16,16, 0,17,17, 0,22, 0,17,17,22,22, 0,13,13, - 16,16, 0,16,16,19,18, 0,13,13,16,16, 0,18,17, 0, - 20, 0,18,17,20, 0, 0,17,17,21, 0, 0, 0, 0, 0, 0, - 0,15,15,21,22, 0,19,20, 0, 0, 0,18,18, 0, 0, 0, - 18,17, 0, 0, 0, 0, 0, 0, 0, 0,16,16,22,22, 0,20, - 20, 0, 0, 0,21,19, 0, 0, 0,15,15,20,19, 0,16,16, - 22,20, 0,17,17, 0,22, 0,18,18, 0,22, 0,19,17, 0, - 0, 0,15,16,22,20, 0,18,19, 0, 0, 0,16,16,22,20, - 0,18,18, 0,22, 0,18,18,22, 0, 0,16,16,21,20, 0, - 19,20, 0,22, 0,16,16, 0,22, 0,18,18, 0,22, 0,18, - 18, 0,21, 0,19,18, 0,22, 0, 0, 0, 0, 0, 0,16,16, - 21,20, 0,20, 0, 0, 0, 0,18,18,21, 0, 0,18,18, 0, - 0, 0, 0, 0, 0, 0, 0,16,16,21,19, 0, 0, 0, 0, 0, - 0,18,18, 0,21, -}; - -static const static_codebook _44p3_p5_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p3_p5_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p3_p5_0, - 0 -}; - -static const long _vq_quantlist__44p3_p5_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p3_p5_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p3_p5_1 = { - 1, 7, - (char *)_vq_lengthlist__44p3_p5_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p3_p5_1, - 0 -}; - -static const long _vq_quantlist__44p3_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p3_p6_0[] = { - 1, 6, 6, 7, 7, 7, 7, 8, 8, 7, 9, 9,11,11,11, 9, - 8, 8, 8, 9, 9,12,11,11, 9, 8, 8, 6, 7, 7,10,11, - 10,10,10,10,11,11,10,14,13,14,12,11,11,11,11,11, - 15,14,14,13,12,12, 5, 6, 6, 8, 5, 5, 8, 7, 7, 8, - 8, 8,12,10,10, 9, 7, 7, 9, 7, 8,12,10,10,10, 7, - 7, 7, 8, 8,12,10,10,12,10,10,11,10,10,15,13,13, - 13,10,10,11,10,10,16,13,14,14,10,10, 7, 7, 7,12, - 11,11,12,11,11,11,11,11,16,15,15,14,12,12,12,11, - 11,16,15,16,14,12,12,10, 9, 9,14,11,11,13,11,11, - 12,11,11,16,14,14,14,11,11,12,11,11,17,15,15,14, - 11,11, 7, 8, 8,12,11,11,12,10,10,12,10,10,16,14, - 13,14,10,10,12,10,10,17,14,14,14,10,10, 8, 7, 7, - 13,11,11,12,11,11,12,11,11,16,15,14,14,12,12,12, - 11,11,16,15,14,15,12,12,11,10,10,13,11,11,13,12, - 11,13,11,11,17,14,14,14,11,11,13,11,11,17,14,15, - 14,11,11, -}; - -static const static_codebook _44p3_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p3_p6_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p3_p6_0, - 0 -}; - -static const long _vq_quantlist__44p3_p6_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p3_p6_1[] = { - 2, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, - 7, 7, 8, 8, 8, 9, 9, 9, 9, 7, 8, 6, 7, 7, 8, 8, - 8, 8, 8, 8, 9, 8, 8,10, 9, 9,10, 8, 8,10, 8, 8, - 10, 9, 9,10, 8, 8, 6, 6, 6, 8, 6, 6, 8, 7, 7, 8, - 7, 7,10, 8, 8, 9, 7, 7, 9, 7, 7,10, 8, 9, 9, 7, - 7, 7, 7, 7,10, 8, 8,11, 8, 8,10, 8, 8,12, 9, 9, - 12, 8, 8,11, 9, 9,12, 9, 9,11, 8, 8, 7, 7, 7,10, - 9, 9,10, 9, 9,10, 9, 9,11,10,10,10, 9, 9,11, 9, - 9,11,10,10,11, 9, 9, 9, 8, 8,10, 9, 9,10, 9, 9, - 11, 9, 9,11,10,10,11, 9, 9,11, 9, 9,11,10,10,11, - 9, 9, 8, 8, 8,11, 9, 9,11, 9, 9,11, 9, 9,12, 9, - 9,12, 8, 8,12, 9, 9,12, 9, 9,12, 8, 8, 8, 7, 7, - 10, 9, 9,10, 9, 9,11, 9, 9,11,11,11,11, 9, 9,11, - 10,10,11,11,11,11, 9, 9,10, 9, 9,11, 9, 9,11, 9, - 10,11,10, 9,11,10,10,11, 9, 9,11, 9,10,11,10,10, - 11, 9, 9, -}; - -static const static_codebook _44p3_p6_1 = { - 5, 243, - (char *)_vq_lengthlist__44p3_p6_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p3_p6_1, - 0 -}; - -static const long _vq_quantlist__44p3_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p3_p7_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p3_p7_0 = { - 5, 243, - (char *)_vq_lengthlist__44p3_p7_0, - 1, -513979392, 1633504256, 2, 0, - (long *)_vq_quantlist__44p3_p7_0, - 0 -}; - -static const long _vq_quantlist__44p3_p7_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p3_p7_1[] = { - 1, 9, 9, 6, 9, 9, 5, 9, 9, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10, -}; - -static const static_codebook _44p3_p7_1 = { - 5, 243, - (char *)_vq_lengthlist__44p3_p7_1, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p3_p7_1, - 0 -}; - -static const long _vq_quantlist__44p3_p7_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p3_p7_2[] = { - 1, 3, 2, 5, 4, 7, 7, 8, 8, 9, 9,10,10,11,11,12, - 12,13,13,14,14,15,15,15,15, -}; - -static const static_codebook _44p3_p7_2 = { - 1, 25, - (char *)_vq_lengthlist__44p3_p7_2, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p3_p7_2, - 0 -}; - -static const long _vq_quantlist__44p3_p7_3[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p3_p7_3[] = { - 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p3_p7_3 = { - 1, 25, - (char *)_vq_lengthlist__44p3_p7_3, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p3_p7_3, - 0 -}; - -static const char _huff_lengthlist__44p3_short[] = { - 4, 5,16, 9, 9,12,17,18, 4, 2,18, 6, 5, 9,13,15, - 10, 7, 7, 6, 7, 9,13,13, 8, 5, 6, 5, 5, 7,11,12, - 8, 4, 7, 4, 3, 6,10,12,11, 8, 9, 7, 6, 8,11,12, - 15,13,13,11, 9, 7,10,12,16,12,16,12, 6, 5, 8,11, -}; - -static const static_codebook _huff_book__44p3_short = { - 2, 64, - (char *)_huff_lengthlist__44p3_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p4_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p4_l0_0[] = { - 1, 4, 4, 8, 8, 9, 8, 9, 9,10,10,10,10, 4, 6, 5, - 8, 7, 9, 9, 9, 9,10, 9,10,10, 4, 5, 6, 7, 8, 9, - 9, 9, 9, 9,10, 9,10, 8, 9, 8, 9, 8,10, 9,11, 9, - 12,10,11,10, 8, 8, 9, 8, 9, 9,10, 9,11,10,11,10, - 12, 9,10,10,11,10,11,11,12,11,12,12,12,12, 9,10, - 10,11,11,11,11,11,12,12,12,12,12,10,11,11,12,12, - 12,12,12,12,12,12,12,12,10,11,11,12,12,12,12,12, - 12,12,12,12,12,11,12,12,12,12,12,12,12,12,12,13, - 12,12,11,12,11,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,13,12,12,12,12,12,12,11,13,12,12, - 12,13,12,12,12,12,12,12,12, -}; - -static const static_codebook _44p4_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p4_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p4_l0_0, - 0 -}; - -static const long _vq_quantlist__44p4_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p4_l0_1[] = { - 3, 4, 4, 5, 5, 4, 4, 5, 5, 5, 4, 5, 4, 5, 5, 5, - 5, 6, 5, 6, 5, 6, 5, 6, 5, -}; - -static const static_codebook _44p4_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p4_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p4_l0_1, - 0 -}; - -static const long _vq_quantlist__44p4_l1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p4_l1_0[] = { - 1, 4, 4, 4, 4, 4, 4, 4, 4, -}; - -static const static_codebook _44p4_l1_0 = { - 2, 9, - (char *)_vq_lengthlist__44p4_l1_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p4_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p4_lfe[] = { - 1, 3, 2, 3, -}; - -static const static_codebook _huff_book__44p4_lfe = { - 2, 4, - (char *)_huff_lengthlist__44p4_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p4_long[] = { - 3, 5,13, 9, 9,12,16,18, 4, 2,20, 6, 7,10,15,20, - 10, 7, 5, 5, 6, 8,10,13, 8, 5, 5, 3, 5, 7,10,11, - 9, 7, 6, 5, 5, 7, 9, 9,11,10, 8, 7, 6, 6, 8, 8, - 15,15,10,10, 9, 7, 8, 9,17,19,13,12,10, 8, 9, 9, -}; - -static const static_codebook _huff_book__44p4_long = { - 2, 64, - (char *)_huff_lengthlist__44p4_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p4_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p4_p1_0[] = { - 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44p4_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p4_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p4_p1_0, - 0 -}; - -static const long _vq_quantlist__44p4_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p4_p2_0[] = { - 3, 9, 9, 0, 0, 0, 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, - 12,12, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0,11,11, 0, 0, 0, 0, 0, - 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, - 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0, - 0, 0, 0, 0, 0, 0,11,11, 0, 0, 0,12,12, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, - 5, 5, 0, 0, 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, - 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, - 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 7, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 7, 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0,11,11, 0, 0, 0, 9, 9, 0, - 0, 0,10,10, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, - 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, - 10,10, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, - 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0,11,11, 0, - 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 7, 7, 0, 0, 0, 8, 8, 0, 0, - 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, - 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0,11,11, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, - 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, 7, 7, - 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, - 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, - 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 0, 0, 0, 7, 7, 0, 0, 0, 8, 8, 0, - 0, 0,10,11, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 7, - 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0,11,11, - 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, 7, - 7, 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, - 9, 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0,10,10, 0, 0, 0, 9, 9, 0, 0, 0,10,10, - 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0,10,10, 0, 0, - 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0,11, - 11, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0,12,12, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, 0, 0, - 9, 9, 0, 0, 0,10,10, 0, 0, 0,12,12, 0, 0, 0, 0, - 0, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, - 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0,10,10, 0, 0, - 0, 0, 0, 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, - 10,10, 0, 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44p4_p2_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p4_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p4_p2_0, - 0 -}; - -static const long _vq_quantlist__44p4_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p4_p3_0[] = { - 1, 6, 6, 5, 7, 8, 0, 8, 8, 6, 9, 9, 7,10,10, 0, - 8, 8, 0, 9, 9, 0,12,12, 0, 8, 8, 4, 7, 7, 6,10, - 10, 0,12,12, 7,11,11, 8,12,12, 0,12,12, 0,13,12, - 0,15,15, 0,12,12, 0, 7, 7, 0, 7, 7, 0, 7, 7, 0, - 8, 8, 0,10,10, 0, 7, 7, 0, 8, 8, 0,11,11, 0, 7, - 7, 5, 7, 7, 8, 9, 9, 0,10,10, 8, 9, 9,11,11,11, - 0,10, 9, 0,11,11, 0,13,13, 0,10,10, 6, 7, 7, 8, - 10,10, 0,12,12, 9,10,10,10,12,12, 0,12,12, 0,12, - 12, 0,15,15, 0,12,12, 0,10,10, 0,11,11, 0,11,11, - 0,11,11, 0,13,13, 0,11,11, 0,11,11, 0,15,15, 0, - 10,10, 0, 8, 8, 0,10,10, 0,12,12, 0,11,11, 0,12, - 12, 0,12,12, 0,12,12, 0,15,15, 0,11,11, 0, 7, 7, - 0,10,10, 0,12,12, 0,10,10, 0,12,12, 0,12,12, 0, - 13,13, 0,14,14, 0,12,12, 0, 0, 0, 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 static_codebook _44p4_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p4_p3_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p4_p3_0, - 0 -}; - -static const long _vq_quantlist__44p4_p3_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p4_p3_1[] = { - 3, 5, 5, 0, 8, 8, 0, 8, 8, 0, 9, 9, 0,10,10, 0, - 8, 8, 0, 8, 8, 0,10,10, 0, 8, 8, 0, 7, 7, 0, 8, - 8, 0, 7, 7, 0, 8, 8, 0, 8, 8, 0, 8, 8, 0, 8, 8, - 0, 8, 8, 0, 8, 8, 0, 7, 7, 0, 6, 6, 0, 7, 7, 0, - 7, 7, 0,10,10, 0, 6, 6, 0, 7, 7, 0,10,10, 0, 5, - 5, 0, 8, 8, 0, 7, 7, 0, 8, 8, 0, 8, 8, 0, 9, 9, - 0, 7, 7, 0, 8, 8, 0, 9, 9, 0, 7, 7, 0, 6, 6, 0, - 9,10, 0,10,10, 0,10,10, 0,11,11, 0, 9, 9, 0,10, - 10, 0,11,11, 0, 9, 9, 0, 8, 8, 0, 8, 8, 0, 8, 8, - 0, 9, 9, 0, 9, 9, 0, 7, 7, 0, 8, 8, 0, 9, 9, 0, - 7, 7, 0, 8, 8, 0, 7, 7, 0, 7, 7, 0, 8, 8, 0, 9, - 9, 0, 7, 7, 0, 7, 7, 0, 8, 8, 0, 6, 6, 0, 6, 6, - 0,10,10, 0,10,10, 0,10,10, 0,12,12, 0, 9, 9, 0, - 10,10, 0,12,12, 0, 9, 9, 0, 8, 8, 0, 7, 7, 0, 7, - 7, 0, 8, 8, 0, 9, 9, 0, 7, 7, 0, 8, 8, 0, 9, 9, - 0, 6, 6, -}; - -static const static_codebook _44p4_p3_1 = { - 5, 243, - (char *)_vq_lengthlist__44p4_p3_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p4_p3_1, - 0 -}; - -static const long _vq_quantlist__44p4_p4_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p4_p4_0[] = { - 1, 6, 6, 6, 7, 7, 7, 8, 8, 7, 8, 8,10,11,11, 9, - 8, 8, 8, 8, 8,11,11,12, 9, 8, 8, 5, 7, 7, 9,11, - 11,10,11,11,10,11,11,12,14,14,11,12,12,10,12,12, - 13,14,14,12,12,12, 5, 6, 6, 7, 6, 6, 8, 7, 7, 8, - 7, 7,11,10,10,10, 7, 7, 9, 8, 8,12,11,11,10, 7, - 7, 7, 7, 7,11,10,10,12,10,10,11,10,10,15,13,13, - 13,10,10,12,11,11,15,13,13,14,11,11, 7, 7, 7,11, - 11,11,12,11,11,12,11,11,14,14,14,13,12,12,12,12, - 12,16,15,15,14,12,12, 0,10,10, 0,11,11, 0,12,12, - 0,11,11, 0,14,14, 0,11,11, 0,12,12, 0,15,15, 0, - 11,11, 7, 8, 8,12,11,10,12,10,10,12,11,11,15,13, - 13,14,11,11,12,10,10,16,14,14,14,10,10, 8, 7, 7, - 12,11,11,12,11,11,12,11,11,15,14,14,14,12,12,13, - 12,12,15,14,14,15,13,13, 0,11,11, 0,12,12, 0,12, - 12, 0,12,12, 0,15,15, 0,12,12, 0,13,13, 0,15,14, - 0,12,12, -}; - -static const static_codebook _44p4_p4_0 = { - 5, 243, - (char *)_vq_lengthlist__44p4_p4_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p4_p4_0, - 0 -}; - -static const long _vq_quantlist__44p4_p4_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p4_p4_1[] = { - 4, 5, 5, 9, 9,12, 9, 9,12,12,12,10,10,13,13,13, - 11,11,12,12,13,13,13,12,12,13,10,10,13,13,13,13, - 13,13,13,13,10,10,13,12,13,11,11,13,13,13,14,14, - 13,12,13,10,10,13,13,12,13,13,13,13,13,10,10,12, - 12,13,11,11,13,13,13,14,14,12,12,13,12,12,13,13, - 13,13,13,13,13,13,11,11,12,12,13,11,11,13,13,13, - 14,14,12,12,13,14,14,13,13,14,13,13,14,14,14,14, - 14,12,12,13,14,14,13,13,14,14,14,12,12,12, 8, 8, - 12,12,13,12,12,11,11,13,11,11,11,11,14,12,12,11, - 11,14,12,12,10,11,14,12,12,12,12,14,12,12,12,12, - 13,13,13,11,11,14,12,12,11,11,14,12,12,12,12,14, - 12,12,12,12,14,12,12,12,12,14,13,13,11,11,14,12, - 12,11,11,14,12,12,12,12,14,13,13,12,12,14,12,12, - 12,12,14,13,13,11,11,14,12,12,11,11,14,13,13,11, - 11,15,13,13,12,12,14,12,12,12,12,15,13,13,12,12, - 14,12,12,11,11,15,13,13,11,11,12, 9, 9,11,11,13, - 7, 7,11,11,13, 8, 8,12,12,14,10,10,10,10,14,14, - 14,11,11,14, 8, 8,12,12,14,14,14,12,12,14, 7, 7, - 11,11,14, 9, 9,12,12,14,14,14,11,11,14, 8, 8,12, - 12,14,14,14,12,12,14, 7, 7,11,11,14, 9, 9,12,12, - 14,14,14,11,11,14,10,10,12,12,14,14,14,13,13,14, - 9, 9,11,11,14,10,10,12,11,15,14,14,11,11,14,15, - 15,12,12,15,14,14,14,14,15,14,14,11,11,15,14,14, - 12,12,15,14,14,11,11,14,11,11,10,10,15,10,10,10, - 10,15,10,10,10,10,15,11,11, 9, 9,15,12,13, 9, 9, - 15,11,11,11,11,15,13,13,11,11,15,10,10,10,10,15, - 11,11,10,10,15,13,13,11,11,15,11,11,11,11,15,13, - 13,11,11,15,10,10,10,10,15,11,11,10,10,15,13,13, - 10,11,15,12,12,11,11,15,13,13,11,10,15,11,11,10, - 10,15,11,12,10, 9,15,13,13,10,10,15,14,14,11,11, - 15,13,13,11,11,15,14,14,10,10,15,13,13,10,10,15, - 14,14,10,10,14,13,13,10,10,15,13,13,10,10,15,13, - 13,10,10,14,14,14, 8, 9,15,14,14, 9, 9,15,14,14, - 11,11,15,14,14,10,10,15,14,14,10,10,15,14,14,11, - 11,15,14,14,10,10,15,14,14,11,11,15,14,14,10,10, - 15,14,14,10,10,15,14,14,10,10,15,14,14, 9, 9,15, - 14,14,11,11,15,14,14,11,11,15,14,14,10,10,15,14, - 14,10,10,14,14,14, 9, 9,15,15,15,11,11,15,14,14, - 12,12,15,15,15,10,10,15,14,15,10,10,15,15,15, 9, - 9,15,10,10,13,13,17, 8, 8,12,12,17,10, 9,13,13, - 18,11,11,12,12,18,14,14,12,12,17, 9, 9,13,13,17, - 13,13,12,12,18, 8, 8,12,12,18,10,10,12,12,18,14, - 14,12,12,18,10,10,13,13,18,13,13,13,13,18, 9, 9, - 12,12,18,10,10,13,13,18,14,14,12,12,18,11,11,13, - 13,18,14,14,13,13,18,10,10,12,12,17,11,11,12,12, - 18,14,14,12,12,18,14,14,13,13,18,14,14,13,13,19, - 14,15,12,12,18,14,14,12,12,18,15,15,12,12,13, 7, - 7,11,11,14,15,15,11,11,14,16,15,11,11,14,15,15, - 11,11,14,15,15,11,11,14,15,15,11,12,14,15,15,12, - 12,13,15,15,11,11,14,15,15,11,11,15,15,15,12,12, - 14,15,15,12,12,14,16,16,12,12,14,15,15,11,11,14, - 15,15,11,11,15,15,15,12,12,15,15,15,12,12,14,15, - 15,12,12,14,15,15,11,11,14,15,15,11,11,15,14,15, - 12,12,15,15,15,12,12,15,16,16,12,12,15,15,15,12, - 12,14,15,15,12,12,15,15,15,12,12,13,13,13,11,11, - 14,14,15,11,11,14,14,14,12,12,14,15,15,10,10,15, - 15,15,11,11,14,15,15,12,12,14,14,14,11,11,14,15, - 15,11,11,14,15,15,12,12,15,15,15,11,11,14,15,15, - 12,12,14,14,15,11,11,14,15,15,11,11,14,15,15,12, - 12,15,15,15,11,11,15,15,15,12,12,14,15,15,12,12, - 14,15,15,10,10,14,15,15,11,11,15,15,15,10,10,15, - 15,15,12,12,15,15,15,14,14,15,15,15,11,11,15,15, - 15,11,11,15,15,15,11,11,14,10,10,10,10,15, 9, 9, - 12,11,15,10,10,12,12,15,11,11,11,11,15,13,13,12, - 12,16,10,10,12,12,15,13,13,12,12,15, 9, 9,11,11, - 15,10,10,13,12,15,13,13,11,11,15,10,10,12,12,15, - 13,13,12,12,15, 9, 9,11,11,15,10,10,12,12,15,13, - 13,11,11,15,11,11,12,12,15,13,13,13,13,15,10,10, - 11,11,15,11,11,12,12,15,13,14,11,11,15,14,14,13, - 13,16,14,14,20,19,15,14,14,11,11,15,13,14,12,12, - 15,14,14,11,11,14,13,13,10,10,14,14,13,11,11,15, - 13,14,12,12,15,14,14,12,12,15,14,14,11,11,15,14, - 14,12,12,15,15,14,13,13,15,14,14,11,11,15,14,14, - 11,11,15,14,14,13,13,15,14,14,12,12,15,14,14,13, - 13,15,14,14,11,11,15,14,14,11,11,15,14,14,13,13, - 15,14,14,12,12,15,14,14,12,12,15,14,14,12,12,15, - 14,14,11,11,15,15,15,12,12,15,15,15,13,13,16,14, - 14,12,12,15,15,15,13,13,15,15,15,12,12,15,15,15, - 12,12,14,10,10,13,13,17, 9, 9,12,12,17, 9, 9,13, - 13,17,11,11,12,12,18,14,14,12,12,18,10,10,13,13, - 18,14,13,12,12,18, 9, 9,12,12,18,10,10,12,13,18, - 14,14,12,12,17, 9, 9,12,12,17,13,14,12,12,17, 9, - 9,12,12,17,10,10,12,12,17,14,14,11,11,18,11,11, - 12,12,18,14,14,12,13,18,10,10,12,12,18,11,11,12, - 12,18,14,14,11,11,18,15,15,12,12,18,14,14,13,13, - 18,14,15,12,12,17,14,14,12,12,17,15,15,12,12,13, - 7, 7,11,11,14,15,15,11,11,14,15,15,11,11,14,15, - 15,11,11,14,15,15,11,11,14,15,15,11,11,14,15,15, - 12,12,14,15,15,11,11,14,15,15,11,11,15,15,15,12, - 12,14,15,15,11,11,14,15,15,12,12,14,15,15,11,11, - 15,15,15,11,11,15,15,15,12,12,14,15,15,12,12,14, - 15,16,12,12,14,15,15,11,11,14,15,15,11,11,15,15, - 15,12,12,15,15,15,12,12,15,16,16,12,12,15,15,15, - 12,12,15,15,15,12,12,15,15,15,12,12,13,13,13,12, - 12,14,14,14,11,11,14,14,14,12,12,14,14,14,10,10, - 15,15,15,11,11,14,15,15,12,12,14,14,14,11,11,14, - 15,15,11,11,14,14,14,12,12,15,15,14,11,11,14,15, - 15,12,12,14,14,14,11,11,14,15,15,11,11,14,14,14, - 11,11,15,14,14,10,10,14,15,15,12,12,14,14,14,12, - 12,14,15,15,10,10,14,15,15,11,11,15,15,15,10,10, - 15,15,15,12,12,15,14,14,13,13,15,15,15,10,10,15, - 14,14,11,11,15,15,15,10,10,14,10,10,10,10,14, 9, - 9,12,12,15,10,10,12,12,14,11,11,11,11,15,13,14, - 12,12,15,10,10,13,13,15,13,13,12,12,15, 9, 9,12, - 12,15,10,10,13,13,15,13,14,11,11,15,10,10,12,12, - 15,13,13,12,12,15, 9, 9,11,11,15,10,10,12,12,15, - 13,13,11,11,15,11,11,12,12,15,13,13,13,13,15,10, - 10,11,11,15,11,11,12,12,15,14,14,11,11,15,14,14, - 13,13,15,14,14,20,19,15,14,14,11,11,15,14,14,12, - 12,15,14,14,11,11,14,13,13,11,11,15,13,13,11,11, - 15,14,13,12,12,15,14,14,11,12,15,14,14,11,11,15, - 14,14,12,12,14,14,14,13,13,15,14,14,11,11,15,14, - 14,11,11,15,14,14,13,13,15,14,14,12,12,15,14,14, - 13,13,14,14,14,11,11,15,14,14,11,11,15,14,14,13, - 13,15,14,14,12,12,15,14,14,12,12,15,14,14,12,12, - 15,14,14,11,11,14,14,14,12,12,15,15,15,13,13,16, - 14,14,12,12,15,15,15,13,13,15,14,14,12,12,15,15, - 15,12,12,15,11,11,13,13,18,10,10,12,12,17,11,11, - 12,12,18,12,12,11,11,18,14,14,12,12,18,10,10,13, - 13,18,14,14,12,12,18,10,10,12,12,18,11,11,12,12, - 18,14,14,12,12,18,11,11,12,13,18,14,14,12,12,18, - 10,10,12,12,18,11,11,12,12,18,14,14,11,11,18,11, - 11,12,12,18,14,14,12,12,17,10,10,11,11,17,12,12, - 11,11,17,14,14,11,11,18,15,15,12,12,18,14,14,13, - 13,18,15,15,11,11,18,15,14,12,12,18,15,15,11,11, - 14, 8, 8,11,11,14,15,15,10,10,14,15,15,11,11,14, - 15,15,11,11,15,15,15,12,12,15,15,15,11,11,15,15, - 15,12,12,14,15,15,10,10,15,15,15,11,11,15,15,15, - 12,12,15,15,15,11,11,15,15,15,13,13,14,15,15,10, - 10,15,15,15,11,11,15,15,15,12,12,15,15,15,12,12, - 15,16,16,12,12,15,14,14,11,11,15,15,15,11,11,15, - 15,15,12,12,16,15,15,13,13,15,16,16,13,13,16,15, - 15,12,12,15,15,15,12,12,15,15,15,12,12,14,13,13, - 11,11,14,14,14,11,11,14,14,14,12,12,15,14,14,11, - 11,15,15,14,11,11,15,14,14,12,12,15,14,14,12,12, - 14,15,15,11,11,15,14,14,12,12,15,14,14,11,11,15, - 14,15,12,12,15,14,14,12,12,14,15,15,11,11,15,14, - 14,11,11,15,14,14,11,11,15,15,14,12,12,15,14,14, - 12,12,15,15,15,10,11,15,14,14,11,11,15,15,15,10, - 10,15,15,15,12,12,16,14,14,13,13,15,15,15,11,11, - 15,14,14,11,11,15,15,15,11,11,14,11,11, 9, 9,14, - 10,10,12,12,15,11,11,12,12,15,12,12,12,12,15,14, - 14,13,13,15,11,11,12,12,15,14,14,13,13,14,10,10, - 12,12,15,11,11,13,13,15,14,14,12,12,15,10,10,12, - 12,14,14,14,13,13,14,10,10,11,11,15,11,11,12,12, - 15,14,14,12,12,15,12,12,13,13,15,14,14,14,14,15, - 11,11,11,11,15,12,11,12,12,15,14,14,11,11,15,15, - 15,13,14,15,14,14,20,19,15,14,14,12,12,15,14,14, - 13,13,15,14,14,12,12,14,13,13,10,10,14,13,13,11, - 11,14,13,13,11,11,15,14,14,12,12,15,14,14,12,12, - 15,14,14,12,11,14,14,14,13,13,15,14,14,11,11,15, - 14,14,11,11,15,14,14,14,14,15,14,14,11,12,15,14, - 14,13,13,14,14,14,11,11,15,14,14,11,11,15,14,14, - 14,14,15,14,14,12,12,15,14,14,13,13,15,14,14,11, - 11,14,14,14,12,12,15,14,14,13,13,15,15,15,13,13, - 15,14,14,13,13,15,15,15,13,13,15,14,14,13,13,15, - 15,15,13,13,15,14,14,13,13,18,15,15,12,12,18,15, - 15,12,12,18,16,16,11,11,18,17,17,12,12,18,15,15, - 13,13,18,17,17,12,12,18,15,15,12,12,18,15,16,12, - 12,18,17,17,12,12,18,15,15,13,12,17,16,17,12,12, - 17,15,15,11,12,18,15,15,12,12,18,17,17,11,11,18, - 16,16,12,12,18,17,16,12,12,18,15,15,11,11,18,15, - 15,12,12,18,17,17,11,11,18,17,17,12,12,18,16,16, - 13,13,18,17,17,11,11,17,16,16,11,11,18,17,17,11, - 11,15,15,15,11,11,16,15,15,11,11,16,15,15,11,11, - 16,15,15,12,12,17,15,15,14,14,16,15,15,11,11,17, - 15,15,14,14,16,15,15,11,11,16,15,15,12,12,18,15, - 15,13,13,16,15,15,11,11,17,15,15,14,14,16,15,15, - 11,11,16,15,15,12,12,17,15,15,13,13,16,15,15,12, - 12,17,16,15,14,14,16,15,15,11,11,16,15,15,12,12, - 18,15,15,13,13,17,15,15,14,14,17,16,16,15,15,18, - 14,15,13,13,18,15,15,14,14,18,15,15,13,13,15,13, - 13,12,12,15,14,14,12,12,16,14,14,12,12,16,14,14, - 12,12,17,14,15,12,12,16,14,14,12,12,17,14,14,13, - 13,16,15,15,12,12,16,14,14,12,12,17,14,14,12,12, - 16,14,14,12,12,17,14,14,13,13,15,15,15,11,11,16, - 14,14,12,12,17,14,14,12,12,16,15,15,12,12,17,14, - 14,13,12,16,15,15,11,11,16,14,14,12,12,17,15,15, - 11,11,17,15,15,13,13,17,14,14,13,13,18,15,15,12, - 12,17,14,14,12,12,17,15,15,12,12,14,15,15, 9, 9, - 14,15,15,12,12,15,16,15,13,13,15,15,15,14,14,15, - 15,15,21,19,15,15,15,13,13,15,15,15,19,19,15,15, - 15,12,12,15,16,16,14,14,15,15,15,19,19,15,16,15, - 13,13,15,16,16,19,20,15,15,15,12,13,15,16,16,14, - 14,15,15,15,20,19,15,15,15,14,14,15,16,16,19,19, - 15,15,15,14,13,15,15,15,14,14,15,15,15,19,19,15, - 16,16,20,19,15,17,16,21,20,15,15,15,20,19,15,16, - 16,20,20,15,15,15,19,20,14,13,13,10,10,14,14,14, - 11,11,14,14,14,12,12,15,14,14,13,13,15,15,14,20, - 20,15,14,14,12,12,14,14,14,19,19,15,14,14,11,11, - 15,14,14,12,12,15,14,14,20,19,15,14,14,12,12,14, - 14,14,20,20,14,14,14,11,11,15,14,14,12,12,15,14, - 14,20,21,15,14,14,13,13,15,14,14,20,20,15,14,14, - 12,12,15,14,14,13,13,14,15,15,20,20,15,15,15,20, - 19,15,14,14,20,19,15,15,15,20,20,15,14,14,21,20, - 15,15,15,20,20, -}; - -static const static_codebook _44p4_p4_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p4_p4_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p4_p4_1, - 0 -}; - -static const long _vq_quantlist__44p4_p5_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p4_p5_0[] = { - 1, 7, 6,15,15, 7, 8, 8,15,15, 8, 8, 8,15,15, 0, - 13,13,16,16, 0,14,14,16,16, 7, 9, 9,16,16,10,11, - 11,17,17,10, 8, 8,15,16, 0,14,14,18,18, 0,14,14, - 16,16, 9, 9, 9,16,16,12,11,11,17,17,10, 9, 9,15, - 15, 0,14,14,19,19, 0,14,14,16,16, 0,15,15,18,17, - 0, 0, 0,20,20, 0,13,13,16,16, 0,17,17,22,20, 0, - 15,15,17,17, 0,15,15,18,18, 0,22,21,20,21, 0,13, - 13,16,16, 0,18,18, 0,22, 0,15,15,17,17, 6, 7, 7, - 13,13, 9,10,10,15,15,11,10,10,15,15, 0,21,22,18, - 18, 0, 0, 0,18,18,10,10,10,15,15,12,13,13,17,17, - 12,11,11,15,15, 0,22,22,18,18, 0, 0,21,18,18,12, - 11,11,15,15,15,14,14,18,18,13,11,11,15,15, 0, 0, - 21,18,19, 0,21,22,18,19, 0,22, 0,18,19, 0, 0, 0, - 0, 0, 0,21,21,18,18, 0,22, 0, 0,21, 0, 0, 0,19, - 18, 0, 0, 0,18,19, 0, 0, 0, 0, 0, 0,20,20,18,17, - 0, 0,22, 0,21, 0, 0, 0,19,19, 6, 6, 6,13,13, 8, - 6, 6,11,11, 9, 7, 7,13,13, 0,10,10,11,11, 0,12, - 12,14,14, 9, 8, 8,14,14,12,10,10,13,13,10, 7, 7, - 13,13, 0,11,11,15,15, 0,11,11,13,13, 9, 8, 8,14, - 14,13,10,10,13,14,11, 7, 7,13,13, 0,11,11,15,15, - 0,11,11,13,13, 0,12,12,15,15, 0,21,21,17,17, 0, - 10,10,13,13, 0,14,14,20,20, 0,12,12,13,13, 0,12, - 12,15,15, 0,21,22,17,18, 0,10,10,13,13, 0,16,16, - 20,21, 0,12,12,13,13, 0,11,11,13,13, 0,12,12,16, - 16, 0,12,12,16,16, 0,16,16, 0,21, 0,17,18, 0, 0, - 0,12,12,15,15, 0,15,15,18,18, 0,12,12,16,16, 0, - 16,16,21,22, 0,17,17,22,21, 0,12,12,16,16, 0,15, - 15,19,19, 0,12,12,16,16, 0,16,16,22,22, 0,17,16, - 22, 0, 0,17,18, 0, 0, 0, 0, 0, 0, 0, 0,15,15,21, - 20, 0,19,20, 0,22, 0,18,18, 0, 0, 0,18,17, 0, 0, - 0, 0, 0, 0, 0, 0,16,16,22,21, 0,20,20, 0,22, 0, - 20,19, 0, 0, 0,11,11,12,12, 0,10,10,11,11, 0,11, - 11,12,12, 0,12,12,10,10, 0,13,13,12,12, 0,11,11, - 13,13, 0,13,13,12,12, 0,10,10,12,12, 0,13,13,14, - 13, 0,12,12,12,12, 0,12,12,13,13, 0,14,14,13,13, - 0,10,10,12,12, 0,13,13,14,14, 0,13,12,12,12, 0, - 14,14,14,14, 0,21,21,16,16, 0,12,12,12,12, 0,16, - 16,20,21, 0,13,13,11,11, 0,14,14,14,14, 0,20,20, - 16,15, 0,12,12,12,12, 0,17,17,20,20, 0,13,13,11, - 11, 7, 8, 8,16,16,11,10,10,15,15,12,10,10,17,17, - 0,14,14,16,15, 0,15,15,17,17,11, 9, 9,16,16,14, - 12,12,17,17,13, 9, 9,16,15, 0,14,14,19,18, 0,14, - 14,16,16,12,10,10,17,18,16,13,13,17,18,14,10,10, - 16,16, 0,14,14,19,19, 0,14,15,17,17, 0,15,15,18, - 19, 0, 0, 0,20,20, 0,13,13,17,17, 0,17,18, 0,22, - 0,15,15,16,17, 0,15,15,18,18, 0, 0, 0,20,21, 0, - 14,14,17,17, 0,19,18, 0, 0, 0,16,16,17,17, 8, 7, - 7,14,14,12,11,11,15,15,13,11,11,15,15, 0, 0, 0, - 18,19, 0,21,20,18,18,12,10,11,15,16,14,13,13,18, - 18,14,11,11,15,15, 0,20,20,19,18, 0,20, 0,18,18, - 13,11,11,16,16,17,15,15,19,19,14,12,12,15,15, 0, - 21, 0,18,20, 0,22,22,18,19, 0,22,22,19,19, 0, 0, - 0, 0, 0, 0,21,22,19,18, 0, 0, 0, 0,21, 0, 0, 0, - 19,19, 0, 0,22,20,20, 0, 0, 0, 0, 0, 0,22, 0,18, - 18, 0, 0, 0, 0,22, 0, 0, 0,19,20,11,10,10,14,14, - 14,11,11,13,13,14,11,11,15,15, 0,14,13,12,12, 0, - 15,15,16,16,13,11,11,15,15,16,13,13,15,15,15,10, - 10,14,15, 0,14,14,16,16, 0,14,14,15,15,13,11,11, - 15,15,18,14,14,15,15,15,10,10,15,14, 0,14,14,16, - 16, 0,14,14,15,15, 0,15,15,17,16, 0,21,22,18,18, - 0,13,13,14,14, 0,18,17,20,21, 0,15,15,14,14, 0, - 15,16,16,17, 0, 0, 0,19,18, 0,13,13,15,14, 0,19, - 19, 0, 0, 0,15,15,14,14, 0,12,12,14,13, 0,13,13, - 16,16, 0,12,12,16,16, 0,16,16,22, 0, 0,17,18, 0, - 22, 0,13,13,16,16, 0,15,15,18,18, 0,12,12,16,16, - 0,16,16,22,22, 0,17,17, 0, 0, 0,13,13,17,17, 0, - 16,16,19,20, 0,12,12,17,17, 0,17,17,22, 0, 0,17, - 17,22,21, 0,18,18, 0, 0, 0, 0, 0, 0, 0, 0,16,16, - 21,21, 0,19,19, 0, 0, 0,18,18, 0,22, 0,18,18, 0, - 22, 0, 0, 0, 0, 0, 0,16,16,22, 0, 0,20,20, 0, 0, - 0,19,18, 0, 0, 0,12,12,15,15, 0,12,12,15,14, 0, - 13,13,15,15, 0,14,14,14,14, 0,15,15,16,16, 0,13, - 13,15,16, 0,15,15,16,16, 0,12,12,15,15, 0,14,14, - 16,16, 0,14,14,15,15, 0,13,13,15,16, 0,15,15,16, - 16, 0,12,12,15,15, 0,15,15,17,17, 0,14,14,15,15, - 0,15,15,17,17, 0,21,21,19,19, 0,13,13,14,14, 0, - 17,17,22, 0, 0,14,14,15,15, 0,15,15,17,17, 0,22, - 0,18,20, 0,13,13,15,15, 0,18,18, 0,22, 0,15,15, - 14,15, 8, 8, 8,17,16,12,10,10,16,16,13,10,10,17, - 16, 0,15,15,17,17, 0,15,15,17,17,12,11,11,18,18, - 15,12,12,18,18,15,10,10,16,17, 0,14,14,18,18, 0, - 14,14,17,17,13,10,10,16,16,17,14,14,17,17,15,10, - 10,16,15, 0,15,15,19,20, 0,14,14,15,16, 0,16,16, - 19,19, 0, 0, 0,21,22, 0,13,13,17,17, 0,18,17, 0, - 21, 0,15,15,17,17, 0,15,15,18,19, 0, 0,22, 0,21, - 0,13,13,16,17, 0,19,19, 0,22, 0,16,15,16,16, 9, - 8, 8,14,14,12,11,11,15,15,13,11,11,15,15, 0,21, - 20,19,18, 0, 0, 0,19,18,12,11,11,16,15,15,13,13, - 17,18,14,11,11,15,15, 0,22,22,19,18, 0,22,21,18, - 18,14,11,11,15,15,17,14,14,18,18,15,12,12,15,15, - 0,22,22,20,19, 0, 0,21,18,18, 0, 0,22,20,20, 0, - 0, 0, 0, 0, 0,20,21,18,18, 0, 0, 0,21,21, 0, 0, - 0,20,19, 0,22,21,19,19, 0, 0, 0, 0, 0, 0, 0,22, - 17,18, 0, 0,22, 0,22, 0,22, 0,19,19, 0,11,11,15, - 15, 0,11,11,14,14, 0,12,12,15,15, 0,15,15,14,14, - 0,16,16,16,16, 0,12,12,16,16, 0,14,14,16,16, 0, - 11,11,15,15, 0,15,15,17,17, 0,15,15,15,15, 0,12, - 12,16,16, 0,14,14,15,15, 0,11,11,15,15, 0,15,15, - 17,17, 0,15,15,14,15, 0,16,16,17,17, 0, 0, 0,19, - 19, 0,14,14,15,15, 0,18,18,21, 0, 0,15,15,14,15, - 0,16,16,17,17, 0,21, 0,19,19, 0,14,14,15,15, 0, - 20,20,22, 0, 0,16,15,14,14, 0,12,12,13,13, 0,12, - 12,16,16, 0,12,12,16,16, 0,16,16,22,21, 0,18,17, - 21, 0, 0,13,13,16,16, 0,15,15,18,19, 0,12,12,16, - 16, 0,16,17,22, 0, 0,17,17, 0,22, 0,13,13,17,16, - 0,15,15,19,19, 0,12,12,16,16, 0,16,16,21,20, 0, - 17,16,22, 0, 0,18,18,22,21, 0, 0, 0, 0, 0, 0,15, - 16,21,21, 0,19,19, 0, 0, 0,18,17, 0, 0, 0,18,18, - 21, 0, 0, 0, 0, 0, 0, 0,16,16,22,22, 0,20,21, 0, - 0, 0,18,19, 0,22, 0,13,13,16,16, 0,12,12,15,15, - 0,13,13,16,16, 0,14,14,15,15, 0,15,15,17,17, 0, - 13,13,17,16, 0,15,15,17,17, 0,12,12,16,16, 0,15, - 15,17,17, 0,14,14,16,16, 0,13,13,16,17, 0,15,15, - 17,17, 0,12,12,16,16, 0,14,14,17,17, 0,14,14,16, - 16, 0,16,16,17,17, 0,21, 0,21,19, 0,13,13,16,16, - 0,17,17, 0, 0, 0,15,15,16,16, 0,16,15,18,18, 0, - 22, 0,20,20, 0,13,13,15,15, 0,18,18, 0, 0, 0,15, - 15,15,15, 0,12,12,17,17, 0,14,14,17,17, 0,14,14, - 17,17, 0,17,17,18,17, 0,17,17,19,18, 0,13,13,17, - 17, 0,16,16,18,18, 0,13,13,16,16, 0,17,17,19,19, - 0,16,16,17,17, 0,13,13,18,18, 0,17,17,18,18, 0, - 13,13,17,17, 0,17,17,19,19, 0,16,17,17,17, 0,17, - 17,19,19, 0,21, 0,21,19, 0,14,14,16,16, 0,20,19, - 0,21, 0,16,16,16,16, 0,17,18,19,19, 0, 0, 0, 0, - 21, 0,15,15,16,17, 0,21,20, 0, 0, 0,17,18,16,17, - 0, 9, 9,14,14, 0,14,14,15,16, 0,14,14,15,15, 0, - 0, 0,18,18, 0,21, 0,18,19, 0,12,12,15,15, 0,16, - 16,17,17, 0,14,14,14,14, 0,22, 0,19,18, 0,22, 0, - 17,18, 0,14,14,16,15, 0,18,18,19,18, 0,14,15,15, - 15, 0, 0,21,20,20, 0, 0, 0,18,18, 0,21,21,19,19, - 0, 0, 0, 0, 0, 0,21,21,18,18, 0,22, 0,20,20, 0, - 22, 0,19,19, 0,22, 0,19,20, 0, 0, 0, 0, 0, 0, 0, - 21,17,18, 0, 0, 0,22,22, 0, 0, 0,19,18, 0,18,20, - 16,16, 0,21,20,17,17, 0, 0,21,18,18, 0,22,21,18, - 18, 0, 0,22,19,19, 0,20,20,17,17, 0, 0, 0,18,18, - 0,19,20,17,17, 0,22, 0,19,21, 0,22,21,18,18, 0, - 20,19,17,18, 0, 0, 0,19,19, 0,20,20,17,17, 0,22, - 22,21,21, 0,20, 0,18,18, 0,22,22,18,18, 0, 0, 0, - 20,22, 0,20,20,16,16, 0, 0, 0,21, 0, 0,21,20,16, - 17, 0,22, 0,19,20, 0, 0, 0,21,20, 0,19,21,17,17, - 0, 0, 0, 0, 0, 0,21,21,17,17, 0,12,12,13,13, 0, - 14,14,16,16, 0,14,14,16,16, 0,18,18, 0, 0, 0,19, - 18,22, 0, 0,13,13,16,16, 0,16,16,18,18, 0,13,13, - 16,16, 0,17,18,21, 0, 0,18,18,21, 0, 0,13,13,16, - 16, 0,17,17,19,20, 0,13,13,16,17, 0,18,18,21, 0, - 0,18,18,21, 0, 0,18,19, 0,21, 0, 0, 0, 0, 0, 0, - 16,16,21,20, 0,20,20, 0, 0, 0,18,19, 0, 0, 0,18, - 18, 0, 0, 0, 0, 0, 0, 0, 0,16,16, 0,21, 0,22,22, - 0, 0, 0,19,19, 0, 0, 0,16,16,19,20, 0,17,16,22, - 21, 0,17,17,21,20, 0,19,18, 0,22, 0,19,19,22,22, - 0,16,15,22,22, 0,19,19, 0,21, 0,15,15,20,20, 0, - 18,19, 0,21, 0,18,18,22,22, 0,16,16,21,20, 0,20, - 19,21,22, 0,16,15,20,20, 0,19,19, 0,22, 0,18,18, - 21, 0, 0,19,18,21,22, 0, 0, 0, 0, 0, 0,16,16,19, - 21, 0,20,22, 0,22, 0,18,18,20,21, 0,19,18, 0,22, - 0, 0, 0,22, 0, 0,16,16,20,20, 0,21,21, 0, 0, 0, - 18,18,21, 0, 0,12,12,17,17, 0,15,14,17,17, 0,14, - 14,18,18, 0,17,17,17,18, 0,18,18,18,18, 0,13,13, - 18,18, 0,16,17,19,18, 0,13,13,16,17, 0,17,17,18, - 19, 0,17,17,17,17, 0,13,13,17,17, 0,17,18,18,18, - 0,13,13,16,16, 0,18,18,19,20, 0,16,17,17,16, 0, - 17,18,19,18, 0, 0, 0,22,21, 0,15,15,16,16, 0,20, - 20,21,22, 0,17,17,16,16, 0,16,17,18,18, 0, 0, 0, - 21,21, 0,15,15,16,16, 0,21,20, 0, 0, 0,17,17,16, - 16, 0,10,10,14,14, 0,14,14,15,15, 0,14,14,15,15, - 0,22, 0,18,18, 0, 0, 0,19,19, 0,13,13,15,16, 0, - 17,16,18,18, 0,14,14,15,15, 0,21,21,19,18, 0,22, - 21,18,17, 0,14,14,15,15, 0,18,18,19,18, 0,15,15, - 14,14, 0,22,21,19,19, 0,22,21,17,18, 0, 0, 0,19, - 19, 0, 0, 0, 0, 0, 0,20,22,17,17, 0, 0,22,22,20, - 0, 0, 0,19,18, 0,21,22,19,18, 0, 0, 0, 0, 0, 0, - 22,22,17,18, 0, 0, 0,21,22, 0, 0, 0,19,18, 0,20, - 20,17,17, 0,21,21,17,18, 0,21,22,18,18, 0,21, 0, - 18,18, 0,22, 0,19,19, 0,19,21,18,18, 0, 0,22,18, - 18, 0,22,21,17,17, 0,22, 0,20,20, 0, 0, 0,18,18, - 0,22,21,18,18, 0,21, 0,19,19, 0,20,21,17,17, 0, - 0,22,22,20, 0,21,22,17,17, 0, 0,21,19,18, 0, 0, - 0,21,21, 0,21,20,16,17, 0, 0, 0, 0, 0, 0,21, 0, - 17,17, 0,21, 0,19,20, 0, 0, 0,20,22, 0,20,20,17, - 17, 0, 0, 0, 0, 0, 0,21,21,17,17, 0,12,12,13,13, - 0,14,14,16,16, 0,14,14,16,16, 0,18,18,21, 0, 0, - 19,19,22, 0, 0,13,13,16,16, 0,16,16,18,18, 0,13, - 13,16,16, 0,18,18,21,22, 0,18,18, 0,22, 0,13,13, - 16,16, 0,17,17,20,18, 0,13,13,16,16, 0,19,18, 0, - 22, 0,18,18,22,21, 0,18,19, 0, 0, 0, 0, 0, 0, 0, - 0,16,16,21,21, 0,21,21, 0, 0, 0,18,19, 0, 0, 0, - 19,19,21, 0, 0, 0, 0, 0, 0, 0,16,16, 0,21, 0,20, - 20, 0, 0, 0,20,20, 0, 0, 0,16,16,21,20, 0,18,17, - 21,22, 0,17,18, 0,21, 0,18,19,22,22, 0,19,19, 0, - 22, 0,16,17,21,22, 0,20,19, 0, 0, 0,16,16,20,21, - 0,19,19, 0, 0, 0,19,19, 0,22, 0,17,17,21,21, 0, - 19,20, 0, 0, 0,16,16, 0,20, 0,19,20, 0,21, 0,18, - 18, 0,22, 0,19,20,22,22, 0, 0, 0, 0,22, 0,17,17, - 0,21, 0,21,21, 0, 0, 0,18,19,23,21, 0,20,19, 0, - 0, 0, 0, 0, 0, 0, 0,17,17, 0,20, 0, 0, 0, 0, 0, - 0,19,19,23,22, -}; - -static const static_codebook _44p4_p5_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p4_p5_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p4_p5_0, - 0 -}; - -static const long _vq_quantlist__44p4_p5_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p4_p5_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p4_p5_1 = { - 1, 7, - (char *)_vq_lengthlist__44p4_p5_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p4_p5_1, - 0 -}; - -static const long _vq_quantlist__44p4_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p4_p6_0[] = { - 1, 7, 7, 7, 8, 8, 7, 8, 8, 7, 9, 9,11,11,11, 9, - 8, 8, 8, 9, 9,12,11,12, 9, 8, 8, 6, 7, 7,10,11, - 11,10,10,10,11,11,11,14,14,14,12,11,12,11,11,11, - 15,15,14,13,12,12, 5, 6, 6, 8, 5, 5, 8, 7, 7, 8, - 7, 7,12,10,10,10, 7, 6, 9, 8, 8,12,10,10,10, 6, - 6, 7, 8, 8,12,10,10,12,10,10,11,10,10,16,14,14, - 13,10,10,12,10,10,15,14,14,14,10,10, 7, 7, 7,13, - 11,11,13,11,11,12,11,11,16,14,14,14,12,12,12,11, - 11,18,15,15,14,12,12,10, 9,10,14,11,11,13,11,11, - 12,11,11,17,14,14,14,11,11,13,11,11,16,15,15,14, - 11,11, 7, 8, 8,13,11,11,12,10,10,12,10,10,16,14, - 13,13,10,10,12,10,10,17,14,14,14,10,10, 8, 7, 7, - 12,11,11,13,11,11,12,11,11,16,15,14,14,12,12,12, - 11,11,16,15,15,14,12,12,11,10,10,14,11,11,13,11, - 11,13,11,11,17,14,14,14,11,11,13,11,11,18,14,15, - 15,11,10, -}; - -static const static_codebook _44p4_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p4_p6_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p4_p6_0, - 0 -}; - -static const long _vq_quantlist__44p4_p6_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p4_p6_1[] = { - 2, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, - 7, 7, 8, 8, 8, 9, 9, 9, 9, 8, 8, 6, 7, 7, 8, 8, - 8, 8, 8, 8, 9, 8, 8, 9, 8, 9, 9, 8, 8,10, 8, 8, - 10, 9, 9,10, 8, 8, 6, 6, 6, 8, 6, 6, 8, 7, 7, 8, - 7, 7,10, 8, 8, 9, 7, 7, 9, 7, 7,10, 8, 8, 9, 7, - 7, 7, 7, 7,10, 8, 8,11, 9, 9,10, 9, 9,11, 9, 9, - 11, 8, 8,11, 9, 9,12, 9, 9,12, 8, 8, 7, 7, 7,10, - 9, 9,10, 9, 9,10, 9, 9,11,10,10,10, 9, 9,11, 9, - 10,11,10,11,10, 9, 9, 9, 8, 8,10, 9, 9,10, 9, 9, - 11, 9, 9,11,10,10,11, 9, 9,11, 9, 9,11,10,10,11, - 9, 9, 8, 8, 8,11, 9, 9,11, 9, 9,11, 9, 9,12, 9, - 9,12, 8, 8,11, 9, 9,12, 9, 9,12, 8, 8, 8, 7, 7, - 10, 9, 9,10, 9, 9,10, 9, 9,11,11,11,11, 9, 9,11, - 10,10,11,11,11,11, 9, 9,10, 9, 9,11, 9, 9,11, 9, - 10,11,10,10,11,10,10,11, 9, 9,11,10,10,11,10,10, - 11, 9, 9, -}; - -static const static_codebook _44p4_p6_1 = { - 5, 243, - (char *)_vq_lengthlist__44p4_p6_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p4_p6_1, - 0 -}; - -static const long _vq_quantlist__44p4_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p4_p7_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p4_p7_0 = { - 5, 243, - (char *)_vq_lengthlist__44p4_p7_0, - 1, -513979392, 1633504256, 2, 0, - (long *)_vq_quantlist__44p4_p7_0, - 0 -}; - -static const long _vq_quantlist__44p4_p7_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p4_p7_1[] = { - 1, 9, 9, 7, 9, 9, 8, 8, 9, 9, 9, 9, 9, 9, 9, 8, - 9, 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 7, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 6, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 5, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 5,10, 9,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10, 8,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10, -}; - -static const static_codebook _44p4_p7_1 = { - 5, 243, - (char *)_vq_lengthlist__44p4_p7_1, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p4_p7_1, - 0 -}; - -static const long _vq_quantlist__44p4_p7_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p4_p7_2[] = { - 1, 3, 2, 5, 4, 7, 7, 8, 8, 9, 9,10,10,11,11,12, - 12,13,13,14,14,15,15,15,15, -}; - -static const static_codebook _44p4_p7_2 = { - 1, 25, - (char *)_vq_lengthlist__44p4_p7_2, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p4_p7_2, - 0 -}; - -static const long _vq_quantlist__44p4_p7_3[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p4_p7_3[] = { - 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p4_p7_3 = { - 1, 25, - (char *)_vq_lengthlist__44p4_p7_3, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p4_p7_3, - 0 -}; - -static const char _huff_lengthlist__44p4_short[] = { - 3, 5,16, 9, 9,13,18,21, 4, 2,21, 6, 6,10,15,21, - 16,19, 6, 5, 7,10,13,16, 8, 6, 5, 4, 4, 8,13,16, - 8, 5, 6, 4, 4, 7,12,15,13,10, 9, 7, 7, 9,13,16, - 18,15,13,12, 9, 7,10,14,21,18,13,13, 7, 5, 8,12, -}; - -static const static_codebook _huff_book__44p4_short = { - 2, 64, - (char *)_huff_lengthlist__44p4_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p5_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p5_l0_0[] = { - 1, 4, 4, 8, 8,10,10,10,10, 9, 8,11,11, 4, 6, 5, - 8, 6,10,10,10,10,10, 9,10, 9, 4, 5, 6, 6, 9,10, - 10,10,10, 9,10, 9,10, 8, 9, 8, 9, 8, 9, 9,10, 9, - 11,10,12,10, 8, 8, 9, 8, 9, 9, 9, 9,10,10,11,10, - 12, 9,10,10,11,10,11,10,12,11,12,11,13,11, 9,10, - 10,10,11,10,11,11,12,11,12,11,12,11,12,12,12,12, - 13,12,13,12,13,12,13,13,11,12,12,12,12,12,12,12, - 13,13,13,13,13,12,12,12,13,13,13,13,13,13,13,13, - 13,13,12,13,12,13,13,13,13,13,13,13,13,13,13,12, - 13,13,13,14,14,13,13,13,13,13,13,13,12,13,12,13, - 13,13,13,13,13,13,13,13,13, -}; - -static const static_codebook _44p5_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p5_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p5_l0_0, - 0 -}; - -static const long _vq_quantlist__44p5_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p5_l0_1[] = { - 4, 4, 4, 5, 5, 4, 5, 5, 5, 5, 4, 5, 4, 4, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p5_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p5_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p5_l0_1, - 0 -}; - -static const long _vq_quantlist__44p5_l1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p5_l1_0[] = { - 1, 4, 4, 4, 4, 4, 4, 4, 4, -}; - -static const static_codebook _44p5_l1_0 = { - 2, 9, - (char *)_vq_lengthlist__44p5_l1_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p5_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p5_lfe[] = { - 1, 3, 2, 3, -}; - -static const static_codebook _huff_book__44p5_lfe = { - 2, 4, - (char *)_huff_lengthlist__44p5_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p5_long[] = { - 3, 7,12,14,14,16,18,19, 6, 2, 4, 6, 8, 9,12,14, - 12, 3, 3, 5, 7, 8,11,13,13, 6, 4, 5, 7, 8,10,11, - 14, 8, 7, 7, 7, 7, 9,10,15, 9, 8, 7, 7, 6, 8, 9, - 17,11,11,10, 9, 8, 9, 9,19,14,13,11,10, 9, 9, 9, -}; - -static const static_codebook _huff_book__44p5_long = { - 2, 64, - (char *)_huff_lengthlist__44p5_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p5_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p5_p1_0[] = { - 2, 5, 5, 5, 7, 7, 5, 7, 7, 5, 7, 7, 7, 8, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 7, 9, 8, 5, 7, 8, 8, 9, - 10, 8, 9,10, 8, 9,10, 9,10,12,10,11,11, 8,10,10, - 10,11,11, 9,11,11, 5, 8, 7, 8, 9, 9, 8,10, 9, 8, - 10,10, 9,11,11,10,11,11, 8,10, 9,10,11,11, 9,12, - 10, 5, 8, 8, 7, 9,10, 8,10, 9, 7, 9, 9, 9,10,11, - 9,11,11, 8,10, 9,10,11,11,10,11,11, 7, 9, 9, 9, - 10,11, 9,11,11, 9, 9,11,10,10,13,11,11,12, 9,11, - 11,11,12,13,11,13,12, 7, 9, 9, 9,11,11, 9,11,10, - 9,11,10,10,11,12,11,13,12, 9,11,11,11,12,13,11, - 13,11, 5, 8, 8, 8, 9,10, 7,10, 9, 8, 9,10,10,11, - 11,10,11,11, 7, 9, 9, 9,11,11, 9,11,10, 7, 9, 9, - 9,10,11, 9,11,11, 9,11,11,11,11,13,11,13,12, 9, - 10,11,11,12,13,10,12,11, 7, 9, 9, 9,11,11, 9,11, - 10, 9,11,11,11,12,13,11,13,12, 9,11, 9,11,12,11, - 10,13,10, -}; - -static const static_codebook _44p5_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p5_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p5_p1_0, - 0 -}; - -static const long _vq_quantlist__44p5_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p5_p2_0[] = { - 4, 6, 6, 9, 9, 6, 7, 8,10,10, 6, 8, 7,10,10, 8, - 10,10,12,13, 8,10,10,13,12, 6, 7, 8,10,10, 7, 8, - 9,10,11, 8, 9, 9,11,11,10,10,11,12,14,10,11,11, - 14,13, 6, 8, 7,10,10, 8, 9, 9,11,11, 7, 9, 8,11, - 10,10,11,11,13,14,10,11,10,14,12, 9,10,10,12,12, - 10,10,11,12,13,10,11,11,13,13,12,12,13,12,15,13, - 14,13,15,14, 9,10,10,12,12,10,11,11,13,13,10,11, - 10,13,12,13,13,14,14,15,12,13,12,15,12, 6, 7, 8, - 10,11, 8, 9,10,11,12, 8, 9, 9,11,12,10,11,12,13, - 14,10,11,11,14,13, 8, 9,10,11,12, 9,10,11,12,13, - 9,10,11,12,13,11,12,13,13,15,12,12,13,15,14, 8, - 9, 9,12,12, 9,10,11,12,13, 9,10,10,13,12,12,12, - 13,14,15,11,12,12,14,14,11,11,12,13,14,11,12,13, - 13,15,12,13,13,14,15,14,13,15,14,16,14,15,15,16, - 16,11,12,11,14,13,12,13,13,15,14,11,13,12,14,13, - 14,15,15,15,16,13,14,14,16,14, 6, 8, 7,11,10, 8, - 9, 9,11,12, 8,10, 9,12,11,10,11,11,13,14,10,12, - 11,14,13, 8, 9, 9,12,12, 9,10,10,12,13, 9,11,10, - 13,12,11,12,12,13,14,12,13,12,15,14, 8,10, 9,12, - 11, 9,11,10,13,12, 9,11,10,13,12,12,13,12,14,15, - 11,13,12,15,13,11,11,12,13,14,11,12,13,13,15,12, - 13,13,14,15,13,14,14,14,16,14,15,15,16,16,11,12, - 11,14,13,12,13,13,15,14,11,13,12,15,13,14,15,15, - 16,16,13,15,13,16,14, 9,10,11,12,14,11,11,12,13, - 15,11,12,12,13,14,13,14,15,15,17,13,14,14,15,16, - 11,11,12,13,15,12,12,13,14,16,12,13,13,14,15,14, - 14,16,15,17,15,15,15,16,17,11,12,12,14,14,12,13, - 13,15,16,12,13,13,15,15,15,15,15,16,17,14,15,15, - 16,16,14,14,15,15,17,14,15,15,15,17,15,15,16,16, - 17,16,16,17,16,18,17,17,17,18,18,14,15,14,16,16, - 15,15,16,17,17,14,15,15,17,16,17,17,17,18,18,16, - 16,16,17,17, 9,11,10,14,12,11,12,12,14,13,11,12, - 11,15,13,13,14,14,16,15,13,15,14,17,15,11,12,12, - 15,14,12,13,13,15,15,12,13,13,15,15,14,15,15,16, - 16,15,15,15,17,16,11,12,11,15,13,12,13,13,15,14, - 12,13,12,16,14,15,15,15,17,16,14,15,14,17,15,14, - 14,15,16,16,14,15,15,16,16,15,16,15,17,17,16,16, - 16,17,17,17,17,17,18,17,14,15,14,16,15,15,15,15, - 17,16,15,15,15,17,15,17,17,17,18,18,16,17,16,18, - 16, 6, 8, 8,11,11, 8, 9, 9,11,12, 8, 9, 9,12,11, - 10,11,11,13,14,10,12,11,14,13, 7, 9, 9,11,12, 9, - 10,10,12,13, 9,10,10,13,13,11,11,12,13,15,11,12, - 12,15,14, 8, 9, 9,12,11, 9,11,10,13,13, 9,11,10, - 13,12,12,13,12,14,15,11,13,12,15,13,10,11,12,13, - 14,11,12,12,13,15,12,12,13,14,15,13,13,14,14,16, - 14,15,15,16,16,11,12,11,14,13,12,13,13,15,14,11, - 13,12,15,13,14,15,15,15,16,13,14,14,16,14, 7, 9, - 9,11,12, 9,10,11,12,13, 9,10,10,13,12,11,12,12, - 14,15,11,12,12,15,14, 9, 9,11,11,13,10,10,12,12, - 14,10,11,12,13,14,12,12,13,14,16,12,13,13,15,15, - 9,11,10,13,13,10,12,12,13,14,10,12,11,14,13,12, - 13,13,15,16,12,13,13,15,14,11,11,13,13,15,12,12, - 14,13,16,13,13,13,14,15,14,14,15,14,17,15,15,15, - 16,16,12,13,12,15,14,13,14,14,15,15,12,14,13,16, - 14,15,15,16,16,17,14,15,14,17,15, 7, 9, 9,12,11, - 9,10,10,12,13, 9,11,10,13,12,11,12,12,14,14,11, - 13,12,15,14, 9,10,10,13,12,10,10,11,12,13,10,12, - 11,14,13,12,12,13,13,15,12,14,13,16,15, 9,10,10, - 13,12,11,11,12,13,13,10,12,10,14,12,13,13,13,15, - 15,12,13,12,15,13,11,12,12,14,14,12,12,13,14,15, - 13,14,13,15,15,14,13,15,13,16,15,16,15,17,16,12, - 13,12,14,14,13,14,14,15,15,12,13,12,15,14,15,15, - 16,16,17,14,15,13,16,13,10,11,12,13,14,11,12,13, - 14,15,12,13,13,15,15,14,14,15,15,17,14,15,15,16, - 16,12,12,13,12,15,12,12,14,13,16,13,13,14,14,16, - 14,14,16,15,17,15,15,16,16,17,12,13,13,15,15,13, - 14,14,16,16,13,14,13,16,15,15,16,16,17,17,14,15, - 15,17,16,14,14,15,14,17,15,15,16,15,17,15,15,16, - 15,17,16,16,17,16,18,17,17,17,17,18,14,15,15,17, - 16,15,16,16,17,17,15,16,15,17,16,17,17,17,18,18, - 16,17,16,18,17,10,12,11,14,14,12,13,13,15,15,12, - 13,12,15,14,14,15,15,16,16,14,15,15,17,16,11,13, - 12,15,14,12,13,13,15,15,13,14,13,16,14,15,15,15, - 16,16,15,16,15,17,16,12,13,13,15,15,13,14,14,16, - 16,12,14,13,16,15,15,16,16,17,17,15,16,15,17,16, - 14,15,15,16,16,14,15,15,16,16,15,16,16,17,16,16, - 16,16,16,17,17,18,17,18,17,14,15,15,17,16,15,16, - 16,17,17,15,16,15,17,16,17,17,18,18,18,16,17,16, - 18,16, 6, 8, 8,11,11, 8, 9, 9,11,12, 8, 9, 9,12, - 11,10,11,12,13,14,10,11,11,14,13, 8, 9, 9,11,12, - 9,10,11,12,13, 9,10,11,13,13,11,12,13,13,15,12, - 12,12,15,14, 7, 9, 9,12,11, 9,10,10,13,13, 9,10, - 10,13,12,11,12,12,14,15,11,12,11,15,13,11,11,12, - 13,14,11,12,13,13,15,12,13,13,14,15,13,14,14,14, - 16,14,15,15,16,16,10,12,11,14,13,12,13,12,14,14, - 11,12,12,15,13,14,15,15,16,16,13,14,13,16,14, 7, - 9, 9,11,12, 9,10,11,12,13, 9,10,10,13,12,11,12, - 13,14,15,11,12,12,14,14, 9,10,10,12,13,10,10,12, - 12,14,11,12,11,13,13,12,12,14,13,15,13,13,13,15, - 15, 9,10,10,12,13,10,11,12,13,14,10,11,10,13,12, - 13,13,14,15,16,12,13,12,15,13,12,13,13,14,14,12, - 12,13,14,15,13,14,14,15,15,14,13,15,13,16,15,16, - 15,17,16,11,12,12,14,14,13,13,14,15,15,12,13,12, - 15,14,15,15,16,16,17,14,14,13,16,13, 7, 9, 9,12, - 11, 9,10,10,12,13, 9,11,10,13,12,11,12,12,14,15, - 11,12,12,15,14, 9,10,11,13,13,10,11,12,13,14,10, - 12,12,14,13,12,13,13,14,16,12,13,13,16,15, 9,11, - 9,13,11,10,12,11,13,13,10,12,10,14,12,12,13,13, - 15,15,12,13,12,16,14,12,12,13,14,15,12,13,14,14, - 15,13,14,14,15,15,14,14,15,15,17,15,16,15,17,16, - 11,13,11,15,13,13,14,13,15,14,12,14,12,16,13,15, - 15,15,16,16,14,15,14,17,14,10,11,12,14,14,12,12, - 13,14,15,12,13,13,15,15,14,15,15,16,17,14,15,15, - 16,16,12,12,13,15,15,13,13,14,15,16,13,14,14,16, - 16,15,15,16,16,17,15,16,16,17,17,11,12,13,14,15, - 13,13,14,15,16,12,13,13,15,15,15,15,16,16,17,15, - 15,15,16,16,14,15,15,16,17,15,15,16,16,17,15,16, - 16,17,17,16,16,17,16,18,17,17,17,18,18,14,15,15, - 16,16,15,16,16,16,17,15,15,15,16,16,17,17,17,18, - 18,16,16,16,17,16,10,12,11,14,13,12,13,13,15,15, - 11,13,12,15,14,14,15,15,16,16,14,15,14,17,15,12, - 13,13,15,15,13,13,14,16,16,13,14,14,16,16,15,15, - 15,16,17,15,16,16,17,17,12,13,12,15,12,13,14,13, - 16,14,12,14,12,16,13,15,16,15,17,16,14,16,14,17, - 15,14,15,15,16,17,15,15,16,17,17,15,16,16,17,17, - 16,16,17,17,18,17,18,17,18,18,14,15,14,17,14,15, - 16,15,17,15,15,16,15,17,15,17,17,17,18,17,16,17, - 16,18,16, 9,11,11,14,14,11,12,12,14,14,11,12,12, - 15,14,13,14,14,16,16,13,15,14,16,16,10,11,12,14, - 14,11,12,13,15,15,12,13,13,15,15,13,14,15,16,17, - 14,15,15,17,16,11,12,12,15,14,12,13,13,15,15,12, - 13,13,15,15,14,15,15,16,16,14,15,15,17,16,12,13, - 14,15,16,13,14,14,15,16,13,14,15,16,16,15,15,16, - 16,18,16,16,16,18,17,14,14,14,16,15,15,15,15,17, - 16,14,15,15,17,16,16,17,17,18,17,16,16,16,18,16, - 10,12,12,14,14,11,12,13,15,15,12,13,13,15,15,13, - 14,15,16,17,14,15,15,17,16,11,12,13,14,15,12,12, - 14,15,16,13,13,14,15,16,14,14,15,16,17,15,15,16, - 17,17,12,13,13,15,15,13,14,14,16,16,13,14,13,16, - 15,15,16,15,17,17,15,16,15,17,16,13,13,15,14,17, - 14,13,16,15,17,15,14,16,15,17,15,15,17,16,18,16, - 16,17,17,18,14,15,15,17,16,15,16,16,17,17,15,16, - 15,17,16,17,17,17,18,18,16,17,16,18,17,10,12,11, - 14,14,11,12,13,15,15,12,13,12,15,15,14,15,15,16, - 16,14,15,15,17,16,11,12,12,15,15,12,13,13,15,15, - 13,14,13,16,15,14,15,15,16,16,15,16,15,17,16,11, - 13,13,15,15,13,14,14,15,15,12,14,13,16,15,15,16, - 15,17,17,15,16,15,17,16,13,15,14,16,16,14,15,14, - 16,16,15,16,15,17,16,15,16,16,16,17,16,17,16,18, - 17,14,15,15,16,16,15,16,16,17,17,15,15,15,17,16, - 17,17,17,18,18,16,16,16,18,16,12,13,13,15,16,13, - 14,14,15,16,13,14,14,16,16,15,15,16,16,18,15,16, - 16,17,17,13,13,14,15,16,14,14,15,15,17,14,15,15, - 16,17,15,15,17,16,18,16,16,17,17,17,13,14,14,16, - 16,14,15,15,17,17,14,15,14,17,16,16,17,16,17,18, - 16,17,16,18,17,15,15,16,14,17,16,15,17,14,18,16, - 16,16,15,18,16,16,18,15,19,18,18,18,17,19,15,16, - 16,18,17,16,17,17,18,17,16,17,16,18,17,18,18,18, - 19,19,17,18,16,18,17,11,12,12,15,15,13,13,14,15, - 16,13,14,13,16,15,15,16,16,16,17,15,16,16,17,16, - 12,14,13,16,15,13,13,14,15,16,14,15,14,17,15,15, - 15,16,16,17,16,17,16,18,17,12,13,14,15,16,14,15, - 15,16,16,13,14,13,16,15,16,16,16,17,17,15,16,15, - 17,15,15,16,15,17,16,15,15,15,16,16,16,17,16,18, - 16,16,15,16,15,17,17,18,17,18,17,15,15,16,17,17, - 16,16,17,17,17,15,16,15,17,16,18,18,18,18,18,16, - 17,16,18,15, 9,11,11,14,14,11,12,12,14,15,10,12, - 12,15,14,13,14,15,16,16,13,14,14,16,16,11,12,12, - 14,15,12,12,13,15,15,12,13,13,15,15,14,15,15,16, - 17,14,15,15,16,16,10,12,12,14,14,12,13,13,15,15, - 11,13,12,15,15,14,15,15,16,17,13,15,14,16,16,14, - 14,14,15,16,14,15,15,16,17,14,15,15,16,17,16,16, - 17,16,18,16,17,17,17,17,12,14,13,16,15,13,15,14, - 16,16,13,14,14,16,15,16,16,16,17,17,15,16,15,17, - 16,10,11,11,14,14,12,12,13,14,15,11,13,12,15,14, - 14,15,15,16,17,14,15,15,16,16,12,13,13,15,15,12, - 13,14,15,16,13,14,14,15,15,15,15,16,16,17,15,15, - 16,17,17,11,12,12,15,15,13,13,14,15,16,12,13,13, - 15,15,15,15,16,16,17,14,15,15,16,16,14,15,15,16, - 16,15,15,15,16,17,15,16,16,17,17,16,16,17,16,18, - 17,17,17,17,18,13,14,15,16,16,15,15,16,16,17,14, - 14,14,16,16,16,16,17,17,18,16,16,16,17,16,10,12, - 12,14,14,12,13,13,15,15,11,13,12,15,15,14,15,15, - 16,17,13,15,14,17,16,12,13,13,15,15,13,13,14,15, - 16,13,14,14,16,16,15,15,16,16,17,15,15,16,17,17, - 11,13,12,15,14,13,14,13,16,15,12,14,12,16,15,15, - 16,15,17,17,14,15,14,17,16,14,15,15,16,17,15,15, - 16,16,17,15,16,16,17,17,16,16,17,17,18,17,17,17, - 18,18,13,15,13,17,14,14,16,14,17,16,14,15,13,17, - 15,16,17,16,18,17,15,17,15,18,16,11,12,12,15,15, - 13,13,14,15,16,13,14,13,16,15,15,16,16,16,17,15, - 16,16,17,16,12,14,13,16,15,13,13,14,15,16,14,15, - 15,16,16,16,15,16,16,17,16,16,16,17,17,12,13,14, - 15,16,14,14,15,15,17,13,14,13,16,15,16,16,17,17, - 18,15,16,15,17,15,15,16,15,17,17,15,15,16,16,17, - 16,17,16,17,17,16,15,17,15,18,17,18,17,18,18,15, - 15,16,16,17,16,16,17,16,18,15,15,15,16,16,17,17, - 18,17,18,16,16,15,17,15,12,13,13,15,15,13,14,14, - 16,16,13,14,14,16,16,15,16,16,17,18,15,16,15,18, - 16,13,14,14,16,16,14,14,15,16,17,14,15,15,17,17, - 16,16,17,17,18,16,16,17,18,17,13,14,13,16,14,14, - 15,15,17,16,14,15,14,17,15,16,17,17,18,17,15,17, - 15,18,16,15,16,16,17,17,16,16,17,17,18,16,17,17, - 18,18,17,16,18,17,19,18,18,18,18,18,15,16,15,17, - 14,16,16,16,18,15,16,17,15,18,14,18,18,18,18,17, - 17,18,16,19,15, -}; - -static const static_codebook _44p5_p2_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p5_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p5_p2_0, - 0 -}; - -static const long _vq_quantlist__44p5_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p5_p3_0[] = { - 1, 5, 6, 5, 7, 8, 5, 8, 7, 5, 7, 8, 7, 8,10, 8, - 10,10, 5, 8, 7, 8,10,10, 7,10, 8, 6, 8, 9, 8,10, - 11, 9,10,10, 9,10,11,10,11,12,11,12,12, 9,11,10, - 11,12,12,10,12,11, 6, 9, 8, 9,10,10, 8,11,10, 9, - 10,11,10,11,12,11,12,12, 9,11,10,11,12,12,10,12, - 11, 6, 9, 9, 8,10,11, 9,11,10, 8,10,10,10,10,12, - 11,12,12, 9,11,10,11,12,12,10,12,11, 8,10,10,10, - 11,12,10,12,11,10,10,12,11,11,13,12,13,13,10,12, - 11,12,13,13,11,13,11, 7,10,10,10,11,12,10,12,11, - 10,12,11,11,11,12,12,14,13,10,12,12,12,14,14,11, - 13,11, 6, 9, 9, 9,10,11, 8,11,10, 9,10,11,10,11, - 12,11,12,12, 8,11,10,11,12,12,10,12,10, 7,10,10, - 10,11,12,10,12,11,10,12,12,11,11,13,12,13,13,10, - 11,12,12,13,14,11,12,11, 8,10,10,10,11,12,10,12, - 11,10,11,12,11,11,13,12,13,13,10,12,10,12,13,13, - 11,13,11, -}; - -static const static_codebook _44p5_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p5_p3_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p5_p3_0, - 0 -}; - -static const long _vq_quantlist__44p5_p3_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p5_p3_1[] = { - 5, 6, 6, 6, 7, 7, 6, 7, 7, 6, 7, 7, 7, 7, 8, 7, - 8, 8, 6, 7, 7, 7, 8, 8, 7, 8, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, 8, - 8, 9, 9, 8, 9, 9, 7, 8, 7, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 9, 9, 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, - 8, 6, 8, 8, 7, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, 9, - 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, 8, 7, 8, 8, 8, - 9, 9, 8, 9, 9, 8, 8, 9, 9, 9, 9, 9, 9, 9, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 7, 8, 8, 8, 8, 9, 8, 9, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 8, 9, 8, 9, 9, 9, 8, - 9, 9, 6, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, - 9, 8, 9, 9, 7, 8, 8, 8, 9, 9, 8, 9, 8, 7, 8, 8, - 8, 8, 9, 8, 9, 8, 8, 8, 9, 8, 9, 9, 9, 9, 9, 8, - 8, 8, 9, 9, 9, 8, 9, 9, 7, 8, 8, 8, 9, 9, 8, 9, - 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 8, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p5_p3_1 = { - 5, 243, - (char *)_vq_lengthlist__44p5_p3_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p5_p3_1, - 0 -}; - -static const long _vq_quantlist__44p5_p4_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p5_p4_0[] = { - 1, 5, 5, 5, 7, 9, 5, 9, 7, 5, 7, 8, 7, 7,10, 9, - 10,10, 5, 8, 7, 9,10,10, 7,10, 7, 6, 8, 9, 9,10, - 12, 9,11,11, 9,10,11,11,11,13,12,13,13, 9,11,11, - 11,12,13,11,13,11, 6, 9, 8, 9,11,11, 9,12,10, 9, - 11,11,11,11,13,11,13,12, 9,11,10,12,13,13,11,13, - 11, 6, 9, 9, 8,10,11, 9,12,11, 9,10,11,10,10,12, - 11,13,13, 9,11,11,11,13,12,11,13,11, 8,10,10, 9, - 10,12,10,12,11,10,10,12,10,10,13,12,13,13,10,12, - 11,12,13,13,10,13,10, 7,10,10,11,11,13,11,14,11, - 10,12,11,11,11,13,13,14,13,10,12,12,14,14,14,11, - 14,11, 6, 9, 9, 9,11,12, 8,11,10, 9,11,11,11,11, - 13,11,12,13, 8,11,10,11,13,13,10,12,10, 7,10,10, - 11,11,14,11,13,11,10,12,12,11,11,14,14,14,14,10, - 11,12,13,13,14,11,13,11, 8,10,10,10,11,12, 9,12, - 10,10,11,12,11,10,13,12,13,13,10,12,10,12,13,13, - 11,13,10, -}; - -static const static_codebook _44p5_p4_0 = { - 5, 243, - (char *)_vq_lengthlist__44p5_p4_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p5_p4_0, - 0 -}; - -static const long _vq_quantlist__44p5_p4_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p5_p4_1[] = { - 5, 7, 7,10,10, 7, 8, 9,10,11, 7, 9, 8,11,10, 9, - 10,10,11,11, 9,10,10,11,11, 7, 9, 9,10,10, 8, 9, - 10,10,11, 9,10,10,11,11,10,10,11,11,11,10,11,11, - 12,12, 7, 9, 9,10,10, 9,10,10,11,11, 8,10, 9,11, - 10,10,11,11,11,11,10,11,10,11,11,10,10,10,11,11, - 10,10,11,11,11,11,11,11,11,11,11,11,12,11,12,11, - 12,11,12,12,10,10,10,11,11,10,11,11,11,11,10,11, - 10,11,11,11,12,11,12,12,11,12,11,12,11, 8, 9, 9, - 11,11, 9,10,10,11,12, 9,10,10,11,11,10,11,11,12, - 12,10,11,11,12,12, 9,10,10,11,11,10,10,11,11,12, - 10,11,11,12,12,11,11,12,12,12,11,12,12,12,12, 9, - 10,10,11,11,10,11,11,12,12,10,11,10,12,12,11,12, - 12,12,12,11,12,12,12,12,11,11,11,12,12,11,11,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,11,11,11,12,12,11,12,12,12,12,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12, 8, 9, 9,11,11, 9, - 10,10,11,11, 9,10,10,11,11,10,11,11,12,12,10,11, - 11,12,12, 9,10,10,11,11,10,10,11,12,12,10,11,11, - 12,12,11,12,12,12,12,11,12,12,12,12, 9,10,10,11, - 11,10,11,11,12,12,10,11,10,12,11,11,12,12,12,12, - 11,12,11,12,12,11,11,11,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11, - 11,12,12,11,12,12,12,12,11,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,10,11,11,12,12,11,12,12,12, - 12,11,12,12,12,12,12,12,13,13,13,12,12,12,13,13, - 11,12,12,12,12,12,12,12,12,13,12,12,12,13,13,12, - 12,13,13,13,12,13,13,13,13,11,12,12,12,12,12,12, - 12,13,13,12,12,12,13,13,12,13,13,13,13,12,13,13, - 13,13,12,12,12,12,13,12,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,12,12,12,13,12, - 13,13,13,13,13,12,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,10,11,11,12,12,11,12,12,12,12,11,12, - 11,12,12,12,12,12,13,12,12,12,12,13,13,11,12,12, - 12,12,12,12,12,13,13,12,12,12,13,13,12,13,13,13, - 13,12,13,13,13,13,11,12,12,12,12,12,12,12,13,13, - 12,12,12,13,12,12,13,13,13,13,12,13,12,13,13,12, - 12,12,12,13,12,13,13,13,13,12,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,12,12,12,13,12,13,13,13, - 13,13,12,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13, 8, 9, 9,11,11, 9,10,10,11,11, 9,10,10,12,11, - 10,11,11,12,12,10,11,11,12,12, 9,10,10,11,11,10, - 10,11,11,12,10,11,11,12,12,11,11,12,12,12,11,12, - 12,12,12, 9,10,10,11,11,10,11,11,12,12,10,11,10, - 12,12,11,12,12,12,12,11,12,12,12,12,11,11,11,12, - 12,11,11,12,12,12,11,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,11,11,11,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12, 9,10, - 10,11,11,10,10,11,12,12,10,11,11,12,12,11,11,12, - 12,12,11,12,12,12,12,10,10,11,11,12,11,11,12,12, - 12,11,11,12,12,12,11,11,12,12,13,12,12,12,12,12, - 10,11,11,12,12,11,12,11,12,12,11,12,11,12,12,12, - 12,12,12,12,12,12,12,12,12,11,11,12,12,12,12,12, - 12,12,12,12,12,12,12,13,12,12,13,12,13,12,12,13, - 13,13,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,13,12,12,12,12,13,12, 8,10,10,11,11, - 10,11,11,12,12,10,11,10,12,12,11,12,12,12,12,11, - 12,12,12,12,10,11,10,12,12,10,10,11,12,12,11,12, - 12,12,12,12,12,12,12,13,12,12,12,13,13,10,11,11, - 12,12,11,12,12,12,12,10,12,11,12,12,12,12,12,13, - 13,12,13,12,13,12,11,12,12,12,12,11,12,12,12,13, - 12,12,12,13,13,12,12,13,12,13,12,13,13,13,13,11, - 12,12,12,12,12,12,12,13,13,12,12,12,13,12,12,13, - 13,13,13,12,13,12,13,12,11,11,11,12,12,11,12,12, - 12,13,11,12,12,12,12,12,12,12,13,13,12,12,13,13, - 13,11,12,12,12,12,12,12,12,12,13,12,12,13,13,13, - 12,12,13,13,13,13,13,13,13,13,11,12,12,12,12,12, - 13,12,13,13,12,12,12,13,13,12,13,13,13,13,12,13, - 13,13,13,12,12,12,12,13,12,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,12,12,12,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,10,11,11,12,12,11,12,12,12,13,11, - 12,12,13,12,12,13,13,13,13,12,13,13,13,13,11,12, - 12,12,12,12,12,12,13,13,12,13,12,13,13,13,13,13, - 13,13,13,13,13,13,13,11,12,12,13,12,12,13,12,13, - 13,12,13,12,13,13,13,13,13,13,13,13,13,13,13,13, - 12,13,13,13,13,12,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,12,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13, 8, 9, 9,11,11, 9,10,10,11,12, 9,10,10,11, - 11,10,11,11,12,12,10,11,11,12,12, 9,10,10,11,11, - 10,10,11,12,12,10,11,11,12,12,11,11,12,12,12,11, - 12,12,12,12, 9,10,10,11,11,10,11,11,12,12,10,11, - 10,12,12,11,12,12,12,12,11,12,11,12,12,11,11,11, - 12,12,11,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,11,11,11,12,12,11,12,12,12,12, - 11,12,11,12,12,12,12,12,12,12,12,12,12,12,12, 8, - 10,10,11,11,10,10,11,12,12,10,11,11,12,12,11,12, - 12,12,12,11,12,12,12,12,10,11,11,12,12,10,11,12, - 12,12,11,12,12,12,12,12,12,12,12,13,12,12,12,13, - 13,10,10,11,12,12,11,12,12,12,12,10,11,10,12,12, - 12,12,12,13,13,12,12,12,13,12,11,12,12,12,12,11, - 12,12,12,13,12,12,12,13,13,12,12,13,12,13,12,13, - 13,13,13,11,12,12,12,12,12,12,12,13,13,11,12,12, - 13,12,12,13,13,13,13,12,13,12,13,12, 9,10,10,11, - 11,10,11,11,12,12,10,11,11,12,12,11,12,12,12,12, - 11,12,11,12,12,10,11,11,12,12,11,11,12,12,12,11, - 11,12,12,12,12,12,12,12,13,12,12,12,13,12,10,11, - 10,12,11,11,12,11,12,12,11,12,11,12,12,12,12,12, - 12,12,12,12,11,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,13,12,13,12,13,13,13,13, - 11,12,11,12,12,12,12,12,13,12,12,12,12,12,12,12, - 13,12,13,13,12,12,12,13,12,10,11,11,12,12,11,12, - 12,12,13,11,12,12,13,12,12,12,13,13,13,12,13,13, - 13,13,11,12,12,12,13,12,12,13,13,13,12,12,13,13, - 13,13,13,13,13,13,13,13,13,13,13,11,12,12,12,12, - 12,12,13,13,13,12,13,12,13,13,13,13,13,13,13,13, - 13,13,13,13,12,13,13,13,13,12,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,13, - 13,13,13,13,13,13,13,12,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,11,11,11,12,12,11,12,12,12,12, - 11,12,12,12,12,12,12,13,13,13,12,13,12,13,13,11, - 12,12,12,12,12,12,13,13,13,12,12,13,13,13,12,13, - 13,13,13,12,13,13,13,13,11,12,12,12,12,12,13,12, - 13,13,12,12,12,13,12,13,13,13,13,13,12,13,12,13, - 13,12,12,12,13,13,12,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,12,12,12,13,12,13, - 13,13,13,13,12,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,10,11,11,12,12,11,12,12,12,12,11,12,12, - 12,12,12,12,12,13,13,12,12,12,13,13,11,12,12,12, - 12,11,12,12,13,13,12,12,12,13,13,12,12,13,13,13, - 12,13,13,13,13,11,12,12,12,12,12,12,12,13,13,12, - 12,12,13,12,12,13,13,13,13,12,13,12,13,13,12,12, - 12,12,12,12,12,13,13,13,12,13,13,13,13,12,13,13, - 13,13,13,13,13,13,13,12,12,12,13,12,12,13,13,13, - 13,12,13,12,13,13,13,13,13,13,13,13,13,13,13,13, - 10,11,11,12,12,11,12,12,12,13,11,12,12,13,12,12, - 12,12,13,13,12,12,12,13,13,11,12,12,12,12,12,12, - 13,13,13,12,12,12,13,13,12,12,13,13,13,12,13,13, - 13,13,11,12,12,12,12,12,12,12,13,13,12,12,12,13, - 13,12,13,13,13,13,12,13,13,13,13,12,12,12,12,13, - 12,12,13,13,13,12,13,13,13,13,12,13,13,13,13,13, - 13,13,13,13,12,12,12,13,13,13,13,13,13,13,12,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,10,11,11, - 12,12,11,12,12,12,13,11,12,12,13,12,12,13,13,13, - 13,12,13,12,13,13,11,12,12,13,13,12,12,12,13,13, - 12,12,13,13,13,12,13,13,13,13,13,13,13,13,13,11, - 12,12,13,12,12,13,12,13,13,12,13,12,13,13,13,13, - 13,13,13,12,13,13,13,13,12,12,12,13,13,12,13,13, - 13,13,12,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,12,12,12,13,13,12,13,13,13,13,12,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,11,11,11,12,12,11, - 12,12,12,12,11,12,12,12,12,12,12,12,13,13,12,12, - 12,13,13,11,12,12,12,12,12,12,12,12,13,12,12,12, - 13,13,12,12,13,13,13,12,13,13,13,13,11,12,12,12, - 12,12,12,12,13,13,12,12,12,13,12,12,13,13,13,13, - 12,13,12,13,13,12,12,12,12,12,12,12,13,12,13,12, - 13,13,13,13,12,13,13,12,13,13,13,13,13,13,12,12, - 12,12,12,12,13,13,13,13,12,13,12,13,13,13,13,13, - 13,13,12,13,13,13,12,10,11,11,12,12,11,12,12,12, - 12,11,12,12,12,12,12,12,12,13,13,12,13,12,13,13, - 11,12,12,12,12,12,12,12,13,13,12,12,12,13,13,12, - 12,13,13,13,13,13,13,13,13,11,12,12,12,12,12,13, - 12,13,13,12,13,12,13,13,12,13,13,13,13,12,13,12, - 13,13,12,12,12,12,12,12,13,13,13,13,12,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,12,12,12,13,12, - 12,13,13,13,13,12,13,12,13,13,13,13,13,13,13,13, - 13,13,13,13,10,11,11,12,12,11,12,12,12,12,11,12, - 12,12,12,12,12,12,13,13,12,12,12,13,13,11,12,12, - 12,12,12,12,12,13,13,12,12,12,13,13,12,12,13,13, - 13,12,12,13,13,13,11,12,11,12,12,12,12,12,13,13, - 11,12,12,13,13,12,13,13,13,13,12,13,12,13,13,12, - 12,12,12,12,12,13,13,13,13,12,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,12,12,12,13,12,12,13,13, - 13,13,12,13,12,13,13,13,13,13,13,13,12,13,13,13, - 13,10,11,11,12,12,11,12,12,12,13,11,12,12,13,12, - 12,12,13,13,13,12,13,13,13,13,11,12,12,13,13,12, - 12,13,13,13,12,12,13,13,13,12,13,13,13,13,13,13, - 13,13,13,11,12,12,13,12,12,13,12,13,13,12,12,12, - 13,13,12,13,13,13,13,13,13,13,13,13,12,12,13,13, - 13,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,12,12,12,13,13,13,13,13,13,13,12, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,10,12, - 11,12,12,11,12,12,12,13,11,12,12,12,12,12,12,12, - 13,13,12,12,12,13,13,11,12,12,12,13,12,12,12,13, - 13,12,12,12,13,13,12,13,13,13,13,12,13,13,13,13, - 11,12,12,13,12,12,12,12,13,13,12,12,12,13,13,12, - 13,13,13,13,12,13,12,13,13,12,13,12,13,13,12,13, - 13,13,13,12,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,12,12,12,13,12,13,13,13,13,13,12,13,12,13, - 13,13,13,13,13,13,12,13,13,13,13,10,11,11,12,12, - 11,12,12,12,13,11,12,12,12,12,12,12,12,13,13,12, - 12,12,13,13,11,12,12,12,12,12,12,13,13,13,12,13, - 13,13,13,12,12,13,13,13,13,13,13,13,13,11,12,12, - 12,12,12,13,12,13,13,12,12,12,13,13,12,13,13,13, - 13,12,13,12,13,13,12,12,12,12,13,12,13,13,13,13, - 12,13,13,13,13,12,13,13,13,13,13,13,13,13,13,12, - 12,12,12,12,12,13,13,13,13,12,13,13,13,13,13,13, - 13,13,13,12,13,13,13,13,11,12,11,12,12,11,12,12, - 12,12,11,12,12,12,12,12,12,12,12,13,12,12,12,13, - 12,11,12,12,12,12,12,12,12,12,13,12,12,12,13,13, - 12,12,13,13,13,12,13,13,13,13,11,12,12,12,12,12, - 12,12,13,13,12,12,12,13,12,12,13,13,13,13,12,13, - 12,13,13,12,12,12,12,12,12,12,13,13,13,12,13,13, - 13,13,13,13,13,12,13,13,13,13,13,13,12,12,12,12, - 12,12,13,13,13,13,12,13,12,13,12,13,13,13,13,13, - 13,13,13,13,12, -}; - -static const static_codebook _44p5_p4_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p5_p4_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p5_p4_1, - 0 -}; - -static const long _vq_quantlist__44p5_p5_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p5_p5_0[] = { - 1, 6, 6,10,10, 6, 7, 9,11,13, 5, 9, 7,13,11, 8, - 11,12,13,15, 8,12,11,15,13, 6, 7, 8,11,11, 7, 8, - 10,11,13, 9,10,10,13,13,11,11,13,12,16,12,13,13, - 16,15, 6, 8, 7,11,11, 9,10,10,13,13, 7,10, 7,13, - 11,12,13,13,15,16,11,13,11,16,12,10,11,11,11,13, - 11,11,13,12,15,13,13,13,14,15,13,12,15,12,17,15, - 16,16,16,16,10,11,11,14,11,13,13,13,15,14,11,13, - 11,15,12,15,15,16,16,16,13,15,12,17,12, 6, 8, 9, - 12,12, 9,10,12,13,15, 9,11,11,15,14,12,13,15,16, - 18,13,14,14,17,16, 9,10,11,13,14,11,10,13,14,16, - 11,12,12,15,15,14,13,16,15,18,14,15,15,17,17, 9, - 11,11,14,14,11,12,13,15,16,11,13,11,15,14,15,15, - 15,17,18,14,15,14,17,15,13,14,14,15,16,14,14,15, - 15,17,15,16,15,17,17,16,16,17,15,19,17,18,18,19, - 18,13,14,14,16,15,15,15,16,17,17,14,15,14,18,15, - 17,17,17,19,19,16,17,15,19,16, 6, 9, 8,13,12, 9, - 11,11,14,15, 9,12,10,15,13,13,14,14,16,17,12,15, - 13,18,16, 9,11,11,14,14,11,11,13,14,15,11,13,12, - 16,15,14,14,15,15,18,14,15,15,18,17, 9,11,10,14, - 13,11,12,12,15,15,11,13,10,16,14,14,15,15,16,18, - 14,16,13,18,15,13,14,14,16,16,14,14,15,15,17,15, - 16,15,17,17,16,16,17,16,19,17,18,17,18,19,13,14, - 14,16,15,15,15,15,17,17,14,15,14,17,15,17,17,17, - 18,19,16,17,15,19,15,11,13,13,15,16,13,14,15,16, - 18,14,15,15,17,17,16,16,18,18,20,17,18,17,19,20, - 13,14,14,16,17,15,15,16,17,18,15,16,16,17,17,18, - 17,19,18,19,18,18,18,19,21,14,14,15,16,17,15,15, - 16,18,18,15,16,16,17,18,18,18,19,19,21,18,19,19, - 22,20,16,16,17,17,19,17,17,17,18,20,17,18,18,20, - 19,19,19,20,19, 0,19,19,20,20,21,17,17,17,19,18, - 18,18,20,19,19,18,18,18,20,20,19,19,20,20,20,20, - 21,20,21,19,11,13,13,16,15,14,15,15,17,17,14,15, - 14,18,16,16,18,18,20,19,16,19,17,21,18,13,14,15, - 16,17,15,15,16,18,18,15,16,15,19,18,18,18,18,19, - 19,18,18,18,22,20,13,14,14,16,16,15,16,16,18,17, - 15,16,15,18,17,18,18,18,19,19,17,18,17,21,18,16, - 17,17,18,18,17,18,19,19,19,18,20,18,19,19,19,20, - 21,19,21,20,20,20, 0,21,16,17,17,19,19,18,18,18, - 19,21,17,18,18,19,18,20,19,21,20,21,19,20,20,22, - 19, 7, 9, 9,13,13, 8,10,11,14,15, 9,12,11,15,14, - 11,13,14,16,17,13,15,14,17,16, 8,10,11,14,14,10, - 10,12,14,16,11,12,12,16,15,13,12,15,15,18,14,15, - 15,19,17, 9,11,11,14,14,11,12,12,15,15,11,13,11, - 16,14,14,15,14,17,17,14,16,14,18,15,12,13,14,15, - 16,13,13,15,14,17,15,15,15,17,17,15,14,17,14,19, - 17,18,18,19,18,13,14,14,16,16,15,15,15,17,17,14, - 15,14,18,15,17,18,17,18,17,16,18,16,19,15, 7,10, - 10,13,13, 9,10,12,14,15,10,12,11,15,14,12,13,14, - 16,17,13,15,14,18,16,10,10,12,13,14,10,10,13,13, - 16,12,12,13,15,15,13,12,15,15,18,15,15,16,18,17, - 10,11,11,14,14,12,13,13,15,16,10,13,10,16,14,14, - 15,15,17,17,14,15,13,17,15,13,13,14,15,16,14,13, - 15,14,18,15,15,16,16,17,16,15,18,15,18,17,18,18, - 18,18,13,15,14,17,16,15,16,16,17,17,14,15,13,17, - 15,17,17,18,18,18,16,17,14,20,14, 8,10,10,14,14, - 11,11,13,14,16,11,13,11,16,14,14,15,16,16,18,14, - 16,15,18,16,10,12,11,15,14,11,11,13,14,16,13,14, - 13,16,15,15,14,16,15,19,16,17,16,20,18,10,11,12, - 14,15,13,13,14,16,16,11,14,11,16,14,16,16,17,18, - 19,15,17,14,20,15,14,15,14,17,16,13,14,15,15,18, - 16,17,16,19,18,16,15,18,15,19,18,19,18,21,21,14, - 14,15,16,17,16,16,17,18,18,13,15,14,17,15,18,18, - 19,18,22,16,18,15,21,15,12,13,14,16,16,14,14,16, - 16,18,14,15,15,17,18,16,16,18,18,20,18,18,17,20, - 20,13,14,15,15,17,15,14,16,16,18,16,16,16,17,19, - 17,15,18,17,21,18,18,18,19,19,14,15,15,18,17,15, - 16,16,18,19,15,16,15,18,18,17,18,18,20,21,17,19, - 17,20,19,16,16,17,16,19,17,17,18,17,20,18,18,18, - 18,19,19,18,20,17,22,20,20,19,20,20,17,17,18,18, - 19,18,18,20,21,20,17,18,17,20,20,21,21,21,21,21, - 19,21,18,22,20,11,13,13,17,16,14,14,16,16,18,14, - 16,14,18,16,17,18,19,19,20,18,19,18,21,19,14,15, - 14,17,16,14,14,16,18,18,16,17,16,18,17,18,17,19, - 18,20,19,19,18,20,20,13,14,15,16,17,16,16,17,18, - 19,14,16,14,19,17,18,19,18,20,20,18,20,17,21,18, - 17,17,17,19,18,16,17,18,18,19,18,19,18,21,21,18, - 18,20,17,21,19,20,20,22,21,16,17,18,18,19,18,18, - 19,21,20,16,17,17,20,18,21,21,22,21,22,18,21,18, - 0,18, 7, 9, 9,13,13, 9,11,12,14,15, 8,11,10,15, - 14,13,14,15,16,18,11,14,13,17,15, 9,11,11,14,14, - 11,11,13,14,16,11,12,12,15,15,14,14,16,15,18,14, - 14,15,17,17, 8,11,10,14,14,11,12,12,15,15,10,12, - 10,16,14,14,15,15,17,18,13,15,12,18,15,13,14,14, - 16,16,14,14,15,15,17,15,15,15,16,17,16,15,17,15, - 19,17,17,17,18,18,12,14,13,16,15,15,15,15,17,17, - 13,15,13,17,14,17,18,18,18,19,15,17,14,19,14, 8, - 10,10,14,14,11,11,13,14,16,11,13,11,16,14,14,15, - 16,17,19,14,16,15,18,17,10,12,11,15,14,11,11,14, - 14,17,13,14,13,17,15,15,14,17,15,19,16,17,16,19, - 17,10,11,12,14,15,13,13,14,15,17,11,13,11,17,14, - 16,16,17,18,19,15,16,14,18,15,14,15,14,16,16,13, - 14,15,15,18,16,16,16,18,18,16,15,18,15,20,18,19, - 18,21,18,14,14,15,16,17,16,16,17,17,18,13,15,14, - 17,16,19,19,19,19,19,15,18,15,20,15, 7,10,10,13, - 13,10,11,12,14,15, 9,12,10,15,14,13,14,15,16,17, - 12,15,13,17,16,10,11,11,14,14,10,10,13,14,16,12, - 13,13,16,15,14,13,16,15,18,15,15,16,17,17,10,12, - 10,14,13,12,13,12,15,15,10,13,10,16,13,15,16,15, - 17,18,13,16,12,18,15,13,14,14,16,17,14,13,15,15, - 18,15,16,15,17,17,16,14,17,15,19,17,18,18,19,19, - 13,15,13,17,14,15,15,15,18,17,14,15,13,17,14,18, - 17,18,18,19,15,17,15,19,15,11,13,13,16,17,14,14, - 16,16,18,14,16,15,18,17,17,18,19,18,21,18,18,17, - 20,18,13,15,14,17,16,14,14,16,17,18,16,17,16,19, - 17,18,17,19,18,22,18,19,19,21,21,13,14,15,16,18, - 16,16,17,17,20,14,16,14,18,17,18,18,19,19,21,17, - 18,17,21,18,17,18,17,19,18,16,17,17,18,19,18,18, - 18,22,22,18,17,19,17, 0,20,21,19,21,20,17,17,18, - 18,21,18,18,18,19,21,17,17,17,19,19,20,20,22,21, - 21,19,20,18,20,17,12,14,13,17,16,14,15,15,17,18, - 14,16,14,18,16,17,18,18,21,20,16,18,16,21,18,14, - 15,15,17,17,15,15,16,18,18,15,17,16,18,18,17,17, - 19,19,20,18,19,18,20,19,14,15,14,17,15,15,16,16, - 18,17,15,16,14,19,15,18,18,18,19,20,17,20,15,21, - 17,16,17,18,18,19,17,17,18,18,20,18,19,18,19,21, - 19,18,19,19,21,20, 0,19,21,20,16,17,16,19,16,18, - 18,18,19,19,17,18,17,20,17,19,20,20,22, 0,19,20, - 17,21,17,11,13,14,16,17,14,15,15,17,18,14,15,15, - 18,18,16,17,17,19,20,16,18,17,19,21,13,14,15,17, - 17,14,15,16,17,19,15,16,16,18,19,16,17,18,19,21, - 17,18,20,21,21,13,15,15,17,17,15,16,16,18,19,15, - 16,16,18,19,17,17,18,19,22,17,19,18,22,19,15,16, - 17,19,19,16,17,18,18,20,17,18,18,19,20,19,18,20, - 18,22,20,19,19,22,21,16,17,17,18,19,18,18,18,19, - 20,17,18,18,20,19,20,19,20,22,20,19,20,21,21,20, - 12,14,14,16,16,13,14,16,17,18,14,16,15,18,18,15, - 17,17,19,19,17,18,18,19,19,13,14,15,16,17,14,14, - 16,16,20,15,16,16,17,19,16,15,18,17,20,18,17,19, - 19,19,14,15,15,17,17,16,16,16,18,18,15,16,15,19, - 18,17,18,18,20,21,17,18,17,21,18,16,15,17,17,19, - 17,15,18,17,20,19,17,18,19,20,18,16,19,17,22,20, - 19,20,19,20,17,17,18,19,19,18,18,19,20,20,17,18, - 17,18,18,21,21,20,20,21,18,20,17,21,19,11,14,14, - 16,17,15,14,16,17,19,14,16,14,18,17,18,18,19,19, - 21,17,19,18,20,20,13,15,14,17,17,14,14,16,17,18, - 16,17,16,19,18,18,17,19,18,20,18,21,18,20,20,13, - 15,15,16,17,16,16,17,18,19,14,16,15,19,18,19,19, - 19,21,20,18,19,17,20,18,16,17,16,19,18,16,17,17, - 19,20,17,19,18,20,19,18,17,21,18, 0,21,20,20, 0, - 20,17,17,18,18,19,18,19,19,20,22,16,17,17,20,18, - 21,22,20,20,22,18,22,18,22,18,12,14,14,17,17,14, - 15,16,17,19,14,16,15,17,17,17,17,18,18,21,17,19, - 17,20,19,14,15,15,16,18,15,14,16,16,19,16,17,16, - 19,18,17,16,20,17,20,18,20,19,19,20,14,15,15,18, - 17,16,16,17,18,19,14,16,15,19,17,18,21,18,19,21, - 17,18,17,19,18,17,17,18,17,20,17,16,18,17,21,18, - 19,19,19,19,18,17,19,17,20,20,21,20,21,20,17,17, - 17,19,19,19,18,18,20,21,16,18,16,19,18,20,20,21, - 21,20,18,19,16, 0,17,12,14,14,17,17,15,15,18,17, - 19,15,18,15,20,16,20,19,21,18,22,20,20,20,22,19, - 14,16,14,20,17,14,15,17,17,20,18,18,17,20,18,18, - 17,19,17,21,20,21,20, 0,21,14,15,16,17,19,18,17, - 19,18,21,14,18,15,21,17,21,20,21,20, 0,18,21,17, - 21,17,18,19,17,20,18,16,17,17,19,19,19,21,20, 0, - 20,18,17,21,17, 0,22, 0,21, 0,22,17,17,19,18,20, - 20,20,21,19,22,16,17,18,20,18,22,22, 0,22, 0,17, - 21,17,22,17,11,14,13,16,16,14,15,15,17,18,14,15, - 14,18,17,17,18,18,19,20,16,17,17,21,19,13,14,15, - 17,17,15,16,16,18,18,15,16,16,19,18,18,18,18,19, - 20,17,18,18,20,19,13,15,14,17,17,15,16,16,17,18, - 14,16,15,19,17,17,18,19,21,21,17,18,17,20,18,16, - 17,17,19,19,17,18,19,19,20,18,19,18,21,21,21,20, - 19,21,22,20,20,19,21,20,15,17,16,19,19,17,18,18, - 20,21,16,18,17,20,18,19,19,21,21,21,19,19,19,20, - 18,11,14,13,17,16,14,14,16,16,19,14,16,15,19,16, - 18,18,18,19,22,17,18,17,20,19,13,15,14,17,17,15, - 15,16,17,19,16,17,16,20,18,18,17,19,18,21,19,19, - 18,22, 0,13,14,15,17,18,16,16,17,17,19,14,16,15, - 19,18,18,19,19,20,21,18,18,17,20,18,17,18,17,20, - 18,16,17,17,18,20,18,19,18,20,20,18,18,21,17,21, - 20,21,21, 0,19,16,16,18,18,19,19,18,20,19,20,16, - 17,17,20,18,21,20,21,22,22,18,20,17,21,17,12,14, - 14,17,16,14,15,16,18,18,13,15,14,18,17,17,18,18, - 19,19,15,17,16,19,19,14,15,15,17,17,15,15,16,18, - 19,15,16,16,19,18,17,17,18,18,20,18,18,18,21,20, - 13,15,14,17,16,15,16,15,18,18,14,16,14,18,17,18, - 18,18,19,21,16,18,16,20,17,17,18,17,18,19,17,17, - 18,18,19,18,19,19,21,19,19,18,20,18,21,21,20,20, - 21,20,16,17,15,20,17,17,19,17,19,19,17,18,15,20, - 17,19,20,19,21,22,17,20,16, 0,17,12,14,14,17,18, - 16,15,18,16,20,16,18,15,21,17,20,18,21,19,22,19, - 21,19, 0,19,14,16,15,19,17,14,15,17,16,21,18,19, - 18,21,17,19,17,21,17,22,20,21,21, 0,21,14,15,16, - 17,19,18,17,19,18,21,14,17,15,20,17,21,22,21,20, - 22,18,21,17,21,17,17,19,17,21,18,16,17,17,19,20, - 19,21,20,21,20,17,18,20,17,21, 0,22,20,21,22,17, - 17,20,18,21,21,20,22,20,21,16,17,17,21,19, 0,22, - 0,21,21,18,22,17,21,17,12,14,14,17,16,14,15,16, - 17,18,14,16,15,18,17,17,17,20,19,20,16,18,17,21, - 18,14,15,15,17,17,14,15,16,17,19,16,17,16,18,18, - 17,16,19,18,19,18,19,18,21,20,14,15,15,18,17,16, - 16,16,19,18,15,16,14,20,16,18,18,19,19,20,16,19, - 16,21,17,17,17,18,19,19,16,16,18,18,19,19,19,18, - 20,20,18,16,19,18,20,22,21,20,19,20,16,18,17,20, - 16,18,19,18,19,18,16,18,16,20,17,21,20,21,20,20, - 18,19,17,21,16, -}; - -static const static_codebook _44p5_p5_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p5_p5_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p5_p5_0, - 0 -}; - -static const long _vq_quantlist__44p5_p5_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p5_p5_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p5_p5_1 = { - 1, 7, - (char *)_vq_lengthlist__44p5_p5_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p5_p5_1, - 0 -}; - -static const long _vq_quantlist__44p5_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p5_p6_0[] = { - 1, 5, 5, 5, 7, 9, 5, 9, 7, 5, 7, 8, 7, 7,10, 9, - 9,10, 5, 8, 7, 9,10, 9, 7,10, 7, 6, 9, 9, 9,10, - 12,10,12,11, 9,10,11,11,10,13,12,12,13,10,11,11, - 12,13,13,11,13,11, 6, 9, 9,10,11,12, 9,12,11,10, - 11,11,11,11,13,12,13,13, 9,11,10,12,13,13,11,13, - 10, 6, 9,10, 9,11,12,10,12,11, 9,10,11,10,10,13, - 11,13,13,10,11,11,12,13,12,11,13,11, 7, 9,10, 9, - 10,12,10,11,11,10,10,11,10,10,12,12,11,12,10,11, - 10,12,12,12,10,12,10, 7,10,10,11,11,13,11,13,11, - 10,12,11,11,10,13,13,14,13,10,11,12,13,13,14,11, - 13,10, 6,10, 9,10,11,12, 9,12,11, 9,11,11,11,11, - 13,12,12,13, 9,11,10,12,13,13,10,13,10, 7,10,10, - 11,11,14,11,13,11,10,12,11,11,10,14,13,14,13,10, - 11,12,13,13,14,11,13,10, 7,10, 9,10,10,12, 9,12, - 10,10,11,11,10,10,12,12,12,12, 9,11,10,11,12,12, - 10,12, 9, -}; - -static const static_codebook _44p5_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p5_p6_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p5_p6_0, - 0 -}; - -static const long _vq_quantlist__44p5_p6_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p5_p6_1[] = { - 2, 6, 6, 5, 7, 8, 5, 8, 7, 6, 7, 7, 7, 7, 8, 8, - 8, 8, 6, 7, 7, 7, 8, 8, 7, 8, 7, 6, 8, 8, 8, 9, - 10, 8, 9, 9, 8, 9, 9, 9, 9,10,10,10,10, 8, 9, 9, - 10,10,10, 9,10,10, 6, 8, 8, 8, 9, 9, 8,10, 9, 9, - 9, 9, 9, 9,10,10,10,10, 8, 9, 9,10,10,10, 9,10, - 9, 6, 8, 9, 8, 9, 9, 8, 9, 9, 8, 9, 9, 9, 9,10, - 9,10,10, 8, 9, 9, 9,10,10, 9,10, 9, 7, 8, 9, 8, - 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 7, 9, 9, 9,10,10, 9,10,10, - 9,10, 9, 9, 9,10,10,10,10, 9,10, 9,10,10,10, 9, - 10, 9, 6, 8, 8, 8, 9, 9, 8, 9, 9, 8, 9, 9, 9, 9, - 10, 9,10,10, 8, 9, 9, 9,10,10, 9,10, 9, 7, 9, 9, - 9,10,10, 9,10, 9, 9, 9,10,10, 9,10,10,10,10, 9, - 9, 9,10,10,10, 9,10, 9, 7, 9, 8, 8, 9, 9, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 8, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p5_p6_1 = { - 5, 243, - (char *)_vq_lengthlist__44p5_p6_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p5_p6_1, - 0 -}; - -static const long _vq_quantlist__44p5_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p5_p7_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p5_p7_0 = { - 5, 243, - (char *)_vq_lengthlist__44p5_p7_0, - 1, -513979392, 1633504256, 2, 0, - (long *)_vq_quantlist__44p5_p7_0, - 0 -}; - -static const long _vq_quantlist__44p5_p7_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p5_p7_1[] = { - 1, 7, 7, 6, 9, 9, 7, 9, 9, 6, 9, 9, 9, 9, 9, 9, - 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10, -}; - -static const static_codebook _44p5_p7_1 = { - 5, 243, - (char *)_vq_lengthlist__44p5_p7_1, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p5_p7_1, - 0 -}; - -static const long _vq_quantlist__44p5_p7_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p5_p7_2[] = { - 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11, - 11,12,12,13,13,14,14,14,14, -}; - -static const static_codebook _44p5_p7_2 = { - 1, 25, - (char *)_vq_lengthlist__44p5_p7_2, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p5_p7_2, - 0 -}; - -static const long _vq_quantlist__44p5_p7_3[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p5_p7_3[] = { - 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p5_p7_3 = { - 1, 25, - (char *)_vq_lengthlist__44p5_p7_3, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p5_p7_3, - 0 -}; - -static const char _huff_lengthlist__44p5_short[] = { - 4, 7,12,14,15,18,20,20, 5, 3, 4, 6, 9,11,15,19, - 9, 4, 3, 4, 7, 9,13,18,11, 6, 3, 3, 5, 8,13,19, - 14, 9, 6, 5, 7,10,16,20,16,11, 9, 8,10,10,14,16, - 21,14,13,11, 8, 7,11,14,21,14,13, 9, 6, 5,10,12, -}; - -static const static_codebook _huff_book__44p5_short = { - 2, 64, - (char *)_huff_lengthlist__44p5_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p6_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p6_l0_0[] = { - 1, 4, 4, 7, 7,10,10,12,12,12,12,13,12, 5, 5, 5, - 8, 6,11, 9,12,12,13,12,12,12, 4, 5, 5, 6, 8, 9, - 11,12,12,13,12,12,12, 7, 7, 8, 9, 9,11, 8,12, 9, - 12,12,12,12, 7, 8, 8, 9, 9, 8,11, 9,12,12,12,11, - 12,10,10,10,11,11,11,11,11,10,11,11,12,11,10,10, - 10,11,11,11,11,10,11,11,11,11,12,11,11,11,12,11, - 12,11,12,11,13,11,13,11,11,11,11,11,12,11,12,10, - 13,11,12,11,13,12,12,12,13,12,13,13,13,12,14,12, - 14,13,12,12,12,12,13,13,13,12,14,12,14,13,14,13, - 14,14,14,14,14,14,14,14,15,14,15,14,13,14,13,14, - 14,14,14,14,15,14,14,14,15, -}; - -static const static_codebook _44p6_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p6_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p6_l0_0, - 0 -}; - -static const long _vq_quantlist__44p6_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p6_l0_1[] = { - 4, 4, 4, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, - 5, 5, 4, 5, 5, 5, 5, 5, 4, -}; - -static const static_codebook _44p6_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p6_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p6_l0_1, - 0 -}; - -static const long _vq_quantlist__44p6_l1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p6_l1_0[] = { - 1, 3, 2, 5, 5, 6, 6, 6, 6, -}; - -static const static_codebook _44p6_l1_0 = { - 2, 9, - (char *)_vq_lengthlist__44p6_l1_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p6_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p6_lfe[] = { - 2, 3, 1, 3, -}; - -static const static_codebook _huff_book__44p6_lfe = { - 2, 4, - (char *)_huff_lengthlist__44p6_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p6_long[] = { - 2, 7,13,15,16,17,19,20, 6, 3, 4, 7, 9,10,12,15, - 13, 4, 3, 4, 7, 8,11,13,14, 7, 4, 4, 6, 7,10,11, - 16, 9, 7, 6, 7, 8, 9,10,16, 9, 8, 7, 7, 6, 8, 8, - 18,12,10,10, 9, 8, 8, 9,20,14,13,12,11, 8, 9, 9, -}; - -static const static_codebook _huff_book__44p6_long = { - 2, 64, - (char *)_huff_lengthlist__44p6_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p6_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p6_p1_0[] = { - 2, 5, 5, 5, 7, 7, 5, 7, 7, 5, 7, 7, 7, 8, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 7, 9, 8, 5, 7, 8, 8, 9, - 10, 8, 9, 9, 8, 9,10, 9,10,12,10,11,11, 8, 9,10, - 10,11,11, 9,11,11, 5, 8, 7, 8, 9, 9, 8,10, 9, 8, - 10, 9, 9,11,11,10,11,11, 8,10, 9,10,11,11, 9,12, - 10, 5, 8, 8, 7, 9,10, 8,10, 9, 7, 9, 9, 9,10,11, - 9,11,11, 8,10,10,10,11,11,10,12,11, 7, 9, 9, 9, - 10,11, 9,11,11, 9, 9,11,10,10,13,11,11,12, 9,11, - 11,11,12,13,11,13,12, 7, 9, 9, 9,11,11, 9,12,10, - 9,11,10,10,11,12,11,13,12, 9,11,11,11,13,13,11, - 13,11, 5, 8, 8, 8, 9,10, 7,10, 9, 8,10,10,10,11, - 11,10,11,11, 7, 9, 9, 9,11,11, 9,11,10, 7, 9, 9, - 9,10,12, 9,11,11, 9,11,11,11,11,13,11,13,13, 9, - 10,11,11,12,13,10,12,11, 7, 9, 9, 9,11,11, 9,11, - 10, 9,11,11,11,12,13,11,13,12, 9,11, 9,11,12,11, - 10,13,10, -}; - -static const static_codebook _44p6_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p6_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p6_p1_0, - 0 -}; - -static const long _vq_quantlist__44p6_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p6_p2_0[] = { - 4, 6, 6, 9, 9, 6, 7, 8,10,10, 6, 8, 7,10,10, 8, - 10,10,12,13, 8,10,10,13,12, 6, 8, 8,10,10, 7, 8, - 9,10,11, 8, 9, 9,11,11,10,10,11,12,13,10,11,11, - 14,13, 6, 8, 8,10,10, 8, 9, 9,11,11, 7, 9, 8,11, - 10,10,11,11,13,14,10,11,10,13,12, 9,10,10,12,12, - 10,10,11,12,13,10,11,11,13,13,12,12,13,12,15,13, - 14,13,15,14, 9,10,10,13,12,10,11,11,13,13,10,11, - 10,13,12,13,13,14,14,15,12,13,12,15,12, 6, 8, 8, - 10,11, 8, 9,10,11,12, 8, 9, 9,11,11,10,11,12,13, - 14,10,11,11,14,13, 8, 9, 9,11,12, 9,10,11,12,13, - 9,10,11,12,13,11,11,13,13,15,11,12,12,14,14, 8, - 9, 9,12,12, 9,10,11,12,13, 9,10,10,13,12,11,12, - 13,14,15,11,12,12,14,14,11,11,12,13,14,11,12,13, - 13,15,12,13,13,14,15,13,13,14,14,16,14,15,15,16, - 16,11,12,11,14,13,12,13,13,14,14,11,13,12,14,13, - 14,15,15,16,16,13,14,14,16,14, 6, 8, 8,11,10, 8, - 9, 9,12,11, 8,10, 9,12,11,10,11,11,13,13,10,12, - 11,14,13, 8, 9, 9,12,12, 9,10,10,12,13, 9,11,10, - 13,12,11,12,12,14,14,11,13,12,15,14, 8, 9, 9,12, - 11, 9,10,10,13,12, 9,11,10,13,12,12,12,12,14,14, - 11,13,12,15,13,11,11,12,13,14,11,12,13,13,14,12, - 13,13,14,15,13,13,14,14,16,14,15,15,16,16,11,12, - 11,14,13,12,13,13,15,14,11,13,12,15,13,14,15,15, - 16,16,13,15,13,16,14, 9,10,11,12,13,11,11,12,13, - 14,11,12,12,13,14,13,13,14,14,16,13,14,14,15,16, - 11,11,12,13,14,12,12,13,14,15,12,13,13,14,15,14, - 14,15,15,17,14,15,15,16,17,11,12,12,14,14,12,13, - 13,14,15,12,13,12,15,15,14,15,15,16,17,14,15,15, - 16,16,13,14,14,15,16,14,14,15,15,17,15,15,15,16, - 17,16,16,17,16,18,16,17,17,18,18,13,14,14,16,15, - 14,15,15,17,16,14,15,15,16,16,16,17,17,18,18,16, - 16,16,17,16, 9,11,10,13,12,11,12,12,14,13,11,12, - 11,15,13,13,14,14,16,15,13,14,13,17,14,11,12,12, - 14,14,12,12,13,15,15,12,13,13,15,14,14,14,15,16, - 16,14,15,15,17,16,11,12,11,14,13,12,13,13,15,14, - 12,13,12,15,13,14,15,15,16,16,14,15,14,17,15,13, - 14,14,15,16,14,15,15,16,17,14,15,15,16,17,16,16, - 16,17,17,16,17,17,18,18,13,15,14,16,15,15,15,15, - 17,16,14,15,14,17,15,16,17,17,18,18,16,17,16,18, - 16, 6, 8, 8,11,11, 8, 9, 9,11,12, 8, 9, 9,12,11, - 10,11,11,13,14,10,12,11,14,13, 7, 9, 9,11,12, 9, - 10,10,12,13, 9,10,10,13,12,11,11,12,13,15,11,12, - 12,15,14, 8, 9, 9,12,11, 9,10,10,13,13, 9,11,10, - 13,12,12,12,12,14,15,11,13,12,15,13,10,11,11,13, - 14,11,12,12,13,15,11,12,12,14,14,13,13,14,14,16, - 14,15,14,16,16,11,12,11,14,13,12,13,13,15,14,11, - 13,12,15,13,14,15,15,16,16,13,14,14,16,14, 8, 9, - 9,11,12, 9,10,11,12,13, 9,10,10,13,12,11,12,13, - 14,15,11,12,12,15,14, 9, 9,11,11,13,10,10,12,12, - 14,10,10,11,13,14,12,12,13,14,16,12,13,13,15,15, - 9,11,10,13,12,10,11,11,13,14,10,12,11,14,13,12, - 13,13,15,16,12,13,13,15,15,11,11,13,13,15,12,12, - 14,13,15,13,13,14,14,15,14,14,15,14,17,15,15,15, - 16,16,12,13,12,15,14,13,14,14,15,15,12,14,13,15, - 14,15,15,15,17,17,14,15,14,17,15, 7, 9, 9,12,11, - 9,10,10,12,12, 9,11,10,13,12,11,12,12,14,14,11, - 13,12,15,14, 9,10,10,12,12,10,10,11,12,13,10,11, - 11,14,13,12,12,13,14,15,12,13,13,16,15, 9,10,10, - 13,12,10,11,11,13,13,10,11,10,14,12,13,13,13,15, - 15,12,13,12,15,14,11,12,12,14,14,12,12,13,14,15, - 13,14,13,15,15,14,13,15,14,16,15,16,15,17,16,12, - 12,12,14,14,13,13,14,15,15,12,13,12,15,14,15,15, - 16,16,17,14,15,14,17,14,10,11,12,13,14,11,12,13, - 14,15,11,12,13,14,15,13,14,15,15,17,14,15,15,16, - 16,11,12,13,12,15,12,12,14,13,16,13,13,14,13,16, - 14,14,16,14,18,15,15,16,16,17,12,13,12,15,15,13, - 14,14,15,16,13,14,13,16,15,15,15,16,17,18,15,15, - 15,17,16,14,14,15,14,17,15,14,16,14,17,15,15,16, - 15,18,16,16,17,16,19,17,17,17,17,18,14,15,15,17, - 16,15,16,16,17,17,15,16,15,18,16,17,17,18,18,18, - 16,17,16,18,17,10,11,11,14,13,11,12,12,15,14,11, - 13,12,15,14,14,15,15,16,16,14,15,15,17,16,11,12, - 12,15,14,12,13,13,15,14,13,14,13,16,14,14,15,15, - 16,16,15,16,15,18,16,11,13,12,15,15,13,14,14,15, - 15,12,14,13,16,15,15,16,16,17,17,15,16,15,17,16, - 14,15,14,16,16,14,15,15,16,16,15,16,15,17,16,16, - 16,17,16,17,17,18,17,19,18,14,15,15,17,16,15,16, - 16,17,17,15,15,15,18,16,17,18,18,18,18,16,17,16, - 19,16, 6, 8, 8,11,11, 8, 9, 9,11,12, 8, 9, 9,12, - 11,10,11,12,13,14,10,11,11,14,13, 8, 9, 9,11,12, - 9,10,11,12,13, 9,10,10,13,13,11,12,13,13,15,11, - 12,12,15,14, 7, 9, 9,12,11, 9,10,10,12,13, 9,10, - 10,13,12,11,12,12,14,15,11,12,11,14,13,11,11,12, - 13,14,11,12,13,13,15,12,13,13,14,15,13,14,14,14, - 16,14,15,15,16,16,10,11,11,14,13,11,12,12,14,14, - 11,12,12,15,13,14,14,14,16,16,13,14,13,16,14, 7, - 9, 9,11,12, 9,10,10,12,13, 9,10,10,12,12,11,12, - 13,14,15,11,12,12,14,14, 9,10,10,12,13,10,10,11, - 12,14,10,11,11,13,13,12,12,13,14,15,13,13,13,15, - 15, 9,10,10,12,12,10,11,11,13,14,10,11,10,13,12, - 12,13,13,15,16,12,13,12,15,14,11,12,13,14,14,12, - 12,13,14,15,13,14,13,15,15,14,14,15,14,17,15,16, - 15,17,16,11,12,12,14,14,13,13,13,15,15,12,13,12, - 15,14,15,15,15,16,17,14,15,14,16,14, 8, 9, 9,12, - 11, 9,10,10,12,13, 9,11,10,13,12,11,12,12,14,15, - 11,12,12,15,14, 9,10,11,13,13,10,11,12,13,14,10, - 11,11,14,13,12,13,13,15,15,12,13,13,16,15, 9,11, - 9,13,11,10,11,10,14,13,10,12,10,14,12,12,13,13, - 15,15,12,13,12,16,14,12,12,13,14,15,12,13,14,14, - 16,13,14,14,15,15,14,14,15,15,17,15,16,15,17,16, - 11,13,11,15,13,13,14,13,15,14,12,14,12,16,13,15, - 15,15,16,16,14,15,14,17,14,10,11,11,13,14,11,12, - 13,14,15,11,12,12,14,15,14,14,15,16,17,14,15,15, - 16,16,11,12,13,14,15,12,13,14,15,16,13,14,14,15, - 16,15,15,16,16,18,15,16,16,17,17,11,12,12,14,15, - 13,13,14,14,16,12,13,13,15,15,15,15,16,16,18,14, - 15,15,16,16,14,15,15,16,17,15,15,16,16,17,15,16, - 16,17,17,16,16,17,16,19,17,18,17,18,18,14,14,15, - 16,16,15,15,16,16,17,14,15,15,16,16,17,17,18,18, - 19,16,17,16,17,16,10,12,11,14,13,11,13,12,15,14, - 11,13,12,15,14,14,15,15,16,16,13,15,14,17,15,12, - 13,13,15,15,13,13,14,15,16,13,14,14,16,16,14,15, - 15,17,17,15,16,16,17,17,11,13,12,15,12,13,14,13, - 16,13,12,14,12,16,13,15,16,15,17,16,14,16,14,18, - 14,14,15,15,16,17,15,15,16,16,17,15,16,16,17,17, - 16,16,17,17,18,17,18,17,18,18,14,15,14,17,14,15, - 16,15,18,15,15,16,15,18,14,17,17,17,18,17,16,17, - 16,19,16, 9,11,11,13,13,10,12,12,14,14,11,12,12, - 15,14,13,14,14,16,16,13,14,14,16,16,10,11,12,14, - 14,11,12,13,14,15,12,13,13,15,15,13,14,15,16,16, - 14,15,15,17,16,11,12,12,15,14,12,13,13,15,15,12, - 13,12,15,15,14,15,15,16,17,14,15,14,17,16,12,13, - 14,15,16,13,13,14,15,16,13,14,15,16,16,14,15,16, - 16,18,15,16,16,18,18,13,14,14,16,15,14,15,15,17, - 16,14,15,15,17,16,16,17,17,18,18,16,17,16,18,17, - 10,12,12,14,14,11,12,13,15,15,12,13,13,15,15,13, - 14,15,16,17,14,15,15,17,16,11,11,13,14,15,12,12, - 14,15,16,13,13,14,15,16,14,14,15,16,17,15,15,16, - 17,17,12,13,12,15,15,13,14,14,16,16,13,14,13,16, - 15,15,16,15,17,17,15,16,15,18,16,13,12,15,14,17, - 14,13,16,14,17,14,14,16,15,18,15,14,17,16,18,16, - 16,17,17,18,14,15,15,17,16,15,16,16,17,17,15,16, - 15,18,16,17,17,17,18,18,16,17,16,19,17,10,11,11, - 14,14,11,12,12,15,15,11,13,12,15,15,14,15,14,16, - 16,14,15,15,17,16,11,12,12,15,14,12,12,13,15,15, - 13,14,13,16,15,14,15,15,16,16,15,16,15,18,17,11, - 13,12,15,15,13,14,13,15,15,12,14,13,16,15,15,16, - 15,17,17,15,16,15,18,16,13,14,13,16,16,14,15,14, - 16,16,14,15,15,17,16,16,16,16,16,18,16,18,17,19, - 18,14,15,15,17,16,15,16,16,17,17,15,15,15,17,16, - 17,17,18,18,19,16,17,16,18,16,12,13,13,15,16,13, - 14,14,16,17,13,14,14,16,16,15,15,16,17,18,15,16, - 16,18,17,13,13,14,14,17,14,14,15,15,17,14,14,15, - 16,17,15,15,17,16,18,16,17,17,18,18,13,14,14,17, - 16,14,15,15,17,17,14,15,14,17,16,16,17,17,18,18, - 16,17,16,18,17,15,14,16,13,18,16,15,17,14,19,16, - 16,17,15,18,17,16,18,15,19,18,18,18,17,19,15,16, - 16,18,17,16,17,17,18,18,16,17,16,19,17,18,19,18, - 19,19,17,18,17,20,18,11,12,12,15,15,13,13,14,15, - 16,13,14,13,16,15,15,16,16,17,17,15,16,16,18,17, - 12,14,13,16,15,13,13,14,15,16,14,15,14,17,16,16, - 16,16,16,17,16,17,17,19,17,12,13,14,16,16,14,15, - 15,16,17,13,15,13,17,15,16,17,17,18,18,16,17,16, - 18,16,15,16,15,17,16,15,15,15,17,17,16,17,16,18, - 17,17,16,17,16,18,18,19,18,20,18,15,16,16,17,17, - 16,17,17,18,18,15,16,15,18,17,18,18,19,19,19,17, - 18,16,19,16, 9,11,11,13,13,11,12,12,14,15,10,12, - 12,14,14,13,14,14,16,16,13,14,14,16,16,11,12,12, - 14,14,12,12,13,15,15,12,13,13,15,15,14,15,15,16, - 17,14,15,15,16,16,10,12,11,14,14,12,13,13,15,15, - 11,13,12,15,14,14,15,15,16,17,13,15,14,17,16,13, - 14,14,15,16,14,15,15,16,17,14,15,15,16,17,16,16, - 17,17,18,16,17,17,18,18,12,14,13,16,15,13,15,14, - 17,16,13,14,13,17,15,15,16,16,18,18,15,16,15,18, - 16,10,11,11,14,14,11,12,13,14,15,11,12,12,15,15, - 14,15,15,16,17,14,15,15,16,16,11,12,13,15,15,12, - 13,14,15,16,13,14,14,15,16,15,15,16,16,18,15,15, - 16,17,17,11,12,12,14,15,13,13,14,15,16,12,13,13, - 15,15,15,15,16,17,18,14,15,15,17,16,14,15,15,16, - 17,15,15,16,16,17,15,16,16,17,17,16,16,17,16,19, - 17,17,18,19,18,13,13,14,16,16,14,15,16,17,17,14, - 14,15,16,16,16,16,17,18,18,16,16,16,18,16,10,12, - 12,14,14,12,13,13,15,15,11,13,12,15,15,14,15,15, - 16,17,13,15,14,17,16,12,13,13,15,15,13,13,14,15, - 16,13,14,14,16,16,15,15,16,17,18,15,15,16,17,17, - 11,13,12,15,14,13,14,13,16,15,12,14,12,16,14,15, - 16,15,17,17,14,16,14,17,16,14,15,15,16,17,15,15, - 16,16,18,15,16,16,17,17,16,17,17,17,19,17,17,17, - 18,18,13,15,12,17,14,14,16,14,17,15,14,15,13,17, - 14,16,17,16,18,17,15,17,14,19,15,11,12,12,15,15, - 13,13,14,15,16,13,14,13,16,15,15,16,16,17,18,15, - 16,16,17,17,12,14,13,16,16,13,13,15,15,17,14,15, - 15,17,16,16,16,17,16,19,16,17,17,18,18,12,13,14, - 15,16,14,14,15,16,17,13,14,13,16,15,16,17,17,18, - 19,15,16,16,17,16,15,16,16,18,17,15,15,16,17,18, - 16,17,17,18,18,16,16,18,16,19,18,19,19,20,19,15, - 15,16,16,17,16,16,17,17,18,15,15,15,17,16,18,18, - 19,18,20,17,17,16,18,16,12,13,13,16,15,13,14,14, - 16,16,13,14,14,16,16,15,16,16,17,18,15,16,15,18, - 17,13,14,14,16,16,14,15,15,16,17,14,15,15,17,17, - 16,17,17,18,18,16,17,17,18,18,13,14,13,17,14,14, - 15,14,17,16,14,15,14,17,15,16,17,17,18,18,15,17, - 15,19,15,16,16,16,17,18,16,16,17,17,19,16,17,17, - 18,19,17,17,18,18,20,18,18,18,19,19,15,16,14,18, - 13,16,17,16,19,15,16,17,15,19,14,18,18,18,19,17, - 17,18,16,20,15, -}; - -static const static_codebook _44p6_p2_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p6_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p6_p2_0, - 0 -}; - -static const long _vq_quantlist__44p6_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p6_p3_0[] = { - 1, 5, 5, 5, 7, 8, 5, 8, 7, 5, 7, 8, 8, 8,10, 8, - 10,10, 5, 8, 7, 8,10,10, 8,10, 8, 6, 8, 9, 8,10, - 12, 9,11,11, 9,10,11,11,11,13,12,13,13, 9,11,11, - 11,13,13,11,13,12, 6, 9, 8, 9,11,11, 8,12,10, 9, - 11,11,11,12,13,11,13,13, 9,11,10,11,13,13,11,13, - 11, 5, 9, 9, 8,11,11, 9,12,11, 8,10,11,10,11,13, - 11,13,13, 9,11,11,11,13,13,11,13,12, 8,10,11,10, - 12,13,10,13,12,10,10,13,11,11,14,12,13,14,11,13, - 12,13,14,14,12,14,12, 8,11,10,11,12,13,11,14,12, - 10,13,12,12,12,13,13,15,14,11,12,13,13,14,15,12, - 14,12, 5, 9, 9, 9,11,12, 8,11,11, 9,11,11,11,12, - 13,11,13,13, 8,11,10,11,13,13,10,13,11, 8,10,11, - 11,12,14,11,13,12,11,13,12,12,12,14,13,15,14,10, - 12,13,13,14,15,12,13,12, 8,11,10,10,12,13,10,13, - 12,11,12,13,12,12,14,13,14,14,10,13,10,12,14,13, - 11,14,11, -}; - -static const static_codebook _44p6_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p6_p3_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p6_p3_0, - 0 -}; - -static const long _vq_quantlist__44p6_p3_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p6_p3_1[] = { - 5, 7, 7, 6, 7, 7, 6, 7, 7, 6, 7, 7, 7, 8, 8, 7, - 8, 8, 6, 7, 7, 7, 8, 8, 7, 8, 8, 7, 7, 8, 7, 8, - 8, 7, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, 8, - 8, 9, 9, 8, 9, 8, 7, 8, 7, 7, 8, 8, 7, 8, 8, 8, - 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, - 8, 6, 8, 8, 7, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, 9, - 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, 8, 7, 8, 8, 8, - 8, 9, 8, 9, 9, 8, 8, 9, 8, 9, 9, 9, 9, 9, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 7, 8, 8, 8, 9, 9, 8, 9, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 8, 9, 8, 9, 9, 9, 9, - 9, 9, 6, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, - 9, 8, 9, 9, 7, 8, 8, 8, 9, 9, 8, 9, 8, 7, 8, 8, - 8, 8, 9, 8, 9, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 8, - 8, 8, 9, 9, 9, 8, 9, 9, 7, 8, 8, 8, 9, 9, 8, 9, - 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 8, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p6_p3_1 = { - 5, 243, - (char *)_vq_lengthlist__44p6_p3_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p6_p3_1, - 0 -}; - -static const long _vq_quantlist__44p6_p4_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p6_p4_0[] = { - 2, 5, 5, 5, 7, 8, 5, 8, 7, 5, 7, 7, 7, 7, 9, 7, - 9, 9, 5, 7, 7, 8, 9, 9, 7, 9, 7, 6, 8, 8, 8, 9, - 10, 8, 9, 9, 8, 9,10, 9, 9,11,10,11,11, 8, 9, 9, - 10,11,11, 9,11,10, 6, 8, 8, 8, 9, 9, 8,10, 9, 8, - 9, 9, 9,10,11,10,11,10, 8,10, 9,10,11,11, 9,11, - 9, 6, 8, 8, 7, 9, 9, 8,10, 9, 7, 9, 9, 9, 9,10, - 9,10,10, 8, 9, 9, 9,10,10, 9,11,10, 7, 9, 9, 8, - 10,10, 9,10,10, 9, 9,10,10,10,11,10,11,11, 9,10, - 10,10,11,11,10,11,10, 7, 9, 9, 9, 9,10, 9,10, 9, - 8,10, 9, 9, 9,11,10,11,11, 9,10,10,10,11,11, 9, - 11, 9, 6, 8, 8, 8, 9,10, 7, 9, 9, 8, 9, 9, 9,10, - 10, 9,10,10, 7, 9, 9, 9,10,10, 9,10, 9, 7, 9, 9, - 9, 9,10, 9,10, 9, 9,10,10, 9, 9,11,10,11,11, 8, - 9,10,10,11,11, 9,11, 9, 7, 9, 9, 9,10,10, 8,10, - 10, 9,10,10,10,10,11,10,11,11, 9,10, 9,10,11,11, - 10,11,10, -}; - -static const static_codebook _44p6_p4_0 = { - 5, 243, - (char *)_vq_lengthlist__44p6_p4_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p6_p4_0, - 0 -}; - -static const long _vq_quantlist__44p6_p4_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p6_p4_1[] = { - 6, 8, 8,10,10, 8, 9, 9,10,11, 8,10, 9,11,10, 9, - 10,10,11,11, 9,10,10,11,11, 8, 9, 9,10,10, 9, 9, - 10,11,11,10,10,10,11,11,10,11,11,11,11,10,11,11, - 11,11, 8, 9, 9,11,10,10,10,10,11,11, 9,10, 9,11, - 11,10,11,11,11,11,10,11,10,11,11,10,10,11,11,11, - 10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,10,11,10,11,11,11,11,11,11,11,10,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11, 8, 9,10, - 11,11,10,10,11,11,11,10,10,10,11,11,10,11,11,12, - 12,10,11,11,12,12,10,10,11,11,11,10,10,11,11,12, - 11,11,11,12,12,11,11,12,12,12,11,11,12,12,12,10, - 10,10,11,11,11,11,11,12,12,10,11,11,12,12,11,12, - 12,12,12,11,12,11,12,12,11,11,11,11,12,11,11,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,11,11,11,12,11,11,12,12,12,12,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12, 8,10, 9,11,11,10, - 10,10,11,11,10,11,10,11,11,10,11,11,12,12,10,11, - 11,12,12,10,10,10,11,11,10,11,11,12,12,11,11,11, - 12,12,11,11,12,12,12,11,12,12,12,12,10,11,10,11, - 11,11,11,11,12,12,10,11,10,12,11,11,12,11,12,12, - 11,12,11,12,12,11,11,11,12,12,11,11,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11, - 11,12,11,11,12,12,12,12,11,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,10,11,11,11,12,11,11,12,12, - 12,11,11,11,12,12,11,12,12,12,12,11,12,12,12,12, - 11,11,12,12,12,11,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,13,11,12,11,12,12,12,12, - 12,12,12,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,13,12,13,12,12,12,12,13,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,12, - 12,12,13,12,10,11,11,12,11,11,11,12,12,12,11,12, - 11,12,12,11,12,12,12,12,11,12,12,12,12,11,11,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,11,12,11,12,12,12,12,12,12,12, - 11,12,12,12,12,12,12,12,12,12,12,12,12,13,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,13,12,12,12,12,13,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,13,13,12,13,12,13, - 12, 8,10,10,11,11,10,10,11,11,11,10,11,10,11,11, - 10,11,11,12,12,10,11,11,12,12, 9,10,11,11,11,10, - 10,11,12,12,10,11,11,12,12,11,11,12,12,12,11,12, - 12,12,12,10,11,10,11,11,11,11,11,12,12,10,11,11, - 12,12,11,12,12,12,12,11,12,11,12,12,11,11,11,12, - 12,11,11,12,12,12,11,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,11,11,11,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12, 9,10, - 10,11,11,10,11,11,12,12,10,11,11,12,12,11,11,12, - 12,12,11,12,12,12,12,10,11,11,12,12,11,11,12,12, - 12,11,11,12,12,12,11,11,12,12,12,12,12,12,12,12, - 10,11,11,12,12,11,12,12,12,12,11,12,11,12,12,12, - 12,12,12,12,12,12,12,12,12,11,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12, 9,10,10,11,11, - 10,11,11,12,12,10,11,11,12,11,11,12,12,12,12,11, - 12,12,12,12,10,11,11,12,12,11,11,11,12,12,11,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,10,11,11, - 12,12,11,12,12,12,12,11,12,11,12,12,12,12,12,12, - 12,12,12,12,12,12,11,12,12,12,12,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,11,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,11,11,11,12,12,11,12,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 13,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,13,12,13,12,12,13,13,13,11,12,12,12,12,12, - 12,12,13,13,12,12,12,13,12,12,12,12,13,13,12,13, - 12,13,13,12,12,12,12,12,12,12,12,12,13,12,13,13, - 13,13,12,13,13,13,13,13,13,13,13,13,12,12,12,12, - 12,12,12,13,13,13,12,13,12,13,13,12,13,13,13,13, - 12,13,13,13,13,11,11,11,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, - 12,13,12,12,12,13,13,11,12,12,12,12,12,12,12,12, - 13,12,12,12,13,12,12,13,12,13,13,12,13,12,13,13, - 12,12,12,12,12,12,12,13,13,13,12,12,13,13,13,12, - 13,13,12,13,13,13,13,13,13,12,12,12,12,12,12,13, - 12,13,13,12,13,12,13,12,12,13,13,13,13,12,13,13, - 13,13, 8,10,10,11,11,10,10,11,11,11, 9,11,10,11, - 11,10,11,11,12,12,10,11,11,12,12,10,10,11,11,11, - 10,11,11,12,12,11,11,11,12,12,11,11,12,12,12,11, - 12,12,12,12, 9,11,10,11,11,10,11,11,12,12,10,11, - 10,12,12,11,12,12,12,12,11,12,11,12,12,11,11,11, - 12,12,11,12,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,11,11,11,12,12,11,12,12,12,12, - 11,12,11,12,12,12,12,12,12,12,12,12,12,12,12, 9, - 10,10,11,11,10,11,11,12,12,10,11,11,12,12,11,12, - 12,12,12,11,12,12,12,12,10,11,11,12,12,11,11,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,10,11,11,12,12,11,11,12,12,12,11,11,11,12,12, - 12,12,12,12,12,11,12,12,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,11,12,12,12,12,12,12,12,12,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12, 9,10,10,11, - 11,10,11,11,12,12,10,11,11,12,12,11,12,12,12,12, - 11,12,11,12,12,10,11,11,12,12,11,11,12,12,12,11, - 11,12,12,12,12,12,12,12,12,12,12,12,12,12,10,11, - 11,12,12,11,12,11,12,12,11,12,11,12,12,12,12,12, - 12,12,11,12,11,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 11,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,11,11,11,12,12,11,12, - 12,12,12,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,13, - 13,12,12,12,13,13,12,12,13,13,13,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,13,12,13,13,12, - 12,12,13,12,12,12,12,12,12,12,12,13,13,13,12,12, - 13,13,13,12,13,13,12,13,12,13,13,13,13,12,12,12, - 12,12,12,12,13,13,13,12,12,12,13,12,12,13,13,13, - 13,12,13,13,13,13,11,11,11,12,12,11,12,12,12,12, - 11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,13,12,12,12, - 13,13,13,12,12,12,13,13,11,12,12,12,12,12,12,12, - 13,12,12,12,12,13,12,12,13,12,13,13,12,13,12,13, - 12,12,12,12,12,12,12,12,13,13,13,12,13,13,13,13, - 12,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12, - 13,12,13,12,12,13,12,13,12,13,13,13,13,13,12,13, - 13,13,13,10,11,11,12,12,11,12,12,12,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,11,11,12,12, - 12,11,12,12,12,12,12,12,12,12,12,12,12,12,13,13, - 12,12,12,13,13,11,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,13,13,12,12,12,13,12,12,12, - 12,12,12,12,12,12,12,13,12,12,12,12,13,12,12,13, - 12,13,12,13,13,13,13,12,12,12,12,12,12,12,12,13, - 12,12,12,12,13,12,12,13,13,13,13,12,13,12,13,13, - 11,11,11,12,12,11,12,12,12,12,11,12,12,12,12,12, - 12,12,12,13,12,12,12,13,12,11,12,12,12,12,12,12, - 12,12,13,12,12,12,12,13,12,12,13,13,13,12,12,13, - 13,13,11,12,12,12,12,12,12,12,12,13,12,12,12,13, - 12,12,13,12,13,13,12,13,12,13,13,12,12,12,12,12, - 12,12,13,12,13,12,12,13,13,13,12,12,13,13,13,13, - 13,13,13,13,12,12,12,12,12,12,13,13,13,13,12,13, - 12,13,12,12,13,13,13,13,12,13,13,13,13,11,11,11, - 12,12,11,12,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,13,11,12,12,12,12,12,12,12,12,13, - 12,12,12,13,13,12,12,13,13,13,12,12,13,13,13,11, - 12,12,12,12,12,12,12,13,13,12,12,12,13,12,12,13, - 12,13,13,12,13,12,13,13,12,12,12,12,12,12,12,12, - 12,13,12,13,12,13,13,12,13,13,13,13,12,13,13,13, - 13,12,12,12,12,12,12,13,12,13,13,12,12,12,13,13, - 12,13,13,13,13,12,13,12,13,13,11,12,12,12,12,11, - 12,12,12,12,11,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,13,12,13,12,12,12,13,13,11,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13, - 12,13,12,13,13,12,12,12,12,12,12,12,13,12,13,12, - 12,13,12,13,12,12,13,12,13,12,13,13,13,13,12,12, - 12,12,12,12,12,12,12,12,12,12,12,13,12,12,13,13, - 13,13,12,13,12,13,12,11,11,11,12,12,11,12,12,12, - 12,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,13,13,11,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,13,13,12,12,12, - 13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,13,12,12,12,13,12,12,12,12,12,12,12,12, - 12,12,12,13,12,12,12,12,13,12,12,13,12,13,12,12, - 13,12,13,12,10,11,11,12,12,11,12,12,12,12,11,12, - 11,12,12,11,12,12,12,12,11,12,12,12,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 13,12,12,12,13,13,11,12,11,12,12,12,12,12,12,12, - 11,12,12,12,12,12,12,12,13,13,12,12,12,13,12,12, - 12,12,12,12,12,12,12,12,13,12,12,12,12,13,12,13, - 13,12,13,12,13,13,13,13,12,12,12,12,12,12,12,12, - 13,13,12,12,12,13,12,12,13,13,13,13,12,13,12,13, - 12,11,11,11,12,12,11,12,12,12,12,11,12,12,12,12, - 12,12,12,13,13,12,12,12,13,12,11,12,12,12,12,12, - 12,12,12,13,12,12,12,13,13,12,12,13,13,13,12,12, - 13,13,13,11,12,12,12,12,12,12,12,13,13,12,12,12, - 13,12,12,13,12,13,13,12,12,12,13,13,12,12,12,12, - 12,12,12,13,13,13,12,12,13,13,13,12,12,13,13,13, - 12,13,13,13,13,12,12,12,12,12,12,12,13,13,13,12, - 12,12,13,12,12,13,13,13,13,12,13,13,13,13,11,11, - 11,12,12,11,12,12,12,12,11,12,12,12,12,12,12,12, - 12,13,12,12,12,13,13,11,12,12,12,12,12,12,12,12, - 13,12,12,12,13,13,12,12,13,13,13,12,12,13,13,13, - 11,12,12,12,12,12,12,12,13,12,12,12,12,13,12,12, - 13,12,13,13,12,13,12,13,13,12,12,12,12,12,12,12, - 12,13,13,12,13,12,13,13,12,13,13,13,13,13,13,13, - 13,13,12,12,12,12,12,12,13,12,13,13,12,13,12,13, - 12,12,13,13,13,13,12,13,12,13,13,11,11,11,12,12, - 11,12,12,12,12,11,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,11,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,13,12,12,12,13,13,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, - 13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, - 12,12,12,12,13,12,12,12,12,13,12,12,13,12,13,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 13,12,12,12,13,12,12,12,11,12,11,12,12,11,12,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,11,12,12,12,12,12,12,12,12,13,12,12,12,12,12, - 12,12,12,13,13,12,12,12,13,13,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,13,12,13,13,12,12, - 12,13,12,12,12,12,12,12,12,12,12,12,13,12,12,12, - 13,13,12,12,13,12,13,12,13,13,13,13,12,12,12,12, - 12,12,12,12,13,12,12,12,12,13,12,12,13,12,13,13, - 12,13,12,13,12, -}; - -static const static_codebook _44p6_p4_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p6_p4_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p6_p4_1, - 0 -}; - -static const long _vq_quantlist__44p6_p5_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p6_p5_0[] = { - 2, 6, 6,10,10, 5, 7, 8,11,12, 5, 8, 7,12,11, 9, - 11,11,13,15, 9,11,11,15,13, 6, 7, 8,11,11, 7, 7, - 9,11,13, 8, 9, 9,13,12,11,11,12,12,15,11,12,12, - 15,14, 6, 8, 7,11,11, 8, 9, 9,12,13, 7, 9, 7,13, - 11,11,12,12,14,15,11,12,11,15,12,10,11,11,12,14, - 10,11,12,12,15,12,13,13,14,15,13,12,14,12,16,15, - 15,15,16,16,10,11,11,14,12,12,13,13,15,14,10,12, - 11,15,12,15,15,15,16,17,13,14,12,17,12, 6, 8, 8, - 12,12, 8, 9,10,13,13, 8, 9, 9,13,13,12,12,13,15, - 16,12,13,13,16,15, 8, 9,10,12,13, 9, 9,11,13,14, - 10,11,11,14,14,13,13,14,15,16,13,14,14,16,16, 8, - 10, 9,13,13,10,11,11,14,14, 9,10,10,14,13,13,14, - 14,16,17,13,13,13,16,15,12,13,13,14,16,13,13,14, - 14,16,14,14,14,16,16,15,15,16,15,18,16,17,17,18, - 18,12,13,13,15,15,14,14,14,16,16,13,14,13,16,15, - 16,16,17,18,18,15,16,15,18,15, 6, 8, 8,12,12, 8, - 9, 9,13,13, 8,10, 9,13,13,12,13,13,15,16,12,13, - 12,16,15, 8, 9,10,13,13, 9,10,10,13,14,10,11,11, - 14,14,13,13,13,15,16,13,14,14,17,16, 8,10, 9,13, - 13,10,11,11,14,14, 9,11, 9,14,13,13,14,14,16,16, - 13,14,13,16,14,12,13,13,15,16,13,13,14,15,16,14, - 14,14,16,16,15,15,16,15,18,17,17,17,18,18,12,13, - 13,16,14,14,14,14,16,16,13,14,13,16,14,16,17,17, - 18,18,15,16,15,18,15,11,12,13,14,16,13,13,14,15, - 17,13,14,14,16,17,16,16,17,17,19,16,17,17,18,19, - 13,13,14,16,16,14,14,15,16,17,14,15,15,17,17,17, - 16,17,17,19,17,17,18,19,19,13,14,14,16,16,14,14, - 15,17,18,14,15,14,17,17,17,17,18,18,19,17,17,17, - 18,19,16,16,16,17,18,17,17,17,18,19,17,17,17,18, - 19,18,18,19,18,20,19,20,19,21,20,16,17,17,18,18, - 17,17,18,19,19,17,17,17,19,18,19,19,19,19,20,19, - 19,19,20,19,11,13,12,16,14,13,14,14,17,16,13,14, - 13,17,15,16,17,17,18,18,16,17,16,19,17,13,14,14, - 16,16,14,14,14,17,17,14,15,15,17,16,17,17,17,19, - 19,17,18,17,19,18,13,14,13,17,16,14,15,15,17,17, - 14,15,14,18,16,17,17,17,19,19,17,17,16,19,17,16, - 17,17,18,19,17,17,17,18,18,17,18,17,19,18,18,19, - 18,19,19,19,20,19,20,20,16,17,16,18,17,17,17,17, - 18,18,17,18,17,19,17,19,19,19,19,20,18,19,19,20, - 18, 6, 8, 8,12,12, 8, 9, 9,13,13, 8,10, 9,13,13, - 11,13,13,15,16,12,13,13,16,15, 8, 9, 9,13,13, 9, - 9,10,13,14,10,11,11,14,14,12,12,13,14,16,13,14, - 14,17,16, 8,10, 9,13,13,10,11,11,14,14, 9,11,10, - 14,13,13,14,14,16,16,13,14,13,16,15,12,13,13,14, - 16,12,13,14,14,16,13,14,14,16,16,15,14,16,15,18, - 16,17,17,18,17,12,13,13,16,15,14,14,14,16,16,13, - 14,13,16,15,16,16,17,17,17,15,16,15,18,15, 7, 9, - 9,13,13, 9, 9,11,13,14, 9,10,10,14,13,12,13,14, - 15,16,12,14,13,17,15, 9, 9,10,13,14,10, 9,11,13, - 15,11,11,11,14,14,13,12,14,14,17,14,14,14,17,16, - 9,10,10,14,13,11,11,11,14,14,10,11,10,15,13,14, - 14,14,16,17,13,14,13,17,14,13,13,14,14,16,13,13, - 14,14,17,14,14,14,16,16,15,14,16,15,18,17,17,17, - 18,18,13,14,13,16,15,14,14,15,17,16,13,14,13,17, - 15,17,16,17,17,17,15,16,14,18,14, 7, 9, 9,13,13, - 9,10,10,13,14, 9,11,10,14,13,13,14,14,16,16,13, - 14,14,17,15, 9,10,10,14,13, 9,10,11,13,14,11,12, - 11,15,14,13,13,14,14,16,14,15,15,17,17, 9,10,10, - 14,14,11,12,12,14,15,10,11,10,15,13,14,15,15,17, - 17,14,15,13,17,14,13,14,13,16,16,13,13,14,15,16, - 14,15,15,17,17,15,14,16,15,18,17,18,17,20,18,13, - 14,14,16,16,15,15,15,17,17,13,14,13,17,15,17,17, - 18,18,18,15,16,14,19,14,12,13,13,15,16,13,13,15, - 16,17,13,14,14,16,16,15,15,17,17,19,16,17,17,19, - 18,13,13,14,15,17,14,13,15,15,17,14,15,15,16,17, - 16,15,18,16,19,17,17,17,18,19,13,14,14,17,16,14, - 15,15,17,17,14,15,14,17,16,17,17,17,18,19,16,17, - 16,19,17,16,16,17,16,18,16,16,17,16,19,17,17,18, - 18,19,18,17,18,17,21,19,19,19,20,19,16,17,17,18, - 18,17,17,18,18,19,16,17,16,18,18,19,19,19,19,20, - 18,18,17,20,18,11,13,13,16,15,13,14,14,16,17,13, - 15,14,17,16,16,17,17,18,18,17,17,17,19,18,13,14, - 13,17,16,14,13,14,16,17,15,16,15,18,16,17,16,17, - 17,19,18,18,18,20,18,13,14,14,16,17,15,15,15,17, - 18,14,15,14,18,16,18,18,18,19,20,17,18,16,20,17, - 16,17,16,18,18,16,16,17,18,18,17,18,18,19,18,18, - 17,19,17,20,19,20,19,22,20,16,16,17,18,18,18,17, - 17,19,19,16,17,16,18,17,19,20,19,22,21,18,19,18, - 21,17, 6, 8, 8,12,12, 8, 9,10,13,13, 8, 9, 9,13, - 13,12,13,13,15,16,11,13,13,16,15, 8, 9,10,13,13, - 9,10,11,13,14,10,11,11,14,14,13,13,14,15,16,13, - 14,14,16,16, 8, 9, 9,13,13,10,11,11,14,14, 9,10, - 9,14,13,13,14,14,16,17,12,14,12,16,14,12,13,13, - 15,16,13,13,14,15,16,13,14,14,15,17,15,15,16,15, - 18,16,16,17,17,17,12,13,13,16,14,13,14,14,16,16, - 12,14,13,16,14,16,17,17,18,18,15,15,14,18,14, 7, - 9, 9,13,13, 9,10,11,13,14, 9,10,10,14,13,13,14, - 14,15,17,13,14,14,16,15, 9,10,10,14,14,10,10,11, - 13,15,11,12,12,15,14,14,13,15,14,17,14,15,15,17, - 17, 9,10,10,13,14,11,11,12,14,15, 9,11,10,14,13, - 14,15,15,16,18,13,14,13,16,14,13,14,14,16,16,13, - 13,14,15,17,15,15,15,16,17,15,14,16,15,18,17,17, - 18,19,18,13,14,14,16,16,14,15,15,17,17,13,14,13, - 16,15,17,17,18,18,18,15,16,14,18,15, 7, 9, 9,13, - 13, 9,10,10,13,14, 9,11,10,14,13,12,13,14,15,16, - 12,14,13,16,15, 9,10,10,13,14,10,10,11,13,14,11, - 11,11,15,14,13,13,14,14,16,14,14,14,17,16, 9,10, - 9,14,13,11,11,11,14,14,10,11, 9,15,13,14,14,14, - 16,16,13,14,12,17,14,13,13,14,15,16,13,13,14,15, - 16,14,15,14,16,17,15,14,16,14,18,16,17,17,18,18, - 13,14,13,16,14,14,14,14,16,16,13,14,13,17,14,17, - 17,17,18,18,15,16,14,18,15,11,13,13,16,16,13,14, - 15,16,17,13,14,14,17,16,16,17,17,18,19,17,17,17, - 19,18,13,14,14,17,17,13,13,15,16,18,15,15,15,17, - 17,17,16,18,17,20,18,17,18,19,19,13,14,14,16,17, - 15,15,16,16,18,14,15,14,16,16,17,17,18,18,20,17, - 18,16,18,17,16,17,16,19,18,16,16,17,18,19,18,18, - 18,19,19,18,17,18,17,21,20,19,19,21,21,16,16,17, - 18,18,17,17,18,19,19,16,17,16,19,18,20,20,20,19, - 21,18,18,17,20,18,12,13,13,16,15,13,14,14,16,16, - 13,14,13,17,16,16,17,17,18,18,15,17,15,19,17,13, - 14,14,16,17,14,14,15,16,17,14,15,15,17,17,16,16, - 17,17,18,17,17,17,19,19,13,14,13,17,15,14,15,15, - 17,16,14,15,13,17,15,17,18,17,19,18,16,17,15,20, - 16,16,17,17,18,18,16,16,17,18,18,17,18,17,19,18, - 17,17,18,18,20,19,20,19,20,19,16,16,16,19,16,17, - 17,17,19,18,16,17,16,19,16,19,19,19,19,19,18,19, - 17,19,17,11,13,13,16,16,13,14,14,17,17,13,14,14, - 17,17,15,17,17,19,19,16,18,17,20,19,12,14,14,17, - 17,13,14,15,17,18,14,15,15,17,18,16,16,17,18,20, - 17,18,18,20,18,13,14,14,17,17,14,15,15,17,18,14, - 15,15,17,17,17,18,17,19,19,17,18,17,19,19,15,16, - 16,18,18,15,16,17,18,19,16,17,17,19,19,17,17,18, - 18,21,18,19,19,21,19,16,17,17,18,18,17,17,18,19, - 19,17,18,17,19,19,19,19,19,20,20,18,19,18,21,19, - 12,13,13,16,16,13,14,14,16,17,13,15,14,17,16,15, - 16,17,17,19,16,17,17,19,18,13,13,14,16,17,14,13, - 15,16,17,14,15,15,17,17,15,15,17,17,20,17,17,18, - 19,18,13,14,14,17,16,15,15,15,17,18,14,15,14,17, - 16,17,17,17,18,18,16,17,16,19,17,16,15,17,17,19, - 16,15,17,16,19,17,16,17,18,19,17,16,19,16,20,19, - 18,19,19,19,16,17,17,18,18,17,17,17,18,19,16,17, - 16,19,18,20,19,19,20,19,18,18,17,20,17,11,13,13, - 16,16,13,14,15,16,17,14,15,14,18,16,17,17,17,18, - 21,17,18,17,20,19,13,14,14,17,16,13,14,15,16,18, - 15,16,15,18,17,17,16,17,17,19,17,18,18,20,19,13, - 14,14,16,17,15,15,16,17,18,14,15,14,18,17,17,18, - 18,19,20,17,18,16,19,17,16,17,15,19,18,16,16,16, - 18,18,17,18,17,20,19,18,17,18,17,20,20,20,19,22, - 20,16,17,17,18,19,18,18,18,19,20,16,17,16,19,18, - 20,19,19,20,20,18,19,17,20,17,13,14,14,16,17,14, - 14,16,16,18,14,16,15,17,16,16,16,17,17,18,17,17, - 16,19,18,14,14,15,16,17,14,14,16,16,18,16,16,16, - 17,17,16,15,17,16,19,18,18,18,19,19,14,15,15,17, - 17,15,16,16,17,18,14,16,14,18,16,17,17,18,18,19, - 16,17,16,19,17,16,16,17,16,18,16,16,17,16,19,18, - 18,18,17,18,17,16,18,16,20,19,19,19,19,19,16,17, - 17,18,18,17,17,18,19,19,16,17,16,19,17,18,19,19, - 19,20,17,18,16,20,16,11,14,13,17,17,14,14,16,16, - 18,14,16,14,19,16,18,18,19,18,19,18,19,18,21,18, - 13,15,14,18,16,14,14,16,16,18,16,17,16,19,17,18, - 16,19,17,20,19,19,19,21,19,13,14,15,17,18,17,16, - 17,17,19,14,16,14,18,16,20,19,19,20,21,18,19,16, - 21,17,17,18,16,19,17,16,16,17,18,18,19,19,18,21, - 18,17,17,18,17,20,20,20,20,22,20,17,17,18,18,20, - 19,19,19,18,20,16,17,17,19,19,21,21,21,20,21,17, - 19,17,23,17,11,13,13,16,16,13,14,14,17,17,13,14, - 14,17,17,16,17,17,19,20,15,16,16,19,19,13,14,14, - 16,17,14,15,15,17,18,14,15,15,17,17,17,17,18,19, - 19,17,17,18,19,19,13,14,14,17,16,14,15,15,17,17, - 13,15,14,18,17,17,18,18,19,20,16,17,16,19,18,16, - 16,17,18,18,17,17,17,18,19,17,18,17,19,19,19,19, - 19,19,20,19,20,19,20,20,15,16,16,18,17,16,17,17, - 20,18,15,16,16,19,17,19,19,19,20,20,17,18,17,21, - 17,11,13,13,16,16,13,14,15,16,17,13,15,14,17,16, - 17,17,18,18,20,17,17,17,19,19,13,14,14,17,17,14, - 14,15,17,18,15,15,15,18,17,17,17,18,17,20,18,18, - 17,20,18,13,14,14,16,17,15,15,16,17,18,14,15,13, - 17,17,17,18,18,19,20,17,17,16,19,17,16,17,17,18, - 18,16,16,17,18,18,18,18,18,19,19,18,17,19,18,21, - 19,20,20,20,20,16,15,17,18,18,17,17,18,18,20,16, - 16,16,18,17,20,19,20,21,22,17,18,17,20,17,12,13, - 13,16,16,13,14,15,16,17,13,14,14,17,16,16,17,18, - 18,19,15,16,16,19,18,13,14,14,16,17,14,14,15,16, - 17,14,15,15,17,17,16,16,17,17,19,17,17,17,19,18, - 13,14,13,17,16,14,15,15,17,17,13,15,13,17,16,17, - 17,17,19,19,15,17,15,19,17,16,17,17,18,18,16,16, - 17,17,19,17,18,17,19,19,18,17,19,17,19,19,19,19, - 20,19,15,17,15,19,16,17,17,16,19,18,16,17,15,18, - 16,19,19,19,20,19,17,19,16,19,16,11,14,14,17,17, - 15,14,16,16,18,15,16,14,18,16,18,18,19,18,21,18, - 19,18,20,18,13,15,14,18,17,14,14,16,16,18,16,17, - 16,19,17,17,17,19,17,22,19,19,19,21,19,13,14,15, - 17,18,17,16,17,17,19,14,16,14,18,16,19,19,19,20, - 21,18,18,16,20,17,17,18,16,19,18,15,17,17,19,19, - 19,19,18,21,19,18,17,20,17,21,22,21,20,21,21,17, - 16,19,18,20,19,18,19,18,20,16,17,16,19,18,21,20, - 21,19,23,18,19,16,20,17,13,14,14,17,16,14,14,15, - 16,18,14,16,14,17,16,16,16,17,17,19,16,17,16,19, - 17,14,15,15,17,17,14,14,16,16,17,15,16,16,18,17, - 16,16,17,17,19,17,18,17,19,18,14,15,14,17,16,16, - 16,16,17,17,14,16,14,17,16,18,18,18,18,19,16,17, - 15,19,16,17,17,17,18,18,16,15,17,17,18,18,18,18, - 19,19,17,16,18,16,19,19,19,19,19,19,16,17,16,19, - 16,18,18,17,19,18,16,17,16,19,16,19,19,20,19,19, - 17,18,16,20,16, -}; - -static const static_codebook _44p6_p5_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p6_p5_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p6_p5_0, - 0 -}; - -static const long _vq_quantlist__44p6_p5_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p6_p5_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p6_p5_1 = { - 1, 7, - (char *)_vq_lengthlist__44p6_p5_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p6_p5_1, - 0 -}; - -static const long _vq_quantlist__44p6_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p6_p6_0[] = { - 1, 5, 5, 5, 7, 9, 5, 9, 7, 5, 7, 8, 7, 7,10, 9, - 10,10, 5, 8, 7, 9,10,10, 7,10, 7, 6, 9, 9, 9,10, - 12, 9,11,11, 9,10,11,11,11,13,12,13,13, 9,11,11, - 12,13,13,11,13,11, 6, 9, 9, 9,11,11, 9,12,10, 9, - 11,11,11,11,13,12,13,13, 9,11,10,12,13,13,11,13, - 11, 6, 9, 9, 9,11,12, 9,12,11, 9,10,11,10,10,13, - 12,13,13, 9,11,11,12,13,12,11,13,11, 7, 9,10, 9, - 10,12,10,12,11,10,10,12,10,10,12,12,12,13,10,11, - 11,12,12,13,10,12,10, 7,10,10,11,11,14,11,14,11, - 10,12,11,11,11,14,14,14,14,10,11,12,14,14,14,11, - 14,11, 6, 9, 9, 9,11,12, 9,12,11, 9,11,11,11,11, - 13,12,12,13, 9,11,10,12,13,13,10,13,10, 7,10,10, - 11,11,14,11,14,11,10,12,11,11,11,14,14,15,14,10, - 11,12,13,14,15,11,14,11, 7,10, 9,10,11,12, 9,12, - 10,10,11,11,10,10,12,12,13,12, 9,12,10,12,13,12, - 10,12,10, -}; - -static const static_codebook _44p6_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p6_p6_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p6_p6_0, - 0 -}; - -static const long _vq_quantlist__44p6_p6_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p6_p6_1[] = { - 2, 6, 6, 6, 7, 8, 6, 8, 7, 6, 7, 7, 7, 7, 8, 7, - 8, 8, 6, 7, 7, 7, 8, 8, 7, 8, 7, 6, 8, 8, 8, 9, - 9, 8, 9, 9, 8, 9, 9, 9, 9,10, 9,10,10, 8, 9, 9, - 9,10,10, 9,10, 9, 6, 8, 8, 8, 9, 9, 8, 9, 9, 8, - 9, 9, 9, 9,10, 9,10,10, 8, 9, 9, 9,10, 9, 9,10, - 9, 6, 8, 8, 8, 9, 9, 8, 9, 9, 8, 9, 9, 9, 9,10, - 9, 9,10, 8, 9, 9, 9,10, 9, 9,10, 9, 7, 8, 8, 8, - 9, 9, 8, 9, 9, 8, 8, 9, 9, 9, 9, 9, 9, 9, 8, 9, - 9, 9,10, 9, 9, 9, 9, 7, 9, 9, 9, 9,10, 9,10, 9, - 9, 9, 9, 9, 9,10,10,10,10, 9, 9, 9,10,10,10, 9, - 10, 9, 6, 8, 8, 8, 9, 9, 8, 9, 9, 8, 9, 9, 9, 9, - 10, 9,10,10, 8, 9, 9, 9,10, 9, 9,10, 9, 7, 9, 9, - 9, 9,10, 9,10, 9, 9, 9, 9, 9, 9,10,10,10,10, 9, - 9, 9,10,10,10, 9,10, 9, 7, 8, 8, 8, 9, 9, 8, 9, - 9, 8, 9, 9, 9, 9,10, 9, 9,10, 8, 9, 8, 9, 9, 9, - 9,10, 9, -}; - -static const static_codebook _44p6_p6_1 = { - 5, 243, - (char *)_vq_lengthlist__44p6_p6_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p6_p6_1, - 0 -}; - -static const long _vq_quantlist__44p6_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p6_p7_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p6_p7_0 = { - 5, 243, - (char *)_vq_lengthlist__44p6_p7_0, - 1, -513979392, 1633504256, 2, 0, - (long *)_vq_quantlist__44p6_p7_0, - 0 -}; - -static const long _vq_quantlist__44p6_p7_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p6_p7_1[] = { - 1, 4, 5, 5,10,10, 5,10,10, 5,10,10,10,10,10,10, - 10,10, 5,10,10,10,10,10,10,10,10, 7,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10, 6,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, 6,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10, 9,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10, 9,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10, 6,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10, 9,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, 9,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11, - 11,11,11, -}; - -static const static_codebook _44p6_p7_1 = { - 5, 243, - (char *)_vq_lengthlist__44p6_p7_1, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p6_p7_1, - 0 -}; - -static const long _vq_quantlist__44p6_p7_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p6_p7_2[] = { - 1, 2, 3, 4, 5, 7, 7, 8, 8, 9, 9,10,10,11,11,12, - 12,13,13,14,14,15,15,15,15, -}; - -static const static_codebook _44p6_p7_2 = { - 1, 25, - (char *)_vq_lengthlist__44p6_p7_2, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p6_p7_2, - 0 -}; - -static const long _vq_quantlist__44p6_p7_3[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p6_p7_3[] = { - 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p6_p7_3 = { - 1, 25, - (char *)_vq_lengthlist__44p6_p7_3, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p6_p7_3, - 0 -}; - -static const char _huff_lengthlist__44p6_short[] = { - 2, 8,13,15,16,18,21,22, 5, 4, 6, 8,10,12,17,21, - 9, 5, 5, 6, 8,11,15,19,11, 6, 5, 5, 6, 7,12,14, - 14, 8, 7, 5, 4, 4, 9,11,16,11, 9, 7, 4, 3, 7,10, - 22,15,14,12, 8, 7, 9,11,21,16,15,12, 9, 5, 6, 8, -}; - -static const static_codebook _huff_book__44p6_short = { - 2, 64, - (char *)_huff_lengthlist__44p6_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p7_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p7_l0_0[] = { - 2, 4, 4, 7, 7, 8, 8,10,10,11,11,12,12, 4, 5, 5, - 7, 7, 9, 9,11, 9,12,11,12,12, 4, 5, 5, 7, 7, 9, - 9, 9,10,10,11,12,12, 7, 7, 7, 7, 8, 9, 8,11, 5, - 12, 6,12,10, 7, 7, 7, 8, 7, 8, 9, 5,11, 6,12,10, - 12, 8, 9, 9, 9, 9,10,10,11, 7,11, 7,12, 9, 8, 9, - 8, 9, 9,10,10, 7,11, 7,11, 9,11,10,10,10,10,10, - 10,10,11,10,11, 8,11, 9,10,10,10,10,10,10,10,10, - 11, 8,10, 9,11,10,11,11,11,11,11,10,11,10,12,10, - 12,11,10,11,11,11,11,10,11,10,11,10,12,11,12,11, - 12,12,12,12,12,12,12,12,12,12,13,12,11,12,11,12, - 12,12,12,12,11,12,11,12,13, -}; - -static const static_codebook _44p7_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p7_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p7_l0_0, - 0 -}; - -static const long _vq_quantlist__44p7_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p7_l0_1[] = { - 4, 4, 4, 5, 5, 4, 4, 5, 5, 5, 4, 5, 4, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p7_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p7_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p7_l0_1, - 0 -}; - -static const long _vq_quantlist__44p7_l1_0[] = { - 54, - 29, - 79, - 0, - 108, -}; - -static const char _vq_lengthlist__44p7_l1_0[] = { - 1, 2, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44p7_l1_0 = { - 2, 25, - (char *)_vq_lengthlist__44p7_l1_0, - 1, -514516992, 1620639744, 7, 0, - (long *)_vq_quantlist__44p7_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p7_lfe[] = { - 2, 3, 1, 3, -}; - -static const static_codebook _huff_book__44p7_lfe = { - 2, 4, - (char *)_huff_lengthlist__44p7_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p7_long[] = { - 2, 7,14,16,17,17,18,20, 6, 3, 5, 8,10,11,13,15, - 13, 5, 3, 5, 8, 9,11,12,15, 7, 4, 3, 5, 7, 9,11, - 16,10, 7, 5, 6, 7, 9,10,17,11, 8, 7, 7, 6, 8, 8, - 19,13,11, 9, 9, 8, 8, 9,20,14,13,11,10, 8, 9, 9, -}; - -static const static_codebook _huff_book__44p7_long = { - 2, 64, - (char *)_huff_lengthlist__44p7_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p7_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p7_p1_0[] = { - 2, 5, 5, 4, 7, 7, 4, 7, 7, 5, 7, 7, 7, 8, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 7, 9, 8, 6, 7, 8, 8, 9, - 10, 8, 9,10, 8, 9,10,10,10,12,10,11,11, 8,10,10, - 10,11,12,10,11,11, 6, 8, 7, 8,10, 9, 8,10, 9, 8, - 10,10,10,11,11,10,12,11, 8,10, 9,10,11,11,10,12, - 10, 5, 8, 8, 8,10,10, 8,10,10, 7, 9,10, 9,10,11, - 9,11,11, 8,10,10,10,11,12,10,12,11, 7, 9, 9, 9, - 10,11, 9,11,11, 9, 9,11,10,11,12,11,11,12, 9,11, - 11,11,12,12,11,12,12, 7, 9, 9,10,11,11,10,12,11, - 9,11,10,11,11,12,11,13,12,10,11,11,12,13,13,11, - 13,11, 5, 8, 8, 8,10,10, 8,10,10, 8,10,10,10,11, - 12,10,12,11, 7,10, 9, 9,11,11, 9,11,10, 7, 9, 9, - 10,11,12,10,11,11,10,11,11,11,11,13,12,13,13, 9, - 10,11,11,12,13,11,12,11, 7, 9, 9, 9,11,11, 9,11, - 10, 9,11,11,11,12,12,11,12,12, 9,11, 9,11,12,11, - 10,12,11, -}; - -static const static_codebook _44p7_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p7_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p7_p1_0, - 0 -}; - -static const long _vq_quantlist__44p7_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p7_p2_0[] = { - 4, 6, 6, 9, 9, 6, 8, 8,10,10, 6, 8, 8,10,10, 8, - 10,10,12,13, 8,10,10,13,12, 6, 8, 8,10,10, 8, 8, - 9,10,11, 8, 9, 9,11,11,10,10,11,12,13,10,11,11, - 13,13, 6, 8, 8,10,10, 8, 9, 9,11,11, 8, 9, 8,11, - 10,10,11,11,13,13,10,11,10,13,12, 9,10,10,12,12, - 10,10,11,12,13,10,11,11,13,13,12,12,13,12,15,13, - 13,13,15,14, 9,10,10,12,12,10,11,11,13,13,10,11, - 10,13,12,12,13,13,14,15,12,13,12,15,12, 6, 8, 8, - 10,11, 8, 9,10,11,12, 8, 9, 9,11,11,10,11,12,13, - 14,10,11,11,13,13, 8, 9, 9,11,12, 9,10,11,12,13, - 9,10,10,12,13,11,12,13,13,15,11,12,12,14,14, 8, - 9, 9,11,12, 9,10,11,12,13, 9,10,10,13,12,11,12, - 13,14,15,11,12,12,14,13,10,11,12,13,14,11,12,13, - 13,15,12,13,13,14,14,13,13,14,14,16,14,15,14,16, - 15,10,12,11,14,13,12,12,13,14,14,11,12,12,14,14, - 14,14,15,15,16,13,14,14,16,14, 6, 8, 8,11,10, 8, - 9, 9,11,11, 8,10, 9,12,11,10,11,11,13,13,10,12, - 11,14,13, 8, 9, 9,12,11, 9,10,10,12,13, 9,11,10, - 13,12,11,12,12,14,14,11,13,12,15,14, 8, 9, 9,12, - 11, 9,10,10,13,12, 9,11,10,13,12,11,12,12,14,14, - 11,13,12,15,13,10,11,12,13,14,11,12,13,13,14,12, - 13,12,14,14,13,13,14,14,16,14,15,14,16,16,10,12, - 11,14,13,12,13,13,14,14,11,13,12,15,13,14,14,15, - 16,16,13,14,13,16,14, 9,10,11,12,13,11,11,12,13, - 14,11,11,12,13,14,13,13,14,14,16,13,14,14,15,15, - 11,11,12,13,14,12,12,13,13,15,12,13,13,14,15,14, - 14,15,15,17,14,14,15,16,16,11,12,12,13,14,12,12, - 13,14,15,12,13,12,14,15,14,14,15,15,17,14,15,14, - 16,16,13,14,14,15,16,14,14,15,15,17,14,15,15,16, - 16,15,16,17,16,18,16,17,16,17,17,13,14,14,16,15, - 14,15,15,16,16,14,15,14,16,15,16,16,17,17,18,16, - 16,16,17,16, 9,11,10,13,12,11,12,11,14,13,11,12, - 11,14,13,13,14,14,16,15,13,14,13,16,14,11,12,12, - 14,13,12,12,13,14,14,12,13,13,15,14,14,14,15,16, - 16,14,15,14,17,15,11,12,11,14,13,12,13,13,15,14, - 12,13,12,15,13,14,15,14,16,16,14,15,14,17,15,13, - 14,14,15,16,14,14,15,16,16,14,15,15,16,16,15,16, - 16,16,17,16,16,16,17,17,13,14,14,16,15,14,15,15, - 17,16,14,15,14,17,15,16,17,17,17,17,16,16,16,18, - 16, 6, 8, 8,11,11, 8, 9, 9,11,12, 8, 9, 9,12,11, - 10,11,11,13,14,10,11,11,14,13, 8, 9, 9,11,12, 9, - 10,10,12,13, 9,10,10,13,12,11,11,12,13,15,11,12, - 12,15,14, 8, 9, 9,12,11, 9,10,11,12,13, 9,11,10, - 13,12,11,12,12,14,15,11,13,12,15,14,10,11,11,13, - 14,11,12,12,13,14,11,12,12,14,14,13,13,14,14,16, - 13,14,14,16,15,11,12,11,14,13,12,13,13,14,14,11, - 13,12,14,13,14,14,15,16,16,13,14,14,16,14, 8, 9, - 9,11,12, 9,10,10,12,13, 9,10,10,13,12,11,12,12, - 14,15,11,12,12,14,14, 9, 9,10,11,13,10,10,12,12, - 14,10,10,11,13,13,12,12,13,14,16,12,12,13,15,15, - 9,10,10,13,12,10,11,11,13,14,10,12,11,14,13,12, - 13,13,15,15,12,13,13,15,15,11,11,12,13,15,12,12, - 13,13,15,12,13,13,14,15,14,14,15,15,17,14,15,15, - 16,16,11,13,12,15,14,13,13,13,15,15,12,14,13,15, - 14,15,15,15,16,16,14,15,15,17,15, 7, 9, 9,12,11, - 9,10,10,12,12, 9,11,10,13,12,11,12,12,14,14,11, - 13,12,15,14, 9,10,10,12,12,10,10,11,12,13,10,11, - 11,14,13,12,12,13,14,15,12,13,13,15,14, 9,10,10, - 12,12,10,11,11,13,13,10,11,10,14,12,12,13,13,15, - 15,12,13,12,15,13,11,12,12,14,14,12,12,13,14,15, - 12,13,13,15,15,14,13,14,13,16,14,15,15,16,16,11, - 12,12,14,14,13,13,14,15,15,12,13,12,15,14,15,15, - 15,16,16,14,15,14,17,14,10,11,12,13,14,11,12,13, - 14,15,11,12,12,14,15,13,14,15,15,17,14,14,14,16, - 16,11,12,13,12,15,12,12,14,13,16,13,13,14,13,16, - 14,14,15,14,17,15,15,15,15,17,11,13,12,15,15,13, - 13,14,15,16,12,14,13,16,15,15,15,15,17,17,15,15, - 15,17,16,14,14,15,14,16,14,14,16,14,17,15,15,15, - 14,17,16,16,17,15,18,17,17,17,16,18,14,15,15,17, - 16,15,16,16,17,17,15,16,15,17,16,17,17,17,18,18, - 16,17,16,18,17,10,11,11,14,13,11,12,12,14,14,11, - 13,12,15,14,14,14,14,16,16,14,15,14,16,15,11,12, - 12,15,13,12,13,13,15,14,13,14,13,16,14,14,15,15, - 16,16,15,16,15,17,16,11,13,12,15,14,13,13,14,15, - 15,12,14,13,16,14,15,15,15,17,17,14,16,15,17,16, - 14,14,14,16,15,14,15,15,16,16,15,16,15,17,16,16, - 16,16,16,17,16,17,17,18,17,14,15,15,16,16,15,15, - 16,17,16,14,15,15,17,16,17,17,17,18,18,16,17,16, - 18,16, 6, 8, 8,11,11, 8, 9, 9,11,12, 8, 9, 9,12, - 11,10,11,12,13,14,10,11,11,14,13, 8, 9, 9,11,12, - 9,10,11,12,13, 9,11,10,13,12,11,12,13,14,15,11, - 12,12,15,14, 8, 9, 9,12,11, 9,10,10,12,13, 9,10, - 10,13,12,11,12,12,14,15,11,12,12,14,13,11,11,12, - 13,14,11,12,13,13,15,12,13,13,14,14,13,14,14,14, - 16,14,15,14,16,16,10,11,11,14,13,11,12,12,14,14, - 11,12,12,14,13,13,14,14,15,16,13,14,13,16,14, 7, - 9, 9,11,11, 9,10,11,12,13, 9,10,10,12,12,11,12, - 13,14,15,11,12,12,14,14, 9,10,10,12,12,10,10,11, - 12,13,10,11,11,13,13,12,12,13,13,15,12,13,13,15, - 15, 9,10,10,12,12,10,11,11,13,13,10,11,10,13,12, - 12,13,13,14,15,12,13,12,15,13,11,12,12,14,14,12, - 12,13,14,15,13,14,13,15,15,14,13,15,13,16,15,15, - 15,16,16,11,12,12,14,14,12,13,13,14,15,12,13,12, - 15,14,14,15,15,16,17,13,14,13,16,13, 8, 9, 9,12, - 11, 9,10,10,12,13, 9,10,10,13,12,11,12,12,14,15, - 11,12,12,15,14, 9,10,10,12,13,10,11,12,13,14,10, - 11,11,14,13,12,13,13,15,15,12,13,13,15,15, 9,10, - 9,13,11,10,11,10,13,13,10,12,10,14,12,12,13,12, - 15,15,12,13,12,15,14,11,12,13,14,15,12,13,14,14, - 15,13,13,13,15,15,14,15,15,15,17,15,15,15,16,16, - 11,12,11,15,13,12,13,13,15,14,12,13,12,16,13,14, - 15,15,16,16,14,15,14,17,14,10,11,11,13,14,11,12, - 13,14,15,11,12,12,14,14,14,14,15,15,17,14,14,14, - 15,16,11,12,13,14,15,12,13,14,14,16,13,14,13,15, - 15,14,15,16,15,17,15,15,15,17,17,11,12,12,13,15, - 13,13,14,14,16,12,13,13,14,15,15,15,15,16,17,14, - 15,15,16,16,14,15,15,16,16,14,15,15,16,17,15,15, - 16,16,17,16,16,17,16,18,17,17,17,18,18,14,14,15, - 15,16,15,15,15,16,17,14,15,15,16,16,16,17,17,17, - 18,16,16,16,17,16,10,11,11,14,13,11,13,12,15,14, - 11,13,12,15,14,14,15,14,16,16,13,15,14,17,15,11, - 12,13,15,15,12,13,14,15,16,13,14,13,16,15,15,15, - 15,16,17,15,15,15,17,16,11,13,11,15,12,13,14,13, - 16,13,12,14,12,16,13,15,15,15,17,15,14,16,14,17, - 14,14,15,15,16,17,15,15,16,16,17,15,16,15,17,17, - 16,16,17,17,18,16,17,17,18,18,14,15,14,17,13,15, - 16,15,17,15,15,16,15,17,14,16,17,16,18,16,16,17, - 16,18,15, 9,11,11,13,13,10,12,12,14,14,11,12,12, - 14,14,13,14,14,15,16,13,14,14,16,16,10,11,12,14, - 14,11,12,13,14,15,11,13,13,15,15,13,14,14,15,16, - 14,15,15,16,16,11,12,12,14,14,12,13,13,15,15,12, - 13,12,15,14,14,15,15,16,16,14,15,14,17,16,12,13, - 13,15,16,13,13,14,15,16,13,14,14,16,16,14,15,16, - 16,17,15,16,16,17,17,13,14,14,16,15,14,15,15,17, - 16,14,15,14,17,15,16,16,17,17,17,16,16,16,18,16, - 10,11,12,14,14,11,12,13,14,15,11,13,12,15,15,13, - 14,15,16,16,14,15,15,17,16,11,11,13,14,15,12,12, - 14,14,16,12,13,14,15,15,14,14,15,16,17,15,15,15, - 17,17,12,13,12,15,15,13,14,14,16,15,13,14,13,16, - 15,15,16,15,17,17,15,16,15,17,16,13,12,15,14,16, - 14,13,15,14,17,14,13,15,15,17,15,14,17,15,18,16, - 15,17,17,18,14,15,15,17,16,15,16,16,17,17,15,16, - 15,17,16,16,17,17,18,18,16,17,16,18,17,10,11,11, - 14,14,11,12,12,14,15,11,13,12,15,14,13,14,14,16, - 16,14,15,14,16,16,11,12,12,14,14,12,12,13,15,15, - 12,13,13,15,15,14,14,15,16,16,14,15,15,17,16,11, - 12,12,15,15,13,13,13,15,15,12,13,13,15,15,15,15, - 15,17,17,14,15,15,17,16,13,14,13,16,15,14,14,14, - 16,16,14,15,14,17,16,15,15,16,16,17,16,17,16,18, - 17,14,15,15,16,16,15,15,15,17,17,14,15,15,17,16, - 16,17,17,18,18,16,17,16,18,16,12,13,13,15,15,13, - 14,14,16,16,13,14,14,16,16,14,15,16,16,18,15,16, - 16,17,17,13,13,14,14,16,14,14,15,15,17,14,14,15, - 15,17,15,15,17,15,18,16,16,17,17,18,13,14,14,16, - 16,14,15,15,16,17,14,15,15,17,16,16,17,16,17,18, - 16,17,16,18,17,15,14,16,13,18,16,15,17,14,18,16, - 15,17,14,18,17,16,18,15,19,17,17,18,16,19,15,16, - 16,17,17,16,17,17,18,18,16,17,16,18,17,18,18,18, - 19,18,17,18,17,19,17,11,12,12,15,15,13,13,14,15, - 16,13,14,13,16,15,15,15,15,16,17,15,16,15,17,16, - 12,13,13,15,15,13,13,14,15,16,14,15,14,16,15,15, - 15,16,16,17,16,16,16,18,17,12,13,13,15,15,14,14, - 15,16,16,13,14,13,16,15,16,16,16,17,17,15,16,15, - 18,16,15,15,15,17,15,14,15,15,16,16,16,17,16,17, - 16,16,16,17,16,17,17,18,17,19,18,15,15,16,17,17, - 16,16,16,17,17,15,16,15,17,16,17,18,18,18,18,16, - 17,16,18,16, 9,11,11,13,13,11,12,12,14,14,10,12, - 12,14,14,13,14,14,15,16,13,14,14,16,15,11,12,12, - 14,14,12,12,13,14,15,12,13,13,15,15,14,14,15,16, - 17,14,15,15,16,16,10,12,11,14,14,11,13,13,15,15, - 11,13,12,15,14,14,14,15,16,16,13,14,14,16,15,13, - 14,14,15,16,14,14,15,15,17,14,15,15,16,17,16,16, - 16,16,18,16,16,17,17,17,12,13,13,16,15,13,14,14, - 16,16,12,14,13,16,15,15,16,16,17,17,14,16,15,17, - 16,10,11,11,14,14,11,12,13,14,15,11,12,12,15,14, - 14,14,15,16,16,13,14,14,16,16,11,12,12,14,15,12, - 13,14,15,15,13,13,13,15,15,14,15,15,16,17,15,15, - 15,16,17,11,12,12,14,14,12,13,13,15,15,12,13,12, - 15,15,14,15,15,16,17,14,15,14,16,16,14,14,15,16, - 16,14,15,15,16,17,15,16,15,17,17,16,16,17,16,18, - 16,17,17,18,18,13,13,14,15,16,14,14,15,16,17,14, - 14,14,16,15,16,16,17,17,18,15,16,15,17,16,10,12, - 11,14,14,11,13,13,15,15,11,13,12,15,15,14,15,15, - 16,16,13,15,14,16,16,12,12,13,15,15,13,13,14,15, - 16,13,14,14,16,15,15,15,16,16,17,15,15,15,17,17, - 11,13,11,15,14,12,14,13,16,15,12,14,12,16,14,15, - 15,15,17,17,14,15,14,17,15,14,15,15,16,17,15,15, - 16,16,17,15,16,16,17,17,16,16,17,17,18,16,17,17, - 18,18,13,14,12,16,14,14,15,13,17,15,14,15,13,17, - 14,16,17,15,18,17,15,17,14,18,15,11,12,12,14,15, - 13,13,14,15,16,13,14,13,16,15,15,15,16,16,17,15, - 15,15,16,16,12,13,13,15,15,13,13,14,15,16,14,15, - 14,16,16,15,15,16,16,18,16,16,16,18,17,12,13,13, - 15,15,14,14,15,15,16,13,14,13,15,15,16,16,16,17, - 18,15,16,15,17,16,15,16,15,17,16,15,15,16,16,17, - 16,17,16,17,17,16,16,17,16,18,17,18,18,18,18,14, - 15,15,15,17,16,15,17,16,17,14,15,15,16,16,17,17, - 18,18,19,16,16,16,17,16,12,13,13,15,15,13,14,14, - 16,16,13,14,14,16,16,15,16,16,17,17,15,16,15,18, - 16,13,14,14,16,16,14,15,15,16,17,14,15,15,17,16, - 16,16,17,17,18,16,17,16,18,18,13,14,13,16,14,14, - 15,14,17,15,14,15,14,17,14,16,17,16,18,17,15,17, - 15,18,15,15,16,16,17,18,16,16,17,17,18,16,17,17, - 17,18,17,17,18,18,19,17,18,18,19,18,15,16,14,17, - 13,16,17,15,18,14,16,17,15,18,14,18,18,17,19,16, - 17,18,16,19,15, -}; - -static const static_codebook _44p7_p2_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p7_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p7_p2_0, - 0 -}; - -static const long _vq_quantlist__44p7_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p7_p3_0[] = { - 2, 5, 5, 4, 7, 7, 4, 7, 7, 5, 7, 8, 7, 8,10, 8, - 9, 9, 5, 7, 7, 8, 9, 9, 7,10, 8, 5, 7, 8, 8, 9, - 10, 8,10,10, 8, 9,10,10,10,12,10,12,12, 8,10,10, - 10,12,12,10,12,11, 5, 8, 7, 8,10,10, 8,10, 9, 8, - 10,10,10,11,12,10,12,12, 8,10, 9,10,12,12,10,12, - 10, 5, 8, 8, 7,10,10, 8,10,10, 7, 9,10, 9,10,12, - 10,12,12, 8,10,10,10,12,12,10,12,11, 7, 9,10, 9, - 11,12,10,12,11, 9, 9,12,11,10,14,12,12,13,10,12, - 11,12,13,13,11,14,12, 7,10, 9,10,11,11,10,12,11, - 9,11,11,11,11,13,12,14,13,10,12,12,12,14,14,11, - 14,12, 5, 8, 8, 8,10,10, 7,10,10, 8,10,10,10,11, - 12,10,12,12, 7,10, 9,10,12,12, 9,12,10, 7, 9,10, - 10,11,12,10,11,11,10,12,12,11,12,14,12,14,14, 9, - 11,11,12,13,14,11,13,11, 7,10, 9,10,11,12, 9,12, - 11,10,11,12,11,12,14,12,13,13, 9,12, 9,12,13,12, - 11,14,10, -}; - -static const static_codebook _44p7_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p7_p3_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p7_p3_0, - 0 -}; - -static const long _vq_quantlist__44p7_p3_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p7_p3_1[] = { - 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 8, 8, 7, - 8, 8, 7, 8, 7, 7, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 9, 8, 8, 8, - 8, 8, 8, 8, 9, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 9, - 8, 7, 8, 8, 7, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 9, 8, 7, 8, 8, 8, - 8, 9, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, - 8, 9, 9, 9, 8, 9, 9, 7, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, - 9, 8, 7, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, - 9, 8, 8, 9, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, - 8, 8, 8, 9, 9, 8, 9, 8, 7, 8, 8, 8, 8, 8, 8, 9, - 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 8, 8, 8, 8, 9, 9, - 8, 9, 8, -}; - -static const static_codebook _44p7_p3_1 = { - 5, 243, - (char *)_vq_lengthlist__44p7_p3_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p7_p3_1, - 0 -}; - -static const long _vq_quantlist__44p7_p4_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p7_p4_0[] = { - 1, 5, 5, 5, 7, 8, 5, 8, 7, 5, 7, 8, 7, 8,10, 8, - 10,10, 5, 8, 7, 8,10,10, 7,10, 8, 6, 8, 9, 9,10, - 12, 9,11,11, 9,10,11,11,11,13,11,13,13, 9,11,11, - 11,12,13,11,13,11, 6, 9, 8, 9,11,11, 9,12,10, 9, - 11,11,11,11,13,11,13,13, 9,11,10,11,13,13,11,13, - 11, 6, 9, 9, 8,10,11, 9,12,11, 8,10,11,10,11,13, - 11,13,13, 9,11,11,11,13,12,11,13,11, 8,10,10, 9, - 11,12,10,12,12,10,10,12,11,11,14,12,13,14,10,12, - 12,12,13,13,11,14,11, 8,11,10,11,12,13,11,14,12, - 10,12,11,11,12,14,13,15,14,10,12,12,13,14,15,12, - 14,12, 5, 9, 9, 9,11,12, 8,11,10, 9,11,11,11,11, - 13,11,12,13, 8,11,10,11,13,13,10,13,11, 8,10,11, - 11,12,14,11,13,12,10,12,12,12,12,14,14,15,14,10, - 11,12,13,14,15,11,14,12, 8,10,10,10,12,12, 9,12, - 11,10,12,12,11,11,14,12,13,13,10,12,10,12,14,13, - 11,13,11, -}; - -static const static_codebook _44p7_p4_0 = { - 5, 243, - (char *)_vq_lengthlist__44p7_p4_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p7_p4_0, - 0 -}; - -static const long _vq_quantlist__44p7_p4_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p7_p4_1[] = { - 7, 8, 8,10,10, 8, 9, 9,10,11, 8, 9, 9,10,10, 9, - 10,10,11,11, 9,10,10,11,11, 8, 9, 9,10,10, 9, 9, - 10,11,11, 9,10,10,11,11,10,10,11,11,11,10,11,11, - 11,11, 8, 9, 9,10,10, 9,10,10,11,11, 9,10, 9,11, - 11,10,11,11,11,11,10,11,10,11,11,10,10,10,11,11, - 10,11,11,11,11,10,11,11,11,11,11,11,11,11,12,11, - 11,11,11,12,10,10,10,11,11,10,11,11,11,11,10,11, - 11,11,11,11,11,11,12,11,11,11,11,12,11, 8, 9,10, - 11,11, 9,10,11,11,11, 9,10,10,11,11,10,11,11,12, - 12,10,11,11,12,12,10,10,10,11,11,10,10,11,11,12, - 10,11,11,12,12,11,11,12,12,12,11,11,12,12,12,10, - 10,10,11,11,10,11,11,12,12,10,11,11,12,11,11,12, - 12,12,12,11,12,11,12,12,11,11,11,11,12,11,11,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,11,11,11,12,12,11,12,12,12,12,11,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12, 8,10, 9,11,11, 9, - 10,10,11,11, 9,10,10,11,11,10,11,11,12,12,10,11, - 11,12,12,10,10,10,11,11,10,11,11,12,12,10,11,11, - 12,12,11,11,12,12,12,11,12,12,12,12,10,10,10,11, - 11,10,11,11,12,12,10,11,10,12,11,11,12,11,12,12, - 11,12,11,12,12,11,11,11,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11, - 11,12,11,11,12,12,12,12,11,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,10,11,11,11,12,11,11,12,12, - 12,11,11,11,12,12,11,12,12,12,12,11,12,12,12,12, - 11,11,12,12,12,11,12,12,12,12,12,12,12,12,12,12, - 12,13,12,13,12,12,12,13,13,11,12,11,12,12,11,12, - 12,12,12,11,12,12,12,12,12,12,12,13,13,12,12,12, - 13,13,12,12,12,12,12,12,12,12,12,13,12,12,13,13, - 13,12,13,13,13,13,12,13,13,13,13,12,12,12,12,12, - 12,12,13,13,13,12,12,12,13,12,12,13,13,13,13,12, - 13,13,13,13,10,11,11,12,11,11,11,11,12,12,11,12, - 11,12,12,11,12,12,12,12,11,12,12,12,12,11,11,11, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,13, - 13,12,12,12,13,13,11,12,11,12,12,12,12,12,12,12, - 11,12,11,12,12,12,12,12,13,13,12,12,12,13,12,12, - 12,12,12,12,12,12,12,13,13,12,12,12,13,13,12,13, - 13,13,13,12,13,13,13,13,12,12,12,12,12,12,12,12, - 13,13,12,13,12,13,12,12,13,13,13,13,13,13,13,13, - 13, 8,10,10,11,11, 9,10,10,11,11, 9,10,10,11,11, - 10,11,11,12,12,10,11,11,12,12, 9,10,10,11,11,10, - 10,11,11,12,10,11,11,12,12,11,11,12,12,12,11,11, - 12,12,12,10,10,10,11,11,10,11,11,12,12,10,11,10, - 12,11,11,12,11,12,12,11,12,11,12,12,11,11,11,12, - 12,11,11,12,12,12,11,12,12,12,12,11,12,12,12,12, - 12,12,12,12,12,11,11,11,12,11,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12, 9,10, - 10,11,11,10,11,11,11,12,10,11,11,12,12,11,11,11, - 12,12,11,11,11,12,12,10,10,11,11,12,11,11,12,12, - 12,11,11,11,12,12,11,11,12,12,12,11,12,12,12,12, - 10,11,11,12,12,11,11,11,12,12,11,12,11,12,12,11, - 12,12,12,12,11,12,12,12,12,11,11,12,12,12,11,12, - 12,12,12,12,12,12,12,12,12,12,12,12,13,12,12,12, - 12,13,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,13,12, 9,10,10,11,11, - 10,11,11,12,12,10,11,11,12,11,11,12,11,12,12,11, - 12,11,12,12,10,11,11,12,12,11,11,11,12,12,11,12, - 11,12,12,11,12,12,12,12,12,12,12,12,12,10,11,11, - 12,12,11,12,11,12,12,11,12,11,12,12,12,12,12,13, - 12,12,12,12,12,12,11,12,11,12,12,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,13,12,12,12,12,13,11, - 12,12,12,12,12,12,12,13,12,11,12,12,12,12,12,12, - 12,13,12,12,12,12,13,12,10,11,11,12,12,11,12,12, - 12,12,11,12,12,12,12,12,12,12,12,13,12,12,12,13, - 13,11,11,12,12,12,12,12,12,12,13,12,12,12,12,12, - 12,12,13,12,13,12,12,13,13,13,11,12,12,12,12,12, - 12,12,13,13,12,12,12,13,12,12,13,12,13,13,12,13, - 12,13,13,12,12,12,12,12,12,12,13,12,13,12,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,12,12,12,13, - 13,12,13,13,13,13,12,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,10,11,11,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,13,13,12,12,12,13,13,11,12, - 12,12,12,12,12,12,12,13,12,12,12,13,12,12,12,13, - 13,13,12,13,13,13,13,11,12,12,12,12,12,12,12,13, - 13,12,12,12,13,12,12,13,13,13,13,12,13,12,13,13, - 12,12,12,12,12,12,13,13,13,13,12,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,12,12,12,13,12,12,13, - 13,13,13,12,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13, 8,10,10,11,11, 9,10,10,11,11, 9,10,10,11, - 11,10,11,11,12,12,10,11,11,12,12,10,10,10,11,11, - 10,11,11,11,12,10,11,11,12,12,11,11,12,12,12,11, - 11,12,12,12, 9,10,10,11,11,10,11,11,12,12,10,11, - 10,12,11,11,12,11,12,12,11,12,11,12,12,11,11,11, - 12,12,11,11,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,11,11,11,12,11,11,12,12,12,12, - 11,12,11,12,12,12,12,12,12,12,12,12,12,12,12, 9, - 10,10,11,11,10,11,11,12,12,10,11,11,12,12,11,11, - 12,12,12,11,12,12,12,12,10,11,11,12,12,11,11,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,10,11,11,12,12,11,11,12,12,12,11,11,11,12,12, - 12,12,12,12,12,11,12,12,12,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,13,12,13,12,12, - 12,13,12,11,12,12,12,12,12,12,12,12,12,11,12,12, - 12,12,12,12,12,13,12,12,12,12,13,12, 9,10,10,11, - 11,10,11,11,12,12,10,11,11,12,12,11,11,11,12,12, - 11,12,11,12,12,10,11,11,12,12,11,11,12,12,12,11, - 11,11,12,12,11,12,12,12,12,11,12,12,12,12,10,11, - 10,12,11,11,11,11,12,12,11,12,11,12,12,11,12,12, - 12,12,11,12,11,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,13,12,12,12,12,13, - 11,12,11,12,12,12,12,12,12,12,11,12,12,12,12,12, - 12,12,13,12,12,12,12,13,12,10,11,11,12,12,11,12, - 12,12,12,11,12,12,12,12,12,12,12,13,13,12,12,12, - 13,13,11,12,12,12,12,12,12,12,12,13,12,12,12,13, - 13,12,12,13,13,13,12,13,13,13,13,11,12,12,12,12, - 12,12,12,12,13,12,12,12,12,12,12,13,13,13,13,12, - 13,12,13,13,12,12,12,12,13,12,13,13,13,13,12,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,12, - 12,12,12,13,13,13,13,12,13,12,13,13,13,13,13,13, - 13,13,13,13,13,13,11,11,11,12,12,11,12,12,12,12, - 11,12,12,12,12,12,12,12,13,13,12,12,12,13,12,11, - 12,12,12,12,12,12,12,13,13,12,12,12,13,13,12,12, - 13,13,13,12,13,13,13,13,11,12,11,12,12,12,12,12, - 13,12,12,12,12,13,12,12,13,12,13,13,12,13,12,13, - 12,12,12,12,12,13,12,12,13,13,13,12,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12, - 13,13,13,13,12,13,12,13,12,13,13,13,13,13,13,13, - 13,13,13,10,11,11,12,12,10,11,11,12,12,10,11,11, - 12,12,11,12,12,12,12,11,12,12,12,12,11,11,11,12, - 12,11,11,12,12,12,11,12,12,12,12,12,12,12,13,13, - 12,12,12,13,13,11,11,11,12,12,11,12,12,12,12,11, - 12,11,13,12,12,12,12,13,13,12,12,12,13,13,11,12, - 12,12,12,12,12,12,12,13,12,12,12,13,13,12,12,13, - 13,13,12,13,12,13,13,11,12,12,12,12,12,12,12,13, - 12,12,12,12,13,12,12,13,13,13,13,12,13,13,13,13, - 10,11,11,12,12,11,12,12,12,12,11,12,12,12,12,12, - 12,12,13,13,12,12,12,13,13,11,11,12,12,12,11,12, - 12,12,13,12,12,12,13,13,12,12,13,13,13,12,12,13, - 13,13,11,12,12,12,12,12,12,12,13,13,12,12,12,13, - 13,12,13,13,13,13,12,13,12,13,13,12,12,12,12,13, - 12,12,13,12,13,12,12,13,13,13,12,12,13,13,13,12, - 13,13,13,13,12,12,12,12,13,12,12,13,13,13,12,12, - 12,13,13,13,13,13,13,13,12,13,13,13,13,10,11,11, - 12,12,11,12,12,12,12,11,12,12,12,12,12,12,12,13, - 13,12,12,12,13,13,11,12,12,12,12,11,12,12,12,13, - 12,12,12,13,13,12,12,13,13,13,12,13,13,13,13,11, - 12,12,12,12,12,12,12,13,13,12,12,12,13,12,12,13, - 12,13,13,12,13,12,13,13,12,12,12,12,12,12,12,12, - 13,13,12,13,12,13,13,12,13,13,13,13,13,13,13,13, - 13,12,12,12,13,12,12,13,13,13,13,12,13,12,13,13, - 13,13,13,13,13,13,13,13,13,13,11,11,11,12,12,11, - 12,12,12,12,11,12,12,12,12,12,12,12,13,13,12,12, - 12,13,13,11,12,12,12,12,12,12,12,12,13,12,12,12, - 13,13,12,12,13,13,13,12,12,13,13,13,11,12,12,12, - 12,12,12,12,13,13,12,12,12,13,13,12,13,13,13,13, - 12,13,12,13,13,12,12,12,12,12,12,12,13,12,13,12, - 13,13,13,13,12,13,13,12,13,13,13,13,13,13,12,12, - 12,12,12,12,13,13,13,13,12,13,12,13,13,13,13,13, - 13,13,13,13,13,13,13,10,11,11,12,12,11,12,12,12, - 13,11,12,12,13,12,12,12,12,13,13,12,12,12,13,13, - 11,12,12,12,12,12,12,12,13,13,12,13,12,13,13,12, - 12,13,13,13,12,13,13,13,13,11,12,12,12,13,12,12, - 12,13,13,12,12,12,13,12,12,13,13,13,13,12,13,12, - 13,13,12,12,12,12,12,12,12,13,13,13,12,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,12,12,12,13,12, - 12,13,13,13,13,12,13,12,13,13,13,13,13,13,13,13, - 13,13,13,13,10,11,11,12,12,10,11,11,12,12,10,11, - 11,12,12,11,12,12,12,12,11,12,12,12,12,11,11,11, - 12,12,11,11,12,12,13,11,12,12,12,12,12,12,12,13, - 13,12,12,12,13,13,10,11,11,12,12,11,12,12,12,12, - 11,12,11,12,12,12,12,12,13,13,12,12,12,13,12,11, - 12,12,12,12,12,12,12,12,13,12,12,12,13,13,12,12, - 13,13,13,12,13,13,13,13,11,12,12,12,12,12,12,12, - 13,13,12,12,12,13,12,12,13,13,13,13,12,13,12,13, - 13,10,11,11,12,12,11,12,12,12,12,11,12,12,12,12, - 12,12,12,13,13,12,12,12,13,13,11,12,12,12,12,12, - 12,12,12,13,12,12,12,13,13,12,12,13,13,13,12,12, - 13,13,13,11,12,12,12,12,12,12,12,13,13,11,12,12, - 13,12,12,13,13,13,13,12,13,12,13,13,12,12,12,12, - 13,12,12,13,13,13,12,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,12,12,12,13,12,12,12,13,13,13,12, - 12,12,13,13,13,13,13,13,13,12,13,13,13,13,10,11, - 11,12,12,11,12,12,12,12,11,12,12,12,12,12,12,12, - 13,13,12,12,12,13,13,11,12,12,12,12,12,12,12,12, - 13,12,12,12,13,13,12,12,13,13,13,12,12,13,13,13, - 11,12,11,12,12,12,12,12,13,13,11,12,12,13,12,12, - 13,12,13,13,12,13,12,13,13,12,12,12,12,12,12,12, - 13,13,13,12,13,12,13,13,12,13,13,13,13,13,13,13, - 13,13,12,12,12,13,12,12,13,12,13,13,12,13,12,13, - 13,13,13,13,13,13,12,13,12,13,13,10,11,11,12,12, - 11,12,12,12,12,11,12,12,13,12,12,12,12,13,13,12, - 12,12,13,13,11,12,12,12,12,12,12,12,12,13,12,12, - 12,13,13,12,12,13,13,13,12,13,13,13,13,11,12,12, - 12,12,12,12,12,13,13,12,12,12,13,12,12,13,13,13, - 13,12,13,12,13,13,12,12,12,12,13,12,12,13,13,13, - 12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,12, - 12,12,12,12,12,13,13,13,13,12,13,12,13,13,13,13, - 13,13,13,13,13,13,13,13,11,11,11,12,12,11,12,12, - 12,12,11,12,12,12,12,12,12,12,13,13,12,12,12,13, - 13,11,12,12,12,12,12,12,12,13,13,12,12,12,13,13, - 12,12,13,13,13,12,13,13,13,13,11,12,12,12,12,12, - 12,12,13,13,12,12,12,13,12,12,13,12,13,13,12,13, - 12,13,13,12,12,12,12,12,12,13,13,13,13,12,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,12,12,12,12, - 12,12,13,13,13,13,12,13,12,13,12,13,13,13,13,13, - 13,13,13,13,12, -}; - -static const static_codebook _44p7_p4_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p7_p4_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p7_p4_1, - 0 -}; - -static const long _vq_quantlist__44p7_p5_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p7_p5_0[] = { - 2, 6, 6, 9, 9, 5, 7, 8,10,11, 5, 8, 7,11,10, 8, - 10,11,12,13, 8,11,10,13,12, 6, 7, 8,10,11, 7, 8, - 10,10,12, 8, 9, 9,12,11,10,10,12,11,14,10,11,12, - 14,13, 6, 8, 7,11,10, 8, 9, 9,11,12, 7,10, 8,12, - 10,10,12,12,13,14,10,12,10,14,11, 9,10,11,11,12, - 10,10,11,11,13,11,12,12,13,13,12,11,13,11,15,13, - 14,13,14,14, 9,11,10,12,11,11,12,12,13,13,10,11, - 10,13,11,13,13,14,14,14,12,13,11,14,11, 7, 8, 9, - 11,12, 9, 9,11,12,13, 9,10,10,13,12,11,12,13,13, - 15,11,12,12,14,14, 9,10,10,12,13,10,10,12,12,14, - 11,11,11,13,13,12,12,13,13,15,12,13,13,15,14, 9, - 10,10,12,13,10,11,11,13,14,10,12,11,14,13,12,13, - 13,14,15,12,13,13,15,14,12,12,13,13,14,12,13,13, - 13,15,13,14,14,14,15,14,14,15,14,16,14,15,15,16, - 16,12,13,13,14,14,13,13,14,15,14,12,13,13,15,14, - 14,15,15,15,16,14,15,14,16,14, 7, 9, 8,12,11, 9, - 10,10,12,13, 9,11, 9,13,12,11,12,12,14,14,11,13, - 12,15,13, 9,10,10,13,12,10,11,12,13,14,10,12,11, - 14,13,12,13,13,14,15,13,13,13,15,14, 9,10,10,13, - 12,11,11,11,13,13,10,12,10,14,12,13,13,13,14,15, - 12,13,12,15,13,12,13,13,14,14,12,13,13,14,15,13, - 14,13,15,15,14,14,15,14,16,14,15,15,16,15,12,13, - 12,14,13,13,13,13,15,14,12,13,13,15,13,14,15,15, - 16,15,14,15,14,16,14,11,12,12,13,14,12,13,14,14, - 15,12,13,13,14,15,14,14,15,15,16,14,15,15,16,16, - 12,13,13,14,15,13,13,14,14,16,13,14,14,15,15,15, - 15,16,15,17,15,15,15,16,16,12,13,13,14,15,13,14, - 14,15,16,13,14,14,15,15,15,15,16,16,17,15,15,15, - 17,16,14,15,15,16,16,15,15,16,15,16,15,16,16,16, - 17,16,16,17,16,18,16,16,17,18,17,14,15,15,16,16, - 15,16,16,16,17,15,16,15,17,16,16,17,17,17,18,16, - 16,16,17,16,11,12,12,14,13,12,13,13,15,14,12,14, - 13,15,14,14,15,15,16,16,14,15,14,16,15,12,13,13, - 15,14,13,14,14,15,15,13,14,14,16,15,15,15,15,16, - 16,15,16,15,17,16,12,13,13,15,14,13,14,14,15,15, - 13,14,13,16,14,15,15,15,16,16,15,15,15,17,15,14, - 15,15,16,16,15,15,15,16,16,15,16,16,17,17,16,16, - 17,17,17,16,17,17,18,17,14,15,15,16,15,15,15,16, - 16,16,15,15,15,17,15,17,17,17,18,17,16,17,16,18, - 16, 6, 9, 9,12,12, 8,10,10,12,13, 9,11,10,13,12, - 10,12,12,14,14,11,13,12,14,14, 8,10,10,12,12, 9, - 10,11,12,14,10,11,11,13,13,12,12,13,13,15,12,13, - 13,15,14, 9,10,10,13,13,10,11,11,13,13,10,12,10, - 14,13,12,13,13,14,15,12,13,13,15,14,11,12,12,13, - 14,12,12,13,13,15,12,13,13,14,14,13,13,14,13,16, - 14,15,15,16,15,11,12,12,14,14,13,13,13,15,14,12, - 13,13,15,14,14,15,15,16,15,14,14,14,16,14, 7, 9, - 10,12,12, 9,10,11,13,13, 9,11,10,13,13,11,12,13, - 14,15,12,13,13,15,14, 9,10,11,12,13,10,10,12,13, - 14,11,11,12,14,14,12,12,14,14,15,13,13,13,15,15, - 9,11,11,13,13,11,12,12,14,14,10,12,10,14,13,13, - 14,13,15,15,12,14,13,15,14,12,12,13,13,15,12,12, - 14,13,15,13,14,14,15,15,14,14,15,14,17,14,15,15, - 16,16,12,13,13,15,14,13,14,14,15,15,12,14,13,15, - 14,14,15,15,16,16,14,15,14,16,14, 7,10,10,12,12, - 10,11,11,12,13,10,12,10,14,12,12,13,13,14,15,12, - 13,13,15,14, 9,11,10,13,12,10,10,12,12,14,11,13, - 12,14,13,13,13,14,13,15,13,14,14,15,14,10,11,11, - 13,13,12,12,12,13,14,10,12,10,14,12,13,14,14,15, - 15,13,14,13,15,13,12,13,13,14,14,12,12,13,14,15, - 13,14,14,15,15,13,13,14,13,15,14,15,15,16,16,12, - 13,13,14,14,13,14,14,15,15,12,13,13,15,13,15,15, - 15,16,16,13,14,13,16,13,11,12,13,14,14,12,13,14, - 14,15,12,13,13,15,15,14,14,15,15,17,14,15,15,16, - 16,12,13,14,14,15,13,13,14,14,16,13,14,14,15,16, - 14,14,16,15,17,15,15,16,16,16,12,13,13,15,15,13, - 14,14,15,16,13,14,14,15,16,15,15,16,17,17,15,16, - 15,17,16,14,15,15,15,16,15,15,16,15,17,15,15,16, - 16,17,16,16,16,16,18,16,16,17,17,17,14,15,15,16, - 16,15,16,16,16,17,15,16,15,17,16,16,17,17,17,17, - 16,17,16,18,17,11,12,12,14,14,13,13,14,14,15,13, - 14,13,15,14,14,15,15,15,16,14,15,15,17,15,12,13, - 13,15,14,13,13,14,15,15,14,15,14,16,15,15,15,15, - 15,16,15,16,15,17,16,12,13,13,15,15,14,14,14,15, - 16,13,14,13,16,15,15,15,16,16,17,15,16,15,17,15, - 14,15,15,16,16,14,15,15,16,16,15,16,16,17,16,15, - 15,16,15,17,16,17,17,18,17,14,15,15,16,16,15,16, - 16,16,17,14,15,15,17,16,17,17,17,17,18,15,16,16, - 18,15, 6, 9, 9,12,12, 9,10,11,12,13, 8,10,10,13, - 12,11,12,13,14,14,10,12,12,14,13, 9,10,10,12,13, - 10,10,12,13,14,10,11,11,13,13,12,13,13,14,15,12, - 13,13,15,14, 8,10,10,12,12,10,11,11,13,13, 9,11, - 10,13,13,12,13,13,14,15,12,13,12,15,13,11,12,12, - 14,14,12,13,13,13,15,13,13,13,14,15,14,14,15,14, - 16,14,15,15,15,15,11,12,12,14,13,12,13,13,15,14, - 12,13,12,15,13,14,14,15,16,16,13,14,13,16,13, 7, - 10,10,12,12,10,10,12,12,14,10,11,11,13,12,12,13, - 13,13,15,12,13,13,15,14,10,11,11,13,13,10,10,12, - 12,14,12,12,12,14,13,13,13,14,13,15,13,14,14,15, - 14, 9,10,11,13,13,11,12,12,13,14,10,12,10,14,12, - 13,13,14,14,15,13,13,12,15,13,12,13,13,14,14,12, - 13,13,14,15,13,14,14,15,15,13,13,15,13,16,15,15, - 15,16,16,12,13,13,14,14,13,14,14,15,15,12,13,12, - 15,14,15,15,15,16,16,13,14,13,15,13, 7,10, 9,12, - 12, 9,10,11,13,13, 9,11,10,13,13,11,13,13,14,15, - 11,13,12,15,14, 9,11,11,13,13,10,10,12,13,14,11, - 12,12,14,14,12,13,14,14,15,13,13,13,15,15, 9,11, - 10,13,12,11,12,11,14,14,10,12,10,14,13,13,14,13, - 15,15,12,14,12,15,14,12,13,13,14,15,13,13,14,14, - 15,13,14,14,15,15,14,14,15,14,17,14,15,15,16,16, - 12,13,12,15,13,13,14,14,15,15,12,14,13,15,13,14, - 15,15,16,16,14,15,14,16,14,11,12,12,14,14,13,13, - 14,14,15,13,14,13,15,15,14,15,15,16,17,14,15,15, - 16,15,12,13,13,15,15,13,13,14,15,16,14,14,14,16, - 15,15,15,16,15,17,15,16,15,17,16,12,13,13,14,15, - 14,14,15,15,16,13,14,13,15,15,15,15,16,16,17,15, - 15,15,16,15,14,15,15,16,16,14,15,15,16,17,15,16, - 16,17,17,16,15,16,15,17,16,17,17,17,17,14,15,15, - 15,16,15,15,16,16,17,14,15,15,16,16,16,16,17,17, - 18,15,16,15,17,15,11,13,12,14,14,12,13,13,15,15, - 12,14,13,15,14,14,15,15,16,16,14,15,14,16,15,12, - 13,13,15,15,13,14,14,15,16,13,14,14,16,16,15,15, - 16,16,17,15,16,15,17,16,12,13,13,15,14,13,14,14, - 16,15,13,14,13,16,14,15,16,15,17,16,15,15,14,18, - 15,14,15,15,16,16,15,15,16,16,17,15,16,15,17,16, - 16,16,17,17,18,16,17,17,18,17,14,15,15,16,15,15, - 16,15,17,16,15,15,15,17,15,16,17,17,18,17,16,17, - 16,18,15,10,12,12,14,14,12,13,13,14,14,12,13,13, - 14,14,13,14,14,15,15,13,14,14,16,15,11,12,13,14, - 14,12,13,13,15,15,12,13,13,15,15,13,14,15,15,16, - 14,15,15,16,16,12,13,13,14,14,13,13,14,15,15,13, - 14,13,15,15,14,15,15,16,16,14,15,14,16,15,13,14, - 14,15,15,13,14,14,15,16,14,14,15,16,16,14,15,15, - 15,17,15,16,16,17,17,13,14,14,15,15,14,15,15,16, - 16,14,15,15,16,16,15,16,16,16,17,15,16,15,17,16, - 11,12,12,14,14,12,13,13,14,15,12,13,13,15,14,13, - 14,14,15,16,13,14,14,16,15,12,13,13,14,15,13,13, - 14,15,15,13,14,14,15,15,14,14,15,15,17,14,15,15, - 16,16,12,13,13,15,15,13,14,14,15,15,13,14,13,15, - 15,14,15,15,16,17,14,15,15,16,16,13,13,14,15,16, - 14,14,15,15,16,14,15,15,16,16,15,15,16,15,18,15, - 16,16,17,17,14,15,15,16,16,15,15,15,16,16,14,15, - 15,17,16,16,16,16,17,17,15,16,16,17,16,10,12,12, - 14,14,12,13,13,14,15,12,13,13,15,14,14,14,15,15, - 16,14,15,14,16,15,12,13,13,15,14,13,13,14,15,15, - 13,14,14,15,15,14,14,15,15,16,14,15,15,16,16,12, - 13,13,15,15,13,14,14,15,16,13,14,13,15,14,15,15, - 15,16,16,14,15,15,16,15,13,14,14,16,15,14,14,14, - 15,16,14,15,15,16,16,15,15,16,15,17,16,17,16,17, - 17,14,14,15,15,16,15,15,16,16,16,14,15,14,16,15, - 16,16,16,17,17,15,16,15,17,15,11,13,13,14,15,13, - 13,14,15,15,13,14,13,15,15,14,15,15,15,16,14,15, - 15,17,15,13,13,14,15,15,13,14,15,15,16,14,14,14, - 16,16,15,14,16,15,17,15,16,16,17,16,13,14,14,15, - 15,14,14,14,16,16,13,15,14,16,15,15,15,16,17,17, - 15,16,15,17,16,14,15,15,15,16,15,15,16,15,17,15, - 16,16,16,17,16,16,17,15,18,16,17,17,17,17,14,15, - 15,16,16,15,16,16,17,17,15,16,15,17,16,16,17,17, - 18,18,16,17,15,18,16,10,12,12,14,14,13,13,14,14, - 15,13,14,13,15,14,14,15,15,15,16,15,15,15,16,15, - 12,13,13,15,14,12,12,14,14,15,14,15,14,16,15,15, - 14,15,14,17,15,16,16,17,16,12,13,13,14,15,14,14, - 15,15,16,13,14,12,16,14,15,16,16,16,17,15,16,14, - 17,15,14,15,14,16,15,14,14,15,15,15,15,16,15,17, - 16,15,14,16,14,16,16,17,17,18,17,14,14,15,15,16, - 15,16,16,16,17,14,15,14,16,15,16,16,17,17,17,15, - 16,14,17,14,10,12,12,14,13,12,13,13,14,14,11,13, - 12,14,14,13,14,14,15,16,13,14,14,16,15,12,13,13, - 14,14,13,13,14,15,15,13,14,13,15,15,14,14,15,15, - 16,14,15,15,16,16,11,13,12,14,14,12,13,13,15,15, - 12,13,13,15,15,14,15,15,16,16,13,14,14,16,15,13, - 14,14,15,15,14,15,15,15,16,14,15,15,16,16,15,16, - 16,16,17,16,16,16,17,17,13,14,14,15,15,14,15,15, - 16,16,13,14,14,16,15,15,16,16,17,17,15,15,15,17, - 15,11,12,12,14,14,12,13,13,14,15,12,13,13,15,14, - 14,14,15,15,16,14,14,14,16,15,12,13,13,15,14,13, - 13,14,15,15,13,14,14,16,15,14,15,15,15,16,15,15, - 15,16,16,12,13,13,14,15,13,13,14,15,15,13,14,13, - 15,15,15,15,15,16,16,14,15,14,16,15,14,14,15,16, - 16,14,15,15,15,16,15,16,15,16,16,15,15,16,15,17, - 16,16,16,17,17,13,14,14,15,16,14,15,15,16,16,14, - 14,14,16,16,16,16,16,17,17,15,15,15,17,15,11,12, - 12,14,14,12,13,13,14,15,12,13,13,15,14,14,14,14, - 15,16,13,14,14,16,15,12,13,13,15,15,13,13,14,15, - 16,13,14,14,15,15,14,15,15,16,17,14,15,15,17,16, - 12,13,13,15,14,13,14,14,15,15,13,14,13,15,15,14, - 15,15,16,16,14,15,14,17,15,14,15,15,16,16,14,15, - 15,16,17,15,15,15,17,17,15,16,16,16,17,16,17,16, - 17,17,13,15,14,16,15,14,15,15,16,16,14,15,14,16, - 15,16,16,16,17,17,15,16,15,17,15,10,12,12,14,14, - 13,13,14,14,15,13,14,13,15,14,14,15,15,15,17,14, - 15,15,16,15,12,13,13,15,14,12,12,14,14,15,14,15, - 14,16,15,15,14,16,15,17,15,16,16,17,16,12,13,13, - 14,15,14,14,15,15,16,12,14,12,15,14,15,16,16,16, - 17,15,16,14,17,14,14,15,14,16,16,14,14,15,15,16, - 15,16,16,17,16,15,14,16,14,17,16,17,17,18,17,14, - 14,15,15,16,15,15,16,16,17,14,15,14,16,15,16,17, - 17,17,18,15,16,14,17,14,11,13,13,15,14,13,13,14, - 15,15,12,14,13,15,15,14,15,15,15,17,14,15,14,16, - 15,13,14,14,15,15,13,14,15,15,16,14,15,14,16,16, - 15,15,16,16,17,15,16,16,17,17,13,14,13,15,15,14, - 14,14,16,16,13,15,14,16,15,15,16,16,17,17,15,16, - 14,17,15,15,15,15,16,17,15,15,16,16,17,15,16,16, - 17,17,16,15,17,16,17,17,17,17,18,18,14,15,15,17, - 15,15,16,16,17,16,15,16,15,17,15,16,17,17,17,17, - 16,17,15,18,15, -}; - -static const static_codebook _44p7_p5_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p7_p5_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p7_p5_0, - 0 -}; - -static const long _vq_quantlist__44p7_p5_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p7_p5_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p7_p5_1 = { - 1, 7, - (char *)_vq_lengthlist__44p7_p5_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p7_p5_1, - 0 -}; - -static const long _vq_quantlist__44p7_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p7_p6_0[] = { - 2, 5, 6, 5, 7, 8, 5, 8, 7, 5, 7, 7, 7, 7, 9, 8, - 9, 9, 5, 7, 7, 8, 9, 9, 7, 9, 7, 6, 8, 8, 8, 9, - 10, 8, 9, 9, 8, 9,10, 9, 9,11,10,10,11, 8,10, 9, - 10,10,11, 9,10,10, 6, 8, 8, 8, 9, 9, 8,10, 9, 8, - 9,10, 9,10,10,10,11,10, 8,10, 9,10,11,10, 9,11, - 9, 6, 8, 8, 7, 9, 9, 8, 9, 9, 7, 9, 9, 9, 9,10, - 9,10,10, 8, 9, 9, 9,10,10, 9,10, 9, 7, 9, 9, 9, - 10,10, 9,10,10, 9, 9,10,10, 9,11,10,11,11, 9,10, - 10,10,11,11,10,11,10, 6, 9, 8, 9,10,10, 9,10, 9, - 8,10,10, 9, 9,10,10,11,11, 9,10,10,10,11,11, 9, - 11, 9, 6, 8, 8, 8, 9, 9, 7, 9, 9, 8, 9, 9, 9, 9, - 10, 9,10,10, 7, 9, 9, 9,10,10, 9,10, 9, 6, 8, 9, - 9, 9,10, 9,10,10, 9,10,10, 9, 9,11,10,11,11, 8, - 10,10,10,11,11, 9,10, 9, 7, 9, 9, 9,10,10, 9,10, - 10, 9,10,10,10,10,11,10,11,11, 9,10, 9,10,11,11, - 10,11, 9, -}; - -static const static_codebook _44p7_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p7_p6_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p7_p6_0, - 0 -}; - -static const long _vq_quantlist__44p7_p6_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p7_p6_1[] = { - 4, 7, 7, 6, 7, 8, 6, 8, 7, 7, 7, 8, 7, 7, 8, 8, - 8, 8, 7, 7, 7, 8, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, 8, - 8, 9, 9, 8, 9, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, - 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, 8, 7, 8, 8, 8, - 8, 9, 8, 9, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, - 8, 9, 9, 9, 8, 9, 9, 7, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, - 9, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 9, 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, 8, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, - 8, 8, 8, 9, 9, 8, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 8, 9, 9, 8, 8, 8, 9, 9, 9, - 8, 9, 8, -}; - -static const static_codebook _44p7_p6_1 = { - 5, 243, - (char *)_vq_lengthlist__44p7_p6_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p7_p6_1, - 0 -}; - -static const long _vq_quantlist__44p7_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p7_p7_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p7_p7_0 = { - 5, 243, - (char *)_vq_lengthlist__44p7_p7_0, - 1, -513979392, 1633504256, 2, 0, - (long *)_vq_quantlist__44p7_p7_0, - 0 -}; - -static const long _vq_quantlist__44p7_p7_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p7_p7_1[] = { - 1, 5, 5, 4,10,10, 5,10,10, 5,10,10,10,10,10,10, - 10,10, 5,10,10,10,10,10, 9,10,10, 6,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10, 7,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, 6,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10, 6,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,11,11, -}; - -static const static_codebook _44p7_p7_1 = { - 5, 243, - (char *)_vq_lengthlist__44p7_p7_1, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44p7_p7_1, - 0 -}; - -static const long _vq_quantlist__44p7_p7_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p7_p7_2[] = { - 1, 3, 2, 4, 5, 7, 7, 8, 8, 9, 9,10,10,11,11,12, - 12,13,13,14,14,15,15,15,15, -}; - -static const static_codebook _44p7_p7_2 = { - 1, 25, - (char *)_vq_lengthlist__44p7_p7_2, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p7_p7_2, - 0 -}; - -static const long _vq_quantlist__44p7_p7_3[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p7_p7_3[] = { - 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p7_p7_3 = { - 1, 25, - (char *)_vq_lengthlist__44p7_p7_3, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p7_p7_3, - 0 -}; - -static const char _huff_lengthlist__44p7_short[] = { - 3, 9,14,16,17,19,22,22, 5, 4, 6, 9,11,13,17,20, - 9, 5, 5, 6, 9,11,15,19,11, 7, 5, 5, 7, 9,13,17, - 14, 9, 7, 6, 6, 7,11,14,16,11, 9, 7, 6, 4, 4, 8, - 19,15,13,11, 9, 4, 3, 4,21,16,16,15,12, 6, 4, 4, -}; - -static const static_codebook _huff_book__44p7_short = { - 2, 64, - (char *)_huff_lengthlist__44p7_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p8_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p8_l0_0[] = { - 2, 4, 4, 7, 7, 8, 8,10,10,11,11,12,12, 4, 5, 5, - 7, 7, 9, 9,10, 9,12,10,12,12, 4, 5, 5, 7, 7, 9, - 9, 9,10,10,12,12,12, 7, 7, 7, 7, 8, 9, 8,11, 5, - 12, 6,12,10, 7, 7, 7, 8, 7, 8, 9, 5,11, 6,12,10, - 12, 8, 9, 9, 9, 9, 9, 9,11, 7,11, 7,11, 9, 8, 9, - 9, 9, 9, 9, 9, 7,10, 7,11, 9,11,10,10,10,10,10, - 10,10,11,10,11, 8,12, 9,10,10,10,10,10,10,10,10, - 11, 8,11, 9,12,10,11,11,11,11,11,11,11,11,12,10, - 12,11,10,11,11,11,11,11,11,11,11,10,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,11,12,12,12, - 12,12,12,12,12,12,11,12,12, -}; - -static const static_codebook _44p8_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p8_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p8_l0_0, - 0 -}; - -static const long _vq_quantlist__44p8_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p8_l0_1[] = { - 4, 4, 4, 5, 5, 4, 4, 5, 5, 5, 4, 5, 4, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p8_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p8_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p8_l0_1, - 0 -}; - -static const long _vq_quantlist__44p8_l1_0[] = { - 54, - 29, - 79, - 0, - 108, -}; - -static const char _vq_lengthlist__44p8_l1_0[] = { - 1, 2, 3, 6, 7, 7, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44p8_l1_0 = { - 2, 25, - (char *)_vq_lengthlist__44p8_l1_0, - 1, -514516992, 1620639744, 7, 0, - (long *)_vq_quantlist__44p8_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p8_lfe[] = { - 2, 3, 1, 3, -}; - -static const static_codebook _huff_book__44p8_lfe = { - 2, 4, - (char *)_huff_lengthlist__44p8_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p8_long[] = { - 2, 7,14,16,17,18,20,21, 7, 4, 6, 8,11,12,14,16, - 13, 5, 4, 4, 8, 9,11,13,15, 8, 4, 3, 5, 7, 9,10, - 17,11, 8, 4, 4, 6, 9, 9,17,11, 9, 7, 6, 5, 7, 8, - 19,13,11, 9, 9, 7, 8, 8,21,15,13,11,10, 8, 8, 7, -}; - -static const static_codebook _huff_book__44p8_long = { - 2, 64, - (char *)_huff_lengthlist__44p8_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p8_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p8_p1_0[] = { - 2, 5, 5, 4, 7, 7, 4, 7, 7, 5, 7, 7, 7, 8, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 7, 9, 8, 6, 7, 8, 8, 9, - 10, 8, 9,10, 8, 9,10,10,10,12,10,11,12, 8,10,10, - 10,11,12,10,11,11, 6, 8, 7, 8,10, 9, 8,10, 9, 8, - 10,10,10,11,11,10,12,11, 8,10, 9,10,12,11,10,12, - 10, 5, 8, 8, 8,10,10, 8,10,10, 7, 9,10, 9,10,11, - 9,11,11, 8,10,10,10,12,12,10,12,11, 7, 9, 9, 9, - 10,11, 9,11,11, 9, 9,11,10,11,12,10,11,12, 9,11, - 11,11,12,12,11,12,12, 7, 9, 9,10,11,11,10,12,11, - 9,11,10,11,11,12,11,13,12,10,11,11,12,13,13,11, - 13,11, 5, 8, 8, 8,10,10, 8,10,10, 8,10,10,10,11, - 12,10,12,11, 7,10, 9, 9,11,11, 9,11,10, 7, 9, 9, - 10,11,12,10,11,11,10,11,11,11,11,13,12,13,13, 9, - 10,11,12,12,13,11,12,11, 7, 9, 9, 9,11,11, 9,11, - 10, 9,11,11,11,12,12,11,12,12, 9,11, 9,10,12,11, - 10,12,11, -}; - -static const static_codebook _44p8_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p8_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p8_p1_0, - 0 -}; - -static const long _vq_quantlist__44p8_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p8_p2_0[] = { - 4, 6, 6, 9, 9, 6, 8, 8,10,10, 6, 8, 8,10,10, 8, - 9,10,12,12, 8,10, 9,12,12, 6, 8, 8,10,10, 8, 8, - 9,10,11, 8, 9, 9,11,11, 9,10,11,12,13,10,11,11, - 13,13, 6, 8, 8,10,10, 8, 9, 9,11,11, 8, 9, 8,11, - 10,10,11,11,13,13, 9,11,10,13,12, 9,10,10,12,12, - 10,10,11,12,13,10,11,11,13,13,12,12,13,12,15,12, - 13,13,15,14, 9,10,10,12,12,10,11,11,13,13,10,11, - 10,13,12,12,13,13,14,15,12,13,12,15,12, 7, 8, 8, - 10,11, 8, 9,10,11,12, 8, 9, 9,11,11,10,11,11,13, - 14,10,11,11,13,13, 8, 9, 9,11,12, 9,10,11,11,13, - 9,10,10,12,12,11,11,12,13,15,11,12,12,14,14, 8, - 9, 9,11,11, 9,10,11,12,13, 9,10,10,12,12,11,12, - 12,14,15,11,12,12,14,14,10,11,12,13,13,11,12,12, - 13,14,12,12,12,14,14,13,13,14,14,16,14,14,14,16, - 15,10,11,11,13,13,12,12,12,14,14,11,12,12,14,13, - 14,14,14,15,16,13,14,13,16,14, 7, 8, 8,11,10, 8, - 9, 9,11,11, 8,10, 9,12,11,10,11,11,13,13,10,11, - 11,14,13, 8, 9, 9,12,11, 9,10,10,12,12, 9,11,10, - 13,12,11,12,12,13,14,11,12,12,15,14, 8, 9, 9,12, - 11, 9,10,10,12,12, 9,11,10,13,11,11,12,12,14,14, - 11,12,12,14,13,10,11,11,13,13,11,12,12,13,14,12, - 13,12,14,14,13,13,14,14,16,13,14,14,16,15,10,11, - 11,13,13,12,12,12,14,14,11,12,12,14,13,13,14,14, - 15,15,13,14,13,16,14, 9,10,11,12,13,11,11,12,12, - 14,11,11,12,13,14,13,13,14,14,16,13,13,14,15,15, - 11,11,12,12,14,12,12,13,13,15,12,12,13,13,15,14, - 14,15,15,16,14,14,14,15,16,11,12,12,13,14,12,12, - 13,14,15,12,13,12,14,14,14,14,15,15,16,14,14,14, - 16,16,13,13,14,15,16,14,14,15,15,16,14,15,15,16, - 16,15,15,16,16,18,16,16,16,17,17,13,14,14,15,15, - 14,14,15,16,16,14,15,14,16,16,16,16,16,17,18,15, - 16,16,17,16, 9,11,10,13,12,11,12,11,14,13,11,12, - 11,14,12,13,14,13,15,14,13,14,13,16,14,11,12,12, - 14,13,12,12,13,14,14,12,13,12,15,14,14,14,14,16, - 16,14,15,14,17,15,11,12,11,14,12,12,13,12,15,13, - 12,13,12,15,13,14,14,14,16,15,14,15,14,16,15,13, - 14,14,15,15,14,14,15,16,16,14,15,14,16,16,15,15, - 16,16,17,16,16,16,17,17,13,14,14,16,15,14,15,15, - 16,16,14,15,14,17,15,16,16,16,17,17,15,16,15,18, - 16, 7, 8, 8,10,11, 8, 9, 9,11,12, 8, 9, 9,12,11, - 10,11,11,13,14,10,11,11,14,13, 8, 9, 9,11,11, 9, - 10,10,12,12, 9,10,10,12,12,11,12,12,13,14,11,12, - 12,14,14, 8, 9, 9,12,11, 9,10,11,12,13, 9,11,10, - 13,12,11,12,12,14,14,11,12,12,14,13,10,11,11,13, - 13,11,12,12,13,14,11,12,12,14,14,13,13,14,14,16, - 13,14,14,16,15,10,12,11,13,13,12,12,12,14,14,11, - 12,12,14,13,14,14,14,15,16,13,14,14,16,14, 8, 9, - 9,11,11, 9,10,10,12,12, 9,10,10,12,12,11,11,12, - 13,14,11,12,12,14,14, 9, 9,10,11,12,10,10,11,12, - 13,10,10,11,12,13,12,12,13,14,15,12,12,13,14,15, - 9,10,10,12,12,10,11,11,13,13,10,11,11,13,13,12, - 13,13,15,15,12,13,13,15,14,11,11,12,13,14,12,12, - 13,13,15,12,12,13,14,15,14,14,15,14,16,14,14,15, - 15,16,11,12,12,14,14,12,13,13,15,15,12,13,13,15, - 14,14,15,15,16,16,14,15,14,17,15, 8, 9, 9,11,11, - 9,10,10,12,12, 9,11,10,13,12,11,12,12,14,14,11, - 13,12,15,13, 9,10,10,12,12,10,10,11,12,13,10,12, - 11,13,13,12,12,13,13,15,12,13,13,15,14, 9,10,10, - 12,12,11,11,12,13,13,10,12,10,13,12,12,13,13,15, - 15,12,13,13,15,13,11,12,12,14,14,12,12,13,14,14, - 12,13,13,15,14,13,13,14,13,16,14,15,14,16,16,11, - 12,12,14,14,13,13,13,15,15,12,13,12,15,14,14,15, - 15,16,17,14,15,13,16,13,10,11,11,13,14,11,12,12, - 13,15,11,12,12,14,14,13,14,14,15,16,13,14,14,16, - 16,11,11,12,12,14,12,12,13,13,15,12,13,13,13,15, - 14,14,15,14,17,14,14,15,15,16,11,12,12,14,14,12, - 13,13,15,15,12,13,13,15,15,14,15,15,16,17,14,15, - 15,16,16,13,14,14,14,16,14,14,15,14,17,14,15,15, - 14,17,16,16,17,15,18,16,16,17,16,18,13,14,14,16, - 16,14,15,15,17,16,14,15,15,17,16,16,17,17,18,18, - 16,17,16,18,17,10,11,11,14,13,11,12,12,14,14,11, - 13,12,15,14,14,14,14,16,15,14,15,14,16,15,11,12, - 12,14,13,12,13,13,15,14,13,14,13,15,14,14,15,15, - 16,16,14,15,15,17,15,11,12,12,14,14,13,13,13,15, - 15,12,13,13,15,14,15,15,15,17,17,14,15,15,17,15, - 13,14,14,16,15,14,15,15,16,16,15,15,15,17,16,16, - 16,16,16,17,16,17,16,18,17,14,14,14,16,16,15,15, - 15,16,16,14,15,14,17,16,16,17,17,17,18,16,17,16, - 18,16, 7, 8, 8,11,11, 8, 9, 9,11,12, 8, 9, 9,12, - 11,10,11,11,13,14,10,11,11,14,13, 8, 9, 9,11,12, - 9,10,11,12,13, 9,11,10,13,12,11,12,12,13,14,11, - 12,12,14,14, 8, 9, 9,11,11, 9,10,10,12,12, 9,10, - 10,13,12,11,12,12,14,14,11,12,11,14,13,10,11,12, - 13,13,11,12,12,13,14,12,13,12,14,14,13,13,14,14, - 16,13,14,14,16,15,10,11,11,13,13,11,12,12,14,14, - 11,12,12,14,13,13,14,14,15,16,13,14,13,16,14, 8, - 9, 9,11,11, 9,10,11,12,13, 9,10,10,12,12,11,12, - 13,13,14,11,12,12,14,14, 9,10,10,12,12,10,10,11, - 12,13,11,12,11,13,13,12,12,13,13,15,12,13,13,15, - 15, 9,10,10,12,12,10,11,12,13,14,10,11,10,13,12, - 12,13,13,14,15,12,13,12,15,13,12,12,12,14,14,12, - 12,13,14,15,13,13,13,15,15,14,14,15,13,16,14,15, - 15,16,16,11,12,12,14,14,12,13,13,14,15,12,13,12, - 14,14,14,14,15,16,16,13,14,13,16,14, 8, 9, 9,11, - 11, 9,10,10,12,12, 9,10,10,12,12,11,12,12,14,14, - 11,12,11,14,14, 9,10,10,12,12,10,11,11,13,13,10, - 11,11,13,13,12,13,13,14,15,12,13,13,15,14, 9,10, - 9,12,11,10,11,10,13,12,10,11,10,13,12,12,13,12, - 15,14,12,13,12,15,14,11,12,12,14,14,12,13,13,14, - 15,12,13,13,15,15,14,14,15,15,17,14,15,15,16,16, - 11,12,11,14,13,12,13,12,15,14,12,13,12,15,13,14, - 15,14,16,15,13,15,14,17,14,10,11,11,13,14,11,12, - 13,13,15,11,12,12,14,14,14,14,15,15,17,13,14,14, - 15,16,11,12,12,14,14,12,12,13,14,15,13,13,13,15, - 15,14,15,15,15,17,15,15,15,16,16,11,12,12,13,14, - 13,13,14,14,15,12,13,13,14,15,14,15,15,16,17,14, - 15,15,16,16,14,14,14,16,16,14,14,15,15,17,15,15, - 15,17,16,16,16,17,16,18,16,17,17,18,17,13,14,14, - 15,16,14,15,15,16,17,14,15,15,16,16,16,17,17,17, - 18,16,16,16,17,16,10,11,11,14,13,11,12,12,14,14, - 11,12,12,15,13,13,14,14,16,15,13,14,14,16,15,11, - 12,12,14,14,12,13,13,15,15,12,13,13,15,15,14,15, - 15,16,17,14,15,15,17,16,11,12,11,14,12,12,13,13, - 15,13,12,13,12,15,13,14,15,15,16,15,14,15,14,17, - 14,13,14,14,16,16,14,15,15,16,17,14,15,15,16,17, - 16,16,17,17,18,16,17,17,18,18,13,14,14,16,13,14, - 15,15,17,14,14,15,14,17,14,16,17,16,17,16,16,17, - 16,18,15, 8,11,11,13,13,10,12,12,14,14,11,12,12, - 14,14,13,13,14,15,16,13,14,14,16,15,10,11,11,14, - 14,11,12,12,14,15,11,12,12,15,14,13,14,14,15,16, - 13,14,14,16,16,11,12,12,14,14,12,13,13,15,15,12, - 13,12,15,14,14,14,15,16,16,14,15,14,16,16,12,13, - 13,15,15,12,13,14,15,16,13,14,14,16,16,14,15,15, - 16,17,15,15,16,17,17,13,14,14,16,15,14,15,15,16, - 16,14,15,14,16,16,16,16,16,17,17,15,16,16,18,16, - 10,11,11,13,14,11,12,12,14,15,11,12,12,15,14,13, - 14,14,16,16,13,14,14,16,16,11,11,12,14,14,12,12, - 13,14,15,12,13,13,15,15,14,14,15,15,17,14,14,15, - 16,16,11,12,12,15,14,12,13,13,15,15,12,13,13,15, - 15,14,15,15,17,17,14,15,15,17,16,13,12,14,14,16, - 13,13,15,14,17,14,13,15,15,17,15,14,16,15,18,16, - 15,16,16,18,13,14,14,16,16,14,15,15,17,17,14,15, - 15,17,16,16,17,17,18,18,16,17,16,18,17,10,11,11, - 14,13,11,12,12,14,14,11,13,12,15,14,13,14,14,15, - 16,13,14,14,16,16,11,12,12,14,14,12,13,13,14,15, - 12,13,13,15,15,14,14,15,15,16,14,15,15,17,16,11, - 12,12,14,14,13,13,13,15,15,12,13,13,15,14,14,15, - 15,16,17,14,15,14,17,15,13,14,13,16,15,14,14,14, - 15,16,14,15,14,16,16,15,15,16,16,17,16,16,16,18, - 17,14,14,14,16,16,15,15,15,17,16,14,15,14,17,16, - 16,16,17,17,18,16,17,16,18,16,11,13,13,15,15,12, - 13,14,15,16,12,14,14,15,15,14,15,15,16,17,14,15, - 15,17,17,12,13,14,14,16,13,14,14,14,16,14,14,14, - 15,16,15,15,16,15,18,15,16,16,17,17,13,14,14,16, - 16,14,14,15,16,16,14,15,14,16,16,15,16,16,17,18, - 15,16,16,18,17,14,14,16,13,17,15,15,16,14,18,15, - 15,16,14,18,16,16,18,15,19,17,17,18,16,18,15,16, - 15,17,17,15,16,17,18,18,16,16,16,18,17,17,18,18, - 19,19,17,18,17,19,18,11,12,12,15,14,13,13,14,15, - 16,13,14,13,16,14,15,15,15,16,17,15,16,15,17,16, - 12,13,13,15,14,13,13,14,15,15,14,15,14,16,15,15, - 15,16,16,17,16,16,16,18,17,12,13,13,15,15,14,14, - 15,16,16,13,14,13,16,15,16,16,16,17,18,15,16,15, - 17,16,14,15,14,17,15,14,15,15,16,16,15,16,15,17, - 16,16,15,16,15,17,17,18,17,18,17,15,15,15,16,17, - 16,16,16,17,17,15,16,15,17,16,17,18,18,18,18,16, - 17,16,18,15, 8,11,11,13,13,11,12,12,14,14,10,12, - 12,14,14,13,14,14,15,16,13,14,13,16,15,11,12,12, - 14,14,12,12,13,14,15,12,13,13,15,15,14,14,15,15, - 16,14,14,14,16,16,10,11,11,14,14,11,12,12,14,15, - 11,12,12,15,14,13,14,14,16,16,13,14,14,16,15,13, - 14,14,15,16,14,14,15,16,16,14,15,15,16,16,15,16, - 16,16,18,16,16,16,17,17,12,13,13,15,15,13,14,14, - 16,16,12,14,13,16,15,15,16,15,17,17,14,16,15,17, - 16,10,11,11,13,14,11,12,13,14,15,11,13,12,14,14, - 14,14,15,16,16,13,14,14,16,16,11,12,12,14,14,12, - 13,13,14,15,13,14,13,15,15,14,15,15,16,17,14,15, - 15,17,16,11,12,12,14,14,12,13,13,15,15,12,13,12, - 15,14,14,15,15,16,17,14,15,15,16,16,14,14,14,16, - 16,14,14,15,16,16,15,15,15,16,16,16,16,17,16,18, - 16,17,17,18,18,13,13,14,15,16,14,14,15,16,17,13, - 14,14,16,16,16,16,17,17,18,15,16,15,17,16,10,11, - 11,14,13,11,12,12,14,14,11,12,12,15,14,13,14,14, - 16,16,13,14,14,16,16,11,12,12,14,14,12,13,13,15, - 15,12,13,13,15,15,14,15,15,16,17,14,15,15,17,16, - 11,12,11,14,14,12,13,13,15,15,12,13,12,15,14,14, - 15,14,16,16,14,15,14,17,16,14,14,14,16,16,14,15, - 15,16,17,14,15,15,17,17,16,16,17,17,18,16,17,17, - 18,18,13,14,12,16,14,14,15,13,17,15,13,15,13,17, - 14,16,16,15,18,16,15,17,14,18,15,11,12,12,14,15, - 13,13,14,14,16,13,14,13,15,14,15,15,16,16,17,15, - 16,15,17,16,12,13,13,15,15,13,13,14,15,16,14,15, - 14,16,16,15,15,16,15,18,16,16,16,18,17,12,13,13, - 15,15,14,14,15,15,16,13,14,13,15,15,16,16,16,16, - 18,15,16,15,17,16,15,15,15,17,16,15,15,16,16,17, - 16,16,16,18,17,16,16,17,15,18,17,18,17,19,18,14, - 14,15,15,17,15,15,16,16,17,14,15,15,16,16,17,17, - 18,17,19,16,17,15,17,15,11,13,12,15,15,12,14,14, - 15,15,12,14,13,16,15,15,15,15,17,17,14,15,15,17, - 16,12,14,14,16,16,14,14,15,16,16,14,14,14,16,16, - 15,16,17,17,18,15,16,16,18,17,12,14,13,16,14,13, - 14,14,16,15,13,15,14,16,14,15,16,16,17,17,15,16, - 15,18,15,15,15,16,17,17,15,16,16,17,18,16,16,16, - 18,18,17,17,18,18,19,17,17,18,19,19,14,15,14,17, - 13,15,16,15,18,14,15,16,15,18,14,17,18,17,18,16, - 16,18,16,19,15, -}; - -static const static_codebook _44p8_p2_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p8_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p8_p2_0, - 0 -}; - -static const long _vq_quantlist__44p8_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p8_p3_0[] = { - 2, 5, 5, 5, 7, 7, 5, 7, 7, 5, 7, 7, 7, 8, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 7, 9, 8, 5, 7, 8, 7, 9, - 10, 8, 9, 9, 8, 9,10, 9,10,12,10,11,11, 8,10, 9, - 10,11,12, 9,11,10, 5, 8, 7, 8,10, 9, 7,10, 9, 8, - 9,10, 9,10,11,10,12,11, 8,10, 9,10,11,11, 9,12, - 10, 5, 8, 8, 7, 9,10, 8,10, 9, 7, 9,10, 9,10,11, - 9,11,11, 8,10, 9,10,11,11,10,12,10, 7, 9,10, 9, - 10,12, 9,11,11, 9, 9,12,11,10,13,11,11,13,10,12, - 11,11,13,13,11,13,12, 7, 9, 9, 9,11,11, 9,12,11, - 9,11,10,10,11,12,11,13,12, 9,11,11,12,13,13,11, - 13,11, 5, 8, 8, 8, 9,10, 7,10, 9, 8, 9,10,10,10, - 12,10,11,11, 7,10, 9, 9,11,11, 9,11,10, 7, 9, 9, - 9,11,12, 9,11,11, 9,11,11,11,11,13,12,13,13, 9, - 10,11,11,12,13,10,12,11, 7,10, 9, 9,11,11, 9,12, - 10,10,11,12,11,12,13,12,13,13, 9,12, 9,11,13,11, - 10,13,10, -}; - -static const static_codebook _44p8_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p8_p3_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p8_p3_0, - 0 -}; - -static const long _vq_quantlist__44p8_p3_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p8_p3_1[] = { - 6, 7, 7, 7, 7, 8, 7, 8, 7, 7, 7, 8, 7, 8, 8, 8, - 8, 8, 7, 8, 7, 7, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 9, 8, 8, - 8, 8, 9, 9, 8, 9, 9, 7, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 8, 8, 8, 9, 9, 8, - 9, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, - 8, 8, 8, 8, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 8, 9, 9, 8, 8, 8, 8, 9, 8, - 8, 9, 8, -}; - -static const static_codebook _44p8_p3_1 = { - 5, 243, - (char *)_vq_lengthlist__44p8_p3_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p8_p3_1, - 0 -}; - -static const long _vq_quantlist__44p8_p4_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p8_p4_0[] = { - 2, 5, 5, 4, 7, 8, 4, 8, 7, 5, 7, 8, 7, 7,10, 8, - 9, 9, 5, 7, 7, 8, 9, 9, 7,10, 7, 5, 7, 8, 8, 9, - 11, 8,10,10, 8, 9,10,10,10,12,11,12,12, 8,10,10, - 10,12,12,10,12,11, 5, 8, 7, 8,10,10, 8,11, 9, 8, - 10,10,10,11,12,10,12,12, 8,10, 9,11,12,12,10,12, - 10, 5, 8, 8, 7,10,10, 8,11,10, 7, 9,10, 9,10,12, - 10,12,12, 8,10,10,10,12,12,10,12,11, 7, 9,10, 9, - 11,12,10,12,11, 9, 9,12,10,10,13,12,12,13,10,12, - 11,12,13,13,11,13,11, 7,10, 9,10,11,12,10,13,11, - 9,11,11,11,11,13,12,14,13,10,11,11,12,14,14,11, - 14,11, 5, 8, 8, 8,10,11, 7,10,10, 8,10,10,10,11, - 12,10,12,12, 7,10, 9,10,12,12, 9,12,10, 7, 9,10, - 10,11,13,10,12,11,10,11,11,11,11,14,12,14,14, 9, - 11,11,12,13,14,11,13,11, 7,10, 9,10,11,12, 9,12, - 10,10,11,12,11,11,13,12,13,13, 9,12, 9,12,13,12, - 10,13,10, -}; - -static const static_codebook _44p8_p4_0 = { - 5, 243, - (char *)_vq_lengthlist__44p8_p4_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p8_p4_0, - 0 -}; - -static const long _vq_quantlist__44p8_p4_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p8_p4_1[] = { - 7, 9, 9,10,10, 9,10,10,10,11, 9,10,10,11,10, 9, - 10,10,11,11, 9,10,10,11,11, 9,10,10,11,11,10,10, - 10,11,11,10,10,10,11,11,10,11,11,11,11,10,11,11, - 11,11, 9,10,10,11,11,10,10,10,11,11, 9,10,10,11, - 11,10,11,11,11,11,10,11,11,11,11,10,11,11,11,11, - 10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,12,10,11,11,11,11,11,11,11,11,11,10,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11, 9,10,10, - 11,11,10,10,11,11,11,10,10,11,11,11,10,11,11,11, - 12,10,11,11,12,12,10,10,11,11,11,10,11,11,11,12, - 11,11,11,12,12,11,11,12,12,12,11,11,12,12,12,10, - 11,11,11,11,11,11,11,12,12,10,11,11,12,12,11,12, - 11,12,12,11,12,11,12,12,11,11,11,11,12,11,11,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,11,11,11,12,12,11,12,12,12,12,11,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12, 9,10,10,11,11,10, - 11,10,11,11,10,11,10,11,11,10,11,11,12,12,10,11, - 11,12,11,10,11,11,11,11,10,11,11,11,12,11,11,11, - 12,12,11,11,12,12,12,11,11,11,12,12,10,11,10,11, - 11,11,11,11,12,12,10,11,11,12,11,11,12,11,12,12, - 11,12,11,12,12,11,11,11,12,12,11,11,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11, - 11,12,11,11,12,12,12,12,11,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,10,11,11,11,11,11,11,11,12, - 12,11,11,11,12,12,11,12,12,12,12,11,12,12,12,12, - 11,11,11,12,12,11,11,12,12,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,11,11,11,12,12,11,12, - 12,12,12,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,13,12,13,12,12,12,12,13,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,13,12,10,11,11,11,11,11,11,11,12,12,11,11, - 11,12,12,11,12,12,12,12,11,12,12,12,12,11,11,11, - 12,12,11,12,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,11,11,11,12,12,11,12,12,12,12, - 11,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,13,12,12,13,12,13, - 12, 9,10,10,11,11,10,10,11,11,11,10,11,10,11,11, - 10,11,11,12,12,10,11,11,12,12,10,10,11,11,11,10, - 11,11,11,12,10,11,11,12,12,11,11,12,12,12,11,11, - 11,12,12,10,11,10,11,11,11,11,11,12,12,10,11,11, - 12,11,11,12,11,12,12,11,12,11,12,12,11,11,11,11, - 12,11,11,12,12,12,11,12,12,12,12,11,12,12,12,12, - 11,12,12,12,12,11,11,11,12,11,11,12,12,12,12,11, - 12,11,12,12,12,12,12,12,12,12,12,12,12,12,10,10, - 11,11,11,10,11,11,12,12,10,11,11,12,12,11,11,11, - 12,12,11,11,12,12,12,10,11,11,11,12,11,11,12,12, - 12,11,11,12,12,12,11,11,12,12,12,11,12,12,12,12, - 11,11,11,12,12,11,12,12,12,12,11,12,11,12,12,11, - 12,12,12,12,11,12,12,12,12,11,11,12,12,12,11,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12, 9,10,10,11,11, - 10,11,11,11,12,10,11,11,12,11,11,12,11,12,12,11, - 12,11,12,12,10,11,11,12,11,11,11,11,12,12,11,12, - 11,12,12,11,12,12,12,12,11,12,12,12,12,10,11,11, - 12,12,11,12,11,12,12,11,12,11,12,12,12,12,12,12, - 12,11,12,12,12,12,11,12,11,12,12,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,11,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,11,11,11,12,12,11,12,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,13,12,12,12,12,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,13,13,12,12, - 12,13,13,12,12,12,12,12,12,12,12,12,13,12,12,12, - 12,13,12,12,13,12,13,12,13,13,13,13,12,12,12,12, - 12,12,12,12,13,12,12,12,12,13,12,12,13,13,13,13, - 12,13,13,13,13,10,11,11,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,13,12,12,12,12,13,13,12,12,12,13,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,12, - 13,13,12,13,12,13,13,13,13,12,12,12,12,12,12,12, - 12,13,12,12,12,12,13,12,12,13,13,13,13,12,13,13, - 13,13, 9,10,10,11,11,10,10,11,11,11,10,11,10,11, - 11,10,11,11,12,12,10,11,11,12,12,10,11,11,11,11, - 10,11,11,12,12,11,11,11,12,12,11,11,12,12,12,11, - 11,12,12,12,10,11,10,11,11,10,11,11,12,12,10,11, - 11,12,11,11,12,11,12,12,11,11,11,12,12,11,11,11, - 11,12,11,11,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,11,11,11,12,11,11,12,12,12,12, - 11,12,11,12,12,12,12,12,12,12,11,12,12,12,12, 9, - 10,10,11,11,10,11,11,11,12,10,11,11,12,11,11,11, - 12,12,12,11,11,12,12,12,10,11,11,12,12,11,11,12, - 12,12,11,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,10,11,11,12,12,11,11,11,12,12,11,11,11,12,12, - 11,12,12,12,12,11,12,12,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,11,11,12,12,12,12,12,12,12,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,10,11,10,11, - 11,10,11,11,12,12,10,11,11,12,12,11,11,11,12,12, - 11,12,11,12,12,11,11,11,12,12,11,11,12,12,12,11, - 11,12,12,12,11,12,12,12,12,11,12,12,12,12,10,11, - 11,12,11,11,12,11,12,12,11,12,11,12,12,11,12,12, - 12,12,11,12,11,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 11,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,11,11,11,12,12,11,11, - 12,12,12,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,11,12,12,12,12,12,12,12,12,13,12,12,12,12, - 12,12,12,12,13,13,12,12,12,13,13,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,12, - 12,12,12,12,12,12,12,12,12,12,12,13,12,13,12,12, - 12,13,13,12,13,13,12,13,12,13,13,13,13,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13, - 13,12,13,12,13,12,11,11,11,12,12,11,12,12,12,12, - 11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,13,13,12,12,12,13,13,11,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,13,12,12,12,12,13, - 12,12,12,12,12,12,12,12,12,13,13,12,12,12,12,13, - 12,13,13,13,13,12,13,13,13,13,12,12,12,12,12,12, - 12,12,13,12,12,12,12,13,12,12,13,13,13,13,12,13, - 13,13,12,10,11,11,12,12,11,11,11,12,12,11,11,11, - 12,12,11,12,12,12,12,11,12,12,12,12,11,11,11,12, - 12,11,11,12,12,12,11,12,12,12,12,11,12,12,12,12, - 12,12,12,12,12,11,11,11,12,12,11,12,12,12,12,11, - 12,11,12,12,12,12,12,12,12,12,12,12,12,12,11,12, - 12,12,12,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,13,12,12,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,13,12,12,12,12,12,12, - 11,11,11,12,12,11,12,12,12,12,11,12,12,12,12,12, - 12,12,12,12,11,12,12,12,12,11,11,12,12,12,11,12, - 12,12,12,12,12,12,12,12,12,12,12,12,13,12,12,12, - 13,13,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,13,13,12,12,12,13,13,12,12,12,12,12, - 12,12,12,12,13,12,12,12,12,13,12,12,13,12,13,12, - 12,13,13,13,12,12,12,12,12,12,12,12,12,13,12,12, - 12,13,12,12,13,13,13,13,12,13,13,13,13,10,11,11, - 12,12,11,12,12,12,12,11,12,12,12,12,11,12,12,12, - 12,12,12,12,12,12,11,11,12,12,12,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,13,12,12,12,13,13,11, - 12,11,12,12,12,12,12,12,12,11,12,12,12,12,12,12, - 12,13,13,12,12,12,13,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,13,12,12,12,12,12,13,12,13,12,13, - 13,12,12,12,12,12,12,12,12,13,12,12,12,12,13,12, - 12,13,12,13,13,12,13,12,13,12,11,11,11,12,12,11, - 12,12,12,12,11,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,13,12,13,12,12,13,13,13,11,12,12,12, - 12,12,12,12,12,12,12,12,12,13,12,12,12,12,13,13, - 12,12,12,13,12,12,12,12,12,12,12,12,13,12,13,12, - 12,12,12,13,12,12,13,12,13,12,13,13,12,13,12,12, - 12,12,12,12,13,13,13,12,12,12,12,13,12,12,13,13, - 13,13,12,13,13,13,12,11,11,11,12,12,11,12,12,12, - 12,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,13,12,12,13,13,13,11,12,12,12,12,12,12, - 12,12,13,12,12,12,13,12,12,13,12,13,13,12,13,12, - 13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,13,12,13,12,13,13,13,12,12,12,12,12,12, - 12,13,12,13,12,12,12,12,13,12,12,13,13,13,12,12, - 13,12,13,12,10,11,11,12,12,11,11,11,12,12,11,11, - 11,12,12,11,12,12,12,12,11,12,12,12,12,11,11,11, - 12,12,11,11,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,11,11,11,12,12,11,12,12,12,12, - 11,12,11,12,12,12,12,12,12,12,11,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,13,12,12,12,12,12,11,12,12,12,12,12,12,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,10,11,11,12,12,11,11,12,12,12,11,12,12,12,12, - 11,12,12,12,12,12,12,12,12,12,11,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,13,12,12, - 12,13,13,11,11,11,12,12,12,12,12,12,12,11,12,12, - 12,12,12,12,12,13,13,12,12,12,13,13,12,12,12,12, - 12,12,12,12,12,13,12,12,12,12,13,12,12,13,12,13, - 12,12,13,13,13,12,12,12,12,12,12,12,12,12,13,12, - 12,12,12,12,12,12,13,13,13,12,12,12,13,12,11,11, - 11,12,12,11,12,12,12,12,11,12,12,12,12,12,12,12, - 12,12,11,12,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,13,13,12,12,12,13,13, - 11,12,11,12,12,12,12,12,12,12,11,12,12,12,12,12, - 12,12,13,13,12,12,12,13,12,12,12,12,12,12,12,12, - 12,12,13,12,12,12,13,13,12,13,13,13,13,12,13,13, - 13,13,12,12,12,12,12,12,12,12,13,12,12,12,12,13, - 12,12,13,12,13,13,12,13,12,13,12,11,11,11,12,12, - 11,12,12,12,12,11,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,11,12,12,12,12,12,12,12,12,13,12,12, - 12,13,13,12,12,13,12,13,12,12,13,13,13,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, - 13,12,12,12,13,12,12,12,12,12,12,12,12,12,12,13, - 12,12,12,13,13,12,12,13,12,13,12,13,13,13,13,12, - 12,12,12,12,12,12,13,12,13,12,12,12,12,12,12,13, - 13,12,12,12,13,12,12,12,11,11,11,12,12,11,12,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,11,12,12,12,12,12,12,12,12,13,12,12,12,12,13, - 12,12,13,13,13,12,12,12,13,13,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,13,12,13,13,12,13, - 12,13,12,12,12,12,12,12,12,12,12,12,13,12,13,12, - 13,13,12,13,13,12,13,12,13,13,13,13,12,12,12,12, - 12,12,12,12,13,12,12,13,12,13,12,12,13,12,13,12, - 12,13,12,13,12, -}; - -static const static_codebook _44p8_p4_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p8_p4_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p8_p4_1, - 0 -}; - -static const long _vq_quantlist__44p8_p5_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p8_p5_0[] = { - 2, 6, 6, 9, 9, 5, 7, 8,10,11, 5, 8, 7,11,10, 8, - 10,11,12,13, 8,11,10,13,12, 6, 7, 8,10,11, 7, 8, - 10,10,12, 8, 9, 9,12,12,10,10,12,12,14,10,12,12, - 14,13, 6, 8, 7,11,10, 8, 9, 9,12,12, 7,10, 8,12, - 11,10,12,12,13,14,10,12,10,14,12, 9,10,11,11,13, - 10,10,11,11,13,11,12,12,13,14,12,12,13,11,15,13, - 14,14,15,14, 9,11,10,13,11,11,12,12,13,13,10,11, - 10,13,11,13,14,14,15,15,12,13,12,15,11, 6, 8, 9, - 11,12, 8, 9,11,12,13, 8,10,10,13,13,11,12,13,14, - 15,11,12,13,14,14, 9, 9,10,12,13,10,10,12,12,14, - 10,11,11,13,14,12,12,14,14,15,13,13,14,15,15, 9, - 10,10,13,13,10,11,11,13,14,10,11,10,14,13,13,13, - 14,15,15,12,14,13,15,14,12,12,13,13,14,12,13,14, - 13,15,13,14,14,15,15,14,14,15,14,16,15,15,15,16, - 16,12,13,13,14,14,13,14,14,15,15,12,14,13,15,14, - 14,15,15,16,16,14,15,14,16,14, 6, 9, 8,12,11, 8, - 10,10,13,13, 8,11, 9,13,12,11,12,12,14,14,11,13, - 12,15,14, 9,10,10,13,13,10,10,11,13,14,10,12,11, - 14,13,12,13,14,14,15,13,13,13,15,14, 9,10, 9,13, - 12,10,11,11,14,13,10,12,10,14,12,13,14,13,15,15, - 12,14,12,15,14,12,13,13,14,14,13,13,13,14,15,13, - 14,14,15,15,14,14,15,14,16,14,15,15,16,16,12,13, - 12,14,13,13,14,14,15,15,12,14,13,15,13,15,15,15, - 16,16,14,15,14,16,14,11,12,12,13,14,12,13,14,14, - 16,12,13,13,15,15,14,14,16,15,17,14,15,15,16,16, - 12,13,14,14,15,13,13,15,15,16,14,14,14,15,16,15, - 15,16,16,17,15,15,16,16,17,13,13,13,15,15,14,14, - 15,15,16,13,14,14,15,16,15,15,16,16,17,15,16,15, - 17,16,14,15,15,16,16,15,15,16,16,17,15,16,16,17, - 17,16,16,17,16,18,16,17,17,17,17,15,15,15,16,16, - 15,16,16,17,17,15,16,16,17,16,16,17,17,18,18,16, - 17,16,17,16,11,12,12,15,13,13,13,13,15,15,12,14, - 13,16,14,14,15,15,16,16,14,15,14,17,15,13,13,13, - 15,14,13,14,14,16,15,14,14,14,16,15,15,15,16,16, - 17,15,16,15,17,16,12,14,13,15,14,14,14,14,16,15, - 13,14,13,16,15,15,16,16,17,16,15,16,15,17,16,15, - 15,15,16,16,15,15,16,16,17,15,16,16,17,17,16,16, - 17,17,17,17,17,17,18,17,14,15,15,16,16,15,16,16, - 17,16,15,16,15,17,16,17,17,17,18,17,16,17,16,18, - 16, 6, 9, 9,12,12, 8,10,10,12,13, 8,10,10,13,12, - 10,12,12,14,15,11,13,12,15,14, 8, 9,10,12,13, 9, - 10,11,13,14,10,11,11,14,13,12,12,13,14,15,12,13, - 13,15,15, 8,10,10,13,13,10,11,11,13,14,10,12,10, - 14,13,12,13,13,15,15,12,14,13,15,14,11,12,12,13, - 14,12,12,13,13,15,12,13,13,15,15,14,13,15,14,16, - 14,15,15,16,16,12,13,13,14,14,13,13,14,15,14,12, - 14,13,15,14,14,15,15,16,15,14,15,14,16,14, 7, 9, - 10,12,12, 9,10,11,13,14, 9,11,10,13,13,11,12,13, - 14,15,12,13,13,15,14, 9,10,11,12,13,10,10,12,13, - 14,11,11,12,14,14,12,12,14,14,15,13,13,14,15,15, - 9,11,11,13,13,11,12,12,14,14,10,12,10,14,13,13, - 14,14,15,15,13,14,13,16,14,12,12,13,14,15,13,13, - 14,14,16,13,14,14,15,15,14,14,15,14,17,14,15,15, - 16,16,12,13,13,15,14,13,14,14,15,15,13,14,13,16, - 14,15,15,15,16,16,14,15,14,16,14, 7,10, 9,13,12, - 10,11,12,12,14,10,12,11,14,12,12,13,13,14,15,12, - 14,13,15,14, 9,11,10,13,13,10,11,12,13,14,12,13, - 12,15,13,13,13,14,13,15,13,14,14,16,15,10,11,11, - 13,13,12,12,13,14,14,11,12,11,14,13,14,14,14,15, - 16,13,14,13,16,13,12,13,13,14,14,12,13,13,14,15, - 14,14,14,15,15,14,13,15,13,16,15,15,15,17,16,13, - 13,13,14,14,14,14,14,15,15,12,13,13,15,14,15,16, - 16,16,16,14,15,14,16,13,11,12,13,14,15,12,13,14, - 15,16,13,14,14,15,15,14,14,15,15,17,14,15,15,16, - 16,13,13,14,14,15,13,13,15,14,16,14,14,15,15,16, - 15,14,16,15,17,15,16,16,16,17,13,14,14,15,15,14, - 14,15,16,16,13,15,14,16,16,15,16,16,17,17,15,16, - 15,17,16,14,15,15,15,17,15,15,16,15,17,15,16,16, - 16,17,16,16,17,16,18,17,17,17,17,18,15,15,15,17, - 16,15,16,16,17,17,15,16,16,17,16,16,17,17,18,18, - 16,17,16,18,17,11,13,12,15,14,13,13,14,15,15,13, - 14,13,16,14,15,15,15,16,16,15,16,15,17,16,13,14, - 13,15,14,13,13,14,15,15,14,15,14,16,15,15,15,16, - 16,16,15,16,15,18,16,13,14,14,15,15,14,15,15,15, - 16,13,15,13,16,15,15,16,16,17,17,15,16,15,17,16, - 15,15,15,16,16,15,15,15,16,17,16,16,16,17,16,16, - 16,17,16,17,17,17,17,18,17,15,15,15,16,16,16,16, - 16,17,17,15,16,15,17,16,17,17,17,18,18,16,17,16, - 17,15, 6, 9, 9,12,12, 8,10,10,12,13, 8,10,10,13, - 12,11,12,13,14,15,10,12,12,14,14, 9,10,10,13,13, - 10,10,12,13,14,10,11,11,14,13,12,13,14,14,15,12, - 13,13,15,15, 8,10, 9,13,12,10,11,11,13,14, 9,11, - 10,14,13,12,13,13,15,15,12,13,12,15,14,12,13,13, - 14,14,12,13,13,14,15,13,14,14,14,15,14,14,15,14, - 16,14,15,15,16,16,11,12,12,14,13,13,13,13,15,15, - 12,13,12,15,13,14,15,15,16,16,14,15,14,16,14, 7, - 9,10,12,13,10,10,12,12,14,10,12,11,14,13,12,13, - 14,14,15,12,13,13,15,14,10,11,11,13,13,11,11,12, - 13,14,12,13,12,14,14,13,13,14,13,16,14,14,14,15, - 15, 9,10,11,13,14,12,12,13,13,15,10,12,10,14,13, - 13,14,14,15,16,13,14,13,15,13,13,14,13,14,15,12, - 13,13,14,15,14,14,14,15,15,14,13,15,13,16,15,16, - 16,16,16,12,13,13,14,14,14,14,14,15,15,12,13,13, - 15,14,15,15,16,16,16,14,15,13,16,13, 7,10, 9,12, - 12, 9,10,11,13,13, 9,11,10,14,13,12,13,13,14,15, - 11,13,12,15,14, 9,11,11,13,13,10,10,12,13,14,11, - 12,12,14,14,13,13,14,14,16,13,14,14,16,15, 9,11, - 10,13,12,11,12,11,14,14,10,12,10,14,13,13,14,13, - 15,15,12,14,12,16,14,12,13,13,14,15,13,13,14,14, - 16,13,14,14,15,15,14,14,15,14,16,15,15,15,16,16, - 12,13,12,15,14,13,14,14,15,15,12,14,13,16,14,14, - 15,15,16,16,14,15,14,17,14,11,12,13,14,15,13,13, - 14,14,16,13,14,13,15,15,15,15,16,16,17,15,15,15, - 16,16,13,14,13,15,15,13,13,15,15,16,14,15,15,16, - 16,15,15,16,15,17,16,16,16,17,17,13,13,14,14,15, - 14,14,15,15,16,13,14,13,15,15,15,16,16,16,17,15, - 16,15,16,16,15,15,15,16,16,15,15,16,16,17,16,16, - 16,17,17,16,16,17,16,18,17,17,17,18,18,15,15,15, - 16,16,16,16,16,17,17,15,15,15,16,16,17,17,17,17, - 18,16,16,16,17,15,11,13,12,15,14,13,13,14,15,15, - 12,14,13,16,14,14,15,15,16,16,14,15,14,16,15,13, - 14,14,15,15,13,14,14,16,16,14,15,14,16,16,15,15, - 16,17,17,15,16,16,17,17,13,14,13,15,14,14,14,14, - 16,15,13,15,13,16,14,15,16,15,17,16,15,16,14,17, - 15,14,16,15,16,17,15,16,16,16,17,15,16,16,17,17, - 16,16,17,17,18,16,17,17,18,17,14,15,15,17,15,15, - 16,16,17,16,15,16,15,17,15,16,17,17,18,17,16,17, - 16,18,15,10,12,12,14,14,12,13,13,15,15,12,13,13, - 15,15,13,14,14,15,16,14,15,14,16,16,12,13,13,15, - 15,12,13,14,15,15,13,14,14,15,15,14,14,15,16,17, - 14,15,15,17,16,12,13,13,15,15,13,14,14,15,16,13, - 14,14,16,15,14,15,15,16,17,14,15,15,17,16,13,14, - 14,15,16,14,14,15,15,16,14,15,15,16,16,15,15,16, - 16,17,15,16,16,17,17,14,15,15,16,16,15,15,15,16, - 16,15,15,15,16,16,16,17,16,17,17,16,16,16,18,16, - 11,12,12,14,14,12,13,14,15,15,12,13,13,15,15,13, - 14,15,16,16,14,15,15,16,16,12,13,13,15,15,13,13, - 14,15,16,13,14,14,15,16,14,14,15,16,17,15,15,15, - 16,17,12,13,13,15,15,13,14,14,15,16,13,14,14,16, - 15,15,15,15,16,17,15,16,15,17,16,14,14,15,15,16, - 14,14,15,15,17,15,15,16,16,17,15,15,16,15,18,16, - 16,16,17,17,14,15,15,16,16,15,16,16,17,17,15,15, - 15,17,16,16,17,16,17,17,16,16,16,18,16,11,12,12, - 14,14,13,13,14,15,15,13,14,13,15,15,14,15,15,16, - 16,14,15,15,16,16,12,13,13,15,15,13,13,14,15,15, - 14,14,14,16,15,15,15,15,15,16,15,16,15,17,16,12, - 13,13,15,15,14,14,15,15,16,13,14,13,16,15,15,15, - 16,16,17,15,16,15,17,15,14,15,14,16,16,14,15,15, - 16,16,15,16,15,17,16,15,15,16,15,17,16,17,16,17, - 17,14,15,15,16,16,15,16,16,16,17,14,15,15,16,16, - 16,17,17,17,18,16,16,16,17,16,12,13,13,15,15,13, - 13,14,15,16,13,14,14,16,15,14,15,15,16,17,14,15, - 15,17,16,13,14,14,15,16,14,14,15,15,17,14,15,15, - 16,16,15,14,16,15,17,15,16,16,17,17,13,14,14,16, - 16,14,15,15,16,16,14,15,14,16,16,15,16,16,17,17, - 15,16,15,17,16,15,15,16,15,17,15,15,16,15,17,15, - 16,16,16,17,16,15,17,15,18,17,17,17,17,17,15,15, - 15,17,17,16,16,16,17,17,15,16,15,17,17,16,17,17, - 18,18,16,17,15,18,15,11,12,12,15,15,13,13,15,14, - 16,13,14,13,16,14,15,15,16,16,17,15,16,15,17,15, - 12,14,13,16,14,13,13,14,14,16,14,15,14,16,15,15, - 15,16,15,17,16,16,16,17,16,12,13,14,15,16,15,15, - 15,15,16,13,15,13,16,14,16,16,16,17,17,15,16,15, - 17,15,15,16,15,16,15,14,14,15,16,16,16,16,16,17, - 16,15,15,16,15,17,17,17,17,18,17,15,15,15,16,16, - 16,16,16,16,17,14,15,15,17,16,17,17,17,17,18,15, - 16,15,18,14,10,12,12,14,14,12,13,13,15,15,12,13, - 13,15,15,14,14,15,15,16,13,15,14,16,16,12,13,13, - 15,15,13,14,14,15,16,13,14,14,15,15,14,15,15,16, - 17,14,15,15,17,16,12,13,13,15,15,13,14,14,15,15, - 12,14,13,15,15,14,15,15,16,17,14,15,14,17,15,14, - 15,15,16,16,14,15,15,16,17,15,15,15,17,16,16,16, - 16,16,17,16,16,16,17,17,13,14,14,16,15,14,15,15, - 16,16,14,15,14,16,16,15,16,16,17,17,15,16,15,17, - 16,11,12,12,14,15,13,13,14,14,15,13,14,13,15,15, - 14,15,15,16,16,14,15,15,16,16,12,14,13,15,15,13, - 13,14,15,16,14,15,14,16,15,15,15,16,15,17,15,16, - 16,17,16,12,13,13,15,15,14,14,15,15,16,13,14,13, - 16,15,15,15,16,16,17,15,15,15,16,16,14,15,15,16, - 16,14,15,15,16,16,15,16,16,17,17,16,16,16,16,17, - 16,17,17,18,17,14,14,15,15,16,15,15,16,16,17,14, - 15,15,16,16,16,16,16,17,17,15,16,15,17,15,11,12, - 12,14,14,12,13,14,15,15,12,13,13,15,15,14,15,15, - 16,16,13,15,14,16,16,12,13,13,15,15,13,14,14,15, - 16,13,14,14,16,16,15,15,15,16,17,15,15,15,17,16, - 12,13,13,15,15,13,14,14,16,15,13,14,13,16,15,15, - 16,15,17,17,14,15,14,17,16,14,15,15,16,16,15,15, - 16,16,17,15,16,16,17,17,16,16,16,16,18,16,17,16, - 18,17,14,15,14,16,15,15,15,15,17,16,14,15,14,17, - 15,16,17,16,17,17,15,16,15,17,15,11,12,12,15,15, - 13,13,15,14,16,13,15,13,16,14,15,15,16,15,17,15, - 16,15,17,16,12,14,13,15,15,13,13,15,15,16,15,15, - 15,16,15,15,15,16,15,17,16,16,16,17,16,12,13,14, - 15,16,14,14,15,15,16,13,14,13,16,14,16,16,16,16, - 17,15,16,15,17,15,15,16,15,16,16,14,15,15,16,16, - 16,16,16,17,16,15,15,16,15,17,17,17,17,18,17,15, - 15,15,15,16,16,16,16,16,17,14,15,14,16,15,17,17, - 17,17,18,15,16,15,17,15,12,13,13,15,15,13,14,14, - 15,16,13,14,14,16,15,14,15,15,16,17,14,15,15,17, - 16,13,14,14,16,15,13,14,15,16,16,14,15,15,16,16, - 15,15,16,16,17,15,16,16,17,17,13,14,13,16,15,14, - 15,15,16,16,13,15,14,16,15,15,16,16,17,17,15,16, - 14,17,15,15,15,16,17,17,15,15,16,16,17,16,16,16, - 17,17,16,15,17,16,18,17,17,17,18,18,15,15,15,17, - 14,16,16,16,17,16,15,16,15,17,15,16,17,17,18,17, - 16,17,15,18,15, -}; - -static const static_codebook _44p8_p5_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p8_p5_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p8_p5_0, - 0 -}; - -static const long _vq_quantlist__44p8_p5_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p8_p5_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p8_p5_1 = { - 1, 7, - (char *)_vq_lengthlist__44p8_p5_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p8_p5_1, - 0 -}; - -static const long _vq_quantlist__44p8_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p8_p6_0[] = { - 2, 6, 6, 5, 7, 7, 5, 7, 7, 5, 7, 7, 7, 7, 9, 7, - 9, 9, 6, 7, 7, 8, 9, 9, 7, 9, 7, 6, 8, 8, 8, 9, - 10, 8, 9, 9, 8, 9,10, 9, 9,10,10,10,10, 8, 9, 9, - 10,10,11, 9,10,10, 6, 8, 8, 8, 9, 9, 8,10, 9, 8, - 9, 9, 9,10,10,10,11,10, 8,10, 9,10,11,10, 9,11, - 9, 6, 8, 8, 7, 9, 9, 7, 9, 9, 7, 9, 9, 8, 9,10, - 9,10,10, 8, 9, 9, 9,10,10, 9,10, 9, 7, 9, 9, 9, - 9,10, 9,10,10, 9, 9,10,10, 9,11,10,11,11, 9,10, - 10,10,11,11,10,11,10, 6, 9, 8, 9, 9,10, 9,10, 9, - 8,10,10, 9, 9,10,10,11,11, 9,10,10,10,11,11, 9, - 11, 9, 6, 8, 8, 7, 9, 9, 7, 9, 9, 8, 9, 9, 9, 9, - 10, 9,10,10, 7, 9, 9, 9,10,10, 8,10, 9, 6, 8, 9, - 9, 9,10, 9,10, 9, 9,10,10, 9, 9,11,10,11,11, 8, - 9,10,10,11,11, 9,10, 9, 7, 9, 9, 9,10,10, 9,10, - 9, 9,10,10,10,10,11,10,11,11, 9,10, 9,10,11,11, - 10,11, 9, -}; - -static const static_codebook _44p8_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p8_p6_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p8_p6_0, - 0 -}; - -static const long _vq_quantlist__44p8_p6_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p8_p6_1[] = { - 4, 7, 7, 7, 7, 8, 7, 8, 7, 7, 7, 8, 7, 8, 8, 8, - 8, 8, 7, 8, 7, 8, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 9, 8, 8, 8, - 8, 9, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 9, - 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 8, 8, 9, 8, 8, 8, 8, 9, 9, 8, 9, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, 8, - 8, 8, 9, 9, 8, 9, 9, 7, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 8, 9, 8, 8, 8, 8, 8, 9, 9, 8, - 9, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 9, 8, 9, 9, 8, 8, 8, 8, 9, 8, 8, 9, 8, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, - 8, 8, 8, 9, 9, 8, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 8, 9, 9, 8, 8, 8, 8, 9, 9, - 8, 9, 8, -}; - -static const static_codebook _44p8_p6_1 = { - 5, 243, - (char *)_vq_lengthlist__44p8_p6_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p8_p6_1, - 0 -}; - -static const long _vq_quantlist__44p8_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p8_p7_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p8_p7_0 = { - 5, 243, - (char *)_vq_lengthlist__44p8_p7_0, - 1, -512202240, 1635281408, 2, 0, - (long *)_vq_quantlist__44p8_p7_0, - 0 -}; - -static const long _vq_quantlist__44p8_p7_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p8_p7_1[] = { - 1, 7, 7,12,12, 5,11,12,12,12, 5,12,11,12,12,12, - 12,12,12,12,12,13,13,13,13, 7,11,11,13,13,13,12, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13, 7,13,10,13,13,13,13,13,13,13,12,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13, 7,13,12, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,12, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13, 8,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,12,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,12,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13, 8,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,12,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,10,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13, 8,13,12,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,11, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,11,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13, -}; - -static const static_codebook _44p8_p7_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p8_p7_1, - 1, -514619392, 1630767104, 3, 0, - (long *)_vq_quantlist__44p8_p7_1, - 0 -}; - -static const long _vq_quantlist__44p8_p7_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p8_p7_2[] = { - 1, 3, 2, 4, 5, 7, 7, 8, 8, 9, 9,10,10,11,11,12, - 12,13,13,14,14,15,15,15,15, -}; - -static const static_codebook _44p8_p7_2 = { - 1, 25, - (char *)_vq_lengthlist__44p8_p7_2, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p8_p7_2, - 0 -}; - -static const long _vq_quantlist__44p8_p7_3[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p8_p7_3[] = { - 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p8_p7_3 = { - 1, 25, - (char *)_vq_lengthlist__44p8_p7_3, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p8_p7_3, - 0 -}; - -static const char _huff_lengthlist__44p8_short[] = { - 3, 9,15,17,20,21,22,23, 5, 5, 7, 9,11,13,17,20, - 9, 5, 5, 6, 8,10,15,18,11, 7, 5, 4, 6, 9,13,17, - 14, 9, 7, 5, 6, 7,10,14,17,10, 8, 6, 6, 4, 5, 8, - 20,14,13,10, 8, 4, 3, 4,23,17,16,14,12, 6, 4, 4, -}; - -static const static_codebook _huff_book__44p8_short = { - 2, 64, - (char *)_huff_lengthlist__44p8_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p9_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44p9_l0_0[] = { - 2, 5, 5, 7, 6, 8, 8, 9, 9,10,10,11,11, 4, 5, 5, - 6, 7, 8, 8, 9, 9,10,10,11,10, 4, 5, 5, 7, 6, 8, - 8, 9, 9,10,10,10,10, 6, 6, 7, 6, 7, 8, 8, 9, 9, - 10, 9,11, 9, 6, 6, 6, 7, 6, 8, 8, 9, 9, 9,10, 9, - 11, 7, 7, 8, 8, 8, 8, 9, 9, 9,10, 9,11, 9, 7, 8, - 8, 8, 8, 9, 8, 9, 9, 9,10, 9,11, 8, 9, 9, 9, 9, - 9, 9,10,10,11,10,12,10, 8, 9, 9, 9, 9, 9, 9,10, - 9,10,11,11,12, 9,10,10,10,10,10,10,10,11,11,11, - 11,12, 9,10,10,10,10,11,10,11,10,11,11,12,11,11, - 11,11,11,11,11,11,11,12,11,12,11,12,11,11,11,11, - 11,11,11,12,11,12,11,12,11, -}; - -static const static_codebook _44p9_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44p9_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44p9_l0_0, - 0 -}; - -static const long _vq_quantlist__44p9_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p9_l0_1[] = { - 4, 4, 4, 5, 5, 4, 4, 5, 5, 5, 4, 5, 4, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p9_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44p9_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p9_l0_1, - 0 -}; - -static const long _vq_quantlist__44p9_l1_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p9_l1_0[] = { - 1, 2, 3, 5, 9, 9, 4, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _44p9_l1_0 = { - 2, 25, - (char *)_vq_lengthlist__44p9_l1_0, - 1, -514619392, 1630767104, 3, 0, - (long *)_vq_quantlist__44p9_l1_0, - 0 -}; - -static const char _huff_lengthlist__44p9_lfe[] = { - 1, 1, -}; - -static const static_codebook _huff_book__44p9_lfe = { - 1, 2, - (char *)_huff_lengthlist__44p9_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44p9_long[] = { - 3, 3, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _huff_book__44p9_long = { - 1, 8, - (char *)_huff_lengthlist__44p9_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44p9_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p9_p1_0[] = { - 1, 5, 5, 4, 8, 8, 4, 8, 8, 5, 7, 8, 8, 9,10, 8, - 10,10, 5, 8, 7, 8,10,10, 8,10, 9, 7, 9, 9, 9,11, - 11, 9,11,11, 9,11,11,11,12,13,11,13,13, 9,11,11, - 11,13,13,11,13,13, 7, 9, 9, 9,11,11, 9,11,11, 9, - 11,11,11,13,13,11,13,13, 9,11,11,11,13,13,11,13, - 12, 5, 9, 9, 9,11,11, 9,11,11, 9,11,11,11,12,13, - 11,13,13, 9,11,11,11,13,13,11,13,13, 9,11,12,11, - 13,13,12,13,13,11,12,13,13,14,15,13,14,14,12,13, - 13,13,15,15,13,15,14, 8,10,10,11,13,13,12,14,13, - 11,12,12,13,14,15,13,15,15,11,12,12,13,15,15,13, - 15,14, 5, 9, 9, 9,11,11, 9,11,11, 9,11,11,11,13, - 13,11,13,13, 9,11,10,11,13,13,11,13,12, 8,10,10, - 11,13,13,12,13,13,11,12,12,13,14,15,14,15,15,10, - 12,12,13,14,15,13,15,14, 9,12,11,12,13,13,11,13, - 13,12,13,13,13,15,15,13,14,15,11,13,12,13,15,14, - 13,15,14, -}; - -static const static_codebook _44p9_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44p9_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p9_p1_0, - 0 -}; - -static const long _vq_quantlist__44p9_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p9_p2_0[] = { - 4, 6, 6, 8, 8, 5, 7, 7, 9, 9, 5, 7, 7, 9, 9, 6, - 8, 8,11,11, 6, 8, 8,11,11, 6, 7, 7, 9, 9, 7, 8, - 9,10,11, 7, 9, 9,11,10, 8, 9,10,12,12, 8,10,10, - 12,12, 6, 7, 7, 9, 9, 7, 9, 9,10,10, 7, 9, 8,11, - 10, 8,10,10,12,12, 8,10, 9,12,12, 8, 9, 9,11,11, - 9,10,10,12,12, 9,11,11,12,13,11,12,12,13,14,11, - 12,12,14,14, 8, 9, 9,11,11, 9,11,10,13,12, 9,10, - 10,13,12,11,12,12,14,14,11,12,12,14,13, 7, 8, 9, - 10,10, 8,10,10,11,11, 8,10,10,11,11,10,11,11,13, - 13,10,11,11,13,13, 8, 9,10,10,11,10,11,11,12,13, - 10,11,11,12,12,11,11,12,13,14,11,12,12,14,14, 8, - 10,10,11,11,10,11,11,12,13,10,11,11,12,12,11,12, - 12,14,14,11,12,12,14,14,10,11,11,12,13,11,12,12, - 13,14,12,13,13,14,14,13,13,14,14,16,13,14,14,15, - 16,10,11,11,13,13,12,12,12,14,14,11,12,12,14,14, - 13,14,14,15,16,13,14,14,16,15, 7, 8, 8,10,10, 8, - 10,10,11,11, 8,10,10,12,11,10,11,11,13,13,10,11, - 11,13,13, 8,10,10,11,11,10,11,11,12,12,10,11,11, - 12,12,11,12,12,14,14,11,12,12,14,14, 8,10, 9,11, - 10,10,11,11,13,12,10,11,10,13,12,11,12,12,14,14, - 11,12,11,14,13,10,11,11,13,13,11,12,12,14,14,12, - 12,12,14,14,13,14,14,15,16,13,14,14,15,15,10,11, - 11,13,12,12,12,12,14,14,11,12,12,14,13,13,14,14, - 16,15,13,14,13,16,14,10,11,11,13,13,12,12,13,14, - 15,12,13,13,14,15,13,14,15,15,16,13,14,14,16,16, - 11,12,13,14,14,13,13,14,15,16,13,14,14,15,16,14, - 15,15,16,17,14,15,16,17,17,11,12,12,14,14,13,14, - 14,15,16,13,14,14,15,15,14,15,15,16,18,14,15,15, - 17,16,13,14,15,15,16,15,15,16,16,18,15,15,15,17, - 17,16,16,17,17,18,16,16,16,18,18,14,14,14,16,16, - 15,15,15,16,17,15,15,15,16,17,16,17,17,18,18,16, - 16,17,18,17,10,11,11,14,13,12,13,13,15,14,11,13, - 13,15,14,13,15,15,16,16,13,14,14,16,16,11,12,12, - 14,14,13,13,13,15,15,13,14,13,15,15,15,15,15,17, - 16,14,15,15,17,16,11,13,12,14,14,13,14,13,15,15, - 13,14,13,15,15,14,15,15,17,17,14,15,15,17,16,14, - 14,14,16,16,14,15,15,17,17,15,15,16,17,16,17,16, - 17,18,18,16,17,17,18,18,13,14,14,16,15,15,15,15, - 17,17,14,16,15,16,16,17,17,17,18,18,16,17,16,20, - 19, 6, 8, 8,10,10, 8,10,10,11,11, 8,10,10,12,11, - 10,11,11,13,13,10,11,11,13,13, 8, 9,10,11,11,10, - 11,11,12,12,10,11,11,13,12,11,12,12,14,14,11,12, - 12,14,14, 9,10,10,11,11,10,11,11,12,12,10,11,11, - 13,12,11,12,12,14,14,11,12,12,14,14,10,10,11,12, - 13,11,12,12,14,14,11,12,12,14,14,13,14,14,15,16, - 13,14,14,15,16,10,11,11,13,13,12,12,12,14,14,12, - 13,12,14,14,13,14,14,16,16,13,14,14,15,15, 9,10, - 10,11,12,10,11,11,12,13,10,11,11,13,12,11,12,12, - 14,14,11,12,12,14,14,10,10,11,12,13,11,12,12,13, - 14,11,12,12,13,14,12,13,14,14,15,12,13,13,15,15, - 10,11,11,13,13,11,12,12,13,14,11,12,12,14,13,12, - 13,13,15,15,12,13,13,15,15,12,11,13,12,14,13,13, - 14,14,15,13,13,14,14,15,14,15,15,16,17,14,15,15, - 16,17,12,13,12,14,14,13,14,14,15,15,13,14,14,15, - 15,14,15,15,16,17,14,15,15,16,17, 8, 9, 9,11,11, - 10,11,11,12,13,10,11,11,13,12,12,13,13,14,15,11, - 13,12,15,14, 9,11,10,12,12,11,12,12,13,14,11,12, - 12,14,13,13,13,14,15,15,13,14,13,15,15, 9,11,11, - 12,12,11,12,12,14,14,11,12,12,14,13,13,14,14,15, - 16,13,14,13,15,14,11,12,12,14,13,12,13,13,14,15, - 13,14,14,16,15,15,15,15,15,16,15,16,15,17,17,11, - 12,12,14,14,13,14,14,15,15,12,13,13,15,14,15,15, - 15,17,17,14,15,15,17,15,11,12,12,14,14,12,13,13, - 15,15,12,13,13,15,15,14,15,15,17,17,14,15,15,16, - 16,12,13,13,14,15,13,14,14,16,16,14,14,14,15,16, - 15,16,16,17,17,15,16,16,17,17,12,13,13,15,15,14, - 14,14,16,16,14,14,15,16,16,15,16,16,17,17,15,16, - 16,17,17,14,15,15,15,16,15,15,16,16,18,15,16,16, - 17,17,17,17,17,18,18,16,17,17,19,18,14,15,15,16, - 17,15,16,16,17,17,15,16,16,18,17,16,17,17,19,18, - 17,17,17,19,18,10,12,12,14,14,13,13,14,15,15,12, - 14,13,16,15,15,15,15,17,17,14,15,15,17,16,12,13, - 13,15,14,13,14,14,16,16,14,14,15,17,16,15,16,16, - 17,17,15,16,16,18,17,12,13,13,15,14,14,15,15,16, - 16,13,15,14,16,15,16,17,16,19,17,15,16,16,17,17, - 14,15,15,17,15,15,16,15,17,17,16,17,16,18,17,17, - 17,18,18,18,17,17,18,19,18,14,15,15,16,16,15,16, - 16,17,18,15,16,16,18,16,17,18,18,19,19,17,18,17, - 18,19, 6, 8, 8,10,10, 8,10,10,11,11, 8,10,10,12, - 11,10,11,11,13,13, 9,11,11,13,13, 9,10,10,11,11, - 10,11,11,12,12,10,11,11,12,12,11,12,12,14,14,11, - 12,12,14,14, 8,10, 9,11,11,10,11,11,12,12,10,11, - 11,12,12,11,12,12,14,14,11,12,12,14,14,10,11,11, - 13,13,11,12,13,14,14,12,12,12,14,14,13,14,14,15, - 16,13,14,14,16,16,10,11,10,13,12,11,12,12,14,14, - 11,12,12,14,14,13,14,14,15,16,13,14,14,16,15, 8, - 9, 9,11,11,10,11,11,12,13,10,11,11,13,12,12,13, - 13,14,15,12,13,13,15,14,10,11,11,12,12,11,11,12, - 13,14,11,12,12,14,14,13,13,14,15,16,13,14,14,15, - 15, 9,10,11,12,12,11,12,12,13,14,11,12,12,14,13, - 13,14,14,15,16,12,14,13,15,15,11,12,12,14,14,12, - 13,13,14,15,13,14,14,16,15,14,15,15,15,17,15,15, - 16,16,17,11,12,12,13,14,13,14,14,15,15,12,13,13, - 15,14,15,16,15,16,17,14,16,15,17,15, 9,10,10,12, - 11,10,11,11,13,13,10,11,11,13,12,11,12,12,14,14, - 11,12,12,14,14,10,11,11,12,13,11,12,12,13,14,11, - 12,12,14,14,12,13,13,15,15,12,13,13,15,15,10,11, - 10,13,12,11,12,12,13,13,11,12,12,14,13,12,13,13, - 15,15,12,13,13,15,14,12,13,12,14,14,13,14,14,15, - 15,13,14,14,15,15,14,15,15,16,16,14,15,15,16,16, - 11,13,11,14,12,13,13,13,15,14,12,14,13,15,14,15, - 15,15,17,16,14,15,14,17,15,10,12,12,14,14,13,13, - 14,15,16,12,14,13,15,15,14,15,16,17,17,14,15,16, - 17,17,12,13,13,14,15,13,14,14,16,16,14,14,15,16, - 16,16,16,16,17,17,16,16,16,18,18,12,13,13,14,15, - 14,14,15,16,16,13,14,14,16,15,16,16,16,17,18,15, - 16,16,17,17,14,15,15,16,16,15,15,16,17,17,15,16, - 16,17,18,17,18,18,18,19,17,18,18,19,19,14,15,15, - 16,16,15,16,16,17,17,15,16,16,17,17,17,17,18,20, - 18,17,18,17,18,18,11,12,12,14,14,12,13,14,15,15, - 12,13,13,15,15,14,15,15,16,17,14,15,15,16,17,12, - 13,13,15,15,14,14,14,16,16,14,14,14,16,16,15,16, - 16,17,17,15,16,16,17,17,12,13,13,15,14,13,14,14, - 16,15,14,15,14,16,15,15,16,16,17,17,15,16,16,17, - 16,14,15,15,16,16,15,16,16,17,17,16,16,16,17,17, - 17,17,17,19,18,17,17,17,18,19,14,15,14,17,15,15, - 16,16,17,17,15,16,15,17,17,16,17,17,18,18,16,17, - 17,18,17, 6,11,11,13,13,11,12,12,14,14,11,12,12, - 14,14,13,14,14,16,16,13,14,14,16,16,11,12,12,14, - 14,12,13,13,15,15,12,13,13,15,15,14,15,15,16,17, - 14,15,15,17,18,11,12,12,14,14,12,13,13,15,15,12, - 13,13,15,15,14,15,15,17,17,14,15,15,16,16,13,14, - 14,15,16,14,15,15,16,17,14,15,15,17,16,15,16,17, - 18,17,16,16,16,18,17,14,14,15,16,16,14,15,15,18, - 16,14,15,15,17,16,16,17,17,18,18,16,17,16,18,17, - 11,12,12,14,14,12,13,13,15,15,12,13,13,15,15,14, - 15,15,17,17,14,15,15,16,16,12,13,13,15,15,13,14, - 14,15,16,13,14,14,16,16,15,16,16,17,17,15,15,16, - 17,17,12,13,13,15,15,14,14,14,16,16,13,14,14,16, - 16,15,16,16,17,17,15,16,16,17,17,14,14,15,15,16, - 15,15,16,16,17,15,15,16,16,17,16,17,17,17,18,16, - 17,17,18,18,14,15,15,16,16,15,16,16,17,17,15,16, - 16,17,17,17,17,17,18,19,17,17,17,18,18,10,12,12, - 14,14,12,13,14,15,16,13,14,13,15,15,14,15,15,17, - 17,14,15,16,17,17,12,13,13,15,15,13,14,14,15,15, - 14,15,14,16,16,15,16,16,17,18,15,17,16,18,17,12, - 13,13,15,15,14,14,14,16,16,13,14,14,16,15,15,16, - 16,17,18,15,16,16,17,17,14,14,14,16,16,15,15,16, - 17,17,15,16,16,17,17,17,17,17,18,20,17,17,17,19, - 19,14,15,15,16,16,15,17,16,18,18,15,16,15,17,16, - 17,18,19,19,19,17,17,17,18,17,13,14,14,16,16,14, - 15,15,17,17,14,15,15,16,17,15,17,17,18,18,16,16, - 17,18,17,14,15,15,16,17,15,16,16,17,17,15,16,16, - 17,17,16,17,17,18,18,17,17,17,18,19,14,15,15,16, - 17,15,16,16,17,17,15,16,16,17,17,16,17,17,18,18, - 17,17,17,19,19,16,16,16,16,18,16,17,17,17,18,17, - 17,17,17,19,18,18,18,19,19,18,18,18,19,20,16,16, - 17,18,18,16,18,17,18,18,17,17,17,20,19,18,18,19, - 21,20,18,20,18,18,19,10,12,12,14,14,14,14,15,15, - 17,14,15,14,17,15,16,16,17,18,18,16,18,17,19,18, - 12,14,13,16,15,14,14,15,15,17,15,16,16,18,17,16, - 17,18,17,19,17,19,18,20,19,12,13,13,15,15,15,16, - 17,17,18,14,16,14,17,16,17,18,18,19,19,17,17,17, - 18,18,15,15,15,17,16,15,16,16,17,17,17,19,17,18, - 18,18,18,18,18,21,19,20,19,20,19,15,15,16,16,17, - 17,17,18,20,20,15,16,16,18,17,18,19,19,19,20,18, - 19,18,19,17, 6,11,11,13,13,11,12,12,14,14,11,12, - 12,14,14,13,14,14,16,16,13,14,14,16,16,11,12,12, - 14,14,12,13,13,15,15,12,13,13,15,15,14,15,15,17, - 17,14,15,15,17,16,11,12,12,14,14,12,13,13,15,15, - 12,13,13,15,15,14,15,15,16,16,14,15,15,16,16,13, - 14,14,16,16,15,15,15,16,16,14,15,15,17,16,16,17, - 17,19,18,16,17,17,18,18,13,14,14,15,15,14,15,15, - 17,16,14,15,15,17,16,16,17,16,17,18,15,16,16,18, - 18,10,12,12,14,14,12,13,14,15,15,12,13,13,15,15, - 14,15,15,17,17,14,15,15,17,16,12,13,13,15,15,14, - 14,14,15,16,14,15,15,16,16,15,16,16,17,18,16,16, - 16,18,18,12,13,13,14,14,14,14,15,16,16,13,14,14, - 16,16,15,16,16,18,18,15,16,16,19,17,14,15,15,16, - 17,15,15,16,17,17,16,17,16,17,18,17,17,18,17,19, - 17,17,18,18,19,14,14,14,16,16,15,16,16,17,17,15, - 16,15,17,17,17,17,17,19,20,16,17,17,18,18,11,12, - 12,14,14,12,13,13,15,15,12,13,13,15,15,14,15,15, - 16,16,14,15,14,16,16,12,13,13,15,15,14,14,14,16, - 16,13,14,14,16,16,15,16,16,18,17,15,16,16,17,17, - 12,13,13,15,15,13,14,14,16,16,13,14,14,16,16,15, - 16,15,18,18,15,16,15,17,16,14,15,15,16,16,15,16, - 16,17,17,15,16,16,18,17,16,17,17,18,18,16,17,17, - 18,18,14,15,14,16,15,15,16,15,17,17,15,16,15,17, - 16,16,17,17,18,18,17,17,16,19,17,10,12,12,14,15, - 14,14,15,15,17,14,15,14,17,15,16,17,17,17,18,16, - 17,17,18,18,12,14,13,16,15,14,14,16,15,17,15,17, - 16,18,17,17,17,18,17,19,18,18,18,19,18,12,13,14, - 15,15,15,16,16,16,17,14,15,14,18,16,18,17,18,19, - 19,17,18,17,20,18,15,15,15,17,17,15,16,16,17,18, - 18,18,18,19,18,18,18,19,18,20,18,19,19,21,21,15, - 15,16,16,17,17,18,18,18,18,15,16,16,17,17,17,19, - 20,19,20,17,18,18,19,17,13,14,14,16,16,14,15,15, - 16,17,14,15,15,17,17,16,16,17,17,18,15,17,16,17, - 17,14,15,15,16,16,15,16,16,17,17,16,16,16,17,17, - 17,17,18,17,18,17,17,17,18,20,14,15,15,17,16,15, - 16,16,17,17,15,16,16,17,17,17,17,17,18,18,16,17, - 17,19,18,16,16,17,17,17,17,18,17,19,18,17,17,17, - 18,19,17,20,18,19,21,17,19,18,19,20,15,17,15,17, - 16,16,17,17,18,18,17,17,17,18,17,18,19,18,19,21, - 18,18,17,19,19, -}; - -static const static_codebook _44p9_p2_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p9_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p9_p2_0, - 0 -}; - -static const long _vq_quantlist__44p9_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p9_p3_0[] = { - 2, 5, 4, 4, 7, 7, 4, 7, 6, 5, 6, 7, 7, 8, 9, 7, - 9, 9, 5, 7, 6, 7, 9, 9, 7, 9, 8, 6, 8, 8, 8,10, - 10, 8,10,10, 8, 9,10,10,11,12,10,12,12, 8,10,10, - 10,12,12,10,12,11, 6, 8, 8, 8,10,10, 8,10,10, 8, - 10,10,10,11,12,10,12,12, 8,10, 9,10,12,11,10,12, - 11, 5, 8, 8, 8,10,10, 8,10,10, 8, 9,10,10,11,11, - 10,11,11, 8,10,10,10,11,12,10,12,11, 8,10,10,10, - 11,11,10,11,11,10,11,11,11,12,13,11,12,13,10,11, - 11,11,13,13,11,13,13, 7, 9, 9,10,11,12,10,12,11, - 9,11,11,11,12,13,12,14,13, 9,11,11,12,13,14,11, - 13,12, 5, 8, 8, 8,10,10, 8,10,10, 8,10,10,10,11, - 12,10,12,12, 8,10, 9,10,12,11, 9,11,11, 7, 9, 9, - 10,11,12,10,12,11, 9,11,11,11,12,13,12,14,13, 9, - 11,11,12,13,14,11,13,12, 8,10,10,10,11,11,10,11, - 11,10,11,11,11,13,13,11,13,13,10,11,10,11,13,12, - 11,13,12, -}; - -static const static_codebook _44p9_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44p9_p3_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44p9_p3_0, - 0 -}; - -static const long _vq_quantlist__44p9_p3_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p9_p3_1[] = { - 4, 6, 6, 6, 7, 7, 6, 7, 7, 6, 7, 7, 7, 7, 8, 7, - 7, 8, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 8, 9, 9, 8, 8, 8, - 8, 9, 9, 8, 9, 9, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 9, 9, 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, - 9, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, - 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, 9, 8, 8, 8, 8, - 9, 9, 8, 9, 9, 8, 8, 9, 9, 9, 9, 9, 9, 9, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 7, 8, 8, 8, 9, 9, 8, 9, 9, - 8, 9, 8, 9, 9, 9, 9, 9, 9, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 9, 8, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, 9, 7, 8, 8, - 8, 9, 9, 8, 9, 9, 8, 8, 9, 9, 9, 9, 9, 9, 9, 8, - 8, 8, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 9, 9, 8, 9, - 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 8, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44p9_p3_1 = { - 5, 243, - (char *)_vq_lengthlist__44p9_p3_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44p9_p3_1, - 0 -}; - -static const long _vq_quantlist__44p9_p4_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p9_p4_0[] = { - 2, 5, 5, 4, 7, 7, 4, 7, 6, 5, 7, 7, 7, 8, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 7, 9, 8, 6, 7, 8, 8, 9, - 10, 8,10,10, 8, 9,10,10,11,12,10,11,12, 8,10,10, - 10,11,12,10,12,11, 6, 8, 7, 8,10,10, 8,10, 9, 8, - 10,10,10,11,12,10,12,12, 8,10, 9,10,12,11,10,12, - 11, 5, 8, 8, 8,10,10, 8,10,10, 7, 9,10, 9,10,11, - 10,11,11, 8,10,10,10,12,12,10,12,11, 7, 9, 9, 9, - 11,11, 9,11,11, 9,10,11,11,11,12,11,12,12, 9,11, - 11,11,12,12,11,12,12, 7, 9, 9,10,11,12,10,12,11, - 9,11,10,11,11,12,12,13,13, 9,11,11,12,13,13,11, - 13,11, 5, 8, 8, 8,10,10, 8,10,10, 8,10,10,10,11, - 12,10,12,12, 7, 9, 9, 9,11,11, 9,11,10, 7, 9, 9, - 10,11,12,10,12,11, 9,11,11,11,11,13,12,13,13, 9, - 10,11,12,13,13,11,12,11, 7, 9, 9, 9,11,11, 9,11, - 11, 9,11,11,11,12,12,11,12,12, 9,11,10,11,12,12, - 10,12,11, -}; - -static const static_codebook _44p9_p4_0 = { - 5, 243, - (char *)_vq_lengthlist__44p9_p4_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44p9_p4_0, - 0 -}; - -static const long _vq_quantlist__44p9_p4_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p9_p4_1[] = { - 6, 8, 8,10, 9, 8, 9, 9,10,10, 8, 9, 9,10,10, 8, - 10,10,10,10, 8,10,10,10,10, 9, 9, 9,10,10, 9,10, - 10,10,11, 9,10,10,11,11,10,10,10,11,11,10,10,10, - 11,11, 9, 9, 9,10,10, 9,10,10,11,11, 9,10,10,11, - 10,10,10,10,11,11,10,10,10,11,11,10,10,10,10,11, - 10,10,11,11,11,10,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,10,10,10,11,10,10,11,11,11,11,10,11, - 10,11,11,11,11,11,11,11,10,11,11,11,11, 9,10,10, - 10,11,10,10,11,11,11,10,11,11,11,11,10,11,11,11, - 11,10,11,11,11,11,10,10,11,11,11,11,11,11,11,11, - 11,11,11,11,12,11,11,12,12,12,11,11,11,12,12,10, - 11,11,11,11,11,11,11,12,12,11,11,11,11,11,11,11, - 11,12,12,11,11,11,12,12,11,11,11,11,11,11,12,12, - 12,12,11,12,12,12,12,11,12,12,12,12,12,12,12,12, - 12,11,11,11,11,11,11,12,12,12,12,11,12,11,12,12, - 11,12,12,12,12,12,12,12,12,12, 9,10,10,11,10,10, - 11,11,11,11,10,11,11,11,11,10,11,11,11,11,10,11, - 11,11,11,10,11,11,11,11,11,11,11,11,11,11,11,11, - 12,12,11,11,12,12,12,11,11,11,12,12,10,11,10,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12, - 11,11,11,12,12,11,11,11,11,11,11,12,12,12,12,11, - 12,12,12,12,11,12,12,12,12,12,12,12,12,12,11,11, - 11,11,11,11,12,12,12,12,11,12,11,12,12,12,12,12, - 12,12,11,12,12,12,12,11,11,11,11,11,11,12,12,12, - 12,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,13,13,12,12,12,13,13,11,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,13,13,12,12,12, - 13,13,12,12,12,12,12,12,12,12,12,13,12,12,12,13, - 13,12,13,13,13,13,12,13,13,13,13,12,12,12,12,12, - 12,12,12,13,13,12,12,12,13,13,12,13,13,13,13,12, - 13,13,13,13,11,11,11,11,11,11,12,12,12,12,11,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, - 13,12,12,12,13,13,11,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,13,13,12,12,12,13,13,12, - 12,12,12,12,12,12,12,13,13,12,12,12,13,13,12,13, - 13,13,13,12,13,13,13,13,12,12,12,12,12,12,12,12, - 13,13,12,12,12,13,12,12,13,13,13,13,12,13,13,13, - 13, 7,10,10,11,11,10,10,11,11,11,10,11,11,11,11, - 10,11,11,11,11,10,11,11,11,11,10,10,10,11,11,10, - 11,11,11,11,11,11,11,11,12,11,11,11,12,12,11,11, - 11,12,12,10,11,11,11,11,11,11,11,12,11,11,11,11, - 12,11,11,11,11,12,12,11,11,11,12,12,11,11,11,11, - 11,11,11,11,12,12,11,11,12,12,12,11,12,12,12,12, - 11,12,12,12,12,11,11,11,11,11,11,12,12,12,12,11, - 11,12,12,12,11,12,12,12,12,11,12,12,12,12,10,11, - 11,11,11,11,11,11,11,12,11,11,11,11,11,11,11,11, - 12,12,11,11,11,12,12,11,11,11,11,11,11,11,12,12, - 12,11,11,11,12,12,11,12,12,12,12,11,12,12,12,12, - 11,11,11,11,11,11,12,11,12,12,11,11,11,12,12,11, - 12,12,12,12,11,12,12,12,12,11,11,11,11,12,11,12, - 12,12,12,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,11,11,11,12,12,11,12,12,12,12,11,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,10,11,10,11,11, - 11,11,11,12,12,11,11,11,12,12,11,12,12,12,12,11, - 12,12,12,12,10,11,11,12,11,11,11,12,12,12,11,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11, - 12,11,11,12,12,12,12,11,12,11,12,12,12,12,12,12, - 12,12,12,12,12,12,11,12,11,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,13,12,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,13,12,12,12,13,12,11,11,11,12,12,12,12,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 13,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,13,13,13,12,12,12,13,13,11,12,12,12,12,12, - 12,12,12,13,12,12,12,12,12,12,12,13,13,13,12,13, - 12,13,13,12,12,12,12,12,12,12,12,13,13,12,12,12, - 13,13,12,13,13,13,13,12,13,13,13,13,12,12,12,12, - 12,12,12,12,13,13,12,13,12,13,13,12,13,13,13,13, - 12,13,13,13,13,11,11,11,12,12,12,12,12,12,12,11, - 12,12,12,12,12,12,12,13,13,12,12,12,13,13,11,12, - 12,12,12,12,12,12,12,12,12,12,12,13,13,12,13,12, - 13,13,12,13,13,13,13,11,12,12,12,12,12,12,12,13, - 13,12,12,12,13,12,12,13,13,13,13,12,13,13,13,13, - 12,12,12,12,12,12,12,13,13,13,12,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,13, - 13,13,13,12,12,12,13,13,13,13,13,13,13,13,13,13, - 13,13, 7,10,10,11,11,10,11,11,11,11,10,11,11,11, - 11,10,11,11,11,11,10,11,11,11,11,10,11,11,11,11, - 11,11,11,11,11,11,11,11,12,11,11,11,12,12,12,11, - 11,11,12,12,10,10,10,11,11,11,11,11,12,11,10,11, - 11,11,11,11,11,11,12,12,11,11,11,12,12,11,11,11, - 11,11,11,11,12,12,12,11,12,11,12,12,11,12,12,12, - 12,11,12,12,12,12,11,11,11,11,11,11,11,11,12,12, - 11,12,11,12,12,11,12,12,12,12,11,12,12,12,12,10, - 10,10,11,11,11,11,11,12,12,11,11,11,12,12,11,12, - 12,12,12,11,12,12,12,12,11,11,11,11,11,11,11,12, - 12,12,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,11,11,11,11,11,11,12,12,12,12,11,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,13,12,12, - 12,13,12,11,11,11,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,10,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12, - 11,11,11,12,12,11,11,11,11,11,11,11,12,12,12,11, - 12,11,12,12,11,12,12,12,12,11,12,12,12,12,11,11, - 11,11,11,11,11,11,12,12,11,11,11,12,12,11,12,12, - 12,12,11,12,12,12,12,11,11,11,12,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 11,11,11,12,11,11,12,12,12,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,11,11,11,12,12,11,12, - 12,12,12,12,12,12,12,12,12,12,12,13,13,12,12,12, - 13,12,11,12,12,12,12,12,12,12,12,13,12,12,12,13, - 13,12,13,13,13,13,12,13,13,13,13,11,12,12,12,12, - 12,12,12,12,13,12,12,12,12,12,12,13,13,13,13,12, - 13,13,13,13,12,12,12,12,12,12,12,13,13,13,12,13, - 12,13,13,13,13,13,13,13,13,13,13,13,13,12,12,12, - 12,12,12,13,13,13,13,12,13,12,13,13,13,13,13,13, - 13,13,13,13,13,13,11,11,11,12,12,11,12,12,12,12, - 11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, - 12,13,13,12,12,12,13,13,11,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,13,13,12,13,12,13, - 13,12,12,12,12,12,12,12,12,13,13,12,12,12,13,13, - 13,13,13,13,13,12,13,13,13,13,12,12,12,12,12,12, - 13,12,13,13,12,13,12,13,12,12,13,13,13,13,12,13, - 13,13,13, 8,11,11,12,12,11,12,12,12,12,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,12, - 12,11,12,12,12,12,12,12,12,12,12,12,12,12,13,13, - 12,12,12,13,13,11,11,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,13,13,12,12,12,13,13,11,12, - 12,12,12,12,12,12,12,13,12,12,12,12,12,12,12,13, - 13,13,12,12,13,13,13,11,12,12,12,12,12,12,12,13, - 12,12,12,12,13,13,12,13,13,13,13,12,13,13,13,13, - 11,11,11,12,12,11,12,12,12,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,11,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,13,13,12,12,12, - 13,13,11,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,13,12,13,13,12,13,12,13,13,12,12,12,12,12, - 12,12,12,12,13,12,12,12,13,13,12,13,13,13,13,12, - 13,13,13,13,12,12,12,12,12,12,12,12,13,13,12,12, - 12,13,13,12,13,13,13,13,12,13,13,13,13,11,11,11, - 12,12,11,12,12,12,12,11,12,12,12,12,12,12,12,13, - 12,12,12,12,12,13,11,12,12,12,12,12,12,12,12,13, - 12,12,12,12,13,12,13,13,13,13,12,13,13,13,13,11, - 12,12,12,12,12,12,12,12,13,12,12,12,13,12,12,13, - 13,13,13,12,13,13,13,13,12,12,12,12,12,12,12,12, - 13,13,12,12,13,13,13,12,13,13,13,13,12,13,13,13, - 13,12,12,12,12,12,12,13,13,13,13,12,13,12,13,13, - 12,13,13,13,13,13,13,13,13,13,11,11,11,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,11,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,13,13,13,12,13,13,13,13,11,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13, - 12,13,12,13,13,12,12,12,12,12,12,12,12,13,13,12, - 12,12,13,13,12,13,13,13,13,12,13,13,13,13,12,12, - 12,12,12,12,13,12,13,13,12,12,12,13,13,13,13,13, - 13,13,12,13,13,13,13,11,11,11,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,13,12,12,12,13,12, - 11,12,12,12,12,12,12,12,12,12,12,12,12,13,13,12, - 12,13,13,13,12,13,13,13,13,11,12,12,12,12,12,12, - 12,12,13,12,12,12,13,12,12,13,13,13,13,12,13,13, - 13,13,12,12,12,12,12,12,12,12,13,13,12,12,12,13, - 13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12, - 12,13,13,13,13,12,13,12,13,13,13,13,13,13,13,13, - 13,13,13,13, 8,11,11,11,11,11,12,12,12,12,11,12, - 12,12,12,12,12,12,12,12,11,12,12,12,12,11,11,11, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 13,12,12,12,13,13,11,11,11,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,13,13,12,12,12,13,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,13,13,12,13, - 13,13,13,12,13,13,13,13,11,12,12,12,12,12,12,12, - 12,13,12,12,12,13,12,12,13,13,13,13,12,13,12,13, - 13,11,11,11,12,12,12,12,12,12,12,11,12,12,12,12, - 12,12,12,13,13,12,12,12,13,12,11,12,12,12,12,12, - 12,12,12,12,12,12,12,13,13,12,12,13,13,13,12,13, - 13,13,13,11,12,12,12,12,12,12,12,13,13,12,12,12, - 12,12,12,13,13,13,13,12,13,13,13,13,12,12,12,12, - 12,12,12,13,13,13,12,12,13,13,13,13,13,13,13,13, - 12,13,13,13,13,12,12,12,12,12,12,13,12,13,13,12, - 12,12,13,13,13,13,13,13,13,12,13,13,13,13,11,11, - 11,12,12,11,12,12,12,12,11,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,11,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,13,12,13,13,12,12,12,13,13, - 11,12,12,12,12,12,12,12,12,13,12,12,12,12,12,12, - 12,12,13,13,12,13,12,13,13,12,12,12,12,12,12,12, - 12,13,12,12,12,12,13,13,12,13,13,13,13,12,13,13, - 13,13,12,12,12,12,12,12,12,12,13,13,12,12,12,13, - 12,12,13,13,13,13,12,13,13,13,13,11,11,11,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,13,13,11,12,12,12,12,12,12,12,12,13,12,12, - 12,12,12,12,13,13,13,13,12,13,13,13,13,11,12,12, - 12,12,12,12,12,12,13,12,12,12,12,12,12,13,13,13, - 13,12,13,13,13,13,12,12,12,12,12,12,12,12,13,13, - 12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,12, - 12,12,12,12,12,13,13,13,13,12,12,12,13,12,13,13, - 13,13,13,12,13,13,13,13,11,11,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 13,11,12,12,12,12,12,12,12,12,12,12,12,12,13,12, - 12,12,12,13,13,12,13,13,13,13,11,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,13,13,13,13,12,13, - 12,13,13,12,12,12,12,12,12,12,13,13,13,12,13,12, - 13,13,12,13,13,13,13,13,13,13,13,13,12,12,12,12, - 12,12,12,12,12,13,12,12,12,13,13,13,13,13,13,13, - 12,13,13,13,13, -}; - -static const static_codebook _44p9_p4_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p9_p4_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44p9_p4_1, - 0 -}; - -static const long _vq_quantlist__44p9_p5_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p9_p5_0[] = { - 4, 6, 6, 9, 9, 6, 7, 8,10,11, 6, 8, 7,10,10, 8, - 10,10,12,12, 8,10,10,12,12, 6, 7, 8,10,10, 7, 8, - 9,10,11, 8, 9, 9,11,11,10,10,11,12,13,10,11,11, - 13,13, 6, 8, 7,10,10, 8, 9, 9,11,11, 7, 9, 8,11, - 10,10,11,11,13,13,10,11,10,13,12, 9,10,10,11,12, - 10,10,11,12,13,10,11,11,12,13,12,12,13,12,14,12, - 13,13,14,14, 9,10,10,12,11,10,11,11,13,12,10,11, - 10,13,12,12,13,13,14,14,12,13,12,14,12, 7, 8, 8, - 10,11, 8, 9,10,11,12, 8, 9, 9,11,12,10,11,12,13, - 14,10,11,11,13,13, 8, 9,10,11,12, 9,10,11,12,13, - 10,10,11,12,12,11,12,12,13,14,11,12,12,14,14, 8, - 9, 9,11,12,10,10,11,12,13, 9,10,10,12,12,11,12, - 12,14,14,11,12,12,14,13,11,11,12,12,13,11,12,12, - 13,14,12,12,13,14,14,13,13,14,14,16,13,14,14,15, - 15,11,12,11,13,13,12,12,12,14,14,11,12,12,14,13, - 13,14,14,15,15,13,14,13,15,14, 7, 8, 8,11,10, 8, - 10, 9,12,11, 8,10, 9,12,11,10,11,11,13,13,10,12, - 11,14,13, 8, 9, 9,12,11, 9,10,10,12,12,10,11,10, - 13,12,11,12,12,13,14,11,12,12,14,14, 8,10, 9,12, - 11,10,11,10,12,12, 9,11,10,13,11,11,12,12,14,14, - 11,12,12,14,13,11,11,12,13,13,11,12,12,13,14,12, - 12,12,14,14,13,13,14,14,15,13,14,14,15,15,11,12, - 11,13,12,12,12,12,14,14,11,12,12,14,13,13,14,14, - 15,15,13,14,13,15,14,10,11,11,12,13,11,12,12,13, - 14,11,12,12,13,14,13,13,14,14,16,13,14,14,15,15, - 11,12,12,12,14,12,12,13,13,15,12,13,13,13,15,14, - 14,15,15,16,14,14,15,15,16,11,12,12,13,14,12,13, - 13,14,15,12,13,13,14,14,14,14,15,15,16,14,14,14, - 15,15,13,14,14,14,15,14,14,15,15,16,14,15,15,15, - 16,15,15,16,16,18,16,16,16,17,17,13,14,14,15,15, - 14,14,15,16,16,14,14,14,16,15,16,16,16,17,17,15, - 16,16,17,16,10,11,11,13,12,11,12,12,14,13,11,12, - 12,14,13,13,14,14,15,15,13,14,13,16,14,11,12,12, - 14,13,12,13,13,14,14,12,13,13,15,14,14,14,14,15, - 15,14,15,14,16,15,11,12,12,14,12,12,13,13,15,14, - 12,13,12,15,13,14,15,14,16,15,14,15,14,16,15,13, - 14,14,15,15,14,14,14,15,16,14,15,14,16,16,15,16, - 16,16,17,16,16,16,17,17,13,14,14,15,14,14,15,15, - 16,15,14,15,14,16,15,16,16,16,17,17,15,16,15,18, - 16, 6, 8, 8,11,11, 8, 9,10,11,12, 8,10, 9,12,12, - 10,11,11,13,13,10,12,11,14,13, 8, 9, 9,11,12, 9, - 10,10,12,12, 9,10,10,12,12,11,11,12,13,14,11,12, - 12,14,14, 8,10, 9,12,11,10,11,11,12,12, 9,11,10, - 13,12,11,12,12,14,14,11,12,12,14,13,10,11,11,13, - 13,11,12,12,13,14,11,12,12,14,14,13,13,14,13,15, - 13,14,14,15,15,11,12,11,13,13,12,12,12,14,14,11, - 12,12,14,13,13,14,14,15,15,13,14,13,15,14, 8, 9, - 9,11,11, 9,10,10,12,12, 9,10,10,12,12,11,12,12, - 13,14,11,12,12,14,14, 9, 9,10,11,12,10,10,11,12, - 13,10,10,11,12,13,12,12,13,13,15,12,12,13,14,14, - 9,10,10,12,12,10,11,11,13,13,10,11,11,13,13,12, - 13,13,14,15,12,13,12,14,14,11,11,12,12,14,12,12, - 13,13,14,12,12,13,13,14,13,13,14,14,16,14,14,14, - 15,15,11,12,12,14,13,12,13,13,14,14,12,13,13,15, - 14,14,14,14,16,16,13,14,14,16,14, 7, 9, 9,12,11, - 9,10,10,12,12, 9,11,10,13,12,11,12,12,13,14,11, - 13,12,14,13, 9,10,10,12,12,10,10,11,12,13,10,12, - 11,13,13,12,12,13,13,14,12,13,13,15,14, 9,10,10, - 12,12,11,11,11,13,13,10,12,10,13,12,12,13,13,14, - 15,12,13,12,15,13,11,12,12,14,13,12,12,13,13,14, - 12,13,13,15,14,13,13,14,13,16,14,15,14,16,15,12, - 12,12,14,14,13,13,13,14,14,12,13,12,14,13,14,15, - 15,16,16,13,14,13,16,13,10,11,12,13,14,11,12,13, - 13,15,12,12,13,14,14,13,14,14,15,16,13,14,14,16, - 15,12,12,13,12,14,12,12,13,13,15,13,13,13,13,15, - 14,14,15,14,16,14,15,15,15,16,12,13,12,14,14,13, - 13,13,15,15,12,13,13,15,15,14,15,15,16,16,14,15, - 15,16,16,13,14,14,13,16,14,14,15,14,16,14,14,15, - 14,16,15,15,16,15,18,16,16,16,16,17,14,14,14,16, - 15,14,15,15,16,16,14,15,15,16,16,16,16,16,17,17, - 15,16,16,17,16,10,12,11,14,13,12,13,13,14,14,12, - 13,12,15,14,14,14,14,15,15,14,15,14,16,15,12,13, - 12,14,13,12,13,13,15,14,13,14,13,15,14,14,15,15, - 16,16,14,15,15,17,15,12,13,12,14,14,13,14,14,15, - 15,13,14,13,15,14,15,15,15,16,16,14,15,15,17,15, - 14,14,14,16,15,14,15,15,16,16,14,15,15,16,15,16, - 16,16,16,17,16,17,16,18,17,14,14,14,16,15,15,15, - 15,16,16,14,15,14,16,15,16,16,17,17,17,15,16,15, - 17,16, 6, 8, 8,11,11, 8, 9,10,12,12, 8,10, 9,12, - 11,10,11,12,13,13,10,11,11,13,13, 8, 9,10,11,12, - 9,10,11,12,13,10,11,11,12,12,11,12,12,13,14,11, - 12,12,14,14, 8, 9, 9,12,11, 9,10,10,12,12, 9,10, - 10,12,12,11,12,12,14,14,11,12,11,14,13,11,11,12, - 13,13,11,12,12,13,14,12,12,12,14,14,13,13,14,14, - 15,13,14,14,15,15,10,11,11,13,13,11,12,12,14,14, - 11,12,12,14,13,13,14,14,15,15,13,14,13,15,13, 7, - 9, 9,11,12, 9,10,11,12,13, 9,10,10,12,12,11,12, - 13,13,14,11,12,12,14,14, 9,10,10,12,12,10,10,11, - 12,13,11,12,11,13,13,12,12,13,13,15,12,13,13,15, - 14, 9,10,10,12,12,10,11,12,13,13,10,11,10,13,12, - 12,13,13,14,15,12,13,12,14,13,12,12,12,14,14,12, - 12,13,13,14,13,13,13,15,14,14,13,14,13,16,14,15, - 15,16,16,11,12,12,13,14,12,13,13,14,15,12,13,12, - 14,13,14,14,15,15,16,13,14,13,15,13, 8, 9, 9,11, - 11, 9,10,10,12,12, 9,10,10,12,12,11,12,12,14,14, - 11,12,11,14,13, 9,10,10,12,12,10,11,11,13,13,10, - 11,11,13,13,12,12,13,14,15,12,13,13,15,14, 9,10, - 9,12,11,10,11,10,13,12,10,11,10,13,12,12,13,12, - 14,14,12,13,12,15,13,11,12,12,13,14,12,13,13,14, - 14,12,13,13,14,14,14,14,14,14,16,14,14,14,16,15, - 11,12,11,14,12,12,13,12,15,13,12,13,12,15,13,14, - 14,14,16,15,13,14,13,16,14,10,11,12,13,14,12,12, - 13,13,15,12,13,13,14,14,14,14,15,15,16,14,14,14, - 15,16,12,12,13,14,14,12,13,14,14,15,13,14,14,15, - 15,14,15,15,15,17,15,15,15,16,16,12,12,13,13,14, - 13,13,14,14,15,12,13,13,14,15,15,15,15,15,17,14, - 15,15,15,15,14,14,14,16,16,14,15,15,15,16,15,15, - 15,16,16,16,15,16,16,18,16,16,17,17,17,14,14,14, - 15,16,15,15,15,16,17,14,15,14,16,16,16,16,17,17, - 18,16,16,15,17,16,10,12,11,14,13,12,12,12,14,14, - 11,13,12,14,13,13,14,14,15,15,13,14,13,16,15,12, - 12,13,14,14,12,13,13,15,15,13,13,13,15,15,14,15, - 15,16,16,14,15,15,17,16,12,13,12,14,12,13,13,13, - 15,13,12,13,12,15,13,14,15,15,16,15,14,15,14,16, - 14,14,14,14,16,16,14,15,15,16,16,14,15,15,16,16, - 15,16,16,16,17,16,17,16,18,17,13,14,14,16,13,14, - 15,15,16,14,14,15,14,16,14,16,16,16,17,16,15,16, - 15,18,15, 9,11,11,13,13,11,12,12,14,14,11,12,12, - 14,14,13,14,14,15,15,13,14,14,15,15,11,12,12,14, - 14,11,12,13,14,15,12,13,13,15,14,13,14,14,15,16, - 13,14,14,16,16,11,12,12,14,14,12,13,13,15,15,12, - 13,13,15,14,14,14,14,16,16,14,15,14,16,15,12,13, - 13,14,15,12,13,14,15,16,13,14,14,16,16,14,14,15, - 16,17,15,15,15,17,17,13,14,14,15,15,14,15,14,16, - 16,14,15,14,16,15,15,16,16,17,17,15,16,15,17,16, - 10,12,12,13,14,11,12,13,14,14,12,13,12,14,14,13, - 14,14,15,16,13,14,14,16,15,11,12,12,14,14,12,12, - 13,14,15,12,13,13,15,15,13,13,15,15,17,14,14,15, - 16,16,12,13,12,14,14,12,13,13,15,15,12,13,13,15, - 14,14,15,15,16,16,14,15,14,16,16,13,12,14,13,16, - 13,13,15,14,16,14,13,15,15,16,14,14,16,15,17,15, - 15,16,16,17,13,14,14,16,15,14,15,15,16,16,14,15, - 14,16,15,16,16,16,17,17,15,16,16,18,16,10,12,12, - 14,14,12,12,13,14,14,12,13,12,15,14,13,14,14,15, - 16,14,15,14,16,15,11,12,12,14,14,12,13,13,14,15, - 13,14,13,15,15,14,14,15,15,16,14,15,15,17,16,12, - 13,13,14,14,13,13,14,15,15,12,14,13,15,15,14,15, - 15,16,16,14,15,15,17,15,13,14,13,15,15,13,14,14, - 15,16,14,15,14,17,16,15,15,15,15,17,16,16,16,18, - 17,14,14,14,16,16,15,15,15,16,16,14,15,14,16,16, - 16,16,17,17,17,16,16,16,17,16,11,12,13,14,14,12, - 13,13,15,15,12,13,13,15,15,14,15,15,16,16,14,15, - 15,17,16,12,13,13,14,15,13,13,14,14,16,13,14,14, - 15,16,15,14,16,15,17,15,15,16,16,17,12,13,13,15, - 15,13,14,14,16,16,13,14,14,16,15,15,15,16,17,17, - 15,16,15,17,16,14,14,15,13,16,15,14,16,14,17,15, - 15,16,14,17,16,15,17,15,18,16,16,17,16,18,14,15, - 15,17,16,15,16,16,17,17,15,16,15,17,16,16,17,17, - 18,18,16,17,15,18,16,11,12,12,14,14,13,13,14,14, - 15,13,14,13,16,14,15,15,15,16,16,15,16,15,17,16, - 12,13,13,15,14,13,13,14,15,15,14,15,14,16,15,15, - 15,16,15,16,16,16,16,18,16,12,13,13,15,15,14,14, - 15,15,16,13,14,13,16,15,16,16,16,17,17,15,16,15, - 17,15,14,15,14,16,15,14,15,15,16,16,15,16,15,17, - 16,16,15,16,15,17,17,18,17,18,17,15,15,15,16,16, - 16,16,16,17,17,14,15,15,17,16,17,17,18,18,18,16, - 17,15,18,15, 9,11,11,13,13,11,12,12,14,14,11,12, - 12,14,14,13,14,14,15,16,13,14,14,15,15,11,12,12, - 14,14,12,13,13,14,15,12,13,13,14,14,14,14,15,15, - 16,14,14,14,16,16,11,12,12,14,14,12,13,13,14,15, - 11,13,12,14,14,13,14,14,16,16,13,14,14,16,15,13, - 14,14,15,15,14,14,15,15,16,14,15,14,16,16,15,15, - 16,16,17,15,16,16,17,17,12,13,13,15,15,13,14,14, - 16,15,12,14,13,16,15,15,16,15,17,17,14,15,15,17, - 15,10,12,12,14,14,12,12,13,14,15,12,13,12,14,14, - 14,14,15,15,16,13,14,14,16,16,12,13,13,14,14,13, - 13,14,14,15,13,14,13,15,15,14,15,15,15,17,14,15, - 15,16,16,11,12,12,14,14,13,13,14,15,15,12,13,13, - 15,14,14,15,15,16,17,14,15,14,16,15,14,14,14,16, - 16,14,15,15,16,16,15,15,15,16,16,15,16,16,16,18, - 16,17,16,18,17,13,13,14,15,15,14,14,15,16,16,13, - 14,14,16,15,16,16,17,17,17,15,15,15,17,15,10,12, - 12,14,13,12,12,13,14,14,11,13,12,14,14,13,14,14, - 16,16,13,14,14,16,15,12,12,13,14,14,12,13,13,14, - 15,13,13,13,15,15,14,14,15,16,16,14,15,15,16,16, - 11,12,12,14,14,12,13,13,15,15,12,13,12,15,14,14, - 15,14,16,16,13,15,13,16,15,13,14,14,15,16,14,15, - 15,15,17,14,15,15,16,16,16,15,16,16,17,16,16,16, - 17,17,13,14,12,16,13,14,15,13,16,15,13,15,13,16, - 14,15,16,15,17,16,15,16,14,17,15,11,12,12,14,15, - 13,13,14,14,16,13,14,13,15,14,15,15,16,16,17,15, - 15,15,16,16,12,13,13,15,15,13,13,14,15,16,14,15, - 14,16,15,15,15,16,15,17,16,16,16,17,17,12,13,13, - 14,15,14,14,15,15,16,13,14,13,15,15,16,16,16,17, - 17,15,16,15,16,15,15,15,15,16,16,14,15,15,16,17, - 16,16,16,17,17,16,15,17,15,18,17,18,17,18,18,14, - 14,15,15,17,15,15,16,16,17,14,15,15,16,16,17,17, - 17,17,18,16,16,15,17,15,11,12,12,14,14,12,13,13, - 15,15,12,13,13,15,15,14,15,15,16,16,14,15,14,17, - 16,13,13,13,15,15,13,14,14,15,16,13,14,14,16,16, - 15,15,16,16,17,15,16,16,17,17,12,13,13,15,14,13, - 14,14,16,15,13,14,13,16,14,15,16,16,17,16,15,16, - 14,17,15,14,15,15,16,17,15,15,16,16,17,15,16,16, - 17,17,16,15,17,16,18,16,17,17,18,18,14,15,14,16, - 13,15,16,15,17,14,15,16,14,17,14,16,17,16,18,16, - 16,17,15,18,15, -}; - -static const static_codebook _44p9_p5_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p9_p5_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44p9_p5_0, - 0 -}; - -static const long _vq_quantlist__44p9_p5_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44p9_p5_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44p9_p5_1 = { - 1, 7, - (char *)_vq_lengthlist__44p9_p5_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44p9_p5_1, - 0 -}; - -static const long _vq_quantlist__44p9_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p9_p6_0[] = { - 2, 5, 5, 5, 7, 7, 5, 7, 7, 5, 7, 7, 7, 8, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 7, 9, 8, 5, 7, 8, 8, 9, - 10, 8, 9,10, 8, 9,10,10,10,12,10,11,11, 8,10,10, - 10,11,12,10,11,10, 5, 8, 7, 8,10,10, 8,10, 9, 8, - 10,10,10,10,11,10,12,11, 8,10, 9,10,11,11,10,12, - 10, 5, 8, 8, 7, 9,10, 8,10, 9, 7, 9,10, 9,10,11, - 9,11,11, 8,10, 9,10,11,11, 9,11,10, 7, 9, 9, 9, - 10,11, 9,11,11, 9, 9,11,10,10,13,11,12,12, 9,11, - 11,11,12,13,11,13,11, 7, 9, 9, 9,10,11, 9,11,10, - 9,11,10,10,10,12,11,13,12, 9,11,11,11,12,12,10, - 12,10, 5, 8, 8, 8, 9,10, 7,10, 9, 8, 9,10, 9,10, - 11,10,11,11, 7,10, 9, 9,11,11, 9,11,10, 7, 9, 9, - 9,10,11, 9,11,10, 9,11,11,10,10,12,11,12,12, 9, - 10,11,11,12,13,10,12,10, 7, 9, 9, 9,11,11, 9,11, - 10, 9,11,11,11,11,13,11,13,12, 9,11, 9,11,12,12, - 10,13,10, -}; - -static const static_codebook _44p9_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44p9_p6_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44p9_p6_0, - 0 -}; - -static const long _vq_quantlist__44p9_p6_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44p9_p6_1[] = { - 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 8, 8, 7, - 8, 8, 7, 8, 7, 7, 8, 8, 7, 8, 8, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 9, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, - 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 9, 8, 8, - 8, 8, 9, 9, 8, 9, 9, 7, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 9, 8, 8, 8, 8, 8, 9, 9, 8, - 9, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 8, - 8, 8, 8, 8, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 8, 9, 9, 8, 8, 8, 8, 9, 8, - 8, 9, 8, -}; - -static const static_codebook _44p9_p6_1 = { - 5, 243, - (char *)_vq_lengthlist__44p9_p6_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44p9_p6_1, - 0 -}; - -static const long _vq_quantlist__44p9_p7_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p9_p7_0[] = { - 1,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13, -}; - -static const static_codebook _44p9_p7_0 = { - 5, 3125, - (char *)_vq_lengthlist__44p9_p7_0, - 1, -510105088, 1635281408, 3, 0, - (long *)_vq_quantlist__44p9_p7_0, - 0 -}; - -static const long _vq_quantlist__44p9_p7_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44p9_p7_1[] = { - 1, 4, 4,16,16, 4, 9,11,15,16, 4,12, 8,16,16,12, - 16,16,16,16,13,16,16,16,16, 5, 8,10,16,16, 9, 9, - 14,15,16,12,14,14,16,16,16,16,16,16,16,16,16,16, - 16,16, 5,11, 8,16,15,12,14,16,16,16, 9,15, 9,16, - 16,16,16,16,16,16,16,16,16,16,16,15,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16, 6,11,11, - 16,16,12,13,16,16,16,12,16,14,16,16,16,16,16,16, - 16,16,16,16,16,16,11,15,15,16,16,14,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,12, - 15,16,16,16,16,16,16,16,16,14,16,15,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16, 5,11,11,16,16,12, - 15,16,16,16,12,16,14,16,16,16,16,16,16,16,16,16, - 16,16,16,12,15,15,16,16,14,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,11,15,15,16, - 16,16,16,16,16,16,15,16,14,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16, 6,11,12,16,16,11,15,16,16,16,13,16,14,16,16, - 16,16,16,16,16,16,16,16,16,16,11,16,14,16,16,14, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,12,14,14,16,16,16,16,16,16,16,15,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,15,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16, 8,13, - 15,16,16,15,15,16,16,16,14,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,14,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16, 7,12,12,16,16, - 13,12,16,16,16,14,16,14,16,16,16,16,16,16,16,16, - 16,16,16,16,13,16,16,16,16,14,14,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,12,14,16, - 16,16,16,16,16,16,16,14,16,14,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16, 6,11,11,16,16,13,15,16,16,16,11,15,14,16, - 16,16,16,16,16,16,14,16,16,16,16,11,16,16,16,16, - 16,16,16,16,16,15,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,11,16,14,16,16,14,16,16,16,16,13,15, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 7, - 11,11,16,16,13,13,16,16,16,13,16,13,16,16,16,16, - 16,16,16,16,16,16,16,16,12,16,15,16,16,14,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,12,14,16,16,16,16,16,16,16,16,14,16,13,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16, 8,13,14,16, - 16,15,16,16,16,16,14,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,15,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,15,16, - 15,16,16,16,16,16,16,16,16,16,15,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,15,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16, -}; - -static const static_codebook _44p9_p7_1 = { - 5, 3125, - (char *)_vq_lengthlist__44p9_p7_1, - 1, -514619392, 1630767104, 3, 0, - (long *)_vq_quantlist__44p9_p7_1, - 0 -}; - -static const long _vq_quantlist__44p9_p7_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p9_p7_2[] = { - 1, 3, 2, 5, 4, 7, 7, 8, 8, 9,10,10,10,11,11,11, - 12,12,12,13,13,13,13,13,13, -}; - -static const static_codebook _44p9_p7_2 = { - 1, 25, - (char *)_vq_lengthlist__44p9_p7_2, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44p9_p7_2, - 0 -}; - -static const long _vq_quantlist__44p9_p7_3[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44p9_p7_3[] = { - 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44p9_p7_3 = { - 1, 25, - (char *)_vq_lengthlist__44p9_p7_3, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44p9_p7_3, - 0 -}; - -static const char _huff_lengthlist__44p9_short[] = { - 3, 3, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _huff_book__44p9_short = { - 1, 8, - (char *)_huff_lengthlist__44p9_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44pn1_l0_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44pn1_l0_0[] = { - 1, 3, 3, 8, 8,10,10,10,10,10,10,10,10, 5, 7, 5, - 9, 8,10,10,10,10,11,10,11,10, 5, 5, 7, 8, 9,10, - 10,11,10,10,11,10,11,10,10,10,11,11,11,11,11,11, - 11,10,11,11,10,10,10,10,11,11,11,11,11,10,11,11, - 11,11,11,11,11,11,12,11,10,11,11,11,11,11,11,11, - 11,11,11,11,11,10,10,11,11,12,11,11,11,11,11,11, - 12,11,11,11,10,11,11,11,11,11,11,11,11,10,11,11, - 10,11,10,11,11,11,11,11,11,11,11,11,11,12,11,11, - 12,12,11,11,11,11,11,11,11,11,11,11,11,11,12,11, - 10,11,11,11,11,11,11,11,12,11,13,11,11,11,11,11, - 11,11,11,11,11,11,12,11,13, -}; - -static const static_codebook _44pn1_l0_0 = { - 2, 169, - (char *)_vq_lengthlist__44pn1_l0_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44pn1_l0_0, - 0 -}; - -static const long _vq_quantlist__44pn1_l0_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44pn1_l0_1[] = { - 1, 4, 4, 7, 7, 4, 5, 6, 7, 7, 4, 6, 5, 7, 7, 7, - 6, 7, 6, 7, 7, 7, 6, 7, 6, -}; - -static const static_codebook _44pn1_l0_1 = { - 2, 25, - (char *)_vq_lengthlist__44pn1_l0_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44pn1_l0_1, - 0 -}; - -static const long _vq_quantlist__44pn1_l1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44pn1_l1_0[] = { - 1, 4, 4, 4, 4, 4, 4, 4, 4, -}; - -static const static_codebook _44pn1_l1_0 = { - 2, 9, - (char *)_vq_lengthlist__44pn1_l1_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44pn1_l1_0, - 0 -}; - -static const char _huff_lengthlist__44pn1_lfe[] = { - 1, 3, 2, 3, -}; - -static const static_codebook _huff_book__44pn1_lfe = { - 2, 4, - (char *)_huff_lengthlist__44pn1_lfe, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44pn1_long[] = { - 2, 3, 6, 7, 9,13,17, 3, 2, 5, 7, 9,13,17, 6, 5, - 5, 6, 9,12,16, 7, 7, 6, 6, 7,10,13,10,10, 9, 7, - 6,10,13,13,13,12,10,10,11,15,17,17,17,14,14,15, - 17, -}; - -static const static_codebook _huff_book__44pn1_long = { - 2, 49, - (char *)_huff_lengthlist__44pn1_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44pn1_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44pn1_p1_0[] = { - 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44pn1_p1_0 = { - 5, 243, - (char *)_vq_lengthlist__44pn1_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44pn1_p1_0, - 0 -}; - -static const long _vq_quantlist__44pn1_p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44pn1_p2_0[] = { - 1, 5, 5, 0, 7, 7, 0, 8, 8, 0, 9, 9, 0,12,12, 0, - 8, 8, 0, 9, 9, 0,13,13, 0, 8, 8, 0, 6, 6, 0,11, - 11, 0,12,12, 0,12,12, 0,14,14, 0,11,12, 0,12,12, - 0,15,15, 0,12,12, 0, 5, 5, 0, 5, 5, 0, 6, 6, 0, - 7, 7, 0,10,10, 0, 6, 6, 0, 7, 7, 0,11,11, 0, 6, - 6, 0, 7, 7, 0,11,11, 0,12,11, 0,11,11, 0,14,14, - 0,10,10, 0,12,12, 0,15,15, 0,12,12, 0, 6, 6, 0, - 12,12, 0,12,12, 0,12,12, 0,14,14, 0,11,11, 0,12, - 12, 0,16,16, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 8, 0,12,12, 0,12,12, 0,12,12, 0,15, - 15, 0,12,12, 0,11,11, 0,16,16, 0,11,11, 0, 6, 6, - 0,12,12, 0,12,12, 0,13,13, 0,15,15, 0,12,12, 0, - 13,13, 0,15,15, 0,12,12, 0, 0, 0, 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 static_codebook _44pn1_p2_0 = { - 5, 243, - (char *)_vq_lengthlist__44pn1_p2_0, - 1, -533200896, 1614282752, 2, 0, - (long *)_vq_quantlist__44pn1_p2_0, - 0 -}; - -static const long _vq_quantlist__44pn1_p2_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44pn1_p2_1[] = { - 1, 3, 3, 0, 9, 9, 0, 9, 9, 0,10,10, 0, 9, 9, 0, - 10,10, 0,10,10, 0,10,10, 0,10,10, 0, 7, 7, 0, 7, - 7, 0, 6, 6, 0, 8, 8, 0, 7, 7, 0, 8, 8, 0, 8, 8, - 0, 7, 7, 0, 8, 8, 0, 7, 7, 0, 9, 9, 0, 8, 9, 0, - 10,10, 0, 9, 9, 0,10,10, 0,10,11, 0, 9, 9, 0,10, - 10, 0, 9, 9, 0,11,11, 0,12,12, 0,12,12, 0,11,11, - 0,12,12, 0,13,13, 0,12,12, 0,13,13, 0, 8, 8, 0, - 12,12, 0,12,12, 0,13,13, 0,13,13, 0,13,13, 0,13, - 13, 0,13,13, 0,13,13, 0, 7, 7, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 0,11,11, 0,12,12, 0,13,13, 0,12, - 12, 0,13,13, 0,13,13, 0,12,12, 0,12,12, 0, 9, 9, - 0,12,12, 0,13,13, 0,14,14, 0,13,13, 0,14,14, 0, - 14,14, 0,13,13, 0,14,14, 0, 7, 7, 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 static_codebook _44pn1_p2_1 = { - 5, 243, - (char *)_vq_lengthlist__44pn1_p2_1, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44pn1_p2_1, - 0 -}; - -static const long _vq_quantlist__44pn1_p3_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44pn1_p3_0[] = { - 1, 6, 6, 6, 8, 8, 6, 8, 8, 7, 9, 9,10,11,11, 8, - 8, 8, 7, 9, 9,11,12,12, 9, 9, 9, 6, 7, 7,10,11, - 11,10,11,11,10,11,11,13,13,13,12,12,12,10,12,11, - 14,14,14,12,12,12, 6, 5, 5, 9, 6, 6, 9, 6, 6, 9, - 7, 7,12,10,10,11, 7, 6, 9, 7, 7,13,11,11,12, 7, - 7, 7, 8, 8,12,10,10,12,10,10,11,10,10,15,13,13, - 13, 9, 9,12,11,11,15,14,14,15,11,11, 8, 7, 7,12, - 11,11,12,11,11,11,11,11,14,13,14,14,12,12,12,11, - 11,16,15,15,14,12,12, 0,10,10, 0,12,12, 0,12,12, - 0,11,11, 0,14,14, 0,11,11, 0,11,11, 0,15,15, 0, - 11,11, 7, 8, 8,13,11,11,12,10,10,12,11,11,15,13, - 13,14,11,11,12,10,10,16,14,14,15,10,10, 9, 7, 7, - 13,11,12,13,12,11,12,11,11,15,14,14,14,12,12,13, - 12,12,16,15,15,15,12,12, 0,11,11, 0,12,12, 0,12, - 13, 0,12,12, 0,15,15, 0,12,12, 0,12,12, 0,16,15, - 0,12,12, -}; - -static const static_codebook _44pn1_p3_0 = { - 5, 243, - (char *)_vq_lengthlist__44pn1_p3_0, - 1, -531365888, 1616117760, 2, 0, - (long *)_vq_quantlist__44pn1_p3_0, - 0 -}; - -static const long _vq_quantlist__44pn1_p3_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44pn1_p3_1[] = { - 2, 3, 4, 9, 9,10,12,12,12,11,10,12,12,13,12,11, - 13,12,11,11,11,12,12,12,11,11,13,13,13,13,11,12, - 12,14,14,12,13,13,13,13,11,13,13,13,13,11,13,13, - 13,13,11,13,13,13,13,11,12,12,14,14,12,13,13,12, - 12,11,13,13,13,13,11,13,13,12,12,11,13,13,13,13, - 12,12,13,14,14,12,13,13,12,12,11,13,13,13,13,11, - 13,13,12,12,11,13,13,13,13,12,13,13,14,14,12,13, - 13,12,12,11,13,13,13,13,11,13,13,12,12,11,10,10, - 10,10,12,10,10,11,11,12, 9, 9,11,11,13,11,11,10, - 10,13,10,10,10,10,13,11,11,12,12,13,10,10,12,12, - 14,12,11,12,12,13,11,11,11,12,13,12,12,12,12,13, - 11,11,12,12,13,10,10,12,12,14,11,11,12,12,13,11, - 11,12,12,13,11,11,12,12,14,12,12,12,12,14,10,10, - 11,11,14,12,11,11,11,13,11,11,11,11,13,12,12,11, - 11,14,12,12,12,11,14,10,10,11,11,14,12,11,11,11, - 13,11,11,11,11,13,12,12,11,11,11,11,11,10,10,12, - 10,11, 9, 9,12,12,12,11,11,13,12,12, 9, 9,13,13, - 13,10,10,13,13,13,12,12,13,13,13,14,14,13,12,12, - 11,11,14,13,13,12,12,14,13,13,11,11,13,13,13,12, - 11,13,13,13,14,14,13,12,12,10,10,14,13,13,11,11, - 13,13,13,10,10,13,13,13,11,11,14,13,13,14,14,14, - 12,12,10,10,13,13,13,11,11,13,13,13,10,10,13,13, - 13,11,11,14,13,13,14,14,14,13,13,10,10,13,13,13, - 11,11,13,13,13,10,10,14,12,12, 8, 8,14,12,12, 9, - 9,14,11,11, 9, 9,14,12,12, 8, 8,14,12,12, 7, 7, - 15,13,13,10,10,15,12,12,10,10,15,13,13,10,10,15, - 12,13, 9, 9,15,13,13,10,10,15,13,13,10,10,15,12, - 12,10,10,15,13,13,10,10,15,13,13, 9, 9,15,13,13, - 10,10,15,13,13,10,10,15,12,12,10,10,15,13,13, 9, - 9,14,13,12, 9, 9,14,13,13, 9, 9,15,13,13,10,10, - 15,12,12,10,10,15,13,13, 9, 9,15,13,13, 9, 9,14, - 13,13, 9, 9,14,12,12, 8, 8,13,13,13, 8, 8,14,14, - 13, 9, 9,14,14,13, 7, 7,14,14,14, 8, 8,14,14,14, - 10,10,15,14,14,12,12,14,14,14, 9, 9,15,14,14,10, - 10,14,14,14, 9, 9,14,14,14,10, 9,15,14,14,12,12, - 14,14,14, 9, 9,15,14,14,10,10,14,14,14, 9, 9,15, - 14,15, 9, 9,15,14,14,11,11,14,14,14, 8, 8,14,14, - 14, 9, 9,14,14,14, 8, 8,14,15,14,10,10,15,14,14, - 11,11,14,14,14, 8, 8,15,14,14, 9, 9,14,14,14, 8, - 8,12,12,12,13,13,16,16,15,12,12,17,16,16,13,13, - 17,16,16,11,11,17,16,16,12,12,17,16,17,13,13,17, - 16,16,14,14,17,17,16,12,12,18,16,16,13,13,17,16, - 17,12,12,17,17,17,13,13,18,16,16,14,14,18,17,17, - 12,12,17,17,17,13,13,18,17,17,13,13,17,17,17,13, - 13,17,16,16,14,14,17,17,17,12,12,16,16,17,13,13, - 17,17,16,12,12,18,17,17,13,13,18,16,16,14,14,18, - 17,17,12,12,19,16,17,13,13,17,16,17,12,12,13,14, - 14,10,10,16,14,14,13,13,17,15,15,14,14,17,14,14, - 13,13,16,14,14,13,13,17,16,15,14,14,16,16,16,15, - 15,17,15,15,14,14,17,15,15,14,14,17,15,15,14,14, - 17,16,15,14,14,16,16,16,15,15,18,15,15,13,13,16, - 16,15,14,14,17,15,15,14,13,17,15,15,14,14,16,16, - 16,15,15,18,15,14,13,13,17,15,15,14,14,18,14,15, - 13,13,18,15,15,14,14,16,16,16,15,15,17,15,15,13, - 13,17,15,15,14,14,17,15,15,13,13,13,11,11,10,10, - 16,14,14,13,13,17,14,15,14,14,17,15,15,12,12,17, - 14,14,12,12,16,15,15,14,14,16,14,14,14,14,16,15, - 15,14,14,16,15,15,14,14,16,15,15,14,14,16,15,15, - 14,14,16,15,14,15,15,17,15,15,14,14,17,15,15,14, - 14,17,15,15,14,14,17,15,16,14,14,16,14,14,14,14, - 17,15,15,13,13,17,15,15,13,13,16,15,15,13,13,17, - 16,16,14,14,17,15,14,15,14,17,15,15,13,13,17,15, - 15,13,13,17,15,15,13,13,14,14,14, 9, 9,14,14,14, - 18,19,14,15,15,19,18,14,14,14,19,19,15,14,14,19, - 19,15,16,16,19,19,15,16,16,19,19,15,15,15,19,19, - 15,16,16,19,20,15,15,15,19,19,15,15,15,19,19,15, - 16,16,20,20,15,15,15,18,19,15,15,16,19,20,15,15, - 15,19,18,15,15,15,18,18,15,16,16,21,20,15,15,15, - 19,19,15,15,15,19,19,15,15,14,19,20,15,15,15,20, - 19,15,16,16,19,20,15,15,15,19,19,15,15,15,20,21, - 15,14,15,19,19,14,12,12, 9, 9,14,14,15,21,19,14, - 14,14,18,19,14,15,15,19,20,14,14,14,19,19,15,15, - 15,19,20,15,15,14,21,19,15,15,15,20,19,15,14,15, - 20,21,15,15,15,18,18,15,15,15,20,21,16,14,14,18, - 19,15,15,15,20,19,15,15,15,18,21,15,15,15,19,19, - 15,15,15,19,20,16,15,14,20,19,15,16,15,19,19,15, - 15,15,19, 0,14,15,15,19,19,15,15,15,19,19,15,15, - 14,20,19,15,15,15,20,19,15,15,15,19,19,15,15,15, - 20,19,12,12,12,13,13,16,15,16,11,11,16,16,16,12, - 12,17,16,16,11,11,17,16,16,12,11,17,17,17,13,13, - 18,16,16,14,14,18,18,17,13,13,17,16,16,13,13,17, - 17,17,13,13,17,16,17,12,12,17,15,16,13,13,17,16, - 17,12,12,17,16,16,13,12,17,16,16,12,12,18,17,17, - 13,13,18,16,16,13,14,18,17,17,12,12,17,16,16,12, - 12,17,17,17,12,12,18,17,17,13,13,17,16,16,14,14, - 17,17,17,12,12,17,16,16,12,12,18,17,17,12,12,13, - 14,14, 9, 9,16,14,14,13,13,16,15,15,14,14,16,14, - 14,13,13,16,14,14,13,13,17,16,15,15,15,16,15,16, - 16,15,17,15,15,14,14,17,15,15,15,15,17,15,15,14, - 14,17,15,15,14,14,16,15,16,16,16,17,15,15,14,14, - 16,15,15,14,15,16,15,15,14,14,17,15,15,15,15,16, - 16,16,15,16,18,15,14,13,14,17,15,15,14,14,17,14, - 14,13,13,17,15,15,14,14,16,15,15,15,15,17,15,14, - 14,14,17,15,15,14,14,17,14,14,13,13,13,11,11,11, - 11,16,14,14,12,12,16,14,14,13,13,16,14,14,12,12, - 16,14,14,12,12,16,15,15,13,13,17,14,14,14,14,17, - 15,15,13,13,16,15,15,14,13,16,15,15,13,13,16,15, - 15,13,13,16,14,14,14,14,16,15,15,13,13,16,14,15, - 13,13,17,15,15,13,13,17,15,15,13,13,16,14,14,14, - 14,17,15,15,12,12,17,14,15,13,13,17,15,15,12,12, - 16,15,15,13,13,17,14,14,14,14,17,15,15,12,12,17, - 15,15,13,13,16,15,15,12,12,14,15,15, 8, 8,14,14, - 14,19,18,14,15,15,19,20,14,14,14,19,19,14,14,15, - 19,20,15,16,15,19,21,15,16,16,21,19,15,15,15,20, - 19,15,16,16,19,20,15,15,15,19,18,15,16,15,20,19, - 15,16,16,19,20,15,15,15,19,19,15,16,15,20,20,14, - 15,15,19,19,15,15,15,21,19,15,17,16,19,20,15,14, - 15, 0,21,15,15,15,19,20,14,14,14,19,19,15,15,15, - 20,19,15,16,16,19,19,15,15,15,19,18,15,15,15,20, - 19,14,14,15,18,18,14,12,12, 9, 9,14,14,14,18,18, - 14,14,14,18,18,14,15,14,19,18,14,14,14,19,18,15, - 15,15,19,20,15,14,14,18,18,15,15,15,20,19,15,15, - 15,18,20,15,15,15,19,18,15,15,15,19,19,15,14,14, - 19,21,15,15,15,20,20,15,15,15,18,19,14,15,15,19, - 20,15,15,15,20,19,15,14,14,19,21,15,15,15,18,19, - 15,14,15,20,19,14,15,15,21,21,14,15,15,19,20,15, - 14,14,19,20,15,15,15,19,20,15,15,14,20,20,14,15, - 15,20,19,13,12,12,13,13,17,16,16,11,11,17,16,16, - 12,12,18,17,16,11,11,18,16,16,11,11,17,17,17,13, - 13,18,16,16,13,13,18,17,17,12,12,18,16,16,13,13, - 18,17,17,12,12,18,17,17,13,13,18,16,16,14,14,18, - 16,17,12,12,18,17,17,13,13,17,17,17,12,12,17,17, - 17,12,12,17,16,15,13,13,18,16,16,11,11,17,16,16, - 12,12,17,16,17,11,11,18,17,17,13,12,17,16,16,13, - 13,17,17,17,12,12,17,16,17,12,12,18,17,17,11,11, - 14,14,14, 9, 9,16,14,14,13,13,17,15,15,14,14,17, - 14,14,13,13,16,14,14,13,13,17,15,15,14,14,16,16, - 16,16,15,18,15,15,14,14,17,16,15,15,15,17,15,15, - 14,14,17,15,15,14,15,16,16,16,15,16,18,15,15,14, - 14,17,15,15,14,15,17,15,15,14,14,17,15,15,14,14, - 16,16,16,15,16,17,14,14,13,13,17,15,15,14,14,18, - 15,15,13,13,17,15,15,14,14,16,16,16,15,15,17,14, - 14,13,13,17,15,15,14,14,17,14,14,13,13,13,11,11, - 11,11,16,14,14,12,12,16,14,14,12,13,17,15,14,11, - 11,17,14,14,11,11,17,15,15,13,14,17,14,14,14,14, - 17,15,15,13,13,17,14,14,13,13,17,15,15,13,13,17, - 15,15,13,13,17,14,14,14,14,17,15,15,13,13,18,14, - 15,13,13,17,15,15,13,13,16,15,15,13,13,17,14,14, - 13,13,17,15,15,12,12,16,14,14,12,12,16,15,15,12, - 12,17,16,15,13,13,17,14,14,13,13,17,15,15,12,12, - 16,15,15,12,12,16,15,15,12,12,13,15,15, 8, 8,14, - 14,14,18,19,14,15,15,19,20,14,14,14,18,18,14,15, - 15,18,18,15,16,16,19,19,15,16,17,20,20,15,15,15, - 19,19,15,16,16,18,20,15,15,15,19,19,15,15,16,18, - 18,15,17,16,19,19,15,15,15,18,21,15,16,16,21,20, - 15,15,15,19,21,15,16,15,20,19,15,16,17,20,20,15, - 15,15,19,19,15,16,16,21,20,15,15,15,19,20,15,15, - 15,19,19,15,16,16,20,19,15,15,15,19,19,15,16,15, - 20,21,15,15,15,21,19,14,12,12, 8, 8,14,14,14,20, - 18,14,13,13,19,19,14,14,14,19,18,15,14,14,19,20, - 14,15,15,20,20,15,14,14,21,20,15,15,15,20,20,15, - 15,14,21,19,15,15,15,19,19,15,15,15,19,20,15,14, - 14,20,20,15,15,15,19,20,15,14,14,19,20,15,15,15, - 20,20,15,15,15,20,19,15,14,14,20,21,15,15,15,20, - 21,15,14,14,20, 0,15,16,15,20,21,15,15,15,19,20, - 15,14,14,19,19,15,15,15,19,20,15,15,15,19,19,15, - 15,15,18,20,13,12,12,13,13,18,16,17,12,12,17,16, - 16,12,12,17,17,16,11,11,18,16,16,11,11,17,17,18, - 13,13,18,16,16,14,14,18,17,17,13,13,18,16,16,13, - 13,18,17,17,12,12,17,17,16,13,13,17,16,16,13,14, - 18,17,17,12,12,18,16,16,12,13,17,16,17,12,12,17, - 18,17,13,13,18,16,16,13,13,18,17,17,12,12,17,16, - 16,12,12,17,17,17,11,11,17,16,17,12,12,17,16,16, - 13,13,17,16,16,11,11,17,16,16,12,12,18,16,17,11, - 11,14,14,14, 9, 9,16,14,15,13,13,17,15,15,14,14, - 17,14,14,12,12,16,14,14,13,13,18,15,15,15,15,17, - 15,16,15,16,18,15,15,14,14,17,15,16,15,15,17,15, - 15,14,14,18,15,15,14,14,16,16,16,16,15,17,15,15, - 14,14,16,15,15,14,14,17,15,15,14,14,17,15,15,14, - 14,17,16,16,15,15,17,15,14,13,13,17,15,15,14,14, - 17,15,15,13,13,17,15,15,14,14,16,16,16,15,15,18, - 15,14,14,14,17,15,15,14,14,18,15,15,13,13,13,12, - 12,11,11,16,14,14,12,12,16,14,14,13,13,17,15,15, - 12,12,17,14,14,12,12,17,15,15,14,14,17,14,14,14, - 14,17,15,15,13,13,17,15,14,13,13,17,15,15,13,13, - 17,15,15,13,13,16,14,14,14,14,17,15,15,13,13,16, - 14,14,13,13,16,15,15,13,13,17,15,16,13,13,17,14, - 14,14,13,17,15,15,12,12,16,15,14,12,12,17,15,15, - 12,12,16,15,16,13,13,16,14,14,14,13,17,15,15,12, - 12,16,14,14,12,12,17,15,15,12,12,14,15,15, 8, 8, - 14,14,14,18,18,14,15,15,19,18,14,14,14,18,18,14, - 15,15,19,20,15,16,15,21,18,15,16,16,18, 0,15,15, - 15,19,20,15,16,16,20, 0,15,16,15,19,18,15,15,15, - 19,19,15,16,16,21,19,15,15,15,19,19,15,16,16,20, - 20,15,15,15,19,19,15,15,15,19,18,15,16,16,20,20, - 15,14,15,20,19,15,15,15,19,20,15,15,15,19,19,15, - 16,15,19,20,15,16,16,19,20,15,15,15,19,19,15,16, - 15,20,20,15,15,15,20,18,13,12,12, 8, 8,14,14,14, - 19,20,14,14,14,19,19,14,15,15,20,20,14,14,14,18, - 19,15,15,15,20, 0,15,14,14,18,20,15,15,15,19,19, - 15,15,15,21,19,15,15,15,19,20,15,15,15,20,21,15, - 14,14,20,19,15,15,15,20,19,15,15,14,21,19,15,15, - 15,19,18,15,15,15,20,19,15,14,14,19,19,15,15,16, - 20,19,15,15,15,20, 0,15,15,15,19,21,15,15,15,22, - 20,15,14,14,22,19,15,15,15,19,20,15,14,14,20,19, - 14,15,15,19,21, -}; - -static const static_codebook _44pn1_p3_1 = { - 5, 3125, - (char *)_vq_lengthlist__44pn1_p3_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44pn1_p3_1, - 0 -}; - -static const long _vq_quantlist__44pn1_p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44pn1_p4_0[] = { - 1, 7, 7,14,14, 6, 8, 8,15,16, 7, 8, 8,16,15, 0, - 14,14,17,17, 0,14,14,16,16, 7, 9, 9,16,16,10,11, - 11,17,18, 9, 8, 8,16,16, 0,14,14,19,19, 0,14,14, - 17,16, 8, 9, 9,16,16,12,12,12,17,17,10, 9, 9,16, - 16, 0,15,14,18,20, 0,14,14,17,17, 0,15,15,18,17, - 0,21, 0, 0,21, 0,13,13,17,17, 0,17,17, 0, 0, 0, - 15,15,17,17, 0,15,15,17,18, 0, 0, 0, 0,21, 0,13, - 13,17,17, 0,18,18, 0,21, 0,16,15,17,18, 6, 7, 7, - 14,14, 9,10,10,16,16,11,10,10,15,15, 0,21, 0,20, - 21, 0, 0, 0,18,20,10,10,10,15,16,12,13,13,18,18, - 12,11,11,15,15, 0, 0, 0,20,20, 0, 0,21,19,19,12, - 11,11,15,15,15,14,14,18,18,13,11,11,15,16, 0, 0, - 0,20,19, 0, 0, 0,20,21, 0, 0,20,19,19, 0, 0, 0, - 0, 0, 0,20, 0,17,18, 0, 0,21, 0, 0, 0, 0, 0,21, - 0, 0,21, 0,20,19, 0, 0, 0, 0, 0, 0,21, 0,18,18, - 0, 0, 0,21, 0, 0, 0, 0, 0,20, 7, 6, 6,13,13, 9, - 6, 6,12,12, 9, 7, 7,14,14, 0,10,10,12,12, 0,11, - 11,15,15, 9, 7, 7,14,14,12, 9, 9,14,14,10, 7, 7, - 14,13, 0,11,11,16,15, 0,11,11,14,14, 9, 7, 7,14, - 14,13,10,10,14,14,11, 7, 7,14,13, 0,11,11,16,16, - 0,11,11,14,14, 0,12,12,16,16, 0,19, 0,17,18, 0, - 10,10,14,14, 0,15,14, 0, 0, 0,12,12,14,14, 0,12, - 12,15,15, 0,20, 0,18,19, 0,10,10,14,14, 0,16,15, - 0,20, 0,13,13,14,14, 0,11,11,13,13, 0,12,13,16, - 16, 0,12,12,16,16, 0,16,16, 0,21, 0,17,18, 0, 0, - 0,12,12,16,16, 0,15,15,18, 0, 0,12,12,16,16, 0, - 17,16,21,21, 0,16,17, 0, 0, 0,13,13,17,16, 0,16, - 16,20,21, 0,12,12,17,16, 0,17,17, 0,21, 0,17,17, - 21,21, 0,17,18, 0, 0, 0, 0, 0, 0, 0, 0,15,15, 0, - 0, 0,18,21, 0, 0, 0,18,19, 0, 0, 0,18,17,21,21, - 0, 0, 0, 0, 0, 0,16,16, 0, 0, 0, 0, 0, 0, 0, 0, - 19,19, 0, 0, 0,11,11,12,12, 0,11,11,10,10, 0,12, - 12,13,13, 0,12,12, 9, 9, 0,14,14,13,13, 0,12,12, - 13,13, 0,14,14,12,13, 0,11,11,12,12, 0,13,13,13, - 13, 0,13,13,13,13, 0,12,12,13,13, 0,14,14,12,12, - 0,11,11,12,12, 0,14,13,14,14, 0,13,13,13,13, 0, - 15,15,14,15, 0, 0, 0,16,16, 0,12,12,13,13, 0,16, - 17,20,21, 0,14,13,12,12, 0,14,14,14,14, 0,21, 0, - 16,16, 0,12,12,13,13, 0,18,17,21, 0, 0,14,14,13, - 13, 7, 8, 8,17,17,11,10,10,18,18,12,10,10,17,17, - 0,15,15,20,18, 0,15,15,17,17,11, 9, 9,17,17,14, - 12,12,19,19,13, 9, 9,16,16, 0,15,14, 0,19, 0,14, - 14,16,16,12,10,10,20,18,16,13,13,21,20,14,10,10, - 17,17, 0,15,15,21,20, 0,15,14,17,17, 0,15,15,21, - 21, 0, 0,21, 0, 0, 0,13,13,18,18, 0,19,16, 0, 0, - 0,15,15,17,16, 0,16,16, 0,21, 0, 0, 0, 0,21, 0, - 13,14,18,17, 0,20,19, 0, 0, 0,15,15,18,18, 8, 7, - 7,15,15,12,11,11,17,16,13,11,11,16,16, 0, 0, 0, - 21,20, 0, 0, 0, 0,20,11,10,10,17,17,14,13,13,19, - 18,14,11,11,16,16, 0,20, 0,21,19, 0, 0,21, 0,20, - 12,11,11,17,17,16,15,15, 0,19,14,11,11,17,16, 0, - 21, 0, 0,19, 0, 0, 0,21,20, 0, 0,21,20, 0, 0, 0, - 0, 0, 0, 0, 0, 0,19,21, 0, 0, 0, 0, 0, 0, 0, 0, - 19,20, 0, 0, 0,20,21, 0, 0, 0, 0, 0, 0,20, 0,19, - 21, 0, 0, 0, 0, 0, 0, 0, 0,21,20,11,10, 9,15,15, - 14,11,11,15,15,14,11,11,16,16, 0,14,14,14,14, 0, - 16,15,17,16,13,11,11,16,16,16,13,13,16,16,15,10, - 10,15,15, 0,14,15,17,17, 0,14,14,16,15,13,11,11, - 16,16,17,15,14,16,16,15,10,10,15,15, 0,15,15,17, - 18, 0,15,15,16,16, 0,16,16,17,17, 0,21, 0,21,20, - 0,13,13,15,15, 0,18,18, 0,21, 0,15,15,15,15, 0, - 16,16,17,17, 0, 0, 0, 0,18, 0,13,13,15,15, 0,19, - 18, 0, 0, 0,15,15,16,16, 0,12,12,15,15, 0,13,13, - 17,17, 0,13,13,17,18, 0,16,17,21, 0, 0,20,18, 0, - 0, 0,13,13,17,17, 0,15,15, 0,18, 0,12,12,17,18, - 0,16,16, 0, 0, 0,17,17,21, 0, 0,13,13,18,18, 0, - 16,16,21,21, 0,12,12,17,18, 0,16,17,21, 0, 0,17, - 17, 0,21, 0,17,18, 0, 0, 0, 0, 0, 0, 0, 0,16,15, - 0,21, 0,21,19, 0, 0, 0,18,18, 0, 0, 0,18,19, 0, - 0, 0, 0, 0, 0, 0, 0,16,16,21,21, 0,20,19, 0, 0, - 0,19,21, 0,21, 0,12,12,15,15, 0,12,12,15,16, 0, - 13,13,16,16, 0,14,14,15,15, 0,16,15,17,17, 0,13, - 13,17,17, 0,15,15,16,18, 0,12,12,16,16, 0,14,14, - 17,17, 0,15,14,16,16, 0,13,13,16,16, 0,16,15,17, - 17, 0,12,12,16,16, 0,15,15,18,18, 0,14,14,17,16, - 0,16,16,17,18, 0, 0, 0,20,21, 0,13,13,16,17, 0, - 17,17, 0, 0, 0,15,15,16,16, 0,15,16,17,17, 0, 0, - 0,19, 0, 0,13,13,15,16, 0,19,18, 0, 0, 0,16,15, - 16,17, 8, 8, 8,17,17,13,11,10,17,18,13,10,10,17, - 17, 0,15,15,20,19, 0,15,15,17,17,12,10,10,19,18, - 15,12,12,20,18,14,10,10,17,16, 0,15,15,20,20, 0, - 14,15,16,16,13,10,10,17,17,17,14,14, 0,18,15,10, - 10,17,17, 0,16,15,20,20, 0,14,14,17,17, 0,15,16, - 20,20, 0, 0,21, 0, 0, 0,13,13,17,17, 0,18,17, 0, - 0, 0,15,16,17,18, 0,15,15,18,21, 0, 0, 0,21, 0, - 0,13,13,18,18, 0,19,19, 0, 0, 0,16,16,18,17, 9, - 8, 8,15,15,12,11,11,16,16,13,11,11,16,15, 0, 0, - 0, 0,21, 0,21, 0,19,19,12,11,11,17,18,15,13,13, - 18,19,14,11,11,16,16, 0, 0,21,21,19, 0, 0, 0,21, - 20,13,11,11,18,17,17,14,15,20,21,15,11,12,16,16, - 0, 0, 0,20, 0, 0, 0,21, 0,19, 0, 0, 0, 0,19, 0, - 0, 0, 0, 0, 0,21,21,19,19, 0, 0, 0,21, 0, 0, 0, - 0,19,21, 0, 0, 0,19,20, 0, 0, 0,21, 0, 0, 0,21, - 19,19, 0, 0, 0, 0, 0, 0, 0, 0,21,20, 0,11,11,15, - 15, 0,12,12,15,16, 0,12,12,16,16, 0,15,15,16,15, - 0,16,16,17,17, 0,12,12,17,17, 0,14,14,17,17, 0, - 11,11,16,16, 0,15,15,19,18, 0,15,15,16,16, 0,12, - 12,17,16, 0,14,15,16,16, 0,11,11,15,15, 0,16,16, - 18,19, 0,15,15,15,16, 0,17,17,18,20, 0,21, 0,21, - 19, 0,14,14,16,16, 0,18,18, 0, 0, 0,16,16,15,15, - 0,16,16,18,17, 0, 0, 0,19,20, 0,14,14,16,16, 0, - 19,19, 0, 0, 0,16,17,15,15, 0,12,12,14,15, 0,13, - 13,16,17, 0,12,12,17,17, 0,17,16, 0, 0, 0,18,17, - 21, 0, 0,13,13,19,17, 0,15,15,20,21, 0,12,12,17, - 17, 0,17,17, 0, 0, 0,17,17, 0, 0, 0,13,13,17,18, - 0,16,16,21, 0, 0,12,12,17,17, 0,17,17, 0, 0, 0, - 17,17, 0, 0, 0,18,21, 0, 0, 0, 0, 0, 0, 0, 0,15, - 15,21, 0, 0,20,21, 0, 0, 0,18,19, 0, 0, 0,18,17, - 0, 0, 0, 0, 0, 0, 0, 0,16,16,21, 0, 0,21,21, 0, - 0, 0,18,19, 0, 0, 0,12,12,16,16, 0,13,13,16,17, - 0,13,13,17,16, 0,14,14,16,16, 0,16,15,19,18, 0, - 13,13,17,17, 0,15,15,18,18, 0,12,12,16,16, 0,15, - 15,18,19, 0,15,15,17,16, 0,13,13,17,17, 0,16,16, - 18,17, 0,12,12,17,16, 0,15,15,18,18, 0,15,15,17, - 17, 0,16,16, 0,19, 0, 0, 0, 0, 0, 0,14,14,16,17, - 0,18,18, 0, 0, 0,15,15,17,17, 0,16,16,21,19, 0, - 21, 0,21,21, 0,13,14,16,16, 0,19,19, 0, 0, 0,15, - 16,16,16, 0,11,11,17,16, 0,15,14,19,18, 0,14,14, - 19,19, 0,18,17,18,20, 0,17,17,18,19, 0,13,13,17, - 17, 0,16,17,21,18, 0,13,13,17,16, 0,18,17,19, 0, - 0,16,17,18,18, 0,12,12,19,18, 0,18,18,20,20, 0, - 13,13,17,17, 0,17,17,21, 0, 0,16,17,17,18, 0,18, - 17,19,18, 0, 0, 0, 0, 0, 0,14,14,17,17, 0,19,19, - 21, 0, 0,16,16,16,17, 0,17,17,19,20, 0, 0, 0, 0, - 21, 0,15,15,17,18, 0,21,21, 0, 0, 0,17,17,17,18, - 0,10,10,15,15, 0,15,14,17,18, 0,14,14,16,16, 0, - 0, 0,18, 0, 0,21, 0,19, 0, 0,13,13,17,16, 0,17, - 17,18, 0, 0,14,14,16,15, 0, 0, 0,21, 0, 0,21, 0, - 19,18, 0,13,13,17,17, 0,18,18,20,20, 0,15,15,16, - 16, 0, 0, 0,21,21, 0, 0, 0,20,20, 0, 0, 0,19, 0, - 0, 0, 0, 0, 0, 0,21,20,18,18, 0, 0, 0, 0, 0, 0, - 0, 0, 0,20, 0, 0, 0, 0,20, 0, 0, 0, 0, 0, 0, 0, - 0,19,18, 0, 0, 0, 0,21, 0, 0, 0,18,20, 0,18,19, - 16,17, 0,21,19,17,17, 0, 0,21,18,18, 0, 0,21,20, - 19, 0, 0, 0,20,20, 0, 0,21,17,17, 0, 0, 0,19,19, - 0,20,20,17,17, 0, 0, 0, 0,20, 0, 0,20,18,18, 0, - 21,20,17,17, 0, 0, 0,20,21, 0,19, 0,17,17, 0, 0, - 21, 0, 0, 0,20, 0,18,19, 0, 0, 0,21,21, 0, 0, 0, - 0,21, 0,20,20,17,17, 0, 0, 0, 0, 0, 0,21, 0,18, - 17, 0, 0, 0,20,19, 0, 0, 0, 0,21, 0,20,20,17,17, - 0, 0, 0, 0, 0, 0,21,21,18,18, 0,12,12,15,14, 0, - 14,14,17,17, 0,14,14,17,16, 0,18,18,21, 0, 0,19, - 20, 0, 0, 0,13,13,18,17, 0,16,16,19,18, 0,13,13, - 17,17, 0,17,17, 0, 0, 0,17,17,21, 0, 0,13,13,17, - 17, 0,17,17,21,20, 0,13,13,18,17, 0,18,19,21,21, - 0,19,18, 0, 0, 0,18,17, 0, 0, 0, 0, 0, 0, 0, 0, - 15,16, 0, 0, 0,21,21, 0, 0, 0,20,18,21, 0, 0,17, - 18, 0, 0, 0, 0, 0, 0, 0, 0,15,16, 0, 0, 0, 0,20, - 0, 0, 0, 0,19, 0, 0, 0,15,15,18,19, 0,18,17,21, - 0, 0,16,18, 0,20, 0,17,18,21, 0, 0,18,20, 0, 0, - 0,16,16,21,21, 0,19,20,21, 0, 0,16,15, 0,21, 0, - 18,20, 0, 0, 0,18,19, 0, 0, 0,16,15,21,21, 0,21, - 0, 0, 0, 0,16,15,21, 0, 0,20,19, 0, 0, 0,18,21, - 21, 0, 0,20,18, 0, 0, 0, 0, 0, 0, 0, 0,16,16, 0, - 20, 0,21, 0, 0, 0, 0,17,18,20,21, 0,18,18,21,21, - 0, 0, 0, 0, 0, 0,16,16,20, 0, 0, 0,21, 0, 0, 0, - 21,18, 0, 0, 0,12,12,20,17, 0,15,15,19,18, 0,14, - 14,19,18, 0,18,17,21,19, 0,17,17,21,17, 0,13,13, - 21,19, 0,16,17,20,19, 0,13,13,16,16, 0,17,17,20, - 21, 0,16,16,19,17, 0,13,13,18,18, 0,17,19,19,19, - 0,13,13,17,17, 0,18,18, 0,19, 0,16,17,18,18, 0, - 16,17,19,21, 0, 0, 0, 0, 0, 0,15,15,16,17, 0,20, - 19,21, 0, 0,17,17,17,17, 0,17,17,21,19, 0, 0, 0, - 0, 0, 0,15,15,17,17, 0,21, 0, 0, 0, 0,18,18,17, - 17, 0,10,10,15,15, 0,15,15,17,17, 0,15,14,16,16, - 0, 0, 0,21,19, 0,21,21,19,21, 0,13,13,17,16, 0, - 17,17,18,19, 0,14,15,16,15, 0, 0, 0,21,19, 0,21, - 21,18,19, 0,14,14,16,17, 0,18,18,18,19, 0,15,15, - 15,16, 0, 0,21, 0,21, 0, 0, 0,19,20, 0, 0, 0,21, - 19, 0, 0, 0, 0, 0, 0,21,21,19,17, 0, 0, 0, 0, 0, - 0, 0, 0,21,21, 0,21, 0, 0,21, 0, 0, 0, 0, 0, 0, - 21,21,19,18, 0, 0, 0, 0, 0, 0, 0, 0, 0,19, 0,21, - 18,18,17, 0,21, 0,20,20, 0, 0, 0,18,20, 0, 0,21, - 18,21, 0, 0, 0,21,18, 0, 0, 0, 0,19, 0, 0, 0,21, - 21, 0,20,21,17,19, 0,21, 0,21, 0, 0,21, 0,18,18, - 0,20,21,17,18, 0, 0, 0,21,19, 0,20,21,17,18, 0, - 0, 0,21,21, 0, 0, 0,20,19, 0, 0, 0,21,21, 0, 0, - 0, 0, 0, 0,21,21,19,18, 0, 0, 0, 0, 0, 0, 0,21, - 19,18, 0,21,21,19, 0, 0, 0, 0,21, 0, 0,21,21,18, - 17, 0, 0, 0, 0, 0, 0,21, 0,21,18, 0,12,12,14,14, - 0,15,14,17,17, 0,14,14,17,16, 0,19,17, 0, 0, 0, - 19,19, 0, 0, 0,13,13,17,17, 0,17,17,20,20, 0,13, - 13,18,18, 0,18,17, 0, 0, 0,18,21, 0, 0, 0,13,13, - 17,17, 0,18,18,21,20, 0,14,14,18,19, 0,19,18,21, - 0, 0,19,19, 0, 0, 0,20,18,20, 0, 0, 0, 0, 0, 0, - 0,15,16, 0, 0, 0,21,21, 0, 0, 0,19,19, 0, 0, 0, - 18,18, 0, 0, 0, 0, 0, 0, 0, 0,16,16, 0,21, 0, 0, - 0, 0, 0, 0,19,20, 0, 0, 0,15,15,20,21, 0,17,17, - 21,21, 0,17,17, 0, 0, 0,19,18, 0, 0, 0,18,19, 0, - 0, 0,17,16, 0,21, 0, 0,20, 0, 0, 0,16,16, 0,20, - 0,19,19, 0,21, 0,19,18, 0,21, 0,16,16, 0, 0, 0, - 21,21, 0, 0, 0,16,16, 0, 0, 0,21,21, 0, 0, 0,19, - 19, 0, 0, 0,20, 0, 0, 0, 0, 0, 0, 0, 0, 0,17,17, - 0,21, 0, 0,20, 0, 0, 0,20,18,21,21, 0,19,18, 0, - 20, 0, 0, 0, 0, 0, 0,16,17,21, 0, 0, 0,21, 0, 0, - 0,19,20,21,20, -}; - -static const static_codebook _44pn1_p4_0 = { - 5, 3125, - (char *)_vq_lengthlist__44pn1_p4_0, - 1, -528744448, 1616642048, 3, 0, - (long *)_vq_quantlist__44pn1_p4_0, - 0 -}; - -static const long _vq_quantlist__44pn1_p4_1[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44pn1_p4_1[] = { - 2, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _44pn1_p4_1 = { - 1, 7, - (char *)_vq_lengthlist__44pn1_p4_1, - 1, -533200896, 1611661312, 3, 0, - (long *)_vq_quantlist__44pn1_p4_1, - 0 -}; - -static const long _vq_quantlist__44pn1_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44pn1_p5_0[] = { - 1, 7, 7, 6, 8, 8, 7, 8, 8, 7, 9, 9,11,11,11, 9, - 8, 8, 7, 9, 9,11,12,11, 9, 9, 9, 6, 7, 7,10,11, - 11,10,10,10,10,11,11,15,14,14,12,12,12,11,11,11, - 14,14,14,12,12,12, 5, 6, 6, 8, 5, 5, 8, 7, 7, 8, - 8, 8,12,10,10,10, 7, 7, 8, 7, 7,12,10,10,10, 7, - 7, 6, 7, 7,12,11,11,12,10,10,11,10,10,14,14,13, - 13,10,10,11,10,10,16,14,14,14,11,10, 7, 7, 7,13, - 12,12,12,12,11,11,11,11,15,14,17,13,12,12,12,11, - 11,15,15,15,14,13,13,10, 9, 9,14,12,11,13,11,11, - 12,11,11,16,15,14,14,11,11,12,11,11,17,14,14,15, - 11,11, 7, 8, 8,12,11,11,13,10,10,11,10,10,17,14, - 13,14,10,10,12,10,10,18,15,15,14,10,10, 8, 7, 7, - 13,12,12,13,11,11,12,11,11,16,14,15,14,12,12,12, - 11,11,18,16,16,14,12,12,11,10,10,13,12,11,13,11, - 11,13,12,12, 0,15,14,14,11,11,13,11,11,16,15,15, - 15,11,11, -}; - -static const static_codebook _44pn1_p5_0 = { - 5, 243, - (char *)_vq_lengthlist__44pn1_p5_0, - 1, -527106048, 1620377600, 2, 0, - (long *)_vq_quantlist__44pn1_p5_0, - 0 -}; - -static const long _vq_quantlist__44pn1_p5_1[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44pn1_p5_1[] = { - 2, 6, 7, 6, 8, 8, 7, 7, 8, 7, 8, 8, 9, 9, 9, 8, - 7, 7, 8, 8, 8, 9, 9, 9, 9, 8, 8, 6, 6, 6, 9, 7, - 7, 9, 7, 7, 9, 8, 8,10, 8, 8,10, 8, 8,10, 8, 8, - 10, 9, 8,10, 8, 8, 7, 6, 6, 9, 6, 6, 9, 6, 6, 9, - 7, 7,10, 8, 8,10, 6, 6, 9, 7, 7,10, 8, 8,10, 6, - 6, 7, 7, 7,11, 9, 9,11, 9, 9,10, 9, 9,12,10,10, - 12, 8, 8,11, 9, 9,13, 9,10,12, 8, 8, 8, 7, 7,11, - 9,10,11,10,10,10, 9, 9,11,11,11,11, 9, 9,11,10, - 9,12,11,11,11, 9,10,10, 8, 8,11, 9,10,11, 9, 9, - 11, 9, 9,12,10,10,11, 9, 9,11, 9, 9,12,10,11,11, - 9, 9, 8, 8, 8,12, 9, 9,12, 9, 9,11, 9, 9,13, 9, - 9,13, 8, 8,12, 9, 9,13,10,10,12, 8, 8, 9, 7, 7, - 11,10,10,11,10,10,11,10,10,12,11,11,11,10, 9,11, - 10,10,11,11,11,11, 9, 9,11, 9, 9,12,10,10,11,10, - 10,12,10,10,11,11,11,11, 9, 9,11,10,10,12,11,11, - 11, 9, 9, -}; - -static const static_codebook _44pn1_p5_1 = { - 5, 243, - (char *)_vq_lengthlist__44pn1_p5_1, - 1, -530841600, 1616642048, 2, 0, - (long *)_vq_quantlist__44pn1_p5_1, - 0 -}; - -static const long _vq_quantlist__44pn1_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44pn1_p6_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, -}; - -static const static_codebook _44pn1_p6_0 = { - 5, 243, - (char *)_vq_lengthlist__44pn1_p6_0, - 1, -516716544, 1630767104, 2, 0, - (long *)_vq_quantlist__44pn1_p6_0, - 0 -}; - -static const long _vq_quantlist__44pn1_p6_1[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44pn1_p6_1[] = { - 1, 3, 2, 5, 4, 7, 7, 8, 8, 9, 9,10,10,11,11,12, - 12,13,13,14,14,15,15,15,15, -}; - -static const static_codebook _44pn1_p6_1 = { - 1, 25, - (char *)_vq_lengthlist__44pn1_p6_1, - 1, -518864896, 1620639744, 5, 0, - (long *)_vq_quantlist__44pn1_p6_1, - 0 -}; - -static const long _vq_quantlist__44pn1_p6_2[] = { - 12, - 11, - 13, - 10, - 14, - 9, - 15, - 8, - 16, - 7, - 17, - 6, - 18, - 5, - 19, - 4, - 20, - 3, - 21, - 2, - 22, - 1, - 23, - 0, - 24, -}; - -static const char _vq_lengthlist__44pn1_p6_2[] = { - 3, 5, 4, 5, 4, 5, 4, 5, 5, 5, 4, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44pn1_p6_2 = { - 1, 25, - (char *)_vq_lengthlist__44pn1_p6_2, - 1, -529006592, 1611661312, 5, 0, - (long *)_vq_quantlist__44pn1_p6_2, - 0 -}; - -static const char _huff_lengthlist__44pn1_short[] = { - 4, 3, 7, 9,12,16,16, 3, 2, 5, 7,11,14,15, 7, 4, - 5, 6, 9,12,15, 8, 5, 5, 5, 8,10,14, 9, 7, 6, 6, - 8,10,12,12,10,10, 7, 6, 8,10,15,12,10, 6, 4, 7, - 9, -}; - -static const static_codebook _huff_book__44pn1_short = { - 2, 49, - (char *)_huff_lengthlist__44pn1_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - diff --git a/Engine/lib/libvorbis/lib/books/coupled/res_books_stereo.h b/Engine/lib/libvorbis/lib/books/coupled/res_books_stereo.h deleted file mode 100644 index 7b53cb972..000000000 --- a/Engine/lib/libvorbis/lib/books/coupled/res_books_stereo.h +++ /dev/null @@ -1,15782 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: static codebooks autogenerated by huff/huffbuld - - ********************************************************************/ - -#include "codebook.h" - -static const long _vq_quantlist__16c0_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16c0_s_p1_0[] = { - 1, 4, 4, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9,10, 0, 0, 0, - 0, 0, 0, 7, 9,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 8, 0, 0, 0, 0, - 0, 0, 8,10,10, 0, 0, 0, 0, 0, 0, 8,10,10, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,10,10, 0, 0, 0, - 0, 0, 0, 9, 9,12, 0, 0, 0, 0, 0, 0,10,12,11, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,10,10, 0, 0, - 0, 0, 0, 0, 9,12,10, 0, 0, 0, 0, 0, 0,10,11,12, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 8,10,10, 0, 0, - 0, 0, 0, 0, 8,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7,10,10, 0, 0, 0, 0, 0, 0,10,12,11, 0, - 0, 0, 0, 0, 0, 9,10,12, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7,10,10, 0, 0, 0, 0, 0, 0,10,11,12, - 0, 0, 0, 0, 0, 0, 9,12, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _16c0_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__16c0_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__16c0_s_p1_0, - 0 -}; - -static const long _vq_quantlist__16c0_s_p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16c0_s_p3_0[] = { - 1, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 6, 7, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 6, 6, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _16c0_s_p3_0 = { - 4, 625, - (char *)_vq_lengthlist__16c0_s_p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16c0_s_p3_0, - 0 -}; - -static const long _vq_quantlist__16c0_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__16c0_s_p4_0[] = { - 1, 3, 2, 7, 8, 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 8, 8, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _16c0_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__16c0_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__16c0_s_p4_0, - 0 -}; - -static const long _vq_quantlist__16c0_s_p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__16c0_s_p5_0[] = { - 1, 3, 3, 6, 6, 6, 6, 8, 8, 0, 0, 0, 7, 7, 7, 7, - 8, 8, 0, 0, 0, 7, 7, 7, 7, 8, 8, 0, 0, 0, 7, 7, - 8, 8, 9, 9, 0, 0, 0, 7, 7, 8, 8, 9, 9, 0, 0, 0, - 8, 9, 8, 8,10,10, 0, 0, 0, 8, 8, 8, 8,10,10, 0, - 0, 0,10,10, 9, 9,10,10, 0, 0, 0, 0, 0, 9, 9,10, - 10, -}; - -static const static_codebook _16c0_s_p5_0 = { - 2, 81, - (char *)_vq_lengthlist__16c0_s_p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__16c0_s_p5_0, - 0 -}; - -static const long _vq_quantlist__16c0_s_p6_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__16c0_s_p6_0[] = { - 1, 3, 4, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10,10,11, - 11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10,11, - 11,11, 0, 0, 0, 6, 6, 8, 8, 9, 9, 9, 9,10,10,11, - 11,11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10,10, - 11,11,12,12,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10, - 10,11,11,12,12,12,13, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0,10,10,10, - 10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9, - 10,10,11,11,12,12,13,13,13,13, 0, 0, 0, 0, 0, 9, - 9,10,10,11,11,12,12,13,13,13,14, 0, 0, 0, 0, 0, - 10,10,10,11,11,11,12,12,13,13,13,14, 0, 0, 0, 0, - 0, 0, 0,10,10,11,11,12,12,13,13,14,14, 0, 0, 0, - 0, 0, 0, 0,11,11,12,12,13,13,13,13,14,14, 0, 0, - 0, 0, 0, 0, 0,11,11,12,12,12,13,13,14,15,14, 0, - 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,13,14,14,15, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,13,13,14,13,14, - 14, -}; - -static const static_codebook _16c0_s_p6_0 = { - 2, 289, - (char *)_vq_lengthlist__16c0_s_p6_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__16c0_s_p6_0, - 0 -}; - -static const long _vq_quantlist__16c0_s_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16c0_s_p7_0[] = { - 1, 4, 4, 6, 6, 6, 7, 6, 6, 4, 7, 7,11,10,10,11, - 11,10, 4, 7, 7,10,10,10,11,10,10, 6,10,10,11,11, - 11,11,11,10, 6, 9, 9,11,12,12,11, 9, 9, 6, 9,10, - 11,12,12,11, 9,10, 7,11,11,11,11,11,12,13,12, 6, - 9,10,11,10,10,12,13,13, 6,10, 9,11,10,10,11,12, - 13, -}; - -static const static_codebook _16c0_s_p7_0 = { - 4, 81, - (char *)_vq_lengthlist__16c0_s_p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__16c0_s_p7_0, - 0 -}; - -static const long _vq_quantlist__16c0_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__16c0_s_p7_1[] = { - 1, 3, 4, 6, 6, 7, 7, 8, 8, 8, 8,10,10,10, 7, 7, - 8, 8, 8, 9, 9, 9,10,10,10, 6, 7, 8, 8, 8, 8, 9, - 8,10,10,10, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10, 7, - 7, 8, 8, 9, 9, 8, 9,10,10,10, 8, 8, 9, 9, 9, 9, - 9, 9,11,11,11, 8, 8, 9, 9, 9, 9, 9,10,10,11,11, - 9, 9, 9, 9, 9, 9, 9,10,11,11,11,10,11, 9, 9, 9, - 9,10, 9,11,11,11,10,11,10,10, 9, 9,10,10,11,11, - 11,11,11, 9, 9, 9, 9,10,10, -}; - -static const static_codebook _16c0_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__16c0_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__16c0_s_p7_1, - 0 -}; - -static const long _vq_quantlist__16c0_s_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__16c0_s_p8_0[] = { - 1, 4, 4, 7, 7, 7, 7, 7, 6, 8, 8,10,10, 6, 5, 6, - 8, 8, 8, 8, 8, 8, 8, 9,10,10, 7, 6, 6, 8, 8, 8, - 8, 8, 8, 8, 8,10,10, 0, 8, 8, 8, 8, 9, 8, 9, 9, - 9,10,10,10, 0, 9, 8, 8, 8, 9, 9, 8, 8, 9, 9,10, - 10, 0,12,11, 8, 8, 9, 9, 9, 9,10,10,11,10, 0,12, - 13, 8, 8, 9,10, 9, 9,11,11,11,12, 0, 0, 0, 8, 8, - 8, 8,10, 9,12,13,12,14, 0, 0, 0, 8, 8, 8, 9,10, - 10,12,12,13,14, 0, 0, 0,13,13, 9, 9,11,11, 0, 0, - 14, 0, 0, 0, 0,14,14,10,10,12,11,12,14,14,14, 0, - 0, 0, 0, 0,11,11,13,13,14,13,14,14, 0, 0, 0, 0, - 0,12,13,13,12,13,14,14,14, -}; - -static const static_codebook _16c0_s_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__16c0_s_p8_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__16c0_s_p8_0, - 0 -}; - -static const long _vq_quantlist__16c0_s_p8_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16c0_s_p8_1[] = { - 1, 4, 3, 5, 5, 7, 7, 7, 6, 6, 7, 7, 7, 5, 5, 7, - 7, 7, 6, 6, 7, 7, 7, 6, 6, -}; - -static const static_codebook _16c0_s_p8_1 = { - 2, 25, - (char *)_vq_lengthlist__16c0_s_p8_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16c0_s_p8_1, - 0 -}; - -static const long _vq_quantlist__16c0_s_p9_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16c0_s_p9_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 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, 7, 7, 7, 7, 7, 7, 7, - 7, -}; - -static const static_codebook _16c0_s_p9_0 = { - 4, 81, - (char *)_vq_lengthlist__16c0_s_p9_0, - 1, -518803456, 1628680192, 2, 0, - (long *)_vq_quantlist__16c0_s_p9_0, - 0 -}; - -static const long _vq_quantlist__16c0_s_p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__16c0_s_p9_1[] = { - 1, 5, 5, 5, 5, 9,11,11,10,10,10,10,10,10,10, 7, - 6, 6, 6, 6,10,10,10,10,10,10,10,10,10,10, 7, 6, - 6, 6, 6,10, 9,10,10,10,10,10,10,10,10,10, 7, 7, - 8, 9,10,10,10,10,10,10,10,10,10,10,10, 8, 7,10, - 10,10, 9,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _16c0_s_p9_1 = { - 2, 225, - (char *)_vq_lengthlist__16c0_s_p9_1, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__16c0_s_p9_1, - 0 -}; - -static const long _vq_quantlist__16c0_s_p9_2[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__16c0_s_p9_2[] = { - 1, 5, 5, 7, 8, 8, 7, 9, 9, 9,12,12,11,12,12,10, - 10,11,12,12,12,11,12,12, 8, 9, 8, 7, 9,10,10,11, - 11,10,11,12,10,12,10,12,12,12,11,12,11, 9, 8, 8, - 9,10, 9, 8, 9,10,12,12,11,11,12,11,10,11,12,11, - 12,12, 8, 9, 9, 9,10,11,12,11,12,11,11,11,11,12, - 12,11,11,12,12,11,11, 9, 9, 8, 9, 9,11, 9, 9,10, - 9,11,11,11,11,12,11,11,10,12,12,12, 9,12,11,10, - 11,11,11,11,12,12,12,11,11,11,12,10,12,12,12,10, - 10, 9,10, 9,10,10, 9, 9, 9,10,10,12,10,11,11, 9, - 11,11,10,11,11,11,10,10,10, 9, 9,10,10, 9, 9,10, - 11,11,10,11,10,11,10,11,11,10,11,11,11,10, 9,10, - 10, 9,10, 9, 9,11, 9, 9,11,10,10,11,11,10,10,11, - 10,11, 8, 9,11,11,10, 9,10,11,11,10,11,11,10,10, - 10,11,10, 9,10,10,11, 9,10,10, 9,11,10,10,10,10, - 11,10,11,11, 9,11,10,11,10,10,11,11,10,10,10, 9, - 10,10,11,11,11, 9,10,10,10,10,10,11,10,10,10, 9, - 10,10,11,10,10,10,10,10, 9,10,11,10,10,10,10,11, - 11,11,10,10,10,10,10,11,10,11,10,11,10,10,10, 9, - 11,11,10,10,10,11,11,10,10,10,10,10,10,10,10,11, - 11, 9,10,10,10,11,10,11,10,10,10,11, 9,10,11,10, - 11,10,10, 9,10,10,10,11,10,11,10,10,10,10,10,11, - 11,10,11,11,10,10,11,11,10, 9, 9,10,10,10,10,10, - 9,11, 9,10,10,10,11,11,10,10,10,10,11,11,11,10, - 9, 9,10,10,11,10,10,10,10,10,11,11,11,10,10,10, - 11,11,11, 9,10,10,10,10, 9,10, 9,10,11,10,11,10, - 10,11,11,10,11,11,11,11,11,10,11,10,10,10, 9,11, - 11,10,11,11,11,11,11,11,11,11,11,10,11,10,10,10, - 10,11,10,10,11, 9,10,10,10, -}; - -static const static_codebook _16c0_s_p9_2 = { - 2, 441, - (char *)_vq_lengthlist__16c0_s_p9_2, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__16c0_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__16c0_s_single[] = { - 3, 4,19, 7, 9, 7, 8,11, 9,12, 4, 1,19, 6, 7, 7, - 8,10,11,13,18,18,18,18,18,18,18,18,18,18, 8, 6, - 18, 8, 9, 9,11,12,14,18, 9, 6,18, 9, 7, 8, 9,11, - 12,18, 7, 6,18, 8, 7, 7, 7, 9,11,17, 8, 8,18, 9, - 7, 6, 6, 8,11,17,10,10,18,12, 9, 8, 7, 9,12,18, - 13,15,18,15,13,11,10,11,15,18,14,18,18,18,18,18, - 16,16,18,18, -}; - -static const static_codebook _huff_book__16c0_s_single = { - 2, 100, - (char *)_huff_lengthlist__16c0_s_single, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__16c1_s_long[] = { - 2, 5,20, 7,10, 7, 8,10,11,11, 4, 2,20, 5, 8, 6, - 7, 9,10,10,20,20,20,20,19,19,19,19,19,19, 7, 5, - 19, 6,10, 7, 9,11,13,17,11, 8,19,10, 7, 7, 8,10, - 11,15, 7, 5,19, 7, 7, 5, 6, 9,11,16, 7, 6,19, 8, - 7, 6, 6, 7, 9,13, 9, 9,19,11, 9, 8, 6, 7, 8,13, - 12,14,19,16,13,10, 9, 8, 9,13,14,17,19,18,18,17, - 12,11,11,13, -}; - -static const static_codebook _huff_book__16c1_s_long = { - 2, 100, - (char *)_huff_lengthlist__16c1_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__16c1_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16c1_s_p1_0[] = { - 1, 5, 5, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 8, 7, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 8, 0, 0, 0, 0, 0, 0, 7, 9, 8, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 7, 0, 0, 0, 0, - 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 9, 9,11, 0, 0, 0, 0, 0, 0, 9,11,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 8,11, 9, 0, 0, 0, 0, 0, 0, 9,10,11, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 8, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,11,10, 0, - 0, 0, 0, 0, 0, 8, 9,11, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,10,11, - 0, 0, 0, 0, 0, 0, 9,11, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _16c1_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__16c1_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__16c1_s_p1_0, - 0 -}; - -static const long _vq_quantlist__16c1_s_p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16c1_s_p3_0[] = { - 1, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 5, 7, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 5, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 7, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _16c1_s_p3_0 = { - 4, 625, - (char *)_vq_lengthlist__16c1_s_p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16c1_s_p3_0, - 0 -}; - -static const long _vq_quantlist__16c1_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__16c1_s_p4_0[] = { - 1, 2, 3, 7, 7, 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 8, 8, 0, 0, 0, 0, 0, 0, 0, 8, 9, 0, 0, 0, 0, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _16c1_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__16c1_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__16c1_s_p4_0, - 0 -}; - -static const long _vq_quantlist__16c1_s_p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__16c1_s_p5_0[] = { - 1, 3, 3, 5, 5, 6, 6, 8, 8, 0, 0, 0, 7, 7, 7, 7, - 9, 9, 0, 0, 0, 7, 7, 7, 7, 9, 9, 0, 0, 0, 8, 8, - 8, 8, 9, 9, 0, 0, 0, 8, 8, 8, 8,10,10, 0, 0, 0, - 9, 9, 8, 8,10,10, 0, 0, 0, 9, 9, 8, 8,10,10, 0, - 0, 0,10,10, 9, 9,10,10, 0, 0, 0, 0, 0, 9, 9,10, - 10, -}; - -static const static_codebook _16c1_s_p5_0 = { - 2, 81, - (char *)_vq_lengthlist__16c1_s_p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__16c1_s_p5_0, - 0 -}; - -static const long _vq_quantlist__16c1_s_p6_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__16c1_s_p6_0[] = { - 1, 3, 3, 6, 6, 8, 8, 9, 9, 9, 9,10,10,11,11,12, - 12, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,11,11, - 12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,11, - 11,12,12, 0, 0, 0, 8, 8, 8, 9,10, 9,10,10,10,10, - 11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10,10,11, - 11,11,12,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10,10, - 11,11,12,12,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10, - 10,11,11,12,12,13,13, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9, - 10,10,11,11,12,12,12,12,13,13, 0, 0, 0, 0, 0, 9, - 9,10,10,11,11,12,12,12,12,13,13, 0, 0, 0, 0, 0, - 10,10,11,10,11,11,12,12,13,13,13,13, 0, 0, 0, 0, - 0, 0, 0,10,10,11,11,12,12,13,13,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,12,12,12,12,13,13,14,14, 0, 0, - 0, 0, 0, 0, 0,11,11,12,12,12,12,13,13,14,14, 0, - 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,13,13,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,13,13,13,13,14, - 14, -}; - -static const static_codebook _16c1_s_p6_0 = { - 2, 289, - (char *)_vq_lengthlist__16c1_s_p6_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__16c1_s_p6_0, - 0 -}; - -static const long _vq_quantlist__16c1_s_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16c1_s_p7_0[] = { - 1, 4, 4, 6, 6, 6, 7, 6, 6, 4, 7, 7,10, 9,10,10, - 10, 9, 4, 7, 7,10,10,10,11,10,10, 6,10,10,11,11, - 11,11,10,10, 6,10, 9,11,11,11,11,10,10, 6,10,10, - 11,11,11,11,10,10, 7,11,11,11,11,11,12,12,11, 6, - 10,10,11,10,10,11,11,11, 6,10,10,10,11,10,11,11, - 11, -}; - -static const static_codebook _16c1_s_p7_0 = { - 4, 81, - (char *)_vq_lengthlist__16c1_s_p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__16c1_s_p7_0, - 0 -}; - -static const long _vq_quantlist__16c1_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__16c1_s_p7_1[] = { - 2, 3, 3, 5, 6, 7, 7, 7, 7, 8, 8,10,10,10, 6, 6, - 7, 7, 8, 8, 8, 8,10,10,10, 6, 6, 7, 7, 8, 8, 8, - 8,10,10,10, 7, 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, - 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, - 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 9, 9,10,10,10,10,10, 8, 8, 8, - 8, 9, 9,10,10,10,10,10, 9, 9, 8, 8, 9, 9,10,10, - 10,10,10, 8, 8, 8, 8, 9, 9, -}; - -static const static_codebook _16c1_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__16c1_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__16c1_s_p7_1, - 0 -}; - -static const long _vq_quantlist__16c1_s_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__16c1_s_p8_0[] = { - 1, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 6, 5, 5, - 7, 8, 8, 9, 8, 8, 9, 9,10,11, 6, 5, 5, 8, 8, 9, - 9, 8, 8, 9,10,10,11, 0, 8, 8, 8, 9, 9, 9, 9, 9, - 10,10,11,11, 0, 9, 9, 9, 8, 9, 9, 9, 9,10,10,11, - 11, 0,13,13, 9, 9,10,10,10,10,11,11,12,12, 0,14, - 13, 9, 9,10,10,10,10,11,11,12,12, 0, 0, 0,10,10, - 9, 9,11,11,12,12,13,12, 0, 0, 0,10,10, 9, 9,10, - 10,12,12,13,13, 0, 0, 0,13,14,11,10,11,11,12,12, - 13,14, 0, 0, 0,14,14,10,10,11,11,12,12,13,13, 0, - 0, 0, 0, 0,12,12,12,12,13,13,14,15, 0, 0, 0, 0, - 0,12,12,12,12,13,13,14,15, -}; - -static const static_codebook _16c1_s_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__16c1_s_p8_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__16c1_s_p8_0, - 0 -}; - -static const long _vq_quantlist__16c1_s_p8_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16c1_s_p8_1[] = { - 2, 3, 3, 5, 5, 6, 6, 6, 5, 5, 6, 6, 6, 5, 5, 6, - 6, 6, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _16c1_s_p8_1 = { - 2, 25, - (char *)_vq_lengthlist__16c1_s_p8_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16c1_s_p8_1, - 0 -}; - -static const long _vq_quantlist__16c1_s_p9_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__16c1_s_p9_0[] = { - 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _16c1_s_p9_0 = { - 2, 169, - (char *)_vq_lengthlist__16c1_s_p9_0, - 1, -513964032, 1628680192, 4, 0, - (long *)_vq_quantlist__16c1_s_p9_0, - 0 -}; - -static const long _vq_quantlist__16c1_s_p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__16c1_s_p9_1[] = { - 1, 4, 4, 4, 4, 8, 8,12,13,14,14,14,14,14,14, 6, - 6, 6, 6, 6,10, 9,14,14,14,14,14,14,14,14, 7, 6, - 5, 6, 6,10, 9,12,13,13,13,13,13,13,13,13, 7, 7, - 9, 9,11,11,12,13,13,13,13,13,13,13,13, 7, 7, 8, - 8,11,12,13,13,13,13,13,13,13,13,13,12,12,10,10, - 13,12,13,13,13,13,13,13,13,13,13,12,12,10,10,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,12,13,12, - 13,13,13,13,13,13,13,13,13,13,13,13,12,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,12,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,12,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13, -}; - -static const static_codebook _16c1_s_p9_1 = { - 2, 225, - (char *)_vq_lengthlist__16c1_s_p9_1, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__16c1_s_p9_1, - 0 -}; - -static const long _vq_quantlist__16c1_s_p9_2[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__16c1_s_p9_2[] = { - 1, 4, 4, 6, 6, 7, 7, 8, 7, 8, 8, 9, 9, 9, 9,10, - 10,10, 9,10,10,11,12,12, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,10,10,10,11,11,10,12,11,11,13,11, 7, 7, 8, - 8, 8, 8, 9, 9, 9,10,10,10,10, 9,10,10,11,11,12, - 11,11, 8, 8, 8, 8, 9, 9,10,10,10,10,11,11,11,11, - 11,11,11,12,11,12,12, 8, 8, 9, 9, 9, 9, 9,10,10, - 10,10,10,10,11,11,11,11,11,11,12,11, 9, 9, 9, 9, - 10,10,10,10,11,10,11,11,11,11,11,11,12,12,12,12, - 11, 9, 9, 9, 9,10,10,10,10,11,11,11,11,11,11,11, - 11,11,12,12,12,13, 9,10,10, 9,11,10,10,10,10,11, - 11,11,11,11,10,11,12,11,12,12,11,12,11,10, 9,10, - 10,11,10,11,11,11,11,11,11,11,11,11,12,12,11,12, - 12,12,10,10,10,11,10,11,11,11,11,11,11,11,11,11, - 11,11,12,13,12,12,11, 9,10,10,11,11,10,11,11,11, - 12,11,11,11,11,11,12,12,13,13,12,13,10,10,12,10, - 11,11,11,11,11,11,11,11,11,12,12,11,13,12,12,12, - 12,13,12,11,11,11,11,11,11,12,11,12,11,11,11,11, - 12,12,13,12,11,12,12,11,11,11,11,11,12,11,11,11, - 11,12,11,11,12,11,12,13,13,12,12,12,12,11,11,11, - 11,11,12,11,11,12,11,12,11,11,11,11,13,12,12,12, - 12,13,11,11,11,12,12,11,11,11,12,11,12,12,12,11, - 12,13,12,11,11,12,12,11,12,11,11,11,12,12,11,12, - 11,11,11,12,12,12,12,13,12,13,12,12,12,12,11,11, - 12,11,11,11,11,11,11,12,12,12,13,12,11,13,13,12, - 12,11,12,10,11,11,11,11,12,11,12,12,11,12,12,13, - 12,12,13,12,12,12,12,12,11,12,12,12,11,12,11,11, - 11,12,13,12,13,13,13,13,13,12,13,13,12,12,13,11, - 11,11,11,11,12,11,11,12,11, -}; - -static const static_codebook _16c1_s_p9_2 = { - 2, 441, - (char *)_vq_lengthlist__16c1_s_p9_2, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__16c1_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__16c1_s_short[] = { - 5, 6,17, 8,12, 9,10,10,12,13, 5, 2,17, 4, 9, 5, - 7, 8,11,13,16,16,16,16,16,16,16,16,16,16, 6, 4, - 16, 5,10, 5, 7,10,14,16,13, 9,16,11, 8, 7, 8, 9, - 13,16, 7, 4,16, 5, 7, 4, 6, 8,11,13, 8, 6,16, 7, - 8, 5, 5, 7, 9,13, 9, 8,16, 9, 8, 6, 6, 7, 9,13, - 11,11,16,10,10, 7, 7, 7, 9,13,13,13,16,13,13, 9, - 9, 9,10,13, -}; - -static const static_codebook _huff_book__16c1_s_short = { - 2, 100, - (char *)_huff_lengthlist__16c1_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__16c2_s_long[] = { - 4, 7, 9, 9, 9, 8, 9,10,13,16, 5, 4, 5, 6, 7, 7, - 8, 9,12,16, 6, 5, 5, 5, 7, 7, 9,10,12,15, 7, 6, - 5, 4, 5, 6, 8, 9,10,13, 8, 7, 7, 5, 5, 5, 7, 9, - 10,12, 7, 7, 7, 6, 5, 5, 6, 7,10,12, 8, 8, 8, 7, - 7, 5, 5, 6, 9,11, 8, 9, 9, 8, 8, 6, 6, 5, 8,11, - 10,11,12,12,11, 9, 9, 8, 9,12,13,14,15,15,14,12, - 12,11,11,13, -}; - -static const static_codebook _huff_book__16c2_s_long = { - 2, 100, - (char *)_huff_lengthlist__16c2_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__16c2_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16c2_s_p1_0[] = { - 1, 3, 3, 0, 0, 0, 0, 0, 0, 4, 5, 5, 0, 0, 0, 0, - 0, 0, 4, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _16c2_s_p1_0 = { - 4, 81, - (char *)_vq_lengthlist__16c2_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__16c2_s_p1_0, - 0 -}; - -static const long _vq_quantlist__16c2_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16c2_s_p2_0[] = { - 2, 4, 4, 7, 7, 0, 0, 0, 8, 8, 0, 0, 0, 8, 8, 0, - 0, 0, 8, 8, 0, 0, 0, 8, 8, 4, 4, 4, 8, 7, 0, 0, - 0, 8, 8, 0, 0, 0, 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, - 9, 9, 4, 4, 4, 7, 8, 0, 0, 0, 8, 8, 0, 0, 0, 8, - 8, 0, 0, 0, 9, 9, 0, 0, 0, 9, 9, 7, 8, 8,10, 9, - 0, 0, 0,12,11, 0, 0, 0,11,12, 0, 0, 0,14,13, 0, - 0, 0,14,14, 7, 8, 8, 9,10, 0, 0, 0,11,12, 0, 0, - 0,11,11, 0, 0, 0,14,14, 0, 0, 0,14,14, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8,11,11, 0, 0, 0, - 12,11, 0, 0, 0,12,12, 0, 0, 0,13,12, 0, 0, 0,13, - 13, 8, 8, 8,11,11, 0, 0, 0,11,11, 0, 0, 0,12,12, - 0, 0, 0,13,13, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 8, 9, 8,12,11, 0, 0, 0,12,12, 0, - 0, 0,12,11, 0, 0, 0,13,13, 0, 0, 0,13,13, 8, 8, - 8,11,12, 0, 0, 0,11,12, 0, 0, 0,11,12, 0, 0, 0, - 13,14, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 8, 9, 9,14,14, 0, 0, 0,13,13, 0, 0, 0,13, - 13, 0, 0, 0,13,12, 0, 0, 0,13,13, 8, 9, 9,14,14, - 0, 0, 0,13,13, 0, 0, 0,13,13, 0, 0, 0,12,13, 0, - 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, - 9, 9,14,14, 0, 0, 0,13,13, 0, 0, 0,13,13, 0, 0, - 0,13,13, 0, 0, 0,13,12, 8, 9, 9,14,14, 0, 0, 0, - 13,13, 0, 0, 0,13,13, 0, 0, 0,13,13, 0, 0, 0,12, - 12, -}; - -static const static_codebook _16c2_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__16c2_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16c2_s_p2_0, - 0 -}; - -static const long _vq_quantlist__16c2_s_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__16c2_s_p3_0[] = { - 1, 3, 3, 5, 5, 7, 7, 8, 8, 0, 0, 0, 6, 6, 8, 8, - 9, 9, 0, 0, 0, 6, 6, 8, 8, 9, 9, 0, 0, 0, 7, 7, - 8, 9,10,10, 0, 0, 0, 7, 7, 9, 9,10,10, 0, 0, 0, - 8, 8, 9, 9,11,11, 0, 0, 0, 7, 7, 9, 9,11,11, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _16c2_s_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__16c2_s_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__16c2_s_p3_0, - 0 -}; - -static const long _vq_quantlist__16c2_s_p4_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__16c2_s_p4_0[] = { - 2, 3, 3, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 9, - 9, 0, 0, 0, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10,10, - 11,10, 0, 0, 0, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10, - 10,10,10, 0, 0, 0, 6, 6, 8, 8, 9, 9, 9, 9,10,10, - 11,11,11,11, 0, 0, 0, 7, 6, 8, 8, 9, 9, 9, 9,10, - 10,11,11,11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9,10,10, - 11,11,11,11,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9,10, - 10,11,11,11,11,12,12, 0, 0, 0, 7, 8, 8, 8, 9, 9, - 10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 8, 8, 9, - 9,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _16c2_s_p4_0 = { - 2, 289, - (char *)_vq_lengthlist__16c2_s_p4_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__16c2_s_p4_0, - 0 -}; - -static const long _vq_quantlist__16c2_s_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16c2_s_p5_0[] = { - 1, 4, 4, 5, 7, 7, 6, 7, 7, 4, 6, 6,10,11,10,10, - 10,11, 4, 6, 6,10,10,11,10,11,10, 5,10,10, 9,12, - 11,10,12,12, 7,10,10,12,12,12,12,13,13, 7,11,10, - 11,12,12,12,13,13, 6,11,10,10,12,12,11,12,12, 7, - 11,10,12,13,13,12,12,12, 7,10,11,12,13,13,12,12, - 12, -}; - -static const static_codebook _16c2_s_p5_0 = { - 4, 81, - (char *)_vq_lengthlist__16c2_s_p5_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__16c2_s_p5_0, - 0 -}; - -static const long _vq_quantlist__16c2_s_p5_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__16c2_s_p5_1[] = { - 2, 3, 3, 6, 6, 6, 6, 7, 7, 7, 7,11,10,10, 6, 6, - 7, 7, 8, 8, 8, 8,10,10,10, 6, 6, 7, 7, 8, 8, 8, - 8,11,11,11, 7, 7, 8, 8, 8, 8, 9, 9,11,11,11, 6, - 7, 8, 8, 8, 8, 9, 9,11,11,11, 7, 7, 8, 8, 8, 8, - 8, 8,11,11,11, 7, 7, 8, 8, 8, 8, 9, 9,11,11,11, - 8, 8, 8, 8, 8, 8, 8, 8,11,11,11,11,11, 8, 8, 8, - 8, 8, 8,12,11,11,11,11, 8, 8, 8, 8, 8, 8,12,11, - 11,11,11, 7, 7, 8, 8, 8, 8, -}; - -static const static_codebook _16c2_s_p5_1 = { - 2, 121, - (char *)_vq_lengthlist__16c2_s_p5_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__16c2_s_p5_1, - 0 -}; - -static const long _vq_quantlist__16c2_s_p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__16c2_s_p6_0[] = { - 1, 4, 4, 6, 6, 8, 7, 8, 8, 9, 9,10,10, 5, 5, 5, - 7, 7, 9, 9, 9, 9,11,11,12,12, 6, 5, 5, 7, 7, 9, - 9,10, 9,11,11,12,12, 0, 7, 7, 7, 7, 9, 9,10,10, - 11,11,12,12, 0, 7, 7, 7, 7, 9, 9,10,10,11,11,12, - 12, 0,11,11, 8, 8,10,10,11,11,12,12,13,13, 0,12, - 12, 9, 9,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 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 static_codebook _16c2_s_p6_0 = { - 2, 169, - (char *)_vq_lengthlist__16c2_s_p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__16c2_s_p6_0, - 0 -}; - -static const long _vq_quantlist__16c2_s_p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16c2_s_p6_1[] = { - 2, 3, 3, 5, 5, 6, 6, 6, 5, 5, 6, 6, 6, 5, 5, 6, - 6, 6, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _16c2_s_p6_1 = { - 2, 25, - (char *)_vq_lengthlist__16c2_s_p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16c2_s_p6_1, - 0 -}; - -static const long _vq_quantlist__16c2_s_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__16c2_s_p7_0[] = { - 1, 4, 4, 7, 7, 8, 8, 8, 8,10, 9,10,10, 5, 5, 5, - 7, 7, 9, 9,10,10,11,10,12,11, 6, 5, 5, 7, 7, 9, - 9,10,10,11,11,12,12,20, 7, 7, 7, 7, 9, 9,10,10, - 11,11,12,12,20, 7, 7, 7, 7, 9, 9,11,10,12,11,12, - 12,20,11,11, 8, 8,10,10,11,11,12,12,13,13,20,12, - 12, 8, 8, 9, 9,11,11,12,12,13,13,20,20,21,10,10, - 10,10,11,11,12,12,13,13,21,21,21,10,10,10,10,11, - 11,12,12,13,13,21,21,21,14,14,11,11,12,12,13,13, - 13,14,21,21,21,16,15,11,11,12,11,13,13,14,14,21, - 21,21,21,21,13,13,12,12,13,13,14,14,21,21,21,21, - 21,13,13,12,12,13,13,14,14, -}; - -static const static_codebook _16c2_s_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__16c2_s_p7_0, - 1, -523206656, 1618345984, 4, 0, - (long *)_vq_quantlist__16c2_s_p7_0, - 0 -}; - -static const long _vq_quantlist__16c2_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__16c2_s_p7_1[] = { - 2, 4, 4, 6, 6, 7, 7, 7, 7, 7, 7, 9, 9, 9, 6, 7, - 7, 7, 7, 7, 8, 8, 9, 9, 9, 6, 6, 7, 7, 7, 7, 8, - 8, 9, 9, 9, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 7, - 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 7, 7, 7, 7, 8, 8, - 8, 8, 9, 9, 9, 7, 7, 7, 7, 7, 7, 8, 8, 9, 9, 9, - 7, 7, 8, 8, 7, 7, 8, 8, 9, 9, 9, 9, 9, 8, 8, 7, - 7, 8, 8, 9, 9, 9, 9, 9, 8, 8, 7, 7, 8, 8, 9, 9, - 9, 9, 9, 7, 7, 7, 7, 8, 8, -}; - -static const static_codebook _16c2_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__16c2_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__16c2_s_p7_1, - 0 -}; - -static const long _vq_quantlist__16c2_s_p8_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__16c2_s_p8_0[] = { - 1, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9,10,10, 6, - 6, 6, 8, 8, 9, 9, 8, 8, 9, 9,10,10,11,11, 6, 5, - 5, 8, 7, 9, 9, 8, 8, 9, 9,10,10,11,11,20, 8, 8, - 8, 8, 9, 9, 9, 9,10,10,11,10,12,11,20, 8, 8, 8, - 8, 9, 9, 9, 9,10,10,11,11,12,12,20,12,12, 9, 9, - 10,10,10,10,11,11,12,12,13,12,20,13,13, 9, 9,10, - 10,10,10,11,11,12,12,13,13,20,20,20, 9, 9, 9, 9, - 10,10,11,11,12,12,13,12,20,20,20, 9, 9, 9, 8,10, - 10,12,11,12,12,13,13,20,20,20,13,13,10,10,11,11, - 12,12,13,13,13,13,20,20,20,13,13,10,10,11,10,12, - 11,13,13,14,14,20,20,20,20,20,11,11,11,11,12,12, - 13,13,14,14,20,20,20,20,20,11,10,11,11,13,11,13, - 13,14,14,20,20,21,21,21,14,14,11,12,13,13,13,13, - 14,14,21,21,21,21,21,15,15,12,11,13,12,14,13,15, - 14, -}; - -static const static_codebook _16c2_s_p8_0 = { - 2, 225, - (char *)_vq_lengthlist__16c2_s_p8_0, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__16c2_s_p8_0, - 0 -}; - -static const long _vq_quantlist__16c2_s_p8_1[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__16c2_s_p8_1[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8,11,11,11, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,11,10, 7, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11, - 11,11, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9,11,11,11, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9,10, 9,10,10,10,10,11,11,11, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,11,11, - 11, 8, 8, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10, - 10,10,10,11,11,11, 9, 9, 9, 9, 9, 9, 9, 9,10,10, - 10,10,10,10,10,10,10,10,11,11,11,11,11, 9, 9, 9, - 9, 9, 9,10,10,10,10,10,10,10,10,10,10,11,11,11, - 11,11, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10, - 10,10,11,11,11,11,11, 9, 9, 9, 9,10,10,10,10,10, - 10,10,10,10,10,10,10,11,11,11,11,11,10, 9,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11, - 11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,11,11,11,11,11,11,11,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11, - 11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10, - 10,10,10,10,10,11,11,11,11,11,11,11,11,11,10,10, - 10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11, - 11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,11, - 11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10, - 10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,10, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _16c2_s_p8_1 = { - 2, 441, - (char *)_vq_lengthlist__16c2_s_p8_1, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__16c2_s_p8_1, - 0 -}; - -static const long _vq_quantlist__16c2_s_p9_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__16c2_s_p9_0[] = { - 1, 4, 3,10, 8,10,10,10,10,10,10,10,10,10,10,10, - 10, 6,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10, 6,10, 9,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _16c2_s_p9_0 = { - 2, 289, - (char *)_vq_lengthlist__16c2_s_p9_0, - 1, -509798400, 1631393792, 5, 0, - (long *)_vq_quantlist__16c2_s_p9_0, - 0 -}; - -static const long _vq_quantlist__16c2_s_p9_1[] = { - 9, - 8, - 10, - 7, - 11, - 6, - 12, - 5, - 13, - 4, - 14, - 3, - 15, - 2, - 16, - 1, - 17, - 0, - 18, -}; - -static const char _vq_lengthlist__16c2_s_p9_1[] = { - 1, 4, 4, 7, 7, 7, 7, 7, 7, 8, 8,10, 9,11,10,13, - 11,14,13, 6, 6, 6, 8, 8, 8, 8, 8, 7, 9, 8,11, 9, - 13,11,14,12,14,13, 5, 6, 6, 8, 8, 8, 8, 8, 8, 9, - 9,11,11,13,11,14,13,15,15,17, 8, 8, 8, 8, 9, 9, - 9, 8,11, 9,12,10,13,11,14,12,14,13,17, 8, 8, 8, - 8, 9, 9, 9, 9,10,10,11,11,13,13,13,14,16,15,17, - 12,12, 8, 8, 9, 9,10,10,11,11,12,11,13,12,13,12, - 14,13,16,12,12, 8, 8, 9, 9,10,10,11,11,12,12,13, - 13,14,14,15,15,17,17,17, 9, 9, 9, 9,11,11,12,12, - 12,13,13,13,16,14,14,14,17,17,17, 9, 8, 9, 8,11, - 10,12,12,13,13,14,14,15,15,16,16,17,17,17,12,12, - 10,10,11,12,12,13,13,14,13,15,15,14,16,15,17,17, - 17,12,12,10, 8,12, 9,13,12,14,14,15,14,15,16,16, - 16,17,17,17,17,17,11,11,12,12,14,14,14,16,15,16, - 15,16,15,17,17,17,17,17,17,11, 9,12,10,13,11,15, - 14,16,16,17,16,16,15,17,17,17,17,17,15,15,12,12, - 14,14,15,16,16,15,16,16,17,17,17,17,17,17,17,14, - 14,12,10,14,11,15,12,17,16,15,16,17,16,17,17,17, - 17,17,17,17,13,13,14,14,14,16,17,17,16,17,17,17, - 17,17,17,17,17,17,17,13, 9,13,12,15,13,16,16,17, - 17,17,17,17,17,17,17,17,17,17,15,17,14,14,15,16, - 16,17,16,17,16,17,17,17,17,17,17,17,17,17,17,14, - 13,15,16,16,17,16,17,17,17, -}; - -static const static_codebook _16c2_s_p9_1 = { - 2, 361, - (char *)_vq_lengthlist__16c2_s_p9_1, - 1, -518287360, 1622704128, 5, 0, - (long *)_vq_quantlist__16c2_s_p9_1, - 0 -}; - -static const long _vq_quantlist__16c2_s_p9_2[] = { - 24, - 23, - 25, - 22, - 26, - 21, - 27, - 20, - 28, - 19, - 29, - 18, - 30, - 17, - 31, - 16, - 32, - 15, - 33, - 14, - 34, - 13, - 35, - 12, - 36, - 11, - 37, - 10, - 38, - 9, - 39, - 8, - 40, - 7, - 41, - 6, - 42, - 5, - 43, - 4, - 44, - 3, - 45, - 2, - 46, - 1, - 47, - 0, - 48, -}; - -static const char _vq_lengthlist__16c2_s_p9_2[] = { - 2, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, - 6, 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, -}; - -static const static_codebook _16c2_s_p9_2 = { - 1, 49, - (char *)_vq_lengthlist__16c2_s_p9_2, - 1, -526909440, 1611661312, 6, 0, - (long *)_vq_quantlist__16c2_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__16c2_s_short[] = { - 7,10,12,11,12,13,15,16,18,15,10, 8, 8, 8, 9,10, - 12,13,14,17,10, 7, 7, 7, 7, 8,10,12,15,18,10, 7, - 7, 5, 5, 6, 8,10,13,15,10, 7, 6, 5, 4, 4, 6, 9, - 12,15,11, 7, 7, 5, 4, 3, 4, 7,11,13,12, 9, 8, 7, - 5, 4, 4, 5,10,13,11,11,11, 9, 7, 5, 5, 5, 9,12, - 13,12,13,12,10, 8, 8, 7, 9,13,14,14,14,14,13,11, - 11,10,10,13, -}; - -static const static_codebook _huff_book__16c2_s_short = { - 2, 100, - (char *)_huff_lengthlist__16c2_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__8c0_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8c0_s_p1_0[] = { - 1, 5, 4, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 7, 8, 9, 0, 0, 0, - 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 7, 9, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 8, 0, 0, 0, 0, - 0, 0, 8,10,10, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,10, 9, 0, 0, 0, - 0, 0, 0, 8, 9,11, 0, 0, 0, 0, 0, 0, 9,11,11, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9,10, 0, 0, - 0, 0, 0, 0, 9,11,10, 0, 0, 0, 0, 0, 0, 9,11,11, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, - 0, 0, 0, 0, 8, 9,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,11,11, 0, - 0, 0, 0, 0, 0, 9,10,11, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 9,10, 0, 0, 0, 0, 0, 0, 9,11,11, - 0, 0, 0, 0, 0, 0, 8,11, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _8c0_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__8c0_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__8c0_s_p1_0, - 0 -}; - -static const long _vq_quantlist__8c0_s_p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__8c0_s_p3_0[] = { - 1, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 5, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 7, 8, 8, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 7, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _8c0_s_p3_0 = { - 4, 625, - (char *)_vq_lengthlist__8c0_s_p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__8c0_s_p3_0, - 0 -}; - -static const long _vq_quantlist__8c0_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__8c0_s_p4_0[] = { - 1, 2, 3, 7, 7, 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 8, 8, 0, 0, 0, 0, 0, 0, 0, 9, 8, 0, 0, 0, 0, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _8c0_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__8c0_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__8c0_s_p4_0, - 0 -}; - -static const long _vq_quantlist__8c0_s_p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__8c0_s_p5_0[] = { - 1, 3, 3, 5, 5, 7, 6, 8, 8, 0, 0, 0, 7, 7, 7, 7, - 8, 8, 0, 0, 0, 7, 7, 7, 7, 8, 9, 0, 0, 0, 8, 8, - 8, 8, 9, 9, 0, 0, 0, 8, 8, 8, 8, 9, 9, 0, 0, 0, - 9, 9, 8, 8,10,10, 0, 0, 0, 9, 9, 8, 8,10,10, 0, - 0, 0,10,10, 9, 9,10,10, 0, 0, 0, 0, 0, 9, 9,10, - 10, -}; - -static const static_codebook _8c0_s_p5_0 = { - 2, 81, - (char *)_vq_lengthlist__8c0_s_p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__8c0_s_p5_0, - 0 -}; - -static const long _vq_quantlist__8c0_s_p6_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__8c0_s_p6_0[] = { - 1, 3, 3, 6, 6, 8, 8, 9, 9, 8, 8,10, 9,10,10,11, - 11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,11,11, - 11,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,11, - 11,12,11, 0, 0, 0, 8, 8, 9, 9,10,10, 9, 9,10,10, - 11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10,10, 9, 9,11, - 10,11,11,12,12, 0, 0, 0, 9, 9, 9, 9,10,10,10,10, - 11,11,11,12,12,12, 0, 0, 0, 9, 9, 9, 9,10,10,10, - 10,11,11,12,12,13,13, 0, 0, 0,10,10,10,10,11,11, - 10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0,10, 9,10, - 11,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9, - 10, 9,10,11,12,12,13,13,14,13, 0, 0, 0, 0, 0, 9, - 9, 9,10,10,10,11,11,13,12,13,13, 0, 0, 0, 0, 0, - 10,10,10,10,11,11,12,12,13,13,14,14, 0, 0, 0, 0, - 0, 0, 0,10,10,11,11,12,12,13,13,13,14, 0, 0, 0, - 0, 0, 0, 0,11,11,11,11,12,12,13,14,14,14, 0, 0, - 0, 0, 0, 0, 0,11,11,11,11,12,12,13,13,14,13, 0, - 0, 0, 0, 0, 0, 0,11,11,12,12,13,13,14,14,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,14, - 14, -}; - -static const static_codebook _8c0_s_p6_0 = { - 2, 289, - (char *)_vq_lengthlist__8c0_s_p6_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__8c0_s_p6_0, - 0 -}; - -static const long _vq_quantlist__8c0_s_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8c0_s_p7_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7,11, 9,10,12, - 9,10, 4, 7, 7,10,10,10,11, 9, 9, 6,11,10,11,11, - 12,11,11,11, 6,10,10,11,11,12,11,10,10, 6, 9,10, - 11,11,11,11,10,10, 7,10,11,12,11,11,12,11,12, 6, - 9, 9,10, 9, 9,11,10,10, 6, 9, 9,10,10,10,11,10, - 10, -}; - -static const static_codebook _8c0_s_p7_0 = { - 4, 81, - (char *)_vq_lengthlist__8c0_s_p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__8c0_s_p7_0, - 0 -}; - -static const long _vq_quantlist__8c0_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__8c0_s_p7_1[] = { - 1, 3, 3, 6, 6, 8, 8, 9, 9, 9, 9,10,10,10, 7, 7, - 8, 8, 9, 9, 9, 9,10,10, 9, 7, 7, 8, 8, 9, 9, 9, - 9,10,10,10, 8, 8, 9, 9, 9, 9, 9, 9,10,10,10, 8, - 8, 9, 9, 9, 9, 8, 9,10,10,10, 8, 8, 9, 9, 9,10, - 10,10,10,10,10, 9, 9, 9, 9, 9, 9,10,10,11,10,11, - 9, 9, 9, 9,10,10,10,10,11,11,11,10,10, 9, 9,10, - 10,10, 9,11,10,10,10,10,10,10, 9, 9,10,10,11,11, - 10,10,10, 9, 9, 9,10,10,10, -}; - -static const static_codebook _8c0_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__8c0_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__8c0_s_p7_1, - 0 -}; - -static const long _vq_quantlist__8c0_s_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__8c0_s_p8_0[] = { - 1, 4, 4, 7, 6, 7, 7, 7, 7, 8, 8, 9, 9, 7, 6, 6, - 7, 7, 8, 8, 7, 7, 8, 9,10,10, 7, 6, 6, 7, 7, 8, - 7, 7, 7, 9, 9,10,12, 0, 8, 8, 8, 8, 8, 9, 8, 8, - 9, 9,10,10, 0, 8, 8, 8, 8, 8, 9, 8, 9, 9, 9,11, - 10, 0, 0,13, 9, 8, 9, 9, 9, 9,10,10,11,11, 0,13, - 0, 9, 9, 9, 9, 9, 9,11,10,11,11, 0, 0, 0, 8, 9, - 10, 9,10,10,13,11,12,12, 0, 0, 0, 8, 9, 9, 9,10, - 10,13,12,12,13, 0, 0, 0,12, 0,10,10,12,11,10,11, - 12,12, 0, 0, 0,13,13,10,10,10,11,12, 0,13, 0, 0, - 0, 0, 0, 0,13,11, 0,12,12,12,13,12, 0, 0, 0, 0, - 0, 0,13,13,11,13,13,11,12, -}; - -static const static_codebook _8c0_s_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__8c0_s_p8_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__8c0_s_p8_0, - 0 -}; - -static const long _vq_quantlist__8c0_s_p8_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__8c0_s_p8_1[] = { - 1, 3, 4, 5, 5, 7, 6, 6, 6, 5, 7, 7, 7, 6, 6, 7, - 7, 7, 6, 6, 7, 7, 7, 6, 6, -}; - -static const static_codebook _8c0_s_p8_1 = { - 2, 25, - (char *)_vq_lengthlist__8c0_s_p8_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__8c0_s_p8_1, - 0 -}; - -static const long _vq_quantlist__8c0_s_p9_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8c0_s_p9_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 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, 7, 7, 7, 7, 7, 7, 7, - 7, -}; - -static const static_codebook _8c0_s_p9_0 = { - 4, 81, - (char *)_vq_lengthlist__8c0_s_p9_0, - 1, -518803456, 1628680192, 2, 0, - (long *)_vq_quantlist__8c0_s_p9_0, - 0 -}; - -static const long _vq_quantlist__8c0_s_p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__8c0_s_p9_1[] = { - 1, 4, 4, 5, 5,10, 8,11,11,11,11,11,11,11,11, 6, - 6, 6, 7, 6,11,10,11,11,11,11,11,11,11,11, 7, 5, - 6, 6, 6, 8, 7,11,11,11,11,11,11,11,11,11, 7, 8, - 8, 8, 9, 9,11,11,11,11,11,11,11,11,11, 9, 8, 7, - 8, 9,11,11,11,11,11,11,11,11,11,11,11,10,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,10,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11, -}; - -static const static_codebook _8c0_s_p9_1 = { - 2, 225, - (char *)_vq_lengthlist__8c0_s_p9_1, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__8c0_s_p9_1, - 0 -}; - -static const long _vq_quantlist__8c0_s_p9_2[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__8c0_s_p9_2[] = { - 1, 5, 5, 7, 7, 8, 7, 8, 8,10,10, 9, 9,10,10,10, - 11,11,10,12,11,12,12,12, 9, 8, 8, 8, 8, 8, 9,10, - 10,10,10,11,11,11,10,11,11,12,12,11,12, 8, 8, 7, - 7, 8, 9,10,10,10, 9,10,10, 9,10,10,11,11,11,11, - 11,11, 9, 9, 9, 9, 8, 9,10,10,11,10,10,11,11,12, - 10,10,12,12,11,11,10, 9, 9,10, 8, 9,10,10,10, 9, - 10,10,11,11,10,11,10,10,10,12,12,12, 9,10, 9,10, - 9, 9,10,10,11,11,11,11,10,10,10,11,12,11,12,11, - 12,10,11,10,11, 9,10, 9,10, 9,10,10, 9,10,10,11, - 10,11,11,11,11,12,11, 9,10,10,10,10,11,11,11,11, - 11,10,11,11,11,11,10,12,10,12,12,11,12,10,10,11, - 10, 9,11,10,11, 9,10,11,10,10,10,11,11,11,11,12, - 12,10, 9, 9,11,10, 9,12,11,10,12,12,11,11,11,11, - 10,11,11,12,11,10,12, 9,11,10,11,10,10,11,10,11, - 9,10,10,10,11,12,11,11,12,11,10,10,11,11, 9,10, - 10,12,10,11,10,10,10, 9,10,10,10,10, 9,10,10,11, - 11,11,11,12,11,10,10,10,10,11,11,10,11,11, 9,11, - 10,12,10,12,11,10,11,10,10,10,11,10,10,11,11,10, - 11,10,10,10,10,11,11,12,10,10,10,11,10,11,12,11, - 10,11,10,10,11,11,10,12,10, 9,10,10,11,11,11,10, - 12,10,10,11,11,11,10,10,11,10,10,10,11,10,11,10, - 12,11,11,10,10,10,12,10,10,11, 9,10,11,11,11,10, - 10,11,10,10, 9,11,11,12,12,11,12,11,11,11,11,11, - 11, 9,10,11,10,12,10,10,10,10,11,10,10,11,10,10, - 12,10,10,10,10,10, 9,12,10,10,10,10,12, 9,11,10, - 10,11,10,12,12,10,12,12,12,10,10,10,10, 9,10,11, - 10,10,12,10,10,12,11,10,11,10,10,12,11,10,12,10, - 10,11, 9,11,10, 9,10, 9,10, -}; - -static const static_codebook _8c0_s_p9_2 = { - 2, 441, - (char *)_vq_lengthlist__8c0_s_p9_2, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__8c0_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__8c0_s_single[] = { - 4, 5,18, 7,10, 6, 7, 8, 9,10, 5, 2,18, 5, 7, 5, - 6, 7, 8,11,17,17,17,17,17,17,17,17,17,17, 7, 4, - 17, 6, 9, 6, 8,10,12,15,11, 7,17, 9, 6, 6, 7, 9, - 11,15, 6, 4,17, 6, 6, 4, 5, 8,11,16, 6, 6,17, 8, - 6, 5, 6, 9,13,16, 8, 9,17,11, 9, 8, 8,11,13,17, - 9,12,17,15,14,13,12,13,14,17,12,15,17,17,17,17, - 17,16,17,17, -}; - -static const static_codebook _huff_book__8c0_s_single = { - 2, 100, - (char *)_huff_lengthlist__8c0_s_single, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__8c1_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8c1_s_p1_0[] = { - 1, 5, 5, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 8, 7, 0, 0, 0, 0, 0, 0, 7, 8, 9, 0, 0, 0, - 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 8, 0, 0, 0, 0, 0, 0, 7, 9, 8, 0, 0, - 0, 0, 0, 0, 7, 9, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 8, 0, 0, 0, 0, - 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 8, 8,10, 0, 0, 0, 0, 0, 0, 9,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 8,10, 9, 0, 0, 0, 0, 0, 0, 9,10,10, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, - 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,10,10, 0, - 0, 0, 0, 0, 0, 8, 9,10, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,10,10, - 0, 0, 0, 0, 0, 0, 8,10, 8, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _8c1_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__8c1_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__8c1_s_p1_0, - 0 -}; - -static const long _vq_quantlist__8c1_s_p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__8c1_s_p3_0[] = { - 2, 4, 4, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 6, 6, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _8c1_s_p3_0 = { - 4, 625, - (char *)_vq_lengthlist__8c1_s_p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__8c1_s_p3_0, - 0 -}; - -static const long _vq_quantlist__8c1_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__8c1_s_p4_0[] = { - 1, 2, 3, 7, 7, 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 8, 8, 0, 0, 0, 0, 0, 0, 0, 9, 8, 0, 0, 0, 0, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _8c1_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__8c1_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__8c1_s_p4_0, - 0 -}; - -static const long _vq_quantlist__8c1_s_p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__8c1_s_p5_0[] = { - 1, 3, 3, 4, 5, 6, 6, 8, 8, 0, 0, 0, 8, 8, 7, 7, - 9, 9, 0, 0, 0, 8, 8, 7, 7, 9, 9, 0, 0, 0, 9,10, - 8, 8, 9, 9, 0, 0, 0,10,10, 8, 8, 9, 9, 0, 0, 0, - 11,10, 8, 8,10,10, 0, 0, 0,11,11, 8, 8,10,10, 0, - 0, 0,12,12, 9, 9,10,10, 0, 0, 0, 0, 0, 9, 9,10, - 10, -}; - -static const static_codebook _8c1_s_p5_0 = { - 2, 81, - (char *)_vq_lengthlist__8c1_s_p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__8c1_s_p5_0, - 0 -}; - -static const long _vq_quantlist__8c1_s_p6_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__8c1_s_p6_0[] = { - 1, 3, 3, 5, 5, 8, 8, 8, 8, 9, 9,10,10,11,11,11, - 11, 0, 0, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11,11, - 12,12, 0, 0, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11,12,12, 0, 0, 0, 9, 9, 8, 8,10,10,10,10,11,11, - 12,12,12,12, 0, 0, 0, 9, 9, 8, 8,10,10,10,10,11, - 11,12,12,12,12, 0, 0, 0,10,10, 9, 9,10,10,10,10, - 11,11,12,12,13,13, 0, 0, 0,10,10, 9, 9,10,10,10, - 10,11,11,12,12,13,13, 0, 0, 0,11,11, 9, 9,10,10, - 10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9, - 10,10,11,11,12,12,12,12,13,13, 0, 0, 0, 0, 0, 9, - 9,10,10,11,11,12,11,12,12,13,13, 0, 0, 0, 0, 0, - 10,10,11,11,11,11,12,12,13,12,13,13, 0, 0, 0, 0, - 0, 0, 0,11,10,11,11,12,12,13,13,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,12,12,12,12,13,13,13,14, 0, 0, - 0, 0, 0, 0, 0,11,11,12,12,12,12,13,13,14,13, 0, - 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,13,13,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,13,13,13,13,14, - 14, -}; - -static const static_codebook _8c1_s_p6_0 = { - 2, 289, - (char *)_vq_lengthlist__8c1_s_p6_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__8c1_s_p6_0, - 0 -}; - -static const long _vq_quantlist__8c1_s_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8c1_s_p7_0[] = { - 1, 4, 4, 6, 6, 6, 7, 6, 6, 4, 7, 7,10, 9, 9,10, - 9, 9, 5, 7, 7,10, 9, 9,10, 9, 9, 6,10,10,10,10, - 10,11,10,10, 6, 9, 9,10, 9,10,11,10,10, 6, 9, 9, - 10, 9, 9,11, 9,10, 7,10,10,11,11,11,11,10,10, 6, - 9, 9,10,10,10,11, 9, 9, 6, 9, 9,10,10,10,10, 9, - 9, -}; - -static const static_codebook _8c1_s_p7_0 = { - 4, 81, - (char *)_vq_lengthlist__8c1_s_p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__8c1_s_p7_0, - 0 -}; - -static const long _vq_quantlist__8c1_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__8c1_s_p7_1[] = { - 2, 3, 3, 5, 5, 7, 7, 7, 7, 7, 7,10,10, 9, 7, 7, - 7, 7, 8, 8, 8, 8, 9, 9, 9, 7, 7, 7, 7, 8, 8, 8, - 8,10,10,10, 7, 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, - 7, 7, 7, 8, 8, 8, 8,10,10,10, 8, 8, 8, 8, 8, 8, - 8, 8,10,10,10, 8, 8, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 8, 8,10,10,10,10,10, 8, 8, 8, - 8, 8, 8,10,10,10,10,10, 8, 8, 8, 8, 8, 8,10,10, - 10,10,10, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _8c1_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__8c1_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__8c1_s_p7_1, - 0 -}; - -static const long _vq_quantlist__8c1_s_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__8c1_s_p8_0[] = { - 1, 4, 4, 6, 6, 8, 8, 8, 8, 9, 9,10,10, 7, 5, 5, - 7, 7, 8, 8, 8, 8, 9,10,11,11, 7, 5, 5, 7, 7, 8, - 8, 9, 9,10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 9,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9, 9, 9,10, 9,10,11,11,11, 0,13, - 12, 9, 8, 9, 9,10,10,11,11,12,11, 0, 0, 0, 9, 9, - 9, 9,10,10,11,11,12,12, 0, 0, 0,10,10, 9, 9,10, - 10,11,11,12,12, 0, 0, 0,13,13,10,10,11,11,12,11, - 13,12, 0, 0, 0,14,14,10,10,11,10,11,11,12,12, 0, - 0, 0, 0, 0,12,12,11,11,12,12,13,13, 0, 0, 0, 0, - 0,12,12,11,10,12,11,13,12, -}; - -static const static_codebook _8c1_s_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__8c1_s_p8_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__8c1_s_p8_0, - 0 -}; - -static const long _vq_quantlist__8c1_s_p8_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__8c1_s_p8_1[] = { - 2, 3, 3, 5, 5, 6, 6, 6, 5, 5, 6, 6, 6, 5, 5, 6, - 6, 6, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _8c1_s_p8_1 = { - 2, 25, - (char *)_vq_lengthlist__8c1_s_p8_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__8c1_s_p8_1, - 0 -}; - -static const long _vq_quantlist__8c1_s_p9_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__8c1_s_p9_0[] = { - 1, 3, 3,10,10,10,10,10,10,10,10,10,10, 5, 6, 6, - 10,10,10,10,10,10,10,10,10,10, 6, 7, 8,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10, 9, 9, 9, 9, -}; - -static const static_codebook _8c1_s_p9_0 = { - 2, 169, - (char *)_vq_lengthlist__8c1_s_p9_0, - 1, -513964032, 1628680192, 4, 0, - (long *)_vq_quantlist__8c1_s_p9_0, - 0 -}; - -static const long _vq_quantlist__8c1_s_p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__8c1_s_p9_1[] = { - 1, 4, 4, 5, 5, 7, 7, 9, 9,11,11,12,12,13,13, 6, - 5, 5, 6, 6, 9, 9,10,10,12,12,12,13,15,14, 6, 5, - 5, 7, 7, 9, 9,10,10,12,12,12,13,14,13,17, 7, 7, - 8, 8,10,10,11,11,12,13,13,13,13,13,17, 7, 7, 8, - 8,10,10,11,11,13,13,13,13,14,14,17,11,11, 9, 9, - 11,11,12,12,12,13,13,14,15,13,17,12,12, 9, 9,11, - 11,12,12,13,13,13,13,14,16,17,17,17,11,12,12,12, - 13,13,13,14,15,14,15,15,17,17,17,12,12,11,11,13, - 13,14,14,15,14,15,15,17,17,17,15,15,13,13,14,14, - 15,14,15,15,16,15,17,17,17,15,15,13,13,13,14,14, - 15,15,15,15,16,17,17,17,17,16,14,15,14,14,15,14, - 14,15,15,15,17,17,17,17,17,14,14,16,14,15,15,15, - 15,15,15,17,17,17,17,17,17,16,16,15,17,15,15,14, - 17,15,17,16,17,17,17,17,16,15,14,15,15,15,15,15, - 15, -}; - -static const static_codebook _8c1_s_p9_1 = { - 2, 225, - (char *)_vq_lengthlist__8c1_s_p9_1, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__8c1_s_p9_1, - 0 -}; - -static const long _vq_quantlist__8c1_s_p9_2[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__8c1_s_p9_2[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8, 9, 8, 9, 9, 9, - 9, 9, 9, 9, 9,11,11,12, 7, 7, 7, 7, 8, 8, 9, 9, - 9, 9,10,10,10,10,10,10,10,10,11,11,11, 7, 7, 7, - 7, 8, 8, 9, 8, 9, 9, 9, 9, 9, 9,10,10,10,10,11, - 11,12, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,10,10,10,10, - 10,10,10,10,11,11,11, 7, 7, 8, 8, 8, 8, 9, 9, 9, - 9,10,10,10,10,10,10,10,10,11,11,11, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,11,11, - 11, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9,10,10,10,10,10, - 10,10,10,11,12,11, 9, 9, 8, 9, 9, 9, 9, 9,10,10, - 10,10,10,10,10,10,10,10,11,11,11,11,11, 8, 8, 9, - 9, 9, 9,10,10,10,10,10,10,10,10,10,10,11,12,11, - 12,11, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10, - 10,10,11,11,11,11,11, 9, 9, 9, 9,10,10,10,10,10, - 10,10,10,10,10,10,10,12,11,12,11,11, 9, 9, 9,10, - 10,10,10,10,10,10,10,10,10,10,10,10,12,11,11,11, - 11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10, - 11,11,11,12,11,11,12,11,10,10,10,10,10,10,10,10, - 10,10,10,10,11,10,11,11,11,11,11,11,11,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,11,11,12,11,12, - 11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 11,11,12,11,12,11,11,11,11,10,10,10,10,10,10,10, - 10,10,10,10,10,11,11,12,11,11,12,11,11,12,10,10, - 11,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11, - 11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,12, - 12,11,12,11,11,12,12,12,11,11,10,10,10,10,10,10, - 10,10,10,11,12,12,11,12,12,11,12,11,11,11,11,10, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _8c1_s_p9_2 = { - 2, 441, - (char *)_vq_lengthlist__8c1_s_p9_2, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__8c1_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__8c1_s_single[] = { - 4, 6,18, 8,11, 8, 8, 9, 9,10, 4, 4,18, 5, 9, 5, - 6, 7, 8,10,18,18,18,18,17,17,17,17,17,17, 7, 5, - 17, 6,11, 6, 7, 8, 9,12,12, 9,17,12, 8, 8, 9,10, - 10,13, 7, 5,17, 6, 8, 4, 5, 6, 8,10, 6, 5,17, 6, - 8, 5, 4, 5, 7, 9, 7, 7,17, 8, 9, 6, 5, 5, 6, 8, - 8, 8,17, 9,11, 8, 6, 6, 6, 7, 9,10,17,12,12,10, - 9, 7, 7, 8, -}; - -static const static_codebook _huff_book__8c1_s_single = { - 2, 100, - (char *)_huff_lengthlist__8c1_s_single, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c2_s_long[] = { - 6, 6,12,10,10,10, 9,10,12,12, 6, 1,10, 5, 6, 6, - 7, 9,11,14,12, 9, 8,11, 7, 8, 9,11,13,15,10, 5, - 12, 7, 8, 7, 9,12,14,15,10, 6, 7, 8, 5, 6, 7, 9, - 12,14, 9, 6, 8, 7, 6, 6, 7, 9,12,12, 9, 7, 9, 9, - 7, 6, 6, 7,10,10,10, 9,10,11, 8, 7, 6, 6, 8,10, - 12,11,13,13,11,10, 8, 8, 8,10,11,13,15,15,14,13, - 10, 8, 8, 9, -}; - -static const static_codebook _huff_book__44c2_s_long = { - 2, 100, - (char *)_huff_lengthlist__44c2_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c2_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c2_s_p1_0[] = { - 2, 4, 4, 0, 0, 0, 0, 0, 0, 5, 6, 6, 0, 0, 0, 0, - 0, 0, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, - 0, 0, 0, 6, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 6, 8, 7, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, - 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 8, 8, 0, 0, - 0, 0, 0, 0, 8, 9, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7, 7, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, - 0, 0, 0, 0, 0, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, - 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c2_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44c2_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c2_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c2_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c2_s_p2_0[] = { - 1, 4, 4, 0, 0, 0, 7, 7, 0, 0, 0, 7, 7, 0, 0, 0, - 8, 8, 0, 0, 0, 0, 0, 0, 0, 4, 6, 6, 0, 0, 0, 8, - 8, 0, 0, 0, 8, 8, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 4, 6, 6, 0, 0, 0, 8, 8, 0, 0, 0, 8, 8, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, 0,11,11, 0, 0, - 0,11,11, 0, 0, 0,12,11, 0, 0, 0, 0, 0, 0, 0, 7, - 8, 8, 0, 0, 0,10,11, 0, 0, 0,11,11, 0, 0, 0,11, - 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 8, 8, 0, 0, 0,11,11, 0, 0, 0,11,11, - 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 6, 8, 8, 0, - 0, 0,10,11, 0, 0, 0,10,11, 0, 0, 0,11,11, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8, 9, 9, 0, 0, 0,11,12, 0, 0, 0,11,12, 0, 0, 0, - 12,11, 0, 0, 0, 0, 0, 0, 0, 8,10, 9, 0, 0, 0,12, - 11, 0, 0, 0,12,11, 0, 0, 0,11,12, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c2_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c2_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c2_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c2_s_p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c2_s_p3_0[] = { - 2, 4, 3, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 6, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c2_s_p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44c2_s_p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c2_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c2_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c2_s_p4_0[] = { - 1, 3, 3, 6, 6, 0, 0, 0, 0, 0, 6, 6, 6, 6, 0, 0, - 0, 0, 0, 6, 6, 6, 6, 0, 0, 0, 0, 0, 7, 7, 6, 6, - 0, 0, 0, 0, 0, 0, 0, 6, 7, 0, 0, 0, 0, 0, 0, 0, - 7, 8, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c2_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44c2_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c2_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c2_s_p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c2_s_p5_0[] = { - 1, 3, 3, 6, 6, 7, 7, 9, 9, 0, 7, 7, 7, 7, 7, 7, - 9, 9, 0, 7, 7, 7, 7, 7, 7, 9, 9, 0, 8, 8, 7, 7, - 8, 8,10,10, 0, 0, 0, 7, 7, 8, 8,10,10, 0, 0, 0, - 9, 9, 8, 8,10,10, 0, 0, 0, 9, 9, 8, 8,10,10, 0, - 0, 0,10,10, 9, 9,11,11, 0, 0, 0, 0, 0, 9, 9,11, - 11, -}; - -static const static_codebook _44c2_s_p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44c2_s_p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c2_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c2_s_p6_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c2_s_p6_0[] = { - 1, 4, 3, 6, 6, 8, 8, 9, 9, 9, 9, 9, 9,10,10,11, - 11, 0, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9,10,10,11,11, - 12,11, 0, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9,10,10,11, - 11,11,12, 0, 8, 8, 7, 7, 9, 9,10,10, 9, 9,10,10, - 11,11,12,12, 0, 0, 0, 7, 7, 9, 9,10,10,10, 9,10, - 10,11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10,10, - 11,11,11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10, - 10,11,11,12,12,12,12, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9, - 10,10,11,11,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, - 9,10,10,11,11,11,11,12,12,13,13, 0, 0, 0, 0, 0, - 10,10,10,10,11,11,12,12,13,12,13,13, 0, 0, 0, 0, - 0, 0, 0,10,10,11,11,12,12,13,13,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,12,12,12,12,13,13,13,14, 0, 0, - 0, 0, 0, 0, 0,11,11,12,12,12,12,13,13,13,14, 0, - 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,13,13,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,13,13,13,13,14, - 14, -}; - -static const static_codebook _44c2_s_p6_0 = { - 2, 289, - (char *)_vq_lengthlist__44c2_s_p6_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c2_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c2_s_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c2_s_p7_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7,10, 9, 9,11, - 9, 9, 4, 7, 7,10, 9, 9,10, 9, 9, 7,10,10,11,10, - 11,11,10,11, 6, 9, 9,11,10,10,11,10,10, 6, 9, 9, - 11,10,11,11,10,10, 7,11,10,11,11,11,12,11,11, 6, - 9, 9,11,10,10,11,11,10, 6, 9, 9,11,10,10,12,10, - 11, -}; - -static const static_codebook _44c2_s_p7_0 = { - 4, 81, - (char *)_vq_lengthlist__44c2_s_p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c2_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c2_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c2_s_p7_1[] = { - 2, 3, 4, 6, 6, 7, 7, 7, 7, 7, 7, 9, 7, 7, 6, 6, - 7, 7, 8, 8, 8, 8, 9, 6, 6, 6, 6, 7, 7, 8, 8, 8, - 8,10, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, - 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, - 8, 8,10,10,10, 7, 8, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 8, 8,10,10,10,10,10, 8, 8, 8, - 8, 8, 8,10,10,10,10,10, 9, 9, 8, 8, 8, 8,10,10, - 10,10,10, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44c2_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44c2_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c2_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c2_s_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c2_s_p8_0[] = { - 1, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 6, 5, 5, - 7, 7, 8, 8, 8, 8, 9, 9,10,10, 7, 6, 5, 7, 7, 8, - 8, 8, 8, 9, 9,10,10, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9,10,10,10,10,11,11,11,11, 0,13, - 13, 9, 9,10,10,10,10,11,11,12,12, 0, 0, 0,10,10, - 10,10,11,11,12,12,12,13, 0, 0, 0,10,10,10,10,11, - 11,12,12,12,12, 0, 0, 0,14,14,10,11,11,11,12,12, - 13,13, 0, 0, 0,14,14,11,10,11,11,13,12,13,13, 0, - 0, 0, 0, 0,12,12,11,12,13,12,14,14, 0, 0, 0, 0, - 0,12,12,12,12,13,12,14,14, -}; - -static const static_codebook _44c2_s_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__44c2_s_p8_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c2_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c2_s_p8_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c2_s_p8_1[] = { - 2, 4, 4, 5, 4, 6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 6, - 5, 5, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c2_s_p8_1 = { - 2, 25, - (char *)_vq_lengthlist__44c2_s_p8_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c2_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c2_s_p9_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c2_s_p9_0[] = { - 1, 5, 4,12,12,12,12,12,12,12,12,12,12, 4, 9, 8, - 11,11,11,11,11,11,11,11,11,11, 2, 8, 7,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,10,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11, -}; - -static const static_codebook _44c2_s_p9_0 = { - 2, 169, - (char *)_vq_lengthlist__44c2_s_p9_0, - 1, -514541568, 1627103232, 4, 0, - (long *)_vq_quantlist__44c2_s_p9_0, - 0 -}; - -static const long _vq_quantlist__44c2_s_p9_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c2_s_p9_1[] = { - 1, 4, 4, 6, 6, 7, 6, 8, 8,10, 9,10,10, 6, 5, 5, - 7, 7, 8, 7,10, 9,11,11,12,13, 6, 5, 5, 7, 7, 8, - 8,10,10,11,11,13,13,18, 8, 8, 8, 8, 9, 9,10,10, - 12,12,12,13,18, 8, 8, 8, 8, 9, 9,10,10,12,12,13, - 13,18,11,11, 8, 8,10,10,11,11,12,11,13,12,18,11, - 11, 9, 7,10,10,11,11,11,12,12,13,17,17,17,10,10, - 11,11,12,12,12,10,12,12,17,17,17,11,10,11,10,13, - 12,11,12,12,12,17,17,17,15,14,11,11,12,11,13,10, - 13,12,17,17,17,14,14,12,10,11,11,13,13,13,13,17, - 17,16,17,16,13,13,12,10,13,10,14,13,17,16,17,16, - 17,13,12,12,10,13,11,14,14, -}; - -static const static_codebook _44c2_s_p9_1 = { - 2, 169, - (char *)_vq_lengthlist__44c2_s_p9_1, - 1, -522616832, 1620115456, 4, 0, - (long *)_vq_quantlist__44c2_s_p9_1, - 0 -}; - -static const long _vq_quantlist__44c2_s_p9_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c2_s_p9_2[] = { - 2, 4, 4, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, - 8,10, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9,10, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9,10, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 8, 7, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9,10,11,11, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9,10, 9, 9, 9,10,11,10, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9,10,10,10,10,11,10, 8, 8, 9, 9, 9, 9, - 9, 9,10, 9, 9,10, 9,10,11,10,11,11,11, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9,10,10,11,11,11,11,11, 9, 9, - 9, 9, 9, 9,10, 9, 9, 9,10,10,11,11,11,11,11, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10, 9,10,11,11,11,11,11, - 9, 9, 9, 9,10,10, 9, 9, 9,10,10,10,11,11,11,11, - 11,11,11, 9, 9, 9,10, 9, 9,10,10,10,10,11,11,10, - 11,11,11,11,10, 9,10,10, 9, 9, 9, 9,10,10,11,10, - 11,11,11,11,11, 9, 9, 9, 9,10, 9,10,10,10,10,11, - 10,11,11,11,11,11,10,10, 9, 9,10, 9,10,10,10,10, - 10,10,10,11,11,11,11,11,11, 9, 9,10, 9,10, 9,10, - 10, -}; - -static const static_codebook _44c2_s_p9_2 = { - 2, 289, - (char *)_vq_lengthlist__44c2_s_p9_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c2_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__44c2_s_short[] = { - 11, 9,13,12,12,11,12,12,13,15, 8, 2,11, 4, 8, 5, - 7,10,12,15,13, 7,10, 9, 8, 8,10,13,17,17,11, 4, - 12, 5, 9, 5, 8,11,14,16,12, 6, 8, 7, 6, 6, 8,11, - 13,16,11, 4, 9, 5, 6, 4, 6,10,13,16,11, 6,11, 7, - 7, 6, 7,10,13,15,13, 9,12, 9, 8, 6, 8,10,12,14, - 14,10,10, 8, 6, 5, 6, 9,11,13,15,11,11, 9, 6, 5, - 6, 8, 9,12, -}; - -static const static_codebook _huff_book__44c2_s_short = { - 2, 100, - (char *)_huff_lengthlist__44c2_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c3_s_long[] = { - 5, 6,11,11,11,11,10,10,12,11, 5, 2,11, 5, 6, 6, - 7, 9,11,13,13,10, 7,11, 6, 7, 8, 9,10,12,11, 5, - 11, 6, 8, 7, 9,11,14,15,11, 6, 6, 8, 4, 5, 7, 8, - 10,13,10, 5, 7, 7, 5, 5, 6, 8,10,11,10, 7, 7, 8, - 6, 5, 5, 7, 9, 9,11, 8, 8,11, 8, 7, 6, 6, 7, 9, - 12,11,10,13, 9, 9, 7, 7, 7, 9,11,13,12,15,12,11, - 9, 8, 8, 8, -}; - -static const static_codebook _huff_book__44c3_s_long = { - 2, 100, - (char *)_huff_lengthlist__44c3_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c3_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c3_s_p1_0[] = { - 2, 4, 4, 0, 0, 0, 0, 0, 0, 5, 6, 6, 0, 0, 0, 0, - 0, 0, 5, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, - 0, 0, 0, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 6, 8, 7, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, - 0, 0, 0, 8, 8, 9, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 8, 8, 0, 0, - 0, 0, 0, 0, 7, 9, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, - 0, 0, 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, - 0, 0, 0, 0, 0, 0, 8, 9, 8, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c3_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44c3_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c3_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c3_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c3_s_p2_0[] = { - 2, 5, 5, 0, 0, 0, 5, 5, 0, 0, 0, 5, 5, 0, 0, 0, - 7, 8, 0, 0, 0, 0, 0, 0, 0, 5, 6, 6, 0, 0, 0, 7, - 7, 0, 0, 0, 7, 7, 0, 0, 0,10,10, 0, 0, 0, 0, 0, - 0, 0, 5, 6, 6, 0, 0, 0, 7, 7, 0, 0, 0, 7, 7, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 7, 7, 0, 0, - 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 5, - 7, 7, 0, 0, 0, 7, 7, 0, 0, 0, 7, 7, 0, 0, 0, 9, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 7, 7, 0, 0, 0, 7, 7, 0, 0, 0, 7, 7, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, - 0, 0, 7, 7, 0, 0, 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8,10,10, 0, 0, 0, 9, 9, 0, 0, 0, 9, 9, 0, 0, 0, - 10,10, 0, 0, 0, 0, 0, 0, 0, 8,10,10, 0, 0, 0, 9, - 9, 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c3_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c3_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c3_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c3_s_p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c3_s_p3_0[] = { - 2, 4, 3, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 6, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c3_s_p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44c3_s_p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c3_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c3_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c3_s_p4_0[] = { - 2, 3, 3, 6, 6, 0, 0, 0, 0, 0, 4, 4, 6, 6, 0, 0, - 0, 0, 0, 4, 4, 6, 6, 0, 0, 0, 0, 0, 5, 5, 6, 6, - 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, - 7, 8, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c3_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44c3_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c3_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c3_s_p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c3_s_p5_0[] = { - 1, 3, 4, 6, 6, 7, 7, 9, 9, 0, 5, 5, 7, 7, 7, 8, - 9, 9, 0, 5, 5, 7, 7, 8, 8, 9, 9, 0, 7, 7, 8, 8, - 8, 8,10,10, 0, 0, 0, 8, 8, 8, 8,10,10, 0, 0, 0, - 9, 9, 9, 9,10,10, 0, 0, 0, 9, 9, 9, 9,10,10, 0, - 0, 0,10,10,10,10,11,11, 0, 0, 0, 0, 0,10,10,11, - 11, -}; - -static const static_codebook _44c3_s_p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44c3_s_p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c3_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c3_s_p6_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c3_s_p6_0[] = { - 2, 3, 3, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10,10,11, - 10, 0, 5, 5, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10,10, - 11,11, 0, 5, 5, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10, - 10,11,11, 0, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,11,12, 0, 0, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11,12,12, 0, 0, 0, 8, 8, 8, 8, 9, 9, 9, - 9,10,10,11,11,12,12, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,10,11,11,12,12, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,11,11,12,12, 0, 0, 0, 0, 0, 9, 8, - 9, 9,10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 8, - 8, 9, 9,10,10,11,11,12,11,12,12, 0, 0, 0, 0, 0, - 9,10,10,10,11,11,11,11,12,12,13,13, 0, 0, 0, 0, - 0, 0, 0,10,10,10,10,11,11,12,12,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,11,11,12,12,12,12,13,13, 0, 0, - 0, 0, 0, 0, 0,11,11,11,11,12,12,12,12,13,13, 0, - 0, 0, 0, 0, 0, 0,11,11,12,12,12,12,13,13,13,13, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,13, - 13, -}; - -static const static_codebook _44c3_s_p6_0 = { - 2, 289, - (char *)_vq_lengthlist__44c3_s_p6_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c3_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c3_s_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c3_s_p7_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7,10, 9, 9,11, - 9, 9, 4, 7, 7,10, 9, 9,11, 9, 9, 7,10,10,11,11, - 10,12,11,11, 6, 9, 9,11,10,10,11,10,10, 6, 9, 9, - 11,10,10,11,10,10, 7,11,11,11,11,11,12,11,11, 6, - 9, 9,11,10,10,11,10,10, 6, 9, 9,11,10,10,11,10, - 10, -}; - -static const static_codebook _44c3_s_p7_0 = { - 4, 81, - (char *)_vq_lengthlist__44c3_s_p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c3_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c3_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c3_s_p7_1[] = { - 2, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8,10, 5, 5, 6, 6, - 7, 7, 8, 8, 8, 8,10, 5, 5, 6, 6, 7, 7, 8, 8, 8, - 8,10, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, 7, - 7, 8, 7, 8, 8, 8, 8,10,10,10, 8, 8, 8, 8, 8, 8, - 8, 8,10,10,10, 7, 8, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 8, 8,10,10,10,10,10, 8, 8, 8, - 8, 8, 8,10,10,10,10,10, 9, 9, 8, 8, 9, 8,10,10, - 10,10,10, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44c3_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44c3_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c3_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c3_s_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c3_s_p8_0[] = { - 1, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10, 6, 5, 5, - 7, 7, 8, 8, 8, 8, 9, 9,10,10, 7, 5, 5, 7, 7, 8, - 8, 8, 8, 9, 9,11,10, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9,10,10,10,10,11,11,11,12, 0,13, - 13, 9, 9,10,10,10,10,11,11,12,12, 0, 0, 0,10,10, - 10,10,11,11,12,12,12,12, 0, 0, 0,10,10,10,10,11, - 11,12,12,12,12, 0, 0, 0,14,14,11,11,11,11,12,12, - 13,13, 0, 0, 0,14,14,11,11,11,11,12,12,13,13, 0, - 0, 0, 0, 0,12,12,12,12,13,13,14,13, 0, 0, 0, 0, - 0,13,13,12,12,13,12,14,13, -}; - -static const static_codebook _44c3_s_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__44c3_s_p8_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c3_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c3_s_p8_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c3_s_p8_1[] = { - 2, 4, 4, 5, 5, 6, 5, 5, 5, 5, 6, 4, 5, 5, 5, 6, - 5, 5, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c3_s_p8_1 = { - 2, 25, - (char *)_vq_lengthlist__44c3_s_p8_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c3_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c3_s_p9_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c3_s_p9_0[] = { - 1, 4, 4,12,12,12,12,12,12,12,12,12,12, 4, 9, 8, - 12,12,12,12,12,12,12,12,12,12, 2, 9, 7,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,11,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11, -}; - -static const static_codebook _44c3_s_p9_0 = { - 2, 169, - (char *)_vq_lengthlist__44c3_s_p9_0, - 1, -514332672, 1627381760, 4, 0, - (long *)_vq_quantlist__44c3_s_p9_0, - 0 -}; - -static const long _vq_quantlist__44c3_s_p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44c3_s_p9_1[] = { - 1, 4, 4, 6, 6, 7, 7, 8, 7, 9, 9,10,10,10,10, 6, - 5, 5, 7, 7, 8, 8,10, 8,11,10,12,12,13,13, 6, 5, - 5, 7, 7, 8, 8,10, 9,11,11,12,12,13,12,18, 8, 8, - 8, 8, 9, 9,10, 9,11,10,12,12,13,13,18, 8, 8, 8, - 8, 9, 9,10,10,11,11,13,12,14,13,18,11,11, 9, 9, - 10,10,11,11,11,12,13,12,13,14,18,11,11, 9, 8,11, - 10,11,11,11,11,12,12,14,13,18,18,18,10,11,10,11, - 12,12,12,12,13,12,14,13,18,18,18,10,11,11, 9,12, - 11,12,12,12,13,13,13,18,18,17,14,14,11,11,12,12, - 13,12,14,12,14,13,18,18,18,14,14,11,10,12, 9,12, - 13,13,13,13,13,18,18,17,16,18,13,13,12,12,13,11, - 14,12,14,14,17,18,18,17,18,13,12,13,10,12,11,14, - 14,14,14,17,18,18,18,18,15,16,12,12,13,10,14,12, - 14,15,18,18,18,16,17,16,14,12,11,13,10,13,13,14, - 15, -}; - -static const static_codebook _44c3_s_p9_1 = { - 2, 225, - (char *)_vq_lengthlist__44c3_s_p9_1, - 1, -522338304, 1620115456, 4, 0, - (long *)_vq_quantlist__44c3_s_p9_1, - 0 -}; - -static const long _vq_quantlist__44c3_s_p9_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c3_s_p9_2[] = { - 2, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, - 8,10, 6, 6, 7, 7, 8, 7, 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9,10, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9,10, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 7, 7, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9,11,11,11, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9,10,10,10, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9,10, 9,10,10,10,11,11, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,11,10,11,11,11, 9, 9, - 9, 9, 9, 9,10,10, 9, 9,10, 9,11,10,11,11,11, 9, - 9, 9, 9, 9, 9, 9, 9,10,10,10, 9,11,11,11,11,11, - 9, 9, 9, 9,10,10, 9, 9, 9, 9,10, 9,11,11,11,11, - 11,11,11, 9, 9, 9, 9, 9, 9,10,10,10,10,11,11,11, - 11,11,11,11,10, 9,10,10, 9,10, 9, 9,10, 9,11,10, - 10,11,11,11,11, 9,10, 9, 9, 9, 9,10,10,10,10,11, - 11,11,11,11,11,10,10,10, 9, 9,10, 9,10, 9,10,10, - 10,10,11,11,11,11,11,11,11, 9, 9, 9, 9, 9,10,10, - 10, -}; - -static const static_codebook _44c3_s_p9_2 = { - 2, 289, - (char *)_vq_lengthlist__44c3_s_p9_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c3_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__44c3_s_short[] = { - 10, 9,13,11,14,10,12,13,13,14, 7, 2,12, 5,10, 5, - 7,10,12,14,12, 6, 9, 8, 7, 7, 9,11,13,16,10, 4, - 12, 5,10, 6, 8,12,14,16,12, 6, 8, 7, 6, 5, 7,11, - 12,16,10, 4, 8, 5, 6, 4, 6, 9,13,16,10, 6,10, 7, - 7, 6, 7, 9,13,15,12, 9,11, 9, 8, 6, 7,10,12,14, - 14,11,10, 9, 6, 5, 6, 9,11,13,15,13,11,10, 6, 5, - 6, 8, 9,11, -}; - -static const static_codebook _huff_book__44c3_s_short = { - 2, 100, - (char *)_huff_lengthlist__44c3_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c4_s_long[] = { - 4, 7,11,11,11,11,10,11,12,11, 5, 2,11, 5, 6, 6, - 7, 9,11,12,11, 9, 6,10, 6, 7, 8, 9,10,11,11, 5, - 11, 7, 8, 8, 9,11,13,14,11, 6, 5, 8, 4, 5, 7, 8, - 10,11,10, 6, 7, 7, 5, 5, 6, 8, 9,11,10, 7, 8, 9, - 6, 6, 6, 7, 8, 9,11, 9, 9,11, 7, 7, 6, 6, 7, 9, - 12,12,10,13, 9, 8, 7, 7, 7, 8,11,13,11,14,11,10, - 9, 8, 7, 7, -}; - -static const static_codebook _huff_book__44c4_s_long = { - 2, 100, - (char *)_huff_lengthlist__44c4_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c4_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c4_s_p1_0[] = { - 2, 4, 4, 0, 0, 0, 0, 0, 0, 5, 6, 6, 0, 0, 0, 0, - 0, 0, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, - 0, 0, 0, 6, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 6, 8, 7, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, - 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 8, 8, 0, 0, - 0, 0, 0, 0, 8, 9, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7, 7, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, - 0, 0, 0, 0, 0, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, - 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c4_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44c4_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c4_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c4_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c4_s_p2_0[] = { - 2, 5, 5, 0, 0, 0, 5, 5, 0, 0, 0, 5, 5, 0, 0, 0, - 7, 7, 0, 0, 0, 0, 0, 0, 0, 5, 6, 6, 0, 0, 0, 7, - 7, 0, 0, 0, 7, 7, 0, 0, 0,10,10, 0, 0, 0, 0, 0, - 0, 0, 5, 6, 6, 0, 0, 0, 7, 7, 0, 0, 0, 7, 7, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5, 8, 7, 0, 0, 0, 7, 7, 0, 0, - 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 5, - 7, 8, 0, 0, 0, 7, 7, 0, 0, 0, 7, 7, 0, 0, 0, 9, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 7, 7, 0, 0, 0, 7, 7, 0, 0, 0, 7, 7, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, - 0, 0, 7, 7, 0, 0, 0, 7, 7, 0, 0, 0, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7,10,10, 0, 0, 0, 9, 9, 0, 0, 0, 9, 9, 0, 0, 0, - 10,10, 0, 0, 0, 0, 0, 0, 0, 8,10,10, 0, 0, 0, 9, - 9, 0, 0, 0, 9, 9, 0, 0, 0,10,10, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c4_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c4_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c4_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c4_s_p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c4_s_p3_0[] = { - 2, 3, 3, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 4, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 4, 5, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 6, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c4_s_p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44c4_s_p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c4_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c4_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c4_s_p4_0[] = { - 2, 3, 3, 6, 6, 0, 0, 0, 0, 0, 4, 4, 6, 6, 0, 0, - 0, 0, 0, 4, 4, 6, 6, 0, 0, 0, 0, 0, 5, 5, 6, 6, - 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, - 7, 8, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c4_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44c4_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c4_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c4_s_p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c4_s_p5_0[] = { - 2, 3, 3, 6, 6, 7, 7, 9, 9, 0, 4, 4, 6, 6, 7, 7, - 9, 9, 0, 4, 5, 6, 6, 7, 7, 9, 9, 0, 6, 6, 7, 7, - 8, 8,10,10, 0, 0, 0, 7, 7, 8, 8,10, 9, 0, 0, 0, - 9, 8, 8, 8,10,10, 0, 0, 0, 8, 8, 8, 8,10,10, 0, - 0, 0,10,10, 9, 9,11,11, 0, 0, 0, 0, 0, 9, 9,10, - 10, -}; - -static const static_codebook _44c4_s_p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44c4_s_p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c4_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c4_s_p6_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c4_s_p6_0[] = { - 2, 4, 4, 6, 6, 8, 8, 9, 9, 8, 8, 9, 9,10,10,11, - 11, 0, 4, 4, 6, 6, 8, 8, 9, 9, 9, 9,10,10,11,11, - 11,11, 0, 4, 4, 7, 6, 8, 8, 9, 9, 9, 9,10,10,11, - 11,11,11, 0, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,11,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,12,12, 0, 0, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11,12,12, 0, 0, 0, 8, 8, 8, 8, 9, 9, 9, - 9,10,10,11,11,12,12, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,11,11,11,12,12, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,11,11,12,12, 0, 0, 0, 0, 0, 9, 9, - 9,10,10,10,11,11,11,11,12,12, 0, 0, 0, 0, 0, 9, - 9, 9, 9,10,10,11,11,11,12,12,12, 0, 0, 0, 0, 0, - 10,10,10,10,11,11,11,11,12,12,13,12, 0, 0, 0, 0, - 0, 0, 0,10,10,11,11,11,11,12,12,12,12, 0, 0, 0, - 0, 0, 0, 0,11,11,11,11,12,12,12,12,13,13, 0, 0, - 0, 0, 0, 0, 0,11,11,11,11,12,12,12,12,13,13, 0, - 0, 0, 0, 0, 0, 0,12,12,12,12,12,12,13,13,13,13, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,12,12,12,13,13, - 13, -}; - -static const static_codebook _44c4_s_p6_0 = { - 2, 289, - (char *)_vq_lengthlist__44c4_s_p6_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c4_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c4_s_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c4_s_p7_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7,10, 9, 9,11, - 9, 9, 4, 7, 7,10, 9, 9,11, 9, 9, 7,10,10,11,11, - 10,11,11,11, 6, 9, 9,11,10,10,11,10,10, 6, 9, 9, - 11,10,10,11,10,10, 7,11,11,12,11,11,12,11,11, 6, - 9, 9,11,10,10,11,10,10, 6, 9, 9,11,10,10,11,10, - 10, -}; - -static const static_codebook _44c4_s_p7_0 = { - 4, 81, - (char *)_vq_lengthlist__44c4_s_p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c4_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c4_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c4_s_p7_1[] = { - 2, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8,10, 5, 5, 6, 6, - 7, 7, 8, 8, 8, 8,10, 5, 5, 6, 6, 7, 7, 8, 8, 8, - 8,10, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, 7, - 7, 8, 8, 8, 8, 8, 8,10,10,10, 8, 7, 8, 8, 8, 8, - 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 8, 8,10,10,10,10,10, 8, 8, 8, - 8, 8, 8,10,10,10,10,10, 9, 9, 8, 8, 9, 8,10,10, - 10,10,10, 8, 8, 8, 8, 9, 9, -}; - -static const static_codebook _44c4_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44c4_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c4_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c4_s_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c4_s_p8_0[] = { - 1, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10, 6, 5, 5, - 7, 7, 8, 8, 8, 8, 9,10,11,11, 7, 5, 5, 7, 7, 8, - 8, 9, 9,10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9, 9, 9,10,10,10,10,11,11, 0,13, - 13, 9, 9,10, 9,10,10,11,11,11,12, 0, 0, 0,10,10, - 10,10,10,10,11,11,12,12, 0, 0, 0,10,10,10,10,10, - 10,11,11,12,12, 0, 0, 0,14,14,11,11,11,11,12,12, - 12,12, 0, 0, 0,14,14,11,11,11,11,12,12,12,13, 0, - 0, 0, 0, 0,12,12,12,12,12,12,13,13, 0, 0, 0, 0, - 0,13,12,12,12,12,12,13,13, -}; - -static const static_codebook _44c4_s_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__44c4_s_p8_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c4_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c4_s_p8_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c4_s_p8_1[] = { - 2, 4, 4, 5, 5, 6, 5, 5, 5, 5, 6, 5, 4, 5, 5, 6, - 5, 5, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c4_s_p8_1 = { - 2, 25, - (char *)_vq_lengthlist__44c4_s_p8_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c4_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c4_s_p9_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c4_s_p9_0[] = { - 1, 3, 3,12,12,12,12,12,12,12,12,12,12, 4, 7, 7, - 12,12,12,12,12,12,12,12,12,12, 3, 8, 8,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12, -}; - -static const static_codebook _44c4_s_p9_0 = { - 2, 169, - (char *)_vq_lengthlist__44c4_s_p9_0, - 1, -513964032, 1628680192, 4, 0, - (long *)_vq_quantlist__44c4_s_p9_0, - 0 -}; - -static const long _vq_quantlist__44c4_s_p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44c4_s_p9_1[] = { - 1, 4, 4, 5, 5, 7, 7, 9, 8,10, 9,10,10,10,10, 6, - 5, 5, 7, 7, 9, 8,10, 9,11,10,12,12,13,13, 6, 5, - 5, 7, 7, 9, 9,10,10,11,11,12,12,12,13,19, 8, 8, - 8, 8, 9, 9,10,10,12,11,12,12,13,13,19, 8, 8, 8, - 8, 9, 9,11,11,12,12,13,13,13,13,19,12,12, 9, 9, - 11,11,11,11,12,11,13,12,13,13,18,12,12, 9, 9,11, - 10,11,11,12,12,12,13,13,14,19,18,18,11,11,11,11, - 12,12,13,12,13,13,14,14,16,18,18,11,11,11,10,12, - 11,13,13,13,13,13,14,17,18,18,14,15,11,12,12,13, - 13,13,13,14,14,14,18,18,18,15,15,12,10,13,10,13, - 13,13,13,13,14,18,17,18,17,18,12,13,12,13,13,13, - 14,14,16,14,18,17,18,18,17,13,12,13,10,12,12,14, - 14,14,14,17,18,18,18,18,14,15,12,12,13,12,14,14, - 15,15,18,18,18,17,18,15,14,12,11,12,12,14,14,14, - 15, -}; - -static const static_codebook _44c4_s_p9_1 = { - 2, 225, - (char *)_vq_lengthlist__44c4_s_p9_1, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__44c4_s_p9_1, - 0 -}; - -static const long _vq_quantlist__44c4_s_p9_2[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__44c4_s_p9_2[] = { - 2, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, - 8, 9, 9, 9, 9,11, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10,10,11, 6, 6, 7, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 9, 9,10, 9,10,10,10,10,11, - 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9,10,10,10, - 10,10,10,10,12,11,11, 7, 7, 8, 8, 9, 9, 9, 9, 9, - 9,10,10,10,10,10,10,10,10,12,11,12, 8, 8, 8, 8, - 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,11,11, - 11, 8, 8, 8, 8, 9, 9, 9, 9,10,10,10,10,10,10,10, - 10,10,10,11,11,12, 9, 9, 9, 9, 9, 9,10, 9,10,10, - 10,10,10,10,10,10,10,10,11,11,11,11,11, 9, 9, 9, - 9,10,10,10,10,10,10,10,10,10,10,10,10,11,12,11, - 11,11, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10, - 10,10,11,11,11,11,11, 9, 9, 9, 9,10,10,10,10,10, - 10,10,10,10,10,10,10,11,11,11,12,12,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,11,12,11,12, - 11,11,11, 9,10,10,10,10,10,10,10,10,10,10,10,10, - 10,11,12,11,11,11,11,11,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,11,11,11,12,11,11,11,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,12,11,11,12,11, - 11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10, - 10,10,10,10,10,11,11,11,11,12,12,11,11,11,11,11, - 11,11,10,10,10,10,10,10,10,10,12,12,12,11,11,11, - 12,11,11,11,10,10,10,10,10,10,10,10,10,10,10,12, - 11,12,12,12,12,12,11,12,11,11,10,10,10,10,10,10, - 10,10,10,10,12,12,12,12,11,11,11,11,11,11,11,10, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _44c4_s_p9_2 = { - 2, 441, - (char *)_vq_lengthlist__44c4_s_p9_2, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__44c4_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__44c4_s_short[] = { - 4, 7,14,10,15,10,12,15,16,15, 4, 2,11, 5,10, 6, - 8,11,14,14,14,10, 7,11, 6, 8,10,11,13,15, 9, 4, - 11, 5, 9, 6, 9,12,14,15,14, 9, 6, 9, 4, 5, 7,10, - 12,13, 9, 5, 7, 6, 5, 5, 7,10,13,13,10, 8, 9, 8, - 7, 6, 8,10,14,14,13,11,10,10, 7, 7, 8,11,14,15, - 13,12, 9, 9, 6, 5, 7,10,14,17,15,13,11,10, 6, 6, - 7, 9,12,17, -}; - -static const static_codebook _huff_book__44c4_s_short = { - 2, 100, - (char *)_huff_lengthlist__44c4_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c5_s_long[] = { - 3, 8, 9,13,10,12,12,12,12,12, 6, 4, 6, 8, 6, 8, - 10,10,11,12, 8, 5, 4,10, 4, 7, 8, 9,10,11,13, 8, - 10, 8, 9, 9,11,12,13,14,10, 6, 4, 9, 3, 5, 6, 8, - 10,11,11, 8, 6, 9, 5, 5, 6, 7, 9,11,12, 9, 7,11, - 6, 6, 6, 7, 8,10,12,11, 9,12, 7, 7, 6, 6, 7, 9, - 13,12,10,13, 9, 8, 7, 7, 7, 8,11,15,11,15,11,10, - 9, 8, 7, 7, -}; - -static const static_codebook _huff_book__44c5_s_long = { - 2, 100, - (char *)_huff_lengthlist__44c5_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c5_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c5_s_p1_0[] = { - 2, 4, 4, 0, 0, 0, 0, 0, 0, 4, 7, 7, 0, 0, 0, 0, - 0, 0, 4, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7, 7, 0, 0, 0, 0, 0, 0, 7, 9, 8, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 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, 7, 7, 0, 0, 0, 0, - 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 9,10,11, 0, 0, 0, 0, 0, 0, 9,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 8,10, 9, 0, 0, 0, 0, 0, 0, 9,10,11, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7, 7, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,11,10, 0, - 0, 0, 0, 0, 0, 8, 9,10, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,10,10, - 0, 0, 0, 0, 0, 0, 9,11,10, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c5_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44c5_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c5_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c5_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c5_s_p2_0[] = { - 2, 4, 4, 0, 0, 0, 5, 5, 0, 0, 0, 5, 5, 0, 0, 0, - 8, 7, 0, 0, 0, 0, 0, 0, 0, 4, 6, 6, 0, 0, 0, 8, - 8, 0, 0, 0, 8, 7, 0, 0, 0,10,10, 0, 0, 0, 0, 0, - 0, 0, 4, 6, 6, 0, 0, 0, 8, 8, 0, 0, 0, 7, 8, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5, 8, 7, 0, 0, 0, 8, 8, 0, 0, - 0, 8, 8, 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 5, - 7, 8, 0, 0, 0, 8, 8, 0, 0, 0, 8, 8, 0, 0, 0,10, - 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 8, 8, 0, 0, 0, 8, 8, 0, 0, 0, 8, 8, - 0, 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 5, 8, 8, 0, - 0, 0, 8, 8, 0, 0, 0, 8, 8, 0, 0, 0,10,10, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8,10,10, 0, 0, 0,10,10, 0, 0, 0, 9,10, 0, 0, 0, - 11,10, 0, 0, 0, 0, 0, 0, 0, 8,10,10, 0, 0, 0,10, - 10, 0, 0, 0,10,10, 0, 0, 0,10,11, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c5_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c5_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c5_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c5_s_p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c5_s_p3_0[] = { - 2, 4, 3, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 5, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 5, 5, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 8, 8, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 6, 6, 8, 8, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c5_s_p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44c5_s_p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c5_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c5_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c5_s_p4_0[] = { - 2, 3, 3, 6, 6, 0, 0, 0, 0, 0, 4, 4, 6, 6, 0, 0, - 0, 0, 0, 4, 4, 6, 6, 0, 0, 0, 0, 0, 5, 5, 6, 6, - 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, - 7, 7, 0, 0, 0, 0, 0, 0, 0, 8, 7, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c5_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44c5_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c5_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c5_s_p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c5_s_p5_0[] = { - 2, 4, 3, 6, 6, 7, 7, 9, 9, 0, 4, 4, 6, 6, 7, 7, - 9, 9, 0, 4, 4, 6, 6, 7, 7, 9, 9, 0, 6, 6, 7, 7, - 7, 7, 9, 9, 0, 0, 0, 7, 6, 7, 7, 9, 9, 0, 0, 0, - 8, 8, 8, 8,10,10, 0, 0, 0, 8, 8, 8, 8,10,10, 0, - 0, 0, 9, 9, 9, 9,10,10, 0, 0, 0, 0, 0, 9, 9,10, - 10, -}; - -static const static_codebook _44c5_s_p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44c5_s_p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c5_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c5_s_p6_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c5_s_p6_0[] = { - 2, 4, 4, 6, 6, 8, 8, 9, 9, 9, 9,10,10,10,10,11, - 11, 0, 4, 4, 6, 6, 8, 8, 9, 9, 9, 9,10,10,11,11, - 12,12, 0, 4, 4, 6, 6, 8, 8, 9, 9, 9, 9,10,10,11, - 11,12,12, 0, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,12,12, 0, 0, 0, 7, 7, 9, 9,10,10,10,10, - 11,11,11,11,12,12, 0, 0, 0, 7, 7, 8, 9,10,10,10, - 10,11,11,11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10,10, - 10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 9, 9, - 10,10,10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 9, - 9, 9,10,10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, - 10,10,10,10,11,11,11,12,12,12,13,13, 0, 0, 0, 0, - 0, 0, 0,10,10,11,11,11,11,12,12,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,11,11,12,12,12,13,13,13, 0, 0, - 0, 0, 0, 0, 0,11,11,11,11,12,12,12,12,13,13, 0, - 0, 0, 0, 0, 0, 0,12,12,12,12,13,12,13,13,13,13, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,13, - 13, -}; - -static const static_codebook _44c5_s_p6_0 = { - 2, 289, - (char *)_vq_lengthlist__44c5_s_p6_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c5_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c5_s_p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c5_s_p7_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7,10, 9, 9,11, - 9, 9, 4, 7, 7,10, 9, 9,11, 9, 9, 7,10,10,11,11, - 10,11,11,11, 6, 9, 9,11,10,10,11,10,10, 6, 9, 9, - 11,10,10,11,10,10, 7,11,11,12,11,11,12,11,11, 6, - 9, 9,11,10,10,11,10,10, 6, 9, 9,11,10,10,11,10, - 10, -}; - -static const static_codebook _44c5_s_p7_0 = { - 4, 81, - (char *)_vq_lengthlist__44c5_s_p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c5_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c5_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c5_s_p7_1[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8,10, 5, 5, 6, 6, - 7, 7, 8, 8, 8, 8,10, 5, 5, 6, 6, 7, 7, 8, 8, 8, - 8,10, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, 7, - 7, 8, 8, 8, 8, 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, - 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 8, 9,10,10,10,10,10, 8, 8, 8, - 8, 8, 8,10,10,10,10,10, 9, 9, 8, 8, 8, 8,10,10, - 10,10,10, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44c5_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44c5_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c5_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c5_s_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c5_s_p8_0[] = { - 1, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10, 6, 5, 5, - 7, 7, 8, 8, 8, 9,10,10,10,10, 7, 5, 5, 7, 7, 8, - 8, 9, 9,10,10,10,10, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9, 9,10,10,10,10,10,11,11, 0,13, - 13, 9, 9, 9, 9,10,10,11,11,11,11, 0, 0, 0,10,10, - 10,10,10,10,11,11,11,11, 0, 0, 0,10,10,10,10,10, - 10,11,11,12,12, 0, 0, 0,14,14,11,11,11,11,12,12, - 12,12, 0, 0, 0,14,14,11,11,11,11,12,12,12,12, 0, - 0, 0, 0, 0,12,12,12,12,12,12,13,13, 0, 0, 0, 0, - 0,12,12,12,12,12,12,13,13, -}; - -static const static_codebook _44c5_s_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__44c5_s_p8_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c5_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c5_s_p8_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c5_s_p8_1[] = { - 2, 4, 4, 5, 5, 6, 5, 5, 5, 5, 6, 4, 5, 5, 5, 6, - 5, 5, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c5_s_p8_1 = { - 2, 25, - (char *)_vq_lengthlist__44c5_s_p8_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c5_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c5_s_p9_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44c5_s_p9_0[] = { - 1, 3, 3,13,13,13,13,13,13,13,13,13,13,13,13, 4, - 7, 7,13,13,13,13,13,13,13,13,13,13,13,13, 3, 8, - 6,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12, - 12, -}; - -static const static_codebook _44c5_s_p9_0 = { - 2, 225, - (char *)_vq_lengthlist__44c5_s_p9_0, - 1, -512522752, 1628852224, 4, 0, - (long *)_vq_quantlist__44c5_s_p9_0, - 0 -}; - -static const long _vq_quantlist__44c5_s_p9_1[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c5_s_p9_1[] = { - 1, 4, 4, 5, 5, 7, 7, 9, 8,10, 9,10,10,11,10,11, - 11, 6, 5, 5, 7, 7, 8, 9,10,10,11,10,12,11,12,11, - 13,12, 6, 5, 5, 7, 7, 9, 9,10,10,11,11,12,12,13, - 12,13,13,18, 8, 8, 8, 8, 9, 9,10,11,11,11,12,11, - 13,11,13,12,18, 8, 8, 8, 8,10,10,11,11,12,12,13, - 13,13,13,13,14,18,12,12, 9, 9,11,11,11,11,12,12, - 13,12,13,12,13,13,20,13,12, 9, 9,11,11,11,11,12, - 12,13,13,13,14,14,13,20,18,19,11,12,11,11,12,12, - 13,13,13,13,13,13,14,13,18,19,19,12,11,11,11,12, - 12,13,12,13,13,13,14,14,13,18,17,19,14,15,12,12, - 12,13,13,13,14,14,14,14,14,14,19,19,19,16,15,12, - 11,13,12,14,14,14,13,13,14,14,14,19,18,19,18,19, - 13,13,13,13,14,14,14,13,14,14,14,14,18,17,19,19, - 19,13,13,13,11,13,11,13,14,14,14,14,14,19,17,17, - 18,18,16,16,13,13,13,13,14,13,15,15,14,14,19,19, - 17,17,18,16,16,13,11,14,10,13,12,14,14,14,14,19, - 19,19,19,19,18,17,13,14,13,11,14,13,14,14,15,15, - 19,19,19,17,19,18,18,14,13,12,11,14,11,15,15,15, - 15, -}; - -static const static_codebook _44c5_s_p9_1 = { - 2, 289, - (char *)_vq_lengthlist__44c5_s_p9_1, - 1, -520814592, 1620377600, 5, 0, - (long *)_vq_quantlist__44c5_s_p9_1, - 0 -}; - -static const long _vq_quantlist__44c5_s_p9_2[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__44c5_s_p9_2[] = { - 3, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 9,11, 5, 6, 7, 7, 8, 7, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11, 5, 5, 7, 7, 7, - 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11, - 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, - 9,10, 9,10,11,11,11, 7, 7, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9,10,10,10,10,10,10,11,11,11, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,11,11, - 11, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9,10,10,10,10,10, - 10,10,10,11,11,11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 10,10,10,10,10,10,10,10,11,11,11,11,11, 9, 9, 9, - 9, 9, 9,10, 9,10,10,10,10,10,10,10,10,11,11,11, - 11,11, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10, - 10,10,11,11,11,11,11, 9, 9, 9, 9, 9, 9,10,10,10, - 10,10,10,10,10,10,10,11,11,11,11,11, 9, 9,10, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11, - 11,11,11, 9, 9,10,10,10,10,10,10,10,10,10,10,10, - 10,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,11,11,11,11,11,11,11,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11, - 11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10, - 10,10,10,10,10,11,11,11,11,11,11,11,11,11,10,10, - 10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11, - 11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,11, - 11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10, - 10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,10, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _44c5_s_p9_2 = { - 2, 441, - (char *)_vq_lengthlist__44c5_s_p9_2, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__44c5_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__44c5_s_short[] = { - 5, 8,10,14,11,11,12,16,15,17, 5, 5, 7, 9, 7, 8, - 10,13,17,17, 7, 5, 5,10, 5, 7, 8,11,13,15,10, 8, - 10, 8, 8, 8,11,15,18,18, 8, 5, 5, 8, 3, 4, 6,10, - 14,16, 9, 7, 6, 7, 4, 3, 5, 9,14,18,10, 9, 8,10, - 6, 5, 6, 9,14,18,12,12,11,12, 8, 7, 8,11,14,18, - 14,13,12,10, 7, 5, 6, 9,14,18,14,14,13,10, 6, 5, - 6, 8,11,16, -}; - -static const static_codebook _huff_book__44c5_s_short = { - 2, 100, - (char *)_huff_lengthlist__44c5_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c6_s_long[] = { - 3, 8,11,13,14,14,13,13,16,14, 6, 3, 4, 7, 9, 9, - 10,11,14,13,10, 4, 3, 5, 7, 7, 9,10,13,15,12, 7, - 4, 4, 6, 6, 8,10,13,15,12, 8, 6, 6, 6, 6, 8,10, - 13,14,11, 9, 7, 6, 6, 6, 7, 8,12,11,13,10, 9, 8, - 7, 6, 6, 7,11,11,13,11,10, 9, 9, 7, 7, 6,10,11, - 13,13,13,13,13,11, 9, 8,10,12,12,15,15,16,15,12, - 11,10,10,12, -}; - -static const static_codebook _huff_book__44c6_s_long = { - 2, 100, - (char *)_huff_lengthlist__44c6_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c6_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c6_s_p1_0[] = { - 1, 5, 5, 0, 5, 5, 0, 5, 5, 5, 8, 7, 0, 9, 9, 0, - 9, 8, 5, 7, 8, 0, 9, 9, 0, 8, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 9, 8, 0, 8, 8, 0, 8, 8, 5, 8, 9, - 0, 8, 8, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, - 9, 9, 0, 8, 8, 0, 8, 8, 5, 9, 9, 0, 8, 8, 0, 8, - 8, -}; -static const static_codebook _44c6_s_p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44c6_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c6_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c6_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c6_s_p2_0[] = { - 3, 5, 5, 8, 8, 0, 5, 5, 8, 8, 0, 5, 5, 8, 8, 0, - 7, 7, 9, 9, 0, 0, 0, 9, 9, 5, 7, 7, 9, 9, 0, 8, - 8,10,10, 0, 8, 7,10, 9, 0,10,10,11,11, 0, 0, 0, - 11,11, 5, 7, 7, 9, 9, 0, 8, 8,10,10, 0, 7, 8, 9, - 10, 0,10,10,11,11, 0, 0, 0,11,11, 8, 9, 9,11,11, - 0,11,11,12,12, 0,11,10,12,12, 0,13,14,14,14, 0, - 0, 0,14,13, 8, 9, 9,11,11, 0,11,11,12,12, 0,10, - 11,12,12, 0,14,13,14,14, 0, 0, 0,13,14, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5, 8, 7,11,10, 0, 7, 7,10,10, - 0, 7, 7,10,10, 0, 9, 9,11,10, 0, 0, 0,11,11, 5, - 7, 8,10,11, 0, 7, 7,10,10, 0, 7, 7,10,10, 0, 9, - 9,10,11, 0, 0, 0,11,11, 8,10, 9,12,12, 0,10,10, - 12,12, 0,10,10,12,12, 0,12,12,13,13, 0, 0, 0,13, - 13, 8, 9,10,12,12, 0,10,10,11,12, 0,10,10,12,12, - 0,12,12,13,13, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 8, 8,11,11, 0, 7, 7,10,10, 0, 7, 7, - 10,10, 0, 9, 9,10,11, 0, 0, 0,11,10, 5, 8, 8,11, - 11, 0, 7, 7,10,10, 0, 7, 7,10,10, 0, 9, 9,11,11, - 0, 0, 0,10,11, 8,10,10,12,12, 0,10,10,12,12, 0, - 10,10,12,12, 0,12,13,13,13, 0, 0, 0,14,13, 8,10, - 10,12,12, 0,10,10,12,12, 0,10,10,12,12, 0,13,12, - 13,13, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7,10,10,14,13, 0, 9, 9,13,12, 0, 9, 9,12,12, 0, - 10,10,12,12, 0, 0, 0,12,12, 7,10,10,13,14, 0, 9, - 9,12,13, 0, 9, 9,12,12, 0,10,10,12,12, 0, 0, 0, - 12,12, 9,11,11,14,13, 0,11,10,14,13, 0,11,11,13, - 13, 0,12,12,13,13, 0, 0, 0,13,13, 9,11,11,13,14, - 0,10,11,13,14, 0,11,11,13,13, 0,12,12,13,13, 0, - 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, - 11,11,14,14, 0,11,11,13,13, 0,11,10,13,13, 0,12, - 12,13,13, 0, 0, 0,13,13, 9,11,11,14,14, 0,11,11, - 13,13, 0,10,11,13,13, 0,12,12,14,13, 0, 0, 0,13, - 13, -}; - -static const static_codebook _44c6_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c6_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c6_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c6_s_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c6_s_p3_0[] = { - 2, 3, 4, 6, 6, 7, 7, 9, 9, 0, 4, 4, 6, 6, 7, 7, - 9,10, 0, 4, 4, 6, 6, 7, 7,10, 9, 0, 5, 5, 7, 7, - 8, 8,10,10, 0, 0, 0, 7, 6, 8, 8,10,10, 0, 0, 0, - 7, 7, 9, 9,11,11, 0, 0, 0, 7, 7, 9, 9,11,11, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c6_s_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44c6_s_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c6_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c6_s_p4_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c6_s_p4_0[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9,10,10, - 10, 0, 4, 4, 6, 6, 8, 8, 9, 9, 9, 9,10,10,10,10, - 11,11, 0, 4, 4, 6, 6, 8, 8, 9, 9, 9, 9,10,10,10, - 10,11,11, 0, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,11,11, 0, 0, 0, 7, 7, 9, 9,10,10,10,10, - 11,11,11,11,12,12, 0, 0, 0, 7, 7, 9, 9,10,10,10, - 10,11,11,11,11,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, - 10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 8, 8, 9, - 9,10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c6_s_p4_0 = { - 2, 289, - (char *)_vq_lengthlist__44c6_s_p4_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c6_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c6_s_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c6_s_p5_0[] = { - 1, 4, 4, 5, 7, 7, 6, 7, 7, 4, 6, 6, 9, 9,10,10, - 10, 9, 4, 6, 6, 9,10, 9,10, 9,10, 6, 9, 9,10,12, - 11,10,11,11, 7,10, 9,11,12,12,12,12,12, 7,10,10, - 11,12,12,12,12,12, 6,10,10,10,12,12,11,12,12, 7, - 9,10,11,12,12,12,12,12, 7,10, 9,12,12,12,12,12, - 12, -}; - -static const static_codebook _44c6_s_p5_0 = { - 4, 81, - (char *)_vq_lengthlist__44c6_s_p5_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c6_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c6_s_p5_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c6_s_p5_1[] = { - 3, 5, 4, 6, 6, 7, 7, 8, 8, 8, 8,11, 4, 4, 6, 6, - 7, 7, 8, 8, 8, 8,11, 4, 4, 6, 6, 7, 7, 8, 8, 8, - 8,11, 6, 6, 6, 6, 8, 8, 8, 8, 9, 9,11,11,11, 6, - 6, 7, 8, 8, 8, 8, 9,11,11,11, 7, 7, 8, 8, 8, 8, - 8, 8,11,11,11, 7, 7, 8, 8, 8, 8, 8, 8,11,11,11, - 8, 8, 8, 8, 8, 8, 8, 8,11,11,11,10,10, 8, 8, 8, - 8, 8, 8,11,11,11,10,10, 8, 8, 8, 8, 8, 8,11,11, - 11,10,10, 7, 7, 8, 8, 8, 8, -}; - -static const static_codebook _44c6_s_p5_1 = { - 2, 121, - (char *)_vq_lengthlist__44c6_s_p5_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c6_s_p5_1, - 0 -}; - -static const long _vq_quantlist__44c6_s_p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c6_s_p6_0[] = { - 1, 4, 4, 6, 6, 8, 8, 8, 8,10, 9,10,10, 6, 5, 5, - 7, 7, 9, 9, 9, 9,10,10,11,11, 6, 5, 5, 7, 7, 9, - 9,10, 9,11,10,11,11, 0, 6, 6, 7, 7, 9, 9,10,10, - 11,11,12,12, 0, 7, 7, 7, 7, 9, 9,10,10,11,11,12, - 12, 0,11,11, 8, 8,10,10,11,11,12,12,12,12, 0,11, - 12, 9, 8,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 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 static_codebook _44c6_s_p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44c6_s_p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c6_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c6_s_p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c6_s_p6_1[] = { - 3, 4, 4, 5, 5, 5, 4, 4, 5, 5, 5, 4, 4, 5, 5, 6, - 5, 5, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c6_s_p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44c6_s_p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c6_s_p6_1, - 0 -}; - -static const long _vq_quantlist__44c6_s_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c6_s_p7_0[] = { - 1, 4, 4, 6, 6, 8, 8, 8, 8,10,10,11,10, 6, 5, 5, - 7, 7, 8, 8, 9, 9,10,10,12,11, 6, 5, 5, 7, 7, 8, - 8, 9, 9,10,10,12,11,21, 7, 7, 7, 7, 9, 9,10,10, - 11,11,12,12,21, 7, 7, 7, 7, 9, 9,10,10,11,11,12, - 12,21,12,12, 9, 9,10,10,11,11,11,11,12,12,21,12, - 12, 9, 9,10,10,11,11,12,12,12,12,21,21,21,11,11, - 10,10,11,12,12,12,13,13,21,21,21,11,11,10,10,12, - 12,12,12,13,13,21,21,21,15,15,11,11,12,12,13,13, - 13,13,21,21,21,15,16,11,11,12,12,13,13,14,14,21, - 21,21,21,20,13,13,13,13,13,13,14,14,20,20,20,20, - 20,13,13,13,13,13,13,14,14, -}; - -static const static_codebook _44c6_s_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44c6_s_p7_0, - 1, -523206656, 1618345984, 4, 0, - (long *)_vq_quantlist__44c6_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c6_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c6_s_p7_1[] = { - 3, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 9, 5, 5, 6, 6, - 7, 7, 7, 7, 8, 7, 8, 5, 5, 6, 6, 7, 7, 7, 7, 7, - 7, 9, 6, 6, 7, 7, 7, 7, 8, 7, 7, 8, 9, 9, 9, 7, - 7, 7, 7, 7, 7, 7, 8, 9, 9, 9, 7, 7, 7, 7, 8, 8, - 8, 8, 9, 9, 9, 7, 7, 7, 7, 7, 7, 8, 8, 9, 9, 9, - 8, 8, 8, 8, 7, 7, 8, 8, 9, 9, 9, 9, 8, 8, 8, 7, - 7, 8, 8, 9, 9, 9, 8, 8, 8, 8, 7, 7, 8, 8, 9, 9, - 9, 8, 8, 7, 7, 7, 7, 8, 8, -}; - -static const static_codebook _44c6_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44c6_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c6_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c6_s_p8_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44c6_s_p8_0[] = { - 1, 4, 4, 7, 7, 8, 8, 7, 7, 8, 7, 9, 8,10, 9, 6, - 5, 5, 8, 8, 9, 9, 8, 8, 9, 9,11,10,11,10, 6, 5, - 5, 8, 8, 9, 9, 8, 8, 9, 9,10,10,11,11,18, 8, 8, - 9, 8,10,10, 9, 9,10,10,10,10,11,10,18, 8, 8, 9, - 9,10,10, 9, 9,10,10,11,11,12,12,18,12,13, 9,10, - 10,10, 9,10,10,10,11,11,12,11,18,13,13, 9, 9,10, - 10,10,10,10,10,11,11,12,12,18,18,18,10,10, 9, 9, - 11,11,11,11,11,12,12,12,18,18,18,10, 9,10, 9,11, - 10,11,11,11,11,13,12,18,18,18,14,13,10,10,11,11, - 12,12,12,12,12,12,18,18,18,14,13,10,10,11,10,12, - 12,12,12,12,12,18,18,18,18,18,12,12,11,11,12,12, - 13,13,13,14,18,18,18,18,18,12,12,11,11,12,11,13, - 13,14,13,18,18,18,18,18,16,16,11,12,12,13,13,13, - 14,13,18,18,18,18,18,16,15,12,11,12,11,13,11,15, - 14, -}; - -static const static_codebook _44c6_s_p8_0 = { - 2, 225, - (char *)_vq_lengthlist__44c6_s_p8_0, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__44c6_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c6_s_p8_1[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__44c6_s_p8_1[] = { - 3, 5, 5, 6, 6, 7, 7, 7, 7, 8, 7, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8,10, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 6, 6, 7, 7, 8, - 8, 8, 8, 8, 8, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9,10, - 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9,10,11,11, 8, 7, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,11,11,11, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11,11, - 11, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9,11,11,11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,11,11,11,11,11, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10, 9,11,11,11, - 11,11, 9, 9, 9, 9, 9, 9,10, 9, 9,10, 9,10, 9, 9, - 10, 9,11,11,11,11,11, 9, 9, 9, 9, 9, 9, 9,10,10, - 10,10, 9,10,10, 9,10,11,11,11,11,11, 9, 9, 9, 9, - 10,10,10, 9,10,10,10,10, 9,10,10, 9,11,11,11,11, - 11,11,11, 9, 9, 9, 9,10,10,10,10, 9,10,10,10,10, - 10,11,11,11,11,11,11,11,10, 9,10,10,10,10,10,10, - 10, 9,10, 9,10,10,11,11,11,11,11,11,11,10, 9,10, - 9,10,10, 9,10,10,10,10,10,10,10,11,11,11,11,11, - 11,11,10,10,10,10,10,10,10, 9,10,10,10,10,10, 9, - 11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10, - 10,10,10,10,10,11,11,11,11,11,11,11,11,11,10,10, - 10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11, - 11,11,11,10,10,10,10,10,10,10,10,10, 9,10,10,11, - 11,11,11,11,11,11,11,11,10,10,10, 9,10,10,10,10, - 10,10,10,10,10,11,11,11,11,11,11,11,11,10,11, 9, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _44c6_s_p8_1 = { - 2, 441, - (char *)_vq_lengthlist__44c6_s_p8_1, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__44c6_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c6_s_p9_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c6_s_p9_0[] = { - 1, 3, 3,11,11,11,11,11,11,11,11,11,11, 4, 7, 7, - 11,11,11,11,11,11,11,11,11,11, 5, 8, 9,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _44c6_s_p9_0 = { - 2, 169, - (char *)_vq_lengthlist__44c6_s_p9_0, - 1, -511845376, 1630791680, 4, 0, - (long *)_vq_quantlist__44c6_s_p9_0, - 0 -}; - -static const long _vq_quantlist__44c6_s_p9_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c6_s_p9_1[] = { - 1, 4, 4, 7, 7, 7, 7, 7, 6, 8, 8, 8, 8, 6, 6, 6, - 8, 8, 8, 8, 8, 7, 9, 8,10,10, 5, 6, 6, 8, 8, 9, - 9, 8, 8,10,10,10,10,16, 9, 9, 9, 9, 9, 9, 9, 8, - 10, 9,11,11,16, 8, 9, 9, 9, 9, 9, 9, 9,10,10,11, - 11,16,13,13, 9, 9,10, 9, 9,10,11,11,11,12,16,13, - 14, 9, 8,10, 8, 9, 9,10,10,12,11,16,14,16, 9, 9, - 9, 9,11,11,12,11,12,11,16,16,16, 9, 7, 9, 6,11, - 11,11,10,11,11,16,16,16,11,12, 9,10,11,11,12,11, - 13,13,16,16,16,12,11,10, 7,12,10,12,12,12,12,16, - 16,15,16,16,10,11,10,11,13,13,14,12,16,16,16,15, - 15,12,10,11,11,13,11,12,13, -}; - -static const static_codebook _44c6_s_p9_1 = { - 2, 169, - (char *)_vq_lengthlist__44c6_s_p9_1, - 1, -518889472, 1622704128, 4, 0, - (long *)_vq_quantlist__44c6_s_p9_1, - 0 -}; - -static const long _vq_quantlist__44c6_s_p9_2[] = { - 24, - 23, - 25, - 22, - 26, - 21, - 27, - 20, - 28, - 19, - 29, - 18, - 30, - 17, - 31, - 16, - 32, - 15, - 33, - 14, - 34, - 13, - 35, - 12, - 36, - 11, - 37, - 10, - 38, - 9, - 39, - 8, - 40, - 7, - 41, - 6, - 42, - 5, - 43, - 4, - 44, - 3, - 45, - 2, - 46, - 1, - 47, - 0, - 48, -}; - -static const char _vq_lengthlist__44c6_s_p9_2[] = { - 2, 4, 3, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 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, -}; - -static const static_codebook _44c6_s_p9_2 = { - 1, 49, - (char *)_vq_lengthlist__44c6_s_p9_2, - 1, -526909440, 1611661312, 6, 0, - (long *)_vq_quantlist__44c6_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__44c6_s_short[] = { - 3, 9,11,11,13,14,19,17,17,19, 5, 4, 5, 8,10,10, - 13,16,18,19, 7, 4, 4, 5, 8, 9,12,14,17,19, 8, 6, - 5, 5, 7, 7,10,13,16,18,10, 8, 7, 6, 5, 5, 8,11, - 17,19,11, 9, 7, 7, 5, 4, 5, 8,17,19,13,11, 8, 7, - 7, 5, 5, 7,16,18,14,13, 8, 6, 6, 5, 5, 7,16,18, - 18,16,10, 8, 8, 7, 7, 9,16,18,18,18,12,10,10, 9, - 9,10,17,18, -}; - -static const static_codebook _huff_book__44c6_s_short = { - 2, 100, - (char *)_huff_lengthlist__44c6_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c7_s_long[] = { - 3, 8,11,13,15,14,14,13,15,14, 6, 4, 5, 7, 9,10, - 11,11,14,13,10, 4, 3, 5, 7, 8, 9,10,13,13,12, 7, - 4, 4, 5, 6, 8, 9,12,14,13, 9, 6, 5, 5, 6, 8, 9, - 12,14,12, 9, 7, 6, 5, 5, 6, 8,11,11,12,11, 9, 8, - 7, 6, 6, 7,10,11,13,11,10, 9, 8, 7, 6, 6, 9,11, - 13,13,12,12,12,10, 9, 8, 9,11,12,14,15,15,14,12, - 11,10,10,12, -}; - -static const static_codebook _huff_book__44c7_s_long = { - 2, 100, - (char *)_huff_lengthlist__44c7_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c7_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c7_s_p1_0[] = { - 1, 5, 5, 0, 5, 5, 0, 5, 5, 5, 8, 7, 0, 9, 9, 0, - 9, 8, 5, 7, 8, 0, 9, 9, 0, 8, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 9, 9, 0, 8, 8, 0, 8, 8, 5, 8, 9, - 0, 8, 8, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, - 9, 9, 0, 8, 8, 0, 8, 8, 5, 8, 9, 0, 8, 8, 0, 8, - 8, -}; - -static const static_codebook _44c7_s_p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44c7_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c7_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c7_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c7_s_p2_0[] = { - 3, 5, 5, 8, 8, 0, 5, 5, 8, 8, 0, 5, 5, 8, 8, 0, - 7, 7, 9, 9, 0, 0, 0, 9, 9, 5, 7, 7, 9, 9, 0, 8, - 8,10,10, 0, 8, 7,10, 9, 0,10,10,11,11, 0, 0, 0, - 11,11, 5, 7, 7, 9, 9, 0, 8, 8,10,10, 0, 7, 8, 9, - 10, 0,10,10,11,11, 0, 0, 0,11,11, 8, 9, 9,11,10, - 0,11,11,12,12, 0,11,10,12,12, 0,13,14,14,14, 0, - 0, 0,14,13, 8, 9, 9,10,11, 0,11,11,12,12, 0,10, - 11,12,12, 0,13,13,14,14, 0, 0, 0,13,14, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5, 8, 7,11,10, 0, 7, 7,10,10, - 0, 7, 7,10,10, 0, 9, 9,11,10, 0, 0, 0,11,11, 5, - 7, 8,10,11, 0, 7, 7,10,10, 0, 7, 7,10,10, 0, 9, - 9,10,11, 0, 0, 0,11,11, 8,10, 9,12,12, 0,10,10, - 12,12, 0,10,10,12,12, 0,12,12,13,13, 0, 0, 0,13, - 13, 8, 9,10,12,12, 0,10,10,12,12, 0,10,10,11,12, - 0,12,12,13,13, 0, 0, 0,13,13, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 8, 8,11,11, 0, 7, 7,10,10, 0, 7, 7, - 10,10, 0, 9, 9,10,11, 0, 0, 0,11,10, 5, 8, 8,10, - 11, 0, 7, 7,10,10, 0, 7, 7,10,10, 0, 9, 9,11,10, - 0, 0, 0,10,11, 9,10,10,12,12, 0,10,10,12,12, 0, - 10,10,12,12, 0,12,13,13,13, 0, 0, 0,13,12, 9,10, - 10,12,12, 0,10,10,12,12, 0,10,10,12,12, 0,13,12, - 13,13, 0, 0, 0,12,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7,10,10,14,13, 0, 9, 9,12,12, 0, 9, 9,12,12, 0, - 10,10,12,12, 0, 0, 0,12,12, 7,10,10,13,14, 0, 9, - 9,12,13, 0, 9, 9,12,12, 0,10,10,12,12, 0, 0, 0, - 12,12, 9,11,11,14,13, 0,11,10,13,12, 0,11,11,13, - 13, 0,12,12,13,13, 0, 0, 0,13,13, 9,11,11,13,14, - 0,10,11,12,13, 0,11,11,13,13, 0,12,12,13,13, 0, - 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, - 11,11,14,14, 0,10,11,13,13, 0,11,10,13,13, 0,12, - 12,13,13, 0, 0, 0,13,12, 9,11,11,14,14, 0,11,10, - 13,13, 0,10,11,13,13, 0,12,12,14,13, 0, 0, 0,13, - 13, -}; - -static const static_codebook _44c7_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c7_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c7_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c7_s_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c7_s_p3_0[] = { - 2, 4, 4, 5, 5, 7, 7, 9, 9, 0, 4, 4, 6, 6, 7, 7, - 9, 9, 0, 4, 4, 6, 6, 7, 7, 9, 9, 0, 5, 5, 6, 6, - 8, 8,10,10, 0, 0, 0, 6, 6, 8, 8,10,10, 0, 0, 0, - 7, 7, 9, 9,10,10, 0, 0, 0, 7, 7, 8, 8,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c7_s_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44c7_s_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c7_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c7_s_p4_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c7_s_p4_0[] = { - 3, 4, 4, 5, 5, 7, 7, 8, 8, 8, 8, 9, 9,10,10,11, - 11, 0, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11,11, - 12,12, 0, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11, - 11,12,12, 0, 5, 5, 6, 6, 8, 8, 9, 9, 9, 9,10,10, - 11,12,12,12, 0, 0, 0, 6, 6, 8, 7, 9, 9, 9, 9,10, - 10,11,11,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9,10,10, - 11,11,12,12,13,12, 0, 0, 0, 7, 7, 8, 8, 9, 9,10, - 10,11,11,12,12,12,13, 0, 0, 0, 7, 7, 8, 8, 9, 9, - 10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 8, 8, 9, - 9,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c7_s_p4_0 = { - 2, 289, - (char *)_vq_lengthlist__44c7_s_p4_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c7_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c7_s_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c7_s_p5_0[] = { - 1, 4, 4, 5, 7, 7, 6, 7, 7, 4, 6, 7,10,10,10,10, - 10, 9, 4, 6, 6,10,10,10,10, 9,10, 5,10,10, 9,11, - 12,10,11,12, 7,10,10,11,12,12,12,12,12, 7,10,10, - 11,12,12,12,12,12, 6,10,10,10,12,12,11,12,12, 7, - 10,10,12,12,12,12,11,12, 7,10,10,11,12,12,12,12, - 12, -}; - -static const static_codebook _44c7_s_p5_0 = { - 4, 81, - (char *)_vq_lengthlist__44c7_s_p5_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c7_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c7_s_p5_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c7_s_p5_1[] = { - 3, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8,11, 4, 4, 6, 6, - 7, 7, 8, 8, 9, 9,11, 4, 4, 6, 6, 7, 7, 8, 8, 9, - 9,12, 5, 5, 6, 6, 7, 7, 9, 9, 9, 9,12,12,12, 6, - 6, 7, 7, 9, 9, 9, 9,11,11,11, 7, 7, 7, 7, 8, 8, - 9, 9,11,11,11, 7, 7, 7, 7, 8, 8, 9, 9,11,11,11, - 7, 7, 8, 8, 8, 8, 9, 9,11,11,11,11,11, 8, 8, 8, - 8, 8, 9,11,11,11,11,11, 8, 8, 8, 8, 8, 8,11,11, - 11,11,11, 7, 7, 8, 8, 8, 8, -}; - -static const static_codebook _44c7_s_p5_1 = { - 2, 121, - (char *)_vq_lengthlist__44c7_s_p5_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c7_s_p5_1, - 0 -}; - -static const long _vq_quantlist__44c7_s_p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c7_s_p6_0[] = { - 1, 4, 4, 6, 6, 7, 7, 8, 7, 9, 8,10,10, 6, 5, 5, - 7, 7, 8, 8, 9, 9, 9,10,11,11, 7, 5, 5, 7, 7, 8, - 8, 9, 9,10,10,11,11, 0, 7, 7, 7, 7, 9, 8, 9, 9, - 10,10,11,11, 0, 8, 8, 7, 7, 8, 9, 9, 9,10,10,11, - 11, 0,11,11, 9, 9,10,10,11,10,11,11,12,12, 0,12, - 12, 9, 9,10,10,11,11,11,11,12,12, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 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 static_codebook _44c7_s_p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44c7_s_p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c7_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c7_s_p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c7_s_p6_1[] = { - 3, 4, 4, 5, 5, 5, 4, 4, 5, 5, 5, 4, 4, 5, 5, 6, - 5, 5, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c7_s_p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44c7_s_p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c7_s_p6_1, - 0 -}; - -static const long _vq_quantlist__44c7_s_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c7_s_p7_0[] = { - 1, 4, 4, 6, 6, 7, 8, 9, 9,10,10,12,11, 6, 5, 5, - 7, 7, 8, 8, 9,10,11,11,12,12, 7, 5, 5, 7, 7, 8, - 8,10,10,11,11,12,12,20, 7, 7, 7, 7, 8, 9,10,10, - 11,11,12,13,20, 7, 7, 7, 7, 9, 9,10,10,11,12,13, - 13,20,11,11, 8, 8, 9, 9,11,11,12,12,13,13,20,11, - 11, 8, 8, 9, 9,11,11,12,12,13,13,20,20,20,10,10, - 10,10,12,12,13,13,13,13,20,20,20,10,10,10,10,12, - 12,13,13,13,14,20,20,20,14,14,11,11,12,12,13,13, - 14,14,20,20,20,14,14,11,11,12,12,13,13,14,14,20, - 20,20,20,19,13,13,13,13,14,14,15,14,19,19,19,19, - 19,13,13,13,13,14,14,15,15, -}; - -static const static_codebook _44c7_s_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44c7_s_p7_0, - 1, -523206656, 1618345984, 4, 0, - (long *)_vq_quantlist__44c7_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c7_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c7_s_p7_1[] = { - 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 8, 6, 6, 7, 7, - 7, 7, 7, 7, 7, 7, 8, 6, 6, 6, 7, 7, 7, 7, 7, 7, - 7, 8, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 7, - 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 7, 7, 7, 7, 7, 7, - 7, 7, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, - 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 7, 7, 7, - 7, 7, 7, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 8, 8, - 8, 8, 8, 7, 7, 7, 7, 7, 7, -}; - -static const static_codebook _44c7_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44c7_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c7_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c7_s_p8_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44c7_s_p8_0[] = { - 1, 4, 4, 7, 7, 8, 8, 8, 7, 9, 8, 9, 9,10,10, 6, - 5, 5, 7, 7, 9, 9, 8, 8,10, 9,11,10,12,11, 6, 5, - 5, 8, 7, 9, 9, 8, 8,10,10,11,11,12,11,19, 8, 8, - 8, 8,10,10, 9, 9,10,10,11,11,12,11,19, 8, 8, 8, - 8,10,10, 9, 9,10,10,11,11,12,12,19,12,12, 9, 9, - 10,10, 9,10,10,10,11,11,12,12,19,12,12, 9, 9,10, - 10,10,10,10,10,12,12,12,12,19,19,19, 9, 9, 9, 9, - 11,10,11,11,12,11,13,13,19,19,19, 9, 9, 9, 9,11, - 10,11,11,11,12,13,13,19,19,19,13,13,10,10,11,11, - 12,12,12,12,13,12,19,19,19,14,13,10,10,11,11,12, - 12,12,13,13,13,19,19,19,19,19,12,12,12,11,12,13, - 14,13,13,13,19,19,19,19,19,12,12,12,11,12,12,13, - 14,13,14,19,19,19,19,19,16,16,12,13,12,13,13,14, - 15,14,19,18,18,18,18,16,15,12,11,12,11,14,12,14, - 14, -}; - -static const static_codebook _44c7_s_p8_0 = { - 2, 225, - (char *)_vq_lengthlist__44c7_s_p8_0, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__44c7_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c7_s_p8_1[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__44c7_s_p8_1[] = { - 3, 5, 5, 7, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8,10, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 6, 6, 7, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, - 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10, - 10, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10,11,10,10,10, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9,10, 9, 9,10, 9, 9,10,11,10, - 11,10, 9, 9, 9, 9, 9, 9, 9,10,10,10, 9,10, 9, 9, - 9, 9,11,10,11,10,10, 9, 9, 9, 9, 9, 9,10, 9, 9, - 10, 9, 9,10, 9, 9,10,11,10,10,11,10, 9, 9, 9, 9, - 9,10,10, 9,10,10,10,10, 9,10,10,10,10,10,10,11, - 11,11,10, 9, 9, 9,10,10,10,10,10,10,10,10,10,10, - 10,10,10,11,11,10,10,10,10,10,10,10,10,10,10,10, - 10, 9,10,10, 9,10,11,11,10,11,10,11,10, 9,10,10, - 9,10,10,10,10,10,10,10,10,10,10,11,11,11,11,10, - 11,11,10,10,10,10,10,10, 9,10, 9,10,10, 9,10, 9, - 10,10,10,11,10,11,10,11,11,10,10,10,10,10,10, 9, - 10,10,10,10,10,10,10,11,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,11,10,11, - 11,10,10,10,10, 9, 9,10,10, 9, 9,10, 9,10,10,10, - 10,11,11,10,10,10,10,10,10,10, 9, 9,10,10,10, 9, - 9,10,10,10,10,10,11,10,11,10,10,10,10,10,10, 9, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _44c7_s_p8_1 = { - 2, 441, - (char *)_vq_lengthlist__44c7_s_p8_1, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__44c7_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c7_s_p9_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c7_s_p9_0[] = { - 1, 3, 3,11,11,11,11,11,11,11,11,11,11, 4, 6, 6, - 11,11,11,11,11,11,11,11,11,11, 4, 7, 7,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11, -}; - -static const static_codebook _44c7_s_p9_0 = { - 2, 169, - (char *)_vq_lengthlist__44c7_s_p9_0, - 1, -511845376, 1630791680, 4, 0, - (long *)_vq_quantlist__44c7_s_p9_0, - 0 -}; - -static const long _vq_quantlist__44c7_s_p9_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c7_s_p9_1[] = { - 1, 4, 4, 7, 7, 7, 7, 7, 6, 8, 8, 8, 8, 6, 6, 6, - 8, 8, 9, 8, 8, 7, 9, 8,11,10, 5, 6, 6, 8, 8, 9, - 8, 8, 8,10, 9,11,11,16, 8, 8, 9, 8, 9, 9, 9, 8, - 10, 9,11,10,16, 8, 8, 9, 9,10,10, 9, 9,10,10,11, - 11,16,13,13, 9, 9,10,10, 9,10,11,11,12,11,16,13, - 13, 9, 8,10, 9,10,10,10,10,11,11,16,14,16, 8, 9, - 9, 9,11,10,11,11,12,11,16,16,16, 9, 7,10, 7,11, - 10,11,11,12,11,16,16,16,12,12, 9,10,11,11,12,11, - 12,12,16,16,16,12,10,10, 7,11, 8,12,11,12,12,16, - 16,15,16,16,11,12,10,10,12,11,12,12,16,16,16,15, - 15,11,11,10,10,12,12,12,12, -}; - -static const static_codebook _44c7_s_p9_1 = { - 2, 169, - (char *)_vq_lengthlist__44c7_s_p9_1, - 1, -518889472, 1622704128, 4, 0, - (long *)_vq_quantlist__44c7_s_p9_1, - 0 -}; - -static const long _vq_quantlist__44c7_s_p9_2[] = { - 24, - 23, - 25, - 22, - 26, - 21, - 27, - 20, - 28, - 19, - 29, - 18, - 30, - 17, - 31, - 16, - 32, - 15, - 33, - 14, - 34, - 13, - 35, - 12, - 36, - 11, - 37, - 10, - 38, - 9, - 39, - 8, - 40, - 7, - 41, - 6, - 42, - 5, - 43, - 4, - 44, - 3, - 45, - 2, - 46, - 1, - 47, - 0, - 48, -}; - -static const char _vq_lengthlist__44c7_s_p9_2[] = { - 2, 4, 3, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 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, -}; - -static const static_codebook _44c7_s_p9_2 = { - 1, 49, - (char *)_vq_lengthlist__44c7_s_p9_2, - 1, -526909440, 1611661312, 6, 0, - (long *)_vq_quantlist__44c7_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__44c7_s_short[] = { - 4,11,12,14,15,15,17,17,18,18, 5, 6, 6, 8, 9,10, - 13,17,18,19, 7, 5, 4, 6, 8, 9,11,15,19,19, 8, 6, - 5, 5, 6, 7,11,14,16,17, 9, 7, 7, 6, 7, 7,10,13, - 15,19,10, 8, 7, 6, 7, 6, 7, 9,14,16,12,10, 9, 7, - 7, 6, 4, 5,10,15,14,13,11, 7, 6, 6, 4, 2, 7,13, - 16,16,15, 9, 8, 8, 8, 6, 9,13,19,19,17,12,11,10, - 10, 9,11,14, -}; - -static const static_codebook _huff_book__44c7_s_short = { - 2, 100, - (char *)_huff_lengthlist__44c7_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c8_s_long[] = { - 3, 8,12,13,14,14,14,13,14,14, 6, 4, 5, 8,10,10, - 11,11,14,13, 9, 5, 4, 5, 7, 8, 9,10,13,13,12, 7, - 5, 4, 5, 6, 8, 9,12,13,13, 9, 6, 5, 5, 5, 7, 9, - 11,14,12,10, 7, 6, 5, 4, 6, 7,10,11,12,11, 9, 8, - 7, 5, 5, 6,10,10,13,12,10, 9, 8, 6, 6, 5, 8,10, - 14,13,12,12,11,10, 9, 7, 8,10,12,13,14,14,13,12, - 11, 9, 9,10, -}; - -static const static_codebook _huff_book__44c8_s_long = { - 2, 100, - (char *)_huff_lengthlist__44c8_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c8_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c8_s_p1_0[] = { - 1, 5, 5, 0, 5, 5, 0, 5, 5, 5, 7, 7, 0, 9, 8, 0, - 9, 8, 6, 7, 7, 0, 8, 9, 0, 8, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 9, 8, 0, 8, 8, 0, 8, 8, 5, 8, 9, - 0, 8, 8, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, - 9, 8, 0, 8, 8, 0, 8, 8, 5, 8, 9, 0, 8, 8, 0, 8, - 8, -}; - -static const static_codebook _44c8_s_p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44c8_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c8_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c8_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c8_s_p2_0[] = { - 3, 5, 5, 8, 8, 0, 5, 5, 8, 8, 0, 5, 5, 8, 8, 0, - 7, 7, 9, 9, 0, 0, 0, 9, 9, 5, 7, 7, 9, 9, 0, 8, - 7,10, 9, 0, 8, 7,10, 9, 0,10,10,11,11, 0, 0, 0, - 11,11, 5, 7, 7, 9, 9, 0, 7, 8, 9,10, 0, 7, 8, 9, - 10, 0,10,10,11,11, 0, 0, 0,11,11, 8, 9, 9,11,10, - 0,11,10,12,11, 0,11,10,12,12, 0,13,13,14,14, 0, - 0, 0,14,13, 8, 9, 9,10,11, 0,10,11,12,12, 0,10, - 11,12,12, 0,13,13,14,14, 0, 0, 0,13,14, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5, 8, 7,11,10, 0, 7, 7,10,10, - 0, 7, 7,10,10, 0, 9, 9,10,10, 0, 0, 0,11,10, 5, - 7, 8,10,11, 0, 7, 7,10,10, 0, 7, 7,10,10, 0, 9, - 9,10,10, 0, 0, 0,10,10, 8,10, 9,12,12, 0,10,10, - 12,11, 0,10,10,12,12, 0,12,12,13,12, 0, 0, 0,13, - 12, 8, 9,10,12,12, 0,10,10,11,12, 0,10,10,11,12, - 0,12,12,13,13, 0, 0, 0,12,13, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 8, 7,11,10, 0, 7, 7,10,10, 0, 7, 7, - 10,10, 0, 9, 9,10,11, 0, 0, 0,10,10, 6, 7, 8,10, - 11, 0, 7, 7,10,10, 0, 7, 7,10,10, 0, 9, 9,10,10, - 0, 0, 0,10,10, 9,10, 9,12,12, 0,10,10,12,12, 0, - 10,10,12,11, 0,12,12,13,13, 0, 0, 0,13,12, 8, 9, - 10,12,12, 0,10,10,12,12, 0,10,10,11,12, 0,12,12, - 13,13, 0, 0, 0,12,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7,10,10,13,13, 0, 9, 9,12,12, 0, 9, 9,12,12, 0, - 10,10,12,12, 0, 0, 0,12,12, 7,10,10,13,13, 0, 9, - 9,12,12, 0, 9, 9,12,12, 0,10,10,12,12, 0, 0, 0, - 12,12, 9,11,11,14,13, 0,10,10,13,12, 0,11,10,13, - 12, 0,12,12,13,12, 0, 0, 0,13,13, 9,11,11,13,14, - 0,10,11,12,13, 0,10,11,13,13, 0,12,12,12,13, 0, - 0, 0,13,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, - 11,11,14,14, 0,10,11,13,13, 0,11,10,13,13, 0,11, - 12,13,13, 0, 0, 0,13,12, 9,11,11,14,14, 0,11,10, - 13,13, 0,10,11,13,13, 0,12,12,13,13, 0, 0, 0,12, - 13, -}; - -static const static_codebook _44c8_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c8_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c8_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c8_s_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c8_s_p3_0[] = { - 2, 4, 4, 5, 5, 7, 7, 9, 9, 0, 4, 4, 6, 6, 7, 7, - 9, 9, 0, 4, 4, 6, 6, 7, 7, 9, 9, 0, 5, 5, 6, 6, - 8, 8,10,10, 0, 0, 0, 6, 6, 8, 8,10,10, 0, 0, 0, - 7, 7, 9, 9,10,10, 0, 0, 0, 7, 7, 8, 8,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c8_s_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44c8_s_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c8_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c8_s_p4_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c8_s_p4_0[] = { - 3, 4, 4, 5, 5, 7, 7, 8, 8, 8, 8, 9, 9,10,10,11, - 11, 0, 4, 4, 6, 6, 7, 7, 8, 8, 9, 8,10,10,11,11, - 11,11, 0, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11, - 11,11,11, 0, 6, 5, 6, 6, 7, 7, 9, 9, 9, 9,10,10, - 11,11,12,12, 0, 0, 0, 6, 6, 7, 7, 9, 9, 9, 9,10, - 10,11,11,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9,10,10, - 11,11,11,12,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9,10, - 10,11,11,11,12,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, - 10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 8, 8, 9, - 9,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c8_s_p4_0 = { - 2, 289, - (char *)_vq_lengthlist__44c8_s_p4_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c8_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c8_s_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c8_s_p5_0[] = { - 1, 4, 4, 5, 7, 7, 6, 7, 7, 4, 7, 6,10,10,10,10, - 10,10, 4, 6, 6,10,10,10,10, 9,10, 5,10,10, 9,11, - 11,10,11,11, 7,10,10,11,12,12,12,12,12, 7,10,10, - 11,12,12,12,12,12, 6,10,10,10,12,12,10,12,12, 7, - 10,10,11,12,12,12,12,12, 7,10,10,11,12,12,12,12, - 12, -}; - -static const static_codebook _44c8_s_p5_0 = { - 4, 81, - (char *)_vq_lengthlist__44c8_s_p5_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c8_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c8_s_p5_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c8_s_p5_1[] = { - 3, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8,11, 4, 5, 6, 6, - 7, 7, 8, 8, 8, 8,11, 5, 5, 6, 6, 7, 7, 8, 8, 8, - 9,12, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,12,12,12, 6, - 6, 7, 7, 8, 8, 9, 9,11,11,11, 6, 6, 7, 7, 8, 8, - 8, 8,11,11,11, 6, 6, 7, 7, 8, 8, 8, 8,11,11,11, - 7, 7, 7, 8, 8, 8, 8, 8,11,11,11,11,11, 7, 7, 8, - 8, 8, 8,11,11,11,11,11, 7, 7, 7, 7, 8, 8,11,11, - 11,11,11, 7, 7, 7, 7, 8, 8, -}; - -static const static_codebook _44c8_s_p5_1 = { - 2, 121, - (char *)_vq_lengthlist__44c8_s_p5_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c8_s_p5_1, - 0 -}; - -static const long _vq_quantlist__44c8_s_p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c8_s_p6_0[] = { - 1, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10, 6, 5, 5, - 7, 7, 8, 8, 9, 9,10,10,11,11, 6, 5, 5, 7, 7, 8, - 8, 9, 9,10,10,11,11, 0, 7, 7, 7, 7, 9, 9,10,10, - 10,10,11,11, 0, 7, 7, 7, 7, 9, 9,10,10,10,10,11, - 11, 0,11,11, 9, 9,10,10,11,11,11,11,12,12, 0,12, - 12, 9, 9,10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 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 static_codebook _44c8_s_p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44c8_s_p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c8_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c8_s_p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c8_s_p6_1[] = { - 3, 4, 4, 5, 5, 5, 4, 4, 5, 5, 5, 4, 4, 5, 5, 6, - 5, 5, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c8_s_p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44c8_s_p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c8_s_p6_1, - 0 -}; - -static const long _vq_quantlist__44c8_s_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c8_s_p7_0[] = { - 1, 4, 4, 6, 6, 8, 7, 9, 9,10,10,12,12, 6, 5, 5, - 7, 7, 8, 8,10,10,11,11,12,12, 7, 5, 5, 7, 7, 8, - 8,10,10,11,11,12,12,21, 7, 7, 7, 7, 8, 9,10,10, - 11,11,12,12,21, 7, 7, 7, 7, 9, 9,10,10,12,12,13, - 13,21,11,11, 8, 8, 9, 9,11,11,12,12,13,13,21,11, - 11, 8, 8, 9, 9,11,11,12,12,13,13,21,21,21,10,10, - 10,10,11,11,12,13,13,13,21,21,21,10,10,10,10,11, - 11,13,13,14,13,21,21,21,13,13,11,11,12,12,13,13, - 14,14,21,21,21,14,14,11,11,12,12,13,13,14,14,21, - 21,21,21,20,13,13,13,12,14,14,16,15,20,20,20,20, - 20,13,13,13,13,14,13,15,15, -}; - -static const static_codebook _44c8_s_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44c8_s_p7_0, - 1, -523206656, 1618345984, 4, 0, - (long *)_vq_quantlist__44c8_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c8_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c8_s_p7_1[] = { - 4, 5, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 6, 6, 6, 7, - 7, 7, 7, 7, 7, 7, 8, 6, 6, 6, 6, 7, 7, 7, 7, 7, - 7, 8, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 7, - 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 7, 7, 7, 7, 7, 7, - 7, 7, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, - 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 7, 7, 7, - 7, 7, 7, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 8, 8, - 8, 8, 8, 7, 7, 7, 7, 7, 7, -}; - -static const static_codebook _44c8_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44c8_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c8_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c8_s_p8_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44c8_s_p8_0[] = { - 1, 4, 4, 7, 6, 8, 8, 8, 7, 9, 8,10,10,11,10, 6, - 5, 5, 7, 7, 9, 9, 8, 8,10,10,11,11,12,11, 6, 5, - 5, 7, 7, 9, 9, 9, 9,10,10,11,11,12,12,20, 8, 8, - 8, 8, 9, 9, 9, 9,10,10,11,11,12,12,20, 8, 8, 8, - 8,10, 9, 9, 9,10,10,11,11,12,12,20,12,12, 9, 9, - 10,10,10,10,10,11,12,12,12,12,20,12,12, 9, 9,10, - 10,10,10,11,11,12,12,13,13,20,20,20, 9, 9, 9, 9, - 11,10,11,11,12,12,12,13,20,19,19, 9, 9, 9, 9,11, - 11,11,12,12,12,13,13,19,19,19,13,13,10,10,11,11, - 12,12,13,13,13,13,19,19,19,14,13,11,10,11,11,12, - 12,12,13,13,13,19,19,19,19,19,12,12,12,12,13,13, - 13,13,14,13,19,19,19,19,19,12,12,12,11,12,12,13, - 14,14,14,19,19,19,19,19,16,15,13,12,13,13,13,14, - 14,14,19,19,19,19,19,17,17,13,12,13,11,14,13,15, - 15, -}; - -static const static_codebook _44c8_s_p8_0 = { - 2, 225, - (char *)_vq_lengthlist__44c8_s_p8_0, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__44c8_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c8_s_p8_1[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__44c8_s_p8_1[] = { - 4, 5, 5, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8,10, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 6, 6, 7, 7, 8, - 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, - 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10, - 10, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, - 10,10, 9, 9, 9, 9, 9, 9, 9, 9,10, 9, 9, 9, 9, 9, - 9, 9,10,10,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10, 9, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 9, 9, 9, 9, 9,10,10,10,10, - 10,10,10, 9, 9, 9, 9, 9,10,10,10, 9, 9, 9, 9, 9, - 9,10,10,10,10,10,10,10, 9,10,10, 9,10,10,10,10, - 9,10, 9,10,10, 9,10,10,10,10,10,10,10, 9,10,10, - 10,10,10,10, 9, 9,10,10, 9,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, 9, 9, 9,10, 9, 9, 9, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, - 10, 9,10, 9,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10, 9, 9,10, 9, 9, 9,10,10,10,10,10,10, - 10,10,10,10,10, 9, 9, 9, 9, 9, 9,10, 9, 9,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10, 9,10, 9, - 9,10, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10, - 10, 9, 9,10,10, 9,10, 9, 9, -}; - -static const static_codebook _44c8_s_p8_1 = { - 2, 441, - (char *)_vq_lengthlist__44c8_s_p8_1, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__44c8_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c8_s_p9_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c8_s_p9_0[] = { - 1, 4, 3,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11, 4, 7, 7,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11, 4, 8,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _44c8_s_p9_0 = { - 2, 289, - (char *)_vq_lengthlist__44c8_s_p9_0, - 1, -509798400, 1631393792, 5, 0, - (long *)_vq_quantlist__44c8_s_p9_0, - 0 -}; - -static const long _vq_quantlist__44c8_s_p9_1[] = { - 9, - 8, - 10, - 7, - 11, - 6, - 12, - 5, - 13, - 4, - 14, - 3, - 15, - 2, - 16, - 1, - 17, - 0, - 18, -}; - -static const char _vq_lengthlist__44c8_s_p9_1[] = { - 1, 4, 4, 7, 6, 7, 7, 7, 7, 8, 8, 9, 9,10,10,10, - 10,11,11, 6, 6, 6, 8, 8, 9, 8, 8, 7,10, 8,11,10, - 12,11,12,12,13,13, 5, 5, 6, 8, 8, 9, 9, 8, 8,10, - 9,11,11,12,12,13,13,13,13,17, 8, 8, 9, 9, 9, 9, - 9, 9,10, 9,12,10,12,12,13,12,13,13,17, 9, 8, 9, - 9, 9, 9, 9, 9,10,10,12,12,12,12,13,13,13,13,17, - 13,13, 9, 9,10,10,10,10,11,11,12,11,13,12,13,13, - 14,15,17,13,13, 9, 8,10, 9,10,10,11,11,12,12,14, - 13,15,13,14,15,17,17,17, 9,10, 9,10,11,11,12,12, - 12,12,13,13,14,14,15,15,17,17,17, 9, 8, 9, 8,11, - 11,12,12,12,12,14,13,14,14,14,15,17,17,17,12,14, - 9,10,11,11,12,12,14,13,13,14,15,13,15,15,17,17, - 17,13,11,10, 8,11, 9,13,12,13,13,13,13,13,14,14, - 14,17,17,17,17,17,11,12,11,11,13,13,14,13,15,14, - 13,15,16,15,17,17,17,17,17,11,11,12, 8,13,12,14, - 13,17,14,15,14,15,14,17,17,17,17,17,15,15,12,12, - 12,12,13,14,14,14,15,14,17,14,17,17,17,17,17,16, - 17,12,12,13,12,13,13,14,14,14,14,14,14,17,17,17, - 17,17,17,17,14,14,13,12,13,13,15,15,14,13,15,17, - 17,17,17,17,17,17,17,13,14,13,13,13,13,14,15,15, - 15,14,15,17,17,17,17,17,17,17,16,15,13,14,13,13, - 14,14,15,14,14,16,17,17,17,17,17,17,17,16,16,13, - 14,13,13,14,14,15,14,15,14, -}; - -static const static_codebook _44c8_s_p9_1 = { - 2, 361, - (char *)_vq_lengthlist__44c8_s_p9_1, - 1, -518287360, 1622704128, 5, 0, - (long *)_vq_quantlist__44c8_s_p9_1, - 0 -}; - -static const long _vq_quantlist__44c8_s_p9_2[] = { - 24, - 23, - 25, - 22, - 26, - 21, - 27, - 20, - 28, - 19, - 29, - 18, - 30, - 17, - 31, - 16, - 32, - 15, - 33, - 14, - 34, - 13, - 35, - 12, - 36, - 11, - 37, - 10, - 38, - 9, - 39, - 8, - 40, - 7, - 41, - 6, - 42, - 5, - 43, - 4, - 44, - 3, - 45, - 2, - 46, - 1, - 47, - 0, - 48, -}; - -static const char _vq_lengthlist__44c8_s_p9_2[] = { - 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 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, -}; - -static const static_codebook _44c8_s_p9_2 = { - 1, 49, - (char *)_vq_lengthlist__44c8_s_p9_2, - 1, -526909440, 1611661312, 6, 0, - (long *)_vq_quantlist__44c8_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__44c8_s_short[] = { - 4,11,13,14,15,15,18,17,19,17, 5, 6, 8, 9,10,10, - 12,15,19,19, 6, 6, 6, 6, 8, 8,11,14,18,19, 8, 6, - 5, 4, 6, 7,10,13,16,17, 9, 7, 6, 5, 6, 7, 9,12, - 15,19,10, 8, 7, 6, 6, 6, 7, 9,13,15,12,10, 9, 8, - 7, 6, 4, 5,10,15,13,13,11, 8, 6, 6, 4, 2, 7,12, - 17,15,16,10, 8, 8, 7, 6, 9,12,19,18,17,13,11,10, - 10, 9,11,14, -}; - -static const static_codebook _huff_book__44c8_s_short = { - 2, 100, - (char *)_huff_lengthlist__44c8_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c9_s_long[] = { - 3, 8,12,14,15,15,15,13,15,15, 6, 5, 8,10,12,12, - 13,12,14,13,10, 6, 5, 6, 8, 9,11,11,13,13,13, 8, - 5, 4, 5, 6, 8,10,11,13,14,10, 7, 5, 4, 5, 7, 9, - 11,12,13,11, 8, 6, 5, 4, 5, 7, 9,11,12,11,10, 8, - 7, 5, 4, 5, 9,10,13,13,11,10, 8, 6, 5, 4, 7, 9, - 15,14,13,12,10, 9, 8, 7, 8, 9,12,12,14,13,12,11, - 10, 9, 8, 9, -}; - -static const static_codebook _huff_book__44c9_s_long = { - 2, 100, - (char *)_huff_lengthlist__44c9_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c9_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c9_s_p1_0[] = { - 1, 5, 5, 0, 5, 5, 0, 5, 5, 6, 8, 8, 0, 9, 8, 0, - 9, 8, 6, 8, 8, 0, 8, 9, 0, 8, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 8, 8, 0, 7, 7, 0, 8, 8, 5, 8, 8, - 0, 7, 8, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, - 9, 8, 0, 8, 8, 0, 7, 7, 5, 8, 9, 0, 8, 8, 0, 7, - 7, -}; - -static const static_codebook _44c9_s_p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44c9_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c9_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c9_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c9_s_p2_0[] = { - 3, 5, 5, 8, 8, 0, 5, 5, 8, 8, 0, 5, 5, 8, 8, 0, - 7, 7, 9, 9, 0, 0, 0, 9, 9, 6, 7, 7, 9, 8, 0, 8, - 8, 9, 9, 0, 8, 7, 9, 9, 0, 9,10,10,10, 0, 0, 0, - 11,10, 6, 7, 7, 8, 9, 0, 8, 8, 9, 9, 0, 7, 8, 9, - 9, 0,10, 9,11,10, 0, 0, 0,10,10, 8, 9, 8,10,10, - 0,10,10,12,11, 0,10,10,11,11, 0,12,13,13,13, 0, - 0, 0,13,12, 8, 8, 9,10,10, 0,10,10,11,12, 0,10, - 10,11,11, 0,13,12,13,13, 0, 0, 0,13,13, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 6, 8, 7,10,10, 0, 7, 7,10, 9, - 0, 7, 7,10,10, 0, 9, 9,10,10, 0, 0, 0,10,10, 6, - 7, 8,10,10, 0, 7, 7, 9,10, 0, 7, 7,10,10, 0, 9, - 9,10,10, 0, 0, 0,10,10, 8, 9, 9,11,11, 0,10,10, - 11,11, 0,10,10,11,11, 0,12,12,12,12, 0, 0, 0,12, - 12, 8, 9,10,11,11, 0, 9,10,11,11, 0,10,10,11,11, - 0,12,12,12,12, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 8, 7,10,10, 0, 7, 7,10,10, 0, 7, 7, - 10, 9, 0, 9, 9,10,10, 0, 0, 0,10,10, 6, 7, 8,10, - 10, 0, 7, 7,10,10, 0, 7, 7, 9,10, 0, 9, 9,10,10, - 0, 0, 0,10,10, 8,10, 9,12,11, 0,10,10,12,11, 0, - 10, 9,11,11, 0,11,12,12,12, 0, 0, 0,12,12, 8, 9, - 10,11,12, 0,10,10,11,11, 0, 9,10,11,11, 0,12,11, - 12,12, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7,10, 9,12,12, 0, 9, 9,12,11, 0, 9, 9,11,11, 0, - 10,10,12,11, 0, 0, 0,11,12, 7, 9,10,12,12, 0, 9, - 9,11,12, 0, 9, 9,11,11, 0,10,10,11,12, 0, 0, 0, - 11,11, 9,11,10,13,12, 0,10,10,12,12, 0,10,10,12, - 12, 0,11,11,12,12, 0, 0, 0,13,12, 9,10,11,12,13, - 0,10,10,12,12, 0,10,10,12,12, 0,11,12,12,12, 0, - 0, 0,12,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, - 11,10,13,13, 0,10,10,12,12, 0,10,10,12,12, 0,11, - 12,12,12, 0, 0, 0,12,12, 9,10,11,13,13, 0,10,10, - 12,12, 0,10,10,12,12, 0,12,11,13,12, 0, 0, 0,12, - 12, -}; - -static const static_codebook _44c9_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c9_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c9_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c9_s_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c9_s_p3_0[] = { - 3, 4, 4, 5, 5, 6, 6, 8, 8, 0, 4, 4, 5, 5, 6, 7, - 8, 8, 0, 4, 4, 5, 5, 7, 7, 8, 8, 0, 5, 5, 6, 6, - 7, 7, 9, 9, 0, 0, 0, 6, 6, 7, 7, 9, 9, 0, 0, 0, - 7, 7, 8, 8, 9, 9, 0, 0, 0, 7, 7, 8, 8, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c9_s_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44c9_s_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c9_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c9_s_p4_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c9_s_p4_0[] = { - 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10,10, - 10, 0, 5, 4, 5, 5, 7, 7, 8, 8, 8, 8, 9, 9,10,10, - 11,11, 0, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10, - 10,11,11, 0, 6, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10, - 11,11,11,12, 0, 0, 0, 6, 6, 7, 7, 8, 8, 9, 9,10, - 10,11,11,12,12, 0, 0, 0, 7, 7, 7, 7, 9, 9, 9, 9, - 10,10,11,11,12,12, 0, 0, 0, 7, 7, 7, 8, 9, 9, 9, - 9,10,10,11,11,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, - 10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 8, 8, 9, - 9,10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c9_s_p4_0 = { - 2, 289, - (char *)_vq_lengthlist__44c9_s_p4_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c9_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c9_s_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c9_s_p5_0[] = { - 1, 4, 4, 5, 7, 7, 6, 7, 7, 4, 7, 6, 9,10,10,10, - 10, 9, 4, 6, 7, 9,10,10,10, 9,10, 5, 9, 9, 9,11, - 11,10,11,11, 7,10, 9,11,12,11,12,12,12, 7, 9,10, - 11,11,12,12,12,12, 6,10,10,10,12,12,10,12,11, 7, - 10,10,11,12,12,11,12,12, 7,10,10,11,12,12,12,12, - 12, -}; - -static const static_codebook _44c9_s_p5_0 = { - 4, 81, - (char *)_vq_lengthlist__44c9_s_p5_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c9_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c9_s_p5_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c9_s_p5_1[] = { - 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7,11, 5, 5, 6, 6, - 7, 7, 7, 7, 8, 8,11, 5, 5, 6, 6, 7, 7, 7, 7, 8, - 8,11, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8,11,11,11, 6, - 6, 7, 7, 7, 8, 8, 8,11,11,11, 6, 6, 7, 7, 7, 8, - 8, 8,11,11,11, 6, 6, 7, 7, 7, 7, 8, 8,11,11,11, - 7, 7, 7, 7, 7, 7, 8, 8,11,11,11,10,10, 7, 7, 7, - 7, 8, 8,11,11,11,11,11, 7, 7, 7, 7, 7, 7,11,11, - 11,11,11, 7, 7, 7, 7, 7, 7, -}; - -static const static_codebook _44c9_s_p5_1 = { - 2, 121, - (char *)_vq_lengthlist__44c9_s_p5_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c9_s_p5_1, - 0 -}; - -static const long _vq_quantlist__44c9_s_p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c9_s_p6_0[] = { - 2, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 5, 4, 4, - 6, 6, 8, 8, 9, 9, 9, 9,10,10, 6, 4, 4, 6, 6, 8, - 8, 9, 9, 9, 9,10,10, 0, 6, 6, 7, 7, 8, 8, 9, 9, - 10,10,11,11, 0, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11, - 11, 0,10,10, 8, 8, 9, 9,10,10,11,11,12,12, 0,11, - 11, 8, 8, 9, 9,10,10,11,11,12,12, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 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 static_codebook _44c9_s_p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44c9_s_p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c9_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c9_s_p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c9_s_p6_1[] = { - 4, 4, 4, 5, 5, 5, 4, 4, 5, 5, 5, 4, 4, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44c9_s_p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44c9_s_p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c9_s_p6_1, - 0 -}; - -static const long _vq_quantlist__44c9_s_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c9_s_p7_0[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8,10,10,11,11, 6, 4, 4, - 6, 6, 8, 8, 9, 9,10,10,12,12, 6, 4, 5, 6, 6, 8, - 8, 9, 9,10,10,12,12,20, 6, 6, 6, 6, 8, 8, 9,10, - 11,11,12,12,20, 6, 6, 6, 6, 8, 8,10,10,11,11,12, - 12,20,10,10, 7, 7, 9, 9,10,10,11,11,12,12,20,11, - 11, 7, 7, 9, 9,10,10,11,11,12,12,20,20,20, 9, 9, - 9, 9,11,11,12,12,13,13,20,20,20, 9, 9, 9, 9,11, - 11,12,12,13,13,20,20,20,13,13,10,10,11,11,12,13, - 13,13,20,20,20,13,13,10,10,11,11,12,13,13,13,20, - 20,20,20,19,12,12,12,12,13,13,14,15,19,19,19,19, - 19,12,12,12,12,13,13,14,14, -}; - -static const static_codebook _44c9_s_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44c9_s_p7_0, - 1, -523206656, 1618345984, 4, 0, - (long *)_vq_quantlist__44c9_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c9_s_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c9_s_p7_1[] = { - 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 7, 7, 7, 7, 7, - 7, 8, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 6, - 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 7, 7, 7, 7, 7, 7, - 7, 7, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, - 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 7, 7, 7, - 7, 7, 7, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 8, 8, - 8, 8, 8, 7, 7, 7, 7, 7, 7, -}; - -static const static_codebook _44c9_s_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44c9_s_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c9_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c9_s_p8_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44c9_s_p8_0[] = { - 1, 4, 4, 7, 6, 8, 8, 8, 8, 9, 9,10,10,11,10, 6, - 5, 5, 7, 7, 9, 9, 8, 9,10,10,11,11,12,12, 6, 5, - 5, 7, 7, 9, 9, 9, 9,10,10,11,11,12,12,21, 7, 8, - 8, 8, 9, 9, 9, 9,10,10,11,11,12,12,21, 8, 8, 8, - 8, 9, 9, 9, 9,10,10,11,11,12,12,21,11,12, 9, 9, - 10,10,10,10,10,11,11,12,12,12,21,12,12, 9, 8,10, - 10,10,10,11,11,12,12,13,13,21,21,21, 9, 9, 9, 9, - 11,11,11,11,12,12,12,13,21,20,20, 9, 9, 9, 9,10, - 11,11,11,12,12,13,13,20,20,20,13,13,10,10,11,11, - 12,12,13,13,13,13,20,20,20,13,13,10,10,11,11,12, - 12,13,13,13,13,20,20,20,20,20,12,12,12,12,12,12, - 13,13,14,14,20,20,20,20,20,12,12,12,11,13,12,13, - 13,14,14,20,20,20,20,20,15,16,13,12,13,13,14,13, - 14,14,20,20,20,20,20,16,15,12,12,13,12,14,13,14, - 14, -}; - -static const static_codebook _44c9_s_p8_0 = { - 2, 225, - (char *)_vq_lengthlist__44c9_s_p8_0, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__44c9_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c9_s_p8_1[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__44c9_s_p8_1[] = { - 4, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8,10, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 6, 6, 7, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, - 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10, - 10, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, - 10,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9,10,10,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10, 9, 9, 9,10,10,10,10, - 10,10,10, 9, 9, 9, 9, 9, 9,10, 9, 9, 9, 9, 9, 9, - 9,10,10,10,10,10,10,10, 9, 9, 9,10,10,10,10,10, - 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10, 9, 9,10, - 9,10, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10, - 10,10,10,10, 9, 9,10,10, 9, 9, 9, 9, 9, 9, 9, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, - 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10, - 10,10, 9, 9,10, 9, 9, 9, 9, 9,10,10,10,10,10,10, - 10,10,10,10,10, 9, 9,10,10, 9, 9,10, 9, 9, 9,10, - 10,10,10,10,10,10,10,10,10,10, 9, 9,10, 9, 9, 9, - 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10, 9, - 9, 9, 9,10, 9, 9, 9, 9, 9, -}; - -static const static_codebook _44c9_s_p8_1 = { - 2, 441, - (char *)_vq_lengthlist__44c9_s_p8_1, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__44c9_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c9_s_p9_0[] = { - 9, - 8, - 10, - 7, - 11, - 6, - 12, - 5, - 13, - 4, - 14, - 3, - 15, - 2, - 16, - 1, - 17, - 0, - 18, -}; - -static const char _vq_lengthlist__44c9_s_p9_0[] = { - 1, 4, 3,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12, 4, 5, 6,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12, 4, 6, 6,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,11,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11, -}; - -static const static_codebook _44c9_s_p9_0 = { - 2, 361, - (char *)_vq_lengthlist__44c9_s_p9_0, - 1, -508535424, 1631393792, 5, 0, - (long *)_vq_quantlist__44c9_s_p9_0, - 0 -}; - -static const long _vq_quantlist__44c9_s_p9_1[] = { - 9, - 8, - 10, - 7, - 11, - 6, - 12, - 5, - 13, - 4, - 14, - 3, - 15, - 2, - 16, - 1, - 17, - 0, - 18, -}; - -static const char _vq_lengthlist__44c9_s_p9_1[] = { - 1, 4, 4, 7, 7, 7, 7, 8, 7, 9, 8, 9, 9,10,10,11, - 11,11,11, 6, 5, 5, 8, 8, 9, 9, 9, 8,10, 9,11,10, - 12,12,13,12,13,13, 5, 5, 5, 8, 8, 9, 9, 9, 9,10, - 10,11,11,12,12,13,12,13,13,17, 8, 8, 9, 9, 9, 9, - 9, 9,10,10,12,11,13,12,13,13,13,13,18, 8, 8, 9, - 9, 9, 9, 9, 9,11,11,12,12,13,13,13,13,13,13,17, - 13,12, 9, 9,10,10,10,10,11,11,12,12,12,13,13,13, - 14,14,18,13,12, 9, 9,10,10,10,10,11,11,12,12,13, - 13,13,14,14,14,17,18,18,10,10,10,10,11,11,11,12, - 12,12,14,13,14,13,13,14,18,18,18,10, 9,10, 9,11, - 11,12,12,12,12,13,13,15,14,14,14,18,18,16,13,14, - 10,11,11,11,12,13,13,13,13,14,13,13,14,14,18,18, - 18,14,12,11, 9,11,10,13,12,13,13,13,14,14,14,13, - 14,18,18,17,18,18,11,12,12,12,13,13,14,13,14,14, - 13,14,14,14,18,18,18,18,17,12,10,12, 9,13,11,13, - 14,14,14,14,14,15,14,18,18,17,17,18,14,15,12,13, - 13,13,14,13,14,14,15,14,15,14,18,17,18,18,18,15, - 15,12,10,14,10,14,14,13,13,14,14,14,14,18,16,18, - 18,18,18,17,14,14,13,14,14,13,13,14,14,14,15,15, - 18,18,18,18,17,17,17,14,14,14,12,14,13,14,14,15, - 14,15,14,18,18,18,18,18,18,18,17,16,13,13,13,14, - 14,14,14,15,16,15,18,18,18,18,18,18,18,17,17,13, - 13,13,13,14,13,14,15,15,15, -}; - -static const static_codebook _44c9_s_p9_1 = { - 2, 361, - (char *)_vq_lengthlist__44c9_s_p9_1, - 1, -518287360, 1622704128, 5, 0, - (long *)_vq_quantlist__44c9_s_p9_1, - 0 -}; - -static const long _vq_quantlist__44c9_s_p9_2[] = { - 24, - 23, - 25, - 22, - 26, - 21, - 27, - 20, - 28, - 19, - 29, - 18, - 30, - 17, - 31, - 16, - 32, - 15, - 33, - 14, - 34, - 13, - 35, - 12, - 36, - 11, - 37, - 10, - 38, - 9, - 39, - 8, - 40, - 7, - 41, - 6, - 42, - 5, - 43, - 4, - 44, - 3, - 45, - 2, - 46, - 1, - 47, - 0, - 48, -}; - -static const char _vq_lengthlist__44c9_s_p9_2[] = { - 2, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, -}; - -static const static_codebook _44c9_s_p9_2 = { - 1, 49, - (char *)_vq_lengthlist__44c9_s_p9_2, - 1, -526909440, 1611661312, 6, 0, - (long *)_vq_quantlist__44c9_s_p9_2, - 0 -}; - -static const char _huff_lengthlist__44c9_s_short[] = { - 5,13,18,16,17,17,19,18,19,19, 5, 7,10,11,12,12, - 13,16,17,18, 6, 6, 7, 7, 9, 9,10,14,17,19, 8, 7, - 6, 5, 6, 7, 9,12,19,17, 8, 7, 7, 6, 5, 6, 8,11, - 15,19, 9, 8, 7, 6, 5, 5, 6, 8,13,15,11,10, 8, 8, - 7, 5, 4, 4,10,14,12,13,11, 9, 7, 6, 4, 2, 6,12, - 18,16,16,13, 8, 7, 7, 5, 8,13,16,17,18,15,11, 9, - 9, 8,10,13, -}; - -static const static_codebook _huff_book__44c9_s_short = { - 2, 100, - (char *)_huff_lengthlist__44c9_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c0_s_long[] = { - 5, 4, 8, 9, 8, 9,10,12,15, 4, 1, 5, 5, 6, 8,11, - 12,12, 8, 5, 8, 9, 9,11,13,12,12, 9, 5, 8, 5, 7, - 9,12,13,13, 8, 6, 8, 7, 7, 9,11,11,11, 9, 7, 9, - 7, 7, 7, 7,10,12,10,10,11, 9, 8, 7, 7, 9,11,11, - 12,13,12,11, 9, 8, 9,11,13,16,16,15,15,12,10,11, - 12, -}; - -static const static_codebook _huff_book__44c0_s_long = { - 2, 81, - (char *)_huff_lengthlist__44c0_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c0_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c0_s_p1_0[] = { - 1, 5, 5, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 8, 7, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 8,10, 9, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 9,10,11, 0, 0, 0, 0, 0, 0, 9,11,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 9,11, 9, 0, 0, 0, 0, 0, 0, 9,10,11, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,11,10, 0, - 0, 0, 0, 0, 0, 9, 9,11, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 9,10, 0, 0, 0, 0, 0, 0, 9,10,11, - 0, 0, 0, 0, 0, 0, 9,11,10, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c0_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44c0_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c0_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c0_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c0_s_p2_0[] = { - 1, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 5, 7, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 5, 6, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 7, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 7, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c0_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c0_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c0_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c0_s_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c0_s_p3_0[] = { - 1, 3, 2, 8, 7, 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 8, 8, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c0_s_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44c0_s_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c0_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c0_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c0_s_p4_0[] = { - 1, 3, 3, 6, 6, 6, 6, 8, 8, 0, 0, 0, 7, 7, 7, 7, - 9, 9, 0, 0, 0, 7, 7, 7, 7, 9, 9, 0, 0, 0, 7, 7, - 7, 8, 9, 9, 0, 0, 0, 7, 7, 7, 7, 9, 9, 0, 0, 0, - 9, 9, 8, 8,10,10, 0, 0, 0, 8, 9, 8, 8,10,10, 0, - 0, 0,10,10, 9, 9,10,10, 0, 0, 0, 0, 0, 9, 9,10, - 10, -}; - -static const static_codebook _44c0_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44c0_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c0_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c0_s_p5_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c0_s_p5_0[] = { - 1, 4, 3, 6, 6, 8, 7, 8, 8, 8, 8, 9, 9,10,10,11, - 11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9, 9,10,10,10, - 11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10, - 10,11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,11,11, 0, 0, 0, 8, 8, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12, 0, 0, 0, 8, 8, 9, 9, 9, 9,10, - 10,10,10,11,11,12,12, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,11,11,12,12,12, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,11,11,12,12, 0, 0, 0, 0, 0, 9, 9, - 10,10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, - 9,10,10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, - 10,10,11,11,11,11,11,12,12,12,13,13, 0, 0, 0, 0, - 0, 0, 0,11,10,11,11,11,11,12,12,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,12,11,12,12,12,12,13,13, 0, 0, - 0, 0, 0, 0, 0,11,11,11,12,12,12,12,13,13,13, 0, - 0, 0, 0, 0, 0, 0,12,12,12,12,12,13,13,13,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,14, - 14, -}; - -static const static_codebook _44c0_s_p5_0 = { - 2, 289, - (char *)_vq_lengthlist__44c0_s_p5_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c0_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c0_s_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c0_s_p6_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7,10, 9, 9,10, - 9, 9, 4, 6, 7,10, 9, 9,11, 9, 9, 7,10,10,11,11, - 11,12,10,11, 6, 9, 9,11,10,11,11,10,10, 6, 9, 9, - 11,10,11,11,10,10, 7,11,10,12,11,11,11,11,11, 7, - 9, 9,10,10,10,11,11,10, 6, 9, 9,11,10,10,11,10, - 10, -}; - -static const static_codebook _44c0_s_p6_0 = { - 4, 81, - (char *)_vq_lengthlist__44c0_s_p6_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c0_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c0_s_p6_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c0_s_p6_1[] = { - 2, 3, 3, 6, 6, 7, 7, 7, 7, 7, 8,10,10,10, 6, 6, - 7, 7, 8, 8, 8, 8,10,10,10, 6, 6, 7, 7, 8, 8, 8, - 8,10,10,10, 7, 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, - 7, 7, 7, 8, 8, 8, 8,10,10,10, 8, 7, 8, 8, 8, 8, - 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 8, 8,10,10,10,10,10, 8, 8, 8, - 8, 8, 8,10,10,10,10,10, 9, 9, 8, 8, 8, 8,10,10, - 10,10,10, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44c0_s_p6_1 = { - 2, 121, - (char *)_vq_lengthlist__44c0_s_p6_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c0_s_p6_1, - 0 -}; - -static const long _vq_quantlist__44c0_s_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c0_s_p7_0[] = { - 1, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 7, 5, 5, - 7, 7, 8, 8, 8, 8, 9, 9,10,10, 7, 5, 6, 7, 7, 8, - 8, 8, 8, 9, 9,10,10, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9,10,10,10,10,11,11,11,11, 0,13, - 13, 9, 9, 9, 9,10,10,11,11,11,12, 0, 0, 0,10,10, - 10,10,11,11,11,11,12,12, 0, 0, 0,10,10, 9, 9,11, - 11,11,12,12,12, 0, 0, 0,13,13,10,10,11,11,12,12, - 13,13, 0, 0, 0,14,14,10,10,11,11,12,12,13,13, 0, - 0, 0, 0, 0,11,11,11,11,13,12,13,13, 0, 0, 0, 0, - 0,12,12,11,11,12,12,13,13, -}; - -static const static_codebook _44c0_s_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44c0_s_p7_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c0_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c0_s_p7_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c0_s_p7_1[] = { - 2, 3, 3, 5, 5, 6, 6, 6, 5, 5, 6, 6, 6, 5, 5, 6, - 6, 6, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c0_s_p7_1 = { - 2, 25, - (char *)_vq_lengthlist__44c0_s_p7_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c0_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c0_s_p8_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c0_s_p8_0[] = { - 1, 5, 5,10,10, 6, 9, 8,10,10, 6,10, 9,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10, 8,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,10,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11, -}; - -static const static_codebook _44c0_s_p8_0 = { - 4, 625, - (char *)_vq_lengthlist__44c0_s_p8_0, - 1, -518283264, 1627103232, 3, 0, - (long *)_vq_quantlist__44c0_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c0_s_p8_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c0_s_p8_1[] = { - 1, 4, 4, 6, 6, 7, 7, 9, 9,11,12,13,12, 6, 5, 5, - 7, 7, 8, 8,10, 9,12,12,12,12, 6, 5, 5, 7, 7, 8, - 8,10, 9,12,11,11,13,16, 7, 7, 8, 8, 9, 9,10,10, - 12,12,13,12,16, 7, 7, 8, 7, 9, 9,10,10,11,12,12, - 13,16,10,10, 8, 8,10,10,11,12,12,12,13,13,16,11, - 10, 8, 7,11,10,11,11,12,11,13,13,16,16,16,10,10, - 10,10,11,11,13,12,13,13,16,16,16,11, 9,11, 9,15, - 13,12,13,13,13,16,16,16,15,13,11,11,12,13,12,12, - 14,13,16,16,16,14,13,11,11,13,12,14,13,13,13,16, - 16,16,16,16,13,13,13,12,14,13,14,14,16,16,16,16, - 16,13,13,12,12,14,14,15,13, -}; - -static const static_codebook _44c0_s_p8_1 = { - 2, 169, - (char *)_vq_lengthlist__44c0_s_p8_1, - 1, -522616832, 1620115456, 4, 0, - (long *)_vq_quantlist__44c0_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c0_s_p8_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c0_s_p8_2[] = { - 2, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, - 8,10,10,10, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9,10,10,10, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9,10,10,10, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, - 9,10, 9, 9,10,10,10, 7, 7, 8, 8, 9, 8, 9, 9, 9, - 9,10, 9, 9,10,10,10,10, 8, 8, 8, 8, 9, 8, 9, 9, - 9, 9, 9,10, 9,10,10,10,10, 7, 7, 8, 8, 9, 9, 9, - 9, 9, 9,10, 9,10,10,10,10,10, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 9,11,10,10,10,10, 8, 8, 9, - 9, 9, 9, 9,10, 9, 9, 9,10,10,10,10,11,11, 9, 9, - 9, 9, 9, 9, 9, 9,10, 9, 9,10,11,10,10,11,11, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 9,11,11,10,11,11, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 9,11,10,10,11, - 11,11,11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, - 11,11,11,11, 9,10, 9,10, 9, 9, 9, 9,10, 9,10,11, - 10,11,10,10,10,10,10, 9, 9, 9,10, 9, 9, 9,10,11, - 11,10,11,11,10,11,10,10,10, 9, 9, 9, 9,10, 9, 9, - 10,11,10,11,11,11,11,10,11,10,10, 9,10, 9, 9, 9, - 10, -}; - -static const static_codebook _44c0_s_p8_2 = { - 2, 289, - (char *)_vq_lengthlist__44c0_s_p8_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c0_s_p8_2, - 0 -}; - -static const char _huff_lengthlist__44c0_s_short[] = { - 9, 8,12,11,12,13,14,14,16, 6, 1, 5, 6, 6, 9,12, - 14,17, 9, 4, 5, 9, 7, 9,13,15,16, 8, 5, 8, 6, 8, - 10,13,17,17, 9, 6, 7, 7, 8, 9,13,15,17,11, 8, 9, - 9, 9,10,12,16,16,13, 7, 8, 7, 7, 9,12,14,15,13, - 6, 7, 5, 5, 7,10,13,13,14, 7, 8, 5, 6, 7, 9,10, - 12, -}; - -static const static_codebook _huff_book__44c0_s_short = { - 2, 81, - (char *)_huff_lengthlist__44c0_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c0_sm_long[] = { - 5, 4, 9,10, 9,10,11,12,13, 4, 1, 5, 7, 7, 9,11, - 12,14, 8, 5, 7, 9, 8,10,13,13,13,10, 7, 9, 4, 6, - 7,10,12,14, 9, 6, 7, 6, 6, 7,10,12,12, 9, 8, 9, - 7, 6, 7, 8,11,12,11,11,11, 9, 8, 7, 8,10,12,12, - 13,14,12,11, 9, 9, 9,12,12,17,17,15,16,12,10,11, - 13, -}; - -static const static_codebook _huff_book__44c0_sm_long = { - 2, 81, - (char *)_huff_lengthlist__44c0_sm_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c0_sm_p1_0[] = { - 1, 5, 5, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 8, 7, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 9, 8, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 7, 0, 0, 0, 0, - 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 9,10,10, 0, 0, 0, 0, 0, 0, 9,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 8,10, 9, 0, 0, 0, 0, 0, 0, 9,10,10, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 8, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,10,10, 0, - 0, 0, 0, 0, 0, 9, 9,10, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,10,10, - 0, 0, 0, 0, 0, 0, 9,10,10, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c0_sm_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44c0_sm_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c0_sm_p1_0, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c0_sm_p2_0[] = { - 1, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 5, 7, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 5, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 7, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c0_sm_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c0_sm_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c0_sm_p2_0, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c0_sm_p3_0[] = { - 1, 3, 3, 7, 7, 0, 0, 0, 0, 0, 5, 4, 7, 7, 0, 0, - 0, 0, 0, 5, 5, 7, 7, 0, 0, 0, 0, 0, 6, 7, 8, 8, - 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, - 9,10, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, - 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c0_sm_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44c0_sm_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c0_sm_p3_0, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c0_sm_p4_0[] = { - 1, 4, 3, 6, 6, 7, 7, 9, 9, 0, 5, 5, 7, 7, 8, 7, - 9, 9, 0, 5, 5, 7, 7, 8, 8, 9, 9, 0, 7, 7, 8, 8, - 8, 8,10,10, 0, 0, 0, 8, 8, 8, 8,10,10, 0, 0, 0, - 9, 9, 9, 9,11,11, 0, 0, 0, 9, 9, 9, 9,11,11, 0, - 0, 0,10,10,10,10,11,11, 0, 0, 0, 0, 0, 9, 9,11, - 11, -}; - -static const static_codebook _44c0_sm_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44c0_sm_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c0_sm_p4_0, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p5_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c0_sm_p5_0[] = { - 1, 4, 4, 6, 6, 8, 8, 8, 8, 8, 8, 9, 9,10,10,11, - 11, 0, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10,11, - 11,11, 0, 5, 6, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10, - 11,11,11, 0, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9,10,10, - 11,11,12,12, 0, 0, 0, 8, 8, 8, 8, 9, 9, 9, 9,10, - 10,11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10,10, - 11,11,11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10, - 10,11,11,11,11,12,12, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12,12,13, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9, - 10,10,11,11,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, - 9,10,10,11,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, - 10,10,10,10,11,11,12,12,12,13,13,13, 0, 0, 0, 0, - 0, 0, 0,10,10,11,11,12,12,12,13,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,12,12,12,12,13,13,14,14, 0, 0, - 0, 0, 0, 0, 0,11,11,12,11,12,12,13,13,13,13, 0, - 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,13,13,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,14, - 14, -}; - -static const static_codebook _44c0_sm_p5_0 = { - 2, 289, - (char *)_vq_lengthlist__44c0_sm_p5_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c0_sm_p5_0, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c0_sm_p6_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7,10, 9, 9,11, - 9, 9, 4, 7, 7,10, 9, 9,11, 9, 9, 7,10,10,10,11, - 11,11,10,10, 6, 9, 9,11,11,10,11,10,10, 6, 9, 9, - 11,10,11,11,10,10, 7,11,10,11,11,11,11,11,11, 6, - 9, 9,11,10,10,11,11,10, 6, 9, 9,11,10,10,11,10, - 11, -}; - -static const static_codebook _44c0_sm_p6_0 = { - 4, 81, - (char *)_vq_lengthlist__44c0_sm_p6_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c0_sm_p6_0, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p6_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c0_sm_p6_1[] = { - 2, 4, 4, 6, 6, 7, 7, 7, 7, 7, 8, 9, 5, 5, 6, 6, - 7, 7, 8, 8, 8, 8, 9, 5, 5, 6, 6, 7, 7, 8, 8, 8, - 8,10, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, - 7, 7, 7, 8, 8, 8, 8,10,10,10, 8, 8, 8, 8, 8, 8, - 8, 8,10,10,10, 8, 8, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 8, 8,10,10,10,10,10, 8, 8, 8, - 8, 8, 8,10,10,10,10,10, 9, 9, 8, 8, 8, 8,10,10, - 10,10,10, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44c0_sm_p6_1 = { - 2, 121, - (char *)_vq_lengthlist__44c0_sm_p6_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c0_sm_p6_1, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c0_sm_p7_0[] = { - 1, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 7, 5, 5, - 7, 7, 8, 8, 8, 8, 9, 9,10,10, 7, 6, 5, 7, 7, 8, - 8, 8, 8, 9, 9,10,10, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9,10,10,10,10,11,11,11,11, 0,13, - 13, 9, 9, 9, 9,10,10,11,11,11,12, 0, 0, 0, 9,10, - 10,10,11,11,12,11,12,12, 0, 0, 0,10,10, 9, 9,11, - 11,12,12,12,12, 0, 0, 0,13,13,10,10,11,11,12,12, - 13,13, 0, 0, 0,14,14,10,10,11,11,12,12,13,13, 0, - 0, 0, 0, 0,11,12,11,11,13,12,13,13, 0, 0, 0, 0, - 0,12,12,11,11,13,12,14,14, -}; - -static const static_codebook _44c0_sm_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44c0_sm_p7_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c0_sm_p7_0, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p7_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c0_sm_p7_1[] = { - 2, 4, 4, 4, 4, 6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 6, - 6, 6, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c0_sm_p7_1 = { - 2, 25, - (char *)_vq_lengthlist__44c0_sm_p7_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c0_sm_p7_1, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p8_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c0_sm_p8_0[] = { - 1, 3, 3,11,11,11,11,11,11, 3, 7, 6,11,11,11,11, - 11,11, 4, 8, 7,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12, -}; - -static const static_codebook _44c0_sm_p8_0 = { - 2, 81, - (char *)_vq_lengthlist__44c0_sm_p8_0, - 1, -516186112, 1627103232, 4, 0, - (long *)_vq_quantlist__44c0_sm_p8_0, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p8_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c0_sm_p8_1[] = { - 1, 4, 4, 6, 6, 7, 7, 9, 9,10,11,12,12, 6, 5, 5, - 7, 7, 8, 8,10,10,12,11,12,12, 6, 5, 5, 7, 7, 8, - 8,10,10,12,11,12,12,17, 7, 7, 8, 8, 9, 9,10,10, - 12,12,13,13,18, 7, 7, 8, 7, 9, 9,10,10,12,12,12, - 13,19,10,10, 8, 8,10,10,11,11,12,12,13,14,19,11, - 10, 8, 7,10,10,11,11,12,12,13,12,19,19,19,10,10, - 10,10,11,11,12,12,13,13,19,19,19,11, 9,11, 9,14, - 12,13,12,13,13,19,20,18,13,14,11,11,12,12,13,13, - 14,13,20,20,20,15,13,11,10,13,11,13,13,14,13,20, - 20,20,20,20,13,14,12,12,13,13,13,13,20,20,20,20, - 20,13,13,12,12,16,13,15,13, -}; - -static const static_codebook _44c0_sm_p8_1 = { - 2, 169, - (char *)_vq_lengthlist__44c0_sm_p8_1, - 1, -522616832, 1620115456, 4, 0, - (long *)_vq_quantlist__44c0_sm_p8_1, - 0 -}; - -static const long _vq_quantlist__44c0_sm_p8_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c0_sm_p8_2[] = { - 2, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, - 8,10, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9,10, 6, 6, 7, 7, 8, 7, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9,10, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 7, 7, 8, 8, 9, 8, 9, 9, 9, - 9,10, 9, 9,10,10,10,11, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 9,10, 9,10,10,10,10, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9,10,10,11,10,10, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10,10,10,11,11, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10,11,11,11,11,11, 9, 9, - 9, 9, 9, 9, 9, 9,10, 9,10, 9,11,11,10,11,11, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 9,11,11,10,11,11, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 9,11,10,11,11, - 11,11,11, 9, 9,10, 9, 9, 9, 9, 9, 9, 9,10,11,10, - 11,11,11,11,10,10,10,10, 9, 9, 9, 9, 9, 9,10,11, - 11,11,11,11,11, 9,10, 9, 9, 9, 9, 9, 9, 9, 9,11, - 11,10,11,11,11,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9, - 10,11,10,11,11,11,11,11,11, 9, 9, 9, 9, 9, 9, 9, - 9, -}; - -static const static_codebook _44c0_sm_p8_2 = { - 2, 289, - (char *)_vq_lengthlist__44c0_sm_p8_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c0_sm_p8_2, - 0 -}; - -static const char _huff_lengthlist__44c0_sm_short[] = { - 6, 6,12,13,13,14,16,17,17, 4, 2, 5, 8, 7, 9,12, - 15,15, 9, 4, 5, 9, 7, 9,12,16,18,11, 6, 7, 4, 6, - 8,11,14,18,10, 5, 6, 5, 5, 7,10,14,17,10, 5, 7, - 7, 6, 7,10,13,16,11, 5, 7, 7, 7, 8,10,12,15,13, - 6, 7, 5, 5, 7, 9,12,13,16, 8, 9, 6, 6, 7, 9,10, - 12, -}; - -static const static_codebook _huff_book__44c0_sm_short = { - 2, 81, - (char *)_huff_lengthlist__44c0_sm_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c1_s_long[] = { - 5, 5, 9,10, 9, 9,10,11,12, 5, 1, 5, 6, 6, 7,10, - 12,14, 9, 5, 6, 8, 8,10,12,14,14,10, 5, 8, 5, 6, - 8,11,13,14, 9, 5, 7, 6, 6, 8,10,12,11, 9, 7, 9, - 7, 6, 6, 7,10,10,10, 9,12, 9, 8, 7, 7,10,12,11, - 11,13,12,10, 9, 8, 9,11,11,14,15,15,13,11, 9, 9, - 11, -}; - -static const static_codebook _huff_book__44c1_s_long = { - 2, 81, - (char *)_huff_lengthlist__44c1_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c1_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c1_s_p1_0[] = { - 2, 4, 4, 0, 0, 0, 0, 0, 0, 5, 7, 6, 0, 0, 0, 0, - 0, 0, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, - 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 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, 7, 7, 0, 0, 0, 0, - 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, - 0, 0, 0, 8, 9,10, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 8, 8, 0, 0, - 0, 0, 0, 0, 8, 9, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7, 7, 0, 0, 0, 0, 0, 0, 7, 8, 8, 0, 0, - 0, 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 8, 8, 0, 0, 0, 0, 0, 0, 8,10, 9, 0, - 0, 0, 0, 0, 0, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, - 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c1_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44c1_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c1_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44c1_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c1_s_p2_0[] = { - 2, 3, 4, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 4, 5, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 8, 8, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 6, 6, 8, 8, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c1_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c1_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c1_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44c1_s_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c1_s_p3_0[] = { - 1, 3, 2, 7, 7, 0, 0, 0, 0, 0,13,13, 6, 6, 0, 0, - 0, 0, 0,12, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 8, 9, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, - 0, 0,11,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c1_s_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44c1_s_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c1_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44c1_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c1_s_p4_0[] = { - 1, 3, 3, 6, 5, 6, 6, 8, 8, 0, 0, 0, 7, 7, 7, 7, - 9, 9, 0, 0, 0, 7, 7, 7, 7, 9, 9, 0, 0, 0, 7, 7, - 8, 8,10,10, 0, 0, 0, 7, 7, 8, 8,10,10, 0, 0, 0, - 9, 9, 8, 8,10,10, 0, 0, 0, 8, 8, 8, 8,10,10, 0, - 0, 0,10,10, 9, 9,11,11, 0, 0, 0, 0, 0, 9, 9,11, - 11, -}; - -static const static_codebook _44c1_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44c1_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c1_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44c1_s_p5_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c1_s_p5_0[] = { - 1, 4, 3, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10,10,11, - 11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10,10, - 11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10, - 10,11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,12,11, 0, 0, 0, 8, 8, 9, 9, 9,10,10,10, - 10,10,11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10, 9,10, - 10,10,10,11,11,12,12, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 9, 9, - 10,10,10,11,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, - 9,10,10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, - 10,10,10,10,11,11,12,12,12,12,13,13, 0, 0, 0, 0, - 0, 0, 0,10,10,11,11,12,12,12,12,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,12,12,12,12,13,13,13,13, 0, 0, - 0, 0, 0, 0, 0,11,11,11,11,12,12,13,13,13,13, 0, - 0, 0, 0, 0, 0, 0,12,12,12,12,12,12,13,13,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,14, - 14, -}; - -static const static_codebook _44c1_s_p5_0 = { - 2, 289, - (char *)_vq_lengthlist__44c1_s_p5_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c1_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44c1_s_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c1_s_p6_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7,10, 9, 9,11, - 9, 9, 4, 7, 7,10, 9, 9,11, 9, 9, 6,10,10,11,11, - 11,11,10,10, 6, 9, 9,11,10,10,11,10,10, 6, 9, 9, - 11,10,11,11,10,10, 7,11,10,11,11,11,12,11,11, 7, - 9, 9,11,10,10,11,11,10, 6, 9, 9,10,10,10,12,10, - 11, -}; - -static const static_codebook _44c1_s_p6_0 = { - 4, 81, - (char *)_vq_lengthlist__44c1_s_p6_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c1_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44c1_s_p6_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c1_s_p6_1[] = { - 2, 3, 3, 6, 6, 7, 7, 7, 7, 8, 8,10,10,10, 6, 6, - 7, 7, 8, 8, 8, 8,10,10,10, 6, 6, 7, 7, 8, 8, 8, - 8,10,10,10, 7, 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, - 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, - 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 8, 8,10,10,10,10,10, 8, 8, 8, - 8, 8, 8,10,10,10,10,10, 9, 9, 8, 8, 8, 8,10,10, - 10,10,10, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44c1_s_p6_1 = { - 2, 121, - (char *)_vq_lengthlist__44c1_s_p6_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c1_s_p6_1, - 0 -}; - -static const long _vq_quantlist__44c1_s_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c1_s_p7_0[] = { - 1, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8,10, 9, 7, 5, 6, - 7, 7, 8, 8, 8, 8, 9, 9,10,10, 7, 5, 5, 7, 7, 8, - 8, 8, 8, 9, 9,10,10, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,10, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9, 9,10,10,10,11,11,11,11, 0,13, - 13, 9, 9, 9, 9,10,10,11,11,11,11, 0, 0, 0,10,10, - 10,10,11,11,12,11,12,12, 0, 0, 0,10,10,10, 9,11, - 11,12,11,13,12, 0, 0, 0,13,13,10,10,11,11,12,12, - 13,13, 0, 0, 0,14,14,10,10,11,11,12,12,13,13, 0, - 0, 0, 0, 0,11,12,11,11,12,12,14,13, 0, 0, 0, 0, - 0,12,11,11,11,13,10,14,13, -}; - -static const static_codebook _44c1_s_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44c1_s_p7_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c1_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44c1_s_p7_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c1_s_p7_1[] = { - 2, 3, 3, 5, 5, 6, 6, 6, 5, 5, 6, 6, 6, 5, 5, 6, - 6, 6, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c1_s_p7_1 = { - 2, 25, - (char *)_vq_lengthlist__44c1_s_p7_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c1_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44c1_s_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c1_s_p8_0[] = { - 1, 4, 3,10,10,10,10,10,10,10,10,10,10, 4, 8, 6, - 10,10,10,10,10,10,10,10,10,10, 4, 8, 7,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _44c1_s_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__44c1_s_p8_0, - 1, -514541568, 1627103232, 4, 0, - (long *)_vq_quantlist__44c1_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44c1_s_p8_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c1_s_p8_1[] = { - 1, 4, 4, 6, 5, 7, 7, 9, 9,10,10,12,12, 6, 5, 5, - 7, 7, 8, 8,10,10,12,11,12,12, 6, 5, 5, 7, 7, 8, - 8,10,10,11,11,12,12,15, 7, 7, 8, 8, 9, 9,11,11, - 12,12,13,12,15, 8, 8, 8, 7, 9, 9,10,10,12,12,13, - 13,16,11,10, 8, 8,10,10,11,11,12,12,13,13,16,11, - 11, 9, 8,11,10,11,11,12,12,13,12,16,16,16,10,11, - 10,11,12,12,12,12,13,13,16,16,16,11, 9,11, 9,14, - 12,12,12,13,13,16,16,16,12,14,11,12,12,12,13,13, - 14,13,16,16,16,15,13,12,10,13,10,13,14,13,13,16, - 16,16,16,16,13,14,12,13,13,12,13,13,16,16,16,16, - 16,13,12,12,11,14,12,15,13, -}; - -static const static_codebook _44c1_s_p8_1 = { - 2, 169, - (char *)_vq_lengthlist__44c1_s_p8_1, - 1, -522616832, 1620115456, 4, 0, - (long *)_vq_quantlist__44c1_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44c1_s_p8_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c1_s_p8_2[] = { - 2, 4, 4, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, - 8,10,10,10, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9,10,10,10, 7, 7, 8, 7, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9,10,10,10, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, - 9,10, 9, 9,10,10,10, 7, 7, 8, 8, 9, 8, 9, 9, 9, - 9,10, 9, 9,10,10,11,11, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9,10, 9, 9,10,10,10,10, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9,10,10,11,11,11, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10,10,11,11,11, 8, 8, 9, - 9, 9, 9,10, 9, 9, 9, 9, 9,11,11,11,11,11, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11,10,10,11,11, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,11,10,11,11, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10, 9,10,10,11,11, - 11,11,11, 9, 9, 9,10, 9, 9, 9, 9, 9, 9,10,11,11, - 11,11,11,11,10,10,10,10, 9, 9, 9, 9, 9, 9,10,11, - 11,11,11,11,11, 9,10, 9, 9, 9, 9,10, 9, 9, 9,11, - 11,11,11,11,11,11,10,10, 9, 9, 9, 9, 9, 9,10, 9, - 11,11,10,11,11,11,11,10,11, 9, 9, 9, 9, 9, 9, 9, - 9, -}; - -static const static_codebook _44c1_s_p8_2 = { - 2, 289, - (char *)_vq_lengthlist__44c1_s_p8_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c1_s_p8_2, - 0 -}; - -static const char _huff_lengthlist__44c1_s_short[] = { - 6, 8,13,12,13,14,15,16,16, 4, 2, 4, 7, 6, 8,11, - 13,15,10, 4, 4, 8, 6, 8,11,14,17,11, 5, 6, 5, 6, - 8,12,14,17,11, 5, 5, 6, 5, 7,10,13,16,12, 6, 7, - 8, 7, 8,10,13,15,13, 8, 8, 7, 7, 8,10,12,15,15, - 7, 7, 5, 5, 7, 9,12,14,15, 8, 8, 6, 6, 7, 8,10, - 11, -}; - -static const static_codebook _huff_book__44c1_s_short = { - 2, 81, - (char *)_huff_lengthlist__44c1_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44c1_sm_long[] = { - 5, 4, 8,10, 9, 9,10,11,12, 4, 2, 5, 6, 6, 8,10, - 11,13, 8, 4, 6, 8, 7, 9,12,12,14,10, 6, 8, 4, 5, - 6, 9,11,12, 9, 5, 6, 5, 5, 6, 9,11,11, 9, 7, 9, - 6, 5, 5, 7,10,10,10, 9,11, 8, 7, 6, 7, 9,11,11, - 12,13,10,10, 9, 8, 9,11,11,15,15,12,13,11, 9,10, - 11, -}; - -static const static_codebook _huff_book__44c1_sm_long = { - 2, 81, - (char *)_huff_lengthlist__44c1_sm_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c1_sm_p1_0[] = { - 1, 5, 5, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 8, 7, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 7, 9, 8, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 7, 0, 0, 0, 0, - 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, - 0, 0, 0, 9, 9,10, 0, 0, 0, 0, 0, 0, 9,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 8,10, 9, 0, 0, 0, 0, 0, 0, 9,10,10, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 7, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, - 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,10,10, 0, - 0, 0, 0, 0, 0, 8, 9,10, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,10,10, - 0, 0, 0, 0, 0, 0, 9,10, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c1_sm_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44c1_sm_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44c1_sm_p1_0, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c1_sm_p2_0[] = { - 2, 3, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 6, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44c1_sm_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44c1_sm_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c1_sm_p2_0, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c1_sm_p3_0[] = { - 1, 3, 3, 7, 7, 0, 0, 0, 0, 0, 5, 5, 6, 6, 0, 0, - 0, 0, 0, 5, 5, 7, 7, 0, 0, 0, 0, 0, 7, 7, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 8, 9, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44c1_sm_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44c1_sm_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c1_sm_p3_0, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44c1_sm_p4_0[] = { - 1, 3, 3, 6, 6, 7, 7, 9, 9, 0, 6, 6, 7, 7, 8, 8, - 9, 9, 0, 6, 6, 7, 7, 8, 8, 9, 9, 0, 7, 7, 8, 8, - 8, 8,10,10, 0, 0, 0, 8, 8, 8, 8,10,10, 0, 0, 0, - 8, 8, 9, 9,11,11, 0, 0, 0, 9, 9, 9, 9,11,11, 0, - 0, 0,10,10,10,10,11,11, 0, 0, 0, 0, 0, 9, 9,11, - 11, -}; - -static const static_codebook _44c1_sm_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44c1_sm_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44c1_sm_p4_0, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p5_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c1_sm_p5_0[] = { - 2, 3, 3, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10,10,11, - 11, 0, 5, 5, 6, 6, 8, 8, 9, 9, 9, 9,10,10,10,10, - 11,11, 0, 5, 5, 6, 6, 8, 8, 9, 9, 9, 9,10,10,10, - 10,11,11, 0, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,12,12, 0, 0, 0, 8, 8, 8, 8, 9, 9,10,10, - 10,11,11,11,12,12, 0, 0, 0, 8, 8, 8, 8, 9, 9,10, - 10,10,10,11,11,12,12, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9, - 9, 9,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, - 9, 9, 9,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, - 9, 9,10,10,11,11,12,12,12,12,13,13, 0, 0, 0, 0, - 0, 0, 0,10,10,11,11,12,12,12,12,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,11,11,12,12,13,13,13,13, 0, 0, - 0, 0, 0, 0, 0,11,11,11,11,12,12,13,13,13,13, 0, - 0, 0, 0, 0, 0, 0,11,11,12,12,12,12,13,13,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,12,12,13,13,14, - 14, -}; - -static const static_codebook _44c1_sm_p5_0 = { - 2, 289, - (char *)_vq_lengthlist__44c1_sm_p5_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c1_sm_p5_0, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44c1_sm_p6_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 7,10, 9, 9,11, - 9, 9, 4, 7, 7,10, 9, 9,11, 9, 9, 7,10,10,10,11, - 11,11,10,10, 6, 9, 9,11,11,10,11,10,10, 6, 9, 9, - 11,10,11,11,10,10, 7,11,11,11,11,11,11,11,11, 6, - 9, 9,11,10,10,11,11,10, 6, 9, 9,10,10,10,11,10, - 11, -}; - -static const static_codebook _44c1_sm_p6_0 = { - 4, 81, - (char *)_vq_lengthlist__44c1_sm_p6_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44c1_sm_p6_0, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p6_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44c1_sm_p6_1[] = { - 2, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8,10, 5, 5, 6, 6, - 7, 7, 8, 8, 8, 8,10, 5, 5, 6, 6, 7, 7, 8, 8, 8, - 8,10, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, 7, - 7, 7, 7, 8, 8, 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, - 8, 8,10,10,10, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 9, 8,10,10,10,10,10, 8, 8, 8, - 8, 8, 8,10,10,10,10,10, 9, 9, 8, 8, 8, 8,10,10, - 10,10,10, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44c1_sm_p6_1 = { - 2, 121, - (char *)_vq_lengthlist__44c1_sm_p6_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44c1_sm_p6_1, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c1_sm_p7_0[] = { - 1, 4, 4, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 7, 5, 5, - 7, 7, 8, 8, 8, 8, 9, 9,10,10, 7, 5, 6, 7, 7, 8, - 8, 8, 8, 9, 9,11,10, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9,10,10,10,10,11,11,11,11, 0,13, - 13, 9, 9, 9, 9,10,10,11,11,12,12, 0, 0, 0, 9,10, - 9,10,11,11,12,11,13,12, 0, 0, 0,10,10, 9, 9,11, - 11,12,12,13,12, 0, 0, 0,13,13,10,10,11,11,12,12, - 13,13, 0, 0, 0,14,14,10,10,11,11,12,12,13,13, 0, - 0, 0, 0, 0,11,12,11,11,12,13,14,13, 0, 0, 0, 0, - 0,12,12,11,11,13,12,14,13, -}; - -static const static_codebook _44c1_sm_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44c1_sm_p7_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44c1_sm_p7_0, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p7_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44c1_sm_p7_1[] = { - 2, 4, 4, 4, 5, 6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 6, - 5, 5, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44c1_sm_p7_1 = { - 2, 25, - (char *)_vq_lengthlist__44c1_sm_p7_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44c1_sm_p7_1, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p8_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c1_sm_p8_0[] = { - 1, 3, 3,13,13,13,13,13,13,13,13,13,13, 3, 6, 6, - 13,13,13,13,13,13,13,13,13,13, 4, 8, 7,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13, -}; - -static const static_codebook _44c1_sm_p8_0 = { - 2, 169, - (char *)_vq_lengthlist__44c1_sm_p8_0, - 1, -514541568, 1627103232, 4, 0, - (long *)_vq_quantlist__44c1_sm_p8_0, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p8_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44c1_sm_p8_1[] = { - 1, 4, 4, 6, 6, 7, 7, 9, 9,10,11,12,12, 6, 5, 5, - 7, 7, 8, 7,10,10,11,11,12,12, 6, 5, 5, 7, 7, 8, - 8,10,10,11,11,12,12,16, 7, 7, 8, 8, 9, 9,11,11, - 12,12,13,13,17, 7, 7, 8, 7, 9, 9,11,10,12,12,13, - 13,19,11,10, 8, 8,10,10,11,11,12,12,13,13,19,11, - 11, 9, 7,11,10,11,11,12,12,13,12,19,19,19,10,10, - 10,10,11,12,12,12,13,14,18,19,19,11, 9,11, 9,13, - 12,12,12,13,13,19,20,19,13,15,11,11,12,12,13,13, - 14,13,18,19,20,15,13,12,10,13,10,13,13,13,14,20, - 20,20,20,20,13,14,12,12,13,12,13,13,20,20,20,20, - 20,13,12,12,12,14,12,14,13, -}; - -static const static_codebook _44c1_sm_p8_1 = { - 2, 169, - (char *)_vq_lengthlist__44c1_sm_p8_1, - 1, -522616832, 1620115456, 4, 0, - (long *)_vq_quantlist__44c1_sm_p8_1, - 0 -}; - -static const long _vq_quantlist__44c1_sm_p8_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44c1_sm_p8_2[] = { - 2, 5, 5, 6, 6, 7, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, - 8,10, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9,10, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9,10, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 7, 7, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9,10,11,11, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9,10,10, 9,10,10,10,10, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9,10,10,11,10,10, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9,10, 9,10,10,10,11,11, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,11,11,11,11,11, 9, 9, - 9, 9, 9, 9, 9, 9,10, 9,10, 9,11,11,11,11,11, 9, - 8, 9, 9, 9, 9, 9, 9, 9,10,10, 9,11,11,10,11,11, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10, 9,11,11,11,11, - 11,11,11, 9, 9,10, 9, 9, 9, 9,10, 9,10,10,11,10, - 11,11,11,11, 9,10,10,10, 9, 9, 9, 9, 9, 9,10,11, - 11,11,11,11,11, 9, 9, 9, 9, 9, 9, 9, 9,10, 9,11, - 11,10,11,11,11,11,10,10, 9, 9, 9, 9, 9, 9,10, 9, - 10,11,10,11,11,11,11,11,11, 9, 9,10, 9, 9, 9, 9, - 9, -}; - -static const static_codebook _44c1_sm_p8_2 = { - 2, 289, - (char *)_vq_lengthlist__44c1_sm_p8_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44c1_sm_p8_2, - 0 -}; - -static const char _huff_lengthlist__44c1_sm_short[] = { - 4, 7,13,14,14,15,16,18,18, 4, 2, 5, 8, 7, 9,12, - 15,15,10, 4, 5,10, 6, 8,11,15,17,12, 5, 7, 5, 6, - 8,11,14,17,11, 5, 6, 6, 5, 6, 9,13,17,12, 6, 7, - 6, 5, 6, 8,12,14,14, 7, 8, 6, 6, 7, 9,11,14,14, - 8, 9, 6, 5, 6, 9,11,13,16,10,10, 7, 6, 7, 8,10, - 11, -}; - -static const static_codebook _huff_book__44c1_sm_short = { - 2, 81, - (char *)_huff_lengthlist__44c1_sm_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44cn1_s_long[] = { - 4, 4, 7, 8, 7, 8,10,12,17, 3, 1, 6, 6, 7, 8,10, - 12,15, 7, 6, 9, 9, 9,11,12,14,17, 8, 6, 9, 6, 7, - 9,11,13,17, 7, 6, 9, 7, 7, 8, 9,12,15, 8, 8,10, - 8, 7, 7, 7,10,14, 9,10,12,10, 8, 8, 8,10,14,11, - 13,15,13,12,11,11,12,16,17,18,18,19,20,18,16,16, - 20, -}; - -static const static_codebook _huff_book__44cn1_s_long = { - 2, 81, - (char *)_huff_lengthlist__44cn1_s_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44cn1_s_p1_0[] = { - 1, 4, 4, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, - 0, 0, 0, 7, 9,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 7,10, 9, 0, 0, - 0, 0, 0, 0, 8,10, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 8, 0, 0, 0, 0, - 0, 0, 8,10,10, 0, 0, 0, 0, 0, 0, 8, 9,10, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,10,10, 0, 0, 0, - 0, 0, 0, 9, 9,11, 0, 0, 0, 0, 0, 0,10,11,11, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,10,10, 0, 0, - 0, 0, 0, 0, 9,11, 9, 0, 0, 0, 0, 0, 0,10,11,11, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 8,10,10, 0, 0, - 0, 0, 0, 0, 8,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7,10,10, 0, 0, 0, 0, 0, 0,10,11,11, 0, - 0, 0, 0, 0, 0, 9, 9,11, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7,10,10, 0, 0, 0, 0, 0, 0,10,11,11, - 0, 0, 0, 0, 0, 0, 9,11, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44cn1_s_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44cn1_s_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44cn1_s_p1_0, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44cn1_s_p2_0[] = { - 1, 4, 4, 7, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 5, 7, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 5, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 7, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 7, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44cn1_s_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44cn1_s_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44cn1_s_p2_0, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44cn1_s_p3_0[] = { - 1, 2, 3, 7, 7, 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, - 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 7, 7, - 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, - 9, 8, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, - 0, 0,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44cn1_s_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44cn1_s_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44cn1_s_p3_0, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44cn1_s_p4_0[] = { - 1, 3, 3, 6, 6, 6, 6, 8, 8, 0, 0, 0, 6, 6, 7, 7, - 9, 9, 0, 0, 0, 6, 6, 7, 7, 9, 9, 0, 0, 0, 7, 7, - 8, 8,10,10, 0, 0, 0, 7, 7, 8, 8,10,10, 0, 0, 0, - 9, 9, 9, 9,10,10, 0, 0, 0, 9, 9, 9, 9,10,10, 0, - 0, 0,10,10,10,10,11,11, 0, 0, 0, 0, 0,10,10,11, - 11, -}; - -static const static_codebook _44cn1_s_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44cn1_s_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44cn1_s_p4_0, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p5_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44cn1_s_p5_0[] = { - 1, 4, 3, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10,10,10, - 10, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10,10, - 11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10,10, - 10,11,11, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,11,12, 0, 0, 0, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,11,11, 0, 0, 0, 8, 8, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12, 0, 0, 0, 8, 8, 9, 9, 9, 9,10, - 10,10,11,11,11,12,12, 0, 0, 0, 9, 9,10, 9,10,10, - 10,10,11,11,11,11,12,12, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,12,12,12,12, 0, 0, 0, 0, 0, 9, 9, - 10,10,10,11,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, - 9,10,10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, - 10,10,11,10,11,11,11,12,13,12,13,13, 0, 0, 0, 0, - 0, 0, 0,11,10,11,11,12,12,12,12,13,13, 0, 0, 0, - 0, 0, 0, 0,11,11,12,12,12,12,13,13,13,14, 0, 0, - 0, 0, 0, 0, 0,11,11,12,12,12,12,13,13,13,14, 0, - 0, 0, 0, 0, 0, 0,12,12,12,13,13,13,13,13,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,13,12,13,13,14, - 14, -}; - -static const static_codebook _44cn1_s_p5_0 = { - 2, 289, - (char *)_vq_lengthlist__44cn1_s_p5_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44cn1_s_p5_0, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44cn1_s_p6_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 6, 6,10, 9, 9,11, - 9, 9, 4, 6, 6,10, 9, 9,10, 9, 9, 7,10,10,11,11, - 11,12,11,11, 7, 9, 9,11,11,10,11,10,10, 7, 9, 9, - 11,10,11,11,10,10, 7,10,10,11,11,11,12,11,11, 7, - 9, 9,11,10,10,11,10,10, 7, 9, 9,11,10,10,11,10, - 10, -}; - -static const static_codebook _44cn1_s_p6_0 = { - 4, 81, - (char *)_vq_lengthlist__44cn1_s_p6_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44cn1_s_p6_0, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p6_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44cn1_s_p6_1[] = { - 1, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8,10,10,10, 7, 6, - 8, 8, 8, 8, 8, 8,10,10,10, 7, 6, 7, 7, 8, 8, 8, - 8,10,10,10, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, 7, - 7, 8, 8, 8, 8, 8, 8,10,10,10, 8, 8, 8, 8, 9, 9, - 9, 9,10,10,10, 8, 8, 8, 8, 9, 9, 9, 9,10,10,10, - 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10, 9, 9, 9, - 9, 9, 9,10,10,10,10,10, 9, 9, 9, 9, 9, 9,10,10, - 10,10,10, 9, 9, 9, 9, 9, 9, -}; - -static const static_codebook _44cn1_s_p6_1 = { - 2, 121, - (char *)_vq_lengthlist__44cn1_s_p6_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44cn1_s_p6_1, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44cn1_s_p7_0[] = { - 1, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10, 6, 5, 5, - 7, 7, 8, 8, 8, 8, 9, 9,11,11, 7, 5, 5, 7, 7, 8, - 8, 8, 8, 9,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9, 9,10,10,10,11,11,11,12, 0,13, - 13, 9, 9, 9, 9,10,10,11,11,11,12, 0, 0, 0,10,10, - 10,10,11,11,12,12,12,13, 0, 0, 0,10,10,10,10,11, - 11,12,12,13,12, 0, 0, 0,14,14,11,10,11,12,12,13, - 13,14, 0, 0, 0,15,15,11,11,12,11,12,12,14,13, 0, - 0, 0, 0, 0,12,12,12,12,13,13,14,14, 0, 0, 0, 0, - 0,13,13,12,12,13,13,13,14, -}; - -static const static_codebook _44cn1_s_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44cn1_s_p7_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44cn1_s_p7_0, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p7_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44cn1_s_p7_1[] = { - 2, 3, 3, 5, 5, 6, 6, 6, 5, 5, 6, 6, 6, 5, 5, 6, - 6, 6, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44cn1_s_p7_1 = { - 2, 25, - (char *)_vq_lengthlist__44cn1_s_p7_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44cn1_s_p7_1, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p8_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44cn1_s_p8_0[] = { - 1, 7, 7,11,11, 8,11,11,11,11, 4,11, 3,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,10,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,10,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11, 7,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,10,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11, 8,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12, -}; - -static const static_codebook _44cn1_s_p8_0 = { - 4, 625, - (char *)_vq_lengthlist__44cn1_s_p8_0, - 1, -518283264, 1627103232, 3, 0, - (long *)_vq_quantlist__44cn1_s_p8_0, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p8_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44cn1_s_p8_1[] = { - 1, 4, 4, 6, 6, 8, 8, 9,10,10,11,11,11, 6, 5, 5, - 7, 7, 8, 8, 9,10, 9,11,11,12, 5, 5, 5, 7, 7, 8, - 9,10,10,12,12,14,13,15, 7, 7, 8, 8, 9,10,11,11, - 10,12,10,11,15, 7, 8, 8, 8, 9, 9,11,11,13,12,12, - 13,15,10,10, 8, 8,10,10,12,12,11,14,10,10,15,11, - 11, 8, 8,10,10,12,13,13,14,15,13,15,15,15,10,10, - 10,10,12,12,13,12,13,10,15,15,15,10,10,11,10,13, - 11,13,13,15,13,15,15,15,13,13,10,11,11,11,12,10, - 14,11,15,15,14,14,13,10,10,12,11,13,13,14,14,15, - 15,15,15,15,11,11,11,11,12,11,15,12,15,15,15,15, - 15,12,12,11,11,14,12,13,14, -}; - -static const static_codebook _44cn1_s_p8_1 = { - 2, 169, - (char *)_vq_lengthlist__44cn1_s_p8_1, - 1, -522616832, 1620115456, 4, 0, - (long *)_vq_quantlist__44cn1_s_p8_1, - 0 -}; - -static const long _vq_quantlist__44cn1_s_p8_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44cn1_s_p8_2[] = { - 3, 4, 3, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, - 9,10,11,11, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9,10,10,10, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9,10,10,10, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, - 9, 9,10, 9,10,11,10, 7, 6, 7, 7, 8, 8, 9, 9, 9, - 9, 9, 9, 9,10,10,10,11, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10, 7, 7, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9,10,11,11,11, 8, 8, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9,11,10,10,11,11, 8, 8, 8, - 9, 9, 9, 9, 9, 9,10, 9,10,10,10,10,11,11, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11,11,10,11,11, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,11,10,11,11, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11,10,10,11, - 11,11,11, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,11,11, - 10,11,11,11, 9,10,10, 9, 9, 9, 9, 9, 9, 9,10,11, - 11,11,11,11,11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11, - 11,11,11,11,11,11,10,10, 9, 9, 9, 9, 9, 9, 9, 9, - 11,11,11,10,11,11,11,11,11, 9, 9, 9,10, 9, 9, 9, - 9, -}; - -static const static_codebook _44cn1_s_p8_2 = { - 2, 289, - (char *)_vq_lengthlist__44cn1_s_p8_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44cn1_s_p8_2, - 0 -}; - -static const char _huff_lengthlist__44cn1_s_short[] = { - 10, 9,12,15,12,13,16,14,16, 7, 1, 5,14, 7,10,13, - 16,16, 9, 4, 6,16, 8,11,16,16,16,14, 4, 7,16, 9, - 12,14,16,16,10, 5, 7,14, 9,12,14,15,15,13, 8, 9, - 14,10,12,13,14,15,13, 9, 9, 7, 6, 8,11,12,12,14, - 8, 8, 5, 4, 5, 8,11,12,16,10,10, 6, 5, 6, 8, 9, - 10, -}; - -static const static_codebook _huff_book__44cn1_s_short = { - 2, 81, - (char *)_huff_lengthlist__44cn1_s_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44cn1_sm_long[] = { - 3, 3, 8, 8, 8, 8,10,12,14, 3, 2, 6, 7, 7, 8,10, - 12,16, 7, 6, 7, 9, 8,10,12,14,16, 8, 6, 8, 4, 5, - 7, 9,11,13, 7, 6, 8, 5, 6, 7, 9,11,14, 8, 8,10, - 7, 7, 6, 8,10,13, 9,11,12, 9, 9, 7, 8,10,12,10, - 13,15,11,11,10, 9,10,13,13,16,17,14,15,14,13,14, - 17, -}; - -static const static_codebook _huff_book__44cn1_sm_long = { - 2, 81, - (char *)_huff_lengthlist__44cn1_sm_long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44cn1_sm_p1_0[] = { - 1, 4, 5, 0, 0, 0, 0, 0, 0, 5, 7, 7, 0, 0, 0, 0, - 0, 0, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, - 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 7, 9, 8, 0, 0, - 0, 0, 0, 0, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 8, 0, 0, 0, 0, - 0, 0, 8,10, 9, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,10, 9, 0, 0, 0, - 0, 0, 0, 9, 9,10, 0, 0, 0, 0, 0, 0, 9,10,10, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 9, 0, 0, - 0, 0, 0, 0, 8,10, 9, 0, 0, 0, 0, 0, 0, 9,10,10, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 8, 8, 0, 0, 0, 0, 0, 0, 8, 9, 9, 0, 0, - 0, 0, 0, 0, 8, 9,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, 0, 9,10,10, 0, - 0, 0, 0, 0, 0, 8, 9,10, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 9,10, 0, 0, 0, 0, 0, 0, 9,10,10, - 0, 0, 0, 0, 0, 0, 9,10, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44cn1_sm_p1_0 = { - 8, 6561, - (char *)_vq_lengthlist__44cn1_sm_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44cn1_sm_p1_0, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44cn1_sm_p2_0[] = { - 1, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 5, 7, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 5, 5, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 7, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 7, 7, 7, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 static_codebook _44cn1_sm_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44cn1_sm_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44cn1_sm_p2_0, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44cn1_sm_p3_0[] = { - 1, 3, 4, 7, 7, 0, 0, 0, 0, 0, 4, 4, 7, 7, 0, 0, - 0, 0, 0, 4, 5, 7, 7, 0, 0, 0, 0, 0, 6, 7, 8, 8, - 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 0, 0, 0, 0, 0, 0, 0,10, 9, 0, 0, 0, 0, 0, - 0, 0,11,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const static_codebook _44cn1_sm_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44cn1_sm_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44cn1_sm_p3_0, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p4_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44cn1_sm_p4_0[] = { - 1, 4, 3, 6, 6, 7, 7, 9, 9, 0, 5, 5, 7, 7, 8, 7, - 9, 9, 0, 5, 5, 7, 7, 8, 8, 9, 9, 0, 7, 7, 8, 8, - 8, 8,10,10, 0, 0, 0, 8, 8, 8, 8,10,10, 0, 0, 0, - 9, 9, 9, 9,10,10, 0, 0, 0, 9, 9, 9, 9,10,10, 0, - 0, 0,10,10,10,10,11,11, 0, 0, 0, 0, 0,10,10,11, - 11, -}; - -static const static_codebook _44cn1_sm_p4_0 = { - 2, 81, - (char *)_vq_lengthlist__44cn1_sm_p4_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44cn1_sm_p4_0, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p5_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44cn1_sm_p5_0[] = { - 1, 4, 4, 6, 6, 8, 8, 9, 9, 8, 8, 9, 9,10,10,11, - 11, 0, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9,10,10,11,11, - 12,12, 0, 6, 5, 7, 7, 8, 8, 9, 9, 9, 9,10,10,11, - 11,12,12, 0, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,12,12, 0, 0, 0, 7, 7, 8, 8, 9, 9,10,10,11, - 11,11,11,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10,10, - 11,11,12,12,12,12, 0, 0, 0, 8, 8, 9, 9,10,10,10, - 10,11,11,12,12,12,12, 0, 0, 0, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9,10, - 10,10,10,11,11,12,12,13,13, 0, 0, 0, 0, 0, 9, 9, - 10,10,11,11,12,12,13,13,13,13, 0, 0, 0, 0, 0, 9, - 9,10,10,11,11,12,12,12,13,13,13, 0, 0, 0, 0, 0, - 10,10,11,11,11,11,12,12,13,13,14,14, 0, 0, 0, 0, - 0, 0, 0,11,11,11,11,12,12,13,13,14,14, 0, 0, 0, - 0, 0, 0, 0,11,11,12,12,13,13,13,13,14,14, 0, 0, - 0, 0, 0, 0, 0,11,11,12,12,13,13,13,13,14,14, 0, - 0, 0, 0, 0, 0, 0,12,12,12,13,13,13,14,14,14,14, - 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,13,13,14,14,14, - 14, -}; - -static const static_codebook _44cn1_sm_p5_0 = { - 2, 289, - (char *)_vq_lengthlist__44cn1_sm_p5_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44cn1_sm_p5_0, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p6_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44cn1_sm_p6_0[] = { - 1, 4, 4, 7, 6, 6, 7, 6, 6, 4, 7, 6,10, 9, 9,11, - 9, 9, 4, 6, 7,10, 9, 9,11, 9, 9, 7,10,10,10,11, - 11,11,11,10, 6, 9, 9,11,10,10,11,10,10, 6, 9, 9, - 11,10,11,11,10,10, 7,11,11,11,11,11,12,11,11, 7, - 9, 9,11,10,10,12,10,10, 7, 9, 9,11,10,10,11,10, - 10, -}; - -static const static_codebook _44cn1_sm_p6_0 = { - 4, 81, - (char *)_vq_lengthlist__44cn1_sm_p6_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44cn1_sm_p6_0, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p6_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44cn1_sm_p6_1[] = { - 2, 4, 4, 5, 5, 7, 7, 7, 7, 8, 8,10, 5, 5, 6, 6, - 7, 7, 8, 8, 8, 8,10, 5, 5, 6, 6, 7, 7, 8, 8, 8, - 8,10, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8,10,10,10, 7, - 7, 7, 7, 8, 8, 8, 8,10,10,10, 8, 8, 8, 8, 8, 8, - 8, 8,10,10,10, 8, 8, 8, 8, 8, 8, 8, 8,10,10,10, - 8, 8, 8, 8, 8, 8, 9, 9,10,10,10,10,10, 8, 8, 8, - 8, 9, 9,10,10,10,10,10, 9, 9, 9, 9, 8, 9,10,10, - 10,10,10, 8, 9, 8, 8, 9, 8, -}; - -static const static_codebook _44cn1_sm_p6_1 = { - 2, 121, - (char *)_vq_lengthlist__44cn1_sm_p6_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44cn1_sm_p6_1, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44cn1_sm_p7_0[] = { - 1, 4, 4, 6, 6, 7, 7, 7, 7, 9, 9,10,10, 7, 5, 5, - 7, 7, 8, 8, 8, 8,10, 9,11,10, 7, 5, 5, 7, 7, 8, - 8, 8, 8, 9,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,11, 0, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11, - 11, 0,12,12, 9, 9, 9,10,10,10,11,11,12,12, 0,13, - 13, 9, 9, 9, 9,10,10,11,11,12,12, 0, 0, 0,10,10, - 10,10,11,11,12,12,12,13, 0, 0, 0,10,10,10,10,11, - 11,12,12,12,12, 0, 0, 0,14,14,11,11,11,11,12,13, - 13,13, 0, 0, 0,14,14,11,10,11,11,12,12,13,13, 0, - 0, 0, 0, 0,12,12,12,12,13,13,13,14, 0, 0, 0, 0, - 0,13,12,12,12,13,13,13,14, -}; - -static const static_codebook _44cn1_sm_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44cn1_sm_p7_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44cn1_sm_p7_0, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p7_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44cn1_sm_p7_1[] = { - 2, 4, 4, 4, 5, 6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 6, - 5, 5, 5, 5, 6, 6, 6, 5, 5, -}; - -static const static_codebook _44cn1_sm_p7_1 = { - 2, 25, - (char *)_vq_lengthlist__44cn1_sm_p7_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44cn1_sm_p7_1, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p8_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44cn1_sm_p8_0[] = { - 1, 4, 4,12,11,13,13,14,14, 4, 7, 7,11,13,14,14, - 14,14, 3, 8, 3,14,14,14,14,14,14,14,10,12,14,14, - 14,14,14,14,14,14, 5,14, 8,14,14,14,14,14,12,14, - 13,14,14,14,14,14,14,14,13,14,10,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14, -}; - -static const static_codebook _44cn1_sm_p8_0 = { - 2, 81, - (char *)_vq_lengthlist__44cn1_sm_p8_0, - 1, -516186112, 1627103232, 4, 0, - (long *)_vq_quantlist__44cn1_sm_p8_0, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p8_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44cn1_sm_p8_1[] = { - 1, 4, 4, 6, 6, 8, 8, 9, 9,10,11,11,11, 6, 5, 5, - 7, 7, 8, 8,10,10,10,11,11,11, 6, 5, 5, 7, 7, 8, - 8,10,10,11,12,12,12,14, 7, 7, 7, 8, 9, 9,11,11, - 11,12,11,12,17, 7, 7, 8, 7, 9, 9,11,11,12,12,12, - 12,14,11,11, 8, 8,10,10,11,12,12,13,11,12,14,11, - 11, 8, 8,10,10,11,12,12,13,13,12,14,15,14,10,10, - 10,10,11,12,12,12,12,11,14,13,16,10,10,10, 9,12, - 11,12,12,13,14,14,15,14,14,13,10,10,11,11,12,11, - 13,11,14,12,15,13,14,11,10,12,10,12,12,13,13,13, - 13,14,15,15,12,12,11,11,12,11,13,12,14,14,14,14, - 17,12,12,11,10,13,11,13,13, -}; - -static const static_codebook _44cn1_sm_p8_1 = { - 2, 169, - (char *)_vq_lengthlist__44cn1_sm_p8_1, - 1, -522616832, 1620115456, 4, 0, - (long *)_vq_quantlist__44cn1_sm_p8_1, - 0 -}; - -static const long _vq_quantlist__44cn1_sm_p8_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44cn1_sm_p8_2[] = { - 3, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9,10, 6, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9,10, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9,10, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9,10,10,10, 7, 7, 7, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9,10,10,10, 8, 8, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10, 8, 8, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9,11,10,11, 8, 8, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,11,11, 8, 8, 8, - 8, 9, 9, 9, 9, 9, 9, 9, 9,11,10,11,11,11, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,11,10,11,11, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,11,11,10,11,11, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11,10,11,11, - 11,11,11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,11,11, - 11,11,11,11, 9,10,10,10, 9, 9, 9, 9, 9, 9,11,10, - 11,11,11,11,11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11, - 11,11,11,11,11,11,10,10, 9, 9, 9, 9, 9, 9, 9, 9, - 10,11,11,11,11,11,11,11,11, 9, 9, 9, 9, 9, 9, 9, - 9, -}; - -static const static_codebook _44cn1_sm_p8_2 = { - 2, 289, - (char *)_vq_lengthlist__44cn1_sm_p8_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44cn1_sm_p8_2, - 0 -}; - -static const char _huff_lengthlist__44cn1_sm_short[] = { - 5, 6,12,14,12,14,16,17,18, 4, 2, 5,11, 7,10,12, - 14,15, 9, 4, 5,11, 7,10,13,15,18,15, 6, 7, 5, 6, - 8,11,13,16,11, 5, 6, 5, 5, 6, 9,13,15,12, 5, 7, - 6, 5, 6, 9,12,14,12, 6, 7, 8, 6, 7, 9,12,13,14, - 8, 8, 7, 5, 5, 8,10,12,16, 9, 9, 8, 6, 6, 7, 9, - 9, -}; - -static const static_codebook _huff_book__44cn1_sm_short = { - 2, 81, - (char *)_huff_lengthlist__44cn1_sm_short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - diff --git a/Engine/lib/libvorbis/lib/books/floor/Makefile.am b/Engine/lib/libvorbis/lib/books/floor/Makefile.am deleted file mode 100644 index 272ab1a28..000000000 --- a/Engine/lib/libvorbis/lib/books/floor/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = floor_books.h diff --git a/Engine/lib/libvorbis/lib/books/floor/floor_books.h b/Engine/lib/libvorbis/lib/books/floor/floor_books.h deleted file mode 100644 index d26664f76..000000000 --- a/Engine/lib/libvorbis/lib/books/floor/floor_books.h +++ /dev/null @@ -1,1546 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: static codebooks autogenerated by huff/huffbuld - - ********************************************************************/ - -#include "codebook.h" - -static const char _huff_lengthlist_line_256x7_0sub1[] = { - 0, 2, 3, 3, 3, 3, 4, 3, 4, -}; - -static const static_codebook _huff_book_line_256x7_0sub1 = { - 1, 9, - (char *)_huff_lengthlist_line_256x7_0sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x7_0sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 3, 4, 3, 5, 3, - 6, 3, 6, 4, 6, 4, 7, 5, 7, -}; - -static const static_codebook _huff_book_line_256x7_0sub2 = { - 1, 25, - (char *)_huff_lengthlist_line_256x7_0sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x7_0sub3[] = { - 0, 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, 5, 2, 5, 3, 5, 3, - 6, 3, 6, 4, 7, 6, 7, 8, 7, 9, 8, 9, 9, 9,10, 9, - 11,13,11,13,10,10,13,13,13,13,13,13,12,12,12,12, -}; - -static const static_codebook _huff_book_line_256x7_0sub3 = { - 1, 64, - (char *)_huff_lengthlist_line_256x7_0sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x7_1sub1[] = { - 0, 3, 3, 3, 3, 2, 4, 3, 4, -}; - -static const static_codebook _huff_book_line_256x7_1sub1 = { - 1, 9, - (char *)_huff_lengthlist_line_256x7_1sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x7_1sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 4, 3, 4, 4, - 5, 4, 6, 5, 6, 7, 6, 8, 8, -}; - -static const static_codebook _huff_book_line_256x7_1sub2 = { - 1, 25, - (char *)_huff_lengthlist_line_256x7_1sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x7_1sub3[] = { - 0, 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, 2, 4, 3, 6, 3, 7, - 3, 8, 5, 8, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, -}; - -static const static_codebook _huff_book_line_256x7_1sub3 = { - 1, 64, - (char *)_huff_lengthlist_line_256x7_1sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x7_class0[] = { - 7, 5, 5, 9, 9, 6, 6, 9,12, 8, 7, 8,11, 8, 9,15, - 6, 3, 3, 7, 7, 4, 3, 6, 9, 6, 5, 6, 8, 6, 8,15, - 8, 5, 5, 9, 8, 5, 4, 6,10, 7, 5, 5,11, 8, 7,15, - 14,15,13,13,13,13, 8,11,15,10, 7, 6,11, 9,10,15, -}; - -static const static_codebook _huff_book_line_256x7_class0 = { - 1, 64, - (char *)_huff_lengthlist_line_256x7_class0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x7_class1[] = { - 5, 6, 8,15, 6, 9,10,15,10,11,12,15,15,15,15,15, - 4, 6, 7,15, 6, 7, 8,15, 9, 8, 9,15,15,15,15,15, - 6, 8, 9,15, 7, 7, 8,15,10, 9,10,15,15,15,15,15, - 15,13,15,15,15,10,11,15,15,13,13,15,15,15,15,15, - 4, 6, 7,15, 6, 8, 9,15,10,10,12,15,15,15,15,15, - 2, 5, 6,15, 5, 6, 7,15, 8, 6, 7,15,15,15,15,15, - 5, 6, 8,15, 5, 6, 7,15, 9, 6, 7,15,15,15,15,15, - 14,12,13,15,12,10,11,15,15,15,15,15,15,15,15,15, - 7, 8, 9,15, 9,10,10,15,15,14,14,15,15,15,15,15, - 5, 6, 7,15, 7, 8, 9,15,12, 9,10,15,15,15,15,15, - 7, 7, 9,15, 7, 7, 8,15,12, 8, 9,15,15,15,15,15, - 13,13,14,15,12,11,12,15,15,15,15,15,15,15,15,15, - 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, - 13,13,13,15,15,15,15,15,15,15,15,15,15,15,15,15, - 15,12,13,15,15,12,13,15,15,14,15,15,15,15,15,15, - 15,15,15,15,15,15,13,15,15,15,15,15,15,15,15,15, -}; - -static const static_codebook _huff_book_line_256x7_class1 = { - 1, 256, - (char *)_huff_lengthlist_line_256x7_class1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_0sub0[] = { - 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 6, 5, 6, 6, 6, 6, 5, 6, 6, 7, 6, 7, 6, 7, 6, - 7, 6, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 9, 7, 9, 7, - 9, 7, 9, 8, 9, 8,10, 8,10, 8,10, 7,10, 6,10, 8, - 10, 8,11, 7,10, 7,11, 8,11,11,12,12,11,11,12,11, - 13,11,13,11,13,12,15,12,13,13,14,14,14,14,14,15, - 15,15,16,14,17,19,19,18,18,18,18,18,18,18,18,18, - 18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, -}; - -static const static_codebook _huff_book_line_512x17_0sub0 = { - 1, 128, - (char *)_huff_lengthlist_line_512x17_0sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_1sub0[] = { - 2, 4, 5, 4, 5, 4, 5, 4, 5, 5, 5, 5, 5, 5, 6, 5, - 6, 5, 6, 6, 7, 6, 7, 6, 8, 7, 8, 7, 8, 7, 8, 7, -}; - -static const static_codebook _huff_book_line_512x17_1sub0 = { - 1, 32, - (char *)_huff_lengthlist_line_512x17_1sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_1sub1[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 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, 3, 5, 3, 5, 4, 5, 4, 5, 4, 5, 5, 5, 5, 6, 5, - 6, 5, 7, 5, 8, 6, 8, 6, 8, 6, 8, 6, 8, 7, 9, 7, - 9, 7,11, 9,11,11,12,11,14,12,14,16,14,16,13,16, - 14,16,12,15,13,16,14,16,13,14,12,15,13,15,13,13, - 13,15,12,14,14,15,13,15,12,15,15,15,15,15,15,15, - 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, -}; - -static const static_codebook _huff_book_line_512x17_1sub1 = { - 1, 128, - (char *)_huff_lengthlist_line_512x17_1sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_2sub1[] = { - 0, 4, 5, 4, 4, 4, 5, 4, 4, 4, 5, 4, 5, 4, 5, 3, - 5, 3, -}; - -static const static_codebook _huff_book_line_512x17_2sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_512x17_2sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_2sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 3, 4, 3, 4, 4, 5, 4, 5, 4, 6, 4, 6, 5, - 6, 5, 7, 5, 7, 6, 8, 6, 8, 6, 8, 7, 8, 7, 9, 7, - 9, 8, -}; - -static const static_codebook _huff_book_line_512x17_2sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_512x17_2sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_2sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 3, 3, 3, 4, 3, 4, 4, 5, 5, 6, 6, 7, 7, - 7, 8, 8,11, 8, 9, 9, 9,10,11,11,11, 9,10,10,11, - 11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _huff_book_line_512x17_2sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_512x17_2sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_3sub1[] = { - 0, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 5, 4, 5, - 5, 5, -}; - -static const static_codebook _huff_book_line_512x17_3sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_512x17_3sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_3sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 3, 3, 4, 3, 5, 4, 6, 4, 6, 5, 7, 6, 7, - 6, 8, 6, 8, 7, 9, 8,10, 8,12, 9,13,10,15,10,15, - 11,14, -}; - -static const static_codebook _huff_book_line_512x17_3sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_512x17_3sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_3sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 8, 4, 8, 4, 8, 4, 8, 5, 8, 5, 8, 6, 8, - 4, 8, 4, 8, 5, 8, 5, 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, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -}; - -static const static_codebook _huff_book_line_512x17_3sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_512x17_3sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_class1[] = { - 1, 2, 3, 6, 5, 4, 7, 7, -}; - -static const static_codebook _huff_book_line_512x17_class1 = { - 1, 8, - (char *)_huff_lengthlist_line_512x17_class1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_class2[] = { - 3, 3, 3,14, 5, 4, 4,11, 8, 6, 6,10,17,12,11,17, - 6, 5, 5,15, 5, 3, 4,11, 8, 5, 5, 8,16, 9,10,14, - 10, 8, 9,17, 8, 6, 6,13,10, 7, 7,10,16,11,13,14, - 17,17,17,17,17,16,16,16,16,15,16,16,16,16,16,16, -}; - -static const static_codebook _huff_book_line_512x17_class2 = { - 1, 64, - (char *)_huff_lengthlist_line_512x17_class2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_512x17_class3[] = { - 2, 4, 6,17, 4, 5, 7,17, 8, 7,10,17,17,17,17,17, - 3, 4, 6,15, 3, 3, 6,15, 7, 6, 9,17,17,17,17,17, - 6, 8,10,17, 6, 6, 8,16, 9, 8,10,17,17,15,16,17, - 17,17,17,17,12,15,15,16,12,15,15,16,16,16,16,16, -}; - -static const static_codebook _huff_book_line_512x17_class3 = { - 1, 64, - (char *)_huff_lengthlist_line_512x17_class3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x4_class0[] = { - 7, 7, 7,11, 6, 6, 7,11, 7, 6, 6,10,12,10,10,13, - 7, 7, 8,11, 7, 7, 7,11, 7, 6, 7,10,11,10,10,13, - 10,10, 9,12, 9, 9, 9,11, 8, 8, 8,11,13,11,10,14, - 15,15,14,15,15,14,13,14,15,12,12,17,17,17,17,17, - 7, 7, 6, 9, 6, 6, 6, 9, 7, 6, 6, 8,11,11,10,12, - 7, 7, 7, 9, 7, 6, 6, 9, 7, 6, 6, 9,13,10,10,11, - 10, 9, 8,10, 9, 8, 8,10, 8, 8, 7, 9,13,12,10,11, - 17,14,14,13,15,14,12,13,17,13,12,15,17,17,14,17, - 7, 6, 6, 7, 6, 6, 5, 7, 6, 6, 6, 6,11, 9, 9, 9, - 7, 7, 6, 7, 7, 6, 6, 7, 6, 6, 6, 6,10, 9, 8, 9, - 10, 9, 8, 8, 9, 8, 7, 8, 8, 7, 6, 8,11,10, 9,10, - 17,17,12,15,15,15,12,14,14,14,10,12,15,13,12,13, - 11,10, 8,10,11,10, 8, 8,10, 9, 7, 7,10, 9, 9,11, - 11,11, 9,10,11,10, 8, 9,10, 8, 6, 8,10, 9, 9,11, - 14,13,10,12,12,11,10,10, 8, 7, 8,10,10,11,11,12, - 17,17,15,17,17,17,17,17,17,13,12,17,17,17,14,17, -}; - -static const static_codebook _huff_book_line_128x4_class0 = { - 1, 256, - (char *)_huff_lengthlist_line_128x4_class0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x4_0sub0[] = { - 2, 2, 2, 2, -}; - -static const static_codebook _huff_book_line_128x4_0sub0 = { - 1, 4, - (char *)_huff_lengthlist_line_128x4_0sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x4_0sub1[] = { - 0, 0, 0, 0, 3, 2, 3, 2, 3, 3, -}; - -static const static_codebook _huff_book_line_128x4_0sub1 = { - 1, 10, - (char *)_huff_lengthlist_line_128x4_0sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x4_0sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 4, 3, 4, 3, - 4, 4, 5, 4, 5, 4, 6, 5, 6, -}; - -static const static_codebook _huff_book_line_128x4_0sub2 = { - 1, 25, - (char *)_huff_lengthlist_line_128x4_0sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x4_0sub3[] = { - 0, 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, 4, 3, 5, 3, 5, 3, - 5, 4, 6, 5, 6, 5, 7, 6, 6, 7, 7, 9, 9,11,11,16, - 11,14,10,11,11,13,16,15,15,15,15,15,15,15,15,15, -}; - -static const static_codebook _huff_book_line_128x4_0sub3 = { - 1, 64, - (char *)_huff_lengthlist_line_128x4_0sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4_class0[] = { - 6, 7, 7,12, 6, 6, 7,12, 7, 6, 6,10,15,12,11,13, - 7, 7, 8,13, 7, 7, 8,12, 7, 7, 7,11,12,12,11,13, - 10, 9, 9,11, 9, 9, 9,10,10, 8, 8,12,14,12,12,14, - 11,11,12,14,11,12,11,15,15,12,13,15,15,15,15,15, - 6, 6, 7,10, 6, 6, 6,11, 7, 6, 6, 9,14,12,11,13, - 7, 7, 7,10, 6, 6, 7, 9, 7, 7, 6,10,13,12,10,12, - 9, 9, 9,11, 9, 9, 8, 9, 9, 8, 8,10,13,12,10,12, - 12,12,11,13,12,12,11,12,15,13,12,15,15,15,14,14, - 6, 6, 6, 8, 6, 6, 5, 6, 7, 7, 6, 5,11,10, 9, 8, - 7, 6, 6, 7, 6, 6, 5, 6, 7, 7, 6, 6,11,10, 9, 8, - 8, 8, 8, 9, 8, 8, 7, 8, 8, 8, 6, 7,11,10, 9, 9, - 14,11,10,14,14,11,10,15,13,11, 9,11,15,12,12,11, - 11, 9, 8, 8,10, 9, 8, 9,11,10, 9, 8,12,11,12,11, - 13,10, 8, 9,11,10, 8, 9,10, 9, 8, 9,10, 8,12,12, - 15,11,10,10,13,11,10,10, 8, 8, 7,12,10, 9,11,12, - 15,12,11,15,13,11,11,15,12,14,11,13,15,15,13,13, -}; - -static const static_codebook _huff_book_line_256x4_class0 = { - 1, 256, - (char *)_huff_lengthlist_line_256x4_class0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4_0sub0[] = { - 2, 2, 2, 2, -}; - -static const static_codebook _huff_book_line_256x4_0sub0 = { - 1, 4, - (char *)_huff_lengthlist_line_256x4_0sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4_0sub1[] = { - 0, 0, 0, 0, 2, 2, 3, 3, 3, 3, -}; - -static const static_codebook _huff_book_line_256x4_0sub1 = { - 1, 10, - (char *)_huff_lengthlist_line_256x4_0sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4_0sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 3, 4, 3, 4, 3, - 5, 3, 5, 4, 5, 4, 6, 4, 6, -}; - -static const static_codebook _huff_book_line_256x4_0sub2 = { - 1, 25, - (char *)_huff_lengthlist_line_256x4_0sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4_0sub3[] = { - 0, 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, 4, 3, 5, 3, 5, 3, - 6, 4, 7, 4, 7, 5, 7, 6, 7, 6, 7, 8,10,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12, -}; - -static const static_codebook _huff_book_line_256x4_0sub3 = { - 1, 64, - (char *)_huff_lengthlist_line_256x4_0sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x7_class0[] = { - 10, 7, 8,13, 9, 6, 7,11,10, 8, 8,12,17,17,17,17, - 7, 5, 5, 9, 6, 4, 4, 8, 8, 5, 5, 8,16,14,13,16, - 7, 5, 5, 7, 6, 3, 3, 5, 8, 5, 4, 7,14,12,12,15, - 10, 7, 8, 9, 7, 5, 5, 6, 9, 6, 5, 5,15,12, 9,10, -}; - -static const static_codebook _huff_book_line_128x7_class0 = { - 1, 64, - (char *)_huff_lengthlist_line_128x7_class0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x7_class1[] = { - 8,13,17,17, 8,11,17,17,11,13,17,17,17,17,17,17, - 6,10,16,17, 6,10,15,17, 8,10,16,17,17,17,17,17, - 9,13,15,17, 8,11,17,17,10,12,17,17,17,17,17,17, - 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, - 6,11,15,17, 7,10,15,17, 8,10,17,17,17,15,17,17, - 4, 8,13,17, 4, 7,13,17, 6, 8,15,17,16,15,17,17, - 6,11,15,17, 6, 9,13,17, 8,10,17,17,15,17,17,17, - 16,17,17,17,12,14,15,17,13,14,15,17,17,17,17,17, - 5,10,14,17, 5, 9,14,17, 7, 9,15,17,15,15,17,17, - 3, 7,12,17, 3, 6,11,17, 5, 7,13,17,12,12,17,17, - 5, 9,14,17, 3, 7,11,17, 5, 8,13,17,13,11,16,17, - 12,17,17,17, 9,14,15,17,10,11,14,17,16,14,17,17, - 8,12,17,17, 8,12,17,17,10,12,17,17,17,17,17,17, - 5,10,17,17, 5, 9,15,17, 7, 9,17,17,13,13,17,17, - 7,11,17,17, 6,10,15,17, 7, 9,15,17,12,11,17,17, - 12,15,17,17,11,14,17,17,11,10,15,17,17,16,17,17, -}; - -static const static_codebook _huff_book_line_128x7_class1 = { - 1, 256, - (char *)_huff_lengthlist_line_128x7_class1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x7_0sub1[] = { - 0, 3, 3, 3, 3, 3, 3, 3, 3, -}; - -static const static_codebook _huff_book_line_128x7_0sub1 = { - 1, 9, - (char *)_huff_lengthlist_line_128x7_0sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x7_0sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 4, 4, 4, 4, - 5, 4, 5, 4, 5, 4, 6, 4, 6, -}; - -static const static_codebook _huff_book_line_128x7_0sub2 = { - 1, 25, - (char *)_huff_lengthlist_line_128x7_0sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x7_0sub3[] = { - 0, 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, 5, 3, 5, 3, 5, 4, - 5, 4, 5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, - 7, 8, 9,11,13,13,13,13,13,13,13,13,13,13,13,13, -}; - -static const static_codebook _huff_book_line_128x7_0sub3 = { - 1, 64, - (char *)_huff_lengthlist_line_128x7_0sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x7_1sub1[] = { - 0, 3, 3, 2, 3, 3, 4, 3, 4, -}; - -static const static_codebook _huff_book_line_128x7_1sub1 = { - 1, 9, - (char *)_huff_lengthlist_line_128x7_1sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x7_1sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 3, 6, 3, 6, 3, - 6, 3, 7, 3, 8, 4, 9, 4, 9, -}; - -static const static_codebook _huff_book_line_128x7_1sub2 = { - 1, 25, - (char *)_huff_lengthlist_line_128x7_1sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x7_1sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 2, 7, 3, 8, 4, - 9, 5, 9, 8,10,11,11,12,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,13,13,13,13, -}; - -static const static_codebook _huff_book_line_128x7_1sub3 = { - 1, 64, - (char *)_huff_lengthlist_line_128x7_1sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_class1[] = { - 1, 6, 3, 7, 2, 4, 5, 7, -}; - -static const static_codebook _huff_book_line_128x11_class1 = { - 1, 8, - (char *)_huff_lengthlist_line_128x11_class1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_class2[] = { - 1, 6,12,16, 4,12,15,16, 9,15,16,16,16,16,16,16, - 2, 5,11,16, 5,11,13,16, 9,13,16,16,16,16,16,16, - 4, 8,12,16, 5, 9,12,16, 9,13,15,16,16,16,16,16, - 15,16,16,16,11,14,13,16,12,15,16,16,16,16,16,15, -}; - -static const static_codebook _huff_book_line_128x11_class2 = { - 1, 64, - (char *)_huff_lengthlist_line_128x11_class2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_class3[] = { - 7, 6, 9,17, 7, 6, 8,17,12, 9,11,16,16,16,16,16, - 5, 4, 7,16, 5, 3, 6,14, 9, 6, 8,15,16,16,16,16, - 5, 4, 6,13, 3, 2, 4,11, 7, 4, 6,13,16,11,10,14, - 12,12,12,16, 9, 7,10,15,12, 9,11,16,16,15,15,16, -}; - -static const static_codebook _huff_book_line_128x11_class3 = { - 1, 64, - (char *)_huff_lengthlist_line_128x11_class3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_0sub0[] = { - 5, 5, 5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, - 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 6, 6, 6, 7, 6, - 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 8, 6, 8, 6, 8, 7, - 8, 7, 8, 7, 8, 7, 9, 7, 9, 8, 9, 8, 9, 8,10, 8, - 10, 9,10, 9,10, 9,11, 9,11, 9,10,10,11,10,11,10, - 11,11,11,11,11,11,12,13,14,14,14,15,15,16,16,16, - 17,15,16,15,16,16,17,17,16,17,17,17,17,17,17,17, - 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, -}; - -static const static_codebook _huff_book_line_128x11_0sub0 = { - 1, 128, - (char *)_huff_lengthlist_line_128x11_0sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_1sub0[] = { - 2, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, - 6, 5, 6, 5, 6, 5, 7, 6, 7, 6, 7, 6, 8, 6, 8, 6, -}; - -static const static_codebook _huff_book_line_128x11_1sub0 = { - 1, 32, - (char *)_huff_lengthlist_line_128x11_1sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_1sub1[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 5, 3, 5, 3, 6, 4, 6, 4, 7, 4, 7, 4, 7, 4, 8, 4, - 8, 4, 9, 5, 9, 5, 9, 5, 9, 6,10, 6,10, 6,11, 7, - 10, 7,10, 8,11, 9,11, 9,11,10,11,11,12,11,11,12, - 15,15,12,14,11,14,12,14,11,14,13,14,12,14,11,14, - 11,14,12,14,11,14,11,14,13,13,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, -}; - -static const static_codebook _huff_book_line_128x11_1sub1 = { - 1, 128, - (char *)_huff_lengthlist_line_128x11_1sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_2sub1[] = { - 0, 4, 5, 4, 5, 4, 5, 3, 5, 3, 5, 3, 5, 4, 4, 4, - 5, 5, -}; - -static const static_codebook _huff_book_line_128x11_2sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_128x11_2sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_2sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 4, 4, 4, 4, 5, 4, 5, 4, 6, 5, 7, - 5, 7, 6, 8, 6, 8, 6, 9, 7, 9, 7,10, 7, 9, 8,11, - 8,11, -}; - -static const static_codebook _huff_book_line_128x11_2sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_128x11_2sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_2sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 8, 3, 8, 4, 8, 4, 8, 6, 8, 5, 8, 4, 8, - 4, 8, 6, 8, 7, 8, 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, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -}; - -static const static_codebook _huff_book_line_128x11_2sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_128x11_2sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_3sub1[] = { - 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, - 5, 4, -}; - -static const static_codebook _huff_book_line_128x11_3sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_128x11_3sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_3sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 3, 5, 4, 6, 4, 6, 4, 7, 4, 7, 4, 8, 4, - 8, 4, 9, 4, 9, 4,10, 4,10, 5,10, 5,11, 5,12, 6, - 12, 6, -}; - -static const static_codebook _huff_book_line_128x11_3sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_128x11_3sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x11_3sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 7, 1, 6, 3, 7, 3, 8, 4, 8, 5, 8, 8, 8, 9, - 7, 8, 8, 7, 7, 7, 8, 9,10, 9, 9,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, -}; - -static const static_codebook _huff_book_line_128x11_3sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_128x11_3sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_class1[] = { - 1, 3, 4, 7, 2, 5, 6, 7, -}; - -static const static_codebook _huff_book_line_128x17_class1 = { - 1, 8, - (char *)_huff_lengthlist_line_128x17_class1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_class2[] = { - 1, 4,10,19, 3, 8,13,19, 7,12,19,19,19,19,19,19, - 2, 6,11,19, 8,13,19,19, 9,11,19,19,19,19,19,19, - 6, 7,13,19, 9,13,19,19,10,13,18,18,18,18,18,18, - 18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, -}; - -static const static_codebook _huff_book_line_128x17_class2 = { - 1, 64, - (char *)_huff_lengthlist_line_128x17_class2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_class3[] = { - 3, 6,10,17, 4, 8,11,20, 8,10,11,20,20,20,20,20, - 2, 4, 8,18, 4, 6, 8,17, 7, 8,10,20,20,17,20,20, - 3, 5, 8,17, 3, 4, 6,17, 8, 8,10,17,17,12,16,20, - 13,13,15,20,10,10,12,20,15,14,15,20,20,20,19,19, -}; - -static const static_codebook _huff_book_line_128x17_class3 = { - 1, 64, - (char *)_huff_lengthlist_line_128x17_class3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_0sub0[] = { - 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, - 7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 7, 5, 8, 5, 8, 5, - 8, 5, 8, 5, 8, 6, 8, 6, 8, 6, 9, 6, 9, 6, 9, 6, - 9, 6, 9, 7, 9, 7, 9, 7, 9, 7,10, 7,10, 8,10, 8, - 10, 8,10, 8,10, 8,11, 8,11, 8,11, 8,11, 8,11, 9, - 12, 9,12, 9,12, 9,12, 9,12,10,12,10,13,11,13,11, - 14,12,14,13,15,14,16,14,17,15,18,16,20,20,20,20, - 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20, -}; - -static const static_codebook _huff_book_line_128x17_0sub0 = { - 1, 128, - (char *)_huff_lengthlist_line_128x17_0sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_1sub0[] = { - 2, 5, 5, 4, 5, 4, 5, 4, 5, 5, 5, 5, 5, 5, 6, 5, - 6, 5, 6, 5, 7, 6, 7, 6, 7, 6, 8, 6, 9, 7, 9, 7, -}; - -static const static_codebook _huff_book_line_128x17_1sub0 = { - 1, 32, - (char *)_huff_lengthlist_line_128x17_1sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_1sub1[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 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, 3, 5, 3, 5, 3, 6, 3, 6, 4, 6, 4, 7, 4, 7, 5, - 8, 5, 8, 6, 9, 7, 9, 7, 9, 8,10, 9,10, 9,11,10, - 11,11,11,11,11,11,12,12,12,13,12,13,12,14,12,15, - 12,14,12,16,13,17,13,17,14,17,14,16,13,17,14,17, - 14,17,15,17,15,15,16,17,17,17,17,17,17,17,17,17, - 17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16, -}; - -static const static_codebook _huff_book_line_128x17_1sub1 = { - 1, 128, - (char *)_huff_lengthlist_line_128x17_1sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_2sub1[] = { - 0, 4, 5, 4, 6, 4, 8, 3, 9, 3, 9, 2, 9, 3, 8, 4, - 9, 4, -}; - -static const static_codebook _huff_book_line_128x17_2sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_128x17_2sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_2sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 1, 5, 3, 5, 3, 5, 4, 7, 5,10, 7,10, 7, - 12,10,14,10,14, 9,14,11,14,14,14,13,13,13,13,13, - 13,13, -}; - -static const static_codebook _huff_book_line_128x17_2sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_128x17_2sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_2sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 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, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -}; - -static const static_codebook _huff_book_line_128x17_2sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_128x17_2sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_3sub1[] = { - 0, 4, 4, 4, 4, 4, 4, 4, 5, 3, 5, 3, 5, 4, 6, 4, - 6, 4, -}; - -static const static_codebook _huff_book_line_128x17_3sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_128x17_3sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_3sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 3, 6, 3, 6, 4, 7, 4, 7, 4, 7, 4, 8, 4, - 8, 4, 8, 4, 8, 4, 9, 4, 9, 5,10, 5,10, 7,10, 8, - 10, 8, -}; - -static const static_codebook _huff_book_line_128x17_3sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_128x17_3sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_128x17_3sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2, 4, 3, 4, 4, 4, 5, 4, 7, 5, 8, 5,11, - 6,10, 6,12, 7,12, 7,12, 8,12, 8,12,10,12,12,12, - 12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, -}; - -static const static_codebook _huff_book_line_128x17_3sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_128x17_3sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_class1[] = { - 2,10, 8,14, 7,12,11,14, 1, 5, 3, 7, 4, 9, 7,13, -}; - -static const static_codebook _huff_book_line_1024x27_class1 = { - 1, 16, - (char *)_huff_lengthlist_line_1024x27_class1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_class2[] = { - 1, 4, 2, 6, 3, 7, 5, 7, -}; - -static const static_codebook _huff_book_line_1024x27_class2 = { - 1, 8, - (char *)_huff_lengthlist_line_1024x27_class2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_class3[] = { - 1, 5, 7,21, 5, 8, 9,21,10, 9,12,20,20,16,20,20, - 4, 8, 9,20, 6, 8, 9,20,11,11,13,20,20,15,17,20, - 9,11,14,20, 8,10,15,20,11,13,15,20,20,20,20,20, - 20,20,20,20,13,20,20,20,18,18,20,20,20,20,20,20, - 3, 6, 8,20, 6, 7, 9,20,10, 9,12,20,20,20,20,20, - 5, 7, 9,20, 6, 6, 9,20,10, 9,12,20,20,20,20,20, - 8,10,13,20, 8, 9,12,20,11,10,12,20,20,20,20,20, - 18,20,20,20,15,17,18,20,18,17,18,20,20,20,20,20, - 7,10,12,20, 8, 9,11,20,14,13,14,20,20,20,20,20, - 6, 9,12,20, 7, 8,11,20,12,11,13,20,20,20,20,20, - 9,11,15,20, 8,10,14,20,12,11,14,20,20,20,20,20, - 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20, - 11,16,18,20,15,15,17,20,20,17,20,20,20,20,20,20, - 9,14,16,20,12,12,15,20,17,15,18,20,20,20,20,20, - 16,19,18,20,15,16,20,20,17,17,20,20,20,20,20,20, - 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20, -}; - -static const static_codebook _huff_book_line_1024x27_class3 = { - 1, 256, - (char *)_huff_lengthlist_line_1024x27_class3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_class4[] = { - 2, 3, 7,13, 4, 4, 7,15, 8, 6, 9,17,21,16,15,21, - 2, 5, 7,11, 5, 5, 7,14, 9, 7,10,16,17,15,16,21, - 4, 7,10,17, 7, 7, 9,15,11, 9,11,16,21,18,15,21, - 18,21,21,21,15,17,17,19,21,19,18,20,21,21,21,20, -}; - -static const static_codebook _huff_book_line_1024x27_class4 = { - 1, 64, - (char *)_huff_lengthlist_line_1024x27_class4, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_0sub0[] = { - 5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, - 6, 5, 6, 5, 6, 5, 6, 5, 7, 5, 7, 5, 7, 5, 7, 5, - 8, 6, 8, 6, 8, 6, 9, 6, 9, 6,10, 6,10, 6,11, 6, - 11, 7,11, 7,12, 7,12, 7,12, 7,12, 7,12, 7,12, 7, - 12, 7,12, 8,13, 8,12, 8,12, 8,13, 8,13, 9,13, 9, - 13, 9,13, 9,12,10,12,10,13,10,14,11,14,12,14,13, - 14,13,14,14,15,16,15,15,15,14,15,17,21,22,22,21, - 22,22,22,22,22,22,21,21,21,21,21,21,21,21,21,21, -}; - -static const static_codebook _huff_book_line_1024x27_0sub0 = { - 1, 128, - (char *)_huff_lengthlist_line_1024x27_0sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_1sub0[] = { - 2, 5, 5, 4, 5, 4, 5, 4, 5, 4, 6, 5, 6, 5, 6, 5, - 6, 5, 7, 5, 7, 6, 8, 6, 8, 6, 8, 6, 9, 6, 9, 6, -}; - -static const static_codebook _huff_book_line_1024x27_1sub0 = { - 1, 32, - (char *)_huff_lengthlist_line_1024x27_1sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_1sub1[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8, 5, 8, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 4, - 9, 4, 9, 4, 9, 4, 8, 4, 8, 4, 9, 5, 9, 5, 9, 5, - 9, 5, 9, 6,10, 6,10, 7,10, 8,11, 9,11,11,12,13, - 12,14,13,15,13,15,14,16,14,17,15,17,15,15,16,16, - 15,16,16,16,15,18,16,15,17,17,19,19,19,19,19,19, - 19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19, -}; - -static const static_codebook _huff_book_line_1024x27_1sub1 = { - 1, 128, - (char *)_huff_lengthlist_line_1024x27_1sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_2sub0[] = { - 1, 5, 5, 5, 5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, - 6, 6, 7, 7, 7, 7, 8, 7, 8, 8, 9, 8,10, 9,10, 9, -}; - -static const static_codebook _huff_book_line_1024x27_2sub0 = { - 1, 32, - (char *)_huff_lengthlist_line_1024x27_2sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_2sub1[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 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, 3, 4, 3, 4, 4, 5, 4, 5, 4, 5, 5, 6, 5, 6, 5, - 7, 5, 7, 6, 7, 6, 8, 7, 8, 7, 8, 7, 9, 8, 9, 9, - 9, 9,10,10,10,11, 9,12, 9,12, 9,15,10,14, 9,13, - 10,13,10,12,10,12,10,13,10,12,11,13,11,14,12,13, - 13,14,14,13,14,15,14,16,13,13,14,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,15,15, -}; - -static const static_codebook _huff_book_line_1024x27_2sub1 = { - 1, 128, - (char *)_huff_lengthlist_line_1024x27_2sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_3sub1[] = { - 0, 4, 5, 4, 5, 3, 5, 3, 5, 3, 5, 4, 4, 4, 4, 5, - 5, 5, -}; - -static const static_codebook _huff_book_line_1024x27_3sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_1024x27_3sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_3sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 4, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, - 5, 7, 5, 8, 6, 8, 6, 9, 7,10, 7,10, 8,10, 8,11, - 9,11, -}; - -static const static_codebook _huff_book_line_1024x27_3sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_1024x27_3sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_3sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 7, 3, 8, 3,10, 3, 8, 3, 9, 3, 8, 4, 9, - 4, 9, 5, 9, 6,10, 6, 9, 7,11, 7,12, 9,13,10,13, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, -}; - -static const static_codebook _huff_book_line_1024x27_3sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_1024x27_3sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_4sub1[] = { - 0, 4, 5, 4, 5, 4, 5, 4, 5, 3, 5, 3, 5, 3, 5, 4, - 5, 4, -}; - -static const static_codebook _huff_book_line_1024x27_4sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_1024x27_4sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_4sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 2, 4, 2, 5, 3, 5, 4, 6, 6, 6, 7, 7, 8, - 7, 8, 7, 8, 7, 9, 8, 9, 8, 9, 8,10, 8,11, 9,12, - 9,12, -}; - -static const static_codebook _huff_book_line_1024x27_4sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_1024x27_4sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_1024x27_4sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2, 6, 3, 6, 4, 7, 4, 7, 5, 9, 5,11, - 6,11, 6,11, 7,11, 6,11, 6,11, 9,11, 8,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10, -}; - -static const static_codebook _huff_book_line_1024x27_4sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_1024x27_4sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_class1[] = { - 2, 6, 8, 9, 7,11,13,13, 1, 3, 5, 5, 6, 6,12,10, -}; - -static const static_codebook _huff_book_line_2048x27_class1 = { - 1, 16, - (char *)_huff_lengthlist_line_2048x27_class1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_class2[] = { - 1, 2, 3, 6, 4, 7, 5, 7, -}; - -static const static_codebook _huff_book_line_2048x27_class2 = { - 1, 8, - (char *)_huff_lengthlist_line_2048x27_class2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_class3[] = { - 3, 3, 6,16, 5, 5, 7,16, 9, 8,11,16,16,16,16,16, - 5, 5, 8,16, 5, 5, 7,16, 8, 7, 9,16,16,16,16,16, - 9, 9,12,16, 6, 8,11,16, 9,10,11,16,16,16,16,16, - 16,16,16,16,13,16,16,16,15,16,16,16,16,16,16,16, - 5, 4, 7,16, 6, 5, 8,16, 9, 8,10,16,16,16,16,16, - 5, 5, 7,15, 5, 4, 6,15, 7, 6, 8,16,16,16,16,16, - 9, 9,11,15, 7, 7, 9,16, 8, 8, 9,16,16,16,16,16, - 16,16,16,16,15,15,15,16,15,15,14,16,16,16,16,16, - 8, 8,11,16, 8, 9,10,16,11,10,14,16,16,16,16,16, - 6, 8,10,16, 6, 7,10,16, 8, 8,11,16,14,16,16,16, - 10,11,14,16, 9, 9,11,16,10,10,11,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,15,16,16,16,16,16,16,16,16,16,16,16, - 12,16,15,16,12,14,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -}; - -static const static_codebook _huff_book_line_2048x27_class3 = { - 1, 256, - (char *)_huff_lengthlist_line_2048x27_class3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_class4[] = { - 2, 4, 7,13, 4, 5, 7,15, 8, 7,10,16,16,14,16,16, - 2, 4, 7,16, 3, 4, 7,14, 8, 8,10,16,16,16,15,16, - 6, 8,11,16, 7, 7, 9,16,11, 9,13,16,16,16,15,16, - 16,16,16,16,14,16,16,16,16,16,16,16,16,16,16,16, -}; - -static const static_codebook _huff_book_line_2048x27_class4 = { - 1, 64, - (char *)_huff_lengthlist_line_2048x27_class4, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_0sub0[] = { - 5, 5, 5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, - 6, 5, 7, 5, 7, 5, 7, 5, 8, 5, 8, 5, 8, 5, 9, 5, - 9, 6,10, 6,10, 6,11, 6,11, 6,11, 6,11, 6,11, 6, - 11, 6,11, 6,12, 7,11, 7,11, 7,11, 7,11, 7,10, 7, - 11, 7,11, 7,12, 7,11, 8,11, 8,11, 8,11, 8,13, 8, - 12, 9,11, 9,11, 9,11,10,12,10,12, 9,12,10,12,11, - 14,12,16,12,12,11,14,16,17,17,17,17,17,17,17,17, - 17,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16, -}; - -static const static_codebook _huff_book_line_2048x27_0sub0 = { - 1, 128, - (char *)_huff_lengthlist_line_2048x27_0sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_1sub0[] = { - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 6, 6, 6, 6, 6, 6, 7, 6, 7, 6, 7, 6, 7, 6, -}; - -static const static_codebook _huff_book_line_2048x27_1sub0 = { - 1, 32, - (char *)_huff_lengthlist_line_2048x27_1sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_1sub1[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 6, 5, 7, 5, 7, 4, 7, 4, 8, 4, 8, 4, 8, 4, 8, 3, - 8, 4, 9, 4, 9, 4, 9, 4, 9, 4, 9, 5, 9, 5, 9, 6, - 9, 7, 9, 8, 9, 9, 9,10, 9,11, 9,14, 9,15,10,15, - 10,15,10,15,10,15,11,15,10,14,12,14,11,14,13,14, - 13,15,15,15,12,15,15,15,13,15,13,15,13,15,15,15, - 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,14, -}; - -static const static_codebook _huff_book_line_2048x27_1sub1 = { - 1, 128, - (char *)_huff_lengthlist_line_2048x27_1sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_2sub0[] = { - 2, 4, 5, 4, 5, 4, 5, 4, 5, 5, 5, 5, 5, 5, 6, 5, - 6, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, -}; - -static const static_codebook _huff_book_line_2048x27_2sub0 = { - 1, 32, - (char *)_huff_lengthlist_line_2048x27_2sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_2sub1[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 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, 4, 3, 4, 3, 4, 4, 5, 4, 5, 5, 5, 6, 6, 6, 7, - 6, 8, 6, 8, 6, 9, 7,10, 7,10, 7,10, 7,12, 7,12, - 7,12, 9,12,11,12,10,12,10,12,11,12,12,12,10,12, - 10,12,10,12, 9,12,11,12,12,12,12,12,11,12,11,12, - 12,12,12,12,12,12,12,12,10,10,12,12,12,12,12,10, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, -}; - -static const static_codebook _huff_book_line_2048x27_2sub1 = { - 1, 128, - (char *)_huff_lengthlist_line_2048x27_2sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_3sub1[] = { - 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, -}; - -static const static_codebook _huff_book_line_2048x27_3sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_2048x27_3sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_3sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, - 6, 7, 6, 7, 6, 8, 6, 9, 7, 9, 7, 9, 9,11, 9,12, - 10,12, -}; - -static const static_codebook _huff_book_line_2048x27_3sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_2048x27_3sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_3sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 6, 3, 7, 3, 7, 5, 7, 7, 7, 7, 7, 6, 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, 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, -}; - -static const static_codebook _huff_book_line_2048x27_3sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_2048x27_3sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_4sub1[] = { - 0, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 5, 4, 5, 4, - 4, 5, -}; - -static const static_codebook _huff_book_line_2048x27_4sub1 = { - 1, 18, - (char *)_huff_lengthlist_line_2048x27_4sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_4sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 2, 4, 3, 4, 4, 4, 5, 5, 6, 5, 6, 5, 7, - 6, 6, 6, 7, 7, 7, 8, 9, 9, 9,12,10,11,10,10,12, - 10,10, -}; - -static const static_codebook _huff_book_line_2048x27_4sub2 = { - 1, 50, - (char *)_huff_lengthlist_line_2048x27_4sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_2048x27_4sub3[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 6, 5, 7, 5, 7, 7, 7, 7, 7, 5, 7, 5, 7, - 5, 7, 5, 7, 7, 7, 7, 7, 4, 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, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, -}; - -static const static_codebook _huff_book_line_2048x27_4sub3 = { - 1, 128, - (char *)_huff_lengthlist_line_2048x27_4sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4low_class0[] = { - 4, 5, 6,11, 5, 5, 6,10, 7, 7, 6, 6,14,13, 9, 9, - 6, 6, 6,10, 6, 6, 6, 9, 8, 7, 7, 9,14,12, 8,11, - 8, 7, 7,11, 8, 8, 7,11, 9, 9, 7, 9,13,11, 9,13, - 19,19,18,19,15,16,16,19,11,11,10,13,10,10, 9,15, - 5, 5, 6,13, 6, 6, 6,11, 8, 7, 6, 7,14,11,10,11, - 6, 6, 6,12, 7, 6, 6,11, 8, 7, 7,11,13,11, 9,11, - 9, 7, 6,12, 8, 7, 6,12, 9, 8, 8,11,13,10, 7,13, - 19,19,17,19,17,14,14,19,12,10, 8,12,13,10, 9,16, - 7, 8, 7,12, 7, 7, 7,11, 8, 7, 7, 8,12,12,11,11, - 8, 8, 7,12, 8, 7, 6,11, 8, 7, 7,10,10,11,10,11, - 9, 8, 8,13, 9, 8, 7,12,10, 9, 7,11, 9, 8, 7,11, - 18,18,15,18,18,16,17,18,15,11,10,18,11, 9, 9,18, - 16,16,13,16,12,11,10,16,12,11, 9, 6,15,12,11,13, - 16,16,14,14,13,11,12,16,12, 9, 9,13,13,10,10,12, - 17,18,17,17,14,15,14,16,14,12,14,15,12,10,11,12, - 18,18,18,18,18,18,18,18,18,12,13,18,16,11, 9,18, -}; - -static const static_codebook _huff_book_line_256x4low_class0 = { - 1, 256, - (char *)_huff_lengthlist_line_256x4low_class0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4low_0sub0[] = { - 1, 3, 2, 3, -}; - -static const static_codebook _huff_book_line_256x4low_0sub0 = { - 1, 4, - (char *)_huff_lengthlist_line_256x4low_0sub0, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4low_0sub1[] = { - 0, 0, 0, 0, 2, 3, 2, 3, 3, 3, -}; - -static const static_codebook _huff_book_line_256x4low_0sub1 = { - 1, 10, - (char *)_huff_lengthlist_line_256x4low_0sub1, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4low_0sub2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 4, 3, 4, - 4, 4, 4, 4, 5, 5, 5, 6, 6, -}; - -static const static_codebook _huff_book_line_256x4low_0sub2 = { - 1, 25, - (char *)_huff_lengthlist_line_256x4low_0sub2, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist_line_256x4low_0sub3[] = { - 0, 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, 4, 2, 4, 3, 5, 4, - 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 8, 6, 9, - 7,12,11,16,13,16,12,15,13,15,12,14,12,15,15,15, -}; - -static const static_codebook _huff_book_line_256x4low_0sub3 = { - 1, 64, - (char *)_huff_lengthlist_line_256x4low_0sub3, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - diff --git a/Engine/lib/libvorbis/lib/books/uncoupled/Makefile.am b/Engine/lib/libvorbis/lib/books/uncoupled/Makefile.am deleted file mode 100644 index 93ff417c8..000000000 --- a/Engine/lib/libvorbis/lib/books/uncoupled/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = res_books_uncoupled.h diff --git a/Engine/lib/libvorbis/lib/books/uncoupled/res_books_uncoupled.h b/Engine/lib/libvorbis/lib/books/uncoupled/res_books_uncoupled.h deleted file mode 100644 index 107e22f9e..000000000 --- a/Engine/lib/libvorbis/lib/books/uncoupled/res_books_uncoupled.h +++ /dev/null @@ -1,7757 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: static codebooks autogenerated by huff/huffbuld - - ********************************************************************/ - -#include "codebook.h" - -static const long _vq_quantlist__16u0__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16u0__p1_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 8, 5, 8, 8, 8,10,10, 8, - 10,11, 5, 8, 8, 8,10,10, 8,10,10, 4, 9, 9, 9,12, - 11, 8,11,11, 8,12,11,10,12,14,10,13,13, 7,11,11, - 10,14,12,11,14,14, 4, 9, 9, 8,11,11, 9,11,12, 7, - 11,11,10,13,14,10,12,14, 8,11,12,10,14,14,10,13, - 12, -}; - -static const static_codebook _16u0__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__16u0__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__16u0__p1_0, - 0 -}; - -static const long _vq_quantlist__16u0__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16u0__p2_0[] = { - 2, 4, 4, 5, 6, 6, 5, 6, 6, 5, 7, 7, 7, 8, 9, 7, - 8, 9, 5, 7, 7, 7, 9, 8, 7, 9, 7, 4, 7, 7, 7, 9, - 9, 7, 8, 8, 6, 9, 8, 7, 8,11, 9,11,10, 6, 8, 9, - 8,11, 8, 9,10,11, 4, 7, 7, 7, 8, 8, 7, 9, 9, 6, - 9, 8, 9,11,10, 8, 8,11, 6, 8, 9, 9,10,11, 8,11, - 8, -}; - -static const static_codebook _16u0__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__16u0__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__16u0__p2_0, - 0 -}; - -static const long _vq_quantlist__16u0__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16u0__p3_0[] = { - 1, 5, 5, 7, 7, 6, 7, 7, 8, 8, 6, 7, 8, 8, 8, 8, - 9, 9,11,11, 8, 9, 9,11,11, 6, 9, 8,10,10, 8,10, - 10,11,11, 8,10,10,11,11,10,11,10,13,12, 9,11,10, - 13,13, 6, 8, 9,10,10, 8,10,10,11,11, 8,10,10,11, - 11, 9,10,11,13,12,10,10,11,12,12, 8,11,11,14,13, - 10,12,11,15,13, 9,12,11,15,14,12,14,13,16,14,12, - 13,13,17,14, 8,11,11,13,14, 9,11,12,14,15,10,11, - 12,13,15,11,13,13,14,16,12,13,14,14,16, 5, 9, 9, - 11,11, 9,11,11,12,12, 8,11,11,12,12,11,12,12,15, - 14,10,12,12,15,15, 8,11,11,13,12,10,12,12,13,13, - 10,12,12,14,13,12,12,13,14,15,11,13,13,17,16, 7, - 11,11,13,13,10,12,12,14,13,10,12,12,13,14,12,13, - 12,15,14,11,13,13,15,14, 9,12,12,16,15,11,13,13, - 17,16,10,13,13,16,16,13,14,15,15,16,13,15,14,19, - 17, 9,12,12,14,16,11,13,13,15,16,10,13,13,17,16, - 13,14,13,17,15,12,15,15,16,17, 5, 9, 9,11,11, 8, - 11,11,13,12, 9,11,11,12,12,10,12,12,14,15,11,12, - 12,14,14, 7,11,10,13,12,10,12,12,14,13,10,11,12, - 13,13,11,13,13,15,16,12,12,13,15,15, 7,11,11,13, - 13,10,13,13,14,14,10,12,12,13,13,11,13,13,16,15, - 12,13,13,15,14, 9,12,12,15,15,10,13,13,17,16,11, - 12,13,15,15,12,15,14,18,18,13,14,14,16,17, 9,12, - 12,15,16,10,13,13,15,16,11,13,13,15,16,13,15,15, - 17,17,13,15,14,16,15, 7,11,11,15,16,10,13,12,16, - 17,10,12,13,15,17,15,16,16,18,17,13,15,15,17,18, - 8,12,12,16,16,11,13,14,17,18,11,13,13,18,16,15, - 17,16,17,19,14,15,15,17,16, 8,12,12,16,15,11,14, - 13,18,17,11,13,14,18,17,15,16,16,18,17,13,16,16, - 18,18,11,15,14,18,17,13,14,15,18, 0,12,15,15, 0, - 17,17,16,17,17,18,14,16,18,18, 0,11,14,14,17, 0, - 12,15,14,17,19,12,15,14,18, 0,15,18,16, 0,17,14, - 18,16,18, 0, 7,11,11,16,15,10,12,12,18,16,10,13, - 13,16,15,13,15,14,17,17,14,16,16,19,18, 8,12,12, - 16,16,11,13,13,18,16,11,13,14,17,16,14,15,15,19, - 18,15,16,16, 0,19, 8,12,12,16,17,11,13,13,17,17, - 11,14,13,17,17,13,15,15,17,19,15,17,17,19, 0,11, - 14,15,19,17,12,15,16,18,18,12,14,15,19,17,14,16, - 17, 0,18,16,16,19,17, 0,11,14,14,18,19,12,15,14, - 17,17,13,16,14,17,16,14,17,16,18,18,15,18,15, 0, - 18, -}; - -static const static_codebook _16u0__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__16u0__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16u0__p3_0, - 0 -}; - -static const long _vq_quantlist__16u0__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16u0__p4_0[] = { - 3, 5, 5, 8, 8, 6, 6, 6, 9, 9, 6, 6, 6, 9, 9, 9, - 10, 9,11,11, 9, 9, 9,11,11, 6, 7, 7,10,10, 7, 7, - 8,10,10, 7, 7, 8,10,10,10,10,10,11,12, 9,10,10, - 11,12, 6, 7, 7,10,10, 7, 8, 7,10,10, 7, 8, 7,10, - 10,10,11,10,12,11,10,10,10,13,10, 9,10,10,12,12, - 10,11,10,14,12, 9,11,11,13,13,11,12,13,13,13,11, - 12,12,15,13, 9,10,10,12,13, 9,11,10,12,13,10,10, - 11,12,13,11,12,12,12,13,11,12,12,13,13, 5, 7, 7, - 10,10, 7, 8, 8,10,10, 7, 8, 8,10,10,10,11,10,12, - 13,10,10,11,12,12, 6, 8, 8,11,10, 7, 8, 9,10,12, - 8, 9, 9,11,11,11,10,11,11,12,10,11,11,13,12, 7, - 8, 8,10,11, 8, 9, 8,11,10, 8, 9, 9,11,11,10,12, - 10,13,11,10,11,11,13,13,10,11,10,14,13,10,10,11, - 13,13,10,12,11,14,13,12,11,13,12,13,13,12,13,14, - 14,10,11,11,13,13,10,11,10,12,13,10,12,12,12,14, - 12,12,12,14,12,12,13,12,17,15, 5, 7, 7,10,10, 7, - 8, 8,10,10, 7, 8, 8,11,10,10,10,11,12,12,10,11, - 11,12,13, 6, 8, 8,11,10, 8, 9, 9,11,11, 7, 8, 9, - 10,11,11,11,11,12,12,10,10,11,12,13, 6, 8, 8,10, - 11, 8, 9, 9,11,11, 7, 9, 7,11,10,10,12,12,13,13, - 11,11,10,13,11, 9,11,10,14,13,11,11,11,15,13,10, - 10,11,13,13,12,13,13,14,14,12,11,12,12,13,10,11, - 11,12,13,10,11,12,13,13,10,11,10,13,12,12,12,13, - 14, 0,12,13,11,13,11, 8,10,10,13,13,10,11,11,14, - 13,10,11,11,13,12,13,14,14,14,15,12,12,12,15,14, - 9,11,10,13,12,10,10,11,13,14,11,11,11,15,12,13, - 12,14,15,16,13,13,13,14,13, 9,11,11,12,12,10,12, - 11,13,13,10,11,11,13,14,13,13,13,15,15,13,13,14, - 17,15,11,12,12,14,14,10,11,12,13,15,12,13,13, 0, - 15,13,11,14,12,16,14,16,14, 0,15,11,12,12,14,16, - 11,13,12,16,15,12,13,13,14,15,12,14,12,15,13,15, - 14,14,16,16, 8,10,10,13,13,10,11,10,13,14,10,11, - 11,13,13,13,13,12,14,14,14,13,13,16,17, 9,10,10, - 12,14,10,12,11,14,13,10,11,12,13,14,12,12,12,15, - 15,13,13,13,14,14, 9,10,10,13,13,10,11,12,12,14, - 10,11,10,13,13,13,13,13,14,16,13,13,13,14,14,11, - 12,13,15,13,12,14,13,14,16,12,12,13,13,14,13,14, - 14,17,15,13,12,17,13,16,11,12,13,14,15,12,13,14, - 14,17,11,12,11,14,14,13,16,14,16, 0,14,15,11,15, - 11, -}; - -static const static_codebook _16u0__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__16u0__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16u0__p4_0, - 0 -}; - -static const long _vq_quantlist__16u0__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__16u0__p5_0[] = { - 1, 4, 4, 7, 7, 7, 7, 9, 9, 4, 6, 6, 8, 8, 8, 8, - 9, 9, 4, 6, 6, 8, 8, 8, 8, 9, 9, 7, 8, 8, 9, 9, - 9, 9,11,10, 7, 8, 8, 9, 9, 9, 9,10,11, 7, 8, 8, - 9, 9,10,10,11,11, 7, 8, 8, 9, 9,10,10,11,11, 9, - 9, 9,10,10,11,11,12,12, 9, 9, 9,10,10,11,11,12, - 12, -}; - -static const static_codebook _16u0__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__16u0__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__16u0__p5_0, - 0 -}; - -static const long _vq_quantlist__16u0__p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__16u0__p6_0[] = { - 1, 4, 4, 7, 7,10,10,12,12,13,13,18,17, 3, 6, 6, - 9, 9,11,11,13,13,14,14,18,17, 3, 6, 6, 9, 9,11, - 11,13,13,14,14,17,18, 7, 9, 9,11,11,13,13,14,14, - 15,15, 0, 0, 7, 9, 9,11,11,13,13,14,14,15,16,19, - 18,10,11,11,13,13,14,14,16,15,17,18, 0, 0,10,11, - 11,13,13,14,14,15,15,16,18, 0, 0,11,13,13,14,14, - 15,15,17,17, 0,19, 0, 0,11,13,13,14,14,14,15,16, - 18, 0,19, 0, 0,13,14,14,15,15,18,17,18,18, 0,19, - 0, 0,13,14,14,15,16,16,16,18,18,19, 0, 0, 0,16, - 17,17, 0,17,19,19, 0,19, 0, 0, 0, 0,16,19,16,17, - 18, 0,19, 0, 0, 0, 0, 0, 0, -}; - -static const static_codebook _16u0__p6_0 = { - 2, 169, - (char *)_vq_lengthlist__16u0__p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__16u0__p6_0, - 0 -}; - -static const long _vq_quantlist__16u0__p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16u0__p6_1[] = { - 1, 4, 5, 6, 6, 4, 6, 6, 6, 6, 4, 6, 6, 6, 6, 6, - 6, 6, 7, 7, 6, 6, 6, 7, 7, -}; - -static const static_codebook _16u0__p6_1 = { - 2, 25, - (char *)_vq_lengthlist__16u0__p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16u0__p6_1, - 0 -}; - -static const long _vq_quantlist__16u0__p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16u0__p7_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 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, 7, 7, 7, 7, 7, 7, 7, - 7, -}; - -static const static_codebook _16u0__p7_0 = { - 4, 81, - (char *)_vq_lengthlist__16u0__p7_0, - 1, -518803456, 1628680192, 2, 0, - (long *)_vq_quantlist__16u0__p7_0, - 0 -}; - -static const long _vq_quantlist__16u0__p7_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__16u0__p7_1[] = { - 1, 5, 5, 6, 5, 9,10,11,11,10,10,10,10,10,10, 5, - 8, 8, 8,10,10,10,10,10,10,10,10,10,10,10, 5, 8, - 9, 9, 9,10,10,10,10,10,10,10,10,10,10, 5,10, 8, - 10,10,10,10,10,10,10,10,10,10,10,10, 4, 8, 9,10, - 10,10,10,10,10,10,10,10,10,10,10, 9,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10, 9,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _16u0__p7_1 = { - 2, 225, - (char *)_vq_lengthlist__16u0__p7_1, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__16u0__p7_1, - 0 -}; - -static const long _vq_quantlist__16u0__p7_2[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__16u0__p7_2[] = { - 1, 6, 6, 7, 8, 7, 7,10, 9,10, 9,11,10, 9,11,10, - 9, 9, 9, 9,10, 6, 8, 7, 9, 9, 8, 8,10,10, 9,11, - 11,12,12,10, 9,11, 9,12,10, 9, 6, 9, 8, 9,12, 8, - 8,11, 9,11,11,12,11,12,12,10,11,11,10,10,11, 7, - 10, 9, 9, 9, 9, 9,10, 9,10, 9,10,10,12,10,10,10, - 11,12,10,10, 7, 9, 9, 9,10, 9, 9,10,10, 9, 9, 9, - 11,11,10,10,10,10, 9, 9,12, 7, 9,10, 9,11, 9,10, - 9,10,11,11,11,10,11,12, 9,12,11,10,10,10, 7, 9, - 9, 9, 9,10,12,10, 9,11,12,10,11,12,12,11, 9,10, - 11,10,11, 7, 9,10,10,11,10, 9,10,11,11,11,10,12, - 12,12,11,11,10,11,11,12, 8, 9,10,12,11,10,10,12, - 12,12,12,12,10,11,11, 9,11,10,12,11,11, 8, 9,10, - 10,11,12,11,11,10,10,10,12,12,12, 9,10,12,12,12, - 12,12, 8,10,11,10,10,12, 9,11,12,12,11,12,12,12, - 12,10,12,10,10,10,10, 8,12,11,11,11,10,10,11,12, - 12,12,12,11,12,12,12,11,11,11,12,10, 9,10,10,12, - 10,12,10,12,12,10,10,10,11,12,12,12,11,12,12,12, - 11,10,11,12,12,12,11,12,12,11,12,12,11,12,12,12, - 12,11,12,12,10,10,10,10,11,11,12,11,12,12,12,12, - 12,12,12,11,12,11,10,11,11,12,11,11, 9,10,10,10, - 12,10,10,11, 9,11,12,11,12,11,12,12,10,11,10,12, - 9, 9, 9,12,11,10,11,10,12,10,12,10,12,12,12,11, - 11,11,11,11,10, 9,10,10,11,10,11,11,12,11,10,11, - 12,12,12,11,11, 9,12,10,12, 9,10,12,10,10,11,10, - 11,11,12,11,10,11,10,11,11,11,11,12,11,11,10, 9, - 10,10,10, 9,11,11,10, 9,12,10,11,12,11,12,12,11, - 12,11,12,11,10,11,10,12,11,12,11,12,11,12,10,11, - 10,10,12,11,10,11,11,11,10, -}; - -static const static_codebook _16u0__p7_2 = { - 2, 441, - (char *)_vq_lengthlist__16u0__p7_2, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__16u0__p7_2, - 0 -}; - -static const char _huff_lengthlist__16u0__single[] = { - 3, 5, 8, 7,14, 8, 9,19, 5, 2, 5, 5, 9, 6, 9,19, - 8, 4, 5, 7, 8, 9,13,19, 7, 4, 6, 5, 9, 6, 9,19, - 12, 8, 7, 9,10,11,13,19, 8, 5, 8, 6, 9, 6, 7,19, - 8, 8,10, 7, 7, 4, 5,19,12,17,19,15,18,13,11,18, -}; - -static const static_codebook _huff_book__16u0__single = { - 2, 64, - (char *)_huff_lengthlist__16u0__single, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__16u1__long[] = { - 3, 6,10, 8,12, 8,14, 8,14,19, 5, 3, 5, 5, 7, 6, - 11, 7,16,19, 7, 5, 6, 7, 7, 9,11,12,19,19, 6, 4, - 7, 5, 7, 6,10, 7,18,18, 8, 6, 7, 7, 7, 7, 8, 9, - 18,18, 7, 5, 8, 5, 7, 5, 8, 6,18,18,12, 9,10, 9, - 9, 9, 8, 9,18,18, 8, 7,10, 6, 8, 5, 6, 4,11,18, - 11,15,16,12,11, 8, 8, 6, 9,18,14,18,18,18,16,16, - 16,13,16,18, -}; - -static const static_codebook _huff_book__16u1__long = { - 2, 100, - (char *)_huff_lengthlist__16u1__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__16u1__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16u1__p1_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 8, 7, 7,10,10, 7, - 9,10, 5, 7, 8, 7,10, 9, 7,10,10, 5, 8, 8, 8,10, - 10, 8,10,10, 7,10,10,10,11,12,10,12,13, 7,10,10, - 9,13,11,10,12,13, 5, 8, 8, 8,10,10, 8,10,10, 7, - 10,10,10,12,12, 9,11,12, 7,10,11,10,12,12,10,13, - 11, -}; - -static const static_codebook _16u1__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__16u1__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__16u1__p1_0, - 0 -}; - -static const long _vq_quantlist__16u1__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16u1__p2_0[] = { - 3, 4, 4, 5, 6, 6, 5, 6, 6, 5, 6, 6, 6, 7, 8, 6, - 7, 8, 5, 6, 6, 6, 8, 7, 6, 8, 7, 5, 6, 6, 6, 8, - 8, 6, 8, 8, 6, 8, 8, 7, 7,10, 8, 9, 9, 6, 8, 8, - 7, 9, 8, 8, 9,10, 5, 6, 6, 6, 8, 8, 7, 8, 8, 6, - 8, 8, 8,10, 9, 7, 8, 9, 6, 8, 8, 8, 9, 9, 7,10, - 8, -}; - -static const static_codebook _16u1__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__16u1__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__16u1__p2_0, - 0 -}; - -static const long _vq_quantlist__16u1__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16u1__p3_0[] = { - 1, 5, 5, 8, 8, 6, 7, 7, 9, 9, 5, 7, 7, 9, 9, 9, - 10, 9,11,11, 9, 9,10,11,11, 6, 8, 8,10,10, 8, 9, - 10,11,11, 8, 9,10,11,11,10,11,11,12,13,10,11,11, - 13,13, 6, 8, 8,10,10, 8,10, 9,11,11, 8,10, 9,11, - 11,10,11,11,13,13,10,11,11,13,12, 9,11,11,14,13, - 10,12,12,15,14,10,12,11,14,13,12,13,13,15,15,12, - 13,13,16,14, 9,11,11,13,14,10,11,12,14,14,10,12, - 12,14,15,12,13,13,14,15,12,13,14,15,16, 5, 8, 8, - 11,11, 8,10,10,12,12, 8,10,10,12,12,11,12,12,14, - 14,11,12,12,14,14, 8,10,10,12,12, 9,11,12,12,13, - 10,12,12,13,13,12,12,13,14,15,11,13,13,15,15, 7, - 10,10,12,12, 9,12,11,13,12,10,11,12,13,13,12,13, - 12,15,14,11,12,13,15,15,10,12,12,15,14,11,13,13, - 16,15,11,13,13,16,15,14,13,14,15,16,13,15,15,17, - 17,10,12,12,14,15,11,12,12,15,15,11,13,13,15,16, - 13,15,13,16,15,13,15,15,16,17, 5, 8, 8,11,11, 8, - 10,10,12,12, 8,10,10,12,12,11,12,12,14,14,11,12, - 12,14,14, 7,10,10,12,12,10,12,12,14,13, 9,11,12, - 12,13,12,13,13,15,15,12,12,13,13,15, 7,10,10,12, - 13,10,11,12,13,13,10,12,11,13,13,11,13,13,15,15, - 12,13,12,15,14, 9,12,12,15,14,11,13,13,15,15,11, - 12,13,15,15,13,14,14,17,19,13,13,14,16,16,10,12, - 12,14,15,11,13,13,15,16,11,13,12,16,15,13,15,15, - 17,18,14,15,13,16,15, 8,11,11,15,14,10,12,12,16, - 15,10,12,12,16,16,14,15,15,18,17,13,14,15,16,18, - 9,12,12,15,15,11,12,14,16,17,11,13,13,16,15,15, - 15,15,17,18,14,15,16,17,17, 9,12,12,15,15,11,14, - 13,16,16,11,13,13,16,16,15,16,15,17,18,14,16,15, - 17,16,12,14,14,17,16,12,14,15,18,17,13,15,15,17, - 17,15,15,18,16,20,15,16,17,18,18,11,14,14,16,17, - 13,15,14,18,17,13,15,15,17,17,15,17,15,18,17,15, - 17,16,19,18, 8,11,11,14,15,10,12,12,15,15,10,12, - 12,16,16,13,14,14,17,16,14,15,15,17,17, 9,12,12, - 15,16,11,13,13,16,16,11,12,13,16,16,14,16,15,20, - 17,14,16,16,17,17, 9,12,12,15,16,11,13,13,16,17, - 11,13,13,17,16,14,15,15,17,18,15,15,15,18,18,11, - 14,14,17,16,13,15,15,17,17,13,14,14,18,17,15,16, - 16,18,19,15,15,17,17,19,11,14,14,16,17,13,15,14, - 17,19,13,15,14,18,17,15,17,16,18,18,15,17,15,18, - 16, -}; - -static const static_codebook _16u1__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__16u1__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16u1__p3_0, - 0 -}; - -static const long _vq_quantlist__16u1__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16u1__p4_0[] = { - 4, 5, 5, 8, 8, 6, 6, 7, 9, 9, 6, 6, 6, 9, 9, 9, - 10, 9,11,11, 9, 9,10,11,11, 6, 7, 7,10, 9, 7, 7, - 8, 9,10, 7, 7, 8,10,10,10,10,10,10,12, 9, 9,10, - 11,12, 6, 7, 7, 9, 9, 7, 8, 7,10,10, 7, 8, 7,10, - 10, 9,10, 9,12,11,10,10, 9,12,10, 9,10,10,12,11, - 10,10,10,12,12, 9,10,10,12,12,12,11,12,13,13,11, - 11,12,12,13, 9,10,10,11,12, 9,10,10,12,12,10,10, - 10,12,12,11,12,11,14,13,11,12,12,14,13, 5, 7, 7, - 10,10, 7, 8, 8,10,10, 7, 8, 7,10,10,10,10,10,12, - 12,10,10,10,12,12, 6, 8, 7,10,10, 7, 7, 9,10,11, - 8, 9, 9,11,10,10,10,11,11,13,10,10,11,12,13, 6, - 8, 8,10,10, 7, 9, 8,11,10, 8, 9, 9,10,11,10,11, - 10,13,11,10,11,10,12,12,10,11,10,12,11,10,10,10, - 12,13,10,11,11,13,12,11,11,13,11,14,12,12,13,14, - 14, 9,10,10,12,13,10,11,10,13,12,10,11,11,12,13, - 11,12,11,14,12,12,13,13,15,14, 5, 7, 7,10,10, 7, - 7, 8,10,10, 7, 8, 8,10,10,10,10,10,11,12,10,10, - 10,12,12, 7, 8, 8,10,10, 8, 9, 8,11,10, 7, 8, 9, - 10,11,10,11,11,12,12,10,10,11,11,13, 7, 7, 8,10, - 10, 8, 8, 9,10,11, 7, 9, 7,11,10,10,11,11,13,12, - 11,11,10,13,11, 9,10,10,12,12,10,11,11,13,12,10, - 10,11,12,12,12,13,13,14,14,11,11,12,12,14,10,10, - 11,12,12,10,11,11,12,13,10,10,10,13,12,12,13,13, - 15,14,12,13,10,14,11, 8,10,10,12,12,10,11,10,13, - 13, 9,10,10,12,12,12,13,13,15,14,11,12,12,13,13, - 9,10,10,13,12,10,10,11,13,13,10,11,10,13,12,12, - 12,13,14,15,12,13,12,15,13, 9,10,10,12,13,10,11, - 10,13,12,10,10,11,12,13,12,14,12,15,13,12,12,13, - 14,15,11,12,11,14,13,11,11,12,14,15,12,13,12,15, - 14,13,11,15,11,16,13,14,14,16,15,11,12,12,14,14, - 11,12,11,14,13,12,12,13,14,15,13,14,12,16,12,14, - 14,14,15,15, 8,10,10,12,12, 9,10,10,12,12,10,10, - 11,13,13,11,12,12,13,13,12,13,13,14,15, 9,10,10, - 13,12,10,11,11,13,12,10,10,11,13,13,12,13,12,15, - 14,12,12,13,13,16, 9, 9,10,12,13,10,10,11,12,13, - 10,11,10,13,13,12,12,13,13,15,13,13,12,15,13,11, - 12,12,14,14,12,13,12,15,14,11,11,12,13,14,14,14, - 14,16,15,13,12,15,12,16,11,11,12,13,14,12,13,13, - 14,15,10,12,11,14,13,14,15,14,16,16,13,14,11,15, - 11, -}; - -static const static_codebook _16u1__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__16u1__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16u1__p4_0, - 0 -}; - -static const long _vq_quantlist__16u1__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__16u1__p5_0[] = { - 1, 4, 4, 7, 7, 7, 7, 9, 9, 4, 6, 6, 8, 8, 8, 8, - 10,10, 4, 5, 6, 8, 8, 8, 8,10,10, 7, 8, 8, 9, 9, - 9, 9,11,11, 7, 8, 8, 9, 9, 9, 9,11,11, 7, 8, 8, - 10, 9,11,11,12,11, 7, 8, 8, 9, 9,11,11,12,12, 9, - 10,10,11,11,12,12,13,12, 9,10,10,11,11,12,12,12, - 13, -}; - -static const static_codebook _16u1__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__16u1__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__16u1__p5_0, - 0 -}; - -static const long _vq_quantlist__16u1__p6_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__16u1__p6_0[] = { - 3, 4, 4, 6, 6, 7, 7, 9, 9, 4, 4, 4, 6, 6, 8, 8, - 9, 9, 4, 4, 4, 6, 6, 7, 7, 9, 9, 6, 6, 6, 7, 7, - 8, 8,10, 9, 6, 6, 6, 7, 7, 8, 8, 9,10, 7, 8, 7, - 8, 8, 9, 9,10,10, 7, 8, 8, 8, 8, 9, 9,10,10, 9, - 9, 9,10,10,10,10,11,11, 9, 9, 9,10,10,10,10,11, - 11, -}; - -static const static_codebook _16u1__p6_0 = { - 2, 81, - (char *)_vq_lengthlist__16u1__p6_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__16u1__p6_0, - 0 -}; - -static const long _vq_quantlist__16u1__p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16u1__p7_0[] = { - 1, 4, 4, 4, 8, 8, 4, 8, 8, 5,11, 9, 8,12,11, 8, - 12,11, 5,10,11, 8,11,12, 8,11,12, 4,11,11,11,14, - 13,10,13,13, 8,14,13,12,14,16,12,16,15, 8,14,14, - 13,16,14,12,15,16, 4,11,11,10,14,13,11,14,14, 8, - 15,14,12,15,15,12,14,16, 8,14,14,11,16,15,12,15, - 13, -}; - -static const static_codebook _16u1__p7_0 = { - 4, 81, - (char *)_vq_lengthlist__16u1__p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__16u1__p7_0, - 0 -}; - -static const long _vq_quantlist__16u1__p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__16u1__p7_1[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8, 4, 6, 5, 7, 7, - 8, 8, 8, 8, 8, 8, 4, 5, 6, 7, 7, 8, 8, 8, 8, 8, - 8, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 6, 7, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 7, 8, 8, 8, 8, 9, 9, 9,10, - 9,10, 7, 8, 8, 8, 8, 9, 9, 9, 9,10, 9, 8, 8, 8, - 9, 9,10,10,10,10,10,10, 8, 8, 8, 9, 9, 9, 9,10, - 10,10,10, 8, 8, 8, 9, 9, 9,10,10,10,10,10, 8, 8, - 8, 9, 9,10,10,10,10,10,10, -}; - -static const static_codebook _16u1__p7_1 = { - 2, 121, - (char *)_vq_lengthlist__16u1__p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__16u1__p7_1, - 0 -}; - -static const long _vq_quantlist__16u1__p8_0[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__16u1__p8_0[] = { - 1, 4, 4, 5, 5, 8, 8,10,10,12,12, 4, 7, 7, 8, 8, - 9, 9,12,11,14,13, 4, 7, 7, 7, 8, 9,10,11,11,13, - 12, 5, 8, 8, 9, 9,11,11,12,13,15,14, 5, 7, 8, 9, - 9,11,11,13,13,17,15, 8, 9,10,11,11,12,13,17,14, - 17,16, 8,10, 9,11,11,12,12,13,15,15,17,10,11,11, - 12,13,14,15,15,16,16,17, 9,11,11,12,12,14,15,17, - 15,15,16,11,14,12,14,15,16,15,16,16,16,15,11,13, - 13,14,14,15,15,16,16,15,16, -}; - -static const static_codebook _16u1__p8_0 = { - 2, 121, - (char *)_vq_lengthlist__16u1__p8_0, - 1, -524582912, 1618345984, 4, 0, - (long *)_vq_quantlist__16u1__p8_0, - 0 -}; - -static const long _vq_quantlist__16u1__p8_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__16u1__p8_1[] = { - 2, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 4, 6, 6, 7, 7, - 8, 7, 8, 8, 8, 8, 4, 6, 6, 7, 7, 7, 7, 8, 8, 8, - 8, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 6, 7, 7, 7, - 7, 8, 8, 8, 8, 9, 9, 7, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 8, 8, 8, - 8, 8, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 8, 8, 8, 9, 8, 9, 9, 9, 9, 9, 9, 8, 8, - 8, 9, 9, 9, 9, 9, 9, 9, 9, -}; - -static const static_codebook _16u1__p8_1 = { - 2, 121, - (char *)_vq_lengthlist__16u1__p8_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__16u1__p8_1, - 0 -}; - -static const long _vq_quantlist__16u1__p9_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__16u1__p9_0[] = { - 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, -}; - -static const static_codebook _16u1__p9_0 = { - 2, 225, - (char *)_vq_lengthlist__16u1__p9_0, - 1, -514071552, 1627381760, 4, 0, - (long *)_vq_quantlist__16u1__p9_0, - 0 -}; - -static const long _vq_quantlist__16u1__p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__16u1__p9_1[] = { - 1, 6, 5, 9, 9,10,10, 6, 7, 9, 9,10,10,10,10, 5, - 10, 8,10, 8,10,10, 8, 8,10, 9,10,10,10,10, 5, 8, - 9,10,10,10,10, 8,10,10,10,10,10,10,10, 9,10,10, - 10,10,10,10, 9, 9,10,10,10,10,10,10, 9, 9, 8, 9, - 10,10,10, 9,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10, 8,10,10,10,10, - 10,10,10,10,10,10,10,10,10, 6, 8, 8,10,10,10, 8, - 10,10,10,10,10,10,10,10, 5, 8, 8,10,10,10, 9, 9, - 10,10,10,10,10,10,10,10, 9,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, -}; - -static const static_codebook _16u1__p9_1 = { - 2, 225, - (char *)_vq_lengthlist__16u1__p9_1, - 1, -522338304, 1620115456, 4, 0, - (long *)_vq_quantlist__16u1__p9_1, - 0 -}; - -static const long _vq_quantlist__16u1__p9_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__16u1__p9_2[] = { - 1, 6, 6, 7, 8, 8,11,10, 9, 9,11, 9,10, 9,11,11, - 9, 6, 7, 6,11, 8,11, 9,10,10,11, 9,11,10,10,10, - 11, 9, 5, 7, 7, 8, 8,10,11, 8, 8,11, 9, 9,10,11, - 9,10,11, 8, 9, 6, 8, 8, 9, 9,10,10,11,11,11, 9, - 11,10, 9,11, 8, 8, 8, 9, 8, 9,10,11, 9, 9,11,11, - 10, 9, 9,11,10, 8,11, 8, 9, 8,11, 9,10, 9,10,11, - 11,10,10, 9,10,10, 8, 8, 9,10,10,10, 9,11, 9,10, - 11,11,11,11,10, 9,11, 9, 9,11,11,10, 8,11,11,11, - 9,10,10,11,10,11,11, 9,11,10, 9,11,10,10,10,10, - 9,11,10,11,10, 9, 9,10,11, 9, 8,10,11,11,10,10, - 11, 9,11,10,11,11,10,11, 9, 9, 8,10, 8, 9,11, 9, - 8,10,10, 9,11,10,11,10,11, 9,11, 8,10,11,11,11, - 11,10,10,11,11,11,11,10,11,11,10, 9, 8,10,10, 9, - 11,10,11,11,11, 9, 9, 9,11,11,11,10,10, 9, 9,10, - 9,11,11,11,11, 8,10,11,10,11,11,10,11,11, 9, 9, - 9,10, 9,11, 9,11,11,11,11,11,10,11,11,10,11,10, - 11,11, 9,11,10,11,10, 9,10, 9,10,10,11,11,11,11, - 9,10, 9,10,11,11,10,11,11,11,11,11,11,10,11,11, - 10, -}; - -static const static_codebook _16u1__p9_2 = { - 2, 289, - (char *)_vq_lengthlist__16u1__p9_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__16u1__p9_2, - 0 -}; - -static const char _huff_lengthlist__16u1__short[] = { - 5, 7,10, 9,11,10,15,11,13,16, 6, 4, 6, 6, 7, 7, - 10, 9,12,16,10, 6, 5, 6, 6, 7,10,11,16,16, 9, 6, - 7, 6, 7, 7,10, 8,14,16,11, 6, 5, 4, 5, 6, 8, 9, - 15,16, 9, 6, 6, 5, 6, 6, 9, 8,14,16,12, 7, 6, 6, - 5, 6, 6, 7,13,16, 8, 6, 7, 6, 5, 5, 4, 4,11,16, - 9, 8, 9, 9, 7, 7, 6, 5,13,16,14,14,16,15,16,15, - 16,16,16,16, -}; - -static const static_codebook _huff_book__16u1__short = { - 2, 100, - (char *)_huff_lengthlist__16u1__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__16u2__long[] = { - 5, 8,10,10,10,11,11,12,14,18, 7, 5, 5, 6, 8, 9, - 10,12,14,17, 9, 5, 4, 5, 6, 8,10,11,13,19, 9, 5, - 4, 4, 5, 6, 9,10,12,17, 8, 6, 5, 4, 4, 5, 7,10, - 11,15, 8, 7, 7, 6, 5, 5, 6, 9,11,14, 8, 9, 8, 7, - 6, 5, 6, 7,11,14, 9,11,11, 9, 7, 6, 6, 6, 9,14, - 11,14,15,13, 9, 8, 7, 7, 9,14,13,15,19,17,12,11, - 10, 9,10,14, -}; - -static const static_codebook _huff_book__16u2__long = { - 2, 100, - (char *)_huff_lengthlist__16u2__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__16u2_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16u2_p1_0[] = { - 1, 5, 5, 5, 7, 7, 5, 7, 7, 5, 7, 7, 7, 9, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 8, 9, 9, 5, 7, 7, 8, 9, - 9, 7, 9, 9, 7, 9, 9, 9,10,11, 9,10,10, 7, 9, 9, - 9,10, 9, 9,10,11, 5, 8, 7, 7, 9, 9, 8, 9, 9, 7, - 9, 9, 9,11,10, 9, 9,10, 7, 9, 9, 9,10,10, 9,11, - 10, -}; - -static const static_codebook _16u2_p1_0 = { - 4, 81, - (char *)_vq_lengthlist__16u2_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__16u2_p1_0, - 0 -}; - -static const long _vq_quantlist__16u2_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16u2_p2_0[] = { - 3, 5, 5, 8, 8, 5, 7, 7, 9, 9, 5, 7, 7, 9, 9, 9, - 10, 9,11,11, 9, 9, 9,11,11, 5, 7, 7, 9, 9, 7, 8, - 8,10,10, 7, 8, 8,10,10,10,10,10,12,12, 9,10,10, - 11,12, 5, 7, 7, 9, 9, 7, 8, 8,10,10, 7, 8, 8,10, - 10, 9,10,10,12,11,10,10,10,12,12, 9,10,10,12,12, - 10,10,10,12,12, 9,10,10,12,12,12,12,12,14,14,11, - 12,12,13,14, 9,10,10,12,12, 9,10,10,12,12,10,10, - 10,12,12,11,12,12,14,13,12,12,12,14,13, 5, 7, 7, - 9, 9, 7, 8, 8,10,10, 7, 8, 8,10,10,10,10,10,12, - 12,10,10,10,12,12, 7, 8, 8,11,10, 8, 9, 9,11,11, - 8, 9, 9,11,11,10,11,11,12,13,10,11,11,12,13, 7, - 8, 8,10,10, 8, 9, 8,11,10, 8, 9, 9,11,11,10,11, - 10,13,12,10,11,11,13,13,10,11,10,13,12,10,11,11, - 13,13,10,11,11,13,13,12,12,13,13,14,12,13,13,14, - 14, 9,10,10,12,12,10,11,10,13,12,10,11,11,13,13, - 12,13,12,14,13,12,13,13,14,15, 5, 7, 7, 9,10, 7, - 8, 8,10,10, 7, 8, 8,10,10,10,10,10,12,12,10,10, - 11,12,12, 7, 8, 8,10,10, 8, 9, 9,11,11, 8, 8, 9, - 10,11,10,11,11,13,13,10,10,11,12,13, 7, 8, 8,10, - 10, 8, 9, 9,11,11, 8, 9, 9,11,11,10,11,11,13,12, - 10,11,11,13,12, 9,10,10,12,12,10,11,11,13,13,10, - 10,11,12,13,12,13,13,15,14,12,12,13,12,14, 9,10, - 11,12,13,10,11,11,13,13,10,11,11,13,13,12,13,13, - 14,14,12,13,12,14,13, 8,10,10,12,12, 9,11,10,13, - 12, 9,10,10,12,13,12,13,13,14,14,12,12,12,14,14, - 9,10,10,13,13,10,11,11,13,13,10,11,11,13,13,13, - 13,13,14,15,12,13,13,14,15, 9,10,10,12,13,10,11, - 10,13,13,10,11,11,12,13,12,13,12,15,14,12,13,13, - 14,15,11,12,12,15,14,12,12,13,14,15,12,13,13,15, - 14,13,13,15,14,16,14,14,14,16,15,11,12,12,14,14, - 11,12,12,14,14,12,13,13,14,15,13,14,13,15,13,14, - 14,14,15,16, 8, 9,10,12,12, 9,10,10,13,12, 9,10, - 11,12,13,12,12,12,14,14,12,13,13,14,14, 9,10,10, - 13,12,10,11,11,13,13,10,10,11,13,13,12,13,13,15, - 14,12,12,13,14,15, 9,10,10,13,13,10,11,11,13,13, - 10,11,11,13,13,12,13,13,14,14,13,13,13,15,15,11, - 12,12,14,13,12,13,13,15,14,11,12,12,14,14,14,14, - 14,16,15,13,13,14,13,16,11,12,12,14,14,12,13,13, - 14,15,12,13,12,14,14,14,14,14,16,16,14,15,13,16, - 14, -}; - -static const static_codebook _16u2_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__16u2_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16u2_p2_0, - 0 -}; - -static const long _vq_quantlist__16u2_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__16u2_p3_0[] = { - 2, 4, 4, 6, 6, 7, 7, 9, 9, 4, 5, 5, 6, 6, 8, 7, - 9, 9, 4, 5, 5, 6, 6, 7, 8, 9, 9, 6, 6, 6, 7, 7, - 8, 8,10,10, 6, 6, 6, 7, 7, 8, 8,10,10, 7, 8, 7, - 8, 8, 9, 9,11,10, 7, 7, 8, 8, 8, 9, 9,10,11, 9, - 9, 9,10,10,11,10,11,11, 9, 9, 9,10,10,10,11,11, - 11, -}; - -static const static_codebook _16u2_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__16u2_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__16u2_p3_0, - 0 -}; - -static const long _vq_quantlist__16u2_p4_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__16u2_p4_0[] = { - 2, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11,11,11, - 11, 5, 5, 5, 7, 6, 8, 7, 9, 9, 9, 9,10,10,11,11, - 12,12, 5, 5, 5, 6, 6, 7, 8, 8, 9, 9, 9,10,10,11, - 11,12,12, 6, 7, 6, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,12,12, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,12,12, 7, 8, 8, 8, 8, 9, 9, 9, 9,10,10, - 11,11,11,11,12,12, 7, 7, 8, 8, 8, 9, 9, 9, 9,10, - 10,11,11,11,11,12,12, 8, 9, 9, 9, 9, 9, 9,10,10, - 10,10,11,11,12,12,12,12, 8, 9, 9, 9, 9, 9, 9,10, - 10,10,10,11,11,12,12,12,12, 9, 9, 9, 9, 9,10,10, - 10,10,10,11,11,11,12,12,13,13, 9, 9, 9, 9, 9,10, - 10,10,10,11,10,11,11,12,12,13,13,10,10,10,10,10, - 11,11,11,11,11,11,11,12,12,12,13,13,10,10,10,10, - 10,11,11,11,11,11,11,12,11,12,12,13,13,11,11,11, - 11,11,11,11,12,12,12,12,12,12,13,13,13,13,11,11, - 11,11,11,11,11,12,12,12,12,13,12,13,13,13,13,11, - 12,12,12,12,12,12,12,12,13,13,13,13,13,13,14,14, - 11,12,12,12,12,12,12,12,13,13,13,13,13,13,13,14, - 14, -}; - -static const static_codebook _16u2_p4_0 = { - 2, 289, - (char *)_vq_lengthlist__16u2_p4_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__16u2_p4_0, - 0 -}; - -static const long _vq_quantlist__16u2_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__16u2_p5_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 8, 8, 7, 9, 9, 7, - 9,10, 5, 8, 8, 7,10, 9, 7,10, 9, 5, 8, 8, 8,11, - 10, 8,10,10, 7,10,10, 9, 9,12,10,12,12, 7,10,10, - 9,12,10,10,11,12, 5, 8, 8, 8,10,10, 8,11,11, 7, - 11,10,10,12,11, 9,10,12, 7,10,11,10,12,12, 9,12, - 9, -}; - -static const static_codebook _16u2_p5_0 = { - 4, 81, - (char *)_vq_lengthlist__16u2_p5_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__16u2_p5_0, - 0 -}; - -static const long _vq_quantlist__16u2_p5_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__16u2_p5_1[] = { - 2, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 5, 6, 6, 7, 7, - 7, 7, 8, 8, 8, 8, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, - 8, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 6, 7, 7, 7, - 7, 8, 8, 8, 8, 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, - 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 9, 9, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, 9, -}; - -static const static_codebook _16u2_p5_1 = { - 2, 121, - (char *)_vq_lengthlist__16u2_p5_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__16u2_p5_1, - 0 -}; - -static const long _vq_quantlist__16u2_p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__16u2_p6_0[] = { - 1, 5, 4, 7, 7, 8, 8, 8, 8,10,10,11,11, 4, 6, 6, - 7, 7, 9, 9, 9, 9,10,10,11,11, 4, 6, 6, 7, 7, 9, - 9, 9, 9,10,10,11,11, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,12,12, 7, 7, 7, 9, 8,10, 9,10,10,11,11,12, - 12, 8, 9, 9, 9,10,10,10,11,11,12,12,13,13, 8, 9, - 9,10, 9,10,10,11,11,12,12,13,13, 8, 9, 9,10,10, - 11,11,11,11,12,12,13,13, 8, 9, 9,10,10,11,11,12, - 11,12,12,13,13,10,10,10,11,11,12,12,12,12,13,13, - 14,14,10,10,10,11,11,12,12,12,12,13,13,14,14,11, - 11,11,12,12,13,13,13,13,14,14,14,14,11,11,11,12, - 12,13,13,13,13,14,14,14,14, -}; - -static const static_codebook _16u2_p6_0 = { - 2, 169, - (char *)_vq_lengthlist__16u2_p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__16u2_p6_0, - 0 -}; - -static const long _vq_quantlist__16u2_p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__16u2_p6_1[] = { - 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _16u2_p6_1 = { - 2, 25, - (char *)_vq_lengthlist__16u2_p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__16u2_p6_1, - 0 -}; - -static const long _vq_quantlist__16u2_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__16u2_p7_0[] = { - 1, 4, 4, 7, 7, 8, 8, 8, 8, 9, 9,10,10, 4, 6, 6, - 8, 8, 9, 9, 9, 9,10,10,11,10, 4, 6, 6, 8, 8, 9, - 9, 9, 9,10,10,11,11, 7, 8, 8,10, 9,10,10,10,10, - 11,11,12,12, 7, 8, 8,10,10,10,10,10,10,11,11,12, - 12, 8, 9, 9,10,10,11,11,11,11,12,12,13,13, 8, 9, - 9,10,10,11,11,11,11,12,12,13,13, 8, 9, 9,11,10, - 11,11,12,12,13,13,14,13, 8, 9, 9,10,10,11,11,12, - 12,13,13,13,13, 9,10,10,11,11,12,12,13,13,13,13, - 14,14, 9,10,10,11,11,12,12,13,13,13,13,14,14,10, - 11,11,12,12,13,13,14,13,14,14,15,14,10,11,11,12, - 12,13,13,14,13,14,14,15,14, -}; - -static const static_codebook _16u2_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__16u2_p7_0, - 1, -523206656, 1618345984, 4, 0, - (long *)_vq_quantlist__16u2_p7_0, - 0 -}; - -static const long _vq_quantlist__16u2_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__16u2_p7_1[] = { - 2, 5, 5, 7, 7, 7, 7, 7, 7, 8, 8, 5, 6, 6, 7, 7, - 7, 7, 8, 8, 8, 8, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, - 8, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, - 7, 8, 8, 8, 8, 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, - 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _16u2_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__16u2_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__16u2_p7_1, - 0 -}; - -static const long _vq_quantlist__16u2_p8_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__16u2_p8_0[] = { - 1, 4, 4, 7, 7, 8, 8, 7, 7, 9, 8,10, 9,11,11, 4, - 7, 6, 9, 8, 9, 9, 9, 9,10, 9,11, 9,12, 9, 4, 6, - 7, 8, 8, 9, 9, 9, 9,10,10,10,11,11,12, 7, 9, 8, - 10,10,11,11,10,10,11,11,12,12,13,12, 7, 8, 8,10, - 10,10,11,10,10,11,11,11,12,12,13, 8, 9, 9,11,11, - 11,11,11,11,12,12,13,13,13,13, 8, 9, 9,11,11,11, - 11,11,11,12,12,13,13,13,14, 8, 9, 9,10,10,11,11, - 12,11,13,13,14,13,14,14, 8, 9, 9,10,10,11,11,12, - 12,12,12,13,13,14,14, 9,10,10,11,11,12,12,13,12, - 13,13,14,14,15,15, 9,10,10,11,11,12,12,12,13,13, - 13,14,14,14,15,10,11,11,12,12,13,13,14,13,14,14, - 15,14,15,15,10,11,11,12,12,13,12,13,14,14,14,14, - 14,15,15,11,12,12,13,13,13,13,14,14,15,14,15,15, - 16,16,11,12,12,13,13,13,13,14,14,14,15,15,15,16, - 16, -}; - -static const static_codebook _16u2_p8_0 = { - 2, 225, - (char *)_vq_lengthlist__16u2_p8_0, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__16u2_p8_0, - 0 -}; - -static const long _vq_quantlist__16u2_p8_1[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__16u2_p8_1[] = { - 3, 5, 5, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10,10, 5, 6, 6, 7, 7, 8, - 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, - 7, 7, 8, 8, 9, 8, 9, 9, 9, 9, 9, 9,10,10,10,10, - 10,10,10,10, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, - 9,10, 9,10,10,10, 9,10, 9, 8, 8, 8, 9, 8, 9, 9, - 9, 9,10, 9,10,10,10,10,10,10,10,10,10,10, 8, 8, - 8, 8, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10, - 10,10,10, 8, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10, - 10,10,10,10,10,10,10,10, 8, 9, 9, 9, 9, 9, 9, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, - 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10, 9, 9, 9, 9, 9,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, - 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10, 9, 9, 9,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10, 9, 9,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10, 9,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10, 9,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10, 9,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _16u2_p8_1 = { - 2, 441, - (char *)_vq_lengthlist__16u2_p8_1, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__16u2_p8_1, - 0 -}; - -static const long _vq_quantlist__16u2_p9_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__16u2_p9_0[] = { - 1, 5, 3, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5, - 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5, 7, - 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _16u2_p9_0 = { - 2, 225, - (char *)_vq_lengthlist__16u2_p9_0, - 1, -510036736, 1631393792, 4, 0, - (long *)_vq_quantlist__16u2_p9_0, - 0 -}; - -static const long _vq_quantlist__16u2_p9_1[] = { - 9, - 8, - 10, - 7, - 11, - 6, - 12, - 5, - 13, - 4, - 14, - 3, - 15, - 2, - 16, - 1, - 17, - 0, - 18, -}; - -static const char _vq_lengthlist__16u2_p9_1[] = { - 1, 4, 4, 7, 7, 7, 7, 7, 6, 9, 7,10, 8,12,12,13, - 13,14,14, 4, 7, 7, 9, 9, 9, 8, 9, 8,10, 9,11, 9, - 14, 9,14,10,13,11, 4, 7, 7, 9, 9, 9, 9, 8, 9,10, - 10,11,11,12,13,12,13,14,15, 7, 9, 9,10,11,10,10, - 10,10,11,12,13,13,13,14,17,14,15,16, 7, 9, 9,10, - 10,10,10,10,10,11,12,13,13,14,14,15,15,18,18, 8, - 9, 9,11,10,11,11,11,12,13,12,14,14,16,15,15,17, - 18,15, 8, 9, 9,10,10,11,11,11,11,13,13,14,14,15, - 15,15,16,16,18, 7, 9, 8,10,10,11,11,12,12,14,14, - 15,15,16,16,15,17,16,18, 8, 9, 9,10,10,11,12,12, - 12,13,13,16,15,17,16,17,18,17,18, 9,10,10,12,11, - 13,13,14,13,14,14,15,17,16,18,17,18,17,18, 9,10, - 10,12,11,12,13,13,14,15,16,14,15,16,18,18,18,18, - 17,11,11,11,13,13,14,14,16,15,15,15,16,15,15,18, - 18,18,17,16,11,11,12,13,13,15,14,15,16,16,16,17, - 16,15,18,17,18,16,18,12,13,13,15,15,15,16,18,16, - 17,16,17,16,17,17,17,18,18,17,13,13,13,15,13,16, - 15,17,16,16,16,18,18,18,18,16,17,17,18,13,15,14, - 15,15,18,17,18,18,18,16,18,17,18,17,18,16,17,17, - 14,14,14,15,16,17,16,18,18,18,17,18,17,18,18,18, - 16,16,16,14,17,16,17,15,16,18,18,17,18,17,18,17, - 18,18,18,17,18,17,15,16,15,18,15,18,17,16,18,18, - 18,18,18,18,17,18,16,18,17, -}; - -static const static_codebook _16u2_p9_1 = { - 2, 361, - (char *)_vq_lengthlist__16u2_p9_1, - 1, -518287360, 1622704128, 5, 0, - (long *)_vq_quantlist__16u2_p9_1, - 0 -}; - -static const long _vq_quantlist__16u2_p9_2[] = { - 24, - 23, - 25, - 22, - 26, - 21, - 27, - 20, - 28, - 19, - 29, - 18, - 30, - 17, - 31, - 16, - 32, - 15, - 33, - 14, - 34, - 13, - 35, - 12, - 36, - 11, - 37, - 10, - 38, - 9, - 39, - 8, - 40, - 7, - 41, - 6, - 42, - 5, - 43, - 4, - 44, - 3, - 45, - 2, - 46, - 1, - 47, - 0, - 48, -}; - -static const char _vq_lengthlist__16u2_p9_2[] = { - 2, 3, 4, 4, 4, 5, 5, 6, 5, 6, 6, 6, 6, 6, 6, 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, 8, 8, 7, 8, 8, 8, 8, 8, - 8, -}; - -static const static_codebook _16u2_p9_2 = { - 1, 49, - (char *)_vq_lengthlist__16u2_p9_2, - 1, -526909440, 1611661312, 6, 0, - (long *)_vq_quantlist__16u2_p9_2, - 0 -}; - -static const char _huff_lengthlist__16u2__short[] = { - 8,11,13,13,15,16,19,19,19,19,11, 8, 8, 9, 9,11, - 13,15,19,20,14, 8, 7, 7, 8, 9,12,13,15,20,15, 9, - 6, 5, 5, 7,10,12,14,18,14, 9, 7, 5, 3, 4, 7,10, - 12,16,13,10, 8, 6, 3, 3, 5, 8,11,14,11,10, 9, 7, - 5, 4, 4, 6,11,14,10,10,10, 8, 6, 5, 5, 6,10,14, - 10,10,10, 9, 8, 7, 7, 7,10,14,11,12,12,12,11,10, - 10,10,12,16, -}; - -static const static_codebook _huff_book__16u2__short = { - 2, 100, - (char *)_huff_lengthlist__16u2__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__8u0__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8u0__p1_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 8, 8, 8,10,10, 7, - 10,10, 5, 8, 8, 7,10,10, 8,10,10, 4, 9, 8, 8,11, - 11, 8,11,11, 7,11,11,10,11,13,10,13,13, 7,11,11, - 10,13,12,10,13,13, 5, 9, 8, 8,11,11, 8,11,11, 7, - 11,11, 9,13,13,10,12,13, 7,11,11,10,13,13,10,13, - 11, -}; - -static const static_codebook _8u0__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__8u0__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__8u0__p1_0, - 0 -}; - -static const long _vq_quantlist__8u0__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8u0__p2_0[] = { - 2, 4, 4, 5, 6, 6, 5, 6, 6, 5, 7, 7, 6, 7, 8, 6, - 7, 8, 5, 7, 7, 6, 8, 8, 7, 9, 7, 5, 7, 7, 7, 9, - 9, 7, 8, 8, 6, 9, 8, 7, 7,10, 8,10,10, 6, 8, 8, - 8,10, 8, 8,10,10, 5, 7, 7, 7, 8, 8, 7, 8, 9, 6, - 8, 8, 8,10,10, 8, 8,10, 6, 8, 9, 8,10,10, 7,10, - 8, -}; - -static const static_codebook _8u0__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__8u0__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__8u0__p2_0, - 0 -}; - -static const long _vq_quantlist__8u0__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__8u0__p3_0[] = { - 1, 5, 5, 7, 7, 6, 7, 7, 9, 9, 6, 7, 7, 9, 9, 8, - 10, 9,11,11, 8, 9, 9,11,11, 6, 8, 8,10,10, 8,10, - 10,11,11, 8,10,10,11,11,10,11,11,12,12,10,11,11, - 12,13, 6, 8, 8,10,10, 8,10,10,11,11, 8,10,10,11, - 11, 9,10,11,12,12,10,11,11,12,12, 8,11,11,14,13, - 10,12,11,15,13,10,12,11,14,14,12,13,12,16,14,12, - 14,12,16,15, 8,11,11,13,14,10,11,12,13,15,10,11, - 12,13,15,11,12,13,14,15,12,12,14,14,16, 5, 8, 8, - 11,11, 9,11,11,12,12, 8,10,11,12,12,11,12,12,15, - 14,11,12,12,14,14, 7,11,10,13,12,10,11,12,13,14, - 10,12,12,14,13,12,13,13,14,15,12,13,13,15,15, 7, - 10,11,12,13,10,12,11,14,13,10,12,13,13,15,12,13, - 12,14,14,11,13,13,15,16, 9,12,12,15,14,11,13,13, - 15,16,11,13,13,16,16,13,14,15,15,15,12,14,15,17, - 16, 9,12,12,14,15,11,13,13,15,16,11,13,13,16,18, - 13,14,14,17,16,13,15,15,17,18, 5, 8, 9,11,11, 8, - 11,11,12,12, 8,10,11,12,12,11,12,12,14,14,11,12, - 12,14,15, 7,11,10,12,13,10,12,12,14,13,10,11,12, - 13,14,11,13,13,15,14,12,13,13,14,15, 7,10,11,13, - 13,10,12,12,13,14,10,12,12,13,13,11,13,13,16,16, - 12,13,13,15,14, 9,12,12,16,15,10,13,13,15,15,11, - 13,13,17,15,12,15,15,18,17,13,14,14,15,16, 9,12, - 12,15,15,11,13,13,15,16,11,13,13,15,15,12,15,15, - 16,16,13,15,14,17,15, 7,11,11,15,15,10,13,13,16, - 15,10,13,13,15,16,14,15,15,17,19,13,15,14,15,18, - 9,12,12,16,16,11,13,14,17,16,11,13,13,17,16,15, - 15,16,17,19,13,15,16, 0,18, 9,12,12,16,15,11,14, - 13,17,17,11,13,14,16,16,15,16,16,19,18,13,15,15, - 17,19,11,14,14,19,16,12,14,15, 0,18,12,16,15,18, - 17,15,15,18,16,19,14,15,17,19,19,11,14,14,18,19, - 13,15,14,19,19,12,16,15,18,17,15,17,15, 0,16,14, - 17,16,19, 0, 7,11,11,14,14,10,12,12,15,15,10,13, - 13,16,15,13,15,15,17, 0,14,15,15,16,19, 9,12,12, - 16,16,11,14,14,16,16,11,13,13,16,16,14,17,16,19, - 0,14,18,17,17,19, 9,12,12,15,16,11,13,13,15,17, - 12,14,13,19,16,13,15,15,17,19,15,17,16,17,19,11, - 14,14,19,16,12,15,15,19,17,13,14,15,17,19,14,16, - 17,19,19,16,15,16,17,19,11,15,14,16,16,12,15,15, - 19, 0,12,14,15,19,19,14,16,16, 0,18,15,19,14,18, - 16, -}; - -static const static_codebook _8u0__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__8u0__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__8u0__p3_0, - 0 -}; - -static const long _vq_quantlist__8u0__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__8u0__p4_0[] = { - 3, 5, 5, 8, 8, 5, 6, 7, 9, 9, 6, 7, 6, 9, 9, 9, - 9, 9,10,11, 9, 9, 9,11,10, 6, 7, 7,10,10, 7, 7, - 8,10,10, 7, 8, 8,10,10,10,10,10,10,11, 9,10,10, - 11,12, 6, 7, 7,10,10, 7, 8, 8,10,10, 7, 8, 7,10, - 10, 9,10,10,12,11,10,10,10,11,10, 9,10,10,12,11, - 10,10,10,13,11, 9,10,10,12,12,11,11,12,12,13,11, - 11,11,12,13, 9,10,10,12,12,10,10,11,12,12,10,10, - 11,12,12,11,11,11,13,13,11,12,12,13,13, 5, 7, 7, - 10,10, 7, 8, 8,10,10, 7, 8, 8,10,10,10,11,11,12, - 12,10,11,10,12,12, 7, 8, 8,11,11, 7, 8, 9,10,11, - 8, 9, 9,11,11,11,10,11,10,12,10,11,11,12,13, 7, - 8, 8,10,11, 8, 9, 8,12,10, 8, 9, 9,11,12,10,11, - 10,13,11,10,11,11,13,12, 9,11,10,13,12,10,10,11, - 12,12,10,11,11,13,13,12,10,13,11,14,11,12,12,15, - 13, 9,11,11,13,13,10,11,11,13,12,10,11,11,12,14, - 12,13,11,14,12,12,12,12,14,14, 5, 7, 7,10,10, 7, - 8, 8,10,10, 7, 8, 8,11,10,10,11,11,12,12,10,11, - 10,12,12, 7, 8, 8,10,11, 8, 9, 9,12,11, 8, 8, 9, - 10,11,10,11,11,12,13,11,10,11,11,13, 6, 8, 8,10, - 11, 8, 9, 9,11,11, 7, 9, 7,11,10,10,11,11,12,12, - 10,11,10,13,10, 9,11,10,13,12,10,12,11,13,13,10, - 10,11,12,13,11,12,13,15,14,11,11,13,12,13, 9,10, - 11,12,13,10,11,11,12,13,10,11,10,13,12,12,13,13, - 13,14,12,12,11,14,11, 8,10,10,12,13,10,11,11,13, - 13,10,11,10,13,13,12,13,14,15,14,12,12,12,14,13, - 9,10,10,13,12,10,10,12,13,13,10,11,11,15,12,12, - 12,13,15,14,12,13,13,15,13, 9,10,11,12,13,10,12, - 10,13,12,10,11,11,12,13,12,14,12,15,13,12,12,12, - 15,14,11,12,11,14,13,11,11,12,14,14,12,13,13,14, - 13,13,11,15,11,15,14,14,14,16,15,11,12,12,13,14, - 11,13,11,14,14,12,12,13,14,15,12,14,12,15,12,13, - 15,14,16,15, 8,10,10,12,12,10,10,10,12,13,10,11, - 11,13,13,12,12,12,13,14,13,13,13,15,15, 9,10,10, - 12,12,10,11,11,13,12,10,10,11,13,13,12,12,12,14, - 14,12,12,13,15,14, 9,10,10,13,12,10,10,12,12,13, - 10,11,10,13,13,12,13,13,14,14,12,13,12,14,13,11, - 12,12,14,13,12,13,12,14,14,10,12,12,14,14,14,14, - 14,16,14,13,12,14,12,15,10,12,12,14,15,12,13,13, - 14,16,11,12,11,15,14,13,14,14,14,15,13,14,11,14, - 12, -}; - -static const static_codebook _8u0__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__8u0__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__8u0__p4_0, - 0 -}; - -static const long _vq_quantlist__8u0__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__8u0__p5_0[] = { - 1, 4, 4, 7, 7, 7, 7, 9, 9, 4, 6, 6, 8, 7, 8, 8, - 10,10, 4, 6, 6, 8, 8, 8, 8,10,10, 6, 8, 8, 9, 9, - 9, 9,11,11, 7, 8, 8, 9, 9, 9, 9,11,11, 7, 8, 8, - 9, 9,10,10,12,11, 7, 8, 8, 9, 9,10,10,11,11, 9, - 10,10,11,11,11,12,12,12, 9,10,10,11,11,12,12,12, - 12, -}; - -static const static_codebook _8u0__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__8u0__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__8u0__p5_0, - 0 -}; - -static const long _vq_quantlist__8u0__p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__8u0__p6_0[] = { - 1, 4, 4, 7, 7, 9, 9,11,11,12,12,16,16, 3, 6, 6, - 9, 9,11,11,12,12,13,14,18,16, 3, 6, 7, 9, 9,11, - 11,13,12,14,14,17,16, 7, 9, 9,11,11,12,12,14,14, - 14,14,17,16, 7, 9, 9,11,11,13,12,13,13,14,14,17, - 0, 9,11,11,12,13,14,14,14,13,15,14,17,17, 9,11, - 11,12,12,14,14,13,14,14,15, 0, 0,11,12,12,15,14, - 15,14,15,14,15,16,17, 0,11,12,13,13,13,14,14,15, - 14,15,15, 0, 0,12,14,14,15,15,14,16,15,15,17,16, - 0,18,13,14,14,15,14,15,14,15,16,17,16, 0, 0,17, - 17,18, 0,16,18,16, 0, 0, 0,17, 0, 0,16, 0, 0,16, - 16, 0,15, 0,17, 0, 0, 0, 0, -}; - -static const static_codebook _8u0__p6_0 = { - 2, 169, - (char *)_vq_lengthlist__8u0__p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__8u0__p6_0, - 0 -}; - -static const long _vq_quantlist__8u0__p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__8u0__p6_1[] = { - 1, 4, 4, 6, 6, 4, 6, 5, 7, 7, 4, 5, 6, 7, 7, 6, - 7, 7, 7, 7, 6, 7, 7, 7, 7, -}; - -static const static_codebook _8u0__p6_1 = { - 2, 25, - (char *)_vq_lengthlist__8u0__p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__8u0__p6_1, - 0 -}; - -static const long _vq_quantlist__8u0__p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8u0__p7_0[] = { - 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 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, 7, 7, 7, 7, 7, 7, 7, - 7, -}; - -static const static_codebook _8u0__p7_0 = { - 4, 81, - (char *)_vq_lengthlist__8u0__p7_0, - 1, -518803456, 1628680192, 2, 0, - (long *)_vq_quantlist__8u0__p7_0, - 0 -}; - -static const long _vq_quantlist__8u0__p7_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__8u0__p7_1[] = { - 1, 5, 5, 5, 5,10,10,11,11,11,11,11,11,11,11, 5, - 7, 6, 8, 8, 9,10,11,11,11,11,11,11,11,11, 6, 6, - 7, 9, 7,11,10,11,11,11,11,11,11,11,11, 5, 6, 6, - 11, 8,11,11,11,11,11,11,11,11,11,11, 5, 6, 6, 9, - 10,11,10,11,11,11,11,11,11,11,11, 7,10,10,11,11, - 11,11,11,11,11,11,11,11,11,11, 7,11, 8,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _8u0__p7_1 = { - 2, 225, - (char *)_vq_lengthlist__8u0__p7_1, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__8u0__p7_1, - 0 -}; - -static const long _vq_quantlist__8u0__p7_2[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__8u0__p7_2[] = { - 1, 6, 5, 7, 7, 9, 9, 9, 9,10,12,12,10,11,11,10, - 11,11,11,10,11, 6, 8, 8, 9, 9,10,10, 9,10,11,11, - 10,11,11,11,11,10,11,11,11,11, 6, 7, 8, 9, 9, 9, - 10,11,10,11,12,11,10,11,11,11,11,11,11,12,10, 8, - 9, 9,10, 9,10,10, 9,10,10,10,10,10, 9,10,10,10, - 10, 9,10,10, 9, 9, 9, 9,10,10, 9, 9,10,10,11,10, - 9,12,10,11,10, 9,10,10,10, 8, 9, 9,10, 9,10, 9, - 9,10,10, 9,10, 9,11,10,10,10,10,10, 9,10, 8, 8, - 9, 9,10, 9,11, 9, 8, 9, 9,10,11,10,10,10,11,12, - 9, 9,11, 8, 9, 8,11,10,11,10,10, 9,11,10,10,10, - 10,10,10,10,11,11,11,11, 8, 9, 9, 9,10,10,10,11, - 11,12,11,12,11,10,10,10,12,11,11,11,10, 8,10, 9, - 11,10,10,11,12,10,11,12,11,11,12,11,12,12,10,11, - 11,10, 9, 9,10,11,12,10,10,10,11,10,11,11,10,12, - 12,10,11,10,11,12,10, 9,10,10,11,10,11,11,11,11, - 11,12,11,11,11, 9,11,10,11,10,11,10, 9, 9,10,11, - 11,11,10,10,11,12,12,11,12,11,11,11,12,12,12,12, - 11, 9,11,11,12,10,11,11,11,11,11,11,12,11,11,12, - 11,11,11,10,11,11, 9,11,10,11,11,11,10,10,10,11, - 11,11,12,10,11,10,11,11,11,11,12, 9,11,10,11,11, - 10,10,11,11, 9,11,11,12,10,10,10,10,10,11,11,10, - 9,10,11,11,12,11,10,10,12,11,11,12,11,12,11,11, - 10,10,11,11,10,12,11,10,11,10,11,10,10,10,11,11, - 10,10,11,11,11,11,10,10,10,12,11,11,11,11,10, 9, - 10,11,11,11,12,11,11,11,12,10,11,11,11, 9,10,11, - 11,11,11,11,11,10,10,11,11,12,11,10,11,12,11,10, - 10,11, 9,10,11,11,11,11,11,10,11,11,10,12,11,11, - 11,12,11,11,11,10,10,11,11, -}; - -static const static_codebook _8u0__p7_2 = { - 2, 441, - (char *)_vq_lengthlist__8u0__p7_2, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__8u0__p7_2, - 0 -}; - -static const char _huff_lengthlist__8u0__single[] = { - 4, 7,11, 9,12, 8, 7,10, 6, 4, 5, 5, 7, 5, 6,16, - 9, 5, 5, 6, 7, 7, 9,16, 7, 4, 6, 5, 7, 5, 7,17, - 10, 7, 7, 8, 7, 7, 8,18, 7, 5, 6, 4, 5, 4, 5,15, - 7, 6, 7, 5, 6, 4, 5,15,12,13,18,12,17,11, 9,17, -}; - -static const static_codebook _huff_book__8u0__single = { - 2, 64, - (char *)_huff_lengthlist__8u0__single, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__8u1__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8u1__p1_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 8, 8, 7, 9,10, 7, - 9, 9, 5, 8, 8, 7,10, 9, 7, 9, 9, 5, 8, 8, 8,10, - 10, 8,10,10, 7,10,10, 9,10,12,10,12,12, 7,10,10, - 9,12,11,10,12,12, 5, 8, 8, 8,10,10, 8,10,10, 7, - 10,10,10,12,12, 9,11,12, 7,10,10,10,12,12, 9,12, - 10, -}; - -static const static_codebook _8u1__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__8u1__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__8u1__p1_0, - 0 -}; - -static const long _vq_quantlist__8u1__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8u1__p2_0[] = { - 3, 4, 5, 5, 6, 6, 5, 6, 6, 5, 7, 6, 6, 7, 8, 6, - 7, 8, 5, 6, 6, 6, 8, 7, 6, 8, 7, 5, 6, 6, 7, 8, - 8, 6, 7, 7, 6, 8, 7, 7, 7, 9, 8, 9, 9, 6, 7, 8, - 7, 9, 7, 8, 9, 9, 5, 6, 6, 6, 7, 7, 7, 8, 8, 6, - 8, 7, 8, 9, 9, 7, 7, 9, 6, 7, 8, 8, 9, 9, 7, 9, - 7, -}; - -static const static_codebook _8u1__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__8u1__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__8u1__p2_0, - 0 -}; - -static const long _vq_quantlist__8u1__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__8u1__p3_0[] = { - 1, 5, 5, 7, 7, 6, 7, 7, 9, 9, 6, 7, 7, 9, 9, 8, - 10, 9,11,11, 9, 9, 9,11,11, 6, 8, 8,10,10, 8,10, - 10,11,11, 8, 9,10,11,11,10,11,11,12,12,10,11,11, - 12,13, 6, 8, 8,10,10, 8,10, 9,11,11, 8,10, 9,11, - 11,10,11,11,12,12,10,11,11,12,12, 9,11,11,14,13, - 10,12,11,14,14,10,12,11,14,13,12,13,13,15,14,12, - 13,13,15,14, 8,11,11,13,14,10,11,12,13,15,10,11, - 12,14,14,12,13,13,14,15,12,13,13,14,15, 5, 8, 8, - 11,11, 8,10,10,12,12, 8,10,10,12,12,11,12,12,14, - 13,11,12,12,13,14, 8,10,10,12,12, 9,11,12,13,14, - 10,12,12,13,13,12,12,13,14,14,11,13,13,15,15, 7, - 10,10,12,12, 9,12,11,14,12,10,11,12,13,14,12,13, - 12,14,14,12,13,13,15,16,10,12,12,15,14,11,12,13, - 15,15,11,13,13,15,16,14,14,15,15,16,13,14,15,17, - 15, 9,12,12,14,15,11,13,12,15,15,11,13,13,15,15, - 13,14,13,15,14,13,14,14,17, 0, 5, 8, 8,11,11, 8, - 10,10,12,12, 8,10,10,12,12,11,12,12,14,14,11,12, - 12,14,14, 7,10,10,12,12,10,12,12,13,13, 9,11,12, - 12,13,11,12,13,15,15,11,12,13,14,15, 8,10,10,12, - 12,10,12,11,13,13,10,12,11,13,13,11,13,13,15,14, - 12,13,12,15,13, 9,12,12,14,14,11,13,13,16,15,11, - 12,13,16,15,13,14,15,16,16,13,13,15,15,16,10,12, - 12,15,14,11,13,13,14,16,11,13,13,15,16,13,15,15, - 16,17,13,15,14,16,15, 8,11,11,14,15,10,12,12,15, - 15,10,12,12,15,16,14,15,15,16,17,13,14,14,16,16, - 9,12,12,15,15,11,13,14,15,17,11,13,13,15,16,14, - 15,16,19,17,13,15,15, 0,17, 9,12,12,15,15,11,14, - 13,16,15,11,13,13,15,16,15,15,15,18,17,13,15,15, - 17,17,11,15,14,18,16,12,14,15,17,17,12,15,15,18, - 18,15,15,16,15,19,14,16,16, 0, 0,11,14,14,16,17, - 12,15,14,18,17,12,15,15,18,18,15,17,15,18,16,14, - 16,16,18,18, 7,11,11,14,14,10,12,12,15,15,10,12, - 13,15,15,13,14,15,16,16,14,15,15,18,18, 9,12,12, - 15,15,11,13,13,16,15,11,12,13,16,16,14,15,15,17, - 16,15,16,16,17,17, 9,12,12,15,15,11,13,13,15,17, - 11,14,13,16,15,13,15,15,17,17,15,15,15,18,17,11, - 14,14,17,15,12,14,15,17,18,13,13,15,17,17,14,16, - 16,19,18,16,15,17,17, 0,11,14,14,17,17,12,15,15, - 18, 0,12,15,14,18,16,14,17,17,19, 0,16,18,15, 0, - 16, -}; - -static const static_codebook _8u1__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__8u1__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__8u1__p3_0, - 0 -}; - -static const long _vq_quantlist__8u1__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__8u1__p4_0[] = { - 4, 5, 5, 9, 9, 6, 7, 7, 9, 9, 6, 7, 7, 9, 9, 9, - 9, 9,11,11, 9, 9, 9,11,11, 6, 7, 7, 9, 9, 7, 7, - 8, 9,10, 7, 7, 8, 9,10, 9, 9,10,10,11, 9, 9,10, - 10,12, 6, 7, 7, 9, 9, 7, 8, 7,10, 9, 7, 8, 7,10, - 9, 9,10, 9,12,11,10,10, 9,12,10, 9,10,10,12,11, - 9,10,10,12,11, 9,10,10,12,12,11,11,12,12,13,11, - 11,12,12,13, 9, 9,10,12,11, 9,10,10,12,12,10,10, - 10,12,12,11,12,11,13,12,11,12,11,13,12, 6, 7, 7, - 9, 9, 7, 8, 8,10,10, 7, 8, 7,10, 9,10,10,10,12, - 12,10,10,10,12,11, 7, 8, 7,10,10, 7, 7, 9,10,11, - 8, 9, 9,11,10,10,10,11,10,12,10,10,11,12,12, 7, - 8, 8,10,10, 7, 9, 8,11,10, 8, 8, 9,11,11,10,11, - 10,12,11,10,11,11,12,12, 9,10,10,12,12, 9,10,10, - 12,12,10,11,11,13,12,11,10,12,10,14,12,12,12,13, - 14, 9,10,10,12,12, 9,11,10,12,12,10,11,11,12,12, - 11,12,11,14,12,12,12,12,14,14, 5, 7, 7, 9, 9, 7, - 7, 7, 9,10, 7, 8, 8,10,10,10,10,10,11,11,10,10, - 10,12,12, 7, 8, 8,10,10, 8, 9, 8,11,10, 7, 8, 9, - 10,11,10,10,10,11,12,10,10,11,11,13, 6, 7, 8,10, - 10, 8, 9, 9,10,10, 7, 9, 7,11,10,10,11,10,12,12, - 10,11,10,12,10, 9,10,10,12,12,10,11,11,13,12, 9, - 10,10,12,12,12,12,12,14,13,11,11,12,11,14, 9,10, - 10,11,12,10,11,11,12,13, 9,10,10,12,12,12,12,12, - 14,13,11,12,10,14,11, 9, 9,10,11,12, 9,10,10,12, - 12, 9,10,10,12,12,12,12,12,14,14,11,12,12,13,12, - 9,10, 9,12,12, 9,10,11,12,13,10,11,10,13,11,12, - 12,13,13,14,12,12,12,13,13, 9,10,10,12,12,10,11, - 10,13,12,10,10,11,12,13,12,13,12,14,13,12,12,12, - 13,14,11,12,11,14,13,10,10,11,13,13,12,12,12,14, - 13,12,10,14,10,15,13,14,14,14,14,11,11,12,13,14, - 10,12,11,13,13,12,12,12,13,15,12,13,11,15,12,13, - 13,14,14,14, 9,10, 9,12,12, 9,10,10,12,12,10,10, - 10,12,12,11,11,12,12,13,12,12,12,14,14, 9,10,10, - 12,12,10,11,10,13,12,10,10,11,12,13,12,12,12,14, - 13,12,12,13,13,14, 9,10,10,12,13,10,10,11,11,12, - 9,11,10,13,12,12,12,12,13,14,12,13,12,14,13,11, - 12,11,13,13,12,13,12,14,13,10,11,12,13,13,13,13, - 13,14,15,12,11,14,12,14,11,11,12,12,13,12,12,12, - 13,14,10,12,10,14,13,13,13,13,14,15,12,14,11,15, - 10, -}; - -static const static_codebook _8u1__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__8u1__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__8u1__p4_0, - 0 -}; - -static const long _vq_quantlist__8u1__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__8u1__p5_0[] = { - 1, 4, 4, 7, 7, 7, 7, 9, 9, 4, 6, 5, 8, 7, 8, 8, - 10,10, 4, 6, 6, 8, 8, 8, 8,10,10, 7, 8, 8, 9, 9, - 9, 9,11,11, 7, 8, 8, 9, 9, 9, 9,11,11, 8, 8, 8, - 9, 9,10,10,12,11, 8, 8, 8, 9, 9,10,10,11,11, 9, - 10,10,11,11,11,11,13,12, 9,10,10,11,11,12,12,12, - 13, -}; - -static const static_codebook _8u1__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__8u1__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__8u1__p5_0, - 0 -}; - -static const long _vq_quantlist__8u1__p6_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__8u1__p6_0[] = { - 3, 4, 4, 6, 6, 7, 7, 9, 9, 4, 4, 5, 6, 6, 7, 7, - 9, 9, 4, 4, 4, 6, 6, 7, 7, 9, 9, 6, 6, 6, 7, 7, - 8, 8, 9, 9, 6, 6, 6, 7, 7, 8, 8, 9, 9, 7, 7, 7, - 8, 8, 8, 9,10,10, 7, 7, 7, 8, 8, 9, 8,10,10, 9, - 9, 9, 9, 9,10,10,10,10, 9, 9, 9, 9, 9,10,10,10, - 10, -}; - -static const static_codebook _8u1__p6_0 = { - 2, 81, - (char *)_vq_lengthlist__8u1__p6_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__8u1__p6_0, - 0 -}; - -static const long _vq_quantlist__8u1__p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__8u1__p7_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 9, 9, 8,10,10, 8, - 10,10, 5, 9, 9, 7,10,10, 8,10,10, 4,10,10, 9,12, - 12, 9,11,11, 7,12,11,10,11,13,10,13,13, 7,12,12, - 10,13,12,10,13,13, 4,10,10, 9,12,12, 9,12,12, 7, - 12,12,10,13,13,10,12,13, 7,11,12,10,13,13,10,13, - 11, -}; - -static const static_codebook _8u1__p7_0 = { - 4, 81, - (char *)_vq_lengthlist__8u1__p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__8u1__p7_0, - 0 -}; - -static const long _vq_quantlist__8u1__p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__8u1__p7_1[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8, 4, 5, 5, 7, 7, - 8, 8, 9, 9, 9, 9, 4, 5, 5, 7, 7, 8, 8, 9, 9, 9, - 9, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 6, 7, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 8, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 8, 9, 9, - 9, 9, 9, 9,10,10,10,10, 8, 9, 9, 9, 9, 9, 9,10, - 10,10,10, 8, 9, 9, 9, 9, 9, 9,10,10,10,10, 8, 9, - 9, 9, 9, 9, 9,10,10,10,10, -}; - -static const static_codebook _8u1__p7_1 = { - 2, 121, - (char *)_vq_lengthlist__8u1__p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__8u1__p7_1, - 0 -}; - -static const long _vq_quantlist__8u1__p8_0[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__8u1__p8_0[] = { - 1, 4, 4, 6, 6, 8, 8,10,10,11,11, 4, 6, 6, 7, 7, - 9, 9,11,11,13,12, 4, 6, 6, 7, 7, 9, 9,11,11,12, - 12, 6, 7, 7, 9, 9,11,11,12,12,13,13, 6, 7, 7, 9, - 9,11,11,12,12,13,13, 8, 9, 9,11,11,12,12,13,13, - 14,14, 8, 9, 9,11,11,12,12,13,13,14,14, 9,11,11, - 12,12,13,13,14,14,15,15, 9,11,11,12,12,13,13,14, - 14,15,14,11,12,12,13,13,14,14,15,15,16,16,11,12, - 12,13,13,14,14,15,15,15,15, -}; - -static const static_codebook _8u1__p8_0 = { - 2, 121, - (char *)_vq_lengthlist__8u1__p8_0, - 1, -524582912, 1618345984, 4, 0, - (long *)_vq_quantlist__8u1__p8_0, - 0 -}; - -static const long _vq_quantlist__8u1__p8_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__8u1__p8_1[] = { - 2, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 5, 6, 6, 7, 7, - 7, 7, 8, 8, 8, 8, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, - 8, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 6, 7, 7, 7, - 7, 8, 8, 8, 8, 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, - 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 8, 9, 9, 7, 8, 8, 8, 8, 8, 8, 9, - 8, 9, 9, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, 9, -}; - -static const static_codebook _8u1__p8_1 = { - 2, 121, - (char *)_vq_lengthlist__8u1__p8_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__8u1__p8_1, - 0 -}; - -static const long _vq_quantlist__8u1__p9_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__8u1__p9_0[] = { - 1, 4, 4,11,11,11,11,11,11,11,11,11,11,11,11, 3, - 11, 8,11,11,11,11,11,11,11,11,11,11,11,11, 3, 9, - 9,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _8u1__p9_0 = { - 2, 225, - (char *)_vq_lengthlist__8u1__p9_0, - 1, -514071552, 1627381760, 4, 0, - (long *)_vq_quantlist__8u1__p9_0, - 0 -}; - -static const long _vq_quantlist__8u1__p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__8u1__p9_1[] = { - 1, 4, 4, 7, 7, 9, 9, 7, 7, 8, 8,10,10,11,11, 4, - 7, 7, 9, 9,10,10, 8, 8,10,10,10,11,10,11, 4, 7, - 7, 9, 9,10,10, 8, 8,10, 9,11,11,11,11, 7, 9, 9, - 12,12,11,12,10,10,11,10,12,11,11,11, 7, 9, 9,11, - 11,13,12, 9, 9,11,10,11,11,12,11, 9,10,10,12,12, - 14,14,10,10,11,12,12,11,11,11, 9,10,11,11,13,14, - 13,10,11,11,11,12,11,12,12, 7, 8, 8,10, 9,11,10, - 11,12,12,11,12,14,12,13, 7, 8, 8, 9,10,10,11,12, - 12,12,11,12,12,12,13, 9, 9, 9,11,11,13,12,12,12, - 12,11,12,12,13,12, 8,10,10,11,10,11,12,12,12,12, - 12,12,14,12,12, 9,11,11,11,12,12,12,12,13,13,12, - 12,13,13,12,10,11,11,12,11,12,12,12,11,12,13,12, - 12,12,13,11,11,12,12,12,13,12,12,11,12,13,13,12, - 12,13,12,11,12,12,13,13,12,13,12,13,13,13,13,14, - 13, -}; - -static const static_codebook _8u1__p9_1 = { - 2, 225, - (char *)_vq_lengthlist__8u1__p9_1, - 1, -522338304, 1620115456, 4, 0, - (long *)_vq_quantlist__8u1__p9_1, - 0 -}; - -static const long _vq_quantlist__8u1__p9_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__8u1__p9_2[] = { - 2, 5, 4, 6, 6, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 5, 6, 6, 7, 7, 8, 8, 9, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 5, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, - 9,10,10, 9, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9,10,10, 8, 8, 8, 9, 9, 9, 9,10,10,10, 9, - 10,10,10,10,10,10, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, - 10,10,10,10,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9,10, - 10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9,10,10,10, - 10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9, 9,10, - 10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9,10, - 10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9,10, - 10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, - 9,10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10, 9,10, - 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10, 9, - 10, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _8u1__p9_2 = { - 2, 289, - (char *)_vq_lengthlist__8u1__p9_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__8u1__p9_2, - 0 -}; - -static const char _huff_lengthlist__8u1__single[] = { - 4, 7,13, 9,15, 9,16, 8,10,13, 7, 5, 8, 6, 9, 7, - 10, 7,10,11,11, 6, 7, 8, 8, 9, 9, 9,12,16, 8, 5, - 8, 6, 8, 6, 9, 7,10,12,11, 7, 7, 7, 6, 7, 7, 7, - 11,15, 7, 5, 8, 6, 7, 5, 7, 6, 9,13,13, 9, 9, 8, - 6, 6, 5, 5, 9,14, 8, 6, 8, 6, 6, 4, 5, 3, 5,13, - 9, 9,11, 8,10, 7, 8, 4, 5,12,11,16,17,15,17,12, - 13, 8, 8,15, -}; - -static const static_codebook _huff_book__8u1__single = { - 2, 100, - (char *)_huff_lengthlist__8u1__single, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u0__long[] = { - 5, 8,13,10,17,11,11,15, 7, 2, 4, 5, 8, 7, 9,16, - 13, 4, 3, 5, 6, 8,11,20,10, 4, 5, 5, 7, 6, 8,18, - 15, 7, 6, 7, 8,10,14,20,10, 6, 7, 6, 9, 7, 8,17, - 9, 8,10, 8,10, 5, 4,11,12,17,19,14,16,10, 7,12, -}; - -static const static_codebook _huff_book__44u0__long = { - 2, 64, - (char *)_huff_lengthlist__44u0__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u0__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u0__p1_0[] = { - 1, 4, 4, 5, 8, 7, 5, 7, 8, 5, 8, 8, 8,11,11, 8, - 10,10, 5, 8, 8, 8,11,10, 8,11,11, 4, 8, 8, 8,11, - 11, 8,11,11, 8,12,11,11,13,13,11,13,14, 7,11,11, - 10,13,12,11,13,14, 4, 8, 8, 8,11,11, 8,11,12, 8, - 11,11,11,13,13,10,12,13, 8,11,11,11,14,13,11,14, - 13, -}; - -static const static_codebook _44u0__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u0__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u0__p1_0, - 0 -}; - -static const long _vq_quantlist__44u0__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u0__p2_0[] = { - 2, 4, 4, 5, 6, 6, 5, 6, 6, 5, 7, 7, 7, 8, 8, 6, - 8, 8, 5, 7, 7, 6, 8, 8, 7, 8, 8, 4, 7, 7, 7, 8, - 8, 7, 8, 8, 7, 8, 8, 8, 9,10, 8,10,10, 6, 8, 8, - 8,10, 8, 8,10,10, 5, 7, 7, 7, 8, 8, 7, 8, 8, 6, - 8, 8, 8,10,10, 8, 8,10, 6, 8, 8, 8,10,10, 8,10, - 9, -}; - -static const static_codebook _44u0__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__44u0__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u0__p2_0, - 0 -}; - -static const long _vq_quantlist__44u0__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u0__p3_0[] = { - 1, 5, 5, 8, 8, 5, 8, 7, 9, 9, 5, 7, 8, 9, 9, 9, - 10, 9,12,12, 9, 9,10,12,12, 6, 8, 8,11,10, 8,10, - 10,11,11, 8, 9,10,11,11,10,11,11,14,13,10,11,11, - 13,13, 5, 8, 8,10,10, 8,10,10,11,11, 8,10,10,11, - 11,10,11,11,13,13,10,11,11,13,13, 9,11,11,15,14, - 10,12,12,15,14,10,12,11,15,14,13,14,14,16,16,12, - 14,13,17,15, 9,11,11,14,15,10,11,12,14,16,10,11, - 12,14,16,12,13,14,16,16,13,13,15,15,18, 5, 8, 8, - 11,11, 8,10,10,12,12, 8,10,10,12,13,11,12,12,14, - 14,11,12,12,15,15, 8,10,10,13,13,10,12,12,13,13, - 10,12,12,14,14,12,13,13,15,15,12,13,13,16,16, 7, - 10,10,12,12,10,12,11,13,13,10,12,12,13,14,12,13, - 12,15,14,12,13,13,16,16,10,12,12,17,16,12,13,13, - 16,15,11,13,13,17,17,15,15,15,16,17,14,15,15,19, - 19,10,12,12,15,16,11,13,12,15,18,11,13,13,16,16, - 14,15,15,17,17,14,15,15,17,19, 5, 8, 8,11,11, 8, - 10,10,12,12, 8,10,10,12,12,11,12,12,16,15,11,12, - 12,14,15, 7,10,10,13,13,10,12,12,14,13,10,11,12, - 13,13,12,13,13,16,16,12,12,13,15,15, 8,10,10,13, - 13,10,12,12,14,14,10,12,12,13,13,12,13,13,16,16, - 12,13,13,15,15,10,12,12,16,15,11,13,13,17,16,11, - 12,13,16,15,13,15,15,19,17,14,15,14,17,16,10,12, - 12,16,16,11,13,13,16,17,12,13,13,15,17,14,15,15, - 17,19,14,15,15,17,17, 8,11,11,16,16,10,13,12,17, - 17,10,12,13,16,16,15,17,16,20,19,14,15,17,18,19, - 9,12,12,16,17,11,13,14,17,18,11,13,13,19,18,16, - 17,18,19,19,15,16,16,19,19, 9,12,12,16,17,11,14, - 13,18,17,11,13,13,17,17,16,17,16,20,19,14,16,16, - 18,18,12,15,15,19,17,14,15,16, 0,20,13,15,16,20, - 17,18,16,20, 0, 0,15,16,19,20, 0,12,15,14,18,19, - 13,16,15,20,19,13,16,15,20,18,17,18,17, 0,20,16, - 17,16, 0, 0, 8,11,11,16,15,10,12,12,17,17,10,13, - 13,17,16,14,16,15,18,20,15,16,16,19,19, 9,12,12, - 16,16,11,13,13,17,16,11,13,14,17,18,15,15,16,20, - 20,16,16,17,19,19, 9,13,12,16,17,11,14,13,17,17, - 11,14,14,18,17,14,16,15,18,19,16,17,18,18,19,12, - 14,15,19,18,13,15,16,18, 0,13,14,15, 0, 0,16,16, - 17,20, 0,17,17,20,20, 0,12,15,15,19,20,13,15,15, - 0, 0,14,16,15, 0, 0,15,18,16, 0, 0,17,18,16, 0, - 19, -}; - -static const static_codebook _44u0__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44u0__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u0__p3_0, - 0 -}; - -static const long _vq_quantlist__44u0__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u0__p4_0[] = { - 4, 5, 5, 9, 9, 5, 6, 6, 9, 9, 5, 6, 6, 9, 9, 9, - 10, 9,12,12, 9, 9,10,12,12, 5, 7, 7,10,10, 7, 7, - 8,10,10, 6, 7, 8,10,10,10,10,10,11,13,10, 9,10, - 12,13, 5, 7, 7,10,10, 6, 8, 7,10,10, 7, 8, 7,10, - 10, 9,10,10,12,12,10,10,10,13,11, 9,10,10,13,13, - 10,11,10,13,13,10,10,10,13,13,12,12,13,14,14,12, - 12,13,14,14, 9,10,10,13,13,10,10,10,13,13,10,10, - 10,13,13,12,13,12,15,14,12,13,12,15,15, 5, 7, 6, - 10,10, 7, 8, 8,10,10, 7, 8, 8,10,10,10,11,10,13, - 13,10,10,10,12,12, 7, 8, 8,11,10, 8, 8, 9,10,11, - 8, 9, 9,11,11,11,10,11,11,14,11,11,11,13,13, 6, - 8, 8,10,10, 7, 9, 8,11,10, 8, 9, 9,11,11,10,11, - 10,14,11,10,11,11,13,13,10,11,11,14,13,10,10,11, - 14,13,10,11,11,14,14,12,11,13,12,16,13,14,14,15, - 15,10,10,11,13,14,10,11,10,14,13,10,11,11,14,14, - 12,13,12,15,13,13,13,14,15,16, 5, 7, 7,10,10, 7, - 8, 8,10,10, 7, 8, 8,10,10,10,10,10,13,13,10,10, - 11,12,13, 6, 8, 8,11,10, 8, 9, 9,11,11, 7, 8, 9, - 10,11,10,11,11,13,13,10,10,11,11,13, 6, 8, 8,10, - 11, 8, 9, 9,11,11, 8, 9, 8,12,10,10,11,11,13,13, - 10,11,10,14,11,10,10,10,14,13,10,11,11,14,13,10, - 10,11,13,13,12,14,14,16,16,12,12,13,13,15,10,11, - 11,13,14,10,11,11,14,15,10,11,10,13,13,13,14,13, - 16,16,12,13,11,15,12, 9,10,10,13,13,10,11,11,14, - 13,10,10,11,13,14,13,14,13,16,16,13,13,13,15,16, - 9,10,10,13,13,10,10,11,13,14,10,11,11,15,13,13, - 13,14,14,18,13,13,14,16,15, 9,10,10,13,14,10,11, - 10,14,13,10,11,11,13,14,13,14,13,16,15,13,13,14, - 15,16,12,13,12,16,14,11,11,13,15,15,13,14,13,16, - 15,15,12,16,12,17,14,15,15,17,17,12,13,13,14,16, - 11,13,11,16,15,12,13,14,15,16,14,15,13, 0,14,14, - 16,16, 0, 0, 9,10,10,13,13,10,11,10,14,14,10,11, - 11,13,13,12,13,13,14,16,13,14,14,16,16, 9,10,10, - 14,14,11,11,11,14,13,10,10,11,14,14,13,13,13,16, - 16,13,13,14,14,17, 9,10,10,13,14,10,11,11,13,15, - 10,11,10,14,14,13,13,13,14,17,13,14,13,17,14,12, - 13,13,16,14,13,14,13,16,15,12,12,13,15,16,15,15, - 16,18,16,15,13,15,14, 0,12,12,13,14,16,13,13,14, - 15,16,11,12,11,16,14,15,16,16,17,17,14,15,12,17, - 12, -}; - -static const static_codebook _44u0__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__44u0__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u0__p4_0, - 0 -}; - -static const long _vq_quantlist__44u0__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u0__p5_0[] = { - 1, 4, 4, 7, 7, 7, 7, 9, 9, 4, 6, 6, 8, 8, 8, 8, - 9, 9, 4, 6, 6, 8, 8, 8, 8, 9, 9, 7, 8, 8, 9, 9, - 9, 9,11,10, 7, 8, 8, 9, 9, 9, 9,10,10, 7, 8, 8, - 9, 9,10,10,11,11, 7, 8, 8, 9, 9,10,10,11,11, 9, - 9, 9,10,10,11,11,12,12, 9, 9, 9,10,11,11,11,12, - 12, -}; - -static const static_codebook _44u0__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44u0__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u0__p5_0, - 0 -}; - -static const long _vq_quantlist__44u0__p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u0__p6_0[] = { - 1, 4, 4, 6, 6, 8, 8,10, 9,11,10,14,13, 4, 6, 5, - 8, 8, 9, 9,11,10,11,11,14,14, 4, 5, 6, 8, 8, 9, - 9,10,10,11,11,14,14, 6, 8, 8, 9, 9,10,10,11,11, - 12,12,16,15, 7, 8, 8, 9, 9,10,10,11,11,12,12,15, - 15, 9,10,10,10,10,11,11,12,12,12,12,15,15, 9,10, - 9,10,11,11,11,12,12,12,13,15,15,10,10,11,11,11, - 12,12,13,12,13,13,16,15,10,11,11,11,11,12,12,13, - 12,13,13,16,17,11,11,12,12,12,13,13,13,14,14,15, - 17,17,11,11,12,12,12,13,13,13,14,14,14,16,18,14, - 15,15,15,15,16,16,16,16,17,18, 0, 0,14,15,15,15, - 15,17,16,17,18,17,17,18, 0, -}; - -static const static_codebook _44u0__p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44u0__p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44u0__p6_0, - 0 -}; - -static const long _vq_quantlist__44u0__p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u0__p6_1[] = { - 2, 4, 4, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 5, 6, 6, 6, 6, -}; - -static const static_codebook _44u0__p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44u0__p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u0__p6_1, - 0 -}; - -static const long _vq_quantlist__44u0__p7_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u0__p7_0[] = { - 1, 4, 4,11,11, 9,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11, 9,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,10,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _44u0__p7_0 = { - 4, 625, - (char *)_vq_lengthlist__44u0__p7_0, - 1, -518709248, 1626677248, 3, 0, - (long *)_vq_quantlist__44u0__p7_0, - 0 -}; - -static const long _vq_quantlist__44u0__p7_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u0__p7_1[] = { - 1, 4, 4, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 5, 7, 7, - 8, 7, 7, 7, 9, 8,10, 9,10,11, 5, 7, 7, 8, 8, 7, - 7, 8, 9,10,10,11,11, 6, 8, 8, 9, 9, 9, 9,11,10, - 12,12,15,12, 6, 8, 8, 9, 9, 9, 9,11,11,12,11,14, - 12, 7, 8, 8,10,10,12,12,13,13,13,15,13,13, 7, 8, - 8,10,10,11,11,13,12,14,15,15,15, 9,10,10,11,12, - 13,13,14,15,14,15,14,15, 8,10,10,12,12,14,14,15, - 14,14,15,15,14,10,12,12,14,14,15,14,15,15,15,14, - 15,15,10,12,12,13,14,15,14,15,15,14,15,15,15,12, - 15,13,15,14,15,15,15,15,15,15,15,15,13,13,15,15, - 15,15,15,15,15,15,15,15,15, -}; - -static const static_codebook _44u0__p7_1 = { - 2, 169, - (char *)_vq_lengthlist__44u0__p7_1, - 1, -523010048, 1618608128, 4, 0, - (long *)_vq_quantlist__44u0__p7_1, - 0 -}; - -static const long _vq_quantlist__44u0__p7_2[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u0__p7_2[] = { - 2, 5, 4, 6, 6, 7, 7, 8, 8, 8, 8, 9, 8, 5, 5, 6, - 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 5, 6, 5, 7, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 6, 7, 7, 8, 8, 8, 8, 9, 8, - 9, 9, 9, 9, 6, 7, 7, 8, 7, 8, 8, 9, 9, 9, 9, 9, - 9, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 7, 8, - 8, 9, 8, 9, 8, 9, 9, 9, 9, 9, 9, 8, 9, 8, 9, 9, - 9, 9, 9, 9, 9, 9,10,10, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9,10, 9,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, 9, 9, 9, 9, 9, - 9, 9, 9,10, 9, 9,10,10, 9, -}; - -static const static_codebook _44u0__p7_2 = { - 2, 169, - (char *)_vq_lengthlist__44u0__p7_2, - 1, -531103744, 1611661312, 4, 0, - (long *)_vq_quantlist__44u0__p7_2, - 0 -}; - -static const char _huff_lengthlist__44u0__short[] = { - 12,13,14,13,17,12,15,17, 5, 5, 6,10,10,11,15,16, - 4, 3, 3, 7, 5, 7,10,16, 7, 7, 7,10, 9,11,12,16, - 6, 5, 5, 9, 5, 6,10,16, 8, 7, 7, 9, 6, 7, 9,16, - 11, 7, 3, 6, 4, 5, 8,16,12, 9, 4, 8, 5, 7, 9,16, -}; - -static const static_codebook _huff_book__44u0__short = { - 2, 64, - (char *)_huff_lengthlist__44u0__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u1__long[] = { - 5, 8,13,10,17,11,11,15, 7, 2, 4, 5, 8, 7, 9,16, - 13, 4, 3, 5, 6, 8,11,20,10, 4, 5, 5, 7, 6, 8,18, - 15, 7, 6, 7, 8,10,14,20,10, 6, 7, 6, 9, 7, 8,17, - 9, 8,10, 8,10, 5, 4,11,12,17,19,14,16,10, 7,12, -}; - -static const static_codebook _huff_book__44u1__long = { - 2, 64, - (char *)_huff_lengthlist__44u1__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u1__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u1__p1_0[] = { - 1, 4, 4, 5, 8, 7, 5, 7, 8, 5, 8, 8, 8,11,11, 8, - 10,10, 5, 8, 8, 8,11,10, 8,11,11, 4, 8, 8, 8,11, - 11, 8,11,11, 8,12,11,11,13,13,11,13,14, 7,11,11, - 10,13,12,11,13,14, 4, 8, 8, 8,11,11, 8,11,12, 8, - 11,11,11,13,13,10,12,13, 8,11,11,11,14,13,11,14, - 13, -}; - -static const static_codebook _44u1__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u1__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u1__p1_0, - 0 -}; - -static const long _vq_quantlist__44u1__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u1__p2_0[] = { - 2, 4, 4, 5, 6, 6, 5, 6, 6, 5, 7, 7, 7, 8, 8, 6, - 8, 8, 5, 7, 7, 6, 8, 8, 7, 8, 8, 4, 7, 7, 7, 8, - 8, 7, 8, 8, 7, 8, 8, 8, 9,10, 8,10,10, 6, 8, 8, - 8,10, 8, 8,10,10, 5, 7, 7, 7, 8, 8, 7, 8, 8, 6, - 8, 8, 8,10,10, 8, 8,10, 6, 8, 8, 8,10,10, 8,10, - 9, -}; - -static const static_codebook _44u1__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__44u1__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u1__p2_0, - 0 -}; - -static const long _vq_quantlist__44u1__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u1__p3_0[] = { - 1, 5, 5, 8, 8, 5, 8, 7, 9, 9, 5, 7, 8, 9, 9, 9, - 10, 9,12,12, 9, 9,10,12,12, 6, 8, 8,11,10, 8,10, - 10,11,11, 8, 9,10,11,11,10,11,11,14,13,10,11,11, - 13,13, 5, 8, 8,10,10, 8,10,10,11,11, 8,10,10,11, - 11,10,11,11,13,13,10,11,11,13,13, 9,11,11,15,14, - 10,12,12,15,14,10,12,11,15,14,13,14,14,16,16,12, - 14,13,17,15, 9,11,11,14,15,10,11,12,14,16,10,11, - 12,14,16,12,13,14,16,16,13,13,15,15,18, 5, 8, 8, - 11,11, 8,10,10,12,12, 8,10,10,12,13,11,12,12,14, - 14,11,12,12,15,15, 8,10,10,13,13,10,12,12,13,13, - 10,12,12,14,14,12,13,13,15,15,12,13,13,16,16, 7, - 10,10,12,12,10,12,11,13,13,10,12,12,13,14,12,13, - 12,15,14,12,13,13,16,16,10,12,12,17,16,12,13,13, - 16,15,11,13,13,17,17,15,15,15,16,17,14,15,15,19, - 19,10,12,12,15,16,11,13,12,15,18,11,13,13,16,16, - 14,15,15,17,17,14,15,15,17,19, 5, 8, 8,11,11, 8, - 10,10,12,12, 8,10,10,12,12,11,12,12,16,15,11,12, - 12,14,15, 7,10,10,13,13,10,12,12,14,13,10,11,12, - 13,13,12,13,13,16,16,12,12,13,15,15, 8,10,10,13, - 13,10,12,12,14,14,10,12,12,13,13,12,13,13,16,16, - 12,13,13,15,15,10,12,12,16,15,11,13,13,17,16,11, - 12,13,16,15,13,15,15,19,17,14,15,14,17,16,10,12, - 12,16,16,11,13,13,16,17,12,13,13,15,17,14,15,15, - 17,19,14,15,15,17,17, 8,11,11,16,16,10,13,12,17, - 17,10,12,13,16,16,15,17,16,20,19,14,15,17,18,19, - 9,12,12,16,17,11,13,14,17,18,11,13,13,19,18,16, - 17,18,19,19,15,16,16,19,19, 9,12,12,16,17,11,14, - 13,18,17,11,13,13,17,17,16,17,16,20,19,14,16,16, - 18,18,12,15,15,19,17,14,15,16, 0,20,13,15,16,20, - 17,18,16,20, 0, 0,15,16,19,20, 0,12,15,14,18,19, - 13,16,15,20,19,13,16,15,20,18,17,18,17, 0,20,16, - 17,16, 0, 0, 8,11,11,16,15,10,12,12,17,17,10,13, - 13,17,16,14,16,15,18,20,15,16,16,19,19, 9,12,12, - 16,16,11,13,13,17,16,11,13,14,17,18,15,15,16,20, - 20,16,16,17,19,19, 9,13,12,16,17,11,14,13,17,17, - 11,14,14,18,17,14,16,15,18,19,16,17,18,18,19,12, - 14,15,19,18,13,15,16,18, 0,13,14,15, 0, 0,16,16, - 17,20, 0,17,17,20,20, 0,12,15,15,19,20,13,15,15, - 0, 0,14,16,15, 0, 0,15,18,16, 0, 0,17,18,16, 0, - 19, -}; - -static const static_codebook _44u1__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44u1__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u1__p3_0, - 0 -}; - -static const long _vq_quantlist__44u1__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u1__p4_0[] = { - 4, 5, 5, 9, 9, 5, 6, 6, 9, 9, 5, 6, 6, 9, 9, 9, - 10, 9,12,12, 9, 9,10,12,12, 5, 7, 7,10,10, 7, 7, - 8,10,10, 6, 7, 8,10,10,10,10,10,11,13,10, 9,10, - 12,13, 5, 7, 7,10,10, 6, 8, 7,10,10, 7, 8, 7,10, - 10, 9,10,10,12,12,10,10,10,13,11, 9,10,10,13,13, - 10,11,10,13,13,10,10,10,13,13,12,12,13,14,14,12, - 12,13,14,14, 9,10,10,13,13,10,10,10,13,13,10,10, - 10,13,13,12,13,12,15,14,12,13,12,15,15, 5, 7, 6, - 10,10, 7, 8, 8,10,10, 7, 8, 8,10,10,10,11,10,13, - 13,10,10,10,12,12, 7, 8, 8,11,10, 8, 8, 9,10,11, - 8, 9, 9,11,11,11,10,11,11,14,11,11,11,13,13, 6, - 8, 8,10,10, 7, 9, 8,11,10, 8, 9, 9,11,11,10,11, - 10,14,11,10,11,11,13,13,10,11,11,14,13,10,10,11, - 14,13,10,11,11,14,14,12,11,13,12,16,13,14,14,15, - 15,10,10,11,13,14,10,11,10,14,13,10,11,11,14,14, - 12,13,12,15,13,13,13,14,15,16, 5, 7, 7,10,10, 7, - 8, 8,10,10, 7, 8, 8,10,10,10,10,10,13,13,10,10, - 11,12,13, 6, 8, 8,11,10, 8, 9, 9,11,11, 7, 8, 9, - 10,11,10,11,11,13,13,10,10,11,11,13, 6, 8, 8,10, - 11, 8, 9, 9,11,11, 8, 9, 8,12,10,10,11,11,13,13, - 10,11,10,14,11,10,10,10,14,13,10,11,11,14,13,10, - 10,11,13,13,12,14,14,16,16,12,12,13,13,15,10,11, - 11,13,14,10,11,11,14,15,10,11,10,13,13,13,14,13, - 16,16,12,13,11,15,12, 9,10,10,13,13,10,11,11,14, - 13,10,10,11,13,14,13,14,13,16,16,13,13,13,15,16, - 9,10,10,13,13,10,10,11,13,14,10,11,11,15,13,13, - 13,14,14,18,13,13,14,16,15, 9,10,10,13,14,10,11, - 10,14,13,10,11,11,13,14,13,14,13,16,15,13,13,14, - 15,16,12,13,12,16,14,11,11,13,15,15,13,14,13,16, - 15,15,12,16,12,17,14,15,15,17,17,12,13,13,14,16, - 11,13,11,16,15,12,13,14,15,16,14,15,13, 0,14,14, - 16,16, 0, 0, 9,10,10,13,13,10,11,10,14,14,10,11, - 11,13,13,12,13,13,14,16,13,14,14,16,16, 9,10,10, - 14,14,11,11,11,14,13,10,10,11,14,14,13,13,13,16, - 16,13,13,14,14,17, 9,10,10,13,14,10,11,11,13,15, - 10,11,10,14,14,13,13,13,14,17,13,14,13,17,14,12, - 13,13,16,14,13,14,13,16,15,12,12,13,15,16,15,15, - 16,18,16,15,13,15,14, 0,12,12,13,14,16,13,13,14, - 15,16,11,12,11,16,14,15,16,16,17,17,14,15,12,17, - 12, -}; - -static const static_codebook _44u1__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__44u1__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u1__p4_0, - 0 -}; - -static const long _vq_quantlist__44u1__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u1__p5_0[] = { - 1, 4, 4, 7, 7, 7, 7, 9, 9, 4, 6, 6, 8, 8, 8, 8, - 9, 9, 4, 6, 6, 8, 8, 8, 8, 9, 9, 7, 8, 8, 9, 9, - 9, 9,11,10, 7, 8, 8, 9, 9, 9, 9,10,10, 7, 8, 8, - 9, 9,10,10,11,11, 7, 8, 8, 9, 9,10,10,11,11, 9, - 9, 9,10,10,11,11,12,12, 9, 9, 9,10,11,11,11,12, - 12, -}; - -static const static_codebook _44u1__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44u1__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u1__p5_0, - 0 -}; - -static const long _vq_quantlist__44u1__p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u1__p6_0[] = { - 1, 4, 4, 6, 6, 8, 8,10, 9,11,10,14,13, 4, 6, 5, - 8, 8, 9, 9,11,10,11,11,14,14, 4, 5, 6, 8, 8, 9, - 9,10,10,11,11,14,14, 6, 8, 8, 9, 9,10,10,11,11, - 12,12,16,15, 7, 8, 8, 9, 9,10,10,11,11,12,12,15, - 15, 9,10,10,10,10,11,11,12,12,12,12,15,15, 9,10, - 9,10,11,11,11,12,12,12,13,15,15,10,10,11,11,11, - 12,12,13,12,13,13,16,15,10,11,11,11,11,12,12,13, - 12,13,13,16,17,11,11,12,12,12,13,13,13,14,14,15, - 17,17,11,11,12,12,12,13,13,13,14,14,14,16,18,14, - 15,15,15,15,16,16,16,16,17,18, 0, 0,14,15,15,15, - 15,17,16,17,18,17,17,18, 0, -}; - -static const static_codebook _44u1__p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44u1__p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44u1__p6_0, - 0 -}; - -static const long _vq_quantlist__44u1__p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u1__p6_1[] = { - 2, 4, 4, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 5, 6, 6, 6, 6, -}; - -static const static_codebook _44u1__p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44u1__p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u1__p6_1, - 0 -}; - -static const long _vq_quantlist__44u1__p7_0[] = { - 3, - 2, - 4, - 1, - 5, - 0, - 6, -}; - -static const char _vq_lengthlist__44u1__p7_0[] = { - 1, 3, 2, 9, 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, -}; - -static const static_codebook _44u1__p7_0 = { - 2, 49, - (char *)_vq_lengthlist__44u1__p7_0, - 1, -518017024, 1626677248, 3, 0, - (long *)_vq_quantlist__44u1__p7_0, - 0 -}; - -static const long _vq_quantlist__44u1__p7_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u1__p7_1[] = { - 1, 4, 4, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 5, 7, 7, - 8, 7, 7, 7, 9, 8,10, 9,10,11, 5, 7, 7, 8, 8, 7, - 7, 8, 9,10,10,11,11, 6, 8, 8, 9, 9, 9, 9,11,10, - 12,12,15,12, 6, 8, 8, 9, 9, 9, 9,11,11,12,11,14, - 12, 7, 8, 8,10,10,12,12,13,13,13,15,13,13, 7, 8, - 8,10,10,11,11,13,12,14,15,15,15, 9,10,10,11,12, - 13,13,14,15,14,15,14,15, 8,10,10,12,12,14,14,15, - 14,14,15,15,14,10,12,12,14,14,15,14,15,15,15,14, - 15,15,10,12,12,13,14,15,14,15,15,14,15,15,15,12, - 15,13,15,14,15,15,15,15,15,15,15,15,13,13,15,15, - 15,15,15,15,15,15,15,15,15, -}; - -static const static_codebook _44u1__p7_1 = { - 2, 169, - (char *)_vq_lengthlist__44u1__p7_1, - 1, -523010048, 1618608128, 4, 0, - (long *)_vq_quantlist__44u1__p7_1, - 0 -}; - -static const long _vq_quantlist__44u1__p7_2[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u1__p7_2[] = { - 2, 5, 4, 6, 6, 7, 7, 8, 8, 8, 8, 9, 8, 5, 5, 6, - 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 5, 6, 5, 7, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 6, 7, 7, 8, 8, 8, 8, 9, 8, - 9, 9, 9, 9, 6, 7, 7, 8, 7, 8, 8, 9, 9, 9, 9, 9, - 9, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 7, 8, - 8, 9, 8, 9, 8, 9, 9, 9, 9, 9, 9, 8, 9, 8, 9, 9, - 9, 9, 9, 9, 9, 9,10,10, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9,10, 9,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, 9, 9, 9, 9, 9, - 9, 9, 9,10, 9, 9,10,10, 9, -}; - -static const static_codebook _44u1__p7_2 = { - 2, 169, - (char *)_vq_lengthlist__44u1__p7_2, - 1, -531103744, 1611661312, 4, 0, - (long *)_vq_quantlist__44u1__p7_2, - 0 -}; - -static const char _huff_lengthlist__44u1__short[] = { - 12,13,14,13,17,12,15,17, 5, 5, 6,10,10,11,15,16, - 4, 3, 3, 7, 5, 7,10,16, 7, 7, 7,10, 9,11,12,16, - 6, 5, 5, 9, 5, 6,10,16, 8, 7, 7, 9, 6, 7, 9,16, - 11, 7, 3, 6, 4, 5, 8,16,12, 9, 4, 8, 5, 7, 9,16, -}; - -static const static_codebook _huff_book__44u1__short = { - 2, 64, - (char *)_huff_lengthlist__44u1__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u2__long[] = { - 5, 9,14,12,15,13,10,13, 7, 4, 5, 6, 8, 7, 8,12, - 13, 4, 3, 5, 5, 6, 9,15,12, 6, 5, 6, 6, 6, 7,14, - 14, 7, 4, 6, 4, 6, 8,15,12, 6, 6, 5, 5, 5, 6,14, - 9, 7, 8, 6, 7, 5, 4,10,10,13,14,14,15,10, 6, 8, -}; - -static const static_codebook _huff_book__44u2__long = { - 2, 64, - (char *)_huff_lengthlist__44u2__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u2__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u2__p1_0[] = { - 1, 4, 4, 5, 8, 7, 5, 7, 8, 5, 8, 8, 8,11,11, 8, - 10,11, 5, 8, 8, 8,11,10, 8,11,11, 4, 8, 8, 8,11, - 11, 8,11,11, 8,11,11,11,13,14,11,13,13, 7,11,11, - 10,13,12,11,14,14, 4, 8, 8, 8,11,11, 8,11,11, 8, - 11,11,11,14,13,10,12,13, 8,11,11,11,13,13,11,13, - 13, -}; - -static const static_codebook _44u2__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u2__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u2__p1_0, - 0 -}; - -static const long _vq_quantlist__44u2__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u2__p2_0[] = { - 2, 5, 5, 5, 6, 6, 5, 6, 6, 5, 6, 6, 7, 8, 8, 6, - 8, 8, 5, 6, 6, 6, 8, 7, 7, 8, 8, 5, 6, 6, 7, 8, - 8, 6, 8, 8, 6, 8, 8, 8, 9,10, 8,10,10, 6, 8, 8, - 7,10, 8, 8,10,10, 5, 6, 6, 6, 8, 8, 7, 8, 8, 6, - 8, 8, 8,10,10, 8, 8,10, 6, 8, 8, 8,10,10, 8,10, - 9, -}; - -static const static_codebook _44u2__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__44u2__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u2__p2_0, - 0 -}; - -static const long _vq_quantlist__44u2__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u2__p3_0[] = { - 2, 4, 4, 7, 8, 5, 7, 7, 9, 9, 5, 7, 7, 9, 9, 8, - 9, 9,12,11, 8, 9, 9,11,12, 5, 7, 7,10,10, 7, 9, - 9,11,11, 7, 9, 9,10,11,10,11,11,13,13, 9,10,11, - 12,13, 5, 7, 7,10,10, 7, 9, 9,11,10, 7, 9, 9,11, - 11, 9,11,10,13,13,10,11,11,13,13, 8,10,10,14,13, - 10,11,11,15,14, 9,11,11,15,14,13,14,13,16,14,12, - 13,13,15,16, 8,10,10,13,14, 9,11,11,14,15,10,11, - 11,14,15,12,13,13,15,15,12,13,14,15,16, 5, 7, 7, - 10,10, 7, 9, 9,11,11, 7, 9, 9,11,12,10,11,11,14, - 13,10,11,11,14,14, 7, 9, 9,12,12, 9,11,11,13,13, - 9,11,11,13,13,12,13,12,14,14,11,12,13,15,15, 7, - 9, 9,12,12, 8,11,10,13,12, 9,11,11,13,13,11,13, - 12,15,13,11,13,13,15,16, 9,12,11,15,15,11,12,12, - 16,15,11,12,13,16,16,13,14,15,16,15,13,15,15,17, - 17, 9,11,11,14,15,10,12,12,15,15,11,13,12,15,16, - 13,15,14,16,16,13,15,15,17,19, 5, 7, 7,10,10, 7, - 9, 9,12,11, 7, 9, 9,11,11,10,11,11,14,14,10,11, - 11,13,14, 7, 9, 9,12,12, 9,11,11,13,13, 9,10,11, - 12,13,11,13,12,16,15,11,12,12,14,15, 7, 9, 9,12, - 12, 9,11,11,13,13, 9,11,11,13,12,11,13,12,15,16, - 12,13,13,15,14, 9,11,11,15,14,11,13,12,16,15,10, - 11,12,15,15,13,14,14,18,17,13,14,14,15,17,10,11, - 11,14,15,11,13,12,15,17,11,13,12,15,16,13,15,14, - 18,17,14,15,15,16,18, 7,10,10,14,14,10,12,12,15, - 15,10,12,12,15,15,14,15,15,18,17,13,15,15,16,16, - 9,11,11,16,15,11,13,13,16,18,11,13,13,16,16,15, - 16,16, 0, 0,14,15,16,18,17, 9,11,11,15,15,10,13, - 12,17,16,11,12,13,16,17,14,15,16,19,19,14,15,15, - 0,20,12,14,14, 0, 0,13,14,16,19,18,13,15,16,20, - 17,16,18, 0, 0, 0,15,16,17,18,19,11,14,14, 0,19, - 12,15,14,17,17,13,15,15, 0, 0,16,17,15,20,19,15, - 17,16,19, 0, 8,10,10,14,15,10,12,11,15,15,10,11, - 12,16,15,13,14,14,19,17,14,15,15, 0, 0, 9,11,11, - 16,15,11,13,13,17,16,10,12,13,16,17,14,15,15,18, - 18,14,15,16,20,19, 9,12,12, 0,15,11,13,13,16,17, - 11,13,13,19,17,14,16,16,18,17,15,16,16,17,19,11, - 14,14,18,18,13,14,15, 0, 0,12,14,15,19,18,15,16, - 19, 0,19,15,16,19,19,17,12,14,14,16,19,13,15,15, - 0,17,13,15,14,18,18,15,16,15, 0,18,16,17,17, 0, - 0, -}; - -static const static_codebook _44u2__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44u2__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u2__p3_0, - 0 -}; - -static const long _vq_quantlist__44u2__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u2__p4_0[] = { - 4, 5, 5, 8, 8, 5, 7, 6, 9, 9, 5, 6, 7, 9, 9, 9, - 9, 9,11,11, 9, 9, 9,11,11, 5, 7, 7, 9, 9, 7, 8, - 8,10,10, 7, 7, 8,10,10,10,10,10,11,12, 9,10,10, - 11,12, 5, 7, 7, 9, 9, 6, 8, 7,10,10, 7, 8, 8,10, - 10, 9,10,10,12,11, 9,10,10,12,11, 9,10,10,12,12, - 10,10,10,13,12, 9,10,10,12,13,12,12,12,14,14,11, - 12,12,13,14, 9,10,10,12,12, 9,10,10,12,13,10,10, - 10,12,13,11,12,12,14,13,12,12,12,14,13, 5, 7, 7, - 10, 9, 7, 8, 8,10,10, 7, 8, 8,10,10,10,10,10,12, - 12,10,10,10,12,12, 7, 8, 8,11,10, 8, 8, 9,11,11, - 8, 9, 9,11,11,10,11,11,12,13,10,11,11,13,13, 6, - 8, 8,10,10, 7, 9, 8,11,10, 8, 9, 9,11,11,10,11, - 10,13,11,10,11,11,13,13, 9,10,10,13,13,10,11,11, - 13,13,10,11,11,14,13,12,11,13,12,15,12,13,13,15, - 15, 9,10,10,12,13,10,11,10,13,13,10,11,11,13,13, - 12,13,11,15,13,12,13,13,15,15, 5, 7, 7, 9,10, 7, - 8, 8,10,10, 7, 8, 8,10,10,10,10,10,12,12,10,10, - 11,12,12, 6, 8, 8,10,10, 8, 9, 9,11,11, 7, 8, 9, - 10,11,10,11,11,13,13,10,10,11,11,13, 7, 8, 8,10, - 11, 8, 9, 9,11,11, 8, 9, 8,11,11,10,11,11,13,13, - 10,11,11,13,12, 9,10,10,13,12,10,11,11,14,13,10, - 10,11,13,13,12,13,13,15,15,12,11,13,12,14, 9,10, - 10,12,13,10,11,11,13,14,10,11,11,13,13,12,13,13, - 15,15,12,13,12,15,12, 8, 9, 9,12,12, 9,11,10,13, - 13, 9,10,10,13,13,12,13,13,15,15,12,12,12,14,14, - 9,10,10,13,13,10,11,11,13,14,10,11,11,14,12,13, - 13,14,14,16,12,13,13,15,14, 9,10,10,13,13,10,11, - 10,14,13,10,11,11,13,14,12,14,13,16,14,13,13,13, - 14,15,11,13,12,15,14,11,12,13,14,15,12,13,13,16, - 15,14,12,15,12,16,14,15,15,17,16,11,12,12,14,15, - 11,13,11,15,14,12,13,13,15,16,13,15,12,17,13,14, - 15,15,16,16, 8, 9, 9,12,12, 9,10,10,13,13, 9,10, - 10,13,13,12,13,12,14,14,12,13,13,15,15, 9,10,10, - 13,13,10,11,11,14,13,10,10,11,13,14,12,13,13,15, - 14,12,12,14,14,16, 9,10,10,13,13,10,11,11,13,14, - 10,11,11,14,13,13,13,13,15,15,13,14,13,16,14,11, - 12,12,14,14,12,13,13,16,15,11,12,13,14,15,14,15, - 15,16,16,14,13,15,13,17,11,12,12,14,15,12,13,13, - 15,16,11,13,12,15,15,14,15,14,16,16,14,15,12,17, - 13, -}; - -static const static_codebook _44u2__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__44u2__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u2__p4_0, - 0 -}; - -static const long _vq_quantlist__44u2__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u2__p5_0[] = { - 1, 4, 4, 7, 7, 8, 8, 9, 9, 4, 6, 5, 8, 8, 8, 8, - 10,10, 4, 5, 6, 8, 8, 8, 8,10,10, 7, 8, 8, 9, 9, - 9, 9,11,11, 7, 8, 8, 9, 9, 9, 9,11,11, 8, 8, 8, - 9, 9,10,11,12,12, 8, 8, 8, 9, 9,10,10,12,12,10, - 10,10,11,11,12,12,13,13,10,10,10,11,11,12,12,13, - 13, -}; - -static const static_codebook _44u2__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44u2__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u2__p5_0, - 0 -}; - -static const long _vq_quantlist__44u2__p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u2__p6_0[] = { - 1, 4, 4, 6, 6, 8, 8,10,10,11,11,14,13, 4, 6, 5, - 8, 8, 9, 9,11,10,12,11,15,14, 4, 5, 6, 8, 8, 9, - 9,11,11,11,11,14,14, 6, 8, 8,10, 9,11,11,11,11, - 12,12,15,15, 6, 8, 8, 9, 9,11,11,11,12,12,12,15, - 15, 8,10,10,11,11,11,11,12,12,13,13,15,16, 8,10, - 10,11,11,11,11,12,12,13,13,16,16,10,11,11,12,12, - 12,12,13,13,13,13,17,16,10,11,11,12,12,12,12,13, - 13,13,14,16,17,11,12,12,13,13,13,13,14,14,15,14, - 18,17,11,12,12,13,13,13,13,14,14,14,15,19,18,14, - 15,15,15,15,16,16,18,19,18,18, 0, 0,14,15,15,16, - 15,17,17,16,18,17,18, 0, 0, -}; - -static const static_codebook _44u2__p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44u2__p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44u2__p6_0, - 0 -}; - -static const long _vq_quantlist__44u2__p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u2__p6_1[] = { - 2, 4, 4, 5, 5, 4, 5, 5, 6, 5, 4, 5, 5, 5, 6, 5, - 6, 5, 6, 6, 5, 5, 6, 6, 6, -}; - -static const static_codebook _44u2__p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44u2__p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u2__p6_1, - 0 -}; - -static const long _vq_quantlist__44u2__p7_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u2__p7_0[] = { - 1, 3, 2,12,12,12,12,12,12, 4,12,12,12,12,12,12, - 12,12, 5,12,12,12,12,12,12,12,12,12,12,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11, -}; - -static const static_codebook _44u2__p7_0 = { - 2, 81, - (char *)_vq_lengthlist__44u2__p7_0, - 1, -516612096, 1626677248, 4, 0, - (long *)_vq_quantlist__44u2__p7_0, - 0 -}; - -static const long _vq_quantlist__44u2__p7_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u2__p7_1[] = { - 1, 4, 4, 7, 6, 7, 6, 8, 7, 9, 7, 9, 8, 4, 7, 6, - 8, 8, 9, 8,10, 9,10,10,11,11, 4, 7, 7, 8, 8, 8, - 8, 9,10,11,11,11,11, 6, 8, 8,10,10,10,10,11,11, - 12,12,12,12, 7, 8, 8,10,10,10,10,11,11,12,12,13, - 13, 7, 9, 9,11,10,12,12,13,13,14,13,14,14, 7, 9, - 9,10,11,11,12,13,13,13,13,16,14, 9,10,10,12,12, - 13,13,14,14,15,16,15,16, 9,10,10,12,12,12,13,14, - 14,14,15,16,15,10,12,12,13,13,15,13,16,16,15,17, - 17,17,10,11,11,12,14,14,14,15,15,17,17,15,17,11, - 12,12,14,14,14,15,15,15,17,16,17,17,10,12,12,13, - 14,14,14,17,15,17,17,17,17, -}; - -static const static_codebook _44u2__p7_1 = { - 2, 169, - (char *)_vq_lengthlist__44u2__p7_1, - 1, -523010048, 1618608128, 4, 0, - (long *)_vq_quantlist__44u2__p7_1, - 0 -}; - -static const long _vq_quantlist__44u2__p7_2[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u2__p7_2[] = { - 2, 5, 5, 6, 6, 7, 7, 8, 7, 8, 8, 8, 8, 5, 6, 6, - 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 5, 6, 6, 7, 7, 8, - 7, 8, 8, 8, 8, 8, 8, 6, 7, 7, 7, 8, 8, 8, 8, 8, - 9, 9, 9, 9, 6, 7, 7, 8, 7, 8, 8, 9, 9, 9, 9, 9, - 9, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 7, 8, - 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, -}; - -static const static_codebook _44u2__p7_2 = { - 2, 169, - (char *)_vq_lengthlist__44u2__p7_2, - 1, -531103744, 1611661312, 4, 0, - (long *)_vq_quantlist__44u2__p7_2, - 0 -}; - -static const char _huff_lengthlist__44u2__short[] = { - 13,15,17,17,15,15,12,17,11, 9, 7,10,10, 9,12,17, - 10, 6, 3, 6, 5, 7,10,17,15,10, 6, 9, 8, 9,11,17, - 15, 8, 4, 7, 3, 5, 9,16,16,10, 5, 8, 4, 5, 8,16, - 13,11, 5, 8, 3, 3, 5,14,13,12, 7,10, 5, 5, 7,14, -}; - -static const static_codebook _huff_book__44u2__short = { - 2, 64, - (char *)_huff_lengthlist__44u2__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u3__long[] = { - 6, 9,13,12,14,11,10,13, 8, 4, 5, 7, 8, 7, 8,12, - 11, 4, 3, 5, 5, 7, 9,14,11, 6, 5, 6, 6, 6, 7,13, - 13, 7, 5, 6, 4, 5, 7,14,11, 7, 6, 6, 5, 5, 6,13, - 9, 7, 8, 6, 7, 5, 3, 9, 9,12,13,12,14,10, 6, 7, -}; - -static const static_codebook _huff_book__44u3__long = { - 2, 64, - (char *)_huff_lengthlist__44u3__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u3__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u3__p1_0[] = { - 1, 4, 4, 5, 8, 7, 5, 7, 8, 5, 8, 8, 8,10,11, 8, - 10,11, 5, 8, 8, 8,11,10, 8,11,11, 4, 8, 8, 8,11, - 11, 8,11,11, 8,11,11,11,13,14,11,14,14, 8,11,11, - 10,14,12,11,14,14, 4, 8, 8, 8,11,11, 8,11,11, 7, - 11,11,11,14,14,10,12,14, 8,11,11,11,14,14,11,14, - 13, -}; - -static const static_codebook _44u3__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u3__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u3__p1_0, - 0 -}; - -static const long _vq_quantlist__44u3__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u3__p2_0[] = { - 2, 5, 4, 5, 6, 6, 5, 6, 6, 5, 6, 6, 7, 8, 8, 6, - 8, 8, 5, 6, 6, 6, 8, 8, 7, 8, 8, 5, 7, 6, 7, 8, - 8, 6, 8, 8, 7, 8, 8, 8, 9,10, 8,10,10, 6, 8, 8, - 8,10, 8, 8,10,10, 5, 6, 6, 6, 8, 8, 7, 8, 8, 6, - 8, 8, 8,10,10, 8, 8,10, 7, 8, 8, 8,10,10, 8,10, - 9, -}; - -static const static_codebook _44u3__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__44u3__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u3__p2_0, - 0 -}; - -static const long _vq_quantlist__44u3__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u3__p3_0[] = { - 2, 4, 4, 7, 7, 5, 7, 7, 9, 9, 5, 7, 7, 9, 9, 8, - 9, 9,12,12, 8, 9, 9,11,12, 5, 7, 7,10,10, 7, 9, - 9,11,11, 7, 9, 9,10,11,10,11,11,13,13, 9,10,11, - 13,13, 5, 7, 7,10,10, 7, 9, 9,11,10, 7, 9, 9,11, - 11, 9,11,10,13,13,10,11,11,14,13, 8,10,10,14,13, - 10,11,11,15,14, 9,11,11,14,14,13,14,13,16,16,12, - 13,13,15,15, 8,10,10,13,14, 9,11,11,14,14,10,11, - 11,14,15,12,13,13,15,15,13,14,14,15,16, 5, 7, 7, - 10,10, 7, 9, 9,11,11, 7, 9, 9,11,12,10,11,11,14, - 14,10,11,11,14,14, 7, 9, 9,12,12, 9,11,11,13,13, - 9,11,11,13,13,12,12,13,15,15,11,12,13,15,16, 7, - 9, 9,11,11, 8,11,10,13,12, 9,11,11,13,13,11,13, - 12,15,13,11,13,13,15,16, 9,12,11,15,14,11,12,13, - 16,15,11,13,13,15,16,14,14,15,17,16,13,15,16, 0, - 17, 9,11,11,15,15,10,13,12,15,15,11,13,13,15,16, - 13,15,13,16,15,14,16,15, 0,19, 5, 7, 7,10,10, 7, - 9, 9,11,11, 7, 9, 9,11,11,10,12,11,14,14,10,11, - 12,14,14, 7, 9, 9,12,12, 9,11,11,14,13, 9,10,11, - 12,13,11,13,13,16,16,11,12,13,13,16, 7, 9, 9,12, - 12, 9,11,11,13,13, 9,11,11,13,13,11,13,13,15,15, - 12,13,12,15,14, 9,11,11,15,14,11,13,12,16,16,10, - 12,12,15,15,13,15,15,17,19,13,14,15,16,17,10,12, - 12,15,15,11,13,13,16,16,11,13,13,15,16,13,15,15, - 0, 0,14,15,15,16,16, 8,10,10,14,14,10,12,12,15, - 15,10,12,11,15,16,14,15,15,19,20,13,14,14,18,16, - 9,11,11,15,15,11,13,13,17,16,11,13,13,16,16,15, - 17,17,20,20,14,15,16,17,20, 9,11,11,15,15,10,13, - 12,16,15,11,13,13,15,17,14,16,15,18, 0,14,16,15, - 18,20,12,14,14, 0, 0,14,14,16, 0, 0,13,16,15, 0, - 0,17,17,18, 0, 0,16,17,19,19, 0,12,14,14,18, 0, - 12,16,14, 0,17,13,15,15,18, 0,16,18,17, 0,17,16, - 18,17, 0, 0, 7,10,10,14,14,10,12,11,15,15,10,12, - 12,16,15,13,15,15,18, 0,14,15,15,17, 0, 9,11,11, - 15,15,11,13,13,16,16,11,12,13,16,16,14,15,16,17, - 17,14,16,16,16,18, 9,11,12,16,16,11,13,13,17,17, - 11,14,13,20,17,15,16,16,19, 0,15,16,17, 0,19,11, - 13,14,17,16,14,15,15,20,18,13,14,15,17,19,16,18, - 18, 0,20,16,16,19,17, 0,12,15,14,17, 0,14,15,15, - 18,19,13,16,15,19,20,15,18,18, 0,20,17, 0,16, 0, - 0, -}; - -static const static_codebook _44u3__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44u3__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u3__p3_0, - 0 -}; - -static const long _vq_quantlist__44u3__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u3__p4_0[] = { - 4, 5, 5, 8, 8, 5, 7, 6, 9, 9, 5, 6, 7, 9, 9, 9, - 9, 9,11,11, 9, 9, 9,11,11, 5, 7, 7, 9, 9, 7, 8, - 8,10,10, 7, 7, 8,10,10, 9,10,10,11,12, 9,10,10, - 11,12, 5, 7, 7, 9, 9, 7, 8, 7,10,10, 7, 8, 8,10, - 10, 9,10, 9,12,11, 9,10,10,12,11, 9,10, 9,12,12, - 9,10,10,13,12, 9,10,10,12,13,12,12,12,14,14,11, - 12,12,13,14, 9, 9,10,12,12, 9,10,10,12,12, 9,10, - 10,12,13,11,12,11,14,13,12,12,12,14,13, 5, 7, 7, - 9, 9, 7, 8, 8,10,10, 7, 8, 8,10,10,10,10,10,12, - 12, 9,10,10,12,12, 7, 8, 8,11,10, 8, 8, 9,11,11, - 8, 9, 9,11,11,11,11,11,12,13,10,11,11,13,13, 6, - 8, 8,10,10, 7, 9, 8,11,10, 8, 9, 9,11,11,10,11, - 10,13,11,10,11,11,13,13, 9,11,10,13,12,10,11,11, - 13,13,10,11,11,13,13,12,12,13,12,15,12,13,13,15, - 15, 9,10,10,12,13,10,11,10,13,12,10,11,11,13,14, - 12,13,11,15,13,12,13,13,15,15, 5, 7, 7, 9, 9, 7, - 8, 8,10,10, 7, 8, 8,10,10, 9,10,10,12,12,10,10, - 11,12,12, 6, 8, 8,10,10, 8, 9, 9,11,11, 7, 8, 9, - 10,11,10,11,11,13,13,10,10,11,11,13, 7, 8, 8,10, - 10, 8, 9, 9,11,11, 8, 9, 9,11,11,10,11,11,13,13, - 11,11,11,13,12, 9,10,10,13,12,10,11,11,14,13,10, - 10,11,12,13,12,13,13,15,15,12,11,13,13,14, 9,10, - 11,12,13,10,11,11,13,13,10,11,11,13,13,12,13,13, - 15,15,12,13,12,15,12, 8, 9, 9,12,12, 9,11,10,13, - 13, 9,10,10,13,13,12,13,13,15,14,12,12,12,14,13, - 9,10,10,13,12,10,11,11,13,13,10,11,11,14,12,13, - 13,14,14,16,12,13,13,15,15, 9,10,10,13,13,10,11, - 10,14,13,10,11,11,13,14,12,14,13,15,14,13,13,13, - 15,15,11,13,12,15,14,11,12,13,14,15,12,13,13,16, - 14,14,12,15,12,16,14,15,15,17,15,11,12,12,14,14, - 11,13,11,15,14,12,13,13,15,15,13,15,12,17,13,14, - 15,15,16,16, 8, 9, 9,12,12, 9,10,10,12,13, 9,10, - 10,13,13,12,12,12,14,14,12,13,13,15,15, 9,10,10, - 13,12,10,11,11,14,13,10,10,11,13,14,12,13,13,15, - 15,12,12,13,14,16, 9,10,10,13,13,10,11,11,13,14, - 10,11,11,14,13,12,13,13,14,15,13,14,13,16,14,11, - 12,12,14,14,12,13,13,15,14,11,12,13,14,15,14,15, - 15,16,16,13,13,15,13,16,11,12,12,14,15,12,13,13, - 14,15,11,13,12,15,14,14,15,15,16,16,14,15,12,16, - 13, -}; - -static const static_codebook _44u3__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__44u3__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u3__p4_0, - 0 -}; - -static const long _vq_quantlist__44u3__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u3__p5_0[] = { - 2, 3, 3, 6, 6, 7, 7, 9, 9, 4, 5, 5, 7, 7, 8, 8, - 10,10, 4, 5, 5, 7, 7, 8, 8,10,10, 6, 7, 7, 8, 8, - 9, 9,11,10, 6, 7, 7, 8, 8, 9, 9,10,10, 7, 8, 8, - 9, 9,10,10,11,11, 7, 8, 8, 9, 9,10,10,11,11, 9, - 10,10,11,10,11,11,12,12, 9,10,10,10,10,11,11,12, - 12, -}; - -static const static_codebook _44u3__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44u3__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u3__p5_0, - 0 -}; - -static const long _vq_quantlist__44u3__p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u3__p6_0[] = { - 1, 4, 4, 6, 6, 8, 8, 9, 9,10,11,13,14, 4, 6, 5, - 8, 8, 9, 9,10,10,11,11,14,14, 4, 6, 6, 8, 8, 9, - 9,10,10,11,11,14,14, 6, 8, 8, 9, 9,10,10,11,11, - 12,12,15,15, 6, 8, 8, 9, 9,10,11,11,11,12,12,15, - 15, 8, 9, 9,11,10,11,11,12,12,13,13,15,16, 8, 9, - 9,10,11,11,11,12,12,13,13,16,16,10,10,11,11,11, - 12,12,13,13,13,14,17,16, 9,10,11,12,11,12,12,13, - 13,13,13,16,18,11,12,11,12,12,13,13,13,14,15,14, - 17,17,11,11,12,12,12,13,13,13,14,14,15,18,17,14, - 15,15,15,15,16,16,17,17,19,18, 0,20,14,15,14,15, - 15,16,16,16,17,18,16,20,18, -}; - -static const static_codebook _44u3__p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44u3__p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44u3__p6_0, - 0 -}; - -static const long _vq_quantlist__44u3__p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u3__p6_1[] = { - 2, 4, 4, 5, 5, 4, 5, 5, 6, 5, 4, 5, 5, 5, 6, 5, - 6, 5, 6, 6, 5, 5, 6, 6, 6, -}; - -static const static_codebook _44u3__p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44u3__p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u3__p6_1, - 0 -}; - -static const long _vq_quantlist__44u3__p7_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u3__p7_0[] = { - 1, 3, 3,10,10,10,10,10,10, 4,10,10,10,10,10,10, - 10,10, 4,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, -}; - -static const static_codebook _44u3__p7_0 = { - 2, 81, - (char *)_vq_lengthlist__44u3__p7_0, - 1, -515907584, 1627381760, 4, 0, - (long *)_vq_quantlist__44u3__p7_0, - 0 -}; - -static const long _vq_quantlist__44u3__p7_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44u3__p7_1[] = { - 1, 4, 4, 6, 6, 7, 6, 8, 7, 9, 8,10, 9,11,11, 4, - 7, 7, 8, 7, 9, 9,10,10,11,11,11,11,12,12, 4, 7, - 7, 7, 7, 9, 9,10,10,11,11,12,12,12,11, 6, 8, 8, - 9, 9,10,10,11,11,12,12,13,12,13,13, 6, 8, 8, 9, - 9,10,11,11,11,12,12,13,14,13,13, 8, 9, 9,11,11, - 12,12,12,13,14,13,14,14,14,15, 8, 9, 9,11,11,11, - 12,13,14,13,14,15,17,14,15, 9,10,10,12,12,13,13, - 13,14,15,15,15,16,16,16, 9,11,11,12,12,13,13,14, - 14,14,15,16,16,16,16,10,12,12,13,13,14,14,15,15, - 15,16,17,17,17,17,10,12,11,13,13,15,14,15,14,16, - 17,16,16,16,16,11,13,12,14,14,14,14,15,16,17,16, - 17,17,17,17,11,13,12,14,14,14,15,17,16,17,17,17, - 17,17,17,12,13,13,15,16,15,16,17,17,16,16,17,17, - 17,17,12,13,13,15,15,15,16,17,17,17,16,17,16,17, - 17, -}; - -static const static_codebook _44u3__p7_1 = { - 2, 225, - (char *)_vq_lengthlist__44u3__p7_1, - 1, -522338304, 1620115456, 4, 0, - (long *)_vq_quantlist__44u3__p7_1, - 0 -}; - -static const long _vq_quantlist__44u3__p7_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44u3__p7_2[] = { - 2, 5, 5, 7, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 10,10, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 8, 9, 9, 9, - 9,10, 9, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 10,10,10,10, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9,10, - 9,10,10,10,10, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 10,10,10,10,10,10, 7, 8, 8, 9, 8, 9, 9, 9, 9,10, - 9,10,10,10,10,10,10, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9,10,10,10,10,10,10,10, 8, 9, 8, 9, 9, 9, 9,10, - 9,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9, 9,10, - 9,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9,10, - 9,10,10,10,10,10,10,10,10,10,10, 9, 9, 9,10, 9, - 10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,10,11, 9,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,11, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 9,10,10,10,10,10,10,10,10,10,10,10,11,11,11,10, - 11, -}; - -static const static_codebook _44u3__p7_2 = { - 2, 289, - (char *)_vq_lengthlist__44u3__p7_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44u3__p7_2, - 0 -}; - -static const char _huff_lengthlist__44u3__short[] = { - 14,14,14,15,13,15,12,16,10, 8, 7, 9, 9, 8,12,16, - 10, 5, 4, 6, 5, 6, 9,16,14, 8, 6, 8, 7, 8,10,16, - 14, 7, 4, 6, 3, 5, 8,16,15, 9, 5, 7, 4, 4, 7,16, - 13,10, 6, 7, 4, 3, 4,13,13,12, 7, 9, 5, 5, 6,12, -}; - -static const static_codebook _huff_book__44u3__short = { - 2, 64, - (char *)_huff_lengthlist__44u3__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u4__long[] = { - 3, 8,12,12,13,12,11,13, 5, 4, 6, 7, 8, 8, 9,13, - 9, 5, 4, 5, 5, 7, 9,13, 9, 6, 5, 6, 6, 7, 8,12, - 12, 7, 5, 6, 4, 5, 8,13,11, 7, 6, 6, 5, 5, 6,12, - 10, 8, 8, 7, 7, 5, 3, 8,10,12,13,12,12, 9, 6, 7, -}; - -static const static_codebook _huff_book__44u4__long = { - 2, 64, - (char *)_huff_lengthlist__44u4__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u4__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u4__p1_0[] = { - 1, 4, 4, 5, 8, 7, 5, 7, 8, 5, 8, 8, 8,10,11, 8, - 10,11, 5, 8, 8, 8,11,10, 8,11,11, 4, 8, 8, 8,11, - 11, 8,11,11, 8,11,11,11,13,14,11,15,14, 8,11,11, - 10,13,12,11,14,14, 4, 8, 8, 8,11,11, 8,11,11, 7, - 11,11,11,15,14,10,12,14, 8,11,11,11,14,14,11,14, - 13, -}; - -static const static_codebook _44u4__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u4__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u4__p1_0, - 0 -}; - -static const long _vq_quantlist__44u4__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u4__p2_0[] = { - 2, 5, 5, 5, 6, 6, 5, 6, 6, 5, 6, 6, 7, 8, 8, 6, - 8, 8, 5, 6, 6, 6, 8, 8, 7, 8, 8, 5, 7, 6, 6, 8, - 8, 6, 8, 8, 6, 8, 8, 8, 9,10, 8,10,10, 6, 8, 8, - 8,10, 8, 8,10,10, 5, 6, 6, 6, 8, 8, 6, 8, 8, 6, - 8, 8, 8,10,10, 8, 8,10, 6, 8, 8, 8,10,10, 8,10, - 9, -}; - -static const static_codebook _44u4__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__44u4__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u4__p2_0, - 0 -}; - -static const long _vq_quantlist__44u4__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u4__p3_0[] = { - 2, 4, 4, 8, 8, 5, 7, 7, 9, 9, 5, 7, 7, 9, 9, 8, - 10, 9,12,12, 8, 9,10,12,12, 5, 7, 7,10,10, 7, 9, - 9,11,11, 7, 9, 9,11,11,10,12,11,14,14, 9,10,11, - 13,14, 5, 7, 7,10,10, 7, 9, 9,11,11, 7, 9, 9,11, - 11, 9,11,10,14,13,10,11,11,14,14, 8,10,10,14,13, - 10,12,12,15,14, 9,11,11,15,14,13,14,14,17,17,12, - 14,14,16,16, 8,10,10,14,14, 9,11,11,14,15,10,12, - 12,14,15,12,14,13,16,16,13,14,15,15,18, 4, 7, 7, - 10,10, 7, 9, 9,12,11, 7, 9, 9,11,12,10,12,11,15, - 14,10,11,12,14,15, 7, 9, 9,12,12, 9,11,12,13,13, - 9,11,12,13,13,12,13,13,15,16,11,13,13,15,16, 7, - 9, 9,12,12, 9,11,10,13,12, 9,11,12,13,14,11,13, - 12,16,14,12,13,13,15,16,10,12,12,16,15,11,13,13, - 17,16,11,13,13,17,16,14,15,15,17,17,14,16,16,18, - 20, 9,11,11,15,16,11,13,12,16,16,11,13,13,16,17, - 14,15,14,18,16,14,16,16,17,20, 5, 7, 7,10,10, 7, - 9, 9,12,11, 7, 9,10,11,12,10,12,11,15,15,10,12, - 12,14,14, 7, 9, 9,12,12, 9,12,11,14,13, 9,10,11, - 12,13,12,13,14,16,16,11,12,13,14,16, 7, 9, 9,12, - 12, 9,12,11,13,13, 9,12,11,13,13,11,13,13,16,16, - 12,13,13,16,15, 9,11,11,16,14,11,13,13,16,16,11, - 12,13,16,16,14,16,16,17,17,13,14,15,16,17,10,12, - 12,15,15,11,13,13,16,17,11,13,13,16,16,14,16,15, - 19,19,14,15,15,17,18, 8,10,10,14,14,10,12,12,15, - 15,10,12,12,16,16,14,16,15,20,19,13,15,15,17,16, - 9,12,12,16,16,11,13,13,16,18,11,14,13,16,17,16, - 17,16,20, 0,15,16,18,18,20, 9,11,11,15,15,11,14, - 12,17,16,11,13,13,17,17,15,17,15,20,20,14,16,16, - 17, 0,13,15,14,18,16,14,15,16, 0,18,14,16,16, 0, - 0,18,16, 0, 0,20,16,18,18, 0, 0,12,14,14,17,18, - 13,15,14,20,18,14,16,15,19,19,16,20,16, 0,18,16, - 19,17,19, 0, 8,10,10,14,14,10,12,12,16,15,10,12, - 12,16,16,13,15,15,18,17,14,16,16,19, 0, 9,11,11, - 16,15,11,14,13,18,17,11,12,13,17,18,14,17,16,18, - 18,15,16,17,18,18, 9,12,12,16,16,11,13,13,16,18, - 11,14,13,17,17,15,16,16,18,20,16,17,17,20,20,12, - 14,14,18,17,14,16,16, 0,19,13,14,15,18, 0,16, 0, - 0, 0, 0,16,16, 0,19,20,13,15,14, 0, 0,14,16,16, - 18,19,14,16,15, 0,20,16,20,18, 0,20,17,20,17, 0, - 0, -}; - -static const static_codebook _44u4__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44u4__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u4__p3_0, - 0 -}; - -static const long _vq_quantlist__44u4__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u4__p4_0[] = { - 4, 5, 5, 8, 8, 5, 7, 6, 9, 9, 5, 6, 7, 9, 9, 9, - 9, 9,11,11, 8, 9, 9,11,11, 5, 7, 7, 9, 9, 7, 8, - 8,10,10, 7, 7, 8,10,10, 9,10,10,11,12, 9,10,10, - 11,12, 5, 7, 7, 9, 9, 7, 8, 7,10,10, 7, 8, 8,10, - 10, 9,10,10,12,11, 9,10,10,12,11, 9,10, 9,12,12, - 9,10,10,13,12, 9,10,10,12,12,12,12,12,14,14,11, - 12,12,13,14, 9, 9,10,12,12, 9,10,10,13,13, 9,10, - 10,12,13,11,12,12,14,13,11,12,12,14,14, 5, 7, 7, - 9, 9, 7, 8, 8,10,10, 7, 8, 8,10,10,10,10,10,12, - 12, 9,10,10,12,12, 7, 8, 8,11,10, 8, 8, 9,11,11, - 8, 9, 9,11,11,11,11,11,12,13,10,11,11,13,13, 6, - 8, 8,10,10, 7, 9, 8,11,10, 8, 9, 9,11,11,10,11, - 10,13,11,10,11,11,13,13, 9,11,10,13,12,10,11,11, - 13,14,10,11,11,14,13,12,12,13,12,15,12,13,13,15, - 15, 9,10,10,12,13,10,11,10,13,12,10,11,11,13,14, - 12,13,11,15,13,13,13,13,15,15, 5, 7, 7, 9, 9, 7, - 8, 8,10,10, 7, 8, 8,10,10, 9,10,10,12,12,10,10, - 11,12,13, 6, 8, 8,10,10, 8, 9, 9,11,11, 7, 8, 9, - 10,11,10,11,11,13,13,10,10,11,11,13, 7, 8, 8,10, - 11, 8, 9, 9,11,11, 8, 9, 8,11,11,10,11,11,13,13, - 11,12,11,13,12, 9,10,10,13,12,10,11,11,14,13,10, - 10,11,12,13,12,13,13,15,15,12,11,13,13,14, 9,10, - 11,12,13,10,11,11,13,14,10,11,11,13,13,12,13,13, - 15,15,12,13,12,15,12, 8, 9, 9,12,12, 9,11,10,13, - 13, 9,10,10,13,13,12,13,13,15,15,12,12,12,14,14, - 9,10,10,13,13,10,11,11,13,14,10,11,11,14,13,13, - 13,14,14,16,13,13,13,15,15, 9,10,10,13,13,10,11, - 10,14,13,10,11,11,13,14,12,14,13,16,14,12,13,13, - 14,15,11,12,12,15,14,11,12,13,14,15,12,13,13,16, - 15,14,12,15,12,16,14,15,15,16,16,11,12,12,14,14, - 11,13,12,15,14,12,13,13,15,16,13,15,13,17,13,14, - 15,15,16,17, 8, 9, 9,12,12, 9,10,10,12,13, 9,10, - 10,13,13,12,12,12,14,14,12,13,13,15,15, 9,10,10, - 13,12,10,11,11,14,13,10,10,11,13,14,13,13,13,15, - 15,12,13,14,14,16, 9,10,10,13,13,10,11,11,13,14, - 10,11,11,14,14,13,13,13,15,15,13,14,13,16,14,11, - 12,12,15,14,12,13,13,16,15,11,12,13,14,15,14,15, - 15,17,16,13,13,15,13,16,11,12,13,14,15,13,13,13, - 15,16,11,13,12,15,14,14,15,15,16,16,14,15,12,17, - 13, -}; - -static const static_codebook _44u4__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__44u4__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u4__p4_0, - 0 -}; - -static const long _vq_quantlist__44u4__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u4__p5_0[] = { - 2, 3, 3, 6, 6, 7, 7, 9, 9, 4, 5, 5, 7, 7, 8, 8, - 10, 9, 4, 5, 5, 7, 7, 8, 8,10,10, 6, 7, 7, 8, 8, - 9, 9,11,10, 6, 7, 7, 8, 8, 9, 9,10,11, 7, 8, 8, - 9, 9,10,10,11,11, 7, 8, 8, 9, 9,10,10,11,11, 9, - 10,10,11,10,11,11,12,12, 9,10,10,10,11,11,11,12, - 12, -}; - -static const static_codebook _44u4__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44u4__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u4__p5_0, - 0 -}; - -static const long _vq_quantlist__44u4__p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u4__p6_0[] = { - 1, 4, 4, 6, 6, 8, 8, 9, 9,11,10,13,13, 4, 6, 5, - 8, 8, 9, 9,10,10,11,11,14,14, 4, 6, 6, 8, 8, 9, - 9,10,10,11,11,14,14, 6, 8, 8, 9, 9,10,10,11,11, - 12,12,15,15, 6, 8, 8, 9, 9,10,11,11,11,12,12,15, - 15, 8, 9, 9,11,10,11,11,12,12,13,13,16,16, 8, 9, - 9,10,10,11,11,12,12,13,13,16,16,10,10,10,12,11, - 12,12,13,13,14,14,16,16,10,10,10,11,12,12,12,13, - 13,13,14,16,17,11,12,11,12,12,13,13,14,14,15,14, - 18,17,11,11,12,12,12,13,13,14,14,14,15,19,18,14, - 15,14,15,15,17,16,17,17,17,17,21, 0,14,15,15,16, - 16,16,16,17,17,18,17,20,21, -}; - -static const static_codebook _44u4__p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44u4__p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44u4__p6_0, - 0 -}; - -static const long _vq_quantlist__44u4__p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u4__p6_1[] = { - 2, 4, 4, 5, 5, 4, 5, 5, 6, 5, 4, 5, 5, 5, 6, 5, - 6, 5, 6, 6, 5, 5, 6, 6, 6, -}; - -static const static_codebook _44u4__p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44u4__p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u4__p6_1, - 0 -}; - -static const long _vq_quantlist__44u4__p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u4__p7_0[] = { - 1, 3, 3,12,12,12,12,12,12,12,12,12,12, 3,12,11, - 12,12,12,12,12,12,12,12,12,12, 4,11,10,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11, -}; - -static const static_codebook _44u4__p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44u4__p7_0, - 1, -514332672, 1627381760, 4, 0, - (long *)_vq_quantlist__44u4__p7_0, - 0 -}; - -static const long _vq_quantlist__44u4__p7_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44u4__p7_1[] = { - 1, 4, 4, 6, 6, 7, 7, 9, 8,10, 8,10, 9,11,11, 4, - 7, 6, 8, 7, 9, 9,10,10,11,10,11,10,12,10, 4, 6, - 7, 8, 8, 9, 9,10,10,11,11,11,11,12,12, 6, 8, 8, - 10, 9,11,10,12,11,12,12,12,12,13,13, 6, 8, 8,10, - 10,10,11,11,11,12,12,13,12,13,13, 8, 9, 9,11,11, - 12,11,12,12,13,13,13,13,13,13, 8, 9, 9,11,11,11, - 12,12,12,13,13,13,13,13,13, 9,10,10,12,11,13,13, - 13,13,14,13,13,14,14,14, 9,10,11,11,12,12,13,13, - 13,13,13,14,15,14,14,10,11,11,12,12,13,13,14,14, - 14,14,14,15,16,16,10,11,11,12,13,13,13,13,15,14, - 14,15,16,15,16,10,12,12,13,13,14,14,14,15,15,15, - 15,15,15,16,11,12,12,13,13,14,14,14,15,15,15,16, - 15,17,16,11,12,12,13,13,13,15,15,14,16,16,16,16, - 16,17,11,12,12,13,13,14,14,15,14,15,15,17,17,16, - 16, -}; - -static const static_codebook _44u4__p7_1 = { - 2, 225, - (char *)_vq_lengthlist__44u4__p7_1, - 1, -522338304, 1620115456, 4, 0, - (long *)_vq_quantlist__44u4__p7_1, - 0 -}; - -static const long _vq_quantlist__44u4__p7_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44u4__p7_2[] = { - 2, 5, 5, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 10,10,10,10, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9,10, - 9,10, 9,10,10, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 10,10,10,10,10,10, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9,10,10,10,10,10,10, 8, 9, 8, 9, 9, 9, 9, 9, 9, - 10,10,10,10,10,10,10,10, 8, 8, 8, 9, 9, 9, 9, 9, - 10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9,10,10, - 10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9,10, - 10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9,10, - 10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, - 10,10,10,10,10,10,10,10,10,11,10,10,10, 9, 9, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, - 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10, 9, - 10, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 9,10, 9,10,10,10,10,10,10,10,10,10,10,11,10,10, - 10, -}; - -static const static_codebook _44u4__p7_2 = { - 2, 289, - (char *)_vq_lengthlist__44u4__p7_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44u4__p7_2, - 0 -}; - -static const char _huff_lengthlist__44u4__short[] = { - 14,17,15,17,16,14,13,16,10, 7, 7,10,13,10,15,16, - 9, 4, 4, 6, 5, 7, 9,16,12, 8, 7, 8, 8, 8,11,16, - 14, 7, 4, 6, 3, 5, 8,15,13, 8, 5, 7, 4, 5, 7,16, - 12, 9, 6, 8, 3, 3, 5,16,14,13, 7,10, 5, 5, 7,15, -}; - -static const static_codebook _huff_book__44u4__short = { - 2, 64, - (char *)_huff_lengthlist__44u4__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u5__long[] = { - 3, 8,13,12,14,12,16,11,13,14, 5, 4, 5, 6, 7, 8, - 10, 9,12,15,10, 5, 5, 5, 6, 8, 9, 9,13,15,10, 5, - 5, 6, 6, 7, 8, 8,11,13,12, 7, 5, 6, 4, 6, 7, 7, - 11,14,11, 7, 7, 6, 6, 6, 7, 6,10,14,14, 9, 8, 8, - 6, 7, 7, 7,11,16,11, 8, 8, 7, 6, 6, 7, 4, 7,12, - 10,10,12,10,10, 9,10, 5, 6, 9,10,12,15,13,14,14, - 14, 8, 7, 8, -}; - -static const static_codebook _huff_book__44u5__long = { - 2, 100, - (char *)_huff_lengthlist__44u5__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u5__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u5__p1_0[] = { - 1, 4, 4, 5, 8, 7, 5, 7, 7, 5, 8, 8, 8,10,10, 7, - 9,10, 5, 8, 8, 7,10, 9, 8,10,10, 5, 8, 8, 8,10, - 10, 8,10,10, 8,10,10,10,12,13,10,13,13, 7,10,10, - 10,13,11,10,13,13, 4, 8, 8, 8,11,10, 8,10,10, 7, - 10,10,10,13,13,10,11,13, 8,10,11,10,13,13,10,13, - 12, -}; - -static const static_codebook _44u5__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u5__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u5__p1_0, - 0 -}; - -static const long _vq_quantlist__44u5__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u5__p2_0[] = { - 3, 4, 4, 5, 6, 6, 5, 6, 6, 5, 6, 6, 6, 8, 8, 6, - 7, 8, 5, 6, 6, 6, 8, 7, 6, 8, 8, 5, 6, 6, 6, 8, - 8, 6, 8, 8, 6, 8, 8, 8, 9, 9, 8, 9, 9, 6, 8, 7, - 7, 9, 8, 8, 9, 9, 5, 6, 6, 6, 8, 7, 6, 8, 8, 6, - 8, 7, 8, 9, 9, 7, 8, 9, 6, 8, 8, 8, 9, 9, 8, 9, - 9, -}; - -static const static_codebook _44u5__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__44u5__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u5__p2_0, - 0 -}; - -static const long _vq_quantlist__44u5__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u5__p3_0[] = { - 2, 4, 5, 8, 8, 5, 7, 6, 9, 9, 5, 6, 7, 9, 9, 8, - 10, 9,13,12, 8, 9,10,12,12, 5, 7, 7,10,10, 7, 9, - 9,11,11, 6, 8, 9,11,11,10,11,11,14,14, 9,10,11, - 13,14, 5, 7, 7, 9,10, 7, 9, 8,11,11, 7, 9, 9,11, - 11, 9,11,10,14,13,10,11,11,14,14, 8,10,10,13,13, - 10,11,11,15,14, 9,11,11,14,14,13,14,14,17,16,12, - 13,13,15,16, 8,10,10,13,13, 9,11,11,14,15,10,11, - 11,14,15,12,14,13,16,16,13,15,14,15,17, 5, 7, 7, - 10,10, 7, 9, 9,11,11, 7, 9, 9,11,11,10,11,11,14, - 14,10,11,12,14,14, 7, 9, 9,12,11, 9,11,11,13,13, - 9,11,11,13,13,12,13,13,15,16,11,12,13,15,16, 6, - 9, 9,11,11, 8,11,10,13,12, 9,11,11,13,14,11,13, - 12,16,14,11,13,13,16,17,10,12,11,15,15,11,13,13, - 16,16,11,13,13,17,16,14,15,15,17,17,14,16,16,17, - 18, 9,11,11,14,15,10,12,12,15,15,11,13,13,16,17, - 13,15,13,17,15,14,15,16,18, 0, 5, 7, 7,10,10, 7, - 9, 9,11,11, 7, 9, 9,11,11,10,11,11,14,14,10,11, - 12,14,15, 6, 9, 9,12,11, 9,11,11,13,13, 8,10,11, - 12,13,11,13,13,16,15,11,12,13,14,15, 7, 9, 9,11, - 12, 9,11,11,13,13, 9,11,11,13,13,11,13,13,15,16, - 11,13,13,15,14, 9,11,11,15,14,11,13,13,17,15,10, - 12,12,15,15,14,16,16,17,17,13,13,15,15,17,10,11, - 12,15,15,11,13,13,16,16,11,13,13,15,15,14,15,15, - 18,18,14,15,15,17,17, 8,10,10,13,13,10,12,11,15, - 15,10,11,12,15,15,14,15,15,18,18,13,14,14,18,18, - 9,11,11,15,16,11,13,13,17,17,11,13,13,16,16,15, - 15,16,17, 0,14,15,17, 0, 0, 9,11,11,15,15,10,13, - 12,18,16,11,13,13,15,16,14,16,15,20,20,14,15,16, - 17, 0,13,14,14,20,16,14,15,16,19,18,14,15,15,19, - 0,18,16, 0,20,20,16,18,18, 0, 0,12,14,14,18,18, - 13,15,14,18,16,14,15,16,18,20,16,19,16, 0,17,17, - 18,18,19, 0, 8,10,10,14,14,10,11,11,14,15,10,11, - 12,15,15,13,15,14,19,17,13,15,15,17, 0, 9,11,11, - 16,15,11,13,13,16,16,10,12,13,15,17,14,16,16,18, - 18,14,15,15,18, 0, 9,11,11,15,15,11,13,13,16,17, - 11,13,13,18,17,14,18,16,18,18,15,17,17,18, 0,12, - 14,14,18,18,14,15,15,20, 0,13,14,15,17, 0,16,18, - 17, 0, 0,16,16, 0,17,20,12,14,14,18,18,14,16,15, - 0,18,14,16,15,18, 0,16,19,17, 0, 0,17,18,16, 0, - 0, -}; - -static const static_codebook _44u5__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44u5__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u5__p3_0, - 0 -}; - -static const long _vq_quantlist__44u5__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u5__p4_0[] = { - 4, 5, 5, 8, 8, 6, 7, 6, 9, 9, 6, 6, 7, 9, 9, 8, - 9, 9,11,11, 8, 9, 9,11,11, 6, 7, 7, 9, 9, 7, 8, - 8,10,10, 6, 7, 8, 9,10, 9,10,10,11,12, 9, 9,10, - 11,12, 6, 7, 7, 9, 9, 6, 8, 7,10, 9, 7, 8, 8,10, - 10, 9,10, 9,12,11, 9,10,10,12,11, 8, 9, 9,12,11, - 9,10,10,12,12, 9,10,10,12,12,11,12,12,13,14,11, - 11,12,13,14, 8, 9, 9,11,12, 9,10,10,12,12, 9,10, - 10,12,12,11,12,11,14,13,11,12,12,13,13, 5, 7, 7, - 9, 9, 7, 8, 8,10,10, 7, 8, 8,10,10, 9,10,10,12, - 12, 9,10,10,12,12, 7, 8, 8,10,10, 8, 8, 9,10,11, - 8, 9, 9,11,11,10,10,11,11,13,10,11,11,12,13, 6, - 7, 8,10,10, 7, 9, 8,11,10, 8, 9, 9,11,11,10,11, - 10,13,11,10,11,11,12,12, 9,10,10,12,12,10,10,11, - 12,13,10,11,11,13,13,12,11,13,12,15,12,13,13,14, - 15, 9,10,10,12,12, 9,11,10,13,12,10,11,11,13,13, - 11,13,11,14,12,12,13,13,14,15, 5, 7, 7, 9, 9, 7, - 8, 8,10,10, 7, 8, 8,10,10, 9,10,10,12,12, 9,10, - 10,12,12, 6, 8, 7,10,10, 8, 9, 9,11,11, 7, 8, 9, - 10,11,10,11,11,12,12,10,10,11,11,13, 7, 8, 8,10, - 10, 8, 9, 9,11,11, 8, 9, 8,11,10,10,11,11,13,12, - 10,11,10,13,11, 9,10,10,12,12,10,11,11,13,12, 9, - 10,10,12,13,12,13,13,14,15,11,11,13,12,14, 9,10, - 10,12,12,10,11,11,13,13,10,11,10,13,12,12,13,13, - 14,14,12,13,11,14,12, 8, 9, 9,12,12, 9,10,10,12, - 12, 9,10,10,12,12,12,12,12,14,14,11,12,12,14,13, - 9,10,10,12,12,10,11,11,13,13,10,11,11,13,12,12, - 12,13,14,15,12,13,13,15,14, 9,10,10,12,12,10,11, - 10,13,12,10,11,11,12,13,12,13,12,15,13,12,13,13, - 14,15,11,12,12,14,13,11,12,12,14,15,12,13,13,15, - 14,13,12,14,12,16,13,14,14,15,15,11,11,12,14,14, - 11,12,11,14,13,12,13,13,14,15,13,14,12,16,12,14, - 14,15,16,16, 8, 9, 9,11,12, 9,10,10,12,12, 9,10, - 10,12,13,11,12,12,13,13,12,12,13,14,14, 9,10,10, - 12,12,10,11,10,13,12,10,10,11,12,13,12,13,13,15, - 14,12,12,13,13,15, 9,10,10,12,13,10,11,11,12,13, - 10,11,11,13,13,12,13,13,14,15,12,13,12,15,14,11, - 12,11,14,13,12,13,13,15,14,11,11,12,13,14,14,15, - 14,16,15,13,12,14,13,16,11,12,12,13,14,12,13,13, - 14,15,11,12,11,14,14,14,14,14,15,16,13,15,12,16, - 12, -}; - -static const static_codebook _44u5__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__44u5__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u5__p4_0, - 0 -}; - -static const long _vq_quantlist__44u5__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u5__p5_0[] = { - 2, 3, 3, 6, 6, 8, 8,10,10, 4, 5, 5, 8, 7, 8, 8, - 11,10, 3, 5, 5, 7, 8, 8, 8,10,11, 6, 8, 7,10, 9, - 10,10,11,11, 6, 7, 8, 9, 9, 9,10,11,12, 8, 8, 8, - 10,10,11,11,13,12, 8, 8, 9, 9,10,11,11,12,13,10, - 11,10,12,11,13,12,14,14,10,10,11,11,12,12,13,14, - 14, -}; - -static const static_codebook _44u5__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44u5__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u5__p5_0, - 0 -}; - -static const long _vq_quantlist__44u5__p6_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u5__p6_0[] = { - 3, 4, 4, 5, 5, 7, 7, 9, 9, 4, 5, 4, 6, 6, 7, 7, - 9, 9, 4, 4, 5, 6, 6, 7, 7, 9, 9, 5, 6, 6, 7, 7, - 8, 8,10,10, 6, 6, 6, 7, 7, 8, 8,10,10, 7, 7, 7, - 8, 8, 9, 9,11,10, 7, 7, 7, 8, 8, 9, 9,10,11, 9, - 9, 9,10,10,11,10,11,11, 9, 9, 9,10,10,11,10,11, - 11, -}; - -static const static_codebook _44u5__p6_0 = { - 2, 81, - (char *)_vq_lengthlist__44u5__p6_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u5__p6_0, - 0 -}; - -static const long _vq_quantlist__44u5__p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u5__p7_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 9, 9, 8,11,10, 7, - 11,10, 5, 9, 9, 7,10,10, 8,10,11, 4, 9, 9, 9,12, - 12, 9,12,12, 8,12,12,11,12,12,10,12,13, 7,12,12, - 11,12,12,10,12,13, 4, 9, 9, 9,12,12, 9,12,12, 7, - 12,11,10,13,13,11,12,12, 7,12,12,10,13,13,11,12, - 12, -}; - -static const static_codebook _44u5__p7_0 = { - 4, 81, - (char *)_vq_lengthlist__44u5__p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44u5__p7_0, - 0 -}; - -static const long _vq_quantlist__44u5__p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u5__p7_1[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8, 4, 5, 5, 7, 7, - 8, 8, 9, 8, 8, 9, 4, 5, 5, 7, 7, 8, 8, 9, 9, 8, - 9, 6, 7, 7, 8, 8, 9, 8, 9, 9, 9, 9, 6, 7, 7, 8, - 8, 9, 9, 9, 9, 9, 9, 7, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, - 9, 9, 9, 9,10,10,10,10, 8, 9, 9, 9, 9, 9, 9,10, - 10,10,10, 8, 9, 9, 9, 9, 9, 9,10,10,10,10, 8, 9, - 9, 9, 9, 9, 9,10,10,10,10, -}; - -static const static_codebook _44u5__p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44u5__p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u5__p7_1, - 0 -}; - -static const long _vq_quantlist__44u5__p8_0[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u5__p8_0[] = { - 1, 4, 4, 6, 6, 8, 8, 9, 9,10,10, 4, 6, 6, 7, 7, - 9, 9,10,10,11,11, 4, 6, 6, 7, 7, 9, 9,10,10,11, - 11, 6, 8, 7, 9, 9,10,10,11,11,13,12, 6, 8, 8, 9, - 9,10,10,11,11,12,13, 8, 9, 9,10,10,12,12,13,12, - 14,13, 8, 9, 9,10,10,12,12,13,13,14,14, 9,11,11, - 12,12,13,13,14,14,15,14, 9,11,11,12,12,13,13,14, - 14,15,14,11,12,12,13,13,14,14,15,14,15,14,11,11, - 12,13,13,14,14,14,14,15,15, -}; - -static const static_codebook _44u5__p8_0 = { - 2, 121, - (char *)_vq_lengthlist__44u5__p8_0, - 1, -524582912, 1618345984, 4, 0, - (long *)_vq_quantlist__44u5__p8_0, - 0 -}; - -static const long _vq_quantlist__44u5__p8_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u5__p8_1[] = { - 3, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 5, 6, 5, 7, 6, - 7, 7, 8, 8, 8, 8, 5, 5, 5, 6, 6, 7, 7, 8, 8, 8, - 8, 6, 7, 6, 7, 7, 8, 8, 8, 8, 8, 8, 6, 6, 7, 7, - 7, 8, 8, 8, 8, 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, - 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44u5__p8_1 = { - 2, 121, - (char *)_vq_lengthlist__44u5__p8_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u5__p8_1, - 0 -}; - -static const long _vq_quantlist__44u5__p9_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u5__p9_0[] = { - 1, 3, 2,12,10,13,13,13,13,13,13,13,13, 4, 9, 9, - 13,13,13,13,13,13,13,13,13,13, 5,10, 9,13,13,13, - 13,13,13,13,13,13,13,12,13,13,13,13,13,13,13,13, - 13,13,13,13,11,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12, -}; - -static const static_codebook _44u5__p9_0 = { - 2, 169, - (char *)_vq_lengthlist__44u5__p9_0, - 1, -514332672, 1627381760, 4, 0, - (long *)_vq_quantlist__44u5__p9_0, - 0 -}; - -static const long _vq_quantlist__44u5__p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44u5__p9_1[] = { - 1, 4, 4, 7, 7, 8, 8, 8, 7, 8, 7, 9, 8, 9, 9, 4, - 7, 6, 9, 8,10,10, 9, 8, 9, 9, 9, 9, 9, 8, 5, 6, - 6, 8, 9,10,10, 9, 9, 9,10,10,10,10,11, 7, 8, 8, - 10,10,11,11,10,10,11,11,11,12,11,11, 7, 8, 8,10, - 10,11,11,10,10,11,11,12,11,11,11, 8, 9, 9,11,11, - 12,12,11,11,12,11,12,12,12,12, 8, 9,10,11,11,12, - 12,11,11,12,12,12,12,12,12, 8, 9, 9,10,10,12,11, - 12,12,12,12,12,12,12,13, 8, 9, 9,11,11,11,11,12, - 12,12,12,13,12,13,13, 9,10,10,11,11,12,12,12,13, - 12,13,13,13,14,13, 9,10,10,11,11,12,12,12,13,13, - 12,13,13,14,13, 9,11,10,12,11,13,12,12,13,13,13, - 13,13,13,14, 9,10,10,12,12,12,12,12,13,13,13,13, - 13,14,14,10,11,11,12,12,12,13,13,13,14,14,13,14, - 14,14,10,11,11,12,12,12,12,13,12,13,14,13,14,14, - 14, -}; - -static const static_codebook _44u5__p9_1 = { - 2, 225, - (char *)_vq_lengthlist__44u5__p9_1, - 1, -522338304, 1620115456, 4, 0, - (long *)_vq_quantlist__44u5__p9_1, - 0 -}; - -static const long _vq_quantlist__44u5__p9_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44u5__p9_2[] = { - 2, 5, 5, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 5, 6, 6, 7, 7, 8, 8, 9, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 5, 6, 6, 7, 7, 8, 8, 9, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 7, 7, 7, 8, 8, 9, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 7, 7, 7, 8, 8, 9, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, - 9,10, 9,10,10,10, 8, 8, 8, 9, 8, 9, 9, 9, 9, 9, - 9, 9,10, 9,10, 9,10, 8, 9, 9, 9, 9, 9, 9, 9, 9, - 9,10, 9,10,10,10,10,10, 8, 9, 9, 9, 9, 9, 9,10, - 9,10, 9,10,10,10,10,10,10, 9, 9, 9, 9, 9,10, 9, - 10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9, 9, - 9,10, 9,10, 9,10,10,10,10,10,10, 9, 9, 9, 9, 9, - 10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, - 9, 9,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, - 9,10,10, 9,10,10,10,10,10,10,10,10,10,10, 9, 9, - 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10, 9, - 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10, - 9, 9, 9,10, 9,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _44u5__p9_2 = { - 2, 289, - (char *)_vq_lengthlist__44u5__p9_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44u5__p9_2, - 0 -}; - -static const char _huff_lengthlist__44u5__short[] = { - 4,10,17,13,17,13,17,17,17,17, 3, 6, 8, 9,11, 9, - 15,12,16,17, 6, 5, 5, 7, 7, 8,10,11,17,17, 7, 8, - 7, 9, 9,10,13,13,17,17, 8, 6, 5, 7, 4, 7, 5, 8, - 14,17, 9, 9, 8, 9, 7, 9, 8,10,16,17,12,10, 7, 8, - 4, 7, 4, 7,16,17,12,11, 9,10, 6, 9, 5, 7,14,17, - 14,13,10,15, 4, 8, 3, 5,14,17,17,14,11,15, 6,10, - 6, 8,15,17, -}; - -static const static_codebook _huff_book__44u5__short = { - 2, 100, - (char *)_huff_lengthlist__44u5__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u6__long[] = { - 3, 9,14,13,14,13,16,12,13,14, 5, 4, 6, 6, 8, 9, - 11,10,12,15,10, 5, 5, 6, 6, 8,10,10,13,16,10, 6, - 6, 6, 6, 8, 9, 9,12,14,13, 7, 6, 6, 4, 6, 6, 7, - 11,14,10, 7, 7, 7, 6, 6, 6, 7,10,13,15,10, 9, 8, - 5, 6, 5, 6,10,14,10, 9, 8, 8, 6, 6, 5, 4, 6,11, - 11,11,12,11,10, 9, 9, 5, 5, 9,10,12,15,13,13,13, - 13, 8, 7, 7, -}; - -static const static_codebook _huff_book__44u6__long = { - 2, 100, - (char *)_huff_lengthlist__44u6__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u6__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u6__p1_0[] = { - 1, 4, 4, 4, 8, 7, 5, 7, 7, 5, 8, 8, 8,10,10, 7, - 9,10, 5, 8, 8, 7,10, 9, 8,10,10, 5, 8, 8, 8,10, - 10, 8,10,10, 8,10,10,10,12,13,10,13,13, 7,10,10, - 10,13,11,10,13,13, 5, 8, 8, 8,11,10, 8,10,10, 7, - 10,10,10,13,13,10,11,13, 8,10,11,10,13,13,10,13, - 12, -}; - -static const static_codebook _44u6__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u6__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u6__p1_0, - 0 -}; - -static const long _vq_quantlist__44u6__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u6__p2_0[] = { - 3, 4, 4, 5, 6, 6, 5, 6, 6, 5, 6, 6, 6, 8, 8, 6, - 7, 8, 5, 6, 6, 6, 8, 7, 6, 8, 8, 5, 6, 6, 6, 8, - 8, 6, 8, 8, 6, 8, 8, 8, 9, 9, 8, 9, 9, 6, 7, 7, - 7, 9, 8, 8, 9, 9, 5, 6, 6, 6, 8, 7, 6, 8, 8, 6, - 8, 8, 8, 9, 9, 7, 8, 9, 6, 8, 8, 8, 9, 9, 8, 9, - 9, -}; - -static const static_codebook _44u6__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__44u6__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u6__p2_0, - 0 -}; - -static const long _vq_quantlist__44u6__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u6__p3_0[] = { - 2, 5, 4, 8, 8, 5, 7, 6, 9, 9, 5, 6, 7, 9, 9, 8, - 9, 9,13,12, 8, 9,10,12,13, 5, 7, 7,10, 9, 7, 9, - 9,11,11, 7, 8, 9,11,11,10,11,11,14,14, 9,10,11, - 13,14, 5, 7, 7, 9,10, 6, 9, 8,11,11, 7, 9, 9,11, - 11, 9,11,10,14,13,10,11,11,14,13, 8,10,10,13,13, - 10,11,11,15,15, 9,11,11,14,14,13,14,14,17,16,12, - 13,14,16,16, 8,10,10,13,14, 9,11,11,14,15,10,11, - 12,14,15,12,14,13,16,15,13,14,14,15,17, 5, 7, 7, - 10,10, 7, 9, 9,11,11, 7, 9, 9,11,11,10,12,11,14, - 14,10,11,11,14,14, 7, 9, 9,12,11, 9,11,11,13,13, - 9,11,11,13,13,11,13,13,14,15,11,12,13,15,16, 6, - 9, 9,11,12, 8,11,10,13,12, 9,11,11,13,14,11,13, - 12,16,14,11,13,13,15,16,10,12,11,14,15,11,13,13, - 15,17,11,13,13,17,16,15,15,16,17,16,14,15,16,18, - 0, 9,11,11,14,15,10,12,12,16,15,11,13,13,16,16, - 13,15,14,18,15,14,16,16, 0, 0, 5, 7, 7,10,10, 7, - 9, 9,11,11, 7, 9, 9,11,11,10,11,11,14,14,10,11, - 12,14,14, 6, 9, 9,11,11, 9,11,11,13,13, 8,10,11, - 12,13,11,13,13,16,15,11,12,13,14,16, 7, 9, 9,11, - 12, 9,11,11,13,13, 9,11,11,13,13,11,13,13,16,15, - 11,13,12,15,15, 9,11,11,15,14,11,13,13,17,16,10, - 12,13,15,16,14,16,16, 0,18,14,14,15,15,17,10,11, - 12,15,15,11,13,13,16,16,11,13,13,16,16,14,16,16, - 19,17,14,15,15,17,17, 8,10,10,14,14,10,12,11,15, - 15,10,11,12,16,15,14,15,15,18,20,13,14,16,17,18, - 9,11,11,15,16,11,13,13,17,17,11,13,13,17,16,15, - 16,16, 0, 0,15,16,16, 0, 0, 9,11,11,15,15,10,13, - 12,17,15,11,13,13,17,16,15,17,15,20,19,15,16,16, - 19, 0,13,15,14, 0,17,14,15,16, 0,20,15,16,16, 0, - 19,17,18, 0, 0, 0,16,17,18, 0, 0,12,14,14,19,18, - 13,15,14, 0,17,14,15,16,19,19,16,18,16, 0,19,19, - 20,17,20, 0, 8,10,10,13,14,10,11,11,15,15,10,12, - 12,15,16,14,15,14,19,16,14,15,15, 0,18, 9,11,11, - 16,15,11,13,13, 0,16,11,12,13,16,17,14,16,17, 0, - 19,15,16,16,18, 0, 9,11,11,15,16,11,13,13,16,16, - 11,14,13,18,17,15,16,16,18,20,15,17,19, 0, 0,12, - 14,14,17,17,14,16,15, 0, 0,13,14,15,19, 0,16,18, - 20, 0, 0,16,16,18,18, 0,12,14,14,17,20,14,16,16, - 19, 0,14,16,14, 0,20,16,20,17, 0, 0,17, 0,15, 0, - 19, -}; - -static const static_codebook _44u6__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44u6__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u6__p3_0, - 0 -}; - -static const long _vq_quantlist__44u6__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u6__p4_0[] = { - 4, 5, 5, 8, 8, 6, 7, 6, 9, 9, 6, 6, 7, 9, 9, 8, - 9, 9,11,11, 8, 9, 9,11,11, 6, 7, 7, 9, 9, 7, 8, - 8,10,10, 7, 7, 8, 9,10, 9,10,10,11,11, 9, 9,10, - 11,12, 6, 7, 7, 9, 9, 7, 8, 7,10, 9, 7, 8, 8,10, - 10, 9,10, 9,12,11, 9,10,10,12,11, 8, 9, 9,11,11, - 9,10,10,12,12, 9,10,10,12,12,11,12,12,14,13,11, - 11,12,13,13, 8, 9, 9,11,11, 9,10,10,12,12, 9,10, - 10,12,12,11,12,11,13,12,11,12,12,13,13, 5, 7, 7, - 9, 9, 7, 8, 7,10,10, 7, 7, 8,10,10, 9,10,10,12, - 11, 9,10,10,11,12, 7, 8, 8,10,10, 8, 8, 9,11,11, - 8, 9, 9,11,11,10,10,11,12,13,10,10,11,12,12, 6, - 7, 7,10,10, 7, 9, 8,11,10, 8, 8, 9,10,11,10,11, - 10,13,11,10,11,11,12,12, 9,10,10,12,12,10,10,11, - 13,13,10,11,11,12,13,12,12,12,13,14,12,12,13,14, - 14, 9,10,10,12,12, 9,10,10,13,12,10,11,11,13,13, - 11,12,11,14,12,12,13,13,14,14, 6, 7, 7, 9, 9, 7, - 8, 7,10,10, 7, 8, 8,10,10, 9,10,10,12,11, 9,10, - 10,11,12, 6, 7, 7,10,10, 8, 9, 8,11,10, 7, 8, 9, - 10,11,10,11,11,12,12,10,10,11,11,13, 7, 8, 8,10, - 10, 8, 9, 9,11,11, 8, 9, 8,11,11,10,11,10,13,12, - 10,11,11,13,12, 9,10,10,12,12,10,11,11,13,12, 9, - 10,10,12,13,12,13,12,14,14,11,11,12,12,14, 9,10, - 10,12,12,10,11,11,13,13,10,11,10,13,12,12,12,12, - 14,14,12,13,12,14,13, 8, 9, 9,11,11, 9,10,10,12, - 12, 9,10,10,12,12,11,12,12,14,13,11,12,12,13,14, - 9,10,10,12,12,10,11,11,13,13,10,11,11,13,13,12, - 12,13,14,15,12,12,13,14,14, 9,10,10,12,12, 9,11, - 10,13,12,10,10,11,12,13,12,13,12,14,13,12,12,13, - 14,15,11,12,12,14,13,11,12,12,14,14,12,13,13,14, - 14,13,13,14,14,16,13,14,14,15,15,11,12,11,13,13, - 11,12,11,14,13,12,12,13,14,15,12,14,12,15,12,13, - 14,15,15,16, 8, 9, 9,11,11, 9,10,10,12,12, 9,10, - 10,12,12,11,12,12,14,13,11,12,12,13,13, 9,10,10, - 12,12,10,11,10,13,12, 9,10,11,12,13,12,13,12,14, - 14,12,12,13,13,14, 9,10,10,12,12,10,11,11,13,13, - 10,11,11,13,13,12,13,12,14,14,12,13,13,14,14,11, - 11,11,13,13,12,13,12,14,14,11,11,12,13,14,14,14, - 14,16,15,12,12,14,12,15,11,12,12,13,14,12,13,13, - 14,15,11,12,12,14,14,13,14,14,16,16,13,14,13,16, - 13, -}; - -static const static_codebook _44u6__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__44u6__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u6__p4_0, - 0 -}; - -static const long _vq_quantlist__44u6__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u6__p5_0[] = { - 2, 3, 3, 6, 6, 8, 8,10,10, 4, 5, 5, 8, 7, 8, 8, - 11,11, 3, 5, 5, 7, 8, 8, 8,11,11, 6, 8, 7, 9, 9, - 10, 9,12,11, 6, 7, 8, 9, 9, 9,10,11,12, 8, 8, 8, - 10, 9,12,11,13,13, 8, 8, 9, 9,10,11,12,13,13,10, - 11,11,12,12,13,13,14,14,10,10,11,11,12,13,13,14, - 14, -}; - -static const static_codebook _44u6__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44u6__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u6__p5_0, - 0 -}; - -static const long _vq_quantlist__44u6__p6_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u6__p6_0[] = { - 3, 4, 4, 5, 5, 7, 7, 9, 9, 4, 5, 4, 6, 6, 7, 7, - 9, 9, 4, 4, 5, 6, 6, 7, 8, 9, 9, 5, 6, 6, 7, 7, - 8, 8,10,10, 5, 6, 6, 7, 7, 8, 8,10,10, 7, 8, 7, - 8, 8,10, 9,11,11, 7, 7, 8, 8, 8, 9,10,10,11, 9, - 9, 9,10,10,11,11,12,11, 9, 9, 9,10,10,11,11,11, - 12, -}; - -static const static_codebook _44u6__p6_0 = { - 2, 81, - (char *)_vq_lengthlist__44u6__p6_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u6__p6_0, - 0 -}; - -static const long _vq_quantlist__44u6__p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u6__p7_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 9, 8, 7,10,10, 8, - 10,10, 5, 8, 9, 7,10,10, 7,10, 9, 4, 8, 8, 9,11, - 11, 8,11,11, 7,11,11,10,10,13,10,13,13, 7,11,11, - 10,13,12,10,13,13, 5, 9, 8, 8,11,11, 9,11,11, 7, - 11,11,10,13,13,10,12,13, 7,11,11,10,13,13, 9,13, - 10, -}; - -static const static_codebook _44u6__p7_0 = { - 4, 81, - (char *)_vq_lengthlist__44u6__p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44u6__p7_0, - 0 -}; - -static const long _vq_quantlist__44u6__p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u6__p7_1[] = { - 3, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8, 4, 5, 5, 7, 6, - 8, 8, 8, 8, 8, 8, 4, 5, 5, 6, 7, 8, 8, 8, 8, 8, - 8, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 6, 7, 7, 7, - 7, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 9, 9, - 9, 9, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 8, 8, 8, - 8, 8, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 8, 8, - 8, 8, 8, 9, 9, 9, 9, 9, 9, -}; - -static const static_codebook _44u6__p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44u6__p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u6__p7_1, - 0 -}; - -static const long _vq_quantlist__44u6__p8_0[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u6__p8_0[] = { - 1, 4, 4, 6, 6, 8, 8, 9, 9,10,10, 4, 6, 6, 7, 7, - 9, 9,10,10,11,11, 4, 6, 6, 7, 7, 9, 9,10,10,11, - 11, 6, 8, 8, 9, 9,10,10,11,11,12,12, 6, 8, 8, 9, - 9,10,10,11,11,12,12, 8, 9, 9,10,10,11,11,12,12, - 13,13, 8, 9, 9,10,10,11,11,12,12,13,13,10,10,10, - 11,11,13,13,13,13,15,14, 9,10,10,12,11,12,13,13, - 13,14,15,11,12,12,13,13,13,13,15,14,15,15,11,11, - 12,13,13,14,14,14,15,15,15, -}; - -static const static_codebook _44u6__p8_0 = { - 2, 121, - (char *)_vq_lengthlist__44u6__p8_0, - 1, -524582912, 1618345984, 4, 0, - (long *)_vq_quantlist__44u6__p8_0, - 0 -}; - -static const long _vq_quantlist__44u6__p8_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u6__p8_1[] = { - 3, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 5, 6, 5, 7, 7, - 7, 7, 8, 7, 8, 8, 5, 5, 6, 6, 7, 7, 7, 7, 7, 8, - 8, 6, 7, 7, 7, 7, 8, 7, 8, 8, 8, 8, 6, 6, 7, 7, - 7, 7, 8, 8, 8, 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, - 8, 8, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44u6__p8_1 = { - 2, 121, - (char *)_vq_lengthlist__44u6__p8_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u6__p8_1, - 0 -}; - -static const long _vq_quantlist__44u6__p9_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44u6__p9_0[] = { - 1, 3, 2, 9, 8,15,15,15,15,15,15,15,15,15,15, 4, - 8, 9,13,14,14,14,14,14,14,14,14,14,14,14, 5, 8, - 9,14,14,14,14,14,14,14,14,14,14,14,14,11,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,11,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, - 14, -}; - -static const static_codebook _44u6__p9_0 = { - 2, 225, - (char *)_vq_lengthlist__44u6__p9_0, - 1, -514071552, 1627381760, 4, 0, - (long *)_vq_quantlist__44u6__p9_0, - 0 -}; - -static const long _vq_quantlist__44u6__p9_1[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44u6__p9_1[] = { - 1, 4, 4, 7, 7, 8, 9, 8, 8, 9, 8, 9, 8, 9, 9, 4, - 7, 6, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 4, 7, - 6, 9, 9,10,10, 9, 9,10,10,10,10,11,11, 7, 9, 8, - 10,10,11,11,10,10,11,11,11,11,11,11, 7, 8, 9,10, - 10,11,11,10,10,11,11,11,11,11,12, 8,10,10,11,11, - 12,12,11,11,12,12,12,12,13,12, 8,10,10,11,11,12, - 11,11,11,11,12,12,12,12,13, 8, 9, 9,11,10,11,11, - 12,12,12,12,13,12,13,12, 8, 9, 9,11,11,11,11,12, - 12,12,12,12,13,13,13, 9,10,10,11,12,12,12,12,12, - 13,13,13,13,13,13, 9,10,10,11,11,12,12,12,12,13, - 13,13,13,14,13,10,10,10,12,11,12,12,13,13,13,13, - 13,13,13,13,10,10,11,11,11,12,12,13,13,13,13,13, - 13,13,13,10,11,11,12,12,13,12,12,13,13,13,13,13, - 13,14,10,11,11,12,12,13,12,13,13,13,14,13,13,14, - 13, -}; - -static const static_codebook _44u6__p9_1 = { - 2, 225, - (char *)_vq_lengthlist__44u6__p9_1, - 1, -522338304, 1620115456, 4, 0, - (long *)_vq_quantlist__44u6__p9_1, - 0 -}; - -static const long _vq_quantlist__44u6__p9_2[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44u6__p9_2[] = { - 3, 5, 5, 7, 7, 8, 8, 8, 8, 8, 8, 9, 8, 8, 9, 9, - 9, 5, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 5, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10, 9, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10, 9, 9, 9,10, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9,10, 9, 9, 9,10, 9, 9,10, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, 9,10, 9,10,10, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10, 9,10,10, 9, 9, - 10, -}; - -static const static_codebook _44u6__p9_2 = { - 2, 289, - (char *)_vq_lengthlist__44u6__p9_2, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44u6__p9_2, - 0 -}; - -static const char _huff_lengthlist__44u6__short[] = { - 4,11,16,13,17,13,17,16,17,17, 4, 7, 9, 9,13,10, - 16,12,16,17, 7, 6, 5, 7, 8, 9,12,12,16,17, 6, 9, - 7, 9,10,10,15,15,17,17, 6, 7, 5, 7, 5, 7, 7,10, - 16,17, 7, 9, 8, 9, 8,10,11,11,15,17, 7, 7, 7, 8, - 5, 8, 8, 9,15,17, 8, 7, 9, 9, 7, 8, 7, 2, 7,15, - 14,13,13,15, 5,10, 4, 3, 6,17,17,15,13,17, 7,11, - 7, 6, 9,16, -}; - -static const static_codebook _huff_book__44u6__short = { - 2, 100, - (char *)_huff_lengthlist__44u6__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u7__long[] = { - 3, 9,14,13,15,14,16,13,13,14, 5, 5, 7, 7, 8, 9, - 11,10,12,15,10, 6, 5, 6, 6, 9,10,10,13,16,10, 6, - 6, 6, 6, 8, 9, 9,12,15,14, 7, 6, 6, 5, 6, 6, 8, - 12,15,10, 8, 7, 7, 6, 7, 7, 7,11,13,14,10, 9, 8, - 5, 6, 4, 5, 9,12,10, 9, 9, 8, 6, 6, 5, 3, 6,11, - 12,11,12,12,10, 9, 8, 5, 5, 8,10,11,15,13,13,13, - 12, 8, 6, 7, -}; - -static const static_codebook _huff_book__44u7__long = { - 2, 100, - (char *)_huff_lengthlist__44u7__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u7__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u7__p1_0[] = { - 1, 4, 4, 4, 7, 7, 5, 7, 7, 5, 8, 8, 8,10,10, 7, - 10,10, 5, 8, 8, 7,10,10, 8,10,10, 5, 8, 8, 8,11, - 10, 8,10,10, 8,10,10,10,12,13,10,13,13, 7,10,10, - 10,13,12,10,13,13, 5, 8, 8, 8,11,10, 8,10,11, 7, - 10,10,10,13,13,10,12,13, 8,11,11,10,13,13,10,13, - 12, -}; - -static const static_codebook _44u7__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u7__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u7__p1_0, - 0 -}; - -static const long _vq_quantlist__44u7__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u7__p2_0[] = { - 3, 4, 4, 5, 6, 6, 5, 6, 6, 5, 6, 6, 6, 8, 8, 6, - 7, 8, 5, 6, 6, 6, 8, 7, 6, 8, 8, 5, 6, 6, 6, 8, - 7, 6, 8, 8, 6, 8, 8, 8, 9, 9, 8, 9, 9, 6, 8, 7, - 7, 9, 8, 8, 9, 9, 5, 6, 6, 6, 8, 7, 6, 8, 8, 6, - 8, 8, 8, 9, 9, 7, 8, 9, 6, 8, 8, 8, 9, 9, 8, 9, - 9, -}; - -static const static_codebook _44u7__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__44u7__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u7__p2_0, - 0 -}; - -static const long _vq_quantlist__44u7__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u7__p3_0[] = { - 2, 5, 4, 8, 8, 5, 7, 6, 9, 9, 5, 6, 7, 9, 9, 8, - 9, 9,13,12, 8, 9,10,12,13, 5, 7, 7,10, 9, 7, 9, - 9,11,11, 6, 8, 9,11,11,10,11,11,14,14, 9,10,11, - 13,14, 5, 7, 7, 9, 9, 7, 9, 8,11,11, 7, 9, 9,11, - 11, 9,11,10,14,13,10,11,11,14,14, 8,10,10,14,13, - 10,11,12,15,14, 9,11,11,15,14,13,14,14,16,16,12, - 13,14,17,16, 8,10,10,13,13, 9,11,11,14,15,10,11, - 12,14,15,12,14,13,16,16,13,14,15,15,17, 5, 7, 7, - 10,10, 7, 9, 9,11,11, 7, 9, 9,11,11,10,12,11,15, - 14,10,11,12,14,14, 7, 9, 9,12,12, 9,11,11,13,13, - 9,11,11,13,13,11,13,13,14,17,11,13,13,15,16, 6, - 9, 9,11,11, 8,11,10,13,12, 9,11,11,13,13,11,13, - 12,16,14,11,13,13,16,16,10,12,12,15,15,11,13,13, - 16,16,11,13,13,16,15,14,16,17,17,19,14,16,16,18, - 0, 9,11,11,14,15,10,13,12,16,15,11,13,13,16,16, - 14,15,14, 0,16,14,16,16,18, 0, 5, 7, 7,10,10, 7, - 9, 9,12,11, 7, 9, 9,11,12,10,11,11,15,14,10,11, - 12,14,14, 6, 9, 9,11,11, 9,11,11,13,13, 8,10,11, - 12,13,11,13,13,17,15,11,12,13,14,15, 7, 9, 9,11, - 12, 9,11,11,13,13, 9,11,11,13,13,11,13,12,16,16, - 11,13,13,15,14, 9,11,11,14,15,11,13,13,16,15,10, - 12,13,16,16,15,16,16, 0, 0,14,13,15,16,18,10,11, - 11,15,15,11,13,14,16,18,11,13,13,16,15,15,16,16, - 19, 0,14,15,15,16,16, 8,10,10,13,13,10,12,11,16, - 15,10,11,11,16,15,13,15,16,18, 0,13,14,15,17,17, - 9,11,11,15,15,11,13,13,16,18,11,13,13,16,17,15, - 16,16, 0, 0,15,18,16, 0,17, 9,11,11,15,15,11,13, - 12,17,15,11,13,14,16,17,15,18,15, 0,17,15,16,16, - 18,19,13,15,14, 0,18,14,16,16,19,18,14,16,15,19, - 19,16,18,19, 0, 0,16,17, 0, 0, 0,12,14,14,17,17, - 13,16,14, 0,18,14,16,15,18, 0,16,18,16,19,17,18, - 19,17, 0, 0, 8,10,10,14,14, 9,12,11,15,15,10,11, - 12,15,17,13,15,15,18,16,14,16,15,18,17, 9,11,11, - 16,15,11,13,13, 0,16,11,12,13,16,15,15,16,16, 0, - 17,15,15,16,18,17, 9,12,11,15,17,11,13,13,16,16, - 11,14,13,16,16,15,15,16,18,19,16,18,16, 0, 0,12, - 14,14, 0,16,14,16,16, 0,18,13,14,15,16, 0,17,16, - 18, 0, 0,16,16,17,19, 0,13,14,14,17, 0,14,17,16, - 0,19,14,15,15,18,19,17,16,18, 0, 0,15,19,16, 0, - 0, -}; - -static const static_codebook _44u7__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44u7__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u7__p3_0, - 0 -}; - -static const long _vq_quantlist__44u7__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u7__p4_0[] = { - 4, 5, 5, 8, 8, 6, 7, 6, 9, 9, 6, 6, 7, 9, 9, 8, - 9, 9,11,11, 8, 9, 9,10,11, 6, 7, 7, 9, 9, 7, 8, - 8,10,10, 6, 7, 8, 9,10, 9,10,10,12,12, 9, 9,10, - 11,12, 6, 7, 7, 9, 9, 6, 8, 7,10, 9, 7, 8, 8,10, - 10, 9,10, 9,12,11, 9,10,10,12,11, 8, 9, 9,11,11, - 9,10,10,12,12, 9,10,10,12,12,11,12,12,13,14,11, - 11,12,13,13, 8, 9, 9,11,11, 9,10,10,12,11, 9,10, - 10,12,12,11,12,11,13,13,11,12,12,13,13, 6, 7, 7, - 9, 9, 7, 8, 7,10,10, 7, 7, 8,10,10, 9,10,10,12, - 11, 9,10,10,12,12, 7, 8, 8,10,10, 8, 8, 9,11,11, - 8, 9, 9,11,11,10,11,11,12,12,10,10,11,12,13, 6, - 7, 7,10,10, 7, 9, 8,11,10, 8, 8, 9,10,11,10,11, - 10,13,11,10,11,11,12,12, 9,10,10,12,12,10,10,11, - 13,13,10,11,11,13,12,12,12,13,13,14,12,12,13,14, - 14, 9,10,10,12,12, 9,10,10,12,12,10,11,11,13,13, - 11,12,11,14,12,12,13,13,14,14, 6, 7, 7, 9, 9, 7, - 8, 7,10,10, 7, 7, 8,10,10, 9,10,10,12,11, 9,10, - 10,11,12, 6, 7, 7,10,10, 8, 9, 8,11,10, 7, 8, 9, - 10,11,10,11,11,13,12,10,10,11,11,13, 7, 8, 8,10, - 10, 8, 9, 9,11,11, 8, 9, 9,11,11,10,11,10,13,12, - 10,11,11,12,12, 9,10,10,12,12,10,11,11,13,12, 9, - 10,10,12,13,12,13,12,14,14,11,11,12,12,14, 9,10, - 10,12,12,10,11,11,13,13,10,11,11,13,13,12,13,12, - 14,14,12,13,12,14,13, 8, 9, 9,11,11, 9,10,10,12, - 12, 9,10,10,12,12,11,12,12,14,13,11,12,12,13,13, - 9,10,10,12,12,10,11,11,13,13,10,11,11,13,12,12, - 13,13,14,14,12,12,13,14,14, 9,10,10,12,12, 9,11, - 10,13,12,10,10,11,12,13,11,13,12,14,13,12,12,13, - 14,14,11,12,12,13,13,11,12,13,14,14,12,13,13,14, - 14,13,13,14,14,16,13,14,14,16,16,11,11,11,13,13, - 11,12,11,14,13,12,12,13,14,15,13,14,12,16,13,14, - 14,14,15,16, 8, 9, 9,11,11, 9,10,10,12,12, 9,10, - 10,12,12,11,12,12,14,13,11,12,12,13,14, 9,10,10, - 12,12,10,11,10,13,12, 9,10,11,12,13,12,13,12,14, - 14,12,12,13,13,14, 9,10,10,12,12,10,11,11,12,13, - 10,11,11,13,13,12,13,12,14,14,12,13,13,14,14,11, - 12,12,13,13,12,13,12,14,14,11,11,12,13,14,13,15, - 14,16,15,13,12,14,13,16,11,12,12,13,13,12,13,13, - 14,14,12,12,12,14,14,13,14,14,15,15,13,14,13,16, - 14, -}; - -static const static_codebook _44u7__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__44u7__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u7__p4_0, - 0 -}; - -static const long _vq_quantlist__44u7__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u7__p5_0[] = { - 2, 3, 3, 6, 6, 7, 8,10,10, 4, 5, 5, 8, 7, 8, 8, - 11,11, 3, 5, 5, 7, 7, 8, 9,11,11, 6, 8, 7, 9, 9, - 10,10,12,12, 6, 7, 8, 9,10,10,10,12,12, 8, 8, 8, - 10,10,12,11,13,13, 8, 8, 9,10,10,11,11,13,13,10, - 11,11,12,12,13,13,14,14,10,11,11,12,12,13,13,14, - 14, -}; - -static const static_codebook _44u7__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44u7__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u7__p5_0, - 0 -}; - -static const long _vq_quantlist__44u7__p6_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u7__p6_0[] = { - 3, 4, 4, 5, 5, 7, 7, 9, 9, 4, 5, 4, 6, 6, 8, 7, - 9, 9, 4, 4, 5, 6, 6, 7, 7, 9, 9, 5, 6, 6, 7, 7, - 8, 8,10,10, 5, 6, 6, 7, 7, 8, 8,10,10, 7, 8, 7, - 8, 8,10, 9,11,11, 7, 7, 8, 8, 8, 9,10,11,11, 9, - 9, 9,10,10,11,10,12,11, 9, 9, 9,10,10,11,11,11, - 12, -}; - -static const static_codebook _44u7__p6_0 = { - 2, 81, - (char *)_vq_lengthlist__44u7__p6_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u7__p6_0, - 0 -}; - -static const long _vq_quantlist__44u7__p7_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u7__p7_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 9, 8, 8, 9, 9, 7, - 10,10, 5, 8, 9, 7, 9,10, 8, 9, 9, 4, 9, 9, 9,11, - 10, 8,10,10, 7,11,10,10,10,12,10,12,12, 7,10,10, - 10,12,11,10,12,12, 5, 9, 9, 8,10,10, 9,11,11, 7, - 11,10,10,12,12,10,11,12, 7,10,11,10,12,12,10,12, - 10, -}; - -static const static_codebook _44u7__p7_0 = { - 4, 81, - (char *)_vq_lengthlist__44u7__p7_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44u7__p7_0, - 0 -}; - -static const long _vq_quantlist__44u7__p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u7__p7_1[] = { - 3, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8, 4, 5, 5, 6, 6, - 8, 7, 8, 8, 8, 8, 4, 5, 5, 6, 6, 7, 8, 8, 8, 8, - 8, 6, 7, 6, 7, 7, 8, 8, 9, 9, 9, 9, 6, 6, 7, 7, - 7, 8, 8, 9, 9, 9, 9, 7, 8, 7, 8, 8, 9, 9, 9, 9, - 9, 9, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9, 8, 8, 8, - 9, 9, 9, 9,10, 9, 9, 9, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9,10, 8, 8, 8, 9, 9, 9, 9,10, 9,10,10, 8, 8, - 8, 9, 9, 9, 9, 9,10,10,10, -}; - -static const static_codebook _44u7__p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44u7__p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u7__p7_1, - 0 -}; - -static const long _vq_quantlist__44u7__p8_0[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u7__p8_0[] = { - 1, 4, 4, 6, 6, 8, 8,10,10,11,11, 4, 6, 6, 7, 7, - 9, 9,11,10,12,12, 5, 6, 5, 7, 7, 9, 9,10,11,12, - 12, 6, 7, 7, 8, 8,10,10,11,11,13,13, 6, 7, 7, 8, - 8,10,10,11,12,13,13, 8, 9, 9,10,10,11,11,12,12, - 14,14, 8, 9, 9,10,10,11,11,12,12,14,14,10,10,10, - 11,11,13,12,14,14,15,15,10,10,10,12,12,13,13,14, - 14,15,15,11,12,12,13,13,14,14,15,14,16,15,11,12, - 12,13,13,14,14,15,15,15,16, -}; - -static const static_codebook _44u7__p8_0 = { - 2, 121, - (char *)_vq_lengthlist__44u7__p8_0, - 1, -524582912, 1618345984, 4, 0, - (long *)_vq_quantlist__44u7__p8_0, - 0 -}; - -static const long _vq_quantlist__44u7__p8_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u7__p8_1[] = { - 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 5, 6, 6, 7, 7, - 7, 7, 7, 7, 7, 7, 5, 6, 6, 6, 7, 7, 7, 7, 7, 7, - 7, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 6, 7, 7, 7, - 7, 7, 7, 7, 7, 8, 8, 7, 7, 7, 7, 7, 8, 7, 8, 8, - 8, 8, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 7, 7, 7, - 7, 7, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 8, 8, 8, - 8, 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, - 7, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44u7__p8_1 = { - 2, 121, - (char *)_vq_lengthlist__44u7__p8_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u7__p8_1, - 0 -}; - -static const long _vq_quantlist__44u7__p9_0[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u7__p9_0[] = { - 1, 3, 3,10,10,10,10,10,10,10,10, 4,10,10,10,10, - 10,10,10,10,10,10, 4,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, -}; - -static const static_codebook _44u7__p9_0 = { - 2, 121, - (char *)_vq_lengthlist__44u7__p9_0, - 1, -512171520, 1630791680, 4, 0, - (long *)_vq_quantlist__44u7__p9_0, - 0 -}; - -static const long _vq_quantlist__44u7__p9_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u7__p9_1[] = { - 1, 4, 4, 6, 5, 8, 6, 9, 8,10, 9,11,10, 4, 6, 6, - 8, 8, 9, 9,11,10,11,11,11,11, 4, 6, 6, 8, 8,10, - 9,11,11,11,11,11,12, 6, 8, 8,10,10,11,11,12,12, - 13,12,13,13, 6, 8, 8,10,10,11,11,12,12,12,13,14, - 13, 8,10,10,11,11,12,13,14,14,14,14,15,15, 8,10, - 10,11,12,12,13,13,14,14,14,14,15, 9,11,11,13,13, - 14,14,15,14,16,15,17,15, 9,11,11,12,13,14,14,15, - 14,15,15,15,16,10,12,12,13,14,15,15,15,15,16,17, - 16,17,10,13,12,13,14,14,16,16,16,16,15,16,17,11, - 13,13,14,15,14,17,15,16,17,17,17,17,11,13,13,14, - 15,15,15,15,17,17,16,17,16, -}; - -static const static_codebook _44u7__p9_1 = { - 2, 169, - (char *)_vq_lengthlist__44u7__p9_1, - 1, -518889472, 1622704128, 4, 0, - (long *)_vq_quantlist__44u7__p9_1, - 0 -}; - -static const long _vq_quantlist__44u7__p9_2[] = { - 24, - 23, - 25, - 22, - 26, - 21, - 27, - 20, - 28, - 19, - 29, - 18, - 30, - 17, - 31, - 16, - 32, - 15, - 33, - 14, - 34, - 13, - 35, - 12, - 36, - 11, - 37, - 10, - 38, - 9, - 39, - 8, - 40, - 7, - 41, - 6, - 42, - 5, - 43, - 4, - 44, - 3, - 45, - 2, - 46, - 1, - 47, - 0, - 48, -}; - -static const char _vq_lengthlist__44u7__p9_2[] = { - 2, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 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, 8, 8, 8, - 8, -}; - -static const static_codebook _44u7__p9_2 = { - 1, 49, - (char *)_vq_lengthlist__44u7__p9_2, - 1, -526909440, 1611661312, 6, 0, - (long *)_vq_quantlist__44u7__p9_2, - 0 -}; - -static const char _huff_lengthlist__44u7__short[] = { - 5,12,17,16,16,17,17,17,17,17, 4, 7,11,11,12, 9, - 17,10,17,17, 7, 7, 8, 9, 7, 9,11,10,15,17, 7, 9, - 10,11,10,12,14,12,16,17, 7, 8, 5, 7, 4, 7, 7, 8, - 16,16, 6,10, 9,10, 7,10,11,11,16,17, 6, 8, 8, 9, - 5, 7, 5, 8,16,17, 5, 5, 8, 7, 6, 7, 7, 6, 6,14, - 12,10,12,11, 7,11, 4, 4, 2, 7,17,15,15,15, 8,15, - 6, 8, 5, 9, -}; - -static const static_codebook _huff_book__44u7__short = { - 2, 100, - (char *)_huff_lengthlist__44u7__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u8__long[] = { - 3, 9,13,14,14,15,14,14,15,15, 5, 4, 6, 8,10,12, - 12,14,15,15, 9, 5, 4, 5, 8,10,11,13,16,16,10, 7, - 4, 3, 5, 7, 9,11,13,13,10, 9, 7, 4, 4, 6, 8,10, - 12,14,13,11, 9, 6, 5, 5, 6, 8,12,14,13,11,10, 8, - 7, 6, 6, 7,10,14,13,11,12,10, 8, 7, 6, 6, 9,13, - 12,11,14,12,11, 9, 8, 7, 9,11,11,12,14,13,14,11, - 10, 8, 8, 9, -}; - -static const static_codebook _huff_book__44u8__long = { - 2, 100, - (char *)_huff_lengthlist__44u8__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u8__short[] = { - 6,14,18,18,17,17,17,17,17,17, 4, 7, 9, 9,10,13, - 15,17,17,17, 6, 7, 5, 6, 8,11,16,17,16,17, 5, 7, - 5, 4, 6,10,14,17,17,17, 6, 6, 6, 5, 7,10,13,16, - 17,17, 7, 6, 7, 7, 7, 8, 7,10,15,16,12, 9, 9, 6, - 6, 5, 3, 5,11,15,14,14,13, 5, 5, 7, 3, 4, 8,15, - 17,17,13, 7, 7,10, 6, 6,10,15,17,17,16,10,11,14, - 10,10,15,17, -}; - -static const static_codebook _huff_book__44u8__short = { - 2, 100, - (char *)_huff_lengthlist__44u8__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u8_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u8_p1_0[] = { - 1, 5, 5, 5, 7, 7, 5, 7, 7, 5, 7, 7, 8, 9, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 8, 9, 9, 5, 7, 7, 7, 9, - 9, 7, 9, 9, 7, 9, 9, 9,10,11, 9,11,10, 7, 9, 9, - 9,11,10, 9,10,11, 5, 7, 7, 7, 9, 9, 7, 9, 9, 7, - 9, 9, 9,11,10, 9,10,10, 8, 9, 9, 9,11,11, 9,11, - 10, -}; - -static const static_codebook _44u8_p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u8_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u8_p1_0, - 0 -}; - -static const long _vq_quantlist__44u8_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u8_p2_0[] = { - 4, 5, 5, 8, 8, 5, 7, 6, 9, 9, 5, 6, 7, 9, 9, 8, - 9, 9,11,11, 8, 9, 9,11,11, 5, 7, 7, 9, 9, 7, 8, - 8,10,10, 7, 8, 8,10,10, 9,10,10,12,12, 9,10,10, - 11,12, 5, 7, 7, 9, 9, 7, 8, 7,10,10, 7, 8, 8,10, - 10, 9,10, 9,12,11, 9,10,10,12,12, 8, 9, 9,12,11, - 9,10,10,12,12, 9,10,10,12,12,11,12,12,14,14,11, - 11,12,13,14, 8, 9, 9,11,11, 9,10,10,12,12, 9,10, - 10,12,12,11,12,11,13,13,11,12,12,14,14, 5, 7, 7, - 9, 9, 7, 8, 8,10,10, 7, 8, 8,10,10, 9,10,10,12, - 12, 9,10,10,11,12, 7, 8, 8,10,10, 8, 9, 9,11,11, - 8, 9, 9,11,11,10,11,11,12,13,10,11,11,12,13, 6, - 8, 8,10,10, 8, 9, 8,11,10, 8, 9, 9,11,11,10,11, - 10,13,12,10,11,11,13,13, 9,10,10,12,12,10,11,11, - 13,13,10,11,11,13,13,12,12,13,13,14,12,13,13,14, - 14, 9,10,10,12,12,10,11,10,13,12,10,11,11,13,13, - 11,13,12,14,13,12,13,13,14,14, 5, 7, 7, 9, 9, 7, - 8, 8,10,10, 7, 8, 8,10,10, 9,10,10,12,12, 9,10, - 10,12,12, 7, 8, 8,10,10, 8, 9, 9,11,11, 8, 8, 9, - 10,11,10,11,11,13,13,10,10,11,12,13, 7, 8, 8,10, - 10, 8, 9, 9,11,11, 8, 9, 9,11,11,10,11,11,13,13, - 10,11,11,13,12, 9,10,10,12,12,10,11,11,13,13,10, - 10,11,12,13,12,13,13,14,14,12,12,13,13,14, 9,10, - 10,12,12,10,11,11,13,13,10,11,11,13,13,12,13,13, - 15,14,12,13,13,14,13, 8, 9, 9,11,11, 9,10,10,12, - 12, 9,10,10,12,12,12,12,12,14,13,11,12,12,14,14, - 9,10,10,12,12,10,11,11,13,13,10,11,11,13,13,12, - 13,13,14,15,12,13,13,14,15, 9,10,10,12,12,10,11, - 10,13,12,10,11,11,13,13,12,13,12,15,14,12,13,13, - 14,15,11,12,12,14,14,12,13,13,14,14,12,13,13,15, - 14,14,14,14,14,16,14,14,15,16,16,11,12,12,14,14, - 11,12,12,14,14,12,13,13,14,15,13,14,13,16,14,14, - 14,14,16,16, 8, 9, 9,11,11, 9,10,10,12,12, 9,10, - 10,12,12,11,12,12,14,13,11,12,12,14,14, 9,10,10, - 12,12,10,11,11,13,13,10,10,11,12,13,12,13,13,15, - 14,12,12,13,13,14, 9,10,10,12,12,10,11,11,13,13, - 10,11,11,13,13,12,13,13,14,14,12,13,13,15,14,11, - 12,12,14,13,12,13,13,15,14,11,12,12,13,14,14,15, - 14,16,15,13,13,14,13,16,11,12,12,14,14,12,13,13, - 14,15,12,13,12,15,14,14,14,14,16,15,14,15,13,16, - 14, -}; - -static const static_codebook _44u8_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44u8_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u8_p2_0, - 0 -}; - -static const long _vq_quantlist__44u8_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u8_p3_0[] = { - 3, 4, 4, 5, 5, 7, 7, 9, 9, 4, 5, 4, 6, 6, 7, 7, - 9, 9, 4, 4, 5, 6, 6, 7, 7, 9, 9, 5, 6, 6, 7, 7, - 8, 8,10,10, 6, 6, 6, 7, 7, 8, 8,10,10, 7, 7, 7, - 8, 8, 9, 9,11,10, 7, 7, 7, 8, 8, 9, 9,10,11, 9, - 9, 9,10,10,11,10,12,11, 9, 9, 9, 9,10,11,11,11, - 12, -}; - -static const static_codebook _44u8_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44u8_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u8_p3_0, - 0 -}; - -static const long _vq_quantlist__44u8_p4_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44u8_p4_0[] = { - 4, 4, 4, 6, 6, 7, 7, 8, 8, 8, 8,10,10,11,11,11, - 11, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11,11, - 12,12, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11, - 11,12,12, 6, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9,10,10, - 11,11,12,12, 6, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9,10, - 10,11,11,12,12, 7, 7, 7, 8, 8, 9, 8,10, 9,10, 9, - 11,10,12,11,13,12, 7, 7, 7, 8, 8, 8, 9, 9,10, 9, - 10,10,11,11,12,12,13, 8, 8, 8, 9, 9, 9, 9,10,10, - 11,10,11,11,12,12,13,13, 8, 8, 8, 9, 9, 9,10,10, - 10,10,11,11,11,12,12,12,13, 8, 9, 9, 9, 9,10, 9, - 11,10,11,11,12,11,13,12,13,13, 8, 9, 9, 9, 9, 9, - 10,10,11,11,11,11,12,12,13,13,13,10,10,10,10,10, - 11,10,11,11,12,11,13,12,13,13,14,13,10,10,10,10, - 10,10,11,11,11,11,12,12,13,13,13,13,14,11,11,11, - 11,11,12,11,12,12,13,12,13,13,14,13,14,14,11,11, - 11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,11, - 12,12,12,12,13,12,13,12,13,13,14,13,14,14,14,14, - 11,12,12,12,12,12,12,13,13,13,13,13,14,14,14,14, - 14, -}; - -static const static_codebook _44u8_p4_0 = { - 2, 289, - (char *)_vq_lengthlist__44u8_p4_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44u8_p4_0, - 0 -}; - -static const long _vq_quantlist__44u8_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u8_p5_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 8, 8, 8, 9, 9, 7, - 9, 9, 5, 8, 8, 7, 9, 9, 8, 9, 9, 5, 8, 8, 8,10, - 10, 8,10,10, 7,10,10, 9,10,12, 9,12,11, 7,10,10, - 9,11,10, 9,11,12, 5, 8, 8, 8,10,10, 8,10,10, 7, - 10,10, 9,11,11, 9,10,11, 7,10,10, 9,11,11,10,12, - 10, -}; - -static const static_codebook _44u8_p5_0 = { - 4, 81, - (char *)_vq_lengthlist__44u8_p5_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44u8_p5_0, - 0 -}; - -static const long _vq_quantlist__44u8_p5_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u8_p5_1[] = { - 4, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 5, 5, 5, 6, 6, - 7, 7, 8, 8, 8, 8, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, - 8, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 6, 6, 6, 7, - 7, 7, 7, 8, 8, 8, 8, 7, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 7, 8, 7, - 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 9, 9, -}; - -static const static_codebook _44u8_p5_1 = { - 2, 121, - (char *)_vq_lengthlist__44u8_p5_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u8_p5_1, - 0 -}; - -static const long _vq_quantlist__44u8_p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u8_p6_0[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10, 4, 6, 5, - 7, 7, 8, 8, 8, 8, 9, 9,10,10, 4, 6, 6, 7, 7, 8, - 8, 8, 8, 9, 9,10,10, 6, 7, 7, 7, 8, 8, 8, 8, 9, - 9,10,10,10, 6, 7, 7, 8, 8, 8, 8, 9, 8,10, 9,11, - 10, 7, 8, 8, 8, 8, 8, 9, 9, 9,10,10,11,11, 7, 8, - 8, 8, 8, 9, 8, 9, 9,10,10,11,11, 8, 8, 8, 9, 9, - 9, 9, 9,10,10,10,11,11, 8, 8, 8, 9, 9, 9, 9,10, - 9,10,10,11,11, 9, 9, 9, 9,10,10,10,10,10,10,11, - 11,12, 9, 9, 9,10, 9,10,10,10,10,11,10,12,11,10, - 10,10,10,10,11,11,11,11,11,12,12,12,10,10,10,10, - 11,11,11,11,11,12,11,12,12, -}; - -static const static_codebook _44u8_p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44u8_p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44u8_p6_0, - 0 -}; - -static const long _vq_quantlist__44u8_p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u8_p6_1[] = { - 3, 4, 4, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44u8_p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44u8_p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u8_p6_1, - 0 -}; - -static const long _vq_quantlist__44u8_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u8_p7_0[] = { - 1, 4, 5, 6, 6, 7, 7, 8, 8,10,10,11,11, 5, 6, 6, - 7, 7, 8, 8, 9, 9,11,10,12,11, 5, 6, 6, 7, 7, 8, - 8, 9, 9,10,11,11,12, 6, 7, 7, 8, 8, 9, 9,10,10, - 11,11,12,12, 6, 7, 7, 8, 8, 9, 9,10,10,11,12,13, - 12, 7, 8, 8, 9, 9,10,10,11,11,12,12,13,13, 8, 8, - 8, 9, 9,10,10,11,11,12,12,13,13, 9, 9, 9,10,10, - 11,11,12,12,13,13,14,14, 9, 9, 9,10,10,11,11,12, - 12,13,13,14,14,10,11,11,12,11,13,12,13,13,14,14, - 15,15,10,11,11,11,12,12,13,13,14,14,14,15,15,11, - 12,12,13,13,14,13,15,14,15,15,16,15,11,11,12,13, - 13,13,14,14,14,15,15,15,16, -}; - -static const static_codebook _44u8_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44u8_p7_0, - 1, -523206656, 1618345984, 4, 0, - (long *)_vq_quantlist__44u8_p7_0, - 0 -}; - -static const long _vq_quantlist__44u8_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u8_p7_1[] = { - 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 5, 6, 6, 7, 7, - 7, 7, 7, 7, 7, 7, 5, 6, 6, 7, 7, 7, 7, 7, 7, 7, - 7, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 6, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 7, 7, 7, 7, 8, 8, - 8, 8, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 7, 7, 7, - 8, 7, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 8, 8, 8, - 8, 8, 8, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, - 7, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44u8_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44u8_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u8_p7_1, - 0 -}; - -static const long _vq_quantlist__44u8_p8_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44u8_p8_0[] = { - 1, 4, 4, 7, 7, 8, 8, 8, 7, 9, 8,10, 9,11,10, 4, - 6, 6, 8, 8,10, 9, 9, 9,10,10,11,10,12,10, 4, 6, - 6, 8, 8,10,10, 9, 9,10,10,11,11,11,12, 7, 8, 8, - 10,10,11,11,11,10,12,11,12,12,13,11, 7, 8, 8,10, - 10,11,11,10,10,11,11,12,12,13,13, 8,10,10,11,11, - 12,11,12,11,13,12,13,12,14,13, 8,10, 9,11,11,12, - 12,12,12,12,12,13,13,14,13, 8, 9, 9,11,10,12,11, - 13,12,13,13,14,13,14,13, 8, 9, 9,10,11,12,12,12, - 12,13,13,14,15,14,14, 9,10,10,12,11,13,12,13,13, - 14,13,14,14,14,14, 9,10,10,12,12,12,12,13,13,14, - 14,14,15,14,14,10,11,11,13,12,13,12,14,14,14,14, - 14,14,15,15,10,11,11,12,12,13,13,14,14,14,15,15, - 14,16,15,11,12,12,13,12,14,14,14,13,15,14,15,15, - 15,17,11,12,12,13,13,14,14,14,15,15,14,15,15,14, - 17, -}; - -static const static_codebook _44u8_p8_0 = { - 2, 225, - (char *)_vq_lengthlist__44u8_p8_0, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__44u8_p8_0, - 0 -}; - -static const long _vq_quantlist__44u8_p8_1[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__44u8_p8_1[] = { - 4, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 6, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5, 6, 6, 7, 7, 8, - 8, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, - 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10, 9,10, 8, 8, - 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 9,10, - 10, 9,10, 8, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9,10, 9, - 10,10,10,10,10,10,10,10, 8, 9, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10,10, 9,10,10, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10, 9,10,10,10,10,10,10, - 10,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 9,10, - 10,10,10,10,10,10,10, 9, 9, 9, 9, 9, 9, 9,10, 9, - 10,10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10, - 10, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10, 9, 9, 9, 9, 9, 9, 9,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9, - 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10, 9, 9, 9,10, 9,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9,10, - 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10, 9, - 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10, 9, 9, 9,10, 9,10, 9,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _44u8_p8_1 = { - 2, 441, - (char *)_vq_lengthlist__44u8_p8_1, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__44u8_p8_1, - 0 -}; - -static const long _vq_quantlist__44u8_p9_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u8_p9_0[] = { - 1, 3, 3, 9, 9, 9, 9, 9, 9, 4, 9, 9, 9, 9, 9, 9, - 9, 9, 5, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, - 8, -}; - -static const static_codebook _44u8_p9_0 = { - 2, 81, - (char *)_vq_lengthlist__44u8_p9_0, - 1, -511895552, 1631393792, 4, 0, - (long *)_vq_quantlist__44u8_p9_0, - 0 -}; - -static const long _vq_quantlist__44u8_p9_1[] = { - 9, - 8, - 10, - 7, - 11, - 6, - 12, - 5, - 13, - 4, - 14, - 3, - 15, - 2, - 16, - 1, - 17, - 0, - 18, -}; - -static const char _vq_lengthlist__44u8_p9_1[] = { - 1, 4, 4, 7, 7, 8, 7, 8, 6, 9, 7,10, 8,11,10,11, - 11,11,11, 4, 7, 6, 9, 9,10, 9, 9, 9,10,10,11,10, - 11,10,11,11,13,11, 4, 7, 7, 9, 9, 9, 9, 9, 9,10, - 10,11,10,11,11,11,12,11,12, 7, 9, 8,11,11,11,11, - 10,10,11,11,12,12,12,12,12,12,14,13, 7, 8, 9,10, - 11,11,11,10,10,11,11,11,11,12,12,14,12,13,14, 8, - 9, 9,11,11,11,11,11,11,12,12,14,12,15,14,14,14, - 15,14, 8, 9, 9,11,11,11,11,12,11,12,12,13,13,13, - 13,13,13,14,14, 8, 9, 9,11,10,12,11,12,12,13,13, - 13,13,15,14,14,14,16,16, 8, 9, 9,10,11,11,12,12, - 12,13,13,13,14,14,14,15,16,15,15, 9,10,10,11,12, - 12,13,13,13,14,14,16,14,14,16,16,16,16,15, 9,10, - 10,11,11,12,13,13,14,15,14,16,14,15,16,16,16,16, - 15,10,11,11,12,13,13,14,15,15,15,15,15,16,15,16, - 15,16,15,15,10,11,11,13,13,14,13,13,15,14,15,15, - 16,15,15,15,16,15,16,10,12,12,14,14,14,14,14,16, - 16,15,15,15,16,16,16,16,16,16,11,12,12,14,14,14, - 14,15,15,16,15,16,15,16,15,16,16,16,16,12,12,13, - 14,14,15,16,16,16,16,16,16,15,16,16,16,16,16,16, - 12,13,13,14,14,14,14,15,16,15,16,16,16,16,16,16, - 16,16,16,12,13,14,14,14,16,15,16,15,16,16,16,16, - 16,16,16,16,16,16,12,14,13,14,15,15,15,16,15,16, - 16,15,16,16,16,16,16,16,16, -}; - -static const static_codebook _44u8_p9_1 = { - 2, 361, - (char *)_vq_lengthlist__44u8_p9_1, - 1, -518287360, 1622704128, 5, 0, - (long *)_vq_quantlist__44u8_p9_1, - 0 -}; - -static const long _vq_quantlist__44u8_p9_2[] = { - 24, - 23, - 25, - 22, - 26, - 21, - 27, - 20, - 28, - 19, - 29, - 18, - 30, - 17, - 31, - 16, - 32, - 15, - 33, - 14, - 34, - 13, - 35, - 12, - 36, - 11, - 37, - 10, - 38, - 9, - 39, - 8, - 40, - 7, - 41, - 6, - 42, - 5, - 43, - 4, - 44, - 3, - 45, - 2, - 46, - 1, - 47, - 0, - 48, -}; - -static const char _vq_lengthlist__44u8_p9_2[] = { - 2, 3, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 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, -}; - -static const static_codebook _44u8_p9_2 = { - 1, 49, - (char *)_vq_lengthlist__44u8_p9_2, - 1, -526909440, 1611661312, 6, 0, - (long *)_vq_quantlist__44u8_p9_2, - 0 -}; - -static const char _huff_lengthlist__44u9__long[] = { - 3, 9,13,13,14,15,14,14,15,15, 5, 5, 9,10,12,12, - 13,14,16,15,10, 6, 6, 6, 8,11,12,13,16,15,11, 7, - 5, 3, 5, 8,10,12,15,15,10,10, 7, 4, 3, 5, 8,10, - 12,12,12,12, 9, 7, 5, 4, 6, 8,10,13,13,12,11, 9, - 7, 5, 5, 6, 9,12,14,12,12,10, 8, 6, 6, 6, 7,11, - 13,12,14,13,10, 8, 7, 7, 7,10,11,11,12,13,12,11, - 10, 8, 8, 9, -}; - -static const static_codebook _huff_book__44u9__long = { - 2, 100, - (char *)_huff_lengthlist__44u9__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const char _huff_lengthlist__44u9__short[] = { - 9,16,18,18,17,17,17,17,17,17, 5, 8,11,12,11,12, - 17,17,16,16, 6, 6, 8, 8, 9,10,14,15,16,16, 6, 7, - 7, 4, 6, 9,13,16,16,16, 6, 6, 7, 4, 5, 8,11,15, - 17,16, 7, 6, 7, 6, 6, 8, 9,10,14,16,11, 8, 8, 7, - 6, 6, 3, 4,10,15,14,12,12,10, 5, 6, 3, 3, 8,13, - 15,17,15,11, 6, 8, 6, 6, 9,14,17,15,15,12, 8,10, - 9, 9,12,15, -}; - -static const static_codebook _huff_book__44u9__short = { - 2, 100, - (char *)_huff_lengthlist__44u9__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44u9_p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u9_p1_0[] = { - 1, 5, 5, 5, 7, 7, 5, 7, 7, 5, 7, 7, 7, 9, 9, 7, - 9, 9, 5, 7, 7, 7, 9, 9, 7, 9, 9, 5, 7, 7, 7, 9, - 9, 7, 9, 9, 8, 9, 9, 9,10,11, 9,11,11, 7, 9, 9, - 9,11,10, 9,11,11, 5, 7, 7, 7, 9, 9, 8, 9,10, 7, - 9, 9, 9,11,11, 9,10,11, 7, 9,10, 9,11,11, 9,11, - 10, -}; - -static const static_codebook _44u9_p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44u9_p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44u9_p1_0, - 0 -}; - -static const long _vq_quantlist__44u9_p2_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u9_p2_0[] = { - 3, 5, 5, 8, 8, 5, 7, 7, 9, 9, 6, 7, 7, 9, 9, 8, - 9, 9,11,10, 8, 9, 9,11,11, 6, 7, 7, 9, 9, 7, 8, - 8,10,10, 7, 8, 8, 9,10, 9,10,10,11,11, 9, 9,10, - 11,11, 6, 7, 7, 9, 9, 7, 8, 8,10, 9, 7, 8, 8,10, - 10, 9,10, 9,11,11, 9,10,10,11,11, 8, 9, 9,11,11, - 9,10,10,12,11, 9,10,10,11,12,11,11,11,13,13,11, - 11,11,12,13, 8, 9, 9,11,11, 9,10,10,11,11, 9,10, - 10,12,11,11,12,11,13,12,11,11,12,13,13, 6, 7, 7, - 9, 9, 7, 8, 8,10,10, 7, 8, 8,10,10, 9,10,10,12, - 11, 9,10,10,11,12, 7, 8, 8,10,10, 8, 9, 9,11,11, - 8, 9, 9,10,10,10,11,11,12,12,10,10,11,12,12, 7, - 8, 8,10,10, 8, 9, 8,10,10, 8, 9, 9,10,10,10,11, - 10,12,11,10,10,11,12,12, 9,10,10,11,12,10,11,11, - 12,12,10,11,10,12,12,12,12,12,13,13,11,12,12,13, - 13, 9,10,10,11,11, 9,10,10,12,12,10,11,11,12,13, - 11,12,11,13,12,12,12,12,13,14, 6, 7, 7, 9, 9, 7, - 8, 8,10,10, 7, 8, 8,10,10, 9,10,10,11,11, 9,10, - 10,11,12, 7, 8, 8,10,10, 8, 9, 9,11,10, 8, 8, 9, - 10,10,10,11,10,12,12,10,10,11,11,12, 7, 8, 8,10, - 10, 8, 9, 9,10,10, 8, 9, 9,10,10,10,11,10,12,12, - 10,11,10,12,12, 9,10,10,12,11,10,11,11,12,12, 9, - 10,10,12,12,12,12,12,13,13,11,11,12,12,14, 9,10, - 10,11,12,10,11,11,12,12,10,11,11,12,12,11,12,12, - 14,14,12,12,12,13,13, 8, 9, 9,11,11, 9,10,10,12, - 11, 9,10,10,12,12,11,12,11,13,13,11,11,12,13,13, - 9,10,10,12,12,10,11,11,12,12,10,11,11,12,12,12, - 12,12,14,14,12,12,12,13,13, 9,10,10,12,11,10,11, - 10,12,12,10,11,11,12,12,11,12,12,14,13,12,12,12, - 13,14,11,12,11,13,13,11,12,12,13,13,12,12,12,14, - 14,13,13,13,13,15,13,13,14,15,15,11,11,11,13,13, - 11,12,11,13,13,11,12,12,13,13,12,13,12,15,13,13, - 13,14,14,15, 8, 9, 9,11,11, 9,10,10,11,12, 9,10, - 10,11,12,11,12,11,13,13,11,12,12,13,13, 9,10,10, - 11,12,10,11,10,12,12,10,10,11,12,13,12,12,12,14, - 13,11,12,12,13,14, 9,10,10,12,12,10,11,11,12,12, - 10,11,11,12,12,12,12,12,14,13,12,12,12,14,13,11, - 11,11,13,13,11,12,12,14,13,11,11,12,13,13,13,13, - 13,15,14,12,12,13,13,15,11,12,12,13,13,12,12,12, - 13,14,11,12,12,13,13,13,13,14,14,15,13,13,13,14, - 14, -}; - -static const static_codebook _44u9_p2_0 = { - 4, 625, - (char *)_vq_lengthlist__44u9_p2_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u9_p2_0, - 0 -}; - -static const long _vq_quantlist__44u9_p3_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44u9_p3_0[] = { - 3, 4, 4, 5, 5, 7, 7, 8, 8, 4, 5, 5, 6, 6, 7, 7, - 9, 9, 4, 4, 5, 6, 6, 7, 7, 9, 9, 5, 6, 6, 7, 7, - 8, 8, 9, 9, 5, 6, 6, 7, 7, 8, 8, 9, 9, 7, 7, 7, - 8, 8, 9, 9,10,10, 7, 7, 7, 8, 8, 9, 9,10,10, 8, - 9, 9,10, 9,10,10,11,11, 8, 9, 9, 9,10,10,10,11, - 11, -}; - -static const static_codebook _44u9_p3_0 = { - 2, 81, - (char *)_vq_lengthlist__44u9_p3_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44u9_p3_0, - 0 -}; - -static const long _vq_quantlist__44u9_p4_0[] = { - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - 0, - 16, -}; - -static const char _vq_lengthlist__44u9_p4_0[] = { - 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10,10,11, - 11, 5, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10,10, - 11,11, 5, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9,10, - 10,11,11, 6, 6, 6, 7, 6, 7, 7, 8, 8, 9, 9,10,10, - 11,11,12,11, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9,10, - 10,11,11,11,12, 7, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, - 10,10,11,11,12,12, 7, 7, 7, 7, 7, 8, 8, 9, 9, 9, - 9,10,10,11,11,12,12, 8, 8, 8, 8, 8, 9, 8,10, 9, - 10,10,11,10,12,11,13,12, 8, 8, 8, 8, 8, 9, 9, 9, - 10,10,10,10,11,11,12,12,12, 8, 8, 8, 9, 9, 9, 9, - 10,10,11,10,12,11,12,12,13,12, 8, 8, 8, 9, 9, 9, - 9,10,10,10,11,11,11,12,12,12,13, 9, 9, 9,10,10, - 10,10,11,10,11,11,12,11,13,12,13,13, 9, 9,10,10, - 10,10,10,10,11,11,11,11,12,12,13,13,13,10,11,10, - 11,11,11,11,12,11,12,12,13,12,13,13,14,13,10,10, - 10,11,11,11,11,11,12,12,12,12,13,13,13,13,14,11, - 11,11,12,11,12,12,12,12,13,13,13,13,14,13,14,14, - 11,11,11,11,12,12,12,12,12,12,13,13,13,13,14,14, - 14, -}; - -static const static_codebook _44u9_p4_0 = { - 2, 289, - (char *)_vq_lengthlist__44u9_p4_0, - 1, -529530880, 1611661312, 5, 0, - (long *)_vq_quantlist__44u9_p4_0, - 0 -}; - -static const long _vq_quantlist__44u9_p5_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44u9_p5_0[] = { - 1, 4, 4, 5, 7, 7, 5, 7, 7, 5, 8, 8, 8, 9, 9, 7, - 9, 9, 5, 8, 8, 7, 9, 9, 8, 9, 9, 5, 8, 8, 8,10, - 10, 8,10,10, 7,10,10, 9,10,12, 9,11,11, 7,10,10, - 9,11,10, 9,11,12, 5, 8, 8, 8,10,10, 8,10,10, 7, - 10,10, 9,12,11, 9,10,11, 7,10,10, 9,11,11,10,12, - 10, -}; - -static const static_codebook _44u9_p5_0 = { - 4, 81, - (char *)_vq_lengthlist__44u9_p5_0, - 1, -529137664, 1618345984, 2, 0, - (long *)_vq_quantlist__44u9_p5_0, - 0 -}; - -static const long _vq_quantlist__44u9_p5_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u9_p5_1[] = { - 5, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 5, 6, 6, 6, 6, - 7, 7, 7, 7, 8, 7, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, - 7, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 6, 6, 6, 7, - 7, 7, 7, 7, 7, 8, 8, 7, 7, 7, 7, 7, 8, 7, 8, 8, - 8, 8, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 7, 7, 7, - 8, 7, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 7, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const static_codebook _44u9_p5_1 = { - 2, 121, - (char *)_vq_lengthlist__44u9_p5_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u9_p5_1, - 0 -}; - -static const long _vq_quantlist__44u9_p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u9_p6_0[] = { - 2, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10, 4, 6, 5, - 7, 7, 8, 8, 8, 8, 9, 9,10,10, 4, 5, 6, 7, 7, 8, - 8, 8, 8, 9, 9,10,10, 6, 7, 7, 8, 8, 8, 8, 9, 9, - 10,10,10,10, 6, 7, 7, 8, 8, 8, 8, 9, 9,10,10,10, - 10, 7, 8, 8, 8, 8, 9, 9, 9, 9,10,10,11,11, 7, 8, - 8, 8, 8, 9, 9, 9, 9,10,10,11,11, 8, 8, 8, 9, 9, - 9, 9, 9,10,10,10,11,11, 8, 8, 8, 9, 9, 9, 9,10, - 9,10,10,11,11, 9, 9, 9,10,10,10,10,10,11,11,11, - 11,12, 9, 9, 9,10,10,10,10,10,10,11,10,12,11,10, - 10,10,10,10,11,11,11,11,11,12,12,12,10,10,10,10, - 10,11,11,11,11,12,11,12,12, -}; - -static const static_codebook _44u9_p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44u9_p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44u9_p6_0, - 0 -}; - -static const long _vq_quantlist__44u9_p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44u9_p6_1[] = { - 4, 4, 4, 5, 5, 4, 5, 4, 5, 5, 4, 4, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, -}; - -static const static_codebook _44u9_p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44u9_p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44u9_p6_1, - 0 -}; - -static const long _vq_quantlist__44u9_p7_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44u9_p7_0[] = { - 1, 4, 5, 6, 6, 7, 7, 8, 9,10,10,11,11, 5, 6, 6, - 7, 7, 8, 8, 9, 9,10,10,11,11, 5, 6, 6, 7, 7, 8, - 8, 9, 9,10,10,11,11, 6, 7, 7, 8, 8, 9, 9,10,10, - 11,11,12,12, 6, 7, 7, 8, 8, 9, 9,10,10,11,11,12, - 12, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13, 8, 8, - 8, 9, 9,10,10,11,11,12,12,13,13, 9, 9, 9,10,10, - 11,11,12,12,13,13,13,13, 9, 9, 9,10,10,11,11,12, - 12,13,13,14,14,10,10,10,11,11,12,12,13,13,14,13, - 15,14,10,10,10,11,11,12,12,13,13,14,14,14,14,11, - 11,12,12,12,13,13,14,14,14,14,15,15,11,11,12,12, - 12,13,13,14,14,14,15,15,15, -}; - -static const static_codebook _44u9_p7_0 = { - 2, 169, - (char *)_vq_lengthlist__44u9_p7_0, - 1, -523206656, 1618345984, 4, 0, - (long *)_vq_quantlist__44u9_p7_0, - 0 -}; - -static const long _vq_quantlist__44u9_p7_1[] = { - 5, - 4, - 6, - 3, - 7, - 2, - 8, - 1, - 9, - 0, - 10, -}; - -static const char _vq_lengthlist__44u9_p7_1[] = { - 5, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 7, 7, - 7, 7, 7, 7, 7, 7, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 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, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 8, 8, 7, 7, 7, 7, 7, 7, 7, 8, 7, 8, 8, 7, 7, - 7, 7, 7, 7, 7, 8, 8, 8, 8, -}; - -static const static_codebook _44u9_p7_1 = { - 2, 121, - (char *)_vq_lengthlist__44u9_p7_1, - 1, -531365888, 1611661312, 4, 0, - (long *)_vq_quantlist__44u9_p7_1, - 0 -}; - -static const long _vq_quantlist__44u9_p8_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44u9_p8_0[] = { - 1, 4, 4, 7, 7, 8, 8, 8, 8, 9, 9,10, 9,11,10, 4, - 6, 6, 8, 8, 9, 9, 9, 9,10,10,11,10,12,10, 4, 6, - 6, 8, 8, 9,10, 9, 9,10,10,11,11,12,12, 7, 8, 8, - 10,10,11,11,10,10,11,11,12,12,13,12, 7, 8, 8,10, - 10,11,11,10,10,11,11,12,12,12,13, 8,10, 9,11,11, - 12,12,11,11,12,12,13,13,14,13, 8, 9, 9,11,11,12, - 12,11,12,12,12,13,13,14,13, 8, 9, 9,10,10,12,11, - 13,12,13,13,14,13,15,14, 8, 9, 9,10,10,11,12,12, - 12,13,13,13,14,14,14, 9,10,10,12,11,13,12,13,13, - 14,13,14,14,14,15, 9,10,10,11,12,12,12,13,13,14, - 14,14,15,15,15,10,11,11,12,12,13,13,14,14,14,14, - 15,14,16,15,10,11,11,12,12,13,13,13,14,14,14,14, - 14,15,16,11,12,12,13,13,14,13,14,14,15,14,15,16, - 16,16,11,12,12,13,13,14,13,14,14,15,15,15,16,15, - 15, -}; - -static const static_codebook _44u9_p8_0 = { - 2, 225, - (char *)_vq_lengthlist__44u9_p8_0, - 1, -520986624, 1620377600, 4, 0, - (long *)_vq_quantlist__44u9_p8_0, - 0 -}; - -static const long _vq_quantlist__44u9_p8_1[] = { - 10, - 9, - 11, - 8, - 12, - 7, - 13, - 6, - 14, - 5, - 15, - 4, - 16, - 3, - 17, - 2, - 18, - 1, - 19, - 0, - 20, -}; - -static const char _vq_lengthlist__44u9_p8_1[] = { - 4, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 6, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 6, 6, 6, 7, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, - 7, 7, 8, 8, 8, 8, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9,10, 9,10,10,10, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9,10,10, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 10, 9,10, 9,10,10,10,10, 8, 8, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9,10,10, 9,10,10,10,10,10, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9,10, 9,10,10,10,10,10,10, - 10,10, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10, - 10,10,10,10,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10, - 10, 9, 9, 9, 9, 9, 9, 9,10, 9,10,10,10,10,10,10, - 10,10,10,10,10,10, 9, 9, 9, 9, 9, 9, 9, 9,10,10, - 10,10,10,10,10,10,10,10,10,10,10, 9, 9, 9, 9, 9, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 9, 9, 9, 9,10, 9, 9,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10, 9, 9, 9,10, 9,10, 9,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10, 9, 9, 9,10, 9,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, 9, - 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10, 9, 9, 9,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10, -}; - -static const static_codebook _44u9_p8_1 = { - 2, 441, - (char *)_vq_lengthlist__44u9_p8_1, - 1, -529268736, 1611661312, 5, 0, - (long *)_vq_quantlist__44u9_p8_1, - 0 -}; - -static const long _vq_quantlist__44u9_p9_0[] = { - 7, - 6, - 8, - 5, - 9, - 4, - 10, - 3, - 11, - 2, - 12, - 1, - 13, - 0, - 14, -}; - -static const char _vq_lengthlist__44u9_p9_0[] = { - 1, 3, 3,11,11,11,11,11,11,11,11,11,11,11,11, 4, - 10,11,11,11,11,11,11,11,11,11,11,11,11,11, 4,10, - 10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _44u9_p9_0 = { - 2, 225, - (char *)_vq_lengthlist__44u9_p9_0, - 1, -510036736, 1631393792, 4, 0, - (long *)_vq_quantlist__44u9_p9_0, - 0 -}; - -static const long _vq_quantlist__44u9_p9_1[] = { - 9, - 8, - 10, - 7, - 11, - 6, - 12, - 5, - 13, - 4, - 14, - 3, - 15, - 2, - 16, - 1, - 17, - 0, - 18, -}; - -static const char _vq_lengthlist__44u9_p9_1[] = { - 1, 4, 4, 7, 7, 8, 7, 8, 7, 9, 8,10, 9,10,10,11, - 11,12,12, 4, 7, 6, 9, 9,10, 9, 9, 8,10,10,11,10, - 12,10,13,12,13,12, 4, 6, 6, 9, 9, 9, 9, 9, 9,10, - 10,11,11,11,12,12,12,12,12, 7, 9, 8,11,10,10,10, - 11,10,11,11,12,12,13,12,13,13,13,13, 7, 8, 9,10, - 10,11,11,10,10,11,11,11,12,13,13,13,13,14,14, 8, - 9, 9,11,11,12,11,12,12,13,12,12,13,13,14,15,14, - 14,14, 8, 9, 9,10,11,11,11,12,12,13,12,13,13,14, - 14,14,15,14,16, 8, 9, 9,11,10,12,12,12,12,15,13, - 13,13,17,14,15,15,15,14, 8, 9, 9,10,11,11,12,13, - 12,13,13,13,14,15,14,14,14,16,15, 9,11,10,12,12, - 13,13,13,13,14,14,16,15,14,14,14,15,15,17, 9,10, - 10,11,11,13,13,13,14,14,13,15,14,15,14,15,16,15, - 16,10,11,11,12,12,13,14,15,14,15,14,14,15,17,16, - 15,15,17,17,10,12,11,13,12,14,14,13,14,15,15,15, - 15,16,17,17,15,17,16,11,12,12,14,13,15,14,15,16, - 17,15,17,15,17,15,15,16,17,15,11,11,12,14,14,14, - 14,14,15,15,16,15,17,17,17,16,17,16,15,12,12,13, - 14,14,14,15,14,15,15,16,16,17,16,17,15,17,17,16, - 12,14,12,14,14,15,15,15,14,14,16,16,16,15,16,16, - 15,17,15,12,13,13,14,15,14,15,17,15,17,16,17,17, - 17,16,17,16,17,17,12,13,13,14,16,15,15,15,16,15, - 17,17,15,17,15,17,16,16,17, -}; - -static const static_codebook _44u9_p9_1 = { - 2, 361, - (char *)_vq_lengthlist__44u9_p9_1, - 1, -518287360, 1622704128, 5, 0, - (long *)_vq_quantlist__44u9_p9_1, - 0 -}; - -static const long _vq_quantlist__44u9_p9_2[] = { - 24, - 23, - 25, - 22, - 26, - 21, - 27, - 20, - 28, - 19, - 29, - 18, - 30, - 17, - 31, - 16, - 32, - 15, - 33, - 14, - 34, - 13, - 35, - 12, - 36, - 11, - 37, - 10, - 38, - 9, - 39, - 8, - 40, - 7, - 41, - 6, - 42, - 5, - 43, - 4, - 44, - 3, - 45, - 2, - 46, - 1, - 47, - 0, - 48, -}; - -static const char _vq_lengthlist__44u9_p9_2[] = { - 2, 4, 4, 5, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 7, 6, 7, 6, 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, -}; - -static const static_codebook _44u9_p9_2 = { - 1, 49, - (char *)_vq_lengthlist__44u9_p9_2, - 1, -526909440, 1611661312, 6, 0, - (long *)_vq_quantlist__44u9_p9_2, - 0 -}; - -static const char _huff_lengthlist__44un1__long[] = { - 5, 6,12, 9,14, 9, 9,19, 6, 1, 5, 5, 8, 7, 9,19, - 12, 4, 4, 7, 7, 9,11,18, 9, 5, 6, 6, 8, 7, 8,17, - 14, 8, 7, 8, 8,10,12,18, 9, 6, 8, 6, 8, 6, 8,18, - 9, 8,11, 8,11, 7, 5,15,16,18,18,18,17,15,11,18, -}; - -static const static_codebook _huff_book__44un1__long = { - 2, 64, - (char *)_huff_lengthlist__44un1__long, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - -static const long _vq_quantlist__44un1__p1_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44un1__p1_0[] = { - 1, 4, 4, 5, 8, 7, 5, 7, 8, 5, 8, 8, 8,10,11, 8, - 10,11, 5, 8, 8, 8,11,10, 8,11,10, 4, 9, 9, 8,11, - 11, 8,11,11, 8,12,11,10,12,14,11,13,13, 7,11,11, - 10,13,11,11,13,14, 4, 8, 9, 8,11,11, 8,11,12, 7, - 11,11,11,14,13,10,11,13, 8,11,12,11,13,13,10,14, - 12, -}; - -static const static_codebook _44un1__p1_0 = { - 4, 81, - (char *)_vq_lengthlist__44un1__p1_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44un1__p1_0, - 0 -}; - -static const long _vq_quantlist__44un1__p2_0[] = { - 1, - 0, - 2, -}; - -static const char _vq_lengthlist__44un1__p2_0[] = { - 2, 4, 4, 5, 6, 6, 5, 6, 6, 5, 7, 7, 7, 8, 8, 6, - 7, 9, 5, 7, 7, 6, 8, 7, 7, 9, 8, 4, 7, 7, 7, 9, - 8, 7, 8, 8, 7, 9, 8, 8, 8,10, 9,10,10, 6, 8, 8, - 7,10, 8, 9,10,10, 5, 7, 7, 7, 8, 8, 7, 8, 9, 6, - 8, 8, 9,10,10, 7, 8,10, 6, 8, 9, 9,10,10, 8,10, - 8, -}; - -static const static_codebook _44un1__p2_0 = { - 4, 81, - (char *)_vq_lengthlist__44un1__p2_0, - 1, -535822336, 1611661312, 2, 0, - (long *)_vq_quantlist__44un1__p2_0, - 0 -}; - -static const long _vq_quantlist__44un1__p3_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44un1__p3_0[] = { - 1, 5, 5, 8, 8, 5, 8, 7, 9, 9, 5, 7, 8, 9, 9, 9, - 10, 9,12,12, 9, 9,10,11,12, 6, 8, 8,10,10, 8,10, - 10,11,11, 8, 9,10,11,11,10,11,11,13,13,10,11,11, - 12,13, 6, 8, 8,10,10, 8,10, 9,11,11, 8,10,10,11, - 11,10,11,11,13,12,10,11,11,13,12, 9,11,11,15,13, - 10,12,11,15,13,10,11,11,15,14,12,14,13,16,15,12, - 13,13,17,16, 9,11,11,13,15,10,11,12,14,15,10,11, - 12,14,15,12,13,13,15,16,12,13,13,16,16, 5, 8, 8, - 11,11, 8,10,10,12,12, 8,10,10,12,12,11,12,12,14, - 14,11,12,12,14,14, 8,11,10,13,12,10,11,12,12,13, - 10,12,12,13,13,12,12,13,13,15,11,12,13,15,14, 7, - 10,10,12,12, 9,12,11,13,12,10,12,12,13,14,12,13, - 12,15,13,11,13,12,14,15,10,12,12,16,14,11,12,12, - 16,15,11,13,12,17,16,13,13,15,15,17,13,15,15,20, - 17,10,12,12,14,16,11,12,12,15,15,11,13,13,15,18, - 13,14,13,15,15,13,15,14,16,16, 5, 8, 8,11,11, 8, - 10,10,12,12, 8,10,10,12,12,11,12,12,14,14,11,12, - 12,14,15, 7,10,10,13,12,10,12,12,14,13, 9,10,12, - 12,13,11,13,13,15,15,11,12,13,13,15, 8,10,10,12, - 13,10,12,12,13,13,10,12,11,13,13,11,13,12,15,15, - 12,13,12,15,13,10,12,12,16,14,11,12,12,16,15,10, - 12,12,16,14,14,15,14,18,16,13,13,14,15,16,10,12, - 12,14,16,11,13,13,16,16,11,13,12,14,16,13,15,15, - 18,18,13,15,13,16,14, 8,11,11,16,16,10,13,13,17, - 16,10,12,12,16,15,14,16,15,20,17,13,14,14,17,17, - 9,12,12,16,16,11,13,14,16,17,11,13,13,16,16,15, - 15,19,18, 0,14,15,15,18,18, 9,12,12,17,16,11,13, - 12,17,16,11,12,13,15,17,15,16,15, 0,19,14,15,14, - 19,18,12,14,14, 0,16,13,14,14,19,18,13,15,16,17, - 16,15,15,17,18, 0,14,16,16,19, 0,12,14,14,16,18, - 13,15,13,17,18,13,15,14,17,18,15,18,14,18,18,16, - 17,16, 0,17, 8,11,11,15,15,10,12,12,16,16,10,13, - 13,16,16,13,15,14,17,17,14,15,17,17,18, 9,12,12, - 16,15,11,13,13,16,16,11,12,13,17,17,14,14,15,17, - 17,14,15,16, 0,18, 9,12,12,16,17,11,13,13,16,17, - 11,14,13,18,17,14,16,14,17,17,15,17,17,18,18,12, - 14,14, 0,16,13,15,15,19, 0,12,13,15, 0, 0,14,17, - 16,19, 0,16,15,18,18, 0,12,14,14,17, 0,13,14,14, - 17, 0,13,15,14, 0,18,15,16,16, 0,18,15,18,15, 0, - 17, -}; - -static const static_codebook _44un1__p3_0 = { - 4, 625, - (char *)_vq_lengthlist__44un1__p3_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44un1__p3_0, - 0 -}; - -static const long _vq_quantlist__44un1__p4_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44un1__p4_0[] = { - 3, 5, 5, 9, 9, 5, 6, 6,10, 9, 5, 6, 6, 9,10,10, - 10,10,12,11, 9,10,10,12,12, 5, 7, 7,10,10, 7, 7, - 8,10,11, 7, 7, 8,10,11,10,10,11,11,13,10,10,11, - 11,13, 6, 7, 7,10,10, 7, 8, 7,11,10, 7, 8, 7,10, - 10,10,11, 9,13,11,10,11,10,13,11,10,10,10,14,13, - 10,11,11,14,13,10,10,11,13,14,12,12,13,15,15,12, - 12,13,13,14,10,10,10,12,13,10,11,10,13,13,10,11, - 11,13,13,12,13,12,14,13,12,13,13,14,13, 5, 7, 7, - 10,10, 7, 8, 8,11,10, 7, 8, 8,10,10,11,11,11,13, - 13,10,11,11,12,12, 7, 8, 8,11,11, 7, 8, 9,10,12, - 8, 9, 9,11,11,11,10,12,11,14,11,11,12,13,13, 6, - 8, 8,10,11, 7, 9, 7,12,10, 8, 9,10,11,12,10,12, - 10,14,11,11,12,11,13,13,10,11,11,14,14,10,10,11, - 13,14,11,12,12,15,13,12,11,14,12,16,12,13,14,15, - 16,10,10,11,13,14,10,11,10,14,12,11,12,12,13,14, - 12,13,11,15,12,14,14,14,15,15, 5, 7, 7,10,10, 7, - 8, 8,10,10, 7, 8, 8,10,11,10,11,10,12,12,10,11, - 11,12,13, 6, 8, 8,11,11, 8, 9, 9,12,11, 7, 7, 9, - 10,12,11,11,11,12,13,11,10,12,11,15, 7, 8, 8,11, - 11, 8, 9, 9,11,11, 7, 9, 8,12,10,11,12,11,13,12, - 11,12,10,15,11,10,11,10,14,12,11,12,11,14,13,10, - 10,11,13,14,13,13,13,17,15,12,11,14,12,15,10,10, - 11,13,14,11,12,12,14,14,10,11,10,14,13,13,14,13, - 16,17,12,14,11,16,12, 9,10,10,14,13,10,11,10,14, - 14,10,11,11,13,13,13,14,14,16,15,12,13,13,14,14, - 9,11,10,14,13,10,10,12,13,14,11,12,11,14,13,13, - 14,14,14,15,13,14,14,15,15, 9,10,11,13,14,10,11, - 10,15,13,11,11,12,12,15,13,14,12,15,14,13,13,14, - 14,15,12,13,12,16,14,11,11,12,15,14,13,15,13,16, - 14,13,12,15,12,17,15,16,15,16,16,12,12,13,13,15, - 11,13,11,15,14,13,13,14,15,17,13,14,12, 0,13,14, - 15,14,15, 0, 9,10,10,13,13,10,11,11,13,13,10,11, - 11,13,13,12,13,12,14,14,13,14,14,15,17, 9,10,10, - 13,13,11,12,11,15,12,10,10,11,13,16,13,14,13,15, - 14,13,13,14,15,16,10,10,11,13,14,11,11,12,13,14, - 10,12,11,14,14,13,13,13,14,15,13,15,13,16,15,12, - 13,12,15,13,12,15,13,15,15,11,11,13,14,15,15,15, - 15,15,17,13,12,14,13,17,12,12,14,14,15,13,13,14, - 14,16,11,13,11,16,15,14,16,16,17, 0,14,13,11,16, - 12, -}; - -static const static_codebook _44un1__p4_0 = { - 4, 625, - (char *)_vq_lengthlist__44un1__p4_0, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44un1__p4_0, - 0 -}; - -static const long _vq_quantlist__44un1__p5_0[] = { - 4, - 3, - 5, - 2, - 6, - 1, - 7, - 0, - 8, -}; - -static const char _vq_lengthlist__44un1__p5_0[] = { - 1, 4, 4, 7, 7, 8, 8, 9, 9, 4, 6, 5, 8, 7, 8, 8, - 10, 9, 4, 6, 6, 8, 8, 8, 8,10,10, 7, 8, 7, 9, 9, - 9, 9,11,10, 7, 8, 8, 9, 9, 9, 9,10,11, 8, 8, 8, - 9, 9,10,10,11,11, 8, 8, 8, 9, 9,10,10,11,11, 9, - 10,10,11,10,11,11,12,12, 9,10,10,10,11,11,11,12, - 12, -}; - -static const static_codebook _44un1__p5_0 = { - 2, 81, - (char *)_vq_lengthlist__44un1__p5_0, - 1, -531628032, 1611661312, 4, 0, - (long *)_vq_quantlist__44un1__p5_0, - 0 -}; - -static const long _vq_quantlist__44un1__p6_0[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44un1__p6_0[] = { - 1, 4, 4, 6, 6, 8, 8,10,10,11,11,15,15, 4, 5, 5, - 8, 8, 9, 9,11,11,12,12,16,16, 4, 5, 6, 8, 8, 9, - 9,11,11,12,12,14,14, 7, 8, 8, 9, 9,10,10,11,12, - 13,13,16,17, 7, 8, 8, 9, 9,10,10,12,12,12,13,15, - 15, 9,10,10,10,10,11,11,12,12,13,13,15,16, 9, 9, - 9,10,10,11,11,13,12,13,13,17,17,10,11,11,11,12, - 12,12,13,13,14,15, 0,18,10,11,11,12,12,12,13,14, - 13,14,14,17,16,11,12,12,13,13,14,14,14,14,15,16, - 17,16,11,12,12,13,13,14,14,14,14,15,15,17,17,14, - 15,15,16,16,16,17,17,16, 0,17, 0,18,14,15,15,16, - 16, 0,15,18,18, 0,16, 0, 0, -}; - -static const static_codebook _44un1__p6_0 = { - 2, 169, - (char *)_vq_lengthlist__44un1__p6_0, - 1, -526516224, 1616117760, 4, 0, - (long *)_vq_quantlist__44un1__p6_0, - 0 -}; - -static const long _vq_quantlist__44un1__p6_1[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44un1__p6_1[] = { - 2, 4, 4, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 6, 5, 5, - 6, 5, 6, 6, 5, 6, 6, 6, 6, -}; - -static const static_codebook _44un1__p6_1 = { - 2, 25, - (char *)_vq_lengthlist__44un1__p6_1, - 1, -533725184, 1611661312, 3, 0, - (long *)_vq_quantlist__44un1__p6_1, - 0 -}; - -static const long _vq_quantlist__44un1__p7_0[] = { - 2, - 1, - 3, - 0, - 4, -}; - -static const char _vq_lengthlist__44un1__p7_0[] = { - 1, 5, 3,11,11,11,11,11,11,11, 8,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,10,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,10,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11, 8,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11, 7,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,10,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10, -}; - -static const static_codebook _44un1__p7_0 = { - 4, 625, - (char *)_vq_lengthlist__44un1__p7_0, - 1, -518709248, 1626677248, 3, 0, - (long *)_vq_quantlist__44un1__p7_0, - 0 -}; - -static const long _vq_quantlist__44un1__p7_1[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44un1__p7_1[] = { - 1, 4, 4, 6, 6, 6, 6, 9, 8, 9, 8, 8, 8, 5, 7, 7, - 7, 7, 8, 8, 8,10, 8,10, 8, 9, 5, 7, 7, 8, 7, 7, - 8,10,10,11,10,12,11, 7, 8, 8, 9, 9, 9,10,11,11, - 11,11,11,11, 7, 8, 8, 8, 9, 9, 9,10,10,10,11,11, - 12, 7, 8, 8, 9, 9,10,11,11,12,11,12,11,11, 7, 8, - 8, 9, 9,10,10,11,11,11,12,12,11, 8,10,10,10,10, - 11,11,14,11,12,12,12,13, 9,10,10,10,10,12,11,14, - 11,14,11,12,13,10,11,11,11,11,13,11,14,14,13,13, - 13,14,11,11,11,12,11,12,12,12,13,14,14,13,14,12, - 11,12,12,12,12,13,13,13,14,13,14,14,11,12,12,14, - 12,13,13,12,13,13,14,14,14, -}; - -static const static_codebook _44un1__p7_1 = { - 2, 169, - (char *)_vq_lengthlist__44un1__p7_1, - 1, -523010048, 1618608128, 4, 0, - (long *)_vq_quantlist__44un1__p7_1, - 0 -}; - -static const long _vq_quantlist__44un1__p7_2[] = { - 6, - 5, - 7, - 4, - 8, - 3, - 9, - 2, - 10, - 1, - 11, - 0, - 12, -}; - -static const char _vq_lengthlist__44un1__p7_2[] = { - 3, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 9, 8, 4, 5, 5, - 6, 6, 8, 8, 9, 8, 9, 9, 9, 9, 4, 5, 5, 7, 6, 8, - 8, 8, 8, 9, 8, 9, 8, 6, 7, 7, 7, 8, 8, 8, 9, 9, - 9, 9, 9, 9, 6, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, - 9, 7, 8, 8, 8, 8, 9, 8, 9, 9,10, 9, 9,10, 7, 8, - 8, 8, 8, 9, 9, 9, 9, 9, 9,10,10, 8, 9, 9, 9, 9, - 9, 9, 9, 9,10,10, 9,10, 8, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9,10,10, 9, 9, 9,10, 9, 9,10, 9, 9,10,10, - 10,10, 9, 9, 9, 9, 9, 9, 9,10, 9,10,10,10,10, 9, - 9, 9,10, 9, 9,10,10, 9,10,10,10,10, 9, 9, 9,10, - 9, 9, 9,10,10,10,10,10,10, -}; - -static const static_codebook _44un1__p7_2 = { - 2, 169, - (char *)_vq_lengthlist__44un1__p7_2, - 1, -531103744, 1611661312, 4, 0, - (long *)_vq_quantlist__44un1__p7_2, - 0 -}; - -static const char _huff_lengthlist__44un1__short[] = { - 12,12,14,12,14,14,14,14,12, 6, 6, 8, 9, 9,11,14, - 12, 4, 2, 6, 6, 7,11,14,13, 6, 5, 7, 8, 9,11,14, - 13, 8, 5, 8, 6, 8,12,14,12, 7, 7, 8, 8, 8,10,14, - 12, 6, 3, 4, 4, 4, 7,14,11, 7, 4, 6, 6, 6, 8,14, -}; - -static const static_codebook _huff_book__44un1__short = { - 2, 64, - (char *)_huff_lengthlist__44un1__short, - 0, 0, 0, 0, 0, - NULL, - 0 -}; - diff --git a/Engine/lib/libvorbis/lib/codebook.c b/Engine/lib/libvorbis/lib/codebook.c deleted file mode 100644 index 7a0c20678..000000000 --- a/Engine/lib/libvorbis/lib/codebook.c +++ /dev/null @@ -1,461 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: basic codebook pack/unpack/code/decode operations - - ********************************************************************/ - -#include -#include -#include -#include -#include "vorbis/codec.h" -#include "codebook.h" -#include "scales.h" -#include "misc.h" -#include "os.h" - -/* packs the given codebook into the bitstream **************************/ - -int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){ - long i,j; - int ordered=0; - - /* first the basic parameters */ - oggpack_write(opb,0x564342,24); - oggpack_write(opb,c->dim,16); - oggpack_write(opb,c->entries,24); - - /* pack the codewords. There are two packings; length ordered and - length random. Decide between the two now. */ - - for(i=1;ientries;i++) - if(c->lengthlist[i-1]==0 || c->lengthlist[i]lengthlist[i-1])break; - if(i==c->entries)ordered=1; - - if(ordered){ - /* length ordered. We only need to say how many codewords of - each length. The actual codewords are generated - deterministically */ - - long count=0; - oggpack_write(opb,1,1); /* ordered */ - oggpack_write(opb,c->lengthlist[0]-1,5); /* 1 to 32 */ - - for(i=1;ientries;i++){ - char this=c->lengthlist[i]; - char last=c->lengthlist[i-1]; - if(this>last){ - for(j=last;jentries-count)); - count=i; - } - } - } - oggpack_write(opb,i-count,ov_ilog(c->entries-count)); - - }else{ - /* length random. Again, we don't code the codeword itself, just - the length. This time, though, we have to encode each length */ - oggpack_write(opb,0,1); /* unordered */ - - /* algortihmic mapping has use for 'unused entries', which we tag - here. The algorithmic mapping happens as usual, but the unused - entry has no codeword. */ - for(i=0;ientries;i++) - if(c->lengthlist[i]==0)break; - - if(i==c->entries){ - oggpack_write(opb,0,1); /* no unused entries */ - for(i=0;ientries;i++) - oggpack_write(opb,c->lengthlist[i]-1,5); - }else{ - oggpack_write(opb,1,1); /* we have unused entries; thus we tag */ - for(i=0;ientries;i++){ - if(c->lengthlist[i]==0){ - oggpack_write(opb,0,1); - }else{ - oggpack_write(opb,1,1); - oggpack_write(opb,c->lengthlist[i]-1,5); - } - } - } - } - - /* is the entry number the desired return value, or do we have a - mapping? If we have a mapping, what type? */ - oggpack_write(opb,c->maptype,4); - switch(c->maptype){ - case 0: - /* no mapping */ - break; - case 1:case 2: - /* implicitly populated value mapping */ - /* explicitly populated value mapping */ - - if(!c->quantlist){ - /* no quantlist? error */ - return(-1); - } - - /* values that define the dequantization */ - oggpack_write(opb,c->q_min,32); - oggpack_write(opb,c->q_delta,32); - oggpack_write(opb,c->q_quant-1,4); - oggpack_write(opb,c->q_sequencep,1); - - { - int quantvals; - switch(c->maptype){ - case 1: - /* a single column of (c->entries/c->dim) quantized values for - building a full value list algorithmically (square lattice) */ - quantvals=_book_maptype1_quantvals(c); - break; - case 2: - /* every value (c->entries*c->dim total) specified explicitly */ - quantvals=c->entries*c->dim; - break; - default: /* NOT_REACHABLE */ - quantvals=-1; - } - - /* quantized values */ - for(i=0;iquantlist[i]),c->q_quant); - - } - break; - default: - /* error case; we don't have any other map types now */ - return(-1); - } - - return(0); -} - -/* unpacks a codebook from the packet buffer into the codebook struct, - readies the codebook auxiliary structures for decode *************/ -static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){ - long i,j; - static_codebook *s=_ogg_calloc(1,sizeof(*s)); - s->allocedp=1; - - /* make sure alignment is correct */ - if(oggpack_read(opb,24)!=0x564342)goto _eofout; - - /* first the basic parameters */ - s->dim=oggpack_read(opb,16); - s->entries=oggpack_read(opb,24); - if(s->entries==-1)goto _eofout; - - if(ov_ilog(s->dim)+ov_ilog(s->entries)>24)goto _eofout; - - /* codeword ordering.... length ordered or unordered? */ - switch((int)oggpack_read(opb,1)){ - case 0:{ - long unused; - /* allocated but unused entries? */ - unused=oggpack_read(opb,1); - if((s->entries*(unused?1:5)+7)>>3>opb->storage-oggpack_bytes(opb)) - goto _eofout; - /* unordered */ - s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries); - - /* allocated but unused entries? */ - if(unused){ - /* yes, unused entries */ - - for(i=0;ientries;i++){ - if(oggpack_read(opb,1)){ - long num=oggpack_read(opb,5); - if(num==-1)goto _eofout; - s->lengthlist[i]=num+1; - }else - s->lengthlist[i]=0; - } - }else{ - /* all entries used; no tagging */ - for(i=0;ientries;i++){ - long num=oggpack_read(opb,5); - if(num==-1)goto _eofout; - s->lengthlist[i]=num+1; - } - } - - break; - } - case 1: - /* ordered */ - { - long length=oggpack_read(opb,5)+1; - if(length==0)goto _eofout; - s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries); - - for(i=0;ientries;){ - long num=oggpack_read(opb,ov_ilog(s->entries-i)); - if(num==-1)goto _eofout; - if(length>32 || num>s->entries-i || - (num>0 && (num-1)>>(length-1)>1)){ - goto _errout; - } - if(length>32)goto _errout; - for(j=0;jlengthlist[i]=length; - length++; - } - } - break; - default: - /* EOF */ - goto _eofout; - } - - /* Do we have a mapping to unpack? */ - switch((s->maptype=oggpack_read(opb,4))){ - case 0: - /* no mapping */ - break; - case 1: case 2: - /* implicitly populated value mapping */ - /* explicitly populated value mapping */ - - s->q_min=oggpack_read(opb,32); - s->q_delta=oggpack_read(opb,32); - s->q_quant=oggpack_read(opb,4)+1; - s->q_sequencep=oggpack_read(opb,1); - if(s->q_sequencep==-1)goto _eofout; - - { - int quantvals=0; - switch(s->maptype){ - case 1: - quantvals=(s->dim==0?0:_book_maptype1_quantvals(s)); - break; - case 2: - quantvals=s->entries*s->dim; - break; - } - - /* quantized values */ - if(((quantvals*s->q_quant+7)>>3)>opb->storage-oggpack_bytes(opb)) - goto _eofout; - s->quantlist=_ogg_malloc(sizeof(*s->quantlist)*quantvals); - for(i=0;iquantlist[i]=oggpack_read(opb,s->q_quant); - - if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; - } - break; - default: - goto _errout; - } - - /* all set */ - return(s); - - _errout: - _eofout: - vorbis_staticbook_destroy(s); - return(NULL); -} - -/* returns the number of bits ************************************************/ -int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b){ - if(a<0 || a>=book->c->entries)return(0); - oggpack_write(b,book->codelist[a],book->c->lengthlist[a]); - return(book->c->lengthlist[a]); -} - -/* the 'eliminate the decode tree' optimization actually requires the - codewords to be MSb first, not LSb. This is an annoying inelegancy - (and one of the first places where carefully thought out design - turned out to be wrong; Vorbis II and future Ogg codecs should go - to an MSb bitpacker), but not actually the huge hit it appears to - be. The first-stage decode table catches most words so that - bitreverse is not in the main execution path. */ - -static ogg_uint32_t bitreverse(ogg_uint32_t x){ - x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000); - x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00); - x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0); - x= ((x>> 2)&0x33333333) | ((x<< 2)&0xcccccccc); - return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa); -} - -STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){ - int read=book->dec_maxlength; - long lo,hi; - long lok = oggpack_look(b,book->dec_firsttablen); - - if (lok >= 0) { - long entry = book->dec_firsttable[lok]; - if(entry&0x80000000UL){ - lo=(entry>>15)&0x7fff; - hi=book->used_entries-(entry&0x7fff); - }else{ - oggpack_adv(b, book->dec_codelengths[entry-1]); - return(entry-1); - } - }else{ - lo=0; - hi=book->used_entries; - } - - /* Single entry codebooks use a firsttablen of 1 and a - dec_maxlength of 1. If a single-entry codebook gets here (due to - failure to read one bit above), the next look attempt will also - fail and we'll correctly kick out instead of trying to walk the - underformed tree */ - - lok = oggpack_look(b, read); - - while(lok<0 && read>1) - lok = oggpack_look(b, --read); - if(lok<0)return -1; - - /* bisect search for the codeword in the ordered list */ - { - ogg_uint32_t testword=bitreverse((ogg_uint32_t)lok); - - while(hi-lo>1){ - long p=(hi-lo)>>1; - long test=book->codelist[lo+p]>testword; - lo+=p&(test-1); - hi-=p&(-test); - } - - if(book->dec_codelengths[lo]<=read){ - oggpack_adv(b, book->dec_codelengths[lo]); - return(lo); - } - } - - oggpack_adv(b, read); - - return(-1); -} - -/* Decode side is specced and easier, because we don't need to find - matches using different criteria; we simply read and map. There are - two things we need to do 'depending': - - We may need to support interleave. We don't really, but it's - convenient to do it here rather than rebuild the vector later. - - Cascades may be additive or multiplicitive; this is not inherent in - the codebook, but set in the code using the codebook. Like - interleaving, it's easiest to do it here. - addmul==0 -> declarative (set the value) - addmul==1 -> additive - addmul==2 -> multiplicitive */ - -/* returns the [original, not compacted] entry number or -1 on eof *********/ -long vorbis_book_decode(codebook *book, oggpack_buffer *b){ - if(book->used_entries>0){ - long packed_entry=decode_packed_entry_number(book,b); - if(packed_entry>=0) - return(book->dec_index[packed_entry]); - } - - /* if there's no dec_index, the codebook unpacking isn't collapsed */ - return(-1); -} - -/* returns 0 on OK or -1 on eof *************************************/ -/* decode vector / dim granularity gaurding is done in the upper layer */ -long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){ - if(book->used_entries>0){ - int step=n/book->dim; - long *entry = alloca(sizeof(*entry)*step); - float **t = alloca(sizeof(*t)*step); - int i,j,o; - - for (i = 0; i < step; i++) { - entry[i]=decode_packed_entry_number(book,b); - if(entry[i]==-1)return(-1); - t[i] = book->valuelist+entry[i]*book->dim; - } - for(i=0,o=0;idim;i++,o+=step) - for (j=0;o+jused_entries>0){ - int i,j,entry; - float *t; - - for(i=0;ivaluelist+entry*book->dim; - for(j=0;idim;) - a[i++]+=t[j++]; - } - } - return(0); -} - -/* unlike the others, we guard against n not being an integer number - of internally rather than in the upper layer (called only by - floor0) */ -long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){ - if(book->used_entries>0){ - int i,j,entry; - float *t; - - for(i=0;ivaluelist+entry*book->dim; - for (j=0;idim;){ - a[i++]=t[j++]; - } - } - }else{ - int i; - - for(i=0;iused_entries>0){ - int m=(offset+n)/ch; - for(i=offset/ch;ivaluelist+entry*book->dim; - for (j=0;idim;j++){ - a[chptr++][i]+=t[j]; - if(chptr==ch){ - chptr=0; - i++; - } - } - } - } - } - return(0); -} diff --git a/Engine/lib/libvorbis/lib/codebook.h b/Engine/lib/libvorbis/lib/codebook.h deleted file mode 100644 index 7d4e2aae4..000000000 --- a/Engine/lib/libvorbis/lib/codebook.h +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: basic shared codebook operations - - ********************************************************************/ - -#ifndef _V_CODEBOOK_H_ -#define _V_CODEBOOK_H_ - -#include - -/* This structure encapsulates huffman and VQ style encoding books; it - doesn't do anything specific to either. - - valuelist/quantlist are nonNULL (and q_* significant) only if - there's entry->value mapping to be done. - - If encode-side mapping must be done (and thus the entry needs to be - hunted), the auxiliary encode pointer will point to a decision - tree. This is true of both VQ and huffman, but is mostly useful - with VQ. - -*/ - -typedef struct static_codebook{ - long dim; /* codebook dimensions (elements per vector) */ - long entries; /* codebook entries */ - char *lengthlist; /* codeword lengths in bits */ - - /* mapping ***************************************************************/ - int maptype; /* 0=none - 1=implicitly populated values from map column - 2=listed arbitrary values */ - - /* The below does a linear, single monotonic sequence mapping. */ - long q_min; /* packed 32 bit float; quant value 0 maps to minval */ - long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ - int q_quant; /* bits: 0 < quant <= 16 */ - int q_sequencep; /* bitflag */ - - long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map - map == 2: list of dim*entries quantized entry vals - */ - int allocedp; -} static_codebook; - -typedef struct codebook{ - long dim; /* codebook dimensions (elements per vector) */ - long entries; /* codebook entries */ - long used_entries; /* populated codebook entries */ - const static_codebook *c; - - /* for encode, the below are entry-ordered, fully populated */ - /* for decode, the below are ordered by bitreversed codeword and only - used entries are populated */ - float *valuelist; /* list of dim*entries actual entry values */ - ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */ - - int *dec_index; /* only used if sparseness collapsed */ - char *dec_codelengths; - ogg_uint32_t *dec_firsttable; - int dec_firsttablen; - int dec_maxlength; - - /* The current encoder uses only centered, integer-only lattice books. */ - int quantvals; - int minval; - int delta; -} codebook; - -extern void vorbis_staticbook_destroy(static_codebook *b); -extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source); -extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); -extern void vorbis_book_clear(codebook *b); - -extern float *_book_unquantize(const static_codebook *b,int n,int *map); -extern float *_book_logdist(const static_codebook *b,float *vals); -extern float _float32_unpack(long val); -extern long _float32_pack(float val); -extern int _best(codebook *book, float *a, int step); -extern long _book_maptype1_quantvals(const static_codebook *b); - -extern int vorbis_book_besterror(codebook *book,float *a,int step,int addmul); -extern long vorbis_book_codeword(codebook *book,int entry); -extern long vorbis_book_codelen(codebook *book,int entry); - - - -extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b); -extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b); - -extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b); - -extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); -extern long vorbis_book_decodevs_add(codebook *book, float *a, - oggpack_buffer *b,int n); -extern long vorbis_book_decodev_set(codebook *book, float *a, - oggpack_buffer *b,int n); -extern long vorbis_book_decodev_add(codebook *book, float *a, - oggpack_buffer *b,int n); -extern long vorbis_book_decodevv_add(codebook *book, float **a, - long off,int ch, - oggpack_buffer *b,int n); - - - -#endif diff --git a/Engine/lib/libvorbis/lib/codec_internal.h b/Engine/lib/libvorbis/lib/codec_internal.h deleted file mode 100644 index 2ecf5e5c7..000000000 --- a/Engine/lib/libvorbis/lib/codec_internal.h +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: libvorbis codec headers - - ********************************************************************/ - -#ifndef _V_CODECI_H_ -#define _V_CODECI_H_ - -#include "envelope.h" -#include "codebook.h" - -#define BLOCKTYPE_IMPULSE 0 -#define BLOCKTYPE_PADDING 1 -#define BLOCKTYPE_TRANSITION 0 -#define BLOCKTYPE_LONG 1 - -#define PACKETBLOBS 15 - -typedef struct vorbis_block_internal{ - float **pcmdelay; /* this is a pointer into local storage */ - float ampmax; - int blocktype; - - oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed; - blob [PACKETBLOBS/2] points to - the oggpack_buffer in the - main vorbis_block */ -} vorbis_block_internal; - -typedef void vorbis_look_floor; -typedef void vorbis_look_residue; -typedef void vorbis_look_transform; - -/* mode ************************************************************/ -typedef struct { - int blockflag; - int windowtype; - int transformtype; - int mapping; -} vorbis_info_mode; - -typedef void vorbis_info_floor; -typedef void vorbis_info_residue; -typedef void vorbis_info_mapping; - -#include "psy.h" -#include "bitrate.h" - -typedef struct private_state { - /* local lookup storage */ - envelope_lookup *ve; /* envelope lookup */ - int window[2]; - vorbis_look_transform **transform[2]; /* block, type */ - drft_lookup fft_look[2]; - - int modebits; - vorbis_look_floor **flr; - vorbis_look_residue **residue; - vorbis_look_psy *psy; - vorbis_look_psy_global *psy_g_look; - - /* local storage, only used on the encoding side. This way the - application does not need to worry about freeing some packets' - memory and not others'; packet storage is always tracked. - Cleared next call to a _dsp_ function */ - unsigned char *header; - unsigned char *header1; - unsigned char *header2; - - bitrate_manager_state bms; - - ogg_int64_t sample_count; -} private_state; - -/* codec_setup_info contains all the setup information specific to the - specific compression/decompression mode in progress (eg, - psychoacoustic settings, channel setup, options, codebook - etc). -*********************************************************************/ - -#include "highlevel.h" -typedef struct codec_setup_info { - - /* Vorbis supports only short and long blocks, but allows the - encoder to choose the sizes */ - - long blocksizes[2]; - - /* modes are the primary means of supporting on-the-fly different - blocksizes, different channel mappings (LR or M/A), - different residue backends, etc. Each mode consists of a - blocksize flag and a mapping (along with the mapping setup */ - - int modes; - int maps; - int floors; - int residues; - int books; - int psys; /* encode only */ - - vorbis_info_mode *mode_param[64]; - int map_type[64]; - vorbis_info_mapping *map_param[64]; - int floor_type[64]; - vorbis_info_floor *floor_param[64]; - int residue_type[64]; - vorbis_info_residue *residue_param[64]; - static_codebook *book_param[256]; - codebook *fullbooks; - - vorbis_info_psy *psy_param[4]; /* encode only */ - vorbis_info_psy_global psy_g_param; - - bitrate_manager_info bi; - highlevel_encode_setup hi; /* used only by vorbisenc.c. It's a - highly redundant structure, but - improves clarity of program flow. */ - int halfrate_flag; /* painless downsample for decode */ -} codec_setup_info; - -extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi); -extern void _vp_global_free(vorbis_look_psy_global *look); - - - -typedef struct { - int sorted_index[VIF_POSIT+2]; - int forward_index[VIF_POSIT+2]; - int reverse_index[VIF_POSIT+2]; - - int hineighbor[VIF_POSIT]; - int loneighbor[VIF_POSIT]; - int posts; - - int n; - int quant_q; - vorbis_info_floor1 *vi; - - long phrasebits; - long postbits; - long frames; -} vorbis_look_floor1; - - - -extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look, - const float *logmdct, /* in */ - const float *logmask); -extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look, - int *A,int *B, - int del); -extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb, - vorbis_look_floor1 *look, - int *post,int *ilogmask); -#endif diff --git a/Engine/lib/libvorbis/lib/envelope.c b/Engine/lib/libvorbis/lib/envelope.c deleted file mode 100644 index 22d39aa6e..000000000 --- a/Engine/lib/libvorbis/lib/envelope.c +++ /dev/null @@ -1,374 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: PCM data envelope analysis - - ********************************************************************/ - -#include -#include -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" - -#include "os.h" -#include "scales.h" -#include "envelope.h" -#include "mdct.h" -#include "misc.h" - -void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){ - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy_global *gi=&ci->psy_g_param; - int ch=vi->channels; - int i,j; - int n=e->winlength=128; - e->searchstep=64; /* not random */ - - e->minenergy=gi->preecho_minenergy; - e->ch=ch; - e->storage=128; - e->cursor=ci->blocksizes[1]/2; - e->mdct_win=_ogg_calloc(n,sizeof(*e->mdct_win)); - mdct_init(&e->mdct,n); - - for(i=0;imdct_win[i]=sin(i/(n-1.)*M_PI); - e->mdct_win[i]*=e->mdct_win[i]; - } - - /* magic follows */ - e->band[0].begin=2; e->band[0].end=4; - e->band[1].begin=4; e->band[1].end=5; - e->band[2].begin=6; e->band[2].end=6; - e->band[3].begin=9; e->band[3].end=8; - e->band[4].begin=13; e->band[4].end=8; - e->band[5].begin=17; e->band[5].end=8; - e->band[6].begin=22; e->band[6].end=8; - - for(j=0;jband[j].end; - e->band[j].window=_ogg_malloc(n*sizeof(*e->band[0].window)); - for(i=0;iband[j].window[i]=sin((i+.5)/n*M_PI); - e->band[j].total+=e->band[j].window[i]; - } - e->band[j].total=1./e->band[j].total; - } - - e->filter=_ogg_calloc(VE_BANDS*ch,sizeof(*e->filter)); - e->mark=_ogg_calloc(e->storage,sizeof(*e->mark)); - -} - -void _ve_envelope_clear(envelope_lookup *e){ - int i; - mdct_clear(&e->mdct); - for(i=0;iband[i].window); - _ogg_free(e->mdct_win); - _ogg_free(e->filter); - _ogg_free(e->mark); - memset(e,0,sizeof(*e)); -} - -/* fairly straight threshhold-by-band based until we find something - that works better and isn't patented. */ - -static int _ve_amp(envelope_lookup *ve, - vorbis_info_psy_global *gi, - float *data, - envelope_band *bands, - envelope_filter_state *filters){ - long n=ve->winlength; - int ret=0; - long i,j; - float decay; - - /* we want to have a 'minimum bar' for energy, else we're just - basing blocks on quantization noise that outweighs the signal - itself (for low power signals) */ - - float minV=ve->minenergy; - float *vec=alloca(n*sizeof(*vec)); - - /* stretch is used to gradually lengthen the number of windows - considered prevoius-to-potential-trigger */ - int stretch=max(VE_MINSTRETCH,ve->stretch/2); - float penalty=gi->stretch_penalty-(ve->stretch/2-VE_MINSTRETCH); - if(penalty<0.f)penalty=0.f; - if(penalty>gi->stretch_penalty)penalty=gi->stretch_penalty; - - /*_analysis_output_always("lpcm",seq2,data,n,0,0, - totalshift+pos*ve->searchstep);*/ - - /* window and transform */ - for(i=0;imdct_win[i]; - mdct_forward(&ve->mdct,vec,vec); - - /*_analysis_output_always("mdct",seq2,vec,n/2,0,1,0); */ - - /* near-DC spreading function; this has nothing to do with - psychoacoustics, just sidelobe leakage and window size */ - { - float temp=vec[0]*vec[0]+.7*vec[1]*vec[1]+.2*vec[2]*vec[2]; - int ptr=filters->nearptr; - - /* the accumulation is regularly refreshed from scratch to avoid - floating point creep */ - if(ptr==0){ - decay=filters->nearDC_acc=filters->nearDC_partialacc+temp; - filters->nearDC_partialacc=temp; - }else{ - decay=filters->nearDC_acc+=temp; - filters->nearDC_partialacc+=temp; - } - filters->nearDC_acc-=filters->nearDC[ptr]; - filters->nearDC[ptr]=temp; - - decay*=(1./(VE_NEARDC+1)); - filters->nearptr++; - if(filters->nearptr>=VE_NEARDC)filters->nearptr=0; - decay=todB(&decay)*.5-15.f; - } - - /* perform spreading and limiting, also smooth the spectrum. yes, - the MDCT results in all real coefficients, but it still *behaves* - like real/imaginary pairs */ - for(i=0;i>1]=val; - decay-=8.; - } - - /*_analysis_output_always("spread",seq2++,vec,n/4,0,0,0);*/ - - /* perform preecho/postecho triggering by band */ - for(j=0;j=VE_AMP)filters[j].ampptr=0; - } - - /* look at min/max, decide trigger */ - if(valmax>gi->preecho_thresh[j]+penalty){ - ret|=1; - ret|=4; - } - if(valminpostecho_thresh[j]-penalty)ret|=2; - } - - return(ret); -} - -#if 0 -static int seq=0; -static ogg_int64_t totalshift=-1024; -#endif - -long _ve_envelope_search(vorbis_dsp_state *v){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy_global *gi=&ci->psy_g_param; - envelope_lookup *ve=((private_state *)(v->backend_state))->ve; - long i,j; - - int first=ve->current/ve->searchstep; - int last=v->pcm_current/ve->searchstep-VE_WIN; - if(first<0)first=0; - - /* make sure we have enough storage to match the PCM */ - if(last+VE_WIN+VE_POST>ve->storage){ - ve->storage=last+VE_WIN+VE_POST; /* be sure */ - ve->mark=_ogg_realloc(ve->mark,ve->storage*sizeof(*ve->mark)); - } - - for(j=first;jstretch++; - if(ve->stretch>VE_MAXSTRETCH*2) - ve->stretch=VE_MAXSTRETCH*2; - - for(i=0;ich;i++){ - float *pcm=v->pcm[i]+ve->searchstep*(j); - ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS); - } - - ve->mark[j+VE_POST]=0; - if(ret&1){ - ve->mark[j]=1; - ve->mark[j+1]=1; - } - - if(ret&2){ - ve->mark[j]=1; - if(j>0)ve->mark[j-1]=1; - } - - if(ret&4)ve->stretch=-1; - } - - ve->current=last*ve->searchstep; - - { - long centerW=v->centerW; - long testW= - centerW+ - ci->blocksizes[v->W]/4+ - ci->blocksizes[1]/2+ - ci->blocksizes[0]/4; - - j=ve->cursor; - - while(jcurrent-(ve->searchstep)){/* account for postecho - working back one window */ - if(j>=testW)return(1); - - ve->cursor=j; - - if(ve->mark[j/ve->searchstep]){ - if(j>centerW){ - -#if 0 - if(j>ve->curmark){ - float *marker=alloca(v->pcm_current*sizeof(*marker)); - int l,m; - memset(marker,0,sizeof(*marker)*v->pcm_current); - fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n", - seq, - (totalshift+ve->cursor)/44100., - (totalshift+j)/44100.); - _analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift); - _analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift); - - _analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift); - _analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift); - - for(m=0;msearchstep]=ve->filter[m].markers[l]*.1; - _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); - } - - for(m=0;msearchstep]=ve->filter[m+VE_BANDS].markers[l]*.1; - _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); - } - - for(l=0;lsearchstep]=ve->mark[l]*.4; - _analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift); - - - seq++; - - } -#endif - - ve->curmark=j; - if(j>=testW)return(1); - return(0); - } - } - j+=ve->searchstep; - } - } - - return(-1); -} - -int _ve_envelope_mark(vorbis_dsp_state *v){ - envelope_lookup *ve=((private_state *)(v->backend_state))->ve; - vorbis_info *vi=v->vi; - codec_setup_info *ci=vi->codec_setup; - long centerW=v->centerW; - long beginW=centerW-ci->blocksizes[v->W]/4; - long endW=centerW+ci->blocksizes[v->W]/4; - if(v->W){ - beginW-=ci->blocksizes[v->lW]/4; - endW+=ci->blocksizes[v->nW]/4; - }else{ - beginW-=ci->blocksizes[0]/4; - endW+=ci->blocksizes[0]/4; - } - - if(ve->curmark>=beginW && ve->curmarksearchstep; - long last=endW/ve->searchstep; - long i; - for(i=first;imark[i])return(1); - } - return(0); -} - -void _ve_envelope_shift(envelope_lookup *e,long shift){ - int smallsize=e->current/e->searchstep+VE_POST; /* adjust for placing marks - ahead of ve->current */ - int smallshift=shift/e->searchstep; - - memmove(e->mark,e->mark+smallshift,(smallsize-smallshift)*sizeof(*e->mark)); - -#if 0 - for(i=0;ich;i++) - memmove(e->filter[i].markers, - e->filter[i].markers+smallshift, - (1024-smallshift)*sizeof(*(*e->filter).markers)); - totalshift+=shift; -#endif - - e->current-=shift; - if(e->curmark>=0) - e->curmark-=shift; - e->cursor-=shift; -} diff --git a/Engine/lib/libvorbis/lib/envelope.h b/Engine/lib/libvorbis/lib/envelope.h deleted file mode 100644 index 2ef60a82c..000000000 --- a/Engine/lib/libvorbis/lib/envelope.h +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: PCM data envelope analysis and manipulation - - ********************************************************************/ - -#ifndef _V_ENVELOPE_ -#define _V_ENVELOPE_ - -#include "mdct.h" - -#define VE_PRE 16 -#define VE_WIN 4 -#define VE_POST 2 -#define VE_AMP (VE_PRE+VE_POST-1) - -#define VE_BANDS 7 -#define VE_NEARDC 15 - -#define VE_MINSTRETCH 2 /* a bit less than short block */ -#define VE_MAXSTRETCH 12 /* one-third full block */ - -typedef struct { - float ampbuf[VE_AMP]; - int ampptr; - - float nearDC[VE_NEARDC]; - float nearDC_acc; - float nearDC_partialacc; - int nearptr; - -} envelope_filter_state; - -typedef struct { - int begin; - int end; - float *window; - float total; -} envelope_band; - -typedef struct { - int ch; - int winlength; - int searchstep; - float minenergy; - - mdct_lookup mdct; - float *mdct_win; - - envelope_band band[VE_BANDS]; - envelope_filter_state *filter; - int stretch; - - int *mark; - - long storage; - long current; - long curmark; - long cursor; -} envelope_lookup; - -extern void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi); -extern void _ve_envelope_clear(envelope_lookup *e); -extern long _ve_envelope_search(vorbis_dsp_state *v); -extern void _ve_envelope_shift(envelope_lookup *e,long shift); -extern int _ve_envelope_mark(vorbis_dsp_state *v); - - -#endif diff --git a/Engine/lib/libvorbis/lib/floor0.c b/Engine/lib/libvorbis/lib/floor0.c deleted file mode 100644 index f4a6d4d55..000000000 --- a/Engine/lib/libvorbis/lib/floor0.c +++ /dev/null @@ -1,223 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: floor backend 0 implementation - - ********************************************************************/ - -#include -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "registry.h" -#include "lpc.h" -#include "lsp.h" -#include "codebook.h" -#include "scales.h" -#include "misc.h" -#include "os.h" - -#include "misc.h" -#include - -typedef struct { - int ln; - int m; - int **linearmap; - int n[2]; - - vorbis_info_floor0 *vi; - - long bits; - long frames; -} vorbis_look_floor0; - - -/***********************************************/ - -static void floor0_free_info(vorbis_info_floor *i){ - vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; - if(info){ - memset(info,0,sizeof(*info)); - _ogg_free(info); - } -} - -static void floor0_free_look(vorbis_look_floor *i){ - vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; - if(look){ - - if(look->linearmap){ - - if(look->linearmap[0])_ogg_free(look->linearmap[0]); - if(look->linearmap[1])_ogg_free(look->linearmap[1]); - - _ogg_free(look->linearmap); - } - memset(look,0,sizeof(*look)); - _ogg_free(look); - } -} - -static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){ - codec_setup_info *ci=vi->codec_setup; - int j; - - vorbis_info_floor0 *info=_ogg_malloc(sizeof(*info)); - info->order=oggpack_read(opb,8); - info->rate=oggpack_read(opb,16); - info->barkmap=oggpack_read(opb,16); - info->ampbits=oggpack_read(opb,6); - info->ampdB=oggpack_read(opb,8); - info->numbooks=oggpack_read(opb,4)+1; - - if(info->order<1)goto err_out; - if(info->rate<1)goto err_out; - if(info->barkmap<1)goto err_out; - if(info->numbooks<1)goto err_out; - - for(j=0;jnumbooks;j++){ - info->books[j]=oggpack_read(opb,8); - if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out; - if(ci->book_param[info->books[j]]->maptype==0)goto err_out; - if(ci->book_param[info->books[j]]->dim<1)goto err_out; - } - return(info); - - err_out: - floor0_free_info(info); - return(NULL); -} - -/* initialize Bark scale and normalization lookups. We could do this - with static tables, but Vorbis allows a number of possible - combinations, so it's best to do it computationally. - - The below is authoritative in terms of defining scale mapping. - Note that the scale depends on the sampling rate as well as the - linear block and mapping sizes */ - -static void floor0_map_lazy_init(vorbis_block *vb, - vorbis_info_floor *infoX, - vorbis_look_floor0 *look){ - if(!look->linearmap[vb->W]){ - vorbis_dsp_state *vd=vb->vd; - vorbis_info *vi=vd->vi; - codec_setup_info *ci=vi->codec_setup; - vorbis_info_floor0 *info=(vorbis_info_floor0 *)infoX; - int W=vb->W; - int n=ci->blocksizes[W]/2,j; - - /* we choose a scaling constant so that: - floor(bark(rate/2-1)*C)=mapped-1 - floor(bark(rate/2)*C)=mapped */ - float scale=look->ln/toBARK(info->rate/2.f); - - /* the mapping from a linear scale to a smaller bark scale is - straightforward. We do *not* make sure that the linear mapping - does not skip bark-scale bins; the decoder simply skips them and - the encoder may do what it wishes in filling them. They're - necessary in some mapping combinations to keep the scale spacing - accurate */ - look->linearmap[W]=_ogg_malloc((n+1)*sizeof(**look->linearmap)); - for(j=0;jrate/2.f)/n*j) - *scale); /* bark numbers represent band edges */ - if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ - look->linearmap[W][j]=val; - } - look->linearmap[W][j]=-1; - look->n[W]=n; - } -} - -static vorbis_look_floor *floor0_look(vorbis_dsp_state *vd, - vorbis_info_floor *i){ - vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; - vorbis_look_floor0 *look=_ogg_calloc(1,sizeof(*look)); - - (void)vd; - - look->m=info->order; - look->ln=info->barkmap; - look->vi=info; - - look->linearmap=_ogg_calloc(2,sizeof(*look->linearmap)); - - return look; -} - -static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){ - vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; - vorbis_info_floor0 *info=look->vi; - int j,k; - - int ampraw=oggpack_read(&vb->opb,info->ampbits); - if(ampraw>0){ /* also handles the -1 out of data case */ - long maxval=(1<ampbits)-1; - float amp=(float)ampraw/maxval*info->ampdB; - int booknum=oggpack_read(&vb->opb,ov_ilog(info->numbooks)); - - if(booknum!=-1 && booknumnumbooks){ /* be paranoid */ - codec_setup_info *ci=vb->vd->vi->codec_setup; - codebook *b=ci->fullbooks+info->books[booknum]; - float last=0.f; - - /* the additional b->dim is a guard against any possible stack - smash; b->dim is provably more than we can overflow the - vector */ - float *lsp=_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+b->dim+1)); - - if(vorbis_book_decodev_set(b,lsp,&vb->opb,look->m)==-1)goto eop; - for(j=0;jm;){ - for(k=0;jm && kdim;k++,j++)lsp[j]+=last; - last=lsp[j-1]; - } - - lsp[look->m]=amp; - return(lsp); - } - } - eop: - return(NULL); -} - -static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, - void *memo,float *out){ - vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; - vorbis_info_floor0 *info=look->vi; - - floor0_map_lazy_init(vb,info,look); - - if(memo){ - float *lsp=(float *)memo; - float amp=lsp[look->m]; - - /* take the coefficients back to a spectral envelope curve */ - vorbis_lsp_to_curve(out, - look->linearmap[vb->W], - look->n[vb->W], - look->ln, - lsp,look->m,amp,(float)info->ampdB); - return(1); - } - memset(out,0,sizeof(*out)*look->n[vb->W]); - return(0); -} - -/* export hooks */ -const vorbis_func_floor floor0_exportbundle={ - NULL,&floor0_unpack,&floor0_look,&floor0_free_info, - &floor0_free_look,&floor0_inverse1,&floor0_inverse2 -}; diff --git a/Engine/lib/libvorbis/lib/floor1.c b/Engine/lib/libvorbis/lib/floor1.c deleted file mode 100644 index c4fe3ea7e..000000000 --- a/Engine/lib/libvorbis/lib/floor1.c +++ /dev/null @@ -1,1086 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: floor backend 1 implementation - - ********************************************************************/ - -#include -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "registry.h" -#include "codebook.h" -#include "misc.h" -#include "scales.h" - -#include - -#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */ - -typedef struct lsfit_acc{ - int x0; - int x1; - - int xa; - int ya; - int x2a; - int y2a; - int xya; - int an; - - int xb; - int yb; - int x2b; - int y2b; - int xyb; - int bn; -} lsfit_acc; - -/***********************************************/ - -static void floor1_free_info(vorbis_info_floor *i){ - vorbis_info_floor1 *info=(vorbis_info_floor1 *)i; - if(info){ - memset(info,0,sizeof(*info)); - _ogg_free(info); - } -} - -static void floor1_free_look(vorbis_look_floor *i){ - vorbis_look_floor1 *look=(vorbis_look_floor1 *)i; - if(look){ - /*fprintf(stderr,"floor 1 bit usage %f:%f (%f total)\n", - (float)look->phrasebits/look->frames, - (float)look->postbits/look->frames, - (float)(look->postbits+look->phrasebits)/look->frames);*/ - - memset(look,0,sizeof(*look)); - _ogg_free(look); - } -} - -static void floor1_pack (vorbis_info_floor *i,oggpack_buffer *opb){ - vorbis_info_floor1 *info=(vorbis_info_floor1 *)i; - int j,k; - int count=0; - int rangebits; - int maxposit=info->postlist[1]; - int maxclass=-1; - - /* save out partitions */ - oggpack_write(opb,info->partitions,5); /* only 0 to 31 legal */ - for(j=0;jpartitions;j++){ - oggpack_write(opb,info->partitionclass[j],4); /* only 0 to 15 legal */ - if(maxclasspartitionclass[j])maxclass=info->partitionclass[j]; - } - - /* save out partition classes */ - for(j=0;jclass_dim[j]-1,3); /* 1 to 8 */ - oggpack_write(opb,info->class_subs[j],2); /* 0 to 3 */ - if(info->class_subs[j])oggpack_write(opb,info->class_book[j],8); - for(k=0;k<(1<class_subs[j]);k++) - oggpack_write(opb,info->class_subbook[j][k]+1,8); - } - - /* save out the post list */ - oggpack_write(opb,info->mult-1,2); /* only 1,2,3,4 legal now */ - /* maxposit cannot legally be less than 1; this is encode-side, we - can assume our setup is OK */ - oggpack_write(opb,ov_ilog(maxposit-1),4); - rangebits=ov_ilog(maxposit-1); - - for(j=0,k=0;jpartitions;j++){ - count+=info->class_dim[info->partitionclass[j]]; - for(;kpostlist[k+2],rangebits); - } -} - -static int icomp(const void *a,const void *b){ - return(**(int **)a-**(int **)b); -} - -static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){ - codec_setup_info *ci=vi->codec_setup; - int j,k,count=0,maxclass=-1,rangebits; - - vorbis_info_floor1 *info=_ogg_calloc(1,sizeof(*info)); - /* read partitions */ - info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */ - for(j=0;jpartitions;j++){ - info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */ - if(info->partitionclass[j]<0)goto err_out; - if(maxclasspartitionclass[j])maxclass=info->partitionclass[j]; - } - - /* read partition classes */ - for(j=0;jclass_dim[j]=oggpack_read(opb,3)+1; /* 1 to 8 */ - info->class_subs[j]=oggpack_read(opb,2); /* 0,1,2,3 bits */ - if(info->class_subs[j]<0) - goto err_out; - if(info->class_subs[j])info->class_book[j]=oggpack_read(opb,8); - if(info->class_book[j]<0 || info->class_book[j]>=ci->books) - goto err_out; - for(k=0;k<(1<class_subs[j]);k++){ - info->class_subbook[j][k]=oggpack_read(opb,8)-1; - if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books) - goto err_out; - } - } - - /* read the post list */ - info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */ - rangebits=oggpack_read(opb,4); - if(rangebits<0)goto err_out; - - for(j=0,k=0;jpartitions;j++){ - count+=info->class_dim[info->partitionclass[j]]; - if(count>VIF_POSIT) goto err_out; - for(;kpostlist[k+2]=oggpack_read(opb,rangebits); - if(t<0 || t>=(1<postlist[0]=0; - info->postlist[1]=1<postlist+j; - qsort(sortpointer,count+2,sizeof(*sortpointer),icomp); - - for(j=1;jvi=info; - look->n=info->postlist[1]; - - /* we drop each position value in-between already decoded values, - and use linear interpolation to predict each new value past the - edges. The positions are read in the order of the position - list... we precompute the bounding positions in the lookup. Of - course, the neighbors can change (if a position is declined), but - this is an initial mapping */ - - for(i=0;ipartitions;i++)n+=info->class_dim[info->partitionclass[i]]; - n+=2; - look->posts=n; - - /* also store a sorted position index */ - for(i=0;ipostlist+i; - qsort(sortpointer,n,sizeof(*sortpointer),icomp); - - /* points from sort order back to range number */ - for(i=0;iforward_index[i]=sortpointer[i]-info->postlist; - /* points from range order to sorted position */ - for(i=0;ireverse_index[look->forward_index[i]]=i; - /* we actually need the post values too */ - for(i=0;isorted_index[i]=info->postlist[look->forward_index[i]]; - - /* quantize values to multiplier spec */ - switch(info->mult){ - case 1: /* 1024 -> 256 */ - look->quant_q=256; - break; - case 2: /* 1024 -> 128 */ - look->quant_q=128; - break; - case 3: /* 1024 -> 86 */ - look->quant_q=86; - break; - case 4: /* 1024 -> 64 */ - look->quant_q=64; - break; - } - - /* discover our neighbors for decode where we don't use fit flags - (that would push the neighbors outward) */ - for(i=0;in; - int currentx=info->postlist[i+2]; - for(j=0;jpostlist[j]; - if(x>lx && xcurrentx){ - hi=j; - hx=x; - } - } - look->loneighbor[i]=lo; - look->hineighbor[i]=hi; - } - - return(look); -} - -static int render_point(int x0,int x1,int y0,int y1,int x){ - y0&=0x7fff; /* mask off flag */ - y1&=0x7fff; - - { - int dy=y1-y0; - int adx=x1-x0; - int ady=abs(dy); - int err=ady*(x-x0); - - int off=err/adx; - if(dy<0)return(y0-off); - return(y0+off); - } -} - -static int vorbis_dBquant(const float *x){ - int i= *x*7.3142857f+1023.5f; - if(i>1023)return(1023); - if(i<0)return(0); - return i; -} - -static const float FLOOR1_fromdB_LOOKUP[256]={ - 1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F, - 1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F, - 1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F, - 2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F, - 2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F, - 3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F, - 4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F, - 6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F, - 7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F, - 1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F, - 1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F, - 1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F, - 2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F, - 2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F, - 3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F, - 4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F, - 5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F, - 7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F, - 9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F, - 1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F, - 1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F, - 2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F, - 2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F, - 3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F, - 4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F, - 5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F, - 7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F, - 9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F, - 0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F, - 0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F, - 0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F, - 0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F, - 0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F, - 0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F, - 0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F, - 0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F, - 0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F, - 0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F, - 0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F, - 0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F, - 0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F, - 0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F, - 0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F, - 0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F, - 0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F, - 0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F, - 0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F, - 0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F, - 0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F, - 0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F, - 0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F, - 0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F, - 0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F, - 0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F, - 0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F, - 0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F, - 0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F, - 0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F, - 0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F, - 0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F, - 0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F, - 0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F, - 0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F, - 0.82788260F, 0.88168307F, 0.9389798F, 1.F, -}; - -static void render_line(int n, int x0,int x1,int y0,int y1,float *d){ - int dy=y1-y0; - int adx=x1-x0; - int ady=abs(dy); - int base=dy/adx; - int sy=(dy<0?base-1:base+1); - int x=x0; - int y=y0; - int err=0; - - ady-=abs(base*adx); - - if(n>x1)n=x1; - - if(x=adx){ - err-=adx; - y+=sy; - }else{ - y+=base; - } - d[x]*=FLOOR1_fromdB_LOOKUP[y]; - } -} - -static void render_line0(int n, int x0,int x1,int y0,int y1,int *d){ - int dy=y1-y0; - int adx=x1-x0; - int ady=abs(dy); - int base=dy/adx; - int sy=(dy<0?base-1:base+1); - int x=x0; - int y=y0; - int err=0; - - ady-=abs(base*adx); - - if(n>x1)n=x1; - - if(x=adx){ - err-=adx; - y+=sy; - }else{ - y+=base; - } - d[x]=y; - } -} - -/* the floor has already been filtered to only include relevant sections */ -static int accumulate_fit(const float *flr,const float *mdct, - int x0, int x1,lsfit_acc *a, - int n,vorbis_info_floor1 *info){ - long i; - - int xa=0,ya=0,x2a=0,y2a=0,xya=0,na=0, xb=0,yb=0,x2b=0,y2b=0,xyb=0,nb=0; - - memset(a,0,sizeof(*a)); - a->x0=x0; - a->x1=x1; - if(x1>=n)x1=n-1; - - for(i=x0;i<=x1;i++){ - int quantized=vorbis_dBquant(flr+i); - if(quantized){ - if(mdct[i]+info->twofitatten>=flr[i]){ - xa += i; - ya += quantized; - x2a += i*i; - y2a += quantized*quantized; - xya += i*quantized; - na++; - }else{ - xb += i; - yb += quantized; - x2b += i*i; - y2b += quantized*quantized; - xyb += i*quantized; - nb++; - } - } - } - - a->xa=xa; - a->ya=ya; - a->x2a=x2a; - a->y2a=y2a; - a->xya=xya; - a->an=na; - - a->xb=xb; - a->yb=yb; - a->x2b=x2b; - a->y2b=y2b; - a->xyb=xyb; - a->bn=nb; - - return(na); -} - -static int fit_line(lsfit_acc *a,int fits,int *y0,int *y1, - vorbis_info_floor1 *info){ - double xb=0,yb=0,x2b=0,y2b=0,xyb=0,bn=0; - int i; - int x0=a[0].x0; - int x1=a[fits-1].x1; - - for(i=0;itwofitweight/(a[i].an+1)+1.; - - xb+=a[i].xb + a[i].xa * weight; - yb+=a[i].yb + a[i].ya * weight; - x2b+=a[i].x2b + a[i].x2a * weight; - y2b+=a[i].y2b + a[i].y2a * weight; - xyb+=a[i].xyb + a[i].xya * weight; - bn+=a[i].bn + a[i].an * weight; - } - - if(*y0>=0){ - xb+= x0; - yb+= *y0; - x2b+= x0 * x0; - y2b+= *y0 * *y0; - xyb+= *y0 * x0; - bn++; - } - - if(*y1>=0){ - xb+= x1; - yb+= *y1; - x2b+= x1 * x1; - y2b+= *y1 * *y1; - xyb+= *y1 * x1; - bn++; - } - - { - double denom=(bn*x2b-xb*xb); - - if(denom>0.){ - double a=(yb*x2b-xyb*xb)/denom; - double b=(bn*xyb-xb*yb)/denom; - *y0=rint(a+b*x0); - *y1=rint(a+b*x1); - - /* limit to our range! */ - if(*y0>1023)*y0=1023; - if(*y1>1023)*y1=1023; - if(*y0<0)*y0=0; - if(*y1<0)*y1=0; - - return 0; - }else{ - *y0=0; - *y1=0; - return 1; - } - } -} - -static int inspect_error(int x0,int x1,int y0,int y1,const float *mask, - const float *mdct, - vorbis_info_floor1 *info){ - int dy=y1-y0; - int adx=x1-x0; - int ady=abs(dy); - int base=dy/adx; - int sy=(dy<0?base-1:base+1); - int x=x0; - int y=y0; - int err=0; - int val=vorbis_dBquant(mask+x); - int mse=0; - int n=0; - - ady-=abs(base*adx); - - mse=(y-val); - mse*=mse; - n++; - if(mdct[x]+info->twofitatten>=mask[x]){ - if(y+info->maxovermaxunder>val)return(1); - } - - while(++x=adx){ - err-=adx; - y+=sy; - }else{ - y+=base; - } - - val=vorbis_dBquant(mask+x); - mse+=((y-val)*(y-val)); - n++; - if(mdct[x]+info->twofitatten>=mask[x]){ - if(val){ - if(y+info->maxovermaxunder>val)return(1); - } - } - } - - if(info->maxover*info->maxover/n>info->maxerr)return(0); - if(info->maxunder*info->maxunder/n>info->maxerr)return(0); - if(mse/n>info->maxerr)return(1); - return(0); -} - -static int post_Y(int *A,int *B,int pos){ - if(A[pos]<0) - return B[pos]; - if(B[pos]<0) - return A[pos]; - - return (A[pos]+B[pos])>>1; -} - -int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look, - const float *logmdct, /* in */ - const float *logmask){ - long i,j; - vorbis_info_floor1 *info=look->vi; - long n=look->n; - long posts=look->posts; - long nonzero=0; - lsfit_acc fits[VIF_POSIT+1]; - int fit_valueA[VIF_POSIT+2]; /* index by range list position */ - int fit_valueB[VIF_POSIT+2]; /* index by range list position */ - - int loneighbor[VIF_POSIT+2]; /* sorted index of range list position (+2) */ - int hineighbor[VIF_POSIT+2]; - int *output=NULL; - int memo[VIF_POSIT+2]; - - for(i=0;isorted_index[i], - look->sorted_index[i+1],fits+i, - n,info); - } - - if(nonzero){ - /* start by fitting the implicit base case.... */ - int y0=-200; - int y1=-200; - fit_line(fits,posts-1,&y0,&y1,info); - - fit_valueA[0]=y0; - fit_valueB[0]=y0; - fit_valueB[1]=y1; - fit_valueA[1]=y1; - - /* Non degenerate case */ - /* start progressive splitting. This is a greedy, non-optimal - algorithm, but simple and close enough to the best - answer. */ - for(i=2;ireverse_index[i]; - int ln=loneighbor[sortpos]; - int hn=hineighbor[sortpos]; - - /* eliminate repeat searches of a particular range with a memo */ - if(memo[ln]!=hn){ - /* haven't performed this error search yet */ - int lsortpos=look->reverse_index[ln]; - int hsortpos=look->reverse_index[hn]; - memo[ln]=hn; - - { - /* A note: we want to bound/minimize *local*, not global, error */ - int lx=info->postlist[ln]; - int hx=info->postlist[hn]; - int ly=post_Y(fit_valueA,fit_valueB,ln); - int hy=post_Y(fit_valueA,fit_valueB,hn); - - if(ly==-1 || hy==-1){ - exit(1); - } - - if(inspect_error(lx,hx,ly,hy,logmask,logmdct,info)){ - /* outside error bounds/begin search area. Split it. */ - int ly0=-200; - int ly1=-200; - int hy0=-200; - int hy1=-200; - int ret0=fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1,info); - int ret1=fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1,info); - - if(ret0){ - ly0=ly; - ly1=hy0; - } - if(ret1){ - hy0=ly1; - hy1=hy; - } - - if(ret0 && ret1){ - fit_valueA[i]=-200; - fit_valueB[i]=-200; - }else{ - /* store new edge values */ - fit_valueB[ln]=ly0; - if(ln==0)fit_valueA[ln]=ly0; - fit_valueA[i]=ly1; - fit_valueB[i]=hy0; - fit_valueA[hn]=hy1; - if(hn==1)fit_valueB[hn]=hy1; - - if(ly1>=0 || hy0>=0){ - /* store new neighbor values */ - for(j=sortpos-1;j>=0;j--) - if(hineighbor[j]==hn) - hineighbor[j]=i; - else - break; - for(j=sortpos+1;jloneighbor[i-2]; - int hn=look->hineighbor[i-2]; - int x0=info->postlist[ln]; - int x1=info->postlist[hn]; - int y0=output[ln]; - int y1=output[hn]; - - int predicted=render_point(x0,x1,y0,y1,info->postlist[i]); - int vx=post_Y(fit_valueA,fit_valueB,i); - - if(vx>=0 && predicted!=vx){ - output[i]=vx; - }else{ - output[i]= predicted|0x8000; - } - } - } - - return(output); - -} - -int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look, - int *A,int *B, - int del){ - - long i; - long posts=look->posts; - int *output=NULL; - - if(A && B){ - output=_vorbis_block_alloc(vb,sizeof(*output)*posts); - - /* overly simpleminded--- look again post 1.2 */ - for(i=0;i>16; - if(A[i]&0x8000 && B[i]&0x8000)output[i]|=0x8000; - } - } - - return(output); -} - - -int floor1_encode(oggpack_buffer *opb,vorbis_block *vb, - vorbis_look_floor1 *look, - int *post,int *ilogmask){ - - long i,j; - vorbis_info_floor1 *info=look->vi; - long posts=look->posts; - codec_setup_info *ci=vb->vd->vi->codec_setup; - int out[VIF_POSIT+2]; - static_codebook **sbooks=ci->book_param; - codebook *books=ci->fullbooks; - - /* quantize values to multiplier spec */ - if(post){ - for(i=0;imult){ - case 1: /* 1024 -> 256 */ - val>>=2; - break; - case 2: /* 1024 -> 128 */ - val>>=3; - break; - case 3: /* 1024 -> 86 */ - val/=12; - break; - case 4: /* 1024 -> 64 */ - val>>=4; - break; - } - post[i]=val | (post[i]&0x8000); - } - - out[0]=post[0]; - out[1]=post[1]; - - /* find prediction values for each post and subtract them */ - for(i=2;iloneighbor[i-2]; - int hn=look->hineighbor[i-2]; - int x0=info->postlist[ln]; - int x1=info->postlist[hn]; - int y0=post[ln]; - int y1=post[hn]; - - int predicted=render_point(x0,x1,y0,y1,info->postlist[i]); - - if((post[i]&0x8000) || (predicted==post[i])){ - post[i]=predicted|0x8000; /* in case there was roundoff jitter - in interpolation */ - out[i]=0; - }else{ - int headroom=(look->quant_q-predictedquant_q-predicted:predicted); - - int val=post[i]-predicted; - - /* at this point the 'deviation' value is in the range +/- max - range, but the real, unique range can always be mapped to - only [0-maxrange). So we want to wrap the deviation into - this limited range, but do it in the way that least screws - an essentially gaussian probability distribution. */ - - if(val<0) - if(val<-headroom) - val=headroom-val-1; - else - val=-1-(val<<1); - else - if(val>=headroom) - val= val+headroom; - else - val<<=1; - - out[i]=val; - post[ln]&=0x7fff; - post[hn]&=0x7fff; - } - } - - /* we have everything we need. pack it out */ - /* mark nontrivial floor */ - oggpack_write(opb,1,1); - - /* beginning/end post */ - look->frames++; - look->postbits+=ov_ilog(look->quant_q-1)*2; - oggpack_write(opb,out[0],ov_ilog(look->quant_q-1)); - oggpack_write(opb,out[1],ov_ilog(look->quant_q-1)); - - - /* partition by partition */ - for(i=0,j=2;ipartitions;i++){ - int class=info->partitionclass[i]; - int cdim=info->class_dim[class]; - int csubbits=info->class_subs[class]; - int csub=1<class_subbook[class][k]; - if(booknum<0){ - maxval[k]=1; - }else{ - maxval[k]=sbooks[info->class_subbook[class][k]]->entries; - } - } - for(k=0;kphrasebits+= - vorbis_book_encode(books+info->class_book[class],cval,opb); - -#ifdef TRAIN_FLOOR1 - { - FILE *of; - char buffer[80]; - sprintf(buffer,"line_%dx%ld_class%d.vqd", - vb->pcmend/2,posts-2,class); - of=fopen(buffer,"a"); - fprintf(of,"%d\n",cval); - fclose(of); - } -#endif - } - - /* write post values */ - for(k=0;kclass_subbook[class][bookas[k]]; - if(book>=0){ - /* hack to allow training with 'bad' books */ - if(out[j+k]<(books+book)->entries) - look->postbits+=vorbis_book_encode(books+book, - out[j+k],opb); - /*else - fprintf(stderr,"+!");*/ - -#ifdef TRAIN_FLOOR1 - { - FILE *of; - char buffer[80]; - sprintf(buffer,"line_%dx%ld_%dsub%d.vqd", - vb->pcmend/2,posts-2,class,bookas[k]); - of=fopen(buffer,"a"); - fprintf(of,"%d\n",out[j+k]); - fclose(of); - } -#endif - } - } - j+=cdim; - } - - { - /* generate quantized floor equivalent to what we'd unpack in decode */ - /* render the lines */ - int hx=0; - int lx=0; - int ly=post[0]*info->mult; - int n=ci->blocksizes[vb->W]/2; - - for(j=1;jposts;j++){ - int current=look->forward_index[j]; - int hy=post[current]&0x7fff; - if(hy==post[current]){ - - hy*=info->mult; - hx=info->postlist[current]; - - render_line0(n,lx,hx,ly,hy,ilogmask); - - lx=hx; - ly=hy; - } - } - for(j=hx;jpcmend/2;j++)ilogmask[j]=ly; /* be certain */ - return(1); - } - }else{ - oggpack_write(opb,0,1); - memset(ilogmask,0,vb->pcmend/2*sizeof(*ilogmask)); - return(0); - } -} - -static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){ - vorbis_look_floor1 *look=(vorbis_look_floor1 *)in; - vorbis_info_floor1 *info=look->vi; - codec_setup_info *ci=vb->vd->vi->codec_setup; - - int i,j,k; - codebook *books=ci->fullbooks; - - /* unpack wrapped/predicted values from stream */ - if(oggpack_read(&vb->opb,1)==1){ - int *fit_value=_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value)); - - fit_value[0]=oggpack_read(&vb->opb,ov_ilog(look->quant_q-1)); - fit_value[1]=oggpack_read(&vb->opb,ov_ilog(look->quant_q-1)); - - /* partition by partition */ - for(i=0,j=2;ipartitions;i++){ - int class=info->partitionclass[i]; - int cdim=info->class_dim[class]; - int csubbits=info->class_subs[class]; - int csub=1<class_book[class],&vb->opb); - - if(cval==-1)goto eop; - } - - for(k=0;kclass_subbook[class][cval&(csub-1)]; - cval>>=csubbits; - if(book>=0){ - if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1) - goto eop; - }else{ - fit_value[j+k]=0; - } - } - j+=cdim; - } - - /* unwrap positive values and reconsitute via linear interpolation */ - for(i=2;iposts;i++){ - int predicted=render_point(info->postlist[look->loneighbor[i-2]], - info->postlist[look->hineighbor[i-2]], - fit_value[look->loneighbor[i-2]], - fit_value[look->hineighbor[i-2]], - info->postlist[i]); - int hiroom=look->quant_q-predicted; - int loroom=predicted; - int room=(hiroom=room){ - if(hiroom>loroom){ - val = val-loroom; - }else{ - val = -1-(val-hiroom); - } - }else{ - if(val&1){ - val= -((val+1)>>1); - }else{ - val>>=1; - } - } - - fit_value[i]=(val+predicted)&0x7fff; - fit_value[look->loneighbor[i-2]]&=0x7fff; - fit_value[look->hineighbor[i-2]]&=0x7fff; - - }else{ - fit_value[i]=predicted|0x8000; - } - - } - - return(fit_value); - } - eop: - return(NULL); -} - -static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo, - float *out){ - vorbis_look_floor1 *look=(vorbis_look_floor1 *)in; - vorbis_info_floor1 *info=look->vi; - - codec_setup_info *ci=vb->vd->vi->codec_setup; - int n=ci->blocksizes[vb->W]/2; - int j; - - if(memo){ - /* render the lines */ - int *fit_value=(int *)memo; - int hx=0; - int lx=0; - int ly=fit_value[0]*info->mult; - /* guard lookup against out-of-range values */ - ly=(ly<0?0:ly>255?255:ly); - - for(j=1;jposts;j++){ - int current=look->forward_index[j]; - int hy=fit_value[current]&0x7fff; - if(hy==fit_value[current]){ - - hx=info->postlist[current]; - hy*=info->mult; - /* guard lookup against out-of-range values */ - hy=(hy<0?0:hy>255?255:hy); - - render_line(n,lx,hx,ly,hy,out); - - lx=hx; - ly=hy; - } - } - for(j=hx;j header packets - - ********************************************************************/ - -/* general handling of the header and the vorbis_info structure (and - substructures) */ - -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "codebook.h" -#include "registry.h" -#include "window.h" -#include "psy.h" -#include "misc.h" -#include "os.h" - -#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.7" -#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20200704 (Reducing Environment)" - -/* helpers */ -static void _v_writestring(oggpack_buffer *o,const char *s, int bytes){ - - while(bytes--){ - oggpack_write(o,*s++,8); - } -} - -static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){ - while(bytes--){ - *buf++=oggpack_read(o,8); - } -} - -static int _v_toupper(int c) { - return (c >= 'a' && c <= 'z') ? (c & ~('a' - 'A')) : c; -} - -void vorbis_comment_init(vorbis_comment *vc){ - memset(vc,0,sizeof(*vc)); -} - -void vorbis_comment_add(vorbis_comment *vc,const char *comment){ - vc->user_comments=_ogg_realloc(vc->user_comments, - (vc->comments+2)*sizeof(*vc->user_comments)); - vc->comment_lengths=_ogg_realloc(vc->comment_lengths, - (vc->comments+2)*sizeof(*vc->comment_lengths)); - vc->comment_lengths[vc->comments]=strlen(comment); - vc->user_comments[vc->comments]=_ogg_malloc(vc->comment_lengths[vc->comments]+1); - strcpy(vc->user_comments[vc->comments], comment); - vc->comments++; - vc->user_comments[vc->comments]=NULL; -} - -void vorbis_comment_add_tag(vorbis_comment *vc, const char *tag, const char *contents){ - /* Length for key and value +2 for = and \0 */ - char *comment=_ogg_malloc(strlen(tag)+strlen(contents)+2); - strcpy(comment, tag); - strcat(comment, "="); - strcat(comment, contents); - vorbis_comment_add(vc, comment); - _ogg_free(comment); -} - -/* This is more or less the same as strncasecmp - but that doesn't exist - * everywhere, and this is a fairly trivial function, so we include it */ -static int tagcompare(const char *s1, const char *s2, int n){ - int c=0; - while(c < n){ - if(_v_toupper(s1[c]) != _v_toupper(s2[c])) - return !0; - c++; - } - return 0; -} - -char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count){ - long i; - int found = 0; - int taglen = strlen(tag)+1; /* +1 for the = we append */ - char *fulltag = _ogg_malloc(taglen+1); - - strcpy(fulltag, tag); - strcat(fulltag, "="); - - for(i=0;icomments;i++){ - if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ - if(count == found) { - /* We return a pointer to the data, not a copy */ - _ogg_free(fulltag); - return vc->user_comments[i] + taglen; - } else { - found++; - } - } - } - _ogg_free(fulltag); - return NULL; /* didn't find anything */ -} - -int vorbis_comment_query_count(vorbis_comment *vc, const char *tag){ - int i,count=0; - int taglen = strlen(tag)+1; /* +1 for the = we append */ - char *fulltag = _ogg_malloc(taglen+1); - strcpy(fulltag,tag); - strcat(fulltag, "="); - - for(i=0;icomments;i++){ - if(!tagcompare(vc->user_comments[i], fulltag, taglen)) - count++; - } - - _ogg_free(fulltag); - return count; -} - -void vorbis_comment_clear(vorbis_comment *vc){ - if(vc){ - long i; - if(vc->user_comments){ - for(i=0;icomments;i++) - if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); - _ogg_free(vc->user_comments); - } - if(vc->comment_lengths)_ogg_free(vc->comment_lengths); - if(vc->vendor)_ogg_free(vc->vendor); - memset(vc,0,sizeof(*vc)); - } -} - -/* blocksize 0 is guaranteed to be short, 1 is guaranteed to be long. - They may be equal, but short will never ge greater than long */ -int vorbis_info_blocksize(vorbis_info *vi,int zo){ - codec_setup_info *ci = vi->codec_setup; - return ci ? ci->blocksizes[zo] : -1; -} - -/* used by synthesis, which has a full, alloced vi */ -void vorbis_info_init(vorbis_info *vi){ - memset(vi,0,sizeof(*vi)); - vi->codec_setup=_ogg_calloc(1,sizeof(codec_setup_info)); -} - -void vorbis_info_clear(vorbis_info *vi){ - codec_setup_info *ci=vi->codec_setup; - int i; - - if(ci){ - - for(i=0;imodes;i++) - if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); - - for(i=0;imaps;i++) /* unpack does the range checking */ - if(ci->map_param[i]) /* this may be cleaning up an aborted - unpack, in which case the below type - cannot be trusted */ - _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); - - for(i=0;ifloors;i++) /* unpack does the range checking */ - if(ci->floor_param[i]) /* this may be cleaning up an aborted - unpack, in which case the below type - cannot be trusted */ - _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); - - for(i=0;iresidues;i++) /* unpack does the range checking */ - if(ci->residue_param[i]) /* this may be cleaning up an aborted - unpack, in which case the below type - cannot be trusted */ - _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); - - for(i=0;ibooks;i++){ - if(ci->book_param[i]){ - /* knows if the book was not alloced */ - vorbis_staticbook_destroy(ci->book_param[i]); - } - if(ci->fullbooks) - vorbis_book_clear(ci->fullbooks+i); - } - if(ci->fullbooks) - _ogg_free(ci->fullbooks); - - for(i=0;ipsys;i++) - _vi_psy_free(ci->psy_param[i]); - - _ogg_free(ci); - } - - memset(vi,0,sizeof(*vi)); -} - -/* Header packing/unpacking ********************************************/ - -static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){ - codec_setup_info *ci=vi->codec_setup; - int bs; - if(!ci)return(OV_EFAULT); - - vi->version=oggpack_read(opb,32); - if(vi->version!=0)return(OV_EVERSION); - - vi->channels=oggpack_read(opb,8); - vi->rate=oggpack_read(opb,32); - - vi->bitrate_upper=(ogg_int32_t)oggpack_read(opb,32); - vi->bitrate_nominal=(ogg_int32_t)oggpack_read(opb,32); - vi->bitrate_lower=(ogg_int32_t)oggpack_read(opb,32); - - bs = oggpack_read(opb,4); - if(bs<0)goto err_out; - ci->blocksizes[0]=1<blocksizes[1]=1<rate<1)goto err_out; - if(vi->channels<1)goto err_out; - if(ci->blocksizes[0]<64)goto err_out; - if(ci->blocksizes[1]blocksizes[0])goto err_out; - if(ci->blocksizes[1]>8192)goto err_out; - - if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ - - return(0); - err_out: - vorbis_info_clear(vi); - return(OV_EBADHEADER); -} - -static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){ - int i; - int vendorlen=oggpack_read(opb,32); - if(vendorlen<0)goto err_out; - if(vendorlen>opb->storage-8)goto err_out; - vc->vendor=_ogg_calloc(vendorlen+1,1); - _v_readstring(opb,vc->vendor,vendorlen); - i=oggpack_read(opb,32); - if(i<0)goto err_out; - if(i>((opb->storage-oggpack_bytes(opb))>>2))goto err_out; - vc->comments=i; - vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments)); - vc->comment_lengths=_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths)); - - for(i=0;icomments;i++){ - int len=oggpack_read(opb,32); - if(len<0)goto err_out; - if(len>opb->storage-oggpack_bytes(opb))goto err_out; - vc->comment_lengths[i]=len; - vc->user_comments[i]=_ogg_calloc(len+1,1); - _v_readstring(opb,vc->user_comments[i],len); - } - if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ - - return(0); - err_out: - vorbis_comment_clear(vc); - return(OV_EBADHEADER); -} - -/* all of the real encoding details are here. The modes, books, - everything */ -static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ - codec_setup_info *ci=vi->codec_setup; - int i; - - /* codebooks */ - ci->books=oggpack_read(opb,8)+1; - if(ci->books<=0)goto err_out; - for(i=0;ibooks;i++){ - ci->book_param[i]=vorbis_staticbook_unpack(opb); - if(!ci->book_param[i])goto err_out; - } - - /* time backend settings; hooks are unused */ - { - int times=oggpack_read(opb,6)+1; - if(times<=0)goto err_out; - for(i=0;i=VI_TIMEB)goto err_out; - } - } - - /* floor backend settings */ - ci->floors=oggpack_read(opb,6)+1; - if(ci->floors<=0)goto err_out; - for(i=0;ifloors;i++){ - ci->floor_type[i]=oggpack_read(opb,16); - if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out; - ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb); - if(!ci->floor_param[i])goto err_out; - } - - /* residue backend settings */ - ci->residues=oggpack_read(opb,6)+1; - if(ci->residues<=0)goto err_out; - for(i=0;iresidues;i++){ - ci->residue_type[i]=oggpack_read(opb,16); - if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out; - ci->residue_param[i]=_residue_P[ci->residue_type[i]]->unpack(vi,opb); - if(!ci->residue_param[i])goto err_out; - } - - /* map backend settings */ - ci->maps=oggpack_read(opb,6)+1; - if(ci->maps<=0)goto err_out; - for(i=0;imaps;i++){ - ci->map_type[i]=oggpack_read(opb,16); - if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out; - ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb); - if(!ci->map_param[i])goto err_out; - } - - /* mode settings */ - ci->modes=oggpack_read(opb,6)+1; - if(ci->modes<=0)goto err_out; - for(i=0;imodes;i++){ - ci->mode_param[i]=_ogg_calloc(1,sizeof(*ci->mode_param[i])); - ci->mode_param[i]->blockflag=oggpack_read(opb,1); - ci->mode_param[i]->windowtype=oggpack_read(opb,16); - ci->mode_param[i]->transformtype=oggpack_read(opb,16); - ci->mode_param[i]->mapping=oggpack_read(opb,8); - - if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out; - if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out; - if(ci->mode_param[i]->mapping>=ci->maps)goto err_out; - if(ci->mode_param[i]->mapping<0)goto err_out; - } - - if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */ - - return(0); - err_out: - vorbis_info_clear(vi); - return(OV_EBADHEADER); -} - -/* Is this packet a vorbis ID header? */ -int vorbis_synthesis_idheader(ogg_packet *op){ - oggpack_buffer opb; - char buffer[6]; - - if(op){ - oggpack_readinit(&opb,op->packet,op->bytes); - - if(!op->b_o_s) - return(0); /* Not the initial packet */ - - if(oggpack_read(&opb,8) != 1) - return 0; /* not an ID header */ - - memset(buffer,0,6); - _v_readstring(&opb,buffer,6); - if(memcmp(buffer,"vorbis",6)) - return 0; /* not vorbis */ - - return 1; - } - - return 0; -} - -/* The Vorbis header is in three packets; the initial small packet in - the first page that identifies basic parameters, a second packet - with bitstream comments and a third packet that holds the - codebook. */ - -int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){ - oggpack_buffer opb; - - if(op){ - oggpack_readinit(&opb,op->packet,op->bytes); - - /* Which of the three types of header is this? */ - /* Also verify header-ness, vorbis */ - { - char buffer[6]; - int packtype=oggpack_read(&opb,8); - memset(buffer,0,6); - _v_readstring(&opb,buffer,6); - if(memcmp(buffer,"vorbis",6)){ - /* not a vorbis header */ - return(OV_ENOTVORBIS); - } - switch(packtype){ - case 0x01: /* least significant *bit* is read first */ - if(!op->b_o_s){ - /* Not the initial packet */ - return(OV_EBADHEADER); - } - if(vi->rate!=0){ - /* previously initialized info header */ - return(OV_EBADHEADER); - } - - return(_vorbis_unpack_info(vi,&opb)); - - case 0x03: /* least significant *bit* is read first */ - if(vi->rate==0){ - /* um... we didn't get the initial header */ - return(OV_EBADHEADER); - } - if(vc->vendor!=NULL){ - /* previously initialized comment header */ - return(OV_EBADHEADER); - } - - return(_vorbis_unpack_comment(vc,&opb)); - - case 0x05: /* least significant *bit* is read first */ - if(vi->rate==0 || vc->vendor==NULL){ - /* um... we didn;t get the initial header or comments yet */ - return(OV_EBADHEADER); - } - if(vi->codec_setup==NULL){ - /* improperly initialized vorbis_info */ - return(OV_EFAULT); - } - if(((codec_setup_info *)vi->codec_setup)->books>0){ - /* previously initialized setup header */ - return(OV_EBADHEADER); - } - - return(_vorbis_unpack_books(vi,&opb)); - - default: - /* Not a valid vorbis header type */ - return(OV_EBADHEADER); - break; - } - } - } - return(OV_EBADHEADER); -} - -/* pack side **********************************************************/ - -static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){ - codec_setup_info *ci=vi->codec_setup; - if(!ci|| - ci->blocksizes[0]<64|| - ci->blocksizes[1]blocksizes[0]){ - return(OV_EFAULT); - } - - /* preamble */ - oggpack_write(opb,0x01,8); - _v_writestring(opb,"vorbis", 6); - - /* basic information about the stream */ - oggpack_write(opb,0x00,32); - oggpack_write(opb,vi->channels,8); - oggpack_write(opb,vi->rate,32); - - oggpack_write(opb,vi->bitrate_upper,32); - oggpack_write(opb,vi->bitrate_nominal,32); - oggpack_write(opb,vi->bitrate_lower,32); - - oggpack_write(opb,ov_ilog(ci->blocksizes[0]-1),4); - oggpack_write(opb,ov_ilog(ci->blocksizes[1]-1),4); - oggpack_write(opb,1,1); - - return(0); -} - -static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){ - int bytes = strlen(ENCODE_VENDOR_STRING); - - /* preamble */ - oggpack_write(opb,0x03,8); - _v_writestring(opb,"vorbis", 6); - - /* vendor */ - oggpack_write(opb,bytes,32); - _v_writestring(opb,ENCODE_VENDOR_STRING, bytes); - - /* comments */ - - oggpack_write(opb,vc->comments,32); - if(vc->comments){ - int i; - for(i=0;icomments;i++){ - if(vc->user_comments[i]){ - oggpack_write(opb,vc->comment_lengths[i],32); - _v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]); - }else{ - oggpack_write(opb,0,32); - } - } - } - oggpack_write(opb,1,1); - - return(0); -} - -static int _vorbis_pack_books(oggpack_buffer *opb,vorbis_info *vi){ - codec_setup_info *ci=vi->codec_setup; - int i; - if(!ci)return(OV_EFAULT); - - oggpack_write(opb,0x05,8); - _v_writestring(opb,"vorbis", 6); - - /* books */ - oggpack_write(opb,ci->books-1,8); - for(i=0;ibooks;i++) - if(vorbis_staticbook_pack(ci->book_param[i],opb))goto err_out; - - /* times; hook placeholders */ - oggpack_write(opb,0,6); - oggpack_write(opb,0,16); - - /* floors */ - oggpack_write(opb,ci->floors-1,6); - for(i=0;ifloors;i++){ - oggpack_write(opb,ci->floor_type[i],16); - if(_floor_P[ci->floor_type[i]]->pack) - _floor_P[ci->floor_type[i]]->pack(ci->floor_param[i],opb); - else - goto err_out; - } - - /* residues */ - oggpack_write(opb,ci->residues-1,6); - for(i=0;iresidues;i++){ - oggpack_write(opb,ci->residue_type[i],16); - _residue_P[ci->residue_type[i]]->pack(ci->residue_param[i],opb); - } - - /* maps */ - oggpack_write(opb,ci->maps-1,6); - for(i=0;imaps;i++){ - oggpack_write(opb,ci->map_type[i],16); - _mapping_P[ci->map_type[i]]->pack(vi,ci->map_param[i],opb); - } - - /* modes */ - oggpack_write(opb,ci->modes-1,6); - for(i=0;imodes;i++){ - oggpack_write(opb,ci->mode_param[i]->blockflag,1); - oggpack_write(opb,ci->mode_param[i]->windowtype,16); - oggpack_write(opb,ci->mode_param[i]->transformtype,16); - oggpack_write(opb,ci->mode_param[i]->mapping,8); - } - oggpack_write(opb,1,1); - - return(0); -err_out: - return(-1); -} - -int vorbis_commentheader_out(vorbis_comment *vc, - ogg_packet *op){ - - oggpack_buffer opb; - - oggpack_writeinit(&opb); - if(_vorbis_pack_comment(&opb,vc)){ - oggpack_writeclear(&opb); - return OV_EIMPL; - } - - op->packet = _ogg_malloc(oggpack_bytes(&opb)); - memcpy(op->packet, opb.buffer, oggpack_bytes(&opb)); - - op->bytes=oggpack_bytes(&opb); - op->b_o_s=0; - op->e_o_s=0; - op->granulepos=0; - op->packetno=1; - - oggpack_writeclear(&opb); - return 0; -} - -int vorbis_analysis_headerout(vorbis_dsp_state *v, - vorbis_comment *vc, - ogg_packet *op, - ogg_packet *op_comm, - ogg_packet *op_code){ - int ret=OV_EIMPL; - vorbis_info *vi=v->vi; - oggpack_buffer opb; - private_state *b=v->backend_state; - - if(!b||vi->channels<=0||vi->channels>256){ - b = NULL; - ret=OV_EFAULT; - goto err_out; - } - - /* first header packet **********************************************/ - - oggpack_writeinit(&opb); - if(_vorbis_pack_info(&opb,vi))goto err_out; - - /* build the packet */ - if(b->header)_ogg_free(b->header); - b->header=_ogg_malloc(oggpack_bytes(&opb)); - memcpy(b->header,opb.buffer,oggpack_bytes(&opb)); - op->packet=b->header; - op->bytes=oggpack_bytes(&opb); - op->b_o_s=1; - op->e_o_s=0; - op->granulepos=0; - op->packetno=0; - - /* second header packet (comments) **********************************/ - - oggpack_reset(&opb); - if(_vorbis_pack_comment(&opb,vc))goto err_out; - - if(b->header1)_ogg_free(b->header1); - b->header1=_ogg_malloc(oggpack_bytes(&opb)); - memcpy(b->header1,opb.buffer,oggpack_bytes(&opb)); - op_comm->packet=b->header1; - op_comm->bytes=oggpack_bytes(&opb); - op_comm->b_o_s=0; - op_comm->e_o_s=0; - op_comm->granulepos=0; - op_comm->packetno=1; - - /* third header packet (modes/codebooks) ****************************/ - - oggpack_reset(&opb); - if(_vorbis_pack_books(&opb,vi))goto err_out; - - if(b->header2)_ogg_free(b->header2); - b->header2=_ogg_malloc(oggpack_bytes(&opb)); - memcpy(b->header2,opb.buffer,oggpack_bytes(&opb)); - op_code->packet=b->header2; - op_code->bytes=oggpack_bytes(&opb); - op_code->b_o_s=0; - op_code->e_o_s=0; - op_code->granulepos=0; - op_code->packetno=2; - - oggpack_writeclear(&opb); - return(0); - err_out: - memset(op,0,sizeof(*op)); - memset(op_comm,0,sizeof(*op_comm)); - memset(op_code,0,sizeof(*op_code)); - - if(b){ - if(vi->channels>0)oggpack_writeclear(&opb); - if(b->header)_ogg_free(b->header); - if(b->header1)_ogg_free(b->header1); - if(b->header2)_ogg_free(b->header2); - b->header=NULL; - b->header1=NULL; - b->header2=NULL; - } - return(ret); -} - -double vorbis_granule_time(vorbis_dsp_state *v,ogg_int64_t granulepos){ - if(granulepos == -1) return -1; - - /* We're not guaranteed a 64 bit unsigned type everywhere, so we - have to put the unsigned granpo in a signed type. */ - if(granulepos>=0){ - return((double)granulepos/v->vi->rate); - }else{ - ogg_int64_t granuleoff=0xffffffff; - granuleoff<<=31; - granuleoff|=0x7ffffffff; - return(((double)granulepos+2+granuleoff+granuleoff)/v->vi->rate); - } -} - -const char *vorbis_version_string(void){ - return GENERAL_VENDOR_STRING; -} diff --git a/Engine/lib/libvorbis/lib/lookup.c b/Engine/lib/libvorbis/lib/lookup.c deleted file mode 100644 index 7cd01a44d..000000000 --- a/Engine/lib/libvorbis/lib/lookup.c +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: lookup based functions - - ********************************************************************/ - -#include -#include "lookup.h" -#include "lookup_data.h" -#include "os.h" -#include "misc.h" - -#ifdef FLOAT_LOOKUP - -/* interpolated lookup based cos function, domain 0 to PI only */ -float vorbis_coslook(float a){ - double d=a*(.31830989*(float)COS_LOOKUP_SZ); - int i=vorbis_ftoi(d-.5); - - return COS_LOOKUP[i]+ (d-i)*(COS_LOOKUP[i+1]-COS_LOOKUP[i]); -} - -/* interpolated 1./sqrt(p) where .5 <= p < 1. */ -float vorbis_invsqlook(float a){ - double d=a*(2.f*(float)INVSQ_LOOKUP_SZ)-(float)INVSQ_LOOKUP_SZ; - int i=vorbis_ftoi(d-.5f); - return INVSQ_LOOKUP[i]+ (d-i)*(INVSQ_LOOKUP[i+1]-INVSQ_LOOKUP[i]); -} - -/* interpolated 1./sqrt(p) where .5 <= p < 1. */ -float vorbis_invsq2explook(int a){ - return INVSQ2EXP_LOOKUP[a-INVSQ2EXP_LOOKUP_MIN]; -} - -#include -/* interpolated lookup based fromdB function, domain -140dB to 0dB only */ -float vorbis_fromdBlook(float a){ - int i=vorbis_ftoi(a*((float)(-(1<=(FROMdB_LOOKUP_SZ<>FROMdB_SHIFT]*FROMdB2_LOOKUP[i&FROMdB2_MASK]); -} - -#endif - -#ifdef INT_LOOKUP -/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in - 16.16 format - - returns in m.8 format */ -long vorbis_invsqlook_i(long a,long e){ - long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1); - long d=(a&INVSQ_LOOKUP_I_MASK)<<(16-INVSQ_LOOKUP_I_SHIFT); /* 0.16 */ - long val=INVSQ_LOOKUP_I[i]- /* 1.16 */ - (((INVSQ_LOOKUP_I[i]-INVSQ_LOOKUP_I[i+1])* /* 0.16 */ - d)>>16); /* result 1.16 */ - - e+=32; - if(e&1)val=(val*5792)>>13; /* multiply val by 1/sqrt(2) */ - e=(e>>1)-8; - - return(val>>e); -} - -/* interpolated lookup based fromdB function, domain -140dB to 0dB only */ -/* a is in n.12 format */ -float vorbis_fromdBlook_i(long a){ - int i=(-a)>>(12-FROMdB2_SHIFT); - return (i<0)?1.f: - ((i>=(FROMdB_LOOKUP_SZ<>FROMdB_SHIFT]*FROMdB2_LOOKUP[i&FROMdB2_MASK]); -} - -/* interpolated lookup based cos function, domain 0 to PI only */ -/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */ -long vorbis_coslook_i(long a){ - int i=a>>COS_LOOKUP_I_SHIFT; - int d=a&COS_LOOKUP_I_MASK; - return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>> - COS_LOOKUP_I_SHIFT); -} - -#endif diff --git a/Engine/lib/libvorbis/lib/lookup.h b/Engine/lib/libvorbis/lib/lookup.h deleted file mode 100644 index ec05014f4..000000000 --- a/Engine/lib/libvorbis/lib/lookup.h +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: lookup based functions - - ********************************************************************/ - -#ifndef _V_LOOKUP_H_ - -#ifdef FLOAT_LOOKUP -extern float vorbis_coslook(float a); -extern float vorbis_invsqlook(float a); -extern float vorbis_invsq2explook(int a); -extern float vorbis_fromdBlook(float a); -#endif -#ifdef INT_LOOKUP -extern long vorbis_invsqlook_i(long a,long e); -extern long vorbis_coslook_i(long a); -extern float vorbis_fromdBlook_i(long a); -#endif - -#endif diff --git a/Engine/lib/libvorbis/lib/lookup_data.h b/Engine/lib/libvorbis/lib/lookup_data.h deleted file mode 100644 index 7935715a7..000000000 --- a/Engine/lib/libvorbis/lib/lookup_data.h +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: lookup data; generated by lookups.pl; edit there - - ********************************************************************/ - -#ifndef _V_LOOKUP_DATA_H_ - -#ifdef FLOAT_LOOKUP -#define COS_LOOKUP_SZ 128 -static const float COS_LOOKUP[COS_LOOKUP_SZ+1]={ - +1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f, - +0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f, - +0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f, - +0.9569403357322f,+0.9495281805930f,+0.9415440651830f,+0.9329927988347f, - +0.9238795325113f,+0.9142097557035f,+0.9039892931234f,+0.8932243011955f, - +0.8819212643484f,+0.8700869911087f,+0.8577286100003f,+0.8448535652497f, - +0.8314696123025f,+0.8175848131516f,+0.8032075314806f,+0.7883464276266f, - +0.7730104533627f,+0.7572088465065f,+0.7409511253550f,+0.7242470829515f, - +0.7071067811865f,+0.6895405447371f,+0.6715589548470f,+0.6531728429538f, - +0.6343932841636f,+0.6152315905806f,+0.5956993044924f,+0.5758081914178f, - +0.5555702330196f,+0.5349976198871f,+0.5141027441932f,+0.4928981922298f, - +0.4713967368260f,+0.4496113296546f,+0.4275550934303f,+0.4052413140050f, - +0.3826834323651f,+0.3598950365350f,+0.3368898533922f,+0.3136817403989f, - +0.2902846772545f,+0.2667127574749f,+0.2429801799033f,+0.2191012401569f, - +0.1950903220161f,+0.1709618887603f,+0.1467304744554f,+0.1224106751992f, - +0.0980171403296f,+0.0735645635997f,+0.0490676743274f,+0.0245412285229f, - +0.0000000000000f,-0.0245412285229f,-0.0490676743274f,-0.0735645635997f, - -0.0980171403296f,-0.1224106751992f,-0.1467304744554f,-0.1709618887603f, - -0.1950903220161f,-0.2191012401569f,-0.2429801799033f,-0.2667127574749f, - -0.2902846772545f,-0.3136817403989f,-0.3368898533922f,-0.3598950365350f, - -0.3826834323651f,-0.4052413140050f,-0.4275550934303f,-0.4496113296546f, - -0.4713967368260f,-0.4928981922298f,-0.5141027441932f,-0.5349976198871f, - -0.5555702330196f,-0.5758081914178f,-0.5956993044924f,-0.6152315905806f, - -0.6343932841636f,-0.6531728429538f,-0.6715589548470f,-0.6895405447371f, - -0.7071067811865f,-0.7242470829515f,-0.7409511253550f,-0.7572088465065f, - -0.7730104533627f,-0.7883464276266f,-0.8032075314806f,-0.8175848131516f, - -0.8314696123025f,-0.8448535652497f,-0.8577286100003f,-0.8700869911087f, - -0.8819212643484f,-0.8932243011955f,-0.9039892931234f,-0.9142097557035f, - -0.9238795325113f,-0.9329927988347f,-0.9415440651830f,-0.9495281805930f, - -0.9569403357322f,-0.9637760657954f,-0.9700312531945f,-0.9757021300385f, - -0.9807852804032f,-0.9852776423889f,-0.9891765099648f,-0.9924795345987f, - -0.9951847266722f,-0.9972904566787f,-0.9987954562052f,-0.9996988186962f, - -1.0000000000000f, -}; - -#define INVSQ_LOOKUP_SZ 32 -static const float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={ - 1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f, - 1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f, - 1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f, - 1.206045378311f,1.192569588000f,1.179535649239f,1.166919931983f, - 1.154700538379f,1.142857142857f,1.131370849898f,1.120224067222f, - 1.109400392450f,1.098884511590f,1.088662107904f,1.078719779941f, - 1.069044967650f,1.059625885652f,1.050451462878f,1.041511287847f, - 1.032795558989f,1.024295039463f,1.016001016002f,1.007905261358f, - 1.000000000000f, -}; - -#define INVSQ2EXP_LOOKUP_MIN (-32) -#define INVSQ2EXP_LOOKUP_MAX 32 -static const float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\ - INVSQ2EXP_LOOKUP_MIN+1]={ - 65536.f, 46340.95001f, 32768.f, 23170.47501f, - 16384.f, 11585.2375f, 8192.f, 5792.618751f, - 4096.f, 2896.309376f, 2048.f, 1448.154688f, - 1024.f, 724.0773439f, 512.f, 362.038672f, - 256.f, 181.019336f, 128.f, 90.50966799f, - 64.f, 45.254834f, 32.f, 22.627417f, - 16.f, 11.3137085f, 8.f, 5.656854249f, - 4.f, 2.828427125f, 2.f, 1.414213562f, - 1.f, 0.7071067812f, 0.5f, 0.3535533906f, - 0.25f, 0.1767766953f, 0.125f, 0.08838834765f, - 0.0625f, 0.04419417382f, 0.03125f, 0.02209708691f, - 0.015625f, 0.01104854346f, 0.0078125f, 0.005524271728f, - 0.00390625f, 0.002762135864f, 0.001953125f, 0.001381067932f, - 0.0009765625f, 0.000690533966f, 0.00048828125f, 0.000345266983f, - 0.000244140625f,0.0001726334915f,0.0001220703125f,8.631674575e-05f, - 6.103515625e-05f,4.315837288e-05f,3.051757812e-05f,2.157918644e-05f, - 1.525878906e-05f, -}; - -#endif - -#define FROMdB_LOOKUP_SZ 35 -#define FROMdB2_LOOKUP_SZ 32 -#define FROMdB_SHIFT 5 -#define FROMdB2_SHIFT 3 -#define FROMdB2_MASK 31 - -#ifdef FLOAT_LOOKUP -static const float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={ - 1.f, 0.6309573445f, 0.3981071706f, 0.2511886432f, - 0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f, - 0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f, - 0.003981071706f, 0.002511886432f, 0.001584893192f, 0.001f, - 0.0006309573445f,0.0003981071706f,0.0002511886432f,0.0001584893192f, - 0.0001f,6.309573445e-05f,3.981071706e-05f,2.511886432e-05f, - 1.584893192e-05f, 1e-05f,6.309573445e-06f,3.981071706e-06f, - 2.511886432e-06f,1.584893192e-06f, 1e-06f,6.309573445e-07f, - 3.981071706e-07f,2.511886432e-07f,1.584893192e-07f, -}; - -static const float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={ - 0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f, - 0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f, - 0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f, - 0.835362547f, 0.8234268041f, 0.8116616003f, 0.8000644989f, - 0.7886330981f, 0.7773650302f, 0.7662579617f, 0.755309592f, - 0.7445176537f, 0.7338799116f, 0.7233941627f, 0.7130582353f, - 0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f, - 0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f, -}; -#endif - -#ifdef INT_LOOKUP - -#define INVSQ_LOOKUP_I_SHIFT 10 -#define INVSQ_LOOKUP_I_MASK 1023 -static const long INVSQ_LOOKUP_I[64+1]={ - 92682l, 91966l, 91267l, 90583l, - 89915l, 89261l, 88621l, 87995l, - 87381l, 86781l, 86192l, 85616l, - 85051l, 84497l, 83953l, 83420l, - 82897l, 82384l, 81880l, 81385l, - 80899l, 80422l, 79953l, 79492l, - 79039l, 78594l, 78156l, 77726l, - 77302l, 76885l, 76475l, 76072l, - 75674l, 75283l, 74898l, 74519l, - 74146l, 73778l, 73415l, 73058l, - 72706l, 72359l, 72016l, 71679l, - 71347l, 71019l, 70695l, 70376l, - 70061l, 69750l, 69444l, 69141l, - 68842l, 68548l, 68256l, 67969l, - 67685l, 67405l, 67128l, 66855l, - 66585l, 66318l, 66054l, 65794l, - 65536l, -}; - -#define COS_LOOKUP_I_SHIFT 9 -#define COS_LOOKUP_I_MASK 511 -#define COS_LOOKUP_I_SZ 128 -static const long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={ - 16384l, 16379l, 16364l, 16340l, - 16305l, 16261l, 16207l, 16143l, - 16069l, 15986l, 15893l, 15791l, - 15679l, 15557l, 15426l, 15286l, - 15137l, 14978l, 14811l, 14635l, - 14449l, 14256l, 14053l, 13842l, - 13623l, 13395l, 13160l, 12916l, - 12665l, 12406l, 12140l, 11866l, - 11585l, 11297l, 11003l, 10702l, - 10394l, 10080l, 9760l, 9434l, - 9102l, 8765l, 8423l, 8076l, - 7723l, 7366l, 7005l, 6639l, - 6270l, 5897l, 5520l, 5139l, - 4756l, 4370l, 3981l, 3590l, - 3196l, 2801l, 2404l, 2006l, - 1606l, 1205l, 804l, 402l, - 0l, -401l, -803l, -1204l, - -1605l, -2005l, -2403l, -2800l, - -3195l, -3589l, -3980l, -4369l, - -4755l, -5138l, -5519l, -5896l, - -6269l, -6638l, -7004l, -7365l, - -7722l, -8075l, -8422l, -8764l, - -9101l, -9433l, -9759l, -10079l, - -10393l, -10701l, -11002l, -11296l, - -11584l, -11865l, -12139l, -12405l, - -12664l, -12915l, -13159l, -13394l, - -13622l, -13841l, -14052l, -14255l, - -14448l, -14634l, -14810l, -14977l, - -15136l, -15285l, -15425l, -15556l, - -15678l, -15790l, -15892l, -15985l, - -16068l, -16142l, -16206l, -16260l, - -16304l, -16339l, -16363l, -16378l, - -16383l, -}; - -#endif - -#endif diff --git a/Engine/lib/libvorbis/lib/lookups.pl b/Engine/lib/libvorbis/lib/lookups.pl deleted file mode 100644 index 87e2cad81..000000000 --- a/Engine/lib/libvorbis/lib/lookups.pl +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/perl -print <<'EOD'; -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: lookup data; generated by lookups.pl; edit there - - ********************************************************************/ - -#ifndef _V_LOOKUP_DATA_H_ - -#ifdef FLOAT_LOOKUP -EOD - -$cos_sz=128; -$invsq_sz=32; -$invsq2exp_min=-32; -$invsq2exp_max=32; - -$fromdB_sz=35; -$fromdB_shift=5; -$fromdB2_shift=3; - -$invsq_i_shift=10; -$cos_i_shift=9; -$delta_shift=6; - -print "#define COS_LOOKUP_SZ $cos_sz\n"; -print "static float COS_LOOKUP[COS_LOOKUP_SZ+1]={\n"; - -for($i=0;$i<=$cos_sz;){ - print "\t"; - for($j=0;$j<4 && $i<=$cos_sz;$j++){ - printf "%+.13f,", cos(3.14159265358979323846*($i++)/$cos_sz) ; - } - print "\n"; -} -print "};\n\n"; - -print "#define INVSQ_LOOKUP_SZ $invsq_sz\n"; -print "static float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={\n"; - -for($i=0;$i<=$invsq_sz;){ - print "\t"; - for($j=0;$j<4 && $i<=$invsq_sz;$j++){ - my$indexmap=$i++/$invsq_sz*.5+.5; - printf "%.12f,", 1./sqrt($indexmap); - } - print "\n"; -} -print "};\n\n"; - -print "#define INVSQ2EXP_LOOKUP_MIN $invsq2exp_min\n"; -print "#define INVSQ2EXP_LOOKUP_MAX $invsq2exp_max\n"; -print "static float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\\\n". - " INVSQ2EXP_LOOKUP_MIN+1]={\n"; - -for($i=$invsq2exp_min;$i<=$invsq2exp_max;){ - print "\t"; - for($j=0;$j<4 && $i<=$invsq2exp_max;$j++){ - printf "%15.10g,", 2**($i++*-.5); - } - print "\n"; -} -print "};\n\n#endif\n\n"; - - -# 0 to -140 dB -$fromdB2_sz=1<<$fromdB_shift; -$fromdB_gran=1<<($fromdB_shift-$fromdB2_shift); -print "#define FROMdB_LOOKUP_SZ $fromdB_sz\n"; -print "#define FROMdB2_LOOKUP_SZ $fromdB2_sz\n"; -print "#define FROMdB_SHIFT $fromdB_shift\n"; -print "#define FROMdB2_SHIFT $fromdB2_shift\n"; -print "#define FROMdB2_MASK ".((1<<$fromdB_shift)-1)."\n"; - -print "static float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={\n"; - -for($i=0;$i<$fromdB_sz;){ - print "\t"; - for($j=0;$j<4 && $i<$fromdB_sz;$j++){ - printf "%15.10g,", 10**(.05*(-$fromdB_gran*$i++)); - } - print "\n"; -} -print "};\n\n"; - -print "static float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={\n"; - -for($i=0;$i<$fromdB2_sz;){ - print "\t"; - for($j=0;$j<4 && $i<$fromdB_sz;$j++){ - printf "%15.10g,", 10**(.05*(-$fromdB_gran/$fromdB2_sz*(.5+$i++))); - } - print "\n"; -} -print "};\n\n#ifdef INT_LOOKUP\n\n"; - - -$iisz=0x10000>>$invsq_i_shift; -print "#define INVSQ_LOOKUP_I_SHIFT $invsq_i_shift\n"; -print "#define INVSQ_LOOKUP_I_MASK ".(0x0ffff>>(16-$invsq_i_shift))."\n"; -print "static long INVSQ_LOOKUP_I[$iisz+1]={\n"; -for($i=0;$i<=$iisz;){ - print "\t"; - for($j=0;$j<4 && $i<=$iisz;$j++){ - my$indexmap=$i++/$iisz*.5+.5; - printf "%8d,", int(1./sqrt($indexmap)*65536.+.5); - } - print "\n"; -} -print "};\n\n"; - -$cisz=0x10000>>$cos_i_shift; -print "#define COS_LOOKUP_I_SHIFT $cos_i_shift\n"; -print "#define COS_LOOKUP_I_MASK ".(0x0ffff>>(16-$cos_i_shift))."\n"; -print "#define COS_LOOKUP_I_SZ $cisz\n"; -print "static long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={\n"; - -for($i=0;$i<=$cisz;){ - print "\t"; - for($j=0;$j<4 && $i<=$cisz;$j++){ - printf "%8d,", int(cos(3.14159265358979323846*($i++)/$cos_sz)*16384.+.5) ; - } - print "\n"; -} -print "};\n\n"; - - -print "#endif\n\n#endif\n"; - - diff --git a/Engine/lib/libvorbis/lib/lpc.c b/Engine/lib/libvorbis/lib/lpc.c deleted file mode 100644 index 877da47f8..000000000 --- a/Engine/lib/libvorbis/lib/lpc.c +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: LPC low level routines - - ********************************************************************/ - -/* Some of these routines (autocorrelator, LPC coefficient estimator) - are derived from code written by Jutta Degener and Carsten Bormann; - thus we include their copyright below. The entirety of this file - is freely redistributable on the condition that both of these - copyright notices are preserved without modification. */ - -/* Preserved Copyright: *********************************************/ - -/* Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, -Technische Universita"t Berlin - -Any use of this software is permitted provided that this notice is not -removed and that neither the authors nor the Technische Universita"t -Berlin are deemed to have made any representations as to the -suitability of this software for any purpose nor are held responsible -for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR -THIS SOFTWARE. - -As a matter of courtesy, the authors request to be informed about uses -this software has found, about bugs in this software, and about any -improvements that may be of general interest. - -Berlin, 28.11.1994 -Jutta Degener -Carsten Bormann - -*********************************************************************/ - -#include -#include -#include -#include "os.h" -#include "smallft.h" -#include "lpc.h" -#include "scales.h" -#include "misc.h" - -/* Autocorrelation LPC coeff generation algorithm invented by - N. Levinson in 1947, modified by J. Durbin in 1959. */ - -/* Input : n elements of time doamin data - Output: m lpc coefficients, excitation energy */ - -float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){ - double *aut=alloca(sizeof(*aut)*(m+1)); - double *lpc=alloca(sizeof(*lpc)*(m)); - double error; - double epsilon; - int i,j; - - /* autocorrelation, p+1 lag coefficients */ - j=m+1; - while(j--){ - double d=0; /* double needed for accumulator depth */ - for(i=j;i -#include -#include -#include "lsp.h" -#include "os.h" -#include "misc.h" -#include "lookup.h" -#include "scales.h" - -/* three possible LSP to f curve functions; the exact computation - (float), a lookup based float implementation, and an integer - implementation. The float lookup is likely the optimal choice on - any machine with an FPU. The integer implementation is *not* fixed - point (due to the need for a large dynamic range and thus a - separately tracked exponent) and thus much more complex than the - relatively simple float implementations. It's mostly for future - work on a fully fixed point implementation for processors like the - ARM family. */ - -/* define either of these (preferably FLOAT_LOOKUP) to have faster - but less precise implementation. */ -#undef FLOAT_LOOKUP -#undef INT_LOOKUP - -#ifdef FLOAT_LOOKUP -#include "lookup.c" /* catch this in the build system; we #include for - compilers (like gcc) that can't inline across - modules */ - -/* side effect: changes *lsp to cosines of lsp */ -void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, - float amp,float ampoffset){ - int i; - float wdel=M_PI/ln; - vorbis_fpu_control fpu; - - vorbis_fpu_setround(&fpu); - for(i=0;i>1; - - while(c--){ - q*=ftmp[0]-w; - p*=ftmp[1]-w; - ftmp+=2; - } - - if(m&1){ - /* odd order filter; slightly assymetric */ - /* the last coefficient */ - q*=ftmp[0]-w; - q*=q; - p*=p*(1.f-w*w); - }else{ - /* even order filter; still symmetric */ - q*=q*(1.f+w); - p*=p*(1.f-w); - } - - q=frexp(p+q,&qexp); - q=vorbis_fromdBlook(amp* - vorbis_invsqlook(q)* - vorbis_invsq2explook(qexp+m)- - ampoffset); - - do{ - curve[i++]*=q; - }while(map[i]==k); - } - vorbis_fpu_restore(fpu); -} - -#else - -#ifdef INT_LOOKUP -#include "lookup.c" /* catch this in the build system; we #include for - compilers (like gcc) that can't inline across - modules */ - -static const int MLOOP_1[64]={ - 0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13, - 14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, -}; - -static const int MLOOP_2[64]={ - 0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7, - 8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8, - 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, - 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, -}; - -static const int MLOOP_3[8]={0,1,2,2,3,3,3,3}; - - -/* side effect: changes *lsp to cosines of lsp */ -void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, - float amp,float ampoffset){ - - /* 0 <= m < 256 */ - - /* set up for using all int later */ - int i; - int ampoffseti=rint(ampoffset*4096.f); - int ampi=rint(amp*16.f); - long *ilsp=alloca(m*sizeof(*ilsp)); - for(i=0;i>25])) - if(!(shift=MLOOP_2[(pi|qi)>>19])) - shift=MLOOP_3[(pi|qi)>>16]; - qi=(qi>>shift)*labs(ilsp[j-1]-wi); - pi=(pi>>shift)*labs(ilsp[j]-wi); - qexp+=shift; - } - if(!(shift=MLOOP_1[(pi|qi)>>25])) - if(!(shift=MLOOP_2[(pi|qi)>>19])) - shift=MLOOP_3[(pi|qi)>>16]; - - /* pi,qi normalized collectively, both tracked using qexp */ - - if(m&1){ - /* odd order filter; slightly assymetric */ - /* the last coefficient */ - qi=(qi>>shift)*labs(ilsp[j-1]-wi); - pi=(pi>>shift)<<14; - qexp+=shift; - - if(!(shift=MLOOP_1[(pi|qi)>>25])) - if(!(shift=MLOOP_2[(pi|qi)>>19])) - shift=MLOOP_3[(pi|qi)>>16]; - - pi>>=shift; - qi>>=shift; - qexp+=shift-14*((m+1)>>1); - - pi=((pi*pi)>>16); - qi=((qi*qi)>>16); - qexp=qexp*2+m; - - pi*=(1<<14)-((wi*wi)>>14); - qi+=pi>>14; - - }else{ - /* even order filter; still symmetric */ - - /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't - worth tracking step by step */ - - pi>>=shift; - qi>>=shift; - qexp+=shift-7*m; - - pi=((pi*pi)>>16); - qi=((qi*qi)>>16); - qexp=qexp*2+m; - - pi*=(1<<14)-wi; - qi*=(1<<14)+wi; - qi=(qi+pi)>>14; - - } - - - /* we've let the normalization drift because it wasn't important; - however, for the lookup, things must be normalized again. We - need at most one right shift or a number of left shifts */ - - if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */ - qi>>=1; qexp++; - }else - while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ - qi<<=1; qexp--; - } - - amp=vorbis_fromdBlook_i(ampi* /* n.4 */ - vorbis_invsqlook_i(qi,qexp)- - /* m.8, m+n<=8 */ - ampoffseti); /* 8.12[0] */ - - curve[i]*=amp; - while(map[++i]==k)curve[i]*=amp; - } -} - -#else - -/* old, nonoptimized but simple version for any poor sap who needs to - figure out what the hell this code does, or wants the other - fraction of a dB precision */ - -/* side effect: changes *lsp to cosines of lsp */ -void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, - float amp,float ampoffset){ - int i; - float wdel=M_PI/ln; - for(i=0;i= i; j--) { - g[j-2] -= g[j]; - g[j] += g[j]; - } - } -} - -static int comp(const void *a,const void *b){ - return (*(float *)a<*(float *)b)-(*(float *)a>*(float *)b); -} - -/* Newton-Raphson-Maehly actually functioned as a decent root finder, - but there are root sets for which it gets into limit cycles - (exacerbated by zero suppression) and fails. We can't afford to - fail, even if the failure is 1 in 100,000,000, so we now use - Laguerre and later polish with Newton-Raphson (which can then - afford to fail) */ - -#define EPSILON 10e-7 -static int Laguerre_With_Deflation(float *a,int ord,float *r){ - int i,m; - double *defl=alloca(sizeof(*defl)*(ord+1)); - for(i=0;i<=ord;i++)defl[i]=a[i]; - - for(m=ord;m>0;m--){ - double new=0.f,delta; - - /* iterate a root */ - while(1){ - double p=defl[m],pp=0.f,ppp=0.f,denom; - - /* eval the polynomial and its first two derivatives */ - for(i=m;i>0;i--){ - ppp = new*ppp + pp; - pp = new*pp + p; - p = new*p + defl[i-1]; - } - - /* Laguerre's method */ - denom=(m-1) * ((m-1)*pp*pp - m*p*ppp); - if(denom<0) - return(-1); /* complex root! The LPC generator handed us a bad filter */ - - if(pp>0){ - denom = pp + sqrt(denom); - if(denom-(EPSILON))denom=-(EPSILON); - } - - delta = m*p/denom; - new -= delta; - - if(delta<0.f)delta*=-1; - - if(fabs(delta/new)<10e-12)break; - } - - r[m-1]=new; - - /* forward deflation */ - - for(i=m;i>0;i--) - defl[i-1]+=new*defl[i]; - defl++; - - } - return(0); -} - - -/* for spit-and-polish only */ -static int Newton_Raphson(float *a,int ord,float *r){ - int i, k, count=0; - double error=1.f; - double *root=alloca(ord*sizeof(*root)); - - for(i=0; i1e-20){ - error=0; - - for(i=0; i= 0; k--) { - - pp= pp* rooti + p; - p = p * rooti + a[k]; - } - - delta = p/pp; - root[i] -= delta; - error+= delta*delta; - } - - if(count>40)return(-1); - - count++; - } - - /* Replaced the original bubble sort with a real sort. With your - help, we can eliminate the bubble sort in our lifetime. --Monty */ - - for(i=0; i>1; - int g1_order,g2_order; - float *g1=alloca(sizeof(*g1)*(order2+1)); - float *g2=alloca(sizeof(*g2)*(order2+1)); - float *g1r=alloca(sizeof(*g1r)*(order2+1)); - float *g2r=alloca(sizeof(*g2r)*(order2+1)); - int i; - - /* even and odd are slightly different base cases */ - g1_order=(m+1)>>1; - g2_order=(m) >>1; - - /* Compute the lengths of the x polynomials. */ - /* Compute the first half of K & R F1 & F2 polynomials. */ - /* Compute half of the symmetric and antisymmetric polynomials. */ - /* Remove the roots at +1 and -1. */ - - g1[g1_order] = 1.f; - for(i=1;i<=g1_order;i++) g1[g1_order-i] = lpc[i-1]+lpc[m-i]; - g2[g2_order] = 1.f; - for(i=1;i<=g2_order;i++) g2[g2_order-i] = lpc[i-1]-lpc[m-i]; - - if(g1_order>g2_order){ - for(i=2; i<=g2_order;i++) g2[g2_order-i] += g2[g2_order-i+2]; - }else{ - for(i=1; i<=g1_order;i++) g1[g1_order-i] -= g1[g1_order-i+1]; - for(i=1; i<=g2_order;i++) g2[g2_order-i] += g2[g2_order-i+1]; - } - - /* Convert into polynomials in cos(alpha) */ - cheby(g1,g1_order); - cheby(g2,g2_order); - - /* Find the roots of the 2 even polynomials.*/ - if(Laguerre_With_Deflation(g1,g1_order,g1r) || - Laguerre_With_Deflation(g2,g2_order,g2r)) - return(-1); - - Newton_Raphson(g1,g1_order,g1r); /* if it fails, it leaves g1r alone */ - Newton_Raphson(g2,g2_order,g2r); /* if it fails, it leaves g2r alone */ - - qsort(g1r,g1_order,sizeof(*g1r),comp); - qsort(g2r,g2_order,sizeof(*g2r),comp); - - for(i=0;i -#include -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "codebook.h" -#include "window.h" -#include "registry.h" -#include "psy.h" -#include "misc.h" - -/* simplistic, wasteful way of doing this (unique lookup for each - mode/submapping); there should be a central repository for - identical lookups. That will require minor work, so I'm putting it - off as low priority. - - Why a lookup for each backend in a given mode? Because the - blocksize is set by the mode, and low backend lookups may require - parameters from other areas of the mode/mapping */ - -static void mapping0_free_info(vorbis_info_mapping *i){ - vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i; - if(info){ - memset(info,0,sizeof(*info)); - _ogg_free(info); - } -} - -static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm, - oggpack_buffer *opb){ - int i; - vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm; - - /* another 'we meant to do it this way' hack... up to beta 4, we - packed 4 binary zeros here to signify one submapping in use. We - now redefine that to mean four bitflags that indicate use of - deeper features; bit0:submappings, bit1:coupling, - bit2,3:reserved. This is backward compatable with all actual uses - of the beta code. */ - - if(info->submaps>1){ - oggpack_write(opb,1,1); - oggpack_write(opb,info->submaps-1,4); - }else - oggpack_write(opb,0,1); - - if(info->coupling_steps>0){ - oggpack_write(opb,1,1); - oggpack_write(opb,info->coupling_steps-1,8); - - for(i=0;icoupling_steps;i++){ - oggpack_write(opb,info->coupling_mag[i],ov_ilog(vi->channels-1)); - oggpack_write(opb,info->coupling_ang[i],ov_ilog(vi->channels-1)); - } - }else - oggpack_write(opb,0,1); - - oggpack_write(opb,0,2); /* 2,3:reserved */ - - /* we don't write the channel submappings if we only have one... */ - if(info->submaps>1){ - for(i=0;ichannels;i++) - oggpack_write(opb,info->chmuxlist[i],4); - } - for(i=0;isubmaps;i++){ - oggpack_write(opb,0,8); /* time submap unused */ - oggpack_write(opb,info->floorsubmap[i],8); - oggpack_write(opb,info->residuesubmap[i],8); - } -} - -/* also responsible for range checking */ -static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){ - int i,b; - vorbis_info_mapping0 *info=_ogg_calloc(1,sizeof(*info)); - codec_setup_info *ci=vi->codec_setup; - if(vi->channels<=0)goto err_out; - - b=oggpack_read(opb,1); - if(b<0)goto err_out; - if(b){ - info->submaps=oggpack_read(opb,4)+1; - if(info->submaps<=0)goto err_out; - }else - info->submaps=1; - - b=oggpack_read(opb,1); - if(b<0)goto err_out; - if(b){ - info->coupling_steps=oggpack_read(opb,8)+1; - if(info->coupling_steps<=0)goto err_out; - for(i=0;icoupling_steps;i++){ - /* vi->channels > 0 is enforced in the caller */ - int testM=info->coupling_mag[i]= - oggpack_read(opb,ov_ilog(vi->channels-1)); - int testA=info->coupling_ang[i]= - oggpack_read(opb,ov_ilog(vi->channels-1)); - - if(testM<0 || - testA<0 || - testM==testA || - testM>=vi->channels || - testA>=vi->channels) goto err_out; - } - - } - - if(oggpack_read(opb,2)!=0)goto err_out; /* 2,3:reserved */ - - if(info->submaps>1){ - for(i=0;ichannels;i++){ - info->chmuxlist[i]=oggpack_read(opb,4); - if(info->chmuxlist[i]>=info->submaps || info->chmuxlist[i]<0)goto err_out; - } - } - for(i=0;isubmaps;i++){ - oggpack_read(opb,8); /* time submap unused */ - info->floorsubmap[i]=oggpack_read(opb,8); - if(info->floorsubmap[i]>=ci->floors || info->floorsubmap[i]<0)goto err_out; - info->residuesubmap[i]=oggpack_read(opb,8); - if(info->residuesubmap[i]>=ci->residues || info->residuesubmap[i]<0)goto err_out; - } - - return info; - - err_out: - mapping0_free_info(info); - return(NULL); -} - -#include "os.h" -#include "lpc.h" -#include "lsp.h" -#include "envelope.h" -#include "mdct.h" -#include "psy.h" -#include "scales.h" - -#if 0 -static long seq=0; -static ogg_int64_t total=0; -static float FLOOR1_fromdB_LOOKUP[256]={ - 1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F, - 1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F, - 1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F, - 2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F, - 2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F, - 3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F, - 4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F, - 6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F, - 7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F, - 1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F, - 1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F, - 1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F, - 2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F, - 2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F, - 3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F, - 4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F, - 5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F, - 7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F, - 9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F, - 1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F, - 1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F, - 2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F, - 2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F, - 3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F, - 4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F, - 5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F, - 7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F, - 9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F, - 0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F, - 0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F, - 0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F, - 0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F, - 0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F, - 0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F, - 0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F, - 0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F, - 0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F, - 0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F, - 0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F, - 0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F, - 0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F, - 0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F, - 0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F, - 0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F, - 0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F, - 0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F, - 0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F, - 0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F, - 0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F, - 0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F, - 0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F, - 0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F, - 0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F, - 0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F, - 0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F, - 0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F, - 0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F, - 0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F, - 0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F, - 0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F, - 0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F, - 0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F, - 0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F, - 0.82788260F, 0.88168307F, 0.9389798F, 1.F, -}; - -#endif - - -static int mapping0_forward(vorbis_block *vb){ - vorbis_dsp_state *vd=vb->vd; - vorbis_info *vi=vd->vi; - codec_setup_info *ci=vi->codec_setup; - private_state *b=vb->vd->backend_state; - vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal; - int n=vb->pcmend; - int i,j,k; - - int *nonzero = alloca(sizeof(*nonzero)*vi->channels); - float **gmdct = _vorbis_block_alloc(vb,vi->channels*sizeof(*gmdct)); - int **iwork = _vorbis_block_alloc(vb,vi->channels*sizeof(*iwork)); - int ***floor_posts = _vorbis_block_alloc(vb,vi->channels*sizeof(*floor_posts)); - - float global_ampmax=vbi->ampmax; - float *local_ampmax=alloca(sizeof(*local_ampmax)*vi->channels); - int blocktype=vbi->blocktype; - - int modenumber=vb->W; - vorbis_info_mapping0 *info=ci->map_param[modenumber]; - vorbis_look_psy *psy_look=b->psy+blocktype+(vb->W?2:0); - - vb->mode=modenumber; - - for(i=0;ichannels;i++){ - float scale=4.f/n; - float scale_dB; - - float *pcm =vb->pcm[i]; - float *logfft =pcm; - - iwork[i]=_vorbis_block_alloc(vb,n/2*sizeof(**iwork)); - gmdct[i]=_vorbis_block_alloc(vb,n/2*sizeof(**gmdct)); - - scale_dB=todB(&scale) + .345; /* + .345 is a hack; the original - todB estimation used on IEEE 754 - compliant machines had a bug that - returned dB values about a third - of a decibel too high. The bug - was harmless because tunings - implicitly took that into - account. However, fixing the bug - in the estimator requires - changing all the tunings as well. - For now, it's easier to sync - things back up here, and - recalibrate the tunings in the - next major model upgrade. */ - -#if 0 - if(vi->channels==2){ - if(i==0) - _analysis_output("pcmL",seq,pcm,n,0,0,total-n/2); - else - _analysis_output("pcmR",seq,pcm,n,0,0,total-n/2); - }else{ - _analysis_output("pcm",seq,pcm,n,0,0,total-n/2); - } -#endif - - /* window the PCM data */ - _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW); - -#if 0 - if(vi->channels==2){ - if(i==0) - _analysis_output("windowedL",seq,pcm,n,0,0,total-n/2); - else - _analysis_output("windowedR",seq,pcm,n,0,0,total-n/2); - }else{ - _analysis_output("windowed",seq,pcm,n,0,0,total-n/2); - } -#endif - - /* transform the PCM data */ - /* only MDCT right now.... */ - mdct_forward(b->transform[vb->W][0],pcm,gmdct[i]); - - /* FFT yields more accurate tonal estimation (not phase sensitive) */ - drft_forward(&b->fft_look[vb->W],pcm); - logfft[0]=scale_dB+todB(pcm) + .345; /* + .345 is a hack; the - original todB estimation used on - IEEE 754 compliant machines had a - bug that returned dB values about - a third of a decibel too high. - The bug was harmless because - tunings implicitly took that into - account. However, fixing the bug - in the estimator requires - changing all the tunings as well. - For now, it's easier to sync - things back up here, and - recalibrate the tunings in the - next major model upgrade. */ - local_ampmax[i]=logfft[0]; - for(j=1;j>1]=scale_dB+.5f*todB(&temp) + .345; /* + - .345 is a hack; the original todB - estimation used on IEEE 754 - compliant machines had a bug that - returned dB values about a third - of a decibel too high. The bug - was harmless because tunings - implicitly took that into - account. However, fixing the bug - in the estimator requires - changing all the tunings as well. - For now, it's easier to sync - things back up here, and - recalibrate the tunings in the - next major model upgrade. */ - if(temp>local_ampmax[i])local_ampmax[i]=temp; - } - - if(local_ampmax[i]>0.f)local_ampmax[i]=0.f; - if(local_ampmax[i]>global_ampmax)global_ampmax=local_ampmax[i]; - -#if 0 - if(vi->channels==2){ - if(i==0){ - _analysis_output("fftL",seq,logfft,n/2,1,0,0); - }else{ - _analysis_output("fftR",seq,logfft,n/2,1,0,0); - } - }else{ - _analysis_output("fft",seq,logfft,n/2,1,0,0); - } -#endif - - } - - { - float *noise = _vorbis_block_alloc(vb,n/2*sizeof(*noise)); - float *tone = _vorbis_block_alloc(vb,n/2*sizeof(*tone)); - - for(i=0;ichannels;i++){ - /* the encoder setup assumes that all the modes used by any - specific bitrate tweaking use the same floor */ - - int submap=info->chmuxlist[i]; - - /* the following makes things clearer to *me* anyway */ - float *mdct =gmdct[i]; - float *logfft =vb->pcm[i]; - - float *logmdct =logfft+n/2; - float *logmask =logfft; - - vb->mode=modenumber; - - floor_posts[i]=_vorbis_block_alloc(vb,PACKETBLOBS*sizeof(**floor_posts)); - memset(floor_posts[i],0,sizeof(**floor_posts)*PACKETBLOBS); - - for(j=0;jchannels==2){ - if(i==0) - _analysis_output("mdctL",seq,logmdct,n/2,1,0,0); - else - _analysis_output("mdctR",seq,logmdct,n/2,1,0,0); - }else{ - _analysis_output("mdct",seq,logmdct,n/2,1,0,0); - } -#endif - - /* first step; noise masking. Not only does 'noise masking' - give us curves from which we can decide how much resolution - to give noise parts of the spectrum, it also implicitly hands - us a tonality estimate (the larger the value in the - 'noise_depth' vector, the more tonal that area is) */ - - _vp_noisemask(psy_look, - logmdct, - noise); /* noise does not have by-frequency offset - bias applied yet */ -#if 0 - if(vi->channels==2){ - if(i==0) - _analysis_output("noiseL",seq,noise,n/2,1,0,0); - else - _analysis_output("noiseR",seq,noise,n/2,1,0,0); - }else{ - _analysis_output("noise",seq,noise,n/2,1,0,0); - } -#endif - - /* second step: 'all the other crap'; all the stuff that isn't - computed/fit for bitrate management goes in the second psy - vector. This includes tone masking, peak limiting and ATH */ - - _vp_tonemask(psy_look, - logfft, - tone, - global_ampmax, - local_ampmax[i]); - -#if 0 - if(vi->channels==2){ - if(i==0) - _analysis_output("toneL",seq,tone,n/2,1,0,0); - else - _analysis_output("toneR",seq,tone,n/2,1,0,0); - }else{ - _analysis_output("tone",seq,tone,n/2,1,0,0); - } -#endif - - /* third step; we offset the noise vectors, overlay tone - masking. We then do a floor1-specific line fit. If we're - performing bitrate management, the line fit is performed - multiple times for up/down tweakage on demand. */ - -#if 0 - { - float aotuv[psy_look->n]; -#endif - - _vp_offset_and_mix(psy_look, - noise, - tone, - 1, - logmask, - mdct, - logmdct); - -#if 0 - if(vi->channels==2){ - if(i==0) - _analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0); - else - _analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0); - }else{ - _analysis_output("aotuvM1",seq,aotuv,psy_look->n,1,1,0); - } - } -#endif - - -#if 0 - if(vi->channels==2){ - if(i==0) - _analysis_output("mask1L",seq,logmask,n/2,1,0,0); - else - _analysis_output("mask1R",seq,logmask,n/2,1,0,0); - }else{ - _analysis_output("mask1",seq,logmask,n/2,1,0,0); - } -#endif - - /* this algorithm is hardwired to floor 1 for now; abort out if - we're *not* floor1. This won't happen unless someone has - broken the encode setup lib. Guard it anyway. */ - if(ci->floor_type[info->floorsubmap[submap]]!=1)return(-1); - - floor_posts[i][PACKETBLOBS/2]= - floor1_fit(vb,b->flr[info->floorsubmap[submap]], - logmdct, - logmask); - - /* are we managing bitrate? If so, perform two more fits for - later rate tweaking (fits represent hi/lo) */ - if(vorbis_bitrate_managed(vb) && floor_posts[i][PACKETBLOBS/2]){ - /* higher rate by way of lower noise curve */ - - _vp_offset_and_mix(psy_look, - noise, - tone, - 2, - logmask, - mdct, - logmdct); - -#if 0 - if(vi->channels==2){ - if(i==0) - _analysis_output("mask2L",seq,logmask,n/2,1,0,0); - else - _analysis_output("mask2R",seq,logmask,n/2,1,0,0); - }else{ - _analysis_output("mask2",seq,logmask,n/2,1,0,0); - } -#endif - - floor_posts[i][PACKETBLOBS-1]= - floor1_fit(vb,b->flr[info->floorsubmap[submap]], - logmdct, - logmask); - - /* lower rate by way of higher noise curve */ - _vp_offset_and_mix(psy_look, - noise, - tone, - 0, - logmask, - mdct, - logmdct); - -#if 0 - if(vi->channels==2){ - if(i==0) - _analysis_output("mask0L",seq,logmask,n/2,1,0,0); - else - _analysis_output("mask0R",seq,logmask,n/2,1,0,0); - }else{ - _analysis_output("mask0",seq,logmask,n/2,1,0,0); - } -#endif - - floor_posts[i][0]= - floor1_fit(vb,b->flr[info->floorsubmap[submap]], - logmdct, - logmask); - - /* we also interpolate a range of intermediate curves for - intermediate rates */ - for(k=1;kflr[info->floorsubmap[submap]], - floor_posts[i][0], - floor_posts[i][PACKETBLOBS/2], - k*65536/(PACKETBLOBS/2)); - for(k=PACKETBLOBS/2+1;kflr[info->floorsubmap[submap]], - floor_posts[i][PACKETBLOBS/2], - floor_posts[i][PACKETBLOBS-1], - (k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2)); - } - } - } - vbi->ampmax=global_ampmax; - - /* - the next phases are performed once for vbr-only and PACKETBLOB - times for bitrate managed modes. - - 1) encode actual mode being used - 2) encode the floor for each channel, compute coded mask curve/res - 3) normalize and couple. - 4) encode residue - 5) save packet bytes to the packetblob vector - - */ - - /* iterate over the many masking curve fits we've created */ - - { - int **couple_bundle=alloca(sizeof(*couple_bundle)*vi->channels); - int *zerobundle=alloca(sizeof(*zerobundle)*vi->channels); - - for(k=(vorbis_bitrate_managed(vb)?0:PACKETBLOBS/2); - k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2); - k++){ - oggpack_buffer *opb=vbi->packetblob[k]; - - /* start out our new packet blob with packet type and mode */ - /* Encode the packet type */ - oggpack_write(opb,0,1); - /* Encode the modenumber */ - /* Encode frame mode, pre,post windowsize, then dispatch */ - oggpack_write(opb,modenumber,b->modebits); - if(vb->W){ - oggpack_write(opb,vb->lW,1); - oggpack_write(opb,vb->nW,1); - } - - /* encode floor, compute masking curve, sep out residue */ - for(i=0;ichannels;i++){ - int submap=info->chmuxlist[i]; - int *ilogmask=iwork[i]; - - nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]], - floor_posts[i][k], - ilogmask); -#if 0 - { - char buf[80]; - sprintf(buf,"maskI%c%d",i?'R':'L',k); - float work[n/2]; - for(j=0;jpsy_g_param, - psy_look, - info, - gmdct, - iwork, - nonzero, - ci->psy_g_param.sliding_lowpass[vb->W][k], - vi->channels); - -#if 0 - for(i=0;ichannels;i++){ - char buf[80]; - sprintf(buf,"res%c%d",i?'R':'L',k); - float work[n/2]; - for(j=0;jsubmaps;i++){ - int ch_in_bundle=0; - long **classifications; - int resnum=info->residuesubmap[i]; - - for(j=0;jchannels;j++){ - if(info->chmuxlist[j]==i){ - zerobundle[ch_in_bundle]=0; - if(nonzero[j])zerobundle[ch_in_bundle]=1; - couple_bundle[ch_in_bundle++]=iwork[j]; - } - } - - classifications=_residue_P[ci->residue_type[resnum]]-> - class(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle); - - ch_in_bundle=0; - for(j=0;jchannels;j++) - if(info->chmuxlist[j]==i) - couple_bundle[ch_in_bundle++]=iwork[j]; - - _residue_P[ci->residue_type[resnum]]-> - forward(opb,vb,b->residue[resnum], - couple_bundle,zerobundle,ch_in_bundle,classifications,i); - } - - /* ok, done encoding. Next protopacket. */ - } - - } - -#if 0 - seq++; - total+=ci->blocksizes[vb->W]/4+ci->blocksizes[vb->nW]/4; -#endif - return(0); -} - -static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){ - vorbis_dsp_state *vd=vb->vd; - vorbis_info *vi=vd->vi; - codec_setup_info *ci=vi->codec_setup; - private_state *b=vd->backend_state; - vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)l; - - int i,j; - long n=vb->pcmend=ci->blocksizes[vb->W]; - - float **pcmbundle=alloca(sizeof(*pcmbundle)*vi->channels); - int *zerobundle=alloca(sizeof(*zerobundle)*vi->channels); - - int *nonzero =alloca(sizeof(*nonzero)*vi->channels); - void **floormemo=alloca(sizeof(*floormemo)*vi->channels); - - /* recover the spectral envelope; store it in the PCM vector for now */ - for(i=0;ichannels;i++){ - int submap=info->chmuxlist[i]; - floormemo[i]=_floor_P[ci->floor_type[info->floorsubmap[submap]]]-> - inverse1(vb,b->flr[info->floorsubmap[submap]]); - if(floormemo[i]) - nonzero[i]=1; - else - nonzero[i]=0; - memset(vb->pcm[i],0,sizeof(*vb->pcm[i])*n/2); - } - - /* channel coupling can 'dirty' the nonzero listing */ - for(i=0;icoupling_steps;i++){ - if(nonzero[info->coupling_mag[i]] || - nonzero[info->coupling_ang[i]]){ - nonzero[info->coupling_mag[i]]=1; - nonzero[info->coupling_ang[i]]=1; - } - } - - /* recover the residue into our working vectors */ - for(i=0;isubmaps;i++){ - int ch_in_bundle=0; - for(j=0;jchannels;j++){ - if(info->chmuxlist[j]==i){ - if(nonzero[j]) - zerobundle[ch_in_bundle]=1; - else - zerobundle[ch_in_bundle]=0; - pcmbundle[ch_in_bundle++]=vb->pcm[j]; - } - } - - _residue_P[ci->residue_type[info->residuesubmap[i]]]-> - inverse(vb,b->residue[info->residuesubmap[i]], - pcmbundle,zerobundle,ch_in_bundle); - } - - /* channel coupling */ - for(i=info->coupling_steps-1;i>=0;i--){ - float *pcmM=vb->pcm[info->coupling_mag[i]]; - float *pcmA=vb->pcm[info->coupling_ang[i]]; - - for(j=0;j0) - if(ang>0){ - pcmM[j]=mag; - pcmA[j]=mag-ang; - }else{ - pcmA[j]=mag; - pcmM[j]=mag+ang; - } - else - if(ang>0){ - pcmM[j]=mag; - pcmA[j]=mag+ang; - }else{ - pcmA[j]=mag; - pcmM[j]=mag-ang; - } - } - } - - /* compute and apply spectral envelope */ - for(i=0;ichannels;i++){ - float *pcm=vb->pcm[i]; - int submap=info->chmuxlist[i]; - _floor_P[ci->floor_type[info->floorsubmap[submap]]]-> - inverse2(vb,b->flr[info->floorsubmap[submap]], - floormemo[i],pcm); - } - - /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */ - /* only MDCT right now.... */ - for(i=0;ichannels;i++){ - float *pcm=vb->pcm[i]; - mdct_backward(b->transform[vb->W][0],pcm,pcm); - } - - /* all done! */ - return(0); -} - -/* export hooks */ -const vorbis_func_mapping mapping0_exportbundle={ - &mapping0_pack, - &mapping0_unpack, - &mapping0_free_info, - &mapping0_forward, - &mapping0_inverse -}; diff --git a/Engine/lib/libvorbis/lib/masking.h b/Engine/lib/libvorbis/lib/masking.h deleted file mode 100644 index 7a196a37e..000000000 --- a/Engine/lib/libvorbis/lib/masking.h +++ /dev/null @@ -1,784 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: masking curve data for psychoacoustics - - ********************************************************************/ - -#ifndef _V_MASKING_H_ -#define _V_MASKING_H_ - -/* more detailed ATH; the bass if flat to save stressing the floor - overly for only a bin or two of savings. */ - -#define MAX_ATH 88 -static const float ATH[]={ - /*15*/ -51, -52, -53, -54, -55, -56, -57, -58, - /*31*/ -59, -60, -61, -62, -63, -64, -65, -66, - /*63*/ -67, -68, -69, -70, -71, -72, -73, -74, - /*125*/ -75, -76, -77, -78, -80, -81, -82, -83, - /*250*/ -84, -85, -86, -87, -88, -88, -89, -89, - /*500*/ -90, -91, -91, -92, -93, -94, -95, -96, - /*1k*/ -96, -97, -98, -98, -99, -99,-100,-100, - /*2k*/ -101,-102,-103,-104,-106,-107,-107,-107, - /*4k*/ -107,-105,-103,-102,-101, -99, -98, -96, - /*8k*/ -95, -95, -96, -97, -96, -95, -93, -90, - /*16k*/ -80, -70, -50, -40, -30, -30, -30, -30 -}; - -/* The tone masking curves from Ehmer's and Fielder's papers have been - replaced by an empirically collected data set. The previously - published values were, far too often, simply on crack. */ - -#define EHMER_OFFSET 16 -#define EHMER_MAX 56 - -/* masking tones from -50 to 0dB, 62.5 through 16kHz at half octaves - test tones from -2 octaves to +5 octaves sampled at eighth octaves */ -/* (Vorbis 0dB, the loudest possible tone, is assumed to be ~100dB SPL - for collection of these curves) */ - -static const float tonemasks[P_BANDS][6][EHMER_MAX]={ - /* 62.5 Hz */ - {{ -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -62, -62, -65, -73, - -69, -68, -68, -67, -70, -70, -72, -74, - -75, -79, -79, -80, -83, -88, -93, -100, - -110, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -48, -48, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -53, -61, -66, - -66, -68, -67, -70, -76, -76, -72, -73, - -75, -76, -78, -79, -83, -88, -93, -100, - -110, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -37, -37, -37, -37, -37, -37, -37, -37, - -38, -40, -42, -46, -48, -53, -55, -62, - -65, -58, -56, -56, -61, -60, -65, -67, - -69, -71, -77, -77, -78, -80, -82, -84, - -88, -93, -98, -106, -112, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -25, -25, -25, -25, -25, -25, -25, -25, - -25, -26, -27, -29, -32, -38, -48, -52, - -52, -50, -48, -48, -51, -52, -54, -60, - -67, -67, -66, -68, -69, -73, -73, -76, - -80, -81, -81, -85, -85, -86, -88, -93, - -100, -110, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -16, -16, -16, -16, -16, -16, -16, -16, - -17, -19, -20, -22, -26, -28, -31, -40, - -47, -39, -39, -40, -42, -43, -47, -51, - -57, -52, -55, -55, -60, -58, -62, -63, - -70, -67, -69, -72, -73, -77, -80, -82, - -83, -87, -90, -94, -98, -104, -115, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -8, -8, -8, -8, -8, -8, -8, -8, - -8, -8, -10, -11, -15, -19, -25, -30, - -34, -31, -30, -31, -29, -32, -35, -42, - -48, -42, -44, -46, -50, -50, -51, -52, - -59, -54, -55, -55, -58, -62, -63, -66, - -72, -73, -76, -75, -78, -80, -80, -81, - -84, -88, -90, -94, -98, -101, -106, -110}}, - /* 88Hz */ - {{ -66, -66, -66, -66, -66, -66, -66, -66, - -66, -66, -66, -66, -66, -67, -67, -67, - -76, -72, -71, -74, -76, -76, -75, -78, - -79, -79, -81, -83, -86, -89, -93, -97, - -100, -105, -110, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -47, -47, -47, -47, -47, -47, -47, -47, - -47, -47, -47, -48, -51, -55, -59, -66, - -66, -66, -67, -66, -68, -69, -70, -74, - -79, -77, -77, -78, -80, -81, -82, -84, - -86, -88, -91, -95, -100, -108, -116, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -36, -36, -36, -36, -36, -36, -36, -36, - -36, -37, -37, -41, -44, -48, -51, -58, - -62, -60, -57, -59, -59, -60, -63, -65, - -72, -71, -70, -72, -74, -77, -76, -78, - -81, -81, -80, -83, -86, -91, -96, -100, - -105, -110, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -28, -28, -28, -28, -28, -28, -28, -28, - -28, -30, -32, -32, -33, -35, -41, -49, - -50, -49, -47, -48, -48, -52, -51, -57, - -65, -61, -59, -61, -64, -69, -70, -74, - -77, -77, -78, -81, -84, -85, -87, -90, - -92, -96, -100, -107, -112, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -19, -19, -19, -19, -19, -19, -19, -19, - -20, -21, -23, -27, -30, -35, -36, -41, - -46, -44, -42, -40, -41, -41, -43, -48, - -55, -53, -52, -53, -56, -59, -58, -60, - -67, -66, -69, -71, -72, -75, -79, -81, - -84, -87, -90, -93, -97, -101, -107, -114, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -9, -9, -9, -9, -9, -9, -9, -9, - -11, -12, -12, -15, -16, -20, -23, -30, - -37, -34, -33, -34, -31, -32, -32, -38, - -47, -44, -41, -40, -47, -49, -46, -46, - -58, -50, -50, -54, -58, -62, -64, -67, - -67, -70, -72, -76, -79, -83, -87, -91, - -96, -100, -104, -110, -999, -999, -999, -999}}, - /* 125 Hz */ - {{ -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -63, -64, -66, -67, -66, -68, - -75, -72, -76, -75, -76, -78, -79, -82, - -84, -85, -90, -94, -101, -110, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -59, -59, -59, -59, -59, -59, -59, -59, - -59, -59, -59, -60, -60, -61, -63, -66, - -71, -68, -70, -70, -71, -72, -72, -75, - -81, -78, -79, -82, -83, -86, -90, -97, - -103, -113, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -53, -53, -53, -53, -53, -53, -53, -53, - -53, -54, -55, -57, -56, -57, -55, -61, - -65, -60, -60, -62, -63, -63, -66, -68, - -74, -73, -75, -75, -78, -80, -80, -82, - -85, -90, -96, -101, -108, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -46, -46, -46, -46, -46, -46, -46, -46, - -46, -46, -47, -47, -47, -47, -48, -51, - -57, -51, -49, -50, -51, -53, -54, -59, - -66, -60, -62, -67, -67, -70, -72, -75, - -76, -78, -81, -85, -88, -94, -97, -104, - -112, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -36, -36, -36, -36, -36, -36, -36, -36, - -39, -41, -42, -42, -39, -38, -41, -43, - -52, -44, -40, -39, -37, -37, -40, -47, - -54, -50, -48, -50, -55, -61, -59, -62, - -66, -66, -66, -69, -69, -73, -74, -74, - -75, -77, -79, -82, -87, -91, -95, -100, - -108, -115, -999, -999, -999, -999, -999, -999}, - { -28, -26, -24, -22, -20, -20, -23, -29, - -30, -31, -28, -27, -28, -28, -28, -35, - -40, -33, -32, -29, -30, -30, -30, -37, - -45, -41, -37, -38, -45, -47, -47, -48, - -53, -49, -48, -50, -49, -49, -51, -52, - -58, -56, -57, -56, -60, -61, -62, -70, - -72, -74, -78, -83, -88, -93, -100, -106}}, - /* 177 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -110, -105, -100, -95, -91, -87, -83, - -80, -78, -76, -78, -78, -81, -83, -85, - -86, -85, -86, -87, -90, -97, -107, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -110, -105, -100, -95, -90, - -85, -81, -77, -73, -70, -67, -67, -68, - -75, -73, -70, -69, -70, -72, -75, -79, - -84, -83, -84, -86, -88, -89, -89, -93, - -98, -105, -112, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-105, -100, -95, -90, -85, -80, -76, -71, - -68, -68, -65, -63, -63, -62, -62, -64, - -65, -64, -61, -62, -63, -64, -66, -68, - -73, -73, -74, -75, -76, -81, -83, -85, - -88, -89, -92, -95, -100, -108, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -80, -75, -71, -68, -65, -63, -62, -61, - -61, -61, -61, -59, -56, -57, -53, -50, - -58, -52, -50, -50, -52, -53, -54, -58, - -67, -63, -67, -68, -72, -75, -78, -80, - -81, -81, -82, -85, -89, -90, -93, -97, - -101, -107, -114, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - { -65, -61, -59, -57, -56, -55, -55, -56, - -56, -57, -55, -53, -52, -47, -44, -44, - -50, -44, -41, -39, -39, -42, -40, -46, - -51, -49, -50, -53, -54, -63, -60, -61, - -62, -66, -66, -66, -70, -73, -74, -75, - -76, -75, -79, -85, -89, -91, -96, -102, - -110, -999, -999, -999, -999, -999, -999, -999}, - { -52, -50, -49, -49, -48, -48, -48, -49, - -50, -50, -49, -46, -43, -39, -35, -33, - -38, -36, -32, -29, -32, -32, -32, -35, - -44, -39, -38, -38, -46, -50, -45, -46, - -53, -50, -50, -50, -54, -54, -53, -53, - -56, -57, -59, -66, -70, -72, -74, -79, - -83, -85, -90, -97, -114, -999, -999, -999}}, - /* 250 Hz */ - {{-999, -999, -999, -999, -999, -999, -110, -105, - -100, -95, -90, -86, -80, -75, -75, -79, - -80, -79, -80, -81, -82, -88, -95, -103, - -110, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -108, -103, -98, -93, - -88, -83, -79, -78, -75, -71, -67, -68, - -73, -73, -72, -73, -75, -77, -80, -82, - -88, -93, -100, -107, -114, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -110, -105, -101, -96, -90, - -86, -81, -77, -73, -69, -66, -61, -62, - -66, -64, -62, -65, -66, -70, -72, -76, - -81, -80, -84, -90, -95, -102, -110, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -107, -103, -97, -92, -88, - -83, -79, -74, -70, -66, -59, -53, -58, - -62, -55, -54, -54, -54, -58, -61, -62, - -72, -70, -72, -75, -78, -80, -81, -80, - -83, -83, -88, -93, -100, -107, -115, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -105, -100, -95, -90, -85, - -80, -75, -70, -66, -62, -56, -48, -44, - -48, -46, -46, -43, -46, -48, -48, -51, - -58, -58, -59, -60, -62, -62, -61, -61, - -65, -64, -65, -68, -70, -74, -75, -78, - -81, -86, -95, -110, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -105, -100, -95, -90, -85, -80, - -75, -70, -65, -61, -55, -49, -39, -33, - -40, -35, -32, -38, -40, -33, -35, -37, - -46, -41, -45, -44, -46, -42, -45, -46, - -52, -50, -50, -50, -54, -54, -55, -57, - -62, -64, -66, -68, -70, -76, -81, -90, - -100, -110, -999, -999, -999, -999, -999, -999}}, - /* 354 hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -105, -98, -90, -85, -82, -83, -80, -78, - -84, -79, -80, -83, -87, -89, -91, -93, - -99, -106, -117, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -105, -98, -90, -85, -80, -75, -70, -68, - -74, -72, -74, -77, -80, -82, -85, -87, - -92, -89, -91, -95, -100, -106, -112, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -105, -98, -90, -83, -75, -71, -63, -64, - -67, -62, -64, -67, -70, -73, -77, -81, - -84, -83, -85, -89, -90, -93, -98, -104, - -109, -114, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -103, -96, -88, -81, -75, -68, -58, -54, - -56, -54, -56, -56, -58, -60, -63, -66, - -74, -69, -72, -72, -75, -74, -77, -81, - -81, -82, -84, -87, -93, -96, -99, -104, - -110, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -108, -102, -96, - -91, -85, -80, -74, -68, -60, -51, -46, - -48, -46, -43, -45, -47, -47, -49, -48, - -56, -53, -55, -58, -57, -63, -58, -60, - -66, -64, -67, -70, -70, -74, -77, -84, - -86, -89, -91, -93, -94, -101, -109, -118, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -108, -103, -98, -93, -88, - -83, -78, -73, -68, -60, -53, -44, -35, - -38, -38, -34, -34, -36, -40, -41, -44, - -51, -45, -46, -47, -46, -54, -50, -49, - -50, -50, -50, -51, -54, -57, -58, -60, - -66, -66, -66, -64, -65, -68, -77, -82, - -87, -95, -110, -999, -999, -999, -999, -999}}, - /* 500 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -107, -102, -97, -92, -87, -83, -78, -75, - -82, -79, -83, -85, -89, -92, -95, -98, - -101, -105, -109, -113, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -106, - -100, -95, -90, -86, -81, -78, -74, -69, - -74, -74, -76, -79, -83, -84, -86, -89, - -92, -97, -93, -100, -103, -107, -110, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -106, -100, - -95, -90, -87, -83, -80, -75, -69, -60, - -66, -66, -68, -70, -74, -78, -79, -81, - -81, -83, -84, -87, -93, -96, -99, -103, - -107, -110, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -108, -103, -98, - -93, -89, -85, -82, -78, -71, -62, -55, - -58, -58, -54, -54, -55, -59, -61, -62, - -70, -66, -66, -67, -70, -72, -75, -78, - -84, -84, -84, -88, -91, -90, -95, -98, - -102, -103, -106, -110, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -108, -103, -98, -94, - -90, -87, -82, -79, -73, -67, -58, -47, - -50, -45, -41, -45, -48, -44, -44, -49, - -54, -51, -48, -47, -49, -50, -51, -57, - -58, -60, -63, -69, -70, -69, -71, -74, - -78, -82, -90, -95, -101, -105, -110, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -105, -101, -97, -93, -90, - -85, -80, -77, -72, -65, -56, -48, -37, - -40, -36, -34, -40, -50, -47, -38, -41, - -47, -38, -35, -39, -38, -43, -40, -45, - -50, -45, -44, -47, -50, -55, -48, -48, - -52, -66, -70, -76, -82, -90, -97, -105, - -110, -999, -999, -999, -999, -999, -999, -999}}, - /* 707 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -108, -103, -98, -93, -86, -79, -76, - -83, -81, -85, -87, -89, -93, -98, -102, - -107, -112, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -108, -103, -98, -93, -86, -79, -71, - -77, -74, -77, -79, -81, -84, -85, -90, - -92, -93, -92, -98, -101, -108, -112, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -108, -103, -98, -93, -87, -78, -68, -65, - -66, -62, -65, -67, -70, -73, -75, -78, - -82, -82, -83, -84, -91, -93, -98, -102, - -106, -110, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -105, -100, -95, -90, -82, -74, -62, -57, - -58, -56, -51, -52, -52, -54, -54, -58, - -66, -59, -60, -63, -66, -69, -73, -79, - -83, -84, -80, -81, -81, -82, -88, -92, - -98, -105, -113, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -107, - -102, -97, -92, -84, -79, -69, -57, -47, - -52, -47, -44, -45, -50, -52, -42, -42, - -53, -43, -43, -48, -51, -56, -55, -52, - -57, -59, -61, -62, -67, -71, -78, -83, - -86, -94, -98, -103, -110, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -105, -100, - -95, -90, -84, -78, -70, -61, -51, -41, - -40, -38, -40, -46, -52, -51, -41, -40, - -46, -40, -38, -38, -41, -46, -41, -46, - -47, -43, -43, -45, -41, -45, -56, -67, - -68, -83, -87, -90, -95, -102, -107, -113, - -999, -999, -999, -999, -999, -999, -999, -999}}, - /* 1000 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -109, -105, -101, -96, -91, -84, -77, - -82, -82, -85, -89, -94, -100, -106, -110, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -106, -103, -98, -92, -85, -80, -71, - -75, -72, -76, -80, -84, -86, -89, -93, - -100, -107, -113, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -107, - -104, -101, -97, -92, -88, -84, -80, -64, - -66, -63, -64, -66, -69, -73, -77, -83, - -83, -86, -91, -98, -104, -111, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -107, - -104, -101, -97, -92, -90, -84, -74, -57, - -58, -52, -55, -54, -50, -52, -50, -52, - -63, -62, -69, -76, -77, -78, -78, -79, - -82, -88, -94, -100, -106, -111, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -106, -102, - -98, -95, -90, -85, -83, -78, -70, -50, - -50, -41, -44, -49, -47, -50, -50, -44, - -55, -46, -47, -48, -48, -54, -49, -49, - -58, -62, -71, -81, -87, -92, -97, -102, - -108, -114, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -106, -102, - -98, -95, -90, -85, -83, -78, -70, -45, - -43, -41, -47, -50, -51, -50, -49, -45, - -47, -41, -44, -41, -39, -43, -38, -37, - -40, -41, -44, -50, -58, -65, -73, -79, - -85, -92, -97, -101, -105, -109, -113, -999, - -999, -999, -999, -999, -999, -999, -999, -999}}, - /* 1414 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -107, -100, -95, -87, -81, - -85, -83, -88, -93, -100, -107, -114, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -107, -101, -95, -88, -83, -76, - -73, -72, -79, -84, -90, -95, -100, -105, - -110, -115, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -104, -98, -92, -87, -81, -70, - -65, -62, -67, -71, -74, -80, -85, -91, - -95, -99, -103, -108, -111, -114, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -103, -97, -90, -85, -76, -60, - -56, -54, -60, -62, -61, -56, -63, -65, - -73, -74, -77, -75, -78, -81, -86, -87, - -88, -91, -94, -98, -103, -110, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -105, - -100, -97, -92, -86, -81, -79, -70, -57, - -51, -47, -51, -58, -60, -56, -53, -50, - -58, -52, -50, -50, -53, -55, -64, -69, - -71, -85, -82, -78, -81, -85, -95, -102, - -112, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -105, - -100, -97, -92, -85, -83, -79, -72, -49, - -40, -43, -43, -54, -56, -51, -50, -40, - -43, -38, -36, -35, -37, -38, -37, -44, - -54, -60, -57, -60, -70, -75, -84, -92, - -103, -112, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}}, - /* 2000 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -110, -102, -95, -89, -82, - -83, -84, -90, -92, -99, -107, -113, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -107, -101, -95, -89, -83, -72, - -74, -78, -85, -88, -88, -90, -92, -98, - -105, -111, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -109, -103, -97, -93, -87, -81, -70, - -70, -67, -75, -73, -76, -79, -81, -83, - -88, -89, -97, -103, -110, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -107, -100, -94, -88, -83, -75, -63, - -59, -59, -63, -66, -60, -62, -67, -67, - -77, -76, -81, -88, -86, -92, -96, -102, - -109, -116, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -105, -98, -92, -86, -81, -73, -56, - -52, -47, -55, -60, -58, -52, -51, -45, - -49, -50, -53, -54, -61, -71, -70, -69, - -78, -79, -87, -90, -96, -104, -112, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -103, -96, -90, -86, -78, -70, -51, - -42, -47, -48, -55, -54, -54, -53, -42, - -35, -28, -33, -38, -37, -44, -47, -49, - -54, -63, -68, -78, -82, -89, -94, -99, - -104, -109, -114, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}}, - /* 2828 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -110, -100, -90, -79, - -85, -81, -82, -82, -89, -94, -99, -103, - -109, -115, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -105, -97, -85, -72, - -74, -70, -70, -70, -76, -85, -91, -93, - -97, -103, -109, -115, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -112, -93, -81, -68, - -62, -60, -60, -57, -63, -70, -77, -82, - -90, -93, -98, -104, -109, -113, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -113, -100, -93, -84, -63, - -58, -48, -53, -54, -52, -52, -57, -64, - -66, -76, -83, -81, -85, -85, -90, -95, - -98, -101, -103, -106, -108, -111, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -105, -95, -86, -74, -53, - -50, -38, -43, -49, -43, -42, -39, -39, - -46, -52, -57, -56, -72, -69, -74, -81, - -87, -92, -94, -97, -99, -102, -105, -108, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -108, -99, -90, -76, -66, -45, - -43, -41, -44, -47, -43, -47, -40, -30, - -31, -31, -39, -33, -40, -41, -43, -53, - -59, -70, -73, -77, -79, -82, -84, -87, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}}, - /* 4000 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -110, -91, -76, - -75, -85, -93, -98, -104, -110, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -110, -91, -70, - -70, -75, -86, -89, -94, -98, -101, -106, - -110, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -110, -95, -80, -60, - -65, -64, -74, -83, -88, -91, -95, -99, - -103, -107, -110, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -110, -95, -80, -58, - -55, -49, -66, -68, -71, -78, -78, -80, - -88, -85, -89, -97, -100, -105, -110, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -110, -95, -80, -53, - -52, -41, -59, -59, -49, -58, -56, -63, - -86, -79, -90, -93, -98, -103, -107, -112, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -110, -97, -91, -73, -45, - -40, -33, -53, -61, -49, -54, -50, -50, - -60, -52, -67, -74, -81, -92, -96, -100, - -105, -110, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}}, - /* 5657 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -113, -106, -99, -92, -77, - -80, -88, -97, -106, -115, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -116, -109, -102, -95, -89, -74, - -72, -88, -87, -95, -102, -109, -116, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -116, -109, -102, -95, -89, -75, - -66, -74, -77, -78, -86, -87, -90, -96, - -105, -115, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -115, -108, -101, -94, -88, -66, - -56, -61, -70, -65, -78, -72, -83, -84, - -93, -98, -105, -110, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -110, -105, -95, -89, -82, -57, - -52, -52, -59, -56, -59, -58, -69, -67, - -88, -82, -82, -89, -94, -100, -108, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -110, -101, -96, -90, -83, -77, -54, - -43, -38, -50, -48, -52, -48, -42, -42, - -51, -52, -53, -59, -65, -71, -78, -85, - -95, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}}, - /* 8000 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -120, -105, -86, -68, - -78, -79, -90, -100, -110, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -120, -105, -86, -66, - -73, -77, -88, -96, -105, -115, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -120, -105, -92, -80, -61, - -64, -68, -80, -87, -92, -100, -110, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -120, -104, -91, -79, -52, - -60, -54, -64, -69, -77, -80, -82, -84, - -85, -87, -88, -90, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -118, -100, -87, -77, -49, - -50, -44, -58, -61, -61, -67, -65, -62, - -62, -62, -65, -68, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -115, -98, -84, -62, -49, - -44, -38, -46, -49, -49, -46, -39, -37, - -39, -40, -42, -43, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}}, - /* 11314 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -110, -88, -74, - -77, -82, -82, -85, -90, -94, -99, -104, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -110, -88, -66, - -70, -81, -80, -81, -84, -88, -91, -93, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -110, -88, -61, - -63, -70, -71, -74, -77, -80, -83, -85, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -110, -86, -62, - -63, -62, -62, -58, -52, -50, -50, -52, - -54, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -118, -108, -84, -53, - -50, -50, -50, -55, -47, -45, -40, -40, - -40, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -118, -100, -73, -43, - -37, -42, -43, -53, -38, -37, -35, -35, - -38, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}}, - /* 16000 Hz */ - {{-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -110, -100, -91, -84, -74, - -80, -80, -80, -80, -80, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -110, -100, -91, -84, -74, - -68, -68, -68, -68, -68, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -110, -100, -86, -78, -70, - -60, -45, -30, -21, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -110, -100, -87, -78, -67, - -48, -38, -29, -21, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -110, -100, -86, -69, -56, - -45, -35, -33, -29, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}, - {-999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -110, -100, -83, -71, -48, - -27, -38, -37, -34, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999, - -999, -999, -999, -999, -999, -999, -999, -999}} -}; - -#endif diff --git a/Engine/lib/libvorbis/lib/mdct.c b/Engine/lib/libvorbis/lib/mdct.c deleted file mode 100644 index 2a0ff8d01..000000000 --- a/Engine/lib/libvorbis/lib/mdct.c +++ /dev/null @@ -1,562 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: normalized modified discrete cosine transform - power of two length transform only [64 <= n ] - - Original algorithm adapted long ago from _The use of multirate filter - banks for coding of high quality digital audio_, by T. Sporer, - K. Brandenburg and B. Edler, collection of the European Signal - Processing Conference (EUSIPCO), Amsterdam, June 1992, Vol.1, pp - 211-214 - - The below code implements an algorithm that no longer looks much like - that presented in the paper, but the basic structure remains if you - dig deep enough to see it. - - This module DOES NOT INCLUDE code to generate/apply the window - function. Everybody has their own weird favorite including me... I - happen to like the properties of y=sin(.5PI*sin^2(x)), but others may - vehemently disagree. - - ********************************************************************/ - -/* this can also be run as an integer transform by uncommenting a - define in mdct.h; the integerization is a first pass and although - it's likely stable for Vorbis, the dynamic range is constrained and - roundoff isn't done (so it's noisy). Consider it functional, but - only a starting point. There's no point on a machine with an FPU */ - -#include -#include -#include -#include -#include "vorbis/codec.h" -#include "mdct.h" -#include "os.h" -#include "misc.h" - -/* build lookups for trig functions; also pre-figure scaling and - some window function algebra. */ - -void mdct_init(mdct_lookup *lookup,int n){ - int *bitrev=_ogg_malloc(sizeof(*bitrev)*(n/4)); - DATA_TYPE *T=_ogg_malloc(sizeof(*T)*(n+n/4)); - - int i; - int n2=n>>1; - int log2n=lookup->log2n=rint(log((float)n)/log(2.f)); - lookup->n=n; - lookup->trig=T; - lookup->bitrev=bitrev; - -/* trig lookups... */ - - for(i=0;i>j;j++) - if((msb>>j)&i)acc|=1<scale=FLOAT_CONV(4.f/n); -} - -/* 8 point butterfly (in place, 4 register) */ -STIN void mdct_butterfly_8(DATA_TYPE *x){ - REG_TYPE r0 = x[6] + x[2]; - REG_TYPE r1 = x[6] - x[2]; - REG_TYPE r2 = x[4] + x[0]; - REG_TYPE r3 = x[4] - x[0]; - - x[6] = r0 + r2; - x[4] = r0 - r2; - - r0 = x[5] - x[1]; - r2 = x[7] - x[3]; - x[0] = r1 + r0; - x[2] = r1 - r0; - - r0 = x[5] + x[1]; - r1 = x[7] + x[3]; - x[3] = r2 + r3; - x[1] = r2 - r3; - x[7] = r1 + r0; - x[5] = r1 - r0; - -} - -/* 16 point butterfly (in place, 4 register) */ -STIN void mdct_butterfly_16(DATA_TYPE *x){ - REG_TYPE r0 = x[1] - x[9]; - REG_TYPE r1 = x[0] - x[8]; - - x[8] += x[0]; - x[9] += x[1]; - x[0] = MULT_NORM((r0 + r1) * cPI2_8); - x[1] = MULT_NORM((r0 - r1) * cPI2_8); - - r0 = x[3] - x[11]; - r1 = x[10] - x[2]; - x[10] += x[2]; - x[11] += x[3]; - x[2] = r0; - x[3] = r1; - - r0 = x[12] - x[4]; - r1 = x[13] - x[5]; - x[12] += x[4]; - x[13] += x[5]; - x[4] = MULT_NORM((r0 - r1) * cPI2_8); - x[5] = MULT_NORM((r0 + r1) * cPI2_8); - - r0 = x[14] - x[6]; - r1 = x[15] - x[7]; - x[14] += x[6]; - x[15] += x[7]; - x[6] = r0; - x[7] = r1; - - mdct_butterfly_8(x); - mdct_butterfly_8(x+8); -} - -/* 32 point butterfly (in place, 4 register) */ -STIN void mdct_butterfly_32(DATA_TYPE *x){ - REG_TYPE r0 = x[30] - x[14]; - REG_TYPE r1 = x[31] - x[15]; - - x[30] += x[14]; - x[31] += x[15]; - x[14] = r0; - x[15] = r1; - - r0 = x[28] - x[12]; - r1 = x[29] - x[13]; - x[28] += x[12]; - x[29] += x[13]; - x[12] = MULT_NORM( r0 * cPI1_8 - r1 * cPI3_8 ); - x[13] = MULT_NORM( r0 * cPI3_8 + r1 * cPI1_8 ); - - r0 = x[26] - x[10]; - r1 = x[27] - x[11]; - x[26] += x[10]; - x[27] += x[11]; - x[10] = MULT_NORM(( r0 - r1 ) * cPI2_8); - x[11] = MULT_NORM(( r0 + r1 ) * cPI2_8); - - r0 = x[24] - x[8]; - r1 = x[25] - x[9]; - x[24] += x[8]; - x[25] += x[9]; - x[8] = MULT_NORM( r0 * cPI3_8 - r1 * cPI1_8 ); - x[9] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 ); - - r0 = x[22] - x[6]; - r1 = x[7] - x[23]; - x[22] += x[6]; - x[23] += x[7]; - x[6] = r1; - x[7] = r0; - - r0 = x[4] - x[20]; - r1 = x[5] - x[21]; - x[20] += x[4]; - x[21] += x[5]; - x[4] = MULT_NORM( r1 * cPI1_8 + r0 * cPI3_8 ); - x[5] = MULT_NORM( r1 * cPI3_8 - r0 * cPI1_8 ); - - r0 = x[2] - x[18]; - r1 = x[3] - x[19]; - x[18] += x[2]; - x[19] += x[3]; - x[2] = MULT_NORM(( r1 + r0 ) * cPI2_8); - x[3] = MULT_NORM(( r1 - r0 ) * cPI2_8); - - r0 = x[0] - x[16]; - r1 = x[1] - x[17]; - x[16] += x[0]; - x[17] += x[1]; - x[0] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 ); - x[1] = MULT_NORM( r1 * cPI1_8 - r0 * cPI3_8 ); - - mdct_butterfly_16(x); - mdct_butterfly_16(x+16); - -} - -/* N point first stage butterfly (in place, 2 register) */ -STIN void mdct_butterfly_first(DATA_TYPE *T, - DATA_TYPE *x, - int points){ - - DATA_TYPE *x1 = x + points - 8; - DATA_TYPE *x2 = x + (points>>1) - 8; - REG_TYPE r0; - REG_TYPE r1; - - do{ - - r0 = x1[6] - x2[6]; - r1 = x1[7] - x2[7]; - x1[6] += x2[6]; - x1[7] += x2[7]; - x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - r0 = x1[4] - x2[4]; - r1 = x1[5] - x2[5]; - x1[4] += x2[4]; - x1[5] += x2[5]; - x2[4] = MULT_NORM(r1 * T[5] + r0 * T[4]); - x2[5] = MULT_NORM(r1 * T[4] - r0 * T[5]); - - r0 = x1[2] - x2[2]; - r1 = x1[3] - x2[3]; - x1[2] += x2[2]; - x1[3] += x2[3]; - x2[2] = MULT_NORM(r1 * T[9] + r0 * T[8]); - x2[3] = MULT_NORM(r1 * T[8] - r0 * T[9]); - - r0 = x1[0] - x2[0]; - r1 = x1[1] - x2[1]; - x1[0] += x2[0]; - x1[1] += x2[1]; - x2[0] = MULT_NORM(r1 * T[13] + r0 * T[12]); - x2[1] = MULT_NORM(r1 * T[12] - r0 * T[13]); - - x1-=8; - x2-=8; - T+=16; - - }while(x2>=x); -} - -/* N/stage point generic N stage butterfly (in place, 2 register) */ -STIN void mdct_butterfly_generic(DATA_TYPE *T, - DATA_TYPE *x, - int points, - int trigint){ - - DATA_TYPE *x1 = x + points - 8; - DATA_TYPE *x2 = x + (points>>1) - 8; - REG_TYPE r0; - REG_TYPE r1; - - do{ - - r0 = x1[6] - x2[6]; - r1 = x1[7] - x2[7]; - x1[6] += x2[6]; - x1[7] += x2[7]; - x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - T+=trigint; - - r0 = x1[4] - x2[4]; - r1 = x1[5] - x2[5]; - x1[4] += x2[4]; - x1[5] += x2[5]; - x2[4] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[5] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - T+=trigint; - - r0 = x1[2] - x2[2]; - r1 = x1[3] - x2[3]; - x1[2] += x2[2]; - x1[3] += x2[3]; - x2[2] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[3] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - T+=trigint; - - r0 = x1[0] - x2[0]; - r1 = x1[1] - x2[1]; - x1[0] += x2[0]; - x1[1] += x2[1]; - x2[0] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[1] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - T+=trigint; - x1-=8; - x2-=8; - - }while(x2>=x); -} - -STIN void mdct_butterflies(mdct_lookup *init, - DATA_TYPE *x, - int points){ - - DATA_TYPE *T=init->trig; - int stages=init->log2n-5; - int i,j; - - if(--stages>0){ - mdct_butterfly_first(T,x,points); - } - - for(i=1;--stages>0;i++){ - for(j=0;j<(1<>i)*j,points>>i,4<trig)_ogg_free(l->trig); - if(l->bitrev)_ogg_free(l->bitrev); - memset(l,0,sizeof(*l)); - } -} - -STIN void mdct_bitreverse(mdct_lookup *init, - DATA_TYPE *x){ - int n = init->n; - int *bit = init->bitrev; - DATA_TYPE *w0 = x; - DATA_TYPE *w1 = x = w0+(n>>1); - DATA_TYPE *T = init->trig+n; - - do{ - DATA_TYPE *x0 = x+bit[0]; - DATA_TYPE *x1 = x+bit[1]; - - REG_TYPE r0 = x0[1] - x1[1]; - REG_TYPE r1 = x0[0] + x1[0]; - REG_TYPE r2 = MULT_NORM(r1 * T[0] + r0 * T[1]); - REG_TYPE r3 = MULT_NORM(r1 * T[1] - r0 * T[0]); - - w1 -= 4; - - r0 = HALVE(x0[1] + x1[1]); - r1 = HALVE(x0[0] - x1[0]); - - w0[0] = r0 + r2; - w1[2] = r0 - r2; - w0[1] = r1 + r3; - w1[3] = r3 - r1; - - x0 = x+bit[2]; - x1 = x+bit[3]; - - r0 = x0[1] - x1[1]; - r1 = x0[0] + x1[0]; - r2 = MULT_NORM(r1 * T[2] + r0 * T[3]); - r3 = MULT_NORM(r1 * T[3] - r0 * T[2]); - - r0 = HALVE(x0[1] + x1[1]); - r1 = HALVE(x0[0] - x1[0]); - - w0[2] = r0 + r2; - w1[0] = r0 - r2; - w0[3] = r1 + r3; - w1[1] = r3 - r1; - - T += 4; - bit += 4; - w0 += 4; - - }while(w0n; - int n2=n>>1; - int n4=n>>2; - - /* rotate */ - - DATA_TYPE *iX = in+n2-7; - DATA_TYPE *oX = out+n2+n4; - DATA_TYPE *T = init->trig+n4; - - do{ - oX -= 4; - oX[0] = MULT_NORM(-iX[2] * T[3] - iX[0] * T[2]); - oX[1] = MULT_NORM (iX[0] * T[3] - iX[2] * T[2]); - oX[2] = MULT_NORM(-iX[6] * T[1] - iX[4] * T[0]); - oX[3] = MULT_NORM (iX[4] * T[1] - iX[6] * T[0]); - iX -= 8; - T += 4; - }while(iX>=in); - - iX = in+n2-8; - oX = out+n2+n4; - T = init->trig+n4; - - do{ - T -= 4; - oX[0] = MULT_NORM (iX[4] * T[3] + iX[6] * T[2]); - oX[1] = MULT_NORM (iX[4] * T[2] - iX[6] * T[3]); - oX[2] = MULT_NORM (iX[0] * T[1] + iX[2] * T[0]); - oX[3] = MULT_NORM (iX[0] * T[0] - iX[2] * T[1]); - iX -= 8; - oX += 4; - }while(iX>=in); - - mdct_butterflies(init,out+n2,n2); - mdct_bitreverse(init,out); - - /* roatate + window */ - - { - DATA_TYPE *oX1=out+n2+n4; - DATA_TYPE *oX2=out+n2+n4; - DATA_TYPE *iX =out; - T =init->trig+n2; - - do{ - oX1-=4; - - oX1[3] = MULT_NORM (iX[0] * T[1] - iX[1] * T[0]); - oX2[0] = -MULT_NORM (iX[0] * T[0] + iX[1] * T[1]); - - oX1[2] = MULT_NORM (iX[2] * T[3] - iX[3] * T[2]); - oX2[1] = -MULT_NORM (iX[2] * T[2] + iX[3] * T[3]); - - oX1[1] = MULT_NORM (iX[4] * T[5] - iX[5] * T[4]); - oX2[2] = -MULT_NORM (iX[4] * T[4] + iX[5] * T[5]); - - oX1[0] = MULT_NORM (iX[6] * T[7] - iX[7] * T[6]); - oX2[3] = -MULT_NORM (iX[6] * T[6] + iX[7] * T[7]); - - oX2+=4; - iX += 8; - T += 8; - }while(iXoX2); - } -} - -void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){ - int n=init->n; - int n2=n>>1; - int n4=n>>2; - int n8=n>>3; - DATA_TYPE *w=alloca(n*sizeof(*w)); /* forward needs working space */ - DATA_TYPE *w2=w+n2; - - /* rotate */ - - /* window + rotate + step 1 */ - - REG_TYPE r0; - REG_TYPE r1; - DATA_TYPE *x0=in+n2+n4; - DATA_TYPE *x1=x0+1; - DATA_TYPE *T=init->trig+n2; - - int i=0; - - for(i=0;itrig+n2; - x0=out+n2; - - for(i=0;iscale); - x0[0] =MULT_NORM((w[0]*T[1]-w[1]*T[0])*init->scale); - w+=2; - T+=2; - } -} diff --git a/Engine/lib/libvorbis/lib/mdct.h b/Engine/lib/libvorbis/lib/mdct.h deleted file mode 100644 index ceaea617a..000000000 --- a/Engine/lib/libvorbis/lib/mdct.h +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: modified discrete cosine transform prototypes - - ********************************************************************/ - -#ifndef _OGG_mdct_H_ -#define _OGG_mdct_H_ - -#include "vorbis/codec.h" - - - - - -/*#define MDCT_INTEGERIZED <- be warned there could be some hurt left here*/ -#ifdef MDCT_INTEGERIZED - -#define DATA_TYPE int -#define REG_TYPE register int -#define TRIGBITS 14 -#define cPI3_8 6270 -#define cPI2_8 11585 -#define cPI1_8 15137 - -#define FLOAT_CONV(x) ((int)((x)*(1<>TRIGBITS) -#define HALVE(x) ((x)>>1) - -#else - -#define DATA_TYPE float -#define REG_TYPE float -#define cPI3_8 .38268343236508977175F -#define cPI2_8 .70710678118654752441F -#define cPI1_8 .92387953251128675613F - -#define FLOAT_CONV(x) (x) -#define MULT_NORM(x) (x) -#define HALVE(x) ((x)*.5f) - -#endif - - -typedef struct { - int n; - int log2n; - - DATA_TYPE *trig; - int *bitrev; - - DATA_TYPE scale; -} mdct_lookup; - -extern void mdct_init(mdct_lookup *lookup,int n); -extern void mdct_clear(mdct_lookup *l); -extern void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out); -extern void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out); - -#endif diff --git a/Engine/lib/libvorbis/lib/misc.c b/Engine/lib/libvorbis/lib/misc.c deleted file mode 100644 index 70a091d79..000000000 --- a/Engine/lib/libvorbis/lib/misc.c +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ********************************************************************/ - -#define HEAD_ALIGN 32 -#include -#include -#include -#include -#include "vorbis/codec.h" -#define MISC_C -#include "misc.h" -#include - -static pthread_mutex_t memlock=PTHREAD_MUTEX_INITIALIZER; -static void **pointers=NULL; -static long *insertlist=NULL; /* We can't embed this in the pointer list; - a pointer can have any value... */ - -static char **files=NULL; -static long *file_bytes=NULL; -static int filecount=0; - -static int ptop=0; -static int palloced=0; -static int pinsert=0; - -typedef struct { - char *file; - long line; - long ptr; - long bytes; -} head; - -long global_bytes=0; -long start_time=-1; - -static void *_insert(void *ptr,long bytes,char *file,long line){ - ((head *)ptr)->file=file; - ((head *)ptr)->line=line; - ((head *)ptr)->ptr=pinsert; - ((head *)ptr)->bytes=bytes-HEAD_ALIGN; - - pthread_mutex_lock(&memlock); - if(pinsert>=palloced){ - palloced+=64; - if(pointers){ - pointers=(void **)realloc(pointers,sizeof(void **)*palloced); - insertlist=(long *)realloc(insertlist,sizeof(long *)*palloced); - }else{ - pointers=(void **)malloc(sizeof(void **)*palloced); - insertlist=(long *)malloc(sizeof(long *)*palloced); - } - } - - pointers[pinsert]=ptr; - - if(pinsert==ptop) - pinsert=++ptop; - else - pinsert=insertlist[pinsert]; - -#ifdef _VDBG_GRAPHFILE - { - FILE *out; - struct timeval tv; - static struct timezone tz; - int i; - char buffer[80]; - gettimeofday(&tv,&tz); - - for(i=0;ifile; - long bytes =((head *)ptr)->bytes; - int i; - - gettimeofday(&tv,&tz); - fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), - global_bytes); - fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), - global_bytes-((head *)ptr)->bytes); - fclose(out); - - for(i=0;ibytes; - - insert=((head *)ptr)->ptr; - insertlist[insert]=pinsert; - pinsert=insert; - - if(pointers[insert]==NULL){ - fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing previously freed memory\n"); - fprintf(stderr,"\t%s %ld\n",((head *)ptr)->file,((head *)ptr)->line); - } - - if(global_bytes<0){ - fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing unmalloced memory\n"); - } - - pointers[insert]=NULL; - pthread_mutex_unlock(&memlock); -} - -void _VDBG_dump(void){ - int i; - pthread_mutex_lock(&memlock); - for(i=0;ifile,ptr->line); - } - - pthread_mutex_unlock(&memlock); -} - -void *_VDBG_malloc(void *ptr,long bytes,char *file,long line){ - if(bytes<=0) - fprintf(stderr,"bad malloc request (%ld bytes) from %s:%ld\n",bytes,file,line); - - bytes+=HEAD_ALIGN; - if(ptr){ - ptr-=HEAD_ALIGN; - _ripremove(ptr); - ptr=realloc(ptr,bytes); - }else{ - ptr=malloc(bytes); - memset(ptr,0,bytes); - } - return _insert(ptr,bytes,file,line); -} - -void _VDBG_free(void *ptr,char *file,long line){ - if(ptr){ - ptr-=HEAD_ALIGN; - _ripremove(ptr); - free(ptr); - } -} - diff --git a/Engine/lib/libvorbis/lib/misc.h b/Engine/lib/libvorbis/lib/misc.h deleted file mode 100644 index eac5160e8..000000000 --- a/Engine/lib/libvorbis/lib/misc.h +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: miscellaneous prototypes - - ********************************************************************/ - -#ifndef _V_RANDOM_H_ -#define _V_RANDOM_H_ -#include "vorbis/codec.h" - -extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); -extern void _vorbis_block_ripcord(vorbis_block *vb); -extern int ov_ilog(ogg_uint32_t v); - -#ifdef ANALYSIS -extern int analysis_noisy; -extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, - ogg_int64_t off); -extern void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB, - ogg_int64_t off); -#endif - -#ifdef DEBUG_MALLOC - -#define _VDBG_GRAPHFILE "malloc.m" -#undef _VDBG_GRAPHFILE -extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line); -extern void _VDBG_free(void *ptr,char *file,long line); - -#ifndef MISC_C -#undef _ogg_malloc -#undef _ogg_calloc -#undef _ogg_realloc -#undef _ogg_free - -#define _ogg_malloc(x) _VDBG_malloc(NULL,(x),__FILE__,__LINE__) -#define _ogg_calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__) -#define _ogg_realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__) -#define _ogg_free(x) _VDBG_free((x),__FILE__,__LINE__) -#endif -#endif - -#endif - - - - diff --git a/Engine/lib/libvorbis/lib/modes/Makefile.am b/Engine/lib/libvorbis/lib/modes/Makefile.am deleted file mode 100644 index 5c7ffefaa..000000000 --- a/Engine/lib/libvorbis/lib/modes/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = floor_all.h psych_44.h residue_44.h setup_11.h setup_32.h \ - setup_8.h psych_11.h psych_8.h residue_44u.h setup_16.h \ - setup_44.h setup_X.h psych_16.h residue_16.h residue_8.h \ - setup_22.h setup_44u.h setup_44p51.h residue_44p51.h diff --git a/Engine/lib/libvorbis/lib/modes/floor_all.h b/Engine/lib/libvorbis/lib/modes/floor_all.h deleted file mode 100644 index 2e3d4a501..000000000 --- a/Engine/lib/libvorbis/lib/modes/floor_all.h +++ /dev/null @@ -1,259 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: key floor settings - - ********************************************************************/ - -#include "vorbis/codec.h" -#include "backends.h" -#include "books/floor/floor_books.h" - -static const static_codebook*const _floor_128x4_books[]={ - &_huff_book_line_128x4_class0, - &_huff_book_line_128x4_0sub0, - &_huff_book_line_128x4_0sub1, - &_huff_book_line_128x4_0sub2, - &_huff_book_line_128x4_0sub3, -}; -static const static_codebook*const _floor_256x4_books[]={ - &_huff_book_line_256x4_class0, - &_huff_book_line_256x4_0sub0, - &_huff_book_line_256x4_0sub1, - &_huff_book_line_256x4_0sub2, - &_huff_book_line_256x4_0sub3, -}; -static const static_codebook*const _floor_128x7_books[]={ - &_huff_book_line_128x7_class0, - &_huff_book_line_128x7_class1, - - &_huff_book_line_128x7_0sub1, - &_huff_book_line_128x7_0sub2, - &_huff_book_line_128x7_0sub3, - &_huff_book_line_128x7_1sub1, - &_huff_book_line_128x7_1sub2, - &_huff_book_line_128x7_1sub3, -}; -static const static_codebook*const _floor_256x7_books[]={ - &_huff_book_line_256x7_class0, - &_huff_book_line_256x7_class1, - - &_huff_book_line_256x7_0sub1, - &_huff_book_line_256x7_0sub2, - &_huff_book_line_256x7_0sub3, - &_huff_book_line_256x7_1sub1, - &_huff_book_line_256x7_1sub2, - &_huff_book_line_256x7_1sub3, -}; -static const static_codebook*const _floor_128x11_books[]={ - &_huff_book_line_128x11_class1, - &_huff_book_line_128x11_class2, - &_huff_book_line_128x11_class3, - - &_huff_book_line_128x11_0sub0, - &_huff_book_line_128x11_1sub0, - &_huff_book_line_128x11_1sub1, - &_huff_book_line_128x11_2sub1, - &_huff_book_line_128x11_2sub2, - &_huff_book_line_128x11_2sub3, - &_huff_book_line_128x11_3sub1, - &_huff_book_line_128x11_3sub2, - &_huff_book_line_128x11_3sub3, -}; -static const static_codebook*const _floor_128x17_books[]={ - &_huff_book_line_128x17_class1, - &_huff_book_line_128x17_class2, - &_huff_book_line_128x17_class3, - - &_huff_book_line_128x17_0sub0, - &_huff_book_line_128x17_1sub0, - &_huff_book_line_128x17_1sub1, - &_huff_book_line_128x17_2sub1, - &_huff_book_line_128x17_2sub2, - &_huff_book_line_128x17_2sub3, - &_huff_book_line_128x17_3sub1, - &_huff_book_line_128x17_3sub2, - &_huff_book_line_128x17_3sub3, -}; -static const static_codebook*const _floor_256x4low_books[]={ - &_huff_book_line_256x4low_class0, - &_huff_book_line_256x4low_0sub0, - &_huff_book_line_256x4low_0sub1, - &_huff_book_line_256x4low_0sub2, - &_huff_book_line_256x4low_0sub3, -}; -static const static_codebook*const _floor_1024x27_books[]={ - &_huff_book_line_1024x27_class1, - &_huff_book_line_1024x27_class2, - &_huff_book_line_1024x27_class3, - &_huff_book_line_1024x27_class4, - - &_huff_book_line_1024x27_0sub0, - &_huff_book_line_1024x27_1sub0, - &_huff_book_line_1024x27_1sub1, - &_huff_book_line_1024x27_2sub0, - &_huff_book_line_1024x27_2sub1, - &_huff_book_line_1024x27_3sub1, - &_huff_book_line_1024x27_3sub2, - &_huff_book_line_1024x27_3sub3, - &_huff_book_line_1024x27_4sub1, - &_huff_book_line_1024x27_4sub2, - &_huff_book_line_1024x27_4sub3, -}; -static const static_codebook*const _floor_2048x27_books[]={ - &_huff_book_line_2048x27_class1, - &_huff_book_line_2048x27_class2, - &_huff_book_line_2048x27_class3, - &_huff_book_line_2048x27_class4, - - &_huff_book_line_2048x27_0sub0, - &_huff_book_line_2048x27_1sub0, - &_huff_book_line_2048x27_1sub1, - &_huff_book_line_2048x27_2sub0, - &_huff_book_line_2048x27_2sub1, - &_huff_book_line_2048x27_3sub1, - &_huff_book_line_2048x27_3sub2, - &_huff_book_line_2048x27_3sub3, - &_huff_book_line_2048x27_4sub1, - &_huff_book_line_2048x27_4sub2, - &_huff_book_line_2048x27_4sub3, -}; - -static const static_codebook*const _floor_512x17_books[]={ - &_huff_book_line_512x17_class1, - &_huff_book_line_512x17_class2, - &_huff_book_line_512x17_class3, - - &_huff_book_line_512x17_0sub0, - &_huff_book_line_512x17_1sub0, - &_huff_book_line_512x17_1sub1, - &_huff_book_line_512x17_2sub1, - &_huff_book_line_512x17_2sub2, - &_huff_book_line_512x17_2sub3, - &_huff_book_line_512x17_3sub1, - &_huff_book_line_512x17_3sub2, - &_huff_book_line_512x17_3sub3, -}; - -static const static_codebook*const _floor_Xx0_books[]={ - 0 -}; - -static const static_codebook*const *const _floor_books[11]={ - _floor_128x4_books, - _floor_256x4_books, - _floor_128x7_books, - _floor_256x7_books, - _floor_128x11_books, - _floor_128x17_books, - _floor_256x4low_books, - _floor_1024x27_books, - _floor_2048x27_books, - _floor_512x17_books, - _floor_Xx0_books, -}; - -static const vorbis_info_floor1 _floor[11]={ - /* 0: 128 x 4 */ - { - 1,{0},{4},{2},{0}, - {{1,2,3,4}}, - 4,{0,128, 33,8,16,70}, - - 60,30,500, 1.,18., 128 - }, - /* 1: 256 x 4 */ - { - 1,{0},{4},{2},{0}, - {{1,2,3,4}}, - 4,{0,256, 66,16,32,140}, - - 60,30,500, 1.,18., 256 - }, - /* 2: 128 x 7 */ - { - 2,{0,1},{3,4},{2,2},{0,1}, - {{-1,2,3,4},{-1,5,6,7}}, - 4,{0,128, 14,4,58, 2,8,28,90}, - - 60,30,500, 1.,18., 128 - }, - /* 3: 256 x 7 */ - { - 2,{0,1},{3,4},{2,2},{0,1}, - {{-1,2,3,4},{-1,5,6,7}}, - 4,{0,256, 28,8,116, 4,16,56,180}, - - 60,30,500, 1.,18., 256 - }, - /* 4: 128 x 11 */ - { - 4,{0,1,2,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, - {{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, - - 2,{0,128, 8,33, 4,16,70, 2,6,12, 23,46,90}, - - 60,30,500, 1,18., 128 - }, - /* 5: 128 x 17 */ - { - 6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, - {{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, - 2,{0,128, 12,46, 4,8,16, 23,33,70, 2,6,10, 14,19,28, 39,58,90}, - - 60,30,500, 1,18., 128 - }, - /* 6: 256 x 4 (low bitrate version) */ - { - 1,{0},{4},{2},{0}, - {{1,2,3,4}}, - 4,{0,256, 66,16,32,140}, - - 60,30,500, 1.,18., 256 - }, - /* 7: 1024 x 27 */ - { - 8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3}, - {{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}}, - 2,{0,1024, 93,23,372, 6,46,186,750, 14,33,65, 130,260,556, - 3,10,18,28, 39,55,79,111, 158,220,312, 464,650,850}, - - 60,30,500, 3,18., 1024 - }, - /* 8: 2048 x 27 */ - { - 8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3}, - {{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}}, - 2,{0,2048, 186,46,744, 12,92,372,1500, 28,66,130, 260,520,1112, - 6,20,36,56, 78,110,158,222, 316,440,624, 928,1300,1700}, - - 60,30,500, 3,18., 2048 - }, - /* 9: 512 x 17 */ - { - 6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, - {{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, - 2,{0,512, 46,186, 16,33,65, 93,130,278, - 7,23,39, 55,79,110, 156,232,360}, - - 60,30,500, 1,18., 512 - }, - - /* 10: X x 0 (LFE floor; edge posts only) */ - { - 0,{0}, {0},{0},{-1}, - {{-1}}, - 2,{0,12}, - 60,30,500, 1.,18., 10 - }, - -}; diff --git a/Engine/lib/libvorbis/lib/modes/psych_11.h b/Engine/lib/libvorbis/lib/modes/psych_11.h deleted file mode 100644 index 9d8ed357e..000000000 --- a/Engine/lib/libvorbis/lib/modes/psych_11.h +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: 11kHz settings - - ********************************************************************/ - -static const double _psy_lowpass_11[3]={4.5,5.5,30.,}; - -static const att3 _psy_tone_masteratt_11[3]={ - {{ 30, 25, 12}, 0, 0}, /* 0 */ - {{ 30, 25, 12}, 0, 0}, /* 0 */ - {{ 20, 0, -14}, 0, 0}, /* 0 */ -}; - -static const vp_adjblock _vp_tonemask_adj_11[3]={ - /* adjust for mode zero */ - /* 63 125 250 500 1 2 4 8 16 */ - {{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 2, 0,99,99,99}}, /* 0 */ - {{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0, 5, 0, 0,99,99,99}}, /* 1 */ - {{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0, 0, 0, 0,99,99,99}}, /* 2 */ -}; - - -static const noise3 _psy_noisebias_11[3]={ - /* 63 125 250 500 1k 2k 4k 8k 16k*/ - {{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 10, 10, 12, 12, 12, 99, 99, 99}, - {-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 4, 5, 5, 10, 99, 99, 99}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, - - {{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 10, 10, 12, 12, 12, 99, 99, 99}, - {-15,-15,-15,-15,-10,-10, -5, -5, -5, 0, 0, 0, 0, 0, 99, 99, 99}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, - - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 99, 99, 99}, - {-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10, 99, 99, 99}, - {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}}, -}; - -static const double _noise_thresh_11[3]={ .3,.5,.5 }; - diff --git a/Engine/lib/libvorbis/lib/modes/psych_16.h b/Engine/lib/libvorbis/lib/modes/psych_16.h deleted file mode 100644 index 49cbf7c4b..000000000 --- a/Engine/lib/libvorbis/lib/modes/psych_16.h +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: 16kHz settings - - ********************************************************************/ - -/* stereo mode by base quality level */ -static const adj_stereo _psy_stereo_modes_16[4]={ - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ - {{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, - { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - {{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, - { 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - {{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 5, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, -}; - -static const double _psy_lowpass_16[4]={6.5,8,30.,99.}; - -static const att3 _psy_tone_masteratt_16[4]={ - {{ 30, 25, 12}, 0, 0}, /* 0 */ - {{ 25, 22, 12}, 0, 0}, /* 0 */ - {{ 20, 12, 0}, 0, 0}, /* 0 */ - {{ 15, 0, -14}, 0, 0}, /* 0 */ -}; - -static const vp_adjblock _vp_tonemask_adj_16[4]={ - /* adjust for mode zero */ - /* 63 125 250 500 1 2 4 8 16 */ - {{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 0 */ - {{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 1 */ - {{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 2 */ - {{-30,-30,-30,-30,-30,-26,-20,-10, -5, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 2 */ -}; - - -static const noise3 _psy_noisebias_16_short[4]={ - /* 63 125 250 500 1k 2k 4k 8k 16k*/ - {{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20}, - {-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, - - {{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 6, 6, 6, 6, 8, 10, 12, 20}, - {-15,-15,-15,-15,-15,-15,-15,-10, -5, -5, -5, 4, 5, 6, 8, 8, 15}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10,-10,-10,-10,-10,-10,-10,-10,-10}}}, - - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 12}, - {-20,-20,-20,-20,-16,-12,-20,-14,-10,-10, -8, 0, 0, 0, 0, 2, 5}, - {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, - - {{{-15,-15,-15,-15,-15,-12,-10, -8, -5, -5, -5, -5, -5, 0, 0, 0, 6}, - {-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10,-10,-10, -6}, - {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, -}; - -static const noise3 _psy_noisebias_16_impulse[4]={ - /* 63 125 250 500 1k 2k 4k 8k 16k*/ - {{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20}, - {-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, - - {{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 4, 4, 4, 5, 5, 6, 8, 15}, - {-15,-15,-15,-15,-15,-15,-15,-10, -5, -5, -5, 0, 0, 0, 0, 4, 10}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10,-10,-10,-10,-10,-10,-10,-10,-10}}}, - - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 4, 10}, - {-20,-20,-20,-20,-16,-12,-20,-14,-10,-10,-10,-10,-10,-10,-10, -7, -5}, - {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, - - {{{-15,-15,-15,-15,-15,-12,-10, -8, -5, -5, -5, -5, -5, 0, 0, 0, 6}, - {-30,-30,-30,-30,-26,-22,-20,-18,-18,-18,-20,-20,-20,-20,-20,-20,-16}, - {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, -}; - -static const noise3 _psy_noisebias_16[4]={ - /* 63 125 250 500 1k 2k 4k 8k 16k*/ - {{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 6, 8, 8, 10, 10, 10, 14, 20}, - {-10,-10,-10,-10,-10, -5, -2, -2, 0, 0, 0, 4, 5, 6, 8, 8, 15}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, - - {{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 6, 6, 6, 6, 8, 10, 12, 20}, - {-15,-15,-15,-15,-15,-10, -5, -5, 0, 0, 0, 4, 5, 6, 8, 8, 15}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, - - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 12}, - {-20,-20,-20,-20,-16,-12,-20,-10, -5, -5, 0, 0, 0, 0, 0, 2, 5}, - {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, - - {{{-15,-15,-15,-15,-15,-12,-10, -8, -5, -5, -5, -5, -5, 0, 0, 0, 6}, - {-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10,-10,-10, -6}, - {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, -}; - -static const noiseguard _psy_noiseguards_16[4]={ - {10,10,-1}, - {10,10,-1}, - {20,20,-1}, - {20,20,-1}, -}; - -static const double _noise_thresh_16[4]={ .3,.5,.5,.5 }; - -static const int _noise_start_16[3]={ 256,256,9999 }; -static const int _noise_part_16[4]={ 8,8,8,8 }; - -static const int _psy_ath_floater_16[4]={ - -100,-100,-100,-105, -}; - -static const int _psy_ath_abs_16[4]={ - -130,-130,-130,-140, -}; diff --git a/Engine/lib/libvorbis/lib/modes/psych_44.h b/Engine/lib/libvorbis/lib/modes/psych_44.h deleted file mode 100644 index d15509b71..000000000 --- a/Engine/lib/libvorbis/lib/modes/psych_44.h +++ /dev/null @@ -1,641 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: key psychoacoustic settings for 44.1/48kHz - - ********************************************************************/ - - -/* preecho trigger settings *****************************************/ - -static const vorbis_info_psy_global _psy_global_44[5]={ - - {8, /* lines per eighth octave */ - {20.f,14.f,12.f,12.f,12.f,12.f,12.f}, - {-60.f,-30.f,-40.f,-40.f,-40.f,-40.f,-40.f}, 2,-75.f, - -6.f, - {99.},{{99.},{99.}},{0},{0},{{0.},{0.}} - }, - {8, /* lines per eighth octave */ - {14.f,10.f,10.f,10.f,10.f,10.f,10.f}, - {-40.f,-30.f,-25.f,-25.f,-25.f,-25.f,-25.f}, 2,-80.f, - -6.f, - {99.},{{99.},{99.}},{0},{0},{{0.},{0.}} - }, - {8, /* lines per eighth octave */ - {12.f,10.f,10.f,10.f,10.f,10.f,10.f}, - {-20.f,-20.f,-15.f,-15.f,-15.f,-15.f,-15.f}, 0,-80.f, - -6.f, - {99.},{{99.},{99.}},{0},{0},{{0.},{0.}} - }, - {8, /* lines per eighth octave */ - {10.f,8.f,8.f,8.f,8.f,8.f,8.f}, - {-20.f,-15.f,-12.f,-12.f,-12.f,-12.f,-12.f}, 0,-80.f, - -6.f, - {99.},{{99.},{99.}},{0},{0},{{0.},{0.}} - }, - {8, /* lines per eighth octave */ - {10.f,6.f,6.f,6.f,6.f,6.f,6.f}, - {-15.f,-15.f,-12.f,-12.f,-12.f,-12.f,-12.f}, 0,-85.f, - -6.f, - {99.},{{99.},{99.}},{0},{0},{{0.},{0.}} - }, -}; - -/* noise compander lookups * low, mid, high quality ****************/ -static const compandblock _psy_compand_44[6]={ - /* sub-mode Z short */ - {{ - 0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ - 8, 9,10,11,12,13,14, 15, /* 15dB */ - 16,17,18,19,20,21,22, 23, /* 23dB */ - 24,25,26,27,28,29,30, 31, /* 31dB */ - 32,33,34,35,36,37,38, 39, /* 39dB */ - }}, - /* mode_Z nominal short */ - {{ - 0, 1, 2, 3, 4, 5, 6, 6, /* 7dB */ - 7, 7, 7, 7, 6, 6, 6, 7, /* 15dB */ - 7, 8, 9,10,11,12,13, 14, /* 23dB */ - 15,16,17,17,17,18,18, 19, /* 31dB */ - 19,19,20,21,22,23,24, 25, /* 39dB */ - }}, - /* mode A short */ - {{ - 0, 1, 2, 3, 4, 5, 5, 5, /* 7dB */ - 6, 6, 6, 5, 4, 4, 4, 4, /* 15dB */ - 4, 4, 5, 5, 5, 6, 6, 6, /* 23dB */ - 7, 7, 7, 8, 8, 8, 9, 10, /* 31dB */ - 11,12,13,14,15,16,17, 18, /* 39dB */ - }}, - /* sub-mode Z long */ - {{ - 0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ - 8, 9,10,11,12,13,14, 15, /* 15dB */ - 16,17,18,19,20,21,22, 23, /* 23dB */ - 24,25,26,27,28,29,30, 31, /* 31dB */ - 32,33,34,35,36,37,38, 39, /* 39dB */ - }}, - /* mode_Z nominal long */ - {{ - 0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ - 8, 9,10,11,12,12,13, 13, /* 15dB */ - 13,14,14,14,15,15,15, 15, /* 23dB */ - 16,16,17,17,17,18,18, 19, /* 31dB */ - 19,19,20,21,22,23,24, 25, /* 39dB */ - }}, - /* mode A long */ - {{ - 0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ - 8, 8, 7, 6, 5, 4, 4, 4, /* 15dB */ - 4, 4, 5, 5, 5, 6, 6, 6, /* 23dB */ - 7, 7, 7, 8, 8, 8, 9, 10, /* 31dB */ - 11,12,13,14,15,16,17, 18, /* 39dB */ - }} -}; - -/* tonal masking curve level adjustments *************************/ - -static const vp_adjblock _vp_tonemask_adj_longblock[12]={ - - /* 63 125 250 500 1 2 4 8 16 */ - - {{ -3, -8,-13,-15,-10,-10,-10,-10,-10,-10,-10, 0, 0, 0, 0, 0, 0}}, /* -1 */ - -/* {{-15,-15,-15,-15,-10, -8, -4, -2, 0, 0, 0, 10, 0, 0, 0, 0, 0}}, 0 */ - {{ -4,-10,-14,-16,-15,-14,-13,-12,-12,-12,-11, -1, -1, -1, -1, -1, 0}}, /* 0 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 5, 0, 0, 0, 0, 0}}, 1 */ - {{ -6,-12,-14,-16,-15,-15,-14,-13,-13,-12,-12, -2, -2, -1, -1, -1, 0}}, /* 1 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, 2 */ - {{-12,-13,-14,-16,-16,-16,-15,-14,-13,-12,-12, -6, -3, -1, -1, -1, 0}}, /* 2 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, 3 */ - {{-15,-15,-15,-16,-16,-16,-16,-14,-13,-13,-13,-10, -4, -2, -1, -1, 0}}, /* 3 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, *//* 4 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-13,-11, -7 -3, -1, -1 , 0}}, /* 4 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, 5 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-13,-11, -7 -3, -1, -1 , 0}}, /* 5 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, 6 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -8, -4, -2, -2, 0}}, /* 6 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, 7 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 7 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, 8 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 8 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, 9 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 9 */ - -/* {{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, 10 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 10 */ -}; - -static const vp_adjblock _vp_tonemask_adj_otherblock[12]={ - /* 63 125 250 500 1 2 4 8 16 */ - - {{ -3, -8,-13,-15,-10,-10, -9, -9, -9, -9, -9, 1, 1, 1, 1, 1, 1}}, /* -1 */ - -/* {{-20,-20,-20,-20,-14,-12,-10, -8, -4, 0, 0, 10, 0, 0, 0, 0, 0}}, 0 */ - {{ -4,-10,-14,-16,-14,-13,-12,-12,-11,-11,-10, 0, 0, 0, 0, 0, 0}}, /* 0 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 5, 0, 0, 0, 0, 0}}, 1 */ - {{ -6,-12,-14,-16,-15,-15,-14,-13,-13,-12,-12, -2, -2, -1, 0, 0, 0}}, /* 1 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, 2 */ - {{-12,-13,-14,-16,-16,-16,-15,-14,-13,-12,-12, -5, -2, -1, 0, 0, 0}}, /* 2 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, 3 */ - {{-15,-15,-15,-16,-16,-16,-16,-14,-13,-13,-13,-10, -4, -2, 0, 0, 0}}, /* 3 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, 4 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-13,-11, -7 -3, -1, -1 , 0}}, /* 4 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, 5 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-13,-11, -7 -3, -1, -1 , 0}}, /* 5 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, 6 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -8, -4, -2, -2, 0}}, /* 6 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, 7 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 7 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, 8 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 8 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, 9 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 9 */ - -/* {{-20,-20,-20,-20,-20,-18,-16,-14,-10, 0, 0, 0, 0, 0, 0, 0, 0}}, 10 */ - {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 10 */ -}; - -/* noise bias (transition block) */ -static const noise3 _psy_noisebias_trans[12]={ - /* 63 125 250 500 1k 2k 4k 8k 16k*/ - /* -1 */ - {{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20}, - {-30,-30,-30,-30,-26,-20,-16, -8, -6, -6, -2, 2, 2, 3, 6, 6, 15}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}}, - /* 0 - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 10}, - {-30,-30,-30,-30,-26,-22,-20,-14, -8, -4, 0, 0, 0, 0, 2, 4, 10}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -4, -4, -4, -2}}},*/ - {{{-15,-15,-15,-15,-15,-12, -6, -4, 0, 2, 4, 4, 5, 5, 5, 8, 10}, - {-30,-30,-30,-30,-26,-22,-20,-14, -8, -4, 0, 0, 0, 0, 2, 3, 6}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -4, -4, -4, -2}}}, - /* 1 - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 10}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2, 0, 2, 8}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6, -4}}},*/ - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 10}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2, 0, 1, 4}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6, -4}}}, - /* 2 - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 2, 2, 4, 4, 5, 6, 10}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, -2, -2, -2, 0, 2, 6}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}}, */ - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 2, 2, 4, 4, 5, 6, 10}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -2, -1, 0, 3}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -7, -4}}}, - /* 3 - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 2, 2, 4, 4, 4, 5, 8}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -1, 1, 6}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},*/ - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 2, 2, 4, 4, 4, 5, 8}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -2, 0, 2}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}}, - /* 4 - {{{-20,-20,-20,-20,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -1, 1, 5}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},*/ - {{{-20,-20,-20,-20,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -3, -3, -3, -3, -2, -1, 1}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}}, - /* 5 - {{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7}, - {-32,-32,-32,-32,-28,-24,-22,-16,-12, -6, -4, -4, -4, -4, -2, -1, 2}, - {-34,-34,-34,-34,-30,-24,-24,-18,-14,-12,-12,-12,-12,-10,-10, -9, -5}}}, */ - {{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7}, - {-32,-32,-32,-32,-28,-24,-22,-16,-12, -6, -4, -4, -4, -4, -3, -1, 0}, - {-34,-34,-34,-34,-30,-24,-24,-18,-14,-12,-12,-12,-12,-10,-10, -9, -5}}}, - /* 6 - {{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7}, - {-32,-32,-32,-32,-28,-24,-24,-18,-14, -8, -6, -6, -6, -6, -4, -2, 1}, - {-34,-34,-34,-34,-30,-26,-24,-18,-17,-15,-15,-15,-15,-13,-13,-12, -8}}},*/ - {{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7}, - {-32,-32,-32,-32,-28,-24,-24,-18,-14, -8, -6, -6, -6, -6, -5, -2, 0}, - {-34,-34,-34,-34,-30,-26,-26,-24,-22,-19,-19,-19,-19,-18,-17,-16,-12}}}, - /* 7 - {{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7}, - {-32,-32,-32,-32,-28,-24,-24,-18,-14,-12,-10, -8, -8, -8, -6, -4, 0}, - {-34,-34,-34,-34,-30,-26,-26,-24,-22,-19,-19,-19,-19,-18,-17,-16,-12}}},*/ - {{{-24,-24,-24,-24,-20,-18,-14, -8, -1, 1, 1, 1, 2, 3, 3, 4, 7}, - {-32,-32,-32,-32,-28,-24,-24,-24,-18,-14,-12,-10,-10,-10, -8, -6, -2}, - {-34,-34,-34,-34,-30,-26,-26,-26,-24,-24,-24,-24,-24,-24,-24,-20,-16}}}, - /* 8 - {{{-24,-24,-24,-24,-22,-20,-15,-10, -8, -2, 0, 0, 0, 1, 2, 3, 7}, - {-36,-36,-36,-36,-30,-30,-30,-24,-18,-14,-12,-10,-10,-10, -8, -6, -2}, - {-36,-36,-36,-36,-34,-30,-28,-26,-24,-24,-24,-24,-24,-24,-24,-20,-16}}},*/ - {{{-24,-24,-24,-24,-22,-20,-15,-10, -8, -2, 0, 0, 0, 1, 2, 3, 7}, - {-36,-36,-36,-36,-30,-30,-30,-24,-20,-16,-16,-16,-16,-14,-12,-10, -7}, - {-36,-36,-36,-36,-34,-30,-28,-26,-24,-30,-30,-30,-30,-30,-30,-24,-20}}}, - /* 9 - {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2, 2}, - {-36,-36,-36,-36,-34,-32,-32,-28,-20,-16,-16,-16,-16,-14,-12,-10, -7}, - {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-24,-20}}},*/ - {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2, 2}, - {-38,-38,-38,-38,-36,-34,-34,-30,-24,-20,-20,-20,-20,-18,-16,-12,-10}, - {-40,-40,-40,-40,-40,-40,-40,-38,-35,-35,-35,-35,-35,-35,-35,-35,-30}}}, - /* 10 */ - {{{-30,-30,-30,-30,-30,-30,-30,-28,-20,-14,-14,-14,-14,-14,-14,-12,-10}, - {-40,-40,-40,-40,-40,-40,-40,-40,-35,-30,-30,-30,-30,-30,-30,-30,-20}, - {-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40}}}, -}; - -/* noise bias (long block) */ -static const noise3 _psy_noisebias_long[12]={ - /*63 125 250 500 1k 2k 4k 8k 16k*/ - /* -1 */ - {{{-10,-10,-10,-10,-10, -4, 0, 0, 0, 6, 6, 6, 6, 10, 10, 12, 20}, - {-20,-20,-20,-20,-20,-20,-10, -2, 0, 0, 0, 0, 0, 2, 4, 6, 15}, - {-20,-20,-20,-20,-20,-20,-20,-10, -6, -6, -6, -6, -6, -4, -4, -4, -2}}}, - - /* 0 */ - /* {{{-10,-10,-10,-10,-10,-10, -8, 2, 2, 2, 4, 4, 5, 5, 5, 8, 10}, - {-20,-20,-20,-20,-20,-20,-20,-14, -6, 0, 0, 0, 0, 0, 2, 4, 10}, - {-20,-20,-20,-20,-20,-20,-20,-14, -8, -6, -6, -6, -6, -4, -4, -4, -2}}},*/ - {{{-10,-10,-10,-10,-10,-10, -8, 2, 2, 2, 4, 4, 5, 5, 5, 8, 10}, - {-20,-20,-20,-20,-20,-20,-20,-14, -6, 0, 0, 0, 0, 0, 2, 3, 6}, - {-20,-20,-20,-20,-20,-20,-20,-14, -8, -6, -6, -6, -6, -4, -4, -4, -2}}}, - /* 1 */ - /* {{{-10,-10,-10,-10,-10,-10, -8, -4, 0, 2, 4, 4, 5, 5, 5, 8, 10}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -2, -2, -2, -2, 0, 2, 8}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6, -4}}},*/ - {{{-10,-10,-10,-10,-10,-10, -8, -4, 0, 2, 4, 4, 5, 5, 5, 8, 10}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -2, -2, -2, -2, 0, 1, 4}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -8, -8, -8, -8, -6, -6, -6, -4}}}, - /* 2 */ - /* {{{-10,-10,-10,-10,-10,-10,-10, -8, 0, 2, 2, 2, 4, 4, 5, 6, 10}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -2, -2, -2, -2, 0, 2, 6}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},*/ - {{{-10,-10,-10,-10,-10,-10,-10, -8, 0, 2, 2, 2, 4, 4, 5, 6, 10}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -2, -1, 0, 3}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}}, - /* 3 */ - /* {{{-10,-10,-10,-10,-10,-10,-10, -8, 0, 2, 2, 2, 4, 4, 4, 5, 8}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -1, 1, 6}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},*/ - {{{-10,-10,-10,-10,-10,-10,-10, -8, 0, 2, 2, 2, 4, 4, 4, 5, 8}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -2, 0, 2}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -5}}}, - /* 4 */ - /* {{{-15,-15,-15,-15,-15,-15,-15,-10, -4, 1, 1, 1, 2, 3, 3, 4, 7}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -1, 1, 5}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -4}}},*/ - {{{-15,-15,-15,-15,-15,-15,-15,-10, -4, 1, 1, 1, 2, 3, 3, 4, 7}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10, -4, -3, -3, -3, -3, -2, -1, 1}, - {-20,-20,-20,-20,-20,-20,-20,-14,-10,-10,-10,-10,-10, -8, -8, -8, -7}}}, - /* 5 */ - /* {{{-15,-15,-15,-15,-15,-15,-15,-10, -4, 1, 1, 1, 2, 3, 3, 4, 7}, - {-22,-22,-22,-22,-22,-22,-22,-16,-12, -6, -4, -4, -4, -4, -2, -1, 2}, - {-24,-24,-24,-24,-24,-24,-24,-18,-14,-12,-12,-12,-12,-10,-10, -9, -5}}},*/ - {{{-15,-15,-15,-15,-15,-15,-15,-10, -4, 1, 1, 1, 2, 3, 3, 4, 7}, - {-22,-22,-22,-22,-22,-22,-22,-16,-12, -6, -4, -4, -4, -4, -3, -1, 0}, - {-24,-24,-24,-24,-24,-24,-24,-18,-14,-12,-12,-12,-12,-10,-10, -9, -8}}}, - /* 6 */ - /* {{{-15,-15,-15,-15,-15,-15,-15,-10, -4, 1, 1, 1, 2, 3, 3, 4, 7}, - {-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -6, -6, -6, -6, -4, -2, 1}, - {-26,-26,-26,-26,-26,-26,-26,-18,-16,-15,-15,-15,-15,-13,-13,-12, -8}}},*/ - {{{-15,-15,-15,-15,-15,-15,-15,-10, -4, 1, 1, 1, 2, 3, 3, 4, 7}, - {-24,-24,-24,-24,-24,-24,-24,-18,-14, -8, -6, -6, -6, -6, -5, -2, 0}, - {-26,-26,-26,-26,-26,-26,-26,-18,-16,-15,-15,-15,-15,-13,-13,-12,-10}}}, - /* 7 */ - {{{-15,-15,-15,-15,-15,-15,-15,-10, -4, 1, 1, 1, 2, 3, 3, 4, 7}, - {-24,-24,-24,-24,-24,-24,-24,-18,-14,-10, -8, -8, -8, -8, -6, -4, 0}, - {-26,-26,-26,-26,-26,-26,-26,-22,-20,-19,-19,-19,-19,-18,-17,-16,-12}}}, - /* 8 */ - {{{-15,-15,-15,-15,-15,-15,-15,-10, -4, 0, 0, 0, 0, 1, 2, 3, 7}, - {-26,-26,-26,-26,-26,-26,-26,-20,-16,-12,-10,-10,-10,-10, -8, -6, -2}, - {-28,-28,-28,-28,-28,-28,-28,-26,-24,-24,-24,-24,-24,-24,-24,-20,-16}}}, - /* 9 */ - {{{-22,-22,-22,-22,-22,-22,-22,-18,-14, -8, -4, -4, -4, -4, -4, -2, 2}, - {-26,-26,-26,-26,-26,-26,-26,-22,-18,-16,-16,-16,-16,-14,-12,-10, -7}, - {-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-24,-20}}}, - /* 10 */ - {{{-24,-24,-24,-24,-24,-24,-24,-24,-24,-18,-14,-14,-14,-14,-14,-12,-10}, - {-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-30,-20}, - {-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40}}}, -}; - -/* noise bias (impulse block) */ -static const noise3 _psy_noisebias_impulse[12]={ - /* 63 125 250 500 1k 2k 4k 8k 16k*/ - /* -1 */ - {{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20}, - {-30,-30,-30,-30,-26,-20,-16, -8, -6, -6, -2, 2, 2, 3, 6, 6, 15}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}}, - - /* 0 */ - /* {{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 4, 8, 8, 8, 10, 12, 14, 20}, - {-30,-30,-30,-30,-26,-22,-20,-14, -6, -2, 0, 0, 0, 0, 2, 4, 10}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}},*/ - {{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 4, 8, 8, 8, 10, 12, 14, 20}, - {-30,-30,-30,-30,-26,-22,-20,-14, -6, -2, 0, 0, 0, 0, 2, 3, 6}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}}, - /* 1 */ - {{{-12,-12,-12,-12,-12, -8, -6, -4, 0, 4, 4, 4, 4, 10, 12, 14, 20}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -4, -4, -2, -2, -2, -2, 2}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8,-10,-10, -8, -8, -8, -6, -4}}}, - /* 2 */ - {{{-14,-14,-14,-14,-14,-10, -8, -6, -2, 2, 2, 2, 2, 8, 10, 10, 16}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2, 0}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10,-10,-10, -8, -4}}}, - /* 3 */ - {{{-14,-14,-14,-14,-14,-10, -8, -6, -2, 2, 2, 2, 2, 6, 8, 8, 14}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2, 0}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10,-10,-10, -8, -4}}}, - /* 4 */ - {{{-16,-16,-16,-16,-16,-12,-10, -6, -2, 0, 0, 0, 0, 4, 6, 6, 12}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -4, -4, -4, -2, 0}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10,-10,-10,-10,-10,-10,-10, -8, -4}}}, - /* 5 */ - {{{-20,-20,-20,-20,-20,-18,-14,-10, -4, 0, 0, 0, 0, 4, 4, 6, 11}, - {-32,-32,-32,-32,-28,-24,-22,-16,-10, -6, -8, -8, -6, -6, -6, -4, -2}, - {-34,-34,-34,-34,-30,-26,-24,-18,-14,-12,-12,-12,-12,-12,-10, -9, -5}}}, - /* 6 - {{{-20,-20,-20,-20,-20,-18,-14,-10, -4, 0, 0, 0, 0, 4, 4, 6, 11}, - {-34,-34,-34,-34,-30,-30,-24,-20,-12,-12,-14,-14,-10, -9, -8, -6, -4}, - {-34,-34,-34,-34,-34,-30,-26,-20,-16,-15,-15,-15,-15,-15,-13,-12, -8}}},*/ - {{{-20,-20,-20,-20,-20,-18,-14,-10, -4, 0, 0, 0, 0, 4, 4, 6, 11}, - {-34,-34,-34,-34,-30,-30,-30,-24,-16,-16,-16,-16,-16,-16,-14,-14,-12}, - {-36,-36,-36,-36,-36,-34,-28,-24,-20,-20,-20,-20,-20,-20,-20,-18,-16}}}, - /* 7 */ - /* {{{-22,-22,-22,-22,-22,-20,-14,-10, -6, 0, 0, 0, 0, 4, 4, 6, 11}, - {-34,-34,-34,-34,-30,-30,-24,-20,-14,-14,-16,-16,-14,-12,-10,-10,-10}, - {-34,-34,-34,-34,-32,-32,-30,-24,-20,-19,-19,-19,-19,-19,-17,-16,-12}}},*/ - {{{-22,-22,-22,-22,-22,-20,-14,-10, -6, 0, 0, 0, 0, 4, 4, 6, 11}, - {-34,-34,-34,-34,-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-24,-22}, - {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-30,-24}}}, - /* 8 */ - /* {{{-24,-24,-24,-24,-24,-22,-14,-10, -6, -1, -1, -1, -1, 3, 3, 5, 10}, - {-34,-34,-34,-34,-30,-30,-30,-24,-20,-20,-20,-20,-20,-18,-16,-16,-14}, - {-36,-36,-36,-36,-36,-34,-28,-24,-24,-24,-24,-24,-24,-24,-24,-20,-16}}},*/ - {{{-24,-24,-24,-24,-24,-22,-14,-10, -6, -1, -1, -1, -1, 3, 3, 5, 10}, - {-34,-34,-34,-34,-34,-32,-32,-30,-26,-26,-26,-26,-26,-26,-26,-26,-24}, - {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-30,-24}}}, - /* 9 */ - /* {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2, 2}, - {-36,-36,-36,-36,-34,-32,-32,-30,-26,-26,-26,-26,-26,-22,-20,-20,-18}, - {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-24,-20}}},*/ - {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -4, -4, -4, -4, -4, -2, 2}, - {-36,-36,-36,-36,-34,-32,-32,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26}, - {-40,-40,-40,-40,-40,-40,-40,-32,-30,-30,-30,-30,-30,-30,-30,-24,-20}}}, - /* 10 */ - {{{-30,-30,-30,-30,-30,-26,-24,-24,-24,-20,-16,-16,-16,-16,-16,-14,-12}, - {-40,-40,-40,-40,-40,-40,-40,-40,-35,-30,-30,-30,-30,-30,-30,-30,-26}, - {-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40}}}, -}; - -/* noise bias (padding block) */ -static const noise3 _psy_noisebias_padding[12]={ - /* 63 125 250 500 1k 2k 4k 8k 16k*/ - - /* -1 */ - {{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20}, - {-30,-30,-30,-30,-26,-20,-16, -8, -6, -6, -2, 2, 2, 3, 6, 6, 15}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -4, -2}}}, - - /* 0 */ - {{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -2, 2, 3, 6, 6, 8, 10}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, -4, -4, -4, -4, -2, 0, 2}}}, - /* 1 */ - {{{-12,-12,-12,-12,-12, -8, -6, -4, 0, 4, 4, 4, 4, 10, 12, 14, 20}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, 0, 0, 0, 2, 2, 4, 8}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -6, -6, -6, -6, -4, -2, 0}}}, - /* 2 */ - /* {{{-14,-14,-14,-14,-14,-10, -8, -6, -2, 2, 2, 2, 2, 8, 10, 10, 16}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -4, 0, 0, 0, 2, 2, 4, 8}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -8, -6, -4, -2}}},*/ - {{{-14,-14,-14,-14,-14,-10, -8, -6, -2, 2, 2, 2, 2, 8, 10, 10, 16}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -1, -1, -1, 0, 0, 2, 6}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -8, -6, -4, -2}}}, - /* 3 */ - {{{-14,-14,-14,-14,-14,-10, -8, -6, -2, 2, 2, 2, 2, 6, 8, 8, 14}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -1, -1, -1, 0, 0, 2, 6}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -8, -6, -4, -2}}}, - /* 4 */ - {{{-16,-16,-16,-16,-16,-12,-10, -6, -2, 0, 0, 0, 0, 4, 6, 6, 12}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -6, -1, -1, -1, -1, 0, 2, 6}, - {-30,-30,-30,-30,-26,-22,-20,-14,-10, -8, -8, -8, -8, -8, -6, -4, -2}}}, - /* 5 */ - {{{-20,-20,-20,-20,-20,-18,-14,-10, -4, 0, 0, 0, 0, 4, 6, 6, 12}, - {-32,-32,-32,-32,-28,-24,-22,-16,-12, -6, -3, -3, -3, -3, -2, 0, 4}, - {-34,-34,-34,-34,-30,-26,-24,-18,-14,-10,-10,-10,-10,-10, -8, -5, -3}}}, - /* 6 */ - {{{-20,-20,-20,-20,-20,-18,-14,-10, -4, 0, 0, 0, 0, 4, 6, 6, 12}, - {-34,-34,-34,-34,-30,-30,-24,-20,-14, -8, -4, -4, -4, -4, -3, -1, 4}, - {-34,-34,-34,-34,-34,-30,-26,-20,-16,-13,-13,-13,-13,-13,-11, -8, -6}}}, - /* 7 */ - {{{-20,-20,-20,-20,-20,-18,-14,-10, -4, 0, 0, 0, 0, 4, 6, 6, 12}, - {-34,-34,-34,-34,-30,-30,-30,-24,-16,-10, -8, -6, -6, -6, -5, -3, 1}, - {-34,-34,-34,-34,-32,-32,-28,-22,-18,-16,-16,-16,-16,-16,-14,-12,-10}}}, - /* 8 */ - {{{-22,-22,-22,-22,-22,-20,-14,-10, -4, 0, 0, 0, 0, 3, 5, 5, 11}, - {-34,-34,-34,-34,-30,-30,-30,-24,-16,-12,-10, -8, -8, -8, -7, -5, -2}, - {-36,-36,-36,-36,-36,-34,-28,-22,-20,-20,-20,-20,-20,-20,-20,-16,-14}}}, - /* 9 */ - {{{-28,-28,-28,-28,-28,-28,-28,-20,-14, -8, -2, -2, -2, -2, 0, 2, 6}, - {-36,-36,-36,-36,-34,-32,-32,-24,-16,-12,-12,-12,-12,-12,-10, -8, -5}, - {-40,-40,-40,-40,-40,-40,-40,-32,-26,-24,-24,-24,-24,-24,-24,-20,-18}}}, - /* 10 */ - {{{-30,-30,-30,-30,-30,-26,-24,-24,-24,-20,-12,-12,-12,-12,-12,-10, -8}, - {-40,-40,-40,-40,-40,-40,-40,-40,-35,-30,-25,-25,-25,-25,-25,-25,-15}, - {-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40,-40}}}, -}; - - -static const noiseguard _psy_noiseguards_44[4]={ - {3,3,15}, - {3,3,15}, - {10,10,100}, - {10,10,100}, -}; - -static const int _psy_tone_suppress[12]={ - -20,-20,-20,-20,-20,-24,-30,-40,-40,-45,-45,-45, -}; -static const int _psy_tone_0dB[12]={ - 90,90,95,95,95,95,105,105,105,105,105,105, -}; -static const int _psy_noise_suppress[12]={ - -20,-20,-24,-24,-24,-24,-30,-40,-40,-45,-45,-45, -}; - -static const vorbis_info_psy _psy_info_template={ - /* blockflag */ - -1, - /* ath_adjatt, ath_maxatt */ - -140.,-140., - /* tonemask att boost/decay,suppr,curves */ - {0.f,0.f,0.f}, 0.,0., -40.f, {0.}, - - /*noisemaskp,supp, low/high window, low/hi guard, minimum */ - 1, -0.f, .5f, .5f, 0,0,0, - /* noiseoffset*3, noisecompand, max_curve_dB */ - {{-1},{-1},{-1}},{-1},105.f, - /* noise normalization - noise_p, start, partition, thresh. */ - 0,-1,-1,0., -}; - -/* ath ****************/ - -static const int _psy_ath_floater[12]={ - -100,-100,-100,-100,-100,-100,-105,-105,-105,-105,-110,-120, -}; -static const int _psy_ath_abs[12]={ - -130,-130,-130,-130,-140,-140,-140,-140,-140,-140,-140,-150, -}; - -/* stereo setup. These don't map directly to quality level, there's - an additional indirection as several of the below may be used in a - single bitmanaged stream - -****************/ - -/* various stereo possibilities */ - -/* stereo mode by base quality level */ -static const adj_stereo _psy_stereo_modes_44[12]={ - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -1 */ - {{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 2, 1, 0, 0, 0, 0}, - { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 4, 3}, - { 1, 2, 3, 4, 4, 4, 4, 4, 4, 5, 6, 7, 8, 8, 8}, - { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}}, - -/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 */ - {{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0}, - { 8, 8, 8, 8, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 3}, - { 1, 2, 3, 4, 4, 5, 6, 6, 6, 6, 6, 8, 8, 8, 8}, - { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}}, - - - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 */ - {{ 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, 0, 0, 0, 0}, - { 8, 8, 8, 8, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 3}, - { 1, 2, 3, 4, 4, 5, 6, 6, 6, 6, 6, 8, 8, 8, 8}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - - - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 */ - {{ 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 0, 0, 0, 0, 0}, - { 8, 8, 6, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 2, 1}, - { 3, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 */ - {{ 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}, - { 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1}, - { 4, 4, 5, 6, 6, 6, 6, 6, 8, 8, 10, 10, 10, 10, 10}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 4 */ - {{ 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 2, 1, 0}, - { 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 5 */ - {{ 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0}, - { 6, 7, 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 6 */ - {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 3, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 7 */ - {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 3, 3, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 8 */ - {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 9 */ - {{ 0, 0, 0, 0, 0, 0, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 10 */ - {{ 0, 0, 0, 0, 0, 0, 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, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, -}; - -/* tone master attenuation by base quality mode and bitrate tweak */ -static const att3 _psy_tone_masteratt_44[12]={ - {{ 35, 21, 9}, 0, 0}, /* -1 */ - {{ 30, 20, 8}, -2, 1.25}, /* 0 */ - /* {{ 25, 14, 4}, 0, 0}, *//* 1 */ - {{ 25, 12, 2}, 0, 0}, /* 1 */ - /* {{ 20, 10, -2}, 0, 0}, *//* 2 */ - {{ 20, 9, -3}, 0, 0}, /* 2 */ - {{ 20, 9, -4}, 0, 0}, /* 3 */ - {{ 20, 9, -4}, 0, 0}, /* 4 */ - {{ 20, 6, -6}, 0, 0}, /* 5 */ - {{ 20, 3, -10}, 0, 0}, /* 6 */ - {{ 18, 1, -14}, 0, 0}, /* 7 */ - {{ 18, 0, -16}, 0, 0}, /* 8 */ - {{ 18, -2, -16}, 0, 0}, /* 9 */ - {{ 12, -2, -20}, 0, 0}, /* 10 */ -}; - -/* lowpass by mode **************/ -static const double _psy_lowpass_44[12]={ - /* 15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999. */ - 13.9,15.1,15.8,16.5,17.2,18.9,20.1,48.,999.,999.,999.,999. -}; - -/* noise normalization **********/ - -static const int _noise_start_short_44[11]={ - /* 16,16,16,16,32,32,9999,9999,9999,9999 */ - 32,16,16,16,32,9999,9999,9999,9999,9999,9999 -}; -static const int _noise_start_long_44[11]={ - /* 128,128,128,256,512,512,9999,9999,9999,9999 */ - 256,128,128,256,512,9999,9999,9999,9999,9999,9999 -}; - -static const int _noise_part_short_44[11]={ - 8,8,8,8,8,8,8,8,8,8,8 -}; -static const int _noise_part_long_44[11]={ - 32,32,32,32,32,32,32,32,32,32,32 -}; - -static const double _noise_thresh_44[11]={ - /* .2,.2,.3,.4,.5,.5,9999.,9999.,9999.,9999., */ - .2,.2,.2,.4,.6,9999.,9999.,9999.,9999.,9999.,9999., -}; - -static const double _noise_thresh_5only[2]={ - .5,.5, -}; diff --git a/Engine/lib/libvorbis/lib/modes/psych_8.h b/Engine/lib/libvorbis/lib/modes/psych_8.h deleted file mode 100644 index a19817f76..000000000 --- a/Engine/lib/libvorbis/lib/modes/psych_8.h +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: 8kHz psychoacoustic settings - - ********************************************************************/ - -static const att3 _psy_tone_masteratt_8[3]={ - {{ 32, 25, 12}, 0, 0}, /* 0 */ - {{ 30, 25, 12}, 0, 0}, /* 0 */ - {{ 20, 0, -14}, 0, 0}, /* 0 */ -}; - -static const vp_adjblock _vp_tonemask_adj_8[3]={ - /* adjust for mode zero */ - /* 63 125 250 500 1 2 4 8 16 */ - {{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0,10, 0, 0,99,99,99}}, /* 1 */ - {{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0,10, 0, 0,99,99,99}}, /* 1 */ - {{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0, 0, 0, 0,99,99,99}}, /* 1 */ -}; - - -static const noise3 _psy_noisebias_8[3]={ - /* 63 125 250 500 1k 2k 4k 8k 16k*/ - {{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 8, 8, 8, 10, 10, 99, 99, 99}, - {-10,-10,-10,-10, -5, -5, -5, 0, 0, 4, 4, 4, 4, 4, 99, 99, 99}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, - - {{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 8, 8, 8, 10, 10, 99, 99, 99}, - {-10,-10,-10,-10,-10,-10, -5, -5, -5, 0, 0, 0, 0, 0, 99, 99, 99}, - {-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, - - {{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 99, 99, 99}, - {-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10, 99, 99, 99}, - {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}}, -}; - -/* stereo mode by base quality level */ -static const adj_stereo _psy_stereo_modes_8[3]={ - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ - {{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - {{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, - {{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, -}; - -static const noiseguard _psy_noiseguards_8[2]={ - {10,10,-1}, - {10,10,-1}, -}; - -static const compandblock _psy_compand_8[2]={ - {{ - 0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ - 8, 8, 9, 9,10,10,11, 11, /* 15dB */ - 12,12,13,13,14,14,15, 15, /* 23dB */ - 16,16,17,17,17,18,18, 19, /* 31dB */ - 19,19,20,21,22,23,24, 25, /* 39dB */ - }}, - {{ - 0, 1, 2, 3, 4, 5, 6, 6, /* 7dB */ - 7, 7, 6, 6, 5, 5, 4, 4, /* 15dB */ - 3, 3, 3, 4, 5, 6, 7, 8, /* 23dB */ - 9,10,11,12,13,14,15, 16, /* 31dB */ - 17,18,19,20,21,22,23, 24, /* 39dB */ - }}, -}; - -static const double _psy_lowpass_8[3]={3.,4.,4.}; -static const int _noise_start_8[2]={ - 64,64, -}; -static const int _noise_part_8[2]={ - 8,8, -}; - -static const int _psy_ath_floater_8[3]={ - -100,-100,-105, -}; - -static const int _psy_ath_abs_8[3]={ - -130,-130,-140, -}; diff --git a/Engine/lib/libvorbis/lib/modes/residue_16.h b/Engine/lib/libvorbis/lib/modes/residue_16.h deleted file mode 100644 index 15e161c86..000000000 --- a/Engine/lib/libvorbis/lib/modes/residue_16.h +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************** - * * - * This FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: toplevel residue templates 16/22kHz - - ********************************************************************/ - -/***** residue backends *********************************************/ - -static const static_bookblock _resbook_16s_0={ - { - {0}, - {0,0,&_16c0_s_p1_0}, - {0}, - {0,0,&_16c0_s_p3_0}, - {0,0,&_16c0_s_p4_0}, - {0,0,&_16c0_s_p5_0}, - {0,0,&_16c0_s_p6_0}, - {&_16c0_s_p7_0,&_16c0_s_p7_1}, - {&_16c0_s_p8_0,&_16c0_s_p8_1}, - {&_16c0_s_p9_0,&_16c0_s_p9_1,&_16c0_s_p9_2} - } -}; -static const static_bookblock _resbook_16s_1={ - { - {0}, - {0,0,&_16c1_s_p1_0}, - {0}, - {0,0,&_16c1_s_p3_0}, - {0,0,&_16c1_s_p4_0}, - {0,0,&_16c1_s_p5_0}, - {0,0,&_16c1_s_p6_0}, - {&_16c1_s_p7_0,&_16c1_s_p7_1}, - {&_16c1_s_p8_0,&_16c1_s_p8_1}, - {&_16c1_s_p9_0,&_16c1_s_p9_1,&_16c1_s_p9_2} - } -}; -static const static_bookblock _resbook_16s_2={ - { - {0}, - {0,0,&_16c2_s_p1_0}, - {0,0,&_16c2_s_p2_0}, - {0,0,&_16c2_s_p3_0}, - {0,0,&_16c2_s_p4_0}, - {&_16c2_s_p5_0,&_16c2_s_p5_1}, - {&_16c2_s_p6_0,&_16c2_s_p6_1}, - {&_16c2_s_p7_0,&_16c2_s_p7_1}, - {&_16c2_s_p8_0,&_16c2_s_p8_1}, - {&_16c2_s_p9_0,&_16c2_s_p9_1,&_16c2_s_p9_2} - } -}; - -static const vorbis_residue_template _res_16s_0[]={ - {2,0,32, &_residue_44_mid, - &_huff_book__16c0_s_single,&_huff_book__16c0_s_single, - &_resbook_16s_0,&_resbook_16s_0}, -}; -static const vorbis_residue_template _res_16s_1[]={ - {2,0,32, &_residue_44_mid, - &_huff_book__16c1_s_short,&_huff_book__16c1_s_short, - &_resbook_16s_1,&_resbook_16s_1}, - - {2,0,32, &_residue_44_mid, - &_huff_book__16c1_s_long,&_huff_book__16c1_s_long, - &_resbook_16s_1,&_resbook_16s_1} -}; -static const vorbis_residue_template _res_16s_2[]={ - {2,0,32, &_residue_44_high, - &_huff_book__16c2_s_short,&_huff_book__16c2_s_short, - &_resbook_16s_2,&_resbook_16s_2}, - - {2,0,32, &_residue_44_high, - &_huff_book__16c2_s_long,&_huff_book__16c2_s_long, - &_resbook_16s_2,&_resbook_16s_2} -}; - -static const vorbis_mapping_template _mapres_template_16_stereo[3]={ - { _map_nominal, _res_16s_0 }, /* 0 */ - { _map_nominal, _res_16s_1 }, /* 1 */ - { _map_nominal, _res_16s_2 }, /* 2 */ -}; - -static const static_bookblock _resbook_16u_0={ - { - {0}, - {0,0,&_16u0__p1_0}, - {0,0,&_16u0__p2_0}, - {0,0,&_16u0__p3_0}, - {0,0,&_16u0__p4_0}, - {0,0,&_16u0__p5_0}, - {&_16u0__p6_0,&_16u0__p6_1}, - {&_16u0__p7_0,&_16u0__p7_1,&_16u0__p7_2} - } -}; -static const static_bookblock _resbook_16u_1={ - { - {0}, - {0,0,&_16u1__p1_0}, - {0,0,&_16u1__p2_0}, - {0,0,&_16u1__p3_0}, - {0,0,&_16u1__p4_0}, - {0,0,&_16u1__p5_0}, - {0,0,&_16u1__p6_0}, - {&_16u1__p7_0,&_16u1__p7_1}, - {&_16u1__p8_0,&_16u1__p8_1}, - {&_16u1__p9_0,&_16u1__p9_1,&_16u1__p9_2} - } -}; -static const static_bookblock _resbook_16u_2={ - { - {0}, - {0,0,&_16u2_p1_0}, - {0,0,&_16u2_p2_0}, - {0,0,&_16u2_p3_0}, - {0,0,&_16u2_p4_0}, - {&_16u2_p5_0,&_16u2_p5_1}, - {&_16u2_p6_0,&_16u2_p6_1}, - {&_16u2_p7_0,&_16u2_p7_1}, - {&_16u2_p8_0,&_16u2_p8_1}, - {&_16u2_p9_0,&_16u2_p9_1,&_16u2_p9_2} - } -}; - -static const vorbis_residue_template _res_16u_0[]={ - {1,0,32, &_residue_44_low_un, - &_huff_book__16u0__single,&_huff_book__16u0__single, - &_resbook_16u_0,&_resbook_16u_0}, -}; -static const vorbis_residue_template _res_16u_1[]={ - {1,0,32, &_residue_44_mid_un, - &_huff_book__16u1__short,&_huff_book__16u1__short, - &_resbook_16u_1,&_resbook_16u_1}, - - {1,0,32, &_residue_44_mid_un, - &_huff_book__16u1__long,&_huff_book__16u1__long, - &_resbook_16u_1,&_resbook_16u_1} -}; -static const vorbis_residue_template _res_16u_2[]={ - {1,0,32, &_residue_44_hi_un, - &_huff_book__16u2__short,&_huff_book__16u2__short, - &_resbook_16u_2,&_resbook_16u_2}, - - {1,0,32, &_residue_44_hi_un, - &_huff_book__16u2__long,&_huff_book__16u2__long, - &_resbook_16u_2,&_resbook_16u_2} -}; - - -static const vorbis_mapping_template _mapres_template_16_uncoupled[3]={ - { _map_nominal_u, _res_16u_0 }, /* 0 */ - { _map_nominal_u, _res_16u_1 }, /* 1 */ - { _map_nominal_u, _res_16u_2 }, /* 2 */ -}; diff --git a/Engine/lib/libvorbis/lib/modes/residue_44.h b/Engine/lib/libvorbis/lib/modes/residue_44.h deleted file mode 100644 index 3f982695a..000000000 --- a/Engine/lib/libvorbis/lib/modes/residue_44.h +++ /dev/null @@ -1,291 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: toplevel residue templates for 32/44.1/48kHz - - ********************************************************************/ - -#include "vorbis/codec.h" -#include "backends.h" -#include "books/coupled/res_books_stereo.h" - -/***** residue backends *********************************************/ - -static const vorbis_info_residue0 _residue_44_low={ - 0,-1, -1, 9,-1,-1, - /* 0 1 2 3 4 5 6 7 */ - {0}, - {-1}, - { 0, 1, 2, 2, 4, 8, 16, 32}, - { 0, 0, 0,999, 4, 8, 16, 32}, -}; - -static const vorbis_info_residue0 _residue_44_mid={ - 0,-1, -1, 10,-1,-1, - /* 0 1 2 3 4 5 6 7 8 */ - {0}, - {-1}, - { 0, 1, 1, 2, 2, 4, 8, 16, 32}, - { 0, 0,999, 0,999, 4, 8, 16, 32}, -}; - -static const vorbis_info_residue0 _residue_44_high={ - 0,-1, -1, 10,-1,-1, - /* 0 1 2 3 4 5 6 7 8 */ - {0}, - {-1}, - { 0, 1, 2, 4, 8, 16, 32, 71,157}, - { 0, 1, 2, 3, 4, 8, 16, 71,157}, -}; - -static const static_bookblock _resbook_44s_n1={ - { - {0},{0,0,&_44cn1_s_p1_0},{0,0,&_44cn1_s_p2_0}, - {0,0,&_44cn1_s_p3_0},{0,0,&_44cn1_s_p4_0},{0,0,&_44cn1_s_p5_0}, - {&_44cn1_s_p6_0,&_44cn1_s_p6_1},{&_44cn1_s_p7_0,&_44cn1_s_p7_1}, - {&_44cn1_s_p8_0,&_44cn1_s_p8_1,&_44cn1_s_p8_2} - } -}; -static const static_bookblock _resbook_44sm_n1={ - { - {0},{0,0,&_44cn1_sm_p1_0},{0,0,&_44cn1_sm_p2_0}, - {0,0,&_44cn1_sm_p3_0},{0,0,&_44cn1_sm_p4_0},{0,0,&_44cn1_sm_p5_0}, - {&_44cn1_sm_p6_0,&_44cn1_sm_p6_1},{&_44cn1_sm_p7_0,&_44cn1_sm_p7_1}, - {&_44cn1_sm_p8_0,&_44cn1_sm_p8_1,&_44cn1_sm_p8_2} - } -}; - -static const static_bookblock _resbook_44s_0={ - { - {0},{0,0,&_44c0_s_p1_0},{0,0,&_44c0_s_p2_0}, - {0,0,&_44c0_s_p3_0},{0,0,&_44c0_s_p4_0},{0,0,&_44c0_s_p5_0}, - {&_44c0_s_p6_0,&_44c0_s_p6_1},{&_44c0_s_p7_0,&_44c0_s_p7_1}, - {&_44c0_s_p8_0,&_44c0_s_p8_1,&_44c0_s_p8_2} - } -}; -static const static_bookblock _resbook_44sm_0={ - { - {0},{0,0,&_44c0_sm_p1_0},{0,0,&_44c0_sm_p2_0}, - {0,0,&_44c0_sm_p3_0},{0,0,&_44c0_sm_p4_0},{0,0,&_44c0_sm_p5_0}, - {&_44c0_sm_p6_0,&_44c0_sm_p6_1},{&_44c0_sm_p7_0,&_44c0_sm_p7_1}, - {&_44c0_sm_p8_0,&_44c0_sm_p8_1,&_44c0_sm_p8_2} - } -}; - -static const static_bookblock _resbook_44s_1={ - { - {0},{0,0,&_44c1_s_p1_0},{0,0,&_44c1_s_p2_0}, - {0,0,&_44c1_s_p3_0},{0,0,&_44c1_s_p4_0},{0,0,&_44c1_s_p5_0}, - {&_44c1_s_p6_0,&_44c1_s_p6_1},{&_44c1_s_p7_0,&_44c1_s_p7_1}, - {&_44c1_s_p8_0,&_44c1_s_p8_1,&_44c1_s_p8_2} - } -}; -static const static_bookblock _resbook_44sm_1={ - { - {0},{0,0,&_44c1_sm_p1_0},{0,0,&_44c1_sm_p2_0}, - {0,0,&_44c1_sm_p3_0},{0,0,&_44c1_sm_p4_0},{0,0,&_44c1_sm_p5_0}, - {&_44c1_sm_p6_0,&_44c1_sm_p6_1},{&_44c1_sm_p7_0,&_44c1_sm_p7_1}, - {&_44c1_sm_p8_0,&_44c1_sm_p8_1,&_44c1_sm_p8_2} - } -}; - -static const static_bookblock _resbook_44s_2={ - { - {0},{0,0,&_44c2_s_p1_0},{0,0,&_44c2_s_p2_0},{0,0,&_44c2_s_p3_0}, - {0,0,&_44c2_s_p4_0},{0,0,&_44c2_s_p5_0},{0,0,&_44c2_s_p6_0}, - {&_44c2_s_p7_0,&_44c2_s_p7_1},{&_44c2_s_p8_0,&_44c2_s_p8_1}, - {&_44c2_s_p9_0,&_44c2_s_p9_1,&_44c2_s_p9_2} - } -}; -static const static_bookblock _resbook_44s_3={ - { - {0},{0,0,&_44c3_s_p1_0},{0,0,&_44c3_s_p2_0},{0,0,&_44c3_s_p3_0}, - {0,0,&_44c3_s_p4_0},{0,0,&_44c3_s_p5_0},{0,0,&_44c3_s_p6_0}, - {&_44c3_s_p7_0,&_44c3_s_p7_1},{&_44c3_s_p8_0,&_44c3_s_p8_1}, - {&_44c3_s_p9_0,&_44c3_s_p9_1,&_44c3_s_p9_2} - } -}; -static const static_bookblock _resbook_44s_4={ - { - {0},{0,0,&_44c4_s_p1_0},{0,0,&_44c4_s_p2_0},{0,0,&_44c4_s_p3_0}, - {0,0,&_44c4_s_p4_0},{0,0,&_44c4_s_p5_0},{0,0,&_44c4_s_p6_0}, - {&_44c4_s_p7_0,&_44c4_s_p7_1},{&_44c4_s_p8_0,&_44c4_s_p8_1}, - {&_44c4_s_p9_0,&_44c4_s_p9_1,&_44c4_s_p9_2} - } -}; -static const static_bookblock _resbook_44s_5={ - { - {0},{0,0,&_44c5_s_p1_0},{0,0,&_44c5_s_p2_0},{0,0,&_44c5_s_p3_0}, - {0,0,&_44c5_s_p4_0},{0,0,&_44c5_s_p5_0},{0,0,&_44c5_s_p6_0}, - {&_44c5_s_p7_0,&_44c5_s_p7_1},{&_44c5_s_p8_0,&_44c5_s_p8_1}, - {&_44c5_s_p9_0,&_44c5_s_p9_1,&_44c5_s_p9_2} - } -}; -static const static_bookblock _resbook_44s_6={ - { - {0},{0,0,&_44c6_s_p1_0},{0,0,&_44c6_s_p2_0},{0,0,&_44c6_s_p3_0}, - {0,0,&_44c6_s_p4_0}, - {&_44c6_s_p5_0,&_44c6_s_p5_1}, - {&_44c6_s_p6_0,&_44c6_s_p6_1}, - {&_44c6_s_p7_0,&_44c6_s_p7_1}, - {&_44c6_s_p8_0,&_44c6_s_p8_1}, - {&_44c6_s_p9_0,&_44c6_s_p9_1,&_44c6_s_p9_2} - } -}; -static const static_bookblock _resbook_44s_7={ - { - {0},{0,0,&_44c7_s_p1_0},{0,0,&_44c7_s_p2_0},{0,0,&_44c7_s_p3_0}, - {0,0,&_44c7_s_p4_0}, - {&_44c7_s_p5_0,&_44c7_s_p5_1}, - {&_44c7_s_p6_0,&_44c7_s_p6_1}, - {&_44c7_s_p7_0,&_44c7_s_p7_1}, - {&_44c7_s_p8_0,&_44c7_s_p8_1}, - {&_44c7_s_p9_0,&_44c7_s_p9_1,&_44c7_s_p9_2} - } -}; -static const static_bookblock _resbook_44s_8={ - { - {0},{0,0,&_44c8_s_p1_0},{0,0,&_44c8_s_p2_0},{0,0,&_44c8_s_p3_0}, - {0,0,&_44c8_s_p4_0}, - {&_44c8_s_p5_0,&_44c8_s_p5_1}, - {&_44c8_s_p6_0,&_44c8_s_p6_1}, - {&_44c8_s_p7_0,&_44c8_s_p7_1}, - {&_44c8_s_p8_0,&_44c8_s_p8_1}, - {&_44c8_s_p9_0,&_44c8_s_p9_1,&_44c8_s_p9_2} - } -}; -static const static_bookblock _resbook_44s_9={ - { - {0},{0,0,&_44c9_s_p1_0},{0,0,&_44c9_s_p2_0},{0,0,&_44c9_s_p3_0}, - {0,0,&_44c9_s_p4_0}, - {&_44c9_s_p5_0,&_44c9_s_p5_1}, - {&_44c9_s_p6_0,&_44c9_s_p6_1}, - {&_44c9_s_p7_0,&_44c9_s_p7_1}, - {&_44c9_s_p8_0,&_44c9_s_p8_1}, - {&_44c9_s_p9_0,&_44c9_s_p9_1,&_44c9_s_p9_2} - } -}; - -static const vorbis_residue_template _res_44s_n1[]={ - {2,0,32, &_residue_44_low, - &_huff_book__44cn1_s_short,&_huff_book__44cn1_sm_short, - &_resbook_44s_n1,&_resbook_44sm_n1}, - - {2,0,32, &_residue_44_low, - &_huff_book__44cn1_s_long,&_huff_book__44cn1_sm_long, - &_resbook_44s_n1,&_resbook_44sm_n1} -}; -static const vorbis_residue_template _res_44s_0[]={ - {2,0,16, &_residue_44_low, - &_huff_book__44c0_s_short,&_huff_book__44c0_sm_short, - &_resbook_44s_0,&_resbook_44sm_0}, - - {2,0,32, &_residue_44_low, - &_huff_book__44c0_s_long,&_huff_book__44c0_sm_long, - &_resbook_44s_0,&_resbook_44sm_0} -}; -static const vorbis_residue_template _res_44s_1[]={ - {2,0,16, &_residue_44_low, - &_huff_book__44c1_s_short,&_huff_book__44c1_sm_short, - &_resbook_44s_1,&_resbook_44sm_1}, - - {2,0,32, &_residue_44_low, - &_huff_book__44c1_s_long,&_huff_book__44c1_sm_long, - &_resbook_44s_1,&_resbook_44sm_1} -}; - -static const vorbis_residue_template _res_44s_2[]={ - {2,0,16, &_residue_44_mid, - &_huff_book__44c2_s_short,&_huff_book__44c2_s_short, - &_resbook_44s_2,&_resbook_44s_2}, - - {2,0,32, &_residue_44_mid, - &_huff_book__44c2_s_long,&_huff_book__44c2_s_long, - &_resbook_44s_2,&_resbook_44s_2} -}; -static const vorbis_residue_template _res_44s_3[]={ - {2,0,16, &_residue_44_mid, - &_huff_book__44c3_s_short,&_huff_book__44c3_s_short, - &_resbook_44s_3,&_resbook_44s_3}, - - {2,0,32, &_residue_44_mid, - &_huff_book__44c3_s_long,&_huff_book__44c3_s_long, - &_resbook_44s_3,&_resbook_44s_3} -}; -static const vorbis_residue_template _res_44s_4[]={ - {2,0,16, &_residue_44_mid, - &_huff_book__44c4_s_short,&_huff_book__44c4_s_short, - &_resbook_44s_4,&_resbook_44s_4}, - - {2,0,32, &_residue_44_mid, - &_huff_book__44c4_s_long,&_huff_book__44c4_s_long, - &_resbook_44s_4,&_resbook_44s_4} -}; -static const vorbis_residue_template _res_44s_5[]={ - {2,0,16, &_residue_44_mid, - &_huff_book__44c5_s_short,&_huff_book__44c5_s_short, - &_resbook_44s_5,&_resbook_44s_5}, - - {2,0,32, &_residue_44_mid, - &_huff_book__44c5_s_long,&_huff_book__44c5_s_long, - &_resbook_44s_5,&_resbook_44s_5} -}; -static const vorbis_residue_template _res_44s_6[]={ - {2,0,16, &_residue_44_high, - &_huff_book__44c6_s_short,&_huff_book__44c6_s_short, - &_resbook_44s_6,&_resbook_44s_6}, - - {2,0,32, &_residue_44_high, - &_huff_book__44c6_s_long,&_huff_book__44c6_s_long, - &_resbook_44s_6,&_resbook_44s_6} -}; -static const vorbis_residue_template _res_44s_7[]={ - {2,0,16, &_residue_44_high, - &_huff_book__44c7_s_short,&_huff_book__44c7_s_short, - &_resbook_44s_7,&_resbook_44s_7}, - - {2,0,32, &_residue_44_high, - &_huff_book__44c7_s_long,&_huff_book__44c7_s_long, - &_resbook_44s_7,&_resbook_44s_7} -}; -static const vorbis_residue_template _res_44s_8[]={ - {2,0,16, &_residue_44_high, - &_huff_book__44c8_s_short,&_huff_book__44c8_s_short, - &_resbook_44s_8,&_resbook_44s_8}, - - {2,0,32, &_residue_44_high, - &_huff_book__44c8_s_long,&_huff_book__44c8_s_long, - &_resbook_44s_8,&_resbook_44s_8} -}; -static const vorbis_residue_template _res_44s_9[]={ - {2,0,16, &_residue_44_high, - &_huff_book__44c9_s_short,&_huff_book__44c9_s_short, - &_resbook_44s_9,&_resbook_44s_9}, - - {2,0,32, &_residue_44_high, - &_huff_book__44c9_s_long,&_huff_book__44c9_s_long, - &_resbook_44s_9,&_resbook_44s_9} -}; - -static const vorbis_mapping_template _mapres_template_44_stereo[]={ - { _map_nominal, _res_44s_n1 }, /* -1 */ - { _map_nominal, _res_44s_0 }, /* 0 */ - { _map_nominal, _res_44s_1 }, /* 1 */ - { _map_nominal, _res_44s_2 }, /* 2 */ - { _map_nominal, _res_44s_3 }, /* 3 */ - { _map_nominal, _res_44s_4 }, /* 4 */ - { _map_nominal, _res_44s_5 }, /* 5 */ - { _map_nominal, _res_44s_6 }, /* 6 */ - { _map_nominal, _res_44s_7 }, /* 7 */ - { _map_nominal, _res_44s_8 }, /* 8 */ - { _map_nominal, _res_44s_9 }, /* 9 */ -}; diff --git a/Engine/lib/libvorbis/lib/modes/residue_44p51.h b/Engine/lib/libvorbis/lib/modes/residue_44p51.h deleted file mode 100644 index 8ac5f65e6..000000000 --- a/Engine/lib/libvorbis/lib/modes/residue_44p51.h +++ /dev/null @@ -1,450 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: toplevel residue templates for 32/44.1/48kHz uncoupled - - ********************************************************************/ - -#include "vorbis/codec.h" -#include "backends.h" - -#include "books/coupled/res_books_51.h" - -/***** residue backends *********************************************/ - -static const vorbis_info_residue0 _residue_44p_lo={ - 0,-1, -1, 7,-1,-1, - /* 0 1 2 3 4 5 6 7 8 */ - {0}, - {-1}, - { 0, 1, 2, 7, 17, 31}, - { 0, 0, 99, 7, 17, 31}, -}; - -static const vorbis_info_residue0 _residue_44p={ - 0,-1, -1, 8,-1,-1, - /* 0 1 2 3 4 5 6 7 8 */ - {0}, - {-1}, - { 0, 1, 1, 2, 7, 17, 31}, - { 0, 0, 99, 99, 7, 17, 31}, -}; - -static const vorbis_info_residue0 _residue_44p_hi={ - 0,-1, -1, 8,-1,-1, - /* 0 1 2 3 4 5 6 7 8 */ - {0}, - {-1}, - { 0, 1, 2, 4, 7, 17, 31}, - { 0, 1, 2, 4, 7, 17, 31}, -}; - -static const vorbis_info_residue0 _residue_44p_lfe={ - 0,-1, -1, 2,-1,-1, - /* 0 1 2 3 4 5 6 7 8 */ - {0}, - {-1}, - { 32}, - { -1} -}; - -static const static_bookblock _resbook_44p_n1={ - { - {0}, - {0,&_44pn1_p1_0}, - - {&_44pn1_p2_0,&_44pn1_p2_1,0}, - {&_44pn1_p3_0,&_44pn1_p3_1,0}, - {&_44pn1_p4_0,&_44pn1_p4_1,0}, - - {&_44pn1_p5_0,&_44pn1_p5_1,&_44pn1_p4_1}, - {&_44pn1_p6_0,&_44pn1_p6_1,&_44pn1_p6_2}, - } -}; - -static const static_bookblock _resbook_44p_0={ - { - {0}, - {0,&_44p0_p1_0}, - - {&_44p0_p2_0,&_44p0_p2_1,0}, - {&_44p0_p3_0,&_44p0_p3_1,0}, - {&_44p0_p4_0,&_44p0_p4_1,0}, - - {&_44p0_p5_0,&_44p0_p5_1,&_44p0_p4_1}, - {&_44p0_p6_0,&_44p0_p6_1,&_44p0_p6_2}, - } -}; - -static const static_bookblock _resbook_44p_1={ - { - {0}, - {0,&_44p1_p1_0}, - - {&_44p1_p2_0,&_44p1_p2_1,0}, - {&_44p1_p3_0,&_44p1_p3_1,0}, - {&_44p1_p4_0,&_44p1_p4_1,0}, - - {&_44p1_p5_0,&_44p1_p5_1,&_44p1_p4_1}, - {&_44p1_p6_0,&_44p1_p6_1,&_44p1_p6_2}, - } -}; - -static const static_bookblock _resbook_44p_2={ - { - {0}, - {0,0,&_44p2_p1_0}, - {0,&_44p2_p2_0,0}, - - {&_44p2_p3_0,&_44p2_p3_1,0}, - {&_44p2_p4_0,&_44p2_p4_1,0}, - {&_44p2_p5_0,&_44p2_p5_1,0}, - - {&_44p2_p6_0,&_44p2_p6_1,&_44p2_p5_1}, - {&_44p2_p7_0,&_44p2_p7_1,&_44p2_p7_2,&_44p2_p7_3} - } -}; -static const static_bookblock _resbook_44p_3={ - { - {0}, - {0,0,&_44p3_p1_0}, - {0,&_44p3_p2_0,0}, - - {&_44p3_p3_0,&_44p3_p3_1,0}, - {&_44p3_p4_0,&_44p3_p4_1,0}, - {&_44p3_p5_0,&_44p3_p5_1,0}, - - {&_44p3_p6_0,&_44p3_p6_1,&_44p3_p5_1}, - {&_44p3_p7_0,&_44p3_p7_1,&_44p3_p7_2,&_44p3_p7_3} - } -}; -static const static_bookblock _resbook_44p_4={ - { - {0}, - {0,0,&_44p4_p1_0}, - {0,&_44p4_p2_0,0}, - - {&_44p4_p3_0,&_44p4_p3_1,0}, - {&_44p4_p4_0,&_44p4_p4_1,0}, - {&_44p4_p5_0,&_44p4_p5_1,0}, - - {&_44p4_p6_0,&_44p4_p6_1,&_44p4_p5_1}, - {&_44p4_p7_0,&_44p4_p7_1,&_44p4_p7_2,&_44p4_p7_3} - } -}; -static const static_bookblock _resbook_44p_5={ - { - {0}, - {0,0,&_44p5_p1_0}, - {0,&_44p5_p2_0,0}, - - {&_44p5_p3_0,&_44p5_p3_1,0}, - {&_44p5_p4_0,&_44p5_p4_1,0}, - {&_44p5_p5_0,&_44p5_p5_1,0}, - - {&_44p5_p6_0,&_44p5_p6_1,&_44p5_p5_1}, - {&_44p5_p7_0,&_44p5_p7_1,&_44p5_p7_2,&_44p5_p7_3} - } -}; -static const static_bookblock _resbook_44p_6={ - { - {0}, - {0,0,&_44p6_p1_0}, - {0,&_44p6_p2_0,0}, - - {&_44p6_p3_0,&_44p6_p3_1,0}, - {&_44p6_p4_0,&_44p6_p4_1,0}, - {&_44p6_p5_0,&_44p6_p5_1,0}, - - {&_44p6_p6_0,&_44p6_p6_1,&_44p6_p5_1}, - {&_44p6_p7_0,&_44p6_p7_1,&_44p6_p7_2,&_44p6_p7_3} - } -}; -static const static_bookblock _resbook_44p_7={ - { - {0}, - {0,0,&_44p7_p1_0}, - {0,&_44p7_p2_0,0}, - - {&_44p7_p3_0,&_44p7_p3_1,0}, - {&_44p7_p4_0,&_44p7_p4_1,0}, - {&_44p7_p5_0,&_44p7_p5_1,0}, - - {&_44p7_p6_0,&_44p7_p6_1,&_44p7_p5_1}, - {&_44p7_p7_0,&_44p7_p7_1,&_44p7_p7_2,&_44p7_p7_3} - } -}; -static const static_bookblock _resbook_44p_8={ - { - {0}, - {0,0,&_44p8_p1_0}, - {0,&_44p8_p2_0,0}, - - {&_44p8_p3_0,&_44p8_p3_1,0}, - {&_44p8_p4_0,&_44p8_p4_1,0}, - {&_44p8_p5_0,&_44p8_p5_1,0}, - - {&_44p8_p6_0,&_44p8_p6_1,&_44p8_p5_1}, - {&_44p8_p7_0,&_44p8_p7_1,&_44p8_p7_2,&_44p8_p7_3} - } -}; -static const static_bookblock _resbook_44p_9={ - { - {0}, - {0,0,&_44p9_p1_0}, - {0,&_44p9_p2_0,0}, - - {&_44p9_p3_0,&_44p9_p3_1,0}, - {&_44p9_p4_0,&_44p9_p4_1,0}, - {&_44p9_p5_0,&_44p9_p5_1,0}, - - {&_44p9_p6_0,&_44p9_p6_1,&_44p9_p5_1}, - {&_44p9_p7_0,&_44p9_p7_1,&_44p9_p7_2,&_44p9_p7_3} - } -}; - -static const static_bookblock _resbook_44p_ln1={ - { - {&_44pn1_l0_0,&_44pn1_l0_1,0}, - {&_44pn1_l1_0,&_44pn1_p6_1,&_44pn1_p6_2}, - } -}; -static const static_bookblock _resbook_44p_l0={ - { - {&_44p0_l0_0,&_44p0_l0_1,0}, - {&_44p0_l1_0,&_44p0_p6_1,&_44p0_p6_2}, - } -}; -static const static_bookblock _resbook_44p_l1={ - { - {&_44p1_l0_0,&_44p1_l0_1,0}, - {&_44p1_l1_0,&_44p1_p6_1,&_44p1_p6_2}, - } -}; -static const static_bookblock _resbook_44p_l2={ - { - {&_44p2_l0_0,&_44p2_l0_1,0}, - {&_44p2_l1_0,&_44p2_p7_2,&_44p2_p7_3}, - } -}; -static const static_bookblock _resbook_44p_l3={ - { - {&_44p3_l0_0,&_44p3_l0_1,0}, - {&_44p3_l1_0,&_44p3_p7_2,&_44p3_p7_3}, - } -}; -static const static_bookblock _resbook_44p_l4={ - { - {&_44p4_l0_0,&_44p4_l0_1,0}, - {&_44p4_l1_0,&_44p4_p7_2,&_44p4_p7_3}, - } -}; -static const static_bookblock _resbook_44p_l5={ - { - {&_44p5_l0_0,&_44p5_l0_1,0}, - {&_44p5_l1_0,&_44p5_p7_2,&_44p5_p7_3}, - } -}; -static const static_bookblock _resbook_44p_l6={ - { - {&_44p6_l0_0,&_44p6_l0_1,0}, - {&_44p6_l1_0,&_44p6_p7_2,&_44p6_p7_3}, - } -}; -static const static_bookblock _resbook_44p_l7={ - { - {&_44p7_l0_0,&_44p7_l0_1,0}, - {&_44p7_l1_0,&_44p7_p7_2,&_44p7_p7_3}, - } -}; -static const static_bookblock _resbook_44p_l8={ - { - {&_44p8_l0_0,&_44p8_l0_1,0}, - {&_44p8_l1_0,&_44p8_p7_2,&_44p8_p7_3}, - } -}; -static const static_bookblock _resbook_44p_l9={ - { - {&_44p9_l0_0,&_44p9_l0_1,0}, - {&_44p9_l1_0,&_44p9_p7_2,&_44p9_p7_3}, - } -}; - - -static const vorbis_info_mapping0 _map_nominal_51[2]={ - {2, {0,0,0,0,0,1}, {0,2}, {0,2}, 4,{0,3,0,0},{2,4,1,3}}, - {2, {0,0,0,0,0,1}, {1,2}, {1,2}, 4,{0,3,0,0},{2,4,1,3}} -}; -static const vorbis_info_mapping0 _map_nominal_51u[2]={ - {2, {0,0,0,0,0,1}, {0,2}, {0,2}, 0,{0},{0}}, - {2, {0,0,0,0,0,1}, {1,2}, {1,2}, 0,{0},{0}} -}; - -static const vorbis_residue_template _res_44p51_n1[]={ - {2,0,30, &_residue_44p_lo, - &_huff_book__44pn1_short,&_huff_book__44pn1_short, - &_resbook_44p_n1,&_resbook_44p_n1}, - - {2,0,30, &_residue_44p_lo, - &_huff_book__44pn1_long,&_huff_book__44pn1_long, - &_resbook_44p_n1,&_resbook_44p_n1}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44pn1_lfe,&_huff_book__44pn1_lfe, - &_resbook_44p_ln1,&_resbook_44p_ln1} -}; -static const vorbis_residue_template _res_44p51_0[]={ - {2,0,15, &_residue_44p_lo, - &_huff_book__44p0_short,&_huff_book__44p0_short, - &_resbook_44p_0,&_resbook_44p_0}, - - {2,0,30, &_residue_44p_lo, - &_huff_book__44p0_long,&_huff_book__44p0_long, - &_resbook_44p_0,&_resbook_44p_0}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p0_lfe,&_huff_book__44p0_lfe, - &_resbook_44p_l0,&_resbook_44p_l0} -}; -static const vorbis_residue_template _res_44p51_1[]={ - {2,0,15, &_residue_44p_lo, - &_huff_book__44p1_short,&_huff_book__44p1_short, - &_resbook_44p_1,&_resbook_44p_1}, - - {2,0,30, &_residue_44p_lo, - &_huff_book__44p1_long,&_huff_book__44p1_long, - &_resbook_44p_1,&_resbook_44p_1}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p1_lfe,&_huff_book__44p1_lfe, - &_resbook_44p_l1,&_resbook_44p_l1} -}; -static const vorbis_residue_template _res_44p51_2[]={ - {2,0,15, &_residue_44p, - &_huff_book__44p2_short,&_huff_book__44p2_short, - &_resbook_44p_2,&_resbook_44p_2}, - - {2,0,30, &_residue_44p, - &_huff_book__44p2_long,&_huff_book__44p2_long, - &_resbook_44p_2,&_resbook_44p_2}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p2_lfe,&_huff_book__44p2_lfe, - &_resbook_44p_l2,&_resbook_44p_l2} -}; -static const vorbis_residue_template _res_44p51_3[]={ - {2,0,15, &_residue_44p, - &_huff_book__44p3_short,&_huff_book__44p3_short, - &_resbook_44p_3,&_resbook_44p_3}, - - {2,0,30, &_residue_44p, - &_huff_book__44p3_long,&_huff_book__44p3_long, - &_resbook_44p_3,&_resbook_44p_3}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p3_lfe,&_huff_book__44p3_lfe, - &_resbook_44p_l3,&_resbook_44p_l3} -}; -static const vorbis_residue_template _res_44p51_4[]={ - {2,0,15, &_residue_44p, - &_huff_book__44p4_short,&_huff_book__44p4_short, - &_resbook_44p_4,&_resbook_44p_4}, - - {2,0,30, &_residue_44p, - &_huff_book__44p4_long,&_huff_book__44p4_long, - &_resbook_44p_4,&_resbook_44p_4}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p4_lfe,&_huff_book__44p4_lfe, - &_resbook_44p_l4,&_resbook_44p_l4} -}; -static const vorbis_residue_template _res_44p51_5[]={ - {2,0,15, &_residue_44p_hi, - &_huff_book__44p5_short,&_huff_book__44p5_short, - &_resbook_44p_5,&_resbook_44p_5}, - - {2,0,30, &_residue_44p_hi, - &_huff_book__44p5_long,&_huff_book__44p5_long, - &_resbook_44p_5,&_resbook_44p_5}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p5_lfe,&_huff_book__44p5_lfe, - &_resbook_44p_l5,&_resbook_44p_l5} -}; -static const vorbis_residue_template _res_44p51_6[]={ - {2,0,15, &_residue_44p_hi, - &_huff_book__44p6_short,&_huff_book__44p6_short, - &_resbook_44p_6,&_resbook_44p_6}, - - {2,0,30, &_residue_44p_hi, - &_huff_book__44p6_long,&_huff_book__44p6_long, - &_resbook_44p_6,&_resbook_44p_6}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p6_lfe,&_huff_book__44p6_lfe, - &_resbook_44p_l6,&_resbook_44p_l6} -}; - - -static const vorbis_residue_template _res_44p51_7[]={ - {2,0,15, &_residue_44p_hi, - &_huff_book__44p7_short,&_huff_book__44p7_short, - &_resbook_44p_7,&_resbook_44p_7}, - - {2,0,30, &_residue_44p_hi, - &_huff_book__44p7_long,&_huff_book__44p7_long, - &_resbook_44p_7,&_resbook_44p_7}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p6_lfe,&_huff_book__44p6_lfe, - &_resbook_44p_l6,&_resbook_44p_l6} -}; -static const vorbis_residue_template _res_44p51_8[]={ - {2,0,15, &_residue_44p_hi, - &_huff_book__44p8_short,&_huff_book__44p8_short, - &_resbook_44p_8,&_resbook_44p_8}, - - {2,0,30, &_residue_44p_hi, - &_huff_book__44p8_long,&_huff_book__44p8_long, - &_resbook_44p_8,&_resbook_44p_8}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p6_lfe,&_huff_book__44p6_lfe, - &_resbook_44p_l6,&_resbook_44p_l6} -}; -static const vorbis_residue_template _res_44p51_9[]={ - {2,0,15, &_residue_44p_hi, - &_huff_book__44p9_short,&_huff_book__44p9_short, - &_resbook_44p_9,&_resbook_44p_9}, - - {2,0,30, &_residue_44p_hi, - &_huff_book__44p9_long,&_huff_book__44p9_long, - &_resbook_44p_9,&_resbook_44p_9}, - - {1,2,6, &_residue_44p_lfe, - &_huff_book__44p6_lfe,&_huff_book__44p6_lfe, - &_resbook_44p_l6,&_resbook_44p_l6} -}; - -static const vorbis_mapping_template _mapres_template_44_51[]={ - { _map_nominal_51, _res_44p51_n1 }, /* -1 */ - { _map_nominal_51, _res_44p51_0 }, /* 0 */ - { _map_nominal_51, _res_44p51_1 }, /* 1 */ - { _map_nominal_51, _res_44p51_2 }, /* 2 */ - { _map_nominal_51, _res_44p51_3 }, /* 3 */ - { _map_nominal_51, _res_44p51_4 }, /* 4 */ - { _map_nominal_51u, _res_44p51_5 }, /* 5 */ - { _map_nominal_51u, _res_44p51_6 }, /* 6 */ - { _map_nominal_51u, _res_44p51_7 }, /* 7 */ - { _map_nominal_51u, _res_44p51_8 }, /* 8 */ - { _map_nominal_51u, _res_44p51_9 }, /* 9 */ -}; diff --git a/Engine/lib/libvorbis/lib/modes/residue_44u.h b/Engine/lib/libvorbis/lib/modes/residue_44u.h deleted file mode 100644 index 2f3595e49..000000000 --- a/Engine/lib/libvorbis/lib/modes/residue_44u.h +++ /dev/null @@ -1,317 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: toplevel residue templates for 32/44.1/48kHz uncoupled - - ********************************************************************/ - -#include "vorbis/codec.h" -#include "backends.h" -#include "books/uncoupled/res_books_uncoupled.h" - -/***** residue backends *********************************************/ - - -static const vorbis_info_residue0 _residue_44_low_un={ - 0,-1, -1, 8,-1,-1, - {0}, - {-1}, - { 0, 1, 1, 2, 2, 4, 28}, - { -1, 25, -1, 45, -1, -1, -1} -}; - -static const vorbis_info_residue0 _residue_44_mid_un={ - 0,-1, -1, 10,-1,-1, - /* 0 1 2 3 4 5 6 7 8 9 */ - {0}, - {-1}, - { 0, 1, 1, 2, 2, 4, 4, 16, 60}, - { -1, 30, -1, 50, -1, 80, -1, -1, -1} -}; - -static const vorbis_info_residue0 _residue_44_hi_un={ - 0,-1, -1, 10,-1,-1, - /* 0 1 2 3 4 5 6 7 8 9 */ - {0}, - {-1}, - { 0, 1, 2, 4, 8, 16, 32, 71,157}, - { -1, -1, -1, -1, -1, -1, -1, -1, -1} -}; - -/* mapping conventions: - only one submap (this would change for efficient 5.1 support for example)*/ -/* Four psychoacoustic profiles are used, one for each blocktype */ -static const vorbis_info_mapping0 _map_nominal_u[2]={ - {1, {0,0,0,0,0,0}, {0}, {0}, 0,{0},{0}}, - {1, {0,0,0,0,0,0}, {1}, {1}, 0,{0},{0}} -}; - -static const static_bookblock _resbook_44u_n1={ - { - {0}, - {0,0,&_44un1__p1_0}, - {0,0,&_44un1__p2_0}, - {0,0,&_44un1__p3_0}, - {0,0,&_44un1__p4_0}, - {0,0,&_44un1__p5_0}, - {&_44un1__p6_0,&_44un1__p6_1}, - {&_44un1__p7_0,&_44un1__p7_1,&_44un1__p7_2} - } -}; -static const static_bookblock _resbook_44u_0={ - { - {0}, - {0,0,&_44u0__p1_0}, - {0,0,&_44u0__p2_0}, - {0,0,&_44u0__p3_0}, - {0,0,&_44u0__p4_0}, - {0,0,&_44u0__p5_0}, - {&_44u0__p6_0,&_44u0__p6_1}, - {&_44u0__p7_0,&_44u0__p7_1,&_44u0__p7_2} - } -}; -static const static_bookblock _resbook_44u_1={ - { - {0}, - {0,0,&_44u1__p1_0}, - {0,0,&_44u1__p2_0}, - {0,0,&_44u1__p3_0}, - {0,0,&_44u1__p4_0}, - {0,0,&_44u1__p5_0}, - {&_44u1__p6_0,&_44u1__p6_1}, - {&_44u1__p7_0,&_44u1__p7_1,&_44u1__p7_2} - } -}; -static const static_bookblock _resbook_44u_2={ - { - {0}, - {0,0,&_44u2__p1_0}, - {0,0,&_44u2__p2_0}, - {0,0,&_44u2__p3_0}, - {0,0,&_44u2__p4_0}, - {0,0,&_44u2__p5_0}, - {&_44u2__p6_0,&_44u2__p6_1}, - {&_44u2__p7_0,&_44u2__p7_1,&_44u2__p7_2} - } -}; -static const static_bookblock _resbook_44u_3={ - { - {0}, - {0,0,&_44u3__p1_0}, - {0,0,&_44u3__p2_0}, - {0,0,&_44u3__p3_0}, - {0,0,&_44u3__p4_0}, - {0,0,&_44u3__p5_0}, - {&_44u3__p6_0,&_44u3__p6_1}, - {&_44u3__p7_0,&_44u3__p7_1,&_44u3__p7_2} - } -}; -static const static_bookblock _resbook_44u_4={ - { - {0}, - {0,0,&_44u4__p1_0}, - {0,0,&_44u4__p2_0}, - {0,0,&_44u4__p3_0}, - {0,0,&_44u4__p4_0}, - {0,0,&_44u4__p5_0}, - {&_44u4__p6_0,&_44u4__p6_1}, - {&_44u4__p7_0,&_44u4__p7_1,&_44u4__p7_2} - } -}; -static const static_bookblock _resbook_44u_5={ - { - {0}, - {0,0,&_44u5__p1_0}, - {0,0,&_44u5__p2_0}, - {0,0,&_44u5__p3_0}, - {0,0,&_44u5__p4_0}, - {0,0,&_44u5__p5_0}, - {0,0,&_44u5__p6_0}, - {&_44u5__p7_0,&_44u5__p7_1}, - {&_44u5__p8_0,&_44u5__p8_1}, - {&_44u5__p9_0,&_44u5__p9_1,&_44u5__p9_2} - } -}; -static const static_bookblock _resbook_44u_6={ - { - {0}, - {0,0,&_44u6__p1_0}, - {0,0,&_44u6__p2_0}, - {0,0,&_44u6__p3_0}, - {0,0,&_44u6__p4_0}, - {0,0,&_44u6__p5_0}, - {0,0,&_44u6__p6_0}, - {&_44u6__p7_0,&_44u6__p7_1}, - {&_44u6__p8_0,&_44u6__p8_1}, - {&_44u6__p9_0,&_44u6__p9_1,&_44u6__p9_2} - } -}; -static const static_bookblock _resbook_44u_7={ - { - {0}, - {0,0,&_44u7__p1_0}, - {0,0,&_44u7__p2_0}, - {0,0,&_44u7__p3_0}, - {0,0,&_44u7__p4_0}, - {0,0,&_44u7__p5_0}, - {0,0,&_44u7__p6_0}, - {&_44u7__p7_0,&_44u7__p7_1}, - {&_44u7__p8_0,&_44u7__p8_1}, - {&_44u7__p9_0,&_44u7__p9_1,&_44u7__p9_2} - } -}; -static const static_bookblock _resbook_44u_8={ - { - {0}, - {0,0,&_44u8_p1_0}, - {0,0,&_44u8_p2_0}, - {0,0,&_44u8_p3_0}, - {0,0,&_44u8_p4_0}, - {&_44u8_p5_0,&_44u8_p5_1}, - {&_44u8_p6_0,&_44u8_p6_1}, - {&_44u8_p7_0,&_44u8_p7_1}, - {&_44u8_p8_0,&_44u8_p8_1}, - {&_44u8_p9_0,&_44u8_p9_1,&_44u8_p9_2} - } -}; -static const static_bookblock _resbook_44u_9={ - { - {0}, - {0,0,&_44u9_p1_0}, - {0,0,&_44u9_p2_0}, - {0,0,&_44u9_p3_0}, - {0,0,&_44u9_p4_0}, - {&_44u9_p5_0,&_44u9_p5_1}, - {&_44u9_p6_0,&_44u9_p6_1}, - {&_44u9_p7_0,&_44u9_p7_1}, - {&_44u9_p8_0,&_44u9_p8_1}, - {&_44u9_p9_0,&_44u9_p9_1,&_44u9_p9_2} - } -}; - -static const vorbis_residue_template _res_44u_n1[]={ - {1,0,32, &_residue_44_low_un, - &_huff_book__44un1__short,&_huff_book__44un1__short, - &_resbook_44u_n1,&_resbook_44u_n1}, - - {1,0,32, &_residue_44_low_un, - &_huff_book__44un1__long,&_huff_book__44un1__long, - &_resbook_44u_n1,&_resbook_44u_n1} -}; -static const vorbis_residue_template _res_44u_0[]={ - {1,0,16, &_residue_44_low_un, - &_huff_book__44u0__short,&_huff_book__44u0__short, - &_resbook_44u_0,&_resbook_44u_0}, - - {1,0,32, &_residue_44_low_un, - &_huff_book__44u0__long,&_huff_book__44u0__long, - &_resbook_44u_0,&_resbook_44u_0} -}; -static const vorbis_residue_template _res_44u_1[]={ - {1,0,16, &_residue_44_low_un, - &_huff_book__44u1__short,&_huff_book__44u1__short, - &_resbook_44u_1,&_resbook_44u_1}, - - {1,0,32, &_residue_44_low_un, - &_huff_book__44u1__long,&_huff_book__44u1__long, - &_resbook_44u_1,&_resbook_44u_1} -}; -static const vorbis_residue_template _res_44u_2[]={ - {1,0,16, &_residue_44_low_un, - &_huff_book__44u2__short,&_huff_book__44u2__short, - &_resbook_44u_2,&_resbook_44u_2}, - - {1,0,32, &_residue_44_low_un, - &_huff_book__44u2__long,&_huff_book__44u2__long, - &_resbook_44u_2,&_resbook_44u_2} -}; -static const vorbis_residue_template _res_44u_3[]={ - {1,0,16, &_residue_44_low_un, - &_huff_book__44u3__short,&_huff_book__44u3__short, - &_resbook_44u_3,&_resbook_44u_3}, - - {1,0,32, &_residue_44_low_un, - &_huff_book__44u3__long,&_huff_book__44u3__long, - &_resbook_44u_3,&_resbook_44u_3} -}; -static const vorbis_residue_template _res_44u_4[]={ - {1,0,16, &_residue_44_low_un, - &_huff_book__44u4__short,&_huff_book__44u4__short, - &_resbook_44u_4,&_resbook_44u_4}, - - {1,0,32, &_residue_44_low_un, - &_huff_book__44u4__long,&_huff_book__44u4__long, - &_resbook_44u_4,&_resbook_44u_4} -}; - -static const vorbis_residue_template _res_44u_5[]={ - {1,0,16, &_residue_44_mid_un, - &_huff_book__44u5__short,&_huff_book__44u5__short, - &_resbook_44u_5,&_resbook_44u_5}, - - {1,0,32, &_residue_44_mid_un, - &_huff_book__44u5__long,&_huff_book__44u5__long, - &_resbook_44u_5,&_resbook_44u_5} -}; - -static const vorbis_residue_template _res_44u_6[]={ - {1,0,16, &_residue_44_mid_un, - &_huff_book__44u6__short,&_huff_book__44u6__short, - &_resbook_44u_6,&_resbook_44u_6}, - - {1,0,32, &_residue_44_mid_un, - &_huff_book__44u6__long,&_huff_book__44u6__long, - &_resbook_44u_6,&_resbook_44u_6} -}; - -static const vorbis_residue_template _res_44u_7[]={ - {1,0,16, &_residue_44_mid_un, - &_huff_book__44u7__short,&_huff_book__44u7__short, - &_resbook_44u_7,&_resbook_44u_7}, - - {1,0,32, &_residue_44_mid_un, - &_huff_book__44u7__long,&_huff_book__44u7__long, - &_resbook_44u_7,&_resbook_44u_7} -}; - -static const vorbis_residue_template _res_44u_8[]={ - {1,0,16, &_residue_44_hi_un, - &_huff_book__44u8__short,&_huff_book__44u8__short, - &_resbook_44u_8,&_resbook_44u_8}, - - {1,0,32, &_residue_44_hi_un, - &_huff_book__44u8__long,&_huff_book__44u8__long, - &_resbook_44u_8,&_resbook_44u_8} -}; -static const vorbis_residue_template _res_44u_9[]={ - {1,0,16, &_residue_44_hi_un, - &_huff_book__44u9__short,&_huff_book__44u9__short, - &_resbook_44u_9,&_resbook_44u_9}, - - {1,0,32, &_residue_44_hi_un, - &_huff_book__44u9__long,&_huff_book__44u9__long, - &_resbook_44u_9,&_resbook_44u_9} -}; - -static const vorbis_mapping_template _mapres_template_44_uncoupled[]={ - { _map_nominal_u, _res_44u_n1 }, /* -1 */ - { _map_nominal_u, _res_44u_0 }, /* 0 */ - { _map_nominal_u, _res_44u_1 }, /* 1 */ - { _map_nominal_u, _res_44u_2 }, /* 2 */ - { _map_nominal_u, _res_44u_3 }, /* 3 */ - { _map_nominal_u, _res_44u_4 }, /* 4 */ - { _map_nominal_u, _res_44u_5 }, /* 5 */ - { _map_nominal_u, _res_44u_6 }, /* 6 */ - { _map_nominal_u, _res_44u_7 }, /* 7 */ - { _map_nominal_u, _res_44u_8 }, /* 8 */ - { _map_nominal_u, _res_44u_9 }, /* 9 */ -}; diff --git a/Engine/lib/libvorbis/lib/modes/residue_8.h b/Engine/lib/libvorbis/lib/modes/residue_8.h deleted file mode 100644 index b836f79c8..000000000 --- a/Engine/lib/libvorbis/lib/modes/residue_8.h +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: toplevel residue templates 8/11kHz - - ********************************************************************/ - -#include "vorbis/codec.h" -#include "backends.h" - -/***** residue backends *********************************************/ - -static const static_bookblock _resbook_8s_0={ - { - {0}, - {0,0,&_8c0_s_p1_0}, - {0}, - {0,0,&_8c0_s_p3_0}, - {0,0,&_8c0_s_p4_0}, - {0,0,&_8c0_s_p5_0}, - {0,0,&_8c0_s_p6_0}, - {&_8c0_s_p7_0,&_8c0_s_p7_1}, - {&_8c0_s_p8_0,&_8c0_s_p8_1}, - {&_8c0_s_p9_0,&_8c0_s_p9_1,&_8c0_s_p9_2} - } -}; -static const static_bookblock _resbook_8s_1={ - { - {0}, - {0,0,&_8c1_s_p1_0}, - {0}, - {0,0,&_8c1_s_p3_0}, - {0,0,&_8c1_s_p4_0}, - {0,0,&_8c1_s_p5_0}, - {0,0,&_8c1_s_p6_0}, - {&_8c1_s_p7_0,&_8c1_s_p7_1}, - {&_8c1_s_p8_0,&_8c1_s_p8_1}, - {&_8c1_s_p9_0,&_8c1_s_p9_1,&_8c1_s_p9_2} - } -}; - -static const vorbis_residue_template _res_8s_0[]={ - {2,0,32, &_residue_44_mid, - &_huff_book__8c0_s_single,&_huff_book__8c0_s_single, - &_resbook_8s_0,&_resbook_8s_0}, -}; -static const vorbis_residue_template _res_8s_1[]={ - {2,0,32, &_residue_44_mid, - &_huff_book__8c1_s_single,&_huff_book__8c1_s_single, - &_resbook_8s_1,&_resbook_8s_1}, -}; - -static const vorbis_mapping_template _mapres_template_8_stereo[2]={ - { _map_nominal, _res_8s_0 }, /* 0 */ - { _map_nominal, _res_8s_1 }, /* 1 */ -}; - -static const static_bookblock _resbook_8u_0={ - { - {0}, - {0,0,&_8u0__p1_0}, - {0,0,&_8u0__p2_0}, - {0,0,&_8u0__p3_0}, - {0,0,&_8u0__p4_0}, - {0,0,&_8u0__p5_0}, - {&_8u0__p6_0,&_8u0__p6_1}, - {&_8u0__p7_0,&_8u0__p7_1,&_8u0__p7_2} - } -}; -static const static_bookblock _resbook_8u_1={ - { - {0}, - {0,0,&_8u1__p1_0}, - {0,0,&_8u1__p2_0}, - {0,0,&_8u1__p3_0}, - {0,0,&_8u1__p4_0}, - {0,0,&_8u1__p5_0}, - {0,0,&_8u1__p6_0}, - {&_8u1__p7_0,&_8u1__p7_1}, - {&_8u1__p8_0,&_8u1__p8_1}, - {&_8u1__p9_0,&_8u1__p9_1,&_8u1__p9_2} - } -}; - -static const vorbis_residue_template _res_8u_0[]={ - {1,0,32, &_residue_44_low_un, - &_huff_book__8u0__single,&_huff_book__8u0__single, - &_resbook_8u_0,&_resbook_8u_0}, -}; -static const vorbis_residue_template _res_8u_1[]={ - {1,0,32, &_residue_44_mid_un, - &_huff_book__8u1__single,&_huff_book__8u1__single, - &_resbook_8u_1,&_resbook_8u_1}, -}; - -static const vorbis_mapping_template _mapres_template_8_uncoupled[2]={ - { _map_nominal_u, _res_8u_0 }, /* 0 */ - { _map_nominal_u, _res_8u_1 }, /* 1 */ -}; diff --git a/Engine/lib/libvorbis/lib/modes/setup_11.h b/Engine/lib/libvorbis/lib/modes/setup_11.h deleted file mode 100644 index 5ade5dd16..000000000 --- a/Engine/lib/libvorbis/lib/modes/setup_11.h +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: 11kHz settings - - ********************************************************************/ - -#include "psych_11.h" - -static const int blocksize_11[2]={ - 512,512 -}; - -static const int _floor_mapping_11a[]={ - 6,6 -}; -static const int *_floor_mapping_11[]={ - _floor_mapping_11a -}; - -static const double rate_mapping_11[3]={ - 8000.,13000.,44000., -}; - -static const double rate_mapping_11_uncoupled[3]={ - 12000.,20000.,50000., -}; - -static const double quality_mapping_11[3]={ - -.1,.0,1. -}; - -static const ve_setup_data_template ve_setup_11_stereo={ - 2, - rate_mapping_11, - quality_mapping_11, - 2, - 9000, - 15000, - - blocksize_11, - blocksize_11, - - _psy_tone_masteratt_11, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_11, - NULL, - _vp_tonemask_adj_11, - - _psy_noiseguards_8, - _psy_noisebias_11, - _psy_noisebias_11, - NULL, - NULL, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_8_mapping, - NULL, - - {_noise_start_8,_noise_start_8}, - {_noise_part_8,_noise_part_8}, - _noise_thresh_11, - - _psy_ath_floater_8, - _psy_ath_abs_8, - - _psy_lowpass_11, - - _psy_global_44, - _global_mapping_8, - _psy_stereo_modes_8, - - _floor_books, - _floor, - 1, - _floor_mapping_11, - - _mapres_template_8_stereo -}; - -static const ve_setup_data_template ve_setup_11_uncoupled={ - 2, - rate_mapping_11_uncoupled, - quality_mapping_11, - -1, - 9000, - 15000, - - blocksize_11, - blocksize_11, - - _psy_tone_masteratt_11, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_11, - NULL, - _vp_tonemask_adj_11, - - _psy_noiseguards_8, - _psy_noisebias_11, - _psy_noisebias_11, - NULL, - NULL, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_8_mapping, - NULL, - - {_noise_start_8,_noise_start_8}, - {_noise_part_8,_noise_part_8}, - _noise_thresh_11, - - _psy_ath_floater_8, - _psy_ath_abs_8, - - _psy_lowpass_11, - - _psy_global_44, - _global_mapping_8, - _psy_stereo_modes_8, - - _floor_books, - _floor, - 1, - _floor_mapping_11, - - _mapres_template_8_uncoupled -}; diff --git a/Engine/lib/libvorbis/lib/modes/setup_16.h b/Engine/lib/libvorbis/lib/modes/setup_16.h deleted file mode 100644 index 8b2daafa3..000000000 --- a/Engine/lib/libvorbis/lib/modes/setup_16.h +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: 16kHz settings - - ********************************************************************/ - -#include "psych_16.h" -#include "residue_16.h" - -static const int blocksize_16_short[3]={ - 1024,512,512 -}; -static const int blocksize_16_long[3]={ - 1024,1024,1024 -}; - -static const int _floor_mapping_16a[]={ - 9,3,3 -}; -static const int _floor_mapping_16b[]={ - 9,9,9 -}; -static const int *_floor_mapping_16[]={ - _floor_mapping_16a, - _floor_mapping_16b -}; - -static const double rate_mapping_16[4]={ - 12000.,20000.,44000.,86000. -}; - -static const double rate_mapping_16_uncoupled[4]={ - 16000.,28000.,64000.,100000. -}; - -static const double _global_mapping_16[4]={ 1., 2., 3., 4. }; - -static const double quality_mapping_16[4]={ -.1,.05,.5,1. }; - -static const double _psy_compand_16_mapping[4]={ 0., .8, 1., 1.}; - -static const ve_setup_data_template ve_setup_16_stereo={ - 3, - rate_mapping_16, - quality_mapping_16, - 2, - 15000, - 19000, - - blocksize_16_short, - blocksize_16_long, - - _psy_tone_masteratt_16, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_16, - _vp_tonemask_adj_16, - _vp_tonemask_adj_16, - - _psy_noiseguards_16, - _psy_noisebias_16_impulse, - _psy_noisebias_16_short, - _psy_noisebias_16_short, - _psy_noisebias_16, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_16_mapping, - _psy_compand_16_mapping, - - {_noise_start_16,_noise_start_16}, - { _noise_part_16, _noise_part_16}, - _noise_thresh_16, - - _psy_ath_floater_16, - _psy_ath_abs_16, - - _psy_lowpass_16, - - _psy_global_44, - _global_mapping_16, - _psy_stereo_modes_16, - - _floor_books, - _floor, - 2, - _floor_mapping_16, - - _mapres_template_16_stereo -}; - -static const ve_setup_data_template ve_setup_16_uncoupled={ - 3, - rate_mapping_16_uncoupled, - quality_mapping_16, - -1, - 15000, - 19000, - - blocksize_16_short, - blocksize_16_long, - - _psy_tone_masteratt_16, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_16, - _vp_tonemask_adj_16, - _vp_tonemask_adj_16, - - _psy_noiseguards_16, - _psy_noisebias_16_impulse, - _psy_noisebias_16_short, - _psy_noisebias_16_short, - _psy_noisebias_16, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_16_mapping, - _psy_compand_16_mapping, - - {_noise_start_16,_noise_start_16}, - { _noise_part_16, _noise_part_16}, - _noise_thresh_16, - - _psy_ath_floater_16, - _psy_ath_abs_16, - - _psy_lowpass_16, - - _psy_global_44, - _global_mapping_16, - _psy_stereo_modes_16, - - _floor_books, - _floor, - 2, - _floor_mapping_16, - - _mapres_template_16_uncoupled -}; diff --git a/Engine/lib/libvorbis/lib/modes/setup_22.h b/Engine/lib/libvorbis/lib/modes/setup_22.h deleted file mode 100644 index eef5a4e7d..000000000 --- a/Engine/lib/libvorbis/lib/modes/setup_22.h +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: 22kHz settings - - ********************************************************************/ - -static const double rate_mapping_22[4]={ - 15000.,20000.,44000.,86000. -}; - -static const double rate_mapping_22_uncoupled[4]={ - 16000.,28000.,50000.,90000. -}; - -static const double _psy_lowpass_22[4]={9.5,11.,30.,99.}; - -static const ve_setup_data_template ve_setup_22_stereo={ - 3, - rate_mapping_22, - quality_mapping_16, - 2, - 19000, - 26000, - - blocksize_16_short, - blocksize_16_long, - - _psy_tone_masteratt_16, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_16, - _vp_tonemask_adj_16, - _vp_tonemask_adj_16, - - _psy_noiseguards_16, - _psy_noisebias_16_impulse, - _psy_noisebias_16_short, - _psy_noisebias_16_short, - _psy_noisebias_16, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_16_mapping, - _psy_compand_16_mapping, - - {_noise_start_16,_noise_start_16}, - { _noise_part_16, _noise_part_16}, - _noise_thresh_16, - - _psy_ath_floater_16, - _psy_ath_abs_16, - - _psy_lowpass_22, - - _psy_global_44, - _global_mapping_16, - _psy_stereo_modes_16, - - _floor_books, - _floor, - 2, - _floor_mapping_16, - - _mapres_template_16_stereo -}; - -static const ve_setup_data_template ve_setup_22_uncoupled={ - 3, - rate_mapping_22_uncoupled, - quality_mapping_16, - -1, - 19000, - 26000, - - blocksize_16_short, - blocksize_16_long, - - _psy_tone_masteratt_16, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_16, - _vp_tonemask_adj_16, - _vp_tonemask_adj_16, - - _psy_noiseguards_16, - _psy_noisebias_16_impulse, - _psy_noisebias_16_short, - _psy_noisebias_16_short, - _psy_noisebias_16, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_16_mapping, - _psy_compand_16_mapping, - - {_noise_start_16,_noise_start_16}, - { _noise_part_16, _noise_part_16}, - _noise_thresh_16, - - _psy_ath_floater_16, - _psy_ath_abs_16, - - _psy_lowpass_22, - - _psy_global_44, - _global_mapping_16, - _psy_stereo_modes_16, - - _floor_books, - _floor, - 2, - _floor_mapping_16, - - _mapres_template_16_uncoupled -}; diff --git a/Engine/lib/libvorbis/lib/modes/setup_32.h b/Engine/lib/libvorbis/lib/modes/setup_32.h deleted file mode 100644 index f87cb767d..000000000 --- a/Engine/lib/libvorbis/lib/modes/setup_32.h +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: toplevel settings for 32kHz - - ********************************************************************/ - -static const double rate_mapping_32[12]={ - 18000.,28000.,35000.,45000.,56000.,60000., - 75000.,90000.,100000.,115000.,150000.,190000., -}; - -static const double rate_mapping_32_un[12]={ - 30000.,42000.,52000.,64000.,72000.,78000., - 86000.,92000.,110000.,120000.,140000.,190000., -}; - -static const double _psy_lowpass_32[12]={ - 12.3,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99. -}; - -static const ve_setup_data_template ve_setup_32_stereo={ - 11, - rate_mapping_32, - quality_mapping_44, - 2, - 26000, - 40000, - - blocksize_short_44, - blocksize_long_44, - - _psy_tone_masteratt_44, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_otherblock, - _vp_tonemask_adj_longblock, - _vp_tonemask_adj_otherblock, - - _psy_noiseguards_44, - _psy_noisebias_impulse, - _psy_noisebias_padding, - _psy_noisebias_trans, - _psy_noisebias_long, - _psy_noise_suppress, - - _psy_compand_44, - _psy_compand_short_mapping, - _psy_compand_long_mapping, - - {_noise_start_short_44,_noise_start_long_44}, - {_noise_part_short_44,_noise_part_long_44}, - _noise_thresh_44, - - _psy_ath_floater, - _psy_ath_abs, - - _psy_lowpass_32, - - _psy_global_44, - _global_mapping_44, - _psy_stereo_modes_44, - - _floor_books, - _floor, - 2, - _floor_mapping_44, - - _mapres_template_44_stereo -}; - -static const ve_setup_data_template ve_setup_32_uncoupled={ - 11, - rate_mapping_32_un, - quality_mapping_44, - -1, - 26000, - 40000, - - blocksize_short_44, - blocksize_long_44, - - _psy_tone_masteratt_44, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_otherblock, - _vp_tonemask_adj_longblock, - _vp_tonemask_adj_otherblock, - - _psy_noiseguards_44, - _psy_noisebias_impulse, - _psy_noisebias_padding, - _psy_noisebias_trans, - _psy_noisebias_long, - _psy_noise_suppress, - - _psy_compand_44, - _psy_compand_short_mapping, - _psy_compand_long_mapping, - - {_noise_start_short_44,_noise_start_long_44}, - {_noise_part_short_44,_noise_part_long_44}, - _noise_thresh_44, - - _psy_ath_floater, - _psy_ath_abs, - - _psy_lowpass_32, - - _psy_global_44, - _global_mapping_44, - NULL, - - _floor_books, - _floor, - 2, - _floor_mapping_44, - - _mapres_template_44_uncoupled -}; diff --git a/Engine/lib/libvorbis/lib/modes/setup_44.h b/Engine/lib/libvorbis/lib/modes/setup_44.h deleted file mode 100644 index 12d592808..000000000 --- a/Engine/lib/libvorbis/lib/modes/setup_44.h +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: toplevel settings for 44.1/48kHz - - ********************************************************************/ - -#include "modes/floor_all.h" -#include "modes/residue_44.h" -#include "modes/psych_44.h" - -static const double rate_mapping_44_stereo[12]={ - 22500.,32000.,40000.,48000.,56000.,64000., - 80000.,96000.,112000.,128000.,160000.,250001. -}; - -static const double quality_mapping_44[12]={ - -.1,.0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0 -}; - -static const int blocksize_short_44[11]={ - 512,256,256,256,256,256,256,256,256,256,256 -}; -static const int blocksize_long_44[11]={ - 4096,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048 -}; - -static const double _psy_compand_short_mapping[12]={ - 0.5, 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2. -}; -static const double _psy_compand_long_mapping[12]={ - 3.5, 4., 4., 4.3, 4.6, 5., 5., 5., 5., 5., 5., 5. -}; - -static const double _global_mapping_44[12]={ - /* 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.5, 4., 4. */ - 0., 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.7, 4., 4. -}; - -static const int _floor_mapping_44a[11]={ - 1,0,0,2,2,4,5,5,5,5,5 -}; - -static const int _floor_mapping_44b[11]={ - 8,7,7,7,7,7,7,7,7,7,7 -}; - -static const int _floor_mapping_44c[11]={ - 10,10,10,10,10,10,10,10,10,10,10 -}; - -static const int *_floor_mapping_44[]={ - _floor_mapping_44a, - _floor_mapping_44b, - _floor_mapping_44c, -}; - -static const ve_setup_data_template ve_setup_44_stereo={ - 11, - rate_mapping_44_stereo, - quality_mapping_44, - 2, - 40000, - 50000, - - blocksize_short_44, - blocksize_long_44, - - _psy_tone_masteratt_44, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_otherblock, - _vp_tonemask_adj_longblock, - _vp_tonemask_adj_otherblock, - - _psy_noiseguards_44, - _psy_noisebias_impulse, - _psy_noisebias_padding, - _psy_noisebias_trans, - _psy_noisebias_long, - _psy_noise_suppress, - - _psy_compand_44, - _psy_compand_short_mapping, - _psy_compand_long_mapping, - - {_noise_start_short_44,_noise_start_long_44}, - {_noise_part_short_44,_noise_part_long_44}, - _noise_thresh_44, - - _psy_ath_floater, - _psy_ath_abs, - - _psy_lowpass_44, - - _psy_global_44, - _global_mapping_44, - _psy_stereo_modes_44, - - _floor_books, - _floor, - 2, - _floor_mapping_44, - - _mapres_template_44_stereo -}; diff --git a/Engine/lib/libvorbis/lib/modes/setup_44p51.h b/Engine/lib/libvorbis/lib/modes/setup_44p51.h deleted file mode 100644 index 4d49173ff..000000000 --- a/Engine/lib/libvorbis/lib/modes/setup_44p51.h +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: toplevel settings for 44.1/48kHz 5.1 surround modes - - ********************************************************************/ - -#include "modes/residue_44p51.h" - -static const double rate_mapping_44p51[12]={ - 14000.,20000.,28000.,38000.,46000.,54000., - 75000.,96000.,120000.,140000.,180000.,240001. -}; - -static const ve_setup_data_template ve_setup_44_51={ - 11, - rate_mapping_44p51, - quality_mapping_44, - 6, - 40000, - 70000, - - blocksize_short_44, - blocksize_long_44, - - _psy_tone_masteratt_44, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_otherblock, - _vp_tonemask_adj_longblock, - _vp_tonemask_adj_otherblock, - - _psy_noiseguards_44, - _psy_noisebias_impulse, - _psy_noisebias_padding, - _psy_noisebias_trans, - _psy_noisebias_long, - _psy_noise_suppress, - - _psy_compand_44, - _psy_compand_short_mapping, - _psy_compand_long_mapping, - - {_noise_start_short_44,_noise_start_long_44}, - {_noise_part_short_44,_noise_part_long_44}, - _noise_thresh_44, - - _psy_ath_floater, - _psy_ath_abs, - - _psy_lowpass_44, - - _psy_global_44, - _global_mapping_44, - _psy_stereo_modes_44, - - _floor_books, - _floor, - 3, - _floor_mapping_44, - - _mapres_template_44_51 -}; diff --git a/Engine/lib/libvorbis/lib/modes/setup_44u.h b/Engine/lib/libvorbis/lib/modes/setup_44u.h deleted file mode 100644 index 2dd8bf701..000000000 --- a/Engine/lib/libvorbis/lib/modes/setup_44u.h +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: toplevel settings for 44.1/48kHz uncoupled modes - - ********************************************************************/ - -#include "modes/residue_44u.h" - -static const double rate_mapping_44_un[12]={ - 32000.,48000.,60000.,70000.,80000.,86000., - 96000.,110000.,120000.,140000.,160000.,240001. -}; - -static const ve_setup_data_template ve_setup_44_uncoupled={ - 11, - rate_mapping_44_un, - quality_mapping_44, - -1, - 40000, - 50000, - - blocksize_short_44, - blocksize_long_44, - - _psy_tone_masteratt_44, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_otherblock, - _vp_tonemask_adj_longblock, - _vp_tonemask_adj_otherblock, - - _psy_noiseguards_44, - _psy_noisebias_impulse, - _psy_noisebias_padding, - _psy_noisebias_trans, - _psy_noisebias_long, - _psy_noise_suppress, - - _psy_compand_44, - _psy_compand_short_mapping, - _psy_compand_long_mapping, - - {_noise_start_short_44,_noise_start_long_44}, - {_noise_part_short_44,_noise_part_long_44}, - _noise_thresh_44, - - _psy_ath_floater, - _psy_ath_abs, - - _psy_lowpass_44, - - _psy_global_44, - _global_mapping_44, - _psy_stereo_modes_44, - - _floor_books, - _floor, - 2, - _floor_mapping_44, - - _mapres_template_44_uncoupled -}; diff --git a/Engine/lib/libvorbis/lib/modes/setup_8.h b/Engine/lib/libvorbis/lib/modes/setup_8.h deleted file mode 100644 index 16b02e01b..000000000 --- a/Engine/lib/libvorbis/lib/modes/setup_8.h +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: 8kHz settings - - ********************************************************************/ - -#include "psych_8.h" -#include "residue_8.h" - -static const int blocksize_8[2]={ - 512,512 -}; - -static const int _floor_mapping_8a[]={ - 6,6 -}; - -static const int *_floor_mapping_8[]={ - _floor_mapping_8a -}; - -static const double rate_mapping_8[3]={ - 6000.,9000.,32000., -}; - -static const double rate_mapping_8_uncoupled[3]={ - 8000.,14000.,42000., -}; - -static const double quality_mapping_8[3]={ - -.1,.0,1. -}; - -static const double _psy_compand_8_mapping[3]={ 0., 1., 1.}; - -static const double _global_mapping_8[3]={ 1., 2., 3. }; - -static const ve_setup_data_template ve_setup_8_stereo={ - 2, - rate_mapping_8, - quality_mapping_8, - 2, - 8000, - 9000, - - blocksize_8, - blocksize_8, - - _psy_tone_masteratt_8, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_8, - NULL, - _vp_tonemask_adj_8, - - _psy_noiseguards_8, - _psy_noisebias_8, - _psy_noisebias_8, - NULL, - NULL, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_8_mapping, - NULL, - - {_noise_start_8,_noise_start_8}, - {_noise_part_8,_noise_part_8}, - _noise_thresh_5only, - - _psy_ath_floater_8, - _psy_ath_abs_8, - - _psy_lowpass_8, - - _psy_global_44, - _global_mapping_8, - _psy_stereo_modes_8, - - _floor_books, - _floor, - 1, - _floor_mapping_8, - - _mapres_template_8_stereo -}; - -static const ve_setup_data_template ve_setup_8_uncoupled={ - 2, - rate_mapping_8_uncoupled, - quality_mapping_8, - -1, - 8000, - 9000, - - blocksize_8, - blocksize_8, - - _psy_tone_masteratt_8, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_8, - NULL, - _vp_tonemask_adj_8, - - _psy_noiseguards_8, - _psy_noisebias_8, - _psy_noisebias_8, - NULL, - NULL, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_8_mapping, - NULL, - - {_noise_start_8,_noise_start_8}, - {_noise_part_8,_noise_part_8}, - _noise_thresh_5only, - - _psy_ath_floater_8, - _psy_ath_abs_8, - - _psy_lowpass_8, - - _psy_global_44, - _global_mapping_8, - _psy_stereo_modes_8, - - _floor_books, - _floor, - 1, - _floor_mapping_8, - - _mapres_template_8_uncoupled -}; diff --git a/Engine/lib/libvorbis/lib/modes/setup_X.h b/Engine/lib/libvorbis/lib/modes/setup_X.h deleted file mode 100644 index 27807c10b..000000000 --- a/Engine/lib/libvorbis/lib/modes/setup_X.h +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: catch-all toplevel settings for q modes only - - ********************************************************************/ - -static const double rate_mapping_X[12]={ - -1.,-1.,-1.,-1.,-1.,-1., - -1.,-1.,-1.,-1.,-1.,-1. -}; - -static const ve_setup_data_template ve_setup_X_stereo={ - 11, - rate_mapping_X, - quality_mapping_44, - 2, - 50000, - 200000, - - blocksize_short_44, - blocksize_long_44, - - _psy_tone_masteratt_44, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_otherblock, - _vp_tonemask_adj_longblock, - _vp_tonemask_adj_otherblock, - - _psy_noiseguards_44, - _psy_noisebias_impulse, - _psy_noisebias_padding, - _psy_noisebias_trans, - _psy_noisebias_long, - _psy_noise_suppress, - - _psy_compand_44, - _psy_compand_short_mapping, - _psy_compand_long_mapping, - - {_noise_start_short_44,_noise_start_long_44}, - {_noise_part_short_44,_noise_part_long_44}, - _noise_thresh_44, - - _psy_ath_floater, - _psy_ath_abs, - - _psy_lowpass_44, - - _psy_global_44, - _global_mapping_44, - _psy_stereo_modes_44, - - _floor_books, - _floor, - 2, - _floor_mapping_44, - - _mapres_template_44_stereo -}; - -static const ve_setup_data_template ve_setup_X_uncoupled={ - 11, - rate_mapping_X, - quality_mapping_44, - -1, - 50000, - 200000, - - blocksize_short_44, - blocksize_long_44, - - _psy_tone_masteratt_44, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_otherblock, - _vp_tonemask_adj_longblock, - _vp_tonemask_adj_otherblock, - - _psy_noiseguards_44, - _psy_noisebias_impulse, - _psy_noisebias_padding, - _psy_noisebias_trans, - _psy_noisebias_long, - _psy_noise_suppress, - - _psy_compand_44, - _psy_compand_short_mapping, - _psy_compand_long_mapping, - - {_noise_start_short_44,_noise_start_long_44}, - {_noise_part_short_44,_noise_part_long_44}, - _noise_thresh_44, - - _psy_ath_floater, - _psy_ath_abs, - - _psy_lowpass_44, - - _psy_global_44, - _global_mapping_44, - NULL, - - _floor_books, - _floor, - 2, - _floor_mapping_44, - - _mapres_template_44_uncoupled -}; - -static const ve_setup_data_template ve_setup_XX_stereo={ - 2, - rate_mapping_X, - quality_mapping_8, - 2, - 0, - 8000, - - blocksize_8, - blocksize_8, - - _psy_tone_masteratt_8, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_8, - NULL, - _vp_tonemask_adj_8, - - _psy_noiseguards_8, - _psy_noisebias_8, - _psy_noisebias_8, - NULL, - NULL, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_8_mapping, - NULL, - - {_noise_start_8,_noise_start_8}, - {_noise_part_8,_noise_part_8}, - _noise_thresh_5only, - - _psy_ath_floater_8, - _psy_ath_abs_8, - - _psy_lowpass_8, - - _psy_global_44, - _global_mapping_8, - _psy_stereo_modes_8, - - _floor_books, - _floor, - 1, - _floor_mapping_8, - - _mapres_template_8_stereo -}; - -static const ve_setup_data_template ve_setup_XX_uncoupled={ - 2, - rate_mapping_X, - quality_mapping_8, - -1, - 0, - 8000, - - blocksize_8, - blocksize_8, - - _psy_tone_masteratt_8, - _psy_tone_0dB, - _psy_tone_suppress, - - _vp_tonemask_adj_8, - NULL, - _vp_tonemask_adj_8, - - _psy_noiseguards_8, - _psy_noisebias_8, - _psy_noisebias_8, - NULL, - NULL, - _psy_noise_suppress, - - _psy_compand_8, - _psy_compand_8_mapping, - NULL, - - {_noise_start_8,_noise_start_8}, - {_noise_part_8,_noise_part_8}, - _noise_thresh_5only, - - _psy_ath_floater_8, - _psy_ath_abs_8, - - _psy_lowpass_8, - - _psy_global_44, - _global_mapping_8, - _psy_stereo_modes_8, - - _floor_books, - _floor, - 1, - _floor_mapping_8, - - _mapres_template_8_uncoupled -}; diff --git a/Engine/lib/libvorbis/lib/os.h b/Engine/lib/libvorbis/lib/os.h deleted file mode 100644 index 9ded7358d..000000000 --- a/Engine/lib/libvorbis/lib/os.h +++ /dev/null @@ -1,189 +0,0 @@ -#ifndef _OS_H -#define _OS_H -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: #ifdef jail to whip a few platforms into the UNIX ideal. - - ********************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include "misc.h" - -#ifndef _V_IFDEFJAIL_H_ -# define _V_IFDEFJAIL_H_ - -# ifdef __GNUC__ -# define STIN static __inline__ -# elif defined(_WIN32) -# define STIN static __inline -# else -# define STIN static -# endif - -#ifdef DJGPP -# define rint(x) (floor((x)+0.5f)) -#endif - -#ifndef M_PI -# define M_PI (3.1415926536f) -#endif - -#if defined(_WIN32) && !defined(__SYMBIAN32__) -# include -# define rint(x) (floor((x)+0.5f)) -# define NO_FLOAT_MATH_LIB -# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b)) -#endif - -#if defined(__SYMBIAN32__) && defined(__WINS__) -void *_alloca(size_t size); -# define alloca _alloca -#endif - -#ifndef FAST_HYPOT -# define FAST_HYPOT hypot -#endif - -#endif /* _V_IFDEFJAIL_H_ */ - -#ifdef HAVE_ALLOCA_H -# include -#endif - -#ifdef USE_MEMORY_H -# include -#endif - -#ifndef min -# define min(x,y) ((x)>(y)?(y):(x)) -#endif - -#ifndef max -# define max(x,y) ((x)<(y)?(y):(x)) -#endif - - -/* Special i386 GCC implementation */ -#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__) && !defined(__SSE2_MATH__) -# define VORBIS_FPU_CONTROL -/* both GCC and MSVC are kinda stupid about rounding/casting to int. - Because of encapsulation constraints (GCC can't see inside the asm - block and so we end up doing stupid things like a store/load that - is collectively a noop), we do it this way */ - -/* we must set up the fpu before this works!! */ - -typedef ogg_int16_t vorbis_fpu_control; - -static inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ - ogg_int16_t ret; - ogg_int16_t temp; - __asm__ __volatile__("fnstcw %0\n\t" - "movw %0,%%dx\n\t" - "andw $62463,%%dx\n\t" - "movw %%dx,%1\n\t" - "fldcw %1\n\t":"=m"(ret):"m"(temp): "dx"); - *fpu=ret; -} - -static inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ - __asm__ __volatile__("fldcw %0":: "m"(fpu)); -} - -/* assumes the FPU is in round mode! */ -static inline int vorbis_ftoi(double f){ /* yes, double! Otherwise, - we get extra fst/fld to - truncate precision */ - int i; - __asm__("fistl %0": "=m"(i) : "t"(f)); - return(i); -} -#endif /* Special i386 GCC implementation */ - - -/* MSVC inline assembly. 32 bit only; inline ASM isn't implemented in the - * 64 bit compiler and doesn't work on arm. */ -#if defined(_MSC_VER) && defined(_M_IX86) && !defined(_WIN32_WCE) -# define VORBIS_FPU_CONTROL - -typedef ogg_int16_t vorbis_fpu_control; - -static __inline int vorbis_ftoi(double f){ - int i; - __asm{ - fld f - fistp i - } - return i; -} - -static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ - (void)fpu; -} - -static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ - (void)fpu; -} - -#endif /* Special MSVC 32 bit implementation */ - - -/* Optimized code path for x86_64 builds. Uses SSE2 intrinsics. This can be - done safely because all x86_64 CPUs supports SSE2. */ -#if (defined(_MSC_VER) && defined(_M_X64)) || (defined(__GNUC__) && defined (__SSE2_MATH__)) -# define VORBIS_FPU_CONTROL - -typedef ogg_int16_t vorbis_fpu_control; - -#include -static __inline int vorbis_ftoi(double f){ - return _mm_cvtsd_si32(_mm_load_sd(&f)); -} - -static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ - (void)fpu; -} - -static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ - (void)fpu; -} - -#endif /* Special MSVC x64 implementation */ - - -/* If no special implementation was found for the current compiler / platform, - use the default implementation here: */ -#ifndef VORBIS_FPU_CONTROL - -typedef int vorbis_fpu_control; - -STIN int vorbis_ftoi(double f){ - /* Note: MSVC and GCC (at least on some systems) round towards zero, thus, - the floor() call is required to ensure correct roudning of - negative numbers */ - return (int)floor(f+.5); -} - -/* We don't have special code for this compiler/arch, so do it the slow way */ -# define vorbis_fpu_setround(vorbis_fpu_control) {} -# define vorbis_fpu_restore(vorbis_fpu_control) {} - -#endif /* default implementation */ - -#endif /* _OS_H */ diff --git a/Engine/lib/libvorbis/lib/psy.c b/Engine/lib/libvorbis/lib/psy.c deleted file mode 100644 index 036b094aa..000000000 --- a/Engine/lib/libvorbis/lib/psy.c +++ /dev/null @@ -1,1209 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: psychoacoustics not including preecho - - ********************************************************************/ - -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" - -#include "masking.h" -#include "psy.h" -#include "os.h" -#include "lpc.h" -#include "smallft.h" -#include "scales.h" -#include "misc.h" - -#define NEGINF -9999.f -static const double stereo_threshholds[]={0.0, .5, 1.0, 1.5, 2.5, 4.5, 8.5, 16.5, 9e10}; -static const double stereo_threshholds_limited[]={0.0, .5, 1.0, 1.5, 2.0, 2.5, 4.5, 8.5, 9e10}; - -vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){ - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy_global *gi=&ci->psy_g_param; - vorbis_look_psy_global *look=_ogg_calloc(1,sizeof(*look)); - - look->channels=vi->channels; - - look->ampmax=-9999.; - look->gi=gi; - return(look); -} - -void _vp_global_free(vorbis_look_psy_global *look){ - if(look){ - memset(look,0,sizeof(*look)); - _ogg_free(look); - } -} - -void _vi_gpsy_free(vorbis_info_psy_global *i){ - if(i){ - memset(i,0,sizeof(*i)); - _ogg_free(i); - } -} - -void _vi_psy_free(vorbis_info_psy *i){ - if(i){ - memset(i,0,sizeof(*i)); - _ogg_free(i); - } -} - -static void min_curve(float *c, - float *c2){ - int i; - for(i=0;ic[i])c[i]=c2[i]; -} - -static void attenuate_curve(float *c,float att){ - int i; - for(i=0;iATH[j+k+ath_offset])min=ATH[j+k+ath_offset]; - }else{ - if(min>ATH[MAX_ATH-1])min=ATH[MAX_ATH-1]; - } - ath[j]=min; - } - - /* copy curves into working space, replicate the 50dB curve to 30 - and 40, replicate the 100dB curve to 110 */ - for(j=0;j<6;j++) - memcpy(workc[i][j+2],tonemasks[i][j],EHMER_MAX*sizeof(*tonemasks[i][j])); - memcpy(workc[i][0],tonemasks[i][0],EHMER_MAX*sizeof(*tonemasks[i][0])); - memcpy(workc[i][1],tonemasks[i][0],EHMER_MAX*sizeof(*tonemasks[i][0])); - - /* apply centered curve boost/decay */ - for(j=0;j0)adj=0.; - if(adj>0. && center_boost<0)adj=0.; - workc[i][j][k]+=adj; - } - } - - /* normalize curves so the driving amplitude is 0dB */ - /* make temp curves with the ATH overlayed */ - for(j=0;j an eighth of an octave and that the eighth - octave values may also be composited. */ - - /* which octave curves will we be compositing? */ - bin=floor(fromOC(i*.5)/binHz); - lo_curve= ceil(toOC(bin*binHz+1)*2); - hi_curve= floor(toOC((bin+1)*binHz)*2); - if(lo_curve>i)lo_curve=i; - if(lo_curve<0)lo_curve=0; - if(hi_curve>=P_BANDS)hi_curve=P_BANDS-1; - - for(m=0;mn)lo_bin=n; - if(lo_binn)hi_bin=n; - - for(;lworkc[k][m][j]) - brute_buffer[l]=workc[k][m][j]; - } - - for(;lworkc[k][m][EHMER_MAX-1]) - brute_buffer[l]=workc[k][m][EHMER_MAX-1]; - - } - - /* be equally paranoid about being valid up to next half ocatve */ - if(i+1n)lo_bin=n; - if(lo_binn)hi_bin=n; - - for(;lworkc[k][m][j]) - brute_buffer[l]=workc[k][m][j]; - } - - for(;lworkc[k][m][EHMER_MAX-1]) - brute_buffer[l]=workc[k][m][EHMER_MAX-1]; - - } - - - for(j=0;j=n){ - ret[i][m][j+2]=-999.; - }else{ - ret[i][m][j+2]=brute_buffer[bin]; - } - } - } - - /* add fenceposts */ - for(j=0;j-200.f)break; - ret[i][m][0]=j; - - for(j=EHMER_MAX-1;j>EHMER_OFFSET+1;j--) - if(ret[i][m][j+2]>-200.f) - break; - ret[i][m][1]=j; - - } - } - - return(ret); -} - -void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, - vorbis_info_psy_global *gi,int n,long rate){ - long i,j,lo=-99,hi=1; - long maxoc; - memset(p,0,sizeof(*p)); - - p->eighth_octave_lines=gi->eighth_octave_lines; - p->shiftoc=rint(log(gi->eighth_octave_lines*8.f)/log(2.f))-1; - - p->firstoc=toOC(.25f*rate*.5/n)*(1<<(p->shiftoc+1))-gi->eighth_octave_lines; - maxoc=toOC((n+.25f)*rate*.5/n)*(1<<(p->shiftoc+1))+.5f; - p->total_octave_lines=maxoc-p->firstoc+1; - p->ath=_ogg_malloc(n*sizeof(*p->ath)); - - p->octave=_ogg_malloc(n*sizeof(*p->octave)); - p->bark=_ogg_malloc(n*sizeof(*p->bark)); - p->vi=vi; - p->n=n; - p->rate=rate; - - /* AoTuV HF weighting */ - p->m_val = 1.; - if(rate < 26000) p->m_val = 0; - else if(rate < 38000) p->m_val = .94; /* 32kHz */ - else if(rate > 46000) p->m_val = 1.275; /* 48kHz */ - - /* set up the lookups for a given blocksize and sample rate */ - - for(i=0,j=0;iath[j]=base+100.; - base+=delta; - } - } - } - - for(;jath[j]=p->ath[j-1]; - } - - for(i=0;inoisewindowlominnoisewindowlo);lo++); - - for(;hi<=n && (hinoisewindowhimin || - toBARK(rate/(2*n)*hi)<(bark+vi->noisewindowhi));hi++); - - p->bark[i]=((lo-1)<<16)+(hi-1); - - } - - for(i=0;ioctave[i]=toOC((i+.25f)*.5*rate/n)*(1<<(p->shiftoc+1))+.5f; - - p->tonecurves=setup_tone_curves(vi->toneatt,rate*.5/n,n, - vi->tone_centerboost,vi->tone_decay); - - /* set up rolling noise median */ - p->noiseoffset=_ogg_malloc(P_NOISECURVES*sizeof(*p->noiseoffset)); - for(i=0;inoiseoffset[i]=_ogg_malloc(n*sizeof(**p->noiseoffset)); - - for(i=0;i=P_BANDS-1)halfoc=P_BANDS-1; - inthalfoc=(int)halfoc; - del=halfoc-inthalfoc; - - for(j=0;jnoiseoffset[j][i]= - p->vi->noiseoff[j][inthalfoc]*(1.-del) + - p->vi->noiseoff[j][inthalfoc+1]*del; - - } -#if 0 - { - static int ls=0; - _analysis_output_always("noiseoff0",ls,p->noiseoffset[0],n,1,0,0); - _analysis_output_always("noiseoff1",ls,p->noiseoffset[1],n,1,0,0); - _analysis_output_always("noiseoff2",ls++,p->noiseoffset[2],n,1,0,0); - } -#endif -} - -void _vp_psy_clear(vorbis_look_psy *p){ - int i,j; - if(p){ - if(p->ath)_ogg_free(p->ath); - if(p->octave)_ogg_free(p->octave); - if(p->bark)_ogg_free(p->bark); - if(p->tonecurves){ - for(i=0;itonecurves[i][j]); - } - _ogg_free(p->tonecurves[i]); - } - _ogg_free(p->tonecurves); - } - if(p->noiseoffset){ - for(i=0;inoiseoffset[i]); - } - _ogg_free(p->noiseoffset); - } - memset(p,0,sizeof(*p)); - } -} - -/* octave/(8*eighth_octave_lines) x scale and dB y scale */ -static void seed_curve(float *seed, - const float **curves, - float amp, - int oc, int n, - int linesper,float dBoffset){ - int i,post1; - int seedptr; - const float *posts,*curve; - - int choice=(int)((amp+dBoffset-P_LEVEL_0)*.1f); - choice=max(choice,0); - choice=min(choice,P_LEVELS-1); - posts=curves[choice]; - curve=posts+2; - post1=(int)posts[1]; - seedptr=oc+(posts[0]-EHMER_OFFSET)*linesper-(linesper>>1); - - for(i=posts[0];i0){ - float lin=amp+curve[i]; - if(seed[seedptr]=n)break; - } -} - -static void seed_loop(vorbis_look_psy *p, - const float ***curves, - const float *f, - const float *flr, - float *seed, - float specmax){ - vorbis_info_psy *vi=p->vi; - long n=p->n,i; - float dBoffset=vi->max_curve_dB-specmax; - - /* prime the working vector with peak values */ - - for(i=0;ioctave[i]; - while(i+1octave[i+1]==oc){ - i++; - if(f[i]>max)max=f[i]; - } - - if(max+6.f>flr[i]){ - oc=oc>>p->shiftoc; - - if(oc>=P_BANDS)oc=P_BANDS-1; - if(oc<0)oc=0; - - seed_curve(seed, - curves[oc], - max, - p->octave[i]-p->firstoc, - p->total_octave_lines, - p->eighth_octave_lines, - dBoffset); - } - } -} - -static void seed_chase(float *seeds, int linesper, long n){ - long *posstack=alloca(n*sizeof(*posstack)); - float *ampstack=alloca(n*sizeof(*ampstack)); - long stack=0; - long pos=0; - long i; - - for(i=0;i1 && ampstack[stack-1]<=ampstack[stack-2] && - iampstack[i]){ - endpos=posstack[i+1]; - }else{ - endpos=posstack[i]+linesper+1; /* +1 is important, else bin 0 is - discarded in short frames */ - } - if(endpos>n)endpos=n; - for(;pos -static void max_seeds(vorbis_look_psy *p, - float *seed, - float *flr){ - long n=p->total_octave_lines; - int linesper=p->eighth_octave_lines; - long linpos=0; - long pos; - - seed_chase(seed,linesper,n); /* for masking */ - - pos=p->octave[0]-p->firstoc-(linesper>>1); - - while(linpos+1n){ - float minV=seed[pos]; - long end=((p->octave[linpos]+p->octave[linpos+1])>>1)-p->firstoc; - if(minV>p->vi->tone_abs_limit)minV=p->vi->tone_abs_limit; - while(pos+1<=end){ - pos++; - if((seed[pos]>NEGINF && seed[pos]firstoc; - for(;linposn && p->octave[linpos]<=end;linpos++) - if(flr[linpos]total_octave_lines-1]; - for(;linposn;linpos++) - if(flr[linpos]> 16; - hi = b[i] & 0xffff; - if( lo>=0 || -lo>=n ) break; - if( hi>=n ) break; - - tN = N[hi] + N[-lo]; - tX = X[hi] - X[-lo]; - tXX = XX[hi] + XX[-lo]; - tY = Y[hi] + Y[-lo]; - tXY = XY[hi] - XY[-lo]; - - A = tY * tXX - tX * tXY; - B = tN * tXY - tX * tY; - D = tN * tXX - tX * tX; - R = (A + x * B) / D; - if (R < 0.f) R = 0.f; - - noise[i] = R - offset; - } - - for ( ; i < n; i++, x += 1.f) { - - lo = b[i] >> 16; - hi = b[i] & 0xffff; - if( lo<0 || lo>=n ) break; - if( hi>=n ) break; - - tN = N[hi] - N[lo]; - tX = X[hi] - X[lo]; - tXX = XX[hi] - XX[lo]; - tY = Y[hi] - Y[lo]; - tXY = XY[hi] - XY[lo]; - - A = tY * tXX - tX * tXY; - B = tN * tXY - tX * tY; - D = tN * tXX - tX * tX; - R = (A + x * B) / D; - if (R < 0.f) R = 0.f; - - noise[i] = R - offset; - } - - for ( ; i < n; i++, x += 1.f) { - - R = (A + x * B) / D; - if (R < 0.f) R = 0.f; - - noise[i] = R - offset; - } - - if (fixed <= 0) return; - - for (i = 0, x = 0.f; i < n; i++, x += 1.f) { - hi = i + fixed / 2; - lo = hi - fixed; - if ( hi>=n ) break; - if ( lo>=0 ) break; - - tN = N[hi] + N[-lo]; - tX = X[hi] - X[-lo]; - tXX = XX[hi] + XX[-lo]; - tY = Y[hi] + Y[-lo]; - tXY = XY[hi] - XY[-lo]; - - - A = tY * tXX - tX * tXY; - B = tN * tXY - tX * tY; - D = tN * tXX - tX * tX; - R = (A + x * B) / D; - - if (R - offset < noise[i]) noise[i] = R - offset; - } - for ( ; i < n; i++, x += 1.f) { - - hi = i + fixed / 2; - lo = hi - fixed; - if ( hi>=n ) break; - if ( lo<0 ) break; - - tN = N[hi] - N[lo]; - tX = X[hi] - X[lo]; - tXX = XX[hi] - XX[lo]; - tY = Y[hi] - Y[lo]; - tXY = XY[hi] - XY[lo]; - - A = tY * tXX - tX * tXY; - B = tN * tXY - tX * tY; - D = tN * tXX - tX * tX; - R = (A + x * B) / D; - - if (R - offset < noise[i]) noise[i] = R - offset; - } - for ( ; i < n; i++, x += 1.f) { - R = (A + x * B) / D; - if (R - offset < noise[i]) noise[i] = R - offset; - } -} - -void _vp_noisemask(vorbis_look_psy *p, - float *logmdct, - float *logmask){ - - int i,n=p->n; - float *work=alloca(n*sizeof(*work)); - - bark_noise_hybridmp(n,p->bark,logmdct,logmask, - 140.,-1); - - for(i=0;ibark,work,logmask,0., - p->vi->noisewindowfixed); - - for(i=0;i=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1; - if(dB<0)dB=0; - logmask[i]= work[i]+p->vi->noisecompand[dB]; - } - -} - -void _vp_tonemask(vorbis_look_psy *p, - float *logfft, - float *logmask, - float global_specmax, - float local_specmax){ - - int i,n=p->n; - - float *seed=alloca(sizeof(*seed)*p->total_octave_lines); - float att=local_specmax+p->vi->ath_adjatt; - for(i=0;itotal_octave_lines;i++)seed[i]=NEGINF; - - /* set the ATH (floating below localmax, not global max by a - specified att) */ - if(attvi->ath_maxatt)att=p->vi->ath_maxatt; - - for(i=0;iath[i]+att; - - /* tone masking */ - seed_loop(p,(const float ***)p->tonecurves,logfft,logmask,seed,global_specmax); - max_seeds(p,seed,logmask); - -} - -void _vp_offset_and_mix(vorbis_look_psy *p, - float *noise, - float *tone, - int offset_select, - float *logmask, - float *mdct, - float *logmdct){ - int i,n=p->n; - float de, coeffi, cx;/* AoTuV */ - float toneatt=p->vi->tone_masteratt[offset_select]; - - cx = p->m_val; - - for(i=0;inoiseoffset[offset_select][i]; - if(val>p->vi->noisemaxsupp)val=p->vi->noisemaxsupp; - logmask[i]=max(val,tone[i]+toneatt); - - - /* AoTuV */ - /** @ M1 ** - The following codes improve a noise problem. - A fundamental idea uses the value of masking and carries out - the relative compensation of the MDCT. - However, this code is not perfect and all noise problems cannot be solved. - by Aoyumi @ 2004/04/18 - */ - - if(offset_select == 1) { - coeffi = -17.2; /* coeffi is a -17.2dB threshold */ - val = val - logmdct[i]; /* val == mdct line value relative to floor in dB */ - - if(val > coeffi){ - /* mdct value is > -17.2 dB below floor */ - - de = 1.0-((val-coeffi)*0.005*cx); - /* pro-rated attenuation: - -0.00 dB boost if mdct value is -17.2dB (relative to floor) - -0.77 dB boost if mdct value is 0dB (relative to floor) - -1.64 dB boost if mdct value is +17.2dB (relative to floor) - etc... */ - - if(de < 0) de = 0.0001; - }else - /* mdct value is <= -17.2 dB below floor */ - - de = 1.0-((val-coeffi)*0.0003*cx); - /* pro-rated attenuation: - +0.00 dB atten if mdct value is -17.2dB (relative to floor) - +0.45 dB atten if mdct value is -34.4dB (relative to floor) - etc... */ - - mdct[i] *= de; - - } - } -} - -float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd){ - vorbis_info *vi=vd->vi; - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy_global *gi=&ci->psy_g_param; - - int n=ci->blocksizes[vd->W]/2; - float secs=(float)n/vi->rate; - - amp+=secs*gi->ampmax_att_per_sec; - if(amp<-9999)amp=-9999; - return(amp); -} - -static float FLOOR1_fromdB_LOOKUP[256]={ - 1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F, - 1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F, - 1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F, - 2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F, - 2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F, - 3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F, - 4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F, - 6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F, - 7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F, - 1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F, - 1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F, - 1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F, - 2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F, - 2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F, - 3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F, - 4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F, - 5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F, - 7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F, - 9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F, - 1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F, - 1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F, - 2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F, - 2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F, - 3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F, - 4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F, - 5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F, - 7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F, - 9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F, - 0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F, - 0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F, - 0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F, - 0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F, - 0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F, - 0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F, - 0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F, - 0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F, - 0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F, - 0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F, - 0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F, - 0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F, - 0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F, - 0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F, - 0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F, - 0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F, - 0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F, - 0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F, - 0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F, - 0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F, - 0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F, - 0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F, - 0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F, - 0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F, - 0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F, - 0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F, - 0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F, - 0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F, - 0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F, - 0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F, - 0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F, - 0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F, - 0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F, - 0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F, - 0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F, - 0.82788260F, 0.88168307F, 0.9389798F, 1.F, -}; - -/* this is for per-channel noise normalization */ -static int apsort(const void *a, const void *b){ - float f1=**(float**)a; - float f2=**(float**)b; - return (f1f2); -} - -static void flag_lossless(int limit, float prepoint, float postpoint, float *mdct, - float *floor, int *flag, int i, int jn){ - int j; - for(j=0;j=limit-i ? postpoint : prepoint; - float r = fabs(mdct[j])/floor[j]; - if(rvi; - float **sort = alloca(n*sizeof(*sort)); - int j,count=0; - int start = (vi->normal_p ? vi->normal_start-i : n); - if(start>n)start=n; - - /* force classic behavior where only energy in the current band is considered */ - acc=0.f; - - /* still responsible for populating *out where noise norm not in - effect. There's no need to [re]populate *q in these areas */ - for(j=0;j pointlimit */ - if(ve<.25f && (!flags || j>=limit-i)){ - acc += ve; - sort[count++]=q+j; /* q is fabs(r) for unflagged element */ - }else{ - /* For now: no acc adjustment for nonzero quantization. populate *out and q as this value is final. */ - if(r[j]<0) - out[j] = -rint(sqrt(ve)); - else - out[j] = rint(sqrt(ve)); - q[j] = out[j]*out[j]*f[j]; - } - }/* else{ - again, no energy adjustment for error in nonzero quant-- for now - }*/ - } - - if(count){ - /* noise norm to do */ - qsort(sort,count,sizeof(*sort),apsort); - for(j=0;j=vi->normal_thresh){ - out[k]=unitnorm(r[k]); - acc-=1.f; - q[k]=f[k]; - }else{ - out[k]=0; - q[k]=0.f; - } - } - } - - return acc; -} - -/* Noise normalization, quantization and coupling are not wholly - seperable processes in depth>1 coupling. */ -void _vp_couple_quantize_normalize(int blobno, - vorbis_info_psy_global *g, - vorbis_look_psy *p, - vorbis_info_mapping0 *vi, - float **mdct, - int **iwork, - int *nonzero, - int sliding_lowpass, - int ch){ - - int i; - int n = p->n; - int partition=(p->vi->normal_p ? p->vi->normal_partition : 16); - int limit = g->coupling_pointlimit[p->vi->blockflag][blobno]; - float prepoint=stereo_threshholds[g->coupling_prepointamp[blobno]]; - float postpoint=stereo_threshholds[g->coupling_postpointamp[blobno]]; -#if 0 - float de=0.1*p->m_val; /* a blend of the AoTuV M2 and M3 code here and below */ -#endif - - /* mdct is our raw mdct output, floor not removed. */ - /* inout passes in the ifloor, passes back quantized result */ - - /* unquantized energy (negative indicates amplitude has negative sign) */ - float **raw = alloca(ch*sizeof(*raw)); - - /* dual pupose; quantized energy (if flag set), othersize fabs(raw) */ - float **quant = alloca(ch*sizeof(*quant)); - - /* floor energy */ - float **floor = alloca(ch*sizeof(*floor)); - - /* flags indicating raw/quantized status of elements in raw vector */ - int **flag = alloca(ch*sizeof(*flag)); - - /* non-zero flag working vector */ - int *nz = alloca(ch*sizeof(*nz)); - - /* energy surplus/defecit tracking */ - float *acc = alloca((ch+vi->coupling_steps)*sizeof(*acc)); - - /* The threshold of a stereo is changed with the size of n */ - if(n > 1000) - postpoint=stereo_threshholds_limited[g->coupling_postpointamp[blobno]]; - - raw[0] = alloca(ch*partition*sizeof(**raw)); - quant[0] = alloca(ch*partition*sizeof(**quant)); - floor[0] = alloca(ch*partition*sizeof(**floor)); - flag[0] = alloca(ch*partition*sizeof(**flag)); - - for(i=1;icoupling_steps;i++) - acc[i]=0.f; - - for(i=0;i n-i ? n-i : partition; - int step,track = 0; - - memcpy(nz,nonzero,sizeof(*nz)*ch); - - /* prefill */ - memset(flag[0],0,ch*partition*sizeof(**flag)); - for(k=0;kcoupling_steps;step++){ - int Mi = vi->coupling_mag[step]; - int Ai = vi->coupling_ang[step]; - int *iM = &iwork[Mi][i]; - int *iA = &iwork[Ai][i]; - float *reM = raw[Mi]; - float *reA = raw[Ai]; - float *qeM = quant[Mi]; - float *qeA = quant[Ai]; - float *floorM = floor[Mi]; - float *floorA = floor[Ai]; - int *fM = flag[Mi]; - int *fA = flag[Ai]; - - if(nz[Mi] || nz[Ai]){ - nz[Mi] = nz[Ai] = 1; - - for(j=0;jabs(B)){ - iA[j]=(A>0?A-B:B-A); - }else{ - iA[j]=(B>0?A-B:B-A); - iM[j]=B; - } - - /* collapse two equivalent tuples to one */ - if(iA[j]>=abs(iM[j])*2){ - iA[j]= -iA[j]; - iM[j]= -iM[j]; - } - - } - - }else{ - /* lossy (point) coupling */ - if(jcoupling_steps;i++){ - /* make sure coupling a zero and a nonzero channel results in two - nonzero channels. */ - if(nonzero[vi->coupling_mag[i]] || - nonzero[vi->coupling_ang[i]]){ - nonzero[vi->coupling_mag[i]]=1; - nonzero[vi->coupling_ang[i]]=1; - } - } -} diff --git a/Engine/lib/libvorbis/lib/psy.h b/Engine/lib/libvorbis/lib/psy.h deleted file mode 100644 index d9a04e8b7..000000000 --- a/Engine/lib/libvorbis/lib/psy.h +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: random psychoacoustics (not including preecho) - - ********************************************************************/ - -#ifndef _V_PSY_H_ -#define _V_PSY_H_ -#include "smallft.h" - -#include "backends.h" -#include "envelope.h" - -#ifndef EHMER_MAX -#define EHMER_MAX 56 -#endif - -/* psychoacoustic setup ********************************************/ -#define P_BANDS 17 /* 62Hz to 16kHz */ -#define P_LEVELS 8 /* 30dB to 100dB */ -#define P_LEVEL_0 30. /* 30 dB */ -#define P_NOISECURVES 3 - -#define NOISE_COMPAND_LEVELS 40 -typedef struct vorbis_info_psy{ - int blockflag; - - float ath_adjatt; - float ath_maxatt; - - float tone_masteratt[P_NOISECURVES]; - float tone_centerboost; - float tone_decay; - float tone_abs_limit; - float toneatt[P_BANDS]; - - int noisemaskp; - float noisemaxsupp; - float noisewindowlo; - float noisewindowhi; - int noisewindowlomin; - int noisewindowhimin; - int noisewindowfixed; - float noiseoff[P_NOISECURVES][P_BANDS]; - float noisecompand[NOISE_COMPAND_LEVELS]; - - float max_curve_dB; - - int normal_p; - int normal_start; - int normal_partition; - double normal_thresh; -} vorbis_info_psy; - -typedef struct{ - int eighth_octave_lines; - - /* for block long/short tuning; encode only */ - float preecho_thresh[VE_BANDS]; - float postecho_thresh[VE_BANDS]; - float stretch_penalty; - float preecho_minenergy; - - float ampmax_att_per_sec; - - /* channel coupling config */ - int coupling_pkHz[PACKETBLOBS]; - int coupling_pointlimit[2][PACKETBLOBS]; - int coupling_prepointamp[PACKETBLOBS]; - int coupling_postpointamp[PACKETBLOBS]; - int sliding_lowpass[2][PACKETBLOBS]; - -} vorbis_info_psy_global; - -typedef struct { - float ampmax; - int channels; - - vorbis_info_psy_global *gi; - int coupling_pointlimit[2][P_NOISECURVES]; -} vorbis_look_psy_global; - - -typedef struct { - int n; - struct vorbis_info_psy *vi; - - float ***tonecurves; - float **noiseoffset; - - float *ath; - long *octave; /* in n.ocshift format */ - long *bark; - - long firstoc; - long shiftoc; - int eighth_octave_lines; /* power of two, please */ - int total_octave_lines; - long rate; /* cache it */ - - float m_val; /* Masking compensation value */ - -} vorbis_look_psy; - -extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, - vorbis_info_psy_global *gi,int n,long rate); -extern void _vp_psy_clear(vorbis_look_psy *p); -extern void *_vi_psy_dup(void *source); - -extern void _vi_psy_free(vorbis_info_psy *i); -extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i); - -extern void _vp_noisemask(vorbis_look_psy *p, - float *logmdct, - float *logmask); - -extern void _vp_tonemask(vorbis_look_psy *p, - float *logfft, - float *logmask, - float global_specmax, - float local_specmax); - -extern void _vp_offset_and_mix(vorbis_look_psy *p, - float *noise, - float *tone, - int offset_select, - float *logmask, - float *mdct, - float *logmdct); - -extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd); - -extern void _vp_couple_quantize_normalize(int blobno, - vorbis_info_psy_global *g, - vorbis_look_psy *p, - vorbis_info_mapping0 *vi, - float **mdct, - int **iwork, - int *nonzero, - int sliding_lowpass, - int ch); - -#endif diff --git a/Engine/lib/libvorbis/lib/psytune.c b/Engine/lib/libvorbis/lib/psytune.c deleted file mode 100644 index 67223e511..000000000 --- a/Engine/lib/libvorbis/lib/psytune.c +++ /dev/null @@ -1,523 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: simple utility that runs audio through the psychoacoustics - without encoding - - ********************************************************************/ - -/* NB: this is dead code, retained purely for doc and reference value - don't try to compile it */ - -#include -#include -#include -#include - -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "os.h" -#include "misc.h" -#include "psy.h" -#include "mdct.h" -#include "smallft.h" -#include "window.h" -#include "scales.h" -#include "lpc.h" -#include "lsp.h" -#include "masking.h" -#include "registry.h" - -static vorbis_info_psy_global _psy_set0G={ - 0, /* decaydBpms */ - 8, /* lines per eighth octave */ - - /* thresh sample period, preecho clamp trigger threshhold, range, minenergy */ - 256, {26.f,26.f,26.f,30.f}, {-90.f,-90.f,-90.f,-90.f}, -90.f, - -6.f, - - 0, - - 0., - 0., -}; - -static vp_part _vp_part0[]={ - { 1,9e10f, 9e10f, 1.f,9999.f}, - { 9999, .75f, 9e10f, .5f,9999.f}, -/*{ 9999, 1.5f, 9e10f, .5f,9999.f},*/ - { 18,9e10f, 9e10f, .5f, 30.f}, - { 9999,9e10f, 9e10f, .5f, 30.f} -}; - -static vp_couple _vp_couple0[]={ - { 1, {9e10f,9e10f,0}, { 0.f, 0.f,0}, { 0.f, 0.f,0}, {0.f,0.f,0}}, - { 18, {9e10f,9e10f,0}, { 0.f, 0.f,0}, { 0.f, 0.f,0}, {0.f,0.f,0}}, - { 9999, {9e10f,9e10f,0}, { 0.f, 9e10f,0}, { 0.f,22.f,1}, {0.f,0.f,0}} -}; - -static vorbis_info_psy _psy_set0={ - ATH_Bark_dB_lineaggressive, - - -100.f, - -140.f, - 6.f, /* floor master att */ - - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */ - /* x: 63 88 125 175 250 350 500 700 1k 1.4k 2k 2.8k 4k 5.6k 8k 11.5k 16k Hz */ - /* y: 0 10 20 30 40 50 60 70 80 90 100 dB */ - 1, /* tonemaskp */ - 0.f, /* tone master att */ - /* 0 10 20 30 40 50 60 70 80 90 100 */ - { - {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f}, /*63*/ - {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f}, /*88*/ - {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f}, /*125*/ - - {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*175*/ - {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*250*/ - {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*350*/ - {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*500*/ - {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*700*/ - {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*1000*/ - {-30.f,-30.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*1400*/ - {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*2000*/ - {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*2800*/ - {-40.f,-40.f,-40.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*4000*/ - - {-30.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*5600*/ - - {-30.f,-30.f,-33.f,-35.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*8000*/ - {-30.f,-30.f,-33.f,-35.f,-40.f,-45.f,-50.f,-60.f,-70.f,-85.f,-100.f}, /*11500*/ - {-24.f,-24.f,-26.f,-32.f,-32.f,-42.f,-50.f,-60.f,-70.f,-85.f,-100.f}, /*16000*/ - - }, - - 1,/* peakattp */ - {{-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*63*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*88*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*125*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*175*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*250*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*350*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*500*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*700*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*1000*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*1400*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*2000*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*2800*/ - {-14.f,-20.f,-20.f,-20.f,-26.f,-32.f,-40.f,-40.f,-40.f,-40.f,-40.f},/*4000*/ - {-10.f,-12.f,-14.f,-16.f,-16.f,-20.f,-24.f,-30.f,-32.f,-40.f,-40.f},/*5600*/ - {-10.f,-12.f,-14.f,-16.f,-16.f,-20.f,-24.f,-30.f,-32.f,-40.f,-40.f},/*8000*/ - {-10.f,-10.f,-10.f,-12.f,-14.f,-18.f,-22.f,-28.f,-32.f,-40.f,-40.f},/*11500*/ - {-10.f,-10.f,-10.f,-12.f,-14.f,-18.f,-22.f,-28.f,-32.f,-40.f,-40.f},/*16000*/ - }, - - 1,/*noisemaskp */ - -10.f, /* suppress any noise curve over maxspec+n */ - .5f, /* low window */ - .5f, /* high window */ - 10, - 10, - 25, - {.000f, 0.f, /*63*/ - .000f, 0.f, /*88*/ - .000f, 0.f, /*125*/ - .000f, 0.f, /*175*/ - .000f, 0.f, /*250*/ - .000f, 0.f, /*350*/ - .000f, 0.f, /*500*/ - .000f, 0.f, /*700*/ - .000f, 0.f, /*1000*/ - .300f, 0.f, /*1400*/ - .300f, 0.f, /*2000*/ - .300f, 0.f, /*2800*/ - .500f, 0.f, /*4000*/ - .700f, 0.f, /*5600*/ - .850f, 0.f, /*8000*/ - .900f, 0.f, /*11500*/ - .900f, 1.f, /*16000*/ - }, - - 95.f, /* even decade + 5 is important; saves an rint() later in a - tight loop) */ - -44., - - 32, - _vp_part0,_vp_couple0 -}; - -static vorbis_info_floor1 _floor_set0={1, - {0}, - - {32}, - {0}, - {0}, - {{-1}}, - - 2, - {0,1024, - - 88,31,243, - - 14,54,143,460, - - 6,3,10, 22,18,26, 41,36,47, - 69,61,78, 112,99,126, 185,162,211, - 329,282,387, 672,553,825 - }, - - 60,30,400, - 20,8,1,18., - 20,600, - 960}; - - -static vorbis_info_mapping0 mapping_info={1,{0,1},{0},{0},{0},0, 1, {0},{1}}; -static codec_setup_info codec_setup0={ {0,0}, - 1,1,1,1,1,0,1, - {NULL}, - {0},{&mapping_info}, - {0},{NULL}, - {1},{&_floor_set0}, - {2},{NULL}, - {NULL}, - {&_psy_set0}, - &_psy_set0G}; - -static int noisy=0; -void analysis(char *base,int i,float *v,int n,int bark,int dB){ - if(noisy){ - int j; - FILE *of; - char buffer[80]; - sprintf(buffer,"%s_%d.m",base,i); - of=fopen(buffer,"w"); - - for(j=0;jlook(NULL,NULL,&_floor_set0); - - /* we cheat on the WAV header; we just bypass 44 bytes and never - verify that it matches 16bit/stereo/44.1kHz. */ - - fread(buffer,1,44,stdin); - fwrite(buffer,1,44,stdout); - memset(buffer,0,framesize*2); - - analysis("window",0,window,framesize,0,0); - - fprintf(stderr,"Processing for frame size %d...\n",framesize); - - while(!eos){ - long bytes=fread(buffer2,1,framesize*2,stdin); - if(bytes>1]=todB(&temp); - if(temp>local_ampmax[i])local_ampmax[i]=temp; - } - if(local_ampmax[i]>ampmax)ampmax=local_ampmax[i]; - - mdct_forward(&m_look,pcm[i],mdct); - for(j=0;jforward(&vb,floor_look, - mdct, - logmdct, - mask, - logmax, - - flr[i]); - } - - _vp_remove_floor(&p_look, - pg_look, - logmdct, - mdct, - flr[i], - pcm[i], - local_ampmax[i]); - - for(j=0;j1500) - fprintf(stderr,"%ld ",frameno+i); - - analysis("res",frameno+i,pcm[i],framesize/2,1,0); - analysis("codedflr",frameno+i,flr[i],framesize/2,1,1); - } - - /* residue prequantization */ - _vp_partition_prequant(&p_look, - &vi, - pcm, - nonzero); - - for(i=0;i<2;i++) - analysis("quant",frameno+i,pcm[i],framesize/2,1,0); - - /* channel coupling / stereo quantization */ - - _vp_couple(&p_look, - &mapping_info, - pcm, - nonzero); - - for(i=0;i<2;i++) - analysis("coupled",frameno+i,pcm[i],framesize/2,1,0); - - /* decoupling */ - for(i=mapping_info.coupling_steps-1;i>=0;i--){ - float *pcmM=pcm[mapping_info.coupling_mag[i]]; - float *pcmA=pcm[mapping_info.coupling_ang[i]]; - - for(j=0;j0) - if(ang>0){ - pcmM[j]=mag; - pcmA[j]=mag-ang; - }else{ - pcmA[j]=mag; - pcmM[j]=mag+ang; - } - else - if(ang>0){ - pcmM[j]=mag; - pcmA[j]=mag+ang; - }else{ - pcmA[j]=mag; - pcmM[j]=mag-ang; - } - } - } - - for(i=0;i<2;i++) - analysis("decoupled",frameno+i,pcm[i],framesize/2,1,0); - - for(i=0;i<2;i++){ - float amp; - - for(j=0;j32767){ - if(!flag)fprintf(stderr,"clipping in frame %ld ",frameno+i); - flag=1; - val=32767; - } - if(val<-32768){ - if(!flag)fprintf(stderr,"clipping in frame %ld ",frameno+i); - flag=1; - val=-32768; - } - ptr[0]=val&0xff; - ptr[1]=(val>>8)&0xff; - ptr+=4; - } - } - - fprintf(stderr,"*"); - fwrite(buffer,1,framesize*2,stdout); - memmove(buffer,buffer2,framesize*2); - - for(i=0;i<2;i++){ - for(j=0,k=framesize/2;j -#include -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "registry.h" -#include "codebook.h" -#include "misc.h" -#include "os.h" - -#if defined(TRAIN_RES) || defined (TRAIN_RESAUX) -#include -#endif - -typedef struct { - vorbis_info_residue0 *info; - - int parts; - int stages; - codebook *fullbooks; - codebook *phrasebook; - codebook ***partbooks; - - int partvals; - int **decodemap; - - long postbits; - long phrasebits; - long frames; - -#if defined(TRAIN_RES) || defined(TRAIN_RESAUX) - int train_seq; - long *training_data[8][64]; - float training_max[8][64]; - float training_min[8][64]; - float tmin; - float tmax; - int submap; -#endif - -} vorbis_look_residue0; - -void res0_free_info(vorbis_info_residue *i){ - vorbis_info_residue0 *info=(vorbis_info_residue0 *)i; - if(info){ - memset(info,0,sizeof(*info)); - _ogg_free(info); - } -} - -void res0_free_look(vorbis_look_residue *i){ - int j; - if(i){ - - vorbis_look_residue0 *look=(vorbis_look_residue0 *)i; - -#ifdef TRAIN_RES - { - int j,k,l; - for(j=0;jparts;j++){ - /*fprintf(stderr,"partition %d: ",j);*/ - for(k=0;k<8;k++) - if(look->training_data[k][j]){ - char buffer[80]; - FILE *of; - codebook *statebook=look->partbooks[j][k]; - - /* long and short into the same bucket by current convention */ - sprintf(buffer,"res_sub%d_part%d_pass%d.vqd",look->submap,j,k); - of=fopen(buffer,"a"); - - for(l=0;lentries;l++) - fprintf(of,"%d:%ld\n",l,look->training_data[k][j][l]); - - fclose(of); - - /*fprintf(stderr,"%d(%.2f|%.2f) ",k, - look->training_min[k][j],look->training_max[k][j]);*/ - - _ogg_free(look->training_data[k][j]); - look->training_data[k][j]=NULL; - } - /*fprintf(stderr,"\n");*/ - } - } - fprintf(stderr,"min/max residue: %g::%g\n",look->tmin,look->tmax); - - /*fprintf(stderr,"residue bit usage %f:%f (%f total)\n", - (float)look->phrasebits/look->frames, - (float)look->postbits/look->frames, - (float)(look->postbits+look->phrasebits)/look->frames);*/ -#endif - - - /*vorbis_info_residue0 *info=look->info; - - fprintf(stderr, - "%ld frames encoded in %ld phrasebits and %ld residue bits " - "(%g/frame) \n",look->frames,look->phrasebits, - look->resbitsflat, - (look->phrasebits+look->resbitsflat)/(float)look->frames); - - for(j=0;jparts;j++){ - long acc=0; - fprintf(stderr,"\t[%d] == ",j); - for(k=0;kstages;k++) - if((info->secondstages[j]>>k)&1){ - fprintf(stderr,"%ld,",look->resbits[j][k]); - acc+=look->resbits[j][k]; - } - - fprintf(stderr,":: (%ld vals) %1.2fbits/sample\n",look->resvals[j], - acc?(float)acc/(look->resvals[j]*info->grouping):0); - } - fprintf(stderr,"\n");*/ - - for(j=0;jparts;j++) - if(look->partbooks[j])_ogg_free(look->partbooks[j]); - _ogg_free(look->partbooks); - for(j=0;jpartvals;j++) - _ogg_free(look->decodemap[j]); - _ogg_free(look->decodemap); - - memset(look,0,sizeof(*look)); - _ogg_free(look); - } -} - -static int icount(unsigned int v){ - int ret=0; - while(v){ - ret+=v&1; - v>>=1; - } - return(ret); -} - - -void res0_pack(vorbis_info_residue *vr,oggpack_buffer *opb){ - vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr; - int j,acc=0; - oggpack_write(opb,info->begin,24); - oggpack_write(opb,info->end,24); - - oggpack_write(opb,info->grouping-1,24); /* residue vectors to group and - code with a partitioned book */ - oggpack_write(opb,info->partitions-1,6); /* possible partition choices */ - oggpack_write(opb,info->groupbook,8); /* group huffman book */ - - /* secondstages is a bitmask; as encoding progresses pass by pass, a - bitmask of one indicates this partition class has bits to write - this pass */ - for(j=0;jpartitions;j++){ - if(ov_ilog(info->secondstages[j])>3){ - /* yes, this is a minor hack due to not thinking ahead */ - oggpack_write(opb,info->secondstages[j],3); - oggpack_write(opb,1,1); - oggpack_write(opb,info->secondstages[j]>>3,5); - }else - oggpack_write(opb,info->secondstages[j],4); /* trailing zero */ - acc+=icount(info->secondstages[j]); - } - for(j=0;jbooklist[j],8); - -} - -/* vorbis_info is for range checking */ -vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){ - int j,acc=0; - vorbis_info_residue0 *info=_ogg_calloc(1,sizeof(*info)); - codec_setup_info *ci=vi->codec_setup; - - info->begin=oggpack_read(opb,24); - info->end=oggpack_read(opb,24); - info->grouping=oggpack_read(opb,24)+1; - info->partitions=oggpack_read(opb,6)+1; - info->groupbook=oggpack_read(opb,8); - - /* check for premature EOP */ - if(info->groupbook<0)goto errout; - - for(j=0;jpartitions;j++){ - int cascade=oggpack_read(opb,3); - int cflag=oggpack_read(opb,1); - if(cflag<0) goto errout; - if(cflag){ - int c=oggpack_read(opb,5); - if(c<0) goto errout; - cascade|=(c<<3); - } - info->secondstages[j]=cascade; - - acc+=icount(cascade); - } - for(j=0;jbooklist[j]=book; - } - - if(info->groupbook>=ci->books)goto errout; - for(j=0;jbooklist[j]>=ci->books)goto errout; - if(ci->book_param[info->booklist[j]]->maptype==0)goto errout; - } - - /* verify the phrasebook is not specifying an impossible or - inconsistent partitioning scheme. */ - /* modify the phrasebook ranging check from r16327; an early beta - encoder had a bug where it used an oversized phrasebook by - accident. These files should continue to be playable, but don't - allow an exploit */ - { - int entries = ci->book_param[info->groupbook]->entries; - int dim = ci->book_param[info->groupbook]->dim; - int partvals = 1; - if (dim<1) goto errout; - while(dim>0){ - partvals *= info->partitions; - if(partvals > entries) goto errout; - dim--; - } - info->partvals = partvals; - } - - return(info); - errout: - res0_free_info(info); - return(NULL); -} - -vorbis_look_residue *res0_look(vorbis_dsp_state *vd, - vorbis_info_residue *vr){ - vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr; - vorbis_look_residue0 *look=_ogg_calloc(1,sizeof(*look)); - codec_setup_info *ci=vd->vi->codec_setup; - - int j,k,acc=0; - int dim; - int maxstage=0; - look->info=info; - - look->parts=info->partitions; - look->fullbooks=ci->fullbooks; - look->phrasebook=ci->fullbooks+info->groupbook; - dim=look->phrasebook->dim; - - look->partbooks=_ogg_calloc(look->parts,sizeof(*look->partbooks)); - - for(j=0;jparts;j++){ - int stages=ov_ilog(info->secondstages[j]); - if(stages){ - if(stages>maxstage)maxstage=stages; - look->partbooks[j]=_ogg_calloc(stages,sizeof(*look->partbooks[j])); - for(k=0;ksecondstages[j]&(1<partbooks[j][k]=ci->fullbooks+info->booklist[acc++]; -#ifdef TRAIN_RES - look->training_data[k][j]=_ogg_calloc(look->partbooks[j][k]->entries, - sizeof(***look->training_data)); -#endif - } - } - } - - look->partvals=1; - for(j=0;jpartvals*=look->parts; - - look->stages=maxstage; - look->decodemap=_ogg_malloc(look->partvals*sizeof(*look->decodemap)); - for(j=0;jpartvals;j++){ - long val=j; - long mult=look->partvals/look->parts; - look->decodemap[j]=_ogg_malloc(dim*sizeof(*look->decodemap[j])); - for(k=0;kparts; - look->decodemap[j][k]=deco; - } - } -#if defined(TRAIN_RES) || defined (TRAIN_RESAUX) - { - static int train_seq=0; - look->train_seq=train_seq++; - } -#endif - return(look); -} - -/* break an abstraction and copy some code for performance purposes */ -static int local_book_besterror(codebook *book,int *a){ - int dim=book->dim; - int i,j,o; - int minval=book->minval; - int del=book->delta; - int qv=book->quantvals; - int ze=(qv>>1); - int index=0; - /* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */ - int p[8]={0,0,0,0,0,0,0,0}; - - if(del!=1){ - for(i=0,o=dim;i>1))/del; - int m = (v=qv?qv-1:m)); - p[o]=v*del+minval; - } - }else{ - for(i=0,o=dim;i=qv?qv-1:m)); - p[o]=v*del+minval; - } - } - - if(book->c->lengthlist[index]<=0){ - const static_codebook *c=book->c; - int best=-1; - /* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */ - int e[8]={0,0,0,0,0,0,0,0}; - int maxval = book->minval + book->delta*(book->quantvals-1); - for(i=0;ientries;i++){ - if(c->lengthlist[i]>0){ - int this=0; - for(j=0;j=maxval) - e[j++]=0; - if(e[j]>=0) - e[j]+=book->delta; - e[j]= -e[j]; - } - } - - if(index>-1){ - for(i=0;idim; - int step=n/dim; - - for(i=0;i=0) - acc[entry]++; -#endif - - bits+=vorbis_book_encode(book,entry,opb); - - } - - return(bits); -} - -static long **_01class(vorbis_block *vb,vorbis_look_residue *vl, - int **in,int ch){ - long i,j,k; - vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; - vorbis_info_residue0 *info=look->info; - - /* move all this setup out later */ - int samples_per_partition=info->grouping; - int possible_partitions=info->partitions; - int n=info->end-info->begin; - - int partvals=n/samples_per_partition; - long **partword=_vorbis_block_alloc(vb,ch*sizeof(*partword)); - float scale=100./samples_per_partition; - - /* we find the partition type for each partition of each - channel. We'll go back and do the interleaved encoding in a - bit. For now, clarity */ - - for(i=0;ibegin; - for(j=0;jmax)max=abs(in[j][offset+k]); - ent+=abs(in[j][offset+k]); - } - ent*=scale; - - for(k=0;kclassmetric1[k] && - (info->classmetric2[k]<0 || entclassmetric2[k])) - break; - - partword[j][i]=k; - } - } - -#ifdef TRAIN_RESAUX - { - FILE *of; - char buffer[80]; - - for(i=0;itrain_seq); - of=fopen(buffer,"a"); - for(j=0;jframes++; - - return(partword); -} - -/* designed for stereo or other modes where the partition size is an - integer multiple of the number of channels encoded in the current - submap */ -static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,int **in, - int ch){ - long i,j,k,l; - vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; - vorbis_info_residue0 *info=look->info; - - /* move all this setup out later */ - int samples_per_partition=info->grouping; - int possible_partitions=info->partitions; - int n=info->end-info->begin; - - int partvals=n/samples_per_partition; - long **partword=_vorbis_block_alloc(vb,sizeof(*partword)); - -#if defined(TRAIN_RES) || defined (TRAIN_RESAUX) - FILE *of; - char buffer[80]; -#endif - - partword[0]=_vorbis_block_alloc(vb,partvals*sizeof(*partword[0])); - memset(partword[0],0,partvals*sizeof(*partword[0])); - - for(i=0,l=info->begin/ch;imagmax)magmax=abs(in[0][l]); - for(k=1;kangmax)angmax=abs(in[k][l]); - l++; - } - - for(j=0;jclassmetric1[j] && - angmax<=info->classmetric2[j]) - break; - - partword[0][i]=j; - - } - -#ifdef TRAIN_RESAUX - sprintf(buffer,"resaux_%d.vqd",look->train_seq); - of=fopen(buffer,"a"); - for(i=0;iframes++; - - return(partword); -} - -static int _01forward(oggpack_buffer *opb, - vorbis_look_residue *vl, - int **in,int ch, - long **partword, -#ifdef TRAIN_RES - int (*encode)(oggpack_buffer *,int *,int, - codebook *,long *), - int submap -#else - int (*encode)(oggpack_buffer *,int *,int, - codebook *) -#endif -){ - long i,j,k,s; - vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; - vorbis_info_residue0 *info=look->info; - -#ifdef TRAIN_RES - look->submap=submap; -#endif - - /* move all this setup out later */ - int samples_per_partition=info->grouping; - int possible_partitions=info->partitions; - int partitions_per_word=look->phrasebook->dim; - int n=info->end-info->begin; - - int partvals=n/samples_per_partition; - long resbits[128]; - long resvals[128]; - -#ifdef TRAIN_RES - for(i=0;ibegin;jend;j++){ - if(in[i][j]>look->tmax)look->tmax=in[i][j]; - if(in[i][j]tmin)look->tmin=in[i][j]; - } -#endif - - memset(resbits,0,sizeof(resbits)); - memset(resvals,0,sizeof(resvals)); - - /* we code the partition words for each channel, then the residual - words for a partition per channel until we've written all the - residual words for that partition word. Then write the next - partition channel words... */ - - for(s=0;sstages;s++){ - - for(i=0;iphrasebook->entries) - look->phrasebits+=vorbis_book_encode(look->phrasebook,val,opb); -#if 0 /*def TRAIN_RES*/ - else - fprintf(stderr,"!"); -#endif - - } - } - - /* now we encode interleaved residual values for the partitions */ - for(k=0;kbegin; - - for(j=0;jsecondstages[partword[j][i]]&(1<partbooks[partword[j][i]][s]; - if(statebook){ - int ret; -#ifdef TRAIN_RES - long *accumulator=NULL; - accumulator=look->training_data[s][partword[j][i]]; - { - int l; - int *samples=in[j]+offset; - for(l=0;ltraining_min[s][partword[j][i]]) - look->training_min[s][partword[j][i]]=samples[l]; - if(samples[l]>look->training_max[s][partword[j][i]]) - look->training_max[s][partword[j][i]]=samples[l]; - } - } - ret=encode(opb,in[j]+offset,samples_per_partition, - statebook,accumulator); -#else - ret=encode(opb,in[j]+offset,samples_per_partition, - statebook); -#endif - - look->postbits+=ret; - resbits[partword[j][i]]+=ret; - } - } - } - } - } - } - - return(0); -} - -/* a truncated packet here just means 'stop working'; it's not an error */ -static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl, - float **in,int ch, - long (*decodepart)(codebook *, float *, - oggpack_buffer *,int)){ - - long i,j,k,l,s; - vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; - vorbis_info_residue0 *info=look->info; - - /* move all this setup out later */ - int samples_per_partition=info->grouping; - int partitions_per_word=look->phrasebook->dim; - int max=vb->pcmend>>1; - int end=(info->endend:max); - int n=end-info->begin; - - if(n>0){ - int partvals=n/samples_per_partition; - int partwords=(partvals+partitions_per_word-1)/partitions_per_word; - int ***partword=alloca(ch*sizeof(*partword)); - - for(j=0;jstages;s++){ - - /* each loop decodes on partition codeword containing - partitions_per_word partitions */ - for(i=0,l=0;iphrasebook,&vb->opb); - - if(temp==-1 || temp>=info->partvals)goto eopbreak; - partword[j][l]=look->decodemap[temp]; - if(partword[j][l]==NULL)goto errout; - } - } - - /* now we decode residual values for the partitions */ - for(k=0;kbegin+i*samples_per_partition; - if(info->secondstages[partword[j][l][k]]&(1<partbooks[partword[j][l][k]][s]; - if(stagebook){ - if(decodepart(stagebook,in[j]+offset,&vb->opb, - samples_per_partition)==-1)goto eopbreak; - } - } - } - } - } - } - errout: - eopbreak: - return(0); -} - -int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl, - float **in,int *nonzero,int ch){ - int i,used=0; - for(i=0;ipcmend/2,used=0; - - /* don't duplicate the code; use a working vector hack for now and - reshape ourselves into a single channel res1 */ - /* ugly; reallocs for each coupling pass :-( */ - int *work=_vorbis_block_alloc(vb,ch*n*sizeof(*work)); - for(i=0;iinfo; - - /* move all this setup out later */ - int samples_per_partition=info->grouping; - int partitions_per_word=look->phrasebook->dim; - int max=(vb->pcmend*ch)>>1; - int end=(info->endend:max); - int n=end-info->begin; - - if(n>0){ - int partvals=n/samples_per_partition; - int partwords=(partvals+partitions_per_word-1)/partitions_per_word; - int **partword=_vorbis_block_alloc(vb,partwords*sizeof(*partword)); - - for(i=0;istages;s++){ - for(i=0,l=0;iphrasebook,&vb->opb); - if(temp==-1 || temp>=info->partvals)goto eopbreak; - partword[l]=look->decodemap[temp]; - if(partword[l]==NULL)goto errout; - } - - /* now we decode residual values for the partitions */ - for(k=0;ksecondstages[partword[l][k]]&(1<partbooks[partword[l][k]][s]; - - if(stagebook){ - if(vorbis_book_decodevv_add(stagebook,in, - i*samples_per_partition+info->begin,ch, - &vb->opb,samples_per_partition)==-1) - goto eopbreak; - } - } - } - } - } - errout: - eopbreak: - return(0); -} - - -const vorbis_func_residue residue0_exportbundle={ - NULL, - &res0_unpack, - &res0_look, - &res0_free_info, - &res0_free_look, - NULL, - NULL, - &res0_inverse -}; - -const vorbis_func_residue residue1_exportbundle={ - &res0_pack, - &res0_unpack, - &res0_look, - &res0_free_info, - &res0_free_look, - &res1_class, - &res1_forward, - &res1_inverse -}; - -const vorbis_func_residue residue2_exportbundle={ - &res0_pack, - &res0_unpack, - &res0_look, - &res0_free_info, - &res0_free_look, - &res2_class, - &res2_forward, - &res2_inverse -}; diff --git a/Engine/lib/libvorbis/lib/scales.h b/Engine/lib/libvorbis/lib/scales.h deleted file mode 100644 index 3c2ae48d9..000000000 --- a/Engine/lib/libvorbis/lib/scales.h +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: linear scale -> dB, Bark and Mel scales - - ********************************************************************/ - -#ifndef _V_SCALES_H_ -#define _V_SCALES_H_ - -#include -#include "os.h" - -#ifdef _MSC_VER -/* MS Visual Studio doesn't have C99 inline keyword. */ -#define inline __inline -#endif - -/* 20log10(x) */ -#define VORBIS_IEEE_FLOAT32 1 -#ifdef VORBIS_IEEE_FLOAT32 - -static inline float unitnorm(float x){ - union { - ogg_uint32_t i; - float f; - } ix; - ix.f = x; - ix.i = (ix.i & 0x80000000U) | (0x3f800000U); - return ix.f; -} - -/* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */ -static inline float todB(const float *x){ - union { - ogg_uint32_t i; - float f; - } ix; - ix.f = *x; - ix.i = ix.i&0x7fffffff; - return (float)(ix.i * 7.17711438e-7f -764.6161886f); -} - -#define todB_nn(x) todB(x) - -#else - -static float unitnorm(float x){ - if(x<0)return(-1.f); - return(1.f); -} - -#define todB(x) (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f) -#define todB_nn(x) (*(x)==0.f?-400.f:log(*(x))*8.6858896f) - -#endif - -#define fromdB(x) (exp((x)*.11512925f)) - -/* The bark scale equations are approximations, since the original - table was somewhat hand rolled. The below are chosen to have the - best possible fit to the rolled tables, thus their somewhat odd - appearance (these are more accurate and over a longer range than - the oft-quoted bark equations found in the texts I have). The - approximations are valid from 0 - 30kHz (nyquist) or so. - - all f in Hz, z in Bark */ - -#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) -#define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f) -#define toMEL(n) (log(1.f+(n)*.001f)*1442.695f) -#define fromMEL(m) (1000.f*exp((m)/1442.695f)-1000.f) - -/* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave - 0.0 */ - -#define toOC(n) (log(n)*1.442695f-5.965784f) -#define fromOC(o) (exp(((o)+5.965784f)*.693147f)) - -#endif diff --git a/Engine/lib/libvorbis/lib/sharedbook.c b/Engine/lib/libvorbis/lib/sharedbook.c deleted file mode 100644 index 62a9a00af..000000000 --- a/Engine/lib/libvorbis/lib/sharedbook.c +++ /dev/null @@ -1,604 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: basic shared codebook operations - - ********************************************************************/ - -#include -#include -#include -#include -#include -#include "os.h" -#include "misc.h" -#include "vorbis/codec.h" -#include "codebook.h" -#include "scales.h" - -/**** pack/unpack helpers ******************************************/ - -int ov_ilog(ogg_uint32_t v){ - int ret; - for(ret=0;v;ret++)v>>=1; - return ret; -} - -/* 32 bit float (not IEEE; nonnormalized mantissa + - biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm - Why not IEEE? It's just not that important here. */ - -#define VQ_FEXP 10 -#define VQ_FMAN 21 -#define VQ_FEXP_BIAS 768 /* bias toward values smaller than 1. */ - -/* doesn't currently guard under/overflow */ -long _float32_pack(float val){ - int sign=0; - long exp; - long mant; - if(val<0){ - sign=0x80000000; - val= -val; - } - exp= floor(log(val)/log(2.f)+.001); /* +epsilon */ - mant=rint(ldexp(val,(VQ_FMAN-1)-exp)); - exp=(exp+VQ_FEXP_BIAS)<>VQ_FMAN; - if(sign)mant= -mant; - exp=exp-(VQ_FMAN-1)-VQ_FEXP_BIAS; - /* clamp excessive exponent values */ - if (exp>63){ - exp=63; - } - if (exp<-63){ - exp=-63; - } - return(ldexp(mant,exp)); -} - -/* given a list of word lengths, generate a list of codewords. Works - for length ordered or unordered, always assigns the lowest valued - codewords first. Extended to handle unused entries (length 0) */ -ogg_uint32_t *_make_words(char *l,long n,long sparsecount){ - long i,j,count=0; - ogg_uint32_t marker[33]; - ogg_uint32_t *r=_ogg_malloc((sparsecount?sparsecount:n)*sizeof(*r)); - memset(marker,0,sizeof(marker)); - - for(i=0;i0){ - ogg_uint32_t entry=marker[length]; - - /* when we claim a node for an entry, we also claim the nodes - below it (pruning off the imagined tree that may have dangled - from it) as well as blocking the use of any nodes directly - above for leaves */ - - /* update ourself */ - if(length<32 && (entry>>length)){ - /* error condition; the lengths must specify an overpopulated tree */ - _ogg_free(r); - return(NULL); - } - r[count++]=entry; - - /* Look to see if the next shorter marker points to the node - above. if so, update it and repeat. */ - { - for(j=length;j>0;j--){ - - if(marker[j]&1){ - /* have to jump branches */ - if(j==1) - marker[1]++; - else - marker[j]=marker[j-1]<<1; - break; /* invariant says next upper marker would already - have been moved if it was on the same path */ - } - marker[j]++; - } - } - - /* prune the tree; the implicit invariant says all the longer - markers were dangling from our just-taken node. Dangle them - from our *new* node. */ - for(j=length+1;j<33;j++) - if((marker[j]>>1) == entry){ - entry=marker[j]; - marker[j]=marker[j-1]<<1; - }else - break; - }else - if(sparsecount==0)count++; - } - - /* any underpopulated tree must be rejected. */ - /* Single-entry codebooks are a retconned extension to the spec. - They have a single codeword '0' of length 1 that results in an - underpopulated tree. Shield that case from the underformed tree check. */ - if(!(count==1 && marker[2]==2)){ - for(i=1;i<33;i++) - if(marker[i] & (0xffffffffUL>>(32-i))){ - _ogg_free(r); - return(NULL); - } - } - - /* bitreverse the words because our bitwise packer/unpacker is LSb - endian */ - for(i=0,count=0;i>j)&1; - } - - if(sparsecount){ - if(l[i]) - r[count++]=temp; - }else - r[count++]=temp; - } - - return(r); -} - -/* there might be a straightforward one-line way to do the below - that's portable and totally safe against roundoff, but I haven't - thought of it. Therefore, we opt on the side of caution */ -long _book_maptype1_quantvals(const static_codebook *b){ - long vals; - if(b->entries<1){ - return(0); - } - vals=floor(pow((float)b->entries,1.f/b->dim)); - - /* the above *should* be reliable, but we'll not assume that FP is - ever reliable when bitstream sync is at stake; verify via integer - means that vals really is the greatest value of dim for which - vals^b->bim <= b->entries */ - /* treat the above as an initial guess */ - if(vals<1){ - vals=1; - } - while(1){ - long acc=1; - long acc1=1; - int i; - for(i=0;idim;i++){ - if(b->entries/vals=b->dim && acc<=b->entries && acc1>b->entries){ - return(vals); - }else{ - if(idim || acc>b->entries){ - vals--; - }else{ - vals++; - } - } - } -} - -/* unpack the quantized list of values for encode/decode ***********/ -/* we need to deal with two map types: in map type 1, the values are - generated algorithmically (each column of the vector counts through - the values in the quant vector). in map type 2, all the values came - in in an explicit list. Both value lists must be unpacked */ -float *_book_unquantize(const static_codebook *b,int n,int *sparsemap){ - long j,k,count=0; - if(b->maptype==1 || b->maptype==2){ - int quantvals; - float mindel=_float32_unpack(b->q_min); - float delta=_float32_unpack(b->q_delta); - float *r=_ogg_calloc(n*b->dim,sizeof(*r)); - - /* maptype 1 and 2 both use a quantized value vector, but - different sizes */ - switch(b->maptype){ - case 1: - /* most of the time, entries%dimensions == 0, but we need to be - well defined. We define that the possible vales at each - scalar is values == entries/dim. If entries%dim != 0, we'll - have 'too few' values (values*dimentries;j++){ - if((sparsemap && b->lengthlist[j]) || !sparsemap){ - float last=0.f; - int indexdiv=1; - for(k=0;kdim;k++){ - int index= (j/indexdiv)%quantvals; - float val=b->quantlist[index]; - val=fabs(val)*delta+mindel+last; - if(b->q_sequencep)last=val; - if(sparsemap) - r[sparsemap[count]*b->dim+k]=val; - else - r[count*b->dim+k]=val; - indexdiv*=quantvals; - } - count++; - } - - } - break; - case 2: - for(j=0;jentries;j++){ - if((sparsemap && b->lengthlist[j]) || !sparsemap){ - float last=0.f; - - for(k=0;kdim;k++){ - float val=b->quantlist[j*b->dim+k]; - val=fabs(val)*delta+mindel+last; - if(b->q_sequencep)last=val; - if(sparsemap) - r[sparsemap[count]*b->dim+k]=val; - else - r[count*b->dim+k]=val; - } - count++; - } - } - break; - } - - return(r); - } - return(NULL); -} - -void vorbis_staticbook_destroy(static_codebook *b){ - if(b->allocedp){ - if(b->quantlist)_ogg_free(b->quantlist); - if(b->lengthlist)_ogg_free(b->lengthlist); - memset(b,0,sizeof(*b)); - _ogg_free(b); - } /* otherwise, it is in static memory */ -} - -void vorbis_book_clear(codebook *b){ - /* static book is not cleared; we're likely called on the lookup and - the static codebook belongs to the info struct */ - if(b->valuelist)_ogg_free(b->valuelist); - if(b->codelist)_ogg_free(b->codelist); - - if(b->dec_index)_ogg_free(b->dec_index); - if(b->dec_codelengths)_ogg_free(b->dec_codelengths); - if(b->dec_firsttable)_ogg_free(b->dec_firsttable); - - memset(b,0,sizeof(*b)); -} - -int vorbis_book_init_encode(codebook *c,const static_codebook *s){ - - memset(c,0,sizeof(*c)); - c->c=s; - c->entries=s->entries; - c->used_entries=s->entries; - c->dim=s->dim; - c->codelist=_make_words(s->lengthlist,s->entries,0); - /* c->valuelist=_book_unquantize(s,s->entries,NULL); */ - c->quantvals=_book_maptype1_quantvals(s); - c->minval=(int)rint(_float32_unpack(s->q_min)); - c->delta=(int)rint(_float32_unpack(s->q_delta)); - - return(0); -} - -static ogg_uint32_t bitreverse(ogg_uint32_t x){ - x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL); - x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL); - x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL); - x= ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL); - return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL); -} - -static int sort32a(const void *a,const void *b){ - return ( **(ogg_uint32_t **)a>**(ogg_uint32_t **)b)- - ( **(ogg_uint32_t **)a<**(ogg_uint32_t **)b); -} - -/* decode codebook arrangement is more heavily optimized than encode */ -int vorbis_book_init_decode(codebook *c,const static_codebook *s){ - int i,j,n=0,tabn; - int *sortindex; - - memset(c,0,sizeof(*c)); - - /* count actually used entries and find max length */ - for(i=0;ientries;i++) - if(s->lengthlist[i]>0) - n++; - - c->entries=s->entries; - c->used_entries=n; - c->dim=s->dim; - - if(n>0){ - /* two different remappings go on here. - - First, we collapse the likely sparse codebook down only to - actually represented values/words. This collapsing needs to be - indexed as map-valueless books are used to encode original entry - positions as integers. - - Second, we reorder all vectors, including the entry index above, - by sorted bitreversed codeword to allow treeless decode. */ - - /* perform sort */ - ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries); - ogg_uint32_t **codep=alloca(sizeof(*codep)*n); - - if(codes==NULL)goto err_out; - - for(i=0;icodelist=_ogg_malloc(n*sizeof(*c->codelist)); - /* the index is a reverse index */ - for(i=0;icodelist[sortindex[i]]=codes[i]; - _ogg_free(codes); - - c->valuelist=_book_unquantize(s,n,sortindex); - c->dec_index=_ogg_malloc(n*sizeof(*c->dec_index)); - - for(n=0,i=0;ientries;i++) - if(s->lengthlist[i]>0) - c->dec_index[sortindex[n++]]=i; - - c->dec_codelengths=_ogg_malloc(n*sizeof(*c->dec_codelengths)); - c->dec_maxlength=0; - for(n=0,i=0;ientries;i++) - if(s->lengthlist[i]>0){ - c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; - if(s->lengthlist[i]>c->dec_maxlength) - c->dec_maxlength=s->lengthlist[i]; - } - - if(n==1 && c->dec_maxlength==1){ - /* special case the 'single entry codebook' with a single bit - fastpath table (that always returns entry 0 )in order to use - unmodified decode paths. */ - c->dec_firsttablen=1; - c->dec_firsttable=_ogg_calloc(2,sizeof(*c->dec_firsttable)); - c->dec_firsttable[0]=c->dec_firsttable[1]=1; - - }else{ - c->dec_firsttablen=ov_ilog(c->used_entries)-4; /* this is magic */ - if(c->dec_firsttablen<5)c->dec_firsttablen=5; - if(c->dec_firsttablen>8)c->dec_firsttablen=8; - - tabn=1<dec_firsttablen; - c->dec_firsttable=_ogg_calloc(tabn,sizeof(*c->dec_firsttable)); - - for(i=0;idec_codelengths[i]<=c->dec_firsttablen){ - ogg_uint32_t orig=bitreverse(c->codelist[i]); - for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) - c->dec_firsttable[orig|(j<dec_codelengths[i])]=i+1; - } - } - - /* now fill in 'unused' entries in the firsttable with hi/lo search - hints for the non-direct-hits */ - { - ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen); - long lo=0,hi=0; - - for(i=0;idec_firsttablen); - if(c->dec_firsttable[bitreverse(word)]==0){ - while((lo+1)codelist[lo+1]<=word)lo++; - while( hi=(c->codelist[hi]&mask))hi++; - - /* we only actually have 15 bits per hint to play with here. - In order to overflow gracefully (nothing breaks, efficiency - just drops), encode as the difference from the extremes. */ - { - unsigned long loval=lo; - unsigned long hival=n-hi; - - if(loval>0x7fff)loval=0x7fff; - if(hival>0x7fff)hival=0x7fff; - c->dec_firsttable[bitreverse(word)]= - 0x80000000UL | (loval<<15) | hival; - } - } - } - } - } - } - - return(0); - err_out: - vorbis_book_clear(c); - return(-1); -} - -long vorbis_book_codeword(codebook *book,int entry){ - if(book->c) /* only use with encode; decode optimizations are - allowed to break this */ - return book->codelist[entry]; - return -1; -} - -long vorbis_book_codelen(codebook *book,int entry){ - if(book->c) /* only use with encode; decode optimizations are - allowed to break this */ - return book->c->lengthlist[entry]; - return -1; -} - -#ifdef _V_SELFTEST - -/* Unit tests of the dequantizer; this stuff will be OK - cross-platform, I simply want to be sure that special mapping cases - actually work properly; a bug could go unnoticed for a while */ - -#include - -/* cases: - - no mapping - full, explicit mapping - algorithmic mapping - - nonsequential - sequential -*/ - -static long full_quantlist1[]={0,1,2,3, 4,5,6,7, 8,3,6,1}; -static long partial_quantlist1[]={0,7,2}; - -/* no mapping */ -static_codebook test1={ - 4,16, - NULL, - 0, - 0,0,0,0, - NULL, - 0 -}; -static float *test1_result=NULL; - -/* linear, full mapping, nonsequential */ -static_codebook test2={ - 4,3, - NULL, - 2, - -533200896,1611661312,4,0, - full_quantlist1, - 0 -}; -static float test2_result[]={-3,-2,-1,0, 1,2,3,4, 5,0,3,-2}; - -/* linear, full mapping, sequential */ -static_codebook test3={ - 4,3, - NULL, - 2, - -533200896,1611661312,4,1, - full_quantlist1, - 0 -}; -static float test3_result[]={-3,-5,-6,-6, 1,3,6,10, 5,5,8,6}; - -/* linear, algorithmic mapping, nonsequential */ -static_codebook test4={ - 3,27, - NULL, - 1, - -533200896,1611661312,4,0, - partial_quantlist1, - 0 -}; -static float test4_result[]={-3,-3,-3, 4,-3,-3, -1,-3,-3, - -3, 4,-3, 4, 4,-3, -1, 4,-3, - -3,-1,-3, 4,-1,-3, -1,-1,-3, - -3,-3, 4, 4,-3, 4, -1,-3, 4, - -3, 4, 4, 4, 4, 4, -1, 4, 4, - -3,-1, 4, 4,-1, 4, -1,-1, 4, - -3,-3,-1, 4,-3,-1, -1,-3,-1, - -3, 4,-1, 4, 4,-1, -1, 4,-1, - -3,-1,-1, 4,-1,-1, -1,-1,-1}; - -/* linear, algorithmic mapping, sequential */ -static_codebook test5={ - 3,27, - NULL, - 1, - -533200896,1611661312,4,1, - partial_quantlist1, - 0 -}; -static float test5_result[]={-3,-6,-9, 4, 1,-2, -1,-4,-7, - -3, 1,-2, 4, 8, 5, -1, 3, 0, - -3,-4,-7, 4, 3, 0, -1,-2,-5, - -3,-6,-2, 4, 1, 5, -1,-4, 0, - -3, 1, 5, 4, 8,12, -1, 3, 7, - -3,-4, 0, 4, 3, 7, -1,-2, 2, - -3,-6,-7, 4, 1, 0, -1,-4,-5, - -3, 1, 0, 4, 8, 7, -1, 3, 2, - -3,-4,-5, 4, 3, 2, -1,-2,-3}; - -void run_test(static_codebook *b,float *comp){ - float *out=_book_unquantize(b,b->entries,NULL); - int i; - - if(comp){ - if(!out){ - fprintf(stderr,"_book_unquantize incorrectly returned NULL\n"); - exit(1); - } - - for(i=0;ientries*b->dim;i++) - if(fabs(out[i]-comp[i])>.0001){ - fprintf(stderr,"disagreement in unquantized and reference data:\n" - "position %d, %g != %g\n",i,out[i],comp[i]); - exit(1); - } - - }else{ - if(out){ - fprintf(stderr,"_book_unquantize returned a value array: \n" - " correct result should have been NULL\n"); - exit(1); - } - } - free(out); -} - -int main(){ - /* run the nine dequant tests, and compare to the hand-rolled results */ - fprintf(stderr,"Dequant test 1... "); - run_test(&test1,test1_result); - fprintf(stderr,"OK\nDequant test 2... "); - run_test(&test2,test2_result); - fprintf(stderr,"OK\nDequant test 3... "); - run_test(&test3,test3_result); - fprintf(stderr,"OK\nDequant test 4... "); - run_test(&test4,test4_result); - fprintf(stderr,"OK\nDequant test 5... "); - run_test(&test5,test5_result); - fprintf(stderr,"OK\n\n"); - - return(0); -} - -#endif diff --git a/Engine/lib/libvorbis/lib/smallft.c b/Engine/lib/libvorbis/lib/smallft.c deleted file mode 100644 index 4ffabab4b..000000000 --- a/Engine/lib/libvorbis/lib/smallft.c +++ /dev/null @@ -1,1254 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: *unnormalized* fft transform - - ********************************************************************/ - -/* FFT implementation from OggSquish, minus cosine transforms, - * minus all but radix 2/4 case. In Vorbis we only need this - * cut-down version. - * - * To do more than just power-of-two sized vectors, see the full - * version I wrote for NetLib. - * - * Note that the packing is a little strange; rather than the FFT r/i - * packing following R_0, I_n, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, - * it follows R_0, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, I_n like the - * FORTRAN version - */ - -#include -#include -#include -#include "smallft.h" -#include "os.h" -#include "misc.h" - -static void drfti1(int n, float *wa, int *ifac){ - static int ntryh[4] = { 4,2,3,5 }; - static float tpi = 6.28318530717958648f; - float arg,argh,argld,fi; - int ntry=0,i,j=-1; - int k1, l1, l2, ib; - int ld, ii, ip, is, nq, nr; - int ido, ipm, nfm1; - int nl=n; - int nf=0; - - L101: - j++; - if (j < 4) - ntry=ntryh[j]; - else - ntry+=2; - - L104: - nq=nl/ntry; - nr=nl-ntry*nq; - if (nr!=0) goto L101; - - nf++; - ifac[nf+1]=ntry; - nl=nq; - if(ntry!=2)goto L107; - if(nf==1)goto L107; - - for (i=1;i>1; - ipp2=ip; - idp2=ido; - nbd=(ido-1)>>1; - t0=l1*ido; - t10=ip*ido; - - if(ido==1)goto L119; - for(ik=0;ikl1){ - for(j=1;j>1; - ipp2=ip; - ipph=(ip+1)>>1; - if(idol1)goto L139; - - is= -ido-1; - t1=0; - for(j=1;jn==1)return; - drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); -} - -void drft_backward(drft_lookup *l,float *data){ - if (l->n==1)return; - drftb1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); -} - -void drft_init(drft_lookup *l,int n){ - l->n=n; - l->trigcache=_ogg_calloc(3*n,sizeof(*l->trigcache)); - l->splitcache=_ogg_calloc(32,sizeof(*l->splitcache)); - fdrffti(n, l->trigcache, l->splitcache); -} - -void drft_clear(drft_lookup *l){ - if(l){ - if(l->trigcache)_ogg_free(l->trigcache); - if(l->splitcache)_ogg_free(l->splitcache); - memset(l,0,sizeof(*l)); - } -} diff --git a/Engine/lib/libvorbis/lib/smallft.h b/Engine/lib/libvorbis/lib/smallft.h deleted file mode 100644 index 02fe8f9cd..000000000 --- a/Engine/lib/libvorbis/lib/smallft.h +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: fft transform - - ********************************************************************/ - -#ifndef _V_SMFT_H_ -#define _V_SMFT_H_ - -#include "vorbis/codec.h" - -typedef struct { - int n; - float *trigcache; - int *splitcache; -} drft_lookup; - -extern void drft_forward(drft_lookup *l,float *data); -extern void drft_backward(drft_lookup *l,float *data); -extern void drft_init(drft_lookup *l,int n); -extern void drft_clear(drft_lookup *l); - -#endif diff --git a/Engine/lib/libvorbis/lib/synthesis.c b/Engine/lib/libvorbis/lib/synthesis.c deleted file mode 100644 index 3e2d68127..000000000 --- a/Engine/lib/libvorbis/lib/synthesis.c +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: single-block PCM synthesis - - ********************************************************************/ - -#include -#include -#include "vorbis/codec.h" -#include "codec_internal.h" -#include "registry.h" -#include "misc.h" -#include "os.h" - -int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ - vorbis_dsp_state *vd= vb ? vb->vd : 0; - private_state *b= vd ? vd->backend_state : 0; - vorbis_info *vi= vd ? vd->vi : 0; - codec_setup_info *ci= vi ? vi->codec_setup : 0; - oggpack_buffer *opb=vb ? &vb->opb : 0; - int type,mode,i; - - if (!vd || !b || !vi || !ci || !opb) { - return OV_EBADPACKET; - } - - /* first things first. Make sure decode is ready */ - _vorbis_block_ripcord(vb); - oggpack_readinit(opb,op->packet,op->bytes); - - /* Check the packet type */ - if(oggpack_read(opb,1)!=0){ - /* Oops. This is not an audio data packet */ - return(OV_ENOTAUDIO); - } - - /* read our mode and pre/post windowsize */ - mode=oggpack_read(opb,b->modebits); - if(mode==-1){ - return(OV_EBADPACKET); - } - - vb->mode=mode; - if(!ci->mode_param[mode]){ - return(OV_EBADPACKET); - } - - vb->W=ci->mode_param[mode]->blockflag; - if(vb->W){ - - /* this doesn;t get mapped through mode selection as it's used - only for window selection */ - vb->lW=oggpack_read(opb,1); - vb->nW=oggpack_read(opb,1); - if(vb->nW==-1){ - return(OV_EBADPACKET); - } - }else{ - vb->lW=0; - vb->nW=0; - } - - /* more setup */ - vb->granulepos=op->granulepos; - vb->sequence=op->packetno; - vb->eofflag=op->e_o_s; - - /* alloc pcm passback storage */ - vb->pcmend=ci->blocksizes[vb->W]; - vb->pcm=_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); - for(i=0;ichannels;i++) - vb->pcm[i]=_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); - - /* unpack_header enforces range checking */ - type=ci->map_type[ci->mode_param[mode]->mapping]; - - return(_mapping_P[type]->inverse(vb,ci->map_param[ci->mode_param[mode]-> - mapping])); -} - -/* used to track pcm position without actually performing decode. - Useful for sequential 'fast forward' */ -int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){ - vorbis_dsp_state *vd=vb->vd; - private_state *b=vd->backend_state; - vorbis_info *vi=vd->vi; - codec_setup_info *ci=vi->codec_setup; - oggpack_buffer *opb=&vb->opb; - int mode; - - /* first things first. Make sure decode is ready */ - _vorbis_block_ripcord(vb); - oggpack_readinit(opb,op->packet,op->bytes); - - /* Check the packet type */ - if(oggpack_read(opb,1)!=0){ - /* Oops. This is not an audio data packet */ - return(OV_ENOTAUDIO); - } - - /* read our mode and pre/post windowsize */ - mode=oggpack_read(opb,b->modebits); - if(mode==-1)return(OV_EBADPACKET); - - vb->mode=mode; - if(!ci->mode_param[mode]){ - return(OV_EBADPACKET); - } - - vb->W=ci->mode_param[mode]->blockflag; - if(vb->W){ - vb->lW=oggpack_read(opb,1); - vb->nW=oggpack_read(opb,1); - if(vb->nW==-1) return(OV_EBADPACKET); - }else{ - vb->lW=0; - vb->nW=0; - } - - /* more setup */ - vb->granulepos=op->granulepos; - vb->sequence=op->packetno; - vb->eofflag=op->e_o_s; - - /* no pcm */ - vb->pcmend=0; - vb->pcm=NULL; - - return(0); -} - -long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ - codec_setup_info *ci=vi->codec_setup; - oggpack_buffer opb; - int mode; - - if(ci==NULL || ci->modes<=0){ - /* codec setup not properly intialized */ - return(OV_EFAULT); - } - - oggpack_readinit(&opb,op->packet,op->bytes); - - /* Check the packet type */ - if(oggpack_read(&opb,1)!=0){ - /* Oops. This is not an audio data packet */ - return(OV_ENOTAUDIO); - } - - /* read our mode and pre/post windowsize */ - mode=oggpack_read(&opb,ov_ilog(ci->modes-1)); - if(mode==-1 || !ci->mode_param[mode])return(OV_EBADPACKET); - return(ci->blocksizes[ci->mode_param[mode]->blockflag]); -} - -int vorbis_synthesis_halfrate(vorbis_info *vi,int flag){ - /* set / clear half-sample-rate mode */ - codec_setup_info *ci=vi->codec_setup; - - /* right now, our MDCT can't handle < 64 sample windows. */ - if(ci->blocksizes[0]<=64 && flag)return -1; - ci->halfrate_flag=(flag?1:0); - return 0; -} - -int vorbis_synthesis_halfrate_p(vorbis_info *vi){ - codec_setup_info *ci=vi->codec_setup; - return ci->halfrate_flag; -} diff --git a/Engine/lib/libvorbis/lib/tone.c b/Engine/lib/libvorbis/lib/tone.c deleted file mode 100644 index 5b8b02060..000000000 --- a/Engine/lib/libvorbis/lib/tone.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include - -void usage(){ - fprintf(stderr,"tone ,[] [,[]...]\n"); - exit(1); -} - -int main (int argc,char *argv[]){ - int i,j; - double *f; - double *amp; - - if(argc<2)usage(); - - f=alloca(sizeof(*f)*(argc-1)); - amp=alloca(sizeof(*amp)*(argc-1)); - - i=0; - while(argv[i+1]){ - char *pos=strchr(argv[i+1],','); - - f[i]=atof(argv[i+1]); - if(pos) - amp[i]=atof(pos+1)*32767.f; - else - amp[i]=32767.f; - - fprintf(stderr,"%g Hz, %g amp\n",f[i],amp[i]); - - i++; - } - - for(i=0;i<44100*10;i++){ - float val=0; - int ival; - for(j=0;j32767.f)ival=32767.f; - if(ival<-32768.f)ival=-32768.f; - - fprintf(stdout,"%c%c%c%c", - (char)(ival&0xff), - (char)((ival>>8)&0xff), - (char)(ival&0xff), - (char)((ival>>8)&0xff)); - } - return(0); -} - diff --git a/Engine/lib/libvorbis/lib/vorbisenc.c b/Engine/lib/libvorbis/lib/vorbisenc.c deleted file mode 100644 index cf3806a6e..000000000 --- a/Engine/lib/libvorbis/lib/vorbisenc.c +++ /dev/null @@ -1,1224 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: simple programmatic interface for encoder mode setup - - ********************************************************************/ - -#include -#include -#include - -#include "vorbis/codec.h" -#include "vorbis/vorbisenc.h" - -#include "codec_internal.h" - -#include "os.h" -#include "misc.h" - -/* careful with this; it's using static array sizing to make managing - all the modes a little less annoying. If we use a residue backend - with > 12 partition types, or a different division of iteration, - this needs to be updated. */ -typedef struct { - const static_codebook *books[12][4]; -} static_bookblock; - -typedef struct { - int res_type; - int limit_type; /* 0 lowpass limited, 1 point stereo limited */ - int grouping; - const vorbis_info_residue0 *res; - const static_codebook *book_aux; - const static_codebook *book_aux_managed; - const static_bookblock *books_base; - const static_bookblock *books_base_managed; -} vorbis_residue_template; - -typedef struct { - const vorbis_info_mapping0 *map; - const vorbis_residue_template *res; -} vorbis_mapping_template; - -typedef struct vp_adjblock{ - int block[P_BANDS]; -} vp_adjblock; - -typedef struct { - int data[NOISE_COMPAND_LEVELS]; -} compandblock; - -/* high level configuration information for setting things up - step-by-step with the detailed vorbis_encode_ctl interface. - There's a fair amount of redundancy such that interactive setup - does not directly deal with any vorbis_info or codec_setup_info - initialization; it's all stored (until full init) in this highlevel - setup, then flushed out to the real codec setup structs later. */ - -typedef struct { - int att[P_NOISECURVES]; - float boost; - float decay; -} att3; -typedef struct { int data[P_NOISECURVES]; } adj3; - -typedef struct { - int pre[PACKETBLOBS]; - int post[PACKETBLOBS]; - float kHz[PACKETBLOBS]; - float lowpasskHz[PACKETBLOBS]; -} adj_stereo; - -typedef struct { - int lo; - int hi; - int fixed; -} noiseguard; -typedef struct { - int data[P_NOISECURVES][17]; -} noise3; - -typedef struct { - int mappings; - const double *rate_mapping; - const double *quality_mapping; - int coupling_restriction; - long samplerate_min_restriction; - long samplerate_max_restriction; - - - const int *blocksize_short; - const int *blocksize_long; - - const att3 *psy_tone_masteratt; - const int *psy_tone_0dB; - const int *psy_tone_dBsuppress; - - const vp_adjblock *psy_tone_adj_impulse; - const vp_adjblock *psy_tone_adj_long; - const vp_adjblock *psy_tone_adj_other; - - const noiseguard *psy_noiseguards; - const noise3 *psy_noise_bias_impulse; - const noise3 *psy_noise_bias_padding; - const noise3 *psy_noise_bias_trans; - const noise3 *psy_noise_bias_long; - const int *psy_noise_dBsuppress; - - const compandblock *psy_noise_compand; - const double *psy_noise_compand_short_mapping; - const double *psy_noise_compand_long_mapping; - - const int *psy_noise_normal_start[2]; - const int *psy_noise_normal_partition[2]; - const double *psy_noise_normal_thresh; - - const int *psy_ath_float; - const int *psy_ath_abs; - - const double *psy_lowpass; - - const vorbis_info_psy_global *global_params; - const double *global_mapping; - const adj_stereo *stereo_modes; - - const static_codebook *const *const *const floor_books; - const vorbis_info_floor1 *floor_params; - const int floor_mappings; - const int **floor_mapping_list; - - const vorbis_mapping_template *maps; -} ve_setup_data_template; - -/* a few static coder conventions */ -static const vorbis_info_mode _mode_template[2]={ - {0,0,0,0}, - {1,0,0,1} -}; - -static const vorbis_info_mapping0 _map_nominal[2]={ - {1, {0,0}, {0}, {0}, 1,{0},{1}}, - {1, {0,0}, {1}, {1}, 1,{0},{1}} -}; - -#include "modes/setup_44.h" -#include "modes/setup_44u.h" -#include "modes/setup_44p51.h" -#include "modes/setup_32.h" -#include "modes/setup_8.h" -#include "modes/setup_11.h" -#include "modes/setup_16.h" -#include "modes/setup_22.h" -#include "modes/setup_X.h" - -static const ve_setup_data_template *const setup_list[]={ - &ve_setup_44_stereo, - &ve_setup_44_51, - &ve_setup_44_uncoupled, - - &ve_setup_32_stereo, - &ve_setup_32_uncoupled, - - &ve_setup_22_stereo, - &ve_setup_22_uncoupled, - &ve_setup_16_stereo, - &ve_setup_16_uncoupled, - - &ve_setup_11_stereo, - &ve_setup_11_uncoupled, - &ve_setup_8_stereo, - &ve_setup_8_uncoupled, - - &ve_setup_X_stereo, - &ve_setup_X_uncoupled, - &ve_setup_XX_stereo, - &ve_setup_XX_uncoupled, - 0 -}; - -static void vorbis_encode_floor_setup(vorbis_info *vi,int s, - const static_codebook *const *const *const books, - const vorbis_info_floor1 *in, - const int *x){ - int i,k,is=s; - vorbis_info_floor1 *f=_ogg_calloc(1,sizeof(*f)); - codec_setup_info *ci=vi->codec_setup; - - memcpy(f,in+x[is],sizeof(*f)); - - /* books */ - { - int partitions=f->partitions; - int maxclass=-1; - int maxbook=-1; - for(i=0;ipartitionclass[i]>maxclass)maxclass=f->partitionclass[i]; - for(i=0;i<=maxclass;i++){ - if(f->class_book[i]>maxbook)maxbook=f->class_book[i]; - f->class_book[i]+=ci->books; - for(k=0;k<(1<class_subs[i]);k++){ - if(f->class_subbook[i][k]>maxbook)maxbook=f->class_subbook[i][k]; - if(f->class_subbook[i][k]>=0)f->class_subbook[i][k]+=ci->books; - } - } - - for(i=0;i<=maxbook;i++) - ci->book_param[ci->books++]=(static_codebook *)books[x[is]][i]; - } - - /* for now, we're only using floor 1 */ - ci->floor_type[ci->floors]=1; - ci->floor_param[ci->floors]=f; - ci->floors++; - - return; -} - -static void vorbis_encode_global_psych_setup(vorbis_info *vi,double s, - const vorbis_info_psy_global *in, - const double *x){ - int i,is=s; - double ds=s-is; - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy_global *g=&ci->psy_g_param; - - memcpy(g,in+(int)x[is],sizeof(*g)); - - ds=x[is]*(1.-ds)+x[is+1]*ds; - is=(int)ds; - ds-=is; - if(ds==0 && is>0){ - is--; - ds=1.; - } - - /* interpolate the trigger threshholds */ - for(i=0;i<4;i++){ - g->preecho_thresh[i]=in[is].preecho_thresh[i]*(1.-ds)+in[is+1].preecho_thresh[i]*ds; - g->postecho_thresh[i]=in[is].postecho_thresh[i]*(1.-ds)+in[is+1].postecho_thresh[i]*ds; - } - g->ampmax_att_per_sec=ci->hi.amplitude_track_dBpersec; - return; -} - -static void vorbis_encode_global_stereo(vorbis_info *vi, - const highlevel_encode_setup *const hi, - const adj_stereo *p){ - float s=hi->stereo_point_setting; - int i,is=s; - double ds=s-is; - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy_global *g=&ci->psy_g_param; - - if(p){ - memcpy(g->coupling_prepointamp,p[is].pre,sizeof(*p[is].pre)*PACKETBLOBS); - memcpy(g->coupling_postpointamp,p[is].post,sizeof(*p[is].post)*PACKETBLOBS); - - if(hi->managed){ - /* interpolate the kHz threshholds */ - for(i=0;icoupling_pointlimit[0][i]=kHz*1000./vi->rate*ci->blocksizes[0]; - g->coupling_pointlimit[1][i]=kHz*1000./vi->rate*ci->blocksizes[1]; - g->coupling_pkHz[i]=kHz; - - kHz=p[is].lowpasskHz[i]*(1.-ds)+p[is+1].lowpasskHz[i]*ds; - g->sliding_lowpass[0][i]=kHz*1000./vi->rate*ci->blocksizes[0]; - g->sliding_lowpass[1][i]=kHz*1000./vi->rate*ci->blocksizes[1]; - - } - }else{ - float kHz=p[is].kHz[PACKETBLOBS/2]*(1.-ds)+p[is+1].kHz[PACKETBLOBS/2]*ds; - for(i=0;icoupling_pointlimit[0][i]=kHz*1000./vi->rate*ci->blocksizes[0]; - g->coupling_pointlimit[1][i]=kHz*1000./vi->rate*ci->blocksizes[1]; - g->coupling_pkHz[i]=kHz; - } - - kHz=p[is].lowpasskHz[PACKETBLOBS/2]*(1.-ds)+p[is+1].lowpasskHz[PACKETBLOBS/2]*ds; - for(i=0;isliding_lowpass[0][i]=kHz*1000./vi->rate*ci->blocksizes[0]; - g->sliding_lowpass[1][i]=kHz*1000./vi->rate*ci->blocksizes[1]; - } - } - }else{ - for(i=0;isliding_lowpass[0][i]=ci->blocksizes[0]; - g->sliding_lowpass[1][i]=ci->blocksizes[1]; - } - } - return; -} - -static void vorbis_encode_psyset_setup(vorbis_info *vi,double s, - const int *nn_start, - const int *nn_partition, - const double *nn_thresh, - int block){ - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy *p=ci->psy_param[block]; - highlevel_encode_setup *hi=&ci->hi; - int is=s; - - if(block>=ci->psys) - ci->psys=block+1; - if(!p){ - p=_ogg_calloc(1,sizeof(*p)); - ci->psy_param[block]=p; - } - - memcpy(p,&_psy_info_template,sizeof(*p)); - p->blockflag=block>>1; - - if(hi->noise_normalize_p){ - p->normal_p=1; - p->normal_start=nn_start[is]; - p->normal_partition=nn_partition[is]; - p->normal_thresh=nn_thresh[is]; - } - - return; -} - -static void vorbis_encode_tonemask_setup(vorbis_info *vi,double s,int block, - const att3 *att, - const int *max, - const vp_adjblock *in){ - int i,is=s; - double ds=s-is; - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy *p=ci->psy_param[block]; - - /* 0 and 2 are only used by bitmanagement, but there's no harm to always - filling the values in here */ - p->tone_masteratt[0]=att[is].att[0]*(1.-ds)+att[is+1].att[0]*ds; - p->tone_masteratt[1]=att[is].att[1]*(1.-ds)+att[is+1].att[1]*ds; - p->tone_masteratt[2]=att[is].att[2]*(1.-ds)+att[is+1].att[2]*ds; - p->tone_centerboost=att[is].boost*(1.-ds)+att[is+1].boost*ds; - p->tone_decay=att[is].decay*(1.-ds)+att[is+1].decay*ds; - - p->max_curve_dB=max[is]*(1.-ds)+max[is+1]*ds; - - for(i=0;itoneatt[i]=in[is].block[i]*(1.-ds)+in[is+1].block[i]*ds; - return; -} - - -static void vorbis_encode_compand_setup(vorbis_info *vi,double s,int block, - const compandblock *in, - const double *x){ - int i,is=s; - double ds=s-is; - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy *p=ci->psy_param[block]; - - ds=x[is]*(1.-ds)+x[is+1]*ds; - is=(int)ds; - ds-=is; - if(ds==0 && is>0){ - is--; - ds=1.; - } - - /* interpolate the compander settings */ - for(i=0;inoisecompand[i]=in[is].data[i]*(1.-ds)+in[is+1].data[i]*ds; - return; -} - -static void vorbis_encode_peak_setup(vorbis_info *vi,double s,int block, - const int *suppress){ - int is=s; - double ds=s-is; - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy *p=ci->psy_param[block]; - - p->tone_abs_limit=suppress[is]*(1.-ds)+suppress[is+1]*ds; - - return; -} - -static void vorbis_encode_noisebias_setup(vorbis_info *vi,double s,int block, - const int *suppress, - const noise3 *in, - const noiseguard *guard, - double userbias){ - int i,is=s,j; - double ds=s-is; - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy *p=ci->psy_param[block]; - - p->noisemaxsupp=suppress[is]*(1.-ds)+suppress[is+1]*ds; - p->noisewindowlomin=guard[block].lo; - p->noisewindowhimin=guard[block].hi; - p->noisewindowfixed=guard[block].fixed; - - for(j=0;jnoiseoff[j][i]=in[is].data[j][i]*(1.-ds)+in[is+1].data[j][i]*ds; - - /* impulse blocks may take a user specified bias to boost the - nominal/high noise encoding depth */ - for(j=0;jnoiseoff[j][0]+6; /* the lowest it can go */ - for(i=0;inoiseoff[j][i]+=userbias; - if(p->noiseoff[j][i]noiseoff[j][i]=min; - } - } - - return; -} - -static void vorbis_encode_ath_setup(vorbis_info *vi,int block){ - codec_setup_info *ci=vi->codec_setup; - vorbis_info_psy *p=ci->psy_param[block]; - - p->ath_adjatt=ci->hi.ath_floating_dB; - p->ath_maxatt=ci->hi.ath_absolute_dB; - return; -} - - -static int book_dup_or_new(codec_setup_info *ci,const static_codebook *book){ - int i; - for(i=0;ibooks;i++) - if(ci->book_param[i]==book)return(i); - - return(ci->books++); -} - -static void vorbis_encode_blocksize_setup(vorbis_info *vi,double s, - const int *shortb,const int *longb){ - - codec_setup_info *ci=vi->codec_setup; - int is=s; - - int blockshort=shortb[is]; - int blocklong=longb[is]; - ci->blocksizes[0]=blockshort; - ci->blocksizes[1]=blocklong; - -} - -static void vorbis_encode_residue_setup(vorbis_info *vi, - int number, int block, - const vorbis_residue_template *res){ - - codec_setup_info *ci=vi->codec_setup; - int i; - - vorbis_info_residue0 *r=ci->residue_param[number]= - _ogg_malloc(sizeof(*r)); - - memcpy(r,res->res,sizeof(*r)); - if(ci->residues<=number)ci->residues=number+1; - - r->grouping=res->grouping; - ci->residue_type[number]=res->res_type; - - /* fill in all the books */ - { - int booklist=0,k; - - if(ci->hi.managed){ - for(i=0;ipartitions;i++) - for(k=0;k<4;k++) - if(res->books_base_managed->books[i][k]) - r->secondstages[i]|=(1<groupbook=book_dup_or_new(ci,res->book_aux_managed); - ci->book_param[r->groupbook]=(static_codebook *)res->book_aux_managed; - - for(i=0;ipartitions;i++){ - for(k=0;k<4;k++){ - if(res->books_base_managed->books[i][k]){ - int bookid=book_dup_or_new(ci,res->books_base_managed->books[i][k]); - r->booklist[booklist++]=bookid; - ci->book_param[bookid]=(static_codebook *)res->books_base_managed->books[i][k]; - } - } - } - - }else{ - - for(i=0;ipartitions;i++) - for(k=0;k<4;k++) - if(res->books_base->books[i][k]) - r->secondstages[i]|=(1<groupbook=book_dup_or_new(ci,res->book_aux); - ci->book_param[r->groupbook]=(static_codebook *)res->book_aux; - - for(i=0;ipartitions;i++){ - for(k=0;k<4;k++){ - if(res->books_base->books[i][k]){ - int bookid=book_dup_or_new(ci,res->books_base->books[i][k]); - r->booklist[booklist++]=bookid; - ci->book_param[bookid]=(static_codebook *)res->books_base->books[i][k]; - } - } - } - } - } - - /* lowpass setup/pointlimit */ - { - double freq=ci->hi.lowpass_kHz*1000.; - vorbis_info_floor1 *f=ci->floor_param[block]; /* by convention */ - double nyq=vi->rate/2.; - long blocksize=ci->blocksizes[block]>>1; - - /* lowpass needs to be set in the floor and the residue. */ - if(freq>nyq)freq=nyq; - /* in the floor, the granularity can be very fine; it doesn't alter - the encoding structure, only the samples used to fit the floor - approximation */ - f->n=freq/nyq*blocksize; - - /* this res may by limited by the maximum pointlimit of the mode, - not the lowpass. the floor is always lowpass limited. */ - switch(res->limit_type){ - case 1: /* point stereo limited */ - if(ci->hi.managed) - freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS-1]*1000.; - else - freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS/2]*1000.; - if(freq>nyq)freq=nyq; - break; - case 2: /* LFE channel; lowpass at ~ 250Hz */ - freq=250; - break; - default: - /* already set */ - break; - } - - /* in the residue, we're constrained, physically, by partition - boundaries. We still lowpass 'wherever', but we have to round up - here to next boundary, or the vorbis spec will round it *down* to - previous boundary in encode/decode */ - if(ci->residue_type[number]==2){ - /* residue 2 bundles together multiple channels; used by stereo - and surround. Count the channels in use */ - /* Multiple maps/submaps can point to the same residue. In the case - of residue 2, they all better have the same number of - channels/samples. */ - int j,k,ch=0; - for(i=0;imaps&&ch==0;i++){ - vorbis_info_mapping0 *mi=(vorbis_info_mapping0 *)ci->map_param[i]; - for(j=0;jsubmaps && ch==0;j++) - if(mi->residuesubmap[j]==number) /* we found a submap referencing theis residue backend */ - for(k=0;kchannels;k++) - if(mi->chmuxlist[k]==j) /* this channel belongs to the submap */ - ch++; - } - - r->end=(int)((freq/nyq*blocksize*ch)/r->grouping+.9)* /* round up only if we're well past */ - r->grouping; - /* the blocksize and grouping may disagree at the end */ - if(r->end>blocksize*ch)r->end=blocksize*ch/r->grouping*r->grouping; - - }else{ - - r->end=(int)((freq/nyq*blocksize)/r->grouping+.9)* /* round up only if we're well past */ - r->grouping; - /* the blocksize and grouping may disagree at the end */ - if(r->end>blocksize)r->end=blocksize/r->grouping*r->grouping; - - } - - if(r->end==0)r->end=r->grouping; /* LFE channel */ - - } -} - -/* we assume two maps in this encoder */ -static void vorbis_encode_map_n_res_setup(vorbis_info *vi,double s, - const vorbis_mapping_template *maps){ - - codec_setup_info *ci=vi->codec_setup; - int i,j,is=s,modes=2; - const vorbis_info_mapping0 *map=maps[is].map; - const vorbis_info_mode *mode=_mode_template; - const vorbis_residue_template *res=maps[is].res; - - if(ci->blocksizes[0]==ci->blocksizes[1])modes=1; - - for(i=0;imap_param[i]=_ogg_calloc(1,sizeof(*map)); - ci->mode_param[i]=_ogg_calloc(1,sizeof(*mode)); - - memcpy(ci->mode_param[i],mode+i,sizeof(*_mode_template)); - if(i>=ci->modes)ci->modes=i+1; - - ci->map_type[i]=0; - memcpy(ci->map_param[i],map+i,sizeof(*map)); - if(i>=ci->maps)ci->maps=i+1; - - for(j=0;jcodec_setup; - highlevel_encode_setup *hi=&ci->hi; - ve_setup_data_template *setup=(ve_setup_data_template *)hi->setup; - int is=hi->base_setting; - double ds=hi->base_setting-is; - int ch=vi->channels; - const double *r=setup->rate_mapping; - - if(r==NULL) - return(-1); - - return((r[is]*(1.-ds)+r[is+1]*ds)*ch); -} - -static const void *get_setup_template(long ch,long srate, - double req,int q_or_bitrate, - double *base_setting){ - int i=0,j; - if(q_or_bitrate)req/=ch; - - while(setup_list[i]){ - if(setup_list[i]->coupling_restriction==-1 || - setup_list[i]->coupling_restriction==ch){ - if(srate>=setup_list[i]->samplerate_min_restriction && - srate<=setup_list[i]->samplerate_max_restriction){ - int mappings=setup_list[i]->mappings; - const double *map=(q_or_bitrate? - setup_list[i]->rate_mapping: - setup_list[i]->quality_mapping); - - /* the template matches. Does the requested quality mode - fall within this template's modes? */ - if(reqmap[setup_list[i]->mappings]){++i;continue;} - for(j=0;j=map[j] && reqcodec_setup; - ve_setup_data_template *setup=NULL; - highlevel_encode_setup *hi=&ci->hi; - - if(ci==NULL)return(OV_EINVAL); - if(vi->channels<1||vi->channels>255)return(OV_EINVAL); - if(!hi->impulse_block_p)i0=1; - - /* too low/high an ATH floater is nonsensical, but doesn't break anything */ - if(hi->ath_floating_dB>-80)hi->ath_floating_dB=-80; - if(hi->ath_floating_dB<-200)hi->ath_floating_dB=-200; - - /* again, bound this to avoid the app shooting itself int he foot - too badly */ - if(hi->amplitude_track_dBpersec>0.)hi->amplitude_track_dBpersec=0.; - if(hi->amplitude_track_dBpersec<-99999.)hi->amplitude_track_dBpersec=-99999.; - - /* get the appropriate setup template; matches the fetch in previous - stages */ - setup=(ve_setup_data_template *)hi->setup; - if(setup==NULL)return(OV_EINVAL); - - hi->set_in_stone=1; - /* choose block sizes from configured sizes as well as paying - attention to long_block_p and short_block_p. If the configured - short and long blocks are the same length, we set long_block_p - and unset short_block_p */ - vorbis_encode_blocksize_setup(vi,hi->base_setting, - setup->blocksize_short, - setup->blocksize_long); - if(ci->blocksizes[0]==ci->blocksizes[1])singleblock=1; - - /* floor setup; choose proper floor params. Allocated on the floor - stack in order; if we alloc only a single long floor, it's 0 */ - for(i=0;ifloor_mappings;i++) - vorbis_encode_floor_setup(vi,hi->base_setting, - setup->floor_books, - setup->floor_params, - setup->floor_mapping_list[i]); - - /* setup of [mostly] short block detection and stereo*/ - vorbis_encode_global_psych_setup(vi,hi->trigger_setting, - setup->global_params, - setup->global_mapping); - vorbis_encode_global_stereo(vi,hi,setup->stereo_modes); - - /* basic psych setup and noise normalization */ - vorbis_encode_psyset_setup(vi,hi->base_setting, - setup->psy_noise_normal_start[0], - setup->psy_noise_normal_partition[0], - setup->psy_noise_normal_thresh, - 0); - vorbis_encode_psyset_setup(vi,hi->base_setting, - setup->psy_noise_normal_start[0], - setup->psy_noise_normal_partition[0], - setup->psy_noise_normal_thresh, - 1); - if(!singleblock){ - vorbis_encode_psyset_setup(vi,hi->base_setting, - setup->psy_noise_normal_start[1], - setup->psy_noise_normal_partition[1], - setup->psy_noise_normal_thresh, - 2); - vorbis_encode_psyset_setup(vi,hi->base_setting, - setup->psy_noise_normal_start[1], - setup->psy_noise_normal_partition[1], - setup->psy_noise_normal_thresh, - 3); - } - - /* tone masking setup */ - vorbis_encode_tonemask_setup(vi,hi->block[i0].tone_mask_setting,0, - setup->psy_tone_masteratt, - setup->psy_tone_0dB, - setup->psy_tone_adj_impulse); - vorbis_encode_tonemask_setup(vi,hi->block[1].tone_mask_setting,1, - setup->psy_tone_masteratt, - setup->psy_tone_0dB, - setup->psy_tone_adj_other); - if(!singleblock){ - vorbis_encode_tonemask_setup(vi,hi->block[2].tone_mask_setting,2, - setup->psy_tone_masteratt, - setup->psy_tone_0dB, - setup->psy_tone_adj_other); - vorbis_encode_tonemask_setup(vi,hi->block[3].tone_mask_setting,3, - setup->psy_tone_masteratt, - setup->psy_tone_0dB, - setup->psy_tone_adj_long); - } - - /* noise companding setup */ - vorbis_encode_compand_setup(vi,hi->block[i0].noise_compand_setting,0, - setup->psy_noise_compand, - setup->psy_noise_compand_short_mapping); - vorbis_encode_compand_setup(vi,hi->block[1].noise_compand_setting,1, - setup->psy_noise_compand, - setup->psy_noise_compand_short_mapping); - if(!singleblock){ - vorbis_encode_compand_setup(vi,hi->block[2].noise_compand_setting,2, - setup->psy_noise_compand, - setup->psy_noise_compand_long_mapping); - vorbis_encode_compand_setup(vi,hi->block[3].noise_compand_setting,3, - setup->psy_noise_compand, - setup->psy_noise_compand_long_mapping); - } - - /* peak guarding setup */ - vorbis_encode_peak_setup(vi,hi->block[i0].tone_peaklimit_setting,0, - setup->psy_tone_dBsuppress); - vorbis_encode_peak_setup(vi,hi->block[1].tone_peaklimit_setting,1, - setup->psy_tone_dBsuppress); - if(!singleblock){ - vorbis_encode_peak_setup(vi,hi->block[2].tone_peaklimit_setting,2, - setup->psy_tone_dBsuppress); - vorbis_encode_peak_setup(vi,hi->block[3].tone_peaklimit_setting,3, - setup->psy_tone_dBsuppress); - } - - /* noise bias setup */ - vorbis_encode_noisebias_setup(vi,hi->block[i0].noise_bias_setting,0, - setup->psy_noise_dBsuppress, - setup->psy_noise_bias_impulse, - setup->psy_noiseguards, - (i0==0?hi->impulse_noisetune:0.)); - vorbis_encode_noisebias_setup(vi,hi->block[1].noise_bias_setting,1, - setup->psy_noise_dBsuppress, - setup->psy_noise_bias_padding, - setup->psy_noiseguards,0.); - if(!singleblock){ - vorbis_encode_noisebias_setup(vi,hi->block[2].noise_bias_setting,2, - setup->psy_noise_dBsuppress, - setup->psy_noise_bias_trans, - setup->psy_noiseguards,0.); - vorbis_encode_noisebias_setup(vi,hi->block[3].noise_bias_setting,3, - setup->psy_noise_dBsuppress, - setup->psy_noise_bias_long, - setup->psy_noiseguards,0.); - } - - vorbis_encode_ath_setup(vi,0); - vorbis_encode_ath_setup(vi,1); - if(!singleblock){ - vorbis_encode_ath_setup(vi,2); - vorbis_encode_ath_setup(vi,3); - } - - vorbis_encode_map_n_res_setup(vi,hi->base_setting,setup->maps); - - /* set bitrate readonlies and management */ - if(hi->bitrate_av>0) - vi->bitrate_nominal=hi->bitrate_av; - else{ - vi->bitrate_nominal=setting_to_approx_bitrate(vi); - } - - vi->bitrate_lower=hi->bitrate_min; - vi->bitrate_upper=hi->bitrate_max; - if(hi->bitrate_av) - vi->bitrate_window=(double)hi->bitrate_reservoir/hi->bitrate_av; - else - vi->bitrate_window=0.; - - if(hi->managed){ - ci->bi.avg_rate=hi->bitrate_av; - ci->bi.min_rate=hi->bitrate_min; - ci->bi.max_rate=hi->bitrate_max; - - ci->bi.reservoir_bits=hi->bitrate_reservoir; - ci->bi.reservoir_bias= - hi->bitrate_reservoir_bias; - - ci->bi.slew_damp=hi->bitrate_av_damp; - - } - - return(0); - -} - -static void vorbis_encode_setup_setting(vorbis_info *vi, - long channels, - long rate){ - int i,is; - codec_setup_info *ci=vi->codec_setup; - highlevel_encode_setup *hi=&ci->hi; - const ve_setup_data_template *setup=hi->setup; - double ds; - - vi->version=0; - vi->channels=channels; - vi->rate=rate; - - hi->impulse_block_p=1; - hi->noise_normalize_p=1; - - is=hi->base_setting; - ds=hi->base_setting-is; - - hi->stereo_point_setting=hi->base_setting; - - if(!hi->lowpass_altered) - hi->lowpass_kHz= - setup->psy_lowpass[is]*(1.-ds)+setup->psy_lowpass[is+1]*ds; - - hi->ath_floating_dB=setup->psy_ath_float[is]*(1.-ds)+ - setup->psy_ath_float[is+1]*ds; - hi->ath_absolute_dB=setup->psy_ath_abs[is]*(1.-ds)+ - setup->psy_ath_abs[is+1]*ds; - - hi->amplitude_track_dBpersec=-6.; - hi->trigger_setting=hi->base_setting; - - for(i=0;i<4;i++){ - hi->block[i].tone_mask_setting=hi->base_setting; - hi->block[i].tone_peaklimit_setting=hi->base_setting; - hi->block[i].noise_bias_setting=hi->base_setting; - hi->block[i].noise_compand_setting=hi->base_setting; - } -} - -int vorbis_encode_setup_vbr(vorbis_info *vi, - long channels, - long rate, - float quality){ - codec_setup_info *ci; - highlevel_encode_setup *hi; - if(rate<=0) return OV_EINVAL; - - ci=vi->codec_setup; - hi=&ci->hi; - - quality+=.0000001; - if(quality>=1.)quality=.9999; - - hi->req=quality; - hi->setup=get_setup_template(channels,rate,quality,0,&hi->base_setting); - if(!hi->setup)return OV_EIMPL; - - vorbis_encode_setup_setting(vi,channels,rate); - hi->managed=0; - hi->coupling_p=1; - - return 0; -} - -int vorbis_encode_init_vbr(vorbis_info *vi, - long channels, - long rate, - - float base_quality /* 0. to 1. */ - ){ - int ret=0; - - ret=vorbis_encode_setup_vbr(vi,channels,rate,base_quality); - - if(ret){ - vorbis_info_clear(vi); - return ret; - } - ret=vorbis_encode_setup_init(vi); - if(ret) - vorbis_info_clear(vi); - return(ret); -} - -int vorbis_encode_setup_managed(vorbis_info *vi, - long channels, - long rate, - - long max_bitrate, - long nominal_bitrate, - long min_bitrate){ - - codec_setup_info *ci; - highlevel_encode_setup *hi; - double tnominal; - if(rate<=0) return OV_EINVAL; - - ci=vi->codec_setup; - hi=&ci->hi; - tnominal=nominal_bitrate; - - if(nominal_bitrate<=0.){ - if(max_bitrate>0.){ - if(min_bitrate>0.) - nominal_bitrate=(max_bitrate+min_bitrate)*.5; - else - nominal_bitrate=max_bitrate*.875; - }else{ - if(min_bitrate>0.){ - nominal_bitrate=min_bitrate; - }else{ - return(OV_EINVAL); - } - } - } - - hi->req=nominal_bitrate; - hi->setup=get_setup_template(channels,rate,nominal_bitrate,1,&hi->base_setting); - if(!hi->setup)return OV_EIMPL; - - vorbis_encode_setup_setting(vi,channels,rate); - - /* initialize management with sane defaults */ - hi->coupling_p=1; - hi->managed=1; - hi->bitrate_min=min_bitrate; - hi->bitrate_max=max_bitrate; - hi->bitrate_av=tnominal; - hi->bitrate_av_damp=1.5f; /* full range in no less than 1.5 second */ - hi->bitrate_reservoir=nominal_bitrate*2; - hi->bitrate_reservoir_bias=.1; /* bias toward hoarding bits */ - - return(0); - -} - -int vorbis_encode_init(vorbis_info *vi, - long channels, - long rate, - - long max_bitrate, - long nominal_bitrate, - long min_bitrate){ - - int ret=vorbis_encode_setup_managed(vi,channels,rate, - max_bitrate, - nominal_bitrate, - min_bitrate); - if(ret){ - vorbis_info_clear(vi); - return(ret); - } - - ret=vorbis_encode_setup_init(vi); - if(ret) - vorbis_info_clear(vi); - return(ret); -} - -int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg){ - if(vi){ - codec_setup_info *ci=vi->codec_setup; - highlevel_encode_setup *hi=&ci->hi; - int setp=(number&0xf); /* a read request has a low nibble of 0 */ - - if(setp && hi->set_in_stone)return(OV_EINVAL); - - switch(number){ - - /* now deprecated *****************/ - case OV_ECTL_RATEMANAGE_GET: - { - - struct ovectl_ratemanage_arg *ai= - (struct ovectl_ratemanage_arg *)arg; - - ai->management_active=hi->managed; - ai->bitrate_hard_window=ai->bitrate_av_window= - (double)hi->bitrate_reservoir/vi->rate; - ai->bitrate_av_window_center=1.; - ai->bitrate_hard_min=hi->bitrate_min; - ai->bitrate_hard_max=hi->bitrate_max; - ai->bitrate_av_lo=hi->bitrate_av; - ai->bitrate_av_hi=hi->bitrate_av; - - } - return(0); - - /* now deprecated *****************/ - case OV_ECTL_RATEMANAGE_SET: - { - struct ovectl_ratemanage_arg *ai= - (struct ovectl_ratemanage_arg *)arg; - if(ai==NULL){ - hi->managed=0; - }else{ - hi->managed=ai->management_active; - vorbis_encode_ctl(vi,OV_ECTL_RATEMANAGE_AVG,arg); - vorbis_encode_ctl(vi,OV_ECTL_RATEMANAGE_HARD,arg); - } - } - return 0; - - /* now deprecated *****************/ - case OV_ECTL_RATEMANAGE_AVG: - { - struct ovectl_ratemanage_arg *ai= - (struct ovectl_ratemanage_arg *)arg; - if(ai==NULL){ - hi->bitrate_av=0; - }else{ - hi->bitrate_av=(ai->bitrate_av_lo+ai->bitrate_av_hi)*.5; - } - } - return(0); - /* now deprecated *****************/ - case OV_ECTL_RATEMANAGE_HARD: - { - struct ovectl_ratemanage_arg *ai= - (struct ovectl_ratemanage_arg *)arg; - if(ai==NULL){ - hi->bitrate_min=0; - hi->bitrate_max=0; - }else{ - hi->bitrate_min=ai->bitrate_hard_min; - hi->bitrate_max=ai->bitrate_hard_max; - hi->bitrate_reservoir=ai->bitrate_hard_window* - (hi->bitrate_max+hi->bitrate_min)*.5; - } - if(hi->bitrate_reservoir<128.) - hi->bitrate_reservoir=128.; - } - return(0); - - /* replacement ratemanage interface */ - case OV_ECTL_RATEMANAGE2_GET: - { - struct ovectl_ratemanage2_arg *ai= - (struct ovectl_ratemanage2_arg *)arg; - if(ai==NULL)return OV_EINVAL; - - ai->management_active=hi->managed; - ai->bitrate_limit_min_kbps=hi->bitrate_min/1000; - ai->bitrate_limit_max_kbps=hi->bitrate_max/1000; - ai->bitrate_average_kbps=hi->bitrate_av/1000; - ai->bitrate_average_damping=hi->bitrate_av_damp; - ai->bitrate_limit_reservoir_bits=hi->bitrate_reservoir; - ai->bitrate_limit_reservoir_bias=hi->bitrate_reservoir_bias; - } - return (0); - case OV_ECTL_RATEMANAGE2_SET: - { - struct ovectl_ratemanage2_arg *ai= - (struct ovectl_ratemanage2_arg *)arg; - if(ai==NULL){ - hi->managed=0; - }else{ - /* sanity check; only catch invariant violations */ - if(ai->bitrate_limit_min_kbps>0 && - ai->bitrate_average_kbps>0 && - ai->bitrate_limit_min_kbps>ai->bitrate_average_kbps) - return OV_EINVAL; - - if(ai->bitrate_limit_max_kbps>0 && - ai->bitrate_average_kbps>0 && - ai->bitrate_limit_max_kbpsbitrate_average_kbps) - return OV_EINVAL; - - if(ai->bitrate_limit_min_kbps>0 && - ai->bitrate_limit_max_kbps>0 && - ai->bitrate_limit_min_kbps>ai->bitrate_limit_max_kbps) - return OV_EINVAL; - - if(ai->bitrate_average_damping <= 0.) - return OV_EINVAL; - - if(ai->bitrate_limit_reservoir_bits < 0) - return OV_EINVAL; - - if(ai->bitrate_limit_reservoir_bias < 0.) - return OV_EINVAL; - - if(ai->bitrate_limit_reservoir_bias > 1.) - return OV_EINVAL; - - hi->managed=ai->management_active; - hi->bitrate_min=ai->bitrate_limit_min_kbps * 1000; - hi->bitrate_max=ai->bitrate_limit_max_kbps * 1000; - hi->bitrate_av=ai->bitrate_average_kbps * 1000; - hi->bitrate_av_damp=ai->bitrate_average_damping; - hi->bitrate_reservoir=ai->bitrate_limit_reservoir_bits; - hi->bitrate_reservoir_bias=ai->bitrate_limit_reservoir_bias; - } - } - return 0; - - case OV_ECTL_LOWPASS_GET: - { - double *farg=(double *)arg; - *farg=hi->lowpass_kHz; - } - return(0); - case OV_ECTL_LOWPASS_SET: - { - double *farg=(double *)arg; - hi->lowpass_kHz=*farg; - - if(hi->lowpass_kHz<2.)hi->lowpass_kHz=2.; - if(hi->lowpass_kHz>99.)hi->lowpass_kHz=99.; - hi->lowpass_altered=1; - } - return(0); - case OV_ECTL_IBLOCK_GET: - { - double *farg=(double *)arg; - *farg=hi->impulse_noisetune; - } - return(0); - case OV_ECTL_IBLOCK_SET: - { - double *farg=(double *)arg; - hi->impulse_noisetune=*farg; - - if(hi->impulse_noisetune>0.)hi->impulse_noisetune=0.; - if(hi->impulse_noisetune<-15.)hi->impulse_noisetune=-15.; - } - return(0); - case OV_ECTL_COUPLING_GET: - { - int *iarg=(int *)arg; - *iarg=hi->coupling_p; - } - return(0); - case OV_ECTL_COUPLING_SET: - { - const void *new_template; - double new_base=0.; - int *iarg=(int *)arg; - hi->coupling_p=((*iarg)!=0); - - /* Fetching a new template can alter the base_setting, which - many other parameters are based on. Right now, the only - parameter drawn from the base_setting that can be altered - by an encctl is the lowpass, so that is explictly flagged - to not be overwritten when we fetch a new template and - recompute the dependant settings */ - new_template = get_setup_template(hi->coupling_p?vi->channels:-1, - vi->rate, - hi->req, - hi->managed, - &new_base); - if(!new_template)return OV_EIMPL; - hi->setup=new_template; - hi->base_setting=new_base; - vorbis_encode_setup_setting(vi,vi->channels,vi->rate); - } - return(0); - } - return(OV_EIMPL); - } - return(OV_EINVAL); -} diff --git a/Engine/lib/libvorbis/lib/vorbisfile.c b/Engine/lib/libvorbis/lib/vorbisfile.c deleted file mode 100644 index 9219c2f2d..000000000 --- a/Engine/lib/libvorbis/lib/vorbisfile.c +++ /dev/null @@ -1,2427 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: stdio-based convenience library for opening/seeking/decoding - - ********************************************************************/ - -#include -#include -#include -#include -#include - -#include "vorbis/codec.h" - -/* we don't need or want the static callback symbols here */ -#define OV_EXCLUDE_STATIC_CALLBACKS -#include "vorbis/vorbisfile.h" - -#include "os.h" -#include "misc.h" - -/* A 'chained bitstream' is a Vorbis bitstream that contains more than - one logical bitstream arranged end to end (the only form of Ogg - multiplexing allowed in a Vorbis bitstream; grouping [parallel - multiplexing] is not allowed in Vorbis) */ - -/* A Vorbis file can be played beginning to end (streamed) without - worrying ahead of time about chaining (see decoder_example.c). If - we have the whole file, however, and want random access - (seeking/scrubbing) or desire to know the total length/time of a - file, we need to account for the possibility of chaining. */ - -/* We can handle things a number of ways; we can determine the entire - bitstream structure right off the bat, or find pieces on demand. - This example determines and caches structure for the entire - bitstream, but builds a virtual decoder on the fly when moving - between links in the chain. */ - -/* There are also different ways to implement seeking. Enough - information exists in an Ogg bitstream to seek to - sample-granularity positions in the output. Or, one can seek by - picking some portion of the stream roughly in the desired area if - we only want coarse navigation through the stream. */ - -/************************************************************************* - * Many, many internal helpers. The intention is not to be confusing; - * rampant duplication and monolithic function implementation would be - * harder to understand anyway. The high level functions are last. Begin - * grokking near the end of the file */ - -/* read a little more data from the file/pipe into the ogg_sync framer -*/ -#define CHUNKSIZE 65536 /* greater-than-page-size granularity seeking */ -#define READSIZE 2048 /* a smaller read size is needed for low-rate streaming. */ - -static long _get_data(OggVorbis_File *vf){ - errno=0; - if(!(vf->callbacks.read_func))return(-1); - if(vf->datasource){ - char *buffer=ogg_sync_buffer(&vf->oy,READSIZE); - long bytes=(vf->callbacks.read_func)(buffer,1,READSIZE,vf->datasource); - if(bytes>0)ogg_sync_wrote(&vf->oy,bytes); - if(bytes==0 && errno)return(-1); - return(bytes); - }else - return(0); -} - -/* save a tiny smidge of verbosity to make the code more readable */ -static int _seek_helper(OggVorbis_File *vf,ogg_int64_t offset){ - if(vf->datasource){ - /* only seek if the file position isn't already there */ - if(vf->offset != offset){ - if(!(vf->callbacks.seek_func)|| - (vf->callbacks.seek_func)(vf->datasource, offset, SEEK_SET) == -1) - return OV_EREAD; - vf->offset=offset; - ogg_sync_reset(&vf->oy); - } - }else{ - /* shouldn't happen unless someone writes a broken callback */ - return OV_EFAULT; - } - return 0; -} - -/* The read/seek functions track absolute position within the stream */ - -/* from the head of the stream, get the next page. boundary specifies - if the function is allowed to fetch more data from the stream (and - how much) or only use internally buffered data. - - boundary: -1) unbounded search - 0) read no additional data; use cached only - n) search for a new page beginning for n bytes - - return: <0) did not find a page (OV_FALSE, OV_EOF, OV_EREAD) - n) found a page at absolute offset n */ - -static ogg_int64_t _get_next_page(OggVorbis_File *vf,ogg_page *og, - ogg_int64_t boundary){ - if(boundary>0)boundary+=vf->offset; - while(1){ - long more; - - if(boundary>0 && vf->offset>=boundary)return(OV_FALSE); - more=ogg_sync_pageseek(&vf->oy,og); - - if(more<0){ - /* skipped n bytes */ - vf->offset-=more; - }else{ - if(more==0){ - /* send more paramedics */ - if(!boundary)return(OV_FALSE); - { - long ret=_get_data(vf); - if(ret==0)return(OV_EOF); - if(ret<0)return(OV_EREAD); - } - }else{ - /* got a page. Return the offset at the page beginning, - advance the internal offset past the page end */ - ogg_int64_t ret=vf->offset; - vf->offset+=more; - return(ret); - - } - } - } -} - -/* find the latest page beginning before the passed in position. Much - dirtier than the above as Ogg doesn't have any backward search - linkage. no 'readp' as it will certainly have to read. */ -/* returns offset or OV_EREAD, OV_FAULT */ -static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_int64_t begin,ogg_page *og){ - ogg_int64_t end = begin; - ogg_int64_t ret; - ogg_int64_t offset=-1; - - while(offset==-1){ - begin-=CHUNKSIZE; - if(begin<0) - begin=0; - - ret=_seek_helper(vf,begin); - if(ret)return(ret); - - while(vf->offsetoffset); - if(ret==OV_EREAD)return(OV_EREAD); - if(ret<0){ - break; - }else{ - offset=ret; - } - } - } - - /* In a fully compliant, non-multiplexed stream, we'll still be - holding the last page. In multiplexed (or noncompliant streams), - we will probably have to re-read the last page we saw */ - if(og->header_len==0){ - ret=_seek_helper(vf,offset); - if(ret)return(ret); - - ret=_get_next_page(vf,og,CHUNKSIZE); - if(ret<0) - /* this shouldn't be possible */ - return(OV_EFAULT); - } - - return(offset); -} - -static void _add_serialno(ogg_page *og,long **serialno_list, int *n){ - long s = ogg_page_serialno(og); - (*n)++; - - if(*serialno_list){ - *serialno_list = _ogg_realloc(*serialno_list, sizeof(**serialno_list)*(*n)); - }else{ - *serialno_list = _ogg_malloc(sizeof(**serialno_list)); - } - - (*serialno_list)[(*n)-1] = s; -} - -/* returns nonzero if found */ -static int _lookup_serialno(long s, long *serialno_list, int n){ - if(serialno_list){ - while(n--){ - if(*serialno_list == s) return 1; - serialno_list++; - } - } - return 0; -} - -static int _lookup_page_serialno(ogg_page *og, long *serialno_list, int n){ - long s = ogg_page_serialno(og); - return _lookup_serialno(s,serialno_list,n); -} - -/* performs the same search as _get_prev_page, but prefers pages of - the specified serial number. If a page of the specified serialno is - spotted during the seek-back-and-read-forward, it will return the - info of last page of the matching serial number instead of the very - last page. If no page of the specified serialno is seen, it will - return the info of last page and alter *serialno. */ -static ogg_int64_t _get_prev_page_serial(OggVorbis_File *vf, ogg_int64_t begin, - long *serial_list, int serial_n, - int *serialno, ogg_int64_t *granpos){ - ogg_page og; - ogg_int64_t end=begin; - ogg_int64_t ret; - - ogg_int64_t prefoffset=-1; - ogg_int64_t offset=-1; - ogg_int64_t ret_serialno=-1; - ogg_int64_t ret_gran=-1; - - while(offset==-1){ - begin-=CHUNKSIZE; - if(begin<0) - begin=0; - - ret=_seek_helper(vf,begin); - if(ret)return(ret); - - while(vf->offsetoffset); - if(ret==OV_EREAD)return(OV_EREAD); - if(ret<0){ - break; - }else{ - ret_serialno=ogg_page_serialno(&og); - ret_gran=ogg_page_granulepos(&og); - offset=ret; - - if(ret_serialno == *serialno){ - prefoffset=ret; - *granpos=ret_gran; - } - - if(!_lookup_serialno(ret_serialno,serial_list,serial_n)){ - /* we fell off the end of the link, which means we seeked - back too far and shouldn't have been looking in that link - to begin with. If we found the preferred serial number, - forget that we saw it. */ - prefoffset=-1; - } - } - } - /*We started from the beginning of the stream and found nothing. - This should be impossible unless the contents of the stream changed out - from under us after we read from it.*/ - if(!begin&&vf->offset<0)return OV_EBADLINK; - } - - /* we're not interested in the page... just the serialno and granpos. */ - if(prefoffset>=0)return(prefoffset); - - *serialno = ret_serialno; - *granpos = ret_gran; - return(offset); - -} - -/* uses the local ogg_stream storage in vf; this is important for - non-streaming input sources */ -static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi,vorbis_comment *vc, - long **serialno_list, int *serialno_n, - ogg_page *og_ptr){ - ogg_page og; - ogg_packet op; - int i,ret; - int allbos=0; - - if(!og_ptr){ - ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE); - if(llret==OV_EREAD)return(OV_EREAD); - if(llret<0)return(OV_ENOTVORBIS); - og_ptr=&og; - } - - vorbis_info_init(vi); - vorbis_comment_init(vc); - vf->ready_state=OPENED; - - /* extract the serialnos of all BOS pages + the first set of vorbis - headers we see in the link */ - - while(ogg_page_bos(og_ptr)){ - if(serialno_list){ - if(_lookup_page_serialno(og_ptr,*serialno_list,*serialno_n)){ - /* a dupe serialnumber in an initial header packet set == invalid stream */ - if(*serialno_list)_ogg_free(*serialno_list); - *serialno_list=0; - *serialno_n=0; - ret=OV_EBADHEADER; - goto bail_header; - } - - _add_serialno(og_ptr,serialno_list,serialno_n); - } - - if(vf->ready_stateos,ogg_page_serialno(og_ptr)); - ogg_stream_pagein(&vf->os,og_ptr); - - if(ogg_stream_packetout(&vf->os,&op) > 0 && - vorbis_synthesis_idheader(&op)){ - /* vorbis header; continue setup */ - vf->ready_state=STREAMSET; - if((ret=vorbis_synthesis_headerin(vi,vc,&op))){ - ret=OV_EBADHEADER; - goto bail_header; - } - } - } - - /* get next page */ - { - ogg_int64_t llret=_get_next_page(vf,og_ptr,CHUNKSIZE); - if(llret==OV_EREAD){ - ret=OV_EREAD; - goto bail_header; - } - if(llret<0){ - ret=OV_ENOTVORBIS; - goto bail_header; - } - - /* if this page also belongs to our vorbis stream, submit it and break */ - if(vf->ready_state==STREAMSET && - vf->os.serialno == ogg_page_serialno(og_ptr)){ - ogg_stream_pagein(&vf->os,og_ptr); - break; - } - } - } - - if(vf->ready_state!=STREAMSET){ - ret = OV_ENOTVORBIS; - goto bail_header; - } - - while(1){ - - i=0; - while(i<2){ /* get a page loop */ - - while(i<2){ /* get a packet loop */ - - int result=ogg_stream_packetout(&vf->os,&op); - if(result==0)break; - if(result==-1){ - ret=OV_EBADHEADER; - goto bail_header; - } - - if((ret=vorbis_synthesis_headerin(vi,vc,&op))) - goto bail_header; - - i++; - } - - while(i<2){ - if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){ - ret=OV_EBADHEADER; - goto bail_header; - } - - /* if this page belongs to the correct stream, go parse it */ - if(vf->os.serialno == ogg_page_serialno(og_ptr)){ - ogg_stream_pagein(&vf->os,og_ptr); - break; - } - - /* if we never see the final vorbis headers before the link - ends, abort */ - if(ogg_page_bos(og_ptr)){ - if(allbos){ - ret = OV_EBADHEADER; - goto bail_header; - }else - allbos=1; - } - - /* otherwise, keep looking */ - } - } - - return 0; - } - - bail_header: - vorbis_info_clear(vi); - vorbis_comment_clear(vc); - vf->ready_state=OPENED; - - return ret; -} - -/* Starting from current cursor position, get initial PCM offset of - next page. Consumes the page in the process without decoding - audio, however this is only called during stream parsing upon - seekable open. */ -static ogg_int64_t _initial_pcmoffset(OggVorbis_File *vf, vorbis_info *vi){ - ogg_page og; - ogg_int64_t accumulated=0; - long lastblock=-1; - int result; - int serialno = vf->os.serialno; - - while(1){ - ogg_packet op; - if(_get_next_page(vf,&og,-1)<0) - break; /* should not be possible unless the file is truncated/mangled */ - - if(ogg_page_bos(&og)) break; - if(ogg_page_serialno(&og)!=serialno) continue; - - /* count blocksizes of all frames in the page */ - ogg_stream_pagein(&vf->os,&og); - while((result=ogg_stream_packetout(&vf->os,&op))){ - if(result>0){ /* ignore holes */ - long thisblock=vorbis_packet_blocksize(vi,&op); - if(thisblock>=0){ - if(lastblock!=-1) - accumulated+=(lastblock+thisblock)>>2; - lastblock=thisblock; - } - } - } - - if(ogg_page_granulepos(&og)!=-1){ - /* pcm offset of last packet on the first audio page */ - accumulated= ogg_page_granulepos(&og)-accumulated; - break; - } - } - - /* less than zero? Either a corrupt file or a stream with samples - trimmed off the beginning, a normal occurrence; in both cases set - the offset to zero */ - if(accumulated<0)accumulated=0; - - return accumulated; -} - -/* finds each bitstream link one at a time using a bisection search - (has to begin by knowing the offset of the lb's initial page). - Recurses for each link so it can alloc the link storage after - finding them all, then unroll and fill the cache at the same time */ -static int _bisect_forward_serialno(OggVorbis_File *vf, - ogg_int64_t begin, - ogg_int64_t searched, - ogg_int64_t end, - ogg_int64_t endgran, - int endserial, - long *currentno_list, - int currentnos, - long m){ - ogg_int64_t pcmoffset; - ogg_int64_t dataoffset=searched; - ogg_int64_t endsearched=end; - ogg_int64_t next=end; - ogg_int64_t searchgran=-1; - ogg_page og; - ogg_int64_t ret,last; - int serialno = vf->os.serialno; - - /* invariants: - we have the headers and serialnos for the link beginning at 'begin' - we have the offset and granpos of the last page in the file (potentially - not a page we care about) - */ - - /* Is the last page in our list of current serialnumbers? */ - if(_lookup_serialno(endserial,currentno_list,currentnos)){ - - /* last page is in the starting serialno list, so we've bisected - down to (or just started with) a single link. Now we need to - find the last vorbis page belonging to the first vorbis stream - for this link. */ - searched = end; - while(endserial != serialno){ - endserial = serialno; - searched=_get_prev_page_serial(vf,searched,currentno_list,currentnos,&endserial,&endgran); - } - - vf->links=m+1; - if(vf->offsets)_ogg_free(vf->offsets); - if(vf->serialnos)_ogg_free(vf->serialnos); - if(vf->dataoffsets)_ogg_free(vf->dataoffsets); - - vf->offsets=_ogg_malloc((vf->links+1)*sizeof(*vf->offsets)); - vf->vi=_ogg_realloc(vf->vi,vf->links*sizeof(*vf->vi)); - vf->vc=_ogg_realloc(vf->vc,vf->links*sizeof(*vf->vc)); - vf->serialnos=_ogg_malloc(vf->links*sizeof(*vf->serialnos)); - vf->dataoffsets=_ogg_malloc(vf->links*sizeof(*vf->dataoffsets)); - vf->pcmlengths=_ogg_malloc(vf->links*2*sizeof(*vf->pcmlengths)); - - vf->offsets[m+1]=end; - vf->offsets[m]=begin; - vf->pcmlengths[m*2+1]=(endgran<0?0:endgran); - - }else{ - - /* last page is not in the starting stream's serial number list, - so we have multiple links. Find where the stream that begins - our bisection ends. */ - - long *next_serialno_list=NULL; - int next_serialnos=0; - vorbis_info vi; - vorbis_comment vc; - int testserial = serialno+1; - - /* the below guards against garbage seperating the last and - first pages of two links. */ - while(searched=0)next=last; - }else{ - searched=vf->offset; - } - } - - /* Bisection point found */ - /* for the time being, fetch end PCM offset the simple way */ - searched = next; - while(testserial != serialno){ - testserial = serialno; - searched = _get_prev_page_serial(vf,searched,currentno_list,currentnos,&testserial,&searchgran); - } - - ret=_seek_helper(vf,next); - if(ret)return(ret); - - ret=_fetch_headers(vf,&vi,&vc,&next_serialno_list,&next_serialnos,NULL); - if(ret)return(ret); - serialno = vf->os.serialno; - dataoffset = vf->offset; - - /* this will consume a page, however the next bisection always - starts with a raw seek */ - pcmoffset = _initial_pcmoffset(vf,&vi); - - ret=_bisect_forward_serialno(vf,next,vf->offset,end,endgran,endserial, - next_serialno_list,next_serialnos,m+1); - if(ret)return(ret); - - if(next_serialno_list)_ogg_free(next_serialno_list); - - vf->offsets[m+1]=next; - vf->serialnos[m+1]=serialno; - vf->dataoffsets[m+1]=dataoffset; - - vf->vi[m+1]=vi; - vf->vc[m+1]=vc; - - vf->pcmlengths[m*2+1]=searchgran; - vf->pcmlengths[m*2+2]=pcmoffset; - vf->pcmlengths[m*2+3]-=pcmoffset; - if(vf->pcmlengths[m*2+3]<0)vf->pcmlengths[m*2+3]=0; - } - return(0); -} - -static int _make_decode_ready(OggVorbis_File *vf){ - if(vf->ready_state>STREAMSET)return 0; - if(vf->ready_stateseekable){ - if(vorbis_synthesis_init(&vf->vd,vf->vi+vf->current_link)) - return OV_EBADLINK; - }else{ - if(vorbis_synthesis_init(&vf->vd,vf->vi)) - return OV_EBADLINK; - } - vorbis_block_init(&vf->vd,&vf->vb); - vf->ready_state=INITSET; - vf->bittrack=0.f; - vf->samptrack=0.f; - return 0; -} - -static int _open_seekable2(OggVorbis_File *vf){ - ogg_int64_t dataoffset=vf->dataoffsets[0],end,endgran=-1; - int endserial=vf->os.serialno; - int serialno=vf->os.serialno; - - /* we're partially open and have a first link header state in - storage in vf */ - - /* fetch initial PCM offset */ - ogg_int64_t pcmoffset = _initial_pcmoffset(vf,vf->vi); - - /* we can seek, so set out learning all about this file */ - if(vf->callbacks.seek_func && vf->callbacks.tell_func){ - (vf->callbacks.seek_func)(vf->datasource,0,SEEK_END); - vf->offset=vf->end=(vf->callbacks.tell_func)(vf->datasource); - }else{ - vf->offset=vf->end=-1; - } - - /* If seek_func is implemented, tell_func must also be implemented */ - if(vf->end==-1) return(OV_EINVAL); - - /* Get the offset of the last page of the physical bitstream, or, if - we're lucky the last vorbis page of this link as most OggVorbis - files will contain a single logical bitstream */ - end=_get_prev_page_serial(vf,vf->end,vf->serialnos+2,vf->serialnos[1],&endserial,&endgran); - if(end<0)return(end); - - /* now determine bitstream structure recursively */ - if(_bisect_forward_serialno(vf,0,dataoffset,end,endgran,endserial, - vf->serialnos+2,vf->serialnos[1],0)<0)return(OV_EREAD); - - vf->offsets[0]=0; - vf->serialnos[0]=serialno; - vf->dataoffsets[0]=dataoffset; - vf->pcmlengths[0]=pcmoffset; - vf->pcmlengths[1]-=pcmoffset; - if(vf->pcmlengths[1]<0)vf->pcmlengths[1]=0; - - return(ov_raw_seek(vf,dataoffset)); -} - -/* clear out the current logical bitstream decoder */ -static void _decode_clear(OggVorbis_File *vf){ - vorbis_dsp_clear(&vf->vd); - vorbis_block_clear(&vf->vb); - vf->ready_state=OPENED; -} - -/* fetch and process a packet. Handles the case where we're at a - bitstream boundary and dumps the decoding machine. If the decoding - machine is unloaded, it loads it. It also keeps pcm_offset up to - date (seek and read both use this. seek uses a special hack with - readp). - - return: <0) error, OV_HOLE (lost packet) or OV_EOF - 0) need more data (only if readp==0) - 1) got a packet -*/ - -static int _fetch_and_process_packet(OggVorbis_File *vf, - ogg_packet *op_in, - int readp, - int spanp){ - ogg_page og; - - /* handle one packet. Try to fetch it from current stream state */ - /* extract packets from page */ - while(1){ - - if(vf->ready_state==STREAMSET){ - int ret=_make_decode_ready(vf); - if(ret<0)return ret; - } - - /* process a packet if we can. */ - - if(vf->ready_state==INITSET){ - int hs=vorbis_synthesis_halfrate_p(vf->vi); - - while(1) { - ogg_packet op; - ogg_packet *op_ptr=(op_in?op_in:&op); - int result=ogg_stream_packetout(&vf->os,op_ptr); - ogg_int64_t granulepos; - - op_in=NULL; - if(result==-1)return(OV_HOLE); /* hole in the data. */ - if(result>0){ - /* got a packet. process it */ - granulepos=op_ptr->granulepos; - if(!vorbis_synthesis(&vf->vb,op_ptr)){ /* lazy check for lazy - header handling. The - header packets aren't - audio, so if/when we - submit them, - vorbis_synthesis will - reject them */ - - /* suck in the synthesis data and track bitrate */ - { - int oldsamples=vorbis_synthesis_pcmout(&vf->vd,NULL); - /* for proper use of libvorbis within libvorbisfile, - oldsamples will always be zero. */ - if(oldsamples)return(OV_EFAULT); - - vorbis_synthesis_blockin(&vf->vd,&vf->vb); - vf->samptrack+=(vorbis_synthesis_pcmout(&vf->vd,NULL)<bittrack+=op_ptr->bytes*8; - } - - /* update the pcm offset. */ - if(granulepos!=-1 && !op_ptr->e_o_s){ - int link=(vf->seekable?vf->current_link:0); - int i,samples; - - /* this packet has a pcm_offset on it (the last packet - completed on a page carries the offset) After processing - (above), we know the pcm position of the *last* sample - ready to be returned. Find the offset of the *first* - - As an aside, this trick is inaccurate if we begin - reading anew right at the last page; the end-of-stream - granulepos declares the last frame in the stream, and the - last packet of the last page may be a partial frame. - So, we need a previous granulepos from an in-sequence page - to have a reference point. Thus the !op_ptr->e_o_s clause - above */ - - if(vf->seekable && link>0) - granulepos-=vf->pcmlengths[link*2]; - if(granulepos<0)granulepos=0; /* actually, this - shouldn't be possible - here unless the stream - is very broken */ - - samples=(vorbis_synthesis_pcmout(&vf->vd,NULL)<pcmlengths[i*2+1]; - vf->pcm_offset=granulepos; - } - return(1); - } - } - else - break; - } - } - - if(vf->ready_state>=OPENED){ - ogg_int64_t ret; - - while(1){ - /* the loop is not strictly necessary, but there's no sense in - doing the extra checks of the larger loop for the common - case in a multiplexed bistream where the page is simply - part of a different logical bitstream; keep reading until - we get one with the correct serialno */ - - if(!readp)return(0); - if((ret=_get_next_page(vf,&og,-1))<0){ - return(OV_EOF); /* eof. leave unitialized */ - } - - /* bitrate tracking; add the header's bytes here, the body bytes - are done by packet above */ - vf->bittrack+=og.header_len*8; - - if(vf->ready_state==INITSET){ - if(vf->current_serialno!=ogg_page_serialno(&og)){ - - /* two possibilities: - 1) our decoding just traversed a bitstream boundary - 2) another stream is multiplexed into this logical section */ - - if(ogg_page_bos(&og)){ - /* boundary case */ - if(!spanp) - return(OV_EOF); - - _decode_clear(vf); - - if(!vf->seekable){ - vorbis_info_clear(vf->vi); - vorbis_comment_clear(vf->vc); - } - break; - - }else - continue; /* possibility #2 */ - } - } - - break; - } - } - - /* Do we need to load a new machine before submitting the page? */ - /* This is different in the seekable and non-seekable cases. - - In the seekable case, we already have all the header - information loaded and cached; we just initialize the machine - with it and continue on our merry way. - - In the non-seekable (streaming) case, we'll only be at a - boundary if we just left the previous logical bitstream and - we're now nominally at the header of the next bitstream - */ - - if(vf->ready_state!=INITSET){ - int link; - - if(vf->ready_stateseekable){ - long serialno = ogg_page_serialno(&og); - - /* match the serialno to bitstream section. We use this rather than - offset positions to avoid problems near logical bitstream - boundaries */ - - for(link=0;linklinks;link++) - if(vf->serialnos[link]==serialno)break; - - if(link==vf->links) continue; /* not the desired Vorbis - bitstream section; keep - trying */ - - vf->current_serialno=serialno; - vf->current_link=link; - - ogg_stream_reset_serialno(&vf->os,vf->current_serialno); - vf->ready_state=STREAMSET; - - }else{ - /* we're streaming */ - /* fetch the three header packets, build the info struct */ - - int ret=_fetch_headers(vf,vf->vi,vf->vc,NULL,NULL,&og); - if(ret)return(ret); - vf->current_serialno=vf->os.serialno; - vf->current_link++; - link=0; - } - } - } - - /* the buffered page is the data we want, and we're ready for it; - add it to the stream state */ - ogg_stream_pagein(&vf->os,&og); - - } -} - -/* if, eg, 64 bit stdio is configured by default, this will build with - fseek64 */ -static int _fseek64_wrap(FILE *f,ogg_int64_t off,int whence){ - if(f==NULL)return(-1); - return fseek(f,off,whence); -} - -static int _ov_open1(void *f,OggVorbis_File *vf,const char *initial, - long ibytes, ov_callbacks callbacks){ - int offsettest=((f && callbacks.seek_func)?callbacks.seek_func(f,0,SEEK_CUR):-1); - long *serialno_list=NULL; - int serialno_list_size=0; - int ret; - - memset(vf,0,sizeof(*vf)); - vf->datasource=f; - vf->callbacks = callbacks; - - /* init the framing state */ - ogg_sync_init(&vf->oy); - - /* perhaps some data was previously read into a buffer for testing - against other stream types. Allow initialization from this - previously read data (especially as we may be reading from a - non-seekable stream) */ - if(initial){ - char *buffer=ogg_sync_buffer(&vf->oy,ibytes); - memcpy(buffer,initial,ibytes); - ogg_sync_wrote(&vf->oy,ibytes); - } - - /* can we seek? Stevens suggests the seek test was portable */ - if(offsettest!=-1)vf->seekable=1; - - /* No seeking yet; Set up a 'single' (current) logical bitstream - entry for partial open */ - vf->links=1; - vf->vi=_ogg_calloc(vf->links,sizeof(*vf->vi)); - vf->vc=_ogg_calloc(vf->links,sizeof(*vf->vc)); - ogg_stream_init(&vf->os,-1); /* fill in the serialno later */ - - /* Fetch all BOS pages, store the vorbis header and all seen serial - numbers, load subsequent vorbis setup headers */ - if((ret=_fetch_headers(vf,vf->vi,vf->vc,&serialno_list,&serialno_list_size,NULL))<0){ - vf->datasource=NULL; - ov_clear(vf); - }else{ - /* serial number list for first link needs to be held somewhere - for second stage of seekable stream open; this saves having to - seek/reread first link's serialnumber data then. */ - vf->serialnos=_ogg_calloc(serialno_list_size+2,sizeof(*vf->serialnos)); - vf->serialnos[0]=vf->current_serialno=vf->os.serialno; - vf->serialnos[1]=serialno_list_size; - memcpy(vf->serialnos+2,serialno_list,serialno_list_size*sizeof(*vf->serialnos)); - - vf->offsets=_ogg_calloc(1,sizeof(*vf->offsets)); - vf->dataoffsets=_ogg_calloc(1,sizeof(*vf->dataoffsets)); - vf->offsets[0]=0; - vf->dataoffsets[0]=vf->offset; - - vf->ready_state=PARTOPEN; - } - if(serialno_list)_ogg_free(serialno_list); - return(ret); -} - -static int _ov_open2(OggVorbis_File *vf){ - if(vf->ready_state != PARTOPEN) return OV_EINVAL; - vf->ready_state=OPENED; - if(vf->seekable){ - int ret=_open_seekable2(vf); - if(ret){ - vf->datasource=NULL; - ov_clear(vf); - } - return(ret); - }else - vf->ready_state=STREAMSET; - - return 0; -} - - -/* clear out the OggVorbis_File struct */ -int ov_clear(OggVorbis_File *vf){ - if(vf){ - vorbis_block_clear(&vf->vb); - vorbis_dsp_clear(&vf->vd); - ogg_stream_clear(&vf->os); - - if(vf->vi && vf->links){ - int i; - for(i=0;ilinks;i++){ - vorbis_info_clear(vf->vi+i); - vorbis_comment_clear(vf->vc+i); - } - _ogg_free(vf->vi); - _ogg_free(vf->vc); - } - if(vf->dataoffsets)_ogg_free(vf->dataoffsets); - if(vf->pcmlengths)_ogg_free(vf->pcmlengths); - if(vf->serialnos)_ogg_free(vf->serialnos); - if(vf->offsets)_ogg_free(vf->offsets); - ogg_sync_clear(&vf->oy); - if(vf->datasource && vf->callbacks.close_func) - (vf->callbacks.close_func)(vf->datasource); - memset(vf,0,sizeof(*vf)); - } -#ifdef DEBUG_LEAKS - _VDBG_dump(); -#endif - return(0); -} - -/* inspects the OggVorbis file and finds/documents all the logical - bitstreams contained in it. Tries to be tolerant of logical - bitstream sections that are truncated/woogie. - - return: -1) error - 0) OK -*/ - -int ov_open_callbacks(void *f,OggVorbis_File *vf, - const char *initial,long ibytes,ov_callbacks callbacks){ - int ret=_ov_open1(f,vf,initial,ibytes,callbacks); - if(ret)return ret; - return _ov_open2(vf); -} - -int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes){ - ov_callbacks callbacks = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) _fseek64_wrap, - (int (*)(void *)) fclose, - (long (*)(void *)) ftell - }; - - return ov_open_callbacks((void *)f, vf, initial, ibytes, callbacks); -} - -int ov_fopen(const char *path,OggVorbis_File *vf){ - int ret; - FILE *f = fopen(path,"rb"); - if(!f) return -1; - - ret = ov_open(f,vf,NULL,0); - if(ret) fclose(f); - return ret; -} - - -/* cheap hack for game usage where downsampling is desirable; there's - no need for SRC as we can just do it cheaply in libvorbis. */ - -int ov_halfrate(OggVorbis_File *vf,int flag){ - int i; - if(vf->vi==NULL)return OV_EINVAL; - if(vf->ready_state>STREAMSET){ - /* clear out stream state; dumping the decode machine is needed to - reinit the MDCT lookups. */ - vorbis_dsp_clear(&vf->vd); - vorbis_block_clear(&vf->vb); - vf->ready_state=STREAMSET; - if(vf->pcm_offset>=0){ - ogg_int64_t pos=vf->pcm_offset; - vf->pcm_offset=-1; /* make sure the pos is dumped if unseekable */ - ov_pcm_seek(vf,pos); - } - } - - for(i=0;ilinks;i++){ - if(vorbis_synthesis_halfrate(vf->vi+i,flag)){ - if(flag) ov_halfrate(vf,0); - return OV_EINVAL; - } - } - return 0; -} - -int ov_halfrate_p(OggVorbis_File *vf){ - if(vf->vi==NULL)return OV_EINVAL; - return vorbis_synthesis_halfrate_p(vf->vi); -} - -/* Only partially open the vorbis file; test for Vorbisness, and load - the headers for the first chain. Do not seek (although test for - seekability). Use ov_test_open to finish opening the file, else - ov_clear to close/free it. Same return codes as open. - - Note that vorbisfile does _not_ take ownership of the file if the - call fails; the calling applicaiton is responsible for closing the file - if this call returns an error. */ - -int ov_test_callbacks(void *f,OggVorbis_File *vf, - const char *initial,long ibytes,ov_callbacks callbacks) -{ - return _ov_open1(f,vf,initial,ibytes,callbacks); -} - -int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes){ - ov_callbacks callbacks = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) _fseek64_wrap, - (int (*)(void *)) fclose, - (long (*)(void *)) ftell - }; - - return ov_test_callbacks((void *)f, vf, initial, ibytes, callbacks); -} - -int ov_test_open(OggVorbis_File *vf){ - if(vf->ready_state!=PARTOPEN)return(OV_EINVAL); - return _ov_open2(vf); -} - -/* How many logical bitstreams in this physical bitstream? */ -long ov_streams(OggVorbis_File *vf){ - return vf->links; -} - -/* Is the FILE * associated with vf seekable? */ -long ov_seekable(OggVorbis_File *vf){ - return vf->seekable; -} - -/* returns the bitrate for a given logical bitstream or the entire - physical bitstream. If the file is open for random access, it will - find the *actual* average bitrate. If the file is streaming, it - returns the nominal bitrate (if set) else the average of the - upper/lower bounds (if set) else -1 (unset). - - If you want the actual bitrate field settings, get them from the - vorbis_info structs */ - -long ov_bitrate(OggVorbis_File *vf,int i){ - if(vf->ready_state=vf->links)return(OV_EINVAL); - if(!vf->seekable && i!=0)return(ov_bitrate(vf,0)); - if(i<0){ - ogg_int64_t bits=0; - int i; - float br; - for(i=0;ilinks;i++) - bits+=(vf->offsets[i+1]-vf->dataoffsets[i])*8; - /* This once read: return(rint(bits/ov_time_total(vf,-1))); - * gcc 3.x on x86 miscompiled this at optimisation level 2 and above, - * so this is slightly transformed to make it work. - */ - br = bits/ov_time_total(vf,-1); - return(rint(br)); - }else{ - if(vf->seekable){ - /* return the actual bitrate */ - return(rint((vf->offsets[i+1]-vf->dataoffsets[i])*8/ov_time_total(vf,i))); - }else{ - /* return nominal if set */ - if(vf->vi[i].bitrate_nominal>0){ - return vf->vi[i].bitrate_nominal; - }else{ - if(vf->vi[i].bitrate_upper>0){ - if(vf->vi[i].bitrate_lower>0){ - return (vf->vi[i].bitrate_upper+vf->vi[i].bitrate_lower)/2; - }else{ - return vf->vi[i].bitrate_upper; - } - } - return(OV_FALSE); - } - } - } -} - -/* returns the actual bitrate since last call. returns -1 if no - additional data to offer since last call (or at beginning of stream), - EINVAL if stream is only partially open -*/ -long ov_bitrate_instant(OggVorbis_File *vf){ - int link=(vf->seekable?vf->current_link:0); - long ret; - if(vf->ready_statesamptrack==0)return(OV_FALSE); - ret=vf->bittrack/vf->samptrack*vf->vi[link].rate+.5; - vf->bittrack=0.f; - vf->samptrack=0.f; - return(ret); -} - -/* Guess */ -long ov_serialnumber(OggVorbis_File *vf,int i){ - if(i>=vf->links)return(ov_serialnumber(vf,vf->links-1)); - if(!vf->seekable && i>=0)return(ov_serialnumber(vf,-1)); - if(i<0){ - return(vf->current_serialno); - }else{ - return(vf->serialnos[i]); - } -} - -/* returns: total raw (compressed) length of content if i==-1 - raw (compressed) length of that logical bitstream for i==0 to n - OV_EINVAL if the stream is not seekable (we can't know the length) - or if stream is only partially open -*/ -ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i){ - if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); - if(i<0){ - ogg_int64_t acc=0; - int i; - for(i=0;ilinks;i++) - acc+=ov_raw_total(vf,i); - return(acc); - }else{ - return(vf->offsets[i+1]-vf->offsets[i]); - } -} - -/* returns: total PCM length (samples) of content if i==-1 PCM length - (samples) of that logical bitstream for i==0 to n - OV_EINVAL if the stream is not seekable (we can't know the - length) or only partially open -*/ -ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i){ - if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); - if(i<0){ - ogg_int64_t acc=0; - int i; - for(i=0;ilinks;i++) - acc+=ov_pcm_total(vf,i); - return(acc); - }else{ - return(vf->pcmlengths[i*2+1]); - } -} - -/* returns: total seconds of content if i==-1 - seconds in that logical bitstream for i==0 to n - OV_EINVAL if the stream is not seekable (we can't know the - length) or only partially open -*/ -double ov_time_total(OggVorbis_File *vf,int i){ - if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); - if(i<0){ - double acc=0; - int i; - for(i=0;ilinks;i++) - acc+=ov_time_total(vf,i); - return(acc); - }else{ - return((double)(vf->pcmlengths[i*2+1])/vf->vi[i].rate); - } -} - -/* seek to an offset relative to the *compressed* data. This also - scans packets to update the PCM cursor. It will cross a logical - bitstream boundary, but only if it can't get any packets out of the - tail of the bitstream we seek to (so no surprises). - - returns zero on success, nonzero on failure */ - -int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos){ - ogg_stream_state work_os; - - if(vf->ready_stateseekable) - return(OV_ENOSEEK); /* don't dump machine if we can't seek */ - - if(pos<0 || pos>vf->end)return(OV_EINVAL); - - /* is the seek position outside our current link [if any]? */ - if(vf->ready_state>=STREAMSET){ - if(posoffsets[vf->current_link] || pos>=vf->offsets[vf->current_link+1]) - _decode_clear(vf); /* clear out stream state */ - } - - /* don't yet clear out decoding machine (if it's initialized), in - the case we're in the same link. Restart the decode lapping, and - let _fetch_and_process_packet deal with a potential bitstream - boundary */ - vf->pcm_offset=-1; - ogg_stream_reset_serialno(&vf->os, - vf->current_serialno); /* must set serialno */ - vorbis_synthesis_restart(&vf->vd); - - if(_seek_helper(vf,pos)) { - /* dump the machine so we're in a known state */ - vf->pcm_offset=-1; - _decode_clear(vf); - return OV_EBADLINK; - } - - /* we need to make sure the pcm_offset is set, but we don't want to - advance the raw cursor past good packets just to get to the first - with a granulepos. That's not equivalent behavior to beginning - decoding as immediately after the seek position as possible. - - So, a hack. We use two stream states; a local scratch state and - the shared vf->os stream state. We use the local state to - scan, and the shared state as a buffer for later decode. - - Unfortuantely, on the last page we still advance to last packet - because the granulepos on the last page is not necessarily on a - packet boundary, and we need to make sure the granpos is - correct. - */ - - { - ogg_page og; - ogg_packet op; - int lastblock=0; - int accblock=0; - int thisblock=0; - int lastflag=0; - int firstflag=0; - ogg_int64_t pagepos=-1; - - ogg_stream_init(&work_os,vf->current_serialno); /* get the memory ready */ - ogg_stream_reset(&work_os); /* eliminate the spurious OV_HOLE - return from not necessarily - starting from the beginning */ - - while(1){ - if(vf->ready_state>=STREAMSET){ - /* snarf/scan a packet if we can */ - int result=ogg_stream_packetout(&work_os,&op); - - if(result>0){ - - if(vf->vi[vf->current_link].codec_setup){ - thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op); - if(thisblock<0){ - ogg_stream_packetout(&vf->os,NULL); - thisblock=0; - }else{ - - /* We can't get a guaranteed correct pcm position out of the - last page in a stream because it might have a 'short' - granpos, which can only be detected in the presence of a - preceding page. However, if the last page is also the first - page, the granpos rules of a first page take precedence. Not - only that, but for first==last, the EOS page must be treated - as if its a normal first page for the stream to open/play. */ - if(lastflag && !firstflag) - ogg_stream_packetout(&vf->os,NULL); - else - if(lastblock)accblock+=(lastblock+thisblock)>>2; - } - - if(op.granulepos!=-1){ - int i,link=vf->current_link; - ogg_int64_t granulepos=op.granulepos-vf->pcmlengths[link*2]; - if(granulepos<0)granulepos=0; - - for(i=0;ipcmlengths[i*2+1]; - vf->pcm_offset=granulepos-accblock; - if(vf->pcm_offset<0)vf->pcm_offset=0; - break; - } - lastblock=thisblock; - continue; - }else - ogg_stream_packetout(&vf->os,NULL); - } - } - - if(!lastblock){ - pagepos=_get_next_page(vf,&og,-1); - if(pagepos<0){ - vf->pcm_offset=ov_pcm_total(vf,-1); - break; - } - }else{ - /* huh? Bogus stream with packets but no granulepos */ - vf->pcm_offset=-1; - break; - } - - /* has our decoding just traversed a bitstream boundary? */ - if(vf->ready_state>=STREAMSET){ - if(vf->current_serialno!=ogg_page_serialno(&og)){ - - /* two possibilities: - 1) our decoding just traversed a bitstream boundary - 2) another stream is multiplexed into this logical section? */ - - if(ogg_page_bos(&og)){ - /* we traversed */ - _decode_clear(vf); /* clear out stream state */ - ogg_stream_clear(&work_os); - } /* else, do nothing; next loop will scoop another page */ - } - } - - if(vf->ready_statelinks;link++) - if(vf->serialnos[link]==serialno)break; - - if(link==vf->links) continue; /* not the desired Vorbis - bitstream section; keep - trying */ - vf->current_link=link; - vf->current_serialno=serialno; - ogg_stream_reset_serialno(&vf->os,serialno); - ogg_stream_reset_serialno(&work_os,serialno); - vf->ready_state=STREAMSET; - firstflag=(pagepos<=vf->dataoffsets[link]); - } - - ogg_stream_pagein(&vf->os,&og); - ogg_stream_pagein(&work_os,&og); - lastflag=ogg_page_eos(&og); - - } - } - - ogg_stream_clear(&work_os); - vf->bittrack=0.f; - vf->samptrack=0.f; - return(0); -} - -/* Page granularity seek (faster than sample granularity because we - don't do the last bit of decode to find a specific sample). - - Seek to the last [granule marked] page preceding the specified pos - location, such that decoding past the returned point will quickly - arrive at the requested position. */ -int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos){ - int link=-1; - ogg_int64_t result=0; - ogg_int64_t total=ov_pcm_total(vf,-1); - - if(vf->ready_stateseekable)return(OV_ENOSEEK); - - if(pos<0 || pos>total)return(OV_EINVAL); - - /* which bitstream section does this pcm offset occur in? */ - for(link=vf->links-1;link>=0;link--){ - total-=vf->pcmlengths[link*2+1]; - if(pos>=total)break; - } - - /* Search within the logical bitstream for the page with the highest - pcm_pos preceding pos. If we're looking for a position on the - first page, bisection will halt without finding our position as - it's before the first explicit granulepos fencepost. That case is - handled separately below. - - There is a danger here; missing pages or incorrect frame number - information in the bitstream could make our task impossible. - Account for that (it would be an error condition) */ - - /* new search algorithm originally by HB (Nicholas Vinen) */ - - { - ogg_int64_t end=vf->offsets[link+1]; - ogg_int64_t begin=vf->dataoffsets[link]; - ogg_int64_t begintime = vf->pcmlengths[link*2]; - ogg_int64_t endtime = vf->pcmlengths[link*2+1]+begintime; - ogg_int64_t target=pos-total+begintime; - ogg_int64_t best=-1; - int got_page=0; - - ogg_page og; - - /* if we have only one page, there will be no bisection. Grab the page here */ - if(begin==end){ - result=_seek_helper(vf,begin); - if(result) goto seek_error; - - result=_get_next_page(vf,&og,1); - if(result<0) goto seek_error; - - got_page=1; - } - - /* bisection loop */ - while(beginoffset); - if(result==OV_EREAD) goto seek_error; - if(result<0){ - /* there is no next page! */ - if(bisect<=begin+1) - /* No bisection left to perform. We've either found the - best candidate already or failed. Exit loop. */ - end=begin; - else{ - /* We tried to load a fraction of the last page; back up a - bit and try to get the whole last page */ - if(bisect==0) goto seek_error; - bisect-=CHUNKSIZE; - - /* don't repeat/loop on a read we've already performed */ - if(bisect<=begin)bisect=begin+1; - - /* seek and cntinue bisection */ - result=_seek_helper(vf,bisect); - if(result) goto seek_error; - } - }else{ - ogg_int64_t granulepos; - got_page=1; - - /* got a page. analyze it */ - /* only consider pages from primary vorbis stream */ - if(ogg_page_serialno(&og)!=vf->serialnos[link]) - continue; - - /* only consider pages with the granulepos set */ - granulepos=ogg_page_granulepos(&og); - if(granulepos==-1)continue; - - if(granuleposoffset; /* raw offset of next page */ - begintime=granulepos; - - /* if we're before our target but within a short distance, - don't bisect; read forward */ - if(target-begintime>44100)break; - - bisect=begin; /* *not* begin + 1 as above */ - }else{ - - /* This is one of our pages, but the granpos is - post-target; it is not a bisection return - candidate. (The only way we'd use it is if it's the - first page in the stream; we handle that case later - outside the bisection) */ - if(bisect<=begin+1){ - /* No bisection left to perform. We've either found the - best candidate already or failed. Exit loop. */ - end=begin; - }else{ - if(end==vf->offset){ - /* bisection read to the end; use the known page - boundary (result) to update bisection, back up a - little bit, and try again */ - end=result; - bisect-=CHUNKSIZE; - if(bisect<=begin)bisect=begin+1; - result=_seek_helper(vf,bisect); - if(result) goto seek_error; - }else{ - /* Normal bisection */ - end=bisect; - endtime=granulepos; - break; - } - } - } - } - } - } - - /* Out of bisection: did it 'fail?' */ - if(best == -1){ - - /* Check the 'looking for data in first page' special case; - bisection would 'fail' because our search target was before the - first PCM granule position fencepost. */ - - if(got_page && - begin == vf->dataoffsets[link] && - ogg_page_serialno(&og)==vf->serialnos[link]){ - - /* Yes, this is the beginning-of-stream case. We already have - our page, right at the beginning of PCM data. Set state - and return. */ - - vf->pcm_offset=total; - - if(link!=vf->current_link){ - /* Different link; dump entire decode machine */ - _decode_clear(vf); - - vf->current_link=link; - vf->current_serialno=vf->serialnos[link]; - vf->ready_state=STREAMSET; - - }else{ - vorbis_synthesis_restart(&vf->vd); - } - - ogg_stream_reset_serialno(&vf->os,vf->current_serialno); - ogg_stream_pagein(&vf->os,&og); - - }else - goto seek_error; - - }else{ - - /* Bisection found our page. seek to it, update pcm offset. Easier case than - raw_seek, don't keep packets preceding granulepos. */ - - ogg_page og; - ogg_packet op; - - /* seek */ - result=_seek_helper(vf,best); - vf->pcm_offset=-1; - if(result) goto seek_error; - result=_get_next_page(vf,&og,-1); - if(result<0) goto seek_error; - - if(link!=vf->current_link){ - /* Different link; dump entire decode machine */ - _decode_clear(vf); - - vf->current_link=link; - vf->current_serialno=vf->serialnos[link]; - vf->ready_state=STREAMSET; - - }else{ - vorbis_synthesis_restart(&vf->vd); - } - - ogg_stream_reset_serialno(&vf->os,vf->current_serialno); - ogg_stream_pagein(&vf->os,&og); - - /* pull out all but last packet; the one with granulepos */ - while(1){ - result=ogg_stream_packetpeek(&vf->os,&op); - if(result==0){ - /* No packet returned; we exited the bisection with 'best' - pointing to a page with a granule position, so the packet - finishing this page ('best') originated on a preceding - page. Keep fetching previous pages until we get one with - a granulepos or without the 'continued' flag set. Then - just use raw_seek for simplicity. */ - /* Do not rewind past the beginning of link data; if we do, - it's either a bug or a broken stream */ - result=best; - while(result>vf->dataoffsets[link]){ - result=_get_prev_page(vf,result,&og); - if(result<0) goto seek_error; - if(ogg_page_serialno(&og)==vf->current_serialno && - (ogg_page_granulepos(&og)>-1 || - !ogg_page_continued(&og))){ - return ov_raw_seek(vf,result); - } - } - } - if(result<0){ - result = OV_EBADPACKET; - goto seek_error; - } - if(op.granulepos!=-1){ - vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2]; - if(vf->pcm_offset<0)vf->pcm_offset=0; - vf->pcm_offset+=total; - break; - }else - result=ogg_stream_packetout(&vf->os,NULL); - } - } - } - - /* verify result */ - if(vf->pcm_offset>pos || pos>ov_pcm_total(vf,-1)){ - result=OV_EFAULT; - goto seek_error; - } - vf->bittrack=0.f; - vf->samptrack=0.f; - return(0); - - seek_error: - /* dump machine so we're in a known state */ - vf->pcm_offset=-1; - _decode_clear(vf); - return (int)result; -} - -/* seek to a sample offset relative to the decompressed pcm stream - returns zero on success, nonzero on failure */ - -int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos){ - int thisblock,lastblock=0; - int ret=ov_pcm_seek_page(vf,pos); - if(ret<0)return(ret); - if((ret=_make_decode_ready(vf)))return ret; - - /* discard leading packets we don't need for the lapping of the - position we want; don't decode them */ - - while(1){ - ogg_packet op; - ogg_page og; - - int ret=ogg_stream_packetpeek(&vf->os,&op); - if(ret>0){ - thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op); - if(thisblock<0){ - ogg_stream_packetout(&vf->os,NULL); - continue; /* non audio packet */ - } - if(lastblock)vf->pcm_offset+=(lastblock+thisblock)>>2; - - if(vf->pcm_offset+((thisblock+ - vorbis_info_blocksize(vf->vi,1))>>2)>=pos)break; - - /* remove the packet from packet queue and track its granulepos */ - ogg_stream_packetout(&vf->os,NULL); - vorbis_synthesis_trackonly(&vf->vb,&op); /* set up a vb with - only tracking, no - pcm_decode */ - vorbis_synthesis_blockin(&vf->vd,&vf->vb); - - /* end of logical stream case is hard, especially with exact - length positioning. */ - - if(op.granulepos>-1){ - int i; - /* always believe the stream markers */ - vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2]; - if(vf->pcm_offset<0)vf->pcm_offset=0; - for(i=0;icurrent_link;i++) - vf->pcm_offset+=vf->pcmlengths[i*2+1]; - } - - lastblock=thisblock; - - }else{ - if(ret<0 && ret!=OV_HOLE)break; - - /* suck in a new page */ - if(_get_next_page(vf,&og,-1)<0)break; - if(ogg_page_bos(&og))_decode_clear(vf); - - if(vf->ready_statelinks;link++) - if(vf->serialnos[link]==serialno)break; - if(link==vf->links) continue; - vf->current_link=link; - - vf->ready_state=STREAMSET; - vf->current_serialno=ogg_page_serialno(&og); - ogg_stream_reset_serialno(&vf->os,serialno); - ret=_make_decode_ready(vf); - if(ret)return ret; - lastblock=0; - } - - ogg_stream_pagein(&vf->os,&og); - } - } - - vf->bittrack=0.f; - vf->samptrack=0.f; - /* discard samples until we reach the desired position. Crossing a - logical bitstream boundary with abandon is OK. */ - { - /* note that halfrate could be set differently in each link, but - vorbisfile encoforces all links are set or unset */ - int hs=vorbis_synthesis_halfrate_p(vf->vi); - while(vf->pcm_offset<((pos>>hs)<pcm_offset)>>hs; - long samples=vorbis_synthesis_pcmout(&vf->vd,NULL); - - if(samples>target)samples=target; - vorbis_synthesis_read(&vf->vd,samples); - vf->pcm_offset+=samples<pcm_offset=ov_pcm_total(vf,-1); /* eof */ - } - } - return 0; -} - -/* seek to a playback time relative to the decompressed pcm stream - returns zero on success, nonzero on failure */ -int ov_time_seek(OggVorbis_File *vf,double seconds){ - /* translate time to PCM position and call ov_pcm_seek */ - - int link=-1; - ogg_int64_t pcm_total=0; - double time_total=0.; - - if(vf->ready_stateseekable)return(OV_ENOSEEK); - if(seconds<0)return(OV_EINVAL); - - /* which bitstream section does this time offset occur in? */ - for(link=0;linklinks;link++){ - double addsec = ov_time_total(vf,link); - if(secondspcmlengths[link*2+1]; - } - - if(link==vf->links)return(OV_EINVAL); - - /* enough information to convert time offset to pcm offset */ - { - ogg_int64_t target=pcm_total+(seconds-time_total)*vf->vi[link].rate; - return(ov_pcm_seek(vf,target)); - } -} - -/* page-granularity version of ov_time_seek - returns zero on success, nonzero on failure */ -int ov_time_seek_page(OggVorbis_File *vf,double seconds){ - /* translate time to PCM position and call ov_pcm_seek */ - - int link=-1; - ogg_int64_t pcm_total=0; - double time_total=0.; - - if(vf->ready_stateseekable)return(OV_ENOSEEK); - if(seconds<0)return(OV_EINVAL); - - /* which bitstream section does this time offset occur in? */ - for(link=0;linklinks;link++){ - double addsec = ov_time_total(vf,link); - if(secondspcmlengths[link*2+1]; - } - - if(link==vf->links)return(OV_EINVAL); - - /* enough information to convert time offset to pcm offset */ - { - ogg_int64_t target=pcm_total+(seconds-time_total)*vf->vi[link].rate; - return(ov_pcm_seek_page(vf,target)); - } -} - -/* tell the current stream offset cursor. Note that seek followed by - tell will likely not give the set offset due to caching */ -ogg_int64_t ov_raw_tell(OggVorbis_File *vf){ - if(vf->ready_stateoffset); -} - -/* return PCM offset (sample) of next PCM sample to be read */ -ogg_int64_t ov_pcm_tell(OggVorbis_File *vf){ - if(vf->ready_statepcm_offset); -} - -/* return time offset (seconds) of next PCM sample to be read */ -double ov_time_tell(OggVorbis_File *vf){ - int link=0; - ogg_int64_t pcm_total=0; - double time_total=0.f; - - if(vf->ready_stateseekable){ - pcm_total=ov_pcm_total(vf,-1); - time_total=ov_time_total(vf,-1); - - /* which bitstream section does this time offset occur in? */ - for(link=vf->links-1;link>=0;link--){ - pcm_total-=vf->pcmlengths[link*2+1]; - time_total-=ov_time_total(vf,link); - if(vf->pcm_offset>=pcm_total)break; - } - } - - return((double)time_total+(double)(vf->pcm_offset-pcm_total)/vf->vi[link].rate); -} - -/* link: -1) return the vorbis_info struct for the bitstream section - currently being decoded - 0-n) to request information for a specific bitstream section - - In the case of a non-seekable bitstream, any call returns the - current bitstream. NULL in the case that the machine is not - initialized */ - -vorbis_info *ov_info(OggVorbis_File *vf,int link){ - if(vf->seekable){ - if(link<0) - if(vf->ready_state>=STREAMSET) - return vf->vi+vf->current_link; - else - return vf->vi; - else - if(link>=vf->links) - return NULL; - else - return vf->vi+link; - }else{ - return vf->vi; - } -} - -/* grr, strong typing, grr, no templates/inheritence, grr */ -vorbis_comment *ov_comment(OggVorbis_File *vf,int link){ - if(vf->seekable){ - if(link<0) - if(vf->ready_state>=STREAMSET) - return vf->vc+vf->current_link; - else - return vf->vc; - else - if(link>=vf->links) - return NULL; - else - return vf->vc+link; - }else{ - return vf->vc; - } -} - -static int host_is_big_endian() { - ogg_int32_t pattern = 0xfeedface; /* deadbeef */ - unsigned char *bytewise = (unsigned char *)&pattern; - if (bytewise[0] == 0xfe) return 1; - return 0; -} - -/* up to this point, everything could more or less hide the multiple - logical bitstream nature of chaining from the toplevel application - if the toplevel application didn't particularly care. However, at - the point that we actually read audio back, the multiple-section - nature must surface: Multiple bitstream sections do not necessarily - have to have the same number of channels or sampling rate. - - ov_read returns the sequential logical bitstream number currently - being decoded along with the PCM data in order that the toplevel - application can take action on channel/sample rate changes. This - number will be incremented even for streamed (non-seekable) streams - (for seekable streams, it represents the actual logical bitstream - index within the physical bitstream. Note that the accessor - functions above are aware of this dichotomy). - - ov_read_filter is exactly the same as ov_read except that it processes - the decoded audio data through a filter before packing it into the - requested format. This gives greater accuracy than applying a filter - after the audio has been converted into integral PCM. - - input values: buffer) a buffer to hold packed PCM data for return - length) the byte length requested to be placed into buffer - bigendianp) should the data be packed LSB first (0) or - MSB first (1) - word) word size for output. currently 1 (byte) or - 2 (16 bit short) - - return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL) - 0) EOF - n) number of bytes of PCM actually returned. The - below works on a packet-by-packet basis, so the - return length is not related to the 'length' passed - in, just guaranteed to fit. - - *section) set to the logical bitstream number */ - -long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, - int bigendianp,int word,int sgned,int *bitstream, - void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param){ - int i,j; - int host_endian = host_is_big_endian(); - int hs; - - float **pcm; - long samples; - - if(vf->ready_stateready_state==INITSET){ - samples=vorbis_synthesis_pcmout(&vf->vd,&pcm); - if(samples)break; - } - - /* suck in another packet */ - { - int ret=_fetch_and_process_packet(vf,NULL,1,1); - if(ret==OV_EOF) - return(0); - if(ret<=0) - return(ret); - } - - } - - if(samples>0){ - - /* yay! proceed to pack data into the byte buffer */ - - long channels=ov_info(vf,-1)->channels; - long bytespersample=word * channels; - vorbis_fpu_control fpu; - - if(channels<1||channels>255)return(OV_EINVAL); - if(samples>length/bytespersample)samples=length/bytespersample; - - if(samples <= 0) - return OV_EINVAL; - - /* Here. */ - if(filter) - filter(pcm,channels,samples,filter_param); - - /* a tight loop to pack each size */ - { - int val; - if(word==1){ - int off=(sgned?0:128); - vorbis_fpu_setround(&fpu); - for(j=0;j127)val=127; - else if(val<-128)val=-128; - *buffer++=val+off; - } - vorbis_fpu_restore(fpu); - }else{ - int off=(sgned?0:32768); - - if(host_endian==bigendianp){ - if(sgned){ - - vorbis_fpu_setround(&fpu); - for(i=0;i32767)val=32767; - else if(val<-32768)val=-32768; - *dest=val; - dest+=channels; - } - } - vorbis_fpu_restore(fpu); - - }else{ - - vorbis_fpu_setround(&fpu); - for(i=0;i32767)val=32767; - else if(val<-32768)val=-32768; - *dest=val+off; - dest+=channels; - } - } - vorbis_fpu_restore(fpu); - - } - }else if(bigendianp){ - - vorbis_fpu_setround(&fpu); - for(j=0;j32767)val=32767; - else if(val<-32768)val=-32768; - val+=off; - *buffer++=(val>>8); - *buffer++=(val&0xff); - } - vorbis_fpu_restore(fpu); - - }else{ - int val; - vorbis_fpu_setround(&fpu); - for(j=0;j32767)val=32767; - else if(val<-32768)val=-32768; - val+=off; - *buffer++=(val&0xff); - *buffer++=(val>>8); - } - vorbis_fpu_restore(fpu); - - } - } - } - - vorbis_synthesis_read(&vf->vd,samples); - hs=vorbis_synthesis_halfrate_p(vf->vi); - vf->pcm_offset+=(samples<current_link; - return(samples*bytespersample); - }else{ - return(samples); - } -} - -long ov_read(OggVorbis_File *vf,char *buffer,int length, - int bigendianp,int word,int sgned,int *bitstream){ - return ov_read_filter(vf, buffer, length, bigendianp, word, sgned, bitstream, NULL, NULL); -} - -/* input values: pcm_channels) a float vector per channel of output - length) the sample length being read by the app - - return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL) - 0) EOF - n) number of samples of PCM actually returned. The - below works on a packet-by-packet basis, so the - return length is not related to the 'length' passed - in, just guaranteed to fit. - - *section) set to the logical bitstream number */ - - - -long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int length, - int *bitstream){ - - if(vf->ready_stateready_state==INITSET){ - float **pcm; - long samples=vorbis_synthesis_pcmout(&vf->vd,&pcm); - if(samples){ - int hs=vorbis_synthesis_halfrate_p(vf->vi); - if(pcm_channels)*pcm_channels=pcm; - if(samples>length)samples=length; - vorbis_synthesis_read(&vf->vd,samples); - vf->pcm_offset+=samples<current_link; - return samples; - - } - } - - /* suck in another packet */ - { - int ret=_fetch_and_process_packet(vf,NULL,1,1); - if(ret==OV_EOF)return(0); - if(ret<=0)return(ret); - } - - } -} - -extern const float *vorbis_window(vorbis_dsp_state *v,int W); - -static void _ov_splice(float **pcm,float **lappcm, - int n1, int n2, - int ch1, int ch2, - const float *w1, const float *w2){ - int i,j; - const float *w=w1; - int n=n1; - - if(n1>n2){ - n=n2; - w=w2; - } - - /* splice */ - for(j=0;jready_state==INITSET)break; - /* suck in another packet */ - { - int ret=_fetch_and_process_packet(vf,NULL,1,0); - if(ret<0 && ret!=OV_HOLE)return(ret); - } - } - return 0; -} - -/* make sure vf is INITSET and that we have a primed buffer; if - we're crosslapping at a stream section boundary, this also makes - sure we're sanity checking against the right stream information */ -static int _ov_initprime(OggVorbis_File *vf){ - vorbis_dsp_state *vd=&vf->vd; - while(1){ - if(vf->ready_state==INITSET) - if(vorbis_synthesis_pcmout(vd,NULL))break; - - /* suck in another packet */ - { - int ret=_fetch_and_process_packet(vf,NULL,1,0); - if(ret<0 && ret!=OV_HOLE)return(ret); - } - } - return 0; -} - -/* grab enough data for lapping from vf; this may be in the form of - unreturned, already-decoded pcm, remaining PCM we will need to - decode, or synthetic postextrapolation from last packets. */ -static void _ov_getlap(OggVorbis_File *vf,vorbis_info *vi,vorbis_dsp_state *vd, - float **lappcm,int lapsize){ - int lapcount=0,i; - float **pcm; - - /* try first to decode the lapping data */ - while(lapcountlapsize-lapcount)samples=lapsize-lapcount; - for(i=0;ichannels;i++) - memcpy(lappcm[i]+lapcount,pcm[i],sizeof(**pcm)*samples); - lapcount+=samples; - vorbis_synthesis_read(vd,samples); - }else{ - /* suck in another packet */ - int ret=_fetch_and_process_packet(vf,NULL,1,0); /* do *not* span */ - if(ret==OV_EOF)break; - } - } - if(lapcountvd,&pcm); - if(samples==0){ - for(i=0;ichannels;i++) - memset(lappcm[i]+lapcount,0,sizeof(**pcm)*lapsize-lapcount); - lapcount=lapsize; - }else{ - if(samples>lapsize-lapcount)samples=lapsize-lapcount; - for(i=0;ichannels;i++) - memcpy(lappcm[i]+lapcount,pcm[i],sizeof(**pcm)*samples); - lapcount+=samples; - } - } -} - -/* this sets up crosslapping of a sample by using trailing data from - sample 1 and lapping it into the windowing buffer of sample 2 */ -int ov_crosslap(OggVorbis_File *vf1, OggVorbis_File *vf2){ - vorbis_info *vi1,*vi2; - float **lappcm; - float **pcm; - const float *w1,*w2; - int n1,n2,i,ret,hs1,hs2; - - if(vf1==vf2)return(0); /* degenerate case */ - if(vf1->ready_stateready_statechannels); - n1=vorbis_info_blocksize(vi1,0)>>(1+hs1); - n2=vorbis_info_blocksize(vi2,0)>>(1+hs2); - w1=vorbis_window(&vf1->vd,0); - w2=vorbis_window(&vf2->vd,0); - - for(i=0;ichannels;i++) - lappcm[i]=alloca(sizeof(**lappcm)*n1); - - _ov_getlap(vf1,vi1,&vf1->vd,lappcm,n1); - - /* have a lapping buffer from vf1; now to splice it into the lapping - buffer of vf2 */ - /* consolidate and expose the buffer. */ - vorbis_synthesis_lapout(&vf2->vd,&pcm); - -#if 0 - _analysis_output_always("pcmL",0,pcm[0],n1*2,0,0,0); - _analysis_output_always("pcmR",0,pcm[1],n1*2,0,0,0); -#endif - - /* splice */ - _ov_splice(pcm,lappcm,n1,n2,vi1->channels,vi2->channels,w1,w2); - - /* done */ - return(0); -} - -static int _ov_64_seek_lap(OggVorbis_File *vf,ogg_int64_t pos, - int (*localseek)(OggVorbis_File *,ogg_int64_t)){ - vorbis_info *vi; - float **lappcm; - float **pcm; - const float *w1,*w2; - int n1,n2,ch1,ch2,hs; - int i,ret; - - if(vf->ready_statechannels; - n1=vorbis_info_blocksize(vi,0)>>(1+hs); - w1=vorbis_window(&vf->vd,0); /* window arrays from libvorbis are - persistent; even if the decode state - from this link gets dumped, this - window array continues to exist */ - - lappcm=alloca(sizeof(*lappcm)*ch1); - for(i=0;ivd,lappcm,n1); - - /* have lapping data; seek and prime the buffer */ - ret=localseek(vf,pos); - if(ret)return ret; - ret=_ov_initprime(vf); - if(ret)return(ret); - - /* Guard against cross-link changes; they're perfectly legal */ - vi=ov_info(vf,-1); - ch2=vi->channels; - n2=vorbis_info_blocksize(vi,0)>>(1+hs); - w2=vorbis_window(&vf->vd,0); - - /* consolidate and expose the buffer. */ - vorbis_synthesis_lapout(&vf->vd,&pcm); - - /* splice */ - _ov_splice(pcm,lappcm,n1,n2,ch1,ch2,w1,w2); - - /* done */ - return(0); -} - -int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos){ - return _ov_64_seek_lap(vf,pos,ov_raw_seek); -} - -int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos){ - return _ov_64_seek_lap(vf,pos,ov_pcm_seek); -} - -int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos){ - return _ov_64_seek_lap(vf,pos,ov_pcm_seek_page); -} - -static int _ov_d_seek_lap(OggVorbis_File *vf,double pos, - int (*localseek)(OggVorbis_File *,double)){ - vorbis_info *vi; - float **lappcm; - float **pcm; - const float *w1,*w2; - int n1,n2,ch1,ch2,hs; - int i,ret; - - if(vf->ready_statechannels; - n1=vorbis_info_blocksize(vi,0)>>(1+hs); - w1=vorbis_window(&vf->vd,0); /* window arrays from libvorbis are - persistent; even if the decode state - from this link gets dumped, this - window array continues to exist */ - - lappcm=alloca(sizeof(*lappcm)*ch1); - for(i=0;ivd,lappcm,n1); - - /* have lapping data; seek and prime the buffer */ - ret=localseek(vf,pos); - if(ret)return ret; - ret=_ov_initprime(vf); - if(ret)return(ret); - - /* Guard against cross-link changes; they're perfectly legal */ - vi=ov_info(vf,-1); - ch2=vi->channels; - n2=vorbis_info_blocksize(vi,0)>>(1+hs); - w2=vorbis_window(&vf->vd,0); - - /* consolidate and expose the buffer. */ - vorbis_synthesis_lapout(&vf->vd,&pcm); - - /* splice */ - _ov_splice(pcm,lappcm,n1,n2,ch1,ch2,w1,w2); - - /* done */ - return(0); -} - -int ov_time_seek_lap(OggVorbis_File *vf,double pos){ - return _ov_d_seek_lap(vf,pos,ov_time_seek); -} - -int ov_time_seek_page_lap(OggVorbis_File *vf,double pos){ - return _ov_d_seek_lap(vf,pos,ov_time_seek_page); -} diff --git a/Engine/lib/libvorbis/lib/window.c b/Engine/lib/libvorbis/lib/window.c deleted file mode 100644 index 2151b278d..000000000 --- a/Engine/lib/libvorbis/lib/window.c +++ /dev/null @@ -1,2135 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: window functions - - ********************************************************************/ - -#include -#include -#include "os.h" -#include "misc.h" -#include "window.h" - -static const float vwin64[32] = { - 0.0009460463F, 0.0085006468F, 0.0235352254F, 0.0458950567F, - 0.0753351908F, 0.1115073077F, 0.1539457973F, 0.2020557475F, - 0.2551056759F, 0.3122276645F, 0.3724270287F, 0.4346027792F, - 0.4975789974F, 0.5601459521F, 0.6211085051F, 0.6793382689F, - 0.7338252629F, 0.7837245849F, 0.8283939355F, 0.8674186656F, - 0.9006222429F, 0.9280614787F, 0.9500073081F, 0.9669131782F, - 0.9793740220F, 0.9880792941F, 0.9937636139F, 0.9971582668F, - 0.9989462667F, 0.9997230082F, 0.9999638688F, 0.9999995525F, -}; - -static const float vwin128[64] = { - 0.0002365472F, 0.0021280687F, 0.0059065254F, 0.0115626550F, - 0.0190823442F, 0.0284463735F, 0.0396300935F, 0.0526030430F, - 0.0673285281F, 0.0837631763F, 0.1018564887F, 0.1215504095F, - 0.1427789367F, 0.1654677960F, 0.1895342001F, 0.2148867160F, - 0.2414252576F, 0.2690412240F, 0.2976177952F, 0.3270303960F, - 0.3571473350F, 0.3878306189F, 0.4189369387F, 0.4503188188F, - 0.4818259135F, 0.5133064334F, 0.5446086751F, 0.5755826278F, - 0.6060816248F, 0.6359640047F, 0.6650947483F, 0.6933470543F, - 0.7206038179F, 0.7467589810F, 0.7717187213F, 0.7954024542F, - 0.8177436264F, 0.8386902831F, 0.8582053981F, 0.8762669622F, - 0.8928678298F, 0.9080153310F, 0.9217306608F, 0.9340480615F, - 0.9450138200F, 0.9546851041F, 0.9631286621F, 0.9704194171F, - 0.9766389810F, 0.9818741197F, 0.9862151938F, 0.9897546035F, - 0.9925852598F, 0.9947991032F, 0.9964856900F, 0.9977308602F, - 0.9986155015F, 0.9992144193F, 0.9995953200F, 0.9998179155F, - 0.9999331503F, 0.9999825563F, 0.9999977357F, 0.9999999720F, -}; - -static const float vwin256[128] = { - 0.0000591390F, 0.0005321979F, 0.0014780301F, 0.0028960636F, - 0.0047854363F, 0.0071449926F, 0.0099732775F, 0.0132685298F, - 0.0170286741F, 0.0212513119F, 0.0259337111F, 0.0310727950F, - 0.0366651302F, 0.0427069140F, 0.0491939614F, 0.0561216907F, - 0.0634851102F, 0.0712788035F, 0.0794969160F, 0.0881331402F, - 0.0971807028F, 0.1066323515F, 0.1164803426F, 0.1267164297F, - 0.1373318534F, 0.1483173323F, 0.1596630553F, 0.1713586755F, - 0.1833933062F, 0.1957555184F, 0.2084333404F, 0.2214142599F, - 0.2346852280F, 0.2482326664F, 0.2620424757F, 0.2761000481F, - 0.2903902813F, 0.3048975959F, 0.3196059553F, 0.3344988887F, - 0.3495595160F, 0.3647705766F, 0.3801144597F, 0.3955732382F, - 0.4111287047F, 0.4267624093F, 0.4424557009F, 0.4581897696F, - 0.4739456913F, 0.4897044744F, 0.5054471075F, 0.5211546088F, - 0.5368080763F, 0.5523887395F, 0.5678780103F, 0.5832575361F, - 0.5985092508F, 0.6136154277F, 0.6285587300F, 0.6433222619F, - 0.6578896175F, 0.6722449294F, 0.6863729144F, 0.7002589187F, - 0.7138889597F, 0.7272497662F, 0.7403288154F, 0.7531143679F, - 0.7655954985F, 0.7777621249F, 0.7896050322F, 0.8011158947F, - 0.8122872932F, 0.8231127294F, 0.8335866365F, 0.8437043850F, - 0.8534622861F, 0.8628575905F, 0.8718884835F, 0.8805540765F, - 0.8888543947F, 0.8967903616F, 0.9043637797F, 0.9115773078F, - 0.9184344360F, 0.9249394562F, 0.9310974312F, 0.9369141608F, - 0.9423961446F, 0.9475505439F, 0.9523851406F, 0.9569082947F, - 0.9611289005F, 0.9650563408F, 0.9687004405F, 0.9720714191F, - 0.9751798427F, 0.9780365753F, 0.9806527301F, 0.9830396204F, - 0.9852087111F, 0.9871715701F, 0.9889398207F, 0.9905250941F, - 0.9919389832F, 0.9931929973F, 0.9942985174F, 0.9952667537F, - 0.9961087037F, 0.9968351119F, 0.9974564312F, 0.9979827858F, - 0.9984239359F, 0.9987892441F, 0.9990876435F, 0.9993276081F, - 0.9995171241F, 0.9996636648F, 0.9997741654F, 0.9998550016F, - 0.9999119692F, 0.9999502656F, 0.9999744742F, 0.9999885497F, - 0.9999958064F, 0.9999989077F, 0.9999998584F, 0.9999999983F, -}; - -static const float vwin512[256] = { - 0.0000147849F, 0.0001330607F, 0.0003695946F, 0.0007243509F, - 0.0011972759F, 0.0017882983F, 0.0024973285F, 0.0033242588F, - 0.0042689632F, 0.0053312973F, 0.0065110982F, 0.0078081841F, - 0.0092223540F, 0.0107533880F, 0.0124010466F, 0.0141650703F, - 0.0160451800F, 0.0180410758F, 0.0201524373F, 0.0223789233F, - 0.0247201710F, 0.0271757958F, 0.0297453914F, 0.0324285286F, - 0.0352247556F, 0.0381335972F, 0.0411545545F, 0.0442871045F, - 0.0475306997F, 0.0508847676F, 0.0543487103F, 0.0579219038F, - 0.0616036982F, 0.0653934164F, 0.0692903546F, 0.0732937809F, - 0.0774029356F, 0.0816170305F, 0.0859352485F, 0.0903567428F, - 0.0948806375F, 0.0995060259F, 0.1042319712F, 0.1090575056F, - 0.1139816300F, 0.1190033137F, 0.1241214941F, 0.1293350764F, - 0.1346429333F, 0.1400439046F, 0.1455367974F, 0.1511203852F, - 0.1567934083F, 0.1625545735F, 0.1684025537F, 0.1743359881F, - 0.1803534820F, 0.1864536069F, 0.1926349000F, 0.1988958650F, - 0.2052349715F, 0.2116506555F, 0.2181413191F, 0.2247053313F, - 0.2313410275F, 0.2380467105F, 0.2448206500F, 0.2516610835F, - 0.2585662164F, 0.2655342226F, 0.2725632448F, 0.2796513950F, - 0.2867967551F, 0.2939973773F, 0.3012512852F, 0.3085564739F, - 0.3159109111F, 0.3233125375F, 0.3307592680F, 0.3382489922F, - 0.3457795756F, 0.3533488602F, 0.3609546657F, 0.3685947904F, - 0.3762670121F, 0.3839690896F, 0.3916987634F, 0.3994537572F, - 0.4072317788F, 0.4150305215F, 0.4228476653F, 0.4306808783F, - 0.4385278181F, 0.4463861329F, 0.4542534630F, 0.4621274424F, - 0.4700057001F, 0.4778858615F, 0.4857655502F, 0.4936423891F, - 0.5015140023F, 0.5093780165F, 0.5172320626F, 0.5250737772F, - 0.5329008043F, 0.5407107971F, 0.5485014192F, 0.5562703465F, - 0.5640152688F, 0.5717338914F, 0.5794239366F, 0.5870831457F, - 0.5947092801F, 0.6023001235F, 0.6098534829F, 0.6173671907F, - 0.6248391059F, 0.6322671161F, 0.6396491384F, 0.6469831217F, - 0.6542670475F, 0.6614989319F, 0.6686768267F, 0.6757988210F, - 0.6828630426F, 0.6898676592F, 0.6968108799F, 0.7036909564F, - 0.7105061843F, 0.7172549043F, 0.7239355032F, 0.7305464154F, - 0.7370861235F, 0.7435531598F, 0.7499461068F, 0.7562635986F, - 0.7625043214F, 0.7686670148F, 0.7747504721F, 0.7807535410F, - 0.7866751247F, 0.7925141825F, 0.7982697296F, 0.8039408387F, - 0.8095266395F, 0.8150263196F, 0.8204391248F, 0.8257643590F, - 0.8310013848F, 0.8361496236F, 0.8412085555F, 0.8461777194F, - 0.8510567129F, 0.8558451924F, 0.8605428730F, 0.8651495278F, - 0.8696649882F, 0.8740891432F, 0.8784219392F, 0.8826633797F, - 0.8868135244F, 0.8908724888F, 0.8948404441F, 0.8987176157F, - 0.9025042831F, 0.9062007791F, 0.9098074886F, 0.9133248482F, - 0.9167533451F, 0.9200935163F, 0.9233459472F, 0.9265112712F, - 0.9295901680F, 0.9325833632F, 0.9354916263F, 0.9383157705F, - 0.9410566504F, 0.9437151618F, 0.9462922398F, 0.9487888576F, - 0.9512060252F, 0.9535447882F, 0.9558062262F, 0.9579914516F, - 0.9601016078F, 0.9621378683F, 0.9641014348F, 0.9659935361F, - 0.9678154261F, 0.9695683830F, 0.9712537071F, 0.9728727198F, - 0.9744267618F, 0.9759171916F, 0.9773453842F, 0.9787127293F, - 0.9800206298F, 0.9812705006F, 0.9824637665F, 0.9836018613F, - 0.9846862258F, 0.9857183066F, 0.9866995544F, 0.9876314227F, - 0.9885153662F, 0.9893528393F, 0.9901452948F, 0.9908941823F, - 0.9916009470F, 0.9922670279F, 0.9928938570F, 0.9934828574F, - 0.9940354423F, 0.9945530133F, 0.9950369595F, 0.9954886562F, - 0.9959094633F, 0.9963007242F, 0.9966637649F, 0.9969998925F, - 0.9973103939F, 0.9975965351F, 0.9978595598F, 0.9981006885F, - 0.9983211172F, 0.9985220166F, 0.9987045311F, 0.9988697776F, - 0.9990188449F, 0.9991527924F, 0.9992726499F, 0.9993794157F, - 0.9994740570F, 0.9995575079F, 0.9996306699F, 0.9996944099F, - 0.9997495605F, 0.9997969190F, 0.9998372465F, 0.9998712678F, - 0.9998996704F, 0.9999231041F, 0.9999421807F, 0.9999574732F, - 0.9999695157F, 0.9999788026F, 0.9999857885F, 0.9999908879F, - 0.9999944746F, 0.9999968817F, 0.9999984010F, 0.9999992833F, - 0.9999997377F, 0.9999999317F, 0.9999999911F, 0.9999999999F, -}; - -static const float vwin1024[512] = { - 0.0000036962F, 0.0000332659F, 0.0000924041F, 0.0001811086F, - 0.0002993761F, 0.0004472021F, 0.0006245811F, 0.0008315063F, - 0.0010679699F, 0.0013339631F, 0.0016294757F, 0.0019544965F, - 0.0023090133F, 0.0026930125F, 0.0031064797F, 0.0035493989F, - 0.0040217533F, 0.0045235250F, 0.0050546946F, 0.0056152418F, - 0.0062051451F, 0.0068243817F, 0.0074729278F, 0.0081507582F, - 0.0088578466F, 0.0095941655F, 0.0103596863F, 0.0111543789F, - 0.0119782122F, 0.0128311538F, 0.0137131701F, 0.0146242260F, - 0.0155642855F, 0.0165333111F, 0.0175312640F, 0.0185581042F, - 0.0196137903F, 0.0206982797F, 0.0218115284F, 0.0229534910F, - 0.0241241208F, 0.0253233698F, 0.0265511886F, 0.0278075263F, - 0.0290923308F, 0.0304055484F, 0.0317471241F, 0.0331170013F, - 0.0345151222F, 0.0359414274F, 0.0373958560F, 0.0388783456F, - 0.0403888325F, 0.0419272511F, 0.0434935347F, 0.0450876148F, - 0.0467094213F, 0.0483588828F, 0.0500359261F, 0.0517404765F, - 0.0534724575F, 0.0552317913F, 0.0570183983F, 0.0588321971F, - 0.0606731048F, 0.0625410369F, 0.0644359070F, 0.0663576272F, - 0.0683061077F, 0.0702812571F, 0.0722829821F, 0.0743111878F, - 0.0763657775F, 0.0784466526F, 0.0805537129F, 0.0826868561F, - 0.0848459782F, 0.0870309736F, 0.0892417345F, 0.0914781514F, - 0.0937401128F, 0.0960275056F, 0.0983402145F, 0.1006781223F, - 0.1030411101F, 0.1054290568F, 0.1078418397F, 0.1102793336F, - 0.1127414119F, 0.1152279457F, 0.1177388042F, 0.1202738544F, - 0.1228329618F, 0.1254159892F, 0.1280227980F, 0.1306532471F, - 0.1333071937F, 0.1359844927F, 0.1386849970F, 0.1414085575F, - 0.1441550230F, 0.1469242403F, 0.1497160539F, 0.1525303063F, - 0.1553668381F, 0.1582254875F, 0.1611060909F, 0.1640084822F, - 0.1669324936F, 0.1698779549F, 0.1728446939F, 0.1758325362F, - 0.1788413055F, 0.1818708232F, 0.1849209084F, 0.1879913785F, - 0.1910820485F, 0.1941927312F, 0.1973232376F, 0.2004733764F, - 0.2036429541F, 0.2068317752F, 0.2100396421F, 0.2132663552F, - 0.2165117125F, 0.2197755102F, 0.2230575422F, 0.2263576007F, - 0.2296754753F, 0.2330109540F, 0.2363638225F, 0.2397338646F, - 0.2431208619F, 0.2465245941F, 0.2499448389F, 0.2533813719F, - 0.2568339669F, 0.2603023956F, 0.2637864277F, 0.2672858312F, - 0.2708003718F, 0.2743298135F, 0.2778739186F, 0.2814324472F, - 0.2850051576F, 0.2885918065F, 0.2921921485F, 0.2958059366F, - 0.2994329219F, 0.3030728538F, 0.3067254799F, 0.3103905462F, - 0.3140677969F, 0.3177569747F, 0.3214578205F, 0.3251700736F, - 0.3288934718F, 0.3326277513F, 0.3363726468F, 0.3401278914F, - 0.3438932168F, 0.3476683533F, 0.3514530297F, 0.3552469734F, - 0.3590499106F, 0.3628615659F, 0.3666816630F, 0.3705099239F, - 0.3743460698F, 0.3781898204F, 0.3820408945F, 0.3858990095F, - 0.3897638820F, 0.3936352274F, 0.3975127601F, 0.4013961936F, - 0.4052852405F, 0.4091796123F, 0.4130790198F, 0.4169831732F, - 0.4208917815F, 0.4248045534F, 0.4287211965F, 0.4326414181F, - 0.4365649248F, 0.4404914225F, 0.4444206167F, 0.4483522125F, - 0.4522859146F, 0.4562214270F, 0.4601584538F, 0.4640966984F, - 0.4680358644F, 0.4719756548F, 0.4759157726F, 0.4798559209F, - 0.4837958024F, 0.4877351199F, 0.4916735765F, 0.4956108751F, - 0.4995467188F, 0.5034808109F, 0.5074128550F, 0.5113425550F, - 0.5152696149F, 0.5191937395F, 0.5231146336F, 0.5270320028F, - 0.5309455530F, 0.5348549910F, 0.5387600239F, 0.5426603597F, - 0.5465557070F, 0.5504457754F, 0.5543302752F, 0.5582089175F, - 0.5620814145F, 0.5659474793F, 0.5698068262F, 0.5736591704F, - 0.5775042283F, 0.5813417176F, 0.5851713571F, 0.5889928670F, - 0.5928059689F, 0.5966103856F, 0.6004058415F, 0.6041920626F, - 0.6079687761F, 0.6117357113F, 0.6154925986F, 0.6192391705F, - 0.6229751612F, 0.6267003064F, 0.6304143441F, 0.6341170137F, - 0.6378080569F, 0.6414872173F, 0.6451542405F, 0.6488088741F, - 0.6524508681F, 0.6560799742F, 0.6596959469F, 0.6632985424F, - 0.6668875197F, 0.6704626398F, 0.6740236662F, 0.6775703649F, - 0.6811025043F, 0.6846198554F, 0.6881221916F, 0.6916092892F, - 0.6950809269F, 0.6985368861F, 0.7019769510F, 0.7054009085F, - 0.7088085484F, 0.7121996632F, 0.7155740484F, 0.7189315023F, - 0.7222718263F, 0.7255948245F, 0.7289003043F, 0.7321880760F, - 0.7354579530F, 0.7387097518F, 0.7419432921F, 0.7451583966F, - 0.7483548915F, 0.7515326059F, 0.7546913723F, 0.7578310265F, - 0.7609514077F, 0.7640523581F, 0.7671337237F, 0.7701953535F, - 0.7732371001F, 0.7762588195F, 0.7792603711F, 0.7822416178F, - 0.7852024259F, 0.7881426654F, 0.7910622097F, 0.7939609356F, - 0.7968387237F, 0.7996954579F, 0.8025310261F, 0.8053453193F, - 0.8081382324F, 0.8109096638F, 0.8136595156F, 0.8163876936F, - 0.8190941071F, 0.8217786690F, 0.8244412960F, 0.8270819086F, - 0.8297004305F, 0.8322967896F, 0.8348709171F, 0.8374227481F, - 0.8399522213F, 0.8424592789F, 0.8449438672F, 0.8474059356F, - 0.8498454378F, 0.8522623306F, 0.8546565748F, 0.8570281348F, - 0.8593769787F, 0.8617030779F, 0.8640064080F, 0.8662869477F, - 0.8685446796F, 0.8707795899F, 0.8729916682F, 0.8751809079F, - 0.8773473059F, 0.8794908626F, 0.8816115819F, 0.8837094713F, - 0.8857845418F, 0.8878368079F, 0.8898662874F, 0.8918730019F, - 0.8938569760F, 0.8958182380F, 0.8977568194F, 0.8996727552F, - 0.9015660837F, 0.9034368465F, 0.9052850885F, 0.9071108577F, - 0.9089142057F, 0.9106951869F, 0.9124538591F, 0.9141902832F, - 0.9159045233F, 0.9175966464F, 0.9192667228F, 0.9209148257F, - 0.9225410313F, 0.9241454187F, 0.9257280701F, 0.9272890704F, - 0.9288285075F, 0.9303464720F, 0.9318430576F, 0.9333183603F, - 0.9347724792F, 0.9362055158F, 0.9376175745F, 0.9390087622F, - 0.9403791881F, 0.9417289644F, 0.9430582055F, 0.9443670283F, - 0.9456555521F, 0.9469238986F, 0.9481721917F, 0.9494005577F, - 0.9506091252F, 0.9517980248F, 0.9529673894F, 0.9541173540F, - 0.9552480557F, 0.9563596334F, 0.9574522282F, 0.9585259830F, - 0.9595810428F, 0.9606175542F, 0.9616356656F, 0.9626355274F, - 0.9636172915F, 0.9645811114F, 0.9655271425F, 0.9664555414F, - 0.9673664664F, 0.9682600774F, 0.9691365355F, 0.9699960034F, - 0.9708386448F, 0.9716646250F, 0.9724741103F, 0.9732672685F, - 0.9740442683F, 0.9748052795F, 0.9755504729F, 0.9762800205F, - 0.9769940950F, 0.9776928703F, 0.9783765210F, 0.9790452223F, - 0.9796991504F, 0.9803384823F, 0.9809633954F, 0.9815740679F, - 0.9821706784F, 0.9827534063F, 0.9833224312F, 0.9838779332F, - 0.9844200928F, 0.9849490910F, 0.9854651087F, 0.9859683274F, - 0.9864589286F, 0.9869370940F, 0.9874030054F, 0.9878568447F, - 0.9882987937F, 0.9887290343F, 0.9891477481F, 0.9895551169F, - 0.9899513220F, 0.9903365446F, 0.9907109658F, 0.9910747662F, - 0.9914281260F, 0.9917712252F, 0.9921042433F, 0.9924273593F, - 0.9927407516F, 0.9930445982F, 0.9933390763F, 0.9936243626F, - 0.9939006331F, 0.9941680631F, 0.9944268269F, 0.9946770982F, - 0.9949190498F, 0.9951528537F, 0.9953786808F, 0.9955967011F, - 0.9958070836F, 0.9960099963F, 0.9962056061F, 0.9963940787F, - 0.9965755786F, 0.9967502693F, 0.9969183129F, 0.9970798704F, - 0.9972351013F, 0.9973841640F, 0.9975272151F, 0.9976644103F, - 0.9977959036F, 0.9979218476F, 0.9980423932F, 0.9981576901F, - 0.9982678862F, 0.9983731278F, 0.9984735596F, 0.9985693247F, - 0.9986605645F, 0.9987474186F, 0.9988300248F, 0.9989085193F, - 0.9989830364F, 0.9990537085F, 0.9991206662F, 0.9991840382F, - 0.9992439513F, 0.9993005303F, 0.9993538982F, 0.9994041757F, - 0.9994514817F, 0.9994959330F, 0.9995376444F, 0.9995767286F, - 0.9996132960F, 0.9996474550F, 0.9996793121F, 0.9997089710F, - 0.9997365339F, 0.9997621003F, 0.9997857677F, 0.9998076311F, - 0.9998277836F, 0.9998463156F, 0.9998633155F, 0.9998788692F, - 0.9998930603F, 0.9999059701F, 0.9999176774F, 0.9999282586F, - 0.9999377880F, 0.9999463370F, 0.9999539749F, 0.9999607685F, - 0.9999667820F, 0.9999720773F, 0.9999767136F, 0.9999807479F, - 0.9999842344F, 0.9999872249F, 0.9999897688F, 0.9999919127F, - 0.9999937009F, 0.9999951749F, 0.9999963738F, 0.9999973342F, - 0.9999980900F, 0.9999986724F, 0.9999991103F, 0.9999994297F, - 0.9999996543F, 0.9999998049F, 0.9999999000F, 0.9999999552F, - 0.9999999836F, 0.9999999957F, 0.9999999994F, 1.0000000000F, -}; - -static const float vwin2048[1024] = { - 0.0000009241F, 0.0000083165F, 0.0000231014F, 0.0000452785F, - 0.0000748476F, 0.0001118085F, 0.0001561608F, 0.0002079041F, - 0.0002670379F, 0.0003335617F, 0.0004074748F, 0.0004887765F, - 0.0005774661F, 0.0006735427F, 0.0007770054F, 0.0008878533F, - 0.0010060853F, 0.0011317002F, 0.0012646969F, 0.0014050742F, - 0.0015528307F, 0.0017079650F, 0.0018704756F, 0.0020403610F, - 0.0022176196F, 0.0024022497F, 0.0025942495F, 0.0027936173F, - 0.0030003511F, 0.0032144490F, 0.0034359088F, 0.0036647286F, - 0.0039009061F, 0.0041444391F, 0.0043953253F, 0.0046535621F, - 0.0049191472F, 0.0051920781F, 0.0054723520F, 0.0057599664F, - 0.0060549184F, 0.0063572052F, 0.0066668239F, 0.0069837715F, - 0.0073080449F, 0.0076396410F, 0.0079785566F, 0.0083247884F, - 0.0086783330F, 0.0090391871F, 0.0094073470F, 0.0097828092F, - 0.0101655700F, 0.0105556258F, 0.0109529726F, 0.0113576065F, - 0.0117695237F, 0.0121887200F, 0.0126151913F, 0.0130489335F, - 0.0134899422F, 0.0139382130F, 0.0143937415F, 0.0148565233F, - 0.0153265536F, 0.0158038279F, 0.0162883413F, 0.0167800889F, - 0.0172790660F, 0.0177852675F, 0.0182986882F, 0.0188193231F, - 0.0193471668F, 0.0198822141F, 0.0204244594F, 0.0209738974F, - 0.0215305225F, 0.0220943289F, 0.0226653109F, 0.0232434627F, - 0.0238287784F, 0.0244212519F, 0.0250208772F, 0.0256276481F, - 0.0262415582F, 0.0268626014F, 0.0274907711F, 0.0281260608F, - 0.0287684638F, 0.0294179736F, 0.0300745833F, 0.0307382859F, - 0.0314090747F, 0.0320869424F, 0.0327718819F, 0.0334638860F, - 0.0341629474F, 0.0348690586F, 0.0355822122F, 0.0363024004F, - 0.0370296157F, 0.0377638502F, 0.0385050960F, 0.0392533451F, - 0.0400085896F, 0.0407708211F, 0.0415400315F, 0.0423162123F, - 0.0430993552F, 0.0438894515F, 0.0446864926F, 0.0454904698F, - 0.0463013742F, 0.0471191969F, 0.0479439288F, 0.0487755607F, - 0.0496140836F, 0.0504594879F, 0.0513117642F, 0.0521709031F, - 0.0530368949F, 0.0539097297F, 0.0547893979F, 0.0556758894F, - 0.0565691941F, 0.0574693019F, 0.0583762026F, 0.0592898858F, - 0.0602103410F, 0.0611375576F, 0.0620715250F, 0.0630122324F, - 0.0639596688F, 0.0649138234F, 0.0658746848F, 0.0668422421F, - 0.0678164838F, 0.0687973985F, 0.0697849746F, 0.0707792005F, - 0.0717800645F, 0.0727875547F, 0.0738016591F, 0.0748223656F, - 0.0758496620F, 0.0768835359F, 0.0779239751F, 0.0789709668F, - 0.0800244985F, 0.0810845574F, 0.0821511306F, 0.0832242052F, - 0.0843037679F, 0.0853898056F, 0.0864823050F, 0.0875812525F, - 0.0886866347F, 0.0897984378F, 0.0909166480F, 0.0920412513F, - 0.0931722338F, 0.0943095813F, 0.0954532795F, 0.0966033140F, - 0.0977596702F, 0.0989223336F, 0.1000912894F, 0.1012665227F, - 0.1024480185F, 0.1036357616F, 0.1048297369F, 0.1060299290F, - 0.1072363224F, 0.1084489014F, 0.1096676504F, 0.1108925534F, - 0.1121235946F, 0.1133607577F, 0.1146040267F, 0.1158533850F, - 0.1171088163F, 0.1183703040F, 0.1196378312F, 0.1209113812F, - 0.1221909370F, 0.1234764815F, 0.1247679974F, 0.1260654674F, - 0.1273688740F, 0.1286781995F, 0.1299934263F, 0.1313145365F, - 0.1326415121F, 0.1339743349F, 0.1353129866F, 0.1366574490F, - 0.1380077035F, 0.1393637315F, 0.1407255141F, 0.1420930325F, - 0.1434662677F, 0.1448452004F, 0.1462298115F, 0.1476200814F, - 0.1490159906F, 0.1504175195F, 0.1518246482F, 0.1532373569F, - 0.1546556253F, 0.1560794333F, 0.1575087606F, 0.1589435866F, - 0.1603838909F, 0.1618296526F, 0.1632808509F, 0.1647374648F, - 0.1661994731F, 0.1676668546F, 0.1691395880F, 0.1706176516F, - 0.1721010238F, 0.1735896829F, 0.1750836068F, 0.1765827736F, - 0.1780871610F, 0.1795967468F, 0.1811115084F, 0.1826314234F, - 0.1841564689F, 0.1856866221F, 0.1872218600F, 0.1887621595F, - 0.1903074974F, 0.1918578503F, 0.1934131947F, 0.1949735068F, - 0.1965387630F, 0.1981089393F, 0.1996840117F, 0.2012639560F, - 0.2028487479F, 0.2044383630F, 0.2060327766F, 0.2076319642F, - 0.2092359007F, 0.2108445614F, 0.2124579211F, 0.2140759545F, - 0.2156986364F, 0.2173259411F, 0.2189578432F, 0.2205943168F, - 0.2222353361F, 0.2238808751F, 0.2255309076F, 0.2271854073F, - 0.2288443480F, 0.2305077030F, 0.2321754457F, 0.2338475493F, - 0.2355239869F, 0.2372047315F, 0.2388897560F, 0.2405790329F, - 0.2422725350F, 0.2439702347F, 0.2456721043F, 0.2473781159F, - 0.2490882418F, 0.2508024539F, 0.2525207240F, 0.2542430237F, - 0.2559693248F, 0.2576995986F, 0.2594338166F, 0.2611719498F, - 0.2629139695F, 0.2646598466F, 0.2664095520F, 0.2681630564F, - 0.2699203304F, 0.2716813445F, 0.2734460691F, 0.2752144744F, - 0.2769865307F, 0.2787622079F, 0.2805414760F, 0.2823243047F, - 0.2841106637F, 0.2859005227F, 0.2876938509F, 0.2894906179F, - 0.2912907928F, 0.2930943447F, 0.2949012426F, 0.2967114554F, - 0.2985249520F, 0.3003417009F, 0.3021616708F, 0.3039848301F, - 0.3058111471F, 0.3076405901F, 0.3094731273F, 0.3113087266F, - 0.3131473560F, 0.3149889833F, 0.3168335762F, 0.3186811024F, - 0.3205315294F, 0.3223848245F, 0.3242409552F, 0.3260998886F, - 0.3279615918F, 0.3298260319F, 0.3316931758F, 0.3335629903F, - 0.3354354423F, 0.3373104982F, 0.3391881247F, 0.3410682882F, - 0.3429509551F, 0.3448360917F, 0.3467236642F, 0.3486136387F, - 0.3505059811F, 0.3524006575F, 0.3542976336F, 0.3561968753F, - 0.3580983482F, 0.3600020179F, 0.3619078499F, 0.3638158096F, - 0.3657258625F, 0.3676379737F, 0.3695521086F, 0.3714682321F, - 0.3733863094F, 0.3753063055F, 0.3772281852F, 0.3791519134F, - 0.3810774548F, 0.3830047742F, 0.3849338362F, 0.3868646053F, - 0.3887970459F, 0.3907311227F, 0.3926667998F, 0.3946040417F, - 0.3965428125F, 0.3984830765F, 0.4004247978F, 0.4023679403F, - 0.4043124683F, 0.4062583455F, 0.4082055359F, 0.4101540034F, - 0.4121037117F, 0.4140546246F, 0.4160067058F, 0.4179599190F, - 0.4199142277F, 0.4218695956F, 0.4238259861F, 0.4257833627F, - 0.4277416888F, 0.4297009279F, 0.4316610433F, 0.4336219983F, - 0.4355837562F, 0.4375462803F, 0.4395095337F, 0.4414734797F, - 0.4434380815F, 0.4454033021F, 0.4473691046F, 0.4493354521F, - 0.4513023078F, 0.4532696345F, 0.4552373954F, 0.4572055533F, - 0.4591740713F, 0.4611429123F, 0.4631120393F, 0.4650814151F, - 0.4670510028F, 0.4690207650F, 0.4709906649F, 0.4729606651F, - 0.4749307287F, 0.4769008185F, 0.4788708972F, 0.4808409279F, - 0.4828108732F, 0.4847806962F, 0.4867503597F, 0.4887198264F, - 0.4906890593F, 0.4926580213F, 0.4946266753F, 0.4965949840F, - 0.4985629105F, 0.5005304176F, 0.5024974683F, 0.5044640255F, - 0.5064300522F, 0.5083955114F, 0.5103603659F, 0.5123245790F, - 0.5142881136F, 0.5162509328F, 0.5182129997F, 0.5201742774F, - 0.5221347290F, 0.5240943178F, 0.5260530070F, 0.5280107598F, - 0.5299675395F, 0.5319233095F, 0.5338780330F, 0.5358316736F, - 0.5377841946F, 0.5397355596F, 0.5416857320F, 0.5436346755F, - 0.5455823538F, 0.5475287304F, 0.5494737691F, 0.5514174337F, - 0.5533596881F, 0.5553004962F, 0.5572398218F, 0.5591776291F, - 0.5611138821F, 0.5630485449F, 0.5649815818F, 0.5669129570F, - 0.5688426349F, 0.5707705799F, 0.5726967564F, 0.5746211290F, - 0.5765436624F, 0.5784643212F, 0.5803830702F, 0.5822998743F, - 0.5842146984F, 0.5861275076F, 0.5880382669F, 0.5899469416F, - 0.5918534968F, 0.5937578981F, 0.5956601107F, 0.5975601004F, - 0.5994578326F, 0.6013532732F, 0.6032463880F, 0.6051371429F, - 0.6070255039F, 0.6089114372F, 0.6107949090F, 0.6126758856F, - 0.6145543334F, 0.6164302191F, 0.6183035092F, 0.6201741706F, - 0.6220421700F, 0.6239074745F, 0.6257700513F, 0.6276298674F, - 0.6294868903F, 0.6313410873F, 0.6331924262F, 0.6350408745F, - 0.6368864001F, 0.6387289710F, 0.6405685552F, 0.6424051209F, - 0.6442386364F, 0.6460690702F, 0.6478963910F, 0.6497205673F, - 0.6515415682F, 0.6533593625F, 0.6551739194F, 0.6569852082F, - 0.6587931984F, 0.6605978593F, 0.6623991609F, 0.6641970728F, - 0.6659915652F, 0.6677826081F, 0.6695701718F, 0.6713542268F, - 0.6731347437F, 0.6749116932F, 0.6766850461F, 0.6784547736F, - 0.6802208469F, 0.6819832374F, 0.6837419164F, 0.6854968559F, - 0.6872480275F, 0.6889954034F, 0.6907389556F, 0.6924786566F, - 0.6942144788F, 0.6959463950F, 0.6976743780F, 0.6993984008F, - 0.7011184365F, 0.7028344587F, 0.7045464407F, 0.7062543564F, - 0.7079581796F, 0.7096578844F, 0.7113534450F, 0.7130448359F, - 0.7147320316F, 0.7164150070F, 0.7180937371F, 0.7197681970F, - 0.7214383620F, 0.7231042077F, 0.7247657098F, 0.7264228443F, - 0.7280755871F, 0.7297239147F, 0.7313678035F, 0.7330072301F, - 0.7346421715F, 0.7362726046F, 0.7378985069F, 0.7395198556F, - 0.7411366285F, 0.7427488034F, 0.7443563584F, 0.7459592717F, - 0.7475575218F, 0.7491510873F, 0.7507399471F, 0.7523240803F, - 0.7539034661F, 0.7554780839F, 0.7570479136F, 0.7586129349F, - 0.7601731279F, 0.7617284730F, 0.7632789506F, 0.7648245416F, - 0.7663652267F, 0.7679009872F, 0.7694318044F, 0.7709576599F, - 0.7724785354F, 0.7739944130F, 0.7755052749F, 0.7770111035F, - 0.7785118815F, 0.7800075916F, 0.7814982170F, 0.7829837410F, - 0.7844641472F, 0.7859394191F, 0.7874095408F, 0.7888744965F, - 0.7903342706F, 0.7917888476F, 0.7932382124F, 0.7946823501F, - 0.7961212460F, 0.7975548855F, 0.7989832544F, 0.8004063386F, - 0.8018241244F, 0.8032365981F, 0.8046437463F, 0.8060455560F, - 0.8074420141F, 0.8088331080F, 0.8102188253F, 0.8115991536F, - 0.8129740810F, 0.8143435957F, 0.8157076861F, 0.8170663409F, - 0.8184195489F, 0.8197672994F, 0.8211095817F, 0.8224463853F, - 0.8237777001F, 0.8251035161F, 0.8264238235F, 0.8277386129F, - 0.8290478750F, 0.8303516008F, 0.8316497814F, 0.8329424083F, - 0.8342294731F, 0.8355109677F, 0.8367868841F, 0.8380572148F, - 0.8393219523F, 0.8405810893F, 0.8418346190F, 0.8430825345F, - 0.8443248294F, 0.8455614974F, 0.8467925323F, 0.8480179285F, - 0.8492376802F, 0.8504517822F, 0.8516602292F, 0.8528630164F, - 0.8540601391F, 0.8552515928F, 0.8564373733F, 0.8576174766F, - 0.8587918990F, 0.8599606368F, 0.8611236868F, 0.8622810460F, - 0.8634327113F, 0.8645786802F, 0.8657189504F, 0.8668535195F, - 0.8679823857F, 0.8691055472F, 0.8702230025F, 0.8713347503F, - 0.8724407896F, 0.8735411194F, 0.8746357394F, 0.8757246489F, - 0.8768078479F, 0.8778853364F, 0.8789571146F, 0.8800231832F, - 0.8810835427F, 0.8821381942F, 0.8831871387F, 0.8842303777F, - 0.8852679127F, 0.8862997456F, 0.8873258784F, 0.8883463132F, - 0.8893610527F, 0.8903700994F, 0.8913734562F, 0.8923711263F, - 0.8933631129F, 0.8943494196F, 0.8953300500F, 0.8963050083F, - 0.8972742985F, 0.8982379249F, 0.8991958922F, 0.9001482052F, - 0.9010948688F, 0.9020358883F, 0.9029712690F, 0.9039010165F, - 0.9048251367F, 0.9057436357F, 0.9066565195F, 0.9075637946F, - 0.9084654678F, 0.9093615456F, 0.9102520353F, 0.9111369440F, - 0.9120162792F, 0.9128900484F, 0.9137582595F, 0.9146209204F, - 0.9154780394F, 0.9163296248F, 0.9171756853F, 0.9180162296F, - 0.9188512667F, 0.9196808057F, 0.9205048559F, 0.9213234270F, - 0.9221365285F, 0.9229441704F, 0.9237463629F, 0.9245431160F, - 0.9253344404F, 0.9261203465F, 0.9269008453F, 0.9276759477F, - 0.9284456648F, 0.9292100080F, 0.9299689889F, 0.9307226190F, - 0.9314709103F, 0.9322138747F, 0.9329515245F, 0.9336838721F, - 0.9344109300F, 0.9351327108F, 0.9358492275F, 0.9365604931F, - 0.9372665208F, 0.9379673239F, 0.9386629160F, 0.9393533107F, - 0.9400385220F, 0.9407185637F, 0.9413934501F, 0.9420631954F, - 0.9427278141F, 0.9433873208F, 0.9440417304F, 0.9446910576F, - 0.9453353176F, 0.9459745255F, 0.9466086968F, 0.9472378469F, - 0.9478619915F, 0.9484811463F, 0.9490953274F, 0.9497045506F, - 0.9503088323F, 0.9509081888F, 0.9515026365F, 0.9520921921F, - 0.9526768723F, 0.9532566940F, 0.9538316742F, 0.9544018300F, - 0.9549671786F, 0.9555277375F, 0.9560835241F, 0.9566345562F, - 0.9571808513F, 0.9577224275F, 0.9582593027F, 0.9587914949F, - 0.9593190225F, 0.9598419038F, 0.9603601571F, 0.9608738012F, - 0.9613828546F, 0.9618873361F, 0.9623872646F, 0.9628826591F, - 0.9633735388F, 0.9638599227F, 0.9643418303F, 0.9648192808F, - 0.9652922939F, 0.9657608890F, 0.9662250860F, 0.9666849046F, - 0.9671403646F, 0.9675914861F, 0.9680382891F, 0.9684807937F, - 0.9689190202F, 0.9693529890F, 0.9697827203F, 0.9702082347F, - 0.9706295529F, 0.9710466953F, 0.9714596828F, 0.9718685362F, - 0.9722732762F, 0.9726739240F, 0.9730705005F, 0.9734630267F, - 0.9738515239F, 0.9742360134F, 0.9746165163F, 0.9749930540F, - 0.9753656481F, 0.9757343198F, 0.9760990909F, 0.9764599829F, - 0.9768170175F, 0.9771702164F, 0.9775196013F, 0.9778651941F, - 0.9782070167F, 0.9785450909F, 0.9788794388F, 0.9792100824F, - 0.9795370437F, 0.9798603449F, 0.9801800080F, 0.9804960554F, - 0.9808085092F, 0.9811173916F, 0.9814227251F, 0.9817245318F, - 0.9820228343F, 0.9823176549F, 0.9826090160F, 0.9828969402F, - 0.9831814498F, 0.9834625674F, 0.9837403156F, 0.9840147169F, - 0.9842857939F, 0.9845535692F, 0.9848180654F, 0.9850793052F, - 0.9853373113F, 0.9855921062F, 0.9858437127F, 0.9860921535F, - 0.9863374512F, 0.9865796287F, 0.9868187085F, 0.9870547136F, - 0.9872876664F, 0.9875175899F, 0.9877445067F, 0.9879684396F, - 0.9881894112F, 0.9884074444F, 0.9886225619F, 0.9888347863F, - 0.9890441404F, 0.9892506468F, 0.9894543284F, 0.9896552077F, - 0.9898533074F, 0.9900486502F, 0.9902412587F, 0.9904311555F, - 0.9906183633F, 0.9908029045F, 0.9909848019F, 0.9911640779F, - 0.9913407550F, 0.9915148557F, 0.9916864025F, 0.9918554179F, - 0.9920219241F, 0.9921859437F, 0.9923474989F, 0.9925066120F, - 0.9926633054F, 0.9928176012F, 0.9929695218F, 0.9931190891F, - 0.9932663254F, 0.9934112527F, 0.9935538932F, 0.9936942686F, - 0.9938324012F, 0.9939683126F, 0.9941020248F, 0.9942335597F, - 0.9943629388F, 0.9944901841F, 0.9946153170F, 0.9947383593F, - 0.9948593325F, 0.9949782579F, 0.9950951572F, 0.9952100516F, - 0.9953229625F, 0.9954339111F, 0.9955429186F, 0.9956500062F, - 0.9957551948F, 0.9958585056F, 0.9959599593F, 0.9960595769F, - 0.9961573792F, 0.9962533869F, 0.9963476206F, 0.9964401009F, - 0.9965308483F, 0.9966198833F, 0.9967072261F, 0.9967928971F, - 0.9968769164F, 0.9969593041F, 0.9970400804F, 0.9971192651F, - 0.9971968781F, 0.9972729391F, 0.9973474680F, 0.9974204842F, - 0.9974920074F, 0.9975620569F, 0.9976306521F, 0.9976978122F, - 0.9977635565F, 0.9978279039F, 0.9978908736F, 0.9979524842F, - 0.9980127547F, 0.9980717037F, 0.9981293499F, 0.9981857116F, - 0.9982408073F, 0.9982946554F, 0.9983472739F, 0.9983986810F, - 0.9984488947F, 0.9984979328F, 0.9985458132F, 0.9985925534F, - 0.9986381711F, 0.9986826838F, 0.9987261086F, 0.9987684630F, - 0.9988097640F, 0.9988500286F, 0.9988892738F, 0.9989275163F, - 0.9989647727F, 0.9990010597F, 0.9990363938F, 0.9990707911F, - 0.9991042679F, 0.9991368404F, 0.9991685244F, 0.9991993358F, - 0.9992292905F, 0.9992584038F, 0.9992866914F, 0.9993141686F, - 0.9993408506F, 0.9993667526F, 0.9993918895F, 0.9994162761F, - 0.9994399273F, 0.9994628576F, 0.9994850815F, 0.9995066133F, - 0.9995274672F, 0.9995476574F, 0.9995671978F, 0.9995861021F, - 0.9996043841F, 0.9996220573F, 0.9996391352F, 0.9996556310F, - 0.9996715579F, 0.9996869288F, 0.9997017568F, 0.9997160543F, - 0.9997298342F, 0.9997431088F, 0.9997558905F, 0.9997681914F, - 0.9997800236F, 0.9997913990F, 0.9998023292F, 0.9998128261F, - 0.9998229009F, 0.9998325650F, 0.9998418296F, 0.9998507058F, - 0.9998592044F, 0.9998673362F, 0.9998751117F, 0.9998825415F, - 0.9998896358F, 0.9998964047F, 0.9999028584F, 0.9999090066F, - 0.9999148590F, 0.9999204253F, 0.9999257148F, 0.9999307368F, - 0.9999355003F, 0.9999400144F, 0.9999442878F, 0.9999483293F, - 0.9999521472F, 0.9999557499F, 0.9999591457F, 0.9999623426F, - 0.9999653483F, 0.9999681708F, 0.9999708175F, 0.9999732959F, - 0.9999756132F, 0.9999777765F, 0.9999797928F, 0.9999816688F, - 0.9999834113F, 0.9999850266F, 0.9999865211F, 0.9999879009F, - 0.9999891721F, 0.9999903405F, 0.9999914118F, 0.9999923914F, - 0.9999932849F, 0.9999940972F, 0.9999948336F, 0.9999954989F, - 0.9999960978F, 0.9999966349F, 0.9999971146F, 0.9999975411F, - 0.9999979185F, 0.9999982507F, 0.9999985414F, 0.9999987944F, - 0.9999990129F, 0.9999992003F, 0.9999993596F, 0.9999994939F, - 0.9999996059F, 0.9999996981F, 0.9999997732F, 0.9999998333F, - 0.9999998805F, 0.9999999170F, 0.9999999444F, 0.9999999643F, - 0.9999999784F, 0.9999999878F, 0.9999999937F, 0.9999999972F, - 0.9999999990F, 0.9999999997F, 1.0000000000F, 1.0000000000F, -}; - -static const float vwin4096[2048] = { - 0.0000002310F, 0.0000020791F, 0.0000057754F, 0.0000113197F, - 0.0000187121F, 0.0000279526F, 0.0000390412F, 0.0000519777F, - 0.0000667623F, 0.0000833949F, 0.0001018753F, 0.0001222036F, - 0.0001443798F, 0.0001684037F, 0.0001942754F, 0.0002219947F, - 0.0002515616F, 0.0002829761F, 0.0003162380F, 0.0003513472F, - 0.0003883038F, 0.0004271076F, 0.0004677584F, 0.0005102563F, - 0.0005546011F, 0.0006007928F, 0.0006488311F, 0.0006987160F, - 0.0007504474F, 0.0008040251F, 0.0008594490F, 0.0009167191F, - 0.0009758351F, 0.0010367969F, 0.0010996044F, 0.0011642574F, - 0.0012307558F, 0.0012990994F, 0.0013692880F, 0.0014413216F, - 0.0015151998F, 0.0015909226F, 0.0016684898F, 0.0017479011F, - 0.0018291565F, 0.0019122556F, 0.0019971983F, 0.0020839845F, - 0.0021726138F, 0.0022630861F, 0.0023554012F, 0.0024495588F, - 0.0025455588F, 0.0026434008F, 0.0027430847F, 0.0028446103F, - 0.0029479772F, 0.0030531853F, 0.0031602342F, 0.0032691238F, - 0.0033798538F, 0.0034924239F, 0.0036068338F, 0.0037230833F, - 0.0038411721F, 0.0039610999F, 0.0040828664F, 0.0042064714F, - 0.0043319145F, 0.0044591954F, 0.0045883139F, 0.0047192696F, - 0.0048520622F, 0.0049866914F, 0.0051231569F, 0.0052614583F, - 0.0054015953F, 0.0055435676F, 0.0056873748F, 0.0058330166F, - 0.0059804926F, 0.0061298026F, 0.0062809460F, 0.0064339226F, - 0.0065887320F, 0.0067453738F, 0.0069038476F, 0.0070641531F, - 0.0072262899F, 0.0073902575F, 0.0075560556F, 0.0077236838F, - 0.0078931417F, 0.0080644288F, 0.0082375447F, 0.0084124891F, - 0.0085892615F, 0.0087678614F, 0.0089482885F, 0.0091305422F, - 0.0093146223F, 0.0095005281F, 0.0096882592F, 0.0098778153F, - 0.0100691958F, 0.0102624002F, 0.0104574281F, 0.0106542791F, - 0.0108529525F, 0.0110534480F, 0.0112557651F, 0.0114599032F, - 0.0116658618F, 0.0118736405F, 0.0120832387F, 0.0122946560F, - 0.0125078917F, 0.0127229454F, 0.0129398166F, 0.0131585046F, - 0.0133790090F, 0.0136013292F, 0.0138254647F, 0.0140514149F, - 0.0142791792F, 0.0145087572F, 0.0147401481F, 0.0149733515F, - 0.0152083667F, 0.0154451932F, 0.0156838304F, 0.0159242777F, - 0.0161665345F, 0.0164106001F, 0.0166564741F, 0.0169041557F, - 0.0171536443F, 0.0174049393F, 0.0176580401F, 0.0179129461F, - 0.0181696565F, 0.0184281708F, 0.0186884883F, 0.0189506084F, - 0.0192145303F, 0.0194802535F, 0.0197477772F, 0.0200171008F, - 0.0202882236F, 0.0205611449F, 0.0208358639F, 0.0211123801F, - 0.0213906927F, 0.0216708011F, 0.0219527043F, 0.0222364019F, - 0.0225218930F, 0.0228091769F, 0.0230982529F, 0.0233891203F, - 0.0236817782F, 0.0239762259F, 0.0242724628F, 0.0245704880F, - 0.0248703007F, 0.0251719002F, 0.0254752858F, 0.0257804565F, - 0.0260874117F, 0.0263961506F, 0.0267066722F, 0.0270189760F, - 0.0273330609F, 0.0276489263F, 0.0279665712F, 0.0282859949F, - 0.0286071966F, 0.0289301753F, 0.0292549303F, 0.0295814607F, - 0.0299097656F, 0.0302398442F, 0.0305716957F, 0.0309053191F, - 0.0312407135F, 0.0315778782F, 0.0319168122F, 0.0322575145F, - 0.0325999844F, 0.0329442209F, 0.0332902231F, 0.0336379900F, - 0.0339875208F, 0.0343388146F, 0.0346918703F, 0.0350466871F, - 0.0354032640F, 0.0357616000F, 0.0361216943F, 0.0364835458F, - 0.0368471535F, 0.0372125166F, 0.0375796339F, 0.0379485046F, - 0.0383191276F, 0.0386915020F, 0.0390656267F, 0.0394415008F, - 0.0398191231F, 0.0401984927F, 0.0405796086F, 0.0409624698F, - 0.0413470751F, 0.0417334235F, 0.0421215141F, 0.0425113457F, - 0.0429029172F, 0.0432962277F, 0.0436912760F, 0.0440880610F, - 0.0444865817F, 0.0448868370F, 0.0452888257F, 0.0456925468F, - 0.0460979992F, 0.0465051816F, 0.0469140931F, 0.0473247325F, - 0.0477370986F, 0.0481511902F, 0.0485670064F, 0.0489845458F, - 0.0494038074F, 0.0498247899F, 0.0502474922F, 0.0506719131F, - 0.0510980514F, 0.0515259060F, 0.0519554756F, 0.0523867590F, - 0.0528197550F, 0.0532544624F, 0.0536908800F, 0.0541290066F, - 0.0545688408F, 0.0550103815F, 0.0554536274F, 0.0558985772F, - 0.0563452297F, 0.0567935837F, 0.0572436377F, 0.0576953907F, - 0.0581488412F, 0.0586039880F, 0.0590608297F, 0.0595193651F, - 0.0599795929F, 0.0604415117F, 0.0609051202F, 0.0613704170F, - 0.0618374009F, 0.0623060704F, 0.0627764243F, 0.0632484611F, - 0.0637221795F, 0.0641975781F, 0.0646746555F, 0.0651534104F, - 0.0656338413F, 0.0661159469F, 0.0665997257F, 0.0670851763F, - 0.0675722973F, 0.0680610873F, 0.0685515448F, 0.0690436684F, - 0.0695374567F, 0.0700329081F, 0.0705300213F, 0.0710287947F, - 0.0715292269F, 0.0720313163F, 0.0725350616F, 0.0730404612F, - 0.0735475136F, 0.0740562172F, 0.0745665707F, 0.0750785723F, - 0.0755922207F, 0.0761075143F, 0.0766244515F, 0.0771430307F, - 0.0776632505F, 0.0781851092F, 0.0787086052F, 0.0792337371F, - 0.0797605032F, 0.0802889018F, 0.0808189315F, 0.0813505905F, - 0.0818838773F, 0.0824187903F, 0.0829553277F, 0.0834934881F, - 0.0840332697F, 0.0845746708F, 0.0851176899F, 0.0856623252F, - 0.0862085751F, 0.0867564379F, 0.0873059119F, 0.0878569954F, - 0.0884096867F, 0.0889639840F, 0.0895198858F, 0.0900773902F, - 0.0906364955F, 0.0911972000F, 0.0917595019F, 0.0923233995F, - 0.0928888909F, 0.0934559745F, 0.0940246485F, 0.0945949110F, - 0.0951667604F, 0.0957401946F, 0.0963152121F, 0.0968918109F, - 0.0974699893F, 0.0980497454F, 0.0986310773F, 0.0992139832F, - 0.0997984614F, 0.1003845098F, 0.1009721267F, 0.1015613101F, - 0.1021520582F, 0.1027443692F, 0.1033382410F, 0.1039336718F, - 0.1045306597F, 0.1051292027F, 0.1057292990F, 0.1063309466F, - 0.1069341435F, 0.1075388878F, 0.1081451776F, 0.1087530108F, - 0.1093623856F, 0.1099732998F, 0.1105857516F, 0.1111997389F, - 0.1118152597F, 0.1124323121F, 0.1130508939F, 0.1136710032F, - 0.1142926379F, 0.1149157960F, 0.1155404755F, 0.1161666742F, - 0.1167943901F, 0.1174236211F, 0.1180543652F, 0.1186866202F, - 0.1193203841F, 0.1199556548F, 0.1205924300F, 0.1212307078F, - 0.1218704860F, 0.1225117624F, 0.1231545349F, 0.1237988013F, - 0.1244445596F, 0.1250918074F, 0.1257405427F, 0.1263907632F, - 0.1270424667F, 0.1276956512F, 0.1283503142F, 0.1290064537F, - 0.1296640674F, 0.1303231530F, 0.1309837084F, 0.1316457312F, - 0.1323092193F, 0.1329741703F, 0.1336405820F, 0.1343084520F, - 0.1349777782F, 0.1356485582F, 0.1363207897F, 0.1369944704F, - 0.1376695979F, 0.1383461700F, 0.1390241842F, 0.1397036384F, - 0.1403845300F, 0.1410668567F, 0.1417506162F, 0.1424358061F, - 0.1431224240F, 0.1438104674F, 0.1444999341F, 0.1451908216F, - 0.1458831274F, 0.1465768492F, 0.1472719844F, 0.1479685308F, - 0.1486664857F, 0.1493658468F, 0.1500666115F, 0.1507687775F, - 0.1514723422F, 0.1521773031F, 0.1528836577F, 0.1535914035F, - 0.1543005380F, 0.1550110587F, 0.1557229631F, 0.1564362485F, - 0.1571509124F, 0.1578669524F, 0.1585843657F, 0.1593031499F, - 0.1600233024F, 0.1607448205F, 0.1614677017F, 0.1621919433F, - 0.1629175428F, 0.1636444975F, 0.1643728047F, 0.1651024619F, - 0.1658334665F, 0.1665658156F, 0.1672995067F, 0.1680345371F, - 0.1687709041F, 0.1695086050F, 0.1702476372F, 0.1709879978F, - 0.1717296843F, 0.1724726938F, 0.1732170237F, 0.1739626711F, - 0.1747096335F, 0.1754579079F, 0.1762074916F, 0.1769583819F, - 0.1777105760F, 0.1784640710F, 0.1792188642F, 0.1799749529F, - 0.1807323340F, 0.1814910049F, 0.1822509628F, 0.1830122046F, - 0.1837747277F, 0.1845385292F, 0.1853036062F, 0.1860699558F, - 0.1868375751F, 0.1876064613F, 0.1883766114F, 0.1891480226F, - 0.1899206919F, 0.1906946164F, 0.1914697932F, 0.1922462194F, - 0.1930238919F, 0.1938028079F, 0.1945829643F, 0.1953643583F, - 0.1961469868F, 0.1969308468F, 0.1977159353F, 0.1985022494F, - 0.1992897859F, 0.2000785420F, 0.2008685145F, 0.2016597005F, - 0.2024520968F, 0.2032457005F, 0.2040405084F, 0.2048365175F, - 0.2056337247F, 0.2064321269F, 0.2072317211F, 0.2080325041F, - 0.2088344727F, 0.2096376240F, 0.2104419547F, 0.2112474618F, - 0.2120541420F, 0.2128619923F, 0.2136710094F, 0.2144811902F, - 0.2152925315F, 0.2161050301F, 0.2169186829F, 0.2177334866F, - 0.2185494381F, 0.2193665340F, 0.2201847712F, 0.2210041465F, - 0.2218246565F, 0.2226462981F, 0.2234690680F, 0.2242929629F, - 0.2251179796F, 0.2259441147F, 0.2267713650F, 0.2275997272F, - 0.2284291979F, 0.2292597739F, 0.2300914518F, 0.2309242283F, - 0.2317581001F, 0.2325930638F, 0.2334291160F, 0.2342662534F, - 0.2351044727F, 0.2359437703F, 0.2367841431F, 0.2376255875F, - 0.2384681001F, 0.2393116776F, 0.2401563165F, 0.2410020134F, - 0.2418487649F, 0.2426965675F, 0.2435454178F, 0.2443953122F, - 0.2452462474F, 0.2460982199F, 0.2469512262F, 0.2478052628F, - 0.2486603262F, 0.2495164129F, 0.2503735194F, 0.2512316421F, - 0.2520907776F, 0.2529509222F, 0.2538120726F, 0.2546742250F, - 0.2555373760F, 0.2564015219F, 0.2572666593F, 0.2581327845F, - 0.2589998939F, 0.2598679840F, 0.2607370510F, 0.2616070916F, - 0.2624781019F, 0.2633500783F, 0.2642230173F, 0.2650969152F, - 0.2659717684F, 0.2668475731F, 0.2677243257F, 0.2686020226F, - 0.2694806601F, 0.2703602344F, 0.2712407419F, 0.2721221789F, - 0.2730045417F, 0.2738878265F, 0.2747720297F, 0.2756571474F, - 0.2765431760F, 0.2774301117F, 0.2783179508F, 0.2792066895F, - 0.2800963240F, 0.2809868505F, 0.2818782654F, 0.2827705647F, - 0.2836637447F, 0.2845578016F, 0.2854527315F, 0.2863485307F, - 0.2872451953F, 0.2881427215F, 0.2890411055F, 0.2899403433F, - 0.2908404312F, 0.2917413654F, 0.2926431418F, 0.2935457567F, - 0.2944492061F, 0.2953534863F, 0.2962585932F, 0.2971645230F, - 0.2980712717F, 0.2989788356F, 0.2998872105F, 0.3007963927F, - 0.3017063781F, 0.3026171629F, 0.3035287430F, 0.3044411145F, - 0.3053542736F, 0.3062682161F, 0.3071829381F, 0.3080984356F, - 0.3090147047F, 0.3099317413F, 0.3108495414F, 0.3117681011F, - 0.3126874163F, 0.3136074830F, 0.3145282972F, 0.3154498548F, - 0.3163721517F, 0.3172951841F, 0.3182189477F, 0.3191434385F, - 0.3200686525F, 0.3209945856F, 0.3219212336F, 0.3228485927F, - 0.3237766585F, 0.3247054271F, 0.3256348943F, 0.3265650560F, - 0.3274959081F, 0.3284274465F, 0.3293596671F, 0.3302925657F, - 0.3312261382F, 0.3321603804F, 0.3330952882F, 0.3340308574F, - 0.3349670838F, 0.3359039634F, 0.3368414919F, 0.3377796651F, - 0.3387184789F, 0.3396579290F, 0.3405980113F, 0.3415387216F, - 0.3424800556F, 0.3434220091F, 0.3443645779F, 0.3453077578F, - 0.3462515446F, 0.3471959340F, 0.3481409217F, 0.3490865036F, - 0.3500326754F, 0.3509794328F, 0.3519267715F, 0.3528746873F, - 0.3538231759F, 0.3547722330F, 0.3557218544F, 0.3566720357F, - 0.3576227727F, 0.3585740610F, 0.3595258964F, 0.3604782745F, - 0.3614311910F, 0.3623846417F, 0.3633386221F, 0.3642931280F, - 0.3652481549F, 0.3662036987F, 0.3671597548F, 0.3681163191F, - 0.3690733870F, 0.3700309544F, 0.3709890167F, 0.3719475696F, - 0.3729066089F, 0.3738661299F, 0.3748261285F, 0.3757866002F, - 0.3767475406F, 0.3777089453F, 0.3786708100F, 0.3796331302F, - 0.3805959014F, 0.3815591194F, 0.3825227796F, 0.3834868777F, - 0.3844514093F, 0.3854163698F, 0.3863817549F, 0.3873475601F, - 0.3883137810F, 0.3892804131F, 0.3902474521F, 0.3912148933F, - 0.3921827325F, 0.3931509650F, 0.3941195865F, 0.3950885925F, - 0.3960579785F, 0.3970277400F, 0.3979978725F, 0.3989683716F, - 0.3999392328F, 0.4009104516F, 0.4018820234F, 0.4028539438F, - 0.4038262084F, 0.4047988125F, 0.4057717516F, 0.4067450214F, - 0.4077186172F, 0.4086925345F, 0.4096667688F, 0.4106413155F, - 0.4116161703F, 0.4125913284F, 0.4135667854F, 0.4145425368F, - 0.4155185780F, 0.4164949044F, 0.4174715116F, 0.4184483949F, - 0.4194255498F, 0.4204029718F, 0.4213806563F, 0.4223585987F, - 0.4233367946F, 0.4243152392F, 0.4252939281F, 0.4262728566F, - 0.4272520202F, 0.4282314144F, 0.4292110345F, 0.4301908760F, - 0.4311709343F, 0.4321512047F, 0.4331316828F, 0.4341123639F, - 0.4350932435F, 0.4360743168F, 0.4370555794F, 0.4380370267F, - 0.4390186540F, 0.4400004567F, 0.4409824303F, 0.4419645701F, - 0.4429468716F, 0.4439293300F, 0.4449119409F, 0.4458946996F, - 0.4468776014F, 0.4478606418F, 0.4488438162F, 0.4498271199F, - 0.4508105483F, 0.4517940967F, 0.4527777607F, 0.4537615355F, - 0.4547454165F, 0.4557293991F, 0.4567134786F, 0.4576976505F, - 0.4586819101F, 0.4596662527F, 0.4606506738F, 0.4616351687F, - 0.4626197328F, 0.4636043614F, 0.4645890499F, 0.4655737936F, - 0.4665585880F, 0.4675434284F, 0.4685283101F, 0.4695132286F, - 0.4704981791F, 0.4714831570F, 0.4724681577F, 0.4734531766F, - 0.4744382089F, 0.4754232501F, 0.4764082956F, 0.4773933406F, - 0.4783783806F, 0.4793634108F, 0.4803484267F, 0.4813334237F, - 0.4823183969F, 0.4833033419F, 0.4842882540F, 0.4852731285F, - 0.4862579608F, 0.4872427462F, 0.4882274802F, 0.4892121580F, - 0.4901967751F, 0.4911813267F, 0.4921658083F, 0.4931502151F, - 0.4941345427F, 0.4951187863F, 0.4961029412F, 0.4970870029F, - 0.4980709667F, 0.4990548280F, 0.5000385822F, 0.5010222245F, - 0.5020057505F, 0.5029891553F, 0.5039724345F, 0.5049555834F, - 0.5059385973F, 0.5069214716F, 0.5079042018F, 0.5088867831F, - 0.5098692110F, 0.5108514808F, 0.5118335879F, 0.5128155277F, - 0.5137972956F, 0.5147788869F, 0.5157602971F, 0.5167415215F, - 0.5177225555F, 0.5187033945F, 0.5196840339F, 0.5206644692F, - 0.5216446956F, 0.5226247086F, 0.5236045035F, 0.5245840759F, - 0.5255634211F, 0.5265425344F, 0.5275214114F, 0.5285000474F, - 0.5294784378F, 0.5304565781F, 0.5314344637F, 0.5324120899F, - 0.5333894522F, 0.5343665461F, 0.5353433670F, 0.5363199102F, - 0.5372961713F, 0.5382721457F, 0.5392478287F, 0.5402232159F, - 0.5411983027F, 0.5421730845F, 0.5431475569F, 0.5441217151F, - 0.5450955548F, 0.5460690714F, 0.5470422602F, 0.5480151169F, - 0.5489876368F, 0.5499598155F, 0.5509316484F, 0.5519031310F, - 0.5528742587F, 0.5538450271F, 0.5548154317F, 0.5557854680F, - 0.5567551314F, 0.5577244174F, 0.5586933216F, 0.5596618395F, - 0.5606299665F, 0.5615976983F, 0.5625650302F, 0.5635319580F, - 0.5644984770F, 0.5654645828F, 0.5664302709F, 0.5673955370F, - 0.5683603765F, 0.5693247850F, 0.5702887580F, 0.5712522912F, - 0.5722153800F, 0.5731780200F, 0.5741402069F, 0.5751019362F, - 0.5760632034F, 0.5770240042F, 0.5779843341F, 0.5789441889F, - 0.5799035639F, 0.5808624549F, 0.5818208575F, 0.5827787673F, - 0.5837361800F, 0.5846930910F, 0.5856494961F, 0.5866053910F, - 0.5875607712F, 0.5885156324F, 0.5894699703F, 0.5904237804F, - 0.5913770586F, 0.5923298004F, 0.5932820016F, 0.5942336578F, - 0.5951847646F, 0.5961353179F, 0.5970853132F, 0.5980347464F, - 0.5989836131F, 0.5999319090F, 0.6008796298F, 0.6018267713F, - 0.6027733292F, 0.6037192993F, 0.6046646773F, 0.6056094589F, - 0.6065536400F, 0.6074972162F, 0.6084401833F, 0.6093825372F, - 0.6103242736F, 0.6112653884F, 0.6122058772F, 0.6131457359F, - 0.6140849604F, 0.6150235464F, 0.6159614897F, 0.6168987862F, - 0.6178354318F, 0.6187714223F, 0.6197067535F, 0.6206414213F, - 0.6215754215F, 0.6225087501F, 0.6234414028F, 0.6243733757F, - 0.6253046646F, 0.6262352654F, 0.6271651739F, 0.6280943862F, - 0.6290228982F, 0.6299507057F, 0.6308778048F, 0.6318041913F, - 0.6327298612F, 0.6336548105F, 0.6345790352F, 0.6355025312F, - 0.6364252945F, 0.6373473211F, 0.6382686070F, 0.6391891483F, - 0.6401089409F, 0.6410279808F, 0.6419462642F, 0.6428637869F, - 0.6437805452F, 0.6446965350F, 0.6456117524F, 0.6465261935F, - 0.6474398544F, 0.6483527311F, 0.6492648197F, 0.6501761165F, - 0.6510866174F, 0.6519963186F, 0.6529052162F, 0.6538133064F, - 0.6547205854F, 0.6556270492F, 0.6565326941F, 0.6574375162F, - 0.6583415117F, 0.6592446769F, 0.6601470079F, 0.6610485009F, - 0.6619491521F, 0.6628489578F, 0.6637479143F, 0.6646460177F, - 0.6655432643F, 0.6664396505F, 0.6673351724F, 0.6682298264F, - 0.6691236087F, 0.6700165157F, 0.6709085436F, 0.6717996889F, - 0.6726899478F, 0.6735793167F, 0.6744677918F, 0.6753553697F, - 0.6762420466F, 0.6771278190F, 0.6780126832F, 0.6788966357F, - 0.6797796728F, 0.6806617909F, 0.6815429866F, 0.6824232562F, - 0.6833025961F, 0.6841810030F, 0.6850584731F, 0.6859350031F, - 0.6868105894F, 0.6876852284F, 0.6885589168F, 0.6894316510F, - 0.6903034275F, 0.6911742430F, 0.6920440939F, 0.6929129769F, - 0.6937808884F, 0.6946478251F, 0.6955137837F, 0.6963787606F, - 0.6972427525F, 0.6981057560F, 0.6989677678F, 0.6998287845F, - 0.7006888028F, 0.7015478194F, 0.7024058309F, 0.7032628340F, - 0.7041188254F, 0.7049738019F, 0.7058277601F, 0.7066806969F, - 0.7075326089F, 0.7083834929F, 0.7092333457F, 0.7100821640F, - 0.7109299447F, 0.7117766846F, 0.7126223804F, 0.7134670291F, - 0.7143106273F, 0.7151531721F, 0.7159946602F, 0.7168350885F, - 0.7176744539F, 0.7185127534F, 0.7193499837F, 0.7201861418F, - 0.7210212247F, 0.7218552293F, 0.7226881526F, 0.7235199914F, - 0.7243507428F, 0.7251804039F, 0.7260089715F, 0.7268364426F, - 0.7276628144F, 0.7284880839F, 0.7293122481F, 0.7301353040F, - 0.7309572487F, 0.7317780794F, 0.7325977930F, 0.7334163868F, - 0.7342338579F, 0.7350502033F, 0.7358654202F, 0.7366795059F, - 0.7374924573F, 0.7383042718F, 0.7391149465F, 0.7399244787F, - 0.7407328655F, 0.7415401041F, 0.7423461920F, 0.7431511261F, - 0.7439549040F, 0.7447575227F, 0.7455589797F, 0.7463592723F, - 0.7471583976F, 0.7479563532F, 0.7487531363F, 0.7495487443F, - 0.7503431745F, 0.7511364244F, 0.7519284913F, 0.7527193726F, - 0.7535090658F, 0.7542975683F, 0.7550848776F, 0.7558709910F, - 0.7566559062F, 0.7574396205F, 0.7582221314F, 0.7590034366F, - 0.7597835334F, 0.7605624194F, 0.7613400923F, 0.7621165495F, - 0.7628917886F, 0.7636658072F, 0.7644386030F, 0.7652101735F, - 0.7659805164F, 0.7667496292F, 0.7675175098F, 0.7682841556F, - 0.7690495645F, 0.7698137341F, 0.7705766622F, 0.7713383463F, - 0.7720987844F, 0.7728579741F, 0.7736159132F, 0.7743725994F, - 0.7751280306F, 0.7758822046F, 0.7766351192F, 0.7773867722F, - 0.7781371614F, 0.7788862848F, 0.7796341401F, 0.7803807253F, - 0.7811260383F, 0.7818700769F, 0.7826128392F, 0.7833543230F, - 0.7840945263F, 0.7848334471F, 0.7855710833F, 0.7863074330F, - 0.7870424941F, 0.7877762647F, 0.7885087428F, 0.7892399264F, - 0.7899698137F, 0.7906984026F, 0.7914256914F, 0.7921516780F, - 0.7928763607F, 0.7935997375F, 0.7943218065F, 0.7950425661F, - 0.7957620142F, 0.7964801492F, 0.7971969692F, 0.7979124724F, - 0.7986266570F, 0.7993395214F, 0.8000510638F, 0.8007612823F, - 0.8014701754F, 0.8021777413F, 0.8028839784F, 0.8035888849F, - 0.8042924592F, 0.8049946997F, 0.8056956048F, 0.8063951727F, - 0.8070934020F, 0.8077902910F, 0.8084858381F, 0.8091800419F, - 0.8098729007F, 0.8105644130F, 0.8112545774F, 0.8119433922F, - 0.8126308561F, 0.8133169676F, 0.8140017251F, 0.8146851272F, - 0.8153671726F, 0.8160478598F, 0.8167271874F, 0.8174051539F, - 0.8180817582F, 0.8187569986F, 0.8194308741F, 0.8201033831F, - 0.8207745244F, 0.8214442966F, 0.8221126986F, 0.8227797290F, - 0.8234453865F, 0.8241096700F, 0.8247725781F, 0.8254341097F, - 0.8260942636F, 0.8267530385F, 0.8274104334F, 0.8280664470F, - 0.8287210782F, 0.8293743259F, 0.8300261889F, 0.8306766662F, - 0.8313257566F, 0.8319734591F, 0.8326197727F, 0.8332646963F, - 0.8339082288F, 0.8345503692F, 0.8351911167F, 0.8358304700F, - 0.8364684284F, 0.8371049907F, 0.8377401562F, 0.8383739238F, - 0.8390062927F, 0.8396372618F, 0.8402668305F, 0.8408949977F, - 0.8415217626F, 0.8421471245F, 0.8427710823F, 0.8433936354F, - 0.8440147830F, 0.8446345242F, 0.8452528582F, 0.8458697844F, - 0.8464853020F, 0.8470994102F, 0.8477121084F, 0.8483233958F, - 0.8489332718F, 0.8495417356F, 0.8501487866F, 0.8507544243F, - 0.8513586479F, 0.8519614568F, 0.8525628505F, 0.8531628283F, - 0.8537613897F, 0.8543585341F, 0.8549542611F, 0.8555485699F, - 0.8561414603F, 0.8567329315F, 0.8573229832F, 0.8579116149F, - 0.8584988262F, 0.8590846165F, 0.8596689855F, 0.8602519327F, - 0.8608334577F, 0.8614135603F, 0.8619922399F, 0.8625694962F, - 0.8631453289F, 0.8637197377F, 0.8642927222F, 0.8648642821F, - 0.8654344172F, 0.8660031272F, 0.8665704118F, 0.8671362708F, - 0.8677007039F, 0.8682637109F, 0.8688252917F, 0.8693854460F, - 0.8699441737F, 0.8705014745F, 0.8710573485F, 0.8716117953F, - 0.8721648150F, 0.8727164073F, 0.8732665723F, 0.8738153098F, - 0.8743626197F, 0.8749085021F, 0.8754529569F, 0.8759959840F, - 0.8765375835F, 0.8770777553F, 0.8776164996F, 0.8781538162F, - 0.8786897054F, 0.8792241670F, 0.8797572013F, 0.8802888082F, - 0.8808189880F, 0.8813477407F, 0.8818750664F, 0.8824009653F, - 0.8829254375F, 0.8834484833F, 0.8839701028F, 0.8844902961F, - 0.8850090636F, 0.8855264054F, 0.8860423218F, 0.8865568131F, - 0.8870698794F, 0.8875815212F, 0.8880917386F, 0.8886005319F, - 0.8891079016F, 0.8896138479F, 0.8901183712F, 0.8906214719F, - 0.8911231503F, 0.8916234067F, 0.8921222417F, 0.8926196556F, - 0.8931156489F, 0.8936102219F, 0.8941033752F, 0.8945951092F, - 0.8950854244F, 0.8955743212F, 0.8960618003F, 0.8965478621F, - 0.8970325071F, 0.8975157359F, 0.8979975490F, 0.8984779471F, - 0.8989569307F, 0.8994345004F, 0.8999106568F, 0.9003854005F, - 0.9008587323F, 0.9013306526F, 0.9018011623F, 0.9022702619F, - 0.9027379521F, 0.9032042337F, 0.9036691074F, 0.9041325739F, - 0.9045946339F, 0.9050552882F, 0.9055145376F, 0.9059723828F, - 0.9064288246F, 0.9068838638F, 0.9073375013F, 0.9077897379F, - 0.9082405743F, 0.9086900115F, 0.9091380503F, 0.9095846917F, - 0.9100299364F, 0.9104737854F, 0.9109162397F, 0.9113573001F, - 0.9117969675F, 0.9122352430F, 0.9126721275F, 0.9131076219F, - 0.9135417273F, 0.9139744447F, 0.9144057750F, 0.9148357194F, - 0.9152642787F, 0.9156914542F, 0.9161172468F, 0.9165416576F, - 0.9169646877F, 0.9173863382F, 0.9178066102F, 0.9182255048F, - 0.9186430232F, 0.9190591665F, 0.9194739359F, 0.9198873324F, - 0.9202993574F, 0.9207100120F, 0.9211192973F, 0.9215272147F, - 0.9219337653F, 0.9223389504F, 0.9227427713F, 0.9231452290F, - 0.9235463251F, 0.9239460607F, 0.9243444371F, 0.9247414557F, - 0.9251371177F, 0.9255314245F, 0.9259243774F, 0.9263159778F, - 0.9267062270F, 0.9270951264F, 0.9274826774F, 0.9278688814F, - 0.9282537398F, 0.9286372540F, 0.9290194254F, 0.9294002555F, - 0.9297797458F, 0.9301578976F, 0.9305347125F, 0.9309101919F, - 0.9312843373F, 0.9316571503F, 0.9320286323F, 0.9323987849F, - 0.9327676097F, 0.9331351080F, 0.9335012816F, 0.9338661320F, - 0.9342296607F, 0.9345918694F, 0.9349527596F, 0.9353123330F, - 0.9356705911F, 0.9360275357F, 0.9363831683F, 0.9367374905F, - 0.9370905042F, 0.9374422108F, 0.9377926122F, 0.9381417099F, - 0.9384895057F, 0.9388360014F, 0.9391811985F, 0.9395250989F, - 0.9398677043F, 0.9402090165F, 0.9405490371F, 0.9408877680F, - 0.9412252110F, 0.9415613678F, 0.9418962402F, 0.9422298301F, - 0.9425621392F, 0.9428931695F, 0.9432229226F, 0.9435514005F, - 0.9438786050F, 0.9442045381F, 0.9445292014F, 0.9448525971F, - 0.9451747268F, 0.9454955926F, 0.9458151963F, 0.9461335399F, - 0.9464506253F, 0.9467664545F, 0.9470810293F, 0.9473943517F, - 0.9477064238F, 0.9480172474F, 0.9483268246F, 0.9486351573F, - 0.9489422475F, 0.9492480973F, 0.9495527087F, 0.9498560837F, - 0.9501582243F, 0.9504591325F, 0.9507588105F, 0.9510572603F, - 0.9513544839F, 0.9516504834F, 0.9519452609F, 0.9522388186F, - 0.9525311584F, 0.9528222826F, 0.9531121932F, 0.9534008923F, - 0.9536883821F, 0.9539746647F, 0.9542597424F, 0.9545436171F, - 0.9548262912F, 0.9551077667F, 0.9553880459F, 0.9556671309F, - 0.9559450239F, 0.9562217272F, 0.9564972429F, 0.9567715733F, - 0.9570447206F, 0.9573166871F, 0.9575874749F, 0.9578570863F, - 0.9581255236F, 0.9583927890F, 0.9586588849F, 0.9589238134F, - 0.9591875769F, 0.9594501777F, 0.9597116180F, 0.9599719003F, - 0.9602310267F, 0.9604889995F, 0.9607458213F, 0.9610014942F, - 0.9612560206F, 0.9615094028F, 0.9617616433F, 0.9620127443F, - 0.9622627083F, 0.9625115376F, 0.9627592345F, 0.9630058016F, - 0.9632512411F, 0.9634955555F, 0.9637387471F, 0.9639808185F, - 0.9642217720F, 0.9644616100F, 0.9647003349F, 0.9649379493F, - 0.9651744556F, 0.9654098561F, 0.9656441534F, 0.9658773499F, - 0.9661094480F, 0.9663404504F, 0.9665703593F, 0.9667991774F, - 0.9670269071F, 0.9672535509F, 0.9674791114F, 0.9677035909F, - 0.9679269921F, 0.9681493174F, 0.9683705694F, 0.9685907506F, - 0.9688098636F, 0.9690279108F, 0.9692448948F, 0.9694608182F, - 0.9696756836F, 0.9698894934F, 0.9701022503F, 0.9703139569F, - 0.9705246156F, 0.9707342291F, 0.9709428000F, 0.9711503309F, - 0.9713568243F, 0.9715622829F, 0.9717667093F, 0.9719701060F, - 0.9721724757F, 0.9723738210F, 0.9725741446F, 0.9727734490F, - 0.9729717369F, 0.9731690109F, 0.9733652737F, 0.9735605279F, - 0.9737547762F, 0.9739480212F, 0.9741402656F, 0.9743315120F, - 0.9745217631F, 0.9747110216F, 0.9748992901F, 0.9750865714F, - 0.9752728681F, 0.9754581829F, 0.9756425184F, 0.9758258775F, - 0.9760082627F, 0.9761896768F, 0.9763701224F, 0.9765496024F, - 0.9767281193F, 0.9769056760F, 0.9770822751F, 0.9772579193F, - 0.9774326114F, 0.9776063542F, 0.9777791502F, 0.9779510023F, - 0.9781219133F, 0.9782918858F, 0.9784609226F, 0.9786290264F, - 0.9787962000F, 0.9789624461F, 0.9791277676F, 0.9792921671F, - 0.9794556474F, 0.9796182113F, 0.9797798615F, 0.9799406009F, - 0.9801004321F, 0.9802593580F, 0.9804173813F, 0.9805745049F, - 0.9807307314F, 0.9808860637F, 0.9810405046F, 0.9811940568F, - 0.9813467232F, 0.9814985065F, 0.9816494095F, 0.9817994351F, - 0.9819485860F, 0.9820968650F, 0.9822442750F, 0.9823908186F, - 0.9825364988F, 0.9826813184F, 0.9828252801F, 0.9829683868F, - 0.9831106413F, 0.9832520463F, 0.9833926048F, 0.9835323195F, - 0.9836711932F, 0.9838092288F, 0.9839464291F, 0.9840827969F, - 0.9842183351F, 0.9843530464F, 0.9844869337F, 0.9846199998F, - 0.9847522475F, 0.9848836798F, 0.9850142993F, 0.9851441090F, - 0.9852731117F, 0.9854013101F, 0.9855287073F, 0.9856553058F, - 0.9857811087F, 0.9859061188F, 0.9860303388F, 0.9861537717F, - 0.9862764202F, 0.9863982872F, 0.9865193756F, 0.9866396882F, - 0.9867592277F, 0.9868779972F, 0.9869959993F, 0.9871132370F, - 0.9872297131F, 0.9873454304F, 0.9874603918F, 0.9875746001F, - 0.9876880581F, 0.9878007688F, 0.9879127348F, 0.9880239592F, - 0.9881344447F, 0.9882441941F, 0.9883532104F, 0.9884614962F, - 0.9885690546F, 0.9886758883F, 0.9887820001F, 0.9888873930F, - 0.9889920697F, 0.9890960331F, 0.9891992859F, 0.9893018312F, - 0.9894036716F, 0.9895048100F, 0.9896052493F, 0.9897049923F, - 0.9898040418F, 0.9899024006F, 0.9900000717F, 0.9900970577F, - 0.9901933616F, 0.9902889862F, 0.9903839343F, 0.9904782087F, - 0.9905718122F, 0.9906647477F, 0.9907570180F, 0.9908486259F, - 0.9909395742F, 0.9910298658F, 0.9911195034F, 0.9912084899F, - 0.9912968281F, 0.9913845208F, 0.9914715708F, 0.9915579810F, - 0.9916437540F, 0.9917288928F, 0.9918134001F, 0.9918972788F, - 0.9919805316F, 0.9920631613F, 0.9921451707F, 0.9922265626F, - 0.9923073399F, 0.9923875052F, 0.9924670615F, 0.9925460114F, - 0.9926243577F, 0.9927021033F, 0.9927792508F, 0.9928558032F, - 0.9929317631F, 0.9930071333F, 0.9930819167F, 0.9931561158F, - 0.9932297337F, 0.9933027728F, 0.9933752362F, 0.9934471264F, - 0.9935184462F, 0.9935891985F, 0.9936593859F, 0.9937290112F, - 0.9937980771F, 0.9938665864F, 0.9939345418F, 0.9940019460F, - 0.9940688018F, 0.9941351118F, 0.9942008789F, 0.9942661057F, - 0.9943307950F, 0.9943949494F, 0.9944585717F, 0.9945216645F, - 0.9945842307F, 0.9946462728F, 0.9947077936F, 0.9947687957F, - 0.9948292820F, 0.9948892550F, 0.9949487174F, 0.9950076719F, - 0.9950661212F, 0.9951240679F, 0.9951815148F, 0.9952384645F, - 0.9952949196F, 0.9953508828F, 0.9954063568F, 0.9954613442F, - 0.9955158476F, 0.9955698697F, 0.9956234132F, 0.9956764806F, - 0.9957290746F, 0.9957811978F, 0.9958328528F, 0.9958840423F, - 0.9959347688F, 0.9959850351F, 0.9960348435F, 0.9960841969F, - 0.9961330977F, 0.9961815486F, 0.9962295521F, 0.9962771108F, - 0.9963242274F, 0.9963709043F, 0.9964171441F, 0.9964629494F, - 0.9965083228F, 0.9965532668F, 0.9965977840F, 0.9966418768F, - 0.9966855479F, 0.9967287998F, 0.9967716350F, 0.9968140559F, - 0.9968560653F, 0.9968976655F, 0.9969388591F, 0.9969796485F, - 0.9970200363F, 0.9970600250F, 0.9970996170F, 0.9971388149F, - 0.9971776211F, 0.9972160380F, 0.9972540683F, 0.9972917142F, - 0.9973289783F, 0.9973658631F, 0.9974023709F, 0.9974385042F, - 0.9974742655F, 0.9975096571F, 0.9975446816F, 0.9975793413F, - 0.9976136386F, 0.9976475759F, 0.9976811557F, 0.9977143803F, - 0.9977472521F, 0.9977797736F, 0.9978119470F, 0.9978437748F, - 0.9978752593F, 0.9979064029F, 0.9979372079F, 0.9979676768F, - 0.9979978117F, 0.9980276151F, 0.9980570893F, 0.9980862367F, - 0.9981150595F, 0.9981435600F, 0.9981717406F, 0.9981996035F, - 0.9982271511F, 0.9982543856F, 0.9982813093F, 0.9983079246F, - 0.9983342336F, 0.9983602386F, 0.9983859418F, 0.9984113456F, - 0.9984364522F, 0.9984612638F, 0.9984857825F, 0.9985100108F, - 0.9985339507F, 0.9985576044F, 0.9985809743F, 0.9986040624F, - 0.9986268710F, 0.9986494022F, 0.9986716583F, 0.9986936413F, - 0.9987153535F, 0.9987367969F, 0.9987579738F, 0.9987788864F, - 0.9987995366F, 0.9988199267F, 0.9988400587F, 0.9988599348F, - 0.9988795572F, 0.9988989278F, 0.9989180487F, 0.9989369222F, - 0.9989555501F, 0.9989739347F, 0.9989920780F, 0.9990099820F, - 0.9990276487F, 0.9990450803F, 0.9990622787F, 0.9990792460F, - 0.9990959841F, 0.9991124952F, 0.9991287812F, 0.9991448440F, - 0.9991606858F, 0.9991763084F, 0.9991917139F, 0.9992069042F, - 0.9992218813F, 0.9992366471F, 0.9992512035F, 0.9992655525F, - 0.9992796961F, 0.9992936361F, 0.9993073744F, 0.9993209131F, - 0.9993342538F, 0.9993473987F, 0.9993603494F, 0.9993731080F, - 0.9993856762F, 0.9993980559F, 0.9994102490F, 0.9994222573F, - 0.9994340827F, 0.9994457269F, 0.9994571918F, 0.9994684793F, - 0.9994795910F, 0.9994905288F, 0.9995012945F, 0.9995118898F, - 0.9995223165F, 0.9995325765F, 0.9995426713F, 0.9995526029F, - 0.9995623728F, 0.9995719829F, 0.9995814349F, 0.9995907304F, - 0.9995998712F, 0.9996088590F, 0.9996176954F, 0.9996263821F, - 0.9996349208F, 0.9996433132F, 0.9996515609F, 0.9996596656F, - 0.9996676288F, 0.9996754522F, 0.9996831375F, 0.9996906862F, - 0.9996981000F, 0.9997053804F, 0.9997125290F, 0.9997195474F, - 0.9997264371F, 0.9997331998F, 0.9997398369F, 0.9997463500F, - 0.9997527406F, 0.9997590103F, 0.9997651606F, 0.9997711930F, - 0.9997771089F, 0.9997829098F, 0.9997885973F, 0.9997941728F, - 0.9997996378F, 0.9998049936F, 0.9998102419F, 0.9998153839F, - 0.9998204211F, 0.9998253550F, 0.9998301868F, 0.9998349182F, - 0.9998395503F, 0.9998440847F, 0.9998485226F, 0.9998528654F, - 0.9998571146F, 0.9998612713F, 0.9998653370F, 0.9998693130F, - 0.9998732007F, 0.9998770012F, 0.9998807159F, 0.9998843461F, - 0.9998878931F, 0.9998913581F, 0.9998947424F, 0.9998980473F, - 0.9999012740F, 0.9999044237F, 0.9999074976F, 0.9999104971F, - 0.9999134231F, 0.9999162771F, 0.9999190601F, 0.9999217733F, - 0.9999244179F, 0.9999269950F, 0.9999295058F, 0.9999319515F, - 0.9999343332F, 0.9999366519F, 0.9999389088F, 0.9999411050F, - 0.9999432416F, 0.9999453196F, 0.9999473402F, 0.9999493044F, - 0.9999512132F, 0.9999530677F, 0.9999548690F, 0.9999566180F, - 0.9999583157F, 0.9999599633F, 0.9999615616F, 0.9999631116F, - 0.9999646144F, 0.9999660709F, 0.9999674820F, 0.9999688487F, - 0.9999701719F, 0.9999714526F, 0.9999726917F, 0.9999738900F, - 0.9999750486F, 0.9999761682F, 0.9999772497F, 0.9999782941F, - 0.9999793021F, 0.9999802747F, 0.9999812126F, 0.9999821167F, - 0.9999829878F, 0.9999838268F, 0.9999846343F, 0.9999854113F, - 0.9999861584F, 0.9999868765F, 0.9999875664F, 0.9999882287F, - 0.9999888642F, 0.9999894736F, 0.9999900577F, 0.9999906172F, - 0.9999911528F, 0.9999916651F, 0.9999921548F, 0.9999926227F, - 0.9999930693F, 0.9999934954F, 0.9999939015F, 0.9999942883F, - 0.9999946564F, 0.9999950064F, 0.9999953390F, 0.9999956547F, - 0.9999959541F, 0.9999962377F, 0.9999965062F, 0.9999967601F, - 0.9999969998F, 0.9999972260F, 0.9999974392F, 0.9999976399F, - 0.9999978285F, 0.9999980056F, 0.9999981716F, 0.9999983271F, - 0.9999984724F, 0.9999986081F, 0.9999987345F, 0.9999988521F, - 0.9999989613F, 0.9999990625F, 0.9999991562F, 0.9999992426F, - 0.9999993223F, 0.9999993954F, 0.9999994625F, 0.9999995239F, - 0.9999995798F, 0.9999996307F, 0.9999996768F, 0.9999997184F, - 0.9999997559F, 0.9999997895F, 0.9999998195F, 0.9999998462F, - 0.9999998698F, 0.9999998906F, 0.9999999088F, 0.9999999246F, - 0.9999999383F, 0.9999999500F, 0.9999999600F, 0.9999999684F, - 0.9999999754F, 0.9999999811F, 0.9999999858F, 0.9999999896F, - 0.9999999925F, 0.9999999948F, 0.9999999965F, 0.9999999978F, - 0.9999999986F, 0.9999999992F, 0.9999999996F, 0.9999999998F, - 0.9999999999F, 1.0000000000F, 1.0000000000F, 1.0000000000F, -}; - -static const float vwin8192[4096] = { - 0.0000000578F, 0.0000005198F, 0.0000014438F, 0.0000028299F, - 0.0000046780F, 0.0000069882F, 0.0000097604F, 0.0000129945F, - 0.0000166908F, 0.0000208490F, 0.0000254692F, 0.0000305515F, - 0.0000360958F, 0.0000421021F, 0.0000485704F, 0.0000555006F, - 0.0000628929F, 0.0000707472F, 0.0000790635F, 0.0000878417F, - 0.0000970820F, 0.0001067842F, 0.0001169483F, 0.0001275744F, - 0.0001386625F, 0.0001502126F, 0.0001622245F, 0.0001746984F, - 0.0001876343F, 0.0002010320F, 0.0002148917F, 0.0002292132F, - 0.0002439967F, 0.0002592421F, 0.0002749493F, 0.0002911184F, - 0.0003077493F, 0.0003248421F, 0.0003423967F, 0.0003604132F, - 0.0003788915F, 0.0003978316F, 0.0004172335F, 0.0004370971F, - 0.0004574226F, 0.0004782098F, 0.0004994587F, 0.0005211694F, - 0.0005433418F, 0.0005659759F, 0.0005890717F, 0.0006126292F, - 0.0006366484F, 0.0006611292F, 0.0006860716F, 0.0007114757F, - 0.0007373414F, 0.0007636687F, 0.0007904576F, 0.0008177080F, - 0.0008454200F, 0.0008735935F, 0.0009022285F, 0.0009313250F, - 0.0009608830F, 0.0009909025F, 0.0010213834F, 0.0010523257F, - 0.0010837295F, 0.0011155946F, 0.0011479211F, 0.0011807090F, - 0.0012139582F, 0.0012476687F, 0.0012818405F, 0.0013164736F, - 0.0013515679F, 0.0013871235F, 0.0014231402F, 0.0014596182F, - 0.0014965573F, 0.0015339576F, 0.0015718190F, 0.0016101415F, - 0.0016489251F, 0.0016881698F, 0.0017278754F, 0.0017680421F, - 0.0018086698F, 0.0018497584F, 0.0018913080F, 0.0019333185F, - 0.0019757898F, 0.0020187221F, 0.0020621151F, 0.0021059690F, - 0.0021502837F, 0.0021950591F, 0.0022402953F, 0.0022859921F, - 0.0023321497F, 0.0023787679F, 0.0024258467F, 0.0024733861F, - 0.0025213861F, 0.0025698466F, 0.0026187676F, 0.0026681491F, - 0.0027179911F, 0.0027682935F, 0.0028190562F, 0.0028702794F, - 0.0029219628F, 0.0029741066F, 0.0030267107F, 0.0030797749F, - 0.0031332994F, 0.0031872841F, 0.0032417289F, 0.0032966338F, - 0.0033519988F, 0.0034078238F, 0.0034641089F, 0.0035208539F, - 0.0035780589F, 0.0036357237F, 0.0036938485F, 0.0037524331F, - 0.0038114775F, 0.0038709817F, 0.0039309456F, 0.0039913692F, - 0.0040522524F, 0.0041135953F, 0.0041753978F, 0.0042376599F, - 0.0043003814F, 0.0043635624F, 0.0044272029F, 0.0044913028F, - 0.0045558620F, 0.0046208806F, 0.0046863585F, 0.0047522955F, - 0.0048186919F, 0.0048855473F, 0.0049528619F, 0.0050206356F, - 0.0050888684F, 0.0051575601F, 0.0052267108F, 0.0052963204F, - 0.0053663890F, 0.0054369163F, 0.0055079025F, 0.0055793474F, - 0.0056512510F, 0.0057236133F, 0.0057964342F, 0.0058697137F, - 0.0059434517F, 0.0060176482F, 0.0060923032F, 0.0061674166F, - 0.0062429883F, 0.0063190183F, 0.0063955066F, 0.0064724532F, - 0.0065498579F, 0.0066277207F, 0.0067060416F, 0.0067848205F, - 0.0068640575F, 0.0069437523F, 0.0070239051F, 0.0071045157F, - 0.0071855840F, 0.0072671102F, 0.0073490940F, 0.0074315355F, - 0.0075144345F, 0.0075977911F, 0.0076816052F, 0.0077658768F, - 0.0078506057F, 0.0079357920F, 0.0080214355F, 0.0081075363F, - 0.0081940943F, 0.0082811094F, 0.0083685816F, 0.0084565108F, - 0.0085448970F, 0.0086337401F, 0.0087230401F, 0.0088127969F, - 0.0089030104F, 0.0089936807F, 0.0090848076F, 0.0091763911F, - 0.0092684311F, 0.0093609276F, 0.0094538805F, 0.0095472898F, - 0.0096411554F, 0.0097354772F, 0.0098302552F, 0.0099254894F, - 0.0100211796F, 0.0101173259F, 0.0102139281F, 0.0103109863F, - 0.0104085002F, 0.0105064700F, 0.0106048955F, 0.0107037766F, - 0.0108031133F, 0.0109029056F, 0.0110031534F, 0.0111038565F, - 0.0112050151F, 0.0113066289F, 0.0114086980F, 0.0115112222F, - 0.0116142015F, 0.0117176359F, 0.0118215252F, 0.0119258695F, - 0.0120306686F, 0.0121359225F, 0.0122416312F, 0.0123477944F, - 0.0124544123F, 0.0125614847F, 0.0126690116F, 0.0127769928F, - 0.0128854284F, 0.0129943182F, 0.0131036623F, 0.0132134604F, - 0.0133237126F, 0.0134344188F, 0.0135455790F, 0.0136571929F, - 0.0137692607F, 0.0138817821F, 0.0139947572F, 0.0141081859F, - 0.0142220681F, 0.0143364037F, 0.0144511927F, 0.0145664350F, - 0.0146821304F, 0.0147982791F, 0.0149148808F, 0.0150319355F, - 0.0151494431F, 0.0152674036F, 0.0153858168F, 0.0155046828F, - 0.0156240014F, 0.0157437726F, 0.0158639962F, 0.0159846723F, - 0.0161058007F, 0.0162273814F, 0.0163494142F, 0.0164718991F, - 0.0165948361F, 0.0167182250F, 0.0168420658F, 0.0169663584F, - 0.0170911027F, 0.0172162987F, 0.0173419462F, 0.0174680452F, - 0.0175945956F, 0.0177215974F, 0.0178490504F, 0.0179769545F, - 0.0181053098F, 0.0182341160F, 0.0183633732F, 0.0184930812F, - 0.0186232399F, 0.0187538494F, 0.0188849094F, 0.0190164200F, - 0.0191483809F, 0.0192807923F, 0.0194136539F, 0.0195469656F, - 0.0196807275F, 0.0198149394F, 0.0199496012F, 0.0200847128F, - 0.0202202742F, 0.0203562853F, 0.0204927460F, 0.0206296561F, - 0.0207670157F, 0.0209048245F, 0.0210430826F, 0.0211817899F, - 0.0213209462F, 0.0214605515F, 0.0216006057F, 0.0217411086F, - 0.0218820603F, 0.0220234605F, 0.0221653093F, 0.0223076066F, - 0.0224503521F, 0.0225935459F, 0.0227371879F, 0.0228812779F, - 0.0230258160F, 0.0231708018F, 0.0233162355F, 0.0234621169F, - 0.0236084459F, 0.0237552224F, 0.0239024462F, 0.0240501175F, - 0.0241982359F, 0.0243468015F, 0.0244958141F, 0.0246452736F, - 0.0247951800F, 0.0249455331F, 0.0250963329F, 0.0252475792F, - 0.0253992720F, 0.0255514111F, 0.0257039965F, 0.0258570281F, - 0.0260105057F, 0.0261644293F, 0.0263187987F, 0.0264736139F, - 0.0266288747F, 0.0267845811F, 0.0269407330F, 0.0270973302F, - 0.0272543727F, 0.0274118604F, 0.0275697930F, 0.0277281707F, - 0.0278869932F, 0.0280462604F, 0.0282059723F, 0.0283661287F, - 0.0285267295F, 0.0286877747F, 0.0288492641F, 0.0290111976F, - 0.0291735751F, 0.0293363965F, 0.0294996617F, 0.0296633706F, - 0.0298275231F, 0.0299921190F, 0.0301571583F, 0.0303226409F, - 0.0304885667F, 0.0306549354F, 0.0308217472F, 0.0309890017F, - 0.0311566989F, 0.0313248388F, 0.0314934211F, 0.0316624459F, - 0.0318319128F, 0.0320018220F, 0.0321721732F, 0.0323429663F, - 0.0325142013F, 0.0326858779F, 0.0328579962F, 0.0330305559F, - 0.0332035570F, 0.0333769994F, 0.0335508829F, 0.0337252074F, - 0.0338999728F, 0.0340751790F, 0.0342508259F, 0.0344269134F, - 0.0346034412F, 0.0347804094F, 0.0349578178F, 0.0351356663F, - 0.0353139548F, 0.0354926831F, 0.0356718511F, 0.0358514588F, - 0.0360315059F, 0.0362119924F, 0.0363929182F, 0.0365742831F, - 0.0367560870F, 0.0369383297F, 0.0371210113F, 0.0373041315F, - 0.0374876902F, 0.0376716873F, 0.0378561226F, 0.0380409961F, - 0.0382263077F, 0.0384120571F, 0.0385982443F, 0.0387848691F, - 0.0389719315F, 0.0391594313F, 0.0393473683F, 0.0395357425F, - 0.0397245537F, 0.0399138017F, 0.0401034866F, 0.0402936080F, - 0.0404841660F, 0.0406751603F, 0.0408665909F, 0.0410584576F, - 0.0412507603F, 0.0414434988F, 0.0416366731F, 0.0418302829F, - 0.0420243282F, 0.0422188088F, 0.0424137246F, 0.0426090755F, - 0.0428048613F, 0.0430010819F, 0.0431977371F, 0.0433948269F, - 0.0435923511F, 0.0437903095F, 0.0439887020F, 0.0441875285F, - 0.0443867889F, 0.0445864830F, 0.0447866106F, 0.0449871717F, - 0.0451881661F, 0.0453895936F, 0.0455914542F, 0.0457937477F, - 0.0459964738F, 0.0461996326F, 0.0464032239F, 0.0466072475F, - 0.0468117032F, 0.0470165910F, 0.0472219107F, 0.0474276622F, - 0.0476338452F, 0.0478404597F, 0.0480475056F, 0.0482549827F, - 0.0484628907F, 0.0486712297F, 0.0488799994F, 0.0490891998F, - 0.0492988306F, 0.0495088917F, 0.0497193830F, 0.0499303043F, - 0.0501416554F, 0.0503534363F, 0.0505656468F, 0.0507782867F, - 0.0509913559F, 0.0512048542F, 0.0514187815F, 0.0516331376F, - 0.0518479225F, 0.0520631358F, 0.0522787775F, 0.0524948475F, - 0.0527113455F, 0.0529282715F, 0.0531456252F, 0.0533634066F, - 0.0535816154F, 0.0538002515F, 0.0540193148F, 0.0542388051F, - 0.0544587222F, 0.0546790660F, 0.0548998364F, 0.0551210331F, - 0.0553426561F, 0.0555647051F, 0.0557871801F, 0.0560100807F, - 0.0562334070F, 0.0564571587F, 0.0566813357F, 0.0569059378F, - 0.0571309649F, 0.0573564168F, 0.0575822933F, 0.0578085942F, - 0.0580353195F, 0.0582624689F, 0.0584900423F, 0.0587180396F, - 0.0589464605F, 0.0591753049F, 0.0594045726F, 0.0596342635F, - 0.0598643774F, 0.0600949141F, 0.0603258735F, 0.0605572555F, - 0.0607890597F, 0.0610212862F, 0.0612539346F, 0.0614870049F, - 0.0617204968F, 0.0619544103F, 0.0621887451F, 0.0624235010F, - 0.0626586780F, 0.0628942758F, 0.0631302942F, 0.0633667331F, - 0.0636035923F, 0.0638408717F, 0.0640785710F, 0.0643166901F, - 0.0645552288F, 0.0647941870F, 0.0650335645F, 0.0652733610F, - 0.0655135765F, 0.0657542108F, 0.0659952636F, 0.0662367348F, - 0.0664786242F, 0.0667209316F, 0.0669636570F, 0.0672068000F, - 0.0674503605F, 0.0676943384F, 0.0679387334F, 0.0681835454F, - 0.0684287742F, 0.0686744196F, 0.0689204814F, 0.0691669595F, - 0.0694138536F, 0.0696611637F, 0.0699088894F, 0.0701570307F, - 0.0704055873F, 0.0706545590F, 0.0709039458F, 0.0711537473F, - 0.0714039634F, 0.0716545939F, 0.0719056387F, 0.0721570975F, - 0.0724089702F, 0.0726612565F, 0.0729139563F, 0.0731670694F, - 0.0734205956F, 0.0736745347F, 0.0739288866F, 0.0741836510F, - 0.0744388277F, 0.0746944166F, 0.0749504175F, 0.0752068301F, - 0.0754636543F, 0.0757208899F, 0.0759785367F, 0.0762365946F, - 0.0764950632F, 0.0767539424F, 0.0770132320F, 0.0772729319F, - 0.0775330418F, 0.0777935616F, 0.0780544909F, 0.0783158298F, - 0.0785775778F, 0.0788397349F, 0.0791023009F, 0.0793652755F, - 0.0796286585F, 0.0798924498F, 0.0801566492F, 0.0804212564F, - 0.0806862712F, 0.0809516935F, 0.0812175231F, 0.0814837597F, - 0.0817504031F, 0.0820174532F, 0.0822849097F, 0.0825527724F, - 0.0828210412F, 0.0830897158F, 0.0833587960F, 0.0836282816F, - 0.0838981724F, 0.0841684682F, 0.0844391688F, 0.0847102740F, - 0.0849817835F, 0.0852536973F, 0.0855260150F, 0.0857987364F, - 0.0860718614F, 0.0863453897F, 0.0866193211F, 0.0868936554F, - 0.0871683924F, 0.0874435319F, 0.0877190737F, 0.0879950175F, - 0.0882713632F, 0.0885481105F, 0.0888252592F, 0.0891028091F, - 0.0893807600F, 0.0896591117F, 0.0899378639F, 0.0902170165F, - 0.0904965692F, 0.0907765218F, 0.0910568740F, 0.0913376258F, - 0.0916187767F, 0.0919003268F, 0.0921822756F, 0.0924646230F, - 0.0927473687F, 0.0930305126F, 0.0933140545F, 0.0935979940F, - 0.0938823310F, 0.0941670653F, 0.0944521966F, 0.0947377247F, - 0.0950236494F, 0.0953099704F, 0.0955966876F, 0.0958838007F, - 0.0961713094F, 0.0964592136F, 0.0967475131F, 0.0970362075F, - 0.0973252967F, 0.0976147805F, 0.0979046585F, 0.0981949307F, - 0.0984855967F, 0.0987766563F, 0.0990681093F, 0.0993599555F, - 0.0996521945F, 0.0999448263F, 0.1002378506F, 0.1005312671F, - 0.1008250755F, 0.1011192757F, 0.1014138675F, 0.1017088505F, - 0.1020042246F, 0.1022999895F, 0.1025961450F, 0.1028926909F, - 0.1031896268F, 0.1034869526F, 0.1037846680F, 0.1040827729F, - 0.1043812668F, 0.1046801497F, 0.1049794213F, 0.1052790813F, - 0.1055791294F, 0.1058795656F, 0.1061803894F, 0.1064816006F, - 0.1067831991F, 0.1070851846F, 0.1073875568F, 0.1076903155F, - 0.1079934604F, 0.1082969913F, 0.1086009079F, 0.1089052101F, - 0.1092098975F, 0.1095149699F, 0.1098204270F, 0.1101262687F, - 0.1104324946F, 0.1107391045F, 0.1110460982F, 0.1113534754F, - 0.1116612359F, 0.1119693793F, 0.1122779055F, 0.1125868142F, - 0.1128961052F, 0.1132057781F, 0.1135158328F, 0.1138262690F, - 0.1141370863F, 0.1144482847F, 0.1147598638F, 0.1150718233F, - 0.1153841631F, 0.1156968828F, 0.1160099822F, 0.1163234610F, - 0.1166373190F, 0.1169515559F, 0.1172661714F, 0.1175811654F, - 0.1178965374F, 0.1182122874F, 0.1185284149F, 0.1188449198F, - 0.1191618018F, 0.1194790606F, 0.1197966960F, 0.1201147076F, - 0.1204330953F, 0.1207518587F, 0.1210709976F, 0.1213905118F, - 0.1217104009F, 0.1220306647F, 0.1223513029F, 0.1226723153F, - 0.1229937016F, 0.1233154615F, 0.1236375948F, 0.1239601011F, - 0.1242829803F, 0.1246062319F, 0.1249298559F, 0.1252538518F, - 0.1255782195F, 0.1259029586F, 0.1262280689F, 0.1265535501F, - 0.1268794019F, 0.1272056241F, 0.1275322163F, 0.1278591784F, - 0.1281865099F, 0.1285142108F, 0.1288422805F, 0.1291707190F, - 0.1294995259F, 0.1298287009F, 0.1301582437F, 0.1304881542F, - 0.1308184319F, 0.1311490766F, 0.1314800881F, 0.1318114660F, - 0.1321432100F, 0.1324753200F, 0.1328077955F, 0.1331406364F, - 0.1334738422F, 0.1338074129F, 0.1341413479F, 0.1344756472F, - 0.1348103103F, 0.1351453370F, 0.1354807270F, 0.1358164801F, - 0.1361525959F, 0.1364890741F, 0.1368259145F, 0.1371631167F, - 0.1375006805F, 0.1378386056F, 0.1381768917F, 0.1385155384F, - 0.1388545456F, 0.1391939129F, 0.1395336400F, 0.1398737266F, - 0.1402141724F, 0.1405549772F, 0.1408961406F, 0.1412376623F, - 0.1415795421F, 0.1419217797F, 0.1422643746F, 0.1426073268F, - 0.1429506358F, 0.1432943013F, 0.1436383231F, 0.1439827008F, - 0.1443274342F, 0.1446725229F, 0.1450179667F, 0.1453637652F, - 0.1457099181F, 0.1460564252F, 0.1464032861F, 0.1467505006F, - 0.1470980682F, 0.1474459888F, 0.1477942620F, 0.1481428875F, - 0.1484918651F, 0.1488411942F, 0.1491908748F, 0.1495409065F, - 0.1498912889F, 0.1502420218F, 0.1505931048F, 0.1509445376F, - 0.1512963200F, 0.1516484516F, 0.1520009321F, 0.1523537612F, - 0.1527069385F, 0.1530604638F, 0.1534143368F, 0.1537685571F, - 0.1541231244F, 0.1544780384F, 0.1548332987F, 0.1551889052F, - 0.1555448574F, 0.1559011550F, 0.1562577978F, 0.1566147853F, - 0.1569721173F, 0.1573297935F, 0.1576878135F, 0.1580461771F, - 0.1584048838F, 0.1587639334F, 0.1591233255F, 0.1594830599F, - 0.1598431361F, 0.1602035540F, 0.1605643131F, 0.1609254131F, - 0.1612868537F, 0.1616486346F, 0.1620107555F, 0.1623732160F, - 0.1627360158F, 0.1630991545F, 0.1634626319F, 0.1638264476F, - 0.1641906013F, 0.1645550926F, 0.1649199212F, 0.1652850869F, - 0.1656505892F, 0.1660164278F, 0.1663826024F, 0.1667491127F, - 0.1671159583F, 0.1674831388F, 0.1678506541F, 0.1682185036F, - 0.1685866872F, 0.1689552044F, 0.1693240549F, 0.1696932384F, - 0.1700627545F, 0.1704326029F, 0.1708027833F, 0.1711732952F, - 0.1715441385F, 0.1719153127F, 0.1722868175F, 0.1726586526F, - 0.1730308176F, 0.1734033121F, 0.1737761359F, 0.1741492886F, - 0.1745227698F, 0.1748965792F, 0.1752707164F, 0.1756451812F, - 0.1760199731F, 0.1763950918F, 0.1767705370F, 0.1771463083F, - 0.1775224054F, 0.1778988279F, 0.1782755754F, 0.1786526477F, - 0.1790300444F, 0.1794077651F, 0.1797858094F, 0.1801641771F, - 0.1805428677F, 0.1809218810F, 0.1813012165F, 0.1816808739F, - 0.1820608528F, 0.1824411530F, 0.1828217739F, 0.1832027154F, - 0.1835839770F, 0.1839655584F, 0.1843474592F, 0.1847296790F, - 0.1851122175F, 0.1854950744F, 0.1858782492F, 0.1862617417F, - 0.1866455514F, 0.1870296780F, 0.1874141211F, 0.1877988804F, - 0.1881839555F, 0.1885693461F, 0.1889550517F, 0.1893410721F, - 0.1897274068F, 0.1901140555F, 0.1905010178F, 0.1908882933F, - 0.1912758818F, 0.1916637828F, 0.1920519959F, 0.1924405208F, - 0.1928293571F, 0.1932185044F, 0.1936079625F, 0.1939977308F, - 0.1943878091F, 0.1947781969F, 0.1951688939F, 0.1955598998F, - 0.1959512141F, 0.1963428364F, 0.1967347665F, 0.1971270038F, - 0.1975195482F, 0.1979123990F, 0.1983055561F, 0.1986990190F, - 0.1990927873F, 0.1994868607F, 0.1998812388F, 0.2002759212F, - 0.2006709075F, 0.2010661974F, 0.2014617904F, 0.2018576862F, - 0.2022538844F, 0.2026503847F, 0.2030471865F, 0.2034442897F, - 0.2038416937F, 0.2042393982F, 0.2046374028F, 0.2050357071F, - 0.2054343107F, 0.2058332133F, 0.2062324145F, 0.2066319138F, - 0.2070317110F, 0.2074318055F, 0.2078321970F, 0.2082328852F, - 0.2086338696F, 0.2090351498F, 0.2094367255F, 0.2098385962F, - 0.2102407617F, 0.2106432213F, 0.2110459749F, 0.2114490220F, - 0.2118523621F, 0.2122559950F, 0.2126599202F, 0.2130641373F, - 0.2134686459F, 0.2138734456F, 0.2142785361F, 0.2146839168F, - 0.2150895875F, 0.2154955478F, 0.2159017972F, 0.2163083353F, - 0.2167151617F, 0.2171222761F, 0.2175296780F, 0.2179373670F, - 0.2183453428F, 0.2187536049F, 0.2191621529F, 0.2195709864F, - 0.2199801051F, 0.2203895085F, 0.2207991961F, 0.2212091677F, - 0.2216194228F, 0.2220299610F, 0.2224407818F, 0.2228518850F, - 0.2232632699F, 0.2236749364F, 0.2240868839F, 0.2244991121F, - 0.2249116204F, 0.2253244086F, 0.2257374763F, 0.2261508229F, - 0.2265644481F, 0.2269783514F, 0.2273925326F, 0.2278069911F, - 0.2282217265F, 0.2286367384F, 0.2290520265F, 0.2294675902F, - 0.2298834292F, 0.2302995431F, 0.2307159314F, 0.2311325937F, - 0.2315495297F, 0.2319667388F, 0.2323842207F, 0.2328019749F, - 0.2332200011F, 0.2336382988F, 0.2340568675F, 0.2344757070F, - 0.2348948166F, 0.2353141961F, 0.2357338450F, 0.2361537629F, - 0.2365739493F, 0.2369944038F, 0.2374151261F, 0.2378361156F, - 0.2382573720F, 0.2386788948F, 0.2391006836F, 0.2395227380F, - 0.2399450575F, 0.2403676417F, 0.2407904902F, 0.2412136026F, - 0.2416369783F, 0.2420606171F, 0.2424845185F, 0.2429086820F, - 0.2433331072F, 0.2437577936F, 0.2441827409F, 0.2446079486F, - 0.2450334163F, 0.2454591435F, 0.2458851298F, 0.2463113747F, - 0.2467378779F, 0.2471646389F, 0.2475916573F, 0.2480189325F, - 0.2484464643F, 0.2488742521F, 0.2493022955F, 0.2497305940F, - 0.2501591473F, 0.2505879549F, 0.2510170163F, 0.2514463311F, - 0.2518758989F, 0.2523057193F, 0.2527357916F, 0.2531661157F, - 0.2535966909F, 0.2540275169F, 0.2544585931F, 0.2548899193F, - 0.2553214948F, 0.2557533193F, 0.2561853924F, 0.2566177135F, - 0.2570502822F, 0.2574830981F, 0.2579161608F, 0.2583494697F, - 0.2587830245F, 0.2592168246F, 0.2596508697F, 0.2600851593F, - 0.2605196929F, 0.2609544701F, 0.2613894904F, 0.2618247534F, - 0.2622602586F, 0.2626960055F, 0.2631319938F, 0.2635682230F, - 0.2640046925F, 0.2644414021F, 0.2648783511F, 0.2653155391F, - 0.2657529657F, 0.2661906305F, 0.2666285329F, 0.2670666725F, - 0.2675050489F, 0.2679436616F, 0.2683825101F, 0.2688215940F, - 0.2692609127F, 0.2697004660F, 0.2701402532F, 0.2705802739F, - 0.2710205278F, 0.2714610142F, 0.2719017327F, 0.2723426830F, - 0.2727838644F, 0.2732252766F, 0.2736669191F, 0.2741087914F, - 0.2745508930F, 0.2749932235F, 0.2754357824F, 0.2758785693F, - 0.2763215837F, 0.2767648251F, 0.2772082930F, 0.2776519870F, - 0.2780959066F, 0.2785400513F, 0.2789844207F, 0.2794290143F, - 0.2798738316F, 0.2803188722F, 0.2807641355F, 0.2812096211F, - 0.2816553286F, 0.2821012574F, 0.2825474071F, 0.2829937773F, - 0.2834403673F, 0.2838871768F, 0.2843342053F, 0.2847814523F, - 0.2852289174F, 0.2856765999F, 0.2861244996F, 0.2865726159F, - 0.2870209482F, 0.2874694962F, 0.2879182594F, 0.2883672372F, - 0.2888164293F, 0.2892658350F, 0.2897154540F, 0.2901652858F, - 0.2906153298F, 0.2910655856F, 0.2915160527F, 0.2919667306F, - 0.2924176189F, 0.2928687171F, 0.2933200246F, 0.2937715409F, - 0.2942232657F, 0.2946751984F, 0.2951273386F, 0.2955796856F, - 0.2960322391F, 0.2964849986F, 0.2969379636F, 0.2973911335F, - 0.2978445080F, 0.2982980864F, 0.2987518684F, 0.2992058534F, - 0.2996600409F, 0.3001144305F, 0.3005690217F, 0.3010238139F, - 0.3014788067F, 0.3019339995F, 0.3023893920F, 0.3028449835F, - 0.3033007736F, 0.3037567618F, 0.3042129477F, 0.3046693306F, - 0.3051259102F, 0.3055826859F, 0.3060396572F, 0.3064968236F, - 0.3069541847F, 0.3074117399F, 0.3078694887F, 0.3083274307F, - 0.3087855653F, 0.3092438920F, 0.3097024104F, 0.3101611199F, - 0.3106200200F, 0.3110791103F, 0.3115383902F, 0.3119978592F, - 0.3124575169F, 0.3129173627F, 0.3133773961F, 0.3138376166F, - 0.3142980238F, 0.3147586170F, 0.3152193959F, 0.3156803598F, - 0.3161415084F, 0.3166028410F, 0.3170643573F, 0.3175260566F, - 0.3179879384F, 0.3184500023F, 0.3189122478F, 0.3193746743F, - 0.3198372814F, 0.3203000685F, 0.3207630351F, 0.3212261807F, - 0.3216895048F, 0.3221530069F, 0.3226166865F, 0.3230805430F, - 0.3235445760F, 0.3240087849F, 0.3244731693F, 0.3249377285F, - 0.3254024622F, 0.3258673698F, 0.3263324507F, 0.3267977045F, - 0.3272631306F, 0.3277287286F, 0.3281944978F, 0.3286604379F, - 0.3291265482F, 0.3295928284F, 0.3300592777F, 0.3305258958F, - 0.3309926821F, 0.3314596361F, 0.3319267573F, 0.3323940451F, - 0.3328614990F, 0.3333291186F, 0.3337969033F, 0.3342648525F, - 0.3347329658F, 0.3352012427F, 0.3356696825F, 0.3361382849F, - 0.3366070492F, 0.3370759749F, 0.3375450616F, 0.3380143087F, - 0.3384837156F, 0.3389532819F, 0.3394230071F, 0.3398928905F, - 0.3403629317F, 0.3408331302F, 0.3413034854F, 0.3417739967F, - 0.3422446638F, 0.3427154860F, 0.3431864628F, 0.3436575938F, - 0.3441288782F, 0.3446003158F, 0.3450719058F, 0.3455436478F, - 0.3460155412F, 0.3464875856F, 0.3469597804F, 0.3474321250F, - 0.3479046189F, 0.3483772617F, 0.3488500527F, 0.3493229914F, - 0.3497960774F, 0.3502693100F, 0.3507426887F, 0.3512162131F, - 0.3516898825F, 0.3521636965F, 0.3526376545F, 0.3531117559F, - 0.3535860003F, 0.3540603870F, 0.3545349157F, 0.3550095856F, - 0.3554843964F, 0.3559593474F, 0.3564344381F, 0.3569096680F, - 0.3573850366F, 0.3578605432F, 0.3583361875F, 0.3588119687F, - 0.3592878865F, 0.3597639402F, 0.3602401293F, 0.3607164533F, - 0.3611929117F, 0.3616695038F, 0.3621462292F, 0.3626230873F, - 0.3631000776F, 0.3635771995F, 0.3640544525F, 0.3645318360F, - 0.3650093496F, 0.3654869926F, 0.3659647645F, 0.3664426648F, - 0.3669206930F, 0.3673988484F, 0.3678771306F, 0.3683555390F, - 0.3688340731F, 0.3693127322F, 0.3697915160F, 0.3702704237F, - 0.3707494549F, 0.3712286091F, 0.3717078857F, 0.3721872840F, - 0.3726668037F, 0.3731464441F, 0.3736262047F, 0.3741060850F, - 0.3745860843F, 0.3750662023F, 0.3755464382F, 0.3760267915F, - 0.3765072618F, 0.3769878484F, 0.3774685509F, 0.3779493686F, - 0.3784303010F, 0.3789113475F, 0.3793925076F, 0.3798737809F, - 0.3803551666F, 0.3808366642F, 0.3813182733F, 0.3817999932F, - 0.3822818234F, 0.3827637633F, 0.3832458124F, 0.3837279702F, - 0.3842102360F, 0.3846926093F, 0.3851750897F, 0.3856576764F, - 0.3861403690F, 0.3866231670F, 0.3871060696F, 0.3875890765F, - 0.3880721870F, 0.3885554007F, 0.3890387168F, 0.3895221349F, - 0.3900056544F, 0.3904892748F, 0.3909729955F, 0.3914568160F, - 0.3919407356F, 0.3924247539F, 0.3929088702F, 0.3933930841F, - 0.3938773949F, 0.3943618021F, 0.3948463052F, 0.3953309035F, - 0.3958155966F, 0.3963003838F, 0.3967852646F, 0.3972702385F, - 0.3977553048F, 0.3982404631F, 0.3987257127F, 0.3992110531F, - 0.3996964838F, 0.4001820041F, 0.4006676136F, 0.4011533116F, - 0.4016390976F, 0.4021249710F, 0.4026109313F, 0.4030969779F, - 0.4035831102F, 0.4040693277F, 0.4045556299F, 0.4050420160F, - 0.4055284857F, 0.4060150383F, 0.4065016732F, 0.4069883899F, - 0.4074751879F, 0.4079620665F, 0.4084490252F, 0.4089360635F, - 0.4094231807F, 0.4099103763F, 0.4103976498F, 0.4108850005F, - 0.4113724280F, 0.4118599315F, 0.4123475107F, 0.4128351648F, - 0.4133228934F, 0.4138106959F, 0.4142985716F, 0.4147865201F, - 0.4152745408F, 0.4157626330F, 0.4162507963F, 0.4167390301F, - 0.4172273337F, 0.4177157067F, 0.4182041484F, 0.4186926583F, - 0.4191812359F, 0.4196698805F, 0.4201585915F, 0.4206473685F, - 0.4211362108F, 0.4216251179F, 0.4221140892F, 0.4226031241F, - 0.4230922221F, 0.4235813826F, 0.4240706050F, 0.4245598887F, - 0.4250492332F, 0.4255386379F, 0.4260281022F, 0.4265176256F, - 0.4270072075F, 0.4274968473F, 0.4279865445F, 0.4284762984F, - 0.4289661086F, 0.4294559743F, 0.4299458951F, 0.4304358704F, - 0.4309258996F, 0.4314159822F, 0.4319061175F, 0.4323963050F, - 0.4328865441F, 0.4333768342F, 0.4338671749F, 0.4343575654F, - 0.4348480052F, 0.4353384938F, 0.4358290306F, 0.4363196149F, - 0.4368102463F, 0.4373009241F, 0.4377916478F, 0.4382824168F, - 0.4387732305F, 0.4392640884F, 0.4397549899F, 0.4402459343F, - 0.4407369212F, 0.4412279499F, 0.4417190198F, 0.4422101305F, - 0.4427012813F, 0.4431924717F, 0.4436837010F, 0.4441749686F, - 0.4446662742F, 0.4451576169F, 0.4456489963F, 0.4461404118F, - 0.4466318628F, 0.4471233487F, 0.4476148690F, 0.4481064230F, - 0.4485980103F, 0.4490896302F, 0.4495812821F, 0.4500729654F, - 0.4505646797F, 0.4510564243F, 0.4515481986F, 0.4520400021F, - 0.4525318341F, 0.4530236942F, 0.4535155816F, 0.4540074959F, - 0.4544994365F, 0.4549914028F, 0.4554833941F, 0.4559754100F, - 0.4564674499F, 0.4569595131F, 0.4574515991F, 0.4579437074F, - 0.4584358372F, 0.4589279881F, 0.4594201595F, 0.4599123508F, - 0.4604045615F, 0.4608967908F, 0.4613890383F, 0.4618813034F, - 0.4623735855F, 0.4628658841F, 0.4633581984F, 0.4638505281F, - 0.4643428724F, 0.4648352308F, 0.4653276028F, 0.4658199877F, - 0.4663123849F, 0.4668047940F, 0.4672972143F, 0.4677896451F, - 0.4682820861F, 0.4687745365F, 0.4692669958F, 0.4697594634F, - 0.4702519387F, 0.4707444211F, 0.4712369102F, 0.4717294052F, - 0.4722219056F, 0.4727144109F, 0.4732069204F, 0.4736994336F, - 0.4741919498F, 0.4746844686F, 0.4751769893F, 0.4756695113F, - 0.4761620341F, 0.4766545571F, 0.4771470797F, 0.4776396013F, - 0.4781321213F, 0.4786246392F, 0.4791171544F, 0.4796096663F, - 0.4801021744F, 0.4805946779F, 0.4810871765F, 0.4815796694F, - 0.4820721561F, 0.4825646360F, 0.4830571086F, 0.4835495732F, - 0.4840420293F, 0.4845344763F, 0.4850269136F, 0.4855193407F, - 0.4860117569F, 0.4865041617F, 0.4869965545F, 0.4874889347F, - 0.4879813018F, 0.4884736551F, 0.4889659941F, 0.4894583182F, - 0.4899506268F, 0.4904429193F, 0.4909351952F, 0.4914274538F, - 0.4919196947F, 0.4924119172F, 0.4929041207F, 0.4933963046F, - 0.4938884685F, 0.4943806116F, 0.4948727335F, 0.4953648335F, - 0.4958569110F, 0.4963489656F, 0.4968409965F, 0.4973330032F, - 0.4978249852F, 0.4983169419F, 0.4988088726F, 0.4993007768F, - 0.4997926539F, 0.5002845034F, 0.5007763247F, 0.5012681171F, - 0.5017598801F, 0.5022516132F, 0.5027433157F, 0.5032349871F, - 0.5037266268F, 0.5042182341F, 0.5047098086F, 0.5052013497F, - 0.5056928567F, 0.5061843292F, 0.5066757664F, 0.5071671679F, - 0.5076585330F, 0.5081498613F, 0.5086411520F, 0.5091324047F, - 0.5096236187F, 0.5101147934F, 0.5106059284F, 0.5110970230F, - 0.5115880766F, 0.5120790887F, 0.5125700587F, 0.5130609860F, - 0.5135518700F, 0.5140427102F, 0.5145335059F, 0.5150242566F, - 0.5155149618F, 0.5160056208F, 0.5164962331F, 0.5169867980F, - 0.5174773151F, 0.5179677837F, 0.5184582033F, 0.5189485733F, - 0.5194388931F, 0.5199291621F, 0.5204193798F, 0.5209095455F, - 0.5213996588F, 0.5218897190F, 0.5223797256F, 0.5228696779F, - 0.5233595755F, 0.5238494177F, 0.5243392039F, 0.5248289337F, - 0.5253186063F, 0.5258082213F, 0.5262977781F, 0.5267872760F, - 0.5272767146F, 0.5277660932F, 0.5282554112F, 0.5287446682F, - 0.5292338635F, 0.5297229965F, 0.5302120667F, 0.5307010736F, - 0.5311900164F, 0.5316788947F, 0.5321677079F, 0.5326564554F, - 0.5331451366F, 0.5336337511F, 0.5341222981F, 0.5346107771F, - 0.5350991876F, 0.5355875290F, 0.5360758007F, 0.5365640021F, - 0.5370521327F, 0.5375401920F, 0.5380281792F, 0.5385160939F, - 0.5390039355F, 0.5394917034F, 0.5399793971F, 0.5404670159F, - 0.5409545594F, 0.5414420269F, 0.5419294179F, 0.5424167318F, - 0.5429039680F, 0.5433911261F, 0.5438782053F, 0.5443652051F, - 0.5448521250F, 0.5453389644F, 0.5458257228F, 0.5463123995F, - 0.5467989940F, 0.5472855057F, 0.5477719341F, 0.5482582786F, - 0.5487445387F, 0.5492307137F, 0.5497168031F, 0.5502028063F, - 0.5506887228F, 0.5511745520F, 0.5516602934F, 0.5521459463F, - 0.5526315103F, 0.5531169847F, 0.5536023690F, 0.5540876626F, - 0.5545728649F, 0.5550579755F, 0.5555429937F, 0.5560279189F, - 0.5565127507F, 0.5569974884F, 0.5574821315F, 0.5579666794F, - 0.5584511316F, 0.5589354875F, 0.5594197465F, 0.5599039080F, - 0.5603879716F, 0.5608719367F, 0.5613558026F, 0.5618395689F, - 0.5623232350F, 0.5628068002F, 0.5632902642F, 0.5637736262F, - 0.5642568858F, 0.5647400423F, 0.5652230953F, 0.5657060442F, - 0.5661888883F, 0.5666716272F, 0.5671542603F, 0.5676367870F, - 0.5681192069F, 0.5686015192F, 0.5690837235F, 0.5695658192F, - 0.5700478058F, 0.5705296827F, 0.5710114494F, 0.5714931052F, - 0.5719746497F, 0.5724560822F, 0.5729374023F, 0.5734186094F, - 0.5738997029F, 0.5743806823F, 0.5748615470F, 0.5753422965F, - 0.5758229301F, 0.5763034475F, 0.5767838480F, 0.5772641310F, - 0.5777442960F, 0.5782243426F, 0.5787042700F, 0.5791840778F, - 0.5796637654F, 0.5801433322F, 0.5806227778F, 0.5811021016F, - 0.5815813029F, 0.5820603814F, 0.5825393363F, 0.5830181673F, - 0.5834968737F, 0.5839754549F, 0.5844539105F, 0.5849322399F, - 0.5854104425F, 0.5858885179F, 0.5863664653F, 0.5868442844F, - 0.5873219746F, 0.5877995353F, 0.5882769660F, 0.5887542661F, - 0.5892314351F, 0.5897084724F, 0.5901853776F, 0.5906621500F, - 0.5911387892F, 0.5916152945F, 0.5920916655F, 0.5925679016F, - 0.5930440022F, 0.5935199669F, 0.5939957950F, 0.5944714861F, - 0.5949470396F, 0.5954224550F, 0.5958977317F, 0.5963728692F, - 0.5968478669F, 0.5973227244F, 0.5977974411F, 0.5982720163F, - 0.5987464497F, 0.5992207407F, 0.5996948887F, 0.6001688932F, - 0.6006427537F, 0.6011164696F, 0.6015900405F, 0.6020634657F, - 0.6025367447F, 0.6030098770F, 0.6034828621F, 0.6039556995F, - 0.6044283885F, 0.6049009288F, 0.6053733196F, 0.6058455606F, - 0.6063176512F, 0.6067895909F, 0.6072613790F, 0.6077330152F, - 0.6082044989F, 0.6086758295F, 0.6091470065F, 0.6096180294F, - 0.6100888977F, 0.6105596108F, 0.6110301682F, 0.6115005694F, - 0.6119708139F, 0.6124409011F, 0.6129108305F, 0.6133806017F, - 0.6138502139F, 0.6143196669F, 0.6147889599F, 0.6152580926F, - 0.6157270643F, 0.6161958746F, 0.6166645230F, 0.6171330088F, - 0.6176013317F, 0.6180694910F, 0.6185374863F, 0.6190053171F, - 0.6194729827F, 0.6199404828F, 0.6204078167F, 0.6208749841F, - 0.6213419842F, 0.6218088168F, 0.6222754811F, 0.6227419768F, - 0.6232083032F, 0.6236744600F, 0.6241404465F, 0.6246062622F, - 0.6250719067F, 0.6255373795F, 0.6260026799F, 0.6264678076F, - 0.6269327619F, 0.6273975425F, 0.6278621487F, 0.6283265800F, - 0.6287908361F, 0.6292549163F, 0.6297188201F, 0.6301825471F, - 0.6306460966F, 0.6311094683F, 0.6315726617F, 0.6320356761F, - 0.6324985111F, 0.6329611662F, 0.6334236410F, 0.6338859348F, - 0.6343480472F, 0.6348099777F, 0.6352717257F, 0.6357332909F, - 0.6361946726F, 0.6366558704F, 0.6371168837F, 0.6375777122F, - 0.6380383552F, 0.6384988123F, 0.6389590830F, 0.6394191668F, - 0.6398790631F, 0.6403387716F, 0.6407982916F, 0.6412576228F, - 0.6417167645F, 0.6421757163F, 0.6426344778F, 0.6430930483F, - 0.6435514275F, 0.6440096149F, 0.6444676098F, 0.6449254119F, - 0.6453830207F, 0.6458404356F, 0.6462976562F, 0.6467546820F, - 0.6472115125F, 0.6476681472F, 0.6481245856F, 0.6485808273F, - 0.6490368717F, 0.6494927183F, 0.6499483667F, 0.6504038164F, - 0.6508590670F, 0.6513141178F, 0.6517689684F, 0.6522236185F, - 0.6526780673F, 0.6531323146F, 0.6535863598F, 0.6540402024F, - 0.6544938419F, 0.6549472779F, 0.6554005099F, 0.6558535373F, - 0.6563063598F, 0.6567589769F, 0.6572113880F, 0.6576635927F, - 0.6581155906F, 0.6585673810F, 0.6590189637F, 0.6594703380F, - 0.6599215035F, 0.6603724598F, 0.6608232064F, 0.6612737427F, - 0.6617240684F, 0.6621741829F, 0.6626240859F, 0.6630737767F, - 0.6635232550F, 0.6639725202F, 0.6644215720F, 0.6648704098F, - 0.6653190332F, 0.6657674417F, 0.6662156348F, 0.6666636121F, - 0.6671113731F, 0.6675589174F, 0.6680062445F, 0.6684533538F, - 0.6689002450F, 0.6693469177F, 0.6697933712F, 0.6702396052F, - 0.6706856193F, 0.6711314129F, 0.6715769855F, 0.6720223369F, - 0.6724674664F, 0.6729123736F, 0.6733570581F, 0.6738015194F, - 0.6742457570F, 0.6746897706F, 0.6751335596F, 0.6755771236F, - 0.6760204621F, 0.6764635747F, 0.6769064609F, 0.6773491204F, - 0.6777915525F, 0.6782337570F, 0.6786757332F, 0.6791174809F, - 0.6795589995F, 0.6800002886F, 0.6804413477F, 0.6808821765F, - 0.6813227743F, 0.6817631409F, 0.6822032758F, 0.6826431785F, - 0.6830828485F, 0.6835222855F, 0.6839614890F, 0.6844004585F, - 0.6848391936F, 0.6852776939F, 0.6857159589F, 0.6861539883F, - 0.6865917815F, 0.6870293381F, 0.6874666576F, 0.6879037398F, - 0.6883405840F, 0.6887771899F, 0.6892135571F, 0.6896496850F, - 0.6900855733F, 0.6905212216F, 0.6909566294F, 0.6913917963F, - 0.6918267218F, 0.6922614055F, 0.6926958471F, 0.6931300459F, - 0.6935640018F, 0.6939977141F, 0.6944311825F, 0.6948644066F, - 0.6952973859F, 0.6957301200F, 0.6961626085F, 0.6965948510F, - 0.6970268470F, 0.6974585961F, 0.6978900980F, 0.6983213521F, - 0.6987523580F, 0.6991831154F, 0.6996136238F, 0.7000438828F, - 0.7004738921F, 0.7009036510F, 0.7013331594F, 0.7017624166F, - 0.7021914224F, 0.7026201763F, 0.7030486779F, 0.7034769268F, - 0.7039049226F, 0.7043326648F, 0.7047601531F, 0.7051873870F, - 0.7056143662F, 0.7060410902F, 0.7064675586F, 0.7068937711F, - 0.7073197271F, 0.7077454264F, 0.7081708684F, 0.7085960529F, - 0.7090209793F, 0.7094456474F, 0.7098700566F, 0.7102942066F, - 0.7107180970F, 0.7111417274F, 0.7115650974F, 0.7119882066F, - 0.7124110545F, 0.7128336409F, 0.7132559653F, 0.7136780272F, - 0.7140998264F, 0.7145213624F, 0.7149426348F, 0.7153636433F, - 0.7157843874F, 0.7162048668F, 0.7166250810F, 0.7170450296F, - 0.7174647124F, 0.7178841289F, 0.7183032786F, 0.7187221613F, - 0.7191407765F, 0.7195591239F, 0.7199772030F, 0.7203950135F, - 0.7208125550F, 0.7212298271F, 0.7216468294F, 0.7220635616F, - 0.7224800233F, 0.7228962140F, 0.7233121335F, 0.7237277813F, - 0.7241431571F, 0.7245582604F, 0.7249730910F, 0.7253876484F, - 0.7258019322F, 0.7262159422F, 0.7266296778F, 0.7270431388F, - 0.7274563247F, 0.7278692353F, 0.7282818700F, 0.7286942287F, - 0.7291063108F, 0.7295181160F, 0.7299296440F, 0.7303408944F, - 0.7307518669F, 0.7311625609F, 0.7315729763F, 0.7319831126F, - 0.7323929695F, 0.7328025466F, 0.7332118435F, 0.7336208600F, - 0.7340295955F, 0.7344380499F, 0.7348462226F, 0.7352541134F, - 0.7356617220F, 0.7360690478F, 0.7364760907F, 0.7368828502F, - 0.7372893259F, 0.7376955176F, 0.7381014249F, 0.7385070475F, - 0.7389123849F, 0.7393174368F, 0.7397222029F, 0.7401266829F, - 0.7405308763F, 0.7409347829F, 0.7413384023F, 0.7417417341F, - 0.7421447780F, 0.7425475338F, 0.7429500009F, 0.7433521791F, - 0.7437540681F, 0.7441556674F, 0.7445569769F, 0.7449579960F, - 0.7453587245F, 0.7457591621F, 0.7461593084F, 0.7465591631F, - 0.7469587259F, 0.7473579963F, 0.7477569741F, 0.7481556590F, - 0.7485540506F, 0.7489521486F, 0.7493499526F, 0.7497474623F, - 0.7501446775F, 0.7505415977F, 0.7509382227F, 0.7513345521F, - 0.7517305856F, 0.7521263229F, 0.7525217636F, 0.7529169074F, - 0.7533117541F, 0.7537063032F, 0.7541005545F, 0.7544945076F, - 0.7548881623F, 0.7552815182F, 0.7556745749F, 0.7560673323F, - 0.7564597899F, 0.7568519474F, 0.7572438046F, 0.7576353611F, - 0.7580266166F, 0.7584175708F, 0.7588082235F, 0.7591985741F, - 0.7595886226F, 0.7599783685F, 0.7603678116F, 0.7607569515F, - 0.7611457879F, 0.7615343206F, 0.7619225493F, 0.7623104735F, - 0.7626980931F, 0.7630854078F, 0.7634724171F, 0.7638591209F, - 0.7642455188F, 0.7646316106F, 0.7650173959F, 0.7654028744F, - 0.7657880459F, 0.7661729100F, 0.7665574664F, 0.7669417150F, - 0.7673256553F, 0.7677092871F, 0.7680926100F, 0.7684756239F, - 0.7688583284F, 0.7692407232F, 0.7696228080F, 0.7700045826F, - 0.7703860467F, 0.7707671999F, 0.7711480420F, 0.7715285728F, - 0.7719087918F, 0.7722886989F, 0.7726682938F, 0.7730475762F, - 0.7734265458F, 0.7738052023F, 0.7741835454F, 0.7745615750F, - 0.7749392906F, 0.7753166921F, 0.7756937791F, 0.7760705514F, - 0.7764470087F, 0.7768231508F, 0.7771989773F, 0.7775744880F, - 0.7779496827F, 0.7783245610F, 0.7786991227F, 0.7790733676F, - 0.7794472953F, 0.7798209056F, 0.7801941982F, 0.7805671729F, - 0.7809398294F, 0.7813121675F, 0.7816841869F, 0.7820558873F, - 0.7824272684F, 0.7827983301F, 0.7831690720F, 0.7835394940F, - 0.7839095957F, 0.7842793768F, 0.7846488373F, 0.7850179767F, - 0.7853867948F, 0.7857552914F, 0.7861234663F, 0.7864913191F, - 0.7868588497F, 0.7872260578F, 0.7875929431F, 0.7879595055F, - 0.7883257445F, 0.7886916601F, 0.7890572520F, 0.7894225198F, - 0.7897874635F, 0.7901520827F, 0.7905163772F, 0.7908803468F, - 0.7912439912F, 0.7916073102F, 0.7919703035F, 0.7923329710F, - 0.7926953124F, 0.7930573274F, 0.7934190158F, 0.7937803774F, - 0.7941414120F, 0.7945021193F, 0.7948624991F, 0.7952225511F, - 0.7955822752F, 0.7959416711F, 0.7963007387F, 0.7966594775F, - 0.7970178875F, 0.7973759685F, 0.7977337201F, 0.7980911422F, - 0.7984482346F, 0.7988049970F, 0.7991614292F, 0.7995175310F, - 0.7998733022F, 0.8002287426F, 0.8005838519F, 0.8009386299F, - 0.8012930765F, 0.8016471914F, 0.8020009744F, 0.8023544253F, - 0.8027075438F, 0.8030603298F, 0.8034127831F, 0.8037649035F, - 0.8041166906F, 0.8044681445F, 0.8048192647F, 0.8051700512F, - 0.8055205038F, 0.8058706222F, 0.8062204062F, 0.8065698556F, - 0.8069189702F, 0.8072677499F, 0.8076161944F, 0.8079643036F, - 0.8083120772F, 0.8086595151F, 0.8090066170F, 0.8093533827F, - 0.8096998122F, 0.8100459051F, 0.8103916613F, 0.8107370806F, - 0.8110821628F, 0.8114269077F, 0.8117713151F, 0.8121153849F, - 0.8124591169F, 0.8128025108F, 0.8131455666F, 0.8134882839F, - 0.8138306627F, 0.8141727027F, 0.8145144038F, 0.8148557658F, - 0.8151967886F, 0.8155374718F, 0.8158778154F, 0.8162178192F, - 0.8165574830F, 0.8168968067F, 0.8172357900F, 0.8175744328F, - 0.8179127349F, 0.8182506962F, 0.8185883164F, 0.8189255955F, - 0.8192625332F, 0.8195991295F, 0.8199353840F, 0.8202712967F, - 0.8206068673F, 0.8209420958F, 0.8212769820F, 0.8216115256F, - 0.8219457266F, 0.8222795848F, 0.8226131000F, 0.8229462721F, - 0.8232791009F, 0.8236115863F, 0.8239437280F, 0.8242755260F, - 0.8246069801F, 0.8249380901F, 0.8252688559F, 0.8255992774F, - 0.8259293544F, 0.8262590867F, 0.8265884741F, 0.8269175167F, - 0.8272462141F, 0.8275745663F, 0.8279025732F, 0.8282302344F, - 0.8285575501F, 0.8288845199F, 0.8292111437F, 0.8295374215F, - 0.8298633530F, 0.8301889382F, 0.8305141768F, 0.8308390688F, - 0.8311636141F, 0.8314878124F, 0.8318116637F, 0.8321351678F, - 0.8324583246F, 0.8327811340F, 0.8331035957F, 0.8334257098F, - 0.8337474761F, 0.8340688944F, 0.8343899647F, 0.8347106867F, - 0.8350310605F, 0.8353510857F, 0.8356707624F, 0.8359900904F, - 0.8363090696F, 0.8366276999F, 0.8369459811F, 0.8372639131F, - 0.8375814958F, 0.8378987292F, 0.8382156130F, 0.8385321472F, - 0.8388483316F, 0.8391641662F, 0.8394796508F, 0.8397947853F, - 0.8401095697F, 0.8404240037F, 0.8407380873F, 0.8410518204F, - 0.8413652029F, 0.8416782347F, 0.8419909156F, 0.8423032456F, - 0.8426152245F, 0.8429268523F, 0.8432381289F, 0.8435490541F, - 0.8438596279F, 0.8441698502F, 0.8444797208F, 0.8447892396F, - 0.8450984067F, 0.8454072218F, 0.8457156849F, 0.8460237959F, - 0.8463315547F, 0.8466389612F, 0.8469460154F, 0.8472527170F, - 0.8475590661F, 0.8478650625F, 0.8481707063F, 0.8484759971F, - 0.8487809351F, 0.8490855201F, 0.8493897521F, 0.8496936308F, - 0.8499971564F, 0.8503003286F, 0.8506031474F, 0.8509056128F, - 0.8512077246F, 0.8515094828F, 0.8518108872F, 0.8521119379F, - 0.8524126348F, 0.8527129777F, 0.8530129666F, 0.8533126015F, - 0.8536118822F, 0.8539108087F, 0.8542093809F, 0.8545075988F, - 0.8548054623F, 0.8551029712F, 0.8554001257F, 0.8556969255F, - 0.8559933707F, 0.8562894611F, 0.8565851968F, 0.8568805775F, - 0.8571756034F, 0.8574702743F, 0.8577645902F, 0.8580585509F, - 0.8583521566F, 0.8586454070F, 0.8589383021F, 0.8592308420F, - 0.8595230265F, 0.8598148556F, 0.8601063292F, 0.8603974473F, - 0.8606882098F, 0.8609786167F, 0.8612686680F, 0.8615583636F, - 0.8618477034F, 0.8621366874F, 0.8624253156F, 0.8627135878F, - 0.8630015042F, 0.8632890646F, 0.8635762690F, 0.8638631173F, - 0.8641496096F, 0.8644357457F, 0.8647215257F, 0.8650069495F, - 0.8652920171F, 0.8655767283F, 0.8658610833F, 0.8661450820F, - 0.8664287243F, 0.8667120102F, 0.8669949397F, 0.8672775127F, - 0.8675597293F, 0.8678415894F, 0.8681230929F, 0.8684042398F, - 0.8686850302F, 0.8689654640F, 0.8692455412F, 0.8695252617F, - 0.8698046255F, 0.8700836327F, 0.8703622831F, 0.8706405768F, - 0.8709185138F, 0.8711960940F, 0.8714733174F, 0.8717501840F, - 0.8720266939F, 0.8723028469F, 0.8725786430F, 0.8728540824F, - 0.8731291648F, 0.8734038905F, 0.8736782592F, 0.8739522711F, - 0.8742259261F, 0.8744992242F, 0.8747721653F, 0.8750447496F, - 0.8753169770F, 0.8755888475F, 0.8758603611F, 0.8761315177F, - 0.8764023175F, 0.8766727603F, 0.8769428462F, 0.8772125752F, - 0.8774819474F, 0.8777509626F, 0.8780196209F, 0.8782879224F, - 0.8785558669F, 0.8788234546F, 0.8790906854F, 0.8793575594F, - 0.8796240765F, 0.8798902368F, 0.8801560403F, 0.8804214870F, - 0.8806865768F, 0.8809513099F, 0.8812156863F, 0.8814797059F, - 0.8817433687F, 0.8820066749F, 0.8822696243F, 0.8825322171F, - 0.8827944532F, 0.8830563327F, 0.8833178556F, 0.8835790219F, - 0.8838398316F, 0.8841002848F, 0.8843603815F, 0.8846201217F, - 0.8848795054F, 0.8851385327F, 0.8853972036F, 0.8856555182F, - 0.8859134764F, 0.8861710783F, 0.8864283239F, 0.8866852133F, - 0.8869417464F, 0.8871979234F, 0.8874537443F, 0.8877092090F, - 0.8879643177F, 0.8882190704F, 0.8884734671F, 0.8887275078F, - 0.8889811927F, 0.8892345216F, 0.8894874948F, 0.8897401122F, - 0.8899923738F, 0.8902442798F, 0.8904958301F, 0.8907470248F, - 0.8909978640F, 0.8912483477F, 0.8914984759F, 0.8917482487F, - 0.8919976662F, 0.8922467284F, 0.8924954353F, 0.8927437871F, - 0.8929917837F, 0.8932394252F, 0.8934867118F, 0.8937336433F, - 0.8939802199F, 0.8942264417F, 0.8944723087F, 0.8947178210F, - 0.8949629785F, 0.8952077815F, 0.8954522299F, 0.8956963239F, - 0.8959400634F, 0.8961834486F, 0.8964264795F, 0.8966691561F, - 0.8969114786F, 0.8971534470F, 0.8973950614F, 0.8976363219F, - 0.8978772284F, 0.8981177812F, 0.8983579802F, 0.8985978256F, - 0.8988373174F, 0.8990764556F, 0.8993152405F, 0.8995536720F, - 0.8997917502F, 0.9000294751F, 0.9002668470F, 0.9005038658F, - 0.9007405317F, 0.9009768446F, 0.9012128048F, 0.9014484123F, - 0.9016836671F, 0.9019185693F, 0.9021531191F, 0.9023873165F, - 0.9026211616F, 0.9028546546F, 0.9030877954F, 0.9033205841F, - 0.9035530210F, 0.9037851059F, 0.9040168392F, 0.9042482207F, - 0.9044792507F, 0.9047099293F, 0.9049402564F, 0.9051702323F, - 0.9053998569F, 0.9056291305F, 0.9058580531F, 0.9060866248F, - 0.9063148457F, 0.9065427159F, 0.9067702355F, 0.9069974046F, - 0.9072242233F, 0.9074506917F, 0.9076768100F, 0.9079025782F, - 0.9081279964F, 0.9083530647F, 0.9085777833F, 0.9088021523F, - 0.9090261717F, 0.9092498417F, 0.9094731623F, 0.9096961338F, - 0.9099187561F, 0.9101410295F, 0.9103629540F, 0.9105845297F, - 0.9108057568F, 0.9110266354F, 0.9112471656F, 0.9114673475F, - 0.9116871812F, 0.9119066668F, 0.9121258046F, 0.9123445945F, - 0.9125630367F, 0.9127811314F, 0.9129988786F, 0.9132162785F, - 0.9134333312F, 0.9136500368F, 0.9138663954F, 0.9140824073F, - 0.9142980724F, 0.9145133910F, 0.9147283632F, 0.9149429890F, - 0.9151572687F, 0.9153712023F, 0.9155847900F, 0.9157980319F, - 0.9160109282F, 0.9162234790F, 0.9164356844F, 0.9166475445F, - 0.9168590595F, 0.9170702296F, 0.9172810548F, 0.9174915354F, - 0.9177016714F, 0.9179114629F, 0.9181209102F, 0.9183300134F, - 0.9185387726F, 0.9187471879F, 0.9189552595F, 0.9191629876F, - 0.9193703723F, 0.9195774136F, 0.9197841119F, 0.9199904672F, - 0.9201964797F, 0.9204021495F, 0.9206074767F, 0.9208124616F, - 0.9210171043F, 0.9212214049F, 0.9214253636F, 0.9216289805F, - 0.9218322558F, 0.9220351896F, 0.9222377821F, 0.9224400335F, - 0.9226419439F, 0.9228435134F, 0.9230447423F, 0.9232456307F, - 0.9234461787F, 0.9236463865F, 0.9238462543F, 0.9240457822F, - 0.9242449704F, 0.9244438190F, 0.9246423282F, 0.9248404983F, - 0.9250383293F, 0.9252358214F, 0.9254329747F, 0.9256297896F, - 0.9258262660F, 0.9260224042F, 0.9262182044F, 0.9264136667F, - 0.9266087913F, 0.9268035783F, 0.9269980280F, 0.9271921405F, - 0.9273859160F, 0.9275793546F, 0.9277724566F, 0.9279652221F, - 0.9281576513F, 0.9283497443F, 0.9285415014F, 0.9287329227F, - 0.9289240084F, 0.9291147586F, 0.9293051737F, 0.9294952536F, - 0.9296849987F, 0.9298744091F, 0.9300634850F, 0.9302522266F, - 0.9304406340F, 0.9306287074F, 0.9308164471F, 0.9310038532F, - 0.9311909259F, 0.9313776654F, 0.9315640719F, 0.9317501455F, - 0.9319358865F, 0.9321212951F, 0.9323063713F, 0.9324911155F, - 0.9326755279F, 0.9328596085F, 0.9330433577F, 0.9332267756F, - 0.9334098623F, 0.9335926182F, 0.9337750434F, 0.9339571380F, - 0.9341389023F, 0.9343203366F, 0.9345014409F, 0.9346822155F, - 0.9348626606F, 0.9350427763F, 0.9352225630F, 0.9354020207F, - 0.9355811498F, 0.9357599503F, 0.9359384226F, 0.9361165667F, - 0.9362943830F, 0.9364718716F, 0.9366490327F, 0.9368258666F, - 0.9370023733F, 0.9371785533F, 0.9373544066F, 0.9375299335F, - 0.9377051341F, 0.9378800087F, 0.9380545576F, 0.9382287809F, - 0.9384026787F, 0.9385762515F, 0.9387494993F, 0.9389224223F, - 0.9390950209F, 0.9392672951F, 0.9394392453F, 0.9396108716F, - 0.9397821743F, 0.9399531536F, 0.9401238096F, 0.9402941427F, - 0.9404641530F, 0.9406338407F, 0.9408032061F, 0.9409722495F, - 0.9411409709F, 0.9413093707F, 0.9414774491F, 0.9416452062F, - 0.9418126424F, 0.9419797579F, 0.9421465528F, 0.9423130274F, - 0.9424791819F, 0.9426450166F, 0.9428105317F, 0.9429757274F, - 0.9431406039F, 0.9433051616F, 0.9434694005F, 0.9436333209F, - 0.9437969232F, 0.9439602074F, 0.9441231739F, 0.9442858229F, - 0.9444481545F, 0.9446101691F, 0.9447718669F, 0.9449332481F, - 0.9450943129F, 0.9452550617F, 0.9454154945F, 0.9455756118F, - 0.9457354136F, 0.9458949003F, 0.9460540721F, 0.9462129292F, - 0.9463714719F, 0.9465297003F, 0.9466876149F, 0.9468452157F, - 0.9470025031F, 0.9471594772F, 0.9473161384F, 0.9474724869F, - 0.9476285229F, 0.9477842466F, 0.9479396584F, 0.9480947585F, - 0.9482495470F, 0.9484040243F, 0.9485581906F, 0.9487120462F, - 0.9488655913F, 0.9490188262F, 0.9491717511F, 0.9493243662F, - 0.9494766718F, 0.9496286683F, 0.9497803557F, 0.9499317345F, - 0.9500828047F, 0.9502335668F, 0.9503840209F, 0.9505341673F, - 0.9506840062F, 0.9508335380F, 0.9509827629F, 0.9511316810F, - 0.9512802928F, 0.9514285984F, 0.9515765982F, 0.9517242923F, - 0.9518716810F, 0.9520187646F, 0.9521655434F, 0.9523120176F, - 0.9524581875F, 0.9526040534F, 0.9527496154F, 0.9528948739F, - 0.9530398292F, 0.9531844814F, 0.9533288310F, 0.9534728780F, - 0.9536166229F, 0.9537600659F, 0.9539032071F, 0.9540460470F, - 0.9541885858F, 0.9543308237F, 0.9544727611F, 0.9546143981F, - 0.9547557351F, 0.9548967723F, 0.9550375100F, 0.9551779485F, - 0.9553180881F, 0.9554579290F, 0.9555974714F, 0.9557367158F, - 0.9558756623F, 0.9560143112F, 0.9561526628F, 0.9562907174F, - 0.9564284752F, 0.9565659366F, 0.9567031017F, 0.9568399710F, - 0.9569765446F, 0.9571128229F, 0.9572488061F, 0.9573844944F, - 0.9575198883F, 0.9576549879F, 0.9577897936F, 0.9579243056F, - 0.9580585242F, 0.9581924497F, 0.9583260824F, 0.9584594226F, - 0.9585924705F, 0.9587252264F, 0.9588576906F, 0.9589898634F, - 0.9591217452F, 0.9592533360F, 0.9593846364F, 0.9595156465F, - 0.9596463666F, 0.9597767971F, 0.9599069382F, 0.9600367901F, - 0.9601663533F, 0.9602956279F, 0.9604246143F, 0.9605533128F, - 0.9606817236F, 0.9608098471F, 0.9609376835F, 0.9610652332F, - 0.9611924963F, 0.9613194733F, 0.9614461644F, 0.9615725699F, - 0.9616986901F, 0.9618245253F, 0.9619500757F, 0.9620753418F, - 0.9622003238F, 0.9623250219F, 0.9624494365F, 0.9625735679F, - 0.9626974163F, 0.9628209821F, 0.9629442656F, 0.9630672671F, - 0.9631899868F, 0.9633124251F, 0.9634345822F, 0.9635564585F, - 0.9636780543F, 0.9637993699F, 0.9639204056F, 0.9640411616F, - 0.9641616383F, 0.9642818359F, 0.9644017549F, 0.9645213955F, - 0.9646407579F, 0.9647598426F, 0.9648786497F, 0.9649971797F, - 0.9651154328F, 0.9652334092F, 0.9653511095F, 0.9654685337F, - 0.9655856823F, 0.9657025556F, 0.9658191538F, 0.9659354773F, - 0.9660515263F, 0.9661673013F, 0.9662828024F, 0.9663980300F, - 0.9665129845F, 0.9666276660F, 0.9667420750F, 0.9668562118F, - 0.9669700766F, 0.9670836698F, 0.9671969917F, 0.9673100425F, - 0.9674228227F, 0.9675353325F, 0.9676475722F, 0.9677595422F, - 0.9678712428F, 0.9679826742F, 0.9680938368F, 0.9682047309F, - 0.9683153569F, 0.9684257150F, 0.9685358056F, 0.9686456289F, - 0.9687551853F, 0.9688644752F, 0.9689734987F, 0.9690822564F, - 0.9691907483F, 0.9692989750F, 0.9694069367F, 0.9695146337F, - 0.9696220663F, 0.9697292349F, 0.9698361398F, 0.9699427813F, - 0.9700491597F, 0.9701552754F, 0.9702611286F, 0.9703667197F, - 0.9704720490F, 0.9705771169F, 0.9706819236F, 0.9707864695F, - 0.9708907549F, 0.9709947802F, 0.9710985456F, 0.9712020514F, - 0.9713052981F, 0.9714082859F, 0.9715110151F, 0.9716134862F, - 0.9717156993F, 0.9718176549F, 0.9719193532F, 0.9720207946F, - 0.9721219794F, 0.9722229080F, 0.9723235806F, 0.9724239976F, - 0.9725241593F, 0.9726240661F, 0.9727237183F, 0.9728231161F, - 0.9729222601F, 0.9730211503F, 0.9731197873F, 0.9732181713F, - 0.9733163027F, 0.9734141817F, 0.9735118088F, 0.9736091842F, - 0.9737063083F, 0.9738031814F, 0.9738998039F, 0.9739961760F, - 0.9740922981F, 0.9741881706F, 0.9742837938F, 0.9743791680F, - 0.9744742935F, 0.9745691707F, 0.9746637999F, 0.9747581814F, - 0.9748523157F, 0.9749462029F, 0.9750398435F, 0.9751332378F, - 0.9752263861F, 0.9753192887F, 0.9754119461F, 0.9755043585F, - 0.9755965262F, 0.9756884496F, 0.9757801291F, 0.9758715650F, - 0.9759627575F, 0.9760537071F, 0.9761444141F, 0.9762348789F, - 0.9763251016F, 0.9764150828F, 0.9765048228F, 0.9765943218F, - 0.9766835802F, 0.9767725984F, 0.9768613767F, 0.9769499154F, - 0.9770382149F, 0.9771262755F, 0.9772140976F, 0.9773016815F, - 0.9773890275F, 0.9774761360F, 0.9775630073F, 0.9776496418F, - 0.9777360398F, 0.9778222016F, 0.9779081277F, 0.9779938182F, - 0.9780792736F, 0.9781644943F, 0.9782494805F, 0.9783342326F, - 0.9784187509F, 0.9785030359F, 0.9785870877F, 0.9786709069F, - 0.9787544936F, 0.9788378484F, 0.9789209714F, 0.9790038631F, - 0.9790865238F, 0.9791689538F, 0.9792511535F, 0.9793331232F, - 0.9794148633F, 0.9794963742F, 0.9795776561F, 0.9796587094F, - 0.9797395345F, 0.9798201316F, 0.9799005013F, 0.9799806437F, - 0.9800605593F, 0.9801402483F, 0.9802197112F, 0.9802989483F, - 0.9803779600F, 0.9804567465F, 0.9805353082F, 0.9806136455F, - 0.9806917587F, 0.9807696482F, 0.9808473143F, 0.9809247574F, - 0.9810019778F, 0.9810789759F, 0.9811557519F, 0.9812323064F, - 0.9813086395F, 0.9813847517F, 0.9814606433F, 0.9815363147F, - 0.9816117662F, 0.9816869981F, 0.9817620108F, 0.9818368047F, - 0.9819113801F, 0.9819857374F, 0.9820598769F, 0.9821337989F, - 0.9822075038F, 0.9822809920F, 0.9823542638F, 0.9824273195F, - 0.9825001596F, 0.9825727843F, 0.9826451940F, 0.9827173891F, - 0.9827893700F, 0.9828611368F, 0.9829326901F, 0.9830040302F, - 0.9830751574F, 0.9831460720F, 0.9832167745F, 0.9832872652F, - 0.9833575444F, 0.9834276124F, 0.9834974697F, 0.9835671166F, - 0.9836365535F, 0.9837057806F, 0.9837747983F, 0.9838436071F, - 0.9839122072F, 0.9839805990F, 0.9840487829F, 0.9841167591F, - 0.9841845282F, 0.9842520903F, 0.9843194459F, 0.9843865953F, - 0.9844535389F, 0.9845202771F, 0.9845868101F, 0.9846531383F, - 0.9847192622F, 0.9847851820F, 0.9848508980F, 0.9849164108F, - 0.9849817205F, 0.9850468276F, 0.9851117324F, 0.9851764352F, - 0.9852409365F, 0.9853052366F, 0.9853693358F, 0.9854332344F, - 0.9854969330F, 0.9855604317F, 0.9856237309F, 0.9856868310F, - 0.9857497325F, 0.9858124355F, 0.9858749404F, 0.9859372477F, - 0.9859993577F, 0.9860612707F, 0.9861229871F, 0.9861845072F, - 0.9862458315F, 0.9863069601F, 0.9863678936F, 0.9864286322F, - 0.9864891764F, 0.9865495264F, 0.9866096826F, 0.9866696454F, - 0.9867294152F, 0.9867889922F, 0.9868483769F, 0.9869075695F, - 0.9869665706F, 0.9870253803F, 0.9870839991F, 0.9871424273F, - 0.9872006653F, 0.9872587135F, 0.9873165721F, 0.9873742415F, - 0.9874317222F, 0.9874890144F, 0.9875461185F, 0.9876030348F, - 0.9876597638F, 0.9877163057F, 0.9877726610F, 0.9878288300F, - 0.9878848130F, 0.9879406104F, 0.9879962225F, 0.9880516497F, - 0.9881068924F, 0.9881619509F, 0.9882168256F, 0.9882715168F, - 0.9883260249F, 0.9883803502F, 0.9884344931F, 0.9884884539F, - 0.9885422331F, 0.9885958309F, 0.9886492477F, 0.9887024838F, - 0.9887555397F, 0.9888084157F, 0.9888611120F, 0.9889136292F, - 0.9889659675F, 0.9890181273F, 0.9890701089F, 0.9891219128F, - 0.9891735392F, 0.9892249885F, 0.9892762610F, 0.9893273572F, - 0.9893782774F, 0.9894290219F, 0.9894795911F, 0.9895299853F, - 0.9895802049F, 0.9896302502F, 0.9896801217F, 0.9897298196F, - 0.9897793443F, 0.9898286961F, 0.9898778755F, 0.9899268828F, - 0.9899757183F, 0.9900243823F, 0.9900728753F, 0.9901211976F, - 0.9901693495F, 0.9902173314F, 0.9902651436F, 0.9903127865F, - 0.9903602605F, 0.9904075659F, 0.9904547031F, 0.9905016723F, - 0.9905484740F, 0.9905951086F, 0.9906415763F, 0.9906878775F, - 0.9907340126F, 0.9907799819F, 0.9908257858F, 0.9908714247F, - 0.9909168988F, 0.9909622086F, 0.9910073543F, 0.9910523364F, - 0.9910971552F, 0.9911418110F, 0.9911863042F, 0.9912306351F, - 0.9912748042F, 0.9913188117F, 0.9913626580F, 0.9914063435F, - 0.9914498684F, 0.9914932333F, 0.9915364383F, 0.9915794839F, - 0.9916223703F, 0.9916650981F, 0.9917076674F, 0.9917500787F, - 0.9917923323F, 0.9918344286F, 0.9918763679F, 0.9919181505F, - 0.9919597769F, 0.9920012473F, 0.9920425621F, 0.9920837217F, - 0.9921247263F, 0.9921655765F, 0.9922062724F, 0.9922468145F, - 0.9922872030F, 0.9923274385F, 0.9923675211F, 0.9924074513F, - 0.9924472294F, 0.9924868557F, 0.9925263306F, 0.9925656544F, - 0.9926048275F, 0.9926438503F, 0.9926827230F, 0.9927214461F, - 0.9927600199F, 0.9927984446F, 0.9928367208F, 0.9928748486F, - 0.9929128285F, 0.9929506608F, 0.9929883459F, 0.9930258841F, - 0.9930632757F, 0.9931005211F, 0.9931376207F, 0.9931745747F, - 0.9932113836F, 0.9932480476F, 0.9932845671F, 0.9933209425F, - 0.9933571742F, 0.9933932623F, 0.9934292074F, 0.9934650097F, - 0.9935006696F, 0.9935361874F, 0.9935715635F, 0.9936067982F, - 0.9936418919F, 0.9936768448F, 0.9937116574F, 0.9937463300F, - 0.9937808629F, 0.9938152565F, 0.9938495111F, 0.9938836271F, - 0.9939176047F, 0.9939514444F, 0.9939851465F, 0.9940187112F, - 0.9940521391F, 0.9940854303F, 0.9941185853F, 0.9941516044F, - 0.9941844879F, 0.9942172361F, 0.9942498495F, 0.9942823283F, - 0.9943146729F, 0.9943468836F, 0.9943789608F, 0.9944109047F, - 0.9944427158F, 0.9944743944F, 0.9945059408F, 0.9945373553F, - 0.9945686384F, 0.9945997902F, 0.9946308112F, 0.9946617017F, - 0.9946924621F, 0.9947230926F, 0.9947535937F, 0.9947839656F, - 0.9948142086F, 0.9948443232F, 0.9948743097F, 0.9949041683F, - 0.9949338995F, 0.9949635035F, 0.9949929807F, 0.9950223315F, - 0.9950515561F, 0.9950806549F, 0.9951096282F, 0.9951384764F, - 0.9951671998F, 0.9951957987F, 0.9952242735F, 0.9952526245F, - 0.9952808520F, 0.9953089564F, 0.9953369380F, 0.9953647971F, - 0.9953925340F, 0.9954201491F, 0.9954476428F, 0.9954750153F, - 0.9955022670F, 0.9955293981F, 0.9955564092F, 0.9955833003F, - 0.9956100720F, 0.9956367245F, 0.9956632582F, 0.9956896733F, - 0.9957159703F, 0.9957421494F, 0.9957682110F, 0.9957941553F, - 0.9958199828F, 0.9958456937F, 0.9958712884F, 0.9958967672F, - 0.9959221305F, 0.9959473784F, 0.9959725115F, 0.9959975300F, - 0.9960224342F, 0.9960472244F, 0.9960719011F, 0.9960964644F, - 0.9961209148F, 0.9961452525F, 0.9961694779F, 0.9961935913F, - 0.9962175930F, 0.9962414834F, 0.9962652627F, 0.9962889313F, - 0.9963124895F, 0.9963359377F, 0.9963592761F, 0.9963825051F, - 0.9964056250F, 0.9964286361F, 0.9964515387F, 0.9964743332F, - 0.9964970198F, 0.9965195990F, 0.9965420709F, 0.9965644360F, - 0.9965866946F, 0.9966088469F, 0.9966308932F, 0.9966528340F, - 0.9966746695F, 0.9966964001F, 0.9967180260F, 0.9967395475F, - 0.9967609651F, 0.9967822789F, 0.9968034894F, 0.9968245968F, - 0.9968456014F, 0.9968665036F, 0.9968873037F, 0.9969080019F, - 0.9969285987F, 0.9969490942F, 0.9969694889F, 0.9969897830F, - 0.9970099769F, 0.9970300708F, 0.9970500651F, 0.9970699601F, - 0.9970897561F, 0.9971094533F, 0.9971290522F, 0.9971485531F, - 0.9971679561F, 0.9971872617F, 0.9972064702F, 0.9972255818F, - 0.9972445968F, 0.9972635157F, 0.9972823386F, 0.9973010659F, - 0.9973196980F, 0.9973382350F, 0.9973566773F, 0.9973750253F, - 0.9973932791F, 0.9974114392F, 0.9974295059F, 0.9974474793F, - 0.9974653599F, 0.9974831480F, 0.9975008438F, 0.9975184476F, - 0.9975359598F, 0.9975533806F, 0.9975707104F, 0.9975879495F, - 0.9976050981F, 0.9976221566F, 0.9976391252F, 0.9976560043F, - 0.9976727941F, 0.9976894950F, 0.9977061073F, 0.9977226312F, - 0.9977390671F, 0.9977554152F, 0.9977716759F, 0.9977878495F, - 0.9978039361F, 0.9978199363F, 0.9978358501F, 0.9978516780F, - 0.9978674202F, 0.9978830771F, 0.9978986488F, 0.9979141358F, - 0.9979295383F, 0.9979448566F, 0.9979600909F, 0.9979752417F, - 0.9979903091F, 0.9980052936F, 0.9980201952F, 0.9980350145F, - 0.9980497515F, 0.9980644067F, 0.9980789804F, 0.9980934727F, - 0.9981078841F, 0.9981222147F, 0.9981364649F, 0.9981506350F, - 0.9981647253F, 0.9981787360F, 0.9981926674F, 0.9982065199F, - 0.9982202936F, 0.9982339890F, 0.9982476062F, 0.9982611456F, - 0.9982746074F, 0.9982879920F, 0.9983012996F, 0.9983145304F, - 0.9983276849F, 0.9983407632F, 0.9983537657F, 0.9983666926F, - 0.9983795442F, 0.9983923208F, 0.9984050226F, 0.9984176501F, - 0.9984302033F, 0.9984426827F, 0.9984550884F, 0.9984674208F, - 0.9984796802F, 0.9984918667F, 0.9985039808F, 0.9985160227F, - 0.9985279926F, 0.9985398909F, 0.9985517177F, 0.9985634734F, - 0.9985751583F, 0.9985867727F, 0.9985983167F, 0.9986097907F, - 0.9986211949F, 0.9986325297F, 0.9986437953F, 0.9986549919F, - 0.9986661199F, 0.9986771795F, 0.9986881710F, 0.9986990946F, - 0.9987099507F, 0.9987207394F, 0.9987314611F, 0.9987421161F, - 0.9987527045F, 0.9987632267F, 0.9987736829F, 0.9987840734F, - 0.9987943985F, 0.9988046584F, 0.9988148534F, 0.9988249838F, - 0.9988350498F, 0.9988450516F, 0.9988549897F, 0.9988648641F, - 0.9988746753F, 0.9988844233F, 0.9988941086F, 0.9989037313F, - 0.9989132918F, 0.9989227902F, 0.9989322269F, 0.9989416021F, - 0.9989509160F, 0.9989601690F, 0.9989693613F, 0.9989784931F, - 0.9989875647F, 0.9989965763F, 0.9990055283F, 0.9990144208F, - 0.9990232541F, 0.9990320286F, 0.9990407443F, 0.9990494016F, - 0.9990580008F, 0.9990665421F, 0.9990750257F, 0.9990834519F, - 0.9990918209F, 0.9991001331F, 0.9991083886F, 0.9991165877F, - 0.9991247307F, 0.9991328177F, 0.9991408491F, 0.9991488251F, - 0.9991567460F, 0.9991646119F, 0.9991724232F, 0.9991801801F, - 0.9991878828F, 0.9991955316F, 0.9992031267F, 0.9992106684F, - 0.9992181569F, 0.9992255925F, 0.9992329753F, 0.9992403057F, - 0.9992475839F, 0.9992548101F, 0.9992619846F, 0.9992691076F, - 0.9992761793F, 0.9992832001F, 0.9992901701F, 0.9992970895F, - 0.9993039587F, 0.9993107777F, 0.9993175470F, 0.9993242667F, - 0.9993309371F, 0.9993375583F, 0.9993441307F, 0.9993506545F, - 0.9993571298F, 0.9993635570F, 0.9993699362F, 0.9993762678F, - 0.9993825519F, 0.9993887887F, 0.9993949785F, 0.9994011216F, - 0.9994072181F, 0.9994132683F, 0.9994192725F, 0.9994252307F, - 0.9994311434F, 0.9994370107F, 0.9994428327F, 0.9994486099F, - 0.9994543423F, 0.9994600303F, 0.9994656739F, 0.9994712736F, - 0.9994768294F, 0.9994823417F, 0.9994878105F, 0.9994932363F, - 0.9994986191F, 0.9995039592F, 0.9995092568F, 0.9995145122F, - 0.9995197256F, 0.9995248971F, 0.9995300270F, 0.9995351156F, - 0.9995401630F, 0.9995451695F, 0.9995501352F, 0.9995550604F, - 0.9995599454F, 0.9995647903F, 0.9995695953F, 0.9995743607F, - 0.9995790866F, 0.9995837734F, 0.9995884211F, 0.9995930300F, - 0.9995976004F, 0.9996021324F, 0.9996066263F, 0.9996110822F, - 0.9996155004F, 0.9996198810F, 0.9996242244F, 0.9996285306F, - 0.9996327999F, 0.9996370326F, 0.9996412287F, 0.9996453886F, - 0.9996495125F, 0.9996536004F, 0.9996576527F, 0.9996616696F, - 0.9996656512F, 0.9996695977F, 0.9996735094F, 0.9996773865F, - 0.9996812291F, 0.9996850374F, 0.9996888118F, 0.9996925523F, - 0.9996962591F, 0.9996999325F, 0.9997035727F, 0.9997071798F, - 0.9997107541F, 0.9997142957F, 0.9997178049F, 0.9997212818F, - 0.9997247266F, 0.9997281396F, 0.9997315209F, 0.9997348708F, - 0.9997381893F, 0.9997414767F, 0.9997447333F, 0.9997479591F, - 0.9997511544F, 0.9997543194F, 0.9997574542F, 0.9997605591F, - 0.9997636342F, 0.9997666797F, 0.9997696958F, 0.9997726828F, - 0.9997756407F, 0.9997785698F, 0.9997814703F, 0.9997843423F, - 0.9997871860F, 0.9997900016F, 0.9997927894F, 0.9997955494F, - 0.9997982818F, 0.9998009869F, 0.9998036648F, 0.9998063157F, - 0.9998089398F, 0.9998115373F, 0.9998141082F, 0.9998166529F, - 0.9998191715F, 0.9998216642F, 0.9998241311F, 0.9998265724F, - 0.9998289884F, 0.9998313790F, 0.9998337447F, 0.9998360854F, - 0.9998384015F, 0.9998406930F, 0.9998429602F, 0.9998452031F, - 0.9998474221F, 0.9998496171F, 0.9998517885F, 0.9998539364F, - 0.9998560610F, 0.9998581624F, 0.9998602407F, 0.9998622962F, - 0.9998643291F, 0.9998663394F, 0.9998683274F, 0.9998702932F, - 0.9998722370F, 0.9998741589F, 0.9998760591F, 0.9998779378F, - 0.9998797952F, 0.9998816313F, 0.9998834464F, 0.9998852406F, - 0.9998870141F, 0.9998887670F, 0.9998904995F, 0.9998922117F, - 0.9998939039F, 0.9998955761F, 0.9998972285F, 0.9998988613F, - 0.9999004746F, 0.9999020686F, 0.9999036434F, 0.9999051992F, - 0.9999067362F, 0.9999082544F, 0.9999097541F, 0.9999112354F, - 0.9999126984F, 0.9999141433F, 0.9999155703F, 0.9999169794F, - 0.9999183709F, 0.9999197449F, 0.9999211014F, 0.9999224408F, - 0.9999237631F, 0.9999250684F, 0.9999263570F, 0.9999276289F, - 0.9999288843F, 0.9999301233F, 0.9999313461F, 0.9999325529F, - 0.9999337437F, 0.9999349187F, 0.9999360780F, 0.9999372218F, - 0.9999383503F, 0.9999394635F, 0.9999405616F, 0.9999416447F, - 0.9999427129F, 0.9999437665F, 0.9999448055F, 0.9999458301F, - 0.9999468404F, 0.9999478365F, 0.9999488185F, 0.9999497867F, - 0.9999507411F, 0.9999516819F, 0.9999526091F, 0.9999535230F, - 0.9999544236F, 0.9999553111F, 0.9999561856F, 0.9999570472F, - 0.9999578960F, 0.9999587323F, 0.9999595560F, 0.9999603674F, - 0.9999611666F, 0.9999619536F, 0.9999627286F, 0.9999634917F, - 0.9999642431F, 0.9999649828F, 0.9999657110F, 0.9999664278F, - 0.9999671334F, 0.9999678278F, 0.9999685111F, 0.9999691835F, - 0.9999698451F, 0.9999704960F, 0.9999711364F, 0.9999717662F, - 0.9999723858F, 0.9999729950F, 0.9999735942F, 0.9999741834F, - 0.9999747626F, 0.9999753321F, 0.9999758919F, 0.9999764421F, - 0.9999769828F, 0.9999775143F, 0.9999780364F, 0.9999785495F, - 0.9999790535F, 0.9999795485F, 0.9999800348F, 0.9999805124F, - 0.9999809813F, 0.9999814417F, 0.9999818938F, 0.9999823375F, - 0.9999827731F, 0.9999832005F, 0.9999836200F, 0.9999840316F, - 0.9999844353F, 0.9999848314F, 0.9999852199F, 0.9999856008F, - 0.9999859744F, 0.9999863407F, 0.9999866997F, 0.9999870516F, - 0.9999873965F, 0.9999877345F, 0.9999880656F, 0.9999883900F, - 0.9999887078F, 0.9999890190F, 0.9999893237F, 0.9999896220F, - 0.9999899140F, 0.9999901999F, 0.9999904796F, 0.9999907533F, - 0.9999910211F, 0.9999912830F, 0.9999915391F, 0.9999917896F, - 0.9999920345F, 0.9999922738F, 0.9999925077F, 0.9999927363F, - 0.9999929596F, 0.9999931777F, 0.9999933907F, 0.9999935987F, - 0.9999938018F, 0.9999940000F, 0.9999941934F, 0.9999943820F, - 0.9999945661F, 0.9999947456F, 0.9999949206F, 0.9999950912F, - 0.9999952575F, 0.9999954195F, 0.9999955773F, 0.9999957311F, - 0.9999958807F, 0.9999960265F, 0.9999961683F, 0.9999963063F, - 0.9999964405F, 0.9999965710F, 0.9999966979F, 0.9999968213F, - 0.9999969412F, 0.9999970576F, 0.9999971707F, 0.9999972805F, - 0.9999973871F, 0.9999974905F, 0.9999975909F, 0.9999976881F, - 0.9999977824F, 0.9999978738F, 0.9999979624F, 0.9999980481F, - 0.9999981311F, 0.9999982115F, 0.9999982892F, 0.9999983644F, - 0.9999984370F, 0.9999985072F, 0.9999985750F, 0.9999986405F, - 0.9999987037F, 0.9999987647F, 0.9999988235F, 0.9999988802F, - 0.9999989348F, 0.9999989873F, 0.9999990379F, 0.9999990866F, - 0.9999991334F, 0.9999991784F, 0.9999992217F, 0.9999992632F, - 0.9999993030F, 0.9999993411F, 0.9999993777F, 0.9999994128F, - 0.9999994463F, 0.9999994784F, 0.9999995091F, 0.9999995384F, - 0.9999995663F, 0.9999995930F, 0.9999996184F, 0.9999996426F, - 0.9999996657F, 0.9999996876F, 0.9999997084F, 0.9999997282F, - 0.9999997469F, 0.9999997647F, 0.9999997815F, 0.9999997973F, - 0.9999998123F, 0.9999998265F, 0.9999998398F, 0.9999998524F, - 0.9999998642F, 0.9999998753F, 0.9999998857F, 0.9999998954F, - 0.9999999045F, 0.9999999130F, 0.9999999209F, 0.9999999282F, - 0.9999999351F, 0.9999999414F, 0.9999999472F, 0.9999999526F, - 0.9999999576F, 0.9999999622F, 0.9999999664F, 0.9999999702F, - 0.9999999737F, 0.9999999769F, 0.9999999798F, 0.9999999824F, - 0.9999999847F, 0.9999999868F, 0.9999999887F, 0.9999999904F, - 0.9999999919F, 0.9999999932F, 0.9999999943F, 0.9999999953F, - 0.9999999961F, 0.9999999969F, 0.9999999975F, 0.9999999980F, - 0.9999999985F, 0.9999999988F, 0.9999999991F, 0.9999999993F, - 0.9999999995F, 0.9999999997F, 0.9999999998F, 0.9999999999F, - 0.9999999999F, 1.0000000000F, 1.0000000000F, 1.0000000000F, - 1.0000000000F, 1.0000000000F, 1.0000000000F, 1.0000000000F, -}; - -static const float *const vwin[8] = { - vwin64, - vwin128, - vwin256, - vwin512, - vwin1024, - vwin2048, - vwin4096, - vwin8192, -}; - -const float *_vorbis_window_get(int n){ - return vwin[n]; -} - -void _vorbis_apply_window(float *d,int *winno,long *blocksizes, - int lW,int W,int nW){ - lW=(W?lW:0); - nW=(W?nW:0); - - { - const float *windowLW=vwin[winno[lW]]; - const float *windowNW=vwin[winno[nW]]; - - long n=blocksizes[W]; - long ln=blocksizes[lW]; - long rn=blocksizes[nW]; - - long leftbegin=n/4-ln/4; - long leftend=leftbegin+ln/2; - - long rightbegin=n/2+n/4-rn/4; - long rightend=rightbegin+rn/2; - - int i,p; - - for(i=0;i -Source: https://downloads.xiph.org/releases/vorbis/%{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-root - -# We're forced to use an epoch since both Red Hat and Ximian use it in their -# rc packages -Epoch: 2 -# Dirty trick to tell rpm that this package actually provides what the -# last rc and beta was offering -Provides: %{name} = %{epoch}:1.0rc3-%{release} -Provides: %{name} = %{epoch}:1.0beta4-%{release} - -Requires: libogg >= 1.1 -BuildRequires: libogg-devel >= 1.1 - -%description -Ogg Vorbis is a fully open, non-proprietary, patent-and-royalty-free, -general-purpose compressed audio format for audio and music at fixed -and variable bitrates from 16 to 128 kbps/channel. - -%package devel -Summary: Vorbis Library Development -Group: Development/Libraries -Requires: libogg-devel >= 1.1 -Requires: libvorbis = %{version} -# Dirty trick to tell rpm that this package actually provides what the -# last rc and beta was offering -Provides: %{name}-devel = %{epoch}:1.0rc3-%{release} -Provides: %{name}-devel = %{epoch}:1.0beta4-%{release} - -%description devel -The libvorbis-devel package contains the header files, static libraries -and documentation needed to develop applications with libvorbis. - -%prep -%setup -q -n %{name}-%{version} - -%build -CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{_prefix} --enable-static -make - -%install -rm -rf $RPM_BUILD_ROOT - -make DESTDIR=$RPM_BUILD_ROOT install - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig - -%postun -p /sbin/ldconfig - -%files -%defattr(-,root,root) -%doc AUTHORS COPYING README -%{_libdir}/libvorbis.so.* -%{_libdir}/libvorbisfile.so.* -%{_libdir}/libvorbisenc.so.* - -%files devel -%doc doc/*.html -%doc doc/*.png -%doc doc/*.txt -%doc doc/vorbisfile -%doc doc/vorbisenc -%{_datadir}/aclocal/vorbis.m4 -%dir %{_includedir}/vorbis -%{_includedir}/vorbis/codec.h -%{_includedir}/vorbis/vorbisfile.h -%{_includedir}/vorbis/vorbisenc.h -%{_libdir}/libvorbis.a -%{_libdir}/libvorbis.la -%{_libdir}/libvorbis.so -%{_libdir}/libvorbisfile.a -%{_libdir}/libvorbisfile.la -%{_libdir}/libvorbisfile.so -%{_libdir}/libvorbisenc.a -%{_libdir}/libvorbisenc.la -%{_libdir}/libvorbisenc.so -%{_libdir}/pkgconfig/vorbis.pc -%{_libdir}/pkgconfig/vorbisfile.pc -%{_libdir}/pkgconfig/vorbisenc.pc - -%changelog -* Sat May 3 2008 Ralph Giles -- updated source location - -* Thu Jun 10 2004 Thomas Vander Stichele -- autogenerate from configure -- fix download location -- remove Prefix -- own include dir -- move ldconfig runs to -p scripts -- change Release tag to include xiph - -* Tue Oct 07 2003 Warren Dukes -- update for 1.0.1 release - -* Sun Jul 14 2002 Thomas Vander Stichele -- Added BuildRequires: -- updated for 1.0 release - -* Sat May 25 2002 Michael Smith -- Fixed requires, copyright string. -* Sun Dec 31 2001 Jack Moffitt -- Updated for rc3 release. - -* Sun Oct 07 2001 Jack Moffitt -- Updated for configurable prefixes - -* Sat Oct 21 2000 Jack Moffitt -- initial spec file created diff --git a/Engine/lib/libvorbis/m4/Makefile.am b/Engine/lib/libvorbis/m4/Makefile.am deleted file mode 100644 index cd184850f..000000000 --- a/Engine/lib/libvorbis/m4/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = add_cflags.m4 ogg.m4 pkg.m4 - diff --git a/Engine/lib/libvorbis/m4/add_cflags.m4 b/Engine/lib/libvorbis/m4/add_cflags.m4 deleted file mode 100644 index eeb6efda0..000000000 --- a/Engine/lib/libvorbis/m4/add_cflags.m4 +++ /dev/null @@ -1,15 +0,0 @@ -dnl @synopsis AC_ADD_CFLAGS -dnl -dnl Add the given option to CFLAGS, if it doesn't break the compiler - -AC_DEFUN([AC_ADD_CFLAGS], -[AC_MSG_CHECKING([if $CC accepts $1]) - ac_add_cflags__old_cflags="$CFLAGS" - CFLAGS="$CFLAGS $1" - AC_TRY_LINK([#include ], - [puts("Hello, World!"); return 0;], - AC_MSG_RESULT([yes]), - AC_MSG_RESULT([no]) - CFLAGS="$ac_add_cflags__old_cflags") - ]) -])# AC_ADD_CFLAGS diff --git a/Engine/lib/libvorbis/m4/ogg.m4 b/Engine/lib/libvorbis/m4/ogg.m4 deleted file mode 100644 index 1d3fb8b7b..000000000 --- a/Engine/lib/libvorbis/m4/ogg.m4 +++ /dev/null @@ -1,116 +0,0 @@ -# Configure paths for libogg -# Jack Moffitt 10-21-2000 -# Shamelessly stolen from Owen Taylor and Manish Singh - -dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS -dnl -AC_DEFUN([XIPH_PATH_OGG], -[dnl -dnl Get the cflags and libraries -dnl -AC_ARG_WITH(ogg,AC_HELP_STRING([--with-ogg=PFX],[Prefix where libogg is installed (optional)]), ogg_prefix="$withval", ogg_prefix="") -AC_ARG_WITH(ogg-libraries,AC_HELP_STRING([--with-ogg-libraries=DIR],[Directory where libogg library is installed (optional)]), ogg_libraries="$withval", ogg_libraries="") -AC_ARG_WITH(ogg-includes,AC_HELP_STRING([--with-ogg-includes=DIR],[Directory where libogg header files are installed (optional)]), ogg_includes="$withval", ogg_includes="") -AC_ARG_ENABLE(oggtest,AC_HELP_STRING([--disable-oggtest],[Do not try to compile and run a test Ogg program]),, enable_oggtest=yes) - - if test "x$ogg_libraries" != "x" ; then - OGG_LIBS="-L$ogg_libraries" - elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then - OGG_LIBS="" - elif test "x$ogg_prefix" != "x" ; then - OGG_LIBS="-L$ogg_prefix/lib" - elif test "x$prefix" != "xNONE" ; then - OGG_LIBS="-L$prefix/lib" - fi - - if test "x$ogg_prefix" != "xno" ; then - OGG_LIBS="$OGG_LIBS -logg" - fi - - if test "x$ogg_includes" != "x" ; then - OGG_CFLAGS="-I$ogg_includes" - elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then - OGG_CFLAGS="" - elif test "x$ogg_prefix" != "x" ; then - OGG_CFLAGS="-I$ogg_prefix/include" - elif test "x$prefix" != "xNONE"; then - OGG_CFLAGS="-I$prefix/include" - fi - - AC_MSG_CHECKING(for Ogg) - if test "x$ogg_prefix" = "xno" ; then - no_ogg="disabled" - enable_oggtest="no" - else - no_ogg="" - fi - - - if test "x$enable_oggtest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $OGG_CFLAGS" - LIBS="$LIBS $OGG_LIBS" -dnl -dnl Now check if the installed Ogg is sufficiently new. -dnl - rm -f conf.oggtest - AC_TRY_RUN([ -#include -#include -#include -#include - -int main () -{ - system("touch conf.oggtest"); - return 0; -} - -],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - - if test "x$no_ogg" = "xdisabled" ; then - AC_MSG_RESULT(no) - ifelse([$2], , :, [$2]) - elif test "x$no_ogg" = "x" ; then - AC_MSG_RESULT(yes) - ifelse([$1], , :, [$1]) - else - AC_MSG_RESULT(no) - if test -f conf.oggtest ; then - : - else - echo "*** Could not run Ogg test program, checking why..." - CFLAGS="$CFLAGS $OGG_CFLAGS" - LIBS="$LIBS $OGG_LIBS" - AC_TRY_LINK([ -#include -#include -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding Ogg or finding the wrong" - echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means Ogg was incorrectly installed" - echo "*** or that you have moved Ogg since it was installed." ]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - OGG_CFLAGS="" - OGG_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(OGG_CFLAGS) - AC_SUBST(OGG_LIBS) - rm -f conf.oggtest -]) diff --git a/Engine/lib/libvorbis/m4/pkg.m4 b/Engine/lib/libvorbis/m4/pkg.m4 deleted file mode 100644 index 996e29454..000000000 --- a/Engine/lib/libvorbis/m4/pkg.m4 +++ /dev/null @@ -1,157 +0,0 @@ -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# -# Copyright © 2004 Scott James Remnant . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- -AC_DEFUN([PKG_PROG_PKG_CONFIG], -[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=m4_default([$1], [0.9.0]) - AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - PKG_CONFIG="" - fi - -fi[]dnl -])# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# -# Similar to PKG_CHECK_MODULES, make sure that the first instance of -# this or PKG_CHECK_MODULES is called, or make sure to call -# PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_EXISTS], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -if test -n "$PKG_CONFIG" && \ - AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then - m4_ifval([$2], [$2], [:]) -m4_ifvaln([$3], [else - $3])dnl -fi]) - - -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- -m4_define([_PKG_CONFIG], -[if test -n "$PKG_CONFIG"; then - if test -n "$$1"; then - pkg_cv_[]$1="$$1" - else - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], - [pkg_failed=yes]) - fi -else - pkg_failed=untried -fi[]dnl -])# _PKG_CONFIG - -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- -AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_MODULES], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl -AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl - -pkg_failed=no -AC_MSG_CHECKING([for $1]) - -_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) -_PKG_CONFIG([$1][_LIBS], [libs], [$2]) - -m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS -and $1[]_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details.]) - -if test $pkg_failed = yes; then - _PKG_SHORT_ERRORS_SUPPORTED - if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` - fi - # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - - ifelse([$4], , [AC_MSG_ERROR(dnl -[Package requirements ($2) were not met: - -$$1_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -_PKG_TEXT -])], - [AC_MSG_RESULT([no]) - $4]) -elif test $pkg_failed = untried; then - ifelse([$4], , [AC_MSG_FAILURE(dnl -[The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -_PKG_TEXT - -To get pkg-config, see .])], - [$4]) -else - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS - AC_MSG_RESULT([yes]) - ifelse([$3], , :, [$3]) -fi[]dnl -])# PKG_CHECK_MODULES diff --git a/Engine/lib/libvorbis/macosx/English.lproj/InfoPlist.strings b/Engine/lib/libvorbis/macosx/English.lproj/InfoPlist.strings deleted file mode 100644 index cfe1b22a8..000000000 Binary files a/Engine/lib/libvorbis/macosx/English.lproj/InfoPlist.strings and /dev/null differ diff --git a/Engine/lib/libvorbis/macosx/Info.plist b/Engine/lib/libvorbis/macosx/Info.plist deleted file mode 100644 index 63e1b09c9..000000000 --- a/Engine/lib/libvorbis/macosx/Info.plist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - Vorbis - CFBundleGetInfoString - Vorbis framework 1.2.3, Copyright © 1994-2009 Xiph.Org Foundation - CFBundleIconFile - - CFBundleIdentifier - org.xiph.vorbis - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.2.3 - CFBundleSignature - ???? - CFBundleVersion - 1.2.3 - NSHumanReadableCopyright - Vorbis framework 1.2.3, Copyright © 1994-2009 Xiph.Org Foundation - CSResourcesFileMapped - - - diff --git a/Engine/lib/libvorbis/macosx/Vorbis.xcodeproj/project.pbxproj b/Engine/lib/libvorbis/macosx/Vorbis.xcodeproj/project.pbxproj deleted file mode 100644 index 12f5392a5..000000000 --- a/Engine/lib/libvorbis/macosx/Vorbis.xcodeproj/project.pbxproj +++ /dev/null @@ -1,891 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 42; - objects = { - -/* Begin PBXBuildFile section */ - 730F23A3091827B100AB638C /* codec.h in Headers */ = {isa = PBXBuildFile; fileRef = F58520B90191D12B01A802FE /* codec.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 730F23A4091827B100AB638C /* vorbisenc.h in Headers */ = {isa = PBXBuildFile; fileRef = F58520BA0191D12B01A802FE /* vorbisenc.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 730F23A5091827B100AB638C /* vorbisfile.h in Headers */ = {isa = PBXBuildFile; fileRef = F58520BB0191D12B01A802FE /* vorbisfile.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 730F23A6091827B100AB638C /* backends.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F60B03389C830112CE8F /* backends.h */; }; - 730F23A7091827B100AB638C /* bitrate.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F60E03389C830112CE8F /* bitrate.h */; }; - 730F23A8091827B100AB638C /* res_books_stereo.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F61603389C830112CE8F /* res_books_stereo.h */; }; - 730F23A9091827B100AB638C /* floor_books.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F61903389C830112CE8F /* floor_books.h */; }; - 730F23AA091827B100AB638C /* res_books_uncoupled.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F62203389C830112CE8F /* res_books_uncoupled.h */; }; - 730F23AB091827B100AB638C /* codebook.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F62403389C830112CE8F /* codebook.h */; }; - 730F23AC091827B100AB638C /* codec_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F62503389C830112CE8F /* codec_internal.h */; }; - 730F23AD091827B100AB638C /* envelope.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F62703389C830112CE8F /* envelope.h */; }; - 730F23AE091827B100AB638C /* highlevel.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F62A03389C830112CE8F /* highlevel.h */; }; - 730F23AF091827B100AB638C /* lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F62D03389C830112CE8F /* lookup.h */; }; - 730F23B0091827B100AB638C /* lookup_data.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F62E03389C830112CE8F /* lookup_data.h */; }; - 730F23B1091827B100AB638C /* lpc.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F63103389C830112CE8F /* lpc.h */; }; - 730F23B2091827B100AB638C /* lsp.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F63303389C830112CE8F /* lsp.h */; }; - 730F23B3091827B100AB638C /* masking.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F63703389C830112CE8F /* masking.h */; }; - 730F23B4091827B100AB638C /* mdct.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F63903389C830112CE8F /* mdct.h */; }; - 730F23B5091827B100AB638C /* misc.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F63B03389C830112CE8F /* misc.h */; }; - 730F23B6091827B100AB638C /* floor_all.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F63E03389C830112CE8F /* floor_all.h */; }; - 730F23B7091827B100AB638C /* psych_11.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64103389C830112CE8F /* psych_11.h */; }; - 730F23B8091827B100AB638C /* psych_16.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64203389C830112CE8F /* psych_16.h */; }; - 730F23B9091827B100AB638C /* psych_44.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64303389C830112CE8F /* psych_44.h */; }; - 730F23BA091827B100AB638C /* psych_8.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64403389C830112CE8F /* psych_8.h */; }; - 730F23BB091827B100AB638C /* residue_16.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64503389C830112CE8F /* residue_16.h */; }; - 730F23BC091827B100AB638C /* residue_44.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64603389C830112CE8F /* residue_44.h */; }; - 730F23BD091827B100AB638C /* residue_44u.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64703389C830112CE8F /* residue_44u.h */; }; - 730F23BE091827B100AB638C /* residue_8.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64803389C830112CE8F /* residue_8.h */; }; - 730F23BF091827B100AB638C /* setup_11.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64903389C830112CE8F /* setup_11.h */; }; - 730F23C0091827B100AB638C /* setup_16.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64A03389C830112CE8F /* setup_16.h */; }; - 730F23C1091827B100AB638C /* setup_22.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64B03389C830112CE8F /* setup_22.h */; }; - 730F23C2091827B100AB638C /* setup_32.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64C03389C830112CE8F /* setup_32.h */; }; - 730F23C3091827B100AB638C /* setup_44.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64D03389C830112CE8F /* setup_44.h */; }; - 730F23C4091827B100AB638C /* setup_44u.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64E03389C830112CE8F /* setup_44u.h */; }; - 730F23C5091827B100AB638C /* setup_8.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F64F03389C830112CE8F /* setup_8.h */; }; - 730F23C6091827B100AB638C /* setup_X.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F65003389C830112CE8F /* setup_X.h */; }; - 730F23C7091827B100AB638C /* os.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F65103389C830112CE8F /* os.h */; }; - 730F23C8091827B100AB638C /* psy.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F65303389C830112CE8F /* psy.h */; }; - 730F23C9091827B100AB638C /* registry.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F65603389C830112CE8F /* registry.h */; }; - 730F23CA091827B100AB638C /* scales.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F65803389C830112CE8F /* scales.h */; }; - 730F23CB091827B100AB638C /* smallft.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F65B03389C830112CE8F /* smallft.h */; }; - 730F23CC091827B100AB638C /* window.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D8F66103389C830112CE8F /* window.h */; }; - 730F23CE091827B100AB638C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; }; - 730F23D3091827B100AB638C /* analysis.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F60A03389C830112CE8F /* analysis.c */; }; - 730F23D4091827B100AB638C /* bitrate.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F60D03389C830112CE8F /* bitrate.c */; }; - 730F23D5091827B100AB638C /* block.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F60F03389C830112CE8F /* block.c */; }; - 730F23D6091827B100AB638C /* codebook.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62303389C830112CE8F /* codebook.c */; }; - 730F23D7091827B100AB638C /* envelope.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62603389C830112CE8F /* envelope.c */; }; - 730F23D8091827B100AB638C /* floor0.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62803389C830112CE8F /* floor0.c */; }; - 730F23D9091827B100AB638C /* floor1.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62903389C830112CE8F /* floor1.c */; }; - 730F23DA091827B100AB638C /* info.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62B03389C830112CE8F /* info.c */; }; - 730F23DB091827B100AB638C /* lookup.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62C03389C830112CE8F /* lookup.c */; }; - 730F23DC091827B100AB638C /* lpc.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F63003389C830112CE8F /* lpc.c */; }; - 730F23DD091827B100AB638C /* lsp.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F63203389C830112CE8F /* lsp.c */; }; - 730F23DE091827B100AB638C /* mapping0.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F63603389C830112CE8F /* mapping0.c */; }; - 730F23DF091827B100AB638C /* mdct.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F63803389C830112CE8F /* mdct.c */; }; - 730F23E0091827B100AB638C /* psy.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65203389C830112CE8F /* psy.c */; }; - 730F23E1091827B100AB638C /* registry.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65503389C830112CE8F /* registry.c */; }; - 730F23E2091827B100AB638C /* res0.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65703389C830112CE8F /* res0.c */; }; - 730F23E3091827B100AB638C /* sharedbook.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65903389C830112CE8F /* sharedbook.c */; }; - 730F23E4091827B100AB638C /* smallft.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65A03389C830112CE8F /* smallft.c */; }; - 730F23E5091827B100AB638C /* synthesis.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65C03389C830112CE8F /* synthesis.c */; }; - 730F23E6091827B100AB638C /* vorbisenc.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65E03389C830112CE8F /* vorbisenc.c */; }; - 730F23E7091827B100AB638C /* vorbisfile.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65F03389C830112CE8F /* vorbisfile.c */; }; - 730F23E8091827B100AB638C /* window.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F66003389C830112CE8F /* window.c */; }; - 730F23FB0918281100AB638C /* Ogg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 730F23FA0918281100AB638C /* Ogg.framework */; }; - 738835F40B18FF50005C7A69 /* mdct.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F63803389C830112CE8F /* mdct.c */; }; - 738835F70B18FF58005C7A69 /* smallft.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65A03389C830112CE8F /* smallft.c */; }; - 738835F80B18FF61005C7A69 /* block.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F60F03389C830112CE8F /* block.c */; }; - 738835F90B18FF67005C7A69 /* envelope.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62603389C830112CE8F /* envelope.c */; }; - 738835FA0B18FF71005C7A69 /* window.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F66003389C830112CE8F /* window.c */; }; - 738835FB0B18FF7A005C7A69 /* lsp.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F63203389C830112CE8F /* lsp.c */; }; - 738835FC0B18FF82005C7A69 /* lpc.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F63003389C830112CE8F /* lpc.c */; }; - 738835FD0B18FF93005C7A69 /* analysis.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F60A03389C830112CE8F /* analysis.c */; }; - 738835FE0B18FF9C005C7A69 /* synthesis.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65C03389C830112CE8F /* synthesis.c */; }; - 738835FF0B18FF9E005C7A69 /* psy.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65203389C830112CE8F /* psy.c */; }; - 738836000B18FFCB005C7A69 /* info.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62B03389C830112CE8F /* info.c */; }; - 738836010B18FFE5005C7A69 /* floor1.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62903389C830112CE8F /* floor1.c */; }; - 738836020B18FFE5005C7A69 /* floor0.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62803389C830112CE8F /* floor0.c */; }; - 738836030B18FFED005C7A69 /* res0.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65703389C830112CE8F /* res0.c */; }; - 738836040B18FFF0005C7A69 /* mapping0.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F63603389C830112CE8F /* mapping0.c */; }; - 738836050B18FFF8005C7A69 /* registry.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65503389C830112CE8F /* registry.c */; }; - 738836060B18FFFD005C7A69 /* codebook.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62303389C830112CE8F /* codebook.c */; }; - 738836070B190001005C7A69 /* sharedbook.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65903389C830112CE8F /* sharedbook.c */; }; - 738836080B190008005C7A69 /* lookup.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F62C03389C830112CE8F /* lookup.c */; }; - 738836090B19000B005C7A69 /* bitrate.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F60D03389C830112CE8F /* bitrate.c */; }; - 738836140B1904A5005C7A69 /* vorbisenc.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65E03389C830112CE8F /* vorbisenc.c */; }; - 738836230B190601005C7A69 /* vorbisfile.c in Sources */ = {isa = PBXBuildFile; fileRef = F5D8F65F03389C830112CE8F /* vorbisfile.c */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; - 730F23F0091827B100AB638C /* Info.plist */ = {isa = PBXFileReference; explicitFileType = text.plist; fileEncoding = 4; path = Info.plist; sourceTree = ""; }; - 730F23F1091827B100AB638C /* Vorbis.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Vorbis.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 730F23FA0918281100AB638C /* Ogg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Ogg.framework; path = /Library/Frameworks/Ogg.framework; sourceTree = ""; }; - 738835E40B18F870005C7A69 /* libvorbis.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libvorbis.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 738836130B190488005C7A69 /* libvorbisenc.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libvorbisenc.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 738836220B1905E5005C7A69 /* libvorbisfile.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libvorbisfile.a; sourceTree = BUILT_PRODUCTS_DIR; }; - F58520B90191D12B01A802FE /* codec.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = codec.h; sourceTree = ""; }; - F58520BA0191D12B01A802FE /* vorbisenc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vorbisenc.h; sourceTree = ""; }; - F58520BB0191D12B01A802FE /* vorbisfile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vorbisfile.h; sourceTree = ""; }; - F5D8F60A03389C830112CE8F /* analysis.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = analysis.c; sourceTree = ""; }; - F5D8F60B03389C830112CE8F /* backends.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = backends.h; sourceTree = ""; }; - F5D8F60C03389C830112CE8F /* barkmel.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = barkmel.c; sourceTree = ""; }; - F5D8F60D03389C830112CE8F /* bitrate.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = bitrate.c; sourceTree = ""; }; - F5D8F60E03389C830112CE8F /* bitrate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bitrate.h; sourceTree = ""; }; - F5D8F60F03389C830112CE8F /* block.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = block.c; sourceTree = ""; }; - F5D8F61603389C830112CE8F /* res_books_stereo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = res_books_stereo.h; sourceTree = ""; }; - F5D8F61903389C830112CE8F /* floor_books.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = floor_books.h; sourceTree = ""; }; - F5D8F62203389C830112CE8F /* res_books_uncoupled.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = res_books_uncoupled.h; sourceTree = ""; }; - F5D8F62303389C830112CE8F /* codebook.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = codebook.c; sourceTree = ""; }; - F5D8F62403389C830112CE8F /* codebook.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = codebook.h; sourceTree = ""; }; - F5D8F62503389C830112CE8F /* codec_internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = codec_internal.h; sourceTree = ""; }; - F5D8F62603389C830112CE8F /* envelope.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = envelope.c; sourceTree = ""; }; - F5D8F62703389C830112CE8F /* envelope.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = envelope.h; sourceTree = ""; }; - F5D8F62803389C830112CE8F /* floor0.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = floor0.c; sourceTree = ""; }; - F5D8F62903389C830112CE8F /* floor1.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = floor1.c; sourceTree = ""; }; - F5D8F62A03389C830112CE8F /* highlevel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = highlevel.h; sourceTree = ""; }; - F5D8F62B03389C830112CE8F /* info.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = info.c; sourceTree = ""; }; - F5D8F62C03389C830112CE8F /* lookup.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lookup.c; sourceTree = ""; }; - F5D8F62D03389C830112CE8F /* lookup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lookup.h; sourceTree = ""; }; - F5D8F62E03389C830112CE8F /* lookup_data.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lookup_data.h; sourceTree = ""; }; - F5D8F63003389C830112CE8F /* lpc.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lpc.c; sourceTree = ""; }; - F5D8F63103389C830112CE8F /* lpc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lpc.h; sourceTree = ""; }; - F5D8F63203389C830112CE8F /* lsp.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lsp.c; sourceTree = ""; }; - F5D8F63303389C830112CE8F /* lsp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lsp.h; sourceTree = ""; }; - F5D8F63603389C830112CE8F /* mapping0.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = mapping0.c; sourceTree = ""; }; - F5D8F63703389C830112CE8F /* masking.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = masking.h; sourceTree = ""; }; - F5D8F63803389C830112CE8F /* mdct.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = mdct.c; sourceTree = ""; }; - F5D8F63903389C830112CE8F /* mdct.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mdct.h; sourceTree = ""; }; - F5D8F63A03389C830112CE8F /* misc.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = misc.c; sourceTree = ""; }; - F5D8F63B03389C830112CE8F /* misc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = misc.h; sourceTree = ""; }; - F5D8F63E03389C830112CE8F /* floor_all.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = floor_all.h; sourceTree = ""; }; - F5D8F64103389C830112CE8F /* psych_11.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = psych_11.h; sourceTree = ""; }; - F5D8F64203389C830112CE8F /* psych_16.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = psych_16.h; sourceTree = ""; }; - F5D8F64303389C830112CE8F /* psych_44.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = psych_44.h; sourceTree = ""; }; - F5D8F64403389C830112CE8F /* psych_8.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = psych_8.h; sourceTree = ""; }; - F5D8F64503389C830112CE8F /* residue_16.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = residue_16.h; sourceTree = ""; }; - F5D8F64603389C830112CE8F /* residue_44.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = residue_44.h; sourceTree = ""; }; - F5D8F64703389C830112CE8F /* residue_44u.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = residue_44u.h; sourceTree = ""; }; - F5D8F64803389C830112CE8F /* residue_8.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = residue_8.h; sourceTree = ""; }; - F5D8F64903389C830112CE8F /* setup_11.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = setup_11.h; sourceTree = ""; }; - F5D8F64A03389C830112CE8F /* setup_16.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = setup_16.h; sourceTree = ""; }; - F5D8F64B03389C830112CE8F /* setup_22.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = setup_22.h; sourceTree = ""; }; - F5D8F64C03389C830112CE8F /* setup_32.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = setup_32.h; sourceTree = ""; }; - F5D8F64D03389C830112CE8F /* setup_44.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = setup_44.h; sourceTree = ""; }; - F5D8F64E03389C830112CE8F /* setup_44u.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = setup_44u.h; sourceTree = ""; }; - F5D8F64F03389C830112CE8F /* setup_8.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = setup_8.h; sourceTree = ""; }; - F5D8F65003389C830112CE8F /* setup_X.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = setup_X.h; sourceTree = ""; }; - F5D8F65103389C830112CE8F /* os.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = os.h; sourceTree = ""; }; - F5D8F65203389C830112CE8F /* psy.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = psy.c; sourceTree = ""; }; - F5D8F65303389C830112CE8F /* psy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = psy.h; sourceTree = ""; }; - F5D8F65403389C830112CE8F /* psytune.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = psytune.c; sourceTree = ""; }; - F5D8F65503389C830112CE8F /* registry.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = registry.c; sourceTree = ""; }; - F5D8F65603389C830112CE8F /* registry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = registry.h; sourceTree = ""; }; - F5D8F65703389C830112CE8F /* res0.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = res0.c; sourceTree = ""; }; - F5D8F65803389C830112CE8F /* scales.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = scales.h; sourceTree = ""; }; - F5D8F65903389C830112CE8F /* sharedbook.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = sharedbook.c; sourceTree = ""; }; - F5D8F65A03389C830112CE8F /* smallft.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = smallft.c; sourceTree = ""; }; - F5D8F65B03389C830112CE8F /* smallft.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = smallft.h; sourceTree = ""; }; - F5D8F65C03389C830112CE8F /* synthesis.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = synthesis.c; sourceTree = ""; }; - F5D8F65D03389C830112CE8F /* tone.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tone.c; sourceTree = ""; }; - F5D8F65E03389C830112CE8F /* vorbisenc.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = vorbisenc.c; sourceTree = ""; }; - F5D8F65F03389C830112CE8F /* vorbisfile.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = vorbisfile.c; sourceTree = ""; }; - F5D8F66003389C830112CE8F /* window.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = window.c; sourceTree = ""; }; - F5D8F66103389C830112CE8F /* window.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = window.h; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 730F23E9091827B100AB638C /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 730F23FB0918281100AB638C /* Ogg.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 738835E20B18F870005C7A69 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 738836110B190488005C7A69 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 738836200B1905E5005C7A69 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 034768DFFF38A50411DB9C8B /* Products */ = { - isa = PBXGroup; - children = ( - 730F23F1091827B100AB638C /* Vorbis.framework */, - 738835E40B18F870005C7A69 /* libvorbis.a */, - 738836130B190488005C7A69 /* libvorbisenc.a */, - 738836220B1905E5005C7A69 /* libvorbisfile.a */, - ); - name = Products; - sourceTree = ""; - }; - 0867D691FE84028FC02AAC07 /* vorbis */ = { - isa = PBXGroup; - children = ( - F58520B70191D12B01A802FE /* Headers */, - F5D8F60803389C830112CE8F /* lib */, - 089C1665FE841158C02AAC07 /* Resources */, - 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */, - 034768DFFF38A50411DB9C8B /* Products */, - ); - name = vorbis; - sourceTree = ""; - }; - 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = { - isa = PBXGroup; - children = ( - 730F23FA0918281100AB638C /* Ogg.framework */, - ); - name = "External Frameworks and Libraries"; - sourceTree = ""; - }; - 089C1665FE841158C02AAC07 /* Resources */ = { - isa = PBXGroup; - children = ( - 730F23F0091827B100AB638C /* Info.plist */, - 089C1666FE841158C02AAC07 /* InfoPlist.strings */, - ); - name = Resources; - sourceTree = ""; - }; - F58520B70191D12B01A802FE /* Headers */ = { - isa = PBXGroup; - children = ( - F58520B90191D12B01A802FE /* codec.h */, - F58520BA0191D12B01A802FE /* vorbisenc.h */, - F58520BB0191D12B01A802FE /* vorbisfile.h */, - ); - name = Headers; - path = ../include/vorbis; - sourceTree = SOURCE_ROOT; - }; - F5D8F60803389C830112CE8F /* lib */ = { - isa = PBXGroup; - children = ( - F5D8F60A03389C830112CE8F /* analysis.c */, - F5D8F60B03389C830112CE8F /* backends.h */, - F5D8F60C03389C830112CE8F /* barkmel.c */, - F5D8F60D03389C830112CE8F /* bitrate.c */, - F5D8F60E03389C830112CE8F /* bitrate.h */, - F5D8F60F03389C830112CE8F /* block.c */, - F5D8F61003389C830112CE8F /* books */, - F5D8F62303389C830112CE8F /* codebook.c */, - F5D8F62403389C830112CE8F /* codebook.h */, - F5D8F62503389C830112CE8F /* codec_internal.h */, - F5D8F62603389C830112CE8F /* envelope.c */, - F5D8F62703389C830112CE8F /* envelope.h */, - F5D8F62803389C830112CE8F /* floor0.c */, - F5D8F62903389C830112CE8F /* floor1.c */, - F5D8F62A03389C830112CE8F /* highlevel.h */, - F5D8F62B03389C830112CE8F /* info.c */, - F5D8F62C03389C830112CE8F /* lookup.c */, - F5D8F62D03389C830112CE8F /* lookup.h */, - F5D8F62E03389C830112CE8F /* lookup_data.h */, - F5D8F63003389C830112CE8F /* lpc.c */, - F5D8F63103389C830112CE8F /* lpc.h */, - F5D8F63203389C830112CE8F /* lsp.c */, - F5D8F63303389C830112CE8F /* lsp.h */, - F5D8F63603389C830112CE8F /* mapping0.c */, - F5D8F63703389C830112CE8F /* masking.h */, - F5D8F63803389C830112CE8F /* mdct.c */, - F5D8F63903389C830112CE8F /* mdct.h */, - F5D8F63A03389C830112CE8F /* misc.c */, - F5D8F63B03389C830112CE8F /* misc.h */, - F5D8F63C03389C830112CE8F /* modes */, - F5D8F65103389C830112CE8F /* os.h */, - F5D8F65203389C830112CE8F /* psy.c */, - F5D8F65303389C830112CE8F /* psy.h */, - F5D8F65403389C830112CE8F /* psytune.c */, - F5D8F65503389C830112CE8F /* registry.c */, - F5D8F65603389C830112CE8F /* registry.h */, - F5D8F65703389C830112CE8F /* res0.c */, - F5D8F65803389C830112CE8F /* scales.h */, - F5D8F65903389C830112CE8F /* sharedbook.c */, - F5D8F65A03389C830112CE8F /* smallft.c */, - F5D8F65B03389C830112CE8F /* smallft.h */, - F5D8F65C03389C830112CE8F /* synthesis.c */, - F5D8F65D03389C830112CE8F /* tone.c */, - F5D8F65E03389C830112CE8F /* vorbisenc.c */, - F5D8F65F03389C830112CE8F /* vorbisfile.c */, - F5D8F66003389C830112CE8F /* window.c */, - F5D8F66103389C830112CE8F /* window.h */, - ); - name = lib; - path = ../lib; - sourceTree = ""; - }; - F5D8F61003389C830112CE8F /* books */ = { - isa = PBXGroup; - children = ( - F5D8F61203389C830112CE8F /* coupled */, - F5D8F61703389C830112CE8F /* floor */, - F5D8F61E03389C830112CE8F /* uncoupled */, - ); - path = books; - sourceTree = ""; - }; - F5D8F61203389C830112CE8F /* coupled */ = { - isa = PBXGroup; - children = ( - F5D8F61603389C830112CE8F /* res_books_stereo.h */, - ); - path = coupled; - sourceTree = ""; - }; - F5D8F61703389C830112CE8F /* floor */ = { - isa = PBXGroup; - children = ( - F5D8F61903389C830112CE8F /* floor_books.h */, - ); - path = floor; - sourceTree = ""; - }; - F5D8F61E03389C830112CE8F /* uncoupled */ = { - isa = PBXGroup; - children = ( - F5D8F62203389C830112CE8F /* res_books_uncoupled.h */, - ); - path = uncoupled; - sourceTree = ""; - }; - F5D8F63C03389C830112CE8F /* modes */ = { - isa = PBXGroup; - children = ( - F5D8F63E03389C830112CE8F /* floor_all.h */, - F5D8F64103389C830112CE8F /* psych_11.h */, - F5D8F64203389C830112CE8F /* psych_16.h */, - F5D8F64303389C830112CE8F /* psych_44.h */, - F5D8F64403389C830112CE8F /* psych_8.h */, - F5D8F64503389C830112CE8F /* residue_16.h */, - F5D8F64603389C830112CE8F /* residue_44.h */, - F5D8F64703389C830112CE8F /* residue_44u.h */, - F5D8F64803389C830112CE8F /* residue_8.h */, - F5D8F64903389C830112CE8F /* setup_11.h */, - F5D8F64A03389C830112CE8F /* setup_16.h */, - F5D8F64B03389C830112CE8F /* setup_22.h */, - F5D8F64C03389C830112CE8F /* setup_32.h */, - F5D8F64D03389C830112CE8F /* setup_44.h */, - F5D8F64E03389C830112CE8F /* setup_44u.h */, - F5D8F64F03389C830112CE8F /* setup_8.h */, - F5D8F65003389C830112CE8F /* setup_X.h */, - ); - path = modes; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 730F23A2091827B100AB638C /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 730F23A3091827B100AB638C /* codec.h in Headers */, - 730F23A4091827B100AB638C /* vorbisenc.h in Headers */, - 730F23A5091827B100AB638C /* vorbisfile.h in Headers */, - 730F23A6091827B100AB638C /* backends.h in Headers */, - 730F23A7091827B100AB638C /* bitrate.h in Headers */, - 730F23A8091827B100AB638C /* res_books_stereo.h in Headers */, - 730F23A9091827B100AB638C /* floor_books.h in Headers */, - 730F23AA091827B100AB638C /* res_books_uncoupled.h in Headers */, - 730F23AB091827B100AB638C /* codebook.h in Headers */, - 730F23AC091827B100AB638C /* codec_internal.h in Headers */, - 730F23AD091827B100AB638C /* envelope.h in Headers */, - 730F23AE091827B100AB638C /* highlevel.h in Headers */, - 730F23AF091827B100AB638C /* lookup.h in Headers */, - 730F23B0091827B100AB638C /* lookup_data.h in Headers */, - 730F23B1091827B100AB638C /* lpc.h in Headers */, - 730F23B2091827B100AB638C /* lsp.h in Headers */, - 730F23B3091827B100AB638C /* masking.h in Headers */, - 730F23B4091827B100AB638C /* mdct.h in Headers */, - 730F23B5091827B100AB638C /* misc.h in Headers */, - 730F23B6091827B100AB638C /* floor_all.h in Headers */, - 730F23B7091827B100AB638C /* psych_11.h in Headers */, - 730F23B8091827B100AB638C /* psych_16.h in Headers */, - 730F23B9091827B100AB638C /* psych_44.h in Headers */, - 730F23BA091827B100AB638C /* psych_8.h in Headers */, - 730F23BB091827B100AB638C /* residue_16.h in Headers */, - 730F23BC091827B100AB638C /* residue_44.h in Headers */, - 730F23BD091827B100AB638C /* residue_44u.h in Headers */, - 730F23BE091827B100AB638C /* residue_8.h in Headers */, - 730F23BF091827B100AB638C /* setup_11.h in Headers */, - 730F23C0091827B100AB638C /* setup_16.h in Headers */, - 730F23C1091827B100AB638C /* setup_22.h in Headers */, - 730F23C2091827B100AB638C /* setup_32.h in Headers */, - 730F23C3091827B100AB638C /* setup_44.h in Headers */, - 730F23C4091827B100AB638C /* setup_44u.h in Headers */, - 730F23C5091827B100AB638C /* setup_8.h in Headers */, - 730F23C6091827B100AB638C /* setup_X.h in Headers */, - 730F23C7091827B100AB638C /* os.h in Headers */, - 730F23C8091827B100AB638C /* psy.h in Headers */, - 730F23C9091827B100AB638C /* registry.h in Headers */, - 730F23CA091827B100AB638C /* scales.h in Headers */, - 730F23CB091827B100AB638C /* smallft.h in Headers */, - 730F23CC091827B100AB638C /* window.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 738835E00B18F870005C7A69 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 7388360F0B190488005C7A69 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 7388361E0B1905E5005C7A69 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 730F23A1091827B100AB638C /* Vorbis */ = { - isa = PBXNativeTarget; - buildConfigurationList = 730F23EC091827B100AB638C /* Build configuration list for PBXNativeTarget "Vorbis" */; - buildPhases = ( - 730F23A2091827B100AB638C /* Headers */, - 730F23CD091827B100AB638C /* Resources */, - 730F23D2091827B100AB638C /* Sources */, - 730F23E9091827B100AB638C /* Frameworks */, - 730F23EB091827B100AB638C /* Rez */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Vorbis; - productInstallPath = /Library/Frameworks; - productName = vorbis; - productReference = 730F23F1091827B100AB638C /* Vorbis.framework */; - productType = "com.apple.product-type.framework"; - }; - 738835E30B18F870005C7A69 /* libvorbis (static) */ = { - isa = PBXNativeTarget; - buildConfigurationList = 738835E50B18F88E005C7A69 /* Build configuration list for PBXNativeTarget "libvorbis (static)" */; - buildPhases = ( - 738835E00B18F870005C7A69 /* Headers */, - 738835E10B18F870005C7A69 /* Sources */, - 738835E20B18F870005C7A69 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "libvorbis (static)"; - productName = vorbis; - productReference = 738835E40B18F870005C7A69 /* libvorbis.a */; - productType = "com.apple.product-type.library.static"; - }; - 738836120B190488005C7A69 /* libvorbisenc (static) */ = { - isa = PBXNativeTarget; - buildConfigurationList = 7388361A0B1904D6005C7A69 /* Build configuration list for PBXNativeTarget "libvorbisenc (static)" */; - buildPhases = ( - 7388360F0B190488005C7A69 /* Headers */, - 738836100B190488005C7A69 /* Sources */, - 738836110B190488005C7A69 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "libvorbisenc (static)"; - productName = vorbisenc; - productReference = 738836130B190488005C7A69 /* libvorbisenc.a */; - productType = "com.apple.product-type.library.static"; - }; - 738836210B1905E5005C7A69 /* libvorbisfile (static) */ = { - isa = PBXNativeTarget; - buildConfigurationList = 738836250B19065D005C7A69 /* Build configuration list for PBXNativeTarget "libvorbisfile (static)" */; - buildPhases = ( - 7388361E0B1905E5005C7A69 /* Headers */, - 7388361F0B1905E5005C7A69 /* Sources */, - 738836200B1905E5005C7A69 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "libvorbisfile (static)"; - productName = vorbisfile; - productReference = 738836220B1905E5005C7A69 /* libvorbisfile.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 0867D690FE84028FC02AAC07 /* Project object */ = { - isa = PBXProject; - buildConfigurationList = 730F23F3091827B200AB638C /* Build configuration list for PBXProject "Vorbis" */; - hasScannedForEncodings = 0; - mainGroup = 0867D691FE84028FC02AAC07 /* vorbis */; - productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; - projectDirPath = ""; - targets = ( - 730F23A1091827B100AB638C /* Vorbis */, - 738835E30B18F870005C7A69 /* libvorbis (static) */, - 738836120B190488005C7A69 /* libvorbisenc (static) */, - 738836210B1905E5005C7A69 /* libvorbisfile (static) */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 730F23CD091827B100AB638C /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 730F23CE091827B100AB638C /* InfoPlist.strings in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXRezBuildPhase section */ - 730F23EB091827B100AB638C /* Rez */ = { - isa = PBXRezBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXRezBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 730F23D2091827B100AB638C /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 730F23D3091827B100AB638C /* analysis.c in Sources */, - 730F23D4091827B100AB638C /* bitrate.c in Sources */, - 730F23D5091827B100AB638C /* block.c in Sources */, - 730F23D6091827B100AB638C /* codebook.c in Sources */, - 730F23D7091827B100AB638C /* envelope.c in Sources */, - 730F23D8091827B100AB638C /* floor0.c in Sources */, - 730F23D9091827B100AB638C /* floor1.c in Sources */, - 730F23DA091827B100AB638C /* info.c in Sources */, - 730F23DB091827B100AB638C /* lookup.c in Sources */, - 730F23DC091827B100AB638C /* lpc.c in Sources */, - 730F23DD091827B100AB638C /* lsp.c in Sources */, - 730F23DE091827B100AB638C /* mapping0.c in Sources */, - 730F23DF091827B100AB638C /* mdct.c in Sources */, - 730F23E0091827B100AB638C /* psy.c in Sources */, - 730F23E1091827B100AB638C /* registry.c in Sources */, - 730F23E2091827B100AB638C /* res0.c in Sources */, - 730F23E3091827B100AB638C /* sharedbook.c in Sources */, - 730F23E4091827B100AB638C /* smallft.c in Sources */, - 730F23E5091827B100AB638C /* synthesis.c in Sources */, - 730F23E6091827B100AB638C /* vorbisenc.c in Sources */, - 730F23E7091827B100AB638C /* vorbisfile.c in Sources */, - 730F23E8091827B100AB638C /* window.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 738835E10B18F870005C7A69 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 738835F40B18FF50005C7A69 /* mdct.c in Sources */, - 738835F70B18FF58005C7A69 /* smallft.c in Sources */, - 738835F80B18FF61005C7A69 /* block.c in Sources */, - 738835F90B18FF67005C7A69 /* envelope.c in Sources */, - 738835FA0B18FF71005C7A69 /* window.c in Sources */, - 738835FB0B18FF7A005C7A69 /* lsp.c in Sources */, - 738835FC0B18FF82005C7A69 /* lpc.c in Sources */, - 738835FD0B18FF93005C7A69 /* analysis.c in Sources */, - 738835FE0B18FF9C005C7A69 /* synthesis.c in Sources */, - 738835FF0B18FF9E005C7A69 /* psy.c in Sources */, - 738836000B18FFCB005C7A69 /* info.c in Sources */, - 738836010B18FFE5005C7A69 /* floor1.c in Sources */, - 738836020B18FFE5005C7A69 /* floor0.c in Sources */, - 738836030B18FFED005C7A69 /* res0.c in Sources */, - 738836040B18FFF0005C7A69 /* mapping0.c in Sources */, - 738836050B18FFF8005C7A69 /* registry.c in Sources */, - 738836060B18FFFD005C7A69 /* codebook.c in Sources */, - 738836070B190001005C7A69 /* sharedbook.c in Sources */, - 738836080B190008005C7A69 /* lookup.c in Sources */, - 738836090B19000B005C7A69 /* bitrate.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 738836100B190488005C7A69 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 738836140B1904A5005C7A69 /* vorbisenc.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 7388361F0B1905E5005C7A69 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 738836230B190601005C7A69 /* vorbisfile.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 089C1666FE841158C02AAC07 /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 089C1667FE841158C02AAC07 /* English */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 730F23ED091827B100AB638C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - FRAMEWORK_SEARCH_PATHS = /Library/Frameworks; - FRAMEWORK_VERSION = A; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - HEADER_SEARCH_PATHS = ../lib; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = /Library/Frameworks; - LIBRARY_SEARCH_PATHS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = Vorbis; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - WRAPPER_EXTENSION = framework; - ZERO_LINK = YES; - }; - name = Debug; - }; - 730F23EE091827B100AB638C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - FRAMEWORK_SEARCH_PATHS = /Library/Frameworks; - FRAMEWORK_VERSION = A; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - HEADER_SEARCH_PATHS = ../lib; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = /Library/Frameworks; - LIBRARY_SEARCH_PATHS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = Vorbis; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - WRAPPER_EXTENSION = framework; - ZERO_LINK = NO; - }; - name = Release; - }; - 730F23F4091827B200AB638C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = __MACOSX__; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; - }; - name = Debug; - }; - 730F23F5091827B200AB638C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - GCC_OPTIMIZATION_LEVEL = 3; - GCC_PREPROCESSOR_DEFINITIONS = __MACOSX__; - OTHER_CFLAGS = ( - "$(OTHER_CFLAGS)", - "-ffast-math", - "-falign-loops=16", - ); - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; - }; - name = Release; - }; - 738835E60B18F88E005C7A69 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - ../../ogg/include, - ); - INSTALL_PATH = /usr/local/lib; - PREBINDING = NO; - PRODUCT_NAME = vorbis; - ZERO_LINK = YES; - }; - name = Debug; - }; - 738835E70B18F88E005C7A69 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - ../../ogg/include, - ); - INSTALL_PATH = /usr/local/lib; - PREBINDING = NO; - PRODUCT_NAME = vorbis; - ZERO_LINK = NO; - }; - name = Release; - }; - 7388361B0B1904D6005C7A69 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - ../lib, - ../../ogg/include, - ); - INSTALL_PATH = /usr/local/lib; - PREBINDING = NO; - PRODUCT_NAME = vorbisenc; - ZERO_LINK = YES; - }; - name = Debug; - }; - 7388361C0B1904D6005C7A69 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - ../lib, - ../../ogg/include, - ); - INSTALL_PATH = /usr/local/lib; - PREBINDING = NO; - PRODUCT_NAME = vorbisenc; - ZERO_LINK = NO; - }; - name = Release; - }; - 738836260B19065D005C7A69 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - ../../ogg/include, - ); - INSTALL_PATH = /usr/local/lib; - PREBINDING = NO; - PRODUCT_NAME = vorbisfile; - ZERO_LINK = YES; - }; - name = Debug; - }; - 738836270B19065D005C7A69 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - ../../ogg/include, - ); - INSTALL_PATH = /usr/local/lib; - PREBINDING = NO; - PRODUCT_NAME = vorbisfile; - ZERO_LINK = NO; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 730F23EC091827B100AB638C /* Build configuration list for PBXNativeTarget "Vorbis" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 730F23ED091827B100AB638C /* Debug */, - 730F23EE091827B100AB638C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 730F23F3091827B200AB638C /* Build configuration list for PBXProject "Vorbis" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 730F23F4091827B200AB638C /* Debug */, - 730F23F5091827B200AB638C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 738835E50B18F88E005C7A69 /* Build configuration list for PBXNativeTarget "libvorbis (static)" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 738835E60B18F88E005C7A69 /* Debug */, - 738835E70B18F88E005C7A69 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 7388361A0B1904D6005C7A69 /* Build configuration list for PBXNativeTarget "libvorbisenc (static)" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 7388361B0B1904D6005C7A69 /* Debug */, - 7388361C0B1904D6005C7A69 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 738836250B19065D005C7A69 /* Build configuration list for PBXNativeTarget "libvorbisfile (static)" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 738836260B19065D005C7A69 /* Debug */, - 738836270B19065D005C7A69 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 0867D690FE84028FC02AAC07 /* Project object */; -} diff --git a/Engine/lib/libvorbis/symbian/bld.inf b/Engine/lib/libvorbis/symbian/bld.inf deleted file mode 100644 index 341e93639..000000000 --- a/Engine/lib/libvorbis/symbian/bld.inf +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - 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 CSIRO Australia nor the names of its - 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 ORGANISATION 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. -*/ - -PRJ_MMPFILES - -vorbis.mmp diff --git a/Engine/lib/libvorbis/symbian/vorbis.mmp b/Engine/lib/libvorbis/symbian/vorbis.mmp deleted file mode 100644 index 4fdeb4093..000000000 --- a/Engine/lib/libvorbis/symbian/vorbis.mmp +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - 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 CSIRO Australia nor the names of its - 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 ORGANISATION 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. -*/ - -TARGET vorbis.lib -TARGETTYPE lib -UID 0 -MACRO HAVE_CONFIG_H -SOURCEPATH ..\lib -SOURCE analysis.c barkmel.c bitrate.c block.c codebook.c envelope.c floor0.c floor1.c info.c -SOURCE lookup.c lpc.c lsp.c mapping0.c mdct.c psy.c registry.c res0.c sharedbook.c -SOURCE smallft.c synthesis.c vorbisfile.c window.c - -USERINCLUDE . ..\include -SYSTEMINCLUDE \epoc32\include \epoc32\include\libc ..\include ..\..\ogg\include ..\..\ogg\symbian diff --git a/Engine/lib/libvorbis/test/Makefile.am b/Engine/lib/libvorbis/test/Makefile.am deleted file mode 100644 index b68ebdb12..000000000 --- a/Engine/lib/libvorbis/test/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -## Process this file with automake to produce Makefile.in - -AUTOMAKE_OPTIONS = foreign - -check_PROGRAMS = test - -check: $(check_PROGRAMS) - ./test$(EXEEXT) - -AM_CPPFLAGS = -I$(top_srcdir)/include @OGG_CFLAGS@ - -test_SOURCES = util.c util.h write_read.c write_read.h test.c -test_LDADD = ../lib/libvorbisenc.la ../lib/libvorbis.la @OGG_LIBS@ @VORBIS_LIBS@ - -debug: - $(MAKE) check CFLAGS="@DEBUG@" - -profile: - $(MAKE) check CFLAGS="@PROFILE@" diff --git a/Engine/lib/libvorbis/test/test.c b/Engine/lib/libvorbis/test/test.c deleted file mode 100644 index e9b48744f..000000000 --- a/Engine/lib/libvorbis/test/test.c +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: vorbis coded test suite using vorbisfile - - ********************************************************************/ - -#include -#include -#include - -#include "util.h" -#include "write_read.h" - -#define DATA_LEN 2048 - -#define MAX(a,b) ((a) > (b) ? (a) : (b)) - - -static int check_output (const float * data_in, unsigned len, float allowable); - -int -main(void){ - static float data_out [DATA_LEN] ; - static float data_in [DATA_LEN] ; - - /* Do safest and most used sample rates first. */ - int sample_rates [] = { 44100, 48000, 32000, 22050, 16000, 96000 } ; - unsigned k ; - int errors = 0 ; - int ch; - - gen_windowed_sine (data_out, ARRAY_LEN (data_out), 0.95); - - for(ch=1;ch<=8;ch++){ - float q=-.05; - printf("\nTesting %d channel%s\n\n",ch,ch==1?"":"s"); - while(q<1.){ - for (k = 0 ; k < ARRAY_LEN (sample_rates); k ++) { - char filename [64] ; - snprintf (filename, sizeof (filename), "vorbis_%dch_q%.1f_%u.ogg", ch,q*10,sample_rates [k]); - - printf (" %-20s : ", filename); - fflush (stdout); - - /* Set to know value. */ - set_data_in (data_in, ARRAY_LEN (data_in), 3.141); - - write_vorbis_data_or_die (filename, sample_rates [k], q, data_out, ARRAY_LEN (data_out),ch); - read_vorbis_data_or_die (filename, sample_rates [k], data_in, ARRAY_LEN (data_in)); - - if (check_output (data_in, ARRAY_LEN (data_in), (.15f - .1f*q)) != 0) - errors ++ ; - else { - puts ("ok"); - remove (filename); - } - } - q+=.1; - } - } - - if (errors) - exit (1); - - return 0; -} - -static int -check_output (const float * data_in, unsigned len, float allowable) -{ - float max_abs = 0.0 ; - unsigned k ; - - for (k = 0 ; k < len ; k++) { - float temp = fabs (data_in [k]); - max_abs = MAX (max_abs, temp); - } - - if (max_abs < 0.95-allowable) { - printf ("Error : max_abs (%f) too small.\n", max_abs); - return 1 ; - } else if (max_abs > .95+allowable) { - printf ("Error : max_abs (%f) too big.\n", max_abs); - return 1 ; - } - - return 0 ; -} - diff --git a/Engine/lib/libvorbis/test/util.c b/Engine/lib/libvorbis/test/util.c deleted file mode 100644 index 3dc1597c3..000000000 --- a/Engine/lib/libvorbis/test/util.c +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: utility functions for vorbis codec test suite. - - ********************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include - -#include "util.h" - -void -gen_windowed_sine (float *data, int len, float maximum) -{ int k ; - - memset (data, 0, len * sizeof (float)) ; - - len /= 2 ; - - for (k = 0 ; k < len ; k++) - { data [k] = sin (2.0 * k * M_PI * 1.0 / 32.0 + 0.4) ; - - /* Apply Hanning Window. */ - data [k] *= maximum * (0.5 - 0.5 * cos (2.0 * M_PI * k / ((len) - 1))) ; - } - - return ; -} - -void -set_data_in (float * data, unsigned len, float value) -{ unsigned k ; - - for (k = 0 ; k < len ; k++) - data [k] = value ; -} diff --git a/Engine/lib/libvorbis/test/util.h b/Engine/lib/libvorbis/test/util.h deleted file mode 100644 index 9fe471c0a..000000000 --- a/Engine/lib/libvorbis/test/util.h +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: utility functions for vorbis codec test suite. - - ********************************************************************/ - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -/* Create simple test data consisting of a windowed sine wave. */ -void gen_windowed_sine (float *data, int len, float maximum) ; - -/* Set len values of data array to given value. */ -void set_data_in (float * data, unsigned len, float value) ; diff --git a/Engine/lib/libvorbis/test/write_read.c b/Engine/lib/libvorbis/test/write_read.c deleted file mode 100644 index 949524095..000000000 --- a/Engine/lib/libvorbis/test/write_read.c +++ /dev/null @@ -1,297 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: utility functions for vorbis codec test suite. - - ********************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include - -#include "write_read.h" - -/* The following function is basically a hacked version of the code in - * examples/encoder_example.c */ -void -write_vorbis_data_or_die (const char *filename, int srate, float q, const float * data, int count, int ch) -{ - FILE * file ; - ogg_stream_state os; - ogg_page og; - ogg_packet op; - vorbis_info vi; - vorbis_comment vc; - vorbis_dsp_state vd; - vorbis_block vb; - - int eos = 0, ret; - - if ((file = fopen (filename, "wb")) == NULL) { - printf("\n\nError : fopen failed : %s\n", strerror (errno)) ; - exit (1) ; - } - - /********** Encode setup ************/ - - vorbis_info_init (&vi); - - ret = vorbis_encode_init_vbr (&vi,ch,srate,q); - if (ret) { - printf ("vorbis_encode_init_vbr return %d\n", ret) ; - exit (1) ; - } - - vorbis_comment_init (&vc); - vorbis_comment_add_tag (&vc,"ENCODER","test/util.c"); - vorbis_analysis_init (&vd,&vi); - vorbis_block_init (&vd,&vb); - - ogg_stream_init (&os,12345678); - - { - ogg_packet header; - ogg_packet header_comm; - ogg_packet header_code; - - vorbis_analysis_headerout (&vd,&vc,&header,&header_comm,&header_code); - ogg_stream_packetin (&os,&header); - ogg_stream_packetin (&os,&header_comm); - ogg_stream_packetin (&os,&header_code); - - /* Ensures the audio data will start on a new page. */ - while (!eos){ - int result = ogg_stream_flush (&os,&og); - if (result == 0) - break; - fwrite (og.header,1,og.header_len,file); - fwrite (og.body,1,og.body_len,file); - } - - } - - { - /* expose the buffer to submit data */ - float **buffer = vorbis_analysis_buffer (&vd,count); - int i; - - for(i=0;i 0 && read_total < count) { - int bout = samples < count ? samples : count; - bout = read_total + bout > count ? count - read_total : bout; - - memcpy (data + read_total, pcm[0], bout * sizeof (float)) ; - - vorbis_synthesis_read (&vd,bout); - read_total += bout ; - } - } - } - - if (ogg_page_eos (&og)) eos = 1; - } - } - - if (!eos) { - buffer = ogg_sync_buffer (&oy,4096); - bytes = fread (buffer,1,4096,file); - ogg_sync_wrote (&oy,bytes); - if (bytes == 0) eos = 1; - } - } - - ogg_stream_clear (&os); - - vorbis_block_clear (&vb); - vorbis_dsp_clear (&vd); - vorbis_comment_clear (&vc); - vorbis_info_clear (&vi); - } -done_decode: - - /* OK, clean up the framer */ - ogg_sync_clear (&oy); - - fclose (file) ; -} - diff --git a/Engine/lib/libvorbis/test/write_read.h b/Engine/lib/libvorbis/test/write_read.h deleted file mode 100644 index b99609aa4..000000000 --- a/Engine/lib/libvorbis/test/write_read.h +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: utility functions for vorbis codec test suite. - - ********************************************************************/ - -/* Write supplied data to an Ogg/Vorbis file with specified filename at - * specified sample rate. Assumes a single channel of audio. */ -void write_vorbis_data_or_die (const char *filename, int srate, float q, - const float * data, int count, int ch) ; - -/* Read given Ogg/Vorbis file into data specified data array. This - * function is basically the inverse of the one above. Again, assumes - * a single channel of audio. */ -void read_vorbis_data_or_die (const char *filename, int srate, - float * data, int count) ; - diff --git a/Engine/lib/libvorbis/vorbis-uninstalled.pc.in b/Engine/lib/libvorbis/vorbis-uninstalled.pc.in deleted file mode 100644 index aa70a0190..000000000 --- a/Engine/lib/libvorbis/vorbis-uninstalled.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -# vorbis uninstalled pkg-config file - -prefix= -exec_prefix= -libdir=${pcfiledir}/lib -includedir=${pcfiledir}/include - -Name: vorbis -Description: vorbis is the primary Ogg Vorbis library (uninstalled) -Version: @VERSION@ -Requires: ogg -Conflicts: -Libs: @VORBIS_LIBS@ ${libdir}/libvorbis.la -Cflags: -I${includedir} diff --git a/Engine/lib/libvorbis/vorbis.m4 b/Engine/lib/libvorbis/vorbis.m4 deleted file mode 100644 index 7b67c584e..000000000 --- a/Engine/lib/libvorbis/vorbis.m4 +++ /dev/null @@ -1,136 +0,0 @@ -# Configure paths for libvorbis -# Jack Moffitt 10-21-2000 -# Shamelessly stolen from Owen Taylor and Manish Singh -# thomasvs added check for vorbis_bitrate_addblock which is new in rc3 - -dnl XIPH_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS -dnl -AC_DEFUN([XIPH_PATH_VORBIS], -[dnl -dnl Get the cflags and libraries -dnl -AC_ARG_WITH(vorbis,AC_HELP_STRING([--with-vorbis=PFX],[Prefix where libvorbis is installed (optional)]), vorbis_prefix="$withval", vorbis_prefix="") -AC_ARG_WITH(vorbis-libraries,AC_HELP_STRING([--with-vorbis-libraries=DIR],[Directory where libvorbis library is installed (optional)]), vorbis_libraries="$withval", vorbis_libraries="") -AC_ARG_WITH(vorbis-includes,AC_HELP_STRING([--with-vorbis-includes=DIR],[Directory where libvorbis header files are installed (optional)]), vorbis_includes="$withval", vorbis_includes="") -AC_ARG_ENABLE(vorbistest,AC_HELP_STRING([--disable-vorbistest],[Do not try to compile and run a test Vorbis program]),, enable_vorbistest=yes) - - if test "x$vorbis_libraries" != "x" ; then - VORBIS_LIBS="-L$vorbis_libraries" - elif test "x$vorbis_prefix" = "xno" || test "x$vorbis_prefix" = "xyes" ; then - VORBIS_LIBS="" - elif test "x$vorbis_prefix" != "x" ; then - VORBIS_LIBS="-L$vorbis_prefix/lib" - elif test "x$prefix" != "xNONE"; then - VORBIS_LIBS="-L$prefix/lib" - fi - - if test "x$vorbis_prefix" != "xno" ; then - VORBIS_LIBS="$VORBIS_LIBS -lvorbis -lm" - fi - VORBISFILE_LIBS="-lvorbisfile" - VORBISENC_LIBS="-lvorbisenc" - - if test "x$vorbis_includes" != "x" ; then - VORBIS_CFLAGS="-I$vorbis_includes" - elif test "x$vorbis_prefix" = "xno" || test "x$vorbis_prefix" = "xyes" ; then - VORBIS_CFLAGS="" - elif test "x$vorbis_prefix" != "x" ; then - VORBIS_CFLAGS="-I$vorbis_prefix/include" - elif test "x$prefix" != "xNONE"; then - VORBIS_CFLAGS="-I$prefix/include" - fi - - - AC_MSG_CHECKING(for Vorbis) - if test "x$vorbis_prefix" = "xno" ; then - no_vorbis="disabled" - enable_vorbistest="no" - else - no_vorbis="" - fi - - - if test "x$enable_vorbistest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $VORBIS_CFLAGS $OGG_CFLAGS" - LIBS="$LIBS $VORBIS_LIBS $VORBISENC_LIBS $OGG_LIBS" -dnl -dnl Now check if the installed Vorbis is sufficiently new. -dnl - rm -f conf.vorbistest - AC_TRY_RUN([ -#include -#include -#include -#include -#include - -int main () -{ - vorbis_block vb; - vorbis_dsp_state vd; - vorbis_info vi; - - vorbis_info_init (&vi); - vorbis_encode_init (&vi, 2, 44100, -1, 128000, -1); - vorbis_analysis_init (&vd, &vi); - vorbis_block_init (&vd, &vb); - /* this function was added in 1.0rc3, so this is what we're testing for */ - vorbis_bitrate_addblock (&vb); - - system("touch conf.vorbistest"); - return 0; -} - -],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - - if test "x$no_vorbis" = "xdisabled" ; then - AC_MSG_RESULT(no) - ifelse([$2], , :, [$2]) - elif test "x$no_vorbis" = "x" ; then - AC_MSG_RESULT(yes) - ifelse([$1], , :, [$1]) - else - AC_MSG_RESULT(no) - if test -f conf.vorbistest ; then - : - else - echo "*** Could not run Vorbis test program, checking why..." - CFLAGS="$CFLAGS $VORBIS_CFLAGS" - LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS" - AC_TRY_LINK([ -#include -#include -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding Vorbis or finding the wrong" - echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means Vorbis was incorrectly installed" - echo "*** or that you have moved Vorbis since it was installed." ]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - VORBIS_CFLAGS="" - VORBIS_LIBS="" - VORBISFILE_LIBS="" - VORBISENC_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(VORBIS_CFLAGS) - AC_SUBST(VORBIS_LIBS) - AC_SUBST(VORBISFILE_LIBS) - AC_SUBST(VORBISENC_LIBS) - rm -f conf.vorbistest -]) diff --git a/Engine/lib/libvorbis/vorbis.pc.in b/Engine/lib/libvorbis/vorbis.pc.in deleted file mode 100644 index f5ca77d0f..000000000 --- a/Engine/lib/libvorbis/vorbis.pc.in +++ /dev/null @@ -1,15 +0,0 @@ -# libvorbis pkg-config source file - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: vorbis -Description: vorbis is the primary Ogg Vorbis library -Version: @VERSION@ -Requires.private: ogg -Conflicts: -Libs: -L${libdir} -lvorbis -Libs.private: @VORBIS_LIBS@ -Cflags: -I${includedir} diff --git a/Engine/lib/libvorbis/vorbisenc-uninstalled.pc.in b/Engine/lib/libvorbis/vorbisenc-uninstalled.pc.in deleted file mode 100644 index 4667d9cfd..000000000 --- a/Engine/lib/libvorbis/vorbisenc-uninstalled.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -# vorbisenc uninstalled pkg-config file - -prefix= -exec_prefix= -libdir=${pcfiledir}/lib -includedir=${pcfiledir}/include - -Name: vorbisenc -Description: vorbisenc is a library that provides a convenient API for setting up an encoding environment using libvorbis (uninstalled) -Version: @VERSION@ -Requires: vorbis -Conflicts: -Libs: ${libdir}/libvorbisenc.la -Cflags: -I${includedir} diff --git a/Engine/lib/libvorbis/vorbisenc.pc.in b/Engine/lib/libvorbis/vorbisenc.pc.in deleted file mode 100644 index a412b7a55..000000000 --- a/Engine/lib/libvorbis/vorbisenc.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -# libvorbisenc pkg-config source file - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: vorbisenc -Description: vorbisenc is a library that provides a convenient API for setting up an encoding environment using libvorbis -Version: @VERSION@ -Requires.private: vorbis -Conflicts: -Libs: -L${libdir} -lvorbisenc -Cflags: -I${includedir} diff --git a/Engine/lib/libvorbis/vorbisfile-uninstalled.pc.in b/Engine/lib/libvorbis/vorbisfile-uninstalled.pc.in deleted file mode 100644 index 2e7e96d8e..000000000 --- a/Engine/lib/libvorbis/vorbisfile-uninstalled.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -# vorbisfile uninstalled pkg-config file - -prefix= -exec_prefix= -libdir=${pcfiledir}/lib -includedir=${pcfiledir}/include - -Name: vorbisfile -Description: vorbisfile is a library that provides a convenient high-level API for decoding and basic manipulation of all Vorbis I audio streams (uninstalled) -Version: @VERSION@ -Requires: vorbis -Conflicts: -Libs: ${libdir}/libvorbisfile.la -Cflags: -I${includedir} diff --git a/Engine/lib/libvorbis/vorbisfile.pc.in b/Engine/lib/libvorbis/vorbisfile.pc.in deleted file mode 100644 index e58a071f2..000000000 --- a/Engine/lib/libvorbis/vorbisfile.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -# libvorbisfile pkg-config source file - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: vorbisfile -Description: vorbisfile is a library that provides a convenient high-level API for decoding and basic manipulation of all Vorbis I audio streams -Version: @VERSION@ -Requires.private: vorbis -Conflicts: -Libs: -L${libdir} -lvorbisfile -Cflags: -I${includedir} diff --git a/Engine/lib/libvorbis/vq/16.vqs b/Engine/lib/libvorbis/vq/16.vqs deleted file mode 100644 index 3d15f4085..000000000 --- a/Engine/lib/libvorbis/vq/16.vqs +++ /dev/null @@ -1,74 +0,0 @@ - -GO - ->_16c0_s noninterleaved -haux 16c0_s/resaux_0.vqd _16c0_s_single 0,64,2 10 - -:_p1_0 16c0_s/res_sub0_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 16c0_s/res_sub0_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 16c0_s/res_sub0_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 16c0_s/res_sub0_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 16c0_s/res_sub0_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 16c0_s/res_sub0_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p7_0 16c0_s/res_sub0_part7_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p7_1 16c0_s/res_sub0_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 16c0_s/res_sub0_part8_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p8_1 16c0_s/res_sub0_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p9_0 16c0_s/res_sub0_part9_pass0.vqd, 4, nonseq, 0 +- 315 -:_p9_1 16c0_s/res_sub0_part9_pass1.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p9_2 16c0_s/res_sub0_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 - ->_16c1s_s noninterleaved -haux 16c1_s/resaux_0.vqd _16c1_s_short 0,64,2 10 - ->_16c1_s noninterleaved -haux 16c1_s/resaux_1.vqd _16c1_s_long 0,64,2 10 - -:_p1_0 16c1_s/res_sub0_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 16c1_s/res_sub0_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 16c1_s/res_sub0_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 16c1_s/res_sub0_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 16c1_s/res_sub0_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 16c1_s/res_sub0_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p7_0 16c1_s/res_sub0_part7_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p7_1 16c1_s/res_sub0_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 16c1_s/res_sub0_part8_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p8_1 16c1_s/res_sub0_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p9_0 16c1_s/res_sub0_part9_pass0.vqd, 2, nonseq, 0 +- 315 630 945 1260 1575 1890 -:_p9_1 16c1_s/res_sub0_part9_pass1.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p9_2 16c1_s/res_sub0_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 - ->_16c2s_s noninterleaved -haux 16c2_s/resaux_0.vqd _16c2_s_short 0,64,2 10 ->_16c2_s noninterleaved -haux 16c2_s/resaux_1.vqd _16c2_s_long 0,64,2 10 - -:_p1_0 16c2_s/res_sub0_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 16c2_s/res_sub0_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 16c2_s/res_sub0_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 16c2_s/res_sub0_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p5_0 16c2_s/res_sub0_part5_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p5_1 16c2_s/res_sub0_part5_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p6_0 16c2_s/res_sub0_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 16c2_s/res_sub0_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 16c2_s/res_sub0_part7_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 66 -:_p7_1 16c2_s/res_sub0_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 16c2_s/res_sub0_part8_pass0.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p8_1 16c2_s/res_sub0_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 9 10 - -:_p9_0 16c2_s/res_sub0_part9_pass0.vqd, 2, nonseq, 0 +- 931 1862 2793 3724 4655 5586 6517 7448 -:_p9_1 16c2_s/res_sub0_part9_pass1.vqd, 2, nonseq, 0 +- 49 98 147 196 245 294 343 392 441 -:_p9_2 16c2_s/res_sub0_part9_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 - diff --git a/Engine/lib/libvorbis/vq/16u.vqs b/Engine/lib/libvorbis/vq/16u.vqs deleted file mode 100644 index 854de98f7..000000000 --- a/Engine/lib/libvorbis/vq/16u.vqs +++ /dev/null @@ -1,69 +0,0 @@ - -GO - ->_16u0_ noninterleaved -haux 16u0/resaux_0.vqd _16u0__single 0,64,2 8 - -:_p1_0 16u0/res_sub0_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 16u0/res_sub0_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 16u0/res_sub0_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 16u0/res_sub0_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 16u0/res_sub0_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p6_0 16u0/res_sub0_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 16u0/res_sub0_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 16u0/res_sub0_part7_pass0.vqd, 4, nonseq, 0 +- 315 -:_p7_1 16u0/res_sub0_part7_pass1.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p7_2 16u0/res_sub0_part7_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 - - ->_16u1s_ noninterleaved -haux 16u1/resaux_0.vqd _16u1__short 0,64,2 10 ->_16u1_ noninterleaved -haux 16u1/resaux_1.vqd _16u1__long 0,64,2 10 - -:_p1_0 16u1/res_sub0_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 16u1/res_sub0_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 16u1/res_sub0_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 16u1/res_sub0_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 16u1/res_sub0_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 16u1/res_sub0_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p7_0 16u1/res_sub0_part7_pass0.vqd, 4, nonseq, 0 +- 11 -:_p7_1 16u1/res_sub0_part7_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p8_0 16u1/res_sub0_part8_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 -:_p8_1 16u1/res_sub0_part8_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p9_0 16u1/res_sub0_part9_pass0.vqd, 2, nonseq, 0 +- 255 510 765 1020 1275 1530 1785 -:_p9_1 16u1/res_sub0_part9_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 119 -:_p9_2 16u1/res_sub0_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 - ->_16u2s noninterleaved -haux 16u2/resaux_0.vqd _16u2__short 0,16,2 10 - ->_16u2 noninterleaved -haux 16u2/resaux_1.vqd _16u2__long 0,64,2 10 - -:_p1_0 16u2/res_sub0_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 16u2/res_sub0_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 16u2/res_sub0_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 16u2/res_sub0_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p5_0 16u2/res_sub0_part5_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p5_1 16u2/res_sub0_part5_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p6_0 16u2/res_sub0_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 16u2/res_sub0_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 16u2/res_sub0_part7_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 66 -:_p7_1 16u2/res_sub0_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 16u2/res_sub0_part8_pass0.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p8_1 16u2/res_sub0_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 9 10 - -:_p9_0 16u2/res_sub0_part9_pass0.vqd, 2, nonseq, 0 +- 931 1862 2793 3724 4655 5586 6517 -:_p9_1 16u2/res_sub0_part9_pass1.vqd, 2, nonseq, 0 +- 49 98 147 196 245 294 343 392 441 -:_p9_2 16u2/res_sub0_part9_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 - diff --git a/Engine/lib/libvorbis/vq/44c-1.vqs b/Engine/lib/libvorbis/vq/44c-1.vqs deleted file mode 100644 index ff30d65d1..000000000 --- a/Engine/lib/libvorbis/vq/44c-1.vqs +++ /dev/null @@ -1,63 +0,0 @@ -GO - ->_44cn1s_s noninterleaved -haux 44c-1_s/resaux_0.vqd _44cn1_s_short 0,16,2 9 - ->_44cn1_s noninterleaved -haux 44c-1_s/resaux_1.vqd _44cn1_s_long 0,64,2 9 - -# 0 1 2 2 4 8 16 32 + -# 0 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 -# 1 . . . -# 2 . . . -# 4 . . . . . . - -:_p1_0 44c-1_s/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c-1_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c-1_s/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c-1_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c-1_s/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p6_0 44c-1_s/res_part6_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p6_1 44c-1_s/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p7_0 44c-1_s/res_part7_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p7_1 44c-1_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p8_0 44c-1_s/res_part8_pass0.vqd, 4, nonseq, 0 +- 221 442 -:_p8_1 44c-1_s/res_part8_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 -:_p8_2 44c-1_s/res_part8_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 - - ->_44cn1s_sm noninterleaved -haux 44c-1_sm/resaux_0.vqd _44cn1_sm_short 0,16,2 9 - ->_44cn1_sm noninterleaved -haux 44c-1_sm/resaux_1.vqd _44cn1_sm_long 0,64,2 9 - -# 0 1 2 2 4 8 16 32 + -# 0 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 -# 1 . . . -# 2 . . . -# 4 . . . . . . - -:_p1_0 44c-1_sm/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c-1_sm/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c-1_sm/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c-1_sm/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c-1_sm/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p6_0 44c-1_sm/res_part6_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p6_1 44c-1_sm/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p7_0 44c-1_sm/res_part7_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p7_1 44c-1_sm/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p8_0 44c-1_sm/res_part8_pass0.vqd, 2, nonseq, 0 +- 221 442 663 884 -:_p8_1 44c-1_sm/res_part8_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 -:_p8_2 44c-1_sm/res_part8_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 - diff --git a/Engine/lib/libvorbis/vq/44c0.vqs b/Engine/lib/libvorbis/vq/44c0.vqs deleted file mode 100644 index f650f8f4f..000000000 --- a/Engine/lib/libvorbis/vq/44c0.vqs +++ /dev/null @@ -1,65 +0,0 @@ -GO - ->_44c0s_s noninterleaved -haux 44c0_s/resaux_0.vqd _44c0_s_short 0,16,2 9 - ->_44c0_s noninterleaved -haux 44c0_s/resaux_1.vqd _44c0_s_long 0,64,2 9 - -# 0 1 2 2 4 8 16 32 + -# 0 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 -# 1 . . . -# 2 . . . -# 4 . . . . . . - -:_p1_0 44c0_s/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c0_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c0_s/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c0_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c0_s/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p6_0 44c0_s/res_part6_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p6_1 44c0_s/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p7_0 44c0_s/res_part7_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p7_1 44c0_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p8_0 44c0_s/res_part8_pass0.vqd, 4, nonseq, 0 +- 221 442 -:_p8_1 44c0_s/res_part8_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 -:_p8_2 44c0_s/res_part8_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 - - ->_44c0s_sm noninterleaved -haux 44c0_sm/resaux_0.vqd _44c0_sm_short 0,16,2 9 - ->_44c0_sm noninterleaved -haux 44c0_sm/resaux_1.vqd _44c0_sm_long 0,64,2 9 - -# 0 1 2 2 4 8 16 32 + -# 0 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 -# 1 . . . -# 2 . . . -# 4 . . . . . . - -:_p1_0 44c0_sm/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c0_sm/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c0_sm/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c0_sm/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c0_sm/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p6_0 44c0_sm/res_part6_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p6_1 44c0_sm/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p7_0 44c0_sm/res_part7_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p7_1 44c0_sm/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p8_0 44c0_sm/res_part8_pass0.vqd, 2, nonseq, 0 +- 221 442 663 884 -:_p8_1 44c0_sm/res_part8_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 -:_p8_2 44c0_sm/res_part8_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 - diff --git a/Engine/lib/libvorbis/vq/44c1.vqs b/Engine/lib/libvorbis/vq/44c1.vqs deleted file mode 100644 index c21a6b369..000000000 --- a/Engine/lib/libvorbis/vq/44c1.vqs +++ /dev/null @@ -1,66 +0,0 @@ - -GO - ->_44c1s_s noninterleaved -haux 44c1_s/resaux_0.vqd _44c1_s_short 0,16,2 9 - ->_44c1_s noninterleaved -haux 44c1_s/resaux_1.vqd _44c1_s_long 0,64,2 9 - -# 0 1 2 2 4 8 16 32 + -# 0 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 -# 1 . . . -# 2 . . . -# 4 . . . . . . - -:_p1_0 44c1_s/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c1_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c1_s/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c1_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c1_s/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p6_0 44c1_s/res_part6_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p6_1 44c1_s/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p7_0 44c1_s/res_part7_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p7_1 44c1_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p8_0 44c1_s/res_part8_pass0.vqd, 2, nonseq, 0 +- 221 442 663 884 1105 1326 -:_p8_1 44c1_s/res_part8_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 -:_p8_2 44c1_s/res_part8_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 - - ->_44c1s_sm noninterleaved -haux 44c1_sm/resaux_0.vqd _44c1_sm_short 0,16,2 9 - ->_44c1_sm noninterleaved -haux 44c1_sm/resaux_1.vqd _44c1_sm_long 0,64,2 9 - -# 0 1 2 2 4 8 16 32 + -# 0 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 -# 1 . . . -# 2 . . . -# 4 . . . . . . - -:_p1_0 44c1_sm/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c1_sm/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c1_sm/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c1_sm/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c1_sm/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p6_0 44c1_sm/res_part6_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p6_1 44c1_sm/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p7_0 44c1_sm/res_part7_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p7_1 44c1_sm/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p8_0 44c1_sm/res_part8_pass0.vqd, 2, nonseq, 0 +- 221 442 663 884 1105 1326 -:_p8_1 44c1_sm/res_part8_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 -:_p8_2 44c1_sm/res_part8_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 - diff --git a/Engine/lib/libvorbis/vq/44c2.vqs b/Engine/lib/libvorbis/vq/44c2.vqs deleted file mode 100644 index 9fdbd03fe..000000000 --- a/Engine/lib/libvorbis/vq/44c2.vqs +++ /dev/null @@ -1,37 +0,0 @@ -GO - ->_44c2s_s noninterleaved -haux 44c2_s/resaux_0.vqd _44c2_s_short 0,16,2 10 - ->_44c2_s noninterleaved -haux 44c2_s/resaux_1.vqd _44c2_s_long 0,64,2 10 - -#iter 0 - -# 0 1 1 2 2 4 8 16 32 + -# 0 99 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . -# 2 . . . -# 4 . . . . . . . - -:_p1_0 44c2_s/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c2_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c2_s/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44c2_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c2_s/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 44c2_s/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p7_0 44c2_s/res_part7_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p7_1 44c2_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44c2_s/res_part8_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p8_1 44c2_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p9_0 44c2_s/res_part9_pass0.vqd, 2, nonseq, 0 +- 221 442 663 884 1105 1326 -:_p9_1 44c2_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 -:_p9_2 44c2_s/res_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 - - \ No newline at end of file diff --git a/Engine/lib/libvorbis/vq/44c3.vqs b/Engine/lib/libvorbis/vq/44c3.vqs deleted file mode 100644 index 57a1317f3..000000000 --- a/Engine/lib/libvorbis/vq/44c3.vqs +++ /dev/null @@ -1,36 +0,0 @@ - -GO - ->_44c3s_s noninterleaved -haux 44c3_s/resaux_0.vqd _44c3_s_short 0,16,2 10 - ->_44c3_s noninterleaved -haux 44c3_s/resaux_1.vqd _44c3_s_long 0,64,2 10 - -#iter 0 - -# 0 1 1 2 2 4 8 16 32 + -# 0 99 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . -# 2 . . . -# 4 . . . . . . . - -:_p1_0 44c3_s/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c3_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c3_s/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44c3_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c3_s/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 44c3_s/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p7_0 44c3_s/res_part7_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p7_1 44c3_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44c3_s/res_part8_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p8_1 44c3_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p9_0 44c3_s/res_part9_pass0.vqd, 2, nonseq, 0 +- 255 510 765 1020 1275 1530 -:_p9_1 44c3_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 119 -:_p9_2 44c3_s/res_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 diff --git a/Engine/lib/libvorbis/vq/44c4.vqs b/Engine/lib/libvorbis/vq/44c4.vqs deleted file mode 100644 index 82a36e192..000000000 --- a/Engine/lib/libvorbis/vq/44c4.vqs +++ /dev/null @@ -1,36 +0,0 @@ - -GO - ->_44c4s_s noninterleaved -haux 44c4_s/resaux_0.vqd _44c4_s_short 0,16,2 10 - ->_44c4_s noninterleaved -haux 44c4_s/resaux_1.vqd _44c4_s_long 0,64,2 10 - -#iter 0 - -# 0 1 1 2 2 4 8 16 32 + -# 0 99 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . -# 2 . . . -# 4 . . . . . . . - -:_p1_0 44c4_s/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c4_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c4_s/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44c4_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c4_s/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 44c4_s/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p7_0 44c4_s/res_part7_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p7_1 44c4_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44c4_s/res_part8_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p8_1 44c4_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p9_0 44c4_s/res_part9_pass0.vqd, 2, nonseq, 0 +- 315 630 945 1260 1575 1890 -:_p9_1 44c4_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p9_2 44c4_s/res_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 diff --git a/Engine/lib/libvorbis/vq/44c5.vqs b/Engine/lib/libvorbis/vq/44c5.vqs deleted file mode 100644 index 9790843bb..000000000 --- a/Engine/lib/libvorbis/vq/44c5.vqs +++ /dev/null @@ -1,37 +0,0 @@ - -GO - ->_44c5s_s noninterleaved -haux 44c5_s/resaux_0.vqd _44c5_s_short 0,16,2 10 - ->_44c5_s noninterleaved -haux 44c5_s/resaux_1.vqd _44c5_s_long 0,64,2 10 - -#iter 0 - -# 0 1 1 2 2 4 8 16 32 + -# 0 99 0 99 4 8 16 32 + - -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . -# 2 . . . -# 4 . . . . . . . - -:_p1_0 44c5_s/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 44c5_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c5_s/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44c5_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 44c5_s/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 44c5_s/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p7_0 44c5_s/res_part7_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p7_1 44c5_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44c5_s/res_part8_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p8_1 44c5_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p9_0 44c5_s/res_part9_pass0.vqd, 2, nonseq, 0 +- 357 714 1071 1428 1785 2142 2499 -:_p9_1 44c5_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 168 -:_p9_2 44c5_s/res_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 - diff --git a/Engine/lib/libvorbis/vq/44c6.vqs b/Engine/lib/libvorbis/vq/44c6.vqs deleted file mode 100644 index f420dd012..000000000 --- a/Engine/lib/libvorbis/vq/44c6.vqs +++ /dev/null @@ -1,37 +0,0 @@ -GO - ->_44c6s_s noninterleaved -haux 44c6_s/resaux_0.vqd _44c6_s_short 0,16,2 10 - ->_44c6_s noninterleaved -haux 44c6_s/resaux_1.vqd _44c6_s_long 0,64,2 10 - - -# 0 1 2 4 8 16 32 71 157 + -# 1 2 3 4 8 16 71 157 + - -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . . . -# 2 . . . . . -# 4 . . . . . - -:_p1_0 44c6_s/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44c6_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c6_s/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c6_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p5_0 44c6_s/res_part5_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p5_1 44c6_s/res_part5_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p6_0 44c6_s/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44c6_s/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44c6_s/res_part7_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 66 -:_p7_1 44c6_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44c6_s/res_part8_pass0.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p8_1 44c6_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 9 10 - -:_p9_0 44c6_s/res_part9_pass0.vqd, 2, nonseq, 0 +- 637 1274 1911 2548 3185 3822 -:_p9_1 44c6_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 49 98 147 196 245 294 -:_p9_2 44c6_s/res_part9_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 diff --git a/Engine/lib/libvorbis/vq/44c7.vqs b/Engine/lib/libvorbis/vq/44c7.vqs deleted file mode 100644 index 088d81db0..000000000 --- a/Engine/lib/libvorbis/vq/44c7.vqs +++ /dev/null @@ -1,38 +0,0 @@ - -GO - ->_44c7s_s noninterleaved -haux 44c7_s/resaux_0.vqd _44c7_s_short 0,16,2 10 - ->_44c7_s noninterleaved -haux 44c7_s/resaux_1.vqd _44c7_s_long 0,64,2 10 - - -# 0 1 2 4 8 16 32 71 157 + -# 1 2 3 4 8 16 71 157 + - -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . . . -# 2 . . . . . -# 4 . . . . . - -:_p1_0 44c7_s/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44c7_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c7_s/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c7_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p5_0 44c7_s/res_part5_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p5_1 44c7_s/res_part5_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p6_0 44c7_s/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44c7_s/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44c7_s/res_part7_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 66 -:_p7_1 44c7_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44c7_s/res_part8_pass0.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p8_1 44c7_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 9 10 - -:_p9_0 44c7_s/res_part9_pass0.vqd, 2, nonseq, 0 +- 637 1274 1911 2548 3185 3822 -:_p9_1 44c7_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 49 98 147 196 245 294 -:_p9_2 44c7_s/res_part9_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 diff --git a/Engine/lib/libvorbis/vq/44c8.vqs b/Engine/lib/libvorbis/vq/44c8.vqs deleted file mode 100644 index ce5bdbe07..000000000 --- a/Engine/lib/libvorbis/vq/44c8.vqs +++ /dev/null @@ -1,39 +0,0 @@ - -GO - ->_44c8s_s noninterleaved -haux 44c8_s/resaux_0.vqd _44c8_s_short 0,16,2 10 - ->_44c8_s noninterleaved -haux44c8_s/resaux_1.vqd _44c8_s_long 0,64,2 10 - - -# 0 1 2 4 8 16 32 71 157 + -# 1 2 3 4 8 16 71 157 + - -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . . . -# 2 . . . . . -# 4 . . . . . - -:_p1_0 44c8_s/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44c8_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c8_s/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c8_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p5_0 44c8_s/res_part5_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p5_1 44c8_s/res_part5_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p6_0 44c8_s/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44c8_s/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44c8_s/res_part7_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 66 -:_p7_1 44c8_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44c8_s/res_part8_pass0.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p8_1 44c8_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 9 10 - -:_p9_0 44c8_s/res_part9_pass0.vqd, 2, nonseq, 0 +- 931 1862 2793 3724 4655 5586 6517 7448 -:_p9_1 44c8_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 49 98 147 196 245 294 343 392 441 -:_p9_2 44c8_s/res_part9_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 - diff --git a/Engine/lib/libvorbis/vq/44c9.vqs b/Engine/lib/libvorbis/vq/44c9.vqs deleted file mode 100644 index 1c54786cb..000000000 --- a/Engine/lib/libvorbis/vq/44c9.vqs +++ /dev/null @@ -1,37 +0,0 @@ -GO - ->_44c9s_s noninterleaved -haux 44c9_s/resaux_0.vqd _44c9_s_short 0,16,2 10 - ->_44c9_s noninterleaved -haux 44c9_s/resaux_1.vqd _44c9_s_long 0,64,2 10 - - -# 0 1 2 4 8 16 32 71 157 + -# 1 2 3 4 8 16 71 157 + - -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . . . -# 2 . . . . . -# 4 . . . . . - -:_p1_0 44c9_s/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44c9_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44c9_s/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44c9_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p5_0 44c9_s/res_part5_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p5_1 44c9_s/res_part5_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p6_0 44c9_s/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44c9_s/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44c9_s/res_part7_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 66 -:_p7_1 44c9_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44c9_s/res_part8_pass0.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p8_1 44c9_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 9 10 - -:_p9_0 44c9_s/res_part9_pass0.vqd, 2, nonseq, 0 +- 931 1862 2793 3724 4655 5586 6517 7448 8379 -:_p9_1 44c9_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 49 98 147 196 245 294 343 392 441 -:_p9_2 44c9_s/res_part9_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 diff --git a/Engine/lib/libvorbis/vq/44p-1.vqs b/Engine/lib/libvorbis/vq/44p-1.vqs deleted file mode 100644 index 02d26fb79..000000000 --- a/Engine/lib/libvorbis/vq/44p-1.vqs +++ /dev/null @@ -1,49 +0,0 @@ -GO - ->_44pn1 noninterleaved -haux 44pn1/resaux_0.vqd _44pn1_short 0,80,2 7 -haux 44pn1/resaux_1.vqd _44pn1_long 0,300,2 7 -haux 44pn1/resaux_2.vqd _44pn1_lfe 0,2,2 2 - -#iter 0 - -# 0 1 2 7 17 31 + -# 0 99 7 17 31 + - -# 0 1 2 3 4 5 6 -# 1 . . . . . -# 2 . . . . . . -# 4 . . - -:_p1_0 44pn1/res_sub0_part1_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p2_0 44pn1/res_sub0_part2_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p2_1 44pn1/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p3_0 44pn1/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p3_1 44pn1/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p4_0 44pn1/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p4_1 44pn1/res_sub0_part4_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p5_0 44pn1/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p5_1 44pn1/res_sub0_part5_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p4_1 :_p5_2 - -:_p6_0 44pn1/res_sub0_part6_pass0.vqd, 5, nonseq, 0 +- 625 -:_p6_1 44pn1/res_sub0_part6_pass1.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p6_2 44pn1/res_sub0_part6_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44pn1/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44pn1/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44pn1/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 -# reuse p7_2/3 for l1_1/2 diff --git a/Engine/lib/libvorbis/vq/44p0.vqs b/Engine/lib/libvorbis/vq/44p0.vqs deleted file mode 100644 index 16479ba66..000000000 --- a/Engine/lib/libvorbis/vq/44p0.vqs +++ /dev/null @@ -1,49 +0,0 @@ -GO - ->_44p0 noninterleaved -haux 44p0/resaux_0.vqd _44p0_short 0,42,2 7 -haux 44p0/resaux_1.vqd _44p0_long 0,170,2 7 -haux 44p0/resaux_2.vqd _44p0_lfe 0,2,2 2 - -#iter 0 - -# 0 1 2 7 17 31 + -# 0 99 7 17 31 + - -# 0 1 2 3 4 5 6 -# 1 . . . . . -# 2 . . . . . . -# 4 . . - -:_p1_0 44p0/res_sub0_part1_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p2_0 44p0/res_sub0_part2_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p2_1 44p0/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p3_0 44p0/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p3_1 44p0/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p4_0 44p0/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p4_1 44p0/res_sub0_part4_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p5_0 44p0/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p5_1 44p0/res_sub0_part5_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p4_1 :_p5_2 - -:_p6_0 44p0/res_sub0_part6_pass0.vqd, 5, nonseq, 0 +- 625 -:_p6_1 44p0/res_sub0_part6_pass1.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p6_2 44p0/res_sub0_part6_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p0/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p0/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p0/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 -# reuse p7_2/3 for l1_1/2 diff --git a/Engine/lib/libvorbis/vq/44p1.vqs b/Engine/lib/libvorbis/vq/44p1.vqs deleted file mode 100644 index 74352c31c..000000000 --- a/Engine/lib/libvorbis/vq/44p1.vqs +++ /dev/null @@ -1,49 +0,0 @@ -GO - ->_44p1 noninterleaved -haux 44p1/resaux_0.vqd _44p1_short 0,42,2 7 -haux 44p1/resaux_1.vqd _44p1_long 0,170,2 7 -haux 44p1/resaux_2.vqd _44p1_lfe 0,2,2 2 - -#iter 0 - -# 0 1 2 7 17 31 + -# 0 99 7 17 31 + - -# 0 1 2 3 4 5 6 -# 1 . . . . . -# 2 . . . . . . -# 4 . . - -:_p1_0 44p1/res_sub0_part1_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p2_0 44p1/res_sub0_part2_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p2_1 44p1/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p3_0 44p1/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p3_1 44p1/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p4_0 44p1/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p4_1 44p1/res_sub0_part4_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p5_0 44p1/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p5_1 44p1/res_sub0_part5_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p4_1 :_p5_2 - -:_p6_0 44p1/res_sub0_part6_pass0.vqd, 5, nonseq, 0 +- 625 -:_p6_1 44p1/res_sub0_part6_pass1.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p6_2 44p1/res_sub0_part6_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p1/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p1/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p1/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 -# reuse p7_2/3 for l1_1/2 diff --git a/Engine/lib/libvorbis/vq/44p2.vqs b/Engine/lib/libvorbis/vq/44p2.vqs deleted file mode 100644 index 7eabbab4a..000000000 --- a/Engine/lib/libvorbis/vq/44p2.vqs +++ /dev/null @@ -1,52 +0,0 @@ -GO - ->_44p2 noninterleaved -haux 44p2/resaux_0.vqd _44p2_short 0,42,2 8 -haux 44p2/resaux_1.vqd _44p2_long 0,170,2 8 -haux 44p2/resaux_2.vqd _44p2_lfe 0,2,2 2 - -#iter 0 - -# 0 1 1 2 7 17 31 + -# 0 99 99 7 17 31 + - -# 0 1 2 3 4 5 6 7 -# 1 . . . . . -# 2 . . . . . . -# 4 . . . -# 8 . - -:_p1_0 44p2/res_sub0_part1_pass2.vqd, 5, nonseq cull, 0 +- 1 -:_p2_0 44p2/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p3_0 44p2/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p3_1 44p2/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p4_0 44p2/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p4_1 44p2/res_sub0_part4_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p5_0 44p2/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p5_1 44p2/res_sub0_part5_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p6_0 44p2/res_sub0_part6_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p6_1 44p2/res_sub0_part6_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p5_1 :_p6_2 - -:_p7_0 44p2/res_sub0_part7_pass0.vqd, 5, nonseq, 0 +- 1875 -:_p7_1 44p2/res_sub0_part7_pass1.vqd, 5, nonseq, 0 +- 625 -:_p7_2 44p2/res_sub0_part7_pass2.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p7_3 44p2/res_sub0_part7_pass3.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p2/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p2/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p2/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 -# reuse p7_2/3 for l1_1/2 diff --git a/Engine/lib/libvorbis/vq/44p3.vqs b/Engine/lib/libvorbis/vq/44p3.vqs deleted file mode 100644 index b1c66a603..000000000 --- a/Engine/lib/libvorbis/vq/44p3.vqs +++ /dev/null @@ -1,52 +0,0 @@ -GO - ->_44p3 noninterleaved -haux 44p3/resaux_0.vqd _44p3_short 0,42,2 8 -haux 44p3/resaux_1.vqd _44p3_long 0,170,2 8 -haux 44p3/resaux_2.vqd _44p3_lfe 0,2,2 2 - -#iter 0 - -# 0 1 1 2 7 17 31 + -# 0 99 99 7 17 31 + - -# 0 1 2 3 4 5 6 7 -# 1 . . . . . -# 2 . . . . . . -# 4 . . . -# 8 . - -:_p1_0 44p3/res_sub0_part1_pass2.vqd, 5, nonseq cull, 0 +- 1 -:_p2_0 44p3/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p3_0 44p3/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p3_1 44p3/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p4_0 44p3/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p4_1 44p3/res_sub0_part4_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p5_0 44p3/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p5_1 44p3/res_sub0_part5_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p6_0 44p3/res_sub0_part6_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p6_1 44p3/res_sub0_part6_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p5_1 :_p6_2 44p3/res_sub0_part6_pass2.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p7_0 44p3/res_sub0_part7_pass0.vqd, 5, nonseq, 0 +- 1875 -:_p7_1 44p3/res_sub0_part7_pass1.vqd, 5, nonseq, 0 +- 625 -:_p7_2 44p3/res_sub0_part7_pass2.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p7_3 44p3/res_sub0_part7_pass3.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p3/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p3/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p3/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 -# reuse p7_2/3 for l1_1/2 diff --git a/Engine/lib/libvorbis/vq/44p4.vqs b/Engine/lib/libvorbis/vq/44p4.vqs deleted file mode 100644 index 4b70436d4..000000000 --- a/Engine/lib/libvorbis/vq/44p4.vqs +++ /dev/null @@ -1,52 +0,0 @@ -GO - ->_44p4 noninterleaved -haux 44p4/resaux_0.vqd _44p4_short 0,42,2 8 -haux 44p4/resaux_1.vqd _44p4_long 0,170,2 8 -haux 44p4/resaux_2.vqd _44p4_lfe 0,2,2 2 - -#iter 0 - -# 0 1 1 2 7 17 31 + -# 0 99 99 7 17 31 + - -# 0 1 2 3 4 5 6 7 -# 1 . . . . . -# 2 . . . . . . -# 4 . . . -# 8 . - -:_p1_0 44p4/res_sub0_part1_pass2.vqd, 5, nonseq cull, 0 +- 1 -:_p2_0 44p4/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p3_0 44p4/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p3_1 44p4/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p4_0 44p4/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p4_1 44p4/res_sub0_part4_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p5_0 44p4/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p5_1 44p4/res_sub0_part5_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p6_0 44p4/res_sub0_part6_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p6_1 44p4/res_sub0_part6_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p5_1 :_p6_2 44p3/res_sub0_part6_pass2.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p7_0 44p4/res_sub0_part7_pass0.vqd, 5, nonseq, 0 +- 1875 -:_p7_1 44p4/res_sub0_part7_pass1.vqd, 5, nonseq, 0 +- 625 -:_p7_2 44p4/res_sub0_part7_pass2.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p7_3 44p4/res_sub0_part7_pass3.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p4/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p4/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p4/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 -# reuse p7_2/3 for l1_1/2 diff --git a/Engine/lib/libvorbis/vq/44p5.vqs b/Engine/lib/libvorbis/vq/44p5.vqs deleted file mode 100644 index 0372321a0..000000000 --- a/Engine/lib/libvorbis/vq/44p5.vqs +++ /dev/null @@ -1,52 +0,0 @@ -GO - ->_44p5 noninterleaved -haux 44p5/resaux_0.vqd _44p5_short 0,42,2 8 -haux 44p5/resaux_1.vqd _44p5_long 0,170,2 8 -haux 44p5/resaux_2.vqd _44p5_lfe 0,2,2 2 - -#iter 0 - -# 0 1 2 4 7 17 31 + -# 1 2 4 7 17 31 + - -# 0 1 2 3 4 5 6 7 -# 1 . . . . . -# 2 . . . . . . -# 4 . . . -# 8 . - -:_p1_0 44p5/res_sub0_part1_pass2.vqd, 5, nonseq cull, 0 +- 1 -:_p2_0 44p5/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p3_0 44p5/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p3_1 44p5/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p4_0 44p5/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p4_1 44p5/res_sub0_part4_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p5_0 44p5/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p5_1 44p5/res_sub0_part5_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p6_0 44p5/res_sub0_part6_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p6_1 44p5/res_sub0_part6_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p5_1 :_p6_2 44p3/res_sub0_part6_pass2.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p7_0 44p5/res_sub0_part7_pass0.vqd, 5, nonseq, 0 +- 1875 -:_p7_1 44p5/res_sub0_part7_pass1.vqd, 5, nonseq, 0 +- 625 -:_p7_2 44p5/res_sub0_part7_pass2.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p7_3 44p5/res_sub0_part7_pass3.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p5/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p5/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p5/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 -# reuse p6_2/3 for l1_2/3 diff --git a/Engine/lib/libvorbis/vq/44p6.vqs b/Engine/lib/libvorbis/vq/44p6.vqs deleted file mode 100644 index 9daad60bb..000000000 --- a/Engine/lib/libvorbis/vq/44p6.vqs +++ /dev/null @@ -1,52 +0,0 @@ -GO - ->_44p6 noninterleaved -haux 44p6/resaux_0.vqd _44p6_short 0,42,2 8 -haux 44p6/resaux_1.vqd _44p6_long 0,170,2 8 -haux 44p6/resaux_2.vqd _44p6_lfe 0,2,2 2 - -#iter 0 - -# 0 1 2 4 7 17 31 + -# 1 2 4 7 17 31 + - -# 0 1 2 3 4 5 6 7 -# 1 . . . . . -# 2 . . . . . . -# 4 . . . -# 8 . - -:_p1_0 44p6/res_sub0_part1_pass2.vqd, 5, nonseq cull, 0 +- 1 -:_p2_0 44p6/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p3_0 44p6/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p3_1 44p6/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p4_0 44p6/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p4_1 44p6/res_sub0_part4_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p5_0 44p6/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p5_1 44p6/res_sub0_part5_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p6_0 44p6/res_sub0_part6_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p6_1 44p6/res_sub0_part6_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p5_1 :_p6_2 44p3/res_sub0_part6_pass2.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p7_0 44p6/res_sub0_part7_pass0.vqd, 5, nonseq, 0 +- 1875 -:_p7_1 44p6/res_sub0_part7_pass1.vqd, 5, nonseq, 0 +- 625 -:_p7_2 44p6/res_sub0_part7_pass2.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p7_3 44p6/res_sub0_part7_pass3.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p6/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p6/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p6/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 -# reuse p6_2/3 for l1_2/3 diff --git a/Engine/lib/libvorbis/vq/44p7.vqs b/Engine/lib/libvorbis/vq/44p7.vqs deleted file mode 100644 index 9ec5d026e..000000000 --- a/Engine/lib/libvorbis/vq/44p7.vqs +++ /dev/null @@ -1,52 +0,0 @@ -GO - ->_44p7 noninterleaved -haux 44p7/resaux_0.vqd _44p7_short 0,42,2 8 -haux 44p7/resaux_1.vqd _44p7_long 0,170,2 8 -haux 44p7/resaux_2.vqd _44p7_lfe 0,2,2 2 - -#iter 0 - -# 0 1 2 4 7 17 31 + -# 1 2 4 7 17 31 + - -# 0 1 2 3 4 5 6 7 -# 1 . . . . . -# 2 . . . . . . -# 4 . . . -# 8 . - -:_p1_0 44p7/res_sub0_part1_pass2.vqd, 5, nonseq cull, 0 +- 1 -:_p2_0 44p7/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p3_0 44p7/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p3_1 44p7/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p4_0 44p7/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p4_1 44p7/res_sub0_part4_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p5_0 44p7/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p5_1 44p7/res_sub0_part5_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p6_0 44p7/res_sub0_part6_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p6_1 44p7/res_sub0_part6_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p5_1 :_p6_2 44p3/res_sub0_part6_pass2.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p7_0 44p7/res_sub0_part7_pass0.vqd, 5, nonseq, 0 +- 1875 -:_p7_1 44p7/res_sub0_part7_pass1.vqd, 5, nonseq, 0 +- 625 -:_p7_2 44p7/res_sub0_part7_pass2.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p7_3 44p7/res_sub0_part7_pass3.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p7/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p7/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p7/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 1350 -# reuse p6_2/3 for l1_2/3 diff --git a/Engine/lib/libvorbis/vq/44p8.vqs b/Engine/lib/libvorbis/vq/44p8.vqs deleted file mode 100644 index a75af84af..000000000 --- a/Engine/lib/libvorbis/vq/44p8.vqs +++ /dev/null @@ -1,52 +0,0 @@ -GO - ->_44p8 noninterleaved -haux 44p8/resaux_0.vqd _44p8_short 0,42,2 8 -haux 44p8/resaux_1.vqd _44p8_long 0,170,2 8 -haux 44p8/resaux_2.vqd _44p8_lfe 0,2,2 2 - -#iter 0 - -# 0 1 2 4 7 17 31 + -# 1 2 4 7 17 31 + - -# 0 1 2 3 4 5 6 7 -# 1 . . . . . -# 2 . . . . . . -# 4 . . . -# 8 . - -:_p1_0 44p8/res_sub0_part1_pass2.vqd, 5, nonseq cull, 0 +- 1 -:_p2_0 44p8/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p3_0 44p8/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p3_1 44p8/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p4_0 44p8/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p4_1 44p8/res_sub0_part4_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p5_0 44p8/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p5_1 44p8/res_sub0_part5_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p6_0 44p8/res_sub0_part6_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p6_1 44p8/res_sub0_part6_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p5_1 :_p6_2 44p3/res_sub0_part6_pass2.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p7_0 44p8/res_sub0_part7_pass0.vqd, 5, nonseq, 0 +- 3125 -:_p7_1 44p8/res_sub0_part7_pass1.vqd, 5, nonseq, 0 +- 625 1250 -:_p7_2 44p8/res_sub0_part7_pass2.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p7_3 44p8/res_sub0_part7_pass3.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p8/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p8/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p8/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 1350 -# reuse p6_2/3 for l1_2/3 diff --git a/Engine/lib/libvorbis/vq/44p9.vqs b/Engine/lib/libvorbis/vq/44p9.vqs deleted file mode 100644 index 4c007800e..000000000 --- a/Engine/lib/libvorbis/vq/44p9.vqs +++ /dev/null @@ -1,52 +0,0 @@ -GO - ->_44p9 noninterleaved -haux 4pp9/resaux_0.vqd _44p9_short 0,42,2 8 -haux 4pp9/resaux_1.vqd _44p9_long 0,170,2 8 -haux 4pp9/resaux_2.vqd _44p9_lfe 0,2,2 2 - -#iter 0 - -# 0 1 2 4 7 17 31 + -# 1 2 4 7 17 31 + - -# 0 1 2 3 4 5 6 7 -# 1 . . . . . -# 2 . . . . . . -# 4 . . . -# 8 . - -:_p1_0 44p9/res_sub0_part1_pass2.vqd, 5, nonseq cull, 0 +- 1 -:_p2_0 44p9/res_sub0_part2_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p3_0 44p9/res_sub0_part3_pass0.vqd, 5, nonseq cull, 0 +- 3 -:_p3_1 44p9/res_sub0_part3_pass1.vqd, 5, nonseq cull, 0 +- 1 - -:_p4_0 44p9/res_sub0_part4_pass0.vqd, 5, nonseq cull, 0 +- 5 -:_p4_1 44p9/res_sub0_part4_pass1.vqd, 5, nonseq cull, 0 +- 1 2 - -:_p5_0 44p9/res_sub0_part5_pass0.vqd, 5, nonseq cull, 0 +- 7 14 -:_p5_1 44p9/res_sub0_part5_pass1.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p6_0 44p9/res_sub0_part6_pass0.vqd, 5, nonseq cull, 0 +- 21 -:_p6_1 44p9/res_sub0_part6_pass1.vqd, 5, nonseq cull, 0 +- 7 -# reuse p5_1 :_p6_2 44p3/res_sub0_part6_pass2.vqd, 1, nonseq cull, 0 +- 1 2 3 - -:_p7_0 44p9/res_sub0_part7_pass0.vqd, 5, nonseq, 0 +- 3125 6250 -:_p7_1 44p9/res_sub0_part7_pass1.vqd, 5, nonseq, 0 +- 625 1250 -:_p7_2 44p9/res_sub0_part7_pass2.vqd, 1, nonseq, 0 +- 25 50 75 100 125 150 175 200 225 250 275 300 -:_p7_3 44p9/res_sub0_part7_pass3.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 - -# 32 + -# 0 0 -# -# 0 1 -# 1 . . -# 2 . . -# 4 . - -:_l0_0 44p9/res_sub1_part0_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_l0_1 44p9/res_sub1_part0_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_l1_0 44p9/res_sub1_part1_pass0.vqd, 2, nonseq, 0 +- 625 1250 -# reuse p6_2/3 for l1_2/3 diff --git a/Engine/lib/libvorbis/vq/44u0.vqs b/Engine/lib/libvorbis/vq/44u0.vqs deleted file mode 100644 index 5bc3f60c8..000000000 --- a/Engine/lib/libvorbis/vq/44u0.vqs +++ /dev/null @@ -1,33 +0,0 @@ -GO - ->_44u0_ noninterleaved -haux 44u0/resaux_0.vqd _44u0__short 0,16,2 8 - ->_44u0_ noninterleaved -haux 44u0/resaux_1.vqd _44u0__long 0,64,2 8 - -#iter 0 - - - -# 0 1 1 2 2 4 32 + -# 25 0 45 0 0 0 0 -# -# 0 1 2 3 4 5 6 7 -# 1 . . -# 2 . . -# 4 . . . . . . - -:_p1_0 44u0/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u0/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 44u0/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44u0/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 44u0/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p6_0 44u0/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44u0/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44u0/res_part7_pass0.vqd, 4, nonseq, 0 +- 169 338 -:_p7_1 44u0/res_part7_pass1.vqd, 2, nonseq, 0 +- 13 26 39 52 65 78 -:_p7_2 44u0/res_part7_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 - diff --git a/Engine/lib/libvorbis/vq/44u1.vqs b/Engine/lib/libvorbis/vq/44u1.vqs deleted file mode 100644 index ed19dc6ce..000000000 --- a/Engine/lib/libvorbis/vq/44u1.vqs +++ /dev/null @@ -1,33 +0,0 @@ -GO - ->_44u1_ noninterleaved -haux 44u1/resaux_0.vqd _44u1__short 0,16,2 8 - ->_44u1_ noninterleaved -haux 44u1/resaux_1.vqd _44u1__long 0,64,2 8 - -#iter 0 - - - -# 0 1 1 2 2 4 32 + -# 25 0 45 0 0 0 0 -# -# 0 1 2 3 4 5 6 7 -# 1 . . -# 2 . . -# 4 . . . . . . - -:_p1_0 44u1/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u1/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 44u1/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44u1/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 44u1/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p6_0 44u1/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44u1/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44u1/res_part7_pass0.vqd, 2, nonseq, 0 +- 169 338 507 -:_p7_1 44u1/res_part7_pass1.vqd, 2, nonseq, 0 +- 13 26 39 52 65 78 -:_p7_2 44u1/res_part7_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 - diff --git a/Engine/lib/libvorbis/vq/44u2.vqs b/Engine/lib/libvorbis/vq/44u2.vqs deleted file mode 100644 index 314461e4a..000000000 --- a/Engine/lib/libvorbis/vq/44u2.vqs +++ /dev/null @@ -1,32 +0,0 @@ -GO - ->_44u2_ noninterleaved -haux 44u2/resaux_0.vqd _44u2__short 0,16,2 8 - ->_44u2_ noninterleaved -haux 44u2/resaux_1.vqd _44u2__long 0,64,2 8 - -#iter 0 - - - -# 0 1 1 2 2 4 32 + -# 25 0 45 0 0 0 0 -# -# 0 1 2 3 4 5 6 7 -# 1 . . -# 2 . . -# 4 . . . . . . - -:_p1_0 44u2/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u2/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 44u2/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44u2/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 44u2/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p6_0 44u2/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44u2/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44u2/res_part7_pass0.vqd, 2, nonseq, 0 +- 169 338 507 676 -:_p7_1 44u2/res_part7_pass1.vqd, 2, nonseq, 0 +- 13 26 39 52 65 78 -:_p7_2 44u2/res_part7_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 diff --git a/Engine/lib/libvorbis/vq/44u3.vqs b/Engine/lib/libvorbis/vq/44u3.vqs deleted file mode 100644 index c882109d4..000000000 --- a/Engine/lib/libvorbis/vq/44u3.vqs +++ /dev/null @@ -1,33 +0,0 @@ - -GO - ->_44u3_ noninterleaved -haux 44u3/resaux_0.vqd _44u3__short 0,16,2 8 - ->_44u3_ noninterleaved -haux 44u3/resaux_1.vqd _44u3__long 0,64,2 8 - -#iter 0 - - - -# 0 1 1 2 2 4 32 + -# 25 0 45 0 0 0 0 -# -# 0 1 2 3 4 5 6 7 -# 1 . . -# 2 . . -# 4 . . . . . . - -:_p1_0 44u3/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u3/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 44u3/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44u3/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 44u3/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p6_0 44u3/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44u3/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44u3/res_part7_pass0.vqd, 2, nonseq, 0 +- 255 510 765 1020 -:_p7_1 44u3/res_part7_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 119 -:_p7_2 44u3/res_part7_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 diff --git a/Engine/lib/libvorbis/vq/44u4.vqs b/Engine/lib/libvorbis/vq/44u4.vqs deleted file mode 100644 index cb4d9baea..000000000 --- a/Engine/lib/libvorbis/vq/44u4.vqs +++ /dev/null @@ -1,33 +0,0 @@ - -GO - ->_44u4_ noninterleaved -haux 44u4/resaux_0.vqd _44u4__short 0,16,2 8 - ->_44u4_ noninterleaved -haux 44u4/resaux_1.vqd _44u4__long 0,64,2 8 - -#iter 0 - - - -# 0 1 1 2 2 4 32 + -# 25 0 45 0 0 0 0 -# -# 0 1 2 3 4 5 6 7 -# 1 . . -# 2 . . -# 4 . . . . . . - -:_p1_0 44u4/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u4/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 44u4/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44u4/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 44u4/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p6_0 44u4/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44u4/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44u4/res_part7_pass0.vqd, 2, nonseq, 0 +- 255 510 765 1020 1275 1530 -:_p7_1 44u4/res_part7_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 119 -:_p7_2 44u4/res_part7_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 diff --git a/Engine/lib/libvorbis/vq/44u5.vqs b/Engine/lib/libvorbis/vq/44u5.vqs deleted file mode 100644 index a3c175d94..000000000 --- a/Engine/lib/libvorbis/vq/44u5.vqs +++ /dev/null @@ -1,35 +0,0 @@ - -GO - ->_44u5_ noninterleaved -haux 44u5/resaux_0.vqd _44u5__short 0,16,2 10 - ->_44u5_ noninterleaved -haux 44u5/resaux_1.vqd _44u5__long 0,64,2 10 - -#iter 0 - -# 0 1 1 2 2 4 4 16 60 + -# 30 0 50 0 80 0 0 0 -# -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . -# 2 . . . -# 4 . . . . . . . - -:_p1_0 44u5/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u5/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 44u5/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44u5/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 44u5/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 44u5/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p7_0 44u5/res_part7_pass0.vqd, 4, nonseq, 0 +- 11 -:_p7_1 44u5/res_part7_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p8_0 44u5/res_part8_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 -:_p8_1 44u5/res_part8_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p9_0 44u5/res_part9_pass0.vqd, 2, nonseq, 0 +- 255 510 765 1020 1275 1530 -:_p9_1 44u5/res_part9_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 119 -:_p9_2 44u5/res_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 diff --git a/Engine/lib/libvorbis/vq/44u6.vqs b/Engine/lib/libvorbis/vq/44u6.vqs deleted file mode 100644 index ca8b7b124..000000000 --- a/Engine/lib/libvorbis/vq/44u6.vqs +++ /dev/null @@ -1,35 +0,0 @@ - -GO - ->_44u6_ noninterleaved -haux 44u6/resaux_0.vqd _44u6__short 0,16,2 10 - ->_44u6_ noninterleaved -haux 44u6/resaux_1.vqd _44u6__long 0,64,2 10 - -#iter 0 - -# 0 1 1 2 2 4 4 16 60 + -# 30 0 50 0 80 0 0 0 -# -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . -# 2 . . . -# 4 . . . . . . . - -:_p1_0 44u6/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u6/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 44u6/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44u6/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 44u6/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 44u6/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p7_0 44u6/res_part7_pass0.vqd, 4, nonseq, 0 +- 11 -:_p7_1 44u6/res_part7_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p8_0 44u6/res_part8_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 -:_p8_1 44u6/res_part8_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p9_0 44u6/res_part9_pass0.vqd, 2, nonseq, 0 +- 255 510 765 1020 1275 1530 1785 -:_p9_1 44u6/res_part9_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 119 -:_p9_2 44u6/res_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 diff --git a/Engine/lib/libvorbis/vq/44u7.vqs b/Engine/lib/libvorbis/vq/44u7.vqs deleted file mode 100644 index 2efe5aa90..000000000 --- a/Engine/lib/libvorbis/vq/44u7.vqs +++ /dev/null @@ -1,34 +0,0 @@ -GO - ->_44u7_ noninterleaved -haux 44u7/resaux_0.vqd _44u7__short 0,16,2 10 - ->_44u7_ noninterleaved -haux 44u7/resaux_1.vqd _44u7__long 0,64,2 10 - -#iter 0 - -# 0 1 1 2 2 4 4 16 60 + -# 30 0 50 0 80 0 0 0 -# -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . -# 2 . . . -# 4 . . . . . . . - -:_p1_0 44u7/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u7/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 44u7/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 44u7/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 44u7/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 44u7/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p7_0 44u7/res_part7_pass0.vqd, 4, nonseq, 0 +- 11 -:_p7_1 44u7/res_part7_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p8_0 44u7/res_part8_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 -:_p8_1 44u7/res_part8_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p9_0 44u7/res_part9_pass0.vqd, 2, nonseq, 0 +- 637 1274 1911 2548 3185 -:_p9_1 44u7/res_part9_pass1.vqd, 2, nonseq, 0 +- 49 98 147 196 245 294 -:_p9_2 44u7/res_part9_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 diff --git a/Engine/lib/libvorbis/vq/44u8.vqs b/Engine/lib/libvorbis/vq/44u8.vqs deleted file mode 100644 index ecedb09a8..000000000 --- a/Engine/lib/libvorbis/vq/44u8.vqs +++ /dev/null @@ -1,35 +0,0 @@ -GO - ->_44u8s noninterleaved -haux 44u8/resaux_0.vqd _44u8__short 0,16,2 10 - ->_44u8 noninterleaved -haux 44u8/resaux_1.vqd _44u8__long 0,64,2 10 - - -# 0 1 2 4 8 16 32 71 157 + -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . . . -# 2 . . . . . -# 4 . . . . . - -:_p1_0 44u8/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u8/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44u8/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44u8/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p5_0 44u8/res_part5_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p5_1 44u8/res_part5_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p6_0 44u8/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44u8/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44u8/res_part7_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 66 -:_p7_1 44u8/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44u8/res_part8_pass0.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p8_1 44u8/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 9 10 - -:_p9_0 44u8/res_part9_pass0.vqd, 2, nonseq, 0 +- 931 1862 2793 3724 -:_p9_1 44u8/res_part9_pass1.vqd, 2, nonseq, 0 +- 49 98 147 196 245 294 343 392 441 -:_p9_2 44u8/res_part9_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 diff --git a/Engine/lib/libvorbis/vq/44u9.vqs b/Engine/lib/libvorbis/vq/44u9.vqs deleted file mode 100644 index 42a3877bf..000000000 --- a/Engine/lib/libvorbis/vq/44u9.vqs +++ /dev/null @@ -1,36 +0,0 @@ - -GO - ->_44u9s noninterleaved -haux 44u9/resaux_0.vqd _44u9__short 0,16,2 10 - ->_44u9 noninterleaved -haux 44u9/resaux_1.vqd _44u9__long 0,64,2 10 - - -# 0 1 2 4 8 16 32 71 157 + -# 0 1 2 3 4 5 6 7 8 9 -# 1 . . . . . -# 2 . . . . . -# 4 . . . . . - -:_p1_0 44u9/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 44u9/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 44u9/res_part3_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p4_0 44u9/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - -:_p5_0 44u9/res_part5_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p5_1 44u9/res_part5_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p6_0 44u9/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 44u9/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 44u9/res_part7_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 66 -:_p7_1 44u9/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 44u9/res_part8_pass0.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p8_1 44u9/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 9 10 - -:_p9_0 44u9/res_part9_pass0.vqd, 2, nonseq, 0 +- 931 1862 2793 3724 4655 5586 6517 -:_p9_1 44u9/res_part9_pass1.vqd, 2, nonseq, 0 +- 49 98 147 196 245 294 343 392 441 -:_p9_2 44u9/res_part9_pass2.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 diff --git a/Engine/lib/libvorbis/vq/8.vqs b/Engine/lib/libvorbis/vq/8.vqs deleted file mode 100644 index 517a589e4..000000000 --- a/Engine/lib/libvorbis/vq/8.vqs +++ /dev/null @@ -1,43 +0,0 @@ -GO - ->_8c0_s noninterleaved -haux 8c0_s/resaux_0.vqd _8c0_s_single 0,64,2 10 - -:_p1_0 8c0_s/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 8c0_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 8c0_s/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 8c0_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 8c0_s/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 8c0_s/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p7_0 8c0_s/res_part7_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p7_1 8c0_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 8c0_s/res_part8_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p8_1 8c0_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p9_0 8c0_s/res_part9_pass0.vqd, 4, nonseq, 0 +- 315 -:_p9_1 8c0_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p9_2 8c0_s/res_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 - ->_8c1_s noninterleaved -haux 8c1_s/resaux_0.vqd _8c1_s_single 0,64,2 10 - -:_p1_0 8c1_s/res_part1_pass2.vqd, 8, nonseq cull, 0 +- 1 -:_p2_0 8c1_s/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p3_0 8c1_s/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 8c1_s/res_part4_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p5_0 8c1_s/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 8c1_s/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 6 7 8 - - -:_p7_0 8c1_s/res_part7_pass0.vqd, 4, nonseq cull, 0 +- 11 -:_p7_1 8c1_s/res_part7_pass1.vqd, 2, nonseq cull, 0 +- 1 2 3 4 5 - -:_p8_0 8c1_s/res_part8_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p8_1 8c1_s/res_part8_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p9_0 8c1_s/res_part9_pass0.vqd, 2, nonseq, 0 +- 315 630 945 1260 1575 1890 -:_p9_1 8c1_s/res_part9_pass1.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p9_2 8c1_s/res_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 diff --git a/Engine/lib/libvorbis/vq/8u.vqs b/Engine/lib/libvorbis/vq/8u.vqs deleted file mode 100644 index 0ed0ec8b8..000000000 --- a/Engine/lib/libvorbis/vq/8u.vqs +++ /dev/null @@ -1,41 +0,0 @@ - -GO - ->_8u0_ noninterleaved -haux 8u0/resaux_0.vqd _8u0__single 0,64,2 8 - - -:_p1_0 8u0/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 8u0/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 8u0/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 8u0/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 8u0/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p6_0 8u0/res_part6_pass0.vqd, 2, nonseq cull, 0 +- 5 10 15 20 25 30 -:_p6_1 8u0/res_part6_pass1.vqd, 2, nonseq cull, 0 +- 1 2 - -:_p7_0 8u0/res_part7_pass0.vqd, 4, nonseq, 0 +- 315 -:_p7_1 8u0/res_part7_pass1.vqd, 2, nonseq, 0 +- 21 42 63 84 105 126 147 -:_p7_2 8u0/res_part7_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 - - ->_8u1_ noninterleaved -haux 8u1/resaux_0.vqd _8u1__single 0,64,2 10 - -:_p1_0 8u1/res_part1_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p2_0 8u1/res_part2_pass2.vqd, 4, nonseq cull, 0 +- 1 -:_p3_0 8u1/res_part3_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p4_0 8u1/res_part4_pass2.vqd, 4, nonseq cull, 0 +- 1 2 -:_p5_0 8u1/res_part5_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 -:_p6_0 8u1/res_part6_pass2.vqd, 2, nonseq cull, 0 +- 1 2 3 4 - -:_p7_0 8u1/res_part7_pass0.vqd, 4, nonseq, 0 +- 11 -:_p7_1 8u1/res_part7_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p8_0 8u1/res_part8_pass0.vqd, 2, nonseq, 0 +- 11 22 33 44 55 -:_p8_1 8u1/res_part8_pass1.vqd, 2, nonseq, 0 +- 1 2 3 4 5 - -:_p9_0 8u1/res_part9_pass0.vqd, 2, nonseq, 0 +- 255 510 765 1020 1275 1530 1785 -:_p9_1 8u1/res_part9_pass1.vqd, 2, nonseq, 0 +- 17 34 51 68 85 102 119 -:_p9_2 8u1/res_part9_pass2.vqd, 2, nonseq, 0 +- 1 2 3 4 5 6 7 8 - diff --git a/Engine/lib/libvorbis/vq/Makefile.am b/Engine/lib/libvorbis/vq/Makefile.am deleted file mode 100644 index e9c272e0c..000000000 --- a/Engine/lib/libvorbis/vq/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -## Process this file with automake to produce Makefile.in - -EXTRA_PROGRAMS = latticebuild latticetune huffbuild distribution -CLEANFILES = $(EXTRA_PROGRAMS) - -AM_CPPFLAGS = -I../lib -I$(top_srcdir)/include @OGG_CFLAGS@ -AM_LDFLAGS = -static -LDADD = ../lib/libvorbis.la - -latticebuild_SOURCES = latticebuild.c vqgen.c bookutil.c\ - vqgen.h bookutil.h localcodebook.h -latticetune_SOURCES = latticetune.c vqgen.c bookutil.c\ - vqgen.h bookutil.h localcodebook.h -huffbuild_SOURCES = huffbuild.c vqgen.c bookutil.c\ - vqgen.h bookutil.h localcodebook.h -distribution_SOURCES = distribution.c bookutil.c\ - bookutil.h localcodebook.h - -vqs_files = 16.vqs 16u.vqs 44c-1.vqs 44c0.vqs 44c1.vqs 44c2.vqs \ - 44c3.vqs 44c4.vqs 44c5.vqs 44c6.vqs 44c7.vqs 44c8.vqs 44c9.vqs \ - 44u0.vqs 44u1.vqs 44u2.vqs 44u3.vqs 44u4.vqs 44u5.vqs 44u6.vqs \ - 44u7.vqs 44u8.vqs 44u9.vqs 8.vqs 8u.vqs floor_11.vqs floor_22.vqs \ - floor_44.vqs 44p-1.vqs 44p0.vqs 44p1.vqs 44p2.vqs 44p3.vqs 44p4.vqs \ - 44p5.vqs 44p6.vqs 44p7.vqs 44p8.vqs 44p9.vqs - -EXTRA_DIST = $(vqs_files) make_floor_books.pl make_residue_books.pl \ - metrics.c - -debugvq: - $(MAKE) vq CFLAGS="@DEBUG@" - -profilevq: - $(MAKE) vq CFLAGS="@PROFILE@" - -vq: - $(MAKE) $(EXTRA_PROGRAMS) diff --git a/Engine/lib/libvorbis/vq/bookutil.c b/Engine/lib/libvorbis/vq/bookutil.c deleted file mode 100644 index c8b894e17..000000000 --- a/Engine/lib/libvorbis/vq/bookutil.c +++ /dev/null @@ -1,476 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2014 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: utility functions for loading .vqh and .vqd files - - ********************************************************************/ - -#include -#include -#include -#include -#include -#include "bookutil.h" - -int _best(codebook *book, float *a, int step){ - - int dim=book->dim; - int i,j,o; - int minval=book->minval; - int del=book->delta; - int qv=book->quantvals; - int ze=(qv>>1); - int index=0; - /* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */ - - if(del!=1){ - for(i=0,o=step*(dim-1);i>1))/del; - int m = (v=qv?qv-1:m)); - } - }else{ - for(i=0,o=step*(dim-1);i=qv?qv-1:m)); - } - } - - if(book->c->lengthlist[index]<=0){ - const static_codebook *c=book->c; - int best=-1; - /* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */ - int e[8]={0,0,0,0,0,0,0,0}; - int maxval = book->minval + book->delta*(book->quantvals-1); - for(i=0;ientries;i++){ - if(c->lengthlist[i]>0){ - float this=0; - for(j=0;j=maxval) - e[j++]=0; - if(e[j]>=0) - e[j]+=book->delta; - e[j]= -e[j]; - } - } - - return index; -} - -/* A few little utils for reading files */ -/* read a line. Use global, persistent buffering */ -static char *linebuffer=NULL; -static int lbufsize=0; -char *get_line(FILE *in){ - long sofar=0; - if(feof(in))return NULL; - - while(1){ - int gotline=0; - - while(!gotline){ - if(sofar+1>=lbufsize){ - if(!lbufsize){ - lbufsize=1024; - linebuffer=_ogg_malloc(lbufsize); - }else{ - lbufsize*=2; - linebuffer=_ogg_realloc(linebuffer,lbufsize); - } - } - { - long c=fgetc(in); - switch(c){ - case EOF: - if(sofar==0)return(NULL); - /* fallthrough correct */ - case '\n': - linebuffer[sofar]='\0'; - gotline=1; - break; - default: - linebuffer[sofar++]=c; - linebuffer[sofar]='\0'; - break; - } - } - } - - if(linebuffer[0]=='#'){ - sofar=0; - }else{ - return(linebuffer); - } - } -} - -/* read the next numerical value from the given file */ -static char *value_line_buff=NULL; - -int get_line_value(FILE *in,float *value){ - char *next; - - if(!value_line_buff)return(-1); - - *value=strtod(value_line_buff, &next); - if(next==value_line_buff){ - value_line_buff=NULL; - return(-1); - }else{ - value_line_buff=next; - while(*value_line_buff>44)value_line_buff++; - if(*value_line_buff==44)value_line_buff++; - return(0); - } -} - -int get_next_value(FILE *in,float *value){ - while(1){ - if(get_line_value(in,value)){ - value_line_buff=get_line(in); - if(!value_line_buff)return(-1); - }else{ - return(0); - } - } -} - -int get_next_ivalue(FILE *in,long *ivalue){ - float value; - int ret=get_next_value(in,&value); - *ivalue=value; - return(ret); -} - -static float sequence_base=0.f; -static int v_sofar=0; -void reset_next_value(void){ - value_line_buff=NULL; - sequence_base=0.f; - v_sofar=0; -} - -char *setup_line(FILE *in){ - reset_next_value(); - value_line_buff=get_line(in); - return(value_line_buff); -} - - -int get_vector(codebook *b,FILE *in,int start, int n,float *a){ - int i; - const static_codebook *c=b->c; - - while(1){ - - if(v_sofar==n || get_line_value(in,a)){ - reset_next_value(); - if(get_next_value(in,a)) - break; - for(i=0;idim;i++) - if(get_line_value(in,a+i)) - break; - - if(i==c->dim){ - float temp=a[c->dim-1]; - for(i=0;idim;i++)a[i]-=sequence_base; - if(c->q_sequencep)sequence_base=temp; - v_sofar++; - return(0); - } - sequence_base=0.f; - } - - return(-1); -} - -/* read lines fromt he beginning until we find one containing the - specified string */ -char *find_seek_to(FILE *in,char *s){ - rewind(in); - while(1){ - char *line=get_line(in); - if(line){ - if(strstr(line,s)) - return(line); - }else - return(NULL); - } -} - - -/* this reads the format as written by vqbuild/latticebuild; innocent - (legal) tweaking of the file that would not affect its valid - header-ness will break this routine */ - -codebook *codebook_load(char *filename){ - codebook *b=_ogg_calloc(1,sizeof(codebook)); - static_codebook *c=(static_codebook *)(b->c=_ogg_calloc(1,sizeof(static_codebook))); - int quant_to_read=0; - FILE *in=fopen(filename,"r"); - char *line; - long i; - - if(in==NULL){ - fprintf(stderr,"Couldn't open codebook %s\n",filename); - exit(1); - } - - /* find the codebook struct */ - find_seek_to(in,"static const static_codebook "); - - /* get the major important values */ - line=get_line(in); - if(sscanf(line,"%ld, %ld,", - &(c->dim),&(c->entries))!=2){ - fprintf(stderr,"1: syntax in %s in line:\t %s",filename,line); - exit(1); - } - line=get_line(in); - line=get_line(in); - if(sscanf(line,"%d, %ld, %ld, %d, %d,", - &(c->maptype),&(c->q_min),&(c->q_delta),&(c->q_quant), - &(c->q_sequencep))!=5){ - fprintf(stderr,"1: syntax in %s in line:\t %s",filename,line); - exit(1); - } - - switch(c->maptype){ - case 0: - quant_to_read=0; - break; - case 1: - quant_to_read=_book_maptype1_quantvals(c); - break; - case 2: - quant_to_read=c->entries*c->dim; - break; - } - - /* load the quantized entries */ - find_seek_to(in,"static const long _vq_quantlist_"); - reset_next_value(); - c->quantlist=_ogg_malloc(sizeof(long)*quant_to_read); - for(i=0;iquantlist+i)){ - fprintf(stderr,"out of data while reading codebook %s\n",filename); - exit(1); - } - - /* load the lengthlist */ - find_seek_to(in,"_lengthlist"); - reset_next_value(); - c->lengthlist=_ogg_malloc(sizeof(long)*c->entries); - for(i=0;ientries;i++) - if(get_next_ivalue(in,c->lengthlist+i)){ - fprintf(stderr,"out of data while reading codebook %s\n",filename); - exit(1); - } - - /* got it all */ - fclose(in); - - vorbis_book_init_encode(b,c); - b->valuelist=_book_unquantize(c,c->entries,NULL); - - return(b); -} - -void spinnit(char *s,int n){ - static int p=0; - static long lasttime=0; - long test; - struct timeval thistime; - - gettimeofday(&thistime,NULL); - test=thistime.tv_sec*10+thistime.tv_usec/100000; - if(lasttime!=test){ - lasttime=test; - - fprintf(stderr,"%s%d ",s,n); - - p++;if(p>3)p=0; - switch(p){ - case 0: - fprintf(stderr,"| \r"); - break; - case 1: - fprintf(stderr,"/ \r"); - break; - case 2: - fprintf(stderr,"- \r"); - break; - case 3: - fprintf(stderr,"\\ \r"); - break; - } - fflush(stderr); - } -} - -void build_tree_from_lengths(int vals, long *hist, long *lengths){ - int i,j; - long *membership=_ogg_malloc(vals*sizeof(long)); - long *histsave=alloca(vals*sizeof(long)); - memcpy(histsave,hist,vals*sizeof(long)); - - for(i=0;i1;i--){ - int first=-1,second=-1; - long least=-1; - - spinnit("building... ",i); - - /* find the two nodes to join */ - for(j=0;j0) - newhist[upper++]=hist[i]; - - if(upper != vals){ - fprintf(stderr,"\rEliminating %d unused entries; %d entries remain\n", - vals-upper,upper); - } - - build_tree_from_lengths(upper,newhist,lengthlist); - - upper=0; - for(i=0;i0) - lengths[i]=lengthlist[upper++]; - else - lengths[i]=0; - - free(lengthlist); -} - -void write_codebook(FILE *out,char *name,const static_codebook *c){ - int i,j,k; - - /* save the book in C header form */ - - /* first, the static vectors, then the book structure to tie it together. */ - /* quantlist */ - if(c->quantlist){ - long vals=(c->maptype==1?_book_maptype1_quantvals(c):c->entries*c->dim); - fprintf(out,"static const long _vq_quantlist_%s[] = {\n",name); - for(j=0;jquantlist[j]); - } - fprintf(out,"};\n\n"); - } - - /* lengthlist */ - fprintf(out,"static const char _vq_lengthlist_%s[] = {\n",name); - for(j=0;jentries;){ - fprintf(out,"\t"); - for(k=0;k<16 && jentries;k++,j++) - fprintf(out,"%2ld,",c->lengthlist[j]); - fprintf(out,"\n"); - } - fprintf(out,"};\n\n"); - - /* tie it all together */ - - fprintf(out,"static const static_codebook %s = {\n",name); - - fprintf(out,"\t%ld, %ld,\n",c->dim,c->entries); - fprintf(out,"\t(char *)_vq_lengthlist_%s,\n",name); - fprintf(out,"\t%d, %ld, %ld, %d, %d,\n", - c->maptype,c->q_min,c->q_delta,c->q_quant,c->q_sequencep); - if(c->quantlist) - fprintf(out,"\t(long *)_vq_quantlist_%s,\n",name); - else - fprintf(out,"\tNULL,\n"); - - fprintf(out,"\t0\n};\n\n"); -} diff --git a/Engine/lib/libvorbis/vq/bookutil.h b/Engine/lib/libvorbis/vq/bookutil.h deleted file mode 100644 index d8fbcbe52..000000000 --- a/Engine/lib/libvorbis/vq/bookutil.h +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: utility functions for loading .vqh and .vqd files - - ********************************************************************/ - -#ifndef _V_BOOKUTIL_H_ -#define _V_BOOKUTIL_H_ - -#include -#include - -#include "localcodebook.h" - -extern char *get_line(FILE *in); -extern char *setup_line(FILE *in); -extern int get_line_value(FILE *in,float *value); -extern int get_next_value(FILE *in,float *value); -extern int get_next_ivalue(FILE *in,long *ivalue); -extern void reset_next_value(void); -extern int get_vector(codebook *b,FILE *in,int start,int num,float *a); -extern char *find_seek_to(FILE *in,char *s); - -extern codebook *codebook_load(char *filename); -extern void write_codebook(FILE *out,char *name,const static_codebook *c); - -extern void spinnit(char *s,int n); -extern void build_tree_from_lengths(int vals, long *hist, long *lengths); -extern void build_tree_from_lengths0(int vals, long *hist, long *lengths); - -#endif - diff --git a/Engine/lib/libvorbis/vq/distribution.c b/Engine/lib/libvorbis/vq/distribution.c deleted file mode 100644 index 7c0c095a6..000000000 --- a/Engine/lib/libvorbis/vq/distribution.c +++ /dev/null @@ -1,247 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: utility for finding the distribution in a data set - - ********************************************************************/ - -#include -#include -#include -#include -#include -#include "bookutil.h" - -/* command line: - distribution file.vqd -*/ - -int ascend(const void *a,const void *b){ - return(**((long **)a)-**((long **)b)); -} - -int main(int argc,char *argv[]){ - FILE *in; - long lines=0; - float min; - float max; - long bins=-1; - int flag=0; - long *countarray; - long total=0; - char *line; - - if(argv[1]==NULL){ - fprintf(stderr,"Usage: distribution {data.vqd [bins]| book.vqh} \n\n"); - exit(1); - } - if(argv[2]!=NULL) - bins=atoi(argv[2])-1; - - in=fopen(argv[1],"r"); - if(!in){ - fprintf(stderr,"Could not open input file %s\n",argv[1]); - exit(1); - } - - if(strrchr(argv[1],'.') && strcmp(strrchr(argv[1],'.'),".vqh")==0){ - /* load/decode a book */ - - codebook *b=codebook_load(argv[1]); - static_codebook *c=(static_codebook *)(b->c); - float delta; - int i; - fclose(in); - - switch(c->maptype){ - case 0: - printf("entropy codebook only; no mappings\n"); - exit(0); - break; - case 1: - bins=_book_maptype1_quantvals(c); - break; - case 2: - bins=c->entries*c->dim; - break; - } - - max=min=_float32_unpack(c->q_min); - delta=_float32_unpack(c->q_delta); - - for(i=0;iquantlist[i]*delta+min; - if(val>max)max=val; - } - - printf("Minimum scalar value: %f\n",min); - printf("Maximum scalar value: %f\n",max); - - switch(c->maptype){ - case 1: - { - /* lattice codebook. dump it. */ - int j,k; - long maxcount=0; - long **sort=calloc(bins,sizeof(long *)); - long base=c->lengthlist[0]; - countarray=calloc(bins,sizeof(long)); - - for(i=0;iquantlist+i; - qsort(sort,bins,sizeof(long *),ascend); - - for(i=0;ientries;i++) - if(c->lengthlist[i]>base)base=c->lengthlist[i]; - - /* dump a full, correlated count */ - for(j=0;jentries;j++){ - if(c->lengthlist[j]){ - int indexdiv=1; - printf("%4d: ",j); - for(k=0;kdim;k++){ - int index= (j/indexdiv)%bins; - printf("%+3.1f,", c->quantlist[index]*_float32_unpack(c->q_delta)+ - _float32_unpack(c->q_min)); - indexdiv*=bins; - } - printf("\t|"); - for(k=0;klengthlist[j];k++)printf("*"); - printf("\n"); - } - } - - /* do a rough count */ - for(j=0;jentries;j++){ - int indexdiv=1; - for(k=0;kdim;k++){ - if(c->lengthlist[j]){ - int index= (j/indexdiv)%bins; - countarray[index]+=(1<<(base-c->lengthlist[j])); - indexdiv*=bins; - } - } - } - - /* dump the count */ - - { - long maxcount=0,i,j; - for(i=0;imaxcount)maxcount=countarray[i]; - - for(i=0;iquantlist; - int stars=rint(50./maxcount*countarray[ptr]); - printf("%+08f (%8ld) |",c->quantlist[ptr]*delta+min,countarray[ptr]); - for(j=0;jmax)max=code; - } - - line=setup_line(in); - } - - if(bins<1){ - if((int)(max-min)==min-max){ - bins=max-min; - }else{ - bins=25; - } - } - - printf("\r \r"); - printf("Minimum scalar value: %f\n",min); - printf("Maximum scalar value: %f\n",max); - - if(argv[2]){ - - printf("\n counting hits into %ld bins...\n",bins+1); - countarray=calloc(bins+1,sizeof(long)); - - rewind(in); - line=setup_line(in); - while(line){ - float code; - lines--; - if(!(lines&0xff))spinnit("counting distribution. lines so far...",lines); - - while(line && sscanf(line,"%f",&code)==1){ - line=strchr(line,','); - if(line)line++; - - code-=min; - code/=(max-min); - code*=bins; - countarray[(int)rint(code)]++; - total++; - } - - line=setup_line(in); - } - - /* make a pretty graph */ - { - long maxcount=0,i,j; - for(i=0;imaxcount)maxcount=countarray[i]; - - printf("\r \r"); - printf("Total scalars: %ld\n",total); - for(i=0;ifloor_11 -=8-11c0_s 8-11c1_s - -build line_256x4_class0 0-256 -build line_256x4_0sub0 0-4 -build line_256x4_0sub1 4-10 -build line_256x4_0sub2 10-25 -build line_256x4_0sub3 25-64 - diff --git a/Engine/lib/libvorbis/vq/floor_22.vqs b/Engine/lib/libvorbis/vq/floor_22.vqs deleted file mode 100644 index b80328e9a..000000000 --- a/Engine/lib/libvorbis/vq/floor_22.vqs +++ /dev/null @@ -1,27 +0,0 @@ -GO ->floor_22 -=22c0_s 22c1_s 22c2_s - -build line_256x7_class0 0-64 -build line_256x7_class1 0-256 -build line_256x7_0sub1 1-9 -build line_256x7_0sub2 9-25 -build line_256x7_0sub3 25-64 -build line_256x7_1sub1 1-9 -build line_256x7_1sub2 9-25 -build line_256x7_1sub3 25-64 - -build line_512x17_class1 0-8 -build line_512x17_class2 0-64 -build line_512x17_class3 0-64 -build line_512x17_0sub0 0-128 -build line_512x17_1sub0 0-32 -build line_512x17_1sub1 32-128 -build line_512x17_2sub1 1-18 -build line_512x17_2sub2 18-50 -build line_512x17_2sub3 50-128 -build line_512x17_3sub1 1-18 -build line_512x17_3sub2 18-50 -build line_512x17_3sub3 50-128 - - diff --git a/Engine/lib/libvorbis/vq/floor_44.vqs b/Engine/lib/libvorbis/vq/floor_44.vqs deleted file mode 100644 index dd213f7b1..000000000 --- a/Engine/lib/libvorbis/vq/floor_44.vqs +++ /dev/null @@ -1,83 +0,0 @@ -GO ->floor_44 -=44c-1_s 44c0_s 44c1_s 44c2_s 44c3_s 44c4_s 44c5_s 44c6_s 44c7_s 44c8_s 44c9_s - -build line_128x4_class0 0-256 -build line_128x4_0sub0 0-4 -build line_128x4_0sub1 4-10 -build line_128x4_0sub2 10-25 -build line_128x4_0sub3 25-64 - -build line_256x4_class0 0-256 -build line_256x4_0sub0 0-4 -build line_256x4_0sub1 4-10 -build line_256x4_0sub2 10-25 -build line_256x4_0sub3 25-64 - -build line_128x7_class0 0-64 -build line_128x7_class1 0-256 -build line_128x7_0sub1 1-9 -build line_128x7_0sub2 9-25 -build line_128x7_0sub3 25-64 -build line_128x7_1sub1 1-9 -build line_128x7_1sub2 9-25 -build line_128x7_1sub3 25-64 - -build line_128x11_class1 0-8 -build line_128x11_class2 0-64 -build line_128x11_class3 0-64 -build line_128x11_0sub0 0-128 -build line_128x11_1sub0 0-32 -build line_128x11_1sub1 32-128 -build line_128x11_2sub1 1-18 -build line_128x11_2sub2 18-50 -build line_128x11_2sub3 50-128 -build line_128x11_3sub1 1-18 -build line_128x11_3sub2 18-50 -build line_128x11_3sub3 50-128 - -build line_128x17_class1 0-8 -build line_128x17_class2 0-64 -build line_128x17_class3 0-64 -build line_128x17_0sub0 0-128 -build line_128x17_1sub0 0-32 -build line_128x17_1sub1 32-128 -build line_128x17_2sub1 1-18 -build line_128x17_2sub2 18-50 -build line_128x17_2sub3 50-128 -build line_128x17_3sub1 1-18 -build line_128x17_3sub2 18-50 -build line_128x17_3sub3 50-128 - -build line_1024x27_class1 0-16 -build line_1024x27_class2 0-8 -build line_1024x27_class3 0-256 -build line_1024x27_class4 0-64 -build line_1024x27_0sub0 0-128 -build line_1024x27_1sub0 0-32 -build line_1024x27_1sub1 32-128 -build line_1024x27_2sub0 0-32 -build line_1024x27_2sub1 32-128 -build line_1024x27_3sub1 1-18 -build line_1024x27_3sub2 18-50 -build line_1024x27_3sub3 50-128 -build line_1024x27_4sub1 1-18 -build line_1024x27_4sub2 18-50 -build line_1024x27_4sub3 50-128 - -build line_2048x27_class1 0-16 -build line_2048x27_class2 0-8 -build line_2048x27_class3 0-256 -build line_2048x27_class4 0-64 -build line_2048x27_0sub0 0-128 -build line_2048x27_1sub0 0-32 -build line_2048x27_1sub1 32-128 -build line_2048x27_2sub0 0-32 -build line_2048x27_2sub1 32-128 -build line_2048x27_3sub1 1-18 -build line_2048x27_3sub2 18-50 -build line_2048x27_3sub3 50-128 -build line_2048x27_4sub1 1-18 -build line_2048x27_4sub2 18-50 -build line_2048x27_4sub3 50-128 - diff --git a/Engine/lib/libvorbis/vq/huffbuild.c b/Engine/lib/libvorbis/vq/huffbuild.c deleted file mode 100644 index ba00a2e8f..000000000 --- a/Engine/lib/libvorbis/vq/huffbuild.c +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2014 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: hufftree builder - - ********************************************************************/ - -#include -#include -#include -#include -#include "bookutil.h" - -static int nsofar=0; -static int getval(FILE *in,int begin,int n,int group,int max){ - float v; - int i; - long val=0; - - if(nsofar>=n || get_line_value(in,&v)){ - reset_next_value(); - nsofar=0; - if(get_next_value(in,&v)) - return(-1); - for(i=1;i<=begin;i++) - get_line_value(in,&v); - } - - val=(int)v; - nsofar++; - - for(i=1;i=n || get_line_value(in,&v)) - return(getval(in,begin,n,group,max)); - else - val = val*max+(int)v; - return(val); -} - -static void usage(){ - fprintf(stderr, - "usage:\n" - "huffbuild .vqd | [noguard]\n" - " where begin,n,group is first scalar, \n" - " number of scalars of each in line,\n" - " number of scalars in a group\n" - "eg: huffbuild reslongaux.vqd 0,1024,4\n" - "produces reslongaux.vqh\n\n"); - exit(1); -} - -int main(int argc, char *argv[]){ - char *base; - char *infile; - int i,j,k,begin,n,subn,guard=1; - FILE *file; - int maxval=0; - int loval=0; - - if(argc<3)usage(); - if(argc==4)guard=0; - - infile=strdup(argv[1]); - base=strdup(infile); - if(strrchr(base,'.')) - strrchr(base,'.')[0]='\0'; - - { - char *pos=strchr(argv[2],','); - char *dpos=strchr(argv[2],'-'); - if(dpos){ - loval=atoi(argv[2]); - maxval=atoi(dpos+1); - subn=1; - begin=0; - }else{ - begin=atoi(argv[2]); - if(!pos) - usage(); - else - n=atoi(pos+1); - pos=strchr(pos+1,','); - if(!pos) - usage(); - else - subn=atoi(pos+1); - if(n/subn*subn != n){ - fprintf(stderr,"n must be divisible by group\n"); - exit(1); - } - } - } - - /* scan the file for maximum value */ - file=fopen(infile,"r"); - if(!file){ - fprintf(stderr,"Could not open file %s\n",infile); - if(!maxval) - exit(1); - else - fprintf(stderr," making untrained books.\n"); - - } - - if(!maxval){ - i=0; - while(1){ - long v; - if(get_next_ivalue(file,&v))break; - if(v>maxval)maxval=v; - - if(!(i++&0xff))spinnit("loading... ",i); - } - rewind(file); - maxval++; - } - - { - long vals=pow(maxval,subn); - long *hist=_ogg_calloc(vals,sizeof(long)); - long *lengths=_ogg_calloc(vals,sizeof(long)); - - for(j=loval;j=vals)break; - hist[val]++; - if(!(i--&0xff))spinnit("loading... ",i*subn); - } - fclose(file); - } - - /* we have the probabilities, build the tree */ - fprintf(stderr,"Building tree for %ld entries\n",vals); - build_tree_from_lengths0(vals,hist,lengths); - - /* save the book */ - { - char *buffer=alloca(strlen(base)+5); - strcpy(buffer,base); - strcat(buffer,".vqh"); - file=fopen(buffer,"w"); - if(!file){ - fprintf(stderr,"Could not open file %s\n",buffer); - exit(1); - } - } - - /* first, the static vectors, then the book structure to tie it together. */ - /* lengthlist */ - fprintf(file,"static const char _huff_lengthlist_%s[] = {\n",base); - for(j=0;j -#include -#include -#include -#include -#include "bookutil.h" - -/* The purpose of this util is just to finish packaging the - description into a static codebook. It used to count hits for a - histogram, but I've divorced that out to add some flexibility (it - currently generates an equal probability codebook) - - command line: - latticebuild description.vql - - the lattice description file contains two lines: - - - ... - - a threshmap (or pigeonmap) struct is generated by latticehint; - there are fun tricks one can do with the threshmap and cascades, - but the utils don't know them... - - entropy encoding is done by feeding an entry list collected from a - training set and feeding it to latticetune along with the book. - - latticebuild produces a codebook on stdout */ - -static int ilog(unsigned int v){ - int ret=0; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - -int main(int argc,char *argv[]){ - codebook b; - static_codebook c; - double *quantlist; - long *hits; - - int entries=-1,dim=-1,quantvals=-1,addmul=-1,sequencep=0; - FILE *in=NULL; - char *line,*name; - long i,j; - - memset(&b,0,sizeof(b)); - memset(&c,0,sizeof(c)); - - if(argv[1]==NULL){ - fprintf(stderr,"Need a lattice description file on the command line.\n"); - exit(1); - } - - { - char *ptr; - char *filename=_ogg_calloc(strlen(argv[1])+4,1); - - strcpy(filename,argv[1]); - in=fopen(filename,"r"); - if(!in){ - fprintf(stderr,"Could not open input file %s\n",filename); - exit(1); - } - - ptr=strrchr(filename,'.'); - if(ptr){ - *ptr='\0'; - name=strdup(filename); - }else{ - name=strdup(filename); - } - - } - - /* read the description */ - line=get_line(in); - if(sscanf(line,"%d %d %d %d",&quantvals,&dim,&addmul,&sequencep)!=4){ - if(sscanf(line,"%d %d %d",&quantvals,&dim,&addmul)!=3){ - fprintf(stderr,"Syntax error reading description file (line 1)\n"); - exit(1); - } - } - entries=pow(quantvals,dim); - c.dim=dim; - c.entries=entries; - c.lengthlist=_ogg_malloc(entries*sizeof(long)); - c.maptype=1; - c.q_sequencep=sequencep; - c.quantlist=_ogg_calloc(quantvals,sizeof(long)); - - quantlist=_ogg_malloc(sizeof(double)*c.dim*c.entries); - hits=_ogg_malloc(c.entries*sizeof(long)); - for(j=0;j.00001f) break; - } - if(fac>100)break; - if(jc.q_quant)c.q_quant=ilog(c.quantlist[j]); - } - } - - /* build the [default] codeword lengths */ - memset(c.lengthlist,0,sizeof(long)*entries); - for(i=0;i -#include -#include -#include -#include -#include "bookutil.h" - -static int strrcmp_i(char *s,char *cmp){ - return(strncmp(s+strlen(s)-strlen(cmp),cmp,strlen(cmp))); -} - -/* This util takes a training-collected file listing codewords used in - LSP fitting, then generates new codeword lengths for maximally - efficient integer-bits entropy encoding. - - command line: - latticetune book.vqh input.vqd [unused_entriesp] - - latticetune produces book.vqh on stdout */ - -int main(int argc,char *argv[]){ - codebook *b; - static_codebook *c; - long *lengths; - long *hits; - - int entries=-1,dim=-1,guard=1; - FILE *in=NULL; - char *line,*name; - long j; - - if(argv[1]==NULL){ - fprintf(stderr,"Need a lattice codebook on the command line.\n"); - exit(1); - } - if(argv[2]==NULL){ - fprintf(stderr,"Need a codeword data file on the command line.\n"); - exit(1); - } - if(argv[3]!=NULL)guard=0; - - { - char *ptr; - char *filename=strdup(argv[1]); - - b=codebook_load(filename); - c=(static_codebook *)(b->c); - - ptr=strrchr(filename,'.'); - if(ptr){ - *ptr='\0'; - name=strdup(filename); - }else{ - name=strdup(filename); - } - } - - if(c->maptype!=1){ - fprintf(stderr,"Provided book is not a latticebook.\n"); - exit(1); - } - - entries=b->entries; - dim=b->dim; - - hits=_ogg_malloc(entries*sizeof(long)); - lengths=_ogg_calloc(entries,sizeof(long)); - for(j=0;jlengthlist=lengths; - write_codebook(stdout,name,c); - - { - long bins=_book_maptype1_quantvals(c); - long i,k,base=c->lengthlist[0]; - for(i=0;ilengthlist[i]>base)base=c->lengthlist[i]; - - for(j=0;jlengthlist[j]){ - int indexdiv=1; - fprintf(stderr,"%4ld: ",j); - for(k=0;kdim;k++){ - int index= (j/indexdiv)%bins; - fprintf(stderr,"%+3.1f,", c->quantlist[index]*_float32_unpack(c->q_delta)+ - _float32_unpack(c->q_min)); - indexdiv*=bins; - } - fprintf(stderr,"\t|"); - for(k=0;klengthlist[j];k++)fprintf(stderr,"*"); - fprintf(stderr,"\n"); - } - } - } - - fprintf(stderr,"\r " - "\nDone.\n"); - exit(0); -} diff --git a/Engine/lib/libvorbis/vq/localcodebook.h b/Engine/lib/libvorbis/vq/localcodebook.h deleted file mode 100644 index dbade0de8..000000000 --- a/Engine/lib/libvorbis/vq/localcodebook.h +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: basic shared codebook operations - - ********************************************************************/ - -#ifndef _V_CODEBOOK_H_ -#define _V_CODEBOOK_H_ - -#include - -/* This structure encapsulates huffman and VQ style encoding books; it - doesn't do anything specific to either. - - valuelist/quantlist are nonNULL (and q_* significant) only if - there's entry->value mapping to be done. - - If encode-side mapping must be done (and thus the entry needs to be - hunted), the auxiliary encode pointer will point to a decision - tree. This is true of both VQ and huffman, but is mostly useful - with VQ. - -*/ - -typedef struct static_codebook{ - long dim; /* codebook dimensions (elements per vector) */ - long entries; /* codebook entries */ - long *lengthlist; /* codeword lengths in bits */ - - /* mapping ***************************************************************/ - int maptype; /* 0=none - 1=implicitly populated values from map column - 2=listed arbitrary values */ - - /* The below does a linear, single monotonic sequence mapping. */ - long q_min; /* packed 32 bit float; quant value 0 maps to minval */ - long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ - int q_quant; /* bits: 0 < quant <= 16 */ - int q_sequencep; /* bitflag */ - - long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map - map == 2: list of dim*entries quantized entry vals - */ - int allocedp; -} static_codebook; - -typedef struct codebook{ - long dim; /* codebook dimensions (elements per vector) */ - long entries; /* codebook entries */ - long used_entries; /* populated codebook entries */ - static_codebook *c; - - /* for encode, the below are entry-ordered, fully populated */ - /* for decode, the below are ordered by bitreversed codeword and only - used entries are populated */ - float *valuelist; /* list of dim*entries actual entry values */ - ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */ - - int *dec_index; /* only used if sparseness collapsed */ - char *dec_codelengths; - ogg_uint32_t *dec_firsttable; - int dec_firsttablen; - int dec_maxlength; - - /* The current encoder uses only centered, integer-only lattice books. */ - int quantvals; - int minval; - int delta; - -} codebook; - -extern void vorbis_staticbook_clear(static_codebook *b); -extern void vorbis_staticbook_destroy(static_codebook *b); -extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source); -extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); -extern void vorbis_book_clear(codebook *b); - -extern float *_book_unquantize(const static_codebook *b,int n,int *map); -extern float *_book_logdist(const static_codebook *b,float *vals); -extern float _float32_unpack(long val); -extern long _float32_pack(float val); -extern int _best(codebook *book, float *a, int step); -extern int _ilog(unsigned int v); -extern long _book_maptype1_quantvals(const static_codebook *b); - -extern int vorbis_book_besterror(codebook *book,float *a,int step,int addmul); -extern long vorbis_book_codeword(codebook *book,int entry); -extern long vorbis_book_codelen(codebook *book,int entry); - - - -extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b); -extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c); - -extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b); - -extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); -extern long vorbis_book_decodevs_add(codebook *book, float *a, - oggpack_buffer *b,int n); -extern long vorbis_book_decodev_set(codebook *book, float *a, - oggpack_buffer *b,int n); -extern long vorbis_book_decodev_add(codebook *book, float *a, - oggpack_buffer *b,int n); -extern long vorbis_book_decodevv_add(codebook *book, float **a, - long off,int ch, - oggpack_buffer *b,int n); - - - -#endif diff --git a/Engine/lib/libvorbis/vq/make_floor_books.pl b/Engine/lib/libvorbis/vq/make_floor_books.pl deleted file mode 100644 index 5c3736617..000000000 --- a/Engine/lib/libvorbis/vq/make_floor_books.pl +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/perl - -# quick, very dirty little script so that we can put all the -# information for building a floor book set in one spec file. - -#eg: - -# >floor_44 -# =44c0_s 44c1_s 44c2_s -# build line_128x4_class0 0-256 -# build line_128x4_0sub0 0-4 - -die "Could not open $ARGV[0]: $!" unless open (F,$ARGV[0]); - -$goflag=0; -while($line=){ - - print "#### $line"; - if($line=~m/^GO/){ - $goflag=1; - next; - } - - if($goflag==0){ - if($line=~m/\S+/ && !($line=~m/^\#/) ){ - my $command=$line; - print ">>> $command"; - die "Couldn't shell command.\n\tcommand:$command\n" - if syst($command); - } - next; - } - - # >floor_44 - # this sets the output bookset file name - if($line=~m/^>(\S+)\s+(\S*)/){ - # set the output name - $globalname=$1; - - $command="rm -f $globalname.vqh"; - die "Couldn't remove file.\n\tcommand:$command\n" - if syst($command); - - next; - } - - #=path1 path2 path3 - #set the search path for input files; each build line will look - #for input files in all of the directories in the search path and - #append them for huffbuild input - if($line=~m/^=(.*)/){ - # set the output name - @paths=split(' ',$1); - next; - } - - # build book.vqd 0-3 [noguard] - if($line=~m/^build (.*)/){ - # build a huffman book (no mapping) - my($datafile,$range,$guard)=split(' ',$1); - - $command="rm -f $datafile.tmp"; - print "\n\n>>> $command\n"; - die "Couldn't remove temp file.\n\tcommand:$command\n" - if syst($command); - - # first find all the inputs we want; they'll need to be collected into a single input file - foreach $dir (@paths){ - if (-e "$dir/$datafile.vqd"){ - $command="cat $dir/$datafile.vqd >> $datafile.tmp"; - print ">>> $command\n"; - die "Couldn't append training data.\n\tcommand:$command\n" - if syst($command); - } - } - - my $command="huffbuild $datafile.tmp $range $guard"; - print ">>> $command\n"; - die "Couldn't build huffbook.\n\tcommand:$command\n" - if syst($command); - - $command="cat $datafile.vqh >> $globalname.vqh"; - print ">>> $command\n"; - die "Couldn't append to output book.\n\tcommand:$command\n" - if syst($command); - - $command="rm $datafile.vqh"; - print ">>> $command\n"; - die "Couldn't remove temporary output file.\n\tcommand:$command\n" - if syst($command); - - $command="rm -f $datafile.tmp"; - print ">>> $command\n"; - die "Couldn't remove temporary output file.\n\tcommand:$command\n" - if syst($command); - next; - } - -} - -$command="rm -f temp$$.vqd"; -print ">>> $command\n"; -die "Couldn't remove temp files.\n\tcommand:$command\n" - if syst($command); - -sub syst{ - system(@_)/256; -} diff --git a/Engine/lib/libvorbis/vq/make_residue_books.pl b/Engine/lib/libvorbis/vq/make_residue_books.pl deleted file mode 100644 index b37d0dcd2..000000000 --- a/Engine/lib/libvorbis/vq/make_residue_books.pl +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/perl - -# quick, very dirty little script so that we can put all the -# information for building a residue book set (except the original -# partitioning) in one spec file. - -#eg: - -# >res0_128_128 interleaved -# haux 44c0_s/resaux_0.vqd res0_96_128aux 0,4,2 9 -# :1 res0_128_128_1.vqd, 4, nonseq cull, 0 +- 1 -# :2 res0_128_128_2.vqd, 4, nonseq, 0 +- 1(.7) 2 -# :3 res0_128_128_3.vqd, 4, nonseq, 0 +- 1(.7) 3 5 -# :4 res0_128_128_4.vqd, 2, nonseq, 0 +- 1(.7) 3 5 8 11 -# :5 res0_128_128_5.vqd, 1, nonseq, 0 +- 1 3 5 8 11 14 17 20 24 28 31 35 39 - - -die "Could not open $ARGV[0]: $!" unless open (F,$ARGV[0]); - -$goflag=0; -while($line=){ - - print "#### $line"; - if($line=~m/^GO/){ - $goflag=1; - next; - } - - if($goflag==0){ - if($line=~m/\S+/ && !($line=~m/^\#/) ){ - my $command=$line; - print ">>> $command"; - die "Couldn't shell command.\n\tcommand:$command\n" - if syst($command); - } - next; - } - - # >res0_128_128 - if($line=~m/^>(\S+)\s+(\S*)/){ - # set the output name - $globalname=$1; - $interleave=$2; - next; - } - - # haux 44c0_s/resaux_0.vqd res0_96_128aux 0,4,2 9 - if($line=~m/^h(.*)/){ - # build a huffman book (no mapping) - my($name,$datafile,$bookname,$interval,$range)=split(' ',$1); - - # check the desired subdir to see if the data file exists - if(-e $datafile){ - my $command="cp $datafile $bookname.tmp"; - print ">>> $command\n"; - die "Couldn't access partition data file.\n\tcommand:$command\n" - if syst($command); - - my $command="huffbuild $bookname.tmp $interval"; - print ">>> $command\n"; - die "Couldn't build huffbook.\n\tcommand:$command\n" - if syst($command); - - my $command="rm $bookname.tmp"; - print ">>> $command\n"; - die "Couldn't remove temporary file.\n\tcommand:$command\n" - if syst($command); - }else{ - my $command="huffbuild $bookname.tmp 0-$range"; - print ">>> $command\n"; - die "Couldn't build huffbook.\n\tcommand:$command\n" - if syst($command); - - } - next; - } - - # :1 res0_128_128_1.vqd, 4, nonseq, 0 +- 1 - if($line=~m/^:(.*)/){ - my($namedata,$dim,$seqp,$vals)=split(',',$1); - my($name,$datafile)=split(' ',$namedata); - # build value list - my$plusminus="+"; - my$list; - my$thlist; - my$count=0; - foreach my$val (split(' ',$vals)){ - if($val=~/\-?\+?\d+/){ - my$th; - - # got an explicit threshhint? - if($val=~/([0-9\.]+)\(([^\)]+)/){ - $val=$1; - $th=$2; - } - - if($plusminus=~/-/){ - $list.="-$val "; - if(defined($th)){ - $thlist.="," if(defined($thlist)); - $thlist.="-$th"; - } - $count++; - } - if($plusminus=~/\+/){ - $list.="$val "; - if(defined($th)){ - $thlist.="," if(defined($thlist)); - $thlist.="$th"; - } - $count++; - } - }else{ - $plusminus=$val; - } - } - die "Couldn't open temp file $globalname$name.vql: $!" unless - open(G,">$globalname$name.vql"); - print G "$count $dim 0 "; - if($seqp=~/non/){ - print G "0\n$list\n"; - }else{ - print G "1\n$list\n"; - } - close(G); - - my $command="latticebuild $globalname$name.vql > $globalname$name.vqh"; - print ">>> $command\n"; - die "Couldn't build latticebook.\n\tcommand:$command\n" - if syst($command); - - if(-e $datafile){ - - if($interleave=~/non/){ - $restune="res1tune"; - }else{ - $restune="res0tune"; - } - - if($seqp=~/cull/){ - my $command="$restune $globalname$name.vqh $datafile 1 > temp$$.vqh"; - print ">>> $command\n"; - die "Couldn't tune latticebook.\n\tcommand:$command\n" - if syst($command); - }else{ - my $command="$restune $globalname$name.vqh $datafile > temp$$.vqh"; - print ">>> $command\n"; - die "Couldn't tune latticebook.\n\tcommand:$command\n" - if syst($command); - } - - my $command="mv temp$$.vqh $globalname$name.vqh"; - print ">>> $command\n"; - die "Couldn't rename latticebook.\n\tcommand:$command\n" - if syst($command); - - }else{ - print "No matching training file; leaving this codebook untrained.\n"; - } - - my $command="rm $globalname$name.vql"; - print ">>> $command\n"; - die "Couldn't remove temp files.\n\tcommand:$command\n" - if syst($command); - - next; - } -} - -$command="rm -f temp$$.vqd"; -print ">>> $command\n"; -die "Couldn't remove temp files.\n\tcommand:$command\n" - if syst($command); - -sub syst{ - system(@_)/256; -} diff --git a/Engine/lib/libvorbis/vq/metrics.c b/Engine/lib/libvorbis/vq/metrics.c deleted file mode 100644 index d9f0da357..000000000 --- a/Engine/lib/libvorbis/vq/metrics.c +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: function calls to collect codebook metrics - - ********************************************************************/ - - -#include -#include -#include -#include "bookutil.h" - -/* collect the following metrics: - - mean and mean squared amplitude - mean and mean squared error - mean and mean squared error (per sample) by entry - worst case fit by entry - entry cell size - hits by entry - total bits - total samples - (average bits per sample)*/ - - -/* set up metrics */ - -float meanamplitude_acc=0.f; -float meanamplitudesq_acc=0.f; -float meanerror_acc=0.f; -float meanerrorsq_acc=0.f; - -float **histogram=NULL; -float **histogram_error=NULL; -float **histogram_errorsq=NULL; -float **histogram_hi=NULL; -float **histogram_lo=NULL; -float bits=0.f; -float count=0.f; - -static float *_now(codebook *c, int i){ - return c->valuelist+i*c->c->dim; -} - -int books=0; - -void process_preprocess(codebook **bs,char *basename){ - int i; - while(bs[books])books++; - - if(books){ - histogram=_ogg_calloc(books,sizeof(float *)); - histogram_error=_ogg_calloc(books,sizeof(float *)); - histogram_errorsq=_ogg_calloc(books,sizeof(float *)); - histogram_hi=_ogg_calloc(books,sizeof(float *)); - histogram_lo=_ogg_calloc(books,sizeof(float *)); - }else{ - fprintf(stderr,"Specify at least one codebook\n"); - exit(1); - } - - for(i=0;ientries,sizeof(float)); - histogram_error[i]=_ogg_calloc(b->entries*b->dim,sizeof(float)); - histogram_errorsq[i]=_ogg_calloc(b->entries*b->dim,sizeof(float)); - histogram_hi[i]=_ogg_calloc(b->entries*b->dim,sizeof(float)); - histogram_lo[i]=_ogg_calloc(b->entries*b->dim,sizeof(float)); - } -} - -static float _dist(int el,float *a, float *b){ - int i; - float acc=0.f; - for(i=0;ic->entries;j++){ - if(c->c->lengthlist[j]>0){ - float localmin=-1.; - for(k=0;kc->entries;k++){ - if(c->c->lengthlist[k]>0){ - float this=_dist(c->c->dim,_now(c,j),_now(c,k)); - if(j!=k && - (localmin==-1 || thismax)max=localmin; - mean+=sqrt(localmin); - meansq+=localmin; - total++; - } - } - - fprintf(stderr,"\tminimum cell spacing (closest side): %g\n",sqrt(min)); - fprintf(stderr,"\tmaximum cell spacing (closest side): %g\n",sqrt(max)); - fprintf(stderr,"\tmean closest side spacing: %g\n",mean/total); - fprintf(stderr,"\tmean sq closest side spacing: %g\n",sqrt(meansq/total)); -} - -void process_postprocess(codebook **bs,char *basename){ - int i,k,book; - char *buffer=alloca(strlen(basename)+80); - - fprintf(stderr,"Done. Processed %ld data points:\n\n", - (long)count); - - fprintf(stderr,"Global statistics:******************\n\n"); - - fprintf(stderr,"\ttotal samples: %ld\n",(long)count); - fprintf(stderr,"\ttotal bits required to code: %ld\n",(long)bits); - fprintf(stderr,"\taverage bits per sample: %g\n\n",bits/count); - - fprintf(stderr,"\tmean sample amplitude: %g\n", - meanamplitude_acc/count); - fprintf(stderr,"\tmean squared sample amplitude: %g\n\n", - sqrt(meanamplitudesq_acc/count)); - - fprintf(stderr,"\tmean code error: %g\n", - meanerror_acc/count); - fprintf(stderr,"\tmean squared code error: %g\n\n", - sqrt(meanerrorsq_acc/count)); - - for(book=0;bookc->entries; - int dim=b->c->dim; - - fprintf(stderr,"Book %d statistics:------------------\n",book); - - cell_spacing(b); - - sprintf(buffer,"%s-%d-mse.m",basename,book); - out=fopen(buffer,"w"); - if(!out){ - fprintf(stderr,"Could not open file %s for writing\n",buffer); - exit(1); - } - - for(i=0;ivaluelist+i*dim)[k], - sqrt((histogram_errorsq[book]+i*dim)[k]/histogram[book][i])); - } - } - fclose(out); - - sprintf(buffer,"%s-%d-me.m",basename,book); - out=fopen(buffer,"w"); - if(!out){ - fprintf(stderr,"Could not open file %s for writing\n",buffer); - exit(1); - } - - for(i=0;ivaluelist+i*dim)[k], - (histogram_error[book]+i*dim)[k]/histogram[book][i]); - } - } - fclose(out); - - sprintf(buffer,"%s-%d-worst.m",basename,book); - out=fopen(buffer,"w"); - if(!out){ - fprintf(stderr,"Could not open file %s for writing\n",buffer); - exit(1); - } - - for(i=0;ivaluelist+i*dim)[k], - (b->valuelist+i*dim)[k]+(histogram_lo[book]+i*dim)[k], - (b->valuelist+i*dim)[k]+(histogram_hi[book]+i*dim)[k]); - } - } - fclose(out); - } -} - -float process_one(codebook *b,int book,float *a,int dim,int step,int addmul, - float base){ - int j,entry; - float amplitude=0.f; - - if(book==0){ - float last=base; - for(j=0;jc->q_sequencep?last:0); - meanamplitude_acc+=fabs(amplitude); - meanamplitudesq_acc+=amplitude*amplitude; - count++; - last=a[j*step]; - } - } - - if(b->c->q_sequencep){ - float temp; - for(j=0;jerror) - histogram_lo[book][entry*dim+j]=error; - } - return base; -} - - -void process_vector(codebook **bs,int *addmul,int inter,float *a,int n){ - int bi; - int i; - - for(bi=0;bidim; - float base=0.f; - - if(inter){ - for(i=0;i.vqh [ +|* ]... \n" - " datafile.vqd [datafile.vqd]...\n\n" - " data can be taken on stdin. -i indicates interleaved coding.\n" - " Output goes to output files:\n" - " basename-me.m: gnuplot: mean error by entry value\n" - " basename-mse.m: gnuplot: mean square error by entry value\n" - " basename-worst.m: gnuplot: worst error by entry value\n" - " basename-distance.m: gnuplot file showing distance probability\n" - "\n"); - -} diff --git a/Engine/lib/libvorbis/vq/vqgen.c b/Engine/lib/libvorbis/vq/vqgen.c deleted file mode 100644 index 45f7790d7..000000000 --- a/Engine/lib/libvorbis/vq/vqgen.c +++ /dev/null @@ -1,566 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: train a VQ codebook - - ********************************************************************/ - -/* This code is *not* part of libvorbis. It is used to generate - trained codebooks offline and then spit the results into a - pregenerated codebook that is compiled into libvorbis. It is an - expensive (but good) algorithm. Run it on big iron. */ - -/* There are so many optimizations to explore in *both* stages that - considering the undertaking is almost withering. For now, we brute - force it all */ - -#include -#include -#include -#include - -#include "vqgen.h" -#include "bookutil.h" - -/* Codebook generation happens in two steps: - - 1) Train the codebook with data collected from the encoder: We use - one of a few error metrics (which represent the distance between a - given data point and a candidate point in the training set) to - divide the training set up into cells representing roughly equal - probability of occurring. - - 2) Generate the codebook and auxiliary data from the trained data set -*/ - -/* Codebook training **************************************************** - * - * The basic idea here is that a VQ codebook is like an m-dimensional - * foam with n bubbles. The bubbles compete for space/volume and are - * 'pressurized' [biased] according to some metric. The basic alg - * iterates through allowing the bubbles to compete for space until - * they converge (if the damping is dome properly) on a steady-state - * solution. Individual input points, collected from libvorbis, are - * used to train the algorithm monte-carlo style. */ - -/* internal helpers *****************************************************/ -#define vN(data,i) (data+v->elements*i) - -/* default metric; squared 'distance' from desired value. */ -float _dist(vqgen *v,float *a, float *b){ - int i; - int el=v->elements; - float acc=0.f; - for(i=0;ientries;i++) - memcpy(_now(v,i),_point(v,i),sizeof(float)*v->elements); - v->seeded=1; -} - -int directdsort(const void *a, const void *b){ - float av=*((float *)a); - float bv=*((float *)b); - return (avbv); -} - -void vqgen_cellmetric(vqgen *v){ - int j,k; - float min=-1.f,max=-1.f,mean=0.f,acc=0.f; - long dup=0,unused=0; - #ifdef NOISY - int i; - char buff[80]; - float spacings[v->entries]; - int count=0; - FILE *cells; - sprintf(buff,"cellspace%d.m",v->it); - cells=fopen(buff,"w"); -#endif - - /* minimum, maximum, cell spacing */ - for(j=0;jentries;j++){ - float localmin=-1.; - - for(k=0;kentries;k++){ - if(j!=k){ - float this=_dist(v,_now(v,j),_now(v,k)); - if(this>0){ - if(v->assigned[k] && (localmin==-1 || thisentries)continue; - - if(v->assigned[j]==0){ - unused++; - continue; - } - - localmin=v->max[j]+localmin/2; /* this gives us rough diameter */ - if(min==-1 || localminmax)max=localmin; - mean+=localmin; - acc++; -#ifdef NOISY - spacings[count++]=localmin; -#endif - } - - fprintf(stderr,"cell diameter: %.03g::%.03g::%.03g (%ld unused/%ld dup)\n", - min,mean/acc,max,unused,dup); - -#ifdef NOISY - qsort(spacings,count,sizeof(float),directdsort); - for(i=0;iquant)-1); - - int j,k; - - mindel=maxdel=_now(v,0)[0]; - - for(j=0;jentries;j++){ - float last=0.f; - for(k=0;kelements;k++){ - if(mindel>_now(v,j)[k]-last)mindel=_now(v,j)[k]-last; - if(maxdel<_now(v,j)[k]-last)maxdel=_now(v,j)[k]-last; - if(q->sequencep)last=_now(v,j)[k]; - } - } - - - /* first find the basic delta amount from the maximum span to be - encoded. Loosen the delta slightly to allow for additional error - during sequence quantization */ - - delta=(maxdel-mindel)/((1<quant)-1.5f); - - q->min=_float32_pack(mindel); - q->delta=_float32_pack(delta); - - mindel=_float32_unpack(q->min); - delta=_float32_unpack(q->delta); - - for(j=0;jentries;j++){ - float last=0; - for(k=0;kelements;k++){ - float val=_now(v,j)[k]; - float now=rint((val-last-mindel)/delta); - - _now(v,j)[k]=now; - if(now<0){ - /* be paranoid; this should be impossible */ - fprintf(stderr,"fault; quantized value<0\n"); - exit(1); - } - - if(now>maxquant){ - /* be paranoid; this should be impossible */ - fprintf(stderr,"fault; quantized value>max\n"); - exit(1); - } - if(q->sequencep)last=(now*delta)+mindel+last; - } - } -} - -/* much easier :-). Unlike in the codebook, we don't un-log log - scales; we just make sure they're properly offset. */ -void vqgen_unquantize(vqgen *v,quant_meta *q){ - long j,k; - float mindel=_float32_unpack(q->min); - float delta=_float32_unpack(q->delta); - - for(j=0;jentries;j++){ - float last=0.f; - for(k=0;kelements;k++){ - float now=_now(v,j)[k]; - now=fabs(now)*delta+last+mindel; - if(q->sequencep)last=now; - _now(v,j)[k]=now; - } - } -} - -void vqgen_init(vqgen *v,int elements,int aux,int entries,float mindist, - float (*metric)(vqgen *,float *, float *), - float *(*weight)(vqgen *,float *),int centroid){ - memset(v,0,sizeof(vqgen)); - - v->centroid=centroid; - v->elements=elements; - v->aux=aux; - v->mindist=mindist; - v->allocated=32768; - v->pointlist=_ogg_malloc(v->allocated*(v->elements+v->aux)*sizeof(float)); - - v->entries=entries; - v->entrylist=_ogg_malloc(v->entries*v->elements*sizeof(float)); - v->assigned=_ogg_malloc(v->entries*sizeof(long)); - v->bias=_ogg_calloc(v->entries,sizeof(float)); - v->max=_ogg_calloc(v->entries,sizeof(float)); - if(metric) - v->metric_func=metric; - else - v->metric_func=_dist; - if(weight) - v->weight_func=weight; - else - v->weight_func=_weight_null; - - v->asciipoints=tmpfile(); - -} - -void vqgen_addpoint(vqgen *v, float *p,float *a){ - int k; - for(k=0;kelements;k++) - fprintf(v->asciipoints,"%.12g\n",p[k]); - for(k=0;kaux;k++) - fprintf(v->asciipoints,"%.12g\n",a[k]); - - if(v->points>=v->allocated){ - v->allocated*=2; - v->pointlist=_ogg_realloc(v->pointlist,v->allocated*(v->elements+v->aux)* - sizeof(float)); - } - - memcpy(_point(v,v->points),p,sizeof(float)*v->elements); - if(v->aux)memcpy(_point(v,v->points)+v->elements,a,sizeof(float)*v->aux); - - /* quantize to the density mesh if it's selected */ - if(v->mindist>0.f){ - /* quantize to the mesh */ - for(k=0;kelements+v->aux;k++) - _point(v,v->points)[k]= - rint(_point(v,v->points)[k]/v->mindist)*v->mindist; - } - v->points++; - if(!(v->points&0xff))spinnit("loading... ",v->points); -} - -/* yes, not threadsafe. These utils aren't */ -static int sortit=0; -static int sortsize=0; -static int meshcomp(const void *a,const void *b){ - if(((sortit++)&0xfff)==0)spinnit("sorting mesh...",sortit); - return(memcmp(a,b,sortsize)); -} - -void vqgen_sortmesh(vqgen *v){ - sortit=0; - if(v->mindist>0.f){ - long i,march=1; - - /* sort to make uniqueness detection trivial */ - sortsize=(v->elements+v->aux)*sizeof(float); - qsort(v->pointlist,v->points,sortsize,meshcomp); - - /* now march through and eliminate dupes */ - for(i=1;ipoints;i++){ - if(memcmp(_point(v,i),_point(v,i-1),sortsize)){ - /* a new, unique entry. march it down */ - if(i>march)memcpy(_point(v,march),_point(v,i),sortsize); - march++; - } - spinnit("eliminating density... ",v->points-i); - } - - /* we're done */ - fprintf(stderr,"\r%ld training points remining out of %ld" - " after density mesh (%ld%%)\n",march,v->points,march*100/v->points); - v->points=march; - - } - v->sorted=1; -} - -float vqgen_iterate(vqgen *v,int biasp){ - long i,j,k; - - float fdesired; - long desired; - long desired2; - - float asserror=0.f; - float meterror=0.f; - float *new; - float *new2; - long *nearcount; - float *nearbias; - #ifdef NOISY - char buff[80]; - FILE *assig; - FILE *bias; - FILE *cells; - sprintf(buff,"cells%d.m",v->it); - cells=fopen(buff,"w"); - sprintf(buff,"assig%d.m",v->it); - assig=fopen(buff,"w"); - sprintf(buff,"bias%d.m",v->it); - bias=fopen(buff,"w"); - #endif - - - if(v->entries<2){ - fprintf(stderr,"generation requires at least two entries\n"); - exit(1); - } - - if(!v->sorted)vqgen_sortmesh(v); - if(!v->seeded)_vqgen_seed(v); - - fdesired=(float)v->points/v->entries; - desired=fdesired; - desired2=desired*2; - new=_ogg_malloc(sizeof(float)*v->entries*v->elements); - new2=_ogg_malloc(sizeof(float)*v->entries*v->elements); - nearcount=_ogg_malloc(v->entries*sizeof(long)); - nearbias=_ogg_malloc(v->entries*desired2*sizeof(float)); - - /* fill in nearest points for entry biasing */ - /*memset(v->bias,0,sizeof(float)*v->entries);*/ - memset(nearcount,0,sizeof(long)*v->entries); - memset(v->assigned,0,sizeof(long)*v->entries); - if(biasp){ - for(i=0;ipoints;i++){ - float *ppt=v->weight_func(v,_point(v,i)); - float firstmetric=v->metric_func(v,_now(v,0),ppt)+v->bias[0]; - float secondmetric=v->metric_func(v,_now(v,1),ppt)+v->bias[1]; - long firstentry=0; - long secondentry=1; - - if(!(i&0xff))spinnit("biasing... ",v->points+v->points+v->entries-i); - - if(firstmetric>secondmetric){ - float temp=firstmetric; - firstmetric=secondmetric; - secondmetric=temp; - firstentry=1; - secondentry=0; - } - - for(j=2;jentries;j++){ - float thismetric=v->metric_func(v,_now(v,j),ppt)+v->bias[j]; - if(thismetricentries;j++){ - - float thismetric,localmetric; - float *nearbiasptr=nearbias+desired2*j; - long k=nearcount[j]; - - localmetric=v->metric_func(v,_now(v,j),ppt); - /* 'thismetric' is to be the bias value necessary in the current - arrangement for entry j to capture point i */ - if(firstentry==j){ - /* use the secondary entry as the threshhold */ - thismetric=secondmetric-localmetric; - }else{ - /* use the primary entry as the threshhold */ - thismetric=firstmetric-localmetric; - } - - /* support the idea of 'minimum distance'... if we want the - cells in a codebook to be roughly some minimum size (as with - the low resolution residue books) */ - - /* a cute two-stage delayed sorting hack */ - if(kpoints+v->points+v->entries-i); - qsort(nearbiasptr,desired,sizeof(float),directdsort); - } - - }else if(thismetric>nearbiasptr[desired-1]){ - nearbiasptr[k]=thismetric; - k++; - if(k==desired2){ - spinnit("biasing... ",v->points+v->points+v->entries-i); - qsort(nearbiasptr,desired2,sizeof(float),directdsort); - k=desired; - } - } - nearcount[j]=k; - } - } - - /* inflate/deflate */ - - for(i=0;ientries;i++){ - float *nearbiasptr=nearbias+desired2*i; - - spinnit("biasing... ",v->points+v->entries-i); - - /* due to the delayed sorting, we likely need to finish it off....*/ - if(nearcount[i]>desired) - qsort(nearbiasptr,nearcount[i],sizeof(float),directdsort); - - v->bias[i]=nearbiasptr[desired-1]; - - } - }else{ - memset(v->bias,0,v->entries*sizeof(float)); - } - - /* Now assign with new bias and find new midpoints */ - for(i=0;ipoints;i++){ - float *ppt=v->weight_func(v,_point(v,i)); - float firstmetric=v->metric_func(v,_now(v,0),ppt)+v->bias[0]; - long firstentry=0; - - if(!(i&0xff))spinnit("centering... ",v->points-i); - - for(j=0;jentries;j++){ - float thismetric=v->metric_func(v,_now(v,j),ppt)+v->bias[j]; - if(thismetricbias[j]; - meterror+=firstmetric; - - if(v->centroid==0){ - /* set up midpoints for next iter */ - if(v->assigned[j]++){ - for(k=0;kelements;k++) - vN(new,j)[k]+=ppt[k]; - if(firstmetric>v->max[j])v->max[j]=firstmetric; - }else{ - for(k=0;kelements;k++) - vN(new,j)[k]=ppt[k]; - v->max[j]=firstmetric; - } - }else{ - /* centroid */ - if(v->assigned[j]++){ - for(k=0;kelements;k++){ - if(vN(new,j)[k]>ppt[k])vN(new,j)[k]=ppt[k]; - if(vN(new2,j)[k]v->max[firstentry])v->max[j]=firstmetric; - }else{ - for(k=0;kelements;k++){ - vN(new,j)[k]=ppt[k]; - vN(new2,j)[k]=ppt[k]; - } - v->max[firstentry]=firstmetric; - } - } - } - - /* assign midpoints */ - - for(j=0;jentries;j++){ -#ifdef NOISY - fprintf(assig,"%ld\n",v->assigned[j]); - fprintf(bias,"%g\n",v->bias[j]); -#endif - asserror+=fabs(v->assigned[j]-fdesired); - if(v->assigned[j]){ - if(v->centroid==0){ - for(k=0;kelements;k++) - _now(v,j)[k]=vN(new,j)[k]/v->assigned[j]; - }else{ - for(k=0;kelements;k++) - _now(v,j)[k]=(vN(new,j)[k]+vN(new2,j)[k])/2.f; - } - } - } - - asserror/=(v->entries*fdesired); - - fprintf(stderr,"Pass #%d... ",v->it); - fprintf(stderr,": dist %g(%g) metric error=%g \n", - asserror,fdesired,meterror/v->points); - v->it++; - - free(new); - free(nearcount); - free(nearbias); -#ifdef NOISY - fclose(assig); - fclose(bias); - fclose(cells); -#endif - return(asserror); -} - diff --git a/Engine/lib/libvorbis/vq/vqgen.h b/Engine/lib/libvorbis/vq/vqgen.h deleted file mode 100644 index 47a7d2da6..000000000 --- a/Engine/lib/libvorbis/vq/vqgen.h +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation https://xiph.org/ * - * * - ******************************************************************** - - function: build a VQ codebook - - ********************************************************************/ - -#ifndef _VQGEN_H_ -#define _VQGEN_H_ - -typedef struct vqgen{ - int seeded; - int sorted; - - int it; - int elements; - - int aux; - float mindist; - int centroid; - - /* point cache */ - float *pointlist; - long points; - long allocated; - - /* entries */ - float *entrylist; - long *assigned; - float *bias; - long entries; - float *max; - - float (*metric_func) (struct vqgen *v,float *entry,float *point); - float *(*weight_func) (struct vqgen *v,float *point); - - FILE *asciipoints; -} vqgen; - -typedef struct { - long min; /* packed 24 bit float */ - long delta; /* packed 24 bit float */ - int quant; /* 0 < quant <= 16 */ - int sequencep; /* bitflag */ -} quant_meta; - -static inline float *_point(vqgen *v,long ptr){ - return v->pointlist+((v->elements+v->aux)*ptr); -} - -static inline float *_aux(vqgen *v,long ptr){ - return _point(v,ptr)+v->aux; -} - -static inline float *_now(vqgen *v,long ptr){ - return v->entrylist+(v->elements*ptr); -} - -extern void vqgen_init(vqgen *v, - int elements,int aux,int entries,float mindist, - float (*metric)(vqgen *,float *, float *), - float *(*weight)(vqgen *,float *),int centroid); -extern void vqgen_addpoint(vqgen *v, float *p,float *aux); - -extern float vqgen_iterate(vqgen *v,int biasp); -extern void vqgen_unquantize(vqgen *v,quant_meta *q); -extern void vqgen_quantize(vqgen *v,quant_meta *q); -extern void vqgen_cellmetric(vqgen *v); - -#endif - - - - - diff --git a/Engine/lib/libvorbis/win32/VS2005/README b/Engine/lib/libvorbis/win32/VS2005/README deleted file mode 100644 index 3e3ea55f2..000000000 --- a/Engine/lib/libvorbis/win32/VS2005/README +++ /dev/null @@ -1,16 +0,0 @@ -libvorbis has libogg as a dependency, you need to have libogg -compiled beforehand. - -Lets say you have libogg and libvorbis in the same directory: - -libogg-1.1.3 -libvorbis-1.2.0 - -Because there is no automatic library detection you have to, -either: - -1. Rename libogg-1.1.3 to libogg - -2. Open libogg.vsprops with a text editor (even notepad.exe -will suffice) and see if LIBOGG_VERSION is set to the correct -version, in this case "1.1.3" diff --git a/Engine/lib/libvorbis/win32/VS2005/libogg.vsprops b/Engine/lib/libvorbis/win32/VS2005/libogg.vsprops deleted file mode 100644 index dca120819..000000000 --- a/Engine/lib/libvorbis/win32/VS2005/libogg.vsprops +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - diff --git a/Engine/lib/libvorbis/win32/VS2008/README b/Engine/lib/libvorbis/win32/VS2008/README deleted file mode 100644 index 3e3ea55f2..000000000 --- a/Engine/lib/libvorbis/win32/VS2008/README +++ /dev/null @@ -1,16 +0,0 @@ -libvorbis has libogg as a dependency, you need to have libogg -compiled beforehand. - -Lets say you have libogg and libvorbis in the same directory: - -libogg-1.1.3 -libvorbis-1.2.0 - -Because there is no automatic library detection you have to, -either: - -1. Rename libogg-1.1.3 to libogg - -2. Open libogg.vsprops with a text editor (even notepad.exe -will suffice) and see if LIBOGG_VERSION is set to the correct -version, in this case "1.1.3" diff --git a/Engine/lib/libvorbis/win32/VS2008/libogg.vsprops b/Engine/lib/libvorbis/win32/VS2008/libogg.vsprops deleted file mode 100644 index 807b74a67..000000000 --- a/Engine/lib/libvorbis/win32/VS2008/libogg.vsprops +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - diff --git a/Engine/lib/libvorbis/win32/VS2010/README b/Engine/lib/libvorbis/win32/VS2010/README deleted file mode 100644 index c2123773f..000000000 --- a/Engine/lib/libvorbis/win32/VS2010/README +++ /dev/null @@ -1,16 +0,0 @@ -libvorbis has libogg as a dependency, you need to have libogg -compiled beforehand. - -Lets say you have libogg and libvorbis in the same directory: - -libogg-1.3.2 -libvorbis-1.4.0 - -Because there is no automatic library detection you have to, -either: - -1. Rename libogg-1.3.2 to libogg. - -2. Open libogg.props with a text editor (even notepad.exe -will suffice) and see if LIBOGG_VERSION is set to the correct -version, in this case "1.3.2". diff --git a/Engine/lib/libvorbis/win32/VS2010/libogg.props b/Engine/lib/libvorbis/win32/VS2010/libogg.props deleted file mode 100644 index c83512ed4..000000000 --- a/Engine/lib/libvorbis/win32/VS2010/libogg.props +++ /dev/null @@ -1,22 +0,0 @@ - - - - 1.3.2 - - - <_ProjectFileVersion>10.0.30319.1 - - - - ..\..\..\..\libogg-$(LIBOGG_VERSION)\include;..\..\..\..\libogg\include;..\..\..\..\..\..\..\core\ogg\libogg\include;%(AdditionalIncludeDirectories) - - - ..\..\..\..\libogg-$(LIBOGG_VERSION)\win32\VS2015\$(PlatformName)\$(ConfigurationName);..\..\..\..\libogg\win32\VS2015\$(PlatformName)\$(ConfigurationName);..\..\..\..\..\..\..\core\ogg\libogg\win32\VS2015\$(PlatformName)\$(ConfigurationName) - - - - - $(LIBOGG_VERSION) - - - diff --git a/Engine/lib/libvorbis/win32/vorbis.def b/Engine/lib/libvorbis/win32/vorbis.def deleted file mode 100644 index 884f8f023..000000000 --- a/Engine/lib/libvorbis/win32/vorbis.def +++ /dev/null @@ -1,58 +0,0 @@ -; vorbis.def -; -LIBRARY -EXPORTS -_floor_P -_mapping_P -_residue_P -; -vorbis_info_init -vorbis_info_clear -vorbis_info_blocksize -; -vorbis_comment_init -vorbis_comment_add -vorbis_comment_add_tag -vorbis_comment_query -vorbis_comment_query_count -vorbis_comment_clear -; -vorbis_block_init -vorbis_block_clear -vorbis_dsp_clear -vorbis_granule_time -; -vorbis_analysis_init -vorbis_commentheader_out -vorbis_analysis_headerout -vorbis_analysis_buffer -vorbis_analysis_wrote -vorbis_analysis_blockout -vorbis_analysis -vorbis_bitrate_addblock -vorbis_bitrate_flushpacket -; -vorbis_synthesis_headerin -vorbis_synthesis_init -vorbis_synthesis_restart -vorbis_synthesis -vorbis_synthesis_trackonly -vorbis_synthesis_blockin -vorbis_synthesis_pcmout -vorbis_synthesis_lapout -vorbis_synthesis_read -vorbis_packet_blocksize -vorbis_synthesis_halfrate -vorbis_synthesis_halfrate_p -vorbis_synthesis_idheader -; -vorbis_window -;_analysis_output_always -vorbis_encode_init -vorbis_encode_setup_managed -vorbis_encode_setup_vbr -vorbis_encode_init_vbr -vorbis_encode_setup_init -vorbis_encode_ctl -; -vorbis_version_string diff --git a/Engine/lib/libvorbis/win32/vorbisenc.def b/Engine/lib/libvorbis/win32/vorbisenc.def deleted file mode 100644 index 79af06440..000000000 --- a/Engine/lib/libvorbis/win32/vorbisenc.def +++ /dev/null @@ -1,12 +0,0 @@ -; vorbisenc.def -; -LIBRARY - -EXPORTS -vorbis_encode_init -vorbis_encode_setup_managed -vorbis_encode_setup_vbr -vorbis_encode_init_vbr -vorbis_encode_setup_init -vorbis_encode_ctl - diff --git a/Engine/lib/libvorbis/win32/vorbisfile.def b/Engine/lib/libvorbis/win32/vorbisfile.def deleted file mode 100644 index 4dc554962..000000000 --- a/Engine/lib/libvorbis/win32/vorbisfile.def +++ /dev/null @@ -1,39 +0,0 @@ -; vorbisfile.def -; -LIBRARY -EXPORTS -ov_clear -ov_open -ov_open_callbacks -ov_bitrate -ov_bitrate_instant -ov_streams -ov_seekable -ov_serialnumber -ov_raw_total -ov_pcm_total -ov_time_total -ov_raw_seek -ov_pcm_seek -ov_pcm_seek_page -ov_time_seek -ov_time_seek_page -ov_raw_seek_lap -ov_pcm_seek_lap -ov_pcm_seek_page_lap -ov_time_seek_lap -ov_time_seek_page_lap -ov_raw_tell -ov_pcm_tell -ov_time_tell -ov_info -ov_comment -ov_read -ov_read_float -ov_test -ov_test_callbacks -ov_test_open -ov_crosslap -ov_halfrate -ov_halfrate_p -ov_fopen diff --git a/Engine/lib/opus/.appveyor.yml b/Engine/lib/opus/.appveyor.yml deleted file mode 100644 index a0f4a776e..000000000 --- a/Engine/lib/opus/.appveyor.yml +++ /dev/null @@ -1,37 +0,0 @@ -image: Visual Studio 2015 -configuration: -- Debug -- DebugDLL -- DebugDLL_fixed -- Release -- ReleaseDLL -- ReleaseDLL_fixed - -platform: -- Win32 -- x64 - -environment: - api_key: - secure: kR3Ac0NjGwFnTmXdFrR8d6VXjdk5F7L4F/BilC4nvaM= - -build: - project: win32\VS2015\opus.sln - parallel: true - verbosity: minimal - -after_build: -- cd %APPVEYOR_BUILD_FOLDER% -- 7z a opus.zip win32\VS2015\%PLATFORM%\%CONFIGURATION%\opus.??? include\*.h - -test_script: -- cd %APPVEYOR_BUILD_FOLDER%\win32\VS2015\%PLATFORM%\%CONFIGURATION% -- test_opus_api.exe -- test_opus_decode.exe -- test_opus_encode.exe - -artifacts: -- path: opus.zip - -on_success: -- ps: if ($env:api_key -and "$env:configuration/$env:platform" -eq "ReleaseDLL_fixed/x64") { Start-AppveyorBuild -ApiKey $env:api_key -ProjectSlug 'opus-tools' } diff --git a/Engine/lib/opus/.gitlab-ci.yml b/Engine/lib/opus/.gitlab-ci.yml deleted file mode 100644 index 01b033fda..000000000 --- a/Engine/lib/opus/.gitlab-ci.yml +++ /dev/null @@ -1,61 +0,0 @@ -include: - - template: 'Workflows/Branch-Pipelines.gitlab-ci.yml' - -default: - tags: - - docker - # Image from https://hub.docker.com/_/gcc/ based on Debian - image: gcc:9 - -whitespace: - stage: test - script: - - git diff-tree --check origin/master HEAD - -autoconf: - stage: build - before_script: - - apt-get update && - apt-get install -y zip doxygen - script: - - ./autogen.sh - - ./configure - - make -j4 - - make distcheck - cache: - paths: - - "src/*.o" - - "src/.libs/*.o" - - "silk/*.o" - - "silk/.libs/*.o" - - "celt/*.o" - - "celt/.libs/*.o" - -cmake: - stage: build - before_script: - - apt-get update && - apt-get install -y cmake ninja-build - script: - - mkdir build - - cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DOPUS_BUILD_TESTING=ON -DOPUS_BUILD_PROGRAMS=ON - - cmake --build build - - cd build && ctest --output-on-failure - -meson: - stage: build - before_script: - - apt-get update && - apt-get install -y python3-pip ninja-build doxygen - - export XDG_CACHE_HOME=$PWD/pip-cache - - pip3 install --user meson - script: - - export PATH=$PATH:$HOME/.local/bin - - mkdir builddir - - meson setup --werror -Dtests=enabled -Ddocs=enabled -Dbuildtype=release builddir - - meson compile -C builddir - - meson test -C builddir - #- meson dist --no-tests -C builddir - cache: - paths: - - 'pip-cache/*' diff --git a/Engine/lib/opus/.travis.yml b/Engine/lib/opus/.travis.yml deleted file mode 100644 index 821c813ec..000000000 --- a/Engine/lib/opus/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: c - -compiler: - - gcc - - clang - -os: - - linux - - osx - -env: - - CONFIG="" - - CONFIG="--enable-assertions" - - CONFIG="--enable-fixed-point" - - CONFIG="--enable-fixed-point --disable-float-api" - - CONFIG="--enable-fixed-point --enable-assertions" - -script: - - ./autogen.sh - - ./configure $CONFIG - - make distcheck diff --git a/Engine/lib/opus/AUTHORS b/Engine/lib/opus/AUTHORS deleted file mode 100644 index b3d22a20c..000000000 --- a/Engine/lib/opus/AUTHORS +++ /dev/null @@ -1,6 +0,0 @@ -Jean-Marc Valin (jmvalin@jmvalin.ca) -Koen Vos (koenvos74@gmail.com) -Timothy Terriberry (tterribe@xiph.org) -Karsten Vandborg Sorensen (karsten.vandborg.sorensen@skype.net) -Soren Skak Jensen (ssjensen@gn.com) -Gregory Maxwell (greg@xiph.org) diff --git a/Engine/lib/opus/CMakeLists.txt b/Engine/lib/opus/CMakeLists.txt deleted file mode 100644 index 60720e5ba..000000000 --- a/Engine/lib/opus/CMakeLists.txt +++ /dev/null @@ -1,646 +0,0 @@ -cmake_minimum_required(VERSION 3.6) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -include(OpusPackageVersion) -get_package_version(PACKAGE_VERSION PROJECT_VERSION) - -project(Opus LANGUAGES C VERSION ${PROJECT_VERSION}) - -include(OpusFunctions) -include(OpusBuildtype) -include(OpusConfig) -include(OpusSources) -include(GNUInstallDirs) -include(CMakeDependentOption) -include(FeatureSummary) - -set(OPUS_BUILD_SHARED_LIBRARY_HELP_STR "build shared library.") -option(OPUS_BUILD_SHARED_LIBRARY ${OPUS_BUILD_SHARED_LIBRARY_HELP_STR} OFF) -if(OPUS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS OR OPUS_BUILD_FRAMEWORK) - # Global flag to cause add_library() to create shared libraries if on. - set(BUILD_SHARED_LIBS ON) - set(OPUS_BUILD_SHARED_LIBRARY ON) -endif() -add_feature_info(OPUS_BUILD_SHARED_LIBRARY OPUS_BUILD_SHARED_LIBRARY ${OPUS_BUILD_SHARED_LIBRARY_HELP_STR}) - -set(OPUS_BUILD_TESTING_HELP_STR "build tests.") -option(OPUS_BUILD_TESTING ${OPUS_BUILD_TESTING_HELP_STR} OFF) -if(OPUS_BUILD_TESTING OR BUILD_TESTING) - set(OPUS_BUILD_TESTING ON) - set(BUILD_TESTING ON) -endif() -add_feature_info(OPUS_BUILD_TESTING OPUS_BUILD_TESTING ${OPUS_BUILD_TESTING_HELP_STR}) - -set(OPUS_CUSTOM_MODES_HELP_STR "enable non-Opus modes, e.g. 44.1 kHz & 2^n frames.") -option(OPUS_CUSTOM_MODES ${OPUS_CUSTOM_MODES_HELP_STR} OFF) -add_feature_info(OPUS_CUSTOM_MODES OPUS_CUSTOM_MODES ${OPUS_CUSTOM_MODES_HELP_STR}) - -set(OPUS_BUILD_PROGRAMS_HELP_STR "build programs.") -option(OPUS_BUILD_PROGRAMS ${OPUS_BUILD_PROGRAMS_HELP_STR} OFF) -add_feature_info(OPUS_BUILD_PROGRAMS OPUS_BUILD_PROGRAMS ${OPUS_BUILD_PROGRAMS_HELP_STR}) - -set(OPUS_DISABLE_INTRINSICS_HELP_STR "disable all intrinsics optimizations.") -option(OPUS_DISABLE_INTRINSICS ${OPUS_DISABLE_INTRINSICS_HELP_STR} OFF) -add_feature_info(OPUS_DISABLE_INTRINSICS OPUS_DISABLE_INTRINSICS ${OPUS_DISABLE_INTRINSICS_HELP_STR}) - -set(OPUS_FIXED_POINT_HELP_STR "compile as fixed-point (for machines without a fast enough FPU).") -option(OPUS_FIXED_POINT ${OPUS_FIXED_POINT_HELP_STR} OFF) -add_feature_info(OPUS_FIXED_POINT OPUS_FIXED_POINT ${OPUS_FIXED_POINT_HELP_STR}) - -set(OPUS_ENABLE_FLOAT_API_HELP_STR "compile with the floating point API (for machines with float library).") -option(OPUS_ENABLE_FLOAT_API ${OPUS_ENABLE_FLOAT_API_HELP_STR} ON) -add_feature_info(OPUS_ENABLE_FLOAT_API OPUS_ENABLE_FLOAT_API ${OPUS_ENABLE_FLOAT_API_HELP_STR}) - -set(OPUS_FLOAT_APPROX_HELP_STR "enable floating point approximations (Ensure your platform supports IEEE 754 before enabling).") -option(OPUS_FLOAT_APPROX ${OPUS_FLOAT_APPROX_HELP_STR} OFF) -add_feature_info(OPUS_FLOAT_APPROX OPUS_FLOAT_APPROX ${OPUS_FLOAT_APPROX_HELP_STR}) - -set(OPUS_ASSERTIONS_HELP_STR "additional software error checking.") -option(OPUS_ASSERTIONS ${OPUS_ASSERTIONS_HELP_STR} OFF) -add_feature_info(OPUS_ASSERTIONS OPUS_ASSERTIONS ${OPUS_ASSERTIONS_HELP_STR}) - -set(OPUS_HARDENING_HELP_STR "run-time checks that are cheap and safe for use in production.") -option(OPUS_HARDENING ${OPUS_HARDENING_HELP_STR} ON) -add_feature_info(OPUS_HARDENING OPUS_HARDENING ${OPUS_HARDENING_HELP_STR}) - -set(OPUS_FUZZING_HELP_STR "causes the encoder to make random decisions (do not use in production).") -option(OPUS_FUZZING ${OPUS_FUZZING_HELP_STR} OFF) -add_feature_info(OPUS_FUZZING OPUS_FUZZING ${OPUS_FUZZING_HELP_STR}) - -set(OPUS_CHECK_ASM_HELP_STR "enable bit-exactness checks between optimized and c implementations.") -option(OPUS_CHECK_ASM ${OPUS_CHECK_ASM_HELP_STR} OFF) -add_feature_info(OPUS_CHECK_ASM OPUS_CHECK_ASM ${OPUS_CHECK_ASM_HELP_STR}) - -set(OPUS_INSTALL_PKG_CONFIG_MODULE_HELP_STR "install pkg-config module.") -option(OPUS_INSTALL_PKG_CONFIG_MODULE ${OPUS_INSTALL_PKG_CONFIG_MODULE_HELP_STR} ON) -add_feature_info(OPUS_INSTALL_PKG_CONFIG_MODULE OPUS_INSTALL_PKG_CONFIG_MODULE ${OPUS_INSTALL_PKG_CONFIG_MODULE_HELP_STR}) - -set(OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR "install CMake package config module.") -option(OPUS_INSTALL_CMAKE_CONFIG_MODULE ${OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR} ON) -add_feature_info(OPUS_INSTALL_CMAKE_CONFIG_MODULE OPUS_INSTALL_CMAKE_CONFIG_MODULE ${OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR}) - -if(APPLE) - set(OPUS_BUILD_FRAMEWORK_HELP_STR "build Framework bundle for Apple systems.") - option(OPUS_BUILD_FRAMEWORK ${OPUS_BUILD_FRAMEWORK_HELP_STR} OFF) - add_feature_info(OPUS_BUILD_FRAMEWORK OPUS_BUILD_FRAMEWORK ${OPUS_BUILD_FRAMEWORK_HELP_STR}) -endif() - -set(OPUS_FIXED_POINT_DEBUG_HELP_STR "debug fixed-point implementation.") -cmake_dependent_option(OPUS_FIXED_POINT_DEBUG - ${OPUS_FIXED_POINT_DEBUG_HELP_STR} - ON - "OPUS_FIXED_POINT; OPUS_FIXED_POINT_DEBUG" - OFF) -add_feature_info(OPUS_FIXED_POINT_DEBUG OPUS_FIXED_POINT_DEBUG ${OPUS_FIXED_POINT_DEBUG_HELP_STR}) - -set(OPUS_VAR_ARRAYS_HELP_STR "use variable length arrays for stack arrays.") -cmake_dependent_option(OPUS_VAR_ARRAYS - ${OPUS_VAR_ARRAYS_HELP_STR} - ON - "VLA_SUPPORTED; NOT OPUS_USE_ALLOCA; NOT OPUS_NONTHREADSAFE_PSEUDOSTACK" - OFF) -add_feature_info(OPUS_VAR_ARRAYS OPUS_VAR_ARRAYS ${OPUS_VAR_ARRAYS_HELP_STR}) - -set(OPUS_USE_ALLOCA_HELP_STR "use alloca for stack arrays (on non-C99 compilers).") -cmake_dependent_option(OPUS_USE_ALLOCA - ${OPUS_USE_ALLOCA_HELP_STR} - ON - "USE_ALLOCA_SUPPORTED; NOT OPUS_VAR_ARRAYS; NOT OPUS_NONTHREADSAFE_PSEUDOSTACK" - OFF) -add_feature_info(OPUS_USE_ALLOCA OPUS_USE_ALLOCA ${OPUS_USE_ALLOCA_HELP_STR}) - -set(OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR "use a non threadsafe pseudostack when neither variable length arrays or alloca is supported.") -cmake_dependent_option(OPUS_NONTHREADSAFE_PSEUDOSTACK - ${OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR} - ON - "NOT OPUS_VAR_ARRAYS; NOT OPUS_USE_ALLOCA" - OFF) -add_feature_info(OPUS_NONTHREADSAFE_PSEUDOSTACK OPUS_NONTHREADSAFE_PSEUDOSTACK ${OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR}) - -set(OPUS_FAST_MATH_HELP_STR "enable fast math (unsupported and discouraged use, as code is not well tested with this build option).") -cmake_dependent_option(OPUS_FAST_MATH - ${OPUS_FAST_MATH_HELP_STR} - ON - "OPUS_FLOAT_APPROX; OPUS_FAST_MATH; FAST_MATH_SUPPORTED" - OFF) -add_feature_info(OPUS_FAST_MATH OPUS_FAST_MATH ${OPUS_FAST_MATH_HELP_STR}) - -set(OPUS_STACK_PROTECTOR_HELP_STR "use stack protection.") -cmake_dependent_option(OPUS_STACK_PROTECTOR - ${OPUS_STACK_PROTECTOR_HELP_STR} - ON - "STACK_PROTECTOR_SUPPORTED" - OFF) -add_feature_info(OPUS_STACK_PROTECTOR OPUS_STACK_PROTECTOR ${OPUS_STACK_PROTECTOR_HELP_STR}) - -if(NOT MSVC) - set(OPUS_FORTIFY_SOURCE_HELP_STR "add protection against buffer overflows.") - cmake_dependent_option(OPUS_FORTIFY_SOURCE - ${OPUS_FORTIFY_SOURCE_HELP_STR} - ON - "FORTIFY_SOURCE_SUPPORTED" - OFF) - add_feature_info(OPUS_FORTIFY_SOURCE OPUS_FORTIFY_SOURCE ${OPUS_FORTIFY_SOURCE_HELP_STR}) -endif() - -if(MINGW AND (OPUS_FORTIFY_SOURCE OR OPUS_STACK_PROTECTOR)) - # ssp lib is needed for security features for MINGW - list(APPEND OPUS_REQUIRED_LIBRARIES ssp) -endif() - -if(OPUS_CPU_X86 OR OPUS_CPU_X64) - set(OPUS_X86_MAY_HAVE_SSE_HELP_STR "does runtime check for SSE1 support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE - ${OPUS_X86_MAY_HAVE_SSE_HELP_STR} - ON - "SSE1_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" - OFF) - add_feature_info(OPUS_X86_MAY_HAVE_SSE OPUS_X86_MAY_HAVE_SSE ${OPUS_X86_MAY_HAVE_SSE_HELP_STR}) - - set(OPUS_X86_MAY_HAVE_SSE2_HELP_STR "does runtime check for SSE2 support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE2 - ${OPUS_X86_MAY_HAVE_SSE2_HELP_STR} - ON - "SSE2_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" - OFF) - add_feature_info(OPUS_X86_MAY_HAVE_SSE2 OPUS_X86_MAY_HAVE_SSE2 ${OPUS_X86_MAY_HAVE_SSE2_HELP_STR}) - - set(OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR "does runtime check for SSE4.1 support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE4_1 - ${OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR} - ON - "SSE4_1_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" - OFF) - add_feature_info(OPUS_X86_MAY_HAVE_SSE4_1 OPUS_X86_MAY_HAVE_SSE4_1 ${OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR}) - - set(OPUS_X86_MAY_HAVE_AVX_HELP_STR "does runtime check for AVX support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_AVX - ${OPUS_X86_MAY_HAVE_AVX_HELP_STR} - ON - "AVX_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" - OFF) - add_feature_info(OPUS_X86_MAY_HAVE_AVX OPUS_X86_MAY_HAVE_AVX ${OPUS_X86_MAY_HAVE_AVX_HELP_STR}) - - # PRESUME depends on MAY HAVE, but PRESUME will override runtime detection - set(OPUS_X86_PRESUME_SSE_HELP_STR "assume target CPU has SSE1 support (override runtime check).") - set(OPUS_X86_PRESUME_SSE2_HELP_STR "assume target CPU has SSE2 support (override runtime check).") - if(OPUS_CPU_X64) # Assume x86_64 has up to SSE2 support - cmake_dependent_option(OPUS_X86_PRESUME_SSE - ${OPUS_X86_PRESUME_SSE_HELP_STR} - ON - "OPUS_X86_MAY_HAVE_SSE; NOT OPUS_DISABLE_INTRINSICS" - OFF) - - cmake_dependent_option(OPUS_X86_PRESUME_SSE2 - ${OPUS_X86_PRESUME_SSE2_HELP_STR} - ON - "OPUS_X86_MAY_HAVE_SSE2; NOT OPUS_DISABLE_INTRINSICS" - OFF) - else() - cmake_dependent_option(OPUS_X86_PRESUME_SSE - ${OPUS_X86_PRESUME_SSE_HELP_STR} - OFF - "OPUS_X86_MAY_HAVE_SSE; NOT OPUS_DISABLE_INTRINSICS" - OFF) - - cmake_dependent_option(OPUS_X86_PRESUME_SSE2 - ${OPUS_X86_PRESUME_SSE2_HELP_STR} - OFF - "OPUS_X86_MAY_HAVE_SSE2; NOT OPUS_DISABLE_INTRINSICS" - OFF) - endif() - add_feature_info(OPUS_X86_PRESUME_SSE OPUS_X86_PRESUME_SSE ${OPUS_X86_PRESUME_SSE_HELP_STR}) - add_feature_info(OPUS_X86_PRESUME_SSE2 OPUS_X86_PRESUME_SSE2 ${OPUS_X86_PRESUME_SSE2_HELP_STR}) - - set(OPUS_X86_PRESUME_SSE4_1_HELP_STR "assume target CPU has SSE4.1 support (override runtime check).") - cmake_dependent_option(OPUS_X86_PRESUME_SSE4_1 - ${OPUS_X86_PRESUME_SSE4_1_HELP_STR} - OFF - "OPUS_X86_MAY_HAVE_SSE4_1; NOT OPUS_DISABLE_INTRINSICS" - OFF) - add_feature_info(OPUS_X86_PRESUME_SSE4_1 OPUS_X86_PRESUME_SSE4_1 ${OPUS_X86_PRESUME_SSE4_1_HELP_STR}) - - set(OPUS_X86_PRESUME_AVX_HELP_STR "assume target CPU has AVX support (override runtime check).") - cmake_dependent_option(OPUS_X86_PRESUME_AVX - ${OPUS_X86_PRESUME_AVX_HELP_STR} - OFF - "OPUS_X86_MAY_HAVE_AVX; NOT OPUS_DISABLE_INTRINSICS" - OFF) - add_feature_info(OPUS_X86_PRESUME_AVX OPUS_X86_PRESUME_AVX ${OPUS_X86_PRESUME_AVX_HELP_STR}) -endif() - -feature_summary(WHAT ALL) - -set_package_properties(Git - PROPERTIES - TYPE - REQUIRED - DESCRIPTION - "fast, scalable, distributed revision control system" - URL - "https://git-scm.com/" - 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) - -if(OPUS_CUSTOM_MODES) - list(APPEND Opus_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_custom.h) -endif() - -add_library(opus ${opus_headers} ${opus_sources} ${opus_sources_float} ${Opus_PUBLIC_HEADER}) -add_library(Opus::opus ALIAS opus) - -get_library_version(OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR) -message(DEBUG "Opus library version: ${OPUS_LIBRARY_VERSION}") - -set_target_properties(opus - PROPERTIES SOVERSION - ${OPUS_LIBRARY_VERSION_MAJOR} - VERSION - ${OPUS_LIBRARY_VERSION} - PUBLIC_HEADER - "${Opus_PUBLIC_HEADER}") - -target_include_directories( - opus - PUBLIC $ - $ - $ - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - celt - silk) - -target_link_libraries(opus PRIVATE ${OPUS_REQUIRED_LIBRARIES}) -target_compile_definitions(opus PRIVATE OPUS_BUILD) - -if(OPUS_FIXED_POINT_DEBUG) - target_compile_definitions(opus PRIVATE FIXED_DEBUG) -endif() - -if(OPUS_FORTIFY_SOURCE AND NOT MSVC) - target_compile_definitions(opus PRIVATE - $<$>:_FORTIFY_SOURCE=2>) -endif() - -if(OPUS_FLOAT_APPROX) - target_compile_definitions(opus PRIVATE FLOAT_APPROX) -endif() - -if(OPUS_ASSERTIONS) - target_compile_definitions(opus PRIVATE ENABLE_ASSERTIONS) -endif() - -if(OPUS_HARDENING) - target_compile_definitions(opus PRIVATE ENABLE_HARDENING) -endif() - -if(OPUS_FUZZING) - target_compile_definitions(opus PRIVATE FUZZING) -endif() - -if(OPUS_CHECK_ASM) - target_compile_definitions(opus PRIVATE OPUS_CHECK_ASM) -endif() - -if(OPUS_VAR_ARRAYS) - target_compile_definitions(opus PRIVATE VAR_ARRAYS) -elseif(OPUS_USE_ALLOCA) - target_compile_definitions(opus PRIVATE USE_ALLOCA) -elseif(OPUS_NONTHREADSAFE_PSEUDOSTACK) - target_compile_definitions(opus PRIVATE NONTHREADSAFE_PSEUDOSTACK) -else() - message(ERROR "Need to set a define for stack allocation") -endif() - -if(OPUS_CUSTOM_MODES) - target_compile_definitions(opus PRIVATE CUSTOM_MODES) -endif() - -if(OPUS_FAST_MATH) - if(MSVC) - target_compile_options(opus PRIVATE /fp:fast) - else() - target_compile_options(opus PRIVATE -ffast-math) - endif() -endif() - -if(OPUS_STACK_PROTECTOR) - if(MSVC) - target_compile_options(opus PRIVATE /GS) - else() - target_compile_options(opus PRIVATE -fstack-protector-strong) - endif() -elseif(STACK_PROTECTOR_DISABLED_SUPPORTED) - target_compile_options(opus PRIVATE /GS-) -endif() - -if(BUILD_SHARED_LIBS) - if(WIN32) - target_compile_definitions(opus PRIVATE DLL_EXPORT) - elseif(HIDDEN_VISIBILITY_SUPPORTED) - set_target_properties(opus PROPERTIES C_VISIBILITY_PRESET hidden) - endif() -endif() - -add_sources_group(opus silk ${silk_headers} ${silk_sources}) -add_sources_group(opus celt ${celt_headers} ${celt_sources}) - -if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed}) - target_include_directories(opus PRIVATE silk/fixed) - target_compile_definitions(opus PRIVATE FIXED_POINT=1) -else() - add_sources_group(opus silk ${silk_sources_float}) - target_include_directories(opus PRIVATE silk/float) -endif() - -if(NOT OPUS_ENABLE_FLOAT_API) - target_compile_definitions(opus PRIVATE DISABLE_FLOAT_API) -endif() - -if(NOT OPUS_DISABLE_INTRINSICS) - if(((OPUS_X86_MAY_HAVE_SSE AND NOT OPUS_X86_PRESUME_SSE) OR - (OPUS_X86_MAY_HAVE_SSE2 AND NOT OPUS_X86_PRESUME_SSE2) OR - (OPUS_X86_MAY_HAVE_SSE4_1 AND NOT OPUS_X86_PRESUME_SSE4_1) OR - (OPUS_X86_MAY_HAVE_AVX AND NOT OPUS_X86_PRESUME_AVX)) AND - RUNTIME_CPU_CAPABILITY_DETECTION) - target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) - if(NOT MSVC) - if(CPU_INFO_BY_ASM_SUPPORTED) - target_compile_definitions(opus PRIVATE CPU_INFO_BY_ASM) - elseif(CPU_INFO_BY_C_SUPPORTED) - target_compile_definitions(opus PRIVATE CPU_INFO_BY_C) - else() - message(ERROR "Runtime cpu capability detection is enabled while CPU_INFO is not supported") - endif() - endif() - add_sources_group(opus celt ${celt_sources_x86_rtcd}) - add_sources_group(opus silk ${silk_sources_x86_rtcd}) - endif() - - if(SSE1_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE) - add_sources_group(opus celt ${celt_sources_sse}) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE) - if(NOT MSVC) - set_source_files_properties(${celt_sources_sse} PROPERTIES COMPILE_FLAGS -msse) - endif() - endif() - if(OPUS_X86_PRESUME_SSE) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE) - if(NOT MSVC) - target_compile_options(opus PRIVATE -msse) - endif() - endif() - endif() - - if(SSE2_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE2) - add_sources_group(opus celt ${celt_sources_sse2}) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE2) - if(NOT MSVC) - set_source_files_properties(${celt_sources_sse2} PROPERTIES COMPILE_FLAGS -msse2) - endif() - endif() - if(OPUS_X86_PRESUME_SSE2) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE2) - if(NOT MSVC) - target_compile_options(opus PRIVATE -msse2) - endif() - endif() - endif() - - if(SSE4_1_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE4_1) - add_sources_group(opus celt ${celt_sources_sse4_1}) - add_sources_group(opus silk ${silk_sources_sse4_1}) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE4_1) - if(NOT MSVC) - set_source_files_properties(${celt_sources_sse4_1} ${silk_sources_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) - endif() - - if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed_sse4_1}) - if(NOT MSVC) - set_source_files_properties(${silk_sources_fixed_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) - endif() - endif() - endif() - if(OPUS_X86_PRESUME_SSE4_1) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE4_1) - if(NOT MSVC) - target_compile_options(opus PRIVATE -msse4.1) - endif() - endif() - endif() - - if(AVX_SUPPORTED) - # mostly placeholder in case of avx intrinsics is added - if(OPUS_X86_MAY_HAVE_AVX) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_AVX) - endif() - if(OPUS_X86_PRESUME_AVX) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_AVX) - if(NOT MSVC) - target_compile_options(opus PRIVATE -mavx) - endif() - endif() - endif() - - if(MSVC) - if(AVX_SUPPORTED AND OPUS_X86_PRESUME_AVX) # on 64 bit and 32 bits - add_definitions(/arch:AVX) - elseif(OPUS_CPU_X86) # if AVX not supported then set SSE flag - if((SSE4_1_SUPPORTED AND OPUS_X86_PRESUME_SSE4_1) - OR (SSE2_SUPPORTED AND OPUS_X86_PRESUME_SSE2)) - target_compile_definitions(opus PRIVATE /arch:SSE2) - elseif(SSE1_SUPPORTED AND OPUS_X86_PRESUME_SSE) - target_compile_definitions(opus PRIVATE /arch:SSE) - endif() - endif() - endif() - - if(COMPILER_SUPPORT_NEON) - if(OPUS_MAY_HAVE_NEON) - if(RUNTIME_CPU_CAPABILITY_DETECTION) - message(STATUS "OPUS_MAY_HAVE_NEON enabling runtime detection") - target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) - add_sources_group(opus celt ${celt_sources_arm_rtcd}) - add_sources_group(opus silk ${silk_sources_arm_rtcd}) - else() - message(ERROR "Runtime cpu capability detection needed for MAY_HAVE_NEON") - endif() - # Do runtime check for NEON - target_compile_definitions(opus - PRIVATE - OPUS_ARM_MAY_HAVE_NEON - OPUS_ARM_MAY_HAVE_NEON_INTR) - endif() - - add_sources_group(opus celt ${celt_sources_arm_neon_intr}) - add_sources_group(opus silk ${silk_sources_arm_neon_intr}) - - # silk arm neon depends on main_Fix.h - target_include_directories(opus PRIVATE silk/fixed) - - if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed_arm_neon_intr}) - endif() - - if(OPUS_PRESUME_NEON) - target_compile_definitions(opus - PRIVATE - OPUS_ARM_PRESUME_NEON - OPUS_ARM_PRESUME_NEON_INTR) - endif() - endif() -endif() - -target_compile_definitions(opus - PRIVATE - $<$:HAVE_LRINT> - $<$:HAVE_LRINTF>) - -if(OPUS_BUILD_FRAMEWORK) - set_target_properties(opus PROPERTIES - FRAMEWORK TRUE - FRAMEWORK_VERSION ${PROJECT_VERSION} - MACOSX_FRAMEWORK_IDENTIFIER org.xiph.opus - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} - MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION} - XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" - OUTPUT_NAME Opus) -endif() - -install(TARGETS opus - EXPORT OpusTargets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/opus) - -if(OPUS_INSTALL_PKG_CONFIG_MODULE) - set(prefix ${CMAKE_INSTALL_PREFIX}) - set(exec_prefix ${CMAKE_INSTALL_PREFIX}) - set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) - set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) - set(VERSION ${PACKAGE_VERSION}) - if(HAVE_LIBM) - set(LIBM "-lm") - endif() - configure_file(opus.pc.in opus.pc) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/opus.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -endif() - -if(OPUS_INSTALL_CMAKE_CONFIG_MODULE) - set(CPACK_GENERATOR TGZ) - include(CPack) - set(CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) - install(EXPORT OpusTargets - NAMESPACE Opus:: - 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 - INSTALL_DESTINATION - ${CMAKE_INSTALL_PACKAGEDIR} - PATH_VARS - INCLUDE_INSTALL_DIR - INSTALL_PREFIX - ${CMAKE_INSTALL_PREFIX}) - write_basic_package_version_file(OpusConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpusConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/OpusConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) -endif() - -if(OPUS_BUILD_PROGRAMS) - # demo - if(OPUS_CUSTOM_MODES) - add_executable(opus_custom_demo ${opus_custom_demo_sources}) - target_include_directories(opus_custom_demo - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(opus_custom_demo PRIVATE opus) - target_compile_definitions(opus_custom_demo PRIVATE OPUS_BUILD) - endif() - - add_executable(opus_demo ${opus_demo_sources}) - target_include_directories(opus_demo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_include_directories(opus_demo PRIVATE silk) # debug.h - target_include_directories(opus_demo PRIVATE celt) # arch.h - target_link_libraries(opus_demo PRIVATE opus ${OPUS_REQUIRED_LIBRARIES}) - target_compile_definitions(opus_demo PRIVATE OPUS_BUILD) - - # compare - add_executable(opus_compare ${opus_compare_sources}) - target_include_directories(opus_compare PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(opus_compare PRIVATE opus ${OPUS_REQUIRED_LIBRARIES}) - if(MSVC) - # move cosmetic warning to level 4 for opus_compare - target_compile_options(opus_compare PRIVATE /w44244) - endif() -endif() - -if(BUILD_TESTING AND NOT BUILD_SHARED_LIBS) - enable_testing() - - # tests - add_executable(test_opus_decode ${test_opus_decode_sources}) - target_include_directories(test_opus_decode - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(test_opus_decode PRIVATE opus) - target_compile_definitions(test_opus_decode PRIVATE OPUS_BUILD) - if(OPUS_FIXED_POINT) - target_compile_definitions(test_opus_decode PRIVATE DISABLE_FLOAT_API) - endif() - add_test(NAME test_opus_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 - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(test_opus_padding PRIVATE opus) - add_test(NAME test_opus_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 - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt) - target_link_libraries(test_opus_api PRIVATE opus) - target_compile_definitions(test_opus_api PRIVATE OPUS_BUILD) - if(OPUS_FIXED_POINT) - target_compile_definitions(test_opus_api PRIVATE DISABLE_FLOAT_API) - endif() - add_test(NAME test_opus_api COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ - -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} - -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") - - add_executable(test_opus_encode ${test_opus_encode_sources}) - target_include_directories(test_opus_encode - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt) - target_link_libraries(test_opus_encode PRIVATE opus) - target_compile_definitions(test_opus_encode PRIVATE OPUS_BUILD) - add_test(NAME test_opus_encode COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ - -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} - -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") -endif() diff --git a/Engine/lib/opus/COPYING b/Engine/lib/opus/COPYING deleted file mode 100644 index 9c739c34a..000000000 --- a/Engine/lib/opus/COPYING +++ /dev/null @@ -1,44 +0,0 @@ -Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic, - Jean-Marc Valin, Timothy B. Terriberry, - CSIRO, Gregory Maxwell, Mark Borgerding, - Erik de Castro Lopo - -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. - -Opus is subject to the royalty-free patent licenses which are -specified at: - -Xiph.Org Foundation: -https://datatracker.ietf.org/ipr/1524/ - -Microsoft Corporation: -https://datatracker.ietf.org/ipr/1914/ - -Broadcom Corporation: -https://datatracker.ietf.org/ipr/1526/ diff --git a/Engine/lib/opus/ChangeLog b/Engine/lib/opus/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/Engine/lib/opus/LICENSE_PLEASE_READ.txt b/Engine/lib/opus/LICENSE_PLEASE_READ.txt deleted file mode 100644 index bc88efa6c..000000000 --- a/Engine/lib/opus/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/Engine/lib/opus/Makefile.am b/Engine/lib/opus/Makefile.am deleted file mode 100644 index 492fc09da..000000000 --- a/Engine/lib/opus/Makefile.am +++ /dev/null @@ -1,382 +0,0 @@ -# Provide the full test output for failed tests when using the parallel -# test suite (which is enabled by default with automake 1.13+). -export VERBOSE = yes - -AUTOMAKE_OPTIONS = subdir-objects -ACLOCAL_AMFLAGS = -I m4 - -lib_LTLIBRARIES = libopus.la - -DIST_SUBDIRS = doc - -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/celt -I$(top_srcdir)/silk \ - -I$(top_srcdir)/silk/float -I$(top_srcdir)/silk/fixed $(NE10_CFLAGS) - -include celt_sources.mk -include silk_sources.mk -include opus_sources.mk - -if FIXED_POINT -SILK_SOURCES += $(SILK_SOURCES_FIXED) -if HAVE_SSE4_1 -SILK_SOURCES += $(SILK_SOURCES_SSE4_1) $(SILK_SOURCES_FIXED_SSE4_1) -endif -if HAVE_ARM_NEON_INTR -SILK_SOURCES += $(SILK_SOURCES_FIXED_ARM_NEON_INTR) -endif -else -SILK_SOURCES += $(SILK_SOURCES_FLOAT) -if HAVE_SSE4_1 -SILK_SOURCES += $(SILK_SOURCES_SSE4_1) -endif -endif - -if DISABLE_FLOAT_API -else -OPUS_SOURCES += $(OPUS_SOURCES_FLOAT) -endif - -if CPU_X86 -if HAVE_RTCD -CELT_SOURCES += $(CELT_SOURCES_X86_RTCD) -SILK_SOURCES += $(SILK_SOURCES_X86_RTCD) -endif -if HAVE_SSE -CELT_SOURCES += $(CELT_SOURCES_SSE) -endif -if HAVE_SSE2 -CELT_SOURCES += $(CELT_SOURCES_SSE2) -endif -if HAVE_SSE4_1 -CELT_SOURCES += $(CELT_SOURCES_SSE4_1) -endif -endif - -if CPU_ARM -if HAVE_RTCD -CELT_SOURCES += $(CELT_SOURCES_ARM_RTCD) -SILK_SOURCES += $(SILK_SOURCES_ARM_RTCD) -endif - -if HAVE_ARM_NEON_INTR -CELT_SOURCES += $(CELT_SOURCES_ARM_NEON_INTR) -SILK_SOURCES += $(SILK_SOURCES_ARM_NEON_INTR) -endif - -if HAVE_ARM_NE10 -CELT_SOURCES += $(CELT_SOURCES_ARM_NE10) -endif - -if OPUS_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) \ - $(CELT_AM_SOURCES_ARM_ASM:.s.in=.s) \ - $(CELT_AM_SOURCES_ARM_ASM:.s.in=-gnu.S) -endif -endif - -CLEANFILES = $(CELT_SOURCES_ARM_ASM:.s=-gnu.S) \ - $(CELT_AM_SOURCES_ARM_ASM:.s.in=-gnu.S) - -include celt_headers.mk -include silk_headers.mk -include opus_headers.mk - -libopus_la_SOURCES = $(CELT_SOURCES) $(SILK_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 -endif - -pkginclude_HEADERS = include/opus.h include/opus_multistream.h include/opus_types.h include/opus_defines.h include/opus_projection.h - -noinst_HEADERS = $(OPUS_HEAD) $(SILK_HEAD) $(CELT_HEAD) - -if EXTRA_PROGRAMS -noinst_PROGRAMS = celt/tests/test_unit_cwrs32 \ - celt/tests/test_unit_dft \ - celt/tests/test_unit_entropy \ - celt/tests/test_unit_laplace \ - celt/tests/test_unit_mathops \ - celt/tests/test_unit_mdct \ - celt/tests/test_unit_rotation \ - celt/tests/test_unit_types \ - opus_compare \ - opus_demo \ - repacketizer_demo \ - silk/tests/test_unit_LPC_inv_pred_gain \ - tests/test_opus_api \ - tests/test_opus_decode \ - tests/test_opus_encode \ - tests/test_opus_padding \ - tests/test_opus_projection \ - trivial_example - -TESTS = celt/tests/test_unit_cwrs32 \ - celt/tests/test_unit_dft \ - celt/tests/test_unit_entropy \ - celt/tests/test_unit_laplace \ - celt/tests/test_unit_mathops \ - celt/tests/test_unit_mdct \ - 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_padding \ - tests/test_opus_projection - -opus_demo_SOURCES = src/opus_demo.c - -opus_demo_LDADD = libopus.la $(NE10_LIBS) $(LIBM) - -repacketizer_demo_SOURCES = src/repacketizer_demo.c - -repacketizer_demo_LDADD = libopus.la $(NE10_LIBS) $(LIBM) - -opus_compare_SOURCES = src/opus_compare.c -opus_compare_LDADD = $(LIBM) - -trivial_example_SOURCES = doc/trivial_example.c -trivial_example_LDADD = libopus.la $(LIBM) - -tests_test_opus_api_SOURCES = tests/test_opus_api.c tests/test_opus_common.h -tests_test_opus_api_LDADD = libopus.la $(NE10_LIBS) $(LIBM) - -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_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_opus_padding_SOURCES = tests/test_opus_padding.c tests/test_opus_common.h -tests_test_opus_padding_LDADD = libopus.la $(NE10_LIBS) $(LIBM) - -CELT_OBJ = $(CELT_SOURCES:.c=.lo) -SILK_OBJ = $(SILK_SOURCES:.c=.lo) -OPUS_OBJ = $(OPUS_SOURCES:.c=.lo) - -tests_test_opus_projection_SOURCES = tests/test_opus_projection.c tests/test_opus_common.h -tests_test_opus_projection_LDADD = $(OPUS_OBJ) $(SILK_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -tests_test_opus_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) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -silk_tests_test_unit_LPC_inv_pred_gain_LDADD += libarmasm.la -endif - -celt_tests_test_unit_cwrs32_SOURCES = celt/tests/test_unit_cwrs32.c -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) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -celt_tests_test_unit_dft_LDADD += libarmasm.la -endif - -celt_tests_test_unit_entropy_SOURCES = celt/tests/test_unit_entropy.c -celt_tests_test_unit_entropy_LDADD = $(LIBM) - -celt_tests_test_unit_laplace_SOURCES = celt/tests/test_unit_laplace.c -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) $(NE10_LIBS) $(LIBM) -if OPUS_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) $(NE10_LIBS) $(LIBM) -if OPUS_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) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -celt_tests_test_unit_rotation_LDADD += libarmasm.la -endif - -celt_tests_test_unit_types_SOURCES = celt/tests/test_unit_types.c -celt_tests_test_unit_types_LDADD = $(LIBM) -endif - -if CUSTOM_MODES -pkginclude_HEADERS += include/opus_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) -endif -endif - -EXTRA_DIST = opus.pc.in \ - opus-uninstalled.pc.in \ - opus.m4 \ - Makefile.mips \ - 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/RunTest.cmake \ - cmake/config.h.cmake.in \ - cmake/vla.c \ - cmake/cpu_info_by_asm.c \ - cmake/cpu_info_by_c.c \ - meson/get-version.py \ - meson/read-sources-list.py \ - meson.build \ - meson_options.txt \ - include/meson.build \ - celt/meson.build \ - celt/tests/meson.build \ - silk/meson.build \ - silk/tests/meson.build \ - src/meson.build \ - tests/meson.build \ - doc/meson.build \ - tests/run_vectors.sh \ - celt/arm/arm2gnu.pl \ - celt/arm/celt_pitch_xcorr_arm.s \ - win32/VS2015/opus.vcxproj \ - win32/VS2015/test_opus_encode.vcxproj.filters \ - win32/VS2015/test_opus_encode.vcxproj \ - win32/VS2015/opus_demo.vcxproj \ - win32/VS2015/test_opus_api.vcxproj.filters \ - win32/VS2015/test_opus_api.vcxproj \ - win32/VS2015/test_opus_decode.vcxproj.filters \ - win32/VS2015/opus_demo.vcxproj.filters \ - win32/VS2015/opus.vcxproj.filters \ - win32/VS2015/test_opus_decode.vcxproj \ - win32/VS2015/opus.sln \ - win32/VS2015/common.props \ - win32/genversion.bat \ - win32/config.h - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = opus.pc - -m4datadir = $(datadir)/aclocal -m4data_DATA = opus.m4 - -# Targets to build and install just the library without the docs -opus check-opus install-opus: export NO_DOXYGEN = 1 - -opus: all -check-opus: check -install-opus: install - - -# Or just the docs -docs: - ( cd doc && $(MAKE) $(AM_MAKEFLAGS) ) - -install-docs: - ( cd doc && $(MAKE) $(AM_MAKEFLAGS) install ) - - -# Or everything (by default) -all-local: - @[ -n "$(NO_DOXYGEN)" ] || ( cd doc && $(MAKE) $(AM_MAKEFLAGS) ) - -install-data-local: - @[ -n "$(NO_DOXYGEN)" ] || ( cd doc && $(MAKE) $(AM_MAKEFLAGS) install ) - -clean-local: - -( cd doc && $(MAKE) $(AM_MAKEFLAGS) clean ) - -uninstall-local: - ( cd doc && $(MAKE) $(AM_MAKEFLAGS) uninstall ) - - -# We check this every time make is run, with configure.ac being touched to -# trigger an update of the build system files if update_version changes the -# current PACKAGE_VERSION (or if package_version was modified manually by a -# user with either AUTO_UPDATE=no or no update_version script present - the -# latter being the normal case for tarball releases). -# -# We can't just add the package_version file to CONFIGURE_DEPENDENCIES since -# simply running autoconf will not actually regenerate configure for us when -# the content of that file changes (due to autoconf dependency checking not -# knowing about that without us creating yet another file for it to include). -# -# The MAKECMDGOALS check is a gnu-make'ism, but will degrade 'gracefully' for -# makes that don't support it. The only loss of functionality is not forcing -# an update of package_version for `make dist` if AUTO_UPDATE=no, but that is -# unlikely to be a real problem for any real user. -$(top_srcdir)/configure.ac: force - @case "$(MAKECMDGOALS)" in \ - dist-hook) exit 0 ;; \ - dist-* | dist | distcheck | distclean) _arg=release ;; \ - esac; \ - if ! $(top_srcdir)/update_version $$_arg 2> /dev/null; then \ - if [ ! -e $(top_srcdir)/package_version ]; then \ - echo 'PACKAGE_VERSION="unknown"' > $(top_srcdir)/package_version; \ - fi; \ - . $(top_srcdir)/package_version || exit 1; \ - [ "$(PACKAGE_VERSION)" != "$$PACKAGE_VERSION" ] || exit 0; \ - fi; \ - touch $@ - -force: - -# Create a minimal package_version file when make dist is run. -dist-hook: - echo 'PACKAGE_VERSION="$(PACKAGE_VERSION)"' > $(top_distdir)/package_version - - -.PHONY: opus check-opus install-opus 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 -$(CELT_SOURCES_ARM_ASM:%.s=%-gnu.S): $(top_srcdir)/celt/arm/arm2gnu.pl - -# convert ARM asm to GNU as format -%-gnu.S: $(top_srcdir)/%.s - $(top_srcdir)/celt/arm/arm2gnu.pl @ARM2GNU_PARAMS@ < $< > $@ -# For autoconf-modified sources (e.g., armopts.s) -%-gnu.S: %.s - $(top_srcdir)/celt/arm/arm2gnu.pl @ARM2GNU_PARAMS@ < $< > $@ - -OPT_UNIT_TEST_OBJ = $(celt_tests_test_unit_mathops_SOURCES:.c=.o) \ - $(celt_tests_test_unit_rotation_SOURCES:.c=.o) \ - $(celt_tests_test_unit_mdct_SOURCES:.c=.o) \ - $(celt_tests_test_unit_dft_SOURCES:.c=.o) \ - $(silk_tests_test_unit_LPC_inv_pred_gain_SOURCES:.c=.o) - -if HAVE_SSE -SSE_OBJ = $(CELT_SOURCES_SSE:.c=.lo) -$(SSE_OBJ): CFLAGS += $(OPUS_X86_SSE_CFLAGS) -endif - -if HAVE_SSE2 -SSE2_OBJ = $(CELT_SOURCES_SSE2:.c=.lo) -$(SSE2_OBJ): CFLAGS += $(OPUS_X86_SSE2_CFLAGS) -endif - -if HAVE_SSE4_1 -SSE4_1_OBJ = $(CELT_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) -endif - -if HAVE_ARM_NEON_INTR -ARM_NEON_INTR_OBJ = $(CELT_SOURCES_ARM_NEON_INTR:.c=.lo) \ - $(SILK_SOURCES_ARM_NEON_INTR:.c=.lo) \ - $(SILK_SOURCES_FIXED_ARM_NEON_INTR:.c=.lo) -$(ARM_NEON_INTR_OBJ): CFLAGS += \ - $(OPUS_ARM_NEON_INTR_CFLAGS) $(NE10_CFLAGS) -endif diff --git a/Engine/lib/opus/Makefile.mips b/Engine/lib/opus/Makefile.mips deleted file mode 100644 index e9bfc22e8..000000000 --- a/Engine/lib/opus/Makefile.mips +++ /dev/null @@ -1,161 +0,0 @@ -#################### COMPILE OPTIONS ####################### - -# Uncomment this for fixed-point build -FIXED_POINT=1 - -# It is strongly recommended to uncomment one of these -# VAR_ARRAYS: Use C99 variable-length arrays for stack allocation -# USE_ALLOCA: Use alloca() for stack allocation -# If none is defined, then the fallback is a non-threadsafe global array -CFLAGS := -DUSE_ALLOCA $(CFLAGS) -#CFLAGS := -DVAR_ARRAYS $(CFLAGS) - -# These options affect performance -# HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion -CFLAGS := -DHAVE_LRINTF $(CFLAGS) - -###################### END OF OPTIONS ###################### - --include package_version - -include silk_sources.mk -include celt_sources.mk -include opus_sources.mk - -ifdef FIXED_POINT -SILK_SOURCES += $(SILK_SOURCES_FIXED) -else -SILK_SOURCES += $(SILK_SOURCES_FLOAT) -OPUS_SOURCES += $(OPUS_SOURCES_FLOAT) -endif - -EXESUFFIX = -LIBPREFIX = lib -LIBSUFFIX = .a -OBJSUFFIX = .o - -CC = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX) -AR = $(TOOLCHAIN_PREFIX)ar -RANLIB = $(TOOLCHAIN_PREFIX)ranlib -CP = $(TOOLCHAIN_PREFIX)cp - -cppflags-from-defines = $(addprefix -D,$(1)) -cppflags-from-includes = $(addprefix -I,$(1)) -ldflags-from-ldlibdirs = $(addprefix -L,$(1)) -ldlibs-from-libs = $(addprefix -l,$(1)) - -WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow - -CFLAGS += -mips32r2 -mno-mips16 -std=gnu99 -O2 -g $(WARNINGS) -DENABLE_ASSERTIONS -DMIPSr1_ASM -DOPUS_BUILD -mdspr2 -march=74kc -mtune=74kc -mmt -mgp32 - -CINCLUDES = include silk celt - -ifdef FIXED_POINT -CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API -CINCLUDES += silk/fixed -else -CINCLUDES += silk/float -endif - - -LIBS = m - -LDLIBDIRS = ./ - -CFLAGS += $(call cppflags-from-defines,$(CDEFINES)) -CFLAGS += $(call cppflags-from-includes,$(CINCLUDES)) -LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS)) -LDLIBS += $(call ldlibs-from-libs,$(LIBS)) - -COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $< -LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS) -LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX) - -ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@ - -%$(OBJSUFFIX):%.c - $(COMPILE.c.cmdline) - -%$(OBJSUFFIX):%.cpp - $(COMPILE.cpp.cmdline) - -# Directives - - -# Variable definitions -LIB_NAME = opus -TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX) - -SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES) - -OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) - -OPUSDEMO_SRCS_C = src/opus_demo.c -OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C)) - -TESTOPUSAPI_SRCS_C = tests/test_opus_api.c -TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C)) - -TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c -TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C)) - -TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c tests/opus_encode_regressions.c -TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C)) - -TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c -TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C)) - -OPUSCOMPARE_SRCS_C = src/opus_compare.c -OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C)) - -TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_padding - -# Rules -all: lib opus_demo opus_compare $(TESTS) - -lib: $(TARGET) - -check: all - for test in $(TESTS); do ./$$test; done - -$(TARGET): $(OBJS) - $(ARCHIVE.cmdline) - -opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET) - $(LINK.o.cmdline) - -test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET) - $(LINK.o.cmdline) - -test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET) - $(LINK.o.cmdline) - -test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET) - $(LINK.o.cmdline) - -test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET) - $(LINK.o.cmdline) - -opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS) - $(LINK.o.cmdline) - -celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' -celt/celt.o: package_version - -package_version: force - @if [ -x ./update_version ]; then \ - ./update_version || true; \ - elif [ ! -e ./package_version ]; then \ - echo 'PACKAGE_VERSION="unknown"' > ./package_version; \ - fi - -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_padding$(EXESUFFIX) \ - $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS) $(TESTOPUSAPI_OBJS) \ - $(TESTOPUSDECODE_OBJS) $(TESTOPUSENCODE_OBJS) $(TESTOPUSPADDING_OBJS) - -.PHONY: all lib clean force check diff --git a/Engine/lib/opus/Makefile.unix b/Engine/lib/opus/Makefile.unix deleted file mode 100644 index 90a48f0cc..000000000 --- a/Engine/lib/opus/Makefile.unix +++ /dev/null @@ -1,159 +0,0 @@ -#################### COMPILE OPTIONS ####################### - -# Uncomment this for fixed-point build -#FIXED_POINT=1 - -# It is strongly recommended to uncomment one of these -# VAR_ARRAYS: Use C99 variable-length arrays for stack allocation -# USE_ALLOCA: Use alloca() for stack allocation -# If none is defined, then the fallback is a non-threadsafe global array -CFLAGS := -DUSE_ALLOCA $(CFLAGS) -#CFLAGS := -DVAR_ARRAYS $(CFLAGS) - -# These options affect performance -# HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion -#CFLAGS := -DHAVE_LRINTF $(CFLAGS) - -###################### END OF OPTIONS ###################### - --include package_version - -include silk_sources.mk -include celt_sources.mk -include opus_sources.mk - -ifdef FIXED_POINT -SILK_SOURCES += $(SILK_SOURCES_FIXED) -else -SILK_SOURCES += $(SILK_SOURCES_FLOAT) -OPUS_SOURCES += $(OPUS_SOURCES_FLOAT) -endif - -EXESUFFIX = -LIBPREFIX = lib -LIBSUFFIX = .a -OBJSUFFIX = .o - -CC = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX) -AR = $(TOOLCHAIN_PREFIX)ar -RANLIB = $(TOOLCHAIN_PREFIX)ranlib -CP = $(TOOLCHAIN_PREFIX)cp - -cppflags-from-defines = $(addprefix -D,$(1)) -cppflags-from-includes = $(addprefix -I,$(1)) -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 -CINCLUDES = include silk celt - -ifdef FIXED_POINT -CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API -CINCLUDES += silk/fixed -else -CINCLUDES += silk/float -endif - - -LIBS = m - -LDLIBDIRS = ./ - -CFLAGS += $(call cppflags-from-defines,$(CDEFINES)) -CFLAGS += $(call cppflags-from-includes,$(CINCLUDES)) -LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS)) -LDLIBS += $(call ldlibs-from-libs,$(LIBS)) - -COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $< -LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS) -LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX) - -ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@ - -%$(OBJSUFFIX):%.c - $(COMPILE.c.cmdline) - -%$(OBJSUFFIX):%.cpp - $(COMPILE.cpp.cmdline) - -# Directives - - -# Variable definitions -LIB_NAME = opus -TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX) - -SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES) - -OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) - -OPUSDEMO_SRCS_C = src/opus_demo.c -OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C)) - -TESTOPUSAPI_SRCS_C = tests/test_opus_api.c -TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C)) - -TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c -TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C)) - -TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c tests/opus_encode_regressions.c -TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C)) - -TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c -TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C)) - -OPUSCOMPARE_SRCS_C = src/opus_compare.c -OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C)) - -TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_padding - -# Rules -all: lib opus_demo opus_compare $(TESTS) - -lib: $(TARGET) - -check: all - for test in $(TESTS); do ./$$test; done - -$(TARGET): $(OBJS) - $(ARCHIVE.cmdline) - -opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET) - $(LINK.o.cmdline) - -test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET) - $(LINK.o.cmdline) - -test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET) - $(LINK.o.cmdline) - -test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET) - $(LINK.o.cmdline) - -test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET) - $(LINK.o.cmdline) - -opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS) - $(LINK.o.cmdline) - -celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' -celt/celt.o: package_version - -package_version: force - @if [ -x ./update_version ]; then \ - ./update_version || true; \ - elif [ ! -e ./package_version ]; then \ - echo 'PACKAGE_VERSION="unknown"' > ./package_version; \ - fi - -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_padding$(EXESUFFIX) \ - $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS) $(TESTOPUSAPI_OBJS) \ - $(TESTOPUSDECODE_OBJS) $(TESTOPUSENCODE_OBJS) $(TESTOPUSPADDING_OBJS) - -.PHONY: all lib clean force check diff --git a/Engine/lib/opus/NEWS b/Engine/lib/opus/NEWS deleted file mode 100644 index e69de29bb..000000000 diff --git a/Engine/lib/opus/README b/Engine/lib/opus/README deleted file mode 100644 index 4b13076fa..000000000 --- a/Engine/lib/opus/README +++ /dev/null @@ -1,161 +0,0 @@ -== Opus audio codec == - -Opus is a codec for interactive speech and audio transmission over the Internet. - - 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 -correct operation of the library. The bitstreams read/written by these -tools should not be used for Opus 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/ - -== Compiling libopus == - -To build from a distribution tarball, you only need to do the following: - - % ./configure - % make - -To build from the git repository, the following steps are necessary: - -0) Set up a development environment: - -On an Ubuntu or Debian family Linux distribution: - - % sudo apt-get install git autoconf automake libtool gcc make - -On a Fedora/Redhat based Linux: - - % sudo dnf install git autoconf automake libtool gcc make - -Or for older Redhat/Centos Linux releases: - - % sudo yum install git autoconf automake libtool gcc make - -On Apple macOS, install Xcode and brew.sh, then in the Terminal enter: - - % brew install autoconf automake libtool - -1) Clone the repository: - - % git clone https://gitlab.xiph.org/xiph/opus.git - % cd opus - -2) Compiling the source - - % ./autogen.sh - % ./configure - % make - -3) Install the codec libraries (optional) - - % sudo make install - -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. - -== Testing == - -This package includes a collection of automated unit and system tests -which SHOULD be run after compiling the package especially the first -time it is run on a new platform. - -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 - -== Portability notes == - -This implementation uses floating-point by default but can be compiled to -use only fixed-point arithmetic by setting --enable-fixed-point (if using -autoconf) or by defining the FIXED_POINT macro (if building manually). -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. -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: - -o Right shifts of negative values are consistent with two's - complement arithmetic, so that a>>b is equivalent to - floor(a/(2^b)), - -o For conversion to a signed integer of N bits, the value is reduced - modulo 2^N to be within range of the type, - -o The result of integer division of a negative value is truncated - towards zero, and - -o The compiler provides a 64-bit integer type (a C99 requirement - which is supported by most C89 compilers). diff --git a/Engine/lib/opus/README.draft b/Engine/lib/opus/README.draft deleted file mode 100644 index 9c31bd023..000000000 --- a/Engine/lib/opus/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/Engine/lib/opus/autogen.sh b/Engine/lib/opus/autogen.sh deleted file mode 100644 index 380d1f3ca..000000000 --- a/Engine/lib/opus/autogen.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Copyright (c) 2010-2015 Xiph.Org Foundation and contributors. -# Use of this source code is governed by a BSD-style license that can be -# found in the COPYING file. - -# Run this to set up the build system: configure, makefiles, etc. -set -e - -srcdir=`dirname $0` -test -n "$srcdir" && cd "$srcdir" - -echo "Updating build configuration files, please wait...." - -autoreconf -isf diff --git a/Engine/lib/opus/celt/_kiss_fft_guts.h b/Engine/lib/opus/celt/_kiss_fft_guts.h deleted file mode 100644 index 17392b3e9..000000000 --- a/Engine/lib/opus/celt/_kiss_fft_guts.h +++ /dev/null @@ -1,182 +0,0 @@ -/*Copyright (c) 2003-2004, Mark Borgerding - - 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_GUTS_H -#define KISS_FFT_GUTS_H - -#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 - and defines - typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */ -#include "kiss_fft.h" - -/* - 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 - C_SUB( res, a,b) : res = a - b - C_SUBFROM( res , a) : res -= a - C_ADDTO( res , a) : res += a - * */ -#ifdef FIXED_POINT -#include "arch.h" - - -#define SAMP_MAX 2147483647 -#define TWID_MAX 32767 -#define TRIG_UPSCALE 1 - -#define SAMP_MIN -SAMP_MAX - - -# define S_MUL(a,b) MULT16_32_Q15(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 - -#if defined(OPUS_ARM_INLINE_EDSP) -#include "arm/kiss_fft_armv5e.h" -#endif -#if defined(MIPSr1_ASM) -#include "mips/kiss_fft_mipsr1.h" -#endif - -#else /* not FIXED_POINT*/ - -# 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_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 */ -#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)\ - (res).r -= (a).r; (res).i -= (a).i; \ - }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) -#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)) -#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) -#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) - -#endif /* KISS_FFT_GUTS_H */ diff --git a/Engine/lib/opus/celt/arch.h b/Engine/lib/opus/celt/arch.h deleted file mode 100644 index 3845c3a08..000000000 --- a/Engine/lib/opus/celt/arch.h +++ /dev/null @@ -1,291 +0,0 @@ -/* Copyright (c) 2003-2008 Jean-Marc Valin - Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/** - @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 - 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 ARCH_H -#define ARCH_H - -#include "opus_types.h" -#include "opus_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 -# endif - -#if OPUS_GNUC_PREREQ(3, 0) -#define opus_likely(x) (__builtin_expect(!!(x), 1)) -#define opus_unlikely(x) (__builtin_expect(!!(x), 0)) -#else -#define opus_likely(x) (!!(x)) -#define opus_unlikely(x) (!!(x)) -#endif - -#define CELT_SIG_SCALE 32768.f - -#define CELT_FATAL(str) celt_fatal(str, __FILE__, __LINE__); - -#if defined(ENABLE_ASSERTIONS) || defined(ENABLE_HARDENING) -#ifdef __GNUC__ -__attribute__((noreturn)) -#endif -void celt_fatal(const char *str, const char *file, int line); - -#if defined(CELT_C) && !defined(OVERRIDE_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 - -#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) -#else -#define celt_assert(cond) -#define celt_assert2(cond, message) -#define MUST_SUCCEED(call) do {if((call) != OPUS_OK) {RESTORE_STACK; return OPUS_INTERNAL_ERROR;} } while (0) -#endif - -#if defined(ENABLE_ASSERTIONS) -#define celt_sig_assert(cond) {if (!(cond)) {CELT_FATAL("signal assertion failed: " #cond);}} -#else -#define celt_sig_assert(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 UADD32(a,b) ((a)+(b)) -#define USUB32(a,b) ((a)-(b)) - -/* Set this if opus_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) -#define OPUS_FAST_INT64 1 -#else -#define OPUS_FAST_INT64 0 -#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_val16 celt_norm; -typedef opus_val32 celt_ener; - -#define celt_isnan(x) 0 - -#define Q15ONE 32767 - -#define SIG_SHIFT 12 -/* Safe saturation value for 32-bit signals. Should be less than - 2^31*(1-0.85) to avoid blowing up on DC at deemphasis.*/ -#define SIG_SAT (300000000) - -#define NORM_SCALING 16384 - -#define DB_SHIFT 10 - -#define EPSILON 1 -#define VERY_SMALL 0 -#define VERY_LARGE16 ((opus_val16)32767) -#define Q15_ONE ((opus_val16)32767) - -#define SCALEIN(a) (a) -#define SCALEOUT(a) (a) - -#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) -#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) - -static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { - return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_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 - -#endif - -#else /* FIXED_POINT */ - -typedef float opus_val16; -typedef float opus_val32; -typedef float opus_val64; - -typedef float celt_sig; -typedef float celt_norm; -typedef float celt_ener; - -#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; -} -#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 - -#define Q15ONE 1.0f - -#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) - -/* 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 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 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 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_Q31(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 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 DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) -#define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) - -#define SCALEIN(a) ((a)*CELT_SIG_SCALE) -#define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) - -#define SIG2WORD16(x) (x) - -#endif /* !FIXED_POINT */ - -#ifndef GLOBAL_STACK_SIZE -#ifdef FIXED_POINT -#define GLOBAL_STACK_SIZE 120000 -#else -#define GLOBAL_STACK_SIZE 120000 -#endif -#endif - -#endif /* ARCH_H */ diff --git a/Engine/lib/opus/celt/arm/arm2gnu.pl b/Engine/lib/opus/celt/arm/arm2gnu.pl deleted file mode 100644 index a2895f744..000000000 --- a/Engine/lib/opus/celt/arm/arm2gnu.pl +++ /dev/null @@ -1,353 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2002-2013 Xiph.org Foundation -# -# 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. - -my $bigend; # little/big endian -my $nxstack; -my $apple = 0; -my $symprefix = ""; - -$nxstack = 0; - -eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' - if $running_under_some_shell; - -while ($ARGV[0] =~ /^-/) { - $_ = shift; - last if /^--$/; - if (/^-n$/) { - $nflag++; - next; - } - if (/^--apple$/) { - $apple = 1; - $symprefix = "_"; - next; - } - die "I don't recognize this switch: $_\\n"; -} -$printit++ unless $nflag; - -$\ = "\n"; # automatically add newline on print -$n=0; - -$thumb = 0; # ARM mode by default, not Thumb. -@proc_stack = (); - -printf (" .syntax unified\n"); - -LINE: -while (<>) { - - # For ADRLs we need to add a new line after the substituted one. - $addPadding = 0; - - # First, we do not dare to touch *anything* inside double quotes, do we? - # Second, if you want a dollar character in the string, - # insert two of them -- that's how ARM C and assembler treat strings. - s/^([A-Za-z_]\w*)[ \t]+DCB[ \t]*\"/$1: .ascii \"/ && do { s/\$\$/\$/g; next }; - s/\bDCB\b[ \t]*\"/.ascii \"/ && do { s/\$\$/\$/g; next }; - s/^(\S+)\s+RN\s+(\S+)/$1 .req r$2/ && do { s/\$\$/\$/g; next }; - # If there's nothing on a line but a comment, don't try to apply any further - # substitutions (this is a cheap hack to avoid mucking up the license header) - s/^([ \t]*);/$1@/ && do { s/\$\$/\$/g; next }; - # If substituted -- leave immediately ! - - s/@/,:/; - s/;/@/; - while ( /@.*'/ ) { - s/(@.*)'/$1/g; - } - s/\{FALSE\}/0/g; - s/\{TRUE\}/1/g; - s/\{(\w\w\w\w+)\}/$1/g; - s/\bINCLUDE[ \t]*([^ \t\n]+)/.include \"$1\"/; - s/\bGET[ \t]*([^ \t\n]+)/.include \"${ my $x=$1; $x =~ s|\.s|-gnu.S|; \$x }\"/; - s/\bIMPORT\b/.extern/; - s/\bEXPORT\b\s*/.global $symprefix/; - s/^(\s+)\[/$1IF/; - s/^(\s+)\|/$1ELSE/; - s/^(\s+)\]/$1ENDIF/; - s/IF *:DEF:/ .ifdef/; - s/IF *:LNOT: *:DEF:/ .ifndef/; - s/ELSE/ .else/; - s/ENDIF/ .endif/; - - if( /\bIF\b/ ) { - s/\bIF\b/ .if/; - s/=/==/; - } - if ( $n == 2) { - s/\$/\\/g; - } - if ($n == 1) { - s/\$//g; - s/label//g; - $n = 2; - } - if ( /MACRO/ ) { - s/MACRO *\n/.macro/; - $n=1; - } - if ( /\bMEND\b/ ) { - s/\bMEND\b/.endm/; - $n=0; - } - - # ".rdata" doesn't work in 'as' version 2.13.2, as it is ".rodata" there. - # - if ( /\bAREA\b/ ) { - my $align; - $align = "2"; - if ( /ALIGN=(\d+)/ ) { - $align = $1; - } - if ( /CODE/ ) { - $nxstack = 1; - } - s/^(.+)CODE(.+)READONLY(.*)/ .text/; - s/^(.+)DATA(.+)READONLY(.*)/ .section .rdata/; - s/^(.+)\|\|\.data\|\|(.+)/ .data/; - s/^(.+)\|\|\.bss\|\|(.+)/ .bss/; - s/$/; .p2align $align/; - # Enable NEON instructions but don't produce a binary that requires - # ARMv7. RVCT does not have equivalent directives, so we just do this - # for all CODE areas. - if ( /.text/ ) { - # Separating .arch, .fpu, etc., by semicolons does not work (gas - # thinks the semicolon is part of the arch name, even when there's - # whitespace separating them). Sadly this means our line numbers - # won't match the original source file (we could use the .line - # directive, which is documented to be obsolete, but then gdb will - # show the wrong line in the translated source file). - s/$/; .arch armv7-a\n .fpu neon\n .object_arch armv4t/ unless ($apple); - } - } - - s/\|\|\.constdata\$(\d+)\|\|/.L_CONST$1/; # ||.constdata$3|| - s/\|\|\.bss\$(\d+)\|\|/.L_BSS$1/; # ||.bss$2|| - s/\|\|\.data\$(\d+)\|\|/.L_DATA$1/; # ||.data$2|| - s/\|\|([a-zA-Z0-9_]+)\@([a-zA-Z0-9_]+)\|\|/@ $&/; - s/^(\s+)\%(\s)/ .space $1/; - - s/\|(.+)\.(\d+)\|/\.$1_$2/; # |L80.123| -> .L80_123 - s/\bCODE32\b/.code 32/ && do {$thumb = 0}; - s/\bCODE16\b/.code 16/ && do {$thumb = 1}; - if (/\bPROC\b/) - { - my $prefix; - my $proc; - /^([A-Za-z_\.]\w+)\b/; - $proc = $1; - $prefix = ""; - if ($proc) - { - $prefix = $prefix.sprintf("\t.type\t%s, %%function", $proc) unless ($apple); - # Make sure we $prefix isn't empty here (for the $apple case). - # We handle mangling the label here, make sure it doesn't match - # the label handling below (if $prefix would be empty). - $prefix = $prefix."; "; - push(@proc_stack, $proc); - s/^[A-Za-z_\.]\w+/$symprefix$&:/; - } - $prefix = $prefix."\t.thumb_func; " if ($thumb); - s/\bPROC\b/@ $&/; - $_ = $prefix.$_; - } - s/^(\s*)(S|Q|SH|U|UQ|UH)ASX\b/$1$2ADDSUBX/; - s/^(\s*)(S|Q|SH|U|UQ|UH)SAX\b/$1$2SUBADDX/; - if (/\bENDP\b/) - { - my $proc; - s/\bENDP\b/@ $&/; - $proc = pop(@proc_stack); - $_ = "\t.size $proc, .-$proc".$_ if ($proc && !$apple); - } - s/\bSUBT\b/@ $&/; - s/\bDATA\b/@ $&/; # DATA directive is deprecated -- Asm guide, p.7-25 - s/\bKEEP\b/@ $&/; - s/\bEXPORTAS\b/@ $&/; - s/\|\|(.)+\bEQU\b/@ $&/; - s/\|\|([\w\$]+)\|\|/$1/; - s/\bENTRY\b/@ $&/; - s/\bASSERT\b/@ $&/; - s/\bGBLL\b/@ $&/; - s/\bGBLA\b/@ $&/; - s/^\W+OPT\b/@ $&/; - s/:OR:/|/g; - s/:SHL:/<>/g; - s/:AND:/&/g; - s/:LAND:/&&/g; - s/CPSR/cpsr/; - s/SPSR/spsr/; - s/ALIGN$/.balign 4/; - s/ALIGN\s+([0-9x]+)$/.balign $1/; - s/psr_cxsf/psr_all/; - s/LTORG/.ltorg/; - s/^([A-Za-z_]\w*)[ \t]+EQU/ .set $1,/; - s/^([A-Za-z_]\w*)[ \t]+SETL/ .set $1,/; - s/^([A-Za-z_]\w*)[ \t]+SETA/ .set $1,/; - s/^([A-Za-z_]\w*)[ \t]+\*/ .set $1,/; - - # {PC} + 0xdeadfeed --> . + 0xdeadfeed - s/\{PC\} \+/ \. +/; - - # Single hex constant on the line ! - # - # >>> NOTE <<< - # Double-precision floats in gcc are always mixed-endian, which means - # bytes in two words are little-endian, but words are big-endian. - # So, 0x0000deadfeed0000 would be stored as 0x0000dead at low address - # and 0xfeed0000 at high address. - # - s/\bDCFD\b[ \t]+0x([a-fA-F0-9]{8})([a-fA-F0-9]{8})/.long 0x$1, 0x$2/; - # Only decimal constants on the line, no hex ! - s/\bDCFD\b[ \t]+([0-9\.\-]+)/.double $1/; - - # Single hex constant on the line ! -# s/\bDCFS\b[ \t]+0x([a-f0-9]{8})([a-f0-9]{8})/.long 0x$1, 0x$2/; - # Only decimal constants on the line, no hex ! -# s/\bDCFS\b[ \t]+([0-9\.\-]+)/.double $1/; - s/\bDCFS[ \t]+0x/.word 0x/; - s/\bDCFS\b/.float/; - - s/^([A-Za-z_]\w*)[ \t]+DCD/$1 .word/; - s/\bDCD\b/.word/; - s/^([A-Za-z_]\w*)[ \t]+DCW/$1 .short/; - s/\bDCW\b/.short/; - s/^([A-Za-z_]\w*)[ \t]+DCB/$1 .byte/; - s/\bDCB\b/.byte/; - s/^([A-Za-z_]\w*)[ \t]+\%/.comm $1,/; - s/^[A-Za-z_\.]\w+/$&:/; - s/^(\d+)/$1:/; - s/\%(\d+)/$1b_or_f/; - s/\%[Bb](\d+)/$1b/; - s/\%[Ff](\d+)/$1f/; - s/\%[Ff][Tt](\d+)/$1f/; - s/&([\dA-Fa-f]+)/0x$1/; - if ( /\b2_[01]+\b/ ) { - s/\b2_([01]+)\b/conv$1&&&&/g; - while ( /[01][01][01][01]&&&&/ ) { - s/0000&&&&/&&&&0/g; - s/0001&&&&/&&&&1/g; - s/0010&&&&/&&&&2/g; - s/0011&&&&/&&&&3/g; - s/0100&&&&/&&&&4/g; - s/0101&&&&/&&&&5/g; - s/0110&&&&/&&&&6/g; - s/0111&&&&/&&&&7/g; - s/1000&&&&/&&&&8/g; - s/1001&&&&/&&&&9/g; - s/1010&&&&/&&&&A/g; - s/1011&&&&/&&&&B/g; - s/1100&&&&/&&&&C/g; - s/1101&&&&/&&&&D/g; - s/1110&&&&/&&&&E/g; - s/1111&&&&/&&&&F/g; - } - s/000&&&&/&&&&0/g; - s/001&&&&/&&&&1/g; - s/010&&&&/&&&&2/g; - s/011&&&&/&&&&3/g; - s/100&&&&/&&&&4/g; - s/101&&&&/&&&&5/g; - s/110&&&&/&&&&6/g; - s/111&&&&/&&&&7/g; - s/00&&&&/&&&&0/g; - s/01&&&&/&&&&1/g; - s/10&&&&/&&&&2/g; - s/11&&&&/&&&&3/g; - s/0&&&&/&&&&0/g; - s/1&&&&/&&&&1/g; - s/conv&&&&/0x/g; - } - - if ( /commandline/) - { - if( /-bigend/) - { - $bigend=1; - } - } - - if ( /\bDCDU\b/ ) - { - my $cmd=$_; - my $value; - my $prefix; - my $w1; - my $w2; - my $w3; - my $w4; - - s/\s+DCDU\b/@ $&/; - - $cmd =~ /\bDCDU\b\s+0x(\d+)/; - $value = $1; - $value =~ /(\w\w)(\w\w)(\w\w)(\w\w)/; - $w1 = $1; - $w2 = $2; - $w3 = $3; - $w4 = $4; - - if( $bigend ne "") - { - # big endian - $prefix = "\t.byte\t0x".$w1.";". - "\t.byte\t0x".$w2.";". - "\t.byte\t0x".$w3.";". - "\t.byte\t0x".$w4."; "; - } - else - { - # little endian - $prefix = "\t.byte\t0x".$w4.";". - "\t.byte\t0x".$w3.";". - "\t.byte\t0x".$w2.";". - "\t.byte\t0x".$w1."; "; - } - $_=$prefix.$_; - } - - if ( /\badrl\b/i ) - { - s/\badrl\s+(\w+)\s*,\s*(\w+)/ldr $1,=$2/i; - $addPadding = 1; - } - s/\bEND\b/@ END/; -} continue { - printf ("%s", $_) if $printit; - if ($addPadding != 0) - { - printf (" mov r0,r0\n"); - $addPadding = 0; - } -} -#If we had a code section, mark that this object doesn't need an executable -# stack. -if ($nxstack && !$apple) { - printf (" .section\t.note.GNU-stack,\"\",\%\%progbits\n"); -} diff --git a/Engine/lib/opus/celt/arm/arm_celt_map.c b/Engine/lib/opus/celt/arm/arm_celt_map.c deleted file mode 100644 index ca988b66f..000000000 --- a/Engine/lib/opus/celt/arm/arm_celt_map.c +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (c) 2010 Xiph.Org Foundation - * Copyright (c) 2013 Parrot */ -/* - 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 "pitch.h" -#include "kiss_fft.h" -#include "mdct.h" - -#if defined(OPUS_HAVE_RTCD) - -# 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 */ -}; - -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 */ -}; -# 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 */ -}; - -# 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 */ -}; -# 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 */ -}; - -#endif - -# if defined(OPUS_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 */ -}; - -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 */ -}; -# endif /* CUSTOM_MODES */ - -void (*const OPUS_FFT[OPUS_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 */ -}; - -void (*const OPUS_IFFT[OPUS_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 */ -}; - -void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(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) = { - clt_mdct_forward_c, /* ARMv4 */ - clt_mdct_forward_c, /* EDSP */ - clt_mdct_forward_c, /* Media */ - clt_mdct_forward_neon /* Neon with NE10 */ -}; - -void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(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) = { - clt_mdct_backward_c, /* ARMv4 */ - clt_mdct_backward_c, /* EDSP */ - clt_mdct_backward_c, /* Media */ - clt_mdct_backward_neon /* Neon with NE10 */ -}; - -# endif /* HAVE_ARM_NE10 */ -# endif /* OPUS_ARM_MAY_HAVE_NEON_INTR */ - -#endif /* OPUS_HAVE_RTCD */ diff --git a/Engine/lib/opus/celt/arm/armcpu.c b/Engine/lib/opus/celt/arm/armcpu.c deleted file mode 100644 index c7d16e6d6..000000000 --- a/Engine/lib/opus/celt/arm/armcpu.c +++ /dev/null @@ -1,194 +0,0 @@ -/* Copyright (c) 2010 Xiph.Org Foundation - * Copyright (c) 2013 Parrot */ -/* - 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. -*/ - -/* Original code from libtheora modified to suit to Opus */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef OPUS_HAVE_RTCD - -#include "armcpu.h" -#include "cpu_support.h" -#include "os_support.h" -#include "opus_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.*/ - } -# endif -# endif -# endif - return flags; -} - -#elif defined(__linux__) -/* Linux based */ -#include - -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; -# 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 - } - - fclose(cpuinfo); - } - return flags; -} -#else -/* The feature registers which can tell us what the processor supports are - * accessible in priveleged 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 - -static int opus_select_arch_impl(void) -{ - opus_uint32 flags = opus_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 & OPUS_CPU_ARM_MEDIA_FLAG)) { - celt_assert(arch == OPUS_ARCH_ARM_EDSP); - return arch; - } - arch++; - - if(!(flags & OPUS_CPU_ARM_NEON_FLAG)) { - celt_assert(arch == OPUS_ARCH_ARM_MEDIA); - return arch; - } - arch++; - - celt_assert(arch == OPUS_ARCH_ARM_NEON); - return arch; -} - -int opus_select_arch(void) { - int arch = opus_select_arch_impl(); -#ifdef FUZZING - arch = rand()%(arch+1); -#endif - return arch; -} -#endif diff --git a/Engine/lib/opus/celt/arm/armcpu.h b/Engine/lib/opus/celt/arm/armcpu.h deleted file mode 100644 index 820262ff5..000000000 --- a/Engine/lib/opus/celt/arm/armcpu.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (c) 2010 Xiph.Org Foundation - * Copyright (c) 2013 Parrot */ -/* - 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(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_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_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) - -# endif - -#endif diff --git a/Engine/lib/opus/celt/arm/armopts.s.in b/Engine/lib/opus/celt/arm/armopts.s.in deleted file mode 100644 index 3d8aaf275..000000000 --- a/Engine/lib/opus/celt/arm/armopts.s.in +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2013 Mozilla Corporation */ -/* - 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. -*/ - -; 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@ - -; Set the following to 1 if we have ARMv6 media instructions. -OPUS_ARM_MAY_HAVE_MEDIA * @OPUS_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@ - -END diff --git a/Engine/lib/opus/celt/arm/celt_fft_ne10.c b/Engine/lib/opus/celt/arm/celt_fft_ne10.c deleted file mode 100644 index ea5fd7808..000000000 --- a/Engine/lib/opus/celt/arm/celt_fft_ne10.c +++ /dev/null @@ -1,173 +0,0 @@ -/* Copyright (c) 2015 Xiph.Org Foundation - Written by Viswanath Puttagunta */ -/** - @file celt_fft_ne10.c - @brief ARM Neon optimizations for fft using NE10 library - */ - -/* - 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 SKIP_CONFIG_H -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#endif - -#include -#include "os_support.h" -#include "kiss_fft.h" -#include "stack_alloc.h" - -#if !defined(FIXED_POINT) -# define NE10_FFT_ALLOC_C2C_TYPE_NEON ne10_fft_alloc_c2c_float32_neon -# define NE10_FFT_CFG_TYPE_T ne10_fft_cfg_float32_t -# define NE10_FFT_STATE_TYPE_T ne10_fft_state_float32_t -# define NE10_FFT_DESTROY_C2C_TYPE ne10_fft_destroy_c2c_float32 -# define NE10_FFT_CPX_TYPE_T ne10_fft_cpx_float32_t -# define NE10_FFT_C2C_1D_TYPE_NEON ne10_fft_c2c_1d_float32_neon -#else -# define NE10_FFT_ALLOC_C2C_TYPE_NEON(nfft) ne10_fft_alloc_c2c_int32_neon(nfft) -# define NE10_FFT_CFG_TYPE_T ne10_fft_cfg_int32_t -# define NE10_FFT_STATE_TYPE_T ne10_fft_state_int32_t -# define NE10_FFT_DESTROY_C2C_TYPE ne10_fft_destroy_c2c_int32 -# define NE10_FFT_DESTROY_C2C_TYPE ne10_fft_destroy_c2c_int32 -# define NE10_FFT_CPX_TYPE_T ne10_fft_cpx_int32_t -# define NE10_FFT_C2C_1D_TYPE_NEON ne10_fft_c2c_1d_int32_neon -#endif - -#if defined(CUSTOM_MODES) - -/* 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 -}; - -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; -} - -void opus_fft_free_arm_neon(kiss_fft_state *st) -{ - NE10_FFT_CFG_TYPE_T cfg; - - 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); -} -#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]; -#if !defined(FIXED_POINT) - state.is_forward_scaled = 1; - - 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, - cfg, 0, 1); -#endif - } - 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]; -#if !defined(FIXED_POINT) - state.is_backward_scaled = 0; - - 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, - cfg, 1, 0); -#endif - } - RESTORE_STACK; -} diff --git a/Engine/lib/opus/celt/arm/celt_mdct_ne10.c b/Engine/lib/opus/celt/arm/celt_mdct_ne10.c deleted file mode 100644 index 3531d02d1..000000000 --- a/Engine/lib/opus/celt/arm/celt_mdct_ne10.c +++ /dev/null @@ -1,258 +0,0 @@ -/* Copyright (c) 2015 Xiph.Org Foundation - Written by Viswanath Puttagunta */ -/** - @file celt_mdct_ne10.c - @brief ARM Neon optimizations for mdct using NE10 library - */ - -/* - 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 SKIP_CONFIG_H -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#endif - -#include "kiss_fft.h" -#include "_kiss_fft_guts.h" -#include "mdct.h" -#include "stack_alloc.h" - -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) -{ - 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; -} - -void 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; -} diff --git a/Engine/lib/opus/celt/arm/celt_neon_intr.c b/Engine/lib/opus/celt/arm/celt_neon_intr.c deleted file mode 100644 index effda769d..000000000 --- a/Engine/lib/opus/celt/arm/celt_neon_intr.c +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright (c) 2014-2015 Xiph.Org Foundation - Written by Viswanath Puttagunta */ -/** - @file celt_neon_intr.c - @brief ARM Neon Intrinsic optimizations for celt - */ - -/* - 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 -#include "../pitch.h" - -#if defined(FIXED_POINT) -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; - - 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; - } - - for (; j < len; j++) - { - int16x4_t x0 = vld1_dup_s16(x); /* load next x */ - int32x4_t a0 = vmlal_s16(a, y0, x0); - - int16x4_t y4 = vld1_dup_s16(y); /* load next y */ - y0 = vext_s16(y0, y4, 1); - a = a0; - x++; - y++; - } - - vst1q_s32(sum, a); -} - -#else -/* - * Function: 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); -} - -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((((unsigned char *)_x-(unsigned char *)NULL)&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); - } -} -#endif diff --git a/Engine/lib/opus/celt/arm/celt_pitch_xcorr_arm.s b/Engine/lib/opus/celt/arm/celt_pitch_xcorr_arm.s deleted file mode 100644 index 6e873afc3..000000000 --- a/Engine/lib/opus/celt/arm/celt_pitch_xcorr_arm.s +++ /dev/null @@ -1,551 +0,0 @@ -; Copyright (c) 2007-2008 CSIRO -; Copyright (c) 2007-2009 Xiph.Org Foundation -; Copyright (c) 2013 Parrot -; Written by Aurélien Zanelli -; -; 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. - - AREA |.text|, CODE, READONLY - - GET celt/arm/armopts.s - -IF OPUS_ARM_MAY_HAVE_EDSP - EXPORT celt_pitch_xcorr_edsp -ENDIF - -IF OPUS_ARM_MAY_HAVE_NEON - EXPORT celt_pitch_xcorr_neon -ENDIF - -IF OPUS_ARM_MAY_HAVE_NEON - -; Compute sum[k]=sum(x[j]*y[j+k],j=0...len-1), k=0...3 -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] - ; output: - ; q0 = opus_val32 sum[4] - ; preserved: r0-r3, r6-r11, d2, q4-q7, q9-q15 - ; internal usage: - ; r12 = int j - ; d3 = y_3|y_2|y_1|y_0 - ; q2 = y_B|y_A|y_9|y_8|y_7|y_6|y_5|y_4 - ; q3 = x_7|x_6|x_5|x_4|x_3|x_2|x_1|x_0 - ; q8 = scratch - ; - ; Load y[0...3] - ; This requires len>0 to always be valid (which we assert in the C code). - VLD1.16 {d5}, [r5]! - SUBS r12, r3, #8 - BLE xcorr_kernel_neon_process4 -; Process 8 samples at a time. -; 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. -xcorr_kernel_neon_process8 - ; This loop has 19 total instructions (10 cycles to issue, minimum), with - ; - 2 cycles of ARM insrtuctions, - ; - 10 cycles of load/store/byte permute instructions, and - ; - 9 cycles of data processing instructions. - ; On a Cortex A8, we dual-issue the maximum amount (9 cycles) between the - ; latter two categories, meaning the whole loop should run in 10 cycles per - ; iteration, barring cache misses. - ; - ; Load x[0...7] - VLD1.16 {d6, d7}, [r4]! - ; Unlike VMOV, VAND is a data processsing instruction (and doesn't get - ; assembled to VMOV, like VORR would), so it dual-issues with the prior VLD1. - VAND d3, d5, d5 - SUBS r12, r12, #8 - ; Load y[4...11] - VLD1.16 {d4, d5}, [r5]! - VMLAL.S16 q0, d3, d6[0] - VEXT.16 d16, d3, d4, #1 - VMLAL.S16 q0, d4, d7[0] - VEXT.16 d17, d4, d5, #1 - VMLAL.S16 q0, d16, d6[1] - VEXT.16 d16, d3, d4, #2 - VMLAL.S16 q0, d17, d7[1] - VEXT.16 d17, d4, d5, #2 - VMLAL.S16 q0, d16, d6[2] - VEXT.16 d16, d3, d4, #3 - VMLAL.S16 q0, d17, d7[2] - VEXT.16 d17, d4, d5, #3 - VMLAL.S16 q0, d16, d6[3] - VMLAL.S16 q0, d17, d7[3] - BGT xcorr_kernel_neon_process8 -; Process 4 samples here if we have > 4 left (still reading one extra y value). -xcorr_kernel_neon_process4 - ADDS r12, r12, #4 - BLE xcorr_kernel_neon_process2 - ; Load x[0...3] - VLD1.16 d6, [r4]! - ; Use VAND since it's a data processing instruction again. - VAND d4, d5, d5 - SUB r12, r12, #4 - ; Load y[4...7] - VLD1.16 d5, [r5]! - VMLAL.S16 q0, d4, d6[0] - VEXT.16 d16, d4, d5, #1 - VMLAL.S16 q0, d16, d6[1] - VEXT.16 d16, d4, d5, #2 - VMLAL.S16 q0, d16, d6[2] - VEXT.16 d16, d4, d5, #3 - VMLAL.S16 q0, d16, d6[3] -; Process 2 samples here if we have > 2 left (still reading one extra y value). -xcorr_kernel_neon_process2 - ADDS r12, r12, #2 - BLE xcorr_kernel_neon_process1 - ; Load x[0...1] - VLD2.16 {d6[],d7[]}, [r4]! - ; Use VAND since it's a data processing instruction again. - VAND d4, d5, d5 - SUB r12, r12, #2 - ; Load y[4...5] - VLD1.32 {d5[]}, [r5]! - VMLAL.S16 q0, d4, d6 - VEXT.16 d16, d4, d5, #1 - ; Replace bottom copy of {y5,y4} in d5 with {y3,y2} from d4, using VSRI - ; instead of VEXT, since it's a data-processing instruction. - VSRI.64 d5, d4, #32 - VMLAL.S16 q0, d16, d7 -; Process 1 sample using the extra y value we loaded above. -xcorr_kernel_neon_process1 - ; Load next *x - VLD1.16 {d6[]}, [r4]! - ADDS r12, r12, #1 - ; y[0...3] are left in d5 from prior iteration(s) (if any) - VMLAL.S16 q0, d5, d6 - MOVLE pc, lr -; Now process 1 last sample, not reading ahead. - ; Load last *y - VLD1.16 {d4[]}, [r5]! - VSRI.64 d4, d5, #16 - ; Load last *x - VLD1.16 {d6[]}, [r4]! - VMLAL.S16 q0, d4, d6 - 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 - ; input: - ; r0 = opus_val16 *_x - ; r1 = opus_val16 *_y - ; r2 = opus_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()) - ; r6 = int max_pitch - ; r12 = int j - ; q15 = int maxcorr[4] (q15 is not used by xcorr_kernel_neon()) - ; ignored: - ; int arch - STMFD sp!, {r4-r6, lr} - LDR r6, [sp, #16] - VMOV.S32 q15, #1 - ; if (max_pitch < 4) goto celt_pitch_xcorr_neon_process4_done - SUBS r6, r6, #4 - BLT celt_pitch_xcorr_neon_process4_done -celt_pitch_xcorr_neon_process4 - ; xcorr_kernel_neon parameters: - ; r3 = len, r4 = _x, r5 = _y, q0 = {0, 0, 0, 0} - MOV r4, r0 - MOV r5, r1 - VEOR q0, q0, q0 - ; xcorr_kernel_neon only modifies r4, r5, r12, and q0...q3. - ; So we don't save/restore any other registers. - BL xcorr_kernel_neon_start - SUBS r6, r6, #4 - VST1.32 {q0}, [r2]! - ; _y += 4 - ADD r1, r1, #8 - VMAX.S32 q15, q15, q0 - ; if (max_pitch < 4) goto celt_pitch_xcorr_neon_process4_done - BGE celt_pitch_xcorr_neon_process4 -; We have less than 4 sums left to compute. -celt_pitch_xcorr_neon_process4_done - ADDS r6, r6, #4 - ; Reduce maxcorr to a single value - VMAX.S32 d30, d30, d31 - VPMAX.S32 d30, d30, d30 - ; if (max_pitch <= 0) goto celt_pitch_xcorr_neon_done - BLE celt_pitch_xcorr_neon_done -; Now compute each remaining sum one at a time. -celt_pitch_xcorr_neon_process_remaining - MOV r4, r0 - MOV r5, r1 - VMOV.I32 q0, #0 - SUBS r12, r3, #8 - BLT celt_pitch_xcorr_neon_process_remaining4 -; Sum terms 8 at a time. -celt_pitch_xcorr_neon_process_remaining_loop8 - ; Load x[0...7] - VLD1.16 {q1}, [r4]! - ; Load y[0...7] - VLD1.16 {q2}, [r5]! - SUBS r12, r12, #8 - VMLAL.S16 q0, d4, d2 - VMLAL.S16 q0, d5, d3 - BGE celt_pitch_xcorr_neon_process_remaining_loop8 -; Sum terms 4 at a time. -celt_pitch_xcorr_neon_process_remaining4 - ADDS r12, r12, #4 - BLT celt_pitch_xcorr_neon_process_remaining4_done - ; Load x[0...3] - VLD1.16 {d2}, [r4]! - ; Load y[0...3] - VLD1.16 {d3}, [r5]! - SUB r12, r12, #4 - VMLAL.S16 q0, d3, d2 -celt_pitch_xcorr_neon_process_remaining4_done - ; Reduce the sum to a single value. - VADD.S32 d0, d0, d1 - VPADDL.S32 d0, d0 - ADDS r12, r12, #4 - BLE celt_pitch_xcorr_neon_process_remaining_loop_done -; Sum terms 1 at a time. -celt_pitch_xcorr_neon_process_remaining_loop1 - VLD1.16 {d2[]}, [r4]! - VLD1.16 {d3[]}, [r5]! - SUBS r12, r12, #1 - VMLAL.S16 q0, d2, d3 - BGT celt_pitch_xcorr_neon_process_remaining_loop1 -celt_pitch_xcorr_neon_process_remaining_loop_done - VST1.32 {d0[0]}, [r2]! - VMAX.S32 d30, d30, d0 - SUBS r6, r6, #1 - ; _y++ - ADD r1, r1, #2 - ; if (--max_pitch > 0) goto celt_pitch_xcorr_neon_process_remaining - BGT celt_pitch_xcorr_neon_process_remaining -celt_pitch_xcorr_neon_done - VMOV.32 r0, d30[0] - LDMFD sp!, {r4-r6, pc} - ENDP - -ENDIF - -IF OPUS_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 -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] - ; output: - ; r6...r9 = opus_val32 sum[4] - ; preserved: r0-r5 - ; internal usage - ; r2 = int j - ; r12,r14 = opus_val16 x[4] - ; r10,r11 = opus_val16 y[4] - STMFD sp!, {r2,r4,r5,lr} - LDR r10, [r5], #4 ; Load y[0...1] - SUBS r2, r3, #4 ; j = len-4 - LDR r11, [r5], #4 ; Load y[2...3] - BLE xcorr_kernel_edsp_process4_done - LDR r12, [r4], #4 ; Load x[0...1] - ; Stall -xcorr_kernel_edsp_process4 - ; The multiplies must issue from pipeline 0, and can't dual-issue with each - ; other. Every other instruction here dual-issues with a multiply, and is - ; thus "free". There should be no stalls in the body of the loop. - SMLABB r6, r12, r10, r6 ; sum[0] = MAC16_16(sum[0],x_0,y_0) - LDR r14, [r4], #4 ; Load x[2...3] - SMLABT r7, r12, r10, r7 ; sum[1] = MAC16_16(sum[1],x_0,y_1) - SUBS r2, r2, #4 ; j-=4 - SMLABB r8, r12, r11, r8 ; sum[2] = MAC16_16(sum[2],x_0,y_2) - SMLABT r9, r12, r11, r9 ; sum[3] = MAC16_16(sum[3],x_0,y_3) - SMLATT r6, r12, r10, r6 ; sum[0] = MAC16_16(sum[0],x_1,y_1) - LDR r10, [r5], #4 ; Load y[4...5] - SMLATB r7, r12, r11, r7 ; sum[1] = MAC16_16(sum[1],x_1,y_2) - SMLATT r8, r12, r11, r8 ; sum[2] = MAC16_16(sum[2],x_1,y_3) - SMLATB r9, r12, r10, r9 ; sum[3] = MAC16_16(sum[3],x_1,y_4) - LDRGT r12, [r4], #4 ; Load x[0...1] - SMLABB r6, r14, r11, r6 ; sum[0] = MAC16_16(sum[0],x_2,y_2) - SMLABT r7, r14, r11, r7 ; sum[1] = MAC16_16(sum[1],x_2,y_3) - SMLABB r8, r14, r10, r8 ; sum[2] = MAC16_16(sum[2],x_2,y_4) - SMLABT r9, r14, r10, r9 ; sum[3] = MAC16_16(sum[3],x_2,y_5) - SMLATT r6, r14, r11, r6 ; sum[0] = MAC16_16(sum[0],x_3,y_3) - LDR r11, [r5], #4 ; Load y[6...7] - SMLATB r7, r14, r10, r7 ; sum[1] = MAC16_16(sum[1],x_3,y_4) - SMLATT r8, r14, r10, r8 ; sum[2] = MAC16_16(sum[2],x_3,y_5) - SMLATB r9, r14, r11, r9 ; sum[3] = MAC16_16(sum[3],x_3,y_6) - BGT xcorr_kernel_edsp_process4 -xcorr_kernel_edsp_process4_done - ADDS r2, r2, #4 - BLE xcorr_kernel_edsp_done - LDRH r12, [r4], #2 ; r12 = *x++ - SUBS r2, r2, #1 ; j-- - ; Stall - SMLABB r6, r12, r10, r6 ; sum[0] = MAC16_16(sum[0],x,y_0) - LDRHGT r14, [r4], #2 ; r14 = *x++ - SMLABT r7, r12, r10, r7 ; sum[1] = MAC16_16(sum[1],x,y_1) - SMLABB r8, r12, r11, r8 ; sum[2] = MAC16_16(sum[2],x,y_2) - SMLABT r9, r12, r11, r9 ; sum[3] = MAC16_16(sum[3],x,y_3) - BLE xcorr_kernel_edsp_done - SMLABT r6, r14, r10, r6 ; sum[0] = MAC16_16(sum[0],x,y_1) - SUBS r2, r2, #1 ; j-- - SMLABB r7, r14, r11, r7 ; sum[1] = MAC16_16(sum[1],x,y_2) - LDRH r10, [r5], #2 ; r10 = y_4 = *y++ - SMLABT r8, r14, r11, r8 ; sum[2] = MAC16_16(sum[2],x,y_3) - LDRHGT r12, [r4], #2 ; r12 = *x++ - SMLABB r9, r14, r10, r9 ; sum[3] = MAC16_16(sum[3],x,y_4) - BLE xcorr_kernel_edsp_done - SMLABB r6, r12, r11, r6 ; sum[0] = MAC16_16(sum[0],tmp,y_2) - CMP r2, #1 ; j-- - SMLABT r7, r12, r11, r7 ; sum[1] = MAC16_16(sum[1],tmp,y_3) - LDRH r2, [r5], #2 ; r2 = y_5 = *y++ - SMLABB r8, r12, r10, r8 ; sum[2] = MAC16_16(sum[2],tmp,y_4) - LDRHGT r14, [r4] ; r14 = *x - SMLABB r9, r12, r2, r9 ; sum[3] = MAC16_16(sum[3],tmp,y_5) - BLE xcorr_kernel_edsp_done - SMLABT r6, r14, r11, r6 ; sum[0] = MAC16_16(sum[0],tmp,y_3) - LDRH r11, [r5] ; r11 = y_6 = *y - SMLABB r7, r14, r10, r7 ; sum[1] = MAC16_16(sum[1],tmp,y_4) - SMLABB r8, r14, r2, r8 ; sum[2] = MAC16_16(sum[2],tmp,y_5) - SMLABB r9, r14, r11, r9 ; sum[3] = MAC16_16(sum[3],tmp,y_6) -xcorr_kernel_edsp_done - LDMFD sp!, {r2,r4,r5,pc} - ENDP - -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 - ; 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 - ; r1 = int max_pitch - ; r12 = int j - ; ignored: - ; int arch - STMFD sp!, {r4-r11, lr} - MOV r5, r1 - LDR r1, [sp, #36] - MOV r4, r0 - TST r5, #3 - ; maxcorr = 1 - MOV r0, #1 - BEQ celt_pitch_xcorr_edsp_process1u_done -; Compute one sum at the start to make y 32-bit aligned. - SUBS r12, r3, #4 - ; r14 = sum = 0 - MOV r14, #0 - LDRH r8, [r5], #2 - BLE celt_pitch_xcorr_edsp_process1u_loop4_done - LDR r6, [r4], #4 - MOV r8, r8, LSL #16 -celt_pitch_xcorr_edsp_process1u_loop4 - LDR r9, [r5], #4 - SMLABT r14, r6, r8, r14 ; sum = MAC16_16(sum, x_0, y_0) - LDR r7, [r4], #4 - SMLATB r14, r6, r9, r14 ; sum = MAC16_16(sum, x_1, y_1) - LDR r8, [r5], #4 - SMLABT r14, r7, r9, r14 ; sum = MAC16_16(sum, x_2, y_2) - SUBS r12, r12, #4 ; j-=4 - SMLATB r14, r7, r8, r14 ; sum = MAC16_16(sum, x_3, y_3) - LDRGT r6, [r4], #4 - BGT celt_pitch_xcorr_edsp_process1u_loop4 - MOV r8, r8, LSR #16 -celt_pitch_xcorr_edsp_process1u_loop4_done - ADDS r12, r12, #4 -celt_pitch_xcorr_edsp_process1u_loop1 - LDRHGE r6, [r4], #2 - ; Stall - SMLABBGE r14, r6, r8, r14 ; sum = MAC16_16(sum, *x, *y) - SUBSGE r12, r12, #1 - LDRHGT r8, [r5], #2 - BGT celt_pitch_xcorr_edsp_process1u_loop1 - ; Restore _x - SUB r4, r4, r3, LSL #1 - ; Restore and advance _y - SUB r5, r5, r3, LSL #1 - ; maxcorr = max(maxcorr, sum) - CMP r0, r14 - ADD r5, r5, #2 - MOVLT r0, r14 - SUBS r1, r1, #1 - ; xcorr[i] = sum - STR r14, [r2], #4 - BLE celt_pitch_xcorr_edsp_done -celt_pitch_xcorr_edsp_process1u_done - ; if (max_pitch < 4) goto celt_pitch_xcorr_edsp_process2 - SUBS r1, r1, #4 - BLT celt_pitch_xcorr_edsp_process2 -celt_pitch_xcorr_edsp_process4 - ; xcorr_kernel_edsp parameters: - ; r3 = len, r4 = _x, r5 = _y, r6...r9 = sum[4] = {0, 0, 0, 0} - MOV r6, #0 - MOV r7, #0 - MOV r8, #0 - MOV r9, #0 - BL xcorr_kernel_edsp_start ; xcorr_kernel_edsp(_x, _y+i, xcorr+i, len) - ; maxcorr = max(maxcorr, sum0, sum1, sum2, sum3) - CMP r0, r6 - ; _y+=4 - ADD r5, r5, #8 - MOVLT r0, r6 - CMP r0, r7 - MOVLT r0, r7 - CMP r0, r8 - MOVLT r0, r8 - CMP r0, r9 - MOVLT r0, r9 - STMIA r2!, {r6-r9} - SUBS r1, r1, #4 - BGE celt_pitch_xcorr_edsp_process4 -celt_pitch_xcorr_edsp_process2 - ADDS r1, r1, #2 - BLT celt_pitch_xcorr_edsp_process1a - SUBS r12, r3, #4 - ; {r10, r11} = {sum0, sum1} = {0, 0} - MOV r10, #0 - MOV r11, #0 - LDR r8, [r5], #4 - BLE celt_pitch_xcorr_edsp_process2_loop_done - LDR r6, [r4], #4 - LDR r9, [r5], #4 -celt_pitch_xcorr_edsp_process2_loop4 - SMLABB r10, r6, r8, r10 ; sum0 = MAC16_16(sum0, x_0, y_0) - LDR r7, [r4], #4 - SMLABT r11, r6, r8, r11 ; sum1 = MAC16_16(sum1, x_0, y_1) - SUBS r12, r12, #4 ; j-=4 - SMLATT r10, r6, r8, r10 ; sum0 = MAC16_16(sum0, x_1, y_1) - LDR r8, [r5], #4 - SMLATB r11, r6, r9, r11 ; sum1 = MAC16_16(sum1, x_1, y_2) - LDRGT r6, [r4], #4 - SMLABB r10, r7, r9, r10 ; sum0 = MAC16_16(sum0, x_2, y_2) - SMLABT r11, r7, r9, r11 ; sum1 = MAC16_16(sum1, x_2, y_3) - SMLATT r10, r7, r9, r10 ; sum0 = MAC16_16(sum0, x_3, y_3) - LDRGT r9, [r5], #4 - SMLATB r11, r7, r8, r11 ; sum1 = MAC16_16(sum1, x_3, y_4) - BGT celt_pitch_xcorr_edsp_process2_loop4 -celt_pitch_xcorr_edsp_process2_loop_done - ADDS r12, r12, #2 - BLE celt_pitch_xcorr_edsp_process2_1 - LDR r6, [r4], #4 - ; Stall - SMLABB r10, r6, r8, r10 ; sum0 = MAC16_16(sum0, x_0, y_0) - LDR r9, [r5], #4 - SMLABT r11, r6, r8, r11 ; sum1 = MAC16_16(sum1, x_0, y_1) - SUB r12, r12, #2 - SMLATT r10, r6, r8, r10 ; sum0 = MAC16_16(sum0, x_1, y_1) - MOV r8, r9 - SMLATB r11, r6, r9, r11 ; sum1 = MAC16_16(sum1, x_1, y_2) -celt_pitch_xcorr_edsp_process2_1 - LDRH r6, [r4], #2 - ADDS r12, r12, #1 - ; Stall - SMLABB r10, r6, r8, r10 ; sum0 = MAC16_16(sum0, x_0, y_0) - LDRHGT r7, [r4], #2 - SMLABT r11, r6, r8, r11 ; sum1 = MAC16_16(sum1, x_0, y_1) - BLE celt_pitch_xcorr_edsp_process2_done - LDRH r9, [r5], #2 - SMLABT r10, r7, r8, r10 ; sum0 = MAC16_16(sum0, x_0, y_1) - SMLABB r11, r7, r9, r11 ; sum1 = MAC16_16(sum1, x_0, y_2) -celt_pitch_xcorr_edsp_process2_done - ; Restore _x - SUB r4, r4, r3, LSL #1 - ; Restore and advance _y - SUB r5, r5, r3, LSL #1 - ; maxcorr = max(maxcorr, sum0) - CMP r0, r10 - ADD r5, r5, #2 - MOVLT r0, r10 - SUB r1, r1, #2 - ; maxcorr = max(maxcorr, sum1) - CMP r0, r11 - ; xcorr[i] = sum - STR r10, [r2], #4 - MOVLT r0, r11 - STR r11, [r2], #4 -celt_pitch_xcorr_edsp_process1a - ADDS r1, r1, #1 - BLT celt_pitch_xcorr_edsp_done - SUBS r12, r3, #4 - ; r14 = sum = 0 - MOV r14, #0 - BLT celt_pitch_xcorr_edsp_process1a_loop_done - LDR r6, [r4], #4 - LDR r8, [r5], #4 - LDR r7, [r4], #4 - LDR r9, [r5], #4 -celt_pitch_xcorr_edsp_process1a_loop4 - SMLABB r14, r6, r8, r14 ; sum = MAC16_16(sum, x_0, y_0) - SUBS r12, r12, #4 ; j-=4 - SMLATT r14, r6, r8, r14 ; sum = MAC16_16(sum, x_1, y_1) - LDRGE r6, [r4], #4 - SMLABB r14, r7, r9, r14 ; sum = MAC16_16(sum, x_2, y_2) - LDRGE r8, [r5], #4 - SMLATT r14, r7, r9, r14 ; sum = MAC16_16(sum, x_3, y_3) - LDRGE r7, [r4], #4 - LDRGE r9, [r5], #4 - BGE celt_pitch_xcorr_edsp_process1a_loop4 -celt_pitch_xcorr_edsp_process1a_loop_done - ADDS r12, r12, #2 - LDRGE r6, [r4], #4 - LDRGE r8, [r5], #4 - ; Stall - SMLABBGE r14, r6, r8, r14 ; sum = MAC16_16(sum, x_0, y_0) - SUBGE r12, r12, #2 - SMLATTGE r14, r6, r8, r14 ; sum = MAC16_16(sum, x_1, y_1) - ADDS r12, r12, #1 - LDRHGE r6, [r4], #2 - LDRHGE r8, [r5], #2 - ; Stall - SMLABBGE r14, r6, r8, r14 ; sum = MAC16_16(sum, *x, *y) - ; maxcorr = max(maxcorr, sum) - CMP r0, r14 - ; xcorr[i] = sum - STR r14, [r2], #4 - MOVLT r0, r14 -celt_pitch_xcorr_edsp_done - LDMFD sp!, {r4-r11, pc} - ENDP - -ENDIF - -END diff --git a/Engine/lib/opus/celt/arm/fft_arm.h b/Engine/lib/opus/celt/arm/fft_arm.h deleted file mode 100644 index 0b78175f3..000000000 --- a/Engine/lib/opus/celt/arm/fft_arm.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2015 Xiph.Org Foundation - Written by Viswanath Puttagunta */ -/** - @file fft_arm.h - @brief ARM Neon Intrinsic optimizations for fft using NE10 library - */ - -/* - 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(FFT_ARM_H) -#define FFT_ARM_H - -#include "kiss_fft.h" - -#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); - -void opus_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); - -#if !defined(OPUS_HAVE_RTCD) -#define OVERRIDE_OPUS_FFT (1) - -#define opus_fft_alloc_arch(_st, arch) \ - ((void)(arch), opus_fft_alloc_arm_neon(_st)) - -#define opus_fft_free_arch(_st, arch) \ - ((void)(arch), opus_fft_free_arm_neon(_st)) - -#define opus_fft(_st, _fin, _fout, arch) \ - ((void)(arch), opus_fft_neon(_st, _fin, _fout)) - -#define opus_ifft(_st, _fin, _fout, arch) \ - ((void)(arch), opus_ifft_neon(_st, _fin, _fout)) - -#endif /* OPUS_HAVE_RTCD */ - -#endif /* HAVE_ARM_NE10 */ - -#endif diff --git a/Engine/lib/opus/celt/arm/fixed_arm64.h b/Engine/lib/opus/celt/arm/fixed_arm64.h deleted file mode 100644 index c6fbd3db2..000000000 --- a/Engine/lib/opus/celt/arm/fixed_arm64.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2015 Vidyo */ -/* - 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 FIXED_ARM64_H -#define FIXED_ARM64_H - -#include - -#undef SIG2WORD16 -#define SIG2WORD16(x) (vqmovns_s32(PSHR32((x), SIG_SHIFT))) - -#endif diff --git a/Engine/lib/opus/celt/arm/fixed_armv4.h b/Engine/lib/opus/celt/arm/fixed_armv4.h deleted file mode 100644 index d84888a77..000000000 --- a/Engine/lib/opus/celt/arm/fixed_armv4.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (C) 2013 Xiph.Org Foundation and contributors */ -/* - 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 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; -} -#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); -} -#define MULT16_32_Q15(a, b) (MULT16_32_Q15_armv4(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. */ -#undef MAC16_32_Q15 -#define MAC16_32_Q15(c, a, b) ADD32(c, MULT16_32_Q15(a, b)) - -/** 16x32 multiply, followed by a 16-bit shift right and 32-bit add. - Result fits in 32 bits. */ -#undef MAC16_32_Q16 -#define MAC16_32_Q16(c, a, b) ADD32(c, MULT16_32_Q16(a, 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) - -#endif diff --git a/Engine/lib/opus/celt/arm/fixed_armv5e.h b/Engine/lib/opus/celt/arm/fixed_armv5e.h deleted file mode 100644 index 6bf73cbac..000000000 --- a/Engine/lib/opus/celt/arm/fixed_armv5e.h +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright (C) 2007-2009 Xiph.Org Foundation - Copyright (C) 2003-2008 Jean-Marc Valin - Copyright (C) 2007-2008 CSIRO - Copyright (C) 2013 Parrot */ -/* - 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 FIXED_ARMv5E_H -#define FIXED_ARMv5E_H - -#include "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_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; -} -#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); -} -#define MULT16_32_Q15(a, b) (MULT16_32_Q15_armv5e(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. */ -#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; -} -#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; -} -#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; -} -#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; -} -#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); -} -#define SIG2WORD16(x) (SIG2WORD16_armv6(x)) - -#endif /* OPUS_ARM_INLINE_MEDIA */ - -#endif diff --git a/Engine/lib/opus/celt/arm/kiss_fft_armv4.h b/Engine/lib/opus/celt/arm/kiss_fft_armv4.h deleted file mode 100644 index e4faad6f2..000000000 --- a/Engine/lib/opus/celt/arm/kiss_fft_armv4.h +++ /dev/null @@ -1,121 +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_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" -#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_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) - -#endif /* FIXED_POINT */ - -#endif /* KISS_FFT_ARMv4_H */ diff --git a/Engine/lib/opus/celt/arm/kiss_fft_armv5e.h b/Engine/lib/opus/celt/arm/kiss_fft_armv5e.h deleted file mode 100644 index 9eca183d7..000000000 --- a/Engine/lib/opus/celt/arm/kiss_fft_armv5e.h +++ /dev/null @@ -1,118 +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_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" -#endif - -#ifdef FIXED_POINT - -#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_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) - -#endif /* FIXED_POINT */ - -#endif /* KISS_FFT_GUTS_H */ diff --git a/Engine/lib/opus/celt/arm/mdct_arm.h b/Engine/lib/opus/celt/arm/mdct_arm.h deleted file mode 100644 index 14200bac4..000000000 --- a/Engine/lib/opus/celt/arm/mdct_arm.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) 2015 Xiph.Org Foundation - Written by Viswanath Puttagunta */ -/** - @file arm_mdct.h - @brief ARM Neon Intrinsic optimizations for mdct using NE10 library - */ - -/* - 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(MDCT_ARM_H) -#define MDCT_ARM_H - -#include "mdct.h" - -#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 */ -#endif /* HAVE_ARM_NE10 */ - -#endif diff --git a/Engine/lib/opus/celt/arm/pitch_arm.h b/Engine/lib/opus/celt/arm/pitch_arm.h deleted file mode 100644 index bed8b04ea..000000000 --- a/Engine/lib/opus/celt/arm/pitch_arm.h +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (c) 2010 Xiph.Org Foundation - * Copyright (c) 2013 Parrot */ -/* - 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(PITCH_ARM_H) -# define PITCH_ARM_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(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 -# 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 -# 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 -# 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 - -#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(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_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); - -# 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_NEON_INTR) - -# define OVERRIDE_PITCH_XCORR (1) -# define celt_pitch_xcorr celt_pitch_xcorr_float_neon - -# endif - -#endif /* end !FIXED_POINT */ - -#endif diff --git a/Engine/lib/opus/celt/arm/pitch_neon_intr.c b/Engine/lib/opus/celt/arm/pitch_neon_intr.c deleted file mode 100644 index 35cc46e2c..000000000 --- a/Engine/lib/opus/celt/arm/pitch_neon_intr.c +++ /dev/null @@ -1,281 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include -#include "pitch.h" - -#ifdef FIXED_POINT - -opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) -{ - int i; - opus_val32 xy; - int16x8_t x_s16x8, y_s16x8; - int32x4_t xy_s32x4 = vdupq_n_s32(0); - int64x2_t xy_s64x2; - int64x1_t xy_s64x1; - - for (i = 0; i < N - 7; i += 8) { - x_s16x8 = vld1q_s16(&x[i]); - y_s16x8 = vld1q_s16(&y[i]); - xy_s32x4 = vmlal_s16(xy_s32x4, vget_low_s16 (x_s16x8), vget_low_s16 (y_s16x8)); - xy_s32x4 = vmlal_s16(xy_s32x4, vget_high_s16(x_s16x8), vget_high_s16(y_s16x8)); - } - - if (N - i >= 4) { - const int16x4_t x_s16x4 = vld1_s16(&x[i]); - const int16x4_t y_s16x4 = vld1_s16(&y[i]); - xy_s32x4 = vmlal_s16(xy_s32x4, x_s16x4, y_s16x4); - i += 4; - } - - xy_s64x2 = vpaddlq_s32(xy_s32x4); - xy_s64x1 = vadd_s64(vget_low_s64(xy_s64x2), vget_high_s64(xy_s64x2)); - xy = vget_lane_s32(vreinterpret_s32_s64(xy_s64x1), 0); - - for (; i < N; i++) { - xy = MAC16_16(xy, x[i], y[i]); - } - -#ifdef OPUS_CHECK_ASM - celt_assert(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) -{ - int i; - opus_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); - int64x2_t xy01_s64x2, xy02_s64x2; - int64x1_t xy01_s64x1, xy02_s64x1; - - for (i = 0; i < N - 7; i += 8) { - x_s16x8 = vld1q_s16(&x[i]); - y01_s16x8 = vld1q_s16(&y01[i]); - y02_s16x8 = vld1q_s16(&y02[i]); - xy01_s32x4 = vmlal_s16(xy01_s32x4, vget_low_s16 (x_s16x8), vget_low_s16 (y01_s16x8)); - xy02_s32x4 = vmlal_s16(xy02_s32x4, vget_low_s16 (x_s16x8), vget_low_s16 (y02_s16x8)); - xy01_s32x4 = vmlal_s16(xy01_s32x4, vget_high_s16(x_s16x8), vget_high_s16(y01_s16x8)); - xy02_s32x4 = vmlal_s16(xy02_s32x4, vget_high_s16(x_s16x8), vget_high_s16(y02_s16x8)); - } - - if (N - i >= 4) { - const int16x4_t x_s16x4 = vld1_s16(&x[i]); - const int16x4_t y01_s16x4 = vld1_s16(&y01[i]); - const int16x4_t y02_s16x4 = vld1_s16(&y02[i]); - xy01_s32x4 = vmlal_s16(xy01_s32x4, x_s16x4, y01_s16x4); - xy02_s32x4 = vmlal_s16(xy02_s32x4, x_s16x4, y02_s16x4); - i += 4; - } - - xy01_s64x2 = vpaddlq_s32(xy01_s32x4); - xy02_s64x2 = vpaddlq_s32(xy02_s32x4); - xy01_s64x1 = vadd_s64(vget_low_s64(xy01_s64x2), vget_high_s64(xy01_s64x2)); - xy02_s64x1 = vadd_s64(vget_low_s64(xy02_s64x2), vget_high_s64(xy02_s64x2)); - xy01 = vget_lane_s32(vreinterpret_s32_s64(xy01_s64x1), 0); - xy02 = vget_lane_s32(vreinterpret_s32_s64(xy02_s64x1), 0); - - for (; i < N; i++) { - xy01 = MAC16_16(xy01, x[i], y01[i]); - xy02 = MAC16_16(xy02, x[i], y02[i]); - } - *xy1 = xy01; - *xy2 = xy02; - -#ifdef OPUS_CHECK_ASM - { - opus_val32 xy1_c, xy2_c; - dual_inner_prod_c(x, y01, y02, N, &xy1_c, &xy2_c); - celt_assert(xy1_c == *xy1); - celt_assert(xy2_c == *xy2); - } -#endif -} - -#else /* !FIXED_POINT */ - -/* ========================================================================== */ - -#ifdef OPUS_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 */ -/* 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; -} - -/* dual_inner_prod_neon_float_c_simulation() simulates the floating-point */ -/* operations of dual_inner_prod_neon(), and both functions should have bit */ -/* exact output. */ -static void dual_inner_prod_neon_float_c_simulation(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2, 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); -} - -#endif /* OPUS_CHECK_ASM */ - -/* ========================================================================== */ - -opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) -{ - int i; - opus_val32 xy; - float32x4_t xy_f32x4 = vdupq_n_f32(0); - float32x2_t xy_f32x2; - - for (i = 0; i < N - 7; i += 8) { - float32x4_t x_f32x4, y_f32x4; - x_f32x4 = vld1q_f32(&x[i]); - y_f32x4 = vld1q_f32(&y[i]); - xy_f32x4 = vmlaq_f32(xy_f32x4, x_f32x4, y_f32x4); - x_f32x4 = vld1q_f32(&x[i + 4]); - y_f32x4 = vld1q_f32(&y[i + 4]); - xy_f32x4 = vmlaq_f32(xy_f32x4, x_f32x4, y_f32x4); - } - - if (N - i >= 4) { - const float32x4_t x_f32x4 = vld1q_f32(&x[i]); - const float32x4_t y_f32x4 = vld1q_f32(&y[i]); - xy_f32x4 = vmlaq_f32(xy_f32x4, x_f32x4, y_f32x4); - i += 4; - } - - xy_f32x2 = vadd_f32(vget_low_f32(xy_f32x4), vget_high_f32(xy_f32x4)); - xy_f32x2 = vpadd_f32(xy_f32x2, xy_f32x2); - xy = vget_lane_f32(xy_f32x2, 0); - - for (; i < N; i++) { - xy = MAC16_16(xy, x[i], y[i]); - } - -#ifdef OPUS_CHECK_ASM - { - float err, res; - res = celt_inner_prod_neon_float_c_simulation(x, y, &err, N); - /*if (ABS32(res - xy) > err) fprintf(stderr, "%g %g %g\n", res, xy, err);*/ - celt_assert(ABS32(res - xy) <= err); - } -#endif - - return xy; -} - -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) -{ - int i; - opus_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; - - for (i = 0; i < N - 7; i += 8) { - float32x4_t x_f32x4, y01_f32x4, y02_f32x4; - x_f32x4 = vld1q_f32(&x[i]); - y01_f32x4 = vld1q_f32(&y01[i]); - y02_f32x4 = vld1q_f32(&y02[i]); - xy01_f32x4 = vmlaq_f32(xy01_f32x4, x_f32x4, y01_f32x4); - xy02_f32x4 = vmlaq_f32(xy02_f32x4, x_f32x4, y02_f32x4); - x_f32x4 = vld1q_f32(&x[i + 4]); - y01_f32x4 = vld1q_f32(&y01[i + 4]); - y02_f32x4 = vld1q_f32(&y02[i + 4]); - xy01_f32x4 = vmlaq_f32(xy01_f32x4, x_f32x4, y01_f32x4); - xy02_f32x4 = vmlaq_f32(xy02_f32x4, x_f32x4, y02_f32x4); - } - - if (N - i >= 4) { - const float32x4_t x_f32x4 = vld1q_f32(&x[i]); - const float32x4_t y01_f32x4 = vld1q_f32(&y01[i]); - const float32x4_t y02_f32x4 = vld1q_f32(&y02[i]); - xy01_f32x4 = vmlaq_f32(xy01_f32x4, x_f32x4, y01_f32x4); - xy02_f32x4 = vmlaq_f32(xy02_f32x4, x_f32x4, y02_f32x4); - i += 4; - } - - xy01_f32x2 = vadd_f32(vget_low_f32(xy01_f32x4), vget_high_f32(xy01_f32x4)); - xy02_f32x2 = vadd_f32(vget_low_f32(xy02_f32x4), vget_high_f32(xy02_f32x4)); - xy01_f32x2 = vpadd_f32(xy01_f32x2, xy01_f32x2); - xy02_f32x2 = vpadd_f32(xy02_f32x2, xy02_f32x2); - xy01 = vget_lane_f32(xy01_f32x2, 0); - xy02 = vget_lane_f32(xy02_f32x2, 0); - - for (; i < N; i++) { - xy01 = MAC16_16(xy01, x[i], y01[i]); - xy02 = MAC16_16(xy02, x[i], y02[i]); - } - *xy1 = xy01; - *xy2 = xy02; - -#ifdef OPUS_CHECK_ASM - { - opus_val32 xy1_c, xy2_c; - float err[2]; - dual_inner_prod_neon_float_c_simulation(x, y01, y02, N, &xy1_c, &xy2_c, err); - /*if (ABS32(xy1_c - *xy1) > err[0]) fprintf(stderr, "dual1 fail: %g %g %g\n", xy1_c, *xy1, err[0]); - if (ABS32(xy2_c - *xy2) > err[1]) fprintf(stderr, "dual2 fail: %g %g %g\n", xy2_c, *xy2, err[1]);*/ - celt_assert(ABS32(xy1_c - *xy1) <= err[0]); - celt_assert(ABS32(xy2_c - *xy2) <= err[1]); - } -#endif -} - -#endif /* FIXED_POINT */ diff --git a/Engine/lib/opus/celt/bands.c b/Engine/lib/opus/celt/bands.c deleted file mode 100644 index 5320ffab0..000000000 --- a/Engine/lib/opus/celt/bands.c +++ /dev/null @@ -1,1673 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Copyright (c) 2008-2009 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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "bands.h" -#include "modes.h" -#include "vq.h" -#include "cwrs.h" -#include "stack_alloc.h" -#include "os_support.h" -#include "mathops.h" -#include "rate.h" -#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; -} - -opus_uint32 celt_lcg_rand(opus_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; -} - -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); -} - -#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 = celt_ilog2(maxval) - 14 + (((m->logN[i]>>BITRES)+LM+1)>>1); - j=eBands[i]<0) - { - do { - sum = MAC16_16(sum, EXTRACT16(SHR32(X[j+c*N],shift)), - EXTRACT16(SHR32(X[j+c*N],shift))); - } while (++jnbEBands] = EPSILON+VSHR32(EXTEND32(celt_sqrt(sum)),-shift); - } else { - bandE[i+c*m->nbEBands] = EPSILON; - } - /*printf ("%f ", bandE[i+c*m->nbEBands]);*/ - } - } while (++ceBands; - N = M*m->shortMdctSize; - c=0; do { - i=0; do { - opus_val16 g; - int j,shift; - opus_val16 E; - shift = celt_zlog2(bandE[i+c*m->nbEBands])-13; - E = VSHR32(bandE[i+c*m->nbEBands], shift); - g = EXTRACT16(celt_rcp(SHL32(E,3))); - j=M*eBands[i]; do { - X[j+c*N] = MULT16_16_Q15(VSHR32(freq[j+c*N],shift-1),g); - } while (++jeBands; - N = m->shortMdctSize<nbEBands] = celt_sqrt(sum); - /*printf ("%f ", bandE[i+c*m->nbEBands]);*/ - } - } while (++ceBands; - N = M*m->shortMdctSize; - c=0; do { - for (i=0;inbEBands]); - for (j=M*eBands[i];jeBands; - 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]; - for (i=0;i>DB_SHIFT); - if (shift>31) - { - shift=0; - g=0; - } else { - /* Handle the fractional part. */ - g = celt_exp2_frac(lg&((1< 16384 we'd be likely to overflow, so we're - capping the gain here, which is equivalent to a cap of 18 on lg. - This shouldn't trigger unless the bitstream is already corrupted. */ - if (shift <= -2) - { - g = 16384; - shift = -2; - } - do { - *f++ = SHL32(MULT16_16(*x++, g), -shift); - } while (++jeBands[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; - -#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); - } -#else - thresh = .5f*celt_exp2(-.125f*depth); - sqrt_1 = celt_rsqrt(N0<nbEBands+i]; - prev2 = prev2logE[c*m->nbEBands+i]; - if (C==1) - { - prev1 = MAX16(prev1,prev1logE[m->nbEBands+i]); - prev2 = MAX16(prev2,prev2logE[m->nbEBands+i]); - } - Ediff = EXTEND32(logE[c*m->nbEBands+i])-EXTEND32(MIN16(prev1,prev2)); - Ediff = MAX32(0, Ediff); - -#ifdef FIXED_POINT - if (Ediff < 16384) - { - opus_val32 r32 = SHR32(celt_exp2(-EXTRACT16(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 = SHR32(MULT16_16_Q15(sqrt_1, r),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(-Ediff); - if (LM==3) - r *= 1.41421356f; - r = MIN16(thresh, r); - r = r*sqrt_1; -#endif - X = X_+c*size+(m->eBands[i]<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)); - a1 = DIV32_16(SHL32(EXTEND32(left),14),norm); - a2 = DIV32_16(SHL32(EXTEND32(right),14),norm); - for (j=0;j>1; - kr = celt_ilog2(Er)>>1; -#endif - t = VSHR32(El, (kl-7)<<1); - lgain = celt_rsqrt_norm(t); - t = VSHR32(Er, (kr-7)<<1); - rgain = celt_rsqrt_norm(t); - -#ifdef FIXED_POINT - 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; - } -#ifdef FUZZING - decision = rand()&0x3; - *tapset_decision=rand()%3; -#endif - return decision; -} - -/* Indexing table for converting from natural Hadamard to ordery Hadamard - This is essentially a bit-reversed Gray, on top of which we've added - 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, -}; - -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>= 1; - for (i=0;i>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; -}; - -struct split_ctx { - int inv; - int imid; - int iside; - int delta; - int itheta; - int qalloc; -}; - -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) -{ - int qn; - int itheta=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 = stereo_itheta(X, Y, stereo, N, ctx->arch); - } - 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; - } - } 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; - 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; - } - 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); - } - - ec_dec_update(ec, fl, fl+fs, ft); - } - } - celt_assert(itheta>=0); - itheta = celt_udiv((opus_int32)itheta*16384, qn); - 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; - } - 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; - sctx->qalloc = qalloc; -} -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] = SHR16(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_val16 gain, int fill) -{ - const unsigned char *cache; - int q; - int curr_bits; - int imid=0, iside=0; - int B0=B; - opus_val16 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); - imid = sctx.imid; - iside = sctx.iside; - delta = sctx.delta; - itheta = sctx.itheta; - qalloc = sctx.qalloc; -#ifdef FIXED_POINT - mid = imid; - side = iside; -#else - mid = (1.f/32768)*imid; - side = (1.f/32768)*iside; -#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, - MULT16_16_P15(gain,mid), fill); - rebalance = mbits - (rebalance-ctx->remaining_bits); - if (rebalance > 3<>B)<<(B0>>1); - } else { - cm = quant_partition(ctx, Y, N, sbits, B, next_lowband2, LM, - MULT16_16_P15(gain,side), fill>>B)<<(B0>>1); - rebalance = sbits - (rebalance-ctx->remaining_bits); - if (rebalance > 3<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, ctx->arch); - } else { - cm = 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 = celt_lcg_rand(ctx->seed); - X[j] = (celt_norm)((opus_int32)ctx->seed>>20); - } - 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, 10); - tmp = (ctx->seed)&0x8000 ? tmp : -tmp; - X[j] = lowband[j]+tmp; - } - cm = fill; - } - renormalise_vector(X, N, gain, ctx->arch); - } - } - } - } - - return cm; -} - - -/* 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_val16 gain, celt_norm *lowband_scratch, int fill) -{ - 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<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; - ec = ctx->ec; - - /* Special case for one sample */ - if (N==1) - { - return quant_band_n1(ctx, X, Y, lowband_out); - } - - orig_fill = fill; - - 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; - qalloc = sctx.qalloc; -#ifdef FIXED_POINT - mid = imid; - side = iside; -#else - mid = (1.f/32768)*imid; - side = (1.f/32768)*iside; -#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. */ - sign = x2[0]*y2[1] - 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, Q15ONE, - 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] = MULT16_16_Q15(mid, X[0]); - X[1] = MULT16_16_Q15(mid, X[1]); - Y[0] = MULT16_16_Q15(side, Y[0]); - Y[1] = MULT16_16_Q15(side, Y[1]); - tmp = X[0]; - X[0] = SUB16(tmp,Y[0]); - Y[0] = ADD16(tmp,Y[0]); - tmp = X[1]; - X[1] = SUB16(tmp,Y[1]); - Y[1] = ADD16(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) - { - /* 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, Q15ONE, - lowband_scratch, fill); - rebalance = mbits - (rebalance-ctx->remaining_bits); - 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 = quant_band(ctx, Y, N, sbits, B, NULL, LM, NULL, side, NULL, fill>>B); - rebalance = sbits - (rebalance-ctx->remaining_bits); - if (rebalance > 3<resynth) - { - if (N!=2) - stereo_merge(X, Y, mid, N, ctx->arch); - if (inv) - { - int j; - for (j=0;jeBands; - 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); -} -#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) -{ - 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); - 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; -#else - int resynth = !encode || theta_rdo; -#endif - 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->nbEBands-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; - /* 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; - 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)) - 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 - - 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; -#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; - 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); - dist0 = MULT16_32_Q15(w[0], celt_inner_prod(X_save, X, N, arch)) + MULT16_32_Q15(w[1], celt_inner_prod(Y_save, Y, N, arch)); - - /* Save first result. */ - cm2 = x_cm; - ec_save2 = *ec; - 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); - - /* Restore */ - *ec = ec_save; - 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); - dist1 = MULT16_32_Q15(w[0], celt_inner_prod(X_save, X, N, arch)) + MULT16_32_Q15(w[1], celt_inner_prod(Y_save, Y, N, arch)); - if (dist0 >= dist1) { - x_cm = cm2; - *ec = ec_save2; - 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); - } - } 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); - } - } 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, Q15ONE, lowband_scratch, x_cm|y_cm); - } - 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< -#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" - -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "unknown" -#endif - -#if defined(MIPSr1_ASM) -#include "mips/celt_mipsr1.h" -#endif - - -int resampling_factor(opus_int32 rate) -{ - int ret; - switch (rate) - { - case 48000: - ret = 1; - break; - case 24000: - ret = 2; - break; - case 16000: - ret = 3; - break; - case 12000: - ret = 4; - break; - case 8000: - ret = 6; - break; - default: -#ifndef CUSTOM_MODES - celt_assert(0); -#endif - ret = 0; - break; - } - return ret; -} - -#if !defined(OVERRIDE_COMB_FILTER_CONST) || defined(NON_STATIC_COMB_FILTER_CONST_C) -/* This version should be faster on ARM */ -#ifdef OPUS_ARM_ASM -#ifndef NON_STATIC_COMB_FILTER_CONST_C -static -#endif -void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, - opus_val16 g10, opus_val16 g11, opus_val16 g12) -{ - opus_val32 x0, x1, x2, x3, x4; - int i; - x4 = SHL32(x[-T-2], 1); - x3 = SHL32(x[-T-1], 1); - x2 = SHL32(x[-T], 1); - x1 = SHL32(x[-T+1], 1); - for (i=0;inbEBands;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 *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. */ -#ifdef FIXED_POINT - "-fixed" -#endif -#ifdef FUZZING - "-fuzzing" -#endif - ; -} diff --git a/Engine/lib/opus/celt/celt.h b/Engine/lib/opus/celt/celt.h deleted file mode 100644 index 24b6b2b52..000000000 --- a/Engine/lib/opus/celt/celt.h +++ /dev/null @@ -1,251 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - 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 - */ - -/* - 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_H -#define CELT_H - -#include "opus_types.h" -#include "opus_defines.h" -#include "opus_custom.h" -#include "entenc.h" -#include "entdec.h" -#include "arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define CELTEncoder OpusCustomEncoder -#define CELTDecoder OpusCustomDecoder -#define CELTMode OpusCustomMode - -#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]; -} AnalysisInfo; - -typedef struct { - int signalType; - int offset; -} SILKInfo; - -#define __celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr))) - -#define __celt_check_analysis_ptr(ptr) ((ptr) + ((ptr) - (const AnalysisInfo*)(ptr))) - -#define __celt_check_silkinfo_ptr(ptr) ((ptr) + ((ptr) - (const SILKInfo*)(ptr))) - -/* Encoder/decoder Requests */ - - -#define CELT_SET_PREDICTION_REQUEST 10002 -/** Controls the use of interframe prediction. - 0=Independent frames - 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_INPUT_CLIPPING_REQUEST 10004 -#define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, __opus_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_SET_CHANNELS_REQUEST 10008 -#define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, __opus_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_END_BAND_REQUEST 10012 -#define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, __opus_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_TONALITY_REQUEST 10018 -#define CELT_SET_TONALITY(x) CELT_SET_TONALITY_REQUEST, __opus_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_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 OPUS_SET_ENERGY_MASK_REQUEST 10026 -#define OPUS_SET_ENERGY_MASK(x) OPUS_SET_ENERGY_MASK_REQUEST, __opus_check_val16_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) - -/* Encoder stuff */ - -int celt_encoder_get_size(int channels); - -int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_val16 * 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); - - - -/* Decoder stuff */ - -int celt_decoder_get_size(int channels); - - -int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels); - -int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned char *data, - int len, opus_val16 * OPUS_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 - - -#ifdef CUSTOM_MODES -#define OPUS_CUSTOM_NOSTATIC -#else -#define OPUS_CUSTOM_NOSTATIC static OPUS_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 tapset_icdf[3]={2,1,0}; - -#ifdef CUSTOM_MODES -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, -}; - -static const unsigned char fromOpusTable[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 OPUS_INLINE int fromOpus(unsigned char c) -{ - if (c<0x80) - return -1; - else - return fromOpusTable[(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]; - -#if defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS) -void validate_celt_decoder(CELTDecoder *st); -#define VALIDATE_CELT_DECODER(st) validate_celt_decoder(st) -#else -#define VALIDATE_CELT_DECODER(st) -#endif - -int resampling_factor(opus_int32 rate); - -void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp, - int N, int CC, int upsample, const opus_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 opus_val16 *window, int overlap, int arch); - -#ifdef NON_STATIC_COMB_FILTER_CONST_C -void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, - opus_val16 g10, opus_val16 g11, opus_val16 g12); -#endif - -#ifndef OVERRIDE_COMB_FILTER_CONST -# define comb_filter_const(y, x, T, N, g10, g11, g12, arch) \ - ((void)(arch),comb_filter_const_c(y, x, T, N, g10, g11, g12)) -#endif - -void init_caps(const CELTMode *m,int *cap,int LM,int C); - -#ifdef RESYNTH -void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem); -void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], - opus_val16 *oldBandE, int start, int effEnd, int C, int CC, int isTransient, - int LM, int downsample, int silence); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* CELT_H */ diff --git a/Engine/lib/opus/celt/celt_decoder.c b/Engine/lib/opus/celt/celt_decoder.c deleted file mode 100644 index 883dae15d..000000000 --- a/Engine/lib/opus/celt/celt_decoder.c +++ /dev/null @@ -1,1375 +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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define CELT_DECODER_C - -#include "cpu_support.h" -#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" - -/* The maximum pitch lag to allow in the pitch-based PLC. It's possible to save - CPU time in the PLC pitch search by making this smaller than MAX_PERIOD. The - current value corresponds to a pitch of 66.67 Hz. */ -#define PLC_PITCH_LAG_MAX (720) -/* The minimum pitch lag to allow in the pitch-based PLC. This corresponds to a - pitch of 480 Hz. */ -#define PLC_PITCH_LAG_MIN (100) - -#if defined(SMALL_FOOTPRINT) && defined(FIXED_POINT) -#define NORM_ALIASING_HACK -#endif -/**********************************************************************/ -/* */ -/* DECODER */ -/* */ -/**********************************************************************/ -#define DECODE_BUFFER_SIZE 2048 - -/** 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 arch; - - /* 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 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; - - celt_sig preemph_memD[2]; - - celt_sig _decode_mem[1]; /* Size = channels*(DECODE_BUFFER_SIZE+mode->overlap) */ - /* opus_val16 lpc[], Size = channels*LPC_ORDER */ - /* opus_val16 oldEBands[], Size = 2*mode->nbEBands */ - /* opus_val16 oldLogE[], Size = 2*mode->nbEBands */ - /* opus_val16 oldLogE2[], Size = 2*mode->nbEBands */ - /* opus_val16 backgroundLogE[], Size = 2*mode->nbEBands */ -}; - -#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) -{ -#ifndef CUSTOM_MODES - celt_assert(st->mode == opus_custom_mode_create(48000, 960, NULL)); - celt_assert(st->overlap == 120); - celt_assert(st->end <= 21); -#else -/* From Section 4.3 in the spec: "The normal CELT layer uses 21 of those bands, - though Opus Custom (see Section 6.2) may use a different number of bands" - - Check if it's within the maximum number of Bark frequency bands instead */ - celt_assert(st->end <= 25); -#endif - celt_assert(st->channels == 1 || st->channels == 2); - celt_assert(st->stream_channels == 1 || st->stream_channels == 2); - celt_assert(st->downsample > 0); - celt_assert(st->start == 0 || st->start == 17); - celt_assert(st->start < st->end); -#ifdef OPUS_ARCHMASK - celt_assert(st->arch >= 0); - celt_assert(st->arch <= OPUS_ARCHMASK); -#endif - 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); - 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) -{ - const CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); - return opus_custom_decoder_get_size(mode, channels); -} - -OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_get_size(const CELTMode *mode, int channels) -{ - int size = sizeof(struct CELTDecoder) - + (channels*(DECODE_BUFFER_SIZE+mode->overlap)-1)*sizeof(celt_sig) - + channels*LPC_ORDER*sizeof(opus_val16) - + 4*2*mode->nbEBands*sizeof(opus_val16); - return size; -} - -#ifdef CUSTOM_MODES -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; -} -#endif /* CUSTOM_MODES */ - -int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels) -{ - int ret; - 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; -} - -OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels) -{ - if (channels < 0 || channels > 2) - return OPUS_BAD_ARG; - - if (st==NULL) - return OPUS_ALLOC_FAIL; - - OPUS_CLEAR((char*)st, opus_custom_decoder_get_size(mode, 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(); - - opus_custom_decoder_ctl(st, OPUS_RESET_STATE); - - return OPUS_OK; -} - -#ifdef CUSTOM_MODES -void opus_custom_decoder_destroy(CELTDecoder *st) -{ - opus_free(st); -} -#endif /* CUSTOM_MODES */ - -#ifndef CUSTOM_MODES -/* 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_val16 *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;joverlap; - 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; - denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M, - downsample, silence); - /* 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, - downsample, silence); - /* Use the output buffer as temp array before downmixing. */ - denormalise_bands(mode, X+N, freq2, oldBandE+nbEBands, start, effEnd, M, - downsample, silence); - 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, - downsample, silence); - for (b=0;bmdct, &freq[b], out_syn[c]+NB*b, mode->window, overlap, shift, B, arch); - } while (++cstorage*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;i>1, opus_val16 ); - pitch_downsample(decode_mem, lp_pitch_buf, - DECODE_BUFFER_SIZE, C, 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 pitch_index; -} - -static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM) -{ - int c; - int i; - const int C = st->channels; - celt_sig *decode_mem[2]; - celt_sig *out_syn[2]; - opus_val16 *lpc; - opus_val16 *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; - const OpusCustomMode *mode; - int nbEBands; - int overlap; - int start; - int loss_duration; - int noise_based; - const opus_int16 *eBands; - SAVE_STACK; - - 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); - oldBandE = lpc+C*LPC_ORDER; - oldLogE = oldBandE + 2*nbEBands; - oldLogE2 = oldLogE + 2*nbEBands; - backgroundLogE = oldLogE2 + 2*nbEBands; - - loss_duration = st->loss_duration; - start = st->start; - noise_based = loss_duration >= 40 || start != 0 || st->skip_plc; - if (noise_based) - { - /* Noise-based PLC/CNG */ -#ifdef NORM_ALIASING_HACK - celt_norm *X; -#else - VARDECL(celt_norm, X); -#endif - opus_uint32 seed; - int end; - int effEnd; - opus_val16 decay; - end = st->end; - effEnd = IMAX(start, IMIN(end, mode->effEBands)); - -#ifdef NORM_ALIASING_HACK - /* This is an ugly hack that breaks aliasing rules and would be easily broken, - but it saves almost 4kB of stack. */ - X = (celt_norm*)(out_syn[C-1]+overlap/2); -#else - ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ -#endif - c=0; do { - OPUS_MOVE(decode_mem[c], decode_mem[c]+N, - DECODE_BUFFER_SIZE-N+(overlap>>1)); - } while (++crng; - for (c=0;c>20); - } - renormalise_vector(X+boffs, blen, Q15ONE, st->arch); - } - } - st->rng = seed; - - celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch); - } else { - int exc_length; - /* Pitch-based PLC */ - const opus_val16 *window; - opus_val16 *exc; - opus_val16 fade = Q15ONE; - int pitch_index; - VARDECL(opus_val32, etmp); - VARDECL(opus_val16, _exc); - VARDECL(opus_val16, fir_tmp); - - if (loss_duration == 0) - { - st->last_pitch_index = pitch_index = celt_plc_pitch_search(decode_mem, C, st->arch); - } else { - pitch_index = st->last_pitch_index; - fade = QCONST16(.8f,15); - } - - /* 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(etmp, overlap, opus_val32); - ALLOC(_exc, MAX_PERIOD+LPC_ORDER, opus_val16); - ALLOC(fir_tmp, exc_length, opus_val16); - exc = _exc+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;iarch); - /* Add a noise floor of -40 dB. */ -#ifdef FIXED_POINT - ac[0] += SHR32(ac[0],13); -#else - ac[0] *= 1.0001f; -#endif - /* Use lag windowing to stabilize the Levinson-Durbin recursion. */ - for (i=1;i<=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]); -#else - ac[i] -= ac[i]*(0.008f*0.008f)*i*i; -#endif - } - _celt_lpc(lpc+c*LPC_ORDER, ac, 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; -#ifdef FIXED_POINT - int shift = IMAX(0,2*celt_zlog2(celt_maxabs16(&exc[MAX_PERIOD-exc_length], exc_length))-20); -#endif - decay_length = exc_length>>1; - for (i=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], - SIG_SHIFT); - S1 += SHR32(MULT16_16(tmp, tmp), 10); - } - { - opus_val16 lpc_mem[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); -#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))) -#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)) -#endif - { - for (i=0;ipostfilter_period, st->postfilter_period, overlap, - -st->postfilter_gain, -st->postfilter_gain, - st->postfilter_tapset, 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;iloss_duration = IMIN(10000, loss_duration+(1<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; - opus_val16 max_background_increase; - ALLOC_STACK; - - 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; - - lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+overlap)*CC); - oldBandE = lpc+CC*LPC_ORDER; - oldLogE = oldBandE + 2*nbEBands; - oldLogE2 = oldLogE + 2*nbEBands; - backgroundLogE = oldLogE2 + 2*nbEBands; - -#ifdef CUSTOM_MODES - if (st->signalling && data!=NULL) - { - int data0=data[0]; - /* Convert "standard mode" to Opus header */ - if (mode->Fs==48000 && mode->shortMdctSize==120) - { - 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); - data++; - len--; - if (LM>mode->maxLM) - return OPUS_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); - deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum); - RESTORE_STACK; - return frame_size/st->downsample; - } - - /* Check if there are at least two packets received consecutively before - * turning on the pitch-based PLC */ - st->skip_plc = st->loss_duration != 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; - /* Get band energies */ - 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)<rng, 0, - st->arch, st->disable_inv); - - if (anti_collapse_rsv > 0) - { - anti_collapse_on = ec_dec_bits(dec, 1); - } - - unquant_energy_finalise(mode, start, end, 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, - start, end, oldBandE, oldLogE, oldLogE2, pulses, st->rng, st->arch); - - if (silence) - { - for (i=0;idownsample, 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); - 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, - 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] = MIN16(oldLogE[i], oldBandE[i]); - } - /* In normal circumstances, we only allow the noise floor to increase by - up to 2.4 dB/second, but when we're in DTX we give the weight of - all missing packets to the update packet. */ - max_background_increase = IMIN(160, st->loss_duration+M)*QCONST16(0.001f,DB_SHIFT); - for (i=0;i<2*nbEBands;i++) - backgroundLogE[i] = MIN16(backgroundLogE[i] + max_background_increase, oldBandE[i]); - /* In case start or end were to change */ - c=0; do - { - for (i=0;irng = dec->rng; - - deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum); - st->loss_duration = 0; - RESTORE_STACK; - if (ec_tell(dec) > 8*len) - return OPUS_INTERNAL_ERROR; - if(ec_get_error(dec)) - st->error = 1; - return frame_size/st->downsample; -} - - -#ifdef CUSTOM_MODES - -#ifdef FIXED_POINT -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); -} - -#ifndef DISABLE_FLOAT_API -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_int16, out); - ALLOC_STACK; - - if (pcm==NULL) - return OPUS_BAD_ARG; - - C = st->channels; - N = frame_size; - - ALLOC(out, C*N, opus_int16); - 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, celt_sig); - - ret=celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); - - if (ret>0) - for (j=0;j=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; - opus_val16 *lpc, *oldBandE, *oldLogE, *oldLogE2; - lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*st->channels); - oldBandE = lpc+st->channels*LPC_ORDER; - 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]=-QCONST16(28.f,DB_SHIFT); - st->skip_plc = 1; - } - 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; -bad_arg: - va_end(ap); - return OPUS_BAD_ARG; -bad_request: - va_end(ap); - return OPUS_UNIMPLEMENTED; -} diff --git a/Engine/lib/opus/celt/celt_encoder.c b/Engine/lib/opus/celt/celt_encoder.c deleted file mode 100644 index 637d442cf..000000000 --- a/Engine/lib/opus/celt/celt_encoder.c +++ /dev/null @@ -1,2613 +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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define CELT_ENCODER_C - -#include "cpu_support.h" -#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" - - -/** 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; - - /* 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; -#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; - opus_val16 *energy_mask; - opus_val16 spec_avg; - -#ifdef RESYNTH - /* +MAX_PERIOD/2 to make space for overlap */ - celt_sig syn_mem[2][2*MAX_PERIOD+MAX_PERIOD/2]; -#endif - - celt_sig in_mem[1]; /* Size = channels*mode->overlap */ - /* celt_sig prefilter_mem[], Size = channels*COMBFILTER_MAXPERIOD */ - /* opus_val16 oldBandE[], Size = channels*mode->nbEBands */ - /* opus_val16 oldLogE[], Size = channels*mode->nbEBands */ - /* opus_val16 oldLogE2[], Size = channels*mode->nbEBands */ - /* opus_val16 energyError[], Size = channels*mode->nbEBands */ -}; - -int celt_encoder_get_size(int channels) -{ - CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); - return opus_custom_encoder_get_size(mode, channels); -} - -OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int channels) -{ - int size = sizeof(struct CELTEncoder) - + (channels*mode->overlap-1)*sizeof(celt_sig) /* celt_sig in_mem[channels*mode->overlap]; */ - + channels*COMBFILTER_MAXPERIOD*sizeof(celt_sig) /* celt_sig prefilter_mem[channels*COMBFILTER_MAXPERIOD]; */ - + 4*channels*mode->nbEBands*sizeof(opus_val16); /* opus_val16 oldBandE[channels*mode->nbEBands]; */ - /* opus_val16 oldLogE[channels*mode->nbEBands]; */ - /* opus_val16 oldLogE2[channels*mode->nbEBands]; */ - /* opus_val16 energyError[channels*mode->nbEBands]; */ - return size; -} - -#ifdef CUSTOM_MODES -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; -} -#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; - - if (st==NULL || mode==NULL) - return OPUS_ALLOC_FAIL; - - OPUS_CLEAR((char*)st, opus_custom_encoder_get_size(mode, 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->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; - - opus_custom_encoder_ctl(st, OPUS_RESET_STATE); - - return OPUS_OK; -} - -#ifdef CUSTOM_MODES -int opus_custom_encoder_init(CELTEncoder *st, const CELTMode *mode, int channels) -{ - return opus_custom_encoder_init_arch(st, mode, channels, opus_select_arch()); -} -#endif - -int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels, - int arch) -{ - int ret; - 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; -} - -#ifdef CUSTOM_MODES -void opus_custom_encoder_destroy(CELTEncoder *st) -{ - opus_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) -{ - 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. */ -#ifdef FIXED_POINT - 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; - 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) - { -#ifdef FIXED_POINT - 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. */ -#ifdef FIXED_POINT - /* FIXME: Use PSHR16() instead */ - tmp[i] = mem0 + PSHR32(tmp[i]-mem0,3); -#else - tmp[i] = mem0 + MULT16_16_P15(QCONST16(0.125f,15),tmp[i]-mem0); -#endif - mem0 = tmp[i]; - maxE = MAX16(maxE, mem0); - } - /*for (i=0;i>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; - /* 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; -#ifdef FUZZING - is_transient = rand()&0x1; -#endif - /*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(opus_val16 *newE, opus_val16 *oldE, int nbEBands, - int start, int end, int C) -{ - int i, c; - opus_val32 mean_diff=0; - opus_val16 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] = MAX16(spread_old[i], spread_old[i+1]-QCONST16(1.0f, DB_SHIFT)); - /* Compute mean increase */ - c=0; do { - for (i=IMAX(2,start);i QCONST16(1.f, DB_SHIFT); -} - -/** 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, - 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; -#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;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(&X[m->eBands[i]<eBands[i]<eBands[i+1]-m->eBands[i])<eBands[i]<eBands[i]<eBands[i+1]-m->eBands[i])<nbEBands]*(opus_int32)(2+2*i-end); - } - } while (++cvalid) - { - trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8), - (opus_val16)(QCONST16(2.f, 8)*(analysis->tonality_slope+.05f)))); - } -#else - (void)analysis; -#endif - -#ifdef FIXED_POINT - trim_index = PSHR32(trim, 8); -#else - trim_index = (int)floor(.5f+trim); -#endif - trim_index = IMAX(0, IMIN(10, trim_index)); - /*printf("%d\n", trim_index);*/ -#ifdef FUZZING - trim_index = rand()%11; -#endif - 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); -} - -#define MSWAP(a,b) do {opus_val16 tmp = a;a=b;b=tmp;} while(0) -static opus_val16 median_of_5(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) - { - MSWAP(t0, t3); - MSWAP(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); - } -} - -static opus_val16 median_of_3(const opus_val16 *x) -{ - opus_val16 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 opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16 *bandLogE2, - 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, opus_val16 *surround_dynalloc, - AnalysisInfo *analysis, int *importance, int *spread_weight) -{ - int i, c; - opus_int32 tot_boost=0; - opus_val16 maxDepth; - VARDECL(opus_val16, follower); - VARDECL(opus_val16, noise_floor); - SAVE_STACK; - ALLOC(follower, C*nbEBands, opus_val16); - ALLOC(noise_floor, C*nbEBands, opus_val16); - OPUS_CLEAR(offsets, nbEBands); - /* Dynamic allocation code */ - maxDepth=-QCONST16(31.9f, DB_SHIFT); - for (i=0;i=0;i--) - mask[i] = MAX16(mask[i], mask[i+1] - QCONST16(3.f, DB_SHIFT)); - for (i=0;i> shift; - } - /*for (i=0;i 50 && LM>=1 && !lfe) - { - int last=0; - c=0;do - { - opus_val16 offset; - opus_val16 tmp; - opus_val16 *f; - f = &follower[c*nbEBands]; - f[0] = bandLogE2[c*nbEBands]; - for (i=1;i bandLogE2[c*nbEBands+i-1]+QCONST16(.5f,DB_SHIFT)) - last=i; - f[i] = MIN16(f[i-1]+QCONST16(1.5f,DB_SHIFT), bandLogE2[c*nbEBands+i]); - } - for (i=last-1;i>=0;i--) - f[i] = MIN16(f[i], MIN16(f[i+1]+QCONST16(2.f,DB_SHIFT), bandLogE2[c*nbEBands+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 = QCONST16(1.f, DB_SHIFT); - for (i=2;i=12) - follower[i] = HALF16(follower[i]); - } -#ifdef DISABLE_FLOAT_API - (void)analysis; -#else - if (analysis->valid) - { - for (i=start;ileak_boost[i]; - } -#endif - for (i=start;i 48) { - boost = (int)SHR32(EXTEND32(follower[i])*8,DB_SHIFT); - boost_bits = (boost*width<>BITRES>>3 > 2*effectiveBytes/3) - { - opus_int32 cap = ((2*effectiveBytes/3)<mode; - overlap = mode->overlap; - ALLOC(_pre, CC*(N+COMBFILTER_MAXPERIOD), celt_sig); - - pre[0] = _pre; - pre[1] = _pre + (N+COMBFILTER_MAXPERIOD); - - - c=0; do { - OPUS_COPY(pre[c], prefilter_mem+c*COMBFILTER_MAXPERIOD, COMBFILTER_MAXPERIOD); - OPUS_COPY(pre[c]+COMBFILTER_MAXPERIOD, in+c*(N+overlap)+overlap, N); - } while (++c>1, opus_val16); - - pitch_downsample(pre, pitch_buf, COMBFILTER_MAXPERIOD+N, CC, 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+(COMBFILTER_MAXPERIOD>>1), pitch_buf, N, - COMBFILTER_MAXPERIOD-3*COMBFILTER_MINPERIOD, &pitch_index, - st->arch); - pitch_index = COMBFILTER_MAXPERIOD-pitch_index; - - gain1 = remove_doubling(pitch_buf, COMBFILTER_MAXPERIOD, COMBFILTER_MINPERIOD, - N, &pitch_index, st->prefilter_period, st->prefilter_gain, st->arch); - if (pitch_index > COMBFILTER_MAXPERIOD-2) - pitch_index = COMBFILTER_MAXPERIOD-2; - 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); -#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); - 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; - -#ifdef FIXED_POINT - 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 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); - if (offset) - comb_filter(in+c*(N+overlap)+overlap, pre[c]+COMBFILTER_MAXPERIOD, - 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]+COMBFILTER_MAXPERIOD+offset, - st->prefilter_period, pitch_index, N-offset, -st->prefilter_gain, -gain1, - st->prefilter_tapset, prefilter_tapset, mode->window, overlap, st->arch); - OPUS_COPY(st->in_mem+c*(overlap), in+c*(N+overlap)+N, overlap); - - if (N>COMBFILTER_MAXPERIOD) - { - OPUS_COPY(prefilter_mem+c*COMBFILTER_MAXPERIOD, pre[c]+N, COMBFILTER_MAXPERIOD); - } else { - OPUS_MOVE(prefilter_mem+c*COMBFILTER_MAXPERIOD, prefilter_mem+c*COMBFILTER_MAXPERIOD+N, COMBFILTER_MAXPERIOD-N); - OPUS_COPY(prefilter_mem+c*COMBFILTER_MAXPERIOD+COMBFILTER_MAXPERIOD-N, pre[c]+COMBFILTER_MAXPERIOD, N); - } - } while (++cnbEBands; - 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 && !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; - } -#else - (void)analysis; - (void)pitch_change; -#endif - - if (has_surround_mask&&!lfe) - { - opus_int32 surround_target = target + (opus_int32)SHR32(MULT16_16(surround_masking,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]<>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(temporal_vbr, amount), DB_SHIFT); - 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; -} - -int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * 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(opus_val16, bandLogE); - VARDECL(opus_val16, bandLogE2); - VARDECL(int, fine_quant); - VARDECL(opus_val16, 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; - opus_val16 *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; - 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; - opus_val16 maxDepth; - const OpusCustomMode *mode; - int nbEBands; - int overlap; - const opus_int16 *eBands; - int secondMdct; - int signalBandwidth; - int transient_got_disabled=0; - opus_val16 surround_masking=0; - opus_val16 temporal_vbr=0; - opus_val16 surround_trim = 0; - opus_int32 equiv_rate; - int hybrid; - int weak_transient = 0; - int enable_tf_analysis; - VARDECL(opus_val16, surround_dynalloc); - 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; - - prefilter_mem = st->in_mem+CC*(overlap); - oldBandE = (opus_val16*)(st->in_mem+CC*(overlap+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; - } - -#ifdef CUSTOM_MODES - 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 */ - if (mode->Fs==48000 && mode->shortMdctSize==120) - { - int c0 = toOpus(compressed[0]); - if (c0<0) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - compressed[0] = c0; - } - compressed++; - nbCompressedBytes--; - } -#else - celt_assert(st->signalling==0); -#endif - - /* Can't produce more than 1275 output bytes */ - nbCompressedBytes = IMIN(nbCompressedBytes,1275); - nbAvailableBytes = nbCompressedBytes - nbFilledBytes; - - if (st->vbr && st->bitrate!=OPUS_BITRATE_MAX) - { - opus_int32 den=mode->Fs>>BITRES; - vbr_rate=(st->bitrate*frame_size+(den>>1))/den; -#ifdef CUSTOM_MODES - if (st->signalling) - vbr_rate -= 8<>(3+BITRES); - } else { - opus_int32 tmp; - vbr_rate = 0; - tmp = st->bitrate*frame_size; - if (tell>1) - tmp += tell; - if (st->bitrate!=OPUS_BITRATE_MAX) - nbCompressedBytes = IMAX(2, IMIN(nbCompressedBytes, - (tmp+4*mode->Fs)/(8*mode->Fs)-!!st->signalling)); - effectiveBytes = nbCompressedBytes - nbFilledBytes; - } - equiv_rate = ((opus_int32)nbCompressedBytes*8*50 << (3-LM)) - (40*C+20)*((400>>LM) - 50); - 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)), - 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_maxabs16(pcm, C*(N-overlap)/st->upsample)); - st->overlap_max=celt_maxabs16(pcm+C*(N-overlap)/st->upsample, C*overlap/st->upsample); - sample_max=MAX32(sample_max, st->overlap_max); -#ifdef FIXED_POINT - silence = (sample_max==0); -#else - silence = (sample_max <= (opus_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); - } - /* 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; -#ifndef FIXED_POINT - need_clip = st->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); - } while (++clfe&&nbAvailableBytes>3) || nbAvailableBytes>12*C) && !hybrid && !silence && !st->disable_pf - && st->complexity >= 5; - - prefilter_tapset = st->tapset_decision; - pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pitch_index, &gain1, &qg, enabled, nbAvailableBytes, &st->analysis); - 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<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, - &tf_estimate, &tf_chan, allow_weak_transients, &weak_transient); - } - if (LM>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, opus_val16); - - secondMdct = shortBlocks && st->complexity>=8; - ALLOC(bandLogE2, C*nbEBands, opus_val16); - 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], - QCONST16(.25f, DB_SHIFT)), -QCONST16(2.0f, DB_SHIFT)); - if (mask > 0) - mask = HALF16(mask); - mask_avg += MULT16_16(mask, eBands[i+1]-eBands[i]); - count += eBands[i+1]-eBands[i]; - diff += MULT16_16(mask, 1+2*i-mask_end); - } - } - celt_assert(count>0); - mask_avg = DIV32_16(mask_avg,count); - mask_avg += QCONST16(.2f, DB_SHIFT); - diff = diff*6/(C*(mask_end-1)*(mask_end+1)*mask_end); - /* Again, being conservative */ - diff = HALF32(diff); - diff = MAX32(MIN32(diff, QCONST32(.031f, DB_SHIFT)), -QCONST32(.031f, DB_SHIFT)); - /* 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 = MIN16(unmask, QCONST16(.0f, DB_SHIFT)); - unmask -= lin; - if (unmask > QCONST16(.25f, DB_SHIFT)) - { - surround_dynalloc[i] = unmask - QCONST16(.25f, DB_SHIFT); - 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 += QCONST16(.25f, DB_SHIFT); - 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) - { - opus_val16 follow=-QCONST16(10.0f,DB_SHIFT); - opus_val32 frame_avg=0; - opus_val16 offset = shortBlocks?HALF16(SHL16(LM, DB_SHIFT)):0; - for(i=start;ispec_avg); - temporal_vbr = MIN16(QCONST16(3.f, DB_SHIFT), MAX16(-QCONST16(1.5f, DB_SHIFT), temporal_vbr)); - st->spec_avg += MULT16_16_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; - - ALLOC(offsets, nbEBands, int); - ALLOC(importance, nbEBands, int); - ALLOC(spread_weight, nbEBands, int); - - maxDepth = dynalloc_analysis(bandLogE, bandLogE2, 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); - - 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;iforce_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 - 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. */ -#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, - &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); - } - - /* 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;iintensity = hysteresis_decision((opus_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, - 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); - } - - /* 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; - opus_int32 min_allowed; - 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,1275>>(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, - 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); - } 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)) + 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)); - - nbAvailableBytes = (target+(1<<(BITRES+2)))>>(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); - } - - /* 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)<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, - 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; - - quant_fine_energy(mode, start, end, oldBandE, error, fine_quant, enc, C); - - /* Residual quantisation */ - ALLOC(collapse_masks, C*nbEBands, unsigned char); - 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); - - 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); - } - quant_energy_finalise(mode, start, end, oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_tell(enc), enc, C); - OPUS_CLEAR(energyError, nbEBands*CC); - c=0; - do { - for (i=start;irng); - } - - c=0; do { - OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, 2*MAX_PERIOD-N+overlap/2); - } while (++csyn_mem[c]+2*MAX_PERIOD-N; - } while (++cupsample, 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, - st->prefilter_gain_old, st->prefilter_gain, st->prefilter_tapset_old, st->prefilter_tapset, - mode->window, overlap); - if (LM!=0) - 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); - } while (++cupsample, mode->preemph, st->preemph_memD); - st->prefilter_period_old = st->prefilter_period; - st->prefilter_gain_old = st->prefilter_gain; - st->prefilter_tapset_old = st->prefilter_tapset; - } -#endif - - 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) { - 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 CUSTOM_MODES - if (st->signalling) - nbCompressedBytes++; -#endif - - RESTORE_STACK; - if (ec_get_error(enc)) - return OPUS_INTERNAL_ERROR; - else - return nbCompressedBytes; -} - - -#ifdef CUSTOM_MODES - -#ifdef FIXED_POINT -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); -} - -#ifndef DISABLE_FLOAT_API -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_int16, in); - ALLOC_STACK; - - if (pcm==NULL) - return OPUS_BAD_ARG; - - C = st->channels; - N = frame_size; - ALLOC(in, C*N, opus_int16); - - for (j=0;jchannels; - N=frame_size; - ALLOC(in, C*N, celt_sig); - for (j=0;j10) - 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, 260000*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; - case OPUS_RESET_STATE: - { - int i; - opus_val16 *oldBandE, *oldLogE, *oldLogE2; - oldBandE = (opus_val16*)(st->in_mem+st->channels*(st->mode->overlap+COMBFILTER_MAXPERIOD)); - 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]=-QCONST16(28.f,DB_SHIFT); - 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; -#ifdef CUSTOM_MODES - 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: - { - opus_val16 *value = va_arg(ap, opus_val16*); - st->energy_mask = value; - } - break; - default: - goto bad_request; - } - va_end(ap); - return OPUS_OK; -bad_arg: - va_end(ap); - return OPUS_BAD_ARG; -bad_request: - va_end(ap); - return OPUS_UNIMPLEMENTED; -} diff --git a/Engine/lib/opus/celt/celt_lpc.c b/Engine/lib/opus/celt/celt_lpc.c deleted file mode 100644 index f91721bca..000000000 --- a/Engine/lib/opus/celt/celt_lpc.c +++ /dev/null @@ -1,344 +0,0 @@ -/* Copyright (c) 2009-2010 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 "celt_lpc.h" -#include "stack_alloc.h" -#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]; -#ifdef FIXED_POINT - opus_val32 lpc[LPC_ORDER]; -#else - float *lpc = _lpc; -#endif - - OPUS_CLEAR(lpc, p); -#ifdef FIXED_POINT - if (ac[0] != 0) -#else - if (ac[0] > 1e-10f) -#endif - { - for (i = 0; i < p; i++) { - /* Sum up this iteration's reflection coefficient */ - opus_val32 rr = 0; - for (j = 0; j < i; j++) - rr += MULT32_32_Q31(lpc[j],ac[i - j]); - rr += SHR32(ac[i + 1],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); - } - - 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; -#else - 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; - - for (iter = 0; iter < 10; iter++) { - maxabs = 0; - for (i = 0; i < p; i++) { - absval = ABS32(lpc[i]); - if (absval > maxabs) { - maxabs = absval; - idx = i; - } - } - maxabs = PSHR32(maxabs, 13); /* Q25->Q12 */ - - if (maxabs > 32767) { - maxabs = MIN32(maxabs, 163838); - chirp_Q16 = QCONST32(0.999, 16) - DIV32(SHL32(maxabs - 32767, 14), - SHR32(MULT32_32_32(maxabs, idx + 1), 2)); - chirp_minus_one_Q16 = chirp_Q16 - 65536; - - /* Apply bandwidth expansion. */ - for (i = 0; i < p - 1; i++) { - lpc[i] = MULT32_32_Q16(chirp_Q16, lpc[i]); - chirp_Q16 += PSHR32(MULT32_32_32(chirp_Q16, chirp_minus_one_Q16), 16); - } - lpc[p - 1] = MULT32_32_Q16(chirp_Q16, lpc[p - 1]); - } else { - break; - } - } - - if (iter == 10) { - /* If the coeffs still do not fit into the 16 bit range after 10 iterations, - fall back to the A(z)=1 filter. */ - OPUS_CLEAR(lpc, p); - _lpc[0] = 4096; /* Q12 */ - } else { - for (i = 0; i < p; i++) { - _lpc[i] = EXTRACT16(PSHR32(lpc[i], 13)); /* Q25->Q12 */ - } - } - } -#endif -} - - -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; - } -#else - int i,j; - VARDECL(opus_val16, rden); - VARDECL(opus_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;i0) - { - for(i=0;i= 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; -} diff --git a/Engine/lib/opus/celt/celt_lpc.h b/Engine/lib/opus/celt/celt_lpc.h deleted file mode 100644 index a4c5fd6ea..000000000 --- a/Engine/lib/opus/celt/celt_lpc.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) 2009-2010 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. -*/ - -#ifndef PLC_H -#define PLC_H - -#include "arch.h" -#include "cpu_support.h" - -#if defined(OPUS_X86_MAY_HAVE_SSE4_1) -#include "x86/celt_lpc_sse.h" -#endif - -#define LPC_ORDER 24 - -void _celt_lpc(opus_val16 *_lpc, const opus_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); - -#if !defined(OVERRIDE_CELT_FIR) -#define celt_fir(x, num, y, N, ord, arch) \ - (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); - -int _celt_autocorr(const opus_val16 *x, opus_val32 *ac, - const opus_val16 *window, int overlap, int lag, int n, int arch); - -#endif /* PLC_H */ diff --git a/Engine/lib/opus/celt/cpu_support.h b/Engine/lib/opus/celt/cpu_support.h deleted file mode 100644 index 7b5c56ca9..000000000 --- a/Engine/lib/opus/celt/cpu_support.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2010 Xiph.Org Foundation - * Copyright (c) 2013 Parrot */ -/* - 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 CPU_SUPPORT_H -#define CPU_SUPPORT_H - -#include "opus_types.h" -#include "opus_defines.h" - -#if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) -#include "arm/armcpu.h" - -/* We currently support 4 ARM variants: - * arch[0] -> ARMv4 - * arch[1] -> ARMv5E - * arch[2] -> ARMv6 - * arch[3] -> NEON - */ -#define OPUS_ARCHMASK 3 - -#elif defined(OPUS_HAVE_RTCD) && \ - ((defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \ - (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \ - (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ - (defined(OPUS_X86_MAY_HAVE_AVX) && !defined(OPUS_X86_PRESUME_AVX))) - -#include "x86/x86cpu.h" -/* We currently support 5 x86 variants: - * arch[0] -> non-sse - * arch[1] -> sse - * arch[2] -> sse2 - * arch[3] -> sse4.1 - * arch[4] -> avx - */ -#define OPUS_ARCHMASK 7 -int opus_select_arch(void); - -#else -#define OPUS_ARCHMASK 0 - -static OPUS_INLINE int opus_select_arch(void) -{ - return 0; -} -#endif -#endif diff --git a/Engine/lib/opus/celt/cwrs.c b/Engine/lib/opus/celt/cwrs.c deleted file mode 100644 index a552e4f0f..000000000 --- a/Engine/lib/opus/celt/cwrs.c +++ /dev/null @@ -1,715 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Copyright (c) 2007-2009 Timothy B. Terriberry - Written by Timothy B. Terriberry 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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "os_support.h" -#include "cwrs.h" -#include "mathops.h" -#include "arch.h" - -#ifdef 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 - 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; - } - 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] = { - {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}, - {1, 6, 18, 38, 66, 102, 146, 198, 258, 326}, - {1, 8, 32, 88, 192, 360, 608, 952, 1408, 1992}, - {1, 10, 50, 170, 450, 1002, 1970, 3530, 5890, 9290}, - {1, 12, 72, 292, 912, 2364, 5336, 10836, 20256, 35436}, - {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 - most K-1 at a time. - 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 - 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 - 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(0,K) = K>0 ? 0 : 1, - the function becomes symmetric: U(N,K) = U(K,N), with a similar table: - 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}, - {0, 1, 5, 13, 25, 41, 61, 85, 113, 145}, - {0, 1, 7, 25, 63, 129, 231, 377, 575, 833}, - {0, 1, 9, 41, 129, 321, 681, 1289, 2241, 3649}, - {0, 1, 11, 61, 231, 681, 1683, 3653, 7183, 13073}, - {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): - 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 - 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 - 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: - 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 - previous row or the next row. - 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, - 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) = ((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 - 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) - multiplications. - 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 - polynomial for fixed N. - The first few are - U(1,K) = 1, - U(2,K) = 2*K-1, - U(3,K) = (2*K-2)*K+1, - U(4,K) = (((4*K-6)*K+8)*K-3)/3, - U(5,K) = ((((2*K-4)*K+10)*K-8)*K+3)/3, - and - V(1,K) = 2, - V(2,K) = 4*K, - V(3,K) = 4*K*K+2, - 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 - small N (and indeed decoding is also O(N) for N<3). - - @ARTICLE{Fis86, - author="Thomas R. Fischer", - title="A Pyramid Vector Quantizer", - journal="IEEE Transactions on Information Theory", - volume="IT-32", - number=4, - 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)]) -/*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)) - -/*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 - 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, - 44, 36, 32, 24, 22, 18, 16, 8, 4, 2).*/ -#if defined(CUSTOM_MODES) -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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) - /*...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(CUSTOM_MODES) -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 -}; -#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 -}; -#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 - -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; -} - -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)); -} - -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); - } - /*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; -} - -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); -} - -#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; -} - -/*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; -} - -/*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); - 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; -} - -/*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; -} - -/*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; -} - -#ifdef 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); - 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); - 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; -} - -#endif /* SMALL_FOOTPRINT */ diff --git a/Engine/lib/opus/celt/cwrs.h b/Engine/lib/opus/celt/cwrs.h deleted file mode 100644 index 7cd471745..000000000 --- a/Engine/lib/opus/celt/cwrs.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Copyright (c) 2007-2009 Timothy B. Terriberry - Written by Timothy B. Terriberry 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. -*/ - -#ifndef CWRS_H -#define CWRS_H - -#include "arch.h" -#include "stack_alloc.h" -#include "entenc.h" -#include "entdec.h" - -#ifdef CUSTOM_MODES -int log2_frac(opus_uint32 val, int frac); -#endif - -void get_required_bits(opus_int16 *bits, int N, int K, int frac); - -void 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); - -#endif /* CWRS_H */ diff --git a/Engine/lib/opus/celt/dump_modes/Makefile b/Engine/lib/opus/celt/dump_modes/Makefile deleted file mode 100644 index 93f599fb5..000000000 --- a/Engine/lib/opus/celt/dump_modes/Makefile +++ /dev/null @@ -1,32 +0,0 @@ - -CFLAGS=-O2 -Wall -Wextra -DHAVE_CONFIG_H -INCLUDES=-I. -I../ -I../.. -I../../include - -SOURCES = dump_modes.c \ - ../modes.c \ - ../cwrs.c \ - ../rate.c \ - ../entcode.c \ - ../entenc.c \ - ../entdec.c \ - ../mathops.c \ - ../mdct.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 -LIBS = -L$(NE10_LIBDIR) -lNE10 -SOURCES += ../arm/celt_ne10_fft.c \ - dump_modes_arm_ne10.c \ - ../arm/armcpu.c -endif - -all: dump_modes - -dump_modes: - $(PREFIX)$(CC) $(CFLAGS) $(INCLUDES) -DCUSTOM_MODES_ONLY -DCUSTOM_MODES $(SOURCES) -o $@ $(LIBS) -lm - -clean: - rm -f dump_modes diff --git a/Engine/lib/opus/celt/dump_modes/dump_modes.c b/Engine/lib/opus/celt/dump_modes/dump_modes.c deleted file mode 100644 index 9105a5344..000000000 --- a/Engine/lib/opus/celt/dump_modes/dump_modes.c +++ /dev/null @@ -1,353 +0,0 @@ -/* Copyright (c) 2008 CSIRO - Copyright (c) 2008-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 -#include -#include "modes.h" -#include "celt.h" -#include "rate.h" -#include "dump_modes_arch.h" - -#define INT16 "%d" -#define INT32 "%d" -#define FLOAT "%#0.8gf" - -#ifdef FIXED_POINT -#define WORD16 INT16 -#define WORD32 INT32 -#else -#define WORD16 FLOAT -#define WORD32 FLOAT -#endif - -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 opus_val16 window%d[%d] = {\n", mode->overlap, mode->overlap); - for (j=0;joverlap;j++) - fprintf (file, WORD16 ",%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;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"); - - /* 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); - 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':' '); - fprintf (file, "};\n"); - -#ifdef OVERRIDE_FFT - 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", - 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", - mode->Fs, mdctSize, k); - fprintf (file, "%d, /* nfft */\n", mode->mdct.kfft[k]->nfft); - fprintf (file, WORD16 ", /* scale */\n", mode->mdct.kfft[k]->scale); -#ifdef FIXED_POINT - 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 opus_val16 mdct_twiddles%d[%d] = {\n", - mdctSize, mdct_twiddles_size); - for (j=0;jmdct.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, "};\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"); -} - -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); - } -} - -#ifdef FIXED_POINT -#define BASENAME "static_modes_fixed" -#else -#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;i -#include -#include "modes.h" -#include "dump_modes_arch.h" -#include - -#if !defined(FIXED_POINT) -# define NE10_FFT_CFG_TYPE_T ne10_fft_cfg_float32_t -# define NE10_FFT_CPX_TYPE_T_STR "ne10_fft_cpx_float32_t" -# define NE10_FFT_STATE_TYPE_T_STR "ne10_fft_state_float32_t" -#else -# define NE10_FFT_CFG_TYPE_T ne10_fft_cfg_int32_t -# define NE10_FFT_CPX_TYPE_T_STR "ne10_fft_cpx_int32_t" -# define NE10_FFT_STATE_TYPE_T_STR "ne10_fft_state_int32_t" -#endif - -static FILE *file; - -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;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_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", - NE10_FFT_CPX_TYPE_T_STR, mode->mdct.kfft[k]->nfft, - mode->mdct.kfft[k]->nfft); - for(j=0;jmdct.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':' '); -#else - 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", - 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, - 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", - NE10_FFT_CPX_TYPE_T_STR, mode->mdct.kfft[k]->nfft); - 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"); -#endif - fprintf(file, "};\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", - 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); -} diff --git a/Engine/lib/opus/celt/ecintrin.h b/Engine/lib/opus/celt/ecintrin.h deleted file mode 100644 index 66a4c36ea..000000000 --- a/Engine/lib/opus/celt/ecintrin.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (c) 2003-2008 Timothy B. Terriberry - Copyright (c) 2008 Xiph.Org Foundation */ -/* - 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. -*/ - -/*Some common macros for potential platform-specific optimization.*/ -#include "opus_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 - versions of these functions which can substantially improve performance. - 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 - instructions, because of the way they represented ((_b)>(_a)) internally.*/ -# 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 -/*In _DEBUG mode this is not an intrinsic by default.*/ -# pragma intrinsic(_BitScanReverse) - -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)) -# endif -#endif - -#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 -#endif diff --git a/Engine/lib/opus/celt/entcode.c b/Engine/lib/opus/celt/entcode.c deleted file mode 100644 index 70f32016e..000000000 --- a/Engine/lib/opus/celt/entcode.c +++ /dev/null @@ -1,153 +0,0 @@ -/* 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 - 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 "entcode.h" -#include "arch.h" - -#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 - 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; -} -#endif - -#if 1 -/* This is a faster version of 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] = - {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; -} -#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; -} -#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 -}; -#endif diff --git a/Engine/lib/opus/celt/entcode.h b/Engine/lib/opus/celt/entcode.h deleted file mode 100644 index 3763e3f28..000000000 --- a/Engine/lib/opus/celt/entcode.h +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (c) 2001-2011 Timothy B. Terriberry - Copyright (c) 2008-2009 Xiph.Org Foundation */ -/* - 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 "opus_types.h" -#include "opus_defines.h" - -#if !defined(_entcode_H) -# define _entcode_H (1) -# include -# include -# include "ecintrin.h" - -extern const opus_uint32 SMALL_DIV_TABLE[129]; - -#ifdef OPUS_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; - -# define EC_WINDOW_SIZE ((int)sizeof(ec_window)*CHAR_BIT) - -/*The number of bits to use for the range-coded part of unsigned integers.*/ -# define EC_UINT_BITS (8) - -/*The resolution of fractional-precision bit usage measurements, i.e., - 3 => 1/8th bits.*/ -# define BITRES 3 - -/*The entropy encoder/decoder context. - We use the same structure for both, so that common functions like 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 oustanding carry propagating symbols.*/ - opus_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 OPUS_INLINE unsigned char *ec_get_buffer(ec_ctx *_this){ - return _this->buf; -} - -static OPUS_INLINE int 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 - suitable for making coding decisions. - 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); -} - -/*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 - suitable for making coding decisions. - 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); - -/* 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 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 -} - -#endif diff --git a/Engine/lib/opus/celt/entdec.c b/Engine/lib/opus/celt/entdec.c deleted file mode 100644 index 0b3433ed8..000000000 --- a/Engine/lib/opus/celt/entdec.c +++ /dev/null @@ -1,245 +0,0 @@ -/* Copyright (c) 2001-2011 Timothy B. Terriberry - Copyright (c) 2008-2009 Xiph.Org Foundation */ -/* - 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 -#include "os_support.h" -#include "arch.h" -#include "entdec.h" -#include "mfrngcod.h" - -/*A range decoder. - 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 - 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$ - 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 - the process is carried out with no rounding errors. - - 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 - 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 - 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 - all the symbols thus far; other data can be packed in the remaining bits of - the input buffer. - @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, - author="Martin, G.N.N.", - title="Range encoding: an algorithm for removing redundancy from a digitised - message", - booktitle="Video & Data Recording Conference", - year=1979, - address="Southampton", - month=Jul - } - @ARTICLE{MNW98, - author="Alistair Moffat and Radford Neal and Ian H. Witten", - title="Arithmetic Coding Revisited", - journal="{ACM} Transactions on Information Systems", - year=1998, - volume=16, - number=3, - 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 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<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); -} - -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 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); -} - -/*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 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; -} - -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; - } -} - -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)<>=_bits; - available-=_bits; - _this->end_window=window; - _this->nend_bits=available; - _this->nbits_total+=_bits; - return ret; -} diff --git a/Engine/lib/opus/celt/entdec.h b/Engine/lib/opus/celt/entdec.h deleted file mode 100644 index 025fc1870..000000000 --- a/Engine/lib/opus/celt/entdec.h +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (c) 2001-2011 Timothy B. Terriberry - Copyright (c) 2008-2009 Xiph.Org Foundation */ -/* - 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(_entdec_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); - -/*Calculates the cumulative frequency for the next symbol. - 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 - encoded with. - 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); - -/*Equivalent to ec_decode() with _ft==1<<_bits.*/ -unsigned 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 - intermediate calculations are performed. - _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 - 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 - 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); - -/* Decode a bit that has a 1/(1<<_logp) probability of being a one */ -int 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 - [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); - -/*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). - 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); - -/*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. - This must be between 0 and 25, inclusive. - Return: The decoded bits.*/ -opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb); - -#endif diff --git a/Engine/lib/opus/celt/entenc.c b/Engine/lib/opus/celt/entenc.c deleted file mode 100644 index f1750d25b..000000000 --- a/Engine/lib/opus/celt/entenc.c +++ /dev/null @@ -1,294 +0,0 @@ -/* Copyright (c) 2001-2011 Timothy B. Terriberry - Copyright (c) 2008-2009 Xiph.Org Foundation */ -/* - 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(HAVE_CONFIG_H) -# include "config.h" -#endif -#include "os_support.h" -#include "arch.h" -#include "entenc.h" -#include "mfrngcod.h" - -/*A range encoder. - See entdec.c and the references for implementation details \cite{Mar79,MNW98}. - - @INPROCEEDINGS{Mar79, - author="Martin, G.N.N.", - title="Range encoding: an algorithm for removing redundancy from a digitised - message", - booktitle="Video \& Data Recording Conference", - year=1979, - address="Southampton", - month=Jul - } - @ARTICLE{MNW98, - author="Alistair Moffat and Radford Neal and Ian H. Witten", - title="Arithmetic Coding Revisited", - journal="{ACM} Transactions on Information Systems", - year=1998, - volume=16, - number=3, - 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 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 - 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 - undecodable. - 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 - 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 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; - } -} - -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 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 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); -} - -/*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 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 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<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; - } - while(used>=EC_SYM_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 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 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){ - 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; - } - _this->buf[_this->storage-_this->end_offs-1]|=(unsigned char)window; - } - } - } -} diff --git a/Engine/lib/opus/celt/entenc.h b/Engine/lib/opus/celt/entenc.h deleted file mode 100644 index f502eaf66..000000000 --- a/Engine/lib/opus/celt/entenc.h +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (c) 2001-2011 Timothy B. Terriberry - Copyright (c) 2008-2009 Xiph.Org Foundation */ -/* - 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(_entenc_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); -/*Encodes a symbol given its frequency information. - The frequency information must be discernable 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 - 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 - encoded. - _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); - -/*Equivalent to ec_encode() with _ft==1<<_bits.*/ -void 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); - -/*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>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); - -/*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). - 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); - -/*Encodes a sequence of raw bits in the stream. - _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); - -/*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 - 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 - encoded using probabilities that are an exact power of two. - 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). - They will be decoded in order from most-significant to least. - _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); - -/*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 - the end of the new buffer size. - 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. - 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); - -/*Indicates that there are no more symbols to encode. - All reamining 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); - -#endif diff --git a/Engine/lib/opus/celt/fixed_c5x.h b/Engine/lib/opus/celt/fixed_c5x.h deleted file mode 100644 index ea95a998c..000000000 --- a/Engine/lib/opus/celt/fixed_c5x.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (C) 2003 Jean-Marc Valin */ -/** - @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 - 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 FIXED_C5X_H -#define FIXED_C5X_H - -#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); -} - -#undef MAX16 -#define MAX16(a,b) _max(a,b) - -#undef MIN16 -#define MIN16(a,b) _min(a,b) - -#undef MAX32 -#define MAX32(a,b) _lmax(a,b) - -#undef MIN32 -#define MIN32(a,b) _lmin(a,b) - -#undef VSHR32 -#define VSHR32(a, shift) _lshl(a,-(shift)) - -#undef MULT16_16_Q15 -#define MULT16_16_Q15(a,b) (_smpy(a,b)) - -#undef MULT16_16SU -#define MULT16_16SU(a,b) _lmpysu(a,b) - -#undef MULT_16_16 -#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 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 OVERRIDE_CELT_MAXABS16 - -#endif /* FIXED_C5X_H */ diff --git a/Engine/lib/opus/celt/fixed_c6x.h b/Engine/lib/opus/celt/fixed_c6x.h deleted file mode 100644 index bb6ad9278..000000000 --- a/Engine/lib/opus/celt/fixed_c6x.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2008 CSIRO */ -/** - @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 - 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 FIXED_C6X_H -#define FIXED_C6X_H - -#undef MULT16_16SU -#define MULT16_16SU(a,b) _mpysu(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 - -#undef MULT16_32_Q15 -#define MULT16_32_Q15(a,b) (_mpylill(a, b) >> 15) - -#if 0 -#include "dsplib.h" - -#undef MAX16 -#define MAX16(a,b) _max(a,b) - -#undef MIN16 -#define MIN16(a,b) _min(a,b) - -#undef MAX32 -#define MAX32(a,b) _lmax(a,b) - -#undef MIN32 -#define MIN32(a,b) _lmin(a,b) - -#undef VSHR32 -#define VSHR32(a, shift) _lshl(a,-(shift)) - -#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 - -#endif /* FIXED_C6X_H */ diff --git a/Engine/lib/opus/celt/fixed_debug.h b/Engine/lib/opus/celt/fixed_debug.h deleted file mode 100644 index ef2e5d02f..000000000 --- a/Engine/lib/opus/celt/fixed_debug.h +++ /dev/null @@ -1,836 +0,0 @@ -/* Copyright (C) 2003-2008 Jean-Marc Valin - Copyright (C) 2007-2012 Xiph.Org Foundation */ -/** - @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 - 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 FIXED_DEBUG_H -#define FIXED_DEBUG_H - -#include -#include "opus_defines.h" - -#ifdef CELT_C -OPUS_EXPORT opus_int64 celt_mips=0; -#else -extern opus_int64 celt_mips; -#endif - -#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)) - -/** 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_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_val32)1)<<(bits)))) - -#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) - -/** Add two 32-bit values, ignore any overflows */ -#define ADD32_ovflw(a,b) (celt_mips+=2,(opus_val32)((opus_uint32)(a)+(opus_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))) -/* 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))) - -static OPUS_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); -#endif - } - res = -x; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "NEG16: output is not short: %d\n", (int)res); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - res = -x; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "NEG16: output is not int: %d\n", (int)res); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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 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 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - celt_mips+=5; - return res; -} - -#define MULT16_16(a, b) MULT16_16_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int MULT16_16_(int a, int b, char *file, int line) -{ - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - celt_mips++; - return res; -} - -#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); -#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", Q, (int)a, (int)b, file, line); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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; -} - -#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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - 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; -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - 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); -#ifdef FIXED_DEBUG_ASSERT - 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); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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); -} -#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); - -#endif diff --git a/Engine/lib/opus/celt/fixed_generic.h b/Engine/lib/opus/celt/fixed_generic.h deleted file mode 100644 index 8f29d46bb..000000000 --- a/Engine/lib/opus/celt/fixed_generic.h +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2007-2009 Xiph.Org Foundation - Copyright (C) 2003-2008 Jean-Marc Valin - Copyright (C) 2007-2008 CSIRO */ -/** - @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 - 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 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)) - -/** 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)) -#else -#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)) -#else -#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)) -#else -#define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15)) -#endif - -/** 32x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT32_32_Q16(a,b) ((opus_val32)SHR((opus_int64)(a)*(opus_int64)(b),16)) -#else -#define MULT32_32_Q16(a,b) (ADD32(ADD32(ADD32((opus_val32)(SHR32(((opus_uint32)((a)&0x0000ffff)*(opus_uint32)((b)&0x0000ffff)),16)), MULT16_16SU(SHR32(a,16),((b)&0x0000ffff))), MULT16_16SU(SHR32(b,16),((a)&0x0000ffff))), SHL32(MULT16_16(SHR32(a,16),SHR32(b,16)),16))) -#endif - -/** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT32_32_Q31(a,b) ((opus_val32)SHR((opus_int64)(a)*(opus_int64)(b),31)) -#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)) -#endif - -/** Compile-time conversion of float constant to 16-bit value */ -#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) - -/** Compile-time conversion of float constant to 32-bit value */ -#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val32)1)<<(bits)))) - -/** Negate a 16-bit value */ -#define NEG16(x) (-(x)) -/** Negate a 32-bit value */ -#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)) -/** Change a 16-bit value into a 32-bit value */ -#define EXTEND32(x) ((opus_val32)(x)) - -/** Arithmetic shift-right of a 16-bit value */ -#define SHR16(a,shift) ((a) >> (shift)) -/** Arithmetic shift-left of a 16-bit value */ -#define SHL16(a,shift) ((opus_int16)((opus_uint16)(a)<<(shift))) -/** Arithmetic shift-right of a 32-bit value */ -#define SHR32(a,shift) ((a) >> (shift)) -/** Arithmetic shift-left of a 32-bit value */ -#define SHL32(a,shift) ((opus_int32)((opus_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)) -/** 32-bit arithmetic shift right where the argument can be negative */ -#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(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 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)))) -/** Shift by a and round-to-nearest 32-bit value. Result is a saturated 16-bit value */ -#define SROUND16(x,a) EXTRACT16(SATURATE(PSHR32(x,a), 32767)); - -/** Divide by two */ -#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))) -/** Subtract two 16-bit values */ -#define SUB16(a,b) ((opus_val16)(a)-(opus_val16)(b)) -/** Add two 32-bit values */ -#define ADD32(a,b) ((opus_val32)(a)+(opus_val32)(b)) -/** Subtract two 32-bit values */ -#define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b)) - -/** Add two 32-bit values, ignore any overflows */ -#define ADD32_ovflw(a,b) ((opus_val32)((opus_uint32)(a)+(opus_uint32)(b))) -/** Subtract two 32-bit values, ignore any overflows */ -#define SUB32_ovflw(a,b) ((opus_val32)((opus_uint32)(a)-(opus_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))) - -/** 16x16 multiplication where the result fits in 16 bits */ -#define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b)))) - -/** 32x32 multiplication where the result fits in 32 bits */ -#define MULT32_32_32(a,b) ((((opus_val32)(a))*((opus_val32)(b)))) - -/* (opus_val32)(opus_val16) gives TI compiler a hint that it's 16x16->32 multiply */ -/** 16x16 multiplication where the result fits in 32 bits */ -#define MULT16_16(a,b) (((opus_val32)(opus_val16)(a))*((opus_val32)(opus_val16)(b))) - -/** 16x16 multiply-add where the result fits in 32 bits */ -#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))) - -/** 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 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)) - -/** 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)))) - -/** 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))) - -#if defined(MIPSr1_ASM) -#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); -} -#define SIG2WORD16(x) (SIG2WORD16_generic(x)) - -#endif diff --git a/Engine/lib/opus/celt/float_cast.h b/Engine/lib/opus/celt/float_cast.h deleted file mode 100644 index 8915a5fd7..000000000 --- a/Engine/lib/opus/celt/float_cast.h +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (C) 2001 Erik de Castro Lopo */ -/* - 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. -*/ - -/* Version 1.1 */ - -#ifndef FLOAT_CAST_H -#define FLOAT_CAST_H - - -#include "arch.h" - -/*============================================================================ -** On Intel Pentium processors (especially PIII and probably P4), converting -** from float to int is very slow. To meet the C specs, the code produced by -** most C compilers targeting Pentium needs to change the FPU rounding mode -** before the float to int conversion is performed. -** -** Changing the FPU rounding mode causes the FPU pipeline to be flushed. It -** is this flushing of the pipeline which is so slow. -** -** Fortunately the ISO C99 specifications define the functions lrint, lrintf, -** llrint and llrintf which fix this problem as a side effect. -** -** On Unix-like systems, the configure process should have detected the -** presence of these functions. If they weren't found we have to replace them -** here with a standard C cast. -*/ - -/* -** The C99 prototypes for lrint and lrintf are as follows: -** -** long int lrintf (float x) ; -** long int lrint (double x) ; -*/ - -/* The presence of the required functions are detected during the configure -** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in -** the config.h file. -*/ - -/* 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));} - -#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)); - } - -#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && defined (_M_IX86) - - #include - - /* Win32 doesn't seem to have these functions. - ** Therefore implement OPUS_INLINE versions of these functions here. - */ - - static OPUS_INLINE opus_int32 - float2int (float flt) - { int intgr; - - _asm - { fld flt - fistp intgr - } ; - - return intgr ; - } - -#elif defined(HAVE_LRINTF) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* These defines enable functionality introduced with the 1999 ISO C -** standard. They must be defined before the inclusion of math.h to -** engage them. If optimisation is enabled, these functions will be -** inlined. With optimisation switched off, you have to link in the -** maths library using -lm. -*/ - -#define _ISOC9X_SOURCE 1 -#define _ISOC99_SOURCE 1 - -#define __USE_ISOC9X 1 -#define __USE_ISOC99 1 - -#include -#define float2int(x) lrintf(x) - -#elif defined(HAVE_LRINT) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -#define _ISOC9X_SOURCE 1 -#define _ISOC99_SOURCE 1 - -#define __USE_ISOC9X 1 -#define __USE_ISOC99 1 - -#include -#define 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))) -#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); -} -#endif /* DISABLE_FLOAT_API */ - -#endif /* FLOAT_CAST_H */ diff --git a/Engine/lib/opus/celt/kiss_fft.c b/Engine/lib/opus/celt/kiss_fft.c deleted file mode 100644 index 83775165d..000000000 --- a/Engine/lib/opus/celt/kiss_fft.c +++ /dev/null @@ -1,604 +0,0 @@ -/*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 - - 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.*/ - -/* This code is originally from Mark Borgerding's KISS-FFT but has been - heavily modified to better suit Opus */ - -#ifndef SKIP_CONFIG_H -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif -#endif - -#include "_kiss_fft_guts.h" -#include "arch.h" -#include "os_support.h" -#include "mathops.h" -#include "stack_alloc.h" - -/* The guts header contains all the multiplication and addition macros that are defined for - complex numbers. It also delares the kf_ internal functions. -*/ - -static void kf_bfly2( - kiss_fft_cpx * Fout, - int m, - int N - ) -{ - kiss_fft_cpx * Fout2; - int i; - (void)m; -#ifdef CUSTOM_MODES - if (m==1) - { - celt_assert(m==1); - for (i=0;itwiddles; - /* m is guaranteed to be a multiple of 4. */ - for (j=0;jtwiddles[fstride*m]; -#endif - for (i=0;itwiddles; - /* 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; - - 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 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 = 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; - } - } -} -#endif /* OVERRIDE_kf_bfly5 */ - - -#endif - - -#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 */ - - /*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) - p = n; /* no more factors, skip to end */ - } - n /= p; -#ifdef RADIX_TWO_ONLY - if (p!=2 && p != 4) -#else - if (p>5) -#endif - { - return 0; - } - facbuf[2*stages] = p; - if (p==2 && stages > 1) - { - facbuf[2*stages] = 4; - facbuf[2] = 2; - } - stages++; - } while (n > 1); - n = nbak; - /* 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; - kiss_twiddle_cpx *twiddles; - - st->nfft=nfft; -#ifdef FIXED_POINT - st->scale_shift = celt_ilog2(st->nfft); - if (st->nfft == 1<scale_shift) - st->scale = Q15ONE; - else - st->scale = (1073741824+st->nfft/2)/st->nfft>>(15-st->scale_shift); -#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; - } else { - st->twiddles = twiddles = (kiss_twiddle_cpx*)KISS_FFT_MALLOC(sizeof(kiss_twiddle_cpx)*nfft); - compute_twiddles(twiddles, nfft); - st->shift = -1; - } - if (!kf_factor(nfft,st->factors)) - { - goto fail; - } - - /* bitrev */ - st->bitrev = bitrev = (opus_int16*)KISS_FFT_MALLOC(sizeof(opus_int16)*nfft); - if (st->bitrev==NULL) - goto fail; - compute_bitrev_table(0, bitrev, 1,1, st->factors,st); - - /* Initialize architecture specific fft parameters */ - if (opus_fft_alloc_arch(st, arch)) - goto fail; - } - return st; -fail: - opus_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); -} - -void opus_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); - } -} - -#endif /* CUSTOM_MODES */ - -void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout) -{ - int m2, m; - int p; - int L; - int fstride[MAXFACTORS]; - int i; - int shift; - - /* st->shift can be -1 */ - shift = st->shift>0 ? st->shift : 0; - - fstride[0] = 1; - 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: - kf_bfly2(fout, m, fstride[i]); - break; - case 4: - kf_bfly4(fout,fstride[i]<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 = SHR32(MULT16_32_Q16(scale, x.r), scale_shift); - fout[st->bitrev[i]].i = SHR32(MULT16_32_Q16(scale, x.i), scale_shift); - } - opus_fft_impl(st, fout); -} - - -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); - for (i=0;infft;i++) - fout[i].i = -fout[i].i; -} diff --git a/Engine/lib/opus/celt/kiss_fft.h b/Engine/lib/opus/celt/kiss_fft.h deleted file mode 100644 index 267f72f99..000000000 --- a/Engine/lib/opus/celt/kiss_fft.h +++ /dev/null @@ -1,210 +0,0 @@ -/*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 - - 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_H -#define KISS_FFT_H - -#include -#include -#include "arch.h" -#include "cpu_support.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef USE_SIMD -# include -# define kiss_fft_scalar __m128 -#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes) -#else -#define KISS_FFT_MALLOC opus_alloc -#endif - -#ifdef FIXED_POINT -#include "arch.h" - -# define kiss_fft_scalar opus_int32 -# define kiss_twiddle_scalar opus_int16 - -/* Some 32-bit CPUs would load/store a kiss_twiddle_cpx with a single memory - * access, and could benefit from additional alignment. - */ -# define KISS_TWIDDLE_CPX_ALIGNMENT (sizeof(opus_int32)) - -#else -# ifndef kiss_fft_scalar -/* default is float */ -# 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))) -#else -#define KISS_TWIDDLE_CPX_ALIGNED -#endif - -typedef struct { - kiss_fft_scalar r; - kiss_fft_scalar i; -}kiss_fft_cpx; - -typedef struct { - 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 - */ - -typedef struct arch_fft_state{ - int is_supported; - void *priv; -} arch_fft_state; - -typedef struct kiss_fft_state{ - int nfft; - opus_val16 scale; -#ifdef FIXED_POINT - int scale_shift; -#endif - int shift; - opus_int16 factors[2*MAXFACTORS]; - const opus_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" -#endif - -/*typedef struct kiss_fft_state* kiss_fft_cfg;*/ - -/** - * opus_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); - * - * 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. - * The returned value should be free()d when done to avoid memory leaks. - * - * The state can be placed in a user supplied buffer 'mem': - * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, - * then the function places the cfg in mem and the size used in *lenmem - * and returns mem. - * - * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), - * then the function returns NULL and places the minimum cfg - * 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 *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch); - -/** - * opus_fft(cfg,in_out_buf) - * - * Perform an FFT on a complex input buffer. - * for a forward FFT, - * fin should be f[0] , f[1] , ... ,f[nfft-1] - * fout will be F[0] , F[1] , ... ,F[nfft-1] - * 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 opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout); -void opus_ifft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout); - -void opus_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); - -#if !defined(OVERRIDE_OPUS_FFT) -/* Is run-time CPU detection enabled on this platform? */ -#if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) - -extern int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])( - kiss_fft_state *st); - -#define opus_fft_alloc_arch(_st, arch) \ - ((*OPUS_FFT_ALLOC_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st)) - -extern void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])( - kiss_fft_state *st); -#define opus_fft_free_arch(_st, arch) \ - ((*OPUS_FFT_FREE_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st)) - -extern void (*const OPUS_FFT[OPUS_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)) - -extern void (*const OPUS_IFFT[OPUS_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)) - -#else /* else for if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ - -#define opus_fft_alloc_arch(_st, arch) \ - ((void)(arch), opus_fft_alloc_arch_c(_st)) - -#define opus_fft_free_arch(_st, arch) \ - ((void)(arch), opus_fft_free_arch_c(_st)) - -#define opus_fft(_cfg, _fin, _fout, arch) \ - ((void)(arch), opus_fft_c(_cfg, _fin, _fout)) - -#define opus_ifft(_cfg, _fin, _fout, arch) \ - ((void)(arch), opus_ifft_c(_cfg, _fin, _fout)) - -#endif /* end if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ -#endif /* end if !defined(OVERRIDE_OPUS_FFT) */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/celt/laplace.c b/Engine/lib/opus/celt/laplace.c deleted file mode 100644 index a7bca874b..000000000 --- a/Engine/lib/opus/celt/laplace.c +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright (c) 2007 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 "laplace.h" -#include "mathops.h" - -/* The minimum probability of an energy delta (out of 32768). */ -#define LAPLACE_LOG_MINP (0) -#define LAPLACE_MINP (1<>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); -} - -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>1; - b=1U<>=1; - bshift--; - } - while(bshift>=0); - return g; -} - -#ifdef FIXED_POINT - -opus_val32 frac_div32(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)); - 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, - SUB16(MULT16_16_Q15(y, 12288), 16384)))); -} - -/** Sqrt approximation (QX input, QX/2 output) */ -opus_val32 celt_sqrt(opus_val32 x) -{ - int k; - opus_val16 n; - opus_val32 rt; - static const opus_val16 C[5] = {23175, 11561, -3011, 1699, -664}; - if (x==0) - return 0; - else if (x>=1073741824) - return 32767; - k = (celt_ilog2(x)>>1)-7; - x = VSHR32(x, 2*k); - n = x-32768; - rt = 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]))))))))); - rt = VSHR32(rt,7-k); - return rt; -} - -#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; - - 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 - -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 (x0); - i = celt_ilog2(x); - /* n is Q15 with range [0,1). */ - n = VSHR32(x,i-15)-32768; - /* 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, n)); - /* Perform two Newton iterations: - r -= r*((r*n)-1.Q15) - = r*((r*n)+(r-1.Q15)). */ - r = SUB16(r, MULT16_16_Q15(r, - ADD16(MULT16_16_Q15(r, n), 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. */ - r = SUB16(r, ADD16(1, MULT16_16_Q15(r, - ADD16(MULT16_16_Q15(r, n), ADD16(r, -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); -} - -#endif diff --git a/Engine/lib/opus/celt/mathops.h b/Engine/lib/opus/celt/mathops.h deleted file mode 100644 index 478ac9187..000000000 --- a/Engine/lib/opus/celt/mathops.h +++ /dev/null @@ -1,290 +0,0 @@ -/* Copyright (c) 2002-2008 Jean-Marc Valin - Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/** - @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 - 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 MATHOPS_H -#define MATHOPS_H - -#include "arch.h" -#include "entcode.h" -#include "os_support.h" - -#define PI 3.141592653f - -/* 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) - -unsigned isqrt32(opus_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>23)-127; - in.i -= (opus_uint32)integer<<23; - frac = in.f - 1.5f; - frac = -0.41445418f + frac*(0.95909232f - + frac*(-0.33951290f + frac*0.16541097f)); - return 1+integer+frac; -} - -/** Base-2 exponential approximation (2^x). */ -static OPUS_INLINE float celt_exp2(float x) -{ - int integer; - float frac; - union { - float f; - opus_uint32 i; - } res; - integer = (int)floor(x); - if (integer < -50) - return 0; - frac = x-integer; - /* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */ - res.f = 0.99992522f + frac * (0.69583354f - + frac * (0.22606716f + 0.078024523f*frac)); - res.i = (res.i + ((opus_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 - -#endif - -#ifdef FIXED_POINT - -#include "os_support.h" - -#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; -} -#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); -} - -opus_val16 celt_rsqrt_norm(opus_val32 x); - -opus_val32 celt_sqrt(opus_val32 x); - -opus_val16 celt_cos_norm(opus_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-DB_SHIFT)), 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 SHL16(i-13,DB_SHIFT)+SHR16(frac,14-DB_SHIFT); -} - -/* - 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)))))); -} -/** 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); -} - -opus_val32 celt_rcp(opus_val32 x); - -#define celt_div(a,b) MULT32_32_Q31((opus_val32)(a),celt_rcp(b)) - -opus_val32 frac_div32(opus_val32 a, opus_val32 b); - -#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))))))); -} - -#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 (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); - } -} - -#endif /* FIXED_POINT */ -#endif /* MATHOPS_H */ diff --git a/Engine/lib/opus/celt/mdct.c b/Engine/lib/opus/celt/mdct.c deleted file mode 100644 index 5c6dab5b7..000000000 --- a/Engine/lib/opus/celt/mdct.c +++ /dev/null @@ -1,343 +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 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(MIPSr1_ASM) -#include "mips/mdct_mipsr1.h" -#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) -#if 1 - for (i=0;i>= 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); -} - -#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 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; - opus_val16 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; -#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 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(;ibitrev[i]] = yc; - } - } - - /* N/4 complex FFT, does not downscale anymore */ - opus_fft_impl(st, f2); - - /* 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,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; -} -#endif /* OVERRIDE_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 opus_val16 * OPUS_RESTRICT window, int overlap, int shift, int stride, int arch) -{ - int i; - int N, N2, N4; - const kiss_twiddle_scalar *trig; - (void) arch; - - N = l->n; - trig = l->trig; - for (i=0;i>= 1; - trig += N; - } - N2 = N>>1; - N4 = N>>2; - - /* 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 = out+(overlap>>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))); - - /* 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 = ADD32_ovflw(S_MUL(re,t0), S_MUL(im,t1)); - yi = SUB32_ovflw(S_MUL(re,t1), S_MUL(im,t0)); - /* 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 = ADD32_ovflw(S_MUL(re,t0), S_MUL(im,t1)); - yi = SUB32_ovflw(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++ = SUB32_ovflw(MULT16_32_Q15(*wp2, x2), MULT16_32_Q15(*wp1, x1)); - *xp1-- = ADD32_ovflw(MULT16_32_Q15(*wp1, x2), MULT16_32_Q15(*wp2, x1)); - wp1++; - wp2--; - } - } -} -#endif /* OVERRIDE_clt_mdct_backward */ diff --git a/Engine/lib/opus/celt/mdct.h b/Engine/lib/opus/celt/mdct.h deleted file mode 100644 index 160ae4e0f..000000000 --- a/Engine/lib/opus/celt/mdct.h +++ /dev/null @@ -1,112 +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_H -#define MDCT_H - -#include "opus_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; -} mdct_lookup; - -#if defined(HAVE_ARM_NE10) -#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); - -/** 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 opus_val16 *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 opus_val16 * OPUS_RESTRICT window, - int overlap, int shift, int stride, int arch); - -#if !defined(OVERRIDE_OPUS_MDCT) -/* Is run-time CPU detection enabled on this platform? */ -#if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) - -extern void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])( - 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); - -#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)) - -extern void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])( - 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); - -#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) - -#else /* if defined(OPUS_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 clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ - 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 diff --git a/Engine/lib/opus/celt/meson.build b/Engine/lib/opus/celt/meson.build deleted file mode 100644 index ad95d949b..000000000 --- a/Engine/lib/opus/celt/meson.build +++ /dev/null @@ -1,69 +0,0 @@ -celt_sources = sources['CELT_SOURCES'] - -celt_sse_sources = sources['CELT_SOURCES_SSE'] - -celt_sse2_sources = sources['CELT_SOURCES_SSE2'] - -celt_sse4_1_sources = sources['CELT_SOURCES_SSE4_1'] - -celt_neon_intr_sources = sources['CELT_SOURCES_ARM_NEON_INTR'] - -celt_static_libs = [] - -if host_cpu_family in ['x86', 'x86_64'] and opus_conf.has('OPUS_HAVE_RTCD') - celt_sources += sources['CELT_SOURCES_X86_RTCD'] -endif - -foreach intr_name : ['sse', 'sse2', 'sse4_1', 'neon_intr'] - have_intr = get_variable('have_' + intr_name) - if not have_intr - continue - endif - - intr_sources = get_variable('celt_@0@_sources'.format(intr_name)) - intr_args = get_variable('opus_@0@_args'.format(intr_name), []) - celt_static_libs += static_library('celt_' + intr_name, intr_sources, - c_args: intr_args, - include_directories: opus_includes, - install: false) -endforeach - -have_arm_intrinsics_or_asm = have_arm_ne10 -if (intrinsics_support.length() + asm_optimization.length() + inline_optimization.length()) > 0 - have_arm_intrinsics_or_asm = true -endif - -if host_cpu_family in ['arm', 'aarch64'] and have_arm_intrinsics_or_asm - if opus_conf.has('OPUS_HAVE_RTCD') - celt_sources += sources['CELT_SOURCES_ARM_RTCD'] - endif - if have_arm_ne10 - celt_sources += sources['CELT_SOURCES_ARM_NE10'] - endif - if opus_arm_external_asm - arm2gnu = [find_program('arm/arm2gnu.pl')] + arm2gnu_args - celt_sources_arm_asm = configure_file(input: 'arm/celt_pitch_xcorr_arm.s', - output: '@BASENAME@-gnu.S', - command: arm2gnu + ['@INPUT@'], - capture: true) - celt_arm_armopts_s = configure_file(input: 'arm/armopts.s.in', - output: 'arm/armopts.s', - configuration: opus_conf) - celt_static_libs += static_library('celt-armasm', - celt_arm_armopts_s, celt_sources_arm_asm, - install: false) - endif -endif - -celt_c_args = [] -if host_system == 'windows' - celt_c_args += ['-DDLL_EXPORT'] -endif - -celt_lib = static_library('opus-celt', - celt_sources, - c_args: celt_c_args, - include_directories: opus_includes, - link_whole: celt_static_libs, - dependencies: libm, - install: false) diff --git a/Engine/lib/opus/celt/mfrngcod.h b/Engine/lib/opus/celt/mfrngcod.h deleted file mode 100644 index 809152a59..000000000 --- a/Engine/lib/opus/celt/mfrngcod.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2001-2008 Timothy B. Terriberry - Copyright (c) 2008-2009 Xiph.Org Foundation */ -/* - 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(_mfrngcode_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) -/*The total number of bits in each of the state registers.*/ -# define EC_CODE_BITS (32) -/*The maximum symbol value.*/ -# define EC_SYM_MAX ((1U<>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) -#endif diff --git a/Engine/lib/opus/celt/mips/celt_mipsr1.h b/Engine/lib/opus/celt/mips/celt_mipsr1.h deleted file mode 100644 index c332fe047..000000000 --- a/Engine/lib/opus/celt/mips/celt_mipsr1.h +++ /dev/null @@ -1,152 +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 - -#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" - -#define OVERRIDE_COMB_FILTER_CONST -#define 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;itwiddles[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 /* KISS_FFT_MIPSR1_H */ diff --git a/Engine/lib/opus/celt/mips/mdct_mipsr1.h b/Engine/lib/opus/celt/mips/mdct_mipsr1.h deleted file mode 100644 index 2934dab77..000000000 --- a/Engine/lib/opus/celt/mips/mdct_mipsr1.h +++ /dev/null @@ -1,288 +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" - -/* Forward MDCT trashes the input array */ -#define OVERRIDE_clt_mdct_forward -void clt_mdct_forward(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; - opus_val16 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; -#endif - - (void)arch; - - SAVE_STACK; - 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 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++ = 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; - } - } - - /* N/4 complex FFT, does not downscale anymore */ - opus_fft_impl(st, f2); - - /* 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,t[N4+i] , fp->r,t[i]); - yi = S_MUL_ADD(fp->r,t[N4+i] ,fp->i,t[i]); - *yp1 = yr; - *yp2 = yi; - fp++; - yp1 += 2*stride; - yp2 -= 2*stride; - } - } - RESTORE_STACK; -} - -#define OVERRIDE_clt_mdct_backward -void clt_mdct_backward(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; - const kiss_twiddle_scalar *trig; - - (void)arch; - - N = l->n; - trig = l->trig; - for (i=0;i>= 1; - trig += N; - } - N2 = N>>1; - N4 = N>>2; - - /* 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 = out+(overlap>>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))); - - /* Post-rotate and de-shuffle from both ends of the buffer at once to make - it in-place. */ - { - kiss_fft_scalar * OPUS_RESTRICT yp0 = out+(overlap>>1); - kiss_fft_scalar * OPUS_RESTRICT 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(re,t0 , im,t1); - yi = S_MUL_SUB(re,t1 , im,t0); - /* 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(re,t0,im,t1); - yi = S_MUL_SUB(re,t1,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--; - } - } -} -#endif /* __MDCT_MIPSR1_H__ */ diff --git a/Engine/lib/opus/celt/mips/pitch_mipsr1.h b/Engine/lib/opus/celt/mips/pitch_mipsr1.h deleted file mode 100644 index a9500aff5..000000000 --- a/Engine/lib/opus/celt/mips/pitch_mipsr1.h +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/** - @file pitch.h - @brief Pitch analysis - */ - -/* - 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 PITCH_MIPSR1_H -#define PITCH_MIPSR1_H - -#define 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; - opus_val32 xy01=0; - opus_val32 xy02=0; - - (void)arch; - - asm volatile("MULT $ac1, $0, $0"); - asm volatile("MULT $ac2, $0, $0"); - /* Compute the norm of X+Y and X-Y as |X|^2 + |Y|^2 +/- sum(xy) */ - for (j=0;j=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)); - } -} - -#define OVERRIDE_renormalise_vector -void renormalise_vector(celt_norm *X, int N, opus_val16 gain, int arch) -{ - int i; -#ifdef FIXED_POINT - int k; -#endif - opus_val32 E = EPSILON; - opus_val16 g; - opus_val32 t; - celt_norm *xptr = X; - int X0, X1; - - (void)arch; - - asm volatile("mult $ac1, $0, $0"); - asm volatile("MTLO %0, $ac1" : :"r" (E)); - /*if(N %4) - printf("error");*/ - for (i=0;i>1; -#endif - t = VSHR32(E, 2*(k-7)); - g = MULT16_16_P15(celt_rsqrt_norm(t),gain); - - xptr = X; - for (i=0;i= 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; -} - -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; -} - -#endif /* CUSTOM_MODES */ - -CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) -{ - int i; -#ifdef CUSTOM_MODES - CELTMode *mode=NULL; - int res; - opus_val16 *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 -#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]; - } - } - } -#endif /* CUSTOM_MODES_ONLY */ - -#ifndef CUSTOM_MODES - if (error) - *error = OPUS_BAD_ARG; - return NULL; -#else - - /* 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; - } - if (frame_size < 40 || frame_size > 1024 || frame_size%2!=0) - { - 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. */ - 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 - - 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); - - compute_allocation_table(mode); - if (mode->allocVectors==NULL) - goto failure; - - window = (opus_val16*)opus_alloc(mode->overlap*sizeof(opus_val16)); - 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 - 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)))); -#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); - - if (clt_mdct_init(&mode->mdct, 2*mode->shortMdctSize*mode->nbShortMdcts, - mode->maxLM, arch) == 0) - goto failure; - - if (error) - *error = OPUS_OK; - - return mode; -failure: - if (error) - *error = OPUS_ALLOC_FAIL; - if (mode!=NULL) - opus_custom_mode_destroy(mode); - return NULL; -#endif /* !CUSTOM_MODES */ -} - -#ifdef CUSTOM_MODES -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;ieBands); - 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); - - opus_free((CELTMode *)mode); -} -#endif diff --git a/Engine/lib/opus/celt/modes.h b/Engine/lib/opus/celt/modes.h deleted file mode 100644 index be813ccc8..000000000 --- a/Engine/lib/opus/celt/modes.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 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 MODES_H -#define MODES_H - -#include "opus_types.h" -#include "celt.h" -#include "arch.h" -#include "mdct.h" -#include "entenc.h" -#include "entdec.h" - -#define MAX_PERIOD 1024 - -typedef struct { - int size; - const opus_int16 *index; - const unsigned char *bits; - const unsigned char *caps; -} PulseCache; - -/** Mode definition (opaque) - @brief Mode definition - */ -struct OpusCustomMode { - opus_int32 Fs; - int overlap; - - int nbEBands; - int effEBands; - opus_val16 preemph[4]; - const opus_int16 *eBands; /**< Definition for each "pseudo-critical band" */ - - 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; - - const opus_val16 *window; - mdct_lookup mdct; - PulseCache cache; -}; - - -#endif diff --git a/Engine/lib/opus/celt/opus_custom_demo.c b/Engine/lib/opus/celt/opus_custom_demo.c deleted file mode 100644 index ae41c0de5..000000000 --- a/Engine/lib/opus/celt/opus_custom_demo.c +++ /dev/null @@ -1,210 +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 -#include -#include -#include - -#define MAX_PACKET 1275 - -int main(int argc, char *argv[]) -{ - int err; - char *inFile, *outFile; - FILE *fin, *fout; - OpusCustomMode *mode=NULL; - OpusCustomEncoder *enc; - OpusCustomDecoder *dec; - int len; - opus_int32 frame_size, channels, rate; - int bytes_per_packet; - unsigned char data[MAX_PACKET]; - int complexity; -#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) - int i; - double rmsd = 0; -#endif - int count = 0; - opus_int32 skip; - opus_int16 *in, *out; - if (argc != 9 && argc != 8 && argc != 7) - { - fprintf (stderr, "Usage: test_opus_custom " - " [ [packet loss rate]] " - " \n"); - return 1; - } - - rate = (opus_int32)atol(argv[1]); - channels = atoi(argv[2]); - frame_size = atoi(argv[3]); - mode = opus_custom_mode_create(rate, frame_size, NULL); - if (mode == NULL) - { - fprintf(stderr, "failed to create a mode\n"); - return 1; - } - - bytes_per_packet = atoi(argv[4]); - if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET) - { - fprintf (stderr, "bytes per packet must be between 0 and %d\n", - MAX_PACKET); - return 1; - } - - inFile = argv[argc-2]; - fin = fopen(inFile, "rb"); - if (!fin) - { - fprintf (stderr, "Could not open input file %s\n", argv[argc-2]); - return 1; - } - outFile = argv[argc-1]; - fout = fopen(outFile, "wb+"); - if (!fout) - { - fprintf (stderr, "Could not open output file %s\n", argv[argc-1]); - fclose(fin); - return 1; - } - - enc = opus_custom_encoder_create(mode, channels, &err); - if (err != 0) - { - fprintf(stderr, "Failed to create the encoder: %s\n", opus_strerror(err)); - fclose(fin); - fclose(fout); - return 1; - } - dec = opus_custom_decoder_create(mode, channels, &err); - if (err != 0) - { - fprintf(stderr, "Failed to create the decoder: %s\n", opus_strerror(err)); - fclose(fin); - fclose(fout); - return 1; - } - opus_custom_decoder_ctl(dec, OPUS_GET_LOOKAHEAD(&skip)); - - if (argc>7) - { - complexity=atoi(argv[5]); - opus_custom_encoder_ctl(enc,OPUS_SET_COMPLEXITY(complexity)); - } - - in = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16)); - out = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16)); - - while (!feof(fin)) - { - int ret; - err = fread(in, sizeof(short), frame_size*channels, fin); - if (feof(fin)) - break; - len = opus_custom_encode(enc, in, frame_size, data, bytes_per_packet); - if (len <= 0) - fprintf (stderr, "opus_custom_encode() failed: %s\n", opus_strerror(len)); - - /* This is for simulating bit errors */ -#if 0 - int errors = 0; - int eid = 0; - /* This simulates random bit error */ - for (i=0;i 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); - return 1; - } else { - fprintf (stderr, "Encoder matches decoder!!\n"); - } -#endif - return 0; -} - diff --git a/Engine/lib/opus/celt/os_support.h b/Engine/lib/opus/celt/os_support.h deleted file mode 100644 index 009bf861d..000000000 --- a/Engine/lib/opus/celt/os_support.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (C) 2007 Jean-Marc Valin - - File: os_support.h - This is the (tiny) OS abstraction layer. Aside from math.h, this is the - only place where system headers are allowed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. 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 AUTHOR ``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 AUTHOR 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 OS_SUPPORT_H -#define OS_SUPPORT_H - -#ifdef CUSTOM_SUPPORT -# include "custom_support.h" -#endif - -#include "opus_types.h" -#include "opus_defines.h" - -#include -#include - -/** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */ -#ifndef OVERRIDE_OPUS_ALLOC -static OPUS_INLINE void *opus_alloc (size_t size) -{ - return malloc(size); -} -#endif - -/** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */ -#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); -} -#endif - -/** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */ -#ifndef OVERRIDE_OPUS_FREE -static OPUS_INLINE void opus_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)) )) -#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)) )) -#endif - -/** Set n elements of dst to zero */ -#ifndef OVERRIDE_OPUS_CLEAR -#define OPUS_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*/ - -#endif /* OS_SUPPORT_H */ - diff --git a/Engine/lib/opus/celt/pitch.c b/Engine/lib/opus/celt/pitch.c deleted file mode 100644 index 7998db416..000000000 --- a/Engine/lib/opus/celt/pitch.c +++ /dev/null @@ -1,546 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/** - @file pitch.c - @brief Pitch analysis - */ - -/* - 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 "pitch.h" -#include "os_support.h" -#include "modes.h" -#include "stack_alloc.h" -#include "mathops.h" -#include "celt_lpc.h" - -static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len, - int max_pitch, int *best_pitch -#ifdef FIXED_POINT - , int yshift, opus_val32 maxcorr -#endif - ) -{ - int i, j; - opus_val32 Syy=1; - opus_val16 best_num[2]; - opus_val32 best_den[2]; -#ifdef FIXED_POINT - int xshift; - - xshift = 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)); -#ifndef FIXED_POINT - /* 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; - } - } - } - 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;i>1;i++) - x_lp[i] = SHR32(x[0][(2*i-1)], shift+2) + SHR32(x[0][(2*i+1)], shift+2) + SHR32(x[0][2*i], shift+1); - x_lp[0] = SHR32(x[0][1], shift+2) + SHR32(x[0][0], shift+1); - if (C==2) - { - for (i=1;i>1;i++) - x_lp[i] += SHR32(x[1][(2*i-1)], shift+2) + SHR32(x[1][(2*i+1)], shift+2) + SHR32(x[1][2*i], shift+1); - x_lp[0] += SHR32(x[1][1], shift+2) + SHR32(x[1][0], shift+1); - } -#else - for (i=1;i>1;i++) - x_lp[i] = .25f*x[0][(2*i-1)] + .25f*x[0][(2*i+1)] + .5f*x[0][2*i]; - x_lp[0] = .25f*x[0][1] + .5f*x[0][0]; - if (C==2) - { - for (i=1;i>1;i++) - x_lp[i] += .25f*x[1][(2*i-1)] + .25f*x[1][(2*i+1)] + .5f*x[1][2*i]; - x_lp[0] += .25f*x[1][1] + .5f*x[1][0]; - } -#endif - _celt_autocorr(x_lp, ac, NULL, 0, - 4, len>>1, arch); - - /* Noise floor -40 dB */ -#ifdef FIXED_POINT - ac[0] += SHR32(ac[0],13); -#else - ac[0] *= 1.0001f; -#endif - /* Lag windowing */ - for (i=1;i<=4;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]); -#else - ac[i] -= ac[i]*(.008f*i)*(.008f*i); -#endif - } - - _celt_lpc(lpc, ac, 4); - for (i=0;i<4;i++) - { - tmp = MULT16_16_Q15(QCONST16(.9f,15), tmp); - lpc[i] = MULT16_16_Q15(lpc[i], tmp); - } - /* Add a zero */ - lpc2[0] = lpc[0] + QCONST16(.8f,SIG_SHIFT); - lpc2[1] = lpc[1] + MULT16_16_Q15(c1,lpc[0]); - lpc2[2] = lpc[2] + MULT16_16_Q15(c1,lpc[1]); - lpc2[3] = lpc[3] + MULT16_16_Q15(c1,lpc[2]); - lpc2[4] = MULT16_16_Q15(c1,lpc[3]); - celt_fir5(x_lp, lpc2, len>>1); -} - -/* Pure C implementation. */ -#ifdef FIXED_POINT -opus_val32 -#else -void -#endif -celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, - opus_val32 *xcorr, int len, int max_pitch, int arch) -{ - -#if 0 /* This is a simple version of the pitch correlation that should work - well on DSPs like Blackfin and TI C5x/C6x */ - int i, j; -#ifdef FIXED_POINT - opus_val32 maxcorr=1; -#endif -#if !defined(OVERRIDE_PITCH_XCORR) - (void)arch; -#endif - for (i=0;i0); - celt_sig_assert(((size_t)_x&3)==0); - for (i=0;i0); - 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); - - /* 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]; - -#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)))-11; - 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; - } -#endif - - /* Coarse search with 4x decimation */ - -#ifdef FIXED_POINT - maxcorr = -#endif - 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 -#ifdef FIXED_POINT - , 0, maxcorr -#endif - ); - - /* Finer search with 2x decimation */ -#ifdef FIXED_POINT - 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; -#ifdef FIXED_POINT - sum = 0; - for (j=0;j>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); -#endif - xcorr[i] = MAX32(-1, sum); -#ifdef FIXED_POINT - maxcorr = MAX32(maxcorr, sum); -#endif - } - find_best_pitch(xcorr, y, len>>1, max_pitch>>1, best_pitch -#ifdef FIXED_POINT - , 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; -} - -#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(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); -} -#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_=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 -#include "os_support.h" -#include "arch.h" -#include "mathops.h" -#include "stack_alloc.h" -#include "rate.h" - -#ifdef FIXED_POINT -/* Mean energy in each band quantized in Q4 */ -const signed char eMeans[25] = { - 103,100, 92, 85, 81, - 77, 72, 70, 78, 75, - 73, 71, 78, 74, 69, - 72, 70, 74, 76, 71, - 60, 60, 60, 60, 60 -}; -#else -/* Mean energy in each band quantized in Q4 and converted back to float */ -const opus_val16 eMeans[25] = { - 6.437500f, 6.250000f, 5.750000f, 5.312500f, 5.062500f, - 4.812500f, 4.500000f, 4.375000f, 4.875000f, 4.687500f, - 4.562500f, 4.437500f, 4.875000f, 4.625000f, 4.312500f, - 4.500000f, 4.375000f, 4.625000f, 4.750000f, 4.437500f, - 3.750000f, 3.750000f, 3.750000f, 3.750000f, 3.750000f -}; -#endif -/* prediction coefficients: 0.9, 0.8, 0.65, 0.5 */ -#ifdef FIXED_POINT -static const opus_val16 pred_coef[4] = {29440, 26112, 21248, 16384}; -static const opus_val16 beta_coef[4] = {30147, 22282, 12124, 6554}; -static const opus_val16 beta_intra = 4915; -#else -static const opus_val16 pred_coef[4] = {29440/32768., 26112/32768., 21248/32768., 16384/32768.}; -static const opus_val16 beta_coef[4] = {30147/32768., 22282/32768., 12124/32768., 6554/32768.}; -static const opus_val16 beta_intra = 4915/32768.; -#endif - -/*Parameters of the Laplace-like probability models used for the coarse energy. - There is one pair of parameters for each frame size, prediction type - (inter/intra), and band number. - The first number of each pair is the probability of 0, and the second is the - decay rate, both in Q8 precision.*/ -static const unsigned char e_prob_model[4][2][42] = { - /*120 sample frames.*/ - { - /*Inter*/ - { - 72, 127, 65, 129, 66, 128, 65, 128, 64, 128, 62, 128, 64, 128, - 64, 128, 92, 78, 92, 79, 92, 78, 90, 79, 116, 41, 115, 40, - 114, 40, 132, 26, 132, 26, 145, 17, 161, 12, 176, 10, 177, 11 - }, - /*Intra*/ - { - 24, 179, 48, 138, 54, 135, 54, 132, 53, 134, 56, 133, 55, 132, - 55, 132, 61, 114, 70, 96, 74, 88, 75, 88, 87, 74, 89, 66, - 91, 67, 100, 59, 108, 50, 120, 40, 122, 37, 97, 43, 78, 50 - } - }, - /*240 sample frames.*/ - { - /*Inter*/ - { - 83, 78, 84, 81, 88, 75, 86, 74, 87, 71, 90, 73, 93, 74, - 93, 74, 109, 40, 114, 36, 117, 34, 117, 34, 143, 17, 145, 18, - 146, 19, 162, 12, 165, 10, 178, 7, 189, 6, 190, 8, 177, 9 - }, - /*Intra*/ - { - 23, 178, 54, 115, 63, 102, 66, 98, 69, 99, 74, 89, 71, 91, - 73, 91, 78, 89, 86, 80, 92, 66, 93, 64, 102, 59, 103, 60, - 104, 60, 117, 52, 123, 44, 138, 35, 133, 31, 97, 38, 77, 45 - } - }, - /*480 sample frames.*/ - { - /*Inter*/ - { - 61, 90, 93, 60, 105, 42, 107, 41, 110, 45, 116, 38, 113, 38, - 112, 38, 124, 26, 132, 27, 136, 19, 140, 20, 155, 14, 159, 16, - 158, 18, 170, 13, 177, 10, 187, 8, 192, 6, 175, 9, 159, 10 - }, - /*Intra*/ - { - 21, 178, 59, 110, 71, 86, 75, 85, 84, 83, 91, 66, 88, 73, - 87, 72, 92, 75, 98, 72, 105, 58, 107, 54, 115, 52, 114, 55, - 112, 56, 129, 51, 132, 40, 150, 33, 140, 29, 98, 35, 77, 42 - } - }, - /*960 sample frames.*/ - { - /*Inter*/ - { - 42, 121, 96, 66, 108, 43, 111, 40, 117, 44, 123, 32, 120, 36, - 119, 33, 127, 33, 134, 34, 139, 21, 147, 23, 152, 20, 158, 25, - 154, 26, 166, 21, 173, 16, 184, 13, 184, 10, 150, 13, 139, 15 - }, - /*Intra*/ - { - 22, 178, 63, 114, 74, 82, 84, 83, 92, 82, 103, 62, 96, 72, - 96, 67, 101, 73, 107, 72, 113, 55, 118, 52, 125, 52, 118, 52, - 117, 55, 135, 49, 137, 39, 157, 32, 145, 29, 97, 33, 77, 40 - } - } -}; - -static const unsigned char small_energy_icdf[3]={2,1,0}; - -static opus_val32 loss_distortion(const opus_val16 *eBands, opus_val16 *oldEBands, int start, int end, int len, int C) -{ - int c, i; - opus_val32 dist = 0; - c=0; do { - for (i=start;inbEBands]; - oldE = MAX16(-QCONST16(9.f,DB_SHIFT), oldEBands[i+c*m->nbEBands]); -#ifdef FIXED_POINT - f = SHL32(EXTEND32(x),7) - PSHR32(MULT16_16(coef,oldE), 8) - prev[c]; - /* Rounding to nearest integer here is really important! */ - qi = (f+QCONST32(.5f,DB_SHIFT+7))>>(DB_SHIFT+7); - decay_bound = EXTRACT16(MAX32(-QCONST16(28.f,DB_SHIFT), - SUB32((opus_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 = MAX16(-QCONST16(28.f,DB_SHIFT), 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)SHR16(SUB16(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] = PSHR32(f,7) - SHL16(qi,DB_SHIFT); - badness += abs(qi0-qi); - q = (opus_val32)SHL32(EXTEND32(qi),DB_SHIFT); - - tmp = PSHR32(MULT16_16(coef,oldE),8) + prev[c] + SHL32(q,7); -#ifdef FIXED_POINT - tmp = MAX32(-QCONST32(28.f, DB_SHIFT+7), tmp); -#endif - oldEBands[i+c*m->nbEBands] = PSHR32(tmp, 7); - prev[c] = prev[c] + SHL32(q,7) - MULT16_16(beta,PSHR32(q,8)); - } while (++c < C); - } - return lfe ? 0 : badness; -} - -void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, - const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget, - opus_val16 *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; - opus_val16 max_decay; - VARDECL(opus_val16, oldEBands_intra); - VARDECL(opus_val16, 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 = QCONST16(16.f,DB_SHIFT); - if (end-start>10) - { -#ifdef FIXED_POINT - max_decay = MIN32(max_decay, SHL32(EXTEND32(nbAvailableBytes),DB_SHIFT-3)); -#else - max_decay = MIN32(max_decay, .125f*nbAvailableBytes); -#endif - } - if (lfe) - max_decay = QCONST16(3.f,DB_SHIFT); - enc_start_state = *enc; - - ALLOC(oldEBands_intra, C*m->nbEBands, opus_val16); - ALLOC(error_intra, C*m->nbEBands, opus_val16); - OPUS_COPY(oldEBands_intra, oldEBands, C*m->nbEBands); - - if (two_pass || intra) - { - badness1 = 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, - 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), - new_distortion); - - RESTORE_STACK; -} - -void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int C) -{ - int i, c; - - /* Encode finer resolution */ - for (i=start;inbEBands]+QCONST16(.5f,DB_SHIFT))>>(DB_SHIFT-fine_quant[i]); -#else - q2 = (int)floor((error[i+c*m->nbEBands]+.5f)*frac); -#endif - if (q2 > frac-1) - q2 = frac-1; - if (q2<0) - q2 = 0; - ec_enc_bits(enc, q2, fine_quant[i]); -#ifdef FIXED_POINT - offset = SUB16(SHR32(SHL32(EXTEND32(q2),DB_SHIFT)+QCONST16(.5f,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT)); -#else - offset = (q2+.5f)*(1<<(14-fine_quant[i]))*(1.f/16384) - .5f; -#endif - 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, opus_val16 *oldEBands, opus_val16 *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; - opus_val16 offset; - q2 = error[i+c*m->nbEBands]<0 ? 0 : 1; - ec_enc_bits(enc, q2, 1); -#ifdef FIXED_POINT - offset = SHR16(SHL16(q2,DB_SHIFT)-QCONST16(.5f,DB_SHIFT),fine_quant[i]+1); -#else - offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384); -#endif - 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, opus_val16 *oldEBands, int intra, ec_dec *dec, int C, int LM) -{ - const unsigned char *prob_model = e_prob_model[LM][intra]; - int i, c; - opus_val32 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] = MAX16(-QCONST16(9.f,DB_SHIFT), oldEBands[i+c*m->nbEBands]); - tmp = PSHR32(MULT16_16(coef,oldEBands[i+c*m->nbEBands]),8) + prev[c] + SHL32(q,7); -#ifdef FIXED_POINT - tmp = MAX32(-QCONST32(28.f, DB_SHIFT+7), tmp); -#endif - oldEBands[i+c*m->nbEBands] = PSHR32(tmp, 7); - prev[c] = prev[c] + SHL32(q,7) - MULT16_16(beta,PSHR32(q,8)); - } while (++c < C); - } -} - -void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int C) -{ - int i, c; - /* Decode finer resolution */ - for (i=start;inbEBands] += offset; - } while (++c < C); - } -} - -void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *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; - opus_val16 offset; - q2 = ec_dec_bits(dec, 1); -#ifdef FIXED_POINT - offset = SHR16(SHL16(q2,DB_SHIFT)-QCONST16(.5f,DB_SHIFT),fine_quant[i]+1); -#else - offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384); -#endif - oldEBands[i+c*m->nbEBands] += offset; - bits_left--; - } while (++c < C); - } - } -} - -void amp2Log2(const CELTMode *m, int effEnd, int end, - celt_ener *bandE, opus_val16 *bandLogE, int C) -{ - int c, i; - c=0; - do { - for (i=0;inbEBands] = - celt_log2(bandE[i+c*m->nbEBands]) - - SHL16((opus_val16)eMeans[i],6); -#ifdef FIXED_POINT - /* Compensate for bandE[] being Q12 but celt_log2() taking a Q14 input. */ - bandLogE[i+c*m->nbEBands] += QCONST16(2.f, DB_SHIFT); -#endif - } - for (i=effEnd;inbEBands+i] = -QCONST16(14.f,DB_SHIFT); - } while (++c < C); -} diff --git a/Engine/lib/opus/celt/quant_bands.h b/Engine/lib/opus/celt/quant_bands.h deleted file mode 100644 index 0490bca4b..000000000 --- a/Engine/lib/opus/celt/quant_bands.h +++ /dev/null @@ -1,66 +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. -*/ - -#ifndef QUANT_BANDS -#define QUANT_BANDS - -#include "arch.h" -#include "modes.h" -#include "entenc.h" -#include "entdec.h" -#include "mathops.h" - -#ifdef FIXED_POINT -extern const signed char eMeans[25]; -#else -extern const opus_val16 eMeans[25]; -#endif - -void amp2Log2(const CELTMode *m, int effEnd, int end, - celt_ener *bandE, opus_val16 *bandLogE, int C); - -void log2Amp(const CELTMode *m, int start, int end, - celt_ener *eBands, const opus_val16 *oldEBands, int C); - -void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, - const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget, - opus_val16 *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 quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int C); - -void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *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, opus_val16 *oldEBands, int intra, ec_dec *dec, int C, int LM); - -void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int C); - -void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int C); - -#endif /* QUANT_BANDS */ diff --git a/Engine/lib/opus/celt/rate.c b/Engine/lib/opus/celt/rate.c deleted file mode 100644 index 7f7ad3fa0..000000000 --- a/Engine/lib/opus/celt/rate.c +++ /dev/null @@ -1,646 +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 -#include "modes.h" -#include "cwrs.h" -#include "arch.h" -#include "os_support.h" - -#include "entcode.h" -#include "rate.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 -}; - -#ifdef 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]; - } -} - -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; - } - } - } - 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]+((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<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 { - 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 cocentrated 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 = j (depth_threshold*band_width<>4 && j<=signalBandwidth)) -#endif - { - ec_enc_bit_logp(ec, 1, 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]<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, - 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; -} - diff --git a/Engine/lib/opus/celt/rate.h b/Engine/lib/opus/celt/rate.h deleted file mode 100644 index fad5e412d..000000000 --- a/Engine/lib/opus/celt/rate.h +++ /dev/null @@ -1,101 +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. -*/ - -#ifndef RATE_H -#define RATE_H - -#define MAX_PSEUDO 40 -#define LOG_MAX_PSEUDO 6 - -#define CELT_MAX_PULSES 128 - -#define MAX_FINE_BITS 8 - -#define FINE_OFFSET 21 -#define QTHETA_OFFSET 4 -#define QTHETA_OFFSET_TWOPHASE 16 - -#include "cwrs.h" -#include "modes.h" - -void 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 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 OPUS_INLINE int 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; -} - -/** 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 - 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); - -#endif diff --git a/Engine/lib/opus/celt/stack_alloc.h b/Engine/lib/opus/celt/stack_alloc.h deleted file mode 100644 index ae40e2a16..000000000 --- a/Engine/lib/opus/celt/stack_alloc.h +++ /dev/null @@ -1,184 +0,0 @@ -/* Copyright (C) 2002-2003 Jean-Marc Valin - Copyright (C) 2007-2009 Xiph.Org Foundation */ -/** - @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 - 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 STACK_ALLOC_H -#define STACK_ALLOC_H - -#include "opus_types.h" -#include "opus_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." -#endif - -#ifdef USE_ALLOCA -# ifdef _WIN32 -# include -# else -# ifdef HAVE_ALLOCA_H -# include -# else -# include -# endif -# endif -#endif - -/** - * @def ALIGN(stack, size) - * - * Aligns the stack to a 'size' boundary - * - * @param stack Stack - * @param size New size boundary - */ - -/** - * @def PUSH(stack, size, type) - * - * Allocates 'size' elements of type 'type' on the stack - * - * @param stack Stack - * @param size Number of elements - * @param type Type of element - */ - -/** - * @def VARDECL(var) - * - * Declare variable on stack - * - * @param var Variable to declare - */ - -/** - * @def ALLOC(var, size, type) - * - * Allocate 'size' elements of 'type' on stack - * - * @param var Name of variable to allocate - * @param size Number of elements - * @param type Type of element - */ - -#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 -/* C99 does not allow VLAs of size zero */ -#define ALLOC_NONE 1 - -#elif defined(USE_ALLOCA) - -#define VARDECL(type, var) type *var - -# ifdef _WIN32 -# define ALLOC(var, size, type) var = ((type*)_alloca(sizeof(type)*(size))) -# else -# define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size))) -# endif - -#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 -extern char *global_stack; -extern char *scratch_ptr; -#endif /* CELT_C */ - -#ifdef ENABLE_VALGRIND - -#include - -#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),sizeof(type)/sizeof(char)),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=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; - -#else - -#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) -#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/sizeof(char)),(stack)+=(size)*(sizeof(type)/sizeof(char)),(type*)((stack)-(size)*(sizeof(type)/sizeof(char)))) -#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=opus_alloc_scratch(GLOBAL_STACK_SIZE)) : global_stack); _saved_stack = global_stack; - -#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 - -#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 - -#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) - -#endif - - -#endif /* STACK_ALLOC_H */ diff --git a/Engine/lib/opus/celt/static_modes_fixed.h b/Engine/lib/opus/celt/static_modes_fixed.h deleted file mode 100644 index 8717d626c..000000000 --- a/Engine/lib/opus/celt/static_modes_fixed.h +++ /dev/null @@ -1,892 +0,0 @@ -/* The contents of this file was automatically generated by dump_modes.c - with arguments: 48000 960 - It contains static definitions for some pre-defined modes. */ -#include "modes.h" -#include "rate.h" - -#ifdef HAVE_ARM_NE10 -#define OVERRIDE_FFT 1 -#include "static_modes_fixed_arm_ne10.h" -#endif - -#ifndef DEF_WINDOW120 -#define DEF_WINDOW120 -static const opus_val16 window120[120] = { -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 - -#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_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, -}; -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, }; -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 - -#ifndef FFT_TWIDDLES48000_960 -#define FFT_TWIDDLES48000_960 -static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { -{32767, 0}, {32766, -429}, -{32757, -858}, {32743, -1287}, -{32724, -1715}, {32698, -2143}, -{32667, -2570}, {32631, -2998}, -{32588, -3425}, {32541, -3851}, -{32488, -4277}, {32429, -4701}, -{32364, -5125}, {32295, -5548}, -{32219, -5971}, {32138, -6393}, -{32051, -6813}, {31960, -7231}, -{31863, -7650}, {31760, -8067}, -{31652, -8481}, {31539, -8895}, -{31419, -9306}, {31294, -9716}, -{31165, -10126}, {31030, -10532}, -{30889, -10937}, {30743, -11340}, -{30592, -11741}, {30436, -12141}, -{30274, -12540}, {30107, -12935}, -{29936, -13328}, {29758, -13718}, -{29577, -14107}, {29390, -14493}, -{29197, -14875}, {29000, -15257}, -{28797, -15635}, {28590, -16010}, -{28379, -16384}, {28162, -16753}, -{27940, -17119}, {27714, -17484}, -{27482, -17845}, {27246, -18205}, -{27006, -18560}, {26760, -18911}, -{26510, -19260}, {26257, -19606}, -{25997, -19947}, {25734, -20286}, -{25466, -20621}, {25194, -20952}, -{24918, -21281}, {24637, -21605}, -{24353, -21926}, {24063, -22242}, -{23770, -22555}, {23473, -22865}, -{23171, -23171}, {22866, -23472}, -{22557, -23769}, {22244, -24063}, -{21927, -24352}, {21606, -24636}, -{21282, -24917}, {20954, -25194}, -{20622, -25465}, {20288, -25733}, -{19949, -25997}, {19607, -26255}, -{19261, -26509}, {18914, -26760}, -{18561, -27004}, {18205, -27246}, -{17846, -27481}, {17485, -27713}, -{17122, -27940}, {16755, -28162}, -{16385, -28378}, {16012, -28590}, -{15636, -28797}, {15258, -28999}, -{14878, -29197}, {14494, -29389}, -{14108, -29576}, {13720, -29757}, -{13329, -29934}, {12937, -30107}, -{12540, -30274}, {12142, -30435}, -{11744, -30592}, {11342, -30743}, -{10939, -30889}, {10534, -31030}, -{10127, -31164}, {9718, -31294}, -{9307, -31418}, {8895, -31537}, -{8482, -31652}, {8067, -31759}, -{7650, -31862}, {7233, -31960}, -{6815, -32051}, {6393, -32138}, -{5973, -32219}, {5549, -32294}, -{5127, -32364}, {4703, -32429}, -{4278, -32487}, {3852, -32541}, -{3426, -32588}, {2999, -32630}, -{2572, -32667}, {2144, -32698}, -{1716, -32724}, {1287, -32742}, -{860, -32757}, {430, -32766}, -{0, -32767}, {-429, -32766}, -{-858, -32757}, {-1287, -32743}, -{-1715, -32724}, {-2143, -32698}, -{-2570, -32667}, {-2998, -32631}, -{-3425, -32588}, {-3851, -32541}, -{-4277, -32488}, {-4701, -32429}, -{-5125, -32364}, {-5548, -32295}, -{-5971, -32219}, {-6393, -32138}, -{-6813, -32051}, {-7231, -31960}, -{-7650, -31863}, {-8067, -31760}, -{-8481, -31652}, {-8895, -31539}, -{-9306, -31419}, {-9716, -31294}, -{-10126, -31165}, {-10532, -31030}, -{-10937, -30889}, {-11340, -30743}, -{-11741, -30592}, {-12141, -30436}, -{-12540, -30274}, {-12935, -30107}, -{-13328, -29936}, {-13718, -29758}, -{-14107, -29577}, {-14493, -29390}, -{-14875, -29197}, {-15257, -29000}, -{-15635, -28797}, {-16010, -28590}, -{-16384, -28379}, {-16753, -28162}, -{-17119, -27940}, {-17484, -27714}, -{-17845, -27482}, {-18205, -27246}, -{-18560, -27006}, {-18911, -26760}, -{-19260, -26510}, {-19606, -26257}, -{-19947, -25997}, {-20286, -25734}, -{-20621, -25466}, {-20952, -25194}, -{-21281, -24918}, {-21605, -24637}, -{-21926, -24353}, {-22242, -24063}, -{-22555, -23770}, {-22865, -23473}, -{-23171, -23171}, {-23472, -22866}, -{-23769, -22557}, {-24063, -22244}, -{-24352, -21927}, {-24636, -21606}, -{-24917, -21282}, {-25194, -20954}, -{-25465, -20622}, {-25733, -20288}, -{-25997, -19949}, {-26255, -19607}, -{-26509, -19261}, {-26760, -18914}, -{-27004, -18561}, {-27246, -18205}, -{-27481, -17846}, {-27713, -17485}, -{-27940, -17122}, {-28162, -16755}, -{-28378, -16385}, {-28590, -16012}, -{-28797, -15636}, {-28999, -15258}, -{-29197, -14878}, {-29389, -14494}, -{-29576, -14108}, {-29757, -13720}, -{-29934, -13329}, {-30107, -12937}, -{-30274, -12540}, {-30435, -12142}, -{-30592, -11744}, {-30743, -11342}, -{-30889, -10939}, {-31030, -10534}, -{-31164, -10127}, {-31294, -9718}, -{-31418, -9307}, {-31537, -8895}, -{-31652, -8482}, {-31759, -8067}, -{-31862, -7650}, {-31960, -7233}, -{-32051, -6815}, {-32138, -6393}, -{-32219, -5973}, {-32294, -5549}, -{-32364, -5127}, {-32429, -4703}, -{-32487, -4278}, {-32541, -3852}, -{-32588, -3426}, {-32630, -2999}, -{-32667, -2572}, {-32698, -2144}, -{-32724, -1716}, {-32742, -1287}, -{-32757, -860}, {-32766, -430}, -{-32767, 0}, {-32766, 429}, -{-32757, 858}, {-32743, 1287}, -{-32724, 1715}, {-32698, 2143}, -{-32667, 2570}, {-32631, 2998}, -{-32588, 3425}, {-32541, 3851}, -{-32488, 4277}, {-32429, 4701}, -{-32364, 5125}, {-32295, 5548}, -{-32219, 5971}, {-32138, 6393}, -{-32051, 6813}, {-31960, 7231}, -{-31863, 7650}, {-31760, 8067}, -{-31652, 8481}, {-31539, 8895}, -{-31419, 9306}, {-31294, 9716}, -{-31165, 10126}, {-31030, 10532}, -{-30889, 10937}, {-30743, 11340}, -{-30592, 11741}, {-30436, 12141}, -{-30274, 12540}, {-30107, 12935}, -{-29936, 13328}, {-29758, 13718}, -{-29577, 14107}, {-29390, 14493}, -{-29197, 14875}, {-29000, 15257}, -{-28797, 15635}, {-28590, 16010}, -{-28379, 16384}, {-28162, 16753}, -{-27940, 17119}, {-27714, 17484}, -{-27482, 17845}, {-27246, 18205}, -{-27006, 18560}, {-26760, 18911}, -{-26510, 19260}, {-26257, 19606}, -{-25997, 19947}, {-25734, 20286}, -{-25466, 20621}, {-25194, 20952}, -{-24918, 21281}, {-24637, 21605}, -{-24353, 21926}, {-24063, 22242}, -{-23770, 22555}, {-23473, 22865}, -{-23171, 23171}, {-22866, 23472}, -{-22557, 23769}, {-22244, 24063}, -{-21927, 24352}, {-21606, 24636}, -{-21282, 24917}, {-20954, 25194}, -{-20622, 25465}, {-20288, 25733}, -{-19949, 25997}, {-19607, 26255}, -{-19261, 26509}, {-18914, 26760}, -{-18561, 27004}, {-18205, 27246}, -{-17846, 27481}, {-17485, 27713}, -{-17122, 27940}, {-16755, 28162}, -{-16385, 28378}, {-16012, 28590}, -{-15636, 28797}, {-15258, 28999}, -{-14878, 29197}, {-14494, 29389}, -{-14108, 29576}, {-13720, 29757}, -{-13329, 29934}, {-12937, 30107}, -{-12540, 30274}, {-12142, 30435}, -{-11744, 30592}, {-11342, 30743}, -{-10939, 30889}, {-10534, 31030}, -{-10127, 31164}, {-9718, 31294}, -{-9307, 31418}, {-8895, 31537}, -{-8482, 31652}, {-8067, 31759}, -{-7650, 31862}, {-7233, 31960}, -{-6815, 32051}, {-6393, 32138}, -{-5973, 32219}, {-5549, 32294}, -{-5127, 32364}, {-4703, 32429}, -{-4278, 32487}, {-3852, 32541}, -{-3426, 32588}, {-2999, 32630}, -{-2572, 32667}, {-2144, 32698}, -{-1716, 32724}, {-1287, 32742}, -{-860, 32757}, {-430, 32766}, -{0, 32767}, {429, 32766}, -{858, 32757}, {1287, 32743}, -{1715, 32724}, {2143, 32698}, -{2570, 32667}, {2998, 32631}, -{3425, 32588}, {3851, 32541}, -{4277, 32488}, {4701, 32429}, -{5125, 32364}, {5548, 32295}, -{5971, 32219}, {6393, 32138}, -{6813, 32051}, {7231, 31960}, -{7650, 31863}, {8067, 31760}, -{8481, 31652}, {8895, 31539}, -{9306, 31419}, {9716, 31294}, -{10126, 31165}, {10532, 31030}, -{10937, 30889}, {11340, 30743}, -{11741, 30592}, {12141, 30436}, -{12540, 30274}, {12935, 30107}, -{13328, 29936}, {13718, 29758}, -{14107, 29577}, {14493, 29390}, -{14875, 29197}, {15257, 29000}, -{15635, 28797}, {16010, 28590}, -{16384, 28379}, {16753, 28162}, -{17119, 27940}, {17484, 27714}, -{17845, 27482}, {18205, 27246}, -{18560, 27006}, {18911, 26760}, -{19260, 26510}, {19606, 26257}, -{19947, 25997}, {20286, 25734}, -{20621, 25466}, {20952, 25194}, -{21281, 24918}, {21605, 24637}, -{21926, 24353}, {22242, 24063}, -{22555, 23770}, {22865, 23473}, -{23171, 23171}, {23472, 22866}, -{23769, 22557}, {24063, 22244}, -{24352, 21927}, {24636, 21606}, -{24917, 21282}, {25194, 20954}, -{25465, 20622}, {25733, 20288}, -{25997, 19949}, {26255, 19607}, -{26509, 19261}, {26760, 18914}, -{27004, 18561}, {27246, 18205}, -{27481, 17846}, {27713, 17485}, -{27940, 17122}, {28162, 16755}, -{28378, 16385}, {28590, 16012}, -{28797, 15636}, {28999, 15258}, -{29197, 14878}, {29389, 14494}, -{29576, 14108}, {29757, 13720}, -{29934, 13329}, {30107, 12937}, -{30274, 12540}, {30435, 12142}, -{30592, 11744}, {30743, 11342}, -{30889, 10939}, {31030, 10534}, -{31164, 10127}, {31294, 9718}, -{31418, 9307}, {31537, 8895}, -{31652, 8482}, {31759, 8067}, -{31862, 7650}, {31960, 7233}, -{32051, 6815}, {32138, 6393}, -{32219, 5973}, {32294, 5549}, -{32364, 5127}, {32429, 4703}, -{32487, 4278}, {32541, 3852}, -{32588, 3426}, {32630, 2999}, -{32667, 2572}, {32698, 2144}, -{32724, 1716}, {32742, 1287}, -{32757, 860}, {32766, 430}, -}; -#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, -}; -#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, -}; -#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, -}; -#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, -}; -#endif - -#ifndef FFT_STATE48000_960_0 -#define FFT_STATE48000_960_0 -static const kiss_fft_state fft_state48000_960_0 = { -480, /* nfft */ -17476, /* 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 - -#ifndef FFT_STATE48000_960_1 -#define FFT_STATE48000_960_1 -static const kiss_fft_state fft_state48000_960_1 = { -240, /* nfft */ -17476, /* 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 - -#ifndef FFT_STATE48000_960_2 -#define FFT_STATE48000_960_2 -static const kiss_fft_state fft_state48000_960_2 = { -120, /* nfft */ -17476, /* 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 - -#ifndef FFT_STATE48000_960_3 -#define FFT_STATE48000_960_3 -static const kiss_fft_state fft_state48000_960_3 = { -60, /* nfft */ -17476, /* 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 - -#ifndef MDCT_TWIDDLES960 -#define MDCT_TWIDDLES960 -static const opus_val16 mdct_twiddles960[1800] = { -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 - -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 */ -}; - -/* List of all the available modes */ -#define TOTAL_MODES 1 -static const CELTMode * const static_mode_list[TOTAL_MODES] = { -&mode48000_960_120, -}; diff --git a/Engine/lib/opus/celt/static_modes_fixed_arm_ne10.h b/Engine/lib/opus/celt/static_modes_fixed_arm_ne10.h deleted file mode 100644 index 762309219..000000000 --- a/Engine/lib/opus/celt/static_modes_fixed_arm_ne10.h +++ /dev/null @@ -1,388 +0,0 @@ -/* The contents of this file was automatically generated by - * dump_mode_arm_ne10.c with arguments: 48000 960 - * It contains static definitions for some pre-defined modes. */ -#include - -#ifndef 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, }; -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, }; -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, }; -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, }; -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}, -}; -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}, -}; -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}, -}; -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}, -}; -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], -}; -static const arch_fft_state cfg_arch_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], -}; -static const arch_fft_state cfg_arch_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], -}; -static const arch_fft_state cfg_arch_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], -}; -static const arch_fft_state cfg_arch_60 = { -1, -(void *)&ne10_fft_state_int32_t_60, -}; - -#endif /* end NE10_FFT_PARAMS48000_960 */ diff --git a/Engine/lib/opus/celt/static_modes_float.h b/Engine/lib/opus/celt/static_modes_float.h deleted file mode 100644 index e102a3839..000000000 --- a/Engine/lib/opus/celt/static_modes_float.h +++ /dev/null @@ -1,888 +0,0 @@ -/* The contents of this file was automatically generated by dump_modes.c - with arguments: 48000 960 - It contains static definitions for some pre-defined modes. */ -#include "modes.h" -#include "rate.h" - -#ifdef HAVE_ARM_NE10 -#define OVERRIDE_FFT 1 -#include "static_modes_float_arm_ne10.h" -#endif - -#ifndef DEF_WINDOW120 -#define DEF_WINDOW120 -static const opus_val16 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.75605424f, 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, }; -#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, -}; -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, }; -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 - -#ifndef 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.1230318e-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.2246064e-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.8369095e-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, -}; -#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, -}; -#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, -}; -#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, -}; -#endif - -#ifndef FFT_STATE48000_960_0 -#define FFT_STATE48000_960_0 -static const kiss_fft_state fft_state48000_960_0 = { -480, /* nfft */ -0.002083333f, /* 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 - -#ifndef FFT_STATE48000_960_1 -#define FFT_STATE48000_960_1 -static const kiss_fft_state fft_state48000_960_1 = { -240, /* nfft */ -0.004166667f, /* 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 - -#ifndef FFT_STATE48000_960_2 -#define FFT_STATE48000_960_2 -static const kiss_fft_state fft_state48000_960_2 = { -120, /* nfft */ -0.008333333f, /* 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 - -#ifndef FFT_STATE48000_960_3 -#define FFT_STATE48000_960_3 -static const kiss_fft_state fft_state48000_960_3 = { -60, /* nfft */ -0.016666667f, /* 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 - -#ifndef MDCT_TWIDDLES960 -#define MDCT_TWIDDLES960 -static const opus_val16 mdct_twiddles960[1800] = { -0.99999994f, 0.99999321f, 0.99997580f, 0.99994773f, 0.99990886f, -0.99985933f, 0.99979913f, 0.99972820f, 0.99964654f, 0.99955416f, -0.99945110f, 0.99933738f, 0.99921292f, 0.99907774f, 0.99893188f, -0.99877530f, 0.99860805f, 0.99843007f, 0.99824142f, 0.99804211f, -0.99783206f, 0.99761140f, 0.99737996f, 0.99713790f, 0.99688518f, -0.99662173f, 0.99634761f, 0.99606287f, 0.99576741f, 0.99546129f, -0.99514455f, 0.99481714f, 0.99447906f, 0.99413031f, 0.99377096f, -0.99340093f, 0.99302030f, 0.99262899f, 0.99222708f, 0.99181455f, -0.99139136f, 0.99095762f, 0.99051321f, 0.99005818f, 0.98959261f, -0.98911643f, 0.98862964f, 0.98813224f, 0.98762429f, 0.98710573f, -0.98657662f, 0.98603696f, 0.98548669f, 0.98492593f, 0.98435456f, -0.98377270f, 0.98318028f, 0.98257732f, 0.98196387f, 0.98133987f, -0.98070538f, 0.98006040f, 0.97940493f, 0.97873890f, 0.97806245f, -0.97737551f, 0.97667813f, 0.97597027f, 0.97525197f, 0.97452319f, -0.97378403f, 0.97303438f, 0.97227436f, 0.97150391f, 0.97072303f, -0.96993178f, 0.96913016f, 0.96831810f, 0.96749574f, 0.96666300f, -0.96581990f, 0.96496642f, 0.96410263f, 0.96322852f, 0.96234411f, -0.96144938f, 0.96054435f, 0.95962906f, 0.95870346f, 0.95776761f, -0.95682150f, 0.95586514f, 0.95489854f, 0.95392174f, 0.95293468f, -0.95193744f, 0.95093000f, 0.94991243f, 0.94888461f, 0.94784665f, -0.94679856f, 0.94574034f, 0.94467193f, 0.94359344f, 0.94250488f, -0.94140619f, 0.94029742f, 0.93917859f, 0.93804967f, 0.93691075f, -0.93576175f, 0.93460274f, 0.93343377f, 0.93225473f, 0.93106574f, -0.92986679f, 0.92865789f, 0.92743903f, 0.92621022f, 0.92497152f, -0.92372292f, 0.92246443f, 0.92119598f, 0.91991776f, 0.91862965f, -0.91733170f, 0.91602397f, 0.91470635f, 0.91337901f, 0.91204184f, -0.91069490f, 0.90933824f, 0.90797186f, 0.90659571f, 0.90520984f, -0.90381432f, 0.90240908f, 0.90099424f, 0.89956969f, 0.89813554f, -0.89669174f, 0.89523834f, 0.89377540f, 0.89230281f, 0.89082074f, -0.88932908f, 0.88782793f, 0.88631725f, 0.88479710f, 0.88326746f, -0.88172835f, 0.88017982f, 0.87862182f, 0.87705445f, 0.87547767f, -0.87389153f, 0.87229604f, 0.87069118f, 0.86907703f, 0.86745358f, -0.86582077f, 0.86417878f, 0.86252749f, 0.86086690f, 0.85919720f, -0.85751826f, 0.85583007f, 0.85413277f, 0.85242635f, 0.85071075f, -0.84898609f, 0.84725231f, 0.84550947f, 0.84375757f, 0.84199661f, -0.84022665f, 0.83844769f, 0.83665979f, 0.83486289f, 0.83305705f, -0.83124226f, 0.82941860f, 0.82758605f, 0.82574469f, 0.82389444f, -0.82203537f, 0.82016748f, 0.81829083f, 0.81640542f, 0.81451124f, -0.81260836f, 0.81069672f, 0.80877650f, 0.80684757f, 0.80490994f, -0.80296379f, 0.80100900f, 0.79904562f, 0.79707366f, 0.79509324f, -0.79310423f, 0.79110676f, 0.78910083f, 0.78708643f, 0.78506362f, -0.78303236f, 0.78099275f, 0.77894479f, 0.77688843f, 0.77482378f, -0.77275085f, 0.77066964f, 0.76858020f, 0.76648247f, 0.76437658f, -0.76226246f, 0.76014024f, 0.75800985f, 0.75587130f, 0.75372469f, -0.75157005f, 0.74940729f, 0.74723655f, 0.74505776f, 0.74287105f, -0.74067634f, 0.73847371f, 0.73626316f, 0.73404479f, 0.73181850f, -0.72958434f, 0.72734243f, 0.72509271f, 0.72283524f, 0.72057003f, -0.71829706f, 0.71601641f, 0.71372813f, 0.71143216f, 0.70912862f, -0.70681745f, 0.70449871f, 0.70217246f, 0.69983864f, 0.69749737f, -0.69514859f, 0.69279242f, 0.69042879f, 0.68805778f, 0.68567938f, -0.68329364f, 0.68090063f, 0.67850029f, 0.67609268f, 0.67367786f, -0.67125577f, 0.66882652f, 0.66639012f, 0.66394657f, 0.66149592f, -0.65903819f, 0.65657341f, 0.65410155f, 0.65162271f, 0.64913690f, -0.64664418f, 0.64414448f, 0.64163786f, 0.63912445f, 0.63660413f, -0.63407701f, 0.63154310f, 0.62900239f, 0.62645501f, 0.62390089f, -0.62134010f, 0.61877263f, 0.61619854f, 0.61361790f, 0.61103064f, -0.60843682f, 0.60583651f, 0.60322970f, 0.60061646f, 0.59799677f, -0.59537065f, 0.59273821f, 0.59009939f, 0.58745426f, 0.58480281f, -0.58214509f, 0.57948118f, 0.57681108f, 0.57413477f, 0.57145232f, -0.56876373f, 0.56606907f, 0.56336832f, 0.56066155f, 0.55794877f, -0.55523002f, 0.55250537f, 0.54977477f, 0.54703826f, 0.54429591f, -0.54154772f, 0.53879374f, 0.53603399f, 0.53326851f, 0.53049731f, -0.52772039f, 0.52493787f, 0.52214974f, 0.51935595f, 0.51655668f, -0.51375180f, 0.51094145f, 0.50812566f, 0.50530440f, 0.50247771f, -0.49964568f, 0.49680826f, 0.49396557f, 0.49111754f, 0.48826426f, -0.48540577f, 0.48254207f, 0.47967321f, 0.47679919f, 0.47392011f, -0.47103590f, 0.46814668f, 0.46525243f, 0.46235323f, 0.45944905f, -0.45653993f, 0.45362595f, 0.45070711f, 0.44778344f, 0.44485497f, -0.44192174f, 0.43898380f, 0.43604112f, 0.43309379f, 0.43014181f, -0.42718524f, 0.42422408f, 0.42125839f, 0.41828820f, 0.41531351f, -0.41233435f, 0.40935081f, 0.40636289f, 0.40337059f, 0.40037400f, -0.39737311f, 0.39436796f, 0.39135858f, 0.38834500f, 0.38532731f, -0.38230544f, 0.37927949f, 0.37624949f, 0.37321547f, 0.37017745f, -0.36713544f, 0.36408952f, 0.36103970f, 0.35798600f, 0.35492846f, -0.35186714f, 0.34880206f, 0.34573323f, 0.34266070f, 0.33958447f, -0.33650464f, 0.33342120f, 0.33033419f, 0.32724363f, 0.32414958f, -0.32105204f, 0.31795108f, 0.31484672f, 0.31173897f, 0.30862790f, -0.30551350f, 0.30239585f, 0.29927495f, 0.29615086f, 0.29302359f, -0.28989318f, 0.28675964f, 0.28362307f, 0.28048345f, 0.27734083f, -0.27419522f, 0.27104670f, 0.26789525f, 0.26474094f, 0.26158381f, -0.25842386f, 0.25526115f, 0.25209570f, 0.24892756f, 0.24575676f, -0.24258332f, 0.23940729f, 0.23622867f, 0.23304754f, 0.22986393f, -0.22667783f, 0.22348931f, 0.22029841f, 0.21710514f, 0.21390954f, -0.21071166f, 0.20751151f, 0.20430915f, 0.20110460f, 0.19789790f, -0.19468907f, 0.19147816f, 0.18826519f, 0.18505022f, 0.18183327f, -0.17861435f, 0.17539354f, 0.17217083f, 0.16894630f, 0.16571994f, -0.16249183f, 0.15926196f, 0.15603039f, 0.15279715f, 0.14956227f, -0.14632578f, 0.14308774f, 0.13984816f, 0.13660708f, 0.13336454f, -0.13012058f, 0.12687522f, 0.12362850f, 0.12038045f, 0.11713112f, -0.11388054f, 0.11062872f, 0.10737573f, 0.10412160f, 0.10086634f, -0.097609997f, 0.094352618f, 0.091094226f, 0.087834857f, 0.084574550f, -0.081313334f, 0.078051247f, 0.074788325f, 0.071524605f, 0.068260118f, -0.064994894f, 0.061728980f, 0.058462404f, 0.055195201f, 0.051927410f, -0.048659060f, 0.045390189f, 0.042120833f, 0.038851023f, 0.035580799f, -0.032310195f, 0.029039243f, 0.025767982f, 0.022496443f, 0.019224664f, -0.015952680f, 0.012680525f, 0.0094082337f, 0.0061358409f, 0.0028633832f, --0.00040910527f, -0.0036815894f, -0.0069540343f, -0.010226404f, -0.013498665f, --0.016770782f, -0.020042717f, -0.023314439f, -0.026585912f, -0.029857099f, --0.033127967f, -0.036398482f, -0.039668605f, -0.042938303f, -0.046207540f, --0.049476285f, -0.052744497f, -0.056012146f, -0.059279196f, -0.062545612f, --0.065811358f, -0.069076397f, -0.072340697f, -0.075604223f, -0.078866936f, --0.082128808f, -0.085389800f, -0.088649876f, -0.091909006f, -0.095167145f, --0.098424271f, -0.10168034f, -0.10493532f, -0.10818918f, -0.11144188f, --0.11469338f, -0.11794366f, -0.12119267f, -0.12444039f, -0.12768677f, --0.13093179f, -0.13417540f, -0.13741758f, -0.14065829f, -0.14389749f, --0.14713514f, -0.15037122f, -0.15360570f, -0.15683852f, -0.16006967f, --0.16329910f, -0.16652679f, -0.16975269f, -0.17297678f, -0.17619900f, --0.17941935f, -0.18263777f, -0.18585424f, -0.18906870f, -0.19228116f, --0.19549155f, -0.19869985f, -0.20190603f, -0.20511003f, -0.20831184f, --0.21151142f, -0.21470875f, -0.21790376f, -0.22109644f, -0.22428675f, --0.22747467f, -0.23066014f, -0.23384315f, -0.23702365f, -0.24020162f, --0.24337701f, -0.24654980f, -0.24971995f, -0.25288740f, -0.25605217f, --0.25921419f, -0.26237345f, -0.26552987f, -0.26868346f, -0.27183419f, --0.27498198f, -0.27812684f, -0.28126872f, -0.28440759f, -0.28754342f, --0.29067615f, -0.29380578f, -0.29693225f, -0.30005556f, -0.30317566f, --0.30629250f, -0.30940607f, -0.31251630f, -0.31562322f, -0.31872672f, --0.32182685f, -0.32492352f, -0.32801670f, -0.33110636f, -0.33419248f, --0.33727503f, -0.34035397f, -0.34342924f, -0.34650084f, -0.34956875f, --0.35263291f, -0.35569328f, -0.35874987f, -0.36180258f, -0.36485144f, --0.36789638f, -0.37093741f, -0.37397444f, -0.37700745f, -0.38003644f, --0.38306138f, -0.38608220f, -0.38909888f, -0.39211139f, -0.39511973f, --0.39812380f, -0.40112361f, -0.40411916f, -0.40711036f, -0.41009718f, --0.41307965f, -0.41605768f, -0.41903123f, -0.42200032f, -0.42496487f, --0.42792490f, -0.43088034f, -0.43383113f, -0.43677729f, -0.43971881f, --0.44265559f, -0.44558764f, -0.44851488f, -0.45143735f, -0.45435500f, --0.45726776f, -0.46017563f, -0.46307856f, -0.46597654f, -0.46886954f, --0.47175750f, -0.47464043f, -0.47751826f, -0.48039100f, -0.48325855f, --0.48612097f, -0.48897815f, -0.49183011f, -0.49467680f, -0.49751821f, --0.50035429f, -0.50318497f, -0.50601029f, -0.50883019f, -0.51164466f, --0.51445359f, -0.51725709f, -0.52005500f, -0.52284735f, -0.52563411f, --0.52841520f, -0.53119069f, -0.53396046f, -0.53672451f, -0.53948283f, --0.54223537f, -0.54498214f, -0.54772300f, -0.55045801f, -0.55318713f, --0.55591035f, -0.55862761f, -0.56133890f, -0.56404412f, -0.56674337f, --0.56943649f, -0.57212353f, -0.57480448f, -0.57747924f, -0.58014780f, --0.58281022f, -0.58546633f, -0.58811617f, -0.59075975f, -0.59339696f, --0.59602785f, -0.59865236f, -0.60127044f, -0.60388207f, -0.60648727f, --0.60908598f, -0.61167812f, -0.61426371f, -0.61684275f, -0.61941516f, --0.62198097f, -0.62454009f, -0.62709254f, -0.62963831f, -0.63217729f, --0.63470948f, -0.63723493f, -0.63975352f, -0.64226526f, -0.64477009f, --0.64726806f, -0.64975911f, -0.65224314f, -0.65472025f, -0.65719032f, --0.65965337f, -0.66210932f, -0.66455823f, -0.66700000f, -0.66943461f, --0.67186207f, -0.67428231f, -0.67669535f, -0.67910111f, -0.68149966f, --0.68389088f, -0.68627477f, -0.68865126f, -0.69102043f, -0.69338220f, --0.69573659f, -0.69808346f, -0.70042288f, -0.70275480f, -0.70507920f, --0.70739603f, -0.70970529f, -0.71200693f, -0.71430099f, -0.71658736f, --0.71886611f, -0.72113711f, -0.72340041f, -0.72565591f, -0.72790372f, --0.73014367f, -0.73237586f, -0.73460019f, -0.73681659f, -0.73902518f, --0.74122584f, -0.74341851f, -0.74560326f, -0.74778003f, -0.74994880f, --0.75210953f, -0.75426215f, -0.75640678f, -0.75854325f, -0.76067162f, --0.76279181f, -0.76490390f, -0.76700771f, -0.76910341f, -0.77119076f, --0.77326995f, -0.77534080f, -0.77740335f, -0.77945763f, -0.78150350f, --0.78354102f, -0.78557014f, -0.78759086f, -0.78960317f, -0.79160696f, --0.79360235f, -0.79558921f, -0.79756755f, -0.79953730f, -0.80149853f, --0.80345118f, -0.80539525f, -0.80733067f, -0.80925739f, -0.81117553f, --0.81308490f, -0.81498563f, -0.81687760f, -0.81876087f, -0.82063532f, --0.82250100f, -0.82435787f, -0.82620591f, -0.82804507f, -0.82987541f, --0.83169687f, -0.83350939f, -0.83531296f, -0.83710766f, -0.83889335f, --0.84067005f, -0.84243774f, -0.84419644f, -0.84594607f, -0.84768665f, --0.84941816f, -0.85114056f, -0.85285389f, -0.85455805f, -0.85625303f, --0.85793889f, -0.85961550f, -0.86128294f, -0.86294121f, -0.86459017f, --0.86622989f, -0.86786032f, -0.86948150f, -0.87109333f, -0.87269586f, --0.87428904f, -0.87587279f, -0.87744725f, -0.87901229f, -0.88056785f, --0.88211405f, -0.88365078f, -0.88517809f, -0.88669586f, -0.88820416f, --0.88970292f, -0.89119220f, -0.89267188f, -0.89414203f, -0.89560264f, --0.89705360f, -0.89849502f, -0.89992678f, -0.90134889f, -0.90276134f, --0.90416414f, -0.90555727f, -0.90694070f, -0.90831441f, -0.90967834f, --0.91103262f, -0.91237706f, -0.91371179f, -0.91503674f, -0.91635185f, --0.91765714f, -0.91895264f, -0.92023826f, -0.92151409f, -0.92277998f, --0.92403603f, -0.92528218f, -0.92651838f, -0.92774469f, -0.92896110f, --0.93016750f, -0.93136400f, -0.93255049f, -0.93372697f, -0.93489349f, --0.93604994f, -0.93719643f, -0.93833286f, -0.93945926f, -0.94057560f, --0.94168180f, -0.94277799f, -0.94386405f, -0.94494003f, -0.94600588f, --0.94706154f, -0.94810712f, -0.94914252f, -0.95016778f, -0.95118284f, --0.95218778f, -0.95318246f, -0.95416695f, -0.95514119f, -0.95610523f, --0.95705903f, -0.95800257f, -0.95893586f, -0.95985889f, -0.96077162f, --0.96167403f, -0.96256620f, -0.96344805f, -0.96431959f, -0.96518075f, --0.96603161f, -0.96687216f, -0.96770233f, -0.96852213f, -0.96933156f, --0.97013056f, -0.97091925f, -0.97169751f, -0.97246534f, -0.97322279f, --0.97396982f, -0.97470641f, -0.97543252f, -0.97614825f, -0.97685349f, --0.97754824f, -0.97823256f, -0.97890645f, -0.97956979f, -0.98022264f, --0.98086500f, -0.98149687f, -0.98211825f, -0.98272908f, -0.98332942f, --0.98391914f, -0.98449844f, -0.98506713f, -0.98562527f, -0.98617285f, --0.98670989f, -0.98723638f, -0.98775226f, -0.98825759f, -0.98875231f, --0.98923647f, -0.98971003f, -0.99017298f, -0.99062532f, -0.99106705f, --0.99149817f, -0.99191868f, -0.99232858f, -0.99272782f, -0.99311644f, --0.99349445f, -0.99386179f, -0.99421853f, -0.99456459f, -0.99489999f, --0.99522477f, -0.99553883f, -0.99584228f, -0.99613506f, -0.99641716f, --0.99668860f, -0.99694937f, -0.99719942f, -0.99743885f, -0.99766755f, --0.99788558f, -0.99809295f, -0.99828959f, -0.99847561f, -0.99865085f, --0.99881548f, -0.99896932f, -0.99911255f, -0.99924499f, -0.99936682f, --0.99947786f, -0.99957830f, -0.99966794f, -0.99974692f, -0.99981517f, --0.99987274f, -0.99991959f, -0.99995571f, -0.99998116f, -0.99999589f, -0.99999964f, 0.99997288f, 0.99990326f, 0.99979085f, 0.99963558f, -0.99943751f, 0.99919659f, 0.99891287f, 0.99858636f, 0.99821711f, -0.99780506f, 0.99735034f, 0.99685282f, 0.99631262f, 0.99572974f, -0.99510419f, 0.99443603f, 0.99372530f, 0.99297196f, 0.99217612f, -0.99133772f, 0.99045694f, 0.98953366f, 0.98856801f, 0.98756003f, -0.98650974f, 0.98541719f, 0.98428243f, 0.98310548f, 0.98188645f, -0.98062533f, 0.97932225f, 0.97797716f, 0.97659022f, 0.97516143f, -0.97369087f, 0.97217858f, 0.97062469f, 0.96902919f, 0.96739221f, -0.96571374f, 0.96399397f, 0.96223283f, 0.96043050f, 0.95858705f, -0.95670253f, 0.95477700f, 0.95281059f, 0.95080340f, 0.94875544f, -0.94666684f, 0.94453770f, 0.94236809f, 0.94015813f, 0.93790787f, -0.93561745f, 0.93328691f, 0.93091643f, 0.92850608f, 0.92605597f, -0.92356616f, 0.92103678f, 0.91846794f, 0.91585976f, 0.91321236f, -0.91052586f, 0.90780038f, 0.90503591f, 0.90223277f, 0.89939094f, -0.89651060f, 0.89359182f, 0.89063478f, 0.88763964f, 0.88460642f, -0.88153529f, 0.87842643f, 0.87527996f, 0.87209594f, 0.86887461f, -0.86561602f, 0.86232042f, 0.85898781f, 0.85561842f, 0.85221243f, -0.84876984f, 0.84529096f, 0.84177583f, 0.83822471f, 0.83463764f, -0.83101481f, 0.82735640f, 0.82366252f, 0.81993335f, 0.81616908f, -0.81236988f, 0.80853581f, 0.80466717f, 0.80076402f, 0.79682660f, -0.79285502f, 0.78884947f, 0.78481019f, 0.78073722f, 0.77663082f, -0.77249116f, 0.76831841f, 0.76411277f, 0.75987434f, 0.75560343f, -0.75130010f, 0.74696463f, 0.74259710f, 0.73819780f, 0.73376691f, -0.72930455f, 0.72481096f, 0.72028631f, 0.71573079f, 0.71114463f, -0.70652801f, 0.70188117f, 0.69720417f, 0.69249737f, 0.68776089f, -0.68299496f, 0.67819971f, 0.67337549f, 0.66852236f, 0.66364062f, -0.65873051f, 0.65379208f, 0.64882571f, 0.64383155f, 0.63880974f, -0.63376063f, 0.62868434f, 0.62358117f, 0.61845124f, 0.61329484f, -0.60811216f, 0.60290343f, 0.59766883f, 0.59240872f, 0.58712316f, -0.58181250f, 0.57647687f, 0.57111657f, 0.56573176f, 0.56032276f, -0.55488980f, 0.54943299f, 0.54395270f, 0.53844911f, 0.53292239f, -0.52737290f, 0.52180082f, 0.51620632f, 0.51058978f, 0.50495136f, -0.49929130f, 0.49360985f, 0.48790723f, 0.48218375f, 0.47643960f, -0.47067502f, 0.46489030f, 0.45908567f, 0.45326138f, 0.44741765f, -0.44155475f, 0.43567297f, 0.42977250f, 0.42385364f, 0.41791660f, -0.41196167f, 0.40598908f, 0.39999911f, 0.39399201f, 0.38796803f, -0.38192743f, 0.37587047f, 0.36979741f, 0.36370850f, 0.35760403f, -0.35148421f, 0.34534934f, 0.33919969f, 0.33303553f, 0.32685706f, -0.32066461f, 0.31445843f, 0.30823877f, 0.30200592f, 0.29576012f, -0.28950164f, 0.28323078f, 0.27694780f, 0.27065292f, 0.26434645f, -0.25802869f, 0.25169984f, 0.24536023f, 0.23901010f, 0.23264973f, -0.22627939f, 0.21989937f, 0.21350993f, 0.20711134f, 0.20070387f, -0.19428782f, 0.18786344f, 0.18143101f, 0.17499080f, 0.16854310f, -0.16208819f, 0.15562633f, 0.14915779f, 0.14268288f, 0.13620184f, -0.12971498f, 0.12322257f, 0.11672486f, 0.11022217f, 0.10371475f, -0.097202882f, 0.090686858f, 0.084166944f, 0.077643424f, 0.071116582f, -0.064586692f, 0.058054037f, 0.051518895f, 0.044981543f, 0.038442269f, -0.031901345f, 0.025359053f, 0.018815678f, 0.012271495f, 0.0057267868f, --0.00081816671f, -0.0073630852f, -0.013907688f, -0.020451695f, -0.026994826f, --0.033536803f, -0.040077340f, -0.046616159f, -0.053152986f, -0.059687532f, --0.066219524f, -0.072748676f, -0.079274714f, -0.085797355f, -0.092316322f, --0.098831341f, -0.10534211f, -0.11184838f, -0.11834986f, -0.12484626f, --0.13133731f, -0.13782275f, -0.14430228f, -0.15077563f, -0.15724251f, --0.16370267f, -0.17015581f, -0.17660165f, -0.18303993f, -0.18947038f, --0.19589271f, -0.20230664f, -0.20871192f, -0.21510825f, -0.22149536f, --0.22787298f, -0.23424086f, -0.24059868f, -0.24694622f, -0.25328314f, --0.25960925f, -0.26592422f, -0.27222782f, -0.27851975f, -0.28479972f, --0.29106751f, -0.29732284f, -0.30356544f, -0.30979502f, -0.31601134f, --0.32221413f, -0.32840309f, -0.33457801f, -0.34073856f, -0.34688455f, --0.35301566f, -0.35913166f, -0.36523229f, -0.37131724f, -0.37738630f, --0.38343921f, -0.38947567f, -0.39549544f, -0.40149832f, -0.40748394f, --0.41345215f, -0.41940263f, -0.42533514f, -0.43124944f, -0.43714526f, --0.44302234f, -0.44888046f, -0.45471936f, -0.46053877f, -0.46633846f, --0.47211814f, -0.47787762f, -0.48361665f, -0.48933494f, -0.49503228f, --0.50070840f, -0.50636309f, -0.51199609f, -0.51760709f, -0.52319598f, --0.52876246f, -0.53430629f, -0.53982723f, -0.54532504f, -0.55079949f, --0.55625033f, -0.56167740f, -0.56708032f, -0.57245898f, -0.57781315f, --0.58314258f, -0.58844697f, -0.59372622f, -0.59897995f, -0.60420811f, --0.60941035f, -0.61458647f, -0.61973625f, -0.62485951f, -0.62995601f, --0.63502556f, -0.64006782f, -0.64508271f, -0.65007001f, -0.65502942f, --0.65996075f, -0.66486382f, -0.66973841f, -0.67458433f, -0.67940134f, --0.68418926f, -0.68894786f, -0.69367695f, -0.69837630f, -0.70304573f, --0.70768511f, -0.71229410f, -0.71687263f, -0.72142041f, -0.72593731f, --0.73042315f, -0.73487765f, -0.73930067f, -0.74369204f, -0.74805158f, --0.75237900f, -0.75667429f, -0.76093709f, -0.76516730f, -0.76936477f, --0.77352923f, -0.77766061f, -0.78175867f, -0.78582323f, -0.78985411f, --0.79385114f, -0.79781419f, -0.80174309f, -0.80563760f, -0.80949765f, --0.81332302f, -0.81711352f, -0.82086903f, -0.82458937f, -0.82827437f, --0.83192390f, -0.83553779f, -0.83911592f, -0.84265804f, -0.84616417f, --0.84963393f, -0.85306740f, -0.85646427f, -0.85982448f, -0.86314780f, --0.86643422f, -0.86968350f, -0.87289548f, -0.87607014f, -0.87920725f, --0.88230664f, -0.88536829f, -0.88839203f, -0.89137769f, -0.89432514f, --0.89723432f, -0.90010506f, -0.90293723f, -0.90573072f, -0.90848541f, --0.91120118f, -0.91387796f, -0.91651553f, -0.91911387f, -0.92167282f, --0.92419231f, -0.92667222f, -0.92911243f, -0.93151283f, -0.93387336f, --0.93619382f, -0.93847424f, -0.94071442f, -0.94291431f, -0.94507378f, --0.94719279f, -0.94927126f, -0.95130903f, -0.95330608f, -0.95526224f, --0.95717752f, -0.95905179f, -0.96088499f, -0.96267700f, -0.96442777f, --0.96613729f, -0.96780539f, -0.96943200f, -0.97101706f, -0.97256058f, --0.97406244f, -0.97552258f, -0.97694093f, -0.97831738f, -0.97965199f, --0.98094457f, -0.98219514f, -0.98340368f, -0.98457009f, -0.98569429f, --0.98677629f, -0.98781598f, -0.98881340f, -0.98976845f, -0.99068111f, --0.99155134f, -0.99237907f, -0.99316430f, -0.99390697f, -0.99460709f, --0.99526459f, -0.99587947f, -0.99645168f, -0.99698120f, -0.99746799f, --0.99791211f, -0.99831343f, -0.99867201f, -0.99898779f, -0.99926084f, --0.99949104f, -0.99967843f, -0.99982297f, -0.99992472f, -0.99998361f, -0.99999869f, 0.99989158f, 0.99961317f, 0.99916345f, 0.99854255f, -0.99775058f, 0.99678761f, 0.99565387f, 0.99434954f, 0.99287480f, -0.99122995f, 0.98941529f, 0.98743105f, 0.98527765f, 0.98295540f, -0.98046476f, 0.97780609f, 0.97497988f, 0.97198665f, 0.96882683f, -0.96550101f, 0.96200979f, 0.95835376f, 0.95453346f, 0.95054960f, -0.94640291f, 0.94209403f, 0.93762374f, 0.93299282f, 0.92820197f, -0.92325211f, 0.91814411f, 0.91287869f, 0.90745693f, 0.90187967f, -0.89614785f, 0.89026248f, 0.88422459f, 0.87803519f, 0.87169534f, -0.86520612f, 0.85856867f, 0.85178405f, 0.84485358f, 0.83777827f, -0.83055943f, 0.82319832f, 0.81569612f, 0.80805415f, 0.80027372f, -0.79235619f, 0.78430289f, 0.77611518f, 0.76779449f, 0.75934225f, -0.75075996f, 0.74204898f, 0.73321080f, 0.72424710f, 0.71515924f, -0.70594883f, 0.69661748f, 0.68716675f, 0.67759830f, 0.66791373f, -0.65811473f, 0.64820296f, 0.63818014f, 0.62804794f, 0.61780810f, -0.60746247f, 0.59701276f, 0.58646071f, 0.57580817f, 0.56505698f, -0.55420899f, 0.54326600f, 0.53222996f, 0.52110273f, 0.50988621f, -0.49858227f, 0.48719296f, 0.47572014f, 0.46416581f, 0.45253196f, -0.44082057f, 0.42903364f, 0.41717321f, 0.40524128f, 0.39323992f, -0.38117120f, 0.36903715f, 0.35683987f, 0.34458145f, 0.33226398f, -0.31988961f, 0.30746040f, 0.29497850f, 0.28244606f, 0.26986524f, -0.25723818f, 0.24456702f, 0.23185398f, 0.21910121f, 0.20631088f, -0.19348522f, 0.18062639f, 0.16773662f, 0.15481812f, 0.14187308f, -0.12890373f, 0.11591230f, 0.10290100f, 0.089872077f, 0.076827750f, -0.063770257f, 0.050701842f, 0.037624735f, 0.024541186f, 0.011453429f, --0.0016362892f, -0.014725727f, -0.027812643f, -0.040894791f, -0.053969935f, --0.067035832f, -0.080090240f, -0.093130924f, -0.10615565f, -0.11916219f, --0.13214831f, -0.14511178f, -0.15805040f, -0.17096193f, -0.18384418f, --0.19669491f, -0.20951195f, -0.22229309f, -0.23503613f, -0.24773891f, --0.26039925f, -0.27301496f, -0.28558388f, -0.29810387f, -0.31057280f, --0.32298848f, -0.33534884f, -0.34765175f, -0.35989508f, -0.37207675f, --0.38419467f, -0.39624676f, -0.40823093f, -0.42014518f, -0.43198743f, --0.44375566f, -0.45544785f, -0.46706200f, -0.47859612f, -0.49004826f, --0.50141639f, -0.51269865f, -0.52389306f, -0.53499764f, -0.54601061f, --0.55693001f, -0.56775403f, -0.57848072f, -0.58910829f, -0.59963489f, --0.61005878f, -0.62037814f, -0.63059121f, -0.64069623f, -0.65069145f, --0.66057515f, -0.67034572f, -0.68000144f, -0.68954057f, -0.69896162f, --0.70826286f, -0.71744281f, -0.72649974f, -0.73543227f, -0.74423873f, --0.75291771f, -0.76146764f, -0.76988715f, -0.77817470f, -0.78632891f, --0.79434842f, -0.80223179f, -0.80997771f, -0.81758487f, -0.82505190f, --0.83237761f, -0.83956063f, -0.84659988f, -0.85349399f, -0.86024189f, --0.86684239f, -0.87329435f, -0.87959671f, -0.88574833f, -0.89174819f, --0.89759529f, -0.90328854f, -0.90882701f, -0.91420978f, -0.91943592f, --0.92450452f, -0.92941469f, -0.93416560f, -0.93875647f, -0.94318646f, --0.94745487f, -0.95156091f, -0.95550388f, -0.95928317f, -0.96289814f, --0.96634805f, -0.96963239f, -0.97275060f, -0.97570217f, -0.97848648f, --0.98110318f, -0.98355180f, -0.98583186f, -0.98794299f, -0.98988485f, --0.99165714f, -0.99325943f, -0.99469161f, -0.99595332f, -0.99704438f, --0.99796462f, -0.99871385f, -0.99929196f, -0.99969882f, -0.99993443f, -0.99999464f, 0.99956632f, 0.99845290f, 0.99665523f, 0.99417448f, -0.99101239f, 0.98717111f, 0.98265326f, 0.97746199f, 0.97160077f, -0.96507365f, 0.95788515f, 0.95004016f, 0.94154406f, 0.93240267f, -0.92262226f, 0.91220951f, 0.90117162f, 0.88951606f, 0.87725091f, -0.86438453f, 0.85092574f, 0.83688372f, 0.82226819f, 0.80708915f, -0.79135692f, 0.77508235f, 0.75827658f, 0.74095112f, 0.72311783f, -0.70478898f, 0.68597710f, 0.66669506f, 0.64695615f, 0.62677377f, -0.60616189f, 0.58513457f, 0.56370622f, 0.54189157f, 0.51970547f, -0.49716324f, 0.47428027f, 0.45107225f, 0.42755505f, 0.40374488f, -0.37965798f, 0.35531086f, 0.33072025f, 0.30590299f, 0.28087607f, -0.25565663f, 0.23026201f, 0.20470956f, 0.17901683f, 0.15320139f, -0.12728097f, 0.10127331f, 0.075196236f, 0.049067631f, 0.022905400f, --0.0032725304f, -0.029448219f, -0.055603724f, -0.081721120f, -0.10778251f, --0.13377003f, -0.15966587f, -0.18545228f, -0.21111161f, -0.23662624f, --0.26197869f, -0.28715160f, -0.31212771f, -0.33688989f, -0.36142120f, --0.38570482f, -0.40972409f, -0.43346253f, -0.45690393f, -0.48003218f, --0.50283146f, -0.52528608f, -0.54738069f, -0.56910020f, -0.59042966f, --0.61135447f, -0.63186026f, -0.65193301f, -0.67155898f, -0.69072473f, --0.70941705f, -0.72762316f, -0.74533063f, -0.76252723f, -0.77920127f, --0.79534131f, -0.81093621f, -0.82597536f, -0.84044844f, -0.85434550f, --0.86765707f, -0.88037395f, -0.89248747f, -0.90398932f, -0.91487163f, --0.92512697f, -0.93474823f, -0.94372886f, -0.95206273f, -0.95974404f, --0.96676767f, -0.97312868f, -0.97882277f, -0.98384601f, -0.98819500f, --0.99186671f, -0.99485862f, -0.99716878f, -0.99879545f, -0.99973762f, -}; -#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 */ -}; - -/* List of all the available modes */ -#define TOTAL_MODES 1 -static const CELTMode * const static_mode_list[TOTAL_MODES] = { -&mode48000_960_120, -}; diff --git a/Engine/lib/opus/celt/static_modes_float_arm_ne10.h b/Engine/lib/opus/celt/static_modes_float_arm_ne10.h deleted file mode 100644 index 66e1abb10..000000000 --- a/Engine/lib/opus/celt/static_modes_float_arm_ne10.h +++ /dev/null @@ -1,404 +0,0 @@ -/* The contents of this file was automatically generated by - * dump_mode_arm_ne10.c with arguments: 48000 960 - * It contains static definitions for some pre-defined modes. */ -#include - -#ifndef 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, }; -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, }; -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, }; -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, }; -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}, -}; -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}, -}; -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}, -}; -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}, -}; -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], -/* is_forward_scaled = true */ -(ne10_int32_t) 1, -/* is_backward_scaled = false */ -(ne10_int32_t) 0, -}; -static const arch_fft_state cfg_arch_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], -/* is_forward_scaled = true */ -(ne10_int32_t) 1, -/* is_backward_scaled = false */ -(ne10_int32_t) 0, -}; -static const arch_fft_state cfg_arch_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], -/* is_forward_scaled = true */ -(ne10_int32_t) 1, -/* is_backward_scaled = false */ -(ne10_int32_t) 0, -}; -static const arch_fft_state cfg_arch_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], -/* is_forward_scaled = true */ -(ne10_int32_t) 1, -/* is_backward_scaled = false */ -(ne10_int32_t) 0, -}; -static const arch_fft_state cfg_arch_60 = { -1, -(void *)&ne10_fft_state_float32_t_60, -}; - -#endif /* end NE10_FFT_PARAMS48000_960 */ diff --git a/Engine/lib/opus/celt/tests/meson.build b/Engine/lib/opus/celt/tests/meson.build deleted file mode 100644 index 0e6d2e627..000000000 --- a/Engine/lib/opus/celt/tests/meson.build +++ /dev/null @@ -1,19 +0,0 @@ -tests = [ - 'test_unit_types', - 'test_unit_mathops', - 'test_unit_entropy', - 'test_unit_laplace', - 'test_unit_dft', - 'test_unit_mdct', - 'test_unit_rotation', - 'test_unit_cwrs32', -] - -foreach test_name : tests - exe = executable(test_name, '@0@.c'.format(test_name), - include_directories : opus_includes, - link_with : [celt_lib, celt_static_libs], - dependencies : libm, - install : false) - test(test_name, exe) -endforeach diff --git a/Engine/lib/opus/celt/tests/test_unit_cwrs32.c b/Engine/lib/opus/celt/tests/test_unit_cwrs32.c deleted file mode 100644 index 36dd8af5f..000000000 --- a/Engine/lib/opus/celt/tests/test_unit_cwrs32.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation, - Gregory Maxwell - Written by Jean-Marc Valin, Gregory Maxwell, 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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#ifndef CUSTOM_MODES -#define CUSTOM_MODES -#else -#define TEST_CUSTOM_MODES -#endif - -#define CELT_C -#include "stack_alloc.h" -#include "entenc.c" -#include "entdec.c" -#include "entcode.c" -#include "cwrs.c" -#include "mathops.c" -#include "rate.h" - -#define NMAX (240) -#define KMAX (128) - -#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 -}; -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 -}; -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); -#if defined(SMALL_FOOTPRINT) - nc=ncwrs_urow(n,k,uu); -#else - nc=CELT_PVQ_V(n,k); -#endif - inc=nc/20000; - if(inc<1)inc=1; - for(i=0;i");*/ -#if defined(SMALL_FOOTPRINT) - ii=icwrs(n,k,&v,y,u); -#else - ii=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; - } - /*printf(" %6u\n",i);*/ - } - /*printf("\n");*/ - } - } - return 0; -} diff --git a/Engine/lib/opus/celt/tests/test_unit_dft.c b/Engine/lib/opus/celt/tests/test_unit_dft.c deleted file mode 100644 index ae9a7b568..000000000 --- a/Engine/lib/opus/celt/tests/test_unit_dft.c +++ /dev/null @@ -1,180 +0,0 @@ -/* Copyright (c) 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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "stack_alloc.h" -#include "kiss_fft.h" -#include "mathops.h" -#include "modes.h" - -#ifndef M_PI -#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; - - for (bin=0;binmdct.kfft[id]; -#endif - - in = (kiss_fft_cpx*)malloc(buflen); - out = (kiss_fft_cpx*)malloc(buflen); - - for (k=0;k1) { - int k; - for (k=1;k -#include -#include -#include -#define CELT_C -#include "entcode.h" -#include "entenc.h" -#include "entdec.h" -#include - -#include "entenc.c" -#include "entdec.c" -#include "entcode.c" - -#ifndef M_LOG2E -# define M_LOG2E 1.4426950408889634074 -#endif -#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>(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()%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<>2)+1); - switch(dec_method){ - case 0:{ - fs=ec_decode(&dec,1<=(1<=(1< -#include -#define CELT_C -#include "laplace.h" -#include "stack_alloc.h" - -#include "entenc.c" -#include "entdec.c" -#include "entcode.c" -#include "laplace.c" - -#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 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); - - 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], - ec_laplace_get_start_freq(decay[i]), decay[i]); - - ec_enc_done(&enc); - - ec_dec_init(&dec,ec_get_buffer(&enc),ec_range_bytes(&enc)); - - for (i=0;i<10000;i++) - { - int d = 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; - } - } - - free(ptr); - return ret; -} diff --git a/Engine/lib/opus/celt/tests/test_unit_mathops.c b/Engine/lib/opus/celt/tests/test_unit_mathops.c deleted file mode 100644 index 0615448db..000000000 --- a/Engine/lib/opus/celt/tests/test_unit_mathops.c +++ /dev/null @@ -1,266 +0,0 @@ -/* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation, - Gregory Maxwell - Written by Jean-Marc Valin, Gregory Maxwell, 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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef CUSTOM_MODES -#define CUSTOM_MODES -#endif - -#include -#include -#include "mathops.h" -#include "bands.h" - -#ifdef FIXED_POINT -#define WORD "%d" -#else -#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); -#ifdef FIXED_POINT - prod = (1./32768./65526.)*val*i; -#else - prod = val*i; -#endif - 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 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 (dmax_d)max_d=d; - if (d0.0009) - { - fprintf (stderr, "celt_log2 failed: fabs((1.442695040888963387*log(x))-celt_log2(x))>0.001 (x = %f, error = %f)\n", x,error); - ret = 1; - } - } -} - -void testexp2(void) -{ - float x; - for (x=-11.0;x<24.0;x+=0.0007f) - { - float error = fabs(x-(1.442695040888963387*log(celt_exp2(x)))); - if (error>0.0002) - { - fprintf (stderr, "celt_exp2 failed: fabs(x-(1.442695040888963387*log(celt_exp2(x))))>0.0005 (x = %f, error = %f)\n", x,error); - ret = 1; - } - } -} - -void testexp2log2(void) -{ - float x; - for (x=-11.0;x<24.0;x+=0.0007f) - { - float error = fabs(x-(celt_log2(celt_exp2(x)))); - if (error>0.001) - { - fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_log2(celt_exp2(x))))>0.001 (x = %f, error = %f)\n", x,error); - ret = 1; - } - } -} -#else -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 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 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 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; - } - } -} -#endif - -int main(void) -{ - testbitexactcos(); - testbitexactlog2tan(); - testdiv(); - testsqrt(); - testlog2(); - testexp2(); - testexp2log2(); -#ifdef FIXED_POINT - testilog2(); -#endif - return ret; -} diff --git a/Engine/lib/opus/celt/tests/test_unit_mdct.c b/Engine/lib/opus/celt/tests/test_unit_mdct.c deleted file mode 100644 index 844c5b481..000000000 --- a/Engine/lib/opus/celt/tests/test_unit_mdct.c +++ /dev/null @@ -1,228 +0,0 @@ -/* Copyright (c) 2008-2011 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 - -#include "mdct.h" -#include "stack_alloc.h" -#include "kiss_fft.h" -#include "mdct.h" -#include "modes.h" - -#ifndef M_PI -#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; - double snr; - for (bin=0;binmdct; -#endif - - in = (kiss_fft_scalar*)malloc(buflen); - in_copy = (kiss_fft_scalar*)malloc(buflen); - out = (kiss_fft_scalar*)malloc(buflen); - window = (opus_val16*)malloc(sizeof(opus_val16)*nfft/2); - - for (k=0;k1) { - int k; - for (k=1;k -#include -#include "vq.h" -#include "bands.h" -#include "stack_alloc.h" -#include - - -#define MAX_SIZE 100 - -int ret=0; -void test_rotation(int N, int K) -{ - int i; - double err = 0, ener = 0, snr, snr0; - opus_val16 x0[MAX_SIZE]; - opus_val16 x1[MAX_SIZE]; - for (i=0;i 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); - return ret; -} diff --git a/Engine/lib/opus/celt/tests/test_unit_types.c b/Engine/lib/opus/celt/tests/test_unit_types.c deleted file mode 100644 index 67a0fb8ed..000000000 --- a/Engine/lib/opus/celt/tests/test_unit_types.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2008-2011 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_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; -} diff --git a/Engine/lib/opus/celt/vq.c b/Engine/lib/opus/celt/vq.c deleted file mode 100644 index 8011e2254..000000000 --- a/Engine/lib/opus/celt/vq.c +++ /dev/null @@ -1,442 +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 "mathops.h" -#include "cwrs.h" -#include "vq.h" -#include "arch.h" -#include "os_support.h" -#include "bands.h" -#include "rate.h" -#include "pitch.h" - -#if defined(MIPSr1_ASM) -#include "mips/vq_mipsr1.h" -#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); - 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)); - } -} -#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>1; -#endif - t = VSHR32(Ryy, 2*(k-7)); - g = MULT16_16_P15(celt_rsqrt_norm(t),gain); - - i=0; - do - X[i] = EXTRACT16(PSHR32(MULT16_16(g, iy[i]), k+1)); - 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 EPSILON && sum < 64)) -#endif - { - 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. */ -#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= 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 (++j0, "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); - - yy = op_pvq_search(X, iy, K, N, arch); - - encode_pulses(iy, N, K, enc); - - if (resynth) - { - normalise_residual(iy, X, N, yy, gain); - exp_rotation(X, N, -1, B, K, spread); - } - - collapse_mask = extract_collapse_mask(iy, N, B); - RESTORE_STACK; - return collapse_mask; -} - -/** Decode pulse vector and combine the result with the pitch vector to produce - the final normalised signal in the current band. */ -unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, - ec_dec *dec, opus_val16 gain) -{ - opus_val32 Ryy; - unsigned collapse_mask; - VARDECL(int, iy); - SAVE_STACK; - - celt_assert2(K>0, "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); - normalise_residual(iy, X, N, Ryy, gain); - exp_rotation(X, N, -1, B, K, spread); - collapse_mask = extract_collapse_mask(iy, N, B); - RESTORE_STACK; - return collapse_mask; -} - -#ifndef OVERRIDE_renormalise_vector -void renormalise_vector(celt_norm *X, int N, opus_val16 gain, int arch) -{ - int i; -#ifdef FIXED_POINT - int k; -#endif - opus_val32 E; - opus_val16 g; - opus_val32 t; - celt_norm *xptr; - E = EPSILON + celt_inner_prod(X, X, N, arch); -#ifdef FIXED_POINT - k = celt_ilog2(E)>>1; -#endif - t = VSHR32(E, 2*(k-7)); - g = MULT16_16_P15(celt_rsqrt_norm(t),gain); - - xptr = X; - for (i=0;i -#include -#include -#include "celt_lpc.h" -#include "stack_alloc.h" -#include "mathops.h" -#include "pitch.h" -#include "x86cpu.h" - -#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); - - __m128i vecNoA; - opus_int32 noA ; - SAVE_STACK; - - ALLOC(rnum, ord, opus_val16); - for(i=0;i> 1; - vecNoA = _mm_set_epi32(noA, noA, noA, noA); - - for (i=0;i -#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)); -} - - -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 -#include - -#include "macros.h" -#include "celt_lpc.h" -#include "stack_alloc.h" -#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; - - __m128i inVec1_76543210, inVec1_FEDCBA98, acc1; - __m128i inVec2_76543210, inVec2_FEDCBA98, acc2; - - sum = 0; - dataSize16 = N & ~15; - - acc1 = _mm_setzero_si128(); - acc2 = _mm_setzero_si128(); - - for (i=0;i= 8) - { - inVec1_76543210 = _mm_loadu_si128((__m128i *)(&x[i + 0])); - inVec2_76543210 = _mm_loadu_si128((__m128i *)(&y[i + 0])); - - inVec1_76543210 = _mm_madd_epi16(inVec1_76543210, inVec2_76543210); - - acc1 = _mm_add_epi32(acc1, inVec1_76543210); - i += 8; - } - - acc1 = _mm_add_epi32(acc1, _mm_unpackhi_epi64( acc1, acc1)); - acc1 = _mm_add_epi32(acc1, _mm_shufflelo_epi16( acc1, 0x0E)); - sum += _mm_cvtsi128_si32(acc1); - - for (;i -#include - -#include "macros.h" -#include "celt_lpc.h" -#include "stack_alloc.h" -#include "mathops.h" -#include "pitch.h" - -#if defined(OPUS_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; - __m128i inVec1_76543210, inVec1_FEDCBA98, acc1; - __m128i inVec2_76543210, inVec2_FEDCBA98, acc2; - __m128i inVec1_3210, inVec2_3210; - - sum = 0; - dataSize16 = N & ~15; - - acc1 = _mm_setzero_si128(); - acc2 = _mm_setzero_si128(); - - for (i=0;i= 8) - { - inVec1_76543210 = _mm_loadu_si128((__m128i *)(&x[i + 0])); - inVec2_76543210 = _mm_loadu_si128((__m128i *)(&y[i + 0])); - - inVec1_76543210 = _mm_madd_epi16(inVec1_76543210, inVec2_76543210); - - acc1 = _mm_add_epi32(acc1, inVec1_76543210); - i += 8; - } - - if (N - i >= 4) - { - inVec1_3210 = OP_CVTEPI16_EPI32_M64(&x[i + 0]); - inVec2_3210 = OP_CVTEPI16_EPI32_M64(&y[i + 0]); - - inVec1_3210 = _mm_mullo_epi32(inVec1_3210, inVec2_3210); - - acc1 = _mm_add_epi32(acc1, inVec1_3210); - i += 4; - } - - acc1 = _mm_add_epi32(acc1, _mm_unpackhi_epi64(acc1, acc1)); - acc1 = _mm_add_epi32(acc1, _mm_shufflelo_epi16(acc1, 0x0E)); - - sum += _mm_cvtsi128_si32(acc1); - - for (;i= 3); - - sum0 = _mm_setzero_si128(); - sum1 = _mm_setzero_si128(); - sum2 = _mm_setzero_si128(); - sum3 = _mm_setzero_si128(); - - for (j=0;j<(len-7);j+=8) - { - vecX = _mm_loadu_si128((__m128i *)(&x[j + 0])); - vecY0 = _mm_loadu_si128((__m128i *)(&y[j + 0])); - vecY1 = _mm_loadu_si128((__m128i *)(&y[j + 1])); - vecY2 = _mm_loadu_si128((__m128i *)(&y[j + 2])); - vecY3 = _mm_loadu_si128((__m128i *)(&y[j + 3])); - - sum0 = _mm_add_epi32(sum0, _mm_madd_epi16(vecX, vecY0)); - sum1 = _mm_add_epi32(sum1, _mm_madd_epi16(vecX, vecY1)); - sum2 = _mm_add_epi32(sum2, _mm_madd_epi16(vecX, vecY2)); - sum3 = _mm_add_epi32(sum3, _mm_madd_epi16(vecX, vecY3)); - } - - sum0 = _mm_add_epi32(sum0, _mm_unpackhi_epi64( sum0, sum0)); - sum0 = _mm_add_epi32(sum0, _mm_shufflelo_epi16( sum0, 0x0E)); - - sum1 = _mm_add_epi32(sum1, _mm_unpackhi_epi64( sum1, sum1)); - sum1 = _mm_add_epi32(sum1, _mm_shufflelo_epi16( sum1, 0x0E)); - - sum2 = _mm_add_epi32(sum2, _mm_unpackhi_epi64( sum2, sum2)); - sum2 = _mm_add_epi32(sum2, _mm_shufflelo_epi16( sum2, 0x0E)); - - sum3 = _mm_add_epi32(sum3, _mm_unpackhi_epi64( sum3, sum3)); - sum3 = _mm_add_epi32(sum3, _mm_shufflelo_epi16( sum3, 0x0E)); - - vecSum = _mm_unpacklo_epi64(_mm_unpacklo_epi32(sum0, sum1), - _mm_unpacklo_epi32(sum2, sum3)); - - 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); - vecX2 = _mm_shuffle_epi32(vecX, 0xaa); - vecX3 = _mm_shuffle_epi32(vecX, 0xff); - - vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]); - vecY1 = OP_CVTEPI16_EPI32_M64(&y[j + 1]); - vecY2 = OP_CVTEPI16_EPI32_M64(&y[j + 2]); - vecY3 = OP_CVTEPI16_EPI32_M64(&y[j + 3]); - - sum0 = _mm_mullo_epi32(vecX0, vecY0); - sum1 = _mm_mullo_epi32(vecX1, vecY1); - sum2 = _mm_mullo_epi32(vecX2, vecY2); - sum3 = _mm_mullo_epi32(vecX3, vecY3); - - sum0 = _mm_add_epi32(sum0, sum1); - sum2 = _mm_add_epi32(sum2, sum3); - vecSum = _mm_add_epi32(vecSum, sum0); - vecSum = _mm_add_epi32(vecSum, sum2); - } - - vecX = OP_CVTEPI16_EPI32_M64(&x[len - 4]); - if (len - j == 3) - { - vecX0 = _mm_shuffle_epi32(vecX, 0x55); - vecX1 = _mm_shuffle_epi32(vecX, 0xaa); - vecX2 = _mm_shuffle_epi32(vecX, 0xff); - - vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]); - vecY1 = OP_CVTEPI16_EPI32_M64(&y[j + 1]); - vecY2 = OP_CVTEPI16_EPI32_M64(&y[j + 2]); - - sum0 = _mm_mullo_epi32(vecX0, vecY0); - sum1 = _mm_mullo_epi32(vecX1, vecY1); - sum2 = _mm_mullo_epi32(vecX2, vecY2); - - vecSum = _mm_add_epi32(vecSum, sum0); - vecSum = _mm_add_epi32(vecSum, sum1); - vecSum = _mm_add_epi32(vecSum, sum2); - } - else if (len - j == 2) - { - vecX0 = _mm_shuffle_epi32(vecX, 0xaa); - vecX1 = _mm_shuffle_epi32(vecX, 0xff); - - vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]); - vecY1 = OP_CVTEPI16_EPI32_M64(&y[j + 1]); - - sum0 = _mm_mullo_epi32(vecX0, vecY0); - sum1 = _mm_mullo_epi32(vecX1, vecY1); - - vecSum = _mm_add_epi32(vecSum, sum0); - vecSum = _mm_add_epi32(vecSum, sum1); - } - else if (len - j == 1) - { - vecX0 = _mm_shuffle_epi32(vecX, 0xff); - - vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]); - - sum0 = _mm_mullo_epi32(vecX0, vecY0); - - vecSum = _mm_add_epi32(vecSum, sum0); - } - - initSum = _mm_loadu_si128((__m128i *)(&sum[0])); - initSum = _mm_add_epi32(initSum, vecSum); - _mm_storeu_si128((__m128i *)sum, initSum); - -#ifdef OPUS_CHECK_ASM - celt_assert(!memcmp(sum_c, sum, sizeof(sum_c))); -#endif -} -#endif diff --git a/Engine/lib/opus/celt/x86/vq_sse.h b/Engine/lib/opus/celt/x86/vq_sse.h deleted file mode 100644 index b4efe8f24..000000000 --- a/Engine/lib/opus/celt/x86/vq_sse.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2016 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. -*/ - -#ifndef VQ_SSE_H -#define VQ_SSE_H - -#if defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT) -#define OVERRIDE_OP_PVQ_SEARCH - -opus_val16 op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch); - -#if defined(OPUS_X86_PRESUME_SSE2) -#define op_pvq_search(x, iy, K, N, arch) \ - (op_pvq_search_sse2(x, iy, K, N, arch)) - -#else - -extern opus_val16 (*const OP_PVQ_SEARCH_IMPL[OPUS_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)) - -#endif -#endif - -#endif diff --git a/Engine/lib/opus/celt/x86/vq_sse2.c b/Engine/lib/opus/celt/x86/vq_sse2.c deleted file mode 100644 index 775042860..000000000 --- a/Engine/lib/opus/celt/x86/vq_sse2.c +++ /dev/null @@ -1,217 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Copyright (c) 2007-2016 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 -#include -#include "celt_lpc.h" -#include "stack_alloc.h" -#include "mathops.h" -#include "vq.h" -#include "x86cpu.h" - - -#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 -static _inline void cpuid(unsigned int CPUInfo[4], unsigned int InfoType) -{ - __cpuid((int*)CPUInfo, InfoType); -} - -#else - -#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__) -/* %ebx is PIC register in 32-bit, so mustn't clobber it. */ - __asm__ __volatile__ ( - "xchg %%ebx, %1\n" - "cpuid\n" - "xchg %%ebx, %1\n": - "=a" (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 - __asm__ __volatile__ ( - "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) - /* We use __get_cpuid_count to clear ECX to avoid a valgrind false-positive - prior to v3.17.0.*/ - if (!__get_cpuid_count(InfoType, 0, &(CPUInfo[0]), &(CPUInfo[1]), &(CPUInfo[2]), &(CPUInfo[3]))) { - /* Our function cannot fail, but __get_cpuid{_count} can. - Returning all zeroes will effectively disable all SIMD, which is - what we want on CPUs that don't support CPUID. */ - CPUInfo[3] = CPUInfo[2] = CPUInfo[1] = CPUInfo[0] = 0; - } -#else -# error "Configured to use x86 RTCD, but no CPU detection method available. " \ - "Reconfigure with --disable-rtcd (or send patches)." -#endif -} - -#endif - -typedef struct CPU_Feature{ - /* SIMD: 128-bit */ - int HW_SSE; - int HW_SSE2; - int HW_SSE41; - /* SIMD: 256-bit */ - int HW_AVX; -} CPU_Feature; - -static void opus_cpu_feature_check(CPU_Feature *cpu_feature) -{ - unsigned int info[4]; - unsigned int nIds = 0; - - 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_AVX = (info[2] & (1 << 28)) != 0; - } - else { - cpu_feature->HW_SSE = 0; - cpu_feature->HW_SSE2 = 0; - cpu_feature->HW_SSE41 = 0; - cpu_feature->HW_AVX = 0; - } -} - -static int opus_select_arch_impl(void) -{ - CPU_Feature cpu_feature; - int arch; - - opus_cpu_feature_check(&cpu_feature); - - arch = 0; - if (!cpu_feature.HW_SSE) - { - return arch; - } - arch++; - - if (!cpu_feature.HW_SSE2) - { - return arch; - } - arch++; - - if (!cpu_feature.HW_SSE41) - { - return arch; - } - arch++; - - if (!cpu_feature.HW_AVX) - { - return arch; - } - arch++; - - return arch; -} - -int opus_select_arch(void) { - int arch = opus_select_arch_impl(); -#ifdef FUZZING - /* Randomly downgrade the architecture. */ - arch = rand()%(arch+1); -#endif - return arch; -} - -#endif diff --git a/Engine/lib/opus/celt/x86/x86cpu.h b/Engine/lib/opus/celt/x86/x86cpu.h deleted file mode 100644 index 04e80489b..000000000 --- a/Engine/lib/opus/celt/x86/x86cpu.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) 2014, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(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(OPUS_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(OPUS_X86_MAY_HAVE_AVX) -# define MAY_HAVE_AVX(name) name ## _avx -# else -# define MAY_HAVE_AVX(name) name ## _c -# endif - -# if defined(OPUS_HAVE_RTCD) -int opus_select_arch(void); -# endif - -/*MOVD should not impose any alignment restrictions, but the C standard does, - and UBSan will report errors if we actually make unaligned accesses. - Use this to work around those restrictions (which should hopefully all get - optimized to a single MOVD instruction).*/ -#define OP_LOADU_EPI32(x) \ - (int)((*(unsigned char *)(x) | *((unsigned char *)(x) + 1) << 8U |\ - *((unsigned char *)(x) + 2) << 16U | (opus_uint32)*((unsigned char *)(x) + 3) << 24U)) - -#define OP_CVTEPI8_EPI32_M32(x) \ - (_mm_cvtepi8_epi32(_mm_cvtsi32_si128(OP_LOADU_EPI32(x)))) - -#define OP_CVTEPI16_EPI32_M64(x) \ - (_mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(x)))) - -#endif diff --git a/Engine/lib/opus/celt_headers.mk b/Engine/lib/opus/celt_headers.mk deleted file mode 100644 index 706185da4..000000000 --- a/Engine/lib/opus/celt_headers.mk +++ /dev/null @@ -1,53 +0,0 @@ -CELT_HEAD = \ -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 \ -celt/cwrs.h \ -celt/ecintrin.h \ -celt/entcode.h \ -celt/entdec.h \ -celt/entenc.h \ -celt/fixed_debug.h \ -celt/fixed_generic.h \ -celt/float_cast.h \ -celt/_kiss_fft_guts.h \ -celt/kiss_fft.h \ -celt/laplace.h \ -celt/mathops.h \ -celt/mdct.h \ -celt/mfrngcod.h \ -celt/modes.h \ -celt/os_support.h \ -celt/pitch.h \ -celt/celt_lpc.h \ -celt/x86/celt_lpc_sse.h \ -celt/quant_bands.h \ -celt/rate.h \ -celt/stack_alloc.h \ -celt/vq.h \ -celt/static_modes_float.h \ -celt/static_modes_fixed.h \ -celt/static_modes_float_arm_ne10.h \ -celt/static_modes_fixed_arm_ne10.h \ -celt/arm/armcpu.h \ -celt/arm/fixed_armv4.h \ -celt/arm/fixed_armv5e.h \ -celt/arm/fixed_arm64.h \ -celt/arm/kiss_fft_armv4.h \ -celt/arm/kiss_fft_armv5e.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/mips/vq_mipsr1.h \ -celt/x86/pitch_sse.h \ -celt/x86/vq_sse.h \ -celt/x86/x86cpu.h diff --git a/Engine/lib/opus/celt_sources.mk b/Engine/lib/opus/celt_sources.mk deleted file mode 100644 index d6b6765be..000000000 --- a/Engine/lib/opus/celt_sources.mk +++ /dev/null @@ -1,52 +0,0 @@ -CELT_SOURCES = \ -celt/bands.c \ -celt/celt.c \ -celt/celt_encoder.c \ -celt/celt_decoder.c \ -celt/cwrs.c \ -celt/entcode.c \ -celt/entdec.c \ -celt/entenc.c \ -celt/kiss_fft.c \ -celt/laplace.c \ -celt/mathops.c \ -celt/mdct.c \ -celt/modes.c \ -celt/pitch.c \ -celt/celt_lpc.c \ -celt/quant_bands.c \ -celt/rate.c \ -celt/vq.c - -CELT_SOURCES_X86_RTCD = \ -celt/x86/x86cpu.c \ -celt/x86/x86_celt_map.c - -CELT_SOURCES_SSE = \ -celt/x86/pitch_sse.c - -CELT_SOURCES_SSE2 = \ -celt/x86/pitch_sse2.c \ -celt/x86/vq_sse2.c - -CELT_SOURCES_SSE4_1 = \ -celt/x86/celt_lpc_sse4_1.c \ -celt/x86/pitch_sse4_1.c - -CELT_SOURCES_ARM_RTCD = \ -celt/arm/armcpu.c \ -celt/arm/arm_celt_map.c - -CELT_SOURCES_ARM_ASM = \ -celt/arm/celt_pitch_xcorr_arm.s - -CELT_AM_SOURCES_ARM_ASM = \ -celt/arm/armopts.s.in - -CELT_SOURCES_ARM_NEON_INTR = \ -celt/arm/celt_neon_intr.c \ -celt/arm/pitch_neon_intr.c - -CELT_SOURCES_ARM_NE10 = \ -celt/arm/celt_fft_ne10.c \ -celt/arm/celt_mdct_ne10.c diff --git a/Engine/lib/opus/cmake/CFeatureCheck.cmake b/Engine/lib/opus/cmake/CFeatureCheck.cmake deleted file mode 100644 index 08828f585..000000000 --- a/Engine/lib/opus/cmake/CFeatureCheck.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# - Compile and run code to check for C features -# -# This functions compiles a source file under the `cmake` folder -# and adds the corresponding `HAVE_[FILENAME]` flag to the CMake -# environment -# -# c_feature_check( []) -# -# - Example -# -# include(CFeatureCheck) -# c_feature_check(VLA) - -if(__c_feature_check) - return() -endif() -set(__c_feature_check INCLUDED) - -function(c_feature_check FILE) - string(TOLOWER ${FILE} FILE) - string(TOUPPER ${FILE} VAR) - string(TOUPPER "${VAR}_SUPPORTED" FEATURE) - if (DEFINED ${VAR}_SUPPORTED) - set(${VAR}_SUPPORTED 1 PARENT_SCOPE) - return() - endif() - - if (NOT DEFINED COMPILE_${FEATURE}) - message(STATUS "Performing Test ${FEATURE}") - try_compile(COMPILE_${FEATURE} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/${FILE}.c) - endif() - - if(COMPILE_${FEATURE}) - message(STATUS "Performing Test ${FEATURE} -- success") - set(${VAR}_SUPPORTED 1 PARENT_SCOPE) - else() - message(STATUS "Performing Test ${FEATURE} -- failed to compile") - endif() -endfunction() diff --git a/Engine/lib/opus/cmake/OpusBuildtype.cmake b/Engine/lib/opus/cmake/OpusBuildtype.cmake deleted file mode 100644 index 557cc89b3..000000000 --- a/Engine/lib/opus/cmake/OpusBuildtype.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# Set a default build type if none was specified -if(__opus_buildtype) - return() -endif() -set(__opus_buildtype INCLUDED) - -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - if(CMAKE_C_FLAGS) - message(STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS}) - else() - set(default_build_type "Release") - message( - STATUS - "Setting build type to '${default_build_type}' as none was specified and no CFLAGS was exported." - ) - set(CMAKE_BUILD_TYPE "${default_build_type}" - CACHE STRING "Choose the type of build." - FORCE) - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE - PROPERTY STRINGS - "Debug" - "Release" - "MinSizeRel" - "RelWithDebInfo") - endif() -endif() diff --git a/Engine/lib/opus/cmake/OpusConfig.cmake b/Engine/lib/opus/cmake/OpusConfig.cmake deleted file mode 100644 index b82307a19..000000000 --- a/Engine/lib/opus/cmake/OpusConfig.cmake +++ /dev/null @@ -1,115 +0,0 @@ -if(__opus_config) - return() -endif() -set(__opus_config INCLUDED) - -include(OpusFunctions) - -configure_file(cmake/config.h.cmake.in config.h @ONLY) -add_definitions(-DHAVE_CONFIG_H) - -set_property(GLOBAL PROPERTY USE_FOLDERS ON) - -if(MSVC) - # For compilers that have no notion of a C standard level, - # such as Microsoft Visual C++ before VS 16.7, - # this property has no effect. - set(CMAKE_C_STANDARD 11) -else() - set(CMAKE_C_STANDARD 99) -endif() - -if(MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) -endif() - -include(CFeatureCheck) -c_feature_check(VLA) - -include(CheckIncludeFile) -check_include_file(alloca.h HAVE_ALLOCA_H) - -include(CheckSymbolExists) -if(HAVE_ALLOCA_H) - add_definitions(-DHAVE_ALLOCA_H) - check_symbol_exists(alloca "alloca.h" USE_ALLOCA_SUPPORTED) -else() - check_symbol_exists(alloca "stdlib.h;malloc.h" USE_ALLOCA_SUPPORTED) -endif() - -include(CMakePushCheckState) -cmake_push_check_state(RESET) -include(CheckLibraryExists) -check_library_exists(m floor "" HAVE_LIBM) -if(HAVE_LIBM) - list(APPEND OPUS_REQUIRED_LIBRARIES m) - set(CMAKE_REQUIRED_LIBRARIES m) -endif() - -check_symbol_exists(lrintf "math.h" HAVE_LRINTF) -check_symbol_exists(lrint "math.h" HAVE_LRINT) -cmake_pop_check_state() - -if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)") - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(OPUS_CPU_X64 1) - else() - set(OPUS_CPU_X86 1) - endif() -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)") - set(OPUS_CPU_ARM 1) -endif() - -if(NOT OPUS_DISABLE_INTRINSICS) - opus_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION) -endif() - -if(OPUS_CPU_X86 OR OPUS_CPU_X64 AND NOT OPUS_DISABLE_INTRINSICS) - opus_detect_sse(COMPILER_SUPPORT_SIMD) -elseif(OPUS_CPU_ARM AND NOT OPUS_DISABLE_INTRINSICS) - opus_detect_neon(COMPILER_SUPPORT_NEON) - if(COMPILER_SUPPORT_NEON) - option(OPUS_USE_NEON "Option to enable NEON" ON) - option(OPUS_MAY_HAVE_NEON "Does runtime check for neon support" ON) - option(OPUS_PRESUME_NEON "Assume target CPU has NEON support" OFF) - if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") - set(OPUS_PRESUME_NEON ON) - elseif(CMAKE_SYSTEM_NAME MATCHES "iOS") - set(OPUS_PRESUME_NEON ON) - endif() - endif() -endif() - -if(MSVC) - check_flag(FAST_MATH /fp:fast) - check_flag(STACK_PROTECTOR /GS) - check_flag(STACK_PROTECTOR_DISABLED /GS-) -else() - check_flag(FAST_MATH -ffast-math) - check_flag(STACK_PROTECTOR -fstack-protector-strong) - check_flag(HIDDEN_VISIBILITY -fvisibility=hidden) - set(FORTIFY_SOURCE_SUPPORTED 1) -endif() - -if(MINGW) - # For MINGW we need to link ssp lib for security features such as - # stack protector and fortify_sources - check_library_exists(ssp __stack_chk_fail "" HAVE_LIBSSP) - if(NOT HAVE_LIBSSP) - message(WARNING "Could not find libssp in MinGW, disabling STACK_PROTECTOR and FORTIFY_SOURCE") - set(STACK_PROTECTOR_SUPPORTED 0) - set(FORTIFY_SOURCE_SUPPORTED 0) - endif() -endif() - -if(NOT MSVC) - set(WARNING_LIST -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow) - include(CheckCCompilerFlag) - foreach(WARNING_FLAG ${WARNING_LIST}) - string(REPLACE - "" WARNING_VAR ${WARNING_FLAG}) - check_c_compiler_flag(${WARNING_FLAG} ${WARNING_VAR}_SUPPORTED) - if(${WARNING_VAR}_SUPPORTED) - add_compile_options(${WARNING_FLAG}) - endif() - endforeach() -endif() diff --git a/Engine/lib/opus/cmake/OpusConfig.cmake.in b/Engine/lib/opus/cmake/OpusConfig.cmake.in deleted file mode 100644 index 0b21231d4..000000000 --- a/Engine/lib/opus/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/Engine/lib/opus/cmake/OpusFunctions.cmake b/Engine/lib/opus/cmake/OpusFunctions.cmake deleted file mode 100644 index 3f22ad813..000000000 --- a/Engine/lib/opus/cmake/OpusFunctions.cmake +++ /dev/null @@ -1,229 +0,0 @@ -if(__opus_functions) - return() -endif() -set(__opus_functions INCLUDED) - -function(get_library_version OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR) - file(STRINGS configure.ac opus_lt_current_string - LIMIT_COUNT 1 - REGEX "OPUS_LT_CURRENT=") - string(REGEX MATCH - "OPUS_LT_CURRENT=([0-9]*)" - _ - ${opus_lt_current_string}) - set(OPUS_LT_CURRENT ${CMAKE_MATCH_1}) - - file(STRINGS configure.ac opus_lt_revision_string - LIMIT_COUNT 1 - REGEX "OPUS_LT_REVISION=") - string(REGEX MATCH - "OPUS_LT_REVISION=([0-9]*)" - _ - ${opus_lt_revision_string}) - set(OPUS_LT_REVISION ${CMAKE_MATCH_1}) - - file(STRINGS configure.ac opus_lt_age_string - LIMIT_COUNT 1 - REGEX "OPUS_LT_AGE=") - string(REGEX MATCH - "OPUS_LT_AGE=([0-9]*)" - _ - ${opus_lt_age_string}) - set(OPUS_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}) - set( - OPUS_LIBRARY_VERSION - "${OPUS_LIBRARY_VERSION_MAJOR}.${OPUS_LIBRARY_VERSION_MINOR}.${OPUS_LIBRARY_VERSION_PATCH}" - PARENT_SCOPE) - set(OPUS_LIBRARY_VERSION_MAJOR ${OPUS_LIBRARY_VERSION_MAJOR} PARENT_SCOPE) -endfunction() - -function(check_flag NAME FLAG) - include(CheckCCompilerFlag) - check_c_compiler_flag(${FLAG} ${NAME}_SUPPORTED) -endfunction() - -include(CheckIncludeFile) -# function to check if compiler supports SSE, SSE2, SSE4.1 and AVX if target -# systems may not have SSE support then use OPUS_MAY_HAVE_SSE option if target -# system is guaranteed to have SSE support then OPUS_PRESUME_SSE can be used to -# skip SSE runtime check -function(opus_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) - if(MSVC) - # different arch options for 32 and 64 bit target for MSVC - if(CMAKE_SIZEOF_VOID_P EQUAL 4) - check_flag(SSE1 /arch:SSE) - else() - set(SSE1_SUPPORTED - 1 - PARENT_SCOPE) - endif() - else() - check_flag(SSE1 -msse) - endif() - else() - set(SSE1_SUPPORTED - 0 - PARENT_SCOPE) - endif() - - check_include_file(emmintrin.h HAVE_EMMINTRIN_H) # SSE2 - if(HAVE_EMMINTRIN_H) - if(MSVC) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) - check_flag(SSE2 /arch:SSE2) - else() - set(SSE2_SUPPORTED - 1 - PARENT_SCOPE) - endif() - else() - check_flag(SSE2 -msse2) - endif() - else() - set(SSE2_SUPPORTED - 0 - PARENT_SCOPE) - endif() - - check_include_file(smmintrin.h HAVE_SMMINTRIN_H) # SSE4.1 - if(HAVE_SMMINTRIN_H) - if(MSVC) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) - check_flag(SSE4_1 /arch:SSE2) # SSE2 and above - else() - set(SSE4_1_SUPPORTED - 1 - PARENT_SCOPE) - endif() - else() - check_flag(SSE4_1 -msse4.1) - endif() - else() - set(SSE4_1_SUPPORTED - 0 - PARENT_SCOPE) - endif() - - check_include_file(immintrin.h HAVE_IMMINTRIN_H) # AVX - if(HAVE_IMMINTRIN_H) - if(MSVC) - check_flag(AVX /arch:AVX) - else() - check_flag(AVX -mavx) - endif() - else() - set(AVX_SUPPORTED - 0 - PARENT_SCOPE) - endif() - - if(SSE1_SUPPORTED OR SSE2_SUPPORTED OR SSE4_1_SUPPORTED OR AVX_SUPPORTED) - set(COMPILER_SUPPORT_SIMD 1 PARENT_SCOPE) - else() - message(STATUS "No SIMD support in compiler") - endif() -endfunction() - -function(opus_detect_neon COMPILER_SUPPORT_NEON) - if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)") - message(STATUS "Check NEON support by compiler") - check_include_file(arm_neon.h HAVE_ARM_NEON_H) - if(HAVE_ARM_NEON_H) - set(COMPILER_SUPPORT_NEON ${HAVE_ARM_NEON_H} PARENT_SCOPE) - endif() - endif() -endfunction() - -function(opus_supports_cpu_detection RUNTIME_CPU_CAPABILITY_DETECTION) - set(RUNTIME_CPU_CAPABILITY_DETECTION 0 PARENT_SCOPE) - if(OPUS_CPU_X86 OR OPUS_CPU_X64) - if(MSVC) - check_include_file(intrin.h HAVE_INTRIN_H) - if(HAVE_INTRIN_H) - # if intrin.h is available we assume __cpuid is there - set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE) - endif() - else() - include(CFeatureCheck) - c_feature_check(CPU_INFO_BY_ASM) - set(CPU_INFO_BY_ASM_SUPPORTED ${CPU_INFO_BY_ASM_SUPPORTED} PARENT_SCOPE) - check_include_file(cpuid.h HAVE_CPUID_H) - if(HAVE_CPUID_H) - c_feature_check(CPU_INFO_BY_C) - set(CPU_INFO_BY_C_SUPPORTED ${CPU_INFO_BY_C_SUPPORTED} PARENT_SCOPE) - endif() - if(CPU_INFO_BY_ASM_SUPPORTED OR CPU_INFO_BY_C_SUPPORTED) - set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE) - endif() - endif() - elseif(OPUS_CPU_ARM) - # ARM cpu detection is implemented for Windows and anything - # using a Linux kernel (such as Android). - if (CMAKE_SYSTEM_NAME MATCHES "(Windows|Linux|Android)") - set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE) - endif () - else() - set(RUNTIME_CPU_CAPABILITY_DETECTION 0 PARENT_SCOPE) - endif() -endfunction() - -function(add_sources_group target group) - target_sources(${target} PRIVATE ${ARGN}) - source_group(${group} FILES ${ARGN}) -endfunction() - -function(get_opus_sources SOURCE_GROUP MAKE_FILE SOURCES) - # read file, each item in list is one group - file(STRINGS ${MAKE_FILE} opus_sources) - - # add wildcard for regex match - string(CONCAT SOURCE_GROUP ${SOURCE_GROUP} ".*$") - - # find group - foreach(val IN LISTS opus_sources) - if(val MATCHES ${SOURCE_GROUP}) - list(LENGTH val list_length) - if(${list_length} EQUAL 1) - # for tests split by '=' and clean up the rest into a list - string(FIND ${val} "=" index) - math(EXPR index "${index} + 1") - string(SUBSTRING ${val} - ${index} - -1 - sources) - string(REPLACE " " - ";" - sources - ${sources}) - else() - # discard the group - list(REMOVE_AT val 0) - set(sources ${val}) - endif() - break() - endif() - endforeach() - - list(LENGTH sources list_length) - if(${list_length} LESS 1) - message( - FATAL_ERROR - "No files parsed succesfully from ${SOURCE_GROUP} in ${MAKE_FILE}") - endif() - - # remove trailing whitespaces - set(list_var "") - foreach(source ${sources}) - string(STRIP "${source}" source) - list(APPEND list_var "${source}") - endforeach() - - set(${SOURCES} ${list_var} PARENT_SCOPE) -endfunction() diff --git a/Engine/lib/opus/cmake/OpusPackageVersion.cmake b/Engine/lib/opus/cmake/OpusPackageVersion.cmake deleted file mode 100644 index 447ce3b17..000000000 --- a/Engine/lib/opus/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/Engine/lib/opus/cmake/OpusSources.cmake b/Engine/lib/opus/cmake/OpusSources.cmake deleted file mode 100644 index b47f8c699..000000000 --- a/Engine/lib/opus/cmake/OpusSources.cmake +++ /dev/null @@ -1,49 +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_ARM_RTCD silk_sources.mk silk_sources_arm_rtcd) -get_opus_sources(SILK_SOURCES_ARM_NEON_INTR silk_sources.mk - silk_sources_arm_neon_intr) -get_opus_sources(SILK_SOURCES_FIXED_ARM_NEON_INTR silk_sources.mk - silk_sources_fixed_arm_neon_intr) - -get_opus_sources(OPUS_HEAD opus_headers.mk opus_headers) -get_opus_sources(OPUS_SOURCES opus_sources.mk opus_sources) -get_opus_sources(OPUS_SOURCES_FLOAT opus_sources.mk opus_sources_float) - -get_opus_sources(CELT_HEAD celt_headers.mk celt_headers) -get_opus_sources(CELT_SOURCES celt_sources.mk celt_sources) -get_opus_sources(CELT_SOURCES_X86_RTCD celt_sources.mk celt_sources_x86_rtcd) -get_opus_sources(CELT_SOURCES_SSE celt_sources.mk celt_sources_sse) -get_opus_sources(CELT_SOURCES_SSE2 celt_sources.mk celt_sources_sse2) -get_opus_sources(CELT_SOURCES_SSE4_1 celt_sources.mk celt_sources_sse4_1) -get_opus_sources(CELT_SOURCES_ARM_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(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_decode_SOURCES Makefile.am - test_opus_decode_sources) -get_opus_sources(tests_test_opus_padding_SOURCES Makefile.am - test_opus_padding_sources) diff --git a/Engine/lib/opus/cmake/RunTest.cmake b/Engine/lib/opus/cmake/RunTest.cmake deleted file mode 100644 index f6f8b4a23..000000000 --- a/Engine/lib/opus/cmake/RunTest.cmake +++ /dev/null @@ -1,61 +0,0 @@ -if(NOT EXISTS ${TEST_EXECUTABLE}) - message(FATAL_ERROR "Error could not find ${TEST_EXECUTABLE}, ensure that you built the test binary") -endif() - -if(CMAKE_SYSTEM_NAME STREQUAL "Android") - - # support to run plain old binary on android devices - # requires android debug bridge to be installed - - find_program(adb_executable adb) - if(NOT adb_executable) - message(FATAL_ERROR "Error could not find adb") - endif() - - # check if any device emulator is attached - execute_process(COMMAND ${adb_executable} shell echo RESULT_VARIABLE CMD_RESULT) - if(CMD_RESULT) - message(FATAL_ERROR "Error adb: no devices/emulators found") - endif() - - # push binary - set(android_path /data/local/tmp) - execute_process(COMMAND ${adb_executable} push ${TEST_EXECUTABLE} ${android_path} RESULT_VARIABLE CMD_RESULT) - if(CMD_RESULT) - message(FATAL_ERROR "Error running ${adb_executable} push ${TEST_EXECUTABLE} ${android_path} failed with result ${CMD_RESULT}") - endif() - - # set permissions - get_filename_component(test_executable ${TEST_EXECUTABLE} NAME) - set(test_executable_on_android /data/local/tmp/${test_executable}) - execute_process(COMMAND ${adb_executable} shell chmod 555 ${test_executable_on_android} RESULT_VARIABLE CMD_RESULT) - if(CMD_RESULT) - message(FATAL_ERROR "Error running ${adb_executable} shell chmod 555 ${test_executable_on_android} failed with result ${CMD_RESULT}") - endif() - - # run executable - execute_process(COMMAND ${adb_executable} shell ${test_executable_on_android} RESULT_VARIABLE CMD_RESULT) - if(CMD_RESULT) - message(FATAL_ERROR "Error running ${adb_executable} shell ${test_executable_on_android} failed with result ${CMD_RESULT}") - endif() - - # clean up binary - execute_process(COMMAND ${adb_executable} shell rm ${test_executable_on_android} RESULT_VARIABLE CMD_RESULT) - if(CMD_RESULT) - message(FATAL_ERROR "Error running ${adb_executable} shell rm ${test_executable_on_android} failed with result ${CMD_RESULT}") - endif() - -elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS") - # CTest doesn't support iOS - - message(FATAL_ERROR "Error CTest is not supported on iOS") - -else() - # for other platforms just execute test binary on host - - execute_process(COMMAND ${TEST_EXECUTABLE} RESULT_VARIABLE CMD_RESULT) - if(CMD_RESULT) - message(FATAL_ERROR "Error running ${TEST_EXECUTABLE} failed with result ${CMD_RESULT}") - endif() - -endif() \ No newline at end of file diff --git a/Engine/lib/opus/cmake/config.h.cmake.in b/Engine/lib/opus/cmake/config.h.cmake.in deleted file mode 100644 index 5550842c5..000000000 --- a/Engine/lib/opus/cmake/config.h.cmake.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" \ No newline at end of file diff --git a/Engine/lib/opus/cmake/cpu_info_by_asm.c b/Engine/lib/opus/cmake/cpu_info_by_asm.c deleted file mode 100644 index 1a70a815a..000000000 --- a/Engine/lib/opus/cmake/cpu_info_by_asm.c +++ /dev/null @@ -1,31 +0,0 @@ -#include -int main() { - unsigned int CPUInfo0; - unsigned int CPUInfo1; - unsigned int CPUInfo2; - unsigned int CPUInfo3; - unsigned int InfoType; -#if defined(__i386__) && defined(__PIC__) -/* %ebx is PIC register in 32-bit, so mustn't clobber it. */ - __asm__ __volatile__ ( - "xchg %%ebx, %1\n" - "cpuid\n" - "xchg %%ebx, %1\n": - "=a" (CPUInfo0), - "=r" (CPUInfo1), - "=c" (CPUInfo2), - "=d" (CPUInfo3) : - "0" (InfoType), "2" (0) - ); -#else - __asm__ __volatile__ ( - "cpuid": - "=a" (CPUInfo0), - "=b" (CPUInfo1), - "=c" (CPUInfo2), - "=d" (CPUInfo3) : - "0" (InfoType), "2" (0) - ); -#endif - return 0; -} diff --git a/Engine/lib/opus/cmake/cpu_info_by_c.c b/Engine/lib/opus/cmake/cpu_info_by_c.c deleted file mode 100644 index 117084eb7..000000000 --- a/Engine/lib/opus/cmake/cpu_info_by_c.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -int main() { - unsigned int CPUInfo0; - unsigned int CPUInfo1; - unsigned int CPUInfo2; - unsigned int CPUInfo3; - unsigned int InfoType; - return __get_cpuid_count(InfoType, 0, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3); -} diff --git a/Engine/lib/opus/cmake/vla.c b/Engine/lib/opus/cmake/vla.c deleted file mode 100644 index 05b211979..000000000 --- a/Engine/lib/opus/cmake/vla.c +++ /dev/null @@ -1,7 +0,0 @@ -int main() { - static int x; - char a[++x]; - a[sizeof a - 1] = 0; - int N; - return a[0]; -} \ No newline at end of file diff --git a/Engine/lib/opus/configure.ac b/Engine/lib/opus/configure.ac deleted file mode 100644 index 999f1783d..000000000 --- a/Engine/lib/opus/configure.ac +++ /dev/null @@ -1,951 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -*-m4-*- - -dnl The package_version file will be automatically synced to the git revision -dnl by the update_version script when configured in the repository, but will -dnl remain constant in tarball releases unless it is manually edited. -m4_define([CURRENT_VERSION], - m4_esyscmd([ ./update_version 2>/dev/null || true - if test -e package_version; then - . ./package_version - printf "$PACKAGE_VERSION" - else - printf "unknown" - fi ])) - -AC_INIT([opus],[CURRENT_VERSION],[opus@xiph.org]) - -AC_CONFIG_SRCDIR(src/opus_encoder.c) -AC_CONFIG_MACRO_DIR([m4]) - -dnl enable silent rules on automake 1.11 and later -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -# For libtool. -dnl Please update these for releases. -OPUS_LT_CURRENT=9 -OPUS_LT_REVISION=0 -OPUS_LT_AGE=9 - -AC_SUBST(OPUS_LT_CURRENT) -AC_SUBST(OPUS_LT_REVISION) -AC_SUBST(OPUS_LT_AGE) - -AM_INIT_AUTOMAKE([no-define]) -AM_MAINTAINER_MODE([enable]) - -AC_CANONICAL_HOST -AC_MINGW32 -AM_PROG_LIBTOOL -AM_PROG_CC_C_O - -AC_PROG_CC_C99 -AC_C_CONST -AC_C_INLINE - -AM_PROG_AS - -AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS]) - -#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) -#Note: Both this and the test for variable-size arrays below are also -# done by AC_PROG_CC_C99, but not thoroughly enough apparently. -AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict, - [ac_cv_c_restrict=no - # The order here caters to the fact that C++ does not require restrict. - for ac_kw in __restrict __restrict__ _Restrict restrict; do - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( - [[typedef int * int_ptr; - int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) { - return ip[0]; - }]], - [[int s[1]; - int * $ac_kw t = s; - t[0] = 0; - return foo(t, (void *)0)]])], - [ac_cv_c_restrict=$ac_kw]) - test "$ac_cv_c_restrict" != no && break - done - ]) - -AH_VERBATIM([restrict], -[/* Define to the equivalent of the C99 'restrict' keyword, or to - nothing if this is not supported. Do not define if restrict is - supported directly. */ -#undef restrict -/* Work around a bug in Sun C++: it does not support _Restrict or - __restrict__, even though the corresponding Sun C compiler ends up with - "#define restrict _Restrict" or "#define restrict __restrict__" in the - previous line. Perhaps some future version of Sun C++ will work with - restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ -#if defined __SUNPRO_CC && !defined __RESTRICT -# define _Restrict -# define __restrict__ -#endif]) - -case $ac_cv_c_restrict in - restrict) ;; - no) AC_DEFINE([restrict], []) ;; - *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; -esac - -AC_MSG_CHECKING(for C99 variable-size arrays) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], - [[static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];]])], - [ has_var_arrays=yes - use_alloca="no (using var arrays)" - AC_DEFINE([VAR_ARRAYS], [1], [Use C99 variable-size arrays]) - ],[ - has_var_arrays=no - ]) -AC_MSG_RESULT([$has_var_arrays]) - -AS_IF([test "$has_var_arrays" = "no"], - [ - AC_CHECK_HEADERS([alloca.h]) - AC_MSG_CHECKING(for alloca) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[int foo=10; int *array = alloca(foo);]])], - [ use_alloca=yes; - AC_DEFINE([USE_ALLOCA], [], [Make use of alloca]) - ],[ - use_alloca=no - ]) - AC_MSG_RESULT([$use_alloca]) - ]) - -LT_LIB_M - -AC_ARG_ENABLE([fixed-point], - [AS_HELP_STRING([--enable-fixed-point], - [compile without floating point (for machines without a fast enough FPU)])],, - [enable_fixed_point=no]) - -AS_IF([test "$enable_fixed_point" = "yes"],[ - enable_float="no" - AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point (for machines without a fast enough FPU)]) - PC_BUILD="fixed-point" -],[ - enable_float="yes"; - PC_BUILD="floating-point" -]) - -AM_CONDITIONAL([FIXED_POINT], [test "$enable_fixed_point" = "yes"]) - -AC_ARG_ENABLE([fixed-point-debug], - [AS_HELP_STRING([--enable-fixed-point-debug], [debug fixed-point implementation])],, - [enable_fixed_point_debug=no]) - -AS_IF([test "$enable_fixed_point_debug" = "yes"],[ - AC_DEFINE([FIXED_DEBUG], [1], [Debug fixed-point implementation]) -]) - -AC_ARG_ENABLE([float_api], - [AS_HELP_STRING([--disable-float-api], - [compile without the floating point API (for machines with no float library)])],, - [enable_float_api=yes]) - -AM_CONDITIONAL([DISABLE_FLOAT_API], [test "$enable_float_api" = "no"]) - -AS_IF([test "$enable_float_api" = "no"],[ - AC_DEFINE([DISABLE_FLOAT_API], [1], [Do not build the float API]) -]) - -AC_ARG_ENABLE([custom-modes], - [AS_HELP_STRING([--enable-custom-modes], [enable non-Opus modes, e.g. 44.1 kHz & 2^n frames])],, - [enable_custom_modes=no]) - -AS_IF([test "$enable_custom_modes" = "yes"],[ - AC_DEFINE([CUSTOM_MODES], [1], [Custom modes]) - PC_BUILD="$PC_BUILD, custom modes" -]) - -AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes"]) - -has_float_approx=no -#case "$host_cpu" in -#i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64) -# has_float_approx=yes -# ;; -#esac - -AC_ARG_ENABLE([float-approx], - [AS_HELP_STRING([--enable-float-approx], [enable fast approximations for floating point])], - [if test "$enable_float_approx" = "yes"; then - AC_WARN([Floating point approximations are not supported on all platforms.]) - fi - ], - [enable_float_approx=$has_float_approx]) - -AS_IF([test "$enable_float_approx" = "yes"],[ - AC_DEFINE([FLOAT_APPROX], [1], [Float approximations]) -]) - -AC_ARG_ENABLE([asm], - [AS_HELP_STRING([--disable-asm], [Disable assembly optimizations])],, - [enable_asm=yes]) - -AC_ARG_ENABLE([rtcd], - [AS_HELP_STRING([--disable-rtcd], [Disable run-time CPU capabilities detection])],, - [enable_rtcd=yes]) - -AC_ARG_ENABLE([intrinsics], - [AS_HELP_STRING([--disable-intrinsics], [Disable intrinsics optimizations])],, - [enable_intrinsics=yes]) - -rtcd_support=no -cpu_arm=no -cpu_x86=no - -AS_IF([test x"${enable_asm}" = x"yes"],[ - inline_optimization="No inline ASM for your platform, please send patches" - case $host_cpu in - arm*) - 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]) - 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_IF([test x"$inline_optimization" = x"ARM"],[ - AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],[true]) - AC_DEFINE([OPUS_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], - [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], - [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, - [Use ARM NEON inline asm optimizations]) - inline_optimization="$inline_optimization (NEON)" - ]) - ]) - 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]) - asm_optimization="ARM" - AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"], [ - OPUS_ARM_PRESUME_EDSP=1 - OPUS_ARM_MAY_HAVE_EDSP=1 - ], - [ - OPUS_ARM_PRESUME_EDSP=0 - OPUS_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 - ], - [ - OPUS_ARM_PRESUME_MEDIA=0 - OPUS_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 - ], - [ - OPUS_ARM_PRESUME_NEON=0 - OPUS_ARM_MAY_HAVE_NEON=0 - ]) - AS_IF([test x"$enable_rtcd" = x"yes"],[ - AS_IF([test x"$OPUS_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_IF([test x"$OPUS_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_IF([test x"$OPUS_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]) - ]) - ]) - rtcd_support= - AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" = x"1"],[ - AC_DEFINE(OPUS_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, - [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, - [Define if assembler supports ARMv6 media instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_MEDIA" = x"1"],[ - AC_DEFINE(OPUS_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, - [Define if compiler supports NEON instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_NEON" = x"1"], [ - AC_DEFINE(OPUS_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) - dnl Make sure turning on RTCD gets us at least one - dnl instruction set. - AS_IF([test x"$rtcd_support" != x""], - [rtcd_support=ARM"$rtcd_support"], - [rtcd_support="no"] - ) - AC_MSG_CHECKING([for apple style tools]) - AC_PREPROC_IFELSE([AC_LANG_PROGRAM([ -#ifndef __APPLE__ -#error 1 -#endif],[])], - [AC_MSG_RESULT([yes]); ARM2GNU_PARAMS="--apple"], - [AC_MSG_RESULT([no]); ARM2GNU_PARAMS=""]) - AC_SUBST(ARM2GNU_PARAMS) - ], - [ - AC_MSG_WARN( - [*** ARM assembly requires perl -- disabling optimizations]) - asm_optimization="(missing perl dependency for ARM)" - ]) - ]) - ;; - esac -],[ - inline_optimization="disabled" - asm_optimization="disabled" -]) - -AM_CONDITIONAL([OPUS_ARM_INLINE_ASM], - [test x"${inline_optimization%% *}" = x"ARM"]) -AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM], - [test x"${asm_optimization%% *}" = x"ARM"]) - -AM_CONDITIONAL([HAVE_SSE], [false]) -AM_CONDITIONAL([HAVE_SSE2], [false]) -AM_CONDITIONAL([HAVE_SSE4_1], [false]) -AM_CONDITIONAL([HAVE_AVX], [false]) - -m4_define([DEFAULT_X86_SSE_CFLAGS], [-msse]) -m4_define([DEFAULT_X86_SSE2_CFLAGS], [-msse2]) -m4_define([DEFAULT_X86_SSE4_1_CFLAGS], [-msse4.1]) -m4_define([DEFAULT_X86_AVX_CFLAGS], [-mavx]) -m4_define([DEFAULT_ARM_NEON_INTR_CFLAGS], [-mfpu=neon]) -# With GCC on ARM32 softfp architectures (e.g. Android, or older Ubuntu) you need to specify -# -mfloat-abi=softfp for -mfpu=neon to work. However, on ARM32 hardfp architectures (e.g. newer Ubuntu), -# this option will break things. - -# As a heuristic, if host matches arm*eabi* but not arm*hf*, it's probably soft-float. -m4_define([DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS], [-mfpu=neon -mfloat-abi=softfp]) - -AS_CASE([$host], - [arm*hf*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")], - [arm*eabi*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS")], - [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")]) - -AC_ARG_VAR([X86_SSE_CFLAGS], [C compiler flags to compile SSE intrinsics @<:@default=]DEFAULT_X86_SSE_CFLAGS[@:>@]) -AC_ARG_VAR([X86_SSE2_CFLAGS], [C compiler flags to compile SSE2 intrinsics @<:@default=]DEFAULT_X86_SSE2_CFLAGS[@:>@]) -AC_ARG_VAR([X86_SSE4_1_CFLAGS], [C compiler flags to compile SSE4.1 intrinsics @<:@default=]DEFAULT_X86_SSE4_1_CFLAGS[@:>@]) -AC_ARG_VAR([X86_AVX_CFLAGS], [C compiler flags to compile AVX intrinsics @<:@default=]DEFAULT_X86_AVX_CFLAGS[@:>@]) -AC_ARG_VAR([ARM_NEON_INTR_CFLAGS], [C compiler flags to compile ARM NEON intrinsics @<:@default=]DEFAULT_ARM_NEON_INTR_CFLAGS / DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS[@:>@]) - -AS_VAR_SET_IF([X86_SSE_CFLAGS], [], [AS_VAR_SET([X86_SSE_CFLAGS], "DEFAULT_X86_SSE_CFLAGS")]) -AS_VAR_SET_IF([X86_SSE2_CFLAGS], [], [AS_VAR_SET([X86_SSE2_CFLAGS], "DEFAULT_X86_SSE2_CFLAGS")]) -AS_VAR_SET_IF([X86_SSE4_1_CFLAGS], [], [AS_VAR_SET([X86_SSE4_1_CFLAGS], "DEFAULT_X86_SSE4_1_CFLAGS")]) -AS_VAR_SET_IF([X86_AVX_CFLAGS], [], [AS_VAR_SET([X86_AVX_CFLAGS], "DEFAULT_X86_AVX_CFLAGS")]) -AS_VAR_SET_IF([ARM_NEON_INTR_CFLAGS], [], [AS_VAR_SET([ARM_NEON_INTR_CFLAGS], ["$RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS"])]) - -AC_DEFUN([OPUS_PATH_NE10], - [ - AC_ARG_WITH(NE10, - AC_HELP_STRING([--with-NE10=PFX],[Prefix where libNE10 is installed (optional)]), - NE10_prefix="$withval", NE10_prefix="") - AC_ARG_WITH(NE10-libraries, - AC_HELP_STRING([--with-NE10-libraries=DIR], - [Directory where libNE10 library is installed (optional)]), - NE10_libraries="$withval", NE10_libraries="") - AC_ARG_WITH(NE10-includes, - AC_HELP_STRING([--with-NE10-includes=DIR], - [Directory where libNE10 header files are installed (optional)]), - NE10_includes="$withval", NE10_includes="") - - if test "x$NE10_libraries" != "x" ; then - NE10_LIBS="-L$NE10_libraries" - elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then - NE10_LIBS="" - elif test "x$NE10_prefix" != "x" ; then - NE10_LIBS="-L$NE10_prefix/lib" - elif test "x$prefix" != "xNONE" ; then - NE10_LIBS="-L$prefix/lib" - fi - - if test "x$NE10_prefix" != "xno" ; then - NE10_LIBS="$NE10_LIBS -lNE10" - fi - - if test "x$NE10_includes" != "x" ; then - NE10_CFLAGS="-I$NE10_includes" - elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then - NE10_CFLAGS="" - elif test "x$NE10_prefix" != "x" ; then - NE10_CFLAGS="-I$NE10_prefix/include" - elif test "x$prefix" != "xNONE"; then - NE10_CFLAGS="-I$prefix/include" - fi - - AC_MSG_CHECKING(for NE10) - save_CFLAGS="$CFLAGS"; CFLAGS="$CFLAGS $NE10_CFLAGS" - save_LIBS="$LIBS"; LIBS="$LIBS $NE10_LIBS $LIBM" - AC_LINK_IFELSE( - [ - AC_LANG_PROGRAM( - [[#include - ]], - [[ - ne10_fft_cfg_float32_t cfg; - cfg = ne10_fft_alloc_c2c_float32_neon(480); - ]] - ) - ],[ - HAVE_ARM_NE10=1 - AC_MSG_RESULT([yes]) - ],[ - HAVE_ARM_NE10=0 - AC_MSG_RESULT([no]) - NE10_CFLAGS="" - NE10_LIBS="" - ] - ) - CFLAGS="$save_CFLAGS"; LIBS="$save_LIBS" - #Now we know if libNE10 is installed or not - AS_IF([test x"$HAVE_ARM_NE10" = x"1"], - [ - AC_DEFINE([HAVE_ARM_NE10], 1, [NE10 library is installed on host. Make sure it is on target!]) - AC_SUBST(HAVE_ARM_NE10) - AC_SUBST(NE10_CFLAGS) - AC_SUBST(NE10_LIBS) - ] - ) - ] -) - -AS_IF([test x"$enable_intrinsics" = x"yes"],[ - intrinsics_support="" - AS_CASE([$host_cpu], - [arm*|aarch64*], - [ - cpu_arm=yes - OPUS_CHECK_INTRINSICS( - [ARM Neon], - [$ARM_NEON_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_NEON_INTR], - [OPUS_ARM_PRESUME_NEON_INTR], - [[#include - ]], - [[ - static float32x4_t A0, A1, SUMM; - SUMM = vmlaq_f32(SUMM, A0, A1); - 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"], - [ - OPUS_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS" - AC_SUBST([OPUS_ARM_NEON_INTR_CFLAGS]) - ] - ) - - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"], - [ - AC_DEFINE([OPUS_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"$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])]) - - OPUS_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"], - [rtcd_support="$rtcd_support (NE10)"]) - ]) - - OPUS_CHECK_INTRINSICS( - [Aarch64 Neon], - [$ARM_NEON_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_AARCH64_NEON_INTR], - [OPUS_ARM_PRESUME_AARCH64_NEON_INTR], - [[#include - ]], - [[ - static int32_t IN; - static int16_t OUT; - OUT = vqmovns_s32(IN); - ]] - ) - - AS_IF([test x"$OPUS_ARM_PRESUME_AARCH64_NEON_INTR" = x"1"], - [ - AC_DEFINE([OPUS_ARM_PRESUME_AARCH64_NEON_INTR], 1, [Define if binary requires Aarch64 Neon Intrinsics]) - intrinsics_support="$intrinsics_support (NEON [Aarch64])" - ]) - - AS_IF([test x"$intrinsics_support" = x""], - [intrinsics_support=no], - [intrinsics_support="ARM$intrinsics_support"]) - ], - [ - AC_MSG_WARN([Compiler does not support ARM intrinsics]) - intrinsics_support=no - ]) - ], - [i?86|x86_64], - [ - cpu_x86=yes - OPUS_CHECK_INTRINSICS( - [SSE], - [$X86_SSE_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE], - [OPUS_X86_PRESUME_SSE], - [[#include - #include - ]], - [[ - __m128 mtest; - mtest = _mm_set1_ps((float)time(NULL)); - mtest = _mm_mul_ps(mtest, mtest); - return _mm_cvtss_si32(mtest); - ]] - ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1" && test x"$OPUS_X86_PRESUME_SSE" != x"1"], - [ - OPUS_X86_SSE_CFLAGS="$X86_SSE_CFLAGS" - AC_SUBST([OPUS_X86_SSE_CFLAGS]) - ] - ) - OPUS_CHECK_INTRINSICS( - [SSE2], - [$X86_SSE2_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE2], - [OPUS_X86_PRESUME_SSE2], - [[#include - #include - ]], - [[ - __m128i mtest; - mtest = _mm_set1_epi32((int)time(NULL)); - mtest = _mm_mul_epu32(mtest, mtest); - return _mm_cvtsi128_si32(mtest); - ]] - ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1" && test x"$OPUS_X86_PRESUME_SSE2" != x"1"], - [ - OPUS_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS" - AC_SUBST([OPUS_X86_SSE2_CFLAGS]) - ] - ) - OPUS_CHECK_INTRINSICS( - [SSE4.1], - [$X86_SSE4_1_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE4_1], - [OPUS_X86_PRESUME_SSE4_1], - [[#include - #include - ]], - [[ - __m128i mtest; - mtest = _mm_set1_epi32((int)time(NULL)); - mtest = _mm_mul_epi32(mtest, mtest); - 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"], - [ - OPUS_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS" - AC_SUBST([OPUS_X86_SSE4_1_CFLAGS]) - ] - ) - OPUS_CHECK_INTRINSICS( - [AVX], - [$X86_AVX_CFLAGS], - [OPUS_X86_MAY_HAVE_AVX], - [OPUS_X86_PRESUME_AVX], - [[#include - #include - ]], - [[ - __m256 mtest; - mtest = _mm256_set1_ps((float)time(NULL)); - mtest = _mm256_addsub_ps(mtest, mtest); - return _mm_cvtss_si32(_mm256_extractf128_ps(mtest, 0)); - ]] - ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX" = x"1" && test x"$OPUS_X86_PRESUME_AVX" != x"1"], - [ - OPUS_X86_AVX_CFLAGS="$X86_AVX_CFLAGS" - AC_SUBST([OPUS_X86_AVX_CFLAGS]) - ] - ) - AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support=""]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"], - [ - AC_DEFINE([OPUS_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])], - [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"], - [ - AC_DEFINE([OPUS_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])], - [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"], - [ - AC_DEFINE([OPUS_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])], - [rtcd_support="$rtcd_support SSE4.1"]) - ], - [ - AC_MSG_WARN([Compiler does not support SSE4.1 intrinsics]) - ]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX" = x"1"], - [ - AC_DEFINE([OPUS_X86_MAY_HAVE_AVX], 1, [Compiler supports X86 AVX Intrinsics]) - intrinsics_support="$intrinsics_support AVX" - - AS_IF([test x"$OPUS_X86_PRESUME_AVX" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_AVX], 1, [Define if binary requires AVX intrinsics support])], - [rtcd_support="$rtcd_support AVX"]) - ], - [ - AC_MSG_WARN([Compiler does not support AVX intrinsics]) - ]) - - AS_IF([test x"$intrinsics_support" = x""], - [intrinsics_support=no], - [intrinsics_support="x86$intrinsics_support"] - ) - AS_IF([test x"$rtcd_support" = x""], - [rtcd_support=no], - [rtcd_support="x86$rtcd_support"], - ) - - AS_IF([test x"$enable_rtcd" = x"yes" && test x"$rtcd_support" != x""],[ - get_cpuid_by_asm="no" - AC_MSG_CHECKING([How to get X86 CPU Info]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]],[[ - unsigned int CPUInfo0; - unsigned int CPUInfo1; - unsigned int CPUInfo2; - unsigned int CPUInfo3; - unsigned int InfoType; - #if defined(__i386__) && defined(__PIC__) - __asm__ __volatile__ ( - "xchg %%ebx, %1\n" - "cpuid\n" - "xchg %%ebx, %1\n": - "=a" (CPUInfo0), - "=r" (CPUInfo1), - "=c" (CPUInfo2), - "=d" (CPUInfo3) : - "a" (InfoType), "c" (0) - ); - #else - __asm__ __volatile__ ( - "cpuid": - "=a" (CPUInfo0), - "=b" (CPUInfo1), - "=c" (CPUInfo2), - "=d" (CPUInfo3) : - "a" (InfoType), "c" (0) - ); - #endif - ]])], - [get_cpuid_by_asm="yes" - AC_MSG_RESULT([Inline Assembly]) - AC_DEFINE([CPU_INFO_BY_ASM], [1], [Get CPU Info by asm method])], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]],[[ - unsigned int CPUInfo0; - unsigned int CPUInfo1; - unsigned int CPUInfo2; - unsigned int CPUInfo3; - unsigned int InfoType; - __get_cpuid_count(InfoType, 0, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3); - ]])], - [AC_MSG_RESULT([C method]) - AC_DEFINE([CPU_INFO_BY_C], [1], [Get CPU Info by c method])], - [AC_MSG_ERROR([no supported Get CPU Info method, please disable run-time CPU capabilities detection or intrinsics])])])]) - ], - [ - AC_MSG_WARN([No intrinsics support for your architecture]) - intrinsics_support="no" - ]) -], -[ - intrinsics_support="no" -]) - -AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"]) -AM_CONDITIONAL([HAVE_ARM_NEON_INTR], - [test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"]) -AM_CONDITIONAL([HAVE_ARM_NE10], - [test x"$HAVE_ARM_NE10" = x"1"]) -AM_CONDITIONAL([CPU_X86], [test "$cpu_x86" = "yes"]) -AM_CONDITIONAL([HAVE_SSE], - [test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"]) -AM_CONDITIONAL([HAVE_SSE2], - [test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"]) -AM_CONDITIONAL([HAVE_SSE4_1], - [test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"]) -AM_CONDITIONAL([HAVE_AVX], - [test x"$OPUS_X86_MAY_HAVE_AVX" = x"1"]) - -AM_CONDITIONAL([HAVE_RTCD], - [test x"$enable_rtcd" = x"yes" -a x"$rtcd_support" != x"no"]) -AS_IF([test x"$enable_rtcd" = x"yes"],[ - AS_IF([test x"$rtcd_support" != x"no"],[ - AC_DEFINE([OPUS_HAVE_RTCD], [1], - [Use run-time CPU capabilities detection]) - OPUS_HAVE_RTCD=1 - AC_SUBST(OPUS_HAVE_RTCD) - ]) -],[ - rtcd_support="disabled" -]) - -AC_ARG_ENABLE([assertions], - [AS_HELP_STRING([--enable-assertions],[enable additional software error checking])],, - [enable_assertions=no]) - -AS_IF([test "$enable_assertions" = "yes"], [ - AC_DEFINE([ENABLE_ASSERTIONS], [1], [Assertions]) -]) - -AC_ARG_ENABLE([hardening], - [AS_HELP_STRING([--disable-hardening],[disable run-time checks that are cheap and safe for use in production])],, - [enable_hardening=yes]) - -AS_IF([test "$enable_hardening" = "yes"], [ - AC_DEFINE([ENABLE_HARDENING], [1], [Hardening]) -]) - -AC_ARG_ENABLE([fuzzing], - [AS_HELP_STRING([--enable-fuzzing],[causes the encoder to make random decisions (do not use in production)])],, - [enable_fuzzing=no]) - -AS_IF([test "$enable_fuzzing" = "yes"], [ - AC_DEFINE([FUZZING], [1], [Fuzzing]) -]) - -AC_ARG_ENABLE([check-asm], - [AS_HELP_STRING([--enable-check-asm], - [enable bit-exactness checks between optimized and c implementations])],, - [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_ARG_ENABLE([doc], - [AS_HELP_STRING([--disable-doc], [Do not build API documentation])],, - [enable_doc=yes]) - -AS_IF([test "$enable_doc" = "yes"], [ - AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no]) - AC_CHECK_PROG(HAVE_DOT, [dot], [yes], [no]) -],[ - HAVE_DOXYGEN=no -]) - -AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"]) - -AC_ARG_ENABLE([extra-programs], - [AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)])],, - [enable_extra_programs=yes]) - -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]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], - [ AC_MSG_RESULT([yes]) ], - [ AC_MSG_RESULT([no]) - CFLAGS="$saved_CFLAGS" - ]) - -on_x86=no -case "$host_cpu" in -i[[3456]]86 | x86_64) - on_x86=yes - ;; -esac - -on_windows=no -case $host in -*cygwin*|*mingw*) - on_windows=yes - ;; -esac - -dnl Enable stack-protector-all only on x86 where it's well supported. -dnl on some platforms it causes crashes. Hopefully the OS's default's -dnl include this on platforms that work but have been missed here. -AC_ARG_ENABLE([stack-protector], - [AS_HELP_STRING([--disable-stack-protector],[Disable compiler stack hardening])],, - [ - AS_IF([test "$ac_cv_c_compiler_gnu" = "yes" && test "$on_x86" = "yes" && test "$on_windows" = "no"], - [enable_stack_protector=yes],[enable_stack_protector=no]) - ]) - -AS_IF([test "$enable_stack_protector" = "yes"], - [ - saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fstack-protector-strong" - AC_MSG_CHECKING([if ${CC} supports -fstack-protector-strong]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[[char foo;]])], - [ AC_MSG_RESULT([yes]) ], - [ - AC_MSG_RESULT([no]) - enable_stack_protector=no - CFLAGS="$saved_CFLAGS" - ]) - ]) - -AS_IF([test x$ac_cv_c_compiler_gnu = xyes], - [AX_ADD_FORTIFY_SOURCE] -) - -CFLAGS="$CFLAGS -W" - -warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes" -saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $warn_CFLAGS" -AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], - [ AC_MSG_RESULT([yes]) ], - [ AC_MSG_RESULT([no]) - CFLAGS="$saved_CFLAGS" - ]) - -saved_LIBS="$LIBS" -LIBS="$LIBS $LIBM" -AC_CHECK_FUNCS([lrintf]) -AC_CHECK_FUNCS([lrint]) -LIBS="$saved_LIBS" - -AC_CHECK_FUNCS([__malloc_hook]) - -AC_SUBST([PC_BUILD]) - -AC_CONFIG_FILES([ - Makefile - opus.pc - opus-uninstalled.pc - celt/arm/armopts.s - doc/Makefile - doc/Doxyfile -]) -AC_CONFIG_HEADERS([config.h]) - -AC_OUTPUT - -AC_MSG_NOTICE([ ------------------------------------------------------------------------- - $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK. - - Compiler support: - - C99 var arrays: ................ ${has_var_arrays} - C99 lrintf: .................... ${ac_cv_func_lrintf} - Use alloca: .................... ${use_alloca} - - General configuration: - - Floating point support: ........ ${enable_float} - Fast float approximations: ..... ${enable_float_approx} - Fixed point debugging: ......... ${enable_fixed_point_debug} - Inline Assembly Optimizations: . ${inline_optimization} - External Assembly Optimizations: ${asm_optimization} - Intrinsics Optimizations: ...... ${intrinsics_support} - Run-time CPU detection: ........ ${rtcd_support} - Custom modes: .................. ${enable_custom_modes} - Assertion checking: ............ ${enable_assertions} - Hardening: ..................... ${enable_hardening} - Fuzzing: ....................... ${enable_fuzzing} - Check ASM: ..................... ${enable_check_asm} - - API documentation: ............. ${enable_doc} - Extra programs: ................ ${enable_extra_programs} ------------------------------------------------------------------------- - - Type "make; make install" to compile and install - Type "make check" to run the test suite -]) - diff --git a/Engine/lib/opus/doc/Doxyfile.in b/Engine/lib/opus/doc/Doxyfile.in deleted file mode 100644 index 6eef650b2..000000000 --- a/Engine/lib/opus/doc/Doxyfile.in +++ /dev/null @@ -1,340 +0,0 @@ -# Doxyfile 1.8.18 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -# Only non-default options are included below to improve portability -# between doxygen versions. -# -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = Opus - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = @VERSION@ - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "Opus audio codec (RFC 6716): API and operations manual" - -# With the PROJECT_LOGO tag one can specify a logo or an icon that is included -# in the documentation. The maximum height of the logo should not exceed 55 -# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy -# the logo to the output directory. - -PROJECT_LOGO = - -# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = YES - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 8 - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# (including Cygwin) ands Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. - -ENABLED_SECTIONS = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = YES - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING -# Note: If this tag is empty the current directory is searched. - -INPUT = @top_srcdir@/include/opus.h \ - @top_srcdir@/include/opus_types.h \ - @top_srcdir@/include/opus_defines.h \ - @top_srcdir@/include/opus_multistream.h \ - @top_srcdir@/include/opus_custom.h - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = NO - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = @top_srcdir@/doc/header.html - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = @top_srcdir@/doc/footer.html - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = @top_srcdir@/doc/customdoxygen.css - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = @top_srcdir@/doc/opus_logo.svg - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 0 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to YES can help to show when doxygen was last run and thus if the -# documentation is up to date. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = YES - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from https://www.mathjax.org before deployment. -# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = https://www.mathjax.org/mathjax - -#--------------------------------------------------------------------------- -# Configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# The PAPER_TYPE tag can be used to set the paper type that is used by the -# printer. -# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x -# 14 inches) and executive (7.25 x 10.5 inches). -# The default value is: a4. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -PAPER_TYPE = letter - -#--------------------------------------------------------------------------- -# Configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for -# classes and files. -# The default value is: NO. - -GENERATE_MAN = YES - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names -# in the source code. If set to NO, only conditional compilation will be -# performed. Macro expansion can be done in a controlled way by setting -# EXPAND_ONLY_PREDEF to YES. -# The default value is: NO. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then -# the macro expansion is limited to the macros specified with the PREDEFINED and -# EXPAND_AS_DEFINED tags. -# The default value is: NO. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -EXPAND_ONLY_PREDEF = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by the -# preprocessor. -# This tag requires that the tag SEARCH_INCLUDES is set to YES. - -INCLUDE_PATH = - -# The PREDEFINED tag can be used to specify one or more macro names that are -# defined before the preprocessor is started (similar to the -D option of e.g. -# gcc). The argument of the tag is a list of macros of the form: name or -# name=definition (no spaces). If the definition and the "=" are omitted, "=1" -# is assumed. To prevent a macro definition from being undefined via #undef or -# recursively expanded use the := operator instead of the = operator. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -PREDEFINED = OPUS_EXPORT= \ - OPUS_CUSTOM_EXPORT= \ - OPUS_CUSTOM_EXPORT_STATIC= \ - OPUS_WARN_UNUSED_RESULT= \ - OPUS_ARG_NONNULL(_x)= - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz (see: -# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent -# Bell Labs. The other options in this section have no effect if this option is -# set to NO -# The default value is: NO. - -# Debian defaults to YES here, while Fedora and Homebrew default to NO. -# So we set this based on whether the graphviz package is available at -# configure time. -# -HAVE_DOT = @HAVE_DOT@ - -# move docs to the correct place -OUTPUT_DIRECTORY = @top_builddir@/doc diff --git a/Engine/lib/opus/doc/Makefile.am b/Engine/lib/opus/doc/Makefile.am deleted file mode 100644 index 31fddab49..000000000 --- a/Engine/lib/opus/doc/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -## Process this file with automake to produce Makefile.in - -DOCINPUTS = $(top_srcdir)/include/opus.h \ - $(top_srcdir)/include/opus_multistream.h \ - $(top_srcdir)/include/opus_defines.h \ - $(top_srcdir)/include/opus_types.h \ - $(top_srcdir)/include/opus_custom.h \ - $(top_srcdir)/doc/header.html \ - $(top_srcdir)/doc/footer.html \ - $(top_srcdir)/doc/customdoxygen.css - -EXTRA_DIST = customdoxygen.css Doxyfile.in footer.html header.html \ - opus_logo.svg trivial_example.c - - -if HAVE_DOXYGEN - -all-local: doxygen-build.stamp - -doxygen-build.stamp: Doxyfile $(DOCINPUTS) - doxygen - touch $@ - -install-data-local: - $(INSTALL) -d $(DESTDIR)$(docdir)/html/search - for f in `find html -type f \! -name "installdox"`; do \ - $(INSTALL_DATA) $$f $(DESTDIR)$(docdir)/$$f; \ - done - - $(INSTALL) -d $(DESTDIR)$(mandir)/man3 - cd man && find man3 -type f -name opus_*.3 \ - -exec $(INSTALL_DATA) \{} $(DESTDIR)$(mandir)/man3 \; - -clean-local: - $(RM) -r html - $(RM) -r latex - $(RM) -r man - $(RM) doxygen-build.stamp - $(RM) doxygen_sqlite3.db - -uninstall-local: - $(RM) -r $(DESTDIR)$(docdir)/html - $(RM) $(DESTDIR)$(mandir)/man3/opus_*.3 $(DESTDIR)$(mandir)/man3/opus.h.3 - -endif diff --git a/Engine/lib/opus/doc/build_draft.sh b/Engine/lib/opus/doc/build_draft.sh deleted file mode 100644 index 14ae51dd5..000000000 --- a/Engine/lib/opus/doc/build_draft.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2011-2012 Xiph.Org Foundation and Mozilla Corporation -# -# This file is extracted from RFC6716. Please see that RFC for additional -# information. -# -# 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. - -#Stop on errors -set -e -#Set the CWD to the location of this script -[ -n "${0%/*}" ] && cd "${0%/*}" - -toplevel=".." -destdir="opus_source" - -echo packaging source code -rm -rf "${destdir}" -mkdir "${destdir}" -mkdir "${destdir}/src" -mkdir "${destdir}/silk" -mkdir "${destdir}/silk/float" -mkdir "${destdir}/silk/fixed" -mkdir "${destdir}/silk/fixed/x86" -mkdir "${destdir}/silk/fixed/arm" -mkdir "${destdir}/silk/fixed/mips" -mkdir "${destdir}/silk/x86" -mkdir "${destdir}/silk/arm" -mkdir "${destdir}/silk/mips" -mkdir "${destdir}/celt" -mkdir "${destdir}/celt/x86" -mkdir "${destdir}/celt/arm" -mkdir "${destdir}/celt/mips" -mkdir "${destdir}/include" -for f in `cat "${toplevel}"/opus_sources.mk "${toplevel}"/celt_sources.mk \ - "${toplevel}"/silk_sources.mk "${toplevel}"/opus_headers.mk \ - "${toplevel}"/celt_headers.mk "${toplevel}"/silk_headers.mk \ - | grep '\.[ch]' | sed -e 's/^.*=//' -e 's/\\\\//'` ; do - cp -a "${toplevel}/${f}" "${destdir}/${f}" -done -cp -a "${toplevel}"/src/opus_demo.c "${destdir}"/src/ -cp -a "${toplevel}"/src/opus_compare.c "${destdir}"/src/ -cp -a "${toplevel}"/celt/opus_custom_demo.c "${destdir}"/celt/ -cp -a "${toplevel}"/Makefile.unix "${destdir}"/Makefile -cp -a "${toplevel}"/opus_sources.mk "${destdir}"/ -cp -a "${toplevel}"/celt_sources.mk "${destdir}"/ -cp -a "${toplevel}"/silk_sources.mk "${destdir}"/ -cp -a "${toplevel}"/README.draft "${destdir}"/README -cp -a "${toplevel}"/COPYING "${destdir}"/COPYING -cp -a "${toplevel}"/tests/run_vectors.sh "${destdir}"/ - -GZIP=-9 tar --owner=root --group=root --format=v7 -czf opus_source.tar.gz "${destdir}" -echo building base64 version -cat opus_source.tar.gz| base64 | tr -d '\n' | fold -w 64 | \ - sed -e 's/^/\###/' -e 's/$/\<\/spanx\>\/' > \ - opus_source.base64 - - -#echo '
    ' > opus_compare_escaped.c -#echo '' >> opus_compare_escaped.c -#echo '> opus_compare_escaped.c -#cat opus_compare.c >> opus_compare_escaped.c -#echo ']]>' >> opus_compare_escaped.c -#echo '' >> opus_compare_escaped.c -#echo '
    ' >> opus_compare_escaped.c - -if [ ! -d ../opus_testvectors ] ; then - echo "Downloading test vectors..." - wget 'http://opus-codec.org/testvectors/opus_testvectors.tar.gz' - tar -C .. -xvzf opus_testvectors.tar.gz -fi -echo '
    ' > testvectors_sha1 -echo '' >> testvectors_sha1 -echo '> testvectors_sha1 -(cd ../opus_testvectors; sha1sum *.bit *.dec) >> testvectors_sha1 -#cd opus_testvectors -#sha1sum *.bit *.dec >> ../testvectors_sha1 -#cd .. -echo ']]>' >> testvectors_sha1 -echo '' >> testvectors_sha1 -echo '
    ' >> testvectors_sha1 - -echo running xml2rfc -xml2rfc draft-ietf-codec-opus.xml draft-ietf-codec-opus.html & -xml2rfc draft-ietf-codec-opus.xml -wait diff --git a/Engine/lib/opus/doc/build_isobmff.sh b/Engine/lib/opus/doc/build_isobmff.sh deleted file mode 100644 index 95ea202e4..000000000 --- a/Engine/lib/opus/doc/build_isobmff.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2014 Xiph.Org Foundation and Mozilla Foundation -# -# 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. - -#Stop on errors -set -e -#Set the CWD to the location of this script -[ -n "${0%/*}" ] && cd "${0%/*}" - -HTML=opus_in_isobmff.html - -echo downloading updates... -CSS=${HTML%%.html}.css -wget -q http://vfrmaniac.fushizen.eu/contents/${HTML} -O ${HTML} -wget -q http://vfrmaniac.fushizen.eu/style.css -O ${CSS} - -echo updating links... -cat ${HTML} | sed -e "s/\\.\\.\\/style.css/${CSS}/" > ${HTML}+ && mv ${HTML}+ ${HTML} - -echo stripping... -cat ${HTML} | sed -e 's///g' > ${HTML}+ && mv ${HTML}+ ${HTML} -cat ${HTML} | sed -e 's/ *$//g' > ${HTML}+ && mv ${HTML}+ ${HTML} -cat ${CSS} | sed -e 's/ *$//g' > ${CSS}+ && mv ${CSS}+ ${CSS} - - -VERSION=$(fgrep Version ${HTML} | sed 's/.*Version \([0-9]\.[0-9]\.[0-9]\).*/\1/') -echo Now at version ${VERSION} diff --git a/Engine/lib/opus/doc/build_oggdraft.sh b/Engine/lib/opus/doc/build_oggdraft.sh deleted file mode 100644 index 30ee534b0..000000000 --- a/Engine/lib/opus/doc/build_oggdraft.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2012 Xiph.Org Foundation and Mozilla Corporation -# -# This file is extracted from RFC6716. Please see that RFC for additional -# information. -# -# 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. - -#Stop on errors -set -e -#Set the CWD to the location of this script -[ -n "${0%/*}" ] && cd "${0%/*}" - -if test -z `which xml2rfc 2> /dev/null`; then - echo "Error: couldn't find xml2rfc." - echo - echo "Please install xml2rfc version 2 or later." - echo "E.g. 'pip install xml2rfc' or follow the instructions" - echo "on http://pypi.python.org/pypi/xml2rfc/ or tools.ietf.org." - exit 1 -fi - -echo running xml2rfc -# version 2 syntax -xml2rfc draft-ietf-codec-oggopus.xml --text --html diff --git a/Engine/lib/opus/doc/customdoxygen.css b/Engine/lib/opus/doc/customdoxygen.css deleted file mode 100644 index 70047787c..000000000 --- a/Engine/lib/opus/doc/customdoxygen.css +++ /dev/null @@ -1,1011 +0,0 @@ -/* The standard CSS for doxygen */ - -body, table, div, p, dl { - font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; - font-size: 13px; - line-height: 1.3; -} - -/* @group Heading Levels */ - -h1 { - font-size: 150%; -} - -.title { - font-size: 150%; - font-weight: bold; - margin: 10px 2px; -} - -h2 { - font-size: 120%; -} - -h3 { - font-size: 100%; -} - -dt { - font-weight: bold; -} - -div.multicol { - -moz-column-gap: 1em; - -webkit-column-gap: 1em; - -moz-column-count: 3; - -webkit-column-count: 3; -} - -p.startli, p.startdd, p.starttd { - margin-top: 2px; -} - -p.endli { - margin-bottom: 0px; -} - -p.enddd { - margin-bottom: 4px; -} - -p.endtd { - margin-bottom: 2px; -} - -/* @end */ - -caption { - font-weight: bold; -} - -span.legend { - font-size: 70%; - text-align: center; -} - -h3.version { - font-size: 90%; - text-align: center; -} - -div.qindex, div.navtab{ - background-color: #F1F1F1; - border: 1px solid #BDBDBD; - text-align: center; -} - -div.qindex, div.navpath { - width: 100%; - line-height: 140%; -} - -div.navtab { - margin-right: 15px; -} - -/* @group Link Styling */ - -a { - color: #646464; - font-weight: normal; - text-decoration: none; -} - -.contents a:visited { - color: #747474; -} - -a:hover { - text-decoration: underline; -} - -a.qindex { - font-weight: bold; -} - -a.qindexHL { - font-weight: bold; - background-color: #B8B8B8; - color: #ffffff; - border: 1px double #A8A8A8; -} - -.contents a.qindexHL:visited { - color: #ffffff; -} - -a.el { - font-weight: bold; -} - -a.elRef { -} - -a.code, a.code:visited { - color: #4665A2; -} - -a.codeRef, a.codeRef:visited { - color: #4665A2; -} - -/* @end */ - -dl.el { - margin-left: -1cm; -} - -.fragment { - font-family: monospace, fixed; - font-size: 105%; -} - -pre.fragment { - border: 1px solid #D5D5D5; - background-color: #FCFCFC; - padding: 4px 6px; - margin: 4px 8px 4px 2px; - overflow: auto; - word-wrap: break-word; - font-size: 9pt; - line-height: 125%; -} - -div.ah { - background-color: black; - font-weight: bold; - color: #ffffff; - margin-bottom: 3px; - margin-top: 3px; - padding: 0.2em; - border: solid thin #333; - border-radius: 0.5em; - -webkit-border-radius: .5em; - -moz-border-radius: .5em; - box-shadow: 2px 2px 3px #999; - -webkit-box-shadow: 2px 2px 3px #999; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; - background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); - background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); -} - -div.groupHeader { - margin-left: 16px; - margin-top: 12px; - font-weight: bold; -} - -div.groupText { - margin-left: 16px; - font-style: italic; -} - -body { - background-color: white; - color: black; - margin: 0; -} - -div.contents { - margin-top: 10px; - margin-left: 8px; - margin-right: 8px; -} - -td.indexkey { - background-color: #F1F1F1; - font-weight: bold; - border: 1px solid #D5D5D5; - margin: 2px 0px 2px 0; - padding: 2px 10px; - white-space: nowrap; - vertical-align: top; -} - -td.indexvalue { - background-color: #F1F1F1; - border: 1px solid #D5D5D5; - padding: 2px 10px; - margin: 2px 0px; -} - -tr.memlist { - background-color: #F2F2F2; -} - -p.formulaDsp { - text-align: center; -} - -img.formulaDsp { - -} - -img.formulaInl { - vertical-align: middle; -} - -div.center { - text-align: center; - margin-top: 0px; - margin-bottom: 0px; - padding: 0px; -} - -div.center img { - border: 0px; -} - -address.footer { - text-align: right; - padding-right: 12px; -} - -img.footer { - border: 0px; - vertical-align: middle; -} - -/* @group Code Colorization */ - -span.keyword { - color: #008000 -} - -span.keywordtype { - color: #604020 -} - -span.keywordflow { - color: #e08000 -} - -span.comment { - color: #800000 -} - -span.preprocessor { - color: #806020 -} - -span.stringliteral { - color: #002080 -} - -span.charliteral { - color: #008080 -} - -span.vhdldigit { - color: #ff00ff -} - -span.vhdlchar { - color: #000000 -} - -span.vhdlkeyword { - color: #700070 -} - -span.vhdllogic { - color: #ff0000 -} - -blockquote { - background-color: #F9F9F9; - border-left: 2px solid #B8B8B8; - margin: 0 24px 0 4px; - padding: 0 12px 0 16px; -} - -/* @end */ - -/* -.search { - color: #003399; - font-weight: bold; -} - -form.search { - margin-bottom: 0px; - margin-top: 0px; -} - -input.search { - font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; -} -*/ - -td.tiny { - font-size: 75%; -} - -.dirtab { - padding: 4px; - border-collapse: collapse; - border: 1px solid #BDBDBD; -} - -th.dirtab { - background: #F1F1F1; - font-weight: bold; -} - -hr { - height: 0px; - border: none; - border-top: 1px solid #7A7A7A; -} - -hr.footer { - height: 1px; -} - -/* @group Member Descriptions */ - -table.memberdecls { - border-spacing: 0px; - padding: 0px; -} - -.mdescLeft, .mdescRight, -.memItemLeft, .memItemRight, -.memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #FAFAFA; - border: none; - margin: 4px; - padding: 1px 0 0 8px; -} - -.mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; -} - -.memItemLeft, .memItemRight, .memTemplParams { - border-top: 1px solid #D5D5D5; -} - -.memItemLeft, .memTemplItemLeft { - white-space: nowrap; -} - -.memItemRight { - width: 100%; -} - -.memTemplParams { - color: #747474; - white-space: nowrap; -} - -/* @end */ - -/* @group Member Details */ - -/* Styles for detailed member documentation */ - -.memtemplate { - font-size: 80%; - color: #747474; - font-weight: normal; - margin-left: 9px; -} - -.memnav { - background-color: #F1F1F1; - border: 1px solid #BDBDBD; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} - -.mempage { - width: 100%; -} - -.memitem { - padding: 0; - margin-bottom: 10px; - margin-right: 5px; -} - -.memname { - white-space: nowrap; - font-weight: bold; - margin-left: 6px; -} - -.memproto, dl.reflist dt { - border-top: 1px solid #C0C0C0; - border-left: 1px solid #C0C0C0; - border-right: 1px solid #C0C0C0; - padding: 6px 0px 6px 0px; - color: #3D3D3D; - font-weight: bold; - text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); - /* opera specific markup */ - box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - border-top-right-radius: 8px; - border-top-left-radius: 8px; - /* firefox specific markup */ - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - -moz-border-radius-topright: 8px; - -moz-border-radius-topleft: 8px; - /* webkit specific markup */ - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - -webkit-border-top-right-radius: 8px; - -webkit-border-top-left-radius: 8px; - background-image:url('nav_f.png'); - background-repeat:repeat-x; - background-color: #EAEAEA; - -} - -.memdoc, dl.reflist dd { - border-bottom: 1px solid #C0C0C0; - border-left: 1px solid #C0C0C0; - border-right: 1px solid #C0C0C0; - padding: 2px 5px; - background-color: #FCFCFC; - border-top-width: 0; - /* opera specific markup */ - border-bottom-left-radius: 8px; - border-bottom-right-radius: 8px; - box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - /* firefox specific markup */ - -moz-border-radius-bottomleft: 8px; - -moz-border-radius-bottomright: 8px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F9F9F9 95%, #F2F2F2); - /* webkit specific markup */ - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F9F9F9), to(#F2F2F2)); -} - -dl.reflist dt { - padding: 5px; -} - -dl.reflist dd { - margin: 0px 0px 10px 0px; - padding: 5px; -} - -.paramkey { - text-align: right; -} - -.paramtype { - white-space: nowrap; -} - -.paramname { - color: #602020; - white-space: nowrap; -} -.paramname em { - font-style: normal; -} - -.params, .retval, .exception, .tparams { - border-spacing: 6px 2px; -} - -.params .paramname, .retval .paramname { - font-weight: bold; - vertical-align: top; -} - -.params .paramtype { - font-style: italic; - vertical-align: top; -} - -.params .paramdir { - font-family: "courier new",courier,monospace; - vertical-align: top; -} - - - - -/* @end */ - -/* @group Directory (tree) */ - -/* for the tree view */ - -.ftvtree { - font-family: sans-serif; - margin: 0px; -} - -/* these are for tree view when used as main index */ - -.directory { - font-size: 9pt; - font-weight: bold; - margin: 5px; -} - -.directory h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -/* -The following two styles can be used to replace the root node title -with an image of your choice. Simply uncomment the next two styles, -specify the name of your image and be sure to set 'height' to the -proper pixel height of your image. -*/ - -/* -.directory h3.swap { - height: 61px; - background-repeat: no-repeat; - background-image: url("yourimage.gif"); -} -.directory h3.swap span { - display: none; -} -*/ - -.directory > h3 { - margin-top: 0; -} - -.directory p { - margin: 0px; - white-space: nowrap; -} - -.directory div { - display: none; - margin: 0px; -} - -.directory img { - vertical-align: -30%; -} - -/* these are for tree view when not used as main index */ - -.directory-alt { - font-size: 100%; - font-weight: bold; -} - -.directory-alt h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -.directory-alt > h3 { - margin-top: 0; -} - -.directory-alt p { - margin: 0px; - white-space: nowrap; -} - -.directory-alt div { - display: none; - margin: 0px; -} - -.directory-alt img { - vertical-align: -30%; -} - -/* @end */ - -div.dynheader { - margin-top: 8px; -} - -address { - font-style: normal; - color: #464646; -} - -table.doxtable { - border-collapse:collapse; - margin-top: 4px; - margin-bottom: 4px; -} - -table.doxtable td, table.doxtable th { - border: 1px solid #4A4A4A; - padding: 3px 7px 2px; -} - -table.doxtable th { - background-color: #5B5B5B; - color: #FFFFFF; - font-size: 110%; - padding-bottom: 4px; - padding-top: 5px; -} - -table.fieldtable { - width: 100%; - margin-bottom: 10px; - border: 1px solid #C0C0C0; - border-spacing: 0px; - -moz-border-radius: 4px; - -webkit-border-radius: 4px; - border-radius: 4px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; - -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); - box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); -} - -.fieldtable td, .fieldtable th { - padding: 3px 7px 2px; -} - -.fieldtable td.fieldtype, .fieldtable td.fieldname { - white-space: nowrap; - border-right: 1px solid #C0C0C0; - border-bottom: 1px solid #C0C0C0; - vertical-align: top; -} - -.fieldtable td.fielddoc { - border-bottom: 1px solid #C0C0C0; - width: 100%; -} - -.fieldtable tr:last-child td { - border-bottom: none; -} - -.fieldtable th { - background-image:url('nav_f.png'); - background-repeat:repeat-x; - background-color: #EAEAEA; - font-size: 90%; - color: #3D3D3D; - padding-bottom: 4px; - padding-top: 5px; - text-align:left; - -moz-border-radius-topleft: 4px; - -moz-border-radius-topright: 4px; - -webkit-border-top-left-radius: 4px; - -webkit-border-top-right-radius: 4px; - border-top-left-radius: 4px; - border-top-right-radius: 4px; - border-bottom: 1px solid #C0C0C0; -} - - -.tabsearch { - top: 0px; - left: 10px; - height: 36px; - background-image: url('tab_b.png'); - z-index: 101; - overflow: hidden; - font-size: 13px; -} - -.navpath ul -{ - font-size: 11px; - background-image:url('tab_b.png'); - background-repeat:repeat-x; - height:30px; - line-height:30px; - color:#ABABAB; - border:solid 1px #D3D3D3; - overflow:hidden; - margin:0px; - padding:0px; -} - -.navpath li -{ - list-style-type:none; - float:left; - padding-left:10px; - padding-right:15px; - background-image:url('bc_s.png'); - background-repeat:no-repeat; - background-position:right; - color:#595959; -} - -.navpath li.navelem a -{ - height:32px; - display:block; - text-decoration: none; - outline: none; -} - -.navpath li.navelem a:hover -{ - color:#929292; -} - -.navpath li.footer -{ - list-style-type:none; - float:right; - padding-left:10px; - padding-right:15px; - background-image:none; - background-repeat:no-repeat; - background-position:right; - color:#595959; - font-size: 8pt; -} - - -div.summary -{ - float: right; - font-size: 8pt; - padding-right: 5px; - width: 50%; - text-align: right; -} - -div.summary a -{ - white-space: nowrap; -} - -div.ingroups -{ - margin-left: 5px; - font-size: 8pt; - padding-left: 5px; - width: 50%; - text-align: left; -} - -div.ingroups a -{ - white-space: nowrap; -} - -div.header -{ - background-image:url('nav_h.png'); - background-repeat:repeat-x; - background-color: #FAFAFA; - margin: 0px; - border-bottom: 1px solid #D5D5D5; -} - -div.headertitle -{ - padding: 5px 5px 5px 7px; -} - -dl -{ - padding: 0 0 0 10px; -} - -/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug */ -dl.section -{ - border-left:4px solid; - padding: 0 0 0 6px; -} - -dl.note -{ - border-color: #D0C000; -} - -dl.warning, dl.attention -{ - border-color: #FF0000; -} - -dl.pre, dl.post, dl.invariant -{ - border-color: #00D000; -} - -dl.deprecated -{ - border-color: #505050; -} - -dl.todo -{ - border-color: #00C0E0; -} - -dl.test -{ - border-color: #3030E0; -} - -dl.bug -{ - border-color: #C08050; -} - -dl.section dd { - margin-bottom: 6px; -} - - -#projectlogo -{ - text-align: center; - vertical-align: bottom; - border-collapse: separate; -} - -#projectlogo img -{ - border: 0px none; -} - -#projectname -{ - font: 300% Tahoma, Arial,sans-serif; - margin: 0px; - padding: 2px 0px; -} - -#projectbrief -{ - font: 120% Tahoma, Arial,sans-serif; - margin: 0px; - padding: 0px; -} - -#projectnumber -{ - font: 100% Tahoma, Arial,sans-serif; - margin: 0px; - padding: 0px; -} - -#titlearea -{ - padding: 0px; - margin: 0px; - width: 100%; - border-bottom: 1px solid #848484; -} - -.image -{ - text-align: center; -} - -.dotgraph -{ - text-align: center; -} - -.mscgraph -{ - text-align: center; -} - -.caption -{ - font-weight: bold; -} - -div.zoom -{ - border: 1px solid #AFAFAF; -} - -dl.citelist { - margin-bottom:50px; -} - -dl.citelist dt { - color:#545454; - float:left; - font-weight:bold; - margin-right:10px; - padding:5px; -} - -dl.citelist dd { - margin:2px 0; - padding:5px 0; -} - -div.toc { - padding: 14px 25px; - background-color: #F7F7F7; - border: 1px solid #E3E3E3; - border-radius: 7px 7px 7px 7px; - float: right; - height: auto; - margin: 0 20px 10px 10px; - width: 200px; -} - -div.toc li { - background: url("bdwn.png") no-repeat scroll 0 5px transparent; - font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; - margin-top: 5px; - padding-left: 10px; - padding-top: 2px; -} - -div.toc h3 { - font: bold 12px/1.2 Arial,FreeSans,sans-serif; - color: #747474; - border-bottom: 0 none; - margin: 0; -} - -div.toc ul { - list-style: none outside none; - border: medium none; - padding: 0px; -} - -div.toc li.level1 { - margin-left: 0px; -} - -div.toc li.level2 { - margin-left: 15px; -} - -div.toc li.level3 { - margin-left: 30px; -} - -div.toc li.level4 { - margin-left: 45px; -} - - -@media print -{ - #top { display: none; } - #side-nav { display: none; } - #nav-path { display: none; } - body { overflow:visible; } - h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } - .summary { display: none; } - .memitem { page-break-inside: avoid; } - #doc-content - { - margin-left:0 !important; - height:auto !important; - width:auto !important; - overflow:inherit; - display:inline; - } - pre.fragment - { - overflow: visible; - text-wrap: unrestricted; - white-space: -moz-pre-wrap; /* Moz */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - white-space: pre-wrap; /* CSS3 */ - word-wrap: break-word; /* IE 5.5+ */ - } -} diff --git a/Engine/lib/opus/doc/draft-ietf-codec-oggopus.xml b/Engine/lib/opus/doc/draft-ietf-codec-oggopus.xml deleted file mode 100644 index 128816e93..000000000 --- a/Engine/lib/opus/doc/draft-ietf-codec-oggopus.xml +++ /dev/null @@ -1,1873 +0,0 @@ - - - - - - - - - - - - -]> - - - - - -Ogg Encapsulation for the Opus Audio Codec - -Mozilla Corporation -
    - -650 Castro Street -Mountain View -CA -94041 -USA - -+1 650 903-0800 -tterribe@xiph.org -
    -
    - - -Voicetronix -
    - -246 Pulteney Street, Level 1 -Adelaide -SA -5000 -Australia - -+61 8 8232 9112 -ron@debian.org -
    -
    - - -Mozilla Corporation -
    - -163 West Hastings Street -Vancouver -BC -V6B 1H5 -Canada - -+1 778 785 1540 -giles@xiph.org -
    -
    - - -RAI -codec - - - -This document defines the Ogg encapsulation for the Opus interactive speech and - audio codec. -This allows data encoded in the Opus format to be stored in an Ogg logical - bitstream. - - -
    - - -
    - -The IETF Opus codec is a low-latency audio codec optimized for both voice and - general-purpose audio. -See for technical details. -This document defines the encapsulation of Opus in a continuous, logical Ogg - bitstream . -Ogg encapsulation provides Opus with a long-term storage format supporting - all of the essential features, including metadata, fast and accurate seeking, - corruption detection, recapture after errors, low overhead, and the ability to - multiplex Opus with other codecs (including video) with minimal buffering. -It also provides a live streamable format, capable of delivery over a reliable - stream-oriented transport, without requiring all the data, or even the total - length of the data, up-front, in a form that is identical to the on-disk - storage format. - - -Ogg bitstreams are made up of a series of 'pages', each of which contains data - from one or more 'packets'. -Pages are the fundamental unit of multiplexing in an Ogg stream. -Each page is associated with a particular logical stream and contains a capture - pattern and checksum, flags to mark the beginning and end of the logical - stream, and a 'granule position' that represents an absolute position in the - stream, to aid seeking. -A single page can contain up to 65,025 octets of packet data from up to 255 - different packets. -Packets can be split arbitrarily across pages, and continued from one page to - the next (allowing packets much larger than would fit on a single page). -Each page contains 'lacing values' that indicate how the data is partitioned - into packets, allowing a demultiplexer (demuxer) to recover the packet - boundaries without examining the encoded data. -A packet is said to 'complete' on a page when the page contains the final - lacing value corresponding to that packet. - - -This encapsulation defines the contents of the packet data, including - the necessary headers, the organization of those packets into a logical - stream, and the interpretation of the codec-specific granule position field. -It does not attempt to describe or specify the existing Ogg container format. -Readers unfamiliar with the basic concepts mentioned above are encouraged to - review the details in . - - -
    - -
    - -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", - "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this - document are to be interpreted as described in . - - -
    - -
    - -An Ogg Opus stream is organized as follows (see - for an example). - - -
    - -
    - - -There are two mandatory header packets. -The first packet in the logical Ogg bitstream MUST contain the identification - (ID) header, which uniquely identifies a stream as Opus audio. -The format of this header is defined in . -It is placed alone (without any other packet data) on the first page of - the logical Ogg bitstream, and completes on that page. -This page has its 'beginning of stream' flag set. - - -The second packet in the logical Ogg bitstream MUST contain the comment header, - which contains user-supplied metadata. -The format of this header is defined in . -It MAY span multiple pages, beginning on the second page of the logical - stream. -However many pages it spans, the comment header packet MUST finish the page on - which it completes. - - -All subsequent pages are audio data pages, and the Ogg packets they contain are - audio data packets. -Each audio data packet contains one Opus packet for each of N different - streams, where N is typically one for mono or stereo, but MAY be greater than - one for multichannel audio. -The value N is specified in the ID header (see - ), and is fixed over the entire length of the - logical Ogg bitstream. - - -The first (N - 1) Opus packets, if any, are packed one after another - into the Ogg packet, using the self-delimiting framing from Appendix B of - . -The remaining Opus packet is packed at the end of the Ogg packet using the - regular, undelimited framing from Section 3 of . -All of the Opus packets in a single Ogg packet MUST be constrained to have the - same duration. -An implementation of this specification SHOULD treat any Opus packet whose - duration is different from that of the first Opus packet in an Ogg packet as - if it were a malformed Opus packet with an invalid Table Of Contents (TOC) - sequence. - - -The TOC sequence at the beginning of each Opus packet indicates the coding - mode, audio bandwidth, channel count, duration (frame size), and number of - frames per packet, as described in Section 3.1 - of . -The coding mode is one of SILK, Hybrid, or Constrained Energy Lapped Transform - (CELT). -The combination of coding mode, audio bandwidth, and frame size is referred to - as the configuration of an Opus packet. - - -Packets are placed into Ogg pages in order until the end of stream. -Audio data packets might span page boundaries. -The first audio data page could have the 'continued packet' flag set - (indicating the first audio data packet is continued from a previous page) if, - for example, it was a live stream joined mid-broadcast, with the headers - pasted on the front. -If a page has the 'continued packet' flag set and one of the following - conditions is also true: - -the previous page with packet data does not end in a continued packet (does - not end with a lacing value of 255) OR -the page sequence numbers are not consecutive, - - then a demuxer MUST NOT attempt to decode the data for the first packet on the - page unless the demuxer has some special knowledge that would allow it to - interpret this data despite the missing pieces. -An implementation MUST treat a zero-octet audio data packet as if it were a - malformed Opus packet as described in - Section 3.4 of . - - -A logical stream ends with a page with the 'end of stream' flag set, but - implementations need to be prepared to deal with truncated streams that do not - have a page marked 'end of stream'. -There is no reason for the final packet on the last page to be a continued - packet, i.e., for the final lacing value to be 255. -However, demuxers might encounter such streams, possibly as the result of a - transfer that did not complete or of corruption. -If a packet continues onto a subsequent page (i.e., when the page ends with a - lacing value of 255) and one of the following conditions is also true: - -the next page with packet data does not have the 'continued packet' flag - set OR -there is no next page with packet data OR -the page sequence numbers are not consecutive, - - then a demuxer MUST NOT attempt to decode the data from that packet unless the - demuxer has some special knowledge that would allow it to interpret this data - despite the missing pieces. -There MUST NOT be any more pages in an Opus logical bitstream after a page - marked 'end of stream'. - -
    - -
    - -The granule position MUST be zero for the ID header page and the - page where the comment header completes. -That is, the first page in the logical stream, and the last header - page before the first audio data page both have a granule position of zero. - - -The granule position of an audio data page encodes the total number of PCM - samples in the stream up to and including the last fully-decodable sample from - the last packet completed on that page. -The granule position of the first audio data page will usually be larger than - zero, as described in . - - - -A page that is entirely spanned by a single packet (that completes on a - subsequent page) has no granule position, and the granule position field is - set to the special value '-1' in two's complement. - - - -The granule position of an audio data page is in units of PCM audio samples at - a fixed rate of 48 kHz (per channel; a stereo stream's granule position - does not increment at twice the speed of a mono stream). -It is possible to run an Opus decoder at other sampling rates, - but all Opus packets encode samples at a sampling rate that evenly divides - 48 kHz. -Therefore, the value in the granule position field always counts samples - assuming a 48 kHz decoding rate, and the rest of this specification makes - the same assumption. - - - -The duration of an Opus packet as defined in can be - any multiple of 2.5 ms, up to a maximum of 120 ms. -This duration is encoded in the TOC sequence at the beginning of each packet. -The number of samples returned by a decoder corresponds to this duration - exactly, even for the first few packets. -For example, a 20 ms packet fed to a decoder running at 48 kHz will - always return 960 samples. -A demuxer can parse the TOC sequence at the beginning of each Ogg packet to - work backwards or forwards from a packet with a known granule position (i.e., - the last packet completed on some page) in order to assign granule positions - to every packet, or even every individual sample. -The one exception is the last page in the stream, as described below. - - - -All other pages with completed packets after the first MUST have a granule - position equal to the number of samples contained in packets that complete on - that page plus the granule position of the most recent page with completed - packets. -This guarantees that a demuxer can assign individual packets the same granule - position when working forwards as when working backwards. -For this to work, there cannot be any gaps. - - -
    - -In order to support capturing a real-time stream that has lost or not - transmitted packets, a multiplexer (muxer) SHOULD emit packets that explicitly - request the use of Packet Loss Concealment (PLC) in place of the missing - packets. -Implementations that fail to do so still MUST NOT increment the granule - position for a page by anything other than the number of samples contained in - packets that actually complete on that page. - - -Only gaps that are a multiple of 2.5 ms are repairable, as these are the - only durations that can be created by packet loss or discontinuous - transmission. -Muxers need not handle other gap sizes. -Creating the necessary packets involves synthesizing a TOC byte (defined in -Section 3.1 of )—and whatever - additional internal framing is needed—to indicate the packet duration - for each stream. -The actual length of each missing Opus frame inside the packet is zero bytes, - as defined in Section 3.2.1 of . - - - -Zero-byte frames MAY be packed into packets using any of codes 0, 1, - 2, or 3. -When successive frames have the same configuration, the higher code packings - reduce overhead. -Likewise, if the TOC configuration matches, the muxer MAY further combine the - empty frames with previous or subsequent non-zero-length frames (using - code 2 or VBR code 3). - - - - does not impose any requirements on the PLC, but this - section outlines choices that are expected to have a positive influence on - most PLC implementations, including the reference implementation. -Synthesized TOC sequences SHOULD maintain the same mode, audio bandwidth, - channel count, and frame size as the previous packet (if any). -This is the simplest and usually the most well-tested case for the PLC to - handle and it covers all losses that do not include a configuration switch, - as defined in Section 4.5 of . - - - -When a previous packet is available, keeping the audio bandwidth and channel - count the same allows the PLC to provide maximum continuity in the concealment - data it generates. -However, if the size of the gap is not a multiple of the most recent frame - size, then the frame size will have to change for at least some frames. -Such changes SHOULD be delayed as long as possible to simplify - things for PLC implementations. - - - -As an example, a 95 ms gap could be encoded as nineteen 5 ms frames - in two bytes with a single CBR code 3 packet. -If the previous frame size was 20 ms, using four 20 ms frames - followed by three 5 ms frames requires 4 bytes (plus an extra byte - of Ogg lacing overhead), but allows the PLC to use its well-tested steady - state behavior for as long as possible. -The total bitrate of the latter approach, including Ogg overhead, is about - 0.4 kbps, so the impact on file size is minimal. - - - -Changing modes is discouraged, since this causes some decoder implementations - to reset their PLC state. -However, SILK and Hybrid mode frames cannot fill gaps that are not a multiple - of 10 ms. -If switching to CELT mode is needed to match the gap size, a muxer SHOULD do - so at the end of the gap to allow the PLC to function for as long as possible. - - - -In the example above, if the previous frame was a 20 ms SILK mode frame, - the better solution is to synthesize a packet describing four 20 ms SILK - frames, followed by a packet with a single 10 ms SILK - frame, and finally a packet with a 5 ms CELT frame, to fill the 95 ms - gap. -This also requires four bytes to describe the synthesized packet data (two - bytes for a CBR code 3 and one byte each for two code 0 packets) but three - bytes of Ogg lacing overhead are needed to mark the packet boundaries. -At 0.6 kbps, this is still a minimal bitrate impact over a naive, low quality - solution. - - - -Since medium-band audio is an option only in the SILK mode, wideband frames - SHOULD be generated if switching from that configuration to CELT mode, to - ensure that any PLC implementation which does try to migrate state between - the modes will be able to preserve all of the available audio bandwidth. - - -
    - -
    - -There is some amount of latency introduced during the decoding process, to - allow for overlap in the CELT mode, stereo mixing in the SILK mode, and - resampling. -The encoder might have introduced additional latency through its own resampling - and analysis (though the exact amount is not specified). -Therefore, the first few samples produced by the decoder do not correspond to - real input audio, but are instead composed of padding inserted by the encoder - to compensate for this latency. -These samples need to be stored and decoded, as Opus is an asymptotically - convergent predictive codec, meaning the decoded contents of each frame depend - on the recent history of decoder inputs. -However, a player will want to skip these samples after decoding them. - - - -A 'pre-skip' field in the ID header (see ) signals - the number of samples that SHOULD be skipped (decoded but discarded) at the - beginning of the stream, though some specific applications might have a reason - for looking at that data. -This amount need not be a multiple of 2.5 ms, MAY be smaller than a single - packet, or MAY span the contents of several packets. -These samples are not valid audio. - - - -For example, if the first Opus frame uses the CELT mode, it will always - produce 120 samples of windowed overlap-add data. -However, the overlap data is initially all zeros (since there is no prior - frame), meaning this cannot, in general, accurately represent the original - audio. -The SILK mode requires additional delay to account for its analysis and - resampling latency. -The encoder delays the original audio to avoid this problem. - - - -The pre-skip field MAY also be used to perform sample-accurate cropping of - already encoded streams. -In this case, a value of at least 3840 samples (80 ms) provides - sufficient history to the decoder that it will have converged - before the stream's output begins. - - -
    - -
    - -The PCM sample position is determined from the granule position using the - formula - -
    - -
    - - -For example, if the granule position of the first audio data page is 59,971, - and the pre-skip is 11,971, then the PCM sample position of the last decoded - sample from that page is 48,000. - - -This can be converted into a playback time using the formula - -
    - -
    - - -The initial PCM sample position before any samples are played is normally '0'. -In this case, the PCM sample position of the first audio sample to be played - starts at '1', because it marks the time on the clock - after that sample has been played, and a stream - that is exactly one second long has a final PCM sample position of '48000', - as in the example here. - - - -Vorbis streams use a granule position smaller than the number of audio samples - contained in the first audio data page to indicate that some of those samples - are trimmed from the output (see ). -However, to do so, Vorbis requires that the first audio data page contains - exactly two packets, in order to allow the decoder to perform PCM position - adjustments before needing to return any PCM data. -Opus uses the pre-skip mechanism for this purpose instead, since the encoder - might introduce more than a single packet's worth of latency, and since very - large packets in streams with a very large number of channels might not fit - on a single page. - -
    - -
    - -The page with the 'end of stream' flag set MAY have a granule position that - indicates the page contains less audio data than would normally be returned by - decoding up through the final packet. -This is used to end the stream somewhere other than an even frame boundary. -The granule position of the most recent audio data page with completed packets - is used to make this determination, or '0' is used if there were no previous - audio data pages with a completed packet. -The difference between these granule positions indicates how many samples to - keep after decoding the packets that completed on the final page. -The remaining samples are discarded. -The number of discarded samples SHOULD be no larger than the number decoded - from the last packet. - -
    - -
    - -The granule position of the first audio data page with a completed packet MAY - be larger than the number of samples contained in packets that complete on - that page, however it MUST NOT be smaller, unless that page has the 'end of - stream' flag set. -Allowing a granule position larger than the number of samples allows the - beginning of a stream to be cropped or a live stream to be joined without - rewriting the granule position of all the remaining pages. -This means that the PCM sample position just before the first sample to be - played MAY be larger than '0'. -Synchronization when multiplexing with other logical streams still uses the PCM - sample position relative to '0' to compute sample times. -This does not affect the behavior of pre-skip: exactly 'pre-skip' samples - SHOULD be skipped from the beginning of the decoded output, even if the - initial PCM sample position is greater than zero. - - - -On the other hand, a granule position that is smaller than the number of - decoded samples prevents a demuxer from working backwards to assign each - packet or each individual sample a valid granule position, since granule - positions are non-negative. -An implementation MUST treat any stream as invalid if the granule position - is smaller than the number of samples contained in packets that complete on - the first audio data page with a completed packet, unless that page has the - 'end of stream' flag set. -It MAY defer this action until it decodes the last packet completed on that - page. - - - -If that page has the 'end of stream' flag set, a demuxer MUST treat any stream - as invalid if its granule position is smaller than the 'pre-skip' amount. -This would indicate that there are more samples to be skipped from the initial - decoded output than exist in the stream. -If the granule position is smaller than the number of decoded samples produced - by the packets that complete on that page, then a demuxer MUST use an initial - granule position of '0', and can work forwards from '0' to timestamp - individual packets. -If the granule position is larger than the number of decoded samples available, - then the demuxer MUST still work backwards as described above, even if the - 'end of stream' flag is set, to determine the initial granule position, and - thus the initial PCM sample position. -Both of these will be greater than '0' in this case. - -
    - -
    - -Seeking in Ogg files is best performed using a bisection search for a page - whose granule position corresponds to a PCM position at or before the seek - target. -With appropriately weighted bisection, accurate seeking can be performed in - just one or two bisections on average, even in multi-gigabyte files. -See for an example of general implementation guidance. - - - -When seeking within an Ogg Opus stream, an implementation SHOULD start decoding - (and discarding the output) at least 3840 samples (80 ms) prior to - the seek target in order to ensure that the output audio is correct by the - time it reaches the seek target. -This 'pre-roll' is separate from, and unrelated to, the 'pre-skip' used at the - beginning of the stream. -If the point 80 ms prior to the seek target comes before the initial PCM - sample position, an implementation SHOULD start decoding from the beginning of - the stream, applying pre-skip as normal, regardless of whether the pre-skip is - larger or smaller than 80 ms, and then continue to discard samples - to reach the seek target (if any). - -
    - -
    - -
    - -An Ogg Opus logical stream contains exactly two mandatory header packets: - an identification header and a comment header. - - -
    - -
    - -
    - - -The fields in the identification (ID) header have the following meaning: - -Magic Signature: - -This is an 8-octet (64-bit) field that allows codec identification and is - human-readable. -It contains, in order, the magic numbers: - -0x4F 'O' -0x70 'p' -0x75 'u' -0x73 's' -0x48 'H' -0x65 'e' -0x61 'a' -0x64 'd' - -Starting with "Op" helps distinguish it from audio data packets, as this is an - invalid TOC sequence. - - -Version (8 bits, unsigned): - -The version number MUST always be '1' for this version of the encapsulation - specification. -Implementations SHOULD treat streams where the upper four bits of the version - number match that of a recognized specification as backwards-compatible with - that specification. -That is, the version number can be split into "major" and "minor" version - sub-fields, with changes to the "minor" sub-field (in the lower four bits) - signaling compatible changes. -For example, an implementation of this specification SHOULD accept any stream - with a version number of '15' or less, and SHOULD assume any stream with a - version number '16' or greater is incompatible. -The initial version '1' was chosen to keep implementations from relying on this - octet as a null terminator for the "OpusHead" string. - - -Output Channel Count 'C' (8 bits, unsigned): - -This is the number of output channels. -This might be different than the number of encoded channels, which can change - on a packet-by-packet basis. -This value MUST NOT be zero. -The maximum allowable value depends on the channel mapping family, and might be - as large as 255. -See for details. - - -Pre-skip (16 bits, unsigned, little - endian): - -This is the number of samples (at 48 kHz) to discard from the decoder - output when starting playback, and also the number to subtract from a page's - granule position to calculate its PCM sample position. -When cropping the beginning of existing Ogg Opus streams, a pre-skip of at - least 3,840 samples (80 ms) is RECOMMENDED to ensure complete - convergence in the decoder. - - -Input Sample Rate (32 bits, unsigned, little - endian): - -This is the sample rate of the original input (before encoding), in Hz. -This field is not the sample rate to use for - playback of the encoded data. - -Opus can switch between internal audio bandwidths of 4, 6, 8, 12, and - 20 kHz. -Each packet in the stream can have a different audio bandwidth. -Regardless of the audio bandwidth, the reference decoder supports decoding any - stream at a sample rate of 8, 12, 16, 24, or 48 kHz. -The original sample rate of the audio passed to the encoder is not preserved - by the lossy compression. - -An Ogg Opus player SHOULD select the playback sample rate according to the - following procedure: - -If the hardware supports 48 kHz playback, decode at 48 kHz. -Otherwise, if the hardware's highest available sample rate is a supported - rate, decode at this sample rate. -Otherwise, if the hardware's highest available sample rate is less than - 48 kHz, decode at the next higher Opus supported rate above the highest - available hardware rate and resample. -Otherwise, decode at 48 kHz and resample. - -However, the 'Input Sample Rate' field allows the muxer to pass the sample - rate of the original input stream as metadata. -This is useful when the user requires the output sample rate to match the - input sample rate. -For example, when not playing the output, an implementation writing PCM format - samples to disk might choose to resample the audio back to the original input - sample rate to reduce surprise to the user, who might reasonably expect to get - back a file with the same sample rate. - -A value of zero indicates 'unspecified'. -Muxers SHOULD write the actual input sample rate or zero, but implementations - which do something with this field SHOULD take care to behave sanely if given - crazy values (e.g., do not actually upsample the output to 10 MHz if - requested). -Implementations SHOULD support input sample rates between 8 kHz and - 192 kHz (inclusive). -Rates outside this range MAY be ignored by falling back to the default rate of - 48 kHz instead. - - -Output Gain (16 bits, signed, little endian): - -This is a gain to be applied when decoding. -It is 20*log10 of the factor by which to scale the decoder output to achieve - the desired playback volume, stored in a 16-bit, signed, two's complement - fixed-point value with 8 fractional bits (i.e., - Q7.8 ). - -To apply the gain, an implementation could use -
    - -
    - where output_gain is the raw 16-bit value from the header. - -Players and media frameworks SHOULD apply it by default. -If a player chooses to apply any volume adjustment or gain modification, such - as the R128_TRACK_GAIN (see ), the adjustment - MUST be applied in addition to this output gain in order to achieve playback - at the normalized volume. - -A muxer SHOULD set this field to zero, and instead apply any gain prior to - encoding, when this is possible and does not conflict with the user's wishes. -A nonzero output gain indicates the gain was adjusted after encoding, or that - a user wished to adjust the gain for playback while preserving the ability - to recover the original signal amplitude. - -Although the output gain has enormous range (+/- 128 dB, enough to amplify - inaudible sounds to the threshold of physical pain), most applications can - only reasonably use a small portion of this range around zero. -The large range serves in part to ensure that gain can always be losslessly - transferred between OpusHead and R128 gain tags (see below) without - saturating. - -
    -Channel Mapping Family (8 bits, unsigned): - -This octet indicates the order and semantic meaning of the output channels. - -Each currently specified value of this octet indicates a mapping family, which - defines a set of allowed channel counts, and the ordered set of channel names - for each allowed channel count. -The details are described in . - -Channel Mapping Table: -This table defines the mapping from encoded streams to output channels. -Its contents are specified in . - -
    -
    - - -All fields in the ID headers are REQUIRED, except for the channel mapping - table, which MUST be omitted when the channel mapping family is 0, but - is REQUIRED otherwise. -Implementations SHOULD treat a stream as invalid if it contains an ID header - that does not have enough data for these fields, even if it contain a valid - Magic Signature. -Future versions of this specification, even backwards-compatible versions, - might include additional fields in the ID header. -If an ID header has a compatible major version, but a larger minor version, - an implementation MUST NOT treat it as invalid for containing additional data - not specified here, provided it still completes on the first page. - - -
    - -An Ogg Opus stream allows mapping one number of Opus streams (N) to a possibly - larger number of decoded channels (M + N) to yet another number of - output channels (C), which might be larger or smaller than the number of - decoded channels. -The order and meaning of these channels are defined by a channel mapping, - which consists of the 'channel mapping family' octet and, for channel mapping - families other than family 0, a channel mapping table, as illustrated in - . - - -
    - -
    - - -The fields in the channel mapping table have the following meaning: - -Stream Count 'N' (8 bits, unsigned): - -This is the total number of streams encoded in each Ogg packet. -This value is necessary to correctly parse the packed Opus packets inside an - Ogg packet, as described in . -This value MUST NOT be zero, as without at least one Opus packet with a valid - TOC sequence, a demuxer cannot recover the duration of an Ogg packet. - -For channel mapping family 0, this value defaults to 1, and is not coded. - - -Coupled Stream Count 'M' (8 bits, unsigned): -This is the number of streams whose decoders are to be configured to produce - two channels (stereo). -This MUST be no larger than the total number of streams, N. - -Each packet in an Opus stream has an internal channel count of 1 or 2, which - can change from packet to packet. -This is selected by the encoder depending on the bitrate and the audio being - encoded. -The original channel count of the audio passed to the encoder is not - necessarily preserved by the lossy compression. - -Regardless of the internal channel count, any Opus stream can be decoded as - mono (a single channel) or stereo (two channels) by appropriate initialization - of the decoder. -The 'coupled stream count' field indicates that the decoders for the first M - Opus streams are to be initialized for stereo (two-channel) output, and the - remaining (N - M) decoders are to be initialized for mono (a single - channel) only. -The total number of decoded channels, (M + N), MUST be no larger than - 255, as there is no way to index more channels than that in the channel - mapping. - -For channel mapping family 0, this value defaults to (C - 1) - (i.e., 0 for mono and 1 for stereo), and is not coded. - - -Channel Mapping (8*C bits): -This contains one octet per output channel, indicating which decoded channel - is to be used for each one. -Let 'index' be the value of this octet for a particular output channel. -This value MUST either be smaller than (M + N), or be the special - value 255. -If 'index' is less than 2*M, the output MUST be taken from decoding stream - ('index'/2) as stereo and selecting the left channel if 'index' is even, and - the right channel if 'index' is odd. -If 'index' is 2*M or larger, but less than 255, the output MUST be taken from - decoding stream ('index' - M) as mono. -If 'index' is 255, the corresponding output channel MUST contain pure silence. - -The number of output channels, C, is not constrained to match the number of - decoded channels (M + N). -A single index value MAY appear multiple times, i.e., the same decoded channel - might be mapped to multiple output channels. -Some decoded channels might not be assigned to any output channel, as well. - -For channel mapping family 0, the first index defaults to 0, and if - C == 2, the second index defaults to 1. -Neither index is coded. - - - - - -After producing the output channels, the channel mapping family determines the - semantic meaning of each one. -There are three defined mapping families in this specification. - - -
    - -Allowed numbers of channels: 1 or 2. -RTP mapping. -This is the same channel interpretation as . - - - -1 channel: monophonic (mono). -2 channels: stereo (left, right). - -Special mapping: This channel mapping value also - indicates that the contents consists of a single Opus stream that is stereo if - and only if C == 2, with stream index 0 mapped to output - channel 0 (mono, or left channel) and stream index 1 mapped to - output channel 1 (right channel) if stereo. -When the 'channel mapping family' octet has this value, the channel mapping - table MUST be omitted from the ID header packet. - -
    - -
    - -Allowed numbers of channels: 1...8. -Vorbis channel order (see below). - - -Each channel is assigned to a speaker location in a conventional surround - arrangement. -Specific locations depend on the number of channels, and are given below - in order of the corresponding channel indices. - - 1 channel: monophonic (mono). - 2 channels: stereo (left, right). - 3 channels: linear surround (left, center, right) - 4 channels: quadraphonic (front left, front right, rear left, rear right). - 5 channels: 5.0 surround (front left, front center, front right, rear left, rear right). - 6 channels: 5.1 surround (front left, front center, front right, rear left, rear right, LFE). - 7 channels: 6.1 surround (front left, front center, front right, side left, side right, rear center, LFE). - 8 channels: 7.1 surround (front left, front center, front right, side left, side right, rear left, rear right, LFE) - - - -This set of surround options and speaker location orderings is the same - as those used by the Vorbis codec . -The ordering is different from the one used by the - WAVE and - Free Lossless Audio Codec (FLAC) formats, - so correct ordering requires permutation of the output channels when decoding - to or encoding from those formats. -'LFE' here refers to a Low Frequency Effects channel, often mapped to a - subwoofer with no particular spatial position. -Implementations SHOULD identify 'side' or 'rear' speaker locations with - 'surround' and 'back' as appropriate when interfacing with audio formats - or systems which prefer that terminology. - -
    - -
    - -Allowed numbers of channels: 1...255. -No defined channel meaning. - - -Channels are unidentified. -General-purpose players SHOULD NOT attempt to play these streams. -Offline implementations MAY deinterleave the output into separate PCM files, - one per channel. -Implementations SHOULD NOT produce output for channels mapped to stream index - 255 (pure silence) unless they have no other way to indicate the index of - non-silent channels. - -
    - -
    - -The remaining channel mapping families (2...254) are reserved. -A demuxer implementation encountering a reserved channel mapping family value - SHOULD act as though the value is 255. - -
    - -
    - -An Ogg Opus player MUST support any valid channel mapping with a channel - mapping family of 0 or 1, even if the number of channels does not match the - physically connected audio hardware. -Players SHOULD perform channel mixing to increase or reduce the number of - channels as needed. - - - -Implementations MAY use the matrices in - Figures  - through  to implement - downmixing from multichannel files using - Channel Mapping Family 1, which are - known to give acceptable results for stereo. -Matrices for 3 and 4 channels are normalized so each coefficient row sums - to 1 to avoid clipping. -For 5 or more channels they are normalized to 2 as a compromise between - clipping and dynamic range reduction. - - -In these matrices the front left and front right channels are generally -passed through directly. -When a surround channel is split between both the left and right stereo - channels, coefficients are chosen so their squares sum to 1, which - helps preserve the perceived intensity. -Rear channels are mixed more diffusely or attenuated to maintain focus - on the front channels. - - -
    - - -Exact coefficient values are 1 and 1/sqrt(2), multiplied by - 1/(1 + 1/sqrt(2)) for normalization. - -
    - -
    - - -Exact coefficient values are 1, sqrt(3)/2 and 1/2, multiplied by - 1/(1 + sqrt(3)/2 + 1/2) for normalization. - -
    - -
    - - -Exact coefficient values are 1, 1/sqrt(2), sqrt(3)/2 and 1/2, multiplied by - 2/(1 + 1/sqrt(2) + sqrt(3)/2 + 1/2) - for normalization. - -
    - -
    - - -Exact coefficient values are 1, 1/sqrt(2), sqrt(3)/2 and 1/2, multiplied by -2/(1 + 1/sqrt(2) + sqrt(3)/2 + 1/2 + 1/sqrt(2)) - for normalization. - -
    - -
    - - -Exact coefficient values are 1, 1/sqrt(2), sqrt(3)/2, 1/2 and - sqrt(3)/2/sqrt(2), multiplied by - 2/(1 + 1/sqrt(2) + sqrt(3)/2 + 1/2 + - sqrt(3)/2/sqrt(2) + 1/sqrt(2)) for normalization. -The coefficients are in the same order as in , - and the matrices above. - -
    - -
    - - -Exact coefficient values are 1, 1/sqrt(2), sqrt(3)/2 and 1/2, multiplied by - 2/(2 + 2/sqrt(2) + sqrt(3)) for normalization. -The coefficients are in the same order as in , - and the matrices above. - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -The comment header consists of a 64-bit magic signature, followed by data in - the same format as the header used in Ogg - Vorbis, except (like Ogg Theora and Speex) the final "framing bit" specified - in the Vorbis spec is not present. - -Magic Signature: - -This is an 8-octet (64-bit) field that allows codec identification and is - human-readable. -It contains, in order, the magic numbers: - -0x4F 'O' -0x70 'p' -0x75 'u' -0x73 's' -0x54 'T' -0x61 'a' -0x67 'g' -0x73 's' - -Starting with "Op" helps distinguish it from audio data packets, as this is an - invalid TOC sequence. - - -Vendor String Length (32 bits, unsigned, little endian): - -This field gives the length of the following vendor string, in octets. -It MUST NOT indicate that the vendor string is longer than the rest of the - packet. - - -Vendor String (variable length, UTF-8 vector): - -This is a simple human-readable tag for vendor information, encoded as a UTF-8 - string . -No terminating null octet is necessary. - -This tag is intended to identify the codec encoder and encapsulation - implementations, for tracing differences in technical behavior. -User-facing applications can use the 'ENCODER' user comment tag to identify - themselves. - - -User Comment List Length (32 bits, unsigned, little endian): - -This field indicates the number of user-supplied comments. -It MAY indicate there are zero user-supplied comments, in which case there are - no additional fields in the packet. -It MUST NOT indicate that there are so many comments that the comment string - lengths would require more data than is available in the rest of the packet. - - -User Comment #i String Length (32 bits, unsigned, little endian): - -This field gives the length of the following user comment string, in octets. -There is one for each user comment indicated by the 'user comment list length' - field. -It MUST NOT indicate that the string is longer than the rest of the packet. - - -User Comment #i String (variable length, UTF-8 vector): - -This field contains a single user comment encoded as a UTF-8 - string . -There is one for each user comment indicated by the 'user comment list length' - field. - - - - - -The vendor string length and user comment list length are REQUIRED, and - implementations SHOULD treat a stream as invalid if it contains a comment - header that does not have enough data for these fields, or that does not - contain enough data for the corresponding vendor string or user comments they - describe. -Making this check before allocating the associated memory to contain the data - helps prevent a possible Denial-of-Service (DoS) attack from small comment - headers that claim to contain strings longer than the entire packet or more - user comments than than could possibly fit in the packet. - - - -Immediately following the user comment list, the comment header MAY - contain zero-padding or other binary data which is not specified here. -If the least-significant bit of the first byte of this data is 1, then editors - SHOULD preserve the contents of this data when updating the tags, but if this - bit is 0, all such data MAY be treated as padding, and truncated or discarded - as desired. -This allows informal experimentation with the format of this binary data until - it can be specified later. - - - -The comment header can be arbitrarily large and might be spread over a large - number of Ogg pages. -Implementations MUST avoid attempting to allocate excessive amounts of memory - when presented with a very large comment header. -To accomplish this, implementations MAY treat a stream as invalid if it has a - comment header larger than 125,829,120 octets (120 MB), and MAY - ignore individual comments that are not fully contained within the first - 61,440 octets of the comment header. - - -
    - -The user comment strings follow the NAME=value format described by - with the same recommended tag names: - ARTIST, TITLE, DATE, ALBUM, and so on. - - -Two new comment tags are introduced here: - - -First, an optional gain for track normalization: -
    - -
    - - representing the volume shift needed to normalize the track's volume - during isolated playback, in random shuffle, and so on. -The gain is a Q7.8 fixed point number in dB, as in the ID header's 'output - gain' field. -This tag is similar to the REPLAYGAIN_TRACK_GAIN tag in - Vorbis , except that the normal volume - reference is the standard. - -Second, an optional gain for album normalization: -
    - -
    - - representing the volume shift needed to normalize the overall volume when - played as part of a particular collection of tracks. -The gain is also a Q7.8 fixed point number in dB, as in the ID header's - 'output gain' field. -The values '-573' and '111' given here are just examples. - - -An Ogg Opus stream MUST NOT have more than one of each of these tags, and if - present their values MUST be an integer from -32768 to 32767, inclusive, - represented in ASCII as a base 10 number with no whitespace. -A leading '+' or '-' character is valid. -Leading zeros are also permitted, but the value MUST be represented by - no more than 6 characters. -Other non-digit characters MUST NOT be present. - - -If present, R128_TRACK_GAIN and R128_ALBUM_GAIN MUST correctly represent - the R128 normalization gain relative to the 'output gain' field specified - in the ID header. -If a player chooses to make use of the R128_TRACK_GAIN tag or the - R128_ALBUM_GAIN tag, it MUST apply those gains - in addition to the 'output gain' value. -If a tool modifies the ID header's 'output gain' field, it MUST also update or - remove the R128_TRACK_GAIN and R128_ALBUM_GAIN comment tags if present. -A muxer SHOULD place the gain it wants other tools to use by default into the - 'output gain' field, and not the comment tag. - - -To avoid confusion with multiple normalization schemes, an Opus comment header - SHOULD NOT contain any of the REPLAYGAIN_TRACK_GAIN, REPLAYGAIN_TRACK_PEAK, - REPLAYGAIN_ALBUM_GAIN, or REPLAYGAIN_ALBUM_PEAK tags, unless they are only - to be used in some context where there is guaranteed to be no such confusion. - normalization is preferred to the earlier - REPLAYGAIN schemes because of its clear definition and adoption by industry. -Peak normalizations are difficult to calculate reliably for lossy codecs - because of variation in excursion heights due to decoder differences. -In the authors' investigations they were not applied consistently or broadly - enough to merit inclusion here. - -
    -
    - -
    - -
    - -Technically, valid Opus packets can be arbitrarily large due to the padding - format, although the amount of non-padding data they can contain is bounded. -These packets might be spread over a similarly enormous number of Ogg pages. -When encoding, implementations SHOULD limit the use of padding in audio data - packets to no more than is necessary to make a variable bitrate (VBR) stream - constant bitrate (CBR), unless they have no reasonable way to determine what - is necessary. -Demuxers SHOULD treat audio data packets as invalid (treat them as if they were - malformed Opus packets with an invalid TOC sequence) if they are larger than - 61,440 octets per Opus stream, unless they have a specific reason for - allowing extra padding. -Such packets necessarily contain more padding than needed to make a stream CBR. -Demuxers MUST avoid attempting to allocate excessive amounts of memory when - presented with a very large packet. -Demuxers MAY treat audio data packets as invalid or partially process them if - they are larger than 61,440 octets in an Ogg Opus stream with channel - mapping families 0 or 1. -Demuxers MAY treat audio data packets as invalid or partially process them in - any Ogg Opus stream if the packet is larger than 61,440 octets and also - larger than 7,680 octets per Opus stream. -The presence of an extremely large packet in the stream could indicate a - memory exhaustion attack or stream corruption. - - -In an Ogg Opus stream, the largest possible valid packet that does not use - padding has a size of (61,298*N - 2) octets. -With 255 streams, this is 15,630,988 octets and can - span up to 61,298 Ogg pages, all but one of which will have a granule - position of -1. -This is of course a very extreme packet, consisting of 255 streams, each - containing 120 ms of audio encoded as 2.5 ms frames, each frame - using the maximum possible number of octets (1275) and stored in the least - efficient manner allowed (a VBR code 3 Opus packet). -Even in such a packet, most of the data will be zeros as 2.5 ms frames - cannot actually use all 1275 octets. - - -The largest packet consisting of entirely useful data is - (15,326*N - 2) octets. -This corresponds to 120 ms of audio encoded as 10 ms frames in either - SILK or Hybrid mode, but at a data rate of over 1 Mbps, which makes little - sense for the quality achieved. - - -A more reasonable limit is (7,664*N - 2) octets. -This corresponds to 120 ms of audio encoded as 20 ms stereo CELT mode - frames, with a total bitrate just under 511 kbps (not counting the Ogg - encapsulation overhead). -For channel mapping family 1, N=8 provides a reasonable upper bound, as it - allows for each of the 8 possible output channels to be decoded from a - separate stereo Opus stream. -This gives a size of 61,310 octets, which is rounded up to a multiple of - 1,024 octets to yield the audio data packet size of 61,440 octets - that any implementation is expected to be able to process successfully. - -
    - -
    - -When encoding Opus streams, Ogg muxers SHOULD take into account the - algorithmic delay of the Opus encoder. - - -In encoders derived from the reference - implementation , the number of samples can be - queried with: - -
    - -
    - -To achieve good quality in the very first samples of a stream, implementations - MAY use linear predictive coding (LPC) extrapolation to generate at least 120 - extra samples at the beginning to avoid the Opus encoder having to encode a - discontinuous signal. -For more information on linear prediction, see - . -For an input file containing 'length' samples, the implementation SHOULD set - the pre-skip header value to (delay_samples + extra_samples), encode - at least (length + delay_samples + extra_samples) - samples, and set the granule position of the last page to - (length + delay_samples + extra_samples). -This ensures that the encoded file has the same duration as the original, with - no time offset. The best way to pad the end of the stream is to also use LPC - extrapolation, but zero-padding is also acceptable. - - -
    - -The first step in LPC extrapolation is to compute linear prediction - coefficients. -When extending the end of the signal, order-N (typically with N ranging from 8 - to 40) LPC analysis is performed on a window near the end of the signal. -The last N samples are used as memory to an infinite impulse response (IIR) - filter. - - -The filter is then applied on a zero input to extrapolate the end of the signal. -Let a(k) be the kth LPC coefficient and x(n) be the nth sample of the signal, - each new sample past the end of the signal is computed as: - -
    - -
    - -The process is repeated independently for each channel. -It is possible to extend the beginning of the signal by applying the same - process backward in time. -When extending the beginning of the signal, it is best to apply a "fade in" to - the extrapolated signal, e.g. by multiplying it by a half-Hanning window - . - - -
    - -
    - -In some applications, such as Internet radio, it is desirable to cut a long - stream into smaller chains, e.g. so the comment header can be updated. -This can be done simply by separating the input streams into segments and - encoding each segment independently. -The drawback of this approach is that it creates a small discontinuity - at the boundary due to the lossy nature of Opus. -A muxer MAY avoid this discontinuity by using the following procedure: - -Encode the last frame of the first segment as an independent frame by - turning off all forms of inter-frame prediction. -De-emphasis is allowed. -Set the granule position of the last page to a point near the end of the - last frame. -Begin the second segment with a copy of the last frame of the first - segment. -Set the pre-skip value of the second stream in such a way as to properly - join the two streams. -Continue the encoding process normally from there, without any reset to - the encoder. - - - -In encoders derived from the reference implementation, inter-frame prediction - can be turned off by calling: - -
    - -
    - -For best results, this implementation requires that prediction be explicitly - enabled again before resuming normal encoding, even after a reset. - - -
    - -
    - -
    - -A brief summary of major implementations of this draft is available - at , - along with their status. - - -[Note to RFC Editor: please remove this entire section before - final publication per , along with - its references.] - -
    - -
    - -Implementations of the Opus codec need to take appropriate security - considerations into account, as outlined in . -This is just as much a problem for the container as it is for the codec itself. -Malicious payloads and/or input streams can be used to attack codec - implementations. -Implementations MUST NOT overrun their allocated memory nor consume excessive - resources when decoding payloads or processing input streams. -Although problems in encoding applications are typically rarer, this still - applies to a muxer, as vulnerabilities would allow an attacker to attack - transcoding gateways. - - - -Header parsing code contains the most likely area for potential overruns. -It is important for implementations to ensure their buffers contain enough - data for all of the required fields before attempting to read it (for example, - for all of the channel map data in the ID header). -Implementations would do well to validate the indices of the channel map, also, - to ensure they meet all of the restrictions outlined in - , in order to avoid attempting to read data - from channels that do not exist. - - - -To avoid excessive resource usage, we advise implementations to be especially - wary of streams that might cause them to process far more data than was - actually transmitted. -For example, a relatively small comment header may contain values for the - string lengths or user comment list length that imply that it is many - gigabytes in size. -Even computing the size of the required buffer could overflow a 32-bit integer, - and actually attempting to allocate such a buffer before verifying it would be - a reasonable size is a bad idea. -After reading the user comment list length, implementations might wish to - verify that the header contains at least the minimum amount of data for that - many comments (4 additional octets per comment, to indicate each has a - length of zero) before proceeding any further, again taking care to avoid - overflow in these calculations. -If allocating an array of pointers to point at these strings, the size of the - pointers may be larger than 4 octets, potentially requiring a separate - overflow check. - - - -Another bug in this class we have observed more than once involves the handling - of invalid data at the end of a stream. -Often, implementations will seek to the end of a stream to locate the last - timestamp in order to compute its total duration. -If they do not find a valid capture pattern and Ogg page from the desired - logical stream, they will back up and try again. -If care is not taken to avoid re-scanning data that was already scanned, this - search can quickly devolve into something with a complexity that is quadratic - in the amount of invalid data. - - - -In general when seeking, implementations will wish to be cautious about the - effects of invalid granule position values, and ensure all algorithms will - continue to make progress and eventually terminate, even if these are missing - or out-of-order. - - - -Like most other container formats, Ogg Opus streams SHOULD NOT be used with - insecure ciphers or cipher modes that are vulnerable to known-plaintext - attacks. -Elements such as the Ogg page capture pattern and the magic signatures in the - ID header and the comment header all have easily predictable values, in - addition to various elements of the codec data itself. - -
    - -
    - -An "Ogg Opus file" consists of one or more sequentially multiplexed segments, - each containing exactly one Ogg Opus stream. -The RECOMMENDED mime-type for Ogg Opus files is "audio/ogg". - - - -If more specificity is desired, one MAY indicate the presence of Opus streams - using the codecs parameter defined in and - , e.g., - -
    - -
    - - for an Ogg Opus file. - - - -The RECOMMENDED filename extension for Ogg Opus files is '.opus'. - - - -When Opus is concurrently multiplexed with other streams in an Ogg container, - one SHOULD use one of the "audio/ogg", "video/ogg", or "application/ogg" - mime-types, as defined in . -Such streams are not strictly "Ogg Opus files" as described above, - since they contain more than a single Opus stream per sequentially - multiplexed segment, e.g. video or multiple audio tracks. -In such cases the the '.opus' filename extension is NOT RECOMMENDED. - - - -In either case, this document updates - to add 'opus' as a codecs parameter value with char[8]: 'OpusHead' - as Codec Identifier. - -
    - -
    - -This document updates the IANA Media Types registry to add .opus - as a file extension for "audio/ogg", and to add itself as a reference - alongside for "audio/ogg", "video/ogg", and - "application/ogg" Media Types. - - -This document defines a new registry "Opus Channel Mapping Families" to - indicate how the semantic meanings of the channels in a multi-channel Opus - stream are described. -IANA is requested to create a new name space of "Opus Channel Mapping - Families". -This will be a new registry on the IANA Matrix, and not a subregistry of an - existing registry. -Modifications to this registry follow the "Specification Required" registration - policy as defined in . -Each registry entry consists of a Channel Mapping Family Number, which is - specified in decimal in the range 0 to 255, inclusive, and a Reference (or - list of references) -Each Reference must point to sufficient documentation to describe what - information is coded in the Opus identification header for this channel - mapping family, how a demuxer determines the Stream Count ('N') and Coupled - Stream Count ('M') from this information, and how it determines the proper - interpretation of each of the decoded channels. - - -This document defines three initial assignments for this registry. - - -ValueReference -0[RFCXXXX] -1[RFCXXXX] -255[RFCXXXX] - - -The designated expert will determine if the Reference points to a specification - that meets the requirements for permanence and ready availability laid out - in  and that it specifies the information - described above with sufficient clarity to allow interoperable - implementations. - -
    - -
    - -Thanks to Ben Campbell, Joel M. Halpern, Mark Harris, Greg Maxwell, - Christopher "Monty" Montgomery, Jean-Marc Valin, Stephan Wenger, and Mo Zanaty - for their valuable contributions to this document. -Additional thanks to Andrew D'Addesio, Greg Maxwell, and Vincent Penquerc'h for - their feedback based on early implementations. - -
    - -
    - -In , "RFCXXXX" is to be replaced with the RFC number - assigned to this draft. - -
    - -
    - - - &rfc2119; - &rfc3533; - &rfc3629; - &rfc5226; - &rfc5334; - &rfc6381; - &rfc6716; - - - - Loudness Recommendation EBU R128 - - EBU Technical Committee - - - - - - - -Ogg Vorbis I Format Specification: Comment Field and Header - Specification - - - - - - - - - - - &rfc4732; - &rfc6982; - &rfc7587; - - - - FLAC - Free Lossless Audio Codec Format Description - - - - - - - - Hann window - - Wikipedia - - - - - - - - Linear Predictive Coding - - Wikipedia - - - - - - - - Autocorrelation LPC coeff generation algorithm - (Vorbis source code) - - - - - - - - -Q (number format) -Wikipedia - - - - - - -VorbisComment: Replay Gain - - - - - - - - -Granulepos Encoding and How Seeking Really Works - - - - - - - - - -The Vorbis I Specification, Section 4.3.9 Output Channel Order - - - - - - - - The Vorbis I Specification, Appendix A: Embedding Vorbis - into an Ogg stream - - - - - - - - Multiple Channel Audio Data and WAVE Files - - Microsoft Corporation - - - - - - - - -
    diff --git a/Engine/lib/opus/doc/draft-ietf-codec-opus-update.xml b/Engine/lib/opus/doc/draft-ietf-codec-opus-update.xml deleted file mode 100644 index 3124e22c0..000000000 --- a/Engine/lib/opus/doc/draft-ietf-codec-opus-update.xml +++ /dev/null @@ -1,513 +0,0 @@ - - - - - - - - - - - - - - - Updates to the Opus Audio Codec - - -Mozilla Corporation -
    - -331 E. Evelyn Avenue -Mountain View -CA -94041 -USA - -+1 650 903-0800 -jmvalin@jmvalin.ca -
    -
    - - -vocTone -
    - - - - - - - - -koenvos74@gmail.com -
    -
    - - - - - - - This document addresses minor issues that were found in the specification - of the Opus audio codec in RFC 6716. It updates the normative decoder implementation - included in the appendix of RFC 6716. The changes fixes real and potential security-related - issues, as well minor quality-related issues. - -
    - - -
    - This document addresses minor issues that were discovered in the reference - implementation of the Opus codec. Unlike most IETF specifications, Opus is defined - in RFC 6716 in terms of a normative reference - decoder implementation rather than from the associated text description. - That RFC includes the reference decoder implementation as Appendix A. - That's why only issues affecting the decoder are - listed here. An up-to-date implementation of the Opus encoder can be found at - . - - Some of the changes in this document update normative behaviour in a way that requires - new test vectors. The English text of the specification is unaffected, only - the C implementation is. The updated specification remains fully compatible with - the original specification. - - - - Note: due to RFC formatting conventions, lines exceeding the column width - in the patch are split using a backslash character. The backslashes - at the end of a line and the white space at the beginning - of the following line are not part of the patch. A properly formatted patch - including all changes is available at - - and has a SHA-1 hash of 029e3aa88fc342c91e67a21e7bfbc9458661cd5f. - - -
    - -
    - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this - document are to be interpreted as described in RFC 2119. -
    - -
    - The reference implementation does not reinitialize the stereo state - during a mode switch. The old stereo memory can produce a brief impulse - (i.e. single sample) in the decoded audio. This can be fixed by changing - silk/dec_API.c at line 72: - -
    - - for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) { - ret = silk_init_decoder( &channel_state[ n ] ); - } -+ silk_memset(&((silk_decoder *)decState)->sStereo, 0, -+ sizeof(((silk_decoder *)decState)->sStereo)); -+ /* Not strictly needed, but it's cleaner that way */ -+ ((silk_decoder *)decState)->prev_decode_only_middle = 0; - - return ret; - } - -]]> -
    - - This change affects the normative output of the decoder, but the - amount of change is within the tolerance and too small to make the testvector check fail. - -
    - -
    - It was discovered that some invalid packets of very large size could trigger - an out-of-bounds read in the Opus packet parsing code responsible for padding. - This is due to an integer overflow if the signaled padding exceeds 2^31-1 bytes - (the actual packet may be smaller). The code can be fixed by decrementing the - (signed) len value, instead of incrementing a separate padding counter. - This is done by applying the following changes at line 596 of src/opus_decoder.c: - -
    - - /* Padding flag is bit 6 */ - if (ch&0x40) - { -- int padding=0; - int p; - do { - if (len<=0) - return OPUS_INVALID_PACKET; - p = *data++; - len--; -- padding += p==255 ? 254: p; -+ len -= p==255 ? 254: p; - } while (p==255); -- len -= padding; - } - -]]> -
    - This packet parsing issue is limited to reading memory up - to about 60 kB beyond the compressed buffer. This can only be triggered - by a compressed packet more than about 16 MB long, so it's not a problem - for RTP. In theory, it could crash a file - decoder (e.g. Opus in Ogg) if the memory just after the incoming packet - is out-of-range, but our attempts to trigger such a crash in a production - application built using an affected version of the Opus decoder failed. -
    - -
    - The SILK resampler had the following issues: - - The calls to memcpy() were using sizeof(opus_int32), but the type of the - local buffer was opus_int16. - Because the size was wrong, this potentially allowed the source - and destination regions of the memcpy() to overlap on the copy from "buf" to "buf". - We believe that nSamplesIn (number of input samples) is at least fs_in_khZ (sampling rate in kHz), - which is at least 8. - Since RESAMPLER_ORDER_FIR_12 is only 8, that should not be a problem once - the type size is fixed. - The size of the buffer used RESAMPLER_MAX_BATCH_SIZE_IN, but the - data stored in it was actually twice the input batch size - (nSamplesIn<<1). - - The code can be fixed by applying the following changes to line 78 of silk/resampler_private_IIR_FIR.c: - -
    - - ) - { - silk_resampler_state_struct *S = \ -(silk_resampler_state_struct *)SS; - opus_int32 nSamplesIn; - opus_int32 max_index_Q16, index_increment_Q16; -- opus_int16 buf[ RESAMPLER_MAX_BATCH_SIZE_IN + \ -RESAMPLER_ORDER_FIR_12 ]; -+ opus_int16 buf[ 2*RESAMPLER_MAX_BATCH_SIZE_IN + \ -RESAMPLER_ORDER_FIR_12 ]; - - /* Copy buffered samples to start of buffer */ -- silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \ -* sizeof( opus_int32 ) ); -+ silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \ -* sizeof( opus_int16 ) ); - - /* Iterate over blocks of frameSizeIn input samples */ - index_increment_Q16 = S->invRatio_Q16; - while( 1 ) { - nSamplesIn = silk_min( inLen, S->batchSize ); - - /* Upsample 2x */ - silk_resampler_private_up2_HQ( S->sIIR, &buf[ \ -RESAMPLER_ORDER_FIR_12 ], in, nSamplesIn ); - - max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 + 1 \ -); /* + 1 because 2x upsampling */ - out = silk_resampler_private_IIR_FIR_INTERPOL( out, \ -buf, max_index_Q16, index_increment_Q16 ); - in += nSamplesIn; - inLen -= nSamplesIn; - - if( inLen > 0 ) { - /* More iterations to do; copy last part of \ -filtered signal to beginning of buffer */ -- silk_memcpy( buf, &buf[ nSamplesIn << 1 ], \ -RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) ); -+ silk_memmove( buf, &buf[ nSamplesIn << 1 ], \ -RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); - } else { - break; - } - } - - /* Copy last part of filtered signal to the state for \ -the next call */ -- silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \ -RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) ); -+ silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \ -RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); - } - -]]> -
    -
    - -
    - - It was discovered through decoder fuzzing that some bitstreams could produce - integer values exceeding 32-bits in LPC_inverse_pred_gain_QA(), causing - a wrap-around. The C standard considers - this behavior as undefined. The following patch to line 87 of silk/LPC_inv_pred_gain.c - detects values that do not fit in a 32-bit integer and considers the corresponding filters unstable: - -
    - - /* Update AR coefficient */ - for( n = 0; n < k; n++ ) { -- tmp_QA = Aold_QA[ n ] - MUL32_FRAC_Q( \ -Aold_QA[ k - n - 1 ], rc_Q31, 31 ); -- Anew_QA[ n ] = MUL32_FRAC_Q( tmp_QA, rc_mult2 , mult2Q ); -+ opus_int64 tmp64; -+ tmp_QA = silk_SUB_SAT32( Aold_QA[ n ], MUL32_FRAC_Q( \ -Aold_QA[ k - n - 1 ], rc_Q31, 31 ) ); -+ tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( tmp_QA, \ -rc_mult2 ), mult2Q); -+ if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) { -+ return 0; -+ } -+ Anew_QA[ n ] = ( opus_int32 )tmp64; - } - -]]> -
    -
    - -
    - - It was discovered -- also from decoder fuzzing -- that an integer wrap-around could - occur when decoding bitstreams with extremely large values for the high LSF parameters. - The end result of the wrap-around is an illegal read access on the stack, which - the authors do not believe is exploitable but should nonetheless be fixed. The following - patch to line 137 of silk/NLSF_stabilize.c prevents the problem: - -
    - - /* Keep delta_min distance between the NLSFs */ - for( i = 1; i < L; i++ ) -- NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], \ -NLSF_Q15[i-1] + NDeltaMin_Q15[i] ); -+ NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], \ -silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) ); - - /* Last NLSF should be no higher than 1 - NDeltaMin[L] */ - -]]> -
    - -
    - -
    - On extreme bit-streams, it is possible for log-domain band energy levels - to exceed the maximum single-precision floating point value once converted - to a linear scale. This would later cause the decoded values to be NaN (not a number), - possibly causing problems in the software using the PCM values. This can be - avoided with the following patch to line 552 of celt/quant_bands.c: - -
    - - { - opus_val16 lg = ADD16(oldEBands[i+c*m->nbEBands], - SHL16((opus_val16)eMeans[i],6)); -+ lg = MIN32(QCONST32(32.f, 16), lg); - eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(lg),4); - } - for (;inbEBands;i++) - -]]> -
    -
    - -
    - When encoding in hybrid mode at low bitrate, we sometimes only have - enough bits to code a single CELT band (8 - 9.6 kHz). When that happens, - the second band (CELT band 18, from 9.6 to 12 kHz) cannot use folding - because it is wider than the amount already coded, and falls back to - white noise. Because it can also happen on transients (e.g. stops), it - can cause audible pre-echo. - - - To address the issue, we change the folding behavior so that it is - never forced to fall back to LCG due to the first band not containing - enough coefficients to fold onto the second band. This - is achieved by simply repeating part of the first band in the folding - of the second band. This changes the code in celt/bands.c around line 1237: - -
    - - b = 0; - } - -- if (resynth && M*eBands[i]-N >= M*eBands[start] && \ -(update_lowband || lowband_offset==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) -+ { -+ int n1, n2; -+ int offset; -+ n1 = M*(eBands[start+1]-eBands[start]); -+ n2 = M*(eBands[start+2]-eBands[start+1]); -+ offset = M*eBands[start]; -+ /* 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[offset+n1], &norm[offset+2*n1 - n2], n2-n1); -+ if (C==2) -+ OPUS_COPY(&norm2[offset+n1], &norm2[offset+2*n1 - n2], \ -n2-n1); -+ } -+ - tf_change = tf_res[i]; - if (i>=m->effEBands) - { - -]]> -
    - - - as well as line 1260: - - -
    - - fold_start = lowband_offset; - while(M*eBands[--fold_start] > effective_lowband); - fold_end = lowband_offset-1; -- while(M*eBands[++fold_end] < effective_lowband+N); -+ while(++fold_end < i && M*eBands[fold_end] < \ -effective_lowband+N); - x_cm = y_cm = 0; - fold_i = fold_start; do { - x_cm |= collapse_masks[fold_i*C+0]; - - -]]> -
    - - The fix does not impact compatibility, because the improvement does - not depend on the encoder doing anything special. There is also no - reasonable way for an encoder to use the original behavior to - improve quality over the proposed change. - -
    - -
    - The last issue is not strictly a bug, but it is an issue that has been reported - when downmixing an Opus decoded stream to mono, whether this is done inside the decoder - or as a post-processing step on the stereo decoder output. Opus intensity stereo allows - optionally coding the two channels 180-degrees out of phase on a per-band basis. - This provides better stereo quality than forcing the two channels to be in phase, - but when the output is downmixed to mono, the energy in the affected bands is cancelled - sometimes resulting in audible artifacts. - - As a work-around for this issue, the decoder MAY choose not to apply the 180-degree - phase shift. This can be useful when downmixing to mono inside or - outside of the decoder (e.g. user-controllable). - -
    - - -
    - Changes in and have - sufficient impact on the testvectors to make them fail. For this reason, - this document also updates the Opus test vectors. The new test vectors now - include two decoded outputs for the same bitstream. The outputs with - suffix 'm' do not apply the CELT 180-degree phase shift as allowed in - , while the outputs without the suffix do. An - implementation is compliant as long as it passes either set of vectors. - - - Any Opus implementation - that passes either the original test vectors from RFC 6716 - or one of the new sets of test vectors is compliant with the Opus specification. However, newer implementations - SHOULD be based on the new test vectors rather than the old ones. - - The new test vectors are located at - . - The SHA-1 hashes of the test vectors are: -
    - - - -
    - Note that the decoder input bitstream files (.bit) are unchanged. -
    -
    - -
    - This document fixes two security issues reported on Opus and that affect the - reference implementation in RFC 6716: CVE-2013-0899 - - and CVE-2017-0381 . - CVE- 2013-0899 theoretically could have caused an information leak. The leaked - information would have gone through the decoder process before being accessible - to the attacker. It is fixed by . - CVE-2017-0381 could have resulted in a 16-bit out-of-bounds read from a fixed - location. It is fixed in . - Beyond the two fixed CVEs, this document adds no new security considerations on top of - RFC 6716. - -
    - -
    - This document makes no request of IANA. - - Note to RFC Editor: this section may be removed on publication as an - RFC. -
    - -
    - We would like to thank Juri Aedla for reporting the issue with the parsing of - the Opus padding. Thanks to Felicia Lim for reporting the LSF integer overflow issue. - Also, thanks to Tina le Grand, Jonathan Lennox, and Mark Harris for their - feedback on this document. -
    -
    - - - - - - - - - -
    diff --git a/Engine/lib/opus/doc/draft-ietf-codec-opus.xml b/Engine/lib/opus/doc/draft-ietf-codec-opus.xml deleted file mode 100644 index 334cad97a..000000000 --- a/Engine/lib/opus/doc/draft-ietf-codec-opus.xml +++ /dev/null @@ -1,8276 +0,0 @@ - - - - - - - -Definition of the Opus Audio Codec - - - -Mozilla Corporation -
    - -650 Castro Street -Mountain View -CA -94041 -USA - -+1 650 903-0800 -jmvalin@jmvalin.ca -
    -
    - - -Skype Technologies S.A. -
    - -Soder Malarstrand 43 -Stockholm - -11825 -SE - -+46 73 085 7619 -koen.vos@skype.net -
    -
    - - -Mozilla Corporation -
    - -650 Castro Street -Mountain View -CA -94041 -USA - -+1 650 903-0800 -tterriberry@mozilla.com -
    -
    - - - -General - - - - - -This document defines the Opus interactive speech and audio codec. -Opus is designed to handle a wide range of interactive audio applications, - including Voice over IP, videoconferencing, in-game chat, and even live, - distributed music performances. -It scales from low bitrate narrowband speech at 6 kb/s to very high quality - stereo music at 510 kb/s. -Opus uses both linear prediction (LP) and the Modified Discrete Cosine - Transform (MDCT) to achieve good compression of both speech and music. - - -
    - - - -
    - -The Opus codec is a real-time interactive audio codec designed to meet the requirements -described in . -It is composed of a linear - prediction (LP)-based layer and a Modified Discrete Cosine Transform - (MDCT)-based layer. -The main idea behind using two layers is that in speech, linear prediction - techniques (such as Code-Excited Linear Prediction, or CELP) code low frequencies more efficiently than transform - (e.g., MDCT) domain techniques, while the situation is reversed for music and - higher speech frequencies. -Thus a codec with both layers available can operate over a wider range than - either one alone and, by combining them, achieve better quality than either - one individually. - - - -The primary normative part of this specification is provided by the source code - in . -Only the decoder portion of this software is normative, though a - significant amount of code is shared by both the encoder and decoder. - provides a decoder conformance test. -The decoder contains a great deal of integer and fixed-point arithmetic which - needs to be performed exactly, including all rounding considerations, so any - useful specification requires domain-specific symbolic language to adequately - define these operations. -Additionally, any -conflict between the symbolic representation and the included reference -implementation must be resolved. For the practical reasons of compatibility and -testability it would be advantageous to give the reference implementation -priority in any disagreement. The C language is also one of the most -widely understood human-readable symbolic representations for machine -behavior. -For these reasons this RFC uses the reference implementation as the sole - symbolic representation of the codec. - - -While the symbolic representation is unambiguous and complete it is not -always the easiest way to understand the codec's operation. For this reason -this document also describes significant parts of the codec in English and -takes the opportunity to explain the rationale behind many of the more -surprising elements of the design. These descriptions are intended to be -accurate and informative, but the limitations of common English sometimes -result in ambiguity, so it is expected that the reader will always read -them alongside the symbolic representation. Numerous references to the -implementation are provided for this purpose. The descriptions sometimes -differ from the reference in ordering or through mathematical simplification -wherever such deviation makes an explanation easier to understand. -For example, the right shift and left shift operations in the reference -implementation are often described using division and multiplication in the text. -In general, the text is focused on the "what" and "why" while the symbolic -representation most clearly provides the "how". - - -
    - -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", - "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be - interpreted as described in RFC 2119 . - - -Various operations in the codec require bit-exact fixed-point behavior, even - when writing a floating point implementation. -The notation "Q<n>", where n is an integer, denotes the number of binary - digits to the right of the decimal point in a fixed-point number. -For example, a signed Q14 value in a 16-bit word can represent values from - -2.0 to 1.99993896484375, inclusive. -This notation is for informational purposes only. -Arithmetic, when described, always operates on the underlying integer. -E.g., the text will explicitly indicate any shifts required after a - multiplication. - - -Expressions, where included in the text, follow C operator rules and - precedence, with the exception that the syntax "x**y" indicates x raised to - the power y. -The text also makes use of the following functions: - - -
    - -The smallest of two values x and y. - -
    - -
    - -The largest of two values x and y. - -
    - -
    -
    - -
    - -With this definition, if lo > hi, the lower bound is the one that - is enforced. - -
    - -
    - -The sign of x, i.e., -
    - 0 . -]]> -
    -
    -
    - -
    - -The absolute value of x, i.e., -
    - -
    -
    -
    - -
    - -The largest integer z such that z <= f. - -
    - -
    - -The smallest integer z such that z >= f. - -
    - -
    - -The integer z nearest to f, with ties rounded towards negative infinity, - i.e., -
    - -
    -
    -
    - -
    - -The base-two logarithm of f. - -
    - -
    - -The minimum number of bits required to store a positive integer n in two's - complement notation, or 0 for a non-positive integer n. -
    - 0 -]]> -
    -Examples: - -ilog(-1) = 0 -ilog(0) = 0 -ilog(1) = 1 -ilog(2) = 2 -ilog(3) = 2 -ilog(4) = 3 -ilog(7) = 3 - -
    -
    - -
    - -
    - -
    - - -The Opus codec scales from 6 kb/s narrowband mono speech to 510 kb/s - fullband stereo music, with algorithmic delays ranging from 5 ms to - 65.2 ms. -At any given time, either the LP layer, the MDCT layer, or both, may be active. -It can seamlessly switch between all of its various operating modes, giving it - a great deal of flexibility to adapt to varying content and network - conditions without renegotiating the current session. -The codec allows input and output of various audio bandwidths, defined as - follows: - - -Abbreviation -Audio Bandwidth -Sample Rate (Effective) -NB (narrowband) 4 kHz 8 kHz -MB (medium-band) 6 kHz 12 kHz -WB (wideband) 8 kHz 16 kHz -SWB (super-wideband) 12 kHz 24 kHz -FB (fullband) 20 kHz (*) 48 kHz - - -(*) Although the sampling theorem allows a bandwidth as large as half the - sampling rate, Opus never codes audio above 20 kHz, as that is the - generally accepted upper limit of human hearing. - - - -Opus defines super-wideband (SWB) with an effective sample rate of 24 kHz, - unlike some other audio coding standards that use 32 kHz. -This was chosen for a number of reasons. -The band layout in the MDCT layer naturally allows skipping coefficients for - frequencies over 12 kHz, but does not allow cleanly dropping just those - frequencies over 16 kHz. -A sample rate of 24 kHz also makes resampling in the MDCT layer easier, - as 24 evenly divides 48, and when 24 kHz is sufficient, it can save - computation in other processing, such as Acoustic Echo Cancellation (AEC). -Experimental changes to the band layout to allow a 16 kHz cutoff - (32 kHz effective sample rate) showed potential quality degradations at - other sample rates, and at typical bitrates the number of bits saved by using - such a cutoff instead of coding in fullband (FB) mode is very small. -Therefore, if an application wishes to process a signal sampled at 32 kHz, - it should just use FB. - - - -The LP layer is based on the SILK codec - . -It supports NB, MB, or WB audio and frame sizes from 10 ms to 60 ms, - and requires an additional 5 ms look-ahead for noise shaping estimation. -A small additional delay (up to 1.5 ms) may be required for sampling rate - conversion. -Like Vorbis and many other modern codecs, SILK is inherently designed for - variable-bitrate (VBR) coding, though the encoder can also produce - constant-bitrate (CBR) streams. -The version of SILK used in Opus is substantially modified from, and not - compatible with, the stand-alone SILK codec previously deployed by Skype. -This document does not serve to define that format, but those interested in the - original SILK codec should see instead. - - - -The MDCT layer is based on the CELT codec . -It supports NB, WB, SWB, or FB audio and frame sizes from 2.5 ms to - 20 ms, and requires an additional 2.5 ms look-ahead due to the - overlapping MDCT windows. -The CELT codec is inherently designed for CBR coding, but unlike many CBR - codecs it is not limited to a set of predetermined rates. -It internally allocates bits to exactly fill any given target budget, and an - encoder can produce a VBR stream by varying the target on a per-frame basis. -The MDCT layer is not used for speech when the audio bandwidth is WB or less, - as it is not useful there. -On the other hand, non-speech signals are not always adequately coded using - linear prediction, so for music only the MDCT layer should be used. - - - -A "Hybrid" mode allows the use of both layers simultaneously with a frame size - of 10 or 20 ms and a SWB or FB audio bandwidth. -The LP layer codes the low frequencies by resampling the signal down to WB. -The MDCT layer follows, coding the high frequency portion of the signal. -The cutoff between the two lies at 8 kHz, the maximum WB audio bandwidth. -In the MDCT layer, all bands below 8 kHz are discarded, so there is no - coding redundancy between the two layers. - - - -The sample rate (in contrast to the actual audio bandwidth) can be chosen - independently on the encoder and decoder side, e.g., a fullband signal can be - decoded as wideband, or vice versa. -This approach ensures a sender and receiver can always interoperate, regardless - of the capabilities of their actual audio hardware. -Internally, the LP layer always operates at a sample rate of twice the audio - bandwidth, up to a maximum of 16 kHz, which it continues to use for SWB - and FB. -The decoder simply resamples its output to support different sample rates. -The MDCT layer always operates internally at a sample rate of 48 kHz. -Since all the supported sample rates evenly divide this rate, and since the - the decoder may easily zero out the high frequency portion of the spectrum in - the frequency domain, it can simply decimate the MDCT layer output to achieve - the other supported sample rates very cheaply. - - - -After conversion to the common, desired output sample rate, the decoder simply - adds the output from the two layers together. -To compensate for the different look-ahead required by each layer, the CELT - encoder input is delayed by an additional 2.7 ms. -This ensures that low frequencies and high frequencies arrive at the same time. -This extra delay may be reduced by an encoder by using less look-ahead for noise - shaping or using a simpler resampler in the LP layer, but this will reduce - quality. -However, the base 2.5 ms look-ahead in the CELT layer cannot be reduced in - the encoder because it is needed for the MDCT overlap, whose size is fixed by - the decoder. - - - -Both layers use the same entropy coder, avoiding any waste from "padding bits" - between them. -The hybrid approach makes it easy to support both CBR and VBR coding. -Although the LP layer is VBR, the bit allocation of the MDCT layer can produce - a final stream that is CBR by using all the bits left unused by the LP layer. - - -
    - -The Opus codec includes a number of control parameters which can be changed dynamically during -regular operation of the codec, without interrupting the audio stream from the encoder to the decoder. -These parameters only affect the encoder since any impact they have on the bit-stream is signaled -in-band such that a decoder can decode any Opus stream without any out-of-band signaling. Any Opus -implementation can add or modify these control parameters without affecting interoperability. The most -important encoder control parameters in the reference encoder are listed below. - - -
    - -Opus supports all bitrates from 6 kb/s to 510 kb/s. All other parameters being -equal, higher bitrate results in higher quality. For a frame size of 20 ms, these -are the bitrate "sweet spots" for Opus in various configurations: - -8-12 kb/s for NB speech, -16-20 kb/s for WB speech, -28-40 kb/s for FB speech, -48-64 kb/s for FB mono music, and -64-128 kb/s for FB stereo music. - - -
    - -
    - -Opus can transmit either mono or stereo frames within a single stream. -When decoding a mono frame in a stereo decoder, the left and right channels are - identical, and when decoding a stereo frame in a mono decoder, the mono output - is the average of the left and right channels. -In some cases, it is desirable to encode a stereo input stream in mono (e.g., - because the bitrate is too low to encode stereo with sufficient quality). -The number of channels encoded can be selected in real-time, but by default the - reference encoder attempts to make the best decision possible given the - current bitrate. - -
    - -
    - -The audio bandwidths supported by Opus are listed in - . -Just like for the number of channels, any decoder can decode audio encoded at - any bandwidth. -For example, any Opus decoder operating at 8 kHz can decode a FB Opus - frame, and any Opus decoder operating at 48 kHz can decode a NB frame. -Similarly, the reference encoder can take a 48 kHz input signal and - encode it as NB. -The higher the audio bandwidth, the higher the required bitrate to achieve - acceptable quality. -The audio bandwidth can be explicitly specified in real-time, but by default - the reference encoder attempts to make the best bandwidth decision possible - given the current bitrate. - -
    - - -
    - -Opus can encode frames of 2.5, 5, 10, 20, 40 or 60 ms. -It can also combine multiple frames into packets of up to 120 ms. -For real-time applications, sending fewer packets per second reduces the - bitrate, since it reduces the overhead from IP, UDP, and RTP headers. -However, it increases latency and sensitivity to packet losses, as losing one - packet constitutes a loss of a bigger chunk of audio. -Increasing the frame duration also slightly improves coding efficiency, but the - gain becomes small for frame sizes above 20 ms. -For this reason, 20 ms frames are a good choice for most applications. - -
    - -
    - -There are various aspects of the Opus encoding process where trade-offs -can be made between CPU complexity and quality/bitrate. In the reference -encoder, the complexity is selected using an integer from 0 to 10, where -0 is the lowest complexity and 10 is the highest. Examples of -computations for which such trade-offs may occur are: - -The order of the pitch analysis whitening filter , -The order of the short-term noise shaping filter, -The number of states in delayed decision quantization of the -residual signal, and -The use of certain bit-stream features such as variable time-frequency -resolution and the pitch post-filter. - - -
    - -
    - -Audio codecs often exploit inter-frame correlations to reduce the -bitrate at a cost in error propagation: after losing one packet -several packets need to be received before the decoder is able to -accurately reconstruct the speech signal. The extent to which Opus -exploits inter-frame dependencies can be adjusted on the fly to -choose a trade-off between bitrate and amount of error propagation. - -
    - -
    - - Another mechanism providing robustness against packet loss is the in-band - Forward Error Correction (FEC). Packets that are determined to - contain perceptually important speech information, such as onsets or - transients, are encoded again at a lower bitrate and this re-encoded - information is added to a subsequent packet. - -
    - -
    - -Opus is more efficient when operating with variable bitrate (VBR), which is -the default. However, in some (rare) applications, constant bitrate (CBR) -is required. There are two main reasons to operate in CBR mode: - -When the transport only supports a fixed size for each compressed frame -When encryption is used for an audio stream that is either highly constrained - (e.g. yes/no, recorded prompts) or highly sensitive - - -When low-latency transmission is required over a relatively slow connection, then -constrained VBR can also be used. This uses VBR in a way that simulates a -"bit reservoir" and is equivalent to what MP3 (MPEG 1, Layer 3) and -AAC (Advanced Audio Coding) call CBR (i.e., not true -CBR due to the bit reservoir). - -
    - -
    - - Discontinuous Transmission (DTX) reduces the bitrate during silence - or background noise. When DTX is enabled, only one frame is encoded - every 400 milliseconds. - -
    - -
    - -
    - -
    - - -The Opus encoder produces "packets", which are each a contiguous set of bytes - meant to be transmitted as a single unit. -The packets described here do not include such things as IP, UDP, or RTP - headers which are normally found in a transport-layer packet. -A single packet may contain multiple audio frames, so long as they share a - common set of parameters, including the operating mode, audio bandwidth, frame - size, and channel count (mono vs. stereo). -This section describes the possible combinations of these parameters and the - internal framing used to pack multiple frames into a single packet. -This framing is not self-delimiting. -Instead, it assumes that a higher layer (such as UDP or RTP -or Ogg or Matroska ) - will communicate the length, in bytes, of the packet, and it uses this - information to reduce the framing overhead in the packet itself. -A decoder implementation MUST support the framing described in this section. -An alternative, self-delimiting variant of the framing is described in - . -Support for that variant is OPTIONAL. - - - -All bit diagrams in this document number the bits so that bit 0 is the most - significant bit of the first byte, and bit 7 is the least significant. -Bit 8 is thus the most significant bit of the second byte, etc. -Well-formed Opus packets obey certain requirements, marked [R1] through [R7] - below. -These are summarized in along with - appropriate means of handling malformed packets. - - -
    - -A well-formed Opus packet MUST contain at least one byte [R1]. -This byte forms a table-of-contents (TOC) header that signals which of the - various modes and configurations a given packet uses. -It is composed of a configuration number, "config", a stereo flag, "s", and a - frame count code, "c", arranged as illustrated in - . -A description of each of these fields follows. - - -
    - -
    - - -The top five bits of the TOC byte, labeled "config", encode one of 32 possible - configurations of operating mode, audio bandwidth, and frame size. -As described, the LP (SILK) layer and MDCT (CELT) layer can be combined in three possible - operating modes: - -A SILK-only mode for use in low bitrate connections with an audio bandwidth - of WB or less, -A Hybrid (SILK+CELT) mode for SWB or FB speech at medium bitrates, and -A CELT-only mode for very low delay speech transmission as well as music - transmission (NB to FB). - -The 32 possible configurations each identify which one of these operating modes - the packet uses, as well as the audio bandwidth and the frame size. - lists the parameters for each configuration. - - -Configuration Number(s) -Mode -Bandwidth -Frame Sizes -0...3 SILK-only NB 10, 20, 40, 60 ms -4...7 SILK-only MB 10, 20, 40, 60 ms -8...11 SILK-only WB 10, 20, 40, 60 ms -12...13 Hybrid SWB 10, 20 ms -14...15 Hybrid FB 10, 20 ms -16...19 CELT-only NB 2.5, 5, 10, 20 ms -20...23 CELT-only WB 2.5, 5, 10, 20 ms -24...27 CELT-only SWB 2.5, 5, 10, 20 ms -28...31 CELT-only FB 2.5, 5, 10, 20 ms - - -The configuration numbers in each range (e.g., 0...3 for NB SILK-only) - correspond to the various choices of frame size, in the same order. -For example, configuration 0 has a 10 ms frame size and configuration 3 - has a 60 ms frame size. - - - -One additional bit, labeled "s", signals mono vs. stereo, with 0 indicating - mono and 1 indicating stereo. - - - -The remaining two bits of the TOC byte, labeled "c", code the number of frames - per packet (codes 0 to 3) as follows: - -0: 1 frame in the packet -1: 2 frames in the packet, each with equal compressed size -2: 2 frames in the packet, with different compressed sizes -3: an arbitrary number of frames in the packet - -This draft refers to a packet as a code 0 packet, code 1 packet, etc., based on - the value of "c". - - -
    - -
    - - -This section describes how frames are packed according to each possible value - of "c" in the TOC byte. - - -
    - -When a packet contains multiple VBR frames (i.e., code 2 or 3), the compressed - length of one or more of these frames is indicated with a one- or two-byte - sequence, with the meaning of the first byte as follows: - -0: No frame (discontinuous transmission (DTX) or lost packet) -1...251: Length of the frame in bytes -252...255: A second byte is needed. The total length is (second_byte*4)+first_byte - - - - -The special length 0 indicates that no frame is available, either because it - was dropped during transmission by some intermediary or because the encoder - chose not to transmit it. -Any Opus frame in any mode MAY have a length of 0. - - - -The maximum representable length is 255*4+255=1275 bytes. -For 20 ms frames, this represents a bitrate of 510 kb/s, which is - approximately the highest useful rate for lossily compressed fullband stereo - music. -Beyond this point, lossless codecs are more appropriate. -It is also roughly the maximum useful rate of the MDCT layer, as shortly - thereafter quality no longer improves with additional bits due to limitations - on the codebook sizes. - - - -No length is transmitted for the last frame in a VBR packet, or for any of the - frames in a CBR packet, as it can be inferred from the total size of the - packet and the size of all other data in the packet. -However, the length of any individual frame MUST NOT exceed - 1275 bytes [R2], to allow for repacketization by gateways, - conference bridges, or other software. - -
    - -
    - - -For code 0 packets, the TOC byte is immediately followed by N-1 bytes - of compressed data for a single frame (where N is the size of the packet), - as illustrated in . - -
    - -
    -
    - -
    - -For code 1 packets, the TOC byte is immediately followed by the - (N-1)/2 bytes of compressed data for the first frame, followed by - (N-1)/2 bytes of compressed data for the second frame, as illustrated in - . -The number of payload bytes available for compressed data, N-1, MUST be even - for all code 1 packets [R3]. - -
    - -
    -
    - -
    - -For code 2 packets, the TOC byte is followed by a one- or two-byte sequence - indicating the length of the first frame (marked N1 in ), - followed by N1 bytes of compressed data for the first frame. -The remaining N-N1-2 or N-N1-3 bytes are the compressed data for the - second frame. -This is illustrated in . -A code 2 packet MUST contain enough bytes to represent a valid length. -For example, a 1-byte code 2 packet is always invalid, and a 2-byte code 2 - packet whose second byte is in the range 252...255 is also invalid. -The length of the first frame, N1, MUST also be no larger than the size of the - payload remaining after decoding that length for all code 2 packets [R4]. -This makes, for example, a 2-byte code 2 packet with a second byte in the range - 1...251 invalid as well (the only valid 2-byte code 2 packet is one where the - length of both frames is zero). - -
    - -
    -
    - -
    - -Code 3 packets signal the number of frames, as well as additional - padding, called "Opus padding" to indicate that this padding is added at the - Opus layer, rather than at the transport layer. -Code 3 packets MUST have at least 2 bytes [R6,R7]. -The TOC byte is followed by a byte encoding the number of frames in the packet - in bits 2 to 7 (marked "M" in ), with bit 1 indicating whether - or not Opus padding is inserted (marked "p" in ), and bit 0 - indicating VBR (marked "v" in ). -M MUST NOT be zero, and the audio duration contained within a packet MUST NOT - exceed 120 ms [R5]. -This limits the maximum frame count for any frame size to 48 (for 2.5 ms - frames), with lower limits for longer frame sizes. - illustrates the layout of the frame count - byte. - -
    - -
    - -When Opus padding is used, the number of bytes of padding is encoded in the - bytes following the frame count byte. -Values from 0...254 indicate that 0...254 bytes of padding are included, - in addition to the byte(s) used to indicate the size of the padding. -If the value is 255, then the size of the additional padding is 254 bytes, - plus the padding value encoded in the next byte. -There MUST be at least one more byte in the packet in this case [R6,R7]. -The additional padding bytes appear at the end of the packet, and MUST be set - to zero by the encoder to avoid creating a covert channel. -The decoder MUST accept any value for the padding bytes, however. - - -Although this encoding provides multiple ways to indicate a given number of - padding bytes, each uses a different number of bytes to indicate the padding - size, and thus will increase the total packet size by a different amount. -For example, to add 255 bytes to a packet, set the padding bit, p, to 1, insert - a single byte after the frame count byte with a value of 254, and append 254 - padding bytes with the value zero to the end of the packet. -To add 256 bytes to a packet, set the padding bit to 1, insert two bytes after - the frame count byte with the values 255 and 0, respectively, and append 254 - padding bytes with the value zero to the end of the packet. -By using the value 255 multiple times, it is possible to create a packet of any - specific, desired size. -Let P be the number of header bytes used to indicate the padding size plus the - number of padding bytes themselves (i.e., P is the total number of bytes added - to the packet). -Then P MUST be no more than N-2 [R6,R7]. - - -In the CBR case, let R=N-2-P be the number of bytes remaining in the packet - after subtracting the (optional) padding. -Then the compressed length of each frame in bytes is equal to R/M. -The value R MUST be a non-negative integer multiple of M [R6]. -The compressed data for all M frames follows, each of size - R/M bytes, as illustrated in . - - -
    - -
    - - -In the VBR case, the (optional) padding length is followed by M-1 frame - lengths (indicated by "N1" to "N[M-1]" in ), each encoded in a - one- or two-byte sequence as described above. -The packet MUST contain enough data for the M-1 lengths after removing the - (optional) padding, and the sum of these lengths MUST be no larger than the - number of bytes remaining in the packet after decoding them [R7]. -The compressed data for all M frames follows, each frame consisting of the - indicated number of bytes, with the final frame consuming any remaining bytes - before the final padding, as illustrated in . -The number of header bytes (TOC byte, frame count byte, padding length bytes, - and frame length bytes), plus the signaled length of the first M-1 frames themselves, - plus the signaled length of the padding MUST be no larger than N, the total size of the - packet. - - -
    - -
    -
    -
    - -
    - -Simplest case, one NB mono 20 ms SILK frame: - - -
    - -
    - - -Two FB mono 5 ms CELT frames of the same compressed size: - - -
    - -
    - - -Two FB mono 20 ms Hybrid frames of different compressed size: - - -
    - -
    - - -Four FB stereo 20 ms CELT frames of the same compressed size: - - -
    - -
    -
    - -
    - -A receiver MUST NOT process packets which violate any of the rules above as - normal Opus packets. -They are reserved for future applications, such as in-band headers (containing - metadata, etc.). -Packets which violate these constraints may cause implementations of - this specification to treat them as malformed, and - discard them. - - -These constraints are summarized here for reference: - -Packets are at least one byte. -No implicit frame length is larger than 1275 bytes. -Code 1 packets have an odd total length, N, so that (N-1)/2 is an - integer. -Code 2 packets have enough bytes after the TOC for a valid frame - length, and that length is no larger than the number of bytes remaining in the - packet. -Code 3 packets contain at least one frame, but no more than 120 ms - of audio total. -The length of a CBR code 3 packet, N, is at least two bytes, the number of - bytes added to indicate the padding size plus the trailing padding bytes - themselves, P, is no more than N-2, and the frame count, M, satisfies - the constraint that (N-2-P) is a non-negative integer multiple of M. -VBR code 3 packets are large enough to contain all the header bytes (TOC - byte, frame count byte, any padding length bytes, and any frame length bytes), - plus the length of the first M-1 frames, plus any trailing padding bytes. - - -
    - -
    - -
    - -The Opus decoder consists of two main blocks: the SILK decoder and the CELT - decoder. -At any given time, one or both of the SILK and CELT decoders may be active. -The output of the Opus decode is the sum of the outputs from the SILK and CELT - decoders with proper sample rate conversion and delay compensation on the SILK - side, and optional decimation (when decoding to sample rates less than - 48 kHz) on the CELT side, as illustrated in the block diagram below. - -
    - -| Decoder |--->| Rate |----+ -Bit- +---------+ | | | | Conversion | v -stream | Range |---+ +---------+ +------------+ /---\ Audio -------->| Decoder | | + |------> - | |---+ +---------+ +------------+ \---/ - +---------+ | | CELT | | Decimation | ^ - +->| Decoder |--->| (Optional) |----+ - | | | | - +---------+ +------------+ -]]> - -
    - -
    - -Opus uses an entropy coder based on range coding -, -which is itself a rediscovery of the FIFO arithmetic code introduced by . -It is very similar to arithmetic encoding, except that encoding is done with -digits in any base instead of with bits, -so it is faster when using larger bases (i.e., a byte). All of the -calculations in the range coder must use bit-exact integer arithmetic. - - -Symbols may also be coded as "raw bits" packed directly into the bitstream, - bypassing the range coder. -These are packed backwards starting at the end of the frame, as illustrated in - . -This reduces complexity and makes the stream more resilient to bit errors, as - corruption in the raw bits will not desynchronize the decoding process, unlike - corruption in the input to the range decoder. -Raw bits are only used in the CELT layer. - - -
    - : -+ + -: : -+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -: | <- Boundary occurs at an arbitrary bit position : -+-+-+-+ + -: <- Raw bits data (packed LSB to MSB) | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -]]> -
    - - -Each symbol coded by the range coder is drawn from a finite alphabet and coded - in a separate "context", which describes the size of the alphabet and the - relative frequency of each symbol in that alphabet. - - -Suppose there is a context with n symbols, identified with an index that ranges - from 0 to n-1. -The parameters needed to encode or decode symbol k in this context are - represented by a three-tuple (fl[k], fh[k], ft), with - 0 <= fl[k] < fh[k] <= ft <= 65535. -The values of this tuple are derived from the probability model for the - symbol, represented by traditional "frequency counts". -Because Opus uses static contexts these are not updated as symbols are decoded. -Let f[i] be the frequency of symbol i. -Then the three-tuple corresponding to symbol k is given by - -
    - -
    - -The range decoder extracts the symbols and integers encoded using the range - encoder in . -The range decoder maintains an internal state vector composed of the two-tuple - (val, rng), representing the difference between the high end of the - current range and the actual coded value, minus one, and the size of the - current range, respectively. -Both val and rng are 32-bit unsigned integer values. - - -
    - -Let b0 be the first input byte (or zero if there are no bytes in this Opus - frame). -The decoder initializes rng to 128 and initializes val to - (127 - (b0>>1)), where (b0>>1) is the top 7 bits of the - first input byte. -It saves the remaining bit, (b0&1), for use in the renormalization - procedure described in , which the - decoder invokes immediately after initialization to read additional bits and - establish the invariant that rng > 2**23. - -
    - -
    - -Decoding a symbol is a two-step process. -The first step determines a 16-bit unsigned value fs, which lies within the - range of some symbol in the current context. -The second step updates the range decoder state with the three-tuple - (fl[k], fh[k], ft) corresponding to that symbol. - - -The first step is implemented by ec_decode() (entdec.c), which computes -
    - -
    -The divisions here are integer division. -
    - -The decoder then identifies the symbol in the current context corresponding to - fs; i.e., the value of k whose three-tuple (fl[k], fh[k], ft) - satisfies fl[k] <= fs < fh[k]. -It uses this tuple to update val according to -
    - -
    -If fl[k] is greater than zero, then the decoder updates rng using -
    - -
    -Otherwise, it updates rng using -
    - -
    -
    - -Using a special case for the first symbol (rather than the last symbol, as is - commonly done in other arithmetic coders) ensures that all the truncation - error from the finite precision arithmetic accumulates in symbol 0. -This makes the cost of coding a 0 slightly smaller, on average, than its - estimated probability indicates and makes the cost of coding any other symbol - slightly larger. -When contexts are designed so that 0 is the most probable symbol, which is - often the case, this strategy minimizes the inefficiency introduced by the - finite precision. -It also makes some of the special-case decoding routines in - particularly simple. - - -After the updates, implemented by ec_dec_update() (entdec.c), the decoder - normalizes the range using the procedure in the next section, and returns the - index k. - - -
    - -To normalize the range, the decoder repeats the following process, implemented - by ec_dec_normalize() (entdec.c), until rng > 2**23. -If rng is already greater than 2**23, the entire process is skipped. -First, it sets rng to (rng<<8). -Then it reads the next byte of the Opus frame and forms an 8-bit value sym, - using the left-over bit buffered from the previous byte as the high bit - and the top 7 bits of the byte just read as the other 7 bits of sym. -The remaining bit in the byte just read is buffered for use in the next - iteration. -If no more input bytes remain, it uses zero bits instead. -See for the initialization used to process - the first byte. -Then, it sets -
    - -
    -
    - -It is normal and expected that the range decoder will read several bytes - into the raw bits data (if any) at the end of the packet by the time the frame - is completely decoded, as illustrated in . -This same data MUST also be returned as raw bits when requested. -The encoder is expected to terminate the stream in such a way that the decoder - will decode the intended values regardless of the data contained in the raw - bits. - describes a procedure for doing this. -If the range decoder consumes all of the bytes belonging to the current frame, - it MUST continue to use zero when any further input bytes are required, even - if there is additional data in the current packet from padding or other - frames. - - -
    - | : -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - ^ ^ - | End of data buffered by the range coder | -...-----------------------------------------------+ - | - | End of data consumed by raw bits - +-------------------------------------------------------... -]]> -
    -
    -
    - -
    - -The reference implementation uses three additional decoding methods that are - exactly equivalent to the above, but make assumptions and simplifications that - allow for a more efficient implementation. - -
    - -The first is ec_decode_bin() (entdec.c), defined using the parameter ftb - instead of ft. -It is mathematically equivalent to calling ec_decode() with - ft = (1<<ftb), but avoids one of the divisions. - -
    -
    - -The next is ec_dec_bit_logp() (entdec.c), which decodes a single binary symbol, - replacing both the ec_decode() and ec_dec_update() steps. -The context is described by a single parameter, logp, which is the absolute - value of the base-2 logarithm of the probability of a "1". -It is mathematically equivalent to calling ec_decode() with - ft = (1<<logp), followed by ec_dec_update() with - the 3-tuple (fl[k] = 0, - fh[k] = (1<<logp) - 1, - ft = (1<<logp)) if the returned value - of fs is less than (1<<logp) - 1 (a "0" was decoded), and with - (fl[k] = (1<<logp) - 1, - fh[k] = ft = (1<<logp)) otherwise (a "1" was - decoded). -The implementation requires no multiplications or divisions. - -
    -
    - -The last is ec_dec_icdf() (entdec.c), which decodes a single symbol with a - table-based context of up to 8 bits, also replacing both the ec_decode() and - ec_dec_update() steps, as well as the search for the decoded symbol in between. -The context is described by two parameters, an icdf - ("inverse" cumulative distribution function) table and ftb. -As with ec_decode_bin(), (1<<ftb) is equivalent to ft. -idcf[k], on the other hand, stores (1<<ftb)-fh[k], which is equal to - (1<<ftb) - fl[k+1]. -fl[0] is assumed to be 0, and the table is terminated by a value of 0 (where - fh[k] == ft). - - -The function is mathematically equivalent to calling ec_decode() with - ft = (1<<ftb), using the returned value fs to search the table - for the first entry where fs < (1<<ftb)-icdf[k], and - calling ec_dec_update() with - fl[k] = (1<<ftb) - icdf[k-1] (or 0 - if k == 0), fh[k] = (1<<ftb) - idcf[k], - and ft = (1<<ftb). -Combining the search with the update allows the division to be replaced by a - series of multiplications (which are usually much cheaper), and using an - inverse CDF allows the use of an ftb as large as 8 in an 8-bit table without - any special cases. -This is the primary interface with the range decoder in the SILK layer, though - it is used in a few places in the CELT layer as well. - - -Although icdf[k] is more convenient for the code, the frequency counts, f[k], - are a more natural representation of the probability distribution function - (PDF) for a given symbol. -Therefore this draft lists the latter, not the former, when describing the - context in which a symbol is coded as a list, e.g., {4, 4, 4, 4}/16 for a - uniform context with four possible values and ft = 16. -The value of ft after the slash is always the sum of the entries in the PDF, - but is included for convenience. -Contexts with identical probabilities, f[k]/ft, but different values of ft - (or equivalently, ftb) are not the same, and cannot, in general, be used in - place of one another. -An icdf table is also not capable of representing a PDF where the first symbol - has 0 probability. -In such contexts, ec_dec_icdf() can decode the symbol by using a table that - drops the entries for any initial zero-probability values and adding the - constant offset of the first value with a non-zero probability to its return - value. - -
    -
    - -
    - -The raw bits used by the CELT layer are packed at the end of the packet, with - the least significant bit of the first value packed in the least significant - bit of the last byte, filling up to the most significant bit in the last byte, - continuing on to the least significant bit of the penultimate byte, and so on. -The reference implementation reads them using ec_dec_bits() (entdec.c). -Because the range decoder must read several bytes ahead in the stream, as - described in , the input consumed by the - raw bits may overlap with the input consumed by the range coder, and a decoder - MUST allow this. -The format should render it impossible to attempt to read more raw bits than - there are actual bits in the frame, though a decoder may wish to check for - this and report an error. - -
    - -
    - -The function ec_dec_uint() (entdec.c) decodes one of ft equiprobable values in - the range 0 to (ft - 1), inclusive, each with a frequency of 1, - where ft may be as large as (2**32 - 1). -Because ec_decode() is limited to a total frequency of (2**16 - 1), - it splits up the value into a range coded symbol representing up to 8 of the - high bits, and, if necessary, raw bits representing the remainder of the - value. -The limit of 8 bits in the range coded symbol is a trade-off between - implementation complexity, modeling error (since the symbols no longer truly - have equal coding cost), and rounding error introduced by the range coder - itself (which gets larger as more bits are included). -Using raw bits reduces the maximum number of divisions required in the worst - case, but means that it may be possible to decode a value outside the range - 0 to (ft - 1), inclusive. - - - -ec_dec_uint() takes a single, positive parameter, ft, which is not necessarily - a power of two, and returns an integer, t, whose value lies between 0 and - (ft - 1), inclusive. -Let ftb = ilog(ft - 1), i.e., the number of bits required - to store (ft - 1) in two's complement notation. -If ftb is 8 or less, then t is decoded with t = ec_decode(ft), and - the range coder state is updated using the three-tuple (t, t + 1, - ft). - - -If ftb is greater than 8, then the top 8 bits of t are decoded using -
    -> (ftb - 8)) + 1) , -]]> -
    - the decoder state is updated using the three-tuple - (t, t + 1, - ((ft - 1) >> (ftb - 8)) + 1), - and the remaining bits are decoded as raw bits, setting -
    - -
    -If, at this point, t >= ft, then the current frame is corrupt. -In that case, the decoder should assume there has been an error in the coding, - decoding, or transmission and SHOULD take measures to conceal the - error and/or report to the application that the error has occurred. -
    - -
    - -
    - -The bit allocation routines in the CELT decoder need a conservative upper bound - on the number of bits that have been used from the current frame thus far, - including both range coder bits and raw bits. -This drives allocation decisions that must match those made in the encoder. -The upper bound is computed in the reference implementation to whole-bit - precision by the function ec_tell() (entcode.h) and to fractional 1/8th bit - precision by the function ec_tell_frac() (entcode.c). -Like all operations in the range coder, it must be implemented in a bit-exact - manner, and must produce exactly the same value returned by the same functions - in the encoder after encoding the same symbols. - - -ec_tell() is guaranteed to return ceil(ec_tell_frac()/8.0). -In various places the codec will check to ensure there is enough room to - contain a symbol before attempting to decode it. -In practice, although the number of bits used so far is an upper bound, - decoding a symbol whose probability model suggests it has a worst-case cost of - p 1/8th bits may actually advance the return value of ec_tell_frac() by - p-1, p, or p+1 1/8th bits, due to approximation error in that upper bound, - truncation error in the range coder, and for large values of ft, modeling - error in ec_dec_uint(). - - -However, this error is bounded, and periodic calls to ec_tell() or - ec_tell_frac() at precisely defined points in the decoding process prevent it - from accumulating. -For a range coder symbol that requires a whole number of bits (i.e., - for which ft/(fh[k] - fl[k]) is a power of two), where there are at - least p 1/8th bits available, decoding the symbol will never cause ec_tell() or - ec_tell_frac() to exceed the size of the frame ("bust the budget"). -In this case the return value of ec_tell_frac() will only advance by more than - p 1/8th bits if there was an additional, fractional number of bits remaining, - and it will never advance beyond the next whole-bit boundary, which is safe, - since frames always contain a whole number of bits. -However, when p is not a whole number of bits, an extra 1/8th bit is required - to ensure that decoding the symbol will not bust the budget. - - -The reference implementation keeps track of the total number of whole bits that - have been processed by the decoder so far in the variable nbits_total, - including the (possibly fractional) number of bits that are currently - buffered, but not consumed, inside the range coder. -nbits_total is initialized to 9 just before the initial range renormalization - process completes (or equivalently, it can be initialized to 33 after the - first renormalization). -The extra two bits over the actual amount buffered by the range coder - guarantees that it is an upper bound and that there is enough room for the - encoder to terminate the stream. -Each iteration through the range coder's renormalization loop increases - nbits_total by 8. -Reading raw bits increases nbits_total by the number of raw bits read. - - -
    - -The whole number of bits buffered in rng may be estimated via lg = ilog(rng). -ec_tell() then becomes a simple matter of removing these bits from the total. -It returns (nbits_total - lg). - - -In a newly initialized decoder, before any symbols have been read, this reports - that 1 bit has been used. -This is the bit reserved for termination of the encoder. - -
    - -
    - -ec_tell_frac() estimates the number of bits buffered in rng to fractional - precision. -Since rng must be greater than 2**23 after renormalization, lg must be at least - 24. -Let -
    - -> (lg-16) , -]]> -
    - so that 32768 <= r_Q15 < 65536, an unsigned Q15 value representing the - fractional part of rng. -Then the following procedure can be used to add one bit of precision to lg. -First, update -
    - -> 15 . -]]> -
    -Then add the 16th bit of r_Q15 to lg via -
    - -> 16) . -]]> -
    -Finally, if this bit was a 1, reduce r_Q15 by a factor of two via -
    - -> 1 , -]]> -
    - so that it once again lies in the range 32768 <= r_Q15 < 65536. -
    - -This procedure is repeated three times to extend lg to 1/8th bit precision. -ec_tell_frac() then returns (nbits_total*8 - lg). - -
    - -
    - -
    - -
    - -The decoder's LP layer uses a modified version of the SILK codec (herein simply - called "SILK"), which runs a decoded excitation signal through adaptive - long-term and short-term prediction synthesis filters. -It runs at NB, MB, and WB sample rates internally. -When used in a SWB or FB Hybrid frame, the LP layer itself still only runs in - WB. - - -
    - -An overview of the decoder is given in . - -
    - -| Range |--->| Decode |---------------------------+ - 1 | Decoder | 2 | Parameters |----------+ 5 | - +---------+ +------------+ 4 | | - 3 | | | - \/ \/ \/ - +------------+ +------------+ +------------+ - | Generate |-->| LTP |-->| LPC | - | Excitation | | Synthesis | | Synthesis | - +------------+ +------------+ +------------+ - ^ | - | | - +-------------------+----------------+ - | 6 - | +------------+ +-------------+ - +-->| Stereo |-->| Sample Rate |--> - | Unmixing | 7 | Conversion | 8 - +------------+ +-------------+ - -1: Range encoded bitstream -2: Coded parameters -3: Pulses, LSBs, and signs -4: Pitch lags, Long-Term Prediction (LTP) coefficients -5: Linear Predictive Coding (LPC) coefficients and gains -6: Decoded signal (mono or mid-side stereo) -7: Unmixed signal (mono or left-right stereo) -8: Resampled signal -]]> - -
    - - -The decoder feeds the bitstream (1) to the range decoder from - , and then decodes the parameters in it (2) - using the procedures detailed in - Sections  - through . -These parameters (3, 4, 5) are used to generate an excitation signal (see - ), which is fed to an optional - long-term prediction (LTP) filter (voiced frames only, see - ) and then a short-term prediction filter - (see ), producing the decoded signal (6). -For stereo streams, the mid-side representation is converted to separate left - and right channels (7). -The result is finally resampled to the desired output sample rate (e.g., - 48 kHz) so that the resampled signal (8) can be mixed with the CELT - layer. - - -
    - -
    - - -Internally, the LP layer of a single Opus frame is composed of either a single - 10 ms regular SILK frame or between one and three 20 ms regular SILK - frames. -A stereo Opus frame may double the number of regular SILK frames (up to a total - of six), since it includes separate frames for a mid channel and, optionally, - a side channel. -Optional Low Bit-Rate Redundancy (LBRR) frames, which are reduced-bitrate - encodings of previous SILK frames, may be included to aid in recovery from - packet loss. -If present, these appear before the regular SILK frames. -They are in most respects identical to regular, active SILK frames, except that - they are usually encoded with a lower bitrate. -This draft uses "SILK frame" to refer to either one and "regular SILK frame" if - it needs to draw a distinction between the two. - - -Logically, each SILK frame is in turn composed of either two or four 5 ms - subframes. -Various parameters, such as the quantization gain of the excitation and the - pitch lag and filter coefficients can vary on a subframe-by-subframe basis. -Physically, the parameters for each subframe are interleaved in the bitstream, - as described in the relevant sections for each parameter. - - -All of these frames and subframes are decoded from the same range coder, with - no padding between them. -Thus packing multiple SILK frames in a single Opus frame saves, on average, - half a byte per SILK frame. -It also allows some parameters to be predicted from prior SILK frames in the - same Opus frame, since this does not degrade packet loss robustness (beyond - any penalty for merely using fewer, larger packets to store multiple frames). - - - -Stereo support in SILK uses a variant of mid-side coding, allowing a mono - decoder to simply decode the mid channel. -However, the data for the two channels is interleaved, so a mono decoder must - still unpack the data for the side channel. -It would be required to do so anyway for Hybrid Opus frames, or to support - decoding individual 20 ms frames. - - - - summarizes the overall grouping of the contents of - the LP layer. -Figures  - and  illustrate - the ordering of the various SILK frames for a 60 ms Opus frame, for both - mono and stereo, respectively. - - - -Symbol(s) -PDF(s) -Condition - -Voice Activity Detection (VAD) flags -{1, 1}/2 - - -LBRR flag -{1, 1}/2 - - -Per-frame LBRR flags - - - -LBRR Frame(s) - - - -Regular SILK Frame(s) - - - - - -
    - -
    - -
    - -
    - -
    - -
    - -The LP layer begins with two to eight header bits, decoded in silk_Decode() - (dec_API.c). -These consist of one Voice Activity Detection (VAD) bit per frame (up to 3), - followed by a single flag indicating the presence of LBRR frames. -For a stereo packet, these first flags correspond to the mid channel, and a - second set of flags is included for the side channel. - - -Because these are the first symbols decoded by the range coder and because they - are coded as binary values with uniform probability, they can be extracted - directly from the most significant bits of the first byte of compressed data. -Thus, a receiver can determine if an Opus frame contains any active SILK frames - without the overhead of using the range decoder. - -
    - -
    - -For Opus frames longer than 20 ms, a set of LBRR flags is - decoded for each channel that has its LBRR flag set. -Each set contains one flag per 20 ms SILK frame. -40 ms Opus frames use the 2-frame LBRR flag PDF from - , and 60 ms Opus frames use the - 3-frame LBRR flag PDF. -For each channel, the resulting 2- or 3-bit integer contains the corresponding - LBRR flag for each frame, packed in order from the LSB to the MSB. - - - -Frame Size -PDF -40 ms {0, 53, 53, 150}/256 -60 ms {0, 41, 20, 29, 41, 15, 28, 82}/256 - - - -A 10 or 20 ms Opus frame does not contain any per-frame LBRR flags, - as there may be at most one LBRR frame per channel. -The global LBRR flag in the header bits (see ) - is already sufficient to indicate the presence of that single LBRR frame. - - -
    - -
    - -The LBRR frames, if present, contain an encoded representation of the signal - immediately prior to the current Opus frame as if it were encoded with the - current mode, frame size, audio bandwidth, and channel count, even if those - differ from the prior Opus frame. -When one of these parameters changes from one Opus frame to the next, this - implies that the LBRR frames of the current Opus frame may not be simple - drop-in replacements for the contents of the previous Opus frame. - - - -For example, when switching from 20 ms to 60 ms, the 60 ms Opus - frame may contain LBRR frames covering up to three prior 20 ms Opus - frames, even if those frames already contained LBRR frames covering some of - the same time periods. -When switching from 20 ms to 10 ms, the 10 ms Opus frame can - contain an LBRR frame covering at most half the prior 20 ms Opus frame, - potentially leaving a hole that needs to be concealed from even a single - packet loss (see ). -When switching from mono to stereo, the LBRR frames in the first stereo Opus - frame MAY contain a non-trivial side channel. - - - -In order to properly produce LBRR frames under all conditions, an encoder might - need to buffer up to 60 ms of audio and re-encode it during these - transitions. -However, the reference implementation opts to disable LBRR frames at the - transition point for simplicity. -Since transitions are relatively infrequent in normal usage, this does not have - a significant impact on packet loss robustness. - - - -The LBRR frames immediately follow the LBRR flags, prior to any regular SILK - frames. - describes their exact contents. -LBRR frames do not include their own separate VAD flags. -LBRR frames are only meant to be transmitted for active speech, thus all LBRR - frames are treated as active. - - - -In a stereo Opus frame longer than 20 ms, although the per-frame LBRR - flags for the mid channel are coded as a unit before the per-frame LBRR flags - for the side channel, the LBRR frames themselves are interleaved. -The decoder parses an LBRR frame for the mid channel of a given 20 ms - interval (if present) and then immediately parses the corresponding LBRR - frame for the side channel (if present), before proceeding to the next - 20 ms interval. - -
    - -
    - -The regular SILK frame(s) follow the LBRR frames (if any). - describes their contents, as well. -Unlike the LBRR frames, a regular SILK frame is coded for each time interval in - an Opus frame, even if the corresponding VAD flags are unset. -For stereo Opus frames longer than 20 ms, the regular mid and side SILK - frames for each 20 ms interval are interleaved, just as with the LBRR - frames. -The side frame may be skipped by coding an appropriate flag, as detailed in - . - -
    - -
    - -Each SILK frame includes a set of side information that encodes - -The frame type and quantization type (), -Quantization gains (), -Short-term prediction filter coefficients (), -A Line Spectral Frequencies (LSF) interpolation weight (), - -Long-term prediction filter lags and gains (), - and - -A linear congruential generator (LCG) seed (). - -The quantized excitation signal (see ) follows - these at the end of the frame. - details the overall organization of a - SILK frame. - - - -Symbol(s) -PDF(s) -Condition - -Stereo Prediction Weights - - - -Mid-only Flag - - - -Frame Type - - - -Subframe Gains - - - -Normalized LSF Stage-1 Index - - - -Normalized LSF Stage-2 Residual - - - -Normalized LSF Interpolation Weight - -20 ms frame - -Primary Pitch Lag - -Voiced frame - -Subframe Pitch Contour - -Voiced frame - -Periodicity Index - -Voiced frame - -LTP Filter - -Voiced frame - -LTP Scaling - - - -LCG Seed - - - -Excitation Rate Level - - - -Excitation Pulse Counts - - - -Excitation Pulse Locations - -Non-zero pulse count - -Excitation LSBs - - - -Excitation Signs - - - - - -
    - -A SILK frame corresponding to the mid channel of a stereo Opus frame begins - with a pair of side channel prediction weights, designed such that zeros - indicate normal mid-side coupling. -Since these weights can change on every frame, the first portion of each frame - linearly interpolates between the previous weights and the current ones, using - zeros for the previous weights if none are available. -These prediction weights are never included in a mono Opus frame, and the - previous weights are reset to zeros on any transition from mono to stereo. -They are also not included in an LBRR frame for the side channel, even if the - LBRR flags indicate the corresponding mid channel was not coded. -In that case, the previous weights are used, again substituting in zeros if no - previous weights are available since the last decoder reset - (see ). - - - -To summarize, these weights are coded if and only if - -This is a stereo Opus frame (), and -The current SILK frame corresponds to the mid channel. - - - - -The prediction weights are coded in three separate pieces, which are decoded - by silk_stereo_decode_pred() (decode_stereo_pred.c). -The first piece jointly codes the high-order part of a table index for both - weights. -The second piece codes the low-order part of each table index. -The third piece codes an offset used to linearly interpolate between table - indices. -The details are as follows. - - - -Let n be an index decoded with the 25-element stage-1 PDF in - . -Then let i0 and i1 be indices decoded with the stage-2 and stage-3 PDFs in - , respectively, and let i2 and i3 - be two more indices decoded with the stage-2 and stage-3 PDFs, all in that - order. - - - -Stage -PDF -Stage 1 -{7, 2, 1, 1, 1, - 10, 24, 8, 1, 1, - 3, 23, 92, 23, 3, - 1, 1, 8, 24, 10, - 1, 1, 1, 2, 7}/256 - -Stage 2 -{85, 86, 85}/256 - -Stage 3 -{51, 51, 52, 51, 51}/256 - - - -Then use n, i0, and i2 to form two table indices, wi0 and wi1, according to -
    - -
    - where the division is integer division. -The range of these indices is 0 to 14, inclusive. -Let w[i] be the i'th weight from . -Then the two prediction weights, w0_Q13 and w1_Q13, are -
    -> 16)*(2*i3 + 1) - -w0_Q13 = w_Q13[wi0] - + ((w_Q13[wi0+1] - w_Q13[wi0])*6554) >> 16)*(2*i1 + 1) - - w1_Q13 -]]> -
    -N.b., w1_Q13 is computed first here, because w0_Q13 depends on it. -The constant 6554 is approximately 0.1 in Q16. -Although wi0 and wi1 only have 15 possible values, - contains 16 entries to allow - interpolation between entry wi0 and (wi0 + 1) (and likewise for wi1). -
    - - -Index -Weight (Q13) - 0 -13732 - 1 -10050 - 2 -8266 - 3 -7526 - 4 -6500 - 5 -5000 - 6 -2950 - 7 -820 - 8 820 - 9 2950 -10 5000 -11 6500 -12 7526 -13 8266 -14 10050 -15 13732 - - -
    - -
    - -A flag appears after the stereo prediction weights that indicates if only the - mid channel is coded for this time interval. -It appears only when - -This is a stereo Opus frame (see ), -The current SILK frame corresponds to the mid channel, and -Either - -This is a regular SILK frame where the VAD flags - (see ) indicate that the corresponding side - channel is not active. - -This is an LBRR frame where the LBRR flags - (see and ) - indicate that the corresponding side channel is not coded. - - - - -It is omitted when there are no stereo weights, for all of the same reasons. -It is also omitted for a regular SILK frame when the VAD flag of the - corresponding side channel frame is set (indicating it is active). -The side channel must be coded in this case, making the mid-only flag - redundant. -It is also omitted for an LBRR frame when the corresponding LBRR flags - indicate the side channel is coded. - - - -When the flag is present, the decoder reads a single value using the PDF in - , as implemented in - silk_stereo_decode_mid_only() (decode_stereo_pred.c). -If the flag is set, then there is no corresponding SILK frame for the side - channel, the entire decoding process for the side channel is skipped, and - zeros are fed to the stereo unmixing process (see - ) instead. -As stated above, LBRR frames still include this flag when the LBRR flag - indicates that the side channel is not coded. -In that case, if this flag is zero (indicating that there should be a side - channel), then Packet Loss Concealment (PLC, see - ) SHOULD be invoked to recover a - side channel signal. -Otherwise, the stereo image will collapse. - - - -PDF -{192, 64}/256 - - -
    - -
    - -Each SILK frame contains a single "frame type" symbol that jointly codes the - signal type and quantization offset type of the corresponding frame. -If the current frame is a regular SILK frame whose VAD bit was not set (an - "inactive" frame), then the frame type symbol takes on a value of either 0 or - 1 and is decoded using the first PDF in . -If the frame is an LBRR frame or a regular SILK frame whose VAD flag was set - (an "active" frame), then the value of the symbol may range from 2 to 5, - inclusive, and is decoded using the second PDF in - . - translates between the value of the - frame type symbol and the corresponding signal type and quantization offset - type. - - - -VAD Flag -PDF -Inactive {26, 230, 0, 0, 0, 0}/256 -Active {0, 0, 24, 74, 148, 10}/256 - - - -Frame Type -Signal Type -Quantization Offset Type -0 Inactive Low -1 Inactive High -2 Unvoiced Low -3 Unvoiced High -4 Voiced Low -5 Voiced High - - -
    - -
    - -A separate quantization gain is coded for each 5 ms subframe. -These gains control the step size between quantization levels of the excitation - signal and, therefore, the quality of the reconstruction. -They are independent of and unrelated to the pitch contours coded for voiced - frames. -The quantization gains are themselves uniformly quantized to 6 bits on a - log scale, giving them a resolution of approximately 1.369 dB and a range - of approximately 1.94 dB to 88.21 dB. - - -The subframe gains are either coded independently, or relative to the gain from - the most recent coded subframe in the same channel. -Independent coding is used if and only if - - -This is the first subframe in the current SILK frame, and - -Either - - -This is the first SILK frame of its type (LBRR or regular) for this channel in - the current Opus frame, or - - -The previous SILK frame of the same type (LBRR or regular) for this channel in - the same Opus frame was not coded. - - - - - - - -In an independently coded subframe gain, the 3 most significant bits of the - quantization gain are decoded using a PDF selected from - based on the decoded signal - type (see ). - - - -Signal Type -PDF -Inactive {32, 112, 68, 29, 12, 1, 1, 1}/256 -Unvoiced {2, 17, 45, 60, 62, 47, 19, 4}/256 -Voiced {1, 3, 26, 71, 94, 50, 9, 2}/256 - - - -The 3 least significant bits are decoded using a uniform PDF: - - -PDF -{32, 32, 32, 32, 32, 32, 32, 32}/256 - - - -These 6 bits are combined to form a value, gain_index, between 0 and 63. -When the gain for the previous subframe is available, then the current gain is - limited as follows: -
    - -
    -This may help some implementations limit the change in precision of their - internal LTP history. -The indices which this clamp applies to cannot simply be removed from the - codebook, because previous_log_gain will not be available after packet loss. -The clamping is skipped after a decoder reset, and in the side channel if the - previous frame in the side channel was not coded, since there is no value for - previous_log_gain available. -It MAY also be skipped after packet loss. -
    - - -For subframes which do not have an independent gain (including the first - subframe of frames not listed as using independent coding above), the - quantization gain is coded relative to the gain from the previous subframe (in - the same channel). -The PDF in yields a delta_gain_index value - between 0 and 40, inclusive. - - -PDF -{6, 5, 11, 31, 132, 21, 8, 4, - 3, 2, 2, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1}/256 - - -The following formula translates this index into a quantization gain for the - current subframe using the gain from the previous subframe: -
    - -
    -
    - -silk_gains_dequant() (gain_quant.c) dequantizes log_gain for the k'th subframe - and converts it into a linear Q16 scale factor via -
    ->16) + 2090) -]]> -
    -
    - -The function silk_log2lin() (log2lin.c) computes an approximation of - 2**(inLog_Q7/128.0), where inLog_Q7 is its Q7 input. -Let i = inLog_Q7>>7 be the integer part of inLogQ7 and - f = inLog_Q7&127 be the fractional part. -Then -
    ->16)+f)*((1<>7) -]]> -
    - yields the approximate exponential. -The final Q16 gain values lies between 81920 and 1686110208, inclusive - (representing scale factors of 1.25 to 25728, respectively). -
    -
    - -
    - -A set of normalized Line Spectral Frequency (LSF) coefficients follow the - quantization gains in the bitstream, and represent the Linear Predictive - Coding (LPC) coefficients for the current SILK frame. -Once decoded, the normalized LSFs form an increasing list of Q15 values between - 0 and 1. -These represent the interleaved zeros on the upper half of the unit circle - (between 0 and pi, hence "normalized") in the standard decomposition - of the LPC filter into a symmetric part - and an anti-symmetric part (P and Q in ). -Because of non-linear effects in the decoding process, an implementation SHOULD - match the fixed-point arithmetic described in this section exactly. -An encoder SHOULD also use the same process. - - -The normalized LSFs are coded using a two-stage vector quantizer (VQ) - ( and ). -NB and MB frames use an order-10 predictor, while WB frames use an order-16 - predictor, and thus have different sets of tables. -After reconstructing the normalized LSFs - (), the decoder runs them through a - stabilization process (), interpolates - them between frames (), converts them - back into LPC coefficients (), and then runs - them through further processes to limit the range of the coefficients - () and the gain of the filter - (). -All of this is necessary to ensure the reconstruction process is stable. - - -
    - -The first VQ stage uses a 32-element codebook, coded with one of the PDFs in - , depending on the audio bandwidth and - the signal type of the current SILK frame. -This yields a single index, I1, for the entire frame, which - -Indexes an element in a coarse codebook, -Selects the PDFs for the second stage of the VQ, and -Selects the prediction weights used to remove intra-frame redundancy from - the second stage. - -The actual codebook elements are listed in - and - , but they are not needed until the last - stages of reconstructing the LSF coefficients. - - - -Audio Bandwidth -Signal Type -PDF -NB or MB Inactive or unvoiced - -{44, 34, 30, 19, 21, 12, 11, 3, - 3, 2, 16, 2, 2, 1, 5, 2, - 1, 3, 3, 1, 1, 2, 2, 2, - 3, 1, 9, 9, 2, 7, 2, 1}/256 - -NB or MB Voiced - -{1, 10, 1, 8, 3, 8, 8, 14, -13, 14, 1, 14, 12, 13, 11, 11, -12, 11, 10, 10, 11, 8, 9, 8, - 7, 8, 1, 1, 6, 1, 6, 5}/256 - -WB Inactive or unvoiced - -{31, 21, 3, 17, 1, 8, 17, 4, - 1, 18, 16, 4, 2, 3, 1, 10, - 1, 3, 16, 11, 16, 2, 2, 3, - 2, 11, 1, 4, 9, 8, 7, 3}/256 - -WB Voiced - -{1, 4, 16, 5, 18, 11, 5, 14, -15, 1, 3, 12, 13, 14, 14, 6, -14, 12, 2, 6, 1, 12, 12, 11, -10, 3, 10, 5, 1, 1, 1, 3}/256 - - - -
    - -
    - -A total of 16 PDFs are available for the LSF residual in the second stage: the - 8 (a...h) for NB and MB frames given in - , and the 8 (i...p) for WB frames - given in . -Which PDF is used for which coefficient is driven by the index, I1, - decoded in the first stage. - lists the letter of the - corresponding PDF for each normalized LSF coefficient for NB and MB, and - lists the same information for WB. - - - -Codebook -PDF -a {1, 1, 1, 15, 224, 11, 1, 1, 1}/256 -b {1, 1, 2, 34, 183, 32, 1, 1, 1}/256 -c {1, 1, 4, 42, 149, 55, 2, 1, 1}/256 -d {1, 1, 8, 52, 123, 61, 8, 1, 1}/256 -e {1, 3, 16, 53, 101, 74, 6, 1, 1}/256 -f {1, 3, 17, 55, 90, 73, 15, 1, 1}/256 -g {1, 7, 24, 53, 74, 67, 26, 3, 1}/256 -h {1, 1, 18, 63, 78, 58, 30, 6, 1}/256 - - - -Codebook -PDF -i {1, 1, 1, 9, 232, 9, 1, 1, 1}/256 -j {1, 1, 2, 28, 186, 35, 1, 1, 1}/256 -k {1, 1, 3, 42, 152, 53, 2, 1, 1}/256 -l {1, 1, 10, 49, 126, 65, 2, 1, 1}/256 -m {1, 4, 19, 48, 100, 77, 5, 1, 1}/256 -n {1, 1, 14, 54, 100, 72, 12, 1, 1}/256 -o {1, 1, 15, 61, 87, 61, 25, 4, 1}/256 -p {1, 7, 21, 50, 77, 81, 17, 1, 1}/256 - - - -I1 -Coefficient - -0 1 2 3 4 5 6 7 8 9 - 0 -a a a a a a a a a a - 1 -b d b c c b c b b b - 2 -c b b b b b b b b b - 3 -b c c c c b c b b b - 4 -c d d d d c c c c c - 5 -a f d d c c c c b b - g -a c c c c c c c c b - 7 -c d g e e e f e f f - 8 -c e f f e f e g e e - 9 -c e e h e f e f f e -10 -e d d d c d c c c c -11 -b f f g e f e f f f -12 -c h e g f f f f f f -13 -c h f f f f f g f e -14 -d d f e e f e f e e -15 -c d d f f e e e e e -16 -c e e g e f e f f f -17 -c f e g f f f e f e -18 -c h e f e f e f f f -19 -c f e g h g f g f e -20 -d g h e g f f g e f -21 -c h g e e e f e f f -22 -e f f e g g f g f e -23 -c f f g f g e g e e -24 -e f f f d h e f f e -25 -c d e f f g e f f e -26 -c d c d d e c d d d -27 -b b c c c c c d c c -28 -e f f g g g f g e f -29 -d f f e e e e d d c -30 -c f d h f f e e f e -31 -e e f e f g f g f e - - - -I1 -Coefficient - -0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 - 0 -i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i - 1 -k  l  l  l  l  l  k  k  k  k  k  j  j  j  i  l - 2 -k  n  n  l  p  m  m  n  k  n  m  n  n  m  l  l - 3 -i  k  j  k  k  j  j  j  j  j  i  i  i  i  i  j - 4 -i  o  n  m  o  m  p  n  m  m  m  n  n  m  m  l - 5 -i  l  n  n  m  l  l  n  l  l  l  l  l  l  k  m - 6 -i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i - 7 -i  k  o  l  p  k  n  l  m  n  n  m  l  l  k  l - 8 -i  o  k  o  o  m  n  m  o  n  m  m  n  l  l  l - 9 -k  j  i  i  i  i  i  i  i  i  i  i  i  i  i  i -10 -i  j  i  i  i  i  i  i  i  i  i  i  i  i  i  j -11 -k  k  l  m  n  l  l  l  l  l  l  l  k  k  j  l -12 -k  k  l  l  m  l  l  l  l  l  l  l  l  k  j  l -13 -l  m  m  m  o  m  m  n  l  n  m  m  n  m  l  m -14 -i  o  m  n  m  p  n  k  o  n  p  m  m  l  n  l -15 -i  j  i  j  j  j  j  j  j  j  i  i  i  i  j  i -16 -j  o  n  p  n  m  n  l  m  n  m  m  m  l  l  m -17 -j  l  l  m  m  l  l  n  k  l  l  n  n  n  l  m -18 -k  l  l  k  k  k  l  k  j  k  j  k  j  j  j  m -19 -i  k  l  n  l  l  k  k  k  j  j  i  i  i  i  i -20 -l  m  l  n  l  l  k  k  j  j  j  j  j  k  k  m -21 -k  o  l  p  p  m  n  m  n  l  n  l  l  k  l  l -22 -k  l  n  o  o  l  n  l  m  m  l  l  l  l  k  m -23 -j  l  l  m  m  m  m  l  n  n  n  l  j  j  j  j -24 -k  n  l  o  o  m  p  m  m  n  l  m  m  l  l  l -25 -i  o  j  j  i  i  i  i  i  i  i  i  i  i  i  i -26 -i  o  o  l  n  k  n  n  l  m  m  p  p  m  m  m -27 -l  l  p  l  n  m  l  l  l  k  k  l  l  l  k  l -28 -i  i  j  i  i  i  k  j  k  j  j  k  k  k  j  j -29 -i  l  k  n  l  l  k  l  k  j  i  i  j  i  i  j -30 -l  n  n  m  p  n  l  l  k  l  k  k  j  i  j  i -31 -k  l  n  l  m  l  l  l  k  j  k  o  m  i  i  i - - - -Decoding the second stage residual proceeds as follows. -For each coefficient, the decoder reads a symbol using the PDF corresponding to - I1 from either or - , and subtracts 4 from the result - to give an index in the range -4 to 4, inclusive. -If the index is either -4 or 4, it reads a second symbol using the PDF in - , and adds the value of this second symbol - to the index, using the same sign. -This gives the index, I2[k], a total range of -10 to 10, inclusive. - - - -PDF -{156, 60, 24, 9, 4, 2, 1}/256 - - - -The decoded indices from both stages are translated back into normalized LSF - coefficients in silk_NLSF_decode() (NLSF_decode.c). -The stage-2 indices represent residuals after both the first stage of the VQ - and a separate backwards-prediction step. -The backwards prediction process in the encoder subtracts a prediction from - each residual formed by a multiple of the coefficient that follows it. -The decoder must undo this process. - contains lists of prediction weights - for each coefficient. -There are two lists for NB and MB, and another two lists for WB, giving two - possible prediction weights for each coefficient. - - - -Coefficient -A -B -C -D - 0 179 116 175 68 - 1 138 67 148 62 - 2 140 82 160 66 - 3 148 59 176 60 - 4 151 92 178 72 - 5 149 72 173 117 - 6 153 100 174 85 - 7 151 89 164 90 - 8 163 92 177 118 - 9 174 136 -10 196 151 -11 182 142 -12 198 160 -13 192 142 -14 182 155 - - - -The prediction is undone using the procedure implemented in - silk_NLSF_residual_dequant() (NLSF_decode.c), which is as follows. -Each coefficient selects its prediction weight from one of the two lists based - on the stage-1 index, I1. - gives the selections for each - coefficient for NB and MB, and gives - the selections for WB. -Let d_LPC be the order of the codebook, i.e., 10 for NB and MB, and 16 for WB, - and let pred_Q8[k] be the weight for the k'th coefficient selected by this - process for 0 <= k < d_LPC-1. -Then, the stage-2 residual for each coefficient is computed via -
    ->8 : 0) - + ((((I2[k]<<10) - sign(I2[k])*102)*qstep)>>16) , -]]> -
    - where qstep is the Q16 quantization step size, which is 11796 for NB and MB - and 9830 for WB (representing step sizes of approximately 0.18 and 0.15, - respectively). -
    - - -I1 -Coefficient - -0 1 2 3 4 5 6 7 8 - 0 -A B A A A A A A A - 1 -B A A A A A A A A - 2 -A A A A A A A A A - 3 -B B B A A A A B A - 4 -A B A A A A A A A - 5 -A B A A A A A A A - 6 -B A B B A A A B A - 7 -A B B A A B B A A - 8 -A A B B A B A B B - 9 -A A B B A A B B B -10 -A A A A A A A A A -11 -A B A B B B B B A -12 -A B A B B B B B A -13 -A B B B B B B B A -14 -B A B B A B B B B -15 -A B B B B B A B A -16 -A A B B A B A B A -17 -A A B B B A B B B -18 -A B B A A B B B A -19 -A A A B B B A B A -20 -A B B A A B A B A -21 -A B B A A A B B A -22 -A A A A A B B B B -23 -A A B B A A A B B -24 -A A A B A B B B B -25 -A B B B B B B B A -26 -A A A A A A A A A -27 -A A A A A A A A A -28 -A A B A B B A B A -29 -B A A B A A A A A -30 -A A A B B A B A B -31 -B A B B A B B B B - - - -I1 -Coefficient - -0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 - 0 -C  C  C  C  C  C  C  C  C  C  C  C  C  C  D - 1 -C  C  C  C  C  C  C  C  C  C  C  C  C  C  C - 2 -C  C  D  C  C  D  D  D  C  D  D  D  D  C  C - 3 -C  C  C  C  C  C  C  C  C  C  C  C  D  C  C - 4 -C  D  D  C  D  C  D  D  C  D  D  D  D  D  C - 5 -C  C  D  C  C  C  C  C  C  C  C  C  C  C  C - 6 -D  C  C  C  C  C  C  C  C  C  C  D  C  D  C - 7 -C  D  D  C  C  C  D  C  D  D  D  C  D  C  D - 8 -C  D  C  D  D  C  D  C  D  C  D  D  D  D  D - 9 -C  C  C  C  C  C  C  C  C  C  C  C  C  C  D -10 -C  D  C  C  C  C  C  C  C  C  C  C  C  C  C -11 -C  C  D  C  D  D  D  D  D  D  D  C  D  C  C -12 -C  C  D  C  C  D  C  D  C  D  C  C  D  C  C -13 -C  C  C  C  D  D  C  D  C  D  D  D  D  C  C -14 -C  D  C  C  C  D  D  C  D  D  D  C  D  D  D -15 -C  C  D  D  C  C  C  C  C  C  C  C  D  D  C -16 -C  D  D  C  D  C  D  D  D  D  D  C  D  C  C -17 -C  C  D  C  C  C  C  D  C  C  D  D  D  C  C -18 -C  C  C  C  C  C  C  C  C  C  C  C  C  C  D -19 -C  C  C  C  C  C  C  C  C  C  C  C  D  C  C -20 -C  C  C  C  C  C  C  C  C  C  C  C  C  C  C -21 -C  D  C  D  C  D  D  C  D  C  D  C  D  D  C -22 -C  C  D  D  D  D  C  D  D  C  C  D  D  C  C -23 -C  D  D  C  D  C  D  C  D  C  C  C  C  D  C -24 -C  C  C  D  D  C  D  C  D  D  D  D  D  D  D -25 -C  C  C  C  C  C  C  C  C  C  C  C  C  C  D -26 -C  D  D  C  C  C  D  D  C  C  D  D  D  D  D -27 -C  C  C  C  C  D  C  D  D  D  D  C  D  D  D -28 -C  C  C  C  C  C  C  C  C  C  C  C  C  C  D -29 -C  C  C  C  C  C  C  C  C  C  C  C  C  C  D -30 -D  C  C  C  C  C  C  C  C  C  C  D  C  C  C -31 -C  C  D  C  C  D  D  D  C  C  D  C  C  D  C - - -
    - -
    - -Once the stage-1 index I1 and the stage-2 residual res_Q10[] have been decoded, - the final normalized LSF coefficients can be reconstructed. - - -The spectral distortion introduced by the quantization of each LSF coefficient - varies, so the stage-2 residual is weighted accordingly, using the - low-complexity Inverse Harmonic Mean Weighting (IHMW) function proposed in - . -The weights are derived directly from the stage-1 codebook vector. -Let cb1_Q8[k] be the k'th entry of the stage-1 codebook vector from - or - . -Then for 0 <= k < d_LPC the following expression - computes the square of the weight as a Q18 value: -
    - - - -
    - where cb1_Q8[-1] = 0 and cb1_Q8[d_LPC] = 256, and the - division is integer division. -This is reduced to an unsquared, Q9 value using the following square-root - approximation: -
    ->(i-8)) & 127 -y = ((i&1) ? 32768 : 46214) >> ((32-i)>>1) -w_Q9[k] = y + ((213*f*y)>>16) -]]> -
    -The constant 46214 here is approximately the square root of 2 in Q15. -The cb1_Q8[] vector completely determines these weights, and they may be - tabulated and stored as 13-bit unsigned values (with a range of 1819 to 5227, - inclusive) to avoid computing them when decoding. -The reference implementation already requires code to compute these weights on - unquantized coefficients in the encoder, in silk_NLSF_VQ_weights_laroia() - (NLSF_VQ_weights_laroia.c) and its callers, so it reuses that code in the - decoder instead of using a pre-computed table to reduce the amount of ROM - required. -
    - - -I1 -Codebook (Q8) - - 0   1   2   3   4   5   6   7   8   9 -0 -12  35  60  83 108 132 157 180 206 228 -1 -15  32  55  77 101 125 151 175 201 225 -2 -19  42  66  89 114 137 162 184 209 230 -3 -12  25  50  72  97 120 147 172 200 223 -4 -26  44  69  90 114 135 159 180 205 225 -5 -13  22  53  80 106 130 156 180 205 228 -6 -15  25  44  64  90 115 142 168 196 222 -7 -19  24  62  82 100 120 145 168 190 214 -8 -22  31  50  79 103 120 151 170 203 227 -9 -21  29  45  65 106 124 150 171 196 224 -10 -30  49  75  97 121 142 165 186 209 229 -11 -19  25  52  70  93 116 143 166 192 219 -12 -26  34  62  75  97 118 145 167 194 217 -13 -25  33  56  70  91 113 143 165 196 223 -14 -21  34  51  72  97 117 145 171 196 222 -15 -20  29  50  67  90 117 144 168 197 221 -16 -22  31  48  66  95 117 146 168 196 222 -17 -24  33  51  77 116 134 158 180 200 224 -18 -21  28  70  87 106 124 149 170 194 217 -19 -26  33  53  64  83 117 152 173 204 225 -20 -27  34  65  95 108 129 155 174 210 225 -21 -20  26  72  99 113 131 154 176 200 219 -22 -34  43  61  78  93 114 155 177 205 229 -23 -23  29  54  97 124 138 163 179 209 229 -24 -30  38  56  89 118 129 158 178 200 231 -25 -21  29  49  63  85 111 142 163 193 222 -26 -27  48  77 103 133 158 179 196 215 232 -27 -29  47  74  99 124 151 176 198 220 237 -28 -33  42  61  76  93 121 155 174 207 225 -29 -29  53  87 112 136 154 170 188 208 227 -30 -24  30  52  84 131 150 166 186 203 229 -31 -37  48  64  84 104 118 156 177 201 230 - - - -I1 -Codebook (Q8) - - 0  1  2  3  4   5   6   7   8   9  10  11  12  13  14  15 -0 - 7 23 38 54 69  85 100 116 131 147 162 178 193 208 223 239 -1 -13 25 41 55 69  83  98 112 127 142 157 171 187 203 220 236 -2 -15 21 34 51 61  78  92 106 126 136 152 167 185 205 225 240 -3 -10 21 36 50 63  79  95 110 126 141 157 173 189 205 221 237 -4 -17 20 37 51 59  78  89 107 123 134 150 164 184 205 224 240 -5 -10 15 32 51 67  81  96 112 129 142 158 173 189 204 220 236 -6 - 8 21 37 51 65  79  98 113 126 138 155 168 179 192 209 218 -7 -12 15 34 55 63  78  87 108 118 131 148 167 185 203 219 236 -8 -16 19 32 36 56  79  91 108 118 136 154 171 186 204 220 237 -9 -11 28 43 58 74  89 105 120 135 150 165 180 196 211 226 241 -10 - 6 16 33 46 60  75  92 107 123 137 156 169 185 199 214 225 -11 -11 19 30 44 57  74  89 105 121 135 152 169 186 202 218 234 -12 -12 19 29 46 57  71  88 100 120 132 148 165 182 199 216 233 -13 -17 23 35 46 56  77  92 106 123 134 152 167 185 204 222 237 -14 -14 17 45 53 63  75  89 107 115 132 151 171 188 206 221 240 -15 - 9 16 29 40 56  71  88 103 119 137 154 171 189 205 222 237 -16 -16 19 36 48 57  76  87 105 118 132 150 167 185 202 218 236 -17 -12 17 29 54 71  81  94 104 126 136 149 164 182 201 221 237 -18 -15 28 47 62 79  97 115 129 142 155 168 180 194 208 223 238 -19 - 8 14 30 45 62  78  94 111 127 143 159 175 192 207 223 239 -20 -17 30 49 62 79  92 107 119 132 145 160 174 190 204 220 235 -21 -14 19 36 45 61  76  91 108 121 138 154 172 189 205 222 238 -22 -12 18 31 45 60  76  91 107 123 138 154 171 187 204 221 236 -23 -13 17 31 43 53  70  83 103 114 131 149 167 185 203 220 237 -24 -17 22 35 42 58  78  93 110 125 139 155 170 188 206 224 240 -25 - 8 15 34 50 67  83  99 115 131 146 162 178 193 209 224 239 -26 -13 16 41 66 73  86  95 111 128 137 150 163 183 206 225 241 -27 -17 25 37 52 63  75  92 102 119 132 144 160 175 191 212 231 -28 -19 31 49 65 83 100 117 133 147 161 174 187 200 213 227 242 -29 -18 31 52 68 88 103 117 126 138 149 163 177 192 207 223 239 -30 -16 29 47 61 76  90 106 119 133 147 161 176 193 209 224 240 -31 -15 21 35 50 61  73  86  97 110 119 129 141 175 198 218 237 - - - -Given the stage-1 codebook entry cb1_Q8[], the stage-2 residual res_Q10[], and - their corresponding weights, w_Q9[], the reconstructed normalized LSF - coefficients are -
    - -
    - where the division is integer division. -However, nothing in either the reconstruction process or the - quantization process in the encoder thus far guarantees that the coefficients - are monotonically increasing and separated well enough to ensure a stable - filter . -When using the reference encoder, roughly 2% of frames violate this constraint. -The next section describes a stabilization procedure used to make these - guarantees. -
    - -
    - -
    - -The normalized LSF stabilization procedure is implemented in - silk_NLSF_stabilize() (NLSF_stabilize.c). -This process ensures that consecutive values of the normalized LSF - coefficients, NLSF_Q15[], are spaced some minimum distance apart - (predetermined to be the 0.01 percentile of a large training set). - gives the minimum spacings for NB and MB - and those for WB, where row k is the minimum allowed value of - NLSF_Q[k]-NLSF_Q[k-1]. -For the purposes of computing this spacing for the first and last coefficient, - NLSF_Q15[-1] is taken to be 0, and NLSF_Q15[d_LPC] is taken to be 32768. - - - -Coefficient -NB and MB -WB - 0 250 100 - 1 3 3 - 2 6 40 - 3 3 3 - 4 3 3 - 5 3 3 - 6 4 5 - 7 3 14 - 8 3 14 - 9 3 10 -10 461 11 -11 3 -12 8 -13 9 -14 7 -15 3 -16 347 - - - -The procedure starts off by trying to make small adjustments which attempt to - minimize the amount of distortion introduced. -After 20 such adjustments, it falls back to a more direct method which - guarantees the constraints are enforced but may require large adjustments. - - -Let NDeltaMin_Q15[k] be the minimum required spacing for the current audio - bandwidth from . -First, the procedure finds the index i where - NLSF_Q15[i] - NLSF_Q15[i-1] - NDeltaMin_Q15[i] is the - smallest, breaking ties by using the lower value of i. -If this value is non-negative, then the stabilization stops; the coefficients - satisfy all the constraints. -Otherwise, if i == 0, it sets NLSF_Q15[0] to NDeltaMin_Q15[0], and if - i == d_LPC, it sets NLSF_Q15[d_LPC-1] to - (32768 - NDeltaMin_Q15[d_LPC]). -For all other values of i, both NLSF_Q15[i-1] and NLSF_Q15[i] are updated as - follows: -
    ->1) + \ NDeltaMin_Q15[k] - /_ - k=0 - d_LPC - __ - max_center_Q15 = 32768 - (NDeltaMin_Q15[i]>>1) - \ NDeltaMin_Q15[k] - /_ - k=i+1 -center_freq_Q15 = clamp(min_center_Q15[i], - (NLSF_Q15[i-1] + NLSF_Q15[i] + 1)>>1, - max_center_Q15[i]) - - NLSF_Q15[i-1] = center_freq_Q15 - (NDeltaMin_Q15[i]>>1) - - NLSF_Q15[i] = NLSF_Q15[i-1] + NDeltaMin_Q15[i] . -]]> -
    -Then the procedure repeats again, until it has either executed 20 times or - has stopped because the coefficients satisfy all the constraints. -
    - -After the 20th repetition of the above procedure, the following fallback - procedure executes once. -First, the values of NLSF_Q15[k] for 0 <= k < d_LPC - are sorted in ascending order. -Then for each value of k from 0 to d_LPC-1, NLSF_Q15[k] is set to -
    - -
    -Next, for each value of k from d_LPC-1 down to 0, NLSF_Q15[k] is set to -
    - -
    -
    - -
    - -
    - -For 20 ms SILK frames, the first half of the frame (i.e., the first two - subframes) may use normalized LSF coefficients that are interpolated between - the decoded LSFs for the most recent coded frame (in the same channel) and the - current frame. -A Q2 interpolation factor follows the LSF coefficient indices in the bitstream, - which is decoded using the PDF in . -This happens in silk_decode_indices() (decode_indices.c). -After either - -An uncoded regular SILK frame in the side channel, or -A decoder reset (see ), - - the decoder still decodes this factor, but ignores its value and always uses - 4 instead. -For 10 ms SILK frames, this factor is not stored at all. - - - -PDF -{13, 22, 29, 11, 181}/256 - - - -Let n2_Q15[k] be the normalized LSF coefficients decoded by the procedure in - , n0_Q15[k] be the LSF coefficients - decoded for the prior frame, and w_Q2 be the interpolation factor. -Then the normalized LSF coefficients used for the first half of a 20 ms - frame, n1_Q15[k], are -
    -> 2) . -]]> -
    -This interpolation is performed in silk_decode_parameters() - (decode_parameters.c). -
    -
    - -
    - -Any LPC filter A(z) can be split into a symmetric part P(z) and an - anti-symmetric part Q(z) such that -
    - -
    -with -
    - -
    -The even normalized LSF coefficients correspond to a pair of conjugate roots of - P(z), while the odd coefficients correspond to a pair of conjugate roots of - Q(z), all of which lie on the unit circle. -In addition, P(z) has a root at pi and Q(z) has a root at 0. -Thus, they may be reconstructed mathematically from a set of normalized LSF - coefficients, n[k], as -
    - -
    -
    - -However, SILK performs this reconstruction using a fixed-point approximation so - that all decoders can reproduce it in a bit-exact manner to avoid prediction - drift. -The function silk_NLSF2A() (NLSF2A.c) implements this procedure. - - -To start, it approximates cos(pi*n[k]) using a table lookup with linear - interpolation. -The encoder SHOULD use the inverse of this piecewise linear approximation, - rather than the true inverse of the cosine function, when deriving the - normalized LSF coefficients. -These values are also re-ordered to improve numerical accuracy when - constructing the LPC polynomials. - - - -Coefficient -NB and MB -WB - 0 0 0 - 1 9 15 - 2 6 8 - 3 3 7 - 4 4 4 - 5 5 11 - 6 8 12 - 7 1 3 - 8 2 2 - 9 7 13 -10 10 -11 5 -12 6 -13 9 -14 14 -15 1 - - - -The top 7 bits of each normalized LSF coefficient index a value in the table, - and the next 8 bits interpolate between it and the next value. -Let i = (n[k] >> 8) be the integer index and - f = (n[k] & 255) be the fractional part of a given - coefficient. -Then the re-ordered, approximated cosine, c_Q17[ordering[k]], is -
    -> 3 , -]]> -
    - where ordering[k] is the k'th entry of the column of - corresponding to the current audio - bandwidth and cos_Q12[i] is the i'th entry of . -
    - - -i -+0 -+1 -+2 -+3 -0 - 4096 4095 4091 4085 -4 - 4076 4065 4052 4036 -8 - 4017 3997 3973 3948 -12 - 3920 3889 3857 3822 -16 - 3784 3745 3703 3659 -20 - 3613 3564 3513 3461 -24 - 3406 3349 3290 3229 -28 - 3166 3102 3035 2967 -32 - 2896 2824 2751 2676 -36 - 2599 2520 2440 2359 -40 - 2276 2191 2106 2019 -44 - 1931 1842 1751 1660 -48 - 1568 1474 1380 1285 -52 - 1189 1093 995 897 -56 - 799 700 601 501 -60 - 401 301 201 101 -64 - 0 -101 -201 -301 -68 - -401 -501 -601 -700 -72 - -799 -897 -995 -1093 -76 --1189-1285-1380-1474 -80 --1568-1660-1751-1842 -84 --1931-2019-2106-2191 -88 --2276-2359-2440-2520 -92 --2599-2676-2751-2824 -96 --2896-2967-3035-3102 -100 --3166-3229-3290-3349 -104 --3406-3461-3513-3564 -108 --3613-3659-3703-3745 -112 --3784-3822-3857-3889 -116 --3920-3948-3973-3997 -120 --4017-4036-4052-4065 -124 --4076-4085-4091-4095 -128 --4096 - - - -Given the list of cosine values, silk_NLSF2A_find_poly() (NLSF2A.c) - computes the coefficients of P and Q, described here via a simple recurrence. -Let p_Q16[k][j] and q_Q16[k][j] be the coefficients of the products of the - first (k+1) root pairs for P and Q, with j indexing the coefficient number. -Only the first (k+2) coefficients are needed, as the products are symmetric. -Let p_Q16[0][0] = q_Q16[0][0] = 1<<16, - p_Q16[0][1] = -c_Q17[0], q_Q16[0][1] = -c_Q17[1], and - d2 = d_LPC/2. -As boundary conditions, assume - p_Q16[k][j] = q_Q16[k][j] = 0 for all - j < 0. -Also, assume p_Q16[k][k+2] = p_Q16[k][k] and - q_Q16[k][k+2] = q_Q16[k][k] (because of the symmetry). -Then, for 0 < k < d2 and 0 <= j <= k+1, -
    ->16) , - -q_Q16[k][j] = q_Q16[k-1][j] + q_Q16[k-1][j-2] - - ((c_Q17[2*k+1]*q_Q16[k-1][j-1] + 32768)>>16) . -]]> -
    -The use of Q17 values for the cosine terms in an otherwise Q16 expression - implicitly scales them by a factor of 2. -The multiplications in this recurrence may require up to 48 bits of precision - in the result to avoid overflow. -In practice, each row of the recurrence only depends on the previous row, so an - implementation does not need to store all of them. -
    - -silk_NLSF2A() uses the values from the last row of this recurrence to - reconstruct a 32-bit version of the LPC filter (without the leading 1.0 - coefficient), a32_Q17[k], 0 <= k < d2: -
    - -
    -The sum and difference of two terms from each of the p_Q16 and q_Q16 - coefficient lists reflect the (1 + z**-1) and - (1 - z**-1) factors of P and Q, respectively. -The promotion of the expression from Q16 to Q17 implicitly scales the result - by 1/2. -
    -
    - -
    - -The a32_Q17[] coefficients are too large to fit in a 16-bit value, which - significantly increases the cost of applying this filter in fixed-point - decoders. -Reducing them to Q12 precision doesn't incur any significant quality loss, - but still does not guarantee they will fit. -silk_NLSF2A() applies up to 10 rounds of bandwidth expansion to limit - the dynamic range of these coefficients. -Even floating-point decoders SHOULD perform these steps, to avoid mismatch. - - -For each round, the process first finds the index k such that abs(a32_Q17[k]) - is largest, breaking ties by choosing the lowest value of k. -Then, it computes the corresponding Q12 precision value, maxabs_Q12, subject to - an upper bound to avoid overflow in subsequent computations: -
    -> 5, 163838) . -]]> -
    -If this is larger than 32767, the procedure derives the chirp factor, - sc_Q16[0], to use in the bandwidth expansion as -
    -> 2 -]]> -
    - where the division here is integer division. -This is an approximation of the chirp factor needed to reduce the target - coefficient to 32767, though it is both less than 0.999 and, for - k > 0 when maxabs_Q12 is much greater than 32767, still slightly - too large. -The upper bound on maxabs_Q12, 163838, was chosen because it is equal to - ((2**31 - 1) >> 14) + 32767, i.e., the - largest value of maxabs_Q12 that would not overflow the numerator in the - equation above when stored in a signed 32-bit integer. -
    - -silk_bwexpander_32() (bwexpander_32.c) performs the bandwidth expansion (again, - only when maxabs_Q12 is greater than 32767) using the following recurrence: -
    -> 16 - -sc_Q16[k+1] = (sc_Q16[0]*sc_Q16[k] + 32768) >> 16 -]]> -
    -The first multiply may require up to 48 bits of precision in the result to - avoid overflow. -The second multiply must be unsigned to avoid overflow with only 32 bits of - precision. -The reference implementation uses a slightly more complex formulation that - avoids the 32-bit overflow using signed multiplication, but is otherwise - equivalent. -
    - -After 10 rounds of bandwidth expansion are performed, they are simply saturated - to 16 bits: -
    -> 5, 32767) << 5 . -]]> -
    -Because this performs the actual saturation in the Q12 domain, but converts the - coefficients back to the Q17 domain for the purposes of prediction gain - limiting, this step must be performed after the 10th round of bandwidth - expansion, regardless of whether or not the Q12 version of any coefficient - still overflows a 16-bit integer. -This saturation is not performed if maxabs_Q12 drops to 32767 or less prior to - the 10th round. -
    -
    - -
    - -The prediction gain of an LPC synthesis filter is the square-root of the output - energy when the filter is excited by a unit-energy impulse. -Even if the Q12 coefficients would fit, the resulting filter may still have a - significant gain (especially for voiced sounds), making the filter unstable. -silk_NLSF2A() applies up to 18 additional rounds of bandwidth expansion to - limit the prediction gain. -Instead of controlling the amount of bandwidth expansion using the prediction - gain itself (which may diverge to infinity for an unstable filter), - silk_NLSF2A() uses silk_LPC_inverse_pred_gain_QA() (LPC_inv_pred_gain.c) to - compute the reflection coefficients associated with the filter. -The filter is stable if and only if the magnitude of these coefficients is - sufficiently less than one. -The reflection coefficients, rc[k], can be computed using a simple Levinson - recurrence, initialized with the LPC coefficients - a[d_LPC-1][n] = a[n], and then updated via -
    - -
    -
    - -However, silk_LPC_inverse_pred_gain_QA() approximates this using fixed-point - arithmetic to guarantee reproducible results across platforms and - implementations. -Since small changes in the coefficients can make a stable filter unstable, it - takes the real Q12 coefficients that will be used during reconstruction as - input. -Thus, let -
    -> 5 -]]> -
    - be the Q12 version of the LPC coefficients that will eventually be used. -As a simple initial check, the decoder computes the DC response as -
    - -
    - and if DC_resp > 4096, the filter is unstable. -
    - -Increasing the precision of these Q12 coefficients to Q24 for intermediate - computations allows more accurate computation of the reflection coefficients, - so the decoder initializes the recurrence via -
    - -
    -Then for each k from d_LPC-1 down to 0, if - abs(a32_Q24[k][k]) > 16773022, the filter is unstable and the - recurrence stops. -The constant 16773022 here is approximately 0.99975 in Q24. -Otherwise, row k-1 of a32_Q24 is computed from row k as -
    -> 32) , - - b1[k] = ilog(div_Q30[k]) , - - b2[k] = b1[k] - 16 , - - (1<<29) - 1 - inv_Qb2[k] = ----------------------- , - div_Q30[k] >> (b2[k]+1) - - err_Q29[k] = (1<<29) - - ((div_Q30[k]<<(15-b2[k]))*inv_Qb2[k] >> 16) , - - gain_Qb1[k] = ((inv_Qb2[k] << 16) - + (err_Q29[k]*inv_Qb2[k] >> 13)) , - -num_Q24[k-1][n] = a32_Q24[k][n] - - ((a32_Q24[k][k-n-1]*rc_Q31[k] + (1<<30)) >> 31) , - -a32_Q24[k-1][n] = (num_Q24[k-1][n]*gain_Qb1[k] - + (1<<(b1[k]-1))) >> b1[k] , -]]> -
    - where 0 <= n < k. -Here, rc_Q30[k] are the reflection coefficients. -div_Q30[k] is the denominator for each iteration, and gain_Qb1[k] is its - multiplicative inverse (with b1[k] fractional bits, where b1[k] ranges from - 20 to 31). -inv_Qb2[k], which ranges from 16384 to 32767, is a low-precision version of - that inverse (with b2[k] fractional bits). -err_Q29[k] is the residual error, ranging from -32763 to 32392, which is used - to improve the accuracy. -The values t_Q24[k-1][n] for each n are the numerators for the next row of - coefficients in the recursion, and a32_Q24[k-1][n] is the final version of - that row. -Every multiply in this procedure except the one used to compute gain_Qb1[k] - requires more than 32 bits of precision, but otherwise all intermediate - results fit in 32 bits or less. -In practice, because each row only depends on the next one, an implementation - does not need to store them all. -
    - -If abs(a32_Q24[k][k]) <= 16773022 for - 0 <= k < d_LPC, then the filter is considered stable. -However, the problem of determining stability is ill-conditioned when the - filter contains several reflection coefficients whose magnitude is very close - to one. -This fixed-point algorithm is not mathematically guaranteed to correctly - classify filters as stable or unstable in this case, though it does very well - in practice. - - -On round i, 1 <= i <= 18, if the filter passes these - stability checks, then this procedure stops, and the final LPC coefficients to - use for reconstruction in are -
    -> 5 . -]]> -
    -Otherwise, a round of bandwidth expansion is applied using the same procedure - as in , with -
    - -
    -During the 15th round, sc_Q16[0] becomes 0 in the above equation, so a_Q12[k] - is set to 0 for all k, guaranteeing a stable filter. -
    -
    - -
    - -
    - -After the normalized LSF indices and, for 20 ms frames, the LSF - interpolation index, voiced frames (see ) - include additional LTP parameters. -There is one primary lag index for each SILK frame, but this is refined to - produce a separate lag index per subframe using a vector quantizer. -Each subframe also gets its own prediction gain coefficient. - - -
    - -The primary lag index is coded either relative to the primary lag of the prior - frame in the same channel, or as an absolute index. -Absolute coding is used if and only if - - -This is the first SILK frame of its type (LBRR or regular) for this channel in - the current Opus frame, - - -The previous SILK frame of the same type (LBRR or regular) for this channel in - the same Opus frame was not coded, or - - -That previous SILK frame was coded, but was not voiced (see - ). - - - - - -With absolute coding, the primary pitch lag may range from 2 ms - (inclusive) up to 18 ms (exclusive), corresponding to pitches from - 500 Hz down to 55.6 Hz, respectively. -It is comprised of a high part and a low part, where the decoder reads the high - part using the 32-entry codebook in - and the low part using the codebook corresponding to the current audio - bandwidth from . -The final primary pitch lag is then -
    - -
    - where lag_high is the high part, lag_low is the low part, and lag_scale - and lag_min are the values from the "Scale" and "Minimum Lag" columns of - , respectively. -
    - - -PDF -{3, 3, 6, 11, 21, 30, 32, 19, - 11, 10, 12, 13, 13, 12, 11, 9, - 8, 7, 6, 4, 2, 2, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1}/256 - - - -Audio Bandwidth -PDF -Scale -Minimum Lag -Maximum Lag -NB {64, 64, 64, 64}/256 4 16 144 -MB {43, 42, 43, 43, 42, 43}/256 6 24 216 -WB {32, 32, 32, 32, 32, 32, 32, 32}/256 8 32 288 - - - -All frames that do not use absolute coding for the primary lag index use - relative coding instead. -The decoder reads a single delta value using the 21-entry PDF in - . -If the resulting value is zero, it falls back to the absolute coding procedure - from the prior paragraph. -Otherwise, the final primary pitch lag is then -
    - -
    - where previous_lag is the primary pitch lag from the most recent frame in the - same channel and delta_lag_index is the value just decoded. -This allows a per-frame change in the pitch lag of -8 to +11 samples. -The decoder does no clamping at this point, so this value can fall outside the - range of 2 ms to 18 ms, and the decoder must use this unclamped - value when using relative coding in the next SILK frame (if any). -However, because an Opus frame can use relative coding for at most two - consecutive SILK frames, integer overflow should not be an issue. -
    - - -PDF -{46, 2, 2, 3, 4, 6, 10, 15, - 26, 38, 30, 22, 15, 10, 7, 6, - 4, 4, 2, 2, 2}/256 - - - -After the primary pitch lag, a "pitch contour", stored as a single entry from - one of four small VQ codebooks, gives lag offsets for each subframe in the - current SILK frame. -The codebook index is decoded using one of the PDFs in - depending on the current frame size - and audio bandwidth. -Tables  - through  - give the corresponding offsets to apply to the primary pitch lag for each - subframe given the decoded codebook index. - - - -Audio Bandwidth -SILK Frame Size -Codebook Size -PDF -NB 10 ms 3 -{143, 50, 63}/256 -NB 20 ms 11 -{68, 12, 21, 17, 19, 22, 30, 24, - 17, 16, 10}/256 -MB or WB 10 ms 12 -{91, 46, 39, 19, 14, 12, 8, 7, - 6, 5, 5, 4}/256 -MB or WB 20 ms 34 -{33, 22, 18, 16, 15, 14, 14, 13, - 13, 10, 9, 9, 8, 6, 6, 6, - 5, 4, 4, 4, 3, 3, 3, 2, - 2, 2, 2, 2, 2, 2, 1, 1, - 1, 1}/256 - - - -Index -Subframe Offsets -0  0  0 -1  1  0 -2  0  1 - - - -Index -Subframe Offsets - 0  0  0  0  0 - 1  2  1  0 -1 - 2 -1  0  1  2 - 3 -1  0  0  1 - 4 -1  0  0  0 - 5  0  0  0  1 - 6  0  0  1  1 - 7  1  1  0  0 - 8  1  0  0  0 - 9  0  0  0 -1 -10  1  0  0 -1 - - - -Index -Subframe Offsets - 0  0  0 - 1  0  1 - 2  1  0 - 3 -1  1 - 4  1 -1 - 5 -1  2 - 6  2 -1 - 7 -2  2 - 8  2 -2 - 9 -2  3 -10  3 -2 -11 -3  3 - - - -Index -Subframe Offsets - 0  0  0  0  0 - 1  0  0  1  1 - 2  1  1  0  0 - 3 -1  0  0  0 - 4  0  0  0  1 - 5  1  0  0  0 - 6 -1  0  0  1 - 7  0  0  0 -1 - 8 -1  0  1  2 - 9  1  0  0 -1 -10 -2 -1  1  2 -11  2  1  0 -1 -12 -2  0  0  2 -13 -2  0  1  3 -14  2  1 -1 -2 -15 -3 -1  1  3 -16  2  0  0 -2 -17  3  1  0 -2 -18 -3 -1  2  4 -19 -4 -1  1  4 -20  3  1 -1 -3 -21 -4 -1  2  5 -22  4  2 -1 -3 -23  4  1 -1 -4 -24 -5 -1  2  6 -25  5  2 -1 -4 -26 -6 -2  2  6 -27 -5 -2  2  5 -28  6  2 -1 -5 -29 -7 -2  3  8 -30  6  2 -2 -6 -31  5  2 -2 -5 -32  8  3 -2 -7 -33 -9 -3  3  9 - - - -The final pitch lag for each subframe is assembled in silk_decode_pitch() - (decode_pitch.c). -Let lag be the primary pitch lag for the current SILK frame, contour_index be - index of the VQ codebook, and lag_cb[contour_index][k] be the corresponding - entry of the codebook from the appropriate table given above for the k'th - subframe. -Then the final pitch lag for that subframe is -
    - -
    - where lag_min and lag_max are the values from the "Minimum Lag" and - "Maximum Lag" columns of , - respectively. -
    - -
    - -
    - -SILK uses a separate 5-tap pitch filter for each subframe, selected from one - of three codebooks. -The three codebooks each represent different rate-distortion trade-offs, with - average rates of 1.61 bits/subframe, 3.68 bits/subframe, and - 4.85 bits/subframe, respectively. - - - -The importance of the filter coefficients generally depends on two factors: the - periodicity of the signal and relative energy between the current subframe and - the signal from one period earlier. -Greater periodicity and decaying energy both lead to more important filter - coefficients, and thus should be coded with lower distortion and higher rate. -These properties are relatively stable over the duration of a single SILK - frame, hence all of the subframes in a SILK frame choose their filter from the - same codebook. -This is signaled with an explicitly-coded "periodicity index". -This immediately follows the subframe pitch lags, and is coded using the - 3-entry PDF from . - - - -PDF -{77, 80, 99}/256 - - - -The indices of the filters for each subframe follow. -They are all coded using the PDF from - corresponding to the periodicity index. -Tables  - through  - contain the corresponding filter taps as signed Q7 integers. - - - -Periodicity Index -Codebook Size -PDF -0 8 {185, 15, 13, 13, 9, 9, 6, 6}/256 -1 16 {57, 34, 21, 20, 15, 13, 12, 13, - 10, 10, 9, 10, 9, 8, 7, 8}/256 -2 32 {15, 16, 14, 12, 12, 12, 11, 11, - 11, 10, 9, 9, 9, 9, 8, 8, - 8, 8, 7, 7, 6, 6, 5, 4, - 5, 4, 4, 4, 3, 4, 3, 2}/256 - - - -Index -Filter Taps (Q7) - 0 -  4   6  24   7   5 - 1 -  0   0   2   0   0 - 2 - 12  28  41  13  -4 - 3 - -9  15  42  25  14 - 4 -  1  -2  62  41  -9 - 5 --10  37  65  -4   3 - 6 - -6   4  66   7  -8 - 7 - 16  14  38  -3  33 - - - -Index -Filter Taps (Q7) - - 0 - 13  22  39  23  12 - 1 - -1  36  64  27  -6 - 2 - -7  10  55  43  17 - 3 -  1   1   8   1   1 - 4 -  6 -11  74  53  -9 - 5 --12  55  76 -12   8 - 6 - -3   3  93  27  -4 - 7 - 26  39  59   3  -8 - 8 -  2   0  77  11   9 - 9 - -8  22  44  -6   7 -10 - 40   9  26   3   9 -11 - -7  20 101  -7   4 -12 -  3  -8  42  26   0 -13 --15  33  68   2  23 -14 - -2  55  46  -2  15 -15 -  3  -1  21  16  41 - - - -Index -Filter Taps (Q7) - 0 - -6  27  61  39   5 - 1 --11  42  88   4   1 - 2 - -2  60  65   6  -4 - 3 - -1  -5  73  56   1 - 4 - -9  19  94  29  -9 - 5 -  0  12  99   6   4 - 6 -  8 -19 102  46 -13 - 7 -  3   2  13   3   2 - 8 -  9 -21  84  72 -18 - 9 --11  46 104 -22   8 -10 - 18  38  48  23   0 -11 --16  70  83 -21  11 -12 -  5 -11 117  22  -8 -13 - -6  23 117 -12   3 -14 -  3  -8  95  28   4 -15 --10  15  77  60 -15 -16 - -1   4 124   2  -4 -17 -  3  38  84  24 -25 -18 -  2  13  42  13  31 -19 - 21  -4  56  46  -1 -20 - -1  35  79 -13  19 -21 - -7  65  88  -9 -14 -22 - 20   4  81  49 -29 -23 - 20   0  75   3 -17 -24 -  5  -9  44  92  -8 -25 -  1  -3  22  69  31 -26 - -6  95  41 -12   5 -27 - 39  67  16  -4   1 -28 -  0  -6 120  55 -36 -29 --13  44 122   4 -24 -30 - 81   5  11   3   7 -31 -  2   0   9  10  88 - - -
    - -
    - -An LTP scaling parameter appears after the LTP filter coefficients if and only - if - -This is a voiced frame (see ), and -Either - - -This SILK frame corresponds to the first time interval of the - current Opus frame for its type (LBRR or regular), or - - -This is an LBRR frame where the LBRR flags (see - ) indicate the previous LBRR frame in the same - channel is not coded. - - - - -This allows the encoder to trade off the prediction gain between - packets against the recovery time after packet loss. -Unlike absolute-coding for pitch lags, regular SILK frames that are not at the - start of an Opus frame (i.e., that do not correspond to the first 20 ms - time interval in Opus frames of 40 or 60 ms) do not include this - field, even if the prior frame was not voiced, or (in the case of the side - channel) not even coded. -After an uncoded frame in the side channel, the LTP buffer (see - ) is cleared to zero, and is thus in a - known state. -In contrast, LBRR frames do include this field when the prior frame was not - coded, since the LTP buffer contains the output of the PLC, which is - non-normative. - - -If present, the decoder reads a value using the 3-entry PDF in - . -The three possible values represent Q14 scale factors of 15565, 12288, and - 8192, respectively (corresponding to approximately 0.95, 0.75, and 0.5). -Frames that do not code the scaling parameter use the default factor of 15565 - (approximately 0.95). - - - -PDF -{128, 64, 64}/256 - - -
    - -
    - -
    - -As described in , SILK uses a - linear congruential generator (LCG) to inject pseudorandom noise into the - quantized excitation. -To ensure synchronization of this process between the encoder and decoder, each - SILK frame stores a 2-bit seed after the LTP parameters (if any). -The encoder may consider the choice of seed during quantization, and the - flexibility of this choice lets it reduce distortion, helping to pay for the - bit cost required to signal it. -The decoder reads the seed using the uniform 4-entry PDF in - , yielding a value between 0 and 3, inclusive. - - - -PDF -{64, 64, 64, 64}/256 - - -
    - -
    - -SILK codes the excitation using a modified version of the Pyramid Vector - Quantization (PVQ) codebook . -The PVQ codebook is designed for Laplace-distributed values and consists of all - sums of K signed, unit pulses in a vector of dimension N, where two pulses at - the same position are required to have the same sign. -Thus the codebook includes all integer codevectors y of dimension N that - satisfy -
    - -
    -Unlike regular PVQ, SILK uses a variable-length, rather than fixed-length, - encoding. -This encoding is better suited to the more Gaussian-like distribution of the - coefficient magnitudes and the non-uniform distribution of their signs (caused - by the quantization offset described below). -SILK also handles large codebooks by coding the least significant bits (LSBs) - of each coefficient directly. -This adds a small coding efficiency loss, but greatly reduces the computation - time and ROM size required for decoding, as implemented in - silk_decode_pulses() (decode_pulses.c). -
    - - -SILK fixes the dimension of the codebook to N = 16. -The excitation is made up of a number of "shell blocks", each 16 samples in - size. - lists the number of shell blocks - required for a SILK frame for each possible audio bandwidth and frame size. -10 ms MB frames nominally contain 120 samples (10 ms at - 12 kHz), which is not a multiple of 16. -This is handled by coding 8 shell blocks (128 samples) and discarding the final - 8 samples of the last block. -The decoder contains no special case that prevents an encoder from placing - pulses in these samples, and they must be correctly parsed from the bitstream - if present, but they are otherwise ignored. - - - -Audio Bandwidth -Frame Size -Number of Shell Blocks -NB 10 ms 5 -MB 10 ms 8 -WB 10 ms 10 -NB 20 ms 10 -MB 20 ms 15 -WB 20 ms 20 - - -
    - -The first symbol in the excitation is a "rate level", which is an index from 0 - to 8, inclusive, coded using the PDF in - corresponding to the signal type of the current frame (from - ). -The rate level selects the PDF used to decode the number of pulses in - the individual shell blocks. -It does not directly convey any information about the bitrate or the number of - pulses itself, but merely changes the probability of the symbols in - . -Level 0 provides a more efficient encoding at low rates generally, and - level 8 provides a more efficient encoding at high rates generally, - though the most efficient level for a particular SILK frame may depend on the - exact distribution of the coded symbols. -An encoder should, but is not required to, use the most efficient rate level. - - - -Signal Type -PDF -Inactive or Unvoiced -{15, 51, 12, 46, 45, 13, 33, 27, 14}/256 -Voiced -{33, 30, 36, 17, 34, 49, 18, 21, 18}/256 - - -
    - -
    - -The total number of pulses in each of the shell blocks follows the rate level. -The pulse counts for all of the shell blocks are coded consecutively, before - the content of any of the blocks. -Each block may have anywhere from 0 to 16 pulses, inclusive, coded using the - 18-entry PDF in corresponding to the - rate level from . -The special value 17 indicates that this block has one or more additional - LSBs to decode for each coefficient. -If the decoder encounters this value, it decodes another value for the actual - pulse count of the block, but uses the PDF corresponding to the special rate - level 9 instead of the normal rate level. -This process repeats until the decoder reads a value less than 17, and it then - sets the number of extra LSBs used to the number of 17's decoded for that - block. -If it reads the value 17 ten times, then the next iteration uses the special - rate level 10 instead of 9. -The probability of decoding a 17 when using the PDF for rate level 10 is - zero, ensuring that the number of LSBs for a block will not exceed 10. -The cumulative distribution for rate level 10 is just a shifted version of - that for 9 and thus does not require any additional storage. - - - -Rate Level -PDF -0 -{131, 74, 25, 8, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}/256 -1 -{58, 93, 60, 23, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}/256 -2 -{43, 51, 46, 33, 24, 16, 11, 8, 6, 3, 3, 3, 2, 1, 1, 2, 1, 2}/256 -3 -{17, 52, 71, 57, 31, 12, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}/256 -4 -{6, 21, 41, 53, 49, 35, 21, 11, 6, 3, 2, 2, 1, 1, 1, 1, 1, 1}/256 -5 -{7, 14, 22, 28, 29, 28, 25, 20, 17, 13, 11, 9, 7, 5, 4, 4, 3, 10}/256 -6 -{2, 5, 14, 29, 42, 46, 41, 31, 19, 11, 6, 3, 2, 1, 1, 1, 1, 1}/256 -7 -{1, 2, 4, 10, 19, 29, 35, 37, 34, 28, 20, 14, 8, 5, 4, 2, 2, 2}/256 -8 -{1, 2, 2, 5, 9, 14, 20, 24, 27, 28, 26, 23, 20, 15, 11, 8, 6, 15}/256 -9 -{1, 1, 1, 6, 27, 58, 56, 39, 25, 14, 10, 6, 3, 3, 2, 1, 1, 2}/256 -10 -{2, 1, 6, 27, 58, 56, 39, 25, 14, 10, 6, 3, 3, 2, 1, 1, 2, 0}/256 - - -
    - -
    - -The locations of the pulses in each shell block follow the pulse counts, - as decoded by silk_shell_decoder() (shell_coder.c). -As with the pulse counts, these locations are coded for all the shell blocks - before any of the remaining information for each block. -Unlike many other codecs, SILK places no restriction on the distribution of - pulses within a shell block. -All of the pulses may be placed in a single location, or each one in a unique - location, or anything in between. - - - -The location of pulses is coded by recursively partitioning each block into - halves, and coding how many pulses fall on the left side of the split. -All remaining pulses must fall on the right side of the split. -The process then recurses into the left half, and after that returns, the - right half (preorder traversal). -The PDF to use is chosen by the size of the current partition (16, 8, 4, or 2) - and the number of pulses in the partition (1 to 16, inclusive). -Tables  - through  list the - PDFs used for each partition size and pulse count. -This process skips partitions without any pulses, i.e., where the initial pulse - count from was zero, or where the split in - the prior level indicated that all of the pulses fell on the other side. -These partitions have nothing to code, so they require no PDF. - - - -Pulse Count -PDF - 1 {126, 130}/256 - 2 {56, 142, 58}/256 - 3 {25, 101, 104, 26}/256 - 4 {12, 60, 108, 64, 12}/256 - 5 {7, 35, 84, 87, 37, 6}/256 - 6 {4, 20, 59, 86, 63, 21, 3}/256 - 7 {3, 12, 38, 72, 75, 42, 12, 2}/256 - 8 {2, 8, 25, 54, 73, 59, 27, 7, 1}/256 - 9 {2, 5, 17, 39, 63, 65, 42, 18, 4, 1}/256 -10 {1, 4, 12, 28, 49, 63, 54, 30, 11, 3, 1}/256 -11 {1, 4, 8, 20, 37, 55, 57, 41, 22, 8, 2, 1}/256 -12 {1, 3, 7, 15, 28, 44, 53, 48, 33, 16, 6, 1, 1}/256 -13 {1, 2, 6, 12, 21, 35, 47, 48, 40, 25, 12, 5, 1, 1}/256 -14 {1, 1, 4, 10, 17, 27, 37, 47, 43, 33, 21, 9, 4, 1, 1}/256 -15 {1, 1, 1, 8, 14, 22, 33, 40, 43, 38, 28, 16, 8, 1, 1, 1}/256 -16 {1, 1, 1, 1, 13, 18, 27, 36, 41, 41, 34, 24, 14, 1, 1, 1, 1}/256 - - - -Pulse Count -PDF - 1 {127, 129}/256 - 2 {53, 149, 54}/256 - 3 {22, 105, 106, 23}/256 - 4 {11, 61, 111, 63, 10}/256 - 5 {6, 35, 86, 88, 36, 5}/256 - 6 {4, 20, 59, 87, 62, 21, 3}/256 - 7 {3, 13, 40, 71, 73, 41, 13, 2}/256 - 8 {3, 9, 27, 53, 70, 56, 28, 9, 1}/256 - 9 {3, 8, 19, 37, 57, 61, 44, 20, 6, 1}/256 -10 {3, 7, 15, 28, 44, 54, 49, 33, 17, 5, 1}/256 -11 {1, 7, 13, 22, 34, 46, 48, 38, 28, 14, 4, 1}/256 -12 {1, 1, 11, 22, 27, 35, 42, 47, 33, 25, 10, 1, 1}/256 -13 {1, 1, 6, 14, 26, 37, 43, 43, 37, 26, 14, 6, 1, 1}/256 -14 {1, 1, 4, 10, 20, 31, 40, 42, 40, 31, 20, 10, 4, 1, 1}/256 -15 {1, 1, 3, 8, 16, 26, 35, 38, 38, 35, 26, 16, 8, 3, 1, 1}/256 -16 {1, 1, 2, 6, 12, 21, 30, 36, 38, 36, 30, 21, 12, 6, 2, 1, 1}/256 - - - -Pulse Count -PDF - 1 {127, 129}/256 - 2 {49, 157, 50}/256 - 3 {20, 107, 109, 20}/256 - 4 {11, 60, 113, 62, 10}/256 - 5 {7, 36, 84, 87, 36, 6}/256 - 6 {6, 24, 57, 82, 60, 23, 4}/256 - 7 {5, 18, 39, 64, 68, 42, 16, 4}/256 - 8 {6, 14, 29, 47, 61, 52, 30, 14, 3}/256 - 9 {1, 15, 23, 35, 51, 50, 40, 30, 10, 1}/256 -10 {1, 1, 21, 32, 42, 52, 46, 41, 18, 1, 1}/256 -11 {1, 6, 16, 27, 36, 42, 42, 36, 27, 16, 6, 1}/256 -12 {1, 5, 12, 21, 31, 38, 40, 38, 31, 21, 12, 5, 1}/256 -13 {1, 3, 9, 17, 26, 34, 38, 38, 34, 26, 17, 9, 3, 1}/256 -14 {1, 3, 7, 14, 22, 29, 34, 36, 34, 29, 22, 14, 7, 3, 1}/256 -15 {1, 2, 5, 11, 18, 25, 31, 35, 35, 31, 25, 18, 11, 5, 2, 1}/256 -16 {1, 1, 4, 9, 15, 21, 28, 32, 34, 32, 28, 21, 15, 9, 4, 1, 1}/256 - - - -Pulse Count -PDF - 1 {128, 128}/256 - 2 {42, 172, 42}/256 - 3 {21, 107, 107, 21}/256 - 4 {12, 60, 112, 61, 11}/256 - 5 {8, 34, 86, 86, 35, 7}/256 - 6 {8, 23, 55, 90, 55, 20, 5}/256 - 7 {5, 15, 38, 72, 72, 36, 15, 3}/256 - 8 {6, 12, 27, 52, 77, 47, 20, 10, 5}/256 - 9 {6, 19, 28, 35, 40, 40, 35, 28, 19, 6}/256 -10 {4, 14, 22, 31, 37, 40, 37, 31, 22, 14, 4}/256 -11 {3, 10, 18, 26, 33, 38, 38, 33, 26, 18, 10, 3}/256 -12 {2, 8, 13, 21, 29, 36, 38, 36, 29, 21, 13, 8, 2}/256 -13 {1, 5, 10, 17, 25, 32, 38, 38, 32, 25, 17, 10, 5, 1}/256 -14 {1, 4, 7, 13, 21, 29, 35, 36, 35, 29, 21, 13, 7, 4, 1}/256 -15 {1, 2, 5, 10, 17, 25, 32, 36, 36, 32, 25, 17, 10, 5, 2, 1}/256 -16 {1, 2, 4, 7, 13, 21, 28, 34, 36, 34, 28, 21, 13, 7, 4, 2, 1}/256 - - -
    - -
    - -After the decoder reads the pulse locations for all blocks, it reads the LSBs - (if any) for each block in turn. -Inside each block, it reads all the LSBs for each coefficient in turn, even - those where no pulses were allocated, before proceeding to the next one. -For 10 ms MB frames, it reads LSBs even for the extra 8 samples in - the last block. -The LSBs are coded from most significant to least significant, and they all use - the PDF in . - - - -PDF -{136, 120}/256 - - - -The number of LSBs read for each coefficient in a block is determined in - . -The magnitude of the coefficient is initially equal to the number of pulses - placed at that location in . -As each LSB is decoded, the magnitude is doubled, and then the value of the LSB - added to it, to obtain an updated magnitude. - -
    - -
    - -After decoding the pulse locations and the LSBs, the decoder knows the - magnitude of each coefficient in the excitation. -It then decodes a sign for all coefficients with a non-zero magnitude, using - one of the PDFs from . -If the value decoded is 0, then the coefficient magnitude is negated. -Otherwise, it remains positive. - - - -The decoder chooses the PDF for the sign based on the signal type and - quantization offset type (from ) and the - number of pulses in the block (from ). -The number of pulses in the block does not take into account any LSBs. -Most PDFs are skewed towards negative signs because of the quantization offset, - but the PDFs for zero pulses are highly skewed towards positive signs. -If a block contains many positive coefficients, it is sometimes beneficial to - code it solely using LSBs (i.e., with zero pulses), since the encoder may be - able to save enough bits on the signs to justify the less efficient - coefficient magnitude encoding. - - - -Signal Type -Quantization Offset Type -Pulse Count -PDF -Inactive Low 0 {2, 254}/256 -Inactive Low 1 {207, 49}/256 -Inactive Low 2 {189, 67}/256 -Inactive Low 3 {179, 77}/256 -Inactive Low 4 {174, 82}/256 -Inactive Low 5 {163, 93}/256 -Inactive Low 6 or more {157, 99}/256 -Inactive High 0 {58, 198}/256 -Inactive High 1 {245, 11}/256 -Inactive High 2 {238, 18}/256 -Inactive High 3 {232, 24}/256 -Inactive High 4 {225, 31}/256 -Inactive High 5 {220, 36}/256 -Inactive High 6 or more {211, 45}/256 -Unvoiced Low 0 {1, 255}/256 -Unvoiced Low 1 {210, 46}/256 -Unvoiced Low 2 {190, 66}/256 -Unvoiced Low 3 {178, 78}/256 -Unvoiced Low 4 {169, 87}/256 -Unvoiced Low 5 {162, 94}/256 -Unvoiced Low 6 or more {152, 104}/256 -Unvoiced High 0 {48, 208}/256 -Unvoiced High 1 {242, 14}/256 -Unvoiced High 2 {235, 21}/256 -Unvoiced High 3 {224, 32}/256 -Unvoiced High 4 {214, 42}/256 -Unvoiced High 5 {205, 51}/256 -Unvoiced High 6 or more {190, 66}/256 -Voiced Low 0 {1, 255}/256 -Voiced Low 1 {162, 94}/256 -Voiced Low 2 {152, 104}/256 -Voiced Low 3 {147, 109}/256 -Voiced Low 4 {144, 112}/256 -Voiced Low 5 {141, 115}/256 -Voiced Low 6 or more {138, 118}/256 -Voiced High 0 {8, 248}/256 -Voiced High 1 {203, 53}/256 -Voiced High 2 {187, 69}/256 -Voiced High 3 {176, 80}/256 -Voiced High 4 {168, 88}/256 -Voiced High 5 {161, 95}/256 -Voiced High 6 or more {154, 102}/256 - - -
    - -
    - - -After the signs have been read, there is enough information to reconstruct the - complete excitation signal. -This requires adding a constant quantization offset to each non-zero sample, - and then pseudorandomly inverting and offsetting every sample. -The constant quantization offset varies depending on the signal type and - quantization offset type (see ). - - - -Signal Type -Quantization Offset Type -Quantization Offset (Q23) -Inactive Low 25 -Inactive High 60 -Unvoiced Low 25 -Unvoiced High 60 -Voiced Low 8 -Voiced High 25 - - - -Let e_raw[i] be the raw excitation value at position i, with a magnitude - composed of the pulses at that location (see - ) combined with any additional LSBs (see - ), and with the corresponding sign decoded in - . -Additionally, let seed be the current pseudorandom seed, which is initialized - to the value decoded from for the first sample in - the current SILK frame, and updated for each subsequent sample according to - the procedure below. -Finally, let offset_Q23 be the quantization offset from - . -Then the following procedure produces the final reconstructed excitation value, - e_Q23[i]: -
    - -
    -When e_raw[i] is zero, sign() returns 0 by the definition in - , so the factor of 20 does not get added. -The final e_Q23[i] value may require more than 16 bits per sample, but will not - require more than 23, including the sign. -
    - -
    - -
    - -
    - - -The remainder of the reconstruction process for the frame does not need to be - bit-exact, as small errors should only introduce proportionally small - distortions. -Although the reference implementation only includes a fixed-point version of - the remaining steps, this section describes them in terms of a floating-point - version for simplicity. -This produces a signal with a nominal range of -1.0 to 1.0. - - - -silk_decode_core() (decode_core.c) contains the code for the main - reconstruction process. -It proceeds subframe-by-subframe, since quantization gains, LTP parameters, and - (in 20 ms SILK frames) LPC coefficients can vary from one to the - next. - - - -Let a_Q12[k] be the LPC coefficients for the current subframe. -If this is the first or second subframe of a 20 ms SILK frame and the LSF - interpolation factor, w_Q2 (see ), is - less than 4, then these correspond to the final LPC coefficients produced by - from the interpolated LSF coefficients, - n1_Q15[k] (computed in ). -Otherwise, they correspond to the final LPC coefficients produced from the - uninterpolated LSF coefficients for the current frame, n2_Q15[k]. - - - -Also, let n be the number of samples in a subframe (40 for NB, 60 for MB, and - 80 for WB), s be the index of the current subframe in this SILK frame (0 or 1 - for 10 ms frames, or 0 to 3 for 20 ms frames), and j be the index of - the first sample in the residual corresponding to the current subframe. - - -
    - -Voiced SILK frames (see ) pass the excitation - through an LTP filter using the parameters decoded in - to produce an LPC residual. -The LTP filter requires LPC residual values from before the current subframe as - input. -However, since the LPC coefficients may have changed, it obtains this residual - by "rewhitening" the corresponding output signal using the LPC coefficients - from the current subframe. -Let out[i] for - (j - pitch_lags[s] - d_LPC - 2) <= i < j - be the fully reconstructed output signal from the last - (pitch_lags[s] + d_LPC + 2) samples of previous subframes - (see ), where pitch_lags[s] is the pitch - lag for the current subframe from . -During reconstruction of the first subframe for this channel after either - -An uncoded regular SILK frame (if this is the side channel), or -A decoder reset (see ), - - out[] is rewhitened into an LPC residual, - res[i], via -
    - -
    -This requires storage to buffer up to 306 values of out[i] from previous - subframes. -This corresponds to WB with a maximum pitch lag of - 18 ms * 16 kHz samples, plus 16 samples for d_LPC, plus 2 - samples for the width of the LTP filter. -
    - - -Let e_Q23[i] for j <= i < (j + n) be the - excitation for the current subframe, and b_Q7[k] for - 0 <= k < 5 be the coefficients of the LTP filter - taken from the codebook entry in one of - Tables  - through  - corresponding to the index decoded for the current subframe in - . -Then for i such that j <= i < (j + n), - the LPC residual is -
    - -
    -
    - - -For unvoiced frames, the LPC residual for - j <= i < (j + n) is simply a normalized - copy of the excitation signal, i.e., -
    - -
    -
    -
    - -
    - -LPC synthesis uses the short-term LPC filter to predict the next output - coefficient. -For i such that (j - d_LPC) <= i < j, let - lpc[i] be the result of LPC synthesis from the last d_LPC samples of the - previous subframe, or zeros in the first subframe for this channel after - either - -An uncoded regular SILK frame (if this is the side channel), or -A decoder reset (see ). - -Then for i such that j <= i < (j + n), the - result of LPC synthesis for the current subframe is -
    - -
    -The decoder saves the final d_LPC values, i.e., lpc[i] such that - (j + n - d_LPC) <= i < (j + n), - to feed into the LPC synthesis of the next subframe. -This requires storage for up to 16 values of lpc[i] (for WB frames). -
    - - -Then, the signal is clamped into the final nominal range: -
    - -
    -This clamping occurs entirely after the LPC synthesis filter has run. -The decoder saves the unclamped values, lpc[i], to feed into the LPC filter for - the next subframe, but saves the clamped values, out[i], for rewhitening in - voiced frames. -
    -
    - -
    - -
    - -
    - -For stereo streams, after decoding a frame from each channel, the decoder must - convert the mid-side (MS) representation into a left-right (LR) - representation. -The function silk_stereo_MS_to_LR (stereo_MS_to_LR.c) implements this process. -In it, the decoder predicts the side channel using a) a simple low-passed - version of the mid channel, and b) the unfiltered mid channel, using the - prediction weights decoded in . -This simple low-pass filter imposes a one-sample delay, and the unfiltered -mid channel is also delayed by one sample. -In order to allow seamless switching between stereo and mono, mono streams must - also impose the same one-sample delay. -The encoder requires an additional one-sample delay for both mono and stereo - streams, though an encoder may omit the delay for mono if it knows it will - never switch to stereo. - - - -The unmixing process operates in two phases. -The first phase lasts for 8 ms, during which it interpolates the - prediction weights from the previous frame, prev_w0_Q13 and prev_w1_Q13, to - the values for the current frame, w0_Q13 and w1_Q13. -The second phase simply uses these weights for the remainder of the frame. - - - -Let mid[i] and side[i] be the contents of out[i] (from - ) for the current mid and side channels, - respectively, and let left[i] and right[i] be the corresponding stereo output - channels. -If the side channel is not coded (see ), - then side[i] is set to zero. -Also let j be defined as in , n1 be - the number of samples in phase 1 (64 for NB, 96 for MB, and 128 for WB), - and n2 be the total number of samples in the frame. -Then for i such that j <= i < (j + n2), - the left and right channel output is -
    - -
    -These formulas require two samples prior to index j, the start of the - frame, for the mid channel, and one prior sample for the side channel. -For the first frame after a decoder reset, zeros are used instead. -
    - -
    - -
    - -After stereo unmixing (if any), the decoder applies resampling to convert the - decoded SILK output to the sample rate desired by the application. -This is necessary when decoding a Hybrid frame at SWB or FB sample rates, or - whenever the decoder wants the output at a different sample rate than the - internal SILK sampling rate (e.g., to allow a constant sample rate when the - audio bandwidth changes, or to allow mixing with audio from other - applications). -The resampler itself is non-normative, and a decoder can use any method it - wants to perform the resampling. - - - -However, a minimum amount of delay is imposed to allow the resampler to - operate, and this delay is normative, so that the corresponding delay can be - applied to the MDCT layer in the encoder. -A decoder is always free to use a resampler which requires more delay than - allowed for here (e.g., to improve quality), but it must then delay the output - of the MDCT layer by this extra amount. -Keeping as much delay as possible on the encoder side allows an encoder which - knows it will never use any of the SILK or Hybrid modes to skip this delay. -By contrast, if it were all applied by the decoder, then a decoder which - processes audio in fixed-size blocks would be forced to delay the output of - CELT frames just in case of a later switch to a SILK or Hybrid mode. - - - - gives the maximum resampler delay - in samples at 48 kHz for each SILK audio bandwidth. -Because the actual output rate may not be 48 kHz, it may not be possible - to achieve exactly these delays while using a whole number of input or output - samples. -The reference implementation is able to resample to any of the supported - output sampling rates (8, 12, 16, 24, or 48 kHz) within or near this - delay constraint. -Some resampling filters (including those used by the reference implementation) - may add a delay that is not an exact integer, or is not linear-phase, and so - cannot be represented by a single delay at all frequencies. -However, such deviations are unlikely to be perceptible, and the comparison - tool described in is designed to be relatively - insensitive to them. -The delays listed here are the ones that should be targeted by the encoder. - - - -Audio Bandwidth -Delay in millisecond -NB 0.538 -MB 0.692 -WB 0.706 - - - -NB is given a smaller decoder delay allocation than MB and WB to allow a - higher-order filter when resampling to 8 kHz in both the encoder and - decoder. -This implies that the audio content of two SILK frames operating at different - bandwidths are not perfectly aligned in time. -This is not an issue for any transitions described in - , because they all involve a SILK decoder reset. -When the decoder is reset, any samples remaining in the resampling buffer - are discarded, and the resampler is re-initialized with silence. - - -
    - -
    - - -
    - - -The CELT layer of Opus is based on the Modified Discrete Cosine Transform - with partially overlapping windows of 5 to 22.5 ms. -The main principle behind CELT is that the MDCT spectrum is divided into -bands that (roughly) follow the Bark scale, i.e., the scale of the ear's -critical bands . The normal CELT layer uses 21 of those bands, though Opus - Custom (see ) may use a different number of bands. -In Hybrid mode, the first 17 bands (up to 8 kHz) are not coded. -A band can contain as little as one MDCT bin per channel, and as many as 176 -bins per channel, as detailed in . -In each band, the gain (energy) is coded separately from -the shape of the spectrum. Coding the gain explicitly makes it easy to -preserve the spectral envelope of the signal. The remaining unit-norm shape -vector is encoded using a Pyramid Vector Quantizer (PVQ) . - - - -Frame Size: -2.5 ms -5 ms -10 ms -20 ms -Start Frequency -Stop Frequency -Band Bins: - 0 1 2 4 8 0 Hz 200 Hz - 1 1 2 4 8 200 Hz 400 Hz - 2 1 2 4 8 400 Hz 600 Hz - 3 1 2 4 8 600 Hz 800 Hz - 4 1 2 4 8 800 Hz 1000 Hz - 5 1 2 4 8 1000 Hz 1200 Hz - 6 1 2 4 8 1200 Hz 1400 Hz - 7 1 2 4 8 1400 Hz 1600 Hz - 8 2 4 8 16 1600 Hz 2000 Hz - 9 2 4 8 16 2000 Hz 2400 Hz -10 2 4 8 16 2400 Hz 2800 Hz -11 2 4 8 16 2800 Hz 3200 Hz -12 4 8 16 32 3200 Hz 4000 Hz -13 4 8 16 32 4000 Hz 4800 Hz -14 4 8 16 32 4800 Hz 5600 Hz -15 6 12 24 48 5600 Hz 6800 Hz -16 6 12 24 48 6800 Hz 8000 Hz -17 8 16 32 64 8000 Hz 9600 Hz -18 12 24 48 96 9600 Hz 12000 Hz -19 18 36 72 144 12000 Hz 15600 Hz -20 22 44 88 176 15600 Hz 20000 Hz - - - -Transients are notoriously difficult for transform codecs to code. -CELT uses two different strategies for them: - -Using multiple smaller MDCTs instead of a single large MDCT, and -Dynamic time-frequency resolution changes (See ). - -To improve quality on highly tonal and periodic signals, CELT includes -a prefilter/postfilter combination. The prefilter on the encoder side -attenuates the signal's harmonics. The postfilter on the decoder side -restores the original gain of the harmonics, while shaping the coding noise -to roughly follow the harmonics. Such noise shaping reduces the perception -of the noise. - - - -When coding a stereo signal, three coding methods are available: - -mid-side stereo: encodes the mean and the difference of the left and right channels, -intensity stereo: only encodes the mean of the left and right channels (discards the difference), -dual stereo: encodes the left and right channels separately. - - - - -An overview of the decoder is given in . - - -
    -| decoder |----+ - | +---------+ | - | | - | +---------+ v - | | Fine | +---+ - +->| decoder |->| + | - | +---------+ +---+ - | ^ | -+---------+ | | | -| Range | | +----------+ v -| Decoder |-+ | Bit | +------+ -+---------+ | |Allocation| | 2**x | - | +----------+ +------+ - | | | - | v v +--------+ - | +---------+ +---+ +-------+ | pitch | - +->| PVQ |->| * |->| IMDCT |->| post- |---> - | | decoder | +---+ +-------+ | filter | - | +---------+ +--------+ - | ^ - +--------------------------------------+ -]]> -
    - - -The decoder is based on the following symbols and sets of symbols: - - - -Symbol(s) -PDF -Condition -silence {32767, 1}/32768 -post-filter {1, 1}/2 -octave uniform (6)post-filter -period raw bits (4+octave)post-filter -gain raw bits (3)post-filter -tapset {2, 1, 1}/4post-filter -transient {7, 1}/8 -intra {7, 1}/8 -coarse energy -tf_change -tf_select {1, 1}/2 -spread {7, 2, 21, 2}/32 -dyn. alloc. -alloc. trim {2, 2, 5, 10, 22, 46, 22, 10, 5, 2, 2}/128 -skip {1, 1}/2 -intensity uniform -dual {1, 1}/2 -fine energy -residual -anti-collapse{1, 1}/2 -finalize - - - -The decoder extracts information from the range-coded bitstream in the order -described in . In some circumstances, it is -possible for a decoded value to be out of range due to a very small amount of redundancy -in the encoding of large integers by the range coder. -In that case, the decoder should assume there has been an error in the coding, -decoding, or transmission and SHOULD take measures to conceal the error and/or report -to the application that a problem has occurred. Such out of range errors cannot occur -in the SILK layer. - - -
    - -The "transient" flag indicates whether the frame uses a single long MDCT or several short MDCTs. -When it is set, then the MDCT coefficients represent multiple -short MDCTs in the frame. When not set, the coefficients represent a single -long MDCT for the frame. The flag is encoded in the bitstream with a probability of 1/8. -In addition to the global transient flag is a per-band -binary flag to change the time-frequency (tf) resolution independently in each band. The -change in tf resolution is defined in tf_select_table[][] in celt.c and depends -on the frame size, whether the transient flag is set, and the value of tf_select. -The tf_select flag uses a 1/2 probability, but is only decoded -if it can have an impact on the result knowing the value of all per-band -tf_change flags. - -
    - -
    - - -It is important to quantize the energy with sufficient resolution because -any energy quantization error cannot be compensated for at a later -stage. Regardless of the resolution used for encoding the spectral shape of a band, -it is perceptually important to preserve the energy in each band. CELT uses a -three-step coarse-fine-fine strategy for encoding the energy in the base-2 log -domain, as implemented in quant_bands.c - -
    - -Coarse quantization of the energy uses a fixed resolution of 6 dB -(integer part of base-2 log). To minimize the bitrate, prediction is applied -both in time (using the previous frame) and in frequency (using the previous -bands). The part of the prediction that is based on the -previous frame can be disabled, creating an "intra" frame where the energy -is coded without reference to prior frames. The decoder first reads the intra flag -to determine what prediction is used. -The 2-D z-transform of -the prediction filter is: -
    - -
    -where b is the band index and l is the frame index. The prediction coefficients -applied depend on the frame size in use when not using intra energy and are alpha=0, beta=4915/32768 -when using intra energy. -The time-domain prediction is based on the final fine quantization of the previous -frame, while the frequency domain (within the current frame) prediction is based -on coarse quantization only (because the fine quantization has not been computed -yet). The prediction is clamped internally so that fixed point implementations with -limited dynamic range always remain in the same state as floating point implementations. -We approximate the ideal -probability distribution of the prediction error using a Laplace distribution -with separate parameters for each frame size in intra- and inter-frame modes. These -parameters are held in the e_prob_model table in quant_bands.c. -The -coarse energy quantization is performed by unquant_coarse_energy() and -unquant_coarse_energy_impl() (quant_bands.c). The encoding of the Laplace-distributed values is -implemented in ec_laplace_decode() (laplace.c). -
    - -
    - -
    - -The number of bits assigned to fine energy quantization in each band is determined -by the bit allocation computation described in . -Let B_i be the number of fine energy bits -for band i; the refinement is an integer f in the range [0,2**B_i-1]. The mapping between f -and the correction applied to the coarse energy is equal to (f+1/2)/2**B_i - 1/2. Fine -energy quantization is implemented in quant_fine_energy() (quant_bands.c). - - -When some bits are left "unused" after all other flags have been decoded, these bits -are assigned to a "final" step of fine allocation. In effect, these bits are used -to add one extra fine energy bit per band per channel. The allocation process -determines two "priorities" for the final fine bits. -Any remaining bits are first assigned only to bands of priority 0, starting -from band 0 and going up. If all bands of priority 0 have received one bit per -channel, then bands of priority 1 are assigned an extra bit per channel, -starting from band 0. If any bits are left after this, they are left unused. -This is implemented in unquant_energy_finalise() (quant_bands.c). - - -
    - -
    - -
    - -Because the bit allocation drives the decoding of the range-coder -stream, it MUST be recovered exactly so that identical coding decisions are -made in the encoder and decoder. Any deviation from the reference's resulting -bit allocation will result in corrupted output, though implementers are -free to implement the procedure in any way which produces identical results. - -The per-band gain-shape structure of the CELT layer ensures that using - the same number of bits for the spectral shape of a band in every frame will - result in a roughly constant signal-to-noise ratio in that band. -This results in coding noise that has the same spectral envelope as the signal. -The masking curve produced by a standard psychoacoustic model also closely - follows the spectral envelope of the signal. -This structure means that the ideal allocation is more consistent from frame to - frame than it is for other codecs without an equivalent structure, and that a - fixed allocation provides fairly consistent perceptual - performance . - -Many codecs transmit significant amounts of side information to control the - bit allocation within a frame. -Often this control is only indirect, and must be exercised carefully to - achieve the desired rate constraints. -The CELT layer, however, can adapt over a very wide range of rates, and thus - has a large number of codebook sizes to choose from for each band. -Explicitly signaling the size of each of these codebooks would impose - considerable overhead, even though the allocation is relatively static from - frame to frame. -This is because all of the information required to compute these codebook sizes - must be derived from a single frame by itself, in order to retain robustness - to packet loss, so the signaling cannot take advantage of knowledge of the - allocation in neighboring frames. -This problem is exacerbated in low-latency (small frame size) applications, - which would include this overhead in every frame. - -For this reason, in the MDCT mode Opus uses a primarily implicit bit -allocation. The available bitstream capacity is known in advance to both -the encoder and decoder without additional signaling, ultimately from the -packet sizes expressed by a higher-level protocol. Using this information, -the codec interpolates an allocation from a hard-coded table. - -While the band-energy structure effectively models intra-band masking, -it ignores the weaker inter-band masking, band-temporal masking, and -other less significant perceptual effects. While these effects can -often be ignored, they can become significant for particular samples. One -mechanism available to encoders would be to simply increase the overall -rate for these frames, but this is not possible in a constant rate mode -and can be fairly inefficient. As a result three explicitly signaled -mechanisms are provided to alter the implicit allocation: - - - -Band boost -Allocation trim -Band skipping - - - -The first of these mechanisms, band boost, allows an encoder to boost -the allocation in specific bands. The second, allocation trim, works by -biasing the overall allocation towards higher or lower frequency bands. The third, band -skipping, selects which low-precision high frequency bands -will be allocated no shape bits at all. - -In stereo mode there are two additional parameters -potentially coded as part of the allocation procedure: a parameter to allow the -selective elimination of allocation for the 'side' (i.e., intensity stereo) in jointly coded bands, -and a flag to deactivate joint coding (i.e., dual stereo). These values are not signaled if -they would be meaningless in the overall context of the allocation. - -Because every signaled adjustment increases overhead and implementation -complexity, none were included speculatively: the reference encoder makes use -of all of these mechanisms. While the decision logic in the reference was -found to be effective enough to justify the overhead and complexity, further -analysis techniques may be discovered which increase the effectiveness of these -parameters. As with other signaled parameters, an encoder is free to choose the -values in any manner, but unless a technique is known to deliver superior -perceptual results the methods used by the reference implementation should be -used. - -The allocation process consists of the following steps: determining the per-band -maximum allocation vector, decoding the boosts, decoding the tilt, determining -the remaining capacity of the frame, searching the mode table for the -entry nearest but not exceeding the available space (subject to the tilt, boosts, band -maximums, and band minimums), linear interpolation, reallocation of -unused bits with concurrent skip decoding, determination of the -fine-energy vs. shape split, and final reallocation. This process results -in a per-band shape allocation (in 1/8th bit units), a per-band fine-energy -allocation (in 1 bit per channel units), a set of band priorities for -controlling the use of remaining bits at the end of the frame, and a -remaining balance of unallocated space, which is usually zero except -at very high rates. - - -The "static" bit allocation (in 1/8 bits) for a quality q, excluding the minimums, maximums, -tilt and boosts, is equal to channels*N*alloc[band][q]<<LM>>2, where -alloc[][] is given in and LM=log2(frame_size/120). The allocation -is obtained by linearly interpolating between two values of q (in steps of 1/64) to find the -highest allocation that does not exceed the number of bits remaining. - - - - Rows indicate the MDCT bands, columns are the different quality (q) parameters. The units are 1/32 bit per MDCT bin. -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -090110118126134144152162172200 -080100110119127137145155165200 -07590103112120130138148158200 -0698493104114124132142152200 -063788695103113123133143200 -05671808997107117127137200 -04965758391101111121131200 -0405870788595105115125200 -034516572788898108118198 -029455966728292102112193 -02039536066768696106188 -01832475460708090100183 -0102640475464748494178 -002031394757677787173 -001223324151617181168 -00015253545556575163 -0004172939495969158 -0000122333435363153 -000011626364656148 -000001015203045129 -00000111120104 - - -The maximum allocation vector is an approximation of the maximum space -that can be used by each band for a given mode. The value is -approximate because the shape encoding is variable rate (due -to entropy coding of splitting parameters). Setting the maximum too low reduces the -maximum achievable quality in a band while setting it too high -may result in waste: bitstream capacity available at the end -of the frame which can not be put to any use. The maximums -specified by the codec reflect the average maximum. In the reference -implementation, the maximums in bits/sample are precomputed in a static table -(see cache_caps50[] in static_modes_float.h) for each band, -for each value of LM, and for both mono and stereo. - -Implementations are expected -to simply use the same table data, but the procedure for generating -this table is included in rate.c as part of compute_pulse_cache(). - -To convert the values in cache.caps into the actual maximums: first -set nbBands to the maximum number of bands for this mode, and stereo to -zero if stereo is not in use and one otherwise. For each band set N -to the number of MDCT bins covered by the band (for one channel), set LM -to the shift value for the frame size, -then set i to nbBands*(2*LM+stereo). Then set the maximum for the band to -the i-th index of cache.caps + 64 and multiply by the number of channels -in the current frame (one or two) and by N, then divide the result by 4 -using integer division. The resulting vector will be called -cap[]. The elements fit in signed 16-bit integers but do not fit in 8 bits. -This procedure is implemented in the reference in the function init_caps() in celt.c. - - -The band boosts are represented by a series of binary symbols which -are entropy coded with very low probability. Each band can potentially be boosted -multiple times, subject to the frame actually having enough room to obey -the boost and having enough room to code the boost symbol. The default -coding cost for a boost starts out at six bits (probability p=1/64), but subsequent boosts -in a band cost only a single bit and every time a band is boosted the -initial cost is reduced (down to a minimum of two bits, or p=1/4). Since the initial -cost of coding a boost is 6 bits, the coding cost of the boost symbols when -completely unused is 0.48 bits/frame for a 21 band mode (21*-log2(1-1/2**6)). - -To decode the band boosts: First set 'dynalloc_logp' to 6, the initial -amount of storage required to signal a boost in bits, 'total_bits' to the -size of the frame in 8th bits, 'total_boost' to zero, and 'tell' to the total number -of 8th bits decoded -so far. For each band from the coding start (0 normally, but 17 in Hybrid mode) -to the coding end (which changes depending on the signaled bandwidth), the boost quanta -in units of 1/8 bit is calculated as quanta = min(8*N, max(48, N)). -This represents a boost step size of six bits, subject to a lower limit of -1/8th bit/sample and an upper limit of 1 bit/sample. -Set 'boost' to zero and 'dynalloc_loop_logp' -to dynalloc_logp. While dynalloc_loop_log (the current worst case symbol cost) in -8th bits plus tell is less than total_bits plus total_boost and boost is less than cap[] for this -band: Decode a bit from the bitstream with a with dynalloc_loop_logp as the cost -of a one, update tell to reflect the current used capacity, if the decoded value -is zero break the loop otherwise add quanta to boost and total_boost, subtract quanta from -total_bits, and set dynalloc_loop_log to 1. When the while loop finishes -boost contains the boost for this band. If boost is non-zero and dynalloc_logp -is greater than 2, decrease dynalloc_logp. Once this process has been -executed on all bands, the band boosts have been decoded. This procedure -is implemented around line 2474 of celt.c. - -At very low rates it is possible that there won't be enough available -space to execute the inner loop even once. In these cases band boost -is not possible but its overhead is completely eliminated. Because of the -high cost of band boost when activated, a reasonable encoder should not be -using it at very low rates. The reference implements its dynalloc decision -logic around line 1304 of celt.c. - -The allocation trim is a integer value from 0-10. The default value of -5 indicates no trim. The trim parameter is entropy coded in order to -lower the coding cost of less extreme adjustments. Values lower than -5 bias the allocation towards lower frequencies and values above 5 -bias it towards higher frequencies. Like other signaled parameters, signaling -of the trim is gated so that it is not included if there is insufficient space -available in the bitstream. To decode the trim, first set -the trim value to 5, then if and only if the count of decoded 8th bits so far (ec_tell_frac) -plus 48 (6 bits) is less than or equal to the total frame size in 8th -bits minus total_boost (a product of the above band boost procedure), -decode the trim value using the PDF in . - - -PDF -{1, 1, 2, 5, 10, 22, 46, 22, 10, 5, 2, 2}/128 - - -For 10 ms and 20 ms frames using short blocks and that have at least LM+2 bits left prior to -the allocation process, then one anti-collapse bit is reserved in the allocation process so it can -be decoded later. Following the the anti-collapse reservation, one bit is reserved for skip if available. - -For stereo frames, bits are reserved for intensity stereo and for dual stereo. Intensity stereo -requires ilog2(end-start) bits. Those bits are reserved if there is enough bits left. Following this, one -bit is reserved for dual stereo if available. - - -The allocation computation begins by setting up some initial conditions. -'total' is set to the remaining available 8th bits, computed by taking the -size of the coded frame times 8 and subtracting ec_tell_frac(). From this value, one (8th bit) -is subtracted to ensure that the resulting allocation will be conservative. 'anti_collapse_rsv' -is set to 8 (8th bits) if and only if the frame is a transient, LM is greater than 1, and total is -greater than or equal to (LM+2) * 8. Total is then decremented by anti_collapse_rsv and clamped -to be equal to or greater than zero. 'skip_rsv' is set to 8 (8th bits) if total is greater than -8, otherwise it is zero. Total is then decremented by skip_rsv. This reserves space for the -final skipping flag. - -If the current frame is stereo, intensity_rsv is set to the conservative log2 in 8th bits -of the number of coded bands for this frame (given by the table LOG2_FRAC_TABLE in rate.c). If -intensity_rsv is greater than total then intensity_rsv is set to zero. Otherwise total is -decremented by intensity_rsv, and if total is still greater than 8, dual_stereo_rsv is -set to 8 and total is decremented by dual_stereo_rsv. - -The allocation process then computes a vector representing the hard minimum amounts allocation -any band will receive for shape. This minimum is higher than the technical limit of the PVQ -process, but very low rate allocations produce an excessively sparse spectrum and these bands -are better served by having no allocation at all. For each coded band, set thresh[band] to -twenty-four times the number of MDCT bins in the band and divide by 16. If 8 times the number -of channels is greater, use that instead. This sets the minimum allocation to one bit per channel -or 48 128th bits per MDCT bin, whichever is greater. The band-size dependent part of this -value is not scaled by the channel count, because at the very low rates where this limit is -applicable there will usually be no bits allocated to the side. - -The previously decoded allocation trim is used to derive a vector of per-band adjustments, -'trim_offsets[]'. For each coded band take the alloc_trim and subtract 5 and LM. Then multiply -the result by the number of channels, the number of MDCT bins in the shortest frame size for this mode, -the number of remaining bands, 2**LM, and 8. Then divide this value by 64. Finally, if the -number of MDCT bins in the band per channel is only one, 8 times the number of channels is subtracted -in order to diminish the allocation by one bit, because width 1 bands receive greater benefit -from the coarse energy coding. - - -
    - -
    - -In each band, the normalized "shape" is encoded -using a vector quantization scheme called a "pyramid vector quantizer". - - -In -the simplest case, the number of bits allocated in - is converted to a number of pulses as described -by . Knowing the number of pulses and the -number of samples in the band, the decoder calculates the size of the codebook -as detailed in . The size is used to decode -an unsigned integer (uniform probability model), which is the codeword index. -This index is converted into the corresponding vector as explained in -. This vector is then scaled to unit norm. - - -
    - -Although the allocation is performed in 1/8th bit units, the quantization requires -an integer number of pulses K. To do this, the encoder searches for the value -of K that produces the number of bits nearest to the allocated value -(rounding down if exactly halfway between two values), not to exceed -the total number of bits available. For efficiency reasons, the search is performed against a -precomputed allocation table which only permits some K values for each N. The number of -codebook entries can be computed as explained in . The difference -between the number of bits allocated and the number of bits used is accumulated to a -"balance" (initialized to zero) that helps adjust the -allocation for the next bands. One third of the balance is applied to the -bit allocation of each band to help achieve the target allocation. The only -exceptions are the band before the last and the last band, for which half the balance -and the whole balance are applied, respectively. - -
    - -
    - - -Decoding of PVQ vectors is implemented in decode_pulses() (cwrs.c). -The unique codeword index is decoded as a uniformly-distributed integer value between 0 and -V(N,K)-1, where V(N,K) is the number of possible combinations of K pulses in -N samples. The index is then converted to a vector in the same way specified in -. The indexing is based on the calculation of V(N,K) -(denoted N(L,K) in ). - - - - The number of combinations can be computed recursively as -V(N,K) = V(N-1,K) + V(N,K-1) + V(N-1,K-1), with V(N,0) = 1 and V(0,K) = 0, K != 0. -There are many different ways to compute V(N,K), including precomputed tables and direct -use of the recursive formulation. The reference implementation applies the recursive -formulation one line (or column) at a time to save on memory use, -along with an alternate, -univariate recurrence to initialize an arbitrary line, and direct -polynomial solutions for small N. All of these methods are -equivalent, and have different trade-offs in speed, memory usage, and -code size. Implementations MAY use any methods they like, as long as -they are equivalent to the mathematical definition. - - - -The decoded vector X is recovered as follows. -Let i be the index decoded with the procedure in - with ft = V(N,K), so that 0 <= i < V(N,K). -Let k = K. -Then for j = 0 to (N - 1), inclusive, do: - -Let p = (V(N-j-1,k) + V(N-j,k))/2. - -If i < p, then let sgn = 1, else let sgn = -1 - and set i = i - p. - -Let k0 = k and set p = p - V(N-j-1,k). - -While p > i, set k = k - 1 and - p = p - V(N-j-1,k). - - -Set X[j] = sgn*(k0 - k) and i = i - p. - - - - - -The decoded vector X is then normalized such that its -L2-norm equals one. - -
    - -
    - -The normalized vector decoded in is then rotated -for the purpose of avoiding tonal artifacts. The rotation gain is equal to -
    - -
    - -where N is the number of dimensions, K is the number of pulses, and f_r depends on -the value of the "spread" parameter in the bit-stream. -
    - - -Spread value -f_r - 0 infinite (no rotation) - 1 15 - 2 10 - 3 5 - - - -The rotation angle is then calculated as -
    - -
    -A 2-D rotation R(i,j) between points x_i and x_j is defined as: -
    - -
    - -An N-D rotation is then achieved by applying a series of 2-D rotations back and forth, in the -following order: R(x_1, x_2), R(x_2, x_3), ..., R(x_N-2, X_N-1), R(x_N-1, X_N), -R(x_N-2, X_N-1), ..., R(x_1, x_2). -
    - - -If the decoded vector represents more -than one time block, then this spreading process is applied separately on each time block. -Also, if each block represents 8 samples or more, then another N-D rotation, by -(pi/2-theta), is applied before the rotation described above. This -extra rotation is applied in an interleaved manner with a stride equal to round(sqrt(N/nb_blocks)), -i.e., it is applied independently for each set of sample S_k = {stride*n + k}, n=0..N/stride-1. - -
    - -
    - -To avoid the need for multi-precision calculations when decoding PVQ codevectors, -the maximum size allowed for codebooks is 32 bits. When larger codebooks are -needed, the vector is instead split in two sub-vectors of size N/2. -A quantized gain parameter with precision -derived from the current allocation is entropy coded to represent the relative -gains of each side of the split, and the entire decoding process is recursively -applied. Multiple levels of splitting may be applied up to a limit of LM+1 splits. -The same recursive mechanism is applied for the joint coding -of stereo audio. - - -
    - -
    - -The time-frequency (TF) parameters are used to control the time-frequency resolution tradeoff -in each coded band. For each band, there are two possible TF choices. For the first -band coded, the PDF is {3, 1}/4 for frames marked as transient and {15, 1}/16 for -the other frames. For subsequent bands, the TF choice is coded relative to the -previous TF choice with probability {15, 1}/15 for transient frames and {31, 1}/32 -otherwise. The mapping between the decoded TF choices and the adjustment in TF -resolution is shown in the tables below. - - - -Frame size (ms) -0 -1 -2.5 0 -1 -5 0 -1 -10 0 -2 -20 0 -2 - - - -Frame size (ms) -0 -1 -2.5 0 -1 -5 0 -2 -10 0 -3 -20 0 -3 - - - - -Frame size (ms) -0 -1 -2.5 0 -1 -5 1 0 -10 2 0 -20 3 0 - - - -Frame size (ms) -0 -1 -2.5 0 -1 -5 1 -1 -10 1 -1 -20 1 -1 - - - -A negative TF adjustment means that the temporal resolution is increased, -while a positive TF adjustment means that the frequency resolution is increased. -Changes in TF resolution are implemented using the Hadamard transform . To increase -the time resolution by N, N "levels" of the Hadamard transform are applied to the -decoded vector for each interleaved MDCT vector. To increase the frequency resolution -(assumes a transient frame), then N levels of the Hadamard transform are applied -across the interleaved MDCT vector. In the case of increased -time resolution the decoder uses the "sequency order" because the input vector -is sorted in time. - -
    - - -
    - -
    - -The anti-collapse feature is designed to avoid the situation where the use of multiple -short MDCTs causes the energy in one or more of the MDCTs to be zero for -some bands, causing unpleasant artifacts. -When the frame has the transient bit set, an anti-collapse bit is decoded. -When anti-collapse is set, the energy in each small MDCT is prevented -from collapsing to zero. For each band of each MDCT where a collapse is -detected, a pseudo-random signal is inserted with an energy corresponding -to the minimum energy over the two previous frames. A renormalization step is -then required to ensure that the anti-collapse step did not alter the -energy preservation property. - -
    - -
    - -Just as each band was normalized in the encoder, the last step of the decoder before -the inverse MDCT is to denormalize the bands. Each decoded normalized band is -multiplied by the square root of the decoded energy. This is done by denormalise_bands() -(bands.c). - -
    - -
    - - -The inverse MDCT implementation has no special characteristics. The -input is N frequency-domain samples and the output is 2*N time-domain -samples, while scaling by 1/2. A "low-overlap" window reduces the algorithmic delay. -It is derived from a basic (full overlap) 240-sample version of the window used by the Vorbis codec: -
    - -
    -The low-overlap window is created by zero-padding the basic window and inserting ones in the -middle, such that the resulting window still satisfies power complementarity . -The IMDCT and -windowing are performed by mdct_backward (mdct.c). -
    - -
    - -The output of the inverse MDCT (after weighted overlap-add) is sent to the -post-filter. Although the post-filter is applied at the end, the post-filter -parameters are encoded at the beginning, just after the silence flag. -The post-filter can be switched on or off using one bit (logp=1). -If the post-filter is enabled, then the octave is decoded as an integer value -between 0 and 6 of uniform probability. Once the octave is known, the fine pitch -within the octave is decoded using 4+octave raw bits. The final pitch period -is equal to (16<<octave)+fine_pitch-1 so it is bounded between 15 and 1022, -inclusively. Next, the gain is decoded as three raw bits and is equal to -G=3*(int_gain+1)/32. The set of post-filter taps is decoded last, using -a pdf equal to {2, 1, 1}/4. Tapset zero corresponds to the filter coefficients -g0 = 0.3066406250, g1 = 0.2170410156, g2 = 0.1296386719. Tapset one -corresponds to the filter coefficients g0 = 0.4638671875, g1 = 0.2680664062, -g2 = 0, and tapset two uses filter coefficients g0 = 0.7998046875, -g1 = 0.1000976562, g2 = 0. - - - -The post-filter response is thus computed as: -
    - - - -
    - -During a transition between different gains, a smooth transition is calculated -using the square of the MDCT window. It is important that values of y(n) be -interpolated one at a time such that the past value of y(n) used is interpolated. -
    -
    - -
    - -After the post-filter, -the signal is de-emphasized using the inverse of the pre-emphasis filter -used in the encoder: -
    - -
    -where alpha_p=0.8500061035. -
    -
    - -
    - -
    - -
    - -Packet loss concealment (PLC) is an optional decoder-side feature that -SHOULD be included when receiving from an unreliable channel. Because -PLC is not part of the bitstream, there are many acceptable ways to -implement PLC with different complexity/quality trade-offs. - - - -The PLC in -the reference implementation depends on the mode of last packet received. -In CELT mode, the PLC finds a periodicity in the decoded -signal and repeats the windowed waveform using the pitch offset. The windowed -waveform is overlapped in such a way as to preserve the time-domain aliasing -cancellation with the previous frame and the next frame. This is implemented -in celt_decode_lost() (mdct.c). In SILK mode, the PLC uses LPC extrapolation -from the previous frame, implemented in silk_PLC() (PLC.c). - - -
    - -Clock drift refers to the gradual desynchronization of two endpoints -whose sample clocks run at different frequencies while they are streaming -live audio. Differences in clock frequencies are generally attributable to -manufacturing variation in the endpoints' clock hardware. For long-lived -streams, the time difference between sender and receiver can grow without -bound. - - - -When the sender's clock runs slower than the receiver's, the effect is similar -to packet loss: too few packets are received. The receiver can distinguish -between drift and loss if the transport provides packet timestamps. A receiver -for live streams SHOULD conceal the effects of drift, and MAY do so by invoking -the PLC. - - - -When the sender's clock runs faster than the receiver's, too many packets will -be received. The receiver MAY respond by skipping any packet (i.e., not -submitting the packet for decoding). This is likely to produce a less severe -artifact than if the frame were dropped after decoding. - - - -A decoder MAY employ a more sophisticated drift compensation method. For -example, the -NetEQ component -of the -Google WebRTC codebase -compensates for drift by adding or removing -one period when the signal is highly periodic. The reference implementation of -Opus allows a caller to learn whether the current frame's signal is highly -periodic, and if so what the period is, using the OPUS_GET_PITCH() request. - -
    - -
    - -
    - - -Switching between the Opus coding modes, audio bandwidths, and channel counts - requires careful consideration to avoid audible glitches. -Switching between any two configurations of the CELT-only mode, any two - configurations of the Hybrid mode, or from WB SILK to Hybrid mode does not - require any special treatment in the decoder, as the MDCT overlap will smooth - the transition. -Switching from Hybrid mode to WB SILK requires adding in the final contents - of the CELT overlap buffer to the first SILK-only packet. -This can be done by decoding a 2.5 ms silence frame with the CELT decoder - using the channel count of the SILK-only packet (and any choice of audio - bandwidth), which will correctly handle the cases when the channel count - changes as well. - - - -When changing the channel count for SILK-only or Hybrid packets, the encoder - can avoid glitches by smoothly varying the stereo width of the input signal - before or after the transition, and SHOULD do so. -However, other transitions between SILK-only packets or between NB or MB SILK - and Hybrid packets may cause glitches, because neither the LSF coefficients - nor the LTP, LPC, stereo unmixing, and resampler buffers are available at the - new sample rate. -These switches SHOULD be delayed by the encoder until quiet periods or - transients, where the inevitable glitches will be less audible. Additionally, - the bit-stream MAY include redundant side information ("redundancy"), in the - form of additional CELT frames embedded in each of the Opus frames around the - transition. - - - -The other transitions that cannot be easily handled are those where the lower - frequencies switch between the SILK LP-based model and the CELT MDCT model. -However, an encoder may not have an opportunity to delay such a switch to a - convenient point. -For example, if the content switches from speech to music, and the encoder does - not have enough latency in its analysis to detect this in advance, there may - be no convenient silence period during which to make the transition for quite - some time. -To avoid or reduce glitches during these problematic mode transitions, and - also between audio bandwidth changes in the SILK-only modes, transitions MAY - include redundant side information ("redundancy"), in the form of an - additional CELT frame embedded in the Opus frame. - - - -A transition between coding the lower frequencies with the LP model and the - MDCT model or a transition that involves changing the SILK bandwidth - is only normatively specified when it includes redundancy. -For those without redundancy, it is RECOMMENDED that the decoder use a - concealment technique (e.g., make use of a PLC algorithm) to "fill in" the - gap or discontinuity caused by the mode transition. -Therefore, PLC MUST NOT be applied during any normative transition, i.e., when - -A packet includes redundancy for this transition (as described below), -The transition is between any WB SILK packet and any Hybrid packet, or vice - versa, -The transition is between any two Hybrid mode packets, or -The transition is between any two CELT mode packets, - - unless there is actual packet loss. - - -
    - -Transitions with side information include an extra 5 ms "redundant" CELT - frame within the Opus frame. -This frame is designed to fill in the gap or discontinuity in the different - layers without requiring the decoder to conceal it. -For transitions from CELT-only to SILK-only or Hybrid, the redundant frame is - inserted in the first Opus frame after the transition (i.e., the first - SILK-only or Hybrid frame). -For transitions from SILK-only or Hybrid to CELT-only, the redundant frame is - inserted in the last Opus frame before the transition (i.e., the last - SILK-only or Hybrid frame). - - -
    - -The presence of redundancy is signaled in all SILK-only and Hybrid frames, not - just those involved in a mode transition. -This allows the frames to be decoded correctly even if an adjacent frame is - lost. -For SILK-only frames, this signaling is implicit, based on the size of the - of the Opus frame and the number of bits consumed decoding the SILK portion of - it. -After decoding the SILK portion of the Opus frame, the decoder uses ec_tell() - (see ) to check if there are at least 17 bits - remaining. -If so, then the frame contains redundancy. - - - -For Hybrid frames, this signaling is explicit. -After decoding the SILK portion of the Opus frame, the decoder uses ec_tell() - (see ) to ensure there are at least 37 bits remaining. -If so, it reads a symbol with the PDF in - , and if the value is 1, then the - frame contains redundancy. -Otherwise (if there were fewer than 37 bits left or the value was 0), the frame - does not contain redundancy. - - - -PDF -{4095, 1}/4096 - -
    - -
    - -Since the current frame is a SILK-only or a Hybrid frame, it must be at least - 10 ms. -Therefore, it needs an additional flag to indicate whether the redundant - 5 ms CELT frame should be mixed into the beginning of the current frame, - or the end. -After determining that a frame contains redundancy, the decoder reads a - 1 bit symbol with a uniform PDF - (). - - - -PDF -{1, 1}/2 - - - -If the value is zero, this is the first frame in the transition, and the - redundancy belongs at the end. -If the value is one, this is the second frame in the transition, and the - redundancy belongs at the beginning. -There is no way to specify that an Opus frame contains separate redundant CELT - frames at both the beginning and the end. - -
    - -
    - -Unlike the CELT portion of a Hybrid frame, the redundant CELT frame does not - use the same entropy coder state as the rest of the Opus frame, because this - would break the CELT bit allocation mechanism in Hybrid frames. -Thus, a redundant CELT frame always starts and ends on a byte boundary, even in - SILK-only frames, where this is not strictly necessary. - - - -For SILK-only frames, the number of bytes in the redundant CELT frame is simply - the number of whole bytes remaining, which must be at least 2, due to the - space check in . -For Hybrid frames, the number of bytes is equal to 2, plus a decoded unsigned - integer less than 256 (see ). -This may be more than the number of whole bytes remaining in the Opus frame, - in which case the frame is invalid. -However, a decoder is not required to ignore the entire frame, as this may be - the result of a bit error that desynchronized the range coder. -There may still be useful data before the error, and a decoder MAY keep any - audio decoded so far instead of invoking the PLC, but it is RECOMMENDED that - the decoder stop decoding and discard the rest of the current Opus frame. - - - -It would have been possible to avoid these invalid states in the design of Opus - by limiting the range of the explicit length decoded from Hybrid frames by the - actual number of whole bytes remaining. -However, this would require an encoder to determine the rate allocation for the - MDCT layer up front, before it began encoding that layer. -By allowing some invalid sizes, the encoder is able to defer that decision - until much later. -When encoding Hybrid frames which do not include redundancy, the encoder must - still decide up-front if it wishes to use the minimum 37 bits required to - trigger encoding of the redundancy flag, but this is a much looser - restriction. - - - -After determining the size of the redundant CELT frame, the decoder reduces - the size of the buffer currently in use by the range coder by that amount. -The CELT layer read any raw bits from the end of this reduced buffer, and all - calculations of the number of bits remaining in the buffer must be done using - this new, reduced size, rather than the original size of the Opus frame. - -
    - -
    - -The redundant frame is decoded like any other CELT-only frame, with the - exception that it does not contain a TOC byte. -The frame size is fixed at 5 ms, the channel count is set to that of the - current frame, and the audio bandwidth is also set to that of the current - frame, with the exception that for MB SILK frames, it is set to WB. - - - -If the redundancy belongs at the beginning (in a CELT-only to SILK-only or - Hybrid transition), the final reconstructed output uses the first 2.5 ms - of audio output by the decoder for the redundant frame as-is, discarding - the corresponding output from the SILK-only or Hybrid portion of the frame. -The remaining 2.5 ms is cross-lapped with the decoded SILK/Hybrid signal - using the CELT's power-complementary MDCT window to ensure a smooth - transition. - - - -If the redundancy belongs at the end (in a SILK-only or Hybrid to CELT-only - transition), only the second half (2.5 ms) of the audio output by the - decoder for the redundant frame is used. -In that case, the second half of the redundant frame is cross-lapped with the - end of the SILK/Hybrid signal, again using CELT's power-complementary MDCT - window to ensure a smooth transition. - -
    - -
    - -
    - -When a transition occurs, the state of the SILK or the CELT decoder (or both) - may need to be reset before decoding a frame in the new mode. -This avoids reusing "out of date" memory, which may not have been updated in - some time or may not be in a well-defined state due to, e.g., PLC. -The SILK state is reset before every SILK-only or Hybrid frame where the - previous frame was CELT-only. -The CELT state is reset every time the operating mode changes and the new mode - is either Hybrid or CELT-only, except when the transition uses redundancy as - described above. -When switching from SILK-only or Hybrid to CELT-only with redundancy, the CELT - state is reset before decoding the redundant CELT frame embedded in the - SILK-only or Hybrid frame, but it is not reset before decoding the following - CELT-only frame. -When switching from CELT-only mode to SILK-only or Hybrid mode with redundancy, - the CELT decoder is not reset for decoding the redundant CELT frame. - -
    - -
    - - - illustrates all of the normative - transitions involving a mode change, an audio bandwidth change, or both. -Each one uses an S, H, or C to represent an Opus frame in the corresponding - mode. -In addition, an R indicates the presence of redundancy in the Opus frame it is - cross-lapped with. -Its location in the first or last 5 ms is assumed to correspond to whether - it is the frame before or after the transition. -Other uses of redundancy are non-normative. -Finally, a c indicates the contents of the CELT overlap buffer after the - previously decoded frame (i.e., as extracted by decoding a silence frame). -
    - S -> S - & - !R -> R - & - ;S -> S -> S - -NB or MB SILK to Hybrid with Redundancy: S -> S -> S - & - !R ->;H -> H -> H - -WB SILK to Hybrid: S -> S -> S ->!H -> H -> H - -SILK to CELT with Redundancy: S -> S -> S - & - !R -> C -> C -> C - -Hybrid to NB or MB SILK with Redundancy: H -> H -> H - & - !R -> R - & - ;S -> S -> S - -Hybrid to WB SILK: H -> H -> H -> c - \ + - > S -> S -> S - -Hybrid to CELT with Redundancy: H -> H -> H - & - !R -> C -> C -> C - -CELT to SILK with Redundancy: C -> C -> C -> R - & - ;S -> S -> S - -CELT to Hybrid with Redundancy: C -> C -> C -> R - & - |H -> H -> H - -Key: -S SILK-only frame ; SILK decoder reset -H Hybrid frame | CELT and SILK decoder resets -C CELT-only frame ! CELT decoder reset -c CELT overlap + Direct mixing -R Redundant CELT frame & Windowed cross-lap -]]> -
    -The first two and the last two Opus frames in each example are illustrative, - i.e., there is no requirement that a stream remain in the same configuration - for three consecutive frames before or after a switch. -
    - - -The behavior of transitions without redundancy where PLC is allowed is non-normative. -An encoder might still wish to use these transitions if, for example, it - doesn't want to add the extra bitrate required for redundancy or if it makes - a decision to switch after it has already transmitted the frame that would - have had to contain the redundancy. - illustrates the recommended - cross-lapping and decoder resets for these transitions. -
    - S -> S ;S -> S -> S - -NB or MB SILK to Hybrid: S -> S -> S |H -> H -> H - -SILK to CELT without Redundancy: S -> S -> S -> P - & - !C -> C -> C - -Hybrid to NB or MB SILK: H -> H -> H -> c - + - ;S -> S -> S - -Hybrid to CELT without Redundancy: H -> H -> H -> P - & - !C -> C -> C - -CELT to SILK without Redundancy: C -> C -> C -> P - & - ;S -> S -> S - -CELT to Hybrid without Redundancy: C -> C -> C -> P - & - |H -> H -> H - -Key: -S SILK-only frame ; SILK decoder reset -H Hybrid frame | CELT and SILK decoder resets -C CELT-only frame ! CELT decoder reset -c CELT overlap + Direct mixing -P Packet Loss Concealment & Windowed cross-lap -]]> -
    -Encoders SHOULD NOT use other transitions, e.g., those that involve redundancy - in ways not illustrated in . -
    - -
    - -
    - -
    - - - - - - -
    - -Just like the decoder, the Opus encoder also normally consists of two main blocks: the -SILK encoder and the CELT encoder. However, unlike the case of the decoder, a valid -(though potentially suboptimal) Opus encoder is not required to support all modes and -may thus only include a SILK encoder module or a CELT encoder module. -The output bit-stream of the Opus encoding contains bits from the SILK and CELT - encoders, though these are not separable due to the use of a range coder. -A block diagram of the encoder is illustrated below. - -
    - -| Rate |--->| Encoder | V - +-----------+ | | Conversion | | | +---------+ - | Optional | | +------------+ +---------+ | Range | -->| High-pass |--+ | Encoder |----> - | Filter | | +--------------+ +---------+ | | Bit- - +-----------+ | | Delay | | CELT | +---------+ stream - +->| Compensation |->| Encoder | ^ - | | | |------+ - +--------------+ +---------+ -]]> - -
    -
    - - -For a normal encoder where both the SILK and the CELT modules are included, an optimal -encoder should select which coding mode to use at run-time depending on the conditions. -In the reference implementation, the frame size is selected by the application, but the -other configuration parameters (number of channels, bandwidth, mode) are automatically -selected (unless explicitly overridden by the application) depend on the following: - -Requested bitrate -Input sampling rate -Type of signal (speech vs music) -Frame size in use - - -The type of signal currently needs to be provided by the application (though it can be -changed in real-time). An Opus encoder implementation could also do automatic detection, -but since Opus is an interactive codec, such an implementation would likely have to either -delay the signal (for non-interactive applications) or delay the mode switching decisions (for -interactive applications). - - - -When the encoder is configured for voice over IP applications, the input signal is -filtered by a high-pass filter to remove the lowest part of the spectrum -that contains little speech energy and may contain background noise. This is a second order -Auto Regressive Moving Average (i.e., with poles and zeros) filter with a cut-off frequency around 50 Hz. -In the future, a music detector may also be used to lower the cut-off frequency when the -input signal is detected to be music rather than speech. - - -
    - -The range coder acts as the bit-packer for Opus. -It is used in three different ways: to encode - - -Entropy-coded symbols with a fixed probability model using ec_encode() - (entenc.c), - - -Integers from 0 to (2**M - 1) using ec_enc_uint() or ec_enc_bits() - (entenc.c), - -Integers from 0 to (ft - 1) (where ft is not a power of two) using - ec_enc_uint() (entenc.c). - - - - - -The range encoder maintains an internal state vector composed of the four-tuple - (val, rng, rem, ext) representing the low end of the current - range, the size of the current range, a single buffered output byte, and a - count of additional carry-propagating output bytes. -Both val and rng are 32-bit unsigned integer values, rem is a byte value or - less than 255 or the special value -1, and ext is an unsigned integer with at - least 11 bits. -This state vector is initialized at the start of each each frame to the value - (0, 2**31, -1, 0). -After encoding a sequence of symbols, the value of rng in the encoder should - exactly match the value of rng in the decoder after decoding the same sequence - of symbols. -This is a powerful tool for detecting errors in either an encoder or decoder - implementation. -The value of val, on the other hand, represents different things in the encoder - and decoder, and is not expected to match. - - - -The decoder has no analog for rem and ext. -These are used to perform carry propagation in the renormalization loop below. -Each iteration of this loop produces 9 bits of output, consisting of 8 data - bits and a carry flag. -The encoder cannot determine the final value of the output bytes until it - propagates these carry flags. -Therefore the reference implementation buffers a single non-propagating output - byte (i.e., one less than 255) in rem and keeps a count of additional - propagating (i.e., 255) output bytes in ext. -An implementation may choose to use any mathematically equivalent scheme to - perform carry propagation. - - -
    - -The main encoding function is ec_encode() (entenc.c), which encodes symbol k in - the current context using the same three-tuple (fl[k], fh[k], ft) - as the decoder to describe the range of the symbol (see - ). - - -ec_encode() updates the state of the encoder as follows. -If fl[k] is greater than zero, then -
    - -
    -Otherwise, val is unchanged and -
    - -
    -The divisions here are integer division. -
    - -
    - -After this update, the range is normalized using a procedure very similar to - that of , implemented by - ec_enc_normalize() (entenc.c). -The following process is repeated until rng > 2**23. -First, the top 9 bits of val, (val>>23), are sent to the carry buffer, - described in . -Then, the encoder sets -
    - -
    -
    -
    - -
    - -The function ec_enc_carry_out() (entenc.c) implements carry propagation and - output buffering. -It takes as input a 9-bit value, c, consisting of 8 data bits and an additional - carry bit. -If c is equal to the value 255, then ext is simply incremented, and no other - state updates are performed. -Otherwise, let b = (c>>8) be the carry bit. -Then, - - -If the buffered byte rem contains a value other than -1, the encoder outputs - the byte (rem + b). -Otherwise, if rem is -1, no byte is output. - - -If ext is non-zero, then the encoder outputs ext bytes---all with a value of 0 - if b is set, or 255 if b is unset---and sets ext to 0. - - -rem is set to the 8 data bits: -
    - -
    -
    -
    -
    -
    - -
    - -
    - -The reference implementation uses three additional encoding methods that are - exactly equivalent to the above, but make assumptions and simplifications that - allow for a more efficient implementation. - - -
    - -The first is ec_encode_bin() (entenc.c), defined using the parameter ftb - instead of ft. -It is mathematically equivalent to calling ec_encode() with - ft = (1<<ftb), but avoids using division. - -
    - -
    - -The next is ec_enc_bit_logp() (entenc.c), which encodes a single binary symbol. -The context is described by a single parameter, logp, which is the absolute - value of the base-2 logarithm of the probability of a "1". -It is mathematically equivalent to calling ec_encode() with the 3-tuple - (fl[k] = 0, fh[k] = (1<<logp) - 1, - ft = (1<<logp)) if k is 0 and with - (fl[k] = (1<<logp) - 1, - fh[k] = ft = (1<<logp)) if k is 1. -The implementation requires no multiplications or divisions. - -
    - -
    - -The last is ec_enc_icdf() (entenc.c), which encodes a single binary symbol with - a table-based context of up to 8 bits. -This uses the same icdf table as ec_dec_icdf() from - . -The function is mathematically equivalent to calling ec_encode() with - fl[k] = (1<<ftb) - icdf[k-1] (or 0 if - k == 0), fh[k] = (1<<ftb) - icdf[k], and - ft = (1<<ftb). -This only saves a few arithmetic operations over ec_encode_bin(), but allows - the encoder to use the same icdf tables as the decoder. - -
    - -
    - -
    - -The raw bits used by the CELT layer are packed at the end of the buffer using - ec_enc_bits() (entenc.c). -Because the raw bits may continue into the last byte output by the range coder - if there is room in the low-order bits, the encoder must be prepared to merge - these values into a single byte. -The procedure in does this in a way that - ensures both the range coded data and the raw bits can be decoded - successfully. - -
    - -
    - -The function ec_enc_uint() (entenc.c) encodes one of ft equiprobable symbols in - the range 0 to (ft - 1), inclusive, each with a frequency of 1, - where ft may be as large as (2**32 - 1). -Like the decoder (see ), it splits up the - value into a range coded symbol representing up to 8 of the high bits, and, if - necessary, raw bits representing the remainder of the value. - - -ec_enc_uint() takes a two-tuple (t, ft), where t is the value to be - encoded, 0 <= t < ft, and ft is not necessarily a - power of two. -Let ftb = ilog(ft - 1), i.e., the number of bits required - to store (ft - 1) in two's complement notation. -If ftb is 8 or less, then t is encoded directly using ec_encode() with the - three-tuple (t, t + 1, ft). - - -If ftb is greater than 8, then the top 8 bits of t are encoded using the - three-tuple (t>>(ftb - 8), - (t>>(ftb - 8)) + 1, - ((ft - 1)>>(ftb - 8)) + 1), and the - remaining bits, - (t & ((1<<(ftb - 8)) - 1), - are encoded as raw bits with ec_enc_bits(). - -
    - -
    - -After all symbols are encoded, the stream must be finalized by outputting a - value inside the current range. -Let end be the integer in the interval [val, val + rng) with the - largest number of trailing zero bits, b, such that - (end + (1<<b) - 1) is also in the interval - [val, val + rng). -This choice of end allows the maximum number of trailing bits to be set to - arbitrary values while still ensuring the range coded part of the buffer can - be decoded correctly. -Then, while end is not zero, the top 9 bits of end, i.e., (end>>23), are - passed to the carry buffer in accordance with the procedure in - , and end is updated via -
    - -
    -Finally, if the buffered output byte, rem, is neither zero nor the special - value -1, or the carry count, ext, is greater than zero, then 9 zero bits are - sent to the carry buffer to flush it to the output buffer. -When outputting the final byte from the range coder, if it would overlap any - raw bits already packed into the end of the output buffer, they should be ORed - into the same byte. -The bit allocation routines in the CELT layer should ensure that this can be - done without corrupting the range coder data so long as end is chosen as - described above. -If there is any space between the end of the range coder data and the end of - the raw bits, it is padded with zero bits. -This entire process is implemented by ec_enc_done() (entenc.c). -
    -
    - -
    - - The bit allocation routines in Opus need to be able to determine a - conservative upper bound on the number of bits that have been used - to encode the current frame thus far. This drives allocation - decisions and ensures that the range coder and raw bits will not - overflow the output buffer. This is computed in the - reference implementation to whole-bit precision by - the function ec_tell() (entcode.h) and to fractional 1/8th bit - precision by the function ec_tell_frac() (entcode.c). - Like all operations in the range coder, it must be implemented in a - bit-exact manner, and must produce exactly the same value returned by - the same functions in the decoder after decoding the same symbols. - -
    - -
    - -
    - - In many respects the SILK encoder mirrors the SILK decoder described - in . - Details such as the quantization and range coder tables can be found - there, while this section describes the high-level design choices that - were made. - The diagram below shows the basic modules of the SILK encoder. -
    - -| Rate |--->| Mixing |--->| Core |----------> -Input |Conversion| | | | Encoder | Bitstream - +----------+ +--------+ +---------+ -]]> - -
    -
    - -
    - -The input signal's sampling rate is adjusted by a sample rate conversion -module so that it matches the SILK internal sampling rate. -The input to the sample rate converter is delayed by a number of samples -depending on the sample rate ratio, such that the overall delay is constant -for all input and output sample rates. - -
    - -
    - -The stereo mixer is only used for stereo input signals. -It converts a stereo left/right signal into an adaptive -mid/side representation. -The first step is to compute non-adaptive mid/side signals -as half the sum and difference between left and right signals. -The side signal is then minimized in energy by subtracting a -prediction of it based on the mid signal. -This prediction works well when the left and right signals -exhibit linear dependency, for instance for an amplitude-panned -input signal. -Like in the decoder, the prediction coefficients are linearly -interpolated during the first 8 ms of the frame. - The mid signal is always encoded, whereas the residual - side signal is only encoded if it has sufficient - energy compared to the mid signal's energy. - If it has not, - the "mid_only_flag" is set without encoding the side signal. - - -The predictor coefficients are coded regardless of whether -the side signal is encoded. -For each frame, two predictor coefficients are computed, one -that predicts between low-passed mid and side channels, and -one that predicts between high-passed mid and side channels. -The low-pass filter is a simple three-tap filter -and creates a delay of one sample. -The high-pass filtered signal is the difference between -the mid signal delayed by one sample and the low-passed -signal. Instead of explicitly computing the high-passed -signal, it is computationally more efficient to transform -the prediction coefficients before applying them to the -filtered mid signal, as follows -
    - - - -
    -where w0 and w1 are the low-pass and high-pass prediction -coefficients, mid(n-1) is the mid signal delayed by one sample, -LP(n) and HP(n) are the low-passed and high-passed -signals and pred(n) is the prediction signal that is subtracted -from the side signal. -
    -
    - -
    - -What follows is a description of the core encoder and its components. -For simplicity, the core encoder is referred to simply as the encoder in -the remainder of this section. An overview of the encoder is given in -. - -
    - -| | - +---------+ | +---------+ | | - |Voice | | |LTP |12 | | - +-->|Activity |--+ +----->|Scaling |-----------+---->| | - | |Detector |3 | | |Control |<--+ | | | - | +---------+ | | +---------+ | | | | - | | | +---------+ | | | | - | | | |Gains | | | | | - | | | +-->|Processor|---|---+---|---->| R | - | | | | | |11 | | | | a | - | \/ | | +---------+ | | | | n | - | +---------+ | | +---------+ | | | | g | - | |Pitch | | | |LSF | | | | | e | - | +->|Analysis |---+ | |Quantizer|---|---|---|---->| | - | | | |4 | | | |8 | | | | E |--> - | | +---------+ | | +---------+ | | | | n | 2 - | | | | 9/\ 10| | | | | c | - | | | | | \/ | | | | o | - | | +---------+ | | +----------+ | | | | d | - | | |Noise | +--|-->|Prediction|--+---|---|---->| e | - | +->|Shaping |---|--+ |Analysis |7 | | | | r | - | | |Analysis |5 | | | | | | | | | - | | +---------+ | | +----------+ | | | | | - | | | | /\ | | | | | - | | +----------|--|--------+ | | | | | - | | | \/ \/ \/ \/ \/ | | - | | | +---------+ +------------+ | | - | | | | | |Noise | | | --+-------+-----+------>|Prefilter|--------->|Shaping |-->| | -1 | | 6 |Quantization|13 | | - +---------+ +------------+ +---+ - -1: Input speech signal -2: Range encoded bitstream -3: Voice activity estimate -4: Pitch lags (per 5 ms) and voicing decision (per 20 ms) -5: Noise shaping quantization coefficients - - Short term synthesis and analysis - noise shaping coefficients (per 5 ms) - - Long term synthesis and analysis noise - shaping coefficients (per 5 ms and for voiced speech only) - - Noise shaping tilt (per 5 ms) - - Quantizer gain/step size (per 5 ms) -6: Input signal filtered with analysis noise shaping filters -7: Short and long term prediction coefficients - LTP (per 5 ms) and LPC (per 20 ms) -8: LSF quantization indices -9: LSF coefficients -10: Quantized LSF coefficients -11: Processed gains, and synthesis noise shape coefficients -12: LTP state scaling coefficient. Controlling error propagation - / prediction gain trade-off -13: Quantized signal -]]> - -
    - -
    - -The input signal is processed by a Voice Activity Detector (VAD) to produce -a measure of voice activity, spectral tilt, and signal-to-noise estimates for -each frame. The VAD uses a sequence of half-band filterbanks to split the -signal into four subbands: 0...Fs/16, Fs/16...Fs/8, Fs/8...Fs/4, and -Fs/4...Fs/2, where Fs is the sampling frequency (8, 12, 16, or 24 kHz). -The lowest subband, from 0 - Fs/16, is high-pass filtered with a first-order -moving average (MA) filter (with transfer function H(z) = 1-z**(-1)) to -reduce the energy at the lowest frequencies. For each frame, the signal -energy per subband is computed. -In each subband, a noise level estimator tracks the background noise level -and a Signal-to-Noise Ratio (SNR) value is computed as the logarithm of the -ratio of energy to noise level. -Using these intermediate variables, the following parameters are calculated -for use in other SILK modules: - - -Average SNR. The average of the subband SNR values. - - - -Smoothed subband SNRs. Temporally smoothed subband SNR values. - - - -Speech activity level. Based on the average SNR and a weighted average of the -subband energies. - - - -Spectral tilt. A weighted average of the subband SNRs, with positive weights -for the low subbands and negative weights for the high subbands. - - - -
    - -
    - -The input signal is processed by the open loop pitch estimator shown in -. -
    - -|sampling|->|Correlator| | - | | | | | |4 - | +--------+ +----------+ \/ - | | 2 +-------+ - | | +-->|Speech |5 - +---------+ +--------+ | \/ | |Type |-> - |LPC | |Down | | +----------+ | | - +->|Analysis | +->|sample |-+------------->|Time- | +-------+ - | | | | |to 8 kHz| |Correlator|-----------> - | +---------+ | +--------+ |__________| 6 - | | | |3 - | \/ | \/ - | +---------+ | +----------+ - | |Whitening| | |Time- | --+->|Filter |-+--------------------------->|Correlator|-----------> -1 | | | | 7 - +---------+ +----------+ - -1: Input signal -2: Lag candidates from stage 1 -3: Lag candidates from stage 2 -4: Correlation threshold -5: Voiced/unvoiced flag -6: Pitch correlation -7: Pitch lags -]]> - -
    -The pitch analysis finds a binary voiced/unvoiced classification, and, for -frames classified as voiced, four pitch lags per frame - one for each -5 ms subframe - and a pitch correlation indicating the periodicity of -the signal. -The input is first whitened using a Linear Prediction (LP) whitening filter, -where the coefficients are computed through standard Linear Prediction Coding -(LPC) analysis. The order of the whitening filter is 16 for best results, but -is reduced to 12 for medium complexity and 8 for low complexity modes. -The whitened signal is analyzed to find pitch lags for which the time -correlation is high. -The analysis consists of three stages for reducing the complexity: - -In the first stage, the whitened signal is downsampled to 4 kHz -(from 8 kHz) and the current frame is correlated to a signal delayed -by a range of lags, starting from a shortest lag corresponding to -500 Hz, to a longest lag corresponding to 56 Hz. - - -The second stage operates on an 8 kHz signal (downsampled from 12, 16, -or 24 kHz) and measures time correlations only near the lags -corresponding to those that had sufficiently high correlations in the first -stage. The resulting correlations are adjusted for a small bias towards -short lags to avoid ending up with a multiple of the true pitch lag. -The highest adjusted correlation is compared to a threshold depending on: - - -Whether the previous frame was classified as voiced - - -The speech activity level - - -The spectral tilt. - - -If the threshold is exceeded, the current frame is classified as voiced and -the lag with the highest adjusted correlation is stored for a final pitch -analysis of the highest precision in the third stage. - - -The last stage operates directly on the whitened input signal to compute time -correlations for each of the four subframes independently in a narrow range -around the lag with highest correlation from the second stage. - - -
    -
    - -
    - -The noise shaping analysis finds gains and filter coefficients used in the -prefilter and noise shaping quantizer. These parameters are chosen such that -they will fulfill several requirements: - - -Balancing quantization noise and bitrate. -The quantization gains determine the step size between reconstruction levels -of the excitation signal. Therefore, increasing the quantization gain -amplifies quantization noise, but also reduces the bitrate by lowering -the entropy of the quantization indices. - - -Spectral shaping of the quantization noise; the noise shaping quantizer is -capable of reducing quantization noise in some parts of the spectrum at the -cost of increased noise in other parts without substantially changing the -bitrate. -By shaping the noise such that it follows the signal spectrum, it becomes -less audible. In practice, best results are obtained by making the shape -of the noise spectrum slightly flatter than the signal spectrum. - - -De-emphasizing spectral valleys; by using different coefficients in the -analysis and synthesis part of the prefilter and noise shaping quantizer, -the levels of the spectral valleys can be decreased relative to the levels -of the spectral peaks such as speech formants and harmonics. -This reduces the entropy of the signal, which is the difference between the -coded signal and the quantization noise, thus lowering the bitrate. - - -Matching the levels of the decoded speech formants to the levels of the -original speech formants; an adjustment gain and a first order tilt -coefficient are computed to compensate for the effect of the noise -shaping quantization on the level and spectral tilt. - - - - -
    - - - Frequency - -1: Input signal spectrum -2: De-emphasized and level matched spectrum -3: Quantization noise spectrum -]]> - -
    - shows an example of an -input signal spectrum (1). -After de-emphasis and level matching, the spectrum has deeper valleys (2). -The quantization noise spectrum (3) more or less follows the input signal -spectrum, while having slightly less pronounced peaks. -The entropy, which provides a lower bound on the bitrate for encoding the -excitation signal, is proportional to the area between the de-emphasized -spectrum (2) and the quantization noise spectrum (3). Without de-emphasis, -the entropy is proportional to the area between input spectrum (1) and -quantization noise (3) - clearly higher. -
    - - -The transformation from input signal to de-emphasized signal can be -described as a filtering operation with a filter -
    - - - -
    -having an adjustment gain G, a first order tilt adjustment filter with -tilt coefficient c_tilt, and where -
    - - - -
    -is the analysis part of the de-emphasis filter, consisting of the short-term -shaping filter with coefficients a_ana(k), and the long-term shaping filter -with coefficients b_ana(k) and pitch lag L. -The parameter d determines the number of long-term shaping filter taps. -
    - - -Similarly, but without the tilt adjustment, the synthesis part can be written as -
    - - - -
    -
    - -All noise shaping parameters are computed and applied per subframe of 5 ms. -First, an LPC analysis is performed on a windowed signal block of 15 ms. -The signal block has a look-ahead of 5 ms relative to the current subframe, -and the window is an asymmetric sine window. The LPC analysis is done with the -autocorrelation method, with an order of between 8, in lowest-complexity mode, -and 16, for best quality. - - -Optionally the LPC analysis and noise shaping filters are warped by replacing -the delay elements by first-order allpass filters. -This increases the frequency resolution at low frequencies and reduces it at -high ones, which better matches the human auditory system and improves -quality. -The warped analysis and filtering comes at a cost in complexity -and is therefore only done in higher complexity modes. - - -The quantization gain is found by taking the square root of the residual energy -from the LPC analysis and multiplying it by a value inversely proportional -to the coding quality control parameter and the pitch correlation. - - -Next the two sets of short-term noise shaping coefficients a_ana(k) and -a_syn(k) are obtained by applying different amounts of bandwidth expansion to the -coefficients found in the LPC analysis. -This bandwidth expansion moves the roots of the LPC polynomial towards the -origin, using the formulas -
    - - - -
    -where a(k) is the k'th LPC coefficient, and the bandwidth expansion factors -g_ana and g_syn are calculated as -
    - - - -
    -where C is the coding quality control parameter between 0 and 1. -Applying more bandwidth expansion to the analysis part than to the synthesis -part gives the desired de-emphasis of spectral valleys in between formants. -
    - - -The long-term shaping is applied only during voiced frames. -It uses three filter taps, described by -
    - - - -
    -For unvoiced frames these coefficients are set to 0. The multiplication factors -F_ana and F_syn are chosen between 0 and 1, depending on the coding quality -control parameter, as well as the calculated pitch correlation and smoothed -subband SNR of the lowest subband. By having F_ana less than F_syn, -the pitch harmonics are emphasized relative to the valleys in between the -harmonics. -
    - - -The tilt coefficient c_tilt is for unvoiced frames chosen as -
    - - - -
    -and as -
    - - - -
    -for voiced frames, where V is the voice activity level between 0 and 1. -
    - -The adjustment gain G serves to correct any level mismatch between the original -and decoded signals that might arise from the noise shaping and de-emphasis. -This gain is computed as the ratio of the prediction gain of the short-term -analysis and synthesis filter coefficients. The prediction gain of an LPC -synthesis filter is the square root of the output energy when the filter is -excited by a unit-energy impulse on the input. -An efficient way to compute the prediction gain is by first computing the -reflection coefficients from the LPC coefficients through the step-down -algorithm, and extracting the prediction gain from the reflection coefficients -as -
    - - - -
    -where r_k is the k'th reflection coefficient. -
    - - -Initial values for the quantization gains are computed as the square-root of -the residual energy of the LPC analysis, adjusted by the coding quality control -parameter. -These quantization gains are later adjusted based on the results of the -prediction analysis. - -
    - -
    - -The prediction analysis is performed in one of two ways depending on how -the pitch estimator classified the frame. -The processing for voiced and unvoiced speech is described in - and - , respectively. - Inputs to this function include the pre-whitened signal from the - pitch estimator (see ). - - -
    - - For a frame of voiced speech the pitch pulses will remain dominant in the - pre-whitened input signal. - Further whitening is desirable as it leads to higher quality at the same - available bitrate. - To achieve this, a Long-Term Prediction (LTP) analysis is carried out to - estimate the coefficients of a fifth-order LTP filter for each of four - subframes. - The LTP coefficients are quantized using the method described in - , and the quantized LTP - coefficients are used to compute the LTP residual signal. - This LTP residual signal is the input to an LPC analysis where the LPC coefficients are - estimated using Burg's method , such that the residual energy is minimized. - The estimated LPC coefficients are converted to a Line Spectral Frequency (LSF) vector - and quantized as described in . -After quantization, the quantized LSF vector is converted back to LPC -coefficients using the full procedure in . -By using quantized LTP coefficients and LPC coefficients derived from the -quantized LSF coefficients, the encoder remains fully synchronized with the -decoder. -The quantized LPC and LTP coefficients are also used to filter the input -signal and measure residual energy for each of the four subframes. - -
    -
    - -For a speech signal that has been classified as unvoiced, there is no need -for LTP filtering, as it has already been determined that the pre-whitened -input signal is not periodic enough within the allowed pitch period range -for LTP analysis to be worth the cost in terms of complexity and bitrate. -The pre-whitened input signal is therefore discarded, and instead the input -signal is used for LPC analysis using Burg's method. -The resulting LPC coefficients are converted to an LSF vector and quantized -as described in the following section. -They are then transformed back to obtain quantized LPC coefficients, which -are then used to filter the input signal and measure residual energy for -each of the four subframes. - -
    - -The main purpose of linear prediction in SILK is to reduce the bitrate by -minimizing the residual energy. -At least at high bitrates, perceptual aspects are handled -independently by the noise shaping filter. -Burg's method is used because it provides higher prediction gain -than the autocorrelation method and, unlike the covariance method, -produces stable filters (assuming numerical errors don't spoil -that). SILK's implementation of Burg's method is also computationally -faster than the autocovariance method. -The implementation of Burg's method differs from traditional -implementations in two aspects. -The first difference is that it -operates on autocorrelations, similar to the Schur algorithm , but -with a simple update to the autocorrelations after finding each -reflection coefficient to make the result identical to Burg's method. -This brings down the complexity of Burg's method to near that of -the autocorrelation method. -The second difference is that the signal in each subframe is scaled -by the inverse of the residual quantization step size. Subframes with -a small quantization step size will on average spend more bits for a -given amount of residual energy than subframes with a large step size. -Without scaling, Burg's method minimizes the total residual energy in -all subframes, which doesn't necessarily minimize the total number of -bits needed for coding the quantized residual. The residual energy -of the scaled subframes is a better measure for that number of -bits. - -
    -
    -
    - -
    - -Unlike many other speech codecs, SILK uses variable bitrate coding -for the LSFs. -This improves the average rate-distortion (R-D) tradeoff and reduces outliers. -The variable bitrate coding minimizes a linear combination of the weighted -quantization errors and the bitrate. -The weights for the quantization errors are the Inverse -Harmonic Mean Weighting (IHMW) function proposed by Laroia et al. -(see ). -These weights are referred to here as Laroia weights. - - -The LSF quantizer consists of two stages. -The first stage is an (unweighted) vector quantizer (VQ), with a -codebook size of 32 vectors. -The quantization errors for the codebook vector are sorted, and -for the N best vectors a second stage quantizer is run. -By varying the number N a tradeoff is made between R-D performance -and computational efficiency. -For each of the N codebook vectors the Laroia weights corresponding -to that vector (and not to the input vector) are calculated. -Then the residual between the input LSF vector and the codebook -vector is scaled by the square roots of these Laroia weights. -This scaling partially normalizes error sensitivity for the -residual vector, so that a uniform quantizer with fixed -step sizes can be used in the second stage without too much -performance loss. -And by scaling with Laroia weights determined from the first-stage -codebook vector, the process can be reversed in the decoder. - - -The second stage uses predictive delayed decision scalar -quantization. -The quantization error is weighted by Laroia weights determined -from the LSF input vector. -The predictor multiplies the previous quantized residual value -by a prediction coefficient that depends on the vector index from the -first stage VQ and on the location in the LSF vector. -The prediction is subtracted from the LSF residual value before -quantizing the result, and added back afterwards. -This subtraction can be interpreted as shifting the quantization levels -of the scalar quantizer, and as a result the quantization error of -each value depends on the quantization decision of the previous value. -This dependency is exploited by the delayed decision mechanism to -search for a quantization sequency with best R-D performance -with a Viterbi-like algorithm . -The quantizer processes the residual LSF vector in reverse order -(i.e., it starts with the highest residual LSF value). -This is done because the prediction works slightly -better in the reverse direction. - - -The quantization index of the first stage is entropy coded. -The quantization sequence from the second stage is also entropy -coded, where for each element the probability table is chosen -depending on the vector index from the first stage and the location -of that element in the LSF vector. - - -
    - -If the input is stable, finding the best candidate usually results in a -quantized vector that is also stable. Because of the two-stage approach, -however, it is possible that the best quantization candidate is unstable. -The encoder applies the same stabilization procedure applied by the decoder - (see to ensure the LSF parameters - are within their valid range, increasingly sorted, and have minimum - distances between each other and the border values. - -
    -
    - -
    - -For voiced frames, the prediction analysis described in - resulted in four sets -(one set per subframe) of five LTP coefficients, plus four weighting matrices. -The LTP coefficients for each subframe are quantized using entropy constrained -vector quantization. -A total of three vector codebooks are available for quantization, with -different rate-distortion trade-offs. The three codebooks have 10, 20, and -40 vectors and average rates of about 3, 4, and 5 bits per vector, respectively. -Consequently, the first codebook has larger average quantization distortion at -a lower rate, whereas the last codebook has smaller average quantization -distortion at a higher rate. -Given the weighting matrix W_ltp and LTP vector b, the weighted rate-distortion -measure for a codebook vector cb_i with rate r_i is give by -
    - - - -
    -where u is a fixed, heuristically-determined parameter balancing the distortion -and rate. -Which codebook gives the best performance for a given LTP vector depends on the -weighting matrix for that LTP vector. -For example, for a low valued W_ltp, it is advantageous to use the codebook -with 10 vectors as it has a lower average rate. -For a large W_ltp, on the other hand, it is often better to use the codebook -with 40 vectors, as it is more likely to contain the best codebook vector. -The weighting matrix W_ltp depends mostly on two aspects of the input signal. -The first is the periodicity of the signal; the more periodic, the larger W_ltp. -The second is the change in signal energy in the current subframe, relative to -the signal one pitch lag earlier. -A decaying energy leads to a larger W_ltp than an increasing energy. -Both aspects fluctuate relatively slowly, which causes the W_ltp matrices for -different subframes of one frame often to be similar. -Because of this, one of the three codebooks typically gives good performance -for all subframes, and therefore the codebook search for the subframe LTP -vectors is constrained to only allow codebook vectors to be chosen from the -same codebook, resulting in a rate reduction. -
    - - -To find the best codebook, each of the three vector codebooks is -used to quantize all subframe LTP vectors and produce a combined -weighted rate-distortion measure for each vector codebook. -The vector codebook with the lowest combined rate-distortion -over all subframes is chosen. The quantized LTP vectors are used -in the noise shaping quantizer, and the index of the codebook -plus the four indices for the four subframe codebook vectors -are passed on to the range encoder. - -
    - -
    - -In the prefilter the input signal is filtered using the spectral valley -de-emphasis filter coefficients from the noise shaping analysis -(see ). -By applying only the noise shaping analysis filter to the input signal, -it provides the input to the noise shaping quantizer. - -
    - -
    - -The noise shaping quantizer independently shapes the signal and coding noise -spectra to obtain a perceptually higher quality at the same bitrate. - - -The prefilter output signal is multiplied with a compensation gain G computed -in the noise shaping analysis. Then the output of a synthesis shaping filter -is added, and the output of a prediction filter is subtracted to create a -residual signal. -The residual signal is multiplied by the inverse quantized quantization gain -from the noise shaping analysis, and input to a scalar quantizer. -The quantization indices of the scalar quantizer represent a signal of pulses -that is input to the pyramid range encoder. -The scalar quantizer also outputs a quantization signal, which is multiplied -by the quantized quantization gain from the noise shaping analysis to create -an excitation signal. -The output of the prediction filter is added to the excitation signal to form -the quantized output signal y(n). -The quantized output signal y(n) is input to the synthesis shaping and -prediction filters. - - -Optionally the noise shaping quantizer operates in a delayed decision -mode. -In this mode it uses a Viterbi algorithm to keep track of -multiple rounding choices in the quantizer and select the best -one after a delay of 32 samples. This improves the rate/distortion -performance of the quantizer. - -
    - -
    - - SILK was designed to run in Variable Bitrate (VBR) mode. However - the reference implementation also has a Constant Bitrate (CBR) mode - for SILK. In CBR mode SILK will attempt to encode each packet with - no more than the allowed number of bits. The Opus wrapper code - then pads the bitstream if any unused bits are left in SILK mode, or - encodes the high band with the remaining number of bits in Hybrid mode. - The number of payload bits is adjusted by changing - the quantization gains and the rate/distortion tradeoff in the noise - shaping quantizer, in an iterative loop - around the noise shaping quantizer and entropy coding. - Compared to the SILK VBR mode, the CBR mode has lower - audio quality at a given average bitrate, and also has higher - computational complexity. - -
    - -
    - -
    - - -
    - -Most of the aspects of the CELT encoder can be directly derived from the description -of the decoder. For example, the filters and rotations in the encoder are simply the -inverse of the operation performed by the decoder. Similarly, the quantizers generally -optimize for the mean square error (because noise shaping is part of the bit-stream itself), -so no special search is required. For this reason, only the less straightforward aspects of the -encoder are described here. - - -
    -The pitch prefilter is applied after the pre-emphasis. It is applied -in such a way as to be the inverse of the decoder's post-filter. The main non-obvious aspect of the -prefilter is the selection of the pitch period. The pitch search should be optimized for the -following criteria: - -continuity: it is important that the pitch period -does not change abruptly between frames; and -avoidance of pitch multiples: when the period used is a multiple of the real period -(lower frequency fundamental), the post-filter loses most of its ability to reduce noise - - -
    - -
    - -The MDCT output is divided into bands that are designed to match the ear's critical -bands for the smallest (2.5 ms) frame size. The larger frame sizes use integer -multiples of the 2.5 ms layout. For each band, the encoder -computes the energy that will later be encoded. Each band is then normalized by the -square root of the unquantized energy, such that each band now forms a unit vector X. -The energy and the normalization are computed by compute_band_energies() -and normalise_bands() (bands.c), respectively. - -
    - -
    - - -Energy quantization (both coarse and fine) can be easily understood from the decoding process. -For all useful bitrates, the coarse quantizer always chooses the quantized log energy value that -minimizes the error for each band. Only at very low rate does the encoder allow larger errors to -minimize the rate and avoid using more bits than are available. When the -available CPU requirements allow it, it is best to try encoding the coarse energy both with and without -inter-frame prediction such that the best prediction mode can be selected. The optimal mode depends on -the coding rate, the available bitrate, and the current rate of packet loss. - - -The fine energy quantizer always chooses the quantized log energy value that -minimizes the error for each band because the rate of the fine quantization depends only -on the bit allocation and not on the values that are coded. - -
    - -
    -The encoder must use exactly the same bit allocation process as used by the decoder -and described in . The three mechanisms that can be used by the -encoder to adjust the bitrate on a frame-by-frame basis are band boost, allocation trim, -and band skipping. - - -
    -The reference encoder makes a decision to boost a band when the energy of that band is significantly -higher than that of the neighboring bands. Let E_j be the log-energy of band j, we define - -D_j = 2*E_j - E_j-1 - E_j+1 - - -The allocation of band j is boosted once if D_j > t1 and twice if D_j > t2. For LM>=1, t1=2 and t2=4, -while for LM<1, t1=3 and t2=5. - - -
    - -
    -The allocation trim is a value between 0 and 10 (inclusively) that controls the allocation -balance between the low and high frequencies. The encoder starts with a safe "default" of 5 -and deviates from that default in two different ways. First the trim can deviate by +/- 2 -depending on the spectral tilt of the input signal. For signals with more low frequencies, the -trim is increased by up to 2, while for signals with more high frequencies, the trim is -decreased by up to 2. -For stereo inputs, the trim value can -be decreased by up to 4 when the inter-channel correlation at low frequency (first 8 bands) -is high. -
    - -
    -The encoder uses band skipping to ensure that the shape of the bands is only coded -if there is at least 1/2 bit per sample available for the PVQ. If not, then no bit is allocated -and folding is used instead. To ensure continuity in the allocation, some amount of hysteresis is -added to the process, such that a band that received PVQ bits in the previous frame only needs 7/16 -bit/sample to be coded for the current frame, while a band that did not receive PVQ bits in the -previous frames needs at least 9/16 bit/sample to be coded. -
    - -
    - -
    -Because CELT applies mid-side stereo coupling in the normalized domain, it does not suffer from -important stereo image problems even when the two channels are completely uncorrelated. For this reason -it is always safe to use stereo coupling on any audio frame. That being said, there are some frames -for which dual (independent) stereo is still more efficient. This decision is made by comparing the estimated -entropy with and without coupling over the first 13 bands, taking into account the fact that all bands with -more than two MDCT bins require one extra degree of freedom when coded in mid-side. Let L1_ms and L1_lr -be the L1-norm of the mid-side vector and the L1-norm of the left-right vector, respectively. The decision -to use mid-side is made if and only if -
    - -
    -where bins is the number of MDCT bins in the first 13 bands and E is the number of extra degrees of -freedom for mid-side coding. For LM>1, E=13, otherwise E=5. -
    - -The reference encoder decides on the intensity stereo threshold based on the bitrate alone. After -taking into account the frame size by subtracting 80 bits per frame for coarse energy, the first -band using intensity coding is as follows: - - - -bitrate (kb/s) -start band -<35 8 -35-50 12 -50-68 16 -84-84 18 -84-102 19 -102-130 20 ->130 disabled - - - -
    - -
    - -The choice of time-frequency resolution used in is based on -R-D optimization. The distortion is the L1-norm (sum of absolute values) of each band -after each TF resolution under consideration. The L1 norm is used because it represents the entropy -for a Laplacian source. The number of bits required to code a change in TF resolution between -two bands is higher than the cost of having those two bands use the same resolution, which is -what requires the R-D optimization. The optimal decision is computed using the Viterbi algorithm. -See tf_analysis() in celt/celt.c. - -
    - -
    - -The choice of the spreading value in has an -impact on the nature of the coding noise introduced by CELT. The larger the f_r value, the -lower the impact of the rotation, and the more tonal the coding noise. The -more tonal the signal, the more tonal the noise should be, so the CELT encoder determines -the optimal value for f_r by estimating how tonal the signal is. The tonality estimate -is based on discrete pdf (4-bin histogram) of each band. Bands that have a large number of small -values are considered more tonal and a decision is made by combining all bands with more than -8 samples. See spreading_decision() in celt/bands.c. - -
    - -
    -CELT uses a Pyramid Vector Quantization (PVQ) -codebook for quantizing the details of the spectrum in each band that have not -been predicted by the pitch predictor. The PVQ codebook consists of all sums -of K signed pulses in a vector of N samples, where two pulses at the same position -are required to have the same sign. Thus the codebook includes -all integer codevectors y of N dimensions that satisfy sum(abs(y(j))) = K. - - - -In bands where there are sufficient bits allocated PVQ is used to encode -the unit vector that results from the normalization in - directly. Given a PVQ codevector y, -the unit vector X is obtained as X = y/||y||, where ||.|| denotes the -L2 norm. - - - -
    - - -The search for the best codevector y is performed by alg_quant() -(vq.c). There are several possible approaches to the -search, with a trade-off between quality and complexity. The method used in the reference -implementation computes an initial codeword y1 by projecting the normalized spectrum -X onto the codebook pyramid of K-1 pulses: - - -y0 = truncate_towards_zero( (K-1) * X / sum(abs(X))) - - - -Depending on N, K and the input data, the initial codeword y0 may contain from -0 to K-1 non-zero values. All the remaining pulses, with the exception of the last one, -are found iteratively with a greedy search that minimizes the normalized correlation -between y and X: -
    - -
    -
    - - -The search described above is considered to be a good trade-off between quality -and computational cost. However, there are other possible ways to search the PVQ -codebook and the implementers MAY use any other search methods. See alg_quant() in celt/vq.c. - -
    - -
    - - -The vector to encode, X, is converted into an index i such that - 0 <= i < V(N,K) as follows. -Let i = 0 and k = 0. -Then for j = (N - 1) down to 0, inclusive, do: - - -If k > 0, set - i = i + (V(N-j-1,k-1) + V(N-j,k-1))/2. - -Set k = k + abs(X[j]). - -If X[j] < 0, set - i = i + (V(N-j-1,k) + V(N-j,k))/2. - - - - - -The index i is then encoded using the procedure in - with ft = V(N,K). - - -
    - -
    - - - - - -
    - -
    - - -
    - - -It is our intention to allow the greatest possible choice of freedom in -implementing the specification. For this reason, outside of the exceptions -noted in this section, conformance is defined through the reference -implementation of the decoder provided in . -Although this document includes an English description of the codec, should -the description contradict the source code of the reference implementation, -the latter shall take precedence. - - - -Compliance with this specification means that in addition to following the normative keywords in this document, - a decoder's output MUST also be - within the thresholds specified by the opus_compare.c tool (included - with the code) when compared to the reference implementation for each of the - test vectors provided (see ) and for each output - sampling rate and channel count supported. In addition, a compliant - decoder implementation MUST have the same final range decoder state as that of the - reference decoder. It is therefore RECOMMENDED that the - decoder implement the same functional behavior as the reference. - - A decoder implementation is not required to support all output sampling - rates or all output channel counts. - - -
    - -Using the reference code provided in , -a test vector can be decoded with - -opus_demo -d <rate> <channels> testvectorX.bit testX.out - -where <rate> is the sampling rate and can be 8000, 12000, 16000, 24000, or 48000, and -<channels> is 1 for mono or 2 for stereo. - - - -If the range decoder state is incorrect for one of the frames, the decoder will exit with -"Error: Range coder state mismatch between encoder and decoder". If the decoder succeeds, then -the output can be compared with the "reference" output with - -opus_compare -s -r <rate> testvectorX.dec testX.out - -for stereo or - -opus_compare -r <rate> testvectorX.dec testX.out - -for mono. - - -In addition to indicating whether the test vector comparison passes, the opus_compare tool -outputs an "Opus quality metric" that indicates how well the tested decoder matches the -reference implementation. A quality of 0 corresponds to the passing threshold, while -a quality of 100 is the highest possible value and means that the output of the tested decoder is identical to the reference -implementation. The passing threshold (quality 0) was calibrated in such a way that it corresponds to -additive white noise with a 48 dB SNR (similar to what can be obtained on a cassette deck). -It is still possible for an implementation to sound very good with such a low quality measure -(e.g. if the deviation is due to inaudible phase distortion), but unless this is verified by -listening tests, it is RECOMMENDED that implementations achieve a quality above 90 for 48 kHz -decoding. For other sampling rates, it is normal for the quality metric to be lower -(typically as low as 50 even for a good implementation) because of harmless mismatch with -the delay and phase of the internal sampling rate conversion. - - - -On POSIX environments, the run_vectors.sh script can be used to verify all test -vectors. This can be done with - -run_vectors.sh <exec path> <vector path> <rate> - -where <exec path> is the directory where the opus_demo and opus_compare executables -are built and <vector path> is the directory containing the test vectors. - -
    - -
    - -Opus Custom is an OPTIONAL part of the specification that is defined to -handle special sample rates and frame rates that are not supported by the -main Opus specification. Use of Opus Custom is discouraged for all but very -special applications for which a frame size different from 2.5, 5, 10, or 20 ms is -needed (for either complexity or latency reasons). Because Opus Custom is -optional, streams encoded using Opus Custom cannot be expected to be decodable by all Opus -implementations. Also, because no in-band mechanism exists for specifying the sampling -rate and frame size of Opus Custom streams, out-of-band signaling is required. -In Opus Custom operation, only the CELT layer is available, using the opus_custom_* function -calls in opus_custom.h. - -
    - -
    - -
    - - -Implementations of the Opus codec need to take appropriate security considerations -into account, as outlined in . -It is extremely important for the decoder to be robust against malicious -payloads. -Malicious payloads must not cause the decoder to overrun its allocated memory - or to take an excessive amount of resources to decode. -Although problems -in encoders are typically rarer, the same applies to the encoder. Malicious -audio streams must not cause the encoder to misbehave because this would -allow an attacker to attack transcoding gateways. - - -The reference implementation contains no known buffer overflow or cases where - a specially crafted packet or audio segment could cause a significant increase - in CPU load. -However, on certain CPU architectures where denormalized floating-point - operations are much slower than normal floating-point operations, it is - possible for some audio content (e.g., silence or near-silence) to cause an - increase in CPU load. -Denormals can be introduced by reordering operations in the compiler and depend - on the target architecture, so it is difficult to guarantee that an implementation - avoids them. -For architectures on which denormals are problematic, adding very small - floating-point offsets to the affected signals to prevent significant numbers - of denormalized operations is RECOMMENDED. -Alternatively, it is often possible to configure the hardware to treat - denormals as zero (DAZ). -No such issue exists for the fixed-point reference implementation. - -The reference implementation was validated in the following conditions: - - -Sending the decoder valid packets generated by the reference encoder and - verifying that the decoder's final range coder state matches that of the - encoder. - - -Sending the decoder packets generated by the reference encoder and then - subjected to random corruption. - -Sending the decoder random packets. - -Sending the decoder packets generated by a version of the reference encoder - modified to make random coding decisions (internal fuzzing), including mode - switching, and verifying that the range coder final states match. - - -In all of the conditions above, both the encoder and the decoder were run - inside the Valgrind memory - debugger, which tracks reads and writes to invalid memory regions as well as - the use of uninitialized memory. -There were no errors reported on any of the tested conditions. - -
    - - -
    - -This document has no actions for IANA. - -
    - -
    - -Thanks to all other developers, including Raymond Chen, Soeren Skak Jensen, Gregory Maxwell, -Christopher Montgomery, and Karsten Vandborg Soerensen. We would also -like to thank Igor Dyakonov, Jan Skoglund, and Christian Hoene for their help with subjective testing of the -Opus codec. Thanks to Ralph Giles, John Ridges, Ben Schwartz, Keith Yan, Christian Hoene, Kat Walsh, and many others on the Opus and CELT mailing lists -for their bug reports and feedback. - -
    - -
    -The authors agree to grant third parties the irrevocable right to copy, use and distribute -the work (excluding Code Components available under the simplified BSD license), with or -without modification, in any medium, without royalty, provided that, unless separate -permission is granted, redistributed modified works do not contain misleading author, version, -name of work, or endorsement information. -
    - -
    - - - - - - - -Key words for use in RFCs to Indicate Requirement Levels - - - - - - - - - - - -Requirements for an Internet Audio Codec - - - - - -IETF - - -This document provides specific requirements for an Internet audio - codec. These requirements address quality, sample rate, bitrate, - and packet-loss robustness, as well as other desirable properties. - - - - - - - - - - -SILK Speech Codec - - - - - - - - - - - - - - - - - -Robust and Efficient Quantization of Speech LSP Parameters Using Structured Vector Quantization - - - - - - - - - - - - - - - - -Constrained-Energy Lapped Transform (CELT) Codec - - - - - - - - - - - - - - - - - - -Guidelines for the use of Variable Bit Rate Audio with Secure RTP - - - - - - - - - - - - - - -Internet Denial-of-Service Considerations - - - - - -IAB - - -This document provides an overview of possible avenues for denial-of-service (DoS) attack on Internet systems. The aim is to encourage protocol designers and network engineers towards designs that are more robust. We discuss partial solutions that reduce the effectiveness of attacks, and how some solutions might inadvertently open up alternative vulnerabilities. This memo provides information for the Internet community. - - - - - - -Range encoding: An algorithm for removing redundancy from a digitised message - - - - - - - - -Source coding algorithms for fast data compression - - - - - - - - -A Pyramid Vector Quantizer - - - - - - - - -The Computation of Line Spectral Frequencies Using Chebyshev Polynomials - - - - - - - - - - -Valgrind website - - - - - - -Google NetEQ code - - - - - - -Google WebRTC code - - - - - - - -Opus Git Repository - - - - - - -Opus website - - - - - - -Vorbis website - - - - - - -Matroska website - - - - - - -Opus Testvectors (webside) - - - - - - -Opus Testvectors (proceedings) - - - - - - -Line Spectral Pairs -Wikipedia - - - - - -Range Coding -Wikipedia - - - - - -Hadamard Transform -Wikipedia - - - - - -Viterbi Algorithm -Wikipedia - - - - - -White Noise -Wikipedia - - - - - -Linear Prediction -Wikipedia - - - - - -Modified Discrete Cosine Transform -Wikipedia - - - - - -Fast Fourier Transform -Wikipedia - - - - - -Z-transform -Wikipedia - - - - - - -Maximum Entropy Spectral Analysis - - - - - - -A fixed point computation of partial correlation coefficients - - - - - - - - -Analysis/synthesis filter bank design based on time domain aliasing cancellation - - - - - - - - -A High-Quality Speech and Audio Codec With Less Than 10 ms delay - - - - - - - - - - - - -Subdivision of the audible frequency range into critical bands - - - - - - - - - -
    - -This appendix contains the complete source code for the -reference implementation of the Opus codec written in C. By default, -this implementation relies on floating-point arithmetic, but it can be -compiled to use only fixed-point arithmetic by defining the FIXED_POINT -macro. Information on building and using the reference implementation is -available in the README file. - - -The implementation can be compiled with either a C89 or a C99 -compiler. It is reasonably optimized for most platforms such that -only architecture-specific optimizations are likely to be useful. -The FFT used is a slightly modified version of the KISS-FFT library, -but it is easy to substitute any other FFT library. - - - -While the reference implementation 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: - -Right shifts of negative values are consistent with two's complement arithmetic, so that a>>b is equivalent to floor(a/(2**b)), -For conversion to a signed integer of N bits, the value is reduced modulo 2**N to be within range of the type, -The result of integer division of a negative value is truncated towards zero, and -The compiler provides a 64-bit integer type (a C99 requirement which is supported by most C89 compilers). - - - - -In its current form, the reference implementation also requires the following -architectural characteristics to obtain acceptable performance: - -Two's complement arithmetic, -At least a 16 bit by 16 bit integer multiplier (32-bit result), and -At least a 32-bit adder/accumulator. - - - - -
    - -The complete source code can be extracted from this draft, by running the -following command line: - - - opus_source.tar.gz -]]> - -tar xzvf opus_source.tar.gz - -cd opus_source -make - -On systems where the provided Makefile does not work, the following command line may be used to compile -the source code: - - - - - -On systems where the base64 utility is not present, the following commands can be used instead: - - opus.b64 -]]> -openssl base64 -d -in opus.b64 > opus_source.tar.gz - - - -
    - -
    - -As of the time of publication of this memo, an up-to-date implementation conforming to -this standard is available in a - Git repository. -Releases and other resources are available at - . However, although that implementation is expected to - remain conformant with the standard, it is the code in this document that shall - remain normative. - -
    - -
    - - - -
    - -
    - -Because of size constraints, the Opus test vectors are not distributed in this -draft. They are available in the proceedings of the 83th IETF meeting (Paris) and from the Opus codec website at -. These test vectors were created specifically to exercise -all aspects of the decoder and therefore the audio quality of the decoded output is -significantly lower than what Opus can achieve in normal operation. - - - -The SHA1 hash of the files in the test vector package are - - - -
    - -
    - -
    - -To use the internal framing described in , the decoder - must know the total length of the Opus packet, in bytes. -This section describes a simple variation of that framing which can be used - when the total length of the packet is not known. -Nothing in the encoding of the packet itself allows a decoder to distinguish - between the regular, undelimited framing and the self-delimiting framing - described in this appendix. -Which one is used and where must be established by context at the transport - layer. -It is RECOMMENDED that a transport layer choose exactly one framing scheme, - rather than allowing an encoder to signal which one it wants to use. - - - -For example, although a regular Opus stream does not support more than two - channels, a multi-channel Opus stream may be formed from several one- and - two-channel streams. -To pack an Opus packet from each of these streams together in a single packet - at the transport layer, one could use the self-delimiting framing for all but - the last stream, and then the regular, undelimited framing for the last one. -Reverting to the undelimited framing for the last stream saves overhead - (because the total size of the transport-layer packet will still be known), - and ensures that a "multi-channel" stream which only has a single Opus stream - uses the same framing as a regular Opus stream does. -This avoids the need for signaling to distinguish these two cases. - - - -The self-delimiting framing is identical to the regular, undelimited framing - from , except that each Opus packet contains one extra - length field, encoded using the same one- or two-byte scheme from - . -This extra length immediately precedes the compressed data of the first Opus - frame in the packet, and is interpreted in the various modes as follows: - - -Code 0 packets: It is the length of the single Opus frame (see - ). - - -Code 1 packets: It is the length used for both of the Opus frames (see - ). - - -Code 2 packets: It is the length of the second Opus frame (see - ). - -CBR Code 3 packets: It is the length used for all of the Opus frames (see - ). - -VBR Code 3 packets: It is the length of the last Opus frame (see - ). - - - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    diff --git a/Engine/lib/opus/doc/draft-ietf-payload-rtp-opus.xml b/Engine/lib/opus/doc/draft-ietf-payload-rtp-opus.xml deleted file mode 100644 index c4eb21077..000000000 --- a/Engine/lib/opus/doc/draft-ietf-payload-rtp-opus.xml +++ /dev/null @@ -1,960 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - ]> - - - - - - - - - - - - - - - - - - RTP Payload Format for the Opus Speech and Audio Codec - - - -
    - jspittka@gmail.com -
    -
    - - - vocTone -
    - - - - - - - - koenvos74@gmail.com -
    -
    - - - Mozilla -
    - - 331 E. Evelyn Avenue - Mountain View - CA - 94041 - USA - - jmvalin@jmvalin.ca -
    -
    - - - - - - This document defines the Real-time Transport Protocol (RTP) payload - format for packetization of Opus encoded - speech and audio data necessary to integrate the codec in the - most compatible way. It also provides an applicability statement - for the use of Opus over RTP. Further, it describes media type registrations - for the RTP payload format. - - -
    - - -
    - - Opus is a speech and audio codec developed within the - IETF Internet Wideband Audio Codec working group. The codec - has a very low algorithmic delay and it - is highly scalable in terms of audio bandwidth, bitrate, and - complexity. Further, it provides different modes to efficiently encode speech signals - as well as music signals, thus making it the codec of choice for - various applications using the Internet or similar networks. - - - This document defines the Real-time Transport Protocol (RTP) - payload format for packetization - of Opus encoded speech and audio data necessary to - integrate Opus in the - most compatible way. It also provides an applicability statement - for the use of Opus over RTP. - Further, it describes media type registrations for - the RTP payload format. - -
    - -
    - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this - document are to be interpreted as described in . - - - The range of audio frequecies being coded - Constant bitrate - Central Processing Unit - Discontinuous transmission - Forward error correction - Internet Protocol - Speech or audio samples (per channel) - Session Description Protocol - Variable bitrate - - - - Throughout this document, we refer to the following definitions: - - - Abbreviation - Name - Audio Bandwidth (Hz) - Sampling Rate (Hz) - NB - Narrowband - 0 - 4000 - 8000 - - MB - Mediumband - 0 - 6000 - 12000 - - WB - Wideband - 0 - 8000 - 16000 - - SWB - Super-wideband - 0 - 12000 - 24000 - - FB - Fullband - 0 - 20000 - 48000 - - - Audio bandwidth naming - - -
    - -
    - - Opus encodes speech - signals as well as general audio signals. Two different modes can be - chosen, a voice mode or an audio mode, to allow the most efficient coding - depending on the type of the input signal, the sampling frequency of the - input signal, and the intended application. - - - - The voice mode allows efficient encoding of voice signals at lower bit - rates while the audio mode is optimized for general audio signals at medium and - higher bitrates. - - - - Opus is highly scalable in terms of audio - bandwidth, bitrate, and complexity. Further, Opus allows - transmitting stereo signals with in-band signaling in the bit-stream. - - -
    - - Opus supports bitrates from 6 kb/s to 510 kb/s. - The bitrate can be changed dynamically within that range. - All - other parameters being - equal, higher bitrates result in higher audio quality. - -
    - - For a frame size of - 20 ms, these - are the bitrate "sweet spots" for Opus in various configurations: - - - 8-12 kb/s for NB speech, - 16-20 kb/s for WB speech, - 28-40 kb/s for FB speech, - 48-64 kb/s for FB mono music, and - 64-128 kb/s for FB stereo music. - - -
    -
    - - For the same average bitrate, variable bitrate (VBR) can achieve higher audio quality - than constant bitrate (CBR). For the majority of voice transmission applications, VBR - is the best choice. One reason for choosing CBR is the potential - information leak that might occur when encrypting the - compressed stream. See for guidelines on when VBR is - appropriate for encrypted audio communications. In the case where an existing - VBR stream needs to be converted to CBR for security reasons, then the Opus padding - mechanism described in is the RECOMMENDED way to achieve padding - because the RTP padding bit is unencrypted. - - - The bitrate can be adjusted at any point in time. To avoid congestion, - the average bitrate SHOULD NOT exceed the available - network bandwidth. If no target bitrate is specified, the bitrates specified in - are RECOMMENDED. - - -
    - -
    - - - Opus can, as described in , - be operated with a variable bitrate. In that case, the encoder will - automatically reduce the bitrate for certain input signals, like periods - of silence. When using continuous transmission, it will reduce the - bitrate when the characteristics of the input signal permit, but - will never interrupt the transmission to the receiver. Therefore, the - received signal will maintain the same high level of audio quality over the - full duration of a transmission while minimizing the average bit - rate over time. - - - - In cases where the bitrate of Opus needs to be reduced even - further or in cases where only constant bitrate is available, - the Opus encoder can use discontinuous - transmission (DTX), where parts of the encoded signal that - correspond to periods of silence in the input speech or audio signal - are not transmitted to the receiver. A receiver can distinguish - between DTX and packet loss by looking for gaps in the sequence - number, as described by Section 4.1 - of . - - - - On the receiving side, the non-transmitted parts will be handled by a - frame loss concealment unit in the Opus decoder which generates a - comfort noise signal to replace the non transmitted parts of the - speech or audio signal. Use of Comfort - Noise (CN) with Opus is discouraged. - The transmitter MUST drop whole frames only, - based on the size of the last transmitted frame, - to ensure successive RTP timestamps differ by a multiple of 120 and - to allow the receiver to use whole frames for concealment. - - - - DTX can be used with both variable and constant bitrate. - It will have a slightly lower speech or audio - quality than continuous transmission. Therefore, using continuous - transmission is RECOMMENDED unless constraints on available network bandwidth - are severe. - - -
    - -
    - -
    - - - Complexity of the encoder can be scaled to optimize for CPU resources in real-time, mostly as - a trade-off between audio quality and bitrate. Also, different modes of Opus have different complexity. - - -
    - -
    - - - The voice mode of Opus allows for embedding "in-band" forward error correction (FEC) - data into the Opus bit stream. This FEC scheme adds - redundant information about the previous packet (N-1) to the current - output packet N. For - each frame, the encoder decides whether to use FEC based on (1) an - externally-provided estimate of the channel's packet loss rate; (2) an - externally-provided estimate of the channel's capacity; (3) the - sensitivity of the audio or speech signal to packet loss; (4) whether - the receiving decoder has indicated it can take advantage of "in-band" - FEC information. The decision to send "in-band" FEC information is - entirely controlled by the encoder and therefore no special precautions - for the payload have to be taken. - - - - On the receiving side, the decoder can take advantage of this - additional information when it loses a packet and the next packet - is available. In order to use the FEC data, the jitter buffer needs - to provide access to payloads with the FEC data. - Instead of performing loss concealment for a missing packet, the - receiver can then configure its decoder to decode the FEC data from the next packet. - - - - Any compliant Opus decoder is capable of ignoring - FEC information when it is not needed, so encoding with FEC cannot cause - interoperability problems. - However, if FEC cannot be used on the receiving side, then FEC - SHOULD NOT be used, as it leads to an inefficient usage of network - resources. Decoder support for FEC SHOULD be indicated at the time a - session is set up. - - -
    - -
    - - - Opus allows for transmission of stereo audio signals. This operation - is signaled in-band in the Opus bit-stream and no special arrangement - is needed in the payload format. An - Opus decoder is capable of handling a stereo encoding, but an - application might only be capable of consuming a single audio - channel. - - - If a decoder cannot take advantage of the benefits of a stereo signal - this SHOULD be indicated at the time a session is set up. In that case - the sending side SHOULD NOT send stereo signals as it leads to an - inefficient usage of network resources. - - -
    - -
    - -
    - The payload format for Opus consists of the RTP header and Opus payload - data. -
    - The format of the RTP header is specified in . - The use of the fields of the RTP header by the Opus payload format is - consistent with that specification. - - The payload length of Opus is an integer number of octets and - therefore no padding is necessary. The payload MAY be padded by an - integer number of octets according to , - although the Opus internal padding is preferred. - - The timestamp, sequence number, and marker bit (M) of the RTP header - are used in accordance with Section 4.1 - of . - - The RTP payload type for Opus is to be assigned dynamically. - - The receiving side MUST be prepared to receive duplicate RTP - packets. The receiver MUST provide at most one of those payloads to the - Opus decoder for decoding, and MUST discard the others. - - Opus supports 5 different audio bandwidths, which can be adjusted during - a stream. - The RTP timestamp is incremented with a 48000 Hz clock rate - for all modes of Opus and all sampling rates. - The unit - for the timestamp is samples per single (mono) channel. The RTP timestamp corresponds to the - sample time of the first encoded sample in the encoded frame. - For data encoded with sampling rates other than 48000 Hz, - the sampling rate has to be adjusted to 48000 Hz. - -
    - -
    - - The Opus encoder can output encoded frames representing 2.5, 5, 10, 20, - 40, or 60 ms of speech or audio data. Further, an arbitrary number of frames can be - combined into a packet, up to a maximum packet duration representing - 120 ms of speech or audio data. The grouping of one or more Opus - frames into a single Opus packet is defined in Section 3 of - . An RTP payload MUST contain exactly one - Opus packet as defined by that document. - - - shows the structure combined with the RTP header. - -
    - - - -
    - - - shows supported frame sizes in - milliseconds of encoded speech or audio data for the speech and audio modes - (Mode) and sampling rates (fs) of Opus and shows how the timestamp is - incremented for packetization (ts incr). If the Opus encoder - outputs multiple encoded frames into a single packet, the timestamp - increment is the sum of the increments for the individual frames. - - - - Mode - fs - 2.5 - 5 - 10 - 20 - 40 - 60 - ts incr - all - 120 - 240 - 480 - 960 - 1920 - 2880 - voice - NB/MB/WB/SWB/FB - x - x - o - o - o - o - audio - NB/WB/SWB/FB - o - o - o - o - x - x - - -
    - -
    - -
    - - The target bitrate of Opus can be adjusted at any point in time, thus - allowing efficient congestion control. Furthermore, the amount - of encoded speech or audio data encoded in a - single packet can be used for congestion control, since the transmission - rate is inversely proportional to the packet duration. A lower packet - transmission rate reduces the amount of header overhead, but at the same - time increases latency and loss sensitivity, so it ought to be used with - care. - - Since UDP does not provide congestion control, applications that use - RTP over UDP SHOULD implement their own congestion control above the - UDP layer . Work in the rmcat working group - describes the - interactions and conceptual interfaces necessary between the application - components that relate to congestion control, including the RTP layer, - the higher-level media codec control layer, and the lower-level - transport interface, as well as components dedicated to congestion - control functions. -
    - -
    - One media subtype (audio/opus) has been defined and registered as - described in the following section. - -
    - Media type registration is done according to and . - - Type name: audio - Subtype name: opus - - Required parameters: - - the RTP timestamp is incremented with a - 48000 Hz clock rate for all modes of Opus and all sampling - rates. For data encoded with sampling rates other than 48000 Hz, - the sampling rate has to be adjusted to 48000 Hz. - - - - Optional parameters: - - - - a hint about the maximum output sampling rate that the receiver is - capable of rendering in Hz. - The decoder MUST be capable of decoding - any audio bandwidth but due to hardware limitations only signals - up to the specified sampling rate can be played back. Sending signals - with higher audio bandwidth results in higher than necessary network - usage and encoding complexity, so an encoder SHOULD NOT encode - frequencies above the audio bandwidth specified by maxplaybackrate. - This parameter can take any value between 8000 and 48000, although - commonly the value will match one of the Opus bandwidths - (). - By default, the receiver is assumed to have no limitations, i.e. 48000. - - - - - a hint about the maximum input sampling rate that the sender is likely to produce. - This is not a guarantee that the sender will never send any higher bandwidth - (e.g. it could send a pre-recorded prompt that uses a higher bandwidth), but it - indicates to the receiver that frequencies above this maximum can safely be discarded. - This parameter is useful to avoid wasting receiver resources by operating the audio - processing pipeline (e.g. echo cancellation) at a higher rate than necessary. - This parameter can take any value between 8000 and 48000, although - commonly the value will match one of the Opus bandwidths - (). - By default, the sender is assumed to have no limitations, i.e. 48000. - - - - the maximum duration of media represented - by a packet (according to Section 6 of - ) that a decoder wants to receive, in - milliseconds rounded up to the next full integer value. - Possible values are 3, 5, 10, 20, 40, 60, or an arbitrary - multiple of an Opus frame size rounded up to the next full integer - value, up to a maximum value of 120, as - defined in . If no value is - specified, the default is 120. - - - the preferred duration of media represented - by a packet (according to Section 6 of - ) that a decoder wants to receive, in - milliseconds rounded up to the next full integer value. - Possible values are 3, 5, 10, 20, 40, 60, or an arbitrary - multiple of an Opus frame size rounded up to the next full integer - value, up to a maximum value of 120, as defined in . If no value is - specified, the default is 20. - - - specifies the maximum average - receive bitrate of a session in bits per second (b/s). The actual - value of the bitrate can vary, as it is dependent on the - characteristics of the media in a packet. Note that the maximum - average bitrate MAY be modified dynamically during a session. Any - positive integer is allowed, but values outside the range - 6000 to 510000 SHOULD be ignored. If no value is specified, the - maximum value specified in - for the corresponding mode of Opus and corresponding maxplaybackrate - is the default. - - - specifies whether the decoder prefers receiving stereo or mono signals. - Possible values are 1 and 0 where 1 specifies that stereo signals are preferred, - and 0 specifies that only mono signals are preferred. - Independent of the stereo parameter every receiver MUST be able to receive and - decode stereo signals but sending stereo signals to a receiver that signaled a - preference for mono signals may result in higher than necessary network - utilization and encoding complexity. If no value is specified, - the default is 0 (mono). - - - - specifies whether the sender is likely to produce stereo audio. - Possible values are 1 and 0, where 1 specifies that stereo signals are likely to - be sent, and 0 specifies that the sender will likely only send mono. - This is not a guarantee that the sender will never send stereo audio - (e.g. it could send a pre-recorded prompt that uses stereo), but it - indicates to the receiver that the received signal can be safely downmixed to mono. - This parameter is useful to avoid wasting receiver resources by operating the audio - processing pipeline (e.g. echo cancellation) in stereo when not necessary. - If no value is specified, the default is 0 - (mono). - - - - specifies if the decoder prefers the use of a constant bitrate versus - variable bitrate. Possible values are 1 and 0, where 1 specifies constant - bitrate and 0 specifies variable bitrate. If no value is specified, - the default is 0 (vbr). When cbr is 1, the maximum average bitrate can still - change, e.g. to adapt to changing network conditions. - - - specifies that the decoder has the capability to - take advantage of the Opus in-band FEC. Possible values are 1 and 0. - Providing 0 when FEC cannot be used on the receiving side is - RECOMMENDED. If no - value is specified, useinbandfec is assumed to be 0. - This parameter is only a preference and the receiver MUST be able to process - packets that include FEC information, even if it means the FEC part is discarded. - - - specifies if the decoder prefers the use of - DTX. Possible values are 1 and 0. If no value is specified, the - default is 0. - - - Encoding considerations: - - The Opus media type is framed and consists of binary data according - to Section 4.8 in . - - - Security considerations: - - See of this document. - - - Interoperability considerations: none - Published specification: RFC [XXXX] - Note to the RFC Editor: Replace [XXXX] with the number of the published - RFC. - - Applications that use this media type: - - Any application that requires the transport of - speech or audio data can use this media type. Some examples are, - but not limited to, audio and video conferencing, Voice over IP, - media streaming. - - - Fragment identifier considerations: N/A - - Person & email address to contact for further information: - - SILK Support silksupport@skype.net - Jean-Marc Valin jmvalin@jmvalin.ca - - - Intended usage: COMMON - - Restrictions on usage: - - - For transfer over RTP, the RTP payload format ( of this document) SHALL be - used. - - - Author: - - Julian Spittka jspittka@gmail.com - Koen Vos koenvos74@gmail.com - Jean-Marc Valin jmvalin@jmvalin.ca - - - Change controller: IETF Payload Working Group delegated from the IESG -
    -
    - -
    - The information described in the media type specification has a - specific mapping to fields in the Session Description Protocol (SDP) - , which is commonly used to describe RTP - sessions. When SDP is used to specify sessions employing Opus, - the mapping is as follows: - - - - The media type ("audio") goes in SDP "m=" as the media name. - - The media subtype ("opus") goes in SDP "a=rtpmap" as the encoding - name. The RTP clock rate in "a=rtpmap" MUST be 48000 and the number of - channels MUST be 2. - - The OPTIONAL media type parameters "ptime" and "maxptime" are - mapped to "a=ptime" and "a=maxptime" attributes, respectively, in the - SDP. - - The OPTIONAL media type parameters "maxaveragebitrate", - "maxplaybackrate", "stereo", "cbr", "useinbandfec", and - "usedtx", when present, MUST be included in the "a=fmtp" attribute - in the SDP, expressed as a media type string in the form of a - semicolon-separated list of parameter=value pairs (e.g., - maxplaybackrate=48000). They MUST NOT be specified in an - SSRC-specific "fmtp" source-level attribute (as defined in - Section 6.3 of ). - - The OPTIONAL media type parameters "sprop-maxcapturerate", - and "sprop-stereo" MAY be mapped to the "a=fmtp" SDP attribute by - copying them directly from the media type parameter string as part - of the semicolon-separated list of parameter=value pairs (e.g., - sprop-stereo=1). These same OPTIONAL media type parameters MAY also - be specified using an SSRC-specific "fmtp" source-level attribute - as described in Section 6.3 of . - They MAY be specified in both places, in which case the parameter - in the source-level attribute overrides the one found on the - "a=fmtp" line. The value of any parameter which is not specified in - a source-level source attribute MUST be taken from the "a=fmtp" - line, if it is present there. - - - - - Below are some examples of SDP session descriptions for Opus: - - Example 1: Standard mono session with 48000 Hz clock rate -
    - - - -
    - - - Example 2: 16000 Hz clock rate, maximum packet size of 40 ms, - recommended packet size of 40 ms, maximum average bitrate of 20000 bps, - prefers to receive stereo but only plans to send mono, FEC is desired, - DTX is not desired - -
    - - - -
    - - Example 3: Two-way full-band stereo preferred - -
    - - - -
    - - -
    - - When using the offer-answer procedure described in to negotiate the use of Opus, the following - considerations apply: - - - - Opus supports several clock rates. For signaling purposes only - the highest, i.e. 48000, is used. The actual clock rate of the - corresponding media is signaled inside the payload and is not - restricted by this payload format description. The decoder MUST be - capable of decoding every received clock rate. An example - is shown below: - -
    - - - -
    -
    - - The "ptime" and "maxptime" parameters are unidirectional - receive-only parameters and typically will not compromise - interoperability; however, some values might cause application - performance to suffer. defines the SDP offer-answer handling of the - "ptime" parameter. The "maxptime" parameter MUST be handled in the - same way. - - - The "maxplaybackrate" parameter is a unidirectional receive-only - parameter that reflects limitations of the local receiver. When - sending to a single destination, a sender MUST NOT use an audio - bandwidth higher than necessary to make full use of audio sampled at - a sampling rate of "maxplaybackrate". Gateways or senders that - are sending the same encoded audio to multiple destinations - SHOULD NOT use an audio bandwidth higher than necessary to - represent audio sampled at "maxplaybackrate", as this would lead - to inefficient use of network resources. - The "maxplaybackrate" parameter does not - affect interoperability. Also, this parameter SHOULD NOT be used - to adjust the audio bandwidth as a function of the bitrate, as this - is the responsibility of the Opus encoder implementation. - - - The "maxaveragebitrate" parameter is a unidirectional receive-only - parameter that reflects limitations of the local receiver. The sender - of the other side MUST NOT send with an average bitrate higher than - "maxaveragebitrate" as it might overload the network and/or - receiver. The "maxaveragebitrate" parameter typically will not - compromise interoperability; however, some values might cause - application performance to suffer, and ought to be set with - care. - - The "sprop-maxcapturerate" and "sprop-stereo" parameters are - unidirectional sender-only parameters that reflect limitations of - the sender side. - They allow the receiver to set up a reduced-complexity audio - processing pipeline if the sender is not planning to use the full - range of Opus's capabilities. - Neither "sprop-maxcapturerate" nor "sprop-stereo" affect - interoperability and the receiver MUST be capable of receiving any signal. - - - - The "stereo" parameter is a unidirectional receive-only - parameter. When sending to a single destination, a sender MUST - NOT use stereo when "stereo" is 0. Gateways or senders that are - sending the same encoded audio to multiple destinations SHOULD - NOT use stereo when "stereo" is 0, as this would lead to - inefficient use of network resources. The "stereo" parameter does - not affect interoperability. - - - - The "cbr" parameter is a unidirectional receive-only - parameter. - - - The "useinbandfec" parameter is a unidirectional receive-only - parameter. - - The "usedtx" parameter is a unidirectional receive-only - parameter. - - Any unknown parameter in an offer MUST be ignored by the receiver - and MUST be removed from the answer. - -
    - - - The Opus parameters in an SDP Offer/Answer exchange are completely - orthogonal, and there is no relationship between the SDP Offer and - the Answer. - -
    - -
    - - For declarative use of SDP such as in Session Announcement Protocol - (SAP), , and RTSP, , for - Opus, the following needs to be considered: - - - - The values for "maxptime", "ptime", "maxplaybackrate", and - "maxaveragebitrate" ought to be selected carefully to ensure that a - reasonable performance can be achieved for the participants of a session. - - - The values for "maxptime", "ptime", and of the payload - format configuration are recommendations by the decoding side to ensure - the best performance for the decoder. - - - All other parameters of the payload format configuration are declarative - and a participant MUST use the configurations that are provided for - the session. More than one configuration can be provided if necessary - by declaring multiple RTP payload types; however, the number of types - ought to be kept small. - -
    -
    - -
    - - Use of variable bitrate (VBR) is subject to the security considerations in - . - - RTP packets using the payload format defined in this specification - are subject to the security considerations discussed in the RTP - specification , and in any applicable RTP profile such as - RTP/AVP , RTP/AVPF , - RTP/SAVP or RTP/SAVPF . - However, as "Securing the RTP Protocol Framework: - Why RTP Does Not Mandate a Single Media Security Solution" - discusses, it is not an RTP payload - format's responsibility to discuss or mandate what solutions are used - to meet the basic security goals like confidentiality, integrity and - source authenticity for RTP in general. This responsibility lays on - anyone using RTP in an application. They can find guidance on - available security mechanisms and important considerations in Options - for Securing RTP Sessions [I-D.ietf-avtcore-rtp-security-options]. - Applications SHOULD use one or more appropriate strong security - mechanisms. - - This payload format and the Opus encoding do not exhibit any - significant non-uniformity in the receiver-end computational load and thus - are unlikely to pose a denial-of-service threat due to the receipt of - pathological datagrams. -
    - -
    - Many people have made useful comments and suggestions contributing to this document. - In particular, we would like to thank - Tina le Grand, Cullen Jennings, Jonathan Lennox, Gregory Maxwell, Colin Perkins, Jan Skoglund, - Timothy B. Terriberry, Martin Thompson, Justin Uberti, Magnus Westerlund, and Mo Zanaty. -
    -
    - - - - &rfc2119; - &rfc3389; - &rfc3550; - &rfc3711; - &rfc3551; - &rfc6838; - &rfc4855; - &rfc4566; - &rfc3264; - &rfc2326; - &rfc5576; - &rfc6562; - &rfc6716; - - - - &rfc2974; - &rfc4585; - &rfc5124; - &rfc5405; - &rfc7202; - - - - rmcat documents - - - - - - - - - - - -
    diff --git a/Engine/lib/opus/doc/footer.html b/Engine/lib/opus/doc/footer.html deleted file mode 100644 index 346c40aba..000000000 --- a/Engine/lib/opus/doc/footer.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - -
    -For more information visit the Opus Website. - - -
    - - - diff --git a/Engine/lib/opus/doc/header.html b/Engine/lib/opus/doc/header.html deleted file mode 100644 index babdcf6d7..000000000 --- a/Engine/lib/opus/doc/header.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - -$projectname: $title -$title - - - -$treeview -$search -$mathjax - -$extrastylesheet - - -
    - - -
    - - - - - - - - - - - - - - - - - - - - - - -
    -
    Opus
    -
    - - -
    -
    $projectbrief
    -
    $projectnumber -
    -
    -
    $projectbrief
    -
    $searchbox
    -
    - - diff --git a/Engine/lib/opus/doc/meson.build b/Engine/lib/opus/doc/meson.build deleted file mode 100644 index ee42a2b02..000000000 --- a/Engine/lib/opus/doc/meson.build +++ /dev/null @@ -1,33 +0,0 @@ -have_dot = find_program('dot', required: false).found() - -doxyfile_conf = configuration_data() -doxyfile_conf.set('VERSION', opus_version) -doxyfile_conf.set('HAVE_DOT', have_dot) -doxyfile_conf.set('top_srcdir', top_srcdir) -doxyfile_conf.set('top_builddir', top_builddir) - -doxyfile = configure_file(input: 'Doxyfile.in', - output: 'Doxyfile', - configuration: doxyfile_conf, - install: false) - -docdir = join_paths(get_option('datadir'), get_option('docdir')) - -doc_inputs = [ - 'customdoxygen.css', - 'footer.html', - 'header.html', - 'opus_logo.svg', - top_srcdir + '/include/opus.h', - top_srcdir + '/include/opus_multistream.h', - top_srcdir + '/include/opus_defines.h', - top_srcdir + '/include/opus_types.h', - top_srcdir + '/include/opus_custom.h', -] - -custom_target('doc', - input: [ doxyfile ] + doc_inputs, - output: [ 'html' ], - command: [ doxygen, doxyfile ], - install_dir: docdir, - install: true) diff --git a/Engine/lib/opus/doc/opus_in_isobmff.css b/Engine/lib/opus/doc/opus_in_isobmff.css deleted file mode 100644 index bffe8f45a..000000000 --- a/Engine/lib/opus/doc/opus_in_isobmff.css +++ /dev/null @@ -1,60 +0,0 @@ -/* Normal links */ -.normal_link a:link -{ - color : yellow; -} -.normal_link a:visited -{ - color : green; -} - -/* Boxes */ -.pre -{ - white-space: pre; /* CSS 2.0 */ - white-space: pre-wrap; /* CSS 2.1 */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - white-space: -moz-pre-wrap; /* Mozilla */ - white-space: -hp-pre-wrap; /* HP Printers */ - word-wrap : break-word; /* IE 5+ */ -} - -.title_box -{ - width : 470px; - height : 70px; - margin : 2px 50px 2px 2px; - padding : 10px; - border : 1px solid black; - background-color : #666666; - white-space : pre; - float : left; - text-align : center; - color : #C0C0C0; - font-size : 50pt; - font-style : italic; -} - -.subindex_box -{ - margin : 5px; - padding : 14px 22px; - border : 1px solid black; - background-color : #778877; - float : left; - text-align : center; - color : #115555; - font-size : 32pt; -} - -.frame_box -{ - margin : 10px; - padding : 10px; - border : 0px; - background-color : #084040; - text-align : left; - color : #C0C0C0; - font-family : monospace; -} diff --git a/Engine/lib/opus/doc/opus_in_isobmff.html b/Engine/lib/opus/doc/opus_in_isobmff.html deleted file mode 100644 index 38aefbf2a..000000000 --- a/Engine/lib/opus/doc/opus_in_isobmff.html +++ /dev/null @@ -1,692 +0,0 @@ - - - - - - Encapsulation of Opus in ISO Base Media File Format - - - Encapsulation of Opus in ISO Base Media File Format
    - last updated: August 28, 2018
    -
    - - - diff --git a/Engine/lib/opus/doc/opus_logo.svg b/Engine/lib/opus/doc/opus_logo.svg deleted file mode 100644 index db2879efc..000000000 --- a/Engine/lib/opus/doc/opus_logo.svg +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Engine/lib/opus/doc/opus_update.patch b/Engine/lib/opus/doc/opus_update.patch deleted file mode 100644 index 11f066c70..000000000 --- a/Engine/lib/opus/doc/opus_update.patch +++ /dev/null @@ -1,244 +0,0 @@ -diff --git a/celt/bands.c b/celt/bands.c -index 6962587..32e1de6 100644 ---- a/celt/bands.c -+++ b/celt/bands.c -@@ -1234,9 +1234,23 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, - b = 0; - } - -- if (resynth && M*eBands[i]-N >= M*eBands[start] && (update_lowband || lowband_offset==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) -+ { -+ int n1, n2; -+ int offset; -+ n1 = M*(eBands[start+1]-eBands[start]); -+ n2 = M*(eBands[start+2]-eBands[start+1]); -+ offset = M*eBands[start]; -+ /* 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[offset+n1], &norm[offset+2*n1 - n2], n2-n1); -+ if (C==2) -+ OPUS_COPY(&norm2[offset+n1], &norm2[offset+2*n1 - n2], n2-n1); -+ } -+ - tf_change = tf_res[i]; - if (i>=m->effEBands) - { -@@ -1257,7 +1271,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, - fold_start = lowband_offset; - while(M*eBands[--fold_start] > effective_lowband); - fold_end = lowband_offset-1; -- while(M*eBands[++fold_end] < effective_lowband+N); -+ while(++fold_end < i && M*eBands[fold_end] < effective_lowband+N); - x_cm = y_cm = 0; - fold_i = fold_start; do { - x_cm |= collapse_masks[fold_i*C+0]; -diff --git a/celt/quant_bands.c b/celt/quant_bands.c -index e5ed9ef..82fb823 100644 ---- a/celt/quant_bands.c -+++ b/celt/quant_bands.c -@@ -552,6 +552,7 @@ void log2Amp(const CELTMode *m, int start, int end, - { - opus_val16 lg = ADD16(oldEBands[i+c*m->nbEBands], - SHL16((opus_val16)eMeans[i],6)); -+ lg = MIN32(QCONST32(32.f, 16), lg); - eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(lg),4); - } - for (;inbEBands;i++) -diff --git a/silk/LPC_inv_pred_gain.c b/silk/LPC_inv_pred_gain.c -index 60c439b..6c301da 100644 ---- a/silk/LPC_inv_pred_gain.c -+++ b/silk/LPC_inv_pred_gain.c -@@ -84,8 +84,13 @@ static opus_int32 LPC_inverse_pred_gain_QA( /* O Returns inver - - /* Update AR coefficient */ - for( n = 0; n < k; n++ ) { -- tmp_QA = Aold_QA[ n ] - MUL32_FRAC_Q( Aold_QA[ k - n - 1 ], rc_Q31, 31 ); -- Anew_QA[ n ] = MUL32_FRAC_Q( tmp_QA, rc_mult2 , mult2Q ); -+ opus_int64 tmp64; -+ tmp_QA = silk_SUB_SAT32( Aold_QA[ n ], MUL32_FRAC_Q( Aold_QA[ k - n - 1 ], rc_Q31, 31 ) ); -+ tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( tmp_QA, rc_mult2 ), mult2Q); -+ if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) { -+ return 0; -+ } -+ Anew_QA[ n ] = ( opus_int32 )tmp64; - } - } - -diff --git a/silk/NLSF_stabilize.c b/silk/NLSF_stabilize.c -index 979aaba..2ef2398 100644 ---- a/silk/NLSF_stabilize.c -+++ b/silk/NLSF_stabilize.c -@@ -134,7 +134,7 @@ void silk_NLSF_stabilize( - - /* Keep delta_min distance between the NLSFs */ - for( i = 1; i < L; i++ ) -- NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], NLSF_Q15[i-1] + NDeltaMin_Q15[i] ); -+ NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) ); - - /* Last NLSF should be no higher than 1 - NDeltaMin[L] */ - NLSF_Q15[L-1] = silk_min_int( NLSF_Q15[L-1], (1<<15) - NDeltaMin_Q15[L] ); -diff --git a/silk/dec_API.c b/silk/dec_API.c -index efd7918..21bb7e0 100644 ---- a/silk/dec_API.c -+++ b/silk/dec_API.c -@@ -72,6 +72,9 @@ opus_int silk_InitDecoder( /* O Returns error co - for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) { - ret = silk_init_decoder( &channel_state[ n ] ); - } -+ silk_memset(&((silk_decoder *)decState)->sStereo, 0, sizeof(((silk_decoder *)decState)->sStereo)); -+ /* Not strictly needed, but it's cleaner that way */ -+ ((silk_decoder *)decState)->prev_decode_only_middle = 0; - - return ret; - } -diff --git a/silk/resampler_private_IIR_FIR.c b/silk/resampler_private_IIR_FIR.c -index dbd6d9a..91a43aa 100644 ---- a/silk/resampler_private_IIR_FIR.c -+++ b/silk/resampler_private_IIR_FIR.c -@@ -75,10 +75,10 @@ void silk_resampler_private_IIR_FIR( - silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; - opus_int32 nSamplesIn; - opus_int32 max_index_Q16, index_increment_Q16; -- opus_int16 buf[ RESAMPLER_MAX_BATCH_SIZE_IN + RESAMPLER_ORDER_FIR_12 ]; -+ opus_int16 buf[ 2*RESAMPLER_MAX_BATCH_SIZE_IN + RESAMPLER_ORDER_FIR_12 ]; - - /* Copy buffered samples to start of buffer */ -- silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) ); -+ silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); - - /* Iterate over blocks of frameSizeIn input samples */ - index_increment_Q16 = S->invRatio_Q16; -@@ -95,13 +95,13 @@ void silk_resampler_private_IIR_FIR( - - if( inLen > 0 ) { - /* More iterations to do; copy last part of filtered signal to beginning of buffer */ -- silk_memcpy( buf, &buf[ nSamplesIn << 1 ], RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) ); -+ silk_memmove( buf, &buf[ nSamplesIn << 1 ], RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); - } else { - break; - } - } - - /* Copy last part of filtered signal to the state for the next call */ -- silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) ); -+ silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); - } - -diff --git a/src/opus_decoder.c b/src/opus_decoder.c -index 0cc56f8..8a30fbc 100644 ---- a/src/opus_decoder.c -+++ b/src/opus_decoder.c -@@ -595,16 +595,14 @@ static int opus_packet_parse_impl(const unsigned char *data, int len, - /* Padding flag is bit 6 */ - if (ch&0x40) - { -- int padding=0; - int p; - do { - if (len<=0) - return OPUS_INVALID_PACKET; - p = *data++; - len--; -- padding += p==255 ? 254: p; -+ len -= p==255 ? 254: p; - } while (p==255); -- len -= padding; - } - if (len<0) - return OPUS_INVALID_PACKET; -diff --git a/run_vectors.sh b/run_vectors.sh -index 7cd23ed..4841b0a 100755 ---- a/run_vectors.sh -+++ b/run_vectors.sh -@@ -1,3 +1,5 @@ -+#!/bin/sh -+# - # Copyright (c) 2011-2012 IETF Trust, Jean-Marc Valin. All rights reserved. - # - # This file is extracted from RFC6716. Please see that RFC for additional -@@ -31,10 +33,8 @@ - # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - --#!/bin/sh -- --rm logs_mono.txt --rm logs_stereo.txt -+rm -f logs_mono.txt logs_mono2.txt -+rm -f logs_stereo.txt logs_stereo2.txt - - if [ "$#" -ne "3" ]; then - echo "usage: run_vectors.sh " -@@ -45,18 +45,23 @@ CMD_PATH=$1 - VECTOR_PATH=$2 - RATE=$3 - --OPUS_DEMO=$CMD_PATH/opus_demo --OPUS_COMPARE=$CMD_PATH/opus_compare -+: ${OPUS_DEMO:=$CMD_PATH/opus_demo} -+: ${OPUS_COMPARE:=$CMD_PATH/opus_compare} - - if [ -d $VECTOR_PATH ]; then - echo Test vectors found in $VECTOR_PATH - else - echo No test vectors found -- #Don't make the test fail here because the test vectors will be -- #distributed separately -+ #Don't make the test fail here because the test vectors -+ #will be distributed separately - exit 0 - fi - -+if [ ! -x $OPUS_COMPARE ]; then -+ echo ERROR: Compare program not found: $OPUS_COMPARE -+ exit 1 -+fi -+ - if [ -x $OPUS_DEMO ]; then - echo Decoding with $OPUS_DEMO - else -@@ -82,9 +87,11 @@ do - echo ERROR: decoding failed - exit 1 - fi -- $OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_mono.txt 2>&1 -+ $OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector${file}.dec tmp.out >> logs_mono.txt 2>&1 - float_ret=$? -- if [ "$float_ret" -eq "0" ]; then -+ $OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector${file}m.dec tmp.out >> logs_mono2.txt 2>&1 -+ float_ret2=$? -+ if [ "$float_ret" -eq "0" ] || [ "$float_ret2" -eq "0" ]; then - echo output matches reference - else - echo ERROR: output does not match reference -@@ -111,9 +118,11 @@ do - echo ERROR: decoding failed - exit 1 - fi -- $OPUS_COMPARE -s -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_stereo.txt 2>&1 -+ $OPUS_COMPARE -s -r $RATE $VECTOR_PATH/testvector${file}.dec tmp.out >> logs_stereo.txt 2>&1 - float_ret=$? -- if [ "$float_ret" -eq "0" ]; then -+ $OPUS_COMPARE -s -r $RATE $VECTOR_PATH/testvector${file}m.dec tmp.out >> logs_stereo2.txt 2>&1 -+ float_ret2=$? -+ if [ "$float_ret" -eq "0" ] || [ "$float_ret2" -eq "0" ]; then - echo output matches reference - else - echo ERROR: output does not match reference -@@ -125,5 +134,10 @@ done - - - echo All tests have passed successfully --grep quality logs_mono.txt | awk '{sum+=$4}END{print "Average mono quality is", sum/NR, "%"}' --grep quality logs_stereo.txt | awk '{sum+=$4}END{print "Average stereo quality is", sum/NR, "%"}' -+mono1=`grep quality logs_mono.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` -+mono2=`grep quality logs_mono2.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` -+echo $mono1 $mono2 | awk '{if ($2 > $1) $1 = $2; print "Average mono quality is", $1, "%"}' -+ -+stereo1=`grep quality logs_stereo.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` -+stereo2=`grep quality logs_stereo2.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` -+echo $stereo1 $stereo2 | awk '{if ($2 > $1) $1 = $2; print "Average stereo quality is", $1, "%"}' diff --git a/Engine/lib/opus/doc/release.txt b/Engine/lib/opus/doc/release.txt deleted file mode 100644 index 411ab7f4b..000000000 --- a/Engine/lib/opus/doc/release.txt +++ /dev/null @@ -1,43 +0,0 @@ -= Release checklist = - -== Source release == - -- Check for uncommitted changes to master. -- Update OPUS_LT_* API versioning in configure.ac. -- Tag the release commit with 'git tag -s vN.M'. - - Include release notes in the tag annotation. -- Verify 'make distcheck' produces a tarball with - the desired name. -- Push tag to public repo. -- Upload source package 'opus-${version}.tar.gz' - - Add to https://svn.xiph.org/releases/opus/ - - Update checksum files - - svn commit - - Copy to archive.mozilla.org/pub/opus/ - - Update checksum files there as well. -- Add release notes to https://gitlab.xiph.org/xiph/opus-website.git -- Update links and checksums on the downloads page. -- Add a copy of the documentation to - and update the links. -- Update /topic in #opus IRC channel. - -Releases are commited to https://svn.xiph.org/releases/opus/ -which propagates to downloads.xiph.org, and copied manually -to https://archive.mozilla.org/pub/opus/ - -Website updates are committed to https://gitlab.xiph.org/xiph/opus-website.git -which propagates to https://opus-codec.org/ - -== Binary release == - -We usually build opus-tools binaries for MacOS and Windows. - -Binary releases are copied manually to -https://archive.mozilla.org/pub/opus/win32/ - -For Mac, submit a pull request to homebrew. - -== Website updates == - -For major releases, recreate the files on https://opus-codec.org/examples/ -with the next encoder. diff --git a/Engine/lib/opus/doc/trivial_example.c b/Engine/lib/opus/doc/trivial_example.c deleted file mode 100644 index 9cf435b4a..000000000 --- a/Engine/lib/opus/doc/trivial_example.c +++ /dev/null @@ -1,171 +0,0 @@ -/* Copyright (c) 2013 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 meant to be a simple example of encoding and decoding audio - using Opus. It should make it easy to understand how the Opus API - works. For more information, see the full API documentation at: - https://www.opus-codec.org/docs/ */ - -#include -#include -#include -#include -#include - -/*The frame size is hardcoded for this sample code but it doesn't have to be*/ -#define FRAME_SIZE 960 -#define SAMPLE_RATE 48000 -#define CHANNELS 2 -#define APPLICATION OPUS_APPLICATION_AUDIO -#define BITRATE 64000 - -#define MAX_FRAME_SIZE 6*960 -#define MAX_PACKET_SIZE (3*1276) - -int main(int argc, char **argv) -{ - char *inFile; - FILE *fin; - char *outFile; - FILE *fout; - opus_int16 in[FRAME_SIZE*CHANNELS]; - opus_int16 out[MAX_FRAME_SIZE*CHANNELS]; - unsigned char cbits[MAX_PACKET_SIZE]; - int nbBytes; - /*Holds the state of the encoder and decoder */ - OpusEncoder *encoder; - OpusDecoder *decoder; - int err; - - if (argc != 3) - { - fprintf(stderr, "usage: trivial_example input.pcm output.pcm\n"); - fprintf(stderr, "input and output are 16-bit little-endian raw files\n"); - return EXIT_FAILURE; - } - - /*Create a new encoder state */ - encoder = opus_encoder_create(SAMPLE_RATE, CHANNELS, APPLICATION, &err); - if (err<0) - { - fprintf(stderr, "failed to create an encoder: %s\n", opus_strerror(err)); - return EXIT_FAILURE; - } - /* Set the desired bit-rate. You can also set other parameters if needed. - The Opus library is designed to have good defaults, so only set - parameters you know you need. Doing otherwise is likely to result - in worse quality, but better. */ - err = opus_encoder_ctl(encoder, OPUS_SET_BITRATE(BITRATE)); - if (err<0) - { - fprintf(stderr, "failed to set bitrate: %s\n", opus_strerror(err)); - return EXIT_FAILURE; - } - inFile = argv[1]; - fin = fopen(inFile, "rb"); - if (fin==NULL) - { - fprintf(stderr, "failed to open input file: %s\n", strerror(errno)); - return EXIT_FAILURE; - } - - - /* Create a new decoder state. */ - decoder = opus_decoder_create(SAMPLE_RATE, CHANNELS, &err); - if (err<0) - { - fprintf(stderr, "failed to create decoder: %s\n", opus_strerror(err)); - return EXIT_FAILURE; - } - outFile = argv[2]; - fout = fopen(outFile, "wb"); - if (fout==NULL) - { - fprintf(stderr, "failed to open output file: %s\n", strerror(errno)); - return EXIT_FAILURE; - } - - while (1) - { - int i; - unsigned char pcm_bytes[MAX_FRAME_SIZE*CHANNELS*2]; - int frame_size; - size_t samples; - - /* Read a 16 bits/sample audio frame. */ - samples = fread(pcm_bytes, sizeof(short)*CHANNELS, FRAME_SIZE, fin); - - /* For simplicity, only read whole frames. In a real application, - * we'd pad the final partial frame with zeroes, record the exact - * duration, and trim the decoded audio to match. - */ - if (samples != FRAME_SIZE) - { - break; - } - - /* Convert from little-endian ordering. */ - for (i=0;i>8)&0xFF; - } - /* Write the decoded audio to file. */ - fwrite(pcm_bytes, sizeof(short), frame_size*CHANNELS, fout); - } - /*Destroy the encoder state*/ - opus_encoder_destroy(encoder); - opus_decoder_destroy(decoder); - fclose(fin); - fclose(fout); - return EXIT_SUCCESS; -} diff --git a/Engine/lib/opus/include/meson.build b/Engine/lib/opus/include/meson.build deleted file mode 100644 index c1fb0b76f..000000000 --- a/Engine/lib/opus/include/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -opus_headers = [ - 'opus.h', - 'opus_multistream.h', - 'opus_projection.h', - 'opus_types.h', - 'opus_defines.h', -] - -if opt_custom_modes - opus_headers += ['opus_custom.h'] -endif - -install_headers(opus_headers, subdir: 'opus') diff --git a/Engine/lib/opus/include/opus.h b/Engine/lib/opus/include/opus.h deleted file mode 100644 index 0c69c627d..000000000 --- a/Engine/lib/opus/include/opus.h +++ /dev/null @@ -1,981 +0,0 @@ -/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited - Written by Jean-Marc Valin and Koen Vos */ -/* - 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. -*/ - -/** - * @file opus.h - * @brief Opus reference implementation API - */ - -#ifndef OPUS_H -#define OPUS_H - -#include "opus_types.h" -#include "opus_defines.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @mainpage Opus - * - * The Opus codec is designed for interactive speech and audio transmission over the Internet. - * It is designed by the IETF Codec Working Group and incorporates technology from - * Skype's SILK codec and Xiph.Org's CELT codec. - * - * The Opus codec is designed to 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. Its main features are: - - * @li Sampling rates from 8 to 48 kHz - * @li Bit-rates from 6 kb/s to 510 kb/s - * @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR) - * @li Audio bandwidth from narrowband to full-band - * @li Support for speech and music - * @li Support for mono and stereo - * @li Support for multichannel (up to 255 channels) - * @li Frame sizes from 2.5 ms to 60 ms - * @li Good loss robustness and packet loss concealment (PLC) - * @li Floating point and fixed-point implementation - * - * Documentation sections: - * @li @ref opus_encoder - * @li @ref opus_decoder - * @li @ref opus_repacketizer - * @li @ref opus_multistream - * @li @ref opus_libinfo - * @li @ref opus_custom - */ - -/** @defgroup opus_encoder Opus Encoder - * @{ - * - * @brief This page describes the process and functions used to encode Opus. - * - * Since Opus is a stateful codec, the encoding process starts with creating an encoder - * state. This can be done with: - * - * @code - * int error; - * OpusEncoder *enc; - * enc = opus_encoder_create(Fs, channels, application, &error); - * @endcode - * - * From this point, @c enc can be used for encoding an audio stream. An encoder state - * @b must @b not be used for more than one stream at the same time. Similarly, the encoder - * state @b must @b not be re-initialized for each frame. - * - * While opus_encoder_create() allocates memory for the state, it's also possible - * to initialize pre-allocated memory: - * - * @code - * int size; - * int error; - * OpusEncoder *enc; - * size = opus_encoder_get_size(channels); - * enc = malloc(size); - * error = opus_encoder_init(enc, Fs, channels, application); - * @endcode - * - * where opus_encoder_get_size() returns the required size for the encoder state. Note that - * future versions of this code may change the size, so no assuptions should be made about it. - * - * The encoder state is always continuous in memory and only a shallow copy is sufficient - * to copy it (e.g. memcpy()) - * - * It is possible to change some of the encoder's settings using the opus_encoder_ctl() - * interface. All these settings already default to the recommended value, so they should - * only be changed when necessary. The most common settings one may want to change are: - * - * @code - * opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate)); - * opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); - * opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type)); - * @endcode - * - * where - * - * @arg bitrate is in bits per second (b/s) - * @arg complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest - * @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or OPUS_SIGNAL_MUSIC - * - * See @ref opus_encoderctls and @ref opus_genericctls for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream. - * - * To encode a frame, opus_encode() or opus_encode_float() must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data: - * @code - * len = opus_encode(enc, audio_frame, frame_size, packet, max_packet); - * @endcode - * - * where - *
      - *
    • audio_frame is the audio data in opus_int16 (or float for opus_encode_float())
    • - *
    • frame_size is the duration of the frame in samples (per channel)
    • - *
    • packet is the byte array to which the compressed data is written
    • - *
    • max_packet is the maximum number of bytes that can be written in the packet (4000 bytes is recommended). - * Do not use max_packet to control VBR target bitrate, instead use the #OPUS_SET_BITRATE CTL.
    • - *
    - * - * opus_encode() and opus_encode_float() return the number of bytes actually written to the packet. - * The return value can be negative, which indicates that an error has occurred. If the return value - * is 2 bytes or less, then the packet does not need to be transmitted (DTX). - * - * Once the encoder state if no longer needed, it can be destroyed with - * - * @code - * opus_encoder_destroy(enc); - * @endcode - * - * If the encoder was created with opus_encoder_init() rather than opus_encoder_create(), - * then no action is required aside from potentially freeing the memory that was manually - * allocated for it (calling free(enc) for the example above) - * - */ - -/** Opus encoder state. - * This contains the complete state of an Opus encoder. - * It is position independent and can be freely copied. - * @see opus_encoder_create,opus_encoder_init - */ -typedef struct OpusEncoder OpusEncoder; - -/** Gets the size of an OpusEncoder structure. - * @param[in] channels int: Number of channels. - * This must be 1 or 2. - * @returns The size in bytes. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels); - -/** - */ - -/** Allocates and initializes an encoder state. - * There are three coding modes: - * - * @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice - * signals. It enhances the input signal by high-pass filtering and - * emphasizing formants and harmonics. Optionally it includes in-band - * forward error correction to protect against packet loss. Use this - * mode for typical VoIP applications. Because of the enhancement, - * even at high bitrates the output may sound different from the input. - * - * @ref OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for most - * non-voice signals like music. Use this mode for music and mixed - * (music/voice) content, broadcast, and applications requiring less - * than 15 ms of coding delay. - * - * @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that - * disables the speech-optimized mode in exchange for slightly reduced delay. - * This mode can only be set on an newly initialized or freshly reset encoder - * because it changes the codec delay. - * - * This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution). - * @param [in] Fs opus_int32: Sampling rate of input signal (Hz) - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param [in] channels int: Number of channels (1 or 2) in input signal - * @param [in] application int: Coding mode (one of @ref OPUS_APPLICATION_VOIP, @ref OPUS_APPLICATION_AUDIO, or @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY) - * @param [out] error int*: @ref opus_errorcodes - * @note Regardless of the sampling rate and number channels selected, the Opus encoder - * can switch to a lower audio bandwidth or number of channels if the bitrate - * selected is too low. This also means that it is safe to always use 48 kHz stereo input - * and let the encoder optimize the encoding. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create( - opus_int32 Fs, - int channels, - int application, - int *error -); - -/** Initializes a previously allocated encoder state - * The memory pointed to by st must be at least the size returned by opus_encoder_get_size(). - * This is intended for applications which use their own allocator instead of malloc. - * @see opus_encoder_create(),opus_encoder_get_size() - * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. - * @param [in] st OpusEncoder*: Encoder state - * @param [in] Fs opus_int32: Sampling rate of input signal (Hz) - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param [in] channels int: Number of channels (1 or 2) in input signal - * @param [in] application int: Coding mode (one of OPUS_APPLICATION_VOIP, OPUS_APPLICATION_AUDIO, or OPUS_APPLICATION_RESTRICTED_LOWDELAY) - * @retval #OPUS_OK Success or @ref opus_errorcodes - */ -OPUS_EXPORT int opus_encoder_init( - OpusEncoder *st, - opus_int32 Fs, - int channels, - int application -) OPUS_ARG_NONNULL(1); - -/** Encodes an Opus frame. - * @param [in] st OpusEncoder*: Encoder state - * @param [in] pcm opus_int16*: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16) - * @param [in] frame_size int: Number of samples per channel in the - * input signal. - * This must be an Opus frame size for - * the encoder's sampling rate. - * For example, at 48 kHz the permitted - * values are 120, 240, 480, 960, 1920, - * and 2880. - * Passing in a duration of less than - * 10 ms (480 samples at 48 kHz) will - * prevent the encoder from using the LPC - * or hybrid modes. - * @param [out] data unsigned char*: Output payload. - * This must contain storage for at - * least \a max_data_bytes. - * @param [in] max_data_bytes opus_int32: Size of the allocated - * memory for the output - * payload. This may be - * used to impose an upper limit on - * the instant bitrate, but should - * not be used as the only bitrate - * control. Use #OPUS_SET_BITRATE to - * control the bitrate. - * @returns The length of the encoded packet (in bytes) on success or a - * negative error code (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode( - OpusEncoder *st, - const opus_int16 *pcm, - int frame_size, - unsigned char *data, - opus_int32 max_data_bytes -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); - -/** Encodes an Opus frame from floating point input. - * @param [in] st OpusEncoder*: Encoder state - * @param [in] pcm float*: Input in float format (interleaved if 2 channels), with a normal range of +/-1.0. - * Samples with a range beyond +/-1.0 are supported but will - * be clipped by decoders using the integer API and should - * only be used if it is known that the far end supports - * extended dynamic range. - * length is frame_size*channels*sizeof(float) - * @param [in] frame_size int: Number of samples per channel in the - * input signal. - * This must be an Opus frame size for - * the encoder's sampling rate. - * For example, at 48 kHz the permitted - * values are 120, 240, 480, 960, 1920, - * and 2880. - * Passing in a duration of less than - * 10 ms (480 samples at 48 kHz) will - * prevent the encoder from using the LPC - * or hybrid modes. - * @param [out] data unsigned char*: Output payload. - * This must contain storage for at - * least \a max_data_bytes. - * @param [in] max_data_bytes opus_int32: Size of the allocated - * memory for the output - * payload. This may be - * used to impose an upper limit on - * the instant bitrate, but should - * not be used as the only bitrate - * control. Use #OPUS_SET_BITRATE to - * control the bitrate. - * @returns The length of the encoded packet (in bytes) on success or a - * negative error code (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float( - OpusEncoder *st, - const float *pcm, - int frame_size, - unsigned char *data, - opus_int32 max_data_bytes -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); - -/** Frees an OpusEncoder allocated by opus_encoder_create(). - * @param[in] st OpusEncoder*: State to be freed. - */ -OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st); - -/** Perform a CTL function on an Opus encoder. - * - * Generally the request and subsequent arguments are generated - * by a convenience macro. - * @param st OpusEncoder*: Encoder state. - * @param request This and all remaining parameters should be replaced by one - * of the convenience macros in @ref opus_genericctls or - * @ref opus_encoderctls. - * @see opus_genericctls - * @see opus_encoderctls - */ -OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); -/**@}*/ - -/** @defgroup opus_decoder Opus Decoder - * @{ - * - * @brief This page describes the process and functions used to decode Opus. - * - * The decoding process also starts with creating a decoder - * state. This can be done with: - * @code - * int error; - * OpusDecoder *dec; - * dec = opus_decoder_create(Fs, channels, &error); - * @endcode - * where - * @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 48000 - * @li channels is the number of channels (1 or 2) - * @li error will hold the error code in case of failure (or #OPUS_OK on success) - * @li the return value is a newly created decoder state to be used for decoding - * - * While opus_decoder_create() allocates memory for the state, it's also possible - * to initialize pre-allocated memory: - * @code - * int size; - * int error; - * OpusDecoder *dec; - * size = opus_decoder_get_size(channels); - * dec = malloc(size); - * error = opus_decoder_init(dec, Fs, channels); - * @endcode - * where opus_decoder_get_size() returns the required size for the decoder state. Note that - * future versions of this code may change the size, so no assuptions should be made about it. - * - * The decoder state is always continuous in memory and only a shallow copy is sufficient - * to copy it (e.g. memcpy()) - * - * To decode a frame, opus_decode() or opus_decode_float() must be called with a packet of compressed audio data: - * @code - * frame_size = opus_decode(dec, packet, len, decoded, max_size, 0); - * @endcode - * where - * - * @li packet is the byte array containing the compressed data - * @li len is the exact number of bytes contained in the packet - * @li decoded is the decoded audio data in opus_int16 (or float for opus_decode_float()) - * @li max_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array - * - * opus_decode() and opus_decode_float() return the number of samples (per channel) decoded from the packet. - * If that value is negative, then an error has occurred. This can occur if the packet is corrupted or if the audio - * buffer is too small to hold the decoded audio. - * - * Opus is a stateful codec with overlapping blocks and as a result Opus - * packets are not coded independently of each other. Packets must be - * passed into the decoder serially and in the correct order for a correct - * decode. Lost packets can be replaced with loss concealment by calling - * the decoder with a null pointer and zero length for the missing packet. - * - * A single codec state may only be accessed from a single thread at - * a time and any required locking must be performed by the caller. Separate - * streams must be decoded with separate decoder states and can be decoded - * in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK - * defined. - * - */ - -/** Opus decoder state. - * This contains the complete state of an Opus decoder. - * It is position independent and can be freely copied. - * @see opus_decoder_create,opus_decoder_init - */ -typedef struct OpusDecoder OpusDecoder; - -/** Gets the size of an OpusDecoder structure. - * @param [in] channels int: Number of channels. - * This must be 1 or 2. - * @returns The size in bytes. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels); - -/** Allocates and initializes a decoder state. - * @param [in] Fs opus_int32: Sample rate to decode at (Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param [in] channels int: Number of channels (1 or 2) to decode - * @param [out] error int*: #OPUS_OK Success or @ref opus_errorcodes - * - * Internally Opus stores data at 48000 Hz, so that should be the default - * value for Fs. However, the decoder can efficiently decode to buffers - * at 8, 12, 16, and 24 kHz so if for some reason the caller cannot use - * data at the full sample rate, or knows the compressed data doesn't - * use the full frequency range, it can request decoding at a reduced - * rate. Likewise, the decoder is capable of filling in either mono or - * interleaved stereo pcm buffers, at the caller's request. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create( - opus_int32 Fs, - int channels, - int *error -); - -/** Initializes a previously allocated decoder state. - * The state must be at least the size returned by opus_decoder_get_size(). - * This is intended for applications which use their own allocator instead of malloc. @see opus_decoder_create,opus_decoder_get_size - * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. - * @param [in] st OpusDecoder*: Decoder state. - * @param [in] Fs opus_int32: Sampling rate to decode to (Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param [in] channels int: Number of channels (1 or 2) to decode - * @retval #OPUS_OK Success or @ref opus_errorcodes - */ -OPUS_EXPORT int opus_decoder_init( - OpusDecoder *st, - opus_int32 Fs, - int channels -) OPUS_ARG_NONNULL(1); - -/** Decode an Opus packet. - * @param [in] st OpusDecoder*: Decoder state - * @param [in] data char*: Input payload. Use a NULL pointer to indicate packet loss - * @param [in] len opus_int32: Number of bytes in payload* - * @param [out] pcm opus_int16*: Output signal (interleaved if 2 channels). length - * is frame_size*channels*sizeof(opus_int16) - * @param [in] frame_size Number of samples per channel of available space in \a pcm. - * If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will - * not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), - * then frame_size needs to be exactly the duration of audio that is missing, otherwise the - * decoder will not be in the optimal state to decode the next incoming packet. For the PLC and - * FEC cases, frame_size must be a multiple of 2.5 ms. - * @param [in] decode_fec int: Flag (0 or 1) to request that any in-band forward error correction data be - * decoded. If no such data is available, the frame is decoded as if it were lost. - * @returns Number of decoded samples or @ref opus_errorcodes - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode( - OpusDecoder *st, - const unsigned char *data, - opus_int32 len, - opus_int16 *pcm, - int frame_size, - int decode_fec -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); - -/** Decode an Opus packet with floating point output. - * @param [in] st OpusDecoder*: Decoder state - * @param [in] data char*: Input payload. Use a NULL pointer to indicate packet loss - * @param [in] len opus_int32: Number of bytes in payload - * @param [out] pcm float*: Output signal (interleaved if 2 channels). length - * is frame_size*channels*sizeof(float) - * @param [in] frame_size Number of samples per channel of available space in \a pcm. - * If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will - * not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), - * then frame_size needs to be exactly the duration of audio that is missing, otherwise the - * decoder will not be in the optimal state to decode the next incoming packet. For the PLC and - * FEC cases, frame_size must be a multiple of 2.5 ms. - * @param [in] decode_fec int: Flag (0 or 1) to request that any in-band forward error correction data be - * decoded. If no such data is available the frame is decoded as if it were lost. - * @returns Number of decoded samples or @ref opus_errorcodes - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float( - OpusDecoder *st, - const unsigned char *data, - opus_int32 len, - float *pcm, - int frame_size, - int decode_fec -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); - -/** Perform a CTL function on an Opus decoder. - * - * Generally the request and subsequent arguments are generated - * by a convenience macro. - * @param st OpusDecoder*: Decoder state. - * @param request This and all remaining parameters should be replaced by one - * of the convenience macros in @ref opus_genericctls or - * @ref opus_decoderctls. - * @see opus_genericctls - * @see opus_decoderctls - */ -OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); - -/** Frees an OpusDecoder allocated by opus_decoder_create(). - * @param[in] st OpusDecoder*: State to be freed. - */ -OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st); - -/** Parse an opus packet into one or more frames. - * Opus_decode will perform this operation internally so most applications do - * not need to use this function. - * This function does not copy the frames, the returned pointers are pointers into - * the input packet. - * @param [in] data char*: Opus packet to be parsed - * @param [in] len opus_int32: size of data - * @param [out] out_toc char*: TOC pointer - * @param [out] frames char*[48] encapsulated frames - * @param [out] size opus_int16[48] sizes of the encapsulated frames - * @param [out] payload_offset int*: returns the position of the payload within the packet (in bytes) - * @returns number of frames - */ -OPUS_EXPORT int opus_packet_parse( - const unsigned char *data, - opus_int32 len, - unsigned char *out_toc, - const unsigned char *frames[48], - opus_int16 size[48], - int *payload_offset -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5); - -/** Gets the bandwidth of an Opus packet. - * @param [in] data char*: Opus packet - * @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) - * @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) - * @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) - * @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) - * @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) - * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1); - -/** Gets the number of samples per frame from an Opus packet. - * @param [in] data char*: Opus packet. - * This must contain at least one byte of - * data. - * @param [in] Fs opus_int32: Sampling rate in Hz. - * This must be a multiple of 400, or - * inaccurate results will be returned. - * @returns Number of samples per frame. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1); - -/** Gets the number of channels from an Opus packet. - * @param [in] data char*: Opus packet - * @returns Number of channels - * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1); - -/** Gets the number of frames in an Opus packet. - * @param [in] packet char*: Opus packet - * @param [in] len opus_int32: Length of packet - * @returns Number of frames - * @retval OPUS_BAD_ARG Insufficient data was passed to the function - * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1); - -/** Gets the number of samples of an Opus packet. - * @param [in] packet char*: Opus packet - * @param [in] len opus_int32: Length of packet - * @param [in] Fs opus_int32: Sampling rate in Hz. - * This must be a multiple of 400, or - * inaccurate results will be returned. - * @returns Number of samples - * @retval OPUS_BAD_ARG Insufficient data was passed to the function - * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1); - -/** Gets the number of samples of an Opus packet. - * @param [in] dec OpusDecoder*: Decoder state - * @param [in] packet char*: Opus packet - * @param [in] len opus_int32: Length of packet - * @returns Number of samples - * @retval OPUS_BAD_ARG Insufficient data was passed to the function - * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); - -/** Applies soft-clipping to bring a float signal within the [-1,1] range. If - * the signal is already in that range, nothing is done. If there are values - * outside of [-1,1], then the signal is clipped as smoothly as possible to - * both fit in the range and avoid creating excessive distortion in the - * process. - * @param [in,out] pcm float*: Input PCM and modified PCM - * @param [in] frame_size int Number of samples per channel to process - * @param [in] channels int: Number of channels - * @param [in,out] softclip_mem float*: State memory for the soft clipping process (one float per channel, initialized to zero) - */ -OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem); - - -/**@}*/ - -/** @defgroup opus_repacketizer Repacketizer - * @{ - * - * The repacketizer can be used to merge multiple Opus packets into a single - * packet or alternatively to split Opus packets that have previously been - * merged. Splitting valid Opus packets is always guaranteed to succeed, - * whereas merging valid packets only succeeds if all frames have the same - * mode, bandwidth, and frame size, and when the total duration of the merged - * packet is no more than 120 ms. The 120 ms limit comes from the - * specification and limits decoder memory requirements at a point where - * framing overhead becomes negligible. - * - * The repacketizer currently only operates on elementary Opus - * streams. It will not manipualte multistream packets successfully, except in - * the degenerate case where they consist of data from a single stream. - * - * The repacketizing process starts with creating a repacketizer state, either - * by calling opus_repacketizer_create() or by allocating the memory yourself, - * e.g., - * @code - * OpusRepacketizer *rp; - * rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size()); - * if (rp != NULL) - * opus_repacketizer_init(rp); - * @endcode - * - * Then the application should submit packets with opus_repacketizer_cat(), - * extract new packets with opus_repacketizer_out() or - * opus_repacketizer_out_range(), and then reset the state for the next set of - * input packets via opus_repacketizer_init(). - * - * For example, to split a sequence of packets into individual frames: - * @code - * unsigned char *data; - * int len; - * while (get_next_packet(&data, &len)) - * { - * unsigned char out[1276]; - * opus_int32 out_len; - * int nb_frames; - * int err; - * int i; - * err = opus_repacketizer_cat(rp, data, len); - * if (err != OPUS_OK) - * { - * release_packet(data); - * return err; - * } - * nb_frames = opus_repacketizer_get_nb_frames(rp); - * for (i = 0; i < nb_frames; i++) - * { - * out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out)); - * if (out_len < 0) - * { - * release_packet(data); - * return (int)out_len; - * } - * output_next_packet(out, out_len); - * } - * opus_repacketizer_init(rp); - * release_packet(data); - * } - * @endcode - * - * Alternatively, to combine a sequence of frames into packets that each - * contain up to TARGET_DURATION_MS milliseconds of data: - * @code - * // The maximum number of packets with duration TARGET_DURATION_MS occurs - * // when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5) - * // packets. - * unsigned char *data[(TARGET_DURATION_MS*2/5)+1]; - * opus_int32 len[(TARGET_DURATION_MS*2/5)+1]; - * int nb_packets; - * unsigned char out[1277*(TARGET_DURATION_MS*2/2)]; - * opus_int32 out_len; - * int prev_toc; - * nb_packets = 0; - * while (get_next_packet(data+nb_packets, len+nb_packets)) - * { - * int nb_frames; - * int err; - * nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]); - * if (nb_frames < 1) - * { - * release_packets(data, nb_packets+1); - * return nb_frames; - * } - * nb_frames += opus_repacketizer_get_nb_frames(rp); - * // If adding the next packet would exceed our target, or it has an - * // incompatible TOC sequence, output the packets we already have before - * // submitting it. - * // N.B., The nb_packets > 0 check ensures we've submitted at least one - * // packet since the last call to opus_repacketizer_init(). Otherwise a - * // single packet longer than TARGET_DURATION_MS would cause us to try to - * // output an (invalid) empty packet. It also ensures that prev_toc has - * // been set to a valid value. Additionally, len[nb_packets] > 0 is - * // guaranteed by the call to opus_packet_get_nb_frames() above, so the - * // reference to data[nb_packets][0] should be valid. - * if (nb_packets > 0 && ( - * ((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) || - * opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames > - * TARGET_DURATION_MS*48)) - * { - * out_len = opus_repacketizer_out(rp, out, sizeof(out)); - * if (out_len < 0) - * { - * release_packets(data, nb_packets+1); - * return (int)out_len; - * } - * output_next_packet(out, out_len); - * opus_repacketizer_init(rp); - * release_packets(data, nb_packets); - * data[0] = data[nb_packets]; - * len[0] = len[nb_packets]; - * nb_packets = 0; - * } - * err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]); - * if (err != OPUS_OK) - * { - * release_packets(data, nb_packets+1); - * return err; - * } - * prev_toc = data[nb_packets][0]; - * nb_packets++; - * } - * // Output the final, partial packet. - * if (nb_packets > 0) - * { - * out_len = opus_repacketizer_out(rp, out, sizeof(out)); - * release_packets(data, nb_packets); - * if (out_len < 0) - * return (int)out_len; - * output_next_packet(out, out_len); - * } - * @endcode - * - * An alternate way of merging packets is to simply call opus_repacketizer_cat() - * unconditionally until it fails. At that point, the merged packet can be - * obtained with opus_repacketizer_out() and the input packet for which - * opus_repacketizer_cat() needs to be re-added to a newly reinitialized - * repacketizer state. - */ - -typedef struct OpusRepacketizer OpusRepacketizer; - -/** Gets the size of an OpusRepacketizer structure. - * @returns The size in bytes. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void); - -/** (Re)initializes a previously allocated repacketizer state. - * The state must be at least the size returned by opus_repacketizer_get_size(). - * This can be used for applications which use their own allocator instead of - * malloc(). - * It must also be called to reset the queue of packets waiting to be - * repacketized, which is necessary if the maximum packet duration of 120 ms - * is reached or if you wish to submit packets with a different Opus - * configuration (coding mode, audio bandwidth, frame size, or channel count). - * Failure to do so will prevent a new packet from being added with - * opus_repacketizer_cat(). - * @see opus_repacketizer_create - * @see opus_repacketizer_get_size - * @see opus_repacketizer_cat - * @param rp OpusRepacketizer*: The repacketizer state to - * (re)initialize. - * @returns A pointer to the same repacketizer state that was passed in. - */ -OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); - -/** Allocates memory and initializes the new repacketizer with - * opus_repacketizer_init(). - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void); - -/** Frees an OpusRepacketizer allocated by - * opus_repacketizer_create(). - * @param[in] rp OpusRepacketizer*: State to be freed. - */ -OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp); - -/** Add a packet to the current repacketizer state. - * This packet must match the configuration of any packets already submitted - * for repacketization since the last call to opus_repacketizer_init(). - * This means that it must have the same coding mode, audio bandwidth, frame - * size, and channel count. - * This can be checked in advance by examining the top 6 bits of the first - * byte of the packet, and ensuring they match the top 6 bits of the first - * byte of any previously submitted packet. - * The total duration of audio in the repacketizer state also must not exceed - * 120 ms, the maximum duration of a single packet, after adding this packet. - * - * The contents of the current repacketizer state can be extracted into new - * packets using opus_repacketizer_out() or opus_repacketizer_out_range(). - * - * In order to add a packet with a different configuration or to add more - * audio beyond 120 ms, you must clear the repacketizer state by calling - * opus_repacketizer_init(). - * If a packet is too large to add to the current repacketizer state, no part - * of it is added, even if it contains multiple frames, some of which might - * fit. - * If you wish to be able to add parts of such packets, you should first use - * another repacketizer to split the packet into pieces and add them - * individually. - * @see opus_repacketizer_out_range - * @see opus_repacketizer_out - * @see opus_repacketizer_init - * @param rp OpusRepacketizer*: The repacketizer state to which to - * add the packet. - * @param[in] data const unsigned char*: The packet data. - * The application must ensure - * this pointer remains valid - * until the next call to - * opus_repacketizer_init() or - * opus_repacketizer_destroy(). - * @param len opus_int32: The number of bytes in the packet data. - * @returns An error code indicating whether or not the operation succeeded. - * @retval #OPUS_OK The packet's contents have been added to the repacketizer - * state. - * @retval #OPUS_INVALID_PACKET The packet did not have a valid TOC sequence, - * the packet's TOC sequence was not compatible - * with previously submitted packets (because - * the coding mode, audio bandwidth, frame size, - * or channel count did not match), or adding - * this packet would increase the total amount of - * audio stored in the repacketizer state to more - * than 120 ms. - */ -OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); - - -/** Construct a new packet from data previously submitted to the repacketizer - * state via opus_repacketizer_cat(). - * @param rp OpusRepacketizer*: The repacketizer state from which to - * construct the new packet. - * @param begin int: The index of the first frame in the current - * repacketizer state to include in the output. - * @param end int: One past the index of the last frame in the - * current repacketizer state to include in the - * output. - * @param[out] data const unsigned char*: The buffer in which to - * store the output packet. - * @param maxlen opus_int32: The maximum number of bytes to store in - * the output buffer. In order to guarantee - * success, this should be at least - * 1276 for a single frame, - * or for multiple frames, - * 1277*(end-begin). - * However, 1*(end-begin) plus - * the size of all packet data submitted to - * the repacketizer since the last call to - * opus_repacketizer_init() or - * opus_repacketizer_create() is also - * sufficient, and possibly much smaller. - * @returns The total size of the output packet on success, or an error code - * on failure. - * @retval #OPUS_BAD_ARG [begin,end) was an invalid range of - * frames (begin < 0, begin >= end, or end > - * opus_repacketizer_get_nb_frames()). - * @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the - * complete output packet. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); - -/** Return the total number of frames contained in packet data submitted to - * the repacketizer state so far via opus_repacketizer_cat() since the last - * call to opus_repacketizer_init() or opus_repacketizer_create(). - * This defines the valid range of packets that can be extracted with - * opus_repacketizer_out_range() or opus_repacketizer_out(). - * @param rp OpusRepacketizer*: The repacketizer state containing the - * frames. - * @returns The total number of frames contained in the packet data submitted - * to the repacketizer state. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); - -/** Construct a new packet from data previously submitted to the repacketizer - * state via opus_repacketizer_cat(). - * This is a convenience routine that returns all the data submitted so far - * in a single packet. - * It is equivalent to calling - * @code - * opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp), - * data, maxlen) - * @endcode - * @param rp OpusRepacketizer*: The repacketizer state from which to - * construct the new packet. - * @param[out] data const unsigned char*: The buffer in which to - * store the output packet. - * @param maxlen opus_int32: The maximum number of bytes to store in - * the output buffer. In order to guarantee - * success, this should be at least - * 1277*opus_repacketizer_get_nb_frames(rp). - * However, - * 1*opus_repacketizer_get_nb_frames(rp) - * plus the size of all packet data - * submitted to the repacketizer since the - * last call to opus_repacketizer_init() or - * opus_repacketizer_create() is also - * sufficient, and possibly much smaller. - * @returns The total size of the output packet on success, or an error code - * on failure. - * @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the - * complete output packet. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1); - -/** Pads a given Opus packet to a larger size (possibly changing the TOC sequence). - * @param[in,out] data const unsigned char*: The buffer containing the - * packet to pad. - * @param len opus_int32: The size of the packet. - * This must be at least 1. - * @param new_len opus_int32: The desired size of the packet after padding. - * This must be at least as large as len. - * @returns an error code - * @retval #OPUS_OK \a on success. - * @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. - * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. - */ -OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len); - -/** Remove all padding from a given Opus packet and rewrite the TOC sequence to - * minimize space usage. - * @param[in,out] data const unsigned char*: The buffer containing the - * packet to strip. - * @param len opus_int32: The size of the packet. - * This must be at least 1. - * @returns The new size of the output packet on success, or an error code - * on failure. - * @retval #OPUS_BAD_ARG \a len was less than 1. - * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len); - -/** Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence). - * @param[in,out] data const unsigned char*: The buffer containing the - * packet to pad. - * @param len opus_int32: The size of the packet. - * This must be at least 1. - * @param new_len opus_int32: The desired size of the packet after padding. - * This must be at least 1. - * @param nb_streams opus_int32: The number of streams (not channels) in the packet. - * This must be at least as large as len. - * @returns an error code - * @retval #OPUS_OK \a on success. - * @retval #OPUS_BAD_ARG \a len was less than 1. - * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. - */ -OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams); - -/** Remove all padding from a given Opus multi-stream packet and rewrite the TOC sequence to - * minimize space usage. - * @param[in,out] data const unsigned char*: The buffer containing the - * packet to strip. - * @param len opus_int32: The size of the packet. - * This must be at least 1. - * @param nb_streams opus_int32: The number of streams (not channels) in the packet. - * This must be at least 1. - * @returns The new size of the output packet on success, or an error code - * on failure. - * @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. - * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* OPUS_H */ diff --git a/Engine/lib/opus/include/opus_custom.h b/Engine/lib/opus/include/opus_custom.h deleted file mode 100644 index 2f22d4b35..000000000 --- a/Engine/lib/opus/include/opus_custom.h +++ /dev/null @@ -1,343 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Copyright (c) 2008-2012 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. -*/ - -/** - @file opus_custom.h - @brief Opus-Custom reference implementation API - */ - -#ifndef OPUS_CUSTOM_H -#define OPUS_CUSTOM_H - -#include "opus_defines.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef CUSTOM_MODES -# define OPUS_CUSTOM_EXPORT OPUS_EXPORT -# define OPUS_CUSTOM_EXPORT_STATIC OPUS_EXPORT -#else -# define OPUS_CUSTOM_EXPORT -# ifdef OPUS_BUILD -# define OPUS_CUSTOM_EXPORT_STATIC static OPUS_INLINE -# else -# define OPUS_CUSTOM_EXPORT_STATIC -# endif -#endif - -/** @defgroup opus_custom Opus Custom - * @{ - * Opus Custom is an optional part of the Opus specification and - * reference implementation which uses a distinct API from the regular - * API and supports frame sizes that are not normally supported.\ Use - * of Opus Custom is discouraged for all but very special applications - * for which a frame size different from 2.5, 5, 10, or 20 ms is needed - * (for either complexity or latency reasons) and where interoperability - * is less important. - * - * In addition to the interoperability limitations the use of Opus custom - * disables a substantial chunk of the codec and generally lowers the - * quality available at a given bitrate. Normally when an application needs - * a different frame size from the codec it should buffer to match the - * sizes but this adds a small amount of delay which may be important - * in some very low latency applications. Some transports (especially - * constant rate RF transports) may also work best with frames of - * particular durations. - * - * Libopus only supports custom modes if they are enabled at compile time. - * - * The Opus Custom API is similar to the regular API but the - * @ref opus_encoder_create and @ref opus_decoder_create calls take - * an additional mode parameter which is a structure produced by - * a call to @ref opus_custom_mode_create. Both the encoder and decoder - * must create a mode using the same sample rate (fs) and frame size - * (frame size) so these parameters must either be signaled out of band - * or fixed in a particular implementation. - * - * Similar to regular Opus the custom modes support on the fly frame size - * switching, but the sizes available depend on the particular frame size in - * use. For some initial frame sizes on a single on the fly size is available. - */ - -/** Contains the state of an encoder. One encoder state is needed - for each stream. It is initialized once at the beginning of the - stream. Do *not* re-initialize the state for every frame. - @brief Encoder state - */ -typedef struct OpusCustomEncoder OpusCustomEncoder; - -/** State of the decoder. One decoder state is needed for each stream. - It is initialized once at the beginning of the stream. Do *not* - re-initialize the state for every frame. - @brief Decoder state - */ -typedef struct OpusCustomDecoder OpusCustomDecoder; - -/** The mode contains all the information necessary to create an - encoder. Both the encoder and decoder need to be initialized - with exactly the same mode, otherwise the output will be - corrupted. The mode MUST NOT BE DESTROYED until the encoders and - decoders that use it are destroyed as well. - @brief Mode configuration - */ -typedef struct OpusCustomMode OpusCustomMode; - -/** Creates a new mode struct. This will be passed to an encoder or - * decoder. The mode MUST NOT BE DESTROYED until the encoders and - * decoders that use it are destroyed as well. - * @param [in] Fs int: Sampling rate (8000 to 96000 Hz) - * @param [in] frame_size int: Number of samples (per channel) to encode in each - * packet (64 - 1024, prime factorization must contain zero or more 2s, 3s, or 5s and no other primes) - * @param [out] error int*: Returned error code (if NULL, no error will be returned) - * @return A newly created mode - */ -OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error); - -/** Destroys a mode struct. Only call this after all encoders and - * decoders using this mode are destroyed as well. - * @param [in] mode OpusCustomMode*: Mode to be freed. - */ -OPUS_CUSTOM_EXPORT void opus_custom_mode_destroy(OpusCustomMode *mode); - - -#if !defined(OPUS_BUILD) || defined(CELT_ENCODER_C) - -/* Encoder */ -/** Gets the size of an OpusCustomEncoder structure. - * @param [in] mode OpusCustomMode *: Mode configuration - * @param [in] channels int: Number of channels - * @returns size - */ -OPUS_CUSTOM_EXPORT_STATIC OPUS_WARN_UNUSED_RESULT int opus_custom_encoder_get_size( - const OpusCustomMode *mode, - int channels -) OPUS_ARG_NONNULL(1); - -# ifdef CUSTOM_MODES -/** Initializes a previously allocated encoder state - * The memory pointed to by st must be the size returned by opus_custom_encoder_get_size. - * This is intended for applications which use their own allocator instead of malloc. - * @see opus_custom_encoder_create(),opus_custom_encoder_get_size() - * To reset a previously initialized state use the OPUS_RESET_STATE CTL. - * @param [in] st OpusCustomEncoder*: Encoder state - * @param [in] mode OpusCustomMode *: Contains all the information about the characteristics of - * the stream (must be the same characteristics as used for the - * decoder) - * @param [in] channels int: Number of channels - * @return OPUS_OK Success or @ref opus_errorcodes - */ -OPUS_CUSTOM_EXPORT int opus_custom_encoder_init( - OpusCustomEncoder *st, - const OpusCustomMode *mode, - int channels -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); -# endif -#endif - - -/** Creates a new encoder state. Each stream needs its own encoder - * state (can't be shared across simultaneous streams). - * @param [in] mode OpusCustomMode*: Contains all the information about the characteristics of - * the stream (must be the same characteristics as used for the - * decoder) - * @param [in] channels int: Number of channels - * @param [out] error int*: Returns an error code - * @return Newly created encoder state. -*/ -OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomEncoder *opus_custom_encoder_create( - const OpusCustomMode *mode, - int channels, - int *error -) OPUS_ARG_NONNULL(1); - - -/** Destroys an encoder state. - * @param[in] st OpusCustomEncoder*: State to be freed. - */ -OPUS_CUSTOM_EXPORT void opus_custom_encoder_destroy(OpusCustomEncoder *st); - -/** Encodes a frame of audio. - * @param [in] st OpusCustomEncoder*: Encoder state - * @param [in] pcm float*: PCM audio in float format, with a normal range of +/-1.0. - * Samples with a range beyond +/-1.0 are supported but will - * be clipped by decoders using the integer API and should - * only be used if it is known that the far end supports - * extended dynamic range. There must be exactly - * frame_size samples per channel. - * @param [in] frame_size int: Number of samples per frame of input signal - * @param [out] compressed char *: The compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long. - * @param [in] maxCompressedBytes int: Maximum number of bytes to use for compressing the frame - * (can change from one frame to another) - * @return Number of bytes written to "compressed". - * If negative, an error has occurred (see error codes). It is IMPORTANT that - * the length returned be somehow transmitted to the decoder. Otherwise, no - * decoding is possible. - */ -OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode_float( - OpusCustomEncoder *st, - const float *pcm, - int frame_size, - unsigned char *compressed, - int maxCompressedBytes -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); - -/** Encodes a frame of audio. - * @param [in] st OpusCustomEncoder*: Encoder state - * @param [in] pcm opus_int16*: PCM audio in signed 16-bit format (native endian). - * There must be exactly frame_size samples per channel. - * @param [in] frame_size int: Number of samples per frame of input signal - * @param [out] compressed char *: The compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long. - * @param [in] maxCompressedBytes int: Maximum number of bytes to use for compressing the frame - * (can change from one frame to another) - * @return Number of bytes written to "compressed". - * If negative, an error has occurred (see error codes). It is IMPORTANT that - * the length returned be somehow transmitted to the decoder. Otherwise, no - * decoding is possible. - */ -OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode( - OpusCustomEncoder *st, - const opus_int16 *pcm, - int frame_size, - unsigned char *compressed, - int maxCompressedBytes -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); - -/** Perform a CTL function on an Opus custom encoder. - * - * Generally the request and subsequent arguments are generated - * by a convenience macro. - * @see opus_encoderctls - */ -OPUS_CUSTOM_EXPORT int opus_custom_encoder_ctl(OpusCustomEncoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1); - - -#if !defined(OPUS_BUILD) || defined(CELT_DECODER_C) -/* Decoder */ - -/** Gets the size of an OpusCustomDecoder structure. - * @param [in] mode OpusCustomMode *: Mode configuration - * @param [in] channels int: Number of channels - * @returns size - */ -OPUS_CUSTOM_EXPORT_STATIC OPUS_WARN_UNUSED_RESULT int opus_custom_decoder_get_size( - const OpusCustomMode *mode, - int channels -) OPUS_ARG_NONNULL(1); - -/** Initializes a previously allocated decoder state - * The memory pointed to by st must be the size returned by opus_custom_decoder_get_size. - * This is intended for applications which use their own allocator instead of malloc. - * @see opus_custom_decoder_create(),opus_custom_decoder_get_size() - * To reset a previously initialized state use the OPUS_RESET_STATE CTL. - * @param [in] st OpusCustomDecoder*: Decoder state - * @param [in] mode OpusCustomMode *: Contains all the information about the characteristics of - * the stream (must be the same characteristics as used for the - * encoder) - * @param [in] channels int: Number of channels - * @return OPUS_OK Success or @ref opus_errorcodes - */ -OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_init( - OpusCustomDecoder *st, - const OpusCustomMode *mode, - int channels -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); - -#endif - - -/** Creates a new decoder state. Each stream needs its own decoder state (can't - * be shared across simultaneous streams). - * @param [in] mode OpusCustomMode: Contains all the information about the characteristics of the - * stream (must be the same characteristics as used for the encoder) - * @param [in] channels int: Number of channels - * @param [out] error int*: Returns an error code - * @return Newly created decoder state. - */ -OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomDecoder *opus_custom_decoder_create( - const OpusCustomMode *mode, - int channels, - int *error -) OPUS_ARG_NONNULL(1); - -/** Destroys a decoder state. - * @param[in] st OpusCustomDecoder*: State to be freed. - */ -OPUS_CUSTOM_EXPORT void opus_custom_decoder_destroy(OpusCustomDecoder *st); - -/** Decode an opus custom frame with floating point output - * @param [in] st OpusCustomDecoder*: Decoder state - * @param [in] data char*: Input payload. Use a NULL pointer to indicate packet loss - * @param [in] len int: Number of bytes in payload - * @param [out] pcm float*: Output signal (interleaved if 2 channels). length - * is frame_size*channels*sizeof(float) - * @param [in] frame_size Number of samples per channel of available space in *pcm. - * @returns Number of decoded samples or @ref opus_errorcodes - */ -OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode_float( - OpusCustomDecoder *st, - const unsigned char *data, - int len, - float *pcm, - int frame_size -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); - -/** Decode an opus custom frame - * @param [in] st OpusCustomDecoder*: Decoder state - * @param [in] data char*: Input payload. Use a NULL pointer to indicate packet loss - * @param [in] len int: Number of bytes in payload - * @param [out] pcm opus_int16*: Output signal (interleaved if 2 channels). length - * is frame_size*channels*sizeof(opus_int16) - * @param [in] frame_size Number of samples per channel of available space in *pcm. - * @returns Number of decoded samples or @ref opus_errorcodes - */ -OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode( - OpusCustomDecoder *st, - const unsigned char *data, - int len, - opus_int16 *pcm, - int frame_size -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); - -/** Perform a CTL function on an Opus custom decoder. - * - * Generally the request and subsequent arguments are generated - * by a convenience macro. - * @see opus_genericctls - */ -OPUS_CUSTOM_EXPORT int opus_custom_decoder_ctl(OpusCustomDecoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* OPUS_CUSTOM_H */ diff --git a/Engine/lib/opus/include/opus_defines.h b/Engine/lib/opus/include/opus_defines.h deleted file mode 100644 index 94b9e0d9f..000000000 --- a/Engine/lib/opus/include/opus_defines.h +++ /dev/null @@ -1,801 +0,0 @@ -/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited - Written by Jean-Marc Valin and Koen Vos */ -/* - 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. -*/ - -/** - * @file opus_defines.h - * @brief Opus reference implementation constants - */ - -#ifndef OPUS_DEFINES_H -#define OPUS_DEFINES_H - -#include "opus_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** @defgroup opus_errorcodes Error codes - * @{ - */ -/** No error @hideinitializer*/ -#define OPUS_OK 0 -/** One or more invalid/out of range arguments @hideinitializer*/ -#define OPUS_BAD_ARG -1 -/** Not enough bytes allocated in the buffer @hideinitializer*/ -#define OPUS_BUFFER_TOO_SMALL -2 -/** An internal error was detected @hideinitializer*/ -#define OPUS_INTERNAL_ERROR -3 -/** The compressed data passed is corrupted @hideinitializer*/ -#define OPUS_INVALID_PACKET -4 -/** Invalid/unsupported request number @hideinitializer*/ -#define OPUS_UNIMPLEMENTED -5 -/** An encoder or decoder structure is invalid or already freed @hideinitializer*/ -#define OPUS_INVALID_STATE -6 -/** Memory allocation has failed @hideinitializer*/ -#define OPUS_ALLOC_FAIL -7 -/**@}*/ - -/** @cond OPUS_INTERNAL_DOC */ -/**Export control for opus functions */ - -#ifndef OPUS_EXPORT -# if defined(_WIN32) -# if defined(OPUS_BUILD) && defined(DLL_EXPORT) -# define OPUS_EXPORT __declspec(dllexport) -# else -# define OPUS_EXPORT -# endif -# elif defined(__GNUC__) && defined(OPUS_BUILD) -# define OPUS_EXPORT __attribute__ ((visibility ("default"))) -# else -# define OPUS_EXPORT -# endif -#endif - -# if !defined(OPUS_GNUC_PREREQ) -# if defined(__GNUC__)&&defined(__GNUC_MINOR__) -# define OPUS_GNUC_PREREQ(_maj,_min) \ - ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) -# else -# define OPUS_GNUC_PREREQ(_maj,_min) 0 -# endif -# endif - -#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) -# if OPUS_GNUC_PREREQ(3,0) -# define OPUS_RESTRICT __restrict__ -# elif (defined(_MSC_VER) && _MSC_VER >= 1400) -# define OPUS_RESTRICT __restrict -# else -# define OPUS_RESTRICT -# endif -#else -# define OPUS_RESTRICT restrict -#endif - -#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) -# if OPUS_GNUC_PREREQ(2,7) -# define OPUS_INLINE __inline__ -# elif (defined(_MSC_VER)) -# define OPUS_INLINE __inline -# else -# define OPUS_INLINE -# endif -#else -# define OPUS_INLINE inline -#endif - -/**Warning attributes for opus functions - * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out - * some paranoid null checks. */ -#if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) -# define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) -#else -# define OPUS_WARN_UNUSED_RESULT -#endif -#if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) -# define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) -#else -# define OPUS_ARG_NONNULL(_x) -#endif - -/** These are the actual Encoder CTL ID numbers. - * They should not be used directly by applications. - * In general, SETs should be even and GETs should be odd.*/ -#define OPUS_SET_APPLICATION_REQUEST 4000 -#define OPUS_GET_APPLICATION_REQUEST 4001 -#define OPUS_SET_BITRATE_REQUEST 4002 -#define OPUS_GET_BITRATE_REQUEST 4003 -#define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 -#define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 -#define OPUS_SET_VBR_REQUEST 4006 -#define OPUS_GET_VBR_REQUEST 4007 -#define OPUS_SET_BANDWIDTH_REQUEST 4008 -#define OPUS_GET_BANDWIDTH_REQUEST 4009 -#define OPUS_SET_COMPLEXITY_REQUEST 4010 -#define OPUS_GET_COMPLEXITY_REQUEST 4011 -#define OPUS_SET_INBAND_FEC_REQUEST 4012 -#define OPUS_GET_INBAND_FEC_REQUEST 4013 -#define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014 -#define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015 -#define OPUS_SET_DTX_REQUEST 4016 -#define OPUS_GET_DTX_REQUEST 4017 -#define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 -#define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 -#define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 -#define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 -#define OPUS_SET_SIGNAL_REQUEST 4024 -#define OPUS_GET_SIGNAL_REQUEST 4025 -#define OPUS_GET_LOOKAHEAD_REQUEST 4027 -/* #define OPUS_RESET_STATE 4028 */ -#define OPUS_GET_SAMPLE_RATE_REQUEST 4029 -#define OPUS_GET_FINAL_RANGE_REQUEST 4031 -#define OPUS_GET_PITCH_REQUEST 4033 -#define OPUS_SET_GAIN_REQUEST 4034 -#define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */ -#define OPUS_SET_LSB_DEPTH_REQUEST 4036 -#define OPUS_GET_LSB_DEPTH_REQUEST 4037 -#define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039 -#define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040 -#define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041 -#define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042 -#define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043 -/* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */ -#define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046 -#define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047 -#define OPUS_GET_IN_DTX_REQUEST 4049 - -/** Defines for the presence of extended APIs. */ -#define OPUS_HAVE_OPUS_PROJECTION_H - -/* Macros to trigger compilation errors when the wrong types are provided to a CTL */ -#define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x)) -#define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) -#define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) -#define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr))) -/** @endcond */ - -/** @defgroup opus_ctlvalues Pre-defined values for CTL interface - * @see opus_genericctls, opus_encoderctls - * @{ - */ -/* Values for the various encoder CTLs */ -#define OPUS_AUTO -1000 /**opus_int32
    : Allowed values: 0-10, inclusive. - * - * @hideinitializer */ -#define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x) -/** Gets the encoder's complexity configuration. - * @see OPUS_SET_COMPLEXITY - * @param[out] x opus_int32 *: Returns a value in the range 0-10, - * inclusive. - * @hideinitializer */ -#define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x) - -/** Configures the bitrate in the encoder. - * Rates from 500 to 512000 bits per second are meaningful, as well as the - * special values #OPUS_AUTO and #OPUS_BITRATE_MAX. - * The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much - * rate as it can, which is useful for controlling the rate by adjusting the - * output buffer size. - * @see OPUS_GET_BITRATE - * @param[in] x opus_int32: Bitrate in bits per second. The default - * is determined based on the number of - * channels and the input sampling rate. - * @hideinitializer */ -#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) -/** Gets the encoder's bitrate configuration. - * @see OPUS_SET_BITRATE - * @param[out] x opus_int32 *: Returns the bitrate in bits per second. - * The default is determined based on the - * number of channels and the input - * sampling rate. - * @hideinitializer */ -#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x) - -/** Enables or disables variable bitrate (VBR) in the encoder. - * The configured bitrate may not be met exactly because frames must - * be an integer number of bytes in length. - * @see OPUS_GET_VBR - * @see OPUS_SET_VBR_CONSTRAINT - * @param[in] x opus_int32: Allowed values: - *
    - *
    0
    Hard CBR. For LPC/hybrid modes at very low bit-rate, this can - * cause noticeable quality degradation.
    - *
    1
    VBR (default). The exact type of VBR is controlled by - * #OPUS_SET_VBR_CONSTRAINT.
    - *
    - * @hideinitializer */ -#define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) -/** Determine if variable bitrate (VBR) is enabled in the encoder. - * @see OPUS_SET_VBR - * @see OPUS_GET_VBR_CONSTRAINT - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    0
    Hard CBR.
    - *
    1
    VBR (default). The exact type of VBR may be retrieved via - * #OPUS_GET_VBR_CONSTRAINT.
    - *
    - * @hideinitializer */ -#define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) - -/** Enables or disables constrained VBR in the encoder. - * This setting is ignored when the encoder is in CBR mode. - * @warning Only the MDCT mode of Opus currently heeds the constraint. - * Speech mode ignores it completely, hybrid mode may fail to obey it - * if the LPC layer uses more bitrate than the constraint would have - * permitted. - * @see OPUS_GET_VBR_CONSTRAINT - * @see OPUS_SET_VBR - * @param[in] x opus_int32: Allowed values: - *
    - *
    0
    Unconstrained VBR.
    - *
    1
    Constrained VBR (default). This creates a maximum of one - * frame of buffering delay assuming a transport with a - * serialization speed of the nominal bitrate.
    - *
    - * @hideinitializer */ -#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x) -/** Determine if constrained VBR is enabled in the encoder. - * @see OPUS_SET_VBR_CONSTRAINT - * @see OPUS_GET_VBR - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    0
    Unconstrained VBR.
    - *
    1
    Constrained VBR (default).
    - *
    - * @hideinitializer */ -#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x) - -/** Configures mono/stereo forcing in the encoder. - * This can force the encoder to produce packets encoded as either mono or - * stereo, regardless of the format of the input audio. This is useful when - * the caller knows that the input signal is currently a mono source embedded - * in a stereo stream. - * @see OPUS_GET_FORCE_CHANNELS - * @param[in] x opus_int32: Allowed values: - *
    - *
    #OPUS_AUTO
    Not forced (default)
    - *
    1
    Forced mono
    - *
    2
    Forced stereo
    - *
    - * @hideinitializer */ -#define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x) -/** Gets the encoder's forced channel configuration. - * @see OPUS_SET_FORCE_CHANNELS - * @param[out] x opus_int32 *: - *
    - *
    #OPUS_AUTO
    Not forced (default)
    - *
    1
    Forced mono
    - *
    2
    Forced stereo
    - *
    - * @hideinitializer */ -#define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x) - -/** Configures the maximum bandpass that the encoder will select automatically. - * Applications should normally use this instead of #OPUS_SET_BANDWIDTH - * (leaving that set to the default, #OPUS_AUTO). This allows the - * application to set an upper bound based on the type of input it is - * providing, but still gives the encoder the freedom to reduce the bandpass - * when the bitrate becomes too low, for better overall quality. - * @see OPUS_GET_MAX_BANDWIDTH - * @param[in] x opus_int32: Allowed values: - *
    - *
    OPUS_BANDWIDTH_NARROWBAND
    4 kHz passband
    - *
    OPUS_BANDWIDTH_MEDIUMBAND
    6 kHz passband
    - *
    OPUS_BANDWIDTH_WIDEBAND
    8 kHz passband
    - *
    OPUS_BANDWIDTH_SUPERWIDEBAND
    12 kHz passband
    - *
    OPUS_BANDWIDTH_FULLBAND
    20 kHz passband (default)
    - *
    - * @hideinitializer */ -#define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x) - -/** Gets the encoder's configured maximum allowed bandpass. - * @see OPUS_SET_MAX_BANDWIDTH - * @param[out] x opus_int32 *: Allowed values: - *
    - *
    #OPUS_BANDWIDTH_NARROWBAND
    4 kHz passband
    - *
    #OPUS_BANDWIDTH_MEDIUMBAND
    6 kHz passband
    - *
    #OPUS_BANDWIDTH_WIDEBAND
    8 kHz passband
    - *
    #OPUS_BANDWIDTH_SUPERWIDEBAND
    12 kHz passband
    - *
    #OPUS_BANDWIDTH_FULLBAND
    20 kHz passband (default)
    - *
    - * @hideinitializer */ -#define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) - -/** Sets the encoder's bandpass to a specific value. - * This prevents the encoder from automatically selecting the bandpass based - * on the available bitrate. If an application knows the bandpass of the input - * audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH - * instead, which still gives the encoder the freedom to reduce the bandpass - * when the bitrate becomes too low, for better overall quality. - * @see OPUS_GET_BANDWIDTH - * @param[in] x opus_int32: Allowed values: - *
    - *
    #OPUS_AUTO
    (default)
    - *
    #OPUS_BANDWIDTH_NARROWBAND
    4 kHz passband
    - *
    #OPUS_BANDWIDTH_MEDIUMBAND
    6 kHz passband
    - *
    #OPUS_BANDWIDTH_WIDEBAND
    8 kHz passband
    - *
    #OPUS_BANDWIDTH_SUPERWIDEBAND
    12 kHz passband
    - *
    #OPUS_BANDWIDTH_FULLBAND
    20 kHz passband
    - *
    - * @hideinitializer */ -#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x) - -/** Configures the type of signal being encoded. - * This is a hint which helps the encoder's mode selection. - * @see OPUS_GET_SIGNAL - * @param[in] x opus_int32: Allowed values: - *
    - *
    #OPUS_AUTO
    (default)
    - *
    #OPUS_SIGNAL_VOICE
    Bias thresholds towards choosing LPC or Hybrid modes.
    - *
    #OPUS_SIGNAL_MUSIC
    Bias thresholds towards choosing MDCT modes.
    - *
    - * @hideinitializer */ -#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) -/** Gets the encoder's configured signal type. - * @see OPUS_SET_SIGNAL - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    #OPUS_AUTO
    (default)
    - *
    #OPUS_SIGNAL_VOICE
    Bias thresholds towards choosing LPC or Hybrid modes.
    - *
    #OPUS_SIGNAL_MUSIC
    Bias thresholds towards choosing MDCT modes.
    - *
    - * @hideinitializer */ -#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) - - -/** Configures the encoder's intended application. - * The initial value is a mandatory argument to the encoder_create function. - * @see OPUS_GET_APPLICATION - * @param[in] x opus_int32: Returns one of the following values: - *
    - *
    #OPUS_APPLICATION_VOIP
    - *
    Process signal for improved speech intelligibility.
    - *
    #OPUS_APPLICATION_AUDIO
    - *
    Favor faithfulness to the original input.
    - *
    #OPUS_APPLICATION_RESTRICTED_LOWDELAY
    - *
    Configure the minimum possible coding delay by disabling certain modes - * of operation.
    - *
    - * @hideinitializer */ -#define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x) -/** Gets the encoder's configured application. - * @see OPUS_SET_APPLICATION - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    #OPUS_APPLICATION_VOIP
    - *
    Process signal for improved speech intelligibility.
    - *
    #OPUS_APPLICATION_AUDIO
    - *
    Favor faithfulness to the original input.
    - *
    #OPUS_APPLICATION_RESTRICTED_LOWDELAY
    - *
    Configure the minimum possible coding delay by disabling certain modes - * of operation.
    - *
    - * @hideinitializer */ -#define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x) - -/** Gets the total samples of delay added by the entire codec. - * This can be queried by the encoder and then the provided number of samples can be - * skipped on from the start of the decoder's output to provide time aligned input - * and output. From the perspective of a decoding application the real data begins this many - * samples late. - * - * The decoder contribution to this delay is identical for all decoders, but the - * encoder portion of the delay may vary from implementation to implementation, - * version to version, or even depend on the encoder's initial configuration. - * Applications needing delay compensation should call this CTL rather than - * hard-coding a value. - * @param[out] x opus_int32 *: Number of lookahead samples - * @hideinitializer */ -#define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x) - -/** Configures the encoder's use of inband forward error correction (FEC). - * @note This is only applicable to the LPC layer - * @see OPUS_GET_INBAND_FEC - * @param[in] x opus_int32: Allowed values: - *
    - *
    0
    Disable inband FEC (default).
    - *
    1
    Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.
    - *
    2
    Inband FEC enabled, but does not necessarily switch to SILK if we have music.
    - *
    - * @hideinitializer */ -#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x) -/** Gets encoder's configured use of inband forward error correction. - * @see OPUS_SET_INBAND_FEC - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    0
    Inband FEC disabled (default).
    - *
    1
    Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.
    - *
    2
    Inband FEC enabled, but does not necessarily switch to SILK if we have music.
    - *
    - * @hideinitializer */ -#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x) - -/** Configures the encoder's expected packet loss percentage. - * Higher values trigger progressively more loss resistant behavior in the encoder - * at the expense of quality at a given bitrate in the absence of packet loss, but - * greater quality under loss. - * @see OPUS_GET_PACKET_LOSS_PERC - * @param[in] x opus_int32: Loss percentage in the range 0-100, inclusive (default: 0). - * @hideinitializer */ -#define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x) -/** Gets the encoder's configured packet loss percentage. - * @see OPUS_SET_PACKET_LOSS_PERC - * @param[out] x opus_int32 *: Returns the configured loss percentage - * in the range 0-100, inclusive (default: 0). - * @hideinitializer */ -#define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x) - -/** Configures the encoder's use of discontinuous transmission (DTX). - * @note This is only applicable to the LPC layer - * @see OPUS_GET_DTX - * @param[in] x opus_int32: Allowed values: - *
    - *
    0
    Disable DTX (default).
    - *
    1
    Enabled DTX.
    - *
    - * @hideinitializer */ -#define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) -/** Gets encoder's configured use of discontinuous transmission. - * @see OPUS_SET_DTX - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    0
    DTX disabled (default).
    - *
    1
    DTX enabled.
    - *
    - * @hideinitializer */ -#define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) -/** Configures the depth of signal being encoded. - * - * This is a hint which helps the encoder identify silence and near-silence. - * It represents the number of significant bits of linear intensity below - * which the signal contains ignorable quantization or other noise. - * - * For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting - * for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate - * for 16-bit linear pcm input with opus_encode_float(). - * - * When using opus_encode() instead of opus_encode_float(), or when libopus - * is compiled for fixed-point, the encoder uses the minimum of the value - * set here and the value 16. - * - * @see OPUS_GET_LSB_DEPTH - * @param[in] x opus_int32: Input precision in bits, between 8 and 24 - * (default: 24). - * @hideinitializer */ -#define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x) -/** Gets the encoder's configured signal depth. - * @see OPUS_SET_LSB_DEPTH - * @param[out] x opus_int32 *: Input precision in bits, between 8 and - * 24 (default: 24). - * @hideinitializer */ -#define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x) - -/** Configures the encoder's use of variable duration frames. - * When variable duration is enabled, the encoder is free to use a shorter frame - * size than the one requested in the opus_encode*() call. - * It is then the user's responsibility - * to verify how much audio was encoded by checking the ToC byte of the encoded - * packet. The part of the audio that was not encoded needs to be resent to the - * encoder for the next call. Do not use this option unless you really - * know what you are doing. - * @see OPUS_GET_EXPERT_FRAME_DURATION - * @param[in] x opus_int32: Allowed values: - *
    - *
    OPUS_FRAMESIZE_ARG
    Select frame size from the argument (default).
    - *
    OPUS_FRAMESIZE_2_5_MS
    Use 2.5 ms frames.
    - *
    OPUS_FRAMESIZE_5_MS
    Use 5 ms frames.
    - *
    OPUS_FRAMESIZE_10_MS
    Use 10 ms frames.
    - *
    OPUS_FRAMESIZE_20_MS
    Use 20 ms frames.
    - *
    OPUS_FRAMESIZE_40_MS
    Use 40 ms frames.
    - *
    OPUS_FRAMESIZE_60_MS
    Use 60 ms frames.
    - *
    OPUS_FRAMESIZE_80_MS
    Use 80 ms frames.
    - *
    OPUS_FRAMESIZE_100_MS
    Use 100 ms frames.
    - *
    OPUS_FRAMESIZE_120_MS
    Use 120 ms frames.
    - *
    - * @hideinitializer */ -#define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x) -/** Gets the encoder's configured use of variable duration frames. - * @see OPUS_SET_EXPERT_FRAME_DURATION - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    OPUS_FRAMESIZE_ARG
    Select frame size from the argument (default).
    - *
    OPUS_FRAMESIZE_2_5_MS
    Use 2.5 ms frames.
    - *
    OPUS_FRAMESIZE_5_MS
    Use 5 ms frames.
    - *
    OPUS_FRAMESIZE_10_MS
    Use 10 ms frames.
    - *
    OPUS_FRAMESIZE_20_MS
    Use 20 ms frames.
    - *
    OPUS_FRAMESIZE_40_MS
    Use 40 ms frames.
    - *
    OPUS_FRAMESIZE_60_MS
    Use 60 ms frames.
    - *
    OPUS_FRAMESIZE_80_MS
    Use 80 ms frames.
    - *
    OPUS_FRAMESIZE_100_MS
    Use 100 ms frames.
    - *
    OPUS_FRAMESIZE_120_MS
    Use 120 ms frames.
    - *
    - * @hideinitializer */ -#define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x) - -/** If set to 1, disables almost all use of prediction, making frames almost - * completely independent. This reduces quality. - * @see OPUS_GET_PREDICTION_DISABLED - * @param[in] x opus_int32: Allowed values: - *
    - *
    0
    Enable prediction (default).
    - *
    1
    Disable prediction.
    - *
    - * @hideinitializer */ -#define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x) -/** Gets the encoder's configured prediction status. - * @see OPUS_SET_PREDICTION_DISABLED - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    0
    Prediction enabled (default).
    - *
    1
    Prediction disabled.
    - *
    - * @hideinitializer */ -#define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x) - -/**@}*/ - -/** @defgroup opus_genericctls Generic CTLs - * - * These macros are used with the \c opus_decoder_ctl and - * \c opus_encoder_ctl calls to generate a particular - * request. - * - * When called on an \c OpusDecoder they apply to that - * particular decoder instance. When called on an - * \c OpusEncoder they apply to the corresponding setting - * on that encoder instance, if present. - * - * Some usage examples: - * - * @code - * int ret; - * opus_int32 pitch; - * ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch)); - * if (ret == OPUS_OK) return ret; - * - * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); - * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); - * - * opus_int32 enc_bw, dec_bw; - * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); - * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); - * if (enc_bw != dec_bw) { - * printf("packet bandwidth mismatch!\n"); - * } - * @endcode - * - * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls - * @{ - */ - -/** Resets the codec state to be equivalent to a freshly initialized state. - * This should be called when switching streams in order to prevent - * the back to back decoding from giving different results from - * one at a time decoding. - * @hideinitializer */ -#define OPUS_RESET_STATE 4028 - -/** Gets the final state of the codec's entropy coder. - * This is used for testing purposes, - * The encoder and decoder state should be identical after coding a payload - * (assuming no data corruption or software bugs) - * - * @param[out] x opus_uint32 *: Entropy coder state - * - * @hideinitializer */ -#define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x) - -/** Gets the encoder's configured bandpass or the decoder's last bandpass. - * @see OPUS_SET_BANDWIDTH - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    #OPUS_AUTO
    (default)
    - *
    #OPUS_BANDWIDTH_NARROWBAND
    4 kHz passband
    - *
    #OPUS_BANDWIDTH_MEDIUMBAND
    6 kHz passband
    - *
    #OPUS_BANDWIDTH_WIDEBAND
    8 kHz passband
    - *
    #OPUS_BANDWIDTH_SUPERWIDEBAND
    12 kHz passband
    - *
    #OPUS_BANDWIDTH_FULLBAND
    20 kHz passband
    - *
    - * @hideinitializer */ -#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) - -/** Gets the sampling rate the encoder or decoder was initialized with. - * This simply returns the Fs value passed to opus_encoder_init() - * or opus_decoder_init(). - * @param[out] x opus_int32 *: Sampling rate of encoder or decoder. - * @hideinitializer - */ -#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) - -/** If set to 1, disables the use of phase inversion for intensity stereo, - * improving the quality of mono downmixes, but slightly reducing normal - * stereo quality. Disabling phase inversion in the decoder does not comply - * with RFC 6716, although it does not cause any interoperability issue and - * is expected to become part of the Opus standard once RFC 6716 is updated - * by draft-ietf-codec-opus-update. - * @see OPUS_GET_PHASE_INVERSION_DISABLED - * @param[in] x opus_int32: Allowed values: - *
    - *
    0
    Enable phase inversion (default).
    - *
    1
    Disable phase inversion.
    - *
    - * @hideinitializer */ -#define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x) -/** Gets the encoder's configured phase inversion status. - * @see OPUS_SET_PHASE_INVERSION_DISABLED - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    0
    Stereo phase inversion enabled (default).
    - *
    1
    Stereo phase inversion disabled.
    - *
    - * @hideinitializer */ -#define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x) -/** Gets the DTX state of the encoder. - * Returns whether the last encoded frame was either a comfort noise update - * during DTX or not encoded because of DTX. - * @param[out] x opus_int32 *: Returns one of the following values: - *
    - *
    0
    The encoder is not in DTX.
    - *
    1
    The encoder is in DTX.
    - *
    - * @hideinitializer */ -#define OPUS_GET_IN_DTX(x) OPUS_GET_IN_DTX_REQUEST, __opus_check_int_ptr(x) - -/**@}*/ - -/** @defgroup opus_decoderctls Decoder related CTLs - * @see opus_genericctls, opus_encoderctls, opus_decoder - * @{ - */ - -/** Configures decoder gain adjustment. - * Scales the decoded output by a factor specified in Q8 dB units. - * This has a maximum range of -32768 to 32767 inclusive, and returns - * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. - * This setting survives decoder reset. - * - * gain = pow(10, x/(20.0*256)) - * - * @param[in] x opus_int32: Amount to scale PCM signal by in Q8 dB units. - * @hideinitializer */ -#define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) -/** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN - * - * @param[out] x opus_int32 *: Amount to scale PCM signal by in Q8 dB units. - * @hideinitializer */ -#define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) - -/** Gets the duration (in samples) of the last packet successfully decoded or concealed. - * @param[out] x opus_int32 *: Number of samples (at current sampling rate). - * @hideinitializer */ -#define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) - -/** Gets the pitch of the last decoded frame, if available. - * This can be used for any post-processing algorithm requiring the use of pitch, - * e.g. time stretching/shortening. If the last frame was not voiced, or if the - * pitch was not coded in the frame, then zero is returned. - * - * This CTL is only implemented for decoder instances. - * - * @param[out] x opus_int32 *: pitch period at 48 kHz (or 0 if not available) - * - * @hideinitializer */ -#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) - -/**@}*/ - -/** @defgroup opus_libinfo Opus library information functions - * @{ - */ - -/** Converts an opus error code into a human readable string. - * - * @param[in] error int: Error number - * @returns Error string - */ -OPUS_EXPORT const char *opus_strerror(int error); - -/** Gets the libopus version string. - * - * Applications may look for the substring "-fixed" in the version string to - * determine whether they have a fixed-point or floating-point build at - * runtime. - * - * @returns Version string - */ -OPUS_EXPORT const char *opus_get_version_string(void); -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* OPUS_DEFINES_H */ diff --git a/Engine/lib/opus/include/opus_multistream.h b/Engine/lib/opus/include/opus_multistream.h deleted file mode 100644 index babcee690..000000000 --- a/Engine/lib/opus/include/opus_multistream.h +++ /dev/null @@ -1,660 +0,0 @@ -/* Copyright (c) 2011 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. -*/ - -/** - * @file opus_multistream.h - * @brief Opus reference implementation multistream API - */ - -#ifndef OPUS_MULTISTREAM_H -#define OPUS_MULTISTREAM_H - -#include "opus.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** @cond OPUS_INTERNAL_DOC */ - -/** Macros to trigger compilation errors when the wrong types are provided to a - * CTL. */ -/**@{*/ -#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr))) -#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr))) -/**@}*/ - -/** These are the actual encoder and decoder CTL ID numbers. - * They should not be used directly by applications. - * In general, SETs should be even and GETs should be odd.*/ -/**@{*/ -#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120 -#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122 -/**@}*/ - -/** @endcond */ - -/** @defgroup opus_multistream_ctls Multistream specific encoder and decoder CTLs - * - * These are convenience macros that are specific to the - * opus_multistream_encoder_ctl() and opus_multistream_decoder_ctl() - * interface. - * The CTLs from @ref opus_genericctls, @ref opus_encoderctls, and - * @ref opus_decoderctls may be applied to a multistream encoder or decoder as - * well. - * In addition, you may retrieve the encoder or decoder state for an specific - * stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or - * #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually. - */ -/**@{*/ - -/** Gets the encoder state for an individual stream of a multistream encoder. - * @param[in] x opus_int32: The index of the stream whose encoder you - * wish to retrieve. - * This must be non-negative and less than - * the streams parameter used - * to initialize the encoder. - * @param[out] y OpusEncoder**: Returns a pointer to the given - * encoder state. - * @retval OPUS_BAD_ARG The index of the requested stream was out of range. - * @hideinitializer - */ -#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y) - -/** Gets the decoder state for an individual stream of a multistream decoder. - * @param[in] x opus_int32: The index of the stream whose decoder you - * wish to retrieve. - * This must be non-negative and less than - * the streams parameter used - * to initialize the decoder. - * @param[out] y OpusDecoder**: Returns a pointer to the given - * decoder state. - * @retval OPUS_BAD_ARG The index of the requested stream was out of range. - * @hideinitializer - */ -#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y) - -/**@}*/ - -/** @defgroup opus_multistream Opus Multistream API - * @{ - * - * The multistream API allows individual Opus streams to be combined into a - * single packet, enabling support for up to 255 channels. Unlike an - * elementary Opus stream, the encoder and decoder must negotiate the channel - * configuration before the decoder can successfully interpret the data in the - * packets produced by the encoder. Some basic information, such as packet - * duration, can be computed without any special negotiation. - * - * The format for multistream Opus packets is defined in - * RFC 7845 - * and is based on the self-delimited Opus framing described in Appendix B of - * RFC 6716. - * Normal Opus packets are just a degenerate case of multistream Opus packets, - * and can be encoded or decoded with the multistream API by setting - * streams to 1 when initializing the encoder or - * decoder. - * - * Multistream Opus streams can contain up to 255 elementary Opus streams. - * These may be either "uncoupled" or "coupled", indicating that the decoder - * is configured to decode them to either 1 or 2 channels, respectively. - * The streams are ordered so that all coupled streams appear at the - * beginning. - * - * A mapping table defines which decoded channel i - * should be used for each input/output (I/O) channel j. This table is - * typically provided as an unsigned char array. - * Let i = mapping[j] be the index for I/O channel j. - * If i < 2*coupled_streams, then I/O channel j is - * encoded as the left channel of stream (i/2) if i - * is even, or as the right channel of stream (i/2) if - * i is odd. Otherwise, I/O channel j is encoded as - * mono in stream (i - coupled_streams), unless it has the special - * value 255, in which case it is omitted from the encoding entirely (the - * decoder will reproduce it as silence). Each value i must either - * be the special value 255 or be less than streams + coupled_streams. - * - * The output channels specified by the encoder - * should use the - * Vorbis - * channel ordering. A decoder may wish to apply an additional permutation - * to the mapping the encoder used to achieve a different output channel - * order (e.g. for outputing in WAV order). - * - * Each multistream packet contains an Opus packet for each stream, and all of - * the Opus packets in a single multistream packet must have the same - * duration. Therefore the duration of a multistream packet can be extracted - * from the TOC sequence of the first stream, which is located at the - * beginning of the packet, just like an elementary Opus stream: - * - * @code - * int nb_samples; - * int nb_frames; - * nb_frames = opus_packet_get_nb_frames(data, len); - * if (nb_frames < 1) - * return nb_frames; - * nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames; - * @endcode - * - * The general encoding and decoding process proceeds exactly the same as in - * the normal @ref opus_encoder and @ref opus_decoder APIs. - * See their documentation for an overview of how to use the corresponding - * multistream functions. - */ - -/** Opus multistream encoder state. - * This contains the complete state of a multistream Opus encoder. - * It is position independent and can be freely copied. - * @see opus_multistream_encoder_create - * @see opus_multistream_encoder_init - */ -typedef struct OpusMSEncoder OpusMSEncoder; - -/** Opus multistream decoder state. - * This contains the complete state of a multistream Opus decoder. - * It is position independent and can be freely copied. - * @see opus_multistream_decoder_create - * @see opus_multistream_decoder_init - */ -typedef struct OpusMSDecoder OpusMSDecoder; - -/**\name Multistream encoder functions */ -/**@{*/ - -/** Gets the size of an OpusMSEncoder structure. - * @param streams int: The total number of streams to encode from the - * input. - * This must be no more than 255. - * @param coupled_streams int: Number of coupled (2 channel) streams - * to encode. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * encoded channels (streams + - * coupled_streams) must be no - * more than 255. - * @returns The size in bytes on success, or a negative error code - * (see @ref opus_errorcodes) on error. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size( - int streams, - int coupled_streams -); - -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size( - int channels, - int mapping_family -); - - -/** Allocates and initializes a multistream encoder state. - * Call opus_multistream_encoder_destroy() to release - * this object when finished. - * @param Fs opus_int32: Sampling rate of the input signal (in Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param channels int: Number of channels in the input signal. - * This must be at most 255. - * It may be greater than the number of - * coded channels (streams + - * coupled_streams). - * @param streams int: The total number of streams to encode from the - * input. - * This must be no more than the number of channels. - * @param coupled_streams int: Number of coupled (2 channel) streams - * to encode. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * encoded channels (streams + - * coupled_streams) must be no - * more than the number of input channels. - * @param[in] mapping const unsigned char[channels]: Mapping from - * encoded channels to input channels, as described in - * @ref opus_multistream. As an extra constraint, the - * multistream encoder does not allow encoding coupled - * streams for which one channel is unused since this - * is never a good idea. - * @param application int: The target encoder application. - * This must be one of the following: - *
    - *
    #OPUS_APPLICATION_VOIP
    - *
    Process signal for improved speech intelligibility.
    - *
    #OPUS_APPLICATION_AUDIO
    - *
    Favor faithfulness to the original input.
    - *
    #OPUS_APPLICATION_RESTRICTED_LOWDELAY
    - *
    Configure the minimum possible coding delay by disabling certain modes - * of operation.
    - *
    - * @param[out] error int *: Returns #OPUS_OK on success, or an error - * code (see @ref opus_errorcodes) on - * failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_create( - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - const unsigned char *mapping, - int application, - int *error -) OPUS_ARG_NONNULL(5); - -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_surround_encoder_create( - opus_int32 Fs, - int channels, - int mapping_family, - int *streams, - int *coupled_streams, - unsigned char *mapping, - int application, - int *error -) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6); - -/** Initialize a previously allocated multistream encoder state. - * The memory pointed to by \a st must be at least the size returned by - * opus_multistream_encoder_get_size(). - * This is intended for applications which use their own allocator instead of - * malloc. - * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. - * @see opus_multistream_encoder_create - * @see opus_multistream_encoder_get_size - * @param st OpusMSEncoder*: Multistream encoder state to initialize. - * @param Fs opus_int32: Sampling rate of the input signal (in Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param channels int: Number of channels in the input signal. - * This must be at most 255. - * It may be greater than the number of - * coded channels (streams + - * coupled_streams). - * @param streams int: The total number of streams to encode from the - * input. - * This must be no more than the number of channels. - * @param coupled_streams int: Number of coupled (2 channel) streams - * to encode. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * encoded channels (streams + - * coupled_streams) must be no - * more than the number of input channels. - * @param[in] mapping const unsigned char[channels]: Mapping from - * encoded channels to input channels, as described in - * @ref opus_multistream. As an extra constraint, the - * multistream encoder does not allow encoding coupled - * streams for which one channel is unused since this - * is never a good idea. - * @param application int: The target encoder application. - * This must be one of the following: - *
    - *
    #OPUS_APPLICATION_VOIP
    - *
    Process signal for improved speech intelligibility.
    - *
    #OPUS_APPLICATION_AUDIO
    - *
    Favor faithfulness to the original input.
    - *
    #OPUS_APPLICATION_RESTRICTED_LOWDELAY
    - *
    Configure the minimum possible coding delay by disabling certain modes - * of operation.
    - *
    - * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) - * on failure. - */ -OPUS_EXPORT int opus_multistream_encoder_init( - OpusMSEncoder *st, - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - const unsigned char *mapping, - int application -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); - -OPUS_EXPORT int opus_multistream_surround_encoder_init( - OpusMSEncoder *st, - opus_int32 Fs, - int channels, - int mapping_family, - int *streams, - int *coupled_streams, - unsigned char *mapping, - int application -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6) OPUS_ARG_NONNULL(7); - -/** Encodes a multistream Opus frame. - * @param st OpusMSEncoder*: Multistream encoder state. - * @param[in] pcm const opus_int16*: The input signal as interleaved - * samples. - * This must contain - * frame_size*channels - * samples. - * @param frame_size int: Number of samples per channel in the input - * signal. - * This must be an Opus frame size for the - * encoder's sampling rate. - * For example, at 48 kHz the permitted values - * are 120, 240, 480, 960, 1920, and 2880. - * Passing in a duration of less than 10 ms - * (480 samples at 48 kHz) will prevent the - * encoder from using the LPC or hybrid modes. - * @param[out] data unsigned char*: Output payload. - * This must contain storage for at - * least \a max_data_bytes. - * @param [in] max_data_bytes opus_int32: Size of the allocated - * memory for the output - * payload. This may be - * used to impose an upper limit on - * the instant bitrate, but should - * not be used as the only bitrate - * control. Use #OPUS_SET_BITRATE to - * control the bitrate. - * @returns The length of the encoded packet (in bytes) on success or a - * negative error code (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode( - OpusMSEncoder *st, - const opus_int16 *pcm, - int frame_size, - unsigned char *data, - opus_int32 max_data_bytes -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); - -/** Encodes a multistream Opus frame from floating point input. - * @param st OpusMSEncoder*: Multistream encoder state. - * @param[in] pcm const float*: The input signal as interleaved - * samples with a normal range of - * +/-1.0. - * Samples with a range beyond +/-1.0 - * are supported but will be clipped by - * decoders using the integer API and - * should only be used if it is known - * that the far end supports extended - * dynamic range. - * This must contain - * frame_size*channels - * samples. - * @param frame_size int: Number of samples per channel in the input - * signal. - * This must be an Opus frame size for the - * encoder's sampling rate. - * For example, at 48 kHz the permitted values - * are 120, 240, 480, 960, 1920, and 2880. - * Passing in a duration of less than 10 ms - * (480 samples at 48 kHz) will prevent the - * encoder from using the LPC or hybrid modes. - * @param[out] data unsigned char*: Output payload. - * This must contain storage for at - * least \a max_data_bytes. - * @param [in] max_data_bytes opus_int32: Size of the allocated - * memory for the output - * payload. This may be - * used to impose an upper limit on - * the instant bitrate, but should - * not be used as the only bitrate - * control. Use #OPUS_SET_BITRATE to - * control the bitrate. - * @returns The length of the encoded packet (in bytes) on success or a - * negative error code (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float( - OpusMSEncoder *st, - const float *pcm, - int frame_size, - unsigned char *data, - opus_int32 max_data_bytes -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); - -/** Frees an OpusMSEncoder allocated by - * opus_multistream_encoder_create(). - * @param st OpusMSEncoder*: Multistream encoder state to be freed. - */ -OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st); - -/** Perform a CTL function on a multistream Opus encoder. - * - * Generally the request and subsequent arguments are generated by a - * convenience macro. - * @param st OpusMSEncoder*: Multistream encoder state. - * @param request This and all remaining parameters should be replaced by one - * of the convenience macros in @ref opus_genericctls, - * @ref opus_encoderctls, or @ref opus_multistream_ctls. - * @see opus_genericctls - * @see opus_encoderctls - * @see opus_multistream_ctls - */ -OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); - -/**@}*/ - -/**\name Multistream decoder functions */ -/**@{*/ - -/** Gets the size of an OpusMSDecoder structure. - * @param streams int: The total number of streams coded in the - * input. - * This must be no more than 255. - * @param coupled_streams int: Number streams to decode as coupled - * (2 channel) streams. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * coded channels (streams + - * coupled_streams) must be no - * more than 255. - * @returns The size in bytes on success, or a negative error code - * (see @ref opus_errorcodes) on error. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size( - int streams, - int coupled_streams -); - -/** Allocates and initializes a multistream decoder state. - * Call opus_multistream_decoder_destroy() to release - * this object when finished. - * @param Fs opus_int32: Sampling rate to decode at (in Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param channels int: Number of channels to output. - * This must be at most 255. - * It may be different from the number of coded - * channels (streams + - * coupled_streams). - * @param streams int: The total number of streams coded in the - * input. - * This must be no more than 255. - * @param coupled_streams int: Number of streams to decode as coupled - * (2 channel) streams. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * coded channels (streams + - * coupled_streams) must be no - * more than 255. - * @param[in] mapping const unsigned char[channels]: Mapping from - * coded channels to output channels, as described in - * @ref opus_multistream. - * @param[out] error int *: Returns #OPUS_OK on success, or an error - * code (see @ref opus_errorcodes) on - * failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create( - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - const unsigned char *mapping, - int *error -) OPUS_ARG_NONNULL(5); - -/** Intialize a previously allocated decoder state object. - * The memory pointed to by \a st must be at least the size returned by - * opus_multistream_encoder_get_size(). - * This is intended for applications which use their own allocator instead of - * malloc. - * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. - * @see opus_multistream_decoder_create - * @see opus_multistream_deocder_get_size - * @param st OpusMSEncoder*: Multistream encoder state to initialize. - * @param Fs opus_int32: Sampling rate to decode at (in Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param channels int: Number of channels to output. - * This must be at most 255. - * It may be different from the number of coded - * channels (streams + - * coupled_streams). - * @param streams int: The total number of streams coded in the - * input. - * This must be no more than 255. - * @param coupled_streams int: Number of streams to decode as coupled - * (2 channel) streams. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * coded channels (streams + - * coupled_streams) must be no - * more than 255. - * @param[in] mapping const unsigned char[channels]: Mapping from - * coded channels to output channels, as described in - * @ref opus_multistream. - * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) - * on failure. - */ -OPUS_EXPORT int opus_multistream_decoder_init( - OpusMSDecoder *st, - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - const unsigned char *mapping -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); - -/** Decode a multistream Opus packet. - * @param st OpusMSDecoder*: Multistream decoder state. - * @param[in] data const unsigned char*: Input payload. - * Use a NULL - * pointer to indicate packet - * loss. - * @param len opus_int32: Number of bytes in payload. - * @param[out] pcm opus_int16*: Output signal, with interleaved - * samples. - * This must contain room for - * frame_size*channels - * samples. - * @param frame_size int: The number of samples per channel of - * available space in \a pcm. - * If this is less than the maximum packet duration - * (120 ms; 5760 for 48kHz), this function will not be capable - * of decoding some packets. In the case of PLC (data==NULL) - * or FEC (decode_fec=1), then frame_size needs to be exactly - * the duration of audio that is missing, otherwise the - * decoder will not be in the optimal state to decode the - * next incoming packet. For the PLC and FEC cases, frame_size - * must be a multiple of 2.5 ms. - * @param decode_fec int: Flag (0 or 1) to request that any in-band - * forward error correction data be decoded. - * If no such data is available, the frame is - * decoded as if it were lost. - * @returns Number of samples decoded on success or a negative error code - * (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode( - OpusMSDecoder *st, - const unsigned char *data, - opus_int32 len, - opus_int16 *pcm, - int frame_size, - int decode_fec -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); - -/** Decode a multistream Opus packet with floating point output. - * @param st OpusMSDecoder*: Multistream decoder state. - * @param[in] data const unsigned char*: Input payload. - * Use a NULL - * pointer to indicate packet - * loss. - * @param len opus_int32: Number of bytes in payload. - * @param[out] pcm opus_int16*: Output signal, with interleaved - * samples. - * This must contain room for - * frame_size*channels - * samples. - * @param frame_size int: The number of samples per channel of - * available space in \a pcm. - * If this is less than the maximum packet duration - * (120 ms; 5760 for 48kHz), this function will not be capable - * of decoding some packets. In the case of PLC (data==NULL) - * or FEC (decode_fec=1), then frame_size needs to be exactly - * the duration of audio that is missing, otherwise the - * decoder will not be in the optimal state to decode the - * next incoming packet. For the PLC and FEC cases, frame_size - * must be a multiple of 2.5 ms. - * @param decode_fec int: Flag (0 or 1) to request that any in-band - * forward error correction data be decoded. - * If no such data is available, the frame is - * decoded as if it were lost. - * @returns Number of samples decoded on success or a negative error code - * (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float( - OpusMSDecoder *st, - const unsigned char *data, - opus_int32 len, - float *pcm, - int frame_size, - int decode_fec -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); - -/** Perform a CTL function on a multistream Opus decoder. - * - * Generally the request and subsequent arguments are generated by a - * convenience macro. - * @param st OpusMSDecoder*: Multistream decoder state. - * @param request This and all remaining parameters should be replaced by one - * of the convenience macros in @ref opus_genericctls, - * @ref opus_decoderctls, or @ref opus_multistream_ctls. - * @see opus_genericctls - * @see opus_decoderctls - * @see opus_multistream_ctls - */ -OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); - -/** Frees an OpusMSDecoder allocated by - * opus_multistream_decoder_create(). - * @param st OpusMSDecoder: Multistream decoder state to be freed. - */ -OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st); - -/**@}*/ - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* OPUS_MULTISTREAM_H */ diff --git a/Engine/lib/opus/include/opus_projection.h b/Engine/lib/opus/include/opus_projection.h deleted file mode 100644 index 9dabf4e85..000000000 --- a/Engine/lib/opus/include/opus_projection.h +++ /dev/null @@ -1,568 +0,0 @@ -/* Copyright (c) 2017 Google Inc. - Written by Andrew Allen */ -/* - 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. -*/ - -/** - * @file opus_projection.h - * @brief Opus projection reference API - */ - -#ifndef OPUS_PROJECTION_H -#define OPUS_PROJECTION_H - -#include "opus_multistream.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** @cond OPUS_INTERNAL_DOC */ - -/** These are the actual encoder and decoder CTL ID numbers. - * They should not be used directly by applications.c - * In general, SETs should be even and GETs should be odd.*/ -/**@{*/ -#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST 6001 -#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST 6003 -#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST 6005 -/**@}*/ - - -/** @endcond */ - -/** @defgroup opus_projection_ctls Projection specific encoder and decoder CTLs - * - * These are convenience macros that are specific to the - * opus_projection_encoder_ctl() and opus_projection_decoder_ctl() - * interface. - * The CTLs from @ref opus_genericctls, @ref opus_encoderctls, - * @ref opus_decoderctls, and @ref opus_multistream_ctls may be applied to a - * projection encoder or decoder as well. - */ -/**@{*/ - -/** Gets the gain (in dB. S7.8-format) of the demixing matrix from the encoder. - * @param[out] x opus_int32 *: Returns the gain (in dB. S7.8-format) - * of the demixing matrix. - * @hideinitializer - */ -#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST, __opus_check_int_ptr(x) - - -/** Gets the size in bytes of the demixing matrix from the encoder. - * @param[out] x opus_int32 *: Returns the size in bytes of the - * demixing matrix. - * @hideinitializer - */ -#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST, __opus_check_int_ptr(x) - - -/** Copies the demixing matrix to the supplied pointer location. - * @param[out] x unsigned char *: Returns the demixing matrix to the - * supplied pointer location. - * @param y opus_int32: The size in bytes of the reserved memory at the - * pointer location. - * @hideinitializer - */ -#define OPUS_PROJECTION_GET_DEMIXING_MATRIX(x,y) OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST, x, __opus_check_int(y) - - -/**@}*/ - -/** Opus projection encoder state. - * This contains the complete state of a projection Opus encoder. - * It is position independent and can be freely copied. - * @see opus_projection_ambisonics_encoder_create - */ -typedef struct OpusProjectionEncoder OpusProjectionEncoder; - - -/** Opus projection decoder state. - * This contains the complete state of a projection Opus decoder. - * It is position independent and can be freely copied. - * @see opus_projection_decoder_create - * @see opus_projection_decoder_init - */ -typedef struct OpusProjectionDecoder OpusProjectionDecoder; - - -/**\name Projection encoder functions */ -/**@{*/ - -/** Gets the size of an OpusProjectionEncoder structure. - * @param channels int: The total number of input channels to encode. - * This must be no more than 255. - * @param mapping_family int: The mapping family to use for selecting - * the appropriate projection. - * @returns The size in bytes on success, or a negative error code - * (see @ref opus_errorcodes) on error. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_ambisonics_encoder_get_size( - int channels, - int mapping_family -); - - -/** Allocates and initializes a projection encoder state. - * Call opus_projection_encoder_destroy() to release - * this object when finished. - * @param Fs opus_int32: Sampling rate of the input signal (in Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param channels int: Number of channels in the input signal. - * This must be at most 255. - * It may be greater than the number of - * coded channels (streams + - * coupled_streams). - * @param mapping_family int: The mapping family to use for selecting - * the appropriate projection. - * @param[out] streams int *: The total number of streams that will - * be encoded from the input. - * @param[out] coupled_streams int *: Number of coupled (2 channel) - * streams that will be encoded from the input. - * @param application int: The target encoder application. - * This must be one of the following: - *
    - *
    #OPUS_APPLICATION_VOIP
    - *
    Process signal for improved speech intelligibility.
    - *
    #OPUS_APPLICATION_AUDIO
    - *
    Favor faithfulness to the original input.
    - *
    #OPUS_APPLICATION_RESTRICTED_LOWDELAY
    - *
    Configure the minimum possible coding delay by disabling certain modes - * of operation.
    - *
    - * @param[out] error int *: Returns #OPUS_OK on success, or an error - * code (see @ref opus_errorcodes) on - * failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionEncoder *opus_projection_ambisonics_encoder_create( - opus_int32 Fs, - int channels, - int mapping_family, - int *streams, - int *coupled_streams, - int application, - int *error -) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5); - - -/** Initialize a previously allocated projection encoder state. - * The memory pointed to by \a st must be at least the size returned by - * opus_projection_ambisonics_encoder_get_size(). - * This is intended for applications which use their own allocator instead of - * malloc. - * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. - * @see opus_projection_ambisonics_encoder_create - * @see opus_projection_ambisonics_encoder_get_size - * @param st OpusProjectionEncoder*: Projection encoder state to initialize. - * @param Fs opus_int32: Sampling rate of the input signal (in Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param channels int: Number of channels in the input signal. - * This must be at most 255. - * It may be greater than the number of - * coded channels (streams + - * coupled_streams). - * @param streams int: The total number of streams to encode from the - * input. - * This must be no more than the number of channels. - * @param coupled_streams int: Number of coupled (2 channel) streams - * to encode. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * encoded channels (streams + - * coupled_streams) must be no - * more than the number of input channels. - * @param application int: The target encoder application. - * This must be one of the following: - *
    - *
    #OPUS_APPLICATION_VOIP
    - *
    Process signal for improved speech intelligibility.
    - *
    #OPUS_APPLICATION_AUDIO
    - *
    Favor faithfulness to the original input.
    - *
    #OPUS_APPLICATION_RESTRICTED_LOWDELAY
    - *
    Configure the minimum possible coding delay by disabling certain modes - * of operation.
    - *
    - * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) - * on failure. - */ -OPUS_EXPORT int opus_projection_ambisonics_encoder_init( - OpusProjectionEncoder *st, - opus_int32 Fs, - int channels, - int mapping_family, - int *streams, - int *coupled_streams, - int application -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6); - - -/** Encodes a projection Opus frame. - * @param st OpusProjectionEncoder*: Projection encoder state. - * @param[in] pcm const opus_int16*: The input signal as interleaved - * samples. - * This must contain - * frame_size*channels - * samples. - * @param frame_size int: Number of samples per channel in the input - * signal. - * This must be an Opus frame size for the - * encoder's sampling rate. - * For example, at 48 kHz the permitted values - * are 120, 240, 480, 960, 1920, and 2880. - * Passing in a duration of less than 10 ms - * (480 samples at 48 kHz) will prevent the - * encoder from using the LPC or hybrid modes. - * @param[out] data unsigned char*: Output payload. - * This must contain storage for at - * least \a max_data_bytes. - * @param [in] max_data_bytes opus_int32: Size of the allocated - * memory for the output - * payload. This may be - * used to impose an upper limit on - * the instant bitrate, but should - * not be used as the only bitrate - * control. Use #OPUS_SET_BITRATE to - * control the bitrate. - * @returns The length of the encoded packet (in bytes) on success or a - * negative error code (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode( - OpusProjectionEncoder *st, - const opus_int16 *pcm, - int frame_size, - unsigned char *data, - opus_int32 max_data_bytes -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); - - -/** Encodes a projection Opus frame from floating point input. - * @param st OpusProjectionEncoder*: Projection encoder state. - * @param[in] pcm const float*: The input signal as interleaved - * samples with a normal range of - * +/-1.0. - * Samples with a range beyond +/-1.0 - * are supported but will be clipped by - * decoders using the integer API and - * should only be used if it is known - * that the far end supports extended - * dynamic range. - * This must contain - * frame_size*channels - * samples. - * @param frame_size int: Number of samples per channel in the input - * signal. - * This must be an Opus frame size for the - * encoder's sampling rate. - * For example, at 48 kHz the permitted values - * are 120, 240, 480, 960, 1920, and 2880. - * Passing in a duration of less than 10 ms - * (480 samples at 48 kHz) will prevent the - * encoder from using the LPC or hybrid modes. - * @param[out] data unsigned char*: Output payload. - * This must contain storage for at - * least \a max_data_bytes. - * @param [in] max_data_bytes opus_int32: Size of the allocated - * memory for the output - * payload. This may be - * used to impose an upper limit on - * the instant bitrate, but should - * not be used as the only bitrate - * control. Use #OPUS_SET_BITRATE to - * control the bitrate. - * @returns The length of the encoded packet (in bytes) on success or a - * negative error code (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode_float( - OpusProjectionEncoder *st, - const float *pcm, - int frame_size, - unsigned char *data, - opus_int32 max_data_bytes -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); - - -/** Frees an OpusProjectionEncoder allocated by - * opus_projection_ambisonics_encoder_create(). - * @param st OpusProjectionEncoder*: Projection encoder state to be freed. - */ -OPUS_EXPORT void opus_projection_encoder_destroy(OpusProjectionEncoder *st); - - -/** Perform a CTL function on a projection Opus encoder. - * - * Generally the request and subsequent arguments are generated by a - * convenience macro. - * @param st OpusProjectionEncoder*: Projection encoder state. - * @param request This and all remaining parameters should be replaced by one - * of the convenience macros in @ref opus_genericctls, - * @ref opus_encoderctls, @ref opus_multistream_ctls, or - * @ref opus_projection_ctls - * @see opus_genericctls - * @see opus_encoderctls - * @see opus_multistream_ctls - * @see opus_projection_ctls - */ -OPUS_EXPORT int opus_projection_encoder_ctl(OpusProjectionEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); - - -/**@}*/ - -/**\name Projection decoder functions */ -/**@{*/ - -/** Gets the size of an OpusProjectionDecoder structure. - * @param channels int: The total number of output channels. - * This must be no more than 255. - * @param streams int: The total number of streams coded in the - * input. - * This must be no more than 255. - * @param coupled_streams int: Number streams to decode as coupled - * (2 channel) streams. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * coded channels (streams + - * coupled_streams) must be no - * more than 255. - * @returns The size in bytes on success, or a negative error code - * (see @ref opus_errorcodes) on error. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_decoder_get_size( - int channels, - int streams, - int coupled_streams -); - - -/** Allocates and initializes a projection decoder state. - * Call opus_projection_decoder_destroy() to release - * this object when finished. - * @param Fs opus_int32: Sampling rate to decode at (in Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param channels int: Number of channels to output. - * This must be at most 255. - * It may be different from the number of coded - * channels (streams + - * coupled_streams). - * @param streams int: The total number of streams coded in the - * input. - * This must be no more than 255. - * @param coupled_streams int: Number of streams to decode as coupled - * (2 channel) streams. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * coded channels (streams + - * coupled_streams) must be no - * more than 255. - * @param[in] demixing_matrix const unsigned char[demixing_matrix_size]: Demixing matrix - * that mapping from coded channels to output channels, - * as described in @ref opus_projection and - * @ref opus_projection_ctls. - * @param demixing_matrix_size opus_int32: The size in bytes of the - * demixing matrix, as - * described in @ref - * opus_projection_ctls. - * @param[out] error int *: Returns #OPUS_OK on success, or an error - * code (see @ref opus_errorcodes) on - * failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionDecoder *opus_projection_decoder_create( - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - unsigned char *demixing_matrix, - opus_int32 demixing_matrix_size, - int *error -) OPUS_ARG_NONNULL(5); - - -/** Intialize a previously allocated projection decoder state object. - * The memory pointed to by \a st must be at least the size returned by - * opus_projection_decoder_get_size(). - * This is intended for applications which use their own allocator instead of - * malloc. - * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. - * @see opus_projection_decoder_create - * @see opus_projection_deocder_get_size - * @param st OpusProjectionDecoder*: Projection encoder state to initialize. - * @param Fs opus_int32: Sampling rate to decode at (in Hz). - * This must be one of 8000, 12000, 16000, - * 24000, or 48000. - * @param channels int: Number of channels to output. - * This must be at most 255. - * It may be different from the number of coded - * channels (streams + - * coupled_streams). - * @param streams int: The total number of streams coded in the - * input. - * This must be no more than 255. - * @param coupled_streams int: Number of streams to decode as coupled - * (2 channel) streams. - * This must be no larger than the total - * number of streams. - * Additionally, The total number of - * coded channels (streams + - * coupled_streams) must be no - * more than 255. - * @param[in] demixing_matrix const unsigned char[demixing_matrix_size]: Demixing matrix - * that mapping from coded channels to output channels, - * as described in @ref opus_projection and - * @ref opus_projection_ctls. - * @param demixing_matrix_size opus_int32: The size in bytes of the - * demixing matrix, as - * described in @ref - * opus_projection_ctls. - * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) - * on failure. - */ -OPUS_EXPORT int opus_projection_decoder_init( - OpusProjectionDecoder *st, - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - unsigned char *demixing_matrix, - opus_int32 demixing_matrix_size -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); - - -/** Decode a projection Opus packet. - * @param st OpusProjectionDecoder*: Projection decoder state. - * @param[in] data const unsigned char*: Input payload. - * Use a NULL - * pointer to indicate packet - * loss. - * @param len opus_int32: Number of bytes in payload. - * @param[out] pcm opus_int16*: Output signal, with interleaved - * samples. - * This must contain room for - * frame_size*channels - * samples. - * @param frame_size int: The number of samples per channel of - * available space in \a pcm. - * If this is less than the maximum packet duration - * (120 ms; 5760 for 48kHz), this function will not be capable - * of decoding some packets. In the case of PLC (data==NULL) - * or FEC (decode_fec=1), then frame_size needs to be exactly - * the duration of audio that is missing, otherwise the - * decoder will not be in the optimal state to decode the - * next incoming packet. For the PLC and FEC cases, frame_size - * must be a multiple of 2.5 ms. - * @param decode_fec int: Flag (0 or 1) to request that any in-band - * forward error correction data be decoded. - * If no such data is available, the frame is - * decoded as if it were lost. - * @returns Number of samples decoded on success or a negative error code - * (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode( - OpusProjectionDecoder *st, - const unsigned char *data, - opus_int32 len, - opus_int16 *pcm, - int frame_size, - int decode_fec -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); - - -/** Decode a projection Opus packet with floating point output. - * @param st OpusProjectionDecoder*: Projection decoder state. - * @param[in] data const unsigned char*: Input payload. - * Use a NULL - * pointer to indicate packet - * loss. - * @param len opus_int32: Number of bytes in payload. - * @param[out] pcm opus_int16*: Output signal, with interleaved - * samples. - * This must contain room for - * frame_size*channels - * samples. - * @param frame_size int: The number of samples per channel of - * available space in \a pcm. - * If this is less than the maximum packet duration - * (120 ms; 5760 for 48kHz), this function will not be capable - * of decoding some packets. In the case of PLC (data==NULL) - * or FEC (decode_fec=1), then frame_size needs to be exactly - * the duration of audio that is missing, otherwise the - * decoder will not be in the optimal state to decode the - * next incoming packet. For the PLC and FEC cases, frame_size - * must be a multiple of 2.5 ms. - * @param decode_fec int: Flag (0 or 1) to request that any in-band - * forward error correction data be decoded. - * If no such data is available, the frame is - * decoded as if it were lost. - * @returns Number of samples decoded on success or a negative error code - * (see @ref opus_errorcodes) on failure. - */ -OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode_float( - OpusProjectionDecoder *st, - const unsigned char *data, - opus_int32 len, - float *pcm, - int frame_size, - int decode_fec -) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); - - -/** Perform a CTL function on a projection Opus decoder. - * - * Generally the request and subsequent arguments are generated by a - * convenience macro. - * @param st OpusProjectionDecoder*: Projection decoder state. - * @param request This and all remaining parameters should be replaced by one - * of the convenience macros in @ref opus_genericctls, - * @ref opus_decoderctls, @ref opus_multistream_ctls, or - * @ref opus_projection_ctls. - * @see opus_genericctls - * @see opus_decoderctls - * @see opus_multistream_ctls - * @see opus_projection_ctls - */ -OPUS_EXPORT int opus_projection_decoder_ctl(OpusProjectionDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); - - -/** Frees an OpusProjectionDecoder allocated by - * opus_projection_decoder_create(). - * @param st OpusProjectionDecoder: Projection decoder state to be freed. - */ -OPUS_EXPORT void opus_projection_decoder_destroy(OpusProjectionDecoder *st); - - -/**@}*/ - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* OPUS_PROJECTION_H */ diff --git a/Engine/lib/opus/include/opus_types.h b/Engine/lib/opus/include/opus_types.h deleted file mode 100644 index 7cf675580..000000000 --- a/Engine/lib/opus/include/opus_types.h +++ /dev/null @@ -1,166 +0,0 @@ -/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */ -/* Modified 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. -*/ -/* opus_types.h based on ogg_types.h from libogg */ - -/** - @file opus_types.h - @brief Opus reference implementation types -*/ -#ifndef OPUS_TYPES_H -#define OPUS_TYPES_H - -#define opus_int int /* used for counters etc; at least 16 bits */ -#define opus_int64 long long -#define opus_int8 signed char - -#define opus_uint unsigned int /* used for counters etc; at least 16 bits */ -#define opus_uint64 unsigned long long -#define opus_uint8 unsigned char - -/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */ -#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) -#include -# undef opus_int64 -# undef opus_int8 -# undef opus_uint64 -# undef opus_uint8 - typedef int8_t opus_int8; - typedef uint8_t opus_uint8; - typedef int16_t opus_int16; - typedef uint16_t opus_uint16; - typedef int32_t opus_int32; - typedef uint32_t opus_uint32; - typedef int64_t opus_int64; - typedef uint64_t opus_uint64; -#elif defined(_WIN32) - -# if defined(__CYGWIN__) -# include <_G_config.h> - typedef _G_int32_t opus_int32; - typedef _G_uint32_t opus_uint32; - typedef _G_int16 opus_int16; - typedef _G_uint16 opus_uint16; -# elif defined(__MINGW32__) - typedef short opus_int16; - typedef unsigned short opus_uint16; - typedef int opus_int32; - typedef unsigned int opus_uint32; -# elif defined(__MWERKS__) - typedef int opus_int32; - typedef unsigned int opus_uint32; - typedef short opus_int16; - typedef unsigned short opus_uint16; -# else - /* MSVC/Borland */ - typedef __int32 opus_int32; - typedef unsigned __int32 opus_uint32; - typedef __int16 opus_int16; - typedef unsigned __int16 opus_uint16; -# endif - -#elif defined(__MACOS__) - -# include - typedef SInt16 opus_int16; - typedef UInt16 opus_uint16; - typedef SInt32 opus_int32; - typedef UInt32 opus_uint32; - -#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ - -# include - typedef int16_t opus_int16; - typedef u_int16_t opus_uint16; - typedef int32_t opus_int32; - typedef u_int32_t opus_uint32; - -#elif defined(__BEOS__) - - /* Be */ -# include - typedef int16 opus_int16; - typedef u_int16 opus_uint16; - typedef int32_t opus_int32; - typedef u_int32_t opus_uint32; - -#elif defined (__EMX__) - - /* OS/2 GCC */ - typedef short opus_int16; - typedef unsigned short opus_uint16; - typedef int opus_int32; - typedef unsigned int opus_uint32; - -#elif defined (DJGPP) - - /* DJGPP */ - typedef short opus_int16; - typedef unsigned short opus_uint16; - typedef int opus_int32; - typedef unsigned int opus_uint32; - -#elif defined(R5900) - - /* PS2 EE */ - typedef int opus_int32; - typedef unsigned opus_uint32; - typedef short opus_int16; - typedef unsigned short opus_uint16; - -#elif defined(__SYMBIAN32__) - - /* Symbian GCC */ - typedef signed short opus_int16; - typedef unsigned short opus_uint16; - typedef signed int opus_int32; - typedef unsigned int opus_uint32; - -#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) - - typedef short opus_int16; - typedef unsigned short opus_uint16; - typedef long opus_int32; - typedef unsigned long opus_uint32; - -#elif defined(CONFIG_TI_C6X) - - typedef short opus_int16; - typedef unsigned short opus_uint16; - typedef int opus_int32; - typedef unsigned int opus_uint32; - -#else - - /* Give up, take a reasonable guess */ - typedef short opus_int16; - typedef unsigned short opus_uint16; - typedef int opus_int32; - typedef unsigned int opus_uint32; - -#endif - -#endif /* OPUS_TYPES_H */ diff --git a/Engine/lib/opus/m4/as-gcc-inline-assembly.m4 b/Engine/lib/opus/m4/as-gcc-inline-assembly.m4 deleted file mode 100644 index b0d2da414..000000000 --- a/Engine/lib/opus/m4/as-gcc-inline-assembly.m4 +++ /dev/null @@ -1,98 +0,0 @@ -dnl as-gcc-inline-assembly.m4 0.1.0 - -dnl autostars m4 macro for detection of gcc inline assembly - -dnl David Schleef - -dnl AS_COMPILER_FLAG(ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) -dnl Tries to compile with the given CFLAGS. -dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, -dnl and ACTION-IF-NOT-ACCEPTED otherwise. - -AC_DEFUN([AS_GCC_INLINE_ASSEMBLY], -[ - AC_MSG_CHECKING([if compiler supports gcc-style inline assembly]) - - AC_TRY_COMPILE([], [ -#ifdef __GNUC_MINOR__ -#if (__GNUC__ * 1000 + __GNUC_MINOR__) < 3004 -#error GCC before 3.4 has critical bugs compiling inline assembly -#endif -#endif -__asm__ (""::) ], [flag_ok=yes], [flag_ok=no]) - - if test "X$flag_ok" = Xyes ; then - $1 - true - else - $2 - true - fi - AC_MSG_RESULT([$flag_ok]) -]) - -AC_DEFUN([AS_ASM_ARM_NEON], -[ - AC_MSG_CHECKING([if assembler supports NEON instructions on ARM]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__("vorr d0,d0,d0")])], - [AC_MSG_RESULT([yes]) - $1], - [AC_MSG_RESULT([no]) - $2]) -]) - -AC_DEFUN([AS_ASM_ARM_NEON_FORCE], -[ - AC_MSG_CHECKING([if assembler supports NEON instructions on ARM]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__(".arch armv7-a\n.fpu neon\n.object_arch armv4t\nvorr d0,d0,d0")])], - [AC_MSG_RESULT([yes]) - $1], - [AC_MSG_RESULT([no]) - $2]) -]) - -AC_DEFUN([AS_ASM_ARM_MEDIA], -[ - AC_MSG_CHECKING([if assembler supports ARMv6 media instructions on ARM]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__("shadd8 r3,r3,r3")])], - [AC_MSG_RESULT([yes]) - $1], - [AC_MSG_RESULT([no]) - $2]) -]) - -AC_DEFUN([AS_ASM_ARM_MEDIA_FORCE], -[ - AC_MSG_CHECKING([if assembler supports ARMv6 media instructions on ARM]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__(".arch armv6\n.object_arch armv4t\nshadd8 r3,r3,r3")])], - [AC_MSG_RESULT([yes]) - $1], - [AC_MSG_RESULT([no]) - $2]) -]) - -AC_DEFUN([AS_ASM_ARM_EDSP], -[ - AC_MSG_CHECKING([if assembler supports EDSP instructions on ARM]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__("qadd r3,r3,r3")])], - [AC_MSG_RESULT([yes]) - $1], - [AC_MSG_RESULT([no]) - $2]) -]) - -AC_DEFUN([AS_ASM_ARM_EDSP_FORCE], -[ - AC_MSG_CHECKING([if assembler supports EDSP instructions on ARM]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[__asm__(".arch armv5te\n.object_arch armv4t\nqadd r3,r3,r3")])], - [AC_MSG_RESULT([yes]) - $1], - [AC_MSG_RESULT([no]) - $2]) -]) diff --git a/Engine/lib/opus/m4/ax_add_fortify_source.m4 b/Engine/lib/opus/m4/ax_add_fortify_source.m4 deleted file mode 100644 index 1c89e4108..000000000 --- a/Engine/lib/opus/m4/ax_add_fortify_source.m4 +++ /dev/null @@ -1,53 +0,0 @@ -# =========================================================================== -# Modified from https://www.gnu.org/software/autoconf-archive/ax_add_fortify_source.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_ADD_FORTIFY_SOURCE -# -# DESCRIPTION -# -# Check whether -D_FORTIFY_SOURCE=2 can be added to CFLAGS without macro -# redefinition warnings. Some distributions (such as Gentoo Linux) enable -# _FORTIFY_SOURCE globally in their compilers, leading to unnecessary -# warnings in the form of -# -# :0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] -# : note: this is the location of the previous definition -# -# which is a problem if -Werror is enabled. This macro checks whether -# _FORTIFY_SOURCE is already defined, and if not, adds -D_FORTIFY_SOURCE=2 -# to CFLAGS. -# -# LICENSE -# -# Copyright (c) 2017 David Seifert -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 1 - -AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[ - AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CFLAGS]) - AC_LINK_IFELSE([ - AC_LANG_SOURCE( - [[ - int main() { - #ifndef _FORTIFY_SOURCE - return 0; - #else - this_is_an_error; - #endif - } - ]] - )], [ - AC_MSG_RESULT([yes]) - CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2" - ], [ - AC_MSG_RESULT([no]) - ]) -]) diff --git a/Engine/lib/opus/m4/opus-intrinsics.m4 b/Engine/lib/opus/m4/opus-intrinsics.m4 deleted file mode 100644 index a262ca181..000000000 --- a/Engine/lib/opus/m4/opus-intrinsics.m4 +++ /dev/null @@ -1,29 +0,0 @@ -dnl opus-intrinsics.m4 -dnl macro for testing for support for compiler intrinsics, either by default or with a compiler flag - -dnl OPUS_CHECK_INTRINSICS(NAME-OF-INTRINSICS, COMPILER-FLAG-FOR-INTRINSICS, VAR-IF-PRESENT, VAR-IF-DEFAULT, TEST-PROGRAM-HEADER, TEST-PROGRAM-BODY) -AC_DEFUN([OPUS_CHECK_INTRINSICS], -[ - AC_MSG_CHECKING([if compiler supports $1 intrinsics]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM($5, $6)], - [ - $3=1 - $4=1 - AC_MSG_RESULT([yes]) - ],[ - $4=0 - AC_MSG_RESULT([no]) - AC_MSG_CHECKING([if compiler supports $1 intrinsics with $2]) - save_CFLAGS="$CFLAGS"; CFLAGS="$CFLAGS $2" - AC_LINK_IFELSE([AC_LANG_PROGRAM($5, $6)], - [ - AC_MSG_RESULT([yes]) - $3=1 - ],[ - AC_MSG_RESULT([no]) - $3=0 - ]) - CFLAGS="$save_CFLAGS" - ]) -]) diff --git a/Engine/lib/opus/meson.build b/Engine/lib/opus/meson.build deleted file mode 100644 index ed66d3807..000000000 --- a/Engine/lib/opus/meson.build +++ /dev/null @@ -1,675 +0,0 @@ -project('opus', 'c', - version: run_command('meson/get-version.py', '--package-version', check: true).stdout().strip(), - meson_version: '>=0.54.0', - default_options: ['warning_level=2', - 'c_std=gnu99', - 'buildtype=debugoptimized']) - -libversion = run_command('meson/get-version.py', '--libtool-version', check: true).stdout().strip() -macosversion = run_command('meson/get-version.py', '--darwin-version', check: true).stdout().strip() - -cc = meson.get_compiler('c') -host_system = host_machine.system() -host_cpu_family = host_machine.cpu_family() -top_srcdir = meson.current_source_dir() -top_builddir = meson.current_build_dir() - -opus_includes = include_directories('.', 'include', 'celt', 'silk') -opus_public_includes = include_directories('include') - -add_project_arguments('-DOPUS_BUILD', language: 'c') -add_project_arguments('-DHAVE_CONFIG_H', language: 'c') - -if host_system == 'windows' - if cc.get_argument_syntax() == 'msvc' - add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c') - endif -endif - -if cc.get_argument_syntax() == 'gnu' - add_project_arguments('-D_FORTIFY_SOURCE=2', language: 'c') -endif - -# Check for extra compiler args -additional_c_args = [] -if cc.get_argument_syntax() != 'msvc' - additional_c_args += [ - '-fvisibility=hidden', - '-Wcast-align', - '-Wnested-externs', - '-Wshadow', - '-Wstrict-prototypes', - ] - - # On Windows, -fstack-protector-strong adds a libssp-0.dll dependency and - # prevents static linking - if host_system != 'windows' - additional_c_args += ['-fstack-protector-strong'] - endif -endif - -foreach arg : additional_c_args - if cc.has_argument(arg) - add_project_arguments(arg, language: 'c') - endif -endforeach - -# Windows MSVC warnings -if cc.get_id() == 'msvc' - # Ignore several spurious warnings. - # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it - # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once - # NOTE: Only add warnings here if you are sure they're spurious - add_project_arguments('/wd4035', '/wd4715', '/wd4116', '/wd4046', '/wd4068', - '/wd4820', '/wd4244', '/wd4255', '/wd4668', - language : 'c') -endif - -opus_version = meson.project_version() - -opus_conf = configuration_data() -opus_conf.set('PACKAGE_BUGREPORT', '"opus@xiph.org"') -opus_conf.set('PACKAGE_NAME', '"opus"') -opus_conf.set('PACKAGE_STRING', '"opus @0@"'.format(opus_version)) -opus_conf.set('PACKAGE_TARNAME', '"opus"') -opus_conf.set('PACKAGE_URL', '""') -opus_conf.set('PACKAGE_VERSION', '"@0@"'.format(opus_version)) - -# FIXME: optional Ne10 dependency -have_arm_ne10 = false - -libm = cc.find_library('m', required : false) - -opus_conf.set('HAVE_LRINTF', cc.has_function('lrintf', prefix: '#include ', dependencies: libm)) -opus_conf.set('HAVE_LRINT', cc.has_function('lrint', prefix: '#include ', dependencies: libm)) -opus_conf.set('HAVE___MALLOC_HOOK', cc.has_function('__malloc_hook', prefix: '#include ')) -opus_conf.set('HAVE_STDINT_H', cc.check_header('stdint.h')) - -# Check for restrict keyword -restrict_tmpl = ''' -typedef int * int_ptr; -int foo (int_ptr @0@ ip, int * @0@ baz[]) { - return ip[0]; -} -int main (int argc, char ** argv) { - int s[1]; - int * @0@ t = s; - t[0] = 0; - return foo(t, (void *)0); -}''' -# Define restrict to the equivalent of the C99 restrict keyword, or to -# nothing if this is not supported. Do not define if restrict is -# supported directly. -if not cc.compiles(restrict_tmpl.format('restrict'), name : 'restrict keyword') - if cc.compiles(restrict_tmpl.format('__restrict'), name : '__restrict') - opus_conf.set('restrict', '__restrict') - elif cc.compiles(restrict_tmpl.format('__restrict__'), name : '__restrict__') - opus_conf.set('restrict', '__restrict') - elif cc.compiles(restrict_tmpl.format('_Restrict'), name : '_Restrict') - opus_conf.set('restrict', '_Restrict') - else - opus_conf.set('restrict', '/**/') - endif -endif - -# Check for C99 variable-size arrays, or alloca() as fallback -msg_use_alloca = false -if cc.compiles('''static int x; - char some_func (void) { - char a[++x]; - a[sizeof a - 1] = 0; - int N; - return a[0]; - }''', name : 'C99 variable-size arrays') - opus_conf.set('VAR_ARRAYS', 1) - msg_use_alloca = 'NO (using C99 variable-size arrays instead)' -elif cc.compiles('''#include - void some_func (void) { - int foo=10; - int * array = alloca(foo); - }''', name : 'alloca (alloca.h)') - opus_conf.set('USE_ALLOCA', true) - opus_conf.set('HAVE_ALLOCA_H', true) - msg_use_alloca = true -elif cc.compiles('''#include - #include - void some_func (void) { - int foo=10; - int * array = alloca(foo); - }''', name : 'alloca (std)') - opus_conf.set('USE_ALLOCA', true) - msg_use_alloca = true -endif - -opts = [ - [ 'fixed-point', 'FIXED_POINT' ], - [ 'fixed-point-debug', 'FIXED_DEBUG' ], - [ 'custom-modes', 'CUSTOM_MODES' ], - [ 'float-approx', 'FLOAT_APPROX' ], - [ 'assertions', 'ENABLE_ASSERTIONS' ], - [ 'hardening', 'ENABLE_HARDENING' ], - [ 'fuzzing', 'FUZZING' ], - [ 'check-asm', 'OPUS_CHECK_ASM' ], -] - -foreach opt : opts - # we assume these are all boolean options - opt_foo = get_option(opt[0]) - if opt_foo - opus_conf.set(opt[1], 1) - endif - set_variable('opt_' + opt[0].underscorify(), opt_foo) -endforeach - -opt_asm = get_option('asm') -opt_rtcd = get_option('rtcd') -opt_intrinsics = get_option('intrinsics') -extra_programs = get_option('extra-programs') -opt_tests = get_option('tests') - -disable_float_api = not get_option('float-api') -if disable_float_api - opus_conf.set('DISABLE_FLOAT_API', 1) -endif - -# This is for the description in the pkg-config .pc file -if opt_fixed_point - pc_build = 'fixed-point' -else - pc_build = 'floating-point' -endif -if opt_custom_modes - pc_build = pc_build + ', custom modes' -endif - -rtcd_support = [] -# With GCC, Clang, ICC, etc, we differentiate between 'may support this SIMD' -# and 'presume we have this SIMD' by checking whether the SIMD / intrinsics can -# be compiled by the compiler as-is (presume) or with SIMD cflags (may have). -# With MSVC, the compiler will always build SIMD/intrinsics targeting all -# specific instruction sets supported by that version of the compiler. No -# special arguments are ever needed. If runtime CPU detection is not disabled, -# we must always assume that we only 'may have' it. -opus_can_presume_simd = true -if cc.get_argument_syntax() == 'msvc' - if opt_rtcd.disabled() - warning('Building with an MSVC-like compiler and runtime CPU detection is disabled. Outputs may not run on all @0@ CPUs.'.format(host_cpu_family)) - else - opus_can_presume_simd = false - endif -endif - -opus_arm_external_asm = false - -asm_tmpl = ''' -int main (int argc, char ** argv) { - __asm__("@0@"); - return 0; -}''' - -asm_optimization = [] -inline_optimization = [] -if not opt_asm.disabled() - # Currently we only have inline asm for fixed-point - if host_cpu_family == 'arm' and opt_fixed_point - opus_conf.set('OPUS_ARM_ASM', true) - - # Check if compiler supports gcc-style inline assembly - if cc.compiles('''#ifdef __GNUC_MINOR__ - #if (__GNUC__ * 1000 + __GNUC_MINOR__) < 3004 - #error GCC before 3.4 has critical bugs compiling inline assembly - #endif - #endif - __asm__ (""::)''', - name : 'compiler supports gcc-style inline assembly') - - opus_conf.set('OPUS_ARM_INLINE_ASM', 1) - - # AS_ASM_ARM_EDSP - if cc.compiles(asm_tmpl.format('qadd r3,r3,r3'), - name : 'assembler supports EDSP instructions on ARM') - opus_conf.set('OPUS_ARM_INLINE_EDSP', 1) - inline_optimization += ['ESDP'] - endif - - # AS_ASM_ARM_MEDIA - if cc.compiles(asm_tmpl.format('shadd8 r3,r3,r3'), - name : 'assembler supports ARMv6 media instructions on ARM') - opus_conf.set('OPUS_ARM_INLINE_MEDIA', 1) - inline_optimization += ['Media'] - endif - - # AS_ASM_ARM_NEON - if cc.compiles(asm_tmpl.format('vorr d0,d0,d0'), - name : 'assembler supports NEON instructions on ARM') - opus_conf.set('OPUS_ARM_INLINE_NEON', 1) - inline_optimization += ['NEON'] - endif - endif - - # We need Perl to translate RVCT-syntax asm to gas syntax - perl = find_program('perl', required: get_option('asm')) - if perl.found() - opus_arm_external_asm = true - # opus_arm_presume_* mean we can and will use those instructions - # directly without doing runtime CPU detection. - # opus_arm_may_have_* mean we can emit those instructions, but we can - # only use them after runtime detection. - # The same rules apply for x86 assembly and intrinsics. - - opus_arm_may_have_edsp = opus_conf.has('OPUS_ARM_INLINE_EDSP') - opus_arm_presume_edsp = opus_arm_may_have_edsp and opus_can_presume_simd - - opus_arm_may_have_media = opus_conf.has('OPUS_ARM_INLINE_MEDIA') - opus_arm_presume_media = opus_arm_may_have_media and opus_can_presume_simd - - opus_arm_may_have_neon = opus_conf.has('OPUS_ARM_INLINE_NEON') - opus_arm_presume_neon = opus_arm_may_have_neon and opus_can_presume_simd - - if not opt_rtcd.disabled() - if not opus_arm_may_have_edsp - message('Trying to force-enable armv5e EDSP instructions...') - # AS_ASM_ARM_EDSP_FORCE - opus_arm_may_have_edsp = cc.compiles(asm_tmpl.format('.arch armv5te\n.object_arch armv4t\nqadd r3,r3,r3'), - name : 'Assembler supports EDSP instructions on ARM (forced)') - endif - if not opus_arm_may_have_media - message('Trying to force-enable ARMv6 media instructions...') - opus_arm_may_have_media = cc.compiles(asm_tmpl.format('.arch armv6\n.object_arch armv4t\nshadd8 r3,r3,r3'), - name : 'Assembler supports ARMv6 media instructions on ARM (forced)') - endif - if not opus_arm_may_have_neon - message('Trying to force-enable NEON instructions...') - opus_arm_may_have_neon = cc.compiles(asm_tmpl.format('.arch armv7-a\n.fpu neon\n.object_arch armv4t\nvorr d0,d0,d0'), - name : 'Assembler supports NEON instructions on ARM (forced)') - endif - endif - - if opus_arm_may_have_edsp - opus_conf.set('OPUS_ARM_MAY_HAVE_EDSP', 1) - if opus_arm_presume_edsp - opus_conf.set('OPUS_ARM_PRESUME_EDSP', 1) - asm_optimization += ['EDSP'] - else - rtcd_support += ['EDSP'] - endif - endif - if opus_arm_may_have_media - opus_conf.set('OPUS_ARM_MAY_HAVE_MEDIA', 1) - if opus_arm_presume_media - opus_conf.set('OPUS_ARM_PRESUME_MEDIA', 1) - asm_optimization += ['Media'] - else - rtcd_support += ['Media'] - endif - endif - if opus_arm_may_have_neon - opus_conf.set('OPUS_ARM_MAY_HAVE_NEON', 1) - if opus_arm_presume_neon - opus_conf.set('OPUS_ARM_PRESUME_NEON', 1) - asm_optimization += ['NEON'] - else - rtcd_support += ['NEON'] - endif - endif - - if cc.get_define('__APPLE__') - arm2gnu_args = ['--apple'] - else - arm2gnu_args = [] - endif - endif # found perl - else # arm + enable fixed point - if opt_asm.enabled() - error('asm option is enabled, but no assembly support for ' + host_cpu_family) - endif - endif -endif # enable asm - -# Check whether we require assembly and we support assembly on this arch, -# but none were detected. Can happen because of incorrect compiler flags, such -# as missing -mfloat-abi=softfp on ARM32 softfp architectures. -if opt_asm.enabled() and (asm_optimization.length() + inline_optimization.length()) == 0 - error('asm option was enabled, but no assembly support was detected') -endif - -# XXX: NEON has hardfp vs softfp compiler configuration issues -# When targeting ARM32 softfp, we sometimes need to explicitly pass -# -mfloat-abi=softfp to enable NEON. F.ex., on Android. It should -# be set in the cross file. -arm_neon_intr_link_args = ['-mfpu=neon'] - -have_sse = false -have_sse2 = false -have_sse4_1 = false -have_avx = false # no avx opus code yet -have_neon_intr = false - -intrinsics_support = [] -if not opt_intrinsics.disabled() - if host_cpu_family in ['arm', 'aarch64'] - # Check for ARMv7/AArch64 neon intrinsics - intrin_check = ''' - #include - int main (void) { - static float32x4_t A0, A1, SUMM; - SUMM = vmlaq_f32(SUMM, A0, A1); - return (int)vgetq_lane_f32(SUMM, 0); - }''' - intrin_name = 'ARMv7/AArch64 NEON' - if cc.links(intrin_check, - name: 'compiler supports @0@ intrinsics'.format(intrin_name)) - opus_arm_presume_neon_intr = opus_can_presume_simd - opus_arm_may_have_neon_intr = true - else - opus_arm_presume_neon_intr = false - if cc.links(intrin_check, - args: arm_neon_intr_link_args, - name: 'compiler supports @0@ intrinsics with @1@'.format(intrin_name, ' '.join(arm_neon_intr_link_args))) - opus_arm_may_have_neon_intr = true - else - opus_arm_may_have_neon_intr = false - endif - endif - - if opus_arm_may_have_neon_intr - have_neon_intr = true - intrinsics_support += [intrin_name] - opus_conf.set('OPUS_ARM_MAY_HAVE_NEON_INTR', 1) - if opus_arm_presume_neon_intr - opus_conf.set('OPUS_ARM_PRESUME_NEON_INTR', 1) - else - rtcd_support += [intrin_name] - opus_neon_intr_args = arm_neon_intr_link_args - endif - else - message('Compiler does not support @0@ intrinsics'.format(intrin_name)) - endif - - # Check for aarch64 neon intrinsics - intrin_check = ''' - #include - int main (void) { - static int32_t IN; - static int16_t OUT; - OUT = vqmovns_s32(IN); - }''' - intrin_name = 'AArch64 NEON' - if cc.links(intrin_check, - name: 'compiler supports @0@ intrinsics'.format(intrin_name)) - opus_arm_presume_aarch64_neon_intr = opus_can_presume_simd - opus_arm_may_have_aarch64_neon_intr = true - else - opus_arm_presume_aarch64_neon_intr = false - if cc.links(intrin_check, - args: arm_neon_intr_link_args, - name: 'compiler supports @0@ intrinsics with @1@'.format(intrin_name, ' '.join(arm_neon_intr_link_args))) - opus_arm_may_have_aarch64_neon_intr = true - else - opus_arm_may_have_aarch64_neon_intr = false - endif - endif - - if opus_arm_may_have_aarch64_neon_intr - intrinsics_support += [intrin_name] - opus_conf.set('OPUS_X86_MAY_HAVE_AARCH64_NEON_INTR', 1) - if opus_arm_presume_aarch64_neon_intr - opus_conf.set('OPUS_X86_PRESUME_AARCH64_NEON_INTR', 1) - endif - else - message('Compiler does not support @0@ intrinsics'.format(intrin_name)) - endif - elif host_cpu_family in ['x86', 'x86_64'] - # XXX: allow external override/specification of the flags - x86_intrinsics = [ - [ 'SSE', 'xmmintrin.h', '__m128', '_mm_setzero_ps()', ['-msse'] ], - [ 'SSE2', 'emmintrin.h', '__m128i', '_mm_setzero_si128()', ['-msse2'] ], - [ 'SSE4.1', 'smmintrin.h', '__m128i', '_mm_setzero_si128(); mtest = _mm_cmpeq_epi64(mtest, mtest)', ['-msse4.1'] ], - [ 'AVX', 'immintrin.h', '__m256', '_mm256_setzero_ps()', ['-mavx'] ], - ] - - foreach intrin : x86_intrinsics - intrin_check = '''#include <@0@> - int main (int argc, char ** argv) { - static @1@ mtest; - mtest = @2@; - return *((unsigned char *) &mtest) != 0; - }'''.format(intrin[1],intrin[2],intrin[3]) - intrin_name = intrin[0] - # Intrinsics arguments are not available with MSVC-like compilers - intrin_args = cc.get_argument_syntax() == 'msvc' ? [] : intrin[4] - if cc.links(intrin_check, name : 'compiler supports @0@ intrinsics'.format(intrin_name)) - may_have_intrin = true - presume_intrin = opus_can_presume_simd - elif intrin_args.length() > 0 - presume_intrin = false - if cc.links(intrin_check, - args : intrin_args, - name : 'compiler supports @0@ intrinsics with @1@'.format(intrin_name, ' '.join(intrin_args))) - may_have_intrin = true - else - may_have_intrin = false - endif - endif - if may_have_intrin - intrinsics_support += [intrin_name] - intrin_lower_name = intrin_name.to_lower().underscorify() - set_variable('have_' + intrin_lower_name, true) - opus_conf.set('OPUS_X86_MAY_HAVE_' + intrin_name.underscorify(), 1) - if presume_intrin - opus_conf.set('OPUS_X86_PRESUME_' + intrin_name.underscorify(), 1) - else - rtcd_support += [intrin_name] - set_variable('opus_@0@_args'.format(intrin_lower_name), intrin_args) - endif - else - message('Compiler does not support @0@ intrinsics'.format(intrin_name)) - endif - endforeach - - if not opt_rtcd.disabled() - get_cpuid_by_asm = false - cpuid_asm_code = ''' - #include - int main (int argc, char ** argv) { - unsigned int CPUInfo0; - unsigned int CPUInfo1; - unsigned int CPUInfo2; - unsigned int CPUInfo3; - unsigned int InfoType; - #if defined(__i386__) && defined(__PIC__) - __asm__ __volatile__ ( - "xchg %%ebx, %1\n" - "cpuid\n" - "xchg %%ebx, %1\n": - "=a" (CPUInfo0), - "=r" (CPUInfo1), - "=c" (CPUInfo2), - "=d" (CPUInfo3) : - "a" (InfoType), "c" (0) - ); - #else - __asm__ __volatile__ ( - "cpuid": - "=a" (CPUInfo0), - "=b" (CPUInfo1), - "=c" (CPUInfo2), - "=d" (CPUInfo3) : - "a" (InfoType), "c" (0) - ); - #endif - return 0; - }''' - cpuid_c_code = ''' - #include - int main (int argc, char ** argv) { - unsigned int CPUInfo0; - unsigned int CPUInfo1; - unsigned int CPUInfo2; - unsigned int CPUInfo3; - unsigned int InfoType; - __get_cpuid(InfoType, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3); - return 0; - }''' - cpuid_msvc_code = ''' - #include - int main (void) { - int CPUInfo, InfoType; - __cpuid(&CPUInfo, InfoType); - }''' - if cc.links(cpuid_asm_code, name : 'Get X86 CPU info via inline assembly') - opus_conf.set('CPU_INFO_BY_ASM', 1) - elif cc.links(cpuid_c_code, name : 'Get X86 CPU info via C method') - opus_conf.set('CPU_INFO_BY_C', 1) - elif cc.get_define('_MSC_VER') != '' and cc.links(cpuid_msvc_code) - message('Getting X86 CPU info via __cpuid') - else - if opt_intrinsics.enabled() and opt_rtcd.enabled() - error('intrinsics and rtcd options are enabled, but no Get CPU Info method detected') - endif - warning('Get CPU Info method not detected, no rtcd for intrinsics') - endif - endif # opt_rtcd - else - if opt_intrinsics.enabled() - error('intrinsics option enabled, but no intrinsics support for ' + host_cpu_family) - endif - warning('No intrinsics support for ' + host_cpu_family) - endif -endif - -# Check whether we require intrinsics and we support intrinsics on this arch, -# but none were detected. Can happen because of incorrect compiler flags, such -# as missing -mfloat-abi=softfp on ARM32 softfp architectures. -if opt_intrinsics.enabled() and intrinsics_support.length() == 0 - error('intrinsics option was enabled, but none were detected') -endif - -if opt_rtcd.disabled() - rtcd_support = 'disabled' -else - if rtcd_support.length() > 0 - opus_conf.set('OPUS_HAVE_RTCD', 1) - else - if intrinsics_support.length() == 0 - rtcd_support = 'none' - if opt_rtcd.enabled() - error('rtcd option is enabled, but no support for intrinsics or assembly is available') - endif - else - rtcd_support = 'not needed' - endif - endif -endif - -# extract source file lists from .mk files -mk_files = ['silk_sources.mk', 'opus_headers.mk', 'opus_sources.mk', 'silk_headers.mk', 'celt_sources.mk', 'celt_headers.mk'] -lines = run_command('meson/read-sources-list.py', mk_files, check: true).stdout().strip().split('\n') -sources = {} -foreach l : lines - a = l.split(' = ') - var_name = a[0] - file_list = a[1].split() - sources += {var_name: files(file_list)} -endforeach - -subdir('include') -subdir('silk') -subdir('celt') -subdir('src') - -configure_file(output: 'config.h', configuration: opus_conf) - -if not opt_tests.disabled() - subdir('celt/tests') - subdir('silk/tests') - subdir('tests') -endif - -# pkg-config files (not using pkg module so we can use the existing .pc.in file) -pkgconf = configuration_data() - -pkgconf.set('prefix', join_paths(get_option('prefix'))) -pkgconf.set('exec_prefix', '${prefix}') -pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir'))) -pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir'))) -pkgconf.set('VERSION', opus_version) -pkgconf.set('PC_BUILD', pc_build) -pkgconf.set('LIBM', libm.found() ? '-lm' : '') - -pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir')) - -configure_file(input : 'opus.pc.in', - output : 'opus.pc', - configuration : pkgconf, - install_dir : pkg_install_dir) - -# The uninstalled one has hardcoded libtool + static lib stuff, skip it for now -#configure_file(input : 'opus-uninstalled.pc.in', -# output : 'opus-uninstalled.pc', -# configuration : pkgconf, -# install : false) - -doxygen = find_program('doxygen', required: get_option('docs')) -if doxygen.found() - subdir('doc') -endif - -summary( - { - 'C99 var arrays': opus_conf.has('VAR_ARRAYS'), - 'C99 lrintf': opus_conf.has('HAVE_LRINTF'), - 'Use alloca': msg_use_alloca, - }, - section: 'Compiler support', - bool_yn: true, - list_sep: ', ', -) - -# Parse optimization status -foreach status : [['inline_optimization', opt_asm], - ['asm_optimization', opt_asm], - ['intrinsics_support', opt_intrinsics]] - res = status[0] - opt = status[1] - resval = get_variable(res) - if opt.disabled() - set_variable(res, 'disabled') - elif resval.length() == 0 - if host_cpu_family not in ['arm', 'aarch64', 'x86', 'x86_64'] - set_variable(res, 'No optimizations for your platform, please send patches') - else - set_variable(res, 'none') - endif - endif -endforeach - -summary( - { - 'Floating point support': not opt_fixed_point, - 'Fast float approximations': opt_float_approx, - 'Fixed point debugging': opt_fixed_point_debug, - 'Inline assembly optimizations': inline_optimization, - 'External assembly optimizations': asm_optimization, - 'Intrinsics optimizations': intrinsics_support, - 'Run-time CPU detection': rtcd_support, - }, - section: 'Optimizations', - bool_yn: true, - list_sep: ', ', -) -summary( - { - 'Custom modes': opt_custom_modes, - 'Assertions': opt_assertions, - 'Hardening': opt_hardening, - 'Fuzzing': opt_fuzzing, - 'Check ASM': opt_check_asm, - 'API documentation': doxygen.found(), - 'Extra programs': not extra_programs.disabled(), - 'Tests': not opt_tests.disabled(), - }, - section: 'General configuration', - bool_yn: true, - list_sep: ', ', -) diff --git a/Engine/lib/opus/meson/get-version.py b/Engine/lib/opus/meson/get-version.py deleted file mode 100644 index d3835f134..000000000 --- a/Engine/lib/opus/meson/get-version.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python3 -# -# Opus get-version.py -# -# Extracts versions for build: -# - Opus package version based on 'git describe' or $srcroot/package_version -# - libtool version based on configure.ac -# - macos lib version based on configure.ac -# -# Usage: -# get-version.py [--package-version | --libtool-version | --darwin-version] -import argparse -import subprocess -import os -import sys -import shutil - -if __name__ == '__main__': - arg_parser = argparse.ArgumentParser(description='Extract Opus package version or libtool version') - group = arg_parser.add_mutually_exclusive_group(required=True) - group.add_argument('--libtool-version', action='store_true') - group.add_argument('--package-version', action='store_true') - group.add_argument('--darwin-version', action='store_true') - args = arg_parser.parse_args() - - srcroot = os.path.normpath(os.path.join(os.path.dirname(__file__), '..')) - - # package version - if args.package_version: - package_version = None - - # check if git checkout - git_dir = os.path.join(srcroot, '.git') - is_git = os.path.isdir(git_dir) or os.path.isfile(git_dir) - have_git = shutil.which('git') is not None - - if is_git and have_git: - git_cmd = subprocess.run(['git', '--git-dir=' + git_dir, 'describe', 'HEAD'], stdout=subprocess.PIPE) - if git_cmd.returncode: - print('ERROR: Could not extract package version via `git describe` in', srcroot, file=sys.stderr) - sys.exit(-1) - package_version = git_cmd.stdout.decode('ascii').strip().lstrip('v') - else: - with open(os.path.join(srcroot, 'package_version'), 'r') as f: - for line in f: - if line.startswith('PACKAGE_VERSION="'): - package_version = line[17:].strip().lstrip('v').rstrip('"') - if package_version: - break - - if not package_version: - print('ERROR: Could not extract package version from package_version file in', srcroot, file=sys.stderr) - sys.exit(-1) - - print(package_version) - sys.exit(0) - - # libtool version + darwin version - elif args.libtool_version or args.darwin_version: - opus_lt_cur = None - opus_lt_rev = None - opus_lt_age = None - - with open(os.path.join(srcroot, 'configure.ac'), 'r') as f: - for line in f: - if line.strip().startswith('OPUS_LT_CURRENT='): - opus_lt_cur = line[16:].strip() - elif line.strip().startswith('OPUS_LT_REVISION='): - opus_lt_rev = line[17:].strip() - elif line.strip().startswith('OPUS_LT_AGE='): - opus_lt_age = line[12:].strip() - - if opus_lt_cur and opus_lt_rev and opus_lt_age: - opus_lt_cur = int(opus_lt_cur) - opus_lt_rev = int(opus_lt_rev) - opus_lt_age = int(opus_lt_age) - if args.libtool_version: - print('{}.{}.{}'.format(opus_lt_cur - opus_lt_age, opus_lt_age, opus_lt_rev)) - elif args.darwin_version: - print('{}.{}.{}'.format(opus_lt_cur + 1, 0, 0)) - sys.exit(0) - else: - print('ERROR: Could not extract libtool version from configure.ac file in', srcroot, file=sys.stderr) - sys.exit(-1) - else: - sys.exit(-1) diff --git a/Engine/lib/opus/meson/read-sources-list.py b/Engine/lib/opus/meson/read-sources-list.py deleted file mode 100644 index fcbec5019..000000000 --- a/Engine/lib/opus/meson/read-sources-list.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 -# -# opus/read-sources-list.py -# -# Parses .mk files and extracts list of source files. -# Prints one line per source file list, with filenames space-separated. - -import sys - -if len(sys.argv) < 2: - sys.exit('Usage: {} sources_foo.mk [sources_bar.mk...]'.format(sys.argv[0])) - -for input_fn in sys.argv[1:]: - with open(input_fn, 'r', encoding='utf8') as f: - text = f.read() - text = text.replace('\\\n', '') - - # Remove empty lines - lines = [line for line in text.split('\n') if line.strip()] - - # Print SOURCES_XYZ = file1.c file2.c - for line in lines: - values = line.strip().split('=', maxsplit=2) - if len(values) != 2: - raise RuntimeError('Unable to parse line "{}" from file "{}"'.format(line, input_fn)) - var, files = values - sources_list = [f for f in files.split(' ') if f] - print(var.strip(), '=', ' '.join(sources_list)) diff --git a/Engine/lib/opus/meson_options.txt b/Engine/lib/opus/meson_options.txt deleted file mode 100644 index 360ff2635..000000000 --- a/Engine/lib/opus/meson_options.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Optimizations -option('fixed-point', type : 'boolean', value : false, description : 'Compile without floating point (for machines without a fast enough FPU') -option('fixed-point-debug', type : 'boolean', value : false, description : 'Debug fixed-point implementation') -option('float-api', type : 'boolean', value : true, description : 'Compile with or without the floating point API (for machines with no float library') -option('float-approx', type : 'boolean', value : false, description : 'Enable fast approximations for floating point (not supported on all platforms)') -option('rtcd', type : 'feature', value : 'auto', description : 'Run-time CPU capabilities detection') -option('asm', type : 'feature', value : 'auto', description : 'Assembly optimizations for ARM (fixed-point)') -option('intrinsics', type : 'feature', value : 'auto', description : 'Intrinsics optimizations for ARM NEON or x86') - -option('custom-modes', type : 'boolean', value : false, description : 'Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames') -option('extra-programs', type : 'feature', value : 'auto', description : 'Extra programs (demo and tests)') -option('assertions', type : 'boolean', value : false, description : 'Additional software error checking') -option('hardening', type : 'boolean', value : true, description : 'Run-time checks that are cheap and safe for use in production') -option('fuzzing', type : 'boolean', value : false, description : 'Causes the encoder to make random decisions') -option('check-asm', type : 'boolean', value : false, description : 'Run bit-exactness checks between optimized and c implementations') - -# common feature options -option('tests', type : 'feature', value : 'auto', description : 'Build tests') -option('docs', type: 'feature', value: 'auto', description: 'Build API documentation') - -# other options -option('docdir', type: 'string', value: 'doc/opus', description: 'Directory to install documentation into (default: DATADIR/doc/opus') diff --git a/Engine/lib/opus/opus-uninstalled.pc.in b/Engine/lib/opus/opus-uninstalled.pc.in deleted file mode 100644 index 19f5c933d..000000000 --- a/Engine/lib/opus/opus-uninstalled.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -# Opus codec reference implementation uninstalled pkg-config file - -libdir=${pcfiledir}/.libs -includedir=${pcfiledir} - -Name: opus uninstalled -Description: Opus IETF audio codec (not installed, @PC_BUILD@) -Version: @VERSION@ -Requires: -Conflicts: -Libs: ${libdir}/libopus.la @LIBM@ -Cflags: -I${pcfiledir}/@top_srcdir@/include diff --git a/Engine/lib/opus/opus.m4 b/Engine/lib/opus/opus.m4 deleted file mode 100644 index 263470d40..000000000 --- a/Engine/lib/opus/opus.m4 +++ /dev/null @@ -1,117 +0,0 @@ -# Configure paths for libopus -# Gregory Maxwell 08-30-2012 -# Shamelessly stolen from Jack Moffitt (libogg) who -# Shamelessly stole from Owen Taylor and Manish Singh - -dnl XIPH_PATH_OPUS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libopus, and define OPUS_CFLAGS and OPUS_LIBS -dnl -AC_DEFUN([XIPH_PATH_OPUS], -[dnl -dnl Get the cflags and libraries -dnl -AC_ARG_WITH(opus,AC_HELP_STRING([--with-opus=PFX],[Prefix where opus is installed (optional)]), opus_prefix="$withval", opus_prefix="") -AC_ARG_WITH(opus-libraries,AC_HELP_STRING([--with-opus-libraries=DIR],[Directory where the opus library is installed (optional)]), opus_libraries="$withval", opus_libraries="") -AC_ARG_WITH(opus-includes,AC_HELP_STRING([--with-opus-includes=DIR],[Directory where the opus header files are installed (optional)]), opus_includes="$withval", opus_includes="") -AC_ARG_ENABLE(opustest,AC_HELP_STRING([--disable-opustest],[Do not try to compile and run a test opus program]),, enable_opustest=yes) - - if test "x$opus_libraries" != "x" ; then - OPUS_LIBS="-L$opus_libraries" - elif test "x$opus_prefix" = "xno" || test "x$opus_prefix" = "xyes" ; then - OPUS_LIBS="" - elif test "x$opus_prefix" != "x" ; then - OPUS_LIBS="-L$opus_prefix/lib" - elif test "x$prefix" != "xNONE" ; then - OPUS_LIBS="-L$prefix/lib" - fi - - if test "x$opus_prefix" != "xno" ; then - OPUS_LIBS="$OPUS_LIBS -lopus" - fi - - if test "x$opus_includes" != "x" ; then - OPUS_CFLAGS="-I$opus_includes" - elif test "x$opus_prefix" = "xno" || test "x$opus_prefix" = "xyes" ; then - OPUS_CFLAGS="" - elif test "x$opus_prefix" != "x" ; then - OPUS_CFLAGS="-I$opus_prefix/include" - elif test "x$prefix" != "xNONE"; then - OPUS_CFLAGS="-I$prefix/include" - fi - - AC_MSG_CHECKING(for Opus) - if test "x$opus_prefix" = "xno" ; then - no_opus="disabled" - enable_opustest="no" - else - no_opus="" - fi - - - if test "x$enable_opustest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $OPUS_CFLAGS" - LIBS="$LIBS $OPUS_LIBS" -dnl -dnl Now check if the installed Opus is sufficiently new. -dnl - rm -f conf.opustest - AC_TRY_RUN([ -#include -#include -#include -#include - -int main (void) -{ - system("touch conf.opustest"); - return 0; -} - -],, no_opus=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - - if test "x$no_opus" = "xdisabled" ; then - AC_MSG_RESULT(no) - ifelse([$2], , :, [$2]) - elif test "x$no_opus" = "x" ; then - AC_MSG_RESULT(yes) - ifelse([$1], , :, [$1]) - else - AC_MSG_RESULT(no) - if test -f conf.opustest ; then - : - else - echo "*** Could not run Opus test program, checking why..." - CFLAGS="$CFLAGS $OPUS_CFLAGS" - LIBS="$LIBS $OPUS_LIBS" - AC_TRY_LINK([ -#include -#include -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding Opus or finding the wrong" - echo "*** version of Opus. If it is not finding Opus, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occurred. This usually means Opus was incorrectly installed" - echo "*** or that you have moved Opus since it was installed." ]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - OPUS_CFLAGS="" - OPUS_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(OPUS_CFLAGS) - AC_SUBST(OPUS_LIBS) - rm -f conf.opustest -]) diff --git a/Engine/lib/opus/opus.pc.in b/Engine/lib/opus/opus.pc.in deleted file mode 100644 index 6946e7de5..000000000 --- a/Engine/lib/opus/opus.pc.in +++ /dev/null @@ -1,16 +0,0 @@ -# Opus codec reference implementation pkg-config file - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: Opus -Description: Opus IETF audio codec (@PC_BUILD@ build) -URL: https://opus-codec.org/ -Version: @VERSION@ -Requires: -Conflicts: -Libs: -L${libdir} -lopus -Libs.private: @LIBM@ -Cflags: -I${includedir}/opus diff --git a/Engine/lib/opus/opus_headers.mk b/Engine/lib/opus/opus_headers.mk deleted file mode 100644 index 27596f2a4..000000000 --- a/Engine/lib/opus/opus_headers.mk +++ /dev/null @@ -1,9 +0,0 @@ -OPUS_HEAD = \ -include/opus.h \ -include/opus_multistream.h \ -include/opus_projection.h \ -src/opus_private.h \ -src/analysis.h \ -src/mapping_matrix.h \ -src/mlp.h \ -src/tansig_table.h diff --git a/Engine/lib/opus/opus_sources.mk b/Engine/lib/opus/opus_sources.mk deleted file mode 100644 index 44153b570..000000000 --- a/Engine/lib/opus/opus_sources.mk +++ /dev/null @@ -1,16 +0,0 @@ -OPUS_SOURCES = \ -src/opus.c \ -src/opus_decoder.c \ -src/opus_encoder.c \ -src/opus_multistream.c \ -src/opus_multistream_encoder.c \ -src/opus_multistream_decoder.c \ -src/repacketizer.c \ -src/opus_projection_encoder.c \ -src/opus_projection_decoder.c \ -src/mapping_matrix.c - -OPUS_SOURCES_FLOAT = \ -src/analysis.c \ -src/mlp.c \ -src/mlp_data.c diff --git a/Engine/lib/opus/releases.sha2 b/Engine/lib/opus/releases.sha2 deleted file mode 100644 index 334976b14..000000000 --- a/Engine/lib/opus/releases.sha2 +++ /dev/null @@ -1,79 +0,0 @@ -b2f75c4ac5ab837845eb028413fae2a28754bfb0a6d76416e2af1441ef447649 opus-0.9.0.tar.gz -4e379a98ba95bbbfe9087ef10fdd05c8ac9060b6d695f587ea82a7b43a0df4fe opus-0.9.10.tar.gz -b1cad6846a8f819a141009fe3f8f10c946e8eff7e9c2339cd517bb136cc59eae opus-0.9.14.tar.gz -206221afc47b87496588013bd4523e1e9f556336c0813f4372773fc536dd4293 opus-0.9.1.tar.gz -6e85c1b57e1d7b7dfe2928bf92586b96b73a9067e054ede45bd8e6d24bd30582 opus-0.9.2.tar.gz -d916e34c18a396eb7dffc47af754f441af52a290b761e20db9aedb65928c699e opus-0.9.3.tar.gz -53801066fa97329768e7b871fd1495740269ec46802e1c9051aa7e78c6edee5b opus-0.9.5.tar.gz -3bfaeb25f4b4a625a0bc994d6fc6f6776a05193f60099e0a99f7530c6b256309 opus-0.9.6.tar.gz -1b69772c31c5cbaa43d1dfa5b1c495fc29712e8e0ff69d6f8ad46459e5c6715f opus-0.9.7.tar.gz -4aa30d2e0652ffb4a7a22cc8a29c4ce78267626f560a2d9213b1d2d4e618cf36 opus-0.9.8.tar.gz -2f62359f09151fa3b242040dc9b4c5b6bda15557c5daea59c8420f1a2ff328b7 opus-0.9.9.tar.gz -43bcea51afa531f32a6a5fdd9cba4bd496993e26a141217db3cccce6caa7cd74 opus-1.0.0-rc.tar.gz -9250fcc74472d45c1e14745542ec9c8d09982538aefed56962495614be3e0d2d opus-1.0.0.tar.gz -76bc0a31502a51dae9ab737b4db043b9ecfcd0b5861f0bfda41b662bd5b92227 opus-1.0.1-rc2.tar.gz -3de8d6809dac38971ebb305532d4ea532519d3bed08985f25d6c557f9ce5e8ff opus-1.0.1-rc3.tar.gz -8044397a6365a07117b08cbe8f9818bf7c93746908806ba74a2917187bbdda5f opus-1.0.1-rc.tar.gz -80fa5c3caf2ac0fd68f8a22cce1564fc46b368c773a17554887d0066fe1841ef opus-1.0.1.tar.gz -da615edbee5d019c1833071d69a4782c19f178cf9ca1401375036ecef25cd78a opus-1.0.2.tar.gz -191a089c92dbc403de6980463dd3604b65beb12d283c607e246c8076363cb49c opus-1.0.3.tar.gz -a8d40efe87f6c3e76725391457d46277878c7a816ae1642843261463133fa5c8 opus-1.1-alpha.tar.gz -ec1784287f385aef994b64734aaecae04860e61aa50fc6eef6643fa7e40dd193 opus-1.1-beta.tar.gz -8aa16360f59a94d3e38f38f28d24039f7663179682cbae82aa42f1dd9e52e6ed opus-1.1-rc.tar.gz -ebc87a086d4fe677c5e42d56888b1fd25af858e4179eae4f8656270410dffac3 opus-1.1-rc2.tar.gz -cbfd09c58cc10a4d3fcb727ad5d46d7bb549f8185ac922ee28b4581b52a7bee9 opus-1.1-rc3.tar.gz -b9727015a58affcf3db527322bf8c4d2fcf39f5f6b8f15dbceca20206cbe1d95 opus-1.1.tar.gz -0c668639dcd16b14709fc9dc49e6686606f5a256f2eaa1ebaa2f39a66f8626cd opus-1.1.1-beta.tar.gz -66f2a5877c8803dc9a5a44b4f3d0bdc8f06bd066324222d144eb255612b68152 opus-1.1.1-rc.tar.gz -9b84ff56bd7720d5554103c557664efac2b8b18acc4bbcc234cb881ab9a3371e opus-1.1.1.tar.gz -0e290078e31211baa7b5886bcc8ab6bc048b9fc83882532da4a1a45e58e907fd opus-1.1.2.tar.gz -58b6fe802e7e30182e95d0cde890c0ace40b6f125cffc50635f0ad2eef69b633 opus-1.1.3.tar.gz -9122b6b380081dd2665189f97bfd777f04f92dc3ab6698eea1dbb27ad59d8692 opus-1.1.4.tar.gz -eb84981ca0f40a3e5d5e58d2e8582cb2fee05a022825a6dfe14d14b04eb563e4 opus-1.1.5.tar.gz -654a9bebb73266271a28edcfff431e4cfd9bfcde71f42849a0cdd73bece803a7 opus-1.2-alpha.tar.gz -c0e90507259cf21ce7b2c82fb9ac55367d8543dae91cc3d4d2c59afd37f44023 opus-1.2-alpha2.tar.gz -291e979a8a2fb679ed35a5dff5d761a9d9a5e22586fd07934ed94461e2636c7a opus-1.2-beta.tar.gz -85343fdaed96529d94c1e1f3a210fa51240d04ca62fa01e97ef02f88020c2ce9 opus-1.2-rc1.tar.gz -77db45a87b51578fbc49555ef1b10926179861d854eb2613207dc79d9ec0a9a9 opus-1.2.tar.gz -cfafd339ccd9c5ef8d6ab15d7e1a412c054bf4cb4ecbbbcc78c12ef2def70732 opus-1.2.1.tar.gz -7f56e058c9549d03ae35511ad9e16ef6d1eb257836830d54abff0f495f17e187 opus-1.3-beta.tar.gz -96fa28598e8ccd558b297277ad59a045c551ba0e06d65a9675938e084f837669 opus-1.3-rc.tar.gz -f6bab321fb81db984766f1e4d340a9e71a5ca2c5d4d53f4ee072e84afda271ca opus-1.3-rc2.tar.gz -4f3d69aefdf2dbaf9825408e452a8a414ffc60494c70633560700398820dc550 opus-1.3.tar.gz -65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d opus-1.3.1.tar.gz -94ac78ca4f74c4e43bc9fe4ec1ad0aa36f38ab90f45b0727c40dd1e96096e767 opus_testvectors-draft11.tar.gz -94ac78ca4f74c4e43bc9fe4ec1ad0aa36f38ab90f45b0727c40dd1e96096e767 opus_testvectors.tar.gz -6b26a22f9ba87b2b836906a9bb7afec5f8e54d49553b1200382520ee6fedfa55 opus_testvectors-rfc8251.tar.gz -5d2b99757bcb628bab2611f3ed27af6f35276ce3abc96c0ed4399d6c6463dda5 opus-tools-0.1.2.tar.gz -008317297d6ce84f84992abf8cc948a048a4fa135e1d1caf429fafde8965a792 opus-tools-0.1.3.tar.gz -de80485c5afa1fd83c0e16a0dd4860470c872997a7dd0a58e99b2ee8a93e5168 opus-tools-0.1.4.tar.gz -76678d0eb7a9b3d793bd0243f9ced9ab0ecdab263f5232ed940c8f5795fb0405 opus-tools-0.1.5.tar.gz -cc86dbc2a4d76da7e1ed9afee85448c8f798c465a5412233f178783220f3a2c1 opus-tools-0.1.6.tar.gz -e0f08d301555dffc417604269b5a85d2bd197f259c7d6c957f370ffd33d6d9cd opus-tools-0.1.7.tar.gz -e4e188579ea1c4e4d5066460d4a7214a7eafe3539e9a4466fdc98af41ba4a2f6 opus-tools-0.1.8.tar.gz -b1873dd78c7fbc98cf65d6e10cfddb5c2c03b3af93f922139a2104baedb4643a opus-tools-0.1.9.tar.gz -a2357532d19471b70666e0e0ec17d514246d8b3cb2eb168f68bb0f6fd372b28c opus-tools-0.1.10.tar.gz -b4e56cb00d3e509acfba9a9b627ffd8273b876b4e2408642259f6da28fa0ff86 opus-tools-0.2.tar.gz -bd6d14e8897a2f80065ef34a516c70e74f8e00060abdbc238e79e5f99bca3e96 libopusenc-0.1.tar.gz -02e6e0b14cbbe0569d948a46420f9c9a81d93bba32dc576a4007cbf96da68ef3 libopusenc-0.1.1.tar.gz -c79e95eeee43a0b965e9b2c59a243763a8f8b0a7e71441df2aa9084f6171c73a libopusenc-0.2.tar.gz -8298db61a8d3d63e41c1a80705baa8ce9ff3f50452ea7ec1c19a564fe106cbb9 libopusenc-0.2.1.tar.gz -8071b968475c1a17f54b6840d6de9d9ee20f930e827b0401abe3c4cf4f3bf30a opusfile-0.1.tar.gz -b4a678b3b6c4adfb6aff1f67ef658becfe146ea7c7ff228e99543762171557f9 opusfile-0.2.tar.gz -4248927f2c4e316ea5b84fb02bd100bfec8fa4624a6910d77f0af7f0c6cb8baa opusfile-0.3.tar.gz -9836ea11706c44f36de92c4c9b1248e03a4c521e7fb2cff18a0cb4f8b0e79140 opusfile-0.4.tar.gz -f187906b1b35f7f0d7de6a759b4aab512a9279d23adb35d8009e7e33bd6a922a opusfile-0.4.zip -2ce52d006aeeec9f10260dbe3073c4636954a1ab19c82b8baafefe0180aa4a39 opusfile-0.5.tar.gz -b940d62beb15b5974764574b9f265481fe5b6ee16902fb705727546caf956261 opusfile-0.5.zip -2428717b356e139f18ed2fdb5ad990b5654a238907a0058200b39c46a7d03ea6 opusfile-0.6.tar.gz -753339225193df605372944889023b9b3c5378d672e8784d69fa241cd465278c opusfile-0.6.zip -9e2bed13bc729058591a0f1cab2505e8cfd8e7ac460bf10a78bcc3b125e7c301 opusfile-0.7.tar.gz -346967d7989bb83b05949483b76bd0f69a12c59bd8b4457e864902b52bb0ac34 opusfile-0.7.zip -2c231ed3cfaa1b3173f52d740e5bbd77d51b9dfecb87014b404917fba4b855a4 opusfile-0.8.tar.gz -89dff4342c3b789574cbea5c57f11b96d4ebe4d28ab90248c1783ea569b1e9e3 opusfile-0.8.zip -f75fb500e40b122775ac1a71ad80c4477698842a8fe9da4a1b4a1a9f16e4e979 opusfile-0.9.tar.gz -e9591da4d4c9e857436c2d46a28a9e470fa5355ea5a76d4d582f137d18755d36 opusfile-0.9.zip -48e03526ba87ef9cf5f1c47b5ebe3aa195bd89b912a57060c36184a6cd19412f opusfile-0.10.tar.gz -9d9e95d01817ecf48bf6daaea8f071f9b45bd1751ca1fc8ce50e5075eb2bc3c8 opusfile-0.10.zip -74ce9b6cf4da103133e7b5c95df810ceb7195471e1162ed57af415fabf5603bf opusfile-0.11.tar.gz -23c5168026c4f1fc34843650135b409d0fc8cf452508163b4ece8077256ac6ff opusfile-0.11.zip diff --git a/Engine/lib/opus/scripts/dump_rnn.py b/Engine/lib/opus/scripts/dump_rnn.py deleted file mode 100644 index dd66403b5..000000000 --- a/Engine/lib/opus/scripts/dump_rnn.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/python - -from __future__ import print_function - -from keras.models import Sequential -from keras.layers import Dense -from keras.layers import LSTM -from keras.layers import GRU -from keras.models import load_model -from keras import backend as K - -import numpy as np - -def printVector(f, vector, name): - v = np.reshape(vector, (-1)); - #print('static const float ', name, '[', len(v), '] = \n', file=f) - f.write('static const opus_int16 {}[{}] = {{\n '.format(name, len(v))) - for i in range(0, len(v)): - f.write('{}'.format(int(round(8192*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\n') - return; - -def binary_crossentrop2(y_true, y_pred): - return K.mean(2*K.abs(y_true-0.5) * K.binary_crossentropy(y_pred, y_true), axis=-1) - - -model = load_model("weights.hdf5", custom_objects={'binary_crossentrop2': binary_crossentrop2}) - -weights = model.get_weights() - -f = open('rnn_weights.c', 'w') - -f.write('/*This file is automatically generated from a Keras model*/\n\n') -f.write('#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n#include "mlp.h"\n\n') - -printVector(f, weights[0], 'layer0_weights') -printVector(f, weights[1], 'layer0_bias') -printVector(f, weights[2], 'layer1_weights') -printVector(f, weights[3], 'layer1_recur_weights') -printVector(f, weights[4], 'layer1_bias') -printVector(f, weights[5], 'layer2_weights') -printVector(f, weights[6], 'layer2_bias') - -f.write('const DenseLayer layer0 = {\n layer0_bias,\n layer0_weights,\n 25, 16, 0\n};\n\n') -f.write('const GRULayer layer1 = {\n layer1_bias,\n layer1_weights,\n layer1_recur_weights,\n 16, 12\n};\n\n') -f.write('const DenseLayer layer2 = {\n layer2_bias,\n layer2_weights,\n 12, 2, 1\n};\n\n') - -f.close() diff --git a/Engine/lib/opus/scripts/rnn_train.py b/Engine/lib/opus/scripts/rnn_train.py deleted file mode 100644 index ffdaa1e7d..000000000 --- a/Engine/lib/opus/scripts/rnn_train.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/python - -from __future__ import print_function - -from keras.models import Sequential -from keras.models import Model -from keras.layers import Input -from keras.layers import Dense -from keras.layers import LSTM -from keras.layers import GRU -from keras.layers import SimpleRNN -from keras.layers import Dropout -from keras import losses -import h5py - -from keras import backend as K -import numpy as np - -def binary_crossentrop2(y_true, y_pred): - return K.mean(2*K.abs(y_true-0.5) * K.binary_crossentropy(y_pred, y_true), axis=-1) - -print('Build model...') -#model = Sequential() -#model.add(Dense(16, activation='tanh', input_shape=(None, 25))) -#model.add(GRU(12, dropout=0.0, recurrent_dropout=0.0, activation='tanh', recurrent_activation='sigmoid', return_sequences=True)) -#model.add(Dense(2, activation='sigmoid')) - -main_input = Input(shape=(None, 25), name='main_input') -x = Dense(16, activation='tanh')(main_input) -x = GRU(12, dropout=0.1, recurrent_dropout=0.1, activation='tanh', recurrent_activation='sigmoid', return_sequences=True)(x) -x = Dense(2, activation='sigmoid')(x) -model = Model(inputs=main_input, outputs=x) - -batch_size = 64 - -print('Loading data...') -with h5py.File('features.h5', 'r') as hf: - all_data = hf['features'][:] -print('done.') - -window_size = 1500 - -nb_sequences = len(all_data)/window_size -print(nb_sequences, ' sequences') -x_train = all_data[:nb_sequences*window_size, :-2] -x_train = np.reshape(x_train, (nb_sequences, window_size, 25)) - -y_train = np.copy(all_data[:nb_sequences*window_size, -2:]) -y_train = np.reshape(y_train, (nb_sequences, window_size, 2)) - -all_data = 0; -x_train = x_train.astype('float32') -y_train = y_train.astype('float32') - -print(len(x_train), 'train sequences. x shape =', x_train.shape, 'y shape = ', y_train.shape) - -# try using different optimizers and different optimizer configs -model.compile(loss=binary_crossentrop2, - optimizer='adam', - metrics=['binary_accuracy']) - -print('Train...') -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=200, - validation_data=(x_train, y_train)) -model.save("newweights.hdf5") diff --git a/Engine/lib/opus/silk/A2NLSF.c b/Engine/lib/opus/silk/A2NLSF.c deleted file mode 100644 index b487686ff..000000000 --- a/Engine/lib/opus/silk/A2NLSF.c +++ /dev/null @@ -1,267 +0,0 @@ -/*********************************************************************** -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. -***********************************************************************/ - -/* Conversion between prediction filter coefficients and NLSFs */ -/* Requires the order to be an even number */ -/* A piecewise linear approximation maps LSF <-> cos(LSF) */ -/* Therefore the result is not accurate NLSFs, but the two */ -/* functions are accurate inverses of each other */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "SigProc_FIX.h" -#include "tables.h" - -/* Number of binary divisions, when not in low complexity mode */ -#define BIN_DIV_STEPS_A2NLSF_FIX 3 /* must be no higher than 16 - log2( LSF_COS_TAB_SZ_FIX ) */ -#define MAX_ITERATIONS_A2NLSF_FIX 16 - -/* Helper function for A2NLSF(..) */ -/* Transforms polynomials from cos(n*f) to cos(f)^n */ -static OPUS_INLINE void silk_A2NLSF_trans_poly( - opus_int32 *p, /* I/O Polynomial */ - const opus_int dd /* I Polynomial order (= filter order / 2 ) */ -) -{ - opus_int k, n; - - for( k = 2; k <= dd; k++ ) { - for( n = dd; n > k; n-- ) { - p[ n - 2 ] -= p[ n ]; - } - p[ k - 2 ] -= silk_LSHIFT( p[ k ], 1 ); - } -} -/* Helper function for A2NLSF(..) */ -/* Polynomial evaluation */ -static OPUS_INLINE opus_int32 silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in Q16 */ - opus_int32 *p, /* I Polynomial, Q16 */ - const opus_int32 x, /* I Evaluation point, Q12 */ - const opus_int dd /* I Order */ -) -{ - opus_int n; - opus_int32 x_Q16, y32; - - y32 = p[ dd ]; /* Q16 */ - x_Q16 = silk_LSHIFT( x, 4 ); - - if ( opus_likely( 8 == dd ) ) - { - y32 = silk_SMLAWW( p[ 7 ], y32, x_Q16 ); - y32 = silk_SMLAWW( p[ 6 ], y32, x_Q16 ); - y32 = silk_SMLAWW( p[ 5 ], y32, x_Q16 ); - y32 = silk_SMLAWW( p[ 4 ], y32, x_Q16 ); - y32 = silk_SMLAWW( p[ 3 ], y32, x_Q16 ); - y32 = silk_SMLAWW( p[ 2 ], y32, x_Q16 ); - y32 = silk_SMLAWW( p[ 1 ], y32, x_Q16 ); - y32 = silk_SMLAWW( p[ 0 ], y32, x_Q16 ); - } - else - { - for( n = dd - 1; n >= 0; n-- ) { - y32 = silk_SMLAWW( p[ n ], y32, x_Q16 ); /* Q16 */ - } - } - return y32; -} - -static OPUS_INLINE void silk_A2NLSF_init( - const opus_int32 *a_Q16, - opus_int32 *P, - opus_int32 *Q, - const opus_int dd -) -{ - opus_int k; - - /* Convert filter coefs to even and odd polynomials */ - P[dd] = silk_LSHIFT( 1, 16 ); - Q[dd] = silk_LSHIFT( 1, 16 ); - for( k = 0; k < dd; k++ ) { - P[ k ] = -a_Q16[ dd - k - 1 ] - a_Q16[ dd + k ]; /* Q16 */ - Q[ k ] = -a_Q16[ dd - k - 1 ] + a_Q16[ dd + k ]; /* Q16 */ - } - - /* Divide out zeros as we have that for even filter orders, */ - /* z = 1 is always a root in Q, and */ - /* z = -1 is always a root in P */ - for( k = dd; k > 0; k-- ) { - P[ k - 1 ] -= P[ k ]; - Q[ k - 1 ] += Q[ k ]; - } - - /* Transform polynomials from cos(n*f) to cos(f)^n */ - silk_A2NLSF_trans_poly( P, dd ); - silk_A2NLSF_trans_poly( Q, dd ); -} - -/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */ -/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */ -void silk_A2NLSF( - opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies in Q15 (0..2^15-1) [d] */ - opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */ - const opus_int d /* I Filter order (must be even) */ -) -{ - opus_int i, k, m, dd, root_ix, ffrac; - opus_int32 xlo, xhi, xmid; - opus_int32 ylo, yhi, ymid, thr; - opus_int32 nom, den; - opus_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ]; - opus_int32 Q[ SILK_MAX_ORDER_LPC / 2 + 1 ]; - opus_int32 *PQ[ 2 ]; - opus_int32 *p; - - /* Store pointers to array */ - PQ[ 0 ] = P; - PQ[ 1 ] = Q; - - dd = silk_RSHIFT( d, 1 ); - - silk_A2NLSF_init( a_Q16, P, Q, dd ); - - /* Find roots, alternating between P and Q */ - p = P; /* Pointer to polynomial */ - - xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; /* Q12*/ - ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); - - if( ylo < 0 ) { - /* Set the first NLSF to zero and move on to the next */ - NLSF[ 0 ] = 0; - p = Q; /* Pointer to polynomial */ - ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); - root_ix = 1; /* Index of current root */ - } else { - root_ix = 0; /* Index of current root */ - } - k = 1; /* Loop counter */ - i = 0; /* Counter for bandwidth expansions applied */ - thr = 0; - while( 1 ) { - /* Evaluate polynomial */ - xhi = silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */ - yhi = silk_A2NLSF_eval_poly( p, xhi, dd ); - - /* Detect zero crossing */ - if( ( ylo <= 0 && yhi >= thr ) || ( ylo >= 0 && yhi <= -thr ) ) { - if( yhi == 0 ) { - /* If the root lies exactly at the end of the current */ - /* interval, look for the next root in the next interval */ - thr = 1; - } else { - thr = 0; - } - /* Binary division */ - ffrac = -256; - for( m = 0; m < BIN_DIV_STEPS_A2NLSF_FIX; m++ ) { - /* Evaluate polynomial */ - xmid = silk_RSHIFT_ROUND( xlo + xhi, 1 ); - ymid = silk_A2NLSF_eval_poly( p, xmid, dd ); - - /* Detect zero crossing */ - if( ( ylo <= 0 && ymid >= 0 ) || ( ylo >= 0 && ymid <= 0 ) ) { - /* Reduce frequency */ - xhi = xmid; - yhi = ymid; - } else { - /* Increase frequency */ - xlo = xmid; - ylo = ymid; - ffrac = silk_ADD_RSHIFT( ffrac, 128, m ); - } - } - - /* Interpolate */ - if( silk_abs( ylo ) < 65536 ) { - /* Avoid dividing by zero */ - den = ylo - yhi; - nom = silk_LSHIFT( ylo, 8 - BIN_DIV_STEPS_A2NLSF_FIX ) + silk_RSHIFT( den, 1 ); - if( den != 0 ) { - ffrac += silk_DIV32( nom, den ); - } - } else { - /* No risk of dividing by zero because abs(ylo - yhi) >= abs(ylo) >= 65536 */ - ffrac += silk_DIV32( ylo, silk_RSHIFT( ylo - yhi, 8 - BIN_DIV_STEPS_A2NLSF_FIX ) ); - } - NLSF[ root_ix ] = (opus_int16)silk_min_32( silk_LSHIFT( (opus_int32)k, 8 ) + ffrac, silk_int16_MAX ); - - silk_assert( NLSF[ root_ix ] >= 0 ); - - root_ix++; /* Next root */ - if( root_ix >= d ) { - /* Found all roots */ - break; - } - /* Alternate pointer to polynomial */ - p = PQ[ root_ix & 1 ]; - - /* Evaluate polynomial */ - xlo = silk_LSFCosTab_FIX_Q12[ k - 1 ]; /* Q12*/ - ylo = silk_LSHIFT( 1 - ( root_ix & 2 ), 12 ); - } else { - /* Increment loop counter */ - k++; - xlo = xhi; - ylo = yhi; - thr = 0; - - if( k > LSF_COS_TAB_SZ_FIX ) { - i++; - if( i > MAX_ITERATIONS_A2NLSF_FIX ) { - /* Set NLSFs to white spectrum and exit */ - NLSF[ 0 ] = (opus_int16)silk_DIV32_16( 1 << 15, d + 1 ); - for( k = 1; k < d; k++ ) { - NLSF[ k ] = (opus_int16)silk_ADD16( NLSF[ k-1 ], NLSF[ 0 ] ); - } - return; - } - - /* Error: Apply progressively more bandwidth expansion and run again */ - silk_bwexpander_32( a_Q16, d, 65536 - silk_LSHIFT( 1, i ) ); - - silk_A2NLSF_init( a_Q16, P, Q, dd ); - p = P; /* Pointer to polynomial */ - xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; /* Q12*/ - ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); - if( ylo < 0 ) { - /* Set the first NLSF to zero and move on to the next */ - NLSF[ 0 ] = 0; - p = Q; /* Pointer to polynomial */ - ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); - root_ix = 1; /* Index of current root */ - } else { - root_ix = 0; /* Index of current root */ - } - k = 1; /* Reset loop counter */ - } - } - } -} diff --git a/Engine/lib/opus/silk/API.h b/Engine/lib/opus/silk/API.h deleted file mode 100644 index 4d90ff9aa..000000000 --- a/Engine/lib/opus/silk/API.h +++ /dev/null @@ -1,135 +0,0 @@ -/*********************************************************************** -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 SILK_API_H -#define SILK_API_H - -#include "control.h" -#include "typedef.h" -#include "errors.h" -#include "entenc.h" -#include "entdec.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define SILK_MAX_FRAMES_PER_PACKET 3 - -/* Struct for TOC (Table of Contents) */ -typedef struct { - opus_int VADFlag; /* Voice activity for packet */ - opus_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet */ - opus_int inbandFECFlag; /* Flag indicating if packet contains in-band FEC */ -} silk_TOC_struct; - -/****************************************/ -/* Encoder functions */ -/****************************************/ - -/***********************************************/ -/* Get size in bytes of the Silk encoder state */ -/***********************************************/ -opus_int silk_Get_Encoder_Size( /* O Returns error code */ - opus_int *encSizeBytes /* O Number of bytes in SILK encoder state */ -); - -/*************************/ -/* Init or reset encoder */ -/*************************/ -opus_int silk_InitEncoder( /* O Returns error code */ - void *encState, /* I/O State */ - int arch, /* I Run-time architecture */ - silk_EncControlStruct *encStatus /* O Encoder Status */ -); - -/**************************/ -/* Encode frame with Silk */ -/**************************/ -/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */ -/* encControl->payloadSize_ms is set to */ -opus_int silk_Encode( /* O Returns error code */ - void *encState, /* I/O State */ - silk_EncControlStruct *encControl, /* I Control status */ - const opus_int16 *samplesIn, /* I Speech sample input vector */ - opus_int nSamplesIn, /* I Number of samples in input vector */ - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int32 *nBytesOut, /* I/O Number of bytes in payload (input: Max bytes) */ - const opus_int prefillFlag, /* I Flag to indicate prefilling buffers no coding */ - int activity /* I Decision of Opus voice activity detector */ -); - -/****************************************/ -/* Decoder functions */ -/****************************************/ - -/***********************************************/ -/* Get size in bytes of the Silk decoder state */ -/***********************************************/ -opus_int silk_Get_Decoder_Size( /* O Returns error code */ - opus_int *decSizeBytes /* O Number of bytes in SILK decoder state */ -); - -/*************************/ -/* Init or Reset decoder */ -/*************************/ -opus_int silk_InitDecoder( /* O Returns error code */ - void *decState /* I/O State */ -); - -/******************/ -/* Decode a frame */ -/******************/ -opus_int silk_Decode( /* O Returns error code */ - void* decState, /* I/O State */ - silk_DecControlStruct* decControl, /* I/O Control Structure */ - opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ - opus_int newPacketFlag, /* I Indicates first decoder call for this packet */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 *samplesOut, /* O Decoded output speech vector */ - opus_int32 *nSamplesOut, /* O Number of samples decoded */ - int arch /* I Run-time architecture */ -); - -#if 0 -/**************************************/ -/* Get table of contents for a packet */ -/**************************************/ -opus_int silk_get_TOC( - const opus_uint8 *payload, /* I Payload data */ - const opus_int nBytesIn, /* I Number of input bytes */ - const opus_int nFramesPerPayload, /* I Number of SILK frames per payload */ - silk_TOC_struct *Silk_TOC /* O Type of content */ -); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/silk/CNG.c b/Engine/lib/opus/silk/CNG.c deleted file mode 100644 index 2a910099e..000000000 --- a/Engine/lib/opus/silk/CNG.c +++ /dev/null @@ -1,188 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" - -/* Generates excitation for CNG LPC synthesis */ -static OPUS_INLINE void silk_CNG_exc( - opus_int32 exc_Q14[], /* O CNG excitation signal Q10 */ - opus_int32 exc_buf_Q14[], /* I Random samples buffer Q10 */ - opus_int length, /* I Length */ - opus_int32 *rand_seed /* I/O Seed to random index generator */ -) -{ - opus_int32 seed; - opus_int i, idx, exc_mask; - - exc_mask = CNG_BUF_MASK_MAX; - while( exc_mask > length ) { - exc_mask = silk_RSHIFT( exc_mask, 1 ); - } - - seed = *rand_seed; - for( i = 0; i < length; i++ ) { - seed = silk_RAND( seed ); - idx = (opus_int)( silk_RSHIFT( seed, 24 ) & exc_mask ); - silk_assert( idx >= 0 ); - silk_assert( idx <= CNG_BUF_MASK_MAX ); - exc_Q14[ i ] = exc_buf_Q14[ idx ]; - } - *rand_seed = seed; -} - -void silk_CNG_Reset( - silk_decoder_state *psDec /* I/O Decoder state */ -) -{ - opus_int i, NLSF_step_Q15, NLSF_acc_Q15; - - NLSF_step_Q15 = silk_DIV32_16( silk_int16_MAX, psDec->LPC_order + 1 ); - NLSF_acc_Q15 = 0; - for( i = 0; i < psDec->LPC_order; i++ ) { - NLSF_acc_Q15 += NLSF_step_Q15; - psDec->sCNG.CNG_smth_NLSF_Q15[ i ] = NLSF_acc_Q15; - } - psDec->sCNG.CNG_smth_Gain_Q16 = 0; - psDec->sCNG.rand_seed = 3176576; -} - -/* Updates CNG estimate, and applies the CNG when packet was lost */ -void silk_CNG( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[], /* I/O Signal */ - opus_int length /* I Length of residual */ -) -{ - opus_int i, subfr; - opus_int32 LPC_pred_Q10, max_Gain_Q16, gain_Q16, gain_Q10; - opus_int16 A_Q12[ MAX_LPC_ORDER ]; - silk_CNG_struct *psCNG = &psDec->sCNG; - SAVE_STACK; - - if( psDec->fs_kHz != psCNG->fs_kHz ) { - /* Reset state */ - silk_CNG_Reset( psDec ); - - psCNG->fs_kHz = psDec->fs_kHz; - } - if( psDec->lossCnt == 0 && psDec->prevSignalType == TYPE_NO_VOICE_ACTIVITY ) { - /* Update CNG parameters */ - - /* Smoothing of LSF's */ - for( i = 0; i < psDec->LPC_order; i++ ) { - psCNG->CNG_smth_NLSF_Q15[ i ] += silk_SMULWB( (opus_int32)psDec->prevNLSF_Q15[ i ] - (opus_int32)psCNG->CNG_smth_NLSF_Q15[ i ], CNG_NLSF_SMTH_Q16 ); - } - /* Find the subframe with the highest gain */ - max_Gain_Q16 = 0; - subfr = 0; - for( i = 0; i < psDec->nb_subfr; i++ ) { - if( psDecCtrl->Gains_Q16[ i ] > max_Gain_Q16 ) { - max_Gain_Q16 = psDecCtrl->Gains_Q16[ i ]; - subfr = i; - } - } - /* Update CNG excitation buffer with excitation from this subframe */ - silk_memmove( &psCNG->CNG_exc_buf_Q14[ psDec->subfr_length ], psCNG->CNG_exc_buf_Q14, ( psDec->nb_subfr - 1 ) * psDec->subfr_length * sizeof( opus_int32 ) ); - silk_memcpy( psCNG->CNG_exc_buf_Q14, &psDec->exc_Q14[ subfr * psDec->subfr_length ], psDec->subfr_length * sizeof( opus_int32 ) ); - - /* Smooth gains */ - for( i = 0; i < psDec->nb_subfr; i++ ) { - psCNG->CNG_smth_Gain_Q16 += silk_SMULWB( psDecCtrl->Gains_Q16[ i ] - psCNG->CNG_smth_Gain_Q16, CNG_GAIN_SMTH_Q16 ); - /* If the smoothed gain is 3 dB greater than this subframe's gain, use this subframe's gain to adapt faster. */ - if( silk_SMULWW( psCNG->CNG_smth_Gain_Q16, CNG_GAIN_SMTH_THRESHOLD_Q16 ) > psDecCtrl->Gains_Q16[ i ] ) { - psCNG->CNG_smth_Gain_Q16 = psDecCtrl->Gains_Q16[ i ]; - } - } - } - - /* Add CNG when packet is lost or during DTX */ - if( psDec->lossCnt ) { - VARDECL( opus_int32, CNG_sig_Q14 ); - ALLOC( CNG_sig_Q14, length + MAX_LPC_ORDER, opus_int32 ); - - /* Generate CNG excitation */ - gain_Q16 = silk_SMULWW( psDec->sPLC.randScale_Q14, psDec->sPLC.prevGain_Q16[1] ); - if( gain_Q16 >= (1 << 21) || psCNG->CNG_smth_Gain_Q16 > (1 << 23) ) { - gain_Q16 = silk_SMULTT( gain_Q16, gain_Q16 ); - gain_Q16 = silk_SUB_LSHIFT32(silk_SMULTT( psCNG->CNG_smth_Gain_Q16, psCNG->CNG_smth_Gain_Q16 ), gain_Q16, 5 ); - gain_Q16 = silk_LSHIFT32( silk_SQRT_APPROX( gain_Q16 ), 16 ); - } else { - gain_Q16 = silk_SMULWW( gain_Q16, gain_Q16 ); - gain_Q16 = silk_SUB_LSHIFT32(silk_SMULWW( psCNG->CNG_smth_Gain_Q16, psCNG->CNG_smth_Gain_Q16 ), gain_Q16, 5 ); - gain_Q16 = silk_LSHIFT32( silk_SQRT_APPROX( gain_Q16 ), 8 ); - } - gain_Q10 = silk_RSHIFT( gain_Q16, 6 ); - - silk_CNG_exc( CNG_sig_Q14 + MAX_LPC_ORDER, psCNG->CNG_exc_buf_Q14, length, &psCNG->rand_seed ); - - /* Convert CNG NLSF to filter representation */ - silk_NLSF2A( A_Q12, psCNG->CNG_smth_NLSF_Q15, psDec->LPC_order, psDec->arch ); - - /* Generate CNG signal, by synthesis filtering */ - silk_memcpy( CNG_sig_Q14, psCNG->CNG_synth_state, MAX_LPC_ORDER * sizeof( opus_int32 ) ); - celt_assert( psDec->LPC_order == 10 || psDec->LPC_order == 16 ); - for( i = 0; i < length; i++ ) { - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LPC_pred_Q10 = silk_RSHIFT( psDec->LPC_order, 1 ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 1 ], A_Q12[ 0 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 2 ], A_Q12[ 1 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 3 ], A_Q12[ 2 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 4 ], A_Q12[ 3 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 5 ], A_Q12[ 4 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 6 ], A_Q12[ 5 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 7 ], A_Q12[ 6 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 8 ], A_Q12[ 7 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 9 ], A_Q12[ 8 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 10 ], A_Q12[ 9 ] ); - if( psDec->LPC_order == 16 ) { - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 11 ], A_Q12[ 10 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 12 ], A_Q12[ 11 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 13 ], A_Q12[ 12 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 14 ], A_Q12[ 13 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 15 ], A_Q12[ 14 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, CNG_sig_Q14[ MAX_LPC_ORDER + i - 16 ], A_Q12[ 15 ] ); - } - - /* Update states */ - CNG_sig_Q14[ MAX_LPC_ORDER + i ] = silk_ADD_SAT32( CNG_sig_Q14[ MAX_LPC_ORDER + i ], silk_LSHIFT_SAT32( LPC_pred_Q10, 4 ) ); - - /* Scale with Gain and add to input signal */ - frame[ i ] = (opus_int16)silk_ADD_SAT16( frame[ i ], silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( CNG_sig_Q14[ MAX_LPC_ORDER + i ], gain_Q10 ), 8 ) ) ); - - } - silk_memcpy( psCNG->CNG_synth_state, &CNG_sig_Q14[ length ], MAX_LPC_ORDER * sizeof( opus_int32 ) ); - } else { - silk_memset( psCNG->CNG_synth_state, 0, psDec->LPC_order * sizeof( opus_int32 ) ); - } - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/HP_variable_cutoff.c b/Engine/lib/opus/silk/HP_variable_cutoff.c deleted file mode 100644 index bbe10f04c..000000000 --- a/Engine/lib/opus/silk/HP_variable_cutoff.c +++ /dev/null @@ -1,77 +0,0 @@ -/*********************************************************************** -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" -#endif -#ifdef FIXED_POINT -#include "main_FIX.h" -#else -#include "main_FLP.h" -#endif -#include "tuning_parameters.h" - -/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */ -void silk_HP_variable_cutoff( - silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */ -) -{ - opus_int quality_Q15; - opus_int32 pitch_freq_Hz_Q16, pitch_freq_log_Q7, delta_freq_Q7; - silk_encoder_state *psEncC1 = &state_Fxx[ 0 ].sCmn; - - /* Adaptive cutoff frequency: estimate low end of pitch frequency range */ - if( psEncC1->prevSignalType == TYPE_VOICED ) { - /* difference, in log domain */ - pitch_freq_Hz_Q16 = silk_DIV32_16( silk_LSHIFT( silk_MUL( psEncC1->fs_kHz, 1000 ), 16 ), psEncC1->prevLag ); - pitch_freq_log_Q7 = silk_lin2log( pitch_freq_Hz_Q16 ) - ( 16 << 7 ); - - /* adjustment based on quality */ - quality_Q15 = psEncC1->input_quality_bands_Q15[ 0 ]; - pitch_freq_log_Q7 = silk_SMLAWB( pitch_freq_log_Q7, silk_SMULWB( silk_LSHIFT( -quality_Q15, 2 ), quality_Q15 ), - pitch_freq_log_Q7 - ( silk_lin2log( SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 16 ) ) - ( 16 << 7 ) ) ); - - /* delta_freq = pitch_freq_log - psEnc->variable_HP_smth1; */ - delta_freq_Q7 = pitch_freq_log_Q7 - silk_RSHIFT( psEncC1->variable_HP_smth1_Q15, 8 ); - if( delta_freq_Q7 < 0 ) { - /* less smoothing for decreasing pitch frequency, to track something close to the minimum */ - delta_freq_Q7 = silk_MUL( delta_freq_Q7, 3 ); - } - - /* limit delta, to reduce impact of outliers in pitch estimation */ - delta_freq_Q7 = silk_LIMIT_32( delta_freq_Q7, -SILK_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ), SILK_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ) ); - - /* update smoother */ - psEncC1->variable_HP_smth1_Q15 = silk_SMLAWB( psEncC1->variable_HP_smth1_Q15, - silk_SMULBB( psEncC1->speech_activity_Q8, delta_freq_Q7 ), SILK_FIX_CONST( VARIABLE_HP_SMTH_COEF1, 16 ) ); - - /* limit frequency range */ - psEncC1->variable_HP_smth1_Q15 = silk_LIMIT_32( psEncC1->variable_HP_smth1_Q15, - silk_LSHIFT( silk_lin2log( VARIABLE_HP_MIN_CUTOFF_HZ ), 8 ), - silk_LSHIFT( silk_lin2log( VARIABLE_HP_MAX_CUTOFF_HZ ), 8 ) ); - } -} diff --git a/Engine/lib/opus/silk/Inlines.h b/Engine/lib/opus/silk/Inlines.h deleted file mode 100644 index ec986cdfd..000000000 --- a/Engine/lib/opus/silk/Inlines.h +++ /dev/null @@ -1,188 +0,0 @@ -/*********************************************************************** -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. -***********************************************************************/ - -/*! \file silk_Inlines.h - * \brief silk_Inlines.h defines OPUS_INLINE signal processing functions. - */ - -#ifndef SILK_FIX_INLINES_H -#define SILK_FIX_INLINES_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* count leading zeros of opus_int64 */ -static OPUS_INLINE opus_int32 silk_CLZ64( opus_int64 in ) -{ - opus_int32 in_upper; - - in_upper = (opus_int32)silk_RSHIFT64(in, 32); - if (in_upper == 0) { - /* Search in the lower 32 bits */ - return 32 + silk_CLZ32( (opus_int32) in ); - } else { - /* Search in the upper 32 bits */ - return silk_CLZ32( in_upper ); - } -} - -/* get number of leading zeros and fractional part (the bits right after the leading one */ -static OPUS_INLINE void silk_CLZ_FRAC( - opus_int32 in, /* I input */ - opus_int32 *lz, /* O number of leading zeros */ - opus_int32 *frac_Q7 /* O the 7 bits right after the leading one */ -) -{ - opus_int32 lzeros = silk_CLZ32(in); - - * lz = lzeros; - * frac_Q7 = silk_ROR32(in, 24 - lzeros) & 0x7f; -} - -/* Approximation of square root */ -/* Accuracy: < +/- 10% for output values > 15 */ -/* < +/- 2.5% for output values > 120 */ -static OPUS_INLINE opus_int32 silk_SQRT_APPROX( opus_int32 x ) -{ - opus_int32 y, lz, frac_Q7; - - if( x <= 0 ) { - return 0; - } - - silk_CLZ_FRAC(x, &lz, &frac_Q7); - - if( lz & 1 ) { - y = 32768; - } else { - y = 46214; /* 46214 = sqrt(2) * 32768 */ - } - - /* get scaling right */ - y >>= silk_RSHIFT(lz, 1); - - /* increment using fractional part of input */ - y = silk_SMLAWB(y, y, silk_SMULBB(213, frac_Q7)); - - return y; -} - -/* Divide two int32 values and return result as int32 in a given Q-domain */ -static OPUS_INLINE opus_int32 silk_DIV32_varQ( /* O returns a good approximation of "(a32 << Qres) / b32" */ - const opus_int32 a32, /* I numerator (Q0) */ - const opus_int32 b32, /* I denominator (Q0) */ - const opus_int Qres /* I Q-domain of result (>= 0) */ -) -{ - opus_int a_headrm, b_headrm, lshift; - opus_int32 b32_inv, a32_nrm, b32_nrm, result; - - silk_assert( b32 != 0 ); - silk_assert( Qres >= 0 ); - - /* Compute number of bits head room and normalize inputs */ - a_headrm = silk_CLZ32( silk_abs(a32) ) - 1; - a32_nrm = silk_LSHIFT(a32, a_headrm); /* Q: a_headrm */ - b_headrm = silk_CLZ32( silk_abs(b32) ) - 1; - b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */ - - /* Inverse of b32, with 14 bits of precision */ - b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */ - - /* First approximation */ - result = silk_SMULWB(a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */ - - /* Compute residual by subtracting product of denominator and first approximation */ - /* It's OK to overflow because the final value of a32_nrm should always be small */ - a32_nrm = silk_SUB32_ovflw(a32_nrm, silk_LSHIFT_ovflw( silk_SMMUL(b32_nrm, result), 3 )); /* Q: a_headrm */ - - /* Refinement */ - result = silk_SMLAWB(result, a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */ - - /* Convert to Qres domain */ - lshift = 29 + a_headrm - b_headrm - Qres; - if( lshift < 0 ) { - return silk_LSHIFT_SAT32(result, -lshift); - } else { - if( lshift < 32){ - return silk_RSHIFT(result, lshift); - } else { - /* Avoid undefined result */ - return 0; - } - } -} - -/* Invert int32 value and return result as int32 in a given Q-domain */ -static OPUS_INLINE opus_int32 silk_INVERSE32_varQ( /* O returns a good approximation of "(1 << Qres) / b32" */ - const opus_int32 b32, /* I denominator (Q0) */ - const opus_int Qres /* I Q-domain of result (> 0) */ -) -{ - opus_int b_headrm, lshift; - opus_int32 b32_inv, b32_nrm, err_Q32, result; - - silk_assert( b32 != 0 ); - silk_assert( Qres > 0 ); - - /* Compute number of bits head room and normalize input */ - b_headrm = silk_CLZ32( silk_abs(b32) ) - 1; - b32_nrm = silk_LSHIFT(b32, b_headrm); /* Q: b_headrm */ - - /* Inverse of b32, with 14 bits of precision */ - b32_inv = silk_DIV32_16( silk_int32_MAX >> 2, silk_RSHIFT(b32_nrm, 16) ); /* Q: 29 + 16 - b_headrm */ - - /* First approximation */ - result = silk_LSHIFT(b32_inv, 16); /* Q: 61 - b_headrm */ - - /* Compute residual by subtracting product of denominator and first approximation from one */ - err_Q32 = silk_LSHIFT( ((opus_int32)1<<29) - silk_SMULWB(b32_nrm, b32_inv), 3 ); /* Q32 */ - - /* Refinement */ - result = silk_SMLAWW(result, err_Q32, b32_inv); /* Q: 61 - b_headrm */ - - /* Convert to Qres domain */ - lshift = 61 - b_headrm - Qres; - if( lshift <= 0 ) { - return silk_LSHIFT_SAT32(result, -lshift); - } else { - if( lshift < 32){ - return silk_RSHIFT(result, lshift); - }else{ - /* Avoid undefined result */ - return 0; - } - } -} - -#ifdef __cplusplus -} -#endif - -#endif /* SILK_FIX_INLINES_H */ diff --git a/Engine/lib/opus/silk/LPC_analysis_filter.c b/Engine/lib/opus/silk/LPC_analysis_filter.c deleted file mode 100644 index d34b5eb70..000000000 --- a/Engine/lib/opus/silk/LPC_analysis_filter.c +++ /dev/null @@ -1,111 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "celt_lpc.h" - -/*******************************************/ -/* LPC analysis filter */ -/* NB! State is kept internally and the */ -/* filter always starts with zero state */ -/* first d output samples are set to zero */ -/*******************************************/ - -/* OPT: Using celt_fir() for this function should be faster, but it may cause - integer overflows in intermediate values (not final results), which the - current implementation silences by casting to unsigned. Enabling - this should be safe in pretty much all cases, even though it is not technically - C89-compliant. */ -#define USE_CELT_FIR 0 - -void silk_LPC_analysis_filter( - opus_int16 *out, /* O Output signal */ - const opus_int16 *in, /* I Input signal */ - const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */ - const opus_int32 len, /* I Signal length */ - const opus_int32 d, /* I Filter order */ - int arch /* I Run-time architecture */ -) -{ - opus_int j; -#if defined(FIXED_POINT) && USE_CELT_FIR - opus_int16 num[SILK_MAX_ORDER_LPC]; -#else - int ix; - opus_int32 out32_Q12, out32; - const opus_int16 *in_ptr; -#endif - - celt_assert( d >= 6 ); - celt_assert( (d & 1) == 0 ); - celt_assert( d <= len ); - -#if defined(FIXED_POINT) && USE_CELT_FIR - celt_assert( d <= SILK_MAX_ORDER_LPC ); - for ( j = 0; j < d; j++ ) { - num[ j ] = -B[ j ]; - } - celt_fir( in + d, num, out + d, len - d, d, arch ); - for ( j = 0; j < d; j++ ) { - out[ j ] = 0; - } -#else - (void)arch; - for( ix = d; ix < len; ix++ ) { - in_ptr = &in[ ix - 1 ]; - - out32_Q12 = silk_SMULBB( in_ptr[ 0 ], B[ 0 ] ); - /* Allowing wrap around so that two wraps can cancel each other. The rare - cases where the result wraps around can only be triggered by invalid streams*/ - out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -1 ], B[ 1 ] ); - out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -2 ], B[ 2 ] ); - out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -3 ], B[ 3 ] ); - out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -4 ], B[ 4 ] ); - out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -5 ], B[ 5 ] ); - for( j = 6; j < d; j += 2 ) { - out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -j ], B[ j ] ); - out32_Q12 = silk_SMLABB_ovflw( out32_Q12, in_ptr[ -j - 1 ], B[ j + 1 ] ); - } - - /* Subtract prediction */ - out32_Q12 = silk_SUB32_ovflw( silk_LSHIFT( (opus_int32)in_ptr[ 1 ], 12 ), out32_Q12 ); - - /* Scale to Q0 */ - out32 = silk_RSHIFT_ROUND( out32_Q12, 12 ); - - /* Saturate output */ - out[ ix ] = (opus_int16)silk_SAT16( out32 ); - } - - /* Set first d output samples to zero */ - silk_memset( out, 0, d * sizeof( opus_int16 ) ); -#endif -} diff --git a/Engine/lib/opus/silk/LPC_fit.c b/Engine/lib/opus/silk/LPC_fit.c deleted file mode 100644 index c0690a1fc..000000000 --- a/Engine/lib/opus/silk/LPC_fit.c +++ /dev/null @@ -1,82 +0,0 @@ -/*********************************************************************** -Copyright (c) 2013, Koen Vos. 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" -#endif - -#include "SigProc_FIX.h" - -/* Convert int32 coefficients to int16 coefs and make sure there's no wrap-around. - This logic is reused in _celt_lpc(). Any bug fixes should also be applied there. */ -void silk_LPC_fit( - opus_int16 *a_QOUT, /* O Output signal */ - opus_int32 *a_QIN, /* I/O Input signal */ - const opus_int QOUT, /* I Input Q domain */ - const opus_int QIN, /* I Input Q domain */ - const opus_int d /* I Filter order */ -) -{ - opus_int i, k, idx = 0; - opus_int32 maxabs, absval, chirp_Q16; - - /* Limit the maximum absolute value of the prediction coefficients, so that they'll fit in int16 */ - for( i = 0; i < 10; i++ ) { - /* Find maximum absolute value and its index */ - maxabs = 0; - for( k = 0; k < d; k++ ) { - absval = silk_abs( a_QIN[k] ); - if( absval > maxabs ) { - maxabs = absval; - idx = k; - } - } - maxabs = silk_RSHIFT_ROUND( maxabs, QIN - QOUT ); - - if( maxabs > silk_int16_MAX ) { - /* Reduce magnitude of prediction coefficients */ - maxabs = silk_min( maxabs, 163838 ); /* ( silk_int32_MAX >> 14 ) + silk_int16_MAX = 163838 */ - chirp_Q16 = SILK_FIX_CONST( 0.999, 16 ) - silk_DIV32( silk_LSHIFT( maxabs - silk_int16_MAX, 14 ), - silk_RSHIFT32( silk_MUL( maxabs, idx + 1), 2 ) ); - silk_bwexpander_32( a_QIN, d, chirp_Q16 ); - } else { - break; - } - } - - if( i == 10 ) { - /* Reached the last iteration, clip the coefficients */ - for( k = 0; k < d; k++ ) { - a_QOUT[ k ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( a_QIN[ k ], QIN - QOUT ) ); - a_QIN[ k ] = silk_LSHIFT( (opus_int32)a_QOUT[ k ], QIN - QOUT ); - } - } else { - for( k = 0; k < d; k++ ) { - a_QOUT[ k ] = (opus_int16)silk_RSHIFT_ROUND( a_QIN[ k ], QIN - QOUT ); - } - } -} diff --git a/Engine/lib/opus/silk/LPC_inv_pred_gain.c b/Engine/lib/opus/silk/LPC_inv_pred_gain.c deleted file mode 100644 index a3746a6ef..000000000 --- a/Engine/lib/opus/silk/LPC_inv_pred_gain.c +++ /dev/null @@ -1,141 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "define.h" - -#define QA 24 -#define A_LIMIT SILK_FIX_CONST( 0.99975, QA ) - -#define MUL32_FRAC_Q(a32, b32, Q) ((opus_int32)(silk_RSHIFT_ROUND64(silk_SMULL(a32, b32), Q))) - -/* Compute inverse of LPC prediction gain, and */ -/* test if LPC coefficients are stable (all poles within unit circle) */ -static opus_int32 LPC_inverse_pred_gain_QA_c( /* O Returns inverse prediction gain in energy domain, Q30 */ - opus_int32 A_QA[ SILK_MAX_ORDER_LPC ], /* I Prediction coefficients */ - const opus_int order /* I Prediction order */ -) -{ - opus_int k, n, mult2Q; - opus_int32 invGain_Q30, rc_Q31, rc_mult1_Q30, rc_mult2, tmp1, tmp2; - - invGain_Q30 = SILK_FIX_CONST( 1, 30 ); - for( k = order - 1; k > 0; k-- ) { - /* Check for stability */ - if( ( A_QA[ k ] > A_LIMIT ) || ( A_QA[ k ] < -A_LIMIT ) ) { - return 0; - } - - /* Set RC equal to negated AR coef */ - rc_Q31 = -silk_LSHIFT( A_QA[ k ], 31 - QA ); - - /* rc_mult1_Q30 range: [ 1 : 2^30 ] */ - rc_mult1_Q30 = silk_SUB32( SILK_FIX_CONST( 1, 30 ), silk_SMMUL( rc_Q31, rc_Q31 ) ); - silk_assert( rc_mult1_Q30 > ( 1 << 15 ) ); /* reduce A_LIMIT if fails */ - silk_assert( rc_mult1_Q30 <= ( 1 << 30 ) ); - - /* Update inverse gain */ - /* invGain_Q30 range: [ 0 : 2^30 ] */ - invGain_Q30 = silk_LSHIFT( silk_SMMUL( invGain_Q30, rc_mult1_Q30 ), 2 ); - silk_assert( invGain_Q30 >= 0 ); - silk_assert( invGain_Q30 <= ( 1 << 30 ) ); - if( invGain_Q30 < SILK_FIX_CONST( 1.0f / MAX_PREDICTION_POWER_GAIN, 30 ) ) { - return 0; - } - - /* rc_mult2 range: [ 2^30 : silk_int32_MAX ] */ - mult2Q = 32 - silk_CLZ32( silk_abs( rc_mult1_Q30 ) ); - rc_mult2 = silk_INVERSE32_varQ( rc_mult1_Q30, mult2Q + 30 ); - - /* Update AR coefficient */ - for( n = 0; n < (k + 1) >> 1; n++ ) { - opus_int64 tmp64; - tmp1 = A_QA[ n ]; - tmp2 = A_QA[ k - n - 1 ]; - tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( silk_SUB_SAT32(tmp1, - MUL32_FRAC_Q( tmp2, rc_Q31, 31 ) ), rc_mult2 ), mult2Q); - if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) { - return 0; - } - A_QA[ n ] = ( opus_int32 )tmp64; - tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( silk_SUB_SAT32(tmp2, - MUL32_FRAC_Q( tmp1, rc_Q31, 31 ) ), rc_mult2), mult2Q); - if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) { - return 0; - } - A_QA[ k - n - 1 ] = ( opus_int32 )tmp64; - } - } - - /* Check for stability */ - if( ( A_QA[ k ] > A_LIMIT ) || ( A_QA[ k ] < -A_LIMIT ) ) { - return 0; - } - - /* Set RC equal to negated AR coef */ - rc_Q31 = -silk_LSHIFT( A_QA[ 0 ], 31 - QA ); - - /* Range: [ 1 : 2^30 ] */ - rc_mult1_Q30 = silk_SUB32( SILK_FIX_CONST( 1, 30 ), silk_SMMUL( rc_Q31, rc_Q31 ) ); - - /* Update inverse gain */ - /* Range: [ 0 : 2^30 ] */ - invGain_Q30 = silk_LSHIFT( silk_SMMUL( invGain_Q30, rc_mult1_Q30 ), 2 ); - silk_assert( invGain_Q30 >= 0 ); - silk_assert( invGain_Q30 <= ( 1 << 30 ) ); - if( invGain_Q30 < SILK_FIX_CONST( 1.0f / MAX_PREDICTION_POWER_GAIN, 30 ) ) { - return 0; - } - - return invGain_Q30; -} - -/* For input in Q12 domain */ -opus_int32 silk_LPC_inverse_pred_gain_c( /* O Returns inverse prediction gain in energy domain, Q30 */ - const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ - const opus_int order /* I Prediction order */ -) -{ - opus_int k; - opus_int32 Atmp_QA[ SILK_MAX_ORDER_LPC ]; - opus_int32 DC_resp = 0; - - /* Increase Q domain of the AR coefficients */ - for( k = 0; k < order; k++ ) { - DC_resp += (opus_int32)A_Q12[ k ]; - Atmp_QA[ k ] = silk_LSHIFT32( (opus_int32)A_Q12[ k ], QA - 12 ); - } - /* If the DC is unstable, we don't even need to do the full calculations */ - if( DC_resp >= 4096 ) { - return 0; - } - return LPC_inverse_pred_gain_QA_c( Atmp_QA, order ); -} diff --git a/Engine/lib/opus/silk/LP_variable_cutoff.c b/Engine/lib/opus/silk/LP_variable_cutoff.c deleted file mode 100644 index 79112ad35..000000000 --- a/Engine/lib/opus/silk/LP_variable_cutoff.c +++ /dev/null @@ -1,135 +0,0 @@ -/*********************************************************************** -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" -#endif - -/* - Elliptic/Cauer filters designed with 0.1 dB passband ripple, - 80 dB minimum stopband attenuation, and - [0.95 : 0.15 : 0.35] normalized cut off frequencies. -*/ - -#include "main.h" - -/* Helper function, interpolates the filter taps */ -static OPUS_INLINE void silk_LP_interpolate_filter_taps( - opus_int32 B_Q28[ TRANSITION_NB ], - opus_int32 A_Q28[ TRANSITION_NA ], - const opus_int ind, - const opus_int32 fac_Q16 -) -{ - opus_int nb, na; - - if( ind < TRANSITION_INT_NUM - 1 ) { - if( fac_Q16 > 0 ) { - if( fac_Q16 < 32768 ) { /* fac_Q16 is in range of a 16-bit int */ - /* Piece-wise linear interpolation of B and A */ - for( nb = 0; nb < TRANSITION_NB; nb++ ) { - B_Q28[ nb ] = silk_SMLAWB( - silk_Transition_LP_B_Q28[ ind ][ nb ], - silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] - - silk_Transition_LP_B_Q28[ ind ][ nb ], - fac_Q16 ); - } - for( na = 0; na < TRANSITION_NA; na++ ) { - A_Q28[ na ] = silk_SMLAWB( - silk_Transition_LP_A_Q28[ ind ][ na ], - silk_Transition_LP_A_Q28[ ind + 1 ][ na ] - - silk_Transition_LP_A_Q28[ ind ][ na ], - fac_Q16 ); - } - } else { /* ( fac_Q16 - ( 1 << 16 ) ) is in range of a 16-bit int */ - silk_assert( fac_Q16 - ( 1 << 16 ) == silk_SAT16( fac_Q16 - ( 1 << 16 ) ) ); - /* Piece-wise linear interpolation of B and A */ - for( nb = 0; nb < TRANSITION_NB; nb++ ) { - B_Q28[ nb ] = silk_SMLAWB( - silk_Transition_LP_B_Q28[ ind + 1 ][ nb ], - silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] - - silk_Transition_LP_B_Q28[ ind ][ nb ], - fac_Q16 - ( (opus_int32)1 << 16 ) ); - } - for( na = 0; na < TRANSITION_NA; na++ ) { - A_Q28[ na ] = silk_SMLAWB( - silk_Transition_LP_A_Q28[ ind + 1 ][ na ], - silk_Transition_LP_A_Q28[ ind + 1 ][ na ] - - silk_Transition_LP_A_Q28[ ind ][ na ], - fac_Q16 - ( (opus_int32)1 << 16 ) ); - } - } - } else { - silk_memcpy( B_Q28, silk_Transition_LP_B_Q28[ ind ], TRANSITION_NB * sizeof( opus_int32 ) ); - silk_memcpy( A_Q28, silk_Transition_LP_A_Q28[ ind ], TRANSITION_NA * sizeof( opus_int32 ) ); - } - } else { - silk_memcpy( B_Q28, silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NB * sizeof( opus_int32 ) ); - silk_memcpy( A_Q28, silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NA * sizeof( opus_int32 ) ); - } -} - -/* Low-pass filter with variable cutoff frequency based on */ -/* piece-wise linear interpolation between elliptic filters */ -/* Start by setting psEncC->mode <> 0; */ -/* Deactivate by setting psEncC->mode = 0; */ -void silk_LP_variable_cutoff( - silk_LP_state *psLP, /* I/O LP filter state */ - opus_int16 *frame, /* I/O Low-pass filtered output signal */ - const opus_int frame_length /* I Frame length */ -) -{ - opus_int32 B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0; - opus_int ind = 0; - - silk_assert( psLP->transition_frame_no >= 0 && psLP->transition_frame_no <= TRANSITION_FRAMES ); - - /* Run filter if needed */ - if( psLP->mode != 0 ) { - /* Calculate index and interpolation factor for interpolation */ -#if( TRANSITION_INT_STEPS == 64 ) - fac_Q16 = silk_LSHIFT( TRANSITION_FRAMES - psLP->transition_frame_no, 16 - 6 ); -#else - fac_Q16 = silk_DIV32_16( silk_LSHIFT( TRANSITION_FRAMES - psLP->transition_frame_no, 16 ), TRANSITION_FRAMES ); -#endif - ind = silk_RSHIFT( fac_Q16, 16 ); - fac_Q16 -= silk_LSHIFT( ind, 16 ); - - silk_assert( ind >= 0 ); - silk_assert( ind < TRANSITION_INT_NUM ); - - /* Interpolate filter coefficients */ - silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 ); - - /* Update transition frame number for next frame */ - psLP->transition_frame_no = silk_LIMIT( psLP->transition_frame_no + psLP->mode, 0, TRANSITION_FRAMES ); - - /* ARMA low-pass filtering */ - silk_assert( TRANSITION_NB == 3 && TRANSITION_NA == 2 ); - silk_biquad_alt_stride1( frame, B_Q28, A_Q28, psLP->In_LP_State, frame, frame_length); - } -} diff --git a/Engine/lib/opus/silk/MacroCount.h b/Engine/lib/opus/silk/MacroCount.h deleted file mode 100644 index dab2f57a6..000000000 --- a/Engine/lib/opus/silk/MacroCount.h +++ /dev/null @@ -1,710 +0,0 @@ -/*********************************************************************** -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 SIGPROCFIX_API_MACROCOUNT_H -#define SIGPROCFIX_API_MACROCOUNT_H - -#ifdef silk_MACRO_COUNT -#include -#define varDefine opus_int64 ops_count = 0; - -extern opus_int64 ops_count; - -static OPUS_INLINE opus_int64 silk_SaveCount(){ - return(ops_count); -} - -static OPUS_INLINE opus_int64 silk_SaveResetCount(){ - opus_int64 ret; - - ret = ops_count; - ops_count = 0; - return(ret); -} - -static OPUS_INLINE silk_PrintCount(){ - printf("ops_count = %d \n ", (opus_int32)ops_count); -} - -#undef silk_MUL -static OPUS_INLINE opus_int32 silk_MUL(opus_int32 a32, opus_int32 b32){ - opus_int32 ret; - ops_count += 4; - ret = a32 * b32; - return ret; -} - -#undef silk_MUL_uint -static OPUS_INLINE opus_uint32 silk_MUL_uint(opus_uint32 a32, opus_uint32 b32){ - opus_uint32 ret; - ops_count += 4; - ret = a32 * b32; - return ret; -} -#undef silk_MLA -static OPUS_INLINE opus_int32 silk_MLA(opus_int32 a32, opus_int32 b32, opus_int32 c32){ - opus_int32 ret; - ops_count += 4; - ret = a32 + b32 * c32; - return ret; -} - -#undef silk_MLA_uint -static OPUS_INLINE opus_int32 silk_MLA_uint(opus_uint32 a32, opus_uint32 b32, opus_uint32 c32){ - opus_uint32 ret; - ops_count += 4; - ret = a32 + b32 * c32; - return ret; -} - -#undef silk_SMULWB -static OPUS_INLINE opus_int32 silk_SMULWB(opus_int32 a32, opus_int32 b32){ - opus_int32 ret; - ops_count += 5; - ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16); - return ret; -} -#undef silk_SMLAWB -static OPUS_INLINE opus_int32 silk_SMLAWB(opus_int32 a32, opus_int32 b32, opus_int32 c32){ - opus_int32 ret; - ops_count += 5; - ret = ((a32) + ((((b32) >> 16) * (opus_int32)((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32))) >> 16))); - return ret; -} - -#undef silk_SMULWT -static OPUS_INLINE opus_int32 silk_SMULWT(opus_int32 a32, opus_int32 b32){ - opus_int32 ret; - ops_count += 4; - ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16); - return ret; -} -#undef silk_SMLAWT -static OPUS_INLINE opus_int32 silk_SMLAWT(opus_int32 a32, opus_int32 b32, opus_int32 c32){ - opus_int32 ret; - ops_count += 4; - ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16)) >> 16)); - return ret; -} - -#undef silk_SMULBB -static OPUS_INLINE opus_int32 silk_SMULBB(opus_int32 a32, opus_int32 b32){ - opus_int32 ret; - ops_count += 1; - ret = (opus_int32)((opus_int16)a32) * (opus_int32)((opus_int16)b32); - return ret; -} -#undef silk_SMLABB -static OPUS_INLINE opus_int32 silk_SMLABB(opus_int32 a32, opus_int32 b32, opus_int32 c32){ - opus_int32 ret; - ops_count += 1; - ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32); - return ret; -} - -#undef silk_SMULBT -static OPUS_INLINE opus_int32 silk_SMULBT(opus_int32 a32, opus_int32 b32 ){ - opus_int32 ret; - ops_count += 4; - ret = ((opus_int32)((opus_int16)a32)) * (b32 >> 16); - return ret; -} - -#undef silk_SMLABT -static OPUS_INLINE opus_int32 silk_SMLABT(opus_int32 a32, opus_int32 b32, opus_int32 c32){ - opus_int32 ret; - ops_count += 1; - ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16); - return ret; -} - -#undef silk_SMULTT -static OPUS_INLINE opus_int32 silk_SMULTT(opus_int32 a32, opus_int32 b32){ - opus_int32 ret; - ops_count += 1; - ret = (a32 >> 16) * (b32 >> 16); - return ret; -} - -#undef silk_SMLATT -static OPUS_INLINE opus_int32 silk_SMLATT(opus_int32 a32, opus_int32 b32, opus_int32 c32){ - opus_int32 ret; - ops_count += 1; - ret = a32 + (b32 >> 16) * (c32 >> 16); - return ret; -} - - -/* multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode)*/ -#undef silk_MLA_ovflw -#define silk_MLA_ovflw silk_MLA - -#undef silk_SMLABB_ovflw -#define silk_SMLABB_ovflw silk_SMLABB - -#undef silk_SMLABT_ovflw -#define silk_SMLABT_ovflw silk_SMLABT - -#undef silk_SMLATT_ovflw -#define silk_SMLATT_ovflw silk_SMLATT - -#undef silk_SMLAWB_ovflw -#define silk_SMLAWB_ovflw silk_SMLAWB - -#undef silk_SMLAWT_ovflw -#define silk_SMLAWT_ovflw silk_SMLAWT - -#undef silk_SMULL -static OPUS_INLINE opus_int64 silk_SMULL(opus_int32 a32, opus_int32 b32){ - opus_int64 ret; - ops_count += 8; - ret = ((opus_int64)(a32) * /*(opus_int64)*/(b32)); - return ret; -} - -#undef silk_SMLAL -static OPUS_INLINE opus_int64 silk_SMLAL(opus_int64 a64, opus_int32 b32, opus_int32 c32){ - opus_int64 ret; - ops_count += 8; - ret = a64 + ((opus_int64)(b32) * /*(opus_int64)*/(c32)); - return ret; -} -#undef silk_SMLALBB -static OPUS_INLINE opus_int64 silk_SMLALBB(opus_int64 a64, opus_int16 b16, opus_int16 c16){ - opus_int64 ret; - ops_count += 4; - ret = a64 + ((opus_int64)(b16) * /*(opus_int64)*/(c16)); - return ret; -} - -#undef SigProcFIX_CLZ16 -static OPUS_INLINE opus_int32 SigProcFIX_CLZ16(opus_int16 in16) -{ - opus_int32 out32 = 0; - ops_count += 10; - if( in16 == 0 ) { - return 16; - } - /* test nibbles */ - if( in16 & 0xFF00 ) { - if( in16 & 0xF000 ) { - in16 >>= 12; - } else { - out32 += 4; - in16 >>= 8; - } - } else { - if( in16 & 0xFFF0 ) { - out32 += 8; - in16 >>= 4; - } else { - out32 += 12; - } - } - /* test bits and return */ - if( in16 & 0xC ) { - if( in16 & 0x8 ) - return out32 + 0; - else - return out32 + 1; - } else { - if( in16 & 0xE ) - return out32 + 2; - else - return out32 + 3; - } -} - -#undef SigProcFIX_CLZ32 -static OPUS_INLINE opus_int32 SigProcFIX_CLZ32(opus_int32 in32) -{ - /* test highest 16 bits and convert to opus_int16 */ - ops_count += 2; - if( in32 & 0xFFFF0000 ) { - return SigProcFIX_CLZ16((opus_int16)(in32 >> 16)); - } else { - return SigProcFIX_CLZ16((opus_int16)in32) + 16; - } -} - -#undef silk_DIV32 -static OPUS_INLINE opus_int32 silk_DIV32(opus_int32 a32, opus_int32 b32){ - ops_count += 64; - return a32 / b32; -} - -#undef silk_DIV32_16 -static OPUS_INLINE opus_int32 silk_DIV32_16(opus_int32 a32, opus_int32 b32){ - ops_count += 32; - return a32 / b32; -} - -#undef silk_SAT8 -static OPUS_INLINE opus_int8 silk_SAT8(opus_int64 a){ - opus_int8 tmp; - ops_count += 1; - tmp = (opus_int8)((a) > silk_int8_MAX ? silk_int8_MAX : \ - ((a) < silk_int8_MIN ? silk_int8_MIN : (a))); - return(tmp); -} - -#undef silk_SAT16 -static OPUS_INLINE opus_int16 silk_SAT16(opus_int64 a){ - opus_int16 tmp; - ops_count += 1; - tmp = (opus_int16)((a) > silk_int16_MAX ? silk_int16_MAX : \ - ((a) < silk_int16_MIN ? silk_int16_MIN : (a))); - return(tmp); -} -#undef silk_SAT32 -static OPUS_INLINE opus_int32 silk_SAT32(opus_int64 a){ - opus_int32 tmp; - ops_count += 1; - tmp = (opus_int32)((a) > silk_int32_MAX ? silk_int32_MAX : \ - ((a) < silk_int32_MIN ? silk_int32_MIN : (a))); - return(tmp); -} -#undef silk_POS_SAT32 -static OPUS_INLINE opus_int32 silk_POS_SAT32(opus_int64 a){ - opus_int32 tmp; - ops_count += 1; - tmp = (opus_int32)((a) > silk_int32_MAX ? silk_int32_MAX : (a)); - return(tmp); -} - -#undef silk_ADD_POS_SAT8 -static OPUS_INLINE opus_int8 silk_ADD_POS_SAT8(opus_int64 a, opus_int64 b){ - opus_int8 tmp; - ops_count += 1; - tmp = (opus_int8)((((a)+(b)) & 0x80) ? silk_int8_MAX : ((a)+(b))); - return(tmp); -} -#undef silk_ADD_POS_SAT16 -static OPUS_INLINE opus_int16 silk_ADD_POS_SAT16(opus_int64 a, opus_int64 b){ - opus_int16 tmp; - ops_count += 1; - tmp = (opus_int16)((((a)+(b)) & 0x8000) ? silk_int16_MAX : ((a)+(b))); - return(tmp); -} - -#undef silk_ADD_POS_SAT32 -static OPUS_INLINE opus_int32 silk_ADD_POS_SAT32(opus_int64 a, opus_int64 b){ - opus_int32 tmp; - ops_count += 1; - tmp = (opus_int32)((((a)+(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b))); - return(tmp); -} - -#undef silk_LSHIFT8 -static OPUS_INLINE opus_int8 silk_LSHIFT8(opus_int8 a, opus_int32 shift){ - opus_int8 ret; - ops_count += 1; - ret = a << shift; - return ret; -} -#undef silk_LSHIFT16 -static OPUS_INLINE opus_int16 silk_LSHIFT16(opus_int16 a, opus_int32 shift){ - opus_int16 ret; - ops_count += 1; - ret = a << shift; - return ret; -} -#undef silk_LSHIFT32 -static OPUS_INLINE opus_int32 silk_LSHIFT32(opus_int32 a, opus_int32 shift){ - opus_int32 ret; - ops_count += 1; - ret = a << shift; - return ret; -} -#undef silk_LSHIFT64 -static OPUS_INLINE opus_int64 silk_LSHIFT64(opus_int64 a, opus_int shift){ - ops_count += 1; - return a << shift; -} - -#undef silk_LSHIFT_ovflw -static OPUS_INLINE opus_int32 silk_LSHIFT_ovflw(opus_int32 a, opus_int32 shift){ - ops_count += 1; - return a << shift; -} - -#undef silk_LSHIFT_uint -static OPUS_INLINE opus_uint32 silk_LSHIFT_uint(opus_uint32 a, opus_int32 shift){ - opus_uint32 ret; - ops_count += 1; - ret = a << shift; - return ret; -} - -#undef silk_RSHIFT8 -static OPUS_INLINE opus_int8 silk_RSHIFT8(opus_int8 a, opus_int32 shift){ - ops_count += 1; - return a >> shift; -} -#undef silk_RSHIFT16 -static OPUS_INLINE opus_int16 silk_RSHIFT16(opus_int16 a, opus_int32 shift){ - ops_count += 1; - return a >> shift; -} -#undef silk_RSHIFT32 -static OPUS_INLINE opus_int32 silk_RSHIFT32(opus_int32 a, opus_int32 shift){ - ops_count += 1; - return a >> shift; -} -#undef silk_RSHIFT64 -static OPUS_INLINE opus_int64 silk_RSHIFT64(opus_int64 a, opus_int64 shift){ - ops_count += 1; - return a >> shift; -} - -#undef silk_RSHIFT_uint -static OPUS_INLINE opus_uint32 silk_RSHIFT_uint(opus_uint32 a, opus_int32 shift){ - ops_count += 1; - return a >> shift; -} - -#undef silk_ADD_LSHIFT -static OPUS_INLINE opus_int32 silk_ADD_LSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){ - opus_int32 ret; - ops_count += 1; - ret = a + (b << shift); - return ret; /* shift >= 0*/ -} -#undef silk_ADD_LSHIFT32 -static OPUS_INLINE opus_int32 silk_ADD_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ - opus_int32 ret; - ops_count += 1; - ret = a + (b << shift); - return ret; /* shift >= 0*/ -} -#undef silk_ADD_LSHIFT_uint -static OPUS_INLINE opus_uint32 silk_ADD_LSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){ - opus_uint32 ret; - ops_count += 1; - ret = a + (b << shift); - return ret; /* shift >= 0*/ -} -#undef silk_ADD_RSHIFT -static OPUS_INLINE opus_int32 silk_ADD_RSHIFT(opus_int32 a, opus_int32 b, opus_int32 shift){ - opus_int32 ret; - ops_count += 1; - ret = a + (b >> shift); - return ret; /* shift > 0*/ -} -#undef silk_ADD_RSHIFT32 -static OPUS_INLINE opus_int32 silk_ADD_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ - opus_int32 ret; - ops_count += 1; - ret = a + (b >> shift); - return ret; /* shift > 0*/ -} -#undef silk_ADD_RSHIFT_uint -static OPUS_INLINE opus_uint32 silk_ADD_RSHIFT_uint(opus_uint32 a, opus_uint32 b, opus_int32 shift){ - opus_uint32 ret; - ops_count += 1; - ret = a + (b >> shift); - return ret; /* shift > 0*/ -} -#undef silk_SUB_LSHIFT32 -static OPUS_INLINE opus_int32 silk_SUB_LSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ - opus_int32 ret; - ops_count += 1; - ret = a - (b << shift); - return ret; /* shift >= 0*/ -} -#undef silk_SUB_RSHIFT32 -static OPUS_INLINE opus_int32 silk_SUB_RSHIFT32(opus_int32 a, opus_int32 b, opus_int32 shift){ - opus_int32 ret; - ops_count += 1; - ret = a - (b >> shift); - return ret; /* shift > 0*/ -} - -#undef silk_RSHIFT_ROUND -static OPUS_INLINE opus_int32 silk_RSHIFT_ROUND(opus_int32 a, opus_int32 shift){ - opus_int32 ret; - ops_count += 3; - ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; - return ret; -} - -#undef silk_RSHIFT_ROUND64 -static OPUS_INLINE opus_int64 silk_RSHIFT_ROUND64(opus_int64 a, opus_int32 shift){ - opus_int64 ret; - ops_count += 6; - ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; - return ret; -} - -#undef silk_abs_int64 -static OPUS_INLINE opus_int64 silk_abs_int64(opus_int64 a){ - ops_count += 1; - return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN*/ -} - -#undef silk_abs_int32 -static OPUS_INLINE opus_int32 silk_abs_int32(opus_int32 a){ - ops_count += 1; - return silk_abs(a); -} - - -#undef silk_min -static silk_min(a, b){ - ops_count += 1; - return (((a) < (b)) ? (a) : (b)); -} -#undef silk_max -static silk_max(a, b){ - ops_count += 1; - return (((a) > (b)) ? (a) : (b)); -} -#undef silk_sign -static silk_sign(a){ - ops_count += 1; - return ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 )); -} - -#undef silk_ADD16 -static OPUS_INLINE opus_int16 silk_ADD16(opus_int16 a, opus_int16 b){ - opus_int16 ret; - ops_count += 1; - ret = a + b; - return ret; -} - -#undef silk_ADD32 -static OPUS_INLINE opus_int32 silk_ADD32(opus_int32 a, opus_int32 b){ - opus_int32 ret; - ops_count += 1; - ret = a + b; - return ret; -} - -#undef silk_ADD64 -static OPUS_INLINE opus_int64 silk_ADD64(opus_int64 a, opus_int64 b){ - opus_int64 ret; - ops_count += 2; - ret = a + b; - return ret; -} - -#undef silk_SUB16 -static OPUS_INLINE opus_int16 silk_SUB16(opus_int16 a, opus_int16 b){ - opus_int16 ret; - ops_count += 1; - ret = a - b; - return ret; -} - -#undef silk_SUB32 -static OPUS_INLINE opus_int32 silk_SUB32(opus_int32 a, opus_int32 b){ - opus_int32 ret; - ops_count += 1; - ret = a - b; - return ret; -} - -#undef silk_SUB64 -static OPUS_INLINE opus_int64 silk_SUB64(opus_int64 a, opus_int64 b){ - opus_int64 ret; - ops_count += 2; - ret = a - b; - return ret; -} - -#undef silk_ADD_SAT16 -static OPUS_INLINE opus_int16 silk_ADD_SAT16( opus_int16 a16, opus_int16 b16 ) { - opus_int16 res; - /* Nb will be counted in AKP_add32 and silk_SAT16*/ - res = (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a16), (b16) ) ); - return res; -} - -#undef silk_ADD_SAT32 -static OPUS_INLINE opus_int32 silk_ADD_SAT32(opus_int32 a32, opus_int32 b32){ - opus_int32 res; - ops_count += 1; - res = ((((a32) + (b32)) & 0x80000000) == 0 ? \ - ((((a32) & (b32)) & 0x80000000) != 0 ? silk_int32_MIN : (a32)+(b32)) : \ - ((((a32) | (b32)) & 0x80000000) == 0 ? silk_int32_MAX : (a32)+(b32)) ); - return res; -} - -#undef silk_ADD_SAT64 -static OPUS_INLINE opus_int64 silk_ADD_SAT64( opus_int64 a64, opus_int64 b64 ) { - opus_int64 res; - ops_count += 1; - res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \ - ((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a64)+(b64)) : \ - ((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a64)+(b64)) ); - return res; -} - -#undef silk_SUB_SAT16 -static OPUS_INLINE opus_int16 silk_SUB_SAT16( opus_int16 a16, opus_int16 b16 ) { - opus_int16 res; - silk_assert(0); - /* Nb will be counted in sub-macros*/ - res = (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a16), (b16) ) ); - return res; -} - -#undef silk_SUB_SAT32 -static OPUS_INLINE opus_int32 silk_SUB_SAT32( opus_int32 a32, opus_int32 b32 ) { - opus_int32 res; - ops_count += 1; - res = ((((a32)-(b32)) & 0x80000000) == 0 ? \ - (( (a32) & ((b32)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a32)-(b32)) : \ - ((((a32)^0x80000000) & (b32) & 0x80000000) ? silk_int32_MAX : (a32)-(b32)) ); - return res; -} - -#undef silk_SUB_SAT64 -static OPUS_INLINE opus_int64 silk_SUB_SAT64( opus_int64 a64, opus_int64 b64 ) { - opus_int64 res; - ops_count += 1; - res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \ - (( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a64)-(b64)) : \ - ((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? silk_int64_MAX : (a64)-(b64)) ); - - return res; -} - -#undef silk_SMULWW -static OPUS_INLINE opus_int32 silk_SMULWW(opus_int32 a32, opus_int32 b32){ - opus_int32 ret; - /* Nb will be counted in sub-macros*/ - ret = silk_MLA(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16)); - return ret; -} - -#undef silk_SMLAWW -static OPUS_INLINE opus_int32 silk_SMLAWW(opus_int32 a32, opus_int32 b32, opus_int32 c32){ - opus_int32 ret; - /* Nb will be counted in sub-macros*/ - ret = silk_MLA(silk_SMLAWB((a32), (b32), (c32)), (b32), silk_RSHIFT_ROUND((c32), 16)); - return ret; -} - -#undef silk_min_int -static OPUS_INLINE opus_int silk_min_int(opus_int a, opus_int b) -{ - ops_count += 1; - return (((a) < (b)) ? (a) : (b)); -} - -#undef silk_min_16 -static OPUS_INLINE opus_int16 silk_min_16(opus_int16 a, opus_int16 b) -{ - ops_count += 1; - return (((a) < (b)) ? (a) : (b)); -} -#undef silk_min_32 -static OPUS_INLINE opus_int32 silk_min_32(opus_int32 a, opus_int32 b) -{ - ops_count += 1; - return (((a) < (b)) ? (a) : (b)); -} -#undef silk_min_64 -static OPUS_INLINE opus_int64 silk_min_64(opus_int64 a, opus_int64 b) -{ - ops_count += 1; - return (((a) < (b)) ? (a) : (b)); -} - -/* silk_min() versions with typecast in the function call */ -#undef silk_max_int -static OPUS_INLINE opus_int silk_max_int(opus_int a, opus_int b) -{ - ops_count += 1; - return (((a) > (b)) ? (a) : (b)); -} -#undef silk_max_16 -static OPUS_INLINE opus_int16 silk_max_16(opus_int16 a, opus_int16 b) -{ - ops_count += 1; - return (((a) > (b)) ? (a) : (b)); -} -#undef silk_max_32 -static OPUS_INLINE opus_int32 silk_max_32(opus_int32 a, opus_int32 b) -{ - ops_count += 1; - return (((a) > (b)) ? (a) : (b)); -} - -#undef silk_max_64 -static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b) -{ - ops_count += 1; - return (((a) > (b)) ? (a) : (b)); -} - - -#undef silk_LIMIT_int -static OPUS_INLINE opus_int silk_LIMIT_int(opus_int a, opus_int limit1, opus_int limit2) -{ - opus_int ret; - ops_count += 6; - - ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \ - : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a)))); - - return(ret); -} - -#undef silk_LIMIT_16 -static OPUS_INLINE opus_int16 silk_LIMIT_16(opus_int16 a, opus_int16 limit1, opus_int16 limit2) -{ - opus_int16 ret; - ops_count += 6; - - ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \ - : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a)))); - -return(ret); -} - - -#undef silk_LIMIT_32 -static OPUS_INLINE opus_int32 silk_LIMIT_32(opus_int32 a, opus_int32 limit1, opus_int32 limit2) -{ - opus_int32 ret; - ops_count += 6; - - ret = ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \ - : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a)))); - return(ret); -} - -#else -#define varDefine -#define silk_SaveCount() - -#endif -#endif - diff --git a/Engine/lib/opus/silk/MacroDebug.h b/Engine/lib/opus/silk/MacroDebug.h deleted file mode 100644 index 3110da9a7..000000000 --- a/Engine/lib/opus/silk/MacroDebug.h +++ /dev/null @@ -1,945 +0,0 @@ -/*********************************************************************** -Copyright (c) 2006-2011, Skype Limited. All rights reserved. -Copyright (C) 2012 Xiph.Org Foundation -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 MACRO_DEBUG_H -#define MACRO_DEBUG_H - -/* Redefine macro functions with extensive assertion in DEBUG mode. - As functions can't be undefined, this file can't work with SigProcFIX_MacroCount.h */ - -#if ( defined (FIXED_DEBUG) || ( 0 && defined (_DEBUG) ) ) && !defined (silk_MACRO_COUNT) - -#undef silk_ADD16 -#define silk_ADD16(a,b) silk_ADD16_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int16 silk_ADD16_(opus_int16 a, opus_int16 b, char *file, int line){ - opus_int16 ret; - - ret = a + b; - if ( ret != silk_ADD_SAT16( a, b ) ) - { - fprintf (stderr, "silk_ADD16(%d, %d) in %s: line %d\n", a, b, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_ADD32 -#define silk_ADD32(a,b) silk_ADD32_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_ADD32_(opus_int32 a, opus_int32 b, char *file, int line){ - opus_int32 ret; - - ret = (opus_int32)((opus_uint32)a + (opus_uint32)b); - if ( ret != silk_ADD_SAT32( a, b ) ) - { - fprintf (stderr, "silk_ADD32(%d, %d) in %s: line %d\n", a, b, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_ADD64 -#define silk_ADD64(a,b) silk_ADD64_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int64 silk_ADD64_(opus_int64 a, opus_int64 b, char *file, int line){ - opus_int64 ret; - - ret = a + b; - if ( ret != silk_ADD_SAT64( a, b ) ) - { - fprintf (stderr, "silk_ADD64(%lld, %lld) in %s: line %d\n", (long long)a, (long long)b, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_SUB16 -#define silk_SUB16(a,b) silk_SUB16_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int16 silk_SUB16_(opus_int16 a, opus_int16 b, char *file, int line){ - opus_int16 ret; - - ret = a - b; - if ( ret != silk_SUB_SAT16( a, b ) ) - { - fprintf (stderr, "silk_SUB16(%d, %d) in %s: line %d\n", a, b, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_SUB32 -#define silk_SUB32(a,b) silk_SUB32_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SUB32_(opus_int32 a, opus_int32 b, char *file, int line){ - opus_int64 ret; - - ret = a - (opus_int64)b; - if ( ret != silk_SUB_SAT32( a, b ) ) - { - fprintf (stderr, "silk_SUB32(%d, %d) in %s: line %d\n", a, b, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_SUB64 -#define silk_SUB64(a,b) silk_SUB64_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int64 silk_SUB64_(opus_int64 a, opus_int64 b, char *file, int line){ - opus_int64 ret; - - ret = a - b; - if ( ret != silk_SUB_SAT64( a, b ) ) - { - fprintf (stderr, "silk_SUB64(%lld, %lld) in %s: line %d\n", (long long)a, (long long)b, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_ADD_SAT16 -#define silk_ADD_SAT16(a,b) silk_ADD_SAT16_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int16 silk_ADD_SAT16_( opus_int16 a16, opus_int16 b16, char *file, int line) { - opus_int16 res; - res = (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a16), (b16) ) ); - if ( res != silk_SAT16( (opus_int32)a16 + (opus_int32)b16 ) ) - { - fprintf (stderr, "silk_ADD_SAT16(%d, %d) in %s: line %d\n", a16, b16, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return res; -} - -#undef silk_ADD_SAT32 -#define silk_ADD_SAT32(a,b) silk_ADD_SAT32_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_ADD_SAT32_(opus_int32 a32, opus_int32 b32, char *file, int line){ - opus_int32 res; - res = ((((opus_uint32)(a32) + (opus_uint32)(b32)) & 0x80000000) == 0 ? \ - ((((a32) & (b32)) & 0x80000000) != 0 ? silk_int32_MIN : (a32)+(b32)) : \ - ((((a32) | (b32)) & 0x80000000) == 0 ? silk_int32_MAX : (a32)+(b32)) ); - if ( res != silk_SAT32( (opus_int64)a32 + (opus_int64)b32 ) ) - { - fprintf (stderr, "silk_ADD_SAT32(%d, %d) in %s: line %d\n", a32, b32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return res; -} - -#undef silk_ADD_SAT64 -#define silk_ADD_SAT64(a,b) silk_ADD_SAT64_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int64 silk_ADD_SAT64_( opus_int64 a64, opus_int64 b64, char *file, int line) { - opus_int64 res; - int fail = 0; - res = ((((a64) + (b64)) & 0x8000000000000000LL) == 0 ? \ - ((((a64) & (b64)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a64)+(b64)) : \ - ((((a64) | (b64)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a64)+(b64)) ); - if( res != a64 + b64 ) { - /* Check that we saturated to the correct extreme value */ - if ( !(( res == silk_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( silk_int64_MAX >> 3 ) ) ) || - ( res == silk_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( silk_int64_MIN >> 3 ) ) ) ) ) - { - fail = 1; - } - } else { - /* Saturation not necessary */ - fail = res != a64 + b64; - } - if ( fail ) - { - fprintf (stderr, "silk_ADD_SAT64(%lld, %lld) in %s: line %d\n", (long long)a64, (long long)b64, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return res; -} - -#undef silk_SUB_SAT16 -#define silk_SUB_SAT16(a,b) silk_SUB_SAT16_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int16 silk_SUB_SAT16_( opus_int16 a16, opus_int16 b16, char *file, int line ) { - opus_int16 res; - res = (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a16), (b16) ) ); - if ( res != silk_SAT16( (opus_int32)a16 - (opus_int32)b16 ) ) - { - fprintf (stderr, "silk_SUB_SAT16(%d, %d) in %s: line %d\n", a16, b16, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return res; -} - -#undef silk_SUB_SAT32 -#define silk_SUB_SAT32(a,b) silk_SUB_SAT32_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SUB_SAT32_( opus_int32 a32, opus_int32 b32, char *file, int line ) { - opus_int32 res; - res = ((((opus_uint32)(a32)-(opus_uint32)(b32)) & 0x80000000) == 0 ? \ - (( (a32) & ((b32)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a32)-(b32)) : \ - ((((a32)^0x80000000) & (b32) & 0x80000000) ? silk_int32_MAX : (a32)-(b32)) ); - if ( res != silk_SAT32( (opus_int64)a32 - (opus_int64)b32 ) ) - { - fprintf (stderr, "silk_SUB_SAT32(%d, %d) in %s: line %d\n", a32, b32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return res; -} - -#undef silk_SUB_SAT64 -#define silk_SUB_SAT64(a,b) silk_SUB_SAT64_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int64 silk_SUB_SAT64_( opus_int64 a64, opus_int64 b64, char *file, int line ) { - opus_int64 res; - int fail = 0; - res = ((((a64)-(b64)) & 0x8000000000000000LL) == 0 ? \ - (( (a64) & ((b64)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a64)-(b64)) : \ - ((((a64)^0x8000000000000000LL) & (b64) & 0x8000000000000000LL) ? silk_int64_MAX : (a64)-(b64)) ); - if( res != a64 - b64 ) { - /* Check that we saturated to the correct extreme value */ - if( !(( res == silk_int64_MAX && ( ( a64 >> 1 ) + ( b64 >> 1 ) > ( silk_int64_MAX >> 3 ) ) ) || - ( res == silk_int64_MIN && ( ( a64 >> 1 ) + ( b64 >> 1 ) < ( silk_int64_MIN >> 3 ) ) ) )) - { - fail = 1; - } - } else { - /* Saturation not necessary */ - fail = res != a64 - b64; - } - if ( fail ) - { - fprintf (stderr, "silk_SUB_SAT64(%lld, %lld) in %s: line %d\n", (long long)a64, (long long)b64, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return res; -} - -#undef silk_MUL -#define silk_MUL(a,b) silk_MUL_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_MUL_(opus_int32 a32, opus_int32 b32, char *file, int line){ - opus_int32 ret; - opus_int64 ret64; - ret = (opus_int32)((opus_uint32)a32 * (opus_uint32)b32); - ret64 = (opus_int64)a32 * (opus_int64)b32; - if ( (opus_int64)ret != ret64 ) - { - fprintf (stderr, "silk_MUL(%d, %d) in %s: line %d\n", a32, b32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_MUL_uint -#define silk_MUL_uint(a,b) silk_MUL_uint_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_uint32 silk_MUL_uint_(opus_uint32 a32, opus_uint32 b32, char *file, int line){ - opus_uint32 ret; - ret = a32 * b32; - if ( (opus_uint64)ret != (opus_uint64)a32 * (opus_uint64)b32 ) - { - fprintf (stderr, "silk_MUL_uint(%u, %u) in %s: line %d\n", a32, b32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_MLA -#define silk_MLA(a,b,c) silk_MLA_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_MLA_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ - opus_int32 ret; - ret = a32 + b32 * c32; - if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32 ) - { - fprintf (stderr, "silk_MLA(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_MLA_uint -#define silk_MLA_uint(a,b,c) silk_MLA_uint_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_MLA_uint_(opus_uint32 a32, opus_uint32 b32, opus_uint32 c32, char *file, int line){ - opus_uint32 ret; - ret = a32 + b32 * c32; - if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int64)c32 ) - { - fprintf (stderr, "silk_MLA_uint(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_SMULWB -#define silk_SMULWB(a,b) silk_SMULWB_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SMULWB_(opus_int32 a32, opus_int32 b32, char *file, int line){ - opus_int32 ret; - ret = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16); - if ( (opus_int64)ret != ((opus_int64)a32 * (opus_int16)b32) >> 16 ) - { - fprintf (stderr, "silk_SMULWB(%d, %d) in %s: line %d\n", a32, b32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_SMLAWB -#define silk_SMLAWB(a,b,c) silk_SMLAWB_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SMLAWB_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ - opus_int32 ret; - ret = silk_ADD32_ovflw( a32, silk_SMULWB( b32, c32 ) ); - if ( ret != silk_ADD_SAT32( a32, silk_SMULWB( b32, c32 ) ) ) - { - fprintf (stderr, "silk_SMLAWB(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_SMULWT -#define silk_SMULWT(a,b) silk_SMULWT_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SMULWT_(opus_int32 a32, opus_int32 b32, char *file, int line){ - opus_int32 ret; - ret = (a32 >> 16) * (b32 >> 16) + (((a32 & 0x0000FFFF) * (b32 >> 16)) >> 16); - if ( (opus_int64)ret != ((opus_int64)a32 * (b32 >> 16)) >> 16 ) - { - fprintf (stderr, "silk_SMULWT(%d, %d) in %s: line %d\n", a32, b32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_SMLAWT -#define silk_SMLAWT(a,b,c) silk_SMLAWT_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SMLAWT_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ - opus_int32 ret; - ret = a32 + ((b32 >> 16) * (c32 >> 16)) + (((b32 & 0x0000FFFF) * ((c32 >> 16)) >> 16)); - if ( (opus_int64)ret != (opus_int64)a32 + (((opus_int64)b32 * (c32 >> 16)) >> 16) ) - { - fprintf (stderr, "silk_SMLAWT(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_SMULL -#define silk_SMULL(a,b) silk_SMULL_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int64 silk_SMULL_(opus_int64 a64, opus_int64 b64, char *file, int line){ - opus_int64 ret64; - int fail = 0; - ret64 = a64 * b64; - if( b64 != 0 ) { - fail = a64 != (ret64 / b64); - } else if( a64 != 0 ) { - fail = b64 != (ret64 / a64); - } - if ( fail ) - { - fprintf (stderr, "silk_SMULL(%lld, %lld) in %s: line %d\n", (long long)a64, (long long)b64, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret64; -} - -/* no checking needed for silk_SMULBB */ -#undef silk_SMLABB -#define silk_SMLABB(a,b,c) silk_SMLABB_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SMLABB_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ - opus_int32 ret; - ret = a32 + (opus_int32)((opus_int16)b32) * (opus_int32)((opus_int16)c32); - if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (opus_int16)c32 ) - { - fprintf (stderr, "silk_SMLABB(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -/* no checking needed for silk_SMULBT */ -#undef silk_SMLABT -#define silk_SMLABT(a,b,c) silk_SMLABT_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SMLABT_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ - opus_int32 ret; - ret = a32 + ((opus_int32)((opus_int16)b32)) * (c32 >> 16); - if ( (opus_int64)ret != (opus_int64)a32 + (opus_int64)b32 * (c32 >> 16) ) - { - fprintf (stderr, "silk_SMLABT(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -/* no checking needed for silk_SMULTT */ -#undef silk_SMLATT -#define silk_SMLATT(a,b,c) silk_SMLATT_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SMLATT_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ - opus_int32 ret; - ret = a32 + (b32 >> 16) * (c32 >> 16); - if ( (opus_int64)ret != (opus_int64)a32 + (b32 >> 16) * (c32 >> 16) ) - { - fprintf (stderr, "silk_SMLATT(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_SMULWW -#define silk_SMULWW(a,b) silk_SMULWW_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SMULWW_(opus_int32 a32, opus_int32 b32, char *file, int line){ - opus_int32 ret, tmp1, tmp2; - opus_int64 ret64; - int fail = 0; - - ret = silk_SMULWB( a32, b32 ); - tmp1 = silk_RSHIFT_ROUND( b32, 16 ); - tmp2 = silk_MUL( a32, tmp1 ); - - fail |= (opus_int64)tmp2 != (opus_int64) a32 * (opus_int64) tmp1; - - tmp1 = ret; - ret = silk_ADD32( tmp1, tmp2 ); - fail |= silk_ADD32( tmp1, tmp2 ) != silk_ADD_SAT32( tmp1, tmp2 ); - - ret64 = silk_RSHIFT64( silk_SMULL( a32, b32 ), 16 ); - fail |= (opus_int64)ret != ret64; - - if ( fail ) - { - fprintf (stderr, "silk_SMULWW(%d, %d) in %s: line %d\n", a32, b32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - - return ret; -} - -#undef silk_SMLAWW -#define silk_SMLAWW(a,b,c) silk_SMLAWW_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SMLAWW_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){ - opus_int32 ret, tmp; - - tmp = silk_SMULWW( b32, c32 ); - ret = silk_ADD32( a32, tmp ); - if ( ret != silk_ADD_SAT32( a32, tmp ) ) - { - fprintf (stderr, "silk_SMLAWW(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -/* no checking needed for silk_SMULL - no checking needed for silk_SMLAL - no checking needed for silk_SMLALBB - no checking needed for SigProcFIX_CLZ16 - no checking needed for SigProcFIX_CLZ32*/ - -#undef silk_DIV32 -#define silk_DIV32(a,b) silk_DIV32_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_DIV32_(opus_int32 a32, opus_int32 b32, char *file, int line){ - if ( b32 == 0 ) - { - fprintf (stderr, "silk_DIV32(%d, %d) in %s: line %d\n", a32, b32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return a32 / b32; -} - -#undef silk_DIV32_16 -#define silk_DIV32_16(a,b) silk_DIV32_16_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_DIV32_16_(opus_int32 a32, opus_int32 b32, char *file, int line){ - int fail = 0; - fail |= b32 == 0; - fail |= b32 > silk_int16_MAX; - fail |= b32 < silk_int16_MIN; - if ( fail ) - { - fprintf (stderr, "silk_DIV32_16(%d, %d) in %s: line %d\n", a32, b32, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return a32 / b32; -} - -/* no checking needed for silk_SAT8 - no checking needed for silk_SAT16 - no checking needed for silk_SAT32 - no checking needed for silk_POS_SAT32 - no checking needed for silk_ADD_POS_SAT8 - no checking needed for silk_ADD_POS_SAT16 - no checking needed for silk_ADD_POS_SAT32 */ - -#undef silk_LSHIFT8 -#define silk_LSHIFT8(a,b) silk_LSHIFT8_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int8 silk_LSHIFT8_(opus_int8 a, opus_int32 shift, char *file, int line){ - opus_int8 ret; - int fail = 0; - ret = (opus_int8)((opus_uint8)a << shift); - fail |= shift < 0; - fail |= shift >= 8; - fail |= (opus_int64)ret != (opus_int64)(((opus_uint64)a) << shift); - if ( fail ) - { - fprintf (stderr, "silk_LSHIFT8(%d, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_LSHIFT16 -#define silk_LSHIFT16(a,b) silk_LSHIFT16_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int16 silk_LSHIFT16_(opus_int16 a, opus_int32 shift, char *file, int line){ - opus_int16 ret; - int fail = 0; - ret = (opus_int16)((opus_uint16)a << shift); - fail |= shift < 0; - fail |= shift >= 16; - fail |= (opus_int64)ret != (opus_int64)(((opus_uint64)a) << shift); - if ( fail ) - { - fprintf (stderr, "silk_LSHIFT16(%d, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_LSHIFT32 -#define silk_LSHIFT32(a,b) silk_LSHIFT32_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_LSHIFT32_(opus_int32 a, opus_int32 shift, char *file, int line){ - opus_int32 ret; - int fail = 0; - ret = (opus_int32)((opus_uint32)a << shift); - fail |= shift < 0; - fail |= shift >= 32; - fail |= (opus_int64)ret != (opus_int64)(((opus_uint64)a) << shift); - if ( fail ) - { - fprintf (stderr, "silk_LSHIFT32(%d, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_LSHIFT64 -#define silk_LSHIFT64(a,b) silk_LSHIFT64_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int64 silk_LSHIFT64_(opus_int64 a, opus_int shift, char *file, int line){ - opus_int64 ret; - int fail = 0; - ret = (opus_int64)((opus_uint64)a << shift); - fail |= shift < 0; - fail |= shift >= 64; - fail |= (ret>>shift) != ((opus_int64)a); - if ( fail ) - { - fprintf (stderr, "silk_LSHIFT64(%lld, %d) in %s: line %d\n", (long long)a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_LSHIFT_ovflw -#define silk_LSHIFT_ovflw(a,b) silk_LSHIFT_ovflw_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_LSHIFT_ovflw_(opus_int32 a, opus_int32 shift, char *file, int line){ - if ( (shift < 0) || (shift >= 32) ) /* no check for overflow */ - { - fprintf (stderr, "silk_LSHIFT_ovflw(%d, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return a << shift; -} - -#undef silk_LSHIFT_uint -#define silk_LSHIFT_uint(a,b) silk_LSHIFT_uint_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_uint32 silk_LSHIFT_uint_(opus_uint32 a, opus_int32 shift, char *file, int line){ - opus_uint32 ret; - ret = a << shift; - if ( (shift < 0) || ((opus_int64)ret != ((opus_int64)a) << shift)) - { - fprintf (stderr, "silk_LSHIFT_uint(%u, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_RSHIFT8 -#define silk_RSHITF8(a,b) silk_RSHIFT8_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int8 silk_RSHIFT8_(opus_int8 a, opus_int32 shift, char *file, int line){ - if ( (shift < 0) || (shift>=8) ) - { - fprintf (stderr, "silk_RSHITF8(%d, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return a >> shift; -} - -#undef silk_RSHIFT16 -#define silk_RSHITF16(a,b) silk_RSHIFT16_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int16 silk_RSHIFT16_(opus_int16 a, opus_int32 shift, char *file, int line){ - if ( (shift < 0) || (shift>=16) ) - { - fprintf (stderr, "silk_RSHITF16(%d, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return a >> shift; -} - -#undef silk_RSHIFT32 -#define silk_RSHIFT32(a,b) silk_RSHIFT32_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_RSHIFT32_(opus_int32 a, opus_int32 shift, char *file, int line){ - if ( (shift < 0) || (shift>=32) ) - { - fprintf (stderr, "silk_RSHITF32(%d, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return a >> shift; -} - -#undef silk_RSHIFT64 -#define silk_RSHIFT64(a,b) silk_RSHIFT64_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int64 silk_RSHIFT64_(opus_int64 a, opus_int64 shift, char *file, int line){ - if ( (shift < 0) || (shift>=64) ) - { - fprintf (stderr, "silk_RSHITF64(%lld, %lld) in %s: line %d\n", (long long)a, (long long)shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return a >> shift; -} - -#undef silk_RSHIFT_uint -#define silk_RSHIFT_uint(a,b) silk_RSHIFT_uint_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_uint32 silk_RSHIFT_uint_(opus_uint32 a, opus_int32 shift, char *file, int line){ - if ( (shift < 0) || (shift>32) ) - { - fprintf (stderr, "silk_RSHIFT_uint(%u, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return a >> shift; -} - -#undef silk_ADD_LSHIFT -#define silk_ADD_LSHIFT(a,b,c) silk_ADD_LSHIFT_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE int silk_ADD_LSHIFT_(int a, int b, int shift, char *file, int line){ - opus_int16 ret; - ret = a + (opus_int16)((opus_uint16)b << shift); - if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (opus_int64)(((opus_uint64)b) << shift)) ) - { - fprintf (stderr, "silk_ADD_LSHIFT(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; /* shift >= 0 */ -} - -#undef silk_ADD_LSHIFT32 -#define silk_ADD_LSHIFT32(a,b,c) silk_ADD_LSHIFT32_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_ADD_LSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){ - opus_int32 ret; - ret = silk_ADD32_ovflw(a, (opus_int32)((opus_uint32)b << shift)); - if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (opus_int64)(((opus_uint64)b) << shift)) ) - { - fprintf (stderr, "silk_ADD_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; /* shift >= 0 */ -} - -#undef silk_ADD_LSHIFT_uint -#define silk_ADD_LSHIFT_uint(a,b,c) silk_ADD_LSHIFT_uint_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_uint32 silk_ADD_LSHIFT_uint_(opus_uint32 a, opus_uint32 b, opus_int32 shift, char *file, int line){ - opus_uint32 ret; - ret = a + (b << shift); - if ( (shift < 0) || (shift>32) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) << shift)) ) - { - fprintf (stderr, "silk_ADD_LSHIFT_uint(%u, %u, %d) in %s: line %d\n", a, b, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; /* shift >= 0 */ -} - -#undef silk_ADD_RSHIFT -#define silk_ADD_RSHIFT(a,b,c) silk_ADD_RSHIFT_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE int silk_ADD_RSHIFT_(int a, int b, int shift, char *file, int line){ - opus_int16 ret; - ret = a + (b >> shift); - if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) >> shift)) ) - { - fprintf (stderr, "silk_ADD_RSHIFT(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; /* shift > 0 */ -} - -#undef silk_ADD_RSHIFT32 -#define silk_ADD_RSHIFT32(a,b,c) silk_ADD_RSHIFT32_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_ADD_RSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){ - opus_int32 ret; - ret = silk_ADD32_ovflw(a, (b >> shift)); - if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) >> shift)) ) - { - fprintf (stderr, "silk_ADD_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; /* shift > 0 */ -} - -#undef silk_ADD_RSHIFT_uint -#define silk_ADD_RSHIFT_uint(a,b,c) silk_ADD_RSHIFT_uint_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_uint32 silk_ADD_RSHIFT_uint_(opus_uint32 a, opus_uint32 b, opus_int32 shift, char *file, int line){ - opus_uint32 ret; - ret = a + (b >> shift); - if ( (shift < 0) || (shift>32) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) >> shift)) ) - { - fprintf (stderr, "silk_ADD_RSHIFT_uint(%u, %u, %d) in %s: line %d\n", a, b, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; /* shift > 0 */ -} - -#undef silk_SUB_LSHIFT32 -#define silk_SUB_LSHIFT32(a,b,c) silk_SUB_LSHIFT32_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SUB_LSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){ - opus_int32 ret; - ret = silk_SUB32_ovflw(a, (opus_int32)((opus_uint32)b << shift)); - if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (opus_int64)(((opus_uint64)b) << shift)) ) - { - fprintf (stderr, "silk_SUB_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; /* shift >= 0 */ -} - -#undef silk_SUB_RSHIFT32 -#define silk_SUB_RSHIFT32(a,b,c) silk_SUB_RSHIFT32_((a), (b), (c), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_SUB_RSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){ - opus_int32 ret; - ret = silk_SUB32_ovflw(a, (b >> shift)); - if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (((opus_int64)b) >> shift)) ) - { - fprintf (stderr, "silk_SUB_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; /* shift > 0 */ -} - -#undef silk_RSHIFT_ROUND -#define silk_RSHIFT_ROUND(a,b) silk_RSHIFT_ROUND_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_RSHIFT_ROUND_(opus_int32 a, opus_int32 shift, char *file, int line){ - opus_int32 ret; - ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; - /* the macro definition can't handle a shift of zero */ - if ( (shift <= 0) || (shift>31) || ((opus_int64)ret != ((opus_int64)a + ((opus_int64)1 << (shift - 1))) >> shift) ) - { - fprintf (stderr, "silk_RSHIFT_ROUND(%d, %d) in %s: line %d\n", a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return ret; -} - -#undef silk_RSHIFT_ROUND64 -#define silk_RSHIFT_ROUND64(a,b) silk_RSHIFT_ROUND64_((a), (b), __FILE__, __LINE__) -static OPUS_INLINE opus_int64 silk_RSHIFT_ROUND64_(opus_int64 a, opus_int32 shift, char *file, int line){ - opus_int64 ret; - /* the macro definition can't handle a shift of zero */ - if ( (shift <= 0) || (shift>=64) ) - { - fprintf (stderr, "silk_RSHIFT_ROUND64(%lld, %d) in %s: line %d\n", (long long)a, shift, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1; - return ret; -} - -/* silk_abs is used on floats also, so doesn't work... */ -/*#undef silk_abs -static OPUS_INLINE opus_int32 silk_abs(opus_int32 a){ - silk_assert(a != 0x80000000); - return (((a) > 0) ? (a) : -(a)); // Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN -}*/ - -#undef silk_abs_int64 -#define silk_abs_int64(a) silk_abs_int64_((a), __FILE__, __LINE__) -static OPUS_INLINE opus_int64 silk_abs_int64_(opus_int64 a, char *file, int line){ - if ( a == silk_int64_MIN ) - { - fprintf (stderr, "silk_abs_int64(%lld) in %s: line %d\n", (long long)a, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return (((a) > 0) ? (a) : -(a)); /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */ -} - -#undef silk_abs_int32 -#define silk_abs_int32(a) silk_abs_int32_((a), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_abs_int32_(opus_int32 a, char *file, int line){ - if ( a == silk_int32_MIN ) - { - fprintf (stderr, "silk_abs_int32(%d) in %s: line %d\n", a, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return silk_abs(a); -} - -#undef silk_CHECK_FIT8 -#define silk_CHECK_FIT8(a) silk_CHECK_FIT8_((a), __FILE__, __LINE__) -static OPUS_INLINE opus_int8 silk_CHECK_FIT8_( opus_int64 a, char *file, int line ){ - opus_int8 ret; - ret = (opus_int8)a; - if ( (opus_int64)ret != a ) - { - fprintf (stderr, "silk_CHECK_FIT8(%lld) in %s: line %d\n", (long long)a, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return( ret ); -} - -#undef silk_CHECK_FIT16 -#define silk_CHECK_FIT16(a) silk_CHECK_FIT16_((a), __FILE__, __LINE__) -static OPUS_INLINE opus_int16 silk_CHECK_FIT16_( opus_int64 a, char *file, int line ){ - opus_int16 ret; - ret = (opus_int16)a; - if ( (opus_int64)ret != a ) - { - fprintf (stderr, "silk_CHECK_FIT16(%lld) in %s: line %d\n", (long long)a, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return( ret ); -} - -#undef silk_CHECK_FIT32 -#define silk_CHECK_FIT32(a) silk_CHECK_FIT32_((a), __FILE__, __LINE__) -static OPUS_INLINE opus_int32 silk_CHECK_FIT32_( opus_int64 a, char *file, int line ){ - opus_int32 ret; - ret = (opus_int32)a; - if ( (opus_int64)ret != a ) - { - fprintf (stderr, "silk_CHECK_FIT32(%lld) in %s: line %d\n", (long long)a, file, line); -#ifdef FIXED_DEBUG_ASSERT - silk_assert( 0 ); -#endif - } - return( ret ); -} - -/* no checking for silk_NSHIFT_MUL_32_32 - no checking for silk_NSHIFT_MUL_16_16 - no checking needed for silk_min - no checking needed for silk_max - no checking needed for silk_sign -*/ - -#endif -#endif /* MACRO_DEBUG_H */ diff --git a/Engine/lib/opus/silk/NLSF2A.c b/Engine/lib/opus/silk/NLSF2A.c deleted file mode 100644 index d5b773063..000000000 --- a/Engine/lib/opus/silk/NLSF2A.c +++ /dev/null @@ -1,141 +0,0 @@ -/*********************************************************************** -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" -#endif - -/* conversion between prediction filter coefficients and LSFs */ -/* order should be even */ -/* a piecewise linear approximation maps LSF <-> cos(LSF) */ -/* therefore the result is not accurate LSFs, but the two */ -/* functions are accurate inverses of each other */ - -#include "SigProc_FIX.h" -#include "tables.h" - -#define QA 16 - -/* helper function for NLSF2A(..) */ -static OPUS_INLINE void silk_NLSF2A_find_poly( - opus_int32 *out, /* O intermediate polynomial, QA [dd+1] */ - const opus_int32 *cLSF, /* I vector of interleaved 2*cos(LSFs), QA [d] */ - opus_int dd /* I polynomial order (= 1/2 * filter order) */ -) -{ - opus_int k, n; - opus_int32 ftmp; - - out[0] = silk_LSHIFT( 1, QA ); - out[1] = -cLSF[0]; - for( k = 1; k < dd; k++ ) { - ftmp = cLSF[2*k]; /* QA*/ - out[k+1] = silk_LSHIFT( out[k-1], 1 ) - (opus_int32)silk_RSHIFT_ROUND64( silk_SMULL( ftmp, out[k] ), QA ); - for( n = k; n > 1; n-- ) { - out[n] += out[n-2] - (opus_int32)silk_RSHIFT_ROUND64( silk_SMULL( ftmp, out[n-1] ), QA ); - } - out[1] -= ftmp; - } -} - -/* compute whitening filter coefficients from normalized line spectral frequencies */ -void silk_NLSF2A( - opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */ - const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */ - const opus_int d, /* I filter order (should be even) */ - int arch /* I Run-time architecture */ -) -{ - /* This ordering was found to maximize quality. It improves numerical accuracy of - silk_NLSF2A_find_poly() compared to "standard" ordering. */ - static const unsigned char ordering16[16] = { - 0, 15, 8, 7, 4, 11, 12, 3, 2, 13, 10, 5, 6, 9, 14, 1 - }; - static const unsigned char ordering10[10] = { - 0, 9, 6, 3, 4, 5, 8, 1, 2, 7 - }; - const unsigned char *ordering; - opus_int k, i, dd; - opus_int32 cos_LSF_QA[ SILK_MAX_ORDER_LPC ]; - opus_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ], Q[ SILK_MAX_ORDER_LPC / 2 + 1 ]; - opus_int32 Ptmp, Qtmp, f_int, f_frac, cos_val, delta; - opus_int32 a32_QA1[ SILK_MAX_ORDER_LPC ]; - - silk_assert( LSF_COS_TAB_SZ_FIX == 128 ); - celt_assert( d==10 || d==16 ); - - /* convert LSFs to 2*cos(LSF), using piecewise linear curve from table */ - ordering = d == 16 ? ordering16 : ordering10; - for( k = 0; k < d; k++ ) { - silk_assert( NLSF[k] >= 0 ); - - /* f_int on a scale 0-127 (rounded down) */ - f_int = silk_RSHIFT( NLSF[k], 15 - 7 ); - - /* f_frac, range: 0..255 */ - f_frac = NLSF[k] - silk_LSHIFT( f_int, 15 - 7 ); - - silk_assert(f_int >= 0); - silk_assert(f_int < LSF_COS_TAB_SZ_FIX ); - - /* Read start and end value from table */ - cos_val = silk_LSFCosTab_FIX_Q12[ f_int ]; /* Q12 */ - delta = silk_LSFCosTab_FIX_Q12[ f_int + 1 ] - cos_val; /* Q12, with a range of 0..200 */ - - /* Linear interpolation */ - cos_LSF_QA[ordering[k]] = silk_RSHIFT_ROUND( silk_LSHIFT( cos_val, 8 ) + silk_MUL( delta, f_frac ), 20 - QA ); /* QA */ - } - - dd = silk_RSHIFT( d, 1 ); - - /* generate even and odd polynomials using convolution */ - silk_NLSF2A_find_poly( P, &cos_LSF_QA[ 0 ], dd ); - silk_NLSF2A_find_poly( Q, &cos_LSF_QA[ 1 ], dd ); - - /* convert even and odd polynomials to opus_int32 Q12 filter coefs */ - for( k = 0; k < dd; k++ ) { - Ptmp = P[ k+1 ] + P[ k ]; - Qtmp = Q[ k+1 ] - Q[ k ]; - - /* the Ptmp and Qtmp values at this stage need to fit in int32 */ - a32_QA1[ k ] = -Qtmp - Ptmp; /* QA+1 */ - a32_QA1[ d-k-1 ] = Qtmp - Ptmp; /* QA+1 */ - } - - /* Convert int32 coefficients to Q12 int16 coefs */ - silk_LPC_fit( a_Q12, a32_QA1, 12, QA + 1, d ); - - for( i = 0; silk_LPC_inverse_pred_gain( a_Q12, d, arch ) == 0 && i < MAX_LPC_STABILIZE_ITERATIONS; i++ ) { - /* Prediction coefficients are (too close to) unstable; apply bandwidth expansion */ - /* on the unscaled coefficients, convert to Q12 and measure again */ - silk_bwexpander_32( a32_QA1, d, 65536 - silk_LSHIFT( 2, i ) ); - for( k = 0; k < d; k++ ) { - a_Q12[ k ] = (opus_int16)silk_RSHIFT_ROUND( a32_QA1[ k ], QA + 1 - 12 ); /* QA+1 -> Q12 */ - } - } -} - diff --git a/Engine/lib/opus/silk/NLSF_VQ.c b/Engine/lib/opus/silk/NLSF_VQ.c deleted file mode 100644 index b83182a79..000000000 --- a/Engine/lib/opus/silk/NLSF_VQ.c +++ /dev/null @@ -1,76 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */ -void silk_NLSF_VQ( - opus_int32 err_Q24[], /* O Quantization errors [K] */ - const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */ - const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */ - const opus_int16 pWght_Q9[], /* I Codebook weights [K*LPC_order] */ - const opus_int K, /* I Number of codebook vectors */ - const opus_int LPC_order /* I Number of LPCs */ -) -{ - opus_int i, m; - opus_int32 diff_Q15, diffw_Q24, sum_error_Q24, pred_Q24; - const opus_int16 *w_Q9_ptr; - const opus_uint8 *cb_Q8_ptr; - - celt_assert( ( LPC_order & 1 ) == 0 ); - - /* Loop over codebook */ - cb_Q8_ptr = pCB_Q8; - w_Q9_ptr = pWght_Q9; - for( i = 0; i < K; i++ ) { - sum_error_Q24 = 0; - pred_Q24 = 0; - for( m = LPC_order-2; m >= 0; m -= 2 ) { - /* Compute weighted absolute predictive quantization error for index m + 1 */ - diff_Q15 = silk_SUB_LSHIFT32( in_Q15[ m + 1 ], (opus_int32)cb_Q8_ptr[ m + 1 ], 7 ); /* range: [ -32767 : 32767 ]*/ - diffw_Q24 = silk_SMULBB( diff_Q15, w_Q9_ptr[ m + 1 ] ); - sum_error_Q24 = silk_ADD32( sum_error_Q24, silk_abs( silk_SUB_RSHIFT32( diffw_Q24, pred_Q24, 1 ) ) ); - pred_Q24 = diffw_Q24; - - /* Compute weighted absolute predictive quantization error for index m */ - diff_Q15 = silk_SUB_LSHIFT32( in_Q15[ m ], (opus_int32)cb_Q8_ptr[ m ], 7 ); /* range: [ -32767 : 32767 ]*/ - diffw_Q24 = silk_SMULBB( diff_Q15, w_Q9_ptr[ m ] ); - sum_error_Q24 = silk_ADD32( sum_error_Q24, silk_abs( silk_SUB_RSHIFT32( diffw_Q24, pred_Q24, 1 ) ) ); - pred_Q24 = diffw_Q24; - - silk_assert( sum_error_Q24 >= 0 ); - } - err_Q24[ i ] = sum_error_Q24; - cb_Q8_ptr += LPC_order; - w_Q9_ptr += LPC_order; - } -} diff --git a/Engine/lib/opus/silk/NLSF_VQ_weights_laroia.c b/Engine/lib/opus/silk/NLSF_VQ_weights_laroia.c deleted file mode 100644 index 9873bcde1..000000000 --- a/Engine/lib/opus/silk/NLSF_VQ_weights_laroia.c +++ /dev/null @@ -1,80 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "define.h" -#include "SigProc_FIX.h" - -/* -R. Laroia, N. Phamdo and N. Farvardin, "Robust and Efficient Quantization of Speech LSP -Parameters Using Structured Vector Quantization", Proc. IEEE Int. Conf. Acoust., Speech, -Signal Processing, pp. 641-644, 1991. -*/ - -/* Laroia low complexity NLSF weights */ -void silk_NLSF_VQ_weights_laroia( - opus_int16 *pNLSFW_Q_OUT, /* O Pointer to input vector weights [D] */ - const opus_int16 *pNLSF_Q15, /* I Pointer to input vector [D] */ - const opus_int D /* I Input vector dimension (even) */ -) -{ - opus_int k; - opus_int32 tmp1_int, tmp2_int; - - celt_assert( D > 0 ); - celt_assert( ( D & 1 ) == 0 ); - - /* First value */ - tmp1_int = silk_max_int( pNLSF_Q15[ 0 ], 1 ); - tmp1_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp1_int ); - tmp2_int = silk_max_int( pNLSF_Q15[ 1 ] - pNLSF_Q15[ 0 ], 1 ); - tmp2_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp2_int ); - pNLSFW_Q_OUT[ 0 ] = (opus_int16)silk_min_int( tmp1_int + tmp2_int, silk_int16_MAX ); - silk_assert( pNLSFW_Q_OUT[ 0 ] > 0 ); - - /* Main loop */ - for( k = 1; k < D - 1; k += 2 ) { - tmp1_int = silk_max_int( pNLSF_Q15[ k + 1 ] - pNLSF_Q15[ k ], 1 ); - tmp1_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp1_int ); - pNLSFW_Q_OUT[ k ] = (opus_int16)silk_min_int( tmp1_int + tmp2_int, silk_int16_MAX ); - silk_assert( pNLSFW_Q_OUT[ k ] > 0 ); - - tmp2_int = silk_max_int( pNLSF_Q15[ k + 2 ] - pNLSF_Q15[ k + 1 ], 1 ); - tmp2_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp2_int ); - pNLSFW_Q_OUT[ k + 1 ] = (opus_int16)silk_min_int( tmp1_int + tmp2_int, silk_int16_MAX ); - silk_assert( pNLSFW_Q_OUT[ k + 1 ] > 0 ); - } - - /* Last value */ - tmp1_int = silk_max_int( ( 1 << 15 ) - pNLSF_Q15[ D - 1 ], 1 ); - tmp1_int = silk_DIV32_16( (opus_int32)1 << ( 15 + NLSF_W_Q ), tmp1_int ); - pNLSFW_Q_OUT[ D - 1 ] = (opus_int16)silk_min_int( tmp1_int + tmp2_int, silk_int16_MAX ); - silk_assert( pNLSFW_Q_OUT[ D - 1 ] > 0 ); -} diff --git a/Engine/lib/opus/silk/NLSF_decode.c b/Engine/lib/opus/silk/NLSF_decode.c deleted file mode 100644 index eeb0ba8c9..000000000 --- a/Engine/lib/opus/silk/NLSF_decode.c +++ /dev/null @@ -1,93 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Predictive dequantizer for NLSF residuals */ -static OPUS_INLINE void silk_NLSF_residual_dequant( /* O Returns RD value in Q30 */ - opus_int16 x_Q10[], /* O Output [ order ] */ - const opus_int8 indices[], /* I Quantization indices [ order ] */ - const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */ - const opus_int quant_step_size_Q16, /* I Quantization step size */ - const opus_int16 order /* I Number of input values */ -) -{ - opus_int i, out_Q10, pred_Q10; - - out_Q10 = 0; - for( i = order-1; i >= 0; i-- ) { - pred_Q10 = silk_RSHIFT( silk_SMULBB( out_Q10, (opus_int16)pred_coef_Q8[ i ] ), 8 ); - out_Q10 = silk_LSHIFT( indices[ i ], 10 ); - if( out_Q10 > 0 ) { - out_Q10 = silk_SUB16( out_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } else if( out_Q10 < 0 ) { - out_Q10 = silk_ADD16( out_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } - out_Q10 = silk_SMLAWB( pred_Q10, (opus_int32)out_Q10, quant_step_size_Q16 ); - x_Q10[ i ] = out_Q10; - } -} - - -/***********************/ -/* NLSF vector decoder */ -/***********************/ -void silk_NLSF_decode( - opus_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */ - opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ -) -{ - opus_int i; - opus_uint8 pred_Q8[ MAX_LPC_ORDER ]; - opus_int16 ec_ix[ MAX_LPC_ORDER ]; - opus_int16 res_Q10[ MAX_LPC_ORDER ]; - opus_int32 NLSF_Q15_tmp; - const opus_uint8 *pCB_element; - const opus_int16 *pCB_Wght_Q9; - - /* Unpack entropy table indices and predictor for current CB1 index */ - silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, NLSFIndices[ 0 ] ); - - /* Predictive residual dequantizer */ - silk_NLSF_residual_dequant( res_Q10, &NLSFIndices[ 1 ], pred_Q8, psNLSF_CB->quantStepSize_Q16, psNLSF_CB->order ); - - /* Apply inverse square-rooted weights to first stage and add to output */ - pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ NLSFIndices[ 0 ] * psNLSF_CB->order ]; - pCB_Wght_Q9 = &psNLSF_CB->CB1_Wght_Q9[ NLSFIndices[ 0 ] * psNLSF_CB->order ]; - for( i = 0; i < psNLSF_CB->order; i++ ) { - NLSF_Q15_tmp = silk_ADD_LSHIFT32( silk_DIV32_16( silk_LSHIFT( (opus_int32)res_Q10[ i ], 14 ), pCB_Wght_Q9[ i ] ), (opus_int16)pCB_element[ i ], 7 ); - pNLSF_Q15[ i ] = (opus_int16)silk_LIMIT( NLSF_Q15_tmp, 0, 32767 ); - } - - /* NLSF stabilization */ - silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order ); -} diff --git a/Engine/lib/opus/silk/NLSF_del_dec_quant.c b/Engine/lib/opus/silk/NLSF_del_dec_quant.c deleted file mode 100644 index 44a16acd0..000000000 --- a/Engine/lib/opus/silk/NLSF_del_dec_quant.c +++ /dev/null @@ -1,215 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Delayed-decision quantizer for NLSF residuals */ -opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ - opus_int8 indices[], /* O Quantization indices [ order ] */ - const opus_int16 x_Q10[], /* I Input [ order ] */ - const opus_int16 w_Q5[], /* I Weights [ order ] */ - const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */ - const opus_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */ - const opus_uint8 ec_rates_Q5[], /* I Rates [] */ - const opus_int quant_step_size_Q16, /* I Quantization step size */ - const opus_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */ - const opus_int32 mu_Q20, /* I R/D tradeoff */ - const opus_int16 order /* I Number of input values */ -) -{ - opus_int i, j, nStates, ind_tmp, ind_min_max, ind_max_min, in_Q10, res_Q10; - opus_int pred_Q10, diff_Q10, rate0_Q5, rate1_Q5; - opus_int16 out0_Q10, out1_Q10; - opus_int32 RD_tmp_Q25, min_Q25, min_max_Q25, max_min_Q25; - opus_int ind_sort[ NLSF_QUANT_DEL_DEC_STATES ]; - opus_int8 ind[ NLSF_QUANT_DEL_DEC_STATES ][ MAX_LPC_ORDER ]; - opus_int16 prev_out_Q10[ 2 * NLSF_QUANT_DEL_DEC_STATES ]; - opus_int32 RD_Q25[ 2 * NLSF_QUANT_DEL_DEC_STATES ]; - opus_int32 RD_min_Q25[ NLSF_QUANT_DEL_DEC_STATES ]; - opus_int32 RD_max_Q25[ NLSF_QUANT_DEL_DEC_STATES ]; - const opus_uint8 *rates_Q5; - - opus_int out0_Q10_table[2 * NLSF_QUANT_MAX_AMPLITUDE_EXT]; - opus_int out1_Q10_table[2 * NLSF_QUANT_MAX_AMPLITUDE_EXT]; - - for (i = -NLSF_QUANT_MAX_AMPLITUDE_EXT; i <= NLSF_QUANT_MAX_AMPLITUDE_EXT-1; i++) - { - out0_Q10 = silk_LSHIFT( i, 10 ); - out1_Q10 = silk_ADD16( out0_Q10, 1024 ); - if( i > 0 ) { - out0_Q10 = silk_SUB16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } else if( i == 0 ) { - out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } else if( i == -1 ) { - out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } else { - out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - out1_Q10 = silk_ADD16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - } - out0_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_RSHIFT( silk_SMULBB( out0_Q10, quant_step_size_Q16 ), 16 ); - out1_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_RSHIFT( silk_SMULBB( out1_Q10, quant_step_size_Q16 ), 16 ); - } - - silk_assert( (NLSF_QUANT_DEL_DEC_STATES & (NLSF_QUANT_DEL_DEC_STATES-1)) == 0 ); /* must be power of two */ - - nStates = 1; - RD_Q25[ 0 ] = 0; - prev_out_Q10[ 0 ] = 0; - for( i = order - 1; i >= 0; i-- ) { - rates_Q5 = &ec_rates_Q5[ ec_ix[ i ] ]; - in_Q10 = x_Q10[ i ]; - for( j = 0; j < nStates; j++ ) { - pred_Q10 = silk_RSHIFT( silk_SMULBB( (opus_int16)pred_coef_Q8[ i ], prev_out_Q10[ j ] ), 8 ); - res_Q10 = silk_SUB16( in_Q10, pred_Q10 ); - ind_tmp = silk_RSHIFT( silk_SMULBB( inv_quant_step_size_Q6, res_Q10 ), 16 ); - ind_tmp = silk_LIMIT( ind_tmp, -NLSF_QUANT_MAX_AMPLITUDE_EXT, NLSF_QUANT_MAX_AMPLITUDE_EXT-1 ); - ind[ j ][ i ] = (opus_int8)ind_tmp; - - /* compute outputs for ind_tmp and ind_tmp + 1 */ - out0_Q10 = out0_Q10_table[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE_EXT ]; - out1_Q10 = out1_Q10_table[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE_EXT ]; - - out0_Q10 = silk_ADD16( out0_Q10, pred_Q10 ); - out1_Q10 = silk_ADD16( out1_Q10, pred_Q10 ); - prev_out_Q10[ j ] = out0_Q10; - prev_out_Q10[ j + nStates ] = out1_Q10; - - /* compute RD for ind_tmp and ind_tmp + 1 */ - if( ind_tmp + 1 >= NLSF_QUANT_MAX_AMPLITUDE ) { - if( ind_tmp + 1 == NLSF_QUANT_MAX_AMPLITUDE ) { - rate0_Q5 = rates_Q5[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE ]; - rate1_Q5 = 280; - } else { - rate0_Q5 = silk_SMLABB( 280 - 43 * NLSF_QUANT_MAX_AMPLITUDE, 43, ind_tmp ); - rate1_Q5 = silk_ADD16( rate0_Q5, 43 ); - } - } else if( ind_tmp <= -NLSF_QUANT_MAX_AMPLITUDE ) { - if( ind_tmp == -NLSF_QUANT_MAX_AMPLITUDE ) { - rate0_Q5 = 280; - rate1_Q5 = rates_Q5[ ind_tmp + 1 + NLSF_QUANT_MAX_AMPLITUDE ]; - } else { - rate0_Q5 = silk_SMLABB( 280 - 43 * NLSF_QUANT_MAX_AMPLITUDE, -43, ind_tmp ); - rate1_Q5 = silk_SUB16( rate0_Q5, 43 ); - } - } else { - rate0_Q5 = rates_Q5[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE ]; - rate1_Q5 = rates_Q5[ ind_tmp + 1 + NLSF_QUANT_MAX_AMPLITUDE ]; - } - RD_tmp_Q25 = RD_Q25[ j ]; - diff_Q10 = silk_SUB16( in_Q10, out0_Q10 ); - RD_Q25[ j ] = silk_SMLABB( silk_MLA( RD_tmp_Q25, silk_SMULBB( diff_Q10, diff_Q10 ), w_Q5[ i ] ), mu_Q20, rate0_Q5 ); - diff_Q10 = silk_SUB16( in_Q10, out1_Q10 ); - RD_Q25[ j + nStates ] = silk_SMLABB( silk_MLA( RD_tmp_Q25, silk_SMULBB( diff_Q10, diff_Q10 ), w_Q5[ i ] ), mu_Q20, rate1_Q5 ); - } - - if( nStates <= NLSF_QUANT_DEL_DEC_STATES/2 ) { - /* double number of states and copy */ - for( j = 0; j < nStates; j++ ) { - ind[ j + nStates ][ i ] = ind[ j ][ i ] + 1; - } - nStates = silk_LSHIFT( nStates, 1 ); - for( j = nStates; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { - ind[ j ][ i ] = ind[ j - nStates ][ i ]; - } - } else { - /* sort lower and upper half of RD_Q25, pairwise */ - for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { - if( RD_Q25[ j ] > RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ] ) { - RD_max_Q25[ j ] = RD_Q25[ j ]; - RD_min_Q25[ j ] = RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ]; - RD_Q25[ j ] = RD_min_Q25[ j ]; - RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ] = RD_max_Q25[ j ]; - /* swap prev_out values */ - out0_Q10 = prev_out_Q10[ j ]; - prev_out_Q10[ j ] = prev_out_Q10[ j + NLSF_QUANT_DEL_DEC_STATES ]; - prev_out_Q10[ j + NLSF_QUANT_DEL_DEC_STATES ] = out0_Q10; - ind_sort[ j ] = j + NLSF_QUANT_DEL_DEC_STATES; - } else { - RD_min_Q25[ j ] = RD_Q25[ j ]; - RD_max_Q25[ j ] = RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ]; - ind_sort[ j ] = j; - } - } - /* compare the highest RD values of the winning half with the lowest one in the losing half, and copy if necessary */ - /* afterwards ind_sort[] will contain the indices of the NLSF_QUANT_DEL_DEC_STATES winning RD values */ - while( 1 ) { - min_max_Q25 = silk_int32_MAX; - max_min_Q25 = 0; - ind_min_max = 0; - ind_max_min = 0; - for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { - if( min_max_Q25 > RD_max_Q25[ j ] ) { - min_max_Q25 = RD_max_Q25[ j ]; - ind_min_max = j; - } - if( max_min_Q25 < RD_min_Q25[ j ] ) { - max_min_Q25 = RD_min_Q25[ j ]; - ind_max_min = j; - } - } - if( min_max_Q25 >= max_min_Q25 ) { - break; - } - /* copy ind_min_max to ind_max_min */ - ind_sort[ ind_max_min ] = ind_sort[ ind_min_max ] ^ NLSF_QUANT_DEL_DEC_STATES; - RD_Q25[ ind_max_min ] = RD_Q25[ ind_min_max + NLSF_QUANT_DEL_DEC_STATES ]; - prev_out_Q10[ ind_max_min ] = prev_out_Q10[ ind_min_max + NLSF_QUANT_DEL_DEC_STATES ]; - RD_min_Q25[ ind_max_min ] = 0; - RD_max_Q25[ ind_min_max ] = silk_int32_MAX; - silk_memcpy( ind[ ind_max_min ], ind[ ind_min_max ], MAX_LPC_ORDER * sizeof( opus_int8 ) ); - } - /* increment index if it comes from the upper half */ - for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { - ind[ j ][ i ] += silk_RSHIFT( ind_sort[ j ], NLSF_QUANT_DEL_DEC_STATES_LOG2 ); - } - } - } - - /* last sample: find winner, copy indices and return RD value */ - ind_tmp = 0; - min_Q25 = silk_int32_MAX; - for( j = 0; j < 2 * NLSF_QUANT_DEL_DEC_STATES; j++ ) { - if( min_Q25 > RD_Q25[ j ] ) { - min_Q25 = RD_Q25[ j ]; - ind_tmp = j; - } - } - for( j = 0; j < order; j++ ) { - indices[ j ] = ind[ ind_tmp & ( NLSF_QUANT_DEL_DEC_STATES - 1 ) ][ j ]; - silk_assert( indices[ j ] >= -NLSF_QUANT_MAX_AMPLITUDE_EXT ); - silk_assert( indices[ j ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT ); - } - indices[ 0 ] += silk_RSHIFT( ind_tmp, NLSF_QUANT_DEL_DEC_STATES_LOG2 ); - silk_assert( indices[ 0 ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT ); - silk_assert( min_Q25 >= 0 ); - return min_Q25; -} diff --git a/Engine/lib/opus/silk/NLSF_encode.c b/Engine/lib/opus/silk/NLSF_encode.c deleted file mode 100644 index 01ac7db78..000000000 --- a/Engine/lib/opus/silk/NLSF_encode.c +++ /dev/null @@ -1,124 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" - -/***********************/ -/* NLSF vector encoder */ -/***********************/ -opus_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */ - opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - opus_int16 *pNLSF_Q15, /* I/O (Un)quantized NLSF vector [ LPC_ORDER ] */ - const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ - const opus_int16 *pW_Q2, /* I NLSF weight vector [ LPC_ORDER ] */ - const opus_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */ - const opus_int nSurvivors, /* I Max survivors after first stage */ - const opus_int signalType /* I Signal type: 0/1/2 */ -) -{ - opus_int i, s, ind1, bestIndex, prob_Q8, bits_q7; - opus_int32 W_tmp_Q9, ret; - VARDECL( opus_int32, err_Q24 ); - VARDECL( opus_int32, RD_Q25 ); - VARDECL( opus_int, tempIndices1 ); - VARDECL( opus_int8, tempIndices2 ); - opus_int16 res_Q10[ MAX_LPC_ORDER ]; - opus_int16 NLSF_tmp_Q15[ MAX_LPC_ORDER ]; - opus_int16 W_adj_Q5[ MAX_LPC_ORDER ]; - opus_uint8 pred_Q8[ MAX_LPC_ORDER ]; - opus_int16 ec_ix[ MAX_LPC_ORDER ]; - const opus_uint8 *pCB_element, *iCDF_ptr; - const opus_int16 *pCB_Wght_Q9; - SAVE_STACK; - - celt_assert( signalType >= 0 && signalType <= 2 ); - silk_assert( NLSF_mu_Q20 <= 32767 && NLSF_mu_Q20 >= 0 ); - - /* NLSF stabilization */ - silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order ); - - /* First stage: VQ */ - ALLOC( err_Q24, psNLSF_CB->nVectors, opus_int32 ); - silk_NLSF_VQ( err_Q24, pNLSF_Q15, psNLSF_CB->CB1_NLSF_Q8, psNLSF_CB->CB1_Wght_Q9, psNLSF_CB->nVectors, psNLSF_CB->order ); - - /* Sort the quantization errors */ - ALLOC( tempIndices1, nSurvivors, opus_int ); - silk_insertion_sort_increasing( err_Q24, tempIndices1, psNLSF_CB->nVectors, nSurvivors ); - - ALLOC( RD_Q25, nSurvivors, opus_int32 ); - ALLOC( tempIndices2, nSurvivors * MAX_LPC_ORDER, opus_int8 ); - - /* Loop over survivors */ - for( s = 0; s < nSurvivors; s++ ) { - ind1 = tempIndices1[ s ]; - - /* Residual after first stage */ - pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ ind1 * psNLSF_CB->order ]; - pCB_Wght_Q9 = &psNLSF_CB->CB1_Wght_Q9[ ind1 * psNLSF_CB->order ]; - for( i = 0; i < psNLSF_CB->order; i++ ) { - NLSF_tmp_Q15[ i ] = silk_LSHIFT16( (opus_int16)pCB_element[ i ], 7 ); - W_tmp_Q9 = pCB_Wght_Q9[ i ]; - res_Q10[ i ] = (opus_int16)silk_RSHIFT( silk_SMULBB( pNLSF_Q15[ i ] - NLSF_tmp_Q15[ i ], W_tmp_Q9 ), 14 ); - W_adj_Q5[ i ] = silk_DIV32_varQ( (opus_int32)pW_Q2[ i ], silk_SMULBB( W_tmp_Q9, W_tmp_Q9 ), 21 ); - } - - /* Unpack entropy table indices and predictor for current CB1 index */ - silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 ); - - /* Trellis quantizer */ - RD_Q25[ s ] = silk_NLSF_del_dec_quant( &tempIndices2[ s * MAX_LPC_ORDER ], res_Q10, W_adj_Q5, pred_Q8, ec_ix, - psNLSF_CB->ec_Rates_Q5, psNLSF_CB->quantStepSize_Q16, psNLSF_CB->invQuantStepSize_Q6, NLSF_mu_Q20, psNLSF_CB->order ); - - /* Add rate for first stage */ - iCDF_ptr = &psNLSF_CB->CB1_iCDF[ ( signalType >> 1 ) * psNLSF_CB->nVectors ]; - if( ind1 == 0 ) { - prob_Q8 = 256 - iCDF_ptr[ ind1 ]; - } else { - prob_Q8 = iCDF_ptr[ ind1 - 1 ] - iCDF_ptr[ ind1 ]; - } - bits_q7 = ( 8 << 7 ) - silk_lin2log( prob_Q8 ); - RD_Q25[ s ] = silk_SMLABB( RD_Q25[ s ], bits_q7, silk_RSHIFT( NLSF_mu_Q20, 2 ) ); - } - - /* Find the lowest rate-distortion error */ - silk_insertion_sort_increasing( RD_Q25, &bestIndex, nSurvivors, 1 ); - - NLSFIndices[ 0 ] = (opus_int8)tempIndices1[ bestIndex ]; - silk_memcpy( &NLSFIndices[ 1 ], &tempIndices2[ bestIndex * MAX_LPC_ORDER ], psNLSF_CB->order * sizeof( opus_int8 ) ); - - /* Decode */ - silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB ); - - ret = RD_Q25[ 0 ]; - RESTORE_STACK; - return ret; -} diff --git a/Engine/lib/opus/silk/NLSF_stabilize.c b/Engine/lib/opus/silk/NLSF_stabilize.c deleted file mode 100644 index 8f3426b91..000000000 --- a/Engine/lib/opus/silk/NLSF_stabilize.c +++ /dev/null @@ -1,142 +0,0 @@ -/*********************************************************************** -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" -#endif - -/* NLSF stabilizer: */ -/* */ -/* - Moves NLSFs further apart if they are too close */ -/* - Moves NLSFs away from borders if they are too close */ -/* - High effort to achieve a modification with minimum */ -/* Euclidean distance to input vector */ -/* - Output are sorted NLSF coefficients */ -/* */ - -#include "SigProc_FIX.h" - -/* Constant Definitions */ -#define MAX_LOOPS 20 - -/* NLSF stabilizer, for a single input data vector */ -void silk_NLSF_stabilize( - opus_int16 *NLSF_Q15, /* I/O Unstable/stabilized normalized LSF vector in Q15 [L] */ - const opus_int16 *NDeltaMin_Q15, /* I Min distance vector, NDeltaMin_Q15[L] must be >= 1 [L+1] */ - const opus_int L /* I Number of NLSF parameters in the input vector */ -) -{ - opus_int i, I=0, k, loops; - opus_int16 center_freq_Q15; - opus_int32 diff_Q15, min_diff_Q15, min_center_Q15, max_center_Q15; - - /* This is necessary to ensure an output within range of a opus_int16 */ - silk_assert( NDeltaMin_Q15[L] >= 1 ); - - for( loops = 0; loops < MAX_LOOPS; loops++ ) { - /**************************/ - /* Find smallest distance */ - /**************************/ - /* First element */ - min_diff_Q15 = NLSF_Q15[0] - NDeltaMin_Q15[0]; - I = 0; - /* Middle elements */ - for( i = 1; i <= L-1; i++ ) { - diff_Q15 = NLSF_Q15[i] - ( NLSF_Q15[i-1] + NDeltaMin_Q15[i] ); - if( diff_Q15 < min_diff_Q15 ) { - min_diff_Q15 = diff_Q15; - I = i; - } - } - /* Last element */ - diff_Q15 = ( 1 << 15 ) - ( NLSF_Q15[L-1] + NDeltaMin_Q15[L] ); - if( diff_Q15 < min_diff_Q15 ) { - min_diff_Q15 = diff_Q15; - I = L; - } - - /***************************************************/ - /* Now check if the smallest distance non-negative */ - /***************************************************/ - if( min_diff_Q15 >= 0 ) { - return; - } - - if( I == 0 ) { - /* Move away from lower limit */ - NLSF_Q15[0] = NDeltaMin_Q15[0]; - - } else if( I == L) { - /* Move away from higher limit */ - NLSF_Q15[L-1] = ( 1 << 15 ) - NDeltaMin_Q15[L]; - - } else { - /* Find the lower extreme for the location of the current center frequency */ - min_center_Q15 = 0; - for( k = 0; k < I; k++ ) { - min_center_Q15 += NDeltaMin_Q15[k]; - } - min_center_Q15 += silk_RSHIFT( NDeltaMin_Q15[I], 1 ); - - /* Find the upper extreme for the location of the current center frequency */ - max_center_Q15 = 1 << 15; - for( k = L; k > I; k-- ) { - max_center_Q15 -= NDeltaMin_Q15[k]; - } - max_center_Q15 -= silk_RSHIFT( NDeltaMin_Q15[I], 1 ); - - /* Move apart, sorted by value, keeping the same center frequency */ - center_freq_Q15 = (opus_int16)silk_LIMIT_32( silk_RSHIFT_ROUND( (opus_int32)NLSF_Q15[I-1] + (opus_int32)NLSF_Q15[I], 1 ), - min_center_Q15, max_center_Q15 ); - NLSF_Q15[I-1] = center_freq_Q15 - silk_RSHIFT( NDeltaMin_Q15[I], 1 ); - NLSF_Q15[I] = NLSF_Q15[I-1] + NDeltaMin_Q15[I]; - } - } - - /* Safe and simple fall back method, which is less ideal than the above */ - if( loops == MAX_LOOPS ) - { - /* Insertion sort (fast for already almost sorted arrays): */ - /* Best case: O(n) for an already sorted array */ - /* Worst case: O(n^2) for an inversely sorted array */ - silk_insertion_sort_increasing_all_values_int16( &NLSF_Q15[0], L ); - - /* First NLSF should be no less than NDeltaMin[0] */ - NLSF_Q15[0] = silk_max_int( NLSF_Q15[0], NDeltaMin_Q15[0] ); - - /* Keep delta_min distance between the NLSFs */ - for( i = 1; i < L; i++ ) - NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) ); - - /* Last NLSF should be no higher than 1 - NDeltaMin[L] */ - NLSF_Q15[L-1] = silk_min_int( NLSF_Q15[L-1], (1<<15) - NDeltaMin_Q15[L] ); - - /* Keep NDeltaMin distance between the NLSFs */ - for( i = L-2; i >= 0; i-- ) - NLSF_Q15[i] = silk_min_int( NLSF_Q15[i], NLSF_Q15[i+1] - NDeltaMin_Q15[i+1] ); - } -} diff --git a/Engine/lib/opus/silk/NLSF_unpack.c b/Engine/lib/opus/silk/NLSF_unpack.c deleted file mode 100644 index 17bd23f75..000000000 --- a/Engine/lib/opus/silk/NLSF_unpack.c +++ /dev/null @@ -1,55 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Unpack predictor values and indices for entropy coding tables */ -void silk_NLSF_unpack( - opus_int16 ec_ix[], /* O Indices to entropy tables [ LPC_ORDER ] */ - opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */ - const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ - const opus_int CB1_index /* I Index of vector in first LSF codebook */ -) -{ - opus_int i; - opus_uint8 entry; - const opus_uint8 *ec_sel_ptr; - - ec_sel_ptr = &psNLSF_CB->ec_sel[ CB1_index * psNLSF_CB->order / 2 ]; - for( i = 0; i < psNLSF_CB->order; i += 2 ) { - entry = *ec_sel_ptr++; - ec_ix [ i ] = silk_SMULBB( silk_RSHIFT( entry, 1 ) & 7, 2 * NLSF_QUANT_MAX_AMPLITUDE + 1 ); - pred_Q8[ i ] = psNLSF_CB->pred_Q8[ i + ( entry & 1 ) * ( psNLSF_CB->order - 1 ) ]; - ec_ix [ i + 1 ] = silk_SMULBB( silk_RSHIFT( entry, 5 ) & 7, 2 * NLSF_QUANT_MAX_AMPLITUDE + 1 ); - pred_Q8[ i + 1 ] = psNLSF_CB->pred_Q8[ i + ( silk_RSHIFT( entry, 4 ) & 1 ) * ( psNLSF_CB->order - 1 ) + 1 ]; - } -} - diff --git a/Engine/lib/opus/silk/NSQ.c b/Engine/lib/opus/silk/NSQ.c deleted file mode 100644 index 45dd45ce8..000000000 --- a/Engine/lib/opus/silk/NSQ.c +++ /dev/null @@ -1,437 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" -#include "NSQ.h" - - -static OPUS_INLINE void silk_nsq_scale_states( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - const opus_int16 x16[], /* I input */ - opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ - const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I subframe number */ - const opus_int LTP_scale_Q14, /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type /* I Signal type */ -); - -#if !defined(OPUS_X86_MAY_HAVE_SSE4_1) -static OPUS_INLINE void silk_noise_shape_quantizer( - silk_nsq_state *NSQ, /* I/O NSQ state */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_sc_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP state */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int shapingLPCOrder, /* I Noise shaping AR filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - int arch /* I Architecture */ -); -#endif - -void silk_NSQ_c -( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -) -{ - opus_int k, lag, start_idx, LSF_interpolation_flag; - const opus_int16 *A_Q12, *B_Q14, *AR_shp_Q13; - opus_int16 *pxq; - VARDECL( opus_int32, sLTP_Q15 ); - VARDECL( opus_int16, sLTP ); - opus_int32 HarmShapeFIRPacked_Q14; - opus_int offset_Q10; - VARDECL( opus_int32, x_sc_Q10 ); - SAVE_STACK; - - NSQ->rand_seed = psIndices->Seed; - - /* Set unvoiced lag to the previous one, overwrite later for voiced */ - lag = NSQ->lagPrev; - - silk_assert( NSQ->prev_gain_Q16 != 0 ); - - offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; - - if( psIndices->NLSFInterpCoef_Q2 == 4 ) { - LSF_interpolation_flag = 0; - } else { - LSF_interpolation_flag = 1; - } - - ALLOC( sLTP_Q15, psEncC->ltp_mem_length + psEncC->frame_length, opus_int32 ); - ALLOC( sLTP, psEncC->ltp_mem_length + psEncC->frame_length, opus_int16 ); - ALLOC( x_sc_Q10, psEncC->subfr_length, opus_int32 ); - /* Set up pointers to start of sub frame */ - NSQ->sLTP_shp_buf_idx = psEncC->ltp_mem_length; - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - pxq = &NSQ->xq[ psEncC->ltp_mem_length ]; - for( k = 0; k < psEncC->nb_subfr; k++ ) { - A_Q12 = &PredCoef_Q12[ (( k >> 1 ) | ( 1 - LSF_interpolation_flag )) * MAX_LPC_ORDER ]; - B_Q14 = <PCoef_Q14[ k * LTP_ORDER ]; - AR_shp_Q13 = &AR_Q13[ k * MAX_SHAPE_LPC_ORDER ]; - - /* Noise shape parameters */ - silk_assert( HarmShapeGain_Q14[ k ] >= 0 ); - HarmShapeFIRPacked_Q14 = silk_RSHIFT( HarmShapeGain_Q14[ k ], 2 ); - HarmShapeFIRPacked_Q14 |= silk_LSHIFT( (opus_int32)silk_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 ); - - NSQ->rewhite_flag = 0; - if( psIndices->signalType == TYPE_VOICED ) { - /* Voiced */ - lag = pitchL[ k ]; - - /* Re-whitening */ - if( ( k & ( 3 - silk_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) { - /* Rewhiten with new A coefs */ - start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2; - celt_assert( start_idx > 0 ); - - silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], - A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder, psEncC->arch ); - - NSQ->rewhite_flag = 1; - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - } - } - - silk_nsq_scale_states( psEncC, NSQ, x16, x_sc_Q10, sLTP, sLTP_Q15, k, LTP_scale_Q14, Gains_Q16, pitchL, psIndices->signalType ); - - silk_noise_shape_quantizer( NSQ, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q15, A_Q12, B_Q14, - AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10, - offset_Q10, psEncC->subfr_length, psEncC->shapingLPCOrder, psEncC->predictLPCOrder, psEncC->arch ); - - x16 += psEncC->subfr_length; - pulses += psEncC->subfr_length; - pxq += psEncC->subfr_length; - } - - /* Update lagPrev for next frame */ - NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ]; - - /* Save quantized speech and noise shaping signals */ - silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) ); - silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) ); - RESTORE_STACK; -} - -/******************************/ -/* silk_noise_shape_quantizer */ -/******************************/ - -#if !defined(OPUS_X86_MAY_HAVE_SSE4_1) -static OPUS_INLINE -#endif -void silk_noise_shape_quantizer( - silk_nsq_state *NSQ, /* I/O NSQ state */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_sc_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP state */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int shapingLPCOrder, /* I Noise shaping AR filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - int arch /* I Architecture */ -) -{ - opus_int i; - opus_int32 LTP_pred_Q13, LPC_pred_Q10, n_AR_Q12, n_LTP_Q13; - opus_int32 n_LF_Q12, r_Q10, rr_Q10, q1_Q0, q1_Q10, q2_Q10, rd1_Q20, rd2_Q20; - opus_int32 exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10; - opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; - opus_int32 *psLPC_Q14, *shp_lag_ptr, *pred_lag_ptr; -#ifdef silk_short_prediction_create_arch_coef - opus_int32 a_Q12_arch[MAX_LPC_ORDER]; -#endif - - shp_lag_ptr = &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ]; - pred_lag_ptr = &sLTP_Q15[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ]; - Gain_Q10 = silk_RSHIFT( Gain_Q16, 6 ); - - /* Set up short term AR state */ - psLPC_Q14 = &NSQ->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 ]; - -#ifdef silk_short_prediction_create_arch_coef - silk_short_prediction_create_arch_coef(a_Q12_arch, a_Q12, predictLPCOrder); -#endif - - for( i = 0; i < length; i++ ) { - /* Generate dither */ - NSQ->rand_seed = silk_RAND( NSQ->rand_seed ); - - /* Short-term prediction */ - LPC_pred_Q10 = silk_noise_shape_quantizer_short_prediction(psLPC_Q14, a_Q12, a_Q12_arch, predictLPCOrder, arch); - - /* Long-term prediction */ - if( signalType == TYPE_VOICED ) { - /* Unrolled loop */ - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LTP_pred_Q13 = 2; - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ 0 ], b_Q14[ 0 ] ); - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -1 ], b_Q14[ 1 ] ); - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -2 ], b_Q14[ 2 ] ); - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -3 ], b_Q14[ 3 ] ); - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -4 ], b_Q14[ 4 ] ); - pred_lag_ptr++; - } else { - LTP_pred_Q13 = 0; - } - - /* Noise shape feedback */ - celt_assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */ - n_AR_Q12 = silk_NSQ_noise_shape_feedback_loop(&NSQ->sDiff_shp_Q14, NSQ->sAR2_Q14, AR_shp_Q13, shapingLPCOrder, arch); - - n_AR_Q12 = silk_SMLAWB( n_AR_Q12, NSQ->sLF_AR_shp_Q14, Tilt_Q14 ); - - n_LF_Q12 = silk_SMULWB( NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - 1 ], LF_shp_Q14 ); - n_LF_Q12 = silk_SMLAWT( n_LF_Q12, NSQ->sLF_AR_shp_Q14, LF_shp_Q14 ); - - celt_assert( lag > 0 || signalType != TYPE_VOICED ); - - /* Combine prediction and noise shaping signals */ - tmp1 = silk_SUB32( silk_LSHIFT32( LPC_pred_Q10, 2 ), n_AR_Q12 ); /* Q12 */ - tmp1 = silk_SUB32( tmp1, n_LF_Q12 ); /* Q12 */ - if( lag > 0 ) { - /* Symmetric, packed FIR coefficients */ - n_LTP_Q13 = silk_SMULWB( silk_ADD_SAT32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); - n_LTP_Q13 = silk_SMLAWT( n_LTP_Q13, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); - n_LTP_Q13 = silk_LSHIFT( n_LTP_Q13, 1 ); - shp_lag_ptr++; - - tmp2 = silk_SUB32( LTP_pred_Q13, n_LTP_Q13 ); /* Q13 */ - tmp1 = silk_ADD_LSHIFT32( tmp2, tmp1, 1 ); /* Q13 */ - tmp1 = silk_RSHIFT_ROUND( tmp1, 3 ); /* Q10 */ - } else { - tmp1 = silk_RSHIFT_ROUND( tmp1, 2 ); /* Q10 */ - } - - r_Q10 = silk_SUB32( x_sc_Q10[ i ], tmp1 ); /* residual error Q10 */ - - /* Flip sign depending on dither */ - if( NSQ->rand_seed < 0 ) { - r_Q10 = -r_Q10; - } - r_Q10 = silk_LIMIT_32( r_Q10, -(31 << 10), 30 << 10 ); - - /* Find two quantization level candidates and measure their rate-distortion */ - q1_Q10 = silk_SUB32( r_Q10, offset_Q10 ); - q1_Q0 = silk_RSHIFT( q1_Q10, 10 ); - if (Lambda_Q10 > 2048) { - /* For aggressive RDO, the bias becomes more than one pulse. */ - int rdo_offset = Lambda_Q10/2 - 512; - if (q1_Q10 > rdo_offset) { - q1_Q0 = silk_RSHIFT( q1_Q10 - rdo_offset, 10 ); - } else if (q1_Q10 < -rdo_offset) { - q1_Q0 = silk_RSHIFT( q1_Q10 + rdo_offset, 10 ); - } else if (q1_Q10 < 0) { - q1_Q0 = -1; - } else { - q1_Q0 = 0; - } - } - if( q1_Q0 > 0 ) { - q1_Q10 = silk_SUB32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); - q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); - q2_Q10 = silk_ADD32( q1_Q10, 1024 ); - rd1_Q20 = silk_SMULBB( q1_Q10, Lambda_Q10 ); - rd2_Q20 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else if( q1_Q0 == 0 ) { - q1_Q10 = offset_Q10; - q2_Q10 = silk_ADD32( q1_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); - rd1_Q20 = silk_SMULBB( q1_Q10, Lambda_Q10 ); - rd2_Q20 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else if( q1_Q0 == -1 ) { - q2_Q10 = offset_Q10; - q1_Q10 = silk_SUB32( q2_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); - rd1_Q20 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); - rd2_Q20 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else { /* Q1_Q0 < -1 */ - q1_Q10 = silk_ADD32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); - q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); - q2_Q10 = silk_ADD32( q1_Q10, 1024 ); - rd1_Q20 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); - rd2_Q20 = silk_SMULBB( -q2_Q10, Lambda_Q10 ); - } - rr_Q10 = silk_SUB32( r_Q10, q1_Q10 ); - rd1_Q20 = silk_SMLABB( rd1_Q20, rr_Q10, rr_Q10 ); - rr_Q10 = silk_SUB32( r_Q10, q2_Q10 ); - rd2_Q20 = silk_SMLABB( rd2_Q20, rr_Q10, rr_Q10 ); - - if( rd2_Q20 < rd1_Q20 ) { - q1_Q10 = q2_Q10; - } - - pulses[ i ] = (opus_int8)silk_RSHIFT_ROUND( q1_Q10, 10 ); - - /* Excitation */ - exc_Q14 = silk_LSHIFT( q1_Q10, 4 ); - if ( NSQ->rand_seed < 0 ) { - exc_Q14 = -exc_Q14; - } - - /* Add predictions */ - LPC_exc_Q14 = silk_ADD_LSHIFT32( exc_Q14, LTP_pred_Q13, 1 ); - xq_Q14 = silk_ADD_LSHIFT32( LPC_exc_Q14, LPC_pred_Q10, 4 ); - - /* Scale XQ back to normal level before saving */ - xq[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( xq_Q14, Gain_Q10 ), 8 ) ); - - /* Update states */ - psLPC_Q14++; - *psLPC_Q14 = xq_Q14; - NSQ->sDiff_shp_Q14 = silk_SUB_LSHIFT32( xq_Q14, x_sc_Q10[ i ], 4 ); - sLF_AR_shp_Q14 = silk_SUB_LSHIFT32( NSQ->sDiff_shp_Q14, n_AR_Q12, 2 ); - NSQ->sLF_AR_shp_Q14 = sLF_AR_shp_Q14; - - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx ] = silk_SUB_LSHIFT32( sLF_AR_shp_Q14, n_LF_Q12, 2 ); - sLTP_Q15[ NSQ->sLTP_buf_idx ] = silk_LSHIFT( LPC_exc_Q14, 1 ); - NSQ->sLTP_shp_buf_idx++; - NSQ->sLTP_buf_idx++; - - /* Make dither dependent on quantized signal */ - NSQ->rand_seed = silk_ADD32_ovflw( NSQ->rand_seed, pulses[ i ] ); - } - - /* Update LPC synth buffer */ - silk_memcpy( NSQ->sLPC_Q14, &NSQ->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); -} - -static OPUS_INLINE void silk_nsq_scale_states( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - const opus_int16 x16[], /* I input */ - opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ - const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I subframe number */ - const opus_int LTP_scale_Q14, /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type /* I Signal type */ -) -{ - opus_int i, lag; - opus_int32 gain_adj_Q16, inv_gain_Q31, inv_gain_Q26; - - lag = pitchL[ subfr ]; - inv_gain_Q31 = silk_INVERSE32_varQ( silk_max( Gains_Q16[ subfr ], 1 ), 47 ); - silk_assert( inv_gain_Q31 != 0 ); - - /* Scale input */ - inv_gain_Q26 = silk_RSHIFT_ROUND( inv_gain_Q31, 5 ); - for( i = 0; i < psEncC->subfr_length; i++ ) { - x_sc_Q10[ i ] = silk_SMULWW( x16[ i ], inv_gain_Q26 ); - } - - /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */ - if( NSQ->rewhite_flag ) { - if( subfr == 0 ) { - /* Do LTP downscaling */ - inv_gain_Q31 = silk_LSHIFT( silk_SMULWB( inv_gain_Q31, LTP_scale_Q14 ), 2 ); - } - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) { - silk_assert( i < MAX_FRAME_LENGTH ); - sLTP_Q15[ i ] = silk_SMULWB( inv_gain_Q31, sLTP[ i ] ); - } - } - - /* Adjust for changing gain */ - if( Gains_Q16[ subfr ] != NSQ->prev_gain_Q16 ) { - gain_adj_Q16 = silk_DIV32_varQ( NSQ->prev_gain_Q16, Gains_Q16[ subfr ], 16 ); - - /* Scale long-term shaping state */ - for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx; i++ ) { - NSQ->sLTP_shp_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q14[ i ] ); - } - - /* Scale long-term prediction state */ - if( signal_type == TYPE_VOICED && NSQ->rewhite_flag == 0 ) { - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) { - sLTP_Q15[ i ] = silk_SMULWW( gain_adj_Q16, sLTP_Q15[ i ] ); - } - } - - NSQ->sLF_AR_shp_Q14 = silk_SMULWW( gain_adj_Q16, NSQ->sLF_AR_shp_Q14 ); - NSQ->sDiff_shp_Q14 = silk_SMULWW( gain_adj_Q16, NSQ->sDiff_shp_Q14 ); - - /* Scale short-term prediction and shaping states */ - for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { - NSQ->sLPC_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLPC_Q14[ i ] ); - } - for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { - NSQ->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sAR2_Q14[ i ] ); - } - - /* Save inverse gain */ - NSQ->prev_gain_Q16 = Gains_Q16[ subfr ]; - } -} diff --git a/Engine/lib/opus/silk/NSQ.h b/Engine/lib/opus/silk/NSQ.h deleted file mode 100644 index 971832f66..000000000 --- a/Engine/lib/opus/silk/NSQ.h +++ /dev/null @@ -1,101 +0,0 @@ -/*********************************************************************** -Copyright (c) 2014 Vidyo. -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 SILK_NSQ_H -#define SILK_NSQ_H - -#include "SigProc_FIX.h" - -#undef silk_short_prediction_create_arch_coef - -static OPUS_INLINE opus_int32 silk_noise_shape_quantizer_short_prediction_c(const opus_int32 *buf32, const opus_int16 *coef16, opus_int order) -{ - opus_int32 out; - silk_assert( order == 10 || order == 16 ); - - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - out = silk_RSHIFT( order, 1 ); - out = silk_SMLAWB( out, buf32[ 0 ], coef16[ 0 ] ); - out = silk_SMLAWB( out, buf32[ -1 ], coef16[ 1 ] ); - out = silk_SMLAWB( out, buf32[ -2 ], coef16[ 2 ] ); - out = silk_SMLAWB( out, buf32[ -3 ], coef16[ 3 ] ); - out = silk_SMLAWB( out, buf32[ -4 ], coef16[ 4 ] ); - out = silk_SMLAWB( out, buf32[ -5 ], coef16[ 5 ] ); - out = silk_SMLAWB( out, buf32[ -6 ], coef16[ 6 ] ); - out = silk_SMLAWB( out, buf32[ -7 ], coef16[ 7 ] ); - out = silk_SMLAWB( out, buf32[ -8 ], coef16[ 8 ] ); - out = silk_SMLAWB( out, buf32[ -9 ], coef16[ 9 ] ); - - if( order == 16 ) - { - out = silk_SMLAWB( out, buf32[ -10 ], coef16[ 10 ] ); - out = silk_SMLAWB( out, buf32[ -11 ], coef16[ 11 ] ); - out = silk_SMLAWB( out, buf32[ -12 ], coef16[ 12 ] ); - out = silk_SMLAWB( out, buf32[ -13 ], coef16[ 13 ] ); - out = silk_SMLAWB( out, buf32[ -14 ], coef16[ 14 ] ); - out = silk_SMLAWB( out, buf32[ -15 ], coef16[ 15 ] ); - } - return out; -} - -#define silk_noise_shape_quantizer_short_prediction(in, coef, coefRev, order, arch) ((void)arch,silk_noise_shape_quantizer_short_prediction_c(in, coef, order)) - -static OPUS_INLINE opus_int32 silk_NSQ_noise_shape_feedback_loop_c(const opus_int32 *data0, opus_int32 *data1, const opus_int16 *coef, opus_int order) -{ - opus_int32 out; - opus_int32 tmp1, tmp2; - opus_int j; - - tmp2 = data0[0]; - tmp1 = data1[0]; - data1[0] = tmp2; - - out = silk_RSHIFT(order, 1); - out = silk_SMLAWB(out, tmp2, coef[0]); - - for (j = 2; j < order; j += 2) { - tmp2 = data1[j - 1]; - data1[j - 1] = tmp1; - out = silk_SMLAWB(out, tmp1, coef[j - 1]); - tmp1 = data1[j + 0]; - data1[j + 0] = tmp2; - out = silk_SMLAWB(out, tmp2, coef[j]); - } - data1[order - 1] = tmp1; - out = silk_SMLAWB(out, tmp1, coef[order - 1]); - /* Q11 -> Q12 */ - out = silk_LSHIFT32( out, 1 ); - return out; -} - -#define silk_NSQ_noise_shape_feedback_loop(data0, data1, coef, order, arch) ((void)arch,silk_NSQ_noise_shape_feedback_loop_c(data0, data1, coef, order)) - -#if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -#include "arm/NSQ_neon.h" -#endif - -#endif /* SILK_NSQ_H */ diff --git a/Engine/lib/opus/silk/NSQ_del_dec.c b/Engine/lib/opus/silk/NSQ_del_dec.c deleted file mode 100644 index 41f3fc93e..000000000 --- a/Engine/lib/opus/silk/NSQ_del_dec.c +++ /dev/null @@ -1,733 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" -#include "NSQ.h" - - -typedef struct { - opus_int32 sLPC_Q14[ MAX_SUB_FRAME_LENGTH + NSQ_LPC_BUF_LENGTH ]; - opus_int32 RandState[ DECISION_DELAY ]; - opus_int32 Q_Q10[ DECISION_DELAY ]; - opus_int32 Xq_Q14[ DECISION_DELAY ]; - opus_int32 Pred_Q15[ DECISION_DELAY ]; - opus_int32 Shape_Q14[ DECISION_DELAY ]; - opus_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ]; - opus_int32 LF_AR_Q14; - opus_int32 Diff_Q14; - opus_int32 Seed; - opus_int32 SeedInit; - opus_int32 RD_Q10; -} NSQ_del_dec_struct; - -typedef struct { - opus_int32 Q_Q10; - opus_int32 RD_Q10; - opus_int32 xq_Q14; - opus_int32 LF_AR_Q14; - opus_int32 Diff_Q14; - opus_int32 sLTP_shp_Q14; - opus_int32 LPC_exc_Q14; -} NSQ_sample_struct; - -typedef NSQ_sample_struct NSQ_sample_pair[ 2 ]; - -#if defined(MIPSr1_ASM) -#include "mips/NSQ_del_dec_mipsr1.h" -#endif -static OPUS_INLINE void silk_nsq_del_dec_scale_states( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - const opus_int16 x16[], /* I Input */ - opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ - const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I Subframe number */ - opus_int nStatesDelayedDecision, /* I Number of del dec states */ - const opus_int LTP_scale_Q14, /* I LTP state scaling */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type, /* I Signal type */ - const opus_int decisionDelay /* I Decision delay */ -); - -/******************************************/ -/* Noise shape quantizer for one subframe */ -/******************************************/ -static OPUS_INLINE void silk_noise_shape_quantizer_del_dec( - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP filter state */ - opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int subfr, /* I Subframe number */ - opus_int shapingLPCOrder, /* I Shaping LPC filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - opus_int warping_Q16, /* I */ - opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ - opus_int *smpl_buf_idx, /* I/O Index to newest samples in buffers */ - opus_int decisionDelay, /* I */ - int arch /* I */ -); - -void silk_NSQ_del_dec_c( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -) -{ - opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr; - opus_int last_smple_idx, smpl_buf_idx, decisionDelay; - const opus_int16 *A_Q12, *B_Q14, *AR_shp_Q13; - opus_int16 *pxq; - VARDECL( opus_int32, sLTP_Q15 ); - VARDECL( opus_int16, sLTP ); - opus_int32 HarmShapeFIRPacked_Q14; - opus_int offset_Q10; - opus_int32 RDmin_Q10, Gain_Q10; - VARDECL( opus_int32, x_sc_Q10 ); - VARDECL( opus_int32, delayedGain_Q10 ); - VARDECL( NSQ_del_dec_struct, psDelDec ); - NSQ_del_dec_struct *psDD; - SAVE_STACK; - - /* Set unvoiced lag to the previous one, overwrite later for voiced */ - lag = NSQ->lagPrev; - - silk_assert( NSQ->prev_gain_Q16 != 0 ); - - /* Initialize delayed decision states */ - ALLOC( psDelDec, psEncC->nStatesDelayedDecision, NSQ_del_dec_struct ); - silk_memset( psDelDec, 0, psEncC->nStatesDelayedDecision * sizeof( NSQ_del_dec_struct ) ); - for( k = 0; k < psEncC->nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - psDD->Seed = ( k + psIndices->Seed ) & 3; - psDD->SeedInit = psDD->Seed; - psDD->RD_Q10 = 0; - psDD->LF_AR_Q14 = NSQ->sLF_AR_shp_Q14; - psDD->Diff_Q14 = NSQ->sDiff_shp_Q14; - psDD->Shape_Q14[ 0 ] = NSQ->sLTP_shp_Q14[ psEncC->ltp_mem_length - 1 ]; - silk_memcpy( psDD->sLPC_Q14, NSQ->sLPC_Q14, NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); - silk_memcpy( psDD->sAR2_Q14, NSQ->sAR2_Q14, sizeof( NSQ->sAR2_Q14 ) ); - } - - offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; - smpl_buf_idx = 0; /* index of oldest samples */ - - decisionDelay = silk_min_int( DECISION_DELAY, psEncC->subfr_length ); - - /* For voiced frames limit the decision delay to lower than the pitch lag */ - if( psIndices->signalType == TYPE_VOICED ) { - for( k = 0; k < psEncC->nb_subfr; k++ ) { - decisionDelay = silk_min_int( decisionDelay, pitchL[ k ] - LTP_ORDER / 2 - 1 ); - } - } else { - if( lag > 0 ) { - decisionDelay = silk_min_int( decisionDelay, lag - LTP_ORDER / 2 - 1 ); - } - } - - if( psIndices->NLSFInterpCoef_Q2 == 4 ) { - LSF_interpolation_flag = 0; - } else { - LSF_interpolation_flag = 1; - } - - ALLOC( sLTP_Q15, psEncC->ltp_mem_length + psEncC->frame_length, opus_int32 ); - ALLOC( sLTP, psEncC->ltp_mem_length + psEncC->frame_length, opus_int16 ); - ALLOC( x_sc_Q10, psEncC->subfr_length, opus_int32 ); - ALLOC( delayedGain_Q10, DECISION_DELAY, opus_int32 ); - /* Set up pointers to start of sub frame */ - pxq = &NSQ->xq[ psEncC->ltp_mem_length ]; - NSQ->sLTP_shp_buf_idx = psEncC->ltp_mem_length; - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - subfr = 0; - for( k = 0; k < psEncC->nb_subfr; k++ ) { - A_Q12 = &PredCoef_Q12[ ( ( k >> 1 ) | ( 1 - LSF_interpolation_flag ) ) * MAX_LPC_ORDER ]; - B_Q14 = <PCoef_Q14[ k * LTP_ORDER ]; - AR_shp_Q13 = &AR_Q13[ k * MAX_SHAPE_LPC_ORDER ]; - - /* Noise shape parameters */ - silk_assert( HarmShapeGain_Q14[ k ] >= 0 ); - HarmShapeFIRPacked_Q14 = silk_RSHIFT( HarmShapeGain_Q14[ k ], 2 ); - HarmShapeFIRPacked_Q14 |= silk_LSHIFT( (opus_int32)silk_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 ); - - NSQ->rewhite_flag = 0; - if( psIndices->signalType == TYPE_VOICED ) { - /* Voiced */ - lag = pitchL[ k ]; - - /* Re-whitening */ - if( ( k & ( 3 - silk_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) { - if( k == 2 ) { - /* RESET DELAYED DECISIONS */ - /* Find winner */ - RDmin_Q10 = psDelDec[ 0 ].RD_Q10; - Winner_ind = 0; - for( i = 1; i < psEncC->nStatesDelayedDecision; i++ ) { - if( psDelDec[ i ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psDelDec[ i ].RD_Q10; - Winner_ind = i; - } - } - for( i = 0; i < psEncC->nStatesDelayedDecision; i++ ) { - if( i != Winner_ind ) { - psDelDec[ i ].RD_Q10 += ( silk_int32_MAX >> 4 ); - silk_assert( psDelDec[ i ].RD_Q10 >= 0 ); - } - } - - /* Copy final part of signals from winner state to output and long-term filter states */ - psDD = &psDelDec[ Winner_ind ]; - last_smple_idx = smpl_buf_idx + decisionDelay; - for( i = 0; i < decisionDelay; i++ ) { - last_smple_idx = ( last_smple_idx - 1 ) % DECISION_DELAY; - if( last_smple_idx < 0 ) last_smple_idx += DECISION_DELAY; - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); - pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( - silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gains_Q16[ 1 ] ), 14 ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q14[ last_smple_idx ]; - } - - subfr = 0; - } - - /* Rewhiten with new A coefs */ - start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2; - celt_assert( start_idx > 0 ); - - silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], - A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder, psEncC->arch ); - - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - NSQ->rewhite_flag = 1; - } - } - - silk_nsq_del_dec_scale_states( psEncC, NSQ, psDelDec, x16, x_sc_Q10, sLTP, sLTP_Q15, k, - psEncC->nStatesDelayedDecision, LTP_scale_Q14, Gains_Q16, pitchL, psIndices->signalType, decisionDelay ); - - silk_noise_shape_quantizer_del_dec( NSQ, psDelDec, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q15, - delayedGain_Q10, A_Q12, B_Q14, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], - Gains_Q16[ k ], Lambda_Q10, offset_Q10, psEncC->subfr_length, subfr++, psEncC->shapingLPCOrder, - psEncC->predictLPCOrder, psEncC->warping_Q16, psEncC->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay, psEncC->arch ); - - x16 += psEncC->subfr_length; - pulses += psEncC->subfr_length; - pxq += psEncC->subfr_length; - } - - /* Find winner */ - RDmin_Q10 = psDelDec[ 0 ].RD_Q10; - Winner_ind = 0; - for( k = 1; k < psEncC->nStatesDelayedDecision; k++ ) { - if( psDelDec[ k ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psDelDec[ k ].RD_Q10; - Winner_ind = k; - } - } - - /* Copy final part of signals from winner state to output and long-term filter states */ - psDD = &psDelDec[ Winner_ind ]; - psIndices->Seed = psDD->SeedInit; - last_smple_idx = smpl_buf_idx + decisionDelay; - Gain_Q10 = silk_RSHIFT32( Gains_Q16[ psEncC->nb_subfr - 1 ], 6 ); - for( i = 0; i < decisionDelay; i++ ) { - last_smple_idx = ( last_smple_idx - 1 ) % DECISION_DELAY; - if( last_smple_idx < 0 ) last_smple_idx += DECISION_DELAY; - - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); - pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( - silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gain_Q10 ), 8 ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q14[ last_smple_idx ]; - } - silk_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); - silk_memcpy( NSQ->sAR2_Q14, psDD->sAR2_Q14, sizeof( psDD->sAR2_Q14 ) ); - - /* Update states */ - NSQ->sLF_AR_shp_Q14 = psDD->LF_AR_Q14; - NSQ->sDiff_shp_Q14 = psDD->Diff_Q14; - NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ]; - - /* Save quantized speech signal */ - silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) ); - silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) ); - RESTORE_STACK; -} - -/******************************************/ -/* Noise shape quantizer for one subframe */ -/******************************************/ -#ifndef OVERRIDE_silk_noise_shape_quantizer_del_dec -static OPUS_INLINE void silk_noise_shape_quantizer_del_dec( - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP filter state */ - opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int subfr, /* I Subframe number */ - opus_int shapingLPCOrder, /* I Shaping LPC filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - opus_int warping_Q16, /* I */ - opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ - opus_int *smpl_buf_idx, /* I/O Index to newest samples in buffers */ - opus_int decisionDelay, /* I */ - int arch /* I */ -) -{ - opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; - opus_int32 Winner_rand_state; - opus_int32 LTP_pred_Q14, LPC_pred_Q14, n_AR_Q14, n_LTP_Q14; - opus_int32 n_LF_Q14, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10; - opus_int32 q1_Q0, q1_Q10, q2_Q10, exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10; - opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; - opus_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14; -#ifdef silk_short_prediction_create_arch_coef - opus_int32 a_Q12_arch[MAX_LPC_ORDER]; -#endif - - VARDECL( NSQ_sample_pair, psSampleState ); - NSQ_del_dec_struct *psDD; - NSQ_sample_struct *psSS; - SAVE_STACK; - - celt_assert( nStatesDelayedDecision > 0 ); - ALLOC( psSampleState, nStatesDelayedDecision, NSQ_sample_pair ); - - shp_lag_ptr = &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ]; - pred_lag_ptr = &sLTP_Q15[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ]; - Gain_Q10 = silk_RSHIFT( Gain_Q16, 6 ); - -#ifdef silk_short_prediction_create_arch_coef - silk_short_prediction_create_arch_coef(a_Q12_arch, a_Q12, predictLPCOrder); -#endif - - for( i = 0; i < length; i++ ) { - /* Perform common calculations used in all states */ - - /* Long-term prediction */ - if( signalType == TYPE_VOICED ) { - /* Unrolled loop */ - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LTP_pred_Q14 = 2; - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ 0 ], b_Q14[ 0 ] ); - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -1 ], b_Q14[ 1 ] ); - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -2 ], b_Q14[ 2 ] ); - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -3 ], b_Q14[ 3 ] ); - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], b_Q14[ 4 ] ); - LTP_pred_Q14 = silk_LSHIFT( LTP_pred_Q14, 1 ); /* Q13 -> Q14 */ - pred_lag_ptr++; - } else { - LTP_pred_Q14 = 0; - } - - /* Long-term shaping */ - if( lag > 0 ) { - /* Symmetric, packed FIR coefficients */ - n_LTP_Q14 = silk_SMULWB( silk_ADD_SAT32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = silk_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = silk_SUB_LSHIFT32( LTP_pred_Q14, n_LTP_Q14, 2 ); /* Q12 -> Q14 */ - shp_lag_ptr++; - } else { - n_LTP_Q14 = 0; - } - - for( k = 0; k < nStatesDelayedDecision; k++ ) { - /* Delayed decision state */ - psDD = &psDelDec[ k ]; - - /* Sample state */ - psSS = psSampleState[ k ]; - - /* Generate dither */ - psDD->Seed = silk_RAND( psDD->Seed ); - - /* Pointer used in short term prediction and shaping */ - psLPC_Q14 = &psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 + i ]; - /* Short-term prediction */ - LPC_pred_Q14 = silk_noise_shape_quantizer_short_prediction(psLPC_Q14, a_Q12, a_Q12_arch, predictLPCOrder, arch); - LPC_pred_Q14 = silk_LSHIFT( LPC_pred_Q14, 4 ); /* Q10 -> Q14 */ - - /* Noise shape feedback */ - celt_assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */ - /* Output of lowpass section */ - tmp2 = silk_SMLAWB( psDD->Diff_Q14, psDD->sAR2_Q14[ 0 ], warping_Q16 ); - /* Output of allpass section */ - tmp1 = silk_SMLAWB( psDD->sAR2_Q14[ 0 ], psDD->sAR2_Q14[ 1 ] - tmp2, warping_Q16 ); - psDD->sAR2_Q14[ 0 ] = tmp2; - n_AR_Q14 = silk_RSHIFT( shapingLPCOrder, 1 ); - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp2, AR_shp_Q13[ 0 ] ); - /* Loop over allpass sections */ - for( j = 2; j < shapingLPCOrder; j += 2 ) { - /* Output of allpass section */ - tmp2 = silk_SMLAWB( psDD->sAR2_Q14[ j - 1 ], psDD->sAR2_Q14[ j + 0 ] - tmp1, warping_Q16 ); - psDD->sAR2_Q14[ j - 1 ] = tmp1; - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp1, AR_shp_Q13[ j - 1 ] ); - /* Output of allpass section */ - tmp1 = silk_SMLAWB( psDD->sAR2_Q14[ j + 0 ], psDD->sAR2_Q14[ j + 1 ] - tmp2, warping_Q16 ); - psDD->sAR2_Q14[ j + 0 ] = tmp2; - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp2, AR_shp_Q13[ j ] ); - } - psDD->sAR2_Q14[ shapingLPCOrder - 1 ] = tmp1; - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp1, AR_shp_Q13[ shapingLPCOrder - 1 ] ); - - n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 1 ); /* Q11 -> Q12 */ - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, psDD->LF_AR_Q14, Tilt_Q14 ); /* Q12 */ - n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 2 ); /* Q12 -> Q14 */ - - n_LF_Q14 = silk_SMULWB( psDD->Shape_Q14[ *smpl_buf_idx ], LF_shp_Q14 ); /* Q12 */ - n_LF_Q14 = silk_SMLAWT( n_LF_Q14, psDD->LF_AR_Q14, LF_shp_Q14 ); /* Q12 */ - n_LF_Q14 = silk_LSHIFT( n_LF_Q14, 2 ); /* Q12 -> Q14 */ - - /* Input minus prediction plus noise feedback */ - /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP */ - tmp1 = silk_ADD_SAT32( n_AR_Q14, n_LF_Q14 ); /* Q14 */ - tmp2 = silk_ADD32( n_LTP_Q14, LPC_pred_Q14 ); /* Q13 */ - tmp1 = silk_SUB_SAT32( tmp2, tmp1 ); /* Q13 */ - tmp1 = silk_RSHIFT_ROUND( tmp1, 4 ); /* Q10 */ - - r_Q10 = silk_SUB32( x_Q10[ i ], tmp1 ); /* residual error Q10 */ - - /* Flip sign depending on dither */ - if ( psDD->Seed < 0 ) { - r_Q10 = -r_Q10; - } - r_Q10 = silk_LIMIT_32( r_Q10, -(31 << 10), 30 << 10 ); - - /* Find two quantization level candidates and measure their rate-distortion */ - q1_Q10 = silk_SUB32( r_Q10, offset_Q10 ); - q1_Q0 = silk_RSHIFT( q1_Q10, 10 ); - if (Lambda_Q10 > 2048) { - /* For aggressive RDO, the bias becomes more than one pulse. */ - int rdo_offset = Lambda_Q10/2 - 512; - if (q1_Q10 > rdo_offset) { - q1_Q0 = silk_RSHIFT( q1_Q10 - rdo_offset, 10 ); - } else if (q1_Q10 < -rdo_offset) { - q1_Q0 = silk_RSHIFT( q1_Q10 + rdo_offset, 10 ); - } else if (q1_Q10 < 0) { - q1_Q0 = -1; - } else { - q1_Q0 = 0; - } - } - if( q1_Q0 > 0 ) { - q1_Q10 = silk_SUB32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); - q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); - q2_Q10 = silk_ADD32( q1_Q10, 1024 ); - rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else if( q1_Q0 == 0 ) { - q1_Q10 = offset_Q10; - q2_Q10 = silk_ADD32( q1_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); - rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else if( q1_Q0 == -1 ) { - q2_Q10 = offset_Q10; - q1_Q10 = silk_SUB32( q2_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); - rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else { /* q1_Q0 < -1 */ - q1_Q10 = silk_ADD32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); - q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); - q2_Q10 = silk_ADD32( q1_Q10, 1024 ); - rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( -q2_Q10, Lambda_Q10 ); - } - rr_Q10 = silk_SUB32( r_Q10, q1_Q10 ); - rd1_Q10 = silk_RSHIFT( silk_SMLABB( rd1_Q10, rr_Q10, rr_Q10 ), 10 ); - rr_Q10 = silk_SUB32( r_Q10, q2_Q10 ); - rd2_Q10 = silk_RSHIFT( silk_SMLABB( rd2_Q10, rr_Q10, rr_Q10 ), 10 ); - - if( rd1_Q10 < rd2_Q10 ) { - psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); - psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); - psSS[ 0 ].Q_Q10 = q1_Q10; - psSS[ 1 ].Q_Q10 = q2_Q10; - } else { - psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); - psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); - psSS[ 0 ].Q_Q10 = q2_Q10; - psSS[ 1 ].Q_Q10 = q1_Q10; - } - - /* Update states for best quantization */ - - /* Quantized excitation */ - exc_Q14 = silk_LSHIFT32( psSS[ 0 ].Q_Q10, 4 ); - if ( psDD->Seed < 0 ) { - exc_Q14 = -exc_Q14; - } - - /* Add predictions */ - LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); - xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); - - /* Update states */ - psSS[ 0 ].Diff_Q14 = silk_SUB_LSHIFT32( xq_Q14, x_Q10[ i ], 4 ); - sLF_AR_shp_Q14 = silk_SUB32( psSS[ 0 ].Diff_Q14, n_AR_Q14 ); - psSS[ 0 ].sLTP_shp_Q14 = silk_SUB_SAT32( sLF_AR_shp_Q14, n_LF_Q14 ); - psSS[ 0 ].LF_AR_Q14 = sLF_AR_shp_Q14; - psSS[ 0 ].LPC_exc_Q14 = LPC_exc_Q14; - psSS[ 0 ].xq_Q14 = xq_Q14; - - /* Update states for second best quantization */ - - /* Quantized excitation */ - exc_Q14 = silk_LSHIFT32( psSS[ 1 ].Q_Q10, 4 ); - if ( psDD->Seed < 0 ) { - exc_Q14 = -exc_Q14; - } - - /* Add predictions */ - LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); - xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); - - /* Update states */ - psSS[ 1 ].Diff_Q14 = silk_SUB_LSHIFT32( xq_Q14, x_Q10[ i ], 4 ); - sLF_AR_shp_Q14 = silk_SUB32( psSS[ 1 ].Diff_Q14, n_AR_Q14 ); - psSS[ 1 ].sLTP_shp_Q14 = silk_SUB_SAT32( sLF_AR_shp_Q14, n_LF_Q14 ); - psSS[ 1 ].LF_AR_Q14 = sLF_AR_shp_Q14; - psSS[ 1 ].LPC_exc_Q14 = LPC_exc_Q14; - psSS[ 1 ].xq_Q14 = xq_Q14; - } - - *smpl_buf_idx = ( *smpl_buf_idx - 1 ) % DECISION_DELAY; - if( *smpl_buf_idx < 0 ) *smpl_buf_idx += DECISION_DELAY; - last_smple_idx = ( *smpl_buf_idx + decisionDelay ) % DECISION_DELAY; - - /* Find winner */ - RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; - Winner_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ k ][ 0 ].RD_Q10; - Winner_ind = k; - } - } - - /* Increase RD values of expired states */ - Winner_rand_state = psDelDec[ Winner_ind ].RandState[ last_smple_idx ]; - for( k = 0; k < nStatesDelayedDecision; k++ ) { - if( psDelDec[ k ].RandState[ last_smple_idx ] != Winner_rand_state ) { - psSampleState[ k ][ 0 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 0 ].RD_Q10, silk_int32_MAX >> 4 ); - psSampleState[ k ][ 1 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 1 ].RD_Q10, silk_int32_MAX >> 4 ); - silk_assert( psSampleState[ k ][ 0 ].RD_Q10 >= 0 ); - } - } - - /* Find worst in first set and best in second set */ - RDmax_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; - RDmin_Q10 = psSampleState[ 0 ][ 1 ].RD_Q10; - RDmax_ind = 0; - RDmin_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - /* find worst in first set */ - if( psSampleState[ k ][ 0 ].RD_Q10 > RDmax_Q10 ) { - RDmax_Q10 = psSampleState[ k ][ 0 ].RD_Q10; - RDmax_ind = k; - } - /* find best in second set */ - if( psSampleState[ k ][ 1 ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ k ][ 1 ].RD_Q10; - RDmin_ind = k; - } - } - - /* Replace a state if best from second set outperforms worst in first set */ - if( RDmin_Q10 < RDmax_Q10 ) { - silk_memcpy( ( (opus_int32 *)&psDelDec[ RDmax_ind ] ) + i, - ( (opus_int32 *)&psDelDec[ RDmin_ind ] ) + i, sizeof( NSQ_del_dec_struct ) - i * sizeof( opus_int32) ); - silk_memcpy( &psSampleState[ RDmax_ind ][ 0 ], &psSampleState[ RDmin_ind ][ 1 ], sizeof( NSQ_sample_struct ) ); - } - - /* Write samples from winner to output and long-term filter states */ - psDD = &psDelDec[ Winner_ind ]; - if( subfr > 0 || i >= decisionDelay ) { - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); - xq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( - silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], delayedGain_Q10[ last_smple_idx ] ), 8 ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDD->Shape_Q14[ last_smple_idx ]; - sLTP_Q15[ NSQ->sLTP_buf_idx - decisionDelay ] = psDD->Pred_Q15[ last_smple_idx ]; - } - NSQ->sLTP_shp_buf_idx++; - NSQ->sLTP_buf_idx++; - - /* Update states */ - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - psSS = &psSampleState[ k ][ 0 ]; - psDD->LF_AR_Q14 = psSS->LF_AR_Q14; - psDD->Diff_Q14 = psSS->Diff_Q14; - psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH + i ] = psSS->xq_Q14; - psDD->Xq_Q14[ *smpl_buf_idx ] = psSS->xq_Q14; - psDD->Q_Q10[ *smpl_buf_idx ] = psSS->Q_Q10; - psDD->Pred_Q15[ *smpl_buf_idx ] = silk_LSHIFT32( psSS->LPC_exc_Q14, 1 ); - psDD->Shape_Q14[ *smpl_buf_idx ] = psSS->sLTP_shp_Q14; - psDD->Seed = silk_ADD32_ovflw( psDD->Seed, silk_RSHIFT_ROUND( psSS->Q_Q10, 10 ) ); - psDD->RandState[ *smpl_buf_idx ] = psDD->Seed; - psDD->RD_Q10 = psSS->RD_Q10; - } - delayedGain_Q10[ *smpl_buf_idx ] = Gain_Q10; - } - /* Update LPC states */ - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - silk_memcpy( psDD->sLPC_Q14, &psDD->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); - } - RESTORE_STACK; -} -#endif /* OVERRIDE_silk_noise_shape_quantizer_del_dec */ - -static OPUS_INLINE void silk_nsq_del_dec_scale_states( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - const opus_int16 x16[], /* I Input */ - opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ - const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I Subframe number */ - opus_int nStatesDelayedDecision, /* I Number of del dec states */ - const opus_int LTP_scale_Q14, /* I LTP state scaling */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type, /* I Signal type */ - const opus_int decisionDelay /* I Decision delay */ -) -{ - opus_int i, k, lag; - opus_int32 gain_adj_Q16, inv_gain_Q31, inv_gain_Q26; - NSQ_del_dec_struct *psDD; - - lag = pitchL[ subfr ]; - inv_gain_Q31 = silk_INVERSE32_varQ( silk_max( Gains_Q16[ subfr ], 1 ), 47 ); - silk_assert( inv_gain_Q31 != 0 ); - - /* Scale input */ - inv_gain_Q26 = silk_RSHIFT_ROUND( inv_gain_Q31, 5 ); - for( i = 0; i < psEncC->subfr_length; i++ ) { - x_sc_Q10[ i ] = silk_SMULWW( x16[ i ], inv_gain_Q26 ); - } - - /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */ - if( NSQ->rewhite_flag ) { - if( subfr == 0 ) { - /* Do LTP downscaling */ - inv_gain_Q31 = silk_LSHIFT( silk_SMULWB( inv_gain_Q31, LTP_scale_Q14 ), 2 ); - } - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) { - silk_assert( i < MAX_FRAME_LENGTH ); - sLTP_Q15[ i ] = silk_SMULWB( inv_gain_Q31, sLTP[ i ] ); - } - } - - /* Adjust for changing gain */ - if( Gains_Q16[ subfr ] != NSQ->prev_gain_Q16 ) { - gain_adj_Q16 = silk_DIV32_varQ( NSQ->prev_gain_Q16, Gains_Q16[ subfr ], 16 ); - - /* Scale long-term shaping state */ - for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx; i++ ) { - NSQ->sLTP_shp_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q14[ i ] ); - } - - /* Scale long-term prediction state */ - if( signal_type == TYPE_VOICED && NSQ->rewhite_flag == 0 ) { - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx - decisionDelay; i++ ) { - sLTP_Q15[ i ] = silk_SMULWW( gain_adj_Q16, sLTP_Q15[ i ] ); - } - } - - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - - /* Scale scalar states */ - psDD->LF_AR_Q14 = silk_SMULWW( gain_adj_Q16, psDD->LF_AR_Q14 ); - psDD->Diff_Q14 = silk_SMULWW( gain_adj_Q16, psDD->Diff_Q14 ); - - /* Scale short-term prediction and shaping states */ - for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { - psDD->sLPC_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->sLPC_Q14[ i ] ); - } - for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { - psDD->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->sAR2_Q14[ i ] ); - } - for( i = 0; i < DECISION_DELAY; i++ ) { - psDD->Pred_Q15[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Pred_Q15[ i ] ); - psDD->Shape_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Shape_Q14[ i ] ); - } - } - - /* Save inverse gain */ - NSQ->prev_gain_Q16 = Gains_Q16[ subfr ]; - } -} diff --git a/Engine/lib/opus/silk/PLC.c b/Engine/lib/opus/silk/PLC.c deleted file mode 100644 index 4667440db..000000000 --- a/Engine/lib/opus/silk/PLC.c +++ /dev/null @@ -1,446 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" -#include "PLC.h" - -#define NB_ATT 2 -static const opus_int16 HARM_ATT_Q15[NB_ATT] = { 32440, 31130 }; /* 0.99, 0.95 */ -static const opus_int16 PLC_RAND_ATTENUATE_V_Q15[NB_ATT] = { 31130, 26214 }; /* 0.95, 0.8 */ -static const opus_int16 PLC_RAND_ATTENUATE_UV_Q15[NB_ATT] = { 32440, 29491 }; /* 0.99, 0.9 */ - -static OPUS_INLINE void silk_PLC_update( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl /* I/O Decoder control */ -); - -static OPUS_INLINE void silk_PLC_conceal( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[], /* O LPC residual signal */ - int arch /* I Run-time architecture */ -); - - -void silk_PLC_Reset( - silk_decoder_state *psDec /* I/O Decoder state */ -) -{ - psDec->sPLC.pitchL_Q8 = silk_LSHIFT( psDec->frame_length, 8 - 1 ); - psDec->sPLC.prevGain_Q16[ 0 ] = SILK_FIX_CONST( 1, 16 ); - psDec->sPLC.prevGain_Q16[ 1 ] = SILK_FIX_CONST( 1, 16 ); - psDec->sPLC.subfr_length = 20; - psDec->sPLC.nb_subfr = 2; -} - -void silk_PLC( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[], /* I/O signal */ - opus_int lost, /* I Loss flag */ - int arch /* I Run-time architecture */ -) -{ - /* PLC control function */ - if( psDec->fs_kHz != psDec->sPLC.fs_kHz ) { - silk_PLC_Reset( psDec ); - psDec->sPLC.fs_kHz = psDec->fs_kHz; - } - - if( lost ) { - /****************************/ - /* Generate Signal */ - /****************************/ - silk_PLC_conceal( psDec, psDecCtrl, frame, arch ); - - psDec->lossCnt++; - } else { - /****************************/ - /* Update state */ - /****************************/ - silk_PLC_update( psDec, psDecCtrl ); - } -} - -/**************************************************/ -/* Update state of PLC */ -/**************************************************/ -static OPUS_INLINE void silk_PLC_update( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl /* I/O Decoder control */ -) -{ - opus_int32 LTP_Gain_Q14, temp_LTP_Gain_Q14; - opus_int i, j; - silk_PLC_struct *psPLC; - - psPLC = &psDec->sPLC; - - /* Update parameters used in case of packet loss */ - psDec->prevSignalType = psDec->indices.signalType; - LTP_Gain_Q14 = 0; - if( psDec->indices.signalType == TYPE_VOICED ) { - /* Find the parameters for the last subframe which contains a pitch pulse */ - for( j = 0; j * psDec->subfr_length < psDecCtrl->pitchL[ psDec->nb_subfr - 1 ]; j++ ) { - if( j == psDec->nb_subfr ) { - break; - } - temp_LTP_Gain_Q14 = 0; - for( i = 0; i < LTP_ORDER; i++ ) { - temp_LTP_Gain_Q14 += psDecCtrl->LTPCoef_Q14[ ( psDec->nb_subfr - 1 - j ) * LTP_ORDER + i ]; - } - if( temp_LTP_Gain_Q14 > LTP_Gain_Q14 ) { - LTP_Gain_Q14 = temp_LTP_Gain_Q14; - silk_memcpy( psPLC->LTPCoef_Q14, - &psDecCtrl->LTPCoef_Q14[ silk_SMULBB( psDec->nb_subfr - 1 - j, LTP_ORDER ) ], - LTP_ORDER * sizeof( opus_int16 ) ); - - psPLC->pitchL_Q8 = silk_LSHIFT( psDecCtrl->pitchL[ psDec->nb_subfr - 1 - j ], 8 ); - } - } - - silk_memset( psPLC->LTPCoef_Q14, 0, LTP_ORDER * sizeof( opus_int16 ) ); - psPLC->LTPCoef_Q14[ LTP_ORDER / 2 ] = LTP_Gain_Q14; - - /* Limit LT coefs */ - if( LTP_Gain_Q14 < V_PITCH_GAIN_START_MIN_Q14 ) { - opus_int scale_Q10; - opus_int32 tmp; - - tmp = silk_LSHIFT( V_PITCH_GAIN_START_MIN_Q14, 10 ); - scale_Q10 = silk_DIV32( tmp, silk_max( LTP_Gain_Q14, 1 ) ); - for( i = 0; i < LTP_ORDER; i++ ) { - psPLC->LTPCoef_Q14[ i ] = silk_RSHIFT( silk_SMULBB( psPLC->LTPCoef_Q14[ i ], scale_Q10 ), 10 ); - } - } else if( LTP_Gain_Q14 > V_PITCH_GAIN_START_MAX_Q14 ) { - opus_int scale_Q14; - opus_int32 tmp; - - tmp = silk_LSHIFT( V_PITCH_GAIN_START_MAX_Q14, 14 ); - scale_Q14 = silk_DIV32( tmp, silk_max( LTP_Gain_Q14, 1 ) ); - for( i = 0; i < LTP_ORDER; i++ ) { - psPLC->LTPCoef_Q14[ i ] = silk_RSHIFT( silk_SMULBB( psPLC->LTPCoef_Q14[ i ], scale_Q14 ), 14 ); - } - } - } else { - psPLC->pitchL_Q8 = silk_LSHIFT( silk_SMULBB( psDec->fs_kHz, 18 ), 8 ); - silk_memset( psPLC->LTPCoef_Q14, 0, LTP_ORDER * sizeof( opus_int16 )); - } - - /* Save LPC coeficients */ - silk_memcpy( psPLC->prevLPC_Q12, psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order * sizeof( opus_int16 ) ); - psPLC->prevLTP_scale_Q14 = psDecCtrl->LTP_scale_Q14; - - /* Save last two gains */ - silk_memcpy( psPLC->prevGain_Q16, &psDecCtrl->Gains_Q16[ psDec->nb_subfr - 2 ], 2 * sizeof( opus_int32 ) ); - - psPLC->subfr_length = psDec->subfr_length; - psPLC->nb_subfr = psDec->nb_subfr; -} - -static OPUS_INLINE void silk_PLC_energy(opus_int32 *energy1, opus_int *shift1, opus_int32 *energy2, opus_int *shift2, - const opus_int32 *exc_Q14, const opus_int32 *prevGain_Q10, int subfr_length, int nb_subfr) -{ - int i, k; - VARDECL( opus_int16, exc_buf ); - opus_int16 *exc_buf_ptr; - SAVE_STACK; - ALLOC( exc_buf, 2*subfr_length, opus_int16 ); - /* Find random noise component */ - /* Scale previous excitation signal */ - exc_buf_ptr = exc_buf; - for( k = 0; k < 2; k++ ) { - for( i = 0; i < subfr_length; i++ ) { - exc_buf_ptr[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT( - silk_SMULWW( exc_Q14[ i + ( k + nb_subfr - 2 ) * subfr_length ], prevGain_Q10[ k ] ), 8 ) ); - } - exc_buf_ptr += subfr_length; - } - /* Find the subframe with lowest energy of the last two and use that as random noise generator */ - silk_sum_sqr_shift( energy1, shift1, exc_buf, subfr_length ); - silk_sum_sqr_shift( energy2, shift2, &exc_buf[ subfr_length ], subfr_length ); - RESTORE_STACK; -} - -static OPUS_INLINE void silk_PLC_conceal( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[], /* O LPC residual signal */ - int arch /* I Run-time architecture */ -) -{ - opus_int i, j, k; - opus_int lag, idx, sLTP_buf_idx, shift1, shift2; - opus_int32 rand_seed, harm_Gain_Q15, rand_Gain_Q15, inv_gain_Q30; - opus_int32 energy1, energy2, *rand_ptr, *pred_lag_ptr; - opus_int32 LPC_pred_Q10, LTP_pred_Q12; - opus_int16 rand_scale_Q14; - opus_int16 *B_Q14; - opus_int32 *sLPC_Q14_ptr; - opus_int16 A_Q12[ MAX_LPC_ORDER ]; -#ifdef SMALL_FOOTPRINT - opus_int16 *sLTP; -#else - VARDECL( opus_int16, sLTP ); -#endif - VARDECL( opus_int32, sLTP_Q14 ); - silk_PLC_struct *psPLC = &psDec->sPLC; - opus_int32 prevGain_Q10[2]; - SAVE_STACK; - - ALLOC( sLTP_Q14, psDec->ltp_mem_length + psDec->frame_length, opus_int32 ); -#ifdef SMALL_FOOTPRINT - /* Ugly hack that breaks aliasing rules to save stack: put sLTP at the very end of sLTP_Q14. */ - sLTP = ((opus_int16*)&sLTP_Q14[psDec->ltp_mem_length + psDec->frame_length])-psDec->ltp_mem_length; -#else - ALLOC( sLTP, psDec->ltp_mem_length, opus_int16 ); -#endif - - prevGain_Q10[0] = silk_RSHIFT( psPLC->prevGain_Q16[ 0 ], 6); - prevGain_Q10[1] = silk_RSHIFT( psPLC->prevGain_Q16[ 1 ], 6); - - if( psDec->first_frame_after_reset ) { - silk_memset( psPLC->prevLPC_Q12, 0, sizeof( psPLC->prevLPC_Q12 ) ); - } - - silk_PLC_energy(&energy1, &shift1, &energy2, &shift2, psDec->exc_Q14, prevGain_Q10, psDec->subfr_length, psDec->nb_subfr); - - if( silk_RSHIFT( energy1, shift2 ) < silk_RSHIFT( energy2, shift1 ) ) { - /* First sub-frame has lowest energy */ - rand_ptr = &psDec->exc_Q14[ silk_max_int( 0, ( psPLC->nb_subfr - 1 ) * psPLC->subfr_length - RAND_BUF_SIZE ) ]; - } else { - /* Second sub-frame has lowest energy */ - rand_ptr = &psDec->exc_Q14[ silk_max_int( 0, psPLC->nb_subfr * psPLC->subfr_length - RAND_BUF_SIZE ) ]; - } - - /* Set up Gain to random noise component */ - B_Q14 = psPLC->LTPCoef_Q14; - rand_scale_Q14 = psPLC->randScale_Q14; - - /* Set up attenuation gains */ - harm_Gain_Q15 = HARM_ATT_Q15[ silk_min_int( NB_ATT - 1, psDec->lossCnt ) ]; - if( psDec->prevSignalType == TYPE_VOICED ) { - rand_Gain_Q15 = PLC_RAND_ATTENUATE_V_Q15[ silk_min_int( NB_ATT - 1, psDec->lossCnt ) ]; - } else { - rand_Gain_Q15 = PLC_RAND_ATTENUATE_UV_Q15[ silk_min_int( NB_ATT - 1, psDec->lossCnt ) ]; - } - - /* LPC concealment. Apply BWE to previous LPC */ - silk_bwexpander( psPLC->prevLPC_Q12, psDec->LPC_order, SILK_FIX_CONST( BWE_COEF, 16 ) ); - - /* Preload LPC coeficients to array on stack. Gives small performance gain */ - silk_memcpy( A_Q12, psPLC->prevLPC_Q12, psDec->LPC_order * sizeof( opus_int16 ) ); - - /* First Lost frame */ - if( psDec->lossCnt == 0 ) { - rand_scale_Q14 = 1 << 14; - - /* Reduce random noise Gain for voiced frames */ - if( psDec->prevSignalType == TYPE_VOICED ) { - for( i = 0; i < LTP_ORDER; i++ ) { - rand_scale_Q14 -= B_Q14[ i ]; - } - rand_scale_Q14 = silk_max_16( 3277, rand_scale_Q14 ); /* 0.2 */ - rand_scale_Q14 = (opus_int16)silk_RSHIFT( silk_SMULBB( rand_scale_Q14, psPLC->prevLTP_scale_Q14 ), 14 ); - } else { - /* Reduce random noise for unvoiced frames with high LPC gain */ - opus_int32 invGain_Q30, down_scale_Q30; - - invGain_Q30 = silk_LPC_inverse_pred_gain( psPLC->prevLPC_Q12, psDec->LPC_order, arch ); - - down_scale_Q30 = silk_min_32( silk_RSHIFT( (opus_int32)1 << 30, LOG2_INV_LPC_GAIN_HIGH_THRES ), invGain_Q30 ); - down_scale_Q30 = silk_max_32( silk_RSHIFT( (opus_int32)1 << 30, LOG2_INV_LPC_GAIN_LOW_THRES ), down_scale_Q30 ); - down_scale_Q30 = silk_LSHIFT( down_scale_Q30, LOG2_INV_LPC_GAIN_HIGH_THRES ); - - rand_Gain_Q15 = silk_RSHIFT( silk_SMULWB( down_scale_Q30, rand_Gain_Q15 ), 14 ); - } - } - - rand_seed = psPLC->rand_seed; - lag = silk_RSHIFT_ROUND( psPLC->pitchL_Q8, 8 ); - sLTP_buf_idx = psDec->ltp_mem_length; - - /* Rewhiten LTP state */ - idx = psDec->ltp_mem_length - lag - psDec->LPC_order - LTP_ORDER / 2; - celt_assert( idx > 0 ); - silk_LPC_analysis_filter( &sLTP[ idx ], &psDec->outBuf[ idx ], A_Q12, psDec->ltp_mem_length - idx, psDec->LPC_order, arch ); - /* Scale LTP state */ - inv_gain_Q30 = silk_INVERSE32_varQ( psPLC->prevGain_Q16[ 1 ], 46 ); - inv_gain_Q30 = silk_min( inv_gain_Q30, silk_int32_MAX >> 1 ); - for( i = idx + psDec->LPC_order; i < psDec->ltp_mem_length; i++ ) { - sLTP_Q14[ i ] = silk_SMULWB( inv_gain_Q30, sLTP[ i ] ); - } - - /***************************/ - /* LTP synthesis filtering */ - /***************************/ - for( k = 0; k < psDec->nb_subfr; k++ ) { - /* Set up pointer */ - pred_lag_ptr = &sLTP_Q14[ sLTP_buf_idx - lag + LTP_ORDER / 2 ]; - for( i = 0; i < psDec->subfr_length; i++ ) { - /* Unrolled loop */ - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LTP_pred_Q12 = 2; - LTP_pred_Q12 = silk_SMLAWB( LTP_pred_Q12, pred_lag_ptr[ 0 ], B_Q14[ 0 ] ); - LTP_pred_Q12 = silk_SMLAWB( LTP_pred_Q12, pred_lag_ptr[ -1 ], B_Q14[ 1 ] ); - LTP_pred_Q12 = silk_SMLAWB( LTP_pred_Q12, pred_lag_ptr[ -2 ], B_Q14[ 2 ] ); - LTP_pred_Q12 = silk_SMLAWB( LTP_pred_Q12, pred_lag_ptr[ -3 ], B_Q14[ 3 ] ); - LTP_pred_Q12 = silk_SMLAWB( LTP_pred_Q12, pred_lag_ptr[ -4 ], B_Q14[ 4 ] ); - pred_lag_ptr++; - - /* Generate LPC excitation */ - rand_seed = silk_RAND( rand_seed ); - idx = silk_RSHIFT( rand_seed, 25 ) & RAND_BUF_MASK; - sLTP_Q14[ sLTP_buf_idx ] = silk_LSHIFT32( silk_SMLAWB( LTP_pred_Q12, rand_ptr[ idx ], rand_scale_Q14 ), 2 ); - sLTP_buf_idx++; - } - - /* Gradually reduce LTP gain */ - for( j = 0; j < LTP_ORDER; j++ ) { - B_Q14[ j ] = silk_RSHIFT( silk_SMULBB( harm_Gain_Q15, B_Q14[ j ] ), 15 ); - } - /* Gradually reduce excitation gain */ - rand_scale_Q14 = silk_RSHIFT( silk_SMULBB( rand_scale_Q14, rand_Gain_Q15 ), 15 ); - - /* Slowly increase pitch lag */ - psPLC->pitchL_Q8 = silk_SMLAWB( psPLC->pitchL_Q8, psPLC->pitchL_Q8, PITCH_DRIFT_FAC_Q16 ); - psPLC->pitchL_Q8 = silk_min_32( psPLC->pitchL_Q8, silk_LSHIFT( silk_SMULBB( MAX_PITCH_LAG_MS, psDec->fs_kHz ), 8 ) ); - lag = silk_RSHIFT_ROUND( psPLC->pitchL_Q8, 8 ); - } - - /***************************/ - /* LPC synthesis filtering */ - /***************************/ - sLPC_Q14_ptr = &sLTP_Q14[ psDec->ltp_mem_length - MAX_LPC_ORDER ]; - - /* Copy LPC state */ - silk_memcpy( sLPC_Q14_ptr, psDec->sLPC_Q14_buf, MAX_LPC_ORDER * sizeof( opus_int32 ) ); - - celt_assert( psDec->LPC_order >= 10 ); /* check that unrolling works */ - for( i = 0; i < psDec->frame_length; i++ ) { - /* partly unrolled */ - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LPC_pred_Q10 = silk_RSHIFT( psDec->LPC_order, 1 ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 1 ], A_Q12[ 0 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 2 ], A_Q12[ 1 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 3 ], A_Q12[ 2 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 4 ], A_Q12[ 3 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 5 ], A_Q12[ 4 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 6 ], A_Q12[ 5 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 7 ], A_Q12[ 6 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 8 ], A_Q12[ 7 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 9 ], A_Q12[ 8 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - 10 ], A_Q12[ 9 ] ); - for( j = 10; j < psDec->LPC_order; j++ ) { - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14_ptr[ MAX_LPC_ORDER + i - j - 1 ], A_Q12[ j ] ); - } - - /* Add prediction to LPC excitation */ - sLPC_Q14_ptr[ MAX_LPC_ORDER + i ] = silk_ADD_SAT32( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], - silk_LSHIFT_SAT32( LPC_pred_Q10, 4 )); - - /* Scale with Gain */ - frame[ i ] = (opus_int16)silk_SAT16( silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( sLPC_Q14_ptr[ MAX_LPC_ORDER + i ], prevGain_Q10[ 1 ] ), 8 ) ) ); - } - - /* Save LPC state */ - silk_memcpy( psDec->sLPC_Q14_buf, &sLPC_Q14_ptr[ psDec->frame_length ], MAX_LPC_ORDER * sizeof( opus_int32 ) ); - - /**************************************/ - /* Update states */ - /**************************************/ - psPLC->rand_seed = rand_seed; - psPLC->randScale_Q14 = rand_scale_Q14; - for( i = 0; i < MAX_NB_SUBFR; i++ ) { - psDecCtrl->pitchL[ i ] = lag; - } - RESTORE_STACK; -} - -/* Glues concealed frames with new good received frames */ -void silk_PLC_glue_frames( - silk_decoder_state *psDec, /* I/O decoder state */ - opus_int16 frame[], /* I/O signal */ - opus_int length /* I length of signal */ -) -{ - opus_int i, energy_shift; - opus_int32 energy; - silk_PLC_struct *psPLC; - psPLC = &psDec->sPLC; - - if( psDec->lossCnt ) { - /* Calculate energy in concealed residual */ - silk_sum_sqr_shift( &psPLC->conc_energy, &psPLC->conc_energy_shift, frame, length ); - - psPLC->last_frame_lost = 1; - } else { - if( psDec->sPLC.last_frame_lost ) { - /* Calculate residual in decoded signal if last frame was lost */ - silk_sum_sqr_shift( &energy, &energy_shift, frame, length ); - - /* Normalize energies */ - if( energy_shift > psPLC->conc_energy_shift ) { - psPLC->conc_energy = silk_RSHIFT( psPLC->conc_energy, energy_shift - psPLC->conc_energy_shift ); - } else if( energy_shift < psPLC->conc_energy_shift ) { - energy = silk_RSHIFT( energy, psPLC->conc_energy_shift - energy_shift ); - } - - /* Fade in the energy difference */ - if( energy > psPLC->conc_energy ) { - opus_int32 frac_Q24, LZ; - opus_int32 gain_Q16, slope_Q16; - - LZ = silk_CLZ32( psPLC->conc_energy ); - LZ = LZ - 1; - psPLC->conc_energy = silk_LSHIFT( psPLC->conc_energy, LZ ); - energy = silk_RSHIFT( energy, silk_max_32( 24 - LZ, 0 ) ); - - frac_Q24 = silk_DIV32( psPLC->conc_energy, silk_max( energy, 1 ) ); - - gain_Q16 = silk_LSHIFT( silk_SQRT_APPROX( frac_Q24 ), 4 ); - slope_Q16 = silk_DIV32_16( ( (opus_int32)1 << 16 ) - gain_Q16, length ); - /* Make slope 4x steeper to avoid missing onsets after DTX */ - slope_Q16 = silk_LSHIFT( slope_Q16, 2 ); - - for( i = 0; i < length; i++ ) { - frame[ i ] = silk_SMULWB( gain_Q16, frame[ i ] ); - gain_Q16 += slope_Q16; - if( gain_Q16 > (opus_int32)1 << 16 ) { - break; - } - } - } - } - psPLC->last_frame_lost = 0; - } -} diff --git a/Engine/lib/opus/silk/PLC.h b/Engine/lib/opus/silk/PLC.h deleted file mode 100644 index 6438f5163..000000000 --- a/Engine/lib/opus/silk/PLC.h +++ /dev/null @@ -1,62 +0,0 @@ -/*********************************************************************** -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 SILK_PLC_H -#define SILK_PLC_H - -#include "main.h" - -#define BWE_COEF 0.99 -#define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */ -#define V_PITCH_GAIN_START_MAX_Q14 15565 /* 0.95 in Q14 */ -#define MAX_PITCH_LAG_MS 18 -#define RAND_BUF_SIZE 128 -#define RAND_BUF_MASK ( RAND_BUF_SIZE - 1 ) -#define LOG2_INV_LPC_GAIN_HIGH_THRES 3 /* 2^3 = 8 dB LPC gain */ -#define LOG2_INV_LPC_GAIN_LOW_THRES 8 /* 2^8 = 24 dB LPC gain */ -#define PITCH_DRIFT_FAC_Q16 655 /* 0.01 in Q16 */ - -void silk_PLC_Reset( - silk_decoder_state *psDec /* I/O Decoder state */ -); - -void silk_PLC( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[], /* I/O signal */ - opus_int lost, /* I Loss flag */ - int arch /* I Run-time architecture */ -); - -void silk_PLC_glue_frames( - silk_decoder_state *psDec, /* I/O decoder state */ - opus_int16 frame[], /* I/O signal */ - opus_int length /* I length of signal */ -); - -#endif - diff --git a/Engine/lib/opus/silk/SigProc_FIX.h b/Engine/lib/opus/silk/SigProc_FIX.h deleted file mode 100644 index fbdfa82e2..000000000 --- a/Engine/lib/opus/silk/SigProc_FIX.h +++ /dev/null @@ -1,643 +0,0 @@ -/*********************************************************************** -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 SILK_SIGPROC_FIX_H -#define SILK_SIGPROC_FIX_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*#define silk_MACRO_COUNT */ /* Used to enable WMOPS counting */ - -#define SILK_MAX_ORDER_LPC 24 /* max order of the LPC analysis in schur() and k2a() */ - -#include /* for memset(), memcpy(), memmove() */ -#include "typedef.h" -#include "resampler_structs.h" -#include "macros.h" -#include "cpu_support.h" - -#if defined(OPUS_X86_MAY_HAVE_SSE4_1) -#include "x86/SigProc_FIX_sse.h" -#endif - -#if (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) -#include "arm/biquad_alt_arm.h" -#include "arm/LPC_inv_pred_gain_arm.h" -#endif - -/********************************************************************/ -/* SIGNAL PROCESSING FUNCTIONS */ -/********************************************************************/ - -/*! - * Initialize/reset the resampler state for a given pair of input/output sampling rates -*/ -opus_int silk_resampler_init( - silk_resampler_state_struct *S, /* I/O Resampler state */ - opus_int32 Fs_Hz_in, /* I Input sampling rate (Hz) */ - opus_int32 Fs_Hz_out, /* I Output sampling rate (Hz) */ - opus_int forEnc /* I If 1: encoder; if 0: decoder */ -); - -/*! - * Resampler: convert from one sampling rate to another - */ -opus_int silk_resampler( - silk_resampler_state_struct *S, /* I/O Resampler state */ - opus_int16 out[], /* O Output signal */ - const opus_int16 in[], /* I Input signal */ - opus_int32 inLen /* I Number of input samples */ -); - -/*! -* Downsample 2x, mediocre quality -*/ -void silk_resampler_down2( - opus_int32 *S, /* I/O State vector [ 2 ] */ - opus_int16 *out, /* O Output signal [ len ] */ - const opus_int16 *in, /* I Input signal [ floor(len/2) ] */ - opus_int32 inLen /* I Number of input samples */ -); - -/*! - * Downsample by a factor 2/3, low quality -*/ -void silk_resampler_down2_3( - opus_int32 *S, /* I/O State vector [ 6 ] */ - opus_int16 *out, /* O Output signal [ floor(2*inLen/3) ] */ - const opus_int16 *in, /* I Input signal [ inLen ] */ - opus_int32 inLen /* I Number of input samples */ -); - -/*! - * second order ARMA filter; - * slower than biquad() but uses more precise coefficients - * can handle (slowly) varying coefficients - */ -void silk_biquad_alt_stride1( - const opus_int16 *in, /* I input signal */ - const opus_int32 *B_Q28, /* I MA coefficients [3] */ - const opus_int32 *A_Q28, /* I AR coefficients [2] */ - opus_int32 *S, /* I/O State vector [2] */ - opus_int16 *out, /* O output signal */ - const opus_int32 len /* I signal length (must be even) */ -); - -void silk_biquad_alt_stride2_c( - const opus_int16 *in, /* I input signal */ - const opus_int32 *B_Q28, /* I MA coefficients [3] */ - const opus_int32 *A_Q28, /* I AR coefficients [2] */ - opus_int32 *S, /* I/O State vector [4] */ - opus_int16 *out, /* O output signal */ - const opus_int32 len /* I signal length (must be even) */ -); - -/* Variable order MA prediction error filter. */ -void silk_LPC_analysis_filter( - opus_int16 *out, /* O Output signal */ - const opus_int16 *in, /* I Input signal */ - const opus_int16 *B, /* I MA prediction coefficients, Q12 [order] */ - const opus_int32 len, /* I Signal length */ - const opus_int32 d, /* I Filter order */ - int arch /* I Run-time architecture */ -); - -/* Chirp (bandwidth expand) LP AR filter */ -void silk_bwexpander( - opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I Length of ar */ - opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ -); - -/* Chirp (bandwidth expand) LP AR filter */ -void silk_bwexpander_32( - opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I Length of ar */ - opus_int32 chirp_Q16 /* I Chirp factor in Q16 */ -); - -/* Compute inverse of LPC prediction gain, and */ -/* test if LPC coefficients are stable (all poles within unit circle) */ -opus_int32 silk_LPC_inverse_pred_gain_c( /* O Returns inverse prediction gain in energy domain, Q30 */ - const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ - const opus_int order /* I Prediction order */ -); - -/* Split signal in two decimated bands using first-order allpass filters */ -void silk_ana_filt_bank_1( - const opus_int16 *in, /* I Input signal [N] */ - opus_int32 *S, /* I/O State vector [2] */ - opus_int16 *outL, /* O Low band [N/2] */ - opus_int16 *outH, /* O High band [N/2] */ - const opus_int32 N /* I Number of input samples */ -); - -#if !defined(OVERRIDE_silk_biquad_alt_stride2) -#define silk_biquad_alt_stride2(in, B_Q28, A_Q28, S, out, len, arch) ((void)(arch), silk_biquad_alt_stride2_c(in, B_Q28, A_Q28, S, out, len)) -#endif - -#if !defined(OVERRIDE_silk_LPC_inverse_pred_gain) -#define silk_LPC_inverse_pred_gain(A_Q12, order, arch) ((void)(arch), silk_LPC_inverse_pred_gain_c(A_Q12, order)) -#endif - -/********************************************************************/ -/* SCALAR FUNCTIONS */ -/********************************************************************/ - -/* Approximation of 128 * log2() (exact inverse of approx 2^() below) */ -/* Convert input to a log scale */ -opus_int32 silk_lin2log( - const opus_int32 inLin /* I input in linear scale */ -); - -/* Approximation of a sigmoid function */ -opus_int silk_sigm_Q15( - opus_int in_Q5 /* I */ -); - -/* Approximation of 2^() (exact inverse of approx log2() above) */ -/* Convert input to a linear scale */ -opus_int32 silk_log2lin( - const opus_int32 inLog_Q7 /* I input on log scale */ -); - -/* Compute number of bits to right shift the sum of squares of a vector */ -/* of int16s to make it fit in an int32 */ -void silk_sum_sqr_shift( - opus_int32 *energy, /* O Energy of x, after shifting to the right */ - opus_int *shift, /* O Number of bits right shift applied to energy */ - const opus_int16 *x, /* I Input vector */ - opus_int len /* I Length of input vector */ -); - -/* Calculates the reflection coefficients from the correlation sequence */ -/* Faster than schur64(), but much less accurate. */ -/* uses SMLAWB(), requiring armv5E and higher. */ -opus_int32 silk_schur( /* O Returns residual energy */ - opus_int16 *rc_Q15, /* O reflection coefficients [order] Q15 */ - const opus_int32 *c, /* I correlations [order+1] */ - const opus_int32 order /* I prediction order */ -); - -/* Calculates the reflection coefficients from the correlation sequence */ -/* Slower than schur(), but more accurate. */ -/* Uses SMULL(), available on armv4 */ -opus_int32 silk_schur64( /* O returns residual energy */ - opus_int32 rc_Q16[], /* O Reflection coefficients [order] Q16 */ - const opus_int32 c[], /* I Correlations [order+1] */ - opus_int32 order /* I Prediction order */ -); - -/* Step up function, converts reflection coefficients to prediction coefficients */ -void silk_k2a( - opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ - const opus_int16 *rc_Q15, /* I Reflection coefficients [order] Q15 */ - const opus_int32 order /* I Prediction order */ -); - -/* Step up function, converts reflection coefficients to prediction coefficients */ -void silk_k2a_Q16( - opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ - const opus_int32 *rc_Q16, /* I Reflection coefficients [order] Q16 */ - const opus_int32 order /* I Prediction order */ -); - -/* Apply sine window to signal vector. */ -/* Window types: */ -/* 1 -> sine window from 0 to pi/2 */ -/* 2 -> sine window from pi/2 to pi */ -/* every other sample of window is linearly interpolated, for speed */ -void silk_apply_sine_window( - opus_int16 px_win[], /* O Pointer to windowed signal */ - const opus_int16 px[], /* I Pointer to input signal */ - const opus_int win_type, /* I Selects a window type */ - const opus_int length /* I Window length, multiple of 4 */ -); - -/* Compute autocorrelation */ -void silk_autocorr( - opus_int32 *results, /* O Result (length correlationCount) */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *inputData, /* I Input data to correlate */ - const opus_int inputDataSize, /* I Length of input */ - const opus_int correlationCount, /* I Number of correlation taps to compute */ - int arch /* I Run-time architecture */ -); - -void silk_decode_pitch( - opus_int16 lagIndex, /* I */ - opus_int8 contourIndex, /* O */ - opus_int pitch_lags[], /* O 4 pitch values */ - const opus_int Fs_kHz, /* I sampling frequency (kHz) */ - const opus_int nb_subfr /* I number of sub frames */ -); - -opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ - const opus_int16 *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ - opus_int *pitch_out, /* O 4 pitch lag values */ - opus_int16 *lagIndex, /* O Lag Index */ - opus_int8 *contourIndex, /* O Pitch contour Index */ - opus_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */ - opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ - const opus_int32 search_thres1_Q16, /* I First stage threshold for lag candidates 0 - 1 */ - const opus_int search_thres2_Q13, /* I Final threshold for lag candidates 0 - 1 */ - const opus_int Fs_kHz, /* I Sample frequency (kHz) */ - const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */ - const opus_int nb_subfr, /* I number of 5 ms subframes */ - int arch /* I Run-time architecture */ -); - -/* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */ -/* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */ -void silk_A2NLSF( - opus_int16 *NLSF, /* O Normalized Line Spectral Frequencies in Q15 (0..2^15-1) [d] */ - opus_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */ - const opus_int d /* I Filter order (must be even) */ -); - -/* compute whitening filter coefficients from normalized line spectral frequencies */ -void silk_NLSF2A( - opus_int16 *a_Q12, /* O monic whitening filter coefficients in Q12, [ d ] */ - const opus_int16 *NLSF, /* I normalized line spectral frequencies in Q15, [ d ] */ - const opus_int d, /* I filter order (should be even) */ - int arch /* I Run-time architecture */ -); - -/* Convert int32 coefficients to int16 coefs and make sure there's no wrap-around */ -void silk_LPC_fit( - opus_int16 *a_QOUT, /* O Output signal */ - opus_int32 *a_QIN, /* I/O Input signal */ - const opus_int QOUT, /* I Input Q domain */ - const opus_int QIN, /* I Input Q domain */ - const opus_int d /* I Filter order */ -); - -void silk_insertion_sort_increasing( - opus_int32 *a, /* I/O Unsorted / Sorted vector */ - opus_int *idx, /* O Index vector for the sorted elements */ - const opus_int L, /* I Vector length */ - const opus_int K /* I Number of correctly sorted positions */ -); - -void silk_insertion_sort_decreasing_int16( - opus_int16 *a, /* I/O Unsorted / Sorted vector */ - opus_int *idx, /* O Index vector for the sorted elements */ - const opus_int L, /* I Vector length */ - const opus_int K /* I Number of correctly sorted positions */ -); - -void silk_insertion_sort_increasing_all_values_int16( - opus_int16 *a, /* I/O Unsorted / Sorted vector */ - const opus_int L /* I Vector length */ -); - -/* NLSF stabilizer, for a single input data vector */ -void silk_NLSF_stabilize( - opus_int16 *NLSF_Q15, /* I/O Unstable/stabilized normalized LSF vector in Q15 [L] */ - const opus_int16 *NDeltaMin_Q15, /* I Min distance vector, NDeltaMin_Q15[L] must be >= 1 [L+1] */ - const opus_int L /* I Number of NLSF parameters in the input vector */ -); - -/* Laroia low complexity NLSF weights */ -void silk_NLSF_VQ_weights_laroia( - opus_int16 *pNLSFW_Q_OUT, /* O Pointer to input vector weights [D] */ - const opus_int16 *pNLSF_Q15, /* I Pointer to input vector [D] */ - const opus_int D /* I Input vector dimension (even) */ -); - -/* Compute reflection coefficients from input signal */ -void silk_burg_modified_c( - opus_int32 *res_nrg, /* O Residual energy */ - opus_int *res_nrg_Q, /* O Residual energy Q value */ - opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ - const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ - const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ - const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ - const opus_int nb_subfr, /* I Number of subframes stacked in x */ - const opus_int D, /* I Order */ - int arch /* I Run-time architecture */ -); - -/* Copy and multiply a vector by a constant */ -void silk_scale_copy_vector16( - opus_int16 *data_out, - const opus_int16 *data_in, - opus_int32 gain_Q16, /* I Gain in Q16 */ - const opus_int dataSize /* I Length */ -); - -/* Some for the LTP related function requires Q26 to work.*/ -void silk_scale_vector32_Q26_lshift_18( - opus_int32 *data1, /* I/O Q0/Q18 */ - opus_int32 gain_Q26, /* I Q26 */ - opus_int dataSize /* I length */ -); - -/********************************************************************/ -/* INLINE ARM MATH */ -/********************************************************************/ - -/* return sum( inVec1[i] * inVec2[i] ) */ - -opus_int32 silk_inner_prod_aligned( - const opus_int16 *const inVec1, /* I input vector 1 */ - const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int len, /* I vector lengths */ - int arch /* I Run-time architecture */ -); - - -opus_int32 silk_inner_prod_aligned_scale( - const opus_int16 *const inVec1, /* I input vector 1 */ - const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int scale, /* I number of bits to shift */ - const opus_int len /* I vector lengths */ -); - -opus_int64 silk_inner_prod16_c( - const opus_int16 *inVec1, /* I input vector 1 */ - const opus_int16 *inVec2, /* I input vector 2 */ - const opus_int len /* I vector lengths */ -); - -/********************************************************************/ -/* MACROS */ -/********************************************************************/ - -/* Rotate a32 right by 'rot' bits. Negative rot values result in rotating - left. Output is 32bit int. - Note: contemporary compilers recognize the C expression below and - compile it into a 'ror' instruction if available. No need for OPUS_INLINE ASM! */ -static OPUS_INLINE opus_int32 silk_ROR32( opus_int32 a32, opus_int rot ) -{ - opus_uint32 x = (opus_uint32) a32; - opus_uint32 r = (opus_uint32) rot; - opus_uint32 m = (opus_uint32) -rot; - if( rot == 0 ) { - return a32; - } else if( rot < 0 ) { - return (opus_int32) ((x << m) | (x >> (32 - m))); - } else { - return (opus_int32) ((x << (32 - r)) | (x >> r)); - } -} - -/* Allocate opus_int16 aligned to 4-byte memory address */ -#if EMBEDDED_ARM -#define silk_DWORD_ALIGN __attribute__((aligned(4))) -#else -#define silk_DWORD_ALIGN -#endif - -/* Useful Macros that can be adjusted to other platforms */ -#define silk_memcpy(dest, src, size) memcpy((dest), (src), (size)) -#define silk_memset(dest, src, size) memset((dest), (src), (size)) -#define silk_memmove(dest, src, size) memmove((dest), (src), (size)) - -/* Fixed point macros */ - -/* (a32 * b32) output have to be 32bit int */ -#define silk_MUL(a32, b32) ((a32) * (b32)) - -/* (a32 * b32) output have to be 32bit uint */ -#define silk_MUL_uint(a32, b32) silk_MUL(a32, b32) - -/* a32 + (b32 * c32) output have to be 32bit int */ -#define silk_MLA(a32, b32, c32) silk_ADD32((a32),((b32) * (c32))) - -/* a32 + (b32 * c32) output have to be 32bit uint */ -#define silk_MLA_uint(a32, b32, c32) silk_MLA(a32, b32, c32) - -/* ((a32 >> 16) * (b32 >> 16)) output have to be 32bit int */ -#define silk_SMULTT(a32, b32) (((a32) >> 16) * ((b32) >> 16)) - -/* a32 + ((a32 >> 16) * (b32 >> 16)) output have to be 32bit int */ -#define silk_SMLATT(a32, b32, c32) silk_ADD32((a32),((b32) >> 16) * ((c32) >> 16)) - -#define silk_SMLALBB(a64, b16, c16) silk_ADD64((a64),(opus_int64)((opus_int32)(b16) * (opus_int32)(c16))) - -/* (a32 * b32) */ -#define silk_SMULL(a32, b32) ((opus_int64)(a32) * /*(opus_int64)*/(b32)) - -/* Adds two signed 32-bit values in a way that can overflow, while not relying on undefined behaviour - (just standard two's complement implementation-specific behaviour) */ -#define silk_ADD32_ovflw(a, b) ((opus_int32)((opus_uint32)(a) + (opus_uint32)(b))) -/* Subtractss two signed 32-bit values in a way that can overflow, while not relying on undefined behaviour - (just standard two's complement implementation-specific behaviour) */ -#define silk_SUB32_ovflw(a, b) ((opus_int32)((opus_uint32)(a) - (opus_uint32)(b))) - -/* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode) */ -#define silk_MLA_ovflw(a32, b32, c32) silk_ADD32_ovflw((a32), (opus_uint32)(b32) * (opus_uint32)(c32)) -#define silk_SMLABB_ovflw(a32, b32, c32) (silk_ADD32_ovflw((a32) , ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32)))) - -#define silk_DIV32_16(a32, b16) ((opus_int32)((a32) / (b16))) -#define silk_DIV32(a32, b32) ((opus_int32)((a32) / (b32))) - -/* These macros enables checking for overflow in silk_API_Debug.h*/ -#define silk_ADD16(a, b) ((a) + (b)) -#define silk_ADD32(a, b) ((a) + (b)) -#define silk_ADD64(a, b) ((a) + (b)) - -#define silk_SUB16(a, b) ((a) - (b)) -#define silk_SUB32(a, b) ((a) - (b)) -#define silk_SUB64(a, b) ((a) - (b)) - -#define silk_SAT8(a) ((a) > silk_int8_MAX ? silk_int8_MAX : \ - ((a) < silk_int8_MIN ? silk_int8_MIN : (a))) -#define silk_SAT16(a) ((a) > silk_int16_MAX ? silk_int16_MAX : \ - ((a) < silk_int16_MIN ? silk_int16_MIN : (a))) -#define silk_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : \ - ((a) < silk_int32_MIN ? silk_int32_MIN : (a))) - -#define silk_CHECK_FIT8(a) (a) -#define silk_CHECK_FIT16(a) (a) -#define silk_CHECK_FIT32(a) (a) - -#define silk_ADD_SAT16(a, b) (opus_int16)silk_SAT16( silk_ADD32( (opus_int32)(a), (b) ) ) -#define silk_ADD_SAT64(a, b) ((((a) + (b)) & 0x8000000000000000LL) == 0 ? \ - ((((a) & (b)) & 0x8000000000000000LL) != 0 ? silk_int64_MIN : (a)+(b)) : \ - ((((a) | (b)) & 0x8000000000000000LL) == 0 ? silk_int64_MAX : (a)+(b)) ) - -#define silk_SUB_SAT16(a, b) (opus_int16)silk_SAT16( silk_SUB32( (opus_int32)(a), (b) ) ) -#define silk_SUB_SAT64(a, b) ((((a)-(b)) & 0x8000000000000000LL) == 0 ? \ - (( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? silk_int64_MIN : (a)-(b)) : \ - ((((a)^0x8000000000000000LL) & (b) & 0x8000000000000000LL) ? silk_int64_MAX : (a)-(b)) ) - -/* Saturation for positive input values */ -#define silk_POS_SAT32(a) ((a) > silk_int32_MAX ? silk_int32_MAX : (a)) - -/* Add with saturation for positive input values */ -#define silk_ADD_POS_SAT8(a, b) ((((a)+(b)) & 0x80) ? silk_int8_MAX : ((a)+(b))) -#define silk_ADD_POS_SAT16(a, b) ((((a)+(b)) & 0x8000) ? silk_int16_MAX : ((a)+(b))) -#define silk_ADD_POS_SAT32(a, b) ((((opus_uint32)(a)+(opus_uint32)(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b))) - -#define silk_LSHIFT8(a, shift) ((opus_int8)((opus_uint8)(a)<<(shift))) /* shift >= 0, shift < 8 */ -#define silk_LSHIFT16(a, shift) ((opus_int16)((opus_uint16)(a)<<(shift))) /* shift >= 0, shift < 16 */ -#define silk_LSHIFT32(a, shift) ((opus_int32)((opus_uint32)(a)<<(shift))) /* shift >= 0, shift < 32 */ -#define silk_LSHIFT64(a, shift) ((opus_int64)((opus_uint64)(a)<<(shift))) /* shift >= 0, shift < 64 */ -#define silk_LSHIFT(a, shift) silk_LSHIFT32(a, shift) /* shift >= 0, shift < 32 */ - -#define silk_RSHIFT8(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 8 */ -#define silk_RSHIFT16(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 16 */ -#define silk_RSHIFT32(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 32 */ -#define silk_RSHIFT64(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 64 */ -#define silk_RSHIFT(a, shift) silk_RSHIFT32(a, shift) /* shift >= 0, shift < 32 */ - -/* saturates before shifting */ -#define silk_LSHIFT_SAT32(a, shift) (silk_LSHIFT32( silk_LIMIT( (a), silk_RSHIFT32( silk_int32_MIN, (shift) ), \ - silk_RSHIFT32( silk_int32_MAX, (shift) ) ), (shift) )) - -#define silk_LSHIFT_ovflw(a, shift) ((opus_int32)((opus_uint32)(a) << (shift))) /* shift >= 0, allowed to overflow */ -#define silk_LSHIFT_uint(a, shift) ((a) << (shift)) /* shift >= 0 */ -#define silk_RSHIFT_uint(a, shift) ((a) >> (shift)) /* shift >= 0 */ - -#define silk_ADD_LSHIFT(a, b, shift) ((a) + silk_LSHIFT((b), (shift))) /* shift >= 0 */ -#define silk_ADD_LSHIFT32(a, b, shift) silk_ADD32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */ -#define silk_ADD_LSHIFT_uint(a, b, shift) ((a) + silk_LSHIFT_uint((b), (shift))) /* shift >= 0 */ -#define silk_ADD_RSHIFT(a, b, shift) ((a) + silk_RSHIFT((b), (shift))) /* shift >= 0 */ -#define silk_ADD_RSHIFT32(a, b, shift) silk_ADD32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */ -#define silk_ADD_RSHIFT_uint(a, b, shift) ((a) + silk_RSHIFT_uint((b), (shift))) /* shift >= 0 */ -#define silk_SUB_LSHIFT32(a, b, shift) silk_SUB32((a), silk_LSHIFT32((b), (shift))) /* shift >= 0 */ -#define silk_SUB_RSHIFT32(a, b, shift) silk_SUB32((a), silk_RSHIFT32((b), (shift))) /* shift >= 0 */ - -/* Requires that shift > 0 */ -#define silk_RSHIFT_ROUND(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) -#define silk_RSHIFT_ROUND64(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) - -/* Number of rightshift required to fit the multiplication */ -#define silk_NSHIFT_MUL_32_32(a, b) ( -(31- (32-silk_CLZ32(silk_abs(a)) + (32-silk_CLZ32(silk_abs(b))))) ) -#define silk_NSHIFT_MUL_16_16(a, b) ( -(15- (16-silk_CLZ16(silk_abs(a)) + (16-silk_CLZ16(silk_abs(b))))) ) - - -#define silk_min(a, b) (((a) < (b)) ? (a) : (b)) -#define silk_max(a, b) (((a) > (b)) ? (a) : (b)) - -/* Macro to convert floating-point constants to fixed-point */ -#define SILK_FIX_CONST( C, Q ) ((opus_int32)((C) * ((opus_int64)1 << (Q)) + 0.5)) - -/* silk_min() versions with typecast in the function call */ -static OPUS_INLINE opus_int silk_min_int(opus_int a, opus_int b) -{ - return (((a) < (b)) ? (a) : (b)); -} -static OPUS_INLINE opus_int16 silk_min_16(opus_int16 a, opus_int16 b) -{ - return (((a) < (b)) ? (a) : (b)); -} -static OPUS_INLINE opus_int32 silk_min_32(opus_int32 a, opus_int32 b) -{ - return (((a) < (b)) ? (a) : (b)); -} -static OPUS_INLINE opus_int64 silk_min_64(opus_int64 a, opus_int64 b) -{ - return (((a) < (b)) ? (a) : (b)); -} - -/* silk_min() versions with typecast in the function call */ -static OPUS_INLINE opus_int silk_max_int(opus_int a, opus_int b) -{ - return (((a) > (b)) ? (a) : (b)); -} -static OPUS_INLINE opus_int16 silk_max_16(opus_int16 a, opus_int16 b) -{ - return (((a) > (b)) ? (a) : (b)); -} -static OPUS_INLINE opus_int32 silk_max_32(opus_int32 a, opus_int32 b) -{ - return (((a) > (b)) ? (a) : (b)); -} -static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b) -{ - return (((a) > (b)) ? (a) : (b)); -} - -#define silk_LIMIT( a, limit1, limit2) ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \ - : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a)))) - -#define silk_LIMIT_int silk_LIMIT -#define silk_LIMIT_16 silk_LIMIT -#define silk_LIMIT_32 silk_LIMIT - -#define silk_abs(a) (((a) > 0) ? (a) : -(a)) /* Be careful, silk_abs returns wrong when input equals to silk_intXX_MIN */ -#define silk_abs_int(a) (((a) ^ ((a) >> (8 * sizeof(a) - 1))) - ((a) >> (8 * sizeof(a) - 1))) -#define silk_abs_int32(a) (((a) ^ ((a) >> 31)) - ((a) >> 31)) -#define silk_abs_int64(a) (((a) > 0) ? (a) : -(a)) - -#define silk_sign(a) ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 )) - -/* PSEUDO-RANDOM GENERATOR */ -/* Make sure to store the result as the seed for the next call (also in between */ -/* frames), otherwise result won't be random at all. When only using some of the */ -/* bits, take the most significant bits by right-shifting. */ -#define RAND_MULTIPLIER 196314165 -#define RAND_INCREMENT 907633515 -#define silk_RAND(seed) (silk_MLA_ovflw((RAND_INCREMENT), (seed), (RAND_MULTIPLIER))) - -/* Add some multiplication functions that can be easily mapped to ARM. */ - -/* silk_SMMUL: Signed top word multiply. - ARMv6 2 instruction cycles. - ARMv3M+ 3 instruction cycles. use SMULL and ignore LSB registers.(except xM)*/ -/*#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT(silk_SMLAL(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16)), 16)*/ -/* the following seems faster on x86 */ -#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32) - -#if !defined(OVERRIDE_silk_burg_modified) -#define silk_burg_modified(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch) \ - ((void)(arch), silk_burg_modified_c(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch)) -#endif - -#if !defined(OVERRIDE_silk_inner_prod16) -#define silk_inner_prod16(inVec1, inVec2, len, arch) \ - ((void)(arch),silk_inner_prod16_c(inVec1, inVec2, len)) -#endif - -#include "Inlines.h" -#include "MacroCount.h" -#include "MacroDebug.h" - -#ifdef OPUS_ARM_INLINE_ASM -#include "arm/SigProc_FIX_armv4.h" -#endif - -#ifdef OPUS_ARM_INLINE_EDSP -#include "arm/SigProc_FIX_armv5e.h" -#endif - -#if defined(MIPSr1_ASM) -#include "mips/sigproc_fix_mipsr1.h" -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* SILK_SIGPROC_FIX_H */ diff --git a/Engine/lib/opus/silk/VAD.c b/Engine/lib/opus/silk/VAD.c deleted file mode 100644 index d0cda5216..000000000 --- a/Engine/lib/opus/silk/VAD.c +++ /dev/null @@ -1,360 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" - -/* Silk VAD noise level estimation */ -# if !defined(OPUS_X86_MAY_HAVE_SSE4_1) -static OPUS_INLINE void silk_VAD_GetNoiseLevels( - const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies */ - silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ -); -#endif - -/**********************************/ -/* Initialization of the Silk VAD */ -/**********************************/ -opus_int silk_VAD_Init( /* O Return value, 0 if success */ - silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ -) -{ - opus_int b, ret = 0; - - /* reset state memory */ - silk_memset( psSilk_VAD, 0, sizeof( silk_VAD_state ) ); - - /* init noise levels */ - /* Initialize array with approx pink noise levels (psd proportional to inverse of frequency) */ - for( b = 0; b < VAD_N_BANDS; b++ ) { - psSilk_VAD->NoiseLevelBias[ b ] = silk_max_32( silk_DIV32_16( VAD_NOISE_LEVELS_BIAS, b + 1 ), 1 ); - } - - /* Initialize state */ - for( b = 0; b < VAD_N_BANDS; b++ ) { - psSilk_VAD->NL[ b ] = silk_MUL( 100, psSilk_VAD->NoiseLevelBias[ b ] ); - psSilk_VAD->inv_NL[ b ] = silk_DIV32( silk_int32_MAX, psSilk_VAD->NL[ b ] ); - } - psSilk_VAD->counter = 15; - - /* init smoothed energy-to-noise ratio*/ - for( b = 0; b < VAD_N_BANDS; b++ ) { - psSilk_VAD->NrgRatioSmth_Q8[ b ] = 100 * 256; /* 100 * 256 --> 20 dB SNR */ - } - - return( ret ); -} - -/* Weighting factors for tilt measure */ -static const opus_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -12000 }; - -/***************************************/ -/* Get the speech activity level in Q8 */ -/***************************************/ -opus_int silk_VAD_GetSA_Q8_c( /* O Return value, 0 if success */ - silk_encoder_state *psEncC, /* I/O Encoder state */ - const opus_int16 pIn[] /* I PCM input */ -) -{ - opus_int SA_Q15, pSNR_dB_Q7, input_tilt; - opus_int decimated_framelength1, decimated_framelength2; - opus_int decimated_framelength; - opus_int dec_subframe_length, dec_subframe_offset, SNR_Q7, i, b, s; - opus_int32 sumSquared, smooth_coef_Q16; - opus_int16 HPstateTmp; - VARDECL( opus_int16, X ); - opus_int32 Xnrg[ VAD_N_BANDS ]; - opus_int32 NrgToNoiseRatio_Q8[ VAD_N_BANDS ]; - opus_int32 speech_nrg, x_tmp; - opus_int X_offset[ VAD_N_BANDS ]; - opus_int ret = 0; - silk_VAD_state *psSilk_VAD = &psEncC->sVAD; - SAVE_STACK; - - /* Safety checks */ - silk_assert( VAD_N_BANDS == 4 ); - celt_assert( MAX_FRAME_LENGTH >= psEncC->frame_length ); - celt_assert( psEncC->frame_length <= 512 ); - celt_assert( psEncC->frame_length == 8 * silk_RSHIFT( psEncC->frame_length, 3 ) ); - - /***********************/ - /* Filter and Decimate */ - /***********************/ - decimated_framelength1 = silk_RSHIFT( psEncC->frame_length, 1 ); - decimated_framelength2 = silk_RSHIFT( psEncC->frame_length, 2 ); - decimated_framelength = silk_RSHIFT( psEncC->frame_length, 3 ); - /* Decimate into 4 bands: - 0 L 3L L 3L 5L - - -- - -- -- - 8 8 2 4 4 - - [0-1 kHz| temp. |1-2 kHz| 2-4 kHz | 4-8 kHz | - - They're arranged to allow the minimal ( frame_length / 4 ) extra - scratch space during the downsampling process */ - X_offset[ 0 ] = 0; - X_offset[ 1 ] = decimated_framelength + decimated_framelength2; - X_offset[ 2 ] = X_offset[ 1 ] + decimated_framelength; - X_offset[ 3 ] = X_offset[ 2 ] + decimated_framelength2; - ALLOC( X, X_offset[ 3 ] + decimated_framelength1, opus_int16 ); - - /* 0-8 kHz to 0-4 kHz and 4-8 kHz */ - silk_ana_filt_bank_1( pIn, &psSilk_VAD->AnaState[ 0 ], - X, &X[ X_offset[ 3 ] ], psEncC->frame_length ); - - /* 0-4 kHz to 0-2 kHz and 2-4 kHz */ - silk_ana_filt_bank_1( X, &psSilk_VAD->AnaState1[ 0 ], - X, &X[ X_offset[ 2 ] ], decimated_framelength1 ); - - /* 0-2 kHz to 0-1 kHz and 1-2 kHz */ - silk_ana_filt_bank_1( X, &psSilk_VAD->AnaState2[ 0 ], - X, &X[ X_offset[ 1 ] ], decimated_framelength2 ); - - /*********************************************/ - /* HP filter on lowest band (differentiator) */ - /*********************************************/ - X[ decimated_framelength - 1 ] = silk_RSHIFT( X[ decimated_framelength - 1 ], 1 ); - HPstateTmp = X[ decimated_framelength - 1 ]; - for( i = decimated_framelength - 1; i > 0; i-- ) { - X[ i - 1 ] = silk_RSHIFT( X[ i - 1 ], 1 ); - X[ i ] -= X[ i - 1 ]; - } - X[ 0 ] -= psSilk_VAD->HPstate; - psSilk_VAD->HPstate = HPstateTmp; - - /*************************************/ - /* Calculate the energy in each band */ - /*************************************/ - for( b = 0; b < VAD_N_BANDS; b++ ) { - /* Find the decimated framelength in the non-uniformly divided bands */ - decimated_framelength = silk_RSHIFT( psEncC->frame_length, silk_min_int( VAD_N_BANDS - b, VAD_N_BANDS - 1 ) ); - - /* Split length into subframe lengths */ - dec_subframe_length = silk_RSHIFT( decimated_framelength, VAD_INTERNAL_SUBFRAMES_LOG2 ); - dec_subframe_offset = 0; - - /* Compute energy per sub-frame */ - /* initialize with summed energy of last subframe */ - Xnrg[ b ] = psSilk_VAD->XnrgSubfr[ b ]; - for( s = 0; s < VAD_INTERNAL_SUBFRAMES; s++ ) { - sumSquared = 0; - for( i = 0; i < dec_subframe_length; i++ ) { - /* The energy will be less than dec_subframe_length * ( silk_int16_MIN / 8 ) ^ 2. */ - /* Therefore we can accumulate with no risk of overflow (unless dec_subframe_length > 128) */ - x_tmp = silk_RSHIFT( - X[ X_offset[ b ] + i + dec_subframe_offset ], 3 ); - sumSquared = silk_SMLABB( sumSquared, x_tmp, x_tmp ); - - /* Safety check */ - silk_assert( sumSquared >= 0 ); - } - - /* Add/saturate summed energy of current subframe */ - if( s < VAD_INTERNAL_SUBFRAMES - 1 ) { - Xnrg[ b ] = silk_ADD_POS_SAT32( Xnrg[ b ], sumSquared ); - } else { - /* Look-ahead subframe */ - Xnrg[ b ] = silk_ADD_POS_SAT32( Xnrg[ b ], silk_RSHIFT( sumSquared, 1 ) ); - } - - dec_subframe_offset += dec_subframe_length; - } - psSilk_VAD->XnrgSubfr[ b ] = sumSquared; - } - - /********************/ - /* Noise estimation */ - /********************/ - silk_VAD_GetNoiseLevels( &Xnrg[ 0 ], psSilk_VAD ); - - /***********************************************/ - /* Signal-plus-noise to noise ratio estimation */ - /***********************************************/ - sumSquared = 0; - input_tilt = 0; - for( b = 0; b < VAD_N_BANDS; b++ ) { - speech_nrg = Xnrg[ b ] - psSilk_VAD->NL[ b ]; - if( speech_nrg > 0 ) { - /* Divide, with sufficient resolution */ - if( ( Xnrg[ b ] & 0xFF800000 ) == 0 ) { - NrgToNoiseRatio_Q8[ b ] = silk_DIV32( silk_LSHIFT( Xnrg[ b ], 8 ), psSilk_VAD->NL[ b ] + 1 ); - } else { - NrgToNoiseRatio_Q8[ b ] = silk_DIV32( Xnrg[ b ], silk_RSHIFT( psSilk_VAD->NL[ b ], 8 ) + 1 ); - } - - /* Convert to log domain */ - SNR_Q7 = silk_lin2log( NrgToNoiseRatio_Q8[ b ] ) - 8 * 128; - - /* Sum-of-squares */ - sumSquared = silk_SMLABB( sumSquared, SNR_Q7, SNR_Q7 ); /* Q14 */ - - /* Tilt measure */ - if( speech_nrg < ( (opus_int32)1 << 20 ) ) { - /* Scale down SNR value for small subband speech energies */ - SNR_Q7 = silk_SMULWB( silk_LSHIFT( silk_SQRT_APPROX( speech_nrg ), 6 ), SNR_Q7 ); - } - input_tilt = silk_SMLAWB( input_tilt, tiltWeights[ b ], SNR_Q7 ); - } else { - NrgToNoiseRatio_Q8[ b ] = 256; - } - } - - /* Mean-of-squares */ - sumSquared = silk_DIV32_16( sumSquared, VAD_N_BANDS ); /* Q14 */ - - /* Root-mean-square approximation, scale to dBs, and write to output pointer */ - pSNR_dB_Q7 = (opus_int16)( 3 * silk_SQRT_APPROX( sumSquared ) ); /* Q7 */ - - /*********************************/ - /* Speech Probability Estimation */ - /*********************************/ - SA_Q15 = silk_sigm_Q15( silk_SMULWB( VAD_SNR_FACTOR_Q16, pSNR_dB_Q7 ) - VAD_NEGATIVE_OFFSET_Q5 ); - - /**************************/ - /* Frequency Tilt Measure */ - /**************************/ - psEncC->input_tilt_Q15 = silk_LSHIFT( silk_sigm_Q15( input_tilt ) - 16384, 1 ); - - /**************************************************/ - /* Scale the sigmoid output based on power levels */ - /**************************************************/ - speech_nrg = 0; - for( b = 0; b < VAD_N_BANDS; b++ ) { - /* Accumulate signal-without-noise energies, higher frequency bands have more weight */ - speech_nrg += ( b + 1 ) * silk_RSHIFT( Xnrg[ b ] - psSilk_VAD->NL[ b ], 4 ); - } - - if( psEncC->frame_length == 20 * psEncC->fs_kHz ) { - speech_nrg = silk_RSHIFT32( speech_nrg, 1 ); - } - /* Power scaling */ - if( speech_nrg <= 0 ) { - SA_Q15 = silk_RSHIFT( SA_Q15, 1 ); - } else if( speech_nrg < 16384 ) { - speech_nrg = silk_LSHIFT32( speech_nrg, 16 ); - - /* square-root */ - speech_nrg = silk_SQRT_APPROX( speech_nrg ); - SA_Q15 = silk_SMULWB( 32768 + speech_nrg, SA_Q15 ); - } - - /* Copy the resulting speech activity in Q8 */ - psEncC->speech_activity_Q8 = silk_min_int( silk_RSHIFT( SA_Q15, 7 ), silk_uint8_MAX ); - - /***********************************/ - /* Energy Level and SNR estimation */ - /***********************************/ - /* Smoothing coefficient */ - smooth_coef_Q16 = silk_SMULWB( VAD_SNR_SMOOTH_COEF_Q18, silk_SMULWB( (opus_int32)SA_Q15, SA_Q15 ) ); - - if( psEncC->frame_length == 10 * psEncC->fs_kHz ) { - smooth_coef_Q16 >>= 1; - } - - for( b = 0; b < VAD_N_BANDS; b++ ) { - /* compute smoothed energy-to-noise ratio per band */ - psSilk_VAD->NrgRatioSmth_Q8[ b ] = silk_SMLAWB( psSilk_VAD->NrgRatioSmth_Q8[ b ], - NrgToNoiseRatio_Q8[ b ] - psSilk_VAD->NrgRatioSmth_Q8[ b ], smooth_coef_Q16 ); - - /* signal to noise ratio in dB per band */ - SNR_Q7 = 3 * ( silk_lin2log( psSilk_VAD->NrgRatioSmth_Q8[b] ) - 8 * 128 ); - /* quality = sigmoid( 0.25 * ( SNR_dB - 16 ) ); */ - psEncC->input_quality_bands_Q15[ b ] = silk_sigm_Q15( silk_RSHIFT( SNR_Q7 - 16 * 128, 4 ) ); - } - - RESTORE_STACK; - return( ret ); -} - -/**************************/ -/* Noise level estimation */ -/**************************/ -# if !defined(OPUS_X86_MAY_HAVE_SSE4_1) -static OPUS_INLINE -#endif -void silk_VAD_GetNoiseLevels( - const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies */ - silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ -) -{ - opus_int k; - opus_int32 nl, nrg, inv_nrg; - opus_int coef, min_coef; - - /* Initially faster smoothing */ - if( psSilk_VAD->counter < 1000 ) { /* 1000 = 20 sec */ - min_coef = silk_DIV32_16( silk_int16_MAX, silk_RSHIFT( psSilk_VAD->counter, 4 ) + 1 ); - /* Increment frame counter */ - psSilk_VAD->counter++; - } else { - min_coef = 0; - } - - for( k = 0; k < VAD_N_BANDS; k++ ) { - /* Get old noise level estimate for current band */ - nl = psSilk_VAD->NL[ k ]; - silk_assert( nl >= 0 ); - - /* Add bias */ - nrg = silk_ADD_POS_SAT32( pX[ k ], psSilk_VAD->NoiseLevelBias[ k ] ); - silk_assert( nrg > 0 ); - - /* Invert energies */ - inv_nrg = silk_DIV32( silk_int32_MAX, nrg ); - silk_assert( inv_nrg >= 0 ); - - /* Less update when subband energy is high */ - if( nrg > silk_LSHIFT( nl, 3 ) ) { - coef = VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 >> 3; - } else if( nrg < nl ) { - coef = VAD_NOISE_LEVEL_SMOOTH_COEF_Q16; - } else { - coef = silk_SMULWB( silk_SMULWW( inv_nrg, nl ), VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 << 1 ); - } - - /* Initially faster smoothing */ - coef = silk_max_int( coef, min_coef ); - - /* Smooth inverse energies */ - psSilk_VAD->inv_NL[ k ] = silk_SMLAWB( psSilk_VAD->inv_NL[ k ], inv_nrg - psSilk_VAD->inv_NL[ k ], coef ); - silk_assert( psSilk_VAD->inv_NL[ k ] >= 0 ); - - /* Compute noise level by inverting again */ - nl = silk_DIV32( silk_int32_MAX, psSilk_VAD->inv_NL[ k ] ); - silk_assert( nl >= 0 ); - - /* Limit noise levels (guarantee 7 bits of head room) */ - nl = silk_min( nl, 0x00FFFFFF ); - - /* Store as part of state */ - psSilk_VAD->NL[ k ] = nl; - } -} diff --git a/Engine/lib/opus/silk/VQ_WMat_EC.c b/Engine/lib/opus/silk/VQ_WMat_EC.c deleted file mode 100644 index 245a7e4b0..000000000 --- a/Engine/lib/opus/silk/VQ_WMat_EC.c +++ /dev/null @@ -1,131 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */ -void silk_VQ_WMat_EC_c( - opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *res_nrg_Q15, /* O best residual energy */ - opus_int32 *rate_dist_Q8, /* O best total bitrate */ - opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ - const opus_int32 *XX_Q17, /* I correlation matrix */ - const opus_int32 *xX_Q17, /* I correlation vector */ - const opus_int8 *cb_Q7, /* I codebook */ - const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ - const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int subfr_len, /* I number of samples per subframe */ - const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ - const opus_int L /* I number of vectors in codebook */ -) -{ - opus_int k, gain_tmp_Q7; - const opus_int8 *cb_row_Q7; - opus_int32 neg_xX_Q24[ 5 ]; - opus_int32 sum1_Q15, sum2_Q24; - opus_int32 bits_res_Q8, bits_tot_Q8; - - /* Negate and convert to new Q domain */ - neg_xX_Q24[ 0 ] = -silk_LSHIFT32( xX_Q17[ 0 ], 7 ); - neg_xX_Q24[ 1 ] = -silk_LSHIFT32( xX_Q17[ 1 ], 7 ); - neg_xX_Q24[ 2 ] = -silk_LSHIFT32( xX_Q17[ 2 ], 7 ); - neg_xX_Q24[ 3 ] = -silk_LSHIFT32( xX_Q17[ 3 ], 7 ); - neg_xX_Q24[ 4 ] = -silk_LSHIFT32( xX_Q17[ 4 ], 7 ); - - /* Loop over codebook */ - *rate_dist_Q8 = silk_int32_MAX; - *res_nrg_Q15 = silk_int32_MAX; - cb_row_Q7 = cb_Q7; - /* If things go really bad, at least *ind is set to something safe. */ - *ind = 0; - for( k = 0; k < L; k++ ) { - opus_int32 penalty; - gain_tmp_Q7 = cb_gain_Q7[k]; - /* Weighted rate */ - /* Quantization error: 1 - 2 * xX * cb + cb' * XX * cb */ - sum1_Q15 = SILK_FIX_CONST( 1.001, 15 ); - - /* Penalty for too large gain */ - penalty = silk_LSHIFT32( silk_max( silk_SUB32( gain_tmp_Q7, max_gain_Q7 ), 0 ), 11 ); - - /* first row of XX_Q17 */ - sum2_Q24 = silk_MLA( neg_xX_Q24[ 0 ], XX_Q17[ 1 ], cb_row_Q7[ 1 ] ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 2 ], cb_row_Q7[ 2 ] ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 3 ], cb_row_Q7[ 3 ] ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 4 ], cb_row_Q7[ 4 ] ); - sum2_Q24 = silk_LSHIFT32( sum2_Q24, 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 0 ], cb_row_Q7[ 0 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 0 ] ); - - /* second row of XX_Q17 */ - sum2_Q24 = silk_MLA( neg_xX_Q24[ 1 ], XX_Q17[ 7 ], cb_row_Q7[ 2 ] ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 8 ], cb_row_Q7[ 3 ] ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 9 ], cb_row_Q7[ 4 ] ); - sum2_Q24 = silk_LSHIFT32( sum2_Q24, 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 6 ], cb_row_Q7[ 1 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 1 ] ); - - /* third row of XX_Q17 */ - sum2_Q24 = silk_MLA( neg_xX_Q24[ 2 ], XX_Q17[ 13 ], cb_row_Q7[ 3 ] ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 14 ], cb_row_Q7[ 4 ] ); - sum2_Q24 = silk_LSHIFT32( sum2_Q24, 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 12 ], cb_row_Q7[ 2 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 2 ] ); - - /* fourth row of XX_Q17 */ - sum2_Q24 = silk_MLA( neg_xX_Q24[ 3 ], XX_Q17[ 19 ], cb_row_Q7[ 4 ] ); - sum2_Q24 = silk_LSHIFT32( sum2_Q24, 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 18 ], cb_row_Q7[ 3 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 3 ] ); - - /* last row of XX_Q17 */ - sum2_Q24 = silk_LSHIFT32( neg_xX_Q24[ 4 ], 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 24 ], cb_row_Q7[ 4 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 4 ] ); - - /* find best */ - if( sum1_Q15 >= 0 ) { - /* Translate residual energy to bits using high-rate assumption (6 dB ==> 1 bit/sample) */ - bits_res_Q8 = silk_SMULBB( subfr_len, silk_lin2log( sum1_Q15 + penalty) - (15 << 7) ); - /* In the following line we reduce the codelength component by half ("-1"); seems to slightly improve quality */ - bits_tot_Q8 = silk_ADD_LSHIFT32( bits_res_Q8, cl_Q5[ k ], 3-1 ); - if( bits_tot_Q8 <= *rate_dist_Q8 ) { - *rate_dist_Q8 = bits_tot_Q8; - *res_nrg_Q15 = sum1_Q15 + penalty; - *ind = (opus_int8)k; - *gain_Q7 = gain_tmp_Q7; - } - } - - /* Go to next cbk vector */ - cb_row_Q7 += LTP_ORDER; - } -} diff --git a/Engine/lib/opus/silk/ana_filt_bank_1.c b/Engine/lib/opus/silk/ana_filt_bank_1.c deleted file mode 100644 index 24cfb03fd..000000000 --- a/Engine/lib/opus/silk/ana_filt_bank_1.c +++ /dev/null @@ -1,74 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Coefficients for 2-band filter bank based on first-order allpass filters */ -static opus_int16 A_fb1_20 = 5394 << 1; -static opus_int16 A_fb1_21 = -24290; /* (opus_int16)(20623 << 1) */ - -/* Split signal into two decimated bands using first-order allpass filters */ -void silk_ana_filt_bank_1( - const opus_int16 *in, /* I Input signal [N] */ - opus_int32 *S, /* I/O State vector [2] */ - opus_int16 *outL, /* O Low band [N/2] */ - opus_int16 *outH, /* O High band [N/2] */ - const opus_int32 N /* I Number of input samples */ -) -{ - opus_int k, N2 = silk_RSHIFT( N, 1 ); - opus_int32 in32, X, Y, out_1, out_2; - - /* Internal variables and state are in Q10 format */ - for( k = 0; k < N2; k++ ) { - /* Convert to Q10 */ - in32 = silk_LSHIFT( (opus_int32)in[ 2 * k ], 10 ); - - /* All-pass section for even input sample */ - Y = silk_SUB32( in32, S[ 0 ] ); - X = silk_SMLAWB( Y, Y, A_fb1_21 ); - out_1 = silk_ADD32( S[ 0 ], X ); - S[ 0 ] = silk_ADD32( in32, X ); - - /* Convert to Q10 */ - in32 = silk_LSHIFT( (opus_int32)in[ 2 * k + 1 ], 10 ); - - /* All-pass section for odd input sample, and add to output of previous section */ - Y = silk_SUB32( in32, S[ 1 ] ); - X = silk_SMULWB( Y, A_fb1_20 ); - out_2 = silk_ADD32( S[ 1 ], X ); - S[ 1 ] = silk_ADD32( in32, X ); - - /* Add/subtract, convert back to int16 and store to output */ - outL[ k ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_ADD32( out_2, out_1 ), 11 ) ); - outH[ k ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SUB32( out_2, out_1 ), 11 ) ); - } -} diff --git a/Engine/lib/opus/silk/arm/LPC_inv_pred_gain_arm.h b/Engine/lib/opus/silk/arm/LPC_inv_pred_gain_arm.h deleted file mode 100644 index 9895b555c..000000000 --- a/Engine/lib/opus/silk/arm/LPC_inv_pred_gain_arm.h +++ /dev/null @@ -1,57 +0,0 @@ -/*********************************************************************** -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. -***********************************************************************/ - -#ifndef SILK_LPC_INV_PRED_GAIN_ARM_H -# define SILK_LPC_INV_PRED_GAIN_ARM_H - -# include "celt/arm/armcpu.h" - -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -opus_int32 silk_LPC_inverse_pred_gain_neon( /* O Returns inverse prediction gain in energy domain, Q30 */ - const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ - const opus_int order /* I Prediction order */ -); - -# if !defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_PRESUME_NEON) -# define OVERRIDE_silk_LPC_inverse_pred_gain (1) -# define silk_LPC_inverse_pred_gain(A_Q12, order, arch) ((void)(arch), PRESUME_NEON(silk_LPC_inverse_pred_gain)(A_Q12, order)) -# endif -# endif - -# if !defined(OVERRIDE_silk_LPC_inverse_pred_gain) -/*Is run-time CPU detection enabled on this platform?*/ -# if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern opus_int32 (*const SILK_LPC_INVERSE_PRED_GAIN_IMPL[OPUS_ARCHMASK+1])(const opus_int16 *A_Q12, const opus_int order); -# define OVERRIDE_silk_LPC_inverse_pred_gain (1) -# define silk_LPC_inverse_pred_gain(A_Q12, order, arch) ((*SILK_LPC_INVERSE_PRED_GAIN_IMPL[(arch)&OPUS_ARCHMASK])(A_Q12, order)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) -# define OVERRIDE_silk_LPC_inverse_pred_gain (1) -# define silk_LPC_inverse_pred_gain(A_Q12, order, arch) ((void)(arch), silk_LPC_inverse_pred_gain_neon(A_Q12, order)) -# endif -# endif - -#endif /* end SILK_LPC_INV_PRED_GAIN_ARM_H */ diff --git a/Engine/lib/opus/silk/arm/LPC_inv_pred_gain_neon_intr.c b/Engine/lib/opus/silk/arm/LPC_inv_pred_gain_neon_intr.c deleted file mode 100644 index 726e6667b..000000000 --- a/Engine/lib/opus/silk/arm/LPC_inv_pred_gain_neon_intr.c +++ /dev/null @@ -1,288 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include -#include "SigProc_FIX.h" -#include "define.h" - -#define QA 24 -#define A_LIMIT SILK_FIX_CONST( 0.99975, QA ) - -#define MUL32_FRAC_Q(a32, b32, Q) ((opus_int32)(silk_RSHIFT_ROUND64(silk_SMULL(a32, b32), Q))) - -/* The difficulty is how to judge a 64-bit signed integer tmp64 is 32-bit overflowed, - * since NEON has no 64-bit min, max or comparison instructions. - * A failed idea is to compare the results of vmovn(tmp64) and vqmovn(tmp64) whether they are equal or not. - * However, this idea fails when the tmp64 is something like 0xFFFFFFF980000000. - * Here we know that mult2Q >= 1, so the highest bit (bit 63, sign bit) of tmp64 must equal to bit 62. - * tmp64 was shifted left by 1 and we got tmp64'. If high_half(tmp64') != 0 and high_half(tmp64') != -1, - * then we know that bit 31 to bit 63 of tmp64 can not all be the sign bit, and therefore tmp64 is 32-bit overflowed. - * That is, we judge if tmp64' > 0x00000000FFFFFFFF, or tmp64' <= 0xFFFFFFFF00000000. - * We use narrowing shift right 31 bits to tmp32' to save data bandwidth and instructions. - * That is, we judge if tmp32' > 0x00000000, or tmp32' <= 0xFFFFFFFF. - */ - -/* Compute inverse of LPC prediction gain, and */ -/* test if LPC coefficients are stable (all poles within unit circle) */ -static OPUS_INLINE opus_int32 LPC_inverse_pred_gain_QA_neon( /* O Returns inverse prediction gain in energy domain, Q30 */ - opus_int32 A_QA[ SILK_MAX_ORDER_LPC ], /* I Prediction coefficients */ - const opus_int order /* I Prediction order */ -) -{ - opus_int k, n, mult2Q; - opus_int32 invGain_Q30, rc_Q31, rc_mult1_Q30, rc_mult2, tmp1, tmp2; - opus_int32 max, min; - int32x4_t max_s32x4, min_s32x4; - int32x2_t max_s32x2, min_s32x2; - - max_s32x4 = vdupq_n_s32( silk_int32_MIN ); - min_s32x4 = vdupq_n_s32( silk_int32_MAX ); - invGain_Q30 = SILK_FIX_CONST( 1, 30 ); - for( k = order - 1; k > 0; k-- ) { - int32x2_t rc_Q31_s32x2, rc_mult2_s32x2; - int64x2_t mult2Q_s64x2; - - /* Check for stability */ - if( ( A_QA[ k ] > A_LIMIT ) || ( A_QA[ k ] < -A_LIMIT ) ) { - return 0; - } - - /* Set RC equal to negated AR coef */ - rc_Q31 = -silk_LSHIFT( A_QA[ k ], 31 - QA ); - - /* rc_mult1_Q30 range: [ 1 : 2^30 ] */ - rc_mult1_Q30 = silk_SUB32( SILK_FIX_CONST( 1, 30 ), silk_SMMUL( rc_Q31, rc_Q31 ) ); - silk_assert( rc_mult1_Q30 > ( 1 << 15 ) ); /* reduce A_LIMIT if fails */ - silk_assert( rc_mult1_Q30 <= ( 1 << 30 ) ); - - /* Update inverse gain */ - /* invGain_Q30 range: [ 0 : 2^30 ] */ - invGain_Q30 = silk_LSHIFT( silk_SMMUL( invGain_Q30, rc_mult1_Q30 ), 2 ); - silk_assert( invGain_Q30 >= 0 ); - silk_assert( invGain_Q30 <= ( 1 << 30 ) ); - if( invGain_Q30 < SILK_FIX_CONST( 1.0f / MAX_PREDICTION_POWER_GAIN, 30 ) ) { - return 0; - } - - /* rc_mult2 range: [ 2^30 : silk_int32_MAX ] */ - mult2Q = 32 - silk_CLZ32( silk_abs( rc_mult1_Q30 ) ); - rc_mult2 = silk_INVERSE32_varQ( rc_mult1_Q30, mult2Q + 30 ); - - /* Update AR coefficient */ - rc_Q31_s32x2 = vdup_n_s32( rc_Q31 ); - mult2Q_s64x2 = vdupq_n_s64( -mult2Q ); - rc_mult2_s32x2 = vdup_n_s32( rc_mult2 ); - - for( n = 0; n < ( ( k + 1 ) >> 1 ) - 3; n += 4 ) { - /* We always calculate extra elements of A_QA buffer when ( k % 4 ) != 0, to take the advantage of SIMD parallelization. */ - int32x4_t tmp1_s32x4, tmp2_s32x4, t0_s32x4, t1_s32x4, s0_s32x4, s1_s32x4, t_QA0_s32x4, t_QA1_s32x4; - int64x2_t t0_s64x2, t1_s64x2, t2_s64x2, t3_s64x2; - tmp1_s32x4 = vld1q_s32( A_QA + n ); - tmp2_s32x4 = vld1q_s32( A_QA + k - n - 4 ); - tmp2_s32x4 = vrev64q_s32( tmp2_s32x4 ); - tmp2_s32x4 = vcombine_s32( vget_high_s32( tmp2_s32x4 ), vget_low_s32( tmp2_s32x4 ) ); - t0_s32x4 = vqrdmulhq_lane_s32( tmp2_s32x4, rc_Q31_s32x2, 0 ); - t1_s32x4 = vqrdmulhq_lane_s32( tmp1_s32x4, rc_Q31_s32x2, 0 ); - t_QA0_s32x4 = vqsubq_s32( tmp1_s32x4, t0_s32x4 ); - t_QA1_s32x4 = vqsubq_s32( tmp2_s32x4, t1_s32x4 ); - t0_s64x2 = vmull_s32( vget_low_s32 ( t_QA0_s32x4 ), rc_mult2_s32x2 ); - t1_s64x2 = vmull_s32( vget_high_s32( t_QA0_s32x4 ), rc_mult2_s32x2 ); - t2_s64x2 = vmull_s32( vget_low_s32 ( t_QA1_s32x4 ), rc_mult2_s32x2 ); - t3_s64x2 = vmull_s32( vget_high_s32( t_QA1_s32x4 ), rc_mult2_s32x2 ); - t0_s64x2 = vrshlq_s64( t0_s64x2, mult2Q_s64x2 ); - t1_s64x2 = vrshlq_s64( t1_s64x2, mult2Q_s64x2 ); - t2_s64x2 = vrshlq_s64( t2_s64x2, mult2Q_s64x2 ); - t3_s64x2 = vrshlq_s64( t3_s64x2, mult2Q_s64x2 ); - t0_s32x4 = vcombine_s32( vmovn_s64( t0_s64x2 ), vmovn_s64( t1_s64x2 ) ); - t1_s32x4 = vcombine_s32( vmovn_s64( t2_s64x2 ), vmovn_s64( t3_s64x2 ) ); - s0_s32x4 = vcombine_s32( vshrn_n_s64( t0_s64x2, 31 ), vshrn_n_s64( t1_s64x2, 31 ) ); - s1_s32x4 = vcombine_s32( vshrn_n_s64( t2_s64x2, 31 ), vshrn_n_s64( t3_s64x2, 31 ) ); - max_s32x4 = vmaxq_s32( max_s32x4, s0_s32x4 ); - min_s32x4 = vminq_s32( min_s32x4, s0_s32x4 ); - max_s32x4 = vmaxq_s32( max_s32x4, s1_s32x4 ); - min_s32x4 = vminq_s32( min_s32x4, s1_s32x4 ); - t1_s32x4 = vrev64q_s32( t1_s32x4 ); - t1_s32x4 = vcombine_s32( vget_high_s32( t1_s32x4 ), vget_low_s32( t1_s32x4 ) ); - vst1q_s32( A_QA + n, t0_s32x4 ); - vst1q_s32( A_QA + k - n - 4, t1_s32x4 ); - } - for( ; n < (k + 1) >> 1; n++ ) { - opus_int64 tmp64; - tmp1 = A_QA[ n ]; - tmp2 = A_QA[ k - n - 1 ]; - tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( silk_SUB_SAT32(tmp1, - MUL32_FRAC_Q( tmp2, rc_Q31, 31 ) ), rc_mult2 ), mult2Q); - if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) { - return 0; - } - A_QA[ n ] = ( opus_int32 )tmp64; - tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( silk_SUB_SAT32(tmp2, - MUL32_FRAC_Q( tmp1, rc_Q31, 31 ) ), rc_mult2), mult2Q); - if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) { - return 0; - } - A_QA[ k - n - 1 ] = ( opus_int32 )tmp64; - } - } - - /* Check for stability */ - if( ( A_QA[ k ] > A_LIMIT ) || ( A_QA[ k ] < -A_LIMIT ) ) { - return 0; - } - - max_s32x2 = vmax_s32( vget_low_s32( max_s32x4 ), vget_high_s32( max_s32x4 ) ); - min_s32x2 = vmin_s32( vget_low_s32( min_s32x4 ), vget_high_s32( min_s32x4 ) ); - max_s32x2 = vmax_s32( max_s32x2, vreinterpret_s32_s64( vshr_n_s64( vreinterpret_s64_s32( max_s32x2 ), 32 ) ) ); - min_s32x2 = vmin_s32( min_s32x2, vreinterpret_s32_s64( vshr_n_s64( vreinterpret_s64_s32( min_s32x2 ), 32 ) ) ); - max = vget_lane_s32( max_s32x2, 0 ); - min = vget_lane_s32( min_s32x2, 0 ); - if( ( max > 0 ) || ( min < -1 ) ) { - return 0; - } - - /* Set RC equal to negated AR coef */ - rc_Q31 = -silk_LSHIFT( A_QA[ 0 ], 31 - QA ); - - /* Range: [ 1 : 2^30 ] */ - rc_mult1_Q30 = silk_SUB32( SILK_FIX_CONST( 1, 30 ), silk_SMMUL( rc_Q31, rc_Q31 ) ); - - /* Update inverse gain */ - /* Range: [ 0 : 2^30 ] */ - invGain_Q30 = silk_LSHIFT( silk_SMMUL( invGain_Q30, rc_mult1_Q30 ), 2 ); - silk_assert( invGain_Q30 >= 0 ); - silk_assert( invGain_Q30 <= ( 1 << 30 ) ); - if( invGain_Q30 < SILK_FIX_CONST( 1.0f / MAX_PREDICTION_POWER_GAIN, 30 ) ) { - return 0; - } - - return invGain_Q30; -} - -/* For input in Q12 domain */ -opus_int32 silk_LPC_inverse_pred_gain_neon( /* O Returns inverse prediction gain in energy domain, Q30 */ - const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ - const opus_int order /* I Prediction order */ -) -{ -#ifdef OPUS_CHECK_ASM - const opus_int32 invGain_Q30_c = silk_LPC_inverse_pred_gain_c( A_Q12, order ); -#endif - - opus_int32 invGain_Q30; - if( ( SILK_MAX_ORDER_LPC != 24 ) || ( order & 1 )) { - invGain_Q30 = silk_LPC_inverse_pred_gain_c( A_Q12, order ); - } - else { - opus_int32 Atmp_QA[ SILK_MAX_ORDER_LPC ]; - opus_int32 DC_resp; - int16x8_t t0_s16x8, t1_s16x8, t2_s16x8; - int32x4_t t0_s32x4; - const opus_int leftover = order & 7; - - /* Increase Q domain of the AR coefficients */ - t0_s16x8 = vld1q_s16( A_Q12 + 0 ); - t1_s16x8 = vld1q_s16( A_Q12 + 8 ); - if ( order > 16 ) { - t2_s16x8 = vld1q_s16( A_Q12 + 16 ); - } - t0_s32x4 = vpaddlq_s16( t0_s16x8 ); - - switch( order - leftover ) - { - case 24: - t0_s32x4 = vpadalq_s16( t0_s32x4, t2_s16x8 ); - vst1q_s32( Atmp_QA + 16, vshll_n_s16( vget_low_s16 ( t2_s16x8 ), QA - 12 ) ); - vst1q_s32( Atmp_QA + 20, vshll_n_s16( vget_high_s16( t2_s16x8 ), QA - 12 ) ); - /* FALLTHROUGH */ - - case 16: - t0_s32x4 = vpadalq_s16( t0_s32x4, t1_s16x8 ); - vst1q_s32( Atmp_QA + 8, vshll_n_s16( vget_low_s16 ( t1_s16x8 ), QA - 12 ) ); - vst1q_s32( Atmp_QA + 12, vshll_n_s16( vget_high_s16( t1_s16x8 ), QA - 12 ) ); - /* FALLTHROUGH */ - - case 8: - { - const int32x2_t t_s32x2 = vpadd_s32( vget_low_s32( t0_s32x4 ), vget_high_s32( t0_s32x4 ) ); - const int64x1_t t_s64x1 = vpaddl_s32( t_s32x2 ); - DC_resp = vget_lane_s32( vreinterpret_s32_s64( t_s64x1 ), 0 ); - vst1q_s32( Atmp_QA + 0, vshll_n_s16( vget_low_s16 ( t0_s16x8 ), QA - 12 ) ); - vst1q_s32( Atmp_QA + 4, vshll_n_s16( vget_high_s16( t0_s16x8 ), QA - 12 ) ); - } - break; - - default: - DC_resp = 0; - break; - } - A_Q12 += order - leftover; - - switch( leftover ) - { - case 6: - DC_resp += (opus_int32)A_Q12[ 5 ]; - DC_resp += (opus_int32)A_Q12[ 4 ]; - Atmp_QA[ order - leftover + 5 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 5 ], QA - 12 ); - Atmp_QA[ order - leftover + 4 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 4 ], QA - 12 ); - /* FALLTHROUGH */ - - case 4: - DC_resp += (opus_int32)A_Q12[ 3 ]; - DC_resp += (opus_int32)A_Q12[ 2 ]; - Atmp_QA[ order - leftover + 3 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 3 ], QA - 12 ); - Atmp_QA[ order - leftover + 2 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 2 ], QA - 12 ); - /* FALLTHROUGH */ - - case 2: - DC_resp += (opus_int32)A_Q12[ 1 ]; - DC_resp += (opus_int32)A_Q12[ 0 ]; - Atmp_QA[ order - leftover + 1 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 1 ], QA - 12 ); - Atmp_QA[ order - leftover + 0 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 0 ], QA - 12 ); - /* FALLTHROUGH */ - - default: - break; - } - - /* If the DC is unstable, we don't even need to do the full calculations */ - if( DC_resp >= 4096 ) { - invGain_Q30 = 0; - } else { - invGain_Q30 = LPC_inverse_pred_gain_QA_neon( Atmp_QA, order ); - } - } - -#ifdef OPUS_CHECK_ASM - silk_assert( invGain_Q30_c == invGain_Q30 ); -#endif - - return invGain_Q30; -} diff --git a/Engine/lib/opus/silk/arm/NSQ_del_dec_arm.h b/Engine/lib/opus/silk/arm/NSQ_del_dec_arm.h deleted file mode 100644 index 9e76e1692..000000000 --- a/Engine/lib/opus/silk/arm/NSQ_del_dec_arm.h +++ /dev/null @@ -1,100 +0,0 @@ -/*********************************************************************** -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. -***********************************************************************/ - -#ifndef SILK_NSQ_DEL_DEC_ARM_H -#define SILK_NSQ_DEL_DEC_ARM_H - -#include "celt/arm/armcpu.h" - -#if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -void silk_NSQ_del_dec_neon( - const silk_encoder_state *psEncC, silk_nsq_state *NSQ, - SideInfoIndices *psIndices, const opus_int16 x16[], opus_int8 pulses[], - const opus_int16 PredCoef_Q12[2 * MAX_LPC_ORDER], - const opus_int16 LTPCoef_Q14[LTP_ORDER * MAX_NB_SUBFR], - const opus_int16 AR_Q13[MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER], - const opus_int HarmShapeGain_Q14[MAX_NB_SUBFR], - const opus_int Tilt_Q14[MAX_NB_SUBFR], - const opus_int32 LF_shp_Q14[MAX_NB_SUBFR], - const opus_int32 Gains_Q16[MAX_NB_SUBFR], - const opus_int pitchL[MAX_NB_SUBFR], const opus_int Lambda_Q10, - const opus_int LTP_scale_Q14); - -#if !defined(OPUS_HAVE_RTCD) -#define OVERRIDE_silk_NSQ_del_dec (1) -#define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, \ - LTPCoef_Q14, AR_Q13, HarmShapeGain_Q14, Tilt_Q14, \ - LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, \ - LTP_scale_Q14, arch) \ - ((void)(arch), \ - PRESUME_NEON(silk_NSQ_del_dec)( \ - psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, \ - AR_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, \ - Lambda_Q10, LTP_scale_Q14)) -#endif -#endif - -#if !defined(OVERRIDE_silk_NSQ_del_dec) -/*Is run-time CPU detection enabled on this platform?*/ -#if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && \ - !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern void (*const SILK_NSQ_DEL_DEC_IMPL[OPUS_ARCHMASK + 1])( - const silk_encoder_state *psEncC, silk_nsq_state *NSQ, - SideInfoIndices *psIndices, const opus_int16 x16[], opus_int8 pulses[], - const opus_int16 PredCoef_Q12[2 * MAX_LPC_ORDER], - const opus_int16 LTPCoef_Q14[LTP_ORDER * MAX_NB_SUBFR], - const opus_int16 AR_Q13[MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER], - const opus_int HarmShapeGain_Q14[MAX_NB_SUBFR], - const opus_int Tilt_Q14[MAX_NB_SUBFR], - const opus_int32 LF_shp_Q14[MAX_NB_SUBFR], - const opus_int32 Gains_Q16[MAX_NB_SUBFR], - const opus_int pitchL[MAX_NB_SUBFR], const opus_int Lambda_Q10, - const opus_int LTP_scale_Q14); -#define OVERRIDE_silk_NSQ_del_dec (1) -#define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, \ - LTPCoef_Q14, AR_Q13, HarmShapeGain_Q14, Tilt_Q14, \ - LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, \ - LTP_scale_Q14, arch) \ - ((*SILK_NSQ_DEL_DEC_IMPL[(arch)&OPUS_ARCHMASK])( \ - psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, \ - AR_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, \ - Lambda_Q10, LTP_scale_Q14)) -#elif defined(OPUS_ARM_PRESUME_NEON_INTR) -#define OVERRIDE_silk_NSQ_del_dec (1) -#define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, \ - LTPCoef_Q14, AR_Q13, HarmShapeGain_Q14, Tilt_Q14, \ - LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, \ - LTP_scale_Q14, arch) \ - ((void)(arch), \ - silk_NSQ_del_dec_neon(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, \ - LTPCoef_Q14, AR_Q13, HarmShapeGain_Q14, Tilt_Q14, \ - LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, \ - LTP_scale_Q14)) -#endif -#endif - -#endif /* end SILK_NSQ_DEL_DEC_ARM_H */ diff --git a/Engine/lib/opus/silk/arm/NSQ_del_dec_neon_intr.c b/Engine/lib/opus/silk/arm/NSQ_del_dec_neon_intr.c deleted file mode 100644 index 212410f36..000000000 --- a/Engine/lib/opus/silk/arm/NSQ_del_dec_neon_intr.c +++ /dev/null @@ -1,1124 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include -#ifdef OPUS_CHECK_ASM -# include -#endif -#include "main.h" -#include "stack_alloc.h" - -/* NEON intrinsics optimization now can only parallelize up to 4 delay decision states. */ -/* If there are more states, C function is called, and this optimization must be expanded. */ -#define NEON_MAX_DEL_DEC_STATES 4 - -typedef struct { - opus_int32 sLPC_Q14[ MAX_SUB_FRAME_LENGTH + NSQ_LPC_BUF_LENGTH ][ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 RandState[ DECISION_DELAY ][ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 Q_Q10[ DECISION_DELAY ][ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 Xq_Q14[ DECISION_DELAY ][ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 Pred_Q15[ DECISION_DELAY ][ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 Shape_Q14[ DECISION_DELAY ][ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ][ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 LF_AR_Q14[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 Diff_Q14[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 Seed[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 SeedInit[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 RD_Q10[ NEON_MAX_DEL_DEC_STATES ]; -} NSQ_del_decs_struct; - -typedef struct { - opus_int32 Q_Q10[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 RD_Q10[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 xq_Q14[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 LF_AR_Q14[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 Diff_Q14[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 sLTP_shp_Q14[ NEON_MAX_DEL_DEC_STATES ]; - opus_int32 LPC_exc_Q14[ NEON_MAX_DEL_DEC_STATES ]; -} NSQ_samples_struct; - -static OPUS_INLINE void silk_nsq_del_dec_scale_states_neon( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_decs_struct psDelDec[], /* I/O Delayed decision states */ - const opus_int16 x16[], /* I Input */ - opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ - const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I Subframe number */ - const opus_int LTP_scale_Q14, /* I LTP state scaling */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type, /* I Signal type */ - const opus_int decisionDelay /* I Decision delay */ -); - -/******************************************/ -/* Noise shape quantizer for one subframe */ -/******************************************/ -static OPUS_INLINE void silk_noise_shape_quantizer_del_dec_neon( - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_decs_struct psDelDec[], /* I/O Delayed decision states */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP filter state */ - opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int subfr, /* I Subframe number */ - opus_int shapingLPCOrder, /* I Shaping LPC filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - opus_int warping_Q16, /* I */ - opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ - opus_int *smpl_buf_idx, /* I/O Index to newest samples in buffers */ - opus_int decisionDelay /* I */ -); - -static OPUS_INLINE void copy_winner_state_kernel( - const NSQ_del_decs_struct *psDelDec, - const opus_int offset, - const opus_int last_smple_idx, - const opus_int Winner_ind, - const int32x2_t gain_lo_s32x2, - const int32x2_t gain_hi_s32x2, - const int32x4_t shift_s32x4, - int32x4_t t0_s32x4, - int32x4_t t1_s32x4, - opus_int8 *const pulses, - opus_int16 *pxq, - silk_nsq_state *NSQ -) -{ - int16x8_t t_s16x8; - int32x4_t o0_s32x4, o1_s32x4; - - t0_s32x4 = vld1q_lane_s32( &psDelDec->Q_Q10[ last_smple_idx - 0 ][ Winner_ind ], t0_s32x4, 0 ); - t0_s32x4 = vld1q_lane_s32( &psDelDec->Q_Q10[ last_smple_idx - 1 ][ Winner_ind ], t0_s32x4, 1 ); - t0_s32x4 = vld1q_lane_s32( &psDelDec->Q_Q10[ last_smple_idx - 2 ][ Winner_ind ], t0_s32x4, 2 ); - t0_s32x4 = vld1q_lane_s32( &psDelDec->Q_Q10[ last_smple_idx - 3 ][ Winner_ind ], t0_s32x4, 3 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Q_Q10[ last_smple_idx - 4 ][ Winner_ind ], t1_s32x4, 0 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Q_Q10[ last_smple_idx - 5 ][ Winner_ind ], t1_s32x4, 1 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Q_Q10[ last_smple_idx - 6 ][ Winner_ind ], t1_s32x4, 2 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Q_Q10[ last_smple_idx - 7 ][ Winner_ind ], t1_s32x4, 3 ); - t_s16x8 = vcombine_s16( vrshrn_n_s32( t0_s32x4, 10 ), vrshrn_n_s32( t1_s32x4, 10 ) ); - vst1_s8( &pulses[ offset ], vmovn_s16( t_s16x8 ) ); - - t0_s32x4 = vld1q_lane_s32( &psDelDec->Xq_Q14[ last_smple_idx - 0 ][ Winner_ind ], t0_s32x4, 0 ); - t0_s32x4 = vld1q_lane_s32( &psDelDec->Xq_Q14[ last_smple_idx - 1 ][ Winner_ind ], t0_s32x4, 1 ); - t0_s32x4 = vld1q_lane_s32( &psDelDec->Xq_Q14[ last_smple_idx - 2 ][ Winner_ind ], t0_s32x4, 2 ); - t0_s32x4 = vld1q_lane_s32( &psDelDec->Xq_Q14[ last_smple_idx - 3 ][ Winner_ind ], t0_s32x4, 3 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Xq_Q14[ last_smple_idx - 4 ][ Winner_ind ], t1_s32x4, 0 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Xq_Q14[ last_smple_idx - 5 ][ Winner_ind ], t1_s32x4, 1 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Xq_Q14[ last_smple_idx - 6 ][ Winner_ind ], t1_s32x4, 2 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Xq_Q14[ last_smple_idx - 7 ][ Winner_ind ], t1_s32x4, 3 ); - o0_s32x4 = vqdmulhq_lane_s32( t0_s32x4, gain_lo_s32x2, 0 ); - o1_s32x4 = vqdmulhq_lane_s32( t1_s32x4, gain_lo_s32x2, 0 ); - o0_s32x4 = vmlaq_lane_s32( o0_s32x4, t0_s32x4, gain_hi_s32x2, 0 ); - o1_s32x4 = vmlaq_lane_s32( o1_s32x4, t1_s32x4, gain_hi_s32x2, 0 ); - o0_s32x4 = vrshlq_s32( o0_s32x4, shift_s32x4 ); - o1_s32x4 = vrshlq_s32( o1_s32x4, shift_s32x4 ); - vst1_s16( &pxq[ offset + 0 ], vqmovn_s32( o0_s32x4 ) ); - vst1_s16( &pxq[ offset + 4 ], vqmovn_s32( o1_s32x4 ) ); - - t0_s32x4 = vld1q_lane_s32( &psDelDec->Shape_Q14[ last_smple_idx - 0 ][ Winner_ind ], t0_s32x4, 0 ); - t0_s32x4 = vld1q_lane_s32( &psDelDec->Shape_Q14[ last_smple_idx - 1 ][ Winner_ind ], t0_s32x4, 1 ); - t0_s32x4 = vld1q_lane_s32( &psDelDec->Shape_Q14[ last_smple_idx - 2 ][ Winner_ind ], t0_s32x4, 2 ); - t0_s32x4 = vld1q_lane_s32( &psDelDec->Shape_Q14[ last_smple_idx - 3 ][ Winner_ind ], t0_s32x4, 3 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Shape_Q14[ last_smple_idx - 4 ][ Winner_ind ], t1_s32x4, 0 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Shape_Q14[ last_smple_idx - 5 ][ Winner_ind ], t1_s32x4, 1 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Shape_Q14[ last_smple_idx - 6 ][ Winner_ind ], t1_s32x4, 2 ); - t1_s32x4 = vld1q_lane_s32( &psDelDec->Shape_Q14[ last_smple_idx - 7 ][ Winner_ind ], t1_s32x4, 3 ); - vst1q_s32( &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx + offset + 0 ], t0_s32x4 ); - vst1q_s32( &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx + offset + 4 ], t1_s32x4 ); -} - -static OPUS_INLINE void copy_winner_state( - const NSQ_del_decs_struct *psDelDec, - const opus_int decisionDelay, - const opus_int smpl_buf_idx, - const opus_int Winner_ind, - const opus_int32 gain, - const opus_int32 shift, - opus_int8 *const pulses, - opus_int16 *pxq, - silk_nsq_state *NSQ -) -{ - opus_int i, last_smple_idx; - const int32x2_t gain_lo_s32x2 = vdup_n_s32( silk_LSHIFT32( gain & 0x0000FFFF, 15 ) ); - const int32x2_t gain_hi_s32x2 = vdup_n_s32( gain >> 16 ); - const int32x4_t shift_s32x4 = vdupq_n_s32( -shift ); - int32x4_t t0_s32x4, t1_s32x4; - - t0_s32x4 = t1_s32x4 = vdupq_n_s32( 0 ); /* initialization */ - last_smple_idx = smpl_buf_idx + decisionDelay - 1 + DECISION_DELAY; - if( last_smple_idx >= DECISION_DELAY ) last_smple_idx -= DECISION_DELAY; - if( last_smple_idx >= DECISION_DELAY ) last_smple_idx -= DECISION_DELAY; - - for( i = 0; ( i < ( decisionDelay - 7 ) ) && ( last_smple_idx >= 7 ); i += 8, last_smple_idx -= 8 ) { - copy_winner_state_kernel( psDelDec, i - decisionDelay, last_smple_idx, Winner_ind, gain_lo_s32x2, gain_hi_s32x2, shift_s32x4, t0_s32x4, t1_s32x4, pulses, pxq, NSQ ); - } - for( ; ( i < decisionDelay ) && ( last_smple_idx >= 0 ); i++, last_smple_idx-- ) { - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDelDec->Q_Q10[ last_smple_idx ][ Winner_ind ], 10 ); - pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( psDelDec->Xq_Q14[ last_smple_idx ][ Winner_ind ], gain ), shift ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDelDec->Shape_Q14[ last_smple_idx ][ Winner_ind ]; - } - - last_smple_idx += DECISION_DELAY; - for( ; i < ( decisionDelay - 7 ); i++, last_smple_idx-- ) { - copy_winner_state_kernel( psDelDec, i - decisionDelay, last_smple_idx, Winner_ind, gain_lo_s32x2, gain_hi_s32x2, shift_s32x4, t0_s32x4, t1_s32x4, pulses, pxq, NSQ ); - } - for( ; i < decisionDelay; i++, last_smple_idx-- ) { - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDelDec->Q_Q10[ last_smple_idx ][ Winner_ind ], 10 ); - pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( psDelDec->Xq_Q14[ last_smple_idx ][ Winner_ind ], gain ), shift ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDelDec->Shape_Q14[ last_smple_idx ][ Winner_ind ]; - } -} - -void silk_NSQ_del_dec_neon( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -) -{ -#ifdef OPUS_CHECK_ASM - silk_nsq_state NSQ_c; - SideInfoIndices psIndices_c; - opus_int8 pulses_c[ MAX_FRAME_LENGTH ]; - const opus_int8 *const pulses_a = pulses; - - ( void )pulses_a; - silk_memcpy( &NSQ_c, NSQ, sizeof( NSQ_c ) ); - silk_memcpy( &psIndices_c, psIndices, sizeof( psIndices_c ) ); - silk_memcpy( pulses_c, pulses, sizeof( pulses_c ) ); - silk_NSQ_del_dec_c( psEncC, &NSQ_c, &psIndices_c, x16, pulses_c, PredCoef_Q12, LTPCoef_Q14, AR_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, - pitchL, Lambda_Q10, LTP_scale_Q14 ); -#endif - - /* The optimization parallelizes the different delay decision states. */ - if(( psEncC->nStatesDelayedDecision > NEON_MAX_DEL_DEC_STATES ) || ( psEncC->nStatesDelayedDecision <= 2 )) { - /* NEON intrinsics optimization now can only parallelize up to 4 delay decision states. */ - /* If there are more states, C function is called, and this optimization must be expanded. */ - /* When the number of delay decision states is less than 3, there are penalties using this */ - /* optimization, and C function is called. */ - /* When the number of delay decision states is 2, it's better to specialize another */ - /* structure NSQ_del_dec2_struct and optimize with shorter NEON registers. (Low priority) */ - silk_NSQ_del_dec_c( psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, HarmShapeGain_Q14, - Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14 ); - } else { - opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr; - opus_int smpl_buf_idx, decisionDelay; - const opus_int16 *A_Q12, *B_Q14, *AR_shp_Q13; - opus_int16 *pxq; - VARDECL( opus_int32, sLTP_Q15 ); - VARDECL( opus_int16, sLTP ); - opus_int32 HarmShapeFIRPacked_Q14; - opus_int offset_Q10; - opus_int32 RDmin_Q10, Gain_Q10; - VARDECL( opus_int32, x_sc_Q10 ); - VARDECL( opus_int32, delayedGain_Q10 ); - VARDECL( NSQ_del_decs_struct, psDelDec ); - int32x4_t t_s32x4; - SAVE_STACK; - - /* Set unvoiced lag to the previous one, overwrite later for voiced */ - lag = NSQ->lagPrev; - - silk_assert( NSQ->prev_gain_Q16 != 0 ); - - /* Initialize delayed decision states */ - ALLOC( psDelDec, 1, NSQ_del_decs_struct ); - /* Only RandState and RD_Q10 need to be initialized to 0. */ - silk_memset( psDelDec->RandState, 0, sizeof( psDelDec->RandState ) ); - vst1q_s32( psDelDec->RD_Q10, vdupq_n_s32( 0 ) ); - - for( k = 0; k < psEncC->nStatesDelayedDecision; k++ ) { - psDelDec->SeedInit[ k ] = psDelDec->Seed[ k ] = ( k + psIndices->Seed ) & 3; - } - vst1q_s32( psDelDec->LF_AR_Q14, vld1q_dup_s32( &NSQ->sLF_AR_shp_Q14 ) ); - vst1q_s32( psDelDec->Diff_Q14, vld1q_dup_s32( &NSQ->sDiff_shp_Q14 ) ); - vst1q_s32( psDelDec->Shape_Q14[ 0 ], vld1q_dup_s32( &NSQ->sLTP_shp_Q14[ psEncC->ltp_mem_length - 1 ] ) ); - for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { - vst1q_s32( psDelDec->sLPC_Q14[ i ], vld1q_dup_s32( &NSQ->sLPC_Q14[ i ] ) ); - } - for( i = 0; i < (opus_int)( sizeof( NSQ->sAR2_Q14 ) / sizeof( NSQ->sAR2_Q14[ 0 ] ) ); i++ ) { - vst1q_s32( psDelDec->sAR2_Q14[ i ], vld1q_dup_s32( &NSQ->sAR2_Q14[ i ] ) ); - } - - offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; - smpl_buf_idx = 0; /* index of oldest samples */ - - decisionDelay = silk_min_int( DECISION_DELAY, psEncC->subfr_length ); - - /* For voiced frames limit the decision delay to lower than the pitch lag */ - if( psIndices->signalType == TYPE_VOICED ) { - opus_int pitch_min = pitchL[ 0 ]; - for( k = 1; k < psEncC->nb_subfr; k++ ) { - pitch_min = silk_min_int( pitch_min, pitchL[ k ] ); - } - decisionDelay = silk_min_int( decisionDelay, pitch_min - LTP_ORDER / 2 - 1 ); - } else { - if( lag > 0 ) { - decisionDelay = silk_min_int( decisionDelay, lag - LTP_ORDER / 2 - 1 ); - } - } - - if( psIndices->NLSFInterpCoef_Q2 == 4 ) { - LSF_interpolation_flag = 0; - } else { - LSF_interpolation_flag = 1; - } - - ALLOC( sLTP_Q15, psEncC->ltp_mem_length + psEncC->frame_length, opus_int32 ); - ALLOC( sLTP, psEncC->ltp_mem_length + psEncC->frame_length, opus_int16 ); - ALLOC( x_sc_Q10, psEncC->subfr_length, opus_int32 ); - ALLOC( delayedGain_Q10, DECISION_DELAY, opus_int32 ); - /* Set up pointers to start of sub frame */ - pxq = &NSQ->xq[ psEncC->ltp_mem_length ]; - NSQ->sLTP_shp_buf_idx = psEncC->ltp_mem_length; - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - subfr = 0; - for( k = 0; k < psEncC->nb_subfr; k++ ) { - A_Q12 = &PredCoef_Q12[ ( ( k >> 1 ) | ( 1 - LSF_interpolation_flag ) ) * MAX_LPC_ORDER ]; - B_Q14 = <PCoef_Q14[ k * LTP_ORDER ]; - AR_shp_Q13 = &AR_Q13[ k * MAX_SHAPE_LPC_ORDER ]; - - /* Noise shape parameters */ - silk_assert( HarmShapeGain_Q14[ k ] >= 0 ); - HarmShapeFIRPacked_Q14 = silk_RSHIFT( HarmShapeGain_Q14[ k ], 2 ); - HarmShapeFIRPacked_Q14 |= silk_LSHIFT( (opus_int32)silk_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 ); - - NSQ->rewhite_flag = 0; - if( psIndices->signalType == TYPE_VOICED ) { - /* Voiced */ - lag = pitchL[ k ]; - - /* Re-whitening */ - if( ( k & ( 3 - silk_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) { - if( k == 2 ) { - /* RESET DELAYED DECISIONS */ - /* Find winner */ - int32x4_t RD_Q10_s32x4; - RDmin_Q10 = psDelDec->RD_Q10[ 0 ]; - Winner_ind = 0; - for( i = 1; i < psEncC->nStatesDelayedDecision; i++ ) { - if( psDelDec->RD_Q10[ i ] < RDmin_Q10 ) { - RDmin_Q10 = psDelDec->RD_Q10[ i ]; - Winner_ind = i; - } - } - psDelDec->RD_Q10[ Winner_ind ] -= ( silk_int32_MAX >> 4 ); - RD_Q10_s32x4 = vld1q_s32( psDelDec->RD_Q10 ); - RD_Q10_s32x4 = vaddq_s32( RD_Q10_s32x4, vdupq_n_s32( silk_int32_MAX >> 4 ) ); - vst1q_s32( psDelDec->RD_Q10, RD_Q10_s32x4 ); - - /* Copy final part of signals from winner state to output and long-term filter states */ - copy_winner_state( psDelDec, decisionDelay, smpl_buf_idx, Winner_ind, Gains_Q16[ 1 ], 14, pulses, pxq, NSQ ); - - subfr = 0; - } - - /* Rewhiten with new A coefs */ - start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2; - silk_assert( start_idx > 0 ); - - silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], - A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder, psEncC->arch ); - - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - NSQ->rewhite_flag = 1; - } - } - - silk_nsq_del_dec_scale_states_neon( psEncC, NSQ, psDelDec, x16, x_sc_Q10, sLTP, sLTP_Q15, k, - LTP_scale_Q14, Gains_Q16, pitchL, psIndices->signalType, decisionDelay ); - - silk_noise_shape_quantizer_del_dec_neon( NSQ, psDelDec, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q15, - delayedGain_Q10, A_Q12, B_Q14, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], - Gains_Q16[ k ], Lambda_Q10, offset_Q10, psEncC->subfr_length, subfr++, psEncC->shapingLPCOrder, - psEncC->predictLPCOrder, psEncC->warping_Q16, psEncC->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay ); - - x16 += psEncC->subfr_length; - pulses += psEncC->subfr_length; - pxq += psEncC->subfr_length; - } - - /* Find winner */ - RDmin_Q10 = psDelDec->RD_Q10[ 0 ]; - Winner_ind = 0; - for( k = 1; k < psEncC->nStatesDelayedDecision; k++ ) { - if( psDelDec->RD_Q10[ k ] < RDmin_Q10 ) { - RDmin_Q10 = psDelDec->RD_Q10[ k ]; - Winner_ind = k; - } - } - - /* Copy final part of signals from winner state to output and long-term filter states */ - psIndices->Seed = psDelDec->SeedInit[ Winner_ind ]; - Gain_Q10 = silk_RSHIFT32( Gains_Q16[ psEncC->nb_subfr - 1 ], 6 ); - copy_winner_state( psDelDec, decisionDelay, smpl_buf_idx, Winner_ind, Gain_Q10, 8, pulses, pxq, NSQ ); - - t_s32x4 = vdupq_n_s32( 0 ); /* initialization */ - for( i = 0; i < ( NSQ_LPC_BUF_LENGTH - 3 ); i += 4 ) { - t_s32x4 = vld1q_lane_s32( &psDelDec->sLPC_Q14[ i + 0 ][ Winner_ind ], t_s32x4, 0 ); - t_s32x4 = vld1q_lane_s32( &psDelDec->sLPC_Q14[ i + 1 ][ Winner_ind ], t_s32x4, 1 ); - t_s32x4 = vld1q_lane_s32( &psDelDec->sLPC_Q14[ i + 2 ][ Winner_ind ], t_s32x4, 2 ); - t_s32x4 = vld1q_lane_s32( &psDelDec->sLPC_Q14[ i + 3 ][ Winner_ind ], t_s32x4, 3 ); - vst1q_s32( &NSQ->sLPC_Q14[ i ], t_s32x4 ); - } - - for( ; i < NSQ_LPC_BUF_LENGTH; i++ ) { - NSQ->sLPC_Q14[ i ] = psDelDec->sLPC_Q14[ i ][ Winner_ind ]; - } - - for( i = 0; i < (opus_int)( sizeof( NSQ->sAR2_Q14 ) / sizeof( NSQ->sAR2_Q14[ 0 ] ) - 3 ); i += 4 ) { - t_s32x4 = vld1q_lane_s32( &psDelDec->sAR2_Q14[ i + 0 ][ Winner_ind ], t_s32x4, 0 ); - t_s32x4 = vld1q_lane_s32( &psDelDec->sAR2_Q14[ i + 1 ][ Winner_ind ], t_s32x4, 1 ); - t_s32x4 = vld1q_lane_s32( &psDelDec->sAR2_Q14[ i + 2 ][ Winner_ind ], t_s32x4, 2 ); - t_s32x4 = vld1q_lane_s32( &psDelDec->sAR2_Q14[ i + 3 ][ Winner_ind ], t_s32x4, 3 ); - vst1q_s32( &NSQ->sAR2_Q14[ i ], t_s32x4 ); - } - - for( ; i < (opus_int)( sizeof( NSQ->sAR2_Q14 ) / sizeof( NSQ->sAR2_Q14[ 0 ] ) ); i++ ) { - NSQ->sAR2_Q14[ i ] = psDelDec->sAR2_Q14[ i ][ Winner_ind ]; - } - - /* Update states */ - NSQ->sLF_AR_shp_Q14 = psDelDec->LF_AR_Q14[ Winner_ind ]; - NSQ->sDiff_shp_Q14 = psDelDec->Diff_Q14[ Winner_ind ]; - NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ]; - - /* Save quantized speech signal */ - silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) ); - silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) ); - RESTORE_STACK; - } - -#ifdef OPUS_CHECK_ASM - silk_assert( !memcmp( &NSQ_c, NSQ, sizeof( NSQ_c ) ) ); - silk_assert( !memcmp( &psIndices_c, psIndices, sizeof( psIndices_c ) ) ); - silk_assert( !memcmp( pulses_c, pulses_a, sizeof( pulses_c ) ) ); -#endif -} - -/******************************************/ -/* Noise shape quantizer for one subframe */ -/******************************************/ -/* Note: Function silk_short_prediction_create_arch_coef_neon() defined in NSQ_neon.h is actually a hacking C function. */ -/* Therefore here we append "_local" to the NEON function name to avoid confusion. */ -static OPUS_INLINE void silk_short_prediction_create_arch_coef_neon_local(opus_int32 *out, const opus_int16 *in, opus_int order) -{ - int16x8_t t_s16x8; - int32x4_t t0_s32x4, t1_s32x4, t2_s32x4, t3_s32x4; - silk_assert( order == 10 || order == 16 ); - - t_s16x8 = vld1q_s16( in + 0 ); /* 7 6 5 4 3 2 1 0 */ - t_s16x8 = vrev64q_s16( t_s16x8 ); /* 4 5 6 7 0 1 2 3 */ - t2_s32x4 = vshll_n_s16( vget_high_s16( t_s16x8 ), 15 ); /* 4 5 6 7 */ - t3_s32x4 = vshll_n_s16( vget_low_s16( t_s16x8 ), 15 ); /* 0 1 2 3 */ - - if( order == 16 ) { - t_s16x8 = vld1q_s16( in + 8 ); /* F E D C B A 9 8 */ - t_s16x8 = vrev64q_s16( t_s16x8 ); /* C D E F 8 9 A B */ - t0_s32x4 = vshll_n_s16( vget_high_s16( t_s16x8 ), 15 ); /* C D E F */ - t1_s32x4 = vshll_n_s16( vget_low_s16( t_s16x8 ), 15 ); /* 8 9 A B */ - } else { - int16x4_t t_s16x4; - - t0_s32x4 = vdupq_n_s32( 0 ); /* zero zero zero zero */ - t_s16x4 = vld1_s16( in + 6 ); /* 9 8 7 6 */ - t_s16x4 = vrev64_s16( t_s16x4 ); /* 6 7 8 9 */ - t1_s32x4 = vshll_n_s16( t_s16x4, 15 ); - t1_s32x4 = vcombine_s32( vget_low_s32(t0_s32x4), vget_low_s32( t1_s32x4 ) ); /* 8 9 zero zero */ - } - vst1q_s32( out + 0, t0_s32x4 ); - vst1q_s32( out + 4, t1_s32x4 ); - vst1q_s32( out + 8, t2_s32x4 ); - vst1q_s32( out + 12, t3_s32x4 ); -} - -static OPUS_INLINE int32x4_t silk_SMLAWB_lane0_neon( - const int32x4_t out_s32x4, - const int32x4_t in_s32x4, - const int32x2_t coef_s32x2 -) -{ - return vaddq_s32( out_s32x4, vqdmulhq_lane_s32( in_s32x4, coef_s32x2, 0 ) ); -} - -static OPUS_INLINE int32x4_t silk_SMLAWB_lane1_neon( - const int32x4_t out_s32x4, - const int32x4_t in_s32x4, - const int32x2_t coef_s32x2 -) -{ - return vaddq_s32( out_s32x4, vqdmulhq_lane_s32( in_s32x4, coef_s32x2, 1 ) ); -} - -/* Note: This function has different return value than silk_noise_shape_quantizer_short_prediction_neon(). */ -/* Therefore here we append "_local" to the function name to avoid confusion. */ -static OPUS_INLINE int32x4_t silk_noise_shape_quantizer_short_prediction_neon_local(const opus_int32 *buf32, const opus_int32 *a_Q12_arch, opus_int order) -{ - const int32x4_t a_Q12_arch0_s32x4 = vld1q_s32( a_Q12_arch + 0 ); - const int32x4_t a_Q12_arch1_s32x4 = vld1q_s32( a_Q12_arch + 4 ); - const int32x4_t a_Q12_arch2_s32x4 = vld1q_s32( a_Q12_arch + 8 ); - const int32x4_t a_Q12_arch3_s32x4 = vld1q_s32( a_Q12_arch + 12 ); - int32x4_t LPC_pred_Q14_s32x4; - - silk_assert( order == 10 || order == 16 ); - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LPC_pred_Q14_s32x4 = vdupq_n_s32( silk_RSHIFT( order, 1 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane0_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 0 * NEON_MAX_DEL_DEC_STATES ), vget_low_s32( a_Q12_arch0_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane1_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 1 * NEON_MAX_DEL_DEC_STATES ), vget_low_s32( a_Q12_arch0_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane0_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 2 * NEON_MAX_DEL_DEC_STATES ), vget_high_s32( a_Q12_arch0_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane1_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 3 * NEON_MAX_DEL_DEC_STATES ), vget_high_s32( a_Q12_arch0_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane0_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 4 * NEON_MAX_DEL_DEC_STATES ), vget_low_s32( a_Q12_arch1_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane1_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 5 * NEON_MAX_DEL_DEC_STATES ), vget_low_s32( a_Q12_arch1_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane0_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 6 * NEON_MAX_DEL_DEC_STATES ), vget_high_s32( a_Q12_arch1_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane1_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 7 * NEON_MAX_DEL_DEC_STATES ), vget_high_s32( a_Q12_arch1_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane0_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 8 * NEON_MAX_DEL_DEC_STATES ), vget_low_s32( a_Q12_arch2_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane1_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 9 * NEON_MAX_DEL_DEC_STATES ), vget_low_s32( a_Q12_arch2_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane0_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 10 * NEON_MAX_DEL_DEC_STATES ), vget_high_s32( a_Q12_arch2_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane1_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 11 * NEON_MAX_DEL_DEC_STATES ), vget_high_s32( a_Q12_arch2_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane0_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 12 * NEON_MAX_DEL_DEC_STATES ), vget_low_s32( a_Q12_arch3_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane1_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 13 * NEON_MAX_DEL_DEC_STATES ), vget_low_s32( a_Q12_arch3_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane0_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 14 * NEON_MAX_DEL_DEC_STATES ), vget_high_s32( a_Q12_arch3_s32x4 ) ); - LPC_pred_Q14_s32x4 = silk_SMLAWB_lane1_neon( LPC_pred_Q14_s32x4, vld1q_s32( buf32 + 15 * NEON_MAX_DEL_DEC_STATES ), vget_high_s32( a_Q12_arch3_s32x4 ) ); - - return LPC_pred_Q14_s32x4; -} - -static OPUS_INLINE void silk_noise_shape_quantizer_del_dec_neon( - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_decs_struct psDelDec[], /* I/O Delayed decision states */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP filter state */ - opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int subfr, /* I Subframe number */ - opus_int shapingLPCOrder, /* I Shaping LPC filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - opus_int warping_Q16, /* I */ - opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ - opus_int *smpl_buf_idx, /* I/O Index to newest samples in buffers */ - opus_int decisionDelay /* I */ -) -{ - opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; - opus_int32 Winner_rand_state; - opus_int32 LTP_pred_Q14, n_LTP_Q14; - opus_int32 RDmin_Q10, RDmax_Q10; - opus_int32 Gain_Q10; - opus_int32 *pred_lag_ptr, *shp_lag_ptr; - opus_int32 a_Q12_arch[MAX_LPC_ORDER]; - const int32x2_t warping_Q16_s32x2 = vdup_n_s32( silk_LSHIFT32( warping_Q16, 16 ) >> 1 ); - const opus_int32 LF_shp_Q29 = silk_LSHIFT32( LF_shp_Q14, 16 ) >> 1; - opus_int32 AR_shp_Q28[ MAX_SHAPE_LPC_ORDER ]; - const uint32x4_t rand_multiplier_u32x4 = vdupq_n_u32( RAND_MULTIPLIER ); - const uint32x4_t rand_increment_u32x4 = vdupq_n_u32( RAND_INCREMENT ); - - VARDECL( NSQ_samples_struct, psSampleState ); - SAVE_STACK; - - silk_assert( nStatesDelayedDecision > 0 ); - silk_assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */ - ALLOC( psSampleState, 2, NSQ_samples_struct ); - - shp_lag_ptr = &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ]; - pred_lag_ptr = &sLTP_Q15[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ]; - Gain_Q10 = silk_RSHIFT( Gain_Q16, 6 ); - - for( i = 0; i < ( MAX_SHAPE_LPC_ORDER - 7 ); i += 8 ) { - const int16x8_t t_s16x8 = vld1q_s16( AR_shp_Q13 + i ); - vst1q_s32( AR_shp_Q28 + i + 0, vshll_n_s16( vget_low_s16( t_s16x8 ), 15 ) ); - vst1q_s32( AR_shp_Q28 + i + 4, vshll_n_s16( vget_high_s16( t_s16x8 ), 15 ) ); - } - - for( ; i < MAX_SHAPE_LPC_ORDER; i++ ) { - AR_shp_Q28[i] = silk_LSHIFT32( AR_shp_Q13[i], 15 ); - } - - silk_short_prediction_create_arch_coef_neon_local( a_Q12_arch, a_Q12, predictLPCOrder ); - - for( i = 0; i < length; i++ ) { - int32x4_t Seed_s32x4, LPC_pred_Q14_s32x4; - int32x4_t sign_s32x4, tmp1_s32x4, tmp2_s32x4; - int32x4_t n_AR_Q14_s32x4, n_LF_Q14_s32x4; - int32x2_t AR_shp_Q28_s32x2; - int16x4_t r_Q10_s16x4, rr_Q10_s16x4; - - /* Perform common calculations used in all states */ - - /* Long-term prediction */ - if( signalType == TYPE_VOICED ) { - /* Unrolled loop */ - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LTP_pred_Q14 = 2; - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ 0 ], b_Q14[ 0 ] ); - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -1 ], b_Q14[ 1 ] ); - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -2 ], b_Q14[ 2 ] ); - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -3 ], b_Q14[ 3 ] ); - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], b_Q14[ 4 ] ); - LTP_pred_Q14 = silk_LSHIFT( LTP_pred_Q14, 1 ); /* Q13 -> Q14 */ - pred_lag_ptr++; - } else { - LTP_pred_Q14 = 0; - } - - /* Long-term shaping */ - if( lag > 0 ) { - /* Symmetric, packed FIR coefficients */ - n_LTP_Q14 = silk_SMULWB( silk_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = silk_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = silk_SUB_LSHIFT32( LTP_pred_Q14, n_LTP_Q14, 2 ); /* Q12 -> Q14 */ - shp_lag_ptr++; - } else { - n_LTP_Q14 = 0; - } - - /* Generate dither */ - Seed_s32x4 = vld1q_s32( psDelDec->Seed ); - Seed_s32x4 = vreinterpretq_s32_u32( vmlaq_u32( rand_increment_u32x4, vreinterpretq_u32_s32( Seed_s32x4 ), rand_multiplier_u32x4 ) ); - vst1q_s32( psDelDec->Seed, Seed_s32x4 ); - - /* Short-term prediction */ - LPC_pred_Q14_s32x4 = silk_noise_shape_quantizer_short_prediction_neon_local(psDelDec->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 16 + i ], a_Q12_arch, predictLPCOrder); - LPC_pred_Q14_s32x4 = vshlq_n_s32( LPC_pred_Q14_s32x4, 4 ); /* Q10 -> Q14 */ - - /* Noise shape feedback */ - /* Output of lowpass section */ - tmp2_s32x4 = silk_SMLAWB_lane0_neon( vld1q_s32( psDelDec->Diff_Q14 ), vld1q_s32( psDelDec->sAR2_Q14[ 0 ] ), warping_Q16_s32x2 ); - /* Output of allpass section */ - tmp1_s32x4 = vsubq_s32( vld1q_s32( psDelDec->sAR2_Q14[ 1 ] ), tmp2_s32x4 ); - tmp1_s32x4 = silk_SMLAWB_lane0_neon( vld1q_s32( psDelDec->sAR2_Q14[ 0 ] ), tmp1_s32x4, warping_Q16_s32x2 ); - vst1q_s32( psDelDec->sAR2_Q14[ 0 ], tmp2_s32x4 ); - AR_shp_Q28_s32x2 = vld1_s32( AR_shp_Q28 ); - n_AR_Q14_s32x4 = vaddq_s32( vdupq_n_s32( silk_RSHIFT( shapingLPCOrder, 1 ) ), vqdmulhq_lane_s32( tmp2_s32x4, AR_shp_Q28_s32x2, 0 ) ); - - /* Loop over allpass sections */ - for( j = 2; j < shapingLPCOrder; j += 2 ) { - /* Output of allpass section */ - tmp2_s32x4 = vsubq_s32( vld1q_s32( psDelDec->sAR2_Q14[ j + 0 ] ), tmp1_s32x4 ); - tmp2_s32x4 = silk_SMLAWB_lane0_neon( vld1q_s32( psDelDec->sAR2_Q14[ j - 1 ] ), tmp2_s32x4, warping_Q16_s32x2 ); - vst1q_s32( psDelDec->sAR2_Q14[ j - 1 ], tmp1_s32x4 ); - n_AR_Q14_s32x4 = vaddq_s32( n_AR_Q14_s32x4, vqdmulhq_lane_s32( tmp1_s32x4, AR_shp_Q28_s32x2, 1 ) ); - /* Output of allpass section */ - tmp1_s32x4 = vsubq_s32( vld1q_s32( psDelDec->sAR2_Q14[ j + 1 ] ), tmp2_s32x4 ); - tmp1_s32x4 = silk_SMLAWB_lane0_neon( vld1q_s32( psDelDec->sAR2_Q14[ j + 0 ] ), tmp1_s32x4, warping_Q16_s32x2 ); - vst1q_s32( psDelDec->sAR2_Q14[ j + 0 ], tmp2_s32x4 ); - AR_shp_Q28_s32x2 = vld1_s32( &AR_shp_Q28[ j ] ); - n_AR_Q14_s32x4 = vaddq_s32( n_AR_Q14_s32x4, vqdmulhq_lane_s32( tmp2_s32x4, AR_shp_Q28_s32x2, 0 ) ); - } - vst1q_s32( psDelDec->sAR2_Q14[ shapingLPCOrder - 1 ], tmp1_s32x4 ); - n_AR_Q14_s32x4 = vaddq_s32( n_AR_Q14_s32x4, vqdmulhq_lane_s32( tmp1_s32x4, AR_shp_Q28_s32x2, 1 ) ); - n_AR_Q14_s32x4 = vshlq_n_s32( n_AR_Q14_s32x4, 1 ); /* Q11 -> Q12 */ - n_AR_Q14_s32x4 = vaddq_s32( n_AR_Q14_s32x4, vqdmulhq_n_s32( vld1q_s32( psDelDec->LF_AR_Q14 ), silk_LSHIFT32( Tilt_Q14, 16 ) >> 1 ) ); /* Q12 */ - n_AR_Q14_s32x4 = vshlq_n_s32( n_AR_Q14_s32x4, 2 ); /* Q12 -> Q14 */ - n_LF_Q14_s32x4 = vqdmulhq_n_s32( vld1q_s32( psDelDec->Shape_Q14[ *smpl_buf_idx ] ), LF_shp_Q29 ); /* Q12 */ - n_LF_Q14_s32x4 = vaddq_s32( n_LF_Q14_s32x4, vqdmulhq_n_s32( vld1q_s32( psDelDec->LF_AR_Q14 ), silk_LSHIFT32( LF_shp_Q14 >> 16 , 15 ) ) ); /* Q12 */ - n_LF_Q14_s32x4 = vshlq_n_s32( n_LF_Q14_s32x4, 2 ); /* Q12 -> Q14 */ - - /* Input minus prediction plus noise feedback */ - /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP */ - tmp1_s32x4 = vaddq_s32( n_AR_Q14_s32x4, n_LF_Q14_s32x4 ); /* Q14 */ - tmp2_s32x4 = vaddq_s32( vdupq_n_s32( n_LTP_Q14 ), LPC_pred_Q14_s32x4 ); /* Q13 */ - tmp1_s32x4 = vsubq_s32( tmp2_s32x4, tmp1_s32x4 ); /* Q13 */ - tmp1_s32x4 = vrshrq_n_s32( tmp1_s32x4, 4 ); /* Q10 */ - tmp1_s32x4 = vsubq_s32( vdupq_n_s32( x_Q10[ i ] ), tmp1_s32x4 ); /* residual error Q10 */ - - /* Flip sign depending on dither */ - sign_s32x4 = vreinterpretq_s32_u32( vcltq_s32( Seed_s32x4, vdupq_n_s32( 0 ) ) ); - tmp1_s32x4 = veorq_s32( tmp1_s32x4, sign_s32x4 ); - tmp1_s32x4 = vsubq_s32( tmp1_s32x4, sign_s32x4 ); - tmp1_s32x4 = vmaxq_s32( tmp1_s32x4, vdupq_n_s32( -( 31 << 10 ) ) ); - tmp1_s32x4 = vminq_s32( tmp1_s32x4, vdupq_n_s32( 30 << 10 ) ); - r_Q10_s16x4 = vmovn_s32( tmp1_s32x4 ); - - /* Find two quantization level candidates and measure their rate-distortion */ - { - int16x4_t q1_Q10_s16x4 = vsub_s16( r_Q10_s16x4, vdup_n_s16( offset_Q10 ) ); - int16x4_t q1_Q0_s16x4 = vshr_n_s16( q1_Q10_s16x4, 10 ); - int16x4_t q2_Q10_s16x4; - int32x4_t rd1_Q10_s32x4, rd2_Q10_s32x4; - uint32x4_t t_u32x4; - - if( Lambda_Q10 > 2048 ) { - /* For aggressive RDO, the bias becomes more than one pulse. */ - const int rdo_offset = Lambda_Q10/2 - 512; - const uint16x4_t greaterThanRdo = vcgt_s16( q1_Q10_s16x4, vdup_n_s16( rdo_offset ) ); - const uint16x4_t lessThanMinusRdo = vclt_s16( q1_Q10_s16x4, vdup_n_s16( -rdo_offset ) ); - /* If Lambda_Q10 > 32767, then q1_Q0, q1_Q10 and q2_Q10 must change to 32-bit. */ - silk_assert( Lambda_Q10 <= 32767 ); - - q1_Q0_s16x4 = vreinterpret_s16_u16( vclt_s16( q1_Q10_s16x4, vdup_n_s16( 0 ) ) ); - q1_Q0_s16x4 = vbsl_s16( greaterThanRdo, vsub_s16( q1_Q10_s16x4, vdup_n_s16( rdo_offset ) ), q1_Q0_s16x4 ); - q1_Q0_s16x4 = vbsl_s16( lessThanMinusRdo, vadd_s16( q1_Q10_s16x4, vdup_n_s16( rdo_offset ) ), q1_Q0_s16x4 ); - q1_Q0_s16x4 = vshr_n_s16( q1_Q0_s16x4, 10 ); - } - { - const uint16x4_t equal0_u16x4 = vceq_s16( q1_Q0_s16x4, vdup_n_s16( 0 ) ); - const uint16x4_t equalMinus1_u16x4 = vceq_s16( q1_Q0_s16x4, vdup_n_s16( -1 ) ); - const uint16x4_t lessThanMinus1_u16x4 = vclt_s16( q1_Q0_s16x4, vdup_n_s16( -1 ) ); - int16x4_t tmp1_s16x4, tmp2_s16x4; - - q1_Q10_s16x4 = vshl_n_s16( q1_Q0_s16x4, 10 ); - tmp1_s16x4 = vadd_s16( q1_Q10_s16x4, vdup_n_s16( offset_Q10 - QUANT_LEVEL_ADJUST_Q10 ) ); - q1_Q10_s16x4 = vadd_s16( q1_Q10_s16x4, vdup_n_s16( offset_Q10 + QUANT_LEVEL_ADJUST_Q10 ) ); - q1_Q10_s16x4 = vbsl_s16( lessThanMinus1_u16x4, q1_Q10_s16x4, tmp1_s16x4 ); - q1_Q10_s16x4 = vbsl_s16( equal0_u16x4, vdup_n_s16( offset_Q10 ), q1_Q10_s16x4 ); - q1_Q10_s16x4 = vbsl_s16( equalMinus1_u16x4, vdup_n_s16( offset_Q10 - ( 1024 - QUANT_LEVEL_ADJUST_Q10 ) ), q1_Q10_s16x4 ); - q2_Q10_s16x4 = vadd_s16( q1_Q10_s16x4, vdup_n_s16( 1024 ) ); - q2_Q10_s16x4 = vbsl_s16( equal0_u16x4, vdup_n_s16( offset_Q10 + 1024 - QUANT_LEVEL_ADJUST_Q10 ), q2_Q10_s16x4 ); - q2_Q10_s16x4 = vbsl_s16( equalMinus1_u16x4, vdup_n_s16( offset_Q10 ), q2_Q10_s16x4 ); - tmp1_s16x4 = q1_Q10_s16x4; - tmp2_s16x4 = q2_Q10_s16x4; - tmp1_s16x4 = vbsl_s16( vorr_u16( equalMinus1_u16x4, lessThanMinus1_u16x4 ), vneg_s16( tmp1_s16x4 ), tmp1_s16x4 ); - tmp2_s16x4 = vbsl_s16( lessThanMinus1_u16x4, vneg_s16( tmp2_s16x4 ), tmp2_s16x4 ); - rd1_Q10_s32x4 = vmull_s16( tmp1_s16x4, vdup_n_s16( Lambda_Q10 ) ); - rd2_Q10_s32x4 = vmull_s16( tmp2_s16x4, vdup_n_s16( Lambda_Q10 ) ); - } - - rr_Q10_s16x4 = vsub_s16( r_Q10_s16x4, q1_Q10_s16x4 ); - rd1_Q10_s32x4 = vmlal_s16( rd1_Q10_s32x4, rr_Q10_s16x4, rr_Q10_s16x4 ); - rd1_Q10_s32x4 = vshrq_n_s32( rd1_Q10_s32x4, 10 ); - - rr_Q10_s16x4 = vsub_s16( r_Q10_s16x4, q2_Q10_s16x4 ); - rd2_Q10_s32x4 = vmlal_s16( rd2_Q10_s32x4, rr_Q10_s16x4, rr_Q10_s16x4 ); - rd2_Q10_s32x4 = vshrq_n_s32( rd2_Q10_s32x4, 10 ); - - tmp2_s32x4 = vld1q_s32( psDelDec->RD_Q10 ); - tmp1_s32x4 = vaddq_s32( tmp2_s32x4, vminq_s32( rd1_Q10_s32x4, rd2_Q10_s32x4 ) ); - tmp2_s32x4 = vaddq_s32( tmp2_s32x4, vmaxq_s32( rd1_Q10_s32x4, rd2_Q10_s32x4 ) ); - vst1q_s32( psSampleState[ 0 ].RD_Q10, tmp1_s32x4 ); - vst1q_s32( psSampleState[ 1 ].RD_Q10, tmp2_s32x4 ); - t_u32x4 = vcltq_s32( rd1_Q10_s32x4, rd2_Q10_s32x4 ); - tmp1_s32x4 = vbslq_s32( t_u32x4, vmovl_s16( q1_Q10_s16x4 ), vmovl_s16( q2_Q10_s16x4 ) ); - tmp2_s32x4 = vbslq_s32( t_u32x4, vmovl_s16( q2_Q10_s16x4 ), vmovl_s16( q1_Q10_s16x4 ) ); - vst1q_s32( psSampleState[ 0 ].Q_Q10, tmp1_s32x4 ); - vst1q_s32( psSampleState[ 1 ].Q_Q10, tmp2_s32x4 ); - } - - { - /* Update states for best quantization */ - int32x4_t exc_Q14_s32x4, LPC_exc_Q14_s32x4, xq_Q14_s32x4, sLF_AR_shp_Q14_s32x4; - - /* Quantized excitation */ - exc_Q14_s32x4 = vshlq_n_s32( tmp1_s32x4, 4 ); - exc_Q14_s32x4 = veorq_s32( exc_Q14_s32x4, sign_s32x4 ); - exc_Q14_s32x4 = vsubq_s32( exc_Q14_s32x4, sign_s32x4 ); - - /* Add predictions */ - LPC_exc_Q14_s32x4 = vaddq_s32( exc_Q14_s32x4, vdupq_n_s32( LTP_pred_Q14 ) ); - xq_Q14_s32x4 = vaddq_s32( LPC_exc_Q14_s32x4, LPC_pred_Q14_s32x4 ); - - /* Update states */ - tmp1_s32x4 = vsubq_s32( xq_Q14_s32x4, vshlq_n_s32( vdupq_n_s32( x_Q10[ i ] ), 4 ) ); - vst1q_s32( psSampleState[ 0 ].Diff_Q14, tmp1_s32x4 ); - sLF_AR_shp_Q14_s32x4 = vsubq_s32( tmp1_s32x4, n_AR_Q14_s32x4 ); - vst1q_s32( psSampleState[ 0 ].sLTP_shp_Q14, vsubq_s32( sLF_AR_shp_Q14_s32x4, n_LF_Q14_s32x4 ) ); - vst1q_s32( psSampleState[ 0 ].LF_AR_Q14, sLF_AR_shp_Q14_s32x4 ); - vst1q_s32( psSampleState[ 0 ].LPC_exc_Q14, LPC_exc_Q14_s32x4 ); - vst1q_s32( psSampleState[ 0 ].xq_Q14, xq_Q14_s32x4 ); - - /* Quantized excitation */ - exc_Q14_s32x4 = vshlq_n_s32( tmp2_s32x4, 4 ); - exc_Q14_s32x4 = veorq_s32( exc_Q14_s32x4, sign_s32x4 ); - exc_Q14_s32x4 = vsubq_s32( exc_Q14_s32x4, sign_s32x4 ); - - /* Add predictions */ - LPC_exc_Q14_s32x4 = vaddq_s32( exc_Q14_s32x4, vdupq_n_s32( LTP_pred_Q14 ) ); - xq_Q14_s32x4 = vaddq_s32( LPC_exc_Q14_s32x4, LPC_pred_Q14_s32x4 ); - - /* Update states */ - tmp1_s32x4 = vsubq_s32( xq_Q14_s32x4, vshlq_n_s32( vdupq_n_s32( x_Q10[ i ] ), 4 ) ); - vst1q_s32( psSampleState[ 1 ].Diff_Q14, tmp1_s32x4 ); - sLF_AR_shp_Q14_s32x4 = vsubq_s32( tmp1_s32x4, n_AR_Q14_s32x4 ); - vst1q_s32( psSampleState[ 1 ].sLTP_shp_Q14, vsubq_s32( sLF_AR_shp_Q14_s32x4, n_LF_Q14_s32x4 ) ); - vst1q_s32( psSampleState[ 1 ].LF_AR_Q14, sLF_AR_shp_Q14_s32x4 ); - vst1q_s32( psSampleState[ 1 ].LPC_exc_Q14, LPC_exc_Q14_s32x4 ); - vst1q_s32( psSampleState[ 1 ].xq_Q14, xq_Q14_s32x4 ); - } - - *smpl_buf_idx = *smpl_buf_idx ? ( *smpl_buf_idx - 1 ) : ( DECISION_DELAY - 1); - last_smple_idx = *smpl_buf_idx + decisionDelay + DECISION_DELAY; - if( last_smple_idx >= DECISION_DELAY ) last_smple_idx -= DECISION_DELAY; - if( last_smple_idx >= DECISION_DELAY ) last_smple_idx -= DECISION_DELAY; - - /* Find winner */ - RDmin_Q10 = psSampleState[ 0 ].RD_Q10[ 0 ]; - Winner_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - if( psSampleState[ 0 ].RD_Q10[ k ] < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ 0 ].RD_Q10[ k ]; - Winner_ind = k; - } - } - - /* Increase RD values of expired states */ - { - uint32x4_t t_u32x4; - Winner_rand_state = psDelDec->RandState[ last_smple_idx ][ Winner_ind ]; - t_u32x4 = vceqq_s32( vld1q_s32( psDelDec->RandState[ last_smple_idx ] ), vdupq_n_s32( Winner_rand_state ) ); - t_u32x4 = vmvnq_u32( t_u32x4 ); - t_u32x4 = vshrq_n_u32( t_u32x4, 5 ); - tmp1_s32x4 = vld1q_s32( psSampleState[ 0 ].RD_Q10 ); - tmp2_s32x4 = vld1q_s32( psSampleState[ 1 ].RD_Q10 ); - tmp1_s32x4 = vaddq_s32( tmp1_s32x4, vreinterpretq_s32_u32( t_u32x4 ) ); - tmp2_s32x4 = vaddq_s32( tmp2_s32x4, vreinterpretq_s32_u32( t_u32x4 ) ); - vst1q_s32( psSampleState[ 0 ].RD_Q10, tmp1_s32x4 ); - vst1q_s32( psSampleState[ 1 ].RD_Q10, tmp2_s32x4 ); - - /* Find worst in first set and best in second set */ - RDmax_Q10 = psSampleState[ 0 ].RD_Q10[ 0 ]; - RDmin_Q10 = psSampleState[ 1 ].RD_Q10[ 0 ]; - RDmax_ind = 0; - RDmin_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - /* find worst in first set */ - if( psSampleState[ 0 ].RD_Q10[ k ] > RDmax_Q10 ) { - RDmax_Q10 = psSampleState[ 0 ].RD_Q10[ k ]; - RDmax_ind = k; - } - /* find best in second set */ - if( psSampleState[ 1 ].RD_Q10[ k ] < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ 1 ].RD_Q10[ k ]; - RDmin_ind = k; - } - } - } - - /* Replace a state if best from second set outperforms worst in first set */ - if( RDmin_Q10 < RDmax_Q10 ) { - opus_int32 (*ptr)[NEON_MAX_DEL_DEC_STATES] = psDelDec->RandState; - const int numOthers = (int)( ( sizeof( NSQ_del_decs_struct ) - sizeof( ( (NSQ_del_decs_struct *)0 )->sLPC_Q14 ) ) - / ( NEON_MAX_DEL_DEC_STATES * sizeof( opus_int32 ) ) ); - /* Only ( predictLPCOrder - 1 ) of sLPC_Q14 buffer need to be updated, though the first several */ - /* useless sLPC_Q14[] will be different comparing with C when predictLPCOrder < NSQ_LPC_BUF_LENGTH. */ - /* Here just update constant ( NSQ_LPC_BUF_LENGTH - 1 ) for simplicity. */ - for( j = i + 1; j < i + NSQ_LPC_BUF_LENGTH; j++ ) { - psDelDec->sLPC_Q14[ j ][ RDmax_ind ] = psDelDec->sLPC_Q14[ j ][ RDmin_ind ]; - } - for( j = 0; j < numOthers; j++ ) { - ptr[ j ][ RDmax_ind ] = ptr[ j ][ RDmin_ind ]; - } - - psSampleState[ 0 ].Q_Q10[ RDmax_ind ] = psSampleState[ 1 ].Q_Q10[ RDmin_ind ]; - psSampleState[ 0 ].RD_Q10[ RDmax_ind ] = psSampleState[ 1 ].RD_Q10[ RDmin_ind ]; - psSampleState[ 0 ].xq_Q14[ RDmax_ind ] = psSampleState[ 1 ].xq_Q14[ RDmin_ind ]; - psSampleState[ 0 ].LF_AR_Q14[ RDmax_ind ] = psSampleState[ 1 ].LF_AR_Q14[ RDmin_ind ]; - psSampleState[ 0 ].Diff_Q14[ RDmax_ind ] = psSampleState[ 1 ].Diff_Q14[ RDmin_ind ]; - psSampleState[ 0 ].sLTP_shp_Q14[ RDmax_ind ] = psSampleState[ 1 ].sLTP_shp_Q14[ RDmin_ind ]; - psSampleState[ 0 ].LPC_exc_Q14[ RDmax_ind ] = psSampleState[ 1 ].LPC_exc_Q14[ RDmin_ind ]; - } - - /* Write samples from winner to output and long-term filter states */ - if( subfr > 0 || i >= decisionDelay ) { - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDelDec->Q_Q10[ last_smple_idx ][ Winner_ind ], 10 ); - xq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( - silk_SMULWW( psDelDec->Xq_Q14[ last_smple_idx ][ Winner_ind ], delayedGain_Q10[ last_smple_idx ] ), 8 ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDelDec->Shape_Q14[ last_smple_idx ][ Winner_ind ]; - sLTP_Q15[ NSQ->sLTP_buf_idx - decisionDelay ] = psDelDec->Pred_Q15[ last_smple_idx ][ Winner_ind ]; - } - NSQ->sLTP_shp_buf_idx++; - NSQ->sLTP_buf_idx++; - - /* Update states */ - vst1q_s32( psDelDec->LF_AR_Q14, vld1q_s32( psSampleState[ 0 ].LF_AR_Q14 ) ); - vst1q_s32( psDelDec->Diff_Q14, vld1q_s32( psSampleState[ 0 ].Diff_Q14 ) ); - vst1q_s32( psDelDec->sLPC_Q14[ NSQ_LPC_BUF_LENGTH + i ], vld1q_s32( psSampleState[ 0 ].xq_Q14 ) ); - vst1q_s32( psDelDec->Xq_Q14[ *smpl_buf_idx ], vld1q_s32( psSampleState[ 0 ].xq_Q14 ) ); - tmp1_s32x4 = vld1q_s32( psSampleState[ 0 ].Q_Q10 ); - vst1q_s32( psDelDec->Q_Q10[ *smpl_buf_idx ], tmp1_s32x4 ); - vst1q_s32( psDelDec->Pred_Q15[ *smpl_buf_idx ], vshlq_n_s32( vld1q_s32( psSampleState[ 0 ].LPC_exc_Q14 ), 1 ) ); - vst1q_s32( psDelDec->Shape_Q14[ *smpl_buf_idx ], vld1q_s32( psSampleState[ 0 ].sLTP_shp_Q14 ) ); - tmp1_s32x4 = vrshrq_n_s32( tmp1_s32x4, 10 ); - tmp1_s32x4 = vaddq_s32( vld1q_s32( psDelDec->Seed ), tmp1_s32x4 ); - vst1q_s32( psDelDec->Seed, tmp1_s32x4 ); - vst1q_s32( psDelDec->RandState[ *smpl_buf_idx ], tmp1_s32x4 ); - vst1q_s32( psDelDec->RD_Q10, vld1q_s32( psSampleState[ 0 ].RD_Q10 ) ); - delayedGain_Q10[ *smpl_buf_idx ] = Gain_Q10; - } - /* Update LPC states */ - silk_memcpy( psDelDec->sLPC_Q14[ 0 ], psDelDec->sLPC_Q14[ length ], NEON_MAX_DEL_DEC_STATES * NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); - - RESTORE_STACK; -} - -static OPUS_INLINE void silk_SMULWB_8_neon( - const opus_int16 *a, - const int32x2_t b, - opus_int32 *o -) -{ - const int16x8_t a_s16x8 = vld1q_s16( a ); - int32x4_t o0_s32x4, o1_s32x4; - - o0_s32x4 = vshll_n_s16( vget_low_s16( a_s16x8 ), 15 ); - o1_s32x4 = vshll_n_s16( vget_high_s16( a_s16x8 ), 15 ); - o0_s32x4 = vqdmulhq_lane_s32( o0_s32x4, b, 0 ); - o1_s32x4 = vqdmulhq_lane_s32( o1_s32x4, b, 0 ); - vst1q_s32( o, o0_s32x4 ); - vst1q_s32( o + 4, o1_s32x4 ); -} - -/* Only works when ( b >= -65536 ) && ( b < 65536 ). */ -static OPUS_INLINE void silk_SMULWW_small_b_4_neon( - opus_int32 *a, - const int32x2_t b_s32x2) -{ - int32x4_t o_s32x4; - - o_s32x4 = vld1q_s32( a ); - o_s32x4 = vqdmulhq_lane_s32( o_s32x4, b_s32x2, 0 ); - vst1q_s32( a, o_s32x4 ); -} - -/* Only works when ( b >= -65536 ) && ( b < 65536 ). */ -static OPUS_INLINE void silk_SMULWW_small_b_8_neon( - opus_int32 *a, - const int32x2_t b_s32x2 -) -{ - int32x4_t o0_s32x4, o1_s32x4; - - o0_s32x4 = vld1q_s32( a ); - o1_s32x4 = vld1q_s32( a + 4 ); - o0_s32x4 = vqdmulhq_lane_s32( o0_s32x4, b_s32x2, 0 ); - o1_s32x4 = vqdmulhq_lane_s32( o1_s32x4, b_s32x2, 0 ); - vst1q_s32( a, o0_s32x4 ); - vst1q_s32( a + 4, o1_s32x4 ); -} - -static OPUS_INLINE void silk_SMULWW_4_neon( - opus_int32 *a, - const int32x2_t b_s32x2) -{ - int32x4_t a_s32x4, o_s32x4; - - a_s32x4 = vld1q_s32( a ); - o_s32x4 = vqdmulhq_lane_s32( a_s32x4, b_s32x2, 0 ); - o_s32x4 = vmlaq_lane_s32( o_s32x4, a_s32x4, b_s32x2, 1 ); - vst1q_s32( a, o_s32x4 ); -} - -static OPUS_INLINE void silk_SMULWW_8_neon( - opus_int32 *a, - const int32x2_t b_s32x2 -) -{ - int32x4_t a0_s32x4, a1_s32x4, o0_s32x4, o1_s32x4; - - a0_s32x4 = vld1q_s32( a ); - a1_s32x4 = vld1q_s32( a + 4 ); - o0_s32x4 = vqdmulhq_lane_s32( a0_s32x4, b_s32x2, 0 ); - o1_s32x4 = vqdmulhq_lane_s32( a1_s32x4, b_s32x2, 0 ); - o0_s32x4 = vmlaq_lane_s32( o0_s32x4, a0_s32x4, b_s32x2, 1 ); - o1_s32x4 = vmlaq_lane_s32( o1_s32x4, a1_s32x4, b_s32x2, 1 ); - vst1q_s32( a, o0_s32x4 ); - vst1q_s32( a + 4, o1_s32x4 ); -} - -static OPUS_INLINE void silk_SMULWW_loop_neon( - const opus_int16 *a, - const opus_int32 b, - opus_int32 *o, - const opus_int loop_num -) -{ - opus_int i; - int32x2_t b_s32x2; - - b_s32x2 = vdup_n_s32( b ); - for( i = 0; i < loop_num - 7; i += 8 ) { - silk_SMULWB_8_neon( a + i, b_s32x2, o + i ); - } - for( ; i < loop_num; i++ ) { - o[ i ] = silk_SMULWW( a[ i ], b ); - } -} - -static OPUS_INLINE void silk_nsq_del_dec_scale_states_neon( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_decs_struct psDelDec[], /* I/O Delayed decision states */ - const opus_int16 x16[], /* I Input */ - opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ - const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I Subframe number */ - const opus_int LTP_scale_Q14, /* I LTP state scaling */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type, /* I Signal type */ - const opus_int decisionDelay /* I Decision delay */ -) -{ - opus_int i, lag; - opus_int32 gain_adj_Q16, inv_gain_Q31, inv_gain_Q26; - - lag = pitchL[ subfr ]; - inv_gain_Q31 = silk_INVERSE32_varQ( silk_max( Gains_Q16[ subfr ], 1 ), 47 ); - silk_assert( inv_gain_Q31 != 0 ); - - /* Scale input */ - inv_gain_Q26 = silk_RSHIFT_ROUND( inv_gain_Q31, 5 ); - silk_SMULWW_loop_neon( x16, inv_gain_Q26, x_sc_Q10, psEncC->subfr_length ); - - /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */ - if( NSQ->rewhite_flag ) { - if( subfr == 0 ) { - /* Do LTP downscaling */ - inv_gain_Q31 = silk_LSHIFT( silk_SMULWB( inv_gain_Q31, LTP_scale_Q14 ), 2 ); - } - silk_SMULWW_loop_neon( sLTP + NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2, inv_gain_Q31, sLTP_Q15 + NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2, lag + LTP_ORDER / 2 ); - } - - /* Adjust for changing gain */ - if( Gains_Q16[ subfr ] != NSQ->prev_gain_Q16 ) { - int32x2_t gain_adj_Q16_s32x2; - gain_adj_Q16 = silk_DIV32_varQ( NSQ->prev_gain_Q16, Gains_Q16[ subfr ], 16 ); - - /* Scale long-term shaping state */ - if( ( gain_adj_Q16 >= -65536 ) && ( gain_adj_Q16 < 65536 ) ) { - gain_adj_Q16_s32x2 = vdup_n_s32( silk_LSHIFT32( gain_adj_Q16, 15 ) ); - for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx - 7; i += 8 ) { - silk_SMULWW_small_b_8_neon( NSQ->sLTP_shp_Q14 + i, gain_adj_Q16_s32x2 ); - } - for( ; i < NSQ->sLTP_shp_buf_idx; i++ ) { - NSQ->sLTP_shp_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q14[ i ] ); - } - - /* Scale long-term prediction state */ - if( signal_type == TYPE_VOICED && NSQ->rewhite_flag == 0 ) { - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx - decisionDelay - 7; i += 8 ) { - silk_SMULWW_small_b_8_neon( sLTP_Q15 + i, gain_adj_Q16_s32x2 ); - } - for( ; i < NSQ->sLTP_buf_idx - decisionDelay; i++ ) { - sLTP_Q15[ i ] = silk_SMULWW( gain_adj_Q16, sLTP_Q15[ i ] ); - } - } - - /* Scale scalar states */ - silk_SMULWW_small_b_4_neon( psDelDec->LF_AR_Q14, gain_adj_Q16_s32x2 ); - silk_SMULWW_small_b_4_neon( psDelDec->Diff_Q14, gain_adj_Q16_s32x2 ); - - /* Scale short-term prediction and shaping states */ - for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { - silk_SMULWW_small_b_4_neon( psDelDec->sLPC_Q14[ i ], gain_adj_Q16_s32x2 ); - } - - for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { - silk_SMULWW_small_b_4_neon( psDelDec->sAR2_Q14[ i ], gain_adj_Q16_s32x2 ); - } - - for( i = 0; i < DECISION_DELAY; i++ ) { - silk_SMULWW_small_b_4_neon( psDelDec->Pred_Q15[ i ], gain_adj_Q16_s32x2 ); - silk_SMULWW_small_b_4_neon( psDelDec->Shape_Q14[ i ], gain_adj_Q16_s32x2 ); - } - } else { - gain_adj_Q16_s32x2 = vdup_n_s32( silk_LSHIFT32( gain_adj_Q16 & 0x0000FFFF, 15 ) ); - gain_adj_Q16_s32x2 = vset_lane_s32( gain_adj_Q16 >> 16, gain_adj_Q16_s32x2, 1 ); - for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx - 7; i += 8 ) { - silk_SMULWW_8_neon( NSQ->sLTP_shp_Q14 + i, gain_adj_Q16_s32x2 ); - } - for( ; i < NSQ->sLTP_shp_buf_idx; i++ ) { - NSQ->sLTP_shp_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q14[ i ] ); - } - - /* Scale long-term prediction state */ - if( signal_type == TYPE_VOICED && NSQ->rewhite_flag == 0 ) { - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx - decisionDelay - 7; i += 8 ) { - silk_SMULWW_8_neon( sLTP_Q15 + i, gain_adj_Q16_s32x2 ); - } - for( ; i < NSQ->sLTP_buf_idx - decisionDelay; i++ ) { - sLTP_Q15[ i ] = silk_SMULWW( gain_adj_Q16, sLTP_Q15[ i ] ); - } - } - - /* Scale scalar states */ - silk_SMULWW_4_neon( psDelDec->LF_AR_Q14, gain_adj_Q16_s32x2 ); - silk_SMULWW_4_neon( psDelDec->Diff_Q14, gain_adj_Q16_s32x2 ); - - /* Scale short-term prediction and shaping states */ - for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { - silk_SMULWW_4_neon( psDelDec->sLPC_Q14[ i ], gain_adj_Q16_s32x2 ); - } - - for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { - silk_SMULWW_4_neon( psDelDec->sAR2_Q14[ i ], gain_adj_Q16_s32x2 ); - } - - for( i = 0; i < DECISION_DELAY; i++ ) { - silk_SMULWW_4_neon( psDelDec->Pred_Q15[ i ], gain_adj_Q16_s32x2 ); - silk_SMULWW_4_neon( psDelDec->Shape_Q14[ i ], gain_adj_Q16_s32x2 ); - } - } - - /* Save inverse gain */ - NSQ->prev_gain_Q16 = Gains_Q16[ subfr ]; - } -} diff --git a/Engine/lib/opus/silk/arm/NSQ_neon.c b/Engine/lib/opus/silk/arm/NSQ_neon.c deleted file mode 100644 index 964252997..000000000 --- a/Engine/lib/opus/silk/arm/NSQ_neon.c +++ /dev/null @@ -1,112 +0,0 @@ -/*********************************************************************** -Copyright (C) 2014 Vidyo -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" -#endif - -#include -#include "main.h" -#include "stack_alloc.h" -#include "NSQ.h" -#include "celt/cpu_support.h" -#include "celt/arm/armcpu.h" - -opus_int32 silk_noise_shape_quantizer_short_prediction_neon(const opus_int32 *buf32, const opus_int32 *coef32, opus_int order) -{ - int32x4_t coef0 = vld1q_s32(coef32); - int32x4_t coef1 = vld1q_s32(coef32 + 4); - int32x4_t coef2 = vld1q_s32(coef32 + 8); - int32x4_t coef3 = vld1q_s32(coef32 + 12); - - int32x4_t a0 = vld1q_s32(buf32 - 15); - int32x4_t a1 = vld1q_s32(buf32 - 11); - int32x4_t a2 = vld1q_s32(buf32 - 7); - int32x4_t a3 = vld1q_s32(buf32 - 3); - - int32x4_t b0 = vqdmulhq_s32(coef0, a0); - int32x4_t b1 = vqdmulhq_s32(coef1, a1); - int32x4_t b2 = vqdmulhq_s32(coef2, a2); - int32x4_t b3 = vqdmulhq_s32(coef3, a3); - - int32x4_t c0 = vaddq_s32(b0, b1); - int32x4_t c1 = vaddq_s32(b2, b3); - - int32x4_t d = vaddq_s32(c0, c1); - - int64x2_t e = vpaddlq_s32(d); - - int64x1_t f = vadd_s64(vget_low_s64(e), vget_high_s64(e)); - - opus_int32 out = vget_lane_s32(vreinterpret_s32_s64(f), 0); - - out += silk_RSHIFT( order, 1 ); - - return out; -} - - -opus_int32 silk_NSQ_noise_shape_feedback_loop_neon(const opus_int32 *data0, opus_int32 *data1, const opus_int16 *coef, opus_int order) -{ - opus_int32 out; - if (order == 8) - { - int32x4_t a00 = vdupq_n_s32(data0[0]); - int32x4_t a01 = vld1q_s32(data1); /* data1[0] ... [3] */ - - int32x4_t a0 = vextq_s32 (a00, a01, 3); /* data0[0] data1[0] ...[2] */ - int32x4_t a1 = vld1q_s32(data1 + 3); /* data1[3] ... [6] */ - - /*TODO: Convert these once in advance instead of once per sample, like - silk_noise_shape_quantizer_short_prediction_neon() does.*/ - int16x8_t coef16 = vld1q_s16(coef); - int32x4_t coef0 = vmovl_s16(vget_low_s16(coef16)); - int32x4_t coef1 = vmovl_s16(vget_high_s16(coef16)); - - /*This is not bit-exact with the C version, since we do not drop the - lower 16 bits of each multiply, but wait until the end to truncate - precision. This is an encoder-specific calculation (and unlike - silk_noise_shape_quantizer_short_prediction_neon(), is not meant to - simulate what the decoder will do). We still could use vqdmulhq_s32() - like silk_noise_shape_quantizer_short_prediction_neon() and save - half the multiplies, but the speed difference is not large, since we - then need two extra adds.*/ - int64x2_t b0 = vmull_s32(vget_low_s32(a0), vget_low_s32(coef0)); - int64x2_t b1 = vmlal_s32(b0, vget_high_s32(a0), vget_high_s32(coef0)); - int64x2_t b2 = vmlal_s32(b1, vget_low_s32(a1), vget_low_s32(coef1)); - int64x2_t b3 = vmlal_s32(b2, vget_high_s32(a1), vget_high_s32(coef1)); - - int64x1_t c = vadd_s64(vget_low_s64(b3), vget_high_s64(b3)); - int64x1_t cS = vrshr_n_s64(c, 15); - int32x2_t d = vreinterpret_s32_s64(cS); - - out = vget_lane_s32(d, 0); - vst1q_s32(data1, a0); - vst1q_s32(data1 + 4, a1); - return out; - } - return silk_NSQ_noise_shape_feedback_loop_c(data0, data1, coef, order); -} diff --git a/Engine/lib/opus/silk/arm/NSQ_neon.h b/Engine/lib/opus/silk/arm/NSQ_neon.h deleted file mode 100644 index b31d9442d..000000000 --- a/Engine/lib/opus/silk/arm/NSQ_neon.h +++ /dev/null @@ -1,114 +0,0 @@ -/*********************************************************************** -Copyright (C) 2014 Vidyo -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 SILK_NSQ_NEON_H -#define SILK_NSQ_NEON_H - -#include "cpu_support.h" -#include "SigProc_FIX.h" - -#undef silk_short_prediction_create_arch_coef -/* For vectorized calc, reverse a_Q12 coefs, convert to 32-bit, and shift for vqdmulhq_s32. */ -static OPUS_INLINE void silk_short_prediction_create_arch_coef_neon(opus_int32 *out, const opus_int16 *in, opus_int order) -{ - out[15] = silk_LSHIFT32(in[0], 15); - out[14] = silk_LSHIFT32(in[1], 15); - out[13] = silk_LSHIFT32(in[2], 15); - out[12] = silk_LSHIFT32(in[3], 15); - out[11] = silk_LSHIFT32(in[4], 15); - out[10] = silk_LSHIFT32(in[5], 15); - out[9] = silk_LSHIFT32(in[6], 15); - out[8] = silk_LSHIFT32(in[7], 15); - out[7] = silk_LSHIFT32(in[8], 15); - out[6] = silk_LSHIFT32(in[9], 15); - - if (order == 16) - { - out[5] = silk_LSHIFT32(in[10], 15); - out[4] = silk_LSHIFT32(in[11], 15); - out[3] = silk_LSHIFT32(in[12], 15); - out[2] = silk_LSHIFT32(in[13], 15); - out[1] = silk_LSHIFT32(in[14], 15); - out[0] = silk_LSHIFT32(in[15], 15); - } - else - { - out[5] = 0; - out[4] = 0; - out[3] = 0; - out[2] = 0; - out[1] = 0; - out[0] = 0; - } -} - -#if defined(OPUS_ARM_PRESUME_NEON_INTR) - -#define silk_short_prediction_create_arch_coef(out, in, order) \ - (silk_short_prediction_create_arch_coef_neon(out, in, order)) - -#elif defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - -#define silk_short_prediction_create_arch_coef(out, in, order) \ - do { if (arch == OPUS_ARCH_ARM_NEON) { silk_short_prediction_create_arch_coef_neon(out, in, order); } } while (0) - -#endif - -opus_int32 silk_noise_shape_quantizer_short_prediction_neon(const opus_int32 *buf32, const opus_int32 *coef32, opus_int order); - -opus_int32 silk_NSQ_noise_shape_feedback_loop_neon(const opus_int32 *data0, opus_int32 *data1, const opus_int16 *coef, opus_int order); - -#if defined(OPUS_ARM_PRESUME_NEON_INTR) -#undef silk_noise_shape_quantizer_short_prediction -#define silk_noise_shape_quantizer_short_prediction(in, coef, coefRev, order, arch) \ - ((void)arch,silk_noise_shape_quantizer_short_prediction_neon(in, coefRev, order)) - -#undef silk_NSQ_noise_shape_feedback_loop -#define silk_NSQ_noise_shape_feedback_loop(data0, data1, coef, order, arch) ((void)arch,silk_NSQ_noise_shape_feedback_loop_neon(data0, data1, coef, order)) - -#elif defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - -/* silk_noise_shape_quantizer_short_prediction implementations take different parameters based on arch - (coef vs. coefRev) so can't use the usual IMPL table implementation */ -#undef silk_noise_shape_quantizer_short_prediction -#define silk_noise_shape_quantizer_short_prediction(in, coef, coefRev, order, arch) \ - (arch == OPUS_ARCH_ARM_NEON ? \ - silk_noise_shape_quantizer_short_prediction_neon(in, coefRev, order) : \ - silk_noise_shape_quantizer_short_prediction_c(in, coef, order)) - -extern opus_int32 - (*const SILK_NSQ_NOISE_SHAPE_FEEDBACK_LOOP_IMPL[OPUS_ARCHMASK+1])( - const opus_int32 *data0, opus_int32 *data1, const opus_int16 *coef, - opus_int order); - -#undef silk_NSQ_noise_shape_feedback_loop -#define silk_NSQ_noise_shape_feedback_loop(data0, data1, coef, order, arch) \ - (SILK_NSQ_NOISE_SHAPE_FEEDBACK_LOOP_IMPL[(arch)&OPUS_ARCHMASK](data0, data1, \ - coef, order)) - -#endif - -#endif /* SILK_NSQ_NEON_H */ diff --git a/Engine/lib/opus/silk/arm/SigProc_FIX_armv4.h b/Engine/lib/opus/silk/arm/SigProc_FIX_armv4.h deleted file mode 100644 index ff62b1e5d..000000000 --- a/Engine/lib/opus/silk/arm/SigProc_FIX_armv4.h +++ /dev/null @@ -1,47 +0,0 @@ -/*********************************************************************** -Copyright (C) 2013 Xiph.Org Foundation and contributors -Copyright (c) 2013 Parrot -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 SILK_SIGPROC_FIX_ARMv4_H -#define SILK_SIGPROC_FIX_ARMv4_H - -#undef silk_MLA -static OPUS_INLINE opus_int32 silk_MLA_armv4(opus_int32 a, opus_int32 b, - opus_int32 c) -{ - opus_int32 res; - __asm__( - "#silk_MLA\n\t" - "mla %0, %1, %2, %3\n\t" - : "=&r"(res) - : "r"(b), "r"(c), "r"(a) - ); - return res; -} -#define silk_MLA(a, b, c) (silk_MLA_armv4(a, b, c)) - -#endif diff --git a/Engine/lib/opus/silk/arm/SigProc_FIX_armv5e.h b/Engine/lib/opus/silk/arm/SigProc_FIX_armv5e.h deleted file mode 100644 index 617a09cab..000000000 --- a/Engine/lib/opus/silk/arm/SigProc_FIX_armv5e.h +++ /dev/null @@ -1,61 +0,0 @@ -/*********************************************************************** -Copyright (c) 2006-2011, Skype Limited. All rights reserved. -Copyright (c) 2013 Parrot -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 SILK_SIGPROC_FIX_ARMv5E_H -#define SILK_SIGPROC_FIX_ARMv5E_H - -#undef silk_SMULTT -static OPUS_INLINE opus_int32 silk_SMULTT_armv5e(opus_int32 a, opus_int32 b) -{ - opus_int32 res; - __asm__( - "#silk_SMULTT\n\t" - "smultt %0, %1, %2\n\t" - : "=r"(res) - : "%r"(a), "r"(b) - ); - return res; -} -#define silk_SMULTT(a, b) (silk_SMULTT_armv5e(a, b)) - -#undef silk_SMLATT -static OPUS_INLINE opus_int32 silk_SMLATT_armv5e(opus_int32 a, opus_int32 b, - opus_int32 c) -{ - opus_int32 res; - __asm__( - "#silk_SMLATT\n\t" - "smlatt %0, %1, %2, %3\n\t" - : "=r"(res) - : "%r"(b), "r"(c), "r"(a) - ); - return res; -} -#define silk_SMLATT(a, b, c) (silk_SMLATT_armv5e(a, b, c)) - -#endif diff --git a/Engine/lib/opus/silk/arm/arm_silk_map.c b/Engine/lib/opus/silk/arm/arm_silk_map.c deleted file mode 100644 index 0b9bfec2c..000000000 --- a/Engine/lib/opus/silk/arm/arm_silk_map.c +++ /dev/null @@ -1,123 +0,0 @@ -/*********************************************************************** -Copyright (C) 2014 Vidyo -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" -#endif - -#include "main_FIX.h" -#include "NSQ.h" -#include "SigProc_FIX.h" - -#if defined(OPUS_HAVE_RTCD) - -# if (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && \ - !defined(OPUS_ARM_PRESUME_NEON_INTR)) - -void (*const SILK_BIQUAD_ALT_STRIDE2_IMPL[OPUS_ARCHMASK + 1])( - const opus_int16 *in, /* I input signal */ - const opus_int32 *B_Q28, /* I MA coefficients [3] */ - const opus_int32 *A_Q28, /* I AR coefficients [2] */ - opus_int32 *S, /* I/O State vector [4] */ - opus_int16 *out, /* O output signal */ - const opus_int32 len /* I signal length (must be even) */ -) = { - silk_biquad_alt_stride2_c, /* ARMv4 */ - silk_biquad_alt_stride2_c, /* EDSP */ - silk_biquad_alt_stride2_c, /* Media */ - silk_biquad_alt_stride2_neon, /* Neon */ -}; - -opus_int32 (*const SILK_LPC_INVERSE_PRED_GAIN_IMPL[OPUS_ARCHMASK + 1])( /* O Returns inverse prediction gain in energy domain, Q30 */ - const opus_int16 *A_Q12, /* I Prediction coefficients, Q12 [order] */ - const opus_int order /* I Prediction order */ -) = { - silk_LPC_inverse_pred_gain_c, /* ARMv4 */ - silk_LPC_inverse_pred_gain_c, /* EDSP */ - silk_LPC_inverse_pred_gain_c, /* Media */ - silk_LPC_inverse_pred_gain_neon, /* Neon */ -}; - -void (*const SILK_NSQ_DEL_DEC_IMPL[OPUS_ARCHMASK + 1])( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -) = { - silk_NSQ_del_dec_c, /* ARMv4 */ - silk_NSQ_del_dec_c, /* EDSP */ - silk_NSQ_del_dec_c, /* Media */ - silk_NSQ_del_dec_neon, /* Neon */ -}; - -/*There is no table for silk_noise_shape_quantizer_short_prediction because the - NEON version takes different parameters than the C version. - Instead RTCD is done via if statements at the call sites. - See NSQ_neon.h for details.*/ - -opus_int32 - (*const SILK_NSQ_NOISE_SHAPE_FEEDBACK_LOOP_IMPL[OPUS_ARCHMASK+1])( - const opus_int32 *data0, opus_int32 *data1, const opus_int16 *coef, - opus_int order) = { - silk_NSQ_noise_shape_feedback_loop_c, /* ARMv4 */ - silk_NSQ_noise_shape_feedback_loop_c, /* EDSP */ - silk_NSQ_noise_shape_feedback_loop_c, /* Media */ - silk_NSQ_noise_shape_feedback_loop_neon, /* NEON */ -}; - -# endif - -# if defined(FIXED_POINT) && \ - defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR) - -void (*const SILK_WARPED_AUTOCORRELATION_FIX_IMPL[OPUS_ARCHMASK + 1])( - opus_int32 *corr, /* O Result [order + 1] */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *input, /* I Input data to correlate */ - const opus_int warping_Q16, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ -) = { - silk_warped_autocorrelation_FIX_c, /* ARMv4 */ - silk_warped_autocorrelation_FIX_c, /* EDSP */ - silk_warped_autocorrelation_FIX_c, /* Media */ - silk_warped_autocorrelation_FIX_neon, /* Neon */ -}; - -# endif - -#endif /* OPUS_HAVE_RTCD */ diff --git a/Engine/lib/opus/silk/arm/biquad_alt_arm.h b/Engine/lib/opus/silk/arm/biquad_alt_arm.h deleted file mode 100644 index 66ea9f43d..000000000 --- a/Engine/lib/opus/silk/arm/biquad_alt_arm.h +++ /dev/null @@ -1,68 +0,0 @@ -/*********************************************************************** -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. -***********************************************************************/ - -#ifndef SILK_BIQUAD_ALT_ARM_H -# define SILK_BIQUAD_ALT_ARM_H - -# include "celt/arm/armcpu.h" - -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -void silk_biquad_alt_stride2_neon( - const opus_int16 *in, /* I input signal */ - const opus_int32 *B_Q28, /* I MA coefficients [3] */ - const opus_int32 *A_Q28, /* I AR coefficients [2] */ - opus_int32 *S, /* I/O State vector [4] */ - opus_int16 *out, /* O output signal */ - const opus_int32 len /* I signal length (must be even) */ -); - -# if !defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_PRESUME_NEON) -# define OVERRIDE_silk_biquad_alt_stride2 (1) -# define silk_biquad_alt_stride2(in, B_Q28, A_Q28, S, out, len, arch) ((void)(arch), PRESUME_NEON(silk_biquad_alt_stride2)(in, B_Q28, A_Q28, S, out, len)) -# endif -# endif - -# if !defined(OVERRIDE_silk_biquad_alt_stride2) -/*Is run-time CPU detection enabled on this platform?*/ -# if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern void (*const SILK_BIQUAD_ALT_STRIDE2_IMPL[OPUS_ARCHMASK+1])( - const opus_int16 *in, /* I input signal */ - const opus_int32 *B_Q28, /* I MA coefficients [3] */ - const opus_int32 *A_Q28, /* I AR coefficients [2] */ - opus_int32 *S, /* I/O State vector [4] */ - opus_int16 *out, /* O output signal */ - const opus_int32 len /* I signal length (must be even) */ - ); -# define OVERRIDE_silk_biquad_alt_stride2 (1) -# define silk_biquad_alt_stride2(in, B_Q28, A_Q28, S, out, len, arch) ((*SILK_BIQUAD_ALT_STRIDE2_IMPL[(arch)&OPUS_ARCHMASK])(in, B_Q28, A_Q28, S, out, len)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) -# define OVERRIDE_silk_biquad_alt_stride2 (1) -# define silk_biquad_alt_stride2(in, B_Q28, A_Q28, S, out, len, arch) ((void)(arch), silk_biquad_alt_stride2_neon(in, B_Q28, A_Q28, S, out, len)) -# endif -# endif - -#endif /* end SILK_BIQUAD_ALT_ARM_H */ diff --git a/Engine/lib/opus/silk/arm/biquad_alt_neon_intr.c b/Engine/lib/opus/silk/arm/biquad_alt_neon_intr.c deleted file mode 100644 index 971573318..000000000 --- a/Engine/lib/opus/silk/arm/biquad_alt_neon_intr.c +++ /dev/null @@ -1,156 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include -#ifdef OPUS_CHECK_ASM -# include -# include "stack_alloc.h" -#endif -#include "SigProc_FIX.h" - -static inline void silk_biquad_alt_stride2_kernel( const int32x4_t A_L_s32x4, const int32x4_t A_U_s32x4, const int32x4_t B_Q28_s32x4, const int32x2_t t_s32x2, const int32x4_t in_s32x4, int32x4_t *S_s32x4, int32x2_t *out32_Q14_s32x2 ) -{ - int32x4_t t_s32x4, out32_Q14_s32x4; - - *out32_Q14_s32x2 = vadd_s32( vget_low_s32( *S_s32x4 ), t_s32x2 ); /* silk_SMLAWB( S{0,1}, B_Q28[ 0 ], in{0,1} ) */ - *S_s32x4 = vcombine_s32( vget_high_s32( *S_s32x4 ), vdup_n_s32( 0 ) ); /* S{0,1} = S{2,3}; S{2,3} = 0; */ - *out32_Q14_s32x2 = vshl_n_s32( *out32_Q14_s32x2, 2 ); /* out32_Q14_{0,1} = silk_LSHIFT( silk_SMLAWB( S{0,1}, B_Q28[ 0 ], in{0,1} ), 2 ); */ - out32_Q14_s32x4 = vcombine_s32( *out32_Q14_s32x2, *out32_Q14_s32x2 ); /* out32_Q14_{0,1,0,1} */ - t_s32x4 = vqdmulhq_s32( out32_Q14_s32x4, A_L_s32x4 ); /* silk_SMULWB( out32_Q14_{0,1,0,1}, A{0,0,1,1}_L_Q28 ) */ - *S_s32x4 = vrsraq_n_s32( *S_s32x4, t_s32x4, 14 ); /* S{0,1} = S{2,3} + silk_RSHIFT_ROUND(); S{2,3} = silk_RSHIFT_ROUND(); */ - t_s32x4 = vqdmulhq_s32( out32_Q14_s32x4, A_U_s32x4 ); /* silk_SMULWB( out32_Q14_{0,1,0,1}, A{0,0,1,1}_U_Q28 ) */ - *S_s32x4 = vaddq_s32( *S_s32x4, t_s32x4 ); /* S0 = silk_SMLAWB( S{0,1,2,3}, out32_Q14_{0,1,0,1}, A{0,0,1,1}_U_Q28 ); */ - t_s32x4 = vqdmulhq_s32( in_s32x4, B_Q28_s32x4 ); /* silk_SMULWB( B_Q28[ {1,1,2,2} ], in{0,1,0,1} ) */ - *S_s32x4 = vaddq_s32( *S_s32x4, t_s32x4 ); /* S0 = silk_SMLAWB( S0, B_Q28[ {1,1,2,2} ], in{0,1,0,1} ); */ -} - -void silk_biquad_alt_stride2_neon( - const opus_int16 *in, /* I input signal */ - const opus_int32 *B_Q28, /* I MA coefficients [3] */ - const opus_int32 *A_Q28, /* I AR coefficients [2] */ - opus_int32 *S, /* I/O State vector [4] */ - opus_int16 *out, /* O output signal */ - const opus_int32 len /* I signal length (must be even) */ -) -{ - /* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */ - opus_int k = 0; - const int32x2_t offset_s32x2 = vdup_n_s32( (1<<14) - 1 ); - const int32x4_t offset_s32x4 = vcombine_s32( offset_s32x2, offset_s32x2 ); - int16x4_t in_s16x4 = vdup_n_s16( 0 ); - int16x4_t out_s16x4; - int32x2_t A_Q28_s32x2, A_L_s32x2, A_U_s32x2, B_Q28_s32x2, t_s32x2; - int32x4_t A_L_s32x4, A_U_s32x4, B_Q28_s32x4, S_s32x4, out32_Q14_s32x4; - int32x2x2_t t0_s32x2x2, t1_s32x2x2, t2_s32x2x2, S_s32x2x2; - -#ifdef OPUS_CHECK_ASM - opus_int32 S_c[ 4 ]; - VARDECL( opus_int16, out_c ); - SAVE_STACK; - ALLOC( out_c, 2 * len, opus_int16 ); - - silk_memcpy( &S_c, S, sizeof( S_c ) ); - silk_biquad_alt_stride2_c( in, B_Q28, A_Q28, S_c, out_c, len ); -#endif - - /* Negate A_Q28 values and split in two parts */ - A_Q28_s32x2 = vld1_s32( A_Q28 ); - A_Q28_s32x2 = vneg_s32( A_Q28_s32x2 ); - A_L_s32x2 = vshl_n_s32( A_Q28_s32x2, 18 ); /* ( -A_Q28[] & 0x00003FFF ) << 18 */ - A_L_s32x2 = vreinterpret_s32_u32( vshr_n_u32( vreinterpret_u32_s32( A_L_s32x2 ), 3 ) ); /* ( -A_Q28[] & 0x00003FFF ) << 15 */ - A_U_s32x2 = vshr_n_s32( A_Q28_s32x2, 14 ); /* silk_RSHIFT( -A_Q28[], 14 ) */ - A_U_s32x2 = vshl_n_s32( A_U_s32x2, 16 ); /* silk_RSHIFT( -A_Q28[], 14 ) << 16 (Clip two leading bits to conform to C function.) */ - A_U_s32x2 = vshr_n_s32( A_U_s32x2, 1 ); /* silk_RSHIFT( -A_Q28[], 14 ) << 15 */ - - B_Q28_s32x2 = vld1_s32( B_Q28 ); - t_s32x2 = vld1_s32( B_Q28 + 1 ); - t0_s32x2x2 = vzip_s32( A_L_s32x2, A_L_s32x2 ); - t1_s32x2x2 = vzip_s32( A_U_s32x2, A_U_s32x2 ); - t2_s32x2x2 = vzip_s32( t_s32x2, t_s32x2 ); - A_L_s32x4 = vcombine_s32( t0_s32x2x2.val[ 0 ], t0_s32x2x2.val[ 1 ] ); /* A{0,0,1,1}_L_Q28 */ - A_U_s32x4 = vcombine_s32( t1_s32x2x2.val[ 0 ], t1_s32x2x2.val[ 1 ] ); /* A{0,0,1,1}_U_Q28 */ - B_Q28_s32x4 = vcombine_s32( t2_s32x2x2.val[ 0 ], t2_s32x2x2.val[ 1 ] ); /* B_Q28[ {1,1,2,2} ] */ - S_s32x4 = vld1q_s32( S ); /* S0 = S[ 0 ]; S3 = S[ 3 ]; */ - S_s32x2x2 = vtrn_s32( vget_low_s32( S_s32x4 ), vget_high_s32( S_s32x4 ) ); /* S2 = S[ 1 ]; S1 = S[ 2 ]; */ - S_s32x4 = vcombine_s32( S_s32x2x2.val[ 0 ], S_s32x2x2.val[ 1 ] ); - - for( ; k < len - 1; k += 2 ) { - int32x4_t in_s32x4[ 2 ], t_s32x4; - int32x2_t out32_Q14_s32x2[ 2 ]; - - /* S[ 2 * i + 0 ], S[ 2 * i + 1 ], S[ 2 * i + 2 ], S[ 2 * i + 3 ]: Q12 */ - in_s16x4 = vld1_s16( &in[ 2 * k ] ); /* in{0,1,2,3} = in[ 2 * k + {0,1,2,3} ]; */ - in_s32x4[ 0 ] = vshll_n_s16( in_s16x4, 15 ); /* in{0,1,2,3} << 15 */ - t_s32x4 = vqdmulhq_lane_s32( in_s32x4[ 0 ], B_Q28_s32x2, 0 ); /* silk_SMULWB( B_Q28[ 0 ], in{0,1,2,3} ) */ - in_s32x4[ 1 ] = vcombine_s32( vget_high_s32( in_s32x4[ 0 ] ), vget_high_s32( in_s32x4[ 0 ] ) ); /* in{2,3,2,3} << 15 */ - in_s32x4[ 0 ] = vcombine_s32( vget_low_s32 ( in_s32x4[ 0 ] ), vget_low_s32 ( in_s32x4[ 0 ] ) ); /* in{0,1,0,1} << 15 */ - silk_biquad_alt_stride2_kernel( A_L_s32x4, A_U_s32x4, B_Q28_s32x4, vget_low_s32 ( t_s32x4 ), in_s32x4[ 0 ], &S_s32x4, &out32_Q14_s32x2[ 0 ] ); - silk_biquad_alt_stride2_kernel( A_L_s32x4, A_U_s32x4, B_Q28_s32x4, vget_high_s32( t_s32x4 ), in_s32x4[ 1 ], &S_s32x4, &out32_Q14_s32x2[ 1 ] ); - - /* Scale back to Q0 and saturate */ - out32_Q14_s32x4 = vcombine_s32( out32_Q14_s32x2[ 0 ], out32_Q14_s32x2[ 1 ] ); /* out32_Q14_{0,1,2,3} */ - out32_Q14_s32x4 = vaddq_s32( out32_Q14_s32x4, offset_s32x4 ); /* out32_Q14_{0,1,2,3} + (1<<14) - 1 */ - out_s16x4 = vqshrn_n_s32( out32_Q14_s32x4, 14 ); /* (opus_int16)silk_SAT16( silk_RSHIFT( out32_Q14_{0,1,2,3} + (1<<14) - 1, 14 ) ) */ - vst1_s16( &out[ 2 * k ], out_s16x4 ); /* out[ 2 * k + {0,1,2,3} ] = (opus_int16)silk_SAT16( silk_RSHIFT( out32_Q14_{0,1,2,3} + (1<<14) - 1, 14 ) ); */ - } - - /* Process leftover. */ - if( k < len ) { - int32x4_t in_s32x4; - int32x2_t out32_Q14_s32x2; - - /* S[ 2 * i + 0 ], S[ 2 * i + 1 ]: Q12 */ - in_s16x4 = vld1_lane_s16( &in[ 2 * k + 0 ], in_s16x4, 0 ); /* in{0,1} = in[ 2 * k + {0,1} ]; */ - in_s16x4 = vld1_lane_s16( &in[ 2 * k + 1 ], in_s16x4, 1 ); /* in{0,1} = in[ 2 * k + {0,1} ]; */ - in_s32x4 = vshll_n_s16( in_s16x4, 15 ); /* in{0,1} << 15 */ - t_s32x2 = vqdmulh_lane_s32( vget_low_s32( in_s32x4 ), B_Q28_s32x2, 0 ); /* silk_SMULWB( B_Q28[ 0 ], in{0,1} ) */ - in_s32x4 = vcombine_s32( vget_low_s32( in_s32x4 ), vget_low_s32( in_s32x4 ) ); /* in{0,1,0,1} << 15 */ - silk_biquad_alt_stride2_kernel( A_L_s32x4, A_U_s32x4, B_Q28_s32x4, t_s32x2, in_s32x4, &S_s32x4, &out32_Q14_s32x2 ); - - /* Scale back to Q0 and saturate */ - out32_Q14_s32x2 = vadd_s32( out32_Q14_s32x2, offset_s32x2 ); /* out32_Q14_{0,1} + (1<<14) - 1 */ - out32_Q14_s32x4 = vcombine_s32( out32_Q14_s32x2, out32_Q14_s32x2 ); /* out32_Q14_{0,1,0,1} + (1<<14) - 1 */ - out_s16x4 = vqshrn_n_s32( out32_Q14_s32x4, 14 ); /* (opus_int16)silk_SAT16( silk_RSHIFT( out32_Q14_{0,1,0,1} + (1<<14) - 1, 14 ) ) */ - vst1_lane_s16( &out[ 2 * k + 0 ], out_s16x4, 0 ); /* out[ 2 * k + 0 ] = (opus_int16)silk_SAT16( silk_RSHIFT( out32_Q14_0 + (1<<14) - 1, 14 ) ); */ - vst1_lane_s16( &out[ 2 * k + 1 ], out_s16x4, 1 ); /* out[ 2 * k + 1 ] = (opus_int16)silk_SAT16( silk_RSHIFT( out32_Q14_1 + (1<<14) - 1, 14 ) ); */ - } - - vst1q_lane_s32( &S[ 0 ], S_s32x4, 0 ); /* S[ 0 ] = S0; */ - vst1q_lane_s32( &S[ 1 ], S_s32x4, 2 ); /* S[ 1 ] = S2; */ - vst1q_lane_s32( &S[ 2 ], S_s32x4, 1 ); /* S[ 2 ] = S1; */ - vst1q_lane_s32( &S[ 3 ], S_s32x4, 3 ); /* S[ 3 ] = S3; */ - -#ifdef OPUS_CHECK_ASM - silk_assert( !memcmp( S_c, S, sizeof( S_c ) ) ); - silk_assert( !memcmp( out_c, out, 2 * len * sizeof( opus_int16 ) ) ); - RESTORE_STACK; -#endif -} diff --git a/Engine/lib/opus/silk/arm/macros_arm64.h b/Engine/lib/opus/silk/arm/macros_arm64.h deleted file mode 100644 index ed030413c..000000000 --- a/Engine/lib/opus/silk/arm/macros_arm64.h +++ /dev/null @@ -1,39 +0,0 @@ -/*********************************************************************** -Copyright (C) 2015 Vidyo -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 SILK_MACROS_ARM64_H -#define SILK_MACROS_ARM64_H - -#include - -#undef silk_ADD_SAT32 -#define silk_ADD_SAT32(a, b) (vqadds_s32((a), (b))) - -#undef silk_SUB_SAT32 -#define silk_SUB_SAT32(a, b) (vqsubs_s32((a), (b))) - -#endif /* SILK_MACROS_ARM64_H */ diff --git a/Engine/lib/opus/silk/arm/macros_armv4.h b/Engine/lib/opus/silk/arm/macros_armv4.h deleted file mode 100644 index 877eb18dd..000000000 --- a/Engine/lib/opus/silk/arm/macros_armv4.h +++ /dev/null @@ -1,110 +0,0 @@ -/*********************************************************************** -Copyright (C) 2013 Xiph.Org Foundation and contributors. -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 SILK_MACROS_ARMv4_H -#define SILK_MACROS_ARMv4_H - -/* This macro only avoids the undefined behaviour from a left shift of - a negative value. It should only be used in macros that can't include - SigProc_FIX.h. In other cases, use silk_LSHIFT32(). */ -#define SAFE_SHL(a,b) ((opus_int32)((opus_uint32)(a) << (b))) - -/* (a32 * (opus_int32)((opus_int16)(b32))) >> 16 output have to be 32bit int */ -#undef silk_SMULWB -static OPUS_INLINE opus_int32 silk_SMULWB_armv4(opus_int32 a, opus_int16 b) -{ - unsigned rd_lo; - int rd_hi; - __asm__( - "#silk_SMULWB\n\t" - "smull %0, %1, %2, %3\n\t" - : "=&r"(rd_lo), "=&r"(rd_hi) - : "%r"(a), "r"(SAFE_SHL(b,16)) - ); - return rd_hi; -} -#define silk_SMULWB(a, b) (silk_SMULWB_armv4(a, b)) - -/* a32 + (b32 * (opus_int32)((opus_int16)(c32))) >> 16 output have to be 32bit int */ -#undef silk_SMLAWB -#define silk_SMLAWB(a, b, c) ((a) + silk_SMULWB(b, c)) - -/* (a32 * (b32 >> 16)) >> 16 */ -#undef silk_SMULWT -static OPUS_INLINE opus_int32 silk_SMULWT_armv4(opus_int32 a, opus_int32 b) -{ - unsigned rd_lo; - int rd_hi; - __asm__( - "#silk_SMULWT\n\t" - "smull %0, %1, %2, %3\n\t" - : "=&r"(rd_lo), "=&r"(rd_hi) - : "%r"(a), "r"(b&~0xFFFF) - ); - return rd_hi; -} -#define silk_SMULWT(a, b) (silk_SMULWT_armv4(a, b)) - -/* a32 + (b32 * (c32 >> 16)) >> 16 */ -#undef silk_SMLAWT -#define silk_SMLAWT(a, b, c) ((a) + silk_SMULWT(b, c)) - -/* (a32 * b32) >> 16 */ -#undef silk_SMULWW -static OPUS_INLINE opus_int32 silk_SMULWW_armv4(opus_int32 a, opus_int32 b) -{ - unsigned rd_lo; - int rd_hi; - __asm__( - "#silk_SMULWW\n\t" - "smull %0, %1, %2, %3\n\t" - : "=&r"(rd_lo), "=&r"(rd_hi) - : "%r"(a), "r"(b) - ); - return SAFE_SHL(rd_hi,16)+(rd_lo>>16); -} -#define silk_SMULWW(a, b) (silk_SMULWW_armv4(a, b)) - -#undef silk_SMLAWW -static OPUS_INLINE opus_int32 silk_SMLAWW_armv4(opus_int32 a, opus_int32 b, - opus_int32 c) -{ - unsigned rd_lo; - int rd_hi; - __asm__( - "#silk_SMLAWW\n\t" - "smull %0, %1, %2, %3\n\t" - : "=&r"(rd_lo), "=&r"(rd_hi) - : "%r"(b), "r"(c) - ); - return a+SAFE_SHL(rd_hi,16)+(rd_lo>>16); -} -#define silk_SMLAWW(a, b, c) (silk_SMLAWW_armv4(a, b, c)) - -#undef SAFE_SHL - -#endif /* SILK_MACROS_ARMv4_H */ diff --git a/Engine/lib/opus/silk/arm/macros_armv5e.h b/Engine/lib/opus/silk/arm/macros_armv5e.h deleted file mode 100644 index b14ec65dd..000000000 --- a/Engine/lib/opus/silk/arm/macros_armv5e.h +++ /dev/null @@ -1,220 +0,0 @@ -/*********************************************************************** -Copyright (c) 2006-2011, Skype Limited. All rights reserved. -Copyright (c) 2013 Parrot -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 SILK_MACROS_ARMv5E_H -#define SILK_MACROS_ARMv5E_H - -/* This macro only avoids the undefined behaviour from a left shift of - a negative value. It should only be used in macros that can't include - SigProc_FIX.h. In other cases, use silk_LSHIFT32(). */ -#define SAFE_SHL(a,b) ((opus_int32)((opus_uint32)(a) << (b))) - -/* (a32 * (opus_int32)((opus_int16)(b32))) >> 16 output have to be 32bit int */ -#undef silk_SMULWB -static OPUS_INLINE opus_int32 silk_SMULWB_armv5e(opus_int32 a, opus_int16 b) -{ - int res; - __asm__( - "#silk_SMULWB\n\t" - "smulwb %0, %1, %2\n\t" - : "=r"(res) - : "r"(a), "r"(b) - ); - return res; -} -#define silk_SMULWB(a, b) (silk_SMULWB_armv5e(a, b)) - -/* a32 + (b32 * (opus_int32)((opus_int16)(c32))) >> 16 output have to be 32bit int */ -#undef silk_SMLAWB -static OPUS_INLINE opus_int32 silk_SMLAWB_armv5e(opus_int32 a, opus_int32 b, - opus_int16 c) -{ - int res; - __asm__( - "#silk_SMLAWB\n\t" - "smlawb %0, %1, %2, %3\n\t" - : "=r"(res) - : "r"(b), "r"(c), "r"(a) - ); - return res; -} -#define silk_SMLAWB(a, b, c) (silk_SMLAWB_armv5e(a, b, c)) - -/* (a32 * (b32 >> 16)) >> 16 */ -#undef silk_SMULWT -static OPUS_INLINE opus_int32 silk_SMULWT_armv5e(opus_int32 a, opus_int32 b) -{ - int res; - __asm__( - "#silk_SMULWT\n\t" - "smulwt %0, %1, %2\n\t" - : "=r"(res) - : "r"(a), "r"(b) - ); - return res; -} -#define silk_SMULWT(a, b) (silk_SMULWT_armv5e(a, b)) - -/* a32 + (b32 * (c32 >> 16)) >> 16 */ -#undef silk_SMLAWT -static OPUS_INLINE opus_int32 silk_SMLAWT_armv5e(opus_int32 a, opus_int32 b, - opus_int32 c) -{ - int res; - __asm__( - "#silk_SMLAWT\n\t" - "smlawt %0, %1, %2, %3\n\t" - : "=r"(res) - : "r"(b), "r"(c), "r"(a) - ); - return res; -} -#define silk_SMLAWT(a, b, c) (silk_SMLAWT_armv5e(a, b, c)) - -/* (opus_int32)((opus_int16)(a3))) * (opus_int32)((opus_int16)(b32)) output have to be 32bit int */ -#undef silk_SMULBB -static OPUS_INLINE opus_int32 silk_SMULBB_armv5e(opus_int32 a, opus_int32 b) -{ - int res; - __asm__( - "#silk_SMULBB\n\t" - "smulbb %0, %1, %2\n\t" - : "=r"(res) - : "%r"(a), "r"(b) - ); - return res; -} -#define silk_SMULBB(a, b) (silk_SMULBB_armv5e(a, b)) - -/* a32 + (opus_int32)((opus_int16)(b32)) * (opus_int32)((opus_int16)(c32)) output have to be 32bit int */ -#undef silk_SMLABB -static OPUS_INLINE opus_int32 silk_SMLABB_armv5e(opus_int32 a, opus_int32 b, - opus_int32 c) -{ - int res; - __asm__( - "#silk_SMLABB\n\t" - "smlabb %0, %1, %2, %3\n\t" - : "=r"(res) - : "%r"(b), "r"(c), "r"(a) - ); - return res; -} -#define silk_SMLABB(a, b, c) (silk_SMLABB_armv5e(a, b, c)) - -/* (opus_int32)((opus_int16)(a32)) * (b32 >> 16) */ -#undef silk_SMULBT -static OPUS_INLINE opus_int32 silk_SMULBT_armv5e(opus_int32 a, opus_int32 b) -{ - int res; - __asm__( - "#silk_SMULBT\n\t" - "smulbt %0, %1, %2\n\t" - : "=r"(res) - : "r"(a), "r"(b) - ); - return res; -} -#define silk_SMULBT(a, b) (silk_SMULBT_armv5e(a, b)) - -/* a32 + (opus_int32)((opus_int16)(b32)) * (c32 >> 16) */ -#undef silk_SMLABT -static OPUS_INLINE opus_int32 silk_SMLABT_armv5e(opus_int32 a, opus_int32 b, - opus_int32 c) -{ - int res; - __asm__( - "#silk_SMLABT\n\t" - "smlabt %0, %1, %2, %3\n\t" - : "=r"(res) - : "r"(b), "r"(c), "r"(a) - ); - return res; -} -#define silk_SMLABT(a, b, c) (silk_SMLABT_armv5e(a, b, c)) - -/* add/subtract with output saturated */ -#undef silk_ADD_SAT32 -static OPUS_INLINE opus_int32 silk_ADD_SAT32_armv5e(opus_int32 a, opus_int32 b) -{ - int res; - __asm__( - "#silk_ADD_SAT32\n\t" - "qadd %0, %1, %2\n\t" - : "=r"(res) - : "%r"(a), "r"(b) - ); - return res; -} -#define silk_ADD_SAT32(a, b) (silk_ADD_SAT32_armv5e(a, b)) - -#undef silk_SUB_SAT32 -static OPUS_INLINE opus_int32 silk_SUB_SAT32_armv5e(opus_int32 a, opus_int32 b) -{ - int res; - __asm__( - "#silk_SUB_SAT32\n\t" - "qsub %0, %1, %2\n\t" - : "=r"(res) - : "r"(a), "r"(b) - ); - return res; -} -#define silk_SUB_SAT32(a, b) (silk_SUB_SAT32_armv5e(a, b)) - -#undef silk_CLZ16 -static OPUS_INLINE opus_int32 silk_CLZ16_armv5(opus_int16 in16) -{ - int res; - __asm__( - "#silk_CLZ16\n\t" - "clz %0, %1;\n" - : "=r"(res) - : "r"(SAFE_SHL(in16,16)|0x8000) - ); - return res; -} -#define silk_CLZ16(in16) (silk_CLZ16_armv5(in16)) - -#undef silk_CLZ32 -static OPUS_INLINE opus_int32 silk_CLZ32_armv5(opus_int32 in32) -{ - int res; - __asm__( - "#silk_CLZ32\n\t" - "clz %0, %1\n\t" - : "=r"(res) - : "r"(in32) - ); - return res; -} -#define silk_CLZ32(in32) (silk_CLZ32_armv5(in32)) - -#undef SAFE_SHL - -#endif /* SILK_MACROS_ARMv5E_H */ diff --git a/Engine/lib/opus/silk/biquad_alt.c b/Engine/lib/opus/silk/biquad_alt.c deleted file mode 100644 index 54566a43c..000000000 --- a/Engine/lib/opus/silk/biquad_alt.c +++ /dev/null @@ -1,121 +0,0 @@ -/*********************************************************************** -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. -***********************************************************************/ - -/* * - * silk_biquad_alt.c * - * * - * Second order ARMA filter * - * Can handle slowly varying filter coefficients * - * */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "SigProc_FIX.h" - -/* Second order ARMA filter, alternative implementation */ -void silk_biquad_alt_stride1( - const opus_int16 *in, /* I input signal */ - const opus_int32 *B_Q28, /* I MA coefficients [3] */ - const opus_int32 *A_Q28, /* I AR coefficients [2] */ - opus_int32 *S, /* I/O State vector [2] */ - opus_int16 *out, /* O output signal */ - const opus_int32 len /* I signal length (must be even) */ -) -{ - /* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */ - opus_int k; - opus_int32 inval, A0_U_Q28, A0_L_Q28, A1_U_Q28, A1_L_Q28, out32_Q14; - - /* Negate A_Q28 values and split in two parts */ - A0_L_Q28 = ( -A_Q28[ 0 ] ) & 0x00003FFF; /* lower part */ - A0_U_Q28 = silk_RSHIFT( -A_Q28[ 0 ], 14 ); /* upper part */ - A1_L_Q28 = ( -A_Q28[ 1 ] ) & 0x00003FFF; /* lower part */ - A1_U_Q28 = silk_RSHIFT( -A_Q28[ 1 ], 14 ); /* upper part */ - - for( k = 0; k < len; k++ ) { - /* S[ 0 ], S[ 1 ]: Q12 */ - inval = in[ k ]; - out32_Q14 = silk_LSHIFT( silk_SMLAWB( S[ 0 ], B_Q28[ 0 ], inval ), 2 ); - - S[ 0 ] = S[1] + silk_RSHIFT_ROUND( silk_SMULWB( out32_Q14, A0_L_Q28 ), 14 ); - S[ 0 ] = silk_SMLAWB( S[ 0 ], out32_Q14, A0_U_Q28 ); - S[ 0 ] = silk_SMLAWB( S[ 0 ], B_Q28[ 1 ], inval); - - S[ 1 ] = silk_RSHIFT_ROUND( silk_SMULWB( out32_Q14, A1_L_Q28 ), 14 ); - S[ 1 ] = silk_SMLAWB( S[ 1 ], out32_Q14, A1_U_Q28 ); - S[ 1 ] = silk_SMLAWB( S[ 1 ], B_Q28[ 2 ], inval ); - - /* Scale back to Q0 and saturate */ - out[ k ] = (opus_int16)silk_SAT16( silk_RSHIFT( out32_Q14 + (1<<14) - 1, 14 ) ); - } -} - -void silk_biquad_alt_stride2_c( - const opus_int16 *in, /* I input signal */ - const opus_int32 *B_Q28, /* I MA coefficients [3] */ - const opus_int32 *A_Q28, /* I AR coefficients [2] */ - opus_int32 *S, /* I/O State vector [4] */ - opus_int16 *out, /* O output signal */ - const opus_int32 len /* I signal length (must be even) */ -) -{ - /* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */ - opus_int k; - opus_int32 A0_U_Q28, A0_L_Q28, A1_U_Q28, A1_L_Q28, out32_Q14[ 2 ]; - - /* Negate A_Q28 values and split in two parts */ - A0_L_Q28 = ( -A_Q28[ 0 ] ) & 0x00003FFF; /* lower part */ - A0_U_Q28 = silk_RSHIFT( -A_Q28[ 0 ], 14 ); /* upper part */ - A1_L_Q28 = ( -A_Q28[ 1 ] ) & 0x00003FFF; /* lower part */ - A1_U_Q28 = silk_RSHIFT( -A_Q28[ 1 ], 14 ); /* upper part */ - - for( k = 0; k < len; k++ ) { - /* S[ 0 ], S[ 1 ], S[ 2 ], S[ 3 ]: Q12 */ - out32_Q14[ 0 ] = silk_LSHIFT( silk_SMLAWB( S[ 0 ], B_Q28[ 0 ], in[ 2 * k + 0 ] ), 2 ); - out32_Q14[ 1 ] = silk_LSHIFT( silk_SMLAWB( S[ 2 ], B_Q28[ 0 ], in[ 2 * k + 1 ] ), 2 ); - - S[ 0 ] = S[ 1 ] + silk_RSHIFT_ROUND( silk_SMULWB( out32_Q14[ 0 ], A0_L_Q28 ), 14 ); - S[ 2 ] = S[ 3 ] + silk_RSHIFT_ROUND( silk_SMULWB( out32_Q14[ 1 ], A0_L_Q28 ), 14 ); - S[ 0 ] = silk_SMLAWB( S[ 0 ], out32_Q14[ 0 ], A0_U_Q28 ); - S[ 2 ] = silk_SMLAWB( S[ 2 ], out32_Q14[ 1 ], A0_U_Q28 ); - S[ 0 ] = silk_SMLAWB( S[ 0 ], B_Q28[ 1 ], in[ 2 * k + 0 ] ); - S[ 2 ] = silk_SMLAWB( S[ 2 ], B_Q28[ 1 ], in[ 2 * k + 1 ] ); - - S[ 1 ] = silk_RSHIFT_ROUND( silk_SMULWB( out32_Q14[ 0 ], A1_L_Q28 ), 14 ); - S[ 3 ] = silk_RSHIFT_ROUND( silk_SMULWB( out32_Q14[ 1 ], A1_L_Q28 ), 14 ); - S[ 1 ] = silk_SMLAWB( S[ 1 ], out32_Q14[ 0 ], A1_U_Q28 ); - S[ 3 ] = silk_SMLAWB( S[ 3 ], out32_Q14[ 1 ], A1_U_Q28 ); - S[ 1 ] = silk_SMLAWB( S[ 1 ], B_Q28[ 2 ], in[ 2 * k + 0 ] ); - S[ 3 ] = silk_SMLAWB( S[ 3 ], B_Q28[ 2 ], in[ 2 * k + 1 ] ); - - /* Scale back to Q0 and saturate */ - out[ 2 * k + 0 ] = (opus_int16)silk_SAT16( silk_RSHIFT( out32_Q14[ 0 ] + (1<<14) - 1, 14 ) ); - out[ 2 * k + 1 ] = (opus_int16)silk_SAT16( silk_RSHIFT( out32_Q14[ 1 ] + (1<<14) - 1, 14 ) ); - } -} diff --git a/Engine/lib/opus/silk/bwexpander.c b/Engine/lib/opus/silk/bwexpander.c deleted file mode 100644 index afa97907e..000000000 --- a/Engine/lib/opus/silk/bwexpander.c +++ /dev/null @@ -1,51 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Chirp (bandwidth expand) LP AR filter */ -void silk_bwexpander( - opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I Length of ar */ - opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ -) -{ - opus_int i; - opus_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536; - - /* NB: Dont use silk_SMULWB, instead of silk_RSHIFT_ROUND( silk_MUL(), 16 ), below. */ - /* Bias in silk_SMULWB can lead to unstable filters */ - for( i = 0; i < d - 1; i++ ) { - ar[ i ] = (opus_int16)silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, ar[ i ] ), 16 ); - chirp_Q16 += silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 ); - } - ar[ d - 1 ] = (opus_int16)silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, ar[ d - 1 ] ), 16 ); -} diff --git a/Engine/lib/opus/silk/bwexpander_32.c b/Engine/lib/opus/silk/bwexpander_32.c deleted file mode 100644 index 0f32b9df1..000000000 --- a/Engine/lib/opus/silk/bwexpander_32.c +++ /dev/null @@ -1,51 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Chirp (bandwidth expand) LP AR filter. - This logic is reused in _celt_lpc(). Any bug fixes should also be applied there. */ -void silk_bwexpander_32( - opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I Length of ar */ - opus_int32 chirp_Q16 /* I Chirp factor in Q16 */ -) -{ - opus_int i; - opus_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536; - - for( i = 0; i < d - 1; i++ ) { - ar[ i ] = silk_SMULWW( chirp_Q16, ar[ i ] ); - chirp_Q16 += silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 ); - } - ar[ d - 1 ] = silk_SMULWW( chirp_Q16, ar[ d - 1 ] ); -} - diff --git a/Engine/lib/opus/silk/check_control_input.c b/Engine/lib/opus/silk/check_control_input.c deleted file mode 100644 index 739fb01f1..000000000 --- a/Engine/lib/opus/silk/check_control_input.c +++ /dev/null @@ -1,106 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "control.h" -#include "errors.h" - -/* Check encoder control struct */ -opus_int check_control_input( - silk_EncControlStruct *encControl /* I Control structure */ -) -{ - celt_assert( encControl != NULL ); - - if( ( ( encControl->API_sampleRate != 8000 ) && - ( encControl->API_sampleRate != 12000 ) && - ( encControl->API_sampleRate != 16000 ) && - ( encControl->API_sampleRate != 24000 ) && - ( encControl->API_sampleRate != 32000 ) && - ( encControl->API_sampleRate != 44100 ) && - ( encControl->API_sampleRate != 48000 ) ) || - ( ( encControl->desiredInternalSampleRate != 8000 ) && - ( encControl->desiredInternalSampleRate != 12000 ) && - ( encControl->desiredInternalSampleRate != 16000 ) ) || - ( ( encControl->maxInternalSampleRate != 8000 ) && - ( encControl->maxInternalSampleRate != 12000 ) && - ( encControl->maxInternalSampleRate != 16000 ) ) || - ( ( encControl->minInternalSampleRate != 8000 ) && - ( encControl->minInternalSampleRate != 12000 ) && - ( encControl->minInternalSampleRate != 16000 ) ) || - ( encControl->minInternalSampleRate > encControl->desiredInternalSampleRate ) || - ( encControl->maxInternalSampleRate < encControl->desiredInternalSampleRate ) || - ( encControl->minInternalSampleRate > encControl->maxInternalSampleRate ) ) { - celt_assert( 0 ); - return SILK_ENC_FS_NOT_SUPPORTED; - } - if( encControl->payloadSize_ms != 10 && - encControl->payloadSize_ms != 20 && - encControl->payloadSize_ms != 40 && - encControl->payloadSize_ms != 60 ) { - celt_assert( 0 ); - return SILK_ENC_PACKET_SIZE_NOT_SUPPORTED; - } - if( encControl->packetLossPercentage < 0 || encControl->packetLossPercentage > 100 ) { - celt_assert( 0 ); - return SILK_ENC_INVALID_LOSS_RATE; - } - if( encControl->useDTX < 0 || encControl->useDTX > 1 ) { - celt_assert( 0 ); - return SILK_ENC_INVALID_DTX_SETTING; - } - if( encControl->useCBR < 0 || encControl->useCBR > 1 ) { - celt_assert( 0 ); - return SILK_ENC_INVALID_CBR_SETTING; - } - if( encControl->useInBandFEC < 0 || encControl->useInBandFEC > 1 ) { - celt_assert( 0 ); - return SILK_ENC_INVALID_INBAND_FEC_SETTING; - } - if( encControl->nChannelsAPI < 1 || encControl->nChannelsAPI > ENCODER_NUM_CHANNELS ) { - celt_assert( 0 ); - return SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; - } - if( encControl->nChannelsInternal < 1 || encControl->nChannelsInternal > ENCODER_NUM_CHANNELS ) { - celt_assert( 0 ); - return SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; - } - if( encControl->nChannelsInternal > encControl->nChannelsAPI ) { - celt_assert( 0 ); - return SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; - } - if( encControl->complexity < 0 || encControl->complexity > 10 ) { - celt_assert( 0 ); - return SILK_ENC_INVALID_COMPLEXITY_SETTING; - } - - return SILK_NO_ERROR; -} diff --git a/Engine/lib/opus/silk/code_signs.c b/Engine/lib/opus/silk/code_signs.c deleted file mode 100644 index dfd1dca9a..000000000 --- a/Engine/lib/opus/silk/code_signs.c +++ /dev/null @@ -1,115 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/*#define silk_enc_map(a) ((a) > 0 ? 1 : 0)*/ -/*#define silk_dec_map(a) ((a) > 0 ? 1 : -1)*/ -/* shifting avoids if-statement */ -#define silk_enc_map(a) ( silk_RSHIFT( (a), 15 ) + 1 ) -#define silk_dec_map(a) ( silk_LSHIFT( (a), 1 ) - 1 ) - -/* Encodes signs of excitation */ -void silk_encode_signs( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - const opus_int8 pulses[], /* I pulse signal */ - opus_int length, /* I length of input */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I Quantization offset type */ - const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ -) -{ - opus_int i, j, p; - opus_uint8 icdf[ 2 ]; - const opus_int8 *q_ptr; - const opus_uint8 *icdf_ptr; - - icdf[ 1 ] = 0; - q_ptr = pulses; - i = silk_SMULBB( 7, silk_ADD_LSHIFT( quantOffsetType, signalType, 1 ) ); - icdf_ptr = &silk_sign_iCDF[ i ]; - length = silk_RSHIFT( length + SHELL_CODEC_FRAME_LENGTH/2, LOG2_SHELL_CODEC_FRAME_LENGTH ); - for( i = 0; i < length; i++ ) { - p = sum_pulses[ i ]; - if( p > 0 ) { - icdf[ 0 ] = icdf_ptr[ silk_min( p & 0x1F, 6 ) ]; - for( j = 0; j < SHELL_CODEC_FRAME_LENGTH; j++ ) { - if( q_ptr[ j ] != 0 ) { - ec_enc_icdf( psRangeEnc, silk_enc_map( q_ptr[ j ]), icdf, 8 ); - } - } - } - q_ptr += SHELL_CODEC_FRAME_LENGTH; - } -} - -/* Decodes signs of excitation */ -void silk_decode_signs( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 pulses[], /* I/O pulse signal */ - opus_int length, /* I length of input */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I Quantization offset type */ - const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ -) -{ - opus_int i, j, p; - opus_uint8 icdf[ 2 ]; - opus_int16 *q_ptr; - const opus_uint8 *icdf_ptr; - - icdf[ 1 ] = 0; - q_ptr = pulses; - i = silk_SMULBB( 7, silk_ADD_LSHIFT( quantOffsetType, signalType, 1 ) ); - icdf_ptr = &silk_sign_iCDF[ i ]; - length = silk_RSHIFT( length + SHELL_CODEC_FRAME_LENGTH/2, LOG2_SHELL_CODEC_FRAME_LENGTH ); - for( i = 0; i < length; i++ ) { - p = sum_pulses[ i ]; - if( p > 0 ) { - icdf[ 0 ] = icdf_ptr[ silk_min( p & 0x1F, 6 ) ]; - for( j = 0; j < SHELL_CODEC_FRAME_LENGTH; j++ ) { - if( q_ptr[ j ] > 0 ) { - /* attach sign */ -#if 0 - /* conditional implementation */ - if( ec_dec_icdf( psRangeDec, icdf, 8 ) == 0 ) { - q_ptr[ j ] = -q_ptr[ j ]; - } -#else - /* implementation with shift, subtraction, multiplication */ - q_ptr[ j ] *= silk_dec_map( ec_dec_icdf( psRangeDec, icdf, 8 ) ); -#endif - } - } - } - q_ptr += SHELL_CODEC_FRAME_LENGTH; - } -} diff --git a/Engine/lib/opus/silk/control.h b/Engine/lib/opus/silk/control.h deleted file mode 100644 index b76ec33cd..000000000 --- a/Engine/lib/opus/silk/control.h +++ /dev/null @@ -1,150 +0,0 @@ -/*********************************************************************** -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 SILK_CONTROL_H -#define SILK_CONTROL_H - -#include "typedef.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Decoder API flags */ -#define FLAG_DECODE_NORMAL 0 -#define FLAG_PACKET_LOST 1 -#define FLAG_DECODE_LBRR 2 - -/***********************************************/ -/* Structure for controlling encoder operation */ -/***********************************************/ -typedef struct { - /* I: Number of channels; 1/2 */ - opus_int32 nChannelsAPI; - - /* I: Number of channels; 1/2 */ - opus_int32 nChannelsInternal; - - /* I: Input signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */ - opus_int32 API_sampleRate; - - /* I: Maximum internal sampling rate in Hertz; 8000/12000/16000 */ - opus_int32 maxInternalSampleRate; - - /* I: Minimum internal sampling rate in Hertz; 8000/12000/16000 */ - opus_int32 minInternalSampleRate; - - /* I: Soft request for internal sampling rate in Hertz; 8000/12000/16000 */ - opus_int32 desiredInternalSampleRate; - - /* I: Number of samples per packet in milliseconds; 10/20/40/60 */ - opus_int payloadSize_ms; - - /* I: Bitrate during active speech in bits/second; internally limited */ - opus_int32 bitRate; - - /* I: Uplink packet loss in percent (0-100) */ - opus_int packetLossPercentage; - - /* I: Complexity mode; 0 is lowest, 10 is highest complexity */ - opus_int complexity; - - /* I: Flag to enable in-band Forward Error Correction (FEC); 0/1 */ - opus_int useInBandFEC; - - /* I: Flag to actually code in-band Forward Error Correction (FEC) in the current packet; 0/1 */ - opus_int LBRR_coded; - - /* I: Flag to enable discontinuous transmission (DTX); 0/1 */ - opus_int useDTX; - - /* I: Flag to use constant bitrate */ - opus_int useCBR; - - /* I: Maximum number of bits allowed for the frame */ - opus_int maxBits; - - /* I: Causes a smooth downmix to mono */ - opus_int toMono; - - /* I: Opus encoder is allowing us to switch bandwidth */ - opus_int opusCanSwitch; - - /* I: Make frames as independent as possible (but still use LPC) */ - opus_int reducedDependency; - - /* O: Internal sampling rate used, in Hertz; 8000/12000/16000 */ - opus_int32 internalSampleRate; - - /* O: Flag that bandwidth switching is allowed (because low voice activity) */ - opus_int allowBandwidthSwitch; - - /* O: Flag that SILK runs in WB mode without variable LP filter (use for switching between WB/SWB/FB) */ - opus_int inWBmodeWithoutVariableLP; - - /* O: Stereo width */ - opus_int stereoWidth_Q14; - - /* O: Tells the Opus encoder we're ready to switch */ - opus_int switchReady; - - /* O: SILK Signal type */ - opus_int signalType; - - /* O: SILK offset (dithering) */ - opus_int offset; -} silk_EncControlStruct; - -/**************************************************************************/ -/* Structure for controlling decoder operation and reading decoder status */ -/**************************************************************************/ -typedef struct { - /* I: Number of channels; 1/2 */ - opus_int32 nChannelsAPI; - - /* I: Number of channels; 1/2 */ - opus_int32 nChannelsInternal; - - /* I: Output signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */ - opus_int32 API_sampleRate; - - /* I: Internal sampling rate used, in Hertz; 8000/12000/16000 */ - opus_int32 internalSampleRate; - - /* I: Number of samples per packet in milliseconds; 10/20/40/60 */ - opus_int payloadSize_ms; - - /* O: Pitch lag of previous frame (0 if unvoiced), measured in samples at 48 kHz */ - opus_int prevPitchLag; -} silk_DecControlStruct; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/silk/control_SNR.c b/Engine/lib/opus/silk/control_SNR.c deleted file mode 100644 index 9a6db2754..000000000 --- a/Engine/lib/opus/silk/control_SNR.c +++ /dev/null @@ -1,113 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "tuning_parameters.h" - -/* These tables hold SNR values divided by 21 (so they fit in 8 bits) - for different target bitrates spaced at 400 bps interval. The first - 10 values are omitted (0-4 kb/s) because they're all zeros. - These tables were obtained by running different SNRs through the - encoder and measuring the active bitrate. */ -static const unsigned char silk_TargetRate_NB_21[117 - 10] = { - 0, 15, 39, 52, 61, 68, - 74, 79, 84, 88, 92, 95, 99,102,105,108,111,114,117,119,122,124, - 126,129,131,133,135,137,139,142,143,145,147,149,151,153,155,157, - 158,160,162,163,165,167,168,170,171,173,174,176,177,179,180,182, - 183,185,186,187,189,190,192,193,194,196,197,199,200,201,203,204, - 205,207,208,209,211,212,213,215,216,217,219,220,221,223,224,225, - 227,228,230,231,232,234,235,236,238,239,241,242,243,245,246,248, - 249,250,252,253,255 -}; - -static const unsigned char silk_TargetRate_MB_21[165 - 10] = { - 0, 0, 28, 43, 52, 59, - 65, 70, 74, 78, 81, 85, 87, 90, 93, 95, 98,100,102,105,107,109, - 111,113,115,116,118,120,122,123,125,127,128,130,131,133,134,136, - 137,138,140,141,143,144,145,147,148,149,151,152,153,154,156,157, - 158,159,160,162,163,164,165,166,167,168,169,171,172,173,174,175, - 176,177,178,179,180,181,182,183,184,185,186,187,188,188,189,190, - 191,192,193,194,195,196,197,198,199,200,201,202,203,203,204,205, - 206,207,208,209,210,211,212,213,214,214,215,216,217,218,219,220, - 221,222,223,224,224,225,226,227,228,229,230,231,232,233,234,235, - 236,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250, - 251,252,253,254,255 -}; - -static const unsigned char silk_TargetRate_WB_21[201 - 10] = { - 0, 0, 0, 8, 29, 41, - 49, 56, 62, 66, 70, 74, 77, 80, 83, 86, 88, 91, 93, 95, 97, 99, - 101,103,105,107,108,110,112,113,115,116,118,119,121,122,123,125, - 126,127,129,130,131,132,134,135,136,137,138,140,141,142,143,144, - 145,146,147,148,149,150,151,152,153,154,156,157,158,159,159,160, - 161,162,163,164,165,166,167,168,169,170,171,171,172,173,174,175, - 176,177,177,178,179,180,181,181,182,183,184,185,185,186,187,188, - 189,189,190,191,192,192,193,194,195,195,196,197,198,198,199,200, - 200,201,202,203,203,204,205,206,206,207,208,209,209,210,211,211, - 212,213,214,214,215,216,216,217,218,219,219,220,221,221,222,223, - 224,224,225,226,226,227,228,229,229,230,231,232,232,233,234,234, - 235,236,237,237,238,239,240,240,241,242,243,243,244,245,246,246, - 247,248,249,249,250,251,252,253,255 -}; - -/* Control SNR of redidual quantizer */ -opus_int silk_control_SNR( - silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ - opus_int32 TargetRate_bps /* I Target max bitrate (bps) */ -) -{ - int id; - int bound; - const unsigned char *snr_table; - - psEncC->TargetRate_bps = TargetRate_bps; - if( psEncC->nb_subfr == 2 ) { - TargetRate_bps -= 2000 + psEncC->fs_kHz/16; - } - if( psEncC->fs_kHz == 8 ) { - bound = sizeof(silk_TargetRate_NB_21); - snr_table = silk_TargetRate_NB_21; - } else if( psEncC->fs_kHz == 12 ) { - bound = sizeof(silk_TargetRate_MB_21); - snr_table = silk_TargetRate_MB_21; - } else { - bound = sizeof(silk_TargetRate_WB_21); - snr_table = silk_TargetRate_WB_21; - } - id = (TargetRate_bps+200)/400; - id = silk_min(id - 10, bound-1); - if( id <= 0 ) { - psEncC->SNR_dB_Q7 = 0; - } else { - psEncC->SNR_dB_Q7 = snr_table[id]*21; - } - return SILK_NO_ERROR; -} diff --git a/Engine/lib/opus/silk/control_audio_bandwidth.c b/Engine/lib/opus/silk/control_audio_bandwidth.c deleted file mode 100644 index f6d22d839..000000000 --- a/Engine/lib/opus/silk/control_audio_bandwidth.c +++ /dev/null @@ -1,132 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "tuning_parameters.h" - -/* Control internal sampling rate */ -opus_int silk_control_audio_bandwidth( - silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ - silk_EncControlStruct *encControl /* I Control structure */ -) -{ - opus_int fs_kHz; - opus_int orig_kHz; - opus_int32 fs_Hz; - - orig_kHz = psEncC->fs_kHz; - /* Handle a bandwidth-switching reset where we need to be aware what the last sampling rate was. */ - if( orig_kHz == 0 ) { - orig_kHz = psEncC->sLP.saved_fs_kHz; - } - fs_kHz = orig_kHz; - fs_Hz = silk_SMULBB( fs_kHz, 1000 ); - if( fs_Hz == 0 ) { - /* Encoder has just been initialized */ - fs_Hz = silk_min( psEncC->desiredInternal_fs_Hz, psEncC->API_fs_Hz ); - fs_kHz = silk_DIV32_16( fs_Hz, 1000 ); - } else if( fs_Hz > psEncC->API_fs_Hz || fs_Hz > psEncC->maxInternal_fs_Hz || fs_Hz < psEncC->minInternal_fs_Hz ) { - /* Make sure internal rate is not higher than external rate or maximum allowed, or lower than minimum allowed */ - fs_Hz = psEncC->API_fs_Hz; - fs_Hz = silk_min( fs_Hz, psEncC->maxInternal_fs_Hz ); - fs_Hz = silk_max( fs_Hz, psEncC->minInternal_fs_Hz ); - fs_kHz = silk_DIV32_16( fs_Hz, 1000 ); - } else { - /* State machine for the internal sampling rate switching */ - if( psEncC->sLP.transition_frame_no >= TRANSITION_FRAMES ) { - /* Stop transition phase */ - psEncC->sLP.mode = 0; - } - if( psEncC->allow_bandwidth_switch || encControl->opusCanSwitch ) { - /* Check if we should switch down */ - if( silk_SMULBB( orig_kHz, 1000 ) > psEncC->desiredInternal_fs_Hz ) - { - /* Switch down */ - if( psEncC->sLP.mode == 0 ) { - /* New transition */ - psEncC->sLP.transition_frame_no = TRANSITION_FRAMES; - - /* Reset transition filter state */ - silk_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) ); - } - if( encControl->opusCanSwitch ) { - /* Stop transition phase */ - psEncC->sLP.mode = 0; - - /* Switch to a lower sample frequency */ - fs_kHz = orig_kHz == 16 ? 12 : 8; - } else { - if( psEncC->sLP.transition_frame_no <= 0 ) { - encControl->switchReady = 1; - /* Make room for redundancy */ - encControl->maxBits -= encControl->maxBits * 5 / ( encControl->payloadSize_ms + 5 ); - } else { - /* Direction: down (at double speed) */ - psEncC->sLP.mode = -2; - } - } - } - else - /* Check if we should switch up */ - if( silk_SMULBB( orig_kHz, 1000 ) < psEncC->desiredInternal_fs_Hz ) - { - /* Switch up */ - if( encControl->opusCanSwitch ) { - /* Switch to a higher sample frequency */ - fs_kHz = orig_kHz == 8 ? 12 : 16; - - /* New transition */ - psEncC->sLP.transition_frame_no = 0; - - /* Reset transition filter state */ - silk_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) ); - - /* Direction: up */ - psEncC->sLP.mode = 1; - } else { - if( psEncC->sLP.mode == 0 ) { - encControl->switchReady = 1; - /* Make room for redundancy */ - encControl->maxBits -= encControl->maxBits * 5 / ( encControl->payloadSize_ms + 5 ); - } else { - /* Direction: up */ - psEncC->sLP.mode = 1; - } - } - } else { - if (psEncC->sLP.mode<0) - psEncC->sLP.mode = 1; - } - } - } - - return fs_kHz; -} diff --git a/Engine/lib/opus/silk/control_codec.c b/Engine/lib/opus/silk/control_codec.c deleted file mode 100644 index 784ffe66d..000000000 --- a/Engine/lib/opus/silk/control_codec.c +++ /dev/null @@ -1,423 +0,0 @@ -/*********************************************************************** -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" -#endif -#ifdef FIXED_POINT -#include "main_FIX.h" -#define silk_encoder_state_Fxx silk_encoder_state_FIX -#else -#include "main_FLP.h" -#define silk_encoder_state_Fxx silk_encoder_state_FLP -#endif -#include "stack_alloc.h" -#include "tuning_parameters.h" -#include "pitch_est_defines.h" - -static opus_int silk_setup_resamplers( - silk_encoder_state_Fxx *psEnc, /* I/O */ - opus_int fs_kHz /* I */ -); - -static opus_int silk_setup_fs( - silk_encoder_state_Fxx *psEnc, /* I/O */ - opus_int fs_kHz, /* I */ - opus_int PacketSize_ms /* I */ -); - -static opus_int silk_setup_complexity( - silk_encoder_state *psEncC, /* I/O */ - opus_int Complexity /* I */ -); - -static OPUS_INLINE opus_int silk_setup_LBRR( - silk_encoder_state *psEncC, /* I/O */ - const silk_EncControlStruct *encControl /* I */ -); - - -/* Control encoder */ -opus_int silk_control_encoder( - silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */ - silk_EncControlStruct *encControl, /* I Control structure */ - const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ - const opus_int channelNb, /* I Channel number */ - const opus_int force_fs_kHz -) -{ - opus_int fs_kHz, ret = 0; - - psEnc->sCmn.useDTX = encControl->useDTX; - psEnc->sCmn.useCBR = encControl->useCBR; - psEnc->sCmn.API_fs_Hz = encControl->API_sampleRate; - psEnc->sCmn.maxInternal_fs_Hz = encControl->maxInternalSampleRate; - psEnc->sCmn.minInternal_fs_Hz = encControl->minInternalSampleRate; - psEnc->sCmn.desiredInternal_fs_Hz = encControl->desiredInternalSampleRate; - psEnc->sCmn.useInBandFEC = encControl->useInBandFEC; - psEnc->sCmn.nChannelsAPI = encControl->nChannelsAPI; - psEnc->sCmn.nChannelsInternal = encControl->nChannelsInternal; - psEnc->sCmn.allow_bandwidth_switch = allow_bw_switch; - psEnc->sCmn.channelNb = channelNb; - - if( psEnc->sCmn.controlled_since_last_payload != 0 && psEnc->sCmn.prefillFlag == 0 ) { - if( psEnc->sCmn.API_fs_Hz != psEnc->sCmn.prev_API_fs_Hz && psEnc->sCmn.fs_kHz > 0 ) { - /* Change in API sampling rate in the middle of encoding a packet */ - ret += silk_setup_resamplers( psEnc, psEnc->sCmn.fs_kHz ); - } - return ret; - } - - /* Beyond this point we know that there are no previously coded frames in the payload buffer */ - - /********************************************/ - /* Determine internal sampling rate */ - /********************************************/ - fs_kHz = silk_control_audio_bandwidth( &psEnc->sCmn, encControl ); - if( force_fs_kHz ) { - fs_kHz = force_fs_kHz; - } - /********************************************/ - /* Prepare resampler and buffered data */ - /********************************************/ - ret += silk_setup_resamplers( psEnc, fs_kHz ); - - /********************************************/ - /* Set internal sampling frequency */ - /********************************************/ - ret += silk_setup_fs( psEnc, fs_kHz, encControl->payloadSize_ms ); - - /********************************************/ - /* Set encoding complexity */ - /********************************************/ - ret += silk_setup_complexity( &psEnc->sCmn, encControl->complexity ); - - /********************************************/ - /* Set packet loss rate measured by farend */ - /********************************************/ - psEnc->sCmn.PacketLoss_perc = encControl->packetLossPercentage; - - /********************************************/ - /* Set LBRR usage */ - /********************************************/ - ret += silk_setup_LBRR( &psEnc->sCmn, encControl ); - - psEnc->sCmn.controlled_since_last_payload = 1; - - return ret; -} - -static opus_int silk_setup_resamplers( - silk_encoder_state_Fxx *psEnc, /* I/O */ - opus_int fs_kHz /* I */ -) -{ - opus_int ret = SILK_NO_ERROR; - SAVE_STACK; - - if( psEnc->sCmn.fs_kHz != fs_kHz || psEnc->sCmn.prev_API_fs_Hz != psEnc->sCmn.API_fs_Hz ) - { - if( psEnc->sCmn.fs_kHz == 0 ) { - /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */ - ret += silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000, 1 ); - } else { - VARDECL( opus_int16, x_buf_API_fs_Hz ); - VARDECL( silk_resampler_state_struct, temp_resampler_state ); -#ifdef FIXED_POINT - opus_int16 *x_bufFIX = psEnc->x_buf; -#else - VARDECL( opus_int16, x_bufFIX ); - opus_int32 new_buf_samples; -#endif - opus_int32 api_buf_samples; - opus_int32 old_buf_samples; - opus_int32 buf_length_ms; - - buf_length_ms = silk_LSHIFT( psEnc->sCmn.nb_subfr * 5, 1 ) + LA_SHAPE_MS; - old_buf_samples = buf_length_ms * psEnc->sCmn.fs_kHz; - -#ifndef FIXED_POINT - new_buf_samples = buf_length_ms * fs_kHz; - ALLOC( x_bufFIX, silk_max( old_buf_samples, new_buf_samples ), - opus_int16 ); - silk_float2short_array( x_bufFIX, psEnc->x_buf, old_buf_samples ); -#endif - - /* Initialize resampler for temporary resampling of x_buf data to API_fs_Hz */ - ALLOC( temp_resampler_state, 1, silk_resampler_state_struct ); - ret += silk_resampler_init( temp_resampler_state, silk_SMULBB( psEnc->sCmn.fs_kHz, 1000 ), psEnc->sCmn.API_fs_Hz, 0 ); - - /* Calculate number of samples to temporarily upsample */ - api_buf_samples = buf_length_ms * silk_DIV32_16( psEnc->sCmn.API_fs_Hz, 1000 ); - - /* Temporary resampling of x_buf data to API_fs_Hz */ - ALLOC( x_buf_API_fs_Hz, api_buf_samples, opus_int16 ); - ret += silk_resampler( temp_resampler_state, x_buf_API_fs_Hz, x_bufFIX, old_buf_samples ); - - /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */ - ret += silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, silk_SMULBB( fs_kHz, 1000 ), 1 ); - - /* Correct resampler state by resampling buffered data from API_fs_Hz to fs_kHz */ - ret += silk_resampler( &psEnc->sCmn.resampler_state, x_bufFIX, x_buf_API_fs_Hz, api_buf_samples ); - -#ifndef FIXED_POINT - silk_short2float_array( psEnc->x_buf, x_bufFIX, new_buf_samples); -#endif - } - } - - psEnc->sCmn.prev_API_fs_Hz = psEnc->sCmn.API_fs_Hz; - - RESTORE_STACK; - return ret; -} - -static opus_int silk_setup_fs( - silk_encoder_state_Fxx *psEnc, /* I/O */ - opus_int fs_kHz, /* I */ - opus_int PacketSize_ms /* I */ -) -{ - opus_int ret = SILK_NO_ERROR; - - /* Set packet size */ - if( PacketSize_ms != psEnc->sCmn.PacketSize_ms ) { - if( ( PacketSize_ms != 10 ) && - ( PacketSize_ms != 20 ) && - ( PacketSize_ms != 40 ) && - ( PacketSize_ms != 60 ) ) { - ret = SILK_ENC_PACKET_SIZE_NOT_SUPPORTED; - } - if( PacketSize_ms <= 10 ) { - psEnc->sCmn.nFramesPerPacket = 1; - psEnc->sCmn.nb_subfr = PacketSize_ms == 10 ? 2 : 1; - psEnc->sCmn.frame_length = silk_SMULBB( PacketSize_ms, fs_kHz ); - psEnc->sCmn.pitch_LPC_win_length = silk_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz ); - if( psEnc->sCmn.fs_kHz == 8 ) { - psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_10_ms_NB_iCDF; - } else { - psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_10_ms_iCDF; - } - } else { - psEnc->sCmn.nFramesPerPacket = silk_DIV32_16( PacketSize_ms, MAX_FRAME_LENGTH_MS ); - psEnc->sCmn.nb_subfr = MAX_NB_SUBFR; - psEnc->sCmn.frame_length = silk_SMULBB( 20, fs_kHz ); - psEnc->sCmn.pitch_LPC_win_length = silk_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz ); - if( psEnc->sCmn.fs_kHz == 8 ) { - psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_NB_iCDF; - } else { - psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_iCDF; - } - } - psEnc->sCmn.PacketSize_ms = PacketSize_ms; - psEnc->sCmn.TargetRate_bps = 0; /* trigger new SNR computation */ - } - - /* Set internal sampling frequency */ - celt_assert( fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16 ); - celt_assert( psEnc->sCmn.nb_subfr == 2 || psEnc->sCmn.nb_subfr == 4 ); - if( psEnc->sCmn.fs_kHz != fs_kHz ) { - /* reset part of the state */ - silk_memset( &psEnc->sShape, 0, sizeof( psEnc->sShape ) ); - silk_memset( &psEnc->sCmn.sNSQ, 0, sizeof( psEnc->sCmn.sNSQ ) ); - silk_memset( psEnc->sCmn.prev_NLSFq_Q15, 0, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) ); - silk_memset( &psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) ); - psEnc->sCmn.inputBufIx = 0; - psEnc->sCmn.nFramesEncoded = 0; - psEnc->sCmn.TargetRate_bps = 0; /* trigger new SNR computation */ - - /* Initialize non-zero parameters */ - psEnc->sCmn.prevLag = 100; - psEnc->sCmn.first_frame_after_reset = 1; - psEnc->sShape.LastGainIndex = 10; - psEnc->sCmn.sNSQ.lagPrev = 100; - psEnc->sCmn.sNSQ.prev_gain_Q16 = 65536; - psEnc->sCmn.prevSignalType = TYPE_NO_VOICE_ACTIVITY; - - psEnc->sCmn.fs_kHz = fs_kHz; - if( psEnc->sCmn.fs_kHz == 8 ) { - if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) { - psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_NB_iCDF; - } else { - psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_10_ms_NB_iCDF; - } - } else { - if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) { - psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_iCDF; - } else { - psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_10_ms_iCDF; - } - } - if( psEnc->sCmn.fs_kHz == 8 || psEnc->sCmn.fs_kHz == 12 ) { - psEnc->sCmn.predictLPCOrder = MIN_LPC_ORDER; - psEnc->sCmn.psNLSF_CB = &silk_NLSF_CB_NB_MB; - } else { - psEnc->sCmn.predictLPCOrder = MAX_LPC_ORDER; - psEnc->sCmn.psNLSF_CB = &silk_NLSF_CB_WB; - } - psEnc->sCmn.subfr_length = SUB_FRAME_LENGTH_MS * fs_kHz; - psEnc->sCmn.frame_length = silk_SMULBB( psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr ); - psEnc->sCmn.ltp_mem_length = silk_SMULBB( LTP_MEM_LENGTH_MS, fs_kHz ); - psEnc->sCmn.la_pitch = silk_SMULBB( LA_PITCH_MS, fs_kHz ); - psEnc->sCmn.max_pitch_lag = silk_SMULBB( 18, fs_kHz ); - if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) { - psEnc->sCmn.pitch_LPC_win_length = silk_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz ); - } else { - psEnc->sCmn.pitch_LPC_win_length = silk_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz ); - } - if( psEnc->sCmn.fs_kHz == 16 ) { - psEnc->sCmn.pitch_lag_low_bits_iCDF = silk_uniform8_iCDF; - } else if( psEnc->sCmn.fs_kHz == 12 ) { - psEnc->sCmn.pitch_lag_low_bits_iCDF = silk_uniform6_iCDF; - } else { - psEnc->sCmn.pitch_lag_low_bits_iCDF = silk_uniform4_iCDF; - } - } - - /* Check that settings are valid */ - celt_assert( ( psEnc->sCmn.subfr_length * psEnc->sCmn.nb_subfr ) == psEnc->sCmn.frame_length ); - - return ret; -} - -static opus_int silk_setup_complexity( - silk_encoder_state *psEncC, /* I/O */ - opus_int Complexity /* I */ -) -{ - opus_int ret = 0; - - /* Set encoding complexity */ - celt_assert( Complexity >= 0 && Complexity <= 10 ); - if( Complexity < 1 ) { - psEncC->pitchEstimationComplexity = SILK_PE_MIN_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.8, 16 ); - psEncC->pitchEstimationLPCOrder = 6; - psEncC->shapingLPCOrder = 12; - psEncC->la_shape = 3 * psEncC->fs_kHz; - psEncC->nStatesDelayedDecision = 1; - psEncC->useInterpolatedNLSFs = 0; - psEncC->NLSF_MSVQ_Survivors = 2; - psEncC->warping_Q16 = 0; - } else if( Complexity < 2 ) { - psEncC->pitchEstimationComplexity = SILK_PE_MID_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.76, 16 ); - psEncC->pitchEstimationLPCOrder = 8; - psEncC->shapingLPCOrder = 14; - psEncC->la_shape = 5 * psEncC->fs_kHz; - psEncC->nStatesDelayedDecision = 1; - psEncC->useInterpolatedNLSFs = 0; - psEncC->NLSF_MSVQ_Survivors = 3; - psEncC->warping_Q16 = 0; - } else if( Complexity < 3 ) { - psEncC->pitchEstimationComplexity = SILK_PE_MIN_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.8, 16 ); - psEncC->pitchEstimationLPCOrder = 6; - psEncC->shapingLPCOrder = 12; - psEncC->la_shape = 3 * psEncC->fs_kHz; - psEncC->nStatesDelayedDecision = 2; - psEncC->useInterpolatedNLSFs = 0; - psEncC->NLSF_MSVQ_Survivors = 2; - psEncC->warping_Q16 = 0; - } else if( Complexity < 4 ) { - psEncC->pitchEstimationComplexity = SILK_PE_MID_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.76, 16 ); - psEncC->pitchEstimationLPCOrder = 8; - psEncC->shapingLPCOrder = 14; - psEncC->la_shape = 5 * psEncC->fs_kHz; - psEncC->nStatesDelayedDecision = 2; - psEncC->useInterpolatedNLSFs = 0; - psEncC->NLSF_MSVQ_Survivors = 4; - psEncC->warping_Q16 = 0; - } else if( Complexity < 6 ) { - psEncC->pitchEstimationComplexity = SILK_PE_MID_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.74, 16 ); - psEncC->pitchEstimationLPCOrder = 10; - psEncC->shapingLPCOrder = 16; - psEncC->la_shape = 5 * psEncC->fs_kHz; - psEncC->nStatesDelayedDecision = 2; - psEncC->useInterpolatedNLSFs = 1; - psEncC->NLSF_MSVQ_Survivors = 6; - psEncC->warping_Q16 = psEncC->fs_kHz * SILK_FIX_CONST( WARPING_MULTIPLIER, 16 ); - } else if( Complexity < 8 ) { - psEncC->pitchEstimationComplexity = SILK_PE_MID_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.72, 16 ); - psEncC->pitchEstimationLPCOrder = 12; - psEncC->shapingLPCOrder = 20; - psEncC->la_shape = 5 * psEncC->fs_kHz; - psEncC->nStatesDelayedDecision = 3; - psEncC->useInterpolatedNLSFs = 1; - psEncC->NLSF_MSVQ_Survivors = 8; - psEncC->warping_Q16 = psEncC->fs_kHz * SILK_FIX_CONST( WARPING_MULTIPLIER, 16 ); - } else { - psEncC->pitchEstimationComplexity = SILK_PE_MAX_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.7, 16 ); - psEncC->pitchEstimationLPCOrder = 16; - psEncC->shapingLPCOrder = 24; - psEncC->la_shape = 5 * psEncC->fs_kHz; - psEncC->nStatesDelayedDecision = MAX_DEL_DEC_STATES; - psEncC->useInterpolatedNLSFs = 1; - psEncC->NLSF_MSVQ_Survivors = 16; - psEncC->warping_Q16 = psEncC->fs_kHz * SILK_FIX_CONST( WARPING_MULTIPLIER, 16 ); - } - - /* Do not allow higher pitch estimation LPC order than predict LPC order */ - psEncC->pitchEstimationLPCOrder = silk_min_int( psEncC->pitchEstimationLPCOrder, psEncC->predictLPCOrder ); - psEncC->shapeWinLength = SUB_FRAME_LENGTH_MS * psEncC->fs_kHz + 2 * psEncC->la_shape; - psEncC->Complexity = Complexity; - - celt_assert( psEncC->pitchEstimationLPCOrder <= MAX_FIND_PITCH_LPC_ORDER ); - celt_assert( psEncC->shapingLPCOrder <= MAX_SHAPE_LPC_ORDER ); - celt_assert( psEncC->nStatesDelayedDecision <= MAX_DEL_DEC_STATES ); - celt_assert( psEncC->warping_Q16 <= 32767 ); - celt_assert( psEncC->la_shape <= LA_SHAPE_MAX ); - celt_assert( psEncC->shapeWinLength <= SHAPE_LPC_WIN_MAX ); - - return ret; -} - -static OPUS_INLINE opus_int silk_setup_LBRR( - silk_encoder_state *psEncC, /* I/O */ - const silk_EncControlStruct *encControl /* I */ -) -{ - opus_int LBRR_in_previous_packet, ret = SILK_NO_ERROR; - - LBRR_in_previous_packet = psEncC->LBRR_enabled; - psEncC->LBRR_enabled = encControl->LBRR_coded; - if( psEncC->LBRR_enabled ) { - /* Set gain increase for coding LBRR excitation */ - if( LBRR_in_previous_packet == 0 ) { - /* Previous packet did not have LBRR, and was therefore coded at a higher bitrate */ - psEncC->LBRR_GainIncreases = 7; - } else { - psEncC->LBRR_GainIncreases = silk_max_int( 7 - silk_SMULWB( (opus_int32)psEncC->PacketLoss_perc, SILK_FIX_CONST( 0.2, 16 ) ), 3 ); - } - } - - return ret; -} diff --git a/Engine/lib/opus/silk/debug.c b/Engine/lib/opus/silk/debug.c deleted file mode 100644 index 46a24a47e..000000000 --- a/Engine/lib/opus/silk/debug.c +++ /dev/null @@ -1,174 +0,0 @@ -/*********************************************************************** -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" -#endif - -typedef int prevent_empty_translation_unit_warning; - -#include "debug.h" - -#if SILK_DEBUG || SILK_TIC_TOC -#include "SigProc_FIX.h" -#endif - -#if SILK_TIC_TOC - -#if (defined(_WIN32) || defined(_WINCE)) -#include /* timer */ -#else /* Linux or Mac*/ -#include -#endif - -#ifdef _WIN32 -unsigned long silk_GetHighResolutionTime(void) /* O time in usec*/ -{ - /* Returns a time counter in microsec */ - /* the resolution is platform dependent */ - /* but is typically 1.62 us resolution */ - LARGE_INTEGER lpPerformanceCount; - LARGE_INTEGER lpFrequency; - QueryPerformanceCounter(&lpPerformanceCount); - QueryPerformanceFrequency(&lpFrequency); - return (unsigned long)((1000000*(lpPerformanceCount.QuadPart)) / lpFrequency.QuadPart); -} -#else /* Linux or Mac*/ -unsigned long GetHighResolutionTime(void) /* O time in usec*/ -{ - struct timeval tv; - gettimeofday(&tv, 0); - return((tv.tv_sec*1000000)+(tv.tv_usec)); -} -#endif - -int silk_Timer_nTimers = 0; -int silk_Timer_depth_ctr = 0; -char silk_Timer_tags[silk_NUM_TIMERS_MAX][silk_NUM_TIMERS_MAX_TAG_LEN]; -#ifdef _WIN32 -LARGE_INTEGER silk_Timer_start[silk_NUM_TIMERS_MAX]; -#else -unsigned long silk_Timer_start[silk_NUM_TIMERS_MAX]; -#endif -unsigned int silk_Timer_cnt[silk_NUM_TIMERS_MAX]; -opus_int64 silk_Timer_min[silk_NUM_TIMERS_MAX]; -opus_int64 silk_Timer_sum[silk_NUM_TIMERS_MAX]; -opus_int64 silk_Timer_max[silk_NUM_TIMERS_MAX]; -opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX]; - -#ifdef _WIN32 -void silk_TimerSave(char *file_name) -{ - if( silk_Timer_nTimers > 0 ) - { - int k; - FILE *fp; - LARGE_INTEGER lpFrequency; - LARGE_INTEGER lpPerformanceCount1, lpPerformanceCount2; - int del = 0x7FFFFFFF; - double avg, sum_avg; - /* estimate overhead of calling performance counters */ - for( k = 0; k < 1000; k++ ) { - QueryPerformanceCounter(&lpPerformanceCount1); - QueryPerformanceCounter(&lpPerformanceCount2); - lpPerformanceCount2.QuadPart -= lpPerformanceCount1.QuadPart; - if( (int)lpPerformanceCount2.LowPart < del ) - del = lpPerformanceCount2.LowPart; - } - QueryPerformanceFrequency(&lpFrequency); - /* print results to file */ - sum_avg = 0.0f; - for( k = 0; k < silk_Timer_nTimers; k++ ) { - if (silk_Timer_depth[k] == 0) { - sum_avg += (1e6 * silk_Timer_sum[k] / silk_Timer_cnt[k] - del) / lpFrequency.QuadPart * silk_Timer_cnt[k]; - } - } - fp = fopen(file_name, "w"); - fprintf(fp, " min avg %% max count\n"); - for( k = 0; k < silk_Timer_nTimers; k++ ) { - if (silk_Timer_depth[k] == 0) { - fprintf(fp, "%-28s", silk_Timer_tags[k]); - } else if (silk_Timer_depth[k] == 1) { - fprintf(fp, " %-27s", silk_Timer_tags[k]); - } else if (silk_Timer_depth[k] == 2) { - fprintf(fp, " %-26s", silk_Timer_tags[k]); - } else if (silk_Timer_depth[k] == 3) { - fprintf(fp, " %-25s", silk_Timer_tags[k]); - } else { - fprintf(fp, " %-24s", silk_Timer_tags[k]); - } - avg = (1e6 * silk_Timer_sum[k] / silk_Timer_cnt[k] - del) / lpFrequency.QuadPart; - fprintf(fp, "%8.2f", (1e6 * (silk_max_64(silk_Timer_min[k] - del, 0))) / lpFrequency.QuadPart); - fprintf(fp, "%12.2f %6.2f", avg, 100.0 * avg / sum_avg * silk_Timer_cnt[k]); - fprintf(fp, "%12.2f", (1e6 * (silk_max_64(silk_Timer_max[k] - del, 0))) / lpFrequency.QuadPart); - fprintf(fp, "%10d\n", silk_Timer_cnt[k]); - } - fprintf(fp, " microseconds\n"); - fclose(fp); - } -} -#else -void silk_TimerSave(char *file_name) -{ - if( silk_Timer_nTimers > 0 ) - { - int k; - FILE *fp; - /* print results to file */ - fp = fopen(file_name, "w"); - fprintf(fp, " min avg max count\n"); - for( k = 0; k < silk_Timer_nTimers; k++ ) - { - if (silk_Timer_depth[k] == 0) { - fprintf(fp, "%-28s", silk_Timer_tags[k]); - } else if (silk_Timer_depth[k] == 1) { - fprintf(fp, " %-27s", silk_Timer_tags[k]); - } else if (silk_Timer_depth[k] == 2) { - fprintf(fp, " %-26s", silk_Timer_tags[k]); - } else if (silk_Timer_depth[k] == 3) { - fprintf(fp, " %-25s", silk_Timer_tags[k]); - } else { - fprintf(fp, " %-24s", silk_Timer_tags[k]); - } - fprintf(fp, "%d ", silk_Timer_min[k]); - fprintf(fp, "%f ", (double)silk_Timer_sum[k] / (double)silk_Timer_cnt[k]); - fprintf(fp, "%d ", silk_Timer_max[k]); - fprintf(fp, "%10d\n", silk_Timer_cnt[k]); - } - fprintf(fp, " microseconds\n"); - fclose(fp); - } -} -#endif - -#endif /* SILK_TIC_TOC */ - -#if SILK_DEBUG -FILE *silk_debug_store_fp[ silk_NUM_STORES_MAX ]; -int silk_debug_store_count = 0; -#endif /* SILK_DEBUG */ - diff --git a/Engine/lib/opus/silk/debug.h b/Engine/lib/opus/silk/debug.h deleted file mode 100644 index 36163e478..000000000 --- a/Engine/lib/opus/silk/debug.h +++ /dev/null @@ -1,267 +0,0 @@ -/*********************************************************************** -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 SILK_DEBUG_H -#define SILK_DEBUG_H - -/* Set to 1 to enable DEBUG_STORE_DATA() macros for dumping - * intermediate signals from the codec. - */ -#define SILK_DEBUG 0 - -/* Flag for using timers */ -#define SILK_TIC_TOC 0 - -#if SILK_DEBUG || SILK_TIC_TOC -#include "typedef.h" -#include /* strcpy, strcmp */ -#include /* file writing */ -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#if SILK_TIC_TOC - -unsigned long GetHighResolutionTime(void); /* O time in usec*/ - -#if (defined(_WIN32) || defined(_WINCE)) -#include /* timer */ -#else /* Linux or Mac*/ -#include -#endif - -/*********************************/ -/* timer functions for profiling */ -/*********************************/ -/* example: */ -/* */ -/* TIC(LPC) */ -/* do_LPC(in_vec, order, acoef); // do LPC analysis */ -/* TOC(LPC) */ -/* */ -/* and call the following just before exiting (from main) */ -/* */ -/* silk_TimerSave("silk_TimingData.txt"); */ -/* */ -/* results are now in silk_TimingData.txt */ - -void silk_TimerSave(char *file_name); - -/* max number of timers (in different locations) */ -#define silk_NUM_TIMERS_MAX 50 -/* max length of name tags in TIC(..), TOC(..) */ -#define silk_NUM_TIMERS_MAX_TAG_LEN 30 - -extern int silk_Timer_nTimers; -extern int silk_Timer_depth_ctr; -extern char silk_Timer_tags[silk_NUM_TIMERS_MAX][silk_NUM_TIMERS_MAX_TAG_LEN]; -#ifdef _WIN32 -extern LARGE_INTEGER silk_Timer_start[silk_NUM_TIMERS_MAX]; -#else -extern unsigned long silk_Timer_start[silk_NUM_TIMERS_MAX]; -#endif -extern unsigned int silk_Timer_cnt[silk_NUM_TIMERS_MAX]; -extern opus_int64 silk_Timer_sum[silk_NUM_TIMERS_MAX]; -extern opus_int64 silk_Timer_max[silk_NUM_TIMERS_MAX]; -extern opus_int64 silk_Timer_min[silk_NUM_TIMERS_MAX]; -extern opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX]; - -/* WARNING: TIC()/TOC can measure only up to 0.1 seconds at a time */ -#ifdef _WIN32 -#define TIC(TAG_NAME) { \ - static int init = 0; \ - static int ID = -1; \ - if( init == 0 ) \ - { \ - int k; \ - init = 1; \ - for( k = 0; k < silk_Timer_nTimers; k++ ) { \ - if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ - ID = k; \ - break; \ - } \ - } \ - if (ID == -1) { \ - ID = silk_Timer_nTimers; \ - silk_Timer_nTimers++; \ - silk_Timer_depth[ID] = silk_Timer_depth_ctr; \ - strcpy(silk_Timer_tags[ID], #TAG_NAME); \ - silk_Timer_cnt[ID] = 0; \ - silk_Timer_sum[ID] = 0; \ - silk_Timer_min[ID] = 0xFFFFFFFF; \ - silk_Timer_max[ID] = 0; \ - } \ - } \ - silk_Timer_depth_ctr++; \ - QueryPerformanceCounter(&silk_Timer_start[ID]); \ -} -#else -#define TIC(TAG_NAME) { \ - static int init = 0; \ - static int ID = -1; \ - if( init == 0 ) \ - { \ - int k; \ - init = 1; \ - for( k = 0; k < silk_Timer_nTimers; k++ ) { \ - if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ - ID = k; \ - break; \ - } \ - } \ - if (ID == -1) { \ - ID = silk_Timer_nTimers; \ - silk_Timer_nTimers++; \ - silk_Timer_depth[ID] = silk_Timer_depth_ctr; \ - strcpy(silk_Timer_tags[ID], #TAG_NAME); \ - silk_Timer_cnt[ID] = 0; \ - silk_Timer_sum[ID] = 0; \ - silk_Timer_min[ID] = 0xFFFFFFFF; \ - silk_Timer_max[ID] = 0; \ - } \ - } \ - silk_Timer_depth_ctr++; \ - silk_Timer_start[ID] = GetHighResolutionTime(); \ -} -#endif - -#ifdef _WIN32 -#define TOC(TAG_NAME) { \ - LARGE_INTEGER lpPerformanceCount; \ - static int init = 0; \ - static int ID = 0; \ - if( init == 0 ) \ - { \ - int k; \ - init = 1; \ - for( k = 0; k < silk_Timer_nTimers; k++ ) { \ - if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ - ID = k; \ - break; \ - } \ - } \ - } \ - QueryPerformanceCounter(&lpPerformanceCount); \ - lpPerformanceCount.QuadPart -= silk_Timer_start[ID].QuadPart; \ - if((lpPerformanceCount.QuadPart < 100000000) && \ - (lpPerformanceCount.QuadPart >= 0)) { \ - silk_Timer_cnt[ID]++; \ - silk_Timer_sum[ID] += lpPerformanceCount.QuadPart; \ - if( lpPerformanceCount.QuadPart > silk_Timer_max[ID] ) \ - silk_Timer_max[ID] = lpPerformanceCount.QuadPart; \ - if( lpPerformanceCount.QuadPart < silk_Timer_min[ID] ) \ - silk_Timer_min[ID] = lpPerformanceCount.QuadPart; \ - } \ - silk_Timer_depth_ctr--; \ -} -#else -#define TOC(TAG_NAME) { \ - unsigned long endTime; \ - static int init = 0; \ - static int ID = 0; \ - if( init == 0 ) \ - { \ - int k; \ - init = 1; \ - for( k = 0; k < silk_Timer_nTimers; k++ ) { \ - if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ - ID = k; \ - break; \ - } \ - } \ - } \ - endTime = GetHighResolutionTime(); \ - endTime -= silk_Timer_start[ID]; \ - if((endTime < 100000000) && \ - (endTime >= 0)) { \ - silk_Timer_cnt[ID]++; \ - silk_Timer_sum[ID] += endTime; \ - if( endTime > silk_Timer_max[ID] ) \ - silk_Timer_max[ID] = endTime; \ - if( endTime < silk_Timer_min[ID] ) \ - silk_Timer_min[ID] = endTime; \ - } \ - silk_Timer_depth_ctr--; \ -} -#endif - -#else /* SILK_TIC_TOC */ - -/* define macros as empty strings */ -#define TIC(TAG_NAME) -#define TOC(TAG_NAME) -#define silk_TimerSave(FILE_NAME) - -#endif /* SILK_TIC_TOC */ - - -#if SILK_DEBUG -/************************************/ -/* write data to file for debugging */ -/************************************/ -/* Example: DEBUG_STORE_DATA(testfile.pcm, &RIN[0], 160*sizeof(opus_int16)); */ - -#define silk_NUM_STORES_MAX 100 -extern FILE *silk_debug_store_fp[ silk_NUM_STORES_MAX ]; -extern int silk_debug_store_count; - -/* Faster way of storing the data */ -#define DEBUG_STORE_DATA( FILE_NAME, DATA_PTR, N_BYTES ) { \ - static opus_int init = 0, cnt = 0; \ - static FILE **fp; \ - if (init == 0) { \ - init = 1; \ - cnt = silk_debug_store_count++; \ - silk_debug_store_fp[ cnt ] = fopen(#FILE_NAME, "wb"); \ - } \ - fwrite((DATA_PTR), (N_BYTES), 1, silk_debug_store_fp[ cnt ]); \ -} - -/* Call this at the end of main() */ -#define SILK_DEBUG_STORE_CLOSE_FILES { \ - opus_int i; \ - for( i = 0; i < silk_debug_store_count; i++ ) { \ - fclose( silk_debug_store_fp[ i ] ); \ - } \ -} - -#else /* SILK_DEBUG */ - -/* define macros as empty strings */ -#define DEBUG_STORE_DATA(FILE_NAME, DATA_PTR, N_BYTES) -#define SILK_DEBUG_STORE_CLOSE_FILES - -#endif /* SILK_DEBUG */ - -#ifdef __cplusplus -} -#endif - -#endif /* SILK_DEBUG_H */ diff --git a/Engine/lib/opus/silk/dec_API.c b/Engine/lib/opus/silk/dec_API.c deleted file mode 100644 index 7d5ca7fb9..000000000 --- a/Engine/lib/opus/silk/dec_API.c +++ /dev/null @@ -1,419 +0,0 @@ -/*********************************************************************** -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" -#endif -#include "API.h" -#include "main.h" -#include "stack_alloc.h" -#include "os_support.h" - -/************************/ -/* Decoder Super Struct */ -/************************/ -typedef struct { - silk_decoder_state channel_state[ DECODER_NUM_CHANNELS ]; - stereo_dec_state sStereo; - opus_int nChannelsAPI; - opus_int nChannelsInternal; - opus_int prev_decode_only_middle; -} silk_decoder; - -/*********************/ -/* Decoder functions */ -/*********************/ - -opus_int silk_Get_Decoder_Size( /* O Returns error code */ - opus_int *decSizeBytes /* O Number of bytes in SILK decoder state */ -) -{ - opus_int ret = SILK_NO_ERROR; - - *decSizeBytes = sizeof( silk_decoder ); - - return ret; -} - -/* Reset decoder state */ -opus_int silk_InitDecoder( /* O Returns error code */ - void *decState /* I/O State */ -) -{ - opus_int n, ret = SILK_NO_ERROR; - silk_decoder_state *channel_state = ((silk_decoder *)decState)->channel_state; - - for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) { - ret = silk_init_decoder( &channel_state[ n ] ); - } - silk_memset(&((silk_decoder *)decState)->sStereo, 0, sizeof(((silk_decoder *)decState)->sStereo)); - /* Not strictly needed, but it's cleaner that way */ - ((silk_decoder *)decState)->prev_decode_only_middle = 0; - - return ret; -} - -/* Decode a frame */ -opus_int silk_Decode( /* O Returns error code */ - void* decState, /* I/O State */ - silk_DecControlStruct* decControl, /* I/O Control Structure */ - opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ - opus_int newPacketFlag, /* I Indicates first decoder call for this packet */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 *samplesOut, /* O Decoded output speech vector */ - opus_int32 *nSamplesOut, /* O Number of samples decoded */ - int arch /* I Run-time architecture */ -) -{ - opus_int i, n, decode_only_middle = 0, ret = SILK_NO_ERROR; - opus_int32 nSamplesOutDec, LBRR_symbol; - opus_int16 *samplesOut1_tmp[ 2 ]; - VARDECL( opus_int16, samplesOut1_tmp_storage1 ); - VARDECL( opus_int16, samplesOut1_tmp_storage2 ); - VARDECL( opus_int16, samplesOut2_tmp ); - opus_int32 MS_pred_Q13[ 2 ] = { 0 }; - opus_int16 *resample_out_ptr; - silk_decoder *psDec = ( silk_decoder * )decState; - silk_decoder_state *channel_state = psDec->channel_state; - opus_int has_side; - opus_int stereo_to_mono; - int delay_stack_alloc; - SAVE_STACK; - - celt_assert( decControl->nChannelsInternal == 1 || decControl->nChannelsInternal == 2 ); - - /**********************************/ - /* Test if first frame in payload */ - /**********************************/ - if( newPacketFlag ) { - for( n = 0; n < decControl->nChannelsInternal; n++ ) { - channel_state[ n ].nFramesDecoded = 0; /* Used to count frames in packet */ - } - } - - /* If Mono -> Stereo transition in bitstream: init state of second channel */ - if( decControl->nChannelsInternal > psDec->nChannelsInternal ) { - ret += silk_init_decoder( &channel_state[ 1 ] ); - } - - stereo_to_mono = decControl->nChannelsInternal == 1 && psDec->nChannelsInternal == 2 && - ( decControl->internalSampleRate == 1000*channel_state[ 0 ].fs_kHz ); - - if( channel_state[ 0 ].nFramesDecoded == 0 ) { - for( n = 0; n < decControl->nChannelsInternal; n++ ) { - opus_int fs_kHz_dec; - if( decControl->payloadSize_ms == 0 ) { - /* Assuming packet loss, use 10 ms */ - channel_state[ n ].nFramesPerPacket = 1; - channel_state[ n ].nb_subfr = 2; - } else if( decControl->payloadSize_ms == 10 ) { - channel_state[ n ].nFramesPerPacket = 1; - channel_state[ n ].nb_subfr = 2; - } else if( decControl->payloadSize_ms == 20 ) { - channel_state[ n ].nFramesPerPacket = 1; - channel_state[ n ].nb_subfr = 4; - } else if( decControl->payloadSize_ms == 40 ) { - channel_state[ n ].nFramesPerPacket = 2; - channel_state[ n ].nb_subfr = 4; - } else if( decControl->payloadSize_ms == 60 ) { - channel_state[ n ].nFramesPerPacket = 3; - channel_state[ n ].nb_subfr = 4; - } else { - celt_assert( 0 ); - RESTORE_STACK; - return SILK_DEC_INVALID_FRAME_SIZE; - } - fs_kHz_dec = ( decControl->internalSampleRate >> 10 ) + 1; - if( fs_kHz_dec != 8 && fs_kHz_dec != 12 && fs_kHz_dec != 16 ) { - celt_assert( 0 ); - RESTORE_STACK; - return SILK_DEC_INVALID_SAMPLING_FREQUENCY; - } - ret += silk_decoder_set_fs( &channel_state[ n ], fs_kHz_dec, decControl->API_sampleRate ); - } - } - - if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 2 && ( psDec->nChannelsAPI == 1 || psDec->nChannelsInternal == 1 ) ) { - silk_memset( psDec->sStereo.pred_prev_Q13, 0, sizeof( psDec->sStereo.pred_prev_Q13 ) ); - silk_memset( psDec->sStereo.sSide, 0, sizeof( psDec->sStereo.sSide ) ); - silk_memcpy( &channel_state[ 1 ].resampler_state, &channel_state[ 0 ].resampler_state, sizeof( silk_resampler_state_struct ) ); - } - psDec->nChannelsAPI = decControl->nChannelsAPI; - psDec->nChannelsInternal = decControl->nChannelsInternal; - - if( decControl->API_sampleRate > (opus_int32)MAX_API_FS_KHZ * 1000 || decControl->API_sampleRate < 8000 ) { - ret = SILK_DEC_INVALID_SAMPLING_FREQUENCY; - RESTORE_STACK; - return( ret ); - } - - if( lostFlag != FLAG_PACKET_LOST && channel_state[ 0 ].nFramesDecoded == 0 ) { - /* First decoder call for this payload */ - /* Decode VAD flags and LBRR flag */ - for( n = 0; n < decControl->nChannelsInternal; n++ ) { - for( i = 0; i < channel_state[ n ].nFramesPerPacket; i++ ) { - channel_state[ n ].VAD_flags[ i ] = ec_dec_bit_logp(psRangeDec, 1); - } - channel_state[ n ].LBRR_flag = ec_dec_bit_logp(psRangeDec, 1); - } - /* Decode LBRR flags */ - for( n = 0; n < decControl->nChannelsInternal; n++ ) { - silk_memset( channel_state[ n ].LBRR_flags, 0, sizeof( channel_state[ n ].LBRR_flags ) ); - if( channel_state[ n ].LBRR_flag ) { - if( channel_state[ n ].nFramesPerPacket == 1 ) { - channel_state[ n ].LBRR_flags[ 0 ] = 1; - } else { - LBRR_symbol = ec_dec_icdf( psRangeDec, silk_LBRR_flags_iCDF_ptr[ channel_state[ n ].nFramesPerPacket - 2 ], 8 ) + 1; - for( i = 0; i < channel_state[ n ].nFramesPerPacket; i++ ) { - channel_state[ n ].LBRR_flags[ i ] = silk_RSHIFT( LBRR_symbol, i ) & 1; - } - } - } - } - - if( lostFlag == FLAG_DECODE_NORMAL ) { - /* Regular decoding: skip all LBRR data */ - for( i = 0; i < channel_state[ 0 ].nFramesPerPacket; i++ ) { - for( n = 0; n < decControl->nChannelsInternal; n++ ) { - if( channel_state[ n ].LBRR_flags[ i ] ) { - opus_int16 pulses[ MAX_FRAME_LENGTH ]; - opus_int condCoding; - - if( decControl->nChannelsInternal == 2 && n == 0 ) { - silk_stereo_decode_pred( psRangeDec, MS_pred_Q13 ); - if( channel_state[ 1 ].LBRR_flags[ i ] == 0 ) { - silk_stereo_decode_mid_only( psRangeDec, &decode_only_middle ); - } - } - /* Use conditional coding if previous frame available */ - if( i > 0 && channel_state[ n ].LBRR_flags[ i - 1 ] ) { - condCoding = CODE_CONDITIONALLY; - } else { - condCoding = CODE_INDEPENDENTLY; - } - silk_decode_indices( &channel_state[ n ], psRangeDec, i, 1, condCoding ); - silk_decode_pulses( psRangeDec, pulses, channel_state[ n ].indices.signalType, - channel_state[ n ].indices.quantOffsetType, channel_state[ n ].frame_length ); - } - } - } - } - } - - /* Get MS predictor index */ - if( decControl->nChannelsInternal == 2 ) { - if( lostFlag == FLAG_DECODE_NORMAL || - ( lostFlag == FLAG_DECODE_LBRR && channel_state[ 0 ].LBRR_flags[ channel_state[ 0 ].nFramesDecoded ] == 1 ) ) - { - silk_stereo_decode_pred( psRangeDec, MS_pred_Q13 ); - /* For LBRR data, decode mid-only flag only if side-channel's LBRR flag is false */ - if( ( lostFlag == FLAG_DECODE_NORMAL && channel_state[ 1 ].VAD_flags[ channel_state[ 0 ].nFramesDecoded ] == 0 ) || - ( lostFlag == FLAG_DECODE_LBRR && channel_state[ 1 ].LBRR_flags[ channel_state[ 0 ].nFramesDecoded ] == 0 ) ) - { - silk_stereo_decode_mid_only( psRangeDec, &decode_only_middle ); - } else { - decode_only_middle = 0; - } - } else { - for( n = 0; n < 2; n++ ) { - MS_pred_Q13[ n ] = psDec->sStereo.pred_prev_Q13[ n ]; - } - } - } - - /* Reset side channel decoder prediction memory for first frame with side coding */ - if( decControl->nChannelsInternal == 2 && decode_only_middle == 0 && psDec->prev_decode_only_middle == 1 ) { - silk_memset( psDec->channel_state[ 1 ].outBuf, 0, sizeof(psDec->channel_state[ 1 ].outBuf) ); - silk_memset( psDec->channel_state[ 1 ].sLPC_Q14_buf, 0, sizeof(psDec->channel_state[ 1 ].sLPC_Q14_buf) ); - psDec->channel_state[ 1 ].lagPrev = 100; - psDec->channel_state[ 1 ].LastGainIndex = 10; - psDec->channel_state[ 1 ].prevSignalType = TYPE_NO_VOICE_ACTIVITY; - psDec->channel_state[ 1 ].first_frame_after_reset = 1; - } - - /* Check if the temp buffer fits into the output PCM buffer. If it fits, - we can delay allocating the temp buffer until after the SILK peak stack - usage. We need to use a < and not a <= because of the two extra samples. */ - delay_stack_alloc = decControl->internalSampleRate*decControl->nChannelsInternal - < decControl->API_sampleRate*decControl->nChannelsAPI; - ALLOC( samplesOut1_tmp_storage1, delay_stack_alloc ? ALLOC_NONE - : decControl->nChannelsInternal*(channel_state[ 0 ].frame_length + 2 ), - opus_int16 ); - if ( delay_stack_alloc ) - { - samplesOut1_tmp[ 0 ] = samplesOut; - samplesOut1_tmp[ 1 ] = samplesOut + channel_state[ 0 ].frame_length + 2; - } else { - samplesOut1_tmp[ 0 ] = samplesOut1_tmp_storage1; - samplesOut1_tmp[ 1 ] = samplesOut1_tmp_storage1 + channel_state[ 0 ].frame_length + 2; - } - - if( lostFlag == FLAG_DECODE_NORMAL ) { - has_side = !decode_only_middle; - } else { - has_side = !psDec->prev_decode_only_middle - || (decControl->nChannelsInternal == 2 && lostFlag == FLAG_DECODE_LBRR && channel_state[1].LBRR_flags[ channel_state[1].nFramesDecoded ] == 1 ); - } - /* Call decoder for one frame */ - for( n = 0; n < decControl->nChannelsInternal; n++ ) { - if( n == 0 || has_side ) { - opus_int FrameIndex; - opus_int condCoding; - - FrameIndex = channel_state[ 0 ].nFramesDecoded - n; - /* Use independent coding if no previous frame available */ - if( FrameIndex <= 0 ) { - condCoding = CODE_INDEPENDENTLY; - } else if( lostFlag == FLAG_DECODE_LBRR ) { - condCoding = channel_state[ n ].LBRR_flags[ FrameIndex - 1 ] ? CODE_CONDITIONALLY : CODE_INDEPENDENTLY; - } else if( n > 0 && psDec->prev_decode_only_middle ) { - /* If we skipped a side frame in this packet, we don't - need LTP scaling; the LTP state is well-defined. */ - condCoding = CODE_INDEPENDENTLY_NO_LTP_SCALING; - } else { - condCoding = CODE_CONDITIONALLY; - } - ret += silk_decode_frame( &channel_state[ n ], psRangeDec, &samplesOut1_tmp[ n ][ 2 ], &nSamplesOutDec, lostFlag, condCoding, arch); - } else { - silk_memset( &samplesOut1_tmp[ n ][ 2 ], 0, nSamplesOutDec * sizeof( opus_int16 ) ); - } - channel_state[ n ].nFramesDecoded++; - } - - if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 2 ) { - /* Convert Mid/Side to Left/Right */ - silk_stereo_MS_to_LR( &psDec->sStereo, samplesOut1_tmp[ 0 ], samplesOut1_tmp[ 1 ], MS_pred_Q13, channel_state[ 0 ].fs_kHz, nSamplesOutDec ); - } else { - /* Buffering */ - silk_memcpy( samplesOut1_tmp[ 0 ], psDec->sStereo.sMid, 2 * sizeof( opus_int16 ) ); - silk_memcpy( psDec->sStereo.sMid, &samplesOut1_tmp[ 0 ][ nSamplesOutDec ], 2 * sizeof( opus_int16 ) ); - } - - /* Number of output samples */ - *nSamplesOut = silk_DIV32( nSamplesOutDec * decControl->API_sampleRate, silk_SMULBB( channel_state[ 0 ].fs_kHz, 1000 ) ); - - /* Set up pointers to temp buffers */ - ALLOC( samplesOut2_tmp, - decControl->nChannelsAPI == 2 ? *nSamplesOut : ALLOC_NONE, opus_int16 ); - if( decControl->nChannelsAPI == 2 ) { - resample_out_ptr = samplesOut2_tmp; - } else { - resample_out_ptr = samplesOut; - } - - ALLOC( samplesOut1_tmp_storage2, delay_stack_alloc - ? decControl->nChannelsInternal*(channel_state[ 0 ].frame_length + 2 ) - : ALLOC_NONE, - opus_int16 ); - if ( delay_stack_alloc ) { - OPUS_COPY(samplesOut1_tmp_storage2, samplesOut, decControl->nChannelsInternal*(channel_state[ 0 ].frame_length + 2)); - samplesOut1_tmp[ 0 ] = samplesOut1_tmp_storage2; - samplesOut1_tmp[ 1 ] = samplesOut1_tmp_storage2 + channel_state[ 0 ].frame_length + 2; - } - for( n = 0; n < silk_min( decControl->nChannelsAPI, decControl->nChannelsInternal ); n++ ) { - - /* Resample decoded signal to API_sampleRate */ - ret += silk_resampler( &channel_state[ n ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ n ][ 1 ], nSamplesOutDec ); - - /* Interleave if stereo output and stereo stream */ - if( decControl->nChannelsAPI == 2 ) { - for( i = 0; i < *nSamplesOut; i++ ) { - samplesOut[ n + 2 * i ] = resample_out_ptr[ i ]; - } - } - } - - /* Create two channel output from mono stream */ - if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 1 ) { - if ( stereo_to_mono ){ - /* Resample right channel for newly collapsed stereo just in case - we weren't doing collapsing when switching to mono */ - ret += silk_resampler( &channel_state[ 1 ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ 0 ][ 1 ], nSamplesOutDec ); - - for( i = 0; i < *nSamplesOut; i++ ) { - samplesOut[ 1 + 2 * i ] = resample_out_ptr[ i ]; - } - } else { - for( i = 0; i < *nSamplesOut; i++ ) { - samplesOut[ 1 + 2 * i ] = samplesOut[ 0 + 2 * i ]; - } - } - } - - /* Export pitch lag, measured at 48 kHz sampling rate */ - if( channel_state[ 0 ].prevSignalType == TYPE_VOICED ) { - int mult_tab[ 3 ] = { 6, 4, 3 }; - decControl->prevPitchLag = channel_state[ 0 ].lagPrev * mult_tab[ ( channel_state[ 0 ].fs_kHz - 8 ) >> 2 ]; - } else { - decControl->prevPitchLag = 0; - } - - if( lostFlag == FLAG_PACKET_LOST ) { - /* On packet loss, remove the gain clamping to prevent having the energy "bounce back" - if we lose packets when the energy is going down */ - for ( i = 0; i < psDec->nChannelsInternal; i++ ) - psDec->channel_state[ i ].LastGainIndex = 10; - } else { - psDec->prev_decode_only_middle = decode_only_middle; - } - RESTORE_STACK; - return ret; -} - -#if 0 -/* Getting table of contents for a packet */ -opus_int silk_get_TOC( - const opus_uint8 *payload, /* I Payload data */ - const opus_int nBytesIn, /* I Number of input bytes */ - const opus_int nFramesPerPayload, /* I Number of SILK frames per payload */ - silk_TOC_struct *Silk_TOC /* O Type of content */ -) -{ - opus_int i, flags, ret = SILK_NO_ERROR; - - if( nBytesIn < 1 ) { - return -1; - } - if( nFramesPerPayload < 0 || nFramesPerPayload > 3 ) { - return -1; - } - - silk_memset( Silk_TOC, 0, sizeof( *Silk_TOC ) ); - - /* For stereo, extract the flags for the mid channel */ - flags = silk_RSHIFT( payload[ 0 ], 7 - nFramesPerPayload ) & ( silk_LSHIFT( 1, nFramesPerPayload + 1 ) - 1 ); - - Silk_TOC->inbandFECFlag = flags & 1; - for( i = nFramesPerPayload - 1; i >= 0 ; i-- ) { - flags = silk_RSHIFT( flags, 1 ); - Silk_TOC->VADFlags[ i ] = flags & 1; - Silk_TOC->VADFlag |= flags & 1; - } - - return ret; -} -#endif diff --git a/Engine/lib/opus/silk/decode_core.c b/Engine/lib/opus/silk/decode_core.c deleted file mode 100644 index 1c352a652..000000000 --- a/Engine/lib/opus/silk/decode_core.c +++ /dev/null @@ -1,237 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" - -/**********************************************************/ -/* Core decoder. Performs inverse NSQ operation LTP + LPC */ -/**********************************************************/ -void silk_decode_core( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I Decoder control */ - opus_int16 xq[], /* O Decoded speech */ - const opus_int16 pulses[ MAX_FRAME_LENGTH ], /* I Pulse signal */ - int arch /* I Run-time architecture */ -) -{ - opus_int i, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, signalType; - opus_int16 *A_Q12, *B_Q14, *pxq, A_Q12_tmp[ MAX_LPC_ORDER ]; - VARDECL( opus_int16, sLTP ); - VARDECL( opus_int32, sLTP_Q15 ); - opus_int32 LTP_pred_Q13, LPC_pred_Q10, Gain_Q10, inv_gain_Q31, gain_adj_Q16, rand_seed, offset_Q10; - opus_int32 *pred_lag_ptr, *pexc_Q14, *pres_Q14; - VARDECL( opus_int32, res_Q14 ); - VARDECL( opus_int32, sLPC_Q14 ); - SAVE_STACK; - - silk_assert( psDec->prev_gain_Q16 != 0 ); - - ALLOC( sLTP, psDec->ltp_mem_length, opus_int16 ); - ALLOC( sLTP_Q15, psDec->ltp_mem_length + psDec->frame_length, opus_int32 ); - ALLOC( res_Q14, psDec->subfr_length, opus_int32 ); - ALLOC( sLPC_Q14, psDec->subfr_length + MAX_LPC_ORDER, opus_int32 ); - - offset_Q10 = silk_Quantization_Offsets_Q10[ psDec->indices.signalType >> 1 ][ psDec->indices.quantOffsetType ]; - - if( psDec->indices.NLSFInterpCoef_Q2 < 1 << 2 ) { - NLSF_interpolation_flag = 1; - } else { - NLSF_interpolation_flag = 0; - } - - /* Decode excitation */ - rand_seed = psDec->indices.Seed; - for( i = 0; i < psDec->frame_length; i++ ) { - rand_seed = silk_RAND( rand_seed ); - psDec->exc_Q14[ i ] = silk_LSHIFT( (opus_int32)pulses[ i ], 14 ); - if( psDec->exc_Q14[ i ] > 0 ) { - psDec->exc_Q14[ i ] -= QUANT_LEVEL_ADJUST_Q10 << 4; - } else - if( psDec->exc_Q14[ i ] < 0 ) { - psDec->exc_Q14[ i ] += QUANT_LEVEL_ADJUST_Q10 << 4; - } - psDec->exc_Q14[ i ] += offset_Q10 << 4; - if( rand_seed < 0 ) { - psDec->exc_Q14[ i ] = -psDec->exc_Q14[ i ]; - } - - rand_seed = silk_ADD32_ovflw( rand_seed, pulses[ i ] ); - } - - /* Copy LPC state */ - silk_memcpy( sLPC_Q14, psDec->sLPC_Q14_buf, MAX_LPC_ORDER * sizeof( opus_int32 ) ); - - pexc_Q14 = psDec->exc_Q14; - pxq = xq; - sLTP_buf_idx = psDec->ltp_mem_length; - /* Loop over subframes */ - for( k = 0; k < psDec->nb_subfr; k++ ) { - pres_Q14 = res_Q14; - A_Q12 = psDecCtrl->PredCoef_Q12[ k >> 1 ]; - - /* Preload LPC coeficients to array on stack. Gives small performance gain */ - silk_memcpy( A_Q12_tmp, A_Q12, psDec->LPC_order * sizeof( opus_int16 ) ); - B_Q14 = &psDecCtrl->LTPCoef_Q14[ k * LTP_ORDER ]; - signalType = psDec->indices.signalType; - - Gain_Q10 = silk_RSHIFT( psDecCtrl->Gains_Q16[ k ], 6 ); - inv_gain_Q31 = silk_INVERSE32_varQ( psDecCtrl->Gains_Q16[ k ], 47 ); - - /* Calculate gain adjustment factor */ - if( psDecCtrl->Gains_Q16[ k ] != psDec->prev_gain_Q16 ) { - gain_adj_Q16 = silk_DIV32_varQ( psDec->prev_gain_Q16, psDecCtrl->Gains_Q16[ k ], 16 ); - - /* Scale short term state */ - for( i = 0; i < MAX_LPC_ORDER; i++ ) { - sLPC_Q14[ i ] = silk_SMULWW( gain_adj_Q16, sLPC_Q14[ i ] ); - } - } else { - gain_adj_Q16 = (opus_int32)1 << 16; - } - - /* Save inv_gain */ - silk_assert( inv_gain_Q31 != 0 ); - psDec->prev_gain_Q16 = psDecCtrl->Gains_Q16[ k ]; - - /* Avoid abrupt transition from voiced PLC to unvoiced normal decoding */ - if( psDec->lossCnt && psDec->prevSignalType == TYPE_VOICED && - psDec->indices.signalType != TYPE_VOICED && k < MAX_NB_SUBFR/2 ) { - - silk_memset( B_Q14, 0, LTP_ORDER * sizeof( opus_int16 ) ); - B_Q14[ LTP_ORDER/2 ] = SILK_FIX_CONST( 0.25, 14 ); - - signalType = TYPE_VOICED; - psDecCtrl->pitchL[ k ] = psDec->lagPrev; - } - - if( signalType == TYPE_VOICED ) { - /* Voiced */ - lag = psDecCtrl->pitchL[ k ]; - - /* Re-whitening */ - if( k == 0 || ( k == 2 && NLSF_interpolation_flag ) ) { - /* Rewhiten with new A coefs */ - start_idx = psDec->ltp_mem_length - lag - psDec->LPC_order - LTP_ORDER / 2; - celt_assert( start_idx > 0 ); - - if( k == 2 ) { - silk_memcpy( &psDec->outBuf[ psDec->ltp_mem_length ], xq, 2 * psDec->subfr_length * sizeof( opus_int16 ) ); - } - - silk_LPC_analysis_filter( &sLTP[ start_idx ], &psDec->outBuf[ start_idx + k * psDec->subfr_length ], - A_Q12, psDec->ltp_mem_length - start_idx, psDec->LPC_order, arch ); - - /* After rewhitening the LTP state is unscaled */ - if( k == 0 ) { - /* Do LTP downscaling to reduce inter-packet dependency */ - inv_gain_Q31 = silk_LSHIFT( silk_SMULWB( inv_gain_Q31, psDecCtrl->LTP_scale_Q14 ), 2 ); - } - for( i = 0; i < lag + LTP_ORDER/2; i++ ) { - sLTP_Q15[ sLTP_buf_idx - i - 1 ] = silk_SMULWB( inv_gain_Q31, sLTP[ psDec->ltp_mem_length - i - 1 ] ); - } - } else { - /* Update LTP state when Gain changes */ - if( gain_adj_Q16 != (opus_int32)1 << 16 ) { - for( i = 0; i < lag + LTP_ORDER/2; i++ ) { - sLTP_Q15[ sLTP_buf_idx - i - 1 ] = silk_SMULWW( gain_adj_Q16, sLTP_Q15[ sLTP_buf_idx - i - 1 ] ); - } - } - } - } - - /* Long-term prediction */ - if( signalType == TYPE_VOICED ) { - /* Set up pointer */ - pred_lag_ptr = &sLTP_Q15[ sLTP_buf_idx - lag + LTP_ORDER / 2 ]; - for( i = 0; i < psDec->subfr_length; i++ ) { - /* Unrolled loop */ - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LTP_pred_Q13 = 2; - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ 0 ], B_Q14[ 0 ] ); - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -1 ], B_Q14[ 1 ] ); - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -2 ], B_Q14[ 2 ] ); - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -3 ], B_Q14[ 3 ] ); - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -4 ], B_Q14[ 4 ] ); - pred_lag_ptr++; - - /* Generate LPC excitation */ - pres_Q14[ i ] = silk_ADD_LSHIFT32( pexc_Q14[ i ], LTP_pred_Q13, 1 ); - - /* Update states */ - sLTP_Q15[ sLTP_buf_idx ] = silk_LSHIFT( pres_Q14[ i ], 1 ); - sLTP_buf_idx++; - } - } else { - pres_Q14 = pexc_Q14; - } - - for( i = 0; i < psDec->subfr_length; i++ ) { - /* Short-term prediction */ - celt_assert( psDec->LPC_order == 10 || psDec->LPC_order == 16 ); - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LPC_pred_Q10 = silk_RSHIFT( psDec->LPC_order, 1 ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 1 ], A_Q12_tmp[ 0 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 2 ], A_Q12_tmp[ 1 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 3 ], A_Q12_tmp[ 2 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 4 ], A_Q12_tmp[ 3 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 5 ], A_Q12_tmp[ 4 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 6 ], A_Q12_tmp[ 5 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 7 ], A_Q12_tmp[ 6 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 8 ], A_Q12_tmp[ 7 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 9 ], A_Q12_tmp[ 8 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 10 ], A_Q12_tmp[ 9 ] ); - if( psDec->LPC_order == 16 ) { - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 11 ], A_Q12_tmp[ 10 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 12 ], A_Q12_tmp[ 11 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 13 ], A_Q12_tmp[ 12 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 14 ], A_Q12_tmp[ 13 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 15 ], A_Q12_tmp[ 14 ] ); - LPC_pred_Q10 = silk_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 16 ], A_Q12_tmp[ 15 ] ); - } - - /* Add prediction to LPC excitation */ - sLPC_Q14[ MAX_LPC_ORDER + i ] = silk_ADD_SAT32( pres_Q14[ i ], silk_LSHIFT_SAT32( LPC_pred_Q10, 4 ) ); - - /* Scale with gain */ - pxq[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( sLPC_Q14[ MAX_LPC_ORDER + i ], Gain_Q10 ), 8 ) ); - } - - /* Update LPC filter state */ - silk_memcpy( sLPC_Q14, &sLPC_Q14[ psDec->subfr_length ], MAX_LPC_ORDER * sizeof( opus_int32 ) ); - pexc_Q14 += psDec->subfr_length; - pxq += psDec->subfr_length; - } - - /* Save LPC state */ - silk_memcpy( psDec->sLPC_Q14_buf, sLPC_Q14, MAX_LPC_ORDER * sizeof( opus_int32 ) ); - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/decode_frame.c b/Engine/lib/opus/silk/decode_frame.c deleted file mode 100644 index 4f36f854c..000000000 --- a/Engine/lib/opus/silk/decode_frame.c +++ /dev/null @@ -1,129 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" -#include "PLC.h" - -/****************/ -/* Decode frame */ -/****************/ -opus_int silk_decode_frame( - silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 pOut[], /* O Pointer to output speech frame */ - opus_int32 *pN, /* O Pointer to size of output frame */ - opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ - opus_int condCoding, /* I The type of conditional coding to use */ - int arch /* I Run-time architecture */ -) -{ - VARDECL( silk_decoder_control, psDecCtrl ); - opus_int L, mv_len, ret = 0; - SAVE_STACK; - - L = psDec->frame_length; - ALLOC( psDecCtrl, 1, silk_decoder_control ); - psDecCtrl->LTP_scale_Q14 = 0; - - /* Safety checks */ - celt_assert( L > 0 && L <= MAX_FRAME_LENGTH ); - - if( lostFlag == FLAG_DECODE_NORMAL || - ( lostFlag == FLAG_DECODE_LBRR && psDec->LBRR_flags[ psDec->nFramesDecoded ] == 1 ) ) - { - VARDECL( opus_int16, pulses ); - ALLOC( pulses, (L + SHELL_CODEC_FRAME_LENGTH - 1) & - ~(SHELL_CODEC_FRAME_LENGTH - 1), opus_int16 ); - /*********************************************/ - /* Decode quantization indices of side info */ - /*********************************************/ - silk_decode_indices( psDec, psRangeDec, psDec->nFramesDecoded, lostFlag, condCoding ); - - /*********************************************/ - /* Decode quantization indices of excitation */ - /*********************************************/ - silk_decode_pulses( psRangeDec, pulses, psDec->indices.signalType, - psDec->indices.quantOffsetType, psDec->frame_length ); - - /********************************************/ - /* Decode parameters and pulse signal */ - /********************************************/ - silk_decode_parameters( psDec, psDecCtrl, condCoding ); - - /********************************************************/ - /* Run inverse NSQ */ - /********************************************************/ - silk_decode_core( psDec, psDecCtrl, pOut, pulses, arch ); - - /********************************************************/ - /* Update PLC state */ - /********************************************************/ - silk_PLC( psDec, psDecCtrl, pOut, 0, arch ); - - psDec->lossCnt = 0; - psDec->prevSignalType = psDec->indices.signalType; - celt_assert( psDec->prevSignalType >= 0 && psDec->prevSignalType <= 2 ); - - /* A frame has been decoded without errors */ - psDec->first_frame_after_reset = 0; - } else { - /* Handle packet loss by extrapolation */ - silk_PLC( psDec, psDecCtrl, pOut, 1, arch ); - } - - /*************************/ - /* Update output buffer. */ - /*************************/ - celt_assert( psDec->ltp_mem_length >= psDec->frame_length ); - mv_len = psDec->ltp_mem_length - psDec->frame_length; - silk_memmove( psDec->outBuf, &psDec->outBuf[ psDec->frame_length ], mv_len * sizeof(opus_int16) ); - silk_memcpy( &psDec->outBuf[ mv_len ], pOut, psDec->frame_length * sizeof( opus_int16 ) ); - - /************************************************/ - /* Comfort noise generation / estimation */ - /************************************************/ - silk_CNG( psDec, psDecCtrl, pOut, L ); - - /****************************************************************/ - /* Ensure smooth connection of extrapolated and good frames */ - /****************************************************************/ - silk_PLC_glue_frames( psDec, pOut, L ); - - /* Update some decoder state variables */ - psDec->lagPrev = psDecCtrl->pitchL[ psDec->nb_subfr - 1 ]; - - /* Set output frame length */ - *pN = L; - - RESTORE_STACK; - return ret; -} diff --git a/Engine/lib/opus/silk/decode_indices.c b/Engine/lib/opus/silk/decode_indices.c deleted file mode 100644 index 0bb4a997a..000000000 --- a/Engine/lib/opus/silk/decode_indices.c +++ /dev/null @@ -1,151 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Decode side-information parameters from payload */ -void silk_decode_indices( - silk_decoder_state *psDec, /* I/O State */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int FrameIndex, /* I Frame number */ - opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */ - opus_int condCoding /* I The type of conditional coding to use */ -) -{ - opus_int i, k, Ix; - opus_int decode_absolute_lagIndex, delta_lagIndex; - opus_int16 ec_ix[ MAX_LPC_ORDER ]; - opus_uint8 pred_Q8[ MAX_LPC_ORDER ]; - - /*******************************************/ - /* Decode signal type and quantizer offset */ - /*******************************************/ - if( decode_LBRR || psDec->VAD_flags[ FrameIndex ] ) { - Ix = ec_dec_icdf( psRangeDec, silk_type_offset_VAD_iCDF, 8 ) + 2; - } else { - Ix = ec_dec_icdf( psRangeDec, silk_type_offset_no_VAD_iCDF, 8 ); - } - psDec->indices.signalType = (opus_int8)silk_RSHIFT( Ix, 1 ); - psDec->indices.quantOffsetType = (opus_int8)( Ix & 1 ); - - /****************/ - /* Decode gains */ - /****************/ - /* First subframe */ - if( condCoding == CODE_CONDITIONALLY ) { - /* Conditional coding */ - psDec->indices.GainsIndices[ 0 ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 ); - } else { - /* Independent coding, in two stages: MSB bits followed by 3 LSBs */ - psDec->indices.GainsIndices[ 0 ] = (opus_int8)silk_LSHIFT( ec_dec_icdf( psRangeDec, silk_gain_iCDF[ psDec->indices.signalType ], 8 ), 3 ); - psDec->indices.GainsIndices[ 0 ] += (opus_int8)ec_dec_icdf( psRangeDec, silk_uniform8_iCDF, 8 ); - } - - /* Remaining subframes */ - for( i = 1; i < psDec->nb_subfr; i++ ) { - psDec->indices.GainsIndices[ i ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 ); - } - - /**********************/ - /* Decode LSF Indices */ - /**********************/ - psDec->indices.NLSFIndices[ 0 ] = (opus_int8)ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->CB1_iCDF[ ( psDec->indices.signalType >> 1 ) * psDec->psNLSF_CB->nVectors ], 8 ); - silk_NLSF_unpack( ec_ix, pred_Q8, psDec->psNLSF_CB, psDec->indices.NLSFIndices[ 0 ] ); - celt_assert( psDec->psNLSF_CB->order == psDec->LPC_order ); - for( i = 0; i < psDec->psNLSF_CB->order; i++ ) { - Ix = ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 ); - if( Ix == 0 ) { - Ix -= ec_dec_icdf( psRangeDec, silk_NLSF_EXT_iCDF, 8 ); - } else if( Ix == 2 * NLSF_QUANT_MAX_AMPLITUDE ) { - Ix += ec_dec_icdf( psRangeDec, silk_NLSF_EXT_iCDF, 8 ); - } - psDec->indices.NLSFIndices[ i+1 ] = (opus_int8)( Ix - NLSF_QUANT_MAX_AMPLITUDE ); - } - - /* Decode LSF interpolation factor */ - if( psDec->nb_subfr == MAX_NB_SUBFR ) { - psDec->indices.NLSFInterpCoef_Q2 = (opus_int8)ec_dec_icdf( psRangeDec, silk_NLSF_interpolation_factor_iCDF, 8 ); - } else { - psDec->indices.NLSFInterpCoef_Q2 = 4; - } - - if( psDec->indices.signalType == TYPE_VOICED ) - { - /*********************/ - /* Decode pitch lags */ - /*********************/ - /* Get lag index */ - decode_absolute_lagIndex = 1; - if( condCoding == CODE_CONDITIONALLY && psDec->ec_prevSignalType == TYPE_VOICED ) { - /* Decode Delta index */ - delta_lagIndex = (opus_int16)ec_dec_icdf( psRangeDec, silk_pitch_delta_iCDF, 8 ); - if( delta_lagIndex > 0 ) { - delta_lagIndex = delta_lagIndex - 9; - psDec->indices.lagIndex = (opus_int16)( psDec->ec_prevLagIndex + delta_lagIndex ); - decode_absolute_lagIndex = 0; - } - } - if( decode_absolute_lagIndex ) { - /* Absolute decoding */ - psDec->indices.lagIndex = (opus_int16)ec_dec_icdf( psRangeDec, silk_pitch_lag_iCDF, 8 ) * silk_RSHIFT( psDec->fs_kHz, 1 ); - psDec->indices.lagIndex += (opus_int16)ec_dec_icdf( psRangeDec, psDec->pitch_lag_low_bits_iCDF, 8 ); - } - psDec->ec_prevLagIndex = psDec->indices.lagIndex; - - /* Get countour index */ - psDec->indices.contourIndex = (opus_int8)ec_dec_icdf( psRangeDec, psDec->pitch_contour_iCDF, 8 ); - - /********************/ - /* Decode LTP gains */ - /********************/ - /* Decode PERIndex value */ - psDec->indices.PERIndex = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTP_per_index_iCDF, 8 ); - - for( k = 0; k < psDec->nb_subfr; k++ ) { - psDec->indices.LTPIndex[ k ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTP_gain_iCDF_ptrs[ psDec->indices.PERIndex ], 8 ); - } - - /**********************/ - /* Decode LTP scaling */ - /**********************/ - if( condCoding == CODE_INDEPENDENTLY ) { - psDec->indices.LTP_scaleIndex = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTPscale_iCDF, 8 ); - } else { - psDec->indices.LTP_scaleIndex = 0; - } - } - psDec->ec_prevSignalType = psDec->indices.signalType; - - /***************/ - /* Decode seed */ - /***************/ - psDec->indices.Seed = (opus_int8)ec_dec_icdf( psRangeDec, silk_uniform4_iCDF, 8 ); -} diff --git a/Engine/lib/opus/silk/decode_parameters.c b/Engine/lib/opus/silk/decode_parameters.c deleted file mode 100644 index a56a40985..000000000 --- a/Engine/lib/opus/silk/decode_parameters.c +++ /dev/null @@ -1,115 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Decode parameters from payload */ -void silk_decode_parameters( - silk_decoder_state *psDec, /* I/O State */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int condCoding /* I The type of conditional coding to use */ -) -{ - opus_int i, k, Ix; - opus_int16 pNLSF_Q15[ MAX_LPC_ORDER ], pNLSF0_Q15[ MAX_LPC_ORDER ]; - const opus_int8 *cbk_ptr_Q7; - - /* Dequant Gains */ - silk_gains_dequant( psDecCtrl->Gains_Q16, psDec->indices.GainsIndices, - &psDec->LastGainIndex, condCoding == CODE_CONDITIONALLY, psDec->nb_subfr ); - - /****************/ - /* Decode NLSFs */ - /****************/ - silk_NLSF_decode( pNLSF_Q15, psDec->indices.NLSFIndices, psDec->psNLSF_CB ); - - /* Convert NLSF parameters to AR prediction filter coefficients */ - silk_NLSF2A( psDecCtrl->PredCoef_Q12[ 1 ], pNLSF_Q15, psDec->LPC_order, psDec->arch ); - - /* If just reset, e.g., because internal Fs changed, do not allow interpolation */ - /* improves the case of packet loss in the first frame after a switch */ - if( psDec->first_frame_after_reset == 1 ) { - psDec->indices.NLSFInterpCoef_Q2 = 4; - } - - if( psDec->indices.NLSFInterpCoef_Q2 < 4 ) { - /* Calculation of the interpolated NLSF0 vector from the interpolation factor, */ - /* the previous NLSF1, and the current NLSF1 */ - for( i = 0; i < psDec->LPC_order; i++ ) { - pNLSF0_Q15[ i ] = psDec->prevNLSF_Q15[ i ] + silk_RSHIFT( silk_MUL( psDec->indices.NLSFInterpCoef_Q2, - pNLSF_Q15[ i ] - psDec->prevNLSF_Q15[ i ] ), 2 ); - } - - /* Convert NLSF parameters to AR prediction filter coefficients */ - silk_NLSF2A( psDecCtrl->PredCoef_Q12[ 0 ], pNLSF0_Q15, psDec->LPC_order, psDec->arch ); - } else { - /* Copy LPC coefficients for first half from second half */ - silk_memcpy( psDecCtrl->PredCoef_Q12[ 0 ], psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order * sizeof( opus_int16 ) ); - } - - silk_memcpy( psDec->prevNLSF_Q15, pNLSF_Q15, psDec->LPC_order * sizeof( opus_int16 ) ); - - /* After a packet loss do BWE of LPC coefs */ - if( psDec->lossCnt ) { - silk_bwexpander( psDecCtrl->PredCoef_Q12[ 0 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 ); - silk_bwexpander( psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 ); - } - - if( psDec->indices.signalType == TYPE_VOICED ) { - /*********************/ - /* Decode pitch lags */ - /*********************/ - - /* Decode pitch values */ - silk_decode_pitch( psDec->indices.lagIndex, psDec->indices.contourIndex, psDecCtrl->pitchL, psDec->fs_kHz, psDec->nb_subfr ); - - /* Decode Codebook Index */ - cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[ psDec->indices.PERIndex ]; /* set pointer to start of codebook */ - - for( k = 0; k < psDec->nb_subfr; k++ ) { - Ix = psDec->indices.LTPIndex[ k ]; - for( i = 0; i < LTP_ORDER; i++ ) { - psDecCtrl->LTPCoef_Q14[ k * LTP_ORDER + i ] = silk_LSHIFT( cbk_ptr_Q7[ Ix * LTP_ORDER + i ], 7 ); - } - } - - /**********************/ - /* Decode LTP scaling */ - /**********************/ - Ix = psDec->indices.LTP_scaleIndex; - psDecCtrl->LTP_scale_Q14 = silk_LTPScales_table_Q14[ Ix ]; - } else { - silk_memset( psDecCtrl->pitchL, 0, psDec->nb_subfr * sizeof( opus_int ) ); - silk_memset( psDecCtrl->LTPCoef_Q14, 0, LTP_ORDER * psDec->nb_subfr * sizeof( opus_int16 ) ); - psDec->indices.PERIndex = 0; - psDecCtrl->LTP_scale_Q14 = 0; - } -} diff --git a/Engine/lib/opus/silk/decode_pitch.c b/Engine/lib/opus/silk/decode_pitch.c deleted file mode 100644 index fd1b6bf55..000000000 --- a/Engine/lib/opus/silk/decode_pitch.c +++ /dev/null @@ -1,77 +0,0 @@ -/*********************************************************************** -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" -#endif - -/*********************************************************** -* Pitch analyser function -********************************************************** */ -#include "SigProc_FIX.h" -#include "pitch_est_defines.h" - -void silk_decode_pitch( - opus_int16 lagIndex, /* I */ - opus_int8 contourIndex, /* O */ - opus_int pitch_lags[], /* O 4 pitch values */ - const opus_int Fs_kHz, /* I sampling frequency (kHz) */ - const opus_int nb_subfr /* I number of sub frames */ -) -{ - opus_int lag, k, min_lag, max_lag, cbk_size; - const opus_int8 *Lag_CB_ptr; - - if( Fs_kHz == 8 ) { - if( nb_subfr == PE_MAX_NB_SUBFR ) { - Lag_CB_ptr = &silk_CB_lags_stage2[ 0 ][ 0 ]; - cbk_size = PE_NB_CBKS_STAGE2_EXT; - } else { - celt_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1 ); - Lag_CB_ptr = &silk_CB_lags_stage2_10_ms[ 0 ][ 0 ]; - cbk_size = PE_NB_CBKS_STAGE2_10MS; - } - } else { - if( nb_subfr == PE_MAX_NB_SUBFR ) { - Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; - cbk_size = PE_NB_CBKS_STAGE3_MAX; - } else { - celt_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1 ); - Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; - cbk_size = PE_NB_CBKS_STAGE3_10MS; - } - } - - min_lag = silk_SMULBB( PE_MIN_LAG_MS, Fs_kHz ); - max_lag = silk_SMULBB( PE_MAX_LAG_MS, Fs_kHz ); - lag = min_lag + lagIndex; - - for( k = 0; k < nb_subfr; k++ ) { - pitch_lags[ k ] = lag + matrix_ptr( Lag_CB_ptr, k, contourIndex, cbk_size ); - pitch_lags[ k ] = silk_LIMIT( pitch_lags[ k ], min_lag, max_lag ); - } -} diff --git a/Engine/lib/opus/silk/decode_pulses.c b/Engine/lib/opus/silk/decode_pulses.c deleted file mode 100644 index a56d2d307..000000000 --- a/Engine/lib/opus/silk/decode_pulses.c +++ /dev/null @@ -1,115 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/*********************************************/ -/* Decode quantization indices of excitation */ -/*********************************************/ -void silk_decode_pulses( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 pulses[], /* O Excitation signal */ - const opus_int signalType, /* I Sigtype */ - const opus_int quantOffsetType, /* I quantOffsetType */ - const opus_int frame_length /* I Frame length */ -) -{ - opus_int i, j, k, iter, abs_q, nLS, RateLevelIndex; - opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ], nLshifts[ MAX_NB_SHELL_BLOCKS ]; - opus_int16 *pulses_ptr; - const opus_uint8 *cdf_ptr; - - /*********************/ - /* Decode rate level */ - /*********************/ - RateLevelIndex = ec_dec_icdf( psRangeDec, silk_rate_levels_iCDF[ signalType >> 1 ], 8 ); - - /* Calculate number of shell blocks */ - silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH ); - iter = silk_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH ); - if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ) { - celt_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */ - iter++; - } - - /***************************************************/ - /* Sum-Weighted-Pulses Decoding */ - /***************************************************/ - cdf_ptr = silk_pulses_per_block_iCDF[ RateLevelIndex ]; - for( i = 0; i < iter; i++ ) { - nLshifts[ i ] = 0; - sum_pulses[ i ] = ec_dec_icdf( psRangeDec, cdf_ptr, 8 ); - - /* LSB indication */ - while( sum_pulses[ i ] == SILK_MAX_PULSES + 1 ) { - nLshifts[ i ]++; - /* When we've already got 10 LSBs, we shift the table to not allow (SILK_MAX_PULSES + 1) */ - sum_pulses[ i ] = ec_dec_icdf( psRangeDec, - silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1] + ( nLshifts[ i ] == 10 ), 8 ); - } - } - - /***************************************************/ - /* Shell decoding */ - /***************************************************/ - for( i = 0; i < iter; i++ ) { - if( sum_pulses[ i ] > 0 ) { - silk_shell_decoder( &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], psRangeDec, sum_pulses[ i ] ); - } else { - silk_memset( &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof( pulses[0] ) ); - } - } - - /***************************************************/ - /* LSB Decoding */ - /***************************************************/ - for( i = 0; i < iter; i++ ) { - if( nLshifts[ i ] > 0 ) { - nLS = nLshifts[ i ]; - pulses_ptr = &pulses[ silk_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ]; - for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) { - abs_q = pulses_ptr[ k ]; - for( j = 0; j < nLS; j++ ) { - abs_q = silk_LSHIFT( abs_q, 1 ); - abs_q += ec_dec_icdf( psRangeDec, silk_lsb_iCDF, 8 ); - } - pulses_ptr[ k ] = abs_q; - } - /* Mark the number of pulses non-zero for sign decoding. */ - sum_pulses[ i ] |= nLS << 5; - } - } - - /****************************************/ - /* Decode and add signs to pulse signal */ - /****************************************/ - silk_decode_signs( psRangeDec, pulses, frame_length, signalType, quantOffsetType, sum_pulses ); -} diff --git a/Engine/lib/opus/silk/decoder_set_fs.c b/Engine/lib/opus/silk/decoder_set_fs.c deleted file mode 100644 index d9a13d0f0..000000000 --- a/Engine/lib/opus/silk/decoder_set_fs.c +++ /dev/null @@ -1,108 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Set decoder sampling rate */ -opus_int silk_decoder_set_fs( - silk_decoder_state *psDec, /* I/O Decoder state pointer */ - opus_int fs_kHz, /* I Sampling frequency (kHz) */ - opus_int32 fs_API_Hz /* I API Sampling frequency (Hz) */ -) -{ - opus_int frame_length, ret = 0; - - celt_assert( fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16 ); - celt_assert( psDec->nb_subfr == MAX_NB_SUBFR || psDec->nb_subfr == MAX_NB_SUBFR/2 ); - - /* New (sub)frame length */ - psDec->subfr_length = silk_SMULBB( SUB_FRAME_LENGTH_MS, fs_kHz ); - frame_length = silk_SMULBB( psDec->nb_subfr, psDec->subfr_length ); - - /* Initialize resampler when switching internal or external sampling frequency */ - if( psDec->fs_kHz != fs_kHz || psDec->fs_API_hz != fs_API_Hz ) { - /* Initialize the resampler for dec_API.c preparing resampling from fs_kHz to API_fs_Hz */ - ret += silk_resampler_init( &psDec->resampler_state, silk_SMULBB( fs_kHz, 1000 ), fs_API_Hz, 0 ); - - psDec->fs_API_hz = fs_API_Hz; - } - - if( psDec->fs_kHz != fs_kHz || frame_length != psDec->frame_length ) { - if( fs_kHz == 8 ) { - if( psDec->nb_subfr == MAX_NB_SUBFR ) { - psDec->pitch_contour_iCDF = silk_pitch_contour_NB_iCDF; - } else { - psDec->pitch_contour_iCDF = silk_pitch_contour_10_ms_NB_iCDF; - } - } else { - if( psDec->nb_subfr == MAX_NB_SUBFR ) { - psDec->pitch_contour_iCDF = silk_pitch_contour_iCDF; - } else { - psDec->pitch_contour_iCDF = silk_pitch_contour_10_ms_iCDF; - } - } - if( psDec->fs_kHz != fs_kHz ) { - psDec->ltp_mem_length = silk_SMULBB( LTP_MEM_LENGTH_MS, fs_kHz ); - if( fs_kHz == 8 || fs_kHz == 12 ) { - psDec->LPC_order = MIN_LPC_ORDER; - psDec->psNLSF_CB = &silk_NLSF_CB_NB_MB; - } else { - psDec->LPC_order = MAX_LPC_ORDER; - psDec->psNLSF_CB = &silk_NLSF_CB_WB; - } - if( fs_kHz == 16 ) { - psDec->pitch_lag_low_bits_iCDF = silk_uniform8_iCDF; - } else if( fs_kHz == 12 ) { - psDec->pitch_lag_low_bits_iCDF = silk_uniform6_iCDF; - } else if( fs_kHz == 8 ) { - psDec->pitch_lag_low_bits_iCDF = silk_uniform4_iCDF; - } else { - /* unsupported sampling rate */ - celt_assert( 0 ); - } - psDec->first_frame_after_reset = 1; - psDec->lagPrev = 100; - psDec->LastGainIndex = 10; - psDec->prevSignalType = TYPE_NO_VOICE_ACTIVITY; - silk_memset( psDec->outBuf, 0, sizeof(psDec->outBuf)); - silk_memset( psDec->sLPC_Q14_buf, 0, sizeof(psDec->sLPC_Q14_buf) ); - } - - psDec->fs_kHz = fs_kHz; - psDec->frame_length = frame_length; - } - - /* Check that settings are valid */ - celt_assert( psDec->frame_length > 0 && psDec->frame_length <= MAX_FRAME_LENGTH ); - - return ret; -} - diff --git a/Engine/lib/opus/silk/define.h b/Engine/lib/opus/silk/define.h deleted file mode 100644 index 491c86f33..000000000 --- a/Engine/lib/opus/silk/define.h +++ /dev/null @@ -1,235 +0,0 @@ -/*********************************************************************** -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 SILK_DEFINE_H -#define SILK_DEFINE_H - -#include "errors.h" -#include "typedef.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Max number of encoder channels (1/2) */ -#define ENCODER_NUM_CHANNELS 2 -/* Number of decoder channels (1/2) */ -#define DECODER_NUM_CHANNELS 2 - -#define MAX_FRAMES_PER_PACKET 3 - -/* Limits on bitrate */ -#define MIN_TARGET_RATE_BPS 5000 -#define MAX_TARGET_RATE_BPS 80000 - -/* LBRR thresholds */ -#define LBRR_NB_MIN_RATE_BPS 12000 -#define LBRR_MB_MIN_RATE_BPS 14000 -#define LBRR_WB_MIN_RATE_BPS 16000 - -/* DTX settings */ -#define NB_SPEECH_FRAMES_BEFORE_DTX 10 /* eq 200 ms */ -#define MAX_CONSECUTIVE_DTX 20 /* eq 400 ms */ -#define DTX_ACTIVITY_THRESHOLD 0.1f - -/* VAD decision */ -#define VAD_NO_DECISION -1 -#define VAD_NO_ACTIVITY 0 -#define VAD_ACTIVITY 1 - -/* Maximum sampling frequency */ -#define MAX_FS_KHZ 16 -#define MAX_API_FS_KHZ 48 - -/* Signal types */ -#define TYPE_NO_VOICE_ACTIVITY 0 -#define TYPE_UNVOICED 1 -#define TYPE_VOICED 2 - -/* Conditional coding types */ -#define CODE_INDEPENDENTLY 0 -#define CODE_INDEPENDENTLY_NO_LTP_SCALING 1 -#define CODE_CONDITIONALLY 2 - -/* Settings for stereo processing */ -#define STEREO_QUANT_TAB_SIZE 16 -#define STEREO_QUANT_SUB_STEPS 5 -#define STEREO_INTERP_LEN_MS 8 /* must be even */ -#define STEREO_RATIO_SMOOTH_COEF 0.01 /* smoothing coef for signal norms and stereo width */ - -/* Range of pitch lag estimates */ -#define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */ -#define PITCH_EST_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */ - -/* Maximum number of subframes */ -#define MAX_NB_SUBFR 4 - -/* Number of samples per frame */ -#define LTP_MEM_LENGTH_MS 20 -#define SUB_FRAME_LENGTH_MS 5 -#define MAX_SUB_FRAME_LENGTH ( SUB_FRAME_LENGTH_MS * MAX_FS_KHZ ) -#define MAX_FRAME_LENGTH_MS ( SUB_FRAME_LENGTH_MS * MAX_NB_SUBFR ) -#define MAX_FRAME_LENGTH ( MAX_FRAME_LENGTH_MS * MAX_FS_KHZ ) - -/* Milliseconds of lookahead for pitch analysis */ -#define LA_PITCH_MS 2 -#define LA_PITCH_MAX ( LA_PITCH_MS * MAX_FS_KHZ ) - -/* Order of LPC used in find pitch */ -#define MAX_FIND_PITCH_LPC_ORDER 16 - -/* Length of LPC window used in find pitch */ -#define FIND_PITCH_LPC_WIN_MS ( 20 + (LA_PITCH_MS << 1) ) -#define FIND_PITCH_LPC_WIN_MS_2_SF ( 10 + (LA_PITCH_MS << 1) ) -#define FIND_PITCH_LPC_WIN_MAX ( FIND_PITCH_LPC_WIN_MS * MAX_FS_KHZ ) - -/* Milliseconds of lookahead for noise shape analysis */ -#define LA_SHAPE_MS 5 -#define LA_SHAPE_MAX ( LA_SHAPE_MS * MAX_FS_KHZ ) - -/* Maximum length of LPC window used in noise shape analysis */ -#define SHAPE_LPC_WIN_MAX ( 15 * MAX_FS_KHZ ) - -/* dB level of lowest gain quantization level */ -#define MIN_QGAIN_DB 2 -/* dB level of highest gain quantization level */ -#define MAX_QGAIN_DB 88 -/* Number of gain quantization levels */ -#define N_LEVELS_QGAIN 64 -/* Max increase in gain quantization index */ -#define MAX_DELTA_GAIN_QUANT 36 -/* Max decrease in gain quantization index */ -#define MIN_DELTA_GAIN_QUANT -4 - -/* Quantization offsets (multiples of 4) */ -#define OFFSET_VL_Q10 32 -#define OFFSET_VH_Q10 100 -#define OFFSET_UVL_Q10 100 -#define OFFSET_UVH_Q10 240 - -#define QUANT_LEVEL_ADJUST_Q10 80 - -/* Maximum numbers of iterations used to stabilize an LPC vector */ -#define MAX_LPC_STABILIZE_ITERATIONS 16 -#define MAX_PREDICTION_POWER_GAIN 1e4f -#define MAX_PREDICTION_POWER_GAIN_AFTER_RESET 1e2f - -#define MAX_LPC_ORDER 16 -#define MIN_LPC_ORDER 10 - -/* Find Pred Coef defines */ -#define LTP_ORDER 5 - -/* LTP quantization settings */ -#define NB_LTP_CBKS 3 - -/* Flag to use harmonic noise shaping */ -#define USE_HARM_SHAPING 1 - -/* Max LPC order of noise shaping filters */ -#define MAX_SHAPE_LPC_ORDER 24 - -#define HARM_SHAPE_FIR_TAPS 3 - -/* Maximum number of delayed decision states */ -#define MAX_DEL_DEC_STATES 4 - -#define LTP_BUF_LENGTH 512 -#define LTP_MASK ( LTP_BUF_LENGTH - 1 ) - -#define DECISION_DELAY 40 - -/* Number of subframes for excitation entropy coding */ -#define SHELL_CODEC_FRAME_LENGTH 16 -#define LOG2_SHELL_CODEC_FRAME_LENGTH 4 -#define MAX_NB_SHELL_BLOCKS ( MAX_FRAME_LENGTH / SHELL_CODEC_FRAME_LENGTH ) - -/* Number of rate levels, for entropy coding of excitation */ -#define N_RATE_LEVELS 10 - -/* Maximum sum of pulses per shell coding frame */ -#define SILK_MAX_PULSES 16 - -#define MAX_MATRIX_SIZE MAX_LPC_ORDER /* Max of LPC Order and LTP order */ - -# define NSQ_LPC_BUF_LENGTH MAX_LPC_ORDER - -/***************************/ -/* Voice activity detector */ -/***************************/ -#define VAD_N_BANDS 4 - -#define VAD_INTERNAL_SUBFRAMES_LOG2 2 -#define VAD_INTERNAL_SUBFRAMES ( 1 << VAD_INTERNAL_SUBFRAMES_LOG2 ) - -#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 1024 /* Must be < 4096 */ -#define VAD_NOISE_LEVELS_BIAS 50 - -/* Sigmoid settings */ -#define VAD_NEGATIVE_OFFSET_Q5 128 /* sigmoid is 0 at -128 */ -#define VAD_SNR_FACTOR_Q16 45000 - -/* smoothing for SNR measurement */ -#define VAD_SNR_SMOOTH_COEF_Q18 4096 - -/* Size of the piecewise linear cosine approximation table for the LSFs */ -#define LSF_COS_TAB_SZ_FIX 128 - -/******************/ -/* NLSF quantizer */ -/******************/ -#define NLSF_W_Q 2 -#define NLSF_VQ_MAX_VECTORS 32 -#define NLSF_QUANT_MAX_AMPLITUDE 4 -#define NLSF_QUANT_MAX_AMPLITUDE_EXT 10 -#define NLSF_QUANT_LEVEL_ADJ 0.1 -#define NLSF_QUANT_DEL_DEC_STATES_LOG2 2 -#define NLSF_QUANT_DEL_DEC_STATES ( 1 << NLSF_QUANT_DEL_DEC_STATES_LOG2 ) - -/* Transition filtering for mode switching */ -#define TRANSITION_TIME_MS 5120 /* 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)*/ -#define TRANSITION_NB 3 /* Hardcoded in tables */ -#define TRANSITION_NA 2 /* Hardcoded in tables */ -#define TRANSITION_INT_NUM 5 /* Hardcoded in tables */ -#define TRANSITION_FRAMES ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS ) -#define TRANSITION_INT_STEPS ( TRANSITION_FRAMES / ( TRANSITION_INT_NUM - 1 ) ) - -/* BWE factors to apply after packet loss */ -#define BWE_AFTER_LOSS_Q16 63570 - -/* Defines for CN generation */ -#define CNG_BUF_MASK_MAX 255 /* 2^floor(log2(MAX_FRAME_LENGTH))-1 */ -#define CNG_GAIN_SMTH_Q16 4634 /* 0.25^(1/4) */ -#define CNG_GAIN_SMTH_THRESHOLD_Q16 46396 /* -3 dB */ -#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/silk/enc_API.c b/Engine/lib/opus/silk/enc_API.c deleted file mode 100644 index 548e07364..000000000 --- a/Engine/lib/opus/silk/enc_API.c +++ /dev/null @@ -1,587 +0,0 @@ -/*********************************************************************** -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" -#endif -#include "define.h" -#include "API.h" -#include "control.h" -#include "typedef.h" -#include "stack_alloc.h" -#include "structs.h" -#include "tuning_parameters.h" -#ifdef FIXED_POINT -#include "main_FIX.h" -#else -#include "main_FLP.h" -#endif - -/***************************************/ -/* Read control structure from encoder */ -/***************************************/ -static opus_int silk_QueryEncoder( /* O Returns error code */ - const void *encState, /* I State */ - silk_EncControlStruct *encStatus /* O Encoder Status */ -); - -/****************************************/ -/* Encoder functions */ -/****************************************/ - -opus_int silk_Get_Encoder_Size( /* O Returns error code */ - opus_int *encSizeBytes /* O Number of bytes in SILK encoder state */ -) -{ - opus_int ret = SILK_NO_ERROR; - - *encSizeBytes = sizeof( silk_encoder ); - - return ret; -} - -/*************************/ -/* Init or Reset encoder */ -/*************************/ -opus_int silk_InitEncoder( /* O Returns error code */ - void *encState, /* I/O State */ - int arch, /* I Run-time architecture */ - silk_EncControlStruct *encStatus /* O Encoder Status */ -) -{ - silk_encoder *psEnc; - opus_int n, ret = SILK_NO_ERROR; - - psEnc = (silk_encoder *)encState; - - /* Reset encoder */ - silk_memset( psEnc, 0, sizeof( silk_encoder ) ); - for( n = 0; n < ENCODER_NUM_CHANNELS; n++ ) { - if( ret += silk_init_encoder( &psEnc->state_Fxx[ n ], arch ) ) { - celt_assert( 0 ); - } - } - - psEnc->nChannelsAPI = 1; - psEnc->nChannelsInternal = 1; - - /* Read control structure */ - if( ret += silk_QueryEncoder( encState, encStatus ) ) { - celt_assert( 0 ); - } - - return ret; -} - -/***************************************/ -/* Read control structure from encoder */ -/***************************************/ -static opus_int silk_QueryEncoder( /* O Returns error code */ - const void *encState, /* I State */ - silk_EncControlStruct *encStatus /* O Encoder Status */ -) -{ - opus_int ret = SILK_NO_ERROR; - silk_encoder_state_Fxx *state_Fxx; - silk_encoder *psEnc = (silk_encoder *)encState; - - state_Fxx = psEnc->state_Fxx; - - encStatus->nChannelsAPI = psEnc->nChannelsAPI; - encStatus->nChannelsInternal = psEnc->nChannelsInternal; - encStatus->API_sampleRate = state_Fxx[ 0 ].sCmn.API_fs_Hz; - encStatus->maxInternalSampleRate = state_Fxx[ 0 ].sCmn.maxInternal_fs_Hz; - encStatus->minInternalSampleRate = state_Fxx[ 0 ].sCmn.minInternal_fs_Hz; - encStatus->desiredInternalSampleRate = state_Fxx[ 0 ].sCmn.desiredInternal_fs_Hz; - encStatus->payloadSize_ms = state_Fxx[ 0 ].sCmn.PacketSize_ms; - encStatus->bitRate = state_Fxx[ 0 ].sCmn.TargetRate_bps; - encStatus->packetLossPercentage = state_Fxx[ 0 ].sCmn.PacketLoss_perc; - encStatus->complexity = state_Fxx[ 0 ].sCmn.Complexity; - encStatus->useInBandFEC = state_Fxx[ 0 ].sCmn.useInBandFEC; - encStatus->useDTX = state_Fxx[ 0 ].sCmn.useDTX; - encStatus->useCBR = state_Fxx[ 0 ].sCmn.useCBR; - encStatus->internalSampleRate = silk_SMULBB( state_Fxx[ 0 ].sCmn.fs_kHz, 1000 ); - encStatus->allowBandwidthSwitch = state_Fxx[ 0 ].sCmn.allow_bandwidth_switch; - encStatus->inWBmodeWithoutVariableLP = state_Fxx[ 0 ].sCmn.fs_kHz == 16 && state_Fxx[ 0 ].sCmn.sLP.mode == 0; - - return ret; -} - - -/**************************/ -/* Encode frame with Silk */ -/**************************/ -/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */ -/* encControl->payloadSize_ms is set to */ -opus_int silk_Encode( /* O Returns error code */ - void *encState, /* I/O State */ - silk_EncControlStruct *encControl, /* I Control status */ - const opus_int16 *samplesIn, /* I Speech sample input vector */ - opus_int nSamplesIn, /* I Number of samples in input vector */ - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int32 *nBytesOut, /* I/O Number of bytes in payload (input: Max bytes) */ - const opus_int prefillFlag, /* I Flag to indicate prefilling buffers no coding */ - opus_int activity /* I Decision of Opus voice activity detector */ -) -{ - opus_int n, i, nBits, flags, tmp_payloadSize_ms = 0, tmp_complexity = 0, ret = 0; - opus_int nSamplesToBuffer, nSamplesToBufferMax, nBlocksOf10ms; - opus_int nSamplesFromInput = 0, nSamplesFromInputMax; - opus_int speech_act_thr_for_switch_Q8; - opus_int32 TargetRate_bps, MStargetRates_bps[ 2 ], channelRate_bps, LBRR_symbol, sum; - silk_encoder *psEnc = ( silk_encoder * )encState; - VARDECL( opus_int16, buf ); - opus_int transition, curr_block, tot_blocks; - SAVE_STACK; - - if (encControl->reducedDependency) - { - psEnc->state_Fxx[0].sCmn.first_frame_after_reset = 1; - psEnc->state_Fxx[1].sCmn.first_frame_after_reset = 1; - } - psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded = psEnc->state_Fxx[ 1 ].sCmn.nFramesEncoded = 0; - - /* Check values in encoder control structure */ - if( ( ret = check_control_input( encControl ) ) != 0 ) { - celt_assert( 0 ); - RESTORE_STACK; - return ret; - } - - encControl->switchReady = 0; - - if( encControl->nChannelsInternal > psEnc->nChannelsInternal ) { - /* Mono -> Stereo transition: init state of second channel and stereo state */ - ret += silk_init_encoder( &psEnc->state_Fxx[ 1 ], psEnc->state_Fxx[ 0 ].sCmn.arch ); - silk_memset( psEnc->sStereo.pred_prev_Q13, 0, sizeof( psEnc->sStereo.pred_prev_Q13 ) ); - silk_memset( psEnc->sStereo.sSide, 0, sizeof( psEnc->sStereo.sSide ) ); - psEnc->sStereo.mid_side_amp_Q0[ 0 ] = 0; - psEnc->sStereo.mid_side_amp_Q0[ 1 ] = 1; - psEnc->sStereo.mid_side_amp_Q0[ 2 ] = 0; - psEnc->sStereo.mid_side_amp_Q0[ 3 ] = 1; - psEnc->sStereo.width_prev_Q14 = 0; - psEnc->sStereo.smth_width_Q14 = SILK_FIX_CONST( 1, 14 ); - if( psEnc->nChannelsAPI == 2 ) { - silk_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, sizeof( silk_resampler_state_struct ) ); - silk_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.In_HP_State, &psEnc->state_Fxx[ 0 ].sCmn.In_HP_State, sizeof( psEnc->state_Fxx[ 1 ].sCmn.In_HP_State ) ); - } - } - - transition = (encControl->payloadSize_ms != psEnc->state_Fxx[ 0 ].sCmn.PacketSize_ms) || (psEnc->nChannelsInternal != encControl->nChannelsInternal); - - psEnc->nChannelsAPI = encControl->nChannelsAPI; - psEnc->nChannelsInternal = encControl->nChannelsInternal; - - nBlocksOf10ms = silk_DIV32( 100 * nSamplesIn, encControl->API_sampleRate ); - tot_blocks = ( nBlocksOf10ms > 1 ) ? nBlocksOf10ms >> 1 : 1; - curr_block = 0; - if( prefillFlag ) { - silk_LP_state save_LP; - /* Only accept input length of 10 ms */ - if( nBlocksOf10ms != 1 ) { - celt_assert( 0 ); - RESTORE_STACK; - return SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; - } - if ( prefillFlag == 2 ) { - save_LP = psEnc->state_Fxx[ 0 ].sCmn.sLP; - /* Save the sampling rate so the bandwidth switching code can keep handling transitions. */ - save_LP.saved_fs_kHz = psEnc->state_Fxx[ 0 ].sCmn.fs_kHz; - } - /* Reset Encoder */ - for( n = 0; n < encControl->nChannelsInternal; n++ ) { - ret = silk_init_encoder( &psEnc->state_Fxx[ n ], psEnc->state_Fxx[ n ].sCmn.arch ); - /* Restore the variable LP state. */ - if ( prefillFlag == 2 ) { - psEnc->state_Fxx[ n ].sCmn.sLP = save_LP; - } - celt_assert( !ret ); - } - tmp_payloadSize_ms = encControl->payloadSize_ms; - encControl->payloadSize_ms = 10; - tmp_complexity = encControl->complexity; - encControl->complexity = 0; - for( n = 0; n < encControl->nChannelsInternal; n++ ) { - psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; - psEnc->state_Fxx[ n ].sCmn.prefillFlag = 1; - } - } else { - /* Only accept input lengths that are a multiple of 10 ms */ - if( nBlocksOf10ms * encControl->API_sampleRate != 100 * nSamplesIn || nSamplesIn < 0 ) { - celt_assert( 0 ); - RESTORE_STACK; - return SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; - } - /* Make sure no more than one packet can be produced */ - if( 1000 * (opus_int32)nSamplesIn > encControl->payloadSize_ms * encControl->API_sampleRate ) { - celt_assert( 0 ); - RESTORE_STACK; - return SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; - } - } - - for( n = 0; n < encControl->nChannelsInternal; n++ ) { - /* Force the side channel to the same rate as the mid */ - opus_int force_fs_kHz = (n==1) ? psEnc->state_Fxx[0].sCmn.fs_kHz : 0; - if( ( ret = silk_control_encoder( &psEnc->state_Fxx[ n ], encControl, psEnc->allowBandwidthSwitch, n, force_fs_kHz ) ) != 0 ) { - silk_assert( 0 ); - RESTORE_STACK; - return ret; - } - if( psEnc->state_Fxx[n].sCmn.first_frame_after_reset || transition ) { - for( i = 0; i < psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket; i++ ) { - psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ] = 0; - } - } - psEnc->state_Fxx[ n ].sCmn.inDTX = psEnc->state_Fxx[ n ].sCmn.useDTX; - } - celt_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->state_Fxx[ 1 ].sCmn.fs_kHz ); - - /* Input buffering/resampling and encoding */ - nSamplesToBufferMax = - 10 * nBlocksOf10ms * psEnc->state_Fxx[ 0 ].sCmn.fs_kHz; - nSamplesFromInputMax = - silk_DIV32_16( nSamplesToBufferMax * - psEnc->state_Fxx[ 0 ].sCmn.API_fs_Hz, - psEnc->state_Fxx[ 0 ].sCmn.fs_kHz * 1000 ); - ALLOC( buf, nSamplesFromInputMax, opus_int16 ); - while( 1 ) { - int curr_nBitsUsedLBRR = 0; - nSamplesToBuffer = psEnc->state_Fxx[ 0 ].sCmn.frame_length - psEnc->state_Fxx[ 0 ].sCmn.inputBufIx; - nSamplesToBuffer = silk_min( nSamplesToBuffer, nSamplesToBufferMax ); - nSamplesFromInput = silk_DIV32_16( nSamplesToBuffer * psEnc->state_Fxx[ 0 ].sCmn.API_fs_Hz, psEnc->state_Fxx[ 0 ].sCmn.fs_kHz * 1000 ); - /* Resample and write to buffer */ - if( encControl->nChannelsAPI == 2 && encControl->nChannelsInternal == 2 ) { - opus_int id = psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded; - for( n = 0; n < nSamplesFromInput; n++ ) { - buf[ n ] = samplesIn[ 2 * n ]; - } - /* Making sure to start both resamplers from the same state when switching from mono to stereo */ - if( psEnc->nPrevChannelsInternal == 1 && id==0 ) { - silk_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, sizeof(psEnc->state_Fxx[ 1 ].sCmn.resampler_state)); - } - - ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, - &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); - psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; - - nSamplesToBuffer = psEnc->state_Fxx[ 1 ].sCmn.frame_length - psEnc->state_Fxx[ 1 ].sCmn.inputBufIx; - nSamplesToBuffer = silk_min( nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc->state_Fxx[ 1 ].sCmn.fs_kHz ); - for( n = 0; n < nSamplesFromInput; n++ ) { - buf[ n ] = samplesIn[ 2 * n + 1 ]; - } - ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, - &psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); - - psEnc->state_Fxx[ 1 ].sCmn.inputBufIx += nSamplesToBuffer; - } else if( encControl->nChannelsAPI == 2 && encControl->nChannelsInternal == 1 ) { - /* Combine left and right channels before resampling */ - for( n = 0; n < nSamplesFromInput; n++ ) { - sum = samplesIn[ 2 * n ] + samplesIn[ 2 * n + 1 ]; - buf[ n ] = (opus_int16)silk_RSHIFT_ROUND( sum, 1 ); - } - ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, - &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); - /* On the first mono frame, average the results for the two resampler states */ - if( psEnc->nPrevChannelsInternal == 2 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == 0 ) { - ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, - &psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); - for( n = 0; n < psEnc->state_Fxx[ 0 ].sCmn.frame_length; n++ ) { - psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx+n+2 ] = - silk_RSHIFT(psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx+n+2 ] - + psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx+n+2 ], 1); - } - } - psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; - } else { - celt_assert( encControl->nChannelsAPI == 1 && encControl->nChannelsInternal == 1 ); - silk_memcpy(buf, samplesIn, nSamplesFromInput*sizeof(opus_int16)); - ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, - &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); - psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; - } - - samplesIn += nSamplesFromInput * encControl->nChannelsAPI; - nSamplesIn -= nSamplesFromInput; - - /* Default */ - psEnc->allowBandwidthSwitch = 0; - - /* Silk encoder */ - if( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx >= psEnc->state_Fxx[ 0 ].sCmn.frame_length ) { - /* Enough data in input buffer, so encode */ - celt_assert( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx == psEnc->state_Fxx[ 0 ].sCmn.frame_length ); - celt_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 1 ].sCmn.inputBufIx == psEnc->state_Fxx[ 1 ].sCmn.frame_length ); - - /* Deal with LBRR data */ - if( psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == 0 && !prefillFlag ) { - /* Create space at start of payload for VAD and FEC flags */ - opus_uint8 iCDF[ 2 ] = { 0, 0 }; - iCDF[ 0 ] = 256 - silk_RSHIFT( 256, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannelsInternal ); - ec_enc_icdf( psRangeEnc, 0, iCDF, 8 ); - curr_nBitsUsedLBRR = ec_tell( psRangeEnc ); - - /* Encode any LBRR data from previous packet */ - /* Encode LBRR flags */ - for( n = 0; n < encControl->nChannelsInternal; n++ ) { - LBRR_symbol = 0; - for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) { - LBRR_symbol |= silk_LSHIFT( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ], i ); - } - psEnc->state_Fxx[ n ].sCmn.LBRR_flag = LBRR_symbol > 0 ? 1 : 0; - if( LBRR_symbol && psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket > 1 ) { - ec_enc_icdf( psRangeEnc, LBRR_symbol - 1, silk_LBRR_flags_iCDF_ptr[ psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket - 2 ], 8 ); - } - } - - /* Code LBRR indices and excitation signals */ - for( i = 0; i < psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket; i++ ) { - for( n = 0; n < encControl->nChannelsInternal; n++ ) { - if( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ] ) { - opus_int condCoding; - - if( encControl->nChannelsInternal == 2 && n == 0 ) { - silk_stereo_encode_pred( psRangeEnc, psEnc->sStereo.predIx[ i ] ); - /* For LBRR data there's no need to code the mid-only flag if the side-channel LBRR flag is set */ - if( psEnc->state_Fxx[ 1 ].sCmn.LBRR_flags[ i ] == 0 ) { - silk_stereo_encode_mid_only( psRangeEnc, psEnc->sStereo.mid_only_flags[ i ] ); - } - } - /* Use conditional coding if previous frame available */ - if( i > 0 && psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i - 1 ] ) { - condCoding = CODE_CONDITIONALLY; - } else { - condCoding = CODE_INDEPENDENTLY; - } - silk_encode_indices( &psEnc->state_Fxx[ n ].sCmn, psRangeEnc, i, 1, condCoding ); - silk_encode_pulses( psRangeEnc, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].signalType, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].quantOffsetType, - psEnc->state_Fxx[ n ].sCmn.pulses_LBRR[ i ], psEnc->state_Fxx[ n ].sCmn.frame_length ); - } - } - } - - /* Reset LBRR flags */ - for( n = 0; n < encControl->nChannelsInternal; n++ ) { - silk_memset( psEnc->state_Fxx[ n ].sCmn.LBRR_flags, 0, sizeof( psEnc->state_Fxx[ n ].sCmn.LBRR_flags ) ); - } - curr_nBitsUsedLBRR = ec_tell( psRangeEnc ) - curr_nBitsUsedLBRR; - } - - silk_HP_variable_cutoff( psEnc->state_Fxx ); - - /* Total target bits for packet */ - nBits = silk_DIV32_16( silk_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 ); - /* Subtract bits used for LBRR */ - if( !prefillFlag ) { - /* psEnc->nBitsUsedLBRR is an exponential moving average of the LBRR usage, - except that for the first LBRR frame it does no averaging and for the first - frame after after LBRR, it goes back to zero immediately. */ - if ( curr_nBitsUsedLBRR < 10 ) { - psEnc->nBitsUsedLBRR = 0; - } else if ( psEnc->nBitsUsedLBRR < 10) { - psEnc->nBitsUsedLBRR = curr_nBitsUsedLBRR; - } else { - psEnc->nBitsUsedLBRR = ( psEnc->nBitsUsedLBRR + curr_nBitsUsedLBRR ) / 2; - } - nBits -= psEnc->nBitsUsedLBRR; - } - /* Divide by number of uncoded frames left in packet */ - nBits = silk_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket ); - /* Convert to bits/second */ - if( encControl->payloadSize_ms == 10 ) { - TargetRate_bps = silk_SMULBB( nBits, 100 ); - } else { - TargetRate_bps = silk_SMULBB( nBits, 50 ); - } - /* Subtract fraction of bits in excess of target in previous frames and packets */ - TargetRate_bps -= silk_DIV32_16( silk_MUL( psEnc->nBitsExceeded, 1000 ), BITRESERVOIR_DECAY_TIME_MS ); - if( !prefillFlag && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded > 0 ) { - /* Compare actual vs target bits so far in this packet */ - opus_int32 bitsBalance = ec_tell( psRangeEnc ) - psEnc->nBitsUsedLBRR - nBits * psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded; - TargetRate_bps -= silk_DIV32_16( silk_MUL( bitsBalance, 1000 ), BITRESERVOIR_DECAY_TIME_MS ); - } - /* Never exceed input bitrate */ - TargetRate_bps = silk_LIMIT( TargetRate_bps, encControl->bitRate, 5000 ); - - /* Convert Left/Right to Mid/Side */ - if( encControl->nChannelsInternal == 2 ) { - silk_stereo_LR_to_MS( &psEnc->sStereo, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ 2 ], &psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ 2 ], - psEnc->sStereo.predIx[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ], &psEnc->sStereo.mid_only_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ], - MStargetRates_bps, TargetRate_bps, psEnc->state_Fxx[ 0 ].sCmn.speech_activity_Q8, encControl->toMono, - psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length ); - if( psEnc->sStereo.mid_only_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] == 0 ) { - /* Reset side channel encoder memory for first frame with side coding */ - if( psEnc->prev_decode_only_middle == 1 ) { - silk_memset( &psEnc->state_Fxx[ 1 ].sShape, 0, sizeof( psEnc->state_Fxx[ 1 ].sShape ) ); - silk_memset( &psEnc->state_Fxx[ 1 ].sCmn.sNSQ, 0, sizeof( psEnc->state_Fxx[ 1 ].sCmn.sNSQ ) ); - silk_memset( psEnc->state_Fxx[ 1 ].sCmn.prev_NLSFq_Q15, 0, sizeof( psEnc->state_Fxx[ 1 ].sCmn.prev_NLSFq_Q15 ) ); - silk_memset( &psEnc->state_Fxx[ 1 ].sCmn.sLP.In_LP_State, 0, sizeof( psEnc->state_Fxx[ 1 ].sCmn.sLP.In_LP_State ) ); - psEnc->state_Fxx[ 1 ].sCmn.prevLag = 100; - psEnc->state_Fxx[ 1 ].sCmn.sNSQ.lagPrev = 100; - psEnc->state_Fxx[ 1 ].sShape.LastGainIndex = 10; - psEnc->state_Fxx[ 1 ].sCmn.prevSignalType = TYPE_NO_VOICE_ACTIVITY; - psEnc->state_Fxx[ 1 ].sCmn.sNSQ.prev_gain_Q16 = 65536; - psEnc->state_Fxx[ 1 ].sCmn.first_frame_after_reset = 1; - } - silk_encode_do_VAD_Fxx( &psEnc->state_Fxx[ 1 ], activity ); - } else { - psEnc->state_Fxx[ 1 ].sCmn.VAD_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] = 0; - } - if( !prefillFlag ) { - silk_stereo_encode_pred( psRangeEnc, psEnc->sStereo.predIx[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] ); - if( psEnc->state_Fxx[ 1 ].sCmn.VAD_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] == 0 ) { - silk_stereo_encode_mid_only( psRangeEnc, psEnc->sStereo.mid_only_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] ); - } - } - } else { - /* Buffering */ - silk_memcpy( psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->sStereo.sMid, 2 * sizeof( opus_int16 ) ); - silk_memcpy( psEnc->sStereo.sMid, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.frame_length ], 2 * sizeof( opus_int16 ) ); - } - silk_encode_do_VAD_Fxx( &psEnc->state_Fxx[ 0 ], activity ); - - /* Encode */ - for( n = 0; n < encControl->nChannelsInternal; n++ ) { - opus_int maxBits, useCBR; - - /* Handling rate constraints */ - maxBits = encControl->maxBits; - if( tot_blocks == 2 && curr_block == 0 ) { - maxBits = maxBits * 3 / 5; - } else if( tot_blocks == 3 ) { - if( curr_block == 0 ) { - maxBits = maxBits * 2 / 5; - } else if( curr_block == 1 ) { - maxBits = maxBits * 3 / 4; - } - } - useCBR = encControl->useCBR && curr_block == tot_blocks - 1; - - if( encControl->nChannelsInternal == 1 ) { - channelRate_bps = TargetRate_bps; - } else { - channelRate_bps = MStargetRates_bps[ n ]; - if( n == 0 && MStargetRates_bps[ 1 ] > 0 ) { - useCBR = 0; - /* Give mid up to 1/2 of the max bits for that frame */ - maxBits -= encControl->maxBits / ( tot_blocks * 2 ); - } - } - - if( channelRate_bps > 0 ) { - opus_int condCoding; - - silk_control_SNR( &psEnc->state_Fxx[ n ].sCmn, channelRate_bps ); - - /* Use independent coding if no previous frame available */ - if( psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded - n <= 0 ) { - condCoding = CODE_INDEPENDENTLY; - } else if( n > 0 && psEnc->prev_decode_only_middle ) { - /* If we skipped a side frame in this packet, we don't - need LTP scaling; the LTP state is well-defined. */ - condCoding = CODE_INDEPENDENTLY_NO_LTP_SCALING; - } else { - condCoding = CODE_CONDITIONALLY; - } - if( ( ret = silk_encode_frame_Fxx( &psEnc->state_Fxx[ n ], nBytesOut, psRangeEnc, condCoding, maxBits, useCBR ) ) != 0 ) { - silk_assert( 0 ); - } - } - psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; - psEnc->state_Fxx[ n ].sCmn.inputBufIx = 0; - psEnc->state_Fxx[ n ].sCmn.nFramesEncoded++; - } - psEnc->prev_decode_only_middle = psEnc->sStereo.mid_only_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded - 1 ]; - - /* Insert VAD and FEC flags at beginning of bitstream */ - if( *nBytesOut > 0 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket) { - flags = 0; - for( n = 0; n < encControl->nChannelsInternal; n++ ) { - for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) { - flags = silk_LSHIFT( flags, 1 ); - flags |= psEnc->state_Fxx[ n ].sCmn.VAD_flags[ i ]; - } - flags = silk_LSHIFT( flags, 1 ); - flags |= psEnc->state_Fxx[ n ].sCmn.LBRR_flag; - } - if( !prefillFlag ) { - ec_enc_patch_initial_bits( psRangeEnc, flags, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannelsInternal ); - } - - /* Return zero bytes if all channels DTXed */ - if( psEnc->state_Fxx[ 0 ].sCmn.inDTX && ( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 1 ].sCmn.inDTX ) ) { - *nBytesOut = 0; - } - - psEnc->nBitsExceeded += *nBytesOut * 8; - psEnc->nBitsExceeded -= silk_DIV32_16( silk_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 ); - psEnc->nBitsExceeded = silk_LIMIT( psEnc->nBitsExceeded, 0, 10000 ); - - /* Update flag indicating if bandwidth switching is allowed */ - speech_act_thr_for_switch_Q8 = silk_SMLAWB( SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ), - SILK_FIX_CONST( ( 1 - SPEECH_ACTIVITY_DTX_THRES ) / MAX_BANDWIDTH_SWITCH_DELAY_MS, 16 + 8 ), psEnc->timeSinceSwitchAllowed_ms ); - if( psEnc->state_Fxx[ 0 ].sCmn.speech_activity_Q8 < speech_act_thr_for_switch_Q8 ) { - psEnc->allowBandwidthSwitch = 1; - psEnc->timeSinceSwitchAllowed_ms = 0; - } else { - psEnc->allowBandwidthSwitch = 0; - psEnc->timeSinceSwitchAllowed_ms += encControl->payloadSize_ms; - } - } - - if( nSamplesIn == 0 ) { - break; - } - } else { - break; - } - curr_block++; - } - - psEnc->nPrevChannelsInternal = encControl->nChannelsInternal; - - encControl->allowBandwidthSwitch = psEnc->allowBandwidthSwitch; - encControl->inWBmodeWithoutVariableLP = psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == 16 && psEnc->state_Fxx[ 0 ].sCmn.sLP.mode == 0; - encControl->internalSampleRate = silk_SMULBB( psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, 1000 ); - encControl->stereoWidth_Q14 = encControl->toMono ? 0 : psEnc->sStereo.smth_width_Q14; - if( prefillFlag ) { - encControl->payloadSize_ms = tmp_payloadSize_ms; - encControl->complexity = tmp_complexity; - for( n = 0; n < encControl->nChannelsInternal; n++ ) { - psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; - psEnc->state_Fxx[ n ].sCmn.prefillFlag = 0; - } - } - - encControl->signalType = psEnc->state_Fxx[0].sCmn.indices.signalType; - encControl->offset = silk_Quantization_Offsets_Q10 - [ psEnc->state_Fxx[0].sCmn.indices.signalType >> 1 ] - [ psEnc->state_Fxx[0].sCmn.indices.quantOffsetType ]; - RESTORE_STACK; - return ret; -} - diff --git a/Engine/lib/opus/silk/encode_indices.c b/Engine/lib/opus/silk/encode_indices.c deleted file mode 100644 index 4bcbc3347..000000000 --- a/Engine/lib/opus/silk/encode_indices.c +++ /dev/null @@ -1,181 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Encode side-information parameters to payload */ -void silk_encode_indices( - silk_encoder_state *psEncC, /* I/O Encoder state */ - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int FrameIndex, /* I Frame number */ - opus_int encode_LBRR, /* I Flag indicating LBRR data is being encoded */ - opus_int condCoding /* I The type of conditional coding to use */ -) -{ - opus_int i, k, typeOffset; - opus_int encode_absolute_lagIndex, delta_lagIndex; - opus_int16 ec_ix[ MAX_LPC_ORDER ]; - opus_uint8 pred_Q8[ MAX_LPC_ORDER ]; - const SideInfoIndices *psIndices; - - if( encode_LBRR ) { - psIndices = &psEncC->indices_LBRR[ FrameIndex ]; - } else { - psIndices = &psEncC->indices; - } - - /*******************************************/ - /* Encode signal type and quantizer offset */ - /*******************************************/ - typeOffset = 2 * psIndices->signalType + psIndices->quantOffsetType; - celt_assert( typeOffset >= 0 && typeOffset < 6 ); - celt_assert( encode_LBRR == 0 || typeOffset >= 2 ); - if( encode_LBRR || typeOffset >= 2 ) { - ec_enc_icdf( psRangeEnc, typeOffset - 2, silk_type_offset_VAD_iCDF, 8 ); - } else { - ec_enc_icdf( psRangeEnc, typeOffset, silk_type_offset_no_VAD_iCDF, 8 ); - } - - /****************/ - /* Encode gains */ - /****************/ - /* first subframe */ - if( condCoding == CODE_CONDITIONALLY ) { - /* conditional coding */ - silk_assert( psIndices->GainsIndices[ 0 ] >= 0 && psIndices->GainsIndices[ 0 ] < MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ); - ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ 0 ], silk_delta_gain_iCDF, 8 ); - } else { - /* independent coding, in two stages: MSB bits followed by 3 LSBs */ - silk_assert( psIndices->GainsIndices[ 0 ] >= 0 && psIndices->GainsIndices[ 0 ] < N_LEVELS_QGAIN ); - ec_enc_icdf( psRangeEnc, silk_RSHIFT( psIndices->GainsIndices[ 0 ], 3 ), silk_gain_iCDF[ psIndices->signalType ], 8 ); - ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ 0 ] & 7, silk_uniform8_iCDF, 8 ); - } - - /* remaining subframes */ - for( i = 1; i < psEncC->nb_subfr; i++ ) { - silk_assert( psIndices->GainsIndices[ i ] >= 0 && psIndices->GainsIndices[ i ] < MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ); - ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ i ], silk_delta_gain_iCDF, 8 ); - } - - /****************/ - /* Encode NLSFs */ - /****************/ - ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ 0 ], &psEncC->psNLSF_CB->CB1_iCDF[ ( psIndices->signalType >> 1 ) * psEncC->psNLSF_CB->nVectors ], 8 ); - silk_NLSF_unpack( ec_ix, pred_Q8, psEncC->psNLSF_CB, psIndices->NLSFIndices[ 0 ] ); - celt_assert( psEncC->psNLSF_CB->order == psEncC->predictLPCOrder ); - for( i = 0; i < psEncC->psNLSF_CB->order; i++ ) { - if( psIndices->NLSFIndices[ i+1 ] >= NLSF_QUANT_MAX_AMPLITUDE ) { - ec_enc_icdf( psRangeEnc, 2 * NLSF_QUANT_MAX_AMPLITUDE, &psEncC->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 ); - ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ i+1 ] - NLSF_QUANT_MAX_AMPLITUDE, silk_NLSF_EXT_iCDF, 8 ); - } else if( psIndices->NLSFIndices[ i+1 ] <= -NLSF_QUANT_MAX_AMPLITUDE ) { - ec_enc_icdf( psRangeEnc, 0, &psEncC->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 ); - ec_enc_icdf( psRangeEnc, -psIndices->NLSFIndices[ i+1 ] - NLSF_QUANT_MAX_AMPLITUDE, silk_NLSF_EXT_iCDF, 8 ); - } else { - ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ i+1 ] + NLSF_QUANT_MAX_AMPLITUDE, &psEncC->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 ); - } - } - - /* Encode NLSF interpolation factor */ - if( psEncC->nb_subfr == MAX_NB_SUBFR ) { - silk_assert( psIndices->NLSFInterpCoef_Q2 >= 0 && psIndices->NLSFInterpCoef_Q2 < 5 ); - ec_enc_icdf( psRangeEnc, psIndices->NLSFInterpCoef_Q2, silk_NLSF_interpolation_factor_iCDF, 8 ); - } - - if( psIndices->signalType == TYPE_VOICED ) - { - /*********************/ - /* Encode pitch lags */ - /*********************/ - /* lag index */ - encode_absolute_lagIndex = 1; - if( condCoding == CODE_CONDITIONALLY && psEncC->ec_prevSignalType == TYPE_VOICED ) { - /* Delta Encoding */ - delta_lagIndex = psIndices->lagIndex - psEncC->ec_prevLagIndex; - if( delta_lagIndex < -8 || delta_lagIndex > 11 ) { - delta_lagIndex = 0; - } else { - delta_lagIndex = delta_lagIndex + 9; - encode_absolute_lagIndex = 0; /* Only use delta */ - } - silk_assert( delta_lagIndex >= 0 && delta_lagIndex < 21 ); - ec_enc_icdf( psRangeEnc, delta_lagIndex, silk_pitch_delta_iCDF, 8 ); - } - if( encode_absolute_lagIndex ) { - /* Absolute encoding */ - opus_int32 pitch_high_bits, pitch_low_bits; - pitch_high_bits = silk_DIV32_16( psIndices->lagIndex, silk_RSHIFT( psEncC->fs_kHz, 1 ) ); - pitch_low_bits = psIndices->lagIndex - silk_SMULBB( pitch_high_bits, silk_RSHIFT( psEncC->fs_kHz, 1 ) ); - silk_assert( pitch_low_bits < psEncC->fs_kHz / 2 ); - silk_assert( pitch_high_bits < 32 ); - ec_enc_icdf( psRangeEnc, pitch_high_bits, silk_pitch_lag_iCDF, 8 ); - ec_enc_icdf( psRangeEnc, pitch_low_bits, psEncC->pitch_lag_low_bits_iCDF, 8 ); - } - psEncC->ec_prevLagIndex = psIndices->lagIndex; - - /* Countour index */ - silk_assert( psIndices->contourIndex >= 0 ); - silk_assert( ( psIndices->contourIndex < 34 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 4 ) || - ( psIndices->contourIndex < 11 && psEncC->fs_kHz == 8 && psEncC->nb_subfr == 4 ) || - ( psIndices->contourIndex < 12 && psEncC->fs_kHz > 8 && psEncC->nb_subfr == 2 ) || - ( psIndices->contourIndex < 3 && psEncC->fs_kHz == 8 && psEncC->nb_subfr == 2 ) ); - ec_enc_icdf( psRangeEnc, psIndices->contourIndex, psEncC->pitch_contour_iCDF, 8 ); - - /********************/ - /* Encode LTP gains */ - /********************/ - /* PERIndex value */ - silk_assert( psIndices->PERIndex >= 0 && psIndices->PERIndex < 3 ); - ec_enc_icdf( psRangeEnc, psIndices->PERIndex, silk_LTP_per_index_iCDF, 8 ); - - /* Codebook Indices */ - for( k = 0; k < psEncC->nb_subfr; k++ ) { - silk_assert( psIndices->LTPIndex[ k ] >= 0 && psIndices->LTPIndex[ k ] < ( 8 << psIndices->PERIndex ) ); - ec_enc_icdf( psRangeEnc, psIndices->LTPIndex[ k ], silk_LTP_gain_iCDF_ptrs[ psIndices->PERIndex ], 8 ); - } - - /**********************/ - /* Encode LTP scaling */ - /**********************/ - if( condCoding == CODE_INDEPENDENTLY ) { - silk_assert( psIndices->LTP_scaleIndex >= 0 && psIndices->LTP_scaleIndex < 3 ); - ec_enc_icdf( psRangeEnc, psIndices->LTP_scaleIndex, silk_LTPscale_iCDF, 8 ); - } - silk_assert( !condCoding || psIndices->LTP_scaleIndex == 0 ); - } - - psEncC->ec_prevSignalType = psIndices->signalType; - - /***************/ - /* Encode seed */ - /***************/ - silk_assert( psIndices->Seed >= 0 && psIndices->Seed < 4 ); - ec_enc_icdf( psRangeEnc, psIndices->Seed, silk_uniform4_iCDF, 8 ); -} diff --git a/Engine/lib/opus/silk/encode_pulses.c b/Engine/lib/opus/silk/encode_pulses.c deleted file mode 100644 index 8a1999138..000000000 --- a/Engine/lib/opus/silk/encode_pulses.c +++ /dev/null @@ -1,206 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" - -/*********************************************/ -/* Encode quantization indices of excitation */ -/*********************************************/ - -static OPUS_INLINE opus_int combine_and_check( /* return ok */ - opus_int *pulses_comb, /* O */ - const opus_int *pulses_in, /* I */ - opus_int max_pulses, /* I max value for sum of pulses */ - opus_int len /* I number of output values */ -) -{ - opus_int k, sum; - - for( k = 0; k < len; k++ ) { - sum = pulses_in[ 2 * k ] + pulses_in[ 2 * k + 1 ]; - if( sum > max_pulses ) { - return 1; - } - pulses_comb[ k ] = sum; - } - - return 0; -} - -/* Encode quantization indices of excitation */ -void silk_encode_pulses( - ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I quantOffsetType */ - opus_int8 pulses[], /* I quantization indices */ - const opus_int frame_length /* I Frame length */ -) -{ - opus_int i, k, j, iter, bit, nLS, scale_down, RateLevelIndex = 0; - opus_int32 abs_q, minSumBits_Q5, sumBits_Q5; - VARDECL( opus_int, abs_pulses ); - VARDECL( opus_int, sum_pulses ); - VARDECL( opus_int, nRshifts ); - opus_int pulses_comb[ 8 ]; - opus_int *abs_pulses_ptr; - const opus_int8 *pulses_ptr; - const opus_uint8 *cdf_ptr; - const opus_uint8 *nBits_ptr; - SAVE_STACK; - - silk_memset( pulses_comb, 0, 8 * sizeof( opus_int ) ); /* Fixing Valgrind reported problem*/ - - /****************************/ - /* Prepare for shell coding */ - /****************************/ - /* Calculate number of shell blocks */ - silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH ); - iter = silk_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH ); - if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ) { - celt_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */ - iter++; - silk_memset( &pulses[ frame_length ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof(opus_int8)); - } - - /* Take the absolute value of the pulses */ - ALLOC( abs_pulses, iter * SHELL_CODEC_FRAME_LENGTH, opus_int ); - silk_assert( !( SHELL_CODEC_FRAME_LENGTH & 3 ) ); - for( i = 0; i < iter * SHELL_CODEC_FRAME_LENGTH; i+=4 ) { - abs_pulses[i+0] = ( opus_int )silk_abs( pulses[ i + 0 ] ); - abs_pulses[i+1] = ( opus_int )silk_abs( pulses[ i + 1 ] ); - abs_pulses[i+2] = ( opus_int )silk_abs( pulses[ i + 2 ] ); - abs_pulses[i+3] = ( opus_int )silk_abs( pulses[ i + 3 ] ); - } - - /* Calc sum pulses per shell code frame */ - ALLOC( sum_pulses, iter, opus_int ); - ALLOC( nRshifts, iter, opus_int ); - abs_pulses_ptr = abs_pulses; - for( i = 0; i < iter; i++ ) { - nRshifts[ i ] = 0; - - while( 1 ) { - /* 1+1 -> 2 */ - scale_down = combine_and_check( pulses_comb, abs_pulses_ptr, silk_max_pulses_table[ 0 ], 8 ); - /* 2+2 -> 4 */ - scale_down += combine_and_check( pulses_comb, pulses_comb, silk_max_pulses_table[ 1 ], 4 ); - /* 4+4 -> 8 */ - scale_down += combine_and_check( pulses_comb, pulses_comb, silk_max_pulses_table[ 2 ], 2 ); - /* 8+8 -> 16 */ - scale_down += combine_and_check( &sum_pulses[ i ], pulses_comb, silk_max_pulses_table[ 3 ], 1 ); - - if( scale_down ) { - /* We need to downscale the quantization signal */ - nRshifts[ i ]++; - for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) { - abs_pulses_ptr[ k ] = silk_RSHIFT( abs_pulses_ptr[ k ], 1 ); - } - } else { - /* Jump out of while(1) loop and go to next shell coding frame */ - break; - } - } - abs_pulses_ptr += SHELL_CODEC_FRAME_LENGTH; - } - - /**************/ - /* Rate level */ - /**************/ - /* find rate level that leads to fewest bits for coding of pulses per block info */ - minSumBits_Q5 = silk_int32_MAX; - for( k = 0; k < N_RATE_LEVELS - 1; k++ ) { - nBits_ptr = silk_pulses_per_block_BITS_Q5[ k ]; - sumBits_Q5 = silk_rate_levels_BITS_Q5[ signalType >> 1 ][ k ]; - for( i = 0; i < iter; i++ ) { - if( nRshifts[ i ] > 0 ) { - sumBits_Q5 += nBits_ptr[ SILK_MAX_PULSES + 1 ]; - } else { - sumBits_Q5 += nBits_ptr[ sum_pulses[ i ] ]; - } - } - if( sumBits_Q5 < minSumBits_Q5 ) { - minSumBits_Q5 = sumBits_Q5; - RateLevelIndex = k; - } - } - ec_enc_icdf( psRangeEnc, RateLevelIndex, silk_rate_levels_iCDF[ signalType >> 1 ], 8 ); - - /***************************************************/ - /* Sum-Weighted-Pulses Encoding */ - /***************************************************/ - cdf_ptr = silk_pulses_per_block_iCDF[ RateLevelIndex ]; - for( i = 0; i < iter; i++ ) { - if( nRshifts[ i ] == 0 ) { - ec_enc_icdf( psRangeEnc, sum_pulses[ i ], cdf_ptr, 8 ); - } else { - ec_enc_icdf( psRangeEnc, SILK_MAX_PULSES + 1, cdf_ptr, 8 ); - for( k = 0; k < nRshifts[ i ] - 1; k++ ) { - ec_enc_icdf( psRangeEnc, SILK_MAX_PULSES + 1, silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); - } - ec_enc_icdf( psRangeEnc, sum_pulses[ i ], silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); - } - } - - /******************/ - /* Shell Encoding */ - /******************/ - for( i = 0; i < iter; i++ ) { - if( sum_pulses[ i ] > 0 ) { - silk_shell_encoder( psRangeEnc, &abs_pulses[ i * SHELL_CODEC_FRAME_LENGTH ] ); - } - } - - /****************/ - /* LSB Encoding */ - /****************/ - for( i = 0; i < iter; i++ ) { - if( nRshifts[ i ] > 0 ) { - pulses_ptr = &pulses[ i * SHELL_CODEC_FRAME_LENGTH ]; - nLS = nRshifts[ i ] - 1; - for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) { - abs_q = (opus_int8)silk_abs( pulses_ptr[ k ] ); - for( j = nLS; j > 0; j-- ) { - bit = silk_RSHIFT( abs_q, j ) & 1; - ec_enc_icdf( psRangeEnc, bit, silk_lsb_iCDF, 8 ); - } - bit = abs_q & 1; - ec_enc_icdf( psRangeEnc, bit, silk_lsb_iCDF, 8 ); - } - } - } - - /****************/ - /* Encode signs */ - /****************/ - silk_encode_signs( psRangeEnc, pulses, frame_length, signalType, quantOffsetType, sum_pulses ); - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/errors.h b/Engine/lib/opus/silk/errors.h deleted file mode 100644 index 45070800f..000000000 --- a/Engine/lib/opus/silk/errors.h +++ /dev/null @@ -1,98 +0,0 @@ -/*********************************************************************** -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 SILK_ERRORS_H -#define SILK_ERRORS_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/******************/ -/* Error messages */ -/******************/ -#define SILK_NO_ERROR 0 - -/**************************/ -/* Encoder error messages */ -/**************************/ - -/* Input length is not a multiple of 10 ms, or length is longer than the packet length */ -#define SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES -101 - -/* Sampling frequency not 8000, 12000 or 16000 Hertz */ -#define SILK_ENC_FS_NOT_SUPPORTED -102 - -/* Packet size not 10, 20, 40, or 60 ms */ -#define SILK_ENC_PACKET_SIZE_NOT_SUPPORTED -103 - -/* Allocated payload buffer too short */ -#define SILK_ENC_PAYLOAD_BUF_TOO_SHORT -104 - -/* Loss rate not between 0 and 100 percent */ -#define SILK_ENC_INVALID_LOSS_RATE -105 - -/* Complexity setting not valid, use 0...10 */ -#define SILK_ENC_INVALID_COMPLEXITY_SETTING -106 - -/* Inband FEC setting not valid, use 0 or 1 */ -#define SILK_ENC_INVALID_INBAND_FEC_SETTING -107 - -/* DTX setting not valid, use 0 or 1 */ -#define SILK_ENC_INVALID_DTX_SETTING -108 - -/* CBR setting not valid, use 0 or 1 */ -#define SILK_ENC_INVALID_CBR_SETTING -109 - -/* Internal encoder error */ -#define SILK_ENC_INTERNAL_ERROR -110 - -/* Internal encoder error */ -#define SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR -111 - -/**************************/ -/* Decoder error messages */ -/**************************/ - -/* Output sampling frequency lower than internal decoded sampling frequency */ -#define SILK_DEC_INVALID_SAMPLING_FREQUENCY -200 - -/* Payload size exceeded the maximum allowed 1024 bytes */ -#define SILK_DEC_PAYLOAD_TOO_LARGE -201 - -/* Payload has bit errors */ -#define SILK_DEC_PAYLOAD_ERROR -202 - -/* Payload has bit errors */ -#define SILK_DEC_INVALID_FRAME_SIZE -203 - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/silk/fixed/LTP_analysis_filter_FIX.c b/Engine/lib/opus/silk/fixed/LTP_analysis_filter_FIX.c deleted file mode 100644 index 5574e7069..000000000 --- a/Engine/lib/opus/silk/fixed/LTP_analysis_filter_FIX.c +++ /dev/null @@ -1,90 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" - -void silk_LTP_analysis_filter_FIX( - opus_int16 *LTP_res, /* O LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */ - const opus_int16 *x, /* I Pointer to input signal with at least max( pitchL ) preceding samples */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag, one for each subframe */ - const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I Inverse quantization gains, one for each subframe */ - const opus_int subfr_length, /* I Length of each subframe */ - const opus_int nb_subfr, /* I Number of subframes */ - const opus_int pre_length /* I Length of the preceding samples starting at &x[0] for each subframe */ -) -{ - const opus_int16 *x_ptr, *x_lag_ptr; - opus_int16 Btmp_Q14[ LTP_ORDER ]; - opus_int16 *LTP_res_ptr; - opus_int k, i; - opus_int32 LTP_est; - - x_ptr = x; - LTP_res_ptr = LTP_res; - for( k = 0; k < nb_subfr; k++ ) { - - x_lag_ptr = x_ptr - pitchL[ k ]; - - Btmp_Q14[ 0 ] = LTPCoef_Q14[ k * LTP_ORDER ]; - Btmp_Q14[ 1 ] = LTPCoef_Q14[ k * LTP_ORDER + 1 ]; - Btmp_Q14[ 2 ] = LTPCoef_Q14[ k * LTP_ORDER + 2 ]; - Btmp_Q14[ 3 ] = LTPCoef_Q14[ k * LTP_ORDER + 3 ]; - Btmp_Q14[ 4 ] = LTPCoef_Q14[ k * LTP_ORDER + 4 ]; - - /* LTP analysis FIR filter */ - for( i = 0; i < subfr_length + pre_length; i++ ) { - LTP_res_ptr[ i ] = x_ptr[ i ]; - - /* Long-term prediction */ - LTP_est = silk_SMULBB( x_lag_ptr[ LTP_ORDER / 2 ], Btmp_Q14[ 0 ] ); - LTP_est = silk_SMLABB_ovflw( LTP_est, x_lag_ptr[ 1 ], Btmp_Q14[ 1 ] ); - LTP_est = silk_SMLABB_ovflw( LTP_est, x_lag_ptr[ 0 ], Btmp_Q14[ 2 ] ); - LTP_est = silk_SMLABB_ovflw( LTP_est, x_lag_ptr[ -1 ], Btmp_Q14[ 3 ] ); - LTP_est = silk_SMLABB_ovflw( LTP_est, x_lag_ptr[ -2 ], Btmp_Q14[ 4 ] ); - - LTP_est = silk_RSHIFT_ROUND( LTP_est, 14 ); /* round and -> Q0*/ - - /* Subtract long-term prediction */ - LTP_res_ptr[ i ] = (opus_int16)silk_SAT16( (opus_int32)x_ptr[ i ] - LTP_est ); - - /* Scale residual */ - LTP_res_ptr[ i ] = silk_SMULWB( invGains_Q16[ k ], LTP_res_ptr[ i ] ); - - x_lag_ptr++; - } - - /* Update pointers */ - LTP_res_ptr += subfr_length + pre_length; - x_ptr += subfr_length; - } -} - diff --git a/Engine/lib/opus/silk/fixed/LTP_scale_ctrl_FIX.c b/Engine/lib/opus/silk/fixed/LTP_scale_ctrl_FIX.c deleted file mode 100644 index db1016e0b..000000000 --- a/Engine/lib/opus/silk/fixed/LTP_scale_ctrl_FIX.c +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" - -/* Calculation of LTP state scaling */ -void silk_LTP_scale_ctrl_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - opus_int condCoding /* I The type of conditional coding to use */ -) -{ - opus_int round_loss; - - if( condCoding == CODE_INDEPENDENTLY ) { - /* Only scale if first frame in packet */ - round_loss = psEnc->sCmn.PacketLoss_perc * psEnc->sCmn.nFramesPerPacket; - if ( psEnc->sCmn.LBRR_flag ) { - /* LBRR reduces the effective loss. In practice, it does not square the loss because - losses aren't independent, but that still seems to work best. We also never go below 2%. */ - round_loss = 2 + silk_SMULBB( round_loss, round_loss ) / 100; - } - psEnc->sCmn.indices.LTP_scaleIndex = silk_SMULBB( psEncCtrl->LTPredCodGain_Q7, round_loss ) > silk_log2lin( 128*7 + 2900-psEnc->sCmn.SNR_dB_Q7 ); - psEnc->sCmn.indices.LTP_scaleIndex += silk_SMULBB( psEncCtrl->LTPredCodGain_Q7, round_loss ) > silk_log2lin( 128*7 + 3900-psEnc->sCmn.SNR_dB_Q7 ); - } else { - /* Default is minimum scaling */ - psEnc->sCmn.indices.LTP_scaleIndex = 0; - } - psEncCtrl->LTP_scale_Q14 = silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ]; -} diff --git a/Engine/lib/opus/silk/fixed/apply_sine_window_FIX.c b/Engine/lib/opus/silk/fixed/apply_sine_window_FIX.c deleted file mode 100644 index 03e088a6d..000000000 --- a/Engine/lib/opus/silk/fixed/apply_sine_window_FIX.c +++ /dev/null @@ -1,101 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Apply sine window to signal vector. */ -/* Window types: */ -/* 1 -> sine window from 0 to pi/2 */ -/* 2 -> sine window from pi/2 to pi */ -/* Every other sample is linearly interpolated, for speed. */ -/* Window length must be between 16 and 120 (incl) and a multiple of 4. */ - -/* Matlab code for table: - for k=16:9*4:16+2*9*4, fprintf(' %7.d,', -round(65536*pi ./ (k:4:k+8*4))); fprintf('\n'); end -*/ -static const opus_int16 freq_table_Q16[ 27 ] = { - 12111, 9804, 8235, 7100, 6239, 5565, 5022, 4575, 4202, - 3885, 3612, 3375, 3167, 2984, 2820, 2674, 2542, 2422, - 2313, 2214, 2123, 2038, 1961, 1889, 1822, 1760, 1702, -}; - -void silk_apply_sine_window( - opus_int16 px_win[], /* O Pointer to windowed signal */ - const opus_int16 px[], /* I Pointer to input signal */ - const opus_int win_type, /* I Selects a window type */ - const opus_int length /* I Window length, multiple of 4 */ -) -{ - opus_int k, f_Q16, c_Q16; - opus_int32 S0_Q16, S1_Q16; - - celt_assert( win_type == 1 || win_type == 2 ); - - /* Length must be in a range from 16 to 120 and a multiple of 4 */ - celt_assert( length >= 16 && length <= 120 ); - celt_assert( ( length & 3 ) == 0 ); - - /* Frequency */ - k = ( length >> 2 ) - 4; - celt_assert( k >= 0 && k <= 26 ); - f_Q16 = (opus_int)freq_table_Q16[ k ]; - - /* Factor used for cosine approximation */ - c_Q16 = silk_SMULWB( (opus_int32)f_Q16, -f_Q16 ); - silk_assert( c_Q16 >= -32768 ); - - /* initialize state */ - if( win_type == 1 ) { - /* start from 0 */ - S0_Q16 = 0; - /* approximation of sin(f) */ - S1_Q16 = f_Q16 + silk_RSHIFT( length, 3 ); - } else { - /* start from 1 */ - S0_Q16 = ( (opus_int32)1 << 16 ); - /* approximation of cos(f) */ - S1_Q16 = ( (opus_int32)1 << 16 ) + silk_RSHIFT( c_Q16, 1 ) + silk_RSHIFT( length, 4 ); - } - - /* Uses the recursive equation: sin(n*f) = 2 * cos(f) * sin((n-1)*f) - sin((n-2)*f) */ - /* 4 samples at a time */ - for( k = 0; k < length; k += 4 ) { - px_win[ k ] = (opus_int16)silk_SMULWB( silk_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k ] ); - px_win[ k + 1 ] = (opus_int16)silk_SMULWB( S1_Q16, px[ k + 1] ); - S0_Q16 = silk_SMULWB( S1_Q16, c_Q16 ) + silk_LSHIFT( S1_Q16, 1 ) - S0_Q16 + 1; - S0_Q16 = silk_min( S0_Q16, ( (opus_int32)1 << 16 ) ); - - px_win[ k + 2 ] = (opus_int16)silk_SMULWB( silk_RSHIFT( S0_Q16 + S1_Q16, 1 ), px[ k + 2] ); - px_win[ k + 3 ] = (opus_int16)silk_SMULWB( S0_Q16, px[ k + 3 ] ); - S1_Q16 = silk_SMULWB( S0_Q16, c_Q16 ) + silk_LSHIFT( S0_Q16, 1 ) - S1_Q16; - S1_Q16 = silk_min( S1_Q16, ( (opus_int32)1 << 16 ) ); - } -} diff --git a/Engine/lib/opus/silk/fixed/arm/warped_autocorrelation_FIX_arm.h b/Engine/lib/opus/silk/fixed/arm/warped_autocorrelation_FIX_arm.h deleted file mode 100644 index 1992e4328..000000000 --- a/Engine/lib/opus/silk/fixed/arm/warped_autocorrelation_FIX_arm.h +++ /dev/null @@ -1,68 +0,0 @@ -/*********************************************************************** -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. -***********************************************************************/ - -#ifndef SILK_WARPED_AUTOCORRELATION_FIX_ARM_H -# define SILK_WARPED_AUTOCORRELATION_FIX_ARM_H - -# include "celt/arm/armcpu.h" - -# if defined(FIXED_POINT) - -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -void silk_warped_autocorrelation_FIX_neon( - opus_int32 *corr, /* O Result [order + 1] */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *input, /* I Input data to correlate */ - const opus_int warping_Q16, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ -); - -# if !defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_PRESUME_NEON) -# define OVERRIDE_silk_warped_autocorrelation_FIX (1) -# define silk_warped_autocorrelation_FIX(corr, scale, input, warping_Q16, length, order, arch) \ - ((void)(arch), PRESUME_NEON(silk_warped_autocorrelation_FIX)(corr, scale, input, warping_Q16, length, order)) -# endif -# endif - -# if !defined(OVERRIDE_silk_warped_autocorrelation_FIX) -/*Is run-time CPU detection enabled on this platform?*/ -# if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern void (*const SILK_WARPED_AUTOCORRELATION_FIX_IMPL[OPUS_ARCHMASK+1])(opus_int32*, opus_int*, const opus_int16*, const opus_int, const opus_int, const opus_int); -# define OVERRIDE_silk_warped_autocorrelation_FIX (1) -# define silk_warped_autocorrelation_FIX(corr, scale, input, warping_Q16, length, order, arch) \ - ((*SILK_WARPED_AUTOCORRELATION_FIX_IMPL[(arch)&OPUS_ARCHMASK])(corr, scale, input, warping_Q16, length, order)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) -# define OVERRIDE_silk_warped_autocorrelation_FIX (1) -# define silk_warped_autocorrelation_FIX(corr, scale, input, warping_Q16, length, order, arch) \ - ((void)(arch), silk_warped_autocorrelation_FIX_neon(corr, scale, input, warping_Q16, length, order)) -# endif -# endif - -# endif /* end FIXED_POINT */ - -#endif /* end SILK_WARPED_AUTOCORRELATION_FIX_ARM_H */ diff --git a/Engine/lib/opus/silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c b/Engine/lib/opus/silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c deleted file mode 100644 index 6f3be025c..000000000 --- a/Engine/lib/opus/silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c +++ /dev/null @@ -1,265 +0,0 @@ -/*********************************************************************** -Copyright (c) 2017 Google Inc., 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. -- 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" -#endif - -#include -#ifdef OPUS_CHECK_ASM -# include -#endif -#include "stack_alloc.h" -#include "main_FIX.h" - -static OPUS_INLINE void calc_corr( const opus_int32 *const input_QS, opus_int64 *const corr_QC, const opus_int offset, const int32x4_t state_QS_s32x4 ) -{ - int64x2_t corr_QC_s64x2[ 2 ], t_s64x2[ 2 ]; - const int32x4_t input_QS_s32x4 = vld1q_s32( input_QS + offset ); - corr_QC_s64x2[ 0 ] = vld1q_s64( corr_QC + offset + 0 ); - corr_QC_s64x2[ 1 ] = vld1q_s64( corr_QC + offset + 2 ); - t_s64x2[ 0 ] = vmull_s32( vget_low_s32( state_QS_s32x4 ), vget_low_s32( input_QS_s32x4 ) ); - t_s64x2[ 1 ] = vmull_s32( vget_high_s32( state_QS_s32x4 ), vget_high_s32( input_QS_s32x4 ) ); - corr_QC_s64x2[ 0 ] = vsraq_n_s64( corr_QC_s64x2[ 0 ], t_s64x2[ 0 ], 2 * QS - QC ); - corr_QC_s64x2[ 1 ] = vsraq_n_s64( corr_QC_s64x2[ 1 ], t_s64x2[ 1 ], 2 * QS - QC ); - vst1q_s64( corr_QC + offset + 0, corr_QC_s64x2[ 0 ] ); - vst1q_s64( corr_QC + offset + 2, corr_QC_s64x2[ 1 ] ); -} - -static OPUS_INLINE int32x4_t calc_state( const int32x4_t state_QS0_s32x4, const int32x4_t state_QS0_1_s32x4, const int32x4_t state_QS1_1_s32x4, const int32x4_t warping_Q16_s32x4 ) -{ - int32x4_t t_s32x4 = vsubq_s32( state_QS0_s32x4, state_QS0_1_s32x4 ); - t_s32x4 = vqdmulhq_s32( t_s32x4, warping_Q16_s32x4 ); - return vaddq_s32( state_QS1_1_s32x4, t_s32x4 ); -} - -void silk_warped_autocorrelation_FIX_neon( - opus_int32 *corr, /* O Result [order + 1] */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *input, /* I Input data to correlate */ - const opus_int warping_Q16, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ -) -{ - if( ( MAX_SHAPE_LPC_ORDER > 24 ) || ( order < 6 ) ) { - silk_warped_autocorrelation_FIX_c( corr, scale, input, warping_Q16, length, order ); - } else { - opus_int n, i, lsh; - opus_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; /* In reverse order */ - opus_int64 corr_QC_orderT; - int64x2_t lsh_s64x2; - const opus_int orderT = ( order + 3 ) & ~3; - opus_int64 *corr_QCT; - opus_int32 *input_QS; - VARDECL( opus_int32, input_QST ); - VARDECL( opus_int32, state ); - SAVE_STACK; - - /* Order must be even */ - silk_assert( ( order & 1 ) == 0 ); - silk_assert( 2 * QS - QC >= 0 ); - - /* The additional +4 is to ensure a later vld1q_s32 call does not overflow. */ - /* Strictly, only +3 is needed but +4 simplifies initialization using the 4x32 neon load. */ - ALLOC( input_QST, length + 2 * MAX_SHAPE_LPC_ORDER + 4, opus_int32 ); - - input_QS = input_QST; - /* input_QS has zero paddings in the beginning and end. */ - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - - /* Loop over samples */ - for( n = 0; n < length - 7; n += 8, input_QS += 8 ) { - const int16x8_t t0_s16x4 = vld1q_s16( input + n ); - vst1q_s32( input_QS + 0, vshll_n_s16( vget_low_s16( t0_s16x4 ), QS ) ); - vst1q_s32( input_QS + 4, vshll_n_s16( vget_high_s16( t0_s16x4 ), QS ) ); - } - for( ; n < length; n++, input_QS++ ) { - input_QS[ 0 ] = silk_LSHIFT32( (opus_int32)input[ n ], QS ); - } - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS += 4; - vst1q_s32( input_QS, vdupq_n_s32( 0 ) ); - input_QS = input_QST + MAX_SHAPE_LPC_ORDER - orderT; - - /* The following loop runs ( length + order ) times, with ( order ) extra epilogues. */ - /* The zero paddings in input_QS guarantee corr_QC's correctness even with the extra epilogues. */ - /* The values of state_QS will be polluted by the extra epilogues, however they are temporary values. */ - - /* Keep the C code here to help understand the intrinsics optimization. */ - /* - { - opus_int32 state_QS[ 2 ][ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; - opus_int32 *state_QST[ 3 ]; - state_QST[ 0 ] = state_QS[ 0 ]; - state_QST[ 1 ] = state_QS[ 1 ]; - for( n = 0; n < length + order; n++, input_QS++ ) { - state_QST[ 0 ][ orderT ] = input_QS[ orderT ]; - for( i = 0; i < orderT; i++ ) { - corr_QC[ i ] += silk_RSHIFT64( silk_SMULL( state_QST[ 0 ][ i ], input_QS[ i ] ), 2 * QS - QC ); - state_QST[ 1 ][ i ] = silk_SMLAWB( state_QST[ 1 ][ i + 1 ], state_QST[ 0 ][ i ] - state_QST[ 0 ][ i + 1 ], warping_Q16 ); - } - state_QST[ 2 ] = state_QST[ 0 ]; - state_QST[ 0 ] = state_QST[ 1 ]; - state_QST[ 1 ] = state_QST[ 2 ]; - } - } - */ - - { - const int32x4_t warping_Q16_s32x4 = vdupq_n_s32( warping_Q16 << 15 ); - const opus_int32 *in = input_QS + orderT; - opus_int o = orderT; - int32x4_t state_QS_s32x4[ 3 ][ 2 ]; - - /* The additional +4 is to ensure a later vld1q_s32 call does not overflow. */ - ALLOC( state, length + order + 4, opus_int32 ); - state_QS_s32x4[ 2 ][ 1 ] = vdupq_n_s32( 0 ); - - /* Calculate 8 taps of all inputs in each loop. */ - do { - state_QS_s32x4[ 0 ][ 0 ] = state_QS_s32x4[ 0 ][ 1 ] = - state_QS_s32x4[ 1 ][ 0 ] = state_QS_s32x4[ 1 ][ 1 ] = vdupq_n_s32( 0 ); - n = 0; - do { - calc_corr( input_QS + n, corr_QC, o - 8, state_QS_s32x4[ 0 ][ 0 ] ); - calc_corr( input_QS + n, corr_QC, o - 4, state_QS_s32x4[ 0 ][ 1 ] ); - state_QS_s32x4[ 2 ][ 1 ] = vld1q_s32( in + n ); - vst1q_lane_s32( state + n, state_QS_s32x4[ 0 ][ 0 ], 0 ); - state_QS_s32x4[ 2 ][ 0 ] = vextq_s32( state_QS_s32x4[ 0 ][ 0 ], state_QS_s32x4[ 0 ][ 1 ], 1 ); - state_QS_s32x4[ 2 ][ 1 ] = vextq_s32( state_QS_s32x4[ 0 ][ 1 ], state_QS_s32x4[ 2 ][ 1 ], 1 ); - state_QS_s32x4[ 0 ][ 0 ] = calc_state( state_QS_s32x4[ 0 ][ 0 ], state_QS_s32x4[ 2 ][ 0 ], state_QS_s32x4[ 1 ][ 0 ], warping_Q16_s32x4 ); - state_QS_s32x4[ 0 ][ 1 ] = calc_state( state_QS_s32x4[ 0 ][ 1 ], state_QS_s32x4[ 2 ][ 1 ], state_QS_s32x4[ 1 ][ 1 ], warping_Q16_s32x4 ); - state_QS_s32x4[ 1 ][ 0 ] = state_QS_s32x4[ 2 ][ 0 ]; - state_QS_s32x4[ 1 ][ 1 ] = state_QS_s32x4[ 2 ][ 1 ]; - } while( ++n < ( length + order ) ); - in = state; - o -= 8; - } while( o > 4 ); - - if( o ) { - /* Calculate the last 4 taps of all inputs. */ - opus_int32 *stateT = state; - silk_assert( o == 4 ); - state_QS_s32x4[ 0 ][ 0 ] = state_QS_s32x4[ 1 ][ 0 ] = vdupq_n_s32( 0 ); - n = length + order; - do { - calc_corr( input_QS, corr_QC, 0, state_QS_s32x4[ 0 ][ 0 ] ); - state_QS_s32x4[ 2 ][ 0 ] = vld1q_s32( stateT ); - vst1q_lane_s32( stateT, state_QS_s32x4[ 0 ][ 0 ], 0 ); - state_QS_s32x4[ 2 ][ 0 ] = vextq_s32( state_QS_s32x4[ 0 ][ 0 ], state_QS_s32x4[ 2 ][ 0 ], 1 ); - state_QS_s32x4[ 0 ][ 0 ] = calc_state( state_QS_s32x4[ 0 ][ 0 ], state_QS_s32x4[ 2 ][ 0 ], state_QS_s32x4[ 1 ][ 0 ], warping_Q16_s32x4 ); - state_QS_s32x4[ 1 ][ 0 ] = state_QS_s32x4[ 2 ][ 0 ]; - input_QS++; - stateT++; - } while( --n ); - } - } - - { - const opus_int16 *inputT = input; - int32x4_t t_s32x4; - int64x1_t t_s64x1; - int64x2_t t_s64x2 = vdupq_n_s64( 0 ); - for( n = 0; n <= length - 8; n += 8 ) { - int16x8_t input_s16x8 = vld1q_s16( inputT ); - t_s32x4 = vmull_s16( vget_low_s16( input_s16x8 ), vget_low_s16( input_s16x8 ) ); - t_s32x4 = vmlal_s16( t_s32x4, vget_high_s16( input_s16x8 ), vget_high_s16( input_s16x8 ) ); - t_s64x2 = vaddw_s32( t_s64x2, vget_low_s32( t_s32x4 ) ); - t_s64x2 = vaddw_s32( t_s64x2, vget_high_s32( t_s32x4 ) ); - inputT += 8; - } - t_s64x1 = vadd_s64( vget_low_s64( t_s64x2 ), vget_high_s64( t_s64x2 ) ); - corr_QC_orderT = vget_lane_s64( t_s64x1, 0 ); - for( ; n < length; n++ ) { - corr_QC_orderT += silk_SMULL( input[ n ], input[ n ] ); - } - corr_QC_orderT = silk_LSHIFT64( corr_QC_orderT, QC ); - corr_QC[ orderT ] = corr_QC_orderT; - } - - corr_QCT = corr_QC + orderT - order; - lsh = silk_CLZ64( corr_QC_orderT ) - 35; - lsh = silk_LIMIT( lsh, -12 - QC, 30 - QC ); - *scale = -( QC + lsh ); - silk_assert( *scale >= -30 && *scale <= 12 ); - lsh_s64x2 = vdupq_n_s64( lsh ); - for( i = 0; i <= order - 3; i += 4 ) { - int32x4_t corr_s32x4; - int64x2_t corr_QC0_s64x2, corr_QC1_s64x2; - corr_QC0_s64x2 = vld1q_s64( corr_QCT + i ); - corr_QC1_s64x2 = vld1q_s64( corr_QCT + i + 2 ); - corr_QC0_s64x2 = vshlq_s64( corr_QC0_s64x2, lsh_s64x2 ); - corr_QC1_s64x2 = vshlq_s64( corr_QC1_s64x2, lsh_s64x2 ); - corr_s32x4 = vcombine_s32( vmovn_s64( corr_QC1_s64x2 ), vmovn_s64( corr_QC0_s64x2 ) ); - corr_s32x4 = vrev64q_s32( corr_s32x4 ); - vst1q_s32( corr + order - i - 3, corr_s32x4 ); - } - if( lsh >= 0 ) { - for( ; i < order + 1; i++ ) { - corr[ order - i ] = (opus_int32)silk_CHECK_FIT32( silk_LSHIFT64( corr_QCT[ i ], lsh ) ); - } - } else { - for( ; i < order + 1; i++ ) { - corr[ order - i ] = (opus_int32)silk_CHECK_FIT32( silk_RSHIFT64( corr_QCT[ i ], -lsh ) ); - } - } - silk_assert( corr_QCT[ order ] >= 0 ); /* If breaking, decrease QC*/ - RESTORE_STACK; - } - -#ifdef OPUS_CHECK_ASM - { - opus_int32 corr_c[ MAX_SHAPE_LPC_ORDER + 1 ]; - opus_int scale_c; - silk_warped_autocorrelation_FIX_c( corr_c, &scale_c, input, warping_Q16, length, order ); - silk_assert( !memcmp( corr_c, corr, sizeof( corr_c[ 0 ] ) * ( order + 1 ) ) ); - silk_assert( scale_c == *scale ); - } -#endif -} diff --git a/Engine/lib/opus/silk/fixed/autocorr_FIX.c b/Engine/lib/opus/silk/fixed/autocorr_FIX.c deleted file mode 100644 index de95c9869..000000000 --- a/Engine/lib/opus/silk/fixed/autocorr_FIX.c +++ /dev/null @@ -1,48 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "celt_lpc.h" - -/* Compute autocorrelation */ -void silk_autocorr( - opus_int32 *results, /* O Result (length correlationCount) */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *inputData, /* I Input data to correlate */ - const opus_int inputDataSize, /* I Length of input */ - const opus_int correlationCount, /* I Number of correlation taps to compute */ - int arch /* I Run-time architecture */ -) -{ - opus_int corrCount; - corrCount = silk_min_int( inputDataSize, correlationCount ); - *scale = _celt_autocorr(inputData, results, NULL, 0, corrCount-1, inputDataSize, arch); -} diff --git a/Engine/lib/opus/silk/fixed/burg_modified_FIX.c b/Engine/lib/opus/silk/fixed/burg_modified_FIX.c deleted file mode 100644 index 185a12b17..000000000 --- a/Engine/lib/opus/silk/fixed/burg_modified_FIX.c +++ /dev/null @@ -1,280 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "define.h" -#include "tuning_parameters.h" -#include "pitch.h" - -#define MAX_FRAME_SIZE 384 /* subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384 */ - -#define QA 25 -#define N_BITS_HEAD_ROOM 3 -#define MIN_RSHIFTS -16 -#define MAX_RSHIFTS (32 - QA) - -/* Compute reflection coefficients from input signal */ -void silk_burg_modified_c( - opus_int32 *res_nrg, /* O Residual energy */ - opus_int *res_nrg_Q, /* O Residual energy Q value */ - opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ - const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ - const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ - const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ - const opus_int nb_subfr, /* I Number of subframes stacked in x */ - const opus_int D, /* I Order */ - int arch /* I Run-time architecture */ -) -{ - opus_int k, n, s, lz, rshifts, reached_max_gain; - opus_int32 C0, num, nrg, rc_Q31, invGain_Q30, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2; - const opus_int16 *x_ptr; - opus_int32 C_first_row[ SILK_MAX_ORDER_LPC ]; - opus_int32 C_last_row[ SILK_MAX_ORDER_LPC ]; - opus_int32 Af_QA[ SILK_MAX_ORDER_LPC ]; - opus_int32 CAf[ SILK_MAX_ORDER_LPC + 1 ]; - opus_int32 CAb[ SILK_MAX_ORDER_LPC + 1 ]; - opus_int32 xcorr[ SILK_MAX_ORDER_LPC ]; - opus_int64 C0_64; - - celt_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE ); - - /* Compute autocorrelations, added over subframes */ - C0_64 = silk_inner_prod16( x, x, subfr_length*nb_subfr, arch ); - lz = silk_CLZ64(C0_64); - rshifts = 32 + 1 + N_BITS_HEAD_ROOM - lz; - if (rshifts > MAX_RSHIFTS) rshifts = MAX_RSHIFTS; - if (rshifts < MIN_RSHIFTS) rshifts = MIN_RSHIFTS; - - if (rshifts > 0) { - C0 = (opus_int32)silk_RSHIFT64(C0_64, rshifts ); - } else { - C0 = silk_LSHIFT32((opus_int32)C0_64, -rshifts ); - } - - CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */ - silk_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) ); - if( rshifts > 0 ) { - 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 ] += (opus_int32)silk_RSHIFT64( - silk_inner_prod16( x_ptr, x_ptr + n, subfr_length - n, arch ), rshifts ); - } - } - } else { - for( s = 0; s < nb_subfr; s++ ) { - int i; - opus_int32 d; - x_ptr = x + s * subfr_length; - celt_pitch_xcorr(x_ptr, x_ptr + 1, xcorr, subfr_length - D, D, arch ); - for( n = 1; n < D + 1; n++ ) { - for ( i = n + subfr_length - D, d = 0; i < subfr_length; i++ ) - d = MAC16_16( d, x_ptr[ i ], x_ptr[ i - n ] ); - xcorr[ n - 1 ] += d; - } - for( n = 1; n < D + 1; n++ ) { - C_first_row[ n - 1 ] += silk_LSHIFT32( xcorr[ n - 1 ], -rshifts ); - } - } - } - silk_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) ); - - /* Initialize */ - CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */ - - invGain_Q30 = (opus_int32)1 << 30; - reached_max_gain = 0; - 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) */ - if( rshifts > -2 ) { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], 16 - rshifts ); /* Q(16-rshifts) */ - x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 16 - rshifts ); /* Q(16-rshifts) */ - tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], QA - 16 ); /* Q(QA-16) */ - tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], QA - 16 ); /* Q(QA-16) */ - for( k = 0; k < n; k++ ) { - C_first_row[ k ] = silk_SMLAWB( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */ - C_last_row[ k ] = silk_SMLAWB( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */ - Atmp_QA = Af_QA[ k ]; - tmp1 = silk_SMLAWB( tmp1, Atmp_QA, x_ptr[ n - k - 1 ] ); /* Q(QA-16) */ - tmp2 = silk_SMLAWB( tmp2, Atmp_QA, x_ptr[ subfr_length - n + k ] ); /* Q(QA-16) */ - } - tmp1 = silk_LSHIFT32( -tmp1, 32 - QA - rshifts ); /* Q(16-rshifts) */ - tmp2 = silk_LSHIFT32( -tmp2, 32 - QA - rshifts ); /* Q(16-rshifts) */ - for( k = 0; k <= n; k++ ) { - CAf[ k ] = silk_SMLAWB( CAf[ k ], tmp1, x_ptr[ n - k ] ); /* Q( -rshift ) */ - CAb[ k ] = silk_SMLAWB( CAb[ k ], tmp2, x_ptr[ subfr_length - n + k - 1 ] ); /* Q( -rshift ) */ - } - } - } else { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], -rshifts ); /* Q( -rshifts ) */ - x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], -rshifts ); /* Q( -rshifts ) */ - tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], 17 ); /* Q17 */ - tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 17 ); /* Q17 */ - for( k = 0; k < n; k++ ) { - C_first_row[ k ] = silk_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */ - C_last_row[ k ] = silk_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */ - Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17 */ - /* We sometimes get overflows in the multiplications (even beyond +/- 2^32), - but they cancel each other and the real result seems to always fit in a 32-bit - signed integer. This was determined experimentally, not theoretically (unfortunately). */ - tmp1 = silk_MLA_ovflw( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17 */ - tmp2 = silk_MLA_ovflw( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17 */ - } - tmp1 = -tmp1; /* Q17 */ - tmp2 = -tmp2; /* Q17 */ - for( k = 0; k <= n; k++ ) { - CAf[ k ] = silk_SMLAWW( CAf[ k ], tmp1, - silk_LSHIFT32( (opus_int32)x_ptr[ n - k ], -rshifts - 1 ) ); /* Q( -rshift ) */ - CAb[ k ] = silk_SMLAWW( CAb[ k ], tmp2, - silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) ); /* Q( -rshift ) */ - } - } - } - - /* Calculate nominator and denominator for the next order reflection (parcor) coefficient */ - tmp1 = C_first_row[ n ]; /* Q( -rshifts ) */ - tmp2 = C_last_row[ n ]; /* Q( -rshifts ) */ - num = 0; /* Q( -rshifts ) */ - nrg = silk_ADD32( CAb[ 0 ], CAf[ 0 ] ); /* Q( 1-rshifts ) */ - for( k = 0; k < n; k++ ) { - Atmp_QA = Af_QA[ k ]; - lz = silk_CLZ32( silk_abs( Atmp_QA ) ) - 1; - lz = silk_min( 32 - QA, lz ); - Atmp1 = silk_LSHIFT32( Atmp_QA, lz ); /* Q( QA + lz ) */ - - tmp1 = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( C_last_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ - tmp2 = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( C_first_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ - num = silk_ADD_LSHIFT32( num, silk_SMMUL( CAb[ n - k ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ - nrg = silk_ADD_LSHIFT32( nrg, silk_SMMUL( silk_ADD32( CAb[ k + 1 ], CAf[ k + 1 ] ), - Atmp1 ), 32 - QA - lz ); /* Q( 1-rshifts ) */ - } - CAf[ n + 1 ] = tmp1; /* Q( -rshifts ) */ - CAb[ n + 1 ] = tmp2; /* Q( -rshifts ) */ - num = silk_ADD32( num, tmp2 ); /* Q( -rshifts ) */ - num = silk_LSHIFT32( -num, 1 ); /* Q( 1-rshifts ) */ - - /* Calculate the next order reflection (parcor) coefficient */ - if( silk_abs( num ) < nrg ) { - rc_Q31 = silk_DIV32_varQ( num, nrg, 31 ); - } else { - rc_Q31 = ( num > 0 ) ? silk_int32_MAX : silk_int32_MIN; - } - - /* Update inverse prediction gain */ - tmp1 = ( (opus_int32)1 << 30 ) - silk_SMMUL( rc_Q31, rc_Q31 ); - tmp1 = silk_LSHIFT( silk_SMMUL( invGain_Q30, tmp1 ), 2 ); - if( tmp1 <= minInvGain_Q30 ) { - /* Max prediction gain exceeded; set reflection coefficient such that max prediction gain is exactly hit */ - tmp2 = ( (opus_int32)1 << 30 ) - silk_DIV32_varQ( minInvGain_Q30, invGain_Q30, 30 ); /* Q30 */ - rc_Q31 = silk_SQRT_APPROX( tmp2 ); /* Q15 */ - if( rc_Q31 > 0 ) { - /* Newton-Raphson iteration */ - rc_Q31 = silk_RSHIFT32( rc_Q31 + silk_DIV32( tmp2, rc_Q31 ), 1 ); /* Q15 */ - rc_Q31 = silk_LSHIFT32( rc_Q31, 16 ); /* Q31 */ - if( num < 0 ) { - /* Ensure adjusted reflection coefficients has the original sign */ - rc_Q31 = -rc_Q31; - } - } - invGain_Q30 = minInvGain_Q30; - reached_max_gain = 1; - } else { - invGain_Q30 = tmp1; - } - - /* Update the AR coefficients */ - for( k = 0; k < (n + 1) >> 1; k++ ) { - tmp1 = Af_QA[ k ]; /* QA */ - tmp2 = Af_QA[ n - k - 1 ]; /* QA */ - Af_QA[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* QA */ - Af_QA[ n - k - 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* QA */ - } - Af_QA[ n ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA */ - - if( reached_max_gain ) { - /* Reached max prediction gain; set remaining coefficients to zero and exit loop */ - for( k = n + 1; k < D; k++ ) { - Af_QA[ k ] = 0; - } - break; - } - - /* Update C * Af and C * Ab */ - for( k = 0; k <= n + 1; k++ ) { - tmp1 = CAf[ k ]; /* Q( -rshifts ) */ - tmp2 = CAb[ n - k + 1 ]; /* Q( -rshifts ) */ - CAf[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* Q( -rshifts ) */ - CAb[ n - k + 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* Q( -rshifts ) */ - } - } - - if( reached_max_gain ) { - for( k = 0; k < D; k++ ) { - /* Scale coefficients */ - A_Q16[ k ] = -silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); - } - /* Subtract energy of preceding samples from C0 */ - if( rshifts > 0 ) { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - C0 -= (opus_int32)silk_RSHIFT64( silk_inner_prod16( x_ptr, x_ptr, D, arch ), rshifts ); - } - } else { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - C0 -= silk_LSHIFT32( silk_inner_prod_aligned( x_ptr, x_ptr, D, arch), -rshifts); - } - } - /* Approximate residual energy */ - *res_nrg = silk_LSHIFT( silk_SMMUL( invGain_Q30, C0 ), 2 ); - *res_nrg_Q = -rshifts; - } else { - /* Return residual energy */ - nrg = CAf[ 0 ]; /* Q( -rshifts ) */ - tmp1 = (opus_int32)1 << 16; /* Q16 */ - for( k = 0; k < D; k++ ) { - Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); /* Q16 */ - nrg = silk_SMLAWW( nrg, CAf[ k + 1 ], Atmp1 ); /* Q( -rshifts ) */ - tmp1 = silk_SMLAWW( tmp1, Atmp1, Atmp1 ); /* Q16 */ - A_Q16[ k ] = -Atmp1; - } - *res_nrg = silk_SMLAWW( nrg, silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ), -tmp1 );/* Q( -rshifts ) */ - *res_nrg_Q = -rshifts; - } -} diff --git a/Engine/lib/opus/silk/fixed/corrMatrix_FIX.c b/Engine/lib/opus/silk/fixed/corrMatrix_FIX.c deleted file mode 100644 index 1b4a29c23..000000000 --- a/Engine/lib/opus/silk/fixed/corrMatrix_FIX.c +++ /dev/null @@ -1,150 +0,0 @@ -/*********************************************************************** -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" -#endif - -/********************************************************************** - * Correlation Matrix Computations for LS estimate. - **********************************************************************/ - -#include "main_FIX.h" - -/* Calculates correlation vector X'*t */ -void silk_corrVector_FIX( - const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ - const opus_int16 *t, /* I Target vector [L] */ - const opus_int L, /* I Length of vectors */ - const opus_int order, /* I Max lag for correlation */ - opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */ - const opus_int rshifts, /* I Right shifts of correlations */ - int arch /* I Run-time architecture */ -) -{ - opus_int lag, i; - const opus_int16 *ptr1, *ptr2; - opus_int32 inner_prod; - - ptr1 = &x[ order - 1 ]; /* Points to first sample of column 0 of X: X[:,0] */ - ptr2 = t; - /* Calculate X'*t */ - if( rshifts > 0 ) { - /* Right shifting used */ - for( lag = 0; lag < order; lag++ ) { - inner_prod = 0; - for( i = 0; i < L; i++ ) { - inner_prod = silk_ADD_RSHIFT32( inner_prod, silk_SMULBB( ptr1[ i ], ptr2[i] ), rshifts ); - } - Xt[ lag ] = inner_prod; /* X[:,lag]'*t */ - ptr1--; /* Go to next column of X */ - } - } else { - silk_assert( rshifts == 0 ); - for( lag = 0; lag < order; lag++ ) { - Xt[ lag ] = silk_inner_prod_aligned( ptr1, ptr2, L, arch ); /* X[:,lag]'*t */ - ptr1--; /* Go to next column of X */ - } - } -} - -/* Calculates correlation matrix X'*X */ -void silk_corrMatrix_FIX( - const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ - const opus_int L, /* I Length of vectors */ - const opus_int order, /* I Max lag for correlation */ - opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */ - opus_int32 *nrg, /* O Energy of x vector */ - opus_int *rshifts, /* O Right shifts of correlations and energy */ - int arch /* I Run-time architecture */ -) -{ - opus_int i, j, lag; - opus_int32 energy; - const opus_int16 *ptr1, *ptr2; - - /* Calculate energy to find shift used to fit in 32 bits */ - silk_sum_sqr_shift( nrg, rshifts, x, L + order - 1 ); - energy = *nrg; - - /* Calculate energy of first column (0) of X: X[:,0]'*X[:,0] */ - /* Remove contribution of first order - 1 samples */ - for( i = 0; i < order - 1; i++ ) { - energy -= silk_RSHIFT32( silk_SMULBB( x[ i ], x[ i ] ), *rshifts ); - } - - /* Calculate energy of remaining columns of X: X[:,j]'*X[:,j] */ - /* Fill out the diagonal of the correlation matrix */ - matrix_ptr( XX, 0, 0, order ) = energy; - silk_assert( energy >= 0 ); - ptr1 = &x[ order - 1 ]; /* First sample of column 0 of X */ - for( j = 1; j < order; j++ ) { - energy = silk_SUB32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ L - j ], ptr1[ L - j ] ), *rshifts ) ); - energy = silk_ADD32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ -j ], ptr1[ -j ] ), *rshifts ) ); - matrix_ptr( XX, j, j, order ) = energy; - silk_assert( energy >= 0 ); - } - - ptr2 = &x[ order - 2 ]; /* First sample of column 1 of X */ - /* Calculate the remaining elements of the correlation matrix */ - if( *rshifts > 0 ) { - /* Right shifting used */ - for( lag = 1; lag < order; lag++ ) { - /* Inner product of column 0 and column lag: X[:,0]'*X[:,lag] */ - energy = 0; - for( i = 0; i < L; i++ ) { - energy += silk_RSHIFT32( silk_SMULBB( ptr1[ i ], ptr2[i] ), *rshifts ); - } - /* Calculate remaining off diagonal: X[:,j]'*X[:,j + lag] */ - matrix_ptr( XX, lag, 0, order ) = energy; - matrix_ptr( XX, 0, lag, order ) = energy; - for( j = 1; j < ( order - lag ); j++ ) { - energy = silk_SUB32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ L - j ], ptr2[ L - j ] ), *rshifts ) ); - energy = silk_ADD32( energy, silk_RSHIFT32( silk_SMULBB( ptr1[ -j ], ptr2[ -j ] ), *rshifts ) ); - matrix_ptr( XX, lag + j, j, order ) = energy; - matrix_ptr( XX, j, lag + j, order ) = energy; - } - ptr2--; /* Update pointer to first sample of next column (lag) in X */ - } - } else { - for( lag = 1; lag < order; lag++ ) { - /* Inner product of column 0 and column lag: X[:,0]'*X[:,lag] */ - energy = silk_inner_prod_aligned( ptr1, ptr2, L, arch ); - matrix_ptr( XX, lag, 0, order ) = energy; - matrix_ptr( XX, 0, lag, order ) = energy; - /* Calculate remaining off diagonal: X[:,j]'*X[:,j + lag] */ - for( j = 1; j < ( order - lag ); j++ ) { - energy = silk_SUB32( energy, silk_SMULBB( ptr1[ L - j ], ptr2[ L - j ] ) ); - energy = silk_SMLABB( energy, ptr1[ -j ], ptr2[ -j ] ); - matrix_ptr( XX, lag + j, j, order ) = energy; - matrix_ptr( XX, j, lag + j, order ) = energy; - } - ptr2--;/* Update pointer to first sample of next column (lag) in X */ - } - } -} - diff --git a/Engine/lib/opus/silk/fixed/encode_frame_FIX.c b/Engine/lib/opus/silk/fixed/encode_frame_FIX.c deleted file mode 100644 index a02bf87db..000000000 --- a/Engine/lib/opus/silk/fixed/encode_frame_FIX.c +++ /dev/null @@ -1,448 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include -#include "main_FIX.h" -#include "stack_alloc.h" -#include "tuning_parameters.h" - -/* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */ -static OPUS_INLINE void silk_LBRR_encode_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ - const opus_int16 x16[], /* I Input signal */ - opus_int condCoding /* I The type of conditional coding used so far for this frame */ -); - -void silk_encode_do_VAD_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - opus_int activity /* I Decision of Opus voice activity detector */ -) -{ - const opus_int activity_threshold = SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ); - - /****************************/ - /* Voice Activity Detection */ - /****************************/ - silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.arch ); - /* If Opus VAD is inactive and Silk VAD is active: lower Silk VAD to just under the threshold */ - if( activity == VAD_NO_ACTIVITY && psEnc->sCmn.speech_activity_Q8 >= activity_threshold ) { - psEnc->sCmn.speech_activity_Q8 = activity_threshold - 1; - } - - /**************************************************/ - /* Convert speech activity into VAD and DTX flags */ - /**************************************************/ - if( psEnc->sCmn.speech_activity_Q8 < activity_threshold ) { - psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY; - psEnc->sCmn.noSpeechCounter++; - if( psEnc->sCmn.noSpeechCounter <= NB_SPEECH_FRAMES_BEFORE_DTX ) { - psEnc->sCmn.inDTX = 0; - } else if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX + NB_SPEECH_FRAMES_BEFORE_DTX ) { - psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX; - psEnc->sCmn.inDTX = 0; - } - psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 0; - } else { - psEnc->sCmn.noSpeechCounter = 0; - psEnc->sCmn.inDTX = 0; - psEnc->sCmn.indices.signalType = TYPE_UNVOICED; - psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 1; - } -} - -/****************/ -/* Encode frame */ -/****************/ -opus_int silk_encode_frame_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */ - ec_enc *psRangeEnc, /* I/O compressor data structure */ - opus_int condCoding, /* I The type of conditional coding to use */ - opus_int maxBits, /* I If > 0: maximum number of output bits */ - opus_int useCBR /* I Flag to force constant-bitrate operation */ -) -{ - silk_encoder_control_FIX sEncCtrl; - opus_int i, iter, maxIter, found_upper, found_lower, ret = 0; - opus_int16 *x_frame; - ec_enc sRangeEnc_copy, sRangeEnc_copy2; - silk_nsq_state sNSQ_copy, sNSQ_copy2; - opus_int32 seed_copy, nBits, nBits_lower, nBits_upper, gainMult_lower, gainMult_upper; - opus_int32 gainsID, gainsID_lower, gainsID_upper; - opus_int16 gainMult_Q8; - opus_int16 ec_prevLagIndex_copy; - opus_int ec_prevSignalType_copy; - opus_int8 LastGainIndex_copy2; - opus_int gain_lock[ MAX_NB_SUBFR ] = {0}; - opus_int16 best_gain_mult[ MAX_NB_SUBFR ]; - opus_int best_sum[ MAX_NB_SUBFR ]; - SAVE_STACK; - - /* This is totally unnecessary but many compilers (including gcc) are too dumb to realise it */ - LastGainIndex_copy2 = nBits_lower = nBits_upper = gainMult_lower = gainMult_upper = 0; - - psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3; - - /**************************************************************/ - /* Set up Input Pointers, and insert frame in input buffer */ - /*************************************************************/ - /* start of frame to encode */ - x_frame = psEnc->x_buf + psEnc->sCmn.ltp_mem_length; - - /***************************************/ - /* Ensure smooth bandwidth transitions */ - /***************************************/ - silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length ); - - /*******************************************/ - /* Copy new frame to front of input buffer */ - /*******************************************/ - silk_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length * sizeof( opus_int16 ) ); - - if( !psEnc->sCmn.prefillFlag ) { - VARDECL( opus_int16, res_pitch ); - VARDECL( opus_uint8, ec_buf_copy ); - opus_int16 *res_pitch_frame; - - ALLOC( res_pitch, - psEnc->sCmn.la_pitch + psEnc->sCmn.frame_length - + psEnc->sCmn.ltp_mem_length, opus_int16 ); - /* start of pitch LPC residual frame */ - res_pitch_frame = res_pitch + psEnc->sCmn.ltp_mem_length; - - /*****************************************/ - /* Find pitch lags, initial LPC analysis */ - /*****************************************/ - silk_find_pitch_lags_FIX( psEnc, &sEncCtrl, res_pitch, x_frame - psEnc->sCmn.ltp_mem_length, psEnc->sCmn.arch ); - - /************************/ - /* Noise shape analysis */ - /************************/ - silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame, psEnc->sCmn.arch ); - - /***************************************************/ - /* Find linear prediction coefficients (LPC + LTP) */ - /***************************************************/ - silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame, condCoding ); - - /****************************************/ - /* Process gains */ - /****************************************/ - silk_process_gains_FIX( psEnc, &sEncCtrl, condCoding ); - - /****************************************/ - /* Low Bitrate Redundant Encoding */ - /****************************************/ - silk_LBRR_encode_FIX( psEnc, &sEncCtrl, x_frame, condCoding ); - - /* Loop over quantizer and entropy coding to control bitrate */ - maxIter = 6; - gainMult_Q8 = SILK_FIX_CONST( 1, 8 ); - found_lower = 0; - found_upper = 0; - gainsID = silk_gains_ID( psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr ); - gainsID_lower = -1; - gainsID_upper = -1; - /* Copy part of the input state */ - silk_memcpy( &sRangeEnc_copy, psRangeEnc, sizeof( ec_enc ) ); - silk_memcpy( &sNSQ_copy, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); - seed_copy = psEnc->sCmn.indices.Seed; - ec_prevLagIndex_copy = psEnc->sCmn.ec_prevLagIndex; - ec_prevSignalType_copy = psEnc->sCmn.ec_prevSignalType; - ALLOC( ec_buf_copy, 1275, opus_uint8 ); - for( iter = 0; ; iter++ ) { - if( gainsID == gainsID_lower ) { - nBits = nBits_lower; - } else if( gainsID == gainsID_upper ) { - nBits = nBits_upper; - } else { - /* Restore part of the input state */ - if( iter > 0 ) { - silk_memcpy( psRangeEnc, &sRangeEnc_copy, sizeof( ec_enc ) ); - silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy, sizeof( silk_nsq_state ) ); - psEnc->sCmn.indices.Seed = seed_copy; - psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy; - psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy; - } - - /*****************************************/ - /* Noise shaping quantization */ - /*****************************************/ - if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { - silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, x_frame, psEnc->sCmn.pulses, - sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR_Q13, sEncCtrl.HarmShapeGain_Q14, - sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14, - psEnc->sCmn.arch ); - } else { - silk_NSQ( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, x_frame, psEnc->sCmn.pulses, - sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR_Q13, sEncCtrl.HarmShapeGain_Q14, - sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14, - psEnc->sCmn.arch); - } - - if ( iter == maxIter && !found_lower ) { - silk_memcpy( &sRangeEnc_copy2, psRangeEnc, sizeof( ec_enc ) ); - } - - /****************************************/ - /* Encode Parameters */ - /****************************************/ - silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding ); - - /****************************************/ - /* Encode Excitation Signal */ - /****************************************/ - silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, - psEnc->sCmn.pulses, psEnc->sCmn.frame_length ); - - nBits = ec_tell( psRangeEnc ); - - /* If we still bust after the last iteration, do some damage control. */ - if ( iter == maxIter && !found_lower && nBits > maxBits ) { - silk_memcpy( psRangeEnc, &sRangeEnc_copy2, sizeof( ec_enc ) ); - - /* Keep gains the same as the last frame. */ - psEnc->sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev; - for ( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - psEnc->sCmn.indices.GainsIndices[ i ] = 4; - } - if (condCoding != CODE_CONDITIONALLY) { - psEnc->sCmn.indices.GainsIndices[ 0 ] = sEncCtrl.lastGainIndexPrev; - } - psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy; - psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy; - /* Clear all pulses. */ - for ( i = 0; i < psEnc->sCmn.frame_length; i++ ) { - psEnc->sCmn.pulses[ i ] = 0; - } - - silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding ); - - silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, - psEnc->sCmn.pulses, psEnc->sCmn.frame_length ); - - nBits = ec_tell( psRangeEnc ); - } - - if( useCBR == 0 && iter == 0 && nBits <= maxBits ) { - break; - } - } - - if( iter == maxIter ) { - if( found_lower && ( gainsID == gainsID_lower || nBits > maxBits ) ) { - /* Restore output state from earlier iteration that did meet the bitrate budget */ - silk_memcpy( psRangeEnc, &sRangeEnc_copy2, sizeof( ec_enc ) ); - celt_assert( sRangeEnc_copy2.offs <= 1275 ); - silk_memcpy( psRangeEnc->buf, ec_buf_copy, sRangeEnc_copy2.offs ); - silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy2, sizeof( silk_nsq_state ) ); - psEnc->sShape.LastGainIndex = LastGainIndex_copy2; - } - break; - } - - if( nBits > maxBits ) { - if( found_lower == 0 && iter >= 2 ) { - /* Adjust the quantizer's rate/distortion tradeoff and discard previous "upper" results */ - sEncCtrl.Lambda_Q10 = silk_ADD_RSHIFT32( sEncCtrl.Lambda_Q10, sEncCtrl.Lambda_Q10, 1 ); - found_upper = 0; - gainsID_upper = -1; - } else { - found_upper = 1; - nBits_upper = nBits; - gainMult_upper = gainMult_Q8; - gainsID_upper = gainsID; - } - } else if( nBits < maxBits - 5 ) { - found_lower = 1; - nBits_lower = nBits; - gainMult_lower = gainMult_Q8; - if( gainsID != gainsID_lower ) { - gainsID_lower = gainsID; - /* Copy part of the output state */ - silk_memcpy( &sRangeEnc_copy2, psRangeEnc, sizeof( ec_enc ) ); - celt_assert( psRangeEnc->offs <= 1275 ); - silk_memcpy( ec_buf_copy, psRangeEnc->buf, psRangeEnc->offs ); - silk_memcpy( &sNSQ_copy2, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); - LastGainIndex_copy2 = psEnc->sShape.LastGainIndex; - } - } else { - /* Within 5 bits of budget: close enough */ - break; - } - - if ( !found_lower && nBits > maxBits ) { - int j; - for ( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - int sum=0; - for ( j = i*psEnc->sCmn.subfr_length; j < (i+1)*psEnc->sCmn.subfr_length; j++ ) { - sum += abs( psEnc->sCmn.pulses[j] ); - } - if ( iter == 0 || (sum < best_sum[i] && !gain_lock[i]) ) { - best_sum[i] = sum; - best_gain_mult[i] = gainMult_Q8; - } else { - gain_lock[i] = 1; - } - } - } - if( ( found_lower & found_upper ) == 0 ) { - /* Adjust gain according to high-rate rate/distortion curve */ - if( nBits > maxBits ) { - if (gainMult_Q8 < 16384) { - gainMult_Q8 *= 2; - } else { - gainMult_Q8 = 32767; - } - } else { - opus_int32 gain_factor_Q16; - gain_factor_Q16 = silk_log2lin( silk_LSHIFT( nBits - maxBits, 7 ) / psEnc->sCmn.frame_length + SILK_FIX_CONST( 16, 7 ) ); - gainMult_Q8 = silk_SMULWB( gain_factor_Q16, gainMult_Q8 ); - } - - } else { - /* Adjust gain by interpolating */ - gainMult_Q8 = gainMult_lower + silk_DIV32_16( silk_MUL( gainMult_upper - gainMult_lower, maxBits - nBits_lower ), nBits_upper - nBits_lower ); - /* New gain multplier must be between 25% and 75% of old range (note that gainMult_upper < gainMult_lower) */ - if( gainMult_Q8 > silk_ADD_RSHIFT32( gainMult_lower, gainMult_upper - gainMult_lower, 2 ) ) { - gainMult_Q8 = silk_ADD_RSHIFT32( gainMult_lower, gainMult_upper - gainMult_lower, 2 ); - } else - if( gainMult_Q8 < silk_SUB_RSHIFT32( gainMult_upper, gainMult_upper - gainMult_lower, 2 ) ) { - gainMult_Q8 = silk_SUB_RSHIFT32( gainMult_upper, gainMult_upper - gainMult_lower, 2 ); - } - } - - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - opus_int16 tmp; - if ( gain_lock[i] ) { - tmp = best_gain_mult[i]; - } else { - tmp = gainMult_Q8; - } - sEncCtrl.Gains_Q16[ i ] = silk_LSHIFT_SAT32( silk_SMULWB( sEncCtrl.GainsUnq_Q16[ i ], tmp ), 8 ); - } - - /* Quantize gains */ - psEnc->sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev; - silk_gains_quant( psEnc->sCmn.indices.GainsIndices, sEncCtrl.Gains_Q16, - &psEnc->sShape.LastGainIndex, condCoding == CODE_CONDITIONALLY, psEnc->sCmn.nb_subfr ); - - /* Unique identifier of gains vector */ - gainsID = silk_gains_ID( psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr ); - } - } - - /* Update input buffer */ - silk_memmove( psEnc->x_buf, &psEnc->x_buf[ psEnc->sCmn.frame_length ], - ( psEnc->sCmn.ltp_mem_length + LA_SHAPE_MS * psEnc->sCmn.fs_kHz ) * sizeof( opus_int16 ) ); - - /* Exit without entropy coding */ - if( psEnc->sCmn.prefillFlag ) { - /* No payload */ - *pnBytesOut = 0; - RESTORE_STACK; - return ret; - } - - /* Parameters needed for next frame */ - psEnc->sCmn.prevLag = sEncCtrl.pitchL[ psEnc->sCmn.nb_subfr - 1 ]; - psEnc->sCmn.prevSignalType = psEnc->sCmn.indices.signalType; - - /****************************************/ - /* Finalize payload */ - /****************************************/ - psEnc->sCmn.first_frame_after_reset = 0; - /* Payload size */ - *pnBytesOut = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); - - RESTORE_STACK; - return ret; -} - -/* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */ -static OPUS_INLINE void silk_LBRR_encode_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ - const opus_int16 x16[], /* I Input signal */ - opus_int condCoding /* I The type of conditional coding used so far for this frame */ -) -{ - opus_int32 TempGains_Q16[ MAX_NB_SUBFR ]; - SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesEncoded ]; - silk_nsq_state sNSQ_LBRR; - - /*******************************************/ - /* Control use of inband LBRR */ - /*******************************************/ - if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SILK_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) { - psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded ] = 1; - - /* Copy noise shaping quantizer state and quantization indices from regular encoding */ - silk_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); - silk_memcpy( psIndices_LBRR, &psEnc->sCmn.indices, sizeof( SideInfoIndices ) ); - - /* Save original gains */ - silk_memcpy( TempGains_Q16, psEncCtrl->Gains_Q16, psEnc->sCmn.nb_subfr * sizeof( opus_int32 ) ); - - if( psEnc->sCmn.nFramesEncoded == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded - 1 ] == 0 ) { - /* First frame in packet or previous frame not LBRR coded */ - psEnc->sCmn.LBRRprevLastGainIndex = psEnc->sShape.LastGainIndex; - - /* Increase Gains to get target LBRR rate */ - psIndices_LBRR->GainsIndices[ 0 ] = psIndices_LBRR->GainsIndices[ 0 ] + psEnc->sCmn.LBRR_GainIncreases; - psIndices_LBRR->GainsIndices[ 0 ] = silk_min_int( psIndices_LBRR->GainsIndices[ 0 ], N_LEVELS_QGAIN - 1 ); - } - - /* Decode to get gains in sync with decoder */ - /* Overwrite unquantized gains with quantized gains */ - silk_gains_dequant( psEncCtrl->Gains_Q16, psIndices_LBRR->GainsIndices, - &psEnc->sCmn.LBRRprevLastGainIndex, condCoding == CODE_CONDITIONALLY, psEnc->sCmn.nb_subfr ); - - /*****************************************/ - /* Noise shaping quantization */ - /*****************************************/ - if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { - silk_NSQ_del_dec( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, x16, - psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, - psEncCtrl->AR_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, - psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14, psEnc->sCmn.arch ); - } else { - silk_NSQ( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, x16, - psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, - psEncCtrl->AR_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, - psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14, psEnc->sCmn.arch ); - } - - /* Restore original gains */ - silk_memcpy( psEncCtrl->Gains_Q16, TempGains_Q16, psEnc->sCmn.nb_subfr * sizeof( opus_int32 ) ); - } -} diff --git a/Engine/lib/opus/silk/fixed/find_LPC_FIX.c b/Engine/lib/opus/silk/fixed/find_LPC_FIX.c deleted file mode 100644 index c762a0f2a..000000000 --- a/Engine/lib/opus/silk/fixed/find_LPC_FIX.c +++ /dev/null @@ -1,151 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" -#include "stack_alloc.h" -#include "tuning_parameters.h" - -/* Finds LPC vector from correlations, and converts to NLSF */ -void silk_find_LPC_FIX( - silk_encoder_state *psEncC, /* I/O Encoder state */ - opus_int16 NLSF_Q15[], /* O NLSFs */ - const opus_int16 x[], /* I Input signal */ - const opus_int32 minInvGain_Q30 /* I Inverse of max prediction gain */ -) -{ - opus_int k, subfr_length; - opus_int32 a_Q16[ MAX_LPC_ORDER ]; - opus_int isInterpLower, shift; - opus_int32 res_nrg0, res_nrg1; - opus_int rshift0, rshift1; - - /* Used only for LSF interpolation */ - opus_int32 a_tmp_Q16[ MAX_LPC_ORDER ], res_nrg_interp, res_nrg, res_tmp_nrg; - opus_int res_nrg_interp_Q, res_nrg_Q, res_tmp_nrg_Q; - opus_int16 a_tmp_Q12[ MAX_LPC_ORDER ]; - opus_int16 NLSF0_Q15[ MAX_LPC_ORDER ]; - SAVE_STACK; - - subfr_length = psEncC->subfr_length + psEncC->predictLPCOrder; - - /* Default: no interpolation */ - psEncC->indices.NLSFInterpCoef_Q2 = 4; - - /* Burg AR analysis for the full frame */ - silk_burg_modified( &res_nrg, &res_nrg_Q, a_Q16, x, minInvGain_Q30, subfr_length, psEncC->nb_subfr, psEncC->predictLPCOrder, psEncC->arch ); - - if( psEncC->useInterpolatedNLSFs && !psEncC->first_frame_after_reset && psEncC->nb_subfr == MAX_NB_SUBFR ) { - VARDECL( opus_int16, LPC_res ); - - /* Optimal solution for last 10 ms */ - silk_burg_modified( &res_tmp_nrg, &res_tmp_nrg_Q, a_tmp_Q16, x + 2 * subfr_length, minInvGain_Q30, subfr_length, 2, psEncC->predictLPCOrder, psEncC->arch ); - - /* subtract residual energy here, as that's easier than adding it to the */ - /* residual energy of the first 10 ms in each iteration of the search below */ - shift = res_tmp_nrg_Q - res_nrg_Q; - if( shift >= 0 ) { - if( shift < 32 ) { - res_nrg = res_nrg - silk_RSHIFT( res_tmp_nrg, shift ); - } - } else { - silk_assert( shift > -32 ); - res_nrg = silk_RSHIFT( res_nrg, -shift ) - res_tmp_nrg; - res_nrg_Q = res_tmp_nrg_Q; - } - - /* Convert to NLSFs */ - silk_A2NLSF( NLSF_Q15, a_tmp_Q16, psEncC->predictLPCOrder ); - - ALLOC( LPC_res, 2 * subfr_length, opus_int16 ); - - /* Search over interpolation indices to find the one with lowest residual energy */ - for( k = 3; k >= 0; k-- ) { - /* Interpolate NLSFs for first half */ - silk_interpolate( NLSF0_Q15, psEncC->prev_NLSFq_Q15, NLSF_Q15, k, psEncC->predictLPCOrder ); - - /* Convert to LPC for residual energy evaluation */ - silk_NLSF2A( a_tmp_Q12, NLSF0_Q15, psEncC->predictLPCOrder, psEncC->arch ); - - /* Calculate residual energy with NLSF interpolation */ - silk_LPC_analysis_filter( LPC_res, x, a_tmp_Q12, 2 * subfr_length, psEncC->predictLPCOrder, psEncC->arch ); - - silk_sum_sqr_shift( &res_nrg0, &rshift0, LPC_res + psEncC->predictLPCOrder, subfr_length - psEncC->predictLPCOrder ); - silk_sum_sqr_shift( &res_nrg1, &rshift1, LPC_res + psEncC->predictLPCOrder + subfr_length, subfr_length - psEncC->predictLPCOrder ); - - /* Add subframe energies from first half frame */ - shift = rshift0 - rshift1; - if( shift >= 0 ) { - res_nrg1 = silk_RSHIFT( res_nrg1, shift ); - res_nrg_interp_Q = -rshift0; - } else { - res_nrg0 = silk_RSHIFT( res_nrg0, -shift ); - res_nrg_interp_Q = -rshift1; - } - res_nrg_interp = silk_ADD32( res_nrg0, res_nrg1 ); - - /* Compare with first half energy without NLSF interpolation, or best interpolated value so far */ - shift = res_nrg_interp_Q - res_nrg_Q; - if( shift >= 0 ) { - if( silk_RSHIFT( res_nrg_interp, shift ) < res_nrg ) { - isInterpLower = silk_TRUE; - } else { - isInterpLower = silk_FALSE; - } - } else { - if( -shift < 32 ) { - if( res_nrg_interp < silk_RSHIFT( res_nrg, -shift ) ) { - isInterpLower = silk_TRUE; - } else { - isInterpLower = silk_FALSE; - } - } else { - isInterpLower = silk_FALSE; - } - } - - /* Determine whether current interpolated NLSFs are best so far */ - if( isInterpLower == silk_TRUE ) { - /* Interpolation has lower residual energy */ - res_nrg = res_nrg_interp; - res_nrg_Q = res_nrg_interp_Q; - psEncC->indices.NLSFInterpCoef_Q2 = (opus_int8)k; - } - } - } - - if( psEncC->indices.NLSFInterpCoef_Q2 == 4 ) { - /* NLSF interpolation is currently inactive, calculate NLSFs from full frame AR coefficients */ - silk_A2NLSF( NLSF_Q15, a_Q16, psEncC->predictLPCOrder ); - } - - celt_assert( psEncC->indices.NLSFInterpCoef_Q2 == 4 || ( psEncC->useInterpolatedNLSFs && !psEncC->first_frame_after_reset && psEncC->nb_subfr == MAX_NB_SUBFR ) ); - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/fixed/find_LTP_FIX.c b/Engine/lib/opus/silk/fixed/find_LTP_FIX.c deleted file mode 100644 index 62d4afb25..000000000 --- a/Engine/lib/opus/silk/fixed/find_LTP_FIX.c +++ /dev/null @@ -1,99 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" -#include "tuning_parameters.h" - -void silk_find_LTP_FIX( - opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */ - opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */ - const opus_int16 r_ptr[], /* I Residual signal after LPC */ - const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I Number of subframes */ - int arch /* I Run-time architecture */ -) -{ - opus_int i, k, extra_shifts; - opus_int xx_shifts, xX_shifts, XX_shifts; - const opus_int16 *lag_ptr; - opus_int32 *XXLTP_Q17_ptr, *xXLTP_Q17_ptr; - opus_int32 xx, nrg, temp; - - xXLTP_Q17_ptr = xXLTP_Q17; - XXLTP_Q17_ptr = XXLTP_Q17; - for( k = 0; k < nb_subfr; k++ ) { - lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 ); - - silk_sum_sqr_shift( &xx, &xx_shifts, r_ptr, subfr_length + LTP_ORDER ); /* xx in Q( -xx_shifts ) */ - silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, XXLTP_Q17_ptr, &nrg, &XX_shifts, arch ); /* XXLTP_Q17_ptr and nrg in Q( -XX_shifts ) */ - extra_shifts = xx_shifts - XX_shifts; - if( extra_shifts > 0 ) { - /* Shift XX */ - xX_shifts = xx_shifts; - for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { - XXLTP_Q17_ptr[ i ] = silk_RSHIFT32( XXLTP_Q17_ptr[ i ], extra_shifts ); /* Q( -xX_shifts ) */ - } - nrg = silk_RSHIFT32( nrg, extra_shifts ); /* Q( -xX_shifts ) */ - } else if( extra_shifts < 0 ) { - /* Shift xx */ - xX_shifts = XX_shifts; - xx = silk_RSHIFT32( xx, -extra_shifts ); /* Q( -xX_shifts ) */ - } else { - xX_shifts = xx_shifts; - } - silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, xXLTP_Q17_ptr, xX_shifts, arch ); /* xXLTP_Q17_ptr in Q( -xX_shifts ) */ - - /* At this point all correlations are in Q(-xX_shifts) */ - temp = silk_SMLAWB( 1, nrg, SILK_FIX_CONST( LTP_CORR_INV_MAX, 16 ) ); - temp = silk_max( temp, xx ); -TIC(div) -#if 0 - for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { - XXLTP_Q17_ptr[ i ] = silk_DIV32_varQ( XXLTP_Q17_ptr[ i ], temp, 17 ); - } - for( i = 0; i < LTP_ORDER; i++ ) { - xXLTP_Q17_ptr[ i ] = silk_DIV32_varQ( xXLTP_Q17_ptr[ i ], temp, 17 ); - } -#else - for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { - XXLTP_Q17_ptr[ i ] = (opus_int32)( silk_LSHIFT64( (opus_int64)XXLTP_Q17_ptr[ i ], 17 ) / temp ); - } - for( i = 0; i < LTP_ORDER; i++ ) { - xXLTP_Q17_ptr[ i ] = (opus_int32)( silk_LSHIFT64( (opus_int64)xXLTP_Q17_ptr[ i ], 17 ) / temp ); - } -#endif -TOC(div) - r_ptr += subfr_length; - XXLTP_Q17_ptr += LTP_ORDER * LTP_ORDER; - xXLTP_Q17_ptr += LTP_ORDER; - } -} diff --git a/Engine/lib/opus/silk/fixed/find_pitch_lags_FIX.c b/Engine/lib/opus/silk/fixed/find_pitch_lags_FIX.c deleted file mode 100644 index 6c3379f2b..000000000 --- a/Engine/lib/opus/silk/fixed/find_pitch_lags_FIX.c +++ /dev/null @@ -1,143 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" -#include "stack_alloc.h" -#include "tuning_parameters.h" - -/* Find pitch lags */ -void silk_find_pitch_lags_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - opus_int16 res[], /* O residual */ - const opus_int16 x[], /* I Speech signal */ - int arch /* I Run-time architecture */ -) -{ - opus_int buf_len, i, scale; - opus_int32 thrhld_Q13, res_nrg; - const opus_int16 *x_ptr; - VARDECL( opus_int16, Wsig ); - opus_int16 *Wsig_ptr; - opus_int32 auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ]; - opus_int16 rc_Q15[ MAX_FIND_PITCH_LPC_ORDER ]; - opus_int32 A_Q24[ MAX_FIND_PITCH_LPC_ORDER ]; - opus_int16 A_Q12[ MAX_FIND_PITCH_LPC_ORDER ]; - SAVE_STACK; - - /******************************************/ - /* Set up buffer lengths etc based on Fs */ - /******************************************/ - buf_len = psEnc->sCmn.la_pitch + psEnc->sCmn.frame_length + psEnc->sCmn.ltp_mem_length; - - /* Safety check */ - celt_assert( buf_len >= psEnc->sCmn.pitch_LPC_win_length ); - - /*************************************/ - /* Estimate LPC AR coefficients */ - /*************************************/ - - /* Calculate windowed signal */ - - ALLOC( Wsig, psEnc->sCmn.pitch_LPC_win_length, opus_int16 ); - - /* First LA_LTP samples */ - x_ptr = x + buf_len - psEnc->sCmn.pitch_LPC_win_length; - Wsig_ptr = Wsig; - silk_apply_sine_window( Wsig_ptr, x_ptr, 1, psEnc->sCmn.la_pitch ); - - /* Middle un - windowed samples */ - Wsig_ptr += psEnc->sCmn.la_pitch; - x_ptr += psEnc->sCmn.la_pitch; - silk_memcpy( Wsig_ptr, x_ptr, ( psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT( psEnc->sCmn.la_pitch, 1 ) ) * sizeof( opus_int16 ) ); - - /* Last LA_LTP samples */ - Wsig_ptr += psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT( psEnc->sCmn.la_pitch, 1 ); - x_ptr += psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT( psEnc->sCmn.la_pitch, 1 ); - silk_apply_sine_window( Wsig_ptr, x_ptr, 2, psEnc->sCmn.la_pitch ); - - /* Calculate autocorrelation sequence */ - silk_autocorr( auto_corr, &scale, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1, arch ); - - /* Add white noise, as fraction of energy */ - auto_corr[ 0 ] = silk_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], SILK_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ) + 1; - - /* Calculate the reflection coefficients using schur */ - res_nrg = silk_schur( rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder ); - - /* Prediction gain */ - psEncCtrl->predGain_Q16 = silk_DIV32_varQ( auto_corr[ 0 ], silk_max_int( res_nrg, 1 ), 16 ); - - /* Convert reflection coefficients to prediction coefficients */ - silk_k2a( A_Q24, rc_Q15, psEnc->sCmn.pitchEstimationLPCOrder ); - - /* Convert From 32 bit Q24 to 16 bit Q12 coefs */ - for( i = 0; i < psEnc->sCmn.pitchEstimationLPCOrder; i++ ) { - A_Q12[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT( A_Q24[ i ], 12 ) ); - } - - /* Do BWE */ - silk_bwexpander( A_Q12, psEnc->sCmn.pitchEstimationLPCOrder, SILK_FIX_CONST( FIND_PITCH_BANDWIDTH_EXPANSION, 16 ) ); - - /*****************************************/ - /* LPC analysis filtering */ - /*****************************************/ - silk_LPC_analysis_filter( res, x, A_Q12, buf_len, psEnc->sCmn.pitchEstimationLPCOrder, psEnc->sCmn.arch ); - - if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0 ) { - /* Threshold for pitch estimator */ - thrhld_Q13 = SILK_FIX_CONST( 0.6, 13 ); - thrhld_Q13 = silk_SMLABB( thrhld_Q13, SILK_FIX_CONST( -0.004, 13 ), psEnc->sCmn.pitchEstimationLPCOrder ); - thrhld_Q13 = silk_SMLAWB( thrhld_Q13, SILK_FIX_CONST( -0.1, 21 ), psEnc->sCmn.speech_activity_Q8 ); - thrhld_Q13 = silk_SMLABB( thrhld_Q13, SILK_FIX_CONST( -0.15, 13 ), silk_RSHIFT( psEnc->sCmn.prevSignalType, 1 ) ); - thrhld_Q13 = silk_SMLAWB( thrhld_Q13, SILK_FIX_CONST( -0.1, 14 ), psEnc->sCmn.input_tilt_Q15 ); - thrhld_Q13 = silk_SAT16( thrhld_Q13 ); - - /*****************************************/ - /* Call pitch estimator */ - /*****************************************/ - if( silk_pitch_analysis_core( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, &psEnc->sCmn.indices.contourIndex, - &psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16, - (opus_int)thrhld_Q13, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr, - psEnc->sCmn.arch) == 0 ) - { - psEnc->sCmn.indices.signalType = TYPE_VOICED; - } else { - psEnc->sCmn.indices.signalType = TYPE_UNVOICED; - } - } else { - silk_memset( psEncCtrl->pitchL, 0, sizeof( psEncCtrl->pitchL ) ); - psEnc->sCmn.indices.lagIndex = 0; - psEnc->sCmn.indices.contourIndex = 0; - psEnc->LTPCorr_Q15 = 0; - } - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/fixed/find_pred_coefs_FIX.c b/Engine/lib/opus/silk/fixed/find_pred_coefs_FIX.c deleted file mode 100644 index ad363fb7b..000000000 --- a/Engine/lib/opus/silk/fixed/find_pred_coefs_FIX.c +++ /dev/null @@ -1,146 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" -#include "stack_alloc.h" - -void silk_find_pred_coefs_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - const opus_int16 res_pitch[], /* I Residual from pitch analysis */ - const opus_int16 x[], /* I Speech signal */ - opus_int condCoding /* I The type of conditional coding to use */ -) -{ - opus_int i; - opus_int32 invGains_Q16[ MAX_NB_SUBFR ], local_gains[ MAX_NB_SUBFR ]; - /* Set to NLSF_Q15 to zero so we don't copy junk to the state. */ - opus_int16 NLSF_Q15[ MAX_LPC_ORDER ]={0}; - const opus_int16 *x_ptr; - opus_int16 *x_pre_ptr; - VARDECL( opus_int16, LPC_in_pre ); - opus_int32 min_gain_Q16, minInvGain_Q30; - SAVE_STACK; - - /* weighting for weighted least squares */ - min_gain_Q16 = silk_int32_MAX >> 6; - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - min_gain_Q16 = silk_min( min_gain_Q16, psEncCtrl->Gains_Q16[ i ] ); - } - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - /* Divide to Q16 */ - silk_assert( psEncCtrl->Gains_Q16[ i ] > 0 ); - /* Invert and normalize gains, and ensure that maximum invGains_Q16 is within range of a 16 bit int */ - invGains_Q16[ i ] = silk_DIV32_varQ( min_gain_Q16, psEncCtrl->Gains_Q16[ i ], 16 - 2 ); - - /* Limit inverse */ - invGains_Q16[ i ] = silk_max( invGains_Q16[ i ], 100 ); - - /* Square the inverted gains */ - silk_assert( invGains_Q16[ i ] == silk_SAT16( invGains_Q16[ i ] ) ); - - /* Invert the inverted and normalized gains */ - local_gains[ i ] = silk_DIV32( ( (opus_int32)1 << 16 ), invGains_Q16[ i ] ); - } - - ALLOC( LPC_in_pre, - psEnc->sCmn.nb_subfr * psEnc->sCmn.predictLPCOrder - + psEnc->sCmn.frame_length, opus_int16 ); - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - VARDECL( opus_int32, xXLTP_Q17 ); - VARDECL( opus_int32, XXLTP_Q17 ); - - /**********/ - /* VOICED */ - /**********/ - celt_assert( psEnc->sCmn.ltp_mem_length - psEnc->sCmn.predictLPCOrder >= psEncCtrl->pitchL[ 0 ] + LTP_ORDER / 2 ); - - ALLOC( xXLTP_Q17, psEnc->sCmn.nb_subfr * LTP_ORDER, opus_int32 ); - ALLOC( XXLTP_Q17, psEnc->sCmn.nb_subfr * LTP_ORDER * LTP_ORDER, opus_int32 ); - - /* LTP analysis */ - silk_find_LTP_FIX( XXLTP_Q17, xXLTP_Q17, res_pitch, - psEncCtrl->pitchL, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.arch ); - - /* Quantize LTP gain parameters */ - silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, - &psEnc->sCmn.sum_log_gain_Q7, &psEncCtrl->LTPredCodGain_Q7, XXLTP_Q17, xXLTP_Q17, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.arch ); - - /* Control LTP scaling */ - silk_LTP_scale_ctrl_FIX( psEnc, psEncCtrl, condCoding ); - - /* Create LTP residual */ - silk_LTP_analysis_filter_FIX( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef_Q14, - psEncCtrl->pitchL, invGains_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder ); - - } else { - /************/ - /* UNVOICED */ - /************/ - /* Create signal with prepended subframes, scaled by inverse gains */ - x_ptr = x - psEnc->sCmn.predictLPCOrder; - x_pre_ptr = LPC_in_pre; - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - silk_scale_copy_vector16( x_pre_ptr, x_ptr, invGains_Q16[ i ], - psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder ); - x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder; - x_ptr += psEnc->sCmn.subfr_length; - } - - silk_memset( psEncCtrl->LTPCoef_Q14, 0, psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( opus_int16 ) ); - psEncCtrl->LTPredCodGain_Q7 = 0; - psEnc->sCmn.sum_log_gain_Q7 = 0; - } - - /* Limit on total predictive coding gain */ - if( psEnc->sCmn.first_frame_after_reset ) { - minInvGain_Q30 = SILK_FIX_CONST( 1.0f / MAX_PREDICTION_POWER_GAIN_AFTER_RESET, 30 ); - } else { - minInvGain_Q30 = silk_log2lin( silk_SMLAWB( 16 << 7, (opus_int32)psEncCtrl->LTPredCodGain_Q7, SILK_FIX_CONST( 1.0 / 3, 16 ) ) ); /* Q16 */ - minInvGain_Q30 = silk_DIV32_varQ( minInvGain_Q30, - silk_SMULWW( SILK_FIX_CONST( MAX_PREDICTION_POWER_GAIN, 0 ), - silk_SMLAWB( SILK_FIX_CONST( 0.25, 18 ), SILK_FIX_CONST( 0.75, 18 ), psEncCtrl->coding_quality_Q14 ) ), 14 ); - } - - /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */ - silk_find_LPC_FIX( &psEnc->sCmn, NLSF_Q15, LPC_in_pre, minInvGain_Q30 ); - - /* Quantize LSFs */ - silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 ); - - /* Calculate residual energy using quantized LPC coefficients */ - silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains, - psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder, psEnc->sCmn.arch ); - - /* Copy to prediction struct for use in next frame for interpolation */ - silk_memcpy( psEnc->sCmn.prev_NLSFq_Q15, NLSF_Q15, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) ); - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/fixed/k2a_FIX.c b/Engine/lib/opus/silk/fixed/k2a_FIX.c deleted file mode 100644 index 549f6eada..000000000 --- a/Engine/lib/opus/silk/fixed/k2a_FIX.c +++ /dev/null @@ -1,54 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Step up function, converts reflection coefficients to prediction coefficients */ -void silk_k2a( - opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ - const opus_int16 *rc_Q15, /* I Reflection coefficients [order] Q15 */ - const opus_int32 order /* I Prediction order */ -) -{ - opus_int k, n; - opus_int32 rc, tmp1, tmp2; - - for( k = 0; k < order; k++ ) { - rc = rc_Q15[ k ]; - for( n = 0; n < (k + 1) >> 1; n++ ) { - tmp1 = A_Q24[ n ]; - tmp2 = A_Q24[ k - n - 1 ]; - A_Q24[ n ] = silk_SMLAWB( tmp1, silk_LSHIFT( tmp2, 1 ), rc ); - A_Q24[ k - n - 1 ] = silk_SMLAWB( tmp2, silk_LSHIFT( tmp1, 1 ), rc ); - } - A_Q24[ k ] = -silk_LSHIFT( (opus_int32)rc_Q15[ k ], 9 ); - } -} diff --git a/Engine/lib/opus/silk/fixed/k2a_Q16_FIX.c b/Engine/lib/opus/silk/fixed/k2a_Q16_FIX.c deleted file mode 100644 index 1595aa621..000000000 --- a/Engine/lib/opus/silk/fixed/k2a_Q16_FIX.c +++ /dev/null @@ -1,54 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Step up function, converts reflection coefficients to prediction coefficients */ -void silk_k2a_Q16( - opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */ - const opus_int32 *rc_Q16, /* I Reflection coefficients [order] Q16 */ - const opus_int32 order /* I Prediction order */ -) -{ - opus_int k, n; - opus_int32 rc, tmp1, tmp2; - - for( k = 0; k < order; k++ ) { - rc = rc_Q16[ k ]; - for( n = 0; n < (k + 1) >> 1; n++ ) { - tmp1 = A_Q24[ n ]; - tmp2 = A_Q24[ k - n - 1 ]; - A_Q24[ n ] = silk_SMLAWW( tmp1, tmp2, rc ); - A_Q24[ k - n - 1 ] = silk_SMLAWW( tmp2, tmp1, rc ); - } - A_Q24[ k ] = -silk_LSHIFT( rc, 8 ); - } -} diff --git a/Engine/lib/opus/silk/fixed/main_FIX.h b/Engine/lib/opus/silk/fixed/main_FIX.h deleted file mode 100644 index 6d2112e51..000000000 --- a/Engine/lib/opus/silk/fixed/main_FIX.h +++ /dev/null @@ -1,244 +0,0 @@ -/*********************************************************************** -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 SILK_MAIN_FIX_H -#define SILK_MAIN_FIX_H - -#include "SigProc_FIX.h" -#include "structs_FIX.h" -#include "control.h" -#include "main.h" -#include "PLC.h" -#include "debug.h" -#include "entenc.h" - -#if ((defined(OPUS_ARM_ASM) && defined(FIXED_POINT)) \ - || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) -#include "fixed/arm/warped_autocorrelation_FIX_arm.h" -#endif - -#ifndef FORCE_CPP_BUILD -#ifdef __cplusplus -extern "C" -{ -#endif -#endif - -#define silk_encoder_state_Fxx silk_encoder_state_FIX -#define silk_encode_do_VAD_Fxx silk_encode_do_VAD_FIX -#define silk_encode_frame_Fxx silk_encode_frame_FIX - -#define QC 10 -#define QS 13 - -/*********************/ -/* Encoder Functions */ -/*********************/ - -/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */ -void silk_HP_variable_cutoff( - silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */ -); - -/* Encoder main function */ -void silk_encode_do_VAD_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - opus_int activity /* I Decision of Opus voice activity detector */ -); - -/* Encoder main function */ -opus_int silk_encode_frame_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */ - ec_enc *psRangeEnc, /* I/O compressor data structure */ - opus_int condCoding, /* I The type of conditional coding to use */ - opus_int maxBits, /* I If > 0: maximum number of output bits */ - opus_int useCBR /* I Flag to force constant-bitrate operation */ -); - -/* Initializes the Silk encoder state */ -opus_int silk_init_encoder( - silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk FIX encoder state */ - int arch /* I Run-time architecture */ -); - -/* Control the Silk encoder */ -opus_int silk_control_encoder( - silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */ - silk_EncControlStruct *encControl, /* I Control structure */ - const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ - const opus_int channelNb, /* I Channel number */ - const opus_int force_fs_kHz -); - -/**************************/ -/* Noise shaping analysis */ -/**************************/ -/* Compute noise shaping coefficients and initial gain values */ -void silk_noise_shape_analysis_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ - const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */ - const opus_int16 *x, /* I Input signal [ frame_length + la_shape ] */ - int arch /* I Run-time architecture */ -); - -/* Autocorrelations for a warped frequency axis */ -void silk_warped_autocorrelation_FIX_c( - opus_int32 *corr, /* O Result [order + 1] */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *input, /* I Input data to correlate */ - const opus_int warping_Q16, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ -); - -#if !defined(OVERRIDE_silk_warped_autocorrelation_FIX) -#define silk_warped_autocorrelation_FIX(corr, scale, input, warping_Q16, length, order, arch) \ - ((void)(arch), silk_warped_autocorrelation_FIX_c(corr, scale, input, warping_Q16, length, order)) -#endif - -/* Calculation of LTP state scaling */ -void silk_LTP_scale_ctrl_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -/**********************************************/ -/* Prediction Analysis */ -/**********************************************/ -/* Find pitch lags */ -void silk_find_pitch_lags_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - opus_int16 res[], /* O residual */ - const opus_int16 x[], /* I Speech signal */ - int arch /* I Run-time architecture */ -); - -/* Find LPC and LTP coefficients */ -void silk_find_pred_coefs_FIX( - silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ - const opus_int16 res_pitch[], /* I Residual from pitch analysis */ - const opus_int16 x[], /* I Speech signal */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -/* LPC analysis */ -void silk_find_LPC_FIX( - silk_encoder_state *psEncC, /* I/O Encoder state */ - opus_int16 NLSF_Q15[], /* O NLSFs */ - const opus_int16 x[], /* I Input signal */ - const opus_int32 minInvGain_Q30 /* I Inverse of max prediction gain */ -); - -/* LTP analysis */ -void silk_find_LTP_FIX( - opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */ - opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */ - const opus_int16 r_lpc[], /* I Residual signal after LPC */ - const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I Number of subframes */ - int arch /* I Run-time architecture */ -); - -void silk_LTP_analysis_filter_FIX( - opus_int16 *LTP_res, /* O LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */ - const opus_int16 *x, /* I Pointer to input signal with at least max( pitchL ) preceding samples */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag, one for each subframe */ - const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I Inverse quantization gains, one for each subframe */ - const opus_int subfr_length, /* I Length of each subframe */ - const opus_int nb_subfr, /* I Number of subframes */ - const opus_int pre_length /* I Length of the preceding samples starting at &x[0] for each subframe */ -); - -/* Calculates residual energies of input subframes where all subframes have LPC_order */ -/* of preceding samples */ -void silk_residual_energy_FIX( - opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ - opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */ - const opus_int16 x[], /* I Input signal */ - opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ - const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I Number of subframes */ - const opus_int LPC_order, /* I LPC order */ - int arch /* I Run-time architecture */ -); - -/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -opus_int32 silk_residual_energy16_covar_FIX( - const opus_int16 *c, /* I Prediction vector */ - const opus_int32 *wXX, /* I Correlation matrix */ - const opus_int32 *wXx, /* I Correlation vector */ - opus_int32 wxx, /* I Signal energy */ - opus_int D, /* I Dimension */ - opus_int cQ /* I Q value for c vector 0 - 15 */ -); - -/* Processing of gains */ -void silk_process_gains_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -/******************/ -/* Linear Algebra */ -/******************/ -/* Calculates correlation matrix X'*X */ -void silk_corrMatrix_FIX( - const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ - const opus_int L, /* I Length of vectors */ - const opus_int order, /* I Max lag for correlation */ - opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */ - opus_int32 *nrg, /* O Energy of x vector */ - opus_int *rshifts, /* O Right shifts of correlations */ - int arch /* I Run-time architecture */ -); - -/* Calculates correlation vector X'*t */ -void silk_corrVector_FIX( - const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ - const opus_int16 *t, /* I Target vector [L] */ - const opus_int L, /* I Length of vectors */ - const opus_int order, /* I Max lag for correlation */ - opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */ - const opus_int rshifts, /* I Right shifts of correlations */ - int arch /* I Run-time architecture */ -); - -#ifndef FORCE_CPP_BUILD -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* FORCE_CPP_BUILD */ -#endif /* SILK_MAIN_FIX_H */ diff --git a/Engine/lib/opus/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h b/Engine/lib/opus/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h deleted file mode 100644 index 3999b5bd0..000000000 --- a/Engine/lib/opus/silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h +++ /dev/null @@ -1,336 +0,0 @@ -/*********************************************************************** -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. -***********************************************************************/ - - -/**************************************************************/ -/* Compute noise shaping coefficients and initial gain values */ -/**************************************************************/ -#define OVERRIDE_silk_noise_shape_analysis_FIX - -void silk_noise_shape_analysis_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ - const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */ - const opus_int16 *x, /* I Input signal [ frame_length + la_shape ] */ - int arch /* I Run-time architecture */ -) -{ - silk_shape_state_FIX *psShapeSt = &psEnc->sShape; - opus_int k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0; - opus_int32 SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp32; - opus_int32 nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_variation_Q7; - opus_int32 delta_Q16, BWExp1_Q16, BWExp2_Q16, gain_mult_Q16, gain_add_Q16, strength_Q16, b_Q8; - opus_int32 auto_corr[ MAX_SHAPE_LPC_ORDER + 1 ]; - opus_int32 refl_coef_Q16[ MAX_SHAPE_LPC_ORDER ]; - opus_int32 AR1_Q24[ MAX_SHAPE_LPC_ORDER ]; - opus_int32 AR2_Q24[ MAX_SHAPE_LPC_ORDER ]; - VARDECL( opus_int16, x_windowed ); - const opus_int16 *x_ptr, *pitch_res_ptr; - SAVE_STACK; - - /* Point to start of first LPC analysis block */ - x_ptr = x - psEnc->sCmn.la_shape; - - /****************/ - /* GAIN CONTROL */ - /****************/ - SNR_adj_dB_Q7 = psEnc->sCmn.SNR_dB_Q7; - - /* Input quality is the average of the quality in the lowest two VAD bands */ - psEncCtrl->input_quality_Q14 = ( opus_int )silk_RSHIFT( (opus_int32)psEnc->sCmn.input_quality_bands_Q15[ 0 ] - + psEnc->sCmn.input_quality_bands_Q15[ 1 ], 2 ); - - /* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */ - psEncCtrl->coding_quality_Q14 = silk_RSHIFT( silk_sigm_Q15( silk_RSHIFT_ROUND( SNR_adj_dB_Q7 - - SILK_FIX_CONST( 20.0, 7 ), 4 ) ), 1 ); - - /* Reduce coding SNR during low speech activity */ - if( psEnc->sCmn.useCBR == 0 ) { - b_Q8 = SILK_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8; - b_Q8 = silk_SMULWB( silk_LSHIFT( b_Q8, 8 ), b_Q8 ); - SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, - silk_SMULBB( SILK_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ), /* Q11*/ - silk_SMULWB( SILK_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) ); /* Q12*/ - } - - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Reduce gains for periodic signals */ - SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, SILK_FIX_CONST( HARM_SNR_INCR_dB, 8 ), psEnc->LTPCorr_Q15 ); - } else { - /* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */ - SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, - silk_SMLAWB( SILK_FIX_CONST( 6.0, 9 ), -SILK_FIX_CONST( 0.4, 18 ), psEnc->sCmn.SNR_dB_Q7 ), - SILK_FIX_CONST( 1.0, 14 ) - psEncCtrl->input_quality_Q14 ); - } - - /*************************/ - /* SPARSENESS PROCESSING */ - /*************************/ - /* Set quantizer offset */ - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Initially set to 0; may be overruled in process_gains(..) */ - psEnc->sCmn.indices.quantOffsetType = 0; - psEncCtrl->sparseness_Q8 = 0; - } else { - /* Sparseness measure, based on relative fluctuations of energy per 2 milliseconds */ - nSamples = silk_LSHIFT( psEnc->sCmn.fs_kHz, 1 ); - energy_variation_Q7 = 0; - log_energy_prev_Q7 = 0; - pitch_res_ptr = pitch_res; - for( k = 0; k < silk_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr ) / 2; k++ ) { - silk_sum_sqr_shift( &nrg, &scale, pitch_res_ptr, nSamples ); - nrg += silk_RSHIFT( nSamples, scale ); /* Q(-scale)*/ - - log_energy_Q7 = silk_lin2log( nrg ); - if( k > 0 ) { - energy_variation_Q7 += silk_abs( log_energy_Q7 - log_energy_prev_Q7 ); - } - log_energy_prev_Q7 = log_energy_Q7; - pitch_res_ptr += nSamples; - } - - psEncCtrl->sparseness_Q8 = silk_RSHIFT( silk_sigm_Q15( silk_SMULWB( energy_variation_Q7 - - SILK_FIX_CONST( 5.0, 7 ), SILK_FIX_CONST( 0.1, 16 ) ) ), 7 ); - - /* Set quantization offset depending on sparseness measure */ - if( psEncCtrl->sparseness_Q8 > SILK_FIX_CONST( SPARSENESS_THRESHOLD_QNT_OFFSET, 8 ) ) { - psEnc->sCmn.indices.quantOffsetType = 0; - } else { - psEnc->sCmn.indices.quantOffsetType = 1; - } - - /* Increase coding SNR for sparse signals */ - SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, SILK_FIX_CONST( SPARSE_SNR_INCR_dB, 15 ), psEncCtrl->sparseness_Q8 - SILK_FIX_CONST( 0.5, 8 ) ); - } - - /*******************************/ - /* Control bandwidth expansion */ - /*******************************/ - /* More BWE for signals with high prediction gain */ - strength_Q16 = silk_SMULWB( psEncCtrl->predGain_Q16, SILK_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ); - BWExp1_Q16 = BWExp2_Q16 = silk_DIV32_varQ( SILK_FIX_CONST( BANDWIDTH_EXPANSION, 16 ), - silk_SMLAWW( SILK_FIX_CONST( 1.0, 16 ), strength_Q16, strength_Q16 ), 16 ); - delta_Q16 = silk_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - silk_SMULBB( 3, psEncCtrl->coding_quality_Q14 ), - SILK_FIX_CONST( LOW_RATE_BANDWIDTH_EXPANSION_DELTA, 16 ) ); - BWExp1_Q16 = silk_SUB32( BWExp1_Q16, delta_Q16 ); - BWExp2_Q16 = silk_ADD32( BWExp2_Q16, delta_Q16 ); - /* BWExp1 will be applied after BWExp2, so make it relative */ - BWExp1_Q16 = silk_DIV32_16( silk_LSHIFT( BWExp1_Q16, 14 ), silk_RSHIFT( BWExp2_Q16, 2 ) ); - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Slightly more warping in analysis will move quantization noise up in frequency, where it's better masked */ - warping_Q16 = silk_SMLAWB( psEnc->sCmn.warping_Q16, (opus_int32)psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( 0.01, 18 ) ); - } else { - warping_Q16 = 0; - } - - /********************************************/ - /* Compute noise shaping AR coefs and gains */ - /********************************************/ - ALLOC( x_windowed, psEnc->sCmn.shapeWinLength, opus_int16 ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - /* Apply window: sine slope followed by flat part followed by cosine slope */ - opus_int shift, slope_part, flat_part; - flat_part = psEnc->sCmn.fs_kHz * 3; - slope_part = silk_RSHIFT( psEnc->sCmn.shapeWinLength - flat_part, 1 ); - - silk_apply_sine_window( x_windowed, x_ptr, 1, slope_part ); - shift = slope_part; - silk_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(opus_int16) ); - shift += flat_part; - silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part ); - - /* Update pointer: next LPC analysis block */ - x_ptr += psEnc->sCmn.subfr_length; - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Calculate warped auto correlation */ - silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warping_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder, arch ); - } else { - /* Calculate regular auto correlation */ - silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1, arch ); - } - - /* Add white noise, as a fraction of energy */ - auto_corr[0] = silk_ADD32( auto_corr[0], silk_max_32( silk_SMULWB( silk_RSHIFT( auto_corr[ 0 ], 4 ), - SILK_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) ); - - /* Calculate the reflection coefficients using schur */ - nrg = silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrder ); - silk_assert( nrg >= 0 ); - - /* Convert reflection coefficients to prediction coefficients */ - silk_k2a_Q16( AR2_Q24, refl_coef_Q16, psEnc->sCmn.shapingLPCOrder ); - - Qnrg = -scale; /* range: -12...30*/ - silk_assert( Qnrg >= -12 ); - silk_assert( Qnrg <= 30 ); - - /* Make sure that Qnrg is an even number */ - if( Qnrg & 1 ) { - Qnrg -= 1; - nrg >>= 1; - } - - tmp32 = silk_SQRT_APPROX( nrg ); - Qnrg >>= 1; /* range: -6...15*/ - - psEncCtrl->Gains_Q16[ k ] = (silk_LSHIFT32( silk_LIMIT( (tmp32), silk_RSHIFT32( silk_int32_MIN, (16 - Qnrg) ), \ - silk_RSHIFT32( silk_int32_MAX, (16 - Qnrg) ) ), (16 - Qnrg) )); - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Adjust gain for warping */ - gain_mult_Q16 = warped_gain( AR2_Q24, warping_Q16, psEnc->sCmn.shapingLPCOrder ); - silk_assert( psEncCtrl->Gains_Q16[ k ] >= 0 ); - if ( silk_SMULWW( silk_RSHIFT_ROUND( psEncCtrl->Gains_Q16[ k ], 1 ), gain_mult_Q16 ) >= ( silk_int32_MAX >> 1 ) ) { - psEncCtrl->Gains_Q16[ k ] = silk_int32_MAX; - } else { - psEncCtrl->Gains_Q16[ k ] = silk_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 ); - } - } - - /* Bandwidth expansion for synthesis filter shaping */ - silk_bwexpander_32( AR2_Q24, psEnc->sCmn.shapingLPCOrder, BWExp2_Q16 ); - - /* Compute noise shaping filter coefficients */ - silk_memcpy( AR1_Q24, AR2_Q24, psEnc->sCmn.shapingLPCOrder * sizeof( opus_int32 ) ); - - /* Bandwidth expansion for analysis filter shaping */ - silk_assert( BWExp1_Q16 <= SILK_FIX_CONST( 1.0, 16 ) ); - silk_bwexpander_32( AR1_Q24, psEnc->sCmn.shapingLPCOrder, BWExp1_Q16 ); - - /* Ratio of prediction gains, in energy domain */ - pre_nrg_Q30 = silk_LPC_inverse_pred_gain_Q24( AR2_Q24, psEnc->sCmn.shapingLPCOrder, arch ); - nrg = silk_LPC_inverse_pred_gain_Q24( AR1_Q24, psEnc->sCmn.shapingLPCOrder, arch ); - - /*psEncCtrl->GainsPre[ k ] = 1.0f - 0.7f * ( 1.0f - pre_nrg / nrg ) = 0.3f + 0.7f * pre_nrg / nrg;*/ - pre_nrg_Q30 = silk_LSHIFT32( silk_SMULWB( pre_nrg_Q30, SILK_FIX_CONST( 0.7, 15 ) ), 1 ); - psEncCtrl->GainsPre_Q14[ k ] = ( opus_int ) SILK_FIX_CONST( 0.3, 14 ) + silk_DIV32_varQ( pre_nrg_Q30, nrg, 14 ); - - /* Convert to monic warped prediction coefficients and limit absolute values */ - limit_warped_coefs( AR2_Q24, AR1_Q24, warping_Q16, SILK_FIX_CONST( 3.999, 24 ), psEnc->sCmn.shapingLPCOrder ); - - /* Convert from Q24 to Q13 and store in int16 */ - for( i = 0; i < psEnc->sCmn.shapingLPCOrder; i++ ) { - psEncCtrl->AR1_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( AR1_Q24[ i ], 11 ) ); - psEncCtrl->AR2_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( AR2_Q24[ i ], 11 ) ); - } - } - - /*****************/ - /* Gain tweaking */ - /*****************/ - /* Increase gains during low speech activity and put lower limit on gains */ - gain_mult_Q16 = silk_log2lin( -silk_SMLAWB( -SILK_FIX_CONST( 16.0, 7 ), SNR_adj_dB_Q7, SILK_FIX_CONST( 0.16, 16 ) ) ); - gain_add_Q16 = silk_log2lin( silk_SMLAWB( SILK_FIX_CONST( 16.0, 7 ), SILK_FIX_CONST( MIN_QGAIN_DB, 7 ), SILK_FIX_CONST( 0.16, 16 ) ) ); - silk_assert( gain_mult_Q16 > 0 ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->Gains_Q16[ k ] = silk_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 ); - silk_assert( psEncCtrl->Gains_Q16[ k ] >= 0 ); - psEncCtrl->Gains_Q16[ k ] = silk_ADD_POS_SAT32( psEncCtrl->Gains_Q16[ k ], gain_add_Q16 ); - } - - gain_mult_Q16 = SILK_FIX_CONST( 1.0, 16 ) + silk_RSHIFT_ROUND( silk_MLA( SILK_FIX_CONST( INPUT_TILT, 26 ), - psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ), 10 ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->GainsPre_Q14[ k ] = silk_SMULWB( gain_mult_Q16, psEncCtrl->GainsPre_Q14[ k ] ); - } - - /************************************************/ - /* Control low-frequency shaping and noise tilt */ - /************************************************/ - /* Less low frequency shaping for noisy inputs */ - strength_Q16 = silk_MUL( SILK_FIX_CONST( LOW_FREQ_SHAPING, 4 ), silk_SMLAWB( SILK_FIX_CONST( 1.0, 12 ), - SILK_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 13 ), psEnc->sCmn.input_quality_bands_Q15[ 0 ] - SILK_FIX_CONST( 1.0, 15 ) ) ); - strength_Q16 = silk_RSHIFT( silk_MUL( strength_Q16, psEnc->sCmn.speech_activity_Q8 ), 8 ); - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */ - /*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/ - opus_int fs_kHz_inv = silk_DIV32_16( SILK_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - b_Q14 = fs_kHz_inv + silk_DIV32_16( SILK_FIX_CONST( 3.0, 14 ), psEncCtrl->pitchL[ k ] ); - /* Pack two coefficients in one int32 */ - psEncCtrl->LF_shp_Q14[ k ] = silk_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - silk_SMULWB( strength_Q16, b_Q14 ), 16 ); - psEncCtrl->LF_shp_Q14[ k ] |= (opus_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) ); - } - silk_assert( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SILK_FIX_CONST( 0.5, 24 ) ); /* Guarantees that second argument to SMULWB() is within range of an opus_int16*/ - Tilt_Q16 = - SILK_FIX_CONST( HP_NOISE_COEF, 16 ) - - silk_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - SILK_FIX_CONST( HP_NOISE_COEF, 16 ), - silk_SMULWB( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->sCmn.speech_activity_Q8 ) ); - } else { - b_Q14 = silk_DIV32_16( 21299, psEnc->sCmn.fs_kHz ); /* 1.3_Q0 = 21299_Q14*/ - /* Pack two coefficients in one int32 */ - psEncCtrl->LF_shp_Q14[ 0 ] = silk_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - - silk_SMULWB( strength_Q16, silk_SMULWB( SILK_FIX_CONST( 0.6, 16 ), b_Q14 ) ), 16 ); - psEncCtrl->LF_shp_Q14[ 0 ] |= (opus_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) ); - for( k = 1; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->LF_shp_Q14[ k ] = psEncCtrl->LF_shp_Q14[ 0 ]; - } - Tilt_Q16 = -SILK_FIX_CONST( HP_NOISE_COEF, 16 ); - } - - /****************************/ - /* HARMONIC SHAPING CONTROL */ - /****************************/ - /* Control boosting of harmonic frequencies */ - HarmBoost_Q16 = silk_SMULWB( silk_SMULWB( SILK_FIX_CONST( 1.0, 17 ) - silk_LSHIFT( psEncCtrl->coding_quality_Q14, 3 ), - psEnc->LTPCorr_Q15 ), SILK_FIX_CONST( LOW_RATE_HARMONIC_BOOST, 16 ) ); - - /* More harmonic boost for noisy input signals */ - HarmBoost_Q16 = silk_SMLAWB( HarmBoost_Q16, - SILK_FIX_CONST( 1.0, 16 ) - silk_LSHIFT( psEncCtrl->input_quality_Q14, 2 ), SILK_FIX_CONST( LOW_INPUT_QUALITY_HARMONIC_BOOST, 16 ) ); - - if( USE_HARM_SHAPING && psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* More harmonic noise shaping for high bitrates or noisy input */ - HarmShapeGain_Q16 = silk_SMLAWB( SILK_FIX_CONST( HARMONIC_SHAPING, 16 ), - SILK_FIX_CONST( 1.0, 16 ) - silk_SMULWB( SILK_FIX_CONST( 1.0, 18 ) - silk_LSHIFT( psEncCtrl->coding_quality_Q14, 4 ), - psEncCtrl->input_quality_Q14 ), SILK_FIX_CONST( HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING, 16 ) ); - - /* Less harmonic noise shaping for less periodic signals */ - HarmShapeGain_Q16 = silk_SMULWB( silk_LSHIFT( HarmShapeGain_Q16, 1 ), - silk_SQRT_APPROX( silk_LSHIFT( psEnc->LTPCorr_Q15, 15 ) ) ); - } else { - HarmShapeGain_Q16 = 0; - } - - /*************************/ - /* Smooth over subframes */ - /*************************/ - for( k = 0; k < MAX_NB_SUBFR; k++ ) { - psShapeSt->HarmBoost_smth_Q16 = - silk_SMLAWB( psShapeSt->HarmBoost_smth_Q16, HarmBoost_Q16 - psShapeSt->HarmBoost_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); - psShapeSt->HarmShapeGain_smth_Q16 = - silk_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); - psShapeSt->Tilt_smth_Q16 = - silk_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); - - psEncCtrl->HarmBoost_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psShapeSt->HarmBoost_smth_Q16, 2 ); - psEncCtrl->HarmShapeGain_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psShapeSt->HarmShapeGain_smth_Q16, 2 ); - psEncCtrl->Tilt_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psShapeSt->Tilt_smth_Q16, 2 ); - } - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/fixed/mips/prefilter_FIX_mipsr1.h b/Engine/lib/opus/silk/fixed/mips/prefilter_FIX_mipsr1.h deleted file mode 100644 index 21b256885..000000000 --- a/Engine/lib/opus/silk/fixed/mips/prefilter_FIX_mipsr1.h +++ /dev/null @@ -1,184 +0,0 @@ -/*********************************************************************** -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 __PREFILTER_FIX_MIPSR1_H__ -#define __PREFILTER_FIX_MIPSR1_H__ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "main_FIX.h" -#include "stack_alloc.h" -#include "tuning_parameters.h" - -#define OVERRIDE_silk_warped_LPC_analysis_filter_FIX -void silk_warped_LPC_analysis_filter_FIX( - opus_int32 state[], /* I/O State [order + 1] */ - opus_int32 res_Q2[], /* O Residual signal [length] */ - const opus_int16 coef_Q13[], /* I Coefficients [order] */ - const opus_int16 input[], /* I Input signal [length] */ - const opus_int16 lambda_Q16, /* I Warping factor */ - const opus_int length, /* I Length of input signal */ - const opus_int order, /* I Filter order (even) */ - int arch -) -{ - opus_int n, i; - opus_int32 acc_Q11, acc_Q22, tmp1, tmp2, tmp3, tmp4; - opus_int32 state_cur, state_next; - - (void)arch; - - /* Order must be even */ - /* Length must be even */ - - silk_assert( ( order & 1 ) == 0 ); - silk_assert( ( length & 1 ) == 0 ); - - for( n = 0; n < length; n+=2 ) { - /* Output of lowpass section */ - tmp2 = silk_SMLAWB( state[ 0 ], state[ 1 ], lambda_Q16 ); - state_cur = silk_LSHIFT( input[ n ], 14 ); - /* Output of allpass section */ - tmp1 = silk_SMLAWB( state[ 1 ], state[ 2 ] - tmp2, lambda_Q16 ); - state_next = tmp2; - acc_Q11 = silk_RSHIFT( order, 1 ); - acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ 0 ] ); - - - /* Output of lowpass section */ - tmp4 = silk_SMLAWB( state_cur, state_next, lambda_Q16 ); - state[ 0 ] = silk_LSHIFT( input[ n+1 ], 14 ); - /* Output of allpass section */ - tmp3 = silk_SMLAWB( state_next, tmp1 - tmp4, lambda_Q16 ); - state[ 1 ] = tmp4; - acc_Q22 = silk_RSHIFT( order, 1 ); - acc_Q22 = silk_SMLAWB( acc_Q22, tmp4, coef_Q13[ 0 ] ); - - /* Loop over allpass sections */ - for( i = 2; i < order; i += 2 ) { - /* Output of allpass section */ - tmp2 = silk_SMLAWB( state[ i ], state[ i + 1 ] - tmp1, lambda_Q16 ); - state_cur = tmp1; - acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ i - 1 ] ); - /* Output of allpass section */ - tmp1 = silk_SMLAWB( state[ i + 1 ], state[ i + 2 ] - tmp2, lambda_Q16 ); - state_next = tmp2; - acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ i ] ); - - - /* Output of allpass section */ - tmp4 = silk_SMLAWB( state_cur, state_next - tmp3, lambda_Q16 ); - state[ i ] = tmp3; - acc_Q22 = silk_SMLAWB( acc_Q22, tmp3, coef_Q13[ i - 1 ] ); - /* Output of allpass section */ - tmp3 = silk_SMLAWB( state_next, tmp1 - tmp4, lambda_Q16 ); - state[ i + 1 ] = tmp4; - acc_Q22 = silk_SMLAWB( acc_Q22, tmp4, coef_Q13[ i ] ); - } - acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ order - 1 ] ); - res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROUND( acc_Q11, 9 ); - - state[ order ] = tmp3; - acc_Q22 = silk_SMLAWB( acc_Q22, tmp3, coef_Q13[ order - 1 ] ); - res_Q2[ n+1 ] = silk_LSHIFT( (opus_int32)input[ n+1 ], 2 ) - silk_RSHIFT_ROUND( acc_Q22, 9 ); - } -} - - - -/* Prefilter for finding Quantizer input signal */ -#define OVERRIDE_silk_prefilt_FIX -static inline void silk_prefilt_FIX( - silk_prefilter_state_FIX *P, /* I/O state */ - opus_int32 st_res_Q12[], /* I short term residual signal */ - opus_int32 xw_Q3[], /* O prefiltered signal */ - opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */ - opus_int Tilt_Q14, /* I Tilt shaping coeficient */ - opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients */ - opus_int lag, /* I Lag for harmonic shaping */ - opus_int length /* I Length of signals */ -) -{ - opus_int i, idx, LTP_shp_buf_idx; - opus_int32 n_LTP_Q12, n_Tilt_Q10, n_LF_Q10; - opus_int32 sLF_MA_shp_Q12, sLF_AR_shp_Q12; - opus_int16 *LTP_shp_buf; - - /* To speed up use temp variables instead of using the struct */ - LTP_shp_buf = P->sLTP_shp; - LTP_shp_buf_idx = P->sLTP_shp_buf_idx; - sLF_AR_shp_Q12 = P->sLF_AR_shp_Q12; - sLF_MA_shp_Q12 = P->sLF_MA_shp_Q12; - - if( lag > 0 ) { - for( i = 0; i < length; i++ ) { - /* unrolled loop */ - silk_assert( HARM_SHAPE_FIR_TAPS == 3 ); - idx = lag + LTP_shp_buf_idx; - n_LTP_Q12 = silk_SMULBB( LTP_shp_buf[ ( idx - HARM_SHAPE_FIR_TAPS / 2 - 1) & LTP_MASK ], HarmShapeFIRPacked_Q12 ); - n_LTP_Q12 = silk_SMLABT( n_LTP_Q12, LTP_shp_buf[ ( idx - HARM_SHAPE_FIR_TAPS / 2 ) & LTP_MASK ], HarmShapeFIRPacked_Q12 ); - n_LTP_Q12 = silk_SMLABB( n_LTP_Q12, LTP_shp_buf[ ( idx - HARM_SHAPE_FIR_TAPS / 2 + 1) & LTP_MASK ], HarmShapeFIRPacked_Q12 ); - - n_Tilt_Q10 = silk_SMULWB( sLF_AR_shp_Q12, Tilt_Q14 ); - n_LF_Q10 = silk_SMLAWB( silk_SMULWT( sLF_AR_shp_Q12, LF_shp_Q14 ), sLF_MA_shp_Q12, LF_shp_Q14 ); - - sLF_AR_shp_Q12 = silk_SUB32( st_res_Q12[ i ], silk_LSHIFT( n_Tilt_Q10, 2 ) ); - sLF_MA_shp_Q12 = silk_SUB32( sLF_AR_shp_Q12, silk_LSHIFT( n_LF_Q10, 2 ) ); - - LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & LTP_MASK; - LTP_shp_buf[ LTP_shp_buf_idx ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sLF_MA_shp_Q12, 12 ) ); - - xw_Q3[i] = silk_RSHIFT_ROUND( silk_SUB32( sLF_MA_shp_Q12, n_LTP_Q12 ), 9 ); - } - } - else - { - for( i = 0; i < length; i++ ) { - - n_LTP_Q12 = 0; - - n_Tilt_Q10 = silk_SMULWB( sLF_AR_shp_Q12, Tilt_Q14 ); - n_LF_Q10 = silk_SMLAWB( silk_SMULWT( sLF_AR_shp_Q12, LF_shp_Q14 ), sLF_MA_shp_Q12, LF_shp_Q14 ); - - sLF_AR_shp_Q12 = silk_SUB32( st_res_Q12[ i ], silk_LSHIFT( n_Tilt_Q10, 2 ) ); - sLF_MA_shp_Q12 = silk_SUB32( sLF_AR_shp_Q12, silk_LSHIFT( n_LF_Q10, 2 ) ); - - LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & LTP_MASK; - LTP_shp_buf[ LTP_shp_buf_idx ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sLF_MA_shp_Q12, 12 ) ); - - xw_Q3[i] = silk_RSHIFT_ROUND( sLF_MA_shp_Q12, 9 ); - } - } - - /* Copy temp variable back to state */ - P->sLF_AR_shp_Q12 = sLF_AR_shp_Q12; - P->sLF_MA_shp_Q12 = sLF_MA_shp_Q12; - P->sLTP_shp_buf_idx = LTP_shp_buf_idx; -} - -#endif /* __PREFILTER_FIX_MIPSR1_H__ */ diff --git a/Engine/lib/opus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h b/Engine/lib/opus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h deleted file mode 100644 index 66eb2ed26..000000000 --- a/Engine/lib/opus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h +++ /dev/null @@ -1,165 +0,0 @@ -/*********************************************************************** -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 __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ -#define __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "main_FIX.h" - -#undef QC -#define QC 10 - -#undef QS -#define QS 14 - -/* Autocorrelations for a warped frequency axis */ -#define OVERRIDE_silk_warped_autocorrelation_FIX_c -void silk_warped_autocorrelation_FIX_c( - opus_int32 *corr, /* O Result [order + 1] */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *input, /* I Input data to correlate */ - const opus_int warping_Q16, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ -) -{ - opus_int n, i, lsh; - opus_int32 tmp1_QS=0, tmp2_QS=0, tmp3_QS=0, tmp4_QS=0, tmp5_QS=0, tmp6_QS=0, tmp7_QS=0, tmp8_QS=0, start_1=0, start_2=0, start_3=0; - opus_int32 state_QS[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; - opus_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; - opus_int64 temp64; - - opus_int32 val; - val = 2 * QS - QC; - - /* Order must be even */ - silk_assert( ( order & 1 ) == 0 ); - silk_assert( 2 * QS - QC >= 0 ); - - /* Loop over samples */ - for( n = 0; n < length; n=n+4 ) { - - tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS ); - start_1 = tmp1_QS; - tmp3_QS = silk_LSHIFT32( (opus_int32)input[ n+1], QS ); - start_2 = tmp3_QS; - tmp5_QS = silk_LSHIFT32( (opus_int32)input[ n+2], QS ); - start_3 = tmp5_QS; - tmp7_QS = silk_LSHIFT32( (opus_int32)input[ n+3], QS ); - - /* Loop over allpass sections */ - for( i = 0; i < order; i += 2 ) { - /* Output of allpass section */ - tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 ); - corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp1_QS, start_1); - - tmp4_QS = silk_SMLAWB( tmp1_QS, tmp2_QS - tmp3_QS, warping_Q16 ); - corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp3_QS, start_2); - - tmp6_QS = silk_SMLAWB( tmp3_QS, tmp4_QS - tmp5_QS, warping_Q16 ); - corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp5_QS, start_3); - - tmp8_QS = silk_SMLAWB( tmp5_QS, tmp6_QS - tmp7_QS, warping_Q16 ); - state_QS[ i ] = tmp7_QS; - corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp7_QS, state_QS[0]); - - /* Output of allpass section */ - tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 ); - corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp2_QS, start_1); - - tmp3_QS = silk_SMLAWB( tmp2_QS, tmp1_QS - tmp4_QS, warping_Q16 ); - corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp4_QS, start_2); - - tmp5_QS = silk_SMLAWB( tmp4_QS, tmp3_QS - tmp6_QS, warping_Q16 ); - corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp6_QS, start_3); - - tmp7_QS = silk_SMLAWB( tmp6_QS, tmp5_QS - tmp8_QS, warping_Q16 ); - state_QS[ i + 1 ] = tmp8_QS; - corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp8_QS, state_QS[ 0 ]); - - } - state_QS[ order ] = tmp7_QS; - - corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp1_QS, start_1); - corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp3_QS, start_2); - corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp5_QS, start_3); - corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp7_QS, state_QS[ 0 ]); - } - - for(;n< length; n++ ) { - - tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS ); - - /* Loop over allpass sections */ - for( i = 0; i < order; i += 2 ) { - - /* Output of allpass section */ - tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 ); - state_QS[ i ] = tmp1_QS; - corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp1_QS, state_QS[ 0 ]); - - /* Output of allpass section */ - tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 ); - state_QS[ i + 1 ] = tmp2_QS; - corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp2_QS, state_QS[ 0 ]); - } - state_QS[ order ] = tmp1_QS; - corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp1_QS, state_QS[ 0 ]); - } - - temp64 = corr_QC[ 0 ]; - temp64 = __builtin_mips_shilo(temp64, val); - - lsh = silk_CLZ64( temp64 ) - 35; - lsh = silk_LIMIT( lsh, -12 - QC, 30 - QC ); - *scale = -( QC + lsh ); - silk_assert( *scale >= -30 && *scale <= 12 ); - if( lsh >= 0 ) { - for( i = 0; i < order + 1; i++ ) { - temp64 = corr_QC[ i ]; - //temp64 = __builtin_mips_shilo(temp64, val); - temp64 = (val >= 0) ? (temp64 >> val) : (temp64 << -val); - corr[ i ] = (opus_int32)silk_CHECK_FIT32( __builtin_mips_shilo( temp64, -lsh ) ); - } - } else { - for( i = 0; i < order + 1; i++ ) { - temp64 = corr_QC[ i ]; - //temp64 = __builtin_mips_shilo(temp64, val); - temp64 = (val >= 0) ? (temp64 >> val) : (temp64 << -val); - corr[ i ] = (opus_int32)silk_CHECK_FIT32( __builtin_mips_shilo( temp64, -lsh ) ); - } - } - - corr_QC[ 0 ] = __builtin_mips_shilo(corr_QC[ 0 ], val); - - silk_assert( corr_QC[ 0 ] >= 0 ); /* If breaking, decrease QC*/ -} -#endif /* __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ */ diff --git a/Engine/lib/opus/silk/fixed/noise_shape_analysis_FIX.c b/Engine/lib/opus/silk/fixed/noise_shape_analysis_FIX.c deleted file mode 100644 index 85fea0bf0..000000000 --- a/Engine/lib/opus/silk/fixed/noise_shape_analysis_FIX.c +++ /dev/null @@ -1,407 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" -#include "stack_alloc.h" -#include "tuning_parameters.h" - -/* Compute gain to make warped filter coefficients have a zero mean log frequency response on a */ -/* non-warped frequency scale. (So that it can be implemented with a minimum-phase monic filter.) */ -/* Note: A monic filter is one with the first coefficient equal to 1.0. In Silk we omit the first */ -/* coefficient in an array of coefficients, for monic filters. */ -static OPUS_INLINE opus_int32 warped_gain( /* gain in Q16*/ - const opus_int32 *coefs_Q24, - opus_int lambda_Q16, - opus_int order -) { - opus_int i; - opus_int32 gain_Q24; - - lambda_Q16 = -lambda_Q16; - gain_Q24 = coefs_Q24[ order - 1 ]; - for( i = order - 2; i >= 0; i-- ) { - gain_Q24 = silk_SMLAWB( coefs_Q24[ i ], gain_Q24, lambda_Q16 ); - } - gain_Q24 = silk_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), gain_Q24, -lambda_Q16 ); - return silk_INVERSE32_varQ( gain_Q24, 40 ); -} - -/* Convert warped filter coefficients to monic pseudo-warped coefficients and limit maximum */ -/* amplitude of monic warped coefficients by using bandwidth expansion on the true coefficients */ -static OPUS_INLINE void limit_warped_coefs( - opus_int32 *coefs_Q24, - opus_int lambda_Q16, - opus_int32 limit_Q24, - opus_int order -) { - opus_int i, iter, ind = 0; - opus_int32 tmp, maxabs_Q24, chirp_Q16, gain_Q16; - opus_int32 nom_Q16, den_Q24; - opus_int32 limit_Q20, maxabs_Q20; - - /* Convert to monic coefficients */ - lambda_Q16 = -lambda_Q16; - for( i = order - 1; i > 0; i-- ) { - coefs_Q24[ i - 1 ] = silk_SMLAWB( coefs_Q24[ i - 1 ], coefs_Q24[ i ], lambda_Q16 ); - } - lambda_Q16 = -lambda_Q16; - nom_Q16 = silk_SMLAWB( SILK_FIX_CONST( 1.0, 16 ), -(opus_int32)lambda_Q16, lambda_Q16 ); - den_Q24 = silk_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_Q24[ 0 ], lambda_Q16 ); - gain_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 ); - for( i = 0; i < order; i++ ) { - coefs_Q24[ i ] = silk_SMULWW( gain_Q16, coefs_Q24[ i ] ); - } - limit_Q20 = silk_RSHIFT(limit_Q24, 4); - for( iter = 0; iter < 10; iter++ ) { - /* Find maximum absolute value */ - maxabs_Q24 = -1; - for( i = 0; i < order; i++ ) { - tmp = silk_abs_int32( coefs_Q24[ i ] ); - if( tmp > maxabs_Q24 ) { - maxabs_Q24 = tmp; - ind = i; - } - } - /* Use Q20 to avoid any overflow when multiplying by (ind + 1) later. */ - maxabs_Q20 = silk_RSHIFT(maxabs_Q24, 4); - if( maxabs_Q20 <= limit_Q20 ) { - /* Coefficients are within range - done */ - return; - } - - /* Convert back to true warped coefficients */ - for( i = 1; i < order; i++ ) { - coefs_Q24[ i - 1 ] = silk_SMLAWB( coefs_Q24[ i - 1 ], coefs_Q24[ i ], lambda_Q16 ); - } - gain_Q16 = silk_INVERSE32_varQ( gain_Q16, 32 ); - for( i = 0; i < order; i++ ) { - coefs_Q24[ i ] = silk_SMULWW( gain_Q16, coefs_Q24[ i ] ); - } - - /* Apply bandwidth expansion */ - chirp_Q16 = SILK_FIX_CONST( 0.99, 16 ) - silk_DIV32_varQ( - silk_SMULWB( maxabs_Q20 - limit_Q20, silk_SMLABB( SILK_FIX_CONST( 0.8, 10 ), SILK_FIX_CONST( 0.1, 10 ), iter ) ), - silk_MUL( maxabs_Q20, ind + 1 ), 22 ); - silk_bwexpander_32( coefs_Q24, order, chirp_Q16 ); - - /* Convert to monic warped coefficients */ - lambda_Q16 = -lambda_Q16; - for( i = order - 1; i > 0; i-- ) { - coefs_Q24[ i - 1 ] = silk_SMLAWB( coefs_Q24[ i - 1 ], coefs_Q24[ i ], lambda_Q16 ); - } - lambda_Q16 = -lambda_Q16; - nom_Q16 = silk_SMLAWB( SILK_FIX_CONST( 1.0, 16 ), -(opus_int32)lambda_Q16, lambda_Q16 ); - den_Q24 = silk_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_Q24[ 0 ], lambda_Q16 ); - gain_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 ); - for( i = 0; i < order; i++ ) { - coefs_Q24[ i ] = silk_SMULWW( gain_Q16, coefs_Q24[ i ] ); - } - } - silk_assert( 0 ); -} - -/* Disable MIPS version until it's updated. */ -#if 0 && defined(MIPSr1_ASM) -#include "mips/noise_shape_analysis_FIX_mipsr1.h" -#endif - -/**************************************************************/ -/* Compute noise shaping coefficients and initial gain values */ -/**************************************************************/ -#ifndef OVERRIDE_silk_noise_shape_analysis_FIX -void silk_noise_shape_analysis_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ - const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */ - const opus_int16 *x, /* I Input signal [ frame_length + la_shape ] */ - int arch /* I Run-time architecture */ -) -{ - silk_shape_state_FIX *psShapeSt = &psEnc->sShape; - opus_int k, i, nSamples, nSegs, Qnrg, b_Q14, warping_Q16, scale = 0; - opus_int32 SNR_adj_dB_Q7, HarmShapeGain_Q16, Tilt_Q16, tmp32; - opus_int32 nrg, log_energy_Q7, log_energy_prev_Q7, energy_variation_Q7; - opus_int32 BWExp_Q16, gain_mult_Q16, gain_add_Q16, strength_Q16, b_Q8; - opus_int32 auto_corr[ MAX_SHAPE_LPC_ORDER + 1 ]; - opus_int32 refl_coef_Q16[ MAX_SHAPE_LPC_ORDER ]; - opus_int32 AR_Q24[ MAX_SHAPE_LPC_ORDER ]; - VARDECL( opus_int16, x_windowed ); - const opus_int16 *x_ptr, *pitch_res_ptr; - SAVE_STACK; - - /* Point to start of first LPC analysis block */ - x_ptr = x - psEnc->sCmn.la_shape; - - /****************/ - /* GAIN CONTROL */ - /****************/ - SNR_adj_dB_Q7 = psEnc->sCmn.SNR_dB_Q7; - - /* Input quality is the average of the quality in the lowest two VAD bands */ - psEncCtrl->input_quality_Q14 = ( opus_int )silk_RSHIFT( (opus_int32)psEnc->sCmn.input_quality_bands_Q15[ 0 ] - + psEnc->sCmn.input_quality_bands_Q15[ 1 ], 2 ); - - /* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */ - psEncCtrl->coding_quality_Q14 = silk_RSHIFT( silk_sigm_Q15( silk_RSHIFT_ROUND( SNR_adj_dB_Q7 - - SILK_FIX_CONST( 20.0, 7 ), 4 ) ), 1 ); - - /* Reduce coding SNR during low speech activity */ - if( psEnc->sCmn.useCBR == 0 ) { - b_Q8 = SILK_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8; - b_Q8 = silk_SMULWB( silk_LSHIFT( b_Q8, 8 ), b_Q8 ); - SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, - silk_SMULBB( SILK_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ), /* Q11*/ - silk_SMULWB( SILK_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) ); /* Q12*/ - } - - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Reduce gains for periodic signals */ - SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, SILK_FIX_CONST( HARM_SNR_INCR_dB, 8 ), psEnc->LTPCorr_Q15 ); - } else { - /* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */ - SNR_adj_dB_Q7 = silk_SMLAWB( SNR_adj_dB_Q7, - silk_SMLAWB( SILK_FIX_CONST( 6.0, 9 ), -SILK_FIX_CONST( 0.4, 18 ), psEnc->sCmn.SNR_dB_Q7 ), - SILK_FIX_CONST( 1.0, 14 ) - psEncCtrl->input_quality_Q14 ); - } - - /*************************/ - /* SPARSENESS PROCESSING */ - /*************************/ - /* Set quantizer offset */ - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Initially set to 0; may be overruled in process_gains(..) */ - psEnc->sCmn.indices.quantOffsetType = 0; - } else { - /* Sparseness measure, based on relative fluctuations of energy per 2 milliseconds */ - nSamples = silk_LSHIFT( psEnc->sCmn.fs_kHz, 1 ); - energy_variation_Q7 = 0; - log_energy_prev_Q7 = 0; - pitch_res_ptr = pitch_res; - nSegs = silk_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr ) / 2; - for( k = 0; k < nSegs; k++ ) { - silk_sum_sqr_shift( &nrg, &scale, pitch_res_ptr, nSamples ); - nrg += silk_RSHIFT( nSamples, scale ); /* Q(-scale)*/ - - log_energy_Q7 = silk_lin2log( nrg ); - if( k > 0 ) { - energy_variation_Q7 += silk_abs( log_energy_Q7 - log_energy_prev_Q7 ); - } - log_energy_prev_Q7 = log_energy_Q7; - pitch_res_ptr += nSamples; - } - - /* Set quantization offset depending on sparseness measure */ - if( energy_variation_Q7 > SILK_FIX_CONST( ENERGY_VARIATION_THRESHOLD_QNT_OFFSET, 7 ) * (nSegs-1) ) { - psEnc->sCmn.indices.quantOffsetType = 0; - } else { - psEnc->sCmn.indices.quantOffsetType = 1; - } - } - - /*******************************/ - /* Control bandwidth expansion */ - /*******************************/ - /* More BWE for signals with high prediction gain */ - strength_Q16 = silk_SMULWB( psEncCtrl->predGain_Q16, SILK_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ); - BWExp_Q16 = silk_DIV32_varQ( SILK_FIX_CONST( BANDWIDTH_EXPANSION, 16 ), - silk_SMLAWW( SILK_FIX_CONST( 1.0, 16 ), strength_Q16, strength_Q16 ), 16 ); - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Slightly more warping in analysis will move quantization noise up in frequency, where it's better masked */ - warping_Q16 = silk_SMLAWB( psEnc->sCmn.warping_Q16, (opus_int32)psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( 0.01, 18 ) ); - } else { - warping_Q16 = 0; - } - - /********************************************/ - /* Compute noise shaping AR coefs and gains */ - /********************************************/ - ALLOC( x_windowed, psEnc->sCmn.shapeWinLength, opus_int16 ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - /* Apply window: sine slope followed by flat part followed by cosine slope */ - opus_int shift, slope_part, flat_part; - flat_part = psEnc->sCmn.fs_kHz * 3; - slope_part = silk_RSHIFT( psEnc->sCmn.shapeWinLength - flat_part, 1 ); - - silk_apply_sine_window( x_windowed, x_ptr, 1, slope_part ); - shift = slope_part; - silk_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(opus_int16) ); - shift += flat_part; - silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part ); - - /* Update pointer: next LPC analysis block */ - x_ptr += psEnc->sCmn.subfr_length; - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Calculate warped auto correlation */ - silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warping_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder, arch ); - } else { - /* Calculate regular auto correlation */ - silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1, arch ); - } - - /* Add white noise, as a fraction of energy */ - auto_corr[0] = silk_ADD32( auto_corr[0], silk_max_32( silk_SMULWB( silk_RSHIFT( auto_corr[ 0 ], 4 ), - SILK_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) ); - - /* Calculate the reflection coefficients using schur */ - nrg = silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrder ); - silk_assert( nrg >= 0 ); - - /* Convert reflection coefficients to prediction coefficients */ - silk_k2a_Q16( AR_Q24, refl_coef_Q16, psEnc->sCmn.shapingLPCOrder ); - - Qnrg = -scale; /* range: -12...30*/ - silk_assert( Qnrg >= -12 ); - silk_assert( Qnrg <= 30 ); - - /* Make sure that Qnrg is an even number */ - if( Qnrg & 1 ) { - Qnrg -= 1; - nrg >>= 1; - } - - tmp32 = silk_SQRT_APPROX( nrg ); - Qnrg >>= 1; /* range: -6...15*/ - - psEncCtrl->Gains_Q16[ k ] = silk_LSHIFT_SAT32( tmp32, 16 - Qnrg ); - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Adjust gain for warping */ - gain_mult_Q16 = warped_gain( AR_Q24, warping_Q16, psEnc->sCmn.shapingLPCOrder ); - silk_assert( psEncCtrl->Gains_Q16[ k ] > 0 ); - if( psEncCtrl->Gains_Q16[ k ] < SILK_FIX_CONST( 0.25, 16 ) ) { - psEncCtrl->Gains_Q16[ k ] = silk_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 ); - } else { - psEncCtrl->Gains_Q16[ k ] = silk_SMULWW( silk_RSHIFT_ROUND( psEncCtrl->Gains_Q16[ k ], 1 ), gain_mult_Q16 ); - if ( psEncCtrl->Gains_Q16[ k ] >= ( silk_int32_MAX >> 1 ) ) { - psEncCtrl->Gains_Q16[ k ] = silk_int32_MAX; - } else { - psEncCtrl->Gains_Q16[ k ] = silk_LSHIFT32( psEncCtrl->Gains_Q16[ k ], 1 ); - } - } - silk_assert( psEncCtrl->Gains_Q16[ k ] > 0 ); - } - - /* Bandwidth expansion */ - silk_bwexpander_32( AR_Q24, psEnc->sCmn.shapingLPCOrder, BWExp_Q16 ); - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Convert to monic warped prediction coefficients and limit absolute values */ - limit_warped_coefs( AR_Q24, warping_Q16, SILK_FIX_CONST( 3.999, 24 ), psEnc->sCmn.shapingLPCOrder ); - - /* Convert from Q24 to Q13 and store in int16 */ - for( i = 0; i < psEnc->sCmn.shapingLPCOrder; i++ ) { - psEncCtrl->AR_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( AR_Q24[ i ], 11 ) ); - } - } else { - silk_LPC_fit( &psEncCtrl->AR_Q13[ k * MAX_SHAPE_LPC_ORDER ], AR_Q24, 13, 24, psEnc->sCmn.shapingLPCOrder ); - } - } - - /*****************/ - /* Gain tweaking */ - /*****************/ - /* Increase gains during low speech activity and put lower limit on gains */ - gain_mult_Q16 = silk_log2lin( -silk_SMLAWB( -SILK_FIX_CONST( 16.0, 7 ), SNR_adj_dB_Q7, SILK_FIX_CONST( 0.16, 16 ) ) ); - gain_add_Q16 = silk_log2lin( silk_SMLAWB( SILK_FIX_CONST( 16.0, 7 ), SILK_FIX_CONST( MIN_QGAIN_DB, 7 ), SILK_FIX_CONST( 0.16, 16 ) ) ); - silk_assert( gain_mult_Q16 > 0 ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->Gains_Q16[ k ] = silk_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 ); - silk_assert( psEncCtrl->Gains_Q16[ k ] >= 0 ); - psEncCtrl->Gains_Q16[ k ] = silk_ADD_POS_SAT32( psEncCtrl->Gains_Q16[ k ], gain_add_Q16 ); - } - - - /************************************************/ - /* Control low-frequency shaping and noise tilt */ - /************************************************/ - /* Less low frequency shaping for noisy inputs */ - strength_Q16 = silk_MUL( SILK_FIX_CONST( LOW_FREQ_SHAPING, 4 ), silk_SMLAWB( SILK_FIX_CONST( 1.0, 12 ), - SILK_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 13 ), psEnc->sCmn.input_quality_bands_Q15[ 0 ] - SILK_FIX_CONST( 1.0, 15 ) ) ); - strength_Q16 = silk_RSHIFT( silk_MUL( strength_Q16, psEnc->sCmn.speech_activity_Q8 ), 8 ); - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */ - /*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/ - opus_int fs_kHz_inv = silk_DIV32_16( SILK_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - b_Q14 = fs_kHz_inv + silk_DIV32_16( SILK_FIX_CONST( 3.0, 14 ), psEncCtrl->pitchL[ k ] ); - /* Pack two coefficients in one int32 */ - psEncCtrl->LF_shp_Q14[ k ] = silk_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - silk_SMULWB( strength_Q16, b_Q14 ), 16 ); - psEncCtrl->LF_shp_Q14[ k ] |= (opus_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) ); - } - silk_assert( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SILK_FIX_CONST( 0.5, 24 ) ); /* Guarantees that second argument to SMULWB() is within range of an opus_int16*/ - Tilt_Q16 = - SILK_FIX_CONST( HP_NOISE_COEF, 16 ) - - silk_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - SILK_FIX_CONST( HP_NOISE_COEF, 16 ), - silk_SMULWB( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->sCmn.speech_activity_Q8 ) ); - } else { - b_Q14 = silk_DIV32_16( 21299, psEnc->sCmn.fs_kHz ); /* 1.3_Q0 = 21299_Q14*/ - /* Pack two coefficients in one int32 */ - psEncCtrl->LF_shp_Q14[ 0 ] = silk_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - - silk_SMULWB( strength_Q16, silk_SMULWB( SILK_FIX_CONST( 0.6, 16 ), b_Q14 ) ), 16 ); - psEncCtrl->LF_shp_Q14[ 0 ] |= (opus_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) ); - for( k = 1; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->LF_shp_Q14[ k ] = psEncCtrl->LF_shp_Q14[ 0 ]; - } - Tilt_Q16 = -SILK_FIX_CONST( HP_NOISE_COEF, 16 ); - } - - /****************************/ - /* HARMONIC SHAPING CONTROL */ - /****************************/ - if( USE_HARM_SHAPING && psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* More harmonic noise shaping for high bitrates or noisy input */ - HarmShapeGain_Q16 = silk_SMLAWB( SILK_FIX_CONST( HARMONIC_SHAPING, 16 ), - SILK_FIX_CONST( 1.0, 16 ) - silk_SMULWB( SILK_FIX_CONST( 1.0, 18 ) - silk_LSHIFT( psEncCtrl->coding_quality_Q14, 4 ), - psEncCtrl->input_quality_Q14 ), SILK_FIX_CONST( HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING, 16 ) ); - - /* Less harmonic noise shaping for less periodic signals */ - HarmShapeGain_Q16 = silk_SMULWB( silk_LSHIFT( HarmShapeGain_Q16, 1 ), - silk_SQRT_APPROX( silk_LSHIFT( psEnc->LTPCorr_Q15, 15 ) ) ); - } else { - HarmShapeGain_Q16 = 0; - } - - /*************************/ - /* Smooth over subframes */ - /*************************/ - for( k = 0; k < MAX_NB_SUBFR; k++ ) { - psShapeSt->HarmShapeGain_smth_Q16 = - silk_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); - psShapeSt->Tilt_smth_Q16 = - silk_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); - - psEncCtrl->HarmShapeGain_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psShapeSt->HarmShapeGain_smth_Q16, 2 ); - psEncCtrl->Tilt_Q14[ k ] = ( opus_int )silk_RSHIFT_ROUND( psShapeSt->Tilt_smth_Q16, 2 ); - } - RESTORE_STACK; -} -#endif /* OVERRIDE_silk_noise_shape_analysis_FIX */ diff --git a/Engine/lib/opus/silk/fixed/pitch_analysis_core_FIX.c b/Engine/lib/opus/silk/fixed/pitch_analysis_core_FIX.c deleted file mode 100644 index 14729046d..000000000 --- a/Engine/lib/opus/silk/fixed/pitch_analysis_core_FIX.c +++ /dev/null @@ -1,721 +0,0 @@ -/*********************************************************************** -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" -#endif - -/*********************************************************** -* Pitch analyser function -********************************************************** */ -#include "SigProc_FIX.h" -#include "pitch_est_defines.h" -#include "stack_alloc.h" -#include "debug.h" -#include "pitch.h" - -#define SCRATCH_SIZE 22 -#define SF_LENGTH_4KHZ ( PE_SUBFR_LENGTH_MS * 4 ) -#define SF_LENGTH_8KHZ ( PE_SUBFR_LENGTH_MS * 8 ) -#define MIN_LAG_4KHZ ( PE_MIN_LAG_MS * 4 ) -#define MIN_LAG_8KHZ ( PE_MIN_LAG_MS * 8 ) -#define MAX_LAG_4KHZ ( PE_MAX_LAG_MS * 4 ) -#define MAX_LAG_8KHZ ( PE_MAX_LAG_MS * 8 - 1 ) -#define CSTRIDE_4KHZ ( MAX_LAG_4KHZ + 1 - MIN_LAG_4KHZ ) -#define CSTRIDE_8KHZ ( MAX_LAG_8KHZ + 3 - ( MIN_LAG_8KHZ - 2 ) ) -#define D_COMP_MIN ( MIN_LAG_8KHZ - 3 ) -#define D_COMP_MAX ( MAX_LAG_8KHZ + 4 ) -#define D_COMP_STRIDE ( D_COMP_MAX - D_COMP_MIN ) - -typedef opus_int32 silk_pe_stage3_vals[ PE_NB_STAGE3_LAGS ]; - -/************************************************************/ -/* Internally used functions */ -/************************************************************/ -static void silk_P_Ana_calc_corr_st3( - silk_pe_stage3_vals cross_corr_st3[], /* O 3 DIM correlation array */ - const opus_int16 frame[], /* I vector to correlate */ - opus_int start_lag, /* I lag offset to search around */ - opus_int sf_length, /* I length of a 5 ms subframe */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity, /* I Complexity setting */ - int arch /* I Run-time architecture */ -); - -static void silk_P_Ana_calc_energy_st3( - silk_pe_stage3_vals energies_st3[], /* O 3 DIM energy array */ - const opus_int16 frame[], /* I vector to calc energy in */ - opus_int start_lag, /* I lag offset to search around */ - opus_int sf_length, /* I length of one 5 ms subframe */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity, /* I Complexity setting */ - int arch /* I Run-time architecture */ -); - -/*************************************************************/ -/* FIXED POINT CORE PITCH ANALYSIS FUNCTION */ -/*************************************************************/ -opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ - const opus_int16 *frame_unscaled, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ - opus_int *pitch_out, /* O 4 pitch lag values */ - opus_int16 *lagIndex, /* O Lag Index */ - opus_int8 *contourIndex, /* O Pitch contour Index */ - opus_int *LTPCorr_Q15, /* I/O Normalized correlation; input: value from previous frame */ - opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ - const opus_int32 search_thres1_Q16, /* I First stage threshold for lag candidates 0 - 1 */ - const opus_int search_thres2_Q13, /* I Final threshold for lag candidates 0 - 1 */ - const opus_int Fs_kHz, /* I Sample frequency (kHz) */ - const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */ - const opus_int nb_subfr, /* I number of 5 ms subframes */ - int arch /* I Run-time architecture */ -) -{ - VARDECL( opus_int16, frame_8kHz_buf ); - VARDECL( opus_int16, frame_4kHz ); - VARDECL( opus_int16, frame_scaled ); - opus_int32 filt_state[ 6 ]; - const opus_int16 *frame, *frame_8kHz; - opus_int i, k, d, j; - VARDECL( opus_int16, C ); - VARDECL( opus_int32, xcorr32 ); - const opus_int16 *target_ptr, *basis_ptr; - opus_int32 cross_corr, normalizer, energy, energy_basis, energy_target; - opus_int d_srch[ PE_D_SRCH_LENGTH ], Cmax, length_d_srch, length_d_comp, shift; - VARDECL( opus_int16, d_comp ); - opus_int32 sum, threshold, lag_counter; - opus_int CBimax, CBimax_new, CBimax_old, lag, start_lag, end_lag, lag_new; - opus_int32 CC[ PE_NB_CBKS_STAGE2_EXT ], CCmax, CCmax_b, CCmax_new_b, CCmax_new; - VARDECL( silk_pe_stage3_vals, energies_st3 ); - VARDECL( silk_pe_stage3_vals, cross_corr_st3 ); - opus_int frame_length, frame_length_8kHz, frame_length_4kHz; - opus_int sf_length; - opus_int min_lag; - opus_int max_lag; - opus_int32 contour_bias_Q15, diff; - opus_int nb_cbk_search, cbk_size; - opus_int32 delta_lag_log2_sqr_Q7, lag_log2_Q7, prevLag_log2_Q7, prev_lag_bias_Q13; - const opus_int8 *Lag_CB_ptr; - SAVE_STACK; - - /* Check for valid sampling frequency */ - celt_assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 ); - - /* Check for valid complexity setting */ - celt_assert( complexity >= SILK_PE_MIN_COMPLEX ); - celt_assert( complexity <= SILK_PE_MAX_COMPLEX ); - - silk_assert( search_thres1_Q16 >= 0 && search_thres1_Q16 <= (1<<16) ); - silk_assert( search_thres2_Q13 >= 0 && search_thres2_Q13 <= (1<<13) ); - - /* Set up frame lengths max / min lag for the sampling frequency */ - frame_length = ( PE_LTP_MEM_LENGTH_MS + nb_subfr * PE_SUBFR_LENGTH_MS ) * Fs_kHz; - frame_length_4kHz = ( PE_LTP_MEM_LENGTH_MS + nb_subfr * PE_SUBFR_LENGTH_MS ) * 4; - frame_length_8kHz = ( PE_LTP_MEM_LENGTH_MS + nb_subfr * PE_SUBFR_LENGTH_MS ) * 8; - sf_length = PE_SUBFR_LENGTH_MS * Fs_kHz; - min_lag = PE_MIN_LAG_MS * Fs_kHz; - max_lag = PE_MAX_LAG_MS * Fs_kHz - 1; - - /* Downscale input if necessary */ - silk_sum_sqr_shift( &energy, &shift, frame_unscaled, frame_length ); - shift += 3 - silk_CLZ32( energy ); /* at least two bits headroom */ - ALLOC( frame_scaled, frame_length, opus_int16 ); - if( shift > 0 ) { - shift = silk_RSHIFT( shift + 1, 1 ); - for( i = 0; i < frame_length; i++ ) { - frame_scaled[ i ] = silk_RSHIFT( frame_unscaled[ i ], shift ); - } - frame = frame_scaled; - } else { - frame = frame_unscaled; - } - - ALLOC( frame_8kHz_buf, ( Fs_kHz == 8 ) ? 1 : frame_length_8kHz, opus_int16 ); - /* Resample from input sampled at Fs_kHz to 8 kHz */ - if( Fs_kHz == 16 ) { - silk_memset( filt_state, 0, 2 * sizeof( opus_int32 ) ); - silk_resampler_down2( filt_state, frame_8kHz_buf, frame, frame_length ); - frame_8kHz = frame_8kHz_buf; - } else if( Fs_kHz == 12 ) { - silk_memset( filt_state, 0, 6 * sizeof( opus_int32 ) ); - silk_resampler_down2_3( filt_state, frame_8kHz_buf, frame, frame_length ); - frame_8kHz = frame_8kHz_buf; - } else { - celt_assert( Fs_kHz == 8 ); - frame_8kHz = frame; - } - - /* Decimate again to 4 kHz */ - silk_memset( filt_state, 0, 2 * sizeof( opus_int32 ) );/* Set state to zero */ - ALLOC( frame_4kHz, frame_length_4kHz, opus_int16 ); - silk_resampler_down2( filt_state, frame_4kHz, frame_8kHz, frame_length_8kHz ); - - /* Low-pass filter */ - for( i = frame_length_4kHz - 1; i > 0; i-- ) { - frame_4kHz[ i ] = silk_ADD_SAT16( frame_4kHz[ i ], frame_4kHz[ i - 1 ] ); - } - - - /****************************************************************************** - * FIRST STAGE, operating in 4 khz - ******************************************************************************/ - ALLOC( C, nb_subfr * CSTRIDE_8KHZ, opus_int16 ); - ALLOC( xcorr32, MAX_LAG_4KHZ-MIN_LAG_4KHZ+1, opus_int32 ); - silk_memset( C, 0, (nb_subfr >> 1) * CSTRIDE_4KHZ * sizeof( opus_int16 ) ); - target_ptr = &frame_4kHz[ silk_LSHIFT( SF_LENGTH_4KHZ, 2 ) ]; - for( k = 0; k < nb_subfr >> 1; k++ ) { - /* Check that we are within range of the array */ - celt_assert( target_ptr >= frame_4kHz ); - celt_assert( target_ptr + SF_LENGTH_8KHZ <= frame_4kHz + frame_length_4kHz ); - - basis_ptr = target_ptr - MIN_LAG_4KHZ; - - /* Check that we are within range of the array */ - celt_assert( basis_ptr >= frame_4kHz ); - celt_assert( basis_ptr + SF_LENGTH_8KHZ <= frame_4kHz + frame_length_4kHz ); - - celt_pitch_xcorr( target_ptr, target_ptr - MAX_LAG_4KHZ, xcorr32, SF_LENGTH_8KHZ, MAX_LAG_4KHZ - MIN_LAG_4KHZ + 1, arch ); - - /* Calculate first vector products before loop */ - cross_corr = xcorr32[ MAX_LAG_4KHZ - MIN_LAG_4KHZ ]; - normalizer = silk_inner_prod_aligned( target_ptr, target_ptr, SF_LENGTH_8KHZ, arch ); - normalizer = silk_ADD32( normalizer, silk_inner_prod_aligned( basis_ptr, basis_ptr, SF_LENGTH_8KHZ, arch ) ); - normalizer = silk_ADD32( normalizer, silk_SMULBB( SF_LENGTH_8KHZ, 4000 ) ); - - matrix_ptr( C, k, 0, CSTRIDE_4KHZ ) = - (opus_int16)silk_DIV32_varQ( cross_corr, normalizer, 13 + 1 ); /* Q13 */ - - /* From now on normalizer is computed recursively */ - for( d = MIN_LAG_4KHZ + 1; d <= MAX_LAG_4KHZ; d++ ) { - basis_ptr--; - - /* Check that we are within range of the array */ - silk_assert( basis_ptr >= frame_4kHz ); - silk_assert( basis_ptr + SF_LENGTH_8KHZ <= frame_4kHz + frame_length_4kHz ); - - cross_corr = xcorr32[ MAX_LAG_4KHZ - d ]; - - /* Add contribution of new sample and remove contribution from oldest sample */ - normalizer = silk_ADD32( normalizer, - silk_SMULBB( basis_ptr[ 0 ], basis_ptr[ 0 ] ) - - silk_SMULBB( basis_ptr[ SF_LENGTH_8KHZ ], basis_ptr[ SF_LENGTH_8KHZ ] ) ); - - matrix_ptr( C, k, d - MIN_LAG_4KHZ, CSTRIDE_4KHZ) = - (opus_int16)silk_DIV32_varQ( cross_corr, normalizer, 13 + 1 ); /* Q13 */ - } - /* Update target pointer */ - target_ptr += SF_LENGTH_8KHZ; - } - - /* Combine two subframes into single correlation measure and apply short-lag bias */ - if( nb_subfr == PE_MAX_NB_SUBFR ) { - for( i = MAX_LAG_4KHZ; i >= MIN_LAG_4KHZ; i-- ) { - sum = (opus_int32)matrix_ptr( C, 0, i - MIN_LAG_4KHZ, CSTRIDE_4KHZ ) - + (opus_int32)matrix_ptr( C, 1, i - MIN_LAG_4KHZ, CSTRIDE_4KHZ ); /* Q14 */ - sum = silk_SMLAWB( sum, sum, silk_LSHIFT( -i, 4 ) ); /* Q14 */ - C[ i - MIN_LAG_4KHZ ] = (opus_int16)sum; /* Q14 */ - } - } else { - /* Only short-lag bias */ - for( i = MAX_LAG_4KHZ; i >= MIN_LAG_4KHZ; i-- ) { - sum = silk_LSHIFT( (opus_int32)C[ i - MIN_LAG_4KHZ ], 1 ); /* Q14 */ - sum = silk_SMLAWB( sum, sum, silk_LSHIFT( -i, 4 ) ); /* Q14 */ - C[ i - MIN_LAG_4KHZ ] = (opus_int16)sum; /* Q14 */ - } - } - - /* Sort */ - length_d_srch = silk_ADD_LSHIFT32( 4, complexity, 1 ); - celt_assert( 3 * length_d_srch <= PE_D_SRCH_LENGTH ); - silk_insertion_sort_decreasing_int16( C, d_srch, CSTRIDE_4KHZ, - length_d_srch ); - - /* Escape if correlation is very low already here */ - Cmax = (opus_int)C[ 0 ]; /* Q14 */ - if( Cmax < SILK_FIX_CONST( 0.2, 14 ) ) { - silk_memset( pitch_out, 0, nb_subfr * sizeof( opus_int ) ); - *LTPCorr_Q15 = 0; - *lagIndex = 0; - *contourIndex = 0; - RESTORE_STACK; - return 1; - } - - threshold = silk_SMULWB( search_thres1_Q16, Cmax ); - for( i = 0; i < length_d_srch; i++ ) { - /* Convert to 8 kHz indices for the sorted correlation that exceeds the threshold */ - if( C[ i ] > threshold ) { - d_srch[ i ] = silk_LSHIFT( d_srch[ i ] + MIN_LAG_4KHZ, 1 ); - } else { - length_d_srch = i; - break; - } - } - celt_assert( length_d_srch > 0 ); - - ALLOC( d_comp, D_COMP_STRIDE, opus_int16 ); - for( i = D_COMP_MIN; i < D_COMP_MAX; i++ ) { - d_comp[ i - D_COMP_MIN ] = 0; - } - for( i = 0; i < length_d_srch; i++ ) { - d_comp[ d_srch[ i ] - D_COMP_MIN ] = 1; - } - - /* Convolution */ - for( i = D_COMP_MAX - 1; i >= MIN_LAG_8KHZ; i-- ) { - d_comp[ i - D_COMP_MIN ] += - d_comp[ i - 1 - D_COMP_MIN ] + d_comp[ i - 2 - D_COMP_MIN ]; - } - - length_d_srch = 0; - for( i = MIN_LAG_8KHZ; i < MAX_LAG_8KHZ + 1; i++ ) { - if( d_comp[ i + 1 - D_COMP_MIN ] > 0 ) { - d_srch[ length_d_srch ] = i; - length_d_srch++; - } - } - - /* Convolution */ - for( i = D_COMP_MAX - 1; i >= MIN_LAG_8KHZ; i-- ) { - d_comp[ i - D_COMP_MIN ] += d_comp[ i - 1 - D_COMP_MIN ] - + d_comp[ i - 2 - D_COMP_MIN ] + d_comp[ i - 3 - D_COMP_MIN ]; - } - - length_d_comp = 0; - for( i = MIN_LAG_8KHZ; i < D_COMP_MAX; i++ ) { - if( d_comp[ i - D_COMP_MIN ] > 0 ) { - d_comp[ length_d_comp ] = i - 2; - length_d_comp++; - } - } - - /********************************************************************************** - ** SECOND STAGE, operating at 8 kHz, on lag sections with high correlation - *************************************************************************************/ - - /********************************************************************************* - * Find energy of each subframe projected onto its history, for a range of delays - *********************************************************************************/ - silk_memset( C, 0, nb_subfr * CSTRIDE_8KHZ * sizeof( opus_int16 ) ); - - target_ptr = &frame_8kHz[ PE_LTP_MEM_LENGTH_MS * 8 ]; - for( k = 0; k < nb_subfr; k++ ) { - - /* Check that we are within range of the array */ - celt_assert( target_ptr >= frame_8kHz ); - celt_assert( target_ptr + SF_LENGTH_8KHZ <= frame_8kHz + frame_length_8kHz ); - - energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_ptr, SF_LENGTH_8KHZ, arch ), 1 ); - for( j = 0; j < length_d_comp; j++ ) { - d = d_comp[ j ]; - basis_ptr = target_ptr - d; - - /* Check that we are within range of the array */ - silk_assert( basis_ptr >= frame_8kHz ); - silk_assert( basis_ptr + SF_LENGTH_8KHZ <= frame_8kHz + frame_length_8kHz ); - - cross_corr = silk_inner_prod_aligned( target_ptr, basis_ptr, SF_LENGTH_8KHZ, arch ); - if( cross_corr > 0 ) { - energy_basis = silk_inner_prod_aligned( basis_ptr, basis_ptr, SF_LENGTH_8KHZ, arch ); - matrix_ptr( C, k, d - ( MIN_LAG_8KHZ - 2 ), CSTRIDE_8KHZ ) = - (opus_int16)silk_DIV32_varQ( cross_corr, - silk_ADD32( energy_target, - energy_basis ), - 13 + 1 ); /* Q13 */ - } else { - matrix_ptr( C, k, d - ( MIN_LAG_8KHZ - 2 ), CSTRIDE_8KHZ ) = 0; - } - } - target_ptr += SF_LENGTH_8KHZ; - } - - /* search over lag range and lags codebook */ - /* scale factor for lag codebook, as a function of center lag */ - - CCmax = silk_int32_MIN; - CCmax_b = silk_int32_MIN; - - CBimax = 0; /* To avoid returning undefined lag values */ - lag = -1; /* To check if lag with strong enough correlation has been found */ - - if( prevLag > 0 ) { - if( Fs_kHz == 12 ) { - prevLag = silk_DIV32_16( silk_LSHIFT( prevLag, 1 ), 3 ); - } else if( Fs_kHz == 16 ) { - prevLag = silk_RSHIFT( prevLag, 1 ); - } - prevLag_log2_Q7 = silk_lin2log( (opus_int32)prevLag ); - } else { - prevLag_log2_Q7 = 0; - } - silk_assert( search_thres2_Q13 == silk_SAT16( search_thres2_Q13 ) ); - /* Set up stage 2 codebook based on number of subframes */ - if( nb_subfr == PE_MAX_NB_SUBFR ) { - cbk_size = PE_NB_CBKS_STAGE2_EXT; - Lag_CB_ptr = &silk_CB_lags_stage2[ 0 ][ 0 ]; - if( Fs_kHz == 8 && complexity > SILK_PE_MIN_COMPLEX ) { - /* If input is 8 khz use a larger codebook here because it is last stage */ - nb_cbk_search = PE_NB_CBKS_STAGE2_EXT; - } else { - nb_cbk_search = PE_NB_CBKS_STAGE2; - } - } else { - cbk_size = PE_NB_CBKS_STAGE2_10MS; - Lag_CB_ptr = &silk_CB_lags_stage2_10_ms[ 0 ][ 0 ]; - nb_cbk_search = PE_NB_CBKS_STAGE2_10MS; - } - - for( k = 0; k < length_d_srch; k++ ) { - d = d_srch[ k ]; - for( j = 0; j < nb_cbk_search; j++ ) { - CC[ j ] = 0; - for( i = 0; i < nb_subfr; i++ ) { - opus_int d_subfr; - /* Try all codebooks */ - d_subfr = d + matrix_ptr( Lag_CB_ptr, i, j, cbk_size ); - CC[ j ] = CC[ j ] - + (opus_int32)matrix_ptr( C, i, - d_subfr - ( MIN_LAG_8KHZ - 2 ), - CSTRIDE_8KHZ ); - } - } - /* Find best codebook */ - CCmax_new = silk_int32_MIN; - CBimax_new = 0; - for( i = 0; i < nb_cbk_search; i++ ) { - if( CC[ i ] > CCmax_new ) { - CCmax_new = CC[ i ]; - CBimax_new = i; - } - } - - /* Bias towards shorter lags */ - lag_log2_Q7 = silk_lin2log( d ); /* Q7 */ - silk_assert( lag_log2_Q7 == silk_SAT16( lag_log2_Q7 ) ); - silk_assert( nb_subfr * SILK_FIX_CONST( PE_SHORTLAG_BIAS, 13 ) == silk_SAT16( nb_subfr * SILK_FIX_CONST( PE_SHORTLAG_BIAS, 13 ) ) ); - CCmax_new_b = CCmax_new - silk_RSHIFT( silk_SMULBB( nb_subfr * SILK_FIX_CONST( PE_SHORTLAG_BIAS, 13 ), lag_log2_Q7 ), 7 ); /* Q13 */ - - /* Bias towards previous lag */ - silk_assert( nb_subfr * SILK_FIX_CONST( PE_PREVLAG_BIAS, 13 ) == silk_SAT16( nb_subfr * SILK_FIX_CONST( PE_PREVLAG_BIAS, 13 ) ) ); - if( prevLag > 0 ) { - delta_lag_log2_sqr_Q7 = lag_log2_Q7 - prevLag_log2_Q7; - silk_assert( delta_lag_log2_sqr_Q7 == silk_SAT16( delta_lag_log2_sqr_Q7 ) ); - delta_lag_log2_sqr_Q7 = silk_RSHIFT( silk_SMULBB( delta_lag_log2_sqr_Q7, delta_lag_log2_sqr_Q7 ), 7 ); - prev_lag_bias_Q13 = silk_RSHIFT( silk_SMULBB( nb_subfr * SILK_FIX_CONST( PE_PREVLAG_BIAS, 13 ), *LTPCorr_Q15 ), 15 ); /* Q13 */ - prev_lag_bias_Q13 = silk_DIV32( silk_MUL( prev_lag_bias_Q13, delta_lag_log2_sqr_Q7 ), delta_lag_log2_sqr_Q7 + SILK_FIX_CONST( 0.5, 7 ) ); - CCmax_new_b -= prev_lag_bias_Q13; /* Q13 */ - } - - if( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */ - CCmax_new > silk_SMULBB( nb_subfr, search_thres2_Q13 ) && /* Correlation needs to be high enough to be voiced */ - silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= MIN_LAG_8KHZ /* Lag must be in range */ - ) { - CCmax_b = CCmax_new_b; - CCmax = CCmax_new; - lag = d; - CBimax = CBimax_new; - } - } - - if( lag == -1 ) { - /* No suitable candidate found */ - silk_memset( pitch_out, 0, nb_subfr * sizeof( opus_int ) ); - *LTPCorr_Q15 = 0; - *lagIndex = 0; - *contourIndex = 0; - RESTORE_STACK; - return 1; - } - - /* Output normalized correlation */ - *LTPCorr_Q15 = (opus_int)silk_LSHIFT( silk_DIV32_16( CCmax, nb_subfr ), 2 ); - silk_assert( *LTPCorr_Q15 >= 0 ); - - if( Fs_kHz > 8 ) { - /* Search in original signal */ - - CBimax_old = CBimax; - /* Compensate for decimation */ - silk_assert( lag == silk_SAT16( lag ) ); - if( Fs_kHz == 12 ) { - lag = silk_RSHIFT( silk_SMULBB( lag, 3 ), 1 ); - } else if( Fs_kHz == 16 ) { - lag = silk_LSHIFT( lag, 1 ); - } else { - lag = silk_SMULBB( lag, 3 ); - } - - lag = silk_LIMIT_int( lag, min_lag, max_lag ); - start_lag = silk_max_int( lag - 2, min_lag ); - end_lag = silk_min_int( lag + 2, max_lag ); - lag_new = lag; /* to avoid undefined lag */ - CBimax = 0; /* to avoid undefined lag */ - - CCmax = silk_int32_MIN; - /* pitch lags according to second stage */ - for( k = 0; k < nb_subfr; k++ ) { - pitch_out[ k ] = lag + 2 * silk_CB_lags_stage2[ k ][ CBimax_old ]; - } - - /* Set up codebook parameters according to complexity setting and frame length */ - if( nb_subfr == PE_MAX_NB_SUBFR ) { - nb_cbk_search = (opus_int)silk_nb_cbk_searchs_stage3[ complexity ]; - cbk_size = PE_NB_CBKS_STAGE3_MAX; - Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; - } else { - nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; - cbk_size = PE_NB_CBKS_STAGE3_10MS; - Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; - } - - /* Calculate the correlations and energies needed in stage 3 */ - ALLOC( energies_st3, nb_subfr * nb_cbk_search, silk_pe_stage3_vals ); - ALLOC( cross_corr_st3, nb_subfr * nb_cbk_search, silk_pe_stage3_vals ); - silk_P_Ana_calc_corr_st3( cross_corr_st3, frame, start_lag, sf_length, nb_subfr, complexity, arch ); - silk_P_Ana_calc_energy_st3( energies_st3, frame, start_lag, sf_length, nb_subfr, complexity, arch ); - - lag_counter = 0; - silk_assert( lag == silk_SAT16( lag ) ); - contour_bias_Q15 = silk_DIV32_16( SILK_FIX_CONST( PE_FLATCONTOUR_BIAS, 15 ), lag ); - - target_ptr = &frame[ PE_LTP_MEM_LENGTH_MS * Fs_kHz ]; - energy_target = silk_ADD32( silk_inner_prod_aligned( target_ptr, target_ptr, nb_subfr * sf_length, arch ), 1 ); - for( d = start_lag; d <= end_lag; d++ ) { - for( j = 0; j < nb_cbk_search; j++ ) { - cross_corr = 0; - energy = energy_target; - for( k = 0; k < nb_subfr; k++ ) { - cross_corr = silk_ADD32( cross_corr, - matrix_ptr( cross_corr_st3, k, j, - nb_cbk_search )[ lag_counter ] ); - energy = silk_ADD32( energy, - matrix_ptr( energies_st3, k, j, - nb_cbk_search )[ lag_counter ] ); - silk_assert( energy >= 0 ); - } - if( cross_corr > 0 ) { - CCmax_new = silk_DIV32_varQ( cross_corr, energy, 13 + 1 ); /* Q13 */ - /* Reduce depending on flatness of contour */ - diff = silk_int16_MAX - silk_MUL( contour_bias_Q15, j ); /* Q15 */ - silk_assert( diff == silk_SAT16( diff ) ); - CCmax_new = silk_SMULWB( CCmax_new, diff ); /* Q14 */ - } else { - CCmax_new = 0; - } - - if( CCmax_new > CCmax && ( d + silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag ) { - CCmax = CCmax_new; - lag_new = d; - CBimax = j; - } - } - lag_counter++; - } - - for( k = 0; k < nb_subfr; k++ ) { - pitch_out[ k ] = lag_new + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size ); - pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag, PE_MAX_LAG_MS * Fs_kHz ); - } - *lagIndex = (opus_int16)( lag_new - min_lag); - *contourIndex = (opus_int8)CBimax; - } else { /* Fs_kHz == 8 */ - /* Save Lags */ - for( k = 0; k < nb_subfr; k++ ) { - pitch_out[ k ] = lag + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size ); - pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], MIN_LAG_8KHZ, PE_MAX_LAG_MS * 8 ); - } - *lagIndex = (opus_int16)( lag - MIN_LAG_8KHZ ); - *contourIndex = (opus_int8)CBimax; - } - celt_assert( *lagIndex >= 0 ); - /* return as voiced */ - RESTORE_STACK; - return 0; -} - -/*********************************************************************** - * Calculates the correlations used in stage 3 search. In order to cover - * the whole lag codebook for all the searched offset lags (lag +- 2), - * the following correlations are needed in each sub frame: - * - * sf1: lag range [-8,...,7] total 16 correlations - * sf2: lag range [-4,...,4] total 9 correlations - * sf3: lag range [-3,....4] total 8 correltions - * sf4: lag range [-6,....8] total 15 correlations - * - * In total 48 correlations. The direct implementation computed in worst - * case 4*12*5 = 240 correlations, but more likely around 120. - ***********************************************************************/ -static void silk_P_Ana_calc_corr_st3( - silk_pe_stage3_vals cross_corr_st3[], /* O 3 DIM correlation array */ - const opus_int16 frame[], /* I vector to correlate */ - opus_int start_lag, /* I lag offset to search around */ - opus_int sf_length, /* I length of a 5 ms subframe */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity, /* I Complexity setting */ - int arch /* I Run-time architecture */ -) -{ - const opus_int16 *target_ptr; - opus_int i, j, k, lag_counter, lag_low, lag_high; - opus_int nb_cbk_search, delta, idx, cbk_size; - VARDECL( opus_int32, scratch_mem ); - VARDECL( opus_int32, xcorr32 ); - const opus_int8 *Lag_range_ptr, *Lag_CB_ptr; - SAVE_STACK; - - celt_assert( complexity >= SILK_PE_MIN_COMPLEX ); - celt_assert( complexity <= SILK_PE_MAX_COMPLEX ); - - if( nb_subfr == PE_MAX_NB_SUBFR ) { - Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; - Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; - nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; - cbk_size = PE_NB_CBKS_STAGE3_MAX; - } else { - celt_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1); - Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; - Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; - nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; - cbk_size = PE_NB_CBKS_STAGE3_10MS; - } - ALLOC( scratch_mem, SCRATCH_SIZE, opus_int32 ); - ALLOC( xcorr32, SCRATCH_SIZE, opus_int32 ); - - target_ptr = &frame[ silk_LSHIFT( sf_length, 2 ) ]; /* Pointer to middle of frame */ - for( k = 0; k < nb_subfr; k++ ) { - lag_counter = 0; - - /* Calculate the correlations for each subframe */ - lag_low = matrix_ptr( Lag_range_ptr, k, 0, 2 ); - lag_high = matrix_ptr( Lag_range_ptr, k, 1, 2 ); - celt_assert(lag_high-lag_low+1 <= SCRATCH_SIZE); - celt_pitch_xcorr( target_ptr, target_ptr - start_lag - lag_high, xcorr32, sf_length, lag_high - lag_low + 1, arch ); - for( j = lag_low; j <= lag_high; j++ ) { - silk_assert( lag_counter < SCRATCH_SIZE ); - scratch_mem[ lag_counter ] = xcorr32[ lag_high - j ]; - lag_counter++; - } - - delta = matrix_ptr( Lag_range_ptr, k, 0, 2 ); - for( i = 0; i < nb_cbk_search; i++ ) { - /* Fill out the 3 dim array that stores the correlations for */ - /* each code_book vector for each start lag */ - idx = matrix_ptr( Lag_CB_ptr, k, i, cbk_size ) - delta; - for( j = 0; j < PE_NB_STAGE3_LAGS; j++ ) { - silk_assert( idx + j < SCRATCH_SIZE ); - silk_assert( idx + j < lag_counter ); - matrix_ptr( cross_corr_st3, k, i, nb_cbk_search )[ j ] = - scratch_mem[ idx + j ]; - } - } - target_ptr += sf_length; - } - RESTORE_STACK; -} - -/********************************************************************/ -/* Calculate the energies for first two subframes. The energies are */ -/* calculated recursively. */ -/********************************************************************/ -static void silk_P_Ana_calc_energy_st3( - silk_pe_stage3_vals energies_st3[], /* O 3 DIM energy array */ - const opus_int16 frame[], /* I vector to calc energy in */ - opus_int start_lag, /* I lag offset to search around */ - opus_int sf_length, /* I length of one 5 ms subframe */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity, /* I Complexity setting */ - int arch /* I Run-time architecture */ -) -{ - const opus_int16 *target_ptr, *basis_ptr; - opus_int32 energy; - opus_int k, i, j, lag_counter; - opus_int nb_cbk_search, delta, idx, cbk_size, lag_diff; - VARDECL( opus_int32, scratch_mem ); - const opus_int8 *Lag_range_ptr, *Lag_CB_ptr; - SAVE_STACK; - - celt_assert( complexity >= SILK_PE_MIN_COMPLEX ); - celt_assert( complexity <= SILK_PE_MAX_COMPLEX ); - - if( nb_subfr == PE_MAX_NB_SUBFR ) { - Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; - Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; - nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; - cbk_size = PE_NB_CBKS_STAGE3_MAX; - } else { - celt_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1); - Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; - Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; - nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; - cbk_size = PE_NB_CBKS_STAGE3_10MS; - } - ALLOC( scratch_mem, SCRATCH_SIZE, opus_int32 ); - - target_ptr = &frame[ silk_LSHIFT( sf_length, 2 ) ]; - for( k = 0; k < nb_subfr; k++ ) { - lag_counter = 0; - - /* Calculate the energy for first lag */ - basis_ptr = target_ptr - ( start_lag + matrix_ptr( Lag_range_ptr, k, 0, 2 ) ); - energy = silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length, arch ); - silk_assert( energy >= 0 ); - scratch_mem[ lag_counter ] = energy; - lag_counter++; - - lag_diff = ( matrix_ptr( Lag_range_ptr, k, 1, 2 ) - matrix_ptr( Lag_range_ptr, k, 0, 2 ) + 1 ); - for( i = 1; i < lag_diff; i++ ) { - /* remove part outside new window */ - energy -= silk_SMULBB( basis_ptr[ sf_length - i ], basis_ptr[ sf_length - i ] ); - silk_assert( energy >= 0 ); - - /* add part that comes into window */ - energy = silk_ADD_SAT32( energy, silk_SMULBB( basis_ptr[ -i ], basis_ptr[ -i ] ) ); - silk_assert( energy >= 0 ); - silk_assert( lag_counter < SCRATCH_SIZE ); - scratch_mem[ lag_counter ] = energy; - lag_counter++; - } - - delta = matrix_ptr( Lag_range_ptr, k, 0, 2 ); - for( i = 0; i < nb_cbk_search; i++ ) { - /* Fill out the 3 dim array that stores the correlations for */ - /* each code_book vector for each start lag */ - idx = matrix_ptr( Lag_CB_ptr, k, i, cbk_size ) - delta; - for( j = 0; j < PE_NB_STAGE3_LAGS; j++ ) { - silk_assert( idx + j < SCRATCH_SIZE ); - silk_assert( idx + j < lag_counter ); - matrix_ptr( energies_st3, k, i, nb_cbk_search )[ j ] = - scratch_mem[ idx + j ]; - silk_assert( - matrix_ptr( energies_st3, k, i, nb_cbk_search )[ j ] >= 0 ); - } - } - target_ptr += sf_length; - } - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/fixed/process_gains_FIX.c b/Engine/lib/opus/silk/fixed/process_gains_FIX.c deleted file mode 100644 index 05aba3178..000000000 --- a/Engine/lib/opus/silk/fixed/process_gains_FIX.c +++ /dev/null @@ -1,117 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" -#include "tuning_parameters.h" - -/* Processing of gains */ -void silk_process_gains_FIX( - silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ - silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */ - opus_int condCoding /* I The type of conditional coding to use */ -) -{ - silk_shape_state_FIX *psShapeSt = &psEnc->sShape; - opus_int k; - opus_int32 s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart, quant_offset_Q10; - - /* Gain reduction when LTP coding gain is high */ - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /*s = -0.5f * silk_sigmoid( 0.25f * ( psEncCtrl->LTPredCodGain - 12.0f ) ); */ - s_Q16 = -silk_sigm_Q15( silk_RSHIFT_ROUND( psEncCtrl->LTPredCodGain_Q7 - SILK_FIX_CONST( 12.0, 7 ), 4 ) ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->Gains_Q16[ k ] = silk_SMLAWB( psEncCtrl->Gains_Q16[ k ], psEncCtrl->Gains_Q16[ k ], s_Q16 ); - } - } - - /* Limit the quantized signal */ - /* InvMaxSqrVal = pow( 2.0f, 0.33f * ( 21.0f - SNR_dB ) ) / subfr_length; */ - InvMaxSqrVal_Q16 = silk_DIV32_16( silk_log2lin( - silk_SMULWB( SILK_FIX_CONST( 21 + 16 / 0.33, 7 ) - psEnc->sCmn.SNR_dB_Q7, SILK_FIX_CONST( 0.33, 16 ) ) ), psEnc->sCmn.subfr_length ); - - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - /* Soft limit on ratio residual energy and squared gains */ - ResNrg = psEncCtrl->ResNrg[ k ]; - ResNrgPart = silk_SMULWW( ResNrg, InvMaxSqrVal_Q16 ); - if( psEncCtrl->ResNrgQ[ k ] > 0 ) { - ResNrgPart = silk_RSHIFT_ROUND( ResNrgPart, psEncCtrl->ResNrgQ[ k ] ); - } else { - if( ResNrgPart >= silk_RSHIFT( silk_int32_MAX, -psEncCtrl->ResNrgQ[ k ] ) ) { - ResNrgPart = silk_int32_MAX; - } else { - ResNrgPart = silk_LSHIFT( ResNrgPart, -psEncCtrl->ResNrgQ[ k ] ); - } - } - gain = psEncCtrl->Gains_Q16[ k ]; - gain_squared = silk_ADD_SAT32( ResNrgPart, silk_SMMUL( gain, gain ) ); - if( gain_squared < silk_int16_MAX ) { - /* recalculate with higher precision */ - gain_squared = silk_SMLAWW( silk_LSHIFT( ResNrgPart, 16 ), gain, gain ); - silk_assert( gain_squared > 0 ); - gain = silk_SQRT_APPROX( gain_squared ); /* Q8 */ - gain = silk_min( gain, silk_int32_MAX >> 8 ); - psEncCtrl->Gains_Q16[ k ] = silk_LSHIFT_SAT32( gain, 8 ); /* Q16 */ - } else { - gain = silk_SQRT_APPROX( gain_squared ); /* Q0 */ - gain = silk_min( gain, silk_int32_MAX >> 16 ); - psEncCtrl->Gains_Q16[ k ] = silk_LSHIFT_SAT32( gain, 16 ); /* Q16 */ - } - } - - /* Save unquantized gains and gain Index */ - silk_memcpy( psEncCtrl->GainsUnq_Q16, psEncCtrl->Gains_Q16, psEnc->sCmn.nb_subfr * sizeof( opus_int32 ) ); - psEncCtrl->lastGainIndexPrev = psShapeSt->LastGainIndex; - - /* Quantize gains */ - silk_gains_quant( psEnc->sCmn.indices.GainsIndices, psEncCtrl->Gains_Q16, - &psShapeSt->LastGainIndex, condCoding == CODE_CONDITIONALLY, psEnc->sCmn.nb_subfr ); - - /* Set quantizer offset for voiced signals. Larger offset when LTP coding gain is low or tilt is high (ie low-pass) */ - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - if( psEncCtrl->LTPredCodGain_Q7 + silk_RSHIFT( psEnc->sCmn.input_tilt_Q15, 8 ) > SILK_FIX_CONST( 1.0, 7 ) ) { - psEnc->sCmn.indices.quantOffsetType = 0; - } else { - psEnc->sCmn.indices.quantOffsetType = 1; - } - } - - /* Quantizer boundary adjustment */ - quant_offset_Q10 = silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ]; - psEncCtrl->Lambda_Q10 = SILK_FIX_CONST( LAMBDA_OFFSET, 10 ) - + silk_SMULBB( SILK_FIX_CONST( LAMBDA_DELAYED_DECISIONS, 10 ), psEnc->sCmn.nStatesDelayedDecision ) - + silk_SMULWB( SILK_FIX_CONST( LAMBDA_SPEECH_ACT, 18 ), psEnc->sCmn.speech_activity_Q8 ) - + silk_SMULWB( SILK_FIX_CONST( LAMBDA_INPUT_QUALITY, 12 ), psEncCtrl->input_quality_Q14 ) - + silk_SMULWB( SILK_FIX_CONST( LAMBDA_CODING_QUALITY, 12 ), psEncCtrl->coding_quality_Q14 ) - + silk_SMULWB( SILK_FIX_CONST( LAMBDA_QUANT_OFFSET, 16 ), quant_offset_Q10 ); - - silk_assert( psEncCtrl->Lambda_Q10 > 0 ); - silk_assert( psEncCtrl->Lambda_Q10 < SILK_FIX_CONST( 2, 10 ) ); -} diff --git a/Engine/lib/opus/silk/fixed/regularize_correlations_FIX.c b/Engine/lib/opus/silk/fixed/regularize_correlations_FIX.c deleted file mode 100644 index a2836b05f..000000000 --- a/Engine/lib/opus/silk/fixed/regularize_correlations_FIX.c +++ /dev/null @@ -1,47 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" - -/* Add noise to matrix diagonal */ -void silk_regularize_correlations_FIX( - opus_int32 *XX, /* I/O Correlation matrices */ - opus_int32 *xx, /* I/O Correlation values */ - opus_int32 noise, /* I Noise to add */ - opus_int D /* I Dimension of XX */ -) -{ - opus_int i; - for( i = 0; i < D; i++ ) { - matrix_ptr( &XX[ 0 ], i, i, D ) = silk_ADD32( matrix_ptr( &XX[ 0 ], i, i, D ), noise ); - } - xx[ 0 ] += noise; -} diff --git a/Engine/lib/opus/silk/fixed/residual_energy16_FIX.c b/Engine/lib/opus/silk/fixed/residual_energy16_FIX.c deleted file mode 100644 index 7f130f3d3..000000000 --- a/Engine/lib/opus/silk/fixed/residual_energy16_FIX.c +++ /dev/null @@ -1,103 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" - -/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -opus_int32 silk_residual_energy16_covar_FIX( - const opus_int16 *c, /* I Prediction vector */ - const opus_int32 *wXX, /* I Correlation matrix */ - const opus_int32 *wXx, /* I Correlation vector */ - opus_int32 wxx, /* I Signal energy */ - opus_int D, /* I Dimension */ - opus_int cQ /* I Q value for c vector 0 - 15 */ -) -{ - opus_int i, j, lshifts, Qxtra; - opus_int32 c_max, w_max, tmp, tmp2, nrg; - opus_int cn[ MAX_MATRIX_SIZE ]; - const opus_int32 *pRow; - - /* Safety checks */ - celt_assert( D >= 0 ); - celt_assert( D <= 16 ); - celt_assert( cQ > 0 ); - celt_assert( cQ < 16 ); - - lshifts = 16 - cQ; - Qxtra = lshifts; - - c_max = 0; - for( i = 0; i < D; i++ ) { - c_max = silk_max_32( c_max, silk_abs( (opus_int32)c[ i ] ) ); - } - Qxtra = silk_min_int( Qxtra, silk_CLZ32( c_max ) - 17 ); - - w_max = silk_max_32( wXX[ 0 ], wXX[ D * D - 1 ] ); - Qxtra = silk_min_int( Qxtra, silk_CLZ32( silk_MUL( D, silk_RSHIFT( silk_SMULWB( w_max, c_max ), 4 ) ) ) - 5 ); - Qxtra = silk_max_int( Qxtra, 0 ); - for( i = 0; i < D; i++ ) { - cn[ i ] = silk_LSHIFT( ( opus_int )c[ i ], Qxtra ); - silk_assert( silk_abs(cn[i]) <= ( silk_int16_MAX + 1 ) ); /* Check that silk_SMLAWB can be used */ - } - lshifts -= Qxtra; - - /* Compute wxx - 2 * wXx * c */ - tmp = 0; - for( i = 0; i < D; i++ ) { - tmp = silk_SMLAWB( tmp, wXx[ i ], cn[ i ] ); - } - nrg = silk_RSHIFT( wxx, 1 + lshifts ) - tmp; /* Q: -lshifts - 1 */ - - /* Add c' * wXX * c, assuming wXX is symmetric */ - tmp2 = 0; - for( i = 0; i < D; i++ ) { - tmp = 0; - pRow = &wXX[ i * D ]; - for( j = i + 1; j < D; j++ ) { - tmp = silk_SMLAWB( tmp, pRow[ j ], cn[ j ] ); - } - tmp = silk_SMLAWB( tmp, silk_RSHIFT( pRow[ i ], 1 ), cn[ i ] ); - tmp2 = silk_SMLAWB( tmp2, tmp, cn[ i ] ); - } - nrg = silk_ADD_LSHIFT32( nrg, tmp2, lshifts ); /* Q: -lshifts - 1 */ - - /* Keep one bit free always, because we add them for LSF interpolation */ - if( nrg < 1 ) { - nrg = 1; - } else if( nrg > silk_RSHIFT( silk_int32_MAX, lshifts + 2 ) ) { - nrg = silk_int32_MAX >> 1; - } else { - nrg = silk_LSHIFT( nrg, lshifts + 1 ); /* Q0 */ - } - return nrg; - -} diff --git a/Engine/lib/opus/silk/fixed/residual_energy_FIX.c b/Engine/lib/opus/silk/fixed/residual_energy_FIX.c deleted file mode 100644 index 6c7cade9a..000000000 --- a/Engine/lib/opus/silk/fixed/residual_energy_FIX.c +++ /dev/null @@ -1,98 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" -#include "stack_alloc.h" - -/* Calculates residual energies of input subframes where all subframes have LPC_order */ -/* of preceding samples */ -void silk_residual_energy_FIX( - opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ - opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */ - const opus_int16 x[], /* I Input signal */ - opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ - const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I Number of subframes */ - const opus_int LPC_order, /* I LPC order */ - int arch /* I Run-time architecture */ -) -{ - opus_int offset, i, j, rshift, lz1, lz2; - opus_int16 *LPC_res_ptr; - VARDECL( opus_int16, LPC_res ); - const opus_int16 *x_ptr; - opus_int32 tmp32; - SAVE_STACK; - - x_ptr = x; - offset = LPC_order + subfr_length; - - /* Filter input to create the LPC residual for each frame half, and measure subframe energies */ - ALLOC( LPC_res, ( MAX_NB_SUBFR >> 1 ) * offset, opus_int16 ); - celt_assert( ( nb_subfr >> 1 ) * ( MAX_NB_SUBFR >> 1 ) == nb_subfr ); - for( i = 0; i < nb_subfr >> 1; i++ ) { - /* Calculate half frame LPC residual signal including preceding samples */ - silk_LPC_analysis_filter( LPC_res, x_ptr, a_Q12[ i ], ( MAX_NB_SUBFR >> 1 ) * offset, LPC_order, arch ); - - /* Point to first subframe of the just calculated LPC residual signal */ - LPC_res_ptr = LPC_res + LPC_order; - for( j = 0; j < ( MAX_NB_SUBFR >> 1 ); j++ ) { - /* Measure subframe energy */ - silk_sum_sqr_shift( &nrgs[ i * ( MAX_NB_SUBFR >> 1 ) + j ], &rshift, LPC_res_ptr, subfr_length ); - - /* Set Q values for the measured energy */ - nrgsQ[ i * ( MAX_NB_SUBFR >> 1 ) + j ] = -rshift; - - /* Move to next subframe */ - LPC_res_ptr += offset; - } - /* Move to next frame half */ - x_ptr += ( MAX_NB_SUBFR >> 1 ) * offset; - } - - /* Apply the squared subframe gains */ - for( i = 0; i < nb_subfr; i++ ) { - /* Fully upscale gains and energies */ - lz1 = silk_CLZ32( nrgs[ i ] ) - 1; - lz2 = silk_CLZ32( gains[ i ] ) - 1; - - tmp32 = silk_LSHIFT32( gains[ i ], lz2 ); - - /* Find squared gains */ - tmp32 = silk_SMMUL( tmp32, tmp32 ); /* Q( 2 * lz2 - 32 )*/ - - /* Scale energies */ - nrgs[ i ] = silk_SMMUL( tmp32, silk_LSHIFT32( nrgs[ i ], lz1 ) ); /* Q( nrgsQ[ i ] + lz1 + 2 * lz2 - 32 - 32 )*/ - nrgsQ[ i ] += lz1 + 2 * lz2 - 32 - 32; - } - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/fixed/schur64_FIX.c b/Engine/lib/opus/silk/fixed/schur64_FIX.c deleted file mode 100644 index 4b7e19ea5..000000000 --- a/Engine/lib/opus/silk/fixed/schur64_FIX.c +++ /dev/null @@ -1,93 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Slower than schur(), but more accurate. */ -/* Uses SMULL(), available on armv4 */ -opus_int32 silk_schur64( /* O returns residual energy */ - opus_int32 rc_Q16[], /* O Reflection coefficients [order] Q16 */ - const opus_int32 c[], /* I Correlations [order+1] */ - opus_int32 order /* I Prediction order */ -) -{ - opus_int k, n; - opus_int32 C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ]; - opus_int32 Ctmp1_Q30, Ctmp2_Q30, rc_tmp_Q31; - - celt_assert( order >= 0 && order <= SILK_MAX_ORDER_LPC ); - - /* Check for invalid input */ - if( c[ 0 ] <= 0 ) { - silk_memset( rc_Q16, 0, order * sizeof( opus_int32 ) ); - return 0; - } - - k = 0; - do { - C[ k ][ 0 ] = C[ k ][ 1 ] = c[ k ]; - } while( ++k <= order ); - - for( k = 0; k < order; k++ ) { - /* Check that we won't be getting an unstable rc, otherwise stop here. */ - if (silk_abs_int32(C[ k + 1 ][ 0 ]) >= C[ 0 ][ 1 ]) { - if ( C[ k + 1 ][ 0 ] > 0 ) { - rc_Q16[ k ] = -SILK_FIX_CONST( .99f, 16 ); - } else { - rc_Q16[ k ] = SILK_FIX_CONST( .99f, 16 ); - } - k++; - break; - } - - /* Get reflection coefficient: divide two Q30 values and get result in Q31 */ - rc_tmp_Q31 = silk_DIV32_varQ( -C[ k + 1 ][ 0 ], C[ 0 ][ 1 ], 31 ); - - /* Save the output */ - rc_Q16[ k ] = silk_RSHIFT_ROUND( rc_tmp_Q31, 15 ); - - /* Update correlations */ - for( n = 0; n < order - k; n++ ) { - Ctmp1_Q30 = C[ n + k + 1 ][ 0 ]; - Ctmp2_Q30 = C[ n ][ 1 ]; - - /* Multiply and add the highest int32 */ - C[ n + k + 1 ][ 0 ] = Ctmp1_Q30 + silk_SMMUL( silk_LSHIFT( Ctmp2_Q30, 1 ), rc_tmp_Q31 ); - C[ n ][ 1 ] = Ctmp2_Q30 + silk_SMMUL( silk_LSHIFT( Ctmp1_Q30, 1 ), rc_tmp_Q31 ); - } - } - - for(; k < order; k++ ) { - rc_Q16[ k ] = 0; - } - - return silk_max_32( 1, C[ 0 ][ 1 ] ); -} diff --git a/Engine/lib/opus/silk/fixed/schur_FIX.c b/Engine/lib/opus/silk/fixed/schur_FIX.c deleted file mode 100644 index 2840f6b1a..000000000 --- a/Engine/lib/opus/silk/fixed/schur_FIX.c +++ /dev/null @@ -1,107 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Faster than schur64(), but much less accurate. */ -/* uses SMLAWB(), requiring armv5E and higher. */ -opus_int32 silk_schur( /* O Returns residual energy */ - opus_int16 *rc_Q15, /* O reflection coefficients [order] Q15 */ - const opus_int32 *c, /* I correlations [order+1] */ - const opus_int32 order /* I prediction order */ -) -{ - opus_int k, n, lz; - opus_int32 C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ]; - opus_int32 Ctmp1, Ctmp2, rc_tmp_Q15; - - celt_assert( order >= 0 && order <= SILK_MAX_ORDER_LPC ); - - /* Get number of leading zeros */ - lz = silk_CLZ32( c[ 0 ] ); - - /* Copy correlations and adjust level to Q30 */ - k = 0; - if( lz < 2 ) { - /* lz must be 1, so shift one to the right */ - do { - C[ k ][ 0 ] = C[ k ][ 1 ] = silk_RSHIFT( c[ k ], 1 ); - } while( ++k <= order ); - } else if( lz > 2 ) { - /* Shift to the left */ - lz -= 2; - do { - C[ k ][ 0 ] = C[ k ][ 1 ] = silk_LSHIFT( c[ k ], lz ); - } while( ++k <= order ); - } else { - /* No need to shift */ - do { - C[ k ][ 0 ] = C[ k ][ 1 ] = c[ k ]; - } while( ++k <= order ); - } - - for( k = 0; k < order; k++ ) { - /* Check that we won't be getting an unstable rc, otherwise stop here. */ - if (silk_abs_int32(C[ k + 1 ][ 0 ]) >= C[ 0 ][ 1 ]) { - if ( C[ k + 1 ][ 0 ] > 0 ) { - rc_Q15[ k ] = -SILK_FIX_CONST( .99f, 15 ); - } else { - rc_Q15[ k ] = SILK_FIX_CONST( .99f, 15 ); - } - k++; - break; - } - - /* Get reflection coefficient */ - rc_tmp_Q15 = -silk_DIV32_16( C[ k + 1 ][ 0 ], silk_max_32( silk_RSHIFT( C[ 0 ][ 1 ], 15 ), 1 ) ); - - /* Clip (shouldn't happen for properly conditioned inputs) */ - rc_tmp_Q15 = silk_SAT16( rc_tmp_Q15 ); - - /* Store */ - rc_Q15[ k ] = (opus_int16)rc_tmp_Q15; - - /* Update correlations */ - for( n = 0; n < order - k; n++ ) { - Ctmp1 = C[ n + k + 1 ][ 0 ]; - Ctmp2 = C[ n ][ 1 ]; - C[ n + k + 1 ][ 0 ] = silk_SMLAWB( Ctmp1, silk_LSHIFT( Ctmp2, 1 ), rc_tmp_Q15 ); - C[ n ][ 1 ] = silk_SMLAWB( Ctmp2, silk_LSHIFT( Ctmp1, 1 ), rc_tmp_Q15 ); - } - } - - for(; k < order; k++ ) { - rc_Q15[ k ] = 0; - } - - /* return residual energy */ - return silk_max_32( 1, C[ 0 ][ 1 ] ); -} diff --git a/Engine/lib/opus/silk/fixed/structs_FIX.h b/Engine/lib/opus/silk/fixed/structs_FIX.h deleted file mode 100644 index 2774a97b2..000000000 --- a/Engine/lib/opus/silk/fixed/structs_FIX.h +++ /dev/null @@ -1,116 +0,0 @@ -/*********************************************************************** -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 SILK_STRUCTS_FIX_H -#define SILK_STRUCTS_FIX_H - -#include "typedef.h" -#include "main.h" -#include "structs.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/********************************/ -/* Noise shaping analysis state */ -/********************************/ -typedef struct { - opus_int8 LastGainIndex; - opus_int32 HarmBoost_smth_Q16; - opus_int32 HarmShapeGain_smth_Q16; - opus_int32 Tilt_smth_Q16; -} silk_shape_state_FIX; - -/********************************/ -/* Encoder state FIX */ -/********************************/ -typedef struct { - silk_encoder_state sCmn; /* Common struct, shared with floating-point code */ - silk_shape_state_FIX sShape; /* Shape state */ - - /* Buffer for find pitch and noise shape analysis */ - silk_DWORD_ALIGN opus_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */ - opus_int LTPCorr_Q15; /* Normalized correlation from pitch lag estimator */ - opus_int32 resNrgSmth; -} silk_encoder_state_FIX; - -/************************/ -/* Encoder control FIX */ -/************************/ -typedef struct { - /* Prediction and coding parameters */ - opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; - silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; - opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; - opus_int LTP_scale_Q14; - opus_int pitchL[ MAX_NB_SUBFR ]; - - /* Noise shaping parameters */ - /* Testing */ - silk_DWORD_ALIGN opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ]; - opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */ - opus_int Tilt_Q14[ MAX_NB_SUBFR ]; - opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ]; - opus_int Lambda_Q10; - opus_int input_quality_Q14; - opus_int coding_quality_Q14; - - /* measures */ - opus_int32 predGain_Q16; - opus_int LTPredCodGain_Q7; - opus_int32 ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */ - opus_int ResNrgQ[ MAX_NB_SUBFR ]; /* Q domain for the residual energy > 0 */ - - /* Parameters for CBR mode */ - opus_int32 GainsUnq_Q16[ MAX_NB_SUBFR ]; - opus_int8 lastGainIndexPrev; -} silk_encoder_control_FIX; - -/************************/ -/* Encoder Super Struct */ -/************************/ -typedef struct { - silk_encoder_state_FIX state_Fxx[ ENCODER_NUM_CHANNELS ]; - stereo_enc_state sStereo; - opus_int32 nBitsUsedLBRR; - opus_int32 nBitsExceeded; - opus_int nChannelsAPI; - opus_int nChannelsInternal; - opus_int nPrevChannelsInternal; - opus_int timeSinceSwitchAllowed_ms; - opus_int allowBandwidthSwitch; - opus_int prev_decode_only_middle; -} silk_encoder; - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/silk/fixed/vector_ops_FIX.c b/Engine/lib/opus/silk/fixed/vector_ops_FIX.c deleted file mode 100644 index dcf84070a..000000000 --- a/Engine/lib/opus/silk/fixed/vector_ops_FIX.c +++ /dev/null @@ -1,102 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "pitch.h" - -/* Copy and multiply a vector by a constant */ -void silk_scale_copy_vector16( - opus_int16 *data_out, - const opus_int16 *data_in, - opus_int32 gain_Q16, /* I Gain in Q16 */ - const opus_int dataSize /* I Length */ -) -{ - opus_int i; - opus_int32 tmp32; - - for( i = 0; i < dataSize; i++ ) { - tmp32 = silk_SMULWB( gain_Q16, data_in[ i ] ); - data_out[ i ] = (opus_int16)silk_CHECK_FIT16( tmp32 ); - } -} - -/* Multiply a vector by a constant */ -void silk_scale_vector32_Q26_lshift_18( - opus_int32 *data1, /* I/O Q0/Q18 */ - opus_int32 gain_Q26, /* I Q26 */ - opus_int dataSize /* I length */ -) -{ - opus_int i; - - for( i = 0; i < dataSize; i++ ) { - data1[ i ] = (opus_int32)silk_CHECK_FIT32( silk_RSHIFT64( silk_SMULL( data1[ i ], gain_Q26 ), 8 ) ); /* OUTPUT: Q18 */ - } -} - -/* sum = for(i=0;i6, memory access can be reduced by half. */ -opus_int32 silk_inner_prod_aligned( - const opus_int16 *const inVec1, /* I input vector 1 */ - const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int len, /* I vector lengths */ - int arch /* I Run-time architecture */ -) -{ -#ifdef FIXED_POINT - return celt_inner_prod(inVec1, inVec2, len, arch); -#else - opus_int i; - opus_int32 sum = 0; - for( i = 0; i < len; i++ ) { - sum = silk_SMLABB( sum, inVec1[ i ], inVec2[ i ] ); - } - return sum; -#endif -} - -opus_int64 silk_inner_prod16_c( - const opus_int16 *inVec1, /* I input vector 1 */ - const opus_int16 *inVec2, /* I input vector 2 */ - const opus_int len /* I vector lengths */ -) -{ - opus_int i; - opus_int64 sum = 0; - for( i = 0; i < len; i++ ) { - sum = silk_SMLALBB( sum, inVec1[ i ], inVec2[ i ] ); - } - return sum; -} diff --git a/Engine/lib/opus/silk/fixed/warped_autocorrelation_FIX.c b/Engine/lib/opus/silk/fixed/warped_autocorrelation_FIX.c deleted file mode 100644 index 5c79553bc..000000000 --- a/Engine/lib/opus/silk/fixed/warped_autocorrelation_FIX.c +++ /dev/null @@ -1,92 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FIX.h" - -#if defined(MIPSr1_ASM) -#include "mips/warped_autocorrelation_FIX_mipsr1.h" -#endif - - -/* Autocorrelations for a warped frequency axis */ -#ifndef OVERRIDE_silk_warped_autocorrelation_FIX_c -void silk_warped_autocorrelation_FIX_c( - opus_int32 *corr, /* O Result [order + 1] */ - opus_int *scale, /* O Scaling of the correlation vector */ - const opus_int16 *input, /* I Input data to correlate */ - const opus_int warping_Q16, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ -) -{ - opus_int n, i, lsh; - opus_int32 tmp1_QS, tmp2_QS; - opus_int32 state_QS[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; - opus_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; - - /* Order must be even */ - celt_assert( ( order & 1 ) == 0 ); - silk_assert( 2 * QS - QC >= 0 ); - - /* Loop over samples */ - for( n = 0; n < length; n++ ) { - tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS ); - /* Loop over allpass sections */ - for( i = 0; i < order; i += 2 ) { - /* Output of allpass section */ - tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 ); - state_QS[ i ] = tmp1_QS; - corr_QC[ i ] += silk_RSHIFT64( silk_SMULL( tmp1_QS, state_QS[ 0 ] ), 2 * QS - QC ); - /* Output of allpass section */ - tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 ); - state_QS[ i + 1 ] = tmp2_QS; - corr_QC[ i + 1 ] += silk_RSHIFT64( silk_SMULL( tmp2_QS, state_QS[ 0 ] ), 2 * QS - QC ); - } - state_QS[ order ] = tmp1_QS; - corr_QC[ order ] += silk_RSHIFT64( silk_SMULL( tmp1_QS, state_QS[ 0 ] ), 2 * QS - QC ); - } - - lsh = silk_CLZ64( corr_QC[ 0 ] ) - 35; - lsh = silk_LIMIT( lsh, -12 - QC, 30 - QC ); - *scale = -( QC + lsh ); - silk_assert( *scale >= -30 && *scale <= 12 ); - if( lsh >= 0 ) { - for( i = 0; i < order + 1; i++ ) { - corr[ i ] = (opus_int32)silk_CHECK_FIT32( silk_LSHIFT64( corr_QC[ i ], lsh ) ); - } - } else { - for( i = 0; i < order + 1; i++ ) { - corr[ i ] = (opus_int32)silk_CHECK_FIT32( silk_RSHIFT64( corr_QC[ i ], -lsh ) ); - } - } - silk_assert( corr_QC[ 0 ] >= 0 ); /* If breaking, decrease QC*/ -} -#endif /* OVERRIDE_silk_warped_autocorrelation_FIX_c */ diff --git a/Engine/lib/opus/silk/fixed/x86/burg_modified_FIX_sse4_1.c b/Engine/lib/opus/silk/fixed/x86/burg_modified_FIX_sse4_1.c deleted file mode 100644 index e58bf079e..000000000 --- a/Engine/lib/opus/silk/fixed/x86/burg_modified_FIX_sse4_1.c +++ /dev/null @@ -1,400 +0,0 @@ -/* Copyright (c) 2014-2020, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang FrancisQuiers - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - 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 -#include -#include - -#include "SigProc_FIX.h" -#include "define.h" -#include "tuning_parameters.h" -#include "pitch.h" -#include "celt/x86/x86cpu.h" - -#define MAX_FRAME_SIZE 384 /* subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384 */ - -#define QA 25 -#define N_BITS_HEAD_ROOM 3 -#define MIN_RSHIFTS -16 -#define MAX_RSHIFTS (32 - QA) - -/* Compute reflection coefficients from input signal */ -void silk_burg_modified_sse4_1( - opus_int32 *res_nrg, /* O Residual energy */ - opus_int *res_nrg_Q, /* O Residual energy Q value */ - opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ - const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ - const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ - const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ - const opus_int nb_subfr, /* I Number of subframes stacked in x */ - const opus_int D, /* I Order */ - int arch /* I Run-time architecture */ -) -{ - opus_int k, n, s, lz, rshifts, reached_max_gain; - opus_int32 C0, num, nrg, rc_Q31, invGain_Q30, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2; - const opus_int16 *x_ptr; - opus_int32 C_first_row[ SILK_MAX_ORDER_LPC ]; - opus_int32 C_last_row[ SILK_MAX_ORDER_LPC ]; - opus_int32 Af_QA[ SILK_MAX_ORDER_LPC ]; - opus_int32 CAf[ SILK_MAX_ORDER_LPC + 1 ]; - opus_int32 CAb[ SILK_MAX_ORDER_LPC + 1 ]; - opus_int32 xcorr[ SILK_MAX_ORDER_LPC ]; - opus_int64 C0_64; - - __m128i FIRST_3210, LAST_3210, ATMP_3210, TMP1_3210, TMP2_3210, T1_3210, T2_3210, PTR_3210, SUBFR_3210, X1_3210, X2_3210; - __m128i CONST1 = _mm_set1_epi32(1); - - celt_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE ); - - /* Compute autocorrelations, added over subframes */ - C0_64 = silk_inner_prod16( x, x, subfr_length*nb_subfr, arch ); - lz = silk_CLZ64(C0_64); - rshifts = 32 + 1 + N_BITS_HEAD_ROOM - lz; - if (rshifts > MAX_RSHIFTS) rshifts = MAX_RSHIFTS; - if (rshifts < MIN_RSHIFTS) rshifts = MIN_RSHIFTS; - - if (rshifts > 0) { - C0 = (opus_int32)silk_RSHIFT64(C0_64, rshifts ); - } else { - C0 = silk_LSHIFT32((opus_int32)C0_64, -rshifts ); - } - - CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */ - silk_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) ); - if( rshifts > 0 ) { - 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 ] += (opus_int32)silk_RSHIFT64( - silk_inner_prod16( x_ptr, x_ptr + n, subfr_length - n, arch ), rshifts ); - } - } - } else { - for( s = 0; s < nb_subfr; s++ ) { - int i; - opus_int32 d; - x_ptr = x + s * subfr_length; - celt_pitch_xcorr(x_ptr, x_ptr + 1, xcorr, subfr_length - D, D, arch ); - for( n = 1; n < D + 1; n++ ) { - for ( i = n + subfr_length - D, d = 0; i < subfr_length; i++ ) - d = MAC16_16( d, x_ptr[ i ], x_ptr[ i - n ] ); - xcorr[ n - 1 ] += d; - } - for( n = 1; n < D + 1; n++ ) { - C_first_row[ n - 1 ] += silk_LSHIFT32( xcorr[ n - 1 ], -rshifts ); - } - } - } - silk_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) ); - - /* Initialize */ - CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */ - - invGain_Q30 = (opus_int32)1 << 30; - reached_max_gain = 0; - 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) */ - if( rshifts > -2 ) { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], 16 - rshifts ); /* Q(16-rshifts) */ - x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 16 - rshifts ); /* Q(16-rshifts) */ - tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], QA - 16 ); /* Q(QA-16) */ - tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], QA - 16 ); /* Q(QA-16) */ - for( k = 0; k < n; k++ ) { - C_first_row[ k ] = silk_SMLAWB( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */ - C_last_row[ k ] = silk_SMLAWB( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */ - Atmp_QA = Af_QA[ k ]; - tmp1 = silk_SMLAWB( tmp1, Atmp_QA, x_ptr[ n - k - 1 ] ); /* Q(QA-16) */ - tmp2 = silk_SMLAWB( tmp2, Atmp_QA, x_ptr[ subfr_length - n + k ] ); /* Q(QA-16) */ - } - tmp1 = silk_LSHIFT32( -tmp1, 32 - QA - rshifts ); /* Q(16-rshifts) */ - tmp2 = silk_LSHIFT32( -tmp2, 32 - QA - rshifts ); /* Q(16-rshifts) */ - for( k = 0; k <= n; k++ ) { - CAf[ k ] = silk_SMLAWB( CAf[ k ], tmp1, x_ptr[ n - k ] ); /* Q( -rshift ) */ - CAb[ k ] = silk_SMLAWB( CAb[ k ], tmp2, x_ptr[ subfr_length - n + k - 1 ] ); /* Q( -rshift ) */ - } - } - } else { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - x1 = -silk_LSHIFT32( (opus_int32)x_ptr[ n ], -rshifts ); /* Q( -rshifts ) */ - x2 = -silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], -rshifts ); /* Q( -rshifts ) */ - tmp1 = silk_LSHIFT32( (opus_int32)x_ptr[ n ], 17 ); /* Q17 */ - tmp2 = silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n - 1 ], 17 ); /* Q17 */ - - X1_3210 = _mm_set1_epi32( x1 ); - X2_3210 = _mm_set1_epi32( x2 ); - TMP1_3210 = _mm_setzero_si128(); - TMP2_3210 = _mm_setzero_si128(); - for( k = 0; k < n - 3; k += 4 ) { - PTR_3210 = OP_CVTEPI16_EPI32_M64( &x_ptr[ n - k - 1 - 3 ] ); - SUBFR_3210 = OP_CVTEPI16_EPI32_M64( &x_ptr[ subfr_length - n + k ] ); - FIRST_3210 = _mm_loadu_si128( (__m128i *)&C_first_row[ k ] ); - PTR_3210 = _mm_shuffle_epi32( PTR_3210, _MM_SHUFFLE( 0, 1, 2, 3 ) ); - LAST_3210 = _mm_loadu_si128( (__m128i *)&C_last_row[ k ] ); - ATMP_3210 = _mm_loadu_si128( (__m128i *)&Af_QA[ k ] ); - - T1_3210 = _mm_mullo_epi32( PTR_3210, X1_3210 ); - T2_3210 = _mm_mullo_epi32( SUBFR_3210, X2_3210 ); - - ATMP_3210 = _mm_srai_epi32( ATMP_3210, 7 ); - ATMP_3210 = _mm_add_epi32( ATMP_3210, CONST1 ); - ATMP_3210 = _mm_srai_epi32( ATMP_3210, 1 ); - - FIRST_3210 = _mm_add_epi32( FIRST_3210, T1_3210 ); - LAST_3210 = _mm_add_epi32( LAST_3210, T2_3210 ); - - PTR_3210 = _mm_mullo_epi32( ATMP_3210, PTR_3210 ); - SUBFR_3210 = _mm_mullo_epi32( ATMP_3210, SUBFR_3210 ); - - _mm_storeu_si128( (__m128i *)&C_first_row[ k ], FIRST_3210 ); - _mm_storeu_si128( (__m128i *)&C_last_row[ k ], LAST_3210 ); - - TMP1_3210 = _mm_add_epi32( TMP1_3210, PTR_3210 ); - TMP2_3210 = _mm_add_epi32( TMP2_3210, SUBFR_3210 ); - } - - TMP1_3210 = _mm_add_epi32( TMP1_3210, _mm_unpackhi_epi64(TMP1_3210, TMP1_3210 ) ); - TMP2_3210 = _mm_add_epi32( TMP2_3210, _mm_unpackhi_epi64(TMP2_3210, TMP2_3210 ) ); - TMP1_3210 = _mm_add_epi32( TMP1_3210, _mm_shufflelo_epi16(TMP1_3210, 0x0E ) ); - TMP2_3210 = _mm_add_epi32( TMP2_3210, _mm_shufflelo_epi16(TMP2_3210, 0x0E ) ); - - tmp1 += _mm_cvtsi128_si32( TMP1_3210 ); - tmp2 += _mm_cvtsi128_si32( TMP2_3210 ); - - for( ; k < n; k++ ) { - C_first_row[ k ] = silk_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */ - C_last_row[ k ] = silk_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */ - Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17 */ - /* We sometimes get overflows in the multiplications (even beyond +/- 2^32), - but they cancel each other and the real result seems to always fit in a 32-bit - signed integer. This was determined experimentally, not theoretically (unfortunately). */ - tmp1 = silk_MLA_ovflw( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17 */ - tmp2 = silk_MLA_ovflw( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17 */ - } - - tmp1 = -tmp1; /* Q17 */ - tmp2 = -tmp2; /* Q17 */ - - { - __m128i xmm_tmp1, xmm_tmp2; - __m128i xmm_x_ptr_n_k_x2x0, xmm_x_ptr_n_k_x3x1; - __m128i xmm_x_ptr_sub_x2x0, xmm_x_ptr_sub_x3x1; - - xmm_tmp1 = _mm_set1_epi32( tmp1 ); - xmm_tmp2 = _mm_set1_epi32( tmp2 ); - - for( k = 0; k <= n - 3; k += 4 ) { - xmm_x_ptr_n_k_x2x0 = OP_CVTEPI16_EPI32_M64( &x_ptr[ n - k - 3 ] ); - xmm_x_ptr_sub_x2x0 = OP_CVTEPI16_EPI32_M64( &x_ptr[ subfr_length - n + k - 1 ] ); - - xmm_x_ptr_n_k_x2x0 = _mm_shuffle_epi32( xmm_x_ptr_n_k_x2x0, _MM_SHUFFLE( 0, 1, 2, 3 ) ); - - xmm_x_ptr_n_k_x2x0 = _mm_slli_epi32( xmm_x_ptr_n_k_x2x0, -rshifts - 1 ); - xmm_x_ptr_sub_x2x0 = _mm_slli_epi32( xmm_x_ptr_sub_x2x0, -rshifts - 1 ); - - /* equal shift right 4 bytes, xmm_x_ptr_n_k_x3x1 = _mm_srli_si128(xmm_x_ptr_n_k_x2x0, 4)*/ - xmm_x_ptr_n_k_x3x1 = _mm_shuffle_epi32( xmm_x_ptr_n_k_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - xmm_x_ptr_sub_x3x1 = _mm_shuffle_epi32( xmm_x_ptr_sub_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - - xmm_x_ptr_n_k_x2x0 = _mm_mul_epi32( xmm_x_ptr_n_k_x2x0, xmm_tmp1 ); - xmm_x_ptr_n_k_x3x1 = _mm_mul_epi32( xmm_x_ptr_n_k_x3x1, xmm_tmp1 ); - xmm_x_ptr_sub_x2x0 = _mm_mul_epi32( xmm_x_ptr_sub_x2x0, xmm_tmp2 ); - xmm_x_ptr_sub_x3x1 = _mm_mul_epi32( xmm_x_ptr_sub_x3x1, xmm_tmp2 ); - - xmm_x_ptr_n_k_x2x0 = _mm_srli_epi64( xmm_x_ptr_n_k_x2x0, 16 ); - xmm_x_ptr_n_k_x3x1 = _mm_slli_epi64( xmm_x_ptr_n_k_x3x1, 16 ); - xmm_x_ptr_sub_x2x0 = _mm_srli_epi64( xmm_x_ptr_sub_x2x0, 16 ); - xmm_x_ptr_sub_x3x1 = _mm_slli_epi64( xmm_x_ptr_sub_x3x1, 16 ); - - xmm_x_ptr_n_k_x2x0 = _mm_blend_epi16( xmm_x_ptr_n_k_x2x0, xmm_x_ptr_n_k_x3x1, 0xCC ); - xmm_x_ptr_sub_x2x0 = _mm_blend_epi16( xmm_x_ptr_sub_x2x0, xmm_x_ptr_sub_x3x1, 0xCC ); - - X1_3210 = _mm_loadu_si128( (__m128i *)&CAf[ k ] ); - PTR_3210 = _mm_loadu_si128( (__m128i *)&CAb[ k ] ); - - X1_3210 = _mm_add_epi32( X1_3210, xmm_x_ptr_n_k_x2x0 ); - PTR_3210 = _mm_add_epi32( PTR_3210, xmm_x_ptr_sub_x2x0 ); - - _mm_storeu_si128( (__m128i *)&CAf[ k ], X1_3210 ); - _mm_storeu_si128( (__m128i *)&CAb[ k ], PTR_3210 ); - } - - for( ; k <= n; k++ ) { - CAf[ k ] = silk_SMLAWW( CAf[ k ], tmp1, - silk_LSHIFT32( (opus_int32)x_ptr[ n - k ], -rshifts - 1 ) ); /* Q( -rshift ) */ - CAb[ k ] = silk_SMLAWW( CAb[ k ], tmp2, - silk_LSHIFT32( (opus_int32)x_ptr[ subfr_length - n + k - 1 ], -rshifts - 1 ) ); /* Q( -rshift ) */ - } - } - } - } - - /* Calculate nominator and denominator for the next order reflection (parcor) coefficient */ - tmp1 = C_first_row[ n ]; /* Q( -rshifts ) */ - tmp2 = C_last_row[ n ]; /* Q( -rshifts ) */ - num = 0; /* Q( -rshifts ) */ - nrg = silk_ADD32( CAb[ 0 ], CAf[ 0 ] ); /* Q( 1-rshifts ) */ - for( k = 0; k < n; k++ ) { - Atmp_QA = Af_QA[ k ]; - lz = silk_CLZ32( silk_abs( Atmp_QA ) ) - 1; - lz = silk_min( 32 - QA, lz ); - Atmp1 = silk_LSHIFT32( Atmp_QA, lz ); /* Q( QA + lz ) */ - - tmp1 = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( C_last_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ - tmp2 = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( C_first_row[ n - k - 1 ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ - num = silk_ADD_LSHIFT32( num, silk_SMMUL( CAb[ n - k ], Atmp1 ), 32 - QA - lz ); /* Q( -rshifts ) */ - nrg = silk_ADD_LSHIFT32( nrg, silk_SMMUL( silk_ADD32( CAb[ k + 1 ], CAf[ k + 1 ] ), - Atmp1 ), 32 - QA - lz ); /* Q( 1-rshifts ) */ - } - CAf[ n + 1 ] = tmp1; /* Q( -rshifts ) */ - CAb[ n + 1 ] = tmp2; /* Q( -rshifts ) */ - num = silk_ADD32( num, tmp2 ); /* Q( -rshifts ) */ - num = silk_LSHIFT32( -num, 1 ); /* Q( 1-rshifts ) */ - - /* Calculate the next order reflection (parcor) coefficient */ - if( silk_abs( num ) < nrg ) { - rc_Q31 = silk_DIV32_varQ( num, nrg, 31 ); - } else { - rc_Q31 = ( num > 0 ) ? silk_int32_MAX : silk_int32_MIN; - } - - /* Update inverse prediction gain */ - tmp1 = ( (opus_int32)1 << 30 ) - silk_SMMUL( rc_Q31, rc_Q31 ); - tmp1 = silk_LSHIFT( silk_SMMUL( invGain_Q30, tmp1 ), 2 ); - if( tmp1 <= minInvGain_Q30 ) { - /* Max prediction gain exceeded; set reflection coefficient such that max prediction gain is exactly hit */ - tmp2 = ( (opus_int32)1 << 30 ) - silk_DIV32_varQ( minInvGain_Q30, invGain_Q30, 30 ); /* Q30 */ - rc_Q31 = silk_SQRT_APPROX( tmp2 ); /* Q15 */ - if( rc_Q31 > 0 ) { - /* Newton-Raphson iteration */ - rc_Q31 = silk_RSHIFT32( rc_Q31 + silk_DIV32( tmp2, rc_Q31 ), 1 ); /* Q15 */ - rc_Q31 = silk_LSHIFT32( rc_Q31, 16 ); /* Q31 */ - if( num < 0 ) { - /* Ensure adjusted reflection coefficients has the original sign */ - rc_Q31 = -rc_Q31; - } - } - invGain_Q30 = minInvGain_Q30; - reached_max_gain = 1; - } else { - invGain_Q30 = tmp1; - } - - /* Update the AR coefficients */ - for( k = 0; k < (n + 1) >> 1; k++ ) { - tmp1 = Af_QA[ k ]; /* QA */ - tmp2 = Af_QA[ n - k - 1 ]; /* QA */ - Af_QA[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* QA */ - Af_QA[ n - k - 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* QA */ - } - Af_QA[ n ] = silk_RSHIFT32( rc_Q31, 31 - QA ); /* QA */ - - if( reached_max_gain ) { - /* Reached max prediction gain; set remaining coefficients to zero and exit loop */ - for( k = n + 1; k < D; k++ ) { - Af_QA[ k ] = 0; - } - break; - } - - /* Update C * Af and C * Ab */ - for( k = 0; k <= n + 1; k++ ) { - tmp1 = CAf[ k ]; /* Q( -rshifts ) */ - tmp2 = CAb[ n - k + 1 ]; /* Q( -rshifts ) */ - CAf[ k ] = silk_ADD_LSHIFT32( tmp1, silk_SMMUL( tmp2, rc_Q31 ), 1 ); /* Q( -rshifts ) */ - CAb[ n - k + 1 ] = silk_ADD_LSHIFT32( tmp2, silk_SMMUL( tmp1, rc_Q31 ), 1 ); /* Q( -rshifts ) */ - } - } - - if( reached_max_gain ) { - for( k = 0; k < D; k++ ) { - /* Scale coefficients */ - A_Q16[ k ] = -silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); - } - /* Subtract energy of preceding samples from C0 */ - if( rshifts > 0 ) { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - C0 -= (opus_int32)silk_RSHIFT64( silk_inner_prod16( x_ptr, x_ptr, D, arch ), rshifts ); - } - } else { - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - C0 -= silk_LSHIFT32( silk_inner_prod_aligned( x_ptr, x_ptr, D, arch ), -rshifts ); - } - } - /* Approximate residual energy */ - *res_nrg = silk_LSHIFT( silk_SMMUL( invGain_Q30, C0 ), 2 ); - *res_nrg_Q = -rshifts; - } else { - /* Return residual energy */ - nrg = CAf[ 0 ]; /* Q( -rshifts ) */ - tmp1 = (opus_int32)1 << 16; /* Q16 */ - for( k = 0; k < D; k++ ) { - Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 16 ); /* Q16 */ - nrg = silk_SMLAWW( nrg, CAf[ k + 1 ], Atmp1 ); /* Q( -rshifts ) */ - tmp1 = silk_SMLAWW( tmp1, Atmp1, Atmp1 ); /* Q16 */ - A_Q16[ k ] = -Atmp1; - } - *res_nrg = silk_SMLAWW( nrg, silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ), -tmp1 );/* Q( -rshifts ) */ - *res_nrg_Q = -rshifts; - } - -#ifdef OPUS_CHECK_ASM - { - opus_int32 res_nrg_c = 0; - opus_int res_nrg_Q_c = 0; - opus_int32 A_Q16_c[ MAX_LPC_ORDER ] = {0}; - - silk_burg_modified_c( - &res_nrg_c, - &res_nrg_Q_c, - A_Q16_c, - x, - minInvGain_Q30, - subfr_length, - nb_subfr, - D, - 0 - ); - - silk_assert( *res_nrg == res_nrg_c ); - silk_assert( *res_nrg_Q == res_nrg_Q_c ); - silk_assert( !memcmp( A_Q16, A_Q16_c, D * sizeof( *A_Q16 ) ) ); - } -#endif -} diff --git a/Engine/lib/opus/silk/fixed/x86/vector_ops_FIX_sse4_1.c b/Engine/lib/opus/silk/fixed/x86/vector_ops_FIX_sse4_1.c deleted file mode 100644 index a46289bbc..000000000 --- a/Engine/lib/opus/silk/fixed/x86/vector_ops_FIX_sse4_1.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (c) 2014, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include "main.h" - -#include "SigProc_FIX.h" -#include "pitch.h" -#include "celt/x86/x86cpu.h" - -opus_int64 silk_inner_prod16_sse4_1( - const opus_int16 *inVec1, /* I input vector 1 */ - const opus_int16 *inVec2, /* I input vector 2 */ - const opus_int len /* I vector lengths */ -) -{ - opus_int i, dataSize4; - opus_int64 sum; - - __m128i xmm_prod_20, xmm_prod_31; - __m128i inVec1_3210, acc1; - __m128i inVec2_3210, acc2; - - sum = 0; - dataSize4 = len & ~3; - - acc1 = _mm_setzero_si128(); - acc2 = _mm_setzero_si128(); - - for( i = 0; i < dataSize4; i += 4 ) { - inVec1_3210 = OP_CVTEPI16_EPI32_M64( &inVec1[i + 0] ); - inVec2_3210 = OP_CVTEPI16_EPI32_M64( &inVec2[i + 0] ); - xmm_prod_20 = _mm_mul_epi32( inVec1_3210, inVec2_3210 ); - - inVec1_3210 = _mm_shuffle_epi32( inVec1_3210, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - inVec2_3210 = _mm_shuffle_epi32( inVec2_3210, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - xmm_prod_31 = _mm_mul_epi32( inVec1_3210, inVec2_3210 ); - - acc1 = _mm_add_epi64( acc1, xmm_prod_20 ); - acc2 = _mm_add_epi64( acc2, xmm_prod_31 ); - } - - acc1 = _mm_add_epi64( acc1, acc2 ); - - /* equal shift right 8 bytes */ - acc2 = _mm_shuffle_epi32( acc1, _MM_SHUFFLE( 0, 0, 3, 2 ) ); - acc1 = _mm_add_epi64( acc1, acc2 ); - - _mm_storel_epi64( (__m128i *)&sum, acc1 ); - - for( ; i < len; i++ ) { - sum = silk_SMLALBB( sum, inVec1[ i ], inVec2[ i ] ); - } - -#ifdef OPUS_CHECK_ASM - { - opus_int64 sum_c = silk_inner_prod16_c( inVec1, inVec2, len ); - silk_assert( sum == sum_c ); - } -#endif - - return sum; -} diff --git a/Engine/lib/opus/silk/float/LPC_analysis_filter_FLP.c b/Engine/lib/opus/silk/float/LPC_analysis_filter_FLP.c deleted file mode 100644 index 0e1a1fed0..000000000 --- a/Engine/lib/opus/silk/float/LPC_analysis_filter_FLP.c +++ /dev/null @@ -1,249 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include -#include "main_FLP.h" - -/************************************************/ -/* LPC analysis filter */ -/* NB! State is kept internally and the */ -/* filter always starts with zero state */ -/* first Order output samples are set to zero */ -/************************************************/ - -/* 16th order LPC analysis filter, does not write first 16 samples */ -static OPUS_INLINE void silk_LPC_analysis_filter16_FLP( - silk_float r_LPC[], /* O LPC residual signal */ - const silk_float PredCoef[], /* I LPC coefficients */ - const silk_float s[], /* I Input signal */ - const opus_int length /* I Length of input signal */ -) -{ - opus_int ix; - silk_float LPC_pred; - const silk_float *s_ptr; - - for( ix = 16; ix < length; ix++ ) { - s_ptr = &s[ix - 1]; - - /* short-term prediction */ - LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + - s_ptr[ -1 ] * PredCoef[ 1 ] + - s_ptr[ -2 ] * PredCoef[ 2 ] + - s_ptr[ -3 ] * PredCoef[ 3 ] + - s_ptr[ -4 ] * PredCoef[ 4 ] + - s_ptr[ -5 ] * PredCoef[ 5 ] + - s_ptr[ -6 ] * PredCoef[ 6 ] + - s_ptr[ -7 ] * PredCoef[ 7 ] + - s_ptr[ -8 ] * PredCoef[ 8 ] + - s_ptr[ -9 ] * PredCoef[ 9 ] + - s_ptr[ -10 ] * PredCoef[ 10 ] + - s_ptr[ -11 ] * PredCoef[ 11 ] + - s_ptr[ -12 ] * PredCoef[ 12 ] + - s_ptr[ -13 ] * PredCoef[ 13 ] + - s_ptr[ -14 ] * PredCoef[ 14 ] + - s_ptr[ -15 ] * PredCoef[ 15 ]; - - /* prediction error */ - r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; - } -} - -/* 12th order LPC analysis filter, does not write first 12 samples */ -static OPUS_INLINE void silk_LPC_analysis_filter12_FLP( - silk_float r_LPC[], /* O LPC residual signal */ - const silk_float PredCoef[], /* I LPC coefficients */ - const silk_float s[], /* I Input signal */ - const opus_int length /* I Length of input signal */ -) -{ - opus_int ix; - silk_float LPC_pred; - const silk_float *s_ptr; - - for( ix = 12; ix < length; ix++ ) { - s_ptr = &s[ix - 1]; - - /* short-term prediction */ - LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + - s_ptr[ -1 ] * PredCoef[ 1 ] + - s_ptr[ -2 ] * PredCoef[ 2 ] + - s_ptr[ -3 ] * PredCoef[ 3 ] + - s_ptr[ -4 ] * PredCoef[ 4 ] + - s_ptr[ -5 ] * PredCoef[ 5 ] + - s_ptr[ -6 ] * PredCoef[ 6 ] + - s_ptr[ -7 ] * PredCoef[ 7 ] + - s_ptr[ -8 ] * PredCoef[ 8 ] + - s_ptr[ -9 ] * PredCoef[ 9 ] + - s_ptr[ -10 ] * PredCoef[ 10 ] + - s_ptr[ -11 ] * PredCoef[ 11 ]; - - /* prediction error */ - r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; - } -} - -/* 10th order LPC analysis filter, does not write first 10 samples */ -static OPUS_INLINE void silk_LPC_analysis_filter10_FLP( - silk_float r_LPC[], /* O LPC residual signal */ - const silk_float PredCoef[], /* I LPC coefficients */ - const silk_float s[], /* I Input signal */ - const opus_int length /* I Length of input signal */ -) -{ - opus_int ix; - silk_float LPC_pred; - const silk_float *s_ptr; - - for( ix = 10; ix < length; ix++ ) { - s_ptr = &s[ix - 1]; - - /* short-term prediction */ - LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + - s_ptr[ -1 ] * PredCoef[ 1 ] + - s_ptr[ -2 ] * PredCoef[ 2 ] + - s_ptr[ -3 ] * PredCoef[ 3 ] + - s_ptr[ -4 ] * PredCoef[ 4 ] + - s_ptr[ -5 ] * PredCoef[ 5 ] + - s_ptr[ -6 ] * PredCoef[ 6 ] + - s_ptr[ -7 ] * PredCoef[ 7 ] + - s_ptr[ -8 ] * PredCoef[ 8 ] + - s_ptr[ -9 ] * PredCoef[ 9 ]; - - /* prediction error */ - r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; - } -} - -/* 8th order LPC analysis filter, does not write first 8 samples */ -static OPUS_INLINE void silk_LPC_analysis_filter8_FLP( - silk_float r_LPC[], /* O LPC residual signal */ - const silk_float PredCoef[], /* I LPC coefficients */ - const silk_float s[], /* I Input signal */ - const opus_int length /* I Length of input signal */ -) -{ - opus_int ix; - silk_float LPC_pred; - const silk_float *s_ptr; - - for( ix = 8; ix < length; ix++ ) { - s_ptr = &s[ix - 1]; - - /* short-term prediction */ - LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + - s_ptr[ -1 ] * PredCoef[ 1 ] + - s_ptr[ -2 ] * PredCoef[ 2 ] + - s_ptr[ -3 ] * PredCoef[ 3 ] + - s_ptr[ -4 ] * PredCoef[ 4 ] + - s_ptr[ -5 ] * PredCoef[ 5 ] + - s_ptr[ -6 ] * PredCoef[ 6 ] + - s_ptr[ -7 ] * PredCoef[ 7 ]; - - /* prediction error */ - r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; - } -} - -/* 6th order LPC analysis filter, does not write first 6 samples */ -static OPUS_INLINE void silk_LPC_analysis_filter6_FLP( - silk_float r_LPC[], /* O LPC residual signal */ - const silk_float PredCoef[], /* I LPC coefficients */ - const silk_float s[], /* I Input signal */ - const opus_int length /* I Length of input signal */ -) -{ - opus_int ix; - silk_float LPC_pred; - const silk_float *s_ptr; - - for( ix = 6; ix < length; ix++ ) { - s_ptr = &s[ix - 1]; - - /* short-term prediction */ - LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] + - s_ptr[ -1 ] * PredCoef[ 1 ] + - s_ptr[ -2 ] * PredCoef[ 2 ] + - s_ptr[ -3 ] * PredCoef[ 3 ] + - s_ptr[ -4 ] * PredCoef[ 4 ] + - s_ptr[ -5 ] * PredCoef[ 5 ]; - - /* prediction error */ - r_LPC[ix] = s_ptr[ 1 ] - LPC_pred; - } -} - -/************************************************/ -/* LPC analysis filter */ -/* NB! State is kept internally and the */ -/* filter always starts with zero state */ -/* first Order output samples are set to zero */ -/************************************************/ -void silk_LPC_analysis_filter_FLP( - silk_float r_LPC[], /* O LPC residual signal */ - const silk_float PredCoef[], /* I LPC coefficients */ - const silk_float s[], /* I Input signal */ - const opus_int length, /* I Length of input signal */ - const opus_int Order /* I LPC order */ -) -{ - celt_assert( Order <= length ); - - switch( Order ) { - case 6: - silk_LPC_analysis_filter6_FLP( r_LPC, PredCoef, s, length ); - break; - - case 8: - silk_LPC_analysis_filter8_FLP( r_LPC, PredCoef, s, length ); - break; - - case 10: - silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length ); - break; - - case 12: - silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length ); - break; - - case 16: - silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length ); - break; - - default: - celt_assert( 0 ); - break; - } - - /* Set first Order output samples to zero */ - silk_memset( r_LPC, 0, Order * sizeof( silk_float ) ); -} - diff --git a/Engine/lib/opus/silk/float/LPC_inv_pred_gain_FLP.c b/Engine/lib/opus/silk/float/LPC_inv_pred_gain_FLP.c deleted file mode 100644 index 2be2122d6..000000000 --- a/Engine/lib/opus/silk/float/LPC_inv_pred_gain_FLP.c +++ /dev/null @@ -1,73 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "SigProc_FLP.h" -#include "define.h" - -/* compute inverse of LPC prediction gain, and */ -/* test if LPC coefficients are stable (all poles within unit circle) */ -/* this code is based on silk_a2k_FLP() */ -silk_float silk_LPC_inverse_pred_gain_FLP( /* O return inverse prediction gain, energy domain */ - const silk_float *A, /* I prediction coefficients [order] */ - opus_int32 order /* I prediction order */ -) -{ - opus_int k, n; - double invGain, rc, rc_mult1, rc_mult2, tmp1, tmp2; - silk_float Atmp[ SILK_MAX_ORDER_LPC ]; - - silk_memcpy( Atmp, A, order * sizeof(silk_float) ); - - invGain = 1.0; - for( k = order - 1; k > 0; k-- ) { - rc = -Atmp[ k ]; - rc_mult1 = 1.0f - rc * rc; - invGain *= rc_mult1; - if( invGain * MAX_PREDICTION_POWER_GAIN < 1.0f ) { - return 0.0f; - } - rc_mult2 = 1.0f / rc_mult1; - for( n = 0; n < (k + 1) >> 1; n++ ) { - tmp1 = Atmp[ n ]; - tmp2 = Atmp[ k - n - 1 ]; - Atmp[ n ] = (silk_float)( ( tmp1 - tmp2 * rc ) * rc_mult2 ); - Atmp[ k - n - 1 ] = (silk_float)( ( tmp2 - tmp1 * rc ) * rc_mult2 ); - } - } - rc = -Atmp[ 0 ]; - rc_mult1 = 1.0f - rc * rc; - invGain *= rc_mult1; - if( invGain * MAX_PREDICTION_POWER_GAIN < 1.0f ) { - return 0.0f; - } - return (silk_float)invGain; -} diff --git a/Engine/lib/opus/silk/float/LTP_analysis_filter_FLP.c b/Engine/lib/opus/silk/float/LTP_analysis_filter_FLP.c deleted file mode 100644 index 849b7c1c5..000000000 --- a/Engine/lib/opus/silk/float/LTP_analysis_filter_FLP.c +++ /dev/null @@ -1,75 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" - -void silk_LTP_analysis_filter_FLP( - silk_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */ - const silk_float *x, /* I Input signal, with preceding samples */ - const silk_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */ - const opus_int subfr_length, /* I Length of each subframe */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int pre_length /* I Preceding samples for each subframe */ -) -{ - const silk_float *x_ptr, *x_lag_ptr; - silk_float Btmp[ LTP_ORDER ]; - silk_float *LTP_res_ptr; - silk_float inv_gain; - opus_int k, i, j; - - x_ptr = x; - LTP_res_ptr = LTP_res; - for( k = 0; k < nb_subfr; k++ ) { - x_lag_ptr = x_ptr - pitchL[ k ]; - inv_gain = invGains[ k ]; - for( i = 0; i < LTP_ORDER; i++ ) { - Btmp[ i ] = B[ k * LTP_ORDER + i ]; - } - - /* LTP analysis FIR filter */ - for( i = 0; i < subfr_length + pre_length; i++ ) { - LTP_res_ptr[ i ] = x_ptr[ i ]; - /* Subtract long-term prediction */ - for( j = 0; j < LTP_ORDER; j++ ) { - LTP_res_ptr[ i ] -= Btmp[ j ] * x_lag_ptr[ LTP_ORDER / 2 - j ]; - } - LTP_res_ptr[ i ] *= inv_gain; - x_lag_ptr++; - } - - /* Update pointers */ - LTP_res_ptr += subfr_length + pre_length; - x_ptr += subfr_length; - } -} diff --git a/Engine/lib/opus/silk/float/LTP_scale_ctrl_FLP.c b/Engine/lib/opus/silk/float/LTP_scale_ctrl_FLP.c deleted file mode 100644 index 6f30ff095..000000000 --- a/Engine/lib/opus/silk/float/LTP_scale_ctrl_FLP.c +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" - -void silk_LTP_scale_ctrl_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - opus_int condCoding /* I The type of conditional coding to use */ -) -{ - opus_int round_loss; - - if( condCoding == CODE_INDEPENDENTLY ) { - /* Only scale if first frame in packet */ - round_loss = psEnc->sCmn.PacketLoss_perc * psEnc->sCmn.nFramesPerPacket; - if ( psEnc->sCmn.LBRR_flag ) { - /* LBRR reduces the effective loss. In practice, it does not square the loss because - losses aren't independent, but that still seems to work best. We also never go below 2%. */ - round_loss = 2 + silk_SMULBB( round_loss, round_loss) / 100; - } - psEnc->sCmn.indices.LTP_scaleIndex = silk_SMULBB( psEncCtrl->LTPredCodGain, round_loss ) > silk_log2lin( 2900 - psEnc->sCmn.SNR_dB_Q7 ); - psEnc->sCmn.indices.LTP_scaleIndex += silk_SMULBB( psEncCtrl->LTPredCodGain, round_loss ) > silk_log2lin( 3900 - psEnc->sCmn.SNR_dB_Q7 ); - } else { - /* Default is minimum scaling */ - psEnc->sCmn.indices.LTP_scaleIndex = 0; - } - - psEncCtrl->LTP_scale = (silk_float)silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ] / 16384.0f; -} diff --git a/Engine/lib/opus/silk/float/SigProc_FLP.h b/Engine/lib/opus/silk/float/SigProc_FLP.h deleted file mode 100644 index 953de8b09..000000000 --- a/Engine/lib/opus/silk/float/SigProc_FLP.h +++ /dev/null @@ -1,197 +0,0 @@ -/*********************************************************************** -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 SILK_SIGPROC_FLP_H -#define SILK_SIGPROC_FLP_H - -#include "SigProc_FIX.h" -#include "float_cast.h" -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/********************************************************************/ -/* SIGNAL PROCESSING FUNCTIONS */ -/********************************************************************/ - -/* Chirp (bw expand) LP AR filter */ -void silk_bwexpander_FLP( - silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I length of ar */ - const silk_float chirp /* I chirp factor (typically in range (0..1) ) */ -); - -/* compute inverse of LPC prediction gain, and */ -/* test if LPC coefficients are stable (all poles within unit circle) */ -/* this code is based on silk_FLP_a2k() */ -silk_float silk_LPC_inverse_pred_gain_FLP( /* O return inverse prediction gain, energy domain */ - const silk_float *A, /* I prediction coefficients [order] */ - opus_int32 order /* I prediction order */ -); - -silk_float silk_schur_FLP( /* O returns residual energy */ - silk_float refl_coef[], /* O reflection coefficients (length order) */ - const silk_float auto_corr[], /* I autocorrelation sequence (length order+1) */ - opus_int order /* I order */ -); - -void silk_k2a_FLP( - silk_float *A, /* O prediction coefficients [order] */ - const silk_float *rc, /* I reflection coefficients [order] */ - opus_int32 order /* I prediction order */ -); - -/* compute autocorrelation */ -void silk_autocorrelation_FLP( - silk_float *results, /* O result (length correlationCount) */ - const silk_float *inputData, /* I input data to correlate */ - opus_int inputDataSize, /* I length of input */ - opus_int correlationCount /* I number of correlation taps to compute */ -); - -opus_int silk_pitch_analysis_core_FLP( /* O Voicing estimate: 0 voiced, 1 unvoiced */ - const silk_float *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ - opus_int *pitch_out, /* O Pitch lag values [nb_subfr] */ - opus_int16 *lagIndex, /* O Lag Index */ - opus_int8 *contourIndex, /* O Pitch contour Index */ - silk_float *LTPCorr, /* I/O Normalized correlation; input: value from previous frame */ - opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ - const silk_float search_thres1, /* I First stage threshold for lag candidates 0 - 1 */ - const silk_float search_thres2, /* I Final threshold for lag candidates 0 - 1 */ - const opus_int Fs_kHz, /* I sample frequency (kHz) */ - const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */ - const opus_int nb_subfr, /* I Number of 5 ms subframes */ - int arch /* I Run-time architecture */ -); - -void silk_insertion_sort_decreasing_FLP( - silk_float *a, /* I/O Unsorted / Sorted vector */ - opus_int *idx, /* O Index vector for the sorted elements */ - const opus_int L, /* I Vector length */ - const opus_int K /* I Number of correctly sorted positions */ -); - -/* Compute reflection coefficients from input signal */ -silk_float silk_burg_modified_FLP( /* O returns residual energy */ - silk_float A[], /* O prediction coefficients (length order) */ - const silk_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ - const silk_float minInvGain, /* I minimum inverse prediction gain */ - const opus_int subfr_length, /* I input signal subframe length (incl. D preceding samples) */ - const opus_int nb_subfr, /* I number of subframes stacked in x */ - const opus_int D /* I order */ -); - -/* multiply a vector by a constant */ -void silk_scale_vector_FLP( - silk_float *data1, - silk_float gain, - opus_int dataSize -); - -/* copy and multiply a vector by a constant */ -void silk_scale_copy_vector_FLP( - silk_float *data_out, - const silk_float *data_in, - silk_float gain, - opus_int dataSize -); - -/* inner product of two silk_float arrays, with result as double */ -double silk_inner_product_FLP( - const silk_float *data1, - const silk_float *data2, - opus_int dataSize -); - -/* sum of squares of a silk_float array, with result as double */ -double silk_energy_FLP( - const silk_float *data, - opus_int dataSize -); - -/********************************************************************/ -/* MACROS */ -/********************************************************************/ - -#define PI (3.1415926536f) - -#define silk_min_float( a, b ) (((a) < (b)) ? (a) : (b)) -#define silk_max_float( a, b ) (((a) > (b)) ? (a) : (b)) -#define silk_abs_float( a ) ((silk_float)fabs(a)) - -/* sigmoid function */ -static OPUS_INLINE silk_float silk_sigmoid( silk_float x ) -{ - return (silk_float)(1.0 / (1.0 + exp(-x))); -} - -/* floating-point to integer conversion (rounding) */ -static OPUS_INLINE opus_int32 silk_float2int( silk_float x ) -{ - return (opus_int32)float2int( x ); -} - -/* floating-point to integer conversion (rounding) */ -static OPUS_INLINE void silk_float2short_array( - opus_int16 *out, - const silk_float *in, - opus_int32 length -) -{ - opus_int32 k; - for( k = length - 1; k >= 0; k-- ) { - out[k] = silk_SAT16( (opus_int32)float2int( in[k] ) ); - } -} - -/* integer to floating-point conversion */ -static OPUS_INLINE void silk_short2float_array( - silk_float *out, - const opus_int16 *in, - opus_int32 length -) -{ - opus_int32 k; - for( k = length - 1; k >= 0; k-- ) { - out[k] = (silk_float)in[k]; - } -} - -/* using log2() helps the fixed-point conversion */ -static OPUS_INLINE silk_float silk_log2( double x ) -{ - return ( silk_float )( 3.32192809488736 * log10( x ) ); -} - -#ifdef __cplusplus -} -#endif - -#endif /* SILK_SIGPROC_FLP_H */ diff --git a/Engine/lib/opus/silk/float/apply_sine_window_FLP.c b/Engine/lib/opus/silk/float/apply_sine_window_FLP.c deleted file mode 100644 index e49e71799..000000000 --- a/Engine/lib/opus/silk/float/apply_sine_window_FLP.c +++ /dev/null @@ -1,81 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" - -/* Apply sine window to signal vector */ -/* Window types: */ -/* 1 -> sine window from 0 to pi/2 */ -/* 2 -> sine window from pi/2 to pi */ -void silk_apply_sine_window_FLP( - silk_float px_win[], /* O Pointer to windowed signal */ - const silk_float px[], /* I Pointer to input signal */ - const opus_int win_type, /* I Selects a window type */ - const opus_int length /* I Window length, multiple of 4 */ -) -{ - opus_int k; - silk_float freq, c, S0, S1; - - celt_assert( win_type == 1 || win_type == 2 ); - - /* Length must be multiple of 4 */ - celt_assert( ( length & 3 ) == 0 ); - - freq = PI / ( length + 1 ); - - /* Approximation of 2 * cos(f) */ - c = 2.0f - freq * freq; - - /* Initialize state */ - if( win_type < 2 ) { - /* Start from 0 */ - S0 = 0.0f; - /* Approximation of sin(f) */ - S1 = freq; - } else { - /* Start from 1 */ - S0 = 1.0f; - /* Approximation of cos(f) */ - S1 = 0.5f * c; - } - - /* Uses the recursive equation: sin(n*f) = 2 * cos(f) * sin((n-1)*f) - sin((n-2)*f) */ - /* 4 samples at a time */ - for( k = 0; k < length; k += 4 ) { - px_win[ k + 0 ] = px[ k + 0 ] * 0.5f * ( S0 + S1 ); - px_win[ k + 1 ] = px[ k + 1 ] * S1; - S0 = c * S1 - S0; - px_win[ k + 2 ] = px[ k + 2 ] * 0.5f * ( S1 + S0 ); - px_win[ k + 3 ] = px[ k + 3 ] * S0; - S1 = c * S0 - S1; - } -} diff --git a/Engine/lib/opus/silk/float/autocorrelation_FLP.c b/Engine/lib/opus/silk/float/autocorrelation_FLP.c deleted file mode 100644 index 8b8a9e659..000000000 --- a/Engine/lib/opus/silk/float/autocorrelation_FLP.c +++ /dev/null @@ -1,52 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "typedef.h" -#include "SigProc_FLP.h" - -/* compute autocorrelation */ -void silk_autocorrelation_FLP( - silk_float *results, /* O result (length correlationCount) */ - const silk_float *inputData, /* I input data to correlate */ - opus_int inputDataSize, /* I length of input */ - opus_int correlationCount /* I number of correlation taps to compute */ -) -{ - opus_int i; - - if( correlationCount > inputDataSize ) { - correlationCount = inputDataSize; - } - - for( i = 0; i < correlationCount; i++ ) { - results[ i ] = (silk_float)silk_inner_product_FLP( inputData, inputData + i, inputDataSize - i ); - } -} diff --git a/Engine/lib/opus/silk/float/burg_modified_FLP.c b/Engine/lib/opus/silk/float/burg_modified_FLP.c deleted file mode 100644 index 756b76a35..000000000 --- a/Engine/lib/opus/silk/float/burg_modified_FLP.c +++ /dev/null @@ -1,186 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FLP.h" -#include "tuning_parameters.h" -#include "define.h" - -#define MAX_FRAME_SIZE 384 /* subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384*/ - -/* Compute reflection coefficients from input signal */ -silk_float silk_burg_modified_FLP( /* O returns residual energy */ - silk_float A[], /* O prediction coefficients (length order) */ - const silk_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ - const silk_float minInvGain, /* I minimum inverse prediction gain */ - const opus_int subfr_length, /* I input signal subframe length (incl. D preceding samples) */ - const opus_int nb_subfr, /* I number of subframes stacked in x */ - const opus_int D /* I order */ -) -{ - opus_int k, n, s, reached_max_gain; - double C0, invGain, num, nrg_f, nrg_b, rc, Atmp, tmp1, tmp2; - const silk_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 ]; - - celt_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE ); - - /* Compute autocorrelations, added over subframes */ - C0 = silk_energy_FLP( x, nb_subfr * subfr_length ); - silk_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 ); - } - } - silk_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; - invGain = 1.0f; - reached_max_gain = 0; - 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; - 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 ]; - Atmp = Af[ k ]; - 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 ]; - } - } - tmp1 = C_first_row[ n ]; - tmp2 = C_last_row[ n ]; - 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; - } - CAf[ n + 1 ] = tmp1; - CAb[ n + 1 ] = tmp2; - - /* Calculate nominator and denominator for the next order reflection (parcor) coefficient */ - num = CAb[ n + 1 ]; - nrg_b = CAb[ 0 ]; - nrg_f = CAf[ 0 ]; - 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; - } - silk_assert( nrg_f > 0.0 ); - silk_assert( nrg_b > 0.0 ); - - /* Calculate the next order reflection (parcor) coefficient */ - rc = -2.0 * num / ( nrg_f + nrg_b ); - silk_assert( rc > -1.0 && rc < 1.0 ); - - /* Update inverse prediction gain */ - 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 ) { - /* Ensure adjusted reflection coefficients has the original sign */ - rc = -rc; - } - invGain = minInvGain; - reached_max_gain = 1; - } else { - invGain = tmp1; - } - - /* Update the AR coefficients */ - 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[ n ] = rc; - - if( reached_max_gain ) { - /* Reached max prediction gain; set remaining coefficients to zero and exit loop */ - 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++ ) { - tmp1 = CAf[ k ]; - CAf[ k ] += rc * CAb[ n - k + 1 ]; - CAb[ n - k + 1 ] += rc * tmp1; - } - } - - if( reached_max_gain ) { - /* Convert to silk_float */ - for( k = 0; k < D; k++ ) { - A[ k ] = (silk_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 ); - } - /* Approximate residual energy */ - nrg_f = C0 * invGain; - } else { - /* Compute residual energy and store coefficients as silk_float */ - nrg_f = CAf[ 0 ]; - tmp1 = 1.0; - for( k = 0; k < D; k++ ) { - Atmp = Af[ k ]; - nrg_f += CAf[ k + 1 ] * Atmp; - tmp1 += Atmp * Atmp; - A[ k ] = (silk_float)(-Atmp); - } - nrg_f -= FIND_LPC_COND_FAC * C0 * tmp1; - } - - /* Return residual energy */ - return (silk_float)nrg_f; -} diff --git a/Engine/lib/opus/silk/float/bwexpander_FLP.c b/Engine/lib/opus/silk/float/bwexpander_FLP.c deleted file mode 100644 index d55a4d79a..000000000 --- a/Engine/lib/opus/silk/float/bwexpander_FLP.c +++ /dev/null @@ -1,49 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FLP.h" - -/* Chirp (bw expand) LP AR filter */ -void silk_bwexpander_FLP( - silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */ - const opus_int d, /* I length of ar */ - const silk_float chirp /* I chirp factor (typically in range (0..1) ) */ -) -{ - opus_int i; - silk_float cfac = chirp; - - for( i = 0; i < d - 1; i++ ) { - ar[ i ] *= cfac; - cfac *= chirp; - } - ar[ d - 1 ] *= cfac; -} diff --git a/Engine/lib/opus/silk/float/corrMatrix_FLP.c b/Engine/lib/opus/silk/float/corrMatrix_FLP.c deleted file mode 100644 index eae6a1cfc..000000000 --- a/Engine/lib/opus/silk/float/corrMatrix_FLP.c +++ /dev/null @@ -1,93 +0,0 @@ -/*********************************************************************** -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" -#endif - -/********************************************************************** - * Correlation matrix computations for LS estimate. - **********************************************************************/ - -#include "main_FLP.h" - -/* Calculates correlation vector X'*t */ -void silk_corrVector_FLP( - const silk_float *x, /* I x vector [L+order-1] used to create X */ - const silk_float *t, /* I Target vector [L] */ - const opus_int L, /* I Length of vecors */ - const opus_int Order, /* I Max lag for correlation */ - silk_float *Xt /* O X'*t correlation vector [order] */ -) -{ - opus_int lag; - const silk_float *ptr1; - - ptr1 = &x[ Order - 1 ]; /* Points to first sample of column 0 of X: X[:,0] */ - for( lag = 0; lag < Order; lag++ ) { - /* Calculate X[:,lag]'*t */ - Xt[ lag ] = (silk_float)silk_inner_product_FLP( ptr1, t, L ); - ptr1--; /* Next column of X */ - } -} - -/* Calculates correlation matrix X'*X */ -void silk_corrMatrix_FLP( - const silk_float *x, /* I x vector [ L+order-1 ] used to create X */ - const opus_int L, /* I Length of vectors */ - const opus_int Order, /* I Max lag for correlation */ - silk_float *XX /* O X'*X correlation matrix [order x order] */ -) -{ - opus_int j, lag; - double energy; - const silk_float *ptr1, *ptr2; - - ptr1 = &x[ Order - 1 ]; /* First sample of column 0 of X */ - energy = silk_energy_FLP( ptr1, L ); /* X[:,0]'*X[:,0] */ - matrix_ptr( XX, 0, 0, Order ) = ( silk_float )energy; - for( j = 1; j < Order; j++ ) { - /* Calculate X[:,j]'*X[:,j] */ - energy += ptr1[ -j ] * ptr1[ -j ] - ptr1[ L - j ] * ptr1[ L - j ]; - matrix_ptr( XX, j, j, Order ) = ( silk_float )energy; - } - - ptr2 = &x[ Order - 2 ]; /* First sample of column 1 of X */ - for( lag = 1; lag < Order; lag++ ) { - /* Calculate X[:,0]'*X[:,lag] */ - energy = silk_inner_product_FLP( ptr1, ptr2, L ); - matrix_ptr( XX, lag, 0, Order ) = ( silk_float )energy; - matrix_ptr( XX, 0, lag, Order ) = ( silk_float )energy; - /* Calculate X[:,j]'*X[:,j + lag] */ - for( j = 1; j < ( Order - lag ); j++ ) { - energy += ptr1[ -j ] * ptr2[ -j ] - ptr1[ L - j ] * ptr2[ L - j ]; - matrix_ptr( XX, lag + j, j, Order ) = ( silk_float )energy; - matrix_ptr( XX, j, lag + j, Order ) = ( silk_float )energy; - } - ptr2--; /* Next column of X */ - } -} diff --git a/Engine/lib/opus/silk/float/encode_frame_FLP.c b/Engine/lib/opus/silk/float/encode_frame_FLP.c deleted file mode 100644 index b029c3f5c..000000000 --- a/Engine/lib/opus/silk/float/encode_frame_FLP.c +++ /dev/null @@ -1,435 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include -#include "main_FLP.h" -#include "tuning_parameters.h" - -/* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */ -static OPUS_INLINE void silk_LBRR_encode_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float xfw[], /* I Input signal */ - opus_int condCoding /* I The type of conditional coding used so far for this frame */ -); - -void silk_encode_do_VAD_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - opus_int activity /* I Decision of Opus voice activity detector */ -) -{ - const opus_int activity_threshold = SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ); - - /****************************/ - /* Voice Activity Detection */ - /****************************/ - silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.arch ); - /* If Opus VAD is inactive and Silk VAD is active: lower Silk VAD to just under the threshold */ - if( activity == VAD_NO_ACTIVITY && psEnc->sCmn.speech_activity_Q8 >= activity_threshold ) { - psEnc->sCmn.speech_activity_Q8 = activity_threshold - 1; - } - - /**************************************************/ - /* Convert speech activity into VAD and DTX flags */ - /**************************************************/ - if( psEnc->sCmn.speech_activity_Q8 < activity_threshold ) { - psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY; - psEnc->sCmn.noSpeechCounter++; - if( psEnc->sCmn.noSpeechCounter <= NB_SPEECH_FRAMES_BEFORE_DTX ) { - psEnc->sCmn.inDTX = 0; - } else if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX + NB_SPEECH_FRAMES_BEFORE_DTX ) { - psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX; - psEnc->sCmn.inDTX = 0; - } - psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 0; - } else { - psEnc->sCmn.noSpeechCounter = 0; - psEnc->sCmn.inDTX = 0; - psEnc->sCmn.indices.signalType = TYPE_UNVOICED; - psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 1; - } -} - -/****************/ -/* Encode frame */ -/****************/ -opus_int silk_encode_frame_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - opus_int32 *pnBytesOut, /* O Number of payload bytes; */ - ec_enc *psRangeEnc, /* I/O compressor data structure */ - opus_int condCoding, /* I The type of conditional coding to use */ - opus_int maxBits, /* I If > 0: maximum number of output bits */ - opus_int useCBR /* I Flag to force constant-bitrate operation */ -) -{ - silk_encoder_control_FLP sEncCtrl; - opus_int i, iter, maxIter, found_upper, found_lower, ret = 0; - silk_float *x_frame, *res_pitch_frame; - silk_float res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ]; - ec_enc sRangeEnc_copy, sRangeEnc_copy2; - silk_nsq_state sNSQ_copy, sNSQ_copy2; - opus_int32 seed_copy, nBits, nBits_lower, nBits_upper, gainMult_lower, gainMult_upper; - opus_int32 gainsID, gainsID_lower, gainsID_upper; - opus_int16 gainMult_Q8; - opus_int16 ec_prevLagIndex_copy; - opus_int ec_prevSignalType_copy; - opus_int8 LastGainIndex_copy2; - opus_int32 pGains_Q16[ MAX_NB_SUBFR ]; - opus_uint8 ec_buf_copy[ 1275 ]; - opus_int gain_lock[ MAX_NB_SUBFR ] = {0}; - opus_int16 best_gain_mult[ MAX_NB_SUBFR ]; - opus_int best_sum[ MAX_NB_SUBFR ]; - - /* This is totally unnecessary but many compilers (including gcc) are too dumb to realise it */ - LastGainIndex_copy2 = nBits_lower = nBits_upper = gainMult_lower = gainMult_upper = 0; - - psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3; - - /**************************************************************/ - /* Set up Input Pointers, and insert frame in input buffer */ - /**************************************************************/ - /* pointers aligned with start of frame to encode */ - x_frame = psEnc->x_buf + psEnc->sCmn.ltp_mem_length; /* start of frame to encode */ - res_pitch_frame = res_pitch + psEnc->sCmn.ltp_mem_length; /* start of pitch LPC residual frame */ - - /***************************************/ - /* Ensure smooth bandwidth transitions */ - /***************************************/ - silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length ); - - /*******************************************/ - /* Copy new frame to front of input buffer */ - /*******************************************/ - silk_short2float_array( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length ); - - /* Add tiny signal to avoid high CPU load from denormalized floating point numbers */ - for( i = 0; i < 8; i++ ) { - x_frame[ LA_SHAPE_MS * psEnc->sCmn.fs_kHz + i * ( psEnc->sCmn.frame_length >> 3 ) ] += ( 1 - ( i & 2 ) ) * 1e-6f; - } - - if( !psEnc->sCmn.prefillFlag ) { - /*****************************************/ - /* Find pitch lags, initial LPC analysis */ - /*****************************************/ - silk_find_pitch_lags_FLP( psEnc, &sEncCtrl, res_pitch, x_frame, psEnc->sCmn.arch ); - - /************************/ - /* Noise shape analysis */ - /************************/ - silk_noise_shape_analysis_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame ); - - /***************************************************/ - /* Find linear prediction coefficients (LPC + LTP) */ - /***************************************************/ - silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame, condCoding ); - - /****************************************/ - /* Process gains */ - /****************************************/ - silk_process_gains_FLP( psEnc, &sEncCtrl, condCoding ); - - /****************************************/ - /* Low Bitrate Redundant Encoding */ - /****************************************/ - silk_LBRR_encode_FLP( psEnc, &sEncCtrl, x_frame, condCoding ); - - /* Loop over quantizer and entroy coding to control bitrate */ - maxIter = 6; - gainMult_Q8 = SILK_FIX_CONST( 1, 8 ); - found_lower = 0; - found_upper = 0; - gainsID = silk_gains_ID( psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr ); - gainsID_lower = -1; - gainsID_upper = -1; - /* Copy part of the input state */ - silk_memcpy( &sRangeEnc_copy, psRangeEnc, sizeof( ec_enc ) ); - silk_memcpy( &sNSQ_copy, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); - seed_copy = psEnc->sCmn.indices.Seed; - ec_prevLagIndex_copy = psEnc->sCmn.ec_prevLagIndex; - ec_prevSignalType_copy = psEnc->sCmn.ec_prevSignalType; - for( iter = 0; ; iter++ ) { - if( gainsID == gainsID_lower ) { - nBits = nBits_lower; - } else if( gainsID == gainsID_upper ) { - nBits = nBits_upper; - } else { - /* Restore part of the input state */ - if( iter > 0 ) { - silk_memcpy( psRangeEnc, &sRangeEnc_copy, sizeof( ec_enc ) ); - silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy, sizeof( silk_nsq_state ) ); - psEnc->sCmn.indices.Seed = seed_copy; - psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy; - psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy; - } - - /*****************************************/ - /* Noise shaping quantization */ - /*****************************************/ - silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, x_frame ); - - if ( iter == maxIter && !found_lower ) { - silk_memcpy( &sRangeEnc_copy2, psRangeEnc, sizeof( ec_enc ) ); - } - - /****************************************/ - /* Encode Parameters */ - /****************************************/ - silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding ); - - /****************************************/ - /* Encode Excitation Signal */ - /****************************************/ - silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, - psEnc->sCmn.pulses, psEnc->sCmn.frame_length ); - - nBits = ec_tell( psRangeEnc ); - - /* If we still bust after the last iteration, do some damage control. */ - if ( iter == maxIter && !found_lower && nBits > maxBits ) { - silk_memcpy( psRangeEnc, &sRangeEnc_copy2, sizeof( ec_enc ) ); - - /* Keep gains the same as the last frame. */ - psEnc->sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev; - for ( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - psEnc->sCmn.indices.GainsIndices[ i ] = 4; - } - if (condCoding != CODE_CONDITIONALLY) { - psEnc->sCmn.indices.GainsIndices[ 0 ] = sEncCtrl.lastGainIndexPrev; - } - psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy; - psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy; - /* Clear all pulses. */ - for ( i = 0; i < psEnc->sCmn.frame_length; i++ ) { - psEnc->sCmn.pulses[ i ] = 0; - } - - silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding ); - - silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, - psEnc->sCmn.pulses, psEnc->sCmn.frame_length ); - - nBits = ec_tell( psRangeEnc ); - } - - if( useCBR == 0 && iter == 0 && nBits <= maxBits ) { - break; - } - } - - if( iter == maxIter ) { - if( found_lower && ( gainsID == gainsID_lower || nBits > maxBits ) ) { - /* Restore output state from earlier iteration that did meet the bitrate budget */ - silk_memcpy( psRangeEnc, &sRangeEnc_copy2, sizeof( ec_enc ) ); - celt_assert( sRangeEnc_copy2.offs <= 1275 ); - silk_memcpy( psRangeEnc->buf, ec_buf_copy, sRangeEnc_copy2.offs ); - silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy2, sizeof( silk_nsq_state ) ); - psEnc->sShape.LastGainIndex = LastGainIndex_copy2; - } - break; - } - - if( nBits > maxBits ) { - if( found_lower == 0 && iter >= 2 ) { - /* Adjust the quantizer's rate/distortion tradeoff and discard previous "upper" results */ - sEncCtrl.Lambda = silk_max_float(sEncCtrl.Lambda*1.5f, 1.5f); - /* Reducing dithering can help us hit the target. */ - psEnc->sCmn.indices.quantOffsetType = 0; - found_upper = 0; - gainsID_upper = -1; - } else { - found_upper = 1; - nBits_upper = nBits; - gainMult_upper = gainMult_Q8; - gainsID_upper = gainsID; - } - } else if( nBits < maxBits - 5 ) { - found_lower = 1; - nBits_lower = nBits; - gainMult_lower = gainMult_Q8; - if( gainsID != gainsID_lower ) { - gainsID_lower = gainsID; - /* Copy part of the output state */ - silk_memcpy( &sRangeEnc_copy2, psRangeEnc, sizeof( ec_enc ) ); - celt_assert( psRangeEnc->offs <= 1275 ); - silk_memcpy( ec_buf_copy, psRangeEnc->buf, psRangeEnc->offs ); - silk_memcpy( &sNSQ_copy2, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); - LastGainIndex_copy2 = psEnc->sShape.LastGainIndex; - } - } else { - /* Within 5 bits of budget: close enough */ - break; - } - - if ( !found_lower && nBits > maxBits ) { - int j; - for ( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - int sum=0; - for ( j = i*psEnc->sCmn.subfr_length; j < (i+1)*psEnc->sCmn.subfr_length; j++ ) { - sum += abs( psEnc->sCmn.pulses[j] ); - } - if ( iter == 0 || (sum < best_sum[i] && !gain_lock[i]) ) { - best_sum[i] = sum; - best_gain_mult[i] = gainMult_Q8; - } else { - gain_lock[i] = 1; - } - } - } - if( ( found_lower & found_upper ) == 0 ) { - /* Adjust gain according to high-rate rate/distortion curve */ - if( nBits > maxBits ) { - if (gainMult_Q8 < 16384) { - gainMult_Q8 *= 2; - } else { - gainMult_Q8 = 32767; - } - } else { - opus_int32 gain_factor_Q16; - gain_factor_Q16 = silk_log2lin( silk_LSHIFT( nBits - maxBits, 7 ) / psEnc->sCmn.frame_length + SILK_FIX_CONST( 16, 7 ) ); - gainMult_Q8 = silk_SMULWB( gain_factor_Q16, gainMult_Q8 ); - } - } else { - /* Adjust gain by interpolating */ - gainMult_Q8 = gainMult_lower + ( ( gainMult_upper - gainMult_lower ) * ( maxBits - nBits_lower ) ) / ( nBits_upper - nBits_lower ); - /* New gain multplier must be between 25% and 75% of old range (note that gainMult_upper < gainMult_lower) */ - if( gainMult_Q8 > silk_ADD_RSHIFT32( gainMult_lower, gainMult_upper - gainMult_lower, 2 ) ) { - gainMult_Q8 = silk_ADD_RSHIFT32( gainMult_lower, gainMult_upper - gainMult_lower, 2 ); - } else - if( gainMult_Q8 < silk_SUB_RSHIFT32( gainMult_upper, gainMult_upper - gainMult_lower, 2 ) ) { - gainMult_Q8 = silk_SUB_RSHIFT32( gainMult_upper, gainMult_upper - gainMult_lower, 2 ); - } - } - - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - opus_int16 tmp; - if ( gain_lock[i] ) { - tmp = best_gain_mult[i]; - } else { - tmp = gainMult_Q8; - } - pGains_Q16[ i ] = silk_LSHIFT_SAT32( silk_SMULWB( sEncCtrl.GainsUnq_Q16[ i ], tmp ), 8 ); - } - - /* Quantize gains */ - psEnc->sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev; - silk_gains_quant( psEnc->sCmn.indices.GainsIndices, pGains_Q16, - &psEnc->sShape.LastGainIndex, condCoding == CODE_CONDITIONALLY, psEnc->sCmn.nb_subfr ); - - /* Unique identifier of gains vector */ - gainsID = silk_gains_ID( psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr ); - - /* Overwrite unquantized gains with quantized gains and convert back to Q0 from Q16 */ - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - sEncCtrl.Gains[ i ] = pGains_Q16[ i ] / 65536.0f; - } - } - } - - /* Update input buffer */ - silk_memmove( psEnc->x_buf, &psEnc->x_buf[ psEnc->sCmn.frame_length ], - ( psEnc->sCmn.ltp_mem_length + LA_SHAPE_MS * psEnc->sCmn.fs_kHz ) * sizeof( silk_float ) ); - - /* Exit without entropy coding */ - if( psEnc->sCmn.prefillFlag ) { - /* No payload */ - *pnBytesOut = 0; - return ret; - } - - /* Parameters needed for next frame */ - psEnc->sCmn.prevLag = sEncCtrl.pitchL[ psEnc->sCmn.nb_subfr - 1 ]; - psEnc->sCmn.prevSignalType = psEnc->sCmn.indices.signalType; - - /****************************************/ - /* Finalize payload */ - /****************************************/ - psEnc->sCmn.first_frame_after_reset = 0; - /* Payload size */ - *pnBytesOut = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); - - return ret; -} - -/* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */ -static OPUS_INLINE void silk_LBRR_encode_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float xfw[], /* I Input signal */ - opus_int condCoding /* I The type of conditional coding used so far for this frame */ -) -{ - opus_int k; - opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; - silk_float TempGains[ MAX_NB_SUBFR ]; - SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesEncoded ]; - silk_nsq_state sNSQ_LBRR; - - /*******************************************/ - /* Control use of inband LBRR */ - /*******************************************/ - if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SILK_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) { - psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded ] = 1; - - /* Copy noise shaping quantizer state and quantization indices from regular encoding */ - silk_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); - silk_memcpy( psIndices_LBRR, &psEnc->sCmn.indices, sizeof( SideInfoIndices ) ); - - /* Save original gains */ - silk_memcpy( TempGains, psEncCtrl->Gains, psEnc->sCmn.nb_subfr * sizeof( silk_float ) ); - - if( psEnc->sCmn.nFramesEncoded == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded - 1 ] == 0 ) { - /* First frame in packet or previous frame not LBRR coded */ - psEnc->sCmn.LBRRprevLastGainIndex = psEnc->sShape.LastGainIndex; - - /* Increase Gains to get target LBRR rate */ - psIndices_LBRR->GainsIndices[ 0 ] += psEnc->sCmn.LBRR_GainIncreases; - psIndices_LBRR->GainsIndices[ 0 ] = silk_min_int( psIndices_LBRR->GainsIndices[ 0 ], N_LEVELS_QGAIN - 1 ); - } - - /* Decode to get gains in sync with decoder */ - silk_gains_dequant( Gains_Q16, psIndices_LBRR->GainsIndices, - &psEnc->sCmn.LBRRprevLastGainIndex, condCoding == CODE_CONDITIONALLY, psEnc->sCmn.nb_subfr ); - - /* Overwrite unquantized gains with quantized gains and convert back to Q0 from Q16 */ - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->Gains[ k ] = Gains_Q16[ k ] * ( 1.0f / 65536.0f ); - } - - /*****************************************/ - /* Noise shaping quantization */ - /*****************************************/ - silk_NSQ_wrapper_FLP( psEnc, psEncCtrl, psIndices_LBRR, &sNSQ_LBRR, - psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], xfw ); - - /* Restore original gains */ - silk_memcpy( psEncCtrl->Gains, TempGains, psEnc->sCmn.nb_subfr * sizeof( silk_float ) ); - } -} diff --git a/Engine/lib/opus/silk/float/energy_FLP.c b/Engine/lib/opus/silk/float/energy_FLP.c deleted file mode 100644 index 7bc7173c9..000000000 --- a/Engine/lib/opus/silk/float/energy_FLP.c +++ /dev/null @@ -1,59 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FLP.h" - -/* sum of squares of a silk_float array, with result as double */ -double silk_energy_FLP( - const silk_float *data, - opus_int dataSize -) -{ - opus_int i; - 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 ]; - } - - /* add any remaining products */ - for( ; i < dataSize; i++ ) { - result += data[ i ] * (double)data[ i ]; - } - - silk_assert( result >= 0.0 ); - return result; -} diff --git a/Engine/lib/opus/silk/float/find_LPC_FLP.c b/Engine/lib/opus/silk/float/find_LPC_FLP.c deleted file mode 100644 index fa3ffe7f8..000000000 --- a/Engine/lib/opus/silk/float/find_LPC_FLP.c +++ /dev/null @@ -1,104 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "define.h" -#include "main_FLP.h" -#include "tuning_parameters.h" - -/* LPC analysis */ -void silk_find_LPC_FLP( - silk_encoder_state *psEncC, /* I/O Encoder state */ - opus_int16 NLSF_Q15[], /* O NLSFs */ - const silk_float x[], /* I Input signal */ - const silk_float minInvGain /* I Inverse of max prediction gain */ -) -{ - opus_int k, subfr_length; - silk_float a[ MAX_LPC_ORDER ]; - - /* Used only for NLSF interpolation */ - silk_float res_nrg, res_nrg_2nd, res_nrg_interp; - opus_int16 NLSF0_Q15[ MAX_LPC_ORDER ]; - silk_float a_tmp[ MAX_LPC_ORDER ]; - silk_float LPC_res[ MAX_FRAME_LENGTH + MAX_NB_SUBFR * MAX_LPC_ORDER ]; - - subfr_length = psEncC->subfr_length + psEncC->predictLPCOrder; - - /* Default: No interpolation */ - psEncC->indices.NLSFInterpCoef_Q2 = 4; - - /* Burg AR analysis for the full frame */ - res_nrg = silk_burg_modified_FLP( a, x, minInvGain, subfr_length, psEncC->nb_subfr, psEncC->predictLPCOrder ); - - if( psEncC->useInterpolatedNLSFs && !psEncC->first_frame_after_reset && psEncC->nb_subfr == MAX_NB_SUBFR ) { - /* Optimal solution for last 10 ms; subtract residual energy here, as that's easier than */ - /* adding it to the residual energy of the first 10 ms in each iteration of the search below */ - res_nrg -= silk_burg_modified_FLP( a_tmp, x + ( MAX_NB_SUBFR / 2 ) * subfr_length, minInvGain, subfr_length, MAX_NB_SUBFR / 2, psEncC->predictLPCOrder ); - - /* Convert to NLSFs */ - silk_A2NLSF_FLP( NLSF_Q15, a_tmp, psEncC->predictLPCOrder ); - - /* Search over interpolation indices to find the one with lowest residual energy */ - res_nrg_2nd = silk_float_MAX; - for( k = 3; k >= 0; k-- ) { - /* Interpolate NLSFs for first half */ - silk_interpolate( NLSF0_Q15, psEncC->prev_NLSFq_Q15, NLSF_Q15, k, psEncC->predictLPCOrder ); - - /* Convert to LPC for residual energy evaluation */ - silk_NLSF2A_FLP( a_tmp, NLSF0_Q15, psEncC->predictLPCOrder, psEncC->arch ); - - /* Calculate residual energy with LSF interpolation */ - silk_LPC_analysis_filter_FLP( LPC_res, a_tmp, x, 2 * subfr_length, psEncC->predictLPCOrder ); - res_nrg_interp = (silk_float)( - silk_energy_FLP( LPC_res + psEncC->predictLPCOrder, subfr_length - psEncC->predictLPCOrder ) + - silk_energy_FLP( LPC_res + psEncC->predictLPCOrder + subfr_length, subfr_length - psEncC->predictLPCOrder ) ); - - /* Determine whether current interpolated NLSFs are best so far */ - if( res_nrg_interp < res_nrg ) { - /* Interpolation has lower residual energy */ - res_nrg = res_nrg_interp; - psEncC->indices.NLSFInterpCoef_Q2 = (opus_int8)k; - } else if( res_nrg_interp > res_nrg_2nd ) { - /* No reason to continue iterating - residual energies will continue to climb */ - break; - } - res_nrg_2nd = res_nrg_interp; - } - } - - if( psEncC->indices.NLSFInterpCoef_Q2 == 4 ) { - /* NLSF interpolation is currently inactive, calculate NLSFs from full frame AR coefficients */ - silk_A2NLSF_FLP( NLSF_Q15, a, psEncC->predictLPCOrder ); - } - - celt_assert( psEncC->indices.NLSFInterpCoef_Q2 == 4 || - ( psEncC->useInterpolatedNLSFs && !psEncC->first_frame_after_reset && psEncC->nb_subfr == MAX_NB_SUBFR ) ); -} diff --git a/Engine/lib/opus/silk/float/find_LTP_FLP.c b/Engine/lib/opus/silk/float/find_LTP_FLP.c deleted file mode 100644 index f97064930..000000000 --- a/Engine/lib/opus/silk/float/find_LTP_FLP.c +++ /dev/null @@ -1,64 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" -#include "tuning_parameters.h" - -void silk_find_LTP_FLP( - silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ - silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O Weight for LTP quantization */ - const silk_float r_ptr[], /* I LPC residual */ - const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr /* I number of subframes */ -) -{ - opus_int k; - silk_float *xX_ptr, *XX_ptr; - const silk_float *lag_ptr; - silk_float xx, temp; - - xX_ptr = xX; - XX_ptr = XX; - for( k = 0; k < nb_subfr; k++ ) { - lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 ); - silk_corrMatrix_FLP( lag_ptr, subfr_length, LTP_ORDER, XX_ptr ); - silk_corrVector_FLP( lag_ptr, r_ptr, subfr_length, LTP_ORDER, xX_ptr ); - xx = ( silk_float )silk_energy_FLP( r_ptr, subfr_length + LTP_ORDER ); - temp = 1.0f / silk_max( xx, LTP_CORR_INV_MAX * 0.5f * ( XX_ptr[ 0 ] + XX_ptr[ 24 ] ) + 1.0f ); - silk_scale_vector_FLP( XX_ptr, temp, LTP_ORDER * LTP_ORDER ); - silk_scale_vector_FLP( xX_ptr, temp, LTP_ORDER ); - - r_ptr += subfr_length; - XX_ptr += LTP_ORDER * LTP_ORDER; - xX_ptr += LTP_ORDER; - } -} diff --git a/Engine/lib/opus/silk/float/find_pitch_lags_FLP.c b/Engine/lib/opus/silk/float/find_pitch_lags_FLP.c deleted file mode 100644 index dedbcd283..000000000 --- a/Engine/lib/opus/silk/float/find_pitch_lags_FLP.c +++ /dev/null @@ -1,132 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include -#include "main_FLP.h" -#include "tuning_parameters.h" - -void silk_find_pitch_lags_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - silk_float res[], /* O Residual */ - const silk_float x[], /* I Speech signal */ - int arch /* I Run-time architecture */ -) -{ - opus_int buf_len; - silk_float thrhld, res_nrg; - const silk_float *x_buf_ptr, *x_buf; - silk_float auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ]; - silk_float A[ MAX_FIND_PITCH_LPC_ORDER ]; - silk_float refl_coef[ MAX_FIND_PITCH_LPC_ORDER ]; - silk_float Wsig[ FIND_PITCH_LPC_WIN_MAX ]; - silk_float *Wsig_ptr; - - /******************************************/ - /* Set up buffer lengths etc based on Fs */ - /******************************************/ - buf_len = psEnc->sCmn.la_pitch + psEnc->sCmn.frame_length + psEnc->sCmn.ltp_mem_length; - - /* Safety check */ - celt_assert( buf_len >= psEnc->sCmn.pitch_LPC_win_length ); - - x_buf = x - psEnc->sCmn.ltp_mem_length; - - /******************************************/ - /* Estimate LPC AR coeficients */ - /******************************************/ - - /* Calculate windowed signal */ - - /* First LA_LTP samples */ - x_buf_ptr = x_buf + buf_len - psEnc->sCmn.pitch_LPC_win_length; - Wsig_ptr = Wsig; - silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch ); - - /* Middle non-windowed samples */ - Wsig_ptr += psEnc->sCmn.la_pitch; - x_buf_ptr += psEnc->sCmn.la_pitch; - silk_memcpy( Wsig_ptr, x_buf_ptr, ( psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 ) ) * sizeof( silk_float ) ); - - /* Last LA_LTP samples */ - Wsig_ptr += psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 ); - x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 ); - silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch ); - - /* Calculate autocorrelation sequence */ - silk_autocorrelation_FLP( auto_corr, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 ); - - /* Add white noise, as a fraction of the energy */ - auto_corr[ 0 ] += auto_corr[ 0 ] * FIND_PITCH_WHITE_NOISE_FRACTION + 1; - - /* Calculate the reflection coefficients using Schur */ - res_nrg = silk_schur_FLP( refl_coef, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder ); - - /* Prediction gain */ - psEncCtrl->predGain = auto_corr[ 0 ] / silk_max_float( res_nrg, 1.0f ); - - /* Convert reflection coefficients to prediction coefficients */ - silk_k2a_FLP( A, refl_coef, psEnc->sCmn.pitchEstimationLPCOrder ); - - /* Bandwidth expansion */ - silk_bwexpander_FLP( A, psEnc->sCmn.pitchEstimationLPCOrder, FIND_PITCH_BANDWIDTH_EXPANSION ); - - /*****************************************/ - /* LPC analysis filtering */ - /*****************************************/ - silk_LPC_analysis_filter_FLP( res, A, x_buf, buf_len, psEnc->sCmn.pitchEstimationLPCOrder ); - - if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0 ) { - /* Threshold for pitch estimator */ - thrhld = 0.6f; - thrhld -= 0.004f * psEnc->sCmn.pitchEstimationLPCOrder; - thrhld -= 0.1f * psEnc->sCmn.speech_activity_Q8 * ( 1.0f / 256.0f ); - thrhld -= 0.15f * (psEnc->sCmn.prevSignalType >> 1); - thrhld -= 0.1f * psEnc->sCmn.input_tilt_Q15 * ( 1.0f / 32768.0f ); - - /*****************************************/ - /* Call Pitch estimator */ - /*****************************************/ - if( silk_pitch_analysis_core_FLP( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, - &psEnc->sCmn.indices.contourIndex, &psEnc->LTPCorr, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16 / 65536.0f, - thrhld, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr, arch ) == 0 ) - { - psEnc->sCmn.indices.signalType = TYPE_VOICED; - } else { - psEnc->sCmn.indices.signalType = TYPE_UNVOICED; - } - } else { - silk_memset( psEncCtrl->pitchL, 0, sizeof( psEncCtrl->pitchL ) ); - psEnc->sCmn.indices.lagIndex = 0; - psEnc->sCmn.indices.contourIndex = 0; - psEnc->LTPCorr = 0; - } -} diff --git a/Engine/lib/opus/silk/float/find_pred_coefs_FLP.c b/Engine/lib/opus/silk/float/find_pred_coefs_FLP.c deleted file mode 100644 index 6f7907889..000000000 --- a/Engine/lib/opus/silk/float/find_pred_coefs_FLP.c +++ /dev/null @@ -1,117 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" - -/* Find LPC and LTP coefficients */ -void silk_find_pred_coefs_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float res_pitch[], /* I Residual from pitch analysis */ - const silk_float x[], /* I Speech signal */ - opus_int condCoding /* I The type of conditional coding to use */ -) -{ - opus_int i; - silk_float XXLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ]; - silk_float xXLTP[ MAX_NB_SUBFR * LTP_ORDER ]; - silk_float invGains[ MAX_NB_SUBFR ]; - /* Set to NLSF_Q15 to zero so we don't copy junk to the state. */ - opus_int16 NLSF_Q15[ MAX_LPC_ORDER ]={0}; - const silk_float *x_ptr; - silk_float *x_pre_ptr, LPC_in_pre[ MAX_NB_SUBFR * MAX_LPC_ORDER + MAX_FRAME_LENGTH ]; - silk_float minInvGain; - - /* Weighting for weighted least squares */ - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - silk_assert( psEncCtrl->Gains[ i ] > 0.0f ); - invGains[ i ] = 1.0f / psEncCtrl->Gains[ i ]; - } - - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /**********/ - /* VOICED */ - /**********/ - celt_assert( psEnc->sCmn.ltp_mem_length - psEnc->sCmn.predictLPCOrder >= psEncCtrl->pitchL[ 0 ] + LTP_ORDER / 2 ); - - /* LTP analysis */ - silk_find_LTP_FLP( XXLTP, xXLTP, res_pitch, psEncCtrl->pitchL, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr ); - - /* Quantize LTP gain parameters */ - silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, - &psEnc->sCmn.sum_log_gain_Q7, &psEncCtrl->LTPredCodGain, XXLTP, xXLTP, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.arch ); - - /* Control LTP scaling */ - silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl, condCoding ); - - /* Create LTP residual */ - silk_LTP_analysis_filter_FLP( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef, - psEncCtrl->pitchL, invGains, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder ); - } else { - /************/ - /* UNVOICED */ - /************/ - /* Create signal with prepended subframes, scaled by inverse gains */ - x_ptr = x - psEnc->sCmn.predictLPCOrder; - x_pre_ptr = LPC_in_pre; - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - silk_scale_copy_vector_FLP( x_pre_ptr, x_ptr, invGains[ i ], - psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder ); - x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder; - x_ptr += psEnc->sCmn.subfr_length; - } - silk_memset( psEncCtrl->LTPCoef, 0, psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( silk_float ) ); - psEncCtrl->LTPredCodGain = 0.0f; - psEnc->sCmn.sum_log_gain_Q7 = 0; - } - - /* Limit on total predictive coding gain */ - if( psEnc->sCmn.first_frame_after_reset ) { - minInvGain = 1.0f / MAX_PREDICTION_POWER_GAIN_AFTER_RESET; - } else { - minInvGain = (silk_float)pow( 2, psEncCtrl->LTPredCodGain / 3 ) / MAX_PREDICTION_POWER_GAIN; - minInvGain /= 0.25f + 0.75f * psEncCtrl->coding_quality; - } - - /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */ - silk_find_LPC_FLP( &psEnc->sCmn, NLSF_Q15, LPC_in_pre, minInvGain ); - - /* Quantize LSFs */ - silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 ); - - /* Calculate residual energy using quantized LPC coefficients */ - silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef, psEncCtrl->Gains, - psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder ); - - /* Copy to prediction struct for use in next frame for interpolation */ - silk_memcpy( psEnc->sCmn.prev_NLSFq_Q15, NLSF_Q15, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) ); -} - diff --git a/Engine/lib/opus/silk/float/inner_product_FLP.c b/Engine/lib/opus/silk/float/inner_product_FLP.c deleted file mode 100644 index cdd39d24c..000000000 --- a/Engine/lib/opus/silk/float/inner_product_FLP.c +++ /dev/null @@ -1,59 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FLP.h" - -/* inner product of two silk_float arrays, with result as double */ -double silk_inner_product_FLP( - const silk_float *data1, - const silk_float *data2, - opus_int dataSize -) -{ - opus_int i; - 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 ]; - } - - /* add any remaining products */ - for( ; i < dataSize; i++ ) { - result += data1[ i ] * (double)data2[ i ]; - } - - return result; -} diff --git a/Engine/lib/opus/silk/float/k2a_FLP.c b/Engine/lib/opus/silk/float/k2a_FLP.c deleted file mode 100644 index 1448008db..000000000 --- a/Engine/lib/opus/silk/float/k2a_FLP.c +++ /dev/null @@ -1,54 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FLP.h" - -/* step up function, converts reflection coefficients to prediction coefficients */ -void silk_k2a_FLP( - silk_float *A, /* O prediction coefficients [order] */ - const silk_float *rc, /* I reflection coefficients [order] */ - opus_int32 order /* I prediction order */ -) -{ - opus_int k, n; - silk_float rck, tmp1, tmp2; - - for( k = 0; k < order; k++ ) { - rck = rc[ k ]; - for( n = 0; n < (k + 1) >> 1; n++ ) { - tmp1 = A[ n ]; - tmp2 = A[ k - n - 1 ]; - A[ n ] = tmp1 + tmp2 * rck; - A[ k - n - 1 ] = tmp2 + tmp1 * rck; - } - A[ k ] = -rck; - } -} diff --git a/Engine/lib/opus/silk/float/main_FLP.h b/Engine/lib/opus/silk/float/main_FLP.h deleted file mode 100644 index 5dc0ccf4a..000000000 --- a/Engine/lib/opus/silk/float/main_FLP.h +++ /dev/null @@ -1,286 +0,0 @@ -/*********************************************************************** -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 SILK_MAIN_FLP_H -#define SILK_MAIN_FLP_H - -#include "SigProc_FLP.h" -#include "SigProc_FIX.h" -#include "structs_FLP.h" -#include "main.h" -#include "define.h" -#include "debug.h" -#include "entenc.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define silk_encoder_state_Fxx silk_encoder_state_FLP -#define silk_encode_do_VAD_Fxx silk_encode_do_VAD_FLP -#define silk_encode_frame_Fxx silk_encode_frame_FLP - -/*********************/ -/* Encoder Functions */ -/*********************/ - -/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */ -void silk_HP_variable_cutoff( - silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */ -); - -/* Encoder main function */ -void silk_encode_do_VAD_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - opus_int activity /* I Decision of Opus voice activity detector */ -); - -/* Encoder main function */ -opus_int silk_encode_frame_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - opus_int32 *pnBytesOut, /* O Number of payload bytes; */ - ec_enc *psRangeEnc, /* I/O compressor data structure */ - opus_int condCoding, /* I The type of conditional coding to use */ - opus_int maxBits, /* I If > 0: maximum number of output bits */ - opus_int useCBR /* I Flag to force constant-bitrate operation */ -); - -/* Initializes the Silk encoder state */ -opus_int silk_init_encoder( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - int arch /* I Run-tim architecture */ -); - -/* Control the Silk encoder */ -opus_int silk_control_encoder( - silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */ - silk_EncControlStruct *encControl, /* I Control structure */ - const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ - const opus_int channelNb, /* I Channel number */ - const opus_int force_fs_kHz -); - -/**************************/ -/* Noise shaping analysis */ -/**************************/ -/* Compute noise shaping coefficients and initial gain values */ -void silk_noise_shape_analysis_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float *pitch_res, /* I LPC residual from pitch analysis */ - const silk_float *x /* I Input signal [frame_length + la_shape] */ -); - -/* Autocorrelations for a warped frequency axis */ -void silk_warped_autocorrelation_FLP( - silk_float *corr, /* O Result [order + 1] */ - const silk_float *input, /* I Input data to correlate */ - const silk_float warping, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ -); - -/* Calculation of LTP state scaling */ -void silk_LTP_scale_ctrl_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -/**********************************************/ -/* Prediction Analysis */ -/**********************************************/ -/* Find pitch lags */ -void silk_find_pitch_lags_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - silk_float res[], /* O Residual */ - const silk_float x[], /* I Speech signal */ - int arch /* I Run-time architecture */ -); - -/* Find LPC and LTP coefficients */ -void silk_find_pred_coefs_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float res_pitch[], /* I Residual from pitch analysis */ - const silk_float x[], /* I Speech signal */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -/* LPC analysis */ -void silk_find_LPC_FLP( - silk_encoder_state *psEncC, /* I/O Encoder state */ - opus_int16 NLSF_Q15[], /* O NLSFs */ - const silk_float x[], /* I Input signal */ - const silk_float minInvGain /* I Prediction gain from LTP (dB) */ -); - -/* LTP analysis */ -void silk_find_LTP_FLP( - silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ - silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O Weight for LTP quantization */ - const silk_float r_ptr[], /* I LPC residual */ - const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr /* I number of subframes */ -); - -void silk_LTP_analysis_filter_FLP( - silk_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */ - const silk_float *x, /* I Input signal, with preceding samples */ - const silk_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */ - const opus_int subfr_length, /* I Length of each subframe */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int pre_length /* I Preceding samples for each subframe */ -); - -/* Calculates residual energies of input subframes where all subframes have LPC_order */ -/* of preceding samples */ -void silk_residual_energy_FLP( - silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ - const silk_float x[], /* I Input signal */ - silk_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ - const silk_float gains[], /* I Quantization gains */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int LPC_order /* I LPC order */ -); - -/* 16th order LPC analysis filter */ -void silk_LPC_analysis_filter_FLP( - silk_float r_LPC[], /* O LPC residual signal */ - const silk_float PredCoef[], /* I LPC coefficients */ - const silk_float s[], /* I Input signal */ - const opus_int length, /* I Length of input signal */ - const opus_int Order /* I LPC order */ -); - -/* LTP tap quantizer */ -void silk_quant_LTP_gains_FLP( - silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ - opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */ - opus_int8 *periodicity_index, /* O Periodicity index */ - opus_int32 *sum_log_gain_Q7, /* I/O Cumulative max prediction gain */ - silk_float *pred_gain_dB, /* O LTP prediction gain */ - const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Correlation matrix */ - const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I Correlation vector */ - const opus_int subfr_len, /* I Number of samples per subframe */ - const opus_int nb_subfr, /* I Number of subframes */ - int arch /* I Run-time architecture */ -); - -/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */ - const silk_float *c, /* I Filter coefficients */ - silk_float *wXX, /* I/O Weighted correlation matrix, reg. out */ - const silk_float *wXx, /* I Weighted correlation vector */ - const silk_float wxx, /* I Weighted correlation value */ - const opus_int D /* I Dimension */ -); - -/* Processing of gains */ -void silk_process_gains_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -/******************/ -/* Linear Algebra */ -/******************/ -/* Calculates correlation matrix X'*X */ -void silk_corrMatrix_FLP( - const silk_float *x, /* I x vector [ L+order-1 ] used to create X */ - const opus_int L, /* I Length of vectors */ - const opus_int Order, /* I Max lag for correlation */ - silk_float *XX /* O X'*X correlation matrix [order x order] */ -); - -/* Calculates correlation vector X'*t */ -void silk_corrVector_FLP( - const silk_float *x, /* I x vector [L+order-1] used to create X */ - const silk_float *t, /* I Target vector [L] */ - const opus_int L, /* I Length of vecors */ - const opus_int Order, /* I Max lag for correlation */ - silk_float *Xt /* O X'*t correlation vector [order] */ -); - -/* Apply sine window to signal vector. */ -/* Window types: */ -/* 1 -> sine window from 0 to pi/2 */ -/* 2 -> sine window from pi/2 to pi */ -void silk_apply_sine_window_FLP( - silk_float px_win[], /* O Pointer to windowed signal */ - const silk_float px[], /* I Pointer to input signal */ - const opus_int win_type, /* I Selects a window type */ - const opus_int length /* I Window length, multiple of 4 */ -); - -/* Wrapper functions. Call flp / fix code */ - -/* Convert AR filter coefficients to NLSF parameters */ -void silk_A2NLSF_FLP( - opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */ - const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */ - const opus_int LPC_order /* I LPC order */ -); - -/* Convert NLSF parameters to AR prediction filter coefficients */ -void silk_NLSF2A_FLP( - silk_float *pAR, /* O LPC coefficients [ LPC_order ] */ - const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */ - const opus_int LPC_order, /* I LPC order */ - int arch /* I Run-time architecture */ -); - -/* Limit, stabilize, and quantize NLSFs */ -void silk_process_NLSFs_FLP( - silk_encoder_state *psEncC, /* I/O Encoder state */ - silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ - opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ - const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ -); - -/* Floating-point Silk NSQ wrapper */ -void silk_NSQ_wrapper_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - SideInfoIndices *psIndices, /* I/O Quantization indices */ - silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const silk_float x[] /* I Prefiltered input signal */ -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/silk/float/noise_shape_analysis_FLP.c b/Engine/lib/opus/silk/float/noise_shape_analysis_FLP.c deleted file mode 100644 index cb3d8a50b..000000000 --- a/Engine/lib/opus/silk/float/noise_shape_analysis_FLP.c +++ /dev/null @@ -1,350 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" -#include "tuning_parameters.h" - -/* Compute gain to make warped filter coefficients have a zero mean log frequency response on a */ -/* non-warped frequency scale. (So that it can be implemented with a minimum-phase monic filter.) */ -/* Note: A monic filter is one with the first coefficient equal to 1.0. In Silk we omit the first */ -/* coefficient in an array of coefficients, for monic filters. */ -static OPUS_INLINE silk_float warped_gain( - const silk_float *coefs, - silk_float lambda, - opus_int order -) { - opus_int i; - silk_float gain; - - lambda = -lambda; - gain = coefs[ order - 1 ]; - for( i = order - 2; i >= 0; i-- ) { - gain = lambda * gain + coefs[ i ]; - } - return (silk_float)( 1.0f / ( 1.0f - lambda * gain ) ); -} - -/* Convert warped filter coefficients to monic pseudo-warped coefficients and limit maximum */ -/* amplitude of monic warped coefficients by using bandwidth expansion on the true coefficients */ -static OPUS_INLINE void warped_true2monic_coefs( - silk_float *coefs, - silk_float lambda, - silk_float limit, - opus_int order -) { - opus_int i, iter, ind = 0; - silk_float tmp, maxabs, chirp, gain; - - /* Convert to monic coefficients */ - for( i = order - 1; i > 0; i-- ) { - coefs[ i - 1 ] -= lambda * coefs[ i ]; - } - gain = ( 1.0f - lambda * lambda ) / ( 1.0f + lambda * coefs[ 0 ] ); - for( i = 0; i < order; i++ ) { - coefs[ i ] *= gain; - } - - /* Limit */ - for( iter = 0; iter < 10; iter++ ) { - /* Find maximum absolute value */ - maxabs = -1.0f; - for( i = 0; i < order; i++ ) { - tmp = silk_abs_float( coefs[ i ] ); - if( tmp > maxabs ) { - maxabs = tmp; - ind = i; - } - } - if( maxabs <= limit ) { - /* Coefficients are within range - done */ - return; - } - - /* Convert back to true warped coefficients */ - for( i = 1; i < order; i++ ) { - coefs[ i - 1 ] += lambda * coefs[ i ]; - } - gain = 1.0f / gain; - for( i = 0; i < order; i++ ) { - coefs[ i ] *= gain; - } - - /* Apply bandwidth expansion */ - chirp = 0.99f - ( 0.8f + 0.1f * iter ) * ( maxabs - limit ) / ( maxabs * ( ind + 1 ) ); - silk_bwexpander_FLP( coefs, order, chirp ); - - /* Convert to monic warped coefficients */ - for( i = order - 1; i > 0; i-- ) { - coefs[ i - 1 ] -= lambda * coefs[ i ]; - } - gain = ( 1.0f - lambda * lambda ) / ( 1.0f + lambda * coefs[ 0 ] ); - for( i = 0; i < order; i++ ) { - coefs[ i ] *= gain; - } - } - silk_assert( 0 ); -} - -static OPUS_INLINE void limit_coefs( - silk_float *coefs, - silk_float limit, - opus_int order -) { - opus_int i, iter, ind = 0; - silk_float tmp, maxabs, chirp; - - for( iter = 0; iter < 10; iter++ ) { - /* Find maximum absolute value */ - maxabs = -1.0f; - for( i = 0; i < order; i++ ) { - tmp = silk_abs_float( coefs[ i ] ); - if( tmp > maxabs ) { - maxabs = tmp; - ind = i; - } - } - if( maxabs <= limit ) { - /* Coefficients are within range - done */ - return; - } - - /* Apply bandwidth expansion */ - chirp = 0.99f - ( 0.8f + 0.1f * iter ) * ( maxabs - limit ) / ( maxabs * ( ind + 1 ) ); - silk_bwexpander_FLP( coefs, order, chirp ); - } - silk_assert( 0 ); -} - -/* Compute noise shaping coefficients and initial gain values */ -void silk_noise_shape_analysis_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - const silk_float *pitch_res, /* I LPC residual from pitch analysis */ - const silk_float *x /* I Input signal [frame_length + la_shape] */ -) -{ - silk_shape_state_FLP *psShapeSt = &psEnc->sShape; - opus_int k, nSamples, nSegs; - silk_float SNR_adj_dB, HarmShapeGain, Tilt; - silk_float nrg, log_energy, log_energy_prev, energy_variation; - silk_float BWExp, gain_mult, gain_add, strength, b, warping; - silk_float x_windowed[ SHAPE_LPC_WIN_MAX ]; - silk_float auto_corr[ MAX_SHAPE_LPC_ORDER + 1 ]; - silk_float rc[ MAX_SHAPE_LPC_ORDER + 1 ]; - const silk_float *x_ptr, *pitch_res_ptr; - - /* Point to start of first LPC analysis block */ - x_ptr = x - psEnc->sCmn.la_shape; - - /****************/ - /* GAIN CONTROL */ - /****************/ - SNR_adj_dB = psEnc->sCmn.SNR_dB_Q7 * ( 1 / 128.0f ); - - /* Input quality is the average of the quality in the lowest two VAD bands */ - psEncCtrl->input_quality = 0.5f * ( psEnc->sCmn.input_quality_bands_Q15[ 0 ] + psEnc->sCmn.input_quality_bands_Q15[ 1 ] ) * ( 1.0f / 32768.0f ); - - /* Coding quality level, between 0.0 and 1.0 */ - psEncCtrl->coding_quality = silk_sigmoid( 0.25f * ( SNR_adj_dB - 20.0f ) ); - - if( psEnc->sCmn.useCBR == 0 ) { - /* Reduce coding SNR during low speech activity */ - b = 1.0f - psEnc->sCmn.speech_activity_Q8 * ( 1.0f / 256.0f ); - SNR_adj_dB -= BG_SNR_DECR_dB * psEncCtrl->coding_quality * ( 0.5f + 0.5f * psEncCtrl->input_quality ) * b * b; - } - - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Reduce gains for periodic signals */ - SNR_adj_dB += HARM_SNR_INCR_dB * psEnc->LTPCorr; - } else { - /* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */ - SNR_adj_dB += ( -0.4f * psEnc->sCmn.SNR_dB_Q7 * ( 1 / 128.0f ) + 6.0f ) * ( 1.0f - psEncCtrl->input_quality ); - } - - /*************************/ - /* SPARSENESS PROCESSING */ - /*************************/ - /* Set quantizer offset */ - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Initially set to 0; may be overruled in process_gains(..) */ - psEnc->sCmn.indices.quantOffsetType = 0; - } else { - /* Sparseness measure, based on relative fluctuations of energy per 2 milliseconds */ - nSamples = 2 * psEnc->sCmn.fs_kHz; - energy_variation = 0.0f; - log_energy_prev = 0.0f; - pitch_res_ptr = pitch_res; - nSegs = silk_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr ) / 2; - for( k = 0; k < nSegs; k++ ) { - nrg = ( silk_float )nSamples + ( silk_float )silk_energy_FLP( pitch_res_ptr, nSamples ); - log_energy = silk_log2( nrg ); - if( k > 0 ) { - energy_variation += silk_abs_float( log_energy - log_energy_prev ); - } - log_energy_prev = log_energy; - pitch_res_ptr += nSamples; - } - - /* Set quantization offset depending on sparseness measure */ - if( energy_variation > ENERGY_VARIATION_THRESHOLD_QNT_OFFSET * (nSegs-1) ) { - psEnc->sCmn.indices.quantOffsetType = 0; - } else { - psEnc->sCmn.indices.quantOffsetType = 1; - } - } - - /*******************************/ - /* Control bandwidth expansion */ - /*******************************/ - /* More BWE for signals with high prediction gain */ - strength = FIND_PITCH_WHITE_NOISE_FRACTION * psEncCtrl->predGain; /* between 0.0 and 1.0 */ - BWExp = BANDWIDTH_EXPANSION / ( 1.0f + strength * strength ); - - /* Slightly more warping in analysis will move quantization noise up in frequency, where it's better masked */ - warping = (silk_float)psEnc->sCmn.warping_Q16 / 65536.0f + 0.01f * psEncCtrl->coding_quality; - - /********************************************/ - /* Compute noise shaping AR coefs and gains */ - /********************************************/ - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - /* Apply window: sine slope followed by flat part followed by cosine slope */ - opus_int shift, slope_part, flat_part; - flat_part = psEnc->sCmn.fs_kHz * 3; - slope_part = ( psEnc->sCmn.shapeWinLength - flat_part ) / 2; - - silk_apply_sine_window_FLP( x_windowed, x_ptr, 1, slope_part ); - shift = slope_part; - silk_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(silk_float) ); - shift += flat_part; - silk_apply_sine_window_FLP( x_windowed + shift, x_ptr + shift, 2, slope_part ); - - /* Update pointer: next LPC analysis block */ - x_ptr += psEnc->sCmn.subfr_length; - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Calculate warped auto correlation */ - silk_warped_autocorrelation_FLP( auto_corr, x_windowed, warping, - psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder ); - } else { - /* Calculate regular auto correlation */ - silk_autocorrelation_FLP( auto_corr, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 ); - } - - /* Add white noise, as a fraction of energy */ - auto_corr[ 0 ] += auto_corr[ 0 ] * SHAPE_WHITE_NOISE_FRACTION + 1.0f; - - /* Convert correlations to prediction coefficients, and compute residual energy */ - nrg = silk_schur_FLP( rc, auto_corr, psEnc->sCmn.shapingLPCOrder ); - silk_k2a_FLP( &psEncCtrl->AR[ k * MAX_SHAPE_LPC_ORDER ], rc, psEnc->sCmn.shapingLPCOrder ); - psEncCtrl->Gains[ k ] = ( silk_float )sqrt( nrg ); - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Adjust gain for warping */ - psEncCtrl->Gains[ k ] *= warped_gain( &psEncCtrl->AR[ k * MAX_SHAPE_LPC_ORDER ], warping, psEnc->sCmn.shapingLPCOrder ); - } - - /* Bandwidth expansion for synthesis filter shaping */ - silk_bwexpander_FLP( &psEncCtrl->AR[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder, BWExp ); - - if( psEnc->sCmn.warping_Q16 > 0 ) { - /* Convert to monic warped prediction coefficients and limit absolute values */ - warped_true2monic_coefs( &psEncCtrl->AR[ k * MAX_SHAPE_LPC_ORDER ], warping, 3.999f, psEnc->sCmn.shapingLPCOrder ); - } else { - /* Limit absolute values */ - limit_coefs( &psEncCtrl->AR[ k * MAX_SHAPE_LPC_ORDER ], 3.999f, psEnc->sCmn.shapingLPCOrder ); - } - } - - /*****************/ - /* Gain tweaking */ - /*****************/ - /* Increase gains during low speech activity */ - gain_mult = (silk_float)pow( 2.0f, -0.16f * SNR_adj_dB ); - gain_add = (silk_float)pow( 2.0f, 0.16f * MIN_QGAIN_DB ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->Gains[ k ] *= gain_mult; - psEncCtrl->Gains[ k ] += gain_add; - } - - /************************************************/ - /* Control low-frequency shaping and noise tilt */ - /************************************************/ - /* Less low frequency shaping for noisy inputs */ - strength = LOW_FREQ_SHAPING * ( 1.0f + LOW_QUALITY_LOW_FREQ_SHAPING_DECR * ( psEnc->sCmn.input_quality_bands_Q15[ 0 ] * ( 1.0f / 32768.0f ) - 1.0f ) ); - strength *= psEnc->sCmn.speech_activity_Q8 * ( 1.0f / 256.0f ); - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */ - /*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/ - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - b = 0.2f / psEnc->sCmn.fs_kHz + 3.0f / psEncCtrl->pitchL[ k ]; - psEncCtrl->LF_MA_shp[ k ] = -1.0f + b; - psEncCtrl->LF_AR_shp[ k ] = 1.0f - b - b * strength; - } - Tilt = - HP_NOISE_COEF - - (1 - HP_NOISE_COEF) * HARM_HP_NOISE_COEF * psEnc->sCmn.speech_activity_Q8 * ( 1.0f / 256.0f ); - } else { - b = 1.3f / psEnc->sCmn.fs_kHz; - psEncCtrl->LF_MA_shp[ 0 ] = -1.0f + b; - psEncCtrl->LF_AR_shp[ 0 ] = 1.0f - b - b * strength * 0.6f; - for( k = 1; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->LF_MA_shp[ k ] = psEncCtrl->LF_MA_shp[ 0 ]; - psEncCtrl->LF_AR_shp[ k ] = psEncCtrl->LF_AR_shp[ 0 ]; - } - Tilt = -HP_NOISE_COEF; - } - - /****************************/ - /* HARMONIC SHAPING CONTROL */ - /****************************/ - if( USE_HARM_SHAPING && psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - /* Harmonic noise shaping */ - HarmShapeGain = HARMONIC_SHAPING; - - /* More harmonic noise shaping for high bitrates or noisy input */ - HarmShapeGain += HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING * - ( 1.0f - ( 1.0f - psEncCtrl->coding_quality ) * psEncCtrl->input_quality ); - - /* Less harmonic noise shaping for less periodic signals */ - HarmShapeGain *= ( silk_float )sqrt( psEnc->LTPCorr ); - } else { - HarmShapeGain = 0.0f; - } - - /*************************/ - /* Smooth over subframes */ - /*************************/ - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psShapeSt->HarmShapeGain_smth += SUBFR_SMTH_COEF * ( HarmShapeGain - psShapeSt->HarmShapeGain_smth ); - psEncCtrl->HarmShapeGain[ k ] = psShapeSt->HarmShapeGain_smth; - psShapeSt->Tilt_smth += SUBFR_SMTH_COEF * ( Tilt - psShapeSt->Tilt_smth ); - psEncCtrl->Tilt[ k ] = psShapeSt->Tilt_smth; - } -} diff --git a/Engine/lib/opus/silk/float/pitch_analysis_core_FLP.c b/Engine/lib/opus/silk/float/pitch_analysis_core_FLP.c deleted file mode 100644 index f351bc371..000000000 --- a/Engine/lib/opus/silk/float/pitch_analysis_core_FLP.c +++ /dev/null @@ -1,630 +0,0 @@ -/*********************************************************************** -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" -#endif - -/***************************************************************************** -* Pitch analyser function -******************************************************************************/ -#include "SigProc_FLP.h" -#include "SigProc_FIX.h" -#include "pitch_est_defines.h" -#include "pitch.h" - -#define SCRATCH_SIZE 22 - -/************************************************************/ -/* Internally used functions */ -/************************************************************/ -static void silk_P_Ana_calc_corr_st3( - silk_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */ - const silk_float frame[], /* I vector to correlate */ - opus_int start_lag, /* I start lag */ - opus_int sf_length, /* I sub frame length */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity, /* I Complexity setting */ - int arch /* I Run-time architecture */ -); - -static void silk_P_Ana_calc_energy_st3( - silk_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */ - const silk_float frame[], /* I vector to correlate */ - opus_int start_lag, /* I start lag */ - opus_int sf_length, /* I sub frame length */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity /* I Complexity setting */ -); - -/************************************************************/ -/* CORE PITCH ANALYSIS FUNCTION */ -/************************************************************/ -opus_int silk_pitch_analysis_core_FLP( /* O Voicing estimate: 0 voiced, 1 unvoiced */ - const silk_float *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ - opus_int *pitch_out, /* O Pitch lag values [nb_subfr] */ - opus_int16 *lagIndex, /* O Lag Index */ - opus_int8 *contourIndex, /* O Pitch contour Index */ - silk_float *LTPCorr, /* I/O Normalized correlation; input: value from previous frame */ - opus_int prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ - const silk_float search_thres1, /* I First stage threshold for lag candidates 0 - 1 */ - const silk_float search_thres2, /* I Final threshold for lag candidates 0 - 1 */ - const opus_int Fs_kHz, /* I sample frequency (kHz) */ - const opus_int complexity, /* I Complexity setting, 0-2, where 2 is highest */ - const opus_int nb_subfr, /* I Number of 5 ms subframes */ - int arch /* I Run-time architecture */ -) -{ - opus_int i, k, d, j; - silk_float frame_8kHz[ PE_MAX_FRAME_LENGTH_MS * 8 ]; - silk_float frame_4kHz[ PE_MAX_FRAME_LENGTH_MS * 4 ]; - opus_int16 frame_8_FIX[ PE_MAX_FRAME_LENGTH_MS * 8 ]; - opus_int16 frame_4_FIX[ PE_MAX_FRAME_LENGTH_MS * 4 ]; - opus_int32 filt_state[ 6 ]; - silk_float threshold, contour_bias; - silk_float C[ PE_MAX_NB_SUBFR][ (PE_MAX_LAG >> 1) + 5 ]; - opus_val32 xcorr[ PE_MAX_LAG_MS * 4 - PE_MIN_LAG_MS * 4 + 1 ]; - silk_float CC[ PE_NB_CBKS_STAGE2_EXT ]; - const silk_float *target_ptr, *basis_ptr; - double cross_corr, normalizer, energy, energy_tmp; - opus_int d_srch[ PE_D_SRCH_LENGTH ]; - opus_int16 d_comp[ (PE_MAX_LAG >> 1) + 5 ]; - opus_int length_d_srch, length_d_comp; - silk_float Cmax, CCmax, CCmax_b, CCmax_new_b, CCmax_new; - opus_int CBimax, CBimax_new, lag, start_lag, end_lag, lag_new; - opus_int cbk_size; - silk_float lag_log2, prevLag_log2, delta_lag_log2_sqr; - silk_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ]; - silk_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ]; - opus_int lag_counter; - opus_int frame_length, frame_length_8kHz, frame_length_4kHz; - opus_int sf_length, sf_length_8kHz, sf_length_4kHz; - opus_int min_lag, min_lag_8kHz, min_lag_4kHz; - opus_int max_lag, max_lag_8kHz, max_lag_4kHz; - opus_int nb_cbk_search; - const opus_int8 *Lag_CB_ptr; - - /* Check for valid sampling frequency */ - celt_assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 ); - - /* Check for valid complexity setting */ - celt_assert( complexity >= SILK_PE_MIN_COMPLEX ); - celt_assert( complexity <= SILK_PE_MAX_COMPLEX ); - - silk_assert( search_thres1 >= 0.0f && search_thres1 <= 1.0f ); - silk_assert( search_thres2 >= 0.0f && search_thres2 <= 1.0f ); - - /* Set up frame lengths max / min lag for the sampling frequency */ - frame_length = ( PE_LTP_MEM_LENGTH_MS + nb_subfr * PE_SUBFR_LENGTH_MS ) * Fs_kHz; - frame_length_4kHz = ( PE_LTP_MEM_LENGTH_MS + nb_subfr * PE_SUBFR_LENGTH_MS ) * 4; - frame_length_8kHz = ( PE_LTP_MEM_LENGTH_MS + nb_subfr * PE_SUBFR_LENGTH_MS ) * 8; - sf_length = PE_SUBFR_LENGTH_MS * Fs_kHz; - sf_length_4kHz = PE_SUBFR_LENGTH_MS * 4; - sf_length_8kHz = PE_SUBFR_LENGTH_MS * 8; - min_lag = PE_MIN_LAG_MS * Fs_kHz; - min_lag_4kHz = PE_MIN_LAG_MS * 4; - min_lag_8kHz = PE_MIN_LAG_MS * 8; - max_lag = PE_MAX_LAG_MS * Fs_kHz - 1; - max_lag_4kHz = PE_MAX_LAG_MS * 4; - max_lag_8kHz = PE_MAX_LAG_MS * 8 - 1; - - /* Resample from input sampled at Fs_kHz to 8 kHz */ - if( Fs_kHz == 16 ) { - /* Resample to 16 -> 8 khz */ - opus_int16 frame_16_FIX[ 16 * PE_MAX_FRAME_LENGTH_MS ]; - silk_float2short_array( frame_16_FIX, frame, frame_length ); - silk_memset( filt_state, 0, 2 * sizeof( opus_int32 ) ); - silk_resampler_down2( filt_state, frame_8_FIX, frame_16_FIX, frame_length ); - silk_short2float_array( frame_8kHz, frame_8_FIX, frame_length_8kHz ); - } else if( Fs_kHz == 12 ) { - /* Resample to 12 -> 8 khz */ - opus_int16 frame_12_FIX[ 12 * PE_MAX_FRAME_LENGTH_MS ]; - silk_float2short_array( frame_12_FIX, frame, frame_length ); - silk_memset( filt_state, 0, 6 * sizeof( opus_int32 ) ); - silk_resampler_down2_3( filt_state, frame_8_FIX, frame_12_FIX, frame_length ); - silk_short2float_array( frame_8kHz, frame_8_FIX, frame_length_8kHz ); - } else { - celt_assert( Fs_kHz == 8 ); - silk_float2short_array( frame_8_FIX, frame, frame_length_8kHz ); - } - - /* Decimate again to 4 kHz */ - silk_memset( filt_state, 0, 2 * sizeof( opus_int32 ) ); - silk_resampler_down2( filt_state, frame_4_FIX, frame_8_FIX, frame_length_8kHz ); - silk_short2float_array( frame_4kHz, frame_4_FIX, frame_length_4kHz ); - - /* Low-pass filter */ - for( i = frame_length_4kHz - 1; i > 0; i-- ) { - frame_4kHz[ i ] = silk_ADD_SAT16( frame_4kHz[ i ], frame_4kHz[ i - 1 ] ); - } - - /****************************************************************************** - * FIRST STAGE, operating in 4 khz - ******************************************************************************/ - silk_memset(C, 0, sizeof(silk_float) * nb_subfr * ((PE_MAX_LAG >> 1) + 5)); - target_ptr = &frame_4kHz[ silk_LSHIFT( sf_length_4kHz, 2 ) ]; - for( k = 0; k < nb_subfr >> 1; k++ ) { - /* Check that we are within range of the array */ - celt_assert( target_ptr >= frame_4kHz ); - celt_assert( target_ptr + sf_length_8kHz <= frame_4kHz + frame_length_4kHz ); - - basis_ptr = target_ptr - min_lag_4kHz; - - /* Check that we are within range of the array */ - celt_assert( basis_ptr >= frame_4kHz ); - celt_assert( basis_ptr + sf_length_8kHz <= frame_4kHz + frame_length_4kHz ); - - celt_pitch_xcorr( target_ptr, target_ptr-max_lag_4kHz, xcorr, sf_length_8kHz, max_lag_4kHz - min_lag_4kHz + 1, arch ); - - /* Calculate first vector products before loop */ - cross_corr = xcorr[ max_lag_4kHz - min_lag_4kHz ]; - normalizer = silk_energy_FLP( target_ptr, sf_length_8kHz ) + - silk_energy_FLP( basis_ptr, sf_length_8kHz ) + - sf_length_8kHz * 4000.0f; - - C[ 0 ][ min_lag_4kHz ] += (silk_float)( 2 * cross_corr / normalizer ); - - /* From now on normalizer is computed recursively */ - for( d = min_lag_4kHz + 1; d <= max_lag_4kHz; d++ ) { - basis_ptr--; - - /* Check that we are within range of the array */ - silk_assert( basis_ptr >= frame_4kHz ); - silk_assert( basis_ptr + sf_length_8kHz <= frame_4kHz + frame_length_4kHz ); - - cross_corr = xcorr[ max_lag_4kHz - d ]; - - /* Add contribution of new sample and remove contribution from oldest sample */ - normalizer += - basis_ptr[ 0 ] * (double)basis_ptr[ 0 ] - - basis_ptr[ sf_length_8kHz ] * (double)basis_ptr[ sf_length_8kHz ]; - C[ 0 ][ d ] += (silk_float)( 2 * cross_corr / normalizer ); - } - /* Update target pointer */ - target_ptr += sf_length_8kHz; - } - - /* Apply short-lag bias */ - for( i = max_lag_4kHz; i >= min_lag_4kHz; i-- ) { - C[ 0 ][ i ] -= C[ 0 ][ i ] * i / 4096.0f; - } - - /* Sort */ - length_d_srch = 4 + 2 * complexity; - celt_assert( 3 * length_d_srch <= PE_D_SRCH_LENGTH ); - silk_insertion_sort_decreasing_FLP( &C[ 0 ][ min_lag_4kHz ], d_srch, max_lag_4kHz - min_lag_4kHz + 1, length_d_srch ); - - /* Escape if correlation is very low already here */ - Cmax = C[ 0 ][ min_lag_4kHz ]; - if( Cmax < 0.2f ) { - silk_memset( pitch_out, 0, nb_subfr * sizeof( opus_int ) ); - *LTPCorr = 0.0f; - *lagIndex = 0; - *contourIndex = 0; - return 1; - } - - threshold = search_thres1 * Cmax; - for( i = 0; i < length_d_srch; i++ ) { - /* Convert to 8 kHz indices for the sorted correlation that exceeds the threshold */ - if( C[ 0 ][ min_lag_4kHz + i ] > threshold ) { - d_srch[ i ] = silk_LSHIFT( d_srch[ i ] + min_lag_4kHz, 1 ); - } else { - length_d_srch = i; - break; - } - } - celt_assert( length_d_srch > 0 ); - - for( i = min_lag_8kHz - 5; i < max_lag_8kHz + 5; i++ ) { - d_comp[ i ] = 0; - } - for( i = 0; i < length_d_srch; i++ ) { - d_comp[ d_srch[ i ] ] = 1; - } - - /* Convolution */ - for( i = max_lag_8kHz + 3; i >= min_lag_8kHz; i-- ) { - d_comp[ i ] += d_comp[ i - 1 ] + d_comp[ i - 2 ]; - } - - length_d_srch = 0; - for( i = min_lag_8kHz; i < max_lag_8kHz + 1; i++ ) { - if( d_comp[ i + 1 ] > 0 ) { - d_srch[ length_d_srch ] = i; - length_d_srch++; - } - } - - /* Convolution */ - for( i = max_lag_8kHz + 3; i >= min_lag_8kHz; i-- ) { - d_comp[ i ] += d_comp[ i - 1 ] + d_comp[ i - 2 ] + d_comp[ i - 3 ]; - } - - length_d_comp = 0; - for( i = min_lag_8kHz; i < max_lag_8kHz + 4; i++ ) { - if( d_comp[ i ] > 0 ) { - d_comp[ length_d_comp ] = (opus_int16)( i - 2 ); - length_d_comp++; - } - } - - /********************************************************************************** - ** SECOND STAGE, operating at 8 kHz, on lag sections with high correlation - *************************************************************************************/ - /********************************************************************************* - * Find energy of each subframe projected onto its history, for a range of delays - *********************************************************************************/ - silk_memset( C, 0, PE_MAX_NB_SUBFR*((PE_MAX_LAG >> 1) + 5) * sizeof(silk_float)); - - if( Fs_kHz == 8 ) { - target_ptr = &frame[ PE_LTP_MEM_LENGTH_MS * 8 ]; - } else { - target_ptr = &frame_8kHz[ PE_LTP_MEM_LENGTH_MS * 8 ]; - } - for( k = 0; k < nb_subfr; k++ ) { - energy_tmp = silk_energy_FLP( target_ptr, sf_length_8kHz ) + 1.0; - for( j = 0; j < length_d_comp; j++ ) { - d = d_comp[ j ]; - basis_ptr = target_ptr - d; - cross_corr = silk_inner_product_FLP( basis_ptr, target_ptr, sf_length_8kHz ); - if( cross_corr > 0.0f ) { - energy = silk_energy_FLP( basis_ptr, sf_length_8kHz ); - C[ k ][ d ] = (silk_float)( 2 * cross_corr / ( energy + energy_tmp ) ); - } else { - C[ k ][ d ] = 0.0f; - } - } - target_ptr += sf_length_8kHz; - } - - /* search over lag range and lags codebook */ - /* scale factor for lag codebook, as a function of center lag */ - - CCmax = 0.0f; /* This value doesn't matter */ - CCmax_b = -1000.0f; - - CBimax = 0; /* To avoid returning undefined lag values */ - lag = -1; /* To check if lag with strong enough correlation has been found */ - - if( prevLag > 0 ) { - if( Fs_kHz == 12 ) { - prevLag = silk_LSHIFT( prevLag, 1 ) / 3; - } else if( Fs_kHz == 16 ) { - prevLag = silk_RSHIFT( prevLag, 1 ); - } - prevLag_log2 = silk_log2( (silk_float)prevLag ); - } else { - prevLag_log2 = 0; - } - - /* Set up stage 2 codebook based on number of subframes */ - if( nb_subfr == PE_MAX_NB_SUBFR ) { - cbk_size = PE_NB_CBKS_STAGE2_EXT; - Lag_CB_ptr = &silk_CB_lags_stage2[ 0 ][ 0 ]; - if( Fs_kHz == 8 && complexity > SILK_PE_MIN_COMPLEX ) { - /* If input is 8 khz use a larger codebook here because it is last stage */ - nb_cbk_search = PE_NB_CBKS_STAGE2_EXT; - } else { - nb_cbk_search = PE_NB_CBKS_STAGE2; - } - } else { - cbk_size = PE_NB_CBKS_STAGE2_10MS; - Lag_CB_ptr = &silk_CB_lags_stage2_10_ms[ 0 ][ 0 ]; - nb_cbk_search = PE_NB_CBKS_STAGE2_10MS; - } - - for( k = 0; k < length_d_srch; k++ ) { - d = d_srch[ k ]; - for( j = 0; j < nb_cbk_search; j++ ) { - CC[j] = 0.0f; - for( i = 0; i < nb_subfr; i++ ) { - /* Try all codebooks */ - CC[ j ] += C[ i ][ d + matrix_ptr( Lag_CB_ptr, i, j, cbk_size )]; - } - } - /* Find best codebook */ - CCmax_new = -1000.0f; - CBimax_new = 0; - for( i = 0; i < nb_cbk_search; i++ ) { - if( CC[ i ] > CCmax_new ) { - CCmax_new = CC[ i ]; - CBimax_new = i; - } - } - - /* Bias towards shorter lags */ - lag_log2 = silk_log2( (silk_float)d ); - CCmax_new_b = CCmax_new - PE_SHORTLAG_BIAS * nb_subfr * lag_log2; - - /* Bias towards previous lag */ - if( prevLag > 0 ) { - delta_lag_log2_sqr = lag_log2 - prevLag_log2; - delta_lag_log2_sqr *= delta_lag_log2_sqr; - CCmax_new_b -= PE_PREVLAG_BIAS * nb_subfr * (*LTPCorr) * delta_lag_log2_sqr / ( delta_lag_log2_sqr + 0.5f ); - } - - if( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */ - CCmax_new > nb_subfr * search_thres2 /* Correlation needs to be high enough to be voiced */ - ) { - CCmax_b = CCmax_new_b; - CCmax = CCmax_new; - lag = d; - CBimax = CBimax_new; - } - } - - if( lag == -1 ) { - /* No suitable candidate found */ - silk_memset( pitch_out, 0, PE_MAX_NB_SUBFR * sizeof(opus_int) ); - *LTPCorr = 0.0f; - *lagIndex = 0; - *contourIndex = 0; - return 1; - } - - /* Output normalized correlation */ - *LTPCorr = (silk_float)( CCmax / nb_subfr ); - silk_assert( *LTPCorr >= 0.0f ); - - if( Fs_kHz > 8 ) { - /* Search in original signal */ - - /* Compensate for decimation */ - silk_assert( lag == silk_SAT16( lag ) ); - if( Fs_kHz == 12 ) { - lag = silk_RSHIFT_ROUND( silk_SMULBB( lag, 3 ), 1 ); - } else { /* Fs_kHz == 16 */ - lag = silk_LSHIFT( lag, 1 ); - } - - lag = silk_LIMIT_int( lag, min_lag, max_lag ); - start_lag = silk_max_int( lag - 2, min_lag ); - end_lag = silk_min_int( lag + 2, max_lag ); - lag_new = lag; /* to avoid undefined lag */ - CBimax = 0; /* to avoid undefined lag */ - - CCmax = -1000.0f; - - /* Calculate the correlations and energies needed in stage 3 */ - silk_P_Ana_calc_corr_st3( cross_corr_st3, frame, start_lag, sf_length, nb_subfr, complexity, arch ); - silk_P_Ana_calc_energy_st3( energies_st3, frame, start_lag, sf_length, nb_subfr, complexity ); - - lag_counter = 0; - silk_assert( lag == silk_SAT16( lag ) ); - contour_bias = PE_FLATCONTOUR_BIAS / lag; - - /* Set up cbk parameters according to complexity setting and frame length */ - if( nb_subfr == PE_MAX_NB_SUBFR ) { - nb_cbk_search = (opus_int)silk_nb_cbk_searchs_stage3[ complexity ]; - cbk_size = PE_NB_CBKS_STAGE3_MAX; - Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; - } else { - nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; - cbk_size = PE_NB_CBKS_STAGE3_10MS; - Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; - } - - target_ptr = &frame[ PE_LTP_MEM_LENGTH_MS * Fs_kHz ]; - energy_tmp = silk_energy_FLP( target_ptr, nb_subfr * sf_length ) + 1.0; - for( d = start_lag; d <= end_lag; d++ ) { - for( j = 0; j < nb_cbk_search; j++ ) { - cross_corr = 0.0; - energy = energy_tmp; - for( k = 0; k < nb_subfr; k++ ) { - cross_corr += cross_corr_st3[ k ][ j ][ lag_counter ]; - energy += energies_st3[ k ][ j ][ lag_counter ]; - } - if( cross_corr > 0.0 ) { - CCmax_new = (silk_float)( 2 * cross_corr / energy ); - /* Reduce depending on flatness of contour */ - CCmax_new *= 1.0f - contour_bias * j; - } else { - CCmax_new = 0.0f; - } - - if( CCmax_new > CCmax && ( d + (opus_int)silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag ) { - CCmax = CCmax_new; - lag_new = d; - CBimax = j; - } - } - lag_counter++; - } - - for( k = 0; k < nb_subfr; k++ ) { - pitch_out[ k ] = lag_new + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size ); - pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag, PE_MAX_LAG_MS * Fs_kHz ); - } - *lagIndex = (opus_int16)( lag_new - min_lag ); - *contourIndex = (opus_int8)CBimax; - } else { /* Fs_kHz == 8 */ - /* Save Lags */ - for( k = 0; k < nb_subfr; k++ ) { - pitch_out[ k ] = lag + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size ); - pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag_8kHz, PE_MAX_LAG_MS * 8 ); - } - *lagIndex = (opus_int16)( lag - min_lag_8kHz ); - *contourIndex = (opus_int8)CBimax; - } - celt_assert( *lagIndex >= 0 ); - /* return as voiced */ - return 0; -} - -/*********************************************************************** - * Calculates the correlations used in stage 3 search. In order to cover - * the whole lag codebook for all the searched offset lags (lag +- 2), - * the following correlations are needed in each sub frame: - * - * sf1: lag range [-8,...,7] total 16 correlations - * sf2: lag range [-4,...,4] total 9 correlations - * sf3: lag range [-3,....4] total 8 correltions - * sf4: lag range [-6,....8] total 15 correlations - * - * In total 48 correlations. The direct implementation computed in worst - * case 4*12*5 = 240 correlations, but more likely around 120. - ***********************************************************************/ -static void silk_P_Ana_calc_corr_st3( - silk_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */ - const silk_float frame[], /* I vector to correlate */ - opus_int start_lag, /* I start lag */ - opus_int sf_length, /* I sub frame length */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity, /* I Complexity setting */ - int arch /* I Run-time architecture */ -) -{ - const silk_float *target_ptr; - opus_int i, j, k, lag_counter, lag_low, lag_high; - opus_int nb_cbk_search, delta, idx, cbk_size; - silk_float scratch_mem[ SCRATCH_SIZE ]; - opus_val32 xcorr[ SCRATCH_SIZE ]; - const opus_int8 *Lag_range_ptr, *Lag_CB_ptr; - - celt_assert( complexity >= SILK_PE_MIN_COMPLEX ); - celt_assert( complexity <= SILK_PE_MAX_COMPLEX ); - - if( nb_subfr == PE_MAX_NB_SUBFR ) { - Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; - Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; - nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; - cbk_size = PE_NB_CBKS_STAGE3_MAX; - } else { - celt_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1); - Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; - Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; - nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; - cbk_size = PE_NB_CBKS_STAGE3_10MS; - } - - target_ptr = &frame[ silk_LSHIFT( sf_length, 2 ) ]; /* Pointer to middle of frame */ - for( k = 0; k < nb_subfr; k++ ) { - lag_counter = 0; - - /* Calculate the correlations for each subframe */ - lag_low = matrix_ptr( Lag_range_ptr, k, 0, 2 ); - lag_high = matrix_ptr( Lag_range_ptr, k, 1, 2 ); - silk_assert(lag_high-lag_low+1 <= SCRATCH_SIZE); - celt_pitch_xcorr( target_ptr, target_ptr - start_lag - lag_high, xcorr, sf_length, lag_high - lag_low + 1, arch ); - for( j = lag_low; j <= lag_high; j++ ) { - silk_assert( lag_counter < SCRATCH_SIZE ); - scratch_mem[ lag_counter ] = xcorr[ lag_high - j ]; - lag_counter++; - } - - delta = matrix_ptr( Lag_range_ptr, k, 0, 2 ); - for( i = 0; i < nb_cbk_search; i++ ) { - /* Fill out the 3 dim array that stores the correlations for */ - /* each code_book vector for each start lag */ - idx = matrix_ptr( Lag_CB_ptr, k, i, cbk_size ) - delta; - for( j = 0; j < PE_NB_STAGE3_LAGS; j++ ) { - silk_assert( idx + j < SCRATCH_SIZE ); - silk_assert( idx + j < lag_counter ); - cross_corr_st3[ k ][ i ][ j ] = scratch_mem[ idx + j ]; - } - } - target_ptr += sf_length; - } -} - -/********************************************************************/ -/* Calculate the energies for first two subframes. The energies are */ -/* calculated recursively. */ -/********************************************************************/ -static void silk_P_Ana_calc_energy_st3( - silk_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */ - const silk_float frame[], /* I vector to correlate */ - opus_int start_lag, /* I start lag */ - opus_int sf_length, /* I sub frame length */ - opus_int nb_subfr, /* I number of subframes */ - opus_int complexity /* I Complexity setting */ -) -{ - const silk_float *target_ptr, *basis_ptr; - double energy; - opus_int k, i, j, lag_counter; - opus_int nb_cbk_search, delta, idx, cbk_size, lag_diff; - silk_float scratch_mem[ SCRATCH_SIZE ]; - const opus_int8 *Lag_range_ptr, *Lag_CB_ptr; - - celt_assert( complexity >= SILK_PE_MIN_COMPLEX ); - celt_assert( complexity <= SILK_PE_MAX_COMPLEX ); - - if( nb_subfr == PE_MAX_NB_SUBFR ) { - Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; - Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; - nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; - cbk_size = PE_NB_CBKS_STAGE3_MAX; - } else { - celt_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1); - Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; - Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; - nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; - cbk_size = PE_NB_CBKS_STAGE3_10MS; - } - - target_ptr = &frame[ silk_LSHIFT( sf_length, 2 ) ]; - for( k = 0; k < nb_subfr; k++ ) { - lag_counter = 0; - - /* Calculate the energy for first lag */ - basis_ptr = target_ptr - ( start_lag + matrix_ptr( Lag_range_ptr, k, 0, 2 ) ); - energy = silk_energy_FLP( basis_ptr, sf_length ) + 1e-3; - silk_assert( energy >= 0.0 ); - scratch_mem[lag_counter] = (silk_float)energy; - lag_counter++; - - lag_diff = ( matrix_ptr( Lag_range_ptr, k, 1, 2 ) - matrix_ptr( Lag_range_ptr, k, 0, 2 ) + 1 ); - for( i = 1; i < lag_diff; i++ ) { - /* remove part outside new window */ - energy -= basis_ptr[sf_length - i] * (double)basis_ptr[sf_length - i]; - silk_assert( energy >= 0.0 ); - - /* add part that comes into window */ - energy += basis_ptr[ -i ] * (double)basis_ptr[ -i ]; - silk_assert( energy >= 0.0 ); - silk_assert( lag_counter < SCRATCH_SIZE ); - scratch_mem[lag_counter] = (silk_float)energy; - lag_counter++; - } - - delta = matrix_ptr( Lag_range_ptr, k, 0, 2 ); - for( i = 0; i < nb_cbk_search; i++ ) { - /* Fill out the 3 dim array that stores the correlations for */ - /* each code_book vector for each start lag */ - idx = matrix_ptr( Lag_CB_ptr, k, i, cbk_size ) - delta; - for( j = 0; j < PE_NB_STAGE3_LAGS; j++ ) { - silk_assert( idx + j < SCRATCH_SIZE ); - silk_assert( idx + j < lag_counter ); - energies_st3[ k ][ i ][ j ] = scratch_mem[ idx + j ]; - silk_assert( energies_st3[ k ][ i ][ j ] >= 0.0f ); - } - } - target_ptr += sf_length; - } -} diff --git a/Engine/lib/opus/silk/float/process_gains_FLP.c b/Engine/lib/opus/silk/float/process_gains_FLP.c deleted file mode 100644 index c0da0dae4..000000000 --- a/Engine/lib/opus/silk/float/process_gains_FLP.c +++ /dev/null @@ -1,103 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" -#include "tuning_parameters.h" - -/* Processing of gains */ -void silk_process_gains_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - opus_int condCoding /* I The type of conditional coding to use */ -) -{ - silk_shape_state_FLP *psShapeSt = &psEnc->sShape; - opus_int k; - opus_int32 pGains_Q16[ MAX_NB_SUBFR ]; - silk_float s, InvMaxSqrVal, gain, quant_offset; - - /* Gain reduction when LTP coding gain is high */ - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - s = 1.0f - 0.5f * silk_sigmoid( 0.25f * ( psEncCtrl->LTPredCodGain - 12.0f ) ); - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->Gains[ k ] *= s; - } - } - - /* Limit the quantized signal */ - InvMaxSqrVal = ( silk_float )( pow( 2.0f, 0.33f * ( 21.0f - psEnc->sCmn.SNR_dB_Q7 * ( 1 / 128.0f ) ) ) / psEnc->sCmn.subfr_length ); - - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - /* Soft limit on ratio residual energy and squared gains */ - gain = psEncCtrl->Gains[ k ]; - gain = ( silk_float )sqrt( gain * gain + psEncCtrl->ResNrg[ k ] * InvMaxSqrVal ); - psEncCtrl->Gains[ k ] = silk_min_float( gain, 32767.0f ); - } - - /* Prepare gains for noise shaping quantization */ - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - pGains_Q16[ k ] = (opus_int32)( psEncCtrl->Gains[ k ] * 65536.0f ); - } - - /* Save unquantized gains and gain Index */ - silk_memcpy( psEncCtrl->GainsUnq_Q16, pGains_Q16, psEnc->sCmn.nb_subfr * sizeof( opus_int32 ) ); - psEncCtrl->lastGainIndexPrev = psShapeSt->LastGainIndex; - - /* Quantize gains */ - silk_gains_quant( psEnc->sCmn.indices.GainsIndices, pGains_Q16, - &psShapeSt->LastGainIndex, condCoding == CODE_CONDITIONALLY, psEnc->sCmn.nb_subfr ); - - /* Overwrite unquantized gains with quantized gains and convert back to Q0 from Q16 */ - for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->Gains[ k ] = pGains_Q16[ k ] / 65536.0f; - } - - /* Set quantizer offset for voiced signals. Larger offset when LTP coding gain is low or tilt is high (ie low-pass) */ - if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - if( psEncCtrl->LTPredCodGain + psEnc->sCmn.input_tilt_Q15 * ( 1.0f / 32768.0f ) > 1.0f ) { - psEnc->sCmn.indices.quantOffsetType = 0; - } else { - psEnc->sCmn.indices.quantOffsetType = 1; - } - } - - /* Quantizer boundary adjustment */ - quant_offset = silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ] / 1024.0f; - psEncCtrl->Lambda = LAMBDA_OFFSET - + LAMBDA_DELAYED_DECISIONS * psEnc->sCmn.nStatesDelayedDecision - + LAMBDA_SPEECH_ACT * psEnc->sCmn.speech_activity_Q8 * ( 1.0f / 256.0f ) - + LAMBDA_INPUT_QUALITY * psEncCtrl->input_quality - + LAMBDA_CODING_QUALITY * psEncCtrl->coding_quality - + LAMBDA_QUANT_OFFSET * quant_offset; - - silk_assert( psEncCtrl->Lambda > 0.0f ); - silk_assert( psEncCtrl->Lambda < 2.0f ); -} diff --git a/Engine/lib/opus/silk/float/regularize_correlations_FLP.c b/Engine/lib/opus/silk/float/regularize_correlations_FLP.c deleted file mode 100644 index df4612604..000000000 --- a/Engine/lib/opus/silk/float/regularize_correlations_FLP.c +++ /dev/null @@ -1,48 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" - -/* Add noise to matrix diagonal */ -void silk_regularize_correlations_FLP( - silk_float *XX, /* I/O Correlation matrices */ - silk_float *xx, /* I/O Correlation values */ - const silk_float noise, /* I Noise energy to add */ - const opus_int D /* I Dimension of XX */ -) -{ - opus_int i; - - for( i = 0; i < D; i++ ) { - matrix_ptr( &XX[ 0 ], i, i, D ) += noise; - } - xx[ 0 ] += noise; -} diff --git a/Engine/lib/opus/silk/float/residual_energy_FLP.c b/Engine/lib/opus/silk/float/residual_energy_FLP.c deleted file mode 100644 index 1bd07b33a..000000000 --- a/Engine/lib/opus/silk/float/residual_energy_FLP.c +++ /dev/null @@ -1,117 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" - -#define MAX_ITERATIONS_RESIDUAL_NRG 10 -#define REGULARIZATION_FACTOR 1e-8f - -/* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */ - const silk_float *c, /* I Filter coefficients */ - silk_float *wXX, /* I/O Weighted correlation matrix, reg. out */ - const silk_float *wXx, /* I Weighted correlation vector */ - const silk_float wxx, /* I Weighted correlation value */ - const opus_int D /* I Dimension */ -) -{ - opus_int i, j, k; - silk_float tmp, nrg = 0.0f, regularization; - - /* Safety checks */ - celt_assert( D >= 0 ); - - regularization = REGULARIZATION_FACTOR * ( wXX[ 0 ] + wXX[ D * D - 1 ] ); - for( k = 0; k < MAX_ITERATIONS_RESIDUAL_NRG; k++ ) { - nrg = wxx; - - tmp = 0.0f; - for( i = 0; i < D; i++ ) { - tmp += wXx[ i ] * c[ i ]; - } - nrg -= 2.0f * tmp; - - /* compute c' * wXX * c, assuming wXX is symmetric */ - for( i = 0; i < D; i++ ) { - tmp = 0.0f; - for( j = i + 1; j < D; j++ ) { - tmp += matrix_c_ptr( wXX, i, j, D ) * c[ j ]; - } - nrg += c[ i ] * ( 2.0f * tmp + matrix_c_ptr( wXX, i, i, D ) * c[ i ] ); - } - if( nrg > 0 ) { - break; - } else { - /* Add white noise */ - for( i = 0; i < D; i++ ) { - matrix_c_ptr( wXX, i, i, D ) += regularization; - } - /* Increase noise for next run */ - regularization *= 2.0f; - } - } - if( k == MAX_ITERATIONS_RESIDUAL_NRG ) { - silk_assert( nrg == 0 ); - nrg = 1.0f; - } - - return nrg; -} - -/* Calculates residual energies of input subframes where all subframes have LPC_order */ -/* of preceding samples */ -void silk_residual_energy_FLP( - silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ - const silk_float x[], /* I Input signal */ - silk_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ - const silk_float gains[], /* I Quantization gains */ - const opus_int subfr_length, /* I Subframe length */ - const opus_int nb_subfr, /* I number of subframes */ - const opus_int LPC_order /* I LPC order */ -) -{ - opus_int shift; - silk_float *LPC_res_ptr, LPC_res[ ( MAX_FRAME_LENGTH + MAX_NB_SUBFR * MAX_LPC_ORDER ) / 2 ]; - - LPC_res_ptr = LPC_res + LPC_order; - shift = LPC_order + subfr_length; - - /* Filter input to create the LPC residual for each frame half, and measure subframe energies */ - silk_LPC_analysis_filter_FLP( LPC_res, a[ 0 ], x + 0 * shift, 2 * shift, LPC_order ); - nrgs[ 0 ] = ( silk_float )( gains[ 0 ] * gains[ 0 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); - nrgs[ 1 ] = ( silk_float )( gains[ 1 ] * gains[ 1 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); - - if( nb_subfr == MAX_NB_SUBFR ) { - silk_LPC_analysis_filter_FLP( LPC_res, a[ 1 ], x + 2 * shift, 2 * shift, LPC_order ); - nrgs[ 2 ] = ( silk_float )( gains[ 2 ] * gains[ 2 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); - nrgs[ 3 ] = ( silk_float )( gains[ 3 ] * gains[ 3 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); - } -} diff --git a/Engine/lib/opus/silk/float/scale_copy_vector_FLP.c b/Engine/lib/opus/silk/float/scale_copy_vector_FLP.c deleted file mode 100644 index 20db32b3b..000000000 --- a/Engine/lib/opus/silk/float/scale_copy_vector_FLP.c +++ /dev/null @@ -1,57 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FLP.h" - -/* copy and multiply a vector by a constant */ -void silk_scale_copy_vector_FLP( - silk_float *data_out, - const silk_float *data_in, - silk_float gain, - opus_int dataSize -) -{ - opus_int i, dataSize4; - - /* 4x unrolled loop */ - dataSize4 = dataSize & 0xFFFC; - for( i = 0; i < dataSize4; i += 4 ) { - data_out[ i + 0 ] = gain * data_in[ i + 0 ]; - data_out[ i + 1 ] = gain * data_in[ i + 1 ]; - data_out[ i + 2 ] = gain * data_in[ i + 2 ]; - data_out[ i + 3 ] = gain * data_in[ i + 3 ]; - } - - /* any remaining elements */ - for( ; i < dataSize; i++ ) { - data_out[ i ] = gain * data_in[ i ]; - } -} diff --git a/Engine/lib/opus/silk/float/scale_vector_FLP.c b/Engine/lib/opus/silk/float/scale_vector_FLP.c deleted file mode 100644 index 108fdcbed..000000000 --- a/Engine/lib/opus/silk/float/scale_vector_FLP.c +++ /dev/null @@ -1,56 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FLP.h" - -/* multiply a vector by a constant */ -void silk_scale_vector_FLP( - silk_float *data1, - silk_float gain, - opus_int dataSize -) -{ - opus_int i, dataSize4; - - /* 4x unrolled loop */ - dataSize4 = dataSize & 0xFFFC; - for( i = 0; i < dataSize4; i += 4 ) { - data1[ i + 0 ] *= gain; - data1[ i + 1 ] *= gain; - data1[ i + 2 ] *= gain; - data1[ i + 3 ] *= gain; - } - - /* any remaining elements */ - for( ; i < dataSize; i++ ) { - data1[ i ] *= gain; - } -} diff --git a/Engine/lib/opus/silk/float/schur_FLP.c b/Engine/lib/opus/silk/float/schur_FLP.c deleted file mode 100644 index 8526c748d..000000000 --- a/Engine/lib/opus/silk/float/schur_FLP.c +++ /dev/null @@ -1,70 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FLP.h" - -silk_float silk_schur_FLP( /* O returns residual energy */ - silk_float refl_coef[], /* O reflection coefficients (length order) */ - const silk_float auto_corr[], /* I autocorrelation sequence (length order+1) */ - opus_int order /* I order */ -) -{ - opus_int k, n; - double C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ]; - double Ctmp1, Ctmp2, rc_tmp; - - celt_assert( order >= 0 && order <= SILK_MAX_ORDER_LPC ); - - /* Copy correlations */ - k = 0; - do { - C[ k ][ 0 ] = C[ k ][ 1 ] = auto_corr[ k ]; - } while( ++k <= order ); - - for( k = 0; k < order; k++ ) { - /* Get reflection coefficient */ - rc_tmp = -C[ k + 1 ][ 0 ] / silk_max_float( C[ 0 ][ 1 ], 1e-9f ); - - /* Save the output */ - refl_coef[ k ] = (silk_float)rc_tmp; - - /* Update correlations */ - for( n = 0; n < order - k; n++ ) { - Ctmp1 = C[ n + k + 1 ][ 0 ]; - Ctmp2 = C[ n ][ 1 ]; - C[ n + k + 1 ][ 0 ] = Ctmp1 + Ctmp2 * rc_tmp; - C[ n ][ 1 ] = Ctmp2 + Ctmp1 * rc_tmp; - } - } - - /* Return residual energy */ - return (silk_float)C[ 0 ][ 1 ]; -} diff --git a/Engine/lib/opus/silk/float/sort_FLP.c b/Engine/lib/opus/silk/float/sort_FLP.c deleted file mode 100644 index 0e18f3195..000000000 --- a/Engine/lib/opus/silk/float/sort_FLP.c +++ /dev/null @@ -1,83 +0,0 @@ -/*********************************************************************** -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" -#endif - -/* Insertion sort (fast for already almost sorted arrays): */ -/* Best case: O(n) for an already sorted array */ -/* Worst case: O(n^2) for an inversely sorted array */ - -#include "typedef.h" -#include "SigProc_FLP.h" - -void silk_insertion_sort_decreasing_FLP( - silk_float *a, /* I/O Unsorted / Sorted vector */ - opus_int *idx, /* O Index vector for the sorted elements */ - const opus_int L, /* I Vector length */ - const opus_int K /* I Number of correctly sorted positions */ -) -{ - silk_float value; - opus_int i, j; - - /* Safety checks */ - celt_assert( K > 0 ); - celt_assert( L > 0 ); - celt_assert( L >= K ); - - /* Write start indices in index vector */ - for( i = 0; i < K; i++ ) { - idx[ i ] = i; - } - - /* Sort vector elements by value, decreasing order */ - for( i = 1; i < K; i++ ) { - value = a[ i ]; - for( j = i - 1; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - idx[ j + 1 ] = idx[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - idx[ j + 1 ] = i; /* Write index */ - } - - /* If less than L values are asked check the remaining values, */ - /* but only spend CPU to ensure that the K first values are correct */ - for( i = K; i < L; i++ ) { - value = a[ i ]; - if( value > a[ K - 1 ] ) { - for( j = K - 2; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - idx[ j + 1 ] = idx[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - idx[ j + 1 ] = i; /* Write index */ - } - } -} diff --git a/Engine/lib/opus/silk/float/structs_FLP.h b/Engine/lib/opus/silk/float/structs_FLP.h deleted file mode 100644 index 3150b386e..000000000 --- a/Engine/lib/opus/silk/float/structs_FLP.h +++ /dev/null @@ -1,112 +0,0 @@ -/*********************************************************************** -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 SILK_STRUCTS_FLP_H -#define SILK_STRUCTS_FLP_H - -#include "typedef.h" -#include "main.h" -#include "structs.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/********************************/ -/* Noise shaping analysis state */ -/********************************/ -typedef struct { - opus_int8 LastGainIndex; - silk_float HarmShapeGain_smth; - silk_float Tilt_smth; -} silk_shape_state_FLP; - -/********************************/ -/* Encoder state FLP */ -/********************************/ -typedef struct { - silk_encoder_state sCmn; /* Common struct, shared with fixed-point code */ - silk_shape_state_FLP sShape; /* Noise shaping state */ - - /* Buffer for find pitch and noise shape analysis */ - silk_float x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */ - silk_float LTPCorr; /* Normalized correlation from pitch lag estimator */ -} silk_encoder_state_FLP; - -/************************/ -/* Encoder control FLP */ -/************************/ -typedef struct { - /* Prediction and coding parameters */ - silk_float Gains[ MAX_NB_SUBFR ]; - silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ]; /* holds interpolated and final coefficients */ - silk_float LTPCoef[LTP_ORDER * MAX_NB_SUBFR]; - silk_float LTP_scale; - opus_int pitchL[ MAX_NB_SUBFR ]; - - /* Noise shaping parameters */ - silk_float AR[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ]; - silk_float LF_MA_shp[ MAX_NB_SUBFR ]; - silk_float LF_AR_shp[ MAX_NB_SUBFR ]; - silk_float Tilt[ MAX_NB_SUBFR ]; - silk_float HarmShapeGain[ MAX_NB_SUBFR ]; - silk_float Lambda; - silk_float input_quality; - silk_float coding_quality; - - /* Measures */ - silk_float predGain; - silk_float LTPredCodGain; - silk_float ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */ - - /* Parameters for CBR mode */ - opus_int32 GainsUnq_Q16[ MAX_NB_SUBFR ]; - opus_int8 lastGainIndexPrev; -} silk_encoder_control_FLP; - -/************************/ -/* Encoder Super Struct */ -/************************/ -typedef struct { - silk_encoder_state_FLP state_Fxx[ ENCODER_NUM_CHANNELS ]; - stereo_enc_state sStereo; - opus_int32 nBitsUsedLBRR; - opus_int32 nBitsExceeded; - opus_int nChannelsAPI; - opus_int nChannelsInternal; - opus_int nPrevChannelsInternal; - opus_int timeSinceSwitchAllowed_ms; - opus_int allowBandwidthSwitch; - opus_int prev_decode_only_middle; -} silk_encoder; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/silk/float/warped_autocorrelation_FLP.c b/Engine/lib/opus/silk/float/warped_autocorrelation_FLP.c deleted file mode 100644 index 09186e73d..000000000 --- a/Engine/lib/opus/silk/float/warped_autocorrelation_FLP.c +++ /dev/null @@ -1,73 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" - -/* Autocorrelations for a warped frequency axis */ -void silk_warped_autocorrelation_FLP( - silk_float *corr, /* O Result [order + 1] */ - const silk_float *input, /* I Input data to correlate */ - const silk_float warping, /* I Warping coefficient */ - const opus_int length, /* I Length of input */ - const opus_int order /* I Correlation order (even) */ -) -{ - opus_int n, i; - double tmp1, tmp2; - double state[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; - double C[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; - - /* Order must be even */ - celt_assert( ( order & 1 ) == 0 ); - - /* Loop over samples */ - for( n = 0; n < length; n++ ) { - tmp1 = input[ n ]; - /* Loop over allpass sections */ - for( i = 0; i < order; i += 2 ) { - /* Output of allpass section */ - tmp2 = state[ i ] + warping * ( state[ i + 1 ] - tmp1 ); - state[ i ] = tmp1; - C[ i ] += state[ 0 ] * tmp1; - /* Output of allpass section */ - tmp1 = state[ i + 1 ] + warping * ( state[ i + 2 ] - tmp2 ); - state[ i + 1 ] = tmp2; - C[ i + 1 ] += state[ 0 ] * tmp2; - } - state[ order ] = tmp1; - C[ order ] += state[ 0 ] * tmp1; - } - - /* Copy correlations in silk_float output format */ - for( i = 0; i < order + 1; i++ ) { - corr[ i ] = ( silk_float )C[ i ]; - } -} diff --git a/Engine/lib/opus/silk/float/wrappers_FLP.c b/Engine/lib/opus/silk/float/wrappers_FLP.c deleted file mode 100644 index c0c183e35..000000000 --- a/Engine/lib/opus/silk/float/wrappers_FLP.c +++ /dev/null @@ -1,209 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main_FLP.h" - -/* Wrappers. Calls flp / fix code */ - -/* Convert AR filter coefficients to NLSF parameters */ -void silk_A2NLSF_FLP( - opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */ - const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */ - const opus_int LPC_order /* I LPC order */ -) -{ - opus_int i; - opus_int32 a_fix_Q16[ MAX_LPC_ORDER ]; - - for( i = 0; i < LPC_order; i++ ) { - a_fix_Q16[ i ] = silk_float2int( pAR[ i ] * 65536.0f ); - } - - silk_A2NLSF( NLSF_Q15, a_fix_Q16, LPC_order ); -} - -/* Convert LSF parameters to AR prediction filter coefficients */ -void silk_NLSF2A_FLP( - silk_float *pAR, /* O LPC coefficients [ LPC_order ] */ - const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */ - const opus_int LPC_order, /* I LPC order */ - int arch /* I Run-time architecture */ -) -{ - opus_int i; - opus_int16 a_fix_Q12[ MAX_LPC_ORDER ]; - - silk_NLSF2A( a_fix_Q12, NLSF_Q15, LPC_order, arch ); - - for( i = 0; i < LPC_order; i++ ) { - pAR[ i ] = ( silk_float )a_fix_Q12[ i ] * ( 1.0f / 4096.0f ); - } -} - -/******************************************/ -/* Floating-point NLSF processing wrapper */ -/******************************************/ -void silk_process_NLSFs_FLP( - silk_encoder_state *psEncC, /* I/O Encoder state */ - silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ - opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ - const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ -) -{ - opus_int i, j; - opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; - - silk_process_NLSFs( psEncC, PredCoef_Q12, NLSF_Q15, prev_NLSF_Q15); - - for( j = 0; j < 2; j++ ) { - for( i = 0; i < psEncC->predictLPCOrder; i++ ) { - PredCoef[ j ][ i ] = ( silk_float )PredCoef_Q12[ j ][ i ] * ( 1.0f / 4096.0f ); - } - } -} - -/****************************************/ -/* Floating-point Silk NSQ wrapper */ -/****************************************/ -void silk_NSQ_wrapper_FLP( - silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ - SideInfoIndices *psIndices, /* I/O Quantization indices */ - silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const silk_float x[] /* I Prefiltered input signal */ -) -{ - opus_int i, j; - opus_int16 x16[ MAX_FRAME_LENGTH ]; - opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; - silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; - opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; - opus_int LTP_scale_Q14; - - /* Noise shaping parameters */ - opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ]; - opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coefficients per int32 value */ - opus_int Lambda_Q10; - opus_int Tilt_Q14[ MAX_NB_SUBFR ]; - opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ]; - - /* Convert control struct to fix control struct */ - /* Noise shape parameters */ - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - for( j = 0; j < psEnc->sCmn.shapingLPCOrder; j++ ) { - AR_Q13[ i * MAX_SHAPE_LPC_ORDER + j ] = silk_float2int( psEncCtrl->AR[ i * MAX_SHAPE_LPC_ORDER + j ] * 8192.0f ); - } - } - - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - LF_shp_Q14[ i ] = silk_LSHIFT32( silk_float2int( psEncCtrl->LF_AR_shp[ i ] * 16384.0f ), 16 ) | - (opus_uint16)silk_float2int( psEncCtrl->LF_MA_shp[ i ] * 16384.0f ); - Tilt_Q14[ i ] = (opus_int)silk_float2int( psEncCtrl->Tilt[ i ] * 16384.0f ); - HarmShapeGain_Q14[ i ] = (opus_int)silk_float2int( psEncCtrl->HarmShapeGain[ i ] * 16384.0f ); - } - Lambda_Q10 = ( opus_int )silk_float2int( psEncCtrl->Lambda * 1024.0f ); - - /* prediction and coding parameters */ - for( i = 0; i < psEnc->sCmn.nb_subfr * LTP_ORDER; i++ ) { - LTPCoef_Q14[ i ] = (opus_int16)silk_float2int( psEncCtrl->LTPCoef[ i ] * 16384.0f ); - } - - for( j = 0; j < 2; j++ ) { - for( i = 0; i < psEnc->sCmn.predictLPCOrder; i++ ) { - PredCoef_Q12[ j ][ i ] = (opus_int16)silk_float2int( psEncCtrl->PredCoef[ j ][ i ] * 4096.0f ); - } - } - - for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - Gains_Q16[ i ] = silk_float2int( psEncCtrl->Gains[ i ] * 65536.0f ); - silk_assert( Gains_Q16[ i ] > 0 ); - } - - if( psIndices->signalType == TYPE_VOICED ) { - LTP_scale_Q14 = silk_LTPScales_table_Q14[ psIndices->LTP_scaleIndex ]; - } else { - LTP_scale_Q14 = 0; - } - - /* Convert input to fix */ - for( i = 0; i < psEnc->sCmn.frame_length; i++ ) { - x16[ i ] = silk_float2int( x[ i ] ); - } - - /* Call NSQ */ - if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { - silk_NSQ_del_dec( &psEnc->sCmn, psNSQ, psIndices, x16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14, - AR_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch ); - } else { - silk_NSQ( &psEnc->sCmn, psNSQ, psIndices, x16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14, - AR_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch ); - } -} - -/***********************************************/ -/* Floating-point Silk LTP quantiation wrapper */ -/***********************************************/ -void silk_quant_LTP_gains_FLP( - silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ - opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */ - opus_int8 *periodicity_index, /* O Periodicity index */ - opus_int32 *sum_log_gain_Q7, /* I/O Cumulative max prediction gain */ - silk_float *pred_gain_dB, /* O LTP prediction gain */ - const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Correlation matrix */ - const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I Correlation vector */ - const opus_int subfr_len, /* I Number of samples per subframe */ - const opus_int nb_subfr, /* I Number of subframes */ - int arch /* I Run-time architecture */ -) -{ - opus_int i, pred_gain_dB_Q7; - opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ]; - opus_int32 XX_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ]; - opus_int32 xX_Q17[ MAX_NB_SUBFR * LTP_ORDER ]; - - i = 0; - do { - XX_Q17[ i ] = (opus_int32)silk_float2int( XX[ i ] * 131072.0f ); - } while ( ++i < nb_subfr * LTP_ORDER * LTP_ORDER ); - i = 0; - do { - xX_Q17[ i ] = (opus_int32)silk_float2int( xX[ i ] * 131072.0f ); - } while ( ++i < nb_subfr * LTP_ORDER ); - - silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, sum_log_gain_Q7, &pred_gain_dB_Q7, XX_Q17, xX_Q17, subfr_len, nb_subfr, arch ); - - for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) { - B[ i ] = (silk_float)B_Q14[ i ] * ( 1.0f / 16384.0f ); - } - - *pred_gain_dB = (silk_float)pred_gain_dB_Q7 * ( 1.0f / 128.0f ); -} diff --git a/Engine/lib/opus/silk/gain_quant.c b/Engine/lib/opus/silk/gain_quant.c deleted file mode 100644 index ee65245aa..000000000 --- a/Engine/lib/opus/silk/gain_quant.c +++ /dev/null @@ -1,142 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -#define OFFSET ( ( MIN_QGAIN_DB * 128 ) / 6 + 16 * 128 ) -#define SCALE_Q16 ( ( 65536 * ( N_LEVELS_QGAIN - 1 ) ) / ( ( ( MAX_QGAIN_DB - MIN_QGAIN_DB ) * 128 ) / 6 ) ) -#define INV_SCALE_Q16 ( ( 65536 * ( ( ( MAX_QGAIN_DB - MIN_QGAIN_DB ) * 128 ) / 6 ) ) / ( N_LEVELS_QGAIN - 1 ) ) - -/* Gain scalar quantization with hysteresis, uniform on log scale */ -void silk_gains_quant( - opus_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */ - opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */ - opus_int8 *prev_ind, /* I/O last index in previous frame */ - const opus_int conditional, /* I first gain is delta coded if 1 */ - const opus_int nb_subfr /* I number of subframes */ -) -{ - opus_int k, double_step_size_threshold; - - for( k = 0; k < nb_subfr; k++ ) { - /* Convert to log scale, scale, floor() */ - ind[ k ] = silk_SMULWB( SCALE_Q16, silk_lin2log( gain_Q16[ k ] ) - OFFSET ); - - /* Round towards previous quantized gain (hysteresis) */ - if( ind[ k ] < *prev_ind ) { - ind[ k ]++; - } - ind[ k ] = silk_LIMIT_int( ind[ k ], 0, N_LEVELS_QGAIN - 1 ); - - /* Compute delta indices and limit */ - if( k == 0 && conditional == 0 ) { - /* Full index */ - ind[ k ] = silk_LIMIT_int( ind[ k ], *prev_ind + MIN_DELTA_GAIN_QUANT, N_LEVELS_QGAIN - 1 ); - *prev_ind = ind[ k ]; - } else { - /* Delta index */ - ind[ k ] = ind[ k ] - *prev_ind; - - /* Double the quantization step size for large gain increases, so that the max gain level can be reached */ - double_step_size_threshold = 2 * MAX_DELTA_GAIN_QUANT - N_LEVELS_QGAIN + *prev_ind; - if( ind[ k ] > double_step_size_threshold ) { - ind[ k ] = double_step_size_threshold + silk_RSHIFT( ind[ k ] - double_step_size_threshold + 1, 1 ); - } - - ind[ k ] = silk_LIMIT_int( ind[ k ], MIN_DELTA_GAIN_QUANT, MAX_DELTA_GAIN_QUANT ); - - /* Accumulate deltas */ - if( ind[ k ] > double_step_size_threshold ) { - *prev_ind += silk_LSHIFT( ind[ k ], 1 ) - double_step_size_threshold; - *prev_ind = silk_min_int( *prev_ind, N_LEVELS_QGAIN - 1 ); - } else { - *prev_ind += ind[ k ]; - } - - /* Shift to make non-negative */ - ind[ k ] -= MIN_DELTA_GAIN_QUANT; - } - - /* Scale and convert to linear scale */ - gain_Q16[ k ] = silk_log2lin( silk_min_32( silk_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */ - } -} - -/* Gains scalar dequantization, uniform on log scale */ -void silk_gains_dequant( - opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */ - const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ - opus_int8 *prev_ind, /* I/O last index in previous frame */ - const opus_int conditional, /* I first gain is delta coded if 1 */ - const opus_int nb_subfr /* I number of subframes */ -) -{ - opus_int k, ind_tmp, double_step_size_threshold; - - for( k = 0; k < nb_subfr; k++ ) { - if( k == 0 && conditional == 0 ) { - /* Gain index is not allowed to go down more than 16 steps (~21.8 dB) */ - *prev_ind = silk_max_int( ind[ k ], *prev_ind - 16 ); - } else { - /* Delta index */ - ind_tmp = ind[ k ] + MIN_DELTA_GAIN_QUANT; - - /* Accumulate deltas */ - double_step_size_threshold = 2 * MAX_DELTA_GAIN_QUANT - N_LEVELS_QGAIN + *prev_ind; - if( ind_tmp > double_step_size_threshold ) { - *prev_ind += silk_LSHIFT( ind_tmp, 1 ) - double_step_size_threshold; - } else { - *prev_ind += ind_tmp; - } - } - *prev_ind = silk_LIMIT_int( *prev_ind, 0, N_LEVELS_QGAIN - 1 ); - - /* Scale and convert to linear scale */ - gain_Q16[ k ] = silk_log2lin( silk_min_32( silk_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */ - } -} - -/* Compute unique identifier of gain indices vector */ -opus_int32 silk_gains_ID( /* O returns unique identifier of gains */ - const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ - const opus_int nb_subfr /* I number of subframes */ -) -{ - opus_int k; - opus_int32 gainsID; - - gainsID = 0; - for( k = 0; k < nb_subfr; k++ ) { - gainsID = silk_ADD_LSHIFT32( ind[ k ], gainsID, 8 ); - } - - return gainsID; -} diff --git a/Engine/lib/opus/silk/init_decoder.c b/Engine/lib/opus/silk/init_decoder.c deleted file mode 100644 index 16c03dcd1..000000000 --- a/Engine/lib/opus/silk/init_decoder.c +++ /dev/null @@ -1,57 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/************************/ -/* Init Decoder State */ -/************************/ -opus_int silk_init_decoder( - silk_decoder_state *psDec /* I/O Decoder state pointer */ -) -{ - /* Clear the entire encoder state, except anything copied */ - silk_memset( psDec, 0, sizeof( silk_decoder_state ) ); - - /* Used to deactivate LSF interpolation */ - psDec->first_frame_after_reset = 1; - psDec->prev_gain_Q16 = 65536; - psDec->arch = opus_select_arch(); - - /* Reset CNG state */ - silk_CNG_Reset( psDec ); - - /* Reset PLC state */ - silk_PLC_Reset( psDec ); - - return(0); -} - diff --git a/Engine/lib/opus/silk/init_encoder.c b/Engine/lib/opus/silk/init_encoder.c deleted file mode 100644 index 65995c33f..000000000 --- a/Engine/lib/opus/silk/init_encoder.c +++ /dev/null @@ -1,64 +0,0 @@ -/*********************************************************************** -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" -#endif -#ifdef FIXED_POINT -#include "main_FIX.h" -#else -#include "main_FLP.h" -#endif -#include "tuning_parameters.h" -#include "cpu_support.h" - -/*********************************/ -/* Initialize Silk Encoder state */ -/*********************************/ -opus_int silk_init_encoder( - silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk FIX encoder state */ - int arch /* I Run-time architecture */ -) -{ - opus_int ret = 0; - - /* Clear the entire encoder state */ - silk_memset( psEnc, 0, sizeof( silk_encoder_state_Fxx ) ); - - psEnc->sCmn.arch = arch; - - psEnc->sCmn.variable_HP_smth1_Q15 = silk_LSHIFT( silk_lin2log( SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 16 ) ) - ( 16 << 7 ), 8 ); - psEnc->sCmn.variable_HP_smth2_Q15 = psEnc->sCmn.variable_HP_smth1_Q15; - - /* Used to deactivate LSF interpolation, pitch prediction */ - psEnc->sCmn.first_frame_after_reset = 1; - - /* Initialize Silk VAD */ - ret += silk_VAD_Init( &psEnc->sCmn.sVAD ); - - return ret; -} diff --git a/Engine/lib/opus/silk/inner_prod_aligned.c b/Engine/lib/opus/silk/inner_prod_aligned.c deleted file mode 100644 index 257ae9e04..000000000 --- a/Engine/lib/opus/silk/inner_prod_aligned.c +++ /dev/null @@ -1,47 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -opus_int32 silk_inner_prod_aligned_scale( - const opus_int16 *const inVec1, /* I input vector 1 */ - const opus_int16 *const inVec2, /* I input vector 2 */ - const opus_int scale, /* I number of bits to shift */ - const opus_int len /* I vector lengths */ -) -{ - opus_int i; - opus_int32 sum = 0; - for( i = 0; i < len; i++ ) { - sum = silk_ADD_RSHIFT32( sum, silk_SMULBB( inVec1[ i ], inVec2[ i ] ), scale ); - } - return sum; -} diff --git a/Engine/lib/opus/silk/interpolate.c b/Engine/lib/opus/silk/interpolate.c deleted file mode 100644 index 833c28ef8..000000000 --- a/Engine/lib/opus/silk/interpolate.c +++ /dev/null @@ -1,51 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Interpolate two vectors */ -void silk_interpolate( - opus_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */ - const opus_int16 x0[ MAX_LPC_ORDER ], /* I first vector */ - const opus_int16 x1[ MAX_LPC_ORDER ], /* I second vector */ - const opus_int ifact_Q2, /* I interp. factor, weight on 2nd vector */ - const opus_int d /* I number of parameters */ -) -{ - opus_int i; - - celt_assert( ifact_Q2 >= 0 ); - celt_assert( ifact_Q2 <= 4 ); - - for( i = 0; i < d; i++ ) { - xi[ i ] = (opus_int16)silk_ADD_RSHIFT( x0[ i ], silk_SMULBB( x1[ i ] - x0[ i ], ifact_Q2 ), 2 ); - } -} diff --git a/Engine/lib/opus/silk/lin2log.c b/Engine/lib/opus/silk/lin2log.c deleted file mode 100644 index 0d5155aa8..000000000 --- a/Engine/lib/opus/silk/lin2log.c +++ /dev/null @@ -1,46 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -/* Approximation of 128 * log2() (very close inverse of silk_log2lin()) */ -/* Convert input to a log scale */ -opus_int32 silk_lin2log( - const opus_int32 inLin /* I input in linear scale */ -) -{ - opus_int32 lz, frac_Q7; - - silk_CLZ_FRAC( inLin, &lz, &frac_Q7 ); - - /* Piece-wise parabolic approximation */ - return silk_ADD_LSHIFT32( silk_SMLAWB( frac_Q7, silk_MUL( frac_Q7, 128 - frac_Q7 ), 179 ), 31 - lz, 7 ); -} - diff --git a/Engine/lib/opus/silk/log2lin.c b/Engine/lib/opus/silk/log2lin.c deleted file mode 100644 index b7c48e474..000000000 --- a/Engine/lib/opus/silk/log2lin.c +++ /dev/null @@ -1,58 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Approximation of 2^() (very close inverse of silk_lin2log()) */ -/* Convert input to a linear scale */ -opus_int32 silk_log2lin( - const opus_int32 inLog_Q7 /* I input on log scale */ -) -{ - opus_int32 out, frac_Q7; - - if( inLog_Q7 < 0 ) { - return 0; - } else if ( inLog_Q7 >= 3967 ) { - return silk_int32_MAX; - } - - out = silk_LSHIFT( 1, silk_RSHIFT( inLog_Q7, 7 ) ); - frac_Q7 = inLog_Q7 & 0x7F; - if( inLog_Q7 < 2048 ) { - /* Piece-wise parabolic approximation */ - out = silk_ADD_RSHIFT32( out, silk_MUL( out, silk_SMLAWB( frac_Q7, silk_SMULBB( frac_Q7, 128 - frac_Q7 ), -174 ) ), 7 ); - } else { - /* Piece-wise parabolic approximation */ - out = silk_MLA( out, silk_RSHIFT( out, 7 ), silk_SMLAWB( frac_Q7, silk_SMULBB( frac_Q7, 128 - frac_Q7 ), -174 ) ); - } - return out; -} diff --git a/Engine/lib/opus/silk/macros.h b/Engine/lib/opus/silk/macros.h deleted file mode 100644 index 3c67b6e5d..000000000 --- a/Engine/lib/opus/silk/macros.h +++ /dev/null @@ -1,151 +0,0 @@ -/*********************************************************************** -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 SILK_MACROS_H -#define SILK_MACROS_H - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "opus_types.h" -#include "opus_defines.h" -#include "arch.h" - -/* This is an OPUS_INLINE header file for general platform. */ - -/* (a32 * (opus_int32)((opus_int16)(b32))) >> 16 output have to be 32bit int */ -#if OPUS_FAST_INT64 -#define silk_SMULWB(a32, b32) ((opus_int32)(((a32) * (opus_int64)((opus_int16)(b32))) >> 16)) -#else -#define silk_SMULWB(a32, b32) ((((a32) >> 16) * (opus_int32)((opus_int16)(b32))) + ((((a32) & 0x0000FFFF) * (opus_int32)((opus_int16)(b32))) >> 16)) -#endif - -/* a32 + (b32 * (opus_int32)((opus_int16)(c32))) >> 16 output have to be 32bit int */ -#if OPUS_FAST_INT64 -#define silk_SMLAWB(a32, b32, c32) ((opus_int32)((a32) + (((b32) * (opus_int64)((opus_int16)(c32))) >> 16))) -#else -#define silk_SMLAWB(a32, b32, c32) ((a32) + ((((b32) >> 16) * (opus_int32)((opus_int16)(c32))) + ((((b32) & 0x0000FFFF) * (opus_int32)((opus_int16)(c32))) >> 16))) -#endif - -/* (a32 * (b32 >> 16)) >> 16 */ -#if OPUS_FAST_INT64 -#define silk_SMULWT(a32, b32) ((opus_int32)(((a32) * (opus_int64)((b32) >> 16)) >> 16)) -#else -#define silk_SMULWT(a32, b32) (((a32) >> 16) * ((b32) >> 16) + ((((a32) & 0x0000FFFF) * ((b32) >> 16)) >> 16)) -#endif - -/* a32 + (b32 * (c32 >> 16)) >> 16 */ -#if OPUS_FAST_INT64 -#define silk_SMLAWT(a32, b32, c32) ((opus_int32)((a32) + (((b32) * ((opus_int64)(c32) >> 16)) >> 16))) -#else -#define silk_SMLAWT(a32, b32, c32) ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16)) -#endif - -/* (opus_int32)((opus_int16)(a3))) * (opus_int32)((opus_int16)(b32)) output have to be 32bit int */ -#define silk_SMULBB(a32, b32) ((opus_int32)((opus_int16)(a32)) * (opus_int32)((opus_int16)(b32))) - -/* a32 + (opus_int32)((opus_int16)(b32)) * (opus_int32)((opus_int16)(c32)) output have to be 32bit int */ -#define silk_SMLABB(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32))) - -/* (opus_int32)((opus_int16)(a32)) * (b32 >> 16) */ -#define silk_SMULBT(a32, b32) ((opus_int32)((opus_int16)(a32)) * ((b32) >> 16)) - -/* a32 + (opus_int32)((opus_int16)(b32)) * (c32 >> 16) */ -#define silk_SMLABT(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * ((c32) >> 16)) - -/* a64 + (b32 * c32) */ -#define silk_SMLAL(a64, b32, c32) (silk_ADD64((a64), ((opus_int64)(b32) * (opus_int64)(c32)))) - -/* (a32 * b32) >> 16 */ -#if OPUS_FAST_INT64 -#define silk_SMULWW(a32, b32) ((opus_int32)(((opus_int64)(a32) * (b32)) >> 16)) -#else -#define silk_SMULWW(a32, b32) silk_MLA(silk_SMULWB((a32), (b32)), (a32), silk_RSHIFT_ROUND((b32), 16)) -#endif - -/* a32 + ((b32 * c32) >> 16) */ -#if OPUS_FAST_INT64 -#define silk_SMLAWW(a32, b32, c32) ((opus_int32)((a32) + (((opus_int64)(b32) * (c32)) >> 16))) -#else -#define silk_SMLAWW(a32, b32, c32) silk_MLA(silk_SMLAWB((a32), (b32), (c32)), (b32), silk_RSHIFT_ROUND((c32), 16)) -#endif - -/* add/subtract with output saturated */ -#define silk_ADD_SAT32(a, b) ((((opus_uint32)(a) + (opus_uint32)(b)) & 0x80000000) == 0 ? \ - ((((a) & (b)) & 0x80000000) != 0 ? silk_int32_MIN : (a)+(b)) : \ - ((((a) | (b)) & 0x80000000) == 0 ? silk_int32_MAX : (a)+(b)) ) - -#define silk_SUB_SAT32(a, b) ((((opus_uint32)(a)-(opus_uint32)(b)) & 0x80000000) == 0 ? \ - (( (a) & ((b)^0x80000000) & 0x80000000) ? silk_int32_MIN : (a)-(b)) : \ - ((((a)^0x80000000) & (b) & 0x80000000) ? silk_int32_MAX : (a)-(b)) ) - -#if defined(MIPSr1_ASM) -#include "mips/macros_mipsr1.h" -#endif - -#include "ecintrin.h" -#ifndef OVERRIDE_silk_CLZ16 -static OPUS_INLINE opus_int32 silk_CLZ16(opus_int16 in16) -{ - return 32 - EC_ILOG(in16<<16|0x8000); -} -#endif - -#ifndef OVERRIDE_silk_CLZ32 -static OPUS_INLINE opus_int32 silk_CLZ32(opus_int32 in32) -{ - return in32 ? 32 - EC_ILOG(in32) : 32; -} -#endif - -/* Row based */ -#define matrix_ptr(Matrix_base_adr, row, column, N) \ - (*((Matrix_base_adr) + ((row)*(N)+(column)))) -#define matrix_adr(Matrix_base_adr, row, column, N) \ - ((Matrix_base_adr) + ((row)*(N)+(column))) - -/* Column based */ -#ifndef matrix_c_ptr -# define matrix_c_ptr(Matrix_base_adr, row, column, M) \ - (*((Matrix_base_adr) + ((row)+(M)*(column)))) -#endif - -#ifdef OPUS_ARM_INLINE_ASM -#include "arm/macros_armv4.h" -#endif - -#ifdef OPUS_ARM_INLINE_EDSP -#include "arm/macros_armv5e.h" -#endif - -#ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR -#include "arm/macros_arm64.h" -#endif - -#endif /* SILK_MACROS_H */ - diff --git a/Engine/lib/opus/silk/main.h b/Engine/lib/opus/silk/main.h deleted file mode 100644 index a5f568758..000000000 --- a/Engine/lib/opus/silk/main.h +++ /dev/null @@ -1,476 +0,0 @@ -/*********************************************************************** -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 SILK_MAIN_H -#define SILK_MAIN_H - -#include "SigProc_FIX.h" -#include "define.h" -#include "structs.h" -#include "tables.h" -#include "PLC.h" -#include "control.h" -#include "debug.h" -#include "entenc.h" -#include "entdec.h" - -#if defined(OPUS_X86_MAY_HAVE_SSE4_1) -#include "x86/main_sse.h" -#endif - -#if (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) -#include "arm/NSQ_del_dec_arm.h" -#endif - -/* Convert Left/Right stereo signal to adaptive Mid/Side representation */ -void silk_stereo_LR_to_MS( - stereo_enc_state *state, /* I/O State */ - opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ - opus_int16 x2[], /* I/O Right input signal, becomes side signal */ - opus_int8 ix[ 2 ][ 3 ], /* O Quantization indices */ - opus_int8 *mid_only_flag, /* O Flag: only mid signal coded */ - opus_int32 mid_side_rates_bps[], /* O Bitrates for mid and side signals */ - opus_int32 total_rate_bps, /* I Total bitrate */ - opus_int prev_speech_act_Q8, /* I Speech activity level in previous frame */ - opus_int toMono, /* I Last frame before a stereo->mono transition */ - opus_int fs_kHz, /* I Sample rate (kHz) */ - opus_int frame_length /* I Number of samples */ -); - -/* Convert adaptive Mid/Side representation to Left/Right stereo signal */ -void silk_stereo_MS_to_LR( - stereo_dec_state *state, /* I/O State */ - opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ - opus_int16 x2[], /* I/O Right input signal, becomes side signal */ - const opus_int32 pred_Q13[], /* I Predictors */ - opus_int fs_kHz, /* I Samples rate (kHz) */ - opus_int frame_length /* I Number of samples */ -); - -/* Find least-squares prediction gain for one signal based on another and quantize it */ -opus_int32 silk_stereo_find_predictor( /* O Returns predictor in Q13 */ - opus_int32 *ratio_Q14, /* O Ratio of residual and mid energies */ - const opus_int16 x[], /* I Basis signal */ - const opus_int16 y[], /* I Target signal */ - opus_int32 mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */ - opus_int length, /* I Number of samples */ - opus_int smooth_coef_Q16 /* I Smoothing coefficient */ -); - -/* Quantize mid/side predictors */ -void silk_stereo_quant_pred( - opus_int32 pred_Q13[], /* I/O Predictors (out: quantized) */ - opus_int8 ix[ 2 ][ 3 ] /* O Quantization indices */ -); - -/* Entropy code the mid/side quantization indices */ -void silk_stereo_encode_pred( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int8 ix[ 2 ][ 3 ] /* I Quantization indices */ -); - -/* Entropy code the mid-only flag */ -void silk_stereo_encode_mid_only( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int8 mid_only_flag -); - -/* Decode mid/side predictors */ -void silk_stereo_decode_pred( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int32 pred_Q13[] /* O Predictors */ -); - -/* Decode mid-only flag */ -void silk_stereo_decode_mid_only( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int *decode_only_mid /* O Flag that only mid channel has been coded */ -); - -/* Encodes signs of excitation */ -void silk_encode_signs( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - const opus_int8 pulses[], /* I pulse signal */ - opus_int length, /* I length of input */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I Quantization offset type */ - const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ -); - -/* Decodes signs of excitation */ -void silk_decode_signs( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 pulses[], /* I/O pulse signal */ - opus_int length, /* I length of input */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I Quantization offset type */ - const opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ -); - -/* Check encoder control struct */ -opus_int check_control_input( - silk_EncControlStruct *encControl /* I Control structure */ -); - -/* Control internal sampling rate */ -opus_int silk_control_audio_bandwidth( - silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ - silk_EncControlStruct *encControl /* I Control structure */ -); - -/* Control SNR of redidual quantizer */ -opus_int silk_control_SNR( - silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ - opus_int32 TargetRate_bps /* I Target max bitrate (bps) */ -); - -/***************/ -/* Shell coder */ -/***************/ - -/* Encode quantization indices of excitation */ -void silk_encode_pulses( - ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int signalType, /* I Signal type */ - const opus_int quantOffsetType, /* I quantOffsetType */ - opus_int8 pulses[], /* I quantization indices */ - const opus_int frame_length /* I Frame length */ -); - -/* Shell encoder, operates on one shell code frame of 16 pulses */ -void silk_shell_encoder( - ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int *pulses0 /* I data: nonnegative pulse amplitudes */ -); - -/* Shell decoder, operates on one shell code frame of 16 pulses */ -void silk_shell_decoder( - opus_int16 *pulses0, /* O data: nonnegative pulse amplitudes */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - const opus_int pulses4 /* I number of pulses per pulse-subframe */ -); - -/* Gain scalar quantization with hysteresis, uniform on log scale */ -void silk_gains_quant( - opus_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */ - opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */ - opus_int8 *prev_ind, /* I/O last index in previous frame */ - const opus_int conditional, /* I first gain is delta coded if 1 */ - const opus_int nb_subfr /* I number of subframes */ -); - -/* Gains scalar dequantization, uniform on log scale */ -void silk_gains_dequant( - opus_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */ - const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ - opus_int8 *prev_ind, /* I/O last index in previous frame */ - const opus_int conditional, /* I first gain is delta coded if 1 */ - const opus_int nb_subfr /* I number of subframes */ -); - -/* Compute unique identifier of gain indices vector */ -opus_int32 silk_gains_ID( /* O returns unique identifier of gains */ - const opus_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ - const opus_int nb_subfr /* I number of subframes */ -); - -/* Interpolate two vectors */ -void silk_interpolate( - opus_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */ - const opus_int16 x0[ MAX_LPC_ORDER ], /* I first vector */ - const opus_int16 x1[ MAX_LPC_ORDER ], /* I second vector */ - const opus_int ifact_Q2, /* I interp. factor, weight on 2nd vector */ - const opus_int d /* I number of parameters */ -); - -/* LTP tap quantizer */ -void silk_quant_LTP_gains( - opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ - opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ - opus_int8 *periodicity_index, /* O Periodicity Index */ - opus_int32 *sum_gain_dB_Q7, /* I/O Cumulative max prediction gain */ - opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */ - const opus_int32 XX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation matrix in Q18 */ - const opus_int32 xX_Q17[ MAX_NB_SUBFR*LTP_ORDER ], /* I Correlation vector in Q18 */ - const opus_int subfr_len, /* I Number of samples per subframe */ - const opus_int nb_subfr, /* I Number of subframes */ - int arch /* I Run-time architecture */ -); - -/* Entropy constrained matrix-weighted VQ, for a single input data vector */ -void silk_VQ_WMat_EC_c( - opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *res_nrg_Q15, /* O best residual energy */ - opus_int32 *rate_dist_Q8, /* O best total bitrate */ - opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ - const opus_int32 *XX_Q17, /* I correlation matrix */ - const opus_int32 *xX_Q17, /* I correlation vector */ - const opus_int8 *cb_Q7, /* I codebook */ - const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ - const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int subfr_len, /* I number of samples per subframe */ - const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ - const opus_int L /* I number of vectors in codebook */ -); - -#if !defined(OVERRIDE_silk_VQ_WMat_EC) -#define silk_VQ_WMat_EC(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, subfr_len, max_gain_Q7, L, arch) \ - ((void)(arch),silk_VQ_WMat_EC_c(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, subfr_len, max_gain_Q7, L)) -#endif - -/************************************/ -/* Noise shaping quantization (NSQ) */ -/************************************/ - -void silk_NSQ_c( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -); - -#if !defined(OVERRIDE_silk_NSQ) -#define silk_NSQ(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ - ((void)(arch),silk_NSQ_c(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) -#endif - -/* Noise shaping using delayed decision */ -void silk_NSQ_del_dec_c( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -); - -#if !defined(OVERRIDE_silk_NSQ_del_dec) -#define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ - ((void)(arch),silk_NSQ_del_dec_c(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) -#endif - -/************/ -/* Silk VAD */ -/************/ -/* Initialize the Silk VAD */ -opus_int silk_VAD_Init( /* O Return value, 0 if success */ - silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ -); - -/* Get speech activity level in Q8 */ -opus_int silk_VAD_GetSA_Q8_c( /* O Return value, 0 if success */ - silk_encoder_state *psEncC, /* I/O Encoder state */ - const opus_int16 pIn[] /* I PCM input */ -); - -#if !defined(OVERRIDE_silk_VAD_GetSA_Q8) -#define silk_VAD_GetSA_Q8(psEnC, pIn, arch) ((void)(arch),silk_VAD_GetSA_Q8_c(psEnC, pIn)) -#endif - -/* Low-pass filter with variable cutoff frequency based on */ -/* piece-wise linear interpolation between elliptic filters */ -/* Start by setting transition_frame_no = 1; */ -void silk_LP_variable_cutoff( - silk_LP_state *psLP, /* I/O LP filter state */ - opus_int16 *frame, /* I/O Low-pass filtered output signal */ - const opus_int frame_length /* I Frame length */ -); - -/******************/ -/* NLSF Quantizer */ -/******************/ -/* Limit, stabilize, convert and quantize NLSFs */ -void silk_process_NLSFs( - silk_encoder_state *psEncC, /* I/O Encoder state */ - opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ - opus_int16 pNLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ - const opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ -); - -opus_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */ - opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - opus_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */ - const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ - const opus_int16 *pW_QW, /* I NLSF weight vector [ LPC_ORDER ] */ - const opus_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */ - const opus_int nSurvivors, /* I Max survivors after first stage */ - const opus_int signalType /* I Signal type: 0/1/2 */ -); - -/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */ -void silk_NLSF_VQ( - opus_int32 err_Q26[], /* O Quantization errors [K] */ - const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */ - const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */ - const opus_int16 pWght_Q9[], /* I Codebook weights [K*LPC_order] */ - const opus_int K, /* I Number of codebook vectors */ - const opus_int LPC_order /* I Number of LPCs */ -); - -/* Delayed-decision quantizer for NLSF residuals */ -opus_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ - opus_int8 indices[], /* O Quantization indices [ order ] */ - const opus_int16 x_Q10[], /* I Input [ order ] */ - const opus_int16 w_Q5[], /* I Weights [ order ] */ - const opus_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */ - const opus_int16 ec_ix[], /* I Indices to entropy coding tables [ order ] */ - const opus_uint8 ec_rates_Q5[], /* I Rates [] */ - const opus_int quant_step_size_Q16, /* I Quantization step size */ - const opus_int16 inv_quant_step_size_Q6, /* I Inverse quantization step size */ - const opus_int32 mu_Q20, /* I R/D tradeoff */ - const opus_int16 order /* I Number of input values */ -); - -/* Unpack predictor values and indices for entropy coding tables */ -void silk_NLSF_unpack( - opus_int16 ec_ix[], /* O Indices to entropy tables [ LPC_ORDER ] */ - opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */ - const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ - const opus_int CB1_index /* I Index of vector in first LSF codebook */ -); - -/***********************/ -/* NLSF vector decoder */ -/***********************/ -void silk_NLSF_decode( - opus_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */ - opus_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ -); - -/****************************************************/ -/* Decoder Functions */ -/****************************************************/ -opus_int silk_init_decoder( - silk_decoder_state *psDec /* I/O Decoder state pointer */ -); - -/* Set decoder sampling rate */ -opus_int silk_decoder_set_fs( - silk_decoder_state *psDec, /* I/O Decoder state pointer */ - opus_int fs_kHz, /* I Sampling frequency (kHz) */ - opus_int32 fs_API_Hz /* I API Sampling frequency (Hz) */ -); - -/****************/ -/* Decode frame */ -/****************/ -opus_int silk_decode_frame( - silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 pOut[], /* O Pointer to output speech frame */ - opus_int32 *pN, /* O Pointer to size of output frame */ - opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ - opus_int condCoding, /* I The type of conditional coding to use */ - int arch /* I Run-time architecture */ -); - -/* Decode indices from bitstream */ -void silk_decode_indices( - silk_decoder_state *psDec, /* I/O State */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int FrameIndex, /* I Frame number */ - opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -/* Decode parameters from payload */ -void silk_decode_parameters( - silk_decoder_state *psDec, /* I/O State */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -/* Core decoder. Performs inverse NSQ operation LTP + LPC */ -void silk_decode_core( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I Decoder control */ - opus_int16 xq[], /* O Decoded speech */ - const opus_int16 pulses[ MAX_FRAME_LENGTH ], /* I Pulse signal */ - int arch /* I Run-time architecture */ -); - -/* Decode quantization indices of excitation (Shell coding) */ -void silk_decode_pulses( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int16 pulses[], /* O Excitation signal */ - const opus_int signalType, /* I Sigtype */ - const opus_int quantOffsetType, /* I quantOffsetType */ - const opus_int frame_length /* I Frame length */ -); - -/******************/ -/* CNG */ -/******************/ - -/* Reset CNG */ -void silk_CNG_Reset( - silk_decoder_state *psDec /* I/O Decoder state */ -); - -/* Updates CNG estimate, and applies the CNG when packet was lost */ -void silk_CNG( - silk_decoder_state *psDec, /* I/O Decoder state */ - silk_decoder_control *psDecCtrl, /* I/O Decoder control */ - opus_int16 frame[], /* I/O Signal */ - opus_int length /* I Length of residual */ -); - -/* Encoding of various parameters */ -void silk_encode_indices( - silk_encoder_state *psEncC, /* I/O Encoder state */ - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int FrameIndex, /* I Frame number */ - opus_int encode_LBRR, /* I Flag indicating LBRR data is being encoded */ - opus_int condCoding /* I The type of conditional coding to use */ -); - -#endif diff --git a/Engine/lib/opus/silk/meson.build b/Engine/lib/opus/silk/meson.build deleted file mode 100644 index 917048b2d..000000000 --- a/Engine/lib/opus/silk/meson.build +++ /dev/null @@ -1,63 +0,0 @@ -silk_sources = sources['SILK_SOURCES'] - -silk_sources_sse4_1 = sources['SILK_SOURCES_SSE4_1'] - -silk_sources_neon_intr = sources['SILK_SOURCES_ARM_NEON_INTR'] - -silk_sources_fixed_neon_intr = sources['SILK_SOURCES_FIXED_ARM_NEON_INTR'] - -silk_sources_fixed = sources['SILK_SOURCES_FIXED'] - -silk_sources_fixed_sse4_1 = sources['SILK_SOURCES_FIXED_SSE4_1'] - -silk_sources_float = sources['SILK_SOURCES_FLOAT'] - -if opt_fixed_point - silk_sources += silk_sources_fixed -else - silk_sources += silk_sources_float -endif - -silk_includes = [opus_includes, include_directories('float', 'fixed')] -silk_static_libs = [] - -if host_cpu_family in ['x86', 'x86_64'] and opus_conf.has('OPUS_HAVE_RTCD') - silk_sources += sources['SILK_SOURCES_X86_RTCD'] -endif - -if host_cpu_family in ['arm', 'aarch64'] and have_arm_intrinsics_or_asm - if opus_conf.has('OPUS_HAVE_RTCD') - silk_sources += sources['SILK_SOURCES_ARM_RTCD'] - endif -endif - -foreach intr_name : ['sse4_1', 'neon_intr'] - have_intr = get_variable('have_' + intr_name) - if not have_intr - continue - endif - - intr_sources = get_variable('silk_sources_' + intr_name) - if opt_fixed_point - intr_sources += get_variable('silk_sources_fixed_' + intr_name) - endif - - intr_args = get_variable('opus_@0@_args'.format(intr_name), []) - silk_static_libs += static_library('silk_' + intr_name, intr_sources, - c_args: intr_args, - include_directories: silk_includes, - install: false) -endforeach - -silk_c_args = [] -if host_machine.system() == 'windows' - silk_c_args += ['-DDLL_EXPORT'] -endif - -silk_lib = static_library('opus-silk', - silk_sources, - c_args: silk_c_args, - include_directories: silk_includes, - link_whole: silk_static_libs, - dependencies: libm, - install: false) diff --git a/Engine/lib/opus/silk/mips/NSQ_del_dec_mipsr1.h b/Engine/lib/opus/silk/mips/NSQ_del_dec_mipsr1.h deleted file mode 100644 index cd70713a8..000000000 --- a/Engine/lib/opus/silk/mips/NSQ_del_dec_mipsr1.h +++ /dev/null @@ -1,410 +0,0 @@ -/*********************************************************************** -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 __NSQ_DEL_DEC_MIPSR1_H__ -#define __NSQ_DEL_DEC_MIPSR1_H__ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "main.h" -#include "stack_alloc.h" - -#define OVERRIDE_silk_noise_shape_quantizer_del_dec -static inline void silk_noise_shape_quantizer_del_dec( - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP filter state */ - opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int subfr, /* I Subframe number */ - opus_int shapingLPCOrder, /* I Shaping LPC filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - opus_int warping_Q16, /* I */ - opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ - opus_int *smpl_buf_idx, /* I/O Index to newest samples in buffers */ - opus_int decisionDelay, /* I */ - int arch /* I */ -) -{ - opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; - opus_int32 Winner_rand_state; - opus_int32 LTP_pred_Q14, LPC_pred_Q14, n_AR_Q14, n_LTP_Q14; - opus_int32 n_LF_Q14, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10; - opus_int32 q1_Q0, q1_Q10, q2_Q10, exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10; - opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; - opus_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14; - NSQ_sample_struct psSampleState[ MAX_DEL_DEC_STATES ][ 2 ]; - NSQ_del_dec_struct *psDD; - NSQ_sample_struct *psSS; - opus_int16 b_Q14_0, b_Q14_1, b_Q14_2, b_Q14_3, b_Q14_4; - opus_int16 a_Q12_0, a_Q12_1, a_Q12_2, a_Q12_3, a_Q12_4, a_Q12_5, a_Q12_6; - opus_int16 a_Q12_7, a_Q12_8, a_Q12_9, a_Q12_10, a_Q12_11, a_Q12_12, a_Q12_13; - opus_int16 a_Q12_14, a_Q12_15; - - opus_int32 cur, prev, next; - - /*Unused.*/ - (void)arch; - - //Intialize b_Q14 variables - b_Q14_0 = b_Q14[ 0 ]; - b_Q14_1 = b_Q14[ 1 ]; - b_Q14_2 = b_Q14[ 2 ]; - b_Q14_3 = b_Q14[ 3 ]; - b_Q14_4 = b_Q14[ 4 ]; - - //Intialize a_Q12 variables - a_Q12_0 = a_Q12[0]; - a_Q12_1 = a_Q12[1]; - a_Q12_2 = a_Q12[2]; - a_Q12_3 = a_Q12[3]; - a_Q12_4 = a_Q12[4]; - a_Q12_5 = a_Q12[5]; - a_Q12_6 = a_Q12[6]; - a_Q12_7 = a_Q12[7]; - a_Q12_8 = a_Q12[8]; - a_Q12_9 = a_Q12[9]; - a_Q12_10 = a_Q12[10]; - a_Q12_11 = a_Q12[11]; - a_Q12_12 = a_Q12[12]; - a_Q12_13 = a_Q12[13]; - a_Q12_14 = a_Q12[14]; - a_Q12_15 = a_Q12[15]; - - long long temp64; - - silk_assert( nStatesDelayedDecision > 0 ); - - shp_lag_ptr = &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ]; - pred_lag_ptr = &sLTP_Q15[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ]; - Gain_Q10 = silk_RSHIFT( Gain_Q16, 6 ); - - for( i = 0; i < length; i++ ) { - /* Perform common calculations used in all states */ - - /* Long-term prediction */ - if( signalType == TYPE_VOICED ) { - /* Unrolled loop */ - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - temp64 = __builtin_mips_mult(pred_lag_ptr[ 0 ], b_Q14_0 ); - temp64 = __builtin_mips_madd( temp64, pred_lag_ptr[ -1 ], b_Q14_1 ); - temp64 = __builtin_mips_madd( temp64, pred_lag_ptr[ -2 ], b_Q14_2 ); - temp64 = __builtin_mips_madd( temp64, pred_lag_ptr[ -3 ], b_Q14_3 ); - temp64 = __builtin_mips_madd( temp64, pred_lag_ptr[ -4 ], b_Q14_4 ); - temp64 += 32768; - LTP_pred_Q14 = __builtin_mips_extr_w(temp64, 16); - LTP_pred_Q14 = silk_LSHIFT( LTP_pred_Q14, 1 ); /* Q13 -> Q14 */ - pred_lag_ptr++; - } else { - LTP_pred_Q14 = 0; - } - - /* Long-term shaping */ - if( lag > 0 ) { - /* Symmetric, packed FIR coefficients */ - n_LTP_Q14 = silk_SMULWB( silk_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = silk_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = silk_SUB_LSHIFT32( LTP_pred_Q14, n_LTP_Q14, 2 ); /* Q12 -> Q14 */ - shp_lag_ptr++; - } else { - n_LTP_Q14 = 0; - } - - for( k = 0; k < nStatesDelayedDecision; k++ ) { - /* Delayed decision state */ - psDD = &psDelDec[ k ]; - - /* Sample state */ - psSS = psSampleState[ k ]; - - /* Generate dither */ - psDD->Seed = silk_RAND( psDD->Seed ); - - /* Pointer used in short term prediction and shaping */ - psLPC_Q14 = &psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 + i ]; - /* Short-term prediction */ - silk_assert( predictLPCOrder == 10 || predictLPCOrder == 16 ); - temp64 = __builtin_mips_mult(psLPC_Q14[ 0 ], a_Q12_0 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -1 ], a_Q12_1 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -2 ], a_Q12_2 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -3 ], a_Q12_3 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -4 ], a_Q12_4 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -5 ], a_Q12_5 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -6 ], a_Q12_6 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -7 ], a_Q12_7 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -8 ], a_Q12_8 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -9 ], a_Q12_9 ); - if( predictLPCOrder == 16 ) { - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -10 ], a_Q12_10 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -11 ], a_Q12_11 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -12 ], a_Q12_12 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -13 ], a_Q12_13 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -14 ], a_Q12_14 ); - temp64 = __builtin_mips_madd( temp64, psLPC_Q14[ -15 ], a_Q12_15 ); - } - temp64 += 32768; - LPC_pred_Q14 = __builtin_mips_extr_w(temp64, 16); - - LPC_pred_Q14 = silk_LSHIFT( LPC_pred_Q14, 4 ); /* Q10 -> Q14 */ - - /* Noise shape feedback */ - silk_assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */ - /* Output of lowpass section */ - tmp2 = silk_SMLAWB( psLPC_Q14[ 0 ], psDD->sAR2_Q14[ 0 ], warping_Q16 ); - /* Output of allpass section */ - tmp1 = silk_SMLAWB( psDD->sAR2_Q14[ 0 ], psDD->sAR2_Q14[ 1 ] - tmp2, warping_Q16 ); - psDD->sAR2_Q14[ 0 ] = tmp2; - - temp64 = __builtin_mips_mult(tmp2, AR_shp_Q13[ 0 ] ); - - prev = psDD->sAR2_Q14[ 1 ]; - - /* Loop over allpass sections */ - for( j = 2; j < shapingLPCOrder; j += 2 ) { - cur = psDD->sAR2_Q14[ j ]; - next = psDD->sAR2_Q14[ j+1 ]; - /* Output of allpass section */ - tmp2 = silk_SMLAWB( prev, cur - tmp1, warping_Q16 ); - psDD->sAR2_Q14[ j - 1 ] = tmp1; - temp64 = __builtin_mips_madd( temp64, tmp1, AR_shp_Q13[ j - 1 ] ); - temp64 = __builtin_mips_madd( temp64, tmp2, AR_shp_Q13[ j ] ); - /* Output of allpass section */ - tmp1 = silk_SMLAWB( cur, next - tmp2, warping_Q16 ); - psDD->sAR2_Q14[ j + 0 ] = tmp2; - prev = next; - } - psDD->sAR2_Q14[ shapingLPCOrder - 1 ] = tmp1; - temp64 = __builtin_mips_madd( temp64, tmp1, AR_shp_Q13[ shapingLPCOrder - 1 ] ); - temp64 += 32768; - n_AR_Q14 = __builtin_mips_extr_w(temp64, 16); - n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 1 ); /* Q11 -> Q12 */ - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, psDD->LF_AR_Q14, Tilt_Q14 ); /* Q12 */ - n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 2 ); /* Q12 -> Q14 */ - - n_LF_Q14 = silk_SMULWB( psDD->Shape_Q14[ *smpl_buf_idx ], LF_shp_Q14 ); /* Q12 */ - n_LF_Q14 = silk_SMLAWT( n_LF_Q14, psDD->LF_AR_Q14, LF_shp_Q14 ); /* Q12 */ - n_LF_Q14 = silk_LSHIFT( n_LF_Q14, 2 ); /* Q12 -> Q14 */ - - /* Input minus prediction plus noise feedback */ - /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP */ - tmp1 = silk_ADD32( n_AR_Q14, n_LF_Q14 ); /* Q14 */ - tmp2 = silk_ADD32( n_LTP_Q14, LPC_pred_Q14 ); /* Q13 */ - tmp1 = silk_SUB32( tmp2, tmp1 ); /* Q13 */ - tmp1 = silk_RSHIFT_ROUND( tmp1, 4 ); /* Q10 */ - - r_Q10 = silk_SUB32( x_Q10[ i ], tmp1 ); /* residual error Q10 */ - - /* Flip sign depending on dither */ - if ( psDD->Seed < 0 ) { - r_Q10 = -r_Q10; - } - r_Q10 = silk_LIMIT_32( r_Q10, -(31 << 10), 30 << 10 ); - - /* Find two quantization level candidates and measure their rate-distortion */ - q1_Q10 = silk_SUB32( r_Q10, offset_Q10 ); - q1_Q0 = silk_RSHIFT( q1_Q10, 10 ); - if( q1_Q0 > 0 ) { - q1_Q10 = silk_SUB32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); - q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); - q2_Q10 = silk_ADD32( q1_Q10, 1024 ); - rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else if( q1_Q0 == 0 ) { - q1_Q10 = offset_Q10; - q2_Q10 = silk_ADD32( q1_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); - rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else if( q1_Q0 == -1 ) { - q2_Q10 = offset_Q10; - q1_Q10 = silk_SUB32( q2_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); - rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else { /* q1_Q0 < -1 */ - q1_Q10 = silk_ADD32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); - q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); - q2_Q10 = silk_ADD32( q1_Q10, 1024 ); - rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( -q2_Q10, Lambda_Q10 ); - } - rr_Q10 = silk_SUB32( r_Q10, q1_Q10 ); - rd1_Q10 = silk_RSHIFT( silk_SMLABB( rd1_Q10, rr_Q10, rr_Q10 ), 10 ); - rr_Q10 = silk_SUB32( r_Q10, q2_Q10 ); - rd2_Q10 = silk_RSHIFT( silk_SMLABB( rd2_Q10, rr_Q10, rr_Q10 ), 10 ); - - if( rd1_Q10 < rd2_Q10 ) { - psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); - psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); - psSS[ 0 ].Q_Q10 = q1_Q10; - psSS[ 1 ].Q_Q10 = q2_Q10; - } else { - psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); - psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); - psSS[ 0 ].Q_Q10 = q2_Q10; - psSS[ 1 ].Q_Q10 = q1_Q10; - } - - /* Update states for best quantization */ - - /* Quantized excitation */ - exc_Q14 = silk_LSHIFT32( psSS[ 0 ].Q_Q10, 4 ); - if ( psDD->Seed < 0 ) { - exc_Q14 = -exc_Q14; - } - - /* Add predictions */ - LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); - xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); - - /* Update states */ - sLF_AR_shp_Q14 = silk_SUB32( xq_Q14, n_AR_Q14 ); - psSS[ 0 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 ); - psSS[ 0 ].LF_AR_Q14 = sLF_AR_shp_Q14; - psSS[ 0 ].LPC_exc_Q14 = LPC_exc_Q14; - psSS[ 0 ].xq_Q14 = xq_Q14; - - /* Update states for second best quantization */ - - /* Quantized excitation */ - exc_Q14 = silk_LSHIFT32( psSS[ 1 ].Q_Q10, 4 ); - if ( psDD->Seed < 0 ) { - exc_Q14 = -exc_Q14; - } - - - /* Add predictions */ - LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); - xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); - - /* Update states */ - sLF_AR_shp_Q14 = silk_SUB32( xq_Q14, n_AR_Q14 ); - psSS[ 1 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 ); - psSS[ 1 ].LF_AR_Q14 = sLF_AR_shp_Q14; - psSS[ 1 ].LPC_exc_Q14 = LPC_exc_Q14; - psSS[ 1 ].xq_Q14 = xq_Q14; - } - - *smpl_buf_idx = ( *smpl_buf_idx - 1 ) % DECISION_DELAY; - if( *smpl_buf_idx < 0 ) *smpl_buf_idx += DECISION_DELAY; - last_smple_idx = ( *smpl_buf_idx + decisionDelay ) % DECISION_DELAY; - - /* Find winner */ - RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; - Winner_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ k ][ 0 ].RD_Q10; - Winner_ind = k; - } - } - - /* Increase RD values of expired states */ - Winner_rand_state = psDelDec[ Winner_ind ].RandState[ last_smple_idx ]; - for( k = 0; k < nStatesDelayedDecision; k++ ) { - if( psDelDec[ k ].RandState[ last_smple_idx ] != Winner_rand_state ) { - psSampleState[ k ][ 0 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 0 ].RD_Q10, silk_int32_MAX >> 4 ); - psSampleState[ k ][ 1 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 1 ].RD_Q10, silk_int32_MAX >> 4 ); - silk_assert( psSampleState[ k ][ 0 ].RD_Q10 >= 0 ); - } - } - - /* Find worst in first set and best in second set */ - RDmax_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; - RDmin_Q10 = psSampleState[ 0 ][ 1 ].RD_Q10; - RDmax_ind = 0; - RDmin_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - /* find worst in first set */ - if( psSampleState[ k ][ 0 ].RD_Q10 > RDmax_Q10 ) { - RDmax_Q10 = psSampleState[ k ][ 0 ].RD_Q10; - RDmax_ind = k; - } - /* find best in second set */ - if( psSampleState[ k ][ 1 ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ k ][ 1 ].RD_Q10; - RDmin_ind = k; - } - } - - /* Replace a state if best from second set outperforms worst in first set */ - if( RDmin_Q10 < RDmax_Q10 ) { - silk_memcpy( ( (opus_int32 *)&psDelDec[ RDmax_ind ] ) + i, - ( (opus_int32 *)&psDelDec[ RDmin_ind ] ) + i, sizeof( NSQ_del_dec_struct ) - i * sizeof( opus_int32) ); - silk_memcpy( &psSampleState[ RDmax_ind ][ 0 ], &psSampleState[ RDmin_ind ][ 1 ], sizeof( NSQ_sample_struct ) ); - } - - /* Write samples from winner to output and long-term filter states */ - psDD = &psDelDec[ Winner_ind ]; - if( subfr > 0 || i >= decisionDelay ) { - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); - xq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( - silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], delayedGain_Q10[ last_smple_idx ] ), 8 ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDD->Shape_Q14[ last_smple_idx ]; - sLTP_Q15[ NSQ->sLTP_buf_idx - decisionDelay ] = psDD->Pred_Q15[ last_smple_idx ]; - } - NSQ->sLTP_shp_buf_idx++; - NSQ->sLTP_buf_idx++; - - /* Update states */ - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - psSS = &psSampleState[ k ][ 0 ]; - psDD->LF_AR_Q14 = psSS->LF_AR_Q14; - psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH + i ] = psSS->xq_Q14; - psDD->Xq_Q14[ *smpl_buf_idx ] = psSS->xq_Q14; - psDD->Q_Q10[ *smpl_buf_idx ] = psSS->Q_Q10; - psDD->Pred_Q15[ *smpl_buf_idx ] = silk_LSHIFT32( psSS->LPC_exc_Q14, 1 ); - psDD->Shape_Q14[ *smpl_buf_idx ] = psSS->sLTP_shp_Q14; - psDD->Seed = silk_ADD32_ovflw( psDD->Seed, silk_RSHIFT_ROUND( psSS->Q_Q10, 10 ) ); - psDD->RandState[ *smpl_buf_idx ] = psDD->Seed; - psDD->RD_Q10 = psSS->RD_Q10; - } - delayedGain_Q10[ *smpl_buf_idx ] = Gain_Q10; - } - /* Update LPC states */ - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - silk_memcpy( psDD->sLPC_Q14, &psDD->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); - } -} - -#endif /* __NSQ_DEL_DEC_MIPSR1_H__ */ diff --git a/Engine/lib/opus/silk/mips/macros_mipsr1.h b/Engine/lib/opus/silk/mips/macros_mipsr1.h deleted file mode 100644 index 12ed981a6..000000000 --- a/Engine/lib/opus/silk/mips/macros_mipsr1.h +++ /dev/null @@ -1,92 +0,0 @@ -/*********************************************************************** -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 __SILK_MACROS_MIPSR1_H__ -#define __SILK_MACROS_MIPSR1_H__ - -#define mips_clz(x) __builtin_clz(x) - -#undef silk_SMULWB -static inline int silk_SMULWB(int a, int b) -{ - long long ac; - int c; - - ac = __builtin_mips_mult(a, (opus_int32)(opus_int16)b); - c = __builtin_mips_extr_w(ac, 16); - - return c; -} - -#undef silk_SMLAWB -#define silk_SMLAWB(a32, b32, c32) ((a32) + silk_SMULWB(b32, c32)) - -#undef silk_SMULWW -static inline int silk_SMULWW(int a, int b) -{ - long long ac; - int c; - - ac = __builtin_mips_mult(a, b); - c = __builtin_mips_extr_w(ac, 16); - - return c; -} - -#undef silk_SMLAWW -static inline int silk_SMLAWW(int a, int b, int c) -{ - long long ac; - int res; - - ac = __builtin_mips_mult(b, c); - res = __builtin_mips_extr_w(ac, 16); - res += a; - - return res; -} - -#define OVERRIDE_silk_CLZ16 -static inline opus_int32 silk_CLZ16(opus_int16 in16) -{ - int re32; - opus_int32 in32 = (opus_int32 )in16; - re32 = mips_clz(in32); - re32-=16; - return re32; -} - -#define OVERRIDE_silk_CLZ32 -static inline opus_int32 silk_CLZ32(opus_int32 in32) -{ - int re32; - re32 = mips_clz(in32); - return re32; -} - -#endif /* __SILK_MACROS_MIPSR1_H__ */ diff --git a/Engine/lib/opus/silk/mips/sigproc_fix_mipsr1.h b/Engine/lib/opus/silk/mips/sigproc_fix_mipsr1.h deleted file mode 100644 index 51520c0a6..000000000 --- a/Engine/lib/opus/silk/mips/sigproc_fix_mipsr1.h +++ /dev/null @@ -1,60 +0,0 @@ -/*********************************************************************** -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 SILK_SIGPROC_FIX_MIPSR1_H -#define SILK_SIGPROC_FIX_MIPSR1_H - -#undef silk_SAT16 -static inline short int silk_SAT16(int a) -{ - int c; - c = __builtin_mips_shll_s_w(a, 16); - c = c>>16; - - return c; -} - -#undef silk_LSHIFT_SAT32 -static inline int silk_LSHIFT_SAT32(int a, int shift) -{ - int r; - - r = __builtin_mips_shll_s_w(a, shift); - - return r; -} - -#undef silk_RSHIFT_ROUND -static inline int silk_RSHIFT_ROUND(int a, int shift) -{ - int r; - - r = __builtin_mips_shra_r_w(a, shift); - return r; -} - -#endif /* SILK_SIGPROC_FIX_MIPSR1_H */ diff --git a/Engine/lib/opus/silk/pitch_est_defines.h b/Engine/lib/opus/silk/pitch_est_defines.h deleted file mode 100644 index e1e4b5d76..000000000 --- a/Engine/lib/opus/silk/pitch_est_defines.h +++ /dev/null @@ -1,88 +0,0 @@ -/*********************************************************************** -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 SILK_PE_DEFINES_H -#define SILK_PE_DEFINES_H - -#include "SigProc_FIX.h" - -/********************************************************/ -/* Definitions for pitch estimator */ -/********************************************************/ - -#define PE_MAX_FS_KHZ 16 /* Maximum sampling frequency used */ - -#define PE_MAX_NB_SUBFR 4 -#define PE_SUBFR_LENGTH_MS 5 /* 5 ms */ - -#define PE_LTP_MEM_LENGTH_MS ( 4 * PE_SUBFR_LENGTH_MS ) - -#define PE_MAX_FRAME_LENGTH_MS ( PE_LTP_MEM_LENGTH_MS + PE_MAX_NB_SUBFR * PE_SUBFR_LENGTH_MS ) -#define PE_MAX_FRAME_LENGTH ( PE_MAX_FRAME_LENGTH_MS * PE_MAX_FS_KHZ ) -#define PE_MAX_FRAME_LENGTH_ST_1 ( PE_MAX_FRAME_LENGTH >> 2 ) -#define PE_MAX_FRAME_LENGTH_ST_2 ( PE_MAX_FRAME_LENGTH >> 1 ) - -#define PE_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */ -#define PE_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */ -#define PE_MAX_LAG ( PE_MAX_LAG_MS * PE_MAX_FS_KHZ ) -#define PE_MIN_LAG ( PE_MIN_LAG_MS * PE_MAX_FS_KHZ ) - -#define PE_D_SRCH_LENGTH 24 - -#define PE_NB_STAGE3_LAGS 5 - -#define PE_NB_CBKS_STAGE2 3 -#define PE_NB_CBKS_STAGE2_EXT 11 - -#define PE_NB_CBKS_STAGE3_MAX 34 -#define PE_NB_CBKS_STAGE3_MID 24 -#define PE_NB_CBKS_STAGE3_MIN 16 - -#define PE_NB_CBKS_STAGE3_10MS 12 -#define PE_NB_CBKS_STAGE2_10MS 3 - -#define PE_SHORTLAG_BIAS 0.2f /* for logarithmic weighting */ -#define PE_PREVLAG_BIAS 0.2f /* for logarithmic weighting */ -#define PE_FLATCONTOUR_BIAS 0.05f - -#define SILK_PE_MIN_COMPLEX 0 -#define SILK_PE_MID_COMPLEX 1 -#define SILK_PE_MAX_COMPLEX 2 - -/* Tables for 20 ms frames */ -extern const opus_int8 silk_CB_lags_stage2[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE2_EXT ]; -extern const opus_int8 silk_CB_lags_stage3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ]; -extern const opus_int8 silk_Lag_range_stage3[ SILK_PE_MAX_COMPLEX + 1 ] [ PE_MAX_NB_SUBFR ][ 2 ]; -extern const opus_int8 silk_nb_cbk_searchs_stage3[ SILK_PE_MAX_COMPLEX + 1 ]; - -/* Tables for 10 ms frames */ -extern const opus_int8 silk_CB_lags_stage2_10_ms[ PE_MAX_NB_SUBFR >> 1][ 3 ]; -extern const opus_int8 silk_CB_lags_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 12 ]; -extern const opus_int8 silk_Lag_range_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 2 ]; - -#endif - diff --git a/Engine/lib/opus/silk/pitch_est_tables.c b/Engine/lib/opus/silk/pitch_est_tables.c deleted file mode 100644 index 81a8bacac..000000000 --- a/Engine/lib/opus/silk/pitch_est_tables.c +++ /dev/null @@ -1,99 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "typedef.h" -#include "pitch_est_defines.h" - -const opus_int8 silk_CB_lags_stage2_10_ms[ PE_MAX_NB_SUBFR >> 1][ PE_NB_CBKS_STAGE2_10MS ] = -{ - {0, 1, 0}, - {0, 0, 1} -}; - -const opus_int8 silk_CB_lags_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ PE_NB_CBKS_STAGE3_10MS ] = -{ - { 0, 0, 1,-1, 1,-1, 2,-2, 2,-2, 3,-3}, - { 0, 1, 0, 1,-1, 2,-1, 2,-2, 3,-2, 3} -}; - -const opus_int8 silk_Lag_range_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 2 ] = -{ - {-3, 7}, - {-2, 7} -}; - -const opus_int8 silk_CB_lags_stage2[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE2_EXT ] = -{ - {0, 2,-1,-1,-1, 0, 0, 1, 1, 0, 1}, - {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0}, - {0,-1, 2, 1, 0, 1, 1, 0, 0,-1,-1} -}; - -const opus_int8 silk_CB_lags_stage3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ] = -{ - {0, 0, 1,-1, 0, 1,-1, 0,-1, 1,-2, 2,-2,-2, 2,-3, 2, 3,-3,-4, 3,-4, 4, 4,-5, 5,-6,-5, 6,-7, 6, 5, 8,-9}, - {0, 0, 1, 0, 0, 0, 0, 0, 0, 0,-1, 1, 0, 0, 1,-1, 0, 1,-1,-1, 1,-1, 2, 1,-1, 2,-2,-2, 2,-2, 2, 2, 3,-3}, - {0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1,-1, 1, 0, 0, 2, 1,-1, 2,-1,-1, 2,-1, 2, 2,-1, 3,-2,-2,-2, 3}, - {0, 1, 0, 0, 1, 0, 1,-1, 2,-1, 2,-1, 2, 3,-2, 3,-2,-2, 4, 4,-3, 5,-3,-4, 6,-4, 6, 5,-5, 8,-6,-5,-7, 9} -}; - -const opus_int8 silk_Lag_range_stage3[ SILK_PE_MAX_COMPLEX + 1 ] [ PE_MAX_NB_SUBFR ][ 2 ] = -{ - /* Lags to search for low number of stage3 cbks */ - { - {-5,8}, - {-1,6}, - {-1,6}, - {-4,10} - }, - /* Lags to search for middle number of stage3 cbks */ - { - {-6,10}, - {-2,6}, - {-1,6}, - {-5,10} - }, - /* Lags to search for max number of stage3 cbks */ - { - {-9,12}, - {-3,7}, - {-2,7}, - {-7,13} - } -}; - -const opus_int8 silk_nb_cbk_searchs_stage3[ SILK_PE_MAX_COMPLEX + 1 ] = -{ - PE_NB_CBKS_STAGE3_MIN, - PE_NB_CBKS_STAGE3_MID, - PE_NB_CBKS_STAGE3_MAX -}; diff --git a/Engine/lib/opus/silk/process_NLSFs.c b/Engine/lib/opus/silk/process_NLSFs.c deleted file mode 100644 index d13080954..000000000 --- a/Engine/lib/opus/silk/process_NLSFs.c +++ /dev/null @@ -1,107 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Limit, stabilize, convert and quantize NLSFs */ -void silk_process_NLSFs( - silk_encoder_state *psEncC, /* I/O Encoder state */ - opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ - opus_int16 pNLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ - const opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ -) -{ - opus_int i, doInterpolate; - opus_int NLSF_mu_Q20; - opus_int16 i_sqr_Q15; - opus_int16 pNLSF0_temp_Q15[ MAX_LPC_ORDER ]; - opus_int16 pNLSFW_QW[ MAX_LPC_ORDER ]; - opus_int16 pNLSFW0_temp_QW[ MAX_LPC_ORDER ]; - - silk_assert( psEncC->speech_activity_Q8 >= 0 ); - silk_assert( psEncC->speech_activity_Q8 <= SILK_FIX_CONST( 1.0, 8 ) ); - celt_assert( psEncC->useInterpolatedNLSFs == 1 || psEncC->indices.NLSFInterpCoef_Q2 == ( 1 << 2 ) ); - - /***********************/ - /* Calculate mu values */ - /***********************/ - /* NLSF_mu = 0.003 - 0.0015 * psEnc->speech_activity; */ - NLSF_mu_Q20 = silk_SMLAWB( SILK_FIX_CONST( 0.003, 20 ), SILK_FIX_CONST( -0.001, 28 ), psEncC->speech_activity_Q8 ); - if( psEncC->nb_subfr == 2 ) { - /* Multiply by 1.5 for 10 ms packets */ - NLSF_mu_Q20 = silk_ADD_RSHIFT( NLSF_mu_Q20, NLSF_mu_Q20, 1 ); - } - - celt_assert( NLSF_mu_Q20 > 0 ); - silk_assert( NLSF_mu_Q20 <= SILK_FIX_CONST( 0.005, 20 ) ); - - /* Calculate NLSF weights */ - silk_NLSF_VQ_weights_laroia( pNLSFW_QW, pNLSF_Q15, psEncC->predictLPCOrder ); - - /* Update NLSF weights for interpolated NLSFs */ - doInterpolate = ( psEncC->useInterpolatedNLSFs == 1 ) && ( psEncC->indices.NLSFInterpCoef_Q2 < 4 ); - if( doInterpolate ) { - /* Calculate the interpolated NLSF vector for the first half */ - silk_interpolate( pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, - psEncC->indices.NLSFInterpCoef_Q2, psEncC->predictLPCOrder ); - - /* Calculate first half NLSF weights for the interpolated NLSFs */ - silk_NLSF_VQ_weights_laroia( pNLSFW0_temp_QW, pNLSF0_temp_Q15, psEncC->predictLPCOrder ); - - /* Update NLSF weights with contribution from first half */ - i_sqr_Q15 = silk_LSHIFT( silk_SMULBB( psEncC->indices.NLSFInterpCoef_Q2, psEncC->indices.NLSFInterpCoef_Q2 ), 11 ); - for( i = 0; i < psEncC->predictLPCOrder; i++ ) { - pNLSFW_QW[ i ] = silk_ADD16( silk_RSHIFT( pNLSFW_QW[ i ], 1 ), silk_RSHIFT( - silk_SMULBB( pNLSFW0_temp_QW[ i ], i_sqr_Q15 ), 16) ); - silk_assert( pNLSFW_QW[ i ] >= 1 ); - } - } - - silk_NLSF_encode( psEncC->indices.NLSFIndices, pNLSF_Q15, psEncC->psNLSF_CB, pNLSFW_QW, - NLSF_mu_Q20, psEncC->NLSF_MSVQ_Survivors, psEncC->indices.signalType ); - - /* Convert quantized NLSFs back to LPC coefficients */ - silk_NLSF2A( PredCoef_Q12[ 1 ], pNLSF_Q15, psEncC->predictLPCOrder, psEncC->arch ); - - if( doInterpolate ) { - /* Calculate the interpolated, quantized LSF vector for the first half */ - silk_interpolate( pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, - psEncC->indices.NLSFInterpCoef_Q2, psEncC->predictLPCOrder ); - - /* Convert back to LPC coefficients */ - silk_NLSF2A( PredCoef_Q12[ 0 ], pNLSF0_temp_Q15, psEncC->predictLPCOrder, psEncC->arch ); - - } else { - /* Copy LPC coefficients for first half from second half */ - celt_assert( psEncC->predictLPCOrder <= MAX_LPC_ORDER ); - silk_memcpy( PredCoef_Q12[ 0 ], PredCoef_Q12[ 1 ], psEncC->predictLPCOrder * sizeof( opus_int16 ) ); - } -} diff --git a/Engine/lib/opus/silk/quant_LTP_gains.c b/Engine/lib/opus/silk/quant_LTP_gains.c deleted file mode 100644 index d6b8eff8d..000000000 --- a/Engine/lib/opus/silk/quant_LTP_gains.c +++ /dev/null @@ -1,132 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "tuning_parameters.h" - -void silk_quant_LTP_gains( - opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */ - opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ - opus_int8 *periodicity_index, /* O Periodicity Index */ - opus_int32 *sum_log_gain_Q7, /* I/O Cumulative max prediction gain */ - opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */ - const opus_int32 XX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation matrix in Q18 */ - const opus_int32 xX_Q17[ MAX_NB_SUBFR*LTP_ORDER ], /* I Correlation vector in Q18 */ - const opus_int subfr_len, /* I Number of samples per subframe */ - const opus_int nb_subfr, /* I Number of subframes */ - int arch /* I Run-time architecture */ -) -{ - opus_int j, k, cbk_size; - opus_int8 temp_idx[ MAX_NB_SUBFR ]; - const opus_uint8 *cl_ptr_Q5; - const opus_int8 *cbk_ptr_Q7; - const opus_uint8 *cbk_gain_ptr_Q7; - const opus_int32 *XX_Q17_ptr, *xX_Q17_ptr; - opus_int32 res_nrg_Q15_subfr, res_nrg_Q15, rate_dist_Q7_subfr, rate_dist_Q7, min_rate_dist_Q7; - opus_int32 sum_log_gain_tmp_Q7, best_sum_log_gain_Q7, max_gain_Q7; - opus_int gain_Q7; - - /***************************************************/ - /* iterate over different codebooks with different */ - /* rates/distortions, and choose best */ - /***************************************************/ - min_rate_dist_Q7 = silk_int32_MAX; - best_sum_log_gain_Q7 = 0; - for( k = 0; k < 3; k++ ) { - /* Safety margin for pitch gain control, to take into account factors - such as state rescaling/rewhitening. */ - opus_int32 gain_safety = SILK_FIX_CONST( 0.4, 7 ); - - cl_ptr_Q5 = silk_LTP_gain_BITS_Q5_ptrs[ k ]; - cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[ k ]; - cbk_gain_ptr_Q7 = silk_LTP_vq_gain_ptrs_Q7[ k ]; - cbk_size = silk_LTP_vq_sizes[ k ]; - - /* Set up pointers to first subframe */ - XX_Q17_ptr = XX_Q17; - xX_Q17_ptr = xX_Q17; - - res_nrg_Q15 = 0; - rate_dist_Q7 = 0; - sum_log_gain_tmp_Q7 = *sum_log_gain_Q7; - for( j = 0; j < nb_subfr; j++ ) { - max_gain_Q7 = silk_log2lin( ( SILK_FIX_CONST( MAX_SUM_LOG_GAIN_DB / 6.0, 7 ) - sum_log_gain_tmp_Q7 ) - + SILK_FIX_CONST( 7, 7 ) ) - gain_safety; - silk_VQ_WMat_EC( - &temp_idx[ j ], /* O index of best codebook vector */ - &res_nrg_Q15_subfr, /* O residual energy */ - &rate_dist_Q7_subfr, /* O best weighted quantization error + mu * rate */ - &gain_Q7, /* O sum of absolute LTP coefficients */ - XX_Q17_ptr, /* I correlation matrix */ - xX_Q17_ptr, /* I correlation vector */ - cbk_ptr_Q7, /* I codebook */ - cbk_gain_ptr_Q7, /* I codebook effective gains */ - cl_ptr_Q5, /* I code length for each codebook vector */ - subfr_len, /* I number of samples per subframe */ - max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ - cbk_size, /* I number of vectors in codebook */ - arch /* I Run-time architecture */ - ); - - res_nrg_Q15 = silk_ADD_POS_SAT32( res_nrg_Q15, res_nrg_Q15_subfr ); - rate_dist_Q7 = silk_ADD_POS_SAT32( rate_dist_Q7, rate_dist_Q7_subfr ); - sum_log_gain_tmp_Q7 = silk_max(0, sum_log_gain_tmp_Q7 - + silk_lin2log( gain_safety + gain_Q7 ) - SILK_FIX_CONST( 7, 7 )); - - XX_Q17_ptr += LTP_ORDER * LTP_ORDER; - xX_Q17_ptr += LTP_ORDER; - } - - if( rate_dist_Q7 <= min_rate_dist_Q7 ) { - min_rate_dist_Q7 = rate_dist_Q7; - *periodicity_index = (opus_int8)k; - silk_memcpy( cbk_index, temp_idx, nb_subfr * sizeof( opus_int8 ) ); - best_sum_log_gain_Q7 = sum_log_gain_tmp_Q7; - } - } - - cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[ *periodicity_index ]; - for( j = 0; j < nb_subfr; j++ ) { - for( k = 0; k < LTP_ORDER; k++ ) { - B_Q14[ j * LTP_ORDER + k ] = silk_LSHIFT( cbk_ptr_Q7[ cbk_index[ j ] * LTP_ORDER + k ], 7 ); - } - } - - if( nb_subfr == 2 ) { - res_nrg_Q15 = silk_RSHIFT32( res_nrg_Q15, 1 ); - } else { - res_nrg_Q15 = silk_RSHIFT32( res_nrg_Q15, 2 ); - } - - *sum_log_gain_Q7 = best_sum_log_gain_Q7; - *pred_gain_dB_Q7 = (opus_int)silk_SMULBB( -3, silk_lin2log( res_nrg_Q15 ) - ( 15 << 7 ) ); -} diff --git a/Engine/lib/opus/silk/resampler.c b/Engine/lib/opus/silk/resampler.c deleted file mode 100644 index 1f11e5089..000000000 --- a/Engine/lib/opus/silk/resampler.c +++ /dev/null @@ -1,215 +0,0 @@ -/*********************************************************************** -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" -#endif - -/* - * Matrix of resampling methods used: - * Fs_out (kHz) - * 8 12 16 24 48 - * - * 8 C UF U UF UF - * 12 AF C UF U UF - * Fs_in (kHz) 16 D AF C UF UF - * 24 AF D AF C U - * 48 AF AF AF D C - * - * C -> Copy (no resampling) - * D -> Allpass-based 2x downsampling - * U -> Allpass-based 2x upsampling - * UF -> Allpass-based 2x upsampling followed by FIR interpolation - * AF -> AR2 filter followed by FIR interpolation - */ - -#include "resampler_private.h" - -/* Tables with delay compensation values to equalize total delay for different modes */ -static const opus_int8 delay_matrix_enc[ 5 ][ 3 ] = { -/* in \ out 8 12 16 */ -/* 8 */ { 6, 0, 3 }, -/* 12 */ { 0, 7, 3 }, -/* 16 */ { 0, 1, 10 }, -/* 24 */ { 0, 2, 6 }, -/* 48 */ { 18, 10, 12 } -}; - -static const opus_int8 delay_matrix_dec[ 3 ][ 5 ] = { -/* in \ out 8 12 16 24 48 */ -/* 8 */ { 4, 0, 2, 0, 0 }, -/* 12 */ { 0, 9, 4, 7, 4 }, -/* 16 */ { 0, 3, 12, 7, 7 } -}; - -/* Simple way to make [8000, 12000, 16000, 24000, 48000] to [0, 1, 2, 3, 4] */ -#define rateID(R) ( ( ( ((R)>>12) - ((R)>16000) ) >> ((R)>24000) ) - 1 ) - -#define USE_silk_resampler_copy (0) -#define USE_silk_resampler_private_up2_HQ_wrapper (1) -#define USE_silk_resampler_private_IIR_FIR (2) -#define USE_silk_resampler_private_down_FIR (3) - -/* Initialize/reset the resampler state for a given pair of input/output sampling rates */ -opus_int silk_resampler_init( - silk_resampler_state_struct *S, /* I/O Resampler state */ - opus_int32 Fs_Hz_in, /* I Input sampling rate (Hz) */ - opus_int32 Fs_Hz_out, /* I Output sampling rate (Hz) */ - opus_int forEnc /* I If 1: encoder; if 0: decoder */ -) -{ - opus_int up2x; - - /* Clear state */ - silk_memset( S, 0, sizeof( silk_resampler_state_struct ) ); - - /* Input checking */ - if( forEnc ) { - if( ( Fs_Hz_in != 8000 && Fs_Hz_in != 12000 && Fs_Hz_in != 16000 && Fs_Hz_in != 24000 && Fs_Hz_in != 48000 ) || - ( Fs_Hz_out != 8000 && Fs_Hz_out != 12000 && Fs_Hz_out != 16000 ) ) { - celt_assert( 0 ); - return -1; - } - S->inputDelay = delay_matrix_enc[ rateID( Fs_Hz_in ) ][ rateID( Fs_Hz_out ) ]; - } else { - if( ( Fs_Hz_in != 8000 && Fs_Hz_in != 12000 && Fs_Hz_in != 16000 ) || - ( Fs_Hz_out != 8000 && Fs_Hz_out != 12000 && Fs_Hz_out != 16000 && Fs_Hz_out != 24000 && Fs_Hz_out != 48000 ) ) { - celt_assert( 0 ); - return -1; - } - S->inputDelay = delay_matrix_dec[ rateID( Fs_Hz_in ) ][ rateID( Fs_Hz_out ) ]; - } - - S->Fs_in_kHz = silk_DIV32_16( Fs_Hz_in, 1000 ); - S->Fs_out_kHz = silk_DIV32_16( Fs_Hz_out, 1000 ); - - /* Number of samples processed per batch */ - S->batchSize = S->Fs_in_kHz * RESAMPLER_MAX_BATCH_SIZE_MS; - - /* Find resampler with the right sampling ratio */ - up2x = 0; - if( Fs_Hz_out > Fs_Hz_in ) { - /* Upsample */ - if( Fs_Hz_out == silk_MUL( Fs_Hz_in, 2 ) ) { /* Fs_out : Fs_in = 2 : 1 */ - /* Special case: directly use 2x upsampler */ - S->resampler_function = USE_silk_resampler_private_up2_HQ_wrapper; - } else { - /* Default resampler */ - S->resampler_function = USE_silk_resampler_private_IIR_FIR; - up2x = 1; - } - } else if ( Fs_Hz_out < Fs_Hz_in ) { - /* Downsample */ - S->resampler_function = USE_silk_resampler_private_down_FIR; - if( silk_MUL( Fs_Hz_out, 4 ) == silk_MUL( Fs_Hz_in, 3 ) ) { /* Fs_out : Fs_in = 3 : 4 */ - S->FIR_Fracs = 3; - S->FIR_Order = RESAMPLER_DOWN_ORDER_FIR0; - S->Coefs = silk_Resampler_3_4_COEFS; - } else if( silk_MUL( Fs_Hz_out, 3 ) == silk_MUL( Fs_Hz_in, 2 ) ) { /* Fs_out : Fs_in = 2 : 3 */ - S->FIR_Fracs = 2; - S->FIR_Order = RESAMPLER_DOWN_ORDER_FIR0; - S->Coefs = silk_Resampler_2_3_COEFS; - } else if( silk_MUL( Fs_Hz_out, 2 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 2 */ - S->FIR_Fracs = 1; - S->FIR_Order = RESAMPLER_DOWN_ORDER_FIR1; - S->Coefs = silk_Resampler_1_2_COEFS; - } else if( silk_MUL( Fs_Hz_out, 3 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 3 */ - S->FIR_Fracs = 1; - S->FIR_Order = RESAMPLER_DOWN_ORDER_FIR2; - S->Coefs = silk_Resampler_1_3_COEFS; - } else if( silk_MUL( Fs_Hz_out, 4 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 4 */ - S->FIR_Fracs = 1; - S->FIR_Order = RESAMPLER_DOWN_ORDER_FIR2; - S->Coefs = silk_Resampler_1_4_COEFS; - } else if( silk_MUL( Fs_Hz_out, 6 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 6 */ - S->FIR_Fracs = 1; - S->FIR_Order = RESAMPLER_DOWN_ORDER_FIR2; - S->Coefs = silk_Resampler_1_6_COEFS; - } else { - /* None available */ - celt_assert( 0 ); - return -1; - } - } else { - /* Input and output sampling rates are equal: copy */ - S->resampler_function = USE_silk_resampler_copy; - } - - /* Ratio of input/output samples */ - S->invRatio_Q16 = silk_LSHIFT32( silk_DIV32( silk_LSHIFT32( Fs_Hz_in, 14 + up2x ), Fs_Hz_out ), 2 ); - /* Make sure the ratio is rounded up */ - while( silk_SMULWW( S->invRatio_Q16, Fs_Hz_out ) < silk_LSHIFT32( Fs_Hz_in, up2x ) ) { - S->invRatio_Q16++; - } - - return 0; -} - -/* Resampler: convert from one sampling rate to another */ -/* Input and output sampling rate are at most 48000 Hz */ -opus_int silk_resampler( - silk_resampler_state_struct *S, /* I/O Resampler state */ - opus_int16 out[], /* O Output signal */ - const opus_int16 in[], /* I Input signal */ - opus_int32 inLen /* I Number of input samples */ -) -{ - opus_int nSamples; - - /* Need at least 1 ms of input data */ - celt_assert( inLen >= S->Fs_in_kHz ); - /* Delay can't exceed the 1 ms of buffering */ - celt_assert( S->inputDelay <= S->Fs_in_kHz ); - - nSamples = S->Fs_in_kHz - S->inputDelay; - - /* Copy to delay buffer */ - silk_memcpy( &S->delayBuf[ S->inputDelay ], in, nSamples * sizeof( opus_int16 ) ); - - switch( S->resampler_function ) { - case USE_silk_resampler_private_up2_HQ_wrapper: - silk_resampler_private_up2_HQ_wrapper( S, out, S->delayBuf, S->Fs_in_kHz ); - silk_resampler_private_up2_HQ_wrapper( S, &out[ S->Fs_out_kHz ], &in[ nSamples ], inLen - S->Fs_in_kHz ); - break; - case USE_silk_resampler_private_IIR_FIR: - silk_resampler_private_IIR_FIR( S, out, S->delayBuf, S->Fs_in_kHz ); - silk_resampler_private_IIR_FIR( S, &out[ S->Fs_out_kHz ], &in[ nSamples ], inLen - S->Fs_in_kHz ); - break; - case USE_silk_resampler_private_down_FIR: - silk_resampler_private_down_FIR( S, out, S->delayBuf, S->Fs_in_kHz ); - silk_resampler_private_down_FIR( S, &out[ S->Fs_out_kHz ], &in[ nSamples ], inLen - S->Fs_in_kHz ); - break; - default: - silk_memcpy( out, S->delayBuf, S->Fs_in_kHz * sizeof( opus_int16 ) ); - silk_memcpy( &out[ S->Fs_out_kHz ], &in[ nSamples ], ( inLen - S->Fs_in_kHz ) * sizeof( opus_int16 ) ); - } - - /* Copy to delay buffer */ - silk_memcpy( S->delayBuf, &in[ inLen - S->inputDelay ], S->inputDelay * sizeof( opus_int16 ) ); - - return 0; -} diff --git a/Engine/lib/opus/silk/resampler_down2.c b/Engine/lib/opus/silk/resampler_down2.c deleted file mode 100644 index 971d7bfd4..000000000 --- a/Engine/lib/opus/silk/resampler_down2.c +++ /dev/null @@ -1,74 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "resampler_rom.h" - -/* Downsample by a factor 2 */ -void silk_resampler_down2( - opus_int32 *S, /* I/O State vector [ 2 ] */ - opus_int16 *out, /* O Output signal [ floor(len/2) ] */ - const opus_int16 *in, /* I Input signal [ len ] */ - opus_int32 inLen /* I Number of input samples */ -) -{ - opus_int32 k, len2 = silk_RSHIFT32( inLen, 1 ); - opus_int32 in32, out32, Y, X; - - celt_assert( silk_resampler_down2_0 > 0 ); - celt_assert( silk_resampler_down2_1 < 0 ); - - /* Internal variables and state are in Q10 format */ - for( k = 0; k < len2; k++ ) { - /* Convert to Q10 */ - in32 = silk_LSHIFT( (opus_int32)in[ 2 * k ], 10 ); - - /* All-pass section for even input sample */ - Y = silk_SUB32( in32, S[ 0 ] ); - X = silk_SMLAWB( Y, Y, silk_resampler_down2_1 ); - out32 = silk_ADD32( S[ 0 ], X ); - S[ 0 ] = silk_ADD32( in32, X ); - - /* Convert to Q10 */ - in32 = silk_LSHIFT( (opus_int32)in[ 2 * k + 1 ], 10 ); - - /* All-pass section for odd input sample, and add to output of previous section */ - Y = silk_SUB32( in32, S[ 1 ] ); - X = silk_SMULWB( Y, silk_resampler_down2_0 ); - out32 = silk_ADD32( out32, S[ 1 ] ); - out32 = silk_ADD32( out32, X ); - S[ 1 ] = silk_ADD32( in32, X ); - - /* Add, convert back to int16 and store to output */ - out[ k ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( out32, 11 ) ); - } -} - diff --git a/Engine/lib/opus/silk/resampler_down2_3.c b/Engine/lib/opus/silk/resampler_down2_3.c deleted file mode 100644 index 4342614dc..000000000 --- a/Engine/lib/opus/silk/resampler_down2_3.c +++ /dev/null @@ -1,103 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "resampler_private.h" -#include "stack_alloc.h" - -#define ORDER_FIR 4 - -/* Downsample by a factor 2/3, low quality */ -void silk_resampler_down2_3( - opus_int32 *S, /* I/O State vector [ 6 ] */ - opus_int16 *out, /* O Output signal [ floor(2*inLen/3) ] */ - const opus_int16 *in, /* I Input signal [ inLen ] */ - opus_int32 inLen /* I Number of input samples */ -) -{ - opus_int32 nSamplesIn, counter, res_Q6; - VARDECL( opus_int32, buf ); - opus_int32 *buf_ptr; - SAVE_STACK; - - ALLOC( buf, RESAMPLER_MAX_BATCH_SIZE_IN + ORDER_FIR, opus_int32 ); - - /* Copy buffered samples to start of buffer */ - silk_memcpy( buf, S, ORDER_FIR * sizeof( opus_int32 ) ); - - /* Iterate over blocks of frameSizeIn input samples */ - while( 1 ) { - nSamplesIn = silk_min( inLen, RESAMPLER_MAX_BATCH_SIZE_IN ); - - /* Second-order AR filter (output in Q8) */ - silk_resampler_private_AR2( &S[ ORDER_FIR ], &buf[ ORDER_FIR ], in, - silk_Resampler_2_3_COEFS_LQ, nSamplesIn ); - - /* Interpolate filtered signal */ - buf_ptr = buf; - counter = nSamplesIn; - while( counter > 2 ) { - /* Inner product */ - res_Q6 = silk_SMULWB( buf_ptr[ 0 ], silk_Resampler_2_3_COEFS_LQ[ 2 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 1 ], silk_Resampler_2_3_COEFS_LQ[ 3 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 2 ], silk_Resampler_2_3_COEFS_LQ[ 5 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 3 ], silk_Resampler_2_3_COEFS_LQ[ 4 ] ); - - /* Scale down, saturate and store in output array */ - *out++ = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( res_Q6, 6 ) ); - - res_Q6 = silk_SMULWB( buf_ptr[ 1 ], silk_Resampler_2_3_COEFS_LQ[ 4 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 2 ], silk_Resampler_2_3_COEFS_LQ[ 5 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 3 ], silk_Resampler_2_3_COEFS_LQ[ 3 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 4 ], silk_Resampler_2_3_COEFS_LQ[ 2 ] ); - - /* Scale down, saturate and store in output array */ - *out++ = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( res_Q6, 6 ) ); - - buf_ptr += 3; - counter -= 3; - } - - in += nSamplesIn; - inLen -= nSamplesIn; - - if( inLen > 0 ) { - /* More iterations to do; copy last part of filtered signal to beginning of buffer */ - silk_memcpy( buf, &buf[ nSamplesIn ], ORDER_FIR * sizeof( opus_int32 ) ); - } else { - break; - } - } - - /* Copy last part of filtered signal to the state for the next call */ - silk_memcpy( S, &buf[ nSamplesIn ], ORDER_FIR * sizeof( opus_int32 ) ); - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/resampler_private.h b/Engine/lib/opus/silk/resampler_private.h deleted file mode 100644 index 422a7d9d9..000000000 --- a/Engine/lib/opus/silk/resampler_private.h +++ /dev/null @@ -1,88 +0,0 @@ -/*********************************************************************** -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 SILK_RESAMPLER_PRIVATE_H -#define SILK_RESAMPLER_PRIVATE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "SigProc_FIX.h" -#include "resampler_structs.h" -#include "resampler_rom.h" - -/* Number of input samples to process in the inner loop */ -#define RESAMPLER_MAX_BATCH_SIZE_MS 10 -#define RESAMPLER_MAX_FS_KHZ 48 -#define RESAMPLER_MAX_BATCH_SIZE_IN ( RESAMPLER_MAX_BATCH_SIZE_MS * RESAMPLER_MAX_FS_KHZ ) - -/* Description: Hybrid IIR/FIR polyphase implementation of resampling */ -void silk_resampler_private_IIR_FIR( - void *SS, /* I/O Resampler state */ - opus_int16 out[], /* O Output signal */ - const opus_int16 in[], /* I Input signal */ - opus_int32 inLen /* I Number of input samples */ -); - -/* Description: Hybrid IIR/FIR polyphase implementation of resampling */ -void silk_resampler_private_down_FIR( - void *SS, /* I/O Resampler state */ - opus_int16 out[], /* O Output signal */ - const opus_int16 in[], /* I Input signal */ - opus_int32 inLen /* I Number of input samples */ -); - -/* Upsample by a factor 2, high quality */ -void silk_resampler_private_up2_HQ_wrapper( - void *SS, /* I/O Resampler state (unused) */ - opus_int16 *out, /* O Output signal [ 2 * len ] */ - const opus_int16 *in, /* I Input signal [ len ] */ - opus_int32 len /* I Number of input samples */ -); - -/* Upsample by a factor 2, high quality */ -void silk_resampler_private_up2_HQ( - opus_int32 *S, /* I/O Resampler state [ 6 ] */ - opus_int16 *out, /* O Output signal [ 2 * len ] */ - const opus_int16 *in, /* I Input signal [ len ] */ - opus_int32 len /* I Number of input samples */ -); - -/* Second order AR filter */ -void silk_resampler_private_AR2( - opus_int32 S[], /* I/O State vector [ 2 ] */ - opus_int32 out_Q8[], /* O Output signal */ - const opus_int16 in[], /* I Input signal */ - const opus_int16 A_Q14[], /* I AR coefficients, Q14 */ - opus_int32 len /* I Signal length */ -); - -#ifdef __cplusplus -} -#endif -#endif /* SILK_RESAMPLER_PRIVATE_H */ diff --git a/Engine/lib/opus/silk/resampler_private_AR2.c b/Engine/lib/opus/silk/resampler_private_AR2.c deleted file mode 100644 index 5fff23714..000000000 --- a/Engine/lib/opus/silk/resampler_private_AR2.c +++ /dev/null @@ -1,55 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "resampler_private.h" - -/* Second order AR filter with single delay elements */ -void silk_resampler_private_AR2( - opus_int32 S[], /* I/O State vector [ 2 ] */ - opus_int32 out_Q8[], /* O Output signal */ - const opus_int16 in[], /* I Input signal */ - const opus_int16 A_Q14[], /* I AR coefficients, Q14 */ - opus_int32 len /* I Signal length */ -) -{ - opus_int32 k; - opus_int32 out32; - - for( k = 0; k < len; k++ ) { - out32 = silk_ADD_LSHIFT32( S[ 0 ], (opus_int32)in[ k ], 8 ); - out_Q8[ k ] = out32; - out32 = silk_LSHIFT( out32, 2 ); - S[ 0 ] = silk_SMLAWB( S[ 1 ], out32, A_Q14[ 0 ] ); - S[ 1 ] = silk_SMULWB( out32, A_Q14[ 1 ] ); - } -} - diff --git a/Engine/lib/opus/silk/resampler_private_IIR_FIR.c b/Engine/lib/opus/silk/resampler_private_IIR_FIR.c deleted file mode 100644 index 6b2b3a2e1..000000000 --- a/Engine/lib/opus/silk/resampler_private_IIR_FIR.c +++ /dev/null @@ -1,107 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "resampler_private.h" -#include "stack_alloc.h" - -static OPUS_INLINE opus_int16 *silk_resampler_private_IIR_FIR_INTERPOL( - opus_int16 *out, - opus_int16 *buf, - opus_int32 max_index_Q16, - opus_int32 index_increment_Q16 -) -{ - opus_int32 index_Q16, res_Q15; - opus_int16 *buf_ptr; - opus_int32 table_index; - - /* Interpolate upsampled signal and store in output array */ - for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) { - table_index = silk_SMULWB( index_Q16 & 0xFFFF, 12 ); - buf_ptr = &buf[ index_Q16 >> 16 ]; - - res_Q15 = silk_SMULBB( buf_ptr[ 0 ], silk_resampler_frac_FIR_12[ table_index ][ 0 ] ); - res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 1 ], silk_resampler_frac_FIR_12[ table_index ][ 1 ] ); - res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 2 ], silk_resampler_frac_FIR_12[ table_index ][ 2 ] ); - res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 3 ], silk_resampler_frac_FIR_12[ table_index ][ 3 ] ); - res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 4 ], silk_resampler_frac_FIR_12[ 11 - table_index ][ 3 ] ); - res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 5 ], silk_resampler_frac_FIR_12[ 11 - table_index ][ 2 ] ); - res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 6 ], silk_resampler_frac_FIR_12[ 11 - table_index ][ 1 ] ); - res_Q15 = silk_SMLABB( res_Q15, buf_ptr[ 7 ], silk_resampler_frac_FIR_12[ 11 - table_index ][ 0 ] ); - *out++ = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( res_Q15, 15 ) ); - } - return out; -} -/* Upsample using a combination of allpass-based 2x upsampling and FIR interpolation */ -void silk_resampler_private_IIR_FIR( - void *SS, /* I/O Resampler state */ - opus_int16 out[], /* O Output signal */ - const opus_int16 in[], /* I Input signal */ - opus_int32 inLen /* I Number of input samples */ -) -{ - silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; - opus_int32 nSamplesIn; - opus_int32 max_index_Q16, index_increment_Q16; - VARDECL( opus_int16, buf ); - SAVE_STACK; - - ALLOC( buf, 2 * S->batchSize + RESAMPLER_ORDER_FIR_12, opus_int16 ); - - /* Copy buffered samples to start of buffer */ - silk_memcpy( buf, S->sFIR.i16, RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); - - /* Iterate over blocks of frameSizeIn input samples */ - index_increment_Q16 = S->invRatio_Q16; - while( 1 ) { - nSamplesIn = silk_min( inLen, S->batchSize ); - - /* Upsample 2x */ - silk_resampler_private_up2_HQ( S->sIIR, &buf[ RESAMPLER_ORDER_FIR_12 ], in, nSamplesIn ); - - max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 + 1 ); /* + 1 because 2x upsampling */ - out = silk_resampler_private_IIR_FIR_INTERPOL( out, buf, max_index_Q16, index_increment_Q16 ); - in += nSamplesIn; - inLen -= nSamplesIn; - - if( inLen > 0 ) { - /* More iterations to do; copy last part of filtered signal to beginning of buffer */ - silk_memcpy( buf, &buf[ nSamplesIn << 1 ], RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); - } else { - break; - } - } - - /* Copy last part of filtered signal to the state for the next call */ - silk_memcpy( S->sFIR.i16, &buf[ nSamplesIn << 1 ], RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/resampler_private_down_FIR.c b/Engine/lib/opus/silk/resampler_private_down_FIR.c deleted file mode 100644 index 3e8735a35..000000000 --- a/Engine/lib/opus/silk/resampler_private_down_FIR.c +++ /dev/null @@ -1,194 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "resampler_private.h" -#include "stack_alloc.h" - -static OPUS_INLINE opus_int16 *silk_resampler_private_down_FIR_INTERPOL( - opus_int16 *out, - opus_int32 *buf, - const opus_int16 *FIR_Coefs, - opus_int FIR_Order, - opus_int FIR_Fracs, - opus_int32 max_index_Q16, - opus_int32 index_increment_Q16 -) -{ - opus_int32 index_Q16, res_Q6; - opus_int32 *buf_ptr; - opus_int32 interpol_ind; - const opus_int16 *interpol_ptr; - - switch( FIR_Order ) { - case RESAMPLER_DOWN_ORDER_FIR0: - for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) { - /* Integer part gives pointer to buffered input */ - buf_ptr = buf + silk_RSHIFT( index_Q16, 16 ); - - /* Fractional part gives interpolation coefficients */ - interpol_ind = silk_SMULWB( index_Q16 & 0xFFFF, FIR_Fracs ); - - /* Inner product */ - interpol_ptr = &FIR_Coefs[ RESAMPLER_DOWN_ORDER_FIR0 / 2 * interpol_ind ]; - res_Q6 = silk_SMULWB( buf_ptr[ 0 ], interpol_ptr[ 0 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 1 ], interpol_ptr[ 1 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 2 ], interpol_ptr[ 2 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 3 ], interpol_ptr[ 3 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 4 ], interpol_ptr[ 4 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 5 ], interpol_ptr[ 5 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 6 ], interpol_ptr[ 6 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 7 ], interpol_ptr[ 7 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 8 ], interpol_ptr[ 8 ] ); - interpol_ptr = &FIR_Coefs[ RESAMPLER_DOWN_ORDER_FIR0 / 2 * ( FIR_Fracs - 1 - interpol_ind ) ]; - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 17 ], interpol_ptr[ 0 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 16 ], interpol_ptr[ 1 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 15 ], interpol_ptr[ 2 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 14 ], interpol_ptr[ 3 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 13 ], interpol_ptr[ 4 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 12 ], interpol_ptr[ 5 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 11 ], interpol_ptr[ 6 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 10 ], interpol_ptr[ 7 ] ); - res_Q6 = silk_SMLAWB( res_Q6, buf_ptr[ 9 ], interpol_ptr[ 8 ] ); - - /* Scale down, saturate and store in output array */ - *out++ = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( res_Q6, 6 ) ); - } - break; - case RESAMPLER_DOWN_ORDER_FIR1: - for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) { - /* Integer part gives pointer to buffered input */ - buf_ptr = buf + silk_RSHIFT( index_Q16, 16 ); - - /* Inner product */ - res_Q6 = silk_SMULWB( silk_ADD32( buf_ptr[ 0 ], buf_ptr[ 23 ] ), FIR_Coefs[ 0 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 1 ], buf_ptr[ 22 ] ), FIR_Coefs[ 1 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 2 ], buf_ptr[ 21 ] ), FIR_Coefs[ 2 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 3 ], buf_ptr[ 20 ] ), FIR_Coefs[ 3 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 4 ], buf_ptr[ 19 ] ), FIR_Coefs[ 4 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 5 ], buf_ptr[ 18 ] ), FIR_Coefs[ 5 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 6 ], buf_ptr[ 17 ] ), FIR_Coefs[ 6 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 7 ], buf_ptr[ 16 ] ), FIR_Coefs[ 7 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 8 ], buf_ptr[ 15 ] ), FIR_Coefs[ 8 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 9 ], buf_ptr[ 14 ] ), FIR_Coefs[ 9 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 10 ], buf_ptr[ 13 ] ), FIR_Coefs[ 10 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 11 ], buf_ptr[ 12 ] ), FIR_Coefs[ 11 ] ); - - /* Scale down, saturate and store in output array */ - *out++ = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( res_Q6, 6 ) ); - } - break; - case RESAMPLER_DOWN_ORDER_FIR2: - for( index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16 ) { - /* Integer part gives pointer to buffered input */ - buf_ptr = buf + silk_RSHIFT( index_Q16, 16 ); - - /* Inner product */ - res_Q6 = silk_SMULWB( silk_ADD32( buf_ptr[ 0 ], buf_ptr[ 35 ] ), FIR_Coefs[ 0 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 1 ], buf_ptr[ 34 ] ), FIR_Coefs[ 1 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 2 ], buf_ptr[ 33 ] ), FIR_Coefs[ 2 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 3 ], buf_ptr[ 32 ] ), FIR_Coefs[ 3 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 4 ], buf_ptr[ 31 ] ), FIR_Coefs[ 4 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 5 ], buf_ptr[ 30 ] ), FIR_Coefs[ 5 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 6 ], buf_ptr[ 29 ] ), FIR_Coefs[ 6 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 7 ], buf_ptr[ 28 ] ), FIR_Coefs[ 7 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 8 ], buf_ptr[ 27 ] ), FIR_Coefs[ 8 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 9 ], buf_ptr[ 26 ] ), FIR_Coefs[ 9 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 10 ], buf_ptr[ 25 ] ), FIR_Coefs[ 10 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 11 ], buf_ptr[ 24 ] ), FIR_Coefs[ 11 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 12 ], buf_ptr[ 23 ] ), FIR_Coefs[ 12 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 13 ], buf_ptr[ 22 ] ), FIR_Coefs[ 13 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 14 ], buf_ptr[ 21 ] ), FIR_Coefs[ 14 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 15 ], buf_ptr[ 20 ] ), FIR_Coefs[ 15 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 16 ], buf_ptr[ 19 ] ), FIR_Coefs[ 16 ] ); - res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 17 ], buf_ptr[ 18 ] ), FIR_Coefs[ 17 ] ); - - /* Scale down, saturate and store in output array */ - *out++ = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( res_Q6, 6 ) ); - } - break; - default: - celt_assert( 0 ); - } - return out; -} - -/* Resample with a 2nd order AR filter followed by FIR interpolation */ -void silk_resampler_private_down_FIR( - void *SS, /* I/O Resampler state */ - opus_int16 out[], /* O Output signal */ - const opus_int16 in[], /* I Input signal */ - opus_int32 inLen /* I Number of input samples */ -) -{ - silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; - opus_int32 nSamplesIn; - opus_int32 max_index_Q16, index_increment_Q16; - VARDECL( opus_int32, buf ); - const opus_int16 *FIR_Coefs; - SAVE_STACK; - - ALLOC( buf, S->batchSize + S->FIR_Order, opus_int32 ); - - /* Copy buffered samples to start of buffer */ - silk_memcpy( buf, S->sFIR.i32, S->FIR_Order * sizeof( opus_int32 ) ); - - FIR_Coefs = &S->Coefs[ 2 ]; - - /* Iterate over blocks of frameSizeIn input samples */ - index_increment_Q16 = S->invRatio_Q16; - while( 1 ) { - nSamplesIn = silk_min( inLen, S->batchSize ); - - /* Second-order AR filter (output in Q8) */ - silk_resampler_private_AR2( S->sIIR, &buf[ S->FIR_Order ], in, S->Coefs, nSamplesIn ); - - max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 ); - - /* Interpolate filtered signal */ - out = silk_resampler_private_down_FIR_INTERPOL( out, buf, FIR_Coefs, S->FIR_Order, - S->FIR_Fracs, max_index_Q16, index_increment_Q16 ); - - in += nSamplesIn; - inLen -= nSamplesIn; - - if( inLen > 1 ) { - /* More iterations to do; copy last part of filtered signal to beginning of buffer */ - silk_memcpy( buf, &buf[ nSamplesIn ], S->FIR_Order * sizeof( opus_int32 ) ); - } else { - break; - } - } - - /* Copy last part of filtered signal to the state for the next call */ - silk_memcpy( S->sFIR.i32, &buf[ nSamplesIn ], S->FIR_Order * sizeof( opus_int32 ) ); - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/resampler_private_up2_HQ.c b/Engine/lib/opus/silk/resampler_private_up2_HQ.c deleted file mode 100644 index c7ec8de36..000000000 --- a/Engine/lib/opus/silk/resampler_private_up2_HQ.c +++ /dev/null @@ -1,113 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" -#include "resampler_private.h" - -/* Upsample by a factor 2, high quality */ -/* Uses 2nd order allpass filters for the 2x upsampling, followed by a */ -/* notch filter just above Nyquist. */ -void silk_resampler_private_up2_HQ( - opus_int32 *S, /* I/O Resampler state [ 6 ] */ - opus_int16 *out, /* O Output signal [ 2 * len ] */ - const opus_int16 *in, /* I Input signal [ len ] */ - opus_int32 len /* I Number of input samples */ -) -{ - opus_int32 k; - opus_int32 in32, out32_1, out32_2, Y, X; - - silk_assert( silk_resampler_up2_hq_0[ 0 ] > 0 ); - silk_assert( silk_resampler_up2_hq_0[ 1 ] > 0 ); - silk_assert( silk_resampler_up2_hq_0[ 2 ] < 0 ); - silk_assert( silk_resampler_up2_hq_1[ 0 ] > 0 ); - silk_assert( silk_resampler_up2_hq_1[ 1 ] > 0 ); - silk_assert( silk_resampler_up2_hq_1[ 2 ] < 0 ); - - /* Internal variables and state are in Q10 format */ - for( k = 0; k < len; k++ ) { - /* Convert to Q10 */ - in32 = silk_LSHIFT( (opus_int32)in[ k ], 10 ); - - /* First all-pass section for even output sample */ - Y = silk_SUB32( in32, S[ 0 ] ); - X = silk_SMULWB( Y, silk_resampler_up2_hq_0[ 0 ] ); - out32_1 = silk_ADD32( S[ 0 ], X ); - S[ 0 ] = silk_ADD32( in32, X ); - - /* Second all-pass section for even output sample */ - Y = silk_SUB32( out32_1, S[ 1 ] ); - X = silk_SMULWB( Y, silk_resampler_up2_hq_0[ 1 ] ); - out32_2 = silk_ADD32( S[ 1 ], X ); - S[ 1 ] = silk_ADD32( out32_1, X ); - - /* Third all-pass section for even output sample */ - Y = silk_SUB32( out32_2, S[ 2 ] ); - X = silk_SMLAWB( Y, Y, silk_resampler_up2_hq_0[ 2 ] ); - out32_1 = silk_ADD32( S[ 2 ], X ); - S[ 2 ] = silk_ADD32( out32_2, X ); - - /* Apply gain in Q15, convert back to int16 and store to output */ - out[ 2 * k ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( out32_1, 10 ) ); - - /* First all-pass section for odd output sample */ - Y = silk_SUB32( in32, S[ 3 ] ); - X = silk_SMULWB( Y, silk_resampler_up2_hq_1[ 0 ] ); - out32_1 = silk_ADD32( S[ 3 ], X ); - S[ 3 ] = silk_ADD32( in32, X ); - - /* Second all-pass section for odd output sample */ - Y = silk_SUB32( out32_1, S[ 4 ] ); - X = silk_SMULWB( Y, silk_resampler_up2_hq_1[ 1 ] ); - out32_2 = silk_ADD32( S[ 4 ], X ); - S[ 4 ] = silk_ADD32( out32_1, X ); - - /* Third all-pass section for odd output sample */ - Y = silk_SUB32( out32_2, S[ 5 ] ); - X = silk_SMLAWB( Y, Y, silk_resampler_up2_hq_1[ 2 ] ); - out32_1 = silk_ADD32( S[ 5 ], X ); - S[ 5 ] = silk_ADD32( out32_2, X ); - - /* Apply gain in Q15, convert back to int16 and store to output */ - out[ 2 * k + 1 ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( out32_1, 10 ) ); - } -} - -void silk_resampler_private_up2_HQ_wrapper( - void *SS, /* I/O Resampler state (unused) */ - opus_int16 *out, /* O Output signal [ 2 * len ] */ - const opus_int16 *in, /* I Input signal [ len ] */ - opus_int32 len /* I Number of input samples */ -) -{ - silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; - silk_resampler_private_up2_HQ( S->sIIR, out, in, len ); -} diff --git a/Engine/lib/opus/silk/resampler_rom.c b/Engine/lib/opus/silk/resampler_rom.c deleted file mode 100644 index 5e6b04476..000000000 --- a/Engine/lib/opus/silk/resampler_rom.c +++ /dev/null @@ -1,96 +0,0 @@ -/*********************************************************************** -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" -#endif - -/* Filter coefficients for IIR/FIR polyphase resampling * - * Total size: 179 Words (358 Bytes) */ - -#include "resampler_private.h" - -/* Matlab code for the notch filter coefficients: */ -/* B = [1, 0.147, 1]; A = [1, 0.107, 0.89]; G = 0.93; freqz(G * B, A, 2^14, 16e3); axis([0, 8000, -10, 1]) */ -/* fprintf('\t%6d, %6d, %6d, %6d\n', round(B(2)*2^16), round(-A(2)*2^16), round((1-A(3))*2^16), round(G*2^15)) */ -/* const opus_int16 silk_resampler_up2_hq_notch[ 4 ] = { 9634, -7012, 7209, 30474 }; */ - -/* Tables with IIR and FIR coefficients for fractional downsamplers (123 Words) */ -silk_DWORD_ALIGN const opus_int16 silk_Resampler_3_4_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ] = { - -20694, -13867, - -49, 64, 17, -157, 353, -496, 163, 11047, 22205, - -39, 6, 91, -170, 186, 23, -896, 6336, 19928, - -19, -36, 102, -89, -24, 328, -951, 2568, 15909, -}; - -silk_DWORD_ALIGN const opus_int16 silk_Resampler_2_3_COEFS[ 2 + 2 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ] = { - -14457, -14019, - 64, 128, -122, 36, 310, -768, 584, 9267, 17733, - 12, 128, 18, -142, 288, -117, -865, 4123, 14459, -}; - -silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_2_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR1 / 2 ] = { - 616, -14323, - -10, 39, 58, -46, -84, 120, 184, -315, -541, 1284, 5380, 9024, -}; - -silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_3_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ] = { - 16102, -15162, - -13, 0, 20, 26, 5, -31, -43, -4, 65, 90, 7, -157, -248, -44, 593, 1583, 2612, 3271, -}; - -silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_4_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ] = { - 22500, -15099, - 3, -14, -20, -15, 2, 25, 37, 25, -16, -71, -107, -79, 50, 292, 623, 982, 1288, 1464, -}; - -silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_6_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ] = { - 27540, -15257, - 17, 12, 8, 1, -10, -22, -30, -32, -22, 3, 44, 100, 168, 243, 317, 381, 429, 455, -}; - -silk_DWORD_ALIGN const opus_int16 silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ] = { - -2797, -6507, - 4697, 10739, - 1567, 8276, -}; - -/* Table with interplation fractions of 1/24, 3/24, 5/24, ... , 23/24 : 23/24 (46 Words) */ -silk_DWORD_ALIGN const opus_int16 silk_resampler_frac_FIR_12[ 12 ][ RESAMPLER_ORDER_FIR_12 / 2 ] = { - { 189, -600, 617, 30567 }, - { 117, -159, -1070, 29704 }, - { 52, 221, -2392, 28276 }, - { -4, 529, -3350, 26341 }, - { -48, 758, -3956, 23973 }, - { -80, 905, -4235, 21254 }, - { -99, 972, -4222, 18278 }, - { -107, 967, -3957, 15143 }, - { -103, 896, -3487, 11950 }, - { -91, 773, -2865, 8798 }, - { -71, 611, -2143, 5784 }, - { -46, 425, -1375, 2996 }, -}; diff --git a/Engine/lib/opus/silk/resampler_rom.h b/Engine/lib/opus/silk/resampler_rom.h deleted file mode 100644 index 490b3388d..000000000 --- a/Engine/lib/opus/silk/resampler_rom.h +++ /dev/null @@ -1,68 +0,0 @@ -/*********************************************************************** -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 SILK_FIX_RESAMPLER_ROM_H -#define SILK_FIX_RESAMPLER_ROM_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "typedef.h" -#include "resampler_structs.h" - -#define RESAMPLER_DOWN_ORDER_FIR0 18 -#define RESAMPLER_DOWN_ORDER_FIR1 24 -#define RESAMPLER_DOWN_ORDER_FIR2 36 -#define RESAMPLER_ORDER_FIR_12 8 - -/* Tables for 2x downsampler */ -static const opus_int16 silk_resampler_down2_0 = 9872; -static const opus_int16 silk_resampler_down2_1 = 39809 - 65536; - -/* Tables for 2x upsampler, high quality */ -static const opus_int16 silk_resampler_up2_hq_0[ 3 ] = { 1746, 14986, 39083 - 65536 }; -static const opus_int16 silk_resampler_up2_hq_1[ 3 ] = { 6854, 25769, 55542 - 65536 }; - -/* Tables with IIR and FIR coefficients for fractional downsamplers */ -extern const opus_int16 silk_Resampler_3_4_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ]; -extern const opus_int16 silk_Resampler_2_3_COEFS[ 2 + 2 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ]; -extern const opus_int16 silk_Resampler_1_2_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR1 / 2 ]; -extern const opus_int16 silk_Resampler_1_3_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ]; -extern const opus_int16 silk_Resampler_1_4_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ]; -extern const opus_int16 silk_Resampler_1_6_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ]; -extern const opus_int16 silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ]; - -/* Table with interplation fractions of 1/24, 3/24, ..., 23/24 */ -extern const opus_int16 silk_resampler_frac_FIR_12[ 12 ][ RESAMPLER_ORDER_FIR_12 / 2 ]; - -#ifdef __cplusplus -} -#endif - -#endif /* SILK_FIX_RESAMPLER_ROM_H */ diff --git a/Engine/lib/opus/silk/resampler_structs.h b/Engine/lib/opus/silk/resampler_structs.h deleted file mode 100644 index 9e9457d11..000000000 --- a/Engine/lib/opus/silk/resampler_structs.h +++ /dev/null @@ -1,60 +0,0 @@ -/*********************************************************************** -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 SILK_RESAMPLER_STRUCTS_H -#define SILK_RESAMPLER_STRUCTS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define SILK_RESAMPLER_MAX_FIR_ORDER 36 -#define SILK_RESAMPLER_MAX_IIR_ORDER 6 - -typedef struct _silk_resampler_state_struct{ - opus_int32 sIIR[ SILK_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */ - union{ - opus_int32 i32[ SILK_RESAMPLER_MAX_FIR_ORDER ]; - opus_int16 i16[ SILK_RESAMPLER_MAX_FIR_ORDER ]; - } sFIR; - opus_int16 delayBuf[ 48 ]; - opus_int resampler_function; - opus_int batchSize; - opus_int32 invRatio_Q16; - opus_int FIR_Order; - opus_int FIR_Fracs; - opus_int Fs_in_kHz; - opus_int Fs_out_kHz; - opus_int inputDelay; - const opus_int16 *Coefs; -} silk_resampler_state_struct; - -#ifdef __cplusplus -} -#endif -#endif /* SILK_RESAMPLER_STRUCTS_H */ - diff --git a/Engine/lib/opus/silk/shell_coder.c b/Engine/lib/opus/silk/shell_coder.c deleted file mode 100644 index 4af341474..000000000 --- a/Engine/lib/opus/silk/shell_coder.c +++ /dev/null @@ -1,151 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* shell coder; pulse-subframe length is hardcoded */ - -static OPUS_INLINE void combine_pulses( - opus_int *out, /* O combined pulses vector [len] */ - const opus_int *in, /* I input vector [2 * len] */ - const opus_int len /* I number of OUTPUT samples */ -) -{ - opus_int k; - for( k = 0; k < len; k++ ) { - out[ k ] = in[ 2 * k ] + in[ 2 * k + 1 ]; - } -} - -static OPUS_INLINE void encode_split( - ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int p_child1, /* I pulse amplitude of first child subframe */ - const opus_int p, /* I pulse amplitude of current subframe */ - const opus_uint8 *shell_table /* I table of shell cdfs */ -) -{ - if( p > 0 ) { - ec_enc_icdf( psRangeEnc, p_child1, &shell_table[ silk_shell_code_table_offsets[ p ] ], 8 ); - } -} - -static OPUS_INLINE void decode_split( - opus_int16 *p_child1, /* O pulse amplitude of first child subframe */ - opus_int16 *p_child2, /* O pulse amplitude of second child subframe */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - const opus_int p, /* I pulse amplitude of current subframe */ - const opus_uint8 *shell_table /* I table of shell cdfs */ -) -{ - if( p > 0 ) { - p_child1[ 0 ] = ec_dec_icdf( psRangeDec, &shell_table[ silk_shell_code_table_offsets[ p ] ], 8 ); - p_child2[ 0 ] = p - p_child1[ 0 ]; - } else { - p_child1[ 0 ] = 0; - p_child2[ 0 ] = 0; - } -} - -/* Shell encoder, operates on one shell code frame of 16 pulses */ -void silk_shell_encoder( - ec_enc *psRangeEnc, /* I/O compressor data structure */ - const opus_int *pulses0 /* I data: nonnegative pulse amplitudes */ -) -{ - opus_int pulses1[ 8 ], pulses2[ 4 ], pulses3[ 2 ], pulses4[ 1 ]; - - /* this function operates on one shell code frame of 16 pulses */ - silk_assert( SHELL_CODEC_FRAME_LENGTH == 16 ); - - /* tree representation per pulse-subframe */ - combine_pulses( pulses1, pulses0, 8 ); - combine_pulses( pulses2, pulses1, 4 ); - combine_pulses( pulses3, pulses2, 2 ); - combine_pulses( pulses4, pulses3, 1 ); - - encode_split( psRangeEnc, pulses3[ 0 ], pulses4[ 0 ], silk_shell_code_table3 ); - - encode_split( psRangeEnc, pulses2[ 0 ], pulses3[ 0 ], silk_shell_code_table2 ); - - encode_split( psRangeEnc, pulses1[ 0 ], pulses2[ 0 ], silk_shell_code_table1 ); - encode_split( psRangeEnc, pulses0[ 0 ], pulses1[ 0 ], silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses0[ 2 ], pulses1[ 1 ], silk_shell_code_table0 ); - - encode_split( psRangeEnc, pulses1[ 2 ], pulses2[ 1 ], silk_shell_code_table1 ); - encode_split( psRangeEnc, pulses0[ 4 ], pulses1[ 2 ], silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses0[ 6 ], pulses1[ 3 ], silk_shell_code_table0 ); - - encode_split( psRangeEnc, pulses2[ 2 ], pulses3[ 1 ], silk_shell_code_table2 ); - - encode_split( psRangeEnc, pulses1[ 4 ], pulses2[ 2 ], silk_shell_code_table1 ); - encode_split( psRangeEnc, pulses0[ 8 ], pulses1[ 4 ], silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses0[ 10 ], pulses1[ 5 ], silk_shell_code_table0 ); - - encode_split( psRangeEnc, pulses1[ 6 ], pulses2[ 3 ], silk_shell_code_table1 ); - encode_split( psRangeEnc, pulses0[ 12 ], pulses1[ 6 ], silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses0[ 14 ], pulses1[ 7 ], silk_shell_code_table0 ); -} - - -/* Shell decoder, operates on one shell code frame of 16 pulses */ -void silk_shell_decoder( - opus_int16 *pulses0, /* O data: nonnegative pulse amplitudes */ - ec_dec *psRangeDec, /* I/O Compressor data structure */ - const opus_int pulses4 /* I number of pulses per pulse-subframe */ -) -{ - opus_int16 pulses3[ 2 ], pulses2[ 4 ], pulses1[ 8 ]; - - /* this function operates on one shell code frame of 16 pulses */ - silk_assert( SHELL_CODEC_FRAME_LENGTH == 16 ); - - decode_split( &pulses3[ 0 ], &pulses3[ 1 ], psRangeDec, pulses4, silk_shell_code_table3 ); - - decode_split( &pulses2[ 0 ], &pulses2[ 1 ], psRangeDec, pulses3[ 0 ], silk_shell_code_table2 ); - - decode_split( &pulses1[ 0 ], &pulses1[ 1 ], psRangeDec, pulses2[ 0 ], silk_shell_code_table1 ); - decode_split( &pulses0[ 0 ], &pulses0[ 1 ], psRangeDec, pulses1[ 0 ], silk_shell_code_table0 ); - decode_split( &pulses0[ 2 ], &pulses0[ 3 ], psRangeDec, pulses1[ 1 ], silk_shell_code_table0 ); - - decode_split( &pulses1[ 2 ], &pulses1[ 3 ], psRangeDec, pulses2[ 1 ], silk_shell_code_table1 ); - decode_split( &pulses0[ 4 ], &pulses0[ 5 ], psRangeDec, pulses1[ 2 ], silk_shell_code_table0 ); - decode_split( &pulses0[ 6 ], &pulses0[ 7 ], psRangeDec, pulses1[ 3 ], silk_shell_code_table0 ); - - decode_split( &pulses2[ 2 ], &pulses2[ 3 ], psRangeDec, pulses3[ 1 ], silk_shell_code_table2 ); - - decode_split( &pulses1[ 4 ], &pulses1[ 5 ], psRangeDec, pulses2[ 2 ], silk_shell_code_table1 ); - decode_split( &pulses0[ 8 ], &pulses0[ 9 ], psRangeDec, pulses1[ 4 ], silk_shell_code_table0 ); - decode_split( &pulses0[ 10 ], &pulses0[ 11 ], psRangeDec, pulses1[ 5 ], silk_shell_code_table0 ); - - decode_split( &pulses1[ 6 ], &pulses1[ 7 ], psRangeDec, pulses2[ 3 ], silk_shell_code_table1 ); - decode_split( &pulses0[ 12 ], &pulses0[ 13 ], psRangeDec, pulses1[ 6 ], silk_shell_code_table0 ); - decode_split( &pulses0[ 14 ], &pulses0[ 15 ], psRangeDec, pulses1[ 7 ], silk_shell_code_table0 ); -} diff --git a/Engine/lib/opus/silk/sigm_Q15.c b/Engine/lib/opus/silk/sigm_Q15.c deleted file mode 100644 index 3c507d255..000000000 --- a/Engine/lib/opus/silk/sigm_Q15.c +++ /dev/null @@ -1,76 +0,0 @@ -/*********************************************************************** -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" -#endif - -/* Approximate sigmoid function */ - -#include "SigProc_FIX.h" - -/* fprintf(1, '%d, ', round(1024 * ([1 ./ (1 + exp(-(1:5))), 1] - 1 ./ (1 + exp(-(0:5)))))); */ -static const opus_int32 sigm_LUT_slope_Q10[ 6 ] = { - 237, 153, 73, 30, 12, 7 -}; -/* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp(-(0:5))))); */ -static const opus_int32 sigm_LUT_pos_Q15[ 6 ] = { - 16384, 23955, 28861, 31213, 32178, 32548 -}; -/* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp((0:5))))); */ -static const opus_int32 sigm_LUT_neg_Q15[ 6 ] = { - 16384, 8812, 3906, 1554, 589, 219 -}; - -opus_int silk_sigm_Q15( - opus_int in_Q5 /* I */ -) -{ - opus_int ind; - - if( in_Q5 < 0 ) { - /* Negative input */ - in_Q5 = -in_Q5; - if( in_Q5 >= 6 * 32 ) { - return 0; /* Clip */ - } else { - /* Linear interpolation of look up table */ - ind = silk_RSHIFT( in_Q5, 5 ); - return( sigm_LUT_neg_Q15[ ind ] - silk_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); - } - } else { - /* Positive input */ - if( in_Q5 >= 6 * 32 ) { - return 32767; /* clip */ - } else { - /* Linear interpolation of look up table */ - ind = silk_RSHIFT( in_Q5, 5 ); - return( sigm_LUT_pos_Q15[ ind ] + silk_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) ); - } - } -} - diff --git a/Engine/lib/opus/silk/sort.c b/Engine/lib/opus/silk/sort.c deleted file mode 100644 index 4fba16f83..000000000 --- a/Engine/lib/opus/silk/sort.c +++ /dev/null @@ -1,154 +0,0 @@ -/*********************************************************************** -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" -#endif - -/* Insertion sort (fast for already almost sorted arrays): */ -/* Best case: O(n) for an already sorted array */ -/* Worst case: O(n^2) for an inversely sorted array */ -/* */ -/* Shell short: https://en.wikipedia.org/wiki/Shell_sort */ - -#include "SigProc_FIX.h" - -void silk_insertion_sort_increasing( - opus_int32 *a, /* I/O Unsorted / Sorted vector */ - opus_int *idx, /* O Index vector for the sorted elements */ - const opus_int L, /* I Vector length */ - const opus_int K /* I Number of correctly sorted positions */ -) -{ - opus_int32 value; - opus_int i, j; - - /* Safety checks */ - celt_assert( K > 0 ); - celt_assert( L > 0 ); - celt_assert( L >= K ); - - /* Write start indices in index vector */ - for( i = 0; i < K; i++ ) { - idx[ i ] = i; - } - - /* Sort vector elements by value, increasing order */ - for( i = 1; i < K; i++ ) { - value = a[ i ]; - for( j = i - 1; ( j >= 0 ) && ( value < a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - idx[ j + 1 ] = idx[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - idx[ j + 1 ] = i; /* Write index */ - } - - /* If less than L values are asked for, check the remaining values, */ - /* but only spend CPU to ensure that the K first values are correct */ - for( i = K; i < L; i++ ) { - value = a[ i ]; - if( value < a[ K - 1 ] ) { - for( j = K - 2; ( j >= 0 ) && ( value < a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - idx[ j + 1 ] = idx[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - idx[ j + 1 ] = i; /* Write index */ - } - } -} - -#ifdef FIXED_POINT -/* This function is only used by the fixed-point build */ -void silk_insertion_sort_decreasing_int16( - opus_int16 *a, /* I/O Unsorted / Sorted vector */ - opus_int *idx, /* O Index vector for the sorted elements */ - const opus_int L, /* I Vector length */ - const opus_int K /* I Number of correctly sorted positions */ -) -{ - opus_int i, j; - opus_int value; - - /* Safety checks */ - celt_assert( K > 0 ); - celt_assert( L > 0 ); - celt_assert( L >= K ); - - /* Write start indices in index vector */ - for( i = 0; i < K; i++ ) { - idx[ i ] = i; - } - - /* Sort vector elements by value, decreasing order */ - for( i = 1; i < K; i++ ) { - value = a[ i ]; - for( j = i - 1; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - idx[ j + 1 ] = idx[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - idx[ j + 1 ] = i; /* Write index */ - } - - /* If less than L values are asked for, check the remaining values, */ - /* but only spend CPU to ensure that the K first values are correct */ - for( i = K; i < L; i++ ) { - value = a[ i ]; - if( value > a[ K - 1 ] ) { - for( j = K - 2; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - idx[ j + 1 ] = idx[ j ]; /* Shift index */ - } - a[ j + 1 ] = value; /* Write value */ - idx[ j + 1 ] = i; /* Write index */ - } - } -} -#endif - -void silk_insertion_sort_increasing_all_values_int16( - opus_int16 *a, /* I/O Unsorted / Sorted vector */ - const opus_int L /* I Vector length */ -) -{ - opus_int value; - opus_int i, j; - - /* Safety checks */ - celt_assert( L > 0 ); - - /* Sort vector elements by value, increasing order */ - for( i = 1; i < L; i++ ) { - value = a[ i ]; - for( j = i - 1; ( j >= 0 ) && ( value < a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - } - a[ j + 1 ] = value; /* Write value */ - } -} diff --git a/Engine/lib/opus/silk/stereo_LR_to_MS.c b/Engine/lib/opus/silk/stereo_LR_to_MS.c deleted file mode 100644 index 751452cb1..000000000 --- a/Engine/lib/opus/silk/stereo_LR_to_MS.c +++ /dev/null @@ -1,229 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" -#include "stack_alloc.h" - -/* Convert Left/Right stereo signal to adaptive Mid/Side representation */ -void silk_stereo_LR_to_MS( - stereo_enc_state *state, /* I/O State */ - opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ - opus_int16 x2[], /* I/O Right input signal, becomes side signal */ - opus_int8 ix[ 2 ][ 3 ], /* O Quantization indices */ - opus_int8 *mid_only_flag, /* O Flag: only mid signal coded */ - opus_int32 mid_side_rates_bps[], /* O Bitrates for mid and side signals */ - opus_int32 total_rate_bps, /* I Total bitrate */ - opus_int prev_speech_act_Q8, /* I Speech activity level in previous frame */ - opus_int toMono, /* I Last frame before a stereo->mono transition */ - opus_int fs_kHz, /* I Sample rate (kHz) */ - opus_int frame_length /* I Number of samples */ -) -{ - opus_int n, is10msFrame, denom_Q16, delta0_Q13, delta1_Q13; - opus_int32 sum, diff, smooth_coef_Q16, pred_Q13[ 2 ], pred0_Q13, pred1_Q13; - opus_int32 LP_ratio_Q14, HP_ratio_Q14, frac_Q16, frac_3_Q16, min_mid_rate_bps, width_Q14, w_Q24, deltaw_Q24; - VARDECL( opus_int16, side ); - VARDECL( opus_int16, LP_mid ); - VARDECL( opus_int16, HP_mid ); - VARDECL( opus_int16, LP_side ); - VARDECL( opus_int16, HP_side ); - opus_int16 *mid = &x1[ -2 ]; - SAVE_STACK; - - ALLOC( side, frame_length + 2, opus_int16 ); - /* Convert to basic mid/side signals */ - for( n = 0; n < frame_length + 2; n++ ) { - sum = x1[ n - 2 ] + (opus_int32)x2[ n - 2 ]; - diff = x1[ n - 2 ] - (opus_int32)x2[ n - 2 ]; - mid[ n ] = (opus_int16)silk_RSHIFT_ROUND( sum, 1 ); - side[ n ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( diff, 1 ) ); - } - - /* Buffering */ - silk_memcpy( mid, state->sMid, 2 * sizeof( opus_int16 ) ); - silk_memcpy( side, state->sSide, 2 * sizeof( opus_int16 ) ); - silk_memcpy( state->sMid, &mid[ frame_length ], 2 * sizeof( opus_int16 ) ); - silk_memcpy( state->sSide, &side[ frame_length ], 2 * sizeof( opus_int16 ) ); - - /* LP and HP filter mid signal */ - ALLOC( LP_mid, frame_length, opus_int16 ); - ALLOC( HP_mid, frame_length, opus_int16 ); - for( n = 0; n < frame_length; n++ ) { - sum = silk_RSHIFT_ROUND( silk_ADD_LSHIFT32( mid[ n ] + (opus_int32)mid[ n + 2 ], mid[ n + 1 ], 1 ), 2 ); - LP_mid[ n ] = sum; - HP_mid[ n ] = mid[ n + 1 ] - sum; - } - - /* LP and HP filter side signal */ - ALLOC( LP_side, frame_length, opus_int16 ); - ALLOC( HP_side, frame_length, opus_int16 ); - for( n = 0; n < frame_length; n++ ) { - sum = silk_RSHIFT_ROUND( silk_ADD_LSHIFT32( side[ n ] + (opus_int32)side[ n + 2 ], side[ n + 1 ], 1 ), 2 ); - LP_side[ n ] = sum; - HP_side[ n ] = side[ n + 1 ] - sum; - } - - /* Find energies and predictors */ - is10msFrame = frame_length == 10 * fs_kHz; - smooth_coef_Q16 = is10msFrame ? - SILK_FIX_CONST( STEREO_RATIO_SMOOTH_COEF / 2, 16 ) : - SILK_FIX_CONST( STEREO_RATIO_SMOOTH_COEF, 16 ); - smooth_coef_Q16 = silk_SMULWB( silk_SMULBB( prev_speech_act_Q8, prev_speech_act_Q8 ), smooth_coef_Q16 ); - - pred_Q13[ 0 ] = silk_stereo_find_predictor( &LP_ratio_Q14, LP_mid, LP_side, &state->mid_side_amp_Q0[ 0 ], frame_length, smooth_coef_Q16 ); - pred_Q13[ 1 ] = silk_stereo_find_predictor( &HP_ratio_Q14, HP_mid, HP_side, &state->mid_side_amp_Q0[ 2 ], frame_length, smooth_coef_Q16 ); - /* Ratio of the norms of residual and mid signals */ - frac_Q16 = silk_SMLABB( HP_ratio_Q14, LP_ratio_Q14, 3 ); - frac_Q16 = silk_min( frac_Q16, SILK_FIX_CONST( 1, 16 ) ); - - /* Determine bitrate distribution between mid and side, and possibly reduce stereo width */ - total_rate_bps -= is10msFrame ? 1200 : 600; /* Subtract approximate bitrate for coding stereo parameters */ - if( total_rate_bps < 1 ) { - total_rate_bps = 1; - } - min_mid_rate_bps = silk_SMLABB( 2000, fs_kHz, 600 ); - silk_assert( min_mid_rate_bps < 32767 ); - /* Default bitrate distribution: 8 parts for Mid and (5+3*frac) parts for Side. so: mid_rate = ( 8 / ( 13 + 3 * frac ) ) * total_ rate */ - frac_3_Q16 = silk_MUL( 3, frac_Q16 ); - mid_side_rates_bps[ 0 ] = silk_DIV32_varQ( total_rate_bps, SILK_FIX_CONST( 8 + 5, 16 ) + frac_3_Q16, 16+3 ); - /* If Mid bitrate below minimum, reduce stereo width */ - if( mid_side_rates_bps[ 0 ] < min_mid_rate_bps ) { - mid_side_rates_bps[ 0 ] = min_mid_rate_bps; - mid_side_rates_bps[ 1 ] = total_rate_bps - mid_side_rates_bps[ 0 ]; - /* width = 4 * ( 2 * side_rate - min_rate ) / ( ( 1 + 3 * frac ) * min_rate ) */ - width_Q14 = silk_DIV32_varQ( silk_LSHIFT( mid_side_rates_bps[ 1 ], 1 ) - min_mid_rate_bps, - silk_SMULWB( SILK_FIX_CONST( 1, 16 ) + frac_3_Q16, min_mid_rate_bps ), 14+2 ); - width_Q14 = silk_LIMIT( width_Q14, 0, SILK_FIX_CONST( 1, 14 ) ); - } else { - mid_side_rates_bps[ 1 ] = total_rate_bps - mid_side_rates_bps[ 0 ]; - width_Q14 = SILK_FIX_CONST( 1, 14 ); - } - - /* Smoother */ - state->smth_width_Q14 = (opus_int16)silk_SMLAWB( state->smth_width_Q14, width_Q14 - state->smth_width_Q14, smooth_coef_Q16 ); - - /* At very low bitrates or for inputs that are nearly amplitude panned, switch to panned-mono coding */ - *mid_only_flag = 0; - if( toMono ) { - /* Last frame before stereo->mono transition; collapse stereo width */ - width_Q14 = 0; - pred_Q13[ 0 ] = 0; - pred_Q13[ 1 ] = 0; - silk_stereo_quant_pred( pred_Q13, ix ); - } else if( state->width_prev_Q14 == 0 && - ( 8 * total_rate_bps < 13 * min_mid_rate_bps || silk_SMULWB( frac_Q16, state->smth_width_Q14 ) < SILK_FIX_CONST( 0.05, 14 ) ) ) - { - /* Code as panned-mono; previous frame already had zero width */ - /* Scale down and quantize predictors */ - pred_Q13[ 0 ] = silk_RSHIFT( silk_SMULBB( state->smth_width_Q14, pred_Q13[ 0 ] ), 14 ); - pred_Q13[ 1 ] = silk_RSHIFT( silk_SMULBB( state->smth_width_Q14, pred_Q13[ 1 ] ), 14 ); - silk_stereo_quant_pred( pred_Q13, ix ); - /* Collapse stereo width */ - width_Q14 = 0; - pred_Q13[ 0 ] = 0; - pred_Q13[ 1 ] = 0; - mid_side_rates_bps[ 0 ] = total_rate_bps; - mid_side_rates_bps[ 1 ] = 0; - *mid_only_flag = 1; - } else if( state->width_prev_Q14 != 0 && - ( 8 * total_rate_bps < 11 * min_mid_rate_bps || silk_SMULWB( frac_Q16, state->smth_width_Q14 ) < SILK_FIX_CONST( 0.02, 14 ) ) ) - { - /* Transition to zero-width stereo */ - /* Scale down and quantize predictors */ - pred_Q13[ 0 ] = silk_RSHIFT( silk_SMULBB( state->smth_width_Q14, pred_Q13[ 0 ] ), 14 ); - pred_Q13[ 1 ] = silk_RSHIFT( silk_SMULBB( state->smth_width_Q14, pred_Q13[ 1 ] ), 14 ); - silk_stereo_quant_pred( pred_Q13, ix ); - /* Collapse stereo width */ - width_Q14 = 0; - pred_Q13[ 0 ] = 0; - pred_Q13[ 1 ] = 0; - } else if( state->smth_width_Q14 > SILK_FIX_CONST( 0.95, 14 ) ) { - /* Full-width stereo coding */ - silk_stereo_quant_pred( pred_Q13, ix ); - width_Q14 = SILK_FIX_CONST( 1, 14 ); - } else { - /* Reduced-width stereo coding; scale down and quantize predictors */ - pred_Q13[ 0 ] = silk_RSHIFT( silk_SMULBB( state->smth_width_Q14, pred_Q13[ 0 ] ), 14 ); - pred_Q13[ 1 ] = silk_RSHIFT( silk_SMULBB( state->smth_width_Q14, pred_Q13[ 1 ] ), 14 ); - silk_stereo_quant_pred( pred_Q13, ix ); - width_Q14 = state->smth_width_Q14; - } - - /* Make sure to keep on encoding until the tapered output has been transmitted */ - if( *mid_only_flag == 1 ) { - state->silent_side_len += frame_length - STEREO_INTERP_LEN_MS * fs_kHz; - if( state->silent_side_len < LA_SHAPE_MS * fs_kHz ) { - *mid_only_flag = 0; - } else { - /* Limit to avoid wrapping around */ - state->silent_side_len = 10000; - } - } else { - state->silent_side_len = 0; - } - - if( *mid_only_flag == 0 && mid_side_rates_bps[ 1 ] < 1 ) { - mid_side_rates_bps[ 1 ] = 1; - mid_side_rates_bps[ 0 ] = silk_max_int( 1, total_rate_bps - mid_side_rates_bps[ 1 ]); - } - - /* Interpolate predictors and subtract prediction from side channel */ - pred0_Q13 = -state->pred_prev_Q13[ 0 ]; - pred1_Q13 = -state->pred_prev_Q13[ 1 ]; - w_Q24 = silk_LSHIFT( state->width_prev_Q14, 10 ); - denom_Q16 = silk_DIV32_16( (opus_int32)1 << 16, STEREO_INTERP_LEN_MS * fs_kHz ); - delta0_Q13 = -silk_RSHIFT_ROUND( silk_SMULBB( pred_Q13[ 0 ] - state->pred_prev_Q13[ 0 ], denom_Q16 ), 16 ); - delta1_Q13 = -silk_RSHIFT_ROUND( silk_SMULBB( pred_Q13[ 1 ] - state->pred_prev_Q13[ 1 ], denom_Q16 ), 16 ); - deltaw_Q24 = silk_LSHIFT( silk_SMULWB( width_Q14 - state->width_prev_Q14, denom_Q16 ), 10 ); - for( n = 0; n < STEREO_INTERP_LEN_MS * fs_kHz; n++ ) { - pred0_Q13 += delta0_Q13; - pred1_Q13 += delta1_Q13; - w_Q24 += deltaw_Q24; - sum = silk_LSHIFT( silk_ADD_LSHIFT32( mid[ n ] + (opus_int32)mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */ - sum = silk_SMLAWB( silk_SMULWB( w_Q24, side[ n + 1 ] ), sum, pred0_Q13 ); /* Q8 */ - sum = silk_SMLAWB( sum, silk_LSHIFT( (opus_int32)mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ - x2[ n - 1 ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sum, 8 ) ); - } - - pred0_Q13 = -pred_Q13[ 0 ]; - pred1_Q13 = -pred_Q13[ 1 ]; - w_Q24 = silk_LSHIFT( width_Q14, 10 ); - for( n = STEREO_INTERP_LEN_MS * fs_kHz; n < frame_length; n++ ) { - sum = silk_LSHIFT( silk_ADD_LSHIFT32( mid[ n ] + (opus_int32)mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */ - sum = silk_SMLAWB( silk_SMULWB( w_Q24, side[ n + 1 ] ), sum, pred0_Q13 ); /* Q8 */ - sum = silk_SMLAWB( sum, silk_LSHIFT( (opus_int32)mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ - x2[ n - 1 ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sum, 8 ) ); - } - state->pred_prev_Q13[ 0 ] = (opus_int16)pred_Q13[ 0 ]; - state->pred_prev_Q13[ 1 ] = (opus_int16)pred_Q13[ 1 ]; - state->width_prev_Q14 = (opus_int16)width_Q14; - RESTORE_STACK; -} diff --git a/Engine/lib/opus/silk/stereo_MS_to_LR.c b/Engine/lib/opus/silk/stereo_MS_to_LR.c deleted file mode 100644 index 1e01bb6eb..000000000 --- a/Engine/lib/opus/silk/stereo_MS_to_LR.c +++ /dev/null @@ -1,85 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Convert adaptive Mid/Side representation to Left/Right stereo signal */ -void silk_stereo_MS_to_LR( - stereo_dec_state *state, /* I/O State */ - opus_int16 x1[], /* I/O Left input signal, becomes mid signal */ - opus_int16 x2[], /* I/O Right input signal, becomes side signal */ - const opus_int32 pred_Q13[], /* I Predictors */ - opus_int fs_kHz, /* I Samples rate (kHz) */ - opus_int frame_length /* I Number of samples */ -) -{ - opus_int n, denom_Q16, delta0_Q13, delta1_Q13; - opus_int32 sum, diff, pred0_Q13, pred1_Q13; - - /* Buffering */ - silk_memcpy( x1, state->sMid, 2 * sizeof( opus_int16 ) ); - silk_memcpy( x2, state->sSide, 2 * sizeof( opus_int16 ) ); - silk_memcpy( state->sMid, &x1[ frame_length ], 2 * sizeof( opus_int16 ) ); - silk_memcpy( state->sSide, &x2[ frame_length ], 2 * sizeof( opus_int16 ) ); - - /* Interpolate predictors and add prediction to side channel */ - pred0_Q13 = state->pred_prev_Q13[ 0 ]; - pred1_Q13 = state->pred_prev_Q13[ 1 ]; - denom_Q16 = silk_DIV32_16( (opus_int32)1 << 16, STEREO_INTERP_LEN_MS * fs_kHz ); - delta0_Q13 = silk_RSHIFT_ROUND( silk_SMULBB( pred_Q13[ 0 ] - state->pred_prev_Q13[ 0 ], denom_Q16 ), 16 ); - delta1_Q13 = silk_RSHIFT_ROUND( silk_SMULBB( pred_Q13[ 1 ] - state->pred_prev_Q13[ 1 ], denom_Q16 ), 16 ); - for( n = 0; n < STEREO_INTERP_LEN_MS * fs_kHz; n++ ) { - pred0_Q13 += delta0_Q13; - pred1_Q13 += delta1_Q13; - sum = silk_LSHIFT( silk_ADD_LSHIFT32( x1[ n ] + (opus_int32)x1[ n + 2 ], x1[ n + 1 ], 1 ), 9 ); /* Q11 */ - sum = silk_SMLAWB( silk_LSHIFT( (opus_int32)x2[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */ - sum = silk_SMLAWB( sum, silk_LSHIFT( (opus_int32)x1[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ - x2[ n + 1 ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sum, 8 ) ); - } - pred0_Q13 = pred_Q13[ 0 ]; - pred1_Q13 = pred_Q13[ 1 ]; - for( n = STEREO_INTERP_LEN_MS * fs_kHz; n < frame_length; n++ ) { - sum = silk_LSHIFT( silk_ADD_LSHIFT32( x1[ n ] + (opus_int32)x1[ n + 2 ], x1[ n + 1 ], 1 ), 9 ); /* Q11 */ - sum = silk_SMLAWB( silk_LSHIFT( (opus_int32)x2[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */ - sum = silk_SMLAWB( sum, silk_LSHIFT( (opus_int32)x1[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ - x2[ n + 1 ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sum, 8 ) ); - } - state->pred_prev_Q13[ 0 ] = pred_Q13[ 0 ]; - state->pred_prev_Q13[ 1 ] = pred_Q13[ 1 ]; - - /* Convert to left/right signals */ - for( n = 0; n < frame_length; n++ ) { - sum = x1[ n + 1 ] + (opus_int32)x2[ n + 1 ]; - diff = x1[ n + 1 ] - (opus_int32)x2[ n + 1 ]; - x1[ n + 1 ] = (opus_int16)silk_SAT16( sum ); - x2[ n + 1 ] = (opus_int16)silk_SAT16( diff ); - } -} diff --git a/Engine/lib/opus/silk/stereo_decode_pred.c b/Engine/lib/opus/silk/stereo_decode_pred.c deleted file mode 100644 index 56ba3925e..000000000 --- a/Engine/lib/opus/silk/stereo_decode_pred.c +++ /dev/null @@ -1,73 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Decode mid/side predictors */ -void silk_stereo_decode_pred( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int32 pred_Q13[] /* O Predictors */ -) -{ - opus_int n, ix[ 2 ][ 3 ]; - opus_int32 low_Q13, step_Q13; - - /* Entropy decoding */ - n = ec_dec_icdf( psRangeDec, silk_stereo_pred_joint_iCDF, 8 ); - ix[ 0 ][ 2 ] = silk_DIV32_16( n, 5 ); - ix[ 1 ][ 2 ] = n - 5 * ix[ 0 ][ 2 ]; - for( n = 0; n < 2; n++ ) { - ix[ n ][ 0 ] = ec_dec_icdf( psRangeDec, silk_uniform3_iCDF, 8 ); - ix[ n ][ 1 ] = ec_dec_icdf( psRangeDec, silk_uniform5_iCDF, 8 ); - } - - /* Dequantize */ - for( n = 0; n < 2; n++ ) { - ix[ n ][ 0 ] += 3 * ix[ n ][ 2 ]; - low_Q13 = silk_stereo_pred_quant_Q13[ ix[ n ][ 0 ] ]; - step_Q13 = silk_SMULWB( silk_stereo_pred_quant_Q13[ ix[ n ][ 0 ] + 1 ] - low_Q13, - SILK_FIX_CONST( 0.5 / STEREO_QUANT_SUB_STEPS, 16 ) ); - pred_Q13[ n ] = silk_SMLABB( low_Q13, step_Q13, 2 * ix[ n ][ 1 ] + 1 ); - } - - /* Subtract second from first predictor (helps when actually applying these) */ - pred_Q13[ 0 ] -= pred_Q13[ 1 ]; -} - -/* Decode mid-only flag */ -void silk_stereo_decode_mid_only( - ec_dec *psRangeDec, /* I/O Compressor data structure */ - opus_int *decode_only_mid /* O Flag that only mid channel has been coded */ -) -{ - /* Decode flag that only mid channel is coded */ - *decode_only_mid = ec_dec_icdf( psRangeDec, silk_stereo_only_code_mid_iCDF, 8 ); -} diff --git a/Engine/lib/opus/silk/stereo_encode_pred.c b/Engine/lib/opus/silk/stereo_encode_pred.c deleted file mode 100644 index 03becb673..000000000 --- a/Engine/lib/opus/silk/stereo_encode_pred.c +++ /dev/null @@ -1,62 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Entropy code the mid/side quantization indices */ -void silk_stereo_encode_pred( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int8 ix[ 2 ][ 3 ] /* I Quantization indices */ -) -{ - opus_int n; - - /* Entropy coding */ - n = 5 * ix[ 0 ][ 2 ] + ix[ 1 ][ 2 ]; - celt_assert( n < 25 ); - ec_enc_icdf( psRangeEnc, n, silk_stereo_pred_joint_iCDF, 8 ); - for( n = 0; n < 2; n++ ) { - celt_assert( ix[ n ][ 0 ] < 3 ); - celt_assert( ix[ n ][ 1 ] < STEREO_QUANT_SUB_STEPS ); - ec_enc_icdf( psRangeEnc, ix[ n ][ 0 ], silk_uniform3_iCDF, 8 ); - ec_enc_icdf( psRangeEnc, ix[ n ][ 1 ], silk_uniform5_iCDF, 8 ); - } -} - -/* Entropy code the mid-only flag */ -void silk_stereo_encode_mid_only( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - opus_int8 mid_only_flag -) -{ - /* Encode flag that only mid channel is coded */ - ec_enc_icdf( psRangeEnc, mid_only_flag, silk_stereo_only_code_mid_iCDF, 8 ); -} diff --git a/Engine/lib/opus/silk/stereo_find_predictor.c b/Engine/lib/opus/silk/stereo_find_predictor.c deleted file mode 100644 index e30e90bdd..000000000 --- a/Engine/lib/opus/silk/stereo_find_predictor.c +++ /dev/null @@ -1,79 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Find least-squares prediction gain for one signal based on another and quantize it */ -opus_int32 silk_stereo_find_predictor( /* O Returns predictor in Q13 */ - opus_int32 *ratio_Q14, /* O Ratio of residual and mid energies */ - const opus_int16 x[], /* I Basis signal */ - const opus_int16 y[], /* I Target signal */ - opus_int32 mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */ - opus_int length, /* I Number of samples */ - opus_int smooth_coef_Q16 /* I Smoothing coefficient */ -) -{ - opus_int scale, scale1, scale2; - opus_int32 nrgx, nrgy, corr, pred_Q13, pred2_Q10; - - /* Find predictor */ - silk_sum_sqr_shift( &nrgx, &scale1, x, length ); - silk_sum_sqr_shift( &nrgy, &scale2, y, length ); - scale = silk_max_int( scale1, scale2 ); - scale = scale + ( scale & 1 ); /* make even */ - nrgy = silk_RSHIFT32( nrgy, scale - scale2 ); - nrgx = silk_RSHIFT32( nrgx, scale - scale1 ); - nrgx = silk_max_int( nrgx, 1 ); - corr = silk_inner_prod_aligned_scale( x, y, scale, length ); - pred_Q13 = silk_DIV32_varQ( corr, nrgx, 13 ); - pred_Q13 = silk_LIMIT( pred_Q13, -(1 << 14), 1 << 14 ); - pred2_Q10 = silk_SMULWB( pred_Q13, pred_Q13 ); - - /* Faster update for signals with large prediction parameters */ - smooth_coef_Q16 = (opus_int)silk_max_int( smooth_coef_Q16, silk_abs( pred2_Q10 ) ); - - /* Smoothed mid and residual norms */ - silk_assert( smooth_coef_Q16 < 32768 ); - scale = silk_RSHIFT( scale, 1 ); - mid_res_amp_Q0[ 0 ] = silk_SMLAWB( mid_res_amp_Q0[ 0 ], silk_LSHIFT( silk_SQRT_APPROX( nrgx ), scale ) - mid_res_amp_Q0[ 0 ], - smooth_coef_Q16 ); - /* Residual energy = nrgy - 2 * pred * corr + pred^2 * nrgx */ - nrgy = silk_SUB_LSHIFT32( nrgy, silk_SMULWB( corr, pred_Q13 ), 3 + 1 ); - nrgy = silk_ADD_LSHIFT32( nrgy, silk_SMULWB( nrgx, pred2_Q10 ), 6 ); - mid_res_amp_Q0[ 1 ] = silk_SMLAWB( mid_res_amp_Q0[ 1 ], silk_LSHIFT( silk_SQRT_APPROX( nrgy ), scale ) - mid_res_amp_Q0[ 1 ], - smooth_coef_Q16 ); - - /* Ratio of smoothed residual and mid norms */ - *ratio_Q14 = silk_DIV32_varQ( mid_res_amp_Q0[ 1 ], silk_max( mid_res_amp_Q0[ 0 ], 1 ), 14 ); - *ratio_Q14 = silk_LIMIT( *ratio_Q14, 0, 32767 ); - - return pred_Q13; -} diff --git a/Engine/lib/opus/silk/stereo_quant_pred.c b/Engine/lib/opus/silk/stereo_quant_pred.c deleted file mode 100644 index d4ced6c3e..000000000 --- a/Engine/lib/opus/silk/stereo_quant_pred.c +++ /dev/null @@ -1,73 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "main.h" - -/* Quantize mid/side predictors */ -void silk_stereo_quant_pred( - opus_int32 pred_Q13[], /* I/O Predictors (out: quantized) */ - opus_int8 ix[ 2 ][ 3 ] /* O Quantization indices */ -) -{ - opus_int i, j, n; - opus_int32 low_Q13, step_Q13, lvl_Q13, err_min_Q13, err_Q13, quant_pred_Q13 = 0; - - /* Quantize */ - for( n = 0; n < 2; n++ ) { - /* Brute-force search over quantization levels */ - err_min_Q13 = silk_int32_MAX; - for( i = 0; i < STEREO_QUANT_TAB_SIZE - 1; i++ ) { - low_Q13 = silk_stereo_pred_quant_Q13[ i ]; - step_Q13 = silk_SMULWB( silk_stereo_pred_quant_Q13[ i + 1 ] - low_Q13, - SILK_FIX_CONST( 0.5 / STEREO_QUANT_SUB_STEPS, 16 ) ); - for( j = 0; j < STEREO_QUANT_SUB_STEPS; j++ ) { - lvl_Q13 = silk_SMLABB( low_Q13, step_Q13, 2 * j + 1 ); - err_Q13 = silk_abs( pred_Q13[ n ] - lvl_Q13 ); - if( err_Q13 < err_min_Q13 ) { - err_min_Q13 = err_Q13; - quant_pred_Q13 = lvl_Q13; - ix[ n ][ 0 ] = i; - ix[ n ][ 1 ] = j; - } else { - /* Error increasing, so we're past the optimum */ - goto done; - } - } - } - done: - ix[ n ][ 2 ] = silk_DIV32_16( ix[ n ][ 0 ], 3 ); - ix[ n ][ 0 ] -= ix[ n ][ 2 ] * 3; - pred_Q13[ n ] = quant_pred_Q13; - } - - /* Subtract second from first predictor (helps when actually applying these) */ - pred_Q13[ 0 ] -= pred_Q13[ 1 ]; -} diff --git a/Engine/lib/opus/silk/structs.h b/Engine/lib/opus/silk/structs.h deleted file mode 100644 index 3380c757b..000000000 --- a/Engine/lib/opus/silk/structs.h +++ /dev/null @@ -1,329 +0,0 @@ -/*********************************************************************** -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 SILK_STRUCTS_H -#define SILK_STRUCTS_H - -#include "typedef.h" -#include "SigProc_FIX.h" -#include "define.h" -#include "entenc.h" -#include "entdec.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/************************************/ -/* Noise shaping quantization state */ -/************************************/ -typedef struct { - opus_int16 xq[ 2 * MAX_FRAME_LENGTH ]; /* Buffer for quantized output signal */ - opus_int32 sLTP_shp_Q14[ 2 * MAX_FRAME_LENGTH ]; - opus_int32 sLPC_Q14[ MAX_SUB_FRAME_LENGTH + NSQ_LPC_BUF_LENGTH ]; - opus_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ]; - opus_int32 sLF_AR_shp_Q14; - opus_int32 sDiff_shp_Q14; - opus_int lagPrev; - opus_int sLTP_buf_idx; - opus_int sLTP_shp_buf_idx; - opus_int32 rand_seed; - opus_int32 prev_gain_Q16; - opus_int rewhite_flag; -} silk_nsq_state; - -/********************************/ -/* VAD state */ -/********************************/ -typedef struct { - opus_int32 AnaState[ 2 ]; /* Analysis filterbank state: 0-8 kHz */ - opus_int32 AnaState1[ 2 ]; /* Analysis filterbank state: 0-4 kHz */ - opus_int32 AnaState2[ 2 ]; /* Analysis filterbank state: 0-2 kHz */ - opus_int32 XnrgSubfr[ VAD_N_BANDS ]; /* Subframe energies */ - opus_int32 NrgRatioSmth_Q8[ VAD_N_BANDS ]; /* Smoothed energy level in each band */ - opus_int16 HPstate; /* State of differentiator in the lowest band */ - opus_int32 NL[ VAD_N_BANDS ]; /* Noise energy level in each band */ - opus_int32 inv_NL[ VAD_N_BANDS ]; /* Inverse noise energy level in each band */ - opus_int32 NoiseLevelBias[ VAD_N_BANDS ]; /* Noise level estimator bias/offset */ - opus_int32 counter; /* Frame counter used in the initial phase */ -} silk_VAD_state; - -/* Variable cut-off low-pass filter state */ -typedef struct { - opus_int32 In_LP_State[ 2 ]; /* Low pass filter state */ - opus_int32 transition_frame_no; /* Counter which is mapped to a cut-off frequency */ - opus_int mode; /* Operating mode, <0: switch down, >0: switch up; 0: do nothing */ - opus_int32 saved_fs_kHz; /* If non-zero, holds the last sampling rate before a bandwidth switching reset. */ -} silk_LP_state; - -/* Structure containing NLSF codebook */ -typedef struct { - const opus_int16 nVectors; - const opus_int16 order; - const opus_int16 quantStepSize_Q16; - const opus_int16 invQuantStepSize_Q6; - const opus_uint8 *CB1_NLSF_Q8; - const opus_int16 *CB1_Wght_Q9; - const opus_uint8 *CB1_iCDF; - const opus_uint8 *pred_Q8; - const opus_uint8 *ec_sel; - const opus_uint8 *ec_iCDF; - const opus_uint8 *ec_Rates_Q5; - const opus_int16 *deltaMin_Q15; -} silk_NLSF_CB_struct; - -typedef struct { - opus_int16 pred_prev_Q13[ 2 ]; - opus_int16 sMid[ 2 ]; - opus_int16 sSide[ 2 ]; - opus_int32 mid_side_amp_Q0[ 4 ]; - opus_int16 smth_width_Q14; - opus_int16 width_prev_Q14; - opus_int16 silent_side_len; - opus_int8 predIx[ MAX_FRAMES_PER_PACKET ][ 2 ][ 3 ]; - opus_int8 mid_only_flags[ MAX_FRAMES_PER_PACKET ]; -} stereo_enc_state; - -typedef struct { - opus_int16 pred_prev_Q13[ 2 ]; - opus_int16 sMid[ 2 ]; - opus_int16 sSide[ 2 ]; -} stereo_dec_state; - -typedef struct { - opus_int8 GainsIndices[ MAX_NB_SUBFR ]; - opus_int8 LTPIndex[ MAX_NB_SUBFR ]; - opus_int8 NLSFIndices[ MAX_LPC_ORDER + 1 ]; - opus_int16 lagIndex; - opus_int8 contourIndex; - opus_int8 signalType; - opus_int8 quantOffsetType; - opus_int8 NLSFInterpCoef_Q2; - opus_int8 PERIndex; - opus_int8 LTP_scaleIndex; - opus_int8 Seed; -} SideInfoIndices; - -/********************************/ -/* Encoder state */ -/********************************/ -typedef struct { - opus_int32 In_HP_State[ 2 ]; /* High pass filter state */ - opus_int32 variable_HP_smth1_Q15; /* State of first smoother */ - opus_int32 variable_HP_smth2_Q15; /* State of second smoother */ - silk_LP_state sLP; /* Low pass filter state */ - silk_VAD_state sVAD; /* Voice activity detector state */ - silk_nsq_state sNSQ; /* Noise Shape Quantizer State */ - opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ]; /* Previously quantized NLSF vector */ - opus_int speech_activity_Q8; /* Speech activity */ - opus_int allow_bandwidth_switch; /* Flag indicating that switching of internal bandwidth is allowed */ - opus_int8 LBRRprevLastGainIndex; - opus_int8 prevSignalType; - opus_int prevLag; - opus_int pitch_LPC_win_length; - opus_int max_pitch_lag; /* Highest possible pitch lag (samples) */ - opus_int32 API_fs_Hz; /* API sampling frequency (Hz) */ - opus_int32 prev_API_fs_Hz; /* Previous API sampling frequency (Hz) */ - opus_int maxInternal_fs_Hz; /* Maximum internal sampling frequency (Hz) */ - opus_int minInternal_fs_Hz; /* Minimum internal sampling frequency (Hz) */ - opus_int desiredInternal_fs_Hz; /* Soft request for internal sampling frequency (Hz) */ - opus_int fs_kHz; /* Internal sampling frequency (kHz) */ - opus_int nb_subfr; /* Number of 5 ms subframes in a frame */ - opus_int frame_length; /* Frame length (samples) */ - opus_int subfr_length; /* Subframe length (samples) */ - opus_int ltp_mem_length; /* Length of LTP memory */ - opus_int la_pitch; /* Look-ahead for pitch analysis (samples) */ - opus_int la_shape; /* Look-ahead for noise shape analysis (samples) */ - opus_int shapeWinLength; /* Window length for noise shape analysis (samples) */ - opus_int32 TargetRate_bps; /* Target bitrate (bps) */ - opus_int PacketSize_ms; /* Number of milliseconds to put in each packet */ - opus_int PacketLoss_perc; /* Packet loss rate measured by farend */ - opus_int32 frameCounter; - opus_int Complexity; /* Complexity setting */ - opus_int nStatesDelayedDecision; /* Number of states in delayed decision quantization */ - opus_int useInterpolatedNLSFs; /* Flag for using NLSF interpolation */ - opus_int shapingLPCOrder; /* Filter order for noise shaping filters */ - opus_int predictLPCOrder; /* Filter order for prediction filters */ - opus_int pitchEstimationComplexity; /* Complexity level for pitch estimator */ - opus_int pitchEstimationLPCOrder; /* Whitening filter order for pitch estimator */ - opus_int32 pitchEstimationThreshold_Q16; /* Threshold for pitch estimator */ - opus_int32 sum_log_gain_Q7; /* Cumulative max prediction gain */ - opus_int NLSF_MSVQ_Survivors; /* Number of survivors in NLSF MSVQ */ - opus_int first_frame_after_reset; /* Flag for deactivating NLSF interpolation, pitch prediction */ - opus_int controlled_since_last_payload; /* Flag for ensuring codec_control only runs once per packet */ - opus_int warping_Q16; /* Warping parameter for warped noise shaping */ - opus_int useCBR; /* Flag to enable constant bitrate */ - opus_int prefillFlag; /* Flag to indicate that only buffers are prefilled, no coding */ - const opus_uint8 *pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */ - const opus_uint8 *pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */ - const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ - opus_int input_quality_bands_Q15[ VAD_N_BANDS ]; - opus_int input_tilt_Q15; - opus_int SNR_dB_Q7; /* Quality setting */ - - opus_int8 VAD_flags[ MAX_FRAMES_PER_PACKET ]; - opus_int8 LBRR_flag; - opus_int LBRR_flags[ MAX_FRAMES_PER_PACKET ]; - - SideInfoIndices indices; - opus_int8 pulses[ MAX_FRAME_LENGTH ]; - - int arch; - - /* Input/output buffering */ - opus_int16 inputBuf[ MAX_FRAME_LENGTH + 2 ]; /* Buffer containing input signal */ - opus_int inputBufIx; - opus_int nFramesPerPacket; - opus_int nFramesEncoded; /* Number of frames analyzed in current packet */ - - opus_int nChannelsAPI; - opus_int nChannelsInternal; - opus_int channelNb; - - /* Parameters For LTP scaling Control */ - opus_int frames_since_onset; - - /* Specifically for entropy coding */ - opus_int ec_prevSignalType; - opus_int16 ec_prevLagIndex; - - silk_resampler_state_struct resampler_state; - - /* DTX */ - opus_int useDTX; /* Flag to enable DTX */ - opus_int inDTX; /* Flag to signal DTX period */ - opus_int noSpeechCounter; /* Counts concecutive nonactive frames, used by DTX */ - - /* Inband Low Bitrate Redundancy (LBRR) data */ - opus_int useInBandFEC; /* Saves the API setting for query */ - opus_int LBRR_enabled; /* Depends on useInBandFRC, bitrate and packet loss rate */ - opus_int LBRR_GainIncreases; /* Gains increment for coding LBRR frames */ - SideInfoIndices indices_LBRR[ MAX_FRAMES_PER_PACKET ]; - opus_int8 pulses_LBRR[ MAX_FRAMES_PER_PACKET ][ MAX_FRAME_LENGTH ]; -} silk_encoder_state; - - -/* Struct for Packet Loss Concealment */ -typedef struct { - opus_int32 pitchL_Q8; /* Pitch lag to use for voiced concealment */ - opus_int16 LTPCoef_Q14[ LTP_ORDER ]; /* LTP coeficients to use for voiced concealment */ - opus_int16 prevLPC_Q12[ MAX_LPC_ORDER ]; - opus_int last_frame_lost; /* Was previous frame lost */ - opus_int32 rand_seed; /* Seed for unvoiced signal generation */ - opus_int16 randScale_Q14; /* Scaling of unvoiced random signal */ - opus_int32 conc_energy; - opus_int conc_energy_shift; - opus_int16 prevLTP_scale_Q14; - opus_int32 prevGain_Q16[ 2 ]; - opus_int fs_kHz; - opus_int nb_subfr; - opus_int subfr_length; -} silk_PLC_struct; - -/* Struct for CNG */ -typedef struct { - opus_int32 CNG_exc_buf_Q14[ MAX_FRAME_LENGTH ]; - opus_int16 CNG_smth_NLSF_Q15[ MAX_LPC_ORDER ]; - opus_int32 CNG_synth_state[ MAX_LPC_ORDER ]; - opus_int32 CNG_smth_Gain_Q16; - opus_int32 rand_seed; - opus_int fs_kHz; -} silk_CNG_struct; - -/********************************/ -/* Decoder state */ -/********************************/ -typedef struct { - opus_int32 prev_gain_Q16; - opus_int32 exc_Q14[ MAX_FRAME_LENGTH ]; - opus_int32 sLPC_Q14_buf[ MAX_LPC_ORDER ]; - opus_int16 outBuf[ MAX_FRAME_LENGTH + 2 * MAX_SUB_FRAME_LENGTH ]; /* Buffer for output signal */ - opus_int lagPrev; /* Previous Lag */ - opus_int8 LastGainIndex; /* Previous gain index */ - opus_int fs_kHz; /* Sampling frequency in kHz */ - opus_int32 fs_API_hz; /* API sample frequency (Hz) */ - opus_int nb_subfr; /* Number of 5 ms subframes in a frame */ - opus_int frame_length; /* Frame length (samples) */ - opus_int subfr_length; /* Subframe length (samples) */ - opus_int ltp_mem_length; /* Length of LTP memory */ - opus_int LPC_order; /* LPC order */ - opus_int16 prevNLSF_Q15[ MAX_LPC_ORDER ]; /* Used to interpolate LSFs */ - opus_int first_frame_after_reset; /* Flag for deactivating NLSF interpolation */ - const opus_uint8 *pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */ - const opus_uint8 *pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */ - - /* For buffering payload in case of more frames per packet */ - opus_int nFramesDecoded; - opus_int nFramesPerPacket; - - /* Specifically for entropy coding */ - opus_int ec_prevSignalType; - opus_int16 ec_prevLagIndex; - - opus_int VAD_flags[ MAX_FRAMES_PER_PACKET ]; - opus_int LBRR_flag; - opus_int LBRR_flags[ MAX_FRAMES_PER_PACKET ]; - - silk_resampler_state_struct resampler_state; - - const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ - - /* Quantization indices */ - SideInfoIndices indices; - - /* CNG state */ - silk_CNG_struct sCNG; - - /* Stuff used for PLC */ - opus_int lossCnt; - opus_int prevSignalType; - int arch; - - silk_PLC_struct sPLC; - -} silk_decoder_state; - -/************************/ -/* Decoder control */ -/************************/ -typedef struct { - /* Prediction and coding parameters */ - opus_int pitchL[ MAX_NB_SUBFR ]; - opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; - /* Holds interpolated and final coefficients, 4-byte aligned */ - silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; - opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; - opus_int LTP_scale_Q14; -} silk_decoder_control; - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/silk/sum_sqr_shift.c b/Engine/lib/opus/silk/sum_sqr_shift.c deleted file mode 100644 index 4fd0c3d7d..000000000 --- a/Engine/lib/opus/silk/sum_sqr_shift.c +++ /dev/null @@ -1,83 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "SigProc_FIX.h" - -/* Compute number of bits to right shift the sum of squares of a vector */ -/* of int16s to make it fit in an int32 */ -void silk_sum_sqr_shift( - opus_int32 *energy, /* O Energy of x, after shifting to the right */ - opus_int *shift, /* O Number of bits right shift applied to energy */ - const opus_int16 *x, /* I Input vector */ - opus_int len /* I Length of input vector */ -) -{ - opus_int i, shft; - opus_uint32 nrg_tmp; - opus_int32 nrg; - - /* Do a first run with the maximum shift we could have. */ - shft = 31-silk_CLZ32(len); - /* Let's be conservative with rounding and start with nrg=len. */ - nrg = len; - for( i = 0; i < len - 1; i += 2 ) { - nrg_tmp = silk_SMULBB( x[ i ], x[ i ] ); - nrg_tmp = silk_SMLABB_ovflw( nrg_tmp, x[ i + 1 ], x[ i + 1 ] ); - nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft ); - } - if( i < len ) { - /* One sample left to process */ - nrg_tmp = silk_SMULBB( x[ i ], x[ i ] ); - nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft ); - } - silk_assert( nrg >= 0 ); - /* Make sure the result will fit in a 32-bit signed integer with two bits - of headroom. */ - shft = silk_max_32(0, shft+3 - silk_CLZ32(nrg)); - nrg = 0; - for( i = 0 ; i < len - 1; i += 2 ) { - nrg_tmp = silk_SMULBB( x[ i ], x[ i ] ); - nrg_tmp = silk_SMLABB_ovflw( nrg_tmp, x[ i + 1 ], x[ i + 1 ] ); - nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft ); - } - if( i < len ) { - /* One sample left to process */ - nrg_tmp = silk_SMULBB( x[ i ], x[ i ] ); - nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft ); - } - - silk_assert( nrg >= 0 ); - - /* Output arguments */ - *shift = shft; - *energy = nrg; -} - diff --git a/Engine/lib/opus/silk/table_LSF_cos.c b/Engine/lib/opus/silk/table_LSF_cos.c deleted file mode 100644 index ec9dc6392..000000000 --- a/Engine/lib/opus/silk/table_LSF_cos.c +++ /dev/null @@ -1,70 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "tables.h" - -/* Cosine approximation table for LSF conversion */ -/* Q12 values (even) */ -const opus_int16 silk_LSFCosTab_FIX_Q12[ LSF_COS_TAB_SZ_FIX + 1 ] = { - 8192, 8190, 8182, 8170, - 8152, 8130, 8104, 8072, - 8034, 7994, 7946, 7896, - 7840, 7778, 7714, 7644, - 7568, 7490, 7406, 7318, - 7226, 7128, 7026, 6922, - 6812, 6698, 6580, 6458, - 6332, 6204, 6070, 5934, - 5792, 5648, 5502, 5352, - 5198, 5040, 4880, 4718, - 4552, 4382, 4212, 4038, - 3862, 3684, 3502, 3320, - 3136, 2948, 2760, 2570, - 2378, 2186, 1990, 1794, - 1598, 1400, 1202, 1002, - 802, 602, 402, 202, - 0, -202, -402, -602, - -802, -1002, -1202, -1400, - -1598, -1794, -1990, -2186, - -2378, -2570, -2760, -2948, - -3136, -3320, -3502, -3684, - -3862, -4038, -4212, -4382, - -4552, -4718, -4880, -5040, - -5198, -5352, -5502, -5648, - -5792, -5934, -6070, -6204, - -6332, -6458, -6580, -6698, - -6812, -6922, -7026, -7128, - -7226, -7318, -7406, -7490, - -7568, -7644, -7714, -7778, - -7840, -7896, -7946, -7994, - -8034, -8072, -8104, -8130, - -8152, -8170, -8182, -8190, - -8192 -}; diff --git a/Engine/lib/opus/silk/tables.h b/Engine/lib/opus/silk/tables.h deleted file mode 100644 index 95230c451..000000000 --- a/Engine/lib/opus/silk/tables.h +++ /dev/null @@ -1,114 +0,0 @@ -/*********************************************************************** -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 SILK_TABLES_H -#define SILK_TABLES_H - -#include "define.h" -#include "structs.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Entropy coding tables (with size in bytes indicated) */ -extern const opus_uint8 silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ]; /* 24 */ -extern const opus_uint8 silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ]; /* 41 */ - -extern const opus_uint8 silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ];/* 32 */ -extern const opus_uint8 silk_pitch_delta_iCDF[ 21 ]; /* 21 */ -extern const opus_uint8 silk_pitch_contour_iCDF[ 34 ]; /* 34 */ -extern const opus_uint8 silk_pitch_contour_NB_iCDF[ 11 ]; /* 11 */ -extern const opus_uint8 silk_pitch_contour_10_ms_iCDF[ 12 ]; /* 12 */ -extern const opus_uint8 silk_pitch_contour_10_ms_NB_iCDF[ 3 ]; /* 3 */ - -extern const opus_uint8 silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ SILK_MAX_PULSES + 2 ]; /* 180 */ -extern const opus_uint8 silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ SILK_MAX_PULSES + 2 ]; /* 162 */ - -extern const opus_uint8 silk_rate_levels_iCDF[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ -extern const opus_uint8 silk_rate_levels_BITS_Q5[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ - -extern const opus_uint8 silk_max_pulses_table[ 4 ]; /* 4 */ - -extern const opus_uint8 silk_shell_code_table0[ 152 ]; /* 152 */ -extern const opus_uint8 silk_shell_code_table1[ 152 ]; /* 152 */ -extern const opus_uint8 silk_shell_code_table2[ 152 ]; /* 152 */ -extern const opus_uint8 silk_shell_code_table3[ 152 ]; /* 152 */ -extern const opus_uint8 silk_shell_code_table_offsets[ SILK_MAX_PULSES + 1 ]; /* 17 */ - -extern const opus_uint8 silk_lsb_iCDF[ 2 ]; /* 2 */ - -extern const opus_uint8 silk_sign_iCDF[ 42 ]; /* 42 */ - -extern const opus_uint8 silk_uniform3_iCDF[ 3 ]; /* 3 */ -extern const opus_uint8 silk_uniform4_iCDF[ 4 ]; /* 4 */ -extern const opus_uint8 silk_uniform5_iCDF[ 5 ]; /* 5 */ -extern const opus_uint8 silk_uniform6_iCDF[ 6 ]; /* 6 */ -extern const opus_uint8 silk_uniform8_iCDF[ 8 ]; /* 8 */ - -extern const opus_uint8 silk_NLSF_EXT_iCDF[ 7 ]; /* 7 */ - -extern const opus_uint8 silk_LTP_per_index_iCDF[ 3 ]; /* 3 */ -extern const opus_uint8 * const silk_LTP_gain_iCDF_ptrs[ NB_LTP_CBKS ]; /* 3 */ -extern const opus_uint8 * const silk_LTP_gain_BITS_Q5_ptrs[ NB_LTP_CBKS ]; /* 3 */ -extern const opus_int8 * const silk_LTP_vq_ptrs_Q7[ NB_LTP_CBKS ]; /* 168 */ -extern const opus_uint8 * const silk_LTP_vq_gain_ptrs_Q7[NB_LTP_CBKS]; -extern const opus_int8 silk_LTP_vq_sizes[ NB_LTP_CBKS ]; /* 3 */ - -extern const opus_uint8 silk_LTPscale_iCDF[ 3 ]; /* 4 */ -extern const opus_int16 silk_LTPScales_table_Q14[ 3 ]; /* 6 */ - -extern const opus_uint8 silk_type_offset_VAD_iCDF[ 4 ]; /* 4 */ -extern const opus_uint8 silk_type_offset_no_VAD_iCDF[ 2 ]; /* 2 */ - -extern const opus_int16 silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ]; /* 32 */ -extern const opus_uint8 silk_stereo_pred_joint_iCDF[ 25 ]; /* 25 */ -extern const opus_uint8 silk_stereo_only_code_mid_iCDF[ 2 ]; /* 2 */ - -extern const opus_uint8 * const silk_LBRR_flags_iCDF_ptr[ 2 ]; /* 10 */ - -extern const opus_uint8 silk_NLSF_interpolation_factor_iCDF[ 5 ]; /* 5 */ - -extern const silk_NLSF_CB_struct silk_NLSF_CB_WB; /* 1040 */ -extern const silk_NLSF_CB_struct silk_NLSF_CB_NB_MB; /* 728 */ - -/* Quantization offsets */ -extern const opus_int16 silk_Quantization_Offsets_Q10[ 2 ][ 2 ]; /* 8 */ - -/* Interpolation points for filter coefficients used in the bandwidth transition smoother */ -extern const opus_int32 silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ]; /* 60 */ -extern const opus_int32 silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ]; /* 60 */ - -/* Rom table with cosine values */ -extern const opus_int16 silk_LSFCosTab_FIX_Q12[ LSF_COS_TAB_SZ_FIX + 1 ]; /* 258 */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Engine/lib/opus/silk/tables_LTP.c b/Engine/lib/opus/silk/tables_LTP.c deleted file mode 100644 index 5e12c8643..000000000 --- a/Engine/lib/opus/silk/tables_LTP.c +++ /dev/null @@ -1,294 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "tables.h" - -const opus_uint8 silk_LTP_per_index_iCDF[3] = { - 179, 99, 0 -}; - -static const opus_uint8 silk_LTP_gain_iCDF_0[8] = { - 71, 56, 43, 30, 21, 12, 6, 0 -}; - -static const opus_uint8 silk_LTP_gain_iCDF_1[16] = { - 199, 165, 144, 124, 109, 96, 84, 71, - 61, 51, 42, 32, 23, 15, 8, 0 -}; - -static const opus_uint8 silk_LTP_gain_iCDF_2[32] = { - 241, 225, 211, 199, 187, 175, 164, 153, - 142, 132, 123, 114, 105, 96, 88, 80, - 72, 64, 57, 50, 44, 38, 33, 29, - 24, 20, 16, 12, 9, 5, 2, 0 -}; - -static const opus_uint8 silk_LTP_gain_BITS_Q5_0[8] = { - 15, 131, 138, 138, 155, 155, 173, 173 -}; - -static const opus_uint8 silk_LTP_gain_BITS_Q5_1[16] = { - 69, 93, 115, 118, 131, 138, 141, 138, - 150, 150, 155, 150, 155, 160, 166, 160 -}; - -static const opus_uint8 silk_LTP_gain_BITS_Q5_2[32] = { - 131, 128, 134, 141, 141, 141, 145, 145, - 145, 150, 155, 155, 155, 155, 160, 160, - 160, 160, 166, 166, 173, 173, 182, 192, - 182, 192, 192, 192, 205, 192, 205, 224 -}; - -const opus_uint8 * const silk_LTP_gain_iCDF_ptrs[NB_LTP_CBKS] = { - silk_LTP_gain_iCDF_0, - silk_LTP_gain_iCDF_1, - silk_LTP_gain_iCDF_2 -}; - -const opus_uint8 * const silk_LTP_gain_BITS_Q5_ptrs[NB_LTP_CBKS] = { - silk_LTP_gain_BITS_Q5_0, - silk_LTP_gain_BITS_Q5_1, - silk_LTP_gain_BITS_Q5_2 -}; - -static const opus_int8 silk_LTP_gain_vq_0[8][5] = -{ -{ - 4, 6, 24, 7, 5 -}, -{ - 0, 0, 2, 0, 0 -}, -{ - 12, 28, 41, 13, -4 -}, -{ - -9, 15, 42, 25, 14 -}, -{ - 1, -2, 62, 41, -9 -}, -{ - -10, 37, 65, -4, 3 -}, -{ - -6, 4, 66, 7, -8 -}, -{ - 16, 14, 38, -3, 33 -} -}; - -static const opus_int8 silk_LTP_gain_vq_1[16][5] = -{ -{ - 13, 22, 39, 23, 12 -}, -{ - -1, 36, 64, 27, -6 -}, -{ - -7, 10, 55, 43, 17 -}, -{ - 1, 1, 8, 1, 1 -}, -{ - 6, -11, 74, 53, -9 -}, -{ - -12, 55, 76, -12, 8 -}, -{ - -3, 3, 93, 27, -4 -}, -{ - 26, 39, 59, 3, -8 -}, -{ - 2, 0, 77, 11, 9 -}, -{ - -8, 22, 44, -6, 7 -}, -{ - 40, 9, 26, 3, 9 -}, -{ - -7, 20, 101, -7, 4 -}, -{ - 3, -8, 42, 26, 0 -}, -{ - -15, 33, 68, 2, 23 -}, -{ - -2, 55, 46, -2, 15 -}, -{ - 3, -1, 21, 16, 41 -} -}; - -static const opus_int8 silk_LTP_gain_vq_2[32][5] = -{ -{ - -6, 27, 61, 39, 5 -}, -{ - -11, 42, 88, 4, 1 -}, -{ - -2, 60, 65, 6, -4 -}, -{ - -1, -5, 73, 56, 1 -}, -{ - -9, 19, 94, 29, -9 -}, -{ - 0, 12, 99, 6, 4 -}, -{ - 8, -19, 102, 46, -13 -}, -{ - 3, 2, 13, 3, 2 -}, -{ - 9, -21, 84, 72, -18 -}, -{ - -11, 46, 104, -22, 8 -}, -{ - 18, 38, 48, 23, 0 -}, -{ - -16, 70, 83, -21, 11 -}, -{ - 5, -11, 117, 22, -8 -}, -{ - -6, 23, 117, -12, 3 -}, -{ - 3, -8, 95, 28, 4 -}, -{ - -10, 15, 77, 60, -15 -}, -{ - -1, 4, 124, 2, -4 -}, -{ - 3, 38, 84, 24, -25 -}, -{ - 2, 13, 42, 13, 31 -}, -{ - 21, -4, 56, 46, -1 -}, -{ - -1, 35, 79, -13, 19 -}, -{ - -7, 65, 88, -9, -14 -}, -{ - 20, 4, 81, 49, -29 -}, -{ - 20, 0, 75, 3, -17 -}, -{ - 5, -9, 44, 92, -8 -}, -{ - 1, -3, 22, 69, 31 -}, -{ - -6, 95, 41, -12, 5 -}, -{ - 39, 67, 16, -4, 1 -}, -{ - 0, -6, 120, 55, -36 -}, -{ - -13, 44, 122, 4, -24 -}, -{ - 81, 5, 11, 3, 7 -}, -{ - 2, 0, 9, 10, 88 -} -}; - -const opus_int8 * const silk_LTP_vq_ptrs_Q7[NB_LTP_CBKS] = { - (opus_int8 *)&silk_LTP_gain_vq_0[0][0], - (opus_int8 *)&silk_LTP_gain_vq_1[0][0], - (opus_int8 *)&silk_LTP_gain_vq_2[0][0] -}; - -/* Maximum frequency-dependent response of the pitch taps above, - computed as max(abs(freqz(taps))) */ -static const opus_uint8 silk_LTP_gain_vq_0_gain[8] = { - 46, 2, 90, 87, 93, 91, 82, 98 -}; - -static const opus_uint8 silk_LTP_gain_vq_1_gain[16] = { - 109, 120, 118, 12, 113, 115, 117, 119, - 99, 59, 87, 111, 63, 111, 112, 80 -}; - -static const opus_uint8 silk_LTP_gain_vq_2_gain[32] = { - 126, 124, 125, 124, 129, 121, 126, 23, - 132, 127, 127, 127, 126, 127, 122, 133, - 130, 134, 101, 118, 119, 145, 126, 86, - 124, 120, 123, 119, 170, 173, 107, 109 -}; - -const opus_uint8 * const silk_LTP_vq_gain_ptrs_Q7[NB_LTP_CBKS] = { - &silk_LTP_gain_vq_0_gain[0], - &silk_LTP_gain_vq_1_gain[0], - &silk_LTP_gain_vq_2_gain[0] -}; - -const opus_int8 silk_LTP_vq_sizes[NB_LTP_CBKS] = { - 8, 16, 32 -}; diff --git a/Engine/lib/opus/silk/tables_NLSF_CB_NB_MB.c b/Engine/lib/opus/silk/tables_NLSF_CB_NB_MB.c deleted file mode 100644 index 195d5b95b..000000000 --- a/Engine/lib/opus/silk/tables_NLSF_CB_NB_MB.c +++ /dev/null @@ -1,195 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "tables.h" - -static const opus_uint8 silk_NLSF_CB1_NB_MB_Q8[ 320 ] = { - 12, 35, 60, 83, 108, 132, 157, 180, - 206, 228, 15, 32, 55, 77, 101, 125, - 151, 175, 201, 225, 19, 42, 66, 89, - 114, 137, 162, 184, 209, 230, 12, 25, - 50, 72, 97, 120, 147, 172, 200, 223, - 26, 44, 69, 90, 114, 135, 159, 180, - 205, 225, 13, 22, 53, 80, 106, 130, - 156, 180, 205, 228, 15, 25, 44, 64, - 90, 115, 142, 168, 196, 222, 19, 24, - 62, 82, 100, 120, 145, 168, 190, 214, - 22, 31, 50, 79, 103, 120, 151, 170, - 203, 227, 21, 29, 45, 65, 106, 124, - 150, 171, 196, 224, 30, 49, 75, 97, - 121, 142, 165, 186, 209, 229, 19, 25, - 52, 70, 93, 116, 143, 166, 192, 219, - 26, 34, 62, 75, 97, 118, 145, 167, - 194, 217, 25, 33, 56, 70, 91, 113, - 143, 165, 196, 223, 21, 34, 51, 72, - 97, 117, 145, 171, 196, 222, 20, 29, - 50, 67, 90, 117, 144, 168, 197, 221, - 22, 31, 48, 66, 95, 117, 146, 168, - 196, 222, 24, 33, 51, 77, 116, 134, - 158, 180, 200, 224, 21, 28, 70, 87, - 106, 124, 149, 170, 194, 217, 26, 33, - 53, 64, 83, 117, 152, 173, 204, 225, - 27, 34, 65, 95, 108, 129, 155, 174, - 210, 225, 20, 26, 72, 99, 113, 131, - 154, 176, 200, 219, 34, 43, 61, 78, - 93, 114, 155, 177, 205, 229, 23, 29, - 54, 97, 124, 138, 163, 179, 209, 229, - 30, 38, 56, 89, 118, 129, 158, 178, - 200, 231, 21, 29, 49, 63, 85, 111, - 142, 163, 193, 222, 27, 48, 77, 103, - 133, 158, 179, 196, 215, 232, 29, 47, - 74, 99, 124, 151, 176, 198, 220, 237, - 33, 42, 61, 76, 93, 121, 155, 174, - 207, 225, 29, 53, 87, 112, 136, 154, - 170, 188, 208, 227, 24, 30, 52, 84, - 131, 150, 166, 186, 203, 229, 37, 48, - 64, 84, 104, 118, 156, 177, 201, 230 -}; - -static const opus_int16 silk_NLSF_CB1_Wght_Q9[ 320 ] = { - 2897, 2314, 2314, 2314, 2287, 2287, 2314, 2300, 2327, 2287, - 2888, 2580, 2394, 2367, 2314, 2274, 2274, 2274, 2274, 2194, - 2487, 2340, 2340, 2314, 2314, 2314, 2340, 2340, 2367, 2354, - 3216, 2766, 2340, 2340, 2314, 2274, 2221, 2207, 2261, 2194, - 2460, 2474, 2367, 2394, 2394, 2394, 2394, 2367, 2407, 2314, - 3479, 3056, 2127, 2207, 2274, 2274, 2274, 2287, 2314, 2261, - 3282, 3141, 2580, 2394, 2247, 2221, 2207, 2194, 2194, 2114, - 4096, 3845, 2221, 2620, 2620, 2407, 2314, 2394, 2367, 2074, - 3178, 3244, 2367, 2221, 2553, 2434, 2340, 2314, 2167, 2221, - 3338, 3488, 2726, 2194, 2261, 2460, 2354, 2367, 2207, 2101, - 2354, 2420, 2327, 2367, 2394, 2420, 2420, 2420, 2460, 2367, - 3779, 3629, 2434, 2527, 2367, 2274, 2274, 2300, 2207, 2048, - 3254, 3225, 2713, 2846, 2447, 2327, 2300, 2300, 2274, 2127, - 3263, 3300, 2753, 2806, 2447, 2261, 2261, 2247, 2127, 2101, - 2873, 2981, 2633, 2367, 2407, 2354, 2194, 2247, 2247, 2114, - 3225, 3197, 2633, 2580, 2274, 2181, 2247, 2221, 2221, 2141, - 3178, 3310, 2740, 2407, 2274, 2274, 2274, 2287, 2194, 2114, - 3141, 3272, 2460, 2061, 2287, 2500, 2367, 2487, 2434, 2181, - 3507, 3282, 2314, 2700, 2647, 2474, 2367, 2394, 2340, 2127, - 3423, 3535, 3038, 3056, 2300, 1950, 2221, 2274, 2274, 2274, - 3404, 3366, 2087, 2687, 2873, 2354, 2420, 2274, 2474, 2540, - 3760, 3488, 1950, 2660, 2897, 2527, 2394, 2367, 2460, 2261, - 3028, 3272, 2740, 2888, 2740, 2154, 2127, 2287, 2234, 2247, - 3695, 3657, 2025, 1969, 2660, 2700, 2580, 2500, 2327, 2367, - 3207, 3413, 2354, 2074, 2888, 2888, 2340, 2487, 2247, 2167, - 3338, 3366, 2846, 2780, 2327, 2154, 2274, 2287, 2114, 2061, - 2327, 2300, 2181, 2167, 2181, 2367, 2633, 2700, 2700, 2553, - 2407, 2434, 2221, 2261, 2221, 2221, 2340, 2420, 2607, 2700, - 3038, 3244, 2806, 2888, 2474, 2074, 2300, 2314, 2354, 2380, - 2221, 2154, 2127, 2287, 2500, 2793, 2793, 2620, 2580, 2367, - 3676, 3713, 2234, 1838, 2181, 2753, 2726, 2673, 2513, 2207, - 2793, 3160, 2726, 2553, 2846, 2513, 2181, 2394, 2221, 2181 -}; - -static const opus_uint8 silk_NLSF_CB1_iCDF_NB_MB[ 64 ] = { - 212, 178, 148, 129, 108, 96, 85, 82, - 79, 77, 61, 59, 57, 56, 51, 49, - 48, 45, 42, 41, 40, 38, 36, 34, - 31, 30, 21, 12, 10, 3, 1, 0, - 255, 245, 244, 236, 233, 225, 217, 203, - 190, 176, 175, 161, 149, 136, 125, 114, - 102, 91, 81, 71, 60, 52, 43, 35, - 28, 20, 19, 18, 12, 11, 5, 0 -}; - -static const opus_uint8 silk_NLSF_CB2_SELECT_NB_MB[ 160 ] = { - 16, 0, 0, 0, 0, 99, 66, 36, - 36, 34, 36, 34, 34, 34, 34, 83, - 69, 36, 52, 34, 116, 102, 70, 68, - 68, 176, 102, 68, 68, 34, 65, 85, - 68, 84, 36, 116, 141, 152, 139, 170, - 132, 187, 184, 216, 137, 132, 249, 168, - 185, 139, 104, 102, 100, 68, 68, 178, - 218, 185, 185, 170, 244, 216, 187, 187, - 170, 244, 187, 187, 219, 138, 103, 155, - 184, 185, 137, 116, 183, 155, 152, 136, - 132, 217, 184, 184, 170, 164, 217, 171, - 155, 139, 244, 169, 184, 185, 170, 164, - 216, 223, 218, 138, 214, 143, 188, 218, - 168, 244, 141, 136, 155, 170, 168, 138, - 220, 219, 139, 164, 219, 202, 216, 137, - 168, 186, 246, 185, 139, 116, 185, 219, - 185, 138, 100, 100, 134, 100, 102, 34, - 68, 68, 100, 68, 168, 203, 221, 218, - 168, 167, 154, 136, 104, 70, 164, 246, - 171, 137, 139, 137, 155, 218, 219, 139 -}; - -static const opus_uint8 silk_NLSF_CB2_iCDF_NB_MB[ 72 ] = { - 255, 254, 253, 238, 14, 3, 2, 1, - 0, 255, 254, 252, 218, 35, 3, 2, - 1, 0, 255, 254, 250, 208, 59, 4, - 2, 1, 0, 255, 254, 246, 194, 71, - 10, 2, 1, 0, 255, 252, 236, 183, - 82, 8, 2, 1, 0, 255, 252, 235, - 180, 90, 17, 2, 1, 0, 255, 248, - 224, 171, 97, 30, 4, 1, 0, 255, - 254, 236, 173, 95, 37, 7, 1, 0 -}; - -static const opus_uint8 silk_NLSF_CB2_BITS_NB_MB_Q5[ 72 ] = { - 255, 255, 255, 131, 6, 145, 255, 255, - 255, 255, 255, 236, 93, 15, 96, 255, - 255, 255, 255, 255, 194, 83, 25, 71, - 221, 255, 255, 255, 255, 162, 73, 34, - 66, 162, 255, 255, 255, 210, 126, 73, - 43, 57, 173, 255, 255, 255, 201, 125, - 71, 48, 58, 130, 255, 255, 255, 166, - 110, 73, 57, 62, 104, 210, 255, 255, - 251, 123, 65, 55, 68, 100, 171, 255 -}; - -static const opus_uint8 silk_NLSF_PRED_NB_MB_Q8[ 18 ] = { - 179, 138, 140, 148, 151, 149, 153, 151, - 163, 116, 67, 82, 59, 92, 72, 100, - 89, 92 -}; - -static const opus_int16 silk_NLSF_DELTA_MIN_NB_MB_Q15[ 11 ] = { - 250, 3, 6, 3, 3, 3, 4, 3, - 3, 3, 461 -}; - -const silk_NLSF_CB_struct silk_NLSF_CB_NB_MB = -{ - 32, - 10, - SILK_FIX_CONST( 0.18, 16 ), - SILK_FIX_CONST( 1.0 / 0.18, 6 ), - silk_NLSF_CB1_NB_MB_Q8, - silk_NLSF_CB1_Wght_Q9, - silk_NLSF_CB1_iCDF_NB_MB, - silk_NLSF_PRED_NB_MB_Q8, - silk_NLSF_CB2_SELECT_NB_MB, - silk_NLSF_CB2_iCDF_NB_MB, - silk_NLSF_CB2_BITS_NB_MB_Q5, - silk_NLSF_DELTA_MIN_NB_MB_Q15, -}; diff --git a/Engine/lib/opus/silk/tables_NLSF_CB_WB.c b/Engine/lib/opus/silk/tables_NLSF_CB_WB.c deleted file mode 100644 index 5cc9f57bf..000000000 --- a/Engine/lib/opus/silk/tables_NLSF_CB_WB.c +++ /dev/null @@ -1,234 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "tables.h" - -static const opus_uint8 silk_NLSF_CB1_WB_Q8[ 512 ] = { - 7, 23, 38, 54, 69, 85, 100, 116, - 131, 147, 162, 178, 193, 208, 223, 239, - 13, 25, 41, 55, 69, 83, 98, 112, - 127, 142, 157, 171, 187, 203, 220, 236, - 15, 21, 34, 51, 61, 78, 92, 106, - 126, 136, 152, 167, 185, 205, 225, 240, - 10, 21, 36, 50, 63, 79, 95, 110, - 126, 141, 157, 173, 189, 205, 221, 237, - 17, 20, 37, 51, 59, 78, 89, 107, - 123, 134, 150, 164, 184, 205, 224, 240, - 10, 15, 32, 51, 67, 81, 96, 112, - 129, 142, 158, 173, 189, 204, 220, 236, - 8, 21, 37, 51, 65, 79, 98, 113, - 126, 138, 155, 168, 179, 192, 209, 218, - 12, 15, 34, 55, 63, 78, 87, 108, - 118, 131, 148, 167, 185, 203, 219, 236, - 16, 19, 32, 36, 56, 79, 91, 108, - 118, 136, 154, 171, 186, 204, 220, 237, - 11, 28, 43, 58, 74, 89, 105, 120, - 135, 150, 165, 180, 196, 211, 226, 241, - 6, 16, 33, 46, 60, 75, 92, 107, - 123, 137, 156, 169, 185, 199, 214, 225, - 11, 19, 30, 44, 57, 74, 89, 105, - 121, 135, 152, 169, 186, 202, 218, 234, - 12, 19, 29, 46, 57, 71, 88, 100, - 120, 132, 148, 165, 182, 199, 216, 233, - 17, 23, 35, 46, 56, 77, 92, 106, - 123, 134, 152, 167, 185, 204, 222, 237, - 14, 17, 45, 53, 63, 75, 89, 107, - 115, 132, 151, 171, 188, 206, 221, 240, - 9, 16, 29, 40, 56, 71, 88, 103, - 119, 137, 154, 171, 189, 205, 222, 237, - 16, 19, 36, 48, 57, 76, 87, 105, - 118, 132, 150, 167, 185, 202, 218, 236, - 12, 17, 29, 54, 71, 81, 94, 104, - 126, 136, 149, 164, 182, 201, 221, 237, - 15, 28, 47, 62, 79, 97, 115, 129, - 142, 155, 168, 180, 194, 208, 223, 238, - 8, 14, 30, 45, 62, 78, 94, 111, - 127, 143, 159, 175, 192, 207, 223, 239, - 17, 30, 49, 62, 79, 92, 107, 119, - 132, 145, 160, 174, 190, 204, 220, 235, - 14, 19, 36, 45, 61, 76, 91, 108, - 121, 138, 154, 172, 189, 205, 222, 238, - 12, 18, 31, 45, 60, 76, 91, 107, - 123, 138, 154, 171, 187, 204, 221, 236, - 13, 17, 31, 43, 53, 70, 83, 103, - 114, 131, 149, 167, 185, 203, 220, 237, - 17, 22, 35, 42, 58, 78, 93, 110, - 125, 139, 155, 170, 188, 206, 224, 240, - 8, 15, 34, 50, 67, 83, 99, 115, - 131, 146, 162, 178, 193, 209, 224, 239, - 13, 16, 41, 66, 73, 86, 95, 111, - 128, 137, 150, 163, 183, 206, 225, 241, - 17, 25, 37, 52, 63, 75, 92, 102, - 119, 132, 144, 160, 175, 191, 212, 231, - 19, 31, 49, 65, 83, 100, 117, 133, - 147, 161, 174, 187, 200, 213, 227, 242, - 18, 31, 52, 68, 88, 103, 117, 126, - 138, 149, 163, 177, 192, 207, 223, 239, - 16, 29, 47, 61, 76, 90, 106, 119, - 133, 147, 161, 176, 193, 209, 224, 240, - 15, 21, 35, 50, 61, 73, 86, 97, - 110, 119, 129, 141, 175, 198, 218, 237 -}; - -static const opus_int16 silk_NLSF_CB1_WB_Wght_Q9[ 512 ] = { - 3657, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2963, 2963, 2925, 2846, - 3216, 3085, 2972, 3056, 3056, 3010, 3010, 3010, 2963, 2963, 3010, 2972, 2888, 2846, 2846, 2726, - 3920, 4014, 2981, 3207, 3207, 2934, 3056, 2846, 3122, 3244, 2925, 2846, 2620, 2553, 2780, 2925, - 3516, 3197, 3010, 3103, 3019, 2888, 2925, 2925, 2925, 2925, 2888, 2888, 2888, 2888, 2888, 2753, - 5054, 5054, 2934, 3573, 3385, 3056, 3085, 2793, 3160, 3160, 2972, 2846, 2513, 2540, 2753, 2888, - 4428, 4149, 2700, 2753, 2972, 3010, 2925, 2846, 2981, 3019, 2925, 2925, 2925, 2925, 2888, 2726, - 3620, 3019, 2972, 3056, 3056, 2873, 2806, 3056, 3216, 3047, 2981, 3291, 3291, 2981, 3310, 2991, - 5227, 5014, 2540, 3338, 3526, 3385, 3197, 3094, 3376, 2981, 2700, 2647, 2687, 2793, 2846, 2673, - 5081, 5174, 4615, 4428, 2460, 2897, 3047, 3207, 3169, 2687, 2740, 2888, 2846, 2793, 2846, 2700, - 3122, 2888, 2963, 2925, 2925, 2925, 2925, 2963, 2963, 2963, 2963, 2925, 2925, 2963, 2963, 2963, - 4202, 3207, 2981, 3103, 3010, 2888, 2888, 2925, 2972, 2873, 2916, 3019, 2972, 3010, 3197, 2873, - 3760, 3760, 3244, 3103, 2981, 2888, 2925, 2888, 2972, 2934, 2793, 2793, 2846, 2888, 2888, 2660, - 3854, 4014, 3207, 3122, 3244, 2934, 3047, 2963, 2963, 3085, 2846, 2793, 2793, 2793, 2793, 2580, - 3845, 4080, 3357, 3516, 3094, 2740, 3010, 2934, 3122, 3085, 2846, 2846, 2647, 2647, 2846, 2806, - 5147, 4894, 3225, 3845, 3441, 3169, 2897, 3413, 3451, 2700, 2580, 2673, 2740, 2846, 2806, 2753, - 4109, 3789, 3291, 3160, 2925, 2888, 2888, 2925, 2793, 2740, 2793, 2740, 2793, 2846, 2888, 2806, - 5081, 5054, 3047, 3545, 3244, 3056, 3085, 2944, 3103, 2897, 2740, 2740, 2740, 2846, 2793, 2620, - 4309, 4309, 2860, 2527, 3207, 3376, 3376, 3075, 3075, 3376, 3056, 2846, 2647, 2580, 2726, 2753, - 3056, 2916, 2806, 2888, 2740, 2687, 2897, 3103, 3150, 3150, 3216, 3169, 3056, 3010, 2963, 2846, - 4375, 3882, 2925, 2888, 2846, 2888, 2846, 2846, 2888, 2888, 2888, 2846, 2888, 2925, 2888, 2846, - 2981, 2916, 2916, 2981, 2981, 3056, 3122, 3216, 3150, 3056, 3010, 2972, 2972, 2972, 2925, 2740, - 4229, 4149, 3310, 3347, 2925, 2963, 2888, 2981, 2981, 2846, 2793, 2740, 2846, 2846, 2846, 2793, - 4080, 4014, 3103, 3010, 2925, 2925, 2925, 2888, 2925, 2925, 2846, 2846, 2846, 2793, 2888, 2780, - 4615, 4575, 3169, 3441, 3207, 2981, 2897, 3038, 3122, 2740, 2687, 2687, 2687, 2740, 2793, 2700, - 4149, 4269, 3789, 3657, 2726, 2780, 2888, 2888, 3010, 2972, 2925, 2846, 2687, 2687, 2793, 2888, - 4215, 3554, 2753, 2846, 2846, 2888, 2888, 2888, 2925, 2925, 2888, 2925, 2925, 2925, 2963, 2888, - 5174, 4921, 2261, 3432, 3789, 3479, 3347, 2846, 3310, 3479, 3150, 2897, 2460, 2487, 2753, 2925, - 3451, 3685, 3122, 3197, 3357, 3047, 3207, 3207, 2981, 3216, 3085, 2925, 2925, 2687, 2540, 2434, - 2981, 3010, 2793, 2793, 2740, 2793, 2846, 2972, 3056, 3103, 3150, 3150, 3150, 3103, 3010, 3010, - 2944, 2873, 2687, 2726, 2780, 3010, 3432, 3545, 3357, 3244, 3056, 3010, 2963, 2925, 2888, 2846, - 3019, 2944, 2897, 3010, 3010, 2972, 3019, 3103, 3056, 3056, 3010, 2888, 2846, 2925, 2925, 2888, - 3920, 3967, 3010, 3197, 3357, 3216, 3291, 3291, 3479, 3704, 3441, 2726, 2181, 2460, 2580, 2607 -}; - -static const opus_uint8 silk_NLSF_CB1_iCDF_WB[ 64 ] = { - 225, 204, 201, 184, 183, 175, 158, 154, - 153, 135, 119, 115, 113, 110, 109, 99, - 98, 95, 79, 68, 52, 50, 48, 45, - 43, 32, 31, 27, 18, 10, 3, 0, - 255, 251, 235, 230, 212, 201, 196, 182, - 167, 166, 163, 151, 138, 124, 110, 104, - 90, 78, 76, 70, 69, 57, 45, 34, - 24, 21, 11, 6, 5, 4, 3, 0 -}; - -static const opus_uint8 silk_NLSF_CB2_SELECT_WB[ 256 ] = { - 0, 0, 0, 0, 0, 0, 0, 1, - 100, 102, 102, 68, 68, 36, 34, 96, - 164, 107, 158, 185, 180, 185, 139, 102, - 64, 66, 36, 34, 34, 0, 1, 32, - 208, 139, 141, 191, 152, 185, 155, 104, - 96, 171, 104, 166, 102, 102, 102, 132, - 1, 0, 0, 0, 0, 16, 16, 0, - 80, 109, 78, 107, 185, 139, 103, 101, - 208, 212, 141, 139, 173, 153, 123, 103, - 36, 0, 0, 0, 0, 0, 0, 1, - 48, 0, 0, 0, 0, 0, 0, 32, - 68, 135, 123, 119, 119, 103, 69, 98, - 68, 103, 120, 118, 118, 102, 71, 98, - 134, 136, 157, 184, 182, 153, 139, 134, - 208, 168, 248, 75, 189, 143, 121, 107, - 32, 49, 34, 34, 34, 0, 17, 2, - 210, 235, 139, 123, 185, 137, 105, 134, - 98, 135, 104, 182, 100, 183, 171, 134, - 100, 70, 68, 70, 66, 66, 34, 131, - 64, 166, 102, 68, 36, 2, 1, 0, - 134, 166, 102, 68, 34, 34, 66, 132, - 212, 246, 158, 139, 107, 107, 87, 102, - 100, 219, 125, 122, 137, 118, 103, 132, - 114, 135, 137, 105, 171, 106, 50, 34, - 164, 214, 141, 143, 185, 151, 121, 103, - 192, 34, 0, 0, 0, 0, 0, 1, - 208, 109, 74, 187, 134, 249, 159, 137, - 102, 110, 154, 118, 87, 101, 119, 101, - 0, 2, 0, 36, 36, 66, 68, 35, - 96, 164, 102, 100, 36, 0, 2, 33, - 167, 138, 174, 102, 100, 84, 2, 2, - 100, 107, 120, 119, 36, 197, 24, 0 -}; - -static const opus_uint8 silk_NLSF_CB2_iCDF_WB[ 72 ] = { - 255, 254, 253, 244, 12, 3, 2, 1, - 0, 255, 254, 252, 224, 38, 3, 2, - 1, 0, 255, 254, 251, 209, 57, 4, - 2, 1, 0, 255, 254, 244, 195, 69, - 4, 2, 1, 0, 255, 251, 232, 184, - 84, 7, 2, 1, 0, 255, 254, 240, - 186, 86, 14, 2, 1, 0, 255, 254, - 239, 178, 91, 30, 5, 1, 0, 255, - 248, 227, 177, 100, 19, 2, 1, 0 -}; - -static const opus_uint8 silk_NLSF_CB2_BITS_WB_Q5[ 72 ] = { - 255, 255, 255, 156, 4, 154, 255, 255, - 255, 255, 255, 227, 102, 15, 92, 255, - 255, 255, 255, 255, 213, 83, 24, 72, - 236, 255, 255, 255, 255, 150, 76, 33, - 63, 214, 255, 255, 255, 190, 121, 77, - 43, 55, 185, 255, 255, 255, 245, 137, - 71, 43, 59, 139, 255, 255, 255, 255, - 131, 66, 50, 66, 107, 194, 255, 255, - 166, 116, 76, 55, 53, 125, 255, 255 -}; - -static const opus_uint8 silk_NLSF_PRED_WB_Q8[ 30 ] = { - 175, 148, 160, 176, 178, 173, 174, 164, - 177, 174, 196, 182, 198, 192, 182, 68, - 62, 66, 60, 72, 117, 85, 90, 118, - 136, 151, 142, 160, 142, 155 -}; - -static const opus_int16 silk_NLSF_DELTA_MIN_WB_Q15[ 17 ] = { - 100, 3, 40, 3, 3, 3, 5, 14, - 14, 10, 11, 3, 8, 9, 7, 3, - 347 -}; - -const silk_NLSF_CB_struct silk_NLSF_CB_WB = -{ - 32, - 16, - SILK_FIX_CONST( 0.15, 16 ), - SILK_FIX_CONST( 1.0 / 0.15, 6 ), - silk_NLSF_CB1_WB_Q8, - silk_NLSF_CB1_WB_Wght_Q9, - silk_NLSF_CB1_iCDF_WB, - silk_NLSF_PRED_WB_Q8, - silk_NLSF_CB2_SELECT_WB, - silk_NLSF_CB2_iCDF_WB, - silk_NLSF_CB2_BITS_WB_Q5, - silk_NLSF_DELTA_MIN_WB_Q15, -}; - diff --git a/Engine/lib/opus/silk/tables_gain.c b/Engine/lib/opus/silk/tables_gain.c deleted file mode 100644 index 37e41d890..000000000 --- a/Engine/lib/opus/silk/tables_gain.c +++ /dev/null @@ -1,63 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "tables.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -const opus_uint8 silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ] = -{ -{ - 224, 112, 44, 15, 3, 2, 1, 0 -}, -{ - 254, 237, 192, 132, 70, 23, 4, 0 -}, -{ - 255, 252, 226, 155, 61, 11, 2, 0 -} -}; - -const opus_uint8 silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ] = { - 250, 245, 234, 203, 71, 50, 42, 38, - 35, 33, 31, 29, 28, 27, 26, 25, - 24, 23, 22, 21, 20, 19, 18, 17, - 16, 15, 14, 13, 12, 11, 10, 9, - 8, 7, 6, 5, 4, 3, 2, 1, - 0 -}; - -#ifdef __cplusplus -} -#endif diff --git a/Engine/lib/opus/silk/tables_other.c b/Engine/lib/opus/silk/tables_other.c deleted file mode 100644 index e34d90777..000000000 --- a/Engine/lib/opus/silk/tables_other.c +++ /dev/null @@ -1,124 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "structs.h" -#include "define.h" -#include "tables.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Tables for stereo predictor coding */ -const opus_int16 silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ] = { - -13732, -10050, -8266, -7526, -6500, -5000, -2950, -820, - 820, 2950, 5000, 6500, 7526, 8266, 10050, 13732 -}; -const opus_uint8 silk_stereo_pred_joint_iCDF[ 25 ] = { - 249, 247, 246, 245, 244, - 234, 210, 202, 201, 200, - 197, 174, 82, 59, 56, - 55, 54, 46, 22, 12, - 11, 10, 9, 7, 0 -}; -const opus_uint8 silk_stereo_only_code_mid_iCDF[ 2 ] = { 64, 0 }; - -/* Tables for LBRR flags */ -static const opus_uint8 silk_LBRR_flags_2_iCDF[ 3 ] = { 203, 150, 0 }; -static const opus_uint8 silk_LBRR_flags_3_iCDF[ 7 ] = { 215, 195, 166, 125, 110, 82, 0 }; -const opus_uint8 * const silk_LBRR_flags_iCDF_ptr[ 2 ] = { - silk_LBRR_flags_2_iCDF, - silk_LBRR_flags_3_iCDF -}; - -/* Table for LSB coding */ -const opus_uint8 silk_lsb_iCDF[ 2 ] = { 120, 0 }; - -/* Tables for LTPScale */ -const opus_uint8 silk_LTPscale_iCDF[ 3 ] = { 128, 64, 0 }; - -/* Tables for signal type and offset coding */ -const opus_uint8 silk_type_offset_VAD_iCDF[ 4 ] = { - 232, 158, 10, 0 -}; -const opus_uint8 silk_type_offset_no_VAD_iCDF[ 2 ] = { - 230, 0 -}; - -/* Tables for NLSF interpolation factor */ -const opus_uint8 silk_NLSF_interpolation_factor_iCDF[ 5 ] = { 243, 221, 192, 181, 0 }; - -/* Quantization offsets */ -const opus_int16 silk_Quantization_Offsets_Q10[ 2 ][ 2 ] = { - { OFFSET_UVL_Q10, OFFSET_UVH_Q10 }, { OFFSET_VL_Q10, OFFSET_VH_Q10 } -}; - -/* Table for LTPScale */ -const opus_int16 silk_LTPScales_table_Q14[ 3 ] = { 15565, 12288, 8192 }; - -/* Uniform entropy tables */ -const opus_uint8 silk_uniform3_iCDF[ 3 ] = { 171, 85, 0 }; -const opus_uint8 silk_uniform4_iCDF[ 4 ] = { 192, 128, 64, 0 }; -const opus_uint8 silk_uniform5_iCDF[ 5 ] = { 205, 154, 102, 51, 0 }; -const opus_uint8 silk_uniform6_iCDF[ 6 ] = { 213, 171, 128, 85, 43, 0 }; -const opus_uint8 silk_uniform8_iCDF[ 8 ] = { 224, 192, 160, 128, 96, 64, 32, 0 }; - -const opus_uint8 silk_NLSF_EXT_iCDF[ 7 ] = { 100, 40, 16, 7, 3, 1, 0 }; - -/* Elliptic/Cauer filters designed with 0.1 dB passband ripple, - 80 dB minimum stopband attenuation, and - [0.95 : 0.15 : 0.35] normalized cut off frequencies. */ - -/* Interpolation points for filter coefficients used in the bandwidth transition smoother */ -const opus_int32 silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ] = -{ -{ 250767114, 501534038, 250767114 }, -{ 209867381, 419732057, 209867381 }, -{ 170987846, 341967853, 170987846 }, -{ 131531482, 263046905, 131531482 }, -{ 89306658, 178584282, 89306658 } -}; - -/* Interpolation points for filter coefficients used in the bandwidth transition smoother */ -const opus_int32 silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ] = -{ -{ 506393414, 239854379 }, -{ 411067935, 169683996 }, -{ 306733530, 116694253 }, -{ 185807084, 77959395 }, -{ 35497197, 57401098 } -}; - -#ifdef __cplusplus -} -#endif - diff --git a/Engine/lib/opus/silk/tables_pitch_lag.c b/Engine/lib/opus/silk/tables_pitch_lag.c deleted file mode 100644 index e80cc59a2..000000000 --- a/Engine/lib/opus/silk/tables_pitch_lag.c +++ /dev/null @@ -1,69 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "tables.h" - -const opus_uint8 silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ] = { - 253, 250, 244, 233, 212, 182, 150, 131, - 120, 110, 98, 85, 72, 60, 49, 40, - 32, 25, 19, 15, 13, 11, 9, 8, - 7, 6, 5, 4, 3, 2, 1, 0 -}; - -const opus_uint8 silk_pitch_delta_iCDF[21] = { - 210, 208, 206, 203, 199, 193, 183, 168, - 142, 104, 74, 52, 37, 27, 20, 14, - 10, 6, 4, 2, 0 -}; - -const opus_uint8 silk_pitch_contour_iCDF[34] = { - 223, 201, 183, 167, 152, 138, 124, 111, - 98, 88, 79, 70, 62, 56, 50, 44, - 39, 35, 31, 27, 24, 21, 18, 16, - 14, 12, 10, 8, 6, 4, 3, 2, - 1, 0 -}; - -const opus_uint8 silk_pitch_contour_NB_iCDF[11] = { - 188, 176, 155, 138, 119, 97, 67, 43, - 26, 10, 0 -}; - -const opus_uint8 silk_pitch_contour_10_ms_iCDF[12] = { - 165, 119, 80, 61, 47, 35, 27, 20, - 14, 9, 4, 0 -}; - -const opus_uint8 silk_pitch_contour_10_ms_NB_iCDF[3] = { - 113, 63, 0 -}; - - diff --git a/Engine/lib/opus/silk/tables_pulses_per_block.c b/Engine/lib/opus/silk/tables_pulses_per_block.c deleted file mode 100644 index c7c01c889..000000000 --- a/Engine/lib/opus/silk/tables_pulses_per_block.c +++ /dev/null @@ -1,264 +0,0 @@ -/*********************************************************************** -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" -#endif - -#include "tables.h" - -const opus_uint8 silk_max_pulses_table[ 4 ] = { - 8, 10, 12, 16 -}; - -const opus_uint8 silk_pulses_per_block_iCDF[ 10 ][ 18 ] = { -{ - 125, 51, 26, 18, 15, 12, 11, 10, - 9, 8, 7, 6, 5, 4, 3, 2, - 1, 0 -}, -{ - 198, 105, 45, 22, 15, 12, 11, 10, - 9, 8, 7, 6, 5, 4, 3, 2, - 1, 0 -}, -{ - 213, 162, 116, 83, 59, 43, 32, 24, - 18, 15, 12, 9, 7, 6, 5, 3, - 2, 0 -}, -{ - 239, 187, 116, 59, 28, 16, 11, 10, - 9, 8, 7, 6, 5, 4, 3, 2, - 1, 0 -}, -{ - 250, 229, 188, 135, 86, 51, 30, 19, - 13, 10, 8, 6, 5, 4, 3, 2, - 1, 0 -}, -{ - 249, 235, 213, 185, 156, 128, 103, 83, - 66, 53, 42, 33, 26, 21, 17, 13, - 10, 0 -}, -{ - 254, 249, 235, 206, 164, 118, 77, 46, - 27, 16, 10, 7, 5, 4, 3, 2, - 1, 0 -}, -{ - 255, 253, 249, 239, 220, 191, 156, 119, - 85, 57, 37, 23, 15, 10, 6, 4, - 2, 0 -}, -{ - 255, 253, 251, 246, 237, 223, 203, 179, - 152, 124, 98, 75, 55, 40, 29, 21, - 15, 0 -}, -{ - 255, 254, 253, 247, 220, 162, 106, 67, - 42, 28, 18, 12, 9, 6, 4, 3, - 2, 0 -} -}; - -const opus_uint8 silk_pulses_per_block_BITS_Q5[ 9 ][ 18 ] = { -{ - 31, 57, 107, 160, 205, 205, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255 -}, -{ - 69, 47, 67, 111, 166, 205, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255 -}, -{ - 82, 74, 79, 95, 109, 128, 145, 160, - 173, 205, 205, 205, 224, 255, 255, 224, - 255, 224 -}, -{ - 125, 74, 59, 69, 97, 141, 182, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255 -}, -{ - 173, 115, 85, 73, 76, 92, 115, 145, - 173, 205, 224, 224, 255, 255, 255, 255, - 255, 255 -}, -{ - 166, 134, 113, 102, 101, 102, 107, 118, - 125, 138, 145, 155, 166, 182, 192, 192, - 205, 150 -}, -{ - 224, 182, 134, 101, 83, 79, 85, 97, - 120, 145, 173, 205, 224, 255, 255, 255, - 255, 255 -}, -{ - 255, 224, 192, 150, 120, 101, 92, 89, - 93, 102, 118, 134, 160, 182, 192, 224, - 224, 224 -}, -{ - 255, 224, 224, 182, 155, 134, 118, 109, - 104, 102, 106, 111, 118, 131, 145, 160, - 173, 131 -} -}; - -const opus_uint8 silk_rate_levels_iCDF[ 2 ][ 9 ] = -{ -{ - 241, 190, 178, 132, 87, 74, 41, 14, - 0 -}, -{ - 223, 193, 157, 140, 106, 57, 39, 18, - 0 -} -}; - -const opus_uint8 silk_rate_levels_BITS_Q5[ 2 ][ 9 ] = -{ -{ - 131, 74, 141, 79, 80, 138, 95, 104, - 134 -}, -{ - 95, 99, 91, 125, 93, 76, 123, 115, - 123 -} -}; - -const opus_uint8 silk_shell_code_table0[ 152 ] = { - 128, 0, 214, 42, 0, 235, 128, 21, - 0, 244, 184, 72, 11, 0, 248, 214, - 128, 42, 7, 0, 248, 225, 170, 80, - 25, 5, 0, 251, 236, 198, 126, 54, - 18, 3, 0, 250, 238, 211, 159, 82, - 35, 15, 5, 0, 250, 231, 203, 168, - 128, 88, 53, 25, 6, 0, 252, 238, - 216, 185, 148, 108, 71, 40, 18, 4, - 0, 253, 243, 225, 199, 166, 128, 90, - 57, 31, 13, 3, 0, 254, 246, 233, - 212, 183, 147, 109, 73, 44, 23, 10, - 2, 0, 255, 250, 240, 223, 198, 166, - 128, 90, 58, 33, 16, 6, 1, 0, - 255, 251, 244, 231, 210, 181, 146, 110, - 75, 46, 25, 12, 5, 1, 0, 255, - 253, 248, 238, 221, 196, 164, 128, 92, - 60, 35, 18, 8, 3, 1, 0, 255, - 253, 249, 242, 229, 208, 180, 146, 110, - 76, 48, 27, 14, 7, 3, 1, 0 -}; - -const opus_uint8 silk_shell_code_table1[ 152 ] = { - 129, 0, 207, 50, 0, 236, 129, 20, - 0, 245, 185, 72, 10, 0, 249, 213, - 129, 42, 6, 0, 250, 226, 169, 87, - 27, 4, 0, 251, 233, 194, 130, 62, - 20, 4, 0, 250, 236, 207, 160, 99, - 47, 17, 3, 0, 255, 240, 217, 182, - 131, 81, 41, 11, 1, 0, 255, 254, - 233, 201, 159, 107, 61, 20, 2, 1, - 0, 255, 249, 233, 206, 170, 128, 86, - 50, 23, 7, 1, 0, 255, 250, 238, - 217, 186, 148, 108, 70, 39, 18, 6, - 1, 0, 255, 252, 243, 226, 200, 166, - 128, 90, 56, 30, 13, 4, 1, 0, - 255, 252, 245, 231, 209, 180, 146, 110, - 76, 47, 25, 11, 4, 1, 0, 255, - 253, 248, 237, 219, 194, 163, 128, 93, - 62, 37, 19, 8, 3, 1, 0, 255, - 254, 250, 241, 226, 205, 177, 145, 111, - 79, 51, 30, 15, 6, 2, 1, 0 -}; - -const opus_uint8 silk_shell_code_table2[ 152 ] = { - 129, 0, 203, 54, 0, 234, 129, 23, - 0, 245, 184, 73, 10, 0, 250, 215, - 129, 41, 5, 0, 252, 232, 173, 86, - 24, 3, 0, 253, 240, 200, 129, 56, - 15, 2, 0, 253, 244, 217, 164, 94, - 38, 10, 1, 0, 253, 245, 226, 189, - 132, 71, 27, 7, 1, 0, 253, 246, - 231, 203, 159, 105, 56, 23, 6, 1, - 0, 255, 248, 235, 213, 179, 133, 85, - 47, 19, 5, 1, 0, 255, 254, 243, - 221, 194, 159, 117, 70, 37, 12, 2, - 1, 0, 255, 254, 248, 234, 208, 171, - 128, 85, 48, 22, 8, 2, 1, 0, - 255, 254, 250, 240, 220, 189, 149, 107, - 67, 36, 16, 6, 2, 1, 0, 255, - 254, 251, 243, 227, 201, 166, 128, 90, - 55, 29, 13, 5, 2, 1, 0, 255, - 254, 252, 246, 234, 213, 183, 147, 109, - 73, 43, 22, 10, 4, 2, 1, 0 -}; - -const opus_uint8 silk_shell_code_table3[ 152 ] = { - 130, 0, 200, 58, 0, 231, 130, 26, - 0, 244, 184, 76, 12, 0, 249, 214, - 130, 43, 6, 0, 252, 232, 173, 87, - 24, 3, 0, 253, 241, 203, 131, 56, - 14, 2, 0, 254, 246, 221, 167, 94, - 35, 8, 1, 0, 254, 249, 232, 193, - 130, 65, 23, 5, 1, 0, 255, 251, - 239, 211, 162, 99, 45, 15, 4, 1, - 0, 255, 251, 243, 223, 186, 131, 74, - 33, 11, 3, 1, 0, 255, 252, 245, - 230, 202, 158, 105, 57, 24, 8, 2, - 1, 0, 255, 253, 247, 235, 214, 179, - 132, 84, 44, 19, 7, 2, 1, 0, - 255, 254, 250, 240, 223, 196, 159, 112, - 69, 36, 15, 6, 2, 1, 0, 255, - 254, 253, 245, 231, 209, 176, 136, 93, - 55, 27, 11, 3, 2, 1, 0, 255, - 254, 253, 252, 239, 221, 194, 158, 117, - 76, 42, 18, 4, 3, 2, 1, 0 -}; - -const opus_uint8 silk_shell_code_table_offsets[ 17 ] = { - 0, 0, 2, 5, 9, 14, 20, 27, - 35, 44, 54, 65, 77, 90, 104, 119, - 135 -}; - -const opus_uint8 silk_sign_iCDF[ 42 ] = { - 254, 49, 67, 77, 82, 93, 99, - 198, 11, 18, 24, 31, 36, 45, - 255, 46, 66, 78, 87, 94, 104, - 208, 14, 21, 32, 42, 51, 66, - 255, 94, 104, 109, 112, 115, 118, - 248, 53, 69, 80, 88, 95, 102 -}; diff --git a/Engine/lib/opus/silk/tests/meson.build b/Engine/lib/opus/silk/tests/meson.build deleted file mode 100644 index b7c70f75f..000000000 --- a/Engine/lib/opus/silk/tests/meson.build +++ /dev/null @@ -1,8 +0,0 @@ -exe = executable('test_unit_LPC_inv_pred_gain', - 'test_unit_LPC_inv_pred_gain.c', '../LPC_inv_pred_gain.c', - include_directories: opus_includes, - link_with: [celt_lib, celt_static_libs, silk_lib, silk_static_libs], - dependencies: libm, - install: false) - -test(test_name, exe) diff --git a/Engine/lib/opus/silk/tests/test_unit_LPC_inv_pred_gain.c b/Engine/lib/opus/silk/tests/test_unit_LPC_inv_pred_gain.c deleted file mode 100644 index 7ca902ad9..000000000 --- a/Engine/lib/opus/silk/tests/test_unit_LPC_inv_pred_gain.c +++ /dev/null @@ -1,129 +0,0 @@ -/*********************************************************************** -Copyright (c) 2017 Google Inc., 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. -- 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" -#endif - -#include -#include -#include "celt/stack_alloc.h" -#include "cpu_support.h" -#include "SigProc_FIX.h" - -/* Computes the impulse response of the filter so we - can catch filters that are definitely unstable. Some - unstable filters may be classified as stable, but not - the other way around. */ -int check_stability(opus_int16 *A_Q12, int order) { - int i; - int j; - int sum_a, sum_abs_a; - double y[SILK_MAX_ORDER_LPC] = {0}; - sum_a = sum_abs_a = 0; - for( j = 0; j < order; j++ ) { - sum_a += A_Q12[ j ]; - sum_abs_a += silk_abs( A_Q12[ j ] ); - } - /* Check DC stability. */ - if( sum_a >= 4096 ) { - return 0; - } - /* If the sum of absolute values is less than 1, the filter - has to be stable. */ - if( sum_abs_a < 4096 ) { - return 1; - } - y[0] = 1; - for( i = 0; i < 10000; i++ ) { - double sum = 0; - for( j = 0; j < order; j++ ) { - sum += y[ j ]*A_Q12[ j ]; - } - for( j = order - 1; j > 0; j-- ) { - y[ j ] = y[ j - 1 ]; - } - y[ 0 ] = sum*(1./4096); - /* If impulse response reaches +/- 10000, the filter - is definitely unstable. */ - if( !(y[ 0 ] < 10000 && y[ 0 ] > -10000) ) { - return 0; - } - /* Test every 8 sample for low amplitude. */ - if( ( i & 0x7 ) == 0 ) { - double amp = 0; - for( j = 0; j < order; j++ ) { - amp += fabs(y[j]); - } - if( amp < 0.00001 ) { - return 1; - } - } - } - return 1; -} - -int main(void) { - const int arch = opus_select_arch(); - /* Set to 10000 so all branches in C function are triggered */ - const int loop_num = 10000; - int count = 0; - ALLOC_STACK; - - /* FIXME: Make the seed random (with option to set it explicitly) - so we get wider coverage. */ - srand(0); - - printf("Testing silk_LPC_inverse_pred_gain() optimization ...\n"); - for( count = 0; count < loop_num; count++ ) { - unsigned int i; - opus_int order; - unsigned int shift; - opus_int16 A_Q12[ SILK_MAX_ORDER_LPC ]; - opus_int32 gain; - - for( order = 2; order <= SILK_MAX_ORDER_LPC; order += 2 ) { /* order must be even. */ - for( shift = 0; shift < 16; shift++ ) { /* Different dynamic range. */ - for( i = 0; i < SILK_MAX_ORDER_LPC; i++ ) { - A_Q12[i] = ((opus_int16)rand()) >> shift; - } - gain = silk_LPC_inverse_pred_gain(A_Q12, order, arch); - /* Look for filters that silk_LPC_inverse_pred_gain() thinks are - stable but definitely aren't. */ - if( gain != 0 && !check_stability(A_Q12, order) ) { - fprintf(stderr, "**Loop %4d failed!**\n", count); - return 1; - } - } - } - if( !(count % 500) ) { - printf("Loop %4d passed\n", count); - } - } - printf("silk_LPC_inverse_pred_gain() optimization passed\n"); - return 0; -} diff --git a/Engine/lib/opus/silk/tuning_parameters.h b/Engine/lib/opus/silk/tuning_parameters.h deleted file mode 100644 index d70275fd8..000000000 --- a/Engine/lib/opus/silk/tuning_parameters.h +++ /dev/null @@ -1,155 +0,0 @@ -/*********************************************************************** -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 SILK_TUNING_PARAMETERS_H -#define SILK_TUNING_PARAMETERS_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Decay time for bitreservoir */ -#define BITRESERVOIR_DECAY_TIME_MS 500 - -/*******************/ -/* Pitch estimator */ -/*******************/ - -/* Level of noise floor for whitening filter LPC analysis in pitch analysis */ -#define FIND_PITCH_WHITE_NOISE_FRACTION 1e-3f - -/* Bandwidth expansion for whitening filter in pitch analysis */ -#define FIND_PITCH_BANDWIDTH_EXPANSION 0.99f - -/*********************/ -/* Linear prediction */ -/*********************/ - -/* LPC analysis regularization */ -#define FIND_LPC_COND_FAC 1e-5f - -/* Max cumulative LTP gain */ -#define MAX_SUM_LOG_GAIN_DB 250.0f - -/* LTP analysis defines */ -#define LTP_CORR_INV_MAX 0.03f - -/***********************/ -/* High pass filtering */ -/***********************/ - -/* Smoothing parameters for low end of pitch frequency range estimation */ -#define VARIABLE_HP_SMTH_COEF1 0.1f -#define VARIABLE_HP_SMTH_COEF2 0.015f -#define VARIABLE_HP_MAX_DELTA_FREQ 0.4f - -/* Min and max cut-off frequency values (-3 dB points) */ -#define VARIABLE_HP_MIN_CUTOFF_HZ 60 -#define VARIABLE_HP_MAX_CUTOFF_HZ 100 - -/***********/ -/* Various */ -/***********/ - -/* VAD threshold */ -#define SPEECH_ACTIVITY_DTX_THRES 0.05f - -/* Speech Activity LBRR enable threshold */ -#define LBRR_SPEECH_ACTIVITY_THRES 0.3f - -/*************************/ -/* Perceptual parameters */ -/*************************/ - -/* reduction in coding SNR during low speech activity */ -#define BG_SNR_DECR_dB 2.0f - -/* factor for reducing quantization noise during voiced speech */ -#define HARM_SNR_INCR_dB 2.0f - -/* factor for reducing quantization noise for unvoiced sparse signals */ -#define SPARSE_SNR_INCR_dB 2.0f - -/* threshold for sparseness measure above which to use lower quantization offset during unvoiced */ -#define ENERGY_VARIATION_THRESHOLD_QNT_OFFSET 0.6f - -/* warping control */ -#define WARPING_MULTIPLIER 0.015f - -/* fraction added to first autocorrelation value */ -#define SHAPE_WHITE_NOISE_FRACTION 3e-5f - -/* noise shaping filter chirp factor */ -#define BANDWIDTH_EXPANSION 0.94f - -/* harmonic noise shaping */ -#define HARMONIC_SHAPING 0.3f - -/* extra harmonic noise shaping for high bitrates or noisy input */ -#define HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING 0.2f - -/* parameter for shaping noise towards higher frequencies */ -#define HP_NOISE_COEF 0.25f - -/* parameter for shaping noise even more towards higher frequencies during voiced speech */ -#define HARM_HP_NOISE_COEF 0.35f - -/* parameter for applying a high-pass tilt to the input signal */ -#define INPUT_TILT 0.05f - -/* parameter for extra high-pass tilt to the input signal at high rates */ -#define HIGH_RATE_INPUT_TILT 0.1f - -/* parameter for reducing noise at the very low frequencies */ -#define LOW_FREQ_SHAPING 4.0f - -/* less reduction of noise at the very low frequencies for signals with low SNR at low frequencies */ -#define LOW_QUALITY_LOW_FREQ_SHAPING_DECR 0.5f - -/* subframe smoothing coefficient for HarmBoost, HarmShapeGain, Tilt (lower -> more smoothing) */ -#define SUBFR_SMTH_COEF 0.4f - -/* parameters defining the R/D tradeoff in the residual quantizer */ -#define LAMBDA_OFFSET 1.2f -#define LAMBDA_SPEECH_ACT -0.2f -#define LAMBDA_DELAYED_DECISIONS -0.05f -#define LAMBDA_INPUT_QUALITY -0.1f -#define LAMBDA_CODING_QUALITY -0.2f -#define LAMBDA_QUANT_OFFSET 0.8f - -/* Compensation in bitrate calculations for 10 ms modes */ -#define REDUCE_BITRATE_10_MS_BPS 2200 - -/* Maximum time before allowing a bandwidth transition */ -#define MAX_BANDWIDTH_SWITCH_DELAY_MS 5000 - -#ifdef __cplusplus -} -#endif - -#endif /* SILK_TUNING_PARAMETERS_H */ diff --git a/Engine/lib/opus/silk/typedef.h b/Engine/lib/opus/silk/typedef.h deleted file mode 100644 index 793d2c0c1..000000000 --- a/Engine/lib/opus/silk/typedef.h +++ /dev/null @@ -1,81 +0,0 @@ -/*********************************************************************** -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 SILK_TYPEDEF_H -#define SILK_TYPEDEF_H - -#include "opus_types.h" -#include "opus_defines.h" - -#ifndef FIXED_POINT -# include -# define silk_float float -# define silk_float_MAX FLT_MAX -#endif - -#define silk_int64_MAX ((opus_int64)0x7FFFFFFFFFFFFFFFLL) /* 2^63 - 1 */ -#define silk_int64_MIN ((opus_int64)0x8000000000000000LL) /* -2^63 */ -#define silk_int32_MAX 0x7FFFFFFF /* 2^31 - 1 = 2147483647 */ -#define silk_int32_MIN ((opus_int32)0x80000000) /* -2^31 = -2147483648 */ -#define silk_int16_MAX 0x7FFF /* 2^15 - 1 = 32767 */ -#define silk_int16_MIN ((opus_int16)0x8000) /* -2^15 = -32768 */ -#define silk_int8_MAX 0x7F /* 2^7 - 1 = 127 */ -#define silk_int8_MIN ((opus_int8)0x80) /* -2^7 = -128 */ -#define silk_uint8_MAX 0xFF /* 2^8 - 1 = 255 */ - -#define silk_TRUE 1 -#define silk_FALSE 0 - -/* assertions */ -#if (defined _WIN32 && !defined _WINCE && !defined(__GNUC__) && !defined(NO_ASSERTS)) -# ifndef silk_assert -# include /* ASSERTE() */ -# define silk_assert(COND) _ASSERTE(COND) -# endif -#else -# ifdef ENABLE_ASSERTIONS -# include -# include -#define silk_fatal(str) _silk_fatal(str, __FILE__, __LINE__); -#ifdef __GNUC__ -__attribute__((noreturn)) -#endif -static OPUS_INLINE void _silk_fatal(const char *str, const char *file, int line) -{ - fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); -#if defined(_MSC_VER) - _set_abort_behavior( 0, _WRITE_ABORT_MSG); -#endif - abort(); -} -# define silk_assert(COND) {if (!(COND)) {silk_fatal("assertion failed: " #COND);}} -# else -# define silk_assert(COND) -# endif -#endif - -#endif /* SILK_TYPEDEF_H */ diff --git a/Engine/lib/opus/silk/x86/NSQ_del_dec_sse4_1.c b/Engine/lib/opus/silk/x86/NSQ_del_dec_sse4_1.c deleted file mode 100644 index a58a76cd8..000000000 --- a/Engine/lib/opus/silk/x86/NSQ_del_dec_sse4_1.c +++ /dev/null @@ -1,915 +0,0 @@ -/* Copyright (c) 2014-2020, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang FrancisQuiers - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - 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 -#include -#include -#include "main.h" -#include "celt/x86/x86cpu.h" - -#include "stack_alloc.h" - -typedef struct { - opus_int32 sLPC_Q14[ MAX_SUB_FRAME_LENGTH + NSQ_LPC_BUF_LENGTH ]; - opus_int32 RandState[ DECISION_DELAY ]; - opus_int32 Q_Q10[ DECISION_DELAY ]; - opus_int32 Xq_Q14[ DECISION_DELAY ]; - opus_int32 Pred_Q15[ DECISION_DELAY ]; - opus_int32 Shape_Q14[ DECISION_DELAY ]; - opus_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ]; - opus_int32 LF_AR_Q14; - opus_int32 Diff_Q14; - opus_int32 Seed; - opus_int32 SeedInit; - opus_int32 RD_Q10; -} NSQ_del_dec_struct; - -typedef struct { - opus_int32 Q_Q10; - opus_int32 RD_Q10; - opus_int32 xq_Q14; - opus_int32 LF_AR_Q14; - opus_int32 Diff_Q14; - opus_int32 sLTP_shp_Q14; - opus_int32 LPC_exc_Q14; -} NSQ_sample_struct; - -typedef NSQ_sample_struct NSQ_sample_pair[ 2 ]; - -static OPUS_INLINE void silk_nsq_del_dec_scale_states_sse4_1( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - const opus_int16 x16[], /* I Input */ - opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ - const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I Subframe number */ - opus_int nStatesDelayedDecision, /* I Number of del dec states */ - const opus_int LTP_scale_Q14, /* I LTP state scaling */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type, /* I Signal type */ - const opus_int decisionDelay /* I Decision delay */ -); - -/******************************************/ -/* Noise shape quantizer for one subframe */ -/******************************************/ -static OPUS_INLINE void silk_noise_shape_quantizer_del_dec_sse4_1( - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP filter state */ - opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int subfr, /* I Subframe number */ - opus_int shapingLPCOrder, /* I Shaping LPC filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - opus_int warping_Q16, /* I */ - opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ - opus_int *smpl_buf_idx, /* I/O Index to newest samples in buffers */ - opus_int decisionDelay /* I */ -); - -void silk_NSQ_del_dec_sse4_1( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -) -{ - opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr; - opus_int last_smple_idx, smpl_buf_idx, decisionDelay; - const opus_int16 *A_Q12, *B_Q14, *AR_shp_Q13; - opus_int16 *pxq; - VARDECL( opus_int32, sLTP_Q15 ); - VARDECL( opus_int16, sLTP ); - opus_int32 HarmShapeFIRPacked_Q14; - opus_int offset_Q10; - opus_int32 RDmin_Q10, Gain_Q10; - VARDECL( opus_int32, x_sc_Q10 ); - VARDECL( opus_int32, delayedGain_Q10 ); - VARDECL( NSQ_del_dec_struct, psDelDec ); - NSQ_del_dec_struct *psDD; -#ifdef OPUS_CHECK_ASM - silk_nsq_state NSQ_c; - SideInfoIndices psIndices_c; - opus_int8 pulses_c[ MAX_FRAME_LENGTH ]; - const opus_int8 *const pulses_a = pulses; -#endif - SAVE_STACK; - -#ifdef OPUS_CHECK_ASM - ( void )pulses_a; - silk_memcpy( &NSQ_c, NSQ, sizeof( NSQ_c ) ); - silk_memcpy( &psIndices_c, psIndices, sizeof( psIndices_c ) ); - silk_assert( psEncC->nb_subfr * psEncC->subfr_length <= MAX_FRAME_LENGTH ); - silk_memcpy( pulses_c, pulses, psEncC->nb_subfr * psEncC->subfr_length * sizeof( pulses[0] ) ); - silk_NSQ_del_dec_c( - psEncC, - &NSQ_c, - &psIndices_c, - x16, - pulses_c, - PredCoef_Q12, - LTPCoef_Q14, - AR_Q13, - HarmShapeGain_Q14, - Tilt_Q14, - LF_shp_Q14, - Gains_Q16, - pitchL, - Lambda_Q10, - LTP_scale_Q14 - ); -#endif - - /* Set unvoiced lag to the previous one, overwrite later for voiced */ - lag = NSQ->lagPrev; - - silk_assert( NSQ->prev_gain_Q16 != 0 ); - - /* Initialize delayed decision states */ - ALLOC( psDelDec, psEncC->nStatesDelayedDecision, NSQ_del_dec_struct ); - silk_memset( psDelDec, 0, psEncC->nStatesDelayedDecision * sizeof( NSQ_del_dec_struct ) ); - for( k = 0; k < psEncC->nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - psDD->Seed = ( k + psIndices->Seed ) & 3; - psDD->SeedInit = psDD->Seed; - psDD->RD_Q10 = 0; - psDD->LF_AR_Q14 = NSQ->sLF_AR_shp_Q14; - psDD->Diff_Q14 = NSQ->sDiff_shp_Q14; - psDD->Shape_Q14[ 0 ] = NSQ->sLTP_shp_Q14[ psEncC->ltp_mem_length - 1 ]; - silk_memcpy( psDD->sLPC_Q14, NSQ->sLPC_Q14, NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); - silk_memcpy( psDD->sAR2_Q14, NSQ->sAR2_Q14, sizeof( NSQ->sAR2_Q14 ) ); - } - - offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; - smpl_buf_idx = 0; /* index of oldest samples */ - - decisionDelay = silk_min_int( DECISION_DELAY, psEncC->subfr_length ); - - /* For voiced frames limit the decision delay to lower than the pitch lag */ - if( psIndices->signalType == TYPE_VOICED ) { - for( k = 0; k < psEncC->nb_subfr; k++ ) { - decisionDelay = silk_min_int( decisionDelay, pitchL[ k ] - LTP_ORDER / 2 - 1 ); - } - } else { - if( lag > 0 ) { - decisionDelay = silk_min_int( decisionDelay, lag - LTP_ORDER / 2 - 1 ); - } - } - - if( psIndices->NLSFInterpCoef_Q2 == 4 ) { - LSF_interpolation_flag = 0; - } else { - LSF_interpolation_flag = 1; - } - - ALLOC( sLTP_Q15, psEncC->ltp_mem_length + psEncC->frame_length, opus_int32 ); - ALLOC( sLTP, psEncC->ltp_mem_length + psEncC->frame_length, opus_int16 ); - ALLOC( x_sc_Q10, psEncC->subfr_length, opus_int32 ); - ALLOC( delayedGain_Q10, DECISION_DELAY, opus_int32 ); - /* Set up pointers to start of sub frame */ - pxq = &NSQ->xq[ psEncC->ltp_mem_length ]; - NSQ->sLTP_shp_buf_idx = psEncC->ltp_mem_length; - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - subfr = 0; - for( k = 0; k < psEncC->nb_subfr; k++ ) { - A_Q12 = &PredCoef_Q12[ ( ( k >> 1 ) | ( 1 - LSF_interpolation_flag ) ) * MAX_LPC_ORDER ]; - B_Q14 = <PCoef_Q14[ k * LTP_ORDER ]; - AR_shp_Q13 = &AR_Q13[ k * MAX_SHAPE_LPC_ORDER ]; - - /* Noise shape parameters */ - silk_assert( HarmShapeGain_Q14[ k ] >= 0 ); - HarmShapeFIRPacked_Q14 = silk_RSHIFT( HarmShapeGain_Q14[ k ], 2 ); - HarmShapeFIRPacked_Q14 |= silk_LSHIFT( (opus_int32)silk_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 ); - - NSQ->rewhite_flag = 0; - if( psIndices->signalType == TYPE_VOICED ) { - /* Voiced */ - lag = pitchL[ k ]; - - /* Re-whitening */ - if( ( k & ( 3 - silk_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) { - if( k == 2 ) { - /* RESET DELAYED DECISIONS */ - /* Find winner */ - RDmin_Q10 = psDelDec[ 0 ].RD_Q10; - Winner_ind = 0; - for( i = 1; i < psEncC->nStatesDelayedDecision; i++ ) { - if( psDelDec[ i ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psDelDec[ i ].RD_Q10; - Winner_ind = i; - } - } - for( i = 0; i < psEncC->nStatesDelayedDecision; i++ ) { - if( i != Winner_ind ) { - psDelDec[ i ].RD_Q10 += ( silk_int32_MAX >> 4 ); - silk_assert( psDelDec[ i ].RD_Q10 >= 0 ); - } - } - - /* Copy final part of signals from winner state to output and long-term filter states */ - psDD = &psDelDec[ Winner_ind ]; - last_smple_idx = smpl_buf_idx + decisionDelay; - for( i = 0; i < decisionDelay; i++ ) { - last_smple_idx = ( last_smple_idx - 1 ) % DECISION_DELAY; - if( last_smple_idx < 0 ) last_smple_idx += DECISION_DELAY; - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); - pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( - silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gains_Q16[ 1 ] ), 14 ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q14[ last_smple_idx ]; - } - - subfr = 0; - } - - /* Rewhiten with new A coefs */ - start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2; - celt_assert( start_idx > 0 ); - - silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], - A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder, psEncC->arch ); - - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - NSQ->rewhite_flag = 1; - } - } - - silk_nsq_del_dec_scale_states_sse4_1( psEncC, NSQ, psDelDec, x16, x_sc_Q10, sLTP, sLTP_Q15, k, - psEncC->nStatesDelayedDecision, LTP_scale_Q14, Gains_Q16, pitchL, psIndices->signalType, decisionDelay ); - - silk_noise_shape_quantizer_del_dec_sse4_1( NSQ, psDelDec, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q15, - delayedGain_Q10, A_Q12, B_Q14, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], - Gains_Q16[ k ], Lambda_Q10, offset_Q10, psEncC->subfr_length, subfr++, psEncC->shapingLPCOrder, - psEncC->predictLPCOrder, psEncC->warping_Q16, psEncC->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay ); - - x16 += psEncC->subfr_length; - pulses += psEncC->subfr_length; - pxq += psEncC->subfr_length; - } - - /* Find winner */ - RDmin_Q10 = psDelDec[ 0 ].RD_Q10; - Winner_ind = 0; - for( k = 1; k < psEncC->nStatesDelayedDecision; k++ ) { - if( psDelDec[ k ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psDelDec[ k ].RD_Q10; - Winner_ind = k; - } - } - - /* Copy final part of signals from winner state to output and long-term filter states */ - psDD = &psDelDec[ Winner_ind ]; - psIndices->Seed = psDD->SeedInit; - last_smple_idx = smpl_buf_idx + decisionDelay; - Gain_Q10 = silk_RSHIFT32( Gains_Q16[ psEncC->nb_subfr - 1 ], 6 ); - for( i = 0; i < decisionDelay; i++ ) { - last_smple_idx = ( last_smple_idx - 1 ) % DECISION_DELAY; - if( last_smple_idx < 0 ) last_smple_idx += DECISION_DELAY; - - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); - pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( - silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gain_Q10 ), 8 ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q14[ last_smple_idx ]; - } - silk_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); - silk_memcpy( NSQ->sAR2_Q14, psDD->sAR2_Q14, sizeof( psDD->sAR2_Q14 ) ); - - /* Update states */ - NSQ->sLF_AR_shp_Q14 = psDD->LF_AR_Q14; - NSQ->sDiff_shp_Q14 = psDD->Diff_Q14; - NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ]; - - /* Save quantized speech signal */ - silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) ); - silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) ); - -#ifdef OPUS_CHECK_ASM - silk_assert( !memcmp( &NSQ_c, NSQ, sizeof( NSQ_c ) ) ); - silk_assert( !memcmp( &psIndices_c, psIndices, sizeof( psIndices_c ) ) ); - silk_assert( !memcmp( pulses_c, pulses_a, psEncC->nb_subfr * psEncC->subfr_length * sizeof( pulses[0] ) ) ); -#endif - - RESTORE_STACK; -} - -/******************************************/ -/* Noise shape quantizer for one subframe */ -/******************************************/ -static OPUS_INLINE void silk_noise_shape_quantizer_del_dec_sse4_1( - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP filter state */ - opus_int32 delayedGain_Q10[], /* I/O Gain delay buffer */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int subfr, /* I Subframe number */ - opus_int shapingLPCOrder, /* I Shaping LPC filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - opus_int warping_Q16, /* I */ - opus_int nStatesDelayedDecision, /* I Number of states in decision tree */ - opus_int *smpl_buf_idx, /* I/O Index to newest samples in buffers */ - opus_int decisionDelay /* I */ -) -{ - opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; - opus_int32 Winner_rand_state; - opus_int32 LTP_pred_Q14, LPC_pred_Q14, n_AR_Q14, n_LTP_Q14; - opus_int32 n_LF_Q14, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10; - opus_int32 q1_Q0, q1_Q10, q2_Q10, exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10; - opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; - opus_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14; - int rdo_offset; - - VARDECL( NSQ_sample_pair, psSampleState ); - NSQ_del_dec_struct *psDD; - NSQ_sample_struct *psSS; - - __m128i a_Q12_0123, a_Q12_4567, a_Q12_89AB, a_Q12_CDEF; - __m128i b_Q12_0123, b_sr_Q12_0123; - SAVE_STACK; - - celt_assert( nStatesDelayedDecision > 0 ); - ALLOC( psSampleState, nStatesDelayedDecision, NSQ_sample_pair ); - - rdo_offset = (Lambda_Q10 >> 1) - 512; - - shp_lag_ptr = &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ]; - pred_lag_ptr = &sLTP_Q15[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ]; - Gain_Q10 = silk_RSHIFT( Gain_Q16, 6 ); - - a_Q12_0123 = OP_CVTEPI16_EPI32_M64( a_Q12 ); - a_Q12_4567 = OP_CVTEPI16_EPI32_M64( a_Q12 + 4 ); - - if( opus_likely( predictLPCOrder == 16 ) ) { - a_Q12_89AB = OP_CVTEPI16_EPI32_M64( a_Q12 + 8 ); - a_Q12_CDEF = OP_CVTEPI16_EPI32_M64( a_Q12 + 12 ); - } - - if( signalType == TYPE_VOICED ){ - b_Q12_0123 = OP_CVTEPI16_EPI32_M64( b_Q14 ); - b_sr_Q12_0123 = _mm_shuffle_epi32( b_Q12_0123, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ - } - for( i = 0; i < length; i++ ) { - /* Perform common calculations used in all states */ - - /* Long-term prediction */ - if( signalType == TYPE_VOICED ) { - /* Unrolled loop */ - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LTP_pred_Q14 = 2; - { - __m128i tmpa, tmpb, pred_lag_ptr_tmp; - pred_lag_ptr_tmp = _mm_loadu_si128( (__m128i *)(&pred_lag_ptr[ -3 ] ) ); - pred_lag_ptr_tmp = _mm_shuffle_epi32( pred_lag_ptr_tmp, 0x1B ); - tmpa = _mm_mul_epi32( pred_lag_ptr_tmp, b_Q12_0123 ); - tmpa = _mm_srli_si128( tmpa, 2 ); - - pred_lag_ptr_tmp = _mm_shuffle_epi32( pred_lag_ptr_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) );/* equal shift right 4 bytes */ - pred_lag_ptr_tmp = _mm_mul_epi32( pred_lag_ptr_tmp, b_sr_Q12_0123 ); - pred_lag_ptr_tmp = _mm_srli_si128( pred_lag_ptr_tmp, 2 ); - pred_lag_ptr_tmp = _mm_add_epi32( pred_lag_ptr_tmp, tmpa ); - - tmpb = _mm_shuffle_epi32( pred_lag_ptr_tmp, _MM_SHUFFLE( 0, 0, 3, 2 ) );/* equal shift right 8 bytes */ - pred_lag_ptr_tmp = _mm_add_epi32( pred_lag_ptr_tmp, tmpb ); - LTP_pred_Q14 += _mm_cvtsi128_si32( pred_lag_ptr_tmp ); - - LTP_pred_Q14 = silk_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -4 ], b_Q14[ 4 ] ); - LTP_pred_Q14 = silk_LSHIFT( LTP_pred_Q14, 1 ); /* Q13 -> Q14 */ - pred_lag_ptr++; - } - } else { - LTP_pred_Q14 = 0; - } - - /* Long-term shaping */ - if( lag > 0 ) { - /* Symmetric, packed FIR coefficients */ - n_LTP_Q14 = silk_SMULWB( silk_ADD_SAT32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = silk_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); - n_LTP_Q14 = silk_SUB_LSHIFT32( LTP_pred_Q14, n_LTP_Q14, 2 ); /* Q12 -> Q14 */ - shp_lag_ptr++; - } else { - n_LTP_Q14 = 0; - } - { - __m128i tmpa, tmpb, psLPC_Q14_tmp, a_Q12_tmp; - - for( k = 0; k < nStatesDelayedDecision; k++ ) { - /* Delayed decision state */ - psDD = &psDelDec[ k ]; - - /* Sample state */ - psSS = psSampleState[ k ]; - - /* Generate dither */ - psDD->Seed = silk_RAND( psDD->Seed ); - - /* Pointer used in short term prediction and shaping */ - psLPC_Q14 = &psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 + i ]; - /* Short-term prediction */ - silk_assert( predictLPCOrder == 10 || predictLPCOrder == 16 ); - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LPC_pred_Q14 = silk_RSHIFT( predictLPCOrder, 1 ); - - tmpb = _mm_setzero_si128(); - - /* step 1 */ - psLPC_Q14_tmp = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -3 ] ) ); /* -3, -2 , -1, 0 */ - psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, 0x1B ); /* 0, -1, -2, -3 */ - tmpa = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_0123 ); /* 0, -1, -2, -3 * 0123 -> 0*0, 2*-2 */ - - tmpa = _mm_srli_epi64( tmpa, 16 ); - tmpb = _mm_add_epi32( tmpb, tmpa ); - - psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ - a_Q12_tmp = _mm_shuffle_epi32( a_Q12_0123, _MM_SHUFFLE(0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ - psLPC_Q14_tmp = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_tmp ); /* 1*-1, 3*-3 */ - psLPC_Q14_tmp = _mm_srli_epi64( psLPC_Q14_tmp, 16 ); - tmpb = _mm_add_epi32( tmpb, psLPC_Q14_tmp ); - - /* step 2 */ - psLPC_Q14_tmp = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -7 ] ) ); - psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, 0x1B ); - tmpa = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_4567 ); - tmpa = _mm_srli_epi64( tmpa, 16 ); - tmpb = _mm_add_epi32( tmpb, tmpa ); - - psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ - a_Q12_tmp = _mm_shuffle_epi32( a_Q12_4567, _MM_SHUFFLE(0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ - psLPC_Q14_tmp = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_tmp ); - psLPC_Q14_tmp = _mm_srli_epi64( psLPC_Q14_tmp, 16 ); - tmpb = _mm_add_epi32( tmpb, psLPC_Q14_tmp ); - - if ( opus_likely( predictLPCOrder == 16 ) ) - { - /* step 3 */ - psLPC_Q14_tmp = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -11 ] ) ); - psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, 0x1B ); - tmpa = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_89AB ); - tmpa = _mm_srli_epi64( tmpa, 16 ); - tmpb = _mm_add_epi32( tmpb, tmpa ); - - psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ - a_Q12_tmp = _mm_shuffle_epi32( a_Q12_89AB, _MM_SHUFFLE(0, 3, 2, 1 ) );/* equal shift right 4 bytes */ - psLPC_Q14_tmp = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_tmp ); - psLPC_Q14_tmp = _mm_srli_epi64( psLPC_Q14_tmp, 16 ); - tmpb = _mm_add_epi32( tmpb, psLPC_Q14_tmp ); - - /* step 4 */ - psLPC_Q14_tmp = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -15 ] ) ); - psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, 0x1B ); - tmpa = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_CDEF ); - tmpa = _mm_srli_epi64( tmpa, 16 ); - tmpb = _mm_add_epi32( tmpb, tmpa ); - - psLPC_Q14_tmp = _mm_shuffle_epi32( psLPC_Q14_tmp, _MM_SHUFFLE( 0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ - a_Q12_tmp = _mm_shuffle_epi32( a_Q12_CDEF, _MM_SHUFFLE(0, 3, 2, 1 ) ); /* equal shift right 4 bytes */ - psLPC_Q14_tmp = _mm_mul_epi32( psLPC_Q14_tmp, a_Q12_tmp ); - psLPC_Q14_tmp = _mm_srli_epi64( psLPC_Q14_tmp, 16 ); - tmpb = _mm_add_epi32( tmpb, psLPC_Q14_tmp ); - - /* add at last */ - /* equal shift right 8 bytes*/ - tmpa = _mm_shuffle_epi32( tmpb, _MM_SHUFFLE( 0, 0, 3, 2 ) ); - tmpb = _mm_add_epi32( tmpb, tmpa ); - LPC_pred_Q14 += _mm_cvtsi128_si32( tmpb ); - } - else - { - /* add at last */ - tmpa = _mm_shuffle_epi32( tmpb, _MM_SHUFFLE( 0, 0, 3, 2 ) ); /* equal shift right 8 bytes*/ - tmpb = _mm_add_epi32( tmpb, tmpa ); - LPC_pred_Q14 += _mm_cvtsi128_si32( tmpb ); - - LPC_pred_Q14 = silk_SMLAWB( LPC_pred_Q14, psLPC_Q14[ -8 ], a_Q12[ 8 ] ); - LPC_pred_Q14 = silk_SMLAWB( LPC_pred_Q14, psLPC_Q14[ -9 ], a_Q12[ 9 ] ); - } - - LPC_pred_Q14 = silk_LSHIFT( LPC_pred_Q14, 4 ); /* Q10 -> Q14 */ - - /* Noise shape feedback */ - celt_assert( ( shapingLPCOrder & 1 ) == 0 ); /* check that order is even */ - /* Output of lowpass section */ - tmp2 = silk_SMLAWB( psDD->Diff_Q14, psDD->sAR2_Q14[ 0 ], warping_Q16 ); - /* Output of allpass section */ - tmp1 = silk_SMLAWB( psDD->sAR2_Q14[ 0 ], psDD->sAR2_Q14[ 1 ] - tmp2, warping_Q16 ); - psDD->sAR2_Q14[ 0 ] = tmp2; - n_AR_Q14 = silk_RSHIFT( shapingLPCOrder, 1 ); - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp2, AR_shp_Q13[ 0 ] ); - /* Loop over allpass sections */ - for( j = 2; j < shapingLPCOrder; j += 2 ) { - /* Output of allpass section */ - tmp2 = silk_SMLAWB( psDD->sAR2_Q14[ j - 1 ], psDD->sAR2_Q14[ j + 0 ] - tmp1, warping_Q16 ); - psDD->sAR2_Q14[ j - 1 ] = tmp1; - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp1, AR_shp_Q13[ j - 1 ] ); - /* Output of allpass section */ - tmp1 = silk_SMLAWB( psDD->sAR2_Q14[ j + 0 ], psDD->sAR2_Q14[ j + 1 ] - tmp2, warping_Q16 ); - psDD->sAR2_Q14[ j + 0 ] = tmp2; - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp2, AR_shp_Q13[ j ] ); - } - psDD->sAR2_Q14[ shapingLPCOrder - 1 ] = tmp1; - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, tmp1, AR_shp_Q13[ shapingLPCOrder - 1 ] ); - - n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 1 ); /* Q11 -> Q12 */ - n_AR_Q14 = silk_SMLAWB( n_AR_Q14, psDD->LF_AR_Q14, Tilt_Q14 ); /* Q12 */ - n_AR_Q14 = silk_LSHIFT( n_AR_Q14, 2 ); /* Q12 -> Q14 */ - - n_LF_Q14 = silk_SMULWB( psDD->Shape_Q14[ *smpl_buf_idx ], LF_shp_Q14 ); /* Q12 */ - n_LF_Q14 = silk_SMLAWT( n_LF_Q14, psDD->LF_AR_Q14, LF_shp_Q14 ); /* Q12 */ - n_LF_Q14 = silk_LSHIFT( n_LF_Q14, 2 ); /* Q12 -> Q14 */ - - /* Input minus prediction plus noise feedback */ - /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP */ - tmp1 = silk_ADD_SAT32( n_AR_Q14, n_LF_Q14 ); /* Q14 */ - tmp2 = silk_ADD32( n_LTP_Q14, LPC_pred_Q14 ); /* Q13 */ - tmp1 = silk_SUB_SAT32( tmp2, tmp1 ); /* Q13 */ - tmp1 = silk_RSHIFT_ROUND( tmp1, 4 ); /* Q10 */ - - r_Q10 = silk_SUB32( x_Q10[ i ], tmp1 ); /* residual error Q10 */ - - /* Flip sign depending on dither */ - if ( psDD->Seed < 0 ) { - r_Q10 = -r_Q10; - } - r_Q10 = silk_LIMIT_32( r_Q10, -(31 << 10), 30 << 10 ); - - /* Find two quantization level candidates and measure their rate-distortion */ - q1_Q10 = silk_SUB32( r_Q10, offset_Q10 ); - q1_Q0 = silk_RSHIFT( q1_Q10, 10 ); - if (Lambda_Q10 > 2048) { - /* For aggressive RDO, the bias becomes more than one pulse. */ - if (q1_Q10 > rdo_offset) { - q1_Q0 = silk_RSHIFT( q1_Q10 - rdo_offset, 10 ); - } else if (q1_Q10 < -rdo_offset) { - q1_Q0 = silk_RSHIFT( q1_Q10 + rdo_offset, 10 ); - } else if (q1_Q10 < 0) { - q1_Q0 = -1; - } else { - q1_Q0 = 0; - } - } - if( q1_Q0 > 0 ) { - q1_Q10 = silk_SUB32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); - q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); - q2_Q10 = silk_ADD32( q1_Q10, 1024 ); - rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else if( q1_Q0 == 0 ) { - q1_Q10 = offset_Q10; - q2_Q10 = silk_ADD32( q1_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); - rd1_Q10 = silk_SMULBB( q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else if( q1_Q0 == -1 ) { - q2_Q10 = offset_Q10; - q1_Q10 = silk_SUB32( q2_Q10, 1024 - QUANT_LEVEL_ADJUST_Q10 ); - rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( q2_Q10, Lambda_Q10 ); - } else { /* q1_Q0 < -1 */ - q1_Q10 = silk_ADD32( silk_LSHIFT( q1_Q0, 10 ), QUANT_LEVEL_ADJUST_Q10 ); - q1_Q10 = silk_ADD32( q1_Q10, offset_Q10 ); - q2_Q10 = silk_ADD32( q1_Q10, 1024 ); - rd1_Q10 = silk_SMULBB( -q1_Q10, Lambda_Q10 ); - rd2_Q10 = silk_SMULBB( -q2_Q10, Lambda_Q10 ); - } - rr_Q10 = silk_SUB32( r_Q10, q1_Q10 ); - rd1_Q10 = silk_RSHIFT( silk_SMLABB( rd1_Q10, rr_Q10, rr_Q10 ), 10 ); - rr_Q10 = silk_SUB32( r_Q10, q2_Q10 ); - rd2_Q10 = silk_RSHIFT( silk_SMLABB( rd2_Q10, rr_Q10, rr_Q10 ), 10 ); - - if( rd1_Q10 < rd2_Q10 ) { - psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); - psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); - psSS[ 0 ].Q_Q10 = q1_Q10; - psSS[ 1 ].Q_Q10 = q2_Q10; - } else { - psSS[ 0 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd2_Q10 ); - psSS[ 1 ].RD_Q10 = silk_ADD32( psDD->RD_Q10, rd1_Q10 ); - psSS[ 0 ].Q_Q10 = q2_Q10; - psSS[ 1 ].Q_Q10 = q1_Q10; - } - - /* Update states for best quantization */ - - /* Quantized excitation */ - exc_Q14 = silk_LSHIFT32( psSS[ 0 ].Q_Q10, 4 ); - if ( psDD->Seed < 0 ) { - exc_Q14 = -exc_Q14; - } - - /* Add predictions */ - LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); - xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); - - /* Update states */ - psSS[ 0 ].Diff_Q14 = silk_SUB_LSHIFT32( xq_Q14, x_Q10[ i ], 4 ); - sLF_AR_shp_Q14 = silk_SUB32( psSS[ 0 ].Diff_Q14, n_AR_Q14 ); - psSS[ 0 ].sLTP_shp_Q14 = silk_SUB_SAT32( sLF_AR_shp_Q14, n_LF_Q14 ); - psSS[ 0 ].LF_AR_Q14 = sLF_AR_shp_Q14; - psSS[ 0 ].LPC_exc_Q14 = LPC_exc_Q14; - psSS[ 0 ].xq_Q14 = xq_Q14; - - /* Update states for second best quantization */ - - /* Quantized excitation */ - exc_Q14 = silk_LSHIFT32( psSS[ 1 ].Q_Q10, 4 ); - if ( psDD->Seed < 0 ) { - exc_Q14 = -exc_Q14; - } - - /* Add predictions */ - LPC_exc_Q14 = silk_ADD32( exc_Q14, LTP_pred_Q14 ); - xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); - - /* Update states */ - psSS[ 1 ].Diff_Q14 = silk_SUB_LSHIFT32( xq_Q14, x_Q10[ i ], 4 ); - sLF_AR_shp_Q14 = silk_SUB32( psSS[ 1 ].Diff_Q14, n_AR_Q14 ); - psSS[ 1 ].sLTP_shp_Q14 = silk_SUB_SAT32( sLF_AR_shp_Q14, n_LF_Q14 ); - psSS[ 1 ].LF_AR_Q14 = sLF_AR_shp_Q14; - psSS[ 1 ].LPC_exc_Q14 = LPC_exc_Q14; - psSS[ 1 ].xq_Q14 = xq_Q14; - } - } - *smpl_buf_idx = ( *smpl_buf_idx - 1 ) % DECISION_DELAY; - if( *smpl_buf_idx < 0 ) *smpl_buf_idx += DECISION_DELAY; - last_smple_idx = ( *smpl_buf_idx + decisionDelay ) % DECISION_DELAY; - - /* Find winner */ - RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; - Winner_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ k ][ 0 ].RD_Q10; - Winner_ind = k; - } - } - - /* Increase RD values of expired states */ - Winner_rand_state = psDelDec[ Winner_ind ].RandState[ last_smple_idx ]; - for( k = 0; k < nStatesDelayedDecision; k++ ) { - if( psDelDec[ k ].RandState[ last_smple_idx ] != Winner_rand_state ) { - psSampleState[ k ][ 0 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 0 ].RD_Q10, silk_int32_MAX >> 4 ); - psSampleState[ k ][ 1 ].RD_Q10 = silk_ADD32( psSampleState[ k ][ 1 ].RD_Q10, silk_int32_MAX >> 4 ); - silk_assert( psSampleState[ k ][ 0 ].RD_Q10 >= 0 ); - } - } - - /* Find worst in first set and best in second set */ - RDmax_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; - RDmin_Q10 = psSampleState[ 0 ][ 1 ].RD_Q10; - RDmax_ind = 0; - RDmin_ind = 0; - for( k = 1; k < nStatesDelayedDecision; k++ ) { - /* find worst in first set */ - if( psSampleState[ k ][ 0 ].RD_Q10 > RDmax_Q10 ) { - RDmax_Q10 = psSampleState[ k ][ 0 ].RD_Q10; - RDmax_ind = k; - } - /* find best in second set */ - if( psSampleState[ k ][ 1 ].RD_Q10 < RDmin_Q10 ) { - RDmin_Q10 = psSampleState[ k ][ 1 ].RD_Q10; - RDmin_ind = k; - } - } - - /* Replace a state if best from second set outperforms worst in first set */ - if( RDmin_Q10 < RDmax_Q10 ) { - silk_memcpy( ( (opus_int32 *)&psDelDec[ RDmax_ind ] ) + i, - ( (opus_int32 *)&psDelDec[ RDmin_ind ] ) + i, sizeof( NSQ_del_dec_struct ) - i * sizeof( opus_int32) ); - silk_memcpy( &psSampleState[ RDmax_ind ][ 0 ], &psSampleState[ RDmin_ind ][ 1 ], sizeof( NSQ_sample_struct ) ); - } - - /* Write samples from winner to output and long-term filter states */ - psDD = &psDelDec[ Winner_ind ]; - if( subfr > 0 || i >= decisionDelay ) { - pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q10[ last_smple_idx ], 10 ); - xq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( - silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], delayedGain_Q10[ last_smple_idx ] ), 8 ) ); - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDD->Shape_Q14[ last_smple_idx ]; - sLTP_Q15[ NSQ->sLTP_buf_idx - decisionDelay ] = psDD->Pred_Q15[ last_smple_idx ]; - } - NSQ->sLTP_shp_buf_idx++; - NSQ->sLTP_buf_idx++; - - /* Update states */ - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - psSS = &psSampleState[ k ][ 0 ]; - psDD->LF_AR_Q14 = psSS->LF_AR_Q14; - psDD->Diff_Q14 = psSS->Diff_Q14; - psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH + i ] = psSS->xq_Q14; - psDD->Xq_Q14[ *smpl_buf_idx ] = psSS->xq_Q14; - psDD->Q_Q10[ *smpl_buf_idx ] = psSS->Q_Q10; - psDD->Pred_Q15[ *smpl_buf_idx ] = silk_LSHIFT32( psSS->LPC_exc_Q14, 1 ); - psDD->Shape_Q14[ *smpl_buf_idx ] = psSS->sLTP_shp_Q14; - psDD->Seed = silk_ADD32_ovflw( psDD->Seed, silk_RSHIFT_ROUND( psSS->Q_Q10, 10 ) ); - psDD->RandState[ *smpl_buf_idx ] = psDD->Seed; - psDD->RD_Q10 = psSS->RD_Q10; - } - delayedGain_Q10[ *smpl_buf_idx ] = Gain_Q10; - } - /* Update LPC states */ - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - silk_memcpy( psDD->sLPC_Q14, &psDD->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); - } - RESTORE_STACK; -} - -static OPUS_INLINE void silk_nsq_del_dec_scale_states_sse4_1( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ - const opus_int16 x16[], /* I Input */ - opus_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ - const opus_int16 sLTP[], /* I Re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I Subframe number */ - opus_int nStatesDelayedDecision, /* I Number of del dec states */ - const opus_int LTP_scale_Q14, /* I LTP state scaling */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type, /* I Signal type */ - const opus_int decisionDelay /* I Decision delay */ -) -{ - opus_int i, k, lag; - opus_int32 gain_adj_Q16, inv_gain_Q31, inv_gain_Q26; - NSQ_del_dec_struct *psDD; - __m128i xmm_inv_gain_Q26, xmm_x16_x2x0, xmm_x16_x3x1; - - lag = pitchL[ subfr ]; - inv_gain_Q31 = silk_INVERSE32_varQ( silk_max( Gains_Q16[ subfr ], 1 ), 47 ); - silk_assert( inv_gain_Q31 != 0 ); - - /* Scale input */ - inv_gain_Q26 = silk_RSHIFT_ROUND( inv_gain_Q31, 5 ); - - /* prepare inv_gain_Q26 in packed 4 32-bits */ - xmm_inv_gain_Q26 = _mm_set1_epi32(inv_gain_Q26); - - for( i = 0; i < psEncC->subfr_length - 3; i += 4 ) { - xmm_x16_x2x0 = OP_CVTEPI16_EPI32_M64( &(x16[ i ] ) ); - - /* equal shift right 4 bytes*/ - xmm_x16_x3x1 = _mm_shuffle_epi32( xmm_x16_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - - xmm_x16_x2x0 = _mm_mul_epi32( xmm_x16_x2x0, xmm_inv_gain_Q26 ); - xmm_x16_x3x1 = _mm_mul_epi32( xmm_x16_x3x1, xmm_inv_gain_Q26 ); - - xmm_x16_x2x0 = _mm_srli_epi64( xmm_x16_x2x0, 16 ); - xmm_x16_x3x1 = _mm_slli_epi64( xmm_x16_x3x1, 16 ); - - xmm_x16_x2x0 = _mm_blend_epi16( xmm_x16_x2x0, xmm_x16_x3x1, 0xCC ); - - _mm_storeu_si128( (__m128i *)(&(x_sc_Q10[ i ] ) ), xmm_x16_x2x0 ); - } - - for( ; i < psEncC->subfr_length; i++ ) { - x_sc_Q10[ i ] = silk_SMULWW( x16[ i ], inv_gain_Q26 ); - } - - /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */ - if( NSQ->rewhite_flag ) { - if( subfr == 0 ) { - /* Do LTP downscaling */ - inv_gain_Q31 = silk_LSHIFT( silk_SMULWB( inv_gain_Q31, LTP_scale_Q14 ), 2 ); - } - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) { - silk_assert( i < MAX_FRAME_LENGTH ); - sLTP_Q15[ i ] = silk_SMULWB( inv_gain_Q31, sLTP[ i ] ); - } - } - - /* Adjust for changing gain */ - if( Gains_Q16[ subfr ] != NSQ->prev_gain_Q16 ) { - gain_adj_Q16 = silk_DIV32_varQ( NSQ->prev_gain_Q16, Gains_Q16[ subfr ], 16 ); - - /* Scale long-term shaping state */ - { - __m128i xmm_gain_adj_Q16, xmm_sLTP_shp_Q14_x2x0, xmm_sLTP_shp_Q14_x3x1; - - /* prepare gain_adj_Q16 in packed 4 32-bits */ - xmm_gain_adj_Q16 = _mm_set1_epi32( gain_adj_Q16 ); - - for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx - 3; i += 4 ) - { - xmm_sLTP_shp_Q14_x2x0 = _mm_loadu_si128( (__m128i *)(&(NSQ->sLTP_shp_Q14[ i ] ) ) ); - /* equal shift right 4 bytes*/ - xmm_sLTP_shp_Q14_x3x1 = _mm_shuffle_epi32( xmm_sLTP_shp_Q14_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - - xmm_sLTP_shp_Q14_x2x0 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x2x0, xmm_gain_adj_Q16 ); - xmm_sLTP_shp_Q14_x3x1 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x3x1, xmm_gain_adj_Q16 ); - - xmm_sLTP_shp_Q14_x2x0 = _mm_srli_epi64( xmm_sLTP_shp_Q14_x2x0, 16 ); - xmm_sLTP_shp_Q14_x3x1 = _mm_slli_epi64( xmm_sLTP_shp_Q14_x3x1, 16 ); - - xmm_sLTP_shp_Q14_x2x0 = _mm_blend_epi16( xmm_sLTP_shp_Q14_x2x0, xmm_sLTP_shp_Q14_x3x1, 0xCC ); - - _mm_storeu_si128( (__m128i *)(&(NSQ->sLTP_shp_Q14[ i ] ) ), xmm_sLTP_shp_Q14_x2x0 ); - } - - for( ; i < NSQ->sLTP_shp_buf_idx; i++ ) { - NSQ->sLTP_shp_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q14[ i ] ); - } - - /* Scale long-term prediction state */ - if( signal_type == TYPE_VOICED && NSQ->rewhite_flag == 0 ) { - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx - decisionDelay; i++ ) { - sLTP_Q15[ i ] = silk_SMULWW( gain_adj_Q16, sLTP_Q15[ i ] ); - } - } - - for( k = 0; k < nStatesDelayedDecision; k++ ) { - psDD = &psDelDec[ k ]; - - /* Scale scalar states */ - psDD->LF_AR_Q14 = silk_SMULWW( gain_adj_Q16, psDD->LF_AR_Q14 ); - psDD->Diff_Q14 = silk_SMULWW( gain_adj_Q16, psDD->Diff_Q14 ); - - /* Scale short-term prediction and shaping states */ - for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { - psDD->sLPC_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->sLPC_Q14[ i ] ); - } - for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { - psDD->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->sAR2_Q14[ i ] ); - } - for( i = 0; i < DECISION_DELAY; i++ ) { - psDD->Pred_Q15[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Pred_Q15[ i ] ); - psDD->Shape_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Shape_Q14[ i ] ); - } - } - } - - /* Save inverse gain */ - NSQ->prev_gain_Q16 = Gains_Q16[ subfr ]; - } -} diff --git a/Engine/lib/opus/silk/x86/NSQ_sse4_1.c b/Engine/lib/opus/silk/x86/NSQ_sse4_1.c deleted file mode 100644 index d5ae1d3b1..000000000 --- a/Engine/lib/opus/silk/x86/NSQ_sse4_1.c +++ /dev/null @@ -1,772 +0,0 @@ -/* Copyright (c) 2014-2020, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang FrancisQuiers - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - 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 -#include -#include -#include "main.h" -#include "celt/x86/x86cpu.h" -#include "stack_alloc.h" - -static OPUS_INLINE void silk_nsq_scale_states_sse4_1( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - const opus_int16 x16[], /* I input */ - opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ - const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I subframe number */ - const opus_int LTP_scale_Q14, /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type /* I Signal type */ -); - -static OPUS_INLINE void silk_noise_shape_quantizer_10_16_sse4_1( - silk_nsq_state *NSQ, /* I/O NSQ state */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_sc_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP state */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int32 table[][4] /* I */ -); - -void silk_NSQ_sse4_1( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -) -{ - opus_int k, lag, start_idx, LSF_interpolation_flag; - const opus_int16 *A_Q12, *B_Q14, *AR_shp_Q13; - opus_int16 *pxq; - VARDECL( opus_int32, sLTP_Q15 ); - VARDECL( opus_int16, sLTP ); - opus_int32 HarmShapeFIRPacked_Q14; - opus_int offset_Q10; - VARDECL( opus_int32, x_sc_Q10 ); - - opus_int32 table[ 64 ][ 4 ]; - opus_int32 tmp1; - opus_int32 q1_Q10, q2_Q10, rd1_Q20, rd2_Q20; - -#ifdef OPUS_CHECK_ASM - silk_nsq_state NSQ_c; - SideInfoIndices psIndices_c; - opus_int8 pulses_c[ MAX_FRAME_LENGTH ]; - const opus_int8 *const pulses_a = pulses; -#endif - - SAVE_STACK; - -#ifdef OPUS_CHECK_ASM - ( void )pulses_a; - silk_memcpy( &NSQ_c, NSQ, sizeof( NSQ_c ) ); - silk_memcpy( &psIndices_c, psIndices, sizeof( psIndices_c ) ); - silk_assert( psEncC->nb_subfr * psEncC->subfr_length <= MAX_FRAME_LENGTH ); - silk_memcpy( pulses_c, pulses, psEncC->nb_subfr * psEncC->subfr_length * sizeof( pulses[0] ) ); - - silk_NSQ_c( - psEncC, - &NSQ_c, - &psIndices_c, - x16, - pulses_c, - PredCoef_Q12, - LTPCoef_Q14, - AR_Q13, - HarmShapeGain_Q14, - Tilt_Q14, - LF_shp_Q14, - Gains_Q16, - pitchL, - Lambda_Q10, - LTP_scale_Q14 - ); -#endif - - NSQ->rand_seed = psIndices->Seed; - - /* Set unvoiced lag to the previous one, overwrite later for voiced */ - lag = NSQ->lagPrev; - - silk_assert( NSQ->prev_gain_Q16 != 0 ); - - offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; - - /* 0 */ - q1_Q10 = offset_Q10; - q2_Q10 = offset_Q10 + ( 1024 - QUANT_LEVEL_ADJUST_Q10 ); - rd1_Q20 = q1_Q10 * Lambda_Q10; - rd2_Q20 = q2_Q10 * Lambda_Q10; - - table[ 32 ][ 0 ] = q1_Q10; - table[ 32 ][ 1 ] = q2_Q10; - table[ 32 ][ 2 ] = 2 * (q1_Q10 - q2_Q10); - table[ 32 ][ 3 ] = (rd1_Q20 - rd2_Q20) + (q1_Q10 * q1_Q10 - q2_Q10 * q2_Q10); - - /* -1 */ - q1_Q10 = offset_Q10 - ( 1024 - QUANT_LEVEL_ADJUST_Q10 ); - q2_Q10 = offset_Q10; - rd1_Q20 = - q1_Q10 * Lambda_Q10; - rd2_Q20 = q2_Q10 * Lambda_Q10; - - table[ 31 ][ 0 ] = q1_Q10; - table[ 31 ][ 1 ] = q2_Q10; - table[ 31 ][ 2 ] = 2 * (q1_Q10 - q2_Q10); - table[ 31 ][ 3 ] = (rd1_Q20 - rd2_Q20) + (q1_Q10 * q1_Q10 - q2_Q10 * q2_Q10); - - /* > 0 */ - for (k = 1; k <= 31; k++) - { - tmp1 = offset_Q10 + silk_LSHIFT( k, 10 ); - - q1_Q10 = tmp1 - QUANT_LEVEL_ADJUST_Q10; - q2_Q10 = tmp1 - QUANT_LEVEL_ADJUST_Q10 + 1024; - rd1_Q20 = q1_Q10 * Lambda_Q10; - rd2_Q20 = q2_Q10 * Lambda_Q10; - - table[ 32 + k ][ 0 ] = q1_Q10; - table[ 32 + k ][ 1 ] = q2_Q10; - table[ 32 + k ][ 2 ] = 2 * (q1_Q10 - q2_Q10); - table[ 32 + k ][ 3 ] = (rd1_Q20 - rd2_Q20) + (q1_Q10 * q1_Q10 - q2_Q10 * q2_Q10); - } - - /* < -1 */ - for (k = -32; k <= -2; k++) - { - tmp1 = offset_Q10 + silk_LSHIFT( k, 10 ); - - q1_Q10 = tmp1 + QUANT_LEVEL_ADJUST_Q10; - q2_Q10 = tmp1 + QUANT_LEVEL_ADJUST_Q10 + 1024; - rd1_Q20 = - q1_Q10 * Lambda_Q10; - rd2_Q20 = - q2_Q10 * Lambda_Q10; - - table[ 32 + k ][ 0 ] = q1_Q10; - table[ 32 + k ][ 1 ] = q2_Q10; - table[ 32 + k ][ 2 ] = 2 * (q1_Q10 - q2_Q10); - table[ 32 + k ][ 3 ] = (rd1_Q20 - rd2_Q20) + (q1_Q10 * q1_Q10 - q2_Q10 * q2_Q10); - } - - if( psIndices->NLSFInterpCoef_Q2 == 4 ) { - LSF_interpolation_flag = 0; - } else { - LSF_interpolation_flag = 1; - } - - ALLOC( sLTP_Q15, psEncC->ltp_mem_length + psEncC->frame_length, opus_int32 ); - ALLOC( sLTP, psEncC->ltp_mem_length + psEncC->frame_length, opus_int16 ); - ALLOC( x_sc_Q10, psEncC->subfr_length, opus_int32 ); - /* Set up pointers to start of sub frame */ - NSQ->sLTP_shp_buf_idx = psEncC->ltp_mem_length; - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - pxq = &NSQ->xq[ psEncC->ltp_mem_length ]; - for( k = 0; k < psEncC->nb_subfr; k++ ) { - A_Q12 = &PredCoef_Q12[ (( k >> 1 ) | ( 1 - LSF_interpolation_flag )) * MAX_LPC_ORDER ]; - B_Q14 = <PCoef_Q14[ k * LTP_ORDER ]; - AR_shp_Q13 = &AR_Q13[ k * MAX_SHAPE_LPC_ORDER ]; - - /* Noise shape parameters */ - silk_assert( HarmShapeGain_Q14[ k ] >= 0 ); - HarmShapeFIRPacked_Q14 = silk_RSHIFT( HarmShapeGain_Q14[ k ], 2 ); - HarmShapeFIRPacked_Q14 |= silk_LSHIFT( (opus_int32)silk_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 ); - - NSQ->rewhite_flag = 0; - if( psIndices->signalType == TYPE_VOICED ) { - /* Voiced */ - lag = pitchL[ k ]; - - /* Re-whitening */ - if( ( k & ( 3 - silk_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) { - /* Rewhiten with new A coefs */ - start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2; - celt_assert( start_idx > 0 ); - - silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], - A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder, psEncC->arch ); - - NSQ->rewhite_flag = 1; - NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; - } - } - - silk_nsq_scale_states_sse4_1( psEncC, NSQ, x16, x_sc_Q10, sLTP, sLTP_Q15, k, LTP_scale_Q14, Gains_Q16, pitchL, psIndices->signalType ); - - if ( opus_likely( ( 10 == psEncC->shapingLPCOrder ) && ( 16 == psEncC->predictLPCOrder) ) ) - { - silk_noise_shape_quantizer_10_16_sse4_1( NSQ, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q15, A_Q12, B_Q14, - AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10, - offset_Q10, psEncC->subfr_length, &(table[32]) ); - } - else - { - silk_noise_shape_quantizer( NSQ, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q15, A_Q12, B_Q14, - AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10, - offset_Q10, psEncC->subfr_length, psEncC->shapingLPCOrder, psEncC->predictLPCOrder, psEncC->arch ); - } - - x16 += psEncC->subfr_length; - pulses += psEncC->subfr_length; - pxq += psEncC->subfr_length; - } - - /* Update lagPrev for next frame */ - NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ]; - - /* Save quantized speech and noise shaping signals */ - silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int16 ) ); - silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ], psEncC->ltp_mem_length * sizeof( opus_int32 ) ); - -#ifdef OPUS_CHECK_ASM - silk_assert( !memcmp( &NSQ_c, NSQ, sizeof( NSQ_c ) ) ); - silk_assert( !memcmp( &psIndices_c, psIndices, sizeof( psIndices_c ) ) ); - silk_assert( !memcmp( pulses_c, pulses_a, psEncC->nb_subfr * psEncC->subfr_length * sizeof( pulses[0] ) ) ); -#endif - - RESTORE_STACK; -} - -/************************************/ -/* silk_noise_shape_quantizer_10_16 */ -/************************************/ -static OPUS_INLINE void silk_noise_shape_quantizer_10_16_sse4_1( - silk_nsq_state *NSQ, /* I/O NSQ state */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_sc_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP state */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int32 table[][4] /* I */ -) -{ - opus_int i; - opus_int32 LTP_pred_Q13, LPC_pred_Q10, n_AR_Q12, n_LTP_Q13; - opus_int32 n_LF_Q12, r_Q10, q1_Q0, q1_Q10, q2_Q10; - opus_int32 exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10, sDiff_shp_Q14; - opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; - opus_int32 *psLPC_Q14, *shp_lag_ptr, *pred_lag_ptr; - - __m128i xmm_tempa, xmm_tempb; - - __m128i xmm_one; - - __m128i psLPC_Q14_hi_01234567, psLPC_Q14_hi_89ABCDEF; - __m128i psLPC_Q14_lo_01234567, psLPC_Q14_lo_89ABCDEF; - __m128i a_Q12_01234567, a_Q12_89ABCDEF; - - __m128i sAR2_Q14_hi_76543210, sAR2_Q14_lo_76543210; - __m128i AR_shp_Q13_76543210; - - int rdo_offset = (Lambda_Q10 >> 1) - 512; - - shp_lag_ptr = &NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ]; - pred_lag_ptr = &sLTP_Q15[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ]; - Gain_Q10 = silk_RSHIFT( Gain_Q16, 6 ); - - /* Set up short term AR state */ - psLPC_Q14 = &NSQ->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 ]; - - sLF_AR_shp_Q14 = NSQ->sLF_AR_shp_Q14; - xq_Q14 = psLPC_Q14[ 0 ]; - sDiff_shp_Q14 = NSQ->sDiff_shp_Q14; - LTP_pred_Q13 = 0; - - /* load a_Q12 */ - xmm_one = _mm_set_epi8( 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 ); - - /* load a_Q12[0] - a_Q12[7] */ - a_Q12_01234567 = _mm_loadu_si128( (__m128i *)(&a_Q12[ 0 ] ) ); - /* load a_Q12[ 8 ] - a_Q12[ 15 ] */ - a_Q12_89ABCDEF = _mm_loadu_si128( (__m128i *)(&a_Q12[ 8 ] ) ); - - a_Q12_01234567 = _mm_shuffle_epi8( a_Q12_01234567, xmm_one ); - a_Q12_89ABCDEF = _mm_shuffle_epi8( a_Q12_89ABCDEF, xmm_one ); - - /* load AR_shp_Q13 */ - AR_shp_Q13_76543210 = _mm_loadu_si128( (__m128i *)(&AR_shp_Q13[0] ) ); - - /* load psLPC_Q14 */ - xmm_one = _mm_set_epi8(15, 14, 11, 10, 7, 6, 3, 2, 13, 12, 9, 8, 5, 4, 1, 0 ); - - xmm_tempa = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[-16]) ); - xmm_tempb = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[-12]) ); - - xmm_tempa = _mm_shuffle_epi8( xmm_tempa, xmm_one ); - xmm_tempb = _mm_shuffle_epi8( xmm_tempb, xmm_one ); - - psLPC_Q14_hi_89ABCDEF = _mm_unpackhi_epi64( xmm_tempa, xmm_tempb ); - psLPC_Q14_lo_89ABCDEF = _mm_unpacklo_epi64( xmm_tempa, xmm_tempb ); - - xmm_tempa = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -8 ]) ); - xmm_tempb = _mm_loadu_si128( (__m128i *)(&psLPC_Q14[ -4 ]) ); - - xmm_tempa = _mm_shuffle_epi8( xmm_tempa, xmm_one ); - xmm_tempb = _mm_shuffle_epi8( xmm_tempb, xmm_one ); - - psLPC_Q14_hi_01234567 = _mm_unpackhi_epi64( xmm_tempa, xmm_tempb ); - psLPC_Q14_lo_01234567 = _mm_unpacklo_epi64( xmm_tempa, xmm_tempb ); - - /* load sAR2_Q14 */ - xmm_tempa = _mm_loadu_si128( (__m128i *)(&(NSQ->sAR2_Q14[ 0 ]) ) ); - xmm_tempb = _mm_loadu_si128( (__m128i *)(&(NSQ->sAR2_Q14[ 4 ]) ) ); - - xmm_tempa = _mm_shuffle_epi8( xmm_tempa, xmm_one ); - xmm_tempb = _mm_shuffle_epi8( xmm_tempb, xmm_one ); - - sAR2_Q14_hi_76543210 = _mm_unpackhi_epi64( xmm_tempa, xmm_tempb ); - sAR2_Q14_lo_76543210 = _mm_unpacklo_epi64( xmm_tempa, xmm_tempb ); - - /* prepare 1 in 8 * 16bit */ - xmm_one = _mm_set1_epi16(1); - - for( i = 0; i < length; i++ ) - { - /* Short-term prediction */ - __m128i xmm_hi_07, xmm_hi_8F, xmm_lo_07, xmm_lo_8F; - - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LPC_pred_Q10 = 8; /* silk_RSHIFT( predictLPCOrder, 1 ); */ - - /* shift psLPC_Q14 */ - psLPC_Q14_hi_89ABCDEF = _mm_alignr_epi8( psLPC_Q14_hi_01234567, psLPC_Q14_hi_89ABCDEF, 2 ); - psLPC_Q14_lo_89ABCDEF = _mm_alignr_epi8( psLPC_Q14_lo_01234567, psLPC_Q14_lo_89ABCDEF, 2 ); - - psLPC_Q14_hi_01234567 = _mm_srli_si128( psLPC_Q14_hi_01234567, 2 ); - psLPC_Q14_lo_01234567 = _mm_srli_si128( psLPC_Q14_lo_01234567, 2 ); - - psLPC_Q14_hi_01234567 = _mm_insert_epi16( psLPC_Q14_hi_01234567, (xq_Q14 >> 16), 7 ); - psLPC_Q14_lo_01234567 = _mm_insert_epi16( psLPC_Q14_lo_01234567, (xq_Q14), 7 ); - - /* high part, use pmaddwd, results in 4 32-bit */ - xmm_hi_07 = _mm_madd_epi16( psLPC_Q14_hi_01234567, a_Q12_01234567 ); - xmm_hi_8F = _mm_madd_epi16( psLPC_Q14_hi_89ABCDEF, a_Q12_89ABCDEF ); - - /* low part, use pmulhw, results in 8 16-bit, note we need simulate unsigned * signed, _mm_srai_epi16(psLPC_Q14_lo_01234567, 15) */ - xmm_tempa = _mm_cmpgt_epi16( _mm_setzero_si128(), psLPC_Q14_lo_01234567 ); - xmm_tempb = _mm_cmpgt_epi16( _mm_setzero_si128(), psLPC_Q14_lo_89ABCDEF ); - - xmm_tempa = _mm_and_si128( xmm_tempa, a_Q12_01234567 ); - xmm_tempb = _mm_and_si128( xmm_tempb, a_Q12_89ABCDEF ); - - xmm_lo_07 = _mm_mulhi_epi16( psLPC_Q14_lo_01234567, a_Q12_01234567 ); - xmm_lo_8F = _mm_mulhi_epi16( psLPC_Q14_lo_89ABCDEF, a_Q12_89ABCDEF ); - - xmm_lo_07 = _mm_add_epi16( xmm_lo_07, xmm_tempa ); - xmm_lo_8F = _mm_add_epi16( xmm_lo_8F, xmm_tempb ); - - xmm_lo_07 = _mm_madd_epi16( xmm_lo_07, xmm_one ); - xmm_lo_8F = _mm_madd_epi16( xmm_lo_8F, xmm_one ); - - /* accumulate */ - xmm_hi_07 = _mm_add_epi32( xmm_hi_07, xmm_hi_8F ); - xmm_lo_07 = _mm_add_epi32( xmm_lo_07, xmm_lo_8F ); - - xmm_hi_07 = _mm_add_epi32( xmm_hi_07, xmm_lo_07 ); - - xmm_hi_07 = _mm_add_epi32( xmm_hi_07, _mm_unpackhi_epi64(xmm_hi_07, xmm_hi_07 ) ); - xmm_hi_07 = _mm_add_epi32( xmm_hi_07, _mm_shufflelo_epi16(xmm_hi_07, 0x0E ) ); - - LPC_pred_Q10 += _mm_cvtsi128_si32( xmm_hi_07 ); - - /* Long-term prediction */ - if ( opus_likely( signalType == TYPE_VOICED ) ) { - /* Unrolled loop */ - /* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */ - LTP_pred_Q13 = 2; - { - __m128i b_Q14_3210, b_Q14_0123, pred_lag_ptr_0123; - - b_Q14_3210 = OP_CVTEPI16_EPI32_M64( b_Q14 ); - b_Q14_0123 = _mm_shuffle_epi32( b_Q14_3210, 0x1B ); - - /* loaded: [0] [-1] [-2] [-3] */ - pred_lag_ptr_0123 = _mm_loadu_si128( (__m128i *)(&pred_lag_ptr[ -3 ] ) ); - /* shuffle to [-3] [-2] [-1] [0] and to new xmm */ - xmm_tempa = _mm_shuffle_epi32( pred_lag_ptr_0123, 0x1B ); - /*64-bit multiply, a[2] * b[-2], a[0] * b[0] */ - xmm_tempa = _mm_mul_epi32( xmm_tempa, b_Q14_3210 ); - /* right shift 2 bytes (16 bits), zero extended */ - xmm_tempa = _mm_srli_si128( xmm_tempa, 2 ); - - /* a[1] * b[-1], a[3] * b[-3] */ - pred_lag_ptr_0123 = _mm_mul_epi32( pred_lag_ptr_0123, b_Q14_0123 ); - pred_lag_ptr_0123 = _mm_srli_si128( pred_lag_ptr_0123, 2 ); - - pred_lag_ptr_0123 = _mm_add_epi32( pred_lag_ptr_0123, xmm_tempa ); - /* equal shift right 8 bytes*/ - xmm_tempa = _mm_shuffle_epi32( pred_lag_ptr_0123, _MM_SHUFFLE( 0, 0, 3, 2 ) ); - xmm_tempa = _mm_add_epi32( xmm_tempa, pred_lag_ptr_0123 ); - - LTP_pred_Q13 += _mm_cvtsi128_si32( xmm_tempa ); - - LTP_pred_Q13 = silk_SMLAWB( LTP_pred_Q13, pred_lag_ptr[ -4 ], b_Q14[ 4 ] ); - pred_lag_ptr++; - } - } - - /* Noise shape feedback */ - NSQ->sAR2_Q14[ 9 ] = NSQ->sAR2_Q14[ 8 ]; - NSQ->sAR2_Q14[ 8 ] = _mm_cvtsi128_si32( _mm_srli_si128(_mm_unpackhi_epi16( sAR2_Q14_lo_76543210, sAR2_Q14_hi_76543210 ), 12 ) ); - - sAR2_Q14_hi_76543210 = _mm_slli_si128( sAR2_Q14_hi_76543210, 2 ); - sAR2_Q14_lo_76543210 = _mm_slli_si128( sAR2_Q14_lo_76543210, 2 ); - - sAR2_Q14_hi_76543210 = _mm_insert_epi16( sAR2_Q14_hi_76543210, (sDiff_shp_Q14 >> 16), 0 ); - sAR2_Q14_lo_76543210 = _mm_insert_epi16( sAR2_Q14_lo_76543210, (sDiff_shp_Q14), 0 ); - - /* high part, use pmaddwd, results in 4 32-bit */ - xmm_hi_07 = _mm_madd_epi16( sAR2_Q14_hi_76543210, AR_shp_Q13_76543210 ); - - /* low part, use pmulhw, results in 8 16-bit, note we need simulate unsigned * signed,_mm_srai_epi16(sAR2_Q14_lo_76543210, 15) */ - xmm_tempa = _mm_cmpgt_epi16( _mm_setzero_si128(), sAR2_Q14_lo_76543210 ); - xmm_tempa = _mm_and_si128( xmm_tempa, AR_shp_Q13_76543210 ); - - xmm_lo_07 = _mm_mulhi_epi16( sAR2_Q14_lo_76543210, AR_shp_Q13_76543210 ); - xmm_lo_07 = _mm_add_epi16( xmm_lo_07, xmm_tempa ); - - xmm_lo_07 = _mm_madd_epi16( xmm_lo_07, xmm_one ); - - /* accumulate */ - xmm_hi_07 = _mm_add_epi32( xmm_hi_07, xmm_lo_07 ); - - xmm_hi_07 = _mm_add_epi32( xmm_hi_07, _mm_unpackhi_epi64(xmm_hi_07, xmm_hi_07 ) ); - xmm_hi_07 = _mm_add_epi32( xmm_hi_07, _mm_shufflelo_epi16(xmm_hi_07, 0x0E ) ); - - n_AR_Q12 = 5 + _mm_cvtsi128_si32( xmm_hi_07 ); - - n_AR_Q12 = silk_SMLAWB( n_AR_Q12, NSQ->sAR2_Q14[ 8 ], AR_shp_Q13[ 8 ] ); - n_AR_Q12 = silk_SMLAWB( n_AR_Q12, NSQ->sAR2_Q14[ 9 ], AR_shp_Q13[ 9 ] ); - - n_AR_Q12 = silk_LSHIFT32( n_AR_Q12, 1 ); /* Q11 -> Q12 */ - n_AR_Q12 = silk_SMLAWB( n_AR_Q12, sLF_AR_shp_Q14, Tilt_Q14 ); - - n_LF_Q12 = silk_SMULWB( NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - 1 ], LF_shp_Q14 ); - n_LF_Q12 = silk_SMLAWT( n_LF_Q12, sLF_AR_shp_Q14, LF_shp_Q14 ); - - celt_assert( lag > 0 || signalType != TYPE_VOICED ); - - /* Combine prediction and noise shaping signals */ - tmp1 = silk_SUB32( silk_LSHIFT32( LPC_pred_Q10, 2 ), n_AR_Q12 ); /* Q12 */ - tmp1 = silk_SUB32( tmp1, n_LF_Q12 ); /* Q12 */ - if( lag > 0 ) { - /* Symmetric, packed FIR coefficients */ - n_LTP_Q13 = silk_SMULWB( silk_ADD_SAT32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 ); - n_LTP_Q13 = silk_SMLAWT( n_LTP_Q13, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 ); - n_LTP_Q13 = silk_LSHIFT( n_LTP_Q13, 1 ); - shp_lag_ptr++; - - tmp2 = silk_SUB32( LTP_pred_Q13, n_LTP_Q13 ); /* Q13 */ - tmp1 = silk_ADD_LSHIFT32( tmp2, tmp1, 1 ); /* Q13 */ - tmp1 = silk_RSHIFT_ROUND( tmp1, 3 ); /* Q10 */ - } else { - tmp1 = silk_RSHIFT_ROUND( tmp1, 2 ); /* Q10 */ - } - - r_Q10 = silk_SUB32( x_sc_Q10[ i ], tmp1 ); /* residual error Q10 */ - - /* Generate dither */ - NSQ->rand_seed = silk_RAND( NSQ->rand_seed ); - - /* Flip sign depending on dither */ - tmp2 = -r_Q10; - if ( NSQ->rand_seed < 0 ) r_Q10 = tmp2; - - r_Q10 = silk_LIMIT_32( r_Q10, -(31 << 10), 30 << 10 ); - - /* Find two quantization level candidates and measure their rate-distortion */ - q1_Q10 = silk_SUB32( r_Q10, offset_Q10 ); - q1_Q0 = silk_RSHIFT( q1_Q10, 10 ); - if (Lambda_Q10 > 2048) { - /* For aggressive RDO, the bias becomes more than one pulse. */ - if (q1_Q10 > rdo_offset) { - q1_Q0 = silk_RSHIFT( q1_Q10 - rdo_offset, 10 ); - } else if (q1_Q10 < -rdo_offset) { - q1_Q0 = silk_RSHIFT( q1_Q10 + rdo_offset, 10 ); - } else if (q1_Q10 < 0) { - q1_Q0 = -1; - } else { - q1_Q0 = 0; - } - } - - q1_Q10 = table[q1_Q0][0]; - q2_Q10 = table[q1_Q0][1]; - - if (r_Q10 * table[q1_Q0][2] - table[q1_Q0][3] < 0) - { - q1_Q10 = q2_Q10; - } - - pulses[ i ] = (opus_int8)silk_RSHIFT_ROUND( q1_Q10, 10 ); - - /* Excitation */ - exc_Q14 = silk_LSHIFT( q1_Q10, 4 ); - - tmp2 = -exc_Q14; - if ( NSQ->rand_seed < 0 ) exc_Q14 = tmp2; - - /* Add predictions */ - LPC_exc_Q14 = silk_ADD_LSHIFT32( exc_Q14, LTP_pred_Q13, 1 ); - xq_Q14 = silk_ADD_LSHIFT32( LPC_exc_Q14, LPC_pred_Q10, 4 ); - - /* Update states */ - psLPC_Q14++; - *psLPC_Q14 = xq_Q14; - NSQ->sDiff_shp_Q14 = silk_SUB_LSHIFT32( xq_Q14, x_sc_Q10[ i ], 4 ); - sLF_AR_shp_Q14 = silk_SUB_LSHIFT32( NSQ->sDiff_shp_Q14, n_AR_Q12, 2 ); - - NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx ] = silk_SUB_LSHIFT32( sLF_AR_shp_Q14, n_LF_Q12, 2 ); - sLTP_Q15[ NSQ->sLTP_buf_idx ] = silk_LSHIFT( LPC_exc_Q14, 1 ); - NSQ->sLTP_shp_buf_idx++; - NSQ->sLTP_buf_idx++; - - /* Make dither dependent on quantized signal */ - NSQ->rand_seed = silk_ADD32_ovflw( NSQ->rand_seed, pulses[ i ] ); - } - - NSQ->sLF_AR_shp_Q14 = sLF_AR_shp_Q14; - - /* Scale XQ back to normal level before saving */ - psLPC_Q14 = &NSQ->sLPC_Q14[ NSQ_LPC_BUF_LENGTH ]; - - /* write back sAR2_Q14 */ - xmm_tempa = _mm_unpackhi_epi16( sAR2_Q14_lo_76543210, sAR2_Q14_hi_76543210 ); - xmm_tempb = _mm_unpacklo_epi16( sAR2_Q14_lo_76543210, sAR2_Q14_hi_76543210 ); - _mm_storeu_si128( (__m128i *)(&NSQ->sAR2_Q14[ 4 ]), xmm_tempa ); - _mm_storeu_si128( (__m128i *)(&NSQ->sAR2_Q14[ 0 ]), xmm_tempb ); - - /* xq[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( psLPC_Q14[ i ], Gain_Q10 ), 8 ) ); */ - { - __m128i xmm_Gain_Q10; - __m128i xmm_xq_Q14_3210, xmm_xq_Q14_x3x1, xmm_xq_Q14_7654, xmm_xq_Q14_x7x5; - - /* prepare (1 << 7) in packed 4 32-bits */ - xmm_tempa = _mm_set1_epi32( (1 << 7) ); - - /* prepare Gain_Q10 in packed 4 32-bits */ - xmm_Gain_Q10 = _mm_set1_epi32( Gain_Q10 ); - - /* process xq */ - for (i = 0; i < length - 7; i += 8) - { - xmm_xq_Q14_3210 = _mm_loadu_si128( (__m128i *)(&(psLPC_Q14[ i + 0 ] ) ) ); - xmm_xq_Q14_7654 = _mm_loadu_si128( (__m128i *)(&(psLPC_Q14[ i + 4 ] ) ) ); - - /* equal shift right 4 bytes*/ - xmm_xq_Q14_x3x1 = _mm_shuffle_epi32( xmm_xq_Q14_3210, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - /* equal shift right 4 bytes*/ - xmm_xq_Q14_x7x5 = _mm_shuffle_epi32( xmm_xq_Q14_7654, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - - xmm_xq_Q14_3210 = _mm_mul_epi32( xmm_xq_Q14_3210, xmm_Gain_Q10 ); - xmm_xq_Q14_x3x1 = _mm_mul_epi32( xmm_xq_Q14_x3x1, xmm_Gain_Q10 ); - xmm_xq_Q14_7654 = _mm_mul_epi32( xmm_xq_Q14_7654, xmm_Gain_Q10 ); - xmm_xq_Q14_x7x5 = _mm_mul_epi32( xmm_xq_Q14_x7x5, xmm_Gain_Q10 ); - - xmm_xq_Q14_3210 = _mm_srli_epi64( xmm_xq_Q14_3210, 16 ); - xmm_xq_Q14_x3x1 = _mm_slli_epi64( xmm_xq_Q14_x3x1, 16 ); - xmm_xq_Q14_7654 = _mm_srli_epi64( xmm_xq_Q14_7654, 16 ); - xmm_xq_Q14_x7x5 = _mm_slli_epi64( xmm_xq_Q14_x7x5, 16 ); - - xmm_xq_Q14_3210 = _mm_blend_epi16( xmm_xq_Q14_3210, xmm_xq_Q14_x3x1, 0xCC ); - xmm_xq_Q14_7654 = _mm_blend_epi16( xmm_xq_Q14_7654, xmm_xq_Q14_x7x5, 0xCC ); - - /* silk_RSHIFT_ROUND(xq, 8) */ - xmm_xq_Q14_3210 = _mm_add_epi32( xmm_xq_Q14_3210, xmm_tempa ); - xmm_xq_Q14_7654 = _mm_add_epi32( xmm_xq_Q14_7654, xmm_tempa ); - - xmm_xq_Q14_3210 = _mm_srai_epi32( xmm_xq_Q14_3210, 8 ); - xmm_xq_Q14_7654 = _mm_srai_epi32( xmm_xq_Q14_7654, 8 ); - - /* silk_SAT16 */ - xmm_xq_Q14_3210 = _mm_packs_epi32( xmm_xq_Q14_3210, xmm_xq_Q14_7654 ); - - /* save to xq */ - _mm_storeu_si128( (__m128i *)(&xq[ i ] ), xmm_xq_Q14_3210 ); - } - } - for ( ; i < length; i++) - { - xq[i] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( silk_SMULWW( psLPC_Q14[ i ], Gain_Q10 ), 8 ) ); - } - - /* Update LPC synth buffer */ - silk_memcpy( NSQ->sLPC_Q14, &NSQ->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( opus_int32 ) ); -} - -static OPUS_INLINE void silk_nsq_scale_states_sse4_1( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - const opus_int16 x16[], /* I input */ - opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ - const opus_int16 sLTP[], /* I re-whitened LTP state in Q0 */ - opus_int32 sLTP_Q15[], /* O LTP state matching scaled input */ - opus_int subfr, /* I subframe number */ - const opus_int LTP_scale_Q14, /* I */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag */ - const opus_int signal_type /* I Signal type */ -) -{ - opus_int i, lag; - opus_int32 gain_adj_Q16, inv_gain_Q31, inv_gain_Q26; - __m128i xmm_inv_gain_Q26, xmm_x16_x2x0, xmm_x16_x3x1; - - lag = pitchL[ subfr ]; - inv_gain_Q31 = silk_INVERSE32_varQ( silk_max( Gains_Q16[ subfr ], 1 ), 47 ); - silk_assert( inv_gain_Q31 != 0 ); - - /* Scale input */ - inv_gain_Q26 = silk_RSHIFT_ROUND( inv_gain_Q31, 5 ); - - /* prepare inv_gain_Q26 in packed 4 32-bits */ - xmm_inv_gain_Q26 = _mm_set1_epi32(inv_gain_Q26); - - for( i = 0; i < psEncC->subfr_length - 3; i += 4 ) { - xmm_x16_x2x0 = OP_CVTEPI16_EPI32_M64( &(x16[ i ] ) ); - - /* equal shift right 4 bytes*/ - xmm_x16_x3x1 = _mm_shuffle_epi32( xmm_x16_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - - xmm_x16_x2x0 = _mm_mul_epi32( xmm_x16_x2x0, xmm_inv_gain_Q26 ); - xmm_x16_x3x1 = _mm_mul_epi32( xmm_x16_x3x1, xmm_inv_gain_Q26 ); - - xmm_x16_x2x0 = _mm_srli_epi64( xmm_x16_x2x0, 16 ); - xmm_x16_x3x1 = _mm_slli_epi64( xmm_x16_x3x1, 16 ); - - xmm_x16_x2x0 = _mm_blend_epi16( xmm_x16_x2x0, xmm_x16_x3x1, 0xCC ); - - _mm_storeu_si128( (__m128i *)(&(x_sc_Q10[ i ] ) ), xmm_x16_x2x0 ); - } - - for( ; i < psEncC->subfr_length; i++ ) { - x_sc_Q10[ i ] = silk_SMULWW( x16[ i ], inv_gain_Q26 ); - } - - /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */ - if( NSQ->rewhite_flag ) { - if( subfr == 0 ) { - /* Do LTP downscaling */ - inv_gain_Q31 = silk_LSHIFT( silk_SMULWB( inv_gain_Q31, LTP_scale_Q14 ), 2 ); - } - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) { - silk_assert( i < MAX_FRAME_LENGTH ); - sLTP_Q15[ i ] = silk_SMULWB( inv_gain_Q31, sLTP[ i ] ); - } - } - - /* Adjust for changing gain */ - if( Gains_Q16[ subfr ] != NSQ->prev_gain_Q16 ) { - __m128i xmm_gain_adj_Q16, xmm_sLTP_shp_Q14_x2x0, xmm_sLTP_shp_Q14_x3x1; - gain_adj_Q16 = silk_DIV32_varQ( NSQ->prev_gain_Q16, Gains_Q16[ subfr ], 16 ); - - /* Scale long-term shaping state */ - - /* prepare gain_adj_Q16 in packed 4 32-bits */ - xmm_gain_adj_Q16 = _mm_set1_epi32(gain_adj_Q16); - - for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx - 3; i += 4 ) - { - xmm_sLTP_shp_Q14_x2x0 = _mm_loadu_si128( (__m128i *)(&(NSQ->sLTP_shp_Q14[ i ] ) ) ); - /* equal shift right 4 bytes*/ - xmm_sLTP_shp_Q14_x3x1 = _mm_shuffle_epi32( xmm_sLTP_shp_Q14_x2x0, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - - xmm_sLTP_shp_Q14_x2x0 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x2x0, xmm_gain_adj_Q16 ); - xmm_sLTP_shp_Q14_x3x1 = _mm_mul_epi32( xmm_sLTP_shp_Q14_x3x1, xmm_gain_adj_Q16 ); - - xmm_sLTP_shp_Q14_x2x0 = _mm_srli_epi64( xmm_sLTP_shp_Q14_x2x0, 16 ); - xmm_sLTP_shp_Q14_x3x1 = _mm_slli_epi64( xmm_sLTP_shp_Q14_x3x1, 16 ); - - xmm_sLTP_shp_Q14_x2x0 = _mm_blend_epi16( xmm_sLTP_shp_Q14_x2x0, xmm_sLTP_shp_Q14_x3x1, 0xCC ); - - _mm_storeu_si128( (__m128i *)(&(NSQ->sLTP_shp_Q14[ i ] ) ), xmm_sLTP_shp_Q14_x2x0 ); - } - - for( ; i < NSQ->sLTP_shp_buf_idx; i++ ) { - NSQ->sLTP_shp_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q14[ i ] ); - } - - /* Scale long-term prediction state */ - if( signal_type == TYPE_VOICED && NSQ->rewhite_flag == 0 ) { - for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) { - sLTP_Q15[ i ] = silk_SMULWW( gain_adj_Q16, sLTP_Q15[ i ] ); - } - } - - NSQ->sLF_AR_shp_Q14 = silk_SMULWW( gain_adj_Q16, NSQ->sLF_AR_shp_Q14 ); - NSQ->sDiff_shp_Q14 = silk_SMULWW( gain_adj_Q16, NSQ->sDiff_shp_Q14 ); - - /* Scale short-term prediction and shaping states */ - for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { - NSQ->sLPC_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLPC_Q14[ i ] ); - } - for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { - NSQ->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sAR2_Q14[ i ] ); - } - - /* Save inverse gain */ - NSQ->prev_gain_Q16 = Gains_Q16[ subfr ]; - } -} diff --git a/Engine/lib/opus/silk/x86/SigProc_FIX_sse.h b/Engine/lib/opus/silk/x86/SigProc_FIX_sse.h deleted file mode 100644 index 89a5ec888..000000000 --- a/Engine/lib/opus/silk/x86/SigProc_FIX_sse.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (c) 2014, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef SIGPROC_FIX_SSE_H -# define SIGPROC_FIX_SSE_H - -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - -# if defined(OPUS_X86_MAY_HAVE_SSE4_1) -void silk_burg_modified_sse4_1( - opus_int32 *res_nrg, /* O Residual energy */ - opus_int *res_nrg_Q, /* O Residual energy Q value */ - opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ - const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ - const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ - const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ - const opus_int nb_subfr, /* I Number of subframes stacked in x */ - const opus_int D, /* I Order */ - int arch /* I Run-time architecture */ -); - -# if defined(OPUS_X86_PRESUME_SSE4_1) - -# define OVERRIDE_silk_burg_modified -# define silk_burg_modified(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch) \ - ((void)(arch), silk_burg_modified_sse4_1(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch)) - -# elif defined(OPUS_HAVE_RTCD) - -extern void (*const SILK_BURG_MODIFIED_IMPL[OPUS_ARCHMASK + 1])( - opus_int32 *res_nrg, /* O Residual energy */ - opus_int *res_nrg_Q, /* O Residual energy Q value */ - opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ - const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ - const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ - const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ - const opus_int nb_subfr, /* I Number of subframes stacked in x */ - const opus_int D, /* I Order */ - int arch /* I Run-time architecture */); - -# define OVERRIDE_silk_burg_modified -# define silk_burg_modified(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch) \ - ((*SILK_BURG_MODIFIED_IMPL[(arch) & OPUS_ARCHMASK])(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch)) - -# endif - -opus_int64 silk_inner_prod16_sse4_1( - const opus_int16 *inVec1, - const opus_int16 *inVec2, - const opus_int len -); - - -# if defined(OPUS_X86_PRESUME_SSE4_1) - -# define OVERRIDE_silk_inner_prod16 -# define silk_inner_prod16(inVec1, inVec2, len, arch) \ - ((void)(arch),silk_inner_prod16_sse4_1(inVec1, inVec2, len)) - -# elif defined(OPUS_HAVE_RTCD) - -extern opus_int64 (*const SILK_INNER_PROD16_IMPL[OPUS_ARCHMASK + 1])( - const opus_int16 *inVec1, - const opus_int16 *inVec2, - const opus_int len); - -# define OVERRIDE_silk_inner_prod16 -# define silk_inner_prod16(inVec1, inVec2, len, arch) \ - ((*SILK_INNER_PROD16_IMPL[(arch) & OPUS_ARCHMASK])(inVec1, inVec2, len)) - -# endif -# endif -#endif diff --git a/Engine/lib/opus/silk/x86/VAD_sse4_1.c b/Engine/lib/opus/silk/x86/VAD_sse4_1.c deleted file mode 100644 index e7eaf9714..000000000 --- a/Engine/lib/opus/silk/x86/VAD_sse4_1.c +++ /dev/null @@ -1,289 +0,0 @@ -/* Copyright (c) 2014-2020, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang FrancisQuiers - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - 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 -#include -#include - -#include "main.h" -#include "stack_alloc.h" - -/* Weighting factors for tilt measure */ -static const opus_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -12000 }; - -/***************************************/ -/* Get the speech activity level in Q8 */ -/***************************************/ -opus_int silk_VAD_GetSA_Q8_sse4_1( /* O Return value, 0 if success */ - silk_encoder_state *psEncC, /* I/O Encoder state */ - const opus_int16 pIn[] /* I PCM input */ -) -{ - opus_int SA_Q15, pSNR_dB_Q7, input_tilt; - opus_int decimated_framelength1, decimated_framelength2; - opus_int decimated_framelength; - opus_int dec_subframe_length, dec_subframe_offset, SNR_Q7, i, b, s; - opus_int32 sumSquared, smooth_coef_Q16; - opus_int16 HPstateTmp; - VARDECL( opus_int16, X ); - opus_int32 Xnrg[ VAD_N_BANDS ]; - opus_int32 NrgToNoiseRatio_Q8[ VAD_N_BANDS ]; - opus_int32 speech_nrg, x_tmp; - opus_int X_offset[ VAD_N_BANDS ]; - opus_int ret = 0; - silk_VAD_state *psSilk_VAD = &psEncC->sVAD; - - SAVE_STACK; - -#ifdef OPUS_CHECK_ASM - silk_encoder_state psEncC_c; - opus_int ret_c; - - silk_memcpy( &psEncC_c, psEncC, sizeof( psEncC_c ) ); - ret_c = silk_VAD_GetSA_Q8_c( &psEncC_c, pIn ); -#endif - - /* Safety checks */ - silk_assert( VAD_N_BANDS == 4 ); - celt_assert( MAX_FRAME_LENGTH >= psEncC->frame_length ); - celt_assert( psEncC->frame_length <= 512 ); - celt_assert( psEncC->frame_length == 8 * silk_RSHIFT( psEncC->frame_length, 3 ) ); - - /***********************/ - /* Filter and Decimate */ - /***********************/ - decimated_framelength1 = silk_RSHIFT( psEncC->frame_length, 1 ); - decimated_framelength2 = silk_RSHIFT( psEncC->frame_length, 2 ); - decimated_framelength = silk_RSHIFT( psEncC->frame_length, 3 ); - /* Decimate into 4 bands: - 0 L 3L L 3L 5L - - -- - -- -- - 8 8 2 4 4 - - [0-1 kHz| temp. |1-2 kHz| 2-4 kHz | 4-8 kHz | - - They're arranged to allow the minimal ( frame_length / 4 ) extra - scratch space during the downsampling process */ - X_offset[ 0 ] = 0; - X_offset[ 1 ] = decimated_framelength + decimated_framelength2; - X_offset[ 2 ] = X_offset[ 1 ] + decimated_framelength; - X_offset[ 3 ] = X_offset[ 2 ] + decimated_framelength2; - ALLOC( X, X_offset[ 3 ] + decimated_framelength1, opus_int16 ); - - /* 0-8 kHz to 0-4 kHz and 4-8 kHz */ - silk_ana_filt_bank_1( pIn, &psSilk_VAD->AnaState[ 0 ], - X, &X[ X_offset[ 3 ] ], psEncC->frame_length ); - - /* 0-4 kHz to 0-2 kHz and 2-4 kHz */ - silk_ana_filt_bank_1( X, &psSilk_VAD->AnaState1[ 0 ], - X, &X[ X_offset[ 2 ] ], decimated_framelength1 ); - - /* 0-2 kHz to 0-1 kHz and 1-2 kHz */ - silk_ana_filt_bank_1( X, &psSilk_VAD->AnaState2[ 0 ], - X, &X[ X_offset[ 1 ] ], decimated_framelength2 ); - - /*********************************************/ - /* HP filter on lowest band (differentiator) */ - /*********************************************/ - X[ decimated_framelength - 1 ] = silk_RSHIFT( X[ decimated_framelength - 1 ], 1 ); - HPstateTmp = X[ decimated_framelength - 1 ]; - for( i = decimated_framelength - 1; i > 0; i-- ) { - X[ i - 1 ] = silk_RSHIFT( X[ i - 1 ], 1 ); - X[ i ] -= X[ i - 1 ]; - } - X[ 0 ] -= psSilk_VAD->HPstate; - psSilk_VAD->HPstate = HPstateTmp; - - /*************************************/ - /* Calculate the energy in each band */ - /*************************************/ - for( b = 0; b < VAD_N_BANDS; b++ ) { - /* Find the decimated framelength in the non-uniformly divided bands */ - decimated_framelength = silk_RSHIFT( psEncC->frame_length, silk_min_int( VAD_N_BANDS - b, VAD_N_BANDS - 1 ) ); - - /* Split length into subframe lengths */ - dec_subframe_length = silk_RSHIFT( decimated_framelength, VAD_INTERNAL_SUBFRAMES_LOG2 ); - dec_subframe_offset = 0; - - /* Compute energy per sub-frame */ - /* initialize with summed energy of last subframe */ - Xnrg[ b ] = psSilk_VAD->XnrgSubfr[ b ]; - for( s = 0; s < VAD_INTERNAL_SUBFRAMES; s++ ) { - __m128i xmm_X, xmm_acc; - sumSquared = 0; - - xmm_acc = _mm_setzero_si128(); - - for( i = 0; i < dec_subframe_length - 7; i += 8 ) - { - xmm_X = _mm_loadu_si128( (__m128i *)&(X[ X_offset[ b ] + i + dec_subframe_offset ] ) ); - xmm_X = _mm_srai_epi16( xmm_X, 3 ); - xmm_X = _mm_madd_epi16( xmm_X, xmm_X ); - xmm_acc = _mm_add_epi32( xmm_acc, xmm_X ); - } - - xmm_acc = _mm_add_epi32( xmm_acc, _mm_unpackhi_epi64( xmm_acc, xmm_acc ) ); - xmm_acc = _mm_add_epi32( xmm_acc, _mm_shufflelo_epi16( xmm_acc, 0x0E ) ); - - sumSquared += _mm_cvtsi128_si32( xmm_acc ); - - for( ; i < dec_subframe_length; i++ ) { - /* The energy will be less than dec_subframe_length * ( silk_int16_MIN / 8 ) ^ 2. */ - /* Therefore we can accumulate with no risk of overflow (unless dec_subframe_length > 128) */ - x_tmp = silk_RSHIFT( - X[ X_offset[ b ] + i + dec_subframe_offset ], 3 ); - sumSquared = silk_SMLABB( sumSquared, x_tmp, x_tmp ); - - /* Safety check */ - silk_assert( sumSquared >= 0 ); - } - - /* Add/saturate summed energy of current subframe */ - if( s < VAD_INTERNAL_SUBFRAMES - 1 ) { - Xnrg[ b ] = silk_ADD_POS_SAT32( Xnrg[ b ], sumSquared ); - } else { - /* Look-ahead subframe */ - Xnrg[ b ] = silk_ADD_POS_SAT32( Xnrg[ b ], silk_RSHIFT( sumSquared, 1 ) ); - } - - dec_subframe_offset += dec_subframe_length; - } - psSilk_VAD->XnrgSubfr[ b ] = sumSquared; - } - - /********************/ - /* Noise estimation */ - /********************/ - silk_VAD_GetNoiseLevels( &Xnrg[ 0 ], psSilk_VAD ); - - /***********************************************/ - /* Signal-plus-noise to noise ratio estimation */ - /***********************************************/ - sumSquared = 0; - input_tilt = 0; - for( b = 0; b < VAD_N_BANDS; b++ ) { - speech_nrg = Xnrg[ b ] - psSilk_VAD->NL[ b ]; - if( speech_nrg > 0 ) { - /* Divide, with sufficient resolution */ - if( ( Xnrg[ b ] & 0xFF800000 ) == 0 ) { - NrgToNoiseRatio_Q8[ b ] = silk_DIV32( silk_LSHIFT( Xnrg[ b ], 8 ), psSilk_VAD->NL[ b ] + 1 ); - } else { - NrgToNoiseRatio_Q8[ b ] = silk_DIV32( Xnrg[ b ], silk_RSHIFT( psSilk_VAD->NL[ b ], 8 ) + 1 ); - } - - /* Convert to log domain */ - SNR_Q7 = silk_lin2log( NrgToNoiseRatio_Q8[ b ] ) - 8 * 128; - - /* Sum-of-squares */ - sumSquared = silk_SMLABB( sumSquared, SNR_Q7, SNR_Q7 ); /* Q14 */ - - /* Tilt measure */ - if( speech_nrg < ( (opus_int32)1 << 20 ) ) { - /* Scale down SNR value for small subband speech energies */ - SNR_Q7 = silk_SMULWB( silk_LSHIFT( silk_SQRT_APPROX( speech_nrg ), 6 ), SNR_Q7 ); - } - input_tilt = silk_SMLAWB( input_tilt, tiltWeights[ b ], SNR_Q7 ); - } else { - NrgToNoiseRatio_Q8[ b ] = 256; - } - } - - /* Mean-of-squares */ - sumSquared = silk_DIV32_16( sumSquared, VAD_N_BANDS ); /* Q14 */ - - /* Root-mean-square approximation, scale to dBs, and write to output pointer */ - pSNR_dB_Q7 = (opus_int16)( 3 * silk_SQRT_APPROX( sumSquared ) ); /* Q7 */ - - /*********************************/ - /* Speech Probability Estimation */ - /*********************************/ - SA_Q15 = silk_sigm_Q15( silk_SMULWB( VAD_SNR_FACTOR_Q16, pSNR_dB_Q7 ) - VAD_NEGATIVE_OFFSET_Q5 ); - - /**************************/ - /* Frequency Tilt Measure */ - /**************************/ - psEncC->input_tilt_Q15 = silk_LSHIFT( silk_sigm_Q15( input_tilt ) - 16384, 1 ); - - /**************************************************/ - /* Scale the sigmoid output based on power levels */ - /**************************************************/ - speech_nrg = 0; - for( b = 0; b < VAD_N_BANDS; b++ ) { - /* Accumulate signal-without-noise energies, higher frequency bands have more weight */ - speech_nrg += ( b + 1 ) * silk_RSHIFT( Xnrg[ b ] - psSilk_VAD->NL[ b ], 4 ); - } - - if( psEncC->frame_length == 20 * psEncC->fs_kHz ) { - speech_nrg = silk_RSHIFT32( speech_nrg, 1 ); - } - /* Power scaling */ - if( speech_nrg <= 0 ) { - SA_Q15 = silk_RSHIFT( SA_Q15, 1 ); - } else if( speech_nrg < 16384 ) { - speech_nrg = silk_LSHIFT32( speech_nrg, 16 ); - - /* square-root */ - speech_nrg = silk_SQRT_APPROX( speech_nrg ); - SA_Q15 = silk_SMULWB( 32768 + speech_nrg, SA_Q15 ); - } - - /* Copy the resulting speech activity in Q8 */ - psEncC->speech_activity_Q8 = silk_min_int( silk_RSHIFT( SA_Q15, 7 ), silk_uint8_MAX ); - - /***********************************/ - /* Energy Level and SNR estimation */ - /***********************************/ - /* Smoothing coefficient */ - smooth_coef_Q16 = silk_SMULWB( VAD_SNR_SMOOTH_COEF_Q18, silk_SMULWB( (opus_int32)SA_Q15, SA_Q15 ) ); - - if( psEncC->frame_length == 10 * psEncC->fs_kHz ) { - smooth_coef_Q16 >>= 1; - } - - for( b = 0; b < VAD_N_BANDS; b++ ) { - /* compute smoothed energy-to-noise ratio per band */ - psSilk_VAD->NrgRatioSmth_Q8[ b ] = silk_SMLAWB( psSilk_VAD->NrgRatioSmth_Q8[ b ], - NrgToNoiseRatio_Q8[ b ] - psSilk_VAD->NrgRatioSmth_Q8[ b ], smooth_coef_Q16 ); - - /* signal to noise ratio in dB per band */ - SNR_Q7 = 3 * ( silk_lin2log( psSilk_VAD->NrgRatioSmth_Q8[b] ) - 8 * 128 ); - /* quality = sigmoid( 0.25 * ( SNR_dB - 16 ) ); */ - psEncC->input_quality_bands_Q15[ b ] = silk_sigm_Q15( silk_RSHIFT( SNR_Q7 - 16 * 128, 4 ) ); - } - -#ifdef OPUS_CHECK_ASM - silk_assert( ret == ret_c ); - silk_assert( !memcmp( &psEncC_c, psEncC, sizeof( psEncC_c ) ) ); -#endif - - RESTORE_STACK; - return( ret ); -} diff --git a/Engine/lib/opus/silk/x86/VQ_WMat_EC_sse4_1.c b/Engine/lib/opus/silk/x86/VQ_WMat_EC_sse4_1.c deleted file mode 100644 index 2c7d18d05..000000000 --- a/Engine/lib/opus/silk/x86/VQ_WMat_EC_sse4_1.c +++ /dev/null @@ -1,173 +0,0 @@ -/* Copyright (c) 2014-2020, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang FrancisQuiers - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - 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 -#include -#include -#include "main.h" -#include "celt/x86/x86cpu.h" - -/* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */ -void silk_VQ_WMat_EC_sse4_1( - opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *res_nrg_Q15, /* O best residual energy */ - opus_int32 *rate_dist_Q8, /* O best total bitrate */ - opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ - const opus_int32 *XX_Q17, /* I correlation matrix */ - const opus_int32 *xX_Q17, /* I correlation vector */ - const opus_int8 *cb_Q7, /* I codebook */ - const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ - const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int subfr_len, /* I number of samples per subframe */ - const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ - const opus_int L /* I number of vectors in codebook */ -) -{ - opus_int k, gain_tmp_Q7; - const opus_int8 *cb_row_Q7; - opus_int32 neg_xX_Q24[ 5 ]; - opus_int32 sum1_Q15, sum2_Q24; - opus_int32 bits_res_Q8, bits_tot_Q8; - __m128i v_XX_31_Q17, v_XX_42_Q17, v_cb_row_31_Q7, v_cb_row_42_Q7, v_acc1_Q24, v_acc2_Q24; - - /* Negate and convert to new Q domain */ - neg_xX_Q24[ 0 ] = -silk_LSHIFT32( xX_Q17[ 0 ], 7 ); - neg_xX_Q24[ 1 ] = -silk_LSHIFT32( xX_Q17[ 1 ], 7 ); - neg_xX_Q24[ 2 ] = -silk_LSHIFT32( xX_Q17[ 2 ], 7 ); - neg_xX_Q24[ 3 ] = -silk_LSHIFT32( xX_Q17[ 3 ], 7 ); - neg_xX_Q24[ 4 ] = -silk_LSHIFT32( xX_Q17[ 4 ], 7 ); - - v_XX_31_Q17 = _mm_loadu_si128( (__m128i *)(&XX_Q17[ 1 ] ) ); - v_XX_42_Q17 = _mm_shuffle_epi32( v_XX_31_Q17, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - - /* Loop over codebook */ - *rate_dist_Q8 = silk_int32_MAX; - *res_nrg_Q15 = silk_int32_MAX; - cb_row_Q7 = cb_Q7; - /* If things go really bad, at least *ind is set to something safe. */ - *ind = 0; - for( k = 0; k < L; k++ ) { - opus_int32 penalty; - gain_tmp_Q7 = cb_gain_Q7[k]; - /* Weighted rate */ - /* Quantization error: 1 - 2 * xX * cb + cb' * XX * cb */ - sum1_Q15 = SILK_FIX_CONST( 1.001, 15 ); - - /* Penalty for too large gain */ - penalty = silk_LSHIFT32( silk_max( silk_SUB32( gain_tmp_Q7, max_gain_Q7 ), 0 ), 11 ); - - /* first row of XX_Q17 */ - v_cb_row_31_Q7 = OP_CVTEPI8_EPI32_M32( &cb_row_Q7[ 1 ] ); - v_cb_row_42_Q7 = _mm_shuffle_epi32( v_cb_row_31_Q7, _MM_SHUFFLE( 0, 3, 2, 1 ) ); - v_cb_row_31_Q7 = _mm_mul_epi32( v_XX_31_Q17, v_cb_row_31_Q7 ); - v_cb_row_42_Q7 = _mm_mul_epi32( v_XX_42_Q17, v_cb_row_42_Q7 ); - v_acc1_Q24 = _mm_add_epi64( v_cb_row_31_Q7, v_cb_row_42_Q7); - v_acc2_Q24 = _mm_shuffle_epi32( v_acc1_Q24, _MM_SHUFFLE( 1, 0, 3, 2 ) ); - v_acc1_Q24 = _mm_add_epi64( v_acc1_Q24, v_acc2_Q24); - sum2_Q24 = _mm_cvtsi128_si32( v_acc1_Q24 ); - sum2_Q24 = silk_ADD32( neg_xX_Q24[ 0 ], sum2_Q24 ); - sum2_Q24 = silk_LSHIFT32( sum2_Q24, 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 0 ], cb_row_Q7[ 0 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 0 ] ); - - /* second row of XX_Q17 */ - sum2_Q24 = silk_MLA( neg_xX_Q24[ 1 ], XX_Q17[ 7 ], cb_row_Q7[ 2 ] ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 8 ], cb_row_Q7[ 3 ] ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 9 ], cb_row_Q7[ 4 ] ); - sum2_Q24 = silk_LSHIFT32( sum2_Q24, 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 6 ], cb_row_Q7[ 1 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 1 ] ); - - /* third row of XX_Q17 */ - sum2_Q24 = silk_MLA( neg_xX_Q24[ 2 ], XX_Q17[ 13 ], cb_row_Q7[ 3 ] ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 14 ], cb_row_Q7[ 4 ] ); - sum2_Q24 = silk_LSHIFT32( sum2_Q24, 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 12 ], cb_row_Q7[ 2 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 2 ] ); - - /* fourth row of XX_Q17 */ - sum2_Q24 = silk_MLA( neg_xX_Q24[ 3 ], XX_Q17[ 19 ], cb_row_Q7[ 4 ] ); - sum2_Q24 = silk_LSHIFT32( sum2_Q24, 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 18 ], cb_row_Q7[ 3 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 3 ] ); - - /* last row of XX_Q17 */ - sum2_Q24 = silk_LSHIFT32( neg_xX_Q24[ 4 ], 1 ); - sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 24 ], cb_row_Q7[ 4 ] ); - sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 4 ] ); - - /* find best */ - if( sum1_Q15 >= 0 ) { - /* Translate residual energy to bits using high-rate assumption (6 dB ==> 1 bit/sample) */ - bits_res_Q8 = silk_SMULBB( subfr_len, silk_lin2log( sum1_Q15 + penalty) - (15 << 7) ); - /* In the following line we reduce the codelength component by half ("-1"); seems to slightly improve quality */ - bits_tot_Q8 = silk_ADD_LSHIFT32( bits_res_Q8, cl_Q5[ k ], 3-1 ); - if( bits_tot_Q8 <= *rate_dist_Q8 ) { - *rate_dist_Q8 = bits_tot_Q8; - *res_nrg_Q15 = sum1_Q15 + penalty; - *ind = (opus_int8)k; - *gain_Q7 = gain_tmp_Q7; - } - } - - /* Go to next cbk vector */ - cb_row_Q7 += LTP_ORDER; - } - -#ifdef OPUS_CHECK_ASM - { - opus_int8 ind_c = 0; - opus_int32 res_nrg_Q15_c = 0; - opus_int32 rate_dist_Q8_c = 0; - opus_int gain_Q7_c = 0; - - silk_VQ_WMat_EC_c( - &ind_c, - &res_nrg_Q15_c, - &rate_dist_Q8_c, - &gain_Q7_c, - XX_Q17, - xX_Q17, - cb_Q7, - cb_gain_Q7, - cl_Q5, - subfr_len, - max_gain_Q7, - L - ); - - silk_assert( *ind == ind_c ); - silk_assert( *res_nrg_Q15 == res_nrg_Q15_c ); - silk_assert( *rate_dist_Q8 == rate_dist_Q8_c ); - silk_assert( *gain_Q7 == gain_Q7_c ); - } -#endif -} diff --git a/Engine/lib/opus/silk/x86/main_sse.h b/Engine/lib/opus/silk/x86/main_sse.h deleted file mode 100644 index a01d7f6c7..000000000 --- a/Engine/lib/opus/silk/x86/main_sse.h +++ /dev/null @@ -1,247 +0,0 @@ -/* Copyright (c) 2014, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef MAIN_SSE_H -# define MAIN_SSE_H - -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - -# if defined(OPUS_X86_MAY_HAVE_SSE4_1) - -void silk_VQ_WMat_EC_sse4_1( - opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *res_nrg_Q15, /* O best residual energy */ - opus_int32 *rate_dist_Q8, /* O best total bitrate */ - opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ - const opus_int32 *XX_Q17, /* I correlation matrix */ - const opus_int32 *xX_Q17, /* I correlation vector */ - const opus_int8 *cb_Q7, /* I codebook */ - const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ - const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int subfr_len, /* I number of samples per subframe */ - const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ - const opus_int L /* I number of vectors in codebook */ -); - -# if defined OPUS_X86_PRESUME_SSE4_1 - -# define OVERRIDE_silk_VQ_WMat_EC -# define silk_VQ_WMat_EC(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, \ - subfr_len, max_gain_Q7, L, arch) \ - ((void)(arch),silk_VQ_WMat_EC_sse4_1(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, \ - subfr_len, max_gain_Q7, L)) - -# elif defined(OPUS_HAVE_RTCD) - -extern void (*const SILK_VQ_WMAT_EC_IMPL[OPUS_ARCHMASK + 1])( - opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *res_nrg_Q15, /* O best residual energy */ - opus_int32 *rate_dist_Q8, /* O best total bitrate */ - opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ - const opus_int32 *XX_Q17, /* I correlation matrix */ - const opus_int32 *xX_Q17, /* I correlation vector */ - const opus_int8 *cb_Q7, /* I codebook */ - const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ - const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int subfr_len, /* I number of samples per subframe */ - const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ - const opus_int L /* I number of vectors in codebook */ -); - -# define OVERRIDE_silk_VQ_WMat_EC -# define silk_VQ_WMat_EC(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, \ - subfr_len, max_gain_Q7, L, arch) \ - ((*SILK_VQ_WMAT_EC_IMPL[(arch) & OPUS_ARCHMASK])(ind, res_nrg_Q15, rate_dist_Q8, gain_Q7, XX_Q17, xX_Q17, cb_Q7, cb_gain_Q7, cl_Q5, \ - subfr_len, max_gain_Q7, L)) - -# endif - -void silk_NSQ_sse4_1( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -); - -# if defined OPUS_X86_PRESUME_SSE4_1 - -# define OVERRIDE_silk_NSQ -# define silk_NSQ(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ - ((void)(arch),silk_NSQ_sse4_1(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) - -# elif defined(OPUS_HAVE_RTCD) - -extern void (*const SILK_NSQ_IMPL[OPUS_ARCHMASK + 1])( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -); - -# define OVERRIDE_silk_NSQ -# define silk_NSQ(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ - ((*SILK_NSQ_IMPL[(arch) & OPUS_ARCHMASK])(psEncC, NSQ, psIndices, x_Q3, pulses, PredCoef_Q12, LTPCoef_Q14, AR2_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) - -# endif - -void silk_NSQ_del_dec_sse4_1( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -); - -# if defined OPUS_X86_PRESUME_SSE4_1 - -# define OVERRIDE_silk_NSQ_del_dec -# define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ - ((void)(arch),silk_NSQ_del_dec_sse4_1(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) - -# elif defined(OPUS_HAVE_RTCD) - -extern void (*const SILK_NSQ_DEL_DEC_IMPL[OPUS_ARCHMASK + 1])( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -); - -# define OVERRIDE_silk_NSQ_del_dec -# define silk_NSQ_del_dec(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14, arch) \ - ((*SILK_NSQ_DEL_DEC_IMPL[(arch) & OPUS_ARCHMASK])(psEncC, NSQ, psIndices, x16, pulses, PredCoef_Q12, LTPCoef_Q14, AR_Q13, \ - HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, pitchL, Lambda_Q10, LTP_scale_Q14)) - -# endif - -void silk_noise_shape_quantizer( - silk_nsq_state *NSQ, /* I/O NSQ state */ - opus_int signalType, /* I Signal type */ - const opus_int32 x_sc_Q10[], /* I */ - opus_int8 pulses[], /* O */ - opus_int16 xq[], /* O */ - opus_int32 sLTP_Q15[], /* I/O LTP state */ - const opus_int16 a_Q12[], /* I Short term prediction coefs */ - const opus_int16 b_Q14[], /* I Long term prediction coefs */ - const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs */ - opus_int lag, /* I Pitch lag */ - opus_int32 HarmShapeFIRPacked_Q14, /* I */ - opus_int Tilt_Q14, /* I Spectral tilt */ - opus_int32 LF_shp_Q14, /* I */ - opus_int32 Gain_Q16, /* I */ - opus_int Lambda_Q10, /* I */ - opus_int offset_Q10, /* I */ - opus_int length, /* I Input length */ - opus_int shapingLPCOrder, /* I Noise shaping AR filter order */ - opus_int predictLPCOrder, /* I Prediction filter order */ - int arch /* I Architecture */ -); - -/**************************/ -/* Noise level estimation */ -/**************************/ -void silk_VAD_GetNoiseLevels( - const opus_int32 pX[ VAD_N_BANDS ], /* I subband energies */ - silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ -); - -opus_int silk_VAD_GetSA_Q8_sse4_1( - silk_encoder_state *psEnC, - const opus_int16 pIn[] -); - -# if defined(OPUS_X86_PRESUME_SSE4_1) - -# define OVERRIDE_silk_VAD_GetSA_Q8 -# define silk_VAD_GetSA_Q8(psEnC, pIn, arch) ((void)(arch),silk_VAD_GetSA_Q8_sse4_1(psEnC, pIn)) - -# elif defined(OPUS_HAVE_RTCD) - -extern opus_int (*const SILK_VAD_GETSA_Q8_IMPL[OPUS_ARCHMASK + 1])( - silk_encoder_state *psEnC, - const opus_int16 pIn[]); - -# define OVERRIDE_silk_VAD_GetSA_Q8 -# define silk_VAD_GetSA_Q8(psEnC, pIn, arch) \ - ((*SILK_VAD_GETSA_Q8_IMPL[(arch) & OPUS_ARCHMASK])(psEnC, pIn)) - -# endif - -# endif -#endif diff --git a/Engine/lib/opus/silk/x86/x86_silk_map.c b/Engine/lib/opus/silk/x86/x86_silk_map.c deleted file mode 100644 index 70f60078c..000000000 --- a/Engine/lib/opus/silk/x86/x86_silk_map.c +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (c) 2014, Cisco Systems, INC - Written by XiangMingZhu WeiZhou MinPeng YanWang - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if defined(HAVE_CONFIG_H) -#include "config.h" -#endif - -#include "celt/x86/x86cpu.h" -#include "structs.h" -#include "SigProc_FIX.h" -#include "pitch.h" -#include "main.h" - -#if defined(OPUS_HAVE_RTCD) && !defined(OPUS_X86_PRESUME_SSE4_1) - -#if defined(FIXED_POINT) - -#include "fixed/main_FIX.h" - -opus_int64 (*const SILK_INNER_PROD16_IMPL[ OPUS_ARCHMASK + 1 ] )( - const opus_int16 *inVec1, - const opus_int16 *inVec2, - const opus_int len -) = { - silk_inner_prod16_c, /* non-sse */ - silk_inner_prod16_c, - silk_inner_prod16_c, - MAY_HAVE_SSE4_1( silk_inner_prod16 ), /* sse4.1 */ - MAY_HAVE_SSE4_1( silk_inner_prod16 ) /* avx */ -}; - -#endif - -opus_int (*const SILK_VAD_GETSA_Q8_IMPL[ OPUS_ARCHMASK + 1 ] )( - silk_encoder_state *psEncC, - const opus_int16 pIn[] -) = { - silk_VAD_GetSA_Q8_c, /* non-sse */ - silk_VAD_GetSA_Q8_c, - silk_VAD_GetSA_Q8_c, - MAY_HAVE_SSE4_1( silk_VAD_GetSA_Q8 ), /* sse4.1 */ - MAY_HAVE_SSE4_1( silk_VAD_GetSA_Q8 ) /* avx */ -}; - -void (*const SILK_NSQ_IMPL[ OPUS_ARCHMASK + 1 ] )( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -) = { - silk_NSQ_c, /* non-sse */ - silk_NSQ_c, - silk_NSQ_c, - MAY_HAVE_SSE4_1( silk_NSQ ), /* sse4.1 */ - MAY_HAVE_SSE4_1( silk_NSQ ) /* avx */ -}; - -void (*const SILK_VQ_WMAT_EC_IMPL[ OPUS_ARCHMASK + 1 ] )( - opus_int8 *ind, /* O index of best codebook vector */ - opus_int32 *res_nrg_Q15, /* O best residual energy */ - opus_int32 *rate_dist_Q8, /* O best total bitrate */ - opus_int *gain_Q7, /* O sum of absolute LTP coefficients */ - const opus_int32 *XX_Q17, /* I correlation matrix */ - const opus_int32 *xX_Q17, /* I correlation vector */ - const opus_int8 *cb_Q7, /* I codebook */ - const opus_uint8 *cb_gain_Q7, /* I codebook effective gain */ - const opus_uint8 *cl_Q5, /* I code length for each codebook vector */ - const opus_int subfr_len, /* I number of samples per subframe */ - const opus_int32 max_gain_Q7, /* I maximum sum of absolute LTP coefficients */ - const opus_int L /* I number of vectors in codebook */ -) = { - silk_VQ_WMat_EC_c, /* non-sse */ - silk_VQ_WMat_EC_c, - silk_VQ_WMat_EC_c, - MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ), /* sse4.1 */ - MAY_HAVE_SSE4_1( silk_VQ_WMat_EC ) /* avx */ -}; - -void (*const SILK_NSQ_DEL_DEC_IMPL[ OPUS_ARCHMASK + 1 ] )( - const silk_encoder_state *psEncC, /* I Encoder State */ - silk_nsq_state *NSQ, /* I/O NSQ state */ - SideInfoIndices *psIndices, /* I/O Quantization Indices */ - const opus_int16 x16[], /* I Input */ - opus_int8 pulses[], /* O Quantized pulse signal */ - const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */ - const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */ - const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */ - const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */ - const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */ - const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */ - const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */ - const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */ - const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */ - const opus_int LTP_scale_Q14 /* I LTP state scaling */ -) = { - silk_NSQ_del_dec_c, /* non-sse */ - silk_NSQ_del_dec_c, - silk_NSQ_del_dec_c, - MAY_HAVE_SSE4_1( silk_NSQ_del_dec ), /* sse4.1 */ - MAY_HAVE_SSE4_1( silk_NSQ_del_dec ) /* avx */ -}; - -#if defined(FIXED_POINT) - -void (*const SILK_BURG_MODIFIED_IMPL[ OPUS_ARCHMASK + 1 ] )( - opus_int32 *res_nrg, /* O Residual energy */ - opus_int *res_nrg_Q, /* O Residual energy Q value */ - opus_int32 A_Q16[], /* O Prediction coefficients (length order) */ - const opus_int16 x[], /* I Input signal, length: nb_subfr * ( D + subfr_length ) */ - const opus_int32 minInvGain_Q30, /* I Inverse of max prediction gain */ - const opus_int subfr_length, /* I Input signal subframe length (incl. D preceding samples) */ - const opus_int nb_subfr, /* I Number of subframes stacked in x */ - const opus_int D, /* I Order */ - int arch /* I Run-time architecture */ -) = { - silk_burg_modified_c, /* non-sse */ - silk_burg_modified_c, - silk_burg_modified_c, - MAY_HAVE_SSE4_1( silk_burg_modified ), /* sse4.1 */ - MAY_HAVE_SSE4_1( silk_burg_modified ) /* avx */ -}; - -#endif -#endif diff --git a/Engine/lib/opus/silk_headers.mk b/Engine/lib/opus/silk_headers.mk deleted file mode 100644 index 2588067c7..000000000 --- a/Engine/lib/opus/silk_headers.mk +++ /dev/null @@ -1,44 +0,0 @@ -SILK_HEAD = \ -silk/debug.h \ -silk/control.h \ -silk/errors.h \ -silk/API.h \ -silk/typedef.h \ -silk/define.h \ -silk/main.h \ -silk/x86/main_sse.h \ -silk/PLC.h \ -silk/structs.h \ -silk/tables.h \ -silk/tuning_parameters.h \ -silk/Inlines.h \ -silk/MacroCount.h \ -silk/MacroDebug.h \ -silk/macros.h \ -silk/NSQ.h \ -silk/pitch_est_defines.h \ -silk/resampler_private.h \ -silk/resampler_rom.h \ -silk/resampler_structs.h \ -silk/SigProc_FIX.h \ -silk/x86/SigProc_FIX_sse.h \ -silk/arm/biquad_alt_arm.h \ -silk/arm/LPC_inv_pred_gain_arm.h \ -silk/arm/macros_armv4.h \ -silk/arm/macros_armv5e.h \ -silk/arm/macros_arm64.h \ -silk/arm/SigProc_FIX_armv4.h \ -silk/arm/SigProc_FIX_armv5e.h \ -silk/arm/NSQ_del_dec_arm.h \ -silk/arm/NSQ_neon.h \ -silk/fixed/main_FIX.h \ -silk/fixed/structs_FIX.h \ -silk/fixed/arm/warped_autocorrelation_FIX_arm.h \ -silk/fixed/mips/noise_shape_analysis_FIX_mipsr1.h \ -silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h \ -silk/float/main_FLP.h \ -silk/float/structs_FLP.h \ -silk/float/SigProc_FLP.h \ -silk/mips/macros_mipsr1.h \ -silk/mips/NSQ_del_dec_mipsr1.h \ -silk/mips/sigproc_fix_mipsr1.h diff --git a/Engine/lib/opus/silk_sources.mk b/Engine/lib/opus/silk_sources.mk deleted file mode 100644 index 3df248166..000000000 --- a/Engine/lib/opus/silk_sources.mk +++ /dev/null @@ -1,158 +0,0 @@ -SILK_SOURCES = \ -silk/CNG.c \ -silk/code_signs.c \ -silk/init_decoder.c \ -silk/decode_core.c \ -silk/decode_frame.c \ -silk/decode_parameters.c \ -silk/decode_indices.c \ -silk/decode_pulses.c \ -silk/decoder_set_fs.c \ -silk/dec_API.c \ -silk/enc_API.c \ -silk/encode_indices.c \ -silk/encode_pulses.c \ -silk/gain_quant.c \ -silk/interpolate.c \ -silk/LP_variable_cutoff.c \ -silk/NLSF_decode.c \ -silk/NSQ.c \ -silk/NSQ_del_dec.c \ -silk/PLC.c \ -silk/shell_coder.c \ -silk/tables_gain.c \ -silk/tables_LTP.c \ -silk/tables_NLSF_CB_NB_MB.c \ -silk/tables_NLSF_CB_WB.c \ -silk/tables_other.c \ -silk/tables_pitch_lag.c \ -silk/tables_pulses_per_block.c \ -silk/VAD.c \ -silk/control_audio_bandwidth.c \ -silk/quant_LTP_gains.c \ -silk/VQ_WMat_EC.c \ -silk/HP_variable_cutoff.c \ -silk/NLSF_encode.c \ -silk/NLSF_VQ.c \ -silk/NLSF_unpack.c \ -silk/NLSF_del_dec_quant.c \ -silk/process_NLSFs.c \ -silk/stereo_LR_to_MS.c \ -silk/stereo_MS_to_LR.c \ -silk/check_control_input.c \ -silk/control_SNR.c \ -silk/init_encoder.c \ -silk/control_codec.c \ -silk/A2NLSF.c \ -silk/ana_filt_bank_1.c \ -silk/biquad_alt.c \ -silk/bwexpander_32.c \ -silk/bwexpander.c \ -silk/debug.c \ -silk/decode_pitch.c \ -silk/inner_prod_aligned.c \ -silk/lin2log.c \ -silk/log2lin.c \ -silk/LPC_analysis_filter.c \ -silk/LPC_inv_pred_gain.c \ -silk/table_LSF_cos.c \ -silk/NLSF2A.c \ -silk/NLSF_stabilize.c \ -silk/NLSF_VQ_weights_laroia.c \ -silk/pitch_est_tables.c \ -silk/resampler.c \ -silk/resampler_down2_3.c \ -silk/resampler_down2.c \ -silk/resampler_private_AR2.c \ -silk/resampler_private_down_FIR.c \ -silk/resampler_private_IIR_FIR.c \ -silk/resampler_private_up2_HQ.c \ -silk/resampler_rom.c \ -silk/sigm_Q15.c \ -silk/sort.c \ -silk/sum_sqr_shift.c \ -silk/stereo_decode_pred.c \ -silk/stereo_encode_pred.c \ -silk/stereo_find_predictor.c \ -silk/stereo_quant_pred.c \ -silk/LPC_fit.c - -SILK_SOURCES_X86_RTCD = \ -silk/x86/x86_silk_map.c - -SILK_SOURCES_SSE4_1 = \ -silk/x86/NSQ_sse4_1.c \ -silk/x86/NSQ_del_dec_sse4_1.c \ -silk/x86/VAD_sse4_1.c \ -silk/x86/VQ_WMat_EC_sse4_1.c - -SILK_SOURCES_ARM_RTCD = \ -silk/arm/arm_silk_map.c - -SILK_SOURCES_ARM_NEON_INTR = \ -silk/arm/biquad_alt_neon_intr.c \ -silk/arm/LPC_inv_pred_gain_neon_intr.c \ -silk/arm/NSQ_del_dec_neon_intr.c \ -silk/arm/NSQ_neon.c - -SILK_SOURCES_FIXED = \ -silk/fixed/LTP_analysis_filter_FIX.c \ -silk/fixed/LTP_scale_ctrl_FIX.c \ -silk/fixed/corrMatrix_FIX.c \ -silk/fixed/encode_frame_FIX.c \ -silk/fixed/find_LPC_FIX.c \ -silk/fixed/find_LTP_FIX.c \ -silk/fixed/find_pitch_lags_FIX.c \ -silk/fixed/find_pred_coefs_FIX.c \ -silk/fixed/noise_shape_analysis_FIX.c \ -silk/fixed/process_gains_FIX.c \ -silk/fixed/regularize_correlations_FIX.c \ -silk/fixed/residual_energy16_FIX.c \ -silk/fixed/residual_energy_FIX.c \ -silk/fixed/warped_autocorrelation_FIX.c \ -silk/fixed/apply_sine_window_FIX.c \ -silk/fixed/autocorr_FIX.c \ -silk/fixed/burg_modified_FIX.c \ -silk/fixed/k2a_FIX.c \ -silk/fixed/k2a_Q16_FIX.c \ -silk/fixed/pitch_analysis_core_FIX.c \ -silk/fixed/vector_ops_FIX.c \ -silk/fixed/schur64_FIX.c \ -silk/fixed/schur_FIX.c - -SILK_SOURCES_FIXED_SSE4_1 = \ -silk/fixed/x86/vector_ops_FIX_sse4_1.c \ -silk/fixed/x86/burg_modified_FIX_sse4_1.c - -SILK_SOURCES_FIXED_ARM_NEON_INTR = \ -silk/fixed/arm/warped_autocorrelation_FIX_neon_intr.c - -SILK_SOURCES_FLOAT = \ -silk/float/apply_sine_window_FLP.c \ -silk/float/corrMatrix_FLP.c \ -silk/float/encode_frame_FLP.c \ -silk/float/find_LPC_FLP.c \ -silk/float/find_LTP_FLP.c \ -silk/float/find_pitch_lags_FLP.c \ -silk/float/find_pred_coefs_FLP.c \ -silk/float/LPC_analysis_filter_FLP.c \ -silk/float/LTP_analysis_filter_FLP.c \ -silk/float/LTP_scale_ctrl_FLP.c \ -silk/float/noise_shape_analysis_FLP.c \ -silk/float/process_gains_FLP.c \ -silk/float/regularize_correlations_FLP.c \ -silk/float/residual_energy_FLP.c \ -silk/float/warped_autocorrelation_FLP.c \ -silk/float/wrappers_FLP.c \ -silk/float/autocorrelation_FLP.c \ -silk/float/burg_modified_FLP.c \ -silk/float/bwexpander_FLP.c \ -silk/float/energy_FLP.c \ -silk/float/inner_product_FLP.c \ -silk/float/k2a_FLP.c \ -silk/float/LPC_inv_pred_gain_FLP.c \ -silk/float/pitch_analysis_core_FLP.c \ -silk/float/scale_copy_vector_FLP.c \ -silk/float/scale_vector_FLP.c \ -silk/float/schur_FLP.c \ -silk/float/sort_FLP.c diff --git a/Engine/lib/opus/src/analysis.c b/Engine/lib/opus/src/analysis.c deleted file mode 100644 index 058328f0f..000000000 --- a/Engine/lib/opus/src/analysis.c +++ /dev/null @@ -1,983 +0,0 @@ -/* Copyright (c) 2011 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 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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define ANALYSIS_C - -#ifdef MLP_TRAINING -#include -#endif - -#include "mathops.h" -#include "kiss_fft.h" -#include "celt.h" -#include "modes.h" -#include "arch.h" -#include "quant_bands.h" -#include "analysis.h" -#include "mlp.h" -#include "stack_alloc.h" -#include "float_cast.h" - -#ifndef M_PI -#define M_PI 3.141592653 -#endif - -#ifndef DISABLE_FLOAT_API - -#define TRANSITION_PENALTY 10 - -static const float dct_table[128] = { - 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, - 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, 0.250000f, - 0.351851f, 0.338330f, 0.311806f, 0.273300f, 0.224292f, 0.166664f, 0.102631f, 0.034654f, - -0.034654f,-0.102631f,-0.166664f,-0.224292f,-0.273300f,-0.311806f,-0.338330f,-0.351851f, - 0.346760f, 0.293969f, 0.196424f, 0.068975f,-0.068975f,-0.196424f,-0.293969f,-0.346760f, - -0.346760f,-0.293969f,-0.196424f,-0.068975f, 0.068975f, 0.196424f, 0.293969f, 0.346760f, - 0.338330f, 0.224292f, 0.034654f,-0.166664f,-0.311806f,-0.351851f,-0.273300f,-0.102631f, - 0.102631f, 0.273300f, 0.351851f, 0.311806f, 0.166664f,-0.034654f,-0.224292f,-0.338330f, - 0.326641f, 0.135299f,-0.135299f,-0.326641f,-0.326641f,-0.135299f, 0.135299f, 0.326641f, - 0.326641f, 0.135299f,-0.135299f,-0.326641f,-0.326641f,-0.135299f, 0.135299f, 0.326641f, - 0.311806f, 0.034654f,-0.273300f,-0.338330f,-0.102631f, 0.224292f, 0.351851f, 0.166664f, - -0.166664f,-0.351851f,-0.224292f, 0.102631f, 0.338330f, 0.273300f,-0.034654f,-0.311806f, - 0.293969f,-0.068975f,-0.346760f,-0.196424f, 0.196424f, 0.346760f, 0.068975f,-0.293969f, - -0.293969f, 0.068975f, 0.346760f, 0.196424f,-0.196424f,-0.346760f,-0.068975f, 0.293969f, - 0.273300f,-0.166664f,-0.338330f, 0.034654f, 0.351851f, 0.102631f,-0.311806f,-0.224292f, - 0.224292f, 0.311806f,-0.102631f,-0.351851f,-0.034654f, 0.338330f, 0.166664f,-0.273300f, -}; - -static const float analysis_window[240] = { - 0.000043f, 0.000171f, 0.000385f, 0.000685f, 0.001071f, 0.001541f, 0.002098f, 0.002739f, - 0.003466f, 0.004278f, 0.005174f, 0.006156f, 0.007222f, 0.008373f, 0.009607f, 0.010926f, - 0.012329f, 0.013815f, 0.015385f, 0.017037f, 0.018772f, 0.020590f, 0.022490f, 0.024472f, - 0.026535f, 0.028679f, 0.030904f, 0.033210f, 0.035595f, 0.038060f, 0.040604f, 0.043227f, - 0.045928f, 0.048707f, 0.051564f, 0.054497f, 0.057506f, 0.060591f, 0.063752f, 0.066987f, - 0.070297f, 0.073680f, 0.077136f, 0.080665f, 0.084265f, 0.087937f, 0.091679f, 0.095492f, - 0.099373f, 0.103323f, 0.107342f, 0.111427f, 0.115579f, 0.119797f, 0.124080f, 0.128428f, - 0.132839f, 0.137313f, 0.141849f, 0.146447f, 0.151105f, 0.155823f, 0.160600f, 0.165435f, - 0.170327f, 0.175276f, 0.180280f, 0.185340f, 0.190453f, 0.195619f, 0.200838f, 0.206107f, - 0.211427f, 0.216797f, 0.222215f, 0.227680f, 0.233193f, 0.238751f, 0.244353f, 0.250000f, - 0.255689f, 0.261421f, 0.267193f, 0.273005f, 0.278856f, 0.284744f, 0.290670f, 0.296632f, - 0.302628f, 0.308658f, 0.314721f, 0.320816f, 0.326941f, 0.333097f, 0.339280f, 0.345492f, - 0.351729f, 0.357992f, 0.364280f, 0.370590f, 0.376923f, 0.383277f, 0.389651f, 0.396044f, - 0.402455f, 0.408882f, 0.415325f, 0.421783f, 0.428254f, 0.434737f, 0.441231f, 0.447736f, - 0.454249f, 0.460770f, 0.467298f, 0.473832f, 0.480370f, 0.486912f, 0.493455f, 0.500000f, - 0.506545f, 0.513088f, 0.519630f, 0.526168f, 0.532702f, 0.539230f, 0.545751f, 0.552264f, - 0.558769f, 0.565263f, 0.571746f, 0.578217f, 0.584675f, 0.591118f, 0.597545f, 0.603956f, - 0.610349f, 0.616723f, 0.623077f, 0.629410f, 0.635720f, 0.642008f, 0.648271f, 0.654508f, - 0.660720f, 0.666903f, 0.673059f, 0.679184f, 0.685279f, 0.691342f, 0.697372f, 0.703368f, - 0.709330f, 0.715256f, 0.721144f, 0.726995f, 0.732807f, 0.738579f, 0.744311f, 0.750000f, - 0.755647f, 0.761249f, 0.766807f, 0.772320f, 0.777785f, 0.783203f, 0.788573f, 0.793893f, - 0.799162f, 0.804381f, 0.809547f, 0.814660f, 0.819720f, 0.824724f, 0.829673f, 0.834565f, - 0.839400f, 0.844177f, 0.848895f, 0.853553f, 0.858151f, 0.862687f, 0.867161f, 0.871572f, - 0.875920f, 0.880203f, 0.884421f, 0.888573f, 0.892658f, 0.896677f, 0.900627f, 0.904508f, - 0.908321f, 0.912063f, 0.915735f, 0.919335f, 0.922864f, 0.926320f, 0.929703f, 0.933013f, - 0.936248f, 0.939409f, 0.942494f, 0.945503f, 0.948436f, 0.951293f, 0.954072f, 0.956773f, - 0.959396f, 0.961940f, 0.964405f, 0.966790f, 0.969096f, 0.971321f, 0.973465f, 0.975528f, - 0.977510f, 0.979410f, 0.981228f, 0.982963f, 0.984615f, 0.986185f, 0.987671f, 0.989074f, - 0.990393f, 0.991627f, 0.992778f, 0.993844f, 0.994826f, 0.995722f, 0.996534f, 0.997261f, - 0.997902f, 0.998459f, 0.998929f, 0.999315f, 0.999615f, 0.999829f, 0.999957f, 1.000000f, -}; - -static const int tbands[NB_TBANDS+1] = { - 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 136, 160, 192, 240 -}; - -#define NB_TONAL_SKIP_BANDS 9 - -static opus_val32 silk_resampler_down2_hp( - opus_val32 *S, /* I/O State vector [ 2 ] */ - opus_val32 *out, /* O Output signal [ floor(len/2) ] */ - const opus_val32 *in, /* I Input signal [ len ] */ - int inLen /* I Number of input samples */ -) -{ - int k, len2 = inLen/2; - opus_val32 in32, out32, out32_hp, Y, X; - opus_val64 hp_ener = 0; - /* Internal variables and state are in Q10 format */ - for( k = 0; k < len2; k++ ) { - /* Convert to Q10 */ - in32 = in[ 2 * k ]; - - /* All-pass section for even input sample */ - Y = SUB32( in32, S[ 0 ] ); - X = MULT16_32_Q15(QCONST16(0.6074371f, 15), Y); - out32 = ADD32( S[ 0 ], X ); - S[ 0 ] = ADD32( in32, X ); - out32_hp = out32; - /* Convert to Q10 */ - in32 = in[ 2 * k + 1 ]; - - /* All-pass section for odd input sample, and add to output of previous section */ - Y = SUB32( in32, S[ 1 ] ); - X = MULT16_32_Q15(QCONST16(0.15063f, 15), Y); - out32 = ADD32( out32, S[ 1 ] ); - out32 = ADD32( out32, X ); - S[ 1 ] = ADD32( in32, X ); - - Y = SUB32( -in32, S[ 2 ] ); - X = MULT16_32_Q15(QCONST16(0.15063f, 15), Y); - out32_hp = ADD32( out32_hp, S[ 2 ] ); - out32_hp = ADD32( out32_hp, X ); - S[ 2 ] = ADD32( -in32, X ); - - hp_ener += out32_hp*(opus_val64)out32_hp; - /* Add, convert back to int16 and store to output */ - out[ k ] = HALF32(out32); - } -#ifdef FIXED_POINT - /* len2 can be up to 480, so we shift by 8 more to make it fit. */ - hp_ener = hp_ener >> (2*SIG_SHIFT + 8); -#endif - return (opus_val32)hp_ener; -} - -static opus_val32 downmix_and_resample(downmix_func downmix, const void *_x, opus_val32 *y, opus_val32 S[3], int subframe, int offset, int c1, int c2, int C, int Fs) -{ - VARDECL(opus_val32, tmp); - opus_val32 scale; - int j; - opus_val32 ret = 0; - SAVE_STACK; - - if (subframe==0) return 0; - if (Fs == 48000) - { - subframe *= 2; - offset *= 2; - } else if (Fs == 16000) { - subframe = subframe*2/3; - offset = offset*2/3; - } - ALLOC(tmp, subframe, opus_val32); - - downmix(_x, tmp, subframe, offset, c1, c2, C); -#ifdef FIXED_POINT - scale = (1<-1) - scale /= 2; - for (j=0;jarch = opus_select_arch(); - tonal->Fs = Fs; - /* Clear remaining fields. */ - tonality_analysis_reset(tonal); -} - -void tonality_analysis_reset(TonalityAnalysisState *tonal) -{ - /* Clear non-reusable fields. */ - char *start = (char*)&tonal->TONALITY_ANALYSIS_RESET_START; - OPUS_CLEAR(start, sizeof(TonalityAnalysisState) - (start - (char*)tonal)); -} - -void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len) -{ - int pos; - int curr_lookahead; - float tonality_max; - float tonality_avg; - int tonality_count; - int i; - int pos0; - float prob_avg; - float prob_count; - float prob_min, prob_max; - float vad_prob; - int mpos, vpos; - int bandwidth_span; - - pos = tonal->read_pos; - curr_lookahead = tonal->write_pos-tonal->read_pos; - if (curr_lookahead<0) - curr_lookahead += DETECT_SIZE; - - tonal->read_subframe += len/(tonal->Fs/400); - while (tonal->read_subframe>=8) - { - tonal->read_subframe -= 8; - tonal->read_pos++; - } - if (tonal->read_pos>=DETECT_SIZE) - tonal->read_pos-=DETECT_SIZE; - - /* On long frames, look at the second analysis window rather than the first. */ - if (len > tonal->Fs/50 && pos != tonal->write_pos) - { - pos++; - if (pos==DETECT_SIZE) - pos=0; - } - if (pos == tonal->write_pos) - pos--; - if (pos<0) - pos = DETECT_SIZE-1; - pos0 = pos; - OPUS_COPY(info_out, &tonal->info[pos], 1); - if (!info_out->valid) - return; - tonality_max = tonality_avg = info_out->tonality; - tonality_count = 1; - /* Look at the neighbouring frames and pick largest bandwidth found (to be safe). */ - bandwidth_span = 6; - /* If possible, look ahead for a tone to compensate for the delay in the tone detector. */ - for (i=0;i<3;i++) - { - pos++; - if (pos==DETECT_SIZE) - pos = 0; - if (pos == tonal->write_pos) - break; - tonality_max = MAX32(tonality_max, tonal->info[pos].tonality); - tonality_avg += tonal->info[pos].tonality; - tonality_count++; - info_out->bandwidth = IMAX(info_out->bandwidth, tonal->info[pos].bandwidth); - bandwidth_span--; - } - pos = pos0; - /* Look back in time to see if any has a wider bandwidth than the current frame. */ - for (i=0;iwrite_pos) - break; - info_out->bandwidth = IMAX(info_out->bandwidth, tonal->info[pos].bandwidth); - } - info_out->tonality = MAX32(tonality_avg/tonality_count, tonality_max-.2f); - - mpos = vpos = pos0; - /* If we have enough look-ahead, compensate for the ~5-frame delay in the music prob and - ~1 frame delay in the VAD prob. */ - if (curr_lookahead > 15) - { - mpos += 5; - if (mpos>=DETECT_SIZE) - mpos -= DETECT_SIZE; - vpos += 1; - if (vpos>=DETECT_SIZE) - vpos -= DETECT_SIZE; - } - - /* The following calculations attempt to minimize a "badness function" - for the transition. When switching from speech to music, the badness - of switching at frame k is - b_k = S*v_k + \sum_{i=0}^{k-1} v_i*(p_i - T) - where - v_i is the activity probability (VAD) at frame i, - p_i is the music probability at frame i - T is the probability threshold for switching - S is the penalty for switching during active audio rather than silence - the current frame has index i=0 - - Rather than apply badness to directly decide when to switch, what we compute - instead is the threshold for which the optimal switching point is now. When - considering whether to switch now (frame 0) or at frame k, we have: - S*v_0 = S*v_k + \sum_{i=0}^{k-1} v_i*(p_i - T) - which gives us: - T = ( \sum_{i=0}^{k-1} v_i*p_i + S*(v_k-v_0) ) / ( \sum_{i=0}^{k-1} v_i ) - We take the min threshold across all positive values of k (up to the maximum - amount of lookahead we have) to give us the threshold for which the current - frame is the optimal switch point. - - The last step is that we need to consider whether we want to switch at all. - For that we use the average of the music probability over the entire window. - If the threshold is higher than that average we're not going to - switch, so we compute a min with the average as well. The result of all these - min operations is music_prob_min, which gives the threshold for switching to music - if we're currently encoding for speech. - - We do the exact opposite to compute music_prob_max which is used for switching - from music to speech. - */ - prob_min = 1.f; - prob_max = 0.f; - vad_prob = tonal->info[vpos].activity_probability; - prob_count = MAX16(.1f, vad_prob); - prob_avg = MAX16(.1f, vad_prob)*tonal->info[mpos].music_prob; - while (1) - { - float pos_vad; - mpos++; - if (mpos==DETECT_SIZE) - mpos = 0; - if (mpos == tonal->write_pos) - break; - vpos++; - if (vpos==DETECT_SIZE) - vpos = 0; - if (vpos == tonal->write_pos) - break; - pos_vad = tonal->info[vpos].activity_probability; - prob_min = MIN16((prob_avg - TRANSITION_PENALTY*(vad_prob - pos_vad))/prob_count, prob_min); - prob_max = MAX16((prob_avg + TRANSITION_PENALTY*(vad_prob - pos_vad))/prob_count, prob_max); - prob_count += MAX16(.1f, pos_vad); - prob_avg += MAX16(.1f, pos_vad)*tonal->info[mpos].music_prob; - } - info_out->music_prob = prob_avg/prob_count; - prob_min = MIN16(prob_avg/prob_count, prob_min); - prob_max = MAX16(prob_avg/prob_count, prob_max); - prob_min = MAX16(prob_min, 0.f); - prob_max = MIN16(prob_max, 1.f); - - /* If we don't have enough look-ahead, do our best to make a decent decision. */ - if (curr_lookahead < 10) - { - float pmin, pmax; - pmin = prob_min; - pmax = prob_max; - pos = pos0; - /* Look for min/max in the past. */ - for (i=0;icount-1, 15);i++) - { - pos--; - if (pos < 0) - pos = DETECT_SIZE-1; - pmin = MIN16(pmin, tonal->info[pos].music_prob); - pmax = MAX16(pmax, tonal->info[pos].music_prob); - } - /* Bias against switching on active audio. */ - pmin = MAX16(0.f, pmin - .1f*vad_prob); - pmax = MIN16(1.f, pmax + .1f*vad_prob); - prob_min += (1.f-.1f*curr_lookahead)*(pmin - prob_min); - prob_max += (1.f-.1f*curr_lookahead)*(pmax - prob_max); - } - info_out->music_prob_min = prob_min; - info_out->music_prob_max = prob_max; - - /* printf("%f %f %f %f %f\n", prob_min, prob_max, prob_avg/prob_count, vad_prob, info_out->music_prob); */ -} - -static const float std_feature_bias[9] = { - 5.684947f, 3.475288f, 1.770634f, 1.599784f, 3.773215f, - 2.163313f, 1.260756f, 1.116868f, 1.918795f -}; - -#define LEAKAGE_OFFSET 2.5f -#define LEAKAGE_SLOPE 2.f - -#ifdef FIXED_POINT -/* For fixed-point, the input is +/-2^15 shifted up by SIG_SHIFT, so we need to - compensate for that in the energy. */ -#define SCALE_COMPENS (1.f/((opus_int32)1<<(15+SIG_SHIFT))) -#define SCALE_ENER(e) ((SCALE_COMPENS*SCALE_COMPENS)*(e)) -#else -#define SCALE_ENER(e) (e) -#endif - -#ifdef FIXED_POINT -static int is_digital_silence32(const opus_val32* pcm, int frame_size, int channels, int lsb_depth) -{ - int silence = 0; - opus_val32 sample_max = 0; -#ifdef MLP_TRAINING - return 0; -#endif - sample_max = celt_maxabs32(pcm, frame_size*channels); - - silence = (sample_max == 0); - (void)lsb_depth; - return silence; -} -#else -#define is_digital_silence32(pcm, frame_size, channels, lsb_depth) is_digital_silence(pcm, frame_size, channels, lsb_depth) -#endif - -static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix) -{ - int i, b; - const kiss_fft_state *kfft; - VARDECL(kiss_fft_cpx, in); - VARDECL(kiss_fft_cpx, out); - int N = 480, N2=240; - float * OPUS_RESTRICT A = tonal->angle; - float * OPUS_RESTRICT dA = tonal->d_angle; - float * OPUS_RESTRICT d2A = tonal->d2_angle; - VARDECL(float, tonality); - VARDECL(float, noisiness); - float band_tonality[NB_TBANDS]; - float logE[NB_TBANDS]; - float BFCC[8]; - float features[25]; - float frame_tonality; - float max_frame_tonality; - /*float tw_sum=0;*/ - float frame_noisiness; - const float pi4 = (float)(M_PI*M_PI*M_PI*M_PI); - float slope=0; - float frame_stationarity; - float relativeE; - float frame_probs[2]; - float alpha, alphaE, alphaE2; - float frame_loudness; - float bandwidth_mask; - int is_masked[NB_TBANDS+1]; - int bandwidth=0; - float maxE = 0; - float noise_floor; - int remaining; - AnalysisInfo *info; - float hp_ener; - float tonality2[240]; - float midE[8]; - float spec_variability=0; - float band_log2[NB_TBANDS+1]; - float leakage_from[NB_TBANDS+1]; - float leakage_to[NB_TBANDS+1]; - float layer_out[MAX_NEURONS]; - float below_max_pitch; - float above_max_pitch; - int is_silence; - SAVE_STACK; - - if (!tonal->initialized) - { - tonal->mem_fill = 240; - tonal->initialized = 1; - } - alpha = 1.f/IMIN(10, 1+tonal->count); - alphaE = 1.f/IMIN(25, 1+tonal->count); - /* Noise floor related decay for bandwidth detection: -2.2 dB/second */ - alphaE2 = 1.f/IMIN(100, 1+tonal->count); - if (tonal->count <= 1) alphaE2 = 1; - - if (tonal->Fs == 48000) - { - /* len and offset are now at 24 kHz. */ - len/= 2; - offset /= 2; - } else if (tonal->Fs == 16000) { - len = 3*len/2; - offset = 3*offset/2; - } - - kfft = celt_mode->mdct.kfft[0]; - tonal->hp_ener_accum += (float)downmix_and_resample(downmix, x, - &tonal->inmem[tonal->mem_fill], tonal->downmix_state, - IMIN(len, ANALYSIS_BUF_SIZE-tonal->mem_fill), offset, c1, c2, C, tonal->Fs); - if (tonal->mem_fill+len < ANALYSIS_BUF_SIZE) - { - tonal->mem_fill += len; - /* Don't have enough to update the analysis */ - RESTORE_STACK; - return; - } - hp_ener = tonal->hp_ener_accum; - info = &tonal->info[tonal->write_pos++]; - if (tonal->write_pos>=DETECT_SIZE) - tonal->write_pos-=DETECT_SIZE; - - is_silence = is_digital_silence32(tonal->inmem, ANALYSIS_BUF_SIZE, 1, lsb_depth); - - ALLOC(in, 480, kiss_fft_cpx); - ALLOC(out, 480, kiss_fft_cpx); - ALLOC(tonality, 240, float); - ALLOC(noisiness, 240, float); - for (i=0;iinmem[i]); - in[i].i = (kiss_fft_scalar)(w*tonal->inmem[N2+i]); - in[N-i-1].r = (kiss_fft_scalar)(w*tonal->inmem[N-i-1]); - in[N-i-1].i = (kiss_fft_scalar)(w*tonal->inmem[N+N2-i-1]); - } - OPUS_MOVE(tonal->inmem, tonal->inmem+ANALYSIS_BUF_SIZE-240, 240); - remaining = len - (ANALYSIS_BUF_SIZE-tonal->mem_fill); - tonal->hp_ener_accum = (float)downmix_and_resample(downmix, x, - &tonal->inmem[240], tonal->downmix_state, remaining, - offset+ANALYSIS_BUF_SIZE-tonal->mem_fill, c1, c2, C, tonal->Fs); - tonal->mem_fill = 240 + remaining; - if (is_silence) - { - /* On silence, copy the previous analysis. */ - int prev_pos = tonal->write_pos-2; - if (prev_pos < 0) - prev_pos += DETECT_SIZE; - OPUS_COPY(info, &tonal->info[prev_pos], 1); - RESTORE_STACK; - return; - } - opus_fft(kfft, in, out, tonal->arch); -#ifndef FIXED_POINT - /* If there's any NaN on the input, the entire output will be NaN, so we only need to check one value. */ - if (celt_isnan(out[0].r)) - { - info->valid = 0; - RESTORE_STACK; - return; - } -#endif - - for (i=1;iactivity = 0; - frame_noisiness = 0; - frame_stationarity = 0; - if (!tonal->count) - { - for (b=0;blowE[b] = 1e10; - tonal->highE[b] = -1e10; - } - } - relativeE = 0; - frame_loudness = 0; - /* The energy of the very first band is special because of DC. */ - { - float E = 0; - float X1r, X2r; - X1r = 2*(float)out[0].r; - X2r = 2*(float)out[0].i; - E = X1r*X1r + X2r*X2r; - for (i=1;i<4;i++) - { - float binE = out[i].r*(float)out[i].r + out[N-i].r*(float)out[N-i].r - + out[i].i*(float)out[i].i + out[N-i].i*(float)out[N-i].i; - E += binE; - } - E = SCALE_ENER(E); - band_log2[0] = .5f*1.442695f*(float)log(E+1e-10f); - } - for (b=0;bvalid = 0; - RESTORE_STACK; - return; - } -#endif - - tonal->E[tonal->E_count][b] = E; - frame_noisiness += nE/(1e-15f+E); - - frame_loudness += (float)sqrt(E+1e-10f); - logE[b] = (float)log(E+1e-10f); - band_log2[b+1] = .5f*1.442695f*(float)log(E+1e-10f); - tonal->logE[tonal->E_count][b] = logE[b]; - if (tonal->count==0) - tonal->highE[b] = tonal->lowE[b] = logE[b]; - if (tonal->highE[b] > tonal->lowE[b] + 7.5) - { - if (tonal->highE[b] - logE[b] > logE[b] - tonal->lowE[b]) - tonal->highE[b] -= .01f; - else - tonal->lowE[b] += .01f; - } - if (logE[b] > tonal->highE[b]) - { - tonal->highE[b] = logE[b]; - tonal->lowE[b] = MAX32(tonal->highE[b]-15, tonal->lowE[b]); - } else if (logE[b] < tonal->lowE[b]) - { - tonal->lowE[b] = logE[b]; - tonal->highE[b] = MIN32(tonal->lowE[b]+15, tonal->highE[b]); - } - relativeE += (logE[b]-tonal->lowE[b])/(1e-5f + (tonal->highE[b]-tonal->lowE[b])); - - L1=L2=0; - for (i=0;iE[i][b]); - L2 += tonal->E[i][b]; - } - - stationarity = MIN16(0.99f,L1/(float)sqrt(1e-15+NB_FRAMES*L2)); - stationarity *= stationarity; - stationarity *= stationarity; - frame_stationarity += stationarity; - /*band_tonality[b] = tE/(1e-15+E)*/; - band_tonality[b] = MAX16(tE/(1e-15f+E), stationarity*tonal->prev_band_tonality[b]); -#if 0 - if (b>=NB_TONAL_SKIP_BANDS) - { - frame_tonality += tweight[b]*band_tonality[b]; - tw_sum += tweight[b]; - } -#else - frame_tonality += band_tonality[b]; - if (b>=NB_TBANDS-NB_TONAL_SKIP_BANDS) - frame_tonality -= band_tonality[b-NB_TBANDS+NB_TONAL_SKIP_BANDS]; -#endif - max_frame_tonality = MAX16(max_frame_tonality, (1.f+.03f*(b-NB_TBANDS))*frame_tonality); - slope += band_tonality[b]*(b-8); - /*printf("%f %f ", band_tonality[b], stationarity);*/ - tonal->prev_band_tonality[b] = band_tonality[b]; - } - - leakage_from[0] = band_log2[0]; - leakage_to[0] = band_log2[0] - LEAKAGE_OFFSET; - for (b=1;b=0;b--) - { - float leak_slope = LEAKAGE_SLOPE*(tbands[b+1]-tbands[b])/4; - leakage_from[b] = MIN16(leakage_from[b+1]+leak_slope, leakage_from[b]); - leakage_to[b] = MAX16(leakage_to[b+1]-leak_slope, leakage_to[b]); - } - celt_assert(NB_TBANDS+1 <= LEAK_BANDS); - for (b=0;bleak_boost[b] = IMIN(255, (int)floor(.5 + 64.f*boost)); - } - for (;bleak_boost[b] = 0; - - for (i=0;ilogE[i][k] - tonal->logE[j][k]; - dist += tmp*tmp; - } - if (j!=i) - mindist = MIN32(mindist, dist); - } - spec_variability += mindist; - } - spec_variability = (float)sqrt(spec_variability/NB_FRAMES/NB_TBANDS); - bandwidth_mask = 0; - bandwidth = 0; - maxE = 0; - noise_floor = 5.7e-4f/(1<<(IMAX(0,lsb_depth-8))); - noise_floor *= noise_floor; - below_max_pitch=0; - above_max_pitch=0; - for (b=0;bmeanE[b] = MAX32((1-alphaE2)*tonal->meanE[b], E); - Em = MAX32(E, tonal->meanE[b]); - /* Consider the band "active" only if all these conditions are met: - 1) less than 90 dB below the peak band (maximal masking possible considering - both the ATH and the loudness-dependent slope of the spreading function) - 2) above the PCM quantization noise floor - We use b+1 because the first CELT band isn't included in tbands[] - */ - if (E*1e9f > maxE && (Em > 3*noise_floor*(band_end-band_start) || E > noise_floor*(band_end-band_start))) - bandwidth = b+1; - /* Check if the band is masked (see below). */ - is_masked[b] = E < (tonal->prev_bandwidth >= b+1 ? .01f : .05f)*bandwidth_mask; - /* Use a simple follower with 13 dB/Bark slope for spreading function. */ - bandwidth_mask = MAX32(.05f*bandwidth_mask, E); - } - /* Special case for the last two bands, for which we don't have spectrum but only - the energy above 12 kHz. The difficulty here is that the high-pass we use - leaks some LF energy, so we need to increase the threshold without accidentally cutting - off the band. */ - if (tonal->Fs == 48000) { - float noise_ratio; - float Em; - float E = hp_ener*(1.f/(60*60)); - noise_ratio = tonal->prev_bandwidth==20 ? 10.f : 30.f; - -#ifdef FIXED_POINT - /* silk_resampler_down2_hp() shifted right by an extra 8 bits. */ - E *= 256.f*(1.f/Q15ONE)*(1.f/Q15ONE); -#endif - above_max_pitch += E; - tonal->meanE[b] = MAX32((1-alphaE2)*tonal->meanE[b], E); - Em = MAX32(E, tonal->meanE[b]); - if (Em > 3*noise_ratio*noise_floor*160 || E > noise_ratio*noise_floor*160) - bandwidth = 20; - /* Check if the band is masked (see below). */ - is_masked[b] = E < (tonal->prev_bandwidth == 20 ? .01f : .05f)*bandwidth_mask; - } - if (above_max_pitch > below_max_pitch) - info->max_pitch_ratio = below_max_pitch/above_max_pitch; - else - info->max_pitch_ratio = 1; - /* In some cases, resampling aliasing can create a small amount of energy in the first band - being cut. So if the last band is masked, we don't include it. */ - if (bandwidth == 20 && is_masked[NB_TBANDS]) - bandwidth-=2; - else if (bandwidth > 0 && bandwidth <= NB_TBANDS && is_masked[bandwidth-1]) - bandwidth--; - if (tonal->count<=2) - bandwidth = 20; - frame_loudness = 20*(float)log10(frame_loudness); - tonal->Etracker = MAX32(tonal->Etracker-.003f, frame_loudness); - tonal->lowECount *= (1-alphaE); - if (frame_loudness < tonal->Etracker-30) - tonal->lowECount += alphaE; - - for (i=0;i<8;i++) - { - float sum=0; - for (b=0;b<16;b++) - sum += dct_table[i*16+b]*logE[b]; - BFCC[i] = sum; - } - for (i=0;i<8;i++) - { - float sum=0; - for (b=0;b<16;b++) - sum += dct_table[i*16+b]*.5f*(tonal->highE[b]+tonal->lowE[b]); - midE[i] = sum; - } - - frame_stationarity /= NB_TBANDS; - relativeE /= NB_TBANDS; - if (tonal->count<10) - relativeE = .5f; - frame_noisiness /= NB_TBANDS; -#if 1 - info->activity = frame_noisiness + (1-frame_noisiness)*relativeE; -#else - info->activity = .5*(1+frame_noisiness-frame_stationarity); -#endif - frame_tonality = (max_frame_tonality/(NB_TBANDS-NB_TONAL_SKIP_BANDS)); - frame_tonality = MAX16(frame_tonality, tonal->prev_tonality*.8f); - tonal->prev_tonality = frame_tonality; - - slope /= 8*8; - info->tonality_slope = slope; - - tonal->E_count = (tonal->E_count+1)%NB_FRAMES; - tonal->count = IMIN(tonal->count+1, ANALYSIS_COUNT_MAX); - info->tonality = frame_tonality; - - for (i=0;i<4;i++) - features[i] = -0.12299f*(BFCC[i]+tonal->mem[i+24]) + 0.49195f*(tonal->mem[i]+tonal->mem[i+16]) + 0.69693f*tonal->mem[i+8] - 1.4349f*tonal->cmean[i]; - - for (i=0;i<4;i++) - tonal->cmean[i] = (1-alpha)*tonal->cmean[i] + alpha*BFCC[i]; - - for (i=0;i<4;i++) - features[4+i] = 0.63246f*(BFCC[i]-tonal->mem[i+24]) + 0.31623f*(tonal->mem[i]-tonal->mem[i+16]); - for (i=0;i<3;i++) - features[8+i] = 0.53452f*(BFCC[i]+tonal->mem[i+24]) - 0.26726f*(tonal->mem[i]+tonal->mem[i+16]) -0.53452f*tonal->mem[i+8]; - - if (tonal->count > 5) - { - for (i=0;i<9;i++) - tonal->std[i] = (1-alpha)*tonal->std[i] + alpha*features[i]*features[i]; - } - for (i=0;i<4;i++) - features[i] = BFCC[i]-midE[i]; - - for (i=0;i<8;i++) - { - tonal->mem[i+24] = tonal->mem[i+16]; - tonal->mem[i+16] = tonal->mem[i+8]; - tonal->mem[i+8] = tonal->mem[i]; - tonal->mem[i] = BFCC[i]; - } - for (i=0;i<9;i++) - features[11+i] = (float)sqrt(tonal->std[i]) - std_feature_bias[i]; - features[18] = spec_variability - 0.78f; - features[20] = info->tonality - 0.154723f; - features[21] = info->activity - 0.724643f; - features[22] = frame_stationarity - 0.743717f; - features[23] = info->tonality_slope + 0.069216f; - features[24] = tonal->lowECount - 0.067930f; - - compute_dense(&layer0, layer_out, features); - compute_gru(&layer1, tonal->rnn_state, layer_out); - compute_dense(&layer2, frame_probs, tonal->rnn_state); - - /* Probability of speech or music vs noise */ - info->activity_probability = frame_probs[1]; - info->music_prob = frame_probs[0]; - - /*printf("%f %f %f\n", frame_probs[0], frame_probs[1], info->music_prob);*/ -#ifdef MLP_TRAINING - for (i=0;i<25;i++) - printf("%f ", features[i]); - printf("\n"); -#endif - - info->bandwidth = bandwidth; - tonal->prev_bandwidth = bandwidth; - /*printf("%d %d\n", info->bandwidth, info->opus_bandwidth);*/ - info->noisiness = frame_noisiness; - info->valid = 1; - RESTORE_STACK; -} - -void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm, - int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs, - int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info) -{ - int offset; - int pcm_len; - - analysis_frame_size -= analysis_frame_size&1; - if (analysis_pcm != NULL) - { - /* Avoid overflow/wrap-around of the analysis buffer */ - analysis_frame_size = IMIN((DETECT_SIZE-5)*Fs/50, analysis_frame_size); - - pcm_len = analysis_frame_size - analysis->analysis_offset; - offset = analysis->analysis_offset; - while (pcm_len>0) { - tonality_analysis(analysis, celt_mode, analysis_pcm, IMIN(Fs/50, pcm_len), offset, c1, c2, C, lsb_depth, downmix); - offset += Fs/50; - pcm_len -= Fs/50; - } - analysis->analysis_offset = analysis_frame_size; - - analysis->analysis_offset -= frame_size; - } - - tonality_get_info(analysis, analysis_info, frame_size); -} - -#endif /* DISABLE_FLOAT_API */ diff --git a/Engine/lib/opus/src/analysis.h b/Engine/lib/opus/src/analysis.h deleted file mode 100644 index 0b66555f2..000000000 --- a/Engine/lib/opus/src/analysis.h +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright (c) 2011 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 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. -*/ - -#ifndef ANALYSIS_H -#define ANALYSIS_H - -#include "celt.h" -#include "opus_private.h" -#include "mlp.h" - -#define NB_FRAMES 8 -#define NB_TBANDS 18 -#define ANALYSIS_BUF_SIZE 720 /* 30 ms at 24 kHz */ - -/* At that point we can stop counting frames because it no longer matters. */ -#define ANALYSIS_COUNT_MAX 10000 - -#define DETECT_SIZE 100 - -/* Uncomment this to print the MLP features on stdout. */ -/*#define MLP_TRAINING*/ - -typedef struct { - int arch; - int application; - opus_int32 Fs; -#define TONALITY_ANALYSIS_RESET_START angle - float angle[240]; - float d_angle[240]; - float d2_angle[240]; - opus_val32 inmem[ANALYSIS_BUF_SIZE]; - int mem_fill; /* number of usable samples in the buffer */ - float prev_band_tonality[NB_TBANDS]; - float prev_tonality; - int prev_bandwidth; - float E[NB_FRAMES][NB_TBANDS]; - float logE[NB_FRAMES][NB_TBANDS]; - float lowE[NB_TBANDS]; - float highE[NB_TBANDS]; - float meanE[NB_TBANDS+1]; - float mem[32]; - float cmean[8]; - float std[9]; - float Etracker; - float lowECount; - int E_count; - int count; - int analysis_offset; - int write_pos; - int read_pos; - int read_subframe; - float hp_ener_accum; - int initialized; - float rnn_state[MAX_NEURONS]; - opus_val32 downmix_state[3]; - AnalysisInfo info[DETECT_SIZE]; -} TonalityAnalysisState; - -/** Initialize a TonalityAnalysisState struct. - * - * This performs some possibly slow initialization steps which should - * not be repeated every analysis step. No allocated memory is retained - * by the state struct, so no cleanup call is required. - */ -void tonality_analysis_init(TonalityAnalysisState *analysis, opus_int32 Fs); - -/** Reset a TonalityAnalysisState stuct. - * - * Call this when there's a discontinuity in the data. - */ -void tonality_analysis_reset(TonalityAnalysisState *analysis); - -void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len); - -void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm, - int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs, - int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info); - -#endif diff --git a/Engine/lib/opus/src/mapping_matrix.c b/Engine/lib/opus/src/mapping_matrix.c deleted file mode 100644 index 31298af05..000000000 --- a/Engine/lib/opus/src/mapping_matrix.c +++ /dev/null @@ -1,378 +0,0 @@ -/* Copyright (c) 2017 Google Inc. - Written by Andrew Allen */ -/* - 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 "arch.h" -#include "float_cast.h" -#include "opus_private.h" -#include "opus_defines.h" -#include "mapping_matrix.h" - -#define MATRIX_INDEX(nb_rows, row, col) (nb_rows * col + row) - -opus_int32 mapping_matrix_get_size(int rows, int cols) -{ - opus_int32 size; - - /* Mapping Matrix must only support up to 255 channels in or out. - * Additionally, the total cell count must be <= 65004 octets in order - * for the matrix to be stored in an OGG header. - */ - if (rows > 255 || cols > 255) - return 0; - size = rows * (opus_int32)cols * sizeof(opus_int16); - if (size > 65004) - return 0; - - return align(sizeof(MappingMatrix)) + align(size); -} - -opus_int16 *mapping_matrix_get_data(const MappingMatrix *matrix) -{ - /* void* cast avoids clang -Wcast-align warning */ - return (opus_int16*)(void*)((char*)matrix + align(sizeof(MappingMatrix))); -} - -void mapping_matrix_init(MappingMatrix * const matrix, - int rows, int cols, int gain, const opus_int16 *data, opus_int32 data_size) -{ - int i; - opus_int16 *ptr; - -#if !defined(ENABLE_ASSERTIONS) - (void)data_size; -#endif - celt_assert(align(data_size) == align(rows * cols * sizeof(opus_int16))); - - matrix->rows = rows; - matrix->cols = cols; - matrix->gain = gain; - ptr = mapping_matrix_get_data(matrix); - for (i = 0; i < rows * cols; i++) - { - ptr[i] = data[i]; - } -} - -#ifndef DISABLE_FLOAT_API -void mapping_matrix_multiply_channel_in_float( - const MappingMatrix *matrix, - const float *input, - int input_rows, - opus_val16 *output, - int output_row, - int output_rows, - int frame_size) -{ - /* Matrix data is ordered col-wise. */ - opus_int16* matrix_data; - int i, col; - - celt_assert(input_rows <= matrix->cols && output_rows <= matrix->rows); - - matrix_data = mapping_matrix_get_data(matrix); - - for (i = 0; i < frame_size; i++) - { - float tmp = 0; - for (col = 0; col < input_rows; col++) - { - tmp += - matrix_data[MATRIX_INDEX(matrix->rows, output_row, col)] * - input[MATRIX_INDEX(input_rows, col, i)]; - } -#if defined(FIXED_POINT) - output[output_rows * i] = FLOAT2INT16((1/32768.f)*tmp); -#else - output[output_rows * i] = (1/32768.f)*tmp; -#endif - } -} - -void mapping_matrix_multiply_channel_out_float( - const MappingMatrix *matrix, - const opus_val16 *input, - int input_row, - int input_rows, - float *output, - int output_rows, - int frame_size -) -{ - /* Matrix data is ordered col-wise. */ - opus_int16* matrix_data; - int i, row; - float input_sample; - - celt_assert(input_rows <= matrix->cols && output_rows <= matrix->rows); - - matrix_data = mapping_matrix_get_data(matrix); - - for (i = 0; i < frame_size; i++) - { -#if defined(FIXED_POINT) - input_sample = (1/32768.f)*input[input_rows * i]; -#else - input_sample = input[input_rows * i]; -#endif - for (row = 0; row < output_rows; row++) - { - float tmp = - (1/32768.f)*matrix_data[MATRIX_INDEX(matrix->rows, row, input_row)] * - input_sample; - output[MATRIX_INDEX(output_rows, row, i)] += tmp; - } - } -} -#endif /* DISABLE_FLOAT_API */ - -void mapping_matrix_multiply_channel_in_short( - const MappingMatrix *matrix, - const opus_int16 *input, - int input_rows, - opus_val16 *output, - int output_row, - int output_rows, - int frame_size) -{ - /* Matrix data is ordered col-wise. */ - opus_int16* matrix_data; - int i, col; - - celt_assert(input_rows <= matrix->cols && output_rows <= matrix->rows); - - matrix_data = mapping_matrix_get_data(matrix); - - for (i = 0; i < frame_size; i++) - { - opus_val32 tmp = 0; - for (col = 0; col < input_rows; col++) - { -#if defined(FIXED_POINT) - tmp += - ((opus_int32)matrix_data[MATRIX_INDEX(matrix->rows, output_row, col)] * - (opus_int32)input[MATRIX_INDEX(input_rows, col, i)]) >> 8; -#else - tmp += - matrix_data[MATRIX_INDEX(matrix->rows, output_row, col)] * - input[MATRIX_INDEX(input_rows, col, i)]; -#endif - } -#if defined(FIXED_POINT) - output[output_rows * i] = (opus_int16)((tmp + 64) >> 7); -#else - output[output_rows * i] = (1/(32768.f*32768.f))*tmp; -#endif - } -} - -void mapping_matrix_multiply_channel_out_short( - const MappingMatrix *matrix, - const opus_val16 *input, - int input_row, - int input_rows, - opus_int16 *output, - int output_rows, - int frame_size) -{ - /* Matrix data is ordered col-wise. */ - opus_int16* matrix_data; - int i, row; - opus_int32 input_sample; - - celt_assert(input_rows <= matrix->cols && output_rows <= matrix->rows); - - matrix_data = mapping_matrix_get_data(matrix); - - for (i = 0; i < frame_size; i++) - { -#if defined(FIXED_POINT) - input_sample = (opus_int32)input[input_rows * i]; -#else - input_sample = (opus_int32)FLOAT2INT16(input[input_rows * i]); -#endif - for (row = 0; row < output_rows; row++) - { - opus_int32 tmp = - (opus_int32)matrix_data[MATRIX_INDEX(matrix->rows, row, input_row)] * - input_sample; - output[MATRIX_INDEX(output_rows, row, i)] += (tmp + 16384) >> 15; - } - } -} - -const MappingMatrix mapping_matrix_foa_mixing = { 6, 6, 0 }; -const opus_int16 mapping_matrix_foa_mixing_data[36] = { - 16384, 0, -16384, 23170, 0, 0, 16384, 23170, - 16384, 0, 0, 0, 16384, 0, -16384, -23170, - 0, 0, 16384, -23170, 16384, 0, 0, 0, - 0, 0, 0, 0, 32767, 0, 0, 0, - 0, 0, 0, 32767 -}; - -const MappingMatrix mapping_matrix_soa_mixing = { 11, 11, 0 }; -const opus_int16 mapping_matrix_soa_mixing_data[121] = { - 10923, 7723, 13377, -13377, 11585, 9459, 7723, -16384, - -6689, 0, 0, 10923, 7723, 13377, 13377, -11585, - 9459, 7723, 16384, -6689, 0, 0, 10923, -15447, - 13377, 0, 0, -18919, 7723, 0, 13377, 0, - 0, 10923, 7723, -13377, -13377, 11585, -9459, 7723, - 16384, -6689, 0, 0, 10923, -7723, 0, 13377, - -16384, 0, -15447, 0, 9459, 0, 0, 10923, - -7723, 0, -13377, 16384, 0, -15447, 0, 9459, - 0, 0, 10923, 15447, 0, 0, 0, 0, - -15447, 0, -18919, 0, 0, 10923, 7723, -13377, - 13377, -11585, -9459, 7723, -16384, -6689, 0, 0, - 10923, -15447, -13377, 0, 0, 18919, 7723, 0, - 13377, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 32767, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 32767 -}; - -const MappingMatrix mapping_matrix_toa_mixing = { 18, 18, 0 }; -const opus_int16 mapping_matrix_toa_mixing_data[324] = { - 8208, 0, -881, 14369, 0, 0, -8192, -4163, - 13218, 0, 0, 0, 11095, -8836, -6218, 14833, - 0, 0, 8208, -10161, 881, 10161, -13218, -2944, - -8192, 2944, 0, -10488, -6218, 6248, -11095, -6248, - 0, -10488, 0, 0, 8208, 10161, 881, -10161, - -13218, 2944, -8192, -2944, 0, 10488, -6218, -6248, - -11095, 6248, 0, 10488, 0, 0, 8176, 5566, - -11552, 5566, 9681, -11205, 8192, -11205, 0, 4920, - -15158, 9756, -3334, 9756, 0, -4920, 0, 0, - 8176, 7871, 11552, 0, 0, 15846, 8192, 0, - -9681, -6958, 0, 13797, 3334, 0, -15158, 0, - 0, 0, 8176, 0, 11552, 7871, 0, 0, - 8192, 15846, 9681, 0, 0, 0, 3334, 13797, - 15158, 6958, 0, 0, 8176, 5566, -11552, -5566, - -9681, -11205, 8192, 11205, 0, 4920, 15158, 9756, - -3334, -9756, 0, 4920, 0, 0, 8208, 14369, - -881, 0, 0, -4163, -8192, 0, -13218, -14833, - 0, -8836, 11095, 0, 6218, 0, 0, 0, - 8208, 10161, 881, 10161, 13218, 2944, -8192, 2944, - 0, 10488, 6218, -6248, -11095, -6248, 0, -10488, - 0, 0, 8208, -14369, -881, 0, 0, 4163, - -8192, 0, -13218, 14833, 0, 8836, 11095, 0, - 6218, 0, 0, 0, 8208, 0, -881, -14369, - 0, 0, -8192, 4163, 13218, 0, 0, 0, - 11095, 8836, -6218, -14833, 0, 0, 8176, -5566, - -11552, 5566, -9681, 11205, 8192, -11205, 0, -4920, - 15158, -9756, -3334, 9756, 0, -4920, 0, 0, - 8176, 0, 11552, -7871, 0, 0, 8192, -15846, - 9681, 0, 0, 0, 3334, -13797, 15158, -6958, - 0, 0, 8176, -7871, 11552, 0, 0, -15846, - 8192, 0, -9681, 6958, 0, -13797, 3334, 0, - -15158, 0, 0, 0, 8176, -5566, -11552, -5566, - 9681, 11205, 8192, 11205, 0, -4920, -15158, -9756, - -3334, -9756, 0, 4920, 0, 0, 8208, -10161, - 881, -10161, 13218, -2944, -8192, -2944, 0, -10488, - 6218, 6248, -11095, 6248, 0, 10488, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 32767, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 32767 -}; - -const MappingMatrix mapping_matrix_foa_demixing = { 6, 6, 0 }; -const opus_int16 mapping_matrix_foa_demixing_data[36] = { - 16384, 16384, 16384, 16384, 0, 0, 0, 23170, - 0, -23170, 0, 0, -16384, 16384, -16384, 16384, - 0, 0, 23170, 0, -23170, 0, 0, 0, - 0, 0, 0, 0, 32767, 0, 0, 0, - 0, 0, 0, 32767 -}; - -const MappingMatrix mapping_matrix_soa_demixing = { 11, 11, 3050 }; -const opus_int16 mapping_matrix_soa_demixing_data[121] = { - 2771, 2771, 2771, 2771, 2771, 2771, 2771, 2771, - 2771, 0, 0, 10033, 10033, -20066, 10033, 14189, - 14189, -28378, 10033, -20066, 0, 0, 3393, 3393, - 3393, -3393, 0, 0, 0, -3393, -3393, 0, - 0, -17378, 17378, 0, -17378, -24576, 24576, 0, - 17378, 0, 0, 0, -14189, 14189, 0, -14189, - -28378, 28378, 0, 14189, 0, 0, 0, 2399, - 2399, -4799, -2399, 0, 0, 0, -2399, 4799, - 0, 0, 1959, 1959, 1959, 1959, -3918, -3918, - -3918, 1959, 1959, 0, 0, -4156, 4156, 0, - 4156, 0, 0, 0, -4156, 0, 0, 0, - 8192, 8192, -16384, 8192, 16384, 16384, -32768, 8192, - -16384, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8312, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 8312 -}; - -const MappingMatrix mapping_matrix_toa_demixing = { 18, 18, 0 }; -const opus_int16 mapping_matrix_toa_demixing_data[324] = { - 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, - 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, - 0, 0, 0, -9779, 9779, 6263, 8857, 0, - 6263, 13829, 9779, -13829, 0, -6263, 0, -8857, - -6263, -9779, 0, 0, -3413, 3413, 3413, -11359, - 11359, 11359, -11359, -3413, 3413, -3413, -3413, -11359, - 11359, 11359, -11359, 3413, 0, 0, 13829, 9779, - -9779, 6263, 0, 8857, -6263, 0, 9779, 0, - -13829, 6263, -8857, 0, -6263, -9779, 0, 0, - 0, -15617, -15617, 6406, 0, 0, -6406, 0, - 15617, 0, 0, -6406, 0, 0, 6406, 15617, - 0, 0, 0, -5003, 5003, -10664, 15081, 0, - -10664, -7075, 5003, 7075, 0, 10664, 0, -15081, - 10664, -5003, 0, 0, -8176, -8176, -8176, 8208, - 8208, 8208, 8208, -8176, -8176, -8176, -8176, 8208, - 8208, 8208, 8208, -8176, 0, 0, -7075, 5003, - -5003, -10664, 0, 15081, 10664, 0, 5003, 0, - 7075, -10664, -15081, 0, 10664, -5003, 0, 0, - 15617, 0, 0, 0, -6406, 6406, 0, -15617, - 0, -15617, 15617, 0, 6406, -6406, 0, 0, - 0, 0, 0, -11393, 11393, 2993, -4233, 0, - 2993, -16112, 11393, 16112, 0, -2993, 0, 4233, - -2993, -11393, 0, 0, 0, -9974, -9974, -13617, - 0, 0, 13617, 0, 9974, 0, 0, 13617, - 0, 0, -13617, 9974, 0, 0, 0, 5579, - -5579, 10185, 14403, 0, 10185, -7890, -5579, 7890, - 0, -10185, 0, -14403, -10185, 5579, 0, 0, - 11826, -11826, -11826, -901, 901, 901, -901, 11826, - -11826, 11826, 11826, -901, 901, 901, -901, -11826, - 0, 0, -7890, -5579, 5579, 10185, 0, 14403, - -10185, 0, -5579, 0, 7890, 10185, -14403, 0, - -10185, 5579, 0, 0, -9974, 0, 0, 0, - -13617, 13617, 0, 9974, 0, 9974, -9974, 0, - 13617, -13617, 0, 0, 0, 0, 16112, -11393, - 11393, -2993, 0, 4233, 2993, 0, -11393, 0, - -16112, -2993, -4233, 0, 2993, 11393, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 32767, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 32767 -}; - diff --git a/Engine/lib/opus/src/mapping_matrix.h b/Engine/lib/opus/src/mapping_matrix.h deleted file mode 100644 index 98bc82df3..000000000 --- a/Engine/lib/opus/src/mapping_matrix.h +++ /dev/null @@ -1,133 +0,0 @@ -/* Copyright (c) 2017 Google Inc. - Written by Andrew Allen */ -/* - 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. -*/ - -/** - * @file mapping_matrix.h - * @brief Opus reference implementation mapping matrix API - */ - -#ifndef MAPPING_MATRIX_H -#define MAPPING_MATRIX_H - -#include "opus_types.h" -#include "opus_projection.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct MappingMatrix -{ - int rows; /* number of channels outputted from matrix. */ - int cols; /* number of channels inputted to matrix. */ - int gain; /* in dB. S7.8-format. */ - /* Matrix cell data goes here using col-wise ordering. */ -} MappingMatrix; - -opus_int32 mapping_matrix_get_size(int rows, int cols); - -opus_int16 *mapping_matrix_get_data(const MappingMatrix *matrix); - -void mapping_matrix_init( - MappingMatrix * const matrix, - int rows, - int cols, - int gain, - const opus_int16 *data, - opus_int32 data_size -); - -#ifndef DISABLE_FLOAT_API -void mapping_matrix_multiply_channel_in_float( - const MappingMatrix *matrix, - const float *input, - int input_rows, - opus_val16 *output, - int output_row, - int output_rows, - int frame_size -); - -void mapping_matrix_multiply_channel_out_float( - const MappingMatrix *matrix, - const opus_val16 *input, - int input_row, - int input_rows, - float *output, - int output_rows, - int frame_size -); -#endif /* DISABLE_FLOAT_API */ - -void mapping_matrix_multiply_channel_in_short( - const MappingMatrix *matrix, - const opus_int16 *input, - int input_rows, - opus_val16 *output, - int output_row, - int output_rows, - int frame_size -); - -void mapping_matrix_multiply_channel_out_short( - const MappingMatrix *matrix, - const opus_val16 *input, - int input_row, - int input_rows, - opus_int16 *output, - int output_rows, - int frame_size -); - -/* Pre-computed mixing and demixing matrices for 1st to 3rd-order ambisonics. - * foa: first-order ambisonics - * soa: second-order ambisonics - * toa: third-order ambisonics - */ -extern const MappingMatrix mapping_matrix_foa_mixing; -extern const opus_int16 mapping_matrix_foa_mixing_data[36]; - -extern const MappingMatrix mapping_matrix_soa_mixing; -extern const opus_int16 mapping_matrix_soa_mixing_data[121]; - -extern const MappingMatrix mapping_matrix_toa_mixing; -extern const opus_int16 mapping_matrix_toa_mixing_data[324]; - -extern const MappingMatrix mapping_matrix_foa_demixing; -extern const opus_int16 mapping_matrix_foa_demixing_data[36]; - -extern const MappingMatrix mapping_matrix_soa_demixing; -extern const opus_int16 mapping_matrix_soa_demixing_data[121]; - -extern const MappingMatrix mapping_matrix_toa_demixing; -extern const opus_int16 mapping_matrix_toa_demixing_data[324]; - -#ifdef __cplusplus -} -#endif - -#endif /* MAPPING_MATRIX_H */ diff --git a/Engine/lib/opus/src/meson.build b/Engine/lib/opus/src/meson.build deleted file mode 100644 index cc07ff06e..000000000 --- a/Engine/lib/opus/src/meson.build +++ /dev/null @@ -1,45 +0,0 @@ -opus_sources = sources['OPUS_SOURCES'] - -opus_sources_float = sources['OPUS_SOURCES_FLOAT'] - -if not disable_float_api - opus_sources += opus_sources_float -endif - -opus_lib_c_args = [] -if host_machine.system() == 'windows' - opus_lib_c_args += ['-DDLL_EXPORT'] -endif - -opus_lib = library('opus', - opus_sources, - version: libversion, - darwin_versions: macosversion, - c_args: opus_lib_c_args, - include_directories: opus_includes, - link_with: [celt_lib, silk_lib], - dependencies: libm, - install: true) - -opus_dep = declare_dependency(link_with: opus_lib, - include_directories: opus_public_includes) - -# Extra uninstalled Opus programs -if not extra_programs.disabled() - foreach prog : ['opus_compare', 'opus_demo', 'repacketizer_demo'] - executable(prog, '@0@.c'.format(prog), - include_directories: opus_includes, - link_with: opus_lib, - dependencies: libm, - install: false) - endforeach - - if opt_custom_modes - executable('opus_custom_demo', '../celt/opus_custom_demo.c', - include_directories: opus_includes, - link_with: opus_lib, - dependencies: libm, - install: false) - endif - -endif diff --git a/Engine/lib/opus/src/mlp.c b/Engine/lib/opus/src/mlp.c deleted file mode 100644 index 964c6a98f..000000000 --- a/Engine/lib/opus/src/mlp.c +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (c) 2008-2011 Octasic Inc. - 2012-2017 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 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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "opus_types.h" -#include "opus_defines.h" -#include "arch.h" -#include "tansig_table.h" -#include "mlp.h" - -static OPUS_INLINE float tansig_approx(float x) -{ - int i; - float y, dy; - float sign=1; - /* Tests are reversed to catch NaNs */ - if (!(x<8)) - return 1; - if (!(x>-8)) - return -1; -#ifndef FIXED_POINT - /* Another check in case of -ffast-math */ - if (celt_isnan(x)) - return 0; -#endif - if (x<0) - { - x=-x; - sign=-1; - } - i = (int)floor(.5f+25*x); - x -= .04f*i; - y = tansig_table[i]; - dy = 1-y*y; - y = y + x*dy*(1 - y*x); - return sign*y; -} - -static OPUS_INLINE float sigmoid_approx(float x) -{ - return .5f + .5f*tansig_approx(.5f*x); -} - -static void gemm_accum(float *out, const opus_int8 *weights, int rows, int cols, int col_stride, const float *x) -{ - int i, j; - for (i=0;inb_inputs; - N = layer->nb_neurons; - stride = N; - for (i=0;ibias[i]; - gemm_accum(output, layer->input_weights, N, M, stride, input); - for (i=0;isigmoid) { - for (i=0;inb_inputs; - N = gru->nb_neurons; - stride = 3*N; - /* Compute update gate. */ - for (i=0;ibias[i]; - gemm_accum(z, gru->input_weights, N, M, stride, input); - gemm_accum(z, gru->recurrent_weights, N, N, stride, state); - for (i=0;ibias[N + i]; - gemm_accum(r, &gru->input_weights[N], N, M, stride, input); - gemm_accum(r, &gru->recurrent_weights[N], N, N, stride, state); - for (i=0;ibias[2*N + i]; - for (i=0;iinput_weights[2*N], N, M, stride, input); - gemm_accum(h, &gru->recurrent_weights[2*N], N, N, stride, tmp); - for (i=0;i=0) - break; - x[i*C] = x[i*C]+a*x[i*C]*x[i*C]; - } - - curr=0; - x0 = x[0]; - while(1) - { - int start, end; - float maxval; - int special=0; - int peak_pos; - for (i=curr;i1 || x[i*C]<-1) - break; - } - if (i==N) - { - a=0; - break; - } - peak_pos = i; - start=end=i; - maxval=ABS16(x[i*C]); - /* Look for first zero crossing before clipping */ - while (start>0 && x[i*C]*x[(start-1)*C]>=0) - start--; - /* Look for first zero crossing after clipping */ - while (end=0) - { - /* Look for other peaks until the next zero-crossing. */ - if (ABS16(x[end*C])>maxval) - { - maxval = ABS16(x[end*C]); - peak_pos = end; - } - end++; - } - /* Detect the special case where we clip before the first zero crossing */ - special = (start==0 && x[i*C]*x[0]>=0); - - /* Compute a such that maxval + a*maxval^2 = 1 */ - a=(maxval-1)/(maxval*maxval); - /* Slightly boost "a" by 2^-22. This is just enough to ensure -ffast-math - does not cause output values larger than +/-1, but small enough not - to matter even for 24-bit output. */ - a += a*2.4e-7f; - if (x[i*C]>0) - a = -a; - /* Apply soft clipping */ - for (i=start;i=2) - { - /* Add a linear ramp from the first sample to the signal peak. - This avoids a discontinuity at the beginning of the frame. */ - float delta; - float offset = x0-x[0]; - delta = offset / peak_pos; - for (i=curr;i>2; - return 2; - } -} - -static int parse_size(const unsigned char *data, opus_int32 len, opus_int16 *size) -{ - if (len<1) - { - *size = -1; - return -1; - } else if (data[0]<252) - { - *size = data[0]; - return 1; - } else if (len<2) - { - *size = -1; - return -1; - } else { - *size = 4*data[1] + data[0]; - return 2; - } -} - -int opus_packet_get_samples_per_frame(const unsigned char *data, - opus_int32 Fs) -{ - int audiosize; - if (data[0]&0x80) - { - audiosize = ((data[0]>>3)&0x3); - audiosize = (Fs<>3)&0x3); - if (audiosize == 3) - audiosize = Fs*60/1000; - else - audiosize = (Fs< len) - return OPUS_INVALID_PACKET; - data += bytes; - last_size = len-size[0]; - break; - /* Multiple CBR/VBR frames (from 0 to 120 ms) */ - default: /*case 3:*/ - if (len<1) - return OPUS_INVALID_PACKET; - /* Number of frames encoded in bits 0 to 5 */ - ch = *data++; - count = ch&0x3F; - if (count <= 0 || framesize*(opus_int32)count > 5760) - return OPUS_INVALID_PACKET; - len--; - /* Padding flag is bit 6 */ - if (ch&0x40) - { - int p; - do { - int tmp; - if (len<=0) - return OPUS_INVALID_PACKET; - p = *data++; - len--; - tmp = p==255 ? 254: p; - len -= tmp; - pad += tmp; - } while (p==255); - } - if (len<0) - return OPUS_INVALID_PACKET; - /* VBR flag is bit 7 */ - cbr = !(ch&0x80); - if (!cbr) - { - /* VBR case */ - last_size = len; - for (i=0;i len) - return OPUS_INVALID_PACKET; - data += bytes; - last_size -= bytes+size[i]; - } - if (last_size<0) - return OPUS_INVALID_PACKET; - } else if (!self_delimited) - { - /* CBR case */ - last_size = len/count; - if (last_size*count!=len) - return OPUS_INVALID_PACKET; - for (i=0;i len) - return OPUS_INVALID_PACKET; - data += bytes; - /* For CBR packets, apply the size to all the frames. */ - if (cbr) - { - if (size[count-1]*count > len) - return OPUS_INVALID_PACKET; - for (i=0;i last_size) - return OPUS_INVALID_PACKET; - } else - { - /* Because it's not encoded explicitly, it's possible the size of the - last packet (or all the packets, for the CBR case) is larger than - 1275. Reject them here.*/ - if (last_size > 1275) - return OPUS_INVALID_PACKET; - size[count-1] = (opus_int16)last_size; - } - - if (payload_offset) - *payload_offset = (int)(data-data0); - - for (i=0;i -#include -#include -#include - -#define OPUS_PI (3.14159265F) - -#define OPUS_COSF(_x) ((float)cos(_x)) -#define OPUS_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 *opus_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 size_t read_pcm16(float **_samples,FILE *_fin,int _nchannels){ - unsigned char buf[1024]; - float *samples; - size_t nsamples; - size_t csamples; - size_t xi; - size_t nread; - samples=NULL; - nsamples=csamples=0; - for(;;){ - nread=fread(buf,2*_nchannels,1024/(2*_nchannels),_fin); - if(nread<=0)break; - if(nsamples+nread>csamples){ - do csamples=csamples<<1|1; - while(nsamples+nread>csamples); - samples=(float *)opus_realloc(samples, - _nchannels*csamples*sizeof(*samples)); - } - for(xi=0;xi=_window_sz)ti-=_window_sz; - } - re*=_downsample; - im*=_downsample; - _ps[(xi*ps_sz+xj)*_nchannels+ci]=re*re+im*im+100000; - p[ci]+=_ps[(xi*ps_sz+xj)*_nchannels+ci]; - } - } - if(_out){ - _out[(xi*_nbands+bi)*_nchannels]=p[0]/(_bands[bi+1]-_bands[bi]); - if(_nchannels==2){ - _out[(xi*_nbands+bi)*_nchannels+1]=p[1]/(_bands[bi+1]-_bands[bi]); - } - } - } - } - free(window); -} - -#define NBANDS (21) -#define NFREQS (240) - -/*Bands on which we compute the pseudo-NMR (Bark-derived - CELT bands).*/ -static const int BANDS[NBANDS+1]={ - 0,2,4,6,8,10,12,14,16,20,24,28,32,40,48,56,68,80,96,120,156,200 -}; - -#define TEST_WIN_SIZE (480) -#define TEST_WIN_STEP (120) - -int main(int _argc,const char **_argv){ - FILE *fin1; - FILE *fin2; - float *x; - float *y; - float *xb; - float *X; - float *Y; - double err; - float Q; - size_t xlength; - size_t ylength; - size_t nframes; - size_t xi; - int ci; - int xj; - int bi; - int nchannels; - unsigned rate; - int downsample; - int ybands; - int yfreqs; - int max_compare; - if(_argc<3||_argc>6){ - fprintf(stderr,"Usage: %s [-s] [-r rate2] \n", - _argv[0]); - return EXIT_FAILURE; - } - nchannels=1; - if(strcmp(_argv[1],"-s")==0){ - nchannels=2; - _argv++; - } - rate=48000; - ybands=NBANDS; - yfreqs=NFREQS; - downsample=1; - if(strcmp(_argv[1],"-r")==0){ - rate=atoi(_argv[2]); - if(rate!=8000&&rate!=12000&&rate!=16000&&rate!=24000&&rate!=48000){ - fprintf(stderr, - "Sampling rate must be 8000, 12000, 16000, 24000, or 48000\n"); - return EXIT_FAILURE; - } - downsample=48000/rate; - switch(rate){ - case 8000:ybands=13;break; - case 12000:ybands=15;break; - case 16000:ybands=17;break; - case 24000:ybands=19;break; - } - yfreqs=NFREQS/downsample; - _argv+=2; - } - 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_pcm16(&x,fin1,2); - if(nchannels==1){ - for(xi=0;xi0;){ - for(ci=0;ci0){ - /*Temporal masking: -3 dB/2.5ms slope.*/ - for(bi=0;bi=79&&xj<=81)im*=0.1F; - if(xj==80)im*=0.1F; - Eb+=im; - } - } - Eb /= (BANDS[bi+1]-BANDS[bi])*nchannels; - Ef += Eb*Eb; - } - /*Using a fixed normalization value means we're willing to accept slightly - lower quality for lower sampling rates.*/ - Ef/=NBANDS; - Ef*=Ef; - err+=Ef*Ef; - } - free(xb); - free(X); - free(Y); - err=pow(err/nframes,1.0/16); - Q=100*(1-0.5*log(1+err)/log(1.13)); - if(Q<0){ - fprintf(stderr,"Test vector FAILS\n"); - fprintf(stderr,"Internal weighted error is %f\n",err); - return EXIT_FAILURE; - } - else{ - fprintf(stderr,"Test vector PASSES\n"); - fprintf(stderr, - "Opus quality metric: %.1f %% (internal weighted error is %f)\n",Q,err); - return EXIT_SUCCESS; - } -} diff --git a/Engine/lib/opus/src/opus_decoder.c b/Engine/lib/opus/src/opus_decoder.c deleted file mode 100644 index 6520e748e..000000000 --- a/Engine/lib/opus/src/opus_decoder.c +++ /dev/null @@ -1,1041 +0,0 @@ -/* Copyright (c) 2010 Xiph.Org Foundation, Skype Limited - Written by Jean-Marc Valin and Koen Vos */ -/* - 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 - -#ifndef OPUS_BUILD -# error "OPUS_BUILD _MUST_ be defined to build Opus. This probably means you need other defines as well, as in a config.h. See the included build files for details." -#endif - -#if defined(__GNUC__) && (__GNUC__ >= 2) && !defined(__OPTIMIZE__) && !defined(OPUS_WILL_BE_SLOW) -# pragma message "You appear to be compiling without optimization, if so opus will be very slow." -#endif - -#include -#include "celt.h" -#include "opus.h" -#include "entdec.h" -#include "modes.h" -#include "API.h" -#include "stack_alloc.h" -#include "float_cast.h" -#include "opus_private.h" -#include "os_support.h" -#include "structs.h" -#include "define.h" -#include "mathops.h" -#include "cpu_support.h" - -struct OpusDecoder { - int celt_dec_offset; - int silk_dec_offset; - int channels; - opus_int32 Fs; /** Sampling rate (at the API level) */ - silk_DecControlStruct DecControl; - int decode_gain; - int arch; - - /* Everything beyond this point gets cleared on a reset */ -#define OPUS_DECODER_RESET_START stream_channels - int stream_channels; - - int bandwidth; - int mode; - int prev_mode; - int frame_size; - int prev_redundancy; - int last_packet_duration; -#ifndef FIXED_POINT - opus_val16 softclip_mem[2]; -#endif - - opus_uint32 rangeFinal; -}; - -#if defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS) -static void validate_opus_decoder(OpusDecoder *st) -{ - celt_assert(st->channels == 1 || st->channels == 2); - celt_assert(st->Fs == 48000 || st->Fs == 24000 || st->Fs == 16000 || st->Fs == 12000 || st->Fs == 8000); - celt_assert(st->DecControl.API_sampleRate == st->Fs); - celt_assert(st->DecControl.internalSampleRate == 0 || st->DecControl.internalSampleRate == 16000 || st->DecControl.internalSampleRate == 12000 || st->DecControl.internalSampleRate == 8000); - celt_assert(st->DecControl.nChannelsAPI == st->channels); - celt_assert(st->DecControl.nChannelsInternal == 0 || st->DecControl.nChannelsInternal == 1 || st->DecControl.nChannelsInternal == 2); - celt_assert(st->DecControl.payloadSize_ms == 0 || st->DecControl.payloadSize_ms == 10 || st->DecControl.payloadSize_ms == 20 || st->DecControl.payloadSize_ms == 40 || st->DecControl.payloadSize_ms == 60); -#ifdef OPUS_ARCHMASK - celt_assert(st->arch >= 0); - celt_assert(st->arch <= OPUS_ARCHMASK); -#endif - celt_assert(st->stream_channels == 1 || st->stream_channels == 2); -} -#define VALIDATE_OPUS_DECODER(st) validate_opus_decoder(st) -#else -#define VALIDATE_OPUS_DECODER(st) -#endif - -int opus_decoder_get_size(int channels) -{ - int silkDecSizeBytes, celtDecSizeBytes; - int ret; - if (channels<1 || channels > 2) - return 0; - ret = silk_Get_Decoder_Size( &silkDecSizeBytes ); - if(ret) - return 0; - silkDecSizeBytes = align(silkDecSizeBytes); - celtDecSizeBytes = celt_decoder_get_size(channels); - return align(sizeof(OpusDecoder))+silkDecSizeBytes+celtDecSizeBytes; -} - -int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels) -{ - void *silk_dec; - CELTDecoder *celt_dec; - int ret, silkDecSizeBytes; - - if ((Fs!=48000&&Fs!=24000&&Fs!=16000&&Fs!=12000&&Fs!=8000) - || (channels!=1&&channels!=2)) - return OPUS_BAD_ARG; - - OPUS_CLEAR((char*)st, opus_decoder_get_size(channels)); - /* Initialize SILK decoder */ - ret = silk_Get_Decoder_Size(&silkDecSizeBytes); - if (ret) - return OPUS_INTERNAL_ERROR; - - silkDecSizeBytes = align(silkDecSizeBytes); - st->silk_dec_offset = align(sizeof(OpusDecoder)); - st->celt_dec_offset = st->silk_dec_offset+silkDecSizeBytes; - silk_dec = (char*)st+st->silk_dec_offset; - celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset); - st->stream_channels = st->channels = channels; - - st->Fs = Fs; - st->DecControl.API_sampleRate = st->Fs; - st->DecControl.nChannelsAPI = st->channels; - - /* Reset decoder */ - ret = silk_InitDecoder( silk_dec ); - if(ret)return OPUS_INTERNAL_ERROR; - - /* Initialize CELT decoder */ - ret = celt_decoder_init(celt_dec, Fs, channels); - if(ret!=OPUS_OK)return OPUS_INTERNAL_ERROR; - - celt_decoder_ctl(celt_dec, CELT_SET_SIGNALLING(0)); - - st->prev_mode = 0; - st->frame_size = Fs/400; - st->arch = opus_select_arch(); - return OPUS_OK; -} - -OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error) -{ - int ret; - OpusDecoder *st; - if ((Fs!=48000&&Fs!=24000&&Fs!=16000&&Fs!=12000&&Fs!=8000) - || (channels!=1&&channels!=2)) - { - if (error) - *error = OPUS_BAD_ARG; - return NULL; - } - st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels)); - if (st == NULL) - { - if (error) - *error = OPUS_ALLOC_FAIL; - return NULL; - } - ret = opus_decoder_init(st, Fs, channels); - if (error) - *error = ret; - if (ret != OPUS_OK) - { - opus_free(st); - st = NULL; - } - return st; -} - -static void smooth_fade(const opus_val16 *in1, const opus_val16 *in2, - opus_val16 *out, int overlap, int channels, - const opus_val16 *window, opus_int32 Fs) -{ - int i, c; - int inc = 48000/Fs; - for (c=0;csilk_dec_offset; - celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset); - F20 = st->Fs/50; - F10 = F20>>1; - F5 = F10>>1; - F2_5 = F5>>1; - if (frame_size < F2_5) - { - RESTORE_STACK; - return OPUS_BUFFER_TOO_SMALL; - } - /* Limit frame_size to avoid excessive stack allocations. */ - frame_size = IMIN(frame_size, st->Fs/25*3); - /* Payloads of 1 (2 including ToC) or 0 trigger the PLC/DTX */ - if (len<=1) - { - data = NULL; - /* In that case, don't conceal more than what the ToC says */ - frame_size = IMIN(frame_size, st->frame_size); - } - if (data != NULL) - { - audiosize = st->frame_size; - mode = st->mode; - bandwidth = st->bandwidth; - ec_dec_init(&dec,(unsigned char*)data,len); - } else { - audiosize = frame_size; - /* Run PLC using last used mode (CELT if we ended with CELT redundancy) */ - mode = st->prev_redundancy ? MODE_CELT_ONLY : st->prev_mode; - bandwidth = 0; - - if (mode == 0) - { - /* If we haven't got any packet yet, all we can do is return zeros */ - for (i=0;ichannels;i++) - pcm[i] = 0; - RESTORE_STACK; - return audiosize; - } - - /* Avoids trying to run the PLC on sizes other than 2.5 (CELT), 5 (CELT), - 10, or 20 (e.g. 12.5 or 30 ms). */ - if (audiosize > F20) - { - do { - int ret = opus_decode_frame(st, NULL, 0, pcm, IMIN(audiosize, F20), 0); - if (ret<0) - { - RESTORE_STACK; - return ret; - } - pcm += ret*st->channels; - audiosize -= ret; - } while (audiosize > 0); - RESTORE_STACK; - return frame_size; - } else if (audiosize < F20) - { - if (audiosize > F10) - audiosize = F10; - else if (mode != MODE_SILK_ONLY && audiosize > F5 && audiosize < F10) - audiosize = F5; - } - } - - /* In fixed-point, we can tell CELT to do the accumulation on top of the - SILK PCM buffer. This saves some stack space. */ -#ifdef FIXED_POINT - celt_accum = (mode != MODE_CELT_ONLY) && (frame_size >= F10); -#else - celt_accum = 0; -#endif - - pcm_transition_silk_size = ALLOC_NONE; - pcm_transition_celt_size = ALLOC_NONE; - if (data!=NULL && st->prev_mode > 0 && ( - (mode == MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY && !st->prev_redundancy) - || (mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) ) - ) - { - transition = 1; - /* Decide where to allocate the stack memory for pcm_transition */ - if (mode == MODE_CELT_ONLY) - pcm_transition_celt_size = F5*st->channels; - else - pcm_transition_silk_size = F5*st->channels; - } - ALLOC(pcm_transition_celt, pcm_transition_celt_size, opus_val16); - if (transition && mode == MODE_CELT_ONLY) - { - pcm_transition = pcm_transition_celt; - opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0); - } - if (audiosize > frame_size) - { - /*fprintf(stderr, "PCM buffer too small: %d vs %d (mode = %d)\n", audiosize, frame_size, mode);*/ - RESTORE_STACK; - return OPUS_BAD_ARG; - } else { - frame_size = audiosize; - } - - /* Don't allocate any memory when in CELT-only mode */ - pcm_silk_size = (mode != MODE_CELT_ONLY && !celt_accum) ? IMAX(F10, frame_size)*st->channels : ALLOC_NONE; - ALLOC(pcm_silk, pcm_silk_size, opus_int16); - - /* SILK processing */ - if (mode != MODE_CELT_ONLY) - { - int lost_flag, decoded_samples; - opus_int16 *pcm_ptr; -#ifdef FIXED_POINT - if (celt_accum) - pcm_ptr = pcm; - else -#endif - pcm_ptr = pcm_silk; - - if (st->prev_mode==MODE_CELT_ONLY) - silk_InitDecoder( silk_dec ); - - /* The SILK PLC cannot produce frames of less than 10 ms */ - st->DecControl.payloadSize_ms = IMAX(10, 1000 * audiosize / st->Fs); - - if (data != NULL) - { - st->DecControl.nChannelsInternal = st->stream_channels; - if( mode == MODE_SILK_ONLY ) { - if( bandwidth == OPUS_BANDWIDTH_NARROWBAND ) { - st->DecControl.internalSampleRate = 8000; - } else if( bandwidth == OPUS_BANDWIDTH_MEDIUMBAND ) { - st->DecControl.internalSampleRate = 12000; - } else if( bandwidth == OPUS_BANDWIDTH_WIDEBAND ) { - st->DecControl.internalSampleRate = 16000; - } else { - st->DecControl.internalSampleRate = 16000; - celt_assert( 0 ); - } - } else { - /* Hybrid mode */ - st->DecControl.internalSampleRate = 16000; - } - } - - lost_flag = data == NULL ? 1 : 2 * decode_fec; - decoded_samples = 0; - do { - /* Call SILK decoder */ - int first_frame = decoded_samples == 0; - silk_ret = silk_Decode( silk_dec, &st->DecControl, - lost_flag, first_frame, &dec, pcm_ptr, &silk_frame_size, st->arch ); - if( silk_ret ) { - if (lost_flag) { - /* PLC failure should not be fatal */ - silk_frame_size = frame_size; - for (i=0;ichannels;i++) - pcm_ptr[i] = 0; - } else { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - } - pcm_ptr += silk_frame_size * st->channels; - decoded_samples += silk_frame_size; - } while( decoded_samples < frame_size ); - } - - start_band = 0; - if (!decode_fec && mode != MODE_CELT_ONLY && data != NULL - && ec_tell(&dec)+17+20*(mode == MODE_HYBRID) <= 8*len) - { - /* Check if we have a redundant 0-8 kHz band */ - if (mode == MODE_HYBRID) - redundancy = ec_dec_bit_logp(&dec, 12); - else - redundancy = 1; - if (redundancy) - { - celt_to_silk = ec_dec_bit_logp(&dec, 1); - /* redundancy_bytes will be at least two, in the non-hybrid - case due to the ec_tell() check above */ - redundancy_bytes = mode==MODE_HYBRID ? - (opus_int32)ec_dec_uint(&dec, 256)+2 : - len-((ec_tell(&dec)+7)>>3); - len -= redundancy_bytes; - /* This is a sanity check. It should never happen for a valid - packet, so the exact behaviour is not normative. */ - if (len*8 < ec_tell(&dec)) - { - len = 0; - redundancy_bytes = 0; - redundancy = 0; - } - /* Shrink decoder because of raw bits */ - dec.storage -= redundancy_bytes; - } - } - if (mode != MODE_CELT_ONLY) - start_band = 17; - - if (redundancy) - { - transition = 0; - pcm_transition_silk_size=ALLOC_NONE; - } - - ALLOC(pcm_transition_silk, pcm_transition_silk_size, opus_val16); - - if (transition && mode != MODE_CELT_ONLY) - { - pcm_transition = pcm_transition_silk; - opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0); - } - - - if (bandwidth) - { - int endband=21; - - switch(bandwidth) - { - case OPUS_BANDWIDTH_NARROWBAND: - endband = 13; - break; - case OPUS_BANDWIDTH_MEDIUMBAND: - case OPUS_BANDWIDTH_WIDEBAND: - endband = 17; - break; - case OPUS_BANDWIDTH_SUPERWIDEBAND: - endband = 19; - break; - case OPUS_BANDWIDTH_FULLBAND: - endband = 21; - break; - default: - celt_assert(0); - break; - } - MUST_SUCCEED(celt_decoder_ctl(celt_dec, CELT_SET_END_BAND(endband))); - } - MUST_SUCCEED(celt_decoder_ctl(celt_dec, CELT_SET_CHANNELS(st->stream_channels))); - - /* Only allocation memory for redundancy if/when needed */ - redundant_audio_size = redundancy ? F5*st->channels : ALLOC_NONE; - ALLOC(redundant_audio, redundant_audio_size, opus_val16); - - /* 5 ms redundant frame for CELT->SILK*/ - if (redundancy && celt_to_silk) - { - /* If the previous frame did not use CELT (the first redundancy frame in - a transition from SILK may have been lost) then the CELT decoder is - stale at this point and the redundancy audio is not useful, however - the final range is still needed (for testing), so the redundancy is - always decoded but the decoded audio may not be used */ - MUST_SUCCEED(celt_decoder_ctl(celt_dec, CELT_SET_START_BAND(0))); - celt_decode_with_ec(celt_dec, data+len, redundancy_bytes, - redundant_audio, F5, NULL, 0); - MUST_SUCCEED(celt_decoder_ctl(celt_dec, OPUS_GET_FINAL_RANGE(&redundant_rng))); - } - - /* MUST be after PLC */ - MUST_SUCCEED(celt_decoder_ctl(celt_dec, CELT_SET_START_BAND(start_band))); - - if (mode != MODE_SILK_ONLY) - { - int celt_frame_size = IMIN(F20, frame_size); - /* Make sure to discard any previous CELT state */ - if (mode != st->prev_mode && st->prev_mode > 0 && !st->prev_redundancy) - MUST_SUCCEED(celt_decoder_ctl(celt_dec, OPUS_RESET_STATE)); - /* Decode CELT */ - celt_ret = celt_decode_with_ec(celt_dec, decode_fec ? NULL : data, - len, pcm, celt_frame_size, &dec, celt_accum); - } else { - unsigned char silence[2] = {0xFF, 0xFF}; - if (!celt_accum) - { - for (i=0;ichannels;i++) - pcm[i] = 0; - } - /* For hybrid -> SILK transitions, we let the CELT MDCT - do a fade-out by decoding a silence frame */ - if (st->prev_mode == MODE_HYBRID && !(redundancy && celt_to_silk && st->prev_redundancy) ) - { - MUST_SUCCEED(celt_decoder_ctl(celt_dec, CELT_SET_START_BAND(0))); - celt_decode_with_ec(celt_dec, silence, 2, pcm, F2_5, NULL, celt_accum); - } - } - - if (mode != MODE_CELT_ONLY && !celt_accum) - { -#ifdef FIXED_POINT - for (i=0;ichannels;i++) - pcm[i] = SAT16(ADD32(pcm[i], pcm_silk[i])); -#else - for (i=0;ichannels;i++) - pcm[i] = pcm[i] + (opus_val16)((1.f/32768.f)*pcm_silk[i]); -#endif - } - - { - const CELTMode *celt_mode; - MUST_SUCCEED(celt_decoder_ctl(celt_dec, CELT_GET_MODE(&celt_mode))); - window = celt_mode->window; - } - - /* 5 ms redundant frame for SILK->CELT */ - if (redundancy && !celt_to_silk) - { - MUST_SUCCEED(celt_decoder_ctl(celt_dec, OPUS_RESET_STATE)); - MUST_SUCCEED(celt_decoder_ctl(celt_dec, CELT_SET_START_BAND(0))); - - celt_decode_with_ec(celt_dec, data+len, redundancy_bytes, redundant_audio, F5, NULL, 0); - MUST_SUCCEED(celt_decoder_ctl(celt_dec, OPUS_GET_FINAL_RANGE(&redundant_rng))); - smooth_fade(pcm+st->channels*(frame_size-F2_5), redundant_audio+st->channels*F2_5, - pcm+st->channels*(frame_size-F2_5), F2_5, st->channels, window, st->Fs); - } - /* 5ms redundant frame for CELT->SILK; ignore if the previous frame did not - use CELT (the first redundancy frame in a transition from SILK may have - been lost) */ - if (redundancy && celt_to_silk && (st->prev_mode != MODE_SILK_ONLY || st->prev_redundancy)) - { - for (c=0;cchannels;c++) - { - for (i=0;ichannels*i+c] = redundant_audio[st->channels*i+c]; - } - smooth_fade(redundant_audio+st->channels*F2_5, pcm+st->channels*F2_5, - pcm+st->channels*F2_5, F2_5, st->channels, window, st->Fs); - } - if (transition) - { - if (audiosize >= F5) - { - for (i=0;ichannels*F2_5;i++) - pcm[i] = pcm_transition[i]; - smooth_fade(pcm_transition+st->channels*F2_5, pcm+st->channels*F2_5, - pcm+st->channels*F2_5, F2_5, - st->channels, window, st->Fs); - } else { - /* Not enough time to do a clean transition, but we do it anyway - This will not preserve amplitude perfectly and may introduce - a bit of temporal aliasing, but it shouldn't be too bad and - that's pretty much the best we can do. In any case, generating this - transition it pretty silly in the first place */ - smooth_fade(pcm_transition, pcm, - pcm, F2_5, - st->channels, window, st->Fs); - } - } - - if(st->decode_gain) - { - opus_val32 gain; - gain = celt_exp2(MULT16_16_P15(QCONST16(6.48814081e-4f, 25), st->decode_gain)); - for (i=0;ichannels;i++) - { - opus_val32 x; - x = MULT16_32_P16(pcm[i],gain); - pcm[i] = SATURATE(x, 32767); - } - } - - if (len <= 1) - st->rangeFinal = 0; - else - st->rangeFinal = dec.rng ^ redundant_rng; - - st->prev_mode = mode; - st->prev_redundancy = redundancy && !celt_to_silk; - - if (celt_ret>=0) - { - if (OPUS_CHECK_ARRAY(pcm, audiosize*st->channels)) - OPUS_PRINT_INT(audiosize); - } - - RESTORE_STACK; - return celt_ret < 0 ? celt_ret : audiosize; - -} - -int opus_decode_native(OpusDecoder *st, const unsigned char *data, - opus_int32 len, opus_val16 *pcm, int frame_size, int decode_fec, - int self_delimited, opus_int32 *packet_offset, int soft_clip) -{ - int i, nb_samples; - int count, offset; - unsigned char toc; - int packet_frame_size, packet_bandwidth, packet_mode, packet_stream_channels; - /* 48 x 2.5 ms = 120 ms */ - opus_int16 size[48]; - VALIDATE_OPUS_DECODER(st); - if (decode_fec<0 || decode_fec>1) - return OPUS_BAD_ARG; - /* For FEC/PLC, frame_size has to be to have a multiple of 2.5 ms */ - if ((decode_fec || len==0 || data==NULL) && frame_size%(st->Fs/400)!=0) - return OPUS_BAD_ARG; - if (len==0 || data==NULL) - { - int pcm_count=0; - do { - int ret; - ret = opus_decode_frame(st, NULL, 0, pcm+pcm_count*st->channels, frame_size-pcm_count, 0); - if (ret<0) - return ret; - pcm_count += ret; - } while (pcm_count < frame_size); - celt_assert(pcm_count == frame_size); - if (OPUS_CHECK_ARRAY(pcm, pcm_count*st->channels)) - OPUS_PRINT_INT(pcm_count); - st->last_packet_duration = pcm_count; - return pcm_count; - } else if (len<0) - return OPUS_BAD_ARG; - - packet_mode = opus_packet_get_mode(data); - packet_bandwidth = opus_packet_get_bandwidth(data); - packet_frame_size = opus_packet_get_samples_per_frame(data, st->Fs); - packet_stream_channels = opus_packet_get_nb_channels(data); - - count = opus_packet_parse_impl(data, len, self_delimited, &toc, NULL, - size, &offset, packet_offset); - if (count<0) - return count; - - data += offset; - - if (decode_fec) - { - int duration_copy; - int ret; - /* If no FEC can be present, run the PLC (recursive call) */ - if (frame_size < packet_frame_size || packet_mode == MODE_CELT_ONLY || st->mode == MODE_CELT_ONLY) - return opus_decode_native(st, NULL, 0, pcm, frame_size, 0, 0, NULL, soft_clip); - /* Otherwise, run the PLC on everything except the size for which we might have FEC */ - duration_copy = st->last_packet_duration; - if (frame_size-packet_frame_size!=0) - { - ret = opus_decode_native(st, NULL, 0, pcm, frame_size-packet_frame_size, 0, 0, NULL, soft_clip); - if (ret<0) - { - st->last_packet_duration = duration_copy; - return ret; - } - celt_assert(ret==frame_size-packet_frame_size); - } - /* Complete with FEC */ - st->mode = packet_mode; - st->bandwidth = packet_bandwidth; - st->frame_size = packet_frame_size; - st->stream_channels = packet_stream_channels; - ret = opus_decode_frame(st, data, size[0], pcm+st->channels*(frame_size-packet_frame_size), - packet_frame_size, 1); - if (ret<0) - return ret; - else { - if (OPUS_CHECK_ARRAY(pcm, frame_size*st->channels)) - OPUS_PRINT_INT(frame_size); - st->last_packet_duration = frame_size; - return frame_size; - } - } - - if (count*packet_frame_size > frame_size) - return OPUS_BUFFER_TOO_SMALL; - - /* Update the state as the last step to avoid updating it on an invalid packet */ - st->mode = packet_mode; - st->bandwidth = packet_bandwidth; - st->frame_size = packet_frame_size; - st->stream_channels = packet_stream_channels; - - nb_samples=0; - for (i=0;ichannels, frame_size-nb_samples, 0); - if (ret<0) - return ret; - celt_assert(ret==packet_frame_size); - data += size[i]; - nb_samples += ret; - } - st->last_packet_duration = nb_samples; - if (OPUS_CHECK_ARRAY(pcm, nb_samples*st->channels)) - OPUS_PRINT_INT(nb_samples); -#ifndef FIXED_POINT - if (soft_clip) - opus_pcm_soft_clip(pcm, nb_samples, st->channels, st->softclip_mem); - else - st->softclip_mem[0]=st->softclip_mem[1]=0; -#endif - return nb_samples; -} - -#ifdef FIXED_POINT - -int opus_decode(OpusDecoder *st, const unsigned char *data, - opus_int32 len, opus_val16 *pcm, int frame_size, int decode_fec) -{ - if(frame_size<=0) - return OPUS_BAD_ARG; - return opus_decode_native(st, data, len, pcm, frame_size, decode_fec, 0, NULL, 0); -} - -#ifndef DISABLE_FLOAT_API -int opus_decode_float(OpusDecoder *st, const unsigned char *data, - opus_int32 len, float *pcm, int frame_size, int decode_fec) -{ - VARDECL(opus_int16, out); - int ret, i; - int nb_samples; - ALLOC_STACK; - - if(frame_size<=0) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - if (data != NULL && len > 0 && !decode_fec) - { - nb_samples = opus_decoder_get_nb_samples(st, data, len); - if (nb_samples>0) - frame_size = IMIN(frame_size, nb_samples); - else - return OPUS_INVALID_PACKET; - } - celt_assert(st->channels == 1 || st->channels == 2); - ALLOC(out, frame_size*st->channels, opus_int16); - - ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 0); - if (ret > 0) - { - for (i=0;ichannels;i++) - pcm[i] = (1.f/32768.f)*(out[i]); - } - RESTORE_STACK; - return ret; -} -#endif - - -#else -int opus_decode(OpusDecoder *st, const unsigned char *data, - opus_int32 len, opus_int16 *pcm, int frame_size, int decode_fec) -{ - VARDECL(float, out); - int ret, i; - int nb_samples; - ALLOC_STACK; - - if(frame_size<=0) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - - if (data != NULL && len > 0 && !decode_fec) - { - nb_samples = opus_decoder_get_nb_samples(st, data, len); - if (nb_samples>0) - frame_size = IMIN(frame_size, nb_samples); - else - return OPUS_INVALID_PACKET; - } - celt_assert(st->channels == 1 || st->channels == 2); - ALLOC(out, frame_size*st->channels, float); - - ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 1); - if (ret > 0) - { - for (i=0;ichannels;i++) - pcm[i] = FLOAT2INT16(out[i]); - } - RESTORE_STACK; - return ret; -} - -int opus_decode_float(OpusDecoder *st, const unsigned char *data, - opus_int32 len, opus_val16 *pcm, int frame_size, int decode_fec) -{ - if(frame_size<=0) - return OPUS_BAD_ARG; - return opus_decode_native(st, data, len, pcm, frame_size, decode_fec, 0, NULL, 0); -} - -#endif - -int opus_decoder_ctl(OpusDecoder *st, int request, ...) -{ - int ret = OPUS_OK; - va_list ap; - void *silk_dec; - CELTDecoder *celt_dec; - - silk_dec = (char*)st+st->silk_dec_offset; - celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset); - - - va_start(ap, request); - - switch (request) - { - case OPUS_GET_BANDWIDTH_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->bandwidth; - } - break; - case OPUS_GET_FINAL_RANGE_REQUEST: - { - opus_uint32 *value = va_arg(ap, opus_uint32*); - if (!value) - { - goto bad_arg; - } - *value = st->rangeFinal; - } - break; - case OPUS_RESET_STATE: - { - OPUS_CLEAR((char*)&st->OPUS_DECODER_RESET_START, - sizeof(OpusDecoder)- - ((char*)&st->OPUS_DECODER_RESET_START - (char*)st)); - - celt_decoder_ctl(celt_dec, OPUS_RESET_STATE); - silk_InitDecoder( silk_dec ); - st->stream_channels = st->channels; - st->frame_size = st->Fs/400; - } - break; - case OPUS_GET_SAMPLE_RATE_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->Fs; - } - break; - case OPUS_GET_PITCH_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - if (st->prev_mode == MODE_CELT_ONLY) - ret = celt_decoder_ctl(celt_dec, OPUS_GET_PITCH(value)); - else - *value = st->DecControl.prevPitchLag; - } - break; - case OPUS_GET_GAIN_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->decode_gain; - } - break; - case OPUS_SET_GAIN_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<-32768 || value>32767) - { - goto bad_arg; - } - st->decode_gain = value; - } - break; - case OPUS_GET_LAST_PACKET_DURATION_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->last_packet_duration; - } - break; - case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - ret = celt_decoder_ctl(celt_dec, OPUS_SET_PHASE_INVERSION_DISABLED(value)); - } - break; - case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - ret = celt_decoder_ctl(celt_dec, OPUS_GET_PHASE_INVERSION_DISABLED(value)); - } - break; - default: - /*fprintf(stderr, "unknown opus_decoder_ctl() request: %d", request);*/ - ret = OPUS_UNIMPLEMENTED; - break; - } - - va_end(ap); - return ret; -bad_arg: - va_end(ap); - return OPUS_BAD_ARG; -} - -void opus_decoder_destroy(OpusDecoder *st) -{ - opus_free(st); -} - - -int opus_packet_get_bandwidth(const unsigned char *data) -{ - int bandwidth; - if (data[0]&0x80) - { - bandwidth = OPUS_BANDWIDTH_MEDIUMBAND + ((data[0]>>5)&0x3); - if (bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) - bandwidth = OPUS_BANDWIDTH_NARROWBAND; - } else if ((data[0]&0x60) == 0x60) - { - bandwidth = (data[0]&0x10) ? OPUS_BANDWIDTH_FULLBAND : - OPUS_BANDWIDTH_SUPERWIDEBAND; - } else { - bandwidth = OPUS_BANDWIDTH_NARROWBAND + ((data[0]>>5)&0x3); - } - return bandwidth; -} - -int opus_packet_get_nb_channels(const unsigned char *data) -{ - return (data[0]&0x4) ? 2 : 1; -} - -int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) -{ - int count; - if (len<1) - return OPUS_BAD_ARG; - count = packet[0]&0x3; - if (count==0) - return 1; - else if (count!=3) - return 2; - else if (len<2) - return OPUS_INVALID_PACKET; - else - return packet[1]&0x3F; -} - -int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len, - opus_int32 Fs) -{ - int samples; - int count = opus_packet_get_nb_frames(packet, len); - - if (count<0) - return count; - - samples = count*opus_packet_get_samples_per_frame(packet, Fs); - /* Can't have more than 120 ms */ - if (samples*25 > Fs*3) - return OPUS_INVALID_PACKET; - else - return samples; -} - -int opus_decoder_get_nb_samples(const OpusDecoder *dec, - const unsigned char packet[], opus_int32 len) -{ - return opus_packet_get_nb_samples(packet, len, dec->Fs); -} diff --git a/Engine/lib/opus/src/opus_demo.c b/Engine/lib/opus/src/opus_demo.c deleted file mode 100644 index 4cc26a6c7..000000000 --- a/Engine/lib/opus/src/opus_demo.c +++ /dev/null @@ -1,892 +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 -#include -#include -#include -#include "opus.h" -#include "debug.h" -#include "opus_types.h" -#include "opus_private.h" -#include "opus_multistream.h" - -#define MAX_PACKET 1500 - -void print_usage( char* argv[] ) -{ - fprintf(stderr, "Usage: %s [-e] " - " [options] \n", argv[0]); - fprintf(stderr, " %s -d " - "[options] \n\n", argv[0]); - fprintf(stderr, "application: voip | audio | restricted-lowdelay\n" ); - fprintf(stderr, "options:\n" ); - fprintf(stderr, "-e : only runs the encoder (output the bit-stream)\n" ); - fprintf(stderr, "-d : only runs the decoder (reads the bit-stream as input)\n" ); - fprintf(stderr, "-cbr : enable constant bitrate; default: variable bitrate\n" ); - fprintf(stderr, "-cvbr : enable constrained variable bitrate; default: unconstrained\n" ); - fprintf(stderr, "-delayed-decision : use look-ahead for speech/music detection (experts only); default: disabled\n" ); - fprintf(stderr, "-bandwidth : audio bandwidth (from narrowband to fullband); default: sampling rate\n" ); - fprintf(stderr, "-framesize <2.5|5|10|20|40|60|80|100|120> : frame size in ms; default: 20 \n" ); - fprintf(stderr, "-max_payload : maximum payload size in bytes, default: 1024\n" ); - fprintf(stderr, "-complexity : complexity, 0 (lowest) ... 10 (highest); default: 10\n" ); - fprintf(stderr, "-inbandfec : enable SILK inband FEC\n" ); - fprintf(stderr, "-forcemono : force mono encoding, even for stereo input\n" ); - fprintf(stderr, "-dtx : enable SILK DTX\n" ); - fprintf(stderr, "-loss : simulate packet loss, in percent (0-100); default: 0\n" ); -} - -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) - -static const int silk8_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 2} -}; - -static const int silk12_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 2} -}; - -static const int silk16_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 2} -}; - -static const int hybrid24_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 2} -}; - -static const int hybrid48_test[][4] = { - {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, - {MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2} -}; - -static const int celt_test[][4] = { - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 240, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 240, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 240, 1}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 120, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 120, 1}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 120, 1}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 2}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 2}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 240, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 240, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 240, 2}, - - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 120, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 120, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 120, 2}, - -}; - -static const int celt_hq_test[][4] = { - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 2}, - {MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2}, -}; - -#if 0 /* This is a hack that replaces the normal encoder/decoder with the multistream version */ -#define OpusEncoder OpusMSEncoder -#define OpusDecoder OpusMSDecoder -#define opus_encode opus_multistream_encode -#define opus_decode opus_multistream_decode -#define opus_encoder_ctl opus_multistream_encoder_ctl -#define opus_decoder_ctl opus_multistream_decoder_ctl -#define opus_encoder_create ms_opus_encoder_create -#define opus_decoder_create ms_opus_decoder_create -#define opus_encoder_destroy opus_multistream_encoder_destroy -#define opus_decoder_destroy opus_multistream_decoder_destroy - -static OpusEncoder *ms_opus_encoder_create(opus_int32 Fs, int channels, int application, int *error) -{ - int streams, coupled_streams; - unsigned char mapping[256]; - return (OpusEncoder *)opus_multistream_surround_encoder_create(Fs, channels, 1, &streams, &coupled_streams, mapping, application, error); -} -static OpusDecoder *ms_opus_decoder_create(opus_int32 Fs, int channels, int *error) -{ - int streams; - int coupled_streams; - unsigned char mapping[256]={0,1}; - streams = 1; - coupled_streams = channels==2; - return (OpusDecoder *)opus_multistream_decoder_create(Fs, channels, streams, coupled_streams, mapping, error); -} -#endif - -int main(int argc, char *argv[]) -{ - int err; - char *inFile, *outFile; - FILE *fin=NULL; - FILE *fout=NULL; - OpusEncoder *enc=NULL; - OpusDecoder *dec=NULL; - int args; - int len[2]; - int frame_size, channels; - opus_int32 bitrate_bps=0; - unsigned char *data[2] = {NULL, NULL}; - unsigned char *fbytes=NULL; - opus_int32 sampling_rate; - int use_vbr; - int max_payload_bytes; - int complexity; - int use_inbandfec; - int use_dtx; - int forcechannels; - int cvbr = 0; - int packet_loss_perc; - opus_int32 count=0, count_act=0; - int k; - opus_int32 skip=0; - int stop=0; - short *in=NULL; - short *out=NULL; - int application=OPUS_APPLICATION_AUDIO; - double bits=0.0, bits_max=0.0, bits_act=0.0, bits2=0.0, nrg; - double tot_samples=0; - opus_uint64 tot_in, tot_out; - int bandwidth=OPUS_AUTO; - const char *bandwidth_string; - int lost = 0, lost_prev = 1; - int toggle = 0; - opus_uint32 enc_final_range[2]; - opus_uint32 dec_final_range; - int encode_only=0, decode_only=0; - int max_frame_size = 48000*2; - size_t num_read; - int curr_read=0; - int sweep_bps = 0; - int random_framesize=0, newsize=0, delayed_celt=0; - int sweep_max=0, sweep_min=0; - int random_fec=0; - const int (*mode_list)[4]=NULL; - int nb_modes_in_list=0; - int curr_mode=0; - int curr_mode_count=0; - int mode_switch_time = 48000; - int nb_encoded=0; - int remaining=0; - int variable_duration=OPUS_FRAMESIZE_ARG; - int delayed_decision=0; - int ret = EXIT_FAILURE; - - if (argc < 5 ) - { - print_usage( argv ); - goto failure; - } - - tot_in=tot_out=0; - fprintf(stderr, "%s\n", opus_get_version_string()); - - args = 1; - if (strcmp(argv[args], "-e")==0) - { - encode_only = 1; - args++; - } else if (strcmp(argv[args], "-d")==0) - { - decode_only = 1; - args++; - } - if (!decode_only && argc < 7 ) - { - print_usage( argv ); - goto failure; - } - - if (!decode_only) - { - if (strcmp(argv[args], "voip")==0) - application = OPUS_APPLICATION_VOIP; - else if (strcmp(argv[args], "restricted-lowdelay")==0) - application = OPUS_APPLICATION_RESTRICTED_LOWDELAY; - else if (strcmp(argv[args], "audio")!=0) { - fprintf(stderr, "unknown application: %s\n", argv[args]); - print_usage(argv); - goto failure; - } - args++; - } - sampling_rate = (opus_int32)atol(argv[args]); - args++; - - if (sampling_rate != 8000 && sampling_rate != 12000 - && sampling_rate != 16000 && sampling_rate != 24000 - && sampling_rate != 48000) - { - fprintf(stderr, "Supported sampling rates are 8000, 12000, " - "16000, 24000 and 48000.\n"); - goto failure; - } - frame_size = sampling_rate/50; - - channels = atoi(argv[args]); - args++; - - if (channels < 1 || channels > 2) - { - fprintf(stderr, "Opus_demo supports only 1 or 2 channels.\n"); - goto failure; - } - - if (!decode_only) - { - bitrate_bps = (opus_int32)atol(argv[args]); - args++; - } - - /* defaults: */ - use_vbr = 1; - max_payload_bytes = MAX_PACKET; - complexity = 10; - use_inbandfec = 0; - forcechannels = OPUS_AUTO; - use_dtx = 0; - packet_loss_perc = 0; - - while( args < argc - 2 ) { - /* process command line options */ - if( strcmp( argv[ args ], "-cbr" ) == 0 ) { - check_encoder_option(decode_only, "-cbr"); - use_vbr = 0; - args++; - } else if( strcmp( argv[ args ], "-bandwidth" ) == 0 ) { - check_encoder_option(decode_only, "-bandwidth"); - if (strcmp(argv[ args + 1 ], "NB")==0) - bandwidth = OPUS_BANDWIDTH_NARROWBAND; - else if (strcmp(argv[ args + 1 ], "MB")==0) - bandwidth = OPUS_BANDWIDTH_MEDIUMBAND; - else if (strcmp(argv[ args + 1 ], "WB")==0) - bandwidth = OPUS_BANDWIDTH_WIDEBAND; - else if (strcmp(argv[ args + 1 ], "SWB")==0) - bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND; - else if (strcmp(argv[ args + 1 ], "FB")==0) - bandwidth = OPUS_BANDWIDTH_FULLBAND; - else { - fprintf(stderr, "Unknown bandwidth %s. " - "Supported are NB, MB, WB, SWB, FB.\n", - argv[ args + 1 ]); - goto failure; - } - args += 2; - } else if( strcmp( argv[ args ], "-framesize" ) == 0 ) { - check_encoder_option(decode_only, "-framesize"); - if (strcmp(argv[ args + 1 ], "2.5")==0) - frame_size = sampling_rate/400; - else if (strcmp(argv[ args + 1 ], "5")==0) - frame_size = sampling_rate/200; - else if (strcmp(argv[ args + 1 ], "10")==0) - frame_size = sampling_rate/100; - else if (strcmp(argv[ args + 1 ], "20")==0) - frame_size = sampling_rate/50; - else if (strcmp(argv[ args + 1 ], "40")==0) - frame_size = sampling_rate/25; - else if (strcmp(argv[ args + 1 ], "60")==0) - frame_size = 3*sampling_rate/50; - else if (strcmp(argv[ args + 1 ], "80")==0) - frame_size = 4*sampling_rate/50; - else if (strcmp(argv[ args + 1 ], "100")==0) - frame_size = 5*sampling_rate/50; - else if (strcmp(argv[ args + 1 ], "120")==0) - frame_size = 6*sampling_rate/50; - else { - fprintf(stderr, "Unsupported frame size: %s ms. " - "Supported are 2.5, 5, 10, 20, 40, 60, 80, 100, 120.\n", - argv[ args + 1 ]); - goto failure; - } - args += 2; - } else if( strcmp( argv[ args ], "-max_payload" ) == 0 ) { - check_encoder_option(decode_only, "-max_payload"); - max_payload_bytes = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-complexity" ) == 0 ) { - check_encoder_option(decode_only, "-complexity"); - complexity = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-inbandfec" ) == 0 ) { - use_inbandfec = 1; - args++; - } else if( strcmp( argv[ args ], "-forcemono" ) == 0 ) { - check_encoder_option(decode_only, "-forcemono"); - forcechannels = 1; - args++; - } else if( strcmp( argv[ args ], "-cvbr" ) == 0 ) { - check_encoder_option(decode_only, "-cvbr"); - cvbr = 1; - args++; - } else if( strcmp( argv[ args ], "-delayed-decision" ) == 0 ) { - check_encoder_option(decode_only, "-delayed-decision"); - delayed_decision = 1; - args++; - } else if( strcmp( argv[ args ], "-dtx") == 0 ) { - check_encoder_option(decode_only, "-dtx"); - use_dtx = 1; - args++; - } else if( strcmp( argv[ args ], "-loss" ) == 0 ) { - packet_loss_perc = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-sweep" ) == 0 ) { - check_encoder_option(decode_only, "-sweep"); - sweep_bps = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-random_framesize" ) == 0 ) { - check_encoder_option(decode_only, "-random_framesize"); - random_framesize = 1; - args++; - } else if( strcmp( argv[ args ], "-sweep_max" ) == 0 ) { - check_encoder_option(decode_only, "-sweep_max"); - sweep_max = atoi( argv[ args + 1 ] ); - args += 2; - } else if( strcmp( argv[ args ], "-random_fec" ) == 0 ) { - check_encoder_option(decode_only, "-random_fec"); - random_fec = 1; - args++; - } else if( strcmp( argv[ args ], "-silk8k_test" ) == 0 ) { - check_encoder_option(decode_only, "-silk8k_test"); - mode_list = silk8_test; - nb_modes_in_list = 8; - args++; - } else if( strcmp( argv[ args ], "-silk12k_test" ) == 0 ) { - check_encoder_option(decode_only, "-silk12k_test"); - mode_list = silk12_test; - nb_modes_in_list = 8; - args++; - } else if( strcmp( argv[ args ], "-silk16k_test" ) == 0 ) { - check_encoder_option(decode_only, "-silk16k_test"); - mode_list = silk16_test; - nb_modes_in_list = 8; - args++; - } else if( strcmp( argv[ args ], "-hybrid24k_test" ) == 0 ) { - check_encoder_option(decode_only, "-hybrid24k_test"); - mode_list = hybrid24_test; - nb_modes_in_list = 4; - args++; - } else if( strcmp( argv[ args ], "-hybrid48k_test" ) == 0 ) { - check_encoder_option(decode_only, "-hybrid48k_test"); - mode_list = hybrid48_test; - nb_modes_in_list = 4; - args++; - } else if( strcmp( argv[ args ], "-celt_test" ) == 0 ) { - check_encoder_option(decode_only, "-celt_test"); - mode_list = celt_test; - nb_modes_in_list = 32; - args++; - } else if( strcmp( argv[ args ], "-celt_hq_test" ) == 0 ) { - check_encoder_option(decode_only, "-celt_hq_test"); - mode_list = celt_hq_test; - nb_modes_in_list = 4; - args++; - } else { - printf( "Error: unrecognized setting: %s\n\n", argv[ args ] ); - print_usage( argv ); - goto failure; - } - } - - if (sweep_max) - sweep_min = bitrate_bps; - - if (max_payload_bytes < 0 || max_payload_bytes > MAX_PACKET) - { - fprintf (stderr, "max_payload_bytes must be between 0 and %d\n", - MAX_PACKET); - 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; - } - if (mode_list) - { - int size; - fseek(fin, 0, SEEK_END); - size = ftell(fin); - fprintf(stderr, "File size is %d bytes\n", size); - fseek(fin, 0, SEEK_SET); - mode_switch_time = size/sizeof(short)/channels/nb_modes_in_list; - fprintf(stderr, "Switching mode every %d samples\n", mode_switch_time); - } - - outFile = argv[argc-1]; - fout = fopen(outFile, "wb+"); - if (!fout) - { - fprintf (stderr, "Could not open output file %s\n", argv[argc-1]); - goto failure; - } - - if (!decode_only) - { - enc = opus_encoder_create(sampling_rate, channels, application, &err); - if (err != OPUS_OK) - { - fprintf(stderr, "Cannot create encoder: %s\n", opus_strerror(err)); - goto failure; - } - opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate_bps)); - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(bandwidth)); - opus_encoder_ctl(enc, OPUS_SET_VBR(use_vbr)); - opus_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(cvbr)); - opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); - opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(use_inbandfec)); - opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(forcechannels)); - opus_encoder_ctl(enc, OPUS_SET_DTX(use_dtx)); - opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(packet_loss_perc)); - - opus_encoder_ctl(enc, OPUS_GET_LOOKAHEAD(&skip)); - opus_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(16)); - opus_encoder_ctl(enc, OPUS_SET_EXPERT_FRAME_DURATION(variable_duration)); - } - if (!encode_only) - { - dec = opus_decoder_create(sampling_rate, channels, &err); - if (err != OPUS_OK) - { - fprintf(stderr, "Cannot create decoder: %s\n", opus_strerror(err)); - goto failure; - } - } - - - switch(bandwidth) - { - case OPUS_BANDWIDTH_NARROWBAND: - bandwidth_string = "narrowband"; - break; - case OPUS_BANDWIDTH_MEDIUMBAND: - bandwidth_string = "mediumband"; - break; - case OPUS_BANDWIDTH_WIDEBAND: - bandwidth_string = "wideband"; - break; - case OPUS_BANDWIDTH_SUPERWIDEBAND: - bandwidth_string = "superwideband"; - break; - case OPUS_BANDWIDTH_FULLBAND: - bandwidth_string = "fullband"; - break; - case OPUS_AUTO: - bandwidth_string = "auto bandwidth"; - break; - default: - bandwidth_string = "unknown"; - break; - } - - if (decode_only) - fprintf(stderr, "Decoding with %ld Hz output (%d channels)\n", - (long)sampling_rate, channels); - else - fprintf(stderr, "Encoding %ld Hz input at %.3f kb/s " - "in %s with %d-sample frames.\n", - (long)sampling_rate, bitrate_bps*0.001, - bandwidth_string, frame_size); - - in = (short*)malloc(max_frame_size*channels*sizeof(short)); - out = (short*)malloc(max_frame_size*channels*sizeof(short)); - /* We need to allocate for 16-bit PCM data, but we store it as unsigned char. */ - fbytes = (unsigned char*)malloc(max_frame_size*channels*sizeof(short)); - data[0] = (unsigned char*)calloc(max_payload_bytes,sizeof(unsigned char)); - if ( use_inbandfec ) { - data[1] = (unsigned char*)calloc(max_payload_bytes,sizeof(unsigned char)); - } - if(delayed_decision) - { - if (frame_size==sampling_rate/400) - variable_duration = OPUS_FRAMESIZE_2_5_MS; - else if (frame_size==sampling_rate/200) - variable_duration = OPUS_FRAMESIZE_5_MS; - else if (frame_size==sampling_rate/100) - variable_duration = OPUS_FRAMESIZE_10_MS; - else if (frame_size==sampling_rate/50) - variable_duration = OPUS_FRAMESIZE_20_MS; - else if (frame_size==sampling_rate/25) - variable_duration = OPUS_FRAMESIZE_40_MS; - else if (frame_size==3*sampling_rate/50) - variable_duration = OPUS_FRAMESIZE_60_MS; - else if (frame_size==4*sampling_rate/50) - variable_duration = OPUS_FRAMESIZE_80_MS; - else if (frame_size==5*sampling_rate/50) - variable_duration = OPUS_FRAMESIZE_100_MS; - else - variable_duration = OPUS_FRAMESIZE_120_MS; - opus_encoder_ctl(enc, OPUS_SET_EXPERT_FRAME_DURATION(variable_duration)); - frame_size = 2*48000; - } - while (!stop) - { - if (delayed_celt) - { - frame_size = newsize; - delayed_celt = 0; - } else if (random_framesize && rand()%20==0) - { - newsize = rand()%6; - switch(newsize) - { - case 0: newsize=sampling_rate/400; break; - case 1: newsize=sampling_rate/200; break; - case 2: newsize=sampling_rate/100; break; - case 3: newsize=sampling_rate/50; break; - case 4: newsize=sampling_rate/25; break; - case 5: newsize=3*sampling_rate/50; break; - } - while (newsize < sampling_rate/25 && bitrate_bps-abs(sweep_bps) <= 3*12*sampling_rate/newsize) - newsize*=2; - if (newsize < sampling_rate/100 && frame_size >= sampling_rate/100) - { - opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(MODE_CELT_ONLY)); - delayed_celt=1; - } else { - frame_size = newsize; - } - } - if (random_fec && rand()%30==0) - { - opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(rand()%4==0)); - } - if (decode_only) - { - unsigned char ch[4]; - num_read = fread(ch, 1, 4, fin); - if (num_read!=4) - break; - len[toggle] = char_to_int(ch); - if (len[toggle]>max_payload_bytes || len[toggle]<0) - { - fprintf(stderr, "Invalid payload length: %d\n",len[toggle]); - break; - } - num_read = fread(ch, 1, 4, fin); - if (num_read!=4) - break; - enc_final_range[toggle] = char_to_int(ch); - num_read = fread(data[toggle], 1, len[toggle], fin); - if (num_read!=(size_t)len[toggle]) - { - fprintf(stderr, "Ran out of input, " - "expecting %d bytes got %d\n", - len[toggle],(int)num_read); - break; - } - } else { - int i; - if (mode_list!=NULL) - { - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(mode_list[curr_mode][1])); - opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(mode_list[curr_mode][0])); - opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(mode_list[curr_mode][3])); - frame_size = mode_list[curr_mode][2]; - } - num_read = fread(fbytes, sizeof(short)*channels, frame_size-remaining, fin); - curr_read = (int)num_read; - tot_in += curr_read; - for(i=0;i sweep_max) - sweep_bps = -sweep_bps; - else if (bitrate_bps < sweep_min) - sweep_bps = -sweep_bps; - } - /* safety */ - if (bitrate_bps<1000) - bitrate_bps = 1000; - opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate_bps)); - } - opus_encoder_ctl(enc, OPUS_GET_FINAL_RANGE(&enc_final_range[toggle])); - if (len[toggle] < 0) - { - fprintf (stderr, "opus_encode() returned %d\n", len[toggle]); - goto failure; - } - curr_mode_count += frame_size; - if (curr_mode_count > mode_switch_time && curr_mode < nb_modes_in_list-1) - { - curr_mode++; - curr_mode_count = 0; - } - } - -#if 0 /* This is for testing the padding code, do not enable by default */ - if (len[toggle]<1275) - { - int new_len = len[toggle]+rand()%(max_payload_bytes-len[toggle]); - if ((err = opus_packet_pad(data[toggle], len[toggle], new_len)) != OPUS_OK) - { - fprintf(stderr, "padding failed: %s\n", opus_strerror(err)); - goto failure; - } - len[toggle] = new_len; - } -#endif - if (encode_only) - { - unsigned char int_field[4]; - int_to_char(len[toggle], int_field); - if (fwrite(int_field, 1, 4, fout) != 4) { - fprintf(stderr, "Error writing.\n"); - goto failure; - } - int_to_char(enc_final_range[toggle], int_field); - if (fwrite(int_field, 1, 4, fout) != 4) { - fprintf(stderr, "Error writing.\n"); - goto failure; - } - if (fwrite(data[toggle], 1, len[toggle], fout) != (unsigned)len[toggle]) { - fprintf(stderr, "Error writing.\n"); - goto failure; - } - tot_samples += nb_encoded; - } else { - opus_int32 output_samples; - lost = len[toggle]==0 || (packet_loss_perc>0 && rand()%100 < packet_loss_perc); - if (lost) - opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples)); - else - output_samples = max_frame_size; - if( count >= use_inbandfec ) { - /* delay by one packet when using in-band FEC */ - if( use_inbandfec ) { - if( lost_prev ) { - /* attempt to decode with in-band FEC from next packet */ - opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples)); - output_samples = opus_decode(dec, lost ? NULL : data[toggle], len[toggle], out, output_samples, 1); - } else { - /* regular decode */ - output_samples = max_frame_size; - output_samples = opus_decode(dec, data[1-toggle], len[1-toggle], out, output_samples, 0); - } - } else { - output_samples = opus_decode(dec, lost ? NULL : data[toggle], len[toggle], out, output_samples, 0); - } - if (output_samples>0) - { - if (!decode_only && tot_out + output_samples > tot_in) - { - stop=1; - output_samples = (opus_int32)(tot_in - tot_out); - } - if (output_samples>skip) { - int i; - for(i=0;i<(output_samples-skip)*channels;i++) - { - short s; - s=out[i+(skip*channels)]; - fbytes[2*i]=s&0xFF; - fbytes[2*i+1]=(s>>8)&0xFF; - } - if (fwrite(fbytes, sizeof(short)*channels, output_samples-skip, fout) != (unsigned)(output_samples-skip)){ - fprintf(stderr, "Error writing.\n"); - goto failure; - } - tot_out += output_samples-skip; - } - if (output_samples= use_inbandfec ) { - /* count bits */ - bits += len[toggle]*8; - bits_max = ( len[toggle]*8 > bits_max ) ? len[toggle]*8 : bits_max; - bits2 += len[toggle]*len[toggle]*64; - if (!decode_only) - { - nrg = 0.0; - for ( k = 0; k < frame_size * channels; k++ ) { - nrg += in[ k ] * (double)in[ k ]; - } - nrg /= frame_size * channels; - if( nrg > 1e5 ) { - bits_act += len[toggle]*8; - count_act++; - } - } - } - count++; - toggle = (toggle + use_inbandfec) & 1; - } - - if(decode_only && count > 0) - frame_size = (int)(tot_samples / count); - count -= use_inbandfec; - if (tot_samples >= 1 && count > 0 && frame_size) - { - /* Print out bitrate statistics */ - double var; - fprintf (stderr, "average bitrate: %7.3f kb/s\n", - 1e-3*bits*sampling_rate/tot_samples); - fprintf (stderr, "maximum bitrate: %7.3f kb/s\n", - 1e-3*bits_max*sampling_rate/frame_size); - if (!decode_only) - fprintf (stderr, "active bitrate: %7.3f kb/s\n", - 1e-3*bits_act*sampling_rate/(1e-15+frame_size*(double)count_act)); - var = bits2/count - bits*bits/(count*(double)count); - if (var < 0) - var = 0; - fprintf (stderr, "bitrate standard deviation: %7.3f kb/s\n", - 1e-3*sqrt(var)*sampling_rate/frame_size); - } else { - fprintf(stderr, "bitrate statistics are undefined\n"); - } - silk_TimerSave("opus_timing.txt"); - ret = EXIT_SUCCESS; -failure: - opus_encoder_destroy(enc); - opus_decoder_destroy(dec); - free(data[0]); - free(data[1]); - if (fin) - fclose(fin); - if (fout) - fclose(fout); - free(in); - free(out); - free(fbytes); - return ret; -} diff --git a/Engine/lib/opus/src/opus_encoder.c b/Engine/lib/opus/src/opus_encoder.c deleted file mode 100644 index 8c8db5a54..000000000 --- a/Engine/lib/opus/src/opus_encoder.c +++ /dev/null @@ -1,2780 +0,0 @@ -/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited - Written by Jean-Marc Valin and Koen Vos */ -/* - 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 -#include "celt.h" -#include "entenc.h" -#include "modes.h" -#include "API.h" -#include "stack_alloc.h" -#include "float_cast.h" -#include "opus.h" -#include "arch.h" -#include "pitch.h" -#include "opus_private.h" -#include "os_support.h" -#include "cpu_support.h" -#include "analysis.h" -#include "mathops.h" -#include "tuning_parameters.h" -#ifdef FIXED_POINT -#include "fixed/structs_FIX.h" -#else -#include "float/structs_FLP.h" -#endif - -#define MAX_ENCODER_BUFFER 480 - -#ifndef DISABLE_FLOAT_API -#define PSEUDO_SNR_THRESHOLD 316.23f /* 10^(25/10) */ -#endif - -typedef struct { - opus_val32 XX, XY, YY; - opus_val16 smoothed_width; - opus_val16 max_follower; -} StereoWidthState; - -struct OpusEncoder { - int celt_enc_offset; - int silk_enc_offset; - silk_EncControlStruct silk_mode; - int application; - int channels; - int delay_compensation; - int force_channels; - int signal_type; - int user_bandwidth; - int max_bandwidth; - int user_forced_mode; - int voice_ratio; - opus_int32 Fs; - int use_vbr; - int vbr_constraint; - int variable_duration; - opus_int32 bitrate_bps; - opus_int32 user_bitrate_bps; - int lsb_depth; - int encoder_buffer; - int lfe; - int arch; - int use_dtx; /* general DTX for both SILK and CELT */ - int fec_config; -#ifndef DISABLE_FLOAT_API - TonalityAnalysisState analysis; -#endif - -#define OPUS_ENCODER_RESET_START stream_channels - int stream_channels; - opus_int16 hybrid_stereo_width_Q14; - opus_int32 variable_HP_smth2_Q15; - opus_val16 prev_HB_gain; - opus_val32 hp_mem[4]; - int mode; - int prev_mode; - int prev_channels; - int prev_framesize; - int bandwidth; - /* Bandwidth determined automatically from the rate (before any other adjustment) */ - int auto_bandwidth; - int silk_bw_switch; - /* Sampling rate (at the API level) */ - int first; - opus_val16 * energy_masking; - StereoWidthState width_mem; - opus_val16 delay_buffer[MAX_ENCODER_BUFFER*2]; -#ifndef DISABLE_FLOAT_API - int detected_bandwidth; - int nb_no_activity_ms_Q1; - opus_val32 peak_signal_energy; -#endif - int nonfinal_frame; /* current frame is not the final in a packet */ - opus_uint32 rangeFinal; -}; - -/* Transition tables for the voice and music. First column is the - middle (memoriless) threshold. The second column is the hysteresis - (difference with the middle) */ -static const opus_int32 mono_voice_bandwidth_thresholds[8] = { - 9000, 700, /* NB<->MB */ - 9000, 700, /* MB<->WB */ - 13500, 1000, /* WB<->SWB */ - 14000, 2000, /* SWB<->FB */ -}; -static const opus_int32 mono_music_bandwidth_thresholds[8] = { - 9000, 700, /* NB<->MB */ - 9000, 700, /* MB<->WB */ - 11000, 1000, /* WB<->SWB */ - 12000, 2000, /* SWB<->FB */ -}; -static const opus_int32 stereo_voice_bandwidth_thresholds[8] = { - 9000, 700, /* NB<->MB */ - 9000, 700, /* MB<->WB */ - 13500, 1000, /* WB<->SWB */ - 14000, 2000, /* SWB<->FB */ -}; -static const opus_int32 stereo_music_bandwidth_thresholds[8] = { - 9000, 700, /* NB<->MB */ - 9000, 700, /* MB<->WB */ - 11000, 1000, /* WB<->SWB */ - 12000, 2000, /* SWB<->FB */ -}; -/* Threshold bit-rates for switching between mono and stereo */ -static const opus_int32 stereo_voice_threshold = 19000; -static const opus_int32 stereo_music_threshold = 17000; - -/* Threshold bit-rate for switching between SILK/hybrid and CELT-only */ -static const opus_int32 mode_thresholds[2][2] = { - /* voice */ /* music */ - { 64000, 10000}, /* mono */ - { 44000, 10000}, /* stereo */ -}; - -static const opus_int32 fec_thresholds[] = { - 12000, 1000, /* NB */ - 14000, 1000, /* MB */ - 16000, 1000, /* WB */ - 20000, 1000, /* SWB */ - 22000, 1000, /* FB */ -}; - -int opus_encoder_get_size(int channels) -{ - int silkEncSizeBytes, celtEncSizeBytes; - int ret; - if (channels<1 || channels > 2) - return 0; - ret = silk_Get_Encoder_Size( &silkEncSizeBytes ); - if (ret) - return 0; - silkEncSizeBytes = align(silkEncSizeBytes); - celtEncSizeBytes = celt_encoder_get_size(channels); - return align(sizeof(OpusEncoder))+silkEncSizeBytes+celtEncSizeBytes; -} - -int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int application) -{ - void *silk_enc; - CELTEncoder *celt_enc; - int err; - int ret, silkEncSizeBytes; - - if((Fs!=48000&&Fs!=24000&&Fs!=16000&&Fs!=12000&&Fs!=8000)||(channels!=1&&channels!=2)|| - (application != OPUS_APPLICATION_VOIP && application != OPUS_APPLICATION_AUDIO - && application != OPUS_APPLICATION_RESTRICTED_LOWDELAY)) - return OPUS_BAD_ARG; - - OPUS_CLEAR((char*)st, opus_encoder_get_size(channels)); - /* Create SILK encoder */ - ret = silk_Get_Encoder_Size( &silkEncSizeBytes ); - if (ret) - return OPUS_BAD_ARG; - silkEncSizeBytes = align(silkEncSizeBytes); - st->silk_enc_offset = align(sizeof(OpusEncoder)); - st->celt_enc_offset = st->silk_enc_offset+silkEncSizeBytes; - silk_enc = (char*)st+st->silk_enc_offset; - celt_enc = (CELTEncoder*)((char*)st+st->celt_enc_offset); - - st->stream_channels = st->channels = channels; - - st->Fs = Fs; - - st->arch = opus_select_arch(); - - ret = silk_InitEncoder( silk_enc, st->arch, &st->silk_mode ); - if(ret)return OPUS_INTERNAL_ERROR; - - /* default SILK parameters */ - st->silk_mode.nChannelsAPI = channels; - st->silk_mode.nChannelsInternal = channels; - st->silk_mode.API_sampleRate = st->Fs; - st->silk_mode.maxInternalSampleRate = 16000; - st->silk_mode.minInternalSampleRate = 8000; - st->silk_mode.desiredInternalSampleRate = 16000; - st->silk_mode.payloadSize_ms = 20; - st->silk_mode.bitRate = 25000; - st->silk_mode.packetLossPercentage = 0; - st->silk_mode.complexity = 9; - st->silk_mode.useInBandFEC = 0; - st->silk_mode.useDTX = 0; - st->silk_mode.useCBR = 0; - st->silk_mode.reducedDependency = 0; - - /* Create CELT encoder */ - /* Initialize CELT encoder */ - err = celt_encoder_init(celt_enc, Fs, channels, st->arch); - if(err!=OPUS_OK)return OPUS_INTERNAL_ERROR; - - celt_encoder_ctl(celt_enc, CELT_SET_SIGNALLING(0)); - celt_encoder_ctl(celt_enc, OPUS_SET_COMPLEXITY(st->silk_mode.complexity)); - - st->use_vbr = 1; - /* Makes constrained VBR the default (safer for real-time use) */ - st->vbr_constraint = 1; - st->user_bitrate_bps = OPUS_AUTO; - st->bitrate_bps = 3000+Fs*channels; - st->application = application; - st->signal_type = OPUS_AUTO; - st->user_bandwidth = OPUS_AUTO; - st->max_bandwidth = OPUS_BANDWIDTH_FULLBAND; - st->force_channels = OPUS_AUTO; - st->user_forced_mode = OPUS_AUTO; - st->voice_ratio = -1; - st->encoder_buffer = st->Fs/100; - st->lsb_depth = 24; - st->variable_duration = OPUS_FRAMESIZE_ARG; - - /* Delay compensation of 4 ms (2.5 ms for SILK's extra look-ahead - + 1.5 ms for SILK resamplers and stereo prediction) */ - st->delay_compensation = st->Fs/250; - - st->hybrid_stereo_width_Q14 = 1 << 14; - st->prev_HB_gain = Q15ONE; - st->variable_HP_smth2_Q15 = silk_LSHIFT( silk_lin2log( VARIABLE_HP_MIN_CUTOFF_HZ ), 8 ); - st->first = 1; - st->mode = MODE_HYBRID; - st->bandwidth = OPUS_BANDWIDTH_FULLBAND; - -#ifndef DISABLE_FLOAT_API - tonality_analysis_init(&st->analysis, st->Fs); - st->analysis.application = st->application; -#endif - - return OPUS_OK; -} - -static unsigned char gen_toc(int mode, int framerate, int bandwidth, int channels) -{ - int period; - unsigned char toc; - period = 0; - while (framerate < 400) - { - framerate <<= 1; - period++; - } - if (mode == MODE_SILK_ONLY) - { - toc = (bandwidth-OPUS_BANDWIDTH_NARROWBAND)<<5; - toc |= (period-2)<<3; - } else if (mode == MODE_CELT_ONLY) - { - int tmp = bandwidth-OPUS_BANDWIDTH_MEDIUMBAND; - if (tmp < 0) - tmp = 0; - toc = 0x80; - toc |= tmp << 5; - toc |= period<<3; - } else /* Hybrid */ - { - toc = 0x60; - toc |= (bandwidth-OPUS_BANDWIDTH_SUPERWIDEBAND)<<4; - toc |= (period-2)<<3; - } - toc |= (channels==2)<<2; - return toc; -} - -#ifndef FIXED_POINT -static void silk_biquad_float( - const opus_val16 *in, /* I: Input signal */ - const opus_int32 *B_Q28, /* I: MA coefficients [3] */ - const opus_int32 *A_Q28, /* I: AR coefficients [2] */ - opus_val32 *S, /* I/O: State vector [2] */ - opus_val16 *out, /* O: Output signal */ - const opus_int32 len, /* I: Signal length (must be even) */ - int stride -) -{ - /* DIRECT FORM II TRANSPOSED (uses 2 element state vector) */ - opus_int k; - opus_val32 vout; - opus_val32 inval; - opus_val32 A[2], B[3]; - - A[0] = (opus_val32)(A_Q28[0] * (1.f/((opus_int32)1<<28))); - A[1] = (opus_val32)(A_Q28[1] * (1.f/((opus_int32)1<<28))); - B[0] = (opus_val32)(B_Q28[0] * (1.f/((opus_int32)1<<28))); - B[1] = (opus_val32)(B_Q28[1] * (1.f/((opus_int32)1<<28))); - B[2] = (opus_val32)(B_Q28[2] * (1.f/((opus_int32)1<<28))); - - /* Negate A_Q28 values and split in two parts */ - - for( k = 0; k < len; k++ ) { - /* S[ 0 ], S[ 1 ]: Q12 */ - inval = in[ k*stride ]; - vout = S[ 0 ] + B[0]*inval; - - S[ 0 ] = S[1] - vout*A[0] + B[1]*inval; - - S[ 1 ] = - vout*A[1] + B[2]*inval + VERY_SMALL; - - /* Scale back to Q0 and saturate */ - out[ k*stride ] = vout; - } -} -#endif - -static void hp_cutoff(const opus_val16 *in, opus_int32 cutoff_Hz, opus_val16 *out, opus_val32 *hp_mem, int len, int channels, opus_int32 Fs, int arch) -{ - opus_int32 B_Q28[ 3 ], A_Q28[ 2 ]; - opus_int32 Fc_Q19, r_Q28, r_Q22; - (void)arch; - - silk_assert( cutoff_Hz <= silk_int32_MAX / SILK_FIX_CONST( 1.5 * 3.14159 / 1000, 19 ) ); - Fc_Q19 = silk_DIV32_16( silk_SMULBB( SILK_FIX_CONST( 1.5 * 3.14159 / 1000, 19 ), cutoff_Hz ), Fs/1000 ); - silk_assert( Fc_Q19 > 0 && Fc_Q19 < 32768 ); - - r_Q28 = SILK_FIX_CONST( 1.0, 28 ) - silk_MUL( SILK_FIX_CONST( 0.92, 9 ), Fc_Q19 ); - - /* b = r * [ 1; -2; 1 ]; */ - /* a = [ 1; -2 * r * ( 1 - 0.5 * Fc^2 ); r^2 ]; */ - B_Q28[ 0 ] = r_Q28; - B_Q28[ 1 ] = silk_LSHIFT( -r_Q28, 1 ); - B_Q28[ 2 ] = r_Q28; - - /* -r * ( 2 - Fc * Fc ); */ - r_Q22 = silk_RSHIFT( r_Q28, 6 ); - A_Q28[ 0 ] = silk_SMULWW( r_Q22, silk_SMULWW( Fc_Q19, Fc_Q19 ) - SILK_FIX_CONST( 2.0, 22 ) ); - A_Q28[ 1 ] = silk_SMULWW( r_Q22, r_Q22 ); - -#ifdef FIXED_POINT - if( channels == 1 ) { - silk_biquad_alt_stride1( in, B_Q28, A_Q28, hp_mem, out, len ); - } else { - silk_biquad_alt_stride2( in, B_Q28, A_Q28, hp_mem, out, len, arch ); - } -#else - silk_biquad_float( in, B_Q28, A_Q28, hp_mem, out, len, channels ); - if( channels == 2 ) { - silk_biquad_float( in+1, B_Q28, A_Q28, hp_mem+2, out+1, len, channels ); - } -#endif -} - -#ifdef FIXED_POINT -static void dc_reject(const opus_val16 *in, opus_int32 cutoff_Hz, opus_val16 *out, opus_val32 *hp_mem, int len, int channels, opus_int32 Fs) -{ - int c, i; - int shift; - - /* Approximates -round(log2(6.3*cutoff_Hz/Fs)) */ - shift=celt_ilog2(Fs/(cutoff_Hz*4)); - for (c=0;cFs/400; - if (st->user_bitrate_bps==OPUS_AUTO) - return 60*st->Fs/frame_size + st->Fs*st->channels; - else if (st->user_bitrate_bps==OPUS_BITRATE_MAX) - return max_data_bytes*8*st->Fs/frame_size; - else - return st->user_bitrate_bps; -} - -#ifndef DISABLE_FLOAT_API -#ifdef FIXED_POINT -#define PCM2VAL(x) FLOAT2INT16(x) -#else -#define PCM2VAL(x) SCALEIN(x) -#endif - -void downmix_float(const void *_x, opus_val32 *y, int subframe, int offset, int c1, int c2, int C) -{ - const float *x; - int j; - - x = (const float *)_x; - for (j=0;j-1) - { - for (j=0;j-1) - { - for (j=0;j= OPUS_FRAMESIZE_2_5_MS && variable_duration <= OPUS_FRAMESIZE_120_MS) - { - if (variable_duration <= OPUS_FRAMESIZE_40_MS) - new_size = (Fs/400)<<(variable_duration-OPUS_FRAMESIZE_2_5_MS); - else - new_size = (variable_duration-OPUS_FRAMESIZE_2_5_MS-2)*Fs/50; - } - else - return -1; - if (new_size>frame_size) - return -1; - if (400*new_size!=Fs && 200*new_size!=Fs && 100*new_size!=Fs && - 50*new_size!=Fs && 25*new_size!=Fs && 50*new_size!=3*Fs && - 50*new_size!=4*Fs && 50*new_size!=5*Fs && 50*new_size!=6*Fs) - return -1; - return new_size; -} - -opus_val16 compute_stereo_width(const opus_val16 *pcm, int frame_size, opus_int32 Fs, StereoWidthState *mem) -{ - opus_val32 xx, xy, yy; - opus_val16 sqrt_xx, sqrt_yy; - opus_val16 qrrt_xx, qrrt_yy; - int frame_rate; - int i; - opus_val16 short_alpha; - - frame_rate = Fs/frame_size; - short_alpha = Q15ONE - MULT16_16(25, Q15ONE)/IMAX(50,frame_rate); - xx=xy=yy=0; - /* Unroll by 4. The frame size is always a multiple of 4 *except* for - 2.5 ms frames at 12 kHz. Since this setting is very rare (and very - stupid), we just discard the last two samples. */ - for (i=0;iXX += MULT16_32_Q15(short_alpha, xx-mem->XX); - mem->XY += MULT16_32_Q15(short_alpha, xy-mem->XY); - mem->YY += MULT16_32_Q15(short_alpha, yy-mem->YY); - mem->XX = MAX32(0, mem->XX); - mem->XY = MAX32(0, mem->XY); - mem->YY = MAX32(0, mem->YY); - if (MAX32(mem->XX, mem->YY)>QCONST16(8e-4f, 18)) - { - opus_val16 corr; - opus_val16 ldiff; - opus_val16 width; - sqrt_xx = celt_sqrt(mem->XX); - sqrt_yy = celt_sqrt(mem->YY); - qrrt_xx = celt_sqrt(sqrt_xx); - qrrt_yy = celt_sqrt(sqrt_yy); - /* Inter-channel correlation */ - mem->XY = MIN32(mem->XY, sqrt_xx*sqrt_yy); - corr = SHR32(frac_div32(mem->XY,EPSILON+MULT16_16(sqrt_xx,sqrt_yy)),16); - /* Approximate loudness difference */ - ldiff = MULT16_16(Q15ONE, ABS16(qrrt_xx-qrrt_yy))/(EPSILON+qrrt_xx+qrrt_yy); - width = MULT16_16_Q15(celt_sqrt(QCONST32(1.f,30)-MULT16_16(corr,corr)), ldiff); - /* Smoothing over one second */ - mem->smoothed_width += (width-mem->smoothed_width)/frame_rate; - /* Peak follower */ - mem->max_follower = MAX16(mem->max_follower-QCONST16(.02f,15)/frame_rate, mem->smoothed_width); - } - /*printf("%f %f %f %f %f ", corr/(float)Q15ONE, ldiff/(float)Q15ONE, width/(float)Q15ONE, mem->smoothed_width/(float)Q15ONE, mem->max_follower/(float)Q15ONE);*/ - return EXTRACT16(MIN32(Q15ONE, MULT16_16(20, mem->max_follower))); -} - -static int decide_fec(int useInBandFEC, int PacketLoss_perc, int last_fec, int mode, int *bandwidth, opus_int32 rate) -{ - int orig_bandwidth; - if (!useInBandFEC || PacketLoss_perc == 0 || mode == MODE_CELT_ONLY) - return 0; - orig_bandwidth = *bandwidth; - for (;;) - { - opus_int32 hysteresis; - opus_int32 LBRR_rate_thres_bps; - /* Compute threshold for using FEC at the current bandwidth setting */ - LBRR_rate_thres_bps = fec_thresholds[2*(*bandwidth - OPUS_BANDWIDTH_NARROWBAND)]; - hysteresis = fec_thresholds[2*(*bandwidth - OPUS_BANDWIDTH_NARROWBAND) + 1]; - if (last_fec == 1) LBRR_rate_thres_bps -= hysteresis; - if (last_fec == 0) LBRR_rate_thres_bps += hysteresis; - LBRR_rate_thres_bps = silk_SMULWB( silk_MUL( LBRR_rate_thres_bps, - 125 - silk_min( PacketLoss_perc, 25 ) ), SILK_FIX_CONST( 0.01, 16 ) ); - /* If loss <= 5%, we look at whether we have enough rate to enable FEC. - If loss > 5%, we decrease the bandwidth until we can enable FEC. */ - if (rate > LBRR_rate_thres_bps) - return 1; - else if (PacketLoss_perc <= 5) - return 0; - else if (*bandwidth > OPUS_BANDWIDTH_NARROWBAND) - (*bandwidth)--; - else - break; - } - /* Couldn't find any bandwidth to enable FEC, keep original bandwidth. */ - *bandwidth = orig_bandwidth; - return 0; -} - -static int compute_silk_rate_for_hybrid(int rate, int bandwidth, int frame20ms, int vbr, int fec, int channels) { - int entry; - int i; - int N; - int silk_rate; - static int rate_table[][5] = { - /* |total| |-------- SILK------------| - |-- No FEC -| |--- FEC ---| - 10ms 20ms 10ms 20ms */ - { 0, 0, 0, 0, 0}, - {12000, 10000, 10000, 11000, 11000}, - {16000, 13500, 13500, 15000, 15000}, - {20000, 16000, 16000, 18000, 18000}, - {24000, 18000, 18000, 21000, 21000}, - {32000, 22000, 22000, 28000, 28000}, - {64000, 38000, 38000, 50000, 50000} - }; - /* Do the allocation per-channel. */ - rate /= channels; - entry = 1 + frame20ms + 2*fec; - N = sizeof(rate_table)/sizeof(rate_table[0]); - for (i=1;i rate) break; - } - if (i == N) - { - silk_rate = rate_table[i-1][entry]; - /* For now, just give 50% of the extra bits to SILK. */ - silk_rate += (rate-rate_table[i-1][0])/2; - } else { - opus_int32 lo, hi, x0, x1; - lo = rate_table[i-1][entry]; - hi = rate_table[i][entry]; - x0 = rate_table[i-1][0]; - x1 = rate_table[i][0]; - silk_rate = (lo*(x1-rate) + hi*(rate-x0))/(x1-x0); - } - if (!vbr) - { - /* Tiny boost to SILK for CBR. We should probably tune this better. */ - silk_rate += 100; - } - if (bandwidth==OPUS_BANDWIDTH_SUPERWIDEBAND) - silk_rate += 300; - silk_rate *= channels; - /* Small adjustment for stereo (calibrated for 32 kb/s, haven't tried other bitrates). */ - if (channels == 2 && rate >= 12000) - silk_rate -= 1000; - return silk_rate; -} - -/* Returns the equivalent bitrate corresponding to 20 ms frames, - complexity 10 VBR operation. */ -static opus_int32 compute_equiv_rate(opus_int32 bitrate, int channels, - int frame_rate, int vbr, int mode, int complexity, int loss) -{ - opus_int32 equiv; - equiv = bitrate; - /* Take into account overhead from smaller frames. */ - if (frame_rate > 50) - equiv -= (40*channels+20)*(frame_rate - 50); - /* CBR is about a 8% penalty for both SILK and CELT. */ - if (!vbr) - equiv -= equiv/12; - /* Complexity makes about 10% difference (from 0 to 10) in general. */ - equiv = equiv * (90+complexity)/100; - if (mode == MODE_SILK_ONLY || mode == MODE_HYBRID) - { - /* SILK complexity 0-1 uses the non-delayed-decision NSQ, which - costs about 20%. */ - if (complexity<2) - equiv = equiv*4/5; - equiv -= equiv*loss/(6*loss + 10); - } else if (mode == MODE_CELT_ONLY) { - /* CELT complexity 0-4 doesn't have the pitch filter, which costs - about 10%. */ - if (complexity<5) - equiv = equiv*9/10; - } else { - /* Mode not known yet */ - /* Half the SILK loss*/ - equiv -= equiv*loss/(12*loss + 20); - } - return equiv; -} - -#ifndef DISABLE_FLOAT_API - -int is_digital_silence(const opus_val16* pcm, int frame_size, int channels, int lsb_depth) -{ - int silence = 0; - opus_val32 sample_max = 0; -#ifdef MLP_TRAINING - return 0; -#endif - sample_max = celt_maxabs16(pcm, frame_size*channels); - -#ifdef FIXED_POINT - silence = (sample_max == 0); - (void)lsb_depth; -#else - silence = (sample_max <= (opus_val16) 1 / (1 << lsb_depth)); -#endif - - return silence; -} - -#ifdef FIXED_POINT -static opus_val32 compute_frame_energy(const opus_val16 *pcm, int frame_size, int channels, int arch) -{ - int i; - opus_val32 sample_max; - int max_shift; - int shift; - opus_val32 energy = 0; - int len = frame_size*channels; - (void)arch; - /* Max amplitude in the signal */ - sample_max = celt_maxabs16(pcm, len); - - /* Compute the right shift required in the MAC to avoid an overflow */ - max_shift = celt_ilog2(len); - shift = IMAX(0, (celt_ilog2(sample_max) << 1) + max_shift - 28); - - /* Compute the energy */ - for (i=0; i NB_SPEECH_FRAMES_BEFORE_DTX*20*2) - { - if (*nb_no_activity_ms_Q1 <= (NB_SPEECH_FRAMES_BEFORE_DTX + MAX_CONSECUTIVE_DTX)*20*2) - /* Valid frame for DTX! */ - return 1; - else - (*nb_no_activity_ms_Q1) = NB_SPEECH_FRAMES_BEFORE_DTX*20*2; - } - } else - (*nb_no_activity_ms_Q1) = 0; - - return 0; -} - -#endif - -static opus_int32 encode_multiframe_packet(OpusEncoder *st, - const opus_val16 *pcm, - int nb_frames, - int frame_size, - unsigned char *data, - opus_int32 out_data_bytes, - int to_celt, - int lsb_depth, - int float_api) -{ - int i; - int ret = 0; - VARDECL(unsigned char, tmp_data); - int bak_mode, bak_bandwidth, bak_channels, bak_to_mono; - VARDECL(OpusRepacketizer, rp); - int max_header_bytes; - opus_int32 bytes_per_frame; - opus_int32 cbr_bytes; - opus_int32 repacketize_len; - int tmp_len; - ALLOC_STACK; - - /* Worst cases: - * 2 frames: Code 2 with different compressed sizes - * >2 frames: Code 3 VBR */ - max_header_bytes = nb_frames == 2 ? 3 : (2+(nb_frames-1)*2); - - if (st->use_vbr || st->user_bitrate_bps==OPUS_BITRATE_MAX) - repacketize_len = out_data_bytes; - else { - cbr_bytes = 3*st->bitrate_bps/(3*8*st->Fs/(frame_size*nb_frames)); - repacketize_len = IMIN(cbr_bytes, out_data_bytes); - } - bytes_per_frame = IMIN(1276, 1+(repacketize_len-max_header_bytes)/nb_frames); - - ALLOC(tmp_data, nb_frames*bytes_per_frame, unsigned char); - ALLOC(rp, 1, OpusRepacketizer); - opus_repacketizer_init(rp); - - bak_mode = st->user_forced_mode; - bak_bandwidth = st->user_bandwidth; - bak_channels = st->force_channels; - - st->user_forced_mode = st->mode; - st->user_bandwidth = st->bandwidth; - st->force_channels = st->stream_channels; - - bak_to_mono = st->silk_mode.toMono; - if (bak_to_mono) - st->force_channels = 1; - else - st->prev_channels = st->stream_channels; - - for (i=0;isilk_mode.toMono = 0; - st->nonfinal_frame = i<(nb_frames-1); - - /* When switching from SILK/Hybrid to CELT, only ask for a switch at the last frame */ - if (to_celt && i==nb_frames-1) - st->user_forced_mode = MODE_CELT_ONLY; - - tmp_len = opus_encode_native(st, pcm+i*(st->channels*frame_size), frame_size, - tmp_data+i*bytes_per_frame, bytes_per_frame, lsb_depth, NULL, 0, 0, 0, 0, - NULL, float_api); - - if (tmp_len<0) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - - ret = opus_repacketizer_cat(rp, tmp_data+i*bytes_per_frame, tmp_len); - - if (ret<0) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - } - - ret = opus_repacketizer_out_range_impl(rp, 0, nb_frames, data, repacketize_len, 0, !st->use_vbr); - - if (ret<0) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - - /* Discard configs that were forced locally for the purpose of repacketization */ - st->user_forced_mode = bak_mode; - st->user_bandwidth = bak_bandwidth; - st->force_channels = bak_channels; - st->silk_mode.toMono = bak_to_mono; - - RESTORE_STACK; - return ret; -} - -static int compute_redundancy_bytes(opus_int32 max_data_bytes, opus_int32 bitrate_bps, int frame_rate, int channels) -{ - int redundancy_bytes_cap; - int redundancy_bytes; - opus_int32 redundancy_rate; - int base_bits; - opus_int32 available_bits; - base_bits = (40*channels+20); - - /* Equivalent rate for 5 ms frames. */ - redundancy_rate = bitrate_bps + base_bits*(200 - frame_rate); - /* For VBR, further increase the bitrate if we can afford it. It's pretty short - and we'll avoid artefacts. */ - redundancy_rate = 3*redundancy_rate/2; - redundancy_bytes = redundancy_rate/1600; - - /* Compute the max rate we can use given CBR or VBR with cap. */ - available_bits = max_data_bytes*8 - 2*base_bits; - redundancy_bytes_cap = (available_bits*240/(240+48000/frame_rate) + base_bits)/8; - redundancy_bytes = IMIN(redundancy_bytes, redundancy_bytes_cap); - /* It we can't get enough bits for redundancy to be worth it, rely on the decoder PLC. */ - if (redundancy_bytes > 4 + 8*channels) - redundancy_bytes = IMIN(257, redundancy_bytes); - else - redundancy_bytes = 0; - return redundancy_bytes; -} - -opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size, - unsigned char *data, opus_int32 out_data_bytes, int lsb_depth, - const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, - int analysis_channels, downmix_func downmix, int float_api) -{ - void *silk_enc; - CELTEncoder *celt_enc; - int i; - int ret=0; - opus_int32 nBytes; - ec_enc enc; - int bytes_target; - int prefill=0; - int start_band = 0; - int redundancy = 0; - int redundancy_bytes = 0; /* Number of bytes to use for redundancy frame */ - int celt_to_silk = 0; - VARDECL(opus_val16, pcm_buf); - int nb_compr_bytes; - int to_celt = 0; - opus_uint32 redundant_rng = 0; - int cutoff_Hz, hp_freq_smth1; - int voice_est; /* Probability of voice in Q7 */ - opus_int32 equiv_rate; - int delay_compensation; - int frame_rate; - opus_int32 max_rate; /* Max bitrate we're allowed to use */ - int curr_bandwidth; - opus_val16 HB_gain; - opus_int32 max_data_bytes; /* Max number of bytes we're allowed to use */ - int total_buffer; - opus_val16 stereo_width; - const CELTMode *celt_mode; -#ifndef DISABLE_FLOAT_API - AnalysisInfo analysis_info; - int analysis_read_pos_bak=-1; - int analysis_read_subframe_bak=-1; - int is_silence = 0; -#endif - opus_int activity = VAD_NO_DECISION; - - VARDECL(opus_val16, tmp_prefill); - - ALLOC_STACK; - - max_data_bytes = IMIN(1276, out_data_bytes); - - st->rangeFinal = 0; - if (frame_size <= 0 || max_data_bytes <= 0) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - - /* Cannot encode 100 ms in 1 byte */ - if (max_data_bytes==1 && st->Fs==(frame_size*10)) - { - RESTORE_STACK; - return OPUS_BUFFER_TOO_SMALL; - } - - silk_enc = (char*)st+st->silk_enc_offset; - celt_enc = (CELTEncoder*)((char*)st+st->celt_enc_offset); - if (st->application == OPUS_APPLICATION_RESTRICTED_LOWDELAY) - delay_compensation = 0; - else - delay_compensation = st->delay_compensation; - - lsb_depth = IMIN(lsb_depth, st->lsb_depth); - - celt_encoder_ctl(celt_enc, CELT_GET_MODE(&celt_mode)); -#ifndef DISABLE_FLOAT_API - analysis_info.valid = 0; -#ifdef FIXED_POINT - if (st->silk_mode.complexity >= 10 && st->Fs>=16000) -#else - if (st->silk_mode.complexity >= 7 && st->Fs>=16000) -#endif - { - is_silence = is_digital_silence(pcm, frame_size, st->channels, lsb_depth); - analysis_read_pos_bak = st->analysis.read_pos; - analysis_read_subframe_bak = st->analysis.read_subframe; - run_analysis(&st->analysis, celt_mode, analysis_pcm, analysis_size, frame_size, - c1, c2, analysis_channels, st->Fs, - lsb_depth, downmix, &analysis_info); - - /* Track the peak signal energy */ - if (!is_silence && analysis_info.activity_probability > DTX_ACTIVITY_THRESHOLD) - st->peak_signal_energy = MAX32(MULT16_32_Q15(QCONST16(0.999f, 15), st->peak_signal_energy), - compute_frame_energy(pcm, frame_size, st->channels, st->arch)); - } else if (st->analysis.initialized) { - tonality_analysis_reset(&st->analysis); - } -#else - (void)analysis_pcm; - (void)analysis_size; - (void)c1; - (void)c2; - (void)analysis_channels; - (void)downmix; -#endif - -#ifndef DISABLE_FLOAT_API - /* Reset voice_ratio if this frame is not silent or if analysis is disabled. - * Otherwise, preserve voice_ratio from the last non-silent frame */ - if (!is_silence) - st->voice_ratio = -1; - - if (is_silence) - { - activity = !is_silence; - } else if (analysis_info.valid) - { - activity = analysis_info.activity_probability >= DTX_ACTIVITY_THRESHOLD; - if (!activity) - { - /* Mark as active if this noise frame is sufficiently loud */ - opus_val32 noise_energy = compute_frame_energy(pcm, frame_size, st->channels, st->arch); - activity = st->peak_signal_energy < (PSEUDO_SNR_THRESHOLD * noise_energy); - } - } - - st->detected_bandwidth = 0; - if (analysis_info.valid) - { - int analysis_bandwidth; - if (st->signal_type == OPUS_AUTO) - { - float prob; - if (st->prev_mode == 0) - prob = analysis_info.music_prob; - else if (st->prev_mode == MODE_CELT_ONLY) - prob = analysis_info.music_prob_max; - else - prob = analysis_info.music_prob_min; - st->voice_ratio = (int)floor(.5+100*(1-prob)); - } - - analysis_bandwidth = analysis_info.bandwidth; - if (analysis_bandwidth<=12) - st->detected_bandwidth = OPUS_BANDWIDTH_NARROWBAND; - else if (analysis_bandwidth<=14) - st->detected_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND; - else if (analysis_bandwidth<=16) - st->detected_bandwidth = OPUS_BANDWIDTH_WIDEBAND; - else if (analysis_bandwidth<=18) - st->detected_bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND; - else - st->detected_bandwidth = OPUS_BANDWIDTH_FULLBAND; - } -#else - st->voice_ratio = -1; -#endif - - if (st->channels==2 && st->force_channels!=1) - stereo_width = compute_stereo_width(pcm, frame_size, st->Fs, &st->width_mem); - else - stereo_width = 0; - total_buffer = delay_compensation; - st->bitrate_bps = user_bitrate_to_bitrate(st, frame_size, max_data_bytes); - - frame_rate = st->Fs/frame_size; - if (!st->use_vbr) - { - int cbrBytes; - /* Multiply by 12 to make sure the division is exact. */ - int frame_rate12 = 12*st->Fs/frame_size; - /* We need to make sure that "int" values always fit in 16 bits. */ - cbrBytes = IMIN( (12*st->bitrate_bps/8 + frame_rate12/2)/frame_rate12, max_data_bytes); - st->bitrate_bps = cbrBytes*(opus_int32)frame_rate12*8/12; - /* Make sure we provide at least one byte to avoid failing. */ - max_data_bytes = IMAX(1, cbrBytes); - } - if (max_data_bytes<3 || st->bitrate_bps < 3*frame_rate*8 - || (frame_rate<50 && (max_data_bytes*frame_rate<300 || st->bitrate_bps < 2400))) - { - /*If the space is too low to do something useful, emit 'PLC' frames.*/ - int tocmode = st->mode; - int bw = st->bandwidth == 0 ? OPUS_BANDWIDTH_NARROWBAND : st->bandwidth; - int packet_code = 0; - int num_multiframes = 0; - - if (tocmode==0) - tocmode = MODE_SILK_ONLY; - if (frame_rate>100) - tocmode = MODE_CELT_ONLY; - /* 40 ms -> 2 x 20 ms if in CELT_ONLY or HYBRID mode */ - if (frame_rate==25 && tocmode!=MODE_SILK_ONLY) - { - frame_rate = 50; - packet_code = 1; - } - - /* >= 60 ms frames */ - if (frame_rate<=16) - { - /* 1 x 60 ms, 2 x 40 ms, 2 x 60 ms */ - if (out_data_bytes==1 || (tocmode==MODE_SILK_ONLY && frame_rate!=10)) - { - tocmode = MODE_SILK_ONLY; - - packet_code = frame_rate <= 12; - frame_rate = frame_rate == 12 ? 25 : 16; - } - else - { - num_multiframes = 50/frame_rate; - frame_rate = 50; - packet_code = 3; - } - } - - if(tocmode==MODE_SILK_ONLY&&bw>OPUS_BANDWIDTH_WIDEBAND) - bw=OPUS_BANDWIDTH_WIDEBAND; - else if (tocmode==MODE_CELT_ONLY&&bw==OPUS_BANDWIDTH_MEDIUMBAND) - bw=OPUS_BANDWIDTH_NARROWBAND; - else if (tocmode==MODE_HYBRID&&bw<=OPUS_BANDWIDTH_SUPERWIDEBAND) - bw=OPUS_BANDWIDTH_SUPERWIDEBAND; - - data[0] = gen_toc(tocmode, frame_rate, bw, st->stream_channels); - data[0] |= packet_code; - - ret = packet_code <= 1 ? 1 : 2; - - max_data_bytes = IMAX(max_data_bytes, ret); - - if (packet_code==3) - data[1] = num_multiframes; - - if (!st->use_vbr) - { - ret = opus_packet_pad(data, ret, max_data_bytes); - if (ret == OPUS_OK) - ret = max_data_bytes; - else - ret = OPUS_INTERNAL_ERROR; - } - RESTORE_STACK; - return ret; - } - max_rate = frame_rate*max_data_bytes*8; - - /* Equivalent 20-ms rate for mode/channel/bandwidth decisions */ - equiv_rate = compute_equiv_rate(st->bitrate_bps, st->channels, st->Fs/frame_size, - st->use_vbr, 0, st->silk_mode.complexity, st->silk_mode.packetLossPercentage); - - if (st->signal_type == OPUS_SIGNAL_VOICE) - voice_est = 127; - else if (st->signal_type == OPUS_SIGNAL_MUSIC) - voice_est = 0; - else if (st->voice_ratio >= 0) - { - voice_est = st->voice_ratio*327>>8; - /* For AUDIO, never be more than 90% confident of having speech */ - if (st->application == OPUS_APPLICATION_AUDIO) - voice_est = IMIN(voice_est, 115); - } else if (st->application == OPUS_APPLICATION_VOIP) - voice_est = 115; - else - voice_est = 48; - - if (st->force_channels!=OPUS_AUTO && st->channels == 2) - { - st->stream_channels = st->force_channels; - } else { -#ifdef FUZZING - (void)stereo_music_threshold; - (void)stereo_voice_threshold; - /* Random mono/stereo decision */ - if (st->channels == 2 && (rand()&0x1F)==0) - st->stream_channels = 3-st->stream_channels; -#else - /* Rate-dependent mono-stereo decision */ - if (st->channels == 2) - { - opus_int32 stereo_threshold; - stereo_threshold = stereo_music_threshold + ((voice_est*voice_est*(stereo_voice_threshold-stereo_music_threshold))>>14); - if (st->stream_channels == 2) - stereo_threshold -= 1000; - else - stereo_threshold += 1000; - st->stream_channels = (equiv_rate > stereo_threshold) ? 2 : 1; - } else { - st->stream_channels = st->channels; - } -#endif - } - /* Update equivalent rate for channels decision. */ - equiv_rate = compute_equiv_rate(st->bitrate_bps, st->stream_channels, st->Fs/frame_size, - st->use_vbr, 0, st->silk_mode.complexity, st->silk_mode.packetLossPercentage); - - /* Allow SILK DTX if DTX is enabled but the generalized DTX cannot be used, - e.g. because of the complexity setting or sample rate. */ -#ifndef DISABLE_FLOAT_API - st->silk_mode.useDTX = st->use_dtx && !(analysis_info.valid || is_silence); -#else - st->silk_mode.useDTX = st->use_dtx; -#endif - - /* Mode selection depending on application and signal type */ - if (st->application == OPUS_APPLICATION_RESTRICTED_LOWDELAY) - { - st->mode = MODE_CELT_ONLY; - } else if (st->user_forced_mode == OPUS_AUTO) - { -#ifdef FUZZING - (void)stereo_width; - (void)mode_thresholds; - /* Random mode switching */ - if ((rand()&0xF)==0) - { - if ((rand()&0x1)==0) - st->mode = MODE_CELT_ONLY; - else - st->mode = MODE_SILK_ONLY; - } else { - if (st->prev_mode==MODE_CELT_ONLY) - st->mode = MODE_CELT_ONLY; - else - st->mode = MODE_SILK_ONLY; - } -#else - opus_int32 mode_voice, mode_music; - opus_int32 threshold; - - /* Interpolate based on stereo width */ - mode_voice = (opus_int32)(MULT16_32_Q15(Q15ONE-stereo_width,mode_thresholds[0][0]) - + MULT16_32_Q15(stereo_width,mode_thresholds[1][0])); - mode_music = (opus_int32)(MULT16_32_Q15(Q15ONE-stereo_width,mode_thresholds[1][1]) - + MULT16_32_Q15(stereo_width,mode_thresholds[1][1])); - /* Interpolate based on speech/music probability */ - threshold = mode_music + ((voice_est*voice_est*(mode_voice-mode_music))>>14); - /* Bias towards SILK for VoIP because of some useful features */ - if (st->application == OPUS_APPLICATION_VOIP) - threshold += 8000; - - /*printf("%f %d\n", stereo_width/(float)Q15ONE, threshold);*/ - /* Hysteresis */ - if (st->prev_mode == MODE_CELT_ONLY) - threshold -= 4000; - else if (st->prev_mode>0) - threshold += 4000; - - st->mode = (equiv_rate >= threshold) ? MODE_CELT_ONLY: MODE_SILK_ONLY; - - /* When FEC is enabled and there's enough packet loss, use SILK. - Unless the FEC is set to 2, in which case we don't switch to SILK if we're confident we have music. */ - if (st->silk_mode.useInBandFEC && st->silk_mode.packetLossPercentage > (128-voice_est)>>4 && (st->fec_config != 2 || voice_est > 25)) - st->mode = MODE_SILK_ONLY; - /* When encoding voice and DTX is enabled but the generalized DTX cannot be used, - use SILK in order to make use of its DTX. */ - if (st->silk_mode.useDTX && voice_est > 100) - st->mode = MODE_SILK_ONLY; -#endif - - /* If max_data_bytes represents less than 6 kb/s, switch to CELT-only mode */ - if (max_data_bytes < (frame_rate > 50 ? 9000 : 6000)*frame_size / (st->Fs * 8)) - st->mode = MODE_CELT_ONLY; - } else { - st->mode = st->user_forced_mode; - } - - /* Override the chosen mode to make sure we meet the requested frame size */ - if (st->mode != MODE_CELT_ONLY && frame_size < st->Fs/100) - st->mode = MODE_CELT_ONLY; - if (st->lfe) - st->mode = MODE_CELT_ONLY; - - if (st->prev_mode > 0 && - ((st->mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) || - (st->mode == MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY))) - { - redundancy = 1; - celt_to_silk = (st->mode != MODE_CELT_ONLY); - if (!celt_to_silk) - { - /* Switch to SILK/hybrid if frame size is 10 ms or more*/ - if (frame_size >= st->Fs/100) - { - st->mode = st->prev_mode; - to_celt = 1; - } else { - redundancy=0; - } - } - } - - /* When encoding multiframes, we can ask for a switch to CELT only in the last frame. This switch - * is processed above as the requested mode shouldn't interrupt stereo->mono transition. */ - if (st->stream_channels == 1 && st->prev_channels ==2 && st->silk_mode.toMono==0 - && st->mode != MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY) - { - /* Delay stereo->mono transition by two frames so that SILK can do a smooth downmix */ - st->silk_mode.toMono = 1; - st->stream_channels = 2; - } else { - st->silk_mode.toMono = 0; - } - - /* Update equivalent rate with mode decision. */ - equiv_rate = compute_equiv_rate(st->bitrate_bps, st->stream_channels, st->Fs/frame_size, - st->use_vbr, st->mode, st->silk_mode.complexity, st->silk_mode.packetLossPercentage); - - if (st->mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) - { - silk_EncControlStruct dummy; - silk_InitEncoder( silk_enc, st->arch, &dummy); - prefill=1; - } - - /* Automatic (rate-dependent) bandwidth selection */ - if (st->mode == MODE_CELT_ONLY || st->first || st->silk_mode.allowBandwidthSwitch) - { - const opus_int32 *voice_bandwidth_thresholds, *music_bandwidth_thresholds; - opus_int32 bandwidth_thresholds[8]; - int bandwidth = OPUS_BANDWIDTH_FULLBAND; - - if (st->channels==2 && st->force_channels!=1) - { - voice_bandwidth_thresholds = stereo_voice_bandwidth_thresholds; - music_bandwidth_thresholds = stereo_music_bandwidth_thresholds; - } else { - voice_bandwidth_thresholds = mono_voice_bandwidth_thresholds; - music_bandwidth_thresholds = mono_music_bandwidth_thresholds; - } - /* Interpolate bandwidth thresholds depending on voice estimation */ - for (i=0;i<8;i++) - { - bandwidth_thresholds[i] = music_bandwidth_thresholds[i] - + ((voice_est*voice_est*(voice_bandwidth_thresholds[i]-music_bandwidth_thresholds[i]))>>14); - } - do { - int threshold, hysteresis; - threshold = bandwidth_thresholds[2*(bandwidth-OPUS_BANDWIDTH_MEDIUMBAND)]; - hysteresis = bandwidth_thresholds[2*(bandwidth-OPUS_BANDWIDTH_MEDIUMBAND)+1]; - if (!st->first) - { - if (st->auto_bandwidth >= bandwidth) - threshold -= hysteresis; - else - threshold += hysteresis; - } - if (equiv_rate >= threshold) - break; - } while (--bandwidth>OPUS_BANDWIDTH_NARROWBAND); - /* We don't use mediumband anymore, except when explicitly requested or during - mode transitions. */ - if (bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) - bandwidth = OPUS_BANDWIDTH_WIDEBAND; - st->bandwidth = st->auto_bandwidth = bandwidth; - /* Prevents any transition to SWB/FB until the SILK layer has fully - switched to WB mode and turned the variable LP filter off */ - if (!st->first && st->mode != MODE_CELT_ONLY && !st->silk_mode.inWBmodeWithoutVariableLP && st->bandwidth > OPUS_BANDWIDTH_WIDEBAND) - st->bandwidth = OPUS_BANDWIDTH_WIDEBAND; - } - - if (st->bandwidth>st->max_bandwidth) - st->bandwidth = st->max_bandwidth; - - if (st->user_bandwidth != OPUS_AUTO) - st->bandwidth = st->user_bandwidth; - - /* This prevents us from using hybrid at unsafe CBR/max rates */ - if (st->mode != MODE_CELT_ONLY && max_rate < 15000) - { - st->bandwidth = IMIN(st->bandwidth, OPUS_BANDWIDTH_WIDEBAND); - } - - /* Prevents Opus from wasting bits on frequencies that are above - the Nyquist rate of the input signal */ - if (st->Fs <= 24000 && st->bandwidth > OPUS_BANDWIDTH_SUPERWIDEBAND) - st->bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND; - if (st->Fs <= 16000 && st->bandwidth > OPUS_BANDWIDTH_WIDEBAND) - st->bandwidth = OPUS_BANDWIDTH_WIDEBAND; - if (st->Fs <= 12000 && st->bandwidth > OPUS_BANDWIDTH_MEDIUMBAND) - st->bandwidth = OPUS_BANDWIDTH_MEDIUMBAND; - if (st->Fs <= 8000 && st->bandwidth > OPUS_BANDWIDTH_NARROWBAND) - st->bandwidth = OPUS_BANDWIDTH_NARROWBAND; -#ifndef DISABLE_FLOAT_API - /* Use detected bandwidth to reduce the encoded bandwidth. */ - if (st->detected_bandwidth && st->user_bandwidth == OPUS_AUTO) - { - int min_detected_bandwidth; - /* Makes bandwidth detection more conservative just in case the detector - gets it wrong when we could have coded a high bandwidth transparently. - When operating in SILK/hybrid mode, we don't go below wideband to avoid - more complicated switches that require redundancy. */ - if (equiv_rate <= 18000*st->stream_channels && st->mode == MODE_CELT_ONLY) - min_detected_bandwidth = OPUS_BANDWIDTH_NARROWBAND; - else if (equiv_rate <= 24000*st->stream_channels && st->mode == MODE_CELT_ONLY) - min_detected_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND; - else if (equiv_rate <= 30000*st->stream_channels) - min_detected_bandwidth = OPUS_BANDWIDTH_WIDEBAND; - else if (equiv_rate <= 44000*st->stream_channels) - min_detected_bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND; - else - min_detected_bandwidth = OPUS_BANDWIDTH_FULLBAND; - - st->detected_bandwidth = IMAX(st->detected_bandwidth, min_detected_bandwidth); - st->bandwidth = IMIN(st->bandwidth, st->detected_bandwidth); - } -#endif - st->silk_mode.LBRR_coded = decide_fec(st->silk_mode.useInBandFEC, st->silk_mode.packetLossPercentage, - st->silk_mode.LBRR_coded, st->mode, &st->bandwidth, equiv_rate); - celt_encoder_ctl(celt_enc, OPUS_SET_LSB_DEPTH(lsb_depth)); - - /* CELT mode doesn't support mediumband, use wideband instead */ - if (st->mode == MODE_CELT_ONLY && st->bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) - st->bandwidth = OPUS_BANDWIDTH_WIDEBAND; - if (st->lfe) - st->bandwidth = OPUS_BANDWIDTH_NARROWBAND; - - curr_bandwidth = st->bandwidth; - - /* Chooses the appropriate mode for speech - *NEVER* switch to/from CELT-only mode here as this will invalidate some assumptions */ - if (st->mode == MODE_SILK_ONLY && curr_bandwidth > OPUS_BANDWIDTH_WIDEBAND) - st->mode = MODE_HYBRID; - if (st->mode == MODE_HYBRID && curr_bandwidth <= OPUS_BANDWIDTH_WIDEBAND) - st->mode = MODE_SILK_ONLY; - - /* Can't support higher than >60 ms frames, and >20 ms when in Hybrid or CELT-only modes */ - if ((frame_size > st->Fs/50 && (st->mode != MODE_SILK_ONLY)) || frame_size > 3*st->Fs/50) - { - int enc_frame_size; - int nb_frames; - - if (st->mode == MODE_SILK_ONLY) - { - if (frame_size == 2*st->Fs/25) /* 80 ms -> 2x 40 ms */ - enc_frame_size = st->Fs/25; - else if (frame_size == 3*st->Fs/25) /* 120 ms -> 2x 60 ms */ - enc_frame_size = 3*st->Fs/50; - else /* 100 ms -> 5x 20 ms */ - enc_frame_size = st->Fs/50; - } - else - enc_frame_size = st->Fs/50; - - nb_frames = frame_size/enc_frame_size; - -#ifndef DISABLE_FLOAT_API - if (analysis_read_pos_bak!= -1) - { - st->analysis.read_pos = analysis_read_pos_bak; - st->analysis.read_subframe = analysis_read_subframe_bak; - } -#endif - - ret = encode_multiframe_packet(st, pcm, nb_frames, enc_frame_size, data, - out_data_bytes, to_celt, lsb_depth, float_api); - - RESTORE_STACK; - return ret; - } - - /* For the first frame at a new SILK bandwidth */ - if (st->silk_bw_switch) - { - redundancy = 1; - celt_to_silk = 1; - st->silk_bw_switch = 0; - /* Do a prefill without reseting the sampling rate control. */ - prefill=2; - } - - /* If we decided to go with CELT, make sure redundancy is off, no matter what - we decided earlier. */ - if (st->mode == MODE_CELT_ONLY) - redundancy = 0; - - if (redundancy) - { - redundancy_bytes = compute_redundancy_bytes(max_data_bytes, st->bitrate_bps, frame_rate, st->stream_channels); - if (redundancy_bytes == 0) - redundancy = 0; - } - - /* printf("%d %d %d %d\n", st->bitrate_bps, st->stream_channels, st->mode, curr_bandwidth); */ - bytes_target = IMIN(max_data_bytes-redundancy_bytes, st->bitrate_bps * frame_size / (st->Fs * 8)) - 1; - - data += 1; - - ec_enc_init(&enc, data, max_data_bytes-1); - - ALLOC(pcm_buf, (total_buffer+frame_size)*st->channels, opus_val16); - OPUS_COPY(pcm_buf, &st->delay_buffer[(st->encoder_buffer-total_buffer)*st->channels], total_buffer*st->channels); - - if (st->mode == MODE_CELT_ONLY) - hp_freq_smth1 = silk_LSHIFT( silk_lin2log( VARIABLE_HP_MIN_CUTOFF_HZ ), 8 ); - else - hp_freq_smth1 = ((silk_encoder*)silk_enc)->state_Fxx[0].sCmn.variable_HP_smth1_Q15; - - st->variable_HP_smth2_Q15 = silk_SMLAWB( st->variable_HP_smth2_Q15, - hp_freq_smth1 - st->variable_HP_smth2_Q15, SILK_FIX_CONST( VARIABLE_HP_SMTH_COEF2, 16 ) ); - - /* convert from log scale to Hertz */ - cutoff_Hz = silk_log2lin( silk_RSHIFT( st->variable_HP_smth2_Q15, 8 ) ); - - if (st->application == OPUS_APPLICATION_VOIP) - { - hp_cutoff(pcm, cutoff_Hz, &pcm_buf[total_buffer*st->channels], st->hp_mem, frame_size, st->channels, st->Fs, st->arch); - } else { - dc_reject(pcm, 3, &pcm_buf[total_buffer*st->channels], st->hp_mem, frame_size, st->channels, st->Fs); - } -#ifndef FIXED_POINT - if (float_api) - { - opus_val32 sum; - sum = celt_inner_prod(&pcm_buf[total_buffer*st->channels], &pcm_buf[total_buffer*st->channels], frame_size*st->channels, st->arch); - /* This should filter out both NaNs and ridiculous signals that could - cause NaNs further down. */ - if (!(sum < 1e9f) || celt_isnan(sum)) - { - OPUS_CLEAR(&pcm_buf[total_buffer*st->channels], frame_size*st->channels); - st->hp_mem[0] = st->hp_mem[1] = st->hp_mem[2] = st->hp_mem[3] = 0; - } - } -#endif - - - /* SILK processing */ - HB_gain = Q15ONE; - if (st->mode != MODE_CELT_ONLY) - { - opus_int32 total_bitRate, celt_rate; -#ifdef FIXED_POINT - const opus_int16 *pcm_silk; -#else - VARDECL(opus_int16, pcm_silk); - ALLOC(pcm_silk, st->channels*frame_size, opus_int16); -#endif - - /* Distribute bits between SILK and CELT */ - total_bitRate = 8 * bytes_target * frame_rate; - if( st->mode == MODE_HYBRID ) { - /* Base rate for SILK */ - st->silk_mode.bitRate = compute_silk_rate_for_hybrid(total_bitRate, - curr_bandwidth, st->Fs == 50 * frame_size, st->use_vbr, st->silk_mode.LBRR_coded, - st->stream_channels); - if (!st->energy_masking) - { - /* Increasingly attenuate high band when it gets allocated fewer bits */ - celt_rate = total_bitRate - st->silk_mode.bitRate; - HB_gain = Q15ONE - SHR32(celt_exp2(-celt_rate * QCONST16(1.f/1024, 10)), 1); - } - } else { - /* SILK gets all bits */ - st->silk_mode.bitRate = total_bitRate; - } - - /* Surround masking for SILK */ - if (st->energy_masking && st->use_vbr && !st->lfe) - { - opus_val32 mask_sum=0; - opus_val16 masking_depth; - opus_int32 rate_offset; - int c; - int end = 17; - opus_int16 srate = 16000; - if (st->bandwidth == OPUS_BANDWIDTH_NARROWBAND) - { - end = 13; - srate = 8000; - } else if (st->bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) - { - end = 15; - srate = 12000; - } - for (c=0;cchannels;c++) - { - for(i=0;ienergy_masking[21*c+i], - QCONST16(.5f, DB_SHIFT)), -QCONST16(2.0f, DB_SHIFT)); - if (mask > 0) - mask = HALF16(mask); - mask_sum += mask; - } - } - /* Conservative rate reduction, we cut the masking in half */ - masking_depth = mask_sum / end*st->channels; - masking_depth += QCONST16(.2f, DB_SHIFT); - rate_offset = (opus_int32)PSHR32(MULT16_16(srate, masking_depth), DB_SHIFT); - rate_offset = MAX32(rate_offset, -2*st->silk_mode.bitRate/3); - /* Split the rate change between the SILK and CELT part for hybrid. */ - if (st->bandwidth==OPUS_BANDWIDTH_SUPERWIDEBAND || st->bandwidth==OPUS_BANDWIDTH_FULLBAND) - st->silk_mode.bitRate += 3*rate_offset/5; - else - st->silk_mode.bitRate += rate_offset; - } - - st->silk_mode.payloadSize_ms = 1000 * frame_size / st->Fs; - st->silk_mode.nChannelsAPI = st->channels; - st->silk_mode.nChannelsInternal = st->stream_channels; - if (curr_bandwidth == OPUS_BANDWIDTH_NARROWBAND) { - st->silk_mode.desiredInternalSampleRate = 8000; - } else if (curr_bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) { - st->silk_mode.desiredInternalSampleRate = 12000; - } else { - celt_assert( st->mode == MODE_HYBRID || curr_bandwidth == OPUS_BANDWIDTH_WIDEBAND ); - st->silk_mode.desiredInternalSampleRate = 16000; - } - if( st->mode == MODE_HYBRID ) { - /* Don't allow bandwidth reduction at lowest bitrates in hybrid mode */ - st->silk_mode.minInternalSampleRate = 16000; - } else { - st->silk_mode.minInternalSampleRate = 8000; - } - - st->silk_mode.maxInternalSampleRate = 16000; - if (st->mode == MODE_SILK_ONLY) - { - opus_int32 effective_max_rate = max_rate; - if (frame_rate > 50) - effective_max_rate = effective_max_rate*2/3; - if (effective_max_rate < 8000) - { - st->silk_mode.maxInternalSampleRate = 12000; - st->silk_mode.desiredInternalSampleRate = IMIN(12000, st->silk_mode.desiredInternalSampleRate); - } - if (effective_max_rate < 7000) - { - st->silk_mode.maxInternalSampleRate = 8000; - st->silk_mode.desiredInternalSampleRate = IMIN(8000, st->silk_mode.desiredInternalSampleRate); - } - } - - st->silk_mode.useCBR = !st->use_vbr; - - /* Call SILK encoder for the low band */ - - /* Max bits for SILK, counting ToC, redundancy bytes, and optionally redundancy. */ - st->silk_mode.maxBits = (max_data_bytes-1)*8; - if (redundancy && redundancy_bytes >= 2) - { - /* Counting 1 bit for redundancy position and 20 bits for flag+size (only for hybrid). */ - st->silk_mode.maxBits -= redundancy_bytes*8 + 1; - if (st->mode == MODE_HYBRID) - st->silk_mode.maxBits -= 20; - } - if (st->silk_mode.useCBR) - { - if (st->mode == MODE_HYBRID) - { - st->silk_mode.maxBits = IMIN(st->silk_mode.maxBits, st->silk_mode.bitRate * frame_size / st->Fs); - } - } else { - /* Constrained VBR. */ - if (st->mode == MODE_HYBRID) - { - /* Compute SILK bitrate corresponding to the max total bits available */ - opus_int32 maxBitRate = compute_silk_rate_for_hybrid(st->silk_mode.maxBits*st->Fs / frame_size, - curr_bandwidth, st->Fs == 50 * frame_size, st->use_vbr, st->silk_mode.LBRR_coded, - st->stream_channels); - st->silk_mode.maxBits = maxBitRate * frame_size / st->Fs; - } - } - - if (prefill) - { - opus_int32 zero=0; - int prefill_offset; - /* Use a smooth onset for the SILK prefill to avoid the encoder trying to encode - a discontinuity. The exact location is what we need to avoid leaving any "gap" - in the audio when mixing with the redundant CELT frame. Here we can afford to - overwrite st->delay_buffer because the only thing that uses it before it gets - rewritten is tmp_prefill[] and even then only the part after the ramp really - gets used (rather than sent to the encoder and discarded) */ - prefill_offset = st->channels*(st->encoder_buffer-st->delay_compensation-st->Fs/400); - gain_fade(st->delay_buffer+prefill_offset, st->delay_buffer+prefill_offset, - 0, Q15ONE, celt_mode->overlap, st->Fs/400, st->channels, celt_mode->window, st->Fs); - OPUS_CLEAR(st->delay_buffer, prefill_offset); -#ifdef FIXED_POINT - pcm_silk = st->delay_buffer; -#else - for (i=0;iencoder_buffer*st->channels;i++) - pcm_silk[i] = FLOAT2INT16(st->delay_buffer[i]); -#endif - silk_Encode( silk_enc, &st->silk_mode, pcm_silk, st->encoder_buffer, NULL, &zero, prefill, activity ); - /* Prevent a second switch in the real encode call. */ - st->silk_mode.opusCanSwitch = 0; - } - -#ifdef FIXED_POINT - pcm_silk = pcm_buf+total_buffer*st->channels; -#else - for (i=0;ichannels;i++) - pcm_silk[i] = FLOAT2INT16(pcm_buf[total_buffer*st->channels + i]); -#endif - ret = silk_Encode( silk_enc, &st->silk_mode, pcm_silk, frame_size, &enc, &nBytes, 0, activity ); - if( ret ) { - /*fprintf (stderr, "SILK encode error: %d\n", ret);*/ - /* Handle error */ - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - - /* Extract SILK internal bandwidth for signaling in first byte */ - if( st->mode == MODE_SILK_ONLY ) { - if( st->silk_mode.internalSampleRate == 8000 ) { - curr_bandwidth = OPUS_BANDWIDTH_NARROWBAND; - } else if( st->silk_mode.internalSampleRate == 12000 ) { - curr_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND; - } else if( st->silk_mode.internalSampleRate == 16000 ) { - curr_bandwidth = OPUS_BANDWIDTH_WIDEBAND; - } - } else { - celt_assert( st->silk_mode.internalSampleRate == 16000 ); - } - - st->silk_mode.opusCanSwitch = st->silk_mode.switchReady && !st->nonfinal_frame; - - if (nBytes==0) - { - st->rangeFinal = 0; - data[-1] = gen_toc(st->mode, st->Fs/frame_size, curr_bandwidth, st->stream_channels); - RESTORE_STACK; - return 1; - } - - /* FIXME: How do we allocate the redundancy for CBR? */ - if (st->silk_mode.opusCanSwitch) - { - redundancy_bytes = compute_redundancy_bytes(max_data_bytes, st->bitrate_bps, frame_rate, st->stream_channels); - redundancy = (redundancy_bytes != 0); - celt_to_silk = 0; - st->silk_bw_switch = 1; - } - } - - /* CELT processing */ - { - int endband=21; - - switch(curr_bandwidth) - { - case OPUS_BANDWIDTH_NARROWBAND: - endband = 13; - break; - case OPUS_BANDWIDTH_MEDIUMBAND: - case OPUS_BANDWIDTH_WIDEBAND: - endband = 17; - break; - case OPUS_BANDWIDTH_SUPERWIDEBAND: - endband = 19; - break; - case OPUS_BANDWIDTH_FULLBAND: - endband = 21; - break; - } - celt_encoder_ctl(celt_enc, CELT_SET_END_BAND(endband)); - celt_encoder_ctl(celt_enc, CELT_SET_CHANNELS(st->stream_channels)); - } - celt_encoder_ctl(celt_enc, OPUS_SET_BITRATE(OPUS_BITRATE_MAX)); - if (st->mode != MODE_SILK_ONLY) - { - opus_val32 celt_pred=2; - celt_encoder_ctl(celt_enc, OPUS_SET_VBR(0)); - /* We may still decide to disable prediction later */ - if (st->silk_mode.reducedDependency) - celt_pred = 0; - celt_encoder_ctl(celt_enc, CELT_SET_PREDICTION(celt_pred)); - - if (st->mode == MODE_HYBRID) - { - if( st->use_vbr ) { - celt_encoder_ctl(celt_enc, OPUS_SET_BITRATE(st->bitrate_bps-st->silk_mode.bitRate)); - celt_encoder_ctl(celt_enc, OPUS_SET_VBR_CONSTRAINT(0)); - } - } else { - if (st->use_vbr) - { - celt_encoder_ctl(celt_enc, OPUS_SET_VBR(1)); - celt_encoder_ctl(celt_enc, OPUS_SET_VBR_CONSTRAINT(st->vbr_constraint)); - celt_encoder_ctl(celt_enc, OPUS_SET_BITRATE(st->bitrate_bps)); - } - } - } - - ALLOC(tmp_prefill, st->channels*st->Fs/400, opus_val16); - if (st->mode != MODE_SILK_ONLY && st->mode != st->prev_mode && st->prev_mode > 0) - { - OPUS_COPY(tmp_prefill, &st->delay_buffer[(st->encoder_buffer-total_buffer-st->Fs/400)*st->channels], st->channels*st->Fs/400); - } - - if (st->channels*(st->encoder_buffer-(frame_size+total_buffer)) > 0) - { - OPUS_MOVE(st->delay_buffer, &st->delay_buffer[st->channels*frame_size], st->channels*(st->encoder_buffer-frame_size-total_buffer)); - OPUS_COPY(&st->delay_buffer[st->channels*(st->encoder_buffer-frame_size-total_buffer)], - &pcm_buf[0], - (frame_size+total_buffer)*st->channels); - } else { - OPUS_COPY(st->delay_buffer, &pcm_buf[(frame_size+total_buffer-st->encoder_buffer)*st->channels], st->encoder_buffer*st->channels); - } - /* gain_fade() and stereo_fade() need to be after the buffer copying - because we don't want any of this to affect the SILK part */ - if( st->prev_HB_gain < Q15ONE || HB_gain < Q15ONE ) { - gain_fade(pcm_buf, pcm_buf, - st->prev_HB_gain, HB_gain, celt_mode->overlap, frame_size, st->channels, celt_mode->window, st->Fs); - } - st->prev_HB_gain = HB_gain; - if (st->mode != MODE_HYBRID || st->stream_channels==1) - { - if (equiv_rate > 32000) - st->silk_mode.stereoWidth_Q14 = 16384; - else if (equiv_rate < 16000) - st->silk_mode.stereoWidth_Q14 = 0; - else - st->silk_mode.stereoWidth_Q14 = 16384 - 2048*(opus_int32)(32000-equiv_rate)/(equiv_rate-14000); - } - if( !st->energy_masking && st->channels == 2 ) { - /* Apply stereo width reduction (at low bitrates) */ - if( st->hybrid_stereo_width_Q14 < (1 << 14) || st->silk_mode.stereoWidth_Q14 < (1 << 14) ) { - opus_val16 g1, g2; - g1 = st->hybrid_stereo_width_Q14; - g2 = (opus_val16)(st->silk_mode.stereoWidth_Q14); -#ifdef FIXED_POINT - g1 = g1==16384 ? Q15ONE : SHL16(g1,1); - g2 = g2==16384 ? Q15ONE : SHL16(g2,1); -#else - g1 *= (1.f/16384); - g2 *= (1.f/16384); -#endif - stereo_fade(pcm_buf, pcm_buf, g1, g2, celt_mode->overlap, - frame_size, st->channels, celt_mode->window, st->Fs); - st->hybrid_stereo_width_Q14 = st->silk_mode.stereoWidth_Q14; - } - } - - if ( st->mode != MODE_CELT_ONLY && ec_tell(&enc)+17+20*(st->mode == MODE_HYBRID) <= 8*(max_data_bytes-1)) - { - /* For SILK mode, the redundancy is inferred from the length */ - if (st->mode == MODE_HYBRID) - ec_enc_bit_logp(&enc, redundancy, 12); - if (redundancy) - { - int max_redundancy; - ec_enc_bit_logp(&enc, celt_to_silk, 1); - if (st->mode == MODE_HYBRID) - { - /* Reserve the 8 bits needed for the redundancy length, - and at least a few bits for CELT if possible */ - max_redundancy = (max_data_bytes-1)-((ec_tell(&enc)+8+3+7)>>3); - } - else - max_redundancy = (max_data_bytes-1)-((ec_tell(&enc)+7)>>3); - /* Target the same bit-rate for redundancy as for the rest, - up to a max of 257 bytes */ - redundancy_bytes = IMIN(max_redundancy, redundancy_bytes); - redundancy_bytes = IMIN(257, IMAX(2, redundancy_bytes)); - if (st->mode == MODE_HYBRID) - ec_enc_uint(&enc, redundancy_bytes-2, 256); - } - } else { - redundancy = 0; - } - - if (!redundancy) - { - st->silk_bw_switch = 0; - redundancy_bytes = 0; - } - if (st->mode != MODE_CELT_ONLY)start_band=17; - - if (st->mode == MODE_SILK_ONLY) - { - ret = (ec_tell(&enc)+7)>>3; - ec_enc_done(&enc); - nb_compr_bytes = ret; - } else { - nb_compr_bytes = (max_data_bytes-1)-redundancy_bytes; - ec_enc_shrink(&enc, nb_compr_bytes); - } - -#ifndef DISABLE_FLOAT_API - if (redundancy || st->mode != MODE_SILK_ONLY) - celt_encoder_ctl(celt_enc, CELT_SET_ANALYSIS(&analysis_info)); -#endif - if (st->mode == MODE_HYBRID) { - SILKInfo info; - info.signalType = st->silk_mode.signalType; - info.offset = st->silk_mode.offset; - celt_encoder_ctl(celt_enc, CELT_SET_SILK_INFO(&info)); - } - - /* 5 ms redundant frame for CELT->SILK */ - if (redundancy && celt_to_silk) - { - int err; - celt_encoder_ctl(celt_enc, CELT_SET_START_BAND(0)); - celt_encoder_ctl(celt_enc, OPUS_SET_VBR(0)); - celt_encoder_ctl(celt_enc, OPUS_SET_BITRATE(OPUS_BITRATE_MAX)); - err = celt_encode_with_ec(celt_enc, pcm_buf, st->Fs/200, data+nb_compr_bytes, redundancy_bytes, NULL); - if (err < 0) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - celt_encoder_ctl(celt_enc, OPUS_GET_FINAL_RANGE(&redundant_rng)); - celt_encoder_ctl(celt_enc, OPUS_RESET_STATE); - } - - celt_encoder_ctl(celt_enc, CELT_SET_START_BAND(start_band)); - - if (st->mode != MODE_SILK_ONLY) - { - if (st->mode != st->prev_mode && st->prev_mode > 0) - { - unsigned char dummy[2]; - celt_encoder_ctl(celt_enc, OPUS_RESET_STATE); - - /* Prefilling */ - celt_encode_with_ec(celt_enc, tmp_prefill, st->Fs/400, dummy, 2, NULL); - celt_encoder_ctl(celt_enc, CELT_SET_PREDICTION(0)); - } - /* If false, we already busted the budget and we'll end up with a "PLC frame" */ - if (ec_tell(&enc) <= 8*nb_compr_bytes) - { - /* Set the bitrate again if it was overridden in the redundancy code above*/ - if (redundancy && celt_to_silk && st->mode==MODE_HYBRID && st->use_vbr) - celt_encoder_ctl(celt_enc, OPUS_SET_BITRATE(st->bitrate_bps-st->silk_mode.bitRate)); - celt_encoder_ctl(celt_enc, OPUS_SET_VBR(st->use_vbr)); - ret = celt_encode_with_ec(celt_enc, pcm_buf, frame_size, NULL, nb_compr_bytes, &enc); - if (ret < 0) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - /* Put CELT->SILK redundancy data in the right place. */ - if (redundancy && celt_to_silk && st->mode==MODE_HYBRID && st->use_vbr) - { - OPUS_MOVE(data+ret, data+nb_compr_bytes, redundancy_bytes); - nb_compr_bytes = nb_compr_bytes+redundancy_bytes; - } - } - } - - /* 5 ms redundant frame for SILK->CELT */ - if (redundancy && !celt_to_silk) - { - int err; - unsigned char dummy[2]; - int N2, N4; - N2 = st->Fs/200; - N4 = st->Fs/400; - - celt_encoder_ctl(celt_enc, OPUS_RESET_STATE); - celt_encoder_ctl(celt_enc, CELT_SET_START_BAND(0)); - celt_encoder_ctl(celt_enc, CELT_SET_PREDICTION(0)); - celt_encoder_ctl(celt_enc, OPUS_SET_VBR(0)); - celt_encoder_ctl(celt_enc, OPUS_SET_BITRATE(OPUS_BITRATE_MAX)); - - if (st->mode == MODE_HYBRID) - { - /* Shrink packet to what the encoder actually used. */ - nb_compr_bytes = ret; - ec_enc_shrink(&enc, nb_compr_bytes); - } - /* NOTE: We could speed this up slightly (at the expense of code size) by just adding a function that prefills the buffer */ - celt_encode_with_ec(celt_enc, pcm_buf+st->channels*(frame_size-N2-N4), N4, dummy, 2, NULL); - - err = celt_encode_with_ec(celt_enc, pcm_buf+st->channels*(frame_size-N2), N2, data+nb_compr_bytes, redundancy_bytes, NULL); - if (err < 0) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - celt_encoder_ctl(celt_enc, OPUS_GET_FINAL_RANGE(&redundant_rng)); - } - - - - /* Signalling the mode in the first byte */ - data--; - data[0] = gen_toc(st->mode, st->Fs/frame_size, curr_bandwidth, st->stream_channels); - - st->rangeFinal = enc.rng ^ redundant_rng; - - if (to_celt) - st->prev_mode = MODE_CELT_ONLY; - else - st->prev_mode = st->mode; - st->prev_channels = st->stream_channels; - st->prev_framesize = frame_size; - - st->first = 0; - - /* DTX decision */ -#ifndef DISABLE_FLOAT_API - if (st->use_dtx && (analysis_info.valid || is_silence)) - { - if (decide_dtx_mode(activity, &st->nb_no_activity_ms_Q1, 2*1000*frame_size/st->Fs)) - { - st->rangeFinal = 0; - data[0] = gen_toc(st->mode, st->Fs/frame_size, curr_bandwidth, st->stream_channels); - RESTORE_STACK; - return 1; - } - } else { - st->nb_no_activity_ms_Q1 = 0; - } -#endif - - /* In the unlikely case that the SILK encoder busted its target, tell - the decoder to call the PLC */ - if (ec_tell(&enc) > (max_data_bytes-1)*8) - { - if (max_data_bytes < 2) - { - RESTORE_STACK; - return OPUS_BUFFER_TOO_SMALL; - } - data[1] = 0; - ret = 1; - st->rangeFinal = 0; - } else if (st->mode==MODE_SILK_ONLY&&!redundancy) - { - /*When in LPC only mode it's perfectly - reasonable to strip off trailing zero bytes as - the required range decoder behavior is to - fill these in. This can't be done when the MDCT - modes are used because the decoder needs to know - the actual length for allocation purposes.*/ - while(ret>2&&data[ret]==0)ret--; - } - /* Count ToC and redundancy */ - ret += 1+redundancy_bytes; - if (!st->use_vbr) - { - if (opus_packet_pad(data, ret, max_data_bytes) != OPUS_OK) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - ret = max_data_bytes; - } - RESTORE_STACK; - return ret; -} - -#ifdef FIXED_POINT - -#ifndef DISABLE_FLOAT_API -opus_int32 opus_encode_float(OpusEncoder *st, const float *pcm, int analysis_frame_size, - unsigned char *data, opus_int32 max_data_bytes) -{ - int i, ret; - int frame_size; - VARDECL(opus_int16, in); - ALLOC_STACK; - - frame_size = frame_size_select(analysis_frame_size, st->variable_duration, st->Fs); - if (frame_size <= 0) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - ALLOC(in, frame_size*st->channels, opus_int16); - - for (i=0;ichannels;i++) - in[i] = FLOAT2INT16(pcm[i]); - ret = opus_encode_native(st, in, frame_size, data, max_data_bytes, 16, - pcm, analysis_frame_size, 0, -2, st->channels, downmix_float, 1); - RESTORE_STACK; - return ret; -} -#endif - -opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_frame_size, - unsigned char *data, opus_int32 out_data_bytes) -{ - int frame_size; - frame_size = frame_size_select(analysis_frame_size, st->variable_duration, st->Fs); - return opus_encode_native(st, pcm, frame_size, data, out_data_bytes, 16, - pcm, analysis_frame_size, 0, -2, st->channels, downmix_int, 0); -} - -#else -opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_frame_size, - unsigned char *data, opus_int32 max_data_bytes) -{ - int i, ret; - int frame_size; - VARDECL(float, in); - ALLOC_STACK; - - frame_size = frame_size_select(analysis_frame_size, st->variable_duration, st->Fs); - if (frame_size <= 0) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - ALLOC(in, frame_size*st->channels, float); - - for (i=0;ichannels;i++) - in[i] = (1.0f/32768)*pcm[i]; - ret = opus_encode_native(st, in, frame_size, data, max_data_bytes, 16, - pcm, analysis_frame_size, 0, -2, st->channels, downmix_int, 0); - RESTORE_STACK; - return ret; -} -opus_int32 opus_encode_float(OpusEncoder *st, const float *pcm, int analysis_frame_size, - unsigned char *data, opus_int32 out_data_bytes) -{ - int frame_size; - frame_size = frame_size_select(analysis_frame_size, st->variable_duration, st->Fs); - return opus_encode_native(st, pcm, frame_size, data, out_data_bytes, 24, - pcm, analysis_frame_size, 0, -2, st->channels, downmix_float, 1); -} -#endif - - -int opus_encoder_ctl(OpusEncoder *st, int request, ...) -{ - int ret; - CELTEncoder *celt_enc; - va_list ap; - - ret = OPUS_OK; - va_start(ap, request); - - celt_enc = (CELTEncoder*)((char*)st+st->celt_enc_offset); - - switch (request) - { - case OPUS_SET_APPLICATION_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if ( (value != OPUS_APPLICATION_VOIP && value != OPUS_APPLICATION_AUDIO - && value != OPUS_APPLICATION_RESTRICTED_LOWDELAY) - || (!st->first && st->application != value)) - { - ret = OPUS_BAD_ARG; - break; - } - st->application = value; -#ifndef DISABLE_FLOAT_API - st->analysis.application = value; -#endif - } - break; - case OPUS_GET_APPLICATION_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->application; - } - break; - case OPUS_SET_BITRATE_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value != OPUS_AUTO && value != OPUS_BITRATE_MAX) - { - if (value <= 0) - goto bad_arg; - else if (value <= 500) - value = 500; - else if (value > (opus_int32)300000*st->channels) - value = (opus_int32)300000*st->channels; - } - st->user_bitrate_bps = value; - } - break; - case OPUS_GET_BITRATE_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = user_bitrate_to_bitrate(st, st->prev_framesize, 1276); - } - break; - case OPUS_SET_FORCE_CHANNELS_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if((value<1 || value>st->channels) && value != OPUS_AUTO) - { - goto bad_arg; - } - st->force_channels = value; - } - break; - case OPUS_GET_FORCE_CHANNELS_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->force_channels; - } - break; - case OPUS_SET_MAX_BANDWIDTH_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value < OPUS_BANDWIDTH_NARROWBAND || value > OPUS_BANDWIDTH_FULLBAND) - { - goto bad_arg; - } - st->max_bandwidth = value; - if (st->max_bandwidth == OPUS_BANDWIDTH_NARROWBAND) { - st->silk_mode.maxInternalSampleRate = 8000; - } else if (st->max_bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) { - st->silk_mode.maxInternalSampleRate = 12000; - } else { - st->silk_mode.maxInternalSampleRate = 16000; - } - } - break; - case OPUS_GET_MAX_BANDWIDTH_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->max_bandwidth; - } - break; - case OPUS_SET_BANDWIDTH_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if ((value < OPUS_BANDWIDTH_NARROWBAND || value > OPUS_BANDWIDTH_FULLBAND) && value != OPUS_AUTO) - { - goto bad_arg; - } - st->user_bandwidth = value; - if (st->user_bandwidth == OPUS_BANDWIDTH_NARROWBAND) { - st->silk_mode.maxInternalSampleRate = 8000; - } else if (st->user_bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) { - st->silk_mode.maxInternalSampleRate = 12000; - } else { - st->silk_mode.maxInternalSampleRate = 16000; - } - } - break; - case OPUS_GET_BANDWIDTH_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->bandwidth; - } - break; - case OPUS_SET_DTX_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - st->use_dtx = value; - } - break; - case OPUS_GET_DTX_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->use_dtx; - } - break; - case OPUS_SET_COMPLEXITY_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>10) - { - goto bad_arg; - } - st->silk_mode.complexity = value; - celt_encoder_ctl(celt_enc, OPUS_SET_COMPLEXITY(value)); - } - break; - case OPUS_GET_COMPLEXITY_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->silk_mode.complexity; - } - break; - case OPUS_SET_INBAND_FEC_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>2) - { - goto bad_arg; - } - st->fec_config = value; - st->silk_mode.useInBandFEC = (value != 0); - } - break; - case OPUS_GET_INBAND_FEC_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->fec_config; - } - break; - case OPUS_SET_PACKET_LOSS_PERC_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value < 0 || value > 100) - { - goto bad_arg; - } - st->silk_mode.packetLossPercentage = value; - celt_encoder_ctl(celt_enc, OPUS_SET_PACKET_LOSS_PERC(value)); - } - break; - case OPUS_GET_PACKET_LOSS_PERC_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->silk_mode.packetLossPercentage; - } - break; - case OPUS_SET_VBR_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - st->use_vbr = value; - st->silk_mode.useCBR = 1-value; - } - break; - case OPUS_GET_VBR_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->use_vbr; - } - break; - case OPUS_SET_VOICE_RATIO_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<-1 || value>100) - { - goto bad_arg; - } - st->voice_ratio = value; - } - break; - case OPUS_GET_VOICE_RATIO_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->voice_ratio; - } - break; - case OPUS_SET_VBR_CONSTRAINT_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - st->vbr_constraint = value; - } - break; - case OPUS_GET_VBR_CONSTRAINT_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->vbr_constraint; - } - break; - case OPUS_SET_SIGNAL_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value!=OPUS_AUTO && value!=OPUS_SIGNAL_VOICE && value!=OPUS_SIGNAL_MUSIC) - { - goto bad_arg; - } - st->signal_type = value; - } - break; - case OPUS_GET_SIGNAL_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->signal_type; - } - break; - case OPUS_GET_LOOKAHEAD_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->Fs/400; - if (st->application != OPUS_APPLICATION_RESTRICTED_LOWDELAY) - *value += st->delay_compensation; - } - break; - case OPUS_GET_SAMPLE_RATE_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->Fs; - } - break; - case OPUS_GET_FINAL_RANGE_REQUEST: - { - opus_uint32 *value = va_arg(ap, opus_uint32*); - if (!value) - { - goto bad_arg; - } - *value = st->rangeFinal; - } - 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*); - if (!value) - { - goto bad_arg; - } - *value = st->lsb_depth; - } - break; - case OPUS_SET_EXPERT_FRAME_DURATION_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value != OPUS_FRAMESIZE_ARG && value != OPUS_FRAMESIZE_2_5_MS && - value != OPUS_FRAMESIZE_5_MS && value != OPUS_FRAMESIZE_10_MS && - value != OPUS_FRAMESIZE_20_MS && value != OPUS_FRAMESIZE_40_MS && - value != OPUS_FRAMESIZE_60_MS && value != OPUS_FRAMESIZE_80_MS && - value != OPUS_FRAMESIZE_100_MS && value != OPUS_FRAMESIZE_120_MS) - { - goto bad_arg; - } - st->variable_duration = value; - } - break; - case OPUS_GET_EXPERT_FRAME_DURATION_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->variable_duration; - } - break; - case OPUS_SET_PREDICTION_DISABLED_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value > 1 || value < 0) - goto bad_arg; - st->silk_mode.reducedDependency = value; - } - break; - case OPUS_GET_PREDICTION_DISABLED_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - goto bad_arg; - *value = st->silk_mode.reducedDependency; - } - break; - case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - celt_encoder_ctl(celt_enc, OPUS_SET_PHASE_INVERSION_DISABLED(value)); - } - break; - case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - celt_encoder_ctl(celt_enc, OPUS_GET_PHASE_INVERSION_DISABLED(value)); - } - break; - case OPUS_RESET_STATE: - { - void *silk_enc; - silk_EncControlStruct dummy; - char *start; - silk_enc = (char*)st+st->silk_enc_offset; -#ifndef DISABLE_FLOAT_API - tonality_analysis_reset(&st->analysis); -#endif - - start = (char*)&st->OPUS_ENCODER_RESET_START; - OPUS_CLEAR(start, sizeof(OpusEncoder) - (start - (char*)st)); - - celt_encoder_ctl(celt_enc, OPUS_RESET_STATE); - silk_InitEncoder( silk_enc, st->arch, &dummy ); - st->stream_channels = st->channels; - st->hybrid_stereo_width_Q14 = 1 << 14; - st->prev_HB_gain = Q15ONE; - st->first = 1; - st->mode = MODE_HYBRID; - st->bandwidth = OPUS_BANDWIDTH_FULLBAND; - st->variable_HP_smth2_Q15 = silk_LSHIFT( silk_lin2log( VARIABLE_HP_MIN_CUTOFF_HZ ), 8 ); - } - break; - case OPUS_SET_FORCE_MODE_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if ((value < MODE_SILK_ONLY || value > MODE_CELT_ONLY) && value != OPUS_AUTO) - { - goto bad_arg; - } - st->user_forced_mode = value; - } - break; - case OPUS_SET_LFE_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - st->lfe = value; - ret = celt_encoder_ctl(celt_enc, OPUS_SET_LFE(value)); - } - break; - case OPUS_SET_ENERGY_MASK_REQUEST: - { - opus_val16 *value = va_arg(ap, opus_val16*); - st->energy_masking = value; - ret = celt_encoder_ctl(celt_enc, OPUS_SET_ENERGY_MASK(value)); - } - break; - case OPUS_GET_IN_DTX_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - if (st->silk_mode.useDTX && (st->prev_mode == MODE_SILK_ONLY || st->prev_mode == MODE_HYBRID)) { - /* DTX determined by Silk. */ - silk_encoder *silk_enc = (silk_encoder*)(void *)((char*)st+st->silk_enc_offset); - *value = silk_enc->state_Fxx[0].sCmn.noSpeechCounter >= NB_SPEECH_FRAMES_BEFORE_DTX; - /* Stereo: check second channel unless only the middle channel was encoded. */ - if(*value == 1 && st->silk_mode.nChannelsInternal == 2 && silk_enc->prev_decode_only_middle == 0) { - *value = silk_enc->state_Fxx[1].sCmn.noSpeechCounter >= NB_SPEECH_FRAMES_BEFORE_DTX; - } - } -#ifndef DISABLE_FLOAT_API - else if (st->use_dtx) { - /* DTX determined by Opus. */ - *value = st->nb_no_activity_ms_Q1 >= NB_SPEECH_FRAMES_BEFORE_DTX*20*2; - } -#endif - else { - *value = 0; - } - } - break; - case CELT_GET_MODE_REQUEST: - { - const CELTMode ** value = va_arg(ap, const CELTMode**); - if (!value) - { - goto bad_arg; - } - ret = celt_encoder_ctl(celt_enc, CELT_GET_MODE(value)); - } - break; - default: - /* fprintf(stderr, "unknown opus_encoder_ctl() request: %d", request);*/ - ret = OPUS_UNIMPLEMENTED; - break; - } - va_end(ap); - return ret; -bad_arg: - va_end(ap); - return OPUS_BAD_ARG; -} - -void opus_encoder_destroy(OpusEncoder *st) -{ - opus_free(st); -} diff --git a/Engine/lib/opus/src/opus_multistream.c b/Engine/lib/opus/src/opus_multistream.c deleted file mode 100644 index 09c3639b7..000000000 --- a/Engine/lib/opus/src/opus_multistream.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2011 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_multistream.h" -#include "opus.h" -#include "opus_private.h" -#include "stack_alloc.h" -#include -#include "float_cast.h" -#include "os_support.h" - - -int validate_layout(const ChannelLayout *layout) -{ - int i, max_channel; - - max_channel = layout->nb_streams+layout->nb_coupled_streams; - if (max_channel>255) - return 0; - for (i=0;inb_channels;i++) - { - if (layout->mapping[i] >= max_channel && layout->mapping[i] != 255) - return 0; - } - return 1; -} - - -int get_left_channel(const ChannelLayout *layout, int stream_id, int prev) -{ - int i; - i = (prev<0) ? 0 : prev+1; - for (;inb_channels;i++) - { - if (layout->mapping[i]==stream_id*2) - return i; - } - return -1; -} - -int get_right_channel(const ChannelLayout *layout, int stream_id, int prev) -{ - int i; - i = (prev<0) ? 0 : prev+1; - for (;inb_channels;i++) - { - if (layout->mapping[i]==stream_id*2+1) - return i; - } - return -1; -} - -int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev) -{ - int i; - i = (prev<0) ? 0 : prev+1; - for (;inb_channels;i++) - { - if (layout->mapping[i]==stream_id+layout->nb_coupled_streams) - return i; - } - return -1; -} - diff --git a/Engine/lib/opus/src/opus_multistream_decoder.c b/Engine/lib/opus/src/opus_multistream_decoder.c deleted file mode 100644 index a2837c354..000000000 --- a/Engine/lib/opus/src/opus_multistream_decoder.c +++ /dev/null @@ -1,552 +0,0 @@ -/* Copyright (c) 2011 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_multistream.h" -#include "opus.h" -#include "opus_private.h" -#include "stack_alloc.h" -#include -#include "float_cast.h" -#include "os_support.h" - -/* DECODER */ - -#if defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS) -static void validate_ms_decoder(OpusMSDecoder *st) -{ - validate_layout(&st->layout); -} -#define VALIDATE_MS_DECODER(st) validate_ms_decoder(st) -#else -#define VALIDATE_MS_DECODER(st) -#endif - - -opus_int32 opus_multistream_decoder_get_size(int nb_streams, int nb_coupled_streams) -{ - int coupled_size; - int mono_size; - - if(nb_streams<1||nb_coupled_streams>nb_streams||nb_coupled_streams<0)return 0; - coupled_size = opus_decoder_get_size(2); - mono_size = opus_decoder_get_size(1); - return align(sizeof(OpusMSDecoder)) - + nb_coupled_streams * align(coupled_size) - + (nb_streams-nb_coupled_streams) * align(mono_size); -} - -int opus_multistream_decoder_init( - OpusMSDecoder *st, - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - const unsigned char *mapping -) -{ - int coupled_size; - int mono_size; - int i, ret; - char *ptr; - - if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) - return OPUS_BAD_ARG; - - st->layout.nb_channels = channels; - st->layout.nb_streams = streams; - st->layout.nb_coupled_streams = coupled_streams; - - for (i=0;ilayout.nb_channels;i++) - st->layout.mapping[i] = mapping[i]; - if (!validate_layout(&st->layout)) - return OPUS_BAD_ARG; - - ptr = (char*)st + align(sizeof(OpusMSDecoder)); - coupled_size = opus_decoder_get_size(2); - mono_size = opus_decoder_get_size(1); - - for (i=0;ilayout.nb_coupled_streams;i++) - { - ret=opus_decoder_init((OpusDecoder*)ptr, Fs, 2); - if(ret!=OPUS_OK)return ret; - ptr += align(coupled_size); - } - for (;ilayout.nb_streams;i++) - { - ret=opus_decoder_init((OpusDecoder*)ptr, Fs, 1); - if(ret!=OPUS_OK)return ret; - ptr += align(mono_size); - } - return OPUS_OK; -} - - -OpusMSDecoder *opus_multistream_decoder_create( - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - const unsigned char *mapping, - int *error -) -{ - int ret; - OpusMSDecoder *st; - if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) - { - if (error) - *error = OPUS_BAD_ARG; - return NULL; - } - st = (OpusMSDecoder *)opus_alloc(opus_multistream_decoder_get_size(streams, coupled_streams)); - if (st==NULL) - { - if (error) - *error = OPUS_ALLOC_FAIL; - return NULL; - } - ret = opus_multistream_decoder_init(st, Fs, channels, streams, coupled_streams, mapping); - if (error) - *error = ret; - if (ret != OPUS_OK) - { - opus_free(st); - st = NULL; - } - return st; -} - -static int opus_multistream_packet_validate(const unsigned char *data, - opus_int32 len, int nb_streams, opus_int32 Fs) -{ - int s; - int count; - unsigned char toc; - opus_int16 size[48]; - int samples=0; - opus_int32 packet_offset; - - for (s=0;slayout.nb_streams-1) - { - RESTORE_STACK; - return OPUS_INVALID_PACKET; - } - if (!do_plc) - { - int ret = opus_multistream_packet_validate(data, len, st->layout.nb_streams, Fs); - if (ret < 0) - { - RESTORE_STACK; - return ret; - } else if (ret > frame_size) - { - RESTORE_STACK; - return OPUS_BUFFER_TOO_SMALL; - } - } - for (s=0;slayout.nb_streams;s++) - { - OpusDecoder *dec; - opus_int32 packet_offset; - int ret; - - dec = (OpusDecoder*)ptr; - ptr += (s < st->layout.nb_coupled_streams) ? align(coupled_size) : align(mono_size); - - if (!do_plc && len<=0) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - packet_offset = 0; - ret = opus_decode_native(dec, data, len, buf, frame_size, decode_fec, s!=st->layout.nb_streams-1, &packet_offset, soft_clip); - if (!do_plc) - { - data += packet_offset; - len -= packet_offset; - } - if (ret <= 0) - { - RESTORE_STACK; - return ret; - } - frame_size = ret; - if (s < st->layout.nb_coupled_streams) - { - int chan, prev; - prev = -1; - /* Copy "left" audio to the channel(s) where it belongs */ - while ( (chan = get_left_channel(&st->layout, s, prev)) != -1) - { - (*copy_channel_out)(pcm, st->layout.nb_channels, chan, - buf, 2, frame_size, user_data); - prev = chan; - } - prev = -1; - /* Copy "right" audio to the channel(s) where it belongs */ - while ( (chan = get_right_channel(&st->layout, s, prev)) != -1) - { - (*copy_channel_out)(pcm, st->layout.nb_channels, chan, - buf+1, 2, frame_size, user_data); - prev = chan; - } - } else { - int chan, prev; - prev = -1; - /* Copy audio to the channel(s) where it belongs */ - while ( (chan = get_mono_channel(&st->layout, s, prev)) != -1) - { - (*copy_channel_out)(pcm, st->layout.nb_channels, chan, - buf, 1, frame_size, user_data); - prev = chan; - } - } - } - /* Handle muted channels */ - for (c=0;clayout.nb_channels;c++) - { - if (st->layout.mapping[c] == 255) - { - (*copy_channel_out)(pcm, st->layout.nb_channels, c, - NULL, 0, frame_size, user_data); - } - } - RESTORE_STACK; - return frame_size; -} - -#if !defined(DISABLE_FLOAT_API) -static void opus_copy_channel_out_float( - void *dst, - int dst_stride, - int dst_channel, - const opus_val16 *src, - int src_stride, - int frame_size, - void *user_data -) -{ - float *float_dst; - opus_int32 i; - (void)user_data; - float_dst = (float*)dst; - if (src != NULL) - { - for (i=0;ilayout.nb_streams;s++) - { - OpusDecoder *dec; - dec = (OpusDecoder*)ptr; - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - ret = opus_decoder_ctl(dec, request, &tmp); - if (ret != OPUS_OK) break; - *value ^= tmp; - } - } - break; - case OPUS_RESET_STATE: - { - int s; - for (s=0;slayout.nb_streams;s++) - { - OpusDecoder *dec; - - dec = (OpusDecoder*)ptr; - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - ret = opus_decoder_ctl(dec, OPUS_RESET_STATE); - if (ret != OPUS_OK) - break; - } - } - break; - case OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST: - { - int s; - opus_int32 stream_id; - OpusDecoder **value; - stream_id = va_arg(ap, opus_int32); - if (stream_id<0 || stream_id >= st->layout.nb_streams) - goto bad_arg; - value = va_arg(ap, OpusDecoder**); - if (!value) - { - goto bad_arg; - } - for (s=0;slayout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - } - *value = (OpusDecoder*)ptr; - } - break; - case OPUS_SET_GAIN_REQUEST: - case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: - { - int s; - /* This works for int32 params */ - opus_int32 value = va_arg(ap, opus_int32); - for (s=0;slayout.nb_streams;s++) - { - OpusDecoder *dec; - - dec = (OpusDecoder*)ptr; - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - ret = opus_decoder_ctl(dec, request, value); - if (ret != OPUS_OK) - break; - } - } - break; - default: - ret = OPUS_UNIMPLEMENTED; - break; - } - return ret; -bad_arg: - return OPUS_BAD_ARG; -} - -int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) -{ - int ret; - va_list ap; - va_start(ap, request); - ret = opus_multistream_decoder_ctl_va_list(st, request, ap); - va_end(ap); - return ret; -} - -void opus_multistream_decoder_destroy(OpusMSDecoder *st) -{ - opus_free(st); -} diff --git a/Engine/lib/opus/src/opus_multistream_encoder.c b/Engine/lib/opus/src/opus_multistream_encoder.c deleted file mode 100644 index 213e3eb2c..000000000 --- a/Engine/lib/opus/src/opus_multistream_encoder.c +++ /dev/null @@ -1,1329 +0,0 @@ -/* Copyright (c) 2011 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_multistream.h" -#include "opus.h" -#include "opus_private.h" -#include "stack_alloc.h" -#include -#include "float_cast.h" -#include "os_support.h" -#include "mathops.h" -#include "mdct.h" -#include "modes.h" -#include "bands.h" -#include "quant_bands.h" -#include "pitch.h" - -typedef struct { - int nb_streams; - int nb_coupled_streams; - unsigned char mapping[8]; -} VorbisLayout; - -/* Index is nb_channel-1*/ -static const VorbisLayout vorbis_mappings[8] = { - {1, 0, {0}}, /* 1: mono */ - {1, 1, {0, 1}}, /* 2: stereo */ - {2, 1, {0, 2, 1}}, /* 3: 1-d surround */ - {2, 2, {0, 1, 2, 3}}, /* 4: quadraphonic surround */ - {3, 2, {0, 4, 1, 2, 3}}, /* 5: 5-channel surround */ - {4, 2, {0, 4, 1, 2, 3, 5}}, /* 6: 5.1 surround */ - {4, 3, {0, 4, 1, 2, 3, 5, 6}}, /* 7: 6.1 surround */ - {5, 3, {0, 6, 1, 2, 3, 4, 5, 7}}, /* 8: 7.1 surround */ -}; - -static opus_val32 *ms_get_preemph_mem(OpusMSEncoder *st) -{ - int s; - char *ptr; - int coupled_size, mono_size; - - coupled_size = opus_encoder_get_size(2); - mono_size = opus_encoder_get_size(1); - ptr = (char*)st + align(sizeof(OpusMSEncoder)); - for (s=0;slayout.nb_streams;s++) - { - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - } - /* void* cast avoids clang -Wcast-align warning */ - return (opus_val32*)(void*)(ptr+st->layout.nb_channels*120*sizeof(opus_val32)); -} - -static opus_val32 *ms_get_window_mem(OpusMSEncoder *st) -{ - int s; - char *ptr; - int coupled_size, mono_size; - - coupled_size = opus_encoder_get_size(2); - mono_size = opus_encoder_get_size(1); - ptr = (char*)st + align(sizeof(OpusMSEncoder)); - for (s=0;slayout.nb_streams;s++) - { - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - } - /* void* cast avoids clang -Wcast-align warning */ - return (opus_val32*)(void*)ptr; -} - -static int validate_ambisonics(int nb_channels, int *nb_streams, int *nb_coupled_streams) -{ - int order_plus_one; - int acn_channels; - int nondiegetic_channels; - - if (nb_channels < 1 || nb_channels > 227) - return 0; - - order_plus_one = isqrt32(nb_channels); - acn_channels = order_plus_one * order_plus_one; - nondiegetic_channels = nb_channels - acn_channels; - - if (nondiegetic_channels != 0 && nondiegetic_channels != 2) - return 0; - - if (nb_streams) - *nb_streams = acn_channels + (nondiegetic_channels != 0); - if (nb_coupled_streams) - *nb_coupled_streams = nondiegetic_channels != 0; - return 1; -} - -static int validate_encoder_layout(const ChannelLayout *layout) -{ - int s; - for (s=0;snb_streams;s++) - { - if (s < layout->nb_coupled_streams) - { - if (get_left_channel(layout, s, -1)==-1) - return 0; - if (get_right_channel(layout, s, -1)==-1) - return 0; - } else { - if (get_mono_channel(layout, s, -1)==-1) - return 0; - } - } - return 1; -} - -static void channel_pos(int channels, int pos[8]) -{ - /* Position in the mix: 0 don't mix, 1: left, 2: center, 3:right */ - if (channels==4) - { - pos[0]=1; - pos[1]=3; - pos[2]=1; - pos[3]=3; - } else if (channels==3||channels==5||channels==6) - { - pos[0]=1; - pos[1]=2; - pos[2]=3; - pos[3]=1; - pos[4]=3; - pos[5]=0; - } else if (channels==7) - { - pos[0]=1; - pos[1]=2; - pos[2]=3; - pos[3]=1; - pos[4]=3; - pos[5]=2; - pos[6]=0; - } else if (channels==8) - { - pos[0]=1; - pos[1]=2; - pos[2]=3; - pos[3]=1; - pos[4]=3; - pos[5]=1; - pos[6]=3; - pos[7]=0; - } -} - -#if 1 -/* Computes a rough approximation of log2(2^a + 2^b) */ -static opus_val16 logSum(opus_val16 a, opus_val16 b) -{ - opus_val16 max; - opus_val32 diff; - opus_val16 frac; - static const opus_val16 diff_table[17] = { - QCONST16(0.5000000f, DB_SHIFT), QCONST16(0.2924813f, DB_SHIFT), QCONST16(0.1609640f, DB_SHIFT), QCONST16(0.0849625f, DB_SHIFT), - QCONST16(0.0437314f, DB_SHIFT), QCONST16(0.0221971f, DB_SHIFT), QCONST16(0.0111839f, DB_SHIFT), QCONST16(0.0056136f, DB_SHIFT), - QCONST16(0.0028123f, DB_SHIFT) - }; - int low; - if (a>b) - { - max = a; - diff = SUB32(EXTEND32(a),EXTEND32(b)); - } else { - max = b; - diff = SUB32(EXTEND32(b),EXTEND32(a)); - } - if (!(diff < QCONST16(8.f, DB_SHIFT))) /* inverted to catch NaNs */ - return max; -#ifdef FIXED_POINT - low = SHR32(diff, DB_SHIFT-1); - frac = SHL16(diff - SHL16(low, DB_SHIFT-1), 16-DB_SHIFT); -#else - low = (int)floor(2*diff); - frac = 2*diff - low; -#endif - return max + diff_table[low] + MULT16_16_Q15(frac, SUB16(diff_table[low+1], diff_table[low])); -} -#else -opus_val16 logSum(opus_val16 a, opus_val16 b) -{ - return log2(pow(4, a)+ pow(4, b))/2; -} -#endif - -void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *bandLogE, opus_val32 *mem, opus_val32 *preemph_mem, - int len, int overlap, int channels, int rate, opus_copy_channel_in_func copy_channel_in, int arch -) -{ - int c; - int i; - int LM; - int pos[8] = {0}; - int upsample; - int frame_size; - int freq_size; - opus_val16 channel_offset; - opus_val32 bandE[21]; - opus_val16 maskLogE[3][21]; - VARDECL(opus_val32, in); - VARDECL(opus_val16, x); - VARDECL(opus_val32, freq); - SAVE_STACK; - - upsample = resampling_factor(rate); - frame_size = len*upsample; - freq_size = IMIN(960, frame_size); - - /* LM = log2(frame_size / 120) */ - for (LM=0;LMmaxLM;LM++) - if (celt_mode->shortMdctSize<preemph, preemph_mem+c, 0); -#ifndef FIXED_POINT - { - opus_val32 sum; - sum = celt_inner_prod(in, in, frame_size+overlap, 0); - /* This should filter out both NaNs and ridiculous signals that could - cause NaNs further down. */ - if (!(sum < 1e18f) || celt_isnan(sum)) - { - OPUS_CLEAR(in, frame_size+overlap); - preemph_mem[c] = 0; - } - } -#endif - OPUS_CLEAR(bandE, 21); - for (frame=0;framemdct, in+960*frame, freq, celt_mode->window, - overlap, celt_mode->maxLM-LM, 1, arch); - if (upsample != 1) - { - int bound = freq_size/upsample; - for (i=0;i=0;i--) - bandLogE[21*c+i] = MAX16(bandLogE[21*c+i], bandLogE[21*c+i+1]-QCONST16(2.f, DB_SHIFT)); - if (pos[c]==1) - { - for (i=0;i<21;i++) - maskLogE[0][i] = logSum(maskLogE[0][i], bandLogE[21*c+i]); - } else if (pos[c]==3) - { - for (i=0;i<21;i++) - maskLogE[2][i] = logSum(maskLogE[2][i], bandLogE[21*c+i]); - } else if (pos[c]==2) - { - for (i=0;i<21;i++) - { - maskLogE[0][i] = logSum(maskLogE[0][i], bandLogE[21*c+i]-QCONST16(.5f, DB_SHIFT)); - maskLogE[2][i] = logSum(maskLogE[2][i], bandLogE[21*c+i]-QCONST16(.5f, DB_SHIFT)); - } - } -#if 0 - for (i=0;i<21;i++) - printf("%f ", bandLogE[21*c+i]); - float sum=0; - for (i=0;i<21;i++) - sum += bandLogE[21*c+i]; - printf("%f ", sum/21); -#endif - OPUS_COPY(mem+c*overlap, in+frame_size, overlap); - } - for (i=0;i<21;i++) - maskLogE[1][i] = MIN32(maskLogE[0][i],maskLogE[2][i]); - channel_offset = HALF16(celt_log2(QCONST32(2.f,14)/(channels-1))); - for (c=0;c<3;c++) - for (i=0;i<21;i++) - maskLogE[c][i] += channel_offset; -#if 0 - for (c=0;c<3;c++) - { - for (i=0;i<21;i++) - printf("%f ", maskLogE[c][i]); - } -#endif - for (c=0;cnb_streams||nb_coupled_streams<0)return 0; - coupled_size = opus_encoder_get_size(2); - mono_size = opus_encoder_get_size(1); - return align(sizeof(OpusMSEncoder)) - + nb_coupled_streams * align(coupled_size) - + (nb_streams-nb_coupled_streams) * align(mono_size); -} - -opus_int32 opus_multistream_surround_encoder_get_size(int channels, int mapping_family) -{ - int nb_streams; - int nb_coupled_streams; - opus_int32 size; - - if (mapping_family==0) - { - if (channels==1) - { - nb_streams=1; - nb_coupled_streams=0; - } else if (channels==2) - { - nb_streams=1; - nb_coupled_streams=1; - } else - return 0; - } else if (mapping_family==1 && channels<=8 && channels>=1) - { - nb_streams=vorbis_mappings[channels-1].nb_streams; - nb_coupled_streams=vorbis_mappings[channels-1].nb_coupled_streams; - } else if (mapping_family==255) - { - nb_streams=channels; - nb_coupled_streams=0; - } else if (mapping_family==2) - { - if (!validate_ambisonics(channels, &nb_streams, &nb_coupled_streams)) - return 0; - } else - return 0; - size = opus_multistream_encoder_get_size(nb_streams, nb_coupled_streams); - if (channels>2) - { - size += channels*(120*sizeof(opus_val32) + sizeof(opus_val32)); - } - return size; -} - -static int opus_multistream_encoder_init_impl( - OpusMSEncoder *st, - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - const unsigned char *mapping, - int application, - MappingType mapping_type -) -{ - int coupled_size; - int mono_size; - int i, ret; - char *ptr; - - if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams) || - (streams+coupled_streams>channels)) - return OPUS_BAD_ARG; - - st->arch = opus_select_arch(); - st->layout.nb_channels = channels; - st->layout.nb_streams = streams; - st->layout.nb_coupled_streams = coupled_streams; - if (mapping_type != MAPPING_TYPE_SURROUND) - st->lfe_stream = -1; - st->bitrate_bps = OPUS_AUTO; - st->application = application; - st->variable_duration = OPUS_FRAMESIZE_ARG; - for (i=0;ilayout.nb_channels;i++) - st->layout.mapping[i] = mapping[i]; - if (!validate_layout(&st->layout)) - return OPUS_BAD_ARG; - if (!validate_encoder_layout(&st->layout)) - return OPUS_BAD_ARG; - if (mapping_type == MAPPING_TYPE_AMBISONICS && - !validate_ambisonics(st->layout.nb_channels, NULL, NULL)) - return OPUS_BAD_ARG; - ptr = (char*)st + align(sizeof(OpusMSEncoder)); - coupled_size = opus_encoder_get_size(2); - mono_size = opus_encoder_get_size(1); - - for (i=0;ilayout.nb_coupled_streams;i++) - { - ret = opus_encoder_init((OpusEncoder*)ptr, Fs, 2, application); - if(ret!=OPUS_OK)return ret; - if (i==st->lfe_stream) - opus_encoder_ctl((OpusEncoder*)ptr, OPUS_SET_LFE(1)); - ptr += align(coupled_size); - } - for (;ilayout.nb_streams;i++) - { - ret = opus_encoder_init((OpusEncoder*)ptr, Fs, 1, application); - if (i==st->lfe_stream) - opus_encoder_ctl((OpusEncoder*)ptr, OPUS_SET_LFE(1)); - if(ret!=OPUS_OK)return ret; - ptr += align(mono_size); - } - if (mapping_type == MAPPING_TYPE_SURROUND) - { - OPUS_CLEAR(ms_get_preemph_mem(st), channels); - OPUS_CLEAR(ms_get_window_mem(st), channels*120); - } - st->mapping_type = mapping_type; - return OPUS_OK; -} - -int opus_multistream_encoder_init( - OpusMSEncoder *st, - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - const unsigned char *mapping, - int application -) -{ - return opus_multistream_encoder_init_impl(st, Fs, channels, streams, - coupled_streams, mapping, - application, MAPPING_TYPE_NONE); -} - -int opus_multistream_surround_encoder_init( - OpusMSEncoder *st, - opus_int32 Fs, - int channels, - int mapping_family, - int *streams, - int *coupled_streams, - unsigned char *mapping, - int application -) -{ - MappingType mapping_type; - - if ((channels>255) || (channels<1)) - return OPUS_BAD_ARG; - st->lfe_stream = -1; - if (mapping_family==0) - { - if (channels==1) - { - *streams=1; - *coupled_streams=0; - mapping[0]=0; - } else if (channels==2) - { - *streams=1; - *coupled_streams=1; - mapping[0]=0; - mapping[1]=1; - } else - return OPUS_UNIMPLEMENTED; - } else if (mapping_family==1 && channels<=8 && channels>=1) - { - int i; - *streams=vorbis_mappings[channels-1].nb_streams; - *coupled_streams=vorbis_mappings[channels-1].nb_coupled_streams; - for (i=0;i=6) - st->lfe_stream = *streams-1; - } else if (mapping_family==255) - { - int i; - *streams=channels; - *coupled_streams=0; - for(i=0;i2 && mapping_family==1) { - mapping_type = MAPPING_TYPE_SURROUND; - } else if (mapping_family==2) - { - mapping_type = MAPPING_TYPE_AMBISONICS; - } else - { - mapping_type = MAPPING_TYPE_NONE; - } - return opus_multistream_encoder_init_impl(st, Fs, channels, *streams, - *coupled_streams, mapping, - application, mapping_type); -} - -OpusMSEncoder *opus_multistream_encoder_create( - opus_int32 Fs, - int channels, - int streams, - int coupled_streams, - const unsigned char *mapping, - int application, - int *error -) -{ - int ret; - OpusMSEncoder *st; - if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams) || - (streams+coupled_streams>channels)) - { - if (error) - *error = OPUS_BAD_ARG; - return NULL; - } - st = (OpusMSEncoder *)opus_alloc(opus_multistream_encoder_get_size(streams, coupled_streams)); - if (st==NULL) - { - if (error) - *error = OPUS_ALLOC_FAIL; - return NULL; - } - ret = opus_multistream_encoder_init(st, Fs, channels, streams, coupled_streams, mapping, application); - if (ret != OPUS_OK) - { - opus_free(st); - st = NULL; - } - if (error) - *error = ret; - return st; -} - -OpusMSEncoder *opus_multistream_surround_encoder_create( - opus_int32 Fs, - int channels, - int mapping_family, - int *streams, - int *coupled_streams, - unsigned char *mapping, - int application, - int *error -) -{ - int ret; - opus_int32 size; - OpusMSEncoder *st; - if ((channels>255) || (channels<1)) - { - if (error) - *error = OPUS_BAD_ARG; - return NULL; - } - size = opus_multistream_surround_encoder_get_size(channels, mapping_family); - if (!size) - { - if (error) - *error = OPUS_UNIMPLEMENTED; - return NULL; - } - st = (OpusMSEncoder *)opus_alloc(size); - if (st==NULL) - { - if (error) - *error = OPUS_ALLOC_FAIL; - return NULL; - } - ret = opus_multistream_surround_encoder_init(st, Fs, channels, mapping_family, streams, coupled_streams, mapping, application); - if (ret != OPUS_OK) - { - opus_free(st); - st = NULL; - } - if (error) - *error = ret; - return st; -} - -static void surround_rate_allocation( - OpusMSEncoder *st, - opus_int32 *rate, - int frame_size, - opus_int32 Fs - ) -{ - int i; - opus_int32 channel_rate; - int stream_offset; - int lfe_offset; - int coupled_ratio; /* Q8 */ - int lfe_ratio; /* Q8 */ - int nb_lfe; - int nb_uncoupled; - int nb_coupled; - int nb_normal; - opus_int32 channel_offset; - opus_int32 bitrate; - int total; - - nb_lfe = (st->lfe_stream!=-1); - nb_coupled = st->layout.nb_coupled_streams; - nb_uncoupled = st->layout.nb_streams-nb_coupled-nb_lfe; - nb_normal = 2*nb_coupled + nb_uncoupled; - - /* Give each non-LFE channel enough bits per channel for coding band energy. */ - channel_offset = 40*IMAX(50, Fs/frame_size); - - if (st->bitrate_bps==OPUS_AUTO) - { - bitrate = nb_normal*(channel_offset + Fs + 10000) + 8000*nb_lfe; - } else if (st->bitrate_bps==OPUS_BITRATE_MAX) - { - bitrate = nb_normal*300000 + nb_lfe*128000; - } else { - bitrate = st->bitrate_bps; - } - - /* Give LFE some basic stream_channel allocation but never exceed 1/20 of the - total rate for the non-energy part to avoid problems at really low rate. */ - lfe_offset = IMIN(bitrate/20, 3000) + 15*IMAX(50, Fs/frame_size); - - /* We give each stream (coupled or uncoupled) a starting bitrate. - This models the main saving of coupled channels over uncoupled. */ - stream_offset = (bitrate - channel_offset*nb_normal - lfe_offset*nb_lfe)/nb_normal/2; - stream_offset = IMAX(0, IMIN(20000, stream_offset)); - - /* Coupled streams get twice the mono rate after the offset is allocated. */ - coupled_ratio = 512; - /* Should depend on the bitrate, for now we assume LFE gets 1/8 the bits of mono */ - lfe_ratio = 32; - - total = (nb_uncoupled<<8) /* mono */ - + coupled_ratio*nb_coupled /* stereo */ - + nb_lfe*lfe_ratio; - channel_rate = 256*(opus_int64)(bitrate - lfe_offset*nb_lfe - stream_offset*(nb_coupled+nb_uncoupled) - channel_offset*nb_normal)/total; - - for (i=0;ilayout.nb_streams;i++) - { - if (ilayout.nb_coupled_streams) - rate[i] = 2*channel_offset + IMAX(0, stream_offset+(channel_rate*coupled_ratio>>8)); - else if (i!=st->lfe_stream) - rate[i] = channel_offset + IMAX(0, stream_offset + channel_rate); - else - rate[i] = IMAX(0, lfe_offset+(channel_rate*lfe_ratio>>8)); - } -} - -static void ambisonics_rate_allocation( - OpusMSEncoder *st, - opus_int32 *rate, - int frame_size, - opus_int32 Fs - ) -{ - int i; - opus_int32 total_rate; - opus_int32 per_stream_rate; - - const int nb_channels = st->layout.nb_streams + st->layout.nb_coupled_streams; - - if (st->bitrate_bps==OPUS_AUTO) - { - total_rate = (st->layout.nb_coupled_streams + st->layout.nb_streams) * - (Fs+60*Fs/frame_size) + st->layout.nb_streams * (opus_int32)15000; - } else if (st->bitrate_bps==OPUS_BITRATE_MAX) - { - total_rate = nb_channels * 320000; - } else - { - total_rate = st->bitrate_bps; - } - - /* Allocate equal number of bits to Ambisonic (uncoupled) and non-diegetic - * (coupled) streams */ - per_stream_rate = total_rate / st->layout.nb_streams; - for (i = 0; i < st->layout.nb_streams; i++) - { - rate[i] = per_stream_rate; - } -} - -static opus_int32 rate_allocation( - OpusMSEncoder *st, - opus_int32 *rate, - int frame_size - ) -{ - int i; - opus_int32 rate_sum=0; - opus_int32 Fs; - char *ptr; - - ptr = (char*)st + align(sizeof(OpusMSEncoder)); - opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_SAMPLE_RATE(&Fs)); - - if (st->mapping_type == MAPPING_TYPE_AMBISONICS) { - ambisonics_rate_allocation(st, rate, frame_size, Fs); - } else - { - surround_rate_allocation(st, rate, frame_size, Fs); - } - - for (i=0;ilayout.nb_streams;i++) - { - rate[i] = IMAX(rate[i], 500); - rate_sum += rate[i]; - } - return rate_sum; -} - -/* Max size in case the encoder decides to return six frames (6 x 20 ms = 120 ms) */ -#define MS_FRAME_TMP (6*1275+12) -int opus_multistream_encode_native -( - OpusMSEncoder *st, - opus_copy_channel_in_func copy_channel_in, - const void *pcm, - int analysis_frame_size, - unsigned char *data, - opus_int32 max_data_bytes, - int lsb_depth, - downmix_func downmix, - int float_api, - void *user_data -) -{ - opus_int32 Fs; - int coupled_size; - int mono_size; - int s; - char *ptr; - int tot_size; - VARDECL(opus_val16, buf); - VARDECL(opus_val16, bandSMR); - unsigned char tmp_data[MS_FRAME_TMP]; - OpusRepacketizer rp; - opus_int32 vbr; - const CELTMode *celt_mode; - opus_int32 bitrates[256]; - opus_val16 bandLogE[42]; - opus_val32 *mem = NULL; - opus_val32 *preemph_mem=NULL; - int frame_size; - opus_int32 rate_sum; - opus_int32 smallest_packet; - ALLOC_STACK; - - if (st->mapping_type == MAPPING_TYPE_SURROUND) - { - preemph_mem = ms_get_preemph_mem(st); - mem = ms_get_window_mem(st); - } - - ptr = (char*)st + align(sizeof(OpusMSEncoder)); - opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_SAMPLE_RATE(&Fs)); - opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_VBR(&vbr)); - opus_encoder_ctl((OpusEncoder*)ptr, CELT_GET_MODE(&celt_mode)); - - frame_size = frame_size_select(analysis_frame_size, st->variable_duration, Fs); - if (frame_size <= 0) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - - /* Smallest packet the encoder can produce. */ - smallest_packet = st->layout.nb_streams*2-1; - /* 100 ms needs an extra byte per stream for the ToC. */ - if (Fs/frame_size == 10) - smallest_packet += st->layout.nb_streams; - if (max_data_bytes < smallest_packet) - { - RESTORE_STACK; - return OPUS_BUFFER_TOO_SMALL; - } - ALLOC(buf, 2*frame_size, opus_val16); - coupled_size = opus_encoder_get_size(2); - mono_size = opus_encoder_get_size(1); - - ALLOC(bandSMR, 21*st->layout.nb_channels, opus_val16); - if (st->mapping_type == MAPPING_TYPE_SURROUND) - { - surround_analysis(celt_mode, pcm, bandSMR, mem, preemph_mem, frame_size, 120, st->layout.nb_channels, Fs, copy_channel_in, st->arch); - } - - /* Compute bitrate allocation between streams (this could be a lot better) */ - rate_sum = rate_allocation(st, bitrates, frame_size); - - if (!vbr) - { - if (st->bitrate_bps == OPUS_AUTO) - { - max_data_bytes = IMIN(max_data_bytes, 3*rate_sum/(3*8*Fs/frame_size)); - } else if (st->bitrate_bps != OPUS_BITRATE_MAX) - { - max_data_bytes = IMIN(max_data_bytes, IMAX(smallest_packet, - 3*st->bitrate_bps/(3*8*Fs/frame_size))); - } - } - ptr = (char*)st + align(sizeof(OpusMSEncoder)); - for (s=0;slayout.nb_streams;s++) - { - OpusEncoder *enc; - enc = (OpusEncoder*)ptr; - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrates[s])); - if (st->mapping_type == MAPPING_TYPE_SURROUND) - { - opus_int32 equiv_rate; - equiv_rate = st->bitrate_bps; - if (frame_size*50 < Fs) - equiv_rate -= 60*(Fs/frame_size - 50)*st->layout.nb_channels; - if (equiv_rate > 10000*st->layout.nb_channels) - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - else if (equiv_rate > 7000*st->layout.nb_channels) - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_SUPERWIDEBAND)); - else if (equiv_rate > 5000*st->layout.nb_channels) - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_WIDEBAND)); - else - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); - if (s < st->layout.nb_coupled_streams) - { - /* To preserve the spatial image, force stereo CELT on coupled streams */ - opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(MODE_CELT_ONLY)); - opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(2)); - } - } - else if (st->mapping_type == MAPPING_TYPE_AMBISONICS) { - opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(MODE_CELT_ONLY)); - } - } - - ptr = (char*)st + align(sizeof(OpusMSEncoder)); - /* Counting ToC */ - tot_size = 0; - for (s=0;slayout.nb_streams;s++) - { - OpusEncoder *enc; - int len; - int curr_max; - int c1, c2; - int ret; - - opus_repacketizer_init(&rp); - enc = (OpusEncoder*)ptr; - if (s < st->layout.nb_coupled_streams) - { - int i; - int left, right; - left = get_left_channel(&st->layout, s, -1); - right = get_right_channel(&st->layout, s, -1); - (*copy_channel_in)(buf, 2, - pcm, st->layout.nb_channels, left, frame_size, user_data); - (*copy_channel_in)(buf+1, 2, - pcm, st->layout.nb_channels, right, frame_size, user_data); - ptr += align(coupled_size); - if (st->mapping_type == MAPPING_TYPE_SURROUND) - { - for (i=0;i<21;i++) - { - bandLogE[i] = bandSMR[21*left+i]; - bandLogE[21+i] = bandSMR[21*right+i]; - } - } - c1 = left; - c2 = right; - } else { - int i; - int chan = get_mono_channel(&st->layout, s, -1); - (*copy_channel_in)(buf, 1, - pcm, st->layout.nb_channels, chan, frame_size, user_data); - ptr += align(mono_size); - if (st->mapping_type == MAPPING_TYPE_SURROUND) - { - for (i=0;i<21;i++) - bandLogE[i] = bandSMR[21*chan+i]; - } - c1 = chan; - c2 = -1; - } - if (st->mapping_type == MAPPING_TYPE_SURROUND) - opus_encoder_ctl(enc, OPUS_SET_ENERGY_MASK(bandLogE)); - /* number of bytes left (+Toc) */ - curr_max = max_data_bytes - tot_size; - /* Reserve one byte for the last stream and two for the others */ - curr_max -= IMAX(0,2*(st->layout.nb_streams-s-1)-1); - /* For 100 ms, reserve an extra byte per stream for the ToC */ - if (Fs/frame_size == 10) - curr_max -= st->layout.nb_streams-s-1; - curr_max = IMIN(curr_max,MS_FRAME_TMP); - /* Repacketizer will add one or two bytes for self-delimited frames */ - if (s != st->layout.nb_streams-1) curr_max -= curr_max>253 ? 2 : 1; - if (!vbr && s == st->layout.nb_streams-1) - opus_encoder_ctl(enc, OPUS_SET_BITRATE(curr_max*(8*Fs/frame_size))); - len = opus_encode_native(enc, buf, frame_size, tmp_data, curr_max, lsb_depth, - pcm, analysis_frame_size, c1, c2, st->layout.nb_channels, downmix, float_api); - if (len<0) - { - RESTORE_STACK; - return len; - } - /* We need to use the repacketizer to add the self-delimiting lengths - while taking into account the fact that the encoder can now return - more than one frame at a time (e.g. 60 ms CELT-only) */ - ret = opus_repacketizer_cat(&rp, tmp_data, len); - /* If the opus_repacketizer_cat() fails, then something's seriously wrong - with the encoder. */ - if (ret != OPUS_OK) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - len = opus_repacketizer_out_range_impl(&rp, 0, opus_repacketizer_get_nb_frames(&rp), - data, max_data_bytes-tot_size, s != st->layout.nb_streams-1, !vbr && s == st->layout.nb_streams-1); - data += len; - tot_size += len; - } - /*printf("\n");*/ - RESTORE_STACK; - return tot_size; -} - -#if !defined(DISABLE_FLOAT_API) -static void opus_copy_channel_in_float( - opus_val16 *dst, - int dst_stride, - const void *src, - int src_stride, - int src_channel, - int frame_size, - void *user_data -) -{ - const float *float_src; - opus_int32 i; - (void)user_data; - float_src = (const float *)src; - for (i=0;ilayout.nb_channels, IMAX(500*st->layout.nb_channels, value)); - } - st->bitrate_bps = value; - } - break; - case OPUS_GET_BITRATE_REQUEST: - { - int s; - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = 0; - for (s=0;slayout.nb_streams;s++) - { - opus_int32 rate; - OpusEncoder *enc; - enc = (OpusEncoder*)ptr; - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - opus_encoder_ctl(enc, request, &rate); - *value += rate; - } - } - break; - case OPUS_GET_LSB_DEPTH_REQUEST: - case OPUS_GET_VBR_REQUEST: - case OPUS_GET_APPLICATION_REQUEST: - case OPUS_GET_BANDWIDTH_REQUEST: - case OPUS_GET_COMPLEXITY_REQUEST: - case OPUS_GET_PACKET_LOSS_PERC_REQUEST: - case OPUS_GET_DTX_REQUEST: - case OPUS_GET_VOICE_RATIO_REQUEST: - case OPUS_GET_VBR_CONSTRAINT_REQUEST: - case OPUS_GET_SIGNAL_REQUEST: - case OPUS_GET_LOOKAHEAD_REQUEST: - case OPUS_GET_SAMPLE_RATE_REQUEST: - case OPUS_GET_INBAND_FEC_REQUEST: - case OPUS_GET_FORCE_CHANNELS_REQUEST: - case OPUS_GET_PREDICTION_DISABLED_REQUEST: - case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST: - { - OpusEncoder *enc; - /* For int32* GET params, just query the first stream */ - opus_int32 *value = va_arg(ap, opus_int32*); - enc = (OpusEncoder*)ptr; - ret = opus_encoder_ctl(enc, request, value); - } - break; - case OPUS_GET_FINAL_RANGE_REQUEST: - { - int s; - opus_uint32 *value = va_arg(ap, opus_uint32*); - opus_uint32 tmp; - if (!value) - { - goto bad_arg; - } - *value=0; - for (s=0;slayout.nb_streams;s++) - { - OpusEncoder *enc; - enc = (OpusEncoder*)ptr; - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - ret = opus_encoder_ctl(enc, request, &tmp); - if (ret != OPUS_OK) break; - *value ^= tmp; - } - } - break; - case OPUS_SET_LSB_DEPTH_REQUEST: - case OPUS_SET_COMPLEXITY_REQUEST: - case OPUS_SET_VBR_REQUEST: - case OPUS_SET_VBR_CONSTRAINT_REQUEST: - case OPUS_SET_MAX_BANDWIDTH_REQUEST: - case OPUS_SET_BANDWIDTH_REQUEST: - case OPUS_SET_SIGNAL_REQUEST: - case OPUS_SET_APPLICATION_REQUEST: - case OPUS_SET_INBAND_FEC_REQUEST: - case OPUS_SET_PACKET_LOSS_PERC_REQUEST: - case OPUS_SET_DTX_REQUEST: - case OPUS_SET_FORCE_MODE_REQUEST: - case OPUS_SET_FORCE_CHANNELS_REQUEST: - case OPUS_SET_PREDICTION_DISABLED_REQUEST: - case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: - { - int s; - /* This works for int32 params */ - opus_int32 value = va_arg(ap, opus_int32); - for (s=0;slayout.nb_streams;s++) - { - OpusEncoder *enc; - - enc = (OpusEncoder*)ptr; - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - ret = opus_encoder_ctl(enc, request, value); - if (ret != OPUS_OK) - break; - } - } - break; - case OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST: - { - int s; - opus_int32 stream_id; - OpusEncoder **value; - stream_id = va_arg(ap, opus_int32); - if (stream_id<0 || stream_id >= st->layout.nb_streams) - goto bad_arg; - value = va_arg(ap, OpusEncoder**); - if (!value) - { - goto bad_arg; - } - for (s=0;slayout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - } - *value = (OpusEncoder*)ptr; - } - break; - case OPUS_SET_EXPERT_FRAME_DURATION_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - st->variable_duration = value; - } - break; - case OPUS_GET_EXPERT_FRAME_DURATION_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->variable_duration; - } - break; - case OPUS_RESET_STATE: - { - int s; - if (st->mapping_type == MAPPING_TYPE_SURROUND) - { - OPUS_CLEAR(ms_get_preemph_mem(st), st->layout.nb_channels); - OPUS_CLEAR(ms_get_window_mem(st), st->layout.nb_channels*120); - } - for (s=0;slayout.nb_streams;s++) - { - OpusEncoder *enc; - enc = (OpusEncoder*)ptr; - if (s < st->layout.nb_coupled_streams) - ptr += align(coupled_size); - else - ptr += align(mono_size); - ret = opus_encoder_ctl(enc, OPUS_RESET_STATE); - if (ret != OPUS_OK) - break; - } - } - break; - default: - ret = OPUS_UNIMPLEMENTED; - break; - } - return ret; -bad_arg: - return OPUS_BAD_ARG; -} - -int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) -{ - int ret; - va_list ap; - va_start(ap, request); - ret = opus_multistream_encoder_ctl_va_list(st, request, ap); - va_end(ap); - return ret; -} - -void opus_multistream_encoder_destroy(OpusMSEncoder *st) -{ - opus_free(st); -} diff --git a/Engine/lib/opus/src/opus_private.h b/Engine/lib/opus/src/opus_private.h deleted file mode 100644 index 5e2463f54..000000000 --- a/Engine/lib/opus/src/opus_private.h +++ /dev/null @@ -1,201 +0,0 @@ -/* Copyright (c) 2012 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. -*/ - - -#ifndef OPUS_PRIVATE_H -#define OPUS_PRIVATE_H - -#include "arch.h" -#include "opus.h" -#include "celt.h" - -#include /* va_list */ -#include /* offsetof */ - -struct OpusRepacketizer { - unsigned char toc; - int nb_frames; - const unsigned char *frames[48]; - opus_int16 len[48]; - int framesize; -}; - -typedef struct ChannelLayout { - int nb_channels; - int nb_streams; - int nb_coupled_streams; - unsigned char mapping[256]; -} ChannelLayout; - -typedef enum { - MAPPING_TYPE_NONE, - MAPPING_TYPE_SURROUND, - MAPPING_TYPE_AMBISONICS -} MappingType; - -struct OpusMSEncoder { - ChannelLayout layout; - int arch; - int lfe_stream; - int application; - int variable_duration; - MappingType mapping_type; - opus_int32 bitrate_bps; - /* Encoder states go here */ - /* then opus_val32 window_mem[channels*120]; */ - /* then opus_val32 preemph_mem[channels]; */ -}; - -struct OpusMSDecoder { - ChannelLayout layout; - /* Decoder states go here */ -}; - -int opus_multistream_encoder_ctl_va_list(struct OpusMSEncoder *st, int request, - va_list ap); -int opus_multistream_decoder_ctl_va_list(struct OpusMSDecoder *st, int request, - va_list ap); - -int validate_layout(const ChannelLayout *layout); -int get_left_channel(const ChannelLayout *layout, int stream_id, int prev); -int get_right_channel(const ChannelLayout *layout, int stream_id, int prev); -int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev); - -typedef void (*opus_copy_channel_in_func)( - opus_val16 *dst, - int dst_stride, - const void *src, - int src_stride, - int src_channel, - int frame_size, - void *user_data -); - -typedef void (*opus_copy_channel_out_func)( - void *dst, - int dst_stride, - int dst_channel, - const opus_val16 *src, - int src_stride, - int frame_size, - void *user_data -); - -#define MODE_SILK_ONLY 1000 -#define MODE_HYBRID 1001 -#define MODE_CELT_ONLY 1002 - -#define OPUS_SET_VOICE_RATIO_REQUEST 11018 -#define OPUS_GET_VOICE_RATIO_REQUEST 11019 - -/** Configures the encoder's expected percentage of voice - * opposed to music or other signals. - * - * @note This interface is currently more aspiration than actuality. It's - * ultimately expected to bias an automatic signal classifier, but it currently - * just shifts the static bitrate to mode mapping around a little bit. - * - * @param[in] x int: Voice percentage in the range 0-100, inclusive. - * @hideinitializer */ -#define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __opus_check_int(x) -/** Gets the encoder's configured voice ratio value, @see OPUS_SET_VOICE_RATIO - * - * @param[out] x int*: Voice percentage in the range 0-100, inclusive. - * @hideinitializer */ -#define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __opus_check_int_ptr(x) - - -#define OPUS_SET_FORCE_MODE_REQUEST 11002 -#define OPUS_SET_FORCE_MODE(x) OPUS_SET_FORCE_MODE_REQUEST, __opus_check_int(x) - -typedef void (*downmix_func)(const void *, opus_val32 *, int, int, int, int, int); -void downmix_float(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C); -void downmix_int(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C); -int is_digital_silence(const opus_val16* pcm, int frame_size, int channels, int lsb_depth); - -int encode_size(int size, unsigned char *data); - -opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_int32 Fs); - -opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size, - unsigned char *data, opus_int32 out_data_bytes, int lsb_depth, - const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, - int analysis_channels, downmix_func downmix, int float_api); - -int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 len, - opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited, - opus_int32 *packet_offset, int soft_clip); - -/* Make sure everything is properly aligned. */ -static OPUS_INLINE int align(int i) -{ - struct foo {char c; union { void* p; opus_int32 i; opus_val32 v; } u;}; - - unsigned int alignment = offsetof(struct foo, u); - - /* Optimizing compilers should optimize div and multiply into and - for all sensible alignment values. */ - return ((i + alignment - 1) / alignment) * alignment; -} - -int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, - int self_delimited, unsigned char *out_toc, - const unsigned char *frames[48], opus_int16 size[48], - int *payload_offset, opus_int32 *packet_offset); - -opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int end, - unsigned char *data, opus_int32 maxlen, int self_delimited, int pad); - -int pad_frame(unsigned char *data, opus_int32 len, opus_int32 new_len); - -int opus_multistream_encode_native -( - struct OpusMSEncoder *st, - opus_copy_channel_in_func copy_channel_in, - const void *pcm, - int analysis_frame_size, - unsigned char *data, - opus_int32 max_data_bytes, - int lsb_depth, - downmix_func downmix, - int float_api, - void *user_data -); - -int opus_multistream_decode_native( - struct OpusMSDecoder *st, - const unsigned char *data, - opus_int32 len, - void *pcm, - opus_copy_channel_out_func copy_channel_out, - int frame_size, - int decode_fec, - int soft_clip, - void *user_data -); - -#endif /* OPUS_PRIVATE_H */ diff --git a/Engine/lib/opus/src/opus_projection_decoder.c b/Engine/lib/opus/src/opus_projection_decoder.c deleted file mode 100644 index c2e07d5bc..000000000 --- a/Engine/lib/opus/src/opus_projection_decoder.c +++ /dev/null @@ -1,258 +0,0 @@ -/* Copyright (c) 2017 Google Inc. - Written by Andrew Allen */ -/* - 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 "mathops.h" -#include "os_support.h" -#include "opus_private.h" -#include "opus_defines.h" -#include "opus_projection.h" -#include "opus_multistream.h" -#include "mapping_matrix.h" -#include "stack_alloc.h" - -struct OpusProjectionDecoder -{ - opus_int32 demixing_matrix_size_in_bytes; - /* Encoder states go here */ -}; - -#if !defined(DISABLE_FLOAT_API) -static void opus_projection_copy_channel_out_float( - void *dst, - int dst_stride, - int dst_channel, - const opus_val16 *src, - int src_stride, - int frame_size, - void *user_data) -{ - float *float_dst; - const MappingMatrix *matrix; - float_dst = (float *)dst; - matrix = (const MappingMatrix *)user_data; - - if (dst_channel == 0) - OPUS_CLEAR(float_dst, frame_size * dst_stride); - - if (src != NULL) - mapping_matrix_multiply_channel_out_float(matrix, src, dst_channel, - src_stride, float_dst, dst_stride, frame_size); -} -#endif - -static void opus_projection_copy_channel_out_short( - void *dst, - int dst_stride, - int dst_channel, - const opus_val16 *src, - int src_stride, - int frame_size, - void *user_data) -{ - opus_int16 *short_dst; - const MappingMatrix *matrix; - short_dst = (opus_int16 *)dst; - matrix = (const MappingMatrix *)user_data; - if (dst_channel == 0) - OPUS_CLEAR(short_dst, frame_size * dst_stride); - - if (src != NULL) - mapping_matrix_multiply_channel_out_short(matrix, src, dst_channel, - src_stride, short_dst, dst_stride, frame_size); -} - -static MappingMatrix *get_dec_demixing_matrix(OpusProjectionDecoder *st) -{ - /* void* cast avoids clang -Wcast-align warning */ - return (MappingMatrix*)(void*)((char*)st + - align(sizeof(OpusProjectionDecoder))); -} - -static OpusMSDecoder *get_multistream_decoder(OpusProjectionDecoder *st) -{ - /* void* cast avoids clang -Wcast-align warning */ - return (OpusMSDecoder*)(void*)((char*)st + - align(sizeof(OpusProjectionDecoder) + - st->demixing_matrix_size_in_bytes)); -} - -opus_int32 opus_projection_decoder_get_size(int channels, int streams, - int coupled_streams) -{ - opus_int32 matrix_size; - opus_int32 decoder_size; - - matrix_size = - mapping_matrix_get_size(streams + coupled_streams, channels); - if (!matrix_size) - return 0; - - decoder_size = opus_multistream_decoder_get_size(streams, coupled_streams); - if (!decoder_size) - return 0; - - return align(sizeof(OpusProjectionDecoder)) + matrix_size + decoder_size; -} - -int opus_projection_decoder_init(OpusProjectionDecoder *st, opus_int32 Fs, - int channels, int streams, int coupled_streams, - unsigned char *demixing_matrix, opus_int32 demixing_matrix_size) -{ - int nb_input_streams; - opus_int32 expected_matrix_size; - int i, ret; - unsigned char mapping[255]; - VARDECL(opus_int16, buf); - ALLOC_STACK; - - /* Verify supplied matrix size. */ - nb_input_streams = streams + coupled_streams; - expected_matrix_size = nb_input_streams * channels * sizeof(opus_int16); - if (expected_matrix_size != demixing_matrix_size) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - - /* Convert demixing matrix input into internal format. */ - ALLOC(buf, nb_input_streams * channels, opus_int16); - for (i = 0; i < nb_input_streams * channels; i++) - { - int s = demixing_matrix[2*i + 1] << 8 | demixing_matrix[2*i]; - s = ((s & 0xFFFF) ^ 0x8000) - 0x8000; - buf[i] = (opus_int16)s; - } - - /* Assign demixing matrix. */ - st->demixing_matrix_size_in_bytes = - mapping_matrix_get_size(channels, nb_input_streams); - if (!st->demixing_matrix_size_in_bytes) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - - mapping_matrix_init(get_dec_demixing_matrix(st), channels, nb_input_streams, 0, - buf, demixing_matrix_size); - - /* Set trivial mapping so each input channel pairs with a matrix column. */ - for (i = 0; i < channels; i++) - mapping[i] = i; - - ret = opus_multistream_decoder_init( - get_multistream_decoder(st), Fs, channels, streams, coupled_streams, mapping); - RESTORE_STACK; - return ret; -} - -OpusProjectionDecoder *opus_projection_decoder_create( - opus_int32 Fs, int channels, int streams, int coupled_streams, - unsigned char *demixing_matrix, opus_int32 demixing_matrix_size, int *error) -{ - int size; - int ret; - OpusProjectionDecoder *st; - - /* Allocate space for the projection decoder. */ - size = opus_projection_decoder_get_size(channels, streams, coupled_streams); - if (!size) { - if (error) - *error = OPUS_ALLOC_FAIL; - return NULL; - } - st = (OpusProjectionDecoder *)opus_alloc(size); - if (!st) - { - if (error) - *error = OPUS_ALLOC_FAIL; - return NULL; - } - - /* Initialize projection decoder with provided settings. */ - ret = opus_projection_decoder_init(st, Fs, channels, streams, coupled_streams, - demixing_matrix, demixing_matrix_size); - if (ret != OPUS_OK) - { - opus_free(st); - st = NULL; - } - if (error) - *error = ret; - return st; -} - -#ifdef FIXED_POINT -int opus_projection_decode(OpusProjectionDecoder *st, const unsigned char *data, - opus_int32 len, opus_int16 *pcm, int frame_size, - int decode_fec) -{ - return opus_multistream_decode_native(get_multistream_decoder(st), data, len, - pcm, opus_projection_copy_channel_out_short, frame_size, decode_fec, 0, - get_dec_demixing_matrix(st)); -} -#else -int opus_projection_decode(OpusProjectionDecoder *st, const unsigned char *data, - opus_int32 len, opus_int16 *pcm, int frame_size, - int decode_fec) -{ - return opus_multistream_decode_native(get_multistream_decoder(st), data, len, - pcm, opus_projection_copy_channel_out_short, frame_size, decode_fec, 1, - get_dec_demixing_matrix(st)); -} -#endif - -#ifndef DISABLE_FLOAT_API -int opus_projection_decode_float(OpusProjectionDecoder *st, const unsigned char *data, - opus_int32 len, float *pcm, int frame_size, int decode_fec) -{ - return opus_multistream_decode_native(get_multistream_decoder(st), data, len, - pcm, opus_projection_copy_channel_out_float, frame_size, decode_fec, 0, - get_dec_demixing_matrix(st)); -} -#endif - -int opus_projection_decoder_ctl(OpusProjectionDecoder *st, int request, ...) -{ - va_list ap; - int ret = OPUS_OK; - - va_start(ap, request); - ret = opus_multistream_decoder_ctl_va_list(get_multistream_decoder(st), - request, ap); - va_end(ap); - return ret; -} - -void opus_projection_decoder_destroy(OpusProjectionDecoder *st) -{ - opus_free(st); -} - diff --git a/Engine/lib/opus/src/opus_projection_encoder.c b/Engine/lib/opus/src/opus_projection_encoder.c deleted file mode 100644 index 06fb2d252..000000000 --- a/Engine/lib/opus/src/opus_projection_encoder.c +++ /dev/null @@ -1,468 +0,0 @@ -/* Copyright (c) 2017 Google Inc. - Written by Andrew Allen */ -/* - 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 "mathops.h" -#include "os_support.h" -#include "opus_private.h" -#include "opus_defines.h" -#include "opus_projection.h" -#include "opus_multistream.h" -#include "stack_alloc.h" -#include "mapping_matrix.h" - -struct OpusProjectionEncoder -{ - opus_int32 mixing_matrix_size_in_bytes; - opus_int32 demixing_matrix_size_in_bytes; - /* Encoder states go here */ -}; - -#if !defined(DISABLE_FLOAT_API) -static void opus_projection_copy_channel_in_float( - opus_val16 *dst, - int dst_stride, - const void *src, - int src_stride, - int src_channel, - int frame_size, - void *user_data -) -{ - mapping_matrix_multiply_channel_in_float((const MappingMatrix*)user_data, - (const float*)src, src_stride, dst, src_channel, dst_stride, frame_size); -} -#endif - -static void opus_projection_copy_channel_in_short( - opus_val16 *dst, - int dst_stride, - const void *src, - int src_stride, - int src_channel, - int frame_size, - void *user_data -) -{ - mapping_matrix_multiply_channel_in_short((const MappingMatrix*)user_data, - (const opus_int16*)src, src_stride, dst, src_channel, dst_stride, frame_size); -} - -static int get_order_plus_one_from_channels(int channels, int *order_plus_one) -{ - int order_plus_one_; - int acn_channels; - int nondiegetic_channels; - - /* Allowed numbers of channels: - * (1 + n)^2 + 2j, for n = 0...14 and j = 0 or 1. - */ - if (channels < 1 || channels > 227) - return OPUS_BAD_ARG; - - order_plus_one_ = isqrt32(channels); - acn_channels = order_plus_one_ * order_plus_one_; - nondiegetic_channels = channels - acn_channels; - if (nondiegetic_channels != 0 && nondiegetic_channels != 2) - return OPUS_BAD_ARG; - - if (order_plus_one) - *order_plus_one = order_plus_one_; - return OPUS_OK; -} - -static int get_streams_from_channels(int channels, int mapping_family, - int *streams, int *coupled_streams, - int *order_plus_one) -{ - if (mapping_family == 3) - { - if (get_order_plus_one_from_channels(channels, order_plus_one) != OPUS_OK) - return OPUS_BAD_ARG; - if (streams) - *streams = (channels + 1) / 2; - if (coupled_streams) - *coupled_streams = channels / 2; - return OPUS_OK; - } - return OPUS_BAD_ARG; -} - -static MappingMatrix *get_mixing_matrix(OpusProjectionEncoder *st) -{ - /* void* cast avoids clang -Wcast-align warning */ - return (MappingMatrix *)(void*)((char*)st + - align(sizeof(OpusProjectionEncoder))); -} - -static MappingMatrix *get_enc_demixing_matrix(OpusProjectionEncoder *st) -{ - /* void* cast avoids clang -Wcast-align warning */ - return (MappingMatrix *)(void*)((char*)st + - align(sizeof(OpusProjectionEncoder) + - st->mixing_matrix_size_in_bytes)); -} - -static OpusMSEncoder *get_multistream_encoder(OpusProjectionEncoder *st) -{ - /* void* cast avoids clang -Wcast-align warning */ - return (OpusMSEncoder *)(void*)((char*)st + - align(sizeof(OpusProjectionEncoder) + - st->mixing_matrix_size_in_bytes + - st->demixing_matrix_size_in_bytes)); -} - -opus_int32 opus_projection_ambisonics_encoder_get_size(int channels, - int mapping_family) -{ - int nb_streams; - int nb_coupled_streams; - int order_plus_one; - int mixing_matrix_rows, mixing_matrix_cols; - int demixing_matrix_rows, demixing_matrix_cols; - opus_int32 mixing_matrix_size, demixing_matrix_size; - opus_int32 encoder_size; - int ret; - - ret = get_streams_from_channels(channels, mapping_family, &nb_streams, - &nb_coupled_streams, &order_plus_one); - if (ret != OPUS_OK) - return 0; - - if (order_plus_one == 2) - { - mixing_matrix_rows = mapping_matrix_foa_mixing.rows; - mixing_matrix_cols = mapping_matrix_foa_mixing.cols; - demixing_matrix_rows = mapping_matrix_foa_demixing.rows; - demixing_matrix_cols = mapping_matrix_foa_demixing.cols; - } - else if (order_plus_one == 3) - { - mixing_matrix_rows = mapping_matrix_soa_mixing.rows; - mixing_matrix_cols = mapping_matrix_soa_mixing.cols; - demixing_matrix_rows = mapping_matrix_soa_demixing.rows; - demixing_matrix_cols = mapping_matrix_soa_demixing.cols; - } - else if (order_plus_one == 4) - { - mixing_matrix_rows = mapping_matrix_toa_mixing.rows; - mixing_matrix_cols = mapping_matrix_toa_mixing.cols; - demixing_matrix_rows = mapping_matrix_toa_demixing.rows; - demixing_matrix_cols = mapping_matrix_toa_demixing.cols; - } - else - return 0; - - mixing_matrix_size = - mapping_matrix_get_size(mixing_matrix_rows, mixing_matrix_cols); - if (!mixing_matrix_size) - return 0; - - demixing_matrix_size = - mapping_matrix_get_size(demixing_matrix_rows, demixing_matrix_cols); - if (!demixing_matrix_size) - return 0; - - encoder_size = - opus_multistream_encoder_get_size(nb_streams, nb_coupled_streams); - if (!encoder_size) - return 0; - - return align(sizeof(OpusProjectionEncoder)) + - mixing_matrix_size + demixing_matrix_size + encoder_size; -} - -int opus_projection_ambisonics_encoder_init(OpusProjectionEncoder *st, opus_int32 Fs, - int channels, int mapping_family, - int *streams, int *coupled_streams, - int application) -{ - MappingMatrix *mixing_matrix; - MappingMatrix *demixing_matrix; - OpusMSEncoder *ms_encoder; - int i; - int ret; - int order_plus_one; - unsigned char mapping[255]; - - if (streams == NULL || coupled_streams == NULL) { - return OPUS_BAD_ARG; - } - - if (get_streams_from_channels(channels, mapping_family, streams, - coupled_streams, &order_plus_one) != OPUS_OK) - return OPUS_BAD_ARG; - - if (mapping_family == 3) - { - /* Assign mixing matrix based on available pre-computed matrices. */ - mixing_matrix = get_mixing_matrix(st); - if (order_plus_one == 2) - { - mapping_matrix_init(mixing_matrix, mapping_matrix_foa_mixing.rows, - mapping_matrix_foa_mixing.cols, mapping_matrix_foa_mixing.gain, - mapping_matrix_foa_mixing_data, - sizeof(mapping_matrix_foa_mixing_data)); - } - else if (order_plus_one == 3) - { - mapping_matrix_init(mixing_matrix, mapping_matrix_soa_mixing.rows, - mapping_matrix_soa_mixing.cols, mapping_matrix_soa_mixing.gain, - mapping_matrix_soa_mixing_data, - sizeof(mapping_matrix_soa_mixing_data)); - } - else if (order_plus_one == 4) - { - mapping_matrix_init(mixing_matrix, mapping_matrix_toa_mixing.rows, - mapping_matrix_toa_mixing.cols, mapping_matrix_toa_mixing.gain, - mapping_matrix_toa_mixing_data, - sizeof(mapping_matrix_toa_mixing_data)); - } - else - return OPUS_BAD_ARG; - - st->mixing_matrix_size_in_bytes = mapping_matrix_get_size( - mixing_matrix->rows, mixing_matrix->cols); - if (!st->mixing_matrix_size_in_bytes) - return OPUS_BAD_ARG; - - /* Assign demixing matrix based on available pre-computed matrices. */ - demixing_matrix = get_enc_demixing_matrix(st); - if (order_plus_one == 2) - { - mapping_matrix_init(demixing_matrix, mapping_matrix_foa_demixing.rows, - mapping_matrix_foa_demixing.cols, mapping_matrix_foa_demixing.gain, - mapping_matrix_foa_demixing_data, - sizeof(mapping_matrix_foa_demixing_data)); - } - else if (order_plus_one == 3) - { - mapping_matrix_init(demixing_matrix, mapping_matrix_soa_demixing.rows, - mapping_matrix_soa_demixing.cols, mapping_matrix_soa_demixing.gain, - mapping_matrix_soa_demixing_data, - sizeof(mapping_matrix_soa_demixing_data)); - } - else if (order_plus_one == 4) - { - mapping_matrix_init(demixing_matrix, mapping_matrix_toa_demixing.rows, - mapping_matrix_toa_demixing.cols, mapping_matrix_toa_demixing.gain, - mapping_matrix_toa_demixing_data, - sizeof(mapping_matrix_toa_demixing_data)); - } - else - return OPUS_BAD_ARG; - - st->demixing_matrix_size_in_bytes = mapping_matrix_get_size( - demixing_matrix->rows, demixing_matrix->cols); - if (!st->demixing_matrix_size_in_bytes) - return OPUS_BAD_ARG; - } - else - return OPUS_UNIMPLEMENTED; - - /* Ensure matrices are large enough for desired coding scheme. */ - if (*streams + *coupled_streams > mixing_matrix->rows || - channels > mixing_matrix->cols || - channels > demixing_matrix->rows || - *streams + *coupled_streams > demixing_matrix->cols) - return OPUS_BAD_ARG; - - /* Set trivial mapping so each input channel pairs with a matrix column. */ - for (i = 0; i < channels; i++) - mapping[i] = i; - - /* Initialize multistream encoder with provided settings. */ - ms_encoder = get_multistream_encoder(st); - ret = opus_multistream_encoder_init(ms_encoder, Fs, channels, *streams, - *coupled_streams, mapping, application); - return ret; -} - -OpusProjectionEncoder *opus_projection_ambisonics_encoder_create( - opus_int32 Fs, int channels, int mapping_family, int *streams, - int *coupled_streams, int application, int *error) -{ - int size; - int ret; - OpusProjectionEncoder *st; - - /* Allocate space for the projection encoder. */ - size = opus_projection_ambisonics_encoder_get_size(channels, mapping_family); - if (!size) { - if (error) - *error = OPUS_ALLOC_FAIL; - return NULL; - } - st = (OpusProjectionEncoder *)opus_alloc(size); - if (!st) - { - if (error) - *error = OPUS_ALLOC_FAIL; - return NULL; - } - - /* Initialize projection encoder with provided settings. */ - ret = opus_projection_ambisonics_encoder_init(st, Fs, channels, - mapping_family, streams, coupled_streams, application); - if (ret != OPUS_OK) - { - opus_free(st); - st = NULL; - } - if (error) - *error = ret; - return st; -} - -int opus_projection_encode(OpusProjectionEncoder *st, const opus_int16 *pcm, - int frame_size, unsigned char *data, - opus_int32 max_data_bytes) -{ - return opus_multistream_encode_native(get_multistream_encoder(st), - opus_projection_copy_channel_in_short, pcm, frame_size, data, - max_data_bytes, 16, downmix_int, 0, get_mixing_matrix(st)); -} - -#ifndef DISABLE_FLOAT_API -#ifdef FIXED_POINT -int opus_projection_encode_float(OpusProjectionEncoder *st, const float *pcm, - int frame_size, unsigned char *data, - opus_int32 max_data_bytes) -{ - return opus_multistream_encode_native(get_multistream_encoder(st), - opus_projection_copy_channel_in_float, pcm, frame_size, data, - max_data_bytes, 16, downmix_float, 1, get_mixing_matrix(st)); -} -#else -int opus_projection_encode_float(OpusProjectionEncoder *st, const float *pcm, - int frame_size, unsigned char *data, - opus_int32 max_data_bytes) -{ - return opus_multistream_encode_native(get_multistream_encoder(st), - opus_projection_copy_channel_in_float, pcm, frame_size, data, - max_data_bytes, 24, downmix_float, 1, get_mixing_matrix(st)); -} -#endif -#endif - -void opus_projection_encoder_destroy(OpusProjectionEncoder *st) -{ - opus_free(st); -} - -int opus_projection_encoder_ctl(OpusProjectionEncoder *st, int request, ...) -{ - va_list ap; - MappingMatrix *demixing_matrix; - OpusMSEncoder *ms_encoder; - int ret = OPUS_OK; - - ms_encoder = get_multistream_encoder(st); - demixing_matrix = get_enc_demixing_matrix(st); - - va_start(ap, request); - switch(request) - { - case OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = - ms_encoder->layout.nb_channels * (ms_encoder->layout.nb_streams - + ms_encoder->layout.nb_coupled_streams) * sizeof(opus_int16); - } - break; - case OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = demixing_matrix->gain; - } - break; - case OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST: - { - int i, j, k, l; - int nb_input_streams; - int nb_output_streams; - unsigned char *external_char; - opus_int16 *internal_short; - opus_int32 external_size; - opus_int32 internal_size; - - /* (I/O is in relation to the decoder's perspective). */ - nb_input_streams = ms_encoder->layout.nb_streams + - ms_encoder->layout.nb_coupled_streams; - nb_output_streams = ms_encoder->layout.nb_channels; - - external_char = va_arg(ap, unsigned char *); - external_size = va_arg(ap, opus_int32); - if (!external_char) - { - goto bad_arg; - } - internal_short = mapping_matrix_get_data(demixing_matrix); - internal_size = nb_input_streams * nb_output_streams * sizeof(opus_int16); - if (external_size != internal_size) - { - goto bad_arg; - } - - /* Copy demixing matrix subset to output destination. */ - l = 0; - for (i = 0; i < nb_input_streams; i++) { - for (j = 0; j < nb_output_streams; j++) { - k = demixing_matrix->rows * i + j; - external_char[2*l] = (unsigned char)internal_short[k]; - external_char[2*l+1] = (unsigned char)(internal_short[k] >> 8); - l++; - } - } - } - break; - default: - { - ret = opus_multistream_encoder_ctl_va_list(ms_encoder, request, ap); - } - break; - } - va_end(ap); - return ret; - -bad_arg: - va_end(ap); - return OPUS_BAD_ARG; -} - diff --git a/Engine/lib/opus/src/repacketizer.c b/Engine/lib/opus/src/repacketizer.c deleted file mode 100644 index bda44a148..000000000 --- a/Engine/lib/opus/src/repacketizer.c +++ /dev/null @@ -1,349 +0,0 @@ -/* Copyright (c) 2011 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.h" -#include "opus_private.h" -#include "os_support.h" - - -int opus_repacketizer_get_size(void) -{ - return sizeof(OpusRepacketizer); -} - -OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) -{ - rp->nb_frames = 0; - return rp; -} - -OpusRepacketizer *opus_repacketizer_create(void) -{ - OpusRepacketizer *rp; - rp=(OpusRepacketizer *)opus_alloc(opus_repacketizer_get_size()); - if(rp==NULL)return NULL; - return opus_repacketizer_init(rp); -} - -void opus_repacketizer_destroy(OpusRepacketizer *rp) -{ - opus_free(rp); -} - -static int opus_repacketizer_cat_impl(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len, int self_delimited) -{ - unsigned char tmp_toc; - int curr_nb_frames,ret; - /* Set of check ToC */ - if (len<1) return OPUS_INVALID_PACKET; - if (rp->nb_frames == 0) - { - rp->toc = data[0]; - rp->framesize = opus_packet_get_samples_per_frame(data, 8000); - } else if ((rp->toc&0xFC) != (data[0]&0xFC)) - { - /*fprintf(stderr, "toc mismatch: 0x%x vs 0x%x\n", rp->toc, data[0]);*/ - return OPUS_INVALID_PACKET; - } - curr_nb_frames = opus_packet_get_nb_frames(data, len); - if(curr_nb_frames<1) return OPUS_INVALID_PACKET; - - /* Check the 120 ms maximum packet size */ - if ((curr_nb_frames+rp->nb_frames)*rp->framesize > 960) - { - return OPUS_INVALID_PACKET; - } - - ret=opus_packet_parse_impl(data, len, self_delimited, &tmp_toc, &rp->frames[rp->nb_frames], &rp->len[rp->nb_frames], NULL, NULL); - if(ret<1)return ret; - - rp->nb_frames += curr_nb_frames; - return OPUS_OK; -} - -int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) -{ - return opus_repacketizer_cat_impl(rp, data, len, 0); -} - -int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) -{ - return rp->nb_frames; -} - -opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int end, - unsigned char *data, opus_int32 maxlen, int self_delimited, int pad) -{ - int i, count; - opus_int32 tot_size; - opus_int16 *len; - const unsigned char **frames; - unsigned char * ptr; - - if (begin<0 || begin>=end || end>rp->nb_frames) - { - /*fprintf(stderr, "%d %d %d\n", begin, end, rp->nb_frames);*/ - return OPUS_BAD_ARG; - } - count = end-begin; - - len = rp->len+begin; - frames = rp->frames+begin; - if (self_delimited) - tot_size = 1 + (len[count-1]>=252); - else - tot_size = 0; - - ptr = data; - if (count==1) - { - /* Code 0 */ - tot_size += len[0]+1; - if (tot_size > maxlen) - return OPUS_BUFFER_TOO_SMALL; - *ptr++ = rp->toc&0xFC; - } else if (count==2) - { - if (len[1] == len[0]) - { - /* Code 1 */ - tot_size += 2*len[0]+1; - if (tot_size > maxlen) - return OPUS_BUFFER_TOO_SMALL; - *ptr++ = (rp->toc&0xFC) | 0x1; - } else { - /* Code 2 */ - tot_size += len[0]+len[1]+2+(len[0]>=252); - if (tot_size > maxlen) - return OPUS_BUFFER_TOO_SMALL; - *ptr++ = (rp->toc&0xFC) | 0x2; - ptr += encode_size(len[0], ptr); - } - } - if (count > 2 || (pad && tot_size < maxlen)) - { - /* Code 3 */ - int vbr; - int pad_amount=0; - - /* Restart the process for the padding case */ - ptr = data; - if (self_delimited) - tot_size = 1 + (len[count-1]>=252); - else - tot_size = 0; - vbr = 0; - for (i=1;i=252) + len[i]; - tot_size += len[count-1]; - - if (tot_size > maxlen) - return OPUS_BUFFER_TOO_SMALL; - *ptr++ = (rp->toc&0xFC) | 0x3; - *ptr++ = count | 0x80; - } else { - tot_size += count*len[0]+2; - if (tot_size > maxlen) - return OPUS_BUFFER_TOO_SMALL; - *ptr++ = (rp->toc&0xFC) | 0x3; - *ptr++ = count; - } - pad_amount = pad ? (maxlen-tot_size) : 0; - if (pad_amount != 0) - { - int nb_255s; - data[1] |= 0x40; - nb_255s = (pad_amount-1)/255; - for (i=0;inb_frames, data, maxlen, 0, 0); -} - -int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len) -{ - OpusRepacketizer rp; - opus_int32 ret; - if (len < 1) - return OPUS_BAD_ARG; - if (len==new_len) - return OPUS_OK; - else if (len > new_len) - return OPUS_BAD_ARG; - opus_repacketizer_init(&rp); - /* Moving payload to the end of the packet so we can do in-place padding */ - OPUS_MOVE(data+new_len-len, data, len); - ret = opus_repacketizer_cat(&rp, data+new_len-len, len); - if (ret != OPUS_OK) - return ret; - ret = opus_repacketizer_out_range_impl(&rp, 0, rp.nb_frames, data, new_len, 0, 1); - if (ret > 0) - return OPUS_OK; - else - return ret; -} - -opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len) -{ - OpusRepacketizer rp; - opus_int32 ret; - if (len < 1) - return OPUS_BAD_ARG; - opus_repacketizer_init(&rp); - ret = opus_repacketizer_cat(&rp, data, len); - if (ret < 0) - return ret; - ret = opus_repacketizer_out_range_impl(&rp, 0, rp.nb_frames, data, len, 0, 0); - celt_assert(ret > 0 && ret <= len); - return ret; -} - -int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams) -{ - int s; - int count; - unsigned char toc; - opus_int16 size[48]; - opus_int32 packet_offset; - opus_int32 amount; - - if (len < 1) - return OPUS_BAD_ARG; - if (len==new_len) - return OPUS_OK; - else if (len > new_len) - return OPUS_BAD_ARG; - amount = new_len - len; - /* Seek to last stream */ - for (s=0;s -#include -#include - -#define MAX_PACKETOUT 32000 - -void usage(char *argv0) -{ - fprintf(stderr, "usage: %s [options] input_file output_file\n", argv0); -} - -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]; -} - -int main(int argc, char *argv[]) -{ - int i, eof=0; - FILE *fin, *fout; - unsigned char packets[48][1500]; - int len[48]; - int rng[48]; - OpusRepacketizer *rp; - unsigned char output_packet[MAX_PACKETOUT]; - int merge = 1, split=0; - - if (argc < 3) - { - usage(argv[0]); - return EXIT_FAILURE; - } - for (i=1;i48) - { - fprintf(stderr, "-merge parameter must be less than 48.\n"); - return EXIT_FAILURE; - } - i++; - } else if (strcmp(argv[i], "-split")==0) - split = 1; - else - { - fprintf(stderr, "Unknown option: %s\n", argv[i]); - usage(argv[0]); - return EXIT_FAILURE; - } - } - fin = fopen(argv[argc-2], "r"); - if(fin==NULL) - { - fprintf(stderr, "Error opening input file: %s\n", argv[argc-2]); - return EXIT_FAILURE; - } - fout = fopen(argv[argc-1], "w"); - if(fout==NULL) - { - fprintf(stderr, "Error opening output file: %s\n", argv[argc-1]); - fclose(fin); - return EXIT_FAILURE; - } - - rp = opus_repacketizer_create(); - while (!eof) - { - int err; - int nb_packets=merge; - opus_repacketizer_init(rp); - for (i=0;i1500 || len[i]<0) - { - if (feof(fin)) - { - eof = 1; - } else { - fprintf(stderr, "Invalid payload length\n"); - fclose(fin); - fclose(fout); - return EXIT_FAILURE; - } - break; - } - if (fread(ch, 1, 4, fin)!=4) - { - if (feof(fin)) - { - eof = 1; - } else { - fprintf(stderr, "Error reading.\n"); - fclose(fin); - fclose(fout); - return EXIT_FAILURE; - } - break; - } - rng[i] = char_to_int(ch); - if (fread(packets[i], len[i], 1, fin)!=1) { - if (feof(fin)) - { - eof = 1; - } else { - fprintf(stderr, "Error reading packet of %u bytes.\n", len[i]); - fclose(fin); - fclose(fout); - return EXIT_FAILURE; - } - break; - } - err = opus_repacketizer_cat(rp, packets[i], len[i]); - if (err!=OPUS_OK) - { - fprintf(stderr, "opus_repacketizer_cat() failed: %s\n", opus_strerror(err)); - break; - } - } - nb_packets = i; - - if (eof) - break; - - if (!split) - { - err = opus_repacketizer_out(rp, output_packet, MAX_PACKETOUT); - if (err>0) { - unsigned char int_field[4]; - int_to_char(err, int_field); - if(fwrite(int_field, 1, 4, fout)!=4){ - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - int_to_char(rng[nb_packets-1], int_field); - if (fwrite(int_field, 1, 4, fout)!=4) { - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - if (fwrite(output_packet, 1, err, fout)!=(unsigned)err) { - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - /*fprintf(stderr, "out len = %d\n", err);*/ - } else { - fprintf(stderr, "opus_repacketizer_out() failed: %s\n", opus_strerror(err)); - } - } else { - int nb_frames = opus_repacketizer_get_nb_frames(rp); - for (i=0;i0) { - unsigned char int_field[4]; - int_to_char(err, int_field); - if (fwrite(int_field, 1, 4, fout)!=4) { - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - if (i==nb_frames-1) - int_to_char(rng[nb_packets-1], int_field); - else - int_to_char(0, int_field); - if (fwrite(int_field, 1, 4, fout)!=4) { - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - if (fwrite(output_packet, 1, err, fout)!=(unsigned)err) { - fprintf(stderr, "Error writing.\n"); - return EXIT_FAILURE; - } - /*fprintf(stderr, "out len = %d\n", err);*/ - } else { - fprintf(stderr, "opus_repacketizer_out() failed: %s\n", opus_strerror(err)); - } - - } - } - } - - fclose(fin); - fclose(fout); - return EXIT_SUCCESS; -} diff --git a/Engine/lib/opus/src/tansig_table.h b/Engine/lib/opus/src/tansig_table.h deleted file mode 100644 index c76f844a7..000000000 --- a/Engine/lib/opus/src/tansig_table.h +++ /dev/null @@ -1,45 +0,0 @@ -/* This file is auto-generated by gen_tables */ - -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, -}; diff --git a/Engine/lib/opus/tests/meson.build b/Engine/lib/opus/tests/meson.build deleted file mode 100644 index 5f3ac9df3..000000000 --- a/Engine/lib/opus/tests/meson.build +++ /dev/null @@ -1,34 +0,0 @@ -# Tests that link to libopus -opus_tests = [ - ['test_opus_api'], - ['test_opus_decode', [], 60], - ['test_opus_encode', 'opus_encode_regressions.c', 120], - ['test_opus_padding'], - ['test_opus_projection'], -] - -foreach t : opus_tests - test_name = t.get(0) - extra_srcs = t.get(1, []) - - test_kwargs = {} - if t.length() > 2 - test_kwargs += {'timeout': t[2]} - endif - - exe_kwargs = {} - # This test uses private symbols - if test_name == 'test_opus_projection' - exe_kwargs = { - 'link_with': [celt_lib, silk_lib], - 'objects': opus_lib.extract_all_objects(), - } - endif - - exe = executable(test_name, '@0@.c'.format(test_name), extra_srcs, - include_directories: opus_includes, - dependencies: [libm, opus_dep], - install: false, - kwargs: exe_kwargs) - test(test_name, exe, kwargs: test_kwargs) -endforeach diff --git a/Engine/lib/opus/tests/opus_build_test.sh b/Engine/lib/opus/tests/opus_build_test.sh deleted file mode 100644 index 573f44731..000000000 --- a/Engine/lib/opus/tests/opus_build_test.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -tarball=`realpath "$1"` -nb_tests="$2" -oldvectors=`realpath "$3"` -newvectors=`realpath "$4"` -base=`basename "$tarball" .tar.gz` - -tar xvf "$tarball" > /dev/null 2>&1 -cd "$base" - -if [ $? -ne 0 ] -then - echo cannot go to "$base" - exit 1 -fi - -mkdir build_tests - -configure_dir=`pwd` -seq -w "$nb_tests" | parallel --halt now,fail=10 -j +2 -q ../random_config.sh "build_tests/run_{}" "$configure_dir" "$oldvectors" "$newvectors" - -if [ $? -ne 0 ] -then - echo Check found errors - exit 1 -else - echo No error found -fi diff --git a/Engine/lib/opus/tests/opus_decode_fuzzer.c b/Engine/lib/opus/tests/opus_decode_fuzzer.c deleted file mode 100644 index ea6ec4fd1..000000000 --- a/Engine/lib/opus/tests/opus_decode_fuzzer.c +++ /dev/null @@ -1,124 +0,0 @@ -/* 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. - - 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 -#include -#include -#include "opus.h" -#include "opus_types.h" - -#define MAX_FRAME_SAMP 5760 -#define MAX_PACKET 1500 - -/* 4 bytes: packet length, 4 bytes: encoder final range */ -#define SETUP_BYTE_COUNT 8 - -#define MAX_DECODES 12 - -typedef struct { - int fs; - int channels; -} TocInfo; - -static void ParseToc(const uint8_t *toc, TocInfo *const info) { - const int samp_freqs[5] = {8000, 12000, 16000, 24000, 48000}; - const int bandwidth = opus_packet_get_bandwidth(toc); - - info->fs = samp_freqs[bandwidth - OPUS_BANDWIDTH_NARROWBAND]; - info->channels = opus_packet_get_nb_channels(toc); -} - -/* Treats the input data as concatenated packets encoded by opus_demo, - * structured as - * bytes 0..3: packet length - * bytes 4..7: encoder final range - * bytes 8+ : Opus packet, including ToC - */ -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - OpusDecoder *dec; - opus_int16 *pcm; - uint8_t *temp_data; - TocInfo toc; - int i = 0; - int err = OPUS_OK; - int num_decodes = 0; - - /* Not enough data to setup the decoder (+1 for the ToC) */ - if (size < SETUP_BYTE_COUNT + 1) { - return 0; - } - - /* Create decoder based on info from the first ToC available */ - ParseToc(&data[SETUP_BYTE_COUNT], &toc); - - dec = opus_decoder_create(toc.fs, toc.channels, &err); - if (err != OPUS_OK || dec == NULL) { - return 0; - } - - pcm = (opus_int16*) malloc(sizeof(*pcm) * MAX_FRAME_SAMP * toc.channels); - - while (i + SETUP_BYTE_COUNT < size && num_decodes++ < MAX_DECODES) { - int len, fec; - - len = (opus_uint32) data[i ] << 24 | - (opus_uint32) data[i + 1] << 16 | - (opus_uint32) data[i + 2] << 8 | - (opus_uint32) data[i + 3]; - if (len > MAX_PACKET || len < 0 || i + SETUP_BYTE_COUNT + len > size) { - break; - } - - /* Bytes 4..7 represent encoder final range, but are unused here. - * Instead, byte 4 is repurposed to determine if FEC is used. */ - fec = data[i + 4] & 1; - - if (len == 0) { - /* Lost packet */ - int frame_size; - opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&frame_size)); - (void) opus_decode(dec, NULL, len, pcm, frame_size, fec); - } else { - temp_data = (uint8_t*) malloc(len); - memcpy(temp_data, &data[i + SETUP_BYTE_COUNT], len); - - (void) opus_decode(dec, temp_data, len, pcm, MAX_FRAME_SAMP, fec); - - free(temp_data); - } - - i += SETUP_BYTE_COUNT + len; - } - - opus_decoder_destroy(dec); - free(pcm); - - return 0; -} diff --git a/Engine/lib/opus/tests/opus_decode_fuzzer.options b/Engine/lib/opus/tests/opus_decode_fuzzer.options deleted file mode 100644 index e5ae71b93..000000000 --- a/Engine/lib/opus/tests/opus_decode_fuzzer.options +++ /dev/null @@ -1,2 +0,0 @@ -[libfuzzer] -max_len = 1000000 diff --git a/Engine/lib/opus/tests/opus_encode_regressions.c b/Engine/lib/opus/tests/opus_encode_regressions.c deleted file mode 100644 index 4d506eb60..000000000 --- a/Engine/lib/opus/tests/opus_encode_regressions.c +++ /dev/null @@ -1,1034 +0,0 @@ -/* Copyright (c) 2016 Mark Harris, 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 -#include -#include -#include -#include -#include -#include "opus_multistream.h" -#include "opus.h" -#include "test_opus_common.h" - - -static int celt_ec_internal_error(void) -{ - OpusMSEncoder *enc; - int err; - unsigned char data[2460]; - int streams; - int coupled_streams; - unsigned char mapping[1]; - - enc = opus_multistream_surround_encoder_create(16000, 1, 1, &streams, - &coupled_streams, mapping, OPUS_APPLICATION_VOIP, &err); - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(8)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(OPUS_AUTO)); - { - static const short pcm[320] = - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1792, 1799, 1799, - 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, - 1799, 1799, 1799, 1799, 1799, 0, 25600, 1799, 1799, - 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, - 1799, 1799, 1799, 1799, 7, 0, 255, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 32767, -1, - 0, 0, 0, 100, 0, 16384, 0, 0, 0, - 0, 0, 0, 4, 0, 0, -256, 255, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0,-32768, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 0, 0, 0, 0, - 0, 0, 0, 0, -256, 0, 0, 32, 0, - 0, 0, 0, 0, 0, 0, 4352, 4, 228, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5632, 0, 0, - 0, 0,-32768, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 256, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - -3944, 10500, 4285, 10459, -6474, 10204, -6539, 11601, -6824, - 13385, -7142, 13872,-11553, 13670, -7725, 13463, -6887, 7874, - -5580, 12600, -4964, 12480, 3254, 11741, -4210, 9741, -3155, - 7558, -5468, 5431, -1073, 3641, -1304, 0, -1, 343, - 26, 0, 0, 150, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1799, 1799, 1799, 1799, 1799, -2553, - 7, 1792, 1799, 1799, 1799, 1799, 1799, 1799, 1799, - 1799, 1799, 1799, 1799, -9721 - }; - err = opus_multistream_encode(enc, pcm, 320, data, 2460); - opus_test_assert(err > 0); - } - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(18)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(90)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(280130)); - { - static const short pcm[160] = - { - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9526, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, 25600, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510 - }; - err = opus_multistream_encode(enc, pcm, 160, data, 2460); - opus_test_assert(err > 0); - } - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(18)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(90)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(280130)); - { - static const short pcm[160] = - { - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9494, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510 - }; - err = opus_multistream_encode(enc, pcm, 160, data, 2460); - opus_test_assert(err > 0); - } - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(18)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(90)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(280130)); - { - static const short pcm[160] = - { - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9479, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, - -9510, -9510, -9510, -9510, -9510, -9510, -9510 - }; - err = opus_multistream_encode(enc, pcm, 160, data, 2460); - opus_test_assert(err > 0); - } - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(18)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(90)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(280130)); - { - static const short pcm[160] = - { - -9510, -9510, 1799, 1799, 1799, 1799, 1799, 1799, 1799, - 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - -256, 255, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 128, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 32, 0, 0, 0, 0, 0, 0, 0, - 4352, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 148, 0, 0, 0, 0, - 5632 - }; - err = opus_multistream_encode(enc, pcm, 160, data, 2460); - opus_test_assert(err > 0); - } - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(12)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(41)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(21425)); - { - static const short pcm[40] = - { - 10459, -6474, 10204, -6539, 11601, -6824, 13385, -7142, 13872, - -11553, 13670, -7725, 13463, -6887, 12482, -5580, 12600, -4964, - 12480, 3254, 11741, -4210, 9741, -3155, 7558, -5468, 5431, - -1073, 3641, -1304, 0, -1, 343, 26, 0, 0, - 0, 0, -256, 226 - }; - err = opus_multistream_encode(enc, pcm, 40, data, 2460); - opus_test_assert(err > 0); - /* returns -3 */ - } - opus_multistream_encoder_destroy(enc); - return 0; -} - -static int mscbr_encode_fail10(void) -{ - OpusMSEncoder *enc; - int err; - unsigned char data[627300]; - static const unsigned char mapping[255] = - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101, - 102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118, - 119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135, - 136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152, - 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169, - 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186, - 187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203, - 204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220, - 221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237, - 238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254 - }; - - enc = opus_multistream_encoder_create(8000, 255, 254, 1, mapping, - OPUS_APPLICATION_RESTRICTED_LOWDELAY, &err); - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(2)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(2)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(14)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(57)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(3642675)); - { - static const short pcm[20*255] = - { - 0 - }; - err = opus_multistream_encode(enc, pcm, 20, data, 627300); - opus_test_assert(err > 0); - /* returns -1 */ - } - opus_multistream_encoder_destroy(enc); - return 0; -} - -static int mscbr_encode_fail(void) -{ - OpusMSEncoder *enc; - int err; - unsigned char data[472320]; - static const unsigned char mapping[192] = - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101, - 102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118, - 119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135, - 136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152, - 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169, - 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186, - 187,188,189,190,191 - }; - - enc = opus_multistream_encoder_create(8000, 192, 189, 3, mapping, - OPUS_APPLICATION_RESTRICTED_LOWDELAY, &err); - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(OPUS_AUTO)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_MEDIUMBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(8)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(15360)); - { - static const short pcm[20*192] = - { - 0 - }; - err = opus_multistream_encode(enc, pcm, 20, data, 472320); - opus_test_assert(err > 0); - /* returns -1 */ - } - opus_multistream_encoder_destroy(enc); - return 0; -} - -static int surround_analysis_uninit(void) -{ - OpusMSEncoder *enc; - int err; - unsigned char data[7380]; - int streams; - int coupled_streams; - unsigned char mapping[3]; - - enc = opus_multistream_surround_encoder_create(24000, 3, 1, &streams, - &coupled_streams, mapping, OPUS_APPLICATION_AUDIO, &err); - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(OPUS_AUTO)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(8)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(84315)); - { - static const short pcm[960*3] = - { - -6896, 4901, -6158, 4120, -5164, 3631, -4442, 3153, -4070, - 3349, -4577, 4474, -5541, 5058, -6701, 3881, -7933, 1863, - -8041, 697, -6738,-31464, 14330,-12523, 4096, -6130, 29178, - -250,-21252, 10467, 16907, -3359, -6644, 31965, 14607,-21544, - -32497, 24020, 12557,-26926,-18421, -1842, 24587, 19659, 4878, - 10954, 23060, 8907,-10215,-16179, 31772,-11825,-15590,-23089, - 17173,-25903,-17387, 11733, 4884, 10204,-16476,-14367, 516, - 20453,-16898, 20967,-23813, -20, 22011,-17167, 9459, 32499, - -25855, -523, -3883, -390, -4206, 634, -3767, 2325, -2751, - 3115, -2392, 2746, -2173, 2317, -1147, 2326, 23142, 11314, - -15350,-24529, 3026, 6146, 2150, 2476, 1105, -830, 1775, - -3425, 3674,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - 4293,-14023, 3879,-15553, 3158,-16161, 2629, 18433,-12535, - -6645,-20735,-32763,-13824,-20992, 25859, 13052, -8731, 2292, - -3860, 24049, 10225,-19220, 10478,-22294, 22773, 28137, 13816, - 30953,-25863,-24598, 16888,-14612,-28942, 20974,-27397,-18944, - -18690, 20991,-16638, 5632,-14330, 28911,-25594, 17408, 29958, - -517,-20984, -1800, 11281, 9977,-21221,-14854, 23840, -9477, - 3362,-12805,-22493, 32507, 156, 16384, -1163, 2301, -1874, - 4600, -1748, 6950, 16557, 8192, -7372, -1033, -3278, 2806, - 20275, 3317, -717, 9792, -767, 9099, -613, 8362, 5027, - 7774, 2597, 8549, 5278, 8743, 9343, 6940, 13038, 4826, - 14086, 2964, 13215, 1355, 11596, 455, 9850, -519, 10680, - -2287, 12551, -3736, 13639, -4291, 13790, -2722, 14544, -866, - 15050, -304, 22833, -1196, 13520, -2063, 13051, -2317, 13066, - -2737, 13773, -2664, 14105, -3447, 13854, 24589, 24672, -5280, - 10388, -4933, 7543, -4149, 3654, -1552, 1726, 661, 57, - 2922, -751, 3917, 8419, 3840, -5218, 3435, 5540, -1073, - 4153, -6656, 1649, -769, -7276,-13072, 6380, -7948, 20717, - 18425, 17392, 14335,-18190, -1842, 24587, 19659, 11790, 10954, - 23060, 8907,-10215,-16179, 31772,-11825,-15590,-23101, 17173, - -25903,-17387, 11733, 4884, 10192,-16627,-14367, 516, 20453, - -16898, 20967,-23813, -20, 22011,-17167, 9468, 32499,-25607, - -523, -3883, -390, -4206, 634, -3767, 2325, -2751, 3115, - -2392, 2746, -2161, 2317, -1147, 2326, 23142, 11314,-15350, - -29137, 3026,-15056, -491,-15170, -386,-16015, -641,-16505, - -930,-16206, -717,-16175, -2839,-16374, -4558,-16237, -5207, - -15903, -6421, 6373, -1403, 5431, -1073, 3641, -1304, -4495, - -769, -7276, 2856, -7870, 3314, -8730, 3964,-10183, 4011, - -11135, 3421,-11727, 2966,-12360, 2818,-13472, 3660,-13805, - 5162,-13478, 6434,-12840, 7335,-12420, 6865,-12349, 5541, - -11965, 5530,-10820, 5132, -9197, 3367, -7745, 1223, -6910, - -433, -6211, -1711, -4958, -1025, -3755, -836, -3292, -1666, - -2661,-10755, 31472,-27906, 31471, 18690, 5617, 16649, 11253, - -22516,-17674,-31990, 3575,-31479, 5883, 26121, 12890, -6612, - 12228,-11634, 523, 26136,-21496, 20745,-15868, -4100,-24826, - 23282, 22798, 491, -1774, 15075,-27373,-13094, 6417,-29487, - 14608, 10185, 16143, 22211, -8436, 4288, -8694, 2375, 3023, - 486, 1455, 128, 202, 942, -923, 2068, -1233, -717, - -1042, -2167, 32255, -4632, 310, -4458, -3639, -5258, 2106, - -6857, 2681, -7497, 2765, -6601, 1945, -5219, 19154, -4877, - 619, -5719, -1928, -6208, -121, 593, 188, 1558, -4152, - 1648, 156, 1604, -3664, -6862, -2851, -5112, -3600, -3747, - -5081, -4428, -5592, 20974,-27397,-18944,-18690, 20991,-17406, - 5632,-14330, 28911, 15934, 15934, 15934, 15934, 15934, 15934, - 15934, 15934, 15934, 15934, 15934, 15934,-25594, 17408, 29958, - -7173,-16888, 9098, -613, 8362, 675, 7774, 2597, 8549, - 5278, 8743, 9375, 6940, 13038, 4826, 14598, 7721,-24308, - -29905,-19703,-17106,-16124, -3287,-26118,-19709,-10769, 24353, - 28648, 6946, -1363, 12485, -1187, 26074,-25055, 10004,-24798, - 7204, -4581, -9678, 1554, 10553, 3102, 12193, 2443, 11955, - 1213, 10689, -1293, 921, -4173, 10709, -6049, 8815, -7128, - 8147, -8308, 6847, -2977, 4920,-11447,-22426,-11794, 3514, - -10220, 3430, -7993, 1926, -7072, 327, -7569, -608, -7605, - 3695, -6271, -1579, -4877, -1419, -3103, -2197, 128, -3904, - 3760, -5401, 4906, -6051, 4250, -6272, 3492, -6343, 3197, - -6397, 4041, -6341, 6255, -6381, 7905, 16504, 0, -6144, - 8062, -5606, 8622, -5555, -9, -1, 7423, 0, 1, - 238, 5148, 1309, 4700, 2218, 4403, 2573, 3568, 28303, - 1758, 3454, -1247, 3434, -4912, 2862, -7844, 1718,-10095, - 369,-12631, 128, -3904, 3632, -5401, 4906, -6051, 4250, - -6272, 3492, -6343, 3197, -6397, 4041, -6341, 6255, -6381, - 7905, 16504, 0, -6144, 8062, -5606, 8622, -5555, 8439, - -3382, 7398, -1170, 6132, 238, 5148, 1309, 4700, 2218, - 4403, 2573, 3568, 2703, 1758, 3454, -1247, 3434, -4912, - 2862, -7844, 1718,-10095, 369,-12631, -259,-14632, 234, - -15056, -521,-15170, -386,-16015, -641,-16505, -930,-16206, - -1209,-16146, -2839,-16374, -4558,-16218, -5207,-15903, -6421, - -15615, -6925,-14871, -6149,-13759, -5233,-12844, 18313, -4357, - -5696, 2804, 12992,-22802, -6720, -9770, -7088, -8998, 14330, - -12523, 14843, -6130, 29178, -250,-27396, 10467, 16907, -3359, - -6644, 31965, 14607,-21544,-32497, 24020, 12557,-26926, -173, - -129, -6401, -130,-25089, -3841, -4916, -3048, 224, -237, - -3969, -189, -3529, -535, -3464,-14863,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14395,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907, 0, 32512,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907, 9925, -718, 9753, -767, - 9099, -613, 8362, 675, 7774, 2597, 8549, 5278, 8743, - 9375, 6940, 13038, 4826, 14598, 7721,-24308,-29905,-19703, - -17106,-16124, -3287,-26118,-19709, 0, 24353, 28648, 10274, - -11292,-29665,-16417, 24346, 14553, 18707, 26323, -4596,-17711, - 5133, 26328, 13,-31168, 24583, 18404,-28927,-24350, 19453, - 28642, 1019,-10777, -3079, 30188, -7686, 27635,-32521,-16384, - 12528, -6386, 10986, 23827,-25880,-32752,-23321, 14605, 32231, - 780,-13849, 15119, 28647, 4888, -7705, 30750, 64, 0, - 32488, 6687,-20758, 19745, -2070,-13792, -6414, 28188, -2821, - -4585, 7168, 7444, 23557,-21998, 13064, 3345, -4086,-28915, - -8694, 32262, 8461, 27387,-12275, 12012, 23563,-18719,-28410, - 29144,-22271, -562, -9986, -5434, 12288, 5573,-16642, 32448, - 29182, 32705,-30723, 24255,-19716, 18368, -4357, -5696, 2804, - 12992,-22802,-22080, -7701, -5183, 486, -3133, -5660, -1083, - 16871,-28726,-11029,-30259, -1209,-16146, -2839,-16374, -4558, - -16218,-10523, 20697, -9500, -1316, 5431, -1073, 3641, -1304, - 1649, -769, -7276, 2856, -7870, 3314, -8730, 3964,-10183, - 4011,-11135, 3421,-11727, 21398, 32767, -1, 32486, -1, - 6301,-13071, 6380, -7948, -1, 32767, 240, 14081, -5646, - 30973, -3598,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907, 32767,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907, 8901, 9375, 6940, 13038, 4826, 14598, 7721,-24308, - -29905,-19703,-17106,-16124, -3287,-26118,-19709,-10769, 24361, - 28648, 10274,-11292,-29665,-16417, 24346, 14580, 18707, 26323, - -4440,-17711, 5133, 26328,-14579,-31008, 24583, 18404, 28417, - -24350, 19453, 28642,-32513,-10777, -3079, 30188, -7686, 27635, - -32521,-16384,-20240, -6386, 10986, 23827,-25880,-32752,-23321, - 14605, 32231, 780,-13849, 15119, 28647, 4888, -7705,-15074, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907, 8192,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14897,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -15931,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907, 26121, 12890, 2604, - 12228,-11634, 12299, 5573,-16642, 32452, 29182, 32705,-30723, - 24255,-19716, 13248,-11779, -5696, 2804, 12992,-27666,-22080, - -7701, -5183, -6682,-31464, 14330,-12523, 14843, -6130, 29178, - -18,-27396, 10467, 16907, -3359, -6644, 31965, 14607,-21544, - -32497, 24020, 12557,-26926,-18421, 706, 24587, 19659, 4878, - 10954, 23060, 8907,-10215,-22579, 31772,-11825,-15590,-23089, - 17173,-25903,-17387, 3285, 4884, 10204,-16627,-14367, 516, - 20453,-16898, 20967,-23815, -20, 22011,-17167, 9468, 32499, - -25607, -523, -3883, -390, -4206, 634, -3767, 2325, -2751, - 3115, -2392, 2746, -2173, 2317, -1147, 2326, 23142, 11314, - -15130,-29137, 3026, 6146, 2150, 2476, 1105, -830, 1775, - -3425, 3674, -5287, 4609, -7175, 4922, -9579, 4556,-12007, - 4236,-14023, 3879,-15553, 3158,-16161, 2576, 18398,-12535, - -6645,-20735,-32763,-13824,-20992, 25859, 5372, 12040, 13307, - -4355,-30213, -9, -6019, 14061,-31487,-13842, 30449, 15083, - 14088, 31205,-18678,-12830, 14090,-26138,-25337,-11541, -3254, - 27628,-22270, 30953,-16136,-30745, 20991,-17406, 5632,-14330, - 28911,-25594, 17408,-20474, 13041, -8731, 2292, -3860, 24049, - 10225,-19220, 10478, -4374, -1199, 148, -330, -74, 593, - 188, 1558, -4152, 15984, 15934, 15934, 15934, 15934, 15934, - 15934, 15934, 15934, 15934, 15934, 15934, 1598, 156, 1604, - -1163, 2278,-30018,-25821,-21763,-23776, 24066, 9502, 25866, - -25055, 10004,-24798, 7204, -4581, -9678, 1554, 10553, 3102, - 12193, 2443, 11955, 1213, 10689, -1293, 921, -4173, 8661, - -6049, 8815,-21221,-14854, 23840, -9477, 8549, 5278, 8743, - 9375, 6940, 13038, 4826, 14598, 7721,-24308,-29905,-19703, - -17106,-16124, -3287,-26118,-19709,-10769, 24361, 28648, 10274, - -11292,-29665,-16417, 24346, 14580, 18707, 26323, -4410,-17711, - 5133, 26328,-14579,-31008, 24583, 18404, 28417,-24350, 19453, - 28642,-32513,-10777, -3079, 30188, -7686, 27635,-32521,-16384, - -20240, -6386, 10986, 23827,-25880,-32752,-23321, 14605, 32231, - 780,-13849, 15119, 28647, 4888, -7705, 30750, 64, 0, - 32488, 6687,-20758, 19745, -2070, -1, -1, 28, 256, - -4608, 7168, 7444, 23557,-21998, 13064, 3345, -4086,-28915, - -8594, 32262, 8461, 27387,-12275, 12012, 23563,-18719,-28410, - 29144,-22271,-32562,-16384, 12528, -6386, 10986, 23827,-25880, - -32752,-23321, 14605, 32231, 780,-13849, 15119, 28647, 4888, - -7705, 30750, 64, 0, 32488, 6687,-20758, 19745, -2070, - -13792, -6414, 28188, -2821, -4585, 7168, 7444, 23557,-21998, - 13064, 3345, -4086,-28915, -8694, 32262, 8461, 27387,-12275, - 12012, 23563,-18719,-28410, 29144,-22271, -562, -9986, -5434, - 12288, -2107,-16643, 32452, 29182, 32705,-30723, 24255,-19716, - 18368, -4357, -5696, 2804, 12992,-22802,-22080, -7701, -5183, - 486, -3133, -5660, -1083, 16871,-28726,-11029,-30259, -1209, - -16146, -2839,-16374, -4558,-16218,-10523, 20697, -9500, -1316, - 5431, -1073, 3641, -1304, 1649, -769, -7276, 2856, -7870, - 3314, -8730, 3964,-10183, 4011,-11135, 3421,-11727, 21398, - 32767, -1, 32486, -1, -99,-13072, 6380, -7948, 4864, - 32767, 17392, 14335, -5646, 30973, -3598,-10299,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14905,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-19771,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-16443,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-15931,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907, -1,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907, 7877, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, -994, -7276, 2856, -7870, - 3314, -8730, 3964,-10183, 4011,-11135, 3421,-11727, 21398, - 32767, -1, 32486, -1, -99,-13072, 6380, -7948, 4864, - 32767, 17392, 14335, -5646, 30973, -3598,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14905,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907, 197, 0,-14977,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907, 12838, 6653, 294, - -29699,-25821,-21763,-23776, 24066, 9502, 25866,-25055, 10004, - -24798, 7204, -4581, -9678, 1554, 10553, 3102, 12193, 2443, - 11955, 1213, 10689, -1293, 921, 179, 8448, -6049, 8815, - -7128, 8147, -8308, 6847, -9889, 4920,-11447, 3174,-11794, - 3514,-10220, 3430, 16384, 1926, -7072, 327, -7537, -608, - -7605, -1169, -6397, -1579, -4877, -1419, -3103, -2197, 128, - -3904, 3632, -5401, 4906, -6051, 4250, -6272, 3492, -6343, - 3197, -6397, 4041, -6341, 6255, -6381, 7905, 16504, 0, - -6144, 8062, -5606, 8622, -5555, 8439, -3382, 7398, -1170, - 6132, 238, 5148, 1309, 4700, 2218, 4403, 2573, 3568, - 2703, 1758, 3454, -1247, 3434, -4912, 2862, -7844, 1718, - -10095, 369,-12631, -259,-14632, 234,-15056, -491,-16194, - -386,-16015, -641,-16505, -930,-16206, -1209,-16146, -2839, - -16374, -4558,-16218, -5207,-15903, -6421,-15615, -6925,-14871, - -6149,-13759, -5233,-12844, 18313, -4357, -5696, 2804, 12992, - -22802, -6720, -9770, -7088, -8998, 14330,-12523, 14843, -6130, - 29178, -250,-27396, 10467, 16907, -3359, -6644, 31965, 14607, - -21544,-32497, 24020, 12557,-26926, -173, -129, -6401, -130, - -25089, -3816, -4916, -3048, -32, -1, -3969, 256, -3529, - -535, -3464,-14863,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -1209,-16146, -2839,-16374, -4558,-16218,-10523, 20697, -9500, - -1316, 5431, -1073, 3641, -1304, 1649, -769, -7276, 2856, - -7870, 3314, -8730, 3964,-10183, 4011,-11135, 3421,-11727, - 21398, 32767, -1, 32486, -1, 6301,-13071, 6380, -7948, - -1, 32767, 240, 14081, -5646, 30973, -3598,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - 32767,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907, 8901, 9375, 6940, - 13038, 4826, 14598, 7721,-24308,-29905,-19703,-17106,-16124, - -3287,-26118,-19709,-10769, 24361, 28648, 10274,-11292,-29665, - -16417, 24346, 14580, 18707, 26323, -4440,-17711, 5133, 26328, - -14579,-31008, 24583, 18404, 28417,-24350, 19453, 28642,-32513, - -10777, -3079, 30188, -7686, 27635,-32521,-16384,-20240, -6386, - 10986, 23827,-25880,-32752,-23321, 14605, 32231, 780,-13849, - 15119, 28647, 4888, -7705,-15074,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, 8192, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14897, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-15931,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907, 26121, 12890, 2604, 12228,-11634, 12299, 5573, - -16642, 32452, 29182, 32705,-30723, 24255,-19716, 13248,-11779, - -5696, 2804, 12992,-27666,-22080, -7701, -5183, -6682,-31464, - 14330,-12523, 14843, -6130, 29178, -18,-27396, 10467, 16907, - -3359, -6644, 31965, 14607,-21544,-32497, 24020, 12557,-26926, - -18421, 706, 24587, 19659, 4878, 10954, 23060, 8907,-10215, - -22579, 31772,-11825,-15590,-23089, 17173,-25903,-17387, 3285, - 4884, 10204,-16627,-14367, 516, 20453,-16898, 20967,-23815, - -20, 22011,-17167, 9468, 32499,-25607, -523, -3883, -390, - -4206, 634, -3767, 2325, -2751, 3115, -2392, 2746, -2173, - 2317, -1147, 2326, 23142, 11314,-15130,-29137, 3026, 6146, - 2150, 2476, 1105, -830, 1775, -3425, 3674, -5287, 4609, - -7175, 4922, -9579, 4556,-12007, 4236,-14023, 3879,-15553, - 3158,-16161, 2576, 18398,-12535, -6645,-20735,-32763,-13824, - -20992, 25859, 5372, 12040, 13307, -4355,-30213, -9, -6019 - }; - err = opus_multistream_encode(enc, pcm, 960, data, 7380); - opus_test_assert(err > 0); - } - opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(0)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(OPUS_AUTO)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(6)); - opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO)); - opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(9)); - opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1)); - opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(5)); - opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(775410)); - { - static const short pcm[1440*3] = - { - 30449, 15083, 14088, 31205,-18678,-12830, 14090,-26138,-25337, - -11541, -3254, 27628,-22270, 30953,-16136,-30745, 20991,-17406, - 5632,-14330, 28911,-25594, 17408,-20474, 13041, -8731, 2292, - -3860, 24049, 10225,-19220, 10478, -4374, -1199, 148, -330, - -74, 593, 188, 1558, -4152, 15984, 15934, 15934, 15934, - 15934, 15934, 15934, 15934, 15934, 15934, 15934, 15934, 1598, - 156, 1604, -1163, 2278,-30018,-25821,-21763,-23776, 24066, - 9502, 25866,-25055, 10004,-24798, 7204, -4581, -9678, 1554, - 10553, 3102, 12193, 2443, 11955, 1213, 10689, -1293, 921, - -4173, 8661, -6049, 8815,-21221,-14854, 23840, -9477, 8549, - 5278, 8743, 9375, 6940, 13038, 4826, 14598, 7721,-24308, - -29905,-19703,-17106,-16124, -3287,-26118,-19709,-10769, 24361, - 28648, 10274,-11292,-29665,-16417, 24346, 14580, 18707, 26323, - -4410,-17711, 5133, 26328,-14579,-31008, 24583, 18404, 28417, - -24350, 19453, 28642,-32513,-10777, -3079, 30188, -7686, 27635, - -32521,-16384,-20240, -6386, 10986, 23827,-25880,-32752,-23321, - 14605, 32231, 780,-13849, 15119, 28647, 4888, -7705, 30750, - 64, 0, 32488, 6687,-20758, 19745, -2070, -1, -1, - 28, 256, -4608, 7168, 7444, 23557,-21998, 13064, 3345, - -4086,-28915, -8594, 32262, 8461, 27387,-12275, 12012, 23563, - -18719,-28410, 29144,-22271,-32562,-16384, 12528, -6386, 10986, - 23827,-25880,-32752,-23321, 14605, 32231, 780,-13849, 15119, - 28647, 4888, -7705, 30750, 64, 0, 32488, 6687,-20758, - 19745, -2070,-13792, -6414, 28188, -2821, -4585, 7168, 7444, - 23557,-21998, 13064, 3345, -4086,-28915, -8694, 32262, 8461, - -14853,-14907,-14907,-14907,-14907, 32767,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14891,-14907,-14907,-14907, - -14907,-14907, 8901, 9375, 6940, 13038, 4826, 14598, 7721, - -24308,-29905,-19703,-17106,-16124, -3287,-26118,-19709,-10769, - 24361, 28648, 10274,-11292,-29665,-16417, 24346, 14580, 18707, - 26323, -4440,-17711, 5133, 26328,-14579,-31008, 24583, 18404, - 28417,-24350, 19453, 28642,-32513,-10777, -3079, 30188, -7686, - 27635,-32521,-16384,-20240, -6386, 10986, 23827,-25880,-32752, - -23321, 14605, 32231, 780,-13849, 15119, 28647, 4888, -7705, - -15074,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907, 8192,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14897,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-15931,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907, 26121, 12890, - 2604, 12228,-11634, 12299, 5573,-16642, 32452, 29182, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, - 7710,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-10811,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14917,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14938,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, - -14907,-14907,-14907,-14907, -571, -9986, -58, 12542,-18491, - 32507, 12838, 6653, 294, -1, 0,-19968, 18368, -4357, - -5696, 2804, 12998,-22802,-22080, -7701, -5183, 486, -3133, - -5660, -1083, 13799,-28726,-11029, 205,-14848, 32464, -1, - -129,-13072, 6380, -7948, 20717, 18425, 17392, 14335, -5646, - 30973, -3598, 7188, -3867, 3055, -4247, 5597, -4011,-26427, - -11,-30418, 7922, 2614, 237, -5839,-27413,-17624,-29716, - -13539, 239, 20991, 18164, -4082,-16647,-27386, 19458, 20224, - 4619, 19728, -7409,-18186,-25073, 27627,-23539, -7945,-31464, - 14330,-12523,-22021, -7701, -5183, 486, -3133, -5660, -1083, - 13799,-28726,-11029, 205,-14848, 32464, -1, -129,-13072, - 6380, -7948, 20717, 18425, 17392, 14093, -5646, 30973, -3598, - 7188, -3867, 3055, 3689, -5401, 4906, -6051, 4250, -6272, - 3492, -6343, 3197, -6397, 4041, -6341, 6255, -6381, 239, - 20991, 18164, -4082,-16647,-27386, 19458, 20224, 4619, 19728, - -7409,-18186,-25073, 27627,-23539, -7945,-31464, 14330,-12523, - 14843, -6130, 30202, -250,-28420, 10467, 16907, -3359, -6644, - 31965, 3343,-11727, 2966,-12616, 3064,-13472, 6732,-12349, - 5541,-11965, 5530,-10820, -1912, -3637, 32285, -4607, 310, - -32768, 0, -5258, 2106, -6857, 2681, -5449, -3606, -6717, - -5482, -3606, -1853, 4082, -7631, -9808, -1742, -2851, -5112, - 64, -868,-13546,-13365,-13365,-13365,-13365,-13365,-13365, - -13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365, - -13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365, - -13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365, - -13365,-13365,-13365,-13365,-13365,-13365,-13365, 7883, -2316, - 9086, -3944, 10500, 4285, 10459, -6474, 10204, -6539, 11601, - -6824, 13385, -7142, 13872, -7457, 13670, -7725, 13463, -6887, - 12482, -5580, 12600, -4964, 12480, 3254, 11741, -4210,-24819, - 23282, 22798, 491, -1774, -1073, 3641, -1304, 28928, -250, - -27396, 6657, -8961, 22524, 19987, 10231, 1791, 8947,-32763, - -26385,-31227, -792,-30461, 8926, 4866, 27863, 27756, 27756, - 27756, 27756, 27756, 27756, 27756, 27756, 5630,-11070,-16136, - 20671,-11530, 27328, 8179, 5059,-31503,-24379,-19472, 17863, - -29202, 22986, -23, 8909, 8422, 10450 - }; - err = opus_multistream_encode(enc, pcm, 1440, data, 7380); - /* reads uninitialized data at src/opus_multistream_encoder.c:293 */ - opus_test_assert(err > 0); - } - opus_multistream_encoder_destroy(enc); - return 0; -} - -static int ec_enc_shrink_assert(void) -{ - OpusEncoder *enc; - int err; - int data_len; - unsigned char data[2000]; - static const short pcm1[960] = { 5140 }; - static const short pcm2[2880] = - { - -256,-12033, 0, -2817, 6912, 0, -5359, 5200, 3061, - 0, -2903, 5652, -1281,-24656,-14433,-24678, 32,-29793, - 2870, 0, 4096, 5120, 5140, -234,-20230,-24673,-24633, - -24673,-24705, 0,-32768,-25444,-25444, 0,-25444,-25444, - 156,-20480, -7948, -5920, -7968, -7968, 224, 0, 20480, - 11, 20496, 13, 20496, 11,-20480, 2292,-20240, 244, - 20480, 11, 20496, 11,-20480, 244,-20240, 7156, 20456, - -246,-20243, 244, 128, 244, 20480, 11, 20496, 11, - -20480, 244,-20256, 244, 20480, 256, 0, -246, 16609, - -176, 0, 29872, -4096, -2888, 516, 2896, 4096, 2896, - -20480, -3852, -2896, -1025,-31056,-14433, 244, 1792, -256, - -12033, 0, -2817, 0, 0, -5359, 5200, 3061, 16, - -2903, 5652, -1281,-24656,-14433,-24678, 32,-29793, 2870, - 0, 4096, 5120, 5140, -234,-20230,-24673,-24633,-24673, - -24705, 0,-32768,-25444,-25444, 0,-25444,-25444, 156, - -20480, -7973, -5920, -7968, -7968, 224, 0, 20480, 11, - 20496, 11, 20496, 11,-20480, 2292,-20213, 244, 20480, - 11, 20496, 11,-24698, -2873, 0, 7, -1, 208, - -256, 244, 0, 4352, 20715, -2796, 11,-22272, 5364, - -234,-20230,-24673,-25913, 8351,-24832, 13963, 11, 0, - 16, 5140, 5652, -1281,-24656,-14433,-24673, 32671, 159, - 0,-25472,-25444, 156,-25600,-25444,-25444, 0, -2896, - -7968, -7960, -7968, -7968, 0, 0, 2896, 4096, 2896, - 4096, 2896, 0, -2896, -4088, -2896, 0, 2896, 0, - -2896, -4096, -2896, 11, 2640, -4609, -2896,-32768, -3072, - 0, 2896, 4096, 2896, 0, -2896, -4096, -2896, 0, - 80, 1, 2816, 0, 20656, 255,-20480, 116,-18192 - }; - static const short pcm3[2880] = { 0 }; - - enc = opus_encoder_create(48000, 1, OPUS_APPLICATION_AUDIO, &err); - opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10)); - opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(6)); - opus_encoder_ctl(enc, OPUS_SET_BITRATE(6000)); - data_len = opus_encode(enc, pcm1, 960, data, 2000); - opus_test_assert(data_len > 0); - - opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); - opus_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1)); - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_SUPERWIDEBAND)); - opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1)); - opus_encoder_ctl(enc, OPUS_SET_BITRATE(15600)); - data_len = opus_encode(enc, pcm2, 2880, data, 122); - opus_test_assert(data_len > 0); - - opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); - opus_encoder_ctl(enc, OPUS_SET_BITRATE(27000)); - data_len = opus_encode(enc, pcm3, 2880, data, 122); /* assertion failure */ - opus_test_assert(data_len > 0); - - opus_encoder_destroy(enc); - return 0; -} - -static int ec_enc_shrink_assert2(void) -{ - OpusEncoder *enc; - int err; - int data_len; - unsigned char data[2000]; - - enc = opus_encoder_create(48000, 1, OPUS_APPLICATION_AUDIO, &err); - opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(6)); - opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); - opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); - opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(26)); - opus_encoder_ctl(enc, OPUS_SET_BITRATE(27000)); - { - static const short pcm[960] = { 0 }; - data_len = opus_encode(enc, pcm, 960, data, 2000); - opus_test_assert(data_len > 0); - } - opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); - { - static const short pcm[480] = - { - 32767, 32767, 0, 0, 32767, 32767, 0, 0, 32767, 32767, - -32768, -32768, 0, 0, -32768, -32768, 0, 0, -32768, -32768 - }; - data_len = opus_encode(enc, pcm, 480, data, 19); - opus_test_assert(data_len > 0); - } - opus_encoder_destroy(enc); - return 0; -} - -static int silk_gain_assert(void) -{ - OpusEncoder *enc; - int err; - int data_len; - unsigned char data[1000]; - static const short pcm1[160] = { 0 }; - static const short pcm2[960] = - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 32767, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 32767 - }; - - enc = opus_encoder_create(8000, 1, OPUS_APPLICATION_AUDIO, &err); - opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(3)); - opus_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND)); - opus_encoder_ctl(enc, OPUS_SET_BITRATE(6000)); - data_len = opus_encode(enc, pcm1, 160, data, 1000); - opus_test_assert(data_len > 0); - - opus_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0)); - opus_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_MEDIUMBAND)); - opus_encoder_ctl(enc, OPUS_SET_BITRATE(2867)); - data_len = opus_encode(enc, pcm2, 960, data, 1000); - opus_test_assert(data_len > 0); - - opus_encoder_destroy(enc); - return 0; -} - -void regression_test(void) -{ - fprintf(stderr, "Running simple tests for bugs that have been fixed previously\n"); - celt_ec_internal_error(); - mscbr_encode_fail10(); - mscbr_encode_fail(); - surround_analysis_uninit(); - ec_enc_shrink_assert(); - ec_enc_shrink_assert2(); - silk_gain_assert(); -} diff --git a/Engine/lib/opus/tests/random_config.sh b/Engine/lib/opus/tests/random_config.sh deleted file mode 100644 index 0cdd855f3..000000000 --- a/Engine/lib/opus/tests/random_config.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash - -dir="$1" -mkdir "$dir" -if [ $? -ne 0 ] -then - exit 1 -fi - -cd "$dir" -if [ $? -ne 0 ] -then - exit 1 -fi - - -configure_path="$2" -config="random_config.txt" - -case `seq 3 | shuf -n1` in -1) -approx=--enable-float-approx -math=-ffast-math -;; -2) -approx=--enable-float-approx -;; -*) -approx= -math= -;; -esac - -CFLAGS='-g' - -opt=`echo -e "-O1\n-O2\n-O3" | shuf -n1` - -#arch=-march=`echo -e "core2\nsandybridge\nbroadwell\nskylake" | shuf -n1` -arch=`echo -e "\n-march=core2\n-march=sandybridge\n-march=broadwell\n-march=skylake\n-march=native" | shuf -n1` - -footprint=`echo -e "\n-DSMALL_FOOTPRINT" | shuf -n1` -std=`echo -e "\n-std=c90\n-std=c99\n-std=c11\n-std=c17" | shuf -n1` -sanitize=`echo -e "\n-fsanitize=address -fno-sanitize-recover=all\n-fsanitize=undefined -fno-sanitize-recover=all -fsanitize-recover=signed-integer-overflow" | shuf -n1` - - -CFLAGS="$CFLAGS $std $opt $arch $footprint $math $sanitize" - -echo "CFLAGS=$CFLAGS" > "$config" - -lib=`echo -e "\n--disable-static\n--disable-shared" | shuf -n1` - -arithmetic=`echo -e "\n--enable-fixed-point\n--enable-fixed-point --enable-fixed-point-debug\n--enable-fixed-point --disable-float-api\n--enable-fixed-point --enable-fixed-point-debug --disable-float-api" | shuf -n1` - -custom=`echo -e "\n--enable-custom-modes" | shuf -n1` - -asm=`echo -e "\n--disable-asm\n--disable-rtcd\n--disable-intrinsics" | shuf -n1` -#asm=`echo -e "\n--disable-asm\n--disable-intrinsics" | shuf -n1` - -assert=`echo -e "\n--enable-assertions" | shuf -n1` -harden=`echo -e "\n--enable-hardening" | shuf -n1` -fuzz=`echo -e "\n--enable-fuzzing" | shuf -n1` -checkasm=`echo -e "\n--enable-check-asm" | shuf -n1` -rfc8251=`echo -e "\n--disable-rfc8251" | shuf -n1` - -if [ "$rfc8251" = --disable-rfc8251 ] -then - vectors="$3" -else - vectors="$4" -fi -echo using testvectors at "$vectors" >> "$config" - - -config_opt="$lib $arithmetic $custom $asm $assert $harden $fuzz $checkasm $rfc8251 $approx" - -echo configure $config_opt >> "$config" - -export CFLAGS -"$configure_path/configure" $config_opt > configure_output.txt 2>&1 - -if [ $? -ne 0 ] -then - echo configure FAIL >> "$config" - exit 1 -fi - -make > make_output.txt 2>&1 - -if [ $? -ne 0 ] -then - echo make FAIL >> "$config" - exit 1 -fi - -#Run valgrind 5% of the time (minus the asan cases) -if [ "`seq 20 | shuf -n1`" -ne 1 -o "$sanitize" = "-fsanitize=address -fno-sanitize-recover=all" ] -then - make check > makecheck_output.txt 2>&1 -else - echo valgrind enabled >> "$config" - valgrind --trace-children=yes --error-exitcode=128 make check > makecheck_output.txt 2>&1 -fi - -if [ $? -ne 0 ] -then - echo check FAIL >> "$config" - exit 1 -fi - - -rate=`echo -e "8000\n12000\n16000\n24000\n48000" | shuf -n1` -echo testvectors for "$rate" Hz > testvectors_output.txt -../../../run_vectors.sh . "$vectors" "$rate" >> testvectors_output.txt 2>&1 - -if [ $? -ne 0 ] -then - echo testvectors FAIL >> "$config" - exit 1 -fi - -echo all tests PASS >> "$config" - -#When everything's good, do some cleaning up to save space -make distclean > /dev/null 2>&1 -rm -f tmp.out -gzip make_output.txt diff --git a/Engine/lib/opus/tests/run_vectors.sh b/Engine/lib/opus/tests/run_vectors.sh deleted file mode 100644 index dcb76cf18..000000000 --- a/Engine/lib/opus/tests/run_vectors.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2011-2012 Jean-Marc Valin -# -# This file is extracted from RFC6716. Please see that RFC for additional -# information. -# -# 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. - -rm -f logs_mono.txt logs_mono2.txt -rm -f logs_stereo.txt logs_stereo2.txt - -if [ "$#" -ne "3" ]; then - echo "usage: run_vectors.sh " - exit 1 -fi - -CMD_PATH=$1 -VECTOR_PATH=$2 -RATE=$3 - -: ${OPUS_DEMO:=$CMD_PATH/opus_demo} -: ${OPUS_COMPARE:=$CMD_PATH/opus_compare} - -if [ -d "$VECTOR_PATH" ]; then - echo "Test vectors found in $VECTOR_PATH" -else - echo "No test vectors found" - #Don't make the test fail here because the test vectors - #will be distributed separately - exit 0 -fi - -if [ ! -x "$OPUS_COMPARE" ]; then - echo "ERROR: Compare program not found: $OPUS_COMPARE" - exit 1 -fi - -if [ -x "$OPUS_DEMO" ]; then - echo "Decoding with $OPUS_DEMO" -else - echo "ERROR: Decoder not found: $OPUS_DEMO" - exit 1 -fi - -echo "==============" -echo "Testing mono" -echo "==============" -echo - -for file in 01 02 03 04 05 06 07 08 09 10 11 12 -do - if [ -e "$VECTOR_PATH/testvector$file.bit" ]; then - echo "Testing testvector$file" - else - echo "Bitstream file not found: testvector$file.bit" - fi - if "$OPUS_DEMO" -d "$RATE" 1 "$VECTOR_PATH/testvector$file.bit" tmp.out >> logs_mono.txt 2>&1; then - echo "successfully decoded" - else - echo "ERROR: decoding failed" - exit 1 - fi - "$OPUS_COMPARE" -r "$RATE" "$VECTOR_PATH/testvector${file}.dec" tmp.out >> logs_mono.txt 2>&1 - float_ret=$? - "$OPUS_COMPARE" -r "$RATE" "$VECTOR_PATH/testvector${file}m.dec" tmp.out >> logs_mono2.txt 2>&1 - float_ret2=$? - if [ "$float_ret" -eq "0" ] || [ "$float_ret2" -eq "0" ]; then - echo "output matches reference" - else - echo "ERROR: output does not match reference" - exit 1 - fi - echo -done - -echo "==============" -echo Testing stereo -echo "==============" -echo - -for file in 01 02 03 04 05 06 07 08 09 10 11 12 -do - if [ -e "$VECTOR_PATH/testvector$file.bit" ]; then - echo "Testing testvector$file" - else - echo "Bitstream file not found: testvector$file" - fi - if "$OPUS_DEMO" -d "$RATE" 2 "$VECTOR_PATH/testvector$file.bit" tmp.out >> logs_stereo.txt 2>&1; then - echo "successfully decoded" - else - echo "ERROR: decoding failed" - exit 1 - fi - "$OPUS_COMPARE" -s -r "$RATE" "$VECTOR_PATH/testvector${file}.dec" tmp.out >> logs_stereo.txt 2>&1 - float_ret=$? - "$OPUS_COMPARE" -s -r "$RATE" "$VECTOR_PATH/testvector${file}m.dec" tmp.out >> logs_stereo2.txt 2>&1 - float_ret2=$? - if [ "$float_ret" -eq "0" ] || [ "$float_ret2" -eq "0" ]; then - echo "output matches reference" - else - echo "ERROR: output does not match reference" - exit 1 - fi - echo -done - - - -echo "All tests have passed successfully" -mono1=`grep quality logs_mono.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` -mono2=`grep quality logs_mono2.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` -echo $mono1 $mono2 | awk '{if ($2 > $1) $1 = $2; print "Average mono quality is", $1, "%"}' - -stereo1=`grep quality logs_stereo.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` -stereo2=`grep quality logs_stereo2.txt | awk '{sum+=$4}END{if (NR == 12) sum /= 12; else sum = 0; print sum}'` -echo $stereo1 $stereo2 | awk '{if ($2 > $1) $1 = $2; print "Average stereo quality is", $1, "%"}' diff --git a/Engine/lib/opus/tests/test_opus_api.c b/Engine/lib/opus/tests/test_opus_api.c deleted file mode 100644 index 0e7ed2cc9..000000000 --- a/Engine/lib/opus/tests/test_opus_api.c +++ /dev/null @@ -1,1904 +0,0 @@ -/* Copyright (c) 2011-2013 Xiph.Org Foundation - Written by 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. -*/ - -/* This tests the API presented by the libopus system. - It does not attempt to extensively exercise the codec internals. - The strategy here is to simply the API interface invariants: - That sane options are accepted, insane options are rejected, - and that nothing blows up. In particular we don't actually test - that settings are heeded by the codec (though we do check that - get after set returns a sane value when it should). Other - tests check the actual codec behavior. - In cases where its reasonable to do so we test exhaustively, - but its not reasonable to do so in all cases. - Although these tests are simple they found several library bugs - when they were initially developed. */ - -/* These tests are more sensitive if compiled with -DVALGRIND and - run inside valgrind. Malloc failure testing requires glibc. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include "arch.h" -#include "opus_multistream.h" -#include "opus.h" -#include "test_opus_common.h" - -#ifdef VALGRIND -#include -#define VG_UNDEF(x,y) VALGRIND_MAKE_MEM_UNDEFINED((x),(y)) -#define VG_CHECK(x,y) VALGRIND_CHECK_MEM_IS_DEFINED((x),(y)) -#else -#define VG_UNDEF(x,y) -#define VG_CHECK(x,y) -#endif - -#if defined(HAVE___MALLOC_HOOK) -#define MALLOC_FAIL -#include "os_support.h" -#include - -static const opus_int32 opus_apps[3] = {OPUS_APPLICATION_VOIP, - OPUS_APPLICATION_AUDIO,OPUS_APPLICATION_RESTRICTED_LOWDELAY}; - -void *malloc_hook(__attribute__((unused)) size_t size, - __attribute__((unused)) const void *caller) -{ - return 0; -} -#endif - -opus_int32 *null_int_ptr = (opus_int32 *)NULL; -opus_uint32 *null_uint_ptr = (opus_uint32 *)NULL; - -static const opus_int32 opus_rates[5] = {48000,24000,16000,12000,8000}; - -opus_int32 test_dec_api(void) -{ - opus_uint32 dec_final_range; - OpusDecoder *dec; - OpusDecoder *dec2; - opus_int32 i,j,cfgs; - unsigned char packet[1276]; -#ifndef DISABLE_FLOAT_API - float fbuf[960*2]; -#endif - short sbuf[960*2]; - int c,err; - - cfgs=0; - /*First test invalid configurations which should fail*/ - fprintf(stdout,"\n Decoder basic API tests\n"); - fprintf(stdout," ---------------------------------------------------\n"); - for(c=0;c<4;c++) - { - i=opus_decoder_get_size(c); - if(((c==1||c==2)&&(i<=2048||i>1<<16))||((c!=1&&c!=2)&&i!=0))test_failed(); - fprintf(stdout," opus_decoder_get_size(%d)=%d ...............%s OK.\n",c,i,i>0?"":"...."); - cfgs++; - } - - /*Test with unsupported sample rates*/ - for(c=0;c<4;c++) - { - for(i=-7;i<=96000;i++) - { - int fs; - if((i==8000||i==12000||i==16000||i==24000||i==48000)&&(c==1||c==2))continue; - switch(i) - { - case(-5):fs=-8000;break; - case(-6):fs=INT32_MAX;break; - case(-7):fs=INT32_MIN;break; - default:fs=i; - } - err = OPUS_OK; - VG_UNDEF(&err,sizeof(err)); - dec = opus_decoder_create(fs, c, &err); - if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed(); - cfgs++; - dec = opus_decoder_create(fs, c, 0); - if(dec!=NULL)test_failed(); - cfgs++; - dec=malloc(opus_decoder_get_size(2)); - if(dec==NULL)test_failed(); - err = opus_decoder_init(dec,fs,c); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - free(dec); - } - } - - VG_UNDEF(&err,sizeof(err)); - dec = opus_decoder_create(48000, 2, &err); - if(err!=OPUS_OK || dec==NULL)test_failed(); - VG_CHECK(dec,opus_decoder_get_size(2)); - cfgs++; - - fprintf(stdout," opus_decoder_create() ........................ OK.\n"); - fprintf(stdout," opus_decoder_init() .......................... OK.\n"); - - err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(null_uint_ptr)); - if(err != OPUS_BAD_ARG)test_failed(); - VG_UNDEF(&dec_final_range,sizeof(dec_final_range)); - err=opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range)); - if(err!=OPUS_OK)test_failed(); - VG_CHECK(&dec_final_range,sizeof(dec_final_range)); - fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n"); - cfgs++; - - err=opus_decoder_ctl(dec,OPUS_UNIMPLEMENTED); - if(err!=OPUS_UNIMPLEMENTED)test_failed(); - fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n"); - cfgs++; - - err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH(null_int_ptr)); - if(err != OPUS_BAD_ARG)test_failed(); - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i)); - if(err != OPUS_OK || i!=0)test_failed(); - fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n"); - cfgs++; - - err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE(null_int_ptr)); - if(err != OPUS_BAD_ARG)test_failed(); - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(dec, OPUS_GET_SAMPLE_RATE(&i)); - if(err != OPUS_OK || i!=48000)test_failed(); - fprintf(stdout," OPUS_GET_SAMPLE_RATE ......................... OK.\n"); - cfgs++; - - /*GET_PITCH has different execution paths depending on the previously decoded frame.*/ - err=opus_decoder_ctl(dec, OPUS_GET_PITCH(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i)); - if(err != OPUS_OK || i>0 || i<-1)test_failed(); - cfgs++; - VG_UNDEF(packet,sizeof(packet)); - packet[0]=63<<2;packet[1]=packet[2]=0; - if(opus_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed(); - cfgs++; - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i)); - if(err != OPUS_OK || i>0 || i<-1)test_failed(); - cfgs++; - packet[0]=1; - if(opus_decode(dec, packet, 1, sbuf, 960, 0)!=960)test_failed(); - cfgs++; - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(dec, OPUS_GET_PITCH(&i)); - if(err != OPUS_OK || i>0 || i<-1)test_failed(); - cfgs++; - fprintf(stdout," OPUS_GET_PITCH ............................... OK.\n"); - - err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(null_int_ptr)); - if(err != OPUS_BAD_ARG)test_failed(); - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&i)); - if(err != OPUS_OK || i!=960)test_failed(); - cfgs++; - fprintf(stdout," OPUS_GET_LAST_PACKET_DURATION ................ OK.\n"); - - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(dec, OPUS_GET_GAIN(&i)); - VG_CHECK(&i,sizeof(i)); - if(err != OPUS_OK || i!=0)test_failed(); - cfgs++; - err=opus_decoder_ctl(dec, OPUS_GET_GAIN(null_int_ptr)); - if(err != OPUS_BAD_ARG)test_failed(); - cfgs++; - err=opus_decoder_ctl(dec, OPUS_SET_GAIN(-32769)); - if(err != OPUS_BAD_ARG)test_failed(); - cfgs++; - err=opus_decoder_ctl(dec, OPUS_SET_GAIN(32768)); - if(err != OPUS_BAD_ARG)test_failed(); - cfgs++; - err=opus_decoder_ctl(dec, OPUS_SET_GAIN(-15)); - if(err != OPUS_OK)test_failed(); - cfgs++; - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(dec, OPUS_GET_GAIN(&i)); - VG_CHECK(&i,sizeof(i)); - if(err != OPUS_OK || i!=-15)test_failed(); - cfgs++; - fprintf(stdout," OPUS_SET_GAIN ................................ OK.\n"); - fprintf(stdout," OPUS_GET_GAIN ................................ OK.\n"); - - /*Reset the decoder*/ - dec2=malloc(opus_decoder_get_size(2)); - memcpy(dec2,dec,opus_decoder_get_size(2)); - if(opus_decoder_ctl(dec, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); - if(memcmp(dec2,dec,opus_decoder_get_size(2))==0)test_failed(); - free(dec2); - fprintf(stdout," OPUS_RESET_STATE ............................. OK.\n"); - cfgs++; - - VG_UNDEF(packet,sizeof(packet)); - packet[0]=0; - if(opus_decoder_get_nb_samples(dec,packet,1)!=480)test_failed(); - if(opus_packet_get_nb_samples(packet,1,48000)!=480)test_failed(); - if(opus_packet_get_nb_samples(packet,1,96000)!=960)test_failed(); - if(opus_packet_get_nb_samples(packet,1,32000)!=320)test_failed(); - if(opus_packet_get_nb_samples(packet,1,8000)!=80)test_failed(); - packet[0]=3; - if(opus_packet_get_nb_samples(packet,1,24000)!=OPUS_INVALID_PACKET)test_failed(); - packet[0]=(63<<2)|3; - packet[1]=63; - if(opus_packet_get_nb_samples(packet,0,24000)!=OPUS_BAD_ARG)test_failed(); - if(opus_packet_get_nb_samples(packet,2,48000)!=OPUS_INVALID_PACKET)test_failed(); - if(opus_decoder_get_nb_samples(dec,packet,2)!=OPUS_INVALID_PACKET)test_failed(); - fprintf(stdout," opus_{packet,decoder}_get_nb_samples() ....... OK.\n"); - cfgs+=9; - - if(OPUS_BAD_ARG!=opus_packet_get_nb_frames(packet,0))test_failed(); - for(i=0;i<256;i++) { - int l1res[4]={1,2,2,OPUS_INVALID_PACKET}; - packet[0]=i; - if(l1res[packet[0]&3]!=opus_packet_get_nb_frames(packet,1))test_failed(); - cfgs++; - for(j=0;j<256;j++) { - packet[1]=j; - if(((packet[0]&3)!=3?l1res[packet[0]&3]:packet[1]&63)!=opus_packet_get_nb_frames(packet,2))test_failed(); - cfgs++; - } - } - fprintf(stdout," opus_packet_get_nb_frames() .................. OK.\n"); - - for(i=0;i<256;i++) { - int bw; - packet[0]=i; - bw=packet[0]>>4; - bw=OPUS_BANDWIDTH_NARROWBAND+(((((bw&7)*9)&(63-(bw&8)))+2+12*((bw&8)!=0))>>4); - if(bw!=opus_packet_get_bandwidth(packet))test_failed(); - cfgs++; - } - fprintf(stdout," opus_packet_get_bandwidth() .................. OK.\n"); - - for(i=0;i<256;i++) { - int fp3s,rate; - packet[0]=i; - fp3s=packet[0]>>3; - fp3s=((((3-(fp3s&3))*13&119)+9)>>2)*((fp3s>13)*(3-((fp3s&3)==3))+1)*25; - for(rate=0;rate<5;rate++) { - if((opus_rates[rate]*3/fp3s)!=opus_packet_get_samples_per_frame(packet,opus_rates[rate]))test_failed(); - cfgs++; - } - } - fprintf(stdout," opus_packet_get_samples_per_frame() .......... OK.\n"); - - packet[0]=(63<<2)+3; - packet[1]=49; - for(j=2;j<51;j++)packet[j]=0; - VG_UNDEF(sbuf,sizeof(sbuf)); - if(opus_decode(dec, packet, 51, sbuf, 960, 0)!=OPUS_INVALID_PACKET)test_failed(); - cfgs++; - packet[0]=(63<<2); - packet[1]=packet[2]=0; - if(opus_decode(dec, packet, -1, sbuf, 960, 0)!=OPUS_BAD_ARG)test_failed(); - cfgs++; - if(opus_decode(dec, packet, 3, sbuf, 60, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - if(opus_decode(dec, packet, 3, sbuf, 480, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - if(opus_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed(); - cfgs++; - fprintf(stdout," opus_decode() ................................ OK.\n"); -#ifndef DISABLE_FLOAT_API - VG_UNDEF(fbuf,sizeof(fbuf)); - if(opus_decode_float(dec, packet, 3, fbuf, 960, 0)!=960)test_failed(); - cfgs++; - fprintf(stdout," opus_decode_float() .......................... OK.\n"); -#endif - -#if 0 - /*These tests are disabled because the library crashes with null states*/ - if(opus_decoder_ctl(0,OPUS_RESET_STATE) !=OPUS_INVALID_STATE)test_failed(); - if(opus_decoder_init(0,48000,1) !=OPUS_INVALID_STATE)test_failed(); - if(opus_decode(0,packet,1,outbuf,2880,0) !=OPUS_INVALID_STATE)test_failed(); - if(opus_decode_float(0,packet,1,0,2880,0) !=OPUS_INVALID_STATE)test_failed(); - if(opus_decoder_get_nb_samples(0,packet,1) !=OPUS_INVALID_STATE)test_failed(); - if(opus_packet_get_nb_frames(NULL,1) !=OPUS_BAD_ARG)test_failed(); - if(opus_packet_get_bandwidth(NULL) !=OPUS_BAD_ARG)test_failed(); - if(opus_packet_get_samples_per_frame(NULL,48000)!=OPUS_BAD_ARG)test_failed(); -#endif - opus_decoder_destroy(dec); - cfgs++; - fprintf(stdout," All decoder interface tests passed\n"); - fprintf(stdout," (%6d API invocations)\n",cfgs); - return cfgs; -} - -opus_int32 test_msdec_api(void) -{ - opus_uint32 dec_final_range; - OpusMSDecoder *dec; - OpusDecoder *streamdec; - opus_int32 i,j,cfgs; - unsigned char packet[1276]; - unsigned char mapping[256]; -#ifndef DISABLE_FLOAT_API - float fbuf[960*2]; -#endif - short sbuf[960*2]; - int a,b,c,err; - - mapping[0]=0; - mapping[1]=1; - for(i=2;i<256;i++)VG_UNDEF(&mapping[i],sizeof(unsigned char)); - - cfgs=0; - /*First test invalid configurations which should fail*/ - fprintf(stdout,"\n Multistream decoder basic API tests\n"); - fprintf(stdout," ---------------------------------------------------\n"); - for(a=-1;a<4;a++) - { - for(b=-1;b<4;b++) - { - i=opus_multistream_decoder_get_size(a,b); - if(((a>0&&b<=a&&b>=0)&&(i<=2048||i>((1<<16)*a)))||((a<1||b>a||b<0)&&i!=0))test_failed(); - fprintf(stdout," opus_multistream_decoder_get_size(%2d,%2d)=%d %sOK.\n",a,b,i,i>0?"":"... "); - cfgs++; - } - } - - /*Test with unsupported sample rates*/ - for(c=1;c<3;c++) - { - for(i=-7;i<=96000;i++) - { - int fs; - if((i==8000||i==12000||i==16000||i==24000||i==48000)&&(c==1||c==2))continue; - switch(i) - { - case(-5):fs=-8000;break; - case(-6):fs=INT32_MAX;break; - case(-7):fs=INT32_MIN;break; - default:fs=i; - } - err = OPUS_OK; - VG_UNDEF(&err,sizeof(err)); - dec = opus_multistream_decoder_create(fs, c, 1, c-1, mapping, &err); - if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed(); - cfgs++; - dec = opus_multistream_decoder_create(fs, c, 1, c-1, mapping, 0); - if(dec!=NULL)test_failed(); - cfgs++; - dec=malloc(opus_multistream_decoder_get_size(1,1)); - if(dec==NULL)test_failed(); - err = opus_multistream_decoder_init(dec,fs,c,1,c-1, mapping); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - free(dec); - } - } - - for(c=0;c<2;c++) - { - int *ret_err; - ret_err = c?0:&err; - - mapping[0]=0; - mapping[1]=1; - for(i=2;i<256;i++)VG_UNDEF(&mapping[i],sizeof(unsigned char)); - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, 2, 1, 0, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - mapping[0]=mapping[1]=0; - dec = opus_multistream_decoder_create(48000, 2, 1, 0, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_OK) || dec==NULL)test_failed(); - cfgs++; - opus_multistream_decoder_destroy(dec); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, 1, 4, 1, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_OK) || dec==NULL)test_failed(); - cfgs++; - - err = opus_multistream_decoder_init(dec,48000, 1, 0, 0, mapping); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - - err = opus_multistream_decoder_init(dec,48000, 1, 1, -1, mapping); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - - opus_multistream_decoder_destroy(dec); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, 2, 1, 1, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_OK) || dec==NULL)test_failed(); - cfgs++; - opus_multistream_decoder_destroy(dec); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, 255, 255, 1, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, -1, 1, 1, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, 0, 1, 1, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, 1, -1, 2, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, 1, -1, -1, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, 256, 255, 1, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - dec = opus_multistream_decoder_create(48000, 256, 255, 0, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - mapping[0]=255; - mapping[1]=1; - mapping[2]=2; - dec = opus_multistream_decoder_create(48000, 3, 2, 0, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - mapping[0]=0; - mapping[1]=0; - mapping[2]=0; - dec = opus_multistream_decoder_create(48000, 3, 2, 1, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_OK) || dec==NULL)test_failed(); - cfgs++; - opus_multistream_decoder_destroy(dec); - cfgs++; - - VG_UNDEF(ret_err,sizeof(*ret_err)); - mapping[0]=0; - mapping[1]=255; - mapping[2]=1; - mapping[3]=2; - mapping[4]=3; - dec = opus_multistream_decoder_create(48001, 5, 4, 1, mapping, ret_err); - if(ret_err){VG_CHECK(ret_err,sizeof(*ret_err));} - if((ret_err && *ret_err!=OPUS_BAD_ARG) || dec!=NULL)test_failed(); - cfgs++; - } - - VG_UNDEF(&err,sizeof(err)); - mapping[0]=0; - mapping[1]=255; - mapping[2]=1; - mapping[3]=2; - dec = opus_multistream_decoder_create(48000, 4, 2, 1, mapping, &err); - VG_CHECK(&err,sizeof(err)); - if(err!=OPUS_OK || dec==NULL)test_failed(); - cfgs++; - - fprintf(stdout," opus_multistream_decoder_create() ............ OK.\n"); - fprintf(stdout," opus_multistream_decoder_init() .............. OK.\n"); - - VG_UNDEF(&dec_final_range,sizeof(dec_final_range)); - err=opus_multistream_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range)); - if(err!=OPUS_OK)test_failed(); - VG_CHECK(&dec_final_range,sizeof(dec_final_range)); - fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n"); - cfgs++; - - streamdec=0; - VG_UNDEF(&streamdec,sizeof(streamdec)); - err=opus_multistream_decoder_ctl(dec, OPUS_MULTISTREAM_GET_DECODER_STATE(-1,&streamdec)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - err=opus_multistream_decoder_ctl(dec, OPUS_MULTISTREAM_GET_DECODER_STATE(1,&streamdec)); - if(err!=OPUS_OK||streamdec==NULL)test_failed(); - VG_CHECK(streamdec,opus_decoder_get_size(1)); - cfgs++; - err=opus_multistream_decoder_ctl(dec, OPUS_MULTISTREAM_GET_DECODER_STATE(2,&streamdec)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - err=opus_multistream_decoder_ctl(dec, OPUS_MULTISTREAM_GET_DECODER_STATE(0,&streamdec)); - if(err!=OPUS_OK||streamdec==NULL)test_failed(); - VG_CHECK(streamdec,opus_decoder_get_size(1)); - fprintf(stdout," OPUS_MULTISTREAM_GET_DECODER_STATE ........... OK.\n"); - cfgs++; - - for(j=0;j<2;j++) - { - OpusDecoder *od; - err=opus_multistream_decoder_ctl(dec,OPUS_MULTISTREAM_GET_DECODER_STATE(j,&od)); - if(err != OPUS_OK)test_failed(); - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(od, OPUS_GET_GAIN(&i)); - VG_CHECK(&i,sizeof(i)); - if(err != OPUS_OK || i!=0)test_failed(); - cfgs++; - } - err=opus_multistream_decoder_ctl(dec,OPUS_SET_GAIN(15)); - if(err!=OPUS_OK)test_failed(); - fprintf(stdout," OPUS_SET_GAIN ................................ OK.\n"); - for(j=0;j<2;j++) - { - OpusDecoder *od; - err=opus_multistream_decoder_ctl(dec,OPUS_MULTISTREAM_GET_DECODER_STATE(j,&od)); - if(err != OPUS_OK)test_failed(); - VG_UNDEF(&i,sizeof(i)); - err=opus_decoder_ctl(od, OPUS_GET_GAIN(&i)); - VG_CHECK(&i,sizeof(i)); - if(err != OPUS_OK || i!=15)test_failed(); - cfgs++; - } - fprintf(stdout," OPUS_GET_GAIN ................................ OK.\n"); - - VG_UNDEF(&i,sizeof(i)); - err=opus_multistream_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i)); - if(err != OPUS_OK || i!=0)test_failed(); - fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n"); - cfgs++; - - err=opus_multistream_decoder_ctl(dec,OPUS_UNIMPLEMENTED); - if(err!=OPUS_UNIMPLEMENTED)test_failed(); - fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n"); - cfgs++; - -#if 0 - /*Currently unimplemented for multistream*/ - /*GET_PITCH has different execution paths depending on the previously decoded frame.*/ - err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - VG_UNDEF(&i,sizeof(i)); - err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(&i)); - if(err != OPUS_OK || i>0 || i<-1)test_failed(); - cfgs++; - VG_UNDEF(packet,sizeof(packet)); - packet[0]=63<<2;packet[1]=packet[2]=0; - if(opus_multistream_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed(); - cfgs++; - VG_UNDEF(&i,sizeof(i)); - err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(&i)); - if(err != OPUS_OK || i>0 || i<-1)test_failed(); - cfgs++; - packet[0]=1; - if(opus_multistream_decode(dec, packet, 1, sbuf, 960, 0)!=960)test_failed(); - cfgs++; - VG_UNDEF(&i,sizeof(i)); - err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(&i)); - if(err != OPUS_OK || i>0 || i<-1)test_failed(); - cfgs++; - fprintf(stdout," OPUS_GET_PITCH ............................... OK.\n"); -#endif - - /*Reset the decoder*/ - if(opus_multistream_decoder_ctl(dec, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); - fprintf(stdout," OPUS_RESET_STATE ............................. OK.\n"); - cfgs++; - - opus_multistream_decoder_destroy(dec); - cfgs++; - VG_UNDEF(&err,sizeof(err)); - dec = opus_multistream_decoder_create(48000, 2, 1, 1, mapping, &err); - if(err!=OPUS_OK || dec==NULL)test_failed(); - cfgs++; - - packet[0]=(63<<2)+3; - packet[1]=49; - for(j=2;j<51;j++)packet[j]=0; - VG_UNDEF(sbuf,sizeof(sbuf)); - if(opus_multistream_decode(dec, packet, 51, sbuf, 960, 0)!=OPUS_INVALID_PACKET)test_failed(); - cfgs++; - packet[0]=(63<<2); - packet[1]=packet[2]=0; - if(opus_multistream_decode(dec, packet, -1, sbuf, 960, 0)!=OPUS_BAD_ARG){printf("%d\n",opus_multistream_decode(dec, packet, -1, sbuf, 960, 0));test_failed();} - cfgs++; - if(opus_multistream_decode(dec, packet, 3, sbuf, -960, 0)!=OPUS_BAD_ARG)test_failed(); - cfgs++; - if(opus_multistream_decode(dec, packet, 3, sbuf, 60, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - if(opus_multistream_decode(dec, packet, 3, sbuf, 480, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - if(opus_multistream_decode(dec, packet, 3, sbuf, 960, 0)!=960)test_failed(); - cfgs++; - fprintf(stdout," opus_multistream_decode() .................... OK.\n"); -#ifndef DISABLE_FLOAT_API - VG_UNDEF(fbuf,sizeof(fbuf)); - if(opus_multistream_decode_float(dec, packet, 3, fbuf, 960, 0)!=960)test_failed(); - cfgs++; - fprintf(stdout," opus_multistream_decode_float() .............. OK.\n"); -#endif - -#if 0 - /*These tests are disabled because the library crashes with null states*/ - if(opus_multistream_decoder_ctl(0,OPUS_RESET_STATE) !=OPUS_INVALID_STATE)test_failed(); - if(opus_multistream_decoder_init(0,48000,1) !=OPUS_INVALID_STATE)test_failed(); - if(opus_multistream_decode(0,packet,1,outbuf,2880,0) !=OPUS_INVALID_STATE)test_failed(); - if(opus_multistream_decode_float(0,packet,1,0,2880,0) !=OPUS_INVALID_STATE)test_failed(); - if(opus_multistream_decoder_get_nb_samples(0,packet,1) !=OPUS_INVALID_STATE)test_failed(); -#endif - opus_multistream_decoder_destroy(dec); - cfgs++; - fprintf(stdout," All multistream decoder interface tests passed\n"); - fprintf(stdout," (%6d API invocations)\n",cfgs); - return cfgs; -} - -#ifdef VALGRIND -#define UNDEFINE_FOR_PARSE toc=-1; \ - frames[0]=(unsigned char *)0; \ - frames[1]=(unsigned char *)0; \ - payload_offset=-1; \ - VG_UNDEF(&toc,sizeof(toc)); \ - VG_UNDEF(frames,sizeof(frames));\ - VG_UNDEF(&payload_offset,sizeof(payload_offset)); -#else -#define UNDEFINE_FOR_PARSE toc=-1; \ - frames[0]=(unsigned char *)0; \ - frames[1]=(unsigned char *)0; \ - payload_offset=-1; -#endif - -/* This test exercises the heck out of the libopus parser. - It is much larger than the parser itself in part because - it tries to hit a lot of corner cases that could never - fail with the libopus code, but might be problematic for - other implementations. */ -opus_int32 test_parse(void) -{ - opus_int32 i,j,jj,sz; - unsigned char packet[1276]; - opus_int32 cfgs,cfgs_total; - unsigned char toc; - const unsigned char *frames[48]; - short size[48]; - int payload_offset, ret; - fprintf(stdout,"\n Packet header parsing tests\n"); - fprintf(stdout," ---------------------------------------------------\n"); - memset(packet,0,sizeof(char)*1276); - packet[0]=63<<2; - if(opus_packet_parse(packet,1,&toc,frames,0,&payload_offset)!=OPUS_BAD_ARG)test_failed(); - cfgs_total=cfgs=1; - /*code 0*/ - for(i=0;i<64;i++) - { - packet[0]=i<<2; - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,4,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=1)test_failed(); - if(size[0]!=3)test_failed(); - if(frames[0]!=packet+1)test_failed(); - } - fprintf(stdout," code 0 (%2d cases) ............................ OK.\n",cfgs); - cfgs_total+=cfgs;cfgs=0; - - /*code 1, two frames of the same size*/ - for(i=0;i<64;i++) - { - packet[0]=(i<<2)+1; - for(jj=0;jj<=1275*2+3;jj++) - { - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,jj,&toc,frames,size,&payload_offset); - cfgs++; - if((jj&1)==1 && jj<=2551) - { - /* Must pass if payload length even (packet length odd) and - size<=2551, must fail otherwise. */ - if(ret!=2)test_failed(); - if(size[0]!=size[1] || size[0]!=((jj-1)>>1))test_failed(); - if(frames[0]!=packet+1)test_failed(); - if(frames[1]!=frames[0]+size[0])test_failed(); - if((toc>>2)!=i)test_failed(); - } else if(ret!=OPUS_INVALID_PACKET)test_failed(); - } - } - fprintf(stdout," code 1 (%6d cases) ........................ OK.\n",cfgs); - cfgs_total+=cfgs;cfgs=0; - - for(i=0;i<64;i++) - { - /*code 2, length code overflow*/ - packet[0]=(i<<2)+2; - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,1,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - packet[1]=252; - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,2,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - for(j=0;j<1275;j++) - { - if(j<252)packet[1]=j; - else{packet[1]=252+(j&3);packet[2]=(j-252)>>2;} - /*Code 2, one too short*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,j+(j<252?2:3)-1,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - /*Code 2, one too long*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,j+(j<252?2:3)+1276,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - /*Code 2, second zero*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,j+(j<252?2:3),&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=2)test_failed(); - if(size[0]!=j||size[1]!=0)test_failed(); - if(frames[1]!=frames[0]+size[0])test_failed(); - if((toc>>2)!=i)test_failed(); - /*Code 2, normal*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,(j<<1)+4,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=2)test_failed(); - if(size[0]!=j||size[1]!=(j<<1)+3-j-(j<252?1:2))test_failed(); - if(frames[1]!=frames[0]+size[0])test_failed(); - if((toc>>2)!=i)test_failed(); - } - } - fprintf(stdout," code 2 (%6d cases) ........................ OK.\n",cfgs); - cfgs_total+=cfgs;cfgs=0; - - for(i=0;i<64;i++) - { - packet[0]=(i<<2)+3; - /*code 3, length code overflow*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,1,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - } - fprintf(stdout," code 3 m-truncation (%2d cases) ............... OK.\n",cfgs); - cfgs_total+=cfgs;cfgs=0; - - for(i=0;i<64;i++) - { - /*code 3, m is zero or 49-63*/ - packet[0]=(i<<2)+3; - for(jj=49;jj<=64;jj++) - { - packet[1]=0+(jj&63); /*CBR, no padding*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,1275,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - packet[1]=128+(jj&63); /*VBR, no padding*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,1275,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - packet[1]=64+(jj&63); /*CBR, padding*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,1275,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - packet[1]=128+64+(jj&63); /*VBR, padding*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,1275,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - } - } - fprintf(stdout," code 3 m=0,49-64 (%2d cases) ................ OK.\n",cfgs); - cfgs_total+=cfgs;cfgs=0; - - for(i=0;i<64;i++) - { - packet[0]=(i<<2)+3; - /*code 3, m is one, cbr*/ - packet[1]=1; - for(j=0;j<1276;j++) - { - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,j+2,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=1)test_failed(); - if(size[0]!=j)test_failed(); - if((toc>>2)!=i)test_failed(); - } - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,1276+2,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - } - fprintf(stdout," code 3 m=1 CBR (%2d cases) ................. OK.\n",cfgs); - cfgs_total+=cfgs;cfgs=0; - - for(i=0;i<64;i++) - { - int frame_samp; - /*code 3, m>1 CBR*/ - packet[0]=(i<<2)+3; - frame_samp=opus_packet_get_samples_per_frame(packet,48000); - for(j=2;j<49;j++) - { - packet[1]=j; - for(sz=2;sz<((j+2)*1275);sz++) - { - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,sz,&toc,frames,size,&payload_offset); - cfgs++; - /*Must be <=120ms, must be evenly divisible, can't have frames>1275 bytes*/ - if(frame_samp*j<=5760 && (sz-2)%j==0 && (sz-2)/j<1276) - { - if(ret!=j)test_failed(); - for(jj=1;jj>2)!=i)test_failed(); - } else if(ret!=OPUS_INVALID_PACKET)test_failed(); - } - } - /*Super jumbo packets*/ - packet[1]=5760/frame_samp; - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,1275*packet[1]+2,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=packet[1])test_failed(); - for(jj=0;jj>2)!=i)test_failed(); - } - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,2+1276,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - for(j=2;j<49;j++) - { - packet[1]=128+j; - /*Length code overflow*/ - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,2+j-2,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - packet[2]=252; - packet[3]=0; - for(jj=4;jj<2+j;jj++)packet[jj]=0; - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,2+j,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - /*One byte too short*/ - for(jj=2;jj<2+j;jj++)packet[jj]=0; - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,2+j-2,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - /*One byte too short thanks to length coding*/ - packet[2]=252; - packet[3]=0; - for(jj=4;jj<2+j;jj++)packet[jj]=0; - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,2+j+252-1,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - /*Most expensive way of coding zeros*/ - for(jj=2;jj<2+j;jj++)packet[jj]=0; - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,2+j-1,&toc,frames,size,&payload_offset); - cfgs++; - if(frame_samp*j<=5760){ - if(ret!=j)test_failed(); - for(jj=0;jj>2)!=i)test_failed(); - } else if(ret!=OPUS_INVALID_PACKET)test_failed(); - /*Quasi-CBR use of mode 3*/ - for(sz=0;sz<8;sz++) - { - const int tsz[8]={50,201,403,700,1472,5110,20400,61298}; - int pos=0; - int as=(tsz[sz]+i-j-2)/j; - for(jj=0;jj>2;pos+=2;} - } - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,tsz[sz]+i,&toc,frames,size,&payload_offset); - cfgs++; - if(frame_samp*j<=5760 && as<1276 && (tsz[sz]+i-2-pos-as*(j-1))<1276){ - if(ret!=j)test_failed(); - for(jj=0;jj>2)!=i)test_failed(); - } else if(ret!=OPUS_INVALID_PACKET)test_failed(); - } - } - } - fprintf(stdout," code 3 m=1-48 VBR (%2d cases) ............. OK.\n",cfgs); - cfgs_total+=cfgs;cfgs=0; - - for(i=0;i<64;i++) - { - packet[0]=(i<<2)+3; - /*Padding*/ - packet[1]=128+1+64; - /*Overflow the length coding*/ - for(jj=2;jj<127;jj++)packet[jj]=255; - UNDEFINE_FOR_PARSE - ret=opus_packet_parse(packet,127,&toc,frames,size,&payload_offset); - cfgs++; - if(ret!=OPUS_INVALID_PACKET)test_failed(); - - for(sz=0;sz<4;sz++) - { - const int tsz[4]={0,72,512,1275}; - for(jj=sz;jj<65025;jj+=11) - { - int pos; - for(pos=0;pos>2)!=i)test_failed(); - } else if (ret!=OPUS_INVALID_PACKET)test_failed(); - } - } - } - fprintf(stdout," code 3 padding (%2d cases) ............... OK.\n",cfgs); - cfgs_total+=cfgs; - fprintf(stdout," opus_packet_parse ............................ OK.\n"); - fprintf(stdout," All packet parsing tests passed\n"); - fprintf(stdout," (%d API invocations)\n",cfgs_total); - return cfgs_total; -} - -/* This is a helper macro for the encoder tests. - The encoder api tests all have a pattern of set-must-fail, set-must-fail, - set-must-pass, get-and-compare, set-must-pass, get-and-compare. */ -#define CHECK_SETGET(setcall,getcall,badv,badv2,goodv,goodv2,sok,gok) \ - i=(badv);\ - if(opus_encoder_ctl(enc,setcall)==OPUS_OK)test_failed();\ - i=(badv2);\ - if(opus_encoder_ctl(enc,setcall)==OPUS_OK)test_failed();\ - j=i=(goodv);\ - if(opus_encoder_ctl(enc,setcall)!=OPUS_OK)test_failed();\ - i=-12345;\ - VG_UNDEF(&i,sizeof(i)); \ - err=opus_encoder_ctl(enc,getcall);\ - if(err!=OPUS_OK || i!=j)test_failed();\ - j=i=(goodv2);\ - if(opus_encoder_ctl(enc,setcall)!=OPUS_OK)test_failed();\ - fprintf(stdout,sok);\ - i=-12345;\ - VG_UNDEF(&i,sizeof(i)); \ - err=opus_encoder_ctl(enc,getcall);\ - if(err!=OPUS_OK || i!=j)test_failed();\ - fprintf(stdout,gok);\ - cfgs+=6; - -opus_int32 test_enc_api(void) -{ - opus_uint32 enc_final_range; - OpusEncoder *enc; - opus_int32 i,j; - unsigned char packet[1276]; -#ifndef DISABLE_FLOAT_API - float fbuf[960*2]; -#endif - short sbuf[960*2]; - int c,err,cfgs; - - cfgs=0; - /*First test invalid configurations which should fail*/ - fprintf(stdout,"\n Encoder basic API tests\n"); - fprintf(stdout," ---------------------------------------------------\n"); - for(c=0;c<4;c++) - { - i=opus_encoder_get_size(c); - if(((c==1||c==2)&&(i<=2048||i>1<<17))||((c!=1&&c!=2)&&i!=0))test_failed(); - fprintf(stdout," opus_encoder_get_size(%d)=%d ...............%s OK.\n",c,i,i>0?"":"...."); - cfgs++; - } - - /*Test with unsupported sample rates, channel counts*/ - for(c=0;c<4;c++) - { - for(i=-7;i<=96000;i++) - { - int fs; - if((i==8000||i==12000||i==16000||i==24000||i==48000)&&(c==1||c==2))continue; - switch(i) - { - case(-5):fs=-8000;break; - case(-6):fs=INT32_MAX;break; - case(-7):fs=INT32_MIN;break; - default:fs=i; - } - err = OPUS_OK; - VG_UNDEF(&err,sizeof(err)); - enc = opus_encoder_create(fs, c, OPUS_APPLICATION_VOIP, &err); - if(err!=OPUS_BAD_ARG || enc!=NULL)test_failed(); - cfgs++; - enc = opus_encoder_create(fs, c, OPUS_APPLICATION_VOIP, 0); - if(enc!=NULL)test_failed(); - cfgs++; - opus_encoder_destroy(enc); - enc=malloc(opus_encoder_get_size(2)); - if(enc==NULL)test_failed(); - err = opus_encoder_init(enc, fs, c, OPUS_APPLICATION_VOIP); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - free(enc); - } - } - - enc = opus_encoder_create(48000, 2, OPUS_AUTO, NULL); - if(enc!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(&err,sizeof(err)); - enc = opus_encoder_create(48000, 2, OPUS_AUTO, &err); - if(err!=OPUS_BAD_ARG || enc!=NULL)test_failed(); - cfgs++; - - VG_UNDEF(&err,sizeof(err)); - enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_VOIP, NULL); - if(enc==NULL)test_failed(); - opus_encoder_destroy(enc); - cfgs++; - - VG_UNDEF(&err,sizeof(err)); - enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_RESTRICTED_LOWDELAY, &err); - if(err!=OPUS_OK || enc==NULL)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); - if(err!=OPUS_OK || i<0 || i>32766)test_failed(); - cfgs++; - opus_encoder_destroy(enc); - - VG_UNDEF(&err,sizeof(err)); - enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_AUDIO, &err); - if(err!=OPUS_OK || enc==NULL)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); - if(err!=OPUS_OK || i<0 || i>32766)test_failed(); - opus_encoder_destroy(enc); - cfgs++; - - VG_UNDEF(&err,sizeof(err)); - enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_VOIP, &err); - if(err!=OPUS_OK || enc==NULL)test_failed(); - cfgs++; - - fprintf(stdout," opus_encoder_create() ........................ OK.\n"); - fprintf(stdout," opus_encoder_init() .......................... OK.\n"); - - i=-12345; - VG_UNDEF(&i,sizeof(i)); - err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i)); - if(err!=OPUS_OK || i<0 || i>32766)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - fprintf(stdout," OPUS_GET_LOOKAHEAD ........................... OK.\n"); - - err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE(&i)); - if(err!=OPUS_OK || i!=48000)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - fprintf(stdout," OPUS_GET_SAMPLE_RATE ......................... OK.\n"); - - if(opus_encoder_ctl(enc,OPUS_UNIMPLEMENTED)!=OPUS_UNIMPLEMENTED)test_failed(); - fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n"); - cfgs++; - - err=opus_encoder_ctl(enc,OPUS_GET_APPLICATION(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_APPLICATION(i),OPUS_GET_APPLICATION(&i),-1,OPUS_AUTO, - OPUS_APPLICATION_AUDIO,OPUS_APPLICATION_RESTRICTED_LOWDELAY, - " OPUS_SET_APPLICATION ......................... OK.\n", - " OPUS_GET_APPLICATION ......................... OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_BITRATE(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - if(opus_encoder_ctl(enc,OPUS_SET_BITRATE(1073741832))!=OPUS_OK)test_failed(); - cfgs++; - VG_UNDEF(&i,sizeof(i)); - if(opus_encoder_ctl(enc,OPUS_GET_BITRATE(&i))!=OPUS_OK)test_failed(); - if(i>700000||i<256000)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_BITRATE(i),OPUS_GET_BITRATE(&i),-12345,0, - 500,256000, - " OPUS_SET_BITRATE ............................. OK.\n", - " OPUS_GET_BITRATE ............................. OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_FORCE_CHANNELS(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_FORCE_CHANNELS(i),OPUS_GET_FORCE_CHANNELS(&i),-1,3, - 1,OPUS_AUTO, - " OPUS_SET_FORCE_CHANNELS ...................... OK.\n", - " OPUS_GET_FORCE_CHANNELS ...................... OK.\n") - - i=-2; - if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))==OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_FULLBAND+1; - if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))==OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_NARROWBAND; - if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))!=OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_FULLBAND; - if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))!=OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_WIDEBAND; - if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))!=OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_MEDIUMBAND; - if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(i))!=OPUS_OK)test_failed(); - cfgs++; - fprintf(stdout," OPUS_SET_BANDWIDTH ........................... OK.\n"); - /*We don't test if the bandwidth has actually changed. - because the change may be delayed until the encoder is advanced.*/ - i=-12345; - VG_UNDEF(&i,sizeof(i)); - err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH(&i)); - if(err!=OPUS_OK || (i!=OPUS_BANDWIDTH_NARROWBAND&& - i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&& - i!=OPUS_BANDWIDTH_FULLBAND&&i!=OPUS_AUTO))test_failed(); - cfgs++; - if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(OPUS_AUTO))!=OPUS_OK)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n"); - - i=-2; - if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))==OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_FULLBAND+1; - if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))==OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_NARROWBAND; - if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_FULLBAND; - if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_WIDEBAND; - if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed(); - cfgs++; - i=OPUS_BANDWIDTH_MEDIUMBAND; - if(opus_encoder_ctl(enc,OPUS_SET_MAX_BANDWIDTH(i))!=OPUS_OK)test_failed(); - cfgs++; - fprintf(stdout," OPUS_SET_MAX_BANDWIDTH ....................... OK.\n"); - /*We don't test if the bandwidth has actually changed. - because the change may be delayed until the encoder is advanced.*/ - i=-12345; - VG_UNDEF(&i,sizeof(i)); - err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH(&i)); - if(err!=OPUS_OK || (i!=OPUS_BANDWIDTH_NARROWBAND&& - i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&& - i!=OPUS_BANDWIDTH_FULLBAND))test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - fprintf(stdout," OPUS_GET_MAX_BANDWIDTH ....................... OK.\n"); - - err=opus_encoder_ctl(enc,OPUS_GET_DTX(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_DTX(i),OPUS_GET_DTX(&i),-1,2, - 1,0, - " OPUS_SET_DTX ................................. OK.\n", - " OPUS_GET_DTX ................................. OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_COMPLEXITY(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_COMPLEXITY(i),OPUS_GET_COMPLEXITY(&i),-1,11, - 0,10, - " OPUS_SET_COMPLEXITY .......................... OK.\n", - " OPUS_GET_COMPLEXITY .......................... OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_INBAND_FEC(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_INBAND_FEC(i),OPUS_GET_INBAND_FEC(&i),-1,3, - 1,0, - " OPUS_SET_INBAND_FEC .......................... OK.\n", - " OPUS_GET_INBAND_FEC .......................... OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_PACKET_LOSS_PERC(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_PACKET_LOSS_PERC(i),OPUS_GET_PACKET_LOSS_PERC(&i),-1,101, - 100,0, - " OPUS_SET_PACKET_LOSS_PERC .................... OK.\n", - " OPUS_GET_PACKET_LOSS_PERC .................... OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_VBR(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_VBR(i),OPUS_GET_VBR(&i),-1,2, - 1,0, - " OPUS_SET_VBR ................................. OK.\n", - " OPUS_GET_VBR ................................. OK.\n") - -/* err=opus_encoder_ctl(enc,OPUS_GET_VOICE_RATIO(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_VOICE_RATIO(i),OPUS_GET_VOICE_RATIO(&i),-2,101, - 0,50, - " OPUS_SET_VOICE_RATIO ......................... OK.\n", - " OPUS_GET_VOICE_RATIO ......................... OK.\n")*/ - - err=opus_encoder_ctl(enc,OPUS_GET_VBR_CONSTRAINT(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_VBR_CONSTRAINT(i),OPUS_GET_VBR_CONSTRAINT(&i),-1,2, - 1,0, - " OPUS_SET_VBR_CONSTRAINT ...................... OK.\n", - " OPUS_GET_VBR_CONSTRAINT ...................... OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_SIGNAL(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_SIGNAL(i),OPUS_GET_SIGNAL(&i),-12345,0x7FFFFFFF, - OPUS_SIGNAL_MUSIC,OPUS_AUTO, - " OPUS_SET_SIGNAL .............................. OK.\n", - " OPUS_GET_SIGNAL .............................. OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_LSB_DEPTH(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_LSB_DEPTH(i),OPUS_GET_LSB_DEPTH(&i),7,25,16,24, - " OPUS_SET_LSB_DEPTH ........................... OK.\n", - " OPUS_GET_LSB_DEPTH ........................... OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_PREDICTION_DISABLED(&i)); - if(i!=0)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_GET_PREDICTION_DISABLED(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_PREDICTION_DISABLED(i),OPUS_GET_PREDICTION_DISABLED(&i),-1,2,1,0, - " OPUS_SET_PREDICTION_DISABLED ................. OK.\n", - " OPUS_GET_PREDICTION_DISABLED ................. OK.\n") - - err=opus_encoder_ctl(enc,OPUS_GET_EXPERT_FRAME_DURATION(null_int_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_2_5_MS)); - if(err!=OPUS_OK)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_5_MS)); - if(err!=OPUS_OK)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_10_MS)); - if(err!=OPUS_OK)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_20_MS)); - if(err!=OPUS_OK)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_40_MS)); - if(err!=OPUS_OK)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_60_MS)); - if(err!=OPUS_OK)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_80_MS)); - if(err!=OPUS_OK)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_100_MS)); - if(err!=OPUS_OK)test_failed(); - cfgs++; - err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_120_MS)); - if(err!=OPUS_OK)test_failed(); - cfgs++; - CHECK_SETGET(OPUS_SET_EXPERT_FRAME_DURATION(i),OPUS_GET_EXPERT_FRAME_DURATION(&i),0,-1, - OPUS_FRAMESIZE_60_MS,OPUS_FRAMESIZE_ARG, - " OPUS_SET_EXPERT_FRAME_DURATION ............... OK.\n", - " OPUS_GET_EXPERT_FRAME_DURATION ............... OK.\n") - - /*OPUS_SET_FORCE_MODE is not tested here because it's not a public API, however the encoder tests use it*/ - - err=opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE(null_uint_ptr)); - if(err!=OPUS_BAD_ARG)test_failed(); - cfgs++; - if(opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test_failed(); - cfgs++; - fprintf(stdout," OPUS_GET_FINAL_RANGE ......................... OK.\n"); - - /*Reset the encoder*/ - if(opus_encoder_ctl(enc, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); - cfgs++; - fprintf(stdout," OPUS_RESET_STATE ............................. OK.\n"); - - memset(sbuf,0,sizeof(short)*2*960); - VG_UNDEF(packet,sizeof(packet)); - i=opus_encode(enc, sbuf, 960, packet, sizeof(packet)); - if(i<1 || (i>(opus_int32)sizeof(packet)))test_failed(); - VG_CHECK(packet,i); - cfgs++; - fprintf(stdout," opus_encode() ................................ OK.\n"); -#ifndef DISABLE_FLOAT_API - memset(fbuf,0,sizeof(float)*2*960); - VG_UNDEF(packet,sizeof(packet)); - i=opus_encode_float(enc, fbuf, 960, packet, sizeof(packet)); - if(i<1 || (i>(opus_int32)sizeof(packet)))test_failed(); - VG_CHECK(packet,i); - cfgs++; - fprintf(stdout," opus_encode_float() .......................... OK.\n"); -#endif - -#if 0 - /*These tests are disabled because the library crashes with null states*/ - if(opus_encoder_ctl(0,OPUS_RESET_STATE) !=OPUS_INVALID_STATE)test_failed(); - if(opus_encoder_init(0,48000,1,OPUS_APPLICATION_VOIP) !=OPUS_INVALID_STATE)test_failed(); - if(opus_encode(0,sbuf,960,packet,sizeof(packet)) !=OPUS_INVALID_STATE)test_failed(); - if(opus_encode_float(0,fbuf,960,packet,sizeof(packet))!=OPUS_INVALID_STATE)test_failed(); -#endif - opus_encoder_destroy(enc); - cfgs++; - fprintf(stdout," All encoder interface tests passed\n"); - fprintf(stdout," (%d API invocations)\n",cfgs); - return cfgs; -} - -#define max_out (1276*48+48*2+2) -int test_repacketizer_api(void) -{ - int ret,cfgs,i,j,k; - OpusRepacketizer *rp; - unsigned char *packet; - unsigned char *po; - cfgs=0; - fprintf(stdout,"\n Repacketizer tests\n"); - fprintf(stdout," ---------------------------------------------------\n"); - - packet=malloc(max_out); - if(packet==NULL)test_failed(); - memset(packet,0,max_out); - po=malloc(max_out+256); - if(po==NULL)test_failed(); - - i=opus_repacketizer_get_size(); - if(i<=0)test_failed(); - cfgs++; - fprintf(stdout," opus_repacketizer_get_size()=%d ............. OK.\n",i); - - rp=malloc(i); - rp=opus_repacketizer_init(rp); - if(rp==NULL)test_failed(); - cfgs++; - free(rp); - fprintf(stdout," opus_repacketizer_init ....................... OK.\n"); - - rp=opus_repacketizer_create(); - if(rp==NULL)test_failed(); - cfgs++; - fprintf(stdout," opus_repacketizer_create ..................... OK.\n"); - - if(opus_repacketizer_get_nb_frames(rp)!=0)test_failed(); - cfgs++; - fprintf(stdout," opus_repacketizer_get_nb_frames .............. OK.\n"); - - /*Length overflows*/ - VG_UNDEF(packet,4); - if(opus_repacketizer_cat(rp,packet,0)!=OPUS_INVALID_PACKET)test_failed(); /* Zero len */ - cfgs++; - packet[0]=1; - if(opus_repacketizer_cat(rp,packet,2)!=OPUS_INVALID_PACKET)test_failed(); /* Odd payload code 1 */ - cfgs++; - packet[0]=2; - if(opus_repacketizer_cat(rp,packet,1)!=OPUS_INVALID_PACKET)test_failed(); /* Code 2 overflow one */ - cfgs++; - packet[0]=3; - if(opus_repacketizer_cat(rp,packet,1)!=OPUS_INVALID_PACKET)test_failed(); /* Code 3 no count */ - cfgs++; - packet[0]=2; - packet[1]=255; - if(opus_repacketizer_cat(rp,packet,2)!=OPUS_INVALID_PACKET)test_failed(); /* Code 2 overflow two */ - cfgs++; - packet[0]=2; - packet[1]=250; - if(opus_repacketizer_cat(rp,packet,251)!=OPUS_INVALID_PACKET)test_failed(); /* Code 2 overflow three */ - cfgs++; - packet[0]=3; - packet[1]=0; - if(opus_repacketizer_cat(rp,packet,2)!=OPUS_INVALID_PACKET)test_failed(); /* Code 3 m=0 */ - cfgs++; - packet[1]=49; - if(opus_repacketizer_cat(rp,packet,100)!=OPUS_INVALID_PACKET)test_failed(); /* Code 3 m=49 */ - cfgs++; - packet[0]=0; - if(opus_repacketizer_cat(rp,packet,3)!=OPUS_OK)test_failed(); - cfgs++; - packet[0]=1<<2; - if(opus_repacketizer_cat(rp,packet,3)!=OPUS_INVALID_PACKET)test_failed(); /* Change in TOC */ - cfgs++; - - /* Code 0,1,3 CBR -> Code 0,1,3 CBR */ - opus_repacketizer_init(rp); - for(j=0;j<32;j++) - { - /* TOC types, test half with stereo */ - int maxi; - packet[0]=((j<<1)+(j&1))<<2; - maxi=960/opus_packet_get_samples_per_frame(packet,8000); - for(i=1;i<=maxi;i++) - { - /* Number of CBR frames in the input packets */ - int maxp; - packet[0]=((j<<1)+(j&1))<<2; - if(i>1)packet[0]+=i==2?1:3; - packet[1]=i>2?i:0; - maxp=960/(i*opus_packet_get_samples_per_frame(packet,8000)); - for(k=0;k<=(1275+75);k+=3) - { - /*Payload size*/ - opus_int32 cnt,rcnt; - if(k%i!=0)continue; /* Only testing CBR here, payload must be a multiple of the count */ - for(cnt=0;cnt0) - { - ret=opus_repacketizer_cat(rp,packet,k+(i>2?2:1)); - if((cnt<=maxp&&k<=(1275*i))?ret!=OPUS_OK:ret!=OPUS_INVALID_PACKET)test_failed(); - cfgs++; - } - rcnt=k<=(1275*i)?(cnt0) - { - int len; - len=k*rcnt+((rcnt*i)>2?2:1); - if(ret!=len)test_failed(); - if((rcnt*i)<2&&(po[0]&3)!=0)test_failed(); /* Code 0 */ - if((rcnt*i)==2&&(po[0]&3)!=1)test_failed(); /* Code 1 */ - if((rcnt*i)>2&&(((po[0]&3)!=3)||(po[1]!=rcnt*i)))test_failed(); /* Code 3 CBR */ - cfgs++; - if(opus_repacketizer_out(rp,po,len)!=len)test_failed(); - cfgs++; - if(opus_packet_unpad(po,len)!=len)test_failed(); - cfgs++; - if(opus_packet_pad(po,len,len+1)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_packet_pad(po,len+1,len+256)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_packet_unpad(po,len+256)!=len)test_failed(); - cfgs++; - if(opus_multistream_packet_unpad(po,len,1)!=len)test_failed(); - cfgs++; - if(opus_multistream_packet_pad(po,len,len+1,1)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_multistream_packet_pad(po,len+1,len+256,1)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_multistream_packet_unpad(po,len+256,1)!=len)test_failed(); - cfgs++; - if(opus_repacketizer_out(rp,po,len-1)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - if(len>1) - { - if(opus_repacketizer_out(rp,po,1)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - } - if(opus_repacketizer_out(rp,po,0)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - } else if (ret!=OPUS_BAD_ARG)test_failed(); /* M must not be 0 */ - } - opus_repacketizer_init(rp); - } - } - } - - /*Change in input count code, CBR out*/ - opus_repacketizer_init(rp); - packet[0]=0; - if(opus_repacketizer_cat(rp,packet,5)!=OPUS_OK)test_failed(); - cfgs++; - packet[0]+=1; - if(opus_repacketizer_cat(rp,packet,9)!=OPUS_OK)test_failed(); - cfgs++; - i=opus_repacketizer_out(rp,po,max_out); - if((i!=(4+8+2))||((po[0]&3)!=3)||((po[1]&63)!=3)||((po[1]>>7)!=0))test_failed(); - cfgs++; - i=opus_repacketizer_out_range(rp,0,1,po,max_out); - if(i!=5||(po[0]&3)!=0)test_failed(); - cfgs++; - i=opus_repacketizer_out_range(rp,1,2,po,max_out); - if(i!=5||(po[0]&3)!=0)test_failed(); - cfgs++; - - /*Change in input count code, VBR out*/ - opus_repacketizer_init(rp); - packet[0]=1; - if(opus_repacketizer_cat(rp,packet,9)!=OPUS_OK)test_failed(); - cfgs++; - packet[0]=0; - if(opus_repacketizer_cat(rp,packet,3)!=OPUS_OK)test_failed(); - cfgs++; - i=opus_repacketizer_out(rp,po,max_out); - if((i!=(2+8+2+2))||((po[0]&3)!=3)||((po[1]&63)!=3)||((po[1]>>7)!=1))test_failed(); - cfgs++; - - /*VBR in, VBR out*/ - opus_repacketizer_init(rp); - packet[0]=2; - packet[1]=4; - if(opus_repacketizer_cat(rp,packet,8)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_repacketizer_cat(rp,packet,8)!=OPUS_OK)test_failed(); - cfgs++; - i=opus_repacketizer_out(rp,po,max_out); - if((i!=(2+1+1+1+4+2+4+2))||((po[0]&3)!=3)||((po[1]&63)!=4)||((po[1]>>7)!=1))test_failed(); - cfgs++; - - /*VBR in, CBR out*/ - opus_repacketizer_init(rp); - packet[0]=2; - packet[1]=4; - if(opus_repacketizer_cat(rp,packet,10)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_repacketizer_cat(rp,packet,10)!=OPUS_OK)test_failed(); - cfgs++; - i=opus_repacketizer_out(rp,po,max_out); - if((i!=(2+4+4+4+4))||((po[0]&3)!=3)||((po[1]&63)!=4)||((po[1]>>7)!=0))test_failed(); - cfgs++; - - /*Count 0 in, VBR out*/ - for(j=0;j<32;j++) - { - /* TOC types, test half with stereo */ - int maxi,sum,rcnt; - packet[0]=((j<<1)+(j&1))<<2; - maxi=960/opus_packet_get_samples_per_frame(packet,8000); - sum=0; - rcnt=0; - opus_repacketizer_init(rp); - for(i=1;i<=maxi+2;i++) - { - int len; - ret=opus_repacketizer_cat(rp,packet,i); - if(rcnt2&&(po[1]&63)!=rcnt)test_failed(); - if(rcnt==2&&(po[0]&3)!=2)test_failed(); - if(rcnt==1&&(po[0]&3)!=0)test_failed(); - cfgs++; - if(opus_repacketizer_out(rp,po,len)!=len)test_failed(); - cfgs++; - if(opus_packet_unpad(po,len)!=len)test_failed(); - cfgs++; - if(opus_packet_pad(po,len,len+1)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_packet_pad(po,len+1,len+256)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_packet_unpad(po,len+256)!=len)test_failed(); - cfgs++; - if(opus_multistream_packet_unpad(po,len,1)!=len)test_failed(); - cfgs++; - if(opus_multistream_packet_pad(po,len,len+1,1)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_multistream_packet_pad(po,len+1,len+256,1)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_multistream_packet_unpad(po,len+256,1)!=len)test_failed(); - cfgs++; - if(opus_repacketizer_out(rp,po,len-1)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - if(len>1) - { - if(opus_repacketizer_out(rp,po,1)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - } - if(opus_repacketizer_out(rp,po,0)!=OPUS_BUFFER_TOO_SMALL)test_failed(); - cfgs++; - } - } - - po[0]='O'; - po[1]='p'; - if(opus_packet_pad(po,4,4)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_multistream_packet_pad(po,4,4,1)!=OPUS_OK)test_failed(); - cfgs++; - if(opus_packet_pad(po,4,5)!=OPUS_INVALID_PACKET)test_failed(); - cfgs++; - if(opus_multistream_packet_pad(po,4,5,1)!=OPUS_INVALID_PACKET)test_failed(); - cfgs++; - if(opus_packet_pad(po,0,5)!=OPUS_BAD_ARG)test_failed(); - cfgs++; - if(opus_multistream_packet_pad(po,0,5,1)!=OPUS_BAD_ARG)test_failed(); - cfgs++; - if(opus_packet_unpad(po,0)!=OPUS_BAD_ARG)test_failed(); - cfgs++; - if(opus_multistream_packet_unpad(po,0,1)!=OPUS_BAD_ARG)test_failed(); - cfgs++; - if(opus_packet_unpad(po,4)!=OPUS_INVALID_PACKET)test_failed(); - cfgs++; - if(opus_multistream_packet_unpad(po,4,1)!=OPUS_INVALID_PACKET)test_failed(); - cfgs++; - po[0]=0; - po[1]=0; - po[2]=0; - if(opus_packet_pad(po,5,4)!=OPUS_BAD_ARG)test_failed(); - cfgs++; - if(opus_multistream_packet_pad(po,5,4,1)!=OPUS_BAD_ARG)test_failed(); - cfgs++; - - fprintf(stdout," opus_repacketizer_cat ........................ OK.\n"); - fprintf(stdout," opus_repacketizer_out ........................ OK.\n"); - fprintf(stdout," opus_repacketizer_out_range .................. OK.\n"); - fprintf(stdout," opus_packet_pad .............................. OK.\n"); - fprintf(stdout," opus_packet_unpad ............................ OK.\n"); - fprintf(stdout," opus_multistream_packet_pad .................. OK.\n"); - fprintf(stdout," opus_multistream_packet_unpad ................ OK.\n"); - - opus_repacketizer_destroy(rp); - cfgs++; - free(packet); - free(po); - fprintf(stdout," All repacketizer tests passed\n"); - fprintf(stdout," (%7d API invocations)\n",cfgs); - - return cfgs; -} - -#ifdef MALLOC_FAIL -/* GLIBC 2.14 declares __malloc_hook as deprecated, generating a warning - * under GCC. However, this is the cleanest way to test malloc failure - * handling in our codebase, and the lack of thread safety isn't an - * issue here. We therefore disable the warning for this function. - */ -#if OPUS_GNUC_PREREQ(4,6) -/* Save the current warning settings */ -#pragma GCC diagnostic push -#endif -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -typedef void *(*mhook)(size_t __size, __const void *); -#endif - -int test_malloc_fail(void) -{ -#ifdef MALLOC_FAIL - OpusDecoder *dec; - OpusEncoder *enc; - OpusRepacketizer *rp; - unsigned char mapping[256] = {0,1}; - OpusMSDecoder *msdec; - OpusMSEncoder *msenc; - int rate,c,app,cfgs,err,useerr; - int *ep; - mhook orig_malloc; - cfgs=0; -#endif - fprintf(stdout,"\n malloc() failure tests\n"); - fprintf(stdout," ---------------------------------------------------\n"); -#ifdef MALLOC_FAIL - orig_malloc=__malloc_hook; - __malloc_hook=malloc_hook; - ep=(int *)opus_alloc(sizeof(int)); - if(ep!=NULL) - { - if(ep)free(ep); - __malloc_hook=orig_malloc; -#endif - fprintf(stdout," opus_decoder_create() ................... SKIPPED.\n"); - fprintf(stdout," opus_encoder_create() ................... SKIPPED.\n"); - fprintf(stdout," opus_repacketizer_create() .............. SKIPPED.\n"); - fprintf(stdout," opus_multistream_decoder_create() ....... SKIPPED.\n"); - fprintf(stdout," opus_multistream_encoder_create() ....... SKIPPED.\n"); - fprintf(stdout,"(Test only supported with GLIBC and without valgrind)\n"); - return 0; -#ifdef MALLOC_FAIL - } - for(useerr=0;useerr<2;useerr++) - { - ep=useerr?&err:0; - for(rate=0;rate<5;rate++) - { - for(c=1;c<3;c++) - { - err=1; - if(useerr) - { - VG_UNDEF(&err,sizeof(err)); - } - dec=opus_decoder_create(opus_rates[rate], c, ep); - if(dec!=NULL||(useerr&&err!=OPUS_ALLOC_FAIL)) - { - __malloc_hook=orig_malloc; - test_failed(); - } - cfgs++; - msdec=opus_multistream_decoder_create(opus_rates[rate], c, 1, c-1, mapping, ep); - if(msdec!=NULL||(useerr&&err!=OPUS_ALLOC_FAIL)) - { - __malloc_hook=orig_malloc; - test_failed(); - } - cfgs++; - for(app=0;app<3;app++) - { - if(useerr) - { - VG_UNDEF(&err,sizeof(err)); - } - enc=opus_encoder_create(opus_rates[rate], c, opus_apps[app],ep); - if(enc!=NULL||(useerr&&err!=OPUS_ALLOC_FAIL)) - { - __malloc_hook=orig_malloc; - test_failed(); - } - cfgs++; - msenc=opus_multistream_encoder_create(opus_rates[rate], c, 1, c-1, mapping, opus_apps[app],ep); - if(msenc!=NULL||(useerr&&err!=OPUS_ALLOC_FAIL)) - { - __malloc_hook=orig_malloc; - test_failed(); - } - cfgs++; - } - } - } - } - rp=opus_repacketizer_create(); - if(rp!=NULL) - { - __malloc_hook=orig_malloc; - test_failed(); - } - cfgs++; - __malloc_hook=orig_malloc; - fprintf(stdout," opus_decoder_create() ........................ OK.\n"); - fprintf(stdout," opus_encoder_create() ........................ OK.\n"); - fprintf(stdout," opus_repacketizer_create() ................... OK.\n"); - fprintf(stdout," opus_multistream_decoder_create() ............ OK.\n"); - fprintf(stdout," opus_multistream_encoder_create() ............ OK.\n"); - fprintf(stdout," All malloc failure tests passed\n"); - fprintf(stdout," (%2d API invocations)\n",cfgs); - return cfgs; -#endif -} - -#ifdef MALLOC_FAIL -#if __GNUC_PREREQ(4,6) -#pragma GCC diagnostic pop /* restore -Wdeprecated-declarations */ -#endif -#endif - -int main(int _argc, char **_argv) -{ - opus_int32 total; - const char * oversion; - if(_argc>1) - { - fprintf(stderr,"Usage: %s\n",_argv[0]); - return 1; - } - iseed=0; - - oversion=opus_get_version_string(); - if(!oversion)test_failed(); - fprintf(stderr,"Testing the %s API deterministically\n", oversion); - if(opus_strerror(-32768)==NULL)test_failed(); - if(opus_strerror(32767)==NULL)test_failed(); - if(strlen(opus_strerror(0))<1)test_failed(); - total=4; - - total+=test_dec_api(); - total+=test_msdec_api(); - total+=test_parse(); - total+=test_enc_api(); - total+=test_repacketizer_api(); - total+=test_malloc_fail(); - - fprintf(stderr,"\nAll API tests passed.\nThe libopus API was invoked %d times.\n",total); - - return 0; -} diff --git a/Engine/lib/opus/tests/test_opus_common.h b/Engine/lib/opus/tests/test_opus_common.h deleted file mode 100644 index 5fb924f4a..000000000 --- a/Engine/lib/opus/tests/test_opus_common.h +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (c) 2011 Xiph.Org Foundation - Written by 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. -*/ - -static OPUS_INLINE void deb2_impl(unsigned char *_t,unsigned char **_p,int _k,int _x,int _y) -{ - int i; - if(_x>2){ - if(_y<3)for(i=0;i<_y;i++)*(--*_p)=_t[i+1]; - }else{ - _t[_x]=_t[_x-_y]; - deb2_impl(_t,_p,_k,_x+1,_y); - for(i=_t[_x-_y]+1;i<_k;i++){ - _t[_x]=i; - deb2_impl(_t,_p,_k,_x+1,_x); - } - } -} - -/*Generates a De Bruijn sequence (k,2) with length k^2*/ -static OPUS_INLINE void debruijn2(int _k, unsigned char *_res) -{ - unsigned char *p; - unsigned char *t; - t=malloc(sizeof(unsigned char)*_k*2); - memset(t,0,sizeof(unsigned char)*_k*2); - p=&_res[_k*_k]; - deb2_impl(t,&p,_k,1,1); - free(t); -} - -/*MWC RNG of George Marsaglia*/ -static opus_uint32 Rz, Rw; -static OPUS_INLINE opus_uint32 fast_rand(void) -{ - Rz=36969*(Rz&65535)+(Rz>>16); - Rw=18000*(Rw&65535)+(Rw>>16); - return (Rz<<16)+Rw; -} -static opus_uint32 iseed; - -#ifdef __GNUC__ -__attribute__((noreturn)) -#elif defined(_MSC_VER) -__declspec(noreturn) -#endif -static OPUS_INLINE void _test_failed(const char *file, int line) -{ - fprintf(stderr,"\n ***************************************************\n"); - fprintf(stderr," *** A fatal error was detected. ***\n"); - fprintf(stderr," ***************************************************\n"); - fprintf(stderr,"Please report this failure and include\n"); - fprintf(stderr,"'make check SEED=%u fails %s at line %d for %s'\n",iseed,file,line,opus_get_version_string()); - fprintf(stderr,"and any relevant details about your system.\n\n"); -#if defined(_MSC_VER) - _set_abort_behavior( 0, _WRITE_ABORT_MSG); -#endif - abort(); -} -#define test_failed() _test_failed(__FILE__, __LINE__); -#define opus_test_assert(cond) {if (!(cond)) {test_failed();}} -void regression_test(void); diff --git a/Engine/lib/opus/tests/test_opus_decode.c b/Engine/lib/opus/tests/test_opus_decode.c deleted file mode 100644 index 2d1e2d414..000000000 --- a/Engine/lib/opus/tests/test_opus_decode.c +++ /dev/null @@ -1,463 +0,0 @@ -/* Copyright (c) 2011-2013 Xiph.Org Foundation - Written by 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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 -#include -#else -#include -#define getpid _getpid -#endif -#include "opus.h" -#include "test_opus_common.h" - -#define MAX_PACKET (1500) -#define MAX_FRAME_SAMP (5760) - -int test_decoder_code0(int no_fuzz) -{ - static const opus_int32 fsv[5]={48000,24000,16000,12000,8000}; - int err,skip,plen; - int out_samples,fec; - int t; - opus_int32 i; - OpusDecoder *dec[5*2]; - opus_int32 decsize; - OpusDecoder *decbak; - opus_uint32 dec_final_range1,dec_final_range2,dec_final_acc; - unsigned char *packet; - unsigned char modes[4096]; - short *outbuf_int; - short *outbuf; - - dec_final_range1=dec_final_range2=2; - - packet=malloc(sizeof(unsigned char)*MAX_PACKET); - if(packet==NULL)test_failed(); - - outbuf_int=malloc(sizeof(short)*(MAX_FRAME_SAMP+16)*2); - for(i=0;i<(MAX_FRAME_SAMP+16)*2;i++)outbuf_int[i]=32749; - outbuf=&outbuf_int[8*2]; - - fprintf(stdout," Starting %d decoders...\n",5*2); - for(t=0;t<5*2;t++) - { - int fs=fsv[t>>1]; - int c=(t&1)+1; - err=OPUS_INTERNAL_ERROR; - dec[t] = opus_decoder_create(fs, c, &err); - if(err!=OPUS_OK || dec[t]==NULL)test_failed(); - fprintf(stdout," opus_decoder_create(%5d,%d) OK. Copy ",fs,c); - { - OpusDecoder *dec2; - /*The opus state structures contain no pointers and can be freely copied*/ - dec2=(OpusDecoder *)malloc(opus_decoder_get_size(c)); - if(dec2==NULL)test_failed(); - memcpy(dec2,dec[t],opus_decoder_get_size(c)); - memset(dec[t],255,opus_decoder_get_size(c)); - opus_decoder_destroy(dec[t]); - printf("OK.\n"); - dec[t]=dec2; - } - } - - decsize=opus_decoder_get_size(1); - decbak=(OpusDecoder *)malloc(decsize); - if(decbak==NULL)test_failed(); - - for(t=0;t<5*2;t++) - { - int factor=48000/fsv[t>>1]; - for(fec=0;fec<2;fec++) - { - opus_int32 dur; - /*Test PLC on a fresh decoder*/ - out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor, fec); - if(out_samples!=120/factor)test_failed(); - if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed(); - if(dur!=120/factor)test_failed(); - - /*Test on a size which isn't a multiple of 2.5ms*/ - out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor+2, fec); - if(out_samples!=OPUS_BAD_ARG)test_failed(); - - /*Test null pointer input*/ - out_samples = opus_decode(dec[t], 0, -1, outbuf, 120/factor, fec); - if(out_samples!=120/factor)test_failed(); - out_samples = opus_decode(dec[t], 0, 1, outbuf, 120/factor, fec); - if(out_samples!=120/factor)test_failed(); - out_samples = opus_decode(dec[t], 0, 10, outbuf, 120/factor, fec); - if(out_samples!=120/factor)test_failed(); - out_samples = opus_decode(dec[t], 0, fast_rand(), outbuf, 120/factor, fec); - if(out_samples!=120/factor)test_failed(); - if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed(); - if(dur!=120/factor)test_failed(); - - /*Zero lengths*/ - out_samples = opus_decode(dec[t], packet, 0, outbuf, 120/factor, fec); - if(out_samples!=120/factor)test_failed(); - - /*Zero buffer*/ - outbuf[0]=32749; - out_samples = opus_decode(dec[t], packet, 0, outbuf, 0, fec); - if(out_samples>0)test_failed(); -#if !defined(OPUS_BUILD) && (OPUS_GNUC_PREREQ(4, 6) || (defined(__clang_major__) && __clang_major__ >= 3)) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnonnull" -#endif - out_samples = opus_decode(dec[t], packet, 0, 0, 0, fec); -#if !defined(OPUS_BUILD) && (OPUS_GNUC_PREREQ(4, 6) || (defined(__clang_major__) && __clang_major__ >= 3)) -#pragma GCC diagnostic pop -#endif - if(out_samples>0)test_failed(); - if(outbuf[0]!=32749)test_failed(); - - /*Invalid lengths*/ - out_samples = opus_decode(dec[t], packet, -1, outbuf, MAX_FRAME_SAMP, fec); - if(out_samples>=0)test_failed(); - out_samples = opus_decode(dec[t], packet, INT_MIN, outbuf, MAX_FRAME_SAMP, fec); - if(out_samples>=0)test_failed(); - out_samples = opus_decode(dec[t], packet, -1, outbuf, -1, fec); - if(out_samples>=0)test_failed(); - - /*Crazy FEC values*/ - out_samples = opus_decode(dec[t], packet, 1, outbuf, MAX_FRAME_SAMP, fec?-1:2); - if(out_samples>=0)test_failed(); - - /*Reset the decoder*/ - if(opus_decoder_ctl(dec[t], OPUS_RESET_STATE)!=OPUS_OK)test_failed(); - } - } - fprintf(stdout," dec[all] initial frame PLC OK.\n"); - - /*Count code 0 tests*/ - for(i=0;i<64;i++) - { - opus_int32 dur; - int j,expected[5*2]; - packet[0]=i<<2; - packet[1]=255; - packet[2]=255; - err=opus_packet_get_nb_channels(packet); - if(err!=(i&1)+1)test_failed(); - - for(t=0;t<5*2;t++){ - expected[t]=opus_decoder_get_nb_samples(dec[t],packet,1); - if(expected[t]>2880)test_failed(); - } - - for(j=0;j<256;j++) - { - packet[1]=j; - for(t=0;t<5*2;t++) - { - out_samples = opus_decode(dec[t], packet, 3, outbuf, MAX_FRAME_SAMP, 0); - if(out_samples!=expected[t])test_failed(); - if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed(); - if(dur!=out_samples)test_failed(); - opus_decoder_ctl(dec[t], OPUS_GET_FINAL_RANGE(&dec_final_range1)); - if(t==0)dec_final_range2=dec_final_range1; - else if(dec_final_range1!=dec_final_range2)test_failed(); - } - } - - for(t=0;t<5*2;t++){ - int factor=48000/fsv[t>>1]; - /* The PLC is run for 6 frames in order to get better PLC coverage. */ - for(j=0;j<6;j++) - { - out_samples = opus_decode(dec[t], 0, 0, outbuf, expected[t], 0); - if(out_samples!=expected[t])test_failed(); - if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed(); - if(dur!=out_samples)test_failed(); - } - /* Run the PLC once at 2.5ms, as a simulation of someone trying to - do small drift corrections. */ - if(expected[t]!=120/factor) - { - out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor, 0); - if(out_samples!=120/factor)test_failed(); - if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed(); - if(dur!=out_samples)test_failed(); - } - out_samples = opus_decode(dec[t], packet, 2, outbuf, expected[t]-1, 0); - if(out_samples>0)test_failed(); - } - } - fprintf(stdout," dec[all] all 2-byte prefix for length 3 and PLC, all modes (64) OK.\n"); - - if(no_fuzz) - { - fprintf(stdout," Skipping many tests which fuzz the decoder as requested.\n"); - free(decbak); - for(t=0;t<5*2;t++)opus_decoder_destroy(dec[t]); - printf(" Decoders stopped.\n"); - - err=0; - for(i=0;i<8*2;i++)err|=outbuf_int[i]!=32749; - for(i=MAX_FRAME_SAMP*2;i<(MAX_FRAME_SAMP+8)*2;i++)err|=outbuf[i]!=32749; - if(err)test_failed(); - - free(outbuf_int); - free(packet); - return 0; - } - - { - /*We only test a subset of the modes here simply because the longer - durations end up taking a long time.*/ - static const int cmodes[4]={16,20,24,28}; - static const opus_uint32 cres[4]={116290185,2172123586u,2172123586u,2172123586u}; - static const opus_uint32 lres[3]={3285687739u,1481572662,694350475}; - static const int lmodes[3]={0,4,8}; - int mode=fast_rand()%4; - - packet[0]=cmodes[mode]<<3; - dec_final_acc=0; - t=fast_rand()%10; - - for(i=0;i<65536;i++) - { - int factor=48000/fsv[t>>1]; - packet[1]=i>>8; - packet[2]=i&255; - packet[3]=255; - out_samples = opus_decode(dec[t], packet, 4, outbuf, MAX_FRAME_SAMP, 0); - if(out_samples!=120/factor)test_failed(); - opus_decoder_ctl(dec[t], OPUS_GET_FINAL_RANGE(&dec_final_range1)); - dec_final_acc+=dec_final_range1; - } - if(dec_final_acc!=cres[mode])test_failed(); - fprintf(stdout," dec[%3d] all 3-byte prefix for length 4, mode %2d OK.\n",t,cmodes[mode]); - - mode=fast_rand()%3; - packet[0]=lmodes[mode]<<3; - dec_final_acc=0; - t=fast_rand()%10; - for(i=0;i<65536;i++) - { - int factor=48000/fsv[t>>1]; - packet[1]=i>>8; - packet[2]=i&255; - packet[3]=255; - out_samples = opus_decode(dec[t], packet, 4, outbuf, MAX_FRAME_SAMP, 0); - if(out_samples!=480/factor)test_failed(); - opus_decoder_ctl(dec[t], OPUS_GET_FINAL_RANGE(&dec_final_range1)); - dec_final_acc+=dec_final_range1; - } - if(dec_final_acc!=lres[mode])test_failed(); - fprintf(stdout," dec[%3d] all 3-byte prefix for length 4, mode %2d OK.\n",t,lmodes[mode]); - } - - skip=fast_rand()%7; - for(i=0;i<64;i++) - { - int j,expected[5*2]; - packet[0]=i<<2; - for(t=0;t<5*2;t++)expected[t]=opus_decoder_get_nb_samples(dec[t],packet,1); - for(j=2+skip;j<1275;j+=4) - { - int jj; - for(jj=0;jj1.f)test_failed(); - if(x[j]<-1.f)test_failed(); - } - } - for(i=1;i<9;i++) - { - for (j=0;j<1024;j++) - { - x[j]=(j&255)*(1/32.f)-4.f; - } - opus_pcm_soft_clip(x,1024/i,i,s); - for (j=0;j<(1024/i)*i;j++) - { - if(x[j]>1.f)test_failed(); - if(x[j]<-1.f)test_failed(); - } - } - opus_pcm_soft_clip(x,0,1,s); - opus_pcm_soft_clip(x,1,0,s); - opus_pcm_soft_clip(x,1,1,0); - opus_pcm_soft_clip(x,1,-1,s); - opus_pcm_soft_clip(x,-1,1,s); - opus_pcm_soft_clip(0,1,1,s); - printf("OK.\n"); -} -#endif - -int main(int _argc, char **_argv) -{ - const char * oversion; - const char * env_seed; - int env_used; - - if(_argc>2) - { - fprintf(stderr,"Usage: %s []\n",_argv[0]); - return 1; - } - - env_used=0; - env_seed=getenv("SEED"); - if(_argc>1)iseed=atoi(_argv[1]); - else if(env_seed) - { - iseed=atoi(env_seed); - env_used=1; - } - else iseed=(opus_uint32)time(NULL)^(((opus_uint32)getpid()&65535)<<16); - Rw=Rz=iseed; - - oversion=opus_get_version_string(); - if(!oversion)test_failed(); - fprintf(stderr,"Testing %s decoder. Random seed: %u (%.4X)\n", oversion, iseed, fast_rand() % 65535); - if(env_used)fprintf(stderr," Random seed set from the environment (SEED=%s).\n", env_seed); - - /*Setting TEST_OPUS_NOFUZZ tells the tool not to send garbage data - into the decoders. This is helpful because garbage data - may cause the decoders to clip, which angers CLANG IOC.*/ - test_decoder_code0(getenv("TEST_OPUS_NOFUZZ")!=NULL); -#ifndef DISABLE_FLOAT_API - test_soft_clip(); -#endif - - return 0; -} diff --git a/Engine/lib/opus/tests/test_opus_encode.c b/Engine/lib/opus/tests/test_opus_encode.c deleted file mode 100644 index d6e8e2d37..000000000 --- a/Engine/lib/opus/tests/test_opus_encode.c +++ /dev/null @@ -1,707 +0,0 @@ -/* Copyright (c) 2011-2013 Xiph.Org Foundation - Written by 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. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#if (!defined WIN32 && !defined _WIN32) || defined(__MINGW32__) -#include -#else -#include -#define getpid _getpid -#endif -#include "opus_multistream.h" -#include "opus.h" -#include "../src/opus_private.h" -#include "test_opus_common.h" - -#define MAX_PACKET (1500) -#define SAMPLES (48000*30) -#define SSAMPLES (SAMPLES/3) -#define MAX_FRAME_SAMP (5760) -#define PI (3.141592653589793238462643f) -#define RAND_SAMPLE(a) (a[fast_rand() % sizeof(a)/sizeof(a[0])]) - -void generate_music(short *buf, opus_int32 len) -{ - opus_int32 a1,b1,a2,b2; - opus_int32 c1,c2,d1,d2; - opus_int32 i,j; - a1=b1=a2=b2=0; - c1=c2=d1=d2=0; - j=0; - /*60ms silence*/ - for(i=0;i<2880;i++)buf[i*2]=buf[i*2+1]=0; - for(i=2880;i>12)^((j>>10|j>>12)&26&j>>7)))&128)+128)<<15; - r=fast_rand();v1+=r&65535;v1-=r>>16; - r=fast_rand();v2+=r&65535;v2-=r>>16; - b1=v1-a1+((b1*61+32)>>6);a1=v1; - b2=v2-a2+((b2*61+32)>>6);a2=v2; - c1=(30*(c1+b1+d1)+32)>>6;d1=b1; - c2=(30*(c2+b2+d2)+32)>>6;d2=b2; - v1=(c1+128)>>8; - v2=(c2+128)>>8; - buf[i*2]=v1>32767?32767:(v1<-32768?-32768:v1); - buf[i*2+1]=v2>32767?32767:(v2<-32768?-32768:v2); - if(i%6==0)j++; - } -} - -#if 0 -static int save_ctr = 0; -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_INLINE void save_packet(unsigned char* p, int len, opus_uint32 rng) -{ - FILE *fout; - unsigned char int_field[4]; - char name[256]; - snprintf(name,255,"test_opus_encode.%llu.%d.bit",(unsigned long long)iseed,save_ctr); - fprintf(stdout,"writing %d byte packet to %s\n",len,name); - fout=fopen(name, "wb+"); - if(fout==NULL)test_failed(); - int_to_char(len, int_field); - fwrite(int_field, 1, 4, fout); - int_to_char(rng, int_field); - fwrite(int_field, 1, 4, fout); - fwrite(p, 1, len, fout); - fclose(fout); - save_ctr++; -} -#endif - -int get_frame_size_enum(int frame_size, int sampling_rate) -{ - int frame_size_enum; - - if(frame_size==sampling_rate/400) - frame_size_enum = OPUS_FRAMESIZE_2_5_MS; - else if(frame_size==sampling_rate/200) - frame_size_enum = OPUS_FRAMESIZE_5_MS; - else if(frame_size==sampling_rate/100) - frame_size_enum = OPUS_FRAMESIZE_10_MS; - else if(frame_size==sampling_rate/50) - frame_size_enum = OPUS_FRAMESIZE_20_MS; - else if(frame_size==sampling_rate/25) - frame_size_enum = OPUS_FRAMESIZE_40_MS; - else if(frame_size==3*sampling_rate/50) - frame_size_enum = OPUS_FRAMESIZE_60_MS; - else if(frame_size==4*sampling_rate/50) - frame_size_enum = OPUS_FRAMESIZE_80_MS; - else if(frame_size==5*sampling_rate/50) - frame_size_enum = OPUS_FRAMESIZE_100_MS; - else if(frame_size==6*sampling_rate/50) - frame_size_enum = OPUS_FRAMESIZE_120_MS; - else - test_failed(); - - return frame_size_enum; -} - -int test_encode(OpusEncoder *enc, int channels, int frame_size, OpusDecoder *dec) -{ - int samp_count = 0; - opus_int16 *inbuf; - unsigned char packet[MAX_PACKET+257]; - int len; - opus_int16 *outbuf; - int out_samples; - int ret = 0; - - /* Generate input data */ - inbuf = (opus_int16*)malloc(sizeof(*inbuf)*SSAMPLES); - generate_music(inbuf, SSAMPLES/2); - - /* Allocate memory for output data */ - outbuf = (opus_int16*)malloc(sizeof(*outbuf)*MAX_FRAME_SAMP*3); - - /* Encode data, then decode for sanity check */ - do { - len = opus_encode(enc, &inbuf[samp_count*channels], frame_size, packet, MAX_PACKET); - if(len<0 || len>MAX_PACKET) { - fprintf(stderr,"opus_encode() returned %d\n",len); - ret = -1; - break; - } - - out_samples = opus_decode(dec, packet, len, outbuf, MAX_FRAME_SAMP, 0); - if(out_samples!=frame_size) { - fprintf(stderr,"opus_decode() returned %d\n",out_samples); - ret = -1; - break; - } - - samp_count += frame_size; - } while (samp_count < ((SSAMPLES/2)-MAX_FRAME_SAMP)); - - /* Clean up */ - free(inbuf); - free(outbuf); - return ret; -} - -void fuzz_encoder_settings(const int num_encoders, const int num_setting_changes) -{ - OpusEncoder *enc; - OpusDecoder *dec; - int i,j,err; - - /* Parameters to fuzz. Some values are duplicated to increase their probability of being tested. */ - int sampling_rates[5] = {8000, 12000, 16000, 24000, 48000}; - int channels[2] = {1, 2}; - int applications[3] = {OPUS_APPLICATION_AUDIO, OPUS_APPLICATION_VOIP, OPUS_APPLICATION_RESTRICTED_LOWDELAY}; - int bitrates[11] = {6000, 12000, 16000, 24000, 32000, 48000, 64000, 96000, 510000, OPUS_AUTO, OPUS_BITRATE_MAX}; - int force_channels[4] = {OPUS_AUTO, OPUS_AUTO, 1, 2}; - int use_vbr[3] = {0, 1, 1}; - int vbr_constraints[3] = {0, 1, 1}; - int complexities[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - int max_bandwidths[6] = {OPUS_BANDWIDTH_NARROWBAND, OPUS_BANDWIDTH_MEDIUMBAND, - OPUS_BANDWIDTH_WIDEBAND, OPUS_BANDWIDTH_SUPERWIDEBAND, - OPUS_BANDWIDTH_FULLBAND, OPUS_BANDWIDTH_FULLBAND}; - int signals[4] = {OPUS_AUTO, OPUS_AUTO, OPUS_SIGNAL_VOICE, OPUS_SIGNAL_MUSIC}; - int inband_fecs[3] = {0, 0, 1}; - int packet_loss_perc[4] = {0, 1, 2, 5}; - int lsb_depths[2] = {8, 24}; - int prediction_disabled[3] = {0, 0, 1}; - int use_dtx[2] = {0, 1}; - int frame_sizes_ms_x2[9] = {5, 10, 20, 40, 80, 120, 160, 200, 240}; /* x2 to avoid 2.5 ms */ - - for (i=0; i=64000?2:1)))!=OPUS_OK)test_failed(); - if(opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY((count>>2)%11))!=OPUS_OK)test_failed(); - if(opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC((fast_rand()&15)&(fast_rand()%15)))!=OPUS_OK)test_failed(); - bw=modes[j]==0?OPUS_BANDWIDTH_NARROWBAND+(fast_rand()%3): - modes[j]==1?OPUS_BANDWIDTH_SUPERWIDEBAND+(fast_rand()&1): - OPUS_BANDWIDTH_NARROWBAND+(fast_rand()%5); - if(modes[j]==2&&bw==OPUS_BANDWIDTH_MEDIUMBAND)bw+=3; - if(opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(bw))!=OPUS_OK)test_failed(); - len = opus_encode(enc, &inbuf[i<<1], frame_size, packet, MAX_PACKET); - if(len<0 || len>MAX_PACKET)test_failed(); - if(opus_encoder_ctl(enc, OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test_failed(); - if((fast_rand()&3)==0) - { - if(opus_packet_pad(packet,len,len+1)!=OPUS_OK)test_failed(); - len++; - } - if((fast_rand()&7)==0) - { - if(opus_packet_pad(packet,len,len+256)!=OPUS_OK)test_failed(); - len+=256; - } - if((fast_rand()&3)==0) - { - len=opus_packet_unpad(packet,len); - if(len<1)test_failed(); - } - out_samples = opus_decode(dec, packet, len, &outbuf[i<<1], MAX_FRAME_SAMP, 0); - if(out_samples!=frame_size)test_failed(); - if(opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range))!=OPUS_OK)test_failed(); - if(enc_final_range!=dec_final_range)test_failed(); - /*LBRR decode*/ - out_samples = opus_decode(dec_err[0], packet, len, out2buf, frame_size, (fast_rand()&3)!=0); - if(out_samples!=frame_size)test_failed(); - out_samples = opus_decode(dec_err[1], packet, (fast_rand()&3)==0?0:len, out2buf, MAX_FRAME_SAMP, (fast_rand()&7)!=0); - if(out_samples<120)test_failed(); - i+=frame_size; - count++; - }while(i<(SSAMPLES-MAX_FRAME_SAMP)); - fprintf(stdout," Mode %s FB encode %s, %6d bps OK.\n",mstrings[modes[j]],rc==0?" VBR":rc==1?"CVBR":" CBR",rate); - fflush(stdout); - } - } - - if(opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(OPUS_AUTO))!=OPUS_OK)test_failed(); - if(opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(OPUS_AUTO))!=OPUS_OK)test_failed(); - if(opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0))!=OPUS_OK)test_failed(); - if(opus_encoder_ctl(enc, OPUS_SET_DTX(0))!=OPUS_OK)test_failed(); - - for(rc=0;rc<3;rc++) - { - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_VBR(rc<2))!=OPUS_OK)test_failed(); - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_VBR_CONSTRAINT(rc==1))!=OPUS_OK)test_failed(); - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_VBR_CONSTRAINT(rc==1))!=OPUS_OK)test_failed(); - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_INBAND_FEC(rc==0))!=OPUS_OK)test_failed(); - for(j=0;j<16;j++) - { - int rate; - int modes[16]={0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2}; - int rates[16]={4000,12000,32000,8000,16000,32000,48000,88000,4000,12000,32000,8000,16000,32000,48000,88000}; - int frame[16]={160*1,160,80,160,160,80,40,20,160*1,160,80,160,160,80,40,20}; - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_INBAND_FEC(rc==0&&j==1))!=OPUS_OK)test_failed(); - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_FORCE_MODE(MODE_SILK_ONLY+modes[j]))!=OPUS_OK)test_failed(); - rate=rates[j]+fast_rand()%rates[j]; - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_DTX(fast_rand()&1))!=OPUS_OK)test_failed(); - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_BITRATE(rate))!=OPUS_OK)test_failed(); - count=i=0; - do { - int len,out_samples,frame_size,loss; - opus_int32 pred; - if(opus_multistream_encoder_ctl(MSenc, OPUS_GET_PREDICTION_DISABLED(&pred))!=OPUS_OK)test_failed(); - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_PREDICTION_DISABLED((int)(fast_rand()&15)<(pred?11:4)))!=OPUS_OK)test_failed(); - frame_size=frame[j]; - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_COMPLEXITY((count>>2)%11))!=OPUS_OK)test_failed(); - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_PACKET_LOSS_PERC((fast_rand()&15)&(fast_rand()%15)))!=OPUS_OK)test_failed(); - if((fast_rand()&255)==0) - { - if(opus_multistream_encoder_ctl(MSenc, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); - if(opus_multistream_decoder_ctl(MSdec, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); - if((fast_rand()&3)!=0) - { - if(opus_multistream_decoder_ctl(MSdec_err, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); - } - } - if((fast_rand()&255)==0) - { - if(opus_multistream_decoder_ctl(MSdec_err, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); - } - len = opus_multistream_encode(MSenc, &inbuf[i<<1], frame_size, packet, MAX_PACKET); - if(len<0 || len>MAX_PACKET)test_failed(); - if(opus_multistream_encoder_ctl(MSenc, OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test_failed(); - if((fast_rand()&3)==0) - { - if(opus_multistream_packet_pad(packet,len,len+1,2)!=OPUS_OK)test_failed(); - len++; - } - if((fast_rand()&7)==0) - { - if(opus_multistream_packet_pad(packet,len,len+256,2)!=OPUS_OK)test_failed(); - len+=256; - } - if((fast_rand()&3)==0) - { - len=opus_multistream_packet_unpad(packet,len,2); - if(len<1)test_failed(); - } - out_samples = opus_multistream_decode(MSdec, packet, len, out2buf, MAX_FRAME_SAMP, 0); - if(out_samples!=frame_size*6)test_failed(); - if(opus_multistream_decoder_ctl(MSdec, OPUS_GET_FINAL_RANGE(&dec_final_range))!=OPUS_OK)test_failed(); - if(enc_final_range!=dec_final_range)test_failed(); - /*LBRR decode*/ - loss=(fast_rand()&63)==0; - out_samples = opus_multistream_decode(MSdec_err, packet, loss?0:len, out2buf, frame_size*6, (fast_rand()&3)!=0); - if(out_samples!=(frame_size*6))test_failed(); - i+=frame_size; - count++; - }while(i<(SSAMPLES/12-MAX_FRAME_SAMP)); - fprintf(stdout," Mode %s NB dual-mono MS encode %s, %6d bps OK.\n",mstrings[modes[j]],rc==0?" VBR":rc==1?"CVBR":" CBR",rate); - fflush(stdout); - } - } - - bitrate_bps=512000; - fsize=fast_rand()%31; - fswitch=100; - - debruijn2(6,db62); - count=i=0; - do { - unsigned char toc; - const unsigned char *frames[48]; - short size[48]; - int payload_offset; - opus_uint32 dec_final_range2; - int jj,dec2; - int len,out_samples; - int frame_size=fsizes[db62[fsize]]; - opus_int32 offset=i%(SAMPLES-MAX_FRAME_SAMP); - - opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate_bps)); - - len = opus_encode(enc, &inbuf[offset<<1], frame_size, packet, MAX_PACKET); - if(len<0 || len>MAX_PACKET)test_failed(); - count++; - - opus_encoder_ctl(enc, OPUS_GET_FINAL_RANGE(&enc_final_range)); - - out_samples = opus_decode(dec, packet, len, &outbuf[offset<<1], MAX_FRAME_SAMP, 0); - if(out_samples!=frame_size)test_failed(); - - opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range)); - - /* compare final range encoder rng values of encoder and decoder */ - if(dec_final_range!=enc_final_range)test_failed(); - - /* We fuzz the packet, but take care not to only corrupt the payload - Corrupted headers are tested elsewhere and we need to actually run - the decoders in order to compare them. */ - if(opus_packet_parse(packet,len,&toc,frames,size,&payload_offset)<=0)test_failed(); - if((fast_rand()&1023)==0)len=0; - for(j=(opus_int32)(frames[0]-packet);j0?packet:NULL, len, out2buf, MAX_FRAME_SAMP, 0); - if(out_samples<0||out_samples>MAX_FRAME_SAMP)test_failed(); - if((len>0&&out_samples!=frame_size))test_failed(); /*FIXME use lastframe*/ - - opus_decoder_ctl(dec_err[0], OPUS_GET_FINAL_RANGE(&dec_final_range)); - - /*randomly select one of the decoders to compare with*/ - dec2=fast_rand()%9+1; - out_samples = opus_decode(dec_err[dec2], len>0?packet:NULL, len, out2buf, MAX_FRAME_SAMP, 0); - if(out_samples<0||out_samples>MAX_FRAME_SAMP)test_failed(); /*FIXME, use factor, lastframe for loss*/ - - opus_decoder_ctl(dec_err[dec2], OPUS_GET_FINAL_RANGE(&dec_final_range2)); - if(len>0&&dec_final_range!=dec_final_range2)test_failed(); - - fswitch--; - if(fswitch<1) - { - int new_size; - fsize=(fsize+1)%36; - new_size=fsizes[db62[fsize]]; - if(new_size==960||new_size==480)fswitch=2880/new_size*(fast_rand()%19+1); - else fswitch=(fast_rand()%(2880/new_size))+1; - } - bitrate_bps=((fast_rand()%508000+4000)+bitrate_bps)>>1; - i+=frame_size; - }while(i] [-fuzz ]\n",_argv[0]); -} - -int main(int _argc, char **_argv) -{ - int args=1; - char * strtol_str=NULL; - const char * oversion; - const char * env_seed; - int env_used; - int num_encoders_to_fuzz=5; - int num_setting_changes=40; - - env_used=0; - env_seed=getenv("SEED"); - if(_argc>1) - iseed=strtol(_argv[1], &strtol_str, 10); /* the first input argument might be the seed */ - if(strtol_str!=NULL && strtol_str[0]=='\0') /* iseed is a valid number */ - args++; - else if(env_seed) { - iseed=atoi(env_seed); - env_used=1; - } - else iseed=(opus_uint32)time(NULL)^(((opus_uint32)getpid()&65535)<<16); - Rw=Rz=iseed; - - while(args<_argc) - { - if(strcmp(_argv[args], "-fuzz")==0 && _argc==(args+3)) { - num_encoders_to_fuzz=strtol(_argv[args+1], &strtol_str, 10); - if(strtol_str[0]!='\0' || num_encoders_to_fuzz<=0) { - print_usage(_argv); - return EXIT_FAILURE; - } - num_setting_changes=strtol(_argv[args+2], &strtol_str, 10); - if(strtol_str[0]!='\0' || num_setting_changes<=0) { - print_usage(_argv); - return EXIT_FAILURE; - } - args+=3; - } - else { - print_usage(_argv); - return EXIT_FAILURE; - } - } - - oversion=opus_get_version_string(); - if(!oversion)test_failed(); - fprintf(stderr,"Testing %s encoder. Random seed: %u (%.4X)\n", oversion, iseed, fast_rand() % 65535); - if(env_used)fprintf(stderr," Random seed set from the environment (SEED=%s).\n", env_seed); - - regression_test(); - - /*Setting TEST_OPUS_NOFUZZ tells the tool not to send garbage data - into the decoders. This is helpful because garbage data - may cause the decoders to clip, which angers CLANG IOC.*/ - run_test1(getenv("TEST_OPUS_NOFUZZ")!=NULL); - - /* Fuzz encoder settings online */ - if(getenv("TEST_OPUS_NOFUZZ")==NULL) { - fprintf(stderr,"Running fuzz_encoder_settings with %d encoder(s) and %d setting change(s) each.\n", - num_encoders_to_fuzz, num_setting_changes); - fuzz_encoder_settings(num_encoders_to_fuzz, num_setting_changes); - } - - fprintf(stderr,"Tests completed successfully.\n"); - - return 0; -} diff --git a/Engine/lib/opus/tests/test_opus_padding.c b/Engine/lib/opus/tests/test_opus_padding.c deleted file mode 100644 index c9ef73756..000000000 --- a/Engine/lib/opus/tests/test_opus_padding.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (c) 2012 Xiph.Org Foundation - Written by Jüri Aedla and Ralph Giles */ -/* - 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. -*/ - -/* Check for overflow in reading the padding length. - * http://lists.xiph.org/pipermail/opus/2012-November/001834.html - */ - -#include -#include -#include -#include "opus.h" -#include "test_opus_common.h" - -#define PACKETSIZE 16909318 -#define CHANNELS 2 -#define FRAMESIZE 5760 - -void test_overflow(void) -{ - OpusDecoder *decoder; - int result; - int error; - - unsigned char *in = malloc(PACKETSIZE); - opus_int16 *out = malloc(FRAMESIZE*CHANNELS*sizeof(*out)); - - fprintf(stderr, " Checking for padding overflow... "); - if (!in || !out) { - fprintf(stderr, "FAIL (out of memory)\n"); - test_failed(); - } - in[0] = 0xff; - in[1] = 0x41; - memset(in + 2, 0xff, PACKETSIZE - 3); - in[PACKETSIZE-1] = 0x0b; - - decoder = opus_decoder_create(48000, CHANNELS, &error); - result = opus_decode(decoder, in, PACKETSIZE, out, FRAMESIZE, 0); - opus_decoder_destroy(decoder); - - free(in); - free(out); - - if (result != OPUS_INVALID_PACKET) { - fprintf(stderr, "FAIL!\n"); - test_failed(); - } - - fprintf(stderr, "OK.\n"); -} - -int main(void) -{ - const char *oversion; - - iseed = 0; - oversion = opus_get_version_string(); - if (!oversion) test_failed(); - fprintf(stderr, "Testing %s padding.\n", oversion); - - test_overflow(); - - fprintf(stderr, "All padding tests passed.\n"); - - return 0; -} diff --git a/Engine/lib/opus/tests/test_opus_projection.c b/Engine/lib/opus/tests/test_opus_projection.c deleted file mode 100644 index 4e06613e6..000000000 --- a/Engine/lib/opus/tests/test_opus_projection.c +++ /dev/null @@ -1,393 +0,0 @@ -/* Copyright (c) 2017 Google Inc. - Written by Andrew Allen */ -/* - 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 -#include -#include -#include -#include "float_cast.h" -#include "opus.h" -#include "test_opus_common.h" -#include "opus_projection.h" -#include "mathops.h" -#include "../src/mapping_matrix.h" -#include "mathops.h" - -#define BUFFER_SIZE 960 -#define MAX_DATA_BYTES 32768 -#define MAX_FRAME_SAMPLES 5760 -#define ERROR_TOLERANCE 1 - -#define SIMPLE_MATRIX_SIZE 12 -#define SIMPLE_MATRIX_FRAME_SIZE 10 -#define SIMPLE_MATRIX_INPUT_SIZE 30 -#define SIMPLE_MATRIX_OUTPUT_SIZE 40 - -int assert_is_equal( - const opus_val16 *a, const opus_int16 *b, int size, opus_int16 tolerance) -{ - int i; - for (i = 0; i < size; i++) - { -#ifdef FIXED_POINT - opus_int16 val = a[i]; -#else - opus_int16 val = FLOAT2INT16(a[i]); -#endif - if (abs(val - b[i]) > tolerance) - return 1; - } - return 0; -} - -int assert_is_equal_short( - const opus_int16 *a, const opus_int16 *b, int size, opus_int16 tolerance) -{ - int i; - for (i = 0; i < size; i++) - if (abs(a[i] - b[i]) > tolerance) - return 1; - return 0; -} - -void test_simple_matrix(void) -{ - const MappingMatrix simple_matrix_params = {4, 3, 0}; - const opus_int16 simple_matrix_data[SIMPLE_MATRIX_SIZE] = {0, 32767, 0, 0, 32767, 0, 0, 0, 0, 0, 0, 32767}; - const opus_int16 input_int16[SIMPLE_MATRIX_INPUT_SIZE] = { - 32767, 0, -32768, 29491, -3277, -29491, 26214, -6554, -26214, 22938, -9830, - -22938, 19661, -13107, -19661, 16384, -16384, -16384, 13107, -19661, -13107, - 9830, -22938, -9830, 6554, -26214, -6554, 3277, -29491, -3277}; - const opus_int16 expected_output_int16[SIMPLE_MATRIX_OUTPUT_SIZE] = { - 0, 32767, 0, -32768, -3277, 29491, 0, -29491, -6554, 26214, 0, -26214, - -9830, 22938, 0, -22938, -13107, 19661, 0, -19661, -16384, 16384, 0, -16384, - -19661, 13107, 0, -13107, -22938, 9830, 0, -9830, -26214, 6554, 0, -6554, - -29491, 3277, 0, -3277}; - - int i, ret; - opus_int32 simple_matrix_size; - opus_val16 *input_val16; - opus_val16 *output_val16; - opus_int16 *output_int16; - MappingMatrix *simple_matrix; - - /* Allocate input/output buffers. */ - input_val16 = (opus_val16 *)opus_alloc(sizeof(opus_val16) * SIMPLE_MATRIX_INPUT_SIZE); - output_int16 = (opus_int16 *)opus_alloc(sizeof(opus_int16) * SIMPLE_MATRIX_OUTPUT_SIZE); - output_val16 = (opus_val16 *)opus_alloc(sizeof(opus_val16) * SIMPLE_MATRIX_OUTPUT_SIZE); - - /* Initialize matrix */ - simple_matrix_size = mapping_matrix_get_size(simple_matrix_params.rows, - simple_matrix_params.cols); - if (!simple_matrix_size) - test_failed(); - - simple_matrix = (MappingMatrix *)opus_alloc(simple_matrix_size); - mapping_matrix_init(simple_matrix, simple_matrix_params.rows, - simple_matrix_params.cols, simple_matrix_params.gain, simple_matrix_data, - sizeof(simple_matrix_data)); - - /* Copy inputs. */ - for (i = 0; i < SIMPLE_MATRIX_INPUT_SIZE; i++) - { -#ifdef FIXED_POINT - input_val16[i] = input_int16[i]; -#else - input_val16[i] = (1/32768.f)*input_int16[i]; -#endif - } - - /* _in_short */ - for (i = 0; i < SIMPLE_MATRIX_OUTPUT_SIZE; i++) - output_val16[i] = 0; - for (i = 0; i < simple_matrix->rows; i++) - { - mapping_matrix_multiply_channel_in_short(simple_matrix, - input_int16, simple_matrix->cols, &output_val16[i], i, - simple_matrix->rows, SIMPLE_MATRIX_FRAME_SIZE); - } - ret = assert_is_equal(output_val16, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); - if (ret) - test_failed(); - - /* _out_short */ - for (i = 0; i < SIMPLE_MATRIX_OUTPUT_SIZE; i++) - output_int16[i] = 0; - for (i = 0; i < simple_matrix->cols; i++) - { - mapping_matrix_multiply_channel_out_short(simple_matrix, - &input_val16[i], i, simple_matrix->cols, output_int16, - simple_matrix->rows, SIMPLE_MATRIX_FRAME_SIZE); - } - ret = assert_is_equal_short(output_int16, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); - if (ret) - test_failed(); - -#if !defined(DISABLE_FLOAT_API) && !defined(FIXED_POINT) - /* _in_float */ - for (i = 0; i < SIMPLE_MATRIX_OUTPUT_SIZE; i++) - output_val16[i] = 0; - for (i = 0; i < simple_matrix->rows; i++) - { - mapping_matrix_multiply_channel_in_float(simple_matrix, - input_val16, simple_matrix->cols, &output_val16[i], i, - simple_matrix->rows, SIMPLE_MATRIX_FRAME_SIZE); - } - ret = assert_is_equal(output_val16, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); - if (ret) - test_failed(); - - /* _out_float */ - for (i = 0; i < SIMPLE_MATRIX_OUTPUT_SIZE; i++) - output_val16[i] = 0; - for (i = 0; i < simple_matrix->cols; i++) - { - mapping_matrix_multiply_channel_out_float(simple_matrix, - &input_val16[i], i, simple_matrix->cols, output_val16, - simple_matrix->rows, SIMPLE_MATRIX_FRAME_SIZE); - } - ret = assert_is_equal(output_val16, expected_output_int16, SIMPLE_MATRIX_OUTPUT_SIZE, ERROR_TOLERANCE); - if (ret) - test_failed(); -#endif - - opus_free(input_val16); - opus_free(output_int16); - opus_free(output_val16); - opus_free(simple_matrix); -} - -void test_creation_arguments(const int channels, const int mapping_family) -{ - int streams; - int coupled_streams; - int enc_error; - int dec_error; - int ret; - OpusProjectionEncoder *st_enc = NULL; - OpusProjectionDecoder *st_dec = NULL; - - const opus_int32 Fs = 48000; - const int application = OPUS_APPLICATION_AUDIO; - - int order_plus_one = (int)floor(sqrt((float)channels)); - int nondiegetic_channels = channels - order_plus_one * order_plus_one; - - int is_channels_valid = 0; - int is_projection_valid = 0; - - st_enc = opus_projection_ambisonics_encoder_create(Fs, channels, - mapping_family, &streams, &coupled_streams, application, &enc_error); - if (st_enc != NULL) - { - opus_int32 matrix_size; - unsigned char *matrix; - - ret = opus_projection_encoder_ctl(st_enc, - OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST, &matrix_size); - if (ret != OPUS_OK || !matrix_size) - test_failed(); - - matrix = (unsigned char *)opus_alloc(matrix_size); - ret = opus_projection_encoder_ctl(st_enc, - OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST, matrix, matrix_size); - - opus_projection_encoder_destroy(st_enc); - - st_dec = opus_projection_decoder_create(Fs, channels, streams, - coupled_streams, matrix, matrix_size, &dec_error); - if (st_dec != NULL) - { - opus_projection_decoder_destroy(st_dec); - } - opus_free(matrix); - } - - is_channels_valid = (order_plus_one >= 2 && order_plus_one <= 4) && - (nondiegetic_channels == 0 || nondiegetic_channels == 2); - is_projection_valid = (enc_error == OPUS_OK && dec_error == OPUS_OK); - if (is_channels_valid ^ is_projection_valid) - { - fprintf(stderr, "Channels: %d, Family: %d\n", channels, mapping_family); - fprintf(stderr, "Order+1: %d, Non-diegetic Channels: %d\n", - order_plus_one, nondiegetic_channels); - fprintf(stderr, "Streams: %d, Coupled Streams: %d\n", - streams, coupled_streams); - test_failed(); - } -} - -void generate_music(short *buf, opus_int32 len, opus_int32 channels) -{ - opus_int32 i,j,k; - opus_int32 *a,*b,*c,*d; - a = (opus_int32 *)malloc(sizeof(opus_int32) * channels); - b = (opus_int32 *)malloc(sizeof(opus_int32) * channels); - c = (opus_int32 *)malloc(sizeof(opus_int32) * channels); - d = (opus_int32 *)malloc(sizeof(opus_int32) * channels); - memset(a, 0, sizeof(opus_int32) * channels); - memset(b, 0, sizeof(opus_int32) * channels); - memset(c, 0, sizeof(opus_int32) * channels); - memset(d, 0, sizeof(opus_int32) * channels); - j=0; - - for(i=0;i>12)^((j>>10|j>>12)&26&j>>7)))&128)+128)<<15; - r=fast_rand();v+=r&65535;v-=r>>16; - b[k]=v-a[k]+((b[k]*61+32)>>6);a[k]=v; - c[k]=(30*(c[k]+b[k]+d[k])+32)>>6;d[k]=b[k]; - v=(c[k]+128)>>8; - buf[i*channels+k]=v>32767?32767:(v<-32768?-32768:v); - if(i%6==0)j++; - } - } - - free(a); - free(b); - free(c); - free(d); -} - -void test_encode_decode(opus_int32 bitrate, opus_int32 channels, - const int mapping_family) -{ - const opus_int32 Fs = 48000; - const int application = OPUS_APPLICATION_AUDIO; - - OpusProjectionEncoder *st_enc; - OpusProjectionDecoder *st_dec; - int streams; - int coupled; - int error; - short *buffer_in; - short *buffer_out; - unsigned char data[MAX_DATA_BYTES] = { 0 }; - int len; - int out_samples; - opus_int32 matrix_size = 0; - unsigned char *matrix = NULL; - - buffer_in = (short *)malloc(sizeof(short) * BUFFER_SIZE * channels); - buffer_out = (short *)malloc(sizeof(short) * BUFFER_SIZE * channels); - - st_enc = opus_projection_ambisonics_encoder_create(Fs, channels, - mapping_family, &streams, &coupled, application, &error); - if (error != OPUS_OK) { - fprintf(stderr, - "Couldn\'t create encoder with %d channels and mapping family %d.\n", - channels, mapping_family); - free(buffer_in); - free(buffer_out); - test_failed(); - } - - error = opus_projection_encoder_ctl(st_enc, - OPUS_SET_BITRATE(bitrate * 1000 * (streams + coupled))); - if (error != OPUS_OK) - { - goto bad_cleanup; - } - - error = opus_projection_encoder_ctl(st_enc, - OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST, &matrix_size); - if (error != OPUS_OK || !matrix_size) - { - goto bad_cleanup; - } - - matrix = (unsigned char *)opus_alloc(matrix_size); - error = opus_projection_encoder_ctl(st_enc, - OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST, matrix, matrix_size); - - st_dec = opus_projection_decoder_create(Fs, channels, streams, coupled, - matrix, matrix_size, &error); - opus_free(matrix); - - if (error != OPUS_OK) { - fprintf(stderr, - "Couldn\'t create decoder with %d channels, %d streams " - "and %d coupled streams.\n", channels, streams, coupled); - goto bad_cleanup; - } - - generate_music(buffer_in, BUFFER_SIZE, channels); - - len = opus_projection_encode( - st_enc, buffer_in, BUFFER_SIZE, data, MAX_DATA_BYTES); - if(len<0 || len>MAX_DATA_BYTES) { - fprintf(stderr,"opus_encode() returned %d\n", len); - goto bad_cleanup; - } - - out_samples = opus_projection_decode( - st_dec, data, len, buffer_out, MAX_FRAME_SAMPLES, 0); - if(out_samples!=BUFFER_SIZE) { - fprintf(stderr,"opus_decode() returned %d\n", out_samples); - goto bad_cleanup; - } - - opus_projection_decoder_destroy(st_dec); - opus_projection_encoder_destroy(st_enc); - free(buffer_in); - free(buffer_out); - return; -bad_cleanup: - free(buffer_in); - free(buffer_out); - test_failed(); -} - -int main(int _argc, char **_argv) -{ - unsigned int i; - - (void)_argc; - (void)_argv; - - /* Test simple matrix multiplication routines. */ - test_simple_matrix(); - - /* Test full range of channels in creation arguments. */ - for (i = 0; i < 255; i++) - test_creation_arguments(i, 3); - - /* Test encode/decode pipeline. */ - test_encode_decode(64 * 18, 18, 3); - - fprintf(stderr, "All projection tests passed.\n"); - return 0; -} - diff --git a/Engine/lib/opus/training/rnn_dump.py b/Engine/lib/opus/training/rnn_dump.py deleted file mode 100644 index c312088e8..000000000 --- a/Engine/lib/opus/training/rnn_dump.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/python - -from __future__ import print_function - -from keras.models import Sequential -from keras.models import Model -from keras.layers import Input -from keras.layers import Dense -from keras.layers import LSTM -from keras.layers import GRU -from keras.models import load_model -from keras import backend as K -import sys - -import numpy as np - -def printVector(f, vector, name): - v = np.reshape(vector, (-1)); - #print('static const float ', name, '[', len(v), '] = \n', file=f) - f.write('static const opus_int8 {}[{}] = {{\n '.format(name, len(v))) - for i in range(0, len(v)): - f.write('{}'.format(max(-128,min(127,int(round(128*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\n') - return; - -def binary_crossentrop2(y_true, y_pred): - return K.mean(2*K.abs(y_true-0.5) * K.binary_crossentropy(y_pred, y_true), axis=-1) - - -#model = load_model(sys.argv[1], custom_objects={'binary_crossentrop2': binary_crossentrop2}) -main_input = Input(shape=(None, 25), name='main_input') -x = Dense(32, activation='tanh')(main_input) -x = GRU(24, activation='tanh', recurrent_activation='sigmoid', return_sequences=True)(x) -x = Dense(2, activation='sigmoid')(x) -model = Model(inputs=main_input, outputs=x) -model.load_weights(sys.argv[1]) - -weights = model.get_weights() - -f = open(sys.argv[2], 'w') - -f.write('/*This file is automatically generated from a Keras model*/\n\n') -f.write('#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n#include "mlp.h"\n\n') - -printVector(f, weights[0], 'layer0_weights') -printVector(f, weights[1], 'layer0_bias') -printVector(f, weights[2], 'layer1_weights') -printVector(f, weights[3], 'layer1_recur_weights') -printVector(f, weights[4], 'layer1_bias') -printVector(f, weights[5], 'layer2_weights') -printVector(f, weights[6], 'layer2_bias') - -f.write('const DenseLayer layer0 = {\n layer0_bias,\n layer0_weights,\n 25, 32, 0\n};\n\n') -f.write('const GRULayer layer1 = {\n layer1_bias,\n layer1_weights,\n layer1_recur_weights,\n 32, 24\n};\n\n') -f.write('const DenseLayer layer2 = {\n layer2_bias,\n layer2_weights,\n 24, 2, 1\n};\n\n') - -f.close() diff --git a/Engine/lib/opus/training/rnn_train.py b/Engine/lib/opus/training/rnn_train.py deleted file mode 100644 index 29bcb0346..000000000 --- a/Engine/lib/opus/training/rnn_train.py +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/python3 - -from __future__ import print_function - -from keras.models import Sequential -from keras.models import Model -from keras.layers import Input -from keras.layers import Dense -from keras.layers import LSTM -from keras.layers import GRU -from keras.layers import CuDNNGRU -from keras.layers import SimpleRNN -from keras.layers import Dropout -from keras import losses -import h5py -from keras.optimizers import Adam - -from keras.constraints import Constraint -from keras import backend as K -import numpy as np - -import tensorflow as tf -from keras.backend.tensorflow_backend import set_session -config = tf.ConfigProto() -config.gpu_options.per_process_gpu_memory_fraction = 0.44 -set_session(tf.Session(config=config)) - -def binary_crossentrop2(y_true, y_pred): - return K.mean(2*K.abs(y_true-0.5) * K.binary_crossentropy(y_true, y_pred), axis=-1) - -def binary_accuracy2(y_true, y_pred): - return K.mean(K.cast(K.equal(y_true, K.round(y_pred)), 'float32') + K.cast(K.equal(y_true, 0.5), 'float32'), axis=-1) - -def quant_model(model): - weights = model.get_weights() - for k in range(len(weights)): - weights[k] = np.maximum(-128, np.minimum(127, np.round(128*weights[k])*0.0078125)) - model.set_weights(weights) - -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): - return K.clip(p, -self.c, self.c) - - def get_config(self): - return {'name': self.__class__.__name__, - 'c': self.c} - -reg = 0.000001 -constraint = WeightClip(.998) - -print('Build model...') - -main_input = Input(shape=(None, 25), name='main_input') -x = Dense(32, activation='tanh', kernel_constraint=constraint, bias_constraint=constraint)(main_input) -#x = CuDNNGRU(24, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, bias_constraint=constraint)(x) -x = GRU(24, recurrent_activation='sigmoid', activation='tanh', return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, bias_constraint=constraint)(x) -x = Dense(2, activation='sigmoid', kernel_constraint=constraint, bias_constraint=constraint)(x) -model = Model(inputs=main_input, outputs=x) - -batch_size = 2048 - -print('Loading data...') -with h5py.File('features10b.h5', 'r') as hf: - all_data = hf['data'][:] -print('done.') - -window_size = 1500 - -nb_sequences = len(all_data)//window_size -print(nb_sequences, ' sequences') -x_train = all_data[:nb_sequences*window_size, :-2] -x_train = np.reshape(x_train, (nb_sequences, window_size, 25)) - -y_train = np.copy(all_data[:nb_sequences*window_size, -2:]) -y_train = np.reshape(y_train, (nb_sequences, window_size, 2)) - -print("Marking ignores") -for s in y_train: - for e in s: - if (e[1] >= 1): - break - e[0] = 0.5 - -all_data = 0; -x_train = x_train.astype('float32') -y_train = y_train.astype('float32') - -print(len(x_train), 'train sequences. x shape =', x_train.shape, 'y shape = ', y_train.shape) - -model.load_weights('newweights10a1b_ep206.hdf5') - -#weights = model.get_weights() -#for k in range(len(weights)): -# weights[k] = np.round(128*weights[k])*0.0078125 -#model.set_weights(weights) - -# try using different optimizers and different optimizer configs -model.compile(loss=binary_crossentrop2, - optimizer=Adam(0.0001), - metrics=[binary_accuracy2]) - -print('Train...') -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=10, validation_data=(x_train, y_train)) -model.save("newweights10a1c_ep10.hdf5") - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=50, initial_epoch=10) -model.save("newweights10a1c_ep50.hdf5") - -model.compile(loss=binary_crossentrop2, - optimizer=Adam(0.0001), - metrics=[binary_accuracy2]) - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=100, initial_epoch=50) -model.save("newweights10a1c_ep100.hdf5") - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=150, initial_epoch=100) -model.save("newweights10a1c_ep150.hdf5") - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=200, initial_epoch=150) -model.save("newweights10a1c_ep200.hdf5") - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=201, initial_epoch=200) -model.save("newweights10a1c_ep201.hdf5") - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=202, initial_epoch=201, validation_data=(x_train, y_train)) -model.save("newweights10a1c_ep202.hdf5") - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=203, initial_epoch=202, validation_data=(x_train, y_train)) -model.save("newweights10a1c_ep203.hdf5") - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=204, initial_epoch=203, validation_data=(x_train, y_train)) -model.save("newweights10a1c_ep204.hdf5") - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=205, initial_epoch=204, validation_data=(x_train, y_train)) -model.save("newweights10a1c_ep205.hdf5") - -quant_model(model) -model.fit(x_train, y_train, - batch_size=batch_size, - epochs=206, initial_epoch=205, validation_data=(x_train, y_train)) -model.save("newweights10a1c_ep206.hdf5") - diff --git a/Engine/lib/opus/training/txt2hdf5.py b/Engine/lib/opus/training/txt2hdf5.py deleted file mode 100644 index 9c602877e..000000000 --- a/Engine/lib/opus/training/txt2hdf5.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/python - -from __future__ import print_function - -import numpy as np -import h5py -import sys - -data = np.loadtxt(sys.argv[1], dtype='float32') -h5f = h5py.File(sys.argv[2], 'w'); -h5f.create_dataset('data', data=data) -h5f.close() diff --git a/Engine/lib/opus/win32/VS2015/common.props b/Engine/lib/opus/win32/VS2015/common.props deleted file mode 100644 index f6e920b63..000000000 --- a/Engine/lib/opus/win32/VS2015/common.props +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\$(ProjectName)\ - Unicode - - - true - true - false - - - false - false - true - - - - Level3 - false - false - ..\..;..\..\include;..\..\silk;..\..\celt;..\..\win32;%(AdditionalIncludeDirectories) - HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - false - false - - - Console - - - true - Console - - - - - Guard - ProgramDatabase - NoExtensions - false - true - false - Disabled - false - false - Disabled - MultiThreadedDebug - MultiThreadedDebugDLL - true - false - - - true - - - - - false - None - true - true - false - Speed - Fast - Precise - true - true - true - MaxSpeed - MultiThreaded - MultiThreadedDLL - 16Bytes - - - false - - - - \ No newline at end of file diff --git a/Engine/lib/opus/win32/config.h b/Engine/lib/opus/win32/config.h deleted file mode 100644 index 3e54bcbbe..000000000 --- a/Engine/lib/opus/win32/config.h +++ /dev/null @@ -1,64 +0,0 @@ -/*********************************************************************** -Copyright (c) 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 CONFIG_H -#define CONFIG_H - -#define USE_ALLOCA 1 - -/* Comment out the next line for floating-point code */ -/*#define FIXED_POINT 1 */ - -#define OPUS_BUILD 1 - -#if defined(_M_IX86) || defined(_M_X64) -/* Can always compile SSE intrinsics (no special compiler flags necessary) */ -#define OPUS_X86_MAY_HAVE_SSE -#define OPUS_X86_MAY_HAVE_SSE2 -#define OPUS_X86_MAY_HAVE_SSE4_1 - -/* Presume SSE functions, if compiled to use SSE/SSE2/AVX (note that AMD64 implies SSE2, and AVX - implies SSE4.1) */ -#if defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1)) || defined(__AVX__) -#define OPUS_X86_PRESUME_SSE 1 -#endif -#if defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(__AVX__) -#define OPUS_X86_PRESUME_SSE2 1 -#endif -#if defined(__AVX__) -#define OPUS_X86_PRESUME_SSE4_1 1 -#endif - -#if !defined(OPUS_X86_PRESUME_SSE4_1) || !defined(OPUS_X86_PRESUME_SSE2) || !defined(OPUS_X86_PRESUME_SSE) -#define OPUS_HAVE_RTCD 1 -#endif - -#endif - -#include "version.h" - -#endif /* CONFIG_H */ diff --git a/Engine/lib/opus/win32/genversion.bat b/Engine/lib/opus/win32/genversion.bat deleted file mode 100644 index 1def7460b..000000000 --- a/Engine/lib/opus/win32/genversion.bat +++ /dev/null @@ -1,37 +0,0 @@ -@echo off - -setlocal enableextensions enabledelayedexpansion - -for /f %%v in ('cd "%~dp0.." ^&^& git status ^>NUL 2^>NUL ^&^& git describe --tags --match "v*" --dirty 2^>NUL') do set version=%%v - -if not "%version%"=="" set version=!version:~1! && goto :gotversion - -if exist "%~dp0..\package_version" goto :getversion - -echo Git cannot be found, nor can package_version. Generating unknown version. - -set version=unknown - -goto :gotversion - -:getversion - -for /f "delims== tokens=2" %%v in (%~dps0..\package_version) do set version=%%v -set version=!version:"=! - -:gotversion - -set version=!version: =! -set version_out=#define %~2 "%version%" - -echo %version_out%> "%~1_temp" - -echo n | comp "%~1_temp" "%~1" > NUL 2> NUL - -if not errorlevel 1 goto exit - -copy /y "%~1_temp" "%~1" - -:exit - -del "%~1_temp" diff --git a/Engine/lib/xiph-flac-1.5.0.tar.gz b/Engine/lib/xiph-flac-1.5.0.tar.gz new file mode 100644 index 000000000..e875838df Binary files /dev/null and b/Engine/lib/xiph-flac-1.5.0.tar.gz differ diff --git a/Engine/lib/xiph-ogg-v1.3.6.tar.gz b/Engine/lib/xiph-ogg-v1.3.6.tar.gz new file mode 100644 index 000000000..c8c1dd0d3 Binary files /dev/null and b/Engine/lib/xiph-ogg-v1.3.6.tar.gz differ diff --git a/Engine/lib/xiph-opus-v1.5.2.tar.gz b/Engine/lib/xiph-opus-v1.5.2.tar.gz new file mode 100644 index 000000000..b0175297d Binary files /dev/null and b/Engine/lib/xiph-opus-v1.5.2.tar.gz differ diff --git a/Engine/lib/xiph-theora-v1.2.0.tar.gz b/Engine/lib/xiph-theora-v1.2.0.tar.gz new file mode 100644 index 000000000..363234e2a Binary files /dev/null and b/Engine/lib/xiph-theora-v1.2.0.tar.gz differ diff --git a/Engine/lib/xiph-vorbis-v1.3.7.tar.gz b/Engine/lib/xiph-vorbis-v1.3.7.tar.gz new file mode 100644 index 000000000..c8f4fd6e4 Binary files /dev/null and b/Engine/lib/xiph-vorbis-v1.3.7.tar.gz differ diff --git a/Tools/CMake/torque_configs.cmake b/Tools/CMake/torque_configs.cmake index b3842e3c6..56805f781 100644 --- a/Tools/CMake/torque_configs.cmake +++ b/Tools/CMake/torque_configs.cmake @@ -1,5 +1,49 @@ ################# Initialize Common Variables ################### +set(VCPKG_ROOT "${CMAKE_BINARY_DIR}/vcpkg" CACHE PATH "VCPKG Root") +if(NOT EXISTS "${VCPKG_ROOT}") + message(STATUS "Bootstrapping vcpkg...") + execute_process( + COMMAND git clone https://github.com/microsoft/vcpkg.git "${VCPKG_ROOT}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + ) + if(WIN32) + execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.bat") + else() + execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.sh") + endif() +endif() +set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") +if(WIN32) + if(GIT_CI_BUILD) + set(VCPKG_TARGET_TRIPLET "x64-windows-mixed-release" CACHE STRING "") + else() + set(VCPKG_TARGET_TRIPLET "x64-windows-mixed" CACHE STRING "") + endif() +else() + if(APPLE) + if(GIT_CI_BUILD) + set(VCPKG_TARGET_TRIPLET "universal-osx-11-release" CACHE STRING "") + else() + set(VCPKG_TARGET_TRIPLET "universal-osx-11" CACHE STRING "") + endif() + endif(APPLE) + + + if(UNIX AND NOT APPLE) + if(GIT_CI_BUILD) + set(VCPKG_TARGET_TRIPLET "x64-linux-mixed-release" CACHE STRING "") + else() + set(VCPKG_TARGET_TRIPLET "x64-linux-mixed" CACHE STRING "") + endif() + endif() + +endif() + +set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_SOURCE_DIR}/Tools/CMake/vcpkg/triplets" CACHE STRING "") +set(VCPKG_OVERLAY_PORTS "${CMAKE_SOURCE_DIR}/Tools/CMake/vcpkg/ports" CACHE STRING "") +set(ENV{VCPKG_LIB_SOURCE_ROOT} "${CMAKE_SOURCE_DIR}/Engine/lib") +set(ENV{VCPKG_KEEP_ENV_VARS} "VCPKG_LIB_SOURCE_ROOT") # All include directories to search. Modules should append to this when they want includes to point # into themselves. set(TORQUE_INCLUDE_DIRECTORIES "") diff --git a/Tools/CMake/vcpkg/ports/libflac/android-cmake.diff b/Tools/CMake/vcpkg/ports/libflac/android-cmake.diff new file mode 100644 index 000000000..fc690854b --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libflac/android-cmake.diff @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9396130..11ef59d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -122,7 +122,7 @@ else() + endif() + + +-if(ANDROID AND CMAKE_SYSTEM_VERSION VERSION_LESS 24 AND (CMAKE_SYSTEM_PROCESSOR MATCHES "i686" OR CMAKE_SYSTEM_PROCESSOR MATCHES "armv7-a")) ++if(ANDROID AND ANDROID_NATIVE_API_LEVEL VERSION_LESS "24" AND (CMAKE_SYSTEM_PROCESSOR MATCHES "i686" OR CMAKE_SYSTEM_PROCESSOR MATCHES "armv7-a")) + # fseeko/ftello may link, but it's not usable before Android API 24 on 32-bit Android + # https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md + message(STATUS "Disabling fseeko/ftello for 32-bit Android before API 24") diff --git a/Engine/lib/flac/oss-fuzz/empty.cc b/Tools/CMake/vcpkg/ports/libflac/cmake-project-include.cmake similarity index 100% rename from Engine/lib/flac/oss-fuzz/empty.cc rename to Tools/CMake/vcpkg/ports/libflac/cmake-project-include.cmake diff --git a/Tools/CMake/vcpkg/ports/libflac/fix-compile-options.patch b/Tools/CMake/vcpkg/ports/libflac/fix-compile-options.patch new file mode 100644 index 000000000..9d438da0e --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libflac/fix-compile-options.patch @@ -0,0 +1,18 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c83dd83..2d1a7e6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -82,9 +82,11 @@ if(HAVE_WERROR_FLAG) + option(ENABLE_WERROR "Enable -Werror in all Makefiles" OFF) + endif() + ++if(MSVC AND NOT WITH_ASM) ++ add_compile_options(/wd4267 /wd4996) ++endif() ++ + add_compile_options( +- $<$:/wd4267> +- $<$:/wd4996> + $<$:-Werror> + $<$,$>:-Weffc++> + $<$,$>:-Wdeclaration-after-statement>) diff --git a/Tools/CMake/vcpkg/ports/libflac/fix-find-threads.patch b/Tools/CMake/vcpkg/ports/libflac/fix-find-threads.patch new file mode 100644 index 000000000..2804a2f24 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libflac/fix-find-threads.patch @@ -0,0 +1,15 @@ +diff --git a/flac-config.cmake.in b/flac-config.cmake.in +index bcafc4c8..dcf299dd 100644 +--- a/flac-config.cmake.in ++++ b/flac-config.cmake.in +@@ -5,6 +5,10 @@ if(NOT TARGET Ogg::ogg) + find_dependency(Ogg) + endif() + ++if (@ENABLE_MULTITHREADING@) ++ find_dependency(Threads) ++endif() ++ + include("${CMAKE_CURRENT_LIST_DIR}/targets.cmake") + + if(TARGET FLAC::FLAC) diff --git a/Tools/CMake/vcpkg/ports/libflac/portfile.cmake b/Tools/CMake/vcpkg/ports/libflac/portfile.cmake new file mode 100644 index 000000000..9dbf9aa87 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libflac/portfile.cmake @@ -0,0 +1,80 @@ +set(LOCAL_ARCHIVE "$ENV{VCPKG_LIB_SOURCE_ROOT}/xiph-flac-1.5.0.tar.gz") + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${LOCAL_ARCHIVE}" + PATCHES + android-cmake.diff + fix-compile-options.patch + fix-find-threads.patch +) + +if("asm" IN_LIST FEATURES) + vcpkg_find_acquire_program(NASM) + get_filename_component(NASM_PATH "${NASM}" DIRECTORY) + vcpkg_add_to_path("${NASM_PATH}") +endif() + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + asm WITH_ASM + stack-protector WITH_STACK_PROTECTOR + multithreading ENABLE_MULTITHREADING +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + -DBUILD_PROGRAMS=OFF + -DBUILD_EXAMPLES=OFF + -DBUILD_DOCS=OFF + -DBUILD_TESTING=OFF + -DINSTALL_MANPAGES=OFF +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(PACKAGE_NAME FLAC CONFIG_PATH lib/cmake/FLAC) + +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +file(REMOVE "${CURRENT_PACKAGES_DIR}/share/LICENSE") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/FLAC/export.h" + "#if defined(FLAC__NO_DLL)" + "#if 0" + ) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/FLAC++/export.h" + "#if defined(FLAC__NO_DLL)" + "#if 0" + ) +else() + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/FLAC/export.h" + "#if defined(FLAC__NO_DLL)" + "#if 1" + ) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/FLAC++/export.h" + "#if defined(FLAC__NO_DLL)" + "#if 1" + ) +endif() + +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/flac.pc" " -lm" "") + + if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/flac.pc") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/flac.pc" " -lm" "") + endif() +endif() + +vcpkg_fixup_pkgconfig() + +# This license (BSD) is relevant only for library - if someone would want to install +# FLAC cmd line tools as well additional license (GPL) should be included +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING.Xiph") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/Tools/CMake/vcpkg/ports/libflac/usage b/Tools/CMake/vcpkg/ports/libflac/usage new file mode 100644 index 000000000..99b4c8019 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libflac/usage @@ -0,0 +1,8 @@ +The package libflac provides CMake targets: + + find_package(FLAC CONFIG REQUIRED) + target_link_libraries(main PRIVATE FLAC::FLAC) + + # Or use the C++ API + find_package(FLAC CONFIG REQUIRED) + target_link_libraries(main PRIVATE FLAC::FLAC++) diff --git a/Tools/CMake/vcpkg/ports/libflac/vcpkg.json b/Tools/CMake/vcpkg/ports/libflac/vcpkg.json new file mode 100644 index 000000000..9c55a31de --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libflac/vcpkg.json @@ -0,0 +1,37 @@ +{ + "name": "libflac", + "version": "1.5.0", + "description": "Library for manipulating FLAC files", + "homepage": "https://xiph.org/flac/", + "license": "BSD-3-Clause", + "dependencies": [ + "libogg", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + { + "name": "stack-protector", + "platform": "!emscripten" + } + ], + "features": { + "asm": { + "description": "Use any assembly optimization routines", + "supports": "x86" + }, + "multithreading": { + "description": "Enable multithreading if pthreads is available" + }, + "stack-protector": { + "description": "Build with stack smashing protection", + "supports": "!emscripten" + } + } +} diff --git a/Tools/CMake/vcpkg/ports/libogg/portfile.cmake b/Tools/CMake/vcpkg/ports/libogg/portfile.cmake new file mode 100644 index 000000000..b819dd52a --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libogg/portfile.cmake @@ -0,0 +1,32 @@ +set(LOCAL_ARCHIVE "$ENV{VCPKG_LIB_SOURCE_ROOT}/xiph-ogg-v1.3.6.tar.gz") + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${LOCAL_ARCHIVE}" +) + +if(VCPKG_TARGET_IS_MINGW) + vcpkg_replace_string("${SOURCE_PATH}/win32/ogg.def" "LIBRARY ogg" "LIBRARY libogg") +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 #https://gitlab.xiph.org/xiph/ogg/-/issues/2304 + -DINSTALL_DOCS=OFF + -DINSTALL_PKG_CONFIG_MODULE=ON + -DBUILD_TESTING=OFF + MAYBE_UNUSED_VARIABLES + CMAKE_POLICY_VERSION_MINIMUM +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/Ogg PACKAGE_NAME ogg) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_copy_pdbs() +vcpkg_fixup_pkgconfig() + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") diff --git a/Tools/CMake/vcpkg/ports/libogg/vcpkg.json b/Tools/CMake/vcpkg/ports/libogg/vcpkg.json new file mode 100644 index 000000000..afdc62459 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libogg/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "libogg", + "version": "1.3.6", + "port-version": 1, + "description": "Ogg is a multimedia container format, and the native file and stream format for the Xiph.org multimedia codecs.", + "homepage": "https://www.xiph.org/ogg", + "license": "BSD-3-Clause", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/Tools/CMake/vcpkg/ports/libsndfile/001-avoid-installing-find-modules.patch b/Tools/CMake/vcpkg/ports/libsndfile/001-avoid-installing-find-modules.patch new file mode 100644 index 000000000..2d115999f --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libsndfile/001-avoid-installing-find-modules.patch @@ -0,0 +1,16 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b501f08..022864f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -855,11 +847,6 @@ if (ENABLE_PACKAGE_CONFIG) + ${CMAKE_CURRENT_BINARY_DIR}/SndFileConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} + ) +- +- if (NOT BUILD_SHARED_LIBS AND FIND_MODULES_INSTALL_LIST) +- file(COPY ${FIND_MODULES_INSTALL_LIST} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +- install(FILES ${FIND_MODULES_INSTALL_LIST} DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) +- endif () + else () + + install (TARGETS sndfile ${sdnfile_PROGRAMS} diff --git a/Tools/CMake/vcpkg/ports/libsndfile/mp3lame-static.diff b/Tools/CMake/vcpkg/ports/libsndfile/mp3lame-static.diff new file mode 100644 index 000000000..a77759a13 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libsndfile/mp3lame-static.diff @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b501f08..946c321 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -236,6 +236,10 @@ if (INSTALL_PKGCONFIG_MODULE) + if (ENABLE_MPEG) + set (EXTERNAL_MPEG_REQUIRE "libmpg123") + set (EXTERNAL_MPEG_LIBS "-lmp3lame") ++ get_target_property(mp3lame_binary mp3lame::mp3lame IMPORTED_LOCATION_RELEASE) ++ if(mp3lame_binary MATCHES "mp3lame-static") ++ set (EXTERNAL_MPEG_LIBS "-lmp3lame-static -lmpghip-static") ++ endif() + endif () + + configure_file (sndfile.pc.in sndfile.pc @ONLY) diff --git a/Tools/CMake/vcpkg/ports/libsndfile/portfile.cmake b/Tools/CMake/vcpkg/ports/libsndfile/portfile.cmake new file mode 100644 index 000000000..e5c65c2ea --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libsndfile/portfile.cmake @@ -0,0 +1,59 @@ +set(LOCAL_ARCHIVE "$ENV{VCPKG_LIB_SOURCE_ROOT}/libsndfile-libsndfile-1.2.2.tar.gz") + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${LOCAL_ARCHIVE}" + PATCHES + 001-avoid-installing-find-modules.patch + mp3lame-static.diff +) + +if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + vcpkg_find_acquire_program(PYTHON3) +endif() + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + external-libs ENABLE_EXTERNAL_LIBS + mpeg ENABLE_MPEG + regtest BUILD_REGTEST +) + +if(VCPKG_TARGET_IS_UWP) + set(VCPKG_C_FLAGS "/sdl- ${VCPKG_C_FLAGS}") + set(VCPKG_CXX_FLAGS "/sdl- ${VCPKG_CXX_FLAGS}") +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_EXAMPLES=OFF + -DBUILD_TESTING=OFF + -DENABLE_BOW_DOCS=OFF + -DBUILD_PROGRAMS=OFF + -DBUILD_REGTEST=OFF + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON + -DPYTHON_EXECUTABLE=${PYTHON3} + ${FEATURE_OPTIONS} + MAYBE_UNUSED_VARIABLES + PYTHON_EXECUTABLE +) + +vcpkg_cmake_install() + +if(EXISTS "${CURRENT_PACKAGES_DIR}/cmake") + set(CONFIG_PATH cmake) +else() + set(CONFIG_PATH lib/cmake/SndFile) +endif() + +vcpkg_cmake_config_fixup(PACKAGE_NAME SndFile CONFIG_PATH "${CONFIG_PATH}") +vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES m) + +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/doc") + +file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/Tools/CMake/vcpkg/ports/libsndfile/vcpkg.json b/Tools/CMake/vcpkg/ports/libsndfile/vcpkg.json new file mode 100644 index 000000000..232a349d0 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libsndfile/vcpkg.json @@ -0,0 +1,52 @@ +{ + "name": "libsndfile", + "version-semver": "1.2.2", + "port-version": 1, + "description": "A library for reading and writing audio files", + "homepage": "https://github.com/erikd/libsndfile", + "license": "LGPL-2.1-or-later", + "supports": "!xbox", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "external-libs", + "mpeg" + ], + "features": { + "experimental": { + "description": "Enable experimental code", + "dependencies": [ + "speex" + ] + }, + "external-libs": { + "description": "Enable FLAC, Vorbis, and Opus codecs", + "dependencies": [ + "libflac", + "libvorbis", + "opus" + ] + }, + "mpeg": { + "description": "Enable MPEG codecs", + "dependencies": [ + "mp3lame", + "mpg123" + ] + }, + "regtest": { + "description": "Build regtest", + "dependencies": [ + "sqlite3" + ] + } + } +} diff --git a/Tools/CMake/vcpkg/ports/libtheora/CMakeLists.txt b/Tools/CMake/vcpkg/ports/libtheora/CMakeLists.txt new file mode 100644 index 000000000..b4bf85cf3 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libtheora/CMakeLists.txt @@ -0,0 +1,160 @@ +cmake_minimum_required(VERSION 3.30) +project(theora LANGUAGES C) + +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}") +set(OGG_REQUIRED_VERSION 1.3.4) +find_package(Ogg "${OGG_REQUIRED_VERSION}" CONFIG REQUIRED) + +file(GLOB HEADERS + "include/theora/codec.h" + "include/theora/theora.h" + "include/theora/theoradec.h" + "include/theora/theoraenc.h" +) + +if(MSVC) + set(LIBTHEORA_COMMON_X86 + "lib/x86_vc/mmxfrag.c" + "lib/x86_vc/mmxidct.c" + "lib/x86_vc/mmxstate.c" + "lib/x86_vc/x86cpu.c" + "lib/x86_vc/x86state.c" + ) +else() + set(LIBTHEORA_COMMON_X86 + "lib/x86/mmxfrag.c" + "lib/x86/mmxidct.c" + "lib/x86/mmxstate.c" + "lib/x86/sse2idct.c" + "lib/x86/x86cpu.c" + "lib/x86/x86state.c" + ) +endif() + +set(LIBTHEORA_COMMON + "lib/apiwrapper.c" + "lib/bitpack.c" + "lib/dequant.c" + "lib/fragment.c" + "lib/idct.c" + "lib/info.c" + "lib/internal.c" + "lib/state.c" + "lib/quant.c" + + ${LIBTHEORA_COMMON_X86} +) + +if(MSVC) + set(LIBTHEORA_ENC_X86 + "lib/x86_vc/mmxencfrag.c" + "lib/x86_vc/mmxfdct.c" + "lib/x86_vc/x86enc.c" + ) +else() + set(LIBTHEORA_ENC_X86 + "lib/x86/mmxencfrag.c" + "lib/x86/mmxfdct.c" + "lib/x86/x86enc.c" + "lib/x86/x86enquant.c" + "lib/x86/sse2encfrag.c" + ) +endif() + +set(LIBTHEORA_ENC + "lib/analyze.c" + "lib/encapiwrapper.c" + "lib/encfrag.c" + "lib/encinfo.c" + "lib/encode.c" + "lib/enquant.c" + "lib/fdct.c" + "lib/huffenc.c" + "lib/mathops.c" + "lib/mcenc.c" + "lib/rate.c" + "lib/tokenize.c" + + ${LIBTHEORA_ENC_X86} +) + +set(LIBTHEORA_DEC + "lib/decapiwrapper.c" + "lib/decinfo.c" + "lib/decode.c" + "lib/huffdec.c" +) + +add_definitions(-D_CRT_SECURE_NO_DEPRECATE) +add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + +option(USE_X86 "Use x86 optimization" OFF) +if(USE_X86) + add_definitions(-DOC_X86_ASM) +endif() + +if (BUILD_SHARED_LIBS) + add_definitions(-DLIBTHEORA_EXPORTS) +endif() + +add_library(theora-common OBJECT ${LIBTHEORA_COMMON} ${HEADERS}) +target_link_libraries(theora-common PUBLIC Ogg::ogg) +target_include_directories(theora-common PUBLIC $ $) +add_library(theora-enc OBJECT ${LIBTHEORA_ENC} ${HEADERS}) +target_link_libraries(theora-enc PUBLIC Ogg::ogg) +target_include_directories(theora-enc PUBLIC $ $) +add_library(theora-dec OBJECT ${LIBTHEORA_DEC} ${HEADERS}) +target_link_libraries(theora-dec PUBLIC Ogg::ogg) +target_include_directories(theora-dec PUBLIC $ $) + +add_library(theora $ $ $ "libtheora.def") +target_link_libraries(theora PUBLIC Ogg::ogg) +target_include_directories(theora PUBLIC $ $) + +add_library(theoraenc $ $ "win32/xmingw32/libtheoraenc-all.def") +target_link_libraries(theoraenc PUBLIC Ogg::ogg) +target_include_directories(theoraenc PUBLIC $ $) + +add_library(theoradec $ $ "win32/xmingw32/libtheoradec-all.def") +target_link_libraries(theoradec PUBLIC Ogg::ogg) +target_include_directories(theoradec PUBLIC $ $) + +include(CMakePackageConfigHelpers) + +configure_package_config_file(unofficial-theora-config.cmake.in unofficial-theora-config.cmake + INSTALL_DESTINATION "lib/unofficial-theora") + +install(FILES ${HEADERS} DESTINATION include/theora) + +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-theora-config.cmake" + DESTINATION "lib/unofficial-theora" +) + +install(TARGETS theora theoraenc theoradec + EXPORT unofficial-theora-targets + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +install(EXPORT unofficial-theora-targets + NAMESPACE unofficial::theora:: + DESTINATION "lib/unofficial-theora" +) + +block(SCOPE_FOR VARIABLES) + set(prefix "${CMAKE_INSTALL_PREFIX}") + set(libdir "\${prefix}/lib") + set(exec_prefix "\${prefix}") + set(includedir "\${prefix}/include") + set(THEORA_LIBOGG_REQ_VERSION "${OGG_REQUIRED_VERSION}") + configure_file(theora.pc.in theora.pc @ONLY) + configure_file(theoradec.pc.in theoradec.pc @ONLY) + configure_file(theoraenc.pc.in theoraenc.pc @ONLY) +endblock() + +install( + FILES "${PROJECT_BINARY_DIR}/theora.pc" "${PROJECT_BINARY_DIR}/theoradec.pc" "${PROJECT_BINARY_DIR}/theoraenc.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" +) diff --git a/Tools/CMake/vcpkg/ports/libtheora/libtheora.def b/Tools/CMake/vcpkg/ports/libtheora/libtheora.def new file mode 100644 index 000000000..9755b81e7 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libtheora/libtheora.def @@ -0,0 +1,61 @@ +EXPORTS +; Old alpha API + theora_version_string + theora_version_number + theora_decode_header + theora_decode_init + theora_decode_packetin + theora_decode_YUVout + theora_control + theora_packet_isheader + theora_packet_iskeyframe + theora_granule_shift + theora_granule_frame + theora_granule_time + theora_info_init + theora_info_clear + theora_clear + theora_comment_init + theora_comment_add + theora_comment_add_tag + theora_comment_query + theora_comment_query_count + theora_comment_clear +; New theora-exp API + th_version_string + th_version_number + th_decode_headerin + th_decode_alloc + th_setup_free + th_decode_ctl + th_decode_packetin + th_decode_ycbcr_out + th_decode_free + th_packet_isheader + th_packet_iskeyframe + th_granule_frame + th_granule_time + th_info_init + th_info_clear + th_comment_init + th_comment_add + th_comment_add_tag + th_comment_query + th_comment_query_count + th_comment_clear +; Old alpha API + theora_encode_init + theora_encode_YUVin + theora_encode_packetout + theora_encode_header + theora_encode_comment + theora_encode_tables +; New theora-exp API + th_encode_alloc + th_encode_ctl + th_encode_flushheader + th_encode_ycbcr_in + th_encode_packetout + th_encode_free + TH_VP31_QUANT_INFO + TH_VP31_HUFF_CODES diff --git a/Tools/CMake/vcpkg/ports/libtheora/portfile.cmake b/Tools/CMake/vcpkg/ports/libtheora/portfile.cmake new file mode 100644 index 000000000..50cd04d0c --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libtheora/portfile.cmake @@ -0,0 +1,32 @@ +set(LOCAL_ARCHIVE "$ENV{VCPKG_LIB_SOURCE_ROOT}/xiph-theora-v1.2.0.tar.gz") + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${LOCAL_ARCHIVE}" +) + +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/libtheora.def" DESTINATION "${SOURCE_PATH}") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-theora-config.cmake.in" DESTINATION "${SOURCE_PATH}") + +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(THEORA_X86_OPT ON) +else() + set(THEORA_X86_OPT OFF) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + "-DVERSION:STRING=${VERSION}" + -DUSE_X86=${THEORA_X86_OPT} +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH "lib/unofficial-theora" PACKAGE_NAME "unofficial-theora") +vcpkg_fixup_pkgconfig() +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING" "${SOURCE_PATH}/LICENSE") diff --git a/Tools/CMake/vcpkg/ports/libtheora/unofficial-theora-config.cmake.in b/Tools/CMake/vcpkg/ports/libtheora/unofficial-theora-config.cmake.in new file mode 100644 index 000000000..98f152e94 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libtheora/unofficial-theora-config.cmake.in @@ -0,0 +1,6 @@ +@PACKAGE_INIT@ +include(CMakeFindDependencyMacro) + +find_dependency(Ogg CONFIG) + +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-theora-targets.cmake") diff --git a/Tools/CMake/vcpkg/ports/libtheora/vcpkg.json b/Tools/CMake/vcpkg/ports/libtheora/vcpkg.json new file mode 100644 index 000000000..08410a644 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libtheora/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "libtheora", + "version": "1.2.0", + "description": "Theora is a free and open video compression format from the Xiph.org Foundation.", + "homepage": "https://github.com/xiph/theora", + "license": null, + "dependencies": [ + "libogg", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/Tools/CMake/vcpkg/ports/libvorbis/0001-Dont-export-vorbisenc-functions.patch b/Tools/CMake/vcpkg/ports/libvorbis/0001-Dont-export-vorbisenc-functions.patch new file mode 100644 index 000000000..f2bab5c6f --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libvorbis/0001-Dont-export-vorbisenc-functions.patch @@ -0,0 +1,16 @@ +diff --git a/win32/vorbis.def b/win32/vorbis.def +index 9cca64d..a80fff7 100644 +--- a/win32/vorbis.def ++++ b/win32/vorbis.def +@@ -49,11 +49,4 @@ vorbis_synthesis_idheader + ; + vorbis_window + ;_analysis_output_always +-vorbis_encode_init +-vorbis_encode_setup_managed +-vorbis_encode_setup_vbr +-vorbis_encode_init_vbr +-vorbis_encode_setup_init +-vorbis_encode_ctl +-; + vorbis_version_string diff --git a/Tools/CMake/vcpkg/ports/libvorbis/0002-Fixup-pkgconfig-libs.patch b/Tools/CMake/vcpkg/ports/libvorbis/0002-Fixup-pkgconfig-libs.patch new file mode 100644 index 000000000..85508f16f --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libvorbis/0002-Fixup-pkgconfig-libs.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f377c428..07530304 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -60,6 +60,9 @@ message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}") + # Find math library + + check_library_exists(m floor "" HAVE_LIBM) ++if(HAVE_LIBM) ++ set(VORBIS_LIBS "-lm") ++endif() + + # Find ogg dependency + find_package(Ogg REQUIRED) + diff --git a/Tools/CMake/vcpkg/ports/libvorbis/0003-def-mingw-compat.patch b/Tools/CMake/vcpkg/ports/libvorbis/0003-def-mingw-compat.patch new file mode 100644 index 000000000..f1622d982 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libvorbis/0003-def-mingw-compat.patch @@ -0,0 +1,33 @@ +diff --git a/win32/vorbis.def b/win32/vorbis.def +index 1310b6c..de14385 100644 +--- a/win32/vorbis.def ++++ b/win32/vorbis.def +@@ -1,6 +1,5 @@ + ; vorbis.def + ; +-LIBRARY + EXPORTS + _floor_P + _mapping_P +diff --git a/win32/vorbisenc.def b/win32/vorbisenc.def +index 79af064..40a3e39 100644 +--- a/win32/vorbisenc.def ++++ b/win32/vorbisenc.def +@@ -1,6 +1,5 @@ + ; vorbisenc.def + ; +-LIBRARY + + EXPORTS + vorbis_encode_init +diff --git a/win32/vorbisfile.def b/win32/vorbisfile.def +index 4dc5549..243795d 100644 +--- a/win32/vorbisfile.def ++++ b/win32/vorbisfile.def +@@ -1,6 +1,5 @@ + ; vorbisfile.def + ; +-LIBRARY + EXPORTS + ov_clear + ov_open diff --git a/Tools/CMake/vcpkg/ports/libvorbis/0004-ogg-find-dependency.patch b/Tools/CMake/vcpkg/ports/libvorbis/0004-ogg-find-dependency.patch new file mode 100644 index 000000000..6db3eb14e --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libvorbis/0004-ogg-find-dependency.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/VorbisConfig.cmake.in b/cmake/VorbisConfig.cmake.in +index 6fc07941..c762ba55 100644 +--- a/cmake/VorbisConfig.cmake.in ++++ b/cmake/VorbisConfig.cmake.in +@@ -1,7 +1,7 @@ + @PACKAGE_INIT@ + + include(CMakeFindDependencyMacro) +-find_dependency(Ogg REQUIRED) ++find_dependency(Ogg CONFIG) + + include(${CMAKE_CURRENT_LIST_DIR}/VorbisTargets.cmake) + diff --git a/Tools/CMake/vcpkg/ports/libvorbis/portfile.cmake b/Tools/CMake/vcpkg/ports/libvorbis/portfile.cmake new file mode 100644 index 000000000..5f2625f47 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libvorbis/portfile.cmake @@ -0,0 +1,29 @@ +set(LOCAL_ARCHIVE "$ENV{VCPKG_LIB_SOURCE_ROOT}/xiph-vorbis-v1.3.7.tar.gz") + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${LOCAL_ARCHIVE}" + PATCHES + 0001-Dont-export-vorbisenc-functions.patch + 0002-Fixup-pkgconfig-libs.patch + 0003-def-mingw-compat.patch + 0004-ogg-find-dependency.patch +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 # https://github.com/xiph/vorbis/issues/113 + MAYBE_UNUSED_VARIABLES + CMAKE_POLICY_VERSION_MINIMUM +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(PACKAGE_NAME Vorbis CONFIG_PATH "lib/cmake/Vorbis") +vcpkg_fixup_pkgconfig() +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/Tools/CMake/vcpkg/ports/libvorbis/usage b/Tools/CMake/vcpkg/ports/libvorbis/usage new file mode 100644 index 000000000..c20766a90 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libvorbis/usage @@ -0,0 +1,13 @@ +The package libvorbis provides CMake targets: + + # Vorbis reference encoder and decoder, low-level API + find_package(Vorbis CONFIG REQUIRED) + target_link_libraries(main PRIVATE Vorbis::vorbis) + + # Audio stream decoding and basic manipulation, high-level API + find_package(Vorbis CONFIG REQUIRED) + target_link_libraries(main PRIVATE Vorbis::vorbisfile) + + # Convenience API for setting up an encoding environment + find_package(Vorbis CONFIG REQUIRED) + target_link_libraries(main PRIVATE Vorbis::vorbisenc) diff --git a/Tools/CMake/vcpkg/ports/libvorbis/vcpkg.json b/Tools/CMake/vcpkg/ports/libvorbis/vcpkg.json new file mode 100644 index 000000000..4743d96f8 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/libvorbis/vcpkg.json @@ -0,0 +1,19 @@ +{ + "name": "libvorbis", + "version": "1.3.7", + "port-version": 4, + "description": "Ogg Vorbis is a fully open, non-proprietary, patent-and-royalty-free, general-purpose compressed audio format", + "homepage": "https://github.com/xiph/vorbis", + "license": "BSD-3-Clause", + "dependencies": [ + "libogg", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/Tools/CMake/vcpkg/ports/opus/fix-pkgconfig-version.patch b/Tools/CMake/vcpkg/ports/opus/fix-pkgconfig-version.patch new file mode 100644 index 000000000..ef9f7229c --- /dev/null +++ b/Tools/CMake/vcpkg/ports/opus/fix-pkgconfig-version.patch @@ -0,0 +1,15 @@ +diff --git a/cmake/OpusPackageVersion.cmake b/cmake/OpusPackageVersion.cmake +index 447ce3b..15ebd8e 100644 +--- a/cmake/OpusPackageVersion.cmake ++++ b/cmake/OpusPackageVersion.cmake +@@ -4,7 +4,9 @@ endif() + set(__opus_version INCLUDED) + + function(get_package_version PACKAGE_VERSION PROJECT_VERSION) +- ++ set(PACKAGE_VERSION "0" CACHE STRING "opus package version") ++ set(PROJECT_VERSION "0" CACHE STRING "opus project version") ++ return() + find_package(Git) + if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git") + execute_process(COMMAND ${GIT_EXECUTABLE} diff --git a/Tools/CMake/vcpkg/ports/opus/portfile.cmake b/Tools/CMake/vcpkg/ports/opus/portfile.cmake new file mode 100644 index 000000000..692d27f2f --- /dev/null +++ b/Tools/CMake/vcpkg/ports/opus/portfile.cmake @@ -0,0 +1,57 @@ +set(LOCAL_ARCHIVE "$ENV{VCPKG_LIB_SOURCE_ROOT}/xiph-opus-v1.5.2.tar.gz") + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${LOCAL_ARCHIVE}" + PATCHES fix-pkgconfig-version.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + avx2 AVX2_SUPPORTED +) + +set(STACK_PROTECTOR ON) +set(ADDITIONAL_OPUS_OPTIONS "") +if(VCPKG_TARGET_IS_MINGW) + set(STACK_PROTECTOR OFF) + string(APPEND VCPKG_C_FLAGS "-D_FORTIFY_SOURCE=0") + string(APPEND VCPKG_CXX_FLAGS "-D_FORTIFY_SOURCE=0") + if(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)64$") + list(APPEND ADDITIONAL_OPUS_OPTIONS "-DOPUS_USE_NEON=OFF") # for version 1.3.1 (remove for future Opus release) + list(APPEND ADDITIONAL_OPUS_OPTIONS "-DOPUS_DISABLE_INTRINSICS=ON") # for HEAD (and future Opus release) + endif() +elseif(VCPKG_TARGET_IS_WINDOWS) + if(VCPKG_CRT_LINKAGE STREQUAL "static") + list(APPEND ADDITIONAL_OPUS_OPTIONS "-DOPUS_STATIC_RUNTIME=ON") + endif() +elseif(VCPKG_TARGET_IS_EMSCRIPTEN) + set(STACK_PROTECTOR OFF) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS ${FEATURE_OPTIONS} + -DPACKAGE_VERSION=${VERSION} + -DOPUS_STACK_PROTECTOR=${STACK_PROTECTOR} + -DOPUS_INSTALL_PKG_CONFIG_MODULE=ON + -DOPUS_INSTALL_CMAKE_CONFIG_MODULE=ON + -DOPUS_BUILD_PROGRAMS=OFF + -DOPUS_BUILD_TESTING=OFF + ${ADDITIONAL_OPUS_OPTIONS} + MAYBE_UNUSED_VARIABLES + OPUS_USE_NEON + OPUS_DISABLE_INTRINSICS +) +vcpkg_cmake_install() +vcpkg_copy_pdbs() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/Opus) +vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES m) + + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/cmake" + "${CURRENT_PACKAGES_DIR}/lib/cmake" + "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") diff --git a/Tools/CMake/vcpkg/ports/opus/vcpkg.json b/Tools/CMake/vcpkg/ports/opus/vcpkg.json new file mode 100644 index 000000000..1afe66a92 --- /dev/null +++ b/Tools/CMake/vcpkg/ports/opus/vcpkg.json @@ -0,0 +1,23 @@ +{ + "name": "opus", + "version": "1.5.2", + "port-version": 1, + "description": "Totally open, royalty-free, highly versatile audio codec", + "homepage": "https://github.com/xiph/opus", + "license": "BSD-3-Clause", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "avx2": { + "description": "Builds the library with avx2 instruction set" + } + } +} diff --git a/Tools/CMake/vcpkg/triplets/universal-osx-11-release.cmake b/Tools/CMake/vcpkg/triplets/universal-osx-11-release.cmake new file mode 100644 index 000000000..ebbf72f58 --- /dev/null +++ b/Tools/CMake/vcpkg/triplets/universal-osx-11-release.cmake @@ -0,0 +1,19 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) + +if(${PORT} MATCHES "sdl2|openal-soft|libsndfile") + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE dynamic) +else() + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE static) +endif() + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES "arm64;x86_64") + +set(VCPKG_CMAKE_SYSTEM_VERSION 11.0) +set(VCPKG_OSX_DEPLOYMENT_TARGET 11.0) +set(VCPKG_C_FLAGS -mmacosx-version-min=11.0) +set(VCPKG_CXX_FLAGS -mmacosx-version-min=11.0) + +set(VCPKG_BUILD_TYPE release) \ No newline at end of file diff --git a/Tools/CMake/vcpkg/triplets/universal-osx-11.cmake b/Tools/CMake/vcpkg/triplets/universal-osx-11.cmake new file mode 100644 index 000000000..752622a95 --- /dev/null +++ b/Tools/CMake/vcpkg/triplets/universal-osx-11.cmake @@ -0,0 +1,17 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) + +if(${PORT} MATCHES "sdl2|openal-soft|libsndfile") + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE dynamic) +else() + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE static) +endif() + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES "arm64;x86_64") + +set(VCPKG_CMAKE_SYSTEM_VERSION 11.0) +set(VCPKG_OSX_DEPLOYMENT_TARGET 11.0) +set(VCPKG_C_FLAGS -mmacosx-version-min=11.0) +set(VCPKG_CXX_FLAGS -mmacosx-version-min=11.0) diff --git a/Tools/CMake/vcpkg/triplets/x64-linux-mixed-release.cmake b/Tools/CMake/vcpkg/triplets/x64-linux-mixed-release.cmake new file mode 100644 index 000000000..86b20c770 --- /dev/null +++ b/Tools/CMake/vcpkg/triplets/x64-linux-mixed-release.cmake @@ -0,0 +1,12 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) + +if(${PORT} MATCHES "sdl2|openal-soft|libsndfile") + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE dynamic) +else() + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE static) +endif() + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) +set(VCPKG_BUILD_TYPE release) \ No newline at end of file diff --git a/Tools/CMake/vcpkg/triplets/x64-linux-mixed.cmake b/Tools/CMake/vcpkg/triplets/x64-linux-mixed.cmake new file mode 100644 index 000000000..39b5b0434 --- /dev/null +++ b/Tools/CMake/vcpkg/triplets/x64-linux-mixed.cmake @@ -0,0 +1,11 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) + +if(${PORT} MATCHES "sdl2|openal-soft|libsndfile") + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE dynamic) +else() + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE static) +endif() + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) diff --git a/Tools/CMake/vcpkg/triplets/x64-windows-mixed-release.cmake b/Tools/CMake/vcpkg/triplets/x64-windows-mixed-release.cmake new file mode 100644 index 000000000..7fff0e867 --- /dev/null +++ b/Tools/CMake/vcpkg/triplets/x64-windows-mixed-release.cmake @@ -0,0 +1,11 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) + +if(${PORT} MATCHES "sdl2|openal-soft|libsndfile") + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE dynamic) +else() + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE static) +endif() + +set(VCPKG_BUILD_TYPE release) \ No newline at end of file diff --git a/Tools/CMake/vcpkg/triplets/x64-windows-mixed.cmake b/Tools/CMake/vcpkg/triplets/x64-windows-mixed.cmake new file mode 100644 index 000000000..0c95d519f --- /dev/null +++ b/Tools/CMake/vcpkg/triplets/x64-windows-mixed.cmake @@ -0,0 +1,9 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) + +if(${PORT} MATCHES "sdl2|openal-soft|libsndfile") + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE dynamic) +else() + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE static) +endif() diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 000000000..eb5e7ae38 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,23 @@ +{ + "name": "torque3d", + "builtin-baseline": "74e6536215718009aae747d86d84b78376bf9e09", + "dependencies": [ + "libogg", + "libvorbis", + "libflac", + "opus", + "libtheora", + { + "name": "libsndfile", + "default-features": false, + "features": [ "external-libs" ] + } + ], + "overrides":[ + { "name": "libogg", "version": "1.3.6"}, + { "name": "libvorbis", "version": "1.3.7"}, + { "name": "libflac", "version": "1.5.0"}, + { "name": "opus", "version": "1.5.2"}, + { "name": "libtheora", "version": "1.2.0"} + ] +} \ No newline at end of file